postbooks-schema-quickstart-4.9.2/0000755000175000017500000000000012603675632016463 5ustar danieldanielpostbooks-schema-quickstart-4.9.2/init.sql0000644000175000017500000000062512603675632020152 0ustar danieldaniel-- -- This script creates the group xtrole and the user admin -- -- -- Create the xtrole group -- CREATE GROUP xtrole; -- -- Create the admin user with createdb and createuser -- permissions. Place the user in the xtrole group and -- set the password to the default of admin. -- CREATE USER admin WITH PASSWORD 'admin' CREATEDB CREATEUSER IN GROUP xtrole; postbooks-schema-quickstart-4.9.2/INSTALL.txt0000644000175000017500000000722612603675632020341 0ustar danieldanielInstalling xTuple ERP =========================================== Last Updated: February 9, 2012 Thank you for your interest in xTuple ERP: PostBooks Edition, an OSI-certified open source application from xTuple. This file provides a brief overview of the steps required to manually prepare your PostgreSQL server to run xTuple ERP: PostBooks Edition. For up-to-date instructions and full details, please visit xtuple.org and click on Docs > Admin and Setup. The easiest way to get started is to use the xTuple all-in-one installer. The xTuple installer is available for Windows, Mac, and Linux. You can download the installer from the PostBooks-installers directory on the PostBooks SourceForge page. For more advanced users who prefer not to use the PostBooks installer, the following steps will get you started: 1. Install and configure PostgreSQL 2. Create the PostgreSQL database superuser 'admin' and the group 'xtrole' $ psql -U postgres -f init.sql template0 # see init.sql below 3. Create a new PostgreSQL database $ createdb -U admin production 4. Restore one of the xTuple starter databases into it (see Starter Databases below), for example: $ pg_restore -U admin -d production quickstart.backup -v PostgreSQL Considerations ------------------------- Before you can start using the xTuple Applications, you must first have PostgreSQL installed and properly configured. Check http://www.xtuple.org/compatibility-matrix to make sure the version of PostgreSQL you are running is compatible with the version of xTuple ERP you are installing. For additional information on installing PostgreSQL, please visit http://www.postgresql.org where you will find in-depth documentation and other resources related to PostgreSQL. Installation support is also available from xTuple. To learn more about xTuple's PostgreSQL services, please visit http://www.xtuple.com/postgres. NOTE: The xTuple applications require the PostgreSQL pgcrypto module. This is used for credit card processing and storing other sensitive information. You should be sure to include the pgcrypto module when installing PostgreSQL. If you do not, you will encounter errors when running the xTuple ERP application. init.sql: Creating the admin user and xtrole group -------------------------------------------------- Run the following SQL script using either psql, pgAdmin, or some other program that allows connecting directly to a PostgreSQL database server before creating your xTuple ERP database: -- -- This script creates the group xtrole and the user admin -- CREATE GROUP xtrole; -- Create the user 'admin' with the password 'admin', -- give it permission to create databases and users, -- and place it in the xtrole group. CREATE USER admin WITH PASSWORD 'admin' CREATEDB CREATEUSER IN GROUP xtrole; -- End of init.sql NOTE: Since the default password for the user admin is 'admin', you'll want to change it immediately. Starter databases ----------------- xTuple supplies three different databases to help get you started: * empty.backup This is an empty database with no data, but with all the tables and structures created. * quickstart.backup This database contains a basic Chart of Accounts and also the Account Assignments required to run the full range of transactions. * demo.backup This database contains a suite of sample data built on top of the 'quickstart' database ----------------- Again, thank you for your interest in xTuple ERP. You can find more information, full documentation, discussion forums, support options, training opportunities, and commercial offerings at http://www.xtuple.org postbooks-schema-quickstart-4.9.2/LICENSE.txt0000644000175000017500000006724412603675632020323 0ustar danieldanielCommon Public Attribution License Version 1.0 (CPAL) 1. Definitions 1.0.1 "Commercial Use" means distribution or otherwise making the Covered Code available to a third party. 1.1 "Contributor" means each entity that creates or contributes to the creation of Modifications. 1.2 "Contributor Version" means the combination of the Original Code, prior Modifications used by a Contributor, and the Modifications made by that particular Contributor. 1.3 "Covered Code" means the Original Code or Modifications or the combination of the Original Code and Modifications, in each case including portions thereof. 1.4 "Electronic Distribution Mechanism" means a mechanism generally accepted in the software development community for the electronic transfer of data. 1.5 "Executable" means Covered Code in any form other than Source Code. 1.6 "Initial Developer" means the individual or entity identified as the Initial Developer in the Source Code notice required by Exhibit A. 1.7 "Larger Work" means a work which combines Covered Code or portions thereof with code not governed by the terms of this License. 1.8 "License" means this document. 1.8.1 "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein. 1.9 "Modifications" means any addition to or deletion from the substance or structure of either the Original Code or any previous Modifications. When Covered Code is released as a series of files, a Modification is: A. Any addition to or deletion from the contents of a file containing Original Code or previous Modifications. B. Any new file that contains any part of the Original Code or previous Modifications. 1.10 "Original Code" means Source Code of computer software code which is described in the Source Code notice required by Exhibit A as Original Code, and which, at the time of its release under this License is not already Covered Code governed by this License. 1.10.1 "Patent Claims" means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor. 1.11 "Source Code" means the preferred form of the Covered Code for making modifications to it, including all modules it contains, plus any associated interface definition files, scripts used to control compilation and installation of an Executable, or source code differential comparisons against either the Original Code or another well known, available Covered Code of the Contributor's choice. The Source Code can be in a compressed or archival form, provided the appropriate decompression or de-archiving software is widely available for no charge. 1.12 "You" (or "Your") means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License or a future version of this License issued under Section 6.1. For legal entities, "You" includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. 2. Source Code License. 2.1 The Initial Developer Grant. The Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims: (a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer to use, reproduce, modify, display, perform, sublicense and distribute the Original Code (or portions thereof) with or without Modifications, and/or as part of a Larger Work; and (b) under Patents Claims infringed by the making, using or selling of Original Code, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Code (or portions thereof). (c) the licenses granted in this Section 2.1(a) and (b) are effective on the date Initial Developer first distributes Original Code under the terms of this License. (d) Notwithstanding Section 2.1(b) above, no patent license is granted: 1) for code that You delete from the Original Code; 2) separate from the Original Code; or 3) for infringements caused by: i) the modification of the Original Code or ii) the combination of the Original Code with other software or devices. 2.2 Contributor Grant. Subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license (a) under intellectual property rights (other than patent or trademark) Licensable by Contributor, to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof) either on an unmodified basis, with other Modifications, as Covered Code and/or as part of a Larger Work; and (b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications made by that Contributor (or portions thereof); and 2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination). (c) the licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first makes Commercial Use of the Covered Code. (d) Notwithstanding Section 2.2(b) above, no patent license is granted: 1) for any code that Contributor has deleted from the Contributor Version; 2) separate from the Contributor Version; 3) for infringements caused by: i) third party modifications of Contributor Version or ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or 4) under Patent Claims infringed by Covered Code in the absence of Modifications made by that Contributor. 3. Distribution Obligations. 3.1 Application of License. The Modifications which You create or to which You contribute are governed by the terms of this License, including without limitation Section 2.2. The Source Code version of Covered Code may be distributed only under the terms of this License or a future version of this License released under Section 6.1, and You must include a copy of this License with every copy of the Source Code You distribute. You may not offer or impose any terms on any Source Code version that alters or restricts the applicable version of this License or the recipients' rights hereunder. However, You may include an additional document offering the additional rights described in Section 3.5. 3.2 Availability of Source Code. Any Modification which You create or to which You contribute must be made available in Source Code form under the terms of this License either on the same media as an Executable version or via an accepted Electronic Distribution Mechanism to anyone to whom you made an Executable version available; and if made available via Electronic Distribution Mechanism, must remain available for at least twelve (12) months after the date it initially became available, or at least six (6) months after a subsequent version of that particular Modification has been made available to such recipients. You are responsible for ensuring that the Source Code version remains available even if the Electronic Distribution Mechanism is maintained by a third party. 3.3 Description of Modifications. You must cause all Covered Code to which You contribute to contain a file documenting the changes You made to create that Covered Code and the date of any change. You must include a prominent statement that the Modification is derived, directly or indirectly, from Original Code provided by the Initial Developer and including the name of the Initial Developer in (a) the Source Code, and (b) in any notice in an Executable version or related documentation in which You describe the origin or ownership of the Covered Code. 3.4 Intellectual Property Matters (a) Third Party Claims. If Contributor has knowledge that a license under a third party's intellectual property rights is required to exercise the rights granted by such Contributor under Sections 2.1 or 2.2, Contributor must include a text file with the Source Code distribution titled "LEGAL" which describes the claim and the party making the claim in sufficient detail that a recipient will know whom to contact. If Contributor obtains such knowledge after the Modification is made available as described in Section 3.2, Contributor shall promptly modify the LEGAL file in all copies Contributor makes available thereafter and shall take other steps (such as notifying appropriate mailing lists or newsgroups) reasonably calculated to inform those who received the Covered Code that new knowledge has been obtained. (b) Contributor APIs. If Contributor's Modifications include an application programming interface and Contributor has knowledge of patent licenses which are reasonably necessary to implement that API, Contributor must also include this information in the LEGAL file. (c) Representations. Contributor represents that, except as disclosed pursuant to Section 3.4(a) above, Contributor believes that Contributor's Modifications are Contributor's original creation(s) and/or Contributor has sufficient rights to grant the rights conveyed by this License. 3.5 Required Notices. You must duplicate the notice in Exhibit A in each file of the Source Code. If it is not possible to put such notice in a particular Source Code file due to its structure, then You must include such notice in a location (such as a relevant directory) where a user would be likely to look for such a notice. If You created one or more Modification(s) You may add your name as a Contributor to the notice described in Exhibit A. You must also duplicate this License in any documentation for the Source Code where You describe recipients' rights or ownership rights relating to Covered Code. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Code. However, You may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear than any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer. 3.6 Distribution of Executable Versions. You may distribute Covered Code in Executable form only if the requirements of Section 3.1-3.5 have been met for that Covered Code, and if You include a notice stating that the Source Code version of the Covered Code is available under the terms of this License, including a description of how and where You have fulfilled the obligations of Section 3.2. The notice must be conspicuously included in any notice in an Executable version, related documentation or collateral in which You describe recipients' rights relating to the Covered Code. You may distribute the Executable version of Covered Code or ownership rights under a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable version does not attempt to limit or alter the recipient's rights in the Source Code version from the rights set forth in this License. If You distribute the Executable version under a different license You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer, Original Developer or any Contributor. You hereby agree to indemnify the Initial Developer, Original Developer and every Contributor for any liability incurred by the Initial Developer, Original Developer or such Contributor as a result of any such terms You offer. 3.7 Larger Works. You may create a Larger Work by combining Covered Code with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Code. 4. Inability to Comply Due to Statute or Regulation. If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Code due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be included in the LEGAL file described in Section 3.4 and must be included with all distributions of the Source Code. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. 5. Application of this License. This License applies to code to which the Initial Developer has attached the notice in Exhibit A and to related Covered Code. 6. Versions of the License. 6.1 New Versions. Socialtext, Inc. ("Socialtext") may publish revised and/or new versions of the License from time to time. Each version will be given a distinguishing version number. 6.2 Effect of New Versions. Once Covered Code has been published under a particular version of the License, You may always continue to use it under the terms of that version. You may also choose to use such Covered Code under the terms of any subsequent version of the License published by Socialtext. No one other than Socialtext has the right to modify the terms applicable to Covered Code created under this License. 6.3 Derivative Works. If You create or use a modified version of this License (which you may only do in order to apply it to code which is not already Covered Code governed by this License), You must (a) rename Your license so that the phrases "Socialtext", "CPAL" or any confusingly similar phrase do not appear in your license (except to note that your license differs from this License) and (b) otherwise make it clear that Your version of the license contains terms which differ from the CPAL. (Filling in the name of the Initial Developer, Original Developer, Original Code or Contributor in the notice described in Exhibit A shall not of themselves be deemed to be modifications of this License.) 7. DISCLAIMER OF WARRANTY. COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER, ORIGINAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. 8. TERMINATION. 8.1 This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. All sublicenses to the Covered Code which are properly granted shall survive any termination of this License. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive. 8.2 If You initiate litigation by asserting a patent infringement claim (excluding declatory judgment actions) against Initial Developer, Original Developer or a Contributor (the Initial Developer, Original Developer or Contributor against whom You file such action is referred to as "Participant") alleging that: (a) such Participant's Contributor Version directly or indirectly infringes any patent, then any and all rights granted by such Participant to You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively, unless if within 60 days after receipt of notice You either: (i) agree in writing to pay Participant a mutually agreeable reasonable royalty for Your past and future use of Modifications made by such Participant, or (ii) withdraw Your litigation claim with respect to the Contributor Version against such Participant. If within 60 days of notice, a reasonable royalty and payment arrangement are not mutually agreed upon in writing by the parties or the litigation claim is not withdrawn, the rights granted by Participant to You under Sections 2.1 and/or 2.2 automatically terminate at the expiration of the 60 day notice period specified above. (b) any software, hardware, or device, other than such Participant's Contributor Version, directly or indirectly infringes any patent, then any rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are revoked effective as of the date You first made, used, sold, distributed, or had made, Modifications made by that Participant. 8.3 If You assert a patent infringement claim against Participant alleging that such Participant's Contributor Version directly or indirectly infringes any patent where such claim is resolved (such as by license or settlement) prior to the initiation of patent infringement litigation, then the reasonable value of the licenses granted by such Participant under Sections 2.1 or 2.2 shall be taken into account in determining the amount or value of any payment or license. 8.4 In the event of termination under Sections 8.1 or 8.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or any distributor hereunder prior to termination shall survive termination. 9. LIMITATION OF LIABILITY. UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ORIGINAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. 10. U.S. GOVERNMENT END USERS. The Covered Code is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and "commercial computer software documentation," as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Code with only those rights set forth herein. 11. MISCELLANEOUS. This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by Virginia law provisions (except to the extent applicable law, if any, provides otherwise), excluding its conflict-of-law provisions. With respect to disputes in which at least one party is a citizen of, or an entity chartered or registered to do business in the United States of America, any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of Virginia, with venue lying in Norfolk, Virginia, with the losing party responsible for costs, including without limitation, court costs and reasonable attorneys' fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. 12. RESPONSIBILITY FOR CLAIMS. As between Initial Developer, Original Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer, Original Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability. 13. MULTIPLE-LICENSED CODE. Initial Developer may designate portions of the Covered Code as Multiple-Licensed. Multiple-Licensed means that the Initial Developer permits you to utilize portions of the Covered Code under Your choice of the CPAL or the alternative licenses, if any, specified by the Initial Developer in the file described in Exhibit A. 14. ADDITIONAL TERM: ATTRIBUTION (a) As a modest attribution to the organizer of the development of the Original Code ("Original Developer"), in the hope that its promotional value may help justify the time, money and effort invested in writing the Original Code, the Original Developer may include in Exhibit B ("Attribution Information") a requirement that each time an Executable and Source Code or a Larger Work is launched or initially run (which includes initiating a session), a prominent display of the Original Developer's Attribution Information (as defined below) must occur on the graphic user interface employed by the end user to access such Covered Code (which may include display on a splash screen), if any. The size of the graphic image should be consistent with the size of the other elements of the Attribution Information. If the access by the end user to the Executable and Source Code does not create a graphic user interface for access to the Covered Code, this obligation shall not apply. If the Original Code displays such Attribution Information in a particular form (such as in the form of a splash screen, notice at login, an "about" display, or dedicated attribution area on user interface screens), continued use of such form for that Attribution Information is one way of meeting this requirement for notice. (b) Attribution information may only include a copyright notice, a brief phrase, graphic image and a URL ("Attribution Information") and is subject to the Attribution Limits as defined below. For these purposes, prominent shall mean display for sufficient duration to give reasonable notice to the user of the identity of the Original Developer and that if You include Attribution Information or similar information for other parties, You must ensure that the Attribution Information for the Original Developer shall be no less prominent than such Attribution Information or similar information for the other party. For greater certainty, the Original Developer may choose to specify in Exhibit B below that the above attribution requirement only applies to an Executable and Source Code resulting from the Original Code or any Modification, but not a Larger Work. The intent is to provide for reasonably modest attribution, therefore the Original Developer cannot require that You display, at any time, more than the following information as Attribution Information: (a) a copyright notice including the name of the Original Developer; (b) a word or one phrase (not exceeding 10 words); (c) one graphic image provided by the Original Developer; and (d) a URL (collectively, the "Attribution Limits"). (c) If Exhibit B does not include any Attribution Information, then there are no requirements for You to display any Attribution Information of the Original Developer. (d) You acknowledge that all trademarks, service marks and/or trade names contained within the Attribution Information distributed with the Covered Code are the exclusive property of their owners and may only be used with the permission of their owners, or under circumstances otherwise permitted by law or as expressly set out in this License. 15. ADDITIONAL TERM: NETWORK USE. The term "External Deployment" means the use, distribution, or communication of the Original Code or Modifications in any way such that the Original Code or Modifications may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Code or Modifications as a distribution under section 3.1 and make Source Code available under Section 3.2. EXHIBIT A. Common Public Attribution License Version 1.0. The contents of this file are subject to the Common Public Attribution License Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.xTuple.com/CPAL. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B. Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is xTuple ERP: PostBooks Edition The Original Developer is not the Initial Developer and is __________. If left blank, the Original Developer is the Initial Developer. The Initial Developer of the Original Code is OpenMFG, LLC, d/b/a xTuple. All portions of the code written by xTuple are Copyright (c) 1999-2012 OpenMFG, LLC, d/b/a xTuple. All Rights Reserved. Contributor(s): ______________________. Alternatively, the contents of this file may be used under the terms of the xTuple End-User License Agreeement (the xTuple License), in which case the provisions of the xTuple License are applicable instead of those above. If you wish to allow use of your version of this file only under the terms of the xTuple License and not to allow others to use your version of this file under the CPAL, indicate your decision by deleting the provisions above and replace them with the notice and other provisions required by the xTuple License. If you do not delete the provisions above, a recipient may use your version of this file under either the CPAL or the xTuple License. [NOTE: The text of this Exhibit A may differ slightly from the text of the notices in the Source Code files of the Original Code. You should use the text of this Exhibit A rather than the text found in the Original Code Source Code for Your Modifications.] EXHIBIT B. Attribution Information Attribution Copyright Notice: Copyright (c) 1999-2012 by OpenMFG, LLC, d/b/a xTuple Attribution Phrase (not exceeding 10 words): Powered by xTuple ERP: PostBooks Edition Attribution URL: www.xtuple.org (to be included in the "Community" menu of the application if possible) Graphic Image as provided in the Covered Code, if any. (online at www.xtuple.com/poweredby) Display of Attribution Information is required in Larger Works which are defined in the CPAL as a work which combines Covered Code or portions thereof with code not governed by the terms of the CPAL. postbooks-schema-quickstart-4.9.2/postbooks_quickstart-4.9.2.sql0000644000175000017500005320363412603675632024171 0ustar danieldaniel-- -- PostgreSQL database dump -- SET statement_timeout = 0; SET lock_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: api; Type: SCHEMA; Schema: -; Owner: admin -- CREATE SCHEMA api; ALTER SCHEMA api OWNER TO admin; -- -- Name: fixcountry; Type: SCHEMA; Schema: -; Owner: admin -- CREATE SCHEMA fixcountry; ALTER SCHEMA fixcountry OWNER TO admin; -- -- Name: SCHEMA fixcountry; Type: COMMENT; Schema: -; Owner: admin -- COMMENT ON SCHEMA fixcountry IS 'Schema to hold contents of fixcountry'; -- -- Name: te; Type: SCHEMA; Schema: -; Owner: admin -- CREATE SCHEMA te; ALTER SCHEMA te OWNER TO admin; -- -- Name: SCHEMA te; Type: COMMENT; Schema: -; Owner: admin -- COMMENT ON SCHEMA te IS 'Time and Expense system add-on package for xTuple ERP. This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and open source Enterprise Resource Planning software suite, Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. It is licensed to you under the Common Public Attribution License version 1.0, the full text of which (including xTuple-specific Exhibits) is available at www.xtuple.com/CPAL. By using this software, you agree to be bound by its terms.'; -- -- Name: xt; Type: SCHEMA; Schema: -; Owner: admin -- CREATE SCHEMA xt; ALTER SCHEMA xt OWNER TO admin; -- -- Name: xtdesktop; Type: SCHEMA; Schema: -; Owner: admin -- CREATE SCHEMA xtdesktop; ALTER SCHEMA xtdesktop OWNER TO admin; -- -- Name: SCHEMA xtdesktop; Type: COMMENT; Schema: -; Owner: admin -- COMMENT ON SCHEMA xtdesktop IS 'Schema to hold contents of xtdesktop'; -- -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; -- -- Name: plv8; Type: EXTENSION; Schema: -; Owner: -- CREATE EXTENSION IF NOT EXISTS plv8 WITH SCHEMA pg_catalog; -- -- Name: EXTENSION plv8; Type: COMMENT; Schema: -; Owner: -- COMMENT ON EXTENSION plv8 IS 'PL/JavaScript (v8) trusted procedural language'; SET search_path = public, pg_catalog; -- -- Name: _docinfo; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE _docinfo AS ( id integer, target_number text, target_type text, target_id integer, source_type text, source_id integer, name text, description text, purpose text ); ALTER TYPE _docinfo OWNER TO admin; -- -- Name: achline; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE achline AS ( achline_checkhead_id integer, achline_batch text, achline_type text, achline_value text ); ALTER TYPE achline OWNER TO admin; -- -- Name: apaging; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE apaging AS ( apaging_docdate text, apaging_duedate date, apaging_ponumber text, apaging_reference text, apaging_invcnumber text, apaging_docnumber text, apaging_doctype text, apaging_vend_id integer, apaging_vend_number text, apaging_vend_name text, apaging_vend_vendtype_id integer, apaging_vendtype_code text, apaging_terms_descrip text, apaging_apopen_amount numeric, apaging_cur_val numeric, apaging_thirty_val numeric, apaging_sixty_val numeric, apaging_ninety_val numeric, apaging_plus_val numeric, apaging_total_val numeric, apaging_discdate date, apaging_disc_val numeric, apaging_discdays numeric, apaging_discprcnt numeric ); ALTER TYPE apaging OWNER TO admin; -- -- Name: araging; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE araging AS ( araging_docdate date, araging_duedate date, araging_ponumber text, araging_docnumber text, araging_doctype text, araging_cust_id integer, araging_cust_number text, araging_cust_name text, araging_cust_custtype_id integer, araging_custtype_code text, araging_terms_descrip text, araging_aropen_amount numeric, araging_cur_val numeric, araging_thirty_val numeric, araging_sixty_val numeric, araging_ninety_val numeric, araging_plus_val numeric, araging_total_val numeric ); ALTER TYPE araging OWNER TO admin; -- -- Name: bomdata; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE bomdata AS ( bomdata_bomwork_id integer, bomdata_bomwork_parent_id integer, bomdata_bomwork_level integer, bomdata_bomwork_seqnumber integer, bomdata_bomitem_id integer, bomdata_item_id integer, bomdata_item_number text, bomdata_uom_name text, bomdata_item_descrip1 text, bomdata_item_descrip2 text, bomdata_itemdescription text, bomdata_batchsize numeric, bomdata_qtyfxd numeric, bomdata_qtyper numeric, bomdata_qtyreq numeric, bomdata_scrap numeric, bomdata_createchild boolean, bomdata_issuemethod text, bomdata_effective date, bomdata_expires date, bomdata_expired boolean, bomdata_future boolean, bomdata_actunitcost numeric, bomdata_stdunitcost numeric, bomdata_actextendedcost numeric, bomdata_stdextendedcost numeric, bomdata_ecn text, bomdata_char_id integer, bomdata_value text, bomdata_notes text, bomdata_ref text ); ALTER TYPE bomdata OWNER TO admin; -- -- Name: checkdata; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE checkdata AS ( checkdata_page integer, checkdata_checknumber text, checkdata_checkwords text, checkdata_checkdate text, checkdata_checkamount text, checkdata_checkcurrsymbol text, checkdata_checkcurrabbr text, checkdata_checkcurrname text, checkdata_checkpayto text, checkdata_checkaddress text, checkdata_checkmemo text, checkdata_docnumber text, checkdata_docreference text, checkdata_docdate text, checkdata_docamount text, checkdata_docdiscount text, checkdata_docnetamount text ); ALTER TYPE checkdata OWNER TO admin; -- -- Name: cntctdup; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE cntctdup AS ( cntct_id integer, cntct_crmacct_id integer, cntct_addr_id integer, cntct_first_name text, cntct_last_name text, cntct_honorific text, cntct_initials text, cntct_active boolean, cntct_phone text, cntct_phone2 text, cntct_fax text, cntct_email text, cntct_webaddr text, cntct_notes text, cntct_title text, cntct_number text, cntct_middle text, cntct_suffix text, cntct_owner_username text, cntct_name text, crmacct_number text, crmacct_name text, addr_id integer, addr_active boolean, addr_line1 text, addr_line2 text, addr_line3 text, addr_city text, addr_state text, addr_postalcode text, addr_country text, addr_notes text, addr_number text, cntctdup_level integer ); ALTER TYPE cntctdup OWNER TO admin; -- -- Name: flcoldata; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE flcoldata AS ( flcoldata_column integer, flcoldata_start date, flcoldata_end date ); ALTER TYPE flcoldata OWNER TO admin; -- -- Name: flstmthead; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE flstmthead AS ( flstmthead_flhead_id integer, flstmthead_flcol_id integer, flstmthead_period_id integer, flstmthead_username text, flstmthead_typedescrip1 text, flstmthead_typedescrip2 text, flstmthead_flhead_name text, flstmthead_flcol_name text, flstmthead_month text, flstmthead_qtr text, flstmthead_year text, flstmthead_prmonth text, flstmthead_prqtr text, flstmthead_pryear text ); ALTER TYPE flstmthead OWNER TO admin; -- -- Name: flstmtitem; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE flstmtitem AS ( flstmtitem_flhead_id integer, flstmtitem_period_id integer, flstmtitem_username text, flstmtitem_order integer, flstmtitem_level integer, flstmtitem_subgrp integer, flstmtitem_type text, flstmtitem_type_id integer, flstmtitem_parent_id integer, flstmtitem_accnt_id integer, flstmtitem_name text, flstmtitem_month numeric, flstmtitem_monthdb numeric, flstmtitem_monthcr numeric, flstmtitem_monthprcnt numeric, flstmtitem_monthbudget numeric, flstmtitem_monthbudgetprcnt numeric, flstmtitem_monthbudgetdiff numeric, flstmtitem_monthbudgetdiffprcnt numeric, flstmtitem_qtr numeric, flstmtitem_qtrdb numeric, flstmtitem_qtrcr numeric, flstmtitem_qtrprcnt numeric, flstmtitem_qtrbudget numeric, flstmtitem_qtrbudgetprcnt numeric, flstmtitem_qtrbudgetdiff numeric, flstmtitem_qtrbudgetdiffprcnt numeric, flstmtitem_year numeric, flstmtitem_yeardb numeric, flstmtitem_yearcr numeric, flstmtitem_yearprcnt numeric, flstmtitem_yearbudget numeric, flstmtitem_yearbudgetprcnt numeric, flstmtitem_yearbudgetdiff numeric, flstmtitem_yearbudgetdiffprcnt numeric, flstmtitem_prmonth numeric, flstmtitem_prmonthprcnt numeric, flstmtitem_prmonthdiff numeric, flstmtitem_prmonthdiffprcnt numeric, flstmtitem_prqtr numeric, flstmtitem_prqtrprcnt numeric, flstmtitem_prqtrdiff numeric, flstmtitem_prqtrdiffprcnt numeric, flstmtitem_pryear numeric, flstmtitem_pryearprcnt numeric, flstmtitem_pryeardiff numeric, flstmtitem_pryeardiffprcnt numeric ); ALTER TYPE flstmtitem OWNER TO admin; -- -- Name: fltrendhead; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE fltrendhead AS ( fltrendhead_flhead_id integer, fltrendhead_username text, fltrendhead_typedescrip text, fltrendhead_flhead_name text, fltrendhead_fld1 text, fltrendhead_fld2 text, fltrendhead_fld3 text, fltrendhead_fld4 text, fltrendhead_fld5 text, fltrendhead_fld6 text, fltrendhead_fld7 text, fltrendhead_fld8 text, fltrendhead_fld9 text, fltrendhead_fld10 text, fltrendhead_fld11 text, fltrendhead_fld12 text, fltrendhead_grndttl text ); ALTER TYPE fltrendhead OWNER TO admin; -- -- Name: fltrenditem; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE fltrenditem AS ( fltrenditem_flhead_id integer, fltrenditem_username text, fltrenditem_order integer, fltrenditem_level integer, fltrenditem_subgrp integer, fltrenditem_type text, fltrenditem_type_id integer, fltrenditem_parent_id integer, fltrenditem_accnt_id integer, fltrenditem_name text, fltrenditem_fld1 text, fltrenditem_fld2 text, fltrenditem_fld3 text, fltrenditem_fld4 text, fltrenditem_fld5 text, fltrenditem_fld6 text, fltrenditem_fld7 text, fltrenditem_fld8 text, fltrenditem_fld9 text, fltrenditem_fld10 text, fltrenditem_fld11 text, fltrenditem_fld12 text, fltrenditem_grndttl text ); ALTER TYPE fltrenditem OWNER TO admin; -- -- Name: freightdata; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE freightdata AS ( freightdata_schedule text, freightdata_from text, freightdata_to text, freightdata_shipvia text, freightdata_freightclass text, freightdata_weight numeric, freightdata_uom text, freightdata_price numeric, freightdata_type text, freightdata_total numeric, freightdata_currency text ); ALTER TYPE freightdata OWNER TO admin; -- -- Name: itemprice; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE itemprice AS ( itemprice_price numeric, itemprice_type character(1) ); ALTER TYPE itemprice OWNER TO admin; -- -- Name: orderitemtype; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE orderitemtype AS ( orderitem_id integer, orderitem_orderhead_type text, orderitem_orderhead_id integer, orderitem_linenumber integer, orderitem_status text, orderitem_itemsite_id integer, orderitem_scheddate date, orderitem_qty_ordered numeric, orderitem_qty_shipped numeric, orderitem_qty_received numeric, orderitem_qty_uom_id integer, orderitem_qty_invuomratio numeric, orderitem_unitcost numeric, orderitem_unitcost_curr_id integer, orderitem_freight numeric, orderitem_freight_received numeric, orderitem_freight_curr_id integer ); ALTER TYPE orderitemtype OWNER TO admin; -- -- Name: ordhead; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE ordhead AS ( orderhead_id integer, orderhead_type text, orderhead_number text, orderhead_status text, orderhead_orderdate date, orderhead_linecount integer, orderhead_from_id integer, orderhead_from text, orderhead_to_id integer, orderhead_to text, orderhead_curr_id integer, orderhead_agent_username text, orderhead_shipvia text ); ALTER TYPE ordhead OWNER TO admin; -- -- Name: orditem; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE orditem AS ( orderitem_id integer, orderitem_orderhead_type text, orderitem_orderhead_id integer, orderitem_linenumber integer, orderitem_status text, orderitem_itemsite_id integer, orderitem_scheddate date, orderitem_qty_ordered numeric, orderitem_qty_shipped numeric, orderitem_qty_received numeric, orderitem_qty_uom_id integer, orderitem_qty_invuomratio numeric, orderitem_unitcost numeric, orderitem_unitcost_curr_id integer, orderitem_freight numeric, orderitem_freight_received numeric, orderitem_freight_curr_id integer ); ALTER TYPE orditem OWNER TO admin; -- -- Name: reordlvl; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE reordlvl AS ( reordlvl_itemsite_id integer, reordlvl_item_id integer, reordlvl_warehous_code text, reordlvl_item_number text, reordlvl_item_descrip text, reordlvl_leadtime integer, reordlvl_daysofstock integer, reordlvl_curr_level numeric, reordlvl_total_days numeric, reordlvl_total_usage numeric, reordlvl_calc_level integer ); ALTER TYPE reordlvl OWNER TO admin; -- -- Name: seqiss; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE seqiss AS ( seqiss_number integer, seqiss_time timestamp with time zone ); ALTER TYPE seqiss OWNER TO admin; -- -- Name: subtax; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE subtax AS ( subtax_taxcode_id integer, subtax_taxcode_code text, subtax_taxcode_descrip text, subtax_taxcode_level integer ); ALTER TYPE subtax OWNER TO admin; -- -- Name: taxassign; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE taxassign AS ( taxassign_taxzone_id integer, taxassign_taxtype_id integer, taxassign_level integer, taxassign_zone_code text, taxassign_type_descrip text, taxassign_taxclass_code text, taxassign_taxclass_sequence integer ); ALTER TYPE taxassign OWNER TO admin; -- -- Name: taxdetail; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE taxdetail AS ( taxdetail_tax_id integer, taxdetail_tax_code text, taxdetail_tax_descrip text, taxdetail_tax_basis_tax_id integer, taxdetail_taxrate_percent numeric(10,6), taxdetail_taxrate_amount numeric(16,2), taxdetail_level integer, taxdetail_taxclass_id integer, taxdetail_taxclass_code text, taxdetail_taxclass_sequence integer, taxdetail_tax numeric(16,6), taxdetail_curr_id integer, taxdetail_curr_abbr text ); ALTER TYPE taxdetail OWNER TO admin; -- -- Name: wodata; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE wodata AS ( wodata_id integer, wodata_id_type integer, wodata_number integer, wodata_subnumber integer, wodata_itemnumber text, wodata_descrip text, wodata_status character(1), wodata_startdate date, wodata_duedate date, wodata_adhoc boolean, wodata_itemsite_id integer, wodata_listprice numeric, wodata_custprice numeric, wodata_qoh numeric, wodata_short numeric, wodata_qtyper numeric, wodata_qtyiss numeric, wodata_qtyrcv numeric, wodata_qtyordreq numeric, wodata_qtyuom text, wodata_scrap numeric, wodata_setup numeric, wodata_run numeric, wodata_notes text, wodata_ref text, wodata_level integer ); ALTER TYPE wodata OWNER TO admin; -- -- Name: woinvav; Type: TYPE; Schema: public; Owner: admin -- CREATE TYPE woinvav AS ( woinvav_itemsite_id integer, woinvav_womatl_id integer, woinvav_type character(1), woinvav_item_wo_number text, woinvav_descrip text, woinvav_uomname text, woinvav_qoh numeric, woinvav_balance numeric, woinvav_allocated numeric, woinvav_ordered numeric, woinvav_woavail numeric, woinvav_totalavail numeric, woinvav_reorderlevel numeric, woinvav_level integer ); ALTER TYPE woinvav OWNER TO admin; SET search_path = xtdesktop, pg_catalog; -- -- Name: usersonline; Type: TYPE; Schema: xtdesktop; Owner: admin -- CREATE TYPE usersonline AS ( usr_id integer, usr_username text, usr_propername text, usr_email text, client_start timestamp with time zone, query_start timestamp with time zone, cnt_internal bigint, cnt_external bigint, client_addr inet ); ALTER TYPE usersonline OWNER TO admin; SET search_path = api, pg_catalog; -- -- Name: getcustnumberfrominfo(text, text, text, text, text, boolean); Type: FUNCTION; Schema: api; Owner: admin -- CREATE FUNCTION getcustnumberfrominfo(text, text, text, text, text, boolean) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _email TEXT := COALESCE(UPPER($1), ''); _company TEXT := COALESCE(UPPER($2), ''); _first TEXT := COALESCE(UPPER($3), ''); _last TEXT := COALESCE(UPPER($4), ''); _fullname TEXT := COALESCE(UPPER($5), TRIM(_first || ' ' || _last)); _generate BOOLEAN := COALESCE($6, FALSE); _counter INTEGER; _custcount INTEGER := 0; _custnumber TEXT; _candidate TEXT := ''; _loopmax INTEGER := 0; _minlength INTEGER := 5; _maxlength INTEGER := 8; _numformat TEXT := ''; _testme TEXT; BEGIN IF (_email != '') THEN SELECT count(*), cust_number INTO _custcount, _custnumber FROM custinfo LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) WHERE (UPPER(cntct_email)=_email) GROUP BY cust_number; IF (NOT FOUND) THEN _custcount := 0; ELSIF(_custcount = 1) THEN RETURN _custnumber; END IF; END IF; IF (_company != '') THEN SELECT count(*), cust_number INTO _custcount, _custnumber FROM custinfo WHERE (UPPER(cust_name)=_company) GROUP BY cust_number; IF (NOT FOUND) THEN _custcount := 0; ELSIF(_custcount = 1) THEN RETURN _custnumber; END IF; END IF; IF (_fullname = '' AND (_first != '' OR _last != '')) THEN _fullname := TRIM(_first || ' ' || _last); END IF; IF (_custcount <= 0 AND _fullname != '') THEN SELECT count(*), cust_number INTO _custcount, _custnumber FROM custinfo WHERE (UPPER(cust_name)=_fullname) GROUP BY cust_number; IF (NOT FOUND) THEN _custcount := 0; ELSIF(_custcount = 1) THEN RETURN _custnumber; END IF; END IF; IF (_custcount > 1) THEN RAISE EXCEPTION 'Found % possible Customers for % and % and %', _custcount, _email, _company, _fullname; END IF; IF (_custcount <= 0 AND _generate) THEN IF (_maxlength < _minlength) THEN RAISE EXCEPTION 'Fix getCustNumberFromInfo: max length < min length'; END IF; IF (_company != '') THEN _candidate := _company; ELSIF (_email != '') THEN _candidate := SUBSTRING(_email FOR POSITION('@' IN _email) - 1); ELSIF (_last != '') THEN _candidate := _last; IF (_first != '') THEN _candidate := _candidate || _first; END IF; ELSIF (_fullname != '' AND (POSITION(' ' IN _fullname) > 0)) THEN _candidate := SUBSTRING(_fullname FROM POSITION(' ' IN _fullname) + 1) || SUBSTRING(_fullname FOR POSITION(' ' IN _fullname) - 1); END IF; WHILE (POSITION(' ' IN _candidate) > 0) LOOP _candidate := SUBSTRING(_candidate FOR POSITION(' ' IN _candidate) - 1) || SUBSTRING(_candidate FROM POSITION(' ' IN _candidate) + 1); END LOOP; FOR _counter IN _minlength.._maxlength LOOP _testme := SUBSTRING(_candidate FOR _counter); IF (NOT EXISTS(SELECT cust_number FROM custinfo WHERE (cust_number=_testme))) THEN _custnumber := _testme; EXIT; END IF; END LOOP; IF (_custnumber IS NULL OR _custnumber = '') THEN IF (LENGTH(_candidate) < _minlength) THEN _minlength := LENGTH(_candidate); END IF; FOR _counter IN _minlength.._maxlength LOOP _loopmax := _loopmax * 10 + 9; _numformat := _numformat || '0'; END LOOP; FOR _counter IN 1.._loopmax LOOP _testme := SUBSTRING(_candidate FOR _minlength) || TRIM(TO_CHAR(_counter, _numformat)); IF (NOT EXISTS(SELECT cust_number FROM custinfo WHERE (cust_number=_testme))) THEN _custnumber := _testme; EXIT; END IF; END LOOP; END IF; IF (_custnumber IS NULL OR _custnumber = '') THEN RAISE EXCEPTION 'Could not generate a new Customer Number'; END IF; END IF; IF (_custnumber IS NULL OR _custnumber = '') THEN RAISE EXCEPTION 'Could not find Customer Number for % and % and %', _email, _company, _fullname; END IF; RETURN _custnumber; END; $_$; ALTER FUNCTION api.getcustnumberfrominfo(text, text, text, text, text, boolean) OWNER TO admin; SET search_path = public, pg_catalog; -- -- Name: formatlocationname(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatlocationname(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLocationid ALIAS FOR $1; _name TEXT; _r RECORD; BEGIN SELECT location_aisle, location_rack, location_bin, location_name INTO _r FROM location WHERE (location_id=pLocationid); IF (FOUND) THEN IF (_r.location_aisle IS NOT NULL) THEN _name := _r.location_aisle; ELSE _name := ''; END IF; IF (_r.location_rack IS NOT NULL) THEN _name := (_name || _r.location_rack); END IF; IF (_r.location_bin IS NOT NULL) THEN _name := (_name || _r.location_bin); END IF; IF (_r.location_name IS NOT NULL) THEN _name := (_name || _r.location_name); END IF; RETURN _name; ELSE RETURN 'N/A'; END IF; END; $_$; ALTER FUNCTION public.formatlocationname(integer) OWNER TO admin; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: cntslip; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cntslip ( cntslip_id integer DEFAULT nextval(('"cntslip_cntslip_id_seq"'::text)::regclass) NOT NULL, cntslip_cnttag_id integer, cntslip_entered timestamp with time zone, cntslip_posted boolean, cntslip_number text, cntslip_qty numeric(18,6), cntslip_comments text, cntslip_location_id integer, cntslip_lotserial text, cntslip_lotserial_expiration date, cntslip_lotserial_warrpurc date, cntslip_username text ); ALTER TABLE cntslip OWNER TO admin; -- -- Name: TABLE cntslip; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE cntslip IS 'Count Slip information'; -- -- Name: invcnt; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE invcnt ( invcnt_id integer DEFAULT nextval(('invcnt_invcnt_id_seq'::text)::regclass) NOT NULL, invcnt_itemsite_id integer, invcnt_tagdate timestamp with time zone, invcnt_cntdate timestamp with time zone, invcnt_qoh_before numeric(18,6), invcnt_qoh_after numeric(18,6), invcnt_matcost numeric(16,6), invcnt_posted boolean, invcnt_postdate timestamp with time zone, invcnt_comments text, invcnt_priority boolean, invcnt_tagnumber text, invcnt_invhist_id integer, invcnt_location_id integer, invcnt_cnt_username text, invcnt_post_username text, invcnt_tag_username text ); ALTER TABLE invcnt OWNER TO admin; -- -- Name: TABLE invcnt; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE invcnt IS 'Count Tag information'; -- -- Name: item; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE item ( item_id integer DEFAULT nextval(('item_item_id_seq'::text)::regclass) NOT NULL, item_number text NOT NULL, item_descrip1 text NOT NULL, item_descrip2 text NOT NULL, item_classcode_id integer NOT NULL, item_picklist boolean DEFAULT true NOT NULL, item_comments text, item_sold boolean NOT NULL, item_fractional boolean NOT NULL, item_active boolean NOT NULL, item_type character(1) DEFAULT 'R'::bpchar NOT NULL, item_prodweight numeric(16,2) DEFAULT 0 NOT NULL, item_packweight numeric(16,2) DEFAULT 0 NOT NULL, item_prodcat_id integer NOT NULL, item_exclusive boolean DEFAULT false NOT NULL, item_listprice numeric(16,4) NOT NULL, item_config boolean DEFAULT false, item_extdescrip text, item_upccode text, item_maxcost numeric(16,6) DEFAULT 0 NOT NULL, item_inv_uom_id integer NOT NULL, item_price_uom_id integer NOT NULL, item_warrdays integer DEFAULT 0, item_freightclass_id integer, item_tax_recoverable boolean DEFAULT false NOT NULL, item_listcost numeric(16,6) DEFAULT 0.0 NOT NULL, CONSTRAINT item_item_number_check CHECK ((item_number <> ''::text)), CONSTRAINT item_item_type_check CHECK (((((((((((((item_type = 'P'::bpchar) OR (item_type = 'M'::bpchar)) OR (item_type = 'F'::bpchar)) OR (item_type = 'O'::bpchar)) OR (item_type = 'R'::bpchar)) OR (item_type = 'S'::bpchar)) OR (item_type = 'T'::bpchar)) OR (item_type = 'B'::bpchar)) OR (item_type = 'L'::bpchar)) OR (item_type = 'Y'::bpchar)) OR (item_type = 'C'::bpchar)) OR (item_type = 'K'::bpchar))), CONSTRAINT item_sold_check CHECK ((NOT (item_sold AND (item_prodcat_id = (-1))))) ); ALTER TABLE item OWNER TO admin; -- -- Name: TABLE item; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE item IS 'Item information'; -- -- Name: COLUMN item.item_maxcost; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN item.item_maxcost IS 'Maximum cost for item. Used to constrain purchase order price.'; -- -- Name: COLUMN item.item_listcost; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN item.item_listcost IS 'List cost for item. Basis for markup pricing.'; -- -- Name: itemsite; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE itemsite ( itemsite_id integer DEFAULT nextval(('itemsite_itemsite_id_seq'::text)::regclass) NOT NULL, itemsite_item_id integer NOT NULL, itemsite_warehous_id integer, itemsite_qtyonhand numeric(18,6) NOT NULL, itemsite_reorderlevel numeric(18,6) NOT NULL, itemsite_ordertoqty numeric(18,6) NOT NULL, itemsite_cyclecountfreq integer NOT NULL, itemsite_datelastcount date, itemsite_datelastused date, itemsite_loccntrl boolean NOT NULL, itemsite_safetystock numeric(18,6) NOT NULL, itemsite_minordqty numeric(18,6) NOT NULL, itemsite_multordqty numeric(18,6) NOT NULL, itemsite_leadtime integer NOT NULL, itemsite_abcclass character(1), itemsite_issuemethod character(1), itemsite_controlmethod character(1), itemsite_active boolean NOT NULL, itemsite_plancode_id integer NOT NULL, itemsite_costcat_id integer NOT NULL, itemsite_eventfence integer NOT NULL, itemsite_sold boolean NOT NULL, itemsite_stocked boolean NOT NULL, itemsite_freeze boolean DEFAULT false NOT NULL, itemsite_location_id integer NOT NULL, itemsite_useparams boolean NOT NULL, itemsite_useparamsmanual boolean NOT NULL, itemsite_soldranking integer DEFAULT 1, itemsite_createpr boolean, itemsite_location text, itemsite_location_comments text, itemsite_notes text, itemsite_perishable boolean NOT NULL, itemsite_autoabcclass boolean NOT NULL, itemsite_ordergroup integer DEFAULT 1 NOT NULL, itemsite_disallowblankwip boolean DEFAULT false NOT NULL, itemsite_maxordqty numeric(18,6) DEFAULT 0.0 NOT NULL, itemsite_mps_timefence integer DEFAULT 0 NOT NULL, itemsite_createwo boolean DEFAULT false NOT NULL, itemsite_warrpurc boolean DEFAULT false NOT NULL, itemsite_autoreg boolean DEFAULT false, itemsite_costmethod character(1) NOT NULL, itemsite_value numeric(12,2) NOT NULL, itemsite_ordergroup_first boolean DEFAULT false NOT NULL, itemsite_supply_itemsite_id integer, itemsite_planning_type character(1) DEFAULT 'M'::bpchar NOT NULL, itemsite_wosupply boolean DEFAULT false NOT NULL, itemsite_posupply boolean DEFAULT false NOT NULL, itemsite_lsseq_id integer, itemsite_cosdefault character(1), itemsite_createsopr boolean DEFAULT false, itemsite_createsopo boolean DEFAULT false, itemsite_dropship boolean DEFAULT false, itemsite_recvlocation_id integer DEFAULT (-1) NOT NULL, itemsite_issuelocation_id integer DEFAULT (-1) NOT NULL, itemsite_location_dist boolean DEFAULT false NOT NULL, itemsite_recvlocation_dist boolean DEFAULT false NOT NULL, itemsite_issuelocation_dist boolean DEFAULT false NOT NULL, CONSTRAINT itemsite_itemsite_abcclass_check CHECK (((((itemsite_abcclass = 'A'::bpchar) OR (itemsite_abcclass = 'B'::bpchar)) OR (itemsite_abcclass = 'C'::bpchar)) OR (itemsite_abcclass = 'T'::bpchar))), CONSTRAINT itemsite_itemsite_controlmethod_check CHECK (((((itemsite_controlmethod = 'N'::bpchar) OR (itemsite_controlmethod = 'R'::bpchar)) OR (itemsite_controlmethod = 'S'::bpchar)) OR (itemsite_controlmethod = 'L'::bpchar))), CONSTRAINT itemsite_itemsite_costmethod_check CHECK (((((itemsite_costmethod = 'N'::bpchar) OR (itemsite_costmethod = 'A'::bpchar)) OR (itemsite_costmethod = 'S'::bpchar)) OR (itemsite_costmethod = 'J'::bpchar))), CONSTRAINT itemsite_itemsite_ordergroup_check CHECK ((itemsite_ordergroup > 0)) ); ALTER TABLE itemsite OWNER TO admin; -- -- Name: TABLE itemsite; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE itemsite IS 'Item Site information'; -- -- Name: COLUMN itemsite.itemsite_lsseq_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN itemsite.itemsite_lsseq_id IS 'Foreign key reference for automatic lot/serial numbering'; -- -- Name: COLUMN itemsite.itemsite_createsopr; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN itemsite.itemsite_createsopr IS 'Used to flag Sales items that create P/Rs'; -- -- Name: COLUMN itemsite.itemsite_createsopo; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN itemsite.itemsite_createsopo IS 'Used to flag Sales items that create P/Os'; -- -- Name: COLUMN itemsite.itemsite_dropship; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN itemsite.itemsite_dropship IS 'Used to flag Sales items to drop ship'; -- -- Name: whsinfo; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE whsinfo ( warehous_id integer DEFAULT nextval(('warehous_warehous_id_seq'::text)::regclass) NOT NULL, warehous_code text NOT NULL, warehous_descrip text, warehous_fob text, warehous_active boolean, warehous_counttag_prefix text, warehous_counttag_number integer, warehous_bol_prefix text, warehous_bol_number integer, warehous_shipping boolean, warehous_useslips boolean, warehous_usezones boolean, warehous_aislesize integer, warehous_aislealpha boolean, warehous_racksize integer, warehous_rackalpha boolean, warehous_binsize integer, warehous_binalpha boolean, warehous_locationsize integer, warehous_locationalpha boolean, warehous_enforcearbl boolean, warehous_default_accnt_id integer, warehous_shipping_commission numeric(8,4) DEFAULT 0.00, warehous_cntct_id integer, warehous_addr_id integer, warehous_transit boolean DEFAULT false NOT NULL, warehous_shipform_id integer, warehous_shipvia_id integer, warehous_shipcomments text, warehous_costcat_id integer, warehous_sitetype_id integer, warehous_taxzone_id integer, warehous_sequence integer DEFAULT 0 NOT NULL, CONSTRAINT whsinfo_check CHECK (((warehous_transit AND (warehous_costcat_id IS NOT NULL)) OR (NOT warehous_transit))), CONSTRAINT whsinfo_warehous_code_check CHECK ((warehous_code <> ''::text)) ); ALTER TABLE whsinfo OWNER TO admin; -- -- Name: TABLE whsinfo; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE whsinfo IS 'Warehouse information'; SET search_path = api, pg_catalog; -- -- Name: physinvcount; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW physinvcount AS SELECT whsinfo.warehous_code AS site, item.item_number, invcnt.invcnt_tagnumber AS tag_number, cntslip.cntslip_qty AS quantity, public.formatlocationname(cntslip.cntslip_location_id) AS location, cntslip.cntslip_lotserial AS lotserial, cntslip.cntslip_comments AS comment FROM ((((public.invcnt JOIN public.itemsite ON ((itemsite.itemsite_id = invcnt.invcnt_itemsite_id))) JOIN public.whsinfo ON ((whsinfo.warehous_id = itemsite.itemsite_warehous_id))) JOIN public.item ON ((item.item_id = itemsite.itemsite_item_id))) LEFT JOIN public.cntslip ON ((cntslip.cntslip_cnttag_id = invcnt.invcnt_id))); ALTER TABLE physinvcount OWNER TO admin; -- -- Name: VIEW physinvcount; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW physinvcount IS 'Physical Inventory Count Tag and Slip'; -- -- Name: insertphysinvcount(physinvcount); Type: FUNCTION; Schema: api; Owner: admin -- CREATE FUNCTION insertphysinvcount(physinvcount) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNEW ALIAS FOR $1; _itemid INTEGER; _type TEXT; _siteid INTEGER; _itemsiteid INTEGER; _controlmethod TEXT; _loccntrl BOOLEAN; _locationid INTEGER; _lsid INTEGER; _invcntid INTEGER; _cntslipid INTEGER; _result INTEGER; BEGIN -- Check Item SELECT item_id, item_type INTO _itemid, _type FROM item WHERE (item_number=UPPER(pNEW.item_number)); IF (NOT FOUND OR _type IN ('F', 'R', 'L','J', 'K')) THEN SELECT item_id, item_type INTO _itemid, _type FROM item WHERE (item_upccode=pNEW.item_number); IF (NOT FOUND OR _type IN ('F', 'R', 'L','J', 'K')) THEN RAISE EXCEPTION 'Function insertPhysInvCount failed because Item % not found or invalid type', pNEW.item_number; END IF; END IF; -- Check Site SELECT warehous_id INTO _siteid FROM whsinfo WHERE (warehous_code=COALESCE(pNEW.site, (SELECT warehous_code FROM usrpref,whsinfo WHERE (usrpref_username=getEffectiveXtUser()) AND (usrpref_name='PreferredWarehouse') AND (warehous_id=CAST(usrpref_value AS INTEGER))))); IF (NOT FOUND) THEN RAISE EXCEPTION 'Function insertPhysInvCount failed because Site % not found', pNEW.site; END IF; -- Check Itemsite SELECT itemsite_id, itemsite_controlmethod, itemsite_loccntrl INTO _itemsiteid, _controlmethod, _loccntrl FROM itemsite WHERE (itemsite_item_id=_itemid) AND (itemsite_warehous_id=_siteid); IF (NOT FOUND) THEN RAISE EXCEPTION 'Function insertPhysInvCount failed because Itemsite %, % not found', pNEW.site, pNEW.item_number; END IF; IF (_controlmethod = 'N') THEN RAISE EXCEPTION 'Function insertPhysInvCount failed because Itemsite %, % not inventory control method', pNEW.site, pNEW.item_number; END IF; IF (_controlmethod IN ('L', 'S') AND COALESCE(pNEW.lotserial, '') = '') THEN RAISE EXCEPTION 'Function insertPhysInvCount failed because Itemsite %, % lot/serial controlled and lotserial not provided', pNEW.site, pNEW.item_number; END IF; IF (_controlmethod = 'S') THEN -- Check for unique serial id SELECT ls_id INTO _lsid FROM ls WHERE (ls_number=pNEW.lotserial); IF (FOUND) THEN RAISE EXCEPTION 'Function insertPhysInvCount failed because Serial %, %, % not unique', pNEW.site, pNEW.item_number, pNEW.lotserial; END IF; END IF; IF (_loccntrl) THEN IF (pNEW.location IS NULL) THEN RAISE EXCEPTION 'Function insertPhysInvCount failed because Itemsite %, % multi location and location not provided', pNEW.site, pNEW.item_number; ELSE -- Check Location SELECT location_id INTO _locationid FROM location WHERE (location_id=getLocationId(pNEW.site, pNEW.location)); IF (NOT FOUND) THEN RAISE EXCEPTION 'Function insertPhysInvCount failed because Location %, % not found', pNEW.site, pNEW.location; END IF; END IF; END IF; -- Create Count Tag SELECT CreateCountTag(_itemsiteid, pNEW.comment, FALSE, FALSE) INTO _invcntid; IF (_invcntid <= 0) THEN RAISE EXCEPTION 'Function insertPhysInvCount failed because CreateCountTag failed for Itemsite %, %', pNEW.site, pNEW.item_number; END IF; -- Create Count Slip INSERT INTO cntslip ( cntslip_cnttag_id, cntslip_username, cntslip_entered, cntslip_posted, cntslip_number, cntslip_qty, cntslip_location_id, cntslip_lotserial, cntslip_lotserial_expiration, cntslip_lotserial_warrpurc, cntslip_comments ) VALUES ( _invcntid, getEffectiveXtUser(), CURRENT_TIMESTAMP, FALSE, 'N/A', pNEW.quantity, COALESCE(_locationid, -1), pNEW.lotserial, NULL, NULL, pNEW.comment ) RETURNING cntslip_id INTO _cntslipid; -- Post Count Slip SELECT postCountSlip(_cntslipid) INTO _result; IF (_result < 0) THEN RAISE EXCEPTION 'Function insertPhysInvCount failed because postCountSlip failed for Itemsite %, %, %', pNEW.site, pNEW.item_number, _result; END IF; RETURN TRUE; END; $_$; ALTER FUNCTION api.insertphysinvcount(physinvcount) OWNER TO admin; SET search_path = public, pg_catalog; -- -- Name: basecurrid(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION basecurrid() RETURNS integer LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE returnVal INTEGER; BEGIN SELECT curr_id INTO returnVal FROM curr_symbol WHERE curr_base = TRUE; IF NOT FOUND THEN RAISE EXCEPTION 'No base currency found'; END IF; RETURN returnVal; END; $$; ALTER FUNCTION public.basecurrid() OWNER TO admin; -- -- Name: formatglaccount(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatglaccount(paccntid integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN formatGlAccount(accnt_company, accnt_profit, accnt_number, accnt_sub) FROM accnt WHERE (accnt_id=pAccntid); END; $$; ALTER FUNCTION public.formatglaccount(paccntid integer) OWNER TO admin; -- -- Name: formatsolinenumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatsolinenumber(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoitemid ALIAS FOR $1; _r RECORD; BEGIN SELECT coitem_linenumber, coitem_subnumber INTO _r FROM coitem WHERE(coitem_id=pSoitemid); IF(NOT FOUND) THEN RETURN NULL; END IF; IF(COALESCE(_r.coitem_subnumber, 0) > 0) THEN RETURN _r.coitem_linenumber || '.' || _r.coitem_subnumber; END IF; RETURN _r.coitem_linenumber; END; $_$; ALTER FUNCTION public.formatsolinenumber(integer) OWNER TO admin; -- -- Name: geteffectivextuser(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION geteffectivextuser() RETURNS text LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN /* The default return value of this function is simply the user currently connected. Overload this function from another schema to implement specific user handling from an external application that uses connection pooling. Use setEffectiveXtUser(text) to create a temporary table that inserts user data that can in turn be used as a lookup reference for an over loaded version of this function like so: SELECT effective_value FROM effective_user WHERE effective_key = 'username' */ RETURN CURRENT_USER; END; $$; ALTER FUNCTION public.geteffectivextuser() OWNER TO admin; -- -- Name: getitemtaxtype(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getitemtaxtype(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pTaxzoneid ALIAS FOR $2; _taxtypeid INTEGER; BEGIN SELECT itemtax_taxtype_id INTO _taxtypeid FROM itemtax WHERE ((itemtax_item_id=pItemid) AND (itemtax_taxzone_id=pTaxzoneid)); IF (NOT FOUND) THEN SELECT itemtax_taxtype_id INTO _taxtypeid FROM itemtax WHERE ((itemtax_item_id=pItemid) AND (itemtax_taxzone_id IS NULL)); IF (NOT FOUND) THEN RETURN NULL; END IF; END IF; RETURN _taxtypeid; END; $_$; ALTER FUNCTION public.getitemtaxtype(integer, integer) OWNER TO admin; -- -- Name: cohead; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cohead ( cohead_id integer DEFAULT nextval(('cohead_cohead_id_seq'::text)::regclass) NOT NULL, cohead_number text NOT NULL, cohead_cust_id integer NOT NULL, cohead_custponumber text, cohead_type character(1), cohead_orderdate date, cohead_warehous_id integer, cohead_shipto_id integer, cohead_shiptoname text, cohead_shiptoaddress1 text, cohead_shiptoaddress2 text, cohead_shiptoaddress3 text, cohead_shiptoaddress4 text, cohead_shiptoaddress5 text, cohead_salesrep_id integer NOT NULL, cohead_terms_id integer NOT NULL, cohead_fob text, cohead_shipvia text, cohead_shiptocity text, cohead_shiptostate text, cohead_shiptozipcode text, cohead_freight numeric(16,4) NOT NULL, cohead_misc numeric(16,4) DEFAULT 0 NOT NULL, cohead_imported boolean DEFAULT false, cohead_ordercomments text, cohead_shipcomments text, cohead_shiptophone text, cohead_shipchrg_id integer, cohead_shipform_id integer, cohead_billtoname text, cohead_billtoaddress1 text, cohead_billtoaddress2 text, cohead_billtoaddress3 text, cohead_billtocity text, cohead_billtostate text, cohead_billtozipcode text, cohead_misc_accnt_id integer, cohead_misc_descrip text, cohead_commission numeric(16,4), cohead_miscdate date, cohead_holdtype character(1), cohead_packdate date, cohead_prj_id integer, cohead_wasquote boolean DEFAULT false NOT NULL, cohead_lastupdated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL, cohead_shipcomplete boolean DEFAULT false NOT NULL, cohead_created timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone, cohead_creator text DEFAULT geteffectivextuser(), cohead_quote_number text, cohead_billtocountry text, cohead_shiptocountry text, cohead_curr_id integer DEFAULT basecurrid(), cohead_calcfreight boolean DEFAULT false NOT NULL, cohead_shipto_cntct_id integer, cohead_shipto_cntct_honorific text, cohead_shipto_cntct_first_name text, cohead_shipto_cntct_middle text, cohead_shipto_cntct_last_name text, cohead_shipto_cntct_suffix text, cohead_shipto_cntct_phone text, cohead_shipto_cntct_title text, cohead_shipto_cntct_fax text, cohead_shipto_cntct_email text, cohead_billto_cntct_id integer, cohead_billto_cntct_honorific text, cohead_billto_cntct_first_name text, cohead_billto_cntct_middle text, cohead_billto_cntct_last_name text, cohead_billto_cntct_suffix text, cohead_billto_cntct_phone text, cohead_billto_cntct_title text, cohead_billto_cntct_fax text, cohead_billto_cntct_email text, cohead_taxzone_id integer, cohead_taxtype_id integer, cohead_ophead_id integer, cohead_status character(1) DEFAULT 'O'::bpchar NOT NULL, cohead_saletype_id integer, cohead_shipzone_id integer, CONSTRAINT cohead_check CHECK (((cohead_misc = (0)::numeric) OR ((cohead_misc <> (0)::numeric) AND (cohead_misc_accnt_id IS NOT NULL)))), CONSTRAINT cohead_cohead_number_check CHECK ((cohead_number <> ''::text)) ); ALTER TABLE cohead OWNER TO admin; -- -- Name: TABLE cohead; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE cohead IS 'Sales Order header information'; -- -- Name: COLUMN cohead.cohead_saletype_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN cohead.cohead_saletype_id IS 'Associated sale type for sales order.'; -- -- Name: COLUMN cohead.cohead_shipzone_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN cohead.cohead_shipzone_id IS 'Associated shipping zone for sales order.'; -- -- Name: coitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE coitem ( coitem_id integer DEFAULT nextval(('coitem_coitem_id_seq'::text)::regclass) NOT NULL, coitem_cohead_id integer, coitem_linenumber integer NOT NULL, coitem_itemsite_id integer, coitem_status character(1), coitem_scheddate date, coitem_promdate date, coitem_qtyord numeric(18,6) NOT NULL, coitem_unitcost numeric(16,6) NOT NULL, coitem_price numeric(16,4) NOT NULL, coitem_custprice numeric(16,4) NOT NULL, coitem_qtyshipped numeric(18,6) NOT NULL, coitem_order_id integer, coitem_memo text, coitem_imported boolean DEFAULT false, coitem_qtyreturned numeric(18,6), coitem_closedate timestamp with time zone, coitem_custpn text, coitem_order_type character(1), coitem_close_username text, coitem_lastupdated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL, coitem_substitute_item_id integer, coitem_created timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone, coitem_creator text DEFAULT geteffectivextuser(), coitem_prcost numeric(16,6), coitem_qty_uom_id integer NOT NULL, coitem_qty_invuomratio numeric(20,10) NOT NULL, coitem_price_uom_id integer NOT NULL, coitem_price_invuomratio numeric(20,10) NOT NULL, coitem_warranty boolean DEFAULT false NOT NULL, coitem_cos_accnt_id integer, coitem_qtyreserved numeric(18,6) DEFAULT 0.0 NOT NULL, coitem_subnumber integer DEFAULT 0 NOT NULL, coitem_firm boolean DEFAULT false NOT NULL, coitem_taxtype_id integer, coitem_rev_accnt_id integer, coitem_pricemode character(1) DEFAULT 'D'::bpchar NOT NULL, CONSTRAINT coitem_coitem_status_check CHECK ((((coitem_status = 'O'::bpchar) OR (coitem_status = 'C'::bpchar)) OR (coitem_status = 'X'::bpchar))), CONSTRAINT valid_coitem_pricemode CHECK ((coitem_pricemode = ANY (ARRAY['D'::bpchar, 'M'::bpchar]))) ); ALTER TABLE coitem OWNER TO admin; -- -- Name: TABLE coitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE coitem IS 'Sales Order Line Item information'; -- -- Name: COLUMN coitem.coitem_pricemode; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN coitem.coitem_pricemode IS 'Pricing mode for sales order item. Valid values are D-discount, and M-markup'; -- -- Name: pohead; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE pohead ( pohead_id integer DEFAULT nextval(('pohead_pohead_id_seq'::text)::regclass) NOT NULL, pohead_status character(1), pohead_number text NOT NULL, pohead_orderdate date, pohead_vend_id integer, pohead_fob text, pohead_shipvia text, pohead_comments text, pohead_freight numeric(16,2) DEFAULT 0, pohead_printed boolean DEFAULT false, pohead_terms_id integer, pohead_warehous_id integer, pohead_vendaddr_id integer, pohead_agent_username text, pohead_curr_id integer DEFAULT basecurrid(), pohead_saved boolean DEFAULT true NOT NULL, pohead_taxzone_id integer, pohead_taxtype_id integer, pohead_dropship boolean DEFAULT false, pohead_vend_cntct_id integer, pohead_vend_cntct_honorific text, pohead_vend_cntct_first_name text, pohead_vend_cntct_middle text, pohead_vend_cntct_last_name text, pohead_vend_cntct_suffix text, pohead_vend_cntct_phone text, pohead_vend_cntct_title text, pohead_vend_cntct_fax text, pohead_vend_cntct_email text, pohead_vendaddress1 text, pohead_vendaddress2 text, pohead_vendaddress3 text, pohead_vendcity text, pohead_vendstate text, pohead_vendzipcode text, pohead_vendcountry text, pohead_shipto_cntct_id integer, pohead_shipto_cntct_honorific text, pohead_shipto_cntct_first_name text, pohead_shipto_cntct_middle text, pohead_shipto_cntct_last_name text, pohead_shipto_cntct_suffix text, pohead_shipto_cntct_phone text, pohead_shipto_cntct_title text, pohead_shipto_cntct_fax text, pohead_shipto_cntct_email text, pohead_shiptoaddress_id integer, pohead_shiptoaddress1 text, pohead_shiptoaddress2 text, pohead_shiptoaddress3 text, pohead_shiptocity text, pohead_shiptostate text, pohead_shiptozipcode text, pohead_shiptocountry text, pohead_cohead_id integer, pohead_released date, pohead_shiptoname text, CONSTRAINT pohead_pohead_number_check CHECK ((pohead_number <> ''::text)), CONSTRAINT pohead_pohead_status_check CHECK ((((pohead_status = 'U'::bpchar) OR (pohead_status = 'O'::bpchar)) OR (pohead_status = 'C'::bpchar))) ); ALTER TABLE pohead OWNER TO admin; -- -- Name: TABLE pohead; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE pohead IS 'Purchase Order header information'; -- -- Name: poitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE poitem ( poitem_id integer DEFAULT nextval(('poitem_poitem_id_seq'::text)::regclass) NOT NULL, poitem_status character(1), poitem_pohead_id integer, poitem_linenumber integer, poitem_duedate date, poitem_itemsite_id integer, poitem_vend_item_descrip text, poitem_vend_uom text, poitem_invvenduomratio numeric(20,10), poitem_qty_ordered numeric(18,6) NOT NULL, poitem_qty_received numeric(18,6) DEFAULT 0.0 NOT NULL, poitem_qty_returned numeric(18,6) DEFAULT 0.0 NOT NULL, poitem_qty_vouchered numeric(18,6) DEFAULT 0.0 NOT NULL, poitem_unitprice numeric(16,6), poitem_vend_item_number text, poitem_comments text, poitem_qty_toreceive numeric(18,6), poitem_expcat_id integer, poitem_itemsrc_id integer, poitem_freight numeric(16,4) DEFAULT 0.0 NOT NULL, poitem_freight_received numeric(16,4) DEFAULT 0.0 NOT NULL, poitem_freight_vouchered numeric(16,4) DEFAULT 0.0 NOT NULL, poitem_prj_id integer, poitem_stdcost numeric(16,6), poitem_bom_rev_id integer, poitem_boo_rev_id integer, poitem_manuf_name text, poitem_manuf_item_number text, poitem_manuf_item_descrip text, poitem_taxtype_id integer, poitem_tax_recoverable boolean DEFAULT true NOT NULL, poitem_rlsd_duedate date, poitem_order_id integer, poitem_order_type character(1), CONSTRAINT poitem_poitem_status_check CHECK ((((poitem_status = 'U'::bpchar) OR (poitem_status = 'O'::bpchar)) OR (poitem_status = 'C'::bpchar))) ); ALTER TABLE poitem OWNER TO admin; -- -- Name: TABLE poitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE poitem IS 'Purchase Order Line Item information'; -- -- Name: taxtype; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE taxtype ( taxtype_id integer NOT NULL, taxtype_name text NOT NULL, taxtype_descrip text, taxtype_sys boolean DEFAULT false NOT NULL, CONSTRAINT taxtype_taxtype_name_check CHECK ((taxtype_name <> ''::text)) ); ALTER TABLE taxtype OWNER TO admin; -- -- Name: TABLE taxtype; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE taxtype IS 'The list of Tax Types'; -- -- Name: uom; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE uom ( uom_id integer NOT NULL, uom_name text NOT NULL, uom_descrip text, uom_item_weight boolean DEFAULT false NOT NULL, CONSTRAINT uom_uom_name_check CHECK ((uom_name <> ''::text)) ); ALTER TABLE uom OWNER TO admin; -- -- Name: TABLE uom; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE uom IS 'Unit of Measure information'; SET search_path = api, pg_catalog; -- -- Name: salesline; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW salesline AS SELECT (cohead.cohead_number)::character varying AS order_number, (public.formatsolinenumber(coitem.coitem_id))::character varying AS line_number, l.item_number, coitem.coitem_custpn AS customer_pn, s.item_number AS substitute_for, whsinfo.warehous_code AS sold_from_site, coitem.coitem_status AS status, coitem.coitem_qtyord AS qty_ordered, q.uom_name AS qty_uom, coitem.coitem_price AS net_unit_price, p.uom_name AS price_uom, coitem.coitem_scheddate AS scheduled_date, coitem.coitem_promdate AS promise_date, coitem.coitem_warranty AS warranty, COALESCE((SELECT taxtype.taxtype_name FROM public.taxtype WHERE (taxtype.taxtype_id = public.getitemtaxtype(l.item_id, cohead.cohead_taxzone_id))), 'None'::text) AS tax_type, CASE WHEN (coitem.coitem_price = (0)::numeric) THEN '100'::text WHEN (coitem.coitem_custprice = (0)::numeric) THEN 'N/A'::text ELSE (round((((1)::numeric - (coitem.coitem_price / coitem.coitem_custprice)) * (100)::numeric), 4))::text END AS discount_pct_from_list, CASE WHEN (coitem.coitem_order_id = (-1)) THEN false ELSE true END AS create_order, CASE WHEN (coitem.coitem_order_id = (-1)) THEN ''::text ELSE ((pohead.pohead_number || '-'::text) || poitem.poitem_linenumber) END AS create_po, coitem.coitem_prcost AS overwrite_po_price, coitem.coitem_memo AS notes, CASE WHEN (coitem.coitem_cos_accnt_id IS NOT NULL) THEN public.formatglaccount(coitem.coitem_cos_accnt_id) ELSE NULL::text END AS alternate_cos_account, CASE WHEN (coitem.coitem_rev_accnt_id IS NOT NULL) THEN public.formatglaccount(coitem.coitem_rev_accnt_id) ELSE NULL::text END AS alternate_rev_account FROM public.cohead, (((public.coitem LEFT JOIN public.itemsite isb ON ((coitem.coitem_substitute_item_id = isb.itemsite_id))) LEFT JOIN public.item s ON ((isb.itemsite_item_id = s.item_id))) LEFT JOIN (public.poitem JOIN public.pohead ON ((poitem.poitem_pohead_id = pohead.pohead_id))) ON ((poitem.poitem_id = coitem.coitem_order_id))), public.itemsite il, public.item l, public.whsinfo, public.uom q, public.uom p WHERE ((((((cohead.cohead_id = coitem.coitem_cohead_id) AND (coitem.coitem_itemsite_id = il.itemsite_id)) AND (il.itemsite_item_id = l.item_id)) AND (il.itemsite_warehous_id = whsinfo.warehous_id)) AND (coitem.coitem_qty_uom_id = q.uom_id)) AND (coitem.coitem_price_uom_id = p.uom_id)) ORDER BY cohead.cohead_number, coitem.coitem_linenumber, coitem.coitem_subnumber; ALTER TABLE salesline OWNER TO admin; -- -- Name: VIEW salesline; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW salesline IS 'Sales Order Line Item'; -- -- Name: insertsalesline(salesline); Type: FUNCTION; Schema: api; Owner: admin -- CREATE FUNCTION insertsalesline(salesline) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNEW ALIAS FOR $1; _r RECORD; BEGIN IF (NOT EXISTS (SELECT cohead_id FROM cohead WHERE cohead_number=pNEW.order_number)) THEN RAISE EXCEPTION 'Function insertSalesLine failed because Sales Order % not found', pNEW.order_number; END IF; IF (NOT EXISTS (SELECT item_id FROM item WHERE item_number=pNEW.item_number)) THEN RAISE EXCEPTION 'Function insertSalesLine failed because Item Number % not found', pNEW.item_number; END IF; SELECT * INTO _r FROM cohead, itemsite, item, whsinfo WHERE ((cohead_number=pNEW.order_number) AND (itemsite_warehous_id=warehous_id AND (itemsite_item_id=item_id) AND (itemsite_active) AND (item_number=pNEW.item_number) AND (warehous_active) AND (warehous_id=COALESCE(getWarehousId(pNEW.sold_from_site,'ALL'),cohead_warehous_id,fetchprefwarehousid())))); IF (NOT FOUND) THEN RAISE EXCEPTION 'Function insertSalesLine failed with unknown failure to retrieve Sales Order'; END IF; INSERT INTO coitem ( coitem_cohead_id, coitem_linenumber, coitem_itemsite_id, coitem_status, coitem_scheddate, coitem_promdate, coitem_qtyord, coitem_qty_uom_id, coitem_qty_invuomratio, coitem_qtyshipped, coitem_unitcost, coitem_price, coitem_price_uom_id, coitem_price_invuomratio, coitem_custprice, coitem_order_id, coitem_memo, coitem_imported, coitem_qtyreturned, coitem_custpn, coitem_order_type, coitem_substitute_item_id, coitem_prcost, coitem_taxtype_id, coitem_warranty, coitem_cos_accnt_id, coitem_rev_accnt_id) VALUES ( _r.cohead_id, pNEW.line_number::INTEGER, _r.itemsite_id, pNEW.status, pNEW.scheduled_date, pNEW.promise_date, pNEW.qty_ordered, COALESCE(getUomId(pNEW.qty_uom),_r.item_inv_uom_id), itemuomtouomratio(_r.item_id,COALESCE(getUomId(pNEW.qty_uom),_r.item_inv_uom_id),_r.item_inv_uom_id), 0, stdCost(_r.item_id), COALESCE(pNEW.net_unit_price,itemPrice(_r.item_id,_r.cohead_cust_id, _r.cohead_shipto_id,pNEW.qty_ordered,_r.cohead_curr_id,_r.cohead_orderdate)), COALESCE(getUomId(pNEW.price_uom),_r.item_price_uom_id), itemuomtouomratio(_r.item_id,COALESCE(getUomId(pNEW.price_uom),_r.item_price_uom_id),_r.item_price_uom_id), itemPrice(_r.item_id, _r.cohead_cust_id, _r.cohead_shipto_id, pNEW.qty_ordered, _r.item_inv_uom_id, _r.item_price_uom_id, _r.cohead_curr_id,_r.cohead_orderdate, CASE WHEN (fetchMetricText('soPriceEffective') = 'ScheduleDate') THEN pNEW.scheduled_date WHEN (fetchMetricText('soPriceEffective') = 'OrderDate') THEN _r.cohead_orderdate ELSE CURRENT_DATE END, NULL) -1, pNEW.notes, true, 0, pNEW.customer_pn, CASE WHEN ((pNEW.create_order AND (_r.item_type = 'M')) OR ((pNEW.create_order IS NULL) AND _r.itemsite_createwo) AND (NOT _r.itemsite_stocked)) THEN 'W' WHEN ((pNEW.create_order AND (_r.item_type = 'P')) OR ((pNEW.create_order IS NULL) AND _r.itemsite_createsopr) AND (NOT _r.itemsite_stocked)) THEN 'R' WHEN ((pNEW.create_order AND (_r.item_type = 'P') AND (_r.itemsite_createsopo)) OR ((pNEW.create_order IS NULL) AND _r.itemsite_createsopo) AND (NOT _r.itemsite_stocked)) THEN 'P' END, getitemid(pNEW.substitute_for), pNEW.overwrite_po_price, COALESCE(getTaxTypeId(pNEW.tax_type), getItemTaxType(_r.itemsite_item_id, _r.cohead_taxzone_id)), pNEW.warranty, getGlAccntId(pNEW.alternate_cos_account), getGlAccntId(pNEW.alternate_rev_account) ); RETURN TRUE; END; $_$; ALTER FUNCTION api.insertsalesline(salesline) OWNER TO admin; SET search_path = public, pg_catalog; -- -- Name: _accntdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _accntdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _accntnum TEXT := formatGLAccount(OLD.accnt_id); _check INTEGER; BEGIN -- This trigger is to protect against accounts that are in use -- Check to see if the passed accnt is used in a Cost Category SELECT costcat_id INTO _check FROM costcat WHERE ( (costcat_asset_accnt_id=OLD.accnt_id) OR (costcat_liability_accnt_id=OLD.accnt_id) OR (costcat_adjustment_accnt_id=OLD.accnt_id) OR (costcat_purchprice_accnt_id=OLD.accnt_id) OR (costcat_laboroverhead_accnt_id=OLD.accnt_id) OR (costcat_scrap_accnt_id=OLD.accnt_id) OR (costcat_invcost_accnt_id=OLD.accnt_id) OR (costcat_wip_accnt_id=OLD.accnt_id) OR (costcat_shipasset_accnt_id=OLD.accnt_id) OR (costcat_mfgscrap_accnt_id=OLD.accnt_id) OR (costcat_transform_accnt_id=OLD.accnt_id) OR (costcat_freight_accnt_id=OLD.accnt_id) ) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in Cost Category'; END IF; -- Check to see if the passed accnt is used in a Sales Account Assignment SELECT salesaccnt_id INTO _check FROM salesaccnt WHERE ( (salesaccnt_sales_accnt_id=OLD.accnt_id) OR (salesaccnt_credit_accnt_id=OLD.accnt_id) OR (salesaccnt_cos_accnt_id=OLD.accnt_id) ) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in Sales Account Assignment'; END IF; -- Check to see if the passed accnt is used in a A/R Account Assignment SELECT araccnt_id INTO _check FROM araccnt WHERE ( (araccnt_freight_accnt_id=OLD.accnt_id) OR (araccnt_ar_accnt_id=OLD.accnt_id) OR (araccnt_prepaid_accnt_id=OLD.accnt_id) ) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in A/R Account Assignment'; END IF; -- Check to see if the passed accnt is used in a Warehouse SELECT warehous_id INTO _check FROM whsinfo WHERE (warehous_default_accnt_id=OLD.accnt_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in Site'; END IF; -- Check to see if the passed accnt is used in a Bank Account SELECT bankaccnt_id INTO _check FROM bankaccnt WHERE (bankaccnt_accnt_id=OLD.accnt_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in Bank Account'; END IF; -- Check to see if the passed accnt is used in an Expense Category SELECT expcat_id INTO _check FROM expcat WHERE ( (expcat_exp_accnt_id=OLD.accnt_id) OR (expcat_liability_accnt_id=OLD.accnt_id) OR (expcat_purchprice_accnt_id=OLD.accnt_id) OR (expcat_freight_accnt_id=OLD.accnt_id) ) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in Expense Category'; END IF; -- Check to see if the passed accnt is used in a Tax Code SELECT tax_id INTO _check FROM tax WHERE (tax_sales_accnt_id=OLD.accnt_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in Tax Code'; END IF; -- Check to see if the passed accnt is used in a Standard Journal Item SELECT stdjrnlitem_id INTO _check FROM stdjrnlitem WHERE (stdjrnlitem_accnt_id=OLD.accnt_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in Standard Journal Item'; END IF; -- Check to see if the passed accnt is used in a A/P Account Assignment SELECT apaccnt_ap_accnt_id INTO _check FROM apaccnt WHERE ( (apaccnt_ap_accnt_id=OLD.accnt_id) OR (apaccnt_prepaid_accnt_id=OLD.accnt_id) OR (apaccnt_discount_accnt_id=OLD.accnt_id) ) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in A/P Account Assignment'; END IF; -- Check to see if the passed accnt is used in an A/R Open Item record SELECT aropen_accnt_id INTO _check FROM aropen WHERE (aropen_accnt_id=OLD.accnt_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in A/R Open Item'; END IF; -- Check to see if the passed accnt has been used in the G/L SELECT gltrans_accnt_id INTO _check FROM gltrans WHERE (gltrans_accnt_id=OLD.accnt_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in G/L Transaction'; END IF; SELECT sltrans_accnt_id INTO _check FROM sltrans WHERE (sltrans_accnt_id=OLD.accnt_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in G/L Journal Transaction'; END IF; SELECT glseries_accnt_id INTO _check FROM glseries WHERE (glseries_accnt_id=OLD.accnt_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in G/L Series'; END IF; SELECT trialbal_accnt_id INTO _check FROM trialbal WHERE (trialbal_accnt_id=OLD.accnt_id) AND (trialbal_beginning != 0 OR trialbal_ending != 0) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in Trial Balance'; END IF; SELECT cashrcptmisc_accnt_id INTO _check FROM cashrcptmisc WHERE (cashrcptmisc_accnt_id=OLD.accnt_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in Cash Receipt Misc. Application'; END IF; -- TODO: everything above here should be replaced by fkeys IF (OLD.accnt_id = fetchMetricValue('DefaultAPAccount')) THEN RAISE EXCEPTION 'Cannot delete the default A/P Account [xtuple: accnt, -1, %]', _accntnum; ELSIF (OLD.accnt_id = fetchMetricValue('DefaultARAccount')) THEN RAISE EXCEPTION 'Cannot delete the default A/R Account [xtuple: accnt, -2, %]', _accntnum; END IF; RETURN OLD; END; $$; ALTER FUNCTION public._accntdeletetrigger() OWNER TO admin; -- -- Name: _accnttrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _accnttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ffSub BOOLEAN; ffProfit BOOLEAN; result INTEGER; BEGIN SELECT (metric_value='t') INTO ffSub FROM metric WHERE(metric_name='GLFFSubaccounts') LIMIT 1; ffSub := COALESCE(ffSub, false); SELECT (metric_value='t') INTO ffProfit FROM metric WHERE(metric_name='GLFFProfitCenters') LIMIT 1; ffProfit := COALESCE(ffProfit, false); IF (NEW.accnt_sub IS NOT NULL AND ffSub = false) THEN SELECT subaccnt_id INTO result FROM subaccnt WHERE(subaccnt_number=NEW.accnt_sub) LIMIT 1; IF (NOT FOUND) THEN RAISE EXCEPTION 'You must supply a valid Sub Account Number.'; END IF; END IF; IF (NEW.accnt_profit IS NOT NULL AND ffProfit = false) THEN SELECT prftcntr_id INTO result FROM prftcntr WHERE(prftcntr_number=NEW.accnt_profit) LIMIT 1; IF (NOT FOUND) THEN RAISE EXCEPTION 'You must supply a valid Profit Center Number.'; END IF; END IF; IF (TG_OP = 'UPDATE') THEN IF ((NEW.accnt_type != OLD.accnt_type) AND (SELECT (count(*) > 0) FROM gltrans WHERE (gltrans_accnt_id=NEW.accnt_id))) THEN RAISE EXCEPTION 'You may not change the account type of an account that has transaction history'; END IF; END IF; NEW.accnt_name := formatGlAccount(NEW.accnt_company, NEW.accnt_profit, NEW.accnt_number, NEW.accnt_sub); RETURN NEW; END; $$; ALTER FUNCTION public._accnttrigger() OWNER TO admin; -- -- Name: _accntuniquetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _accntuniquetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN -- This trigger is to protect against id collision on inherited tables since there is no way -- to enforce that with regular constraints. It should be applied to accnt and any table that -- inherits accnt. IF (SELECT (count(accnt_id) > 0) FROM accnt WHERE (accnt_id = NEW.accnt_id)) THEN RAISE EXCEPTION 'Can not create record on account with duplicate key %.', NEW.accnt_id; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._accntuniquetrigger() OWNER TO admin; -- -- Name: _addrafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _addrafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'ADDR' AND charass_target_id = OLD.addr_id; RETURN OLD; END; $$; ALTER FUNCTION public._addrafterdeletetrigger() OWNER TO admin; -- -- Name: _addrtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _addrtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _uses INTEGER := 0; BEGIN IF (TG_OP = 'INSERT') THEN --- clear the number from the issue cache PERFORM clearNumberIssue('AddressNumber', NEW.addr_number); ELSE SELECT count(*) INTO _uses FROM cntct WHERE ((cntct_addr_id=OLD.addr_id) AND cntct_active); END IF; IF (TG_OP = 'UPDATE') THEN IF (OLD.addr_active AND NOT NEW.addr_active AND _uses > 0) THEN RAISE EXCEPTION 'Cannot inactivate Address with Active Contacts (%)', _uses; END IF; ELSIF (TG_OP = 'DELETE') THEN IF (_uses > 0) THEN RAISE EXCEPTION 'Cannot Delete Address with Active Contacts (%)', _uses; END IF; UPDATE cntct SET cntct_addr_id = NULL WHERE ((cntct_addr_id=OLD.addr_id) AND (NOT cntct_active)); RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._addrtrigger() OWNER TO admin; -- -- Name: _alarmbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _alarmbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN PERFORM clearNumberIssue('AlarmNumber', NEW.alarm_number); RETURN NEW; END; $$; ALTER FUNCTION public._alarmbeforetrigger() OWNER TO admin; -- -- Name: _apapplytrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _apapplytrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _tpaid NUMERIC; BEGIN -- get the exchange rate for the doc date IF (TG_OP = 'INSERT') THEN SELECT currtocurr(NEW.apapply_curr_id,apopen_curr_id,NEW.apapply_amount,NEW.apapply_postdate) INTO _tpaid FROM apopen WHERE ( apopen_id=NEW.apapply_target_apopen_id ); IF (FOUND) THEN NEW.apapply_target_paid := _tpaid; ELSE RAISE EXCEPTION 'Error calculating paid amount on application'; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._apapplytrigger() OWNER TO admin; -- -- Name: _apopentrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _apopentrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _currrate NUMERIC; BEGIN -- get the base exchange rate for the doc date IF (TG_OP = 'INSERT' AND NEW.apopen_curr_rate IS NULL) THEN SELECT curr_rate INTO _currrate FROM curr_rate WHERE ( (NEW.apopen_curr_id=curr_id) AND ( NEW.apopen_docdate BETWEEN curr_effective AND curr_expires) ); IF (FOUND) THEN NEW.apopen_curr_rate := _currrate; ELSE RAISE EXCEPTION 'Currency exchange rate not found'; END IF; END IF; NEW.apopen_open := NEW.apopen_amount > NEW.apopen_paid; IF (TG_OP = 'INSERT') THEN IF (NEW.apopen_open=FALSE) THEN NEW.apopen_status='C'; ELSE NEW.apopen_status='O'; END IF; --- clear the number from the issue cache PERFORM clearNumberIssue('APMemoNumber', NEW.apopen_docnumber); END IF; IF (TG_OP = 'UPDATE') THEN IF ((OLD.apopen_open=TRUE) AND (NEW.apopen_open=FALSE)) THEN NEW.apopen_status='C'; IF (NEW.apopen_closedate IS NULL) THEN NEW.apopen_closedate=CURRENT_DATE; END IF; END IF; IF ((OLD.apopen_open=FALSE) AND (NEW.apopen_open=TRUE)) THEN NEW.apopen_status='O'; NEW.apopen_closedate=NULL; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._apopentrigger() OWNER TO admin; -- -- Name: _arapplytrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _arapplytrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _tpaid NUMERIC; BEGIN -- get the exchange rate for the doc date IF (TG_OP = 'INSERT') THEN IF (NEW.arapply_target_doctype != 'K') THEN SELECT round(currtocurr(NEW.arapply_curr_id,aropen_curr_id,NEW.arapply_applied,NEW.arapply_postdate),2) INTO NEW.arapply_target_paid FROM aropen WHERE ( aropen_id=NEW.arapply_target_aropen_id ); ELSE SELECT round(currtocurr(NEW.arapply_curr_id,aropen_curr_id,NEW.arapply_applied,NEW.arapply_postdate),2) INTO NEW.arapply_target_paid FROM aropen WHERE ( aropen_id=NEW.arapply_source_aropen_id ); END IF; IF NOT FOUND THEN NEW.arapply_target_paid := NEW.arapply_applied; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._arapplytrigger() OWNER TO admin; -- -- Name: _aropenaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _aropenaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _openAmount NUMERIC; _lateCount INTEGER := 0; _graceDays INTEGER; _checkLate BOOLEAN := false; _checkLimit BOOLEAN := false; _id INTEGER; BEGIN IF (TG_OP = 'INSERT') THEN _id := NEW.aropen_id; ELSE _id := OLD.aropen_id; END IF; -- If metric is set then auto close any associated incidents when AR is closed IF (fetchMetricBool('AutoCloseARIncident')) THEN IF (NEW.aropen_open = FALSE) THEN UPDATE incdt SET incdt_status='L' WHERE (incdt_aropen_id=_id); END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._aropenaftertrigger() OWNER TO admin; -- -- Name: _aropentrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _aropentrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _openAmount NUMERIC; _p RECORD; _lateCount INTEGER := 0; _graceDays INTEGER; _checkLate BOOLEAN := false; _checkLimit BOOLEAN := false; _id INTEGER; _currRate NUMERIC; BEGIN -- Checks -- Start with privileges IF ( (NOT checkPrivilege('MaintainARMemos')) AND (NOT checkPrivilege('PostMiscInvoices')) AND (NOT checkPrivilege('MaintainSalesOrders')) AND -- #24608 Required to post payments on SOs (NOT checkPrivilege('PostARDocuments')) ) THEN RAISE EXCEPTION 'You do not have privileges to maintain A/R Memos.'; END IF; IF ( (NEW.aropen_docnumber IS NULL) OR (LENGTH(NEW.aropen_docnumber) = 0) ) THEN RAISE EXCEPTION 'You must enter a valid Document # for this A/R Memo.'; END IF; IF (TG_OP IN ('INSERT', 'UPDATE') AND NEW.aropen_cust_id < 0) THEN RAISE WARNING 'Fixing deprecated use of negative aropen_cust_id'; NEW.aropen_cust_id := NULL; END IF; IF (TG_OP IN ('INSERT', 'UPDATE') AND NEW.aropen_salesrep_id < 0) THEN RAISE WARNING 'Fixing deprecated use of negative aropen_salesrep_id'; NEW.aropen_salesrep_id := NULL; END IF; IF (TG_OP = 'INSERT') THEN SELECT aropen_id INTO _id FROM aropen WHERE ( (aropen_doctype=NEW.aropen_doctype) AND (aropen_docnumber=NEW.aropen_docnumber) ) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'This Document Type/Number already exists. You may not enter a duplicate A/R Memo.'; END IF; --- clear the number from the issue cache if applicable PERFORM clearNumberIssue('ARMemoNumber', NEW.aropen_docnumber); END IF; -- Determine the number of late invoices IF ( SELECT (metric_value='t') FROM metric WHERE(metric_name='AutoCreditWarnLateCustomers')) THEN _checkLate := true; SELECT COALESCE(metric_value::integer, _graceDays) INTO _graceDays FROM metric WHERE(metric_name='DefaultAutoCreditWarnGraceDays'); IF (NOT FOUND) THEN _graceDays := 30; END IF; SELECT COALESCE(cust_gracedays, _graceDays) INTO _graceDays FROM custinfo WHERE(cust_id=NEW.aropen_cust_id); IF (NOT FOUND) THEN _graceDays := 30; END IF; SELECT count(aropen_id) INTO _lateCount FROM aropen WHERE((NEW.aropen_cust_id = aropen_cust_id) AND (aropen_open) AND (aropen_amount > aropen_paid) AND (aropen_doctype IN ('I', 'D')) AND (aropen_duedate < (CURRENT_DATE - _graceDays))); -- Adjust _lateCount if late invoice being paid IF ( (NEW.aropen_paid = NEW.aropen_amount) AND (NEW.aropen_doctype IN ('I', 'D')) AND (NEW.aropen_duedate < (CURRENT_DATE - _graceDays))) THEN _lateCount := _lateCount - 1; END IF; END IF; -- get the base exchange rate for the doc date IF (TG_OP = 'INSERT' AND NEW.aropen_curr_rate IS NULL) THEN SELECT curr_rate INTO _currrate FROM curr_rate WHERE ( (NEW.aropen_curr_id=curr_id) AND ( NEW.aropen_docdate BETWEEN curr_effective AND curr_expires) ); IF (FOUND) THEN NEW.aropen_curr_rate := _currrate; ELSE RAISE EXCEPTION 'Currency exchange rate not found'; END IF; END IF; -- Close this aropen if it is paid IF (NEW.aropen_paid = NEW.aropen_amount) THEN NEW.aropen_open=FALSE; -- Remove any aropenalloc regards that reference this aropen item DELETE FROM aropenalloc WHERE (aropenalloc_aropen_id=NEW.aropen_id); END IF; IF (TG_OP = 'INSERT') THEN IF (NEW.aropen_open=FALSE) AND (NEW.aropen_closedate IS NULL) THEN NEW.aropen_closedate=current_date; END IF; END IF; IF (TG_OP = 'UPDATE') THEN IF ((OLD.aropen_open=TRUE) AND (NEW.aropen_open=FALSE) AND (NEW.aropen_closedate IS NULL)) THEN NEW.aropen_closedate=current_date; END IF; END IF; -- Only check if the customer in question has a non-zero Credit Limit SELECT cust_id, cust_creditlmt, cust_creditstatus, cust_autoupdatestatus, cust_autoholdorders INTO _p FROM custinfo WHERE (cust_id=NEW.aropen_cust_id); IF (_p.cust_creditlmt > 0) THEN _checkLimit := true; SELECT COALESCE(SUM( CASE WHEN (aropen_doctype IN ('I', 'D')) THEN (aropen_amount - aropen_paid) ELSE ((aropen_amount - aropen_paid) * -1) END ), 0.0) INTO _openAmount FROM aropen AS current WHERE ( (current.aropen_cust_id=NEW.aropen_cust_id) AND (current.aropen_open) AND (current.aropen_id <> NEW.aropen_id) ); -- Add in the value of the current aropen item IF (NEW.aropen_doctype IN ('I', 'D')) THEN _openAmount := (_openAmount + (NEW.aropen_amount - NEW.aropen_paid)); ELSE _openAmount := (_openAmount - (NEW.aropen_amount - NEW.aropen_paid)); END IF; ELSE _openAmount := 0; END IF; IF (_checkLimit OR _checkLate) THEN -- Handle a Customer that is going under its credit limit IF ((_p.cust_creditlmt >= _openAmount) AND (_lateCount <= 0)) THEN -- Handle the Customer Status IF ( (_p.cust_autoupdatestatus) AND (_p.cust_creditstatus='W') ) THEN UPDATE custinfo SET cust_creditstatus='G' WHERE (cust_id=NEW.aropen_cust_id); END IF; -- Handle the open Sales Orders IF (_p.cust_autoholdorders) THEN UPDATE cohead SET cohead_holdtype='N' FROM coitem WHERE ( (coitem_cohead_id=cohead_id) AND (cohead_holdtype='C') AND (coitem_status='O') AND (cohead_cust_id=_p.cust_id) ); END IF; -- Handle a Customer that is going over its credit limit ELSIF ((_p.cust_creditlmt < _openAmount) OR (_lateCount > 0)) THEN -- Handle the Customer Status IF ( (_p.cust_autoupdatestatus) AND (_p.cust_creditstatus = 'G') ) THEN UPDATE custinfo SET cust_creditstatus='W' WHERE (cust_id=NEW.aropen_cust_id); END IF; -- Handle the open Sales Orders IF (_p.cust_autoholdorders) THEN UPDATE cohead SET cohead_holdtype='C' FROM coitem WHERE ( (coitem_cohead_id=cohead_id) AND (cohead_holdtype='N') AND (coitem_status='O') AND (cohead_cust_id=_p.cust_id) ); END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._aropentrigger() OWNER TO admin; -- -- Name: _bomheadtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _bomheadtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _revid INTEGER; _check TEXT; _cmnttypeid INTEGER; BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainBOMs')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Bills of Material.'; END IF; -- Cache the cmnttype_id for ChangeLog SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (FOUND) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'BMH', NEW.bomhead_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.bomhead_revision <> NEW.bomhead_revision) THEN PERFORM postComment(_cmnttypeid, 'BMH', NEW.bomhead_id, 'Revision Updated from '|| OLD.bomhead_revision||' to '||NEW.bomhead_revision); ELSE PERFORM postComment(_cmnttypeid, 'BMH', NEW.bomhead_id, 'Updated'); END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._bomheadtrigger() OWNER TO admin; -- -- Name: _bomitemaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _bomitemaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF ( SELECT fetchMetricBool('ItemChangeLog') ) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment('ChangeLog', 'BMI', NEW.bomitem_id, ('Created BOM Item Sequence ' || NEW.bomitem_seqnumber::TEXT)); ELSIF (TG_OP = 'UPDATE') THEN IF (NEW.bomitem_effective <> OLD.bomitem_effective) THEN PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id, ( 'Effective Date Changed from ' || formatDate(OLD.bomitem_effective, 'Always') || ' to ' || formatDate(NEW.bomitem_effective, 'Always' ) ) ); END IF; IF (NEW.bomitem_expires <> OLD.bomitem_expires) THEN PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id, ( 'Expiration Date Changed from ' || formatDate(OLD.bomitem_expires, 'Never') || ' to ' || formatDate(NEW.bomitem_expires, 'Never' ) ) ); END IF; IF (NEW.bomitem_qtyfxd <> OLD.bomitem_qtyfxd) THEN PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id, ( 'Fixed Qty. Changed from ' || formatQtyPer(OLD.bomitem_qtyfxd) || ' to ' || formatQtyPer(NEW.bomitem_qtyfxd ) ) ); END IF; IF (NEW.bomitem_qtyper <> OLD.bomitem_qtyper) THEN PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id, ( 'Qty. Per Changed from ' || formatQtyPer(OLD.bomitem_qtyper) || ' to ' || formatQtyPer(NEW.bomitem_qtyper ) ) ); END IF; IF (NEW.bomitem_scrap <> OLD.bomitem_scrap) THEN PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id, ( 'Scrap % Changed from ' || formatPrcnt(OLD.bomitem_scrap) || ' to ' || formatPrcnt(NEW.bomitem_scrap ) ) ); END IF; IF (NEW.bomitem_issuemethod <> OLD.bomitem_issuemethod) THEN PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id, ( 'Issue Method Changed from ' || (CASE WHEN(OLD.bomitem_issuemethod='S') THEN 'Push' WHEN(OLD.bomitem_issuemethod='L') THEN 'Pull' WHEN(OLD.bomitem_issuemethod='M') THEN 'Mixed' ELSE OLD.bomitem_issuemethod END) || ' to ' || (CASE WHEN(NEW.bomitem_issuemethod='S') THEN 'Push' WHEN(NEW.bomitem_issuemethod='L') THEN 'Pull' WHEN(NEW.bomitem_issuemethod='M') THEN 'Mixed' ELSE NEW.bomitem_issuemethod END) ) ); END IF; IF (NEW.bomitem_ecn <> OLD.bomitem_ecn) THEN PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id, ( 'ECN Changed from ' || OLD.bomitem_ecn || ' to ' || NEW.bomitem_ecn ) ); END IF; IF (OLD.bomitem_createwo <> NEW.bomitem_createwo) THEN IF (NEW.bomitem_createwo) THEN PERFORM postComment('ChangeLog', 'BMI', NEW.bomitem_id, 'Create Child W/O activated'); ELSE PERFORM postComment('ChangeLog', 'BMI', NEW.bomitem_id, 'Create Child W/O deactivated'); END IF; END IF; IF (OLD.bomitem_issuewo <> NEW.bomitem_issuewo) THEN IF (NEW.bomitem_issuewo) THEN PERFORM postComment('ChangeLog', 'BMI', NEW.bomitem_id, 'Issue Child W/O activated'); ELSE PERFORM postComment('ChangeLog', 'BMI', NEW.bomitem_id, 'Issue Child W/O deactivated'); END IF; END IF; END IF; END IF; IF (TG_OP = 'DELETE') THEN DELETE FROM comment WHERE ( (comment_source='BMI') AND (comment_source_id=OLD.bomitem_id) ); RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._bomitemaftertrigger() OWNER TO admin; -- -- Name: _bomitembeforedeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _bomitembeforedeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM comment WHERE ( (comment_source='BMI') AND (comment_source_id=OLD.bomitem_id) ); RETURN OLD; END; $$; ALTER FUNCTION public._bomitembeforedeletetrigger() OWNER TO admin; -- -- Name: _bomitembeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _bomitembeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _bomworksetid INTEGER; _bomworkid INTEGER; _seqNumber INTEGER; _parentItem RECORD; _bomheadid INTEGER; BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainBOMs')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Bills of Material.'; END IF; -- Cache Parent Item SELECT * INTO _parentItem FROM item WHERE (item_id=NEW.bomitem_parent_item_id); IF (TG_OP = 'INSERT') THEN -- Make sure that the parent and component are not the same IF (NEW.bomitem_parent_item_id = NEW.bomitem_item_id) THEN RAISE EXCEPTION 'BOM Item Parent and Component Item cannot be the same. [xtuple: createBOMItem, -1]'; END IF; -- Make sure that the parent is not used in the component at some level SELECT indentedWhereUsed(NEW.bomitem_parent_item_id) INTO _bomworksetid; SELECT bomwork_id INTO _bomworkid FROM bomwork WHERE ((bomwork_set_id=_bomworksetid) AND (bomwork_item_id=NEW.bomitem_item_id)) LIMIT 1; IF (FOUND) THEN PERFORM deleteBOMWorkset(_bomworksetid); RAISE EXCEPTION 'BOM Item Parent is used by Component, BOM is recursive. [xtuple: createBOMItem, -2]'; END IF; PERFORM deleteBOMWorkset(_bomworksetid); -- Create bomhead record if one does not exist SELECT bomhead_id INTO _bomheadid FROM bomhead WHERE (bomhead_item_id=NEW.bomitem_parent_item_id); IF (NOT FOUND) THEN INSERT INTO bomhead (bomhead_item_id, bomhead_batchsize, bomhead_rev_id) VALUES (NEW.bomitem_parent_item_id, 1, -1); END IF; -- Set defaults NEW.bomitem_rev_id := COALESCE(NEW.bomitem_rev_id, -1); NEW.bomitem_booitem_seq_id := COALESCE(NEW.bomitem_booitem_seq_id, -1); NEW.bomitem_schedatwooper := COALESCE(NEW.bomitem_schedatwooper, FALSE); IF (NEW.bomitem_seqnumber IS NULL) THEN -- Grab the next Sequence Number, if any SELECT MAX(bomitem_seqnumber) INTO _seqNumber FROM bomitem(NEW.bomitem_parent_item_id,NEW.bomitem_rev_id); IF (_seqNumber IS NOT NULL) THEN NEW.bomitem_seqnumber := (_seqNumber + 10); ELSE NEW.bomitem_seqnumber := 10; END IF; END IF; END IF; -- end Insert specific IF (TG_OP = 'UPDATE') THEN -- Disallow changes that would compromise revision control integrity IF (NEW.bomitem_parent_item_id != OLD.bomitem_parent_item_id) THEN RAISE EXCEPTION 'Parent Item ID may not be changed.'; END IF; IF (NEW.bomitem_item_id != OLD.bomitem_item_id) THEN RAISE EXCEPTION 'Item ID may not be changed.'; END IF; IF ((fetchMetricBool('RevControl')) AND (OLD.bomitem_rev_id > -1)) THEN IF (SELECT (rev_status = 'I') FROM rev WHERE (rev_id=OLD.bomitem_rev_id)) THEN RAISE EXCEPTION 'Bill of material is Inactive and may not be modified'; END IF; END IF; END IF; -- end Update specific -- Check for valid UOM IF (SELECT (count(*) != 1) FROM (SELECT uom_id FROM item JOIN uom ON (item_inv_uom_id=uom_id) WHERE(item_id=NEW.bomitem_item_id) UNION SELECT uom_id FROM item JOIN itemuomconv ON (itemuomconv_item_id=item_id) JOIN uom ON (itemuomconv_to_uom_id=uom_id), itemuom, uomtype WHERE((itemuomconv_from_uom_id=item_inv_uom_id) AND (item_id=NEW.bomitem_item_id) AND (itemuom_itemuomconv_id=itemuomconv_id) AND (uomtype_id=itemuom_uomtype_id) AND (uomtype_name='MaterialIssue')) UNION SELECT uom_id FROM item JOIN itemuomconv ON (itemuomconv_item_id=item_id) JOIN uom ON (itemuomconv_from_uom_id=uom_id), itemuom, uomtype WHERE((itemuomconv_to_uom_id=item_inv_uom_id) AND (item_id=NEW.bomitem_item_id) AND (itemuom_itemuomconv_id=itemuomconv_id) AND (uomtype_id=itemuom_uomtype_id) AND (uomtype_name='MaterialIssue'))) AS data WHERE (uom_id=NEW.bomitem_uom_id)) THEN RAISE EXCEPTION 'Unit of Measure Invalid for Material Issue.'; END IF; -- Disallow configuration parameters if parent is not a job item IF (NEW.bomitem_char_id IS NOT NULL) THEN IF (NOT _parentItem.item_config) THEN RAISE EXCEPTION 'Configuration characteristics may only be defined for Configured Items'; END IF; END IF; -- Kit items must be sold and not kits themselves IF (_parentItem.item_type = 'K') THEN IF (SELECT (COUNT(item_id) = 0) FROM item WHERE ((item_id=NEW.bomitem_item_id) AND (item_sold) AND (item_type != 'K'))) THEN RAISE EXCEPTION 'Bill of Material Items for kits must be sold and not kits themselves'; END IF; END IF; -- Over ride logic to disallow invalid data IF (NEW.bomitem_createwo) THEN IF (SELECT (item_type != 'M') FROM item WHERE (item_id=NEW.bomitem_item_id)) THEN NEW.bomitem_createwo := FALSE; END IF; IF (NEW.bomitem_booitem_seq_id = -1) THEN NEW.bomitem_schedatwooper := FALSE; END IF; END IF; NEW.bomitem_moddate := COALESCE(NEW.bomitem_moddate, CURRENT_DATE); RETURN NEW; END; $$; ALTER FUNCTION public._bomitembeforetrigger() OWNER TO admin; -- -- Name: _bomitemsubtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _bomitemsubtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainBOMs')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Bills of Material.'; END IF; IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END; $$; ALTER FUNCTION public._bomitemsubtrigger() OWNER TO admin; -- -- Name: _cashrcptitemaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _cashrcptitemaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _total NUMERIC; BEGIN -- Checks -- Total Over Application Warning SELECT (cashrcpt_amount - SUM(COALESCE(cashrcptitem_amount, 0))) INTO _total FROM cashrcptitem JOIN cashrcpt ON (cashrcpt_id=cashrcptitem_cashrcpt_id) WHERE (cashrcptitem_cashrcpt_id=NEW.cashrcptitem_cashrcpt_id) GROUP BY cashrcpt_amount; IF (_total < 0.0) THEN RAISE WARNING 'Warning -- the Cash Receipt has been over applied.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._cashrcptitemaftertrigger() OWNER TO admin; -- -- Name: _cashrcptitemtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _cashrcptitemtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check BOOLEAN; _openAmount NUMERIC; BEGIN -- Checks -- Start with Privileges IF (TG_OP = 'INSERT') THEN SELECT checkPrivilege('MaintainCashReceipts') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to add a new Cash Receipt Application.'; END IF; ELSE SELECT checkPrivilege('MaintainCashReceipts') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to alter a Cash Receipt Application.'; END IF; END IF; -- Over Application SELECT round(currToCurr(aropen_curr_id, cashrcpt_curr_id, aropen_amount - aropen_paid, cashrcpt_distdate) - COALESCE((SELECT SUM(cashrcptitem_amount) FROM cashrcptitem, cashrcpt WHERE ((cashrcpt_id=cashrcptitem_cashrcpt_id) AND (NOT cashrcpt_void) AND (NOT cashrcpt_posted) AND (cashrcpt_id != NEW.cashrcptitem_cashrcpt_id) AND (cashrcptitem_aropen_id=NEW.cashrcptitem_aropen_id))), 0),2) INTO _openAmount FROM aropen, cashrcpt WHERE ( (aropen_id=NEW.cashrcptitem_aropen_id) AND (cashrcpt_id=NEW.cashrcptitem_cashrcpt_id) ); IF (NEW.cashrcptitem_amount > _openAmount) THEN RAISE EXCEPTION 'You may not apply more than the balance of this item.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._cashrcptitemtrigger() OWNER TO admin; -- -- Name: _cashrcptmisctrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _cashrcptmisctrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check BOOLEAN; BEGIN -- Checks -- Start with Privileges IF (TG_OP = 'INSERT') THEN SELECT checkPrivilege('MaintainCashReceipts') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to add a new Cash Receipt Misc. Application.'; END IF; ELSE SELECT checkPrivilege('MaintainCashReceipts') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to alter a Cash Receipt Misc. Application.'; END IF; END IF; -- Account is required IF (NEW.cashrcptmisc_accnt_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid GL Account.'; END IF; -- Amount is required IF (COALESCE(NEW.cashrcptmisc_amount, 0) = 0) THEN RAISE EXCEPTION 'You must supply a valid Amount.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._cashrcptmisctrigger() OWNER TO admin; -- -- Name: _cashrcpttrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _cashrcpttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check BOOLEAN; _checkId INTEGER; _currId INTEGER; _bankCurrId INTEGER; _currrate NUMERIC; BEGIN -- Checks -- Start with privileges IF (TG_OP = 'INSERT') THEN SELECT checkPrivilege('MaintainCashReceipts') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to add new Cash Receipts.'; END IF; ELSE SELECT checkPrivilege('MaintainCashReceipts') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to alter a Cash Receipt.'; END IF; END IF; -- Currency must be same as Bank Currency IF (TG_OP = 'INSERT') THEN _currId = COALESCE(NEW.cashrcpt_curr_id, basecurrid()); --- clear the number from the issue cache PERFORM clearNumberIssue('CashRcptNumber', NEW.cashrcpt_number); ELSE _currId = NEW.cashrcpt_curr_id; END IF; -- get the base exchange rate for the dist date IF (NEW.cashrcpt_curr_rate IS NULL) THEN SELECT curr_rate INTO _currrate FROM curr_rate WHERE ( (NEW.cashrcpt_curr_id=curr_id) AND ( NEW.cashrcpt_distdate BETWEEN curr_effective AND curr_expires) ); IF (FOUND) THEN NEW.cashrcpt_curr_rate := _currrate; ELSE RAISE EXCEPTION 'Currency exchange rate not found'; END IF; END IF; -- Create CashReceiptPosted Event IF (TG_OP = 'UPDATE') THEN IF (OLD.cashrcpt_posted=FALSE AND NEW.cashrcpt_posted=TRUE) THEN PERFORM postEvent('CashReceiptPosted', NULL, NEW.cashrcpt_id, NULL, (cust_number || '-' || NEW.cashrcpt_docnumber || ' ' || currConcat(NEW.cashrcpt_curr_id) || formatMoney(NEW.cashrcpt_amount)), NULL, NULL, NULL, NULL) FROM custinfo WHERE (cust_id=NEW.cashrcpt_cust_id); END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._cashrcpttrigger() OWNER TO admin; -- -- Name: _ccardtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _ccardtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN New.ccard_lastupdated := current_timestamp; New.ccard_last_updated_by_username := getEffectiveXtUser(); IF (TG_OP = 'UPDATE') THEN INSERT INTO ccardaud VALUES (nextval('ccardaud_ccardaud_id_seq'), NEW.ccard_id, OLD.ccard_seq, NEW.ccard_seq, OLD.ccard_cust_id, NEW.ccard_cust_id, OLD.ccard_active, NEW.ccard_active, OLD.ccard_name, NEW.ccard_name, OLD.ccard_address1, NEW.ccard_address1, OLD.ccard_address2, NEW.ccard_address2, OLD.ccard_city, NEW.ccard_city, OLD.ccard_state, NEW.ccard_state, OLD.ccard_zip, NEW.ccard_zip, OLD.ccard_country, NEW.ccard_country, OLD.ccard_number, NEW.ccard_number, OLD.ccard_debit, NEW.ccard_debit, OLD.ccard_month_expired, NEW.ccard_month_expired, OLD.ccard_year_expired, NEW.ccard_year_expired, OLD.ccard_type, NEW.ccard_type); ELSE -- We are inserting a record, therefore no old values INSERT INTO ccardaud VALUES (nextval('ccardaud_ccardaud_id_seq'), NEW.ccard_id, NULL, NEW.ccard_seq, NULL, NEW.ccard_cust_id, NULL, NEW.ccard_active, NULL, NEW.ccard_name, NULL, NEW.ccard_address1, NULL, NEW.ccard_address2, NULL, NEW.ccard_city, NULL, NEW.ccard_state, NULL, NEW.ccard_zip, NULL, NEW.ccard_country, NULL, NEW.ccard_number, NULL, NEW.ccard_debit, NULL, NEW.ccard_month_expired, NULL, NEW.ccard_year_expired, NULL, NEW.ccard_type); END IF; RETURN NEW; END; $$; ALTER FUNCTION public._ccardtrigger() OWNER TO admin; -- -- Name: _ccpaybeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _ccpaybeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cardType TEXT; BEGIN IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN -- If ccpay_ccard_id is set, we don't care if ccpay_card_type is set, -- we want to get the Card Type from ccard. IF (NEW.ccpay_ccard_id IS NOT NULL) THEN SELECT ccard_type INTO _cardType FROM ccard WHERE ccard_id = NEW.ccpay_ccard_id; IF (_cardType IS NOT NULL) THEN NEW.ccpay_card_type = _cardType; END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._ccpaybeforetrigger() OWNER TO admin; -- -- Name: _charasshistorytrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _charasshistorytrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF(TG_OP = 'DELETE') THEN IF (OLD.charass_target_type = 'INCDT') THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_descrip) VALUES(OLD.charass_target_id, ('Characteristic ' || COALESCE((SELECT char_name FROM char WHERE (char_id=OLD.charass_char_id)), '') || ' Deleted: "' || COALESCE(OLD.charass_value,'') || '"') ); END IF; RETURN OLD; ELSIF (NEW.charass_target_type = 'INCDT') THEN IF (TG_OP = 'INSERT') THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_descrip) VALUES(NEW.charass_target_id, ('Characteristic ' || COALESCE((SELECT char_name FROM char WHERE (char_id=NEW.charass_char_id)), '') || ' Added: "' || COALESCE(NEW.charass_value,'') || '"') ); ELSIF (TG_OP = 'UPDATE') THEN IF (COALESCE(NEW.charass_value,'') <> COALESCE(OLD.charass_value,'')) THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_descrip) VALUES(NEW.charass_target_id, ('Characteristic ' || COALESCE((SELECT char_name FROM char WHERE (char_id=NEW.charass_char_id)), '') || ' Changed: "' || COALESCE(OLD.charass_value,'') || '" -> "' || COALESCE(NEW.charass_value,'') || '"') ); END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._charasshistorytrigger() OWNER TO admin; -- -- Name: _charasstrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _charasstrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Privilege Checks IF (NEW.charass_target_type = 'I' AND NOT checkPrivilege('MaintainItemMasters')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Items.'; END IF; IF (NEW.charass_target_type = 'C' AND NOT checkPrivilege('MaintainCustomerMasters')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Customers.'; END IF; -- Data check IF (NEW.charass_char_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Characteristic ID.'; END IF; -- Default Logic IF (NEW.charass_default) THEN UPDATE charass SET charass_default = false WHERE ((charass_target_id=NEW.charass_target_id) AND (charass_target_type=NEW.charass_target_type) AND (charass_char_id=NEW.charass_char_id) AND (charass_id <> NEW.charass_ID)); END IF; -- Incident update IF (NEW.charass_target_type = 'INCDT') THEN UPDATE incdt SET incdt_updated = now() WHERE incdt_id = NEW.charass_target_id; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._charasstrigger() OWNER TO admin; -- -- Name: _charbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _charbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (NOT checkPrivilege('MaintainCharacteristics')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Characteristics.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._charbeforetrigger() OWNER TO admin; -- -- Name: _charopttrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _charopttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (NOT checkPrivilege('MaintainCharacteristics')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Characteristic options.'; END IF; IF (TG_OP = 'UPDATE') THEN UPDATE charass SET charass_value = NEW.charopt_value WHERE ((charass_char_id=NEW.charopt_char_id) AND (charass_value=OLD.charopt_value)); END IF; IF (TG_OP = 'DELETE') THEN IF (SELECT (count(charass_id) > 0) FROM charass WHERE ((charass_char_id=OLD.charopt_char_id) AND (charass_value=OLD.charopt_value))) THEN RAISE EXCEPTION 'This characteristic option value is in use and can not be deleted.'; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._charopttrigger() OWNER TO admin; -- -- Name: _charusebeforeupserttrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _charusebeforeupserttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF NEW.charuse_target_type != 'LSR' AND NOT EXISTS (SELECT 1 FROM source WHERE source_charass = NEW.charuse_target_type) THEN RAISE EXCEPTION 'Cannot use Characteristic % with undefined target type % [ xtuple: charuse, -1, %, % ]', NEW.charuse_char_id, NEW.charuse_target_type, NEW.charuse_char_id, NEW.charuse_target_type; END IF; IF (TG_OP = 'INSERT') THEN NEW.charuse_created = CURRENT_TIMESTAMP; ELSE NEW.charuse_created = OLD.charuse_created; END IF; NEW.charuse_last_modified = CURRENT_TIMESTAMP; RETURN NEW; END $$; ALTER FUNCTION public._charusebeforeupserttrigger() OWNER TO admin; -- -- Name: _checkheadbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _checkheadbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _amount NUMERIC; _currrate NUMERIC; BEGIN -- get the base exchange rate for the check date IF (TG_OP = 'INSERT' AND NEW.checkhead_curr_rate IS NULL) THEN SELECT curr_rate INTO _currrate FROM curr_rate WHERE ( (NEW.checkhead_curr_id=curr_id) AND ( NEW.checkhead_checkdate BETWEEN curr_effective AND curr_expires) ); IF (FOUND) THEN NEW.checkhead_curr_rate := _currrate; ELSE RAISE EXCEPTION 'Currency exchange rate not found'; END IF; END IF; IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN IF (NOT EXISTS (SELECT checkrecip_id FROM checkrecip WHERE ((checkrecip_type=NEW.checkhead_recip_type) AND (checkrecip_id=NEW.checkhead_recip_id)) )) THEN RAISE EXCEPTION 'Cannot verify recipient for check % (type % id %)', NEW.checkhead_number, NEW.checkhead_recip_type, NEW.checkhead_recip_id; END IF; IF (NEW.checkhead_journalnumber IS NOT NULL AND NOT EXISTS (SELECT jrnluse_number FROM jrnluse WHERE (jrnluse_number=NEW.checkhead_journalnumber)) ) THEN RAISE EXCEPTION 'Journal Number % does not exist and cannot be used for check %.', NEW.checkhead_journalnumber, NEW.checkhead_number; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._checkheadbeforetrigger() OWNER TO admin; -- -- Name: _cmheadbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _cmheadbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check BOOLEAN; _id INTEGER; BEGIN -- Checks -- Start with privileges SELECT checkPrivilege('MaintainCreditMemos') INTO _check; IF ( (TG_OP = 'INSERT') OR (TG_OP = 'DELETE') ) THEN IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to maintain Credit Memos.'; END IF; END IF; IF (TG_OP = 'UPDATE') THEN IF ((OLD.cmhead_printed = NEW.cmhead_printed) AND NOT (_check) ) THEN RAISE EXCEPTION 'You do not have privileges to maintain Credit Memos.'; END IF; END IF; IF (TG_OP = 'DELETE') THEN DELETE FROM cmheadtax WHERE (taxhist_parent_id=OLD.cmhead_id); RETURN OLD; END IF; IF ( (NEW.cmhead_number IS NULL) OR (LENGTH(NEW.cmhead_number) = 0) ) THEN RAISE EXCEPTION 'You must enter a valid Memo # for this Credit Memo.'; END IF; IF (TG_OP = 'INSERT') THEN SELECT cmhead_id INTO _id FROM cmhead WHERE (cmhead_number=NEW.cmhead_number); IF (FOUND) THEN RAISE EXCEPTION 'The Memo # is already in use.'; END IF; IF (fetchMetricText('CMNumberGeneration') IN ('A','O')) THEN --- clear the number from the issue cache PERFORM clearNumberIssue('CmNumber', NEW.cmhead_number); ELSIF (fetchMetricText('CMNumberGeneration') = 'S') THEN --- clear the number from the issue cache PERFORM clearNumberIssue('SoNumber', NEW.cmhead_number); END IF; END IF; IF (NEW.cmhead_cust_id IS NOT NULL) THEN SELECT cust_id INTO _id FROM custinfo WHERE (cust_id=NEW.cmhead_cust_id); IF (NOT FOUND) THEN RAISE EXCEPTION 'You must enter a valid Customer # for this Credit Memo.'; END IF; END IF; IF ( (NEW.cmhead_misc > 0) AND (NEW.cmhead_misc_accnt_id = -1) ) THEN RAISE EXCEPTION 'You may not enter a Misc. Charge without indicating the G/L Sales Account.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._cmheadbeforetrigger() OWNER TO admin; -- -- Name: _cmheadtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _cmheadtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN -- If this was created by a return, then reset the return IF (OLD.cmhead_rahead_id IS NOT NULL) THEN UPDATE rahead SET rahead_headcredited=false WHERE (rahead_id=OLD.cmhead_rahead_id); DELETE FROM rahist WHERE ((rahist_rahead_id=OLD.cmhead_rahead_id) AND (rahist_source='CM') AND (rahist_source_id=OLD.cmhead_id)); END IF; RETURN OLD; END IF; -- Insert new row IF (TG_OP = 'INSERT') THEN -- Calculate Freight Tax IF (NEW.cmhead_freight <> 0) THEN PERFORM calculateTaxHist( 'cmheadtax', NEW.cmhead_id, NEW.cmhead_taxzone_id, getFreightTaxtypeId(), NEW.cmhead_docdate, NEW.cmhead_curr_id, NEW.cmhead_freight * -1 ); END IF; END IF; -- Update row IF (TG_OP = 'UPDATE') THEN IF ( (NEW.cmhead_freight <> OLD.cmhead_freight) OR (COALESCE(NEW.cmhead_taxzone_id,-1) <> COALESCE(OLD.cmhead_taxzone_id,-1)) OR (NEW.cmhead_docdate <> OLD.cmhead_docdate) OR (NEW.cmhead_curr_id <> OLD.cmhead_curr_id) ) THEN -- Calculate cmhead Tax PERFORM calculateTaxHist( 'cmheadtax', NEW.cmhead_id, NEW.cmhead_taxzone_id, getFreightTaxtypeId(), NEW.cmhead_docdate, NEW.cmhead_curr_id, NEW.cmhead_freight * -1 ); END IF; IF ( (COALESCE(NEW.cmhead_taxzone_id,-1) <> COALESCE(OLD.cmhead_taxzone_id,-1)) OR (NEW.cmhead_docdate <> OLD.cmhead_docdate) OR (NEW.cmhead_curr_id <> OLD.cmhead_curr_id) ) THEN -- Calculate cmitem Tax IF (COALESCE(NEW.cmhead_taxzone_id,-1) <> COALESCE(OLD.cmhead_taxzone_id,-1)) THEN -- Cmitem trigger will calculate tax UPDATE cmitem SET cmitem_taxtype_id=getItemTaxType(itemsite_item_id,NEW.cmhead_taxzone_id) FROM itemsite WHERE ((itemsite_id=cmitem_itemsite_id) AND (cmitem_cmhead_id=NEW.cmhead_id)); ELSE PERFORM calculateTaxHist( 'cmitemtax', cmitem_id, NEW.cmhead_taxzone_id, cmitem_taxtype_id, NEW.cmhead_docdate, NEW.cmhead_curr_id, (cmitem_qtycredit * cmitem_qty_invuomratio) * (cmitem_unitprice / cmitem_price_invuomratio) * -1) FROM cmitem WHERE (cmitem_cmhead_id = NEW.cmhead_id); END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._cmheadtrigger() OWNER TO admin; -- -- Name: _cmitembeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _cmitembeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check BOOLEAN; _id INTEGER; BEGIN -- Checks -- Start with privileges SELECT checkPrivilege('MaintainCreditMemos') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to maintain Credit Memos.'; END IF; IF (TG_OP = 'DELETE') THEN DELETE FROM cmitemtax WHERE (taxhist_parent_id=OLD.cmitem_id); RETURN OLD; END IF; IF (TG_OP = 'INSERT') THEN IF ( (NEW.cmitem_qtycredit IS NULL) OR (NEW.cmitem_qtycredit = 0) ) THEN RAISE EXCEPTION 'Quantity to Credit must be greater than zero.'; END IF; SELECT cmitem_id INTO _id FROM cmitem WHERE ( (cmitem_cmhead_id=NEW.cmitem_cmhead_id) AND (cmitem_linenumber=NEW.cmitem_linenumber) ); IF (FOUND) THEN RAISE EXCEPTION 'The Memo Line Number is already in use.'; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._cmitembeforetrigger() OWNER TO admin; -- -- Name: _cmitemtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _cmitemtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _ext NUMERIC; _r RECORD; BEGIN IF (TG_OP = 'DELETE') THEN -- If this was created by a return, reset return values IF (OLD.cmitem_raitem_id) IS NOT NULL THEN _ext := ROUND((OLD.cmitem_qtycredit * OLD.cmitem_qty_invuomratio) * (OLD.cmitem_unitprice / OLD.cmitem_price_invuomratio),2); UPDATE raitem SET raitem_status = 'O', raitem_qtycredited = raitem_qtycredited-OLD.cmitem_qtycredit, raitem_amtcredited = raitem_amtcredited-_ext WHERE (raitem_id=OLD.cmitem_raitem_id); END IF; RETURN OLD; END IF; -- Cache Credit Memo Head SELECT * INTO _r FROM cmhead WHERE (cmhead_id=NEW.cmitem_cmhead_id); IF (NOT FOUND) THEN RAISE EXCEPTION 'Credit Memo head not found'; END IF; -- Insert new row IF (TG_OP = 'INSERT') THEN -- Calculate Tax PERFORM calculateTaxHist( 'cmitemtax', NEW.cmitem_id, COALESCE(_r.cmhead_taxzone_id, -1), NEW.cmitem_taxtype_id, COALESCE(_r.cmhead_docdate, CURRENT_DATE), COALESCE(_r.cmhead_curr_id, -1), (NEW.cmitem_qtycredit * NEW.cmitem_qty_invuomratio) * (NEW.cmitem_unitprice / NEW.cmitem_price_invuomratio) * -1); END IF; -- Update row IF (TG_OP = 'UPDATE') THEN -- Calculate Tax IF ( (NEW.cmitem_qtycredit <> OLD.cmitem_qtycredit) OR (NEW.cmitem_qty_invuomratio <> OLD.cmitem_qty_invuomratio) OR (NEW.cmitem_unitprice <> OLD.cmitem_unitprice) OR (NEW.cmitem_price_invuomratio <> OLD.cmitem_price_invuomratio) OR (COALESCE(NEW.cmitem_taxtype_id, -1) <> COALESCE(OLD.cmitem_taxtype_id, -1)) ) THEN PERFORM calculateTaxHist( 'cmitemtax', NEW.cmitem_id, COALESCE(_r.cmhead_taxzone_id, -1), NEW.cmitem_taxtype_id, COALESCE(_r.cmhead_docdate, CURRENT_DATE), COALESCE(_r.cmhead_curr_id, -1), (NEW.cmitem_qtycredit * NEW.cmitem_qty_invuomratio) * (NEW.cmitem_unitprice / NEW.cmitem_price_invuomratio) * -1); END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._cmitemtrigger() OWNER TO admin; -- -- Name: _cntctafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _cntctafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'CNTCT' AND charass_target_id = OLD.cntct_id; RETURN OLD; END; $$; ALTER FUNCTION public._cntctafterdeletetrigger() OWNER TO admin; -- -- Name: _cntcttrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _cntcttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN NEW.cntct_name := formatCntctName(NULL, NEW.cntct_first_name, NEW.cntct_middle, NEW.cntct_last_name, NEW.cntct_suffix); NEW.cntct_email := lower(NEW.cntct_email); IF (TG_OP = 'INSERT') THEN --- clear the number from the issue cache PERFORM clearNumberIssue('ContactNumber', NEW.cntct_number); END IF; RETURN NEW; END; $$; ALTER FUNCTION public._cntcttrigger() OWNER TO admin; -- -- Name: _cntcttriggerafter(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _cntcttriggerafter() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cntctemlid INTEGER; _rows INTEGER; BEGIN IF (TG_OP = 'INSERT') THEN IF(length(coalesce(NEW.cntct_email,'')) > 0) THEN INSERT INTO cntcteml ( cntcteml_cntct_id, cntcteml_primary, cntcteml_email ) VALUES ( NEW.cntct_id, true, NEW.cntct_email ); END IF; PERFORM postComment('ChangeLog', 'T', NEW.cntct_id, ('Created by ' || getEffectiveXtUser())); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.cntct_email != NEW.cntct_email) THEN SELECT cntcteml_id INTO _cntctemlid FROM cntcteml WHERE ((cntcteml_cntct_id=NEW.cntct_id) AND (cntcteml_email=NEW.cntct_email)); GET DIAGNOSTICS _rows = ROW_COUNT; IF (_rows = 0) THEN UPDATE cntcteml SET cntcteml_primary=false WHERE ((cntcteml_cntct_id=NEW.cntct_id) AND (cntcteml_primary=true)); INSERT INTO cntcteml ( cntcteml_cntct_id, cntcteml_primary, cntcteml_email ) VALUES ( NEW.cntct_id, true, NEW.cntct_email ); ELSE UPDATE cntcteml SET cntcteml_primary=false WHERE ((cntcteml_cntct_id=NEW.cntct_id) AND (cntcteml_primary=true)); UPDATE cntcteml SET cntcteml_primary=true WHERE (cntcteml_id=_cntctemlid); END IF; END IF; ELSIF (TG_OP = 'DELETE') THEN DELETE FROM comment WHERE (comment_source_id=OLD.cntct_id AND comment_source = 'T'); DELETE FROM docass WHERE (docass_source_id=OLD.cntct_id AND docass_source_type = 'T') OR (docass_target_id=OLD.cntct_id AND docass_target_type = 'T'); RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._cntcttriggerafter() OWNER TO admin; -- -- Name: _cntcttriggerbeforedelete(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _cntcttriggerbeforedelete() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN DELETE FROM cntctaddr WHERE cntctaddr_cntct_id=OLD.cntct_id; DELETE FROM cntctdata WHERE cntctdata_cntct_id=OLD.cntct_id; DELETE FROM cntcteml WHERE cntcteml_cntct_id=OLD.cntct_id; DELETE FROM docass WHERE docass_source_id = OLD.cntct_id AND docass_source_type = 'T'; DELETE FROM docass WHERE docass_target_id = OLD.cntct_id AND docass_target_type = 'T'; -- these have denormalized cntct info so it should be ok to update them UPDATE cohead SET cohead_billto_cntct_id=NULL WHERE cohead_billto_cntct_id=OLD.cntct_id; UPDATE cohead SET cohead_shipto_cntct_id=NULL WHERE cohead_shipto_cntct_id=OLD.cntct_id; UPDATE pohead SET pohead_vend_cntct_id=NULL WHERE pohead_vend_cntct_id=OLD.cntct_id; UPDATE pohead SET pohead_shipto_cntct_id=NULL WHERE pohead_shipto_cntct_id=OLD.cntct_id; UPDATE quhead SET quhead_billto_cntct_id=NULL WHERE quhead_billto_cntct_id=OLD.cntct_id; UPDATE quhead SET quhead_shipto_cntct_id=NULL WHERE quhead_shipto_cntct_id=OLD.cntct_id; IF (fetchMetricBool('MultiWhs')) THEN UPDATE tohead SET tohead_destcntct_id=NULL WHERE tohead_destcntct_id=OLD.cntct_id; UPDATE tohead SET tohead_srccntct_id=NULL WHERE tohead_srccntct_id=OLD.cntct_id; END IF; END IF; RETURN OLD; END; $$; ALTER FUNCTION public._cntcttriggerbeforedelete() OWNER TO admin; -- -- Name: _cntsliptrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _cntsliptrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _p RECORD; _comments TEXT; _temp TEXT; BEGIN IF (TG_OP = 'DELETE') THEN SELECT itemsite_loccntrl, itemsite_controlmethod, cntslip_posted, cntslip_lotserial, cntslip_comments, cntslip_number, cntslip_qty INTO _p FROM cntslip, invcnt, itemsite WHERE ( (cntslip_cnttag_id=invcnt_id) AND (invcnt_itemsite_id=itemsite_id) AND (cntslip_id=OLD.cntslip_id) ); IF(_p.cntslip_posted) THEN SELECT ( ' Count Slip #' || _p.cntslip_number || ' deleted ' || formatQty(_p.cntslip_qty) ) INTO _comments; -- Add the Location name if the itemsite is MLC IF (_p.itemsite_loccntrl) THEN SELECT ( ', Location:' || location_name ) INTO _temp FROM location, cntslip WHERE ( (cntslip_location_id=location_id) AND (cntslip_id=OLD.cntslip_id) ); _comments := (_comments || _temp); END IF; -- Add the Lot/Serial if the itemsite is Lot or Serial controlled IF (_p.itemsite_controlmethod = 'L') THEN _comments := (_comments || ( ', Lot #:' || _p.cntslip_lotserial)); ELSIF (_p.itemsite_controlmethod = 'S') THEN _comments := (_comments || ( ', Serial #:' || _p.cntslip_lotserial)); END IF; _comments := (_comments || ' ' || _p.cntslip_comments); UPDATE invcnt SET invcnt_qoh_after = ( COALESCE(invcnt_qoh_after, 0) - cntslip_qty), invcnt_comments = (invcnt_comments || _comments) FROM cntslip WHERE ( (cntslip_cnttag_id=invcnt_id) AND (NOT invcnt_posted) AND (cntslip_id=OLD.cntslip_id) ); END IF; RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._cntsliptrigger() OWNER TO admin; -- -- Name: _cobillbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _cobillbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF (TG_OP = 'DELETE') THEN DELETE FROM cobilltax WHERE (taxhist_parent_id=OLD.cobill_id); RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._cobillbeforetrigger() OWNER TO admin; -- -- Name: _cobilltrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _cobilltrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; -- Cache Billing Head SELECT * INTO _r FROM cobmisc WHERE (cobmisc_id=NEW.cobill_cobmisc_id); IF (NOT FOUND) THEN RAISE EXCEPTION 'Billing head not found'; END IF; -- Insert new row IF (TG_OP = 'INSERT') THEN -- Calculate Tax PERFORM calculateTaxHist( 'cobilltax', NEW.cobill_id, COALESCE(_r.cobmisc_taxzone_id, -1), NEW.cobill_taxtype_id, COALESCE(_r.cobmisc_shipdate, CURRENT_DATE), COALESCE(_r.cobmisc_curr_id, -1), (NEW.cobill_qty * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio) ) FROM coitem WHERE (coitem_id=NEW.cobill_coitem_id); END IF; -- Update row IF (TG_OP = 'UPDATE') THEN -- Calculate Tax IF ( (NEW.cobill_qty <> OLD.cobill_qty) OR (NEW.cobill_taxtype_id <> OLD.cobill_taxtype_id) ) THEN PERFORM calculateTaxHist( 'cobilltax', NEW.cobill_id, COALESCE(_r.cobmisc_taxzone_id, -1), NEW.cobill_taxtype_id, COALESCE(_r.cobmisc_shipdate, CURRENT_DATE), COALESCE(_r.cobmisc_curr_id, -1), (NEW.cobill_qty * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio) ) FROM coitem WHERE (coitem_id=NEW.cobill_coitem_id); END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._cobilltrigger() OWNER TO admin; -- -- Name: _cobmiscbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _cobmiscbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF (TG_OP = 'DELETE') THEN DELETE FROM cobmisctax WHERE (taxhist_parent_id=OLD.cobmisc_id); RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._cobmiscbeforetrigger() OWNER TO admin; -- -- Name: _cobmisctrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _cobmisctrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN -- Something can go here RETURN OLD; END IF; -- Insert new row IF (TG_OP = 'INSERT') THEN -- Calculate Freight Tax IF (NEW.cobmisc_freight <> 0) THEN PERFORM calculateTaxHist( 'cobmisctax', NEW.cobmisc_id, NEW.cobmisc_taxzone_id, getFreightTaxtypeId(), NEW.cobmisc_invcdate, NEW.cobmisc_curr_id, NEW.cobmisc_freight ); END IF; END IF; -- Update row IF (TG_OP = 'UPDATE') THEN -- Calculate Tax IF (COALESCE(NEW.cobmisc_taxzone_id,-1) <> COALESCE(OLD.cobmisc_taxzone_id,-1)) THEN UPDATE cobill SET cobill_taxtype_id=getItemTaxType(itemsite_item_id,NEW.cobmisc_taxzone_id) FROM coitem JOIN itemsite ON (coitem_itemsite_id=itemsite_id) WHERE ((coitem_id=cobill_coitem_id) AND (cobill_cobmisc_id=NEW.cobmisc_id)); END IF; IF ( (NEW.cobmisc_freight <> OLD.cobmisc_freight) OR (COALESCE(NEW.cobmisc_taxzone_id,-1) <> COALESCE(OLD.cobmisc_taxzone_id,-1)) OR (NEW.cobmisc_invcdate <> OLD.cobmisc_invcdate) OR (NEW.cobmisc_curr_id <> OLD.cobmisc_curr_id) ) THEN PERFORM calculateTaxHist( 'cobmisctax', NEW.cobmisc_id, NEW.cobmisc_taxzone_id, getFreightTaxtypeId(), NEW.cobmisc_invcdate, NEW.cobmisc_curr_id, NEW.cobmisc_freight ); PERFORM calculateTaxHist( 'cobilltax', cobill_id, NEW.cobmisc_taxzone_id, cobill_taxtype_id, NEW.cobmisc_invcdate, NEW.cobmisc_curr_id, (cobill_qty * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio) ) FROM cobill JOIN coitem ON (coitem_id = cobill_coitem_id) WHERE (cobill_cobmisc_id = NEW.cobmisc_id); END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._cobmisctrigger() OWNER TO admin; -- -- Name: _coheadafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _coheadafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'SO' AND charass_target_id = OLD.cohead_id; RETURN OLD; END; $$; ALTER FUNCTION public._coheadafterdeletetrigger() OWNER TO admin; -- -- Name: _coitembeforeimptaxtypedeftrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _coitembeforeimptaxtypedeftrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _itemid INTEGER := 0; _cohead RECORD; BEGIN IF (NEW.coitem_taxtype_id IS NULL) THEN -- Get the cohead_taxzone_id and cohead_imported SELECT cohead_taxzone_id, cohead_imported INTO _cohead FROM cohead WHERE (cohead_id = NEW.coitem_cohead_id); IF (_cohead.cohead_imported) THEN -- Get the item_id SELECT item_id INTO _itemid FROM item LEFT JOIN itemsite ON item.item_id = itemsite.itemsite_item_id WHERE (itemsite_id = NEW.coitem_itemsite_id); -- Set coitem_taxtype_id default NEW.coitem_taxtype_id = getItemTaxType(_itemid, _cohead.cohead_taxzone_id); END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._coitembeforeimptaxtypedeftrigger() OWNER TO admin; -- -- Name: _commenttrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _commenttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (NEW.comment_cmnttype_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Comment Type ID.'; ELSIF (NEW.comment_source = 'INCDT') THEN UPDATE incdt SET incdt_updated = now() WHERE incdt_id = NEW.comment_source_id; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._commenttrigger() OWNER TO admin; -- -- Name: _companytrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _companytrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _used BOOLEAN := false; BEGIN IF (NEW.company_external AND NOT OLD.company_external) THEN IF EXISTS(SELECT accnt_id FROM accnt, company, ( SELECT DISTINCT apaccnt_ap_accnt_id AS test_accnt_id FROM apaccnt UNION SELECT DISTINCT apaccnt_discount_accnt_id FROM apaccnt UNION SELECT DISTINCT apaccnt_prepaid_accnt_id FROM apaccnt UNION SELECT DISTINCT apopen_accnt_id FROM apopen UNION SELECT DISTINCT araccnt_ar_accnt_id FROM araccnt UNION SELECT DISTINCT araccnt_deferred_accnt_id FROM araccnt UNION SELECT DISTINCT araccnt_freight_accnt_id FROM araccnt UNION SELECT DISTINCT araccnt_prepaid_accnt_id FROM araccnt UNION SELECT DISTINCT aropen_accnt_id FROM aropen UNION SELECT DISTINCT bankaccnt_accnt_id FROM bankaccnt UNION SELECT DISTINCT bankaccnt_rec_accnt_id FROM bankaccnt UNION SELECT DISTINCT budgitem_accnt_id FROM budgitem UNION SELECT DISTINCT cashrcptmisc_accnt_id FROM cashrcptmisc UNION SELECT DISTINCT cmhead_misc_accnt_id FROM cmhead UNION SELECT DISTINCT cobmisc_misc_accnt_id FROM cobmisc UNION SELECT DISTINCT cohead_misc_accnt_id FROM cohead UNION SELECT DISTINCT coitem_cos_accnt_id FROM coitem UNION SELECT DISTINCT costcat_adjustment_accnt_id FROM costcat UNION SELECT DISTINCT costcat_asset_accnt_id FROM costcat UNION SELECT DISTINCT costcat_freight_accnt_id FROM costcat UNION SELECT DISTINCT costcat_invcost_accnt_id FROM costcat UNION SELECT DISTINCT costcat_laboroverhead_accnt_id FROM costcat UNION SELECT DISTINCT costcat_liability_accnt_id FROM costcat UNION SELECT DISTINCT costcat_matusage_accnt_id FROM costcat UNION SELECT DISTINCT costcat_mfgscrap_accnt_id FROM costcat UNION SELECT DISTINCT costcat_purchprice_accnt_id FROM costcat UNION SELECT DISTINCT costcat_scrap_accnt_id FROM costcat UNION SELECT DISTINCT costcat_shipasset_accnt_id FROM costcat UNION SELECT DISTINCT costcat_toliability_accnt_id FROM costcat UNION SELECT DISTINCT costcat_transform_accnt_id FROM costcat UNION SELECT DISTINCT costcat_wip_accnt_id FROM costcat UNION SELECT DISTINCT costelem_exp_accnt_id FROM costelem UNION SELECT DISTINCT expcat_exp_accnt_id FROM expcat UNION SELECT DISTINCT expcat_freight_accnt_id FROM expcat UNION SELECT DISTINCT expcat_liability_accnt_id FROM expcat UNION SELECT DISTINCT expcat_purchprice_accnt_id FROM expcat UNION SELECT DISTINCT glseries_accnt_id FROM glseries UNION SELECT DISTINCT gltrans_accnt_id FROM gltrans UNION SELECT DISTINCT invchead_misc_accnt_id FROM invchead UNION SELECT DISTINCT quhead_misc_accnt_id FROM quhead UNION SELECT DISTINCT salesaccnt_cor_accnt_id FROM salesaccnt UNION SELECT DISTINCT salesaccnt_cos_accnt_id FROM salesaccnt UNION SELECT DISTINCT salesaccnt_cow_accnt_id FROM salesaccnt UNION SELECT DISTINCT salesaccnt_credit_accnt_id FROM salesaccnt UNION SELECT DISTINCT salesaccnt_returns_accnt_id FROM salesaccnt UNION SELECT DISTINCT salesaccnt_sales_accnt_id FROM salesaccnt UNION SELECT DISTINCT salescat_ar_accnt_id FROM salescat UNION SELECT DISTINCT salescat_prepaid_accnt_id FROM salescat UNION SELECT DISTINCT salescat_sales_accnt_id FROM salescat UNION SELECT DISTINCT stdjrnlitem_accnt_id FROM stdjrnlitem UNION SELECT DISTINCT tax_sales_accnt_id FROM tax UNION SELECT DISTINCT taxauth_accnt_id FROM taxauth UNION SELECT DISTINCT vodist_accnt_id FROM vodist UNION SELECT DISTINCT warehous_default_accnt_id FROM whsinfo ) AS dummy WHERE ((accnt_id=test_accnt_id) AND (accnt_company=company_number) AND (accnt_company=NEW.company_number)) ) THEN RAISE EXCEPTION 'Cannot make Company % External because it is used in the local database.', NEW.company_number; ELSIF (fetchMetricBool('EnableReturnAuth')) THEN IF EXISTS(SELECT accnt_id FROM accnt, company, ( SELECT DISTINCT rahead_misc_accnt_id AS test_accnt_id FROM rahead UNION SELECT DISTINCT raitem_cos_accnt_id FROM raitem ) AS dummy WHERE ((accnt_id=test_accnt_id) AND (accnt_company=company_number) AND (accnt_company=NEW.company_number)) ) THEN RAISE EXCEPTION 'Cannot make Company % External because it is used in the local database.', NEW.company_number; END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._companytrigger() OWNER TO admin; -- -- Name: _contrctaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _contrctaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN -- synchronize contract effectivity with item source effectivity IF (NEW.contrct_effective <> OLD.contrct_effective) THEN UPDATE itemsrc SET itemsrc_effective=NEW.contrct_effective WHERE itemsrc_contrct_id=NEW.contrct_id; END IF; IF (NEW.contrct_expires <> OLD.contrct_expires) THEN UPDATE itemsrc SET itemsrc_expires=NEW.contrct_expires WHERE itemsrc_contrct_id=NEW.contrct_id; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._contrctaftertrigger() OWNER TO admin; -- -- Name: _crmacctafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _crmacctafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'CRMACCT' AND charass_target_id = OLD.crmacct_id; RETURN OLD; END; $$; ALTER FUNCTION public._crmacctafterdeletetrigger() OWNER TO admin; -- -- Name: _crmacctaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _crmacctaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; _gotpriv BOOLEAN; BEGIN /* update _number and _name separately to propagate just what changed. the priv manipulation allows targeted updates of crmaccount-maintained data */ IF TG_OP = 'UPDATE' AND (OLD.crmacct_number != NEW.crmacct_number OR OLD.crmacct_name != NEW.crmacct_name) THEN IF NEW.crmacct_cust_id IS NOT NULL THEN UPDATE custinfo SET cust_number = NEW.crmacct_number WHERE ((cust_id=NEW.crmacct_cust_id) AND (cust_number!=NEW.crmacct_number)); UPDATE custinfo SET cust_name = NEW.crmacct_name WHERE ((cust_id=NEW.crmacct_cust_id) AND (cust_name!=NEW.crmacct_name)); END IF; IF NEW.crmacct_emp_id IS NOT NULL THEN UPDATE emp SET emp_code = NEW.crmacct_number WHERE ((emp_id=NEW.crmacct_emp_id) AND (emp_code!=NEW.crmacct_number)); UPDATE emp SET emp_name = NEW.crmacct_name WHERE ((emp_id=NEW.crmacct_emp_id) AND (emp_name!=NEW.crmacct_name)); END IF; IF (NEW.crmacct_prospect_id IS NOT NULL) THEN UPDATE prospect SET prospect_number = NEW.crmacct_number WHERE ((prospect_id=NEW.crmacct_prospect_id) AND (prospect_number!=NEW.crmacct_number)); UPDATE prospect SET prospect_name = NEW.crmacct_name WHERE ((prospect_id=NEW.crmacct_prospect_id) AND (prospect_name!=NEW.crmacct_name)); END IF; IF (NEW.crmacct_salesrep_id IS NOT NULL) THEN UPDATE salesrep SET salesrep_number = NEW.crmacct_number WHERE ((salesrep_id=NEW.crmacct_salesrep_id) AND (salesrep_number!=NEW.crmacct_number)); UPDATE salesrep SET salesrep_name = NEW.crmacct_name WHERE ((salesrep_id=NEW.crmacct_salesrep_id) AND (salesrep_name!=NEW.crmacct_name)); END IF; IF (NEW.crmacct_taxauth_id IS NOT NULL) THEN UPDATE taxauth SET taxauth_code = NEW.crmacct_number WHERE ((taxauth_id=NEW.crmacct_taxauth_id) AND (taxauth_code!=NEW.crmacct_number)); UPDATE taxauth SET taxauth_name = NEW.crmacct_name WHERE ((taxauth_id=NEW.crmacct_taxauth_id) AND (taxauth_name!=NEW.crmacct_name)); END IF; IF (NEW.crmacct_vend_id IS NOT NULL) THEN UPDATE vendinfo SET vend_number = NEW.crmacct_number WHERE ((vend_id=NEW.crmacct_vend_id) AND (vend_number!=NEW.crmacct_number)); UPDATE vendinfo SET vend_name = NEW.crmacct_name WHERE ((vend_id=NEW.crmacct_vend_id) AND (vend_name!=NEW.crmacct_name)); END IF; END IF; IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN -- Link Primary and Secondary Contacts to this Account if they are not already IF (NEW.crmacct_cntct_id_1 IS NOT NULL) THEN UPDATE cntct SET cntct_crmacct_id = NEW.crmacct_id WHERE cntct_id=NEW.crmacct_cntct_id_1 AND COALESCE(cntct_crmacct_id, -1) != NEW.crmacct_id; END IF; IF (NEW.crmacct_cntct_id_2 IS NOT NULL) THEN UPDATE cntct SET cntct_crmacct_id = NEW.crmacct_id WHERE cntct_id=NEW.crmacct_cntct_id_2 AND COALESCE(cntct_crmacct_id, -1) != NEW.crmacct_id; END IF; -- cannot have fkey references to system catalogs so enforce them here IF (NEW.crmacct_usr_username IS NOT NULL) THEN IF (NOT EXISTS(SELECT usr_username FROM usr WHERE usr_username=NEW.crmacct_usr_username)) THEN RAISE EXCEPTION 'User % does not exist so this CRM Account Number is invalid.', NEW.crmacct_usr_username; END IF; IF (TG_OP = 'UPDATE') THEN -- reminder: this evaluates to false if either is NULL IF (NEW.crmacct_usr_username != OLD.crmacct_usr_username) THEN RAISE EXCEPTION 'Cannot change the user name for %', OLD.crmacct_usr_username; END IF; END IF; UPDATE usrpref SET usrpref_value = NEW.crmacct_name WHERE ((usrpref_username=NEW.crmacct_usr_username) AND (usrpref_name='propername') AND (usrpref_value!=NEW.crmacct_name)); END IF; ELSIF (TG_OP = 'DELETE') THEN IF (OLD.crmacct_cust_id IS NOT NULL) THEN RAISE EXCEPTION 'Cannot delete CRM Account because it is a Customer [xtuple: deleteCrmAccount, -1]'; END IF; IF (OLD.crmacct_emp_id IS NOT NULL) THEN RAISE EXCEPTION 'Cannot delete CRM Account because it is an Employee [xtuple: deleteCrmAccount, -7]'; END IF; IF (OLD.crmacct_prospect_id IS NOT NULL) THEN RAISE EXCEPTION 'Cannot delete CRM Account because it is a Prospect [xtuple: deleteCrmAccount, -3]'; END IF; DELETE FROM salesrep WHERE salesrep_id = OLD.crmacct_salesrep_id; IF (OLD.crmacct_salesrep_id IS NOT NULL) THEN RAISE EXCEPTION 'Cannot delete CRM Account because it is a Sales Rep [xtuple: deleteCrmAccount, -6]'; END IF; IF (OLD.crmacct_taxauth_id IS NOT NULL) THEN RAISE EXCEPTION 'Cannot delete CRM Account because it is a Tax Authority [xtuple: deleteCrmAccount, -5]'; END IF; IF (EXISTS(SELECT usename FROM pg_user WHERE usename=OLD.crmacct_usr_username)) THEN RAISE EXCEPTION 'Cannot delete CRM Account because it is a User [xtuple: deleteCrmAccount, -8]'; END IF; IF (OLD.crmacct_vend_id IS NOT NULL) THEN RAISE EXCEPTION 'Cannot delete CRM Account because it is a Vendor [xtuple: deleteCrmAccount, -2]'; END IF; DELETE FROM imageass WHERE (imageass_source_id=OLD.crmacct_id) AND (imageass_source='CRMA'); DELETE FROM url WHERE (url_source_id=OLD.crmacct_id) AND (url_source='CRMA'); END IF; SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (_cmnttypeid IS NOT NULL) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'CRMA', NEW.crmacct_id, ('Created by ' || getEffectiveXtUser())); ELSIF (TG_OP = 'DELETE') THEN PERFORM postComment(_cmnttypeid, 'CRMA', OLD.crmacct_id, 'Deleted "' || OLD.crmacct_number || '"'); END IF; END IF; IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._crmacctaftertrigger() OWNER TO admin; -- -- Name: _crmacctbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _crmacctbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _count INTEGER; BEGIN -- disallow reusing crmacct_numbers IF (TG_OP IN ('INSERT', 'UPDATE')) THEN IF (TG_OP = 'INSERT' AND fetchMetricText('CRMAccountNumberGeneration') IN ('A','O')) THEN PERFORM clearNumberIssue('CRMAccountNumber', NEW.crmacct_number); END IF; NEW.crmacct_usr_username := LOWER(TRIM(NEW.crmacct_usr_username)); IF (NEW.crmacct_usr_username = '') THEN NEW.crmacct_usr_username = NULL; END IF; NEW.crmacct_owner_username := LOWER(TRIM(NEW.crmacct_owner_username)); IF (COALESCE(NEW.crmacct_owner_username, '') = '') THEN NEW.crmacct_owner_username = getEffectiveXtUser(); END IF; IF (NEW.crmacct_competitor_id < 0) THEN NEW.crmacct_competitor_id := NULL; END IF; IF (NEW.crmacct_partner_id < 0) THEN NEW.crmacct_partner_id := NULL; END IF; NEW.crmacct_number = UPPER(NEW.crmacct_number); IF (TG_OP = 'UPDATE') THEN -- TODO: why not ALTER USER OLD.crmacct_number RENAME TO LOWER(NEW.crmacct_number)? IF (NEW.crmacct_number != UPPER(OLD.crmacct_number) AND NEW.crmacct_usr_username IS NOT NULL AND UPPER(NEW.crmacct_usr_username) != NEW.crmacct_number) THEN RAISE EXCEPTION 'The CRM Account % is associated with a system User so the number cannot be changed.', NEW.crmacct_number; END IF; -- It appears possible to remove a user account without cleaning up the CRM account (#25291) -- Tidy up CRM Account in this scenario to prevent errors IF (NEW.crmacct_usr_username IS NOT NULL) THEN IF (NOT EXISTS(SELECT usr_username FROM usr WHERE usr_username=NEW.crmacct_usr_username)) THEN NEW.crmacct_usr_username = NULL; END IF; END IF; END IF; ELSIF (TG_OP = 'DELETE') THEN UPDATE cntct SET cntct_crmacct_id = NULL WHERE cntct_crmacct_id = OLD.crmacct_id; DELETE FROM docass WHERE docass_source_id = OLD.crmacct_id AND docass_source_type = 'CRMA'; DELETE FROM docass WHERE docass_target_id = OLD.crmacct_id AND docass_target_type = 'CRMA'; GET DIAGNOSTICS _count = ROW_COUNT; RAISE DEBUG 'updated % contacts', _count; RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._crmacctbeforetrigger() OWNER TO admin; -- -- Name: _custaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _custaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; _whsId INTEGER := -1; BEGIN IF (TG_OP = 'INSERT') THEN -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE LOOP UPDATE crmacct SET crmacct_cust_id=NEW.cust_id, crmacct_name=NEW.cust_name, crmacct_prospect_id=NULL WHERE crmacct_number=NEW.cust_number; IF (FOUND) THEN DELETE FROM prospect WHERE prospect_id=NEW.cust_id; EXIT; END IF; BEGIN INSERT INTO crmacct(crmacct_number, crmacct_name, crmacct_active, crmacct_type, crmacct_cust_id, crmacct_cntct_id_1, crmacct_cntct_id_2 ) VALUES (NEW.cust_number, NEW.cust_name, NEW.cust_active, 'O', NEW.cust_id, NEW.cust_cntct_id, NEW.cust_corrcntct_id); EXIT; EXCEPTION WHEN unique_violation THEN -- do nothing, and loop to try the UPDATE again END; END LOOP; PERFORM updateCharAssignment('C', NEW.cust_id, char_id, charass_value) FROM custtype JOIN charass ON (custtype_id=charass_target_id AND charass_target_type='CT') JOIN char ON (charass_char_id=char_id) WHERE ((custtype_id=NEW.cust_custtype_id) AND (custtype_char) AND (charass_default)); ELSIF (TG_OP = 'UPDATE') THEN UPDATE crmacct SET crmacct_number = NEW.cust_number WHERE ((crmacct_cust_id=NEW.cust_id) AND (crmacct_number!=NEW.cust_number)); UPDATE crmacct SET crmacct_name = NEW.cust_name WHERE ((crmacct_cust_id=NEW.cust_id) AND (crmacct_name!=NEW.cust_name)); END IF; IF (TG_OP = 'INSERT') THEN PERFORM postEvent('NewCustomer', 'C', NEW.cust_id, NULL, NEW.cust_number, NULL, NULL, NULL, NULL); END IF; IF (fetchMetricBool('CustomerChangeLog')) THEN SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (_cmnttypeid IS NOT NULL) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.cust_number <> NEW.cust_number) THEN PERFORM postComment( _cmnttypeid, 'C', NEW.cust_id, ('Number changed from "' || OLD.cust_number || '" to "' || NEW.cust_number || '"') ); END IF; IF (OLD.cust_name <> NEW.cust_name) THEN PERFORM postComment( _cmnttypeid, 'C', NEW.cust_id, ('Name changed from "' || OLD.cust_name || '" to "' || NEW.cust_name || '"') ); END IF; IF (OLD.cust_active <> NEW.cust_active) THEN PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id, CASE WHEN NEW.cust_active THEN 'Activated' ELSE 'Deactivated' END); END IF; IF (OLD.cust_discntprcnt <> NEW.cust_discntprcnt) THEN PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id, ('Discount changed from "' || formatprcnt(OLD.cust_discntprcnt) || '%" to "' || formatprcnt(NEW.cust_discntprcnt) || '%"') ); END IF; IF (OLD.cust_creditlmt <> NEW.cust_creditlmt) THEN PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id, ('Credit Limit changed from ' || formatMoney(OLD.cust_creditlmt) || ' to ' || formatMoney(NEW.cust_creditlmt))); END IF; IF (OLD.cust_creditstatus <> NEW.cust_creditstatus) THEN PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id, ('Credit Status Changed from "' || CASE OLD.cust_creditstatus WHEN 'G' THEN 'In Good Standing' WHEN 'W' THEN 'Credit Warning' WHEN 'H' THEN 'Credit Hold' ELSE 'Unknown/Error' END || '" to "' || CASE NEW.cust_creditstatus WHEN 'G' THEN 'In Good Standing' WHEN 'W' THEN 'Credit Warning' WHEN 'H' THEN 'Credit Hold' ELSE 'Unknown/Error' END || '"') ); END IF; IF (OLD.cust_custtype_id <> NEW.cust_custtype_id) THEN PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id, ('Customer type changed from "' || (SELECT custtype_code FROM custtype WHERE custtype_id = OLD.cust_custtype_id) || '" to "' || (SELECT custtype_code FROM custtype WHERE custtype_id = NEW.cust_custtype_id) || '"') ); END IF; IF (COALESCE(OLD.cust_gracedays,-1) <> COALESCE(NEW.cust_gracedays,-1)) THEN PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id, ('Grace Days changed from "' || COALESCE(TEXT(OLD.cust_gracedays), 'Default') || '" to "' || COALESCE(TEXT(NEW.cust_gracedays), 'Default') || '"')); END IF; IF (OLD.cust_terms_id <> NEW.cust_terms_id) THEN PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id, ('Terms changed from "' || (SELECT terms_code FROM terms WHERE terms_id = OLD.cust_terms_id) || '" to "' || (SELECT terms_code FROM terms WHERE terms_id = NEW.cust_terms_id) || '"')); END IF; END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._custaftertrigger() OWNER TO admin; -- -- Name: _custinfoafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _custinfoafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- handle transitory state when converting customer to prospect IF EXISTS(SELECT quhead_id FROM quhead WHERE (quhead_cust_id=OLD.cust_id) AND NOT EXISTS(SELECT prospect_id FROM prospect WHERE prospect_id=OLD.cust_id)) THEN RAISE EXCEPTION '[xtuple: deleteCustomer, -8]'; END IF; IF EXISTS(SELECT invchead_id FROM invchead WHERE (invchead_cust_id=OLD.cust_id)) THEN RAISE EXCEPTION '[xtuple: deleteCustomer, -7]'; END IF; -- end TODO IF EXISTS(SELECT checkhead_recip_id FROM checkhead WHERE ((checkhead_recip_id=OLD.cust_id) AND (checkhead_recip_type='C'))) THEN RAISE EXCEPTION '[xtuple: deleteCustomer, -6]'; END IF; DELETE FROM taxreg WHERE ((taxreg_rel_type='C') AND (taxreg_rel_id=OLD.cust_id)); DELETE FROM ipsass WHERE (ipsass_cust_id=OLD.cust_id); DELETE FROM docass WHERE docass_source_id = OLD.cust_id AND docass_source_type = 'C'; DELETE FROM docass WHERE docass_target_id = OLD.cust_id AND docass_target_type = 'C'; DELETE FROM charass WHERE charass_target_type = 'C' AND charass_target_id = OLD.cust_id; IF (fetchMetricBool('CustomerChangeLog')) THEN PERFORM postComment(cmnttype_id, 'C', OLD.cust_id, ('Deleted "' || OLD.cust_number || '"')) FROM cmnttype WHERE (cmnttype_name='ChangeLog'); END IF; RETURN OLD; END; $$; ALTER FUNCTION public._custinfoafterdeletetrigger() OWNER TO admin; -- -- Name: _custinfobeforedeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _custinfobeforedeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF NOT (checkPrivilege('MaintainCustomerMasters')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Customers.'; END IF; UPDATE crmacct SET crmacct_cust_id = NULL WHERE crmacct_cust_id = OLD.cust_id; RETURN OLD; END; $$; ALTER FUNCTION public._custinfobeforedeletetrigger() OWNER TO admin; -- -- Name: _custtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _custtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF NOT (checkPrivilege('MaintainCustomerMasters') OR checkPrivilege('PostMiscInvoices')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Customers.'; END IF; IF (NEW.cust_number IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Customer Number.'; END IF; IF (LENGTH(COALESCE(NEW.cust_name,''))=0) THEN RAISE EXCEPTION 'You must supply a valid Customer Name.'; END IF; IF (NEW.cust_custtype_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Customer Type ID.'; END IF; IF (NEW.cust_salesrep_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Sales Rep ID.'; END IF; IF (NEW.cust_terms_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Terms Code ID.'; END IF; IF (TG_OP = 'INSERT' AND fetchMetricText('CRMAccountNumberGeneration') IN ('A','O')) THEN PERFORM clearNumberIssue('CRMAccountNumber', NEW.cust_number); END IF; NEW.cust_number := UPPER(NEW.cust_number); RETURN NEW; END; $$; ALTER FUNCTION public._custtrigger() OWNER TO admin; -- -- Name: _custtypeafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _custtypeafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (SELECT fetchMetricValue('DefaultCustType') = OLD.custtype_id) THEN RAISE EXCEPTION 'Cannot delete the default Customer Type [xtuple: custtype, -1, %]', OLD.custtype_code; END IF; DELETE FROM charass WHERE charass_target_type = 'CT' AND charass_target_id = OLD.custtype_id; RETURN OLD; END; $$; ALTER FUNCTION public._custtypeafterdeletetrigger() OWNER TO admin; -- -- Name: _custtypetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _custtypetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check BOOLEAN; _code TEXT; BEGIN -- Checks IF (TG_OP IN ('INSERT','UPDATE')) THEN IF (LENGTH(COALESCE(NEW.custtype_code, ''))=0) THEN RAISE EXCEPTION 'You must supply a valid Customer Type Code.'; END IF; SELECT custtype_code INTO _code FROM custtype WHERE ( (UPPER(custtype_code)=UPPER(NEW.custtype_code)) AND (custtype_id<>NEW.custtype_id) ); IF (FOUND) THEN RAISE EXCEPTION 'The Customer Type Code entered cannot be used as it is in use.'; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._custtypetrigger() OWNER TO admin; -- -- Name: _docasstrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _docasstrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (NEW.docass_source_type = 'INCDT') THEN UPDATE incdt SET incdt_updated = now() WHERE incdt_id = NEW.docass_source_id; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._docasstrigger() OWNER TO admin; -- -- Name: _docinfo(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _docinfo(req_id integer, req_type text) RETURNS SETOF _docinfo LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- Return all document associations, optionally limited to the given document type DECLARE _current TEXT := ''; _row _docinfo%rowtype; _desc record; _crm record; _rev TEXT := $$SELECT '' AS revnumber, '' AS revname, '' AS revdesc, -1 AS revid, '' AS revtype$$; _reverseQ TEXT := $$SELECT %s AS revnumber, %s AS revname, %s AS revdesc, %s AS revid, '%s' AS revtype FROM %s %s$$; _docassQ TEXT := $$SELECT docass_id AS id, %s AS target_number, %s AS target_type, %s AS target_id, %s AS source_type, %s AS source_id, %s AS name, %s AS description, docass_purpose AS purpose FROM docass JOIN %s ON docass_target_id = %s %s %s WHERE docass_target_type = '%s' AND docass_source_id = %s AND docass_source_type = '%s' UNION ALL SELECT docass_id AS id, revnumber AS target_number, %s AS target_type, %s AS target_id, %s AS source_type, %s AS source_id, revname AS name, revdesc AS description, CASE WHEN docass_purpose = 'A' THEN 'C' WHEN docass_purpose = 'C' THEN 'A' ELSE docass_purpose END AS purpose FROM docass JOIN %s ON docass_target_id = %s JOIN rev ON revid = docass_source_id AND revtype = docass_source_type %s WHERE docass_target_type = '%s' AND docass_source_id = %s AND docass_source_type = '%s' $$; _imgQ TEXT := $$SELECT imageass_id AS id, image_id::text AS target_number, 'IMG' AS target_type, imageass_image_id AS target_id, imageass_source AS source_type, imageass_source_id AS source_id, image_name AS name, image_descrip AS description, imageass_purpose AS purpose FROM imageass JOIN image ON imageass_image_id=image_id WHERE true AND imageass_source_id = %s AND imageass_source = '%s' $$; _urlQ TEXT := $$SELECT url_id AS id, url_id::text AS target_number, 'URL' AS target_type, url_id AS target_id, url_source AS source_type, url_source_id AS source_id, url_title AS name, url_url AS description, 'S' AS doc_purpose FROM url WHERE (url_stream IS NULL) AND url_source_id = %s AND url_source = '%s' $$; _fileQ TEXT := $$SELECT url_id AS id, url_id::text AS target_number, 'FILE' AS target_type, url_id AS target_id, url_source AS source_type, url_source_id AS source_id, url_title AS name, url_url AS description, 'S' AS doc_purpose FROM url WHERE (url_stream IS NOT NULL) AND url_source_id = %s AND url_source = '%s' $$; _crmIdField TEXT := ''; _crmChildIdField TEXT := ''; BEGIN -- TODO: normalize image, url, and file into docass _current := _current || format(_imgQ, req_id, req_type); _current := _current || ' UNION ALL ' || format(_urlQ, req_id, req_type); _current := _current || ' UNION ALL ' || format(_fileQ, req_id, req_type); SELECT source.* INTO _crm FROM source WHERE source_docass = 'CRMA'; -- must match populate_source.sql FOR _desc IN SELECT source.* FROM source JOIN pg_class c on source_table = relname JOIN pg_namespace n on relnamespace = n.oid JOIN regexp_split_to_table(buildSearchPath(), E',\\s*') sp on nspname = sp WHERE relkind = 'r' LOOP _rev := _rev || ' UNION ALL ' || format(_reverseQ, _desc.source_number_field, _desc.source_name_field, _desc.source_desc_field, _desc.source_key_field, _desc.source_docass, _desc.source_table, _desc.source_joins); _current := _current || ' UNION ALL ' || format(_docassQ, _desc.source_number_field, 'docass_target_type', 'docass_target_id', 'docass_source_type', 'docass_source_id', _desc.source_name_field, _desc.source_desc_field, _desc.source_table, _desc.source_key_field, _desc.source_joins, '', _desc.source_docass, req_id, req_type, 'docass_source_type', 'docass_source_id', 'docass_target_type', 'docass_target_id', _desc.source_table, _desc.source_key_field, _desc.source_joins, _desc.source_docass, req_id, req_type); -- must match populate_source.sql IF _desc.source_docass IN ('C', 'V', 'EMP', 'PSPCT', 'SR', 'USR', 'TAXAUTH') THEN /* for each type of CRM Account child (e.g. customer, vendor), - return all CRM Account child doc associations as belonging to the CRM Account - return all CRM Account document associations as belonging to the child */ CASE _desc.source_docass WHEN 'C' THEN _crmIdField := 'crmacct_cust_id'; _crmChildIdField := 'cust_id'; WHEN 'V' THEN _crmIdField := 'crmacct_vend_id'; _crmChildIdField := 'vend_id'; WHEN 'EMP' THEN _crmIdField := 'crmacct_emp_id'; _crmChildIdField := 'emp_id'; WHEN 'PSPCT' THEN _crmIdField := 'crmacct_prospect_id'; _crmChildIdField := 'prospect_id'; WHEN 'SR' THEN _crmIdField := 'crmacct_salesrep_id'; _crmChildIdField := 'salesrep_id'; WHEN 'USR' THEN _crmIdField := 'crmacct_usr_username'; _crmChildIdField := 'usr_username'; WHEN 'TAXAUTH' THEN _crmIdField := 'crmacct_taxauth_id'; _crmChildIdField := 'taxauth_id'; END CASE; _current := _current || ' UNION ALL ' || format(_docassQ, _crm.source_number_field, '$$' || _crm.source_docass || '$$', _crm.source_key_field, 'docass_source_type', 'docass_source_id', _desc.source_name_field, _desc.source_desc_field, _desc.source_table, _desc.source_key_field, _desc.source_joins, format('JOIN crmacct ON %s = %s', _crmIdField, _crmChildIdField), _desc.source_docass, req_id, req_type, 'docass_source_type', 'docass_source_id', '$$' || _crm.source_docass || '$$', _crm.source_key_field, _desc.source_table, _desc.source_key_field, format('JOIN crmacct ON %s = %s', _crmIdField, _crmChildIdField), _desc.source_docass, req_id, req_type); END IF; END LOOP; _current := 'WITH rev AS (' || _rev || ') ' || _current; FOR _row IN EXECUTE(_current) LOOP RETURN NEXT _row; END LOOP; RETURN; END; $_$; ALTER FUNCTION public._docinfo(req_id integer, req_type text) OWNER TO admin; -- -- Name: _empafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _empafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (fetchMetricBool('EmployeeChangeLog')) THEN PERFORM postComment(cmnttype_id, 'EMP', OLD.emp_id, ('Deleted "' || OLD.emp_code || '"')) FROM cmnttype WHERE (cmnttype_name='ChangeLog'); END IF; DELETE FROM charass WHERE charass_target_type = 'EMP' AND charass_target_id = OLD.emp_id; RETURN OLD; END; $$; ALTER FUNCTION public._empafterdeletetrigger() OWNER TO admin; -- -- Name: _empaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _empaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; _newcrmacctname TEXT; BEGIN IF (TG_OP = 'INSERT') THEN -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE LOOP UPDATE crmacct SET crmacct_emp_id=NEW.emp_id, crmacct_name=NEW.emp_name WHERE crmacct_number=NEW.emp_code; IF (FOUND) THEN EXIT; END IF; BEGIN INSERT INTO crmacct(crmacct_number, crmacct_name, crmacct_active, crmacct_type, crmacct_emp_id, crmacct_cntct_id_1 ) VALUES (NEW.emp_code, NEW.emp_name, NEW.emp_active, 'I', NEW.emp_id, NEW.emp_cntct_id); EXIT; EXCEPTION WHEN unique_violation THEN -- do nothing, and loop to try the UPDATE again END; END LOOP; /* TODO: default characteristic assignments based on empgrp? */ ELSIF (TG_OP = 'UPDATE') THEN UPDATE crmacct SET crmacct_number = NEW.emp_code WHERE ((crmacct_emp_id=NEW.emp_id) AND (crmacct_number!=NEW.emp_code)); UPDATE crmacct SET crmacct_name = NEW.emp_name WHERE ((crmacct_emp_id=NEW.emp_id) AND (crmacct_name!=NEW.emp_name)); END IF; IF (fetchMetricBool('EmployeeChangeLog')) THEN SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (_cmnttypeid IS NOT NULL) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'EMP', NEW.emp_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.emp_number <> NEW.emp_number) THEN PERFORM postComment(_cmnttypeid, 'EMP', NEW.emp_id, ('Number Changed from "' || OLD.emp_number || '" to "' || NEW.emp_number || '"')); END IF; IF (OLD.emp_code <> NEW.emp_code) THEN PERFORM postComment(_cmnttypeid, 'EMP', NEW.emp_id, ('Code Changed from "' || OLD.emp_code || '" to "' || NEW.emp_code || '"')); END IF; IF (OLD.emp_active <> NEW.emp_active) THEN PERFORM postComment(_cmnttypeid, 'EMP', NEW.emp_id, CASE WHEN NEW.emp_active THEN 'Activated' ELSE 'Deactivated' END); END IF; IF (COALESCE(OLD.emp_dept_id, -1) <> COALESCE(NEW.emp_dept_id, -1)) THEN PERFORM postComment(_cmnttypeid, 'EMP', NEW.emp_id, ('Department Changed from "' || COALESCE((SELECT dept_number FROM dept WHERE dept_id=OLD.emp_dept_id), '') || '" to "' || COALESCE((SELECT dept_number FROM dept WHERE dept_id=NEW.emp_dept_id), '') || '"')); END IF; IF (COALESCE(OLD.emp_shift_id, -1) <> COALESCE(NEW.emp_shift_id, -1)) THEN PERFORM postComment(_cmnttypeid, 'EMP', NEW.emp_id, ('Shift Changed from "' || COALESCE((SELECT shift_number FROM shift WHERE shift_id=OLD.emp_shift_id), '') || '" to "' || COALESCE((SELECT shift_number FROM shift WHERE shift_id=NEW.emp_shift_id), '') || '"')); END IF; END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._empaftertrigger() OWNER TO admin; -- -- Name: _empbeforedeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _empbeforedeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF NOT (checkPrivilege('MaintainEmployees')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Employees.'; END IF; UPDATE crmacct SET crmacct_emp_id = NULL WHERE crmacct_emp_id = OLD.emp_id; UPDATE salesrep SET salesrep_emp_id = NULL WHERE salesrep_emp_id = OLD.emp_id; DELETE FROM docass WHERE docass_source_id = OLD.emp_id AND docass_source_type = 'EMP'; DELETE FROM docass WHERE docass_target_id = OLD.emp_id AND docass_target_type = 'EMP'; RETURN OLD; END; $$; ALTER FUNCTION public._empbeforedeletetrigger() OWNER TO admin; -- -- Name: _empbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _empbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF NOT (checkPrivilege('MaintainEmployees')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Employees.'; END IF; IF (NEW.emp_code IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Employee Code.'; END IF; IF (NEW.emp_number IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Employee Number.'; END IF; IF (NEW.emp_id = NEW.emp_mgr_emp_id) THEN RAISE EXCEPTION 'An Employee may not be his or her own Manager.'; END IF; -- ERROR: cannot use column references in default expression IF (NEW.emp_name IS NULL) THEN NEW.emp_name = COALESCE(formatCntctName(NEW.emp_cntct_id), NEW.emp_number); END IF; IF (TG_OP = 'INSERT' AND fetchMetricText('CRMAccountNumberGeneration') IN ('A','O')) THEN PERFORM clearNumberIssue('CRMAccountNumber', NEW.emp_number); END IF; NEW.emp_code := UPPER(NEW.emp_code); -- deprecated column emp_username IF (TG_OP = 'UPDATE' AND LOWER(NEW.emp_username) != LOWER(NEW.emp_code) AND EXISTS(SELECT 1 FROM crmacct WHERE crmacct_emp_id = NEW.emp_id AND crmacct_usr_username IS NOT NULL)) THEN NEW.emp_username = LOWER(NEW.emp_code); END IF; RETURN NEW; END; $$; ALTER FUNCTION public._empbeforetrigger() OWNER TO admin; -- -- Name: _evntlogafterinserttrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _evntlogafterinserttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; BEGIN IF (NEW.evntlog_username = 'autopilot') THEN SELECT * INTO _r FROM evnttype WHERE (evnttype_id=NEW.evntlog_evnttype_id); IF (_r.evnttype_name = 'SoCreated') THEN PERFORM createPrjToSale(NEW.evntlog_ord_id); END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._evntlogafterinserttrigger() OWNER TO admin; -- -- Name: _gltransaltertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _gltransaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _externalCompany BOOLEAN := false; _updated BOOLEAN := false; BEGIN IF(TG_OP='DELETE') THEN RAISE EXCEPTION 'You may not delete G/L Transactions once they have been created.'; ELSIF (TG_OP = 'UPDATE') THEN SELECT company_external INTO _externalCompany FROM company JOIN accnt ON (company_number=accnt_company) WHERE (accnt_id=NEW.gltrans_accnt_id); IF (_externalCompany) THEN RAISE EXCEPTION 'Transactions are not allowed for G/L Accounts with External Company segments.'; END IF; IF(OLD.gltrans_id != NEW.gltrans_id) THEN _updated := true; ELSIF(OLD.gltrans_date != NEW.gltrans_date) THEN _updated := true; ELSIF(OLD.gltrans_accnt_id != NEW.gltrans_accnt_id) THEN _updated := true; ELSIF(OLD.gltrans_amount != NEW.gltrans_amount) THEN _updated := true; ELSIF(OLD.gltrans_username != NEW.gltrans_username) THEN _updated := true; ELSIF( (OLD.gltrans_sequence IS NULL AND NEW.gltrans_sequence IS NOT NULL) OR (OLD.gltrans_sequence IS NOT NULL AND NEW.gltrans_sequence IS NULL) OR (COALESCE(OLD.gltrans_sequence,0) != COALESCE(NEW.gltrans_sequence,0)) ) THEN _updated := true; ELSIF( (OLD.gltrans_created IS NULL AND NEW.gltrans_created IS NOT NULL) OR (OLD.gltrans_created IS NOT NULL AND NEW.gltrans_created IS NULL) OR (COALESCE(OLD.gltrans_created,now()) != COALESCE(NEW.gltrans_created,now())) ) THEN _updated := true; ELSIF( (OLD.gltrans_source IS NULL AND NEW.gltrans_source IS NOT NULL) OR (OLD.gltrans_source IS NOT NULL AND NEW.gltrans_source IS NULL) OR (COALESCE(OLD.gltrans_source,'') != COALESCE(NEW.gltrans_source,'')) ) THEN _updated := true; ELSIF( (OLD.gltrans_docnumber IS NULL AND NEW.gltrans_docnumber IS NOT NULL) OR (OLD.gltrans_docnumber IS NOT NULL AND NEW.gltrans_docnumber IS NULL) OR (COALESCE(OLD.gltrans_docnumber,'') != COALESCE(NEW.gltrans_docnumber,'')) ) THEN _updated := true; ELSIF( (OLD.gltrans_doctype IS NULL AND NEW.gltrans_doctype IS NOT NULL) OR (OLD.gltrans_doctype IS NOT NULL AND NEW.gltrans_doctype IS NULL) OR (COALESCE(OLD.gltrans_doctype,'') != COALESCE(NEW.gltrans_doctype,'')) ) THEN _updated := true; END IF; IF(_updated) THEN RAISE EXCEPTION 'You may not alter some G/L Transaction fields once they have been created.'; END IF; ELSE RAISE EXCEPTION 'trigger for gltrans table called in unexpected state.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._gltransaltertrigger() OWNER TO admin; -- -- Name: _gltransinserttrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _gltransinserttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _reqNotes BOOLEAN; _externalCompany BOOLEAN := false; BEGIN -- Checks -- Start with privileges IF ((NEW.gltrans_doctype='JE') AND (NOT checkPrivilege('PostJournalEntries'))) THEN RAISE EXCEPTION 'You do not have privileges to create a Journal Entry.'; END IF; SELECT company_external INTO _externalCompany FROM company JOIN accnt ON (company_number=accnt_company) WHERE (accnt_id=NEW.gltrans_accnt_id); IF (_externalCompany) THEN RAISE EXCEPTION 'Transactions are not allowed for G/L Accounts with External Company segments.'; END IF; -- RAISE NOTICE '_gltransInsertTrigger(): company_external = %', _externalCompany; SELECT metric_value='t' INTO _reqNotes FROM metric WHERE(metric_name='MandatoryGLEntryNotes'); IF (_reqNotes IS NULL) THEN _reqNotes := false; END IF; IF ((NEW.gltrans_doctype='JE') AND _reqNotes AND (TRIM(BOTH FROM COALESCE(NEW.gltrans_notes,''))='')) THEN RAISE EXCEPTION 'Notes are required for Journal Entries.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._gltransinserttrigger() OWNER TO admin; -- -- Name: _grpprivtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _grpprivtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check BOOLEAN; _returnVal INTEGER; BEGIN -- This looks like a candidate for a foreign key but isn't. -- fkeys don't work if the foreign key value resides in a child of the -- table and not the table itself. IF ((TG_OP = 'UPDATE' OR TG_OP = 'INSERT') AND (NOT EXISTS(SELECT priv_id FROM priv WHERE (priv_id=NEW.grppriv_priv_id)))) THEN RAISE EXCEPTION 'Privilege id % does not exist or is part of a disabled package.', NEW.grppriv_priv_id; RETURN OLD; ELSIF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._grpprivtrigger() OWNER TO admin; -- -- Name: _imageasstrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _imageasstrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (NEW.imageass_source = 'INCDT') THEN UPDATE incdt SET incdt_updated = now() WHERE incdt_id = NEW.imageass_source_id; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._imageasstrigger() OWNER TO admin; -- -- Name: _incdtafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _incdtafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'INCDT' AND charass_target_id = OLD.incdt_id; RETURN OLD; END; $$; ALTER FUNCTION public._incdtafterdeletetrigger() OWNER TO admin; -- -- Name: _incdtbeforedeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _incdtbeforedeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _recurid INTEGER; _newparentid INTEGER; BEGIN IF (TG_OP = 'DELETE') THEN SELECT recur_id INTO _recurid FROM recur WHERE ((recur_parent_id=OLD.incdt_id) AND (recur_parent_type='INCDT')); IF (_recurid IS NOT NULL) THEN SELECT MIN(incdt_id) INTO _newparentid FROM incdt WHERE ((incdt_recurring_incdt_id=OLD.inctd_id) AND (incdt_id!=OLD.incdt_id)); -- client is responsible for warning about deleting a recurring incdt IF (_newparentid IS NULL) THEN DELETE FROM recur WHERE recur_id=_recurid; ELSE UPDATE recur SET recur_parent_id=_newparentid WHERE recur_id=_recurid; END IF; END IF; RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._incdtbeforedeletetrigger() OWNER TO admin; -- -- Name: _incdtbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _incdtbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _rec RECORD; _check BOOLEAN; _crmacct INTEGER; BEGIN IF(TG_OP = 'DELETE') THEN _rec := OLD; ELSE _rec := NEW; END IF; -- Set the incident number if blank IF (TG_OP = 'INSERT') THEN IF (NEW.incdt_number IS NULL) THEN SELECT fetchIncidentNumber() INTO NEW.incdt_number; END IF; --- clear the number from the issue cache PERFORM clearNumberIssue('IncidentNumber', NEW.incdt_number); END IF; -- Description is required IF (LENGTH(COALESCE(NEW.incdt_summary,''))=0) THEN RAISE EXCEPTION 'You must supply a valid Incident Description.'; END IF; -- CRM Account is required IF (NEW.incdt_crmacct_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid CRM Account.'; END IF; -- Contact is required IF (NEW.incdt_cntct_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Contact.'; END IF; NEW.incdt_updated := now(); RETURN NEW; END; $$; ALTER FUNCTION public._incdtbeforetrigger() OWNER TO admin; -- -- Name: _incdttrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _incdttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; _counter INTEGER := 0; _whsId INTEGER := -1; _evntType TEXT; _cmnttypeid INTEGER := -1; _cmntid INTEGER := -1; BEGIN SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='Notes to Comment'); IF NOT FOUND OR _cmnttypeid IS NULL THEN _cmnttypeid := -1; END IF; IF (TG_OP = 'DELETE') THEN -- This should never happen RETURN OLD; ELSIF (TG_OP = 'INSERT') THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_change, incdthist_target_id, incdthist_descrip) VALUES(NEW.incdt_id, 'N', NULL, 'Incident Added'); _evntType = 'NewIncident'; IF (_cmnttypeid <> -1 AND COALESCE(NEW.incdt_descrip, '') <> '') THEN PERFORM postComment(_cmnttypeid, 'INCDT', NEW.incdt_id, NEW.incdt_descrip); END IF; ELSIF (TG_OP = 'UPDATE') THEN _evntType = 'UpdatedIncident'; IF (COALESCE(NEW.incdt_cntct_id,-1) <> COALESCE(OLD.incdt_cntct_id,-1)) THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_change, incdthist_target_id, incdthist_descrip) VALUES(NEW.incdt_id, 'C', NEW.incdt_cntct_id, ('Contact Changed: "' || COALESCE((SELECT cntct_first_name || ' ' || cntct_last_name FROM cntct WHERE (cntct_id=OLD.incdt_cntct_id)), '') || '" -> "' || COALESCE((SELECT cntct_first_name || ' ' || cntct_last_name FROM cntct WHERE (cntct_id=NEW.incdt_cntct_id)), '') || '"') ); END IF; IF (COALESCE(NEW.incdt_summary,'') <> COALESCE(OLD.incdt_summary,'')) THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_descrip) VALUES(NEW.incdt_id, ('Description Updated: "' || COALESCE(OLD.incdt_summary, '') || '" -> "' || COALESCE(NEW.incdt_summary, '') || '"') ); END IF; IF (COALESCE(NEW.incdt_descrip,'') <> COALESCE(OLD.incdt_descrip,'')) THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_descrip) VALUES(NEW.incdt_id, ('Notes Updated: "' || substr(COALESCE(OLD.incdt_descrip, ''), 1, 20) || '..." -> "' || substr(COALESCE(NEW.incdt_descrip, ''), 1, 20) || '..."') ); IF (_cmnttypeid <> -1) THEN -- find an existing comment SELECT comment_id INTO _cmntid FROM comment WHERE comment_source = 'INCDT' AND comment_source_id = NEW.incdt_id -- back out change for 21068 -- AND comment_user = getEffectiveXtUser() AND comment_cmnttype_id = _cmnttypeid; IF FOUND THEN UPDATE comment SET comment_text = NEW.incdt_descrip WHERE comment_id = _cmntid; ELSE PERFORM postComment(_cmnttypeid, 'INCDT', NEW.incdt_id, NEW.incdt_descrip); END IF; END IF; END IF; IF (NEW.incdt_status <> OLD.incdt_status) THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_change, incdthist_target_id, incdthist_descrip) VALUES(NEW.incdt_id, 'S', NULL, ('Status Changed: ' || CASE WHEN(OLD.incdt_status='N') THEN 'New' WHEN(OLD.incdt_status='F') THEN 'Feedback' WHEN(OLD.incdt_status='C') THEN 'Confirmed' WHEN(OLD.incdt_status='A') THEN 'Assigned' WHEN(OLD.incdt_status='R') THEN 'Resolved' WHEN(OLD.incdt_status='L') THEN 'Closed' ELSE OLD.incdt_status END || ' -> ' || CASE WHEN(NEW.incdt_status='N') THEN 'New' WHEN(NEW.incdt_status='F') THEN 'Feedback' WHEN(NEW.incdt_status='C') THEN 'Confirmed' WHEN(NEW.incdt_status='A') THEN 'Assigned' WHEN(NEW.incdt_status='R') THEN 'Resolved' WHEN(NEW.incdt_status='L') THEN 'Closed' ELSE NEW.incdt_status END ) ); IF (NEW.incdt_status = 'L') THEN _evntType = 'ClosedIncident'; ELSIF (OLD.incdt_status = 'L') THEN _evntType = 'ReopenedIncident'; END IF; END IF; IF (COALESCE(NEW.incdt_assigned_username,'') <> COALESCE(OLD.incdt_assigned_username,'')) THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_change, incdthist_target_id, incdthist_descrip) VALUES(NEW.incdt_id, 'A', NULL, ('Assigned to: "' || COALESCE(OLD.incdt_assigned_username, '') || '" -> "' || COALESCE(NEW.incdt_assigned_username, '') || '"') ); END IF; IF (COALESCE(NEW.incdt_incdtcat_id,-1) <> COALESCE(OLD.incdt_incdtcat_id,-1)) THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_change, incdthist_target_id, incdthist_descrip) VALUES(NEW.incdt_id, 'T', NEW.incdt_incdtcat_id, ('Category Changed: ' || COALESCE((SELECT incdtcat_name FROM incdtcat WHERE (incdtcat_id=OLD.incdt_incdtcat_id)), '') || ' -> ' || COALESCE((SELECT incdtcat_name FROM incdtcat WHERE (incdtcat_id=NEW.incdt_incdtcat_id)), '') || '') ); END IF; IF (COALESCE(NEW.incdt_incdtseverity_id,-1) <> COALESCE(OLD.incdt_incdtseverity_id,-1)) THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_change, incdthist_target_id, incdthist_descrip) VALUES(NEW.incdt_id, 'V', NEW.incdt_incdtseverity_id, ('Severity Changed: ' || COALESCE((SELECT incdtseverity_name FROM incdtseverity WHERE (incdtseverity_id=OLD.incdt_incdtseverity_id)), '') || ' -> ' || COALESCE((SELECT incdtseverity_name FROM incdtseverity WHERE (incdtseverity_id=NEW.incdt_incdtseverity_id)), '') || '') ); END IF; IF (COALESCE(NEW.incdt_incdtpriority_id,-1) <> COALESCE(OLD.incdt_incdtpriority_id,-1)) THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_change, incdthist_target_id, incdthist_descrip) VALUES(NEW.incdt_id, 'P', NEW.incdt_incdtpriority_id, ('Priority Changed: ' || COALESCE((SELECT incdtpriority_name FROM incdtpriority WHERE (incdtpriority_id=OLD.incdt_incdtpriority_id)), '') || ' -> ' || COALESCE((SELECT incdtpriority_name FROM incdtpriority WHERE (incdtpriority_id=NEW.incdt_incdtpriority_id)), '') || '') ); END IF; IF (COALESCE(NEW.incdt_incdtresolution_id,-1) <> COALESCE(OLD.incdt_incdtresolution_id,-1)) THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_change, incdthist_target_id, incdthist_descrip) VALUES(NEW.incdt_id, 'E', NEW.incdt_incdtresolution_id, ('Resolution Changed: ' || COALESCE((SELECT incdtresolution_name FROM incdtresolution WHERE (incdtresolution_id=OLD.incdt_incdtresolution_id)), '') || ' -> ' || COALESCE((SELECT incdtresolution_name FROM incdtresolution WHERE (incdtresolution_id=NEW.incdt_incdtresolution_id)), '') || '') ); END IF; END IF; PERFORM postEvent(_evntType, 'IC', NEW.incdt_id, NULL, NEW.incdt_number::TEXT, NULL, NULL, NULL, NULL); RETURN NEW; END; $$; ALTER FUNCTION public._incdttrigger() OWNER TO admin; -- -- Name: _invcheadafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _invcheadafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'INV' AND charass_target_id = OLD.invchead_id; RETURN OLD; END; $$; ALTER FUNCTION public._invcheadafterdeletetrigger() OWNER TO admin; -- -- Name: _invcheadaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _invcheadaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; _cohead_id INTEGER; BEGIN -- Create a comment entry when on a Sales Order when an Invoice is Posted for that order -- Cache the cmnttype_id for ChangeLog SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (FOUND) THEN IF (TG_OP = 'UPDATE') THEN IF ((OLD.invchead_posted != NEW.invchead_posted) AND NEW.invchead_posted) THEN SELECT cohead_id INTO _cohead_id FROM cohead WHERE (cohead_number = OLD.invchead_ordernumber); IF (FOUND) THEN PERFORM postComment( _cmnttypeid, 'S', _cohead_id, ('Invoice, ' || NEW.invchead_invcnumber || ', posted for this order') ); END IF; END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._invcheadaftertrigger() OWNER TO admin; -- -- Name: _invcheadbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _invcheadbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _recurid INTEGER; _newparentid INTEGER; BEGIN IF (TG_OP = 'UPDATE') THEN IF (OLD.invchead_posted AND ((OLD.invchead_invcnumber != NEW.invchead_invcnumber) OR (OLD.invchead_invcdate != NEW.invchead_invcdate) OR (OLD.invchead_terms_id != NEW.invchead_terms_id) OR (OLD.invchead_salesrep_id != NEW.invchead_salesrep_id) OR (OLD.invchead_commission != NEW.invchead_commission) OR (OLD.invchead_taxzone_id != NEW.invchead_taxzone_id) OR (OLD.invchead_shipchrg_id != NEW.invchead_shipchrg_id) OR (OLD.invchead_prj_id != NEW.invchead_prj_id) OR (OLD.invchead_misc_accnt_id != NEW.invchead_misc_accnt_id) OR (OLD.invchead_misc_amount != NEW.invchead_misc_amount) OR (OLD.invchead_freight != NEW.invchead_freight))) THEN RAISE EXCEPTION 'Edit not allow on Posted Invoice.'; END IF; END IF; IF (TG_OP = 'DELETE') THEN DELETE FROM invcheadtax WHERE (taxhist_parent_id=OLD.invchead_id); SELECT recur_id INTO _recurid FROM recur WHERE ((recur_parent_id=OLD.invchead_id) AND (recur_parent_type='I')); IF (_recurid IS NOT NULL) THEN SELECT invchead_id INTO _newparentid FROM invchead WHERE ((invchead_recurring_invchead_id=OLD.invchead_id) AND (invchead_id!=OLD.invchead_id)) ORDER BY invchead_invcdate LIMIT 1; IF (_newparentid IS NULL) THEN DELETE FROM recur WHERE recur_id=_recurid; ELSE UPDATE recur SET recur_parent_id=_newparentid WHERE recur_id=_recurid; UPDATE invchead SET invchead_recurring_invchead_id=_newparentid WHERE invchead_recurring_invchead_id=OLD.invchead_id AND invchead_id!=OLD.invchead_id; END IF; END IF; RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._invcheadbeforetrigger() OWNER TO admin; -- -- Name: _invcheadtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _invcheadtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN -- Something can go here RETURN OLD; END IF; -- Insert new row IF (TG_OP = 'INSERT') THEN -- Calculate Freight Tax IF (NEW.invchead_freight <> 0) THEN PERFORM calculateTaxHist( 'invcheadtax', NEW.invchead_id, NEW.invchead_taxzone_id, getFreightTaxtypeId(), NEW.invchead_invcdate, NEW.invchead_curr_id, NEW.invchead_freight ); END IF; --- clear the number from the issue cache PERFORM clearNumberIssue('InvcNumber', NEW.invchead_invcnumber); END IF; -- Update row IF (TG_OP = 'UPDATE') THEN IF ( (NEW.invchead_freight <> OLD.invchead_freight) OR (COALESCE(NEW.invchead_taxzone_id,-1) <> COALESCE(OLD.invchead_taxzone_id,-1)) OR (NEW.invchead_invcdate <> OLD.invchead_invcdate) OR (NEW.invchead_curr_id <> OLD.invchead_curr_id) ) THEN -- Calculate invchead Tax PERFORM calculateTaxHist( 'invcheadtax', NEW.invchead_id, NEW.invchead_taxzone_id, getFreightTaxtypeId(), NEW.invchead_invcdate, NEW.invchead_curr_id, NEW.invchead_freight ); END IF; IF ( (COALESCE(NEW.invchead_taxzone_id,-1) <> COALESCE(OLD.invchead_taxzone_id,-1)) OR (NEW.invchead_invcdate <> OLD.invchead_invcdate) OR (NEW.invchead_curr_id <> OLD.invchead_curr_id) ) THEN -- Calculate invcitem Tax IF (COALESCE(NEW.invchead_taxzone_id,-1) <> COALESCE(OLD.invchead_taxzone_id,-1)) THEN UPDATE invcitem SET invcitem_taxtype_id=getItemTaxType(invcitem_item_id,NEW.invchead_taxzone_id) WHERE (invcitem_invchead_id=NEW.invchead_id); PERFORM calculateTaxHist( 'invcitemtax', invcitem_id, NEW.invchead_taxzone_id, invcitem_taxtype_id, NEW.invchead_invcdate, NEW.invchead_curr_id, (invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio) ) FROM invcitem WHERE (invcitem_invchead_id = NEW.invchead_id); END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._invcheadtrigger() OWNER TO admin; -- -- Name: _invcitembeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _invcitembeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _itemfractional BOOLEAN; BEGIN IF (TG_OP = 'DELETE') THEN DELETE FROM invcitemtax WHERE (taxhist_parent_id=OLD.invcitem_id); RETURN OLD; END IF; IF (TG_OP IN ('UPDATE','DELETE')) THEN IF (SELECT COUNT(invchead_id) > 0 FROM invchead WHERE ((invchead_id=OLD.invcitem_invchead_id) AND (invchead_posted))) THEN RAISE EXCEPTION 'Edit not allowed on Posted Invoices.'; END IF; END IF; -- If regular Item then enforce item_fractional IF (COALESCE(NEW.invcitem_item_id, -1) <> -1) THEN SELECT itemuomfractionalbyuom(NEW.invcitem_item_id, NEW.invcitem_qty_uom_id) INTO _itemfractional; IF (NOT _itemfractional) THEN IF (TRUNC(NEW.invcitem_ordered) <> NEW.invcitem_ordered) THEN RAISE EXCEPTION 'Item does not support fractional quantities'; END IF; IF (TRUNC(NEW.invcitem_billed) <> NEW.invcitem_billed) THEN RAISE EXCEPTION 'Item does not support fractional quantities'; END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._invcitembeforetrigger() OWNER TO admin; -- -- Name: _invcitemtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _invcitemtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; -- Cache Invoice Head SELECT * INTO _r FROM invchead WHERE (invchead_id=NEW.invcitem_invchead_id); IF (NOT FOUND) THEN RAISE EXCEPTION 'Invoice head not found'; END IF; -- Insert new row IF (TG_OP = 'INSERT') THEN -- Calculate Tax PERFORM calculateTaxHist( 'invcitemtax', NEW.invcitem_id, COALESCE(_r.invchead_taxzone_id, -1), NEW.invcitem_taxtype_id, COALESCE(_r.invchead_invcdate, CURRENT_DATE), COALESCE(_r.invchead_curr_id, -1), (NEW.invcitem_billed * NEW.invcitem_qty_invuomratio) * (NEW.invcitem_price / NEW.invcitem_price_invuomratio) ); END IF; -- Update row IF (TG_OP = 'UPDATE') THEN -- Calculate Tax IF ( (NEW.invcitem_billed <> OLD.invcitem_billed) OR (NEW.invcitem_qty_invuomratio <> OLD.invcitem_qty_invuomratio) OR (NEW.invcitem_price <> OLD.invcitem_price) OR (NEW.invcitem_price_invuomratio <> OLD.invcitem_price_invuomratio) OR (COALESCE(NEW.invcitem_taxtype_id, -1) <> COALESCE(OLD.invcitem_taxtype_id, -1)) ) THEN PERFORM calculateTaxHist( 'invcitemtax', NEW.invcitem_id, COALESCE(_r.invchead_taxzone_id, -1), NEW.invcitem_taxtype_id, COALESCE(_r.invchead_invcdate, CURRENT_DATE), COALESCE(_r.invchead_curr_id, -1), (NEW.invcitem_billed * NEW.invcitem_qty_invuomratio) * (NEW.invcitem_price / NEW.invcitem_price_invuomratio) ); END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._invcitemtrigger() OWNER TO admin; -- -- Name: _ipsassbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _ipsassbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Checks IF NOT (checkPrivilege('MaintainPricingSchedules')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Price Schedules.'; END IF; -- Business logic, disallow invalid combinations IF (TG_OP IN ('INSERT','UPDATE')) THEN IF (LENGTH(COALESCE(NEW.ipsass_custtype_pattern,'')) != 0) THEN new.ipsass_cust_id = -1; new.ipsass_custtype_id = -1; new.ipsass_shipto_id = -1; new.ipsass_shipto_pattern = ''; ELSIF (COALESCE(NEW.ipsass_custtype_id,-1) > -1) THEN new.ipsass_cust_id = -1; new.ipsass_shipto_id = -1; new.ipsass_shipto_pattern = ''; new.ipsass_custtype_pattern = ''; ELSIF (LENGTH(COALESCE(NEW.ipsass_shipto_pattern,'')) != 0) THEN new.ipsass_custtype_id = -1; new.ipsass_shipto_id = -1; new.ipsass_custtype_pattern = ''; ELSE new.ipsass_shipto_id = COALESCE(NEW.ipsass_shipto_id,-1); new.ipsass_custtype_id = -1; new.ipsass_shipto_pattern = ''; new.ipsass_custtype_pattern = ''; END IF; RETURN NEW; ELSE RETURN OLD; END IF; END; $$; ALTER FUNCTION public._ipsassbeforetrigger() OWNER TO admin; -- -- Name: _ipsheadbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _ipsheadbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Checks IF NOT (checkPrivilege('MaintainPricingSchedules')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Price Schedules.'; END IF; IF (TG_OP IN ('INSERT','UPDATE')) THEN RETURN NEW; ELSE RETURN OLD; END IF; END; $$; ALTER FUNCTION public._ipsheadbeforetrigger() OWNER TO admin; -- -- Name: _ipsitemcharbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _ipsitemcharbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Checks IF NOT (checkPrivilege('MaintainPricingSchedules')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Price Schedules.'; END IF; IF (TG_OP IN ('INSERT','UPDATE')) THEN IF (SELECT (COUNT(item_id)=0) FROM ipsiteminfo JOIN item ON (item_id=ipsitem_item_id) WHERE ((ipsitem_id=NEW.ipsitemchar_ipsitem_id) AND (item_config))) THEN RAISE EXCEPTION 'Characteristic prices may only be set on configured items.'; ELSIF (SELECT (COUNT(item_id)=0) FROM ipsiteminfo JOIN item ON (item_id=ipsitem_item_id) JOIN charass ON (charass_target_id=item_id AND charass_target_type='I') WHERE ((ipsitem_id=NEW.ipsitemchar_ipsitem_id) AND (charass_char_id=NEW.ipsitemchar_char_id) AND (charass_value=NEW.ipsitemchar_value))) THEN RAISE EXCEPTION 'No characteristic with matching value exists for this item.'; END IF; RETURN NEW; ELSE RETURN OLD; END IF; END; $$; ALTER FUNCTION public._ipsitemcharbeforetrigger() OWNER TO admin; -- -- Name: _ipsiteminfobeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _ipsiteminfobeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN -- Checks IF NOT (checkPrivilege('MaintainPricingSchedules')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Price Schedules.'; END IF; IF (TG_OP IN ('INSERT','UPDATE')) THEN RETURN NEW; ELSE RETURN OLD; END IF; END; $$; ALTER FUNCTION public._ipsiteminfobeforetrigger() OWNER TO admin; -- -- Name: _item_uom_check(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _item_uom_check() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- This trigger checks the all item uom_id columns have valid conversion ratios. BEGIN IF (NEW.item_active AND NEW.item_sold) THEN IF (NEW.item_inv_uom_id <> NEW.item_price_uom_id) THEN BEGIN PERFORM itemuomtouomratio(NEW.item_id, NEW.item_inv_uom_id, NEW.item_price_uom_id) FROM item WHERE TRUE AND item_id = NEW.item_id; EXCEPTION WHEN SQLSTATE 'P0001' THEN RAISE EXCEPTION 'An invalid UOM was set on this item. Please verify that the Unit Price UOM has a conversion to the Inventory UOM.'; END; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._item_uom_check() OWNER TO admin; -- -- Name: _itemafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _itemafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'I' AND charass_target_id = OLD.item_id; RETURN OLD; END; $$; ALTER FUNCTION public._itemafterdeletetrigger() OWNER TO admin; -- -- Name: _itemaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _itemaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainItemMasters')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Items.'; END IF; -- Integrity checks IF (TG_OP = 'UPDATE') THEN IF ((OLD.item_type <> NEW.item_type) AND (NEW.item_type = 'L')) THEN IF (SELECT COUNT(*) != 0 FROM bomitem WHERE (bomitem_item_id = OLD.item_id)) THEN RAISE EXCEPTION 'This item is part of one or more Bills of Materials and cannot be a Planning Item.'; END IF; END IF; IF ((OLD.item_type <> NEW.item_type) AND (NEW.item_type IN ('R','S','T'))) THEN IF (SELECT COUNT(*) != 0 FROM itemsite WHERE ((itemsite_item_id=OLD.item_id) AND (itemsite_qtyonhand + qtyallocated(itemsite_id,startoftime(),endoftime()) + qtyordered(itemsite_id,startoftime(),endoftime()) > 0 ))) THEN RAISE EXCEPTION 'Item type not allowed when there are itemsites with quantities with on hand quantities or pending inventory activity for this item.'; END IF; END IF; -- If type changed remove costs and deactivate item sites IF (NEW.item_type <> OLD.item_type) THEN PERFORM updateCost(itemcost_id, 0) FROM itemcost WHERE (itemcost_item_id=OLD.item_id); UPDATE itemsite SET itemsite_active=false WHERE (itemsite_item_id=OLD.item_id); IF (NEW.item_type = 'R') THEN UPDATE itemsite SET itemsite_controlmethod='N' WHERE (itemsite_item_id=OLD.item_id); END IF; END IF; END IF; IF ( SELECT (metric_value='t') FROM metric WHERE (metric_name='ItemChangeLog') ) THEN -- Cache the cmnttype_id for ChangeLog SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (FOUND) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'I', NEW.item_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.item_active <> NEW.item_active) THEN IF (NEW.item_active) THEN PERFORM postComment(_cmnttypeid, 'I', NEW.item_id, 'Activated'); ELSE PERFORM postComment(_cmnttypeid, 'I', NEW.item_id, 'Deactivated'); END IF; END IF; IF (OLD.item_descrip1 <> NEW.item_descrip1) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Description 1 Changed from "' || OLD.item_descrip1 || '" to "' || NEW.item_descrip1 || '"' ) ); END IF; IF (OLD.item_descrip2 <> NEW.item_descrip2) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Description 2 Changed from "' || OLD.item_descrip2 || '" to "' || NEW.item_descrip2 || '"' ) ); END IF; IF (OLD.item_inv_uom_id <> NEW.item_inv_uom_id) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Inventory UOM Changed from "' || (SELECT uom_name FROM uom WHERE uom_id=OLD.item_inv_uom_id) || '" (' || CAST(OLD.item_inv_uom_id AS TEXT) || ') to "' || (SELECT uom_name FROM uom WHERE uom_id=NEW.item_inv_uom_id) || '" (' || CAST(NEW.item_inv_uom_id AS TEXT) || ')' ) ); END IF; IF (OLD.item_sold <> NEW.item_sold) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, CASE WHEN (NEW.item_sold) THEN 'Sold Changed from FALSE to TRUE' ELSE 'Sold Changed from TRUE to FALSE' END ); END IF; IF (OLD.item_picklist <> NEW.item_picklist) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, CASE WHEN (NEW.item_picklist) THEN 'Pick List Changed from FALSE to TRUE' ELSE 'Pick List Changed from TRUE to FALSE' END ); END IF; IF (OLD.item_fractional <> NEW.item_fractional) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, CASE WHEN (NEW.item_fractional) THEN 'Fractional Changed from FALSE to TRUE' ELSE 'Fractional Changed from TRUE to FALSE' END ); END IF; IF (OLD.item_exclusive <> NEW.item_exclusive) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, CASE WHEN (NEW.item_exclusive) THEN 'Exclusive Changed from FALSE to TRUE' ELSE 'Exclusive Changed from TRUE to FALSE' END ); END IF; IF (OLD.item_config <> NEW.item_config) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, CASE WHEN (NEW.item_config) THEN 'Configured Changed from FALSE to TRUE' ELSE 'Configured Changed from TRUE to FALSE' END ); END IF; IF (OLD.item_listprice <> NEW.item_listprice) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'List Price Changed from "' || formatSalesPrice(OLD.item_listprice) || '" to "' || formatSalesPrice(NEW.item_listprice) || '"' ) ); END IF; -- Add New stuff IF (OLD.item_type <> NEW.item_type) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Type Changed from "' || OLD.item_type || '" to "' || NEW.item_type || '"' ) ); END IF; IF (OLD.item_price_uom_id <> NEW.item_price_uom_id) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Price UOM Changed from "' || (SELECT uom_name FROM uom WHERE uom_id=OLD.item_price_uom_id) || '" (' || CAST(OLD.item_price_uom_id AS TEXT) || ') to "' || (SELECT uom_name FROM uom WHERE uom_id=NEW.item_price_uom_id) || '" (' || CAST(NEW.item_price_uom_id AS TEXT) || ')' ) ); END IF; IF (OLD.item_classcode_id <> NEW.item_classcode_id) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Class Code Changed from "' || (SELECT classcode_code || '-' || classcode_descrip FROM classcode WHERE classcode_id=OLD.item_classcode_id) || '" (' || CAST(OLD.item_classcode_id AS TEXT) || ') to "' || (SELECT classcode_code || '-' || classcode_descrip FROM classcode WHERE classcode_id=NEW.item_classcode_id) || '" (' || CAST(NEW.item_classcode_id AS TEXT) || ')' ) ); END IF; IF (OLD.item_freightclass_id <> NEW.item_freightclass_id) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Freight Class Changed from "' || (SELECT freightclass_code || '-' || freightclass_descrip FROM freightclass WHERE freightclass_id=OLD.item_freightclass_id) || '" (' || CAST(OLD.item_freightclass_id AS TEXT) || ') to "' || (SELECT freightclass_code || '-' || freightclass_descrip FROM freightclass WHERE freightclass_id=NEW.item_freightclass_id) || '" (' || CAST(NEW.item_freightclass_id AS TEXT) || ')' ) ); END IF; IF (OLD.item_prodcat_id <> NEW.item_prodcat_id) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Product Category Changed from "' || (SELECT prodcat_code || '-' || prodcat_descrip FROM prodcat WHERE prodcat_id=OLD.item_prodcat_id) || '" (' || CAST(OLD.item_prodcat_id AS TEXT) || ') to "' || (SELECT prodcat_code || '-' || prodcat_descrip FROM prodcat WHERE prodcat_id=NEW.item_prodcat_id) || '" (' || CAST(NEW.item_prodcat_id AS TEXT) || ')' ) ); END IF; IF (OLD.item_upccode <> NEW.item_upccode) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'UPC Code Changed from "' || OLD.item_upccode || '" to "' || NEW.item_upccode || '"' ) ); END IF; IF (OLD.item_prodweight <> NEW.item_prodweight) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Product Weight Changed from "' || formatWeight(OLD.item_prodweight) || '" to "' || formatWeight(NEW.item_prodweight) || '"' ) ); END IF; IF (OLD.item_packweight <> NEW.item_packweight) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Packaging Weight Changed from "' || formatWeight(OLD.item_packweight) || '" to "' || formatWeight(NEW.item_packweight) || '"' ) ); END IF; IF (OLD.item_maxcost <> NEW.item_maxcost) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Maximum Desired Cost Changed from "' || formatCost(OLD.item_maxcost) || '" to "' || formatCost(NEW.item_maxcost) || '"' ) ); END IF; IF (OLD.item_listcost <> NEW.item_listcost) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'List Cost Changed from "' || formatCost(OLD.item_listcost) || '" to "' || formatCost(NEW.item_listcost) || '"' ) ); END IF; -- End changes END IF; END IF; END IF; IF (TG_OP = 'DELETE') THEN DELETE FROM imageass WHERE ((imageass_source_id=OLD.item_id) AND (imageass_source='I')); DELETE FROM url WHERE ((url_source_id=OLD.item_id) AND (url_source='I')); DELETE FROM docass WHERE docass_source_id = OLD.item_id AND docass_source_type = 'I'; DELETE FROM docass WHERE docass_target_id = OLD.item_id AND docass_target_type = 'I'; RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._itemaftertrigger() OWNER TO admin; -- -- Name: _itemaliastrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _itemaliastrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainItemMasters')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Item Aliases.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._itemaliastrigger() OWNER TO admin; -- -- Name: _itemcostaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _itemcostaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _itemNumber TEXT; _maxCost NUMERIC; _oldStdCost NUMERIC; _oldActCost NUMERIC; _actualCost NUMERIC; _standardCost NUMERIC; BEGIN -- Create Event if Standard or Actual Cost is greater than Max Cost IF NOT EXISTS(SELECT 1 FROM evntnot JOIN evnttype ON (evnttype_id = evntnot_evnttype_id) JOIN usrpref ON (evntnot_username = usrpref_username) WHERE evnttype_name = 'CostExceedsMaxDesired' AND usrpref_name = 'active' AND usrpref_value = 't') THEN RETURN NEW; END IF; SELECT item_number, item_maxcost, actcost(item_id), stdcost(item_id) INTO _itemNumber, _maxCost, _actualCost, _standardCost FROM item WHERE (item_id=NEW.itemcost_item_id); IF (_maxCost > 0.0) THEN -- IF (_standardCost > _maxCost) IF NOT EXISTS(SELECT 1 --COUNT(evntlog_id) FROM evntlog, evnttype WHERE evntlog_evnttype_id = evnttype_id AND evntlog_number LIKE (_itemNumber || ' -Standard- New:' || '%') AND (evntlog_dispatched IS NULL) AND CAST(evntlog_evnttime AS DATE) = current_date ) AND (_standardCost > _maxCost) THEN IF (TG_OP = 'INSERT') THEN _oldStdCost := 0; _oldActCost := 0; ELSE _oldStdCost := OLD.itemcost_stdcost; _oldActCost := OLD.itemcost_stdcost; END IF; PERFORM postEvent('CostExceedsMaxDesired', NULL, NEW.itemcost_item_id, itemsite_warehous_id, (_itemNumber || ' -Standard- ' || 'New: ' || formatCost(_standardCost) || ' Max: '|| formatCost(_MaxCost)), NEW.itemcost_stdcost, _oldStdCost, NULL, NULL) FROM itemsite WHERE (itemsite_item_id=NEW.itemcost_item_id); END IF; IF NOT EXISTS( SELECT 1 FROM evntlog, evnttype WHERE evntlog_evnttype_id = evnttype_id AND evntlog_number LIKE (_itemNumber || ' -Actual- New:' || '%') AND (evntlog_dispatched IS NULL) AND CAST(evntlog_evnttime AS DATE) = current_date ) AND (_actualCost > _maxCost) THEN PERFORM postEvent('CostExceedsMaxDesired', NULL, NEW.itemcost_item_id, itemsite_warehous_id, (_itemNumber || ' -Actual- ' || 'New: ' || formatCost(_actualCost) || ' Max: '|| formatCost(_MaxCost)), NEW.itemcost_actcost, _oldActCost, NULL, NULL) FROM itemsite WHERE (itemsite_item_id=NEW.itemcost_item_id); END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._itemcostaftertrigger() OWNER TO admin; -- -- Name: _itemcosttrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _itemcosttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN --Privilege Checks IF ( (TG_OP = 'INSERT') AND (NOT checkPrivilege('CreateCosts')) AND (NOT checkPrivilege('PostVouchers')) ) THEN RAISE EXCEPTION 'You do not have privileges to enter Item Costs.'; END IF; IF ( (TG_OP = 'UPDATE') AND (NOT checkPrivilege('EnterActualCosts')) AND (NOT checkPrivilege('PostVouchers')) AND (NOT checkPrivilege('UpdateActualCosts')) AND (NOT checkPrivilege('PostActualCosts')) AND (NOT checkPrivilege('PostStandardCosts')) ) THEN RAISE EXCEPTION 'You do not have privileges to update Item Costs.'; END IF; IF ( (TG_OP = 'DELETE') AND (NOT checkPrivilege('DeleteCosts')) ) THEN RAISE EXCEPTION 'You do not have privileges to delete Item Costs.'; END IF; IF (TG_OP = 'UPDATE') THEN IF (NEW.itemcost_actcost <> OLD.itemcost_actcost OR NEW.itemcost_curr_id <> OLD.itemcost_curr_id) THEN INSERT INTO costhist ( costhist_item_id, costhist_costelem_id, costhist_type, costhist_lowlevel, costhist_username, costhist_date, costhist_oldcost, costhist_newcost, costhist_oldcurr_id, costhist_newcurr_id ) VALUES ( NEW.itemcost_item_id, NEW.itemcost_costelem_id, 'A', NEW.itemcost_lowlevel, getEffectiveXtUser(), CURRENT_TIMESTAMP, OLD.itemcost_actcost, NEW.itemcost_actcost, OLD.itemcost_curr_id, NEW.itemcost_curr_id ); END IF; IF (NEW.itemcost_stdcost <> OLD.itemcost_stdcost) THEN INSERT INTO costhist ( costhist_item_id, costhist_costelem_id, costhist_type, costhist_lowlevel, costhist_username, costhist_date, costhist_oldcost, costhist_newcost, costhist_oldcurr_id, costhist_newcurr_id ) VALUES ( NEW.itemcost_item_id, NEW.itemcost_costelem_id, 'S', NEW.itemcost_lowlevel, getEffectiveXtUser(), CURRENT_TIMESTAMP, OLD.itemcost_stdcost, NEW.itemcost_stdcost, baseCurrId(), baseCurrId() ); END IF; RETURN NEW; ELSIF (TG_OP = 'INSERT') THEN INSERT INTO costhist ( costhist_item_id, costhist_costelem_id, costhist_type, costhist_lowlevel, costhist_username, costhist_date, costhist_oldcost, costhist_newcost, costhist_oldcurr_id, costhist_newcurr_id ) VALUES ( NEW.itemcost_item_id, NEW.itemcost_costelem_id, 'N', NEW.itemcost_lowlevel, getEffectiveXtUser(), CURRENT_TIMESTAMP, 0, NEW.itemcost_actcost, baseCurrId(), NEW.itemcost_curr_id ); RETURN NEW; ELSIF (TG_OP = 'DELETE') THEN INSERT INTO costhist ( costhist_item_id, costhist_costelem_id, costhist_type, costhist_lowlevel, costhist_username, costhist_date, costhist_oldcost, costhist_newcost, costhist_oldcurr_id, costhist_newcurr_id ) VALUES ( OLD.itemcost_item_id, OLD.itemcost_costelem_id, 'D', OLD.itemcost_lowlevel, getEffectiveXtUser(), CURRENT_TIMESTAMP, OLD.itemcost_stdcost, 0, OLD.itemcost_curr_id, baseCurrId() ); RETURN OLD; END IF; END; $$; ALTER FUNCTION public._itemcosttrigger() OWNER TO admin; -- -- Name: _itemsiteaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _itemsiteaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _state INTEGER; _wasLocationControl BOOLEAN; _isLocationControl BOOLEAN; _wasLotSerial BOOLEAN; _isLotSerial BOOLEAN; _wasPerishable BOOLEAN; _isPerishable BOOLEAN; _qty NUMERIC; _maint BOOLEAN; _cost NUMERIC; _variance NUMERIC; _application TEXT; BEGIN -- Cache Application SELECT fetchMetricText('Application') INTO _application; -- Check if we are doing maintenance IF (TG_OP = 'INSERT') THEN _maint := TRUE; ELSIF (TG_OP = 'UPDATE') THEN IF ((OLD.itemsite_item_id != NEW.itemsite_item_id) OR (OLD.itemsite_warehous_id != NEW.itemsite_warehous_id) OR (OLD.itemsite_reorderlevel != NEW.itemsite_reorderlevel) OR (OLD.itemsite_ordertoqty != NEW.itemsite_ordertoqty) OR (OLD.itemsite_cyclecountfreq != NEW.itemsite_cyclecountfreq) OR (OLD.itemsite_planning_type != NEW.itemsite_planning_type) OR (OLD.itemsite_posupply != NEW.itemsite_posupply) OR (OLD.itemsite_wosupply != NEW.itemsite_wosupply) OR (OLD.itemsite_loccntrl != NEW.itemsite_loccntrl) OR (OLD.itemsite_safetystock != NEW.itemsite_safetystock) OR (OLD.itemsite_minordqty != NEW.itemsite_minordqty) OR (OLD.itemsite_multordqty != NEW.itemsite_multordqty) OR (OLD.itemsite_leadtime != NEW.itemsite_leadtime) OR (OLD.itemsite_abcclass != NEW.itemsite_abcclass) OR (OLD.itemsite_controlmethod != NEW.itemsite_controlmethod) OR (OLD.itemsite_active != NEW.itemsite_active) OR (OLD.itemsite_plancode_id != NEW.itemsite_plancode_id) OR (OLD.itemsite_costcat_id != NEW.itemsite_costcat_id) OR (OLD.itemsite_eventfence != NEW.itemsite_eventfence) OR (OLD.itemsite_sold != NEW.itemsite_sold) OR (OLD.itemsite_stocked != NEW.itemsite_stocked) OR (OLD.itemsite_location_id != NEW.itemsite_location_id) OR (OLD.itemsite_recvlocation_id != NEW.itemsite_recvlocation_id) OR (OLD.itemsite_issuelocation_id != NEW.itemsite_issuelocation_id) OR (OLD.itemsite_location_dist != NEW.itemsite_location_dist) OR (OLD.itemsite_recvlocation_dist != NEW.itemsite_recvlocation_dist) OR (OLD.itemsite_issuelocation_dist != NEW.itemsite_issuelocation_dist) OR (OLD.itemsite_useparams != NEW.itemsite_useparams) OR (OLD.itemsite_useparamsmanual != NEW.itemsite_useparamsmanual) OR (OLD.itemsite_soldranking != NEW.itemsite_soldranking) OR (OLD.itemsite_createpr != NEW.itemsite_createpr) OR (OLD.itemsite_location != NEW.itemsite_location) OR (OLD.itemsite_location_comments != NEW.itemsite_location_comments) OR (OLD.itemsite_notes != NEW.itemsite_notes) OR (OLD.itemsite_perishable != NEW.itemsite_perishable) OR (OLD.itemsite_autoabcclass != NEW.itemsite_autoabcclass) OR (OLD.itemsite_ordergroup != NEW.itemsite_ordergroup) OR (OLD.itemsite_disallowblankwip != NEW.itemsite_disallowblankwip) OR (OLD.itemsite_maxordqty != NEW.itemsite_maxordqty) OR (OLD.itemsite_mps_timefence != NEW.itemsite_mps_timefence) OR (OLD.itemsite_createwo != NEW.itemsite_createwo) OR (OLD.itemsite_warrpurc != NEW.itemsite_warrpurc) OR (OLD.itemsite_costmethod != NEW.itemsite_costmethod) OR (OLD.itemsite_autoreg != NEW.itemsite_autoreg) OR (OLD.itemsite_lsseq_id != NEW.itemsite_lsseq_id) ) THEN IF (OLD.itemsite_item_id != NEW.itemsite_item_id) THEN RAISE EXCEPTION 'The item number on an itemsite may not be changed.'; ELSIF (OLD.itemsite_warehous_id != NEW.itemsite_warehous_id) THEN RAISE EXCEPTION 'The warehouse code on an itemsite may not be changed.'; END IF; _maint := TRUE; END IF; ELSE _maint := FALSE; END IF; IF (_maint) THEN -- Begin Maintenance -- Privilege Checks IF ( NOT checkPrivilege('MaintainItemSites') ) THEN RAISE EXCEPTION 'You do not have privileges to maintain Item Sites.'; END IF; -- Override values to avoid invalid data combinations IF (NOT NEW.itemsite_posupply) THEN UPDATE itemsite SET itemsite_createpr = FALSE WHERE (itemsite_id=NEW.itemsite_id); END IF; IF (NOT NEW.itemsite_wosupply) THEN UPDATE itemsite SET itemsite_createwo = FALSE WHERE (itemsite_id=NEW.itemsite_id); END IF; IF (NEW.itemsite_controlmethod NOT IN ('S','L')) THEN UPDATE itemsite SET itemsite_perishable = FALSE, itemsite_warrpurc = FALSE, itemsite_autoreg = FALSE, itemsite_lsseq_id = NULL WHERE (itemsite_id=NEW.itemsite_id); END IF; IF (NOT NEW.itemsite_loccntrl) THEN UPDATE itemsite SET itemsite_disallowblankwip = FALSE WHERE (itemsite_id=NEW.itemsite_id); END IF; IF (NOT NEW.itemsite_useparams) THEN UPDATE itemsite SET itemsite_reorderlevel = 0, itemsite_ordertoqty = 0, itemsite_minordqty = 0, itemsite_maxordqty = 0, itemsite_multordqty = 0, itemsite_useparamsmanual = FALSE WHERE (itemsite_id = NEW.itemsite_id); END IF; -- Integrity check -- Both insert and update IF ( (NEW.itemsite_controlmethod IN ('S', 'L')) AND (NEW.itemsite_location_dist OR NEW.itemsite_recvlocation_dist OR NEW.itemsite_issuelocation_dist) ) THEN RAISE EXCEPTION 'You cannot auto-distribute Lot/Serial controlled Item Sites.'; END IF; IF (TG_OP = 'INSERT') THEN -- Handle MLC logic IF ( (NEW.itemsite_loccntrl) AND (NEW.itemsite_warehous_id IS NOT NULL) ) THEN IF (SELECT count(*)=0 FROM location WHERE ((location_warehous_id=NEW.itemsite_warehous_id) AND ( (NOT location_restrict) OR ( (location_restrict) AND (location_id IN ( SELECT locitem_location_id FROM locitem WHERE (locitem_item_id=NEW.itemsite_item_id) ) ) ) ))) THEN RAISE EXCEPTION 'You must first create at least one valid Location for this Item Site before it may be multiply located.'; END IF; END IF; END IF; IF (TG_OP = 'UPDATE') THEN -- Integrity check IF (NOT OLD.itemsite_loccntrl AND NEW.itemsite_loccntrl) THEN IF (SELECT count(*)=0 FROM location WHERE ((location_warehous_id=NEW.itemsite_warehous_id) AND ( (NOT location_restrict) OR ( (location_restrict) AND (location_id IN ( SELECT locitem_location_id FROM locitem WHERE (locitem_item_id=NEW.itemsite_item_id) ) ) ) ))) THEN RAISE EXCEPTION 'You must first create at least one valid Location for this Item Site before it may be multiply located.'; END IF; END IF; -- Update detail records based on control method changes _wasLocationControl := OLD.itemsite_loccntrl; _isLocationControl := NEW.itemsite_loccntrl; _wasLotSerial := OLD.itemsite_controlmethod IN ('S','L'); _isLotSerial := NEW.itemsite_controlmethod IN ('S','L'); _wasPerishable := OLD.itemsite_perishable; _isPerishable := NEW.itemsite_perishable; _state := 0; IF ( (_wasLocationControl) AND (_isLocationControl) ) THEN _state := 10; ELSIF ( (NOT _wasLocationControl) AND (NOT _isLocationControl) ) THEN _state := 20; ELSIF ( (NOT _wasLocationControl) AND (_isLocationControl) ) THEN _state := 30; ELSIF ( (_wasLocationControl) AND (NOT _isLocationControl) ) THEN _state := 40; END IF; IF ( (_wasLotSerial) AND (_isLotSerial) ) THEN _state := _state + 1; ELSIF ( (NOT _wasLotSerial) AND (NOT _isLotSerial) ) THEN _state := _state + 2; ELSIF ( (NOT _wasLotSerial) AND (_isLotSerial) ) THEN _state := _state + 3; ELSIF ( (_wasLotSerial) AND (NOT _isLotSerial) ) THEN _state := _state + 4; END IF; IF ( (_application = 'Standard') AND (_state IN (41, 43, 14, 34, 24, 42, 44)) ) THEN -- Check for Reservations IF (SELECT COUNT(*) > 0 FROM itemloc JOIN reserve ON (reserve_supply_id=itemloc_id AND reserve_supply_type='I') WHERE (itemloc_itemsite_id=OLD.itemsite_id)) THEN RAISE EXCEPTION 'Sales Order Reservations by Location exist for this Item Site'; END IF; END IF; IF (_state IN (41, 43)) THEN PERFORM consolidateLotSerial(OLD.itemsite_id); ELSIF (_state IN (14, 34)) THEN PERFORM consolidateLocations(OLD.itemsite_id); ELSIF (_state IN (24, 42, 44)) THEN DELETE FROM itemloc WHERE (itemloc_itemsite_id=OLD.itemsite_id); END IF; IF (NEW.itemsite_qtyonhand != 0) THEN -- Handle detail creation -- Create itemloc records if they do not exist IF (_state IN (23, 32, 33)) THEN INSERT INTO itemloc ( itemloc_itemsite_id, itemloc_location_id, itemloc_expiration, itemloc_qty ) VALUES ( NEW.itemsite_id, -1, endOfTime(), NEW.itemsite_qtyonhand ); END IF; -- Handle Location distribution IF (_state IN (31, 32, 33, 34)) THEN IF (SELECT (COUNT(*)=1) FROM location WHERE ((location_id=NEW.itemsite_location_id) AND (location_warehous_id=NEW.itemsite_warehous_id) AND ( (NOT location_restrict) OR ( (location_restrict) AND (location_id IN ( SELECT locitem_location_id FROM locitem WHERE (locitem_item_id=NEW.itemsite_item_id) ) ) ) ))) THEN PERFORM initialDistribution(NEW.itemsite_id, NEW.itemsite_location_id); ELSE RAISE EXCEPTION 'A valid default location must be selected to distribute existing inventory to.'; END IF; END IF; -- Handle Lot/Serial distribution IF ( (_state = 13) OR (_state = 23) OR (_state = 33) OR (_state = 43) ) THEN RAISE WARNING 'You should now use the Reassign Lot/Serial # window to assign Lot/Serial #s.'; END IF; END IF; IF (OLD.itemsite_costmethod='A' AND NEW.itemsite_costmethod='S') THEN -- TODO: Average costing cost method change SELECT stdcost(NEW.itemsite_item_id) * NEW.itemsite_qtyonhand INTO _cost; _variance := _cost - NEW.itemsite_value; NEW.itemsite_value := _cost; IF(_variance <> 0.0) THEN PERFORM insertGLTransaction( 'P/D', '', '', 'Itemsite converted from Average to Standard cost.', costcat_invcost_accnt_id, costcat_asset_accnt_id, NEW.itemsite_id, _variance, CURRENT_DATE ) FROM costcat WHERE(costcat_id=NEW.itemsite_costcat_id); UPDATE itemsite SET itemsite_value = _cost WHERE (itemsite_id = NEW.itemsite_id); END IF; END IF; END IF; -- Handle Perishable IF ( (_application = 'Standard') AND (_wasPerishable) AND (NOT _isPerishable) ) THEN UPDATE itemloc SET itemloc_expiration = endOfTime() WHERE (itemloc_itemsite_id = OLD.itemsite_id); PERFORM consolidateLotSerial(OLD.itemsite_id); END IF; -- If Planning Type changed to None then delete all Planned Orders IF ( (_application = 'Standard') AND (TG_OP = 'UPDATE') ) THEN IF (NEW.itemsite_planning_type = 'N' AND OLD.itemsite_planning_type <> 'N') THEN PERFORM deletePlannedOrder(planord_id, TRUE) FROM planord WHERE (planord_itemsite_id=NEW.itemsite_id); END IF; END IF; END IF; -- End Maintenance RETURN NEW; END; $$; ALTER FUNCTION public._itemsiteaftertrigger() OWNER TO admin; -- -- Name: _itemsitetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _itemsitetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; _r RECORD; BEGIN -- Cache some information -- Added item_number as part of feature request 21645 SELECT item_type, item_number INTO _r FROM item WHERE (item_id=NEW.itemsite_item_id); -- Override values to avoid invalid data combinations IF (_r.item_type IN ('J','R','S')) THEN NEW.itemsite_planning_type := 'N'; END IF; IF (_r.item_type = 'L') THEN NEW.itemsite_planning_type := 'S'; END IF; IF (TG_OP = 'UPDATE') THEN IF ( (NEW.itemsite_qtyonhand <> OLD.itemsite_qtyonhand) ) THEN IF (OLD.itemsite_freeze) THEN NEW.itemsite_qtyonhand := OLD.itemsite_qtyonhand; ELSE NEW.itemsite_datelastused := CURRENT_DATE; END IF; IF ( (NEW.itemsite_qtyonhand < 0) AND (OLD.itemsite_qtyonhand >= 0) AND (NEW.itemsite_eventfence > 0) ) THEN PERFORM postEvent('QOHBelowZero', 'I', NEW.itemsite_id, warehous_id, (item_number || '/' || warehous_code), NULL, NULL, NULL, NULL) FROM item, whsinfo WHERE (item_id=NEW.itemsite_item_id) AND (warehous_id=NEW.itemsite_warehous_id); END IF; END IF; IF ( (NEW.itemsite_value <> OLD.itemsite_value) AND (OLD.itemsite_freeze) ) THEN NEW.itemsite_value := OLD.itemsite_value; END IF; END IF; -- Added item_number to error messages displayed to fulfill Feature Request 21645 IF (NEW.itemsite_qtyonhand < 0 AND NEW.itemsite_costmethod = 'A') THEN RAISE EXCEPTION 'Itemsite (%) is set to use average costing and is not allowed to have a negative quantity on hand.', 'ID: ' || NEW.itemsite_id || ', Item: ' || _r.item_number; ELSIF (NEW.itemsite_value < 0 AND NEW.itemsite_costmethod = 'A') THEN RAISE EXCEPTION 'This transaction results in a negative itemsite value. Itemsite (%) is set to use average costing and is not allowed to have a negative value.', 'ID: ' || NEW.itemsite_id || ', Item: ' || _r.item_number; END IF; -- Handle the ChangeLog IF ( SELECT (metric_value='t') FROM metric WHERE (metric_name='ItemSiteChangeLog') ) THEN -- Cache the cmnttype_id for ChangeLog SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (FOUND) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'IS', NEW.itemsite_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.itemsite_plancode_id <> NEW.itemsite_plancode_id) THEN PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id, ( 'Planner Code Changed from "' || oldplancode.plancode_code || '" to "' || newplancode.plancode_code || '"' ) ) FROM plancode AS oldplancode, plancode AS newplancode WHERE ( (oldplancode.plancode_id=OLD.itemsite_plancode_id) AND (newplancode.plancode_id=NEW.itemsite_plancode_id) ); END IF; IF (NEW.itemsite_reorderlevel <> OLD.itemsite_reorderlevel) THEN PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id, ( 'Reorder Level Changed from ' || formatQty(OLD.itemsite_reorderlevel) || ' to ' || formatQty(NEW.itemsite_reorderlevel ) ) ); END IF; IF (NEW.itemsite_ordertoqty <> OLD.itemsite_ordertoqty) THEN PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id, ( 'Order Up To Changed from ' || formatQty(OLD.itemsite_ordertoqty) || ' to ' || formatQty(NEW.itemsite_ordertoqty ) ) ); END IF; IF (NEW.itemsite_leadtime <> OLD.itemsite_leadtime) THEN PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id, ( 'Itemsite Leadtime Changed from ' || formatQty(OLD.itemsite_leadtime) || ' to ' || formatQty(NEW.itemsite_leadtime ) ) ); END IF; IF (NEW.itemsite_abcclass <> OLD.itemsite_abcclass) THEN PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id, ( 'Itemsite ABC Class Changed from ' || COALESCE(OLD.itemsite_abcclass, 'None') || ' to ' || COALESCE(NEW.itemsite_abcclass,'None') ) ); END IF; IF (NEW.itemsite_controlmethod <> OLD.itemsite_controlmethod) THEN PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id, ( 'Itemsite Control Method Changed from ' || COALESCE(OLD.itemsite_controlmethod,'None') || ' to ' || COALESCE(NEW.itemsite_controlmethod,'None') ) ); END IF; IF (OLD.itemsite_sold <> NEW.itemsite_sold) THEN PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id, CASE WHEN (NEW.itemsite_sold) THEN 'Sold Changed from FALSE to TRUE' ELSE 'Sold Changed from TRUE to FALSE' END ); END IF; IF (OLD.itemsite_active <> NEW.itemsite_active) THEN IF (NEW.itemsite_active) THEN PERFORM postComment(_cmnttypeid, 'IS', NEW.itemsite_id, 'Activated'); ELSE PERFORM postComment(_cmnttypeid, 'IS', NEW.itemsite_id, 'Deactivated'); END IF; END IF; END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._itemsitetrigger() OWNER TO admin; -- -- Name: _itemsrcaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _itemsrcaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainItemSources')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Item Sources.'; END IF; -- Set default to false for other item sources of this item IF (COALESCE(NEW.itemsrc_default, FALSE) = TRUE) THEN UPDATE itemsrc SET itemsrc_default = FALSE WHERE ( (itemsrc_item_id = NEW.itemsrc_item_id) AND (itemsrc_id <> NEW.itemsrc_id) ); END IF; RETURN NEW; END; $$; ALTER FUNCTION public._itemsrcaftertrigger() OWNER TO admin; -- -- Name: _itemsrcptrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _itemsrcptrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainItemSources')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Item Sources.'; END IF; -- Set defaults NEW.itemsrcp_curr_id := COALESCE(NEW.itemsrcp_curr_id,basecurrid()); RETURN NEW; END; $$; ALTER FUNCTION public._itemsrcptrigger() OWNER TO admin; -- -- Name: _itemsrctrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _itemsrctrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainItemSources')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Item Sources.'; END IF; -- Set defaults NEW.itemsrc_invvendoruomratio := COALESCE(NEW.itemsrc_invvendoruomratio,1); NEW.itemsrc_minordqty := COALESCE(NEW.itemsrc_minordqty,0); NEW.itemsrc_multordqty := COALESCE(NEW.itemsrc_multordqty,0); NEW.itemsrc_active := COALESCE(NEW.itemsrc_active,true); NEW.itemsrc_leadtime := COALESCE(NEW.itemsrc_leadtime,0); NEW.itemsrc_ranking := COALESCE(NEW.itemsrc_ranking,1); RETURN NEW; END; $$; ALTER FUNCTION public._itemsrctrigger() OWNER TO admin; -- -- Name: _itemsubtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _itemsubtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainItemMasters')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Item Substitutes.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._itemsubtrigger() OWNER TO admin; -- -- Name: _itemtaxtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _itemtaxtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainItemMasters')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Items.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._itemtaxtrigger() OWNER TO admin; -- -- Name: _itemtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _itemtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Override values to avoid invalid data combinations IF (NEW.item_type IN ('R','S','O','L','B')) THEN NEW.item_picklist := FALSE; END IF; IF (NEW.item_type IN ('F','S','O','L','B')) THEN NEW.item_picklist := FALSE; NEW.item_sold := FALSE; NEW.item_prodcat_id := -1; NEW.item_exclusive := false; NEW.item_listprice := 0; NEW.item_upccode := ''; NEW.item_prodweight := 0; NEW.item_packweight := 0; END IF; IF (NEW.item_type NOT IN ('M','R')) THEN NEW.item_config := false; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._itemtrigger() OWNER TO admin; -- -- Name: _itemuomconvtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _itemuomconvtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainItemMasters')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Items.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._itemuomconvtrigger() OWNER TO admin; -- -- Name: _locationaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _locationaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _itemloc RECORD; BEGIN RETURN NEW; END; $$; ALTER FUNCTION public._locationaftertrigger() OWNER TO admin; -- -- Name: _locationtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _locationtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check BOOLEAN; _checkId INTEGER; BEGIN -- Checks -- Start with privileges IF (TG_OP = 'INSERT') THEN SELECT checkPrivilege('MaintainLocations') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to add new Locations.'; END IF; ELSE SELECT checkPrivilege('MaintainLocations') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to alter a Location.'; END IF; END IF; -- Code is required IF ( (LENGTH(COALESCE(NEW.location_name,''))=0) AND (LENGTH(COALESCE(NEW.location_aisle,''))=0) AND (LENGTH(COALESCE(NEW.location_rack,''))=0) AND (LENGTH(COALESCE(NEW.location_bin,''))=0) ) THEN RAISE EXCEPTION 'You must supply a valid Location Identifier.'; END IF; -- Site is required IF (NEW.location_warehous_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Site.'; END IF; -- Location Identifier must be unique SELECT location_id INTO _checkId FROM location WHERE ( (UPPER(location_name)=UPPER(NEW.location_name)) AND (UPPER(location_aisle)=UPPER(NEW.location_aisle)) AND (UPPER(location_rack)=UPPER(NEW.location_rack)) AND (UPPER(location_bin)=UPPER(NEW.location_bin)) AND (location_warehous_id=NEW.location_warehous_id) AND (location_id<>NEW.location_id) ); IF (FOUND) THEN RAISE EXCEPTION 'You must supply a unique Location Identifier for this Site.'; END IF; -- Populate formatted name IF (NEW.location_aisle IS NOT NULL) THEN NEW.location_formatname := NEW.location_aisle; ELSE NEW.location_formatname := ''; END IF; IF (NEW.location_rack IS NOT NULL) THEN NEW.location_formatname := (NEW.location_formatname || NEW.location_rack); END IF; IF (NEW.location_bin IS NOT NULL) THEN NEW.location_formatname := (NEW.location_formatname || NEW.location_bin); END IF; IF (NEW.location_name IS NOT NULL) THEN NEW.location_formatname := (NEW.location_formatname || NEW.location_name); END IF; RETURN NEW; END; $$; ALTER FUNCTION public._locationtrigger() OWNER TO admin; -- -- Name: _metasqlaltertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _metasqlaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (NOT (isDBA() OR checkPrivilege('MaintainMetaSQL'))) THEN RAISE EXCEPTION '% does not have privileges to maintain MetaSQL statements in %.%', getEffectiveXtUser(), TG_TABLE_SCHEMA, TG_TABLE_NAME; END IF; IF ((TG_OP = 'UPDATE' OR TG_OP = 'DELETE') AND NEW.metasql_grade <= 0 AND NOT isDBA()) THEN RAISE EXCEPTION 'You may not alter grade 0 metasql queries except using the xTuple Updater utility'; END IF; IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._metasqlaltertrigger() OWNER TO admin; -- -- Name: _metasqltrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _metasqltrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN NEW.metasql_lastuser := getEffectiveXtUser(); NEW.metasql_lastupdate := current_date; RETURN NEW; END; $$; ALTER FUNCTION public._metasqltrigger() OWNER TO admin; -- -- Name: _normalizeversion(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _normalizeversion(pversion text) RETURNS smallint[] LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- Convert an arbitrary version number string to an array of integers. -- Supports the following styles: -- xTuple 4.5.6Beta2A -- semver 4.5.6-beta.2.a+buildId -- postgres 9.3 DECLARE _result SMALLINT[]; -- 4.5.6 _part TEXT[]; _debug BOOLEAN := false; BEGIN -- extract 4.5.6 _part := regexp_matches(pVersion, -- v----------- 6 -----------v -- capture v-3-v v---- 8 ----v -- 1 2 4 5 7 9 10 -- 4 . 5 . 6 - beta 2 a E'^([0-9]+)\\.([0-9]+)((\\.)([0-9]+))?-?(([a-z]+)\\.?(([0-9]*)\\.?([a-z]?)?)?)?', 'i'); IF _debug THEN RAISE NOTICE 'M: % N: % dP: % d: % P: % rest: % alpha: % sub: % num: % let: %', _part[1], _part[2], _part[3], _part[4], _part[5], _part[6], _part[7], _part[8], _part[9], _part[10]; END IF; _result := ARRAY [ _part[1]::SMALLINT, _part[2]::SMALLINT, COALESCE(_part[5]::SMALLINT, 0), CASE lower(COALESCE(_part[7], '')) WHEN '' THEN 50 WHEN 'rc' THEN 40 WHEN 'beta' THEN 30 WHEN 'alpha' THEN 20 ELSE 10 END, CASE WHEN _part[9] IS NULL THEN 0 WHEN _part[9] = '' THEN 0 ELSE _part[9]::SMALLINT -- beta < beta2 END, ascii(CASE WHEN _part[10] IS NULL THEN '_' WHEN _part[10] = '' THEN '_' ELSE lower(COALESCE(_part[10], '_')) END) -- 2 < 2a ]; IF _debug THEN RAISE NOTICE '_part: % -> _result: %', _part, _result; END IF; IF _part[1] IS NULL OR _part[2] IS NULL THEN RAISE EXCEPTION '% is not recognized as a valid version number', pVersion; END IF; RETURN _result; END; $$; ALTER FUNCTION public._normalizeversion(pversion text) OWNER TO admin; -- -- Name: _opheadafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _opheadafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'OPP' AND charass_target_id = OLD.ophead_id; RETURN OLD; END; $$; ALTER FUNCTION public._opheadafterdeletetrigger() OWNER TO admin; -- -- Name: _opheadaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _opheadaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; BEGIN IF (TG_OP = 'DELETE') THEN DELETE FROM docass WHERE docass_source_id = OLD.ophead_id AND docass_source_type = 'OPP'; DELETE FROM docass WHERE docass_target_id = OLD.ophead_id AND docass_target_type = 'OPP'; END IF; -- Comments IF ( SELECT (metric_value='t') FROM metric WHERE (metric_name='OpportunityChangeLog') ) THEN -- Cache the cmnttype_id for ChangeLog SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (FOUND) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'OPP', NEW.ophead_id, 'Created'); --- clear the number from the issue cache PERFORM clearNumberIssue('OpportunityNumber', NEW.ophead_number); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.ophead_active <> NEW.ophead_active) THEN IF (NEW.ophead_active) THEN PERFORM postComment(_cmnttypeid, 'OPP', NEW.ophead_id, 'Activated'); ELSE PERFORM postComment(_cmnttypeid, 'OPP', NEW.ophead_id, 'Deactivated'); END IF; END IF; IF (OLD.ophead_name <> NEW.ophead_name) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'Name Changed from "' || OLD.ophead_name || '" to "' || NEW.ophead_name || '"' ) ); END IF; IF (OLD.ophead_owner_username <> NEW.ophead_owner_username) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'Owner Name Changed from "' || OLD.ophead_owner_username || '" to "' || NEW.ophead_owner_username || '"' ) ); END IF; IF (OLD.ophead_probability_prcnt <> NEW.ophead_probability_prcnt) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'Probability % Changed from "' || OLD.ophead_probability_prcnt || '" to "' || NEW.ophead_probability_prcnt || '"' ) ); END IF; IF (OLD.ophead_amount <> NEW.ophead_amount) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'Amount Changed from "' || OLD.ophead_amount || '" to "' || NEW.ophead_amount || '"' ) ); END IF; IF (OLD.ophead_target_date <> NEW.ophead_target_date) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'Target Date Changed from "' || OLD.ophead_target_date || '" to "' || NEW.ophead_target_date || '"' ) ); END IF; IF (OLD.ophead_actual_date <> NEW.ophead_actual_date) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'Actual Date Changed from "' || OLD.ophead_actual_date || '" to "' || NEW.ophead_actual_date || '"' ) ); END IF; IF (OLD.ophead_crmacct_id <> NEW.ophead_crmacct_id) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'CRM Account Changed from "' || (SELECT crmacct_name FROM crmacct WHERE crmacct_id=OLD.ophead_crmacct_id) || '" (' || OLD.ophead_crmacct_id || ') to "' || (SELECT crmacct_name FROM crmacct WHERE crmacct_id=NEW.ophead_crmacct_id) || '" (' || NEW.ophead_crmacct_id || ')' ) ); END IF; IF (OLD.ophead_curr_id <> NEW.ophead_curr_id) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'Currency Changed from "' || (SELECT curr_name FROM curr_symbol WHERE curr_id=OLD.ophead_curr_id) || '" (' || OLD.ophead_curr_id || ') to "' || (SELECT curr_name FROM curr_symbol WHERE curr_id=NEW.ophead_curr_id) || '" (' || NEW.ophead_curr_id || ')' ) ); END IF; IF (OLD.ophead_opstage_id <> NEW.ophead_opstage_id) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'Stage Changed from "' || (SELECT opstage_name FROM opstage WHERE opstage_id=OLD.ophead_opstage_id) || '" (' || OLD.ophead_opstage_id || ') to "' || (SELECT opstage_name FROM opstage WHERE opstage_id=NEW.ophead_opstage_id) || '" (' || NEW.ophead_opstage_id || ')' ) ); END IF; IF (OLD.ophead_opsource_id <> NEW.ophead_opsource_id) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'Source Changed from "' || (SELECT opsource_name FROM opsource WHERE opsource_id=OLD.ophead_opsource_id) || '" (' || OLD.ophead_opsource_id || ') to "' || (SELECT opsource_name FROM opsource WHERE opsource_id=NEW.ophead_opsource_id) || '" (' || NEW.ophead_opsource_id || ')' ) ); END IF; IF (OLD.ophead_optype_id <> NEW.ophead_optype_id) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'Type Changed from "' || (SELECT optype_name FROM optype WHERE optype_id=OLD.ophead_optype_id) || '" (' || OLD.ophead_optype_id || ') to "' || (SELECT optype_name FROM optype WHERE optype_id=NEW.ophead_optype_id) || '" (' || NEW.ophead_optype_id || ')' ) ); END IF; END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._opheadaftertrigger() OWNER TO admin; -- -- Name: _opheadbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _opheadbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _rec record; _check boolean; _test text; BEGIN IF(TG_OP = 'DELETE') THEN _rec := OLD; ELSE _rec := NEW; END IF; -- Auto inactivate IF (TG_OP = 'UPDATE') THEN IF ( (NEW.ophead_opstage_id != OLD.ophead_opstage_id) AND (SELECT opstage_opinactive FROM opstage WHERE opstage_id=NEW.ophead_opstage_id) ) THEN NEW.ophead_active := FALSE; END IF; END IF; IF (TG_OP = 'INSERT') THEN IF (SELECT opstage_opinactive FROM opstage WHERE opstage_id=NEW.ophead_opstage_id) THEN NEW.ophead_active := FALSE; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._opheadbeforetrigger() OWNER TO admin; -- -- Name: _packbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _packbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; BEGIN SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (FOUND) THEN IF ((TG_OP = 'INSERT') AND (NEW.pack_head_id) IS NOT NULL)THEN PERFORM postComment(_cmnttypeid, 'S', NEW.pack_head_id, 'Added to Packing List Batch'); END IF; END IF; IF ((TG_OP = 'INSERT') OR (TG_OP = 'UPDATE')) THEN IF (NEW.pack_shiphead_id IS NOT NULL AND NEW.pack_shiphead_id NOT IN (SELECT shiphead_id FROM shiphead WHERE (shiphead_order_id=NEW.pack_head_id) AND (shiphead_order_type=NEW.pack_head_type))) THEN RAISE EXCEPTION 'Shipment does not exist for % id %', NEW.pack_head_type, NEW.pack_head_id; RETURN OLD; END IF; IF (NEW.pack_head_type = 'SO' AND NEW.pack_head_id IN (SELECT cohead_id FROM cohead)) THEN RETURN NEW; ELSEIF (NEW.pack_head_type = 'TO') THEN IF (NOT fetchMetricBool('MultiWhs')) THEN RAISE EXCEPTION 'Transfer Orders are not supported by this version of the application'; ELSEIF (NEW.pack_head_id IN (SELECT tohead_id FROM tohead)) THEN RETURN NEW; END IF; END IF; RAISE EXCEPTION '% with id % does not exist', NEW.pack_head_type, NEW.pack_head_id; RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._packbeforetrigger() OWNER TO admin; -- -- Name: _periodaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _periodaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _idoffirst INTEGER; _test INTEGER; BEGIN -- This trigger can easily cause an infinite loop -- because of this we have to be very careful to not -- do an update on the period table if no updates -- are absolutely needed so we don't just keep -- trigger ourselves again and again -- Figure out which period is the first one SELECT period_id INTO _idoffirst FROM period ORDER BY period_start LIMIT 1; -- If we didn't find anything there is nothing to do IF( NOT FOUND ) THEN RETURN NEW; END IF; -- do a select to see if there is at least one record that needs to be -- updated. If we do not find any then we can just leave without -- causing a retrigger of ourselves SELECT period_id INTO _test FROM period WHERE((COALESCE(period_initial, true) AND (NOT period_id=_idoffirst)) OR ((NOT COALESCE(period_initial, false)) AND (period_id=_idoffirst))) LIMIT 1; -- Nothing to update - get out of here IF( NOT FOUND ) THEN RETURN NEW; END IF; -- Update all the period records that already have the initial flag -- set and the one that we know should be the first. -- We don't have to be as careful here since we have already ruled -- out if don't need to update already. UPDATE period SET period_initial = (_idoffirst=period_id) WHERE((COALESCE(period_initial, true)) OR (period_id=_idoffirst)); RETURN NEW; END; $$; ALTER FUNCTION public._periodaftertrigger() OWNER TO admin; -- -- Name: _pkgcmdaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgcmdaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgcmdaftertrigger() OWNER TO admin; -- -- Name: _pkgcmdaltertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgcmdaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END IF; IF (TG_OP = 'INSERT') THEN RAISE EXCEPTION 'You may not create custom commands in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'UPDATE') THEN RAISE EXCEPTION 'You may not alter custom commands in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'DELETE') THEN RAISE EXCEPTION 'You may not delete custom commands from packages. Try deleting or disabling the package.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgcmdaltertrigger() OWNER TO admin; -- -- Name: _pkgcmdargaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgcmdargaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgcmdargaftertrigger() OWNER TO admin; -- -- Name: _pkgcmdargaltertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgcmdargaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END IF; IF (TG_OP = 'INSERT') THEN RAISE EXCEPTION 'You may not create command arguments in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'UPDATE') THEN RAISE EXCEPTION 'You may not alter command arguments in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'DELETE') THEN RAISE EXCEPTION 'You may not delete command arguments from packages. Try deleting or disabling the package.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgcmdargaltertrigger() OWNER TO admin; -- -- Name: _pkgcmdargbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgcmdargbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmdargid INTEGER; _debug BOOL := false; BEGIN IF (TG_OP = 'UPDATE') THEN RETURN NEW; ELSIF (TG_OP = 'INSERT') THEN RETURN NEW; ELSIF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgcmdargbeforetrigger() OWNER TO admin; -- -- Name: _pkgcmdbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgcmdbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmdid INTEGER; _debug BOOL := false; BEGIN IF (TG_OP = 'UPDATE') THEN IF (_debug) THEN RAISE NOTICE 'OLD.cmd_name %, NEW.cmd_name %', OLD.cmd_name, NEW.cmd_name; END IF; IF (NEW.cmd_name != OLD.cmd_name) THEN SELECT cmd_id INTO _cmdid FROM cmd WHERE cmd_name=NEW.cmd_name; IF (FOUND) THEN RAISE EXCEPTION 'Cannot change command name % because another command with that name already exists.', NEW.cmd_name; END IF; END IF; ELSIF (TG_OP = 'INSERT') THEN IF (_debug) THEN RAISE NOTICE 'inserting NEW.cmd_name %', NEW.cmd_name; END IF; SELECT cmd_id INTO _cmdid FROM cmd WHERE cmd_name=NEW.cmd_name; IF (FOUND) THEN RAISE EXCEPTION 'Cannot create new command % because another command with that name already exists.', NEW.cmd_name; END IF; ELSIF (TG_OP = 'DELETE') THEN DELETE FROM cmdarg WHERE cmdarg_cmd_id=OLD.cmd_id; RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgcmdbeforetrigger() OWNER TO admin; -- -- Name: _pkgheadbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgheadbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; BEGIN IF (TG_OP = 'UPDATE') THEN NEW.pkghead_created := OLD.pkghead_created; NEW.pkghead_updated := CURRENT_TIMESTAMP; IF (NEW.pkghead_indev AND NOT userCanCreateUsers(getEffectiveXtUser())) THEN NEW.pkghead_indev = FALSE; END IF; ELSIF (TG_OP = 'INSERT') THEN NEW.pkghead_created := CURRENT_TIMESTAMP; NEW.pkghead_updated := NEW.pkghead_created; IF (NEW.pkghead_indev AND NOT userCanCreateUsers(getEffectiveXtUser())) THEN NEW.pkghead_indev = FALSE; END IF; ELSIF (TG_OP = 'DELETE') THEN DELETE FROM pkgdep WHERE pkgdep_pkghead_id=OLD.pkghead_id; EXECUTE 'DROP SCHEMA ' || OLD.pkghead_name || ' CASCADE'; RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgheadbeforetrigger() OWNER TO admin; -- -- Name: _pkgimageaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgimageaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgimageaftertrigger() OWNER TO admin; -- -- Name: _pkgimagealtertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgimagealtertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END IF; IF (TG_OP = 'INSERT') THEN RAISE EXCEPTION 'You may not create images in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'UPDATE') THEN RAISE EXCEPTION 'You may not alter images in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'DELETE') THEN RAISE EXCEPTION 'You may not delete images from packages. Try deleting or disabling the package.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgimagealtertrigger() OWNER TO admin; -- -- Name: _pkgimagebeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgimagebeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _imageid INTEGER; _debug BOOL := false; BEGIN IF (TG_OP = 'UPDATE') THEN IF (_debug) THEN RAISE NOTICE 'OLD.image_name %, NEW.image_name %', OLD.image_name, NEW.image_name; END IF; IF (NEW.image_name != OLD.image_name) THEN SELECT image_id INTO _imageid FROM image WHERE image_name=NEW.image_name; IF (FOUND) THEN RAISE EXCEPTION 'Cannot change image named % because another image with that name already exists.', NEW.image_name; END IF; END IF; ELSIF (TG_OP = 'INSERT') THEN IF (_debug) THEN RAISE NOTICE 'inserting NEW.image_name %', NEW.image_name; END IF; SELECT image_id INTO _imageid FROM image WHERE image_name=NEW.image_name; IF (FOUND) THEN RAISE EXCEPTION 'Cannot create new image % because another image with that name already exists.', NEW.image_name; END IF; ELSIF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgimagebeforetrigger() OWNER TO admin; -- -- Name: _pkgitembeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgitembeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _functionargs TEXT; _group TEXT; _object TEXT; _schema TEXT; _debug BOOL := false; BEGIN IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN _object = NEW.pkgitem_name; SELECT LOWER(pkghead_name) INTO _schema FROM pkghead WHERE (pkghead_id=NEW.pkgitem_pkghead_id); IF (NOT FOUND) THEN _schema := 'public'; END IF; IF (NEW.pkgitem_type = 'F') THEN _object := SPLIT_PART(_object, '(', 1); ELSIF (NEW.pkgitem_type = 'M') THEN _group := SPLIT_PART(_object, '-', 1); _object := SPLIT_PART(_object, '-', 2); END IF; IF _debug THEN RAISE NOTICE '_schema % and _object %', _schema, _object; END IF; IF (NEW.pkgitem_type = 'C') THEN IF (NOT EXISTS(SELECT script_id FROM script WHERE ((script_id=NEW.pkgitem_item_id) AND (script_name=NEW.pkgitem_name)))) THEN RAISE EXCEPTION 'Cannot create Script % as a Package Item without a corresponding script record.', NEW.pkgitem_name; END IF; ELSIF (NEW.pkgitem_type = 'D') THEN IF (NOT EXISTS(SELECT cmd_id FROM cmd WHERE ((cmd_id=NEW.pkgitem_item_id) AND (cmd_name=NEW.pkgitem_name)))) THEN RAISE EXCEPTION 'Cannot create Custom Command % as a Package Item without a corresponding cmd record.', NEW.pkgitem_name; END IF; ELSIF (NEW.pkgitem_type = 'F') THEN IF (NOT EXISTS(SELECT pg_proc.oid FROM pg_proc, pg_namespace WHERE ((pg_proc.oid=NEW.pkgitem_item_id) AND (proname = (_object)) AND (pronamespace=pg_namespace.oid) AND (nspname=_schema)) )) THEN RAISE EXCEPTION 'Cannot create Function % (oid %) as a Package Item without a corresponding function in the database.', NEW.pkgitem_name, NEW.pkgitem_item_id; END IF; ELSIF (NEW.pkgitem_type = 'G') THEN IF (NOT EXISTS(SELECT pg_class.oid FROM pg_trigger, pg_class, pg_namespace WHERE ((tgname=_object) AND (tgrelid=pg_class.oid) AND (relnamespace=pg_namespace.oid) AND (nspname=_schema)))) THEN RAISE EXCEPTION 'Cannot create Trigger % as a Package Item without a corresponding trigger in the database.', NEW.pkgitem_name; END IF; ELSIF (NEW.pkgitem_type = 'I') THEN IF (NOT EXISTS(SELECT image_id FROM image WHERE ((image_id=NEW.pkgitem_item_id) AND (image_name=NEW.pkgitem_name)))) THEN RAISE EXCEPTION 'Cannot create Image % as a Package Item without a corresponding image record.', NEW.pkgitem_name; END IF; ELSIF (NEW.pkgitem_type = 'M') THEN IF (NOT EXISTS(SELECT metasql_id FROM metasql WHERE ((metasql_id=NEW.pkgitem_item_id) AND (metasql_group=_group) AND (metasql_name=_object)))) THEN RAISE EXCEPTION 'Cannot create MetaSQL statement % as a Package Item without a corresponding metasql record.', NEW.pkgitem_name; END IF; ELSIF (NEW.pkgitem_type = 'P') THEN IF (NOT EXISTS(SELECT priv_id FROM priv WHERE ((priv_id=NEW.pkgitem_item_id) AND (priv_name=NEW.pkgitem_name)))) THEN RAISE EXCEPTION 'Cannot create Privilege % as a Package Item without a corresponding priv record.', NEW.pkgitem_name; END IF; ELSIF (NEW.pkgitem_type = 'R') THEN IF (NOT EXISTS(SELECT report_id FROM report WHERE ((report_id=NEW.pkgitem_item_id) AND (report_name=NEW.pkgitem_name)))) THEN RAISE EXCEPTION 'Cannot create Report % as a Package Item without a corresponding report record.', NEW.pkgitem_name; END IF; ELSIF (NEW.pkgitem_type = 'S') THEN IF (NOT EXISTS(SELECT oid FROM pg_namespace WHERE (LOWER(nspname)=LOWER(NEW.pkgitem_name)))) THEN RAISE EXCEPTION 'Cannot create Schema % as a Package Item without a corresponding schema in the database.', NEW.pkgitem_name; END IF; ELSIF (NEW.pkgitem_type = 'T') THEN IF (NOT EXISTS(SELECT pg_class.oid FROM pg_class, pg_namespace WHERE ((relname=_object) AND (relnamespace=pg_namespace.oid) AND (relkind='r') AND (nspname=_schema)))) THEN RAISE EXCEPTION 'Cannot create Table % as a Package Item without a corresponding table in the database.', NEW.pkgitem_name; END IF; ELSIF (NEW.pkgitem_type = 'U') THEN IF (NOT EXISTS(SELECT uiform_id FROM uiform WHERE ((uiform_id=NEW.pkgitem_item_id) AND (uiform_name=NEW.pkgitem_name)))) THEN RAISE EXCEPTION 'Cannot create User Interface Form % as a Package Item without a corresponding uiform record.', NEW.pkgitem_name; END IF; ELSIF (NEW.pkgitem_type = 'V') THEN IF (NOT EXISTS(SELECT pg_class.oid FROM pg_class, pg_namespace WHERE ((relname=_object) AND (relnamespace=pg_namespace.oid) AND (relkind='v') AND (nspname=_schema)))) THEN RAISE EXCEPTION 'Cannot create View % as a Package Item without a corresponding view in the database.', NEW.pkgitem_name; END IF; ELSE RAISE EXCEPTION '"%" is not a valid type of package item.', NEW.pkgitem_type; END IF; ELSIF (TG_OP = 'DELETE') THEN IF _debug THEN RAISE NOTICE 'Deleting % % %', OLD.pkgitem_item_id, OLD.pkgitem_name, OLD.pkgitem_type; END IF; _object = OLD.pkgitem_name; SELECT pkghead_name INTO _schema FROM pkghead WHERE (pkghead_id=OLD.pkgitem_pkghead_id); IF (NOT FOUND) THEN _schema := 'public'; END IF; IF (OLD.pkgitem_type = 'F') THEN _object := SPLIT_PART(_object, '(', 1); ELSIF (OLD.pkgitem_type = 'M') THEN _group := SPLIT_PART(_object, '-', 1); _object := SPLIT_PART(_object, '-', 2); END IF; IF _debug THEN RAISE NOTICE '_schema % and _object %', _schema, _object; END IF; IF (OLD.pkgitem_type = 'C') THEN DELETE FROM script WHERE ((script_id=OLD.pkgitem_item_id) AND (script_name=OLD.pkgitem_name)); ELSIF (OLD.pkgitem_type = 'D') THEN DELETE FROM cmd WHERE ((cmd_id=OLD.pkgitem_item_id) AND (cmd_name=OLD.pkgitem_name)); ELSIF (OLD.pkgitem_type = 'F') THEN -- SELECT dropIfExists('FUNCTION', CAST (oid::regprocedure AS TEXT), _schema) PERFORM dropIfExists('FUNCTION', proname || '(' || oidvectortypes(proargtypes) || ')', _schema) FROM pg_proc WHERE (oid=OLD.pkgitem_item_id); ELSIF (OLD.pkgitem_type = 'G') THEN PERFORM dropIfExists('TRIGGER', _object, _schema); ELSIF (OLD.pkgitem_type = 'I') THEN DELETE FROM image WHERE ((image_id=OLD.pkgitem_item_id) AND (image_name=OLD.pkgitem_name)); ELSIF (OLD.pkgitem_type = 'M') THEN DELETE FROM metasql WHERE ((metasql_id=OLD.pkgitem_item_id) AND (metasql_group=_group) AND (metasql_name=_object)); ELSIF (OLD.pkgitem_type = 'P') THEN DELETE FROM priv WHERE ((priv_id=OLD.pkgitem_item_id) AND (priv_name=OLD.pkgitem_name)); ELSIF (OLD.pkgitem_type = 'R') THEN DELETE FROM report WHERE ((report_id=OLD.pkgitem_item_id) AND (report_name=OLD.pkgitem_name)); ELSIF (OLD.pkgitem_type = 'S') THEN PERFORM dropIfExists('SCHEMA', OLD.pkgitem_name, OLD.pkgitem_name); ELSIF (OLD.pkgitem_type = 'T') THEN PERFORM dropIfExists('TABLE', _object, _schema, true); ELSIF (OLD.pkgitem_type = 'U') THEN DELETE FROM uiform WHERE ((uiform_id=OLD.pkgitem_item_id) AND (uiform_name=OLD.pkgitem_name)); ELSIF (OLD.pkgitem_type = 'V') THEN PERFORM dropIfExists('VIEW', _object, _schema, true); ELSE RAISE EXCEPTION '"%" is not a valid type of package item.', OLD.pkgitem_type; END IF; RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgitembeforetrigger() OWNER TO admin; -- -- Name: _pkgmetasqlaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgmetasqlaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgmetasqlaftertrigger() OWNER TO admin; -- -- Name: _pkgmetasqlaltertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgmetasqlaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END IF; -- cannot combine IF's because plpgsql does not always evaluate left-to-right IF (TG_OP = 'INSERT') THEN IF (NEW.metasql_grade <= 0 AND NOT _isdba) THEN RAISE EXCEPTION 'You may not create grade 0 MetaSQL statements in packages except using the xTuple Updater utility'; END IF; ELSIF (TG_OP = 'UPDATE') THEN IF (NEW.metasql_grade <= 0 AND NOT _isdba) THEN RAISE EXCEPTION 'You may not alter grade 0 MetaSQL statements in packages except using the xTuple Updater utility'; END IF; ELSIF (TG_OP = 'DELETE') THEN IF (OLD.metasql_grade <= 0 AND NOT _isdba) THEN RAISE EXCEPTION 'You may not delete grade 0 MetaSQL statements from packages. Try deleting or disabling the package.'; ELSE RETURN OLD; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgmetasqlaltertrigger() OWNER TO admin; -- -- Name: _pkgmetasqlbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgmetasqlbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _metasqlid INTEGER; _isdba BOOLEAN := false; BEGIN SELECT rolsuper INTO _isdba FROM pg_roles WHERE (rolname=getEffectiveXtUser()); IF (NOT (_isdba OR checkPrivilege('MaintainMetaSQL'))) THEN RAISE EXCEPTION '% does not have privileges to maintain MetaSQL statements in %.% (DBA=%)', getEffectiveXtUser(), TG_TABLE_SCHEMA, TG_TABLE_NAME, _isdba; END IF; IF (TG_OP = 'UPDATE') THEN RAISE DEBUG 'update OLD %-%-%, NEW %-%-%', OLD.metasql_group, OLD.metasql_name, OLD.metasql_grade, NEW.metasql_group, NEW.metasql_name, NEW.metasql_grade; IF (NEW.metasql_name != OLD.metasql_name OR NEW.metasql_group != OLD.metasql_group OR NEW.metasql_grade != OLD.metasql_grade) THEN SELECT metasql_id INTO _metasqlid FROM metasql WHERE metasql_name=NEW.metasql_name AND metasql_group=NEW.metasql_group AND metasql_grade=NEW.metasql_grade; IF (FOUND) THEN RAISE EXCEPTION 'Cannot change the MetaSQL statement named %-%-% because another MetaSQL statement with that group, name and grade already exists.', NEW.metasql_group, NEW.metasql_name, NEW.metasql_grade; END IF; END IF; ELSIF (TG_OP = 'INSERT') THEN RAISE DEBUG 'insert NEW %-% %', NEW.metasql_group, NEW.metasql_name, NEW.metasql_grade; SELECT metasql_id INTO _metasqlid FROM metasql WHERE metasql_name=NEW.metasql_name AND metasql_group=NEW.metasql_group AND metasql_grade=NEW.metasql_grade; IF (FOUND) THEN RAISE EXCEPTION 'The new MetaSQL statement %-% % conflicts with an existing statement.', NEW.metasql_group, NEW.metasql_name, NEW.metasql_grade; END IF; ELSIF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgmetasqlbeforetrigger() OWNER TO admin; -- -- Name: _pkgprivaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgprivaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgprivaftertrigger() OWNER TO admin; -- -- Name: _pkgprivaltertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgprivaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END IF; IF (TG_OP = 'INSERT') THEN RAISE EXCEPTION 'You may not create privileges in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'UPDATE') THEN RAISE EXCEPTION 'You may not alter privileges in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'DELETE') THEN RAISE EXCEPTION 'You may not delete privileges from packages. Try deleting or disabling the package.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgprivaltertrigger() OWNER TO admin; -- -- Name: _pkgprivbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgprivbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _privid INTEGER; _debug BOOL := false; BEGIN IF (TG_OP = 'UPDATE') THEN IF (_debug) THEN RAISE NOTICE 'OLD.priv_name %, NEW.priv_name %', OLD.priv_name, NEW.priv_name; END IF; IF (NEW.priv_name != OLD.priv_name) THEN SELECT priv_id INTO _privid FROM priv WHERE priv_name=NEW.priv_name; IF (FOUND) THEN RAISE EXCEPTION 'Cannot change privilege name % because another privilege with that name already exists.', NEW.priv_name; END IF; END IF; ELSIF (TG_OP = 'INSERT') THEN IF (_debug) THEN RAISE NOTICE 'inserting NEW.priv_name %', NEW.priv_name; END IF; SELECT priv_id INTO _privid FROM priv WHERE priv_name=NEW.priv_name; IF (FOUND) THEN RAISE EXCEPTION 'Cannot create new privilege % because another privilege with that name already exists.', NEW.priv_name; END IF; ELSIF (TG_OP = 'DELETE') THEN IF (_debug) THEN RAISE NOTICE 'deleting pkgpriv_id %', OLD.priv_id; END IF; DELETE FROM usrpriv WHERE usrpriv_priv_id=OLD.priv_id; DELETE FROM grppriv WHERE grppriv_priv_id=OLD.priv_id; RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgprivbeforetrigger() OWNER TO admin; -- -- Name: _pkgreportaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgreportaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgreportaftertrigger() OWNER TO admin; -- -- Name: _pkgreportaltertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgreportaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END IF; IF (TG_OP = 'INSERT') THEN RAISE EXCEPTION 'You may not create report definitions in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'UPDATE') THEN RAISE EXCEPTION 'You may not alter report definitions in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'DELETE') THEN RAISE EXCEPTION 'You may not delete report definitions from packages. Try deleting or disabling the package.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgreportaltertrigger() OWNER TO admin; -- -- Name: _pkgreportbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgreportbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _reportid INTEGER; _debug BOOL := false; BEGIN IF (TG_OP = 'UPDATE') THEN IF (_debug) THEN RAISE NOTICE 'update OLD % %, NEW % %', OLD.report_name, OLD.report_grade, NEW.report_name, NEW.report_grade; END IF; IF (NEW.report_name != OLD.report_name) THEN SELECT report_id INTO _reportid FROM report WHERE ((report_name=NEW.report_name) AND (report_grade=NEW.report_grade)); IF (FOUND) THEN RAISE EXCEPTION 'Cannot change report % % because another report with that name and grade already exists.', NEW.report_name, NEW.report_grade; END IF; END IF; ELSIF (TG_OP = 'INSERT') THEN IF (_debug) THEN RAISE NOTICE 'insert NEW % %', NEW.report_name, NEW.report_grade; END IF; SELECT report_id INTO _reportid FROM report WHERE ((report_name=NEW.report_name) AND (report_grade=NEW.report_grade)); IF (FOUND) THEN RAISE EXCEPTION 'Cannot create new report % % because another report with that name and grade already exists.', NEW.report_name, NEW.report_grade; END IF; ELSIF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgreportbeforetrigger() OWNER TO admin; -- -- Name: _pkgscriptaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgscriptaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgscriptaftertrigger() OWNER TO admin; -- -- Name: _pkgscriptaltertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgscriptaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END IF; IF (TG_OP = 'INSERT') THEN RAISE EXCEPTION 'You may not create scripts in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'UPDATE') THEN RAISE EXCEPTION 'You may not alter scripts in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'DELETE') THEN RAISE EXCEPTION 'You may not delete scripts from packages. Try deleting or disabling the package.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgscriptaltertrigger() OWNER TO admin; -- -- Name: _pkgscriptbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkgscriptbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _scriptid INTEGER; _debug BOOL := false; BEGIN IF (TG_OP = 'UPDATE') THEN RETURN NEW; ELSIF (TG_OP = 'INSERT') THEN RETURN NEW; ELSIF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkgscriptbeforetrigger() OWNER TO admin; -- -- Name: _pkguiformaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkguiformaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkguiformaftertrigger() OWNER TO admin; -- -- Name: _pkguiformaltertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkguiformaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END IF; IF (TG_OP = 'INSERT') THEN RAISE EXCEPTION 'You may not create forms in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'UPDATE') THEN RAISE EXCEPTION 'You may not alter forms in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'DELETE') THEN RAISE EXCEPTION 'You may not delete forms from packages. Try deleting or disabling the package.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkguiformaltertrigger() OWNER TO admin; -- -- Name: _pkguiformbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _pkguiformbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _uiformid INTEGER; _debug BOOL := false; BEGIN IF (TG_OP = 'UPDATE') THEN RETURN NEW; ELSIF (TG_OP = 'INSERT') THEN RETURN NEW; ELSIF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._pkguiformbeforetrigger() OWNER TO admin; -- -- Name: _poheadafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _poheadafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'PO' AND charass_target_id = OLD.pohead_id; RETURN OLD; END; $$; ALTER FUNCTION public._poheadafterdeletetrigger() OWNER TO admin; -- -- Name: _poheadtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _poheadtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; _check BOOLEAN; _maint BOOLEAN := TRUE; BEGIN -- Check if we are doing maintenance IF (TG_OP = 'UPDATE') THEN IF ( (OLD.pohead_status != NEW.pohead_status) OR (OLD.pohead_printed != NEW.pohead_printed) ) THEN _maint := FALSE; END IF; END IF; -- Check IF ( (NOT _maint) AND (NOT checkPrivilege('MaintainPurchaseOrders')) AND (NOT checkPrivilege('PostPurchaseOrders')) AND (NOT checkPrivilege('PrintPurchaseOrders')) AND (NOT checkPrivilege('PostVouchers')) ) THEN RAISE EXCEPTION 'You do not have privileges to alter a Purchase Order.'; END IF; IF ( _maint AND (NOT checkPrivilege('MaintainPurchaseOrders')) ) THEN RAISE EXCEPTION 'You do not have privileges to alter a Purchase Order.'; END IF; IF (TG_OP = 'INSERT') THEN --- clear the number from the issue cache PERFORM clearNumberIssue('PoNumber', NEW.pohead_number); END IF; IF ( (TG_OP = 'INSERT') OR (TG_op = 'UPDATE') ) THEN IF (NOT ISNUMERIC(NEW.pohead_number) AND NEW.pohead_saved) THEN RAISE EXCEPTION 'Purchase Order Number must be numeric.'; END IF; END IF; IF (TG_OP = 'UPDATE') THEN IF (NEW.pohead_status = 'O' AND OLD.pohead_released IS NULL) THEN NEW.pohead_released := CURRENT_DATE; END IF; END IF; IF ( SELECT (metric_value='t') FROM metric WHERE (metric_name='POChangeLog') ) THEN -- Cache the cmnttype_id for ChangeLog SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (FOUND) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'P', NEW.pohead_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.pohead_terms_id <> NEW.pohead_terms_id) THEN PERFORM postComment( _cmnttypeid, 'P', NEW.pohead_id, ('Terms Changed from "' || oldterms.terms_code || '" to "' || newterms.terms_code || '"') ) FROM terms AS oldterms, terms AS newterms WHERE ( (oldterms.terms_id=OLD.pohead_terms_id) AND (newterms.terms_id=NEW.pohead_terms_id) ); END IF; ELSIF (TG_OP = 'DELETE') THEN DELETE FROM docass WHERE docass_source_id = OLD.pohead_id AND docass_source_type = 'P'; DELETE FROM docass WHERE docass_target_id = OLD.pohead_id AND docass_target_type = 'P'; DELETE FROM comment WHERE ( (comment_source='P') AND (comment_source_id=OLD.pohead_id) ); END IF; END IF; END IF; IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END; $$; ALTER FUNCTION public._poheadtrigger() OWNER TO admin; -- -- Name: _poheadtriggerafter(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _poheadtriggerafter() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (COALESCE(NEW.pohead_taxzone_id,-1) <> COALESCE(OLD.pohead_taxzone_id,-1)) THEN UPDATE poitem SET poitem_taxtype_id=getItemTaxType(itemsite_item_id,NEW.pohead_taxzone_id) FROM itemsite WHERE ((itemsite_id=poitem_itemsite_id) AND (poitem_pohead_id=NEW.pohead_id)); END IF; -- Do not update closed poitems IF (TG_OP = 'UPDATE') THEN IF (OLD.pohead_status != NEW.pohead_status) THEN UPDATE poitem SET poitem_status=NEW.pohead_status WHERE ( (poitem_pohead_id=NEW.pohead_id) AND (poitem_status <> 'C') ); END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._poheadtriggerafter() OWNER TO admin; -- -- Name: _poitemafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _poitemafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _changelog BOOLEAN := FALSE; BEGIN IF (OLD.poitem_status = 'O') THEN IF ( (SELECT (count(*) < 1) FROM poitem WHERE ((poitem_pohead_id=OLD.poitem_pohead_id) AND (poitem_id != OLD.poitem_id) AND (poitem_status <> 'C')) ) ) THEN UPDATE pohead SET pohead_status = 'C' WHERE ((pohead_id=OLD.poitem_pohead_id) AND (pohead_status='O')); END IF; END IF; IF ( SELECT fetchMetricBool('POChangeLog') ) THEN _changelog := TRUE; END IF; IF ( _changelog ) THEN PERFORM postComment('ChangeLog', 'P', OLD.poitem_pohead_id, ('Deleted Line #' || OLD.poitem_linenumber::TEXT)); END IF; DELETE FROM charass WHERE charass_target_type = 'PI' AND charass_target_id = OLD.poitem_id; RETURN OLD; END; $$; ALTER FUNCTION public._poitemafterdeletetrigger() OWNER TO admin; -- -- Name: _poitemaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _poitemaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _changelog BOOLEAN := FALSE; BEGIN IF (TG_OP = 'UPDATE') THEN IF (OLD.poitem_status <> NEW.poitem_status) THEN IF ( (SELECT (count(*) < 1) FROM poitem WHERE ((poitem_pohead_id=NEW.poitem_pohead_id) AND (poitem_id != NEW.poitem_id) AND (poitem_status<>'C')) ) AND (NEW.poitem_status='C') ) THEN UPDATE pohead SET pohead_status = 'C' WHERE ((pohead_id=NEW.poitem_pohead_id) AND (pohead_status='O')); ELSE UPDATE pohead SET pohead_status = 'O' WHERE ((pohead_id=NEW.poitem_pohead_id) AND (pohead_status='C')); END IF; END IF; END IF; IF (TG_OP = 'INSERT') THEN PERFORM postEvent('POitemCreate', 'P', NEW.poitem_id, itemsite_warehous_id, (pohead_number || '-' || NEW.poitem_linenumber || ': ' || item_number), NULL, NULL, NULL, NULL) FROM pohead JOIN itemsite ON (itemsite_id=NEW.poitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (pohead_id=NEW.poitem_pohead_id) AND (NEW.poitem_duedate <= (CURRENT_DATE + itemsite_eventfence)); END IF; IF ( SELECT fetchMetricBool('POChangeLog') ) THEN _changelog := TRUE; END IF; IF ( _changelog ) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment('ChangeLog', 'P', NEW.poitem_pohead_id, ('Created Line #' || NEW.poitem_linenumber::TEXT)); PERFORM postComment('ChangeLog', 'PI', NEW.poitem_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (NEW.poitem_qty_ordered <> OLD.poitem_qty_ordered) THEN PERFORM postComment( 'ChangeLog', 'PI', NEW.poitem_id, ( 'Qty. Ordered Changed from ' || formatQty(OLD.poitem_qty_ordered) || ' to ' || formatQty(NEW.poitem_qty_ordered ) ) ); END IF; IF (NEW.poitem_unitprice <> OLD.poitem_unitprice) THEN PERFORM postComment( 'ChangeLog', 'PI', NEW.poitem_id, ( 'Unit Price Changed from ' || formatPurchPrice(OLD.poitem_unitprice) || ' to ' || formatPurchPrice(NEW.poitem_unitprice ) ) ); END IF; IF (NEW.poitem_duedate <> OLD.poitem_duedate) THEN PERFORM postComment( 'ChangeLog', 'PI', NEW.poitem_id, ( 'Due Date Changed from ' || formatDate(OLD.poitem_duedate) || ' to ' || formatDate(NEW.poitem_duedate ) ) ); END IF; IF (COALESCE(OLD.poitem_taxtype_id, -1) <> COALESCE(NEW.poitem_taxtype_id, -1)) THEN PERFORM postComment( 'ChangeLog', 'PI', NEW.poitem_id, ( 'Tax Type Changed from "' || COALESCE((SELECT taxtype_name FROM taxtype WHERE taxtype_id=OLD.poitem_taxtype_id), 'None') || '" (' || COALESCE(OLD.poitem_taxtype_id, 0) || ') to "' || COALESCE((SELECT taxtype_name FROM taxtype WHERE taxtype_id=NEW.poitem_taxtype_id), 'None') || '" (' || COALESCE(NEW.poitem_taxtype_id, 0) || ')' ) ); END IF; IF (NEW.poitem_status <> OLD.poitem_status) THEN IF (NEW.poitem_status = 'C') THEN PERFORM postComment('ChangeLog', 'PI', NEW.poitem_id, 'Closed'); ELSIF (NEW.poitem_status = 'O') THEN PERFORM postComment('ChangeLog', 'PI', NEW.poitem_id, 'Opened'); END IF; END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._poitemaftertrigger() OWNER TO admin; -- -- Name: _poitemdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _poitemdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF (NOT checkPrivilege('MaintainPurchaseOrders')) THEN RAISE EXCEPTION 'You do not have privileges to alter a Purchase Order.'; END IF; IF (EXISTS(SELECT recv_id FROM recv WHERE ((recv_order_type='PO') AND (recv_orderitem_id=OLD.poitem_id) AND (recv_qty>0)))) THEN RAISE EXCEPTION 'Cannot delete an P/O Item which has been received'; END IF; DELETE FROM comment WHERE ( (comment_source='PI') AND (comment_source_id=OLD.poitem_id) ); DELETE FROM charass WHERE ((charass_target_type='PI') AND (charass_target_id=OLD.poitem_id)); RETURN OLD; END; $$; ALTER FUNCTION public._poitemdeletetrigger() OWNER TO admin; -- -- Name: _poitemtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _poitemtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; _status CHAR(1); _check BOOLEAN; _cnt INTEGER; _s RECORD; BEGIN -- Check IF ( (TG_OP = 'UPDATE') AND (NOT checkPrivilege('MaintainPurchaseOrders')) AND (NOT checkPrivilege('ChangePurchaseOrderQty')) AND (NOT checkPrivilege('EnterReceipts')) AND (NOT checkPrivilege('PostVouchers')) ) THEN RAISE EXCEPTION 'You do not have privileges to alter a Purchase Order.'; END IF; IF ( (TG_OP = 'INSERT') AND (NOT checkPrivilege('MaintainPurchaseOrders')) ) THEN RAISE EXCEPTION 'You do not have privileges to alter a Purchase Order.'; END IF; IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN SELECT pohead_status INTO _status FROM pohead WHERE (pohead_id=NEW.poitem_pohead_id); IF (NEW.poitem_itemsite_id=-1) THEN NEW.poitem_itemsite_id := NULL; END IF; IF (NEW.poitem_expcat_id=-1) THEN NEW.poitem_expcat_id := NULL; END IF; IF (NEW.poitem_itemsite_id IS NOT NULL AND NEW.poitem_expcat_id IS NOT NULL) THEN RAISE EXCEPTION 'A purchase order line may not include both an inventory and non-inventory item'; ELSIF (NEW.poitem_itemsite_id IS NULL AND NEW.poitem_expcat_id IS NULL) THEN RAISE EXCEPTION 'A purchase order line must specify either an inventory item or a non-inventory expense category'; ELSIF (NEW.poitem_qty_ordered IS NULL) THEN RAISE EXCEPTION 'A purchase order line must specify a quantity'; ELSIF (COALESCE(NEW.poitem_itemsite_id,-1) != -1) THEN SELECT (COUNT(item_id)=1) INTO _check FROM itemsite, item WHERE ((itemsite_id=NEW.poitem_itemsite_id) AND (itemsite_item_id=item_id) AND (item_type IN ('P','O','M','T'))); IF NOT (_check) THEN RAISE EXCEPTION 'The item is not a purchasable item type'; END IF; END IF; END IF; IF (TG_OP = 'INSERT') THEN IF (_status='C') THEN RAISE EXCEPTION 'New lines may not be inserted into a closed purchase order'; END IF; --Fetch and apply default item source data if applicable IF ((NEW.poitem_itemsrc_id IS NULL) AND (NEW.poitem_itemsite_id IS NOT NULL)) THEN IF (NEW.poitem_itemsrc_id IS NULL) THEN SELECT COUNT(itemsrc_id) INTO _cnt FROM pohead,itemsrc,itemsite WHERE ((pohead_id=NEW.poitem_pohead_id) AND (pohead_vend_id=itemsrc_vend_id) AND (itemsite_id=NEW.poitem_itemsite_id) AND (itemsite_item_id=itemsrc_item_id)); IF (_cnt = 1) THEN -- We found the one and only item source, so populate data for it SELECT itemsrc.* INTO _s FROM pohead,itemsrc,itemsite WHERE ((pohead_id=NEW.poitem_pohead_id) AND (pohead_vend_id=itemsrc_vend_id) AND (itemsite_id=NEW.poitem_itemsite_id) AND (itemsite_item_id=itemsrc_item_id)); IF (FOUND) THEN NEW.poitem_itemsrc_id := _s.itemsrc_id; NEW.poitem_vend_uom := _s.itemsrc_vend_uom; NEW.poitem_invvenduomratio := _s.itemsrc_invvendoruomratio; NEW.poitem_duedate := COALESCE(NEW.poitem_duedate, CURRENT_DATE + _s.itemsrc_leadtime); NEW.poitem_vend_item_number := COALESCE(NEW.poitem_vend_item_number,_s.itemsrc_vend_item_number); NEW.poitem_vend_item_descrip := COALESCE(NEW.poitem_vend_item_descrip,_s.itemsrc_vend_item_descrip); NEW.poitem_manuf_name := COALESCE(NEW.poitem_manuf_name,_s.itemsrc_manuf_name); NEW.poitem_manuf_item_number := COALESCE(NEW.poitem_manuf_item_number, _s.itemsrc_manuf_item_number); NEW.poitem_manuf_item_descrip := COALESCE(NEW.poitem_manuf_item_descrip, _s.itemsrc_manuf_item_descrip); END IF; ELSIF (_cnt > 1) THEN -- There are multiple sources, see if there is an exact match with provided vendor info. SELECT itemsrc.* INTO _s FROM pohead,itemsrc,itemsite WHERE ((pohead_id=NEW.poitem_pohead_id) AND (pohead_vend_id=itemsrc_vend_id) AND (itemsite_id=NEW.poitem_itemsite_id) AND (itemsite_item_id=itemsrc_item_id) AND (NEW.poitem_vend_item_number=itemsrc_vend_item_number) AND (COALESCE(NEW.poitem_manuf_name,'')=COALESCE(itemsrc_manuf_name,'')) AND (COALESCE(NEW.poitem_manuf_item_number,'')=COALESCE(itemsrc_manuf_item_number,''))); IF (FOUND) THEN NEW.poitem_itemsrc_id := _s.itemsrc_id; NEW.poitem_vend_uom := _s.itemsrc_vend_uom; NEW.poitem_invvenduomratio := _s.itemsrc_invvendoruomratio; NEW.poitem_duedate := COALESCE(NEW.poitem_duedate, CURRENT_DATE + _s.itemsrc_leadtime); NEW.poitem_vend_item_descrip := COALESCE(NEW.poitem_vend_item_descrip,_s.itemsrc_vend_item_descrip); NEW.poitem_manuf_item_descrip := COALESCE(NEW.poitem_manuf_item_descrip, _s.itemsrc_manuf_item_descrip); END IF; END IF; END IF; END IF; IF (NEW.poitem_duedate IS NULL) THEN RAISE EXCEPTION 'A due date is required'; END IF; --Set defaults NEW.poitem_linenumber := COALESCE(NEW.poitem_linenumber,( SELECT COALESCE(MAX(poitem_linenumber),0) + 1 FROM poitem WHERE (poitem_pohead_id=NEW.poitem_pohead_id))); NEW.poitem_status := _status; NEW.poitem_invvenduomratio := COALESCE(NEW.poitem_invvenduomratio,1); IF (NEW.poitem_invvenduomratio = 0.0) THEN NEW.poitem_invvenduomratio = 1.0; END IF; NEW.poitem_vend_item_number := COALESCE(NEW.poitem_vend_item_number,''); NEW.poitem_vend_item_descrip := COALESCE(NEW.poitem_vend_item_descrip,''); NEW.poitem_unitprice := COALESCE(NEW.poitem_unitprice,( SELECT itemsrcPrice(NEW.poitem_itemsrc_id, COALESCE(itemsite_warehous_id, -1), pohead_dropship, NEW.poitem_qty_ordered, pohead_curr_id, CURRENT_DATE) FROM itemsite, pohead WHERE ( (itemsite_id=NEW.poitem_itemsite_id) AND (pohead_id=NEW.poitem_pohead_id) )), 0.0); NEW.poitem_stdcost := COALESCE(NEW.poitem_stdcost,( SELECT stdcost(itemsite_item_id) FROM itemsite WHERE (itemsite_id=NEW.poitem_itemsite_id))); NEW.poitem_bom_rev_id := COALESCE(NEW.poitem_bom_rev_id,( SELECT getActiveRevId('BOM',itemsite_item_id) FROM itemsite WHERE (itemsite_id=NEW.poitem_itemsite_id))); NEW.poitem_boo_rev_id := COALESCE(NEW.poitem_boo_rev_id,( SELECT getActiveRevId('BOO',itemsite_item_id) FROM itemsite WHERE (itemsite_id=NEW.poitem_itemsite_id))); NEW.poitem_comments := COALESCE(NEW.poitem_comments,''); NEW.poitem_freight := COALESCE(NEW.poitem_freight,0); NEW.poitem_qty_received := 0; NEW.poitem_qty_returned := 0; NEW.poitem_qty_vouchered := 0; END IF; IF (TG_OP = 'UPDATE') THEN IF (NEW.poitem_itemsite_id != OLD.poitem_itemsite_id) THEN RAISE EXCEPTION 'You may not change the item site for a line item.'; ELSIF (NEW.poitem_expcat_id != OLD.poitem_expcat_id) THEN RAISE EXCEPTION 'You may not change the expense category for a line item.'; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._poitemtrigger() OWNER TO admin; -- -- Name: _prjafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _prjafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'PROJ' AND charass_target_id = OLD.prj_id; RETURN OLD; END; $$; ALTER FUNCTION public._prjafterdeletetrigger() OWNER TO admin; -- -- Name: _prjaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _prjaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; BEGIN -- Cache the cmnttype_id for ChangeLog SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (NOT FOUND) THEN RAISE EXCEPTION 'Comment type ChangeLog not found'; END IF; IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'J', NEW.prj_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.prj_start_date <> NEW.prj_start_date) THEN PERFORM postComment( _cmnttypeid, 'J', NEW.prj_id, ('Start Date Changed from ' || formatDate(OLD.prj_start_date) || ' to ' || formatDate(NEW.prj_start_date)) ); END IF; IF (OLD.prj_due_date <> NEW.prj_due_date) THEN PERFORM postComment( _cmnttypeid, 'J', NEW.prj_id, ('Due Date Changed from ' || formatDate(OLD.prj_due_date) || ' to ' || formatDate(NEW.prj_due_date)) ); END IF; IF (OLD.prj_assigned_date <> NEW.prj_assigned_date) THEN PERFORM postComment( _cmnttypeid, 'J', NEW.prj_id, ('Assigned Date Changed from ' || formatDate(OLD.prj_assigned_date) || ' to ' || formatDate(NEW.prj_assigned_date)) ); END IF; IF (OLD.prj_completed_date <> NEW.prj_completed_date) THEN PERFORM postComment( _cmnttypeid, 'J', NEW.prj_id, ('Completed Date Changed from ' || formatDate(OLD.prj_completed_date) || ' to ' || formatDate(NEW.prj_completed_date)) ); END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._prjaftertrigger() OWNER TO admin; -- -- Name: _prjbeforedeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _prjbeforedeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _recurid INTEGER; _newparentid INTEGER; BEGIN IF (TG_OP = 'DELETE') THEN DELETE FROM docass WHERE docass_source_id = OLD.prj_id AND docass_source_type = 'J'; DELETE FROM docass WHERE docass_target_id = OLD.prj_id AND docass_target_type = 'J'; SELECT recur_id INTO _recurid FROM recur WHERE ((recur_parent_id=OLD.prj_id) AND (recur_parent_type='J')); IF (_recurid IS NOT NULL) THEN SELECT MIN(prj_id) INTO _newparentid FROM prj WHERE ((prj_recurring_prj_id=OLD.prj_id) AND (prj_id!=OLD.prj_id)); -- client is responsible for warning about deleting a recurring prj IF (_newparentid IS NULL) THEN DELETE FROM recur WHERE recur_id=_recurid; ELSE UPDATE recur SET recur_parent_id=_newparentid WHERE recur_id=_recurid; END IF; END IF; RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._prjbeforedeletetrigger() OWNER TO admin; -- -- Name: _prjtaskafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _prjtaskafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'TASK' AND charass_target_id = OLD.prjtask_id; RETURN OLD; END; $$; ALTER FUNCTION public._prjtaskafterdeletetrigger() OWNER TO admin; -- -- Name: _prjtaskaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _prjtaskaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; BEGIN SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (NOT FOUND) THEN RAISE EXCEPTION 'Comment type ChangeLog not found'; END IF; IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'TA', NEW.prjtask_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.prjtask_start_date <> NEW.prjtask_start_date) THEN PERFORM postComment( _cmnttypeid, 'TA', NEW.prjtask_id, ('Start Date Changed from ' || formatDate(OLD.prjtask_start_date) || ' to ' || formatDate(NEW.prjtask_start_date)) ); END IF; IF (OLD.prjtask_due_date <> NEW.prjtask_due_date) THEN PERFORM postComment( _cmnttypeid, 'TA', NEW.prjtask_id, ('Due Date Changed from ' || formatDate(OLD.prjtask_due_date) || ' to ' || formatDate(NEW.prjtask_due_date)) ); END IF; IF (OLD.prjtask_assigned_date <> NEW.prjtask_assigned_date) THEN PERFORM postComment( _cmnttypeid, 'TA', NEW.prjtask_id, ('Assigned Date Changed from ' || formatDate(OLD.prjtask_assigned_date) || ' to ' || formatDate(NEW.prjtask_assigned_date)) ); END IF; IF (OLD.prjtask_completed_date <> NEW.prjtask_completed_date) THEN PERFORM postComment( _cmnttypeid, 'TA', NEW.prjtask_id, ('Completed Date Changed from ' || formatDate(OLD.prjtask_completed_date) || ' to ' || formatDate(NEW.prjtask_completed_date)) ); END IF; IF (OLD.prjtask_hours_actual != NEW.prjtask_hours_actual) THEN PERFORM postComment(_cmnttypeid, 'TA', NEW.prjtask_id, 'Actual Hours changed from ' || formatQty(OLD.prjtask_hours_actual) || ' to ' || formatQty(NEW.prjtask_hours_actual)); END IF; IF (OLD.prjtask_exp_actual != NEW.prjtask_exp_actual) THEN PERFORM postComment(_cmnttypeid, 'TA', NEW.prjtask_id, 'Actual Expense changed from ' || formatQty(OLD.prjtask_exp_actual) || ' to ' || formatQty(NEW.prjtask_exp_actual)); END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._prjtaskaftertrigger() OWNER TO admin; -- -- Name: _prjtasktrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _prjtasktrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Checks IF (NEW.prjtask_owner_username=getEffectiveXtUser()) THEN IF (NOT checkPrivilege('MaintainAllProjects') AND NOT checkPrivilege('MaintainPersonalProjects')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Projects.'; END IF; ELSIF (NOT checkPrivilege('MaintainAllProjects')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Projects.'; ELSIF (LENGTH(COALESCE(NEW.prjtask_number,'')) = 0) THEN RAISE EXCEPTION 'You must ender a valid number.'; ELSIF (LENGTH(COALESCE(NEW.prjtask_name,'')) = 0) THEN RAISE EXCEPTION 'You must ender a valid name.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._prjtasktrigger() OWNER TO admin; -- -- Name: _prospectafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _prospectafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF EXISTS(SELECT 1 FROM quhead WHERE quhead_cust_id = OLD.prospect_id) AND NOT EXISTS (SELECT 1 FROM custinfo WHERE cust_id = OLD.prospect_id) THEN RAISE EXCEPTION '[xtuple: deleteProspect, -1]'; END IF; IF (fetchMetricBool('ProspectChangeLog')) THEN PERFORM postComment(cmnttype_id, 'PSPCT', OLD.prospect_id, 'Deleted "' || OLD.prospect_number || '"') FROM cmnttype WHERE (cmnttype_name='ChangeLog'); END IF; RETURN OLD; END; $$; ALTER FUNCTION public._prospectafterdeletetrigger() OWNER TO admin; -- -- Name: _prospectaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _prospectaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; _custid INTEGER; _prospectid INTEGER; BEGIN IF (TG_OP = 'INSERT') THEN SELECT crmacct_cust_id, crmacct_prospect_id INTO _custid, _prospectid FROM crmacct WHERE crmacct_number=NEW.prospect_number; IF (_custid > 0 AND _custid != _prospectid) THEN RAISE EXCEPTION '[xtuple: createProspect, -2]'; END IF; IF (_prospectid > 0) THEN RAISE EXCEPTION '[xtuple: createProspect, -3]'; END IF; -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE LOOP UPDATE crmacct SET crmacct_prospect_id=NEW.prospect_id, crmacct_cust_id=NULL, crmacct_name=NEW.prospect_name WHERE crmacct_number=NEW.prospect_number; IF (FOUND) THEN EXIT; END IF; BEGIN INSERT INTO crmacct(crmacct_number, crmacct_name, crmacct_active, crmacct_type, crmacct_prospect_id, crmacct_cntct_id_1 ) VALUES (NEW.prospect_number, NEW.prospect_name, NEW.prospect_active, 'O', NEW.prospect_id, NEW.prospect_cntct_id); EXIT; EXCEPTION WHEN unique_violation THEN -- do nothing, and loop to try the UPDATE again END; END LOOP; /* TODO: default characteristic assignments based on what? */ ELSIF (TG_OP = 'UPDATE') THEN UPDATE crmacct SET crmacct_number = NEW.prospect_number WHERE ((crmacct_prospect_id=NEW.prospect_id) AND (crmacct_number!=NEW.prospect_number)); UPDATE crmacct SET crmacct_name = NEW.prospect_name WHERE ((crmacct_prospect_id=NEW.prospect_id) AND (crmacct_name!=NEW.prospect_name)); END IF; IF (fetchMetricBool('ProspectChangeLog')) THEN SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (_cmnttypeid IS NOT NULL) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.prospect_active <> NEW.prospect_active) THEN PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id, CASE WHEN NEW.prospect_active THEN 'Activated' ELSE 'Deactivated' END); END IF; IF (OLD.prospect_number <> NEW.prospect_number) THEN PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id, 'Number changed from "' || OLD.prospect_number || '" to "' || NEW.prospect_number || '"'); END IF; IF (OLD.prospect_name <> NEW.prospect_name) THEN PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id, 'Name changed from "' || OLD.prospect_name || '" to "' || NEW.prospect_name || '"'); END IF; IF (OLD.prospect_cntct_id <> NEW.prospect_cntct_id) THEN PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id, 'Contact changed from "' || formatCntctName(OLD.prospect_cntct_id) || '" to "' || formatCntctName(NEW.prospect_cntct_id) || '"'); END IF; IF (OLD.prospect_taxauth_id <> NEW.prospect_taxauth_id) THEN PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id, 'Tax Authority changed from "' || (SELECT taxauth_code FROM taxauth WHERE taxauth_id=OLD.prospect_taxauth_id) || '" to "' || (SELECT taxauth_code FROM taxauth WHERE taxauth_id=NEW.prospect_taxauth_id) || '"'); END IF; IF (OLD.prospect_salesrep_id <> NEW.prospect_salesrep_id) THEN PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id, 'Sales Rep changed from "' || (SELECT salesrep_number FROM salesrep WHERE salesrep_id=OLD.prospect_salesrep_id) || '" to "' || (SELECT salesrep_number FROM salesrep WHERE salesrep_id=NEW.prospect_salesrep_id) || '"'); END IF; IF (OLD.prospect_warehous_id <> NEW.prospect_warehous_id) THEN PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id, 'Warehouse changed from "' || (SELECT warehous_code FROM whsinfo WHERE warehous_id=OLD.prospect_warehous_id) || '" to "' || (SELECT warehous_code FROM whsinfo WHERE warehous_id=NEW.prospect_warehous_id) || '"'); END IF; IF (OLD.prospect_taxzone_id <> NEW.prospect_taxzone_id) THEN PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id, 'Tax Zone changed from "' || (SELECT taxzone_code FROM taxzone WHERE taxzone_id=OLD.prospect_taxzone_id) || '" to "' || (SELECT taxzone_code FROM taxzone WHERE taxzone_id=NEW.prospect_taxzone_id) || '"'); END IF; END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._prospectaftertrigger() OWNER TO admin; -- -- Name: _prospectbeforedeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _prospectbeforedeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (NOT checkPrivilege('MaintainProspectMasters')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Prospects.'; END IF; UPDATE crmacct SET crmacct_prospect_id = NULL WHERE crmacct_prospect_id = OLD.prospect_id; RETURN OLD; END; $$; ALTER FUNCTION public._prospectbeforedeletetrigger() OWNER TO admin; -- -- Name: _prospecttrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _prospecttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (NOT checkPrivilege('MaintainProspectMasters')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Prospects.'; END IF; IF (NEW.prospect_number IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Prospect Number.'; END IF; NEW.prospect_number := UPPER(NEW.prospect_number); RETURN NEW; END; $$; ALTER FUNCTION public._prospecttrigger() OWNER TO admin; -- -- Name: _prtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _prtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/EULA for the full text of the software license. BEGIN --- clear the number from the issue cache PERFORM clearNumberIssue('PrNumber', NEW.pr_number); RETURN NEW; END; $$; ALTER FUNCTION public._prtrigger() OWNER TO admin; -- -- Name: _quheadafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _quheadafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'QU' AND charass_target_id = OLD.quhead_id; RETURN OLD; END; $$; ALTER FUNCTION public._quheadafterdeletetrigger() OWNER TO admin; -- -- Name: _quheadtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _quheadtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; _oldHoldType TEXT; _newHoldType TEXT; _p RECORD; _a RECORD; _w RECORD; _shiptoId INTEGER; _addrId INTEGER; _prjId INTEGER; _check BOOLEAN; _numGen CHAR(1); BEGIN -- Checks SELECT checkPrivilege('MaintainQuotes') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to maintain Quotes.'; END IF; -- If this is imported, check the quote number IF (TG_OP = 'INSERT') THEN IF (NEW.quhead_imported) THEN SELECT fetchMetricText('QUNumberGeneration') INTO _numGen; IF ((NEW.quhead_number IS NULL) AND (_numGen='M')) THEN RAISE EXCEPTION 'You must supply a Quote Number.'; ELSE IF ((NEW.quhead_number IS NOT NULL) AND (_numGen='A')) THEN RAISE EXCEPTION 'You may not supply a new Quote Number xTuple will generate the number.'; ELSE IF ((NEW.quhead_number IS NULL) AND (_numGen='S')) THEN SELECT fetchsonumber() INTO NEW.quhead_number; ELSE IF (NEW.quhead_number IS NULL) THEN SELECT fetchqunumber() INTO NEW.quhead_number; END IF; END IF; END IF; END IF; END IF; IF (fetchMetricText('QUNumberGeneration') IN ('A','O')) THEN --- clear the number from the issue cache PERFORM clearNumberIssue('QuNumber', NEW.quhead_number); ELSIF (fetchMetricText('QUNumberGeneration') = 'S') THEN --- clear the number from the issue cache PERFORM clearNumberIssue('SoNumber', NEW.quhead_number); END IF; ELSE IF (TG_OP = 'UPDATE') THEN IF (NEW.quhead_number <> OLD.quhead_number) THEN RAISE EXCEPTION 'The order number may not be changed.'; END IF; END IF; END IF; IF (TG_OP IN ('INSERT','UPDATE')) THEN -- Get Customer data IF (NEW.quhead_shipto_id IS NULL) THEN SELECT * INTO _p FROM ( SELECT cust_number,cust_usespos,cust_blanketpos,cust_ffbillto, cust_ffshipto,cust_name,cust_salesrep_id,cust_terms_id,cust_shipvia, cust_commprcnt,cust_curr_id,cust_taxzone_id, addr_line1,addr_line2,addr_line3,addr_city,addr_state,addr_postalcode,addr_country, shipto_id,shipto_addr_id,shipto_name,shipto_salesrep_id,shipto_shipvia, shipto_shipchrg_id,shipto_shipform_id,shipto_commission,shipto_taxzone_id FROM custinfo LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) LEFT OUTER JOIN shiptoinfo ON ((cust_id=shipto_cust_id) AND shipto_default) WHERE (cust_id=NEW.quhead_cust_id) UNION SELECT prospect_number,false,false,true, true,prospect_name,prospect_salesrep_id,null,null, null,null,prospect_taxzone_id, addr_line1,addr_line2,addr_line3,addr_city,addr_state,addr_postalcode,addr_country, null,null,null,null,null, null,null,null,null FROM prospect LEFT OUTER JOIN cntct ON (prospect_cntct_id=cntct_id) LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) WHERE (prospect_id=NEW.quhead_cust_id)) AS data; ELSE SELECT cust_creditstatus,cust_number,cust_usespos,cust_blanketpos,cust_ffbillto, cust_ffshipto,cust_name,cust_salesrep_id,cust_terms_id,cust_shipvia, cust_shipchrg_id,cust_shipform_id,cust_commprcnt,cust_curr_id,cust_taxzone_id, addr_line1,addr_line2,addr_line3,addr_city,addr_state,addr_postalcode,addr_country, shipto_id,shipto_addr_id,shipto_name,shipto_salesrep_id,shipto_shipvia, shipto_shipchrg_id,shipto_shipform_id,shipto_commission,shipto_taxzone_id INTO _p FROM shiptoinfo,custinfo LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) WHERE ((cust_id=NEW.quhead_cust_id) AND (shipto_id=shipto_id)); END IF; -- If there is customer data, then we can get to work IF (FOUND) THEN -- Only check PO number for imports because UI checks when whole quote is saved IF (TG_OP = 'INSERT') THEN -- Set to defaults if values not provided NEW.quhead_shipto_id := COALESCE(NEW.quhead_shipto_id,_p.shipto_id); NEW.quhead_salesrep_id := COALESCE(NEW.quhead_salesrep_id,_p.shipto_salesrep_id,_p.cust_salesrep_id); NEW.quhead_terms_id := COALESCE(NEW.quhead_terms_id,_p.cust_terms_id); NEW.quhead_shipvia := COALESCE(NEW.quhead_shipvia,_p.shipto_shipvia,_p.cust_shipvia); NEW.quhead_commission := COALESCE(NEW.quhead_commission,_p.shipto_commission,_p.cust_commprcnt); NEW.quhead_quotedate := COALESCE(NEW.quhead_quotedate,current_date); NEW.quhead_packdate := COALESCE(NEW.quhead_packdate,NEW.quhead_quotedate); NEW.quhead_curr_id := COALESCE(NEW.quhead_curr_id,_p.cust_curr_id,basecurrid()); NEW.quhead_taxzone_id := COALESCE(NEW.quhead_taxzone_id,_p.shipto_taxzone_id,_p.cust_taxzone_id); NEW.quhead_freight := COALESCE(NEW.quhead_freight,0); NEW.quhead_custponumber := COALESCE(NEW.quhead_custponumber,''); NEW.quhead_ordercomments := COALESCE(NEW.quhead_ordercomments,''); NEW.quhead_shipcomments := COALESCE(NEW.quhead_shipcomments,''); NEW.quhead_shiptophone := COALESCE(NEW.quhead_shiptophone,''); NEW.quhead_misc := COALESCE(NEW.quhead_misc,0); NEW.quhead_misc_descrip := COALESCE(NEW.quhead_misc_descrip,''); IF ((NEW.quhead_warehous_id IS NULL) OR (NEW.quhead_fob IS NULL)) THEN IF (NEW.quhead_warehous_id IS NULL) THEN SELECT warehous_id,warehous_fob INTO _w FROM usrpref, whsinfo WHERE ((warehous_id=CAST(usrpref_value AS INTEGER)) AND (warehous_shipping) AND (warehous_active) AND (usrpref_username=getEffectiveXtUser()) AND (usrpref_name='PreferredWarehouse')); ELSE SELECT warehous_id,warehous_fob INTO _w FROM whsinfo WHERE (warehous_id=NEW.quhead_warehous_id); END IF; IF (FOUND) THEN NEW.quhead_warehous_id := COALESCE(NEW.quhead_warehous_id,_w.warehous_id); NEW.quhead_fob := COALESCE(NEW.quhead_fob,_w.warehous_fob); END IF; END IF; END IF; --Auto create project if applicable IF ((TG_OP = 'INSERT') AND (COALESCE(NEW.quhead_prj_id,-1)=-1)) THEN SELECT fetchMetricBool('AutoCreateProjectsForOrders') INTO _check; IF (_check) THEN SELECT NEXTVAL('prj_prj_id_seq') INTO _prjId; NEW.quhead_prj_id := _prjId; INSERT INTO prj (prj_id, prj_number, prj_name, prj_descrip, prj_status, prj_so, prj_wo, prj_po, prj_owner_username, prj_start_date, prj_due_date, prj_assigned_date, prj_completed_date, prj_username, prj_recurring_prj_id, prj_crmacct_id, prj_cntct_id, prj_prjtype_id) SELECT _prjId, NEW.quhead_number, NEW.quhead_number, 'Auto Generated Project from Quote.', 'O', TRUE, TRUE, TRUE, getEffectiveXTUser(), NEW.quhead_quotedate, NEW.quhead_packdate, NEW.quhead_quotedate, NULL, getEffectiveXTUser(), NULL, crmacct_id, NEW.quhead_billto_cntct_id, NULL FROM crmacct WHERE (crmacct_cust_id=NEW.quhead_cust_id) OR (crmacct_prospect_id=NEW.quhead_cust_id) LIMIT 1; END IF; END IF; -- Deal with Billing Address IF (TG_OP = 'INSERT') THEN IF (_p.cust_ffbillto) THEN -- If they didn't supply data, we'll put in the bill to address NEW.quhead_billtoname=COALESCE(NEW.quhead_billtoname,_p.cust_name,''); NEW.quhead_billtoaddress1=COALESCE(NEW.quhead_billtoaddress1,_p.addr_line1,''); NEW.quhead_billtoaddress2=COALESCE(NEW.quhead_billtoaddress2,_p.addr_line2,''); NEW.quhead_billtoaddress3=COALESCE(NEW.quhead_billtoaddress3,_p.addr_line3,''); NEW.quhead_billtocity=COALESCE(NEW.quhead_billtocity,_p.addr_city,''); NEW.quhead_billtostate=COALESCE(NEW.quhead_billtostate,_p.addr_state,''); NEW.quhead_billtozip=COALESCE(NEW.quhead_billtozip,_p.addr_postalcode,''); NEW.quhead_billtocountry=COALESCE(NEW.quhead_billtocountry,_p.addr_country,''); ELSE -- Free form not allowed, we're going to put in the address regardless NEW.quhead_billtoname=COALESCE(_p.cust_name,''); NEW.quhead_billtoaddress1=COALESCE(_p.addr_line1,''); NEW.quhead_billtoaddress2=COALESCE(_p.addr_line2,''); NEW.quhead_billtoaddress3=COALESCE(_p.addr_line3,''); NEW.quhead_billtocity=COALESCE(_p.addr_city,''); NEW.quhead_billtostate=COALESCE(_p.addr_state,''); NEW.quhead_billtozip=COALESCE(_p.addr_postalcode,''); NEW.quhead_billtocountry=COALESCE(_p.addr_country,''); END IF; END IF; -- Now let's look at Shipto Address -- If there's nothing in the address fields and there is a shipto id -- or there is a default address available, let's put in some shipto address data IF ((TG_OP = 'INSERT') AND NOT ((NEW.quhead_shipto_id IS NULL) AND NOT _p.cust_ffshipto) AND (NEW.quhead_shiptoname IS NULL) AND (NEW.quhead_shiptoaddress1 IS NULL) AND (NEW.quhead_shiptoaddress2 IS NULL) AND (NEW.quhead_shiptoaddress3 IS NULL) AND (NEW.quhead_shiptocity IS NULL) AND (NEW.quhead_shiptostate IS NULL) AND (NEW.quhead_shiptocountry IS NULL)) THEN IF ((NEW.quhead_shipto_id IS NULL) AND (_p.shipto_id IS NOT NULL)) THEN _shiptoId := _p.shipto_addr_id; ELSE _shiptoId := NEW.quhead_shipto_id; END IF; SELECT * INTO _a FROM shiptoinfo, addr WHERE ((shipto_id=_shiptoId) AND (addr_id=shipto_addr_id)); NEW.quhead_shiptoname := COALESCE(_p.shipto_name,''); NEW.quhead_shiptoaddress1 := COALESCE(_a.addr_line1,''); NEW.quhead_shiptoaddress2 := COALESCE(_a.addr_line2,''); NEW.quhead_shiptoaddress3 := COALESCE(_a.addr_line3,''); NEW.quhead_shiptocity := COALESCE(_a.addr_city,''); NEW.quhead_shiptostate := COALESCE(_a.addr_state,''); NEW.quhead_shiptozipcode := COALESCE(_a.addr_postalcode,''); NEW.quhead_shiptocountry := COALESCE(_a.addr_country,''); ELSE IF (_p.cust_ffshipto) THEN -- Use Address Save function to see if the new address entered matches -- data for the shipto number. If not that will insert new address for CRM SELECT SaveAddr( NULL, NULL, NEW.quhead_shiptoaddress1, NEW.quhead_shiptoaddress2, NEW.quhead_shiptoaddress3, NEW.quhead_shiptocity, NEW.quhead_shiptostate, NEW.quhead_shiptozipcode, NEW.quhead_shiptocountry, 'CHANGEONE') INTO _addrId; SELECT shipto_addr_id INTO _shiptoid FROM shiptoinfo WHERE (shipto_id=NEW.quhead_shipto_id); -- If the address passed doesn't match shipto address, then it's something else IF (_shiptoid <> _addrId) THEN NEW.quhead_shipto_id := NULL; END IF; ELSE SELECT quhead_shipto_id INTO _shiptoid FROM quhead WHERE (quhead_id=NEW.quhead_id); -- Get the shipto address IF (COALESCE(NEW.quhead_shipto_id,-1) <> COALESCE(_shiptoid,-1)) THEN SELECT * INTO _a FROM shiptoinfo LEFT OUTER JOIN cntct ON (shipto_cntct_id=cntct_id) LEFT OUTER JOIN addr ON (shipto_addr_id=addr_id) WHERE (shipto_id=NEW.quhead_shipto_id); IF (FOUND) THEN -- Free form not allowed so we're going to make sure address matches Shipto data NEW.quhead_shiptoname := COALESCE(_a.shipto_name,''); NEW.quhead_shiptophone := COALESCE(_a.cntct_phone,''); NEW.quhead_shiptoaddress1 := COALESCE(_a.addr_line1,''); NEW.quhead_shiptoaddress2 := COALESCE(_a.addr_line2,''); NEW.quhead_shiptoaddress3 := COALESCE(_a.addr_line3,''); NEW.quhead_shiptocity := COALESCE(_a.addr_city,''); NEW.quhead_shiptostate := COALESCE(_a.addr_state,''); NEW.quhead_shiptozipcode := COALESCE(_a.addr_postalcode,''); NEW.quhead_shiptocountry := COALESCE(_a.addr_country,''); ELSE -- If no shipto data and free form not allowed, this won't work RAISE EXCEPTION 'Free form Shipto is not allowed on this Customer. You must supply a valid Shipto ID.'; END IF; END IF; END IF; END IF; END IF; END IF; IF ( SELECT (metric_value='t') FROM metric WHERE (metric_name='SalesOrderChangeLog') ) THEN -- Cache the cmnttype_id for ChangeLog SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (FOUND) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'Q', NEW.quhead_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.quhead_terms_id <> NEW.quhead_terms_id) THEN PERFORM postComment( _cmnttypeid, 'Q', NEW.quhead_id, ('Terms Changed from "' || oldterms.terms_code || '" to "' || newterms.terms_code || '"') ) FROM terms AS oldterms, terms AS newterms WHERE ( (oldterms.terms_id=OLD.quhead_terms_id) AND (newterms.terms_id=NEW.quhead_terms_id) ); END IF; ELSIF (TG_OP = 'DELETE') THEN DELETE FROM comment WHERE ( (comment_source='Q') AND (comment_source_id=OLD.quhead_id) ); END IF; END IF; END IF; IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END; $$; ALTER FUNCTION public._quheadtrigger() OWNER TO admin; -- -- Name: _quitemafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _quitemafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'QI' AND charass_target_id = OLD.quitem_id; RETURN OLD; END; $$; ALTER FUNCTION public._quitemafterdeletetrigger() OWNER TO admin; -- -- Name: _quitemaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _quitemaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check NUMERIC; BEGIN --If auto calculate freight, recalculate quhead_freight IF (SELECT quhead_calcfreight FROM quhead WHERE (quhead_id=NEW.quitem_quhead_id)) THEN UPDATE quhead SET quhead_freight = (SELECT SUM(freightdata_total) FROM freightDetail('QU', quhead_id, quhead_cust_id, quhead_shipto_id, quhead_quotedate, quhead_shipvia, quhead_curr_id)) WHERE quhead_id=NEW.quitem_quhead_id; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._quitemaftertrigger() OWNER TO admin; -- -- Name: _quitembeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _quitembeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check NUMERIC; _itemNumber TEXT; BEGIN -- Check IF (NEW.quitem_scheddate IS NULL) THEN RAISE EXCEPTION 'A schedule date is required.'; END IF; -- If this is imported, go ahead and insert default characteristics IF ((TG_OP = 'INSERT') AND NEW.quitem_imported) THEN PERFORM updateCharAssignment('SI', NEW.quitem_id, char_id, charass_value) FROM ( SELECT DISTINCT char_id, char_name, charass_value FROM charass, char, itemsite, item WHERE ((itemsite_id=NEW.quitem_itemsite_id) AND (itemsite_item_id=item_id) AND (charass_target_type='I') AND (charass_target_id=item_id) AND (charass_default) AND (char_id=charass_char_id)) ORDER BY char_name) AS data; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._quitembeforetrigger() OWNER TO admin; -- -- Name: _quitemtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _quitemtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _changelog BOOLEAN := FALSE; _check BOOLEAN; BEGIN -- Checks SELECT checkPrivilege('MaintainQuotes') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to maintain Quotes.'; END IF; IF ( SELECT fetchMetricBool('SalesOrderChangeLog') ) THEN _changelog := TRUE; END IF; IF (TG_OP = 'INSERT') THEN IF (_changelog) THEN PERFORM postComment('ChangeLog', 'QI', NEW.quitem_id, 'Created'); END IF; RETURN NEW; END IF; IF (TG_OP = 'DELETE') THEN DELETE FROM comment WHERE ( (comment_source='QI') AND (comment_source_id=OLD.quitem_id) ); DELETE FROM charass WHERE ((charass_target_type='QI') AND (charass_target_id=OLD.quitem_id)); RETURN OLD; END IF; IF (TG_OP = 'UPDATE') THEN IF (_changelog) THEN IF (NEW.quitem_qtyord <> OLD.quitem_qtyord) THEN PERFORM postComment( 'ChangeLog', 'QI', NEW.quitem_id, ( 'Changed Qty. Ordered from ' || formatQty(OLD.quitem_qtyord) || ' to ' || formatQty(NEW.quitem_qtyord) ) ); END IF; IF (NEW.quitem_price <> OLD.quitem_price) THEN PERFORM postComment( 'ChangeLog', 'QI', NEW.quitem_id, ( 'Changed Unit Price from ' || formatPrice(OLD.quitem_price) || ' to ' || formatPrice(NEW.quitem_price) ) ); END IF; IF (NEW.quitem_scheddate <> OLD.quitem_scheddate) THEN PERFORM postComment( 'ChangeLog', 'QI', NEW.quitem_id, ( 'Changed Sched. Date from ' || formatDate(OLD.quitem_scheddate) || ' to ' || formatDate(NEW.quitem_scheddate)) ); END IF; END IF; END IF; -- NEW.quitem_lastupdated = CURRENT_TIMESTAMP; RETURN NEW; END; $$; ALTER FUNCTION public._quitemtrigger() OWNER TO admin; -- -- Name: _recuraftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _recuraftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _parentid INTEGER; _parenttype TEXT; BEGIN IF (TG_OP = 'DELETE') THEN IF (UPPER(OLD.recur_parent_type) = 'TODO') THEN UPDATE todoitem SET todoitem_recurring_todoitem_id=NULL WHERE (todoitem_recurring_todoitem_id=OLD.recur_parent_id); END IF; RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._recuraftertrigger() OWNER TO admin; -- -- Name: _reporttrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _reporttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN NEW.report_loaddate = CURRENT_TIMESTAMP; RETURN NEW; END; $$; ALTER FUNCTION public._reporttrigger() OWNER TO admin; -- -- Name: _salesrepafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _salesrepafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN IF (SELECT fetchMetricValue('DefaultSalesRep') = OLD.salesrep_id) THEN RAISE EXCEPTION 'Cannot delete the default Sales Rep [xtuple: salesrep, -1, %]', OLD.salesrep_number; END IF; PERFORM postComment('ChangeLog', 'SR', OLD.salesrep_id, 'Deleted "' || OLD.salesrep_number || '"'); RETURN OLD; END; $$; ALTER FUNCTION public._salesrepafterdeletetrigger() OWNER TO admin; -- -- Name: _salesrepaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _salesrepaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF (TG_OP = 'INSERT') THEN -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE LOOP UPDATE crmacct SET crmacct_salesrep_id=NEW.salesrep_id, crmacct_name=NEW.salesrep_name WHERE crmacct_number=NEW.salesrep_number; IF (FOUND) THEN EXIT; END IF; BEGIN INSERT INTO crmacct(crmacct_number, crmacct_name, crmacct_active, crmacct_type, crmacct_salesrep_id ) VALUES (NEW.salesrep_number, NEW.salesrep_name, NEW.salesrep_active, 'I', NEW.salesrep_id); EXIT; EXCEPTION WHEN unique_violation THEN -- do nothing, and loop to try the UPDATE again END; END LOOP; -- TODO: default characteristic assignments? ELSIF (TG_OP = 'UPDATE') THEN UPDATE crmacct SET crmacct_number = NEW.salesrep_number WHERE ((crmacct_salesrep_id=NEW.salesrep_id) AND (crmacct_number!=NEW.salesrep_number)); UPDATE crmacct SET crmacct_name = NEW.salesrep_name WHERE ((crmacct_salesrep_id=NEW.salesrep_id) AND (crmacct_name!=NEW.salesrep_name)); END IF; IF (fetchMetricBool('SalesRepChangeLog')) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment('ChangeLog', 'SR', NEW.salesrep_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.salesrep_active <> NEW.salesrep_active) THEN PERFORM postComment('ChangeLog', 'SR', NEW.salesrep_id, CASE WHEN NEW.salesrep_active THEN 'Activated' ELSE 'Deactivated' END); END IF; IF (OLD.salesrep_number <> NEW.salesrep_number) THEN PERFORM postComment('ChangeLog', 'SR', NEW.salesrep_id, 'Number changed from "' || OLD.salesrep_number || '" to "' || NEW.salesrep_number || '"'); END IF; IF (OLD.salesrep_name <> NEW.salesrep_name) THEN PERFORM postComment('ChangeLog', 'SR', NEW.salesrep_id, 'Name changed from "' || OLD.salesrep_name || '" to "' || NEW.salesrep_name || '"'); END IF; IF (OLD.salesrep_commission <> NEW.salesrep_commission) THEN PERFORM postComment('ChangeLog', 'SR', NEW.salesrep_id, 'Commission changed from "' || OLD.salesrep_commission || '" to "' || NEW.salesrep_commission || '"'); END IF; IF (OLD.salesrep_method <> NEW.salesrep_method) THEN PERFORM postComment('ChangeLog', 'SR', NEW.salesrep_id, 'Method changed from "' || OLD.salesrep_method || '" to "' || NEW.salesrep_method || '"'); END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._salesrepaftertrigger() OWNER TO admin; -- -- Name: _salesrepbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _salesrepbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF NOT (checkPrivilege('MaintainSalesReps')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Sales Reps.'; END IF; IF (TG_OP IN ('INSERT', 'UPDATE')) THEN IF (NEW.salesrep_number IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Sales Rep Number.'; END IF; IF (NEW.salesrep_commission IS NULL) THEN RAISE EXCEPTION 'You must supply a Commission Rate for this Sales Rep.'; END IF; IF (TG_OP = 'INSERT' AND fetchMetricText('CRMAccountNumberGeneration') IN ('A','O') AND isNumeric(NEW.salesrep_number)) THEN --- clear the number from the issue cache PERFORM clearNumberIssue('CRMAccountNumber', NEW.salesrep_number); END IF; NEW.salesrep_number = UPPER(NEW.salesrep_number); -- deprecated column salesrep_emp_id -- TODO: will this prevent breaking the crmacct-emp relationship? IF (TG_OP = 'UPDATE') THEN SELECT crmacct_emp_id INTO NEW.salesrep_emp_id FROM crmacct WHERE crmacct_salesrep_id = NEW.salesrep_id; END IF; ELSIF (TG_OP = 'DELETE') THEN UPDATE crmacct SET crmacct_salesrep_id = NULL WHERE crmacct_salesrep_id = OLD.salesrep_id; RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._salesrepbeforetrigger() OWNER TO admin; -- -- Name: _saletypeaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _saletypeaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- If this Sale Type is marked "default" set all others to not default IF (NEW.saletype_default) THEN UPDATE saletype SET saletype_default = false WHERE saletype_id <> NEW.saletype_id; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._saletypeaftertrigger() OWNER TO admin; -- -- Name: _saletypebeforedeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _saletypebeforedeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check TEXT; BEGIN -- Check to see if any sales orders are assigned to the passed saletype SELECT cohead_number INTO _check FROM cohead WHERE (cohead_saletype_id=OLD.saletype_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Assigned to Sales Order % and possibly more. [xtuple: deletesaletype, -1]', _check; END IF; -- Check to see if any quotes are assigned to the passed saletype SELECT quhead_number INTO _check FROM quhead WHERE (quhead_saletype_id=OLD.saletype_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Assigned to Quote % and possibly more. [xtuple: deletesaletype, -2]', _check; END IF; -- Check to see if any invoice are assigned to the passed saletype SELECT invchead_invcnumber INTO _check FROM invchead WHERE (invchead_saletype_id=OLD.saletype_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Assigned to Invoice % and possibly more. [xtuple: deletesaletype, -3]', _check; END IF; -- Check to see if any credit memos are assigned to the passed saletype SELECT cmhead_number INTO _check FROM cmhead WHERE (cmhead_saletype_id=OLD.saletype_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Assigned to Credit Memo % and possibly more. [xtuple: deletesaletype, -4]', _check; END IF; -- Check to see if any return ruthorizations are assigned to the passed saletype IF (fetchMetricBool('EnableReturnAuth')) THEN SELECT rahead_number INTO _check FROM rahead WHERE (rahead_saletype_id=OLD.saletype_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Assigned to Return Authorization % and possibly more returns. [xtuple: deleteSaleType, -5]', _check; END IF; END IF; RETURN OLD; END; $$; ALTER FUNCTION public._saletypebeforedeletetrigger() OWNER TO admin; -- -- Name: _shipdatasumtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _shipdatasumtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (LENGTH(TRIM(NEW.shipdatasum_shiphead_number)) = 0) THEN NEW.shipdatasum_shiphead_number = NULL; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._shipdatasumtrigger() OWNER TO admin; -- -- Name: _shipdatatrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _shipdatatrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _newShipdata_cohead_number INTEGER; _shipdatasum_shipper TEXT; _rows INTEGER; _cohead_id INTEGER; _shiphead_number TEXT; _headcount INTEGER; BEGIN -- This is where the shipper is identified and may need to be changed NEW.shipdata_cohead_number := TRIM(NEW.shipdata_cohead_number); IF (substring(NEW.shipdata_cosmisc_tracknum from 1 for 2) = '1Z') THEN _shipdatasum_shipper := 'UPS'; ELSE _shipdatasum_shipper := 'UNKNOWN'; END IF; IF (LENGTH(TRIM(NEW.shipdata_shiphead_number)) = 0) THEN NEW.shipdata_shiphead_number := NULL; END IF; IF (NEW.shipdata_cosmisc_tracknum = NEW.shipdata_cosmisc_packnum_tracknum) THEN IF (NEW.shipdata_void_ind = 'Y') THEN -- Delete the current shipdatasum DELETE FROM shipdatasum WHERE ((shipdatasum_cohead_number = NEW.shipdata_cohead_number) AND (shipdatasum_cosmisc_tracknum = NEW.shipdata_cosmisc_tracknum)); ELSIF (TG_OP = 'INSERT') THEN -- RAISE NOTICE 'Getting cohead_id (%)', NEW.shipdata_cohead_number; IF (NEW.shipdata_shiphead_number IS NULL) THEN SELECT cohead_id INTO _cohead_id FROM cohead WHERE cohead_number = NEW.shipdata_cohead_number; IF (FOUND) THEN -- RAISE NOTICE 'Getting shiphead number (%)', _cohead_id; SELECT count(shiphead_order_id), MAX(shiphead_number) INTO _headcount, _shiphead_number FROM shiphead WHERE ((shiphead_tracknum IS NULL OR shiphead_tracknum = '') AND ( shiphead_order_type = 'SO' and shiphead_order_id = _cohead_id) ); IF (_headcount = 1) THEN -- RAISE NOTICE 'Updating Shiphead Number (%)', _shiphead_number; NEW.shipdata_shiphead_number = _shiphead_number; ELSIF (_headcount > 1) THEN -- Trap for potential workflow problem. Can only infer shiphead from sales order number -- if shipping one at a time RAISE EXCEPTION 'Multiple shipments exist for this order. Please provide a specific a shipment number.'; END IF; END IF; END IF; INSERT INTO shipdatasum (shipdatasum_cohead_number, shipdatasum_cosmisc_tracknum, shipdatasum_cosmisc_packnum_tracknum, shipdatasum_weight, shipdatasum_base_freight, shipdatasum_total_freight, shipdatasum_base_freight_curr_id, shipdatasum_total_freight_curr_id, shipdatasum_shipper, shipdatasum_billing_option, shipdatasum_package_type, shipdatasum_shiphead_number) VALUES (NEW.shipdata_cohead_number, NEW.shipdata_cosmisc_tracknum, NEW.shipdata_cosmisc_packnum_tracknum, NEW.shipdata_weight, NEW.shipdata_base_freight, NEW.shipdata_total_freight, NEW.shipdata_base_freight_curr_id, NEW.shipdata_total_freight_curr_id, _shipdatasum_shipper, NEW.shipdata_billing_option, NEW.shipdata_package_type, NEW.shipdata_shiphead_number); ELSIF (TG_OP = 'UPDATE') THEN UPDATE shipdatasum SET shipdatasum_cohead_number=NEW.shipdata_cohead_number, shipdatasum_cosmisc_tracknum=NEW.shipdata_cosmisc_tracknum, shipdatasum_cosmisc_packnum_tracknum=NEW.shipdata_cosmisc_packnum_tracknum, shipdatasum_weight=NEW.shipdata_weight, shipdatasum_base_freight=NEW.shipdata_base_freight, shipdatasum_total_freight=NEW.shipdata_total_freight, shipdatasum_base_freight_curr_id=NEW.shipdata_base_freight_curr_id, shipdatasum_total_freight_curr_id=NEW.shipdata_total_freight_curr_id, shipdatasum_shipper=_shipdatasum_shipper, shipdatasum_billing_option=NEW.shipdata_billing_option, shipdatasum_package_type=NEW.shipdata_package_type, shipdatasum_shiphead_number=NEW.shipdata_shiphead_number WHERE ((TRIM(shipdatasum_cohead_number)=TRIM(OLD.shipdata_cohead_number)) AND (TRIM(shipdatasum_cosmisc_tracknum)=TRIM(OLD.shipdata_cosmisc_tracknum)) AND (TRIM(shipdatasum_cosmisc_packnum_tracknum)=TRIM(OLD.shipdata_cosmisc_packnum_tracknum))); GET DIAGNOSTICS _rows = ROW_COUNT; IF (_rows <= 0) THEN INSERT INTO shipdatasum (shipdatasum_cohead_number, shipdatasum_cosmisc_tracknum, shipdatasum_cosmisc_packnum_tracknum, shipdatasum_weight, shipdatasum_base_freight, shipdatasum_total_freight, shipdatasum_base_freight_curr_id, shipdatasum_total_freight_curr_id, shipdatasum_shipper, shipdatasum_billing_option, shipdatasum_package_type, shipdatasum_shiphead_number) VALUES (NEW.shipdata_cohead_number, NEW.shipdata_cosmisc_tracknum, NEW.shipdata_cosmisc_packnum_tracknum, NEW.shipdata_weight, NEW.shipdata_base_freight, NEW.shipdata_total_freight, NEW.shipdata_base_freight_curr_id, NEW.shipdata_total_freight_curr_id, _shipdatasum_shipper, NEW.shipdata_billing_option, NEW.shipdata_package_type, NEW.shipdata_shiphead_number); END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._shipdatatrigger() OWNER TO admin; -- -- Name: _shipformafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _shipformafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (fetchMetricValue('DefaultShipFormId') = OLD.shipform_id) THEN RAISE EXCEPTION 'Cannot delete the default Shipping Form [xtuple: shipform, -1, %, %]', OLD.shipform_name, OLD.shipform_report_name; END IF; RETURN OLD; END; $$; ALTER FUNCTION public._shipformafterdeletetrigger() OWNER TO admin; -- -- Name: _shipheadbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _shipheadbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF ((TG_OP = 'INSERT') OR (TG_OP = 'UPDATE')) THEN IF (NEW.shiphead_order_type = 'SO' AND NEW.shiphead_order_id IN (SELECT cohead_id FROM cohead)) THEN RETURN NEW; ELSEIF (NEW.shiphead_order_type = 'TO' AND NEW.shiphead_order_id IN (SELECT tohead_id FROM tohead)) THEN RETURN NEW; END IF; RAISE EXCEPTION '% with id % does not exist', NEW.shiphead_order_type, NEW.shiphead_order_id; RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._shipheadbeforetrigger() OWNER TO admin; -- -- Name: _shiptoinfoaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _shiptoinfoaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; BEGIN IF (NEW.shipto_default) THEN UPDATE shiptoinfo SET shipto_default = false WHERE ((shipto_cust_id=NEW.shipto_cust_id) AND (shipto_id <> NEW.shipto_id)); END IF; IF (SELECT fetchMetricBool('CustomerChangeLog')) THEN -- Cache the cmnttype_id for ChangeLog SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (FOUND) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'C', NEW.shipto_cust_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.shipto_name <> NEW.shipto_name) THEN PERFORM postComment( _cmnttypeid, 'C', NEW.shipto_cust_id, ( NEW.shipto_name || ': Ship To Name Changed from "' || COALESCE(OLD.shipto_name, '') || '" to "' || COALESCE(NEW.shipto_name, '') || '"' ) ); END IF; IF (OLD.shipto_shipvia <> NEW.shipto_shipvia) THEN PERFORM postComment( _cmnttypeid, 'C', NEW.shipto_cust_id, ( NEW.shipto_name || ': Ship To ShipVia Changed from "' || COALESCE(OLD.shipto_shipvia, '') || '" to "' || COALESCE(NEW.shipto_shipvia, '') || '"' ) ); END IF; IF (COALESCE(OLD.shipto_taxzone_id, -1) <> COALESCE(NEW.shipto_taxzone_id, -1)) THEN PERFORM postComment( _cmnttypeid, 'C', NEW.shipto_cust_id, ( NEW.shipto_name || ': Ship To Tax Zone Changed from "' || COALESCE((SELECT taxzone_code FROM taxzone WHERE taxzone_id=OLD.shipto_taxzone_id), 'None') || '" to "' || COALESCE((SELECT taxzone_code FROM taxzone WHERE taxzone_id=NEW.shipto_taxzone_id), 'None') || '"' ) ); END IF; IF (OLD.shipto_shipzone_id <> NEW.shipto_shipzone_id) THEN PERFORM postComment( _cmnttypeid, 'C', NEW.shipto_cust_id, ( NEW.shipto_name || ': Ship To Shipping Zone Changed from "' || (SELECT shipzone_name FROM shipzone WHERE shipzone_id=OLD.shipto_shipzone_id) || '" to "' || (SELECT shipzone_name FROM shipzone WHERE shipzone_id=NEW.shipto_shipzone_id) || '"' ) ); END IF; IF (OLD.shipto_salesrep_id <> NEW.shipto_salesrep_id) THEN PERFORM postComment( _cmnttypeid, 'C', NEW.shipto_cust_id, ( NEW.shipto_name || ': Ship To Sales Rep Changed from "' || (SELECT salesrep_name FROM salesrep WHERE salesrep_id=OLD.shipto_salesrep_id) || '" to "' || (SELECT salesrep_name FROM salesrep WHERE salesrep_id=NEW.shipto_salesrep_id) || '"' ) ); END IF; IF (OLD.shipto_active <> NEW.shipto_active) THEN IF (NEW.shipto_active) THEN PERFORM postComment(_cmnttypeid, 'C', NEW.shipto_cust_id, (NEW.shipto_name || ': Ship To Activated')); ELSE PERFORM postComment(_cmnttypeid, 'C', NEW.shipto_cust_id, (NEW.shipto_name || ': Ship To Deactivated')); END IF; END IF; END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._shiptoinfoaftertrigger() OWNER TO admin; -- -- Name: _shipviaafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _shipviaafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (SELECT fetchMetricValue('DefaultShipViaId') = OLD.shipvia_id) THEN RAISE EXCEPTION 'Cannot delete the default Ship-Via [xtuple: shipvia, -1, %]', OLD.shipvia_code; END IF; RETURN OLD; END; $$; ALTER FUNCTION public._shipviaafterdeletetrigger() OWNER TO admin; -- -- Name: _sltransaltertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _sltransaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _externalCompany BOOLEAN := false; _updated BOOLEAN := false; BEGIN IF(TG_OP='DELETE') THEN RAISE EXCEPTION 'You may not delete Journal Transactions once they have been created.'; ELSIF (TG_OP = 'UPDATE') THEN IF(OLD.sltrans_id != NEW.sltrans_id) THEN _updated := true; ELSIF(OLD.sltrans_date != NEW.sltrans_date) THEN _updated := true; ELSIF(OLD.sltrans_accnt_id != NEW.sltrans_accnt_id) THEN _updated := true; ELSIF(OLD.sltrans_amount != NEW.sltrans_amount) THEN _updated := true; ELSIF(OLD.sltrans_username != NEW.sltrans_username) THEN _updated := true; ELSIF( (OLD.sltrans_sequence IS NULL AND NEW.sltrans_sequence IS NOT NULL) OR (OLD.sltrans_sequence IS NOT NULL AND NEW.sltrans_sequence IS NULL) OR (COALESCE(OLD.sltrans_sequence,0) != COALESCE(NEW.sltrans_sequence,0)) ) THEN _updated := true; ELSIF( (OLD.sltrans_created IS NULL AND NEW.sltrans_created IS NOT NULL) OR (OLD.sltrans_created IS NOT NULL AND NEW.sltrans_created IS NULL) OR (COALESCE(OLD.sltrans_created,now()) != COALESCE(NEW.sltrans_created,now())) ) THEN _updated := true; ELSIF( (OLD.sltrans_source IS NULL AND NEW.sltrans_source IS NOT NULL) OR (OLD.sltrans_source IS NOT NULL AND NEW.sltrans_source IS NULL) OR (COALESCE(OLD.sltrans_source,'') != COALESCE(NEW.sltrans_source,'')) ) THEN _updated := true; ELSIF( (OLD.sltrans_docnumber IS NULL AND NEW.sltrans_docnumber IS NOT NULL) OR (OLD.sltrans_docnumber IS NOT NULL AND NEW.sltrans_docnumber IS NULL) OR (COALESCE(OLD.sltrans_docnumber,'') != COALESCE(NEW.sltrans_docnumber,'')) ) THEN _updated := true; ELSIF( (OLD.sltrans_doctype IS NULL AND NEW.sltrans_doctype IS NOT NULL) OR (OLD.sltrans_doctype IS NOT NULL AND NEW.sltrans_doctype IS NULL) OR (COALESCE(OLD.sltrans_doctype,'') != COALESCE(NEW.sltrans_doctype,'')) ) THEN _updated := true; END IF; IF(_updated) THEN RAISE EXCEPTION 'You may not alter some Journal Transaction fields once they have been created.'; END IF; ELSE RAISE EXCEPTION 'trigger for sltrans table called in unexpected state.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._sltransaltertrigger() OWNER TO admin; -- -- Name: _sltransinserttrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _sltransinserttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _reqNotes BOOLEAN; _externalCompany BOOLEAN := false; BEGIN -- Checks SELECT company_external INTO _externalCompany FROM company JOIN accnt ON (company_number=accnt_company) WHERE (accnt_id=NEW.sltrans_accnt_id); IF (_externalCompany) THEN RAISE EXCEPTION 'Transactions are not allowed for G/L Accounts with External Company segments.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._sltransinserttrigger() OWNER TO admin; -- -- Name: _soheadtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _soheadtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _p RECORD; _a RECORD; _w RECORD; _shiptoId INTEGER; _addrId INTEGER; _prjId INTEGER; _check BOOLEAN; _numGen CHAR(1); BEGIN -- Checks -- Start with privileges IF (TG_OP = 'INSERT') THEN IF ( (NOT checkPrivilege('MaintainSalesOrders')) AND (NOT checkPrivilege('EnterReceipts')) ) THEN RAISE EXCEPTION 'You do not have privileges to create a Sales Order.'; END IF; ELSIF (TG_OP = 'UPDATE') THEN IF ( (NOT checkPrivilege('MaintainSalesOrders')) AND (NOT checkPrivilege('IssueStockToShipping')) AND (NEW.cohead_holdtype = OLD.cohead_holdtype) ) THEN RAISE EXCEPTION 'You do not have privileges to alter a Sales Order.'; END IF; ELSE IF ( (NOT checkPrivilege('MaintainSalesOrders')) AND (NOT checkPrivilege('IssueStockToShipping')) ) THEN RAISE EXCEPTION 'You do not have privileges to alter a Sales Order.'; END IF; END IF; -- If this is imported, check the order number IF (TG_OP = 'INSERT') THEN IF (NEW.cohead_imported) THEN SELECT fetchMetricText('CONumberGeneration') INTO _numGen; IF ((NEW.cohead_number IS NULL) AND (_numGen='M')) THEN RAISE EXCEPTION 'You must supply an Order Number.'; ELSE IF (NEW.cohead_number IS NULL) THEN SELECT fetchsonumber() INTO NEW.cohead_number; END IF; END IF; END IF; IF (fetchMetricText('CONumberGeneration') IN ('A','O')) THEN --- clear the number from the issue cache PERFORM clearNumberIssue('SoNumber', NEW.cohead_number); END IF; ELSE IF (TG_OP = 'UPDATE') THEN IF (NEW.cohead_number <> OLD.cohead_number) THEN RAISE EXCEPTION 'The order number may not be changed.'; END IF; END IF; END IF; IF (TG_OP IN ('INSERT','UPDATE')) THEN -- Get Customer data IF (NEW.cohead_shipto_id IS NULL) THEN SELECT cust_creditstatus,cust_number,cust_usespos,cust_blanketpos,cust_ffbillto, cust_ffshipto,cust_name,cust_salesrep_id,cust_terms_id,cust_shipvia, cust_shipchrg_id,cust_shipform_id,cust_commprcnt,cust_curr_id,cust_taxzone_id, cntct.*,addr.*, shipto_id,shipto_addr_id,shipto_name,shipto_salesrep_id,shipto_shipvia, shipto_shipchrg_id,shipto_shipform_id,shipto_commission,shipto_taxzone_id INTO _p FROM custinfo LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) LEFT OUTER JOIN shiptoinfo ON ((cust_id=shipto_cust_id) AND shipto_default) WHERE (cust_id=NEW.cohead_cust_id); ELSE SELECT cust_creditstatus,cust_number,cust_usespos,cust_blanketpos,cust_ffbillto, cust_ffshipto,cust_name,cust_salesrep_id,cust_terms_id,cust_shipvia, cust_shipchrg_id,cust_shipform_id,cust_commprcnt,cust_curr_id,cust_taxzone_id, cntct.*,addr.*, shipto_id,shipto_addr_id,shipto_name,shipto_salesrep_id,shipto_shipvia, shipto_shipchrg_id,shipto_shipform_id,shipto_commission,shipto_taxzone_id INTO _p FROM shiptoinfo,custinfo LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) WHERE ((cust_id=NEW.cohead_cust_id) AND (shipto_id=NEW.cohead_shipto_id)); END IF; -- If there is customer data, then we can get to work IF (FOUND) THEN -- Check Credit IF (TG_OP = 'INSERT') THEN IF (_p.cust_creditstatus = 'H') THEN SELECT checkPrivilege('CreateSOForHoldCustomer') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'Customer % has been placed on a Credit Hold and you do not have privilege to create Sales Orders for Customers on Credit Hold. The selected Customer must be taken off of Credit Hold before you may create a new Sales Order for the Customer.',_p.cust_number; ELSE NEW.cohead_holdtype='C'; END IF; END IF; IF (_p.cust_creditstatus = 'W') THEN SELECT checkPrivilege('CreateSOForWarnCustomer') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'Customer % has been placed on a Credit Warning and you do not have privilege to create Sales Orders for Customers on Credit Warning. The selected Customer must be taken off of Credit Warning before you may create a new Sales Order for the Customer.',_p.cust_number; ELSE NEW.cohead_holdtype='C'; END IF; END IF; -- Set to defaults if values not provided NEW.cohead_shipto_id := COALESCE(NEW.cohead_shipto_id,_p.shipto_id); NEW.cohead_terms_id := COALESCE(NEW.cohead_terms_id,_p.cust_terms_id); NEW.cohead_orderdate := COALESCE(NEW.cohead_orderdate,current_date); NEW.cohead_packdate := COALESCE(NEW.cohead_packdate,NEW.cohead_orderdate); NEW.cohead_curr_id := COALESCE(NEW.cohead_curr_id,_p.cust_curr_id,basecurrid()); NEW.cohead_freight := COALESCE(NEW.cohead_freight,0); NEW.cohead_custponumber := COALESCE(NEW.cohead_custponumber,''); NEW.cohead_ordercomments := COALESCE(NEW.cohead_ordercomments,''); NEW.cohead_shipcomments := COALESCE(NEW.cohead_shipcomments,''); NEW.cohead_shiptophone := COALESCE(NEW.cohead_shiptophone,''); NEW.cohead_misc := COALESCE(NEW.cohead_misc,0); NEW.cohead_misc_descrip := COALESCE(NEW.cohead_misc_descrip,''); NEW.cohead_shipcomplete := COALESCE(NEW.cohead_shipcomplete,false); IF (_p.shipto_id IS NOT NULL) THEN -- Pull in over ride values NEW.cohead_salesrep_id := COALESCE(NEW.cohead_salesrep_id,_p.shipto_salesrep_id); NEW.cohead_shipvia := COALESCE(NEW.cohead_shipvia,_p.shipto_shipvia); NEW.cohead_shipchrg_id := COALESCE(NEW.cohead_shipchrg_id,_p.shipto_shipchrg_id); NEW.cohead_shipform_id := COALESCE(NEW.cohead_shipform_id,_p.shipto_shipform_id); NEW.cohead_commission := COALESCE(NEW.cohead_commission,_p.shipto_commission); IF (NEW.cohead_taxzone_id=-1) THEN NEW.cohead_taxzone_id := NULL; ELSE NEW.cohead_taxzone_id := COALESCE(NEW.cohead_taxzone_id,_p.shipto_taxzone_id); END IF; ELSE NEW.cohead_salesrep_id := COALESCE(NEW.cohead_salesrep_id,_p.cust_salesrep_id); NEW.cohead_shipvia := COALESCE(NEW.cohead_shipvia,_p.cust_shipvia); NEW.cohead_shipchrg_id := COALESCE(NEW.cohead_shipchrg_id,_p.cust_shipchrg_id); NEW.cohead_shipform_id := COALESCE(NEW.cohead_shipform_id,_p.cust_shipform_id); NEW.cohead_commission := COALESCE(NEW.cohead_commission,_p.cust_commprcnt); IF (NEW.cohead_taxzone_id=-1) THEN NEW.cohead_taxzone_id := NULL; ELSE NEW.cohead_taxzone_id := COALESCE(NEW.cohead_taxzone_id,_p.cust_taxzone_id); END IF; END IF; IF ((NEW.cohead_warehous_id IS NULL) OR (NEW.cohead_fob IS NULL)) THEN IF (NEW.cohead_warehous_id IS NULL) THEN SELECT warehous_id,warehous_fob INTO _w FROM usrpref, whsinfo WHERE ((warehous_id=CAST(usrpref_value AS INTEGER)) AND (warehous_shipping) AND (warehous_active) AND (usrpref_username=getEffectiveXtUser()) AND (usrpref_name='PreferredWarehouse')); ELSE SELECT warehous_id,warehous_fob INTO _w FROM whsinfo WHERE (warehous_id=NEW.cohead_warehous_id); END IF; IF (FOUND) THEN NEW.cohead_warehous_id := COALESCE(NEW.cohead_warehous_id,_w.warehous_id); NEW.cohead_fob := COALESCE(NEW.cohead_fob,_w.warehous_fob); END IF; END IF; END IF; -- Only Check P/O logic for imports, because UI checks when entire order is saved IF (NEW.cohead_imported) THEN -- Check for required Purchase Order IF (_p.cust_usespos AND ((NEW.cohead_custponumber IS NULL) OR (TRIM(BOTH FROM NEW.cohead_custponumber)=''))) THEN RAISE EXCEPTION 'You must enter a Customer P/O for this Sales Order.'; END IF; -- Check for duplicate Purchase Orders if not allowed IF (_p.cust_usespos AND NOT (_p.cust_blanketpos)) THEN SELECT cohead_id INTO _a FROM cohead WHERE ((cohead_cust_id=NEW.cohead_cust_id) AND (cohead_id<>NEW.cohead_id) AND (UPPER(cohead_custponumber) = UPPER(NEW.cohead_custponumber)) ) UNION SELECT quhead_id FROM quhead WHERE ((quhead_cust_id=NEW.cohead_cust_id) AND (quhead_id<>NEW.cohead_id) AND (UPPER(quhead_custponumber) = UPPER(NEW.cohead_custponumber)) ); IF (FOUND) THEN RAISE EXCEPTION 'This Customer does not use Blanket P/O Numbers and the P/O Number you entered has already been used for another Sales Order. Please verify the P/O Number and either enter a new P/O Number or add to the existing Sales Order.'; END IF; END IF; END IF; --Auto create project if applicable IF ((TG_OP = 'INSERT') AND (COALESCE(NEW.cohead_prj_id,-1)=-1)) THEN SELECT fetchMetricBool('AutoCreateProjectsForOrders') INTO _check; IF (_check) THEN SELECT NEXTVAL('prj_prj_id_seq') INTO _prjId; NEW.cohead_prj_id := _prjId; INSERT INTO prj (prj_id, prj_number, prj_name, prj_descrip, prj_status, prj_so, prj_wo, prj_po, prj_owner_username, prj_start_date, prj_due_date, prj_assigned_date, prj_completed_date, prj_username, prj_recurring_prj_id, prj_crmacct_id, prj_cntct_id, prj_prjtype_id) SELECT _prjId, NEW.cohead_number, NEW.cohead_number, 'Auto Generated Project from Sales Order.', 'O', TRUE, TRUE, TRUE, getEffectiveXTUser(), NEW.cohead_orderdate, NEW.cohead_packdate, NEW.cohead_orderdate, NULL, getEffectiveXTUser(), NULL, crmacct_id, NEW.cohead_billto_cntct_id, NULL FROM crmacct WHERE (crmacct_cust_id=NEW.cohead_cust_id); END IF; END IF; IF (TG_OP = 'UPDATE') THEN SELECT true INTO _check FROM coitem WHERE ( (coitem_status='C') AND (coitem_cohead_id=NEW.cohead_id) ) LIMIT 1; IF (NOT FOUND) THEN --Update project references on supply UPDATE pr SET pr_prj_id=NEW.cohead_prj_id FROM coitem WHERE ((coitem_cohead_id=NEW.cohead_id) AND (coitem_order_type='R') AND (coitem_order_id=pr_id)); PERFORM changeWoProject(coitem_order_id, NEW.cohead_prj_id, TRUE) FROM coitem WHERE ((coitem_cohead_id=NEW.cohead_id) AND (coitem_order_type='W')); ELSE IF NEW.cohead_prj_id <> COALESCE(OLD.cohead_prj_id,-1) THEN RAISE EXCEPTION 'You can not change the project ID on orders with closed lines.'; END IF; END IF; END IF; -- Deal with Billing Address IF (TG_OP = 'INSERT') THEN IF (_p.cust_ffbillto) THEN -- If they didn't supply data, we'll put in the bill to contact and address NEW.cohead_billto_cntct_id=COALESCE(NEW.cohead_billto_cntct_id,_p.cntct_id); NEW.cohead_billto_cntct_honorific=COALESCE(NEW.cohead_billto_cntct_honorific,_p.cntct_honorific,''); NEW.cohead_billto_cntct_first_name=COALESCE(NEW.cohead_billto_cntct_first_name,_p.cntct_first_name,''); NEW.cohead_billto_cntct_middle=COALESCE(NEW.cohead_billto_cntct_middle,_p.cntct_middle,''); NEW.cohead_billto_cntct_last_name=COALESCE(NEW.cohead_billto_cntct_last_name,_p.cntct_last_name,''); NEW.cohead_billto_cntct_phone=COALESCE(NEW.cohead_billto_cntct_phone,_p.cntct_phone,''); NEW.cohead_billto_cntct_title=COALESCE(NEW.cohead_billto_cntct_title,_p.cntct_title,''); NEW.cohead_billto_cntct_fax=COALESCE(NEW.cohead_billto_cntct_fax,_p.cntct_fax,''); NEW.cohead_billto_cntct_email=COALESCE(NEW.cohead_billto_cntct_email,_p.cntct_email,''); NEW.cohead_billtoname=COALESCE(NEW.cohead_billtoname,_p.cust_name,''); NEW.cohead_billtoaddress1=COALESCE(NEW.cohead_billtoaddress1,_p.addr_line1,''); NEW.cohead_billtoaddress2=COALESCE(NEW.cohead_billtoaddress2,_p.addr_line2,''); NEW.cohead_billtoaddress3=COALESCE(NEW.cohead_billtoaddress3,_p.addr_line3,''); NEW.cohead_billtocity=COALESCE(NEW.cohead_billtocity,_p.addr_city,''); NEW.cohead_billtostate=COALESCE(NEW.cohead_billtostate,_p.addr_state,''); NEW.cohead_billtozipcode=COALESCE(NEW.cohead_billtozipcode,_p.addr_postalcode,''); NEW.cohead_billtocountry=COALESCE(NEW.cohead_billtocountry,_p.addr_country,''); ELSE -- Free form not allowed, we're going to put in the address regardless NEW.cohead_billto_cntct_id=_p.cntct_id; NEW.cohead_billto_cntct_honorific=COALESCE(_p.cntct_honorific,''); NEW.cohead_billto_cntct_first_name=COALESCE(_p.cntct_first_name,''); NEW.cohead_billto_cntct_middle=COALESCE(_p.cntct_middle,''); NEW.cohead_billto_cntct_last_name=COALESCE(_p.cntct_last_name,''); NEW.cohead_billto_cntct_phone=COALESCE(_p.cntct_phone,''); NEW.cohead_billto_cntct_title=COALESCE(_p.cntct_title,''); NEW.cohead_billto_cntct_fax=COALESCE(_p.cntct_fax,''); NEW.cohead_billto_cntct_email=COALESCE(_p.cntct_email,''); NEW.cohead_billtoname=COALESCE(_p.cust_name,''); NEW.cohead_billtoaddress1=COALESCE(_p.addr_line1,''); NEW.cohead_billtoaddress2=COALESCE(_p.addr_line2,''); NEW.cohead_billtoaddress3=COALESCE(_p.addr_line3,''); NEW.cohead_billtocity=COALESCE(_p.addr_city,''); NEW.cohead_billtostate=COALESCE(_p.addr_state,''); NEW.cohead_billtozipcode=COALESCE(_p.addr_postalcode,''); NEW.cohead_billtocountry=COALESCE(_p.addr_country,''); END IF; END IF; -- Now let's look at Shipto Address -- If there's nothing in the address fields and there is a shipto id -- or there is a default address available, let's put in some shipto address data IF ((TG_OP = 'INSERT') AND NOT ((NEW.cohead_shipto_id IS NULL) AND NOT _p.cust_ffshipto) AND (NEW.cohead_shipto_cntct_id IS NULL) AND (NEW.cohead_shipto_cntct_honorific IS NULL) AND (NEW.cohead_shipto_cntct_first_name IS NULL) AND (NEW.cohead_shipto_cntct_middle IS NULL) AND (NEW.cohead_shipto_cntct_last_name IS NULL) AND (NEW.cohead_shipto_cntct_suffix IS NULL) AND (NEW.cohead_shipto_cntct_phone IS NULL) AND (NEW.cohead_shipto_cntct_title IS NULL) AND (NEW.cohead_shipto_cntct_fax IS NULL) AND (NEW.cohead_shipto_cntct_email IS NULL) AND (NEW.cohead_shiptoname IS NULL) AND (NEW.cohead_shiptoaddress1 IS NULL) AND (NEW.cohead_shiptoaddress2 IS NULL) AND (NEW.cohead_shiptoaddress3 IS NULL) AND (NEW.cohead_shiptocity IS NULL) AND (NEW.cohead_shiptostate IS NULL) AND (NEW.cohead_shiptocountry IS NULL)) THEN IF ((NEW.cohead_shipto_id IS NULL) AND (_p.shipto_id IS NOT NULL)) THEN _shiptoId := _p.shipto_addr_id; ELSE _shiptoId := NEW.cohead_shipto_id; END IF; SELECT * INTO _a FROM shiptoinfo LEFT OUTER JOIN addr ON (addr_id=shipto_addr_id) LEFT OUTER JOIN cntct ON (cntct_id=shipto_cntct_id) WHERE (shipto_id=_shiptoId); NEW.cohead_shipto_cntct_id := _a.cntct_id; NEW.cohead_shipto_cntct_honorific := COALESCE(_a.cntct_honorific,''); NEW.cohead_shipto_cntct_first_name := COALESCE(_a.cntct_first_name,''); NEW.cohead_shipto_cntct_middle := COALESCE(_a.cntct_middle,''); NEW.cohead_shipto_cntct_last_name := COALESCE(_a.cntct_last_name,''); NEW.cohead_shipto_cntct_suffix := COALESCE(_a.cntct_suffix,''); NEW.cohead_shipto_cntct_phone := COALESCE(_a.cntct_phone,''); NEW.cohead_shipto_cntct_title := COALESCE(_a.cntct_title,''); NEW.cohead_shipto_cntct_fax := COALESCE(_a.cntct_fax,''); NEW.cohead_shipto_cntct_email := COALESCE(_a.cntct_email,''); NEW.cohead_shiptoname := COALESCE(_p.shipto_name,''); NEW.cohead_shiptoaddress1 := COALESCE(_a.addr_line1,''); NEW.cohead_shiptoaddress2 := COALESCE(_a.addr_line2,''); NEW.cohead_shiptoaddress3 := COALESCE(_a.addr_line3,''); NEW.cohead_shiptocity := COALESCE(_a.addr_city,''); NEW.cohead_shiptostate := COALESCE(_a.addr_state,''); NEW.cohead_shiptozipcode := COALESCE(_a.addr_postalcode,''); NEW.cohead_shiptocountry := COALESCE(_a.addr_country,''); ELSE IF (_p.cust_ffshipto) THEN -- Use Address Save function to see if the new address entered matches -- data for the shipto number. If not that will insert new address for CRM SELECT SaveAddr( NULL, NULL, NEW.cohead_shiptoaddress1, NEW.cohead_shiptoaddress2, NEW.cohead_shiptoaddress3, NEW.cohead_shiptocity, NEW.cohead_shiptostate, NEW.cohead_shiptozipcode, NEW.cohead_shiptocountry, 'CHANGEONE') INTO _addrId; SELECT shipto_addr_id INTO _shiptoid FROM shiptoinfo WHERE (shipto_id=NEW.cohead_shipto_id); -- If the address passed doesn't match shipto address, then it's something else IF (_shiptoid <> _addrId) THEN NEW.cohead_shipto_id := NULL; END IF; ELSE SELECT cohead_shipto_id INTO _shiptoid FROM cohead WHERE (cohead_id=NEW.cohead_id); -- Get the shipto address IF (COALESCE(NEW.cohead_shipto_id,-1) <> COALESCE(_shiptoid,-1)) THEN SELECT * INTO _a FROM shiptoinfo LEFT OUTER JOIN cntct ON (shipto_cntct_id=cntct_id) LEFT OUTER JOIN addr ON (shipto_addr_id=addr_id) WHERE (shipto_id=NEW.cohead_shipto_id); IF (FOUND) THEN -- Free form not allowed so we're going to make sure address matches Shipto data NEW.cohead_shipto_cntct_id=_a.cntct_id; NEW.cohead_shipto_cntct_honorific=COALESCE(_a.cntct_honorific,''); NEW.cohead_shipto_cntct_first_name=COALESCE(_a.cntct_first_name,''); NEW.cohead_shipto_cntct_middle=COALESCE(_a.cntct_middle,''); NEW.cohead_shipto_cntct_last_name=COALESCE(_a.cntct_last_name,''); NEW.cohead_shipto_cntct_phone=COALESCE(_a.cntct_phone,''); NEW.cohead_shipto_cntct_title=COALESCE(_a.cntct_title,''); NEW.cohead_shipto_cntct_fax=COALESCE(_a.cntct_fax,''); NEW.cohead_shipto_cntct_email=COALESCE(_a.cntct_email,''); NEW.cohead_shiptoname := COALESCE(_a.shipto_name,''); NEW.cohead_shiptophone := COALESCE(_a.cntct_phone,''); NEW.cohead_shiptoaddress1 := COALESCE(_a.addr_line1,''); NEW.cohead_shiptoaddress2 := COALESCE(_a.addr_line2,''); NEW.cohead_shiptoaddress3 := COALESCE(_a.addr_line3,''); NEW.cohead_shiptocity := COALESCE(_a.addr_city,''); NEW.cohead_shiptostate := COALESCE(_a.addr_state,''); NEW.cohead_shiptozipcode := COALESCE(_a.addr_postalcode,''); NEW.cohead_shiptocountry := COALESCE(_a.addr_country,''); ELSE -- If no shipto data and free form not allowed, this won't work RAISE EXCEPTION 'Free form Shipto is not allowed on this Customer. You must supply a valid Shipto ID.'; END IF; END IF; END IF; END IF; END IF; END IF; IF ( SELECT (metric_value='t') FROM metric WHERE (metric_name='SalesOrderChangeLog') ) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment('ChangeLog', 'S', NEW.cohead_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF ( (OLD.cohead_terms_id <> NEW.cohead_terms_id) AND (OLD.cohead_cust_id = NEW.cohead_cust_id) ) THEN PERFORM postComment( 'ChangeLog', 'S', NEW.cohead_id, ('Terms Changed from "' || oldterms.terms_code || '" to "' || newterms.terms_code || '"') ) FROM terms AS oldterms, terms AS newterms WHERE ( (oldterms.terms_id=OLD.cohead_terms_id) AND (newterms.terms_id=NEW.cohead_terms_id) ); END IF; IF ( (OLD.cohead_shipvia <> NEW.cohead_shipvia) AND (OLD.cohead_cust_id = NEW.cohead_cust_id) ) THEN PERFORM postComment ('ChangeLog', 'S', New.cohead_id, ('Shipvia Changed from "' || OLD.cohead_shipvia || '" to "' || NEW.cohead_shipvia || '"')); END IF; IF (OLD.cohead_holdtype <> NEW.cohead_holdtype) THEN PERFORM postComment( 'ChangeLog', 'S', NEW.cohead_id, ( 'Hold Type Changed from ' || (CASE OLD.cohead_holdtype WHEN('N') THEN 'No Hold' WHEN('C') THEN 'Credit Hold' WHEN('P') THEN 'Packing Hold' WHEN('S') THEN 'Shipping Hold' ELSE 'Unknown/Error' END) || ' to ' || (CASE NEW.cohead_holdtype WHEN('N') THEN 'No Hold' WHEN('C') THEN 'Credit Hold' WHEN('P') THEN 'Packing Hold' WHEN('S') THEN 'Shipping Hold' ELSE 'Unknown/Error' END) ) ); END IF; ELSIF (TG_OP = 'DELETE') THEN DELETE FROM docass WHERE docass_source_id = OLD.cohead_id AND docass_source_type = 'S'; DELETE FROM docass WHERE docass_target_id = OLD.cohead_id AND docass_target_type = 'S'; DELETE FROM comment WHERE ( (comment_source='S') AND (comment_source_id=OLD.cohead_id) ); END IF; END IF; IF (TG_OP = 'UPDATE') THEN IF ( (NOT (OLD.cohead_holdtype = 'N')) AND (NEW.cohead_holdtype='N') ) THEN PERFORM postEvent('SoReleased', 'S', NEW.cohead_id, NEW.cohead_warehous_id, NEW.cohead_number, NULL, NULL, NULL, NULL); END IF; IF (OLD.cohead_ordercomments <> NEW.cohead_ordercomments) THEN PERFORM postEvent('SoNotesChanged', 'S', NEW.cohead_id, NEW.cohead_warehous_id, NEW.cohead_number, NULL, NULL, NULL, NULL); END IF; IF ((OLD.cohead_shipchrg_id != NEW.cohead_shipchrg_id) OR (OLD.cohead_freight != NEW.cohead_freight) OR (OLD.cohead_shipvia != NEW.cohead_shipvia)) THEN UPDATE shiphead SET shiphead_shipchrg_id= CASE WHEN (NEW.cohead_shipchrg_id <= 0) THEN NULL ELSE NEW.cohead_shipchrg_id END, shiphead_freight=NEW.cohead_freight, shiphead_shipvia=NEW.cohead_shipvia WHERE ((shiphead_order_type='SO') AND (shiphead_order_id=NEW.cohead_id) AND (NOT shiphead_shipped)); END IF; END IF; IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE NEW.cohead_lastupdated = CURRENT_TIMESTAMP; RETURN NEW; END IF; END; $$; ALTER FUNCTION public._soheadtrigger() OWNER TO admin; -- -- Name: _soheadtriggerafter(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _soheadtriggerafter() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (COALESCE(NEW.cohead_taxzone_id,-1) <> COALESCE(OLD.cohead_taxzone_id,-1)) THEN UPDATE coitem SET coitem_taxtype_id=getItemTaxType(itemsite_item_id,NEW.cohead_taxzone_id) FROM itemsite WHERE ((itemsite_id=coitem_itemsite_id) AND (coitem_cohead_id=NEW.cohead_id)); END IF; -- update comments on any associated drop ship POs IF (COALESCE(NEW.cohead_shipcomments, TEXT('')) <> COALESCE(OLD.cohead_shipcomments, TEXT(''))) THEN UPDATE pohead SET pohead_comments=NEW.cohead_shipcomments FROM poitem JOIN coitem ON (coitem_cohead_id=NEW.cohead_id AND coitem_order_type='P' AND coitem_order_id=poitem_id) WHERE (pohead_id=poitem_pohead_id); END IF; RETURN NEW; END; $$; ALTER FUNCTION public._soheadtriggerafter() OWNER TO admin; -- -- Name: _soitemafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _soitemafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF (OLD.coitem_status = 'O') THEN IF ( (SELECT (count(*) < 1) FROM coitem WHERE ((coitem_cohead_id=OLD.coitem_cohead_id) AND (coitem_id != OLD.coitem_id) AND (coitem_status = 'O')) ) ) THEN UPDATE cohead SET cohead_status = 'C' WHERE ((cohead_id=OLD.coitem_cohead_id) AND (cohead_status='O')); END IF; END IF; DELETE FROM charass WHERE charass_target_type = 'SI' AND charass_target_id = OLD.coitem_id; RETURN OLD; END; $$; ALTER FUNCTION public._soitemafterdeletetrigger() OWNER TO admin; -- -- Name: _soitemaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _soitemaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check NUMERIC; _r RECORD; _kit BOOLEAN; _fractional BOOLEAN; _rec RECORD; _kstat TEXT; _pstat TEXT; _result INTEGER; _coheadnumber TEXT; _coitemid INTEGER; _itemsrcid INTEGER; _orderid INTEGER; BEGIN _rec := NEW; --Cache some information SELECT * INTO _r FROM cohead WHERE (cohead_id=_rec.coitem_cohead_id); --Determine if this is a kit for later processing SELECT COALESCE(item_type,'')='K', item_fractional INTO _kit, _fractional FROM itemsite, item WHERE((itemsite_item_id=item_id) AND (itemsite_id=_rec.coitem_itemsite_id)); _kit := COALESCE(_kit, false); _fractional := COALESCE(_fractional, false); IF (_kit) THEN -- Kit Processing IF (TG_OP = 'INSERT') THEN -- Create Sub Lines for Kit Components PERFORM explodeKit(NEW.coitem_cohead_id, NEW.coitem_linenumber, 0, NEW.coitem_itemsite_id, NEW.coitem_qtyord, NEW.coitem_scheddate, NEW.coitem_promdate, NEW.coitem_memo); IF (fetchMetricBool('KitComponentInheritCOS')) THEN -- Update kit line item COS UPDATE coitem SET coitem_cos_accnt_id = CASE WHEN (COALESCE(NEW.coitem_cos_accnt_id, -1) != -1) THEN NEW.coitem_cos_accnt_id WHEN (NEW.coitem_warranty) THEN resolveCOWAccount(NEW.coitem_itemsite_id, _r.cohead_cust_id, _r.cohead_saletype_id, _r.cohead_shipzone_id) ELSE resolveCOSAccount(NEW.coitem_itemsite_id, _r.cohead_cust_id, _r.cohead_saletype_id, _r.cohead_shipzone_id) END WHERE((coitem_cohead_id=NEW.coitem_cohead_id) AND (coitem_linenumber = NEW.coitem_linenumber) AND (coitem_subnumber > 0)); END IF; END IF; IF (TG_OP = 'UPDATE') THEN IF (NEW.coitem_qtyord <> OLD.coitem_qtyord) THEN -- Recreate Sub Lines for Kit Components FOR _coitemid IN SELECT coitem_id FROM coitem WHERE ( (coitem_cohead_id=OLD.coitem_cohead_id) AND (coitem_linenumber=OLD.coitem_linenumber) AND (coitem_subnumber > 0) ) LOOP SELECT deleteSoItem(_coitemid) INTO _result; IF (_result < 0) THEN RAISE EXCEPTION 'Error deleting kit components: deleteSoItem(integer) Error:%', _result; END IF; END LOOP; PERFORM explodeKit(NEW.coitem_cohead_id, NEW.coitem_linenumber, 0, NEW.coitem_itemsite_id, NEW.coitem_qtyord, NEW.coitem_scheddate, NEW.coitem_promdate); END IF; IF ( (NEW.coitem_qtyord <> OLD.coitem_qtyord) OR (NEW.coitem_cos_accnt_id <> OLD.coitem_cos_accnt_id) ) THEN IF (fetchMetricBool('KitComponentInheritCOS')) THEN -- Update kit line item COS UPDATE coitem SET coitem_cos_accnt_id = CASE WHEN (COALESCE(NEW.coitem_cos_accnt_id, -1) != -1) THEN NEW.coitem_cos_accnt_id WHEN (NEW.coitem_warranty) THEN resolveCOWAccount(NEW.coitem_itemsite_id, _r.cohead_cust_id, _r.cohead_saletype_id, _r.cohead_shipzone_id) ELSE resolveCOSAccount(NEW.coitem_itemsite_id, _r.cohead_cust_id, _r.cohead_saletype_id, _r.cohead_shipzone_id) END WHERE((coitem_cohead_id=NEW.coitem_cohead_id) AND (coitem_linenumber = NEW.coitem_linenumber) AND (coitem_subnumber > 0)); END IF; END IF; IF (NEW.coitem_scheddate <> OLD.coitem_scheddate) THEN -- Update kit line item Schedule Date UPDATE coitem SET coitem_scheddate = NEW.coitem_scheddate WHERE((coitem_cohead_id=NEW.coitem_cohead_id) AND (coitem_linenumber = NEW.coitem_linenumber) AND (coitem_subnumber > 0)); END IF; END IF; END IF; IF (TG_OP = 'INSERT') THEN -- Create Purchase Request if flagged to do so IF ((NEW.coitem_order_type='R') AND (NEW.coitem_order_id=-1)) THEN SELECT cohead_number INTO _coheadnumber FROM cohead, itemsite WHERE (cohead_id=NEW.coitem_cohead_id) AND (itemsite_id=NEW.coitem_itemsite_id) AND (NOT itemsite_stocked); IF (FOUND) THEN SELECT createPR(CAST(_coheadnumber AS INTEGER), 'S', NEW.coitem_id) INTO _orderid; IF (_orderid > 0) THEN UPDATE coitem SET coitem_order_id=_orderid WHERE (coitem_id=NEW.coitem_id); ELSE RAISE EXCEPTION 'CreatePR failed, result=%', _orderid; END IF; END IF; END IF; -- Create Purchase Order if flagged to do so IF ((NEW.coitem_order_type='P') AND (NEW.coitem_order_id=-1)) THEN SELECT itemsrc_id INTO _itemsrcid FROM itemsite JOIN itemsrc ON (itemsrc_item_id=itemsite_item_id AND itemsrc_default) WHERE (itemsite_id=NEW.coitem_itemsite_id) AND (NOT itemsite_stocked); IF (FOUND) THEN SELECT createPurchaseToSale(NEW.coitem_id, _itemsrcid, itemsite_dropship, CASE WHEN (NEW.coitem_prcost=0.0) THEN NULL ELSE NEW.coitem_prcost END) INTO _orderid FROM itemsite WHERE (itemsite_id=NEW.coitem_itemsite_id); IF (_orderid > 0) THEN UPDATE coitem SET coitem_order_id=_orderid WHERE (coitem_id=NEW.coitem_id); ELSE RAISE EXCEPTION 'CreatePurchaseToSale failed, result=%', _orderid; END IF; END IF; END IF; -- Update Purchase Order comments IF (NEW.coitem_order_type='P') THEN UPDATE poitem SET poitem_comments=NEW.coitem_memo WHERE ((poitem_order_id=NEW.coitem_id) AND (poitem_order_type='S')); END IF; END IF; IF (TG_OP = 'UPDATE') THEN IF (NEW.coitem_order_type = 'P') THEN --If soitem is cancelled IF ((NEW.coitem_status = 'X') AND (OLD.coitem_status <> 'X')) THEN PERFORM postEvent('PoItemSoCancelled', 'P', poitem_id, itemsite_warehous_id, (pohead_number || '-' || poitem_linenumber || ':' || item_number), NULL, NULL, NULL, NULL) FROM poitem JOIN itemsite ON (itemsite_id=poitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) JOIN pohead ON (pohead_id=poitem_pohead_id) WHERE ( (poitem_id=OLD.coitem_order_id) AND (poitem_duedate <= (CURRENT_DATE + itemsite_eventfence)) ); --If soitem notes changed ELSIF (NEW.coitem_memo <> OLD.coitem_memo) THEN UPDATE poitem SET poitem_comments=NEW.coitem_memo WHERE ((poitem_order_id=NEW.coitem_id) AND (poitem_order_type='S')); END IF; END IF; END IF; IF (_rec.coitem_subnumber > 0) THEN SELECT coitem_status INTO _kstat FROM coitem WHERE((coitem_cohead_id=_rec.coitem_cohead_id) AND (coitem_linenumber=_rec.coitem_linenumber) AND (coitem_subnumber = 0)); IF ((SELECT count(*) FROM coitem WHERE((coitem_cohead_id=_rec.coitem_cohead_id) AND (coitem_linenumber=_rec.coitem_linenumber) AND (coitem_subnumber <> _rec.coitem_subnumber) AND (coitem_subnumber > 0) AND (coitem_status = 'O'))) > 0) THEN _pstat := 'O'; ELSE _pstat := _rec.coitem_status; END IF; END IF; IF(TG_OP = 'INSERT') THEN IF (_rec.coitem_subnumber > 0 AND _rec.coitem_status = 'O') THEN _pstat := 'O'; END IF; ELSIF (TG_OP = 'UPDATE') THEN IF (_rec.coitem_subnumber > 0 AND _rec.coitem_status = 'O') THEN _pstat := 'O'; END IF; IF ((NEW.coitem_status = 'C') AND (OLD.coitem_status <> 'C')) THEN IF(_kit) THEN UPDATE coitem SET coitem_status='C' WHERE((coitem_cohead_id=OLD.coitem_cohead_id) AND (coitem_linenumber=OLD.coitem_linenumber) AND (coitem_status='O') AND (coitem_subnumber > 0)); END IF; END IF; IF ((NEW.coitem_status = 'X') AND (OLD.coitem_status <> 'X')) THEN IF(_kit) THEN UPDATE coitem SET coitem_status='X' WHERE((coitem_cohead_id=OLD.coitem_cohead_id) AND (coitem_linenumber=OLD.coitem_linenumber) AND (coitem_status='O') AND (coitem_subnumber > 0)); END IF; END IF; IF(NEW.coitem_status = 'O' AND OLD.coitem_status <> 'O') THEN IF(_kit) THEN UPDATE coitem SET coitem_status='O' WHERE((coitem_cohead_id=OLD.coitem_cohead_id) AND (coitem_linenumber=OLD.coitem_linenumber) AND ((coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) > 0) AND (coitem_subnumber > 0)); END IF; END IF; END IF; IF ((_kstat IS NOT NULL) AND (_pstat IS NOT NULL) AND (_rec.coitem_subnumber > 0) AND (_kstat <> _pstat)) THEN UPDATE coitem SET coitem_status = _pstat WHERE((coitem_cohead_id=_rec.coitem_cohead_id) AND (coitem_linenumber=_rec.coitem_linenumber) AND (coitem_subnumber = 0)); END IF; --If auto calculate freight, recalculate cohead_freight IF (SELECT cohead_calcfreight FROM cohead WHERE (cohead_id=NEW.coitem_cohead_id)) THEN UPDATE cohead SET cohead_freight = COALESCE( (SELECT SUM(freightdata_total) FROM freightDetail('SO', cohead_id, cohead_cust_id, cohead_shipto_id, cohead_orderdate, cohead_shipvia, cohead_curr_id)), 0) WHERE cohead_id=NEW.coitem_cohead_id; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._soitemaftertrigger() OWNER TO admin; -- -- Name: _soitembeforedeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _soitembeforedeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; _kit BOOLEAN := FALSE; _shipped BOOLEAN := FALSE; _coitemid INTEGER := 0; _result INTEGER := 0; BEGIN -- Check Priv IF NOT (checkPrivilege('MaintainSalesOrders')) THEN RAISE EXCEPTION 'You do not have privileges to alter a Sales Order.'; END IF; -- Cache some information SELECT * INTO _r FROM cohead, itemsite, item WHERE ( (cohead_id=OLD.coitem_cohead_id) AND (itemsite_id=OLD.coitem_itemsite_id) AND (item_id=itemsite_item_id) ); _kit := (COALESCE(_r.item_type,'')='K'); -- Check for shipped kit components IF(_kit AND OLD.coitem_status <> 'C' AND OLD.coitem_status <> 'X') THEN IF (EXISTS (SELECT coitem_id FROM coitem JOIN shipitem ON (shipitem_orderitem_id=coitem_id) JOIN shiphead ON (shiphead_id=shipitem_shiphead_id AND shiphead_order_type='SO') WHERE ((coitem_cohead_id=OLD.coitem_cohead_id) AND (coitem_linenumber=OLD.coitem_linenumber) AND (coitem_subnumber > 0)) GROUP BY coitem_id HAVING (SUM(shipitem_qty) > 0) LIMIT 1) ) THEN _shipped := TRUE; END IF; END IF; IF(_kit AND _shipped) THEN RAISE EXCEPTION 'You can not delete this Sales Order Line as it has several sub components that have already been shipped.'; END IF; DELETE FROM comment WHERE ( (comment_source='SI') AND (comment_source_id=OLD.coitem_id) ); DELETE FROM charass WHERE ((charass_target_type='SI') AND (charass_target_id=OLD.coitem_id)); -- Delete Sub Lines for Kit Components IF (OLD.coitem_subnumber = 0) THEN FOR _coitemid IN SELECT coitem_id FROM coitem WHERE ( (coitem_cohead_id=OLD.coitem_cohead_id) AND (coitem_linenumber=OLD.coitem_linenumber) AND (coitem_subnumber > 0) ) LOOP SELECT deleteSoItem(_coitemid) INTO _result; IF (_result < 0) THEN IF NOT (_r.itemsite_createsopo AND (_result = -10 OR _result = -20)) THEN RAISE EXCEPTION 'Error deleting kit components: deleteSoItem(integer) Error:%', _result; END IF; END IF; END LOOP; END IF; IF (OLD.coitem_scheddate <= (CURRENT_DATE + _r.itemsite_eventfence)) THEN PERFORM postEvent('SoitemCancelled', 'S', OLD.coitem_id, _r.itemsite_warehous_id, (_r.cohead_number || '-' || OLD.coitem_linenumber), NULL, NULL, NULL, NULL); END IF; RETURN OLD; END; $$; ALTER FUNCTION public._soitembeforedeletetrigger() OWNER TO admin; -- -- Name: _soitembeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _soitembeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check NUMERIC; _itemNumber TEXT; _r RECORD; _kit BOOLEAN; BEGIN --Determine if this is a kit for later processing SELECT COALESCE(item_type,'')='K' INTO _kit FROM itemsite, item WHERE((itemsite_item_id=item_id) AND (itemsite_id=NEW.coitem_itemsite_id)); _kit := COALESCE(_kit, false); IF (TG_OP = 'INSERT') THEN -- If this is imported, go ahead and insert default characteristics IF (NEW.coitem_imported) THEN INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_price) SELECT 'SI', NEW.coitem_id, char_id, charass_value, itemcharprice(item_id,char_id,charass_value,cohead_cust_id,cohead_shipto_id,NEW.coitem_qtyord,cohead_curr_id,cohead_orderdate) FROM ( SELECT DISTINCT char_id, char_name, charass_value, item_id, cohead_cust_id, cohead_shipto_id, cohead_curr_id, cohead_orderdate FROM cohead, charass, char, itemsite, item WHERE((itemsite_id=NEW.coitem_itemsite_id) AND (itemsite_item_id=item_id) AND (charass_target_type='I') AND (charass_target_id=item_id) AND (charass_default) AND (char_id=charass_char_id) AND (cohead_id=NEW.coitem_cohead_id)) ORDER BY char_name) AS data; END IF; END IF; -- Create work order and process if flagged to do so IF ((NEW.coitem_order_type='W') AND (NEW.coitem_order_id=-1)) THEN SELECT createwo(CAST(cohead_number AS INTEGER), NEW.coitem_itemsite_id, 1, -- priority validateOrderQty(NEW.coitem_itemsite_id, NEW.coitem_qtyord, TRUE), itemsite_leadtime, NEW.coitem_scheddate, NEW.coitem_memo, 'S', NEW.coitem_id, cohead_prj_id) INTO NEW.coitem_order_id FROM cohead, itemsite WHERE ((cohead_id=NEW.coitem_cohead_id) AND (itemsite_id=NEW.coitem_itemsite_id)); INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value) SELECT 'W', NEW.coitem_order_id, charass_char_id, charass_value FROM charass WHERE ((charass_target_type='SI') AND (charass_target_id=NEW.coitem_id)); END IF; IF (TG_OP = 'UPDATE') THEN -- Update P/R date if applicable IF (NEW.coitem_scheddate <> OLD.coitem_scheddate AND NEW.coitem_order_type='R' AND NEW.coitem_order_id > 1) THEN UPDATE pr SET pr_duedate = NEW.coitem_scheddate WHERE (pr_order_id=NEW.coitem_id AND pr_order_type='S'); END IF; -- If closing or cancelling and there is a job item work order, then close job and distribute remaining costs IF ((NEW.coitem_status = 'C' AND OLD.coitem_status <> 'C') OR (NEW.coitem_status = 'X' AND OLD.coitem_status <> 'X')) AND (OLD.coitem_order_id > -1) THEN SELECT wo_id, wo_wipvalue INTO _r FROM wo,itemsite,item WHERE ((wo_ordtype='S') AND (wo_ordid=OLD.coitem_id) AND (itemsite_id=wo_itemsite_id) AND (item_id=itemsite_item_id) AND (itemsite_costmethod = 'J')); IF (FOUND) THEN IF (_r.wo_wipvalue > 0) THEN -- Distribute to G/L, debit Cost of Sales, credit WIP PERFORM MIN(insertGLTransaction( 'W/O', 'WO', formatWoNumber(NEW.coitem_order_id), 'Job Closed Incomplete', costcat_wip_accnt_id, CASE WHEN (COALESCE(NEW.coitem_cos_accnt_id, -1) != -1) THEN NEW.coitem_cos_accnt_id WHEN (NEW.coitem_warranty=TRUE) THEN resolveCOWAccount(itemsite_id, cohead_cust_id, cohead_saletype_id, cohead_shipzone_id) ELSE resolveCOSAccount(itemsite_id, cohead_cust_id, cohead_saletype_id, cohead_shipzone_id) END, -1, _r.wo_wipvalue, current_date )) FROM itemsite, costcat, cohead WHERE ((itemsite_id=NEW.coitem_itemsite_id) AND (itemsite_costcat_id=costcat_id) AND (cohead_id=NEW.coitem_cohead_id)); END IF; UPDATE wo SET wo_status = 'C', wo_wipvalue = 0 WHERE (wo_id = _r.wo_id); END IF; END IF; -- Likewise, reopen the job if line reopened IF ((NEW.coitem_status != 'C' AND OLD.coitem_status = 'C') OR (NEW.coitem_status != 'X' AND OLD.coitem_status = 'X')) AND (OLD.coitem_order_id > -1) THEN UPDATE wo SET wo_status = 'I' FROM itemsite, item WHERE ((wo_ordtype = 'S') AND (wo_ordid=NEW.coitem_id) AND (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (itemsite_costmethod='J')); END IF; -- Handle links to Return Authorization IF (fetchMetricBool('EnableReturnAuth')) THEN SELECT * INTO _r FROM raitem,rahead WHERE ((raitem_new_coitem_id=NEW.coitem_id) AND (rahead_id=raitem_rahead_id)); IF (FOUND) THEN IF ((_r.raitem_qtyauthorized <> NEW.coitem_qtyord OR _r.raitem_qty_uom_id <> NEW.coitem_qty_uom_id OR _r.raitem_qty_invuomratio <> NEW.coitem_qty_invuomratio OR _r.raitem_price_uom_id <> NEW.coitem_price_uom_id OR _r.raitem_price_invuomratio <> NEW.coitem_price_invuomratio) AND NOT (NEW.coitem_status = 'X' AND _r.raitem_qtyauthorized = 0)) THEN RAISE EXCEPTION 'Quantities for line item % may only be changed on the Return Authorization that created it.',NEW.coitem_linenumber; END IF; IF (OLD.coitem_warranty <> NEW.coitem_warranty) THEN UPDATE raitem SET raitem_warranty = NEW.coitem_warranty WHERE((raitem_new_coitem_id=NEW.coitem_id) AND (raitem_warranty != NEW.coitem_warranty)); END IF; IF (OLD.coitem_cos_accnt_id <> NEW.coitem_cos_accnt_id) THEN UPDATE raitem SET raitem_cos_accnt_id = NEW.coitem_cos_accnt_id WHERE((raitem_new_coitem_id=NEW.coitem_id) AND (COALESCE(raitem_cos_accnt_id,-1) != COALESCE(NEW.coitem_cos_accnt_id,-1))); END IF; IF (OLD.coitem_taxtype_id <> NEW.coitem_taxtype_id) THEN UPDATE raitem SET raitem_taxtype_id = NEW.coitem_taxtype_id WHERE((raitem_new_coitem_id=NEW.coitem_id) AND (COALESCE(raitem_taxtype_id,-1) != COALESCE(NEW.coitem_taxtype_id,-1))); END IF; IF (OLD.coitem_scheddate <> NEW.coitem_scheddate) THEN UPDATE raitem SET raitem_scheddate = NEW.coitem_scheddate WHERE((raitem_new_coitem_id=NEW.coitem_id) AND (raitem_scheddate != NEW.coitem_scheddate)); END IF; IF (OLD.coitem_memo <> NEW.coitem_memo) THEN UPDATE raitem SET raitem_notes = NEW.coitem_memo WHERE((raitem_new_coitem_id=NEW.coitem_id) AND (raitem_notes != NEW.coitem_memo)); END IF; IF ((OLD.coitem_qtyshipped <> NEW.coitem_qtyshipped) AND (NEW.coitem_qtyshipped >= _r.raitem_qtyauthorized) AND ((_r.raitem_disposition = 'S') OR (_r.raitem_status = 'O') AND (_r.raitem_disposition IN ('P','V')) AND (_r.raitem_qtyreceived >= _r.raitem_qtyauthorized))) THEN UPDATE raitem SET raitem_status = 'C' WHERE (raitem_new_coitem_id=NEW.coitem_id); END IF; END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._soitembeforetrigger() OWNER TO admin; -- -- Name: _soitemtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _soitemtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _changelog BOOLEAN := FALSE; _check BOOLEAN; _kit BOOLEAN; _shipped BOOLEAN; _atShipping NUMERIC; _tmp INTEGER; _rec RECORD; BEGIN -- Check SELECT checkPrivilege('MaintainSalesOrders') OR checkPrivilege('ShipOrders') OR checkPrivilege('IssueStockToShipping') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to alter a Sales Order.'; END IF; IF ( SELECT fetchMetricBool('SalesOrderChangeLog') ) THEN _changelog := TRUE; END IF; IF (TG_OP IN ('INSERT','UPDATE')) THEN IF (NEW.coitem_scheddate IS NULL) THEN IF (fetchmetricbool('AllowASAPShipSchedules')) THEN NEW.coitem_scheddate := current_date; ELSE RAISE EXCEPTION 'A schedule date is required.'; END IF; END IF; END IF; _rec := NEW; SELECT COALESCE(item_type,'')='K' INTO _kit FROM itemsite, item WHERE((itemsite_item_id=item_id) AND (itemsite_id=_rec.coitem_itemsite_id)); _kit := COALESCE(_kit, false); _shipped := false; IF(_kit AND _rec.coitem_status <> 'C' AND _rec.coitem_status <> 'X') THEN SELECT coitem_id INTO _tmp FROM coitem JOIN shipitem ON (shipitem_orderitem_id=coitem_id) JOIN shiphead ON (shiphead_id=shipitem_shiphead_id AND shiphead_order_type='SO') WHERE((coitem_cohead_id=_rec.coitem_cohead_id) AND (coitem_linenumber=_rec.coitem_linenumber) AND (coitem_subnumber > 0)) GROUP BY coitem_id HAVING (SUM(shipitem_qty) > 0) LIMIT 1; IF (FOUND) THEN _shipped := true; END IF; END IF; IF (TG_OP ='UPDATE') THEN IF ((OLD.coitem_status <> 'C') AND (NEW.coitem_status = 'C')) THEN SELECT qtyAtShipping(NEW.coitem_id) INTO _atShipping; IF (_atShipping > 0) THEN RAISE EXCEPTION 'Line % cannot be Closed at this time as there is inventory at shipping.',NEW.coitem_linenumber; END IF; END IF; END IF; IF (TG_OP = 'INSERT') THEN PERFORM postEvent('SoitemCreated', 'S', NEW.coitem_id, itemsite_warehous_id, (cohead_number || '-' || NEW.coitem_linenumber), NULL, NULL, NULL, NULL) FROM cohead, itemsite WHERE ( (cohead_id=NEW.coitem_cohead_id) AND (itemsite_id=NEW.coitem_itemsite_id) AND (NEW.coitem_scheddate <= (CURRENT_DATE + itemsite_eventfence)) ); IF (_changelog) THEN PERFORM postComment('ChangeLog', 'SI', NEW.coitem_id, 'Created'); END IF; --Set defaults if no values passed NEW.coitem_linenumber := COALESCE(NEW.coitem_linenumber, (SELECT (COALESCE(MAX(coitem_linenumber), 0) + 1) FROM coitem WHERE (coitem_cohead_id=NEW.coitem_cohead_id))); NEW.coitem_status := COALESCE(NEW.coitem_status,'O'); NEW.coitem_scheddate := COALESCE(NEW.coitem_scheddate, (SELECT MIN(coitem_scheddate) FROM coitem WHERE (coitem_cohead_id=NEW.coitem_cohead_id))); NEW.coitem_memo := COALESCE(NEW.coitem_memo,''); NEW.coitem_prcost := COALESCE(NEW.coitem_prcost,0); NEW.coitem_warranty := COALESCE(NEW.coitem_warranty,false); IF (NEW.coitem_status='O') THEN UPDATE cohead SET cohead_status = 'O' WHERE ((cohead_id=NEW.coitem_cohead_id) AND (cohead_status='C')); END IF; RETURN NEW; ELSIF (TG_OP = 'UPDATE') THEN IF (NEW.coitem_qtyord <> OLD.coitem_qtyord) THEN IF(_kit) THEN IF(_shipped) THEN RAISE EXCEPTION 'You can not change the qty ordered for a Kit item when one or more of its components have shipped inventory.'; END IF; END IF; PERFORM postEvent('SoitemQtyChanged', 'S', NEW.coitem_id, itemsite_warehous_id, (cohead_number || '-' || NEW.coitem_linenumber), NEW.coitem_qtyord, OLD.coitem_qtyord, NULL, NULL) FROM cohead, itemsite WHERE ( (cohead_id=NEW.coitem_cohead_id) AND (itemsite_id=NEW.coitem_itemsite_id) AND ( (NEW.coitem_scheddate <= (CURRENT_DATE + itemsite_eventfence)) OR (OLD.coitem_scheddate <= (CURRENT_DATE + itemsite_eventfence)) ) ); IF (_changelog) THEN PERFORM postComment( 'ChangeLog', 'SI', NEW.coitem_id, ( 'Changed Qty. Ordered from ' || formatQty(OLD.coitem_qtyord) || ' to ' || formatQty(NEW.coitem_qtyord) ) ); END IF; END IF; IF (NEW.coitem_price <> OLD.coitem_price) THEN IF (_changelog) THEN PERFORM postComment( 'ChangeLog', 'SI', NEW.coitem_id, ( 'Changed Unit Price from ' || formatPrice(OLD.coitem_price) || ' to ' || formatPrice(NEW.coitem_price) ) ); END IF; END IF; IF (NEW.coitem_scheddate <> OLD.coitem_scheddate) THEN PERFORM postEvent('SoitemSchedDateChanged', 'S', NEW.coitem_id, itemsite_warehous_id, (cohead_number || '-' || NEW.coitem_linenumber), NULL, NULL, NEW.coitem_scheddate, OLD.coitem_scheddate) FROM cohead, itemsite WHERE ( (cohead_id=NEW.coitem_cohead_id) AND (itemsite_id=NEW.coitem_itemsite_id) AND ( (NEW.coitem_scheddate <= (CURRENT_DATE + itemsite_eventfence)) OR (OLD.coitem_scheddate <= (CURRENT_DATE + itemsite_eventfence)) ) ); IF (_changelog) THEN PERFORM postComment( 'ChangeLog', 'SI', NEW.coitem_id, ( 'Changed Sched. Date from ' || formatDate(OLD.coitem_scheddate) || ' to ' || formatDate(NEW.coitem_scheddate)) ); END IF; END IF; IF ((NEW.coitem_status = 'C') AND (OLD.coitem_status <> 'C')) THEN NEW.coitem_closedate = CURRENT_TIMESTAMP; NEW.coitem_close_username = getEffectiveXtUser(); NEW.coitem_qtyreserved := 0; IF (_changelog) THEN PERFORM postComment('ChangeLog', 'SI', NEW.coitem_id, 'Closed'); END IF; END IF; IF ((NEW.coitem_status <> 'C') AND (OLD.coitem_status = 'C')) THEN NEW.coitem_closedate = NULL; NEW.coitem_close_username = NULL; IF (_changelog) THEN PERFORM postComment('ChangeLog', 'SI', NEW.coitem_id, 'Reopened'); END IF; END IF; IF ((NEW.coitem_status = 'X') AND (OLD.coitem_status <> 'X')) THEN IF ((OLD.coitem_order_type = 'W') AND (SELECT wo_status IN ('O', 'E', 'R') FROM wo WHERE (wo_id=OLD.coitem_order_id))) THEN -- Close any associated W/O PERFORM closeWo(OLD.coitem_order_id, FALSE, CURRENT_DATE); ELSIF (OLD.coitem_order_type = 'R') THEN -- Delete any associated P/R PERFORM deletePr(OLD.coitem_order_id); END IF; NEW.coitem_qtyreserved := 0; IF (_changelog) THEN PERFORM postComment('ChangeLog', 'SI', NEW.coitem_id, 'Canceled'); PERFORM postComment('ChangeLog', 'S', NEW.coitem_cohead_id, 'Line # '|| NEW.coitem_linenumber ||' Canceled'); END IF; PERFORM postEvent('SoitemCancelled', 'S', OLD.coitem_id, itemsite_warehous_id, (cohead_number || '-' || OLD.coitem_linenumber), NULL, NULL, NULL, NULL) FROM cohead, itemsite WHERE ( (cohead_id=OLD.coitem_cohead_id) AND (itemsite_id=OLD.coitem_itemsite_id) AND (OLD.coitem_scheddate <= (CURRENT_DATE + itemsite_eventfence)) ); END IF; IF ((NEW.coitem_qtyreserved <> OLD.coitem_qtyreserved) AND (_changelog)) THEN PERFORM postComment('ChangeLog', 'SI', NEW.coitem_id, 'Changed Qty Reserved to '|| NEW.coitem_qtyreserved); END IF; END IF; NEW.coitem_lastupdated = CURRENT_TIMESTAMP; -- Handle status for header IF (TG_OP = 'UPDATE') THEN IF (OLD.coitem_status <> NEW.coitem_status) THEN IF ( (SELECT (count(*) < 1) FROM coitem WHERE ((coitem_cohead_id=NEW.coitem_cohead_id) AND (coitem_id != NEW.coitem_id) AND (coitem_status='O')) ) AND (NEW.coitem_status<>'O') ) THEN UPDATE cohead SET cohead_status = 'C' WHERE ((cohead_id=NEW.coitem_cohead_id) AND (cohead_status='O')); ELSE UPDATE cohead SET cohead_status = 'O' WHERE ((cohead_id=NEW.coitem_cohead_id) AND (cohead_status='C')); END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._soitemtrigger() OWNER TO admin; -- -- Name: _sourcebeforeupserttrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _sourcebeforeupserttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF TG_OP = 'INSERT' THEN NEW.source_created := CURRENT_TIMESTAMP; ELSE NEW.source_created := OLD.source_created; NEW.source_docass_num := COALESCE(NEW.source_docass_num, OLD.source_docass_num); END IF; IF COALESCE(NEW.source_module, '') = '' THEN NEW.source_module = 'System'; END IF; IF COALESCE(NEW.source_docass_num, 0) = 0 THEN /* 0 == Documents::Uninitialized */ SELECT max(source_docass_num) + 1 FROM source INTO NEW.source_docass_num; END IF; NEW.source_last_modified := CURRENT_TIMESTAMP; RETURN NEW; END; $$; ALTER FUNCTION public._sourcebeforeupserttrigger() OWNER TO admin; -- -- Name: _taxauthafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _taxauthafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (EXISTS(SELECT 1 FROM checkhead WHERE checkhead_recip_id = OLD.taxauth_id AND checkhead_recip_type='T')) THEN RAISE EXCEPTION 'Cannot delete the tax authority % because checks have been written to it [xtuple: deleteTaxAuthority, -7, %]', OLD.taxauth_number, OLD.taxauth_number; END IF; IF (fetchMetricValue('DefaultTaxAuthority') = OLD.taxauth_id) THEN RAISE EXCEPTION 'Cannot delete the default Tax Authority [xtuple: deleteTaxAuthority, -8, %]', OLD.taxauth_code; END IF; IF (fetchMetricBool('TaxAuthChangeLog')) THEN PERFORM postComment(cmnttype_id, 'TAXAUTH', OLD.taxauth_id, 'Deleted "' || OLD.taxauth_number || '"') FROM cmnttype WHERE (cmnttype_name='ChangeLog'); END IF; RETURN OLD; END; $$; ALTER FUNCTION public._taxauthafterdeletetrigger() OWNER TO admin; -- -- Name: _taxauthaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _taxauthaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; BEGIN IF (TG_OP = 'INSERT') THEN -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE LOOP UPDATE crmacct SET crmacct_taxauth_id=NEW.taxauth_id, crmacct_name=NEW.taxauth_name WHERE crmacct_number=NEW.taxauth_code; IF (FOUND) THEN EXIT; END IF; BEGIN INSERT INTO crmacct(crmacct_number, crmacct_name, crmacct_active, crmacct_type, crmacct_taxauth_id ) VALUES (NEW.taxauth_code, NEW.taxauth_name, TRUE, 'O', NEW.taxauth_id); EXIT; EXCEPTION WHEN unique_violation THEN -- do nothing, and loop to try the UPDATE again END; END LOOP; /* TODO: default characteristic assignments based on what? */ ELSIF (TG_OP = 'UPDATE') THEN UPDATE crmacct SET crmacct_number = NEW.taxauth_code WHERE ((crmacct_taxauth_id=NEW.taxauth_id) AND (crmacct_number!=NEW.taxauth_code)); UPDATE crmacct SET crmacct_name = NEW.taxauth_name WHERE ((crmacct_taxauth_id=NEW.taxauth_id) AND (crmacct_name!=NEW.taxauth_name)); END IF; IF (fetchMetricBool('TaxAuthChangeLog')) THEN SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (_cmnttypeid IS NOT NULL) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.taxauth_code <> NEW.taxauth_code) THEN PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id, 'Code changed from "' || OLD.taxauth_code || '" to "' || NEW.taxauth_code || '"'); END IF; IF (OLD.taxauth_name <> NEW.taxauth_name) THEN PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id, 'Name changed from "' || OLD.taxauth_name || '" to "' || NEW.taxauth_name || '"'); END IF; IF (OLD.taxauth_extref <> NEW.taxauth_extref) THEN PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id, 'External Ref. changed from "' || OLD.taxauth_extref || '" to "' || NEW.taxauth_extref || '"'); END IF; IF (OLD.taxauth_addr_id <> NEW.taxauth_addr_id) THEN PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id, 'Address changed from ' || formatAddr(OLD.taxauth_addr_id) || ' to ' || formatAddr(NEW.taxauth_addr_id)); END IF; IF (OLD.taxauth_curr_id <> NEW.taxauth_curr_id) THEN PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id, 'Currency changed from "' || currConcat(OLD.taxauth_curr_id) || '" to "' || currConcat(NEW.taxauth_curr_id) || '"'); END IF; IF (OLD.taxauth_county <> NEW.taxauth_county) THEN PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id, 'County changed from "' || OLD.taxauth_county || '" to "' || NEW.taxauth_county || '"'); END IF; IF (OLD.taxauth_accnt_id <> NEW.taxauth_accnt_id) THEN PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id, 'Account changed from "' || formatGLAccount(OLD.taxauth_accnt_id) || '" to "' || formatGLAccount(NEW.taxauth_accnt_id) || '"'); END IF; END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._taxauthaftertrigger() OWNER TO admin; -- -- Name: _taxauthbeforedeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _taxauthbeforedeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (NOT checkPrivilege('MaintainTaxAuthorities')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Tax Authorities.'; END IF; UPDATE crmacct SET crmacct_taxauth_id = NULL WHERE crmacct_taxauth_id = OLD.taxauth_id; RETURN OLD; END; $$; ALTER FUNCTION public._taxauthbeforedeletetrigger() OWNER TO admin; -- -- Name: _taxauthbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _taxauthbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (NOT checkPrivilege('MaintainTaxAuthorities')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Tax Authorities.'; END IF; IF (NEW.taxauth_code IS NULL) THEN RAISE EXCEPTION 'You must supply a Tax Authority Code.'; END IF; IF (TG_OP = 'INSERT' AND fetchMetricText('CRMAccountNumberGeneration') IN ('A','O')) THEN PERFORM clearNumberIssue('CRMAccountNumber', NEW.taxauth_code); END IF; NEW.taxauth_code := UPPER(NEW.taxauth_code); RETURN NEW; END; $$; ALTER FUNCTION public._taxauthbeforetrigger() OWNER TO admin; -- -- Name: _termsafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _termsafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (fetchMetricValue('DefaultTerms') = OLD.terms_id) THEN RAISE EXCEPTION 'Cannot delete the default Terms [xtuple: terms, -1, %]', OLD.terms_code; END IF; RETURN OLD; END; $$; ALTER FUNCTION public._termsafterdeletetrigger() OWNER TO admin; -- -- Name: _todoitemtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _todoitemtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _recurid INTEGER; _newparentid INTEGER; BEGIN IF (TG_OP = 'DELETE') THEN SELECT recur_id INTO _recurid FROM recur WHERE ((recur_parent_id=OLD.todoitem_id) AND (recur_parent_type='TODO')); IF (_recurid IS NOT NULL) THEN RAISE DEBUG 'recur_id for deleted todoitem = %', _recurid; SELECT todoitem_id INTO _newparentid FROM todoitem WHERE ((todoitem_recurring_todoitem_id=OLD.todoitem_id) AND (todoitem_id!=OLD.todoitem_id)) ORDER BY todoitem_due_date LIMIT 1; RAISE DEBUG '_newparentid for deleted todoitem = %', COALESCE(_newparentid, NULL); -- client is responsible for warning about deleting a recurring todoitem IF (_newparentid IS NULL) THEN DELETE FROM recur WHERE recur_id=_recurid; ELSE UPDATE recur SET recur_parent_id=_newparentid WHERE recur_id=_recurid; UPDATE todoitem SET todoitem_recurring_todoitem_id=_newparentid WHERE todoitem_recurring_todoitem_id=OLD.todoitem_id AND todoitem_id != OLD.todoitem_id; RAISE DEBUG 'reparented recurrence'; END IF; END IF; DELETE FROM alarm WHERE ((alarm_source='TODO') AND (alarm_source_id=OLD.todoitem_id)); DELETE FROM docass WHERE docass_source_id = OLD.todoitem_id AND docass_source_type = 'TODO'; DELETE FROM docass WHERE docass_target_id = OLD.todoitem_id AND docass_target_type = 'TODO'; RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._todoitemtrigger() OWNER TO admin; -- -- Name: _trialbalaltertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _trialbalaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _accntid INTEGER[]; BEGIN IF (TG_OP='DELETE') THEN IF (SELECT period_closed FROM period WHERE period_id=OLD.trialbal_period_id) THEN RAISE EXCEPTION 'You may not delete Trial Balance Transactions in closed periods.'; END IF; RETURN OLD; END IF; IF (TG_OP='INSERT' OR TG_OP='UPDATE') THEN IF (coalesce(fetchMetricValue('GLCompanySize'),0) = 0) THEN -- Get the default account number for year end closing _accntid := fetchmetricvalue('YearEndEquityAccount'); ELSE -- Multi-company setup _accntid := (SELECT array_agg(company_yearend_accnt_id) FROM company); END IF; If (NEW.trialbal_accnt_id = ANY(_accntid) OR (NEW.trialbal_beginning = 0.00 AND NEW.trialbal_ending = 0.00)) THEN -- Dont check new accounts or Retained Earnings account ELSE IF (SELECT period_closed FROM period WHERE period_id=NEW.trialbal_period_id) THEN RAISE EXCEPTION 'You may not alter Trial Balance records in a closed Period.'; END IF; END IF; RETURN NEW; END IF; END; $$; ALTER FUNCTION public._trialbalaltertrigger() OWNER TO admin; -- -- Name: _uomconvupdate(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _uomconvupdate() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN UPDATE itemuomconv SET itemuomconv_to_value = NEW.uomconv_to_value, itemuomconv_from_value = NEW.uomconv_from_value, itemuomconv_fractional = NEW.uomconv_fractional WHERE((itemuomconv_from_uom_id = NEW.uomconv_from_uom_id) AND (itemuomconv_to_uom_id = NEW.uomconv_to_uom_id)); RETURN NEW; END; $$; ALTER FUNCTION public._uomconvupdate() OWNER TO admin; -- -- Name: _usrprefaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _usrprefaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE IF (NEW.usrpref_name='active') THEN LOOP UPDATE crmacct SET crmacct_usr_username=NEW.usrpref_username WHERE crmacct_number=UPPER(NEW.usrpref_username); IF (FOUND) THEN EXIT; END IF; BEGIN INSERT INTO crmacct(crmacct_number, crmacct_active, crmacct_type, crmacct_usr_username ) VALUES (NEW.usrpref_username, NEW.usrpref_value::BOOL, 'I', NEW.usrpref_username); EXIT; EXCEPTION WHEN unique_violation THEN -- do nothing, and loop to try the UPDATE again END; END LOOP; ELSIF (NEW.usrpref_name='propername') THEN LOOP UPDATE crmacct SET crmacct_name=NEW.usrpref_value WHERE crmacct_number=UPPER(NEW.usrpref_username); IF (FOUND) THEN EXIT; END IF; BEGIN INSERT INTO crmacct(crmacct_number, crmacct_active, crmacct_name, crmacct_type, crmacct_usr_username ) VALUES (UPPER(NEW.usrpref_username), TRUE, NEW.usrpref_value, 'I', NEW.usrpref_username); EXIT; EXCEPTION WHEN unique_violation THEN -- do nothing, and loop to try the UPDATE again END; END LOOP; END IF; ELSIF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._usrprefaftertrigger() OWNER TO admin; -- -- Name: _usrprefbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _usrprefbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF NOT (checkPrivilege('MaintainUsers') OR checkPrivilege('MaintainPreferencesOthers') OR (checkPrivilege('MaintainPreferencesSelf'))) THEN -- 2 IFs because plpgsql doesn't always evaluate boolean exprs left-to-right IF (TG_OP = 'DELETE') THEN IF NOT (OLD.usrpref_name LIKE '%/checked' OR OLD.usrpref_name LIKE '%/columnsShown') THEN RAISE EXCEPTION 'You do not have privileges to change this User Preference.'; END IF; ELSIF (NEW.usrpref_username = getEffectiveXtUser()) THEN IF NOT (NEW.usrpref_name LIKE '%/checked' OR NEW.usrpref_name LIKE '%/columnsShown') THEN RAISE EXCEPTION 'You do not have privileges to change this User Preference.'; END IF; END IF; END IF; IF (TG_OP IN ('INSERT', 'UPDATE')) THEN IF (NEW.usrpref_name = 'locale') THEN IF NOT EXISTS(SELECT locale_id FROM locale WHERE locale_id = NEW.usrpref_value::INTEGER) THEN RAISE EXCEPTION 'You must supply a valid Locale.'; END IF; ELSIF (NEW.usrpref_name IN ('agent', 'active')) THEN IF (NEW.usrpref_value NOT IN ('t', 'f')) THEN RAISE EXCEPTION '% must be either "t" or "f"', NEW.usrpref_name; END IF; END IF; ELSIF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._usrprefbeforetrigger() OWNER TO admin; -- -- Name: _usrprivtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _usrprivtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF NOT checkPrivilege('MaintainUsers') THEN RAISE EXCEPTION '% does not have privileges to modify user privileges.', getEffectiveXtUser(); END IF; -- This looks like a candidate for a foreign key but isn't. -- fkeys don't work if the foreign key value resides in a child of the -- table and not the table itself. IF ((TG_OP = 'UPDATE' OR TG_OP = 'INSERT') AND (NOT EXISTS(SELECT priv_id FROM priv WHERE (priv_id=NEW.usrpriv_priv_id)))) THEN RAISE EXCEPTION 'Privilege id % does not exist or is part of a disabled package.', NEW.usrpriv_priv_id; RETURN OLD; ELSIF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._usrprivtrigger() OWNER TO admin; -- -- Name: _vendaddrtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _vendaddrtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check BOOLEAN; _vendname TEXT; BEGIN -- Checks SELECT checkPrivilege('MaintainVendors') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to maintain Vendors.'; END IF; IF (TG_OP IN ('INSERT','UPDATE')) THEN IF (LENGTH(COALESCE(NEW.vendaddr_code, ''))=0) THEN RAISE EXCEPTION 'You must supply a valid Vendor Address Number.'; END IF; IF (LENGTH(COALESCE(NEW.vendaddr_name, ''))=0) THEN RAISE EXCEPTION 'You must supply a valid Vendor Address Name.'; END IF; IF (NEW.vendaddr_vend_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Vendor ID.'; END IF; SELECT vendaddr_code INTO _vendname FROM vendaddrinfo WHERE ( (vendaddr_vend_id=NEW.vendaddr_vend_id) AND (UPPER(vendaddr_code)=UPPER(NEW.vendaddr_code)) AND (vendaddr_id<>NEW.vendaddr_id) ); IF (FOUND) THEN RAISE EXCEPTION 'The Vendor Address Number entered cannot be used as it is in use.'; END IF; END IF; IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._vendaddrtrigger() OWNER TO admin; -- -- Name: _vendaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _vendaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; BEGIN IF (TG_OP = 'INSERT') THEN -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE LOOP UPDATE crmacct SET crmacct_vend_id=NEW.vend_id, crmacct_name=NEW.vend_name WHERE crmacct_number=NEW.vend_number; IF (FOUND) THEN EXIT; END IF; BEGIN INSERT INTO crmacct(crmacct_number, crmacct_name, crmacct_active, crmacct_type, crmacct_vend_id, crmacct_cntct_id_1, crmacct_cntct_id_2 ) VALUES (NEW.vend_number, NEW.vend_name, NEW.vend_active, 'O', NEW.vend_id, NEW.vend_cntct1_id, NEW.vend_cntct2_id); EXIT; EXCEPTION WHEN unique_violation THEN -- do nothing, and loop to try the UPDATE again END; END LOOP; /* TODO: default characteristic assignments based on vendgrp? */ ELSIF (TG_OP = 'UPDATE') THEN UPDATE crmacct SET crmacct_number = NEW.vend_number WHERE ((crmacct_vend_id=NEW.vend_id) AND (crmacct_number!=NEW.vend_number)); UPDATE crmacct SET crmacct_name = NEW.vend_name WHERE ((crmacct_vend_id=NEW.vend_id) AND (crmacct_name!=NEW.vend_name)); END IF; IF (fetchMetricBool('VendorChangeLog')) THEN SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (_cmnttypeid IS NOT NULL) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'V', NEW.vend_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.vend_number <> NEW.vend_number) THEN PERFORM postComment(_cmnttypeid, 'V', NEW.vend_id, ('Number Changed from "' || OLD.vend_number || '" to "' || NEW.vend_number || '"') ); END IF; IF (OLD.vend_name <> NEW.vend_name) THEN PERFORM postComment( _cmnttypeid, 'V', NEW.vend_id, ('Name Changed from "' || OLD.vend_name || '" to "' || NEW.vend_name || '"') ); END IF; IF (OLD.vend_active <> NEW.vend_active) THEN PERFORM postComment(_cmnttypeid, 'V', NEW.vend_id, CASE WHEN NEW.vend_active THEN 'Activated' ELSE 'Deactivated' END); END IF; END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._vendaftertrigger() OWNER TO admin; -- -- Name: _vendinfoafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _vendinfoafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF EXISTS(SELECT 1 FROM checkhead WHERE ((checkhead_recip_id=OLD.vend_id) AND (checkhead_recip_type='V'))) THEN RAISE EXCEPTION '[xtuple: deleteVendor, -7]'; END IF; DELETE FROM taxreg WHERE ((taxreg_rel_type='V') AND (taxreg_rel_id=OLD.vend_id)); IF (fetchMetricBool('VendorChangeLog')) THEN PERFORM postComment(cmnttype_id, 'V', OLD.vend_id, ('Deleted "' || OLD.vend_number || '"')) FROM cmnttype WHERE (cmnttype_name='ChangeLog'); END IF; DELETE FROM charass WHERE charass_target_type = 'V' AND charass_target_id = OLD.vend_id; RETURN OLD; END; $$; ALTER FUNCTION public._vendinfoafterdeletetrigger() OWNER TO admin; -- -- Name: _vendinfobeforedeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _vendinfobeforedeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF NOT (checkPrivilege('MaintainVendors')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Vendors.'; END IF; DELETE FROM itemsrcp WHERE itemsrcp_itemsrc_id IN (SELECT itemsrc_id FROM itemsrc WHERE itemsrc_vend_id=OLD.vend_id); DELETE FROM itemsrc WHERE (itemsrc_vend_id=OLD.vend_id); DELETE FROM vendaddrinfo WHERE (vendaddr_vend_id=OLD.vend_id); DELETE FROM docass WHERE docass_source_id = OLD.vend_id AND docass_source_type = 'V'; DELETE FROM docass WHERE docass_target_id = OLD.vend_id AND docass_target_type = 'V'; UPDATE crmacct SET crmacct_vend_id = NULL WHERE crmacct_vend_id = OLD.vend_id; RETURN OLD; END; $$; ALTER FUNCTION public._vendinfobeforedeletetrigger() OWNER TO admin; -- -- Name: _vendtrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _vendtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF NOT (checkPrivilege('MaintainVendors')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Vendors.'; END IF; IF (LENGTH(COALESCE(NEW.vend_number, ''))=0) THEN RAISE EXCEPTION 'You must supply a valid Vendor Number.'; END IF; IF (LENGTH(COALESCE(NEW.vend_name, ''))=0) THEN RAISE EXCEPTION 'You must supply a valid Vendor Name.'; END IF; IF (NEW.vend_vendtype_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Vendor Type ID.'; END IF; IF (NEW.vend_terms_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Terms Code ID.'; END IF; IF (TG_OP = 'INSERT' AND fetchMetricText('CRMAccountNumberGeneration') IN ('A','O')) THEN PERFORM clearNumberIssue('CRMAccountNumber', NEW.vend_number); END IF; NEW.vend_number := UPPER(NEW.vend_number); RETURN NEW; END; $$; ALTER FUNCTION public._vendtrigger() OWNER TO admin; -- -- Name: _vodistaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _vodistaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; BEGIN IF ( (TG_OP = 'UPDATE') OR (TG_OP = 'DELETE') ) THEN IF (OLD.vodist_tax_id <> -1) THEN -- Delete any existing voheadtax adjustment records DELETE FROM voheadtax WHERE ( (taxhist_parent_id=OLD.vodist_vohead_id) AND (taxhist_tax_id=OLD.vodist_tax_id) AND (taxhist_taxtype_id=getAdjustmentTaxTypeId()) ); END IF; END IF; IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; -- Cache Voucher Head SELECT * INTO _r FROM vohead WHERE (vohead_id=NEW.vodist_vohead_id); IF (NOT FOUND) THEN RAISE EXCEPTION 'Voucher head not found'; END IF; IF (NEW.vodist_tax_id <> -1) THEN -- Insert adjustment voheadtax INSERT INTO voheadtax ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate ) VALUES ( NEW.vodist_vohead_id, getAdjustmentTaxTypeId(), NEW.vodist_tax_id, 0, NULL, 1, 0, 0, (NEW.vodist_amount * -1), _r.vohead_docdate ); END IF; RETURN NEW; END; $$; ALTER FUNCTION public._vodistaftertrigger() OWNER TO admin; -- -- Name: _vodistbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _vodistbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF (TG_OP = 'DELETE') THEN IF (OLD.vodist_tax_id <> -1) THEN -- Delete any existing voheadtax adjustment records DELETE FROM voheadtax WHERE ( (taxhist_parent_id=OLD.vodist_vohead_id) AND (taxhist_tax_id=OLD.vodist_tax_id) AND (taxhist_taxtype_id=getAdjustmentTaxTypeId()) ); END IF; RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._vodistbeforetrigger() OWNER TO admin; -- -- Name: _voheadafterdeletetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _voheadafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'VCH' AND charass_target_id = OLD.vohead_id; RETURN OLD; END; $$; ALTER FUNCTION public._voheadafterdeletetrigger() OWNER TO admin; -- -- Name: _voheadaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _voheadaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN PERFORM releaseVoNumber(CAST(OLD.vohead_number AS INTEGER)); RETURN OLD; END IF; IF (TG_OP = 'INSERT') THEN PERFORM clearNumberIssue('VcNumber', NEW.vohead_number); RETURN NEW; END IF; IF (TG_OP = 'UPDATE') THEN IF ( (COALESCE(NEW.vohead_taxzone_id,-1) <> COALESCE(OLD.vohead_taxzone_id,-1)) OR (NEW.vohead_docdate <> OLD.vohead_docdate) OR (NEW.vohead_curr_id <> OLD.vohead_curr_id) ) THEN PERFORM calculateTaxHist( 'voitemtax', voitem_id, NEW.vohead_taxzone_id, voitem_taxtype_id, NEW.vohead_docdate, NEW.vohead_curr_id, (vodist_amount * -1) ) FROM voitem JOIN vodist ON ( (vodist_vohead_id=voitem_vohead_id) AND (vodist_poitem_id=voitem_poitem_id) ) WHERE (voitem_vohead_id = NEW.vohead_id); END IF; -- Touch any Misc Tax Distributions so voheadtax is recalculated IF (NEW.vohead_docdate <> OLD.vohead_docdate) THEN UPDATE vodist SET vodist_vohead_id=NEW.vohead_id WHERE ( (vodist_vohead_id=OLD.vohead_id) AND (vodist_tax_id <> -1) ); END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._voheadaftertrigger() OWNER TO admin; -- -- Name: _voheadbeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _voheadbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _recurid INTEGER; _newparentid INTEGER; BEGIN IF (TG_OP = 'DELETE') THEN IF (OLD.vohead_posted) THEN -- Cannot delete a posted voucher RAISE EXCEPTION 'Cannot delete a posted voucher'; END IF; /* TODO: is setting recv_invoiced and poreject_invoiced to FALSE correct? this behavior is inherited from the now-defunct deleteVoucher. */ UPDATE recv SET recv_vohead_id = NULL, recv_voitem_id = NULL, recv_invoiced = FALSE WHERE recv_vohead_id = OLD.vohead_id; UPDATE poreject SET poreject_vohead_id = NULL, poreject_voitem_id = NULL, poreject_invoiced = FALSE WHERE poreject_vohead_id = OLD.vohead_id; DELETE FROM vodist WHERE vodist_vohead_id = OLD.vohead_id; DELETE FROM voheadtax WHERE taxhist_parent_id = OLD.vohead_id; DELETE FROM voitem WHERE voitem_vohead_id = OLD.vohead_id; SELECT recur_id INTO _recurid FROM recur WHERE ((recur_parent_id=OLD.vohead_id) AND (recur_parent_type='V')); IF (_recurid IS NOT NULL) THEN SELECT vohead_id INTO _newparentid FROM vohead WHERE ((vohead_recurring_vohead_id=OLD.vohead_id) AND (vohead_id!=OLD.vohead_id)) ORDER BY vohead_docdate LIMIT 1; IF (_newparentid IS NULL) THEN DELETE FROM recur WHERE recur_id=_recurid; ELSE UPDATE recur SET recur_parent_id=_newparentid WHERE recur_id=_recurid; UPDATE vohead SET vohead_recurring_vohead_id=_newparentid WHERE vohead_recurring_vohead_id=OLD.vohead_id AND vohead_id!=OLD.vohead_id; END IF; END IF; RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._voheadbeforetrigger() OWNER TO admin; -- -- Name: _voitemaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _voitemaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; -- Cache Voucher Head SELECT * INTO _r FROM vohead WHERE (vohead_id=NEW.voitem_vohead_id); IF (NOT FOUND) THEN RAISE EXCEPTION 'Voucher head not found'; END IF; -- Calculate Tax PERFORM calculateTaxHist( 'voitemtax', NEW.voitem_id, COALESCE(_r.vohead_taxzone_id, -1), NEW.voitem_taxtype_id, COALESCE(_r.vohead_docdate, CURRENT_DATE), COALESCE(_r.vohead_curr_id, -1), COALESCE(SUM(vodist_amount * -1), 0) ) FROM vodist WHERE ( (vodist_vohead_id=_r.vohead_id) AND (vodist_poitem_id=NEW.voitem_poitem_id) ); RETURN NEW; END; $$; ALTER FUNCTION public._voitemaftertrigger() OWNER TO admin; -- -- Name: _voitembeforetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _voitembeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF (TG_OP = 'DELETE') THEN DELETE FROM voitemtax WHERE (taxhist_parent_id=OLD.voitem_id); RETURN OLD; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._voitembeforetrigger() OWNER TO admin; -- -- Name: _warehoustrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _warehoustrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; _check BOOLEAN; _checkId INTEGER; BEGIN -- Checks -- Start with privileges IF (TG_OP = 'INSERT') THEN SELECT checkPrivilege('MaintainWarehouses') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to add new Sites.'; END IF; ELSE SELECT checkPrivilege('MaintainWarehouses') OR checkPrivilege('IssueCountTags') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to alter a Site.'; END IF; END IF; -- Code is required IF (LENGTH(COALESCE(NEW.warehous_code,''))=0) THEN RAISE EXCEPTION 'You must supply a valid Site Code.'; END IF; -- Sitetype is required IF (NEW.warehous_sitetype_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Site Type.'; END IF; -- Cost Category is required for Transit types IF ((NEW.warehous_transit) AND (NEW.warehous_costcat_id IS NULL)) THEN RAISE EXCEPTION 'You must supply a valid Cost Category for Transit Sites.'; END IF; -- Code must be unique SELECT warehous_id INTO _checkId FROM whsinfo WHERE ( (UPPER(warehous_code)=UPPER(NEW.warehous_code)) AND (warehous_id<>NEW.warehous_id) ); IF (FOUND) THEN RAISE EXCEPTION 'You must supply a unique Site Code.'; END IF; -- Count Tag Prefix must be unique IF (TG_OP = 'INSERT') THEN SELECT warehous_id INTO _checkId FROM whsinfo WHERE (warehous_counttag_prefix=NEW.warehous_counttag_prefix); ELSE SELECT warehous_id INTO _checkId FROM whsinfo WHERE ( (warehous_counttag_prefix=NEW.warehous_counttag_prefix) AND (warehous_id<>NEW.warehous_id) ); END IF; IF (FOUND) THEN RAISE EXCEPTION 'You must supply a unique Count Tag Prefix.'; END IF; -- Check Complete -- Change Log IF ( SELECT (metric_value='t') FROM metric WHERE (metric_name='WarehouseChangeLog') ) THEN -- Cache the cmnttype_id for ChangeLog SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (FOUND) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'WH', NEW.warehous_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.warehous_code <> NEW.warehous_code) THEN PERFORM postComment( _cmnttypeid, 'WH', NEW.warehous_id, ('Code Changed from "' || OLD.warehous_code || '" to "' || NEW.warehous_code || '"') ); END IF; IF (OLD.warehous_descrip <> NEW.warehous_descrip) THEN PERFORM postComment( _cmnttypeid, 'WH', NEW.warehous_id, ( 'Description Changed from "' || OLD.warehous_descrip || '" to "' || NEW.warehous_descrip || '"' ) ); END IF; IF (OLD.warehous_active <> NEW.warehous_active) THEN IF (NEW.warehous_active) THEN PERFORM postComment(_cmnttypeid, 'WH', NEW.warehous_id, 'Activated'); ELSE PERFORM postComment(_cmnttypeid, 'WH', NEW.warehous_id, 'Deactivated'); END IF; END IF; END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._warehoustrigger() OWNER TO admin; -- -- Name: _whsezonetrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _whsezonetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check BOOLEAN; _checkId INTEGER; BEGIN -- Checks -- Start with privileges IF (TG_OP = 'INSERT') THEN SELECT checkPrivilege('MaintainWarehouses') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to add new Site Zones.'; END IF; ELSE SELECT checkPrivilege('MaintainWarehouses') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to alter a Site Zone.'; END IF; END IF; -- Name is required IF (LENGTH(COALESCE(NEW.whsezone_name,''))=0) THEN RAISE EXCEPTION 'You must supply a valid Site Zone Name.'; END IF; -- Site is required IF (NEW.whsezone_warehous_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Site.'; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._whsezonetrigger() OWNER TO admin; -- -- Name: _womatlaftertrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _womatlaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF (TG_OP = 'INSERT') THEN -- Create any required P/R's PERFORM createPr('W', NEW.womatl_id) FROM itemsite WHERE ((itemsite_id=NEW.womatl_itemsite_id) AND (itemsite_createpr)); END IF; RETURN NEW; END; $$; ALTER FUNCTION public._womatlaftertrigger() OWNER TO admin; -- -- Name: _wotrigger(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION _wotrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF (TG_OP = 'INSERT') THEN PERFORM postEvent('WoCreated', 'W', NEW.wo_id, itemsite_warehous_id, (NEW.wo_number || '-' || NEW.wo_subnumber), NULL, NULL, NULL, NULL) FROM itemsite WHERE (itemsite_id=NEW.wo_itemsite_id) AND (NEW.wo_duedate <= (CURRENT_DATE + itemsite_eventfence)); PERFORM postComment('ChangeLog', 'W', NEW.wo_id, 'Created'); IF (fetchMetricText('WONumberGeneration') IN ('A','O')) THEN --- clear the number from the issue cache PERFORM clearNumberIssue('WoNumber', NEW.wo_number); END IF; RETURN NEW; ELSE IF (TG_OP = 'DELETE') THEN PERFORM postEvent('WoCancelled', 'W', OLD.wo_id, itemsite_warehous_id, (OLD.wo_number || '-' || OLD.wo_subnumber), NULL, NULL, NULL, NULL) FROM itemsite WHERE (itemsite_id=OLD.wo_itemsite_id) AND (OLD.wo_duedate <= (CURRENT_DATE + itemsite_eventfence)); DELETE FROM docass WHERE docass_source_id = OLD.wo_id AND docass_source_type = 'W'; DELETE FROM docass WHERE docass_target_id = OLD.wo_id AND docass_target_type = 'W'; DELETE FROM comment WHERE ( (comment_source='W') AND (comment_source_id=OLD.wo_id) ); DELETE FROM charass WHERE ((charass_target_type='W') AND (charass_target_id=OLD.wo_id)); RETURN OLD; ELSE IF (TG_OP = 'UPDATE') THEN IF (NEW.wo_qtyord <> OLD.wo_qtyord) THEN PERFORM postEvent('WoQtyChanged', 'W', NEW.wo_id, itemsite_warehous_id, (NEW.wo_number || '-' || NEW.wo_subnumber), NEW.wo_qtyord, OLD.wo_qtyord, NULL, NULL) FROM itemsite WHERE (itemsite_id=NEW.wo_itemsite_id) AND ( (NEW.wo_duedate <= (CURRENT_DATE + itemsite_eventfence)) OR (OLD.wo_duedate <= (CURRENT_DATE + itemsite_eventfence)) ); PERFORM postComment( 'ChangeLog', 'W', NEW.wo_id, ( 'Qty. Ordered Changed from ' || formatQty(OLD.wo_qtyord) || ' to ' || formatQty(NEW.wo_qtyord ) ) ); END IF; IF (NEW.wo_duedate <> OLD.wo_duedate) THEN PERFORM postEvent('WoDueDateChanged', 'W', NEW.wo_id, itemsite_warehous_id, (NEW.wo_number || '-' || NEW.wo_subnumber), NULL, NULL, NEW.wo_duedate, OLD.wo_duedate) FROM itemsite WHERE (itemsite_id=NEW.wo_itemsite_id) AND ( (NEW.wo_duedate <= (CURRENT_DATE + itemsite_eventfence)) OR (OLD.wo_duedate <= (CURRENT_DATE + itemsite_eventfence)) ); PERFORM postComment( 'ChangeLog', 'W', NEW.wo_id, ( 'Due Date Changed from ' || formatDate(OLD.wo_duedate) || ' to ' || formatDate(NEW.wo_duedate ) ) ); END IF; IF (NEW.wo_status <> OLD.wo_status) THEN PERFORM postComment( 'ChangeLog', 'W', NEW.wo_id, ('Status Changed from ' || OLD.wo_status || ' to ' || NEW.wo_status) ); END IF; END IF; END IF; END IF; IF (TG_OP = 'UPDATE') THEN IF (NEW.wo_prj_id <> OLD.wo_prj_id) THEN UPDATE wo SET wo_prj_id=NEW.wo_prj_id WHERE (wo_ordtype='W') AND (wo_ordid=NEW.wo_id); END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public._wotrigger() OWNER TO admin; -- -- Name: acknowledgemessage(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION acknowledgemessage(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pMsgid ALIAS FOR $1; BEGIN UPDATE msguser SET msguser_viewed=CURRENT_TIMESTAMP WHERE ( (msguser_msg_id=pMsgid) AND (msguser_username=getEffectiveXtUser()) ); RETURN TRUE; END; $_$; ALTER FUNCTION public.acknowledgemessage(integer) OWNER TO admin; -- -- Name: actcost(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION actcost(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN actCost($1, NULL, baseCurrId()); END; $_$; ALTER FUNCTION public.actcost(integer) OWNER TO admin; -- -- Name: actcost(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION actcost(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN actCost($1, $2, baseCurrId()); END; $_$; ALTER FUNCTION public.actcost(integer, integer) OWNER TO admin; -- -- Name: actcost(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION actcost(integer, integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pBomitemid ALIAS FOR $2; pCurrid ALIAS FOR $3; _cost NUMERIC; BEGIN -- Return actual cost in the given currency at the current conversion rate SELECT SUM(CASE WHEN (bomitemcost_id IS NOT NULL) THEN ROUND(currToCurr(bomitemcost_curr_id, pCurrid, bomitemcost_actcost, CURRENT_DATE), 6) ELSE ROUND(currToCurr(itemcost_curr_id, pCurrid, itemcost_actcost, CURRENT_DATE), 6) END) INTO _cost FROM itemcost LEFT OUTER JOIN bomitemcost ON (bomitemcost_bomitem_id=pBomitemid AND bomitemcost_costelem_id=itemcost_costelem_id) WHERE (itemcost_item_id=pItemid); IF (_cost IS NULL) THEN RETURN 0; ELSE RETURN _cost; END IF; END; $_$; ALTER FUNCTION public.actcost(integer, integer, integer) OWNER TO admin; -- -- Name: addrusecount(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION addrusecount(integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAddrId ALIAS FOR $1; _fk RECORD; _r RECORD; _seq INTEGER; _col TEXT; _qry TEXT; _count INTEGER = 0; BEGIN -- Determine where this address is used by analyzing foreign key linkages -- TO DO: Can this be rationalized with cntctused(int)? FOR _fk IN SELECT pg_namespace.nspname AS schemaname, con.relname AS tablename, conkey AS seq, conrelid AS class_id FROM pg_constraint, pg_class f, pg_class con, pg_namespace WHERE confrelid=f.oid AND conrelid=con.oid AND f.relname = 'addr' AND con.relnamespace=pg_namespace.oid AND con.relname NOT IN ('pohead') -- exception(s) where address key doesn't actually drive document information LOOP -- Validate IF (ARRAY_UPPER(_fk.seq,1) > 1) THEN RAISE EXCEPTION 'Checks to tables where the address is one of multiple foreign key columns is not supported. Error on Table: %', pg_namespace.nspname || '.' || con.relname; END IF; _seq := _fk.seq[1]; -- Get the specific column name SELECT attname INTO _col FROM pg_attribute, pg_class WHERE ((attrelid=pg_class.oid) AND (pg_class.oid=_fk.class_id) AND (attnum=_seq)); -- See if there are dependencies _qry := 'SELECT * FROM ' || _fk.schemaname || '.' || _fk.tablename || ' WHERE ('|| _col || '=' || pAddrId || ');'; FOR _r IN EXECUTE _qry LOOP _count := _count + 1; END LOOP; END LOOP; RETURN _count; END; $_$; ALTER FUNCTION public.addrusecount(integer) OWNER TO admin; -- -- Name: addtaxtoglseries(integer, text, text, text, integer, date, date, text, integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION addtaxtoglseries(integer, text, text, text, integer, date, date, text, integer, text) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; pSource ALIAS FOR $2; pDocType ALIAS FOR $3; pDocNumber ALIAS FOR $4; pCurrId ALIAS FOR $5; pExchDate ALIAS FOR $6; pDistDate ALIAS FOR $7; pTableName ALIAS FOR $8; pParentId ALIAS FOR $9; pNotes ALIAS FOR $10; _count INTEGER := 0; _baseTax NUMERIC := 0; _returnVal NUMERIC := 0; _t RECORD; _test INTEGER := 0; BEGIN -- This is just a fancy select statement on taxhist. -- Because all tax records tables inherit from taxhist, -- we can use the same select statement for all. -- https://www.postgresql.org/docs/8.1/static/ddl-inherit.html -- pTableName in the where clause narrows down the selection -- to the correct sub table. FOR _t IN SELECT * FROM taxhist JOIN tax ON (tax_id = taxhist_tax_id) JOIN pg_class ON (pg_class.oid = taxhist.tableoid) WHERE ( (taxhist_parent_id = pParentId) AND (relname = pTableName) ) LOOP _count := _count + 1; _baseTax := currToBase(pCurrId, _t.taxhist_tax, pExchDate); _returnVal := _returnVal + _baseTax; PERFORM insertIntoGLSeries( pSequence, pSource, pDocType, pDocNumber, _t.tax_sales_accnt_id, _baseTax, pDistDate, pNotes ); UPDATE taxhist SET taxhist_docdate=pExchDate, taxhist_distdate=pDistDate, taxhist_curr_id=pCurrId, taxhist_curr_rate=curr_rate FROM curr_rate WHERE ((taxhist_id=_t.taxhist_id) AND (pCurrId=curr_id) AND ( pExchDate BETWEEN curr_effective AND curr_expires) ); END LOOP; RETURN _returnVal; END; $_$; ALTER FUNCTION public.addtaxtoglseries(integer, text, text, text, integer, date, date, text, integer, text) OWNER TO admin; -- -- Name: addtopackinglistbatch(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION addtopackinglistbatch(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; returnVal INTEGER; BEGIN -- MIN because error codes are negative SELECT MIN(addToPackingListBatch('SO', pSoheadid, shiphead_id)) INTO returnVal FROM shiphead WHERE ((shiphead_order_id=pSoheadid) AND (NOT shiphead_shipped) AND (shiphead_order_type='SO')); IF (NOT FOUND OR returnVal IS NULL) THEN returnVal := addToPackingListBatch('SO', pSoheadid, NULL); END IF; RETURN returnVal; END; $_$; ALTER FUNCTION public.addtopackinglistbatch(integer) OWNER TO admin; -- -- Name: addtopackinglistbatch(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION addtopackinglistbatch(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN addToPackingListBatch('SO', $1, $2); END; $_$; ALTER FUNCTION public.addtopackinglistbatch(integer, integer) OWNER TO admin; -- -- Name: addtopackinglistbatch(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION addtopackinglistbatch(text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pheadtype ALIAS FOR $1; pheadid ALIAS FOR $2; returnVal INTEGER; BEGIN -- MIN because error codes are negative SELECT MIN(addToPackingListBatch(pheadtype, pheadid, shiphead_id)) INTO returnVal FROM shiphead WHERE ((shiphead_order_id=pheadid) AND (NOT shiphead_shipped) AND (shiphead_order_type=pheadtype)); IF (NOT FOUND OR returnVal IS NULL) THEN returnVal := addToPackingListBatch(pheadtype, pheadid, NULL); END IF; RETURN returnVal; END; $_$; ALTER FUNCTION public.addtopackinglistbatch(text, integer) OWNER TO admin; -- -- Name: addtopackinglistbatch(text, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION addtopackinglistbatch(text, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pheadtype ALIAS FOR $1; pheadid ALIAS FOR $2; pshipheadid ALIAS FOR $3; _check INTEGER; BEGIN SELECT pack_id INTO _check FROM pack WHERE ((pack_head_id=pheadid) AND ((pack_shiphead_id=pshipheadid) OR (pshipheadid IS NULL AND pack_shiphead_id IS NULL)) AND (pack_head_type=pheadtype) ); IF (NOT FOUND) THEN INSERT INTO pack ( pack_head_type, pack_head_id, pack_shiphead_id, pack_printed ) VALUES ( pheadtype, pheadid, pshipheadid, FALSE ); -- Auto Firm Sales Orders conditionally based on metric IF ( (pheadtype = 'SO') AND (fetchMetricBool('FirmSalesOrderPackingList')) ) THEN UPDATE coitem SET coitem_firm=TRUE WHERE (coitem_cohead_id=pheadid); END IF; END IF; RETURN pheadid; END; $_$; ALTER FUNCTION public.addtopackinglistbatch(text, integer, integer) OWNER TO admin; -- -- Name: addtopackinglistbatch(integer, text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION addtopackinglistbatch(integer, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pwarehousid ALIAS FOR $1; pheadtype ALIAS FOR $2; pheadid ALIAS FOR $3; returnVal INTEGER; BEGIN -- MIN because error codes are negative SELECT MIN(addToPackingListBatch(pheadtype, pheadid, getOpenShipmentId(pheadtype, pheadid, pwarehousid))) INTO returnVal; IF (NOT FOUND OR returnVal IS NULL) THEN returnVal := addToPackingListBatch(pheadtype, pheadid, NULL); END IF; RETURN returnVal; END; $_$; ALTER FUNCTION public.addtopackinglistbatch(integer, text, integer) OWNER TO admin; -- -- Name: adjustinvvalue(integer, numeric, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION adjustinvvalue(integer, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pNewValue ALIAS FOR $2; pAccountid ALIAS FOR $3; _delta NUMERIC; _glreturn INTEGER; _invhistid INTEGER; _itemlocSeries INTEGER; BEGIN SELECT pNewValue - itemsite_value INTO _delta FROM itemsite WHERE (itemsite_id=pItemsiteid) FOR UPDATE; IF (NOT FOUND) THEN RETURN -1; END IF; SELECT insertGLTransaction('I/M', '', 'Post Value', 'Inventory Value Adjustment for ' || item_number, COALESCE (pAccountid, costcat_adjustment_accnt_id), costcat_asset_accnt_id, -1, _delta, CURRENT_DATE) INTO _glreturn FROM itemsite JOIN costcat ON (itemsite_costcat_id=costcat_id) JOIN item ON (itemsite_item_id=item_id) WHERE (itemsite_id=pItemsiteid); -- Create the AD transaction INSERT INTO invhist ( invhist_itemsite_id, invhist_transdate, invhist_transtype, invhist_invqty, invhist_qoh_before, invhist_qoh_after, invhist_docnumber, invhist_comments, invhist_invuom, invhist_unitcost, invhist_hasdetail, invhist_costmethod, invhist_value_before, invhist_value_after, invhist_series ) SELECT itemsite_id, CURRENT_TIMESTAMP, 'AD', 0.0, itemsite_qtyonhand, itemsite_qtyonhand, '', 'Inventory Value Adjustment', uom_name, _delta, FALSE, itemsite_costmethod, itemsite_value, pNewValue, 0 FROM itemsite, item, uom WHERE ( (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (itemsite_id=pItemsiteid) ); UPDATE itemsite SET itemsite_value=pNewValue WHERE (itemsite_id=pItemsiteid); RETURN 0; END; $_$; ALTER FUNCTION public.adjustinvvalue(integer, numeric, integer) OWNER TO admin; -- -- Name: adjustments(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION adjustments(text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTransType ALIAS FOR $1; BEGIN IF (pTransType IN ('CC', 'AD')) THEN RETURN TRUE; ELSE RETURN FALSE; END IF; END; $_$; ALTER FUNCTION public.adjustments(text) OWNER TO admin; -- -- Name: allocatedforso(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION allocatedforso(integer, date) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pDate ALIAS FOR $2; BEGIN RETURN allocatedForSo(pItemsiteid, startOfTime(), pDate); END; $_$; ALTER FUNCTION public.allocatedforso(integer, date) OWNER TO admin; -- -- Name: allocatedforso(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION allocatedforso(integer, integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pDate ALIAS FOR $2; BEGIN RETURN allocatedForSo(pItemsiteid, startOfTime(), (CURRENT_DATE + pDate)); END; $_$; ALTER FUNCTION public.allocatedforso(integer, integer) OWNER TO admin; -- -- Name: allocatedforso(integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION allocatedforso(integer, date, date) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _qty NUMERIC; BEGIN SELECT COALESCE(SUM(noNeg(itemuomtouom(itemsite_item_id, coitem_qty_uom_id, NULL, coitem_qtyord - (coitem_qtyshipped + qtyAtShipping(coitem_id)) + coitem_qtyreturned))), 0.0) INTO _qty FROM coitem, itemsite, item WHERE ( (coitem_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (coitem_status='O') AND (coitem_itemsite_id=pItemsiteid) AND (coitem_scheddate BETWEEN pStartDate AND pEndDate) ); RETURN _qty; END; $_$; ALTER FUNCTION public.allocatedforso(integer, date, date) OWNER TO admin; -- -- Name: allocatedforwo(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION allocatedforwo(integer, date) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pDate ALIAS FOR $2; BEGIN RETURN allocatedForWo(pItemsiteid, startOfTime(), pDate); END; $_$; ALTER FUNCTION public.allocatedforwo(integer, date) OWNER TO admin; -- -- Name: allocatedforwo(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION allocatedforwo(integer, integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pLookAheadDays ALIAS FOR $2; BEGIN RETURN allocatedForWo(pItemsiteid, startOfTime(), (CURRENT_DATE + pLookaheadDays)); END; $_$; ALTER FUNCTION public.allocatedforwo(integer, integer) OWNER TO admin; -- -- Name: allocatedforwo(integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION allocatedforwo(integer, date, date) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _itemtype TEXT; _qty NUMERIC; BEGIN SELECT item_type INTO _itemtype FROM itemsite JOIN item ON (item_id=itemsite_item_id) WHERE (itemsite_id=pItemsiteid); IF (_itemtype != 'T') THEN SELECT COALESCE(SUM(noNeg(itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq - womatl_qtyiss))), 0.0) INTO _qty FROM womatl JOIN wo ON (wo_id=womatl_wo_id AND wo_status IN ('E','I','R')) JOIN itemsite ON (itemsite_id=womatl_itemsite_id) WHERE (womatl_itemsite_id=pItemsiteid) AND (womatl_duedate BETWEEN pStartDate AND pEndDate); ELSE SELECT COALESCE(SUM(noNeg(itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq))), 0.0) - ( SELECT COALESCE(SUM(invhist_invqty),0) FROM itemsite, item, wo, womatl LEFT OUTER JOIN womatlpost ON (womatl_id=womatlpost_womatl_id) LEFT OUTER JOIN invhist ON ((womatlpost_invhist_id=invhist_id) AND (invhist_invqty > 0)) WHERE ( (womatl_itemsite_id=pItemsiteid) AND (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (womatl_duedate BETWEEN pStartDate AND pEndDate) AND (wo_id=womatl_wo_id) AND (wo_status IN ('E','I','R')) ) ) INTO _qty FROM womatl JOIN wo ON (wo_id=womatl_wo_id AND wo_status IN ('E','I','R')) JOIN itemsite ON (itemsite_id=womatl_itemsite_id) WHERE (womatl_itemsite_id=pItemsiteid) AND (womatl_duedate BETWEEN pStartDate AND pEndDate); END IF; RETURN COALESCE(_qty,0); END; $_$; ALTER FUNCTION public.allocatedforwo(integer, date, date) OWNER TO admin; -- -- Name: alterencrypt(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION alterencrypt(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOldKey ALIAS FOR $1; pNewKey ALIAS FOR $2; _cc RECORD; _ccaud RECORD; _metricenc RECORD; num_updated INTEGER; BEGIN num_updated := 0; -- Update ccard FOR _cc IN SELECT ccard_id, decrypt(setbytea(ccard_name), setbytea(pOldKey), 'bf') AS ccard_name, decrypt(setbytea(ccard_address1), setbytea(pOldKey), 'bf') AS ccard_address1, decrypt(setbytea(ccard_address2), setbytea(pOldKey), 'bf') AS ccard_address2, decrypt(setbytea(ccard_city), setbytea(pOldKey), 'bf') AS ccard_city, decrypt(setbytea(ccard_state), setbytea(pOldKey), 'bf') AS ccard_state, decrypt(setbytea(ccard_zip), setbytea(pOldKey), 'bf') AS ccard_zip, decrypt(setbytea(ccard_country), setbytea(pOldKey), 'bf') AS ccard_country, decrypt(setbytea(ccard_number), setbytea(pOldKey), 'bf') AS ccard_number, decrypt(setbytea(ccard_month_expired), setbytea(pOldKey), 'bf') AS ccard_month_expired, decrypt(setbytea(ccard_year_expired), setbytea(pOldKey), 'bf') AS ccard_year_expired FROM ccard LOOP UPDATE ccard set ccard_name = encrypt(setbytea(_cc.ccard_name), setbytea(pNewKey), 'bf'), ccard_address1 = encrypt(setbytea(_cc.ccard_address1), setbytea(pNewKey), 'bf'), ccard_address2 = encrypt(setbytea(_cc.ccard_address2), setbytea(pNewKey), 'bf'), ccard_city = encrypt(setbytea(_cc.ccard_city), setbytea(pNewKey), 'bf'), ccard_state = encrypt(setbytea(_cc.ccard_state), setbytea(pNewKey), 'bf'), ccard_zip = encrypt(setbytea(_cc.ccard_zip), setbytea(pNewKey), 'bf'), ccard_country = encrypt(setbytea(_cc.ccard_country), setbytea(pNewKey), 'bf'), ccard_number = encrypt(setbytea(_cc.ccard_number), setbytea(pNewKey), 'bf'), ccard_month_expired = encrypt(setbytea(_cc.ccard_month_expired), setbytea(pNewKey), 'bf'), ccard_year_expired = encrypt(setbytea(_cc.ccard_year_expired), setbytea(pNewKey), 'bf') WHERE ccard_id = _cc.ccard_id; num_updated := num_updated + 1; END LOOP; -- Update ccardaud FOR _ccaud IN SELECT ccardaud_id, decrypt(setbytea(ccardaud_ccard_name_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_name_old, decrypt(setbytea(ccardaud_ccard_name_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_name_new, decrypt(setbytea(ccardaud_ccard_address1_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_address1_old, decrypt(setbytea(ccardaud_ccard_address1_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_address1_new, decrypt(setbytea(ccardaud_ccard_address2_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_address2_old, decrypt(setbytea(ccardaud_ccard_address2_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_address2_new, decrypt(setbytea(ccardaud_ccard_city_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_city_old, decrypt(setbytea(ccardaud_ccard_city_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_city_new, decrypt(setbytea(ccardaud_ccard_state_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_state_old, decrypt(setbytea(ccardaud_ccard_state_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_state_new, decrypt(setbytea(ccardaud_ccard_zip_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_zip_old, decrypt(setbytea(ccardaud_ccard_zip_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_zip_new, decrypt(setbytea(ccardaud_ccard_country_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_country_old, decrypt(setbytea(ccardaud_ccard_country_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_country_new, decrypt(setbytea(ccardaud_ccard_number_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_number_old, decrypt(setbytea(ccardaud_ccard_number_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_number_new, decrypt(setbytea(ccardaud_ccard_month_expired_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_month_expired_old, decrypt(setbytea(ccardaud_ccard_month_expired_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_month_expired_new, decrypt(setbytea(ccardaud_ccard_year_expired_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_year_expired_old, decrypt(setbytea(ccardaud_ccard_year_expired_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_year_expired_new FROM ccardaud LOOP UPDATE ccardaud set ccardaud_ccard_name_old = encrypt(setbytea(_ccaud.ccardaud_ccard_name_old), setbytea(pNewKey), 'bf'), ccardaud_ccard_name_new = encrypt(setbytea(_ccaud.ccardaud_ccard_name_new), setbytea(pNewKey), 'bf'), ccardaud_ccard_address1_old = encrypt(setbytea(_ccaud.ccardaud_ccard_address1_old), setbytea(pNewKey), 'bf'), ccardaud_ccard_address1_new = encrypt(setbytea(_ccaud.ccardaud_ccard_address1_new), setbytea(pNewKey), 'bf'), ccardaud_ccard_address2_old = encrypt(setbytea(_ccaud.ccardaud_ccard_address2_old), setbytea(pNewKey), 'bf'), ccardaud_ccard_address2_new = encrypt(setbytea(_ccaud.ccardaud_ccard_address2_new), setbytea(pNewKey), 'bf'), ccardaud_ccard_city_old = encrypt(setbytea(_ccaud.ccardaud_ccard_city_old), setbytea(pNewKey), 'bf'), ccardaud_ccard_city_new = encrypt(setbytea(_ccaud.ccardaud_ccard_city_new), setbytea(pNewKey), 'bf'), ccardaud_ccard_state_old = encrypt(setbytea(_ccaud.ccardaud_ccard_state_old), setbytea(pNewKey), 'bf'), ccardaud_ccard_state_new = encrypt(setbytea(_ccaud.ccardaud_ccard_state_new), setbytea(pNewKey), 'bf'), ccardaud_ccard_zip_old = encrypt(setbytea(_ccaud.ccardaud_ccard_zip_old), setbytea(pNewKey), 'bf'), ccardaud_ccard_zip_new = encrypt(setbytea(_ccaud.ccardaud_ccard_zip_new), setbytea(pNewKey), 'bf'), ccardaud_ccard_country_old = encrypt(setbytea(_ccaud.ccardaud_ccard_country_old), setbytea(pNewKey), 'bf'), ccardaud_ccard_country_new = encrypt(setbytea(_ccaud.ccardaud_ccard_country_new), setbytea(pNewKey), 'bf'), ccardaud_ccard_number_old = encrypt(setbytea(_ccaud.ccardaud_ccard_number_old), setbytea(pNewKey), 'bf'), ccardaud_ccard_number_new = encrypt(setbytea(_ccaud.ccardaud_ccard_number_new), setbytea(pNewKey), 'bf'), ccardaud_ccard_month_expired_old = encrypt(setbytea(_ccaud.ccardaud_ccard_month_expired_old), setbytea(pNewKey), 'bf'), ccardaud_ccard_month_expired_new = encrypt(setbytea(_ccaud.ccardaud_ccard_month_expired_new), setbytea(pNewKey), 'bf'), ccardaud_ccard_year_expired_old = encrypt(setbytea(_ccaud.ccardaud_ccard_year_expired_old), setbytea(pNewKey), 'bf'), ccardaud_ccard_year_expired_new = encrypt(setbytea(_ccaud.ccardaud_ccard_year_expired_new), setbytea(pNewKey), 'bf') WHERE ccardaud_id = _ccaud.ccardaud_id; num_updated := num_updated + 1; END LOOP; -- Update metricenc FOR _metricenc IN SELECT metricenc_id, decrypt(setbytea(metricenc_value), setbytea(pOldKey), 'bf') AS metricenc_value FROM metricenc LOOP UPDATE metricenc set metricenc_value = encrypt(setbytea(_metricenc.metricenc_value), setbytea(pNewKey), 'bf') WHERE metricenc_id = _metricenc.metricenc_id; num_updated := num_updated + 1; END LOOP; RETURN num_updated; END; $_$; ALTER FUNCTION public.alterencrypt(text, text) OWNER TO admin; -- -- Name: apaging(date, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION apaging(date, boolean) RETURNS SETOF apaging LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAsOfDate ALIAS FOR $1; pUseDocDate ALIAS FOR $2; _row apaging%ROWTYPE; _x RECORD; _returnVal INTEGER; _asOfDate DATE; BEGIN _asOfDate := COALESCE(pAsOfDate,current_date); FOR _x IN SELECT --report uses currency rate snapshot to convert all amounts to base based on apopen_docdate to ensure the same exchange rate --today and greater base: CASE WHEN((apopen.apopen_duedate >= DATE(_asOfDate))) THEN (((apopen.apopen_amount - apopen.apopen_paid + COALESCE(SUM(apapply_target_paid * apopen.apopen_curr_rate / target.apopen_curr_rate),0))) / apopen.apopen_curr_rate * CASE WHEN (apopen.apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END) ELSE 0 END AS cur_val, --0 to 30 base CASE WHEN((apopen.apopen_duedate >= DATE(_asOfDate)-30) AND (apopen.apopen_duedate < DATE(_asOfDate))) THEN (((apopen.apopen_amount - apopen.apopen_paid + COALESCE(SUM(apapply_target_paid * apopen.apopen_curr_rate / target.apopen_curr_rate),0))) / apopen.apopen_curr_rate * CASE WHEN (apopen.apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END) ELSE 0 END AS thirty_val, --30-60 base CASE WHEN((apopen.apopen_duedate >= DATE(_asOfDate)-60) AND (apopen.apopen_duedate < DATE(_asOfDate) - 30 )) THEN (((apopen.apopen_amount - apopen.apopen_paid + COALESCE(SUM(apapply_target_paid * apopen.apopen_curr_rate / target.apopen_curr_rate),0))) / apopen.apopen_curr_rate * CASE WHEN (apopen.apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END) ELSE 0 END AS sixty_val, --60-90 base CASE WHEN((apopen.apopen_duedate >= DATE(_asOfDate)-90) AND (apopen.apopen_duedate < DATE(_asOfDate) - 60)) THEN (((apopen.apopen_amount - apopen.apopen_paid + COALESCE(SUM(apapply_target_paid * apopen.apopen_curr_rate / target.apopen_curr_rate),0))) / apopen.apopen_curr_rate * CASE WHEN (apopen.apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END) ELSE 0 END AS ninety_val, --greater than 90 base: CASE WHEN((apopen.apopen_duedate > DATE(_asOfDate)-10000) AND (apopen.apopen_duedate < DATE(_asOfDate) - 90)) THEN (((apopen.apopen_amount - apopen.apopen_paid + COALESCE(SUM(apapply_target_paid * apopen.apopen_curr_rate / target.apopen_curr_rate),0))) / apopen.apopen_curr_rate * CASE WHEN (apopen.apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END) ELSE 0 END AS plus_val, --total amount base: CASE WHEN((apopen.apopen_duedate > DATE(_asOfDate)-10000)) THEN (((apopen.apopen_amount - apopen.apopen_paid + COALESCE(SUM(apapply_target_paid * apopen.apopen_curr_rate / target.apopen_curr_rate),0))) / apopen.apopen_curr_rate * CASE WHEN (apopen.apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END) ELSE 0 END AS total_val, --AP Open Amount base CASE WHEN apopen.apopen_doctype IN ('C', 'R') THEN (apopen.apopen_amount / apopen.apopen_curr_rate * -1.0) ELSE (apopen.apopen_amount / apopen.apopen_curr_rate) END AS apopen_amount, apopen.apopen_docdate, apopen.apopen_duedate, apopen.apopen_ponumber, apopen.apopen_invcnumber, apopen.apopen_docnumber, apopen.apopen_doctype, vend_id, vend_name, vend_number, vend_vendtype_id, vendtype_code, terms_descrip, determineDiscountDate(terms_id, apopen.apopen_docdate) AS discdate, noNeg(apopen.apopen_discountable_amount * CASE WHEN (CURRENT_DATE <= determineDiscountDate(terms_id, apopen.apopen_docdate)) THEN terms_discprcnt ELSE 0.0 END) AS disc_val, terms_discdays AS discdays, (terms_discprcnt * 100.0) AS discprcnt FROM vendinfo, vendtype, apopen LEFT OUTER JOIN terms ON (apopen_terms_id=terms_id) LEFT OUTER JOIN apapply ON (((apopen_id=apapply_target_apopen_id) OR (apopen_id=apapply_source_apopen_id)) AND (apapply_postdate >_asOfDate)) LEFT OUTER JOIN apopen target ON (target.apopen_id=apapply_target_apopen_id) WHERE ( (apopen.apopen_vend_id = vend_id) AND (vend_vendtype_id=vendtype_id) AND (CASE WHEN (pUseDocDate) THEN apopen.apopen_docdate ELSE apopen.apopen_distdate END <= _asOfDate) AND (COALESCE(apopen.apopen_closedate,_asOfDate+1)>_asOfDate) ) GROUP BY apopen.apopen_id,apopen.apopen_docdate,apopen.apopen_duedate,apopen.apopen_ponumber, apopen.apopen_invcnumber,apopen.apopen_docnumber,apopen.apopen_doctype,apopen.apopen_paid, apopen.apopen_curr_id,apopen.apopen_amount,vend_id,vend_name,vend_number,vend_vendtype_id,vendtype_code,terms_descrip, apopen.apopen_curr_rate, terms_id, terms_discdays, terms_discprcnt, apopen.apopen_discountable_amount ORDER BY vend_number, apopen.apopen_duedate LOOP _row.apaging_docdate := _x.apopen_docdate; _row.apaging_duedate := _x.apopen_duedate; _row.apaging_ponumber := _x.apopen_ponumber; _row.apaging_invcnumber := _x.apopen_invcnumber; _row.apaging_docnumber := _x.apopen_docnumber; _row.apaging_doctype := _x.apopen_doctype; _row.apaging_vend_id := _x.vend_id; _row.apaging_vend_number := _x.vend_number; _row.apaging_vend_name := _x.vend_name; _row.apaging_vend_vendtype_id := _x.vend_vendtype_id; _row.apaging_vendtype_code := _x.vendtype_code; _row.apaging_terms_descrip := _x.terms_descrip; _row.apaging_apopen_amount := _x.apopen_amount; _row.apaging_cur_val := _x.cur_val; _row.apaging_thirty_val := _x.thirty_val; _row.apaging_sixty_val := _x.sixty_val; _row.apaging_ninety_val := _x.ninety_val; _row.apaging_plus_val := _x.plus_val; _row.apaging_total_val := _x.total_val; _row.apaging_discdate := _x.discdate; _row.apaging_disc_val := _x.disc_val; _row.apaging_discdays := _x.discdays; _row.apaging_discprcnt := _x.discprcnt; RETURN NEXT _row; END LOOP; RETURN; END; $_$; ALTER FUNCTION public.apaging(date, boolean) OWNER TO admin; -- -- Name: apapplied(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION apapplied(integer, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pApopenid ALIAS FOR $1; pDate ALIAS FOR $2; _amount NUMERIC; BEGIN -- Return amount applied to an apopen in base currency as of apapply_postdate SELECT SUM(currtobase(apapply_curr_id,apapply_amount,apapply_postdate)) INTO _amount FROM apapply WHERE (((apapply_target_apopen_id = pApopenid) OR (apapply_source_apopen_id = pApopenid)) AND (((apapply_journalnumber=0) AND (apapply_postdate <= pDate)) OR EXISTS(SELECT * FROM gltrans WHERE ((gltrans_journalnumber=apapply_journalnumber) AND (gltrans_date <= pDate))))); IF (_amount IS NULL) THEN RETURN 0; ELSE RETURN _amount; END IF; END; $_$; ALTER FUNCTION public.apapplied(integer, date) OWNER TO admin; -- -- Name: apcheckpending(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION apcheckpending(integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pApopenid ALIAS FOR $1; _qty NUMERIC := 0.0; BEGIN SELECT SUM(checkitem_amount + checkitem_discount) INTO _qty FROM checkitem JOIN checkhead ON (checkitem_checkhead_id=checkhead_id) WHERE ((checkitem_apopen_id=pApopenid) AND (NOT checkhead_deleted) AND (NOT checkhead_replaced) AND (NOT checkhead_void) AND (NOT checkhead_posted)); RETURN COALESCE(_qty, 0.0); END; $_$; ALTER FUNCTION public.apcheckpending(integer) OWNER TO admin; -- -- Name: apcurrgain(integer, integer, numeric, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION apcurrgain(integer, integer, numeric, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pApopenId ALIAS FOR $1; pCurrId ALIAS FOR $2; pValue ALIAS FOR $3; pDate ALIAS FOR $4; _start DATE; _end DATE; _gain NUMERIC; _r RECORD; BEGIN IF (pApopenId IS NULL OR pValue = 0) THEN RETURN 0; END IF; SELECT apopen_docdate, apopen_curr_rate INTO _r FROM apopen WHERE (apopen_id=pApopenId); IF (_r.apopen_docdate > pDate) THEN _gain := (currToBase(pCurrId, pValue, pDate) - (pValue / _r.apopen_curr_rate)) * -1; ELSE _gain := (pValue / _r.apopen_curr_rate) - currToBase(pCurrId, pValue, pDate); END IF; IF (_gain IS NULL) THEN RAISE EXCEPTION 'Error processing currency gain/loss.'; END IF; RETURN _gain; END; $_$; ALTER FUNCTION public.apcurrgain(integer, integer, numeric, date) OWNER TO admin; -- -- Name: applyapcreditmemotobalance(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION applyapcreditmemotobalance(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pApopenid ALIAS FOR $1; _amount NUMERIC; _curr_id INTEGER; _curr_rate NUMERIC; _docdate DATE; _applyAmount NUMERIC; _r RECORD; _p RECORD; BEGIN -- Find the balance to apply SELECT (apopen_amount - apopen_paid - COALESCE(prepared,0.0) - COALESCE(selected,0.0) - COALESCE(SUM(currToCurr(apcreditapply_curr_id, apopen_curr_id, apcreditapply_amount, apopen_docdate)), 0)), apopen_curr_id, apopen_curr_rate, apopen_docdate INTO _amount, _curr_id, _curr_rate, _docdate FROM apopen LEFT OUTER JOIN apcreditapply ON (apcreditapply_source_apopen_id=apopen_id) LEFT OUTER JOIN (SELECT apopen_id AS selected_apopen_id, SUM(currToCurr(apselect_curr_id, apopen_curr_id, apselect_amount + apselect_discount, apselect_date)) AS selected FROM apselect JOIN apopen ON (apselect_apopen_id=apopen_id) GROUP BY apopen_id) AS sub1 ON (apopen_id=selected_apopen_id) LEFT OUTER JOIN (SELECT apopen_id AS prepared_apopen_id, SUM(checkitem_amount + checkitem_discount) AS prepared FROM checkhead JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN apopen ON (checkitem_apopen_id=apopen_id) WHERE ((NOT checkhead_posted) AND (NOT checkhead_void)) GROUP BY apopen_id) AS sub2 ON (prepared_apopen_id=apopen_id) WHERE (apopen_id=pApopenid) GROUP BY apopen_amount, apopen_paid, apopen_curr_id, apopen_curr_rate, apopen_docdate, prepared, selected; IF (_amount < 0) THEN RETURN -1; END IF; -- Loop through the apopen items in order of due date FOR _r IN SELECT target.apopen_id AS apopenid, currToCurr(target.apopen_curr_id,source.apopen_curr_id, target.apopen_amount - target.apopen_paid - COALESCE(prepared,0.0) - COALESCE(selected,0.0) - COALESCE(applied,0.0), current_date) AS balance FROM apopen AS source, apopen AS target LEFT OUTER JOIN (SELECT apcreditapply_target_apopen_id AS applied_apopen_id, SUM(currToCurr(apcreditapply_curr_id, apopen_curr_id, apcreditapply_amount, apopen_docdate)) AS applied FROM apcreditapply JOIN apopen ON (apopen_id=apcreditapply_source_apopen_id) GROUP BY apcreditapply_target_apopen_id) AS sub3 ON (target.apopen_id=applied_apopen_id) LEFT OUTER JOIN (SELECT apopen_id AS selected_apopen_id, SUM(currToCurr(apselect_curr_id, apopen_curr_id, apselect_amount + apselect_discount, apselect_date)) AS selected FROM apselect JOIN apopen ON (apselect_apopen_id=apopen_id) GROUP BY apopen_id) AS sub1 ON (target.apopen_id=selected_apopen_id) LEFT OUTER JOIN (SELECT apopen_id AS prepared_apopen_id, SUM(checkitem_amount + checkitem_discount) AS prepared FROM checkhead JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN apopen ON (checkitem_apopen_id=apopen_id) WHERE ((NOT checkhead_posted) AND (NOT checkhead_void)) GROUP BY apopen_id) AS sub2 ON (prepared_apopen_id=target.apopen_id) WHERE ( (source.apopen_vend_id=target.apopen_vend_id) AND (target.apopen_doctype IN ('V', 'D')) AND (target.apopen_open) AND (source.apopen_id=pApopenid) ) ORDER BY target.apopen_duedate, (target.apopen_amount - target.apopen_paid) LOOP -- Determine the amount to apply IF (_r.balance <= 0.0) THEN CONTINUE; ELSEIF (_r.balance > _amount) THEN _applyAmount := _amount; ELSE _applyAmount := _r.balance; END IF; -- Does an apcreditapply record already exist? SELECT apcreditapply_id, apcreditapply_amount * _curr_rate / currRate(apcreditapply_curr_id,_docdate) AS apcreditapply_amount INTO _p FROM apcreditapply WHERE ( (apcreditapply_target_apopen_id=_r.apopenid) AND (apcreditapply_source_apopen_id=pApopenid) ); IF (FOUND) THEN -- The following is depreciated, just skip the record -- Recalculate the amount to apply -- IF ((_r.balance - _p.apcreditapply_amount) > _amount) THEN -- _applyAmount := _amount; -- ELSE -- _applyAmount := (_r.balance - _p.apcreditapply_amount); -- END IF; -- Update the apcreditapply with the new amount to apply -- UPDATE apcreditapply -- SET apcreditapply_amount = (apcreditapply_amount + -- _applyAmount * currRate(apcreditapply_curr_id,_docdate) / _curr_rate) -- WHERE (apcreditapply_id=_p.apcreditapply_id); CONTINUE; ELSE -- Create a new apcreditapply record INSERT INTO apcreditapply ( apcreditapply_source_apopen_id, apcreditapply_target_apopen_id, apcreditapply_amount, apcreditapply_curr_id ) VALUES ( pApopenid, _r.apopenid, _applyAmount, _curr_id ); END IF; _amount := (_amount - _applyAmount); IF (_amount = 0) THEN EXIT; END IF; END LOOP; RETURN 1; END; $_$; ALTER FUNCTION public.applyapcreditmemotobalance(integer) OWNER TO admin; -- -- Name: applyapcredits(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION applyapcredits(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendId ALIAS FOR $1; _result INTEGER; _apopenid INTEGER; _r RECORD; BEGIN -- Fetch credit memo(s) for the vendor FOR _r IN SELECT apopen_id, apopen_duedate FROM apopen JOIN vendinfo ON (apopen_vend_id = vend_id) WHERE ((apopen_doctype = 'C') AND (apopen_status = 'O') AND (vend_id = pVendId)) ORDER BY apopen_duedate LOOP -- Apply credit memo(s) according to due date SELECT applyapcreditmemotobalance(_r.apopen_id) INTO _result; -- Post the credit memo if applied IF (_result = 1) THEN SELECT postapcreditmemoapplication(_r.apopen_id) INTO _apopenid; IF (_apopenid < 0) THEN RETURN -1; END IF; ELSE RETURN -1; END IF; END LOOP; RETURN 1; END; $_$; ALTER FUNCTION public.applyapcredits(integer) OWNER TO admin; -- -- Name: applyarcreditmemotobalance(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION applyarcreditmemotobalance(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAropenid ALIAS FOR $1; BEGIN RETURN applyARCreditMemoToBalance(pAropenid, NULL); END; $_$; ALTER FUNCTION public.applyarcreditmemotobalance(integer) OWNER TO admin; -- -- Name: applyarcreditmemotobalance(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION applyarcreditmemotobalance(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSourceAropenid ALIAS FOR $1; pTargetAropenid ALIAS FOR $2; _amount NUMERIC; _amountcurrid INTEGER; _applyAmount NUMERIC; _applycurrid INTEGER; _curr_rate NUMERIC; _r RECORD; _p RECORD; BEGIN -- Find the balance to apply SELECT (aropen_amount - COALESCE(SUM(currToCurr(arcreditapply_curr_id, aropen_curr_id, arcreditapply_amount, aropen_docdate)), 0) - aropen_paid - COALESCE(prepared,0.0) - COALESCE(cashapplied,0.0)), aropen_curr_id, aropen_curr_rate INTO _amount, _amountcurrid, _curr_rate FROM aropen LEFT OUTER JOIN arcreditapply ON (arcreditapply_source_aropen_id=aropen_id) LEFT OUTER JOIN (SELECT aropen_id AS prepared_aropen_id, SUM(checkitem_amount + checkitem_discount) AS prepared FROM checkhead JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN aropen ON (checkitem_aropen_id=aropen_id) WHERE ((NOT checkhead_posted) AND (NOT checkhead_void)) GROUP BY aropen_id) AS sub1 ON (prepared_aropen_id=aropen_id) LEFT OUTER JOIN (SELECT aropen_id AS cash_aropen_id, SUM(cashrcptitem_amount + cashrcptitem_discount) * -1.0 AS cashapplied FROM cashrcpt JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id) JOIN aropen ON (cashrcptitem_aropen_id=aropen_id) WHERE (NOT cashrcpt_posted) AND (NOT cashrcpt_void) GROUP BY aropen_id ) AS sub2 ON (cash_aropen_id=aropen_id) WHERE (aropen_id=pSourceAropenid) GROUP BY aropen_amount, aropen_paid, aropen_curr_id, aropen_curr_rate, prepared, cashapplied; IF (_amount < 0) THEN RETURN -1; END IF; -- Loop through the aropen items in order of due date FOR _r IN SELECT target.aropen_id AS aropenid, currToCurr(target.aropen_curr_id,source.aropen_curr_id, (target.aropen_amount - target.aropen_paid - calcpendingarapplications(target.aropen_id)), current_date) AS balance, target.aropen_curr_id AS curr_id, target.aropen_docdate AS docdate FROM aropen AS target, aropen AS source WHERE ( (source.aropen_cust_id=target.aropen_cust_id) AND (target.aropen_doctype IN ('D', 'I')) AND (target.aropen_open) AND (source.aropen_id=pSourceAropenid) AND ((pTargetAropenid IS NULL) OR (target.aropen_id=pTargetAropenid)) ) ORDER BY target.aropen_duedate, target.aropen_docnumber LOOP -- Determine the amount to apply IF (_r.balance > _amount) THEN _applyAmount := _amount; ELSE _applyAmount := _r.balance; END IF; _applycurrid := _amountcurrid; -- Does an arcreditapply record already exist? SELECT arcreditapply_id, arcreditapply_amount, arcreditapply_amount * _curr_rate / currRate(arcreditapply_curr_id,_r.docdate) AS arcreditapply_amount_applycurr INTO _p FROM arcreditapply WHERE ( (arcreditapply_target_aropen_id=_r.aropenid) AND (arcreditapply_source_aropen_id=pSourceAropenid) ); IF (FOUND) THEN -- Offset the amount to apply by the amount already applied _applyAmount := (_applyAmount - _p.arcreditapply_amount_applycurr); IF (_applyAmount < 0) THEN _applyAmount := 0; END IF; -- Update the arcreditapply with the new amount to apply UPDATE arcreditapply SET arcreditapply_amount = (arcreditapply_amount + _applyAmount * currRate(arcreditapply_curr_id,_r.docdate) / _curr_rate) WHERE (arcreditapply_id=_p.arcreditapply_id); ELSE -- Create a new arcreditapply record INSERT INTO arcreditapply ( arcreditapply_source_aropen_id, arcreditapply_target_aropen_id, arcreditapply_amount, arcreditapply_curr_id ) VALUES ( pSourceAropenid, _r.aropenid, _applyAmount, _applycurrid ); END IF; _amount := _amount - currToCurr(_applycurrid, _amountcurrid, _applyAmount, _r.docdate); IF (_amount = 0) THEN EXIT; END IF; END LOOP; RETURN 1; END; $_$; ALTER FUNCTION public.applyarcreditmemotobalance(integer, integer) OWNER TO admin; -- -- Name: applycashreceiptlinebalance(integer, integer, numeric, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION applycashreceiptlinebalance(integer, integer, numeric, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCashrcptId ALIAS FOR $1; pAropenid ALIAS FOR $2; pAmount ALIAS FOR $3; pCurrId ALIAS FOR $4; _balance NUMERIC; _amount NUMERIC; _applyAmount NUMERIC := 0; _discount NUMERIC := 0; _discprct NUMERIC; _docDate DATE; _r RECORD; _doctype CHAR(1); BEGIN -- All calculations performed in currency of Cash Receipt -- Clear previously applied DELETE FROM cashrcptitem WHERE ((cashrcptitem_cashrcpt_id=pCashrcptId) AND (cashrcptitem_aropen_id=pAropenId)); -- Find the balance to apply SELECT (pAmount - (COALESCE(SUM(cashrcptitem_amount), 0) ) ), COALESCE(cashrcpt_docdate, current_date) INTO _amount, _docDate FROM cashrcpt LEFT OUTER JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id = cashrcpt_id) WHERE (cashrcpt_id=pCashrcptid) GROUP BY cashrcpt_curr_id, cashrcpt_distdate, cashrcpt_docdate; SELECT (_amount - COALESCE(SUM(cashrcptmisc_amount), 0)) INTO _amount FROM cashrcptmisc WHERE (cashrcptmisc_cashrcpt_id=pCashrcptid); SELECT aropen_doctype INTO _doctype FROM aropen WHERE (aropen_id=pAropenId); RAISE DEBUG 'Amount (%) DocType (%)', _amount, _doctype; IF (_amount <= 0 AND _doctype IN ('I','D')) THEN RETURN 0; END IF; -- Determine Line balance SELECT currToCurr(aropen_curr_id, cashrcpt_curr_id, aropen_amount - aropen_paid, cashrcpt_distdate) - COALESCE((SELECT (SUM(cashrcptitem_amount) + SUM(cashrcptitem_discount)) FROM cashrcptitem, cashrcpt WHERE ((cashrcpt_id=cashrcptitem_cashrcpt_id) AND (NOT cashrcpt_void) AND (NOT cashrcpt_posted) AND (cashrcpt_id != pCashrcptId) AND (cashrcptitem_aropen_id=pAropenId))), 0) INTO _balance FROM aropen, cashrcpt WHERE ((aropen_id=pAropenId) AND (cashrcpt_id=pCashrcptId)); RAISE DEBUG 'Balance (%)', _balance; -- If Invoice or Debit Memo, determine Max Discount as per Terms IF (_doctype IN ('I','D')) THEN SELECT round(noNeg(_balance * CASE WHEN (_docDate <= determineDiscountDate(terms_id, aropen_docdate)) THEN COALESCE(terms_discprcnt, 0.0) ELSE 0.00 END - applied),2), CASE WHEN (_docDate <= determineDiscountDate(terms_id, aropen_docdate)) THEN COALESCE(terms_discprcnt, 0.0) ELSE 0.00 END INTO _discount, _discprct FROM aropen LEFT OUTER JOIN terms ON (terms_id=aropen_terms_id), (SELECT COALESCE(SUM(arapply_applied), 0.00) AS applied FROM arapply, aropen WHERE ((arapply_target_aropen_id=pAropenId) AND (arapply_source_aropen_id=pAropenId) AND (aropen_discount) ) ) AS data WHERE (aropen_id=pAropenId); -- Determine the amount to apply IF (_balance <= _amount + _discount) THEN _applyAmount := _balance - _discount; ELSE _discount := round((_amount / (1 - _discprct)) - _amount, 2); _applyAmount := _amount; END IF; ELSIF (_doctype IN ('C', 'R')) THEN -- Handle Credits, discounts don't apply here _applyAmount := _balance * -1; ELSE _applyAmount := _amount; END IF; IF (_applyAmount != 0) THEN -- Create a new cashrcptitem INSERT INTO cashrcptitem ( cashrcptitem_aropen_id, cashrcptitem_cashrcpt_id, cashrcptitem_amount,cashrcptitem_discount ) VALUES ( pAropenid, pCashrcptid, round(_applyAmount, 2), round(_discount, 2) ); END IF; RETURN abs(_applyAmount); END; $_$; ALTER FUNCTION public.applycashreceiptlinebalance(integer, integer, numeric, integer) OWNER TO admin; -- -- Name: applycashreceipttobalance(integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION applycashreceipttobalance(integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCashrcptid ALIAS FOR $1; pAmount ALIAS FOR $2; BEGIN RETURN applyCashReceiptToBalance(pCashrcptid, pAmount, baseCurrId() ); END; $_$; ALTER FUNCTION public.applycashreceipttobalance(integer, numeric) OWNER TO admin; -- -- Name: applycashreceipttobalance(integer, numeric, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION applycashreceipttobalance(integer, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCashrcptid ALIAS FOR $1; pAmount ALIAS FOR $2; pCurrId ALIAS FOR $3; BEGIN RETURN applyCashReceiptToBalance(pCashrcptid, pAmount, pCurrId, false); END; $_$; ALTER FUNCTION public.applycashreceipttobalance(integer, numeric, integer) OWNER TO admin; -- -- Name: applycashreceipttobalance(integer, numeric, integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION applycashreceipttobalance(integer, numeric, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCashrcptid ALIAS FOR $1; pAmount ALIAS FOR $2; pCurrId ALIAS FOR $3; pInclCredits ALIAS FOR $4; _amount NUMERIC; _applied NUMERIC := 0; _applyAmount NUMERIC; _discount NUMERIC; _discprct NUMERIC; _docDate DATE; _r RECORD; _toApply NUMERIC; BEGIN -- Apply open credits first if applicable IF (pInclCredits) THEN -- First find total debits unaccounted for by this receipt so we can apply as much credit -- as possible to clear, but no more SELECT coalesce(noNeg(sum(currToCurr(aropen_curr_id, cashrcpt_curr_id, aropen_amount - aropen_paid, cashrcpt_distdate) - COALESCE((SELECT (SUM(cashrcptitem_amount) + SUM(cashrcptitem_discount)) FROM cashrcptitem, cashrcpt WHERE ((cashrcpt_id=cashrcptitem_cashrcpt_id) AND (NOT cashrcpt_void) AND (NOT cashrcpt_posted) AND (cashrcpt_id != pCashrcptid) AND (cashrcptitem_aropen_id=aropen_id))), 0)) - pAmount),0) INTO _toApply FROM cashrcpt JOIN custinfo ON (cashrcpt_cust_id=cust_id) JOIN aropen ON (cust_id=aropen_cust_id) WHERE ((cashrcpt_id=pCashrcptid) AND (aropen_open) AND (aropen_doctype IN ('I','D'))); -- Loop through and apply credits until we account for all remaining debits we can FOR _r IN SELECT aropen_id FROM cashrcpt JOIN custinfo ON (cashrcpt_cust_id=cust_id) JOIN aropen ON (cust_id=aropen_cust_id) WHERE ((cashrcpt_id=pCashrcptid) AND (aropen_open) AND (aropen_doctype IN ('C','R'))) ORDER BY aropen_duedate, aropen_docnumber LOOP EXIT WHEN _toApply <= 0; _toApply := _toApply - applyCashReceiptLineBalance(pCashrcptid, _r.aropen_id, _toApply, pCurrId); END LOOP; END IF; -- Find the balance to apply SELECT (currToCurr(pCurrId, cashrcpt_curr_id, pAmount, cashrcpt_distdate) - (COALESCE(SUM(cashrcptitem_amount), 0) ) ), COALESCE(cashrcpt_docdate, current_date) INTO _amount, _docDate FROM cashrcpt LEFT OUTER JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id = cashrcpt_id) WHERE (cashrcpt_id=pCashrcptid) GROUP BY cashrcpt_curr_id, cashrcpt_distdate, cashrcpt_docdate; SELECT (_amount - COALESCE(SUM(cashrcptmisc_amount), 0)) INTO _amount FROM cashrcptmisc WHERE (cashrcptmisc_cashrcpt_id=pCashrcptid); IF (_amount = 0) THEN RETURN 1; END IF; -- Loop through the aropen item in order of due date, searching only for -- aropen items that are open, for the current customer and have an outstanding balance FOR _r IN SELECT aropen_id, currToCurr(aropen_curr_id, cashrcpt_curr_id, aropen_amount - aropen_paid, cashrcpt_distdate) - COALESCE((SELECT SUM(cashrcptitem_amount) + SUM(cashrcptitem_discount) FROM cashrcptitem, cashrcpt WHERE ((cashrcpt_id=cashrcptitem_cashrcpt_id) AND (NOT cashrcpt_void) AND (NOT cashrcpt_posted) AND (cashrcpt_id != pCashrcptId) AND (cashrcptitem_aropen_id=aropen_id))), 0) AS balance, s.cashrcptitem_id AS cashrcptitem_id FROM cashrcpt, aropen LEFT OUTER JOIN cashrcptitem s ON (s.cashrcptitem_aropen_id=aropen_id AND s.cashrcptitem_cashrcpt_id=pCashrcptId) LEFT OUTER JOIN terms ON (aropen_terms_id=terms_id), (SELECT COALESCE(SUM(arapply_applied), 0.00) AS applied FROM arapply, aropen WHERE ((arapply_target_aropen_id=aropen_id) AND (arapply_source_aropen_id=aropen_id) AND (aropen_discount) ) ) AS data WHERE ( (aropen_cust_id=cashrcpt_cust_id) AND (aropen_doctype IN ('I', 'D')) AND (aropen_open) AND (cashrcpt_id=pCashrcptid) ) ORDER BY aropen_duedate, aropen_amount, balance LOOP -- Determine Max Discount as per Terms SELECT COALESCE(round(noNeg(_r.balance * CASE WHEN (_docDate <= determineDiscountDate(terms_id, aropen_docdate)) THEN terms_discprcnt ELSE 0.00 END - applied),2), 0), COALESCE(CASE WHEN (_docDate <= determineDiscountDate(terms_id, aropen_docdate)) THEN terms_discprcnt ELSE 0.00 END, 0) INTO _discount, _discprct FROM aropen LEFT OUTER JOIN terms ON (terms_id=aropen_terms_id), (SELECT COALESCE(SUM(arapply_applied), 0.00) AS applied FROM arapply, aropen WHERE ((arapply_target_aropen_id=_r.aropen_id) AND (arapply_source_aropen_id=_r.aropen_id) AND (aropen_discount) ) ) AS data WHERE (aropen_id=_r.aropen_id); -- Determine the amount to apply IF (_r.balance <= _amount + _discount) THEN _applyAmount := _r.balance - _discount; ELSE _discount := round((_amount / (1 - _discprct)) - _amount, 2); _applyAmount := _amount; END IF; IF (_applyAmount > 0) THEN -- Does an cashrcptitem already exist? IF (_r.cashrcptitem_id IS NOT NULL) THEN -- Update the cashrcptitem with the new amount to apply UPDATE cashrcptitem SET cashrcptitem_amount = round(cashrcptitem_amount + _applyAmount, 2), cashrcptitem_discount = round(_discount, 2) WHERE (cashrcptitem_id=_r.cashrcptitem_id); ELSE -- Create a new cashrcptitem INSERT INTO cashrcptitem ( cashrcptitem_aropen_id, cashrcptitem_cashrcpt_id, cashrcptitem_amount, cashrcptitem_discount ) VALUES ( _r.aropen_id, pCashrcptid, round(_applyAmount, 2), round(_discount, 2) ); END IF; _amount := (_amount - _applyAmount); IF (round(_amount, 2) = 0) THEN EXIT; END IF; END IF; END LOOP; RETURN 1; END; $_$; ALTER FUNCTION public.applycashreceipttobalance(integer, numeric, integer, boolean) OWNER TO admin; -- -- Name: araging(date, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION araging(date, boolean) RETURNS SETOF araging LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAsOfDate ALIAS FOR $1; pUseDocDate ALIAS FOR $2; _row araging%ROWTYPE; BEGIN FOR _row IN SELECT * FROM araging(pAsOfDate, pUseDocDate, true) LOOP RETURN NEXT _row; END LOOP; RETURN; END; $_$; ALTER FUNCTION public.araging(date, boolean) OWNER TO admin; -- -- Name: araging(date, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION araging(date, boolean, boolean) RETURNS SETOF araging LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAsOfDate ALIAS FOR $1; pUseDocDate ALIAS FOR $2; pConvBaseCurr ALIAS FOR $3; _row araging%ROWTYPE; _x RECORD; _returnVal INTEGER; _asOfDate DATE; BEGIN _asOfDate := COALESCE(pAsOfDate,current_date); FOR _x IN SELECT aropen_docdate, aropen_duedate, aropen_ponumber, aropen_docnumber, aropen_doctype, cust_id, cust_name, cust_number, cust_custtype_id, custtype_code, terms_descrip, --if pConvBaseCurr is true then use currtobase to convert all amounts to base based on aropen_docdate to ensure the same exchange rate --otherwise use currtocurr to convert all amounts to customer's currency based on aropen_docdate to ensure the same exchange rate --today and greater: CASE WHEN((aropen_duedate >= DATE(_asOfDate))) THEN balance ELSE 0.0 END AS cur_val, --0 to 30 CASE WHEN((aropen_duedate >= DATE(_asOfDate)-30) AND (aropen_duedate < DATE(_asOfDate))) THEN balance ELSE 0.0 END AS thirty_val, --30-60 CASE WHEN((aropen_duedate >= DATE(_asOfDate)-60) AND (aropen_duedate < DATE(_asOfDate) - 30 )) THEN balance ELSE 0.0 END AS sixty_val, --60-90 CASE WHEN((aropen_duedate >= DATE(_asOfDate)-90) AND (aropen_duedate < DATE(_asOfDate) - 60)) THEN balance ELSE 0.0 END AS ninety_val, --greater than 90: CASE WHEN((aropen_duedate > DATE(_asOfDate)-10000) AND (aropen_duedate < DATE(_asOfDate) - 90)) THEN balance ELSE 0.0 END AS plus_val, --total amount: CASE WHEN((aropen_duedate > DATE(_asOfDate)-10000)) THEN balance ELSE 0.0 END AS total_val, --AR Open Amount base aropen_amount FROM ( SELECT (((aropen_amount - aropen_paid + COALESCE(SUM(arapply_target_paid),0))) / CASE WHEN (pConvBaseCurr) THEN aropen_curr_rate ELSE currRate(aropen_curr_id, cust_curr_id, aropen_docdate) END * CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1.0 ELSE 1.0 END) AS balance, ((aropen_amount) / CASE WHEN (pConvBaseCurr) THEN aropen_curr_rate ELSE currRate(aropen_curr_id, cust_curr_id, aropen_docdate) END * CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1.0 ELSE 1.0 END) AS aropen_amount, aropen_docdate, aropen_duedate, aropen_ponumber, aropen_docnumber, aropen_doctype, cust_id, cust_name, cust_number, cust_custtype_id, custtype_code, COALESCE(arterms.terms_descrip, custterms.terms_descrip, '') AS terms_descrip FROM aropen JOIN custinfo ON (cust_id=aropen_cust_id) JOIN custtype ON (custtype_id=cust_custtype_id) LEFT OUTER JOIN terms arterms ON (arterms.terms_id=aropen_terms_id) LEFT OUTER JOIN terms custterms ON (custterms.terms_id=cust_terms_id) LEFT OUTER JOIN arapply ON (((aropen_id=arapply_target_aropen_id) OR (aropen_id=arapply_source_aropen_id)) AND (arapply_distdate>_asOfDate)) WHERE ( (CASE WHEN (pUseDocDate) THEN aropen_docdate ELSE aropen_distdate END <= _asOfDate) AND (COALESCE(aropen_closedate,_asOfDate+1)>_asOfDate) ) GROUP BY aropen_id,aropen_docdate,aropen_duedate,aropen_ponumber,aropen_docnumber,aropen_doctype,aropen_paid, aropen_curr_id,aropen_amount,cust_id,cust_name,cust_number,cust_custtype_id,custtype_code, arterms.terms_descrip,custterms.terms_descrip, aropen_curr_rate, aropen_curr_id, cust_curr_id ORDER BY cust_number, aropen_duedate ) AS data LOOP _row.araging_docdate := _x.aropen_docdate; _row.araging_duedate := _x.aropen_duedate; _row.araging_ponumber := _x.aropen_ponumber; _row.araging_docnumber := _x.aropen_docnumber; _row.araging_doctype := _x.aropen_doctype; _row.araging_cust_id := _x.cust_id; _row.araging_cust_number := _x.cust_number; _row.araging_cust_name := _x.cust_name; _row.araging_cust_custtype_id := _x.cust_custtype_id; _row.araging_custtype_code := _x.custtype_code; _row.araging_terms_descrip := _x.terms_descrip; _row.araging_aropen_amount := _x.aropen_amount; _row.araging_cur_val := _x.cur_val; _row.araging_thirty_val := _x.thirty_val; _row.araging_sixty_val := _x.sixty_val; _row.araging_ninety_val := _x.ninety_val; _row.araging_plus_val := _x.plus_val; _row.araging_total_val := _x.total_val; RETURN NEXT _row; END LOOP; RETURN; END; $_$; ALTER FUNCTION public.araging(date, boolean, boolean) OWNER TO admin; -- -- Name: arapplied(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION arapplied(integer, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAropenid ALIAS FOR $1; pDate ALIAS FOR $2; _amount NUMERIC; BEGIN -- Return amount applied to an aropen in base currency item as of the parameter date SELECT SUM(currtobase(arapply_curr_id,arapply_applied,pDate)) INTO _amount FROM arapply WHERE (((arapply_target_aropen_id = pAropenid) OR (arapply_source_aropen_id = pAropenid)) AND (((arapply_journalnumber=0) AND (arapply_postdate <= pDate)) OR EXISTS(SELECT * FROM gltrans WHERE ((gltrans_journalnumber=arapply_journalnumber) AND (gltrans_date <= pDate))))); IF (_amount IS NULL) THEN RETURN 0; ELSE RETURN _amount; END IF; END; $_$; ALTER FUNCTION public.arapplied(integer, date) OWNER TO admin; -- -- Name: archivesaleshistory(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION archivesaleshistory(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSohistid ALIAS FOR $1; BEGIN INSERT INTO asohist ( asohist_id, asohist_cust_id, asohist_itemsite_id, asohist_shipdate, asohist_invcdate, asohist_duedate, asohist_promisedate, asohist_ordernumber, asohist_invcnumber, asohist_qtyshipped, asohist_unitprice, asohist_unitcost, asohist_billtoname, asohist_billtoaddress1, asohist_billtoaddress2, asohist_billtoaddress3, asohist_billtocity, asohist_billtostate, asohist_billtozip, asohist_shiptoname, asohist_shiptoaddress1, asohist_shiptoaddress2, asohist_shiptoaddress3, asohist_shiptocity, asohist_shiptostate, asohist_shiptozip, asohist_shipto_id, asohist_shipvia, asohist_salesrep_id, asohist_misc_type, asohist_misc_descrip, asohist_misc_id, asohist_commission, asohist_commissionpaid, asohist_doctype, asohist_orderdate, asohist_imported, asohist_ponumber, asohist_curr_id, asohist_taxtype_id, asohist_taxzone_id ) SELECT cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipdate, cohist_invcdate, cohist_duedate, cohist_promisedate, cohist_ordernumber, cohist_invcnumber, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_shipto_id, cohist_shipvia, cohist_salesrep_id, cohist_misc_type, cohist_misc_descrip, cohist_misc_id, cohist_commission, cohist_commissionpaid, cohist_doctype, cohist_orderdate, cohist_imported, cohist_ponumber, cohist_curr_id, cohist_taxtype_id, cohist_taxzone_id FROM cohist WHERE (cohist_id=pSohistid); INSERT INTO asohisttax ( taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM cohisttax WHERE (taxhist_parent_id=pSohistid); DELETE FROM cohisttax WHERE (taxhist_parent_id=pSohistid); DELETE FROM cohist WHERE (cohist_id=pSohistid); RETURN pSohistid; END; $_$; ALTER FUNCTION public.archivesaleshistory(integer) OWNER TO admin; -- -- Name: arcurrgain(integer, integer, numeric, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION arcurrgain(integer, integer, numeric, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAropenId ALIAS FOR $1; pCurrId ALIAS FOR $2; pValue ALIAS FOR $3; pDate ALIAS FOR $4; _start DATE; _end DATE; _gain NUMERIC; _r RECORD; BEGIN IF (pAropenId IS NULL OR pValue = 0) THEN RETURN 0; END IF; SELECT aropen_docdate, aropen_curr_id, aropen_curr_rate INTO _r FROM aropen WHERE (aropen_id=pAropenId); IF (_r.aropen_docdate > pDate) THEN _gain := (currToBase(pCurrId, pValue, pDate) - currToCurr(pCurrId,_r.aropen_curr_id, pValue, pDate) / _r.aropen_curr_rate) * -1; ELSE _gain := currToCurr(pCurrId,_r.aropen_curr_id, pValue, pDate) / _r.aropen_curr_rate - currToBase(pCurrId, pValue, pDate); END IF; IF (_gain IS NULL) THEN RAISE EXCEPTION 'Error processing currency gain/loss.'; END IF; RETURN _gain; END; $_$; ALTER FUNCTION public.arcurrgain(integer, integer, numeric, date) OWNER TO admin; -- -- Name: armor(bytea); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION armor(bytea) RETURNS text LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_armor'; ALTER FUNCTION public.armor(bytea) OWNER TO admin; -- -- Name: invbal; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE invbal ( invbal_id integer NOT NULL, invbal_period_id integer, invbal_itemsite_id integer, invbal_qoh_beginning numeric(18,6) NOT NULL, invbal_qoh_ending numeric(18,6) NOT NULL, invbal_qty_in numeric(18,6) NOT NULL, invbal_qty_out numeric(18,6) NOT NULL, invbal_value_beginning numeric(12,2) NOT NULL, invbal_value_ending numeric(12,2) NOT NULL, invbal_value_in numeric(12,2) NOT NULL, invbal_value_out numeric(12,2) NOT NULL, invbal_nn_beginning numeric(18,6) NOT NULL, invbal_nn_ending numeric(18,6) NOT NULL, invbal_nn_in numeric(18,6) NOT NULL, invbal_nn_out numeric(18,6) NOT NULL, invbal_nnval_beginning numeric(12,2) NOT NULL, invbal_nnval_ending numeric(12,2) NOT NULL, invbal_nnval_in numeric(12,2) NOT NULL, invbal_nnval_out numeric(12,2) NOT NULL, invbal_dirty boolean DEFAULT true NOT NULL ); ALTER TABLE invbal OWNER TO admin; -- -- Name: asofinvbal(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION asofinvbal(integer, date) RETURNS SETOF invbal LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteId ALIAS FOR $1; pAsofDate ALIAS FOR $2; _result invbal%ROWTYPE; _i RECORD; _h RECORD; _r RECORD; _prevCostmethod TEXT := 'A'; _prevDate TIMESTAMP WITH TIME ZONE; _runningQty NUMERIC := 0; _runningNn NUMERIC := 0; _runningValue NUMERIC := 0; _runningNnval NUMERIC := 0; BEGIN /* This is a base function to gather data. Because it is STABLE it should only need to be calculated once, even though it is likely to be called several times by other functions in parent query to present the various data. */ -- First make sure inventory balance is forward updated PERFORM forwardUpdateItemsite(pItemsiteId); -- Next find the previous period balace to use as a starting point SELECT invbal.*, period_start, itemsite_costmethod INTO _i FROM invbal JOIN itemsite ON (invbal_itemsite_id=itemsite_id) JOIN period ON (invbal_period_id=period_id) WHERE ((invbal_itemsite_id=pItemsiteId) AND (pAsofDate >= period_start)) ORDER BY period_start DESC LIMIT 1; _runningQty := _i.invbal_qoh_beginning; _runningNn := _i.invbal_nn_beginning; _runningValue := _i.invbal_value_beginning; _runningNnval := _i.invbal_nnval_beginning; _prevDate := _i.period_start; _prevCostmethod := _i.itemsite_costmethod; FOR _r IN SELECT invhist_id, invhist_created, invhist_invqty, invhist_transtype, invhist_unitcost, invhist_costmethod, itemsite_item_id, invhistSense(invhist_id) AS sense FROM invhist JOIN itemsite ON (itemsite_id=invhist_itemsite_id) WHERE ((invhist_itemsite_id=pItemsiteId) AND (invhist_transdate::date BETWEEN _i.period_start AND pAsofdate)) ORDER BY invhist_created, invhist_id LOOP -- Update balances changed by any standard cost update between transactions IF (_prevCostmethod = 'S' AND _runningQty != 0) THEN FOR _h IN SELECT costhist_oldcost, costhist_newcost FROM costhist JOIN item ON (costhist_item_id=item_id) JOIN itemsite ON (itemsite_item_id=item_id) WHERE ((itemsite_id=pItemsiteId) AND (costhist_date BETWEEN _prevDate AND _r.invhist_created) AND (costhist_type IN ('S','D'))) LOOP _runningValue := _runningValue + round((_h.costhist_newcost-_h.costhist_oldcost) * _runningQty,2); _runningNnval := _runningNnval + round((_h.costhist_newcost-_h.costhist_oldcost) * _runningNn,2); END LOOP; END IF; _prevDate := _r.invhist_created; _prevCostmethod := _r.invhist_costmethod; _runningQty := _runningQty + _r.invhist_invqty * _r.sense; _runningValue := _runningValue + round( _r.invhist_invqty * _r.sense * _r.invhist_unitcost,2); IF (_r.invhist_transtype = 'NN') THEN _runningNn := _runningNn + _r.invhist_invqty * -1; _runningNnval := _runningNnval + round( _r.invhist_invqty * -1 * _r.invhist_unitcost,2); END IF; END LOOP; _prevDate := COALESCE(_prevDate, _i.period_start); _prevCostmethod := COALESCE(_r.invhist_costmethod, _i.itemsite_costmethod); IF (_prevCostmethod = 'S' AND _runningQty != 0) THEN FOR _h IN SELECT costhist_oldcost, costhist_newcost FROM costhist JOIN item ON (costhist_item_id=item_id) JOIN itemsite ON (itemsite_item_id=item_id) WHERE ((itemsite_id=pItemsiteId) AND (costhist_date BETWEEN _prevDate AND CAST(pAsofDate + 1 AS TIMESTAMP WITH TIME ZONE)) AND (costhist_type IN ('S','D'))) LOOP _runningValue := _runningValue + round((_h.costhist_newcost-_h.costhist_oldcost) * _runningQty,2); _runningNnval := _runningNnval + round((_h.costhist_newcost-_h.costhist_oldcost) * _runningNn,2); END LOOP; END IF; _result := _i; _result.invbal_qoh_ending := _runningQty; _result.invbal_value_ending := _runningValue; _result.invbal_nn_ending := _runningNn; _result.invbal_nnval_ending := _runningNnval; RETURN NEXT _result; RETURN; END; $_$; ALTER FUNCTION public.asofinvbal(integer, date) OWNER TO admin; -- -- Name: asofinvnn(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION asofinvnn(integer, date) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteId ALIAS FOR $1; pAsofDate ALIAS FOR $2; _result NUMERIC; BEGIN SELECT invbal_nn_ending INTO _result FROM asofinvbal(pItemsiteId, pAsofDate); RETURN COALESCE(_result, 0); END; $_$; ALTER FUNCTION public.asofinvnn(integer, date) OWNER TO admin; -- -- Name: asofinvqty(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION asofinvqty(integer, date) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteId ALIAS FOR $1; pAsofDate ALIAS FOR $2; _result NUMERIC; BEGIN SELECT invbal_qoh_ending INTO _result FROM asofinvbal(pItemsiteId, pAsofDate); RETURN COALESCE(_result, 0); END; $_$; ALTER FUNCTION public.asofinvqty(integer, date) OWNER TO admin; -- -- Name: assessfinancecharge(integer, date, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION assessfinancecharge(paropenid integer, passessdate date, passessamount numeric) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _fc RECORD; _ar RECORD; _invcheadid INTEGER; BEGIN -- cache some information SELECT * INTO _fc FROM fincharg; IF (NOT FOUND) THEN RAISE EXCEPTION 'assessFinanceCharge, configuration not set.'; END IF; SELECT * INTO _ar FROM aropen WHERE (aropen_id=pAropenid); IF (NOT FOUND) THEN RAISE EXCEPTION 'assessFinanceCharge, aropen not found.'; END IF; -- create invoice head INSERT INTO invchead ( invchead_cust_id, invchead_shipto_id, invchead_ordernumber, invchead_orderdate, invchead_posted, invchead_printed, invchead_invcnumber, invchead_invcdate, invchead_shipdate, invchead_ponumber, invchead_shipvia, invchead_fob, invchead_billto_name, invchead_billto_address1, invchead_billto_address2, invchead_billto_address3, invchead_billto_city, invchead_billto_state, invchead_billto_zipcode, invchead_billto_phone, invchead_shipto_name, invchead_shipto_address1, invchead_shipto_address2, invchead_shipto_address3, invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode, invchead_shipto_phone, invchead_salesrep_id, invchead_commission, invchead_terms_id, invchead_freight, invchead_misc_amount, invchead_misc_descrip, invchead_misc_accnt_id, invchead_payment, invchead_paymentref, invchead_notes, invchead_billto_country, invchead_shipto_country, invchead_prj_id, invchead_curr_id, invchead_gldistdate, invchead_recurring, invchead_recurring_interval, invchead_recurring_type, invchead_recurring_until, invchead_recurring_invchead_id, invchead_shipchrg_id, invchead_taxzone_id, invchead_void, invchead_saletype_id, invchead_shipzone_id ) SELECT invchead_cust_id, invchead_shipto_id, invchead_ordernumber, invchead_orderdate, FALSE, FALSE, fetchInvcNumber(), pAssessDate, invchead_shipdate, invchead_ponumber, invchead_shipvia, invchead_fob, invchead_billto_name, invchead_billto_address1, invchead_billto_address2, invchead_billto_address3, invchead_billto_city, invchead_billto_state, invchead_billto_zipcode, invchead_billto_phone, invchead_shipto_name, invchead_shipto_address1, invchead_shipto_address2, invchead_shipto_address3, invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode, invchead_shipto_phone, invchead_salesrep_id, 0.0, invchead_terms_id, 0.0, 0.0, NULL, NULL, 0.0, NULL, '', invchead_billto_country, invchead_shipto_country, invchead_prj_id, invchead_curr_id, NULL, FALSE, NULL, NULL, NULL, NULL, invchead_shipchrg_id, invchead_taxzone_id, invchead_void, invchead_saletype_id, invchead_shipzone_id FROM invchead WHERE (invchead_invcnumber=_ar.aropen_docnumber) RETURNING invchead_id INTO _invcheadid; -- create invoice item INSERT INTO invcitem ( invcitem_invchead_id, invcitem_linenumber, invcitem_item_id, invcitem_warehous_id, invcitem_custpn, invcitem_number, invcitem_descrip, invcitem_ordered, invcitem_billed, invcitem_custprice, invcitem_price, invcitem_notes, invcitem_salescat_id, invcitem_taxtype_id, invcitem_qty_uom_id, invcitem_qty_invuomratio, invcitem_price_uom_id, invcitem_price_invuomratio, invcitem_coitem_id, invcitem_updateinv, invcitem_rev_accnt_id ) VALUES ( _invcheadid, 1, -1, -1, NULL, _fc.fincharg_markoninvoice, -- - enhance data shown in the item description for the invoice line to indicate which invoice is affected -- - Feature Request 23344 -- 'Finance Charge Assessment', 'Finance Charge Assessment - Invoice Number ' || _ar.aropen_docnumber || ' - Past Due Balance ' || (_ar.aropen_amount - _ar.aropen_paid) || ' Due Date - ' || _ar.aropen_duedate, 1.0, 1.0, pAssessAmount, pAssessAmount, '', _fc.fincharg_salescat_id, NULL, NULL, 1.0, NULL, 1.0, NULL, FALSE, _fc.fincharg_accnt_id ); -- update aropen UPDATE aropen SET aropen_fincharg_date = pAssessDate, aropen_fincharg_amount = COALESCE(aropen_fincharg_amount, 0.0) + pAssessAmount WHERE (aropen_id=pAropenid); RETURN 0; END; $$; ALTER FUNCTION public.assessfinancecharge(paropenid integer, passessdate date, passessamount numeric) OWNER TO admin; -- -- Name: attachcontact(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION attachcontact(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pcntctId ALIAS FOR $1; pcrmacctId ALIAS FOR $2; BEGIN UPDATE cntct SET cntct_crmacct_id = pcrmacctId WHERE cntct_id = pcntctId; RETURN 0; END; $_$; ALTER FUNCTION public.attachcontact(integer, integer) OWNER TO admin; -- -- Name: attachquotetoopportunity(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION attachquotetoopportunity(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuheadid ALIAS FOR $1; pOpheadid ALIAS FOR $2; BEGIN -- Check Quote IF (NOT EXISTS(SELECT quhead_id FROM quhead WHERE (quhead_id=pQuheadid))) THEN RETURN -1; END IF; -- Check Opportunity IF (NOT EXISTS(SELECT ophead_id FROM ophead WHERE (ophead_id=pOpheadid))) THEN RETURN -2; END IF; -- Cannot attach if already attached IF (EXISTS(SELECT quhead_id FROM quhead WHERE ((quhead_id=pQuheadid) AND (quhead_ophead_id IS NOT NULL)))) THEN RETURN -3; END IF; UPDATE quhead SET quhead_ophead_id=pOpheadid WHERE (quhead_id=pQuheadid); RETURN 0; END; $_$; ALTER FUNCTION public.attachquotetoopportunity(integer, integer) OWNER TO admin; -- -- Name: attachsalesordertoopportunity(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION attachsalesordertoopportunity(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; pOpheadid ALIAS FOR $2; BEGIN -- Check Sales Order IF (NOT EXISTS(SELECT cohead_id FROM cohead WHERE (cohead_id=pSoheadid))) THEN RETURN -1; END IF; -- Check Opportunity IF (NOT EXISTS(SELECT ophead_id FROM ophead WHERE (ophead_id=pOpheadid))) THEN RETURN -2; END IF; -- Cannot attach if already attached IF (EXISTS(SELECT cohead_id FROM cohead WHERE ((cohead_id=pSoheadid) AND (cohead_ophead_id IS NOT NULL)))) THEN RETURN -3; END IF; UPDATE cohead SET cohead_ophead_id=pOpheadid WHERE (cohead_id=pSoheadid); RETURN 0; END; $_$; ALTER FUNCTION public.attachsalesordertoopportunity(integer, integer) OWNER TO admin; -- -- Name: averagesalesprice(integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION averagesalesprice(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _p RECORD; BEGIN -- Returns value in base currency -- ToDo: is cohist_shipdate the right DATE to use? SELECT SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitprice, cohist_shipdate)) AS totalsales, SUM(cohist_qtyshipped) AS totalship INTO _p FROM cohist WHERE ( (cohist_itemsite_id=pItemsiteid) AND (cohist_invcdate BETWEEN pStartDate AND pEndDate) ); IF ( (_p.totalship IS NULL) OR (_p.totalship = 0) ) THEN RETURN 0; ELSE RETURN (_p.totalsales / _p.totalship); END IF; END; $_$; ALTER FUNCTION public.averagesalesprice(integer, date, date) OWNER TO admin; -- -- Name: avgcost(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION avgcost(pitemsiteid integer) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _value NUMERIC; _qoh NUMERIC; BEGIN SELECT itemsite_value, itemsite_qtyonhand INTO _value, _qoh FROM itemsite WHERE(itemsite_id=pItemsiteid); IF (_qoh = 0.0) THEN RETURN 0.0; END IF; RETURN _value / _qoh; END; $$; ALTER FUNCTION public.avgcost(pitemsiteid integer) OWNER TO admin; -- -- Name: balanceitemsite(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION balanceitemsite(pitemsiteid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _itemlocseries INTEGER; _balanced NUMERIC; _qoh NUMERIC; BEGIN -- Make sure that that passed Itemsite is MLC or Lot/Serial controlled IF ( ( SELECT (NOT ( (itemsite_loccntrl) OR (itemsite_controlmethod IN ('L', 'S')) )) FROM itemsite WHERE (itemsite_id=pItemsiteid) ) ) THEN RETURN 0; END IF; IF ( ( SELECT itemsite_freeze FROM itemsite WHERE(itemsite_id=pItemsiteid) ) ) THEN RETURN -1; END IF; -- Calculate the qoh SELECT COALESCE(SUM(itemloc_qty), 0) INTO _balanced FROM itemloc WHERE (itemloc_itemsite_id=pItemsiteid); -- Post an AD Transaction SELECT invAdjustment( itemsite_id, (_balanced - itemsite_qtyonhand), 'Balance', 'Inventory Balance' ) INTO _itemlocseries FROM itemsite WHERE (itemsite_id=pItemsiteid); -- Post the itemloc series which will postIntoTrialBalance and postInvHist PERFORM postItemlocSeries(_itemlocseries); -- Kill the resultant distribution records DELETE FROM itemlocdist WHERE (itemlocdist_series=_itemlocseries); RETURN 1; END; $$; ALTER FUNCTION public.balanceitemsite(pitemsiteid integer) OWNER TO admin; -- -- Name: bankreconciliation(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION bankreconciliation(pbankrecid integer, ptask text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- posting and reopening bank reconciliations are nearly identical. -- the main differences revolve around what cleanup is done before starting. -- other than that, posting and reopening touch the same g/l accounts but with -- debits and credits reversed. DECLARE _accntid INTEGER; _bankrecid INTEGER; _gltransid INTEGER; _post BOOLEAN; _r RECORD; _result INTEGER; _sequence INTEGER; _sign INTEGER := 1; _tax RECORD; BEGIN CASE lower(pTask) WHEN 'post' THEN _post = TRUE; WHEN 'reopen' THEN _post = FALSE; ELSE RAISE EXCEPTION 'bankReconciliation got an invalid task %1 [xtuple: bankReconciliation, -2, %2]', pTask, pTask; END CASE; -- Check the accnt information to make sure it is valid SELECT accnt_id INTO _accntid FROM bankrec JOIN bankaccnt ON (bankrec_bankaccnt_id=bankaccnt_id) JOIN accnt ON (bankaccnt_accnt_id=accnt_id) WHERE (bankrec_id=pBankrecid); IF ( NOT FOUND ) THEN RAISE EXCEPTION 'bankReconciliation %1 %2 did not find the bank''s G/L account [xtuple: bankReconciliation, -1, %3, %4]', pTask, pBankrecid, pTask, pBankrecid; END IF; IF _post THEN DELETE FROM bankrecitem WHERE ( (NOT bankrecitem_cleared) AND (bankrecitem_bankrec_id=pBankrecid) ); -- Post any cleared bankadj items and convert the bankrecitem FOR _r IN SELECT bankrecitem_id, bankrecitem_source_id FROM bankrecitem, bankadj WHERE ( (bankrecitem_source = 'AD') AND (bankrecitem_source_id=bankadj_id) AND (bankrecitem_cleared) AND (NOT bankadj_posted) AND (bankrecitem_bankrec_id=pBankrecid) ) LOOP _sequence := postBankAdjustment(_r.bankrecitem_source_id); IF (_sequence < 0) THEN RAISE EXCEPTION 'postBankAdjustment %1 %2 failed during bankReconciliation [xtuple: postBankAdjustment, -10, %3, %4, %5]', pTask, pBankrecid, pTask, pBankrecid, _sequence; END IF; SELECT gltrans_id INTO _gltransid FROM gltrans WHERE ( (gltrans_sequence=_sequence) AND (gltrans_accnt_id=_accntid) ); IF ( NOT FOUND ) THEN RAISE EXCEPTION 'bankReconciliation %1 %2 did not find exactly one gltrans record for %3 [xtuple: bankReconciliation, -11, %4, %5, %6]', pTask, pBankrecid, _sequence, pTask, pBankrecid, _sequence; END IF; UPDATE bankrecitem SET bankrecitem_source = 'GL', bankrecitem_source_id=_gltransid WHERE (bankrecitem_id=_r.bankrecitem_id); END LOOP; ELSE -- NOT _post, therefore must be reopen _sign := -1; SELECT bankrec_id INTO _bankrecid FROM bankrec WHERE (NOT bankrec_posted); IF (FOUND) THEN -- Delete any bankrecitem records for unposted periods DELETE FROM bankrecitem WHERE (bankrecitem_bankrec_id=_bankrecid); -- Delete any bankrec records for unposted period DELETE FROM bankrec WHERE (bankrec_id=_bankrecid); END IF; END IF; IF (fetchMetricBool('CashBasedTax')) THEN -- Cash based tax distributions -- GL Transactions SELECT fetchGLSequence() INTO _sequence; FOR _r IN SELECT * FROM bankrecitem WHERE ( (bankrecitem_cleared) AND (bankrecitem_bankrec_id=pBankrecid) ) LOOP -- first, debit the tax liability clearing account -- and credit the tax liability distribution account -- for each tax code FOR _tax IN SELECT docnumber, custname, distdate, source, doctype, tax_sales_accnt_id, tax_dist_accnt_id, ROUND(currToBase(currid, ROUND(SUM(taxhist_tax),2), taxhist_docdate) * percentpaid, 2) AS taxbasevalue FROM ( -- Cash receipt, gltrans SELECT aropen_docnumber AS docnumber, cust_name AS custname, aropen_curr_id AS currid, gltrans_date AS distdate, (cashrcptitem_amount / aropen_amount) AS percentpaid, gltrans_source AS source, gltrans_doctype AS doctype, tax_sales_accnt_id, tax_dist_accnt_id, taxhist_tax, taxhist_docdate FROM gltrans JOIN cashrcpt ON ((gltrans_source='A/R') AND (gltrans_doctype='CR') AND (gltrans_misc_id=cashrcpt_id)) JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id) JOIN aropen ON (aropen_id=cashrcptitem_aropen_id) JOIN custinfo ON (cust_id=aropen_cust_id) JOIN cohist ON (cohist_invcnumber=aropen_docnumber AND cohist_doctype=aropen_doctype) JOIN cohisttax ON (taxhist_parent_id=cohist_id) JOIN tax ON (tax_id=taxhist_tax_id) WHERE (gltrans_id=_r.bankrecitem_source_id) -- Cash receipt, sltrans UNION SELECT aropen_docnumber AS docnumber, cust_name AS custname, aropen_curr_id AS currid, sltrans_date AS distdate, (cashrcptitem_amount / aropen_amount) AS percentpaid, sltrans_source AS source, sltrans_doctype AS doctype, tax_sales_accnt_id, tax_dist_accnt_id, taxhist_tax, taxhist_docdate FROM sltrans JOIN cashrcpt ON ((sltrans_source='A/R') AND (sltrans_doctype='CR') AND (sltrans_misc_id=cashrcpt_id)) JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id) JOIN aropen ON (aropen_id=cashrcptitem_aropen_id) JOIN custinfo ON (cust_id=aropen_cust_id) JOIN cohist ON (cohist_invcnumber=aropen_docnumber AND cohist_doctype=aropen_doctype) JOIN cohisttax ON (taxhist_parent_id=cohist_id) JOIN tax ON (tax_id=taxhist_tax_id) WHERE (sltrans_id=_r.bankrecitem_source_id) -- Cash payment, gltrans UNION SELECT apopen_docnumber AS docnumber, vend_name AS vendname, apopen_curr_id AS currid, gltrans_date AS distdate, (checkitem_amount / apopen_amount) AS percentpaid, gltrans_source AS source, gltrans_doctype AS doctype, tax_sales_accnt_id, tax_dist_accnt_id, taxhist_tax, taxhist_docdate FROM gltrans JOIN checkhead ON ((gltrans_source='A/P') AND (gltrans_doctype='CK') AND (gltrans_misc_id=checkhead_id)) JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN apopen ON (apopen_id=checkitem_apopen_id) JOIN vohead ON (vohead_number=apopen_docnumber) JOIN vendinfo ON (vend_id=apopen_vend_id) JOIN voheadtax ON (taxhist_parent_id=vohead_id) JOIN tax ON (tax_id=taxhist_tax_id) WHERE (gltrans_id=_r.bankrecitem_source_id) UNION SELECT apopen_docnumber AS docnumber, vend_name AS vendname, apopen_curr_id AS currid, gltrans_date AS distdate, (checkitem_amount / apopen_amount) AS percentpaid, gltrans_source AS source, gltrans_doctype AS doctype, tax_sales_accnt_id, tax_dist_accnt_id, taxhist_tax, taxhist_docdate FROM gltrans JOIN checkhead ON ((gltrans_source='A/P') AND (gltrans_doctype='CK') AND (gltrans_misc_id=checkhead_id)) JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN apopen ON (apopen_id=checkitem_apopen_id) JOIN vohead ON (vohead_number=apopen_docnumber) JOIN vendinfo ON (vend_id=apopen_vend_id) JOIN voitem ON (voitem_vohead_id=vohead_id) JOIN voitemtax ON (taxhist_parent_id=voitem_id) JOIN tax ON (tax_id=taxhist_tax_id) WHERE (gltrans_id=_r.bankrecitem_source_id) -- Cash payment, sltrans UNION SELECT apopen_docnumber AS docnumber, vend_name AS vendname, apopen_curr_id AS currid, sltrans_date AS distdate, (checkitem_amount / apopen_amount) AS percentpaid, sltrans_source AS source, sltrans_doctype AS doctype, tax_sales_accnt_id, tax_dist_accnt_id, taxhist_tax, taxhist_docdate FROM sltrans JOIN checkhead ON ((sltrans_source='A/P') AND (sltrans_doctype='CK') AND (sltrans_misc_id=checkhead_id)) JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN apopen ON (apopen_id=checkitem_apopen_id) JOIN vohead ON (vohead_number=apopen_docnumber) JOIN vendinfo ON (vend_id=apopen_vend_id) JOIN voheadtax ON (taxhist_parent_id=vohead_id) JOIN tax ON (tax_id=taxhist_tax_id) WHERE (sltrans_id=_r.bankrecitem_source_id) UNION SELECT apopen_docnumber AS docnumber, vend_name AS vendname, apopen_curr_id AS currid, sltrans_date AS distdate, (checkitem_amount / apopen_amount) AS percentpaid, sltrans_source AS source, sltrans_doctype AS doctype, tax_sales_accnt_id, tax_dist_accnt_id, taxhist_tax, taxhist_docdate FROM sltrans JOIN checkhead ON ((sltrans_source='A/P') AND (sltrans_doctype='CK') AND (sltrans_misc_id=checkhead_id)) JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN apopen ON (apopen_id=checkitem_apopen_id) JOIN vohead ON (vohead_number=apopen_docnumber) JOIN vendinfo ON (vend_id=apopen_vend_id) JOIN voitem ON (voitem_vohead_id=vohead_id) JOIN voitemtax ON (taxhist_parent_id=voitem_id) JOIN tax ON (tax_id=taxhist_tax_id) WHERE (sltrans_id=_r.bankrecitem_source_id) ) AS data GROUP BY docnumber, custname, currid, distdate, percentpaid, source, doctype, tax_sales_accnt_id, tax_dist_accnt_id, taxhist_docdate LOOP SELECT insertIntoGLSeries( _sequence, _tax.source, _tax.doctype, _tax.docnumber, _tax.tax_dist_accnt_id, _tax.taxbasevalue * _sign, COALESCE(_r.bankrecitem_effdate, _tax.distdate), _tax.custname ) INTO _result; IF (_result < 0) THEN RAISE EXCEPTION 'insertIntoGLSeries failed, result=%', _result; END IF; SELECT insertIntoGLSeries( _sequence, _tax.source, _tax.doctype, _tax.docnumber, _tax.tax_sales_accnt_id, (_tax.taxbasevalue * -1.0 * _sign), COALESCE(_r.bankrecitem_effdate, _tax.distdate), _tax.custname ) INTO _result; IF (_result < 0) THEN RAISE EXCEPTION 'insertIntoGLSeries failed, result=%', _result; END IF; END LOOP; -- second, create a taxpay row for each taxhist FOR _tax IN SELECT taxhist_id, applyid, distdate, ROUND(taxhist_tax * percentpaid, 2) AS taxpaid FROM ( -- Cash receipt, gltrans SELECT taxhist_id, aropen_id AS applyid, gltrans_date AS distdate, taxhist_tax, (cashrcptitem_amount / aropen_amount) AS percentpaid FROM gltrans JOIN cashrcpt ON ((gltrans_source='A/R') AND (gltrans_doctype='CR') AND (gltrans_misc_id=cashrcpt_id)) JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id) JOIN aropen ON (aropen_id=cashrcptitem_aropen_id) JOIN cohist ON (cohist_invcnumber=aropen_docnumber AND cohist_doctype=aropen_doctype) JOIN cohisttax ON (taxhist_parent_id=cohist_id) WHERE (gltrans_id=_r.bankrecitem_source_id) -- Cash receipt, sltrans UNION SELECT taxhist_id, aropen_id AS applyid, sltrans_date AS distdate, taxhist_tax, (cashrcptitem_amount / aropen_amount) AS percentpaid FROM sltrans JOIN cashrcpt ON ((sltrans_source='A/R') AND (sltrans_doctype='CR') AND (sltrans_misc_id=cashrcpt_id)) JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id) JOIN aropen ON (aropen_id=cashrcptitem_aropen_id) JOIN cohist ON (cohist_invcnumber=aropen_docnumber AND cohist_doctype=aropen_doctype) JOIN cohisttax ON (taxhist_parent_id=cohist_id) WHERE (sltrans_id=_r.bankrecitem_source_id) -- Cash payment, gltrans UNION SELECT taxhist_id, apopen_id AS applyid, gltrans_date AS distdate, taxhist_tax, (checkitem_amount / apopen_amount) AS percentpaid FROM gltrans JOIN checkhead ON ((gltrans_source='A/P') AND (gltrans_doctype='CK') AND (gltrans_misc_id=checkhead_id)) JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN apopen ON (apopen_id=checkitem_apopen_id) JOIN vohead ON (vohead_number=apopen_docnumber) JOIN voheadtax ON (taxhist_parent_id=vohead_id) WHERE (gltrans_id=_r.bankrecitem_source_id) UNION SELECT taxhist_id, apopen_id AS applyid, gltrans_date AS distdate, taxhist_tax, (checkitem_amount / apopen_amount) AS percentpaid FROM gltrans JOIN checkhead ON ((gltrans_source='A/P') AND (gltrans_doctype='CK') AND (gltrans_misc_id=checkhead_id)) JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN apopen ON (apopen_id=checkitem_apopen_id) JOIN vohead ON (vohead_number=apopen_docnumber) JOIN voitem ON (voitem_vohead_id=vohead_id) JOIN voitemtax ON (taxhist_parent_id=voitem_id) WHERE (gltrans_id=_r.bankrecitem_source_id) -- Cash payment, sltrans UNION SELECT taxhist_id, apopen_id AS applyid, sltrans_date AS distdate, taxhist_tax, (checkitem_amount / apopen_amount) AS percentpaid FROM sltrans JOIN checkhead ON ((sltrans_source='A/P') AND (sltrans_doctype='CK') AND (sltrans_misc_id=checkhead_id)) JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN apopen ON (apopen_id=checkitem_apopen_id) JOIN vohead ON (vohead_number=apopen_docnumber) JOIN voheadtax ON (taxhist_parent_id=vohead_id) WHERE (sltrans_id=_r.bankrecitem_source_id) UNION SELECT taxhist_id, apopen_id AS applyid, sltrans_date AS distdate, taxhist_tax, (checkitem_amount / apopen_amount) AS percentpaid FROM sltrans JOIN checkhead ON ((sltrans_source='A/P') AND (sltrans_doctype='CK') AND (sltrans_misc_id=checkhead_id)) JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN apopen ON (apopen_id=checkitem_apopen_id) JOIN vohead ON (vohead_number=apopen_docnumber) JOIN voitem ON (voitem_vohead_id=vohead_id) JOIN voitemtax ON (taxhist_parent_id=voitem_id) WHERE (sltrans_id=_r.bankrecitem_source_id) ) AS data LOOP IF _post THEN INSERT INTO taxpay ( taxpay_taxhist_id, taxpay_apply_id, taxpay_distdate, taxpay_tax ) VALUES ( _tax.taxhist_id, _tax.applyid, COALESCE(_r.bankrecitem_effdate, _tax.distdate), _tax.taxpaid ); ELSE DELETE FROM taxpay WHERE ((taxpay_taxhist_id=_tax.taxhist_id) AND (taxpay_apply_id=_tax.applyid) AND (taxpay_distdate=COALESCE(_r.bankrecitem_effdate, _tax.distdate)) AND (taxpay_tax=_tax.taxpaid)); END IF; END LOOP; END LOOP; SELECT postGLSeries(_sequence, fetchJournalNumber('GL-MISC')) INTO _result; IF (_result < 0) THEN RAISE EXCEPTION 'postGLSeries failed, result=%', _result; END IF; END IF; UPDATE gltrans SET gltrans_rec = _post WHERE ( (gltrans_id IN (SELECT bankrecitem_source_id FROM bankrecitem WHERE ((bankrecitem_source = 'GL') AND (bankrecitem_cleared) AND (bankrecitem_bankrec_id=pBankrecid) ) ) ) AND (gltrans_accnt_id=_accntid) ) ; UPDATE sltrans SET sltrans_rec = _post WHERE ( (sltrans_id IN (SELECT bankrecitem_source_id FROM bankrecitem WHERE ((bankrecitem_source = 'SL') AND (bankrecitem_cleared) AND (bankrecitem_bankrec_id=pBankrecid) ) ) ) AND (sltrans_accnt_id=_accntid) ) ; UPDATE bankrec SET bankrec_posted = _post, bankrec_postdate = CASE _post WHEN TRUE THEN now() ELSE NULL END WHERE (bankrec_id=pBankrecid); RETURN pBankrecid; END; $$; ALTER FUNCTION public.bankreconciliation(pbankrecid integer, ptask text) OWNER TO admin; -- -- Name: bomcontains(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION bomcontains(integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pparentitemid ALIAS FOR $1; pchilditemid ALIAS FOR $2; _bomworksetid INTEGER; _result BOOLEAN; BEGIN _bomworksetid := indentedWhereUsed(pchilditemid); _result := EXISTS(SELECT bomwork_id FROM bomwork WHERE ((bomwork_set_id=_bomworksetid) AND (bomwork_item_id=pparentitemid) )); PERFORM deleteBOMWorkset(_bomworksetid); RETURN _result; END; $_$; ALTER FUNCTION public.bomcontains(integer, integer) OWNER TO admin; -- -- Name: bomhistsequence(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION bomhistsequence(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pHistid ALIAS FOR $1; _wid INTEGER; _seqnum TEXT; _bomhist RECORD; BEGIN _wid := pHistid; SELECT bomhist_parent_id AS parent, to_char(bomhist_seqnumber, '00009') AS seq INTO _bomhist FROM bomhist WHERE bomhist_seq_id=_wid; IF (FOUND) THEN _seqnum := _bomhist.seq; _wid := _bomhist.parent; WHILE (_wid != -1) LOOP SELECT bomhist_parent_id AS parent, to_char(bomhist_seqnumber, '00009') AS seq INTO _bomhist FROM bomhist WHERE bomhist_seq_id=_wid; IF (FOUND) THEN _seqnum := _bomhist.seq || '-' || _seqnum; _wid := _bomhist.parent; ELSE _wid := -1; END IF; END LOOP; ELSE _seqnum := ''::TEXT; END IF; RETURN _seqnum; END; $_$; ALTER FUNCTION public.bomhistsequence(integer) OWNER TO admin; -- -- Name: bomitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE bomitem ( bomitem_id integer DEFAULT nextval(('bomitem_bomitem_id_seq'::text)::regclass) NOT NULL, bomitem_parent_item_id integer NOT NULL, bomitem_seqnumber integer, bomitem_item_id integer NOT NULL, bomitem_qtyper numeric(20,8) NOT NULL, bomitem_scrap numeric(8,4) NOT NULL, bomitem_status character(1), bomitem_effective date NOT NULL, bomitem_expires date NOT NULL, bomitem_createwo boolean NOT NULL, bomitem_issuemethod character(1) NOT NULL, bomitem_schedatwooper boolean NOT NULL, bomitem_ecn text, bomitem_moddate date, bomitem_subtype character(1) NOT NULL, bomitem_uom_id integer NOT NULL, bomitem_rev_id integer DEFAULT (-1), bomitem_booitem_seq_id integer DEFAULT (-1), bomitem_char_id integer, bomitem_value text, bomitem_notes text, bomitem_ref text, bomitem_qtyfxd numeric(20,8) DEFAULT 0 NOT NULL, bomitem_issuewo boolean DEFAULT false NOT NULL, CONSTRAINT bomitem_bomitem_issuemethod_check CHECK ((((bomitem_issuemethod = 'M'::bpchar) OR (bomitem_issuemethod = 'S'::bpchar)) OR (bomitem_issuemethod = 'L'::bpchar))), CONSTRAINT bomitem_bomitem_subtype_check CHECK ((((bomitem_subtype = 'N'::bpchar) OR (bomitem_subtype = 'I'::bpchar)) OR (bomitem_subtype = 'B'::bpchar))) ); ALTER TABLE bomitem OWNER TO admin; -- -- Name: TABLE bomitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE bomitem IS 'Bill of Materials (BOM) component Items information'; -- -- Name: COLUMN bomitem.bomitem_qtyfxd; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN bomitem.bomitem_qtyfxd IS 'The fixed quantity required'; -- -- Name: bomitem(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION bomitem(integer) RETURNS SETOF bomitem LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT * FROM bomitem WHERE ((bomitem_parent_item_id=$1) AND (bomitem_rev_id=getActiveRevId('BOM',$1))); $_$; ALTER FUNCTION public.bomitem(integer) OWNER TO admin; -- -- Name: bomitem(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION bomitem(integer, integer) RETURNS SETOF bomitem LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT * FROM bomitem WHERE ((bomitem_parent_item_id=$1) AND (bomitem_rev_id=$2)); $_$; ALTER FUNCTION public.bomitem(integer, integer) OWNER TO admin; -- -- Name: bomlevelbyitem(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION bomlevelbyitem(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; _cnt INTEGER; _result INTEGER; _bomitem RECORD; BEGIN _cnt := 0; BEGIN FOR _bomitem IN SELECT bomitem_parent_item_id FROM bomitem WHERE ((bomitem_item_id=pItemid) AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id)) AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1))) LOOP SELECT bomLevelByItem(_bomitem.bomitem_parent_item_id) + 1 INTO _result; IF (_result > _cnt) THEN _cnt := _result; END IF; END LOOP; EXCEPTION WHEN statement_too_complex THEN RAISE EXCEPTION 'potential recursive BOM found for item_id %', pItemid; END; return _cnt; END; $_$; ALTER FUNCTION public.bomlevelbyitem(integer) OWNER TO admin; -- -- Name: bomlevelbyitem(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION bomlevelbyitem(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pBomrevid ALIAS FOR $2; _cnt INTEGER; _result INTEGER; _bomitem RECORD; BEGIN _cnt := 0; BEGIN FOR _bomitem IN SELECT bomitem_parent_item_id FROM bomitem WHERE ((bomitem_item_id=pItemid) AND (bomitem_rev_id=pBomrevid) AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1))) LOOP SELECT bomLevelByItem(_bomitem.bomitem_parent_item_id, pBomrevid) + 1 INTO _result; IF (_result > _cnt) THEN _cnt := _result; END IF; END LOOP; EXCEPTION WHEN statement_too_complex THEN RAISE EXCEPTION 'potential recursive BOM found for item_id %', pItemid; END; return _cnt; END; $_$; ALTER FUNCTION public.bomlevelbyitem(integer, integer) OWNER TO admin; -- -- Name: bomworkeffective(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION bomworkeffective(integer, date) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE workid ALIAS FOR $1; effdate ALIAS FOR $2; _wid INTEGER; _bomwork RECORD; BEGIN _wid := workid; WHILE (_wid != -1) LOOP SELECT bomwork_parent_id AS parent, bomwork_effective AS effective INTO _bomwork FROM bomwork WHERE bomwork_id=_wid; IF (FOUND) THEN _wid := _bomwork.parent; IF (_bomwork.effective > effdate) THEN RETURN FALSE; END IF; ELSE _wid := -1; END IF; END LOOP; RETURN TRUE; END; $_$; ALTER FUNCTION public.bomworkeffective(integer, date) OWNER TO admin; -- -- Name: bomworkexpired(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION bomworkexpired(integer, date) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE workid ALIAS FOR $1; expdate ALIAS FOR $2; _wid INTEGER; _bomwork RECORD; BEGIN _wid := workid; WHILE (_wid != -1) LOOP SELECT bomwork_parent_id AS parent, bomwork_expires AS expires INTO _bomwork FROM bomwork WHERE bomwork_id=_wid; IF (FOUND) THEN _wid := _bomwork.parent; IF (_bomwork.expires <= expdate) THEN RETURN TRUE; END IF; ELSE _wid := -1; END IF; END LOOP; RETURN FALSE; END; $_$; ALTER FUNCTION public.bomworkexpired(integer, date) OWNER TO admin; -- -- Name: bomworkitemsequence(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION bomworkitemsequence(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWorkid ALIAS FOR $1; _wid INTEGER; _seqnum TEXT; _bomwork RECORD; BEGIN _wid := pWorkid; SELECT bomwork_parent_id AS parent, item_number AS seq INTO _bomwork FROM bomwork, item WHERE ((bomwork_id=_wid) AND (bomwork_item_id=item_id)); IF (FOUND) THEN _seqnum := _bomwork.seq; _wid := _bomwork.parent; WHILE (_wid != -1) LOOP SELECT bomwork_parent_id AS parent, item_number AS seq INTO _bomwork FROM bomwork, item WHERE ((bomwork_id=_wid) AND (bomwork_item_id=item_id)); IF (FOUND) THEN _seqnum := _bomwork.seq || '-' || _seqnum; _wid := _bomwork.parent; ELSE _wid := -1; END IF; END LOOP; ELSE _seqnum := ''::TEXT; END IF; RETURN _seqnum; END; $_$; ALTER FUNCTION public.bomworkitemsequence(integer) OWNER TO admin; -- -- Name: bomworksequence(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION bomworksequence(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWorkid ALIAS FOR $1; _wid INTEGER; _seqnum TEXT; _bomwork RECORD; BEGIN _wid := pWorkid; SELECT bomwork_parent_id AS parent, to_char(bomwork_seqnumber, '00009') AS seq INTO _bomwork FROM bomwork WHERE bomwork_id=_wid; IF (FOUND) THEN _seqnum := _bomwork.seq; _wid := _bomwork.parent; WHILE (_wid != -1) LOOP SELECT bomwork_parent_id AS parent, to_char(bomwork_seqnumber, '00009') AS seq INTO _bomwork FROM bomwork WHERE bomwork_id=_wid; IF (FOUND) THEN _seqnum := _bomwork.seq || '-' || _seqnum; _wid := _bomwork.parent; ELSE _wid := -1; END IF; END LOOP; ELSE _seqnum := ''::TEXT; END IF; RETURN _seqnum; END; $_$; ALTER FUNCTION public.bomworksequence(integer) OWNER TO admin; -- -- Name: buildinvbal(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION buildinvbal(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteId ALIAS FOR $1; _r RECORD; _prevCostmethod TEXT := 'A'; _prevDate TIMESTAMP WITH TIME ZONE; _runningQty NUMERIC := 0; _runningNn NUMERIC := 0; BEGIN -- Validate IF (SELECT (count(invhist_id) > 0) FROM invhist WHERE ((invhist_itemsite_id=pItemsiteId) AND (NOT invhist_posted))) THEN SELECT item_number, warehous_code INTO _r FROM itemsite JOIN item ON (item_id=itemsite_item_id) JOIN whsinfo ON (itemsite_warehous_id=warehous_id) WHERE (itemsite_id=pItemsiteId); RAISE EXCEPTION 'Unposted inventory transactions exist for % at % [xtuple: buildInvBal, -1, %, %]', _r.item_number, _r.warehous_code, _r.item_number, _r.warehous_code; END IF; -- Remove any old records DELETE FROM invbal WHERE invbal_itemsite_id=pItemsiteId; FOR _r IN SELECT invhist.*, itemsite_item_id, invhistSense(invhist_id) AS sense, item_number, warehous_code FROM invhist JOIN itemsite ON (itemsite_id=invhist_itemsite_id) JOIN item ON (itemsite_item_id=item_id) JOIN whsinfo ON (itemsite_warehous_id=warehous_id) WHERE (invhist_itemsite_id=pItemsiteId) ORDER BY invhist_created, invhist_id LOOP --RAISE NOTICE 'Calculating balances for Item % at Site % against transaction %, transtype %, sense %, qty %, %', _r.item_number, _r.warehous_code, _r.invhist_id, _r.invhist_transtype, _r.sense, _r.invhist_invqty, _r.invhist_comments; -- Update balances changed by any standard cost update between transactions IF (_prevCostmethod = 'S' AND _runningQty != 0) THEN PERFORM postValueintoInvBalance(pItemsiteid, costhist_date::date, _runningQty, _runningNn, costhist_oldcost, costhist_newcost ) FROM costhist WHERE ((costhist_item_id=_r.itemsite_item_id) AND (costhist_date BETWEEN _prevDate AND _r.invhist_created) AND (costhist_type IN ('S','D'))); END IF; -- Post transaction into inventory balance table PERFORM postIntoInvBalance(_r.invhist_id); _prevDate := _r.invhist_created; _prevCostmethod := _r.invhist_costmethod; _runningQty := _runningQty + _r.invhist_invqty * _r.sense; IF (_r.invhist_transtype = 'NN') THEN _runningNn := _runningNn + _r.invhist_invqty * -1; END IF; END LOOP; -- Update balances changed by any standard cost since last transaction IF (_prevCostmethod = 'S' AND _runningQty != 0) THEN PERFORM postValueintoInvBalance(pItemsiteid, costhist_date::date, _runningQty, _runningNn, costhist_oldcost, costhist_newcost ) FROM costhist WHERE ((costhist_item_id=_r.itemsite_item_id) AND (costhist_date > _prevDate) AND (costhist_type IN ('S','D'))); END IF; -- Forward update changes through all the balances PERFORM forwardupdateitemsite(pItemsiteId); RETURN 1; END; $_$; ALTER FUNCTION public.buildinvbal(integer) OWNER TO admin; -- -- Name: buildsearchpath(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION buildsearchpath() RETURNS text LANGUAGE plpgsql AS $_$ DECLARE _path TEXT := ''; _schema TEXT; _seq INTEGER; BEGIN -- get the schemas as ordered by the administrator SELECT concatagg(quote_ident(schemaord_name) || ',') INTO _path FROM (SELECT schemaord_name FROM schemaord LEFT OUTER JOIN pkghead ON (schemaord_name=pkghead_name) WHERE (pkghead_id IS NULL OR (pkghead_id IS NOT NULL AND packageisenabled(pkghead_id))) ORDER BY schemaord_order ) AS xtspq; -- add others that we think/know we need -- TODO: is there a reason not to include public, api, or packages? FOR _schema, _seq IN SELECT pkghead_name AS schema, 0 AS seq FROM pkghead WHERE packageisenabled(pkghead_id) UNION ALL SELECT 'public', 1 UNION ALL SELECT 'api', 2 ORDER BY seq, schema LOOP IF (_path !~* (E'(^|\\W)' || _schema || E'(\\W|$)')) THEN _path := _path || ',' || quote_ident(_schema); END IF; END LOOP; -- remove extraneous spaces and commas _path = BTRIM(REGEXP_REPLACE(_path, '( ?, ?)+', ',', 'g'), ', '); RAISE DEBUG 'buildSearchPath() returning %', _path; RETURN _path; END; $_$; ALTER FUNCTION public.buildsearchpath() OWNER TO admin; -- -- Name: FUNCTION buildsearchpath(); Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON FUNCTION buildsearchpath() IS 'buildSearchPath() examines the schemaord and pkghead tables to build a search path string. It ensures that public, api, and all enabled packages are included even if they are not listed in the schemaord table. It returns the constructed search_path but does not set it.'; -- -- Name: calccashbudget(integer, integer, character); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calccashbudget(integer, integer, character) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAccntId ALIAS FOR $1; pPeriodId ALIAS FOR $2; pInterval ALIAS FOR $3; _accntType CHAR; _currentBudget NUMERIC; _priorBudget NUMERIC; _result NUMERIC; BEGIN SELECT accnt_type INTO _accntType FROM accnt WHERE (accnt_id=pAccntId); SELECT COALESCE(SUM(budget_amount),0) INTO _currentBudget FROM budget WHERE ((budget_accnt_id=pAccntId) AND (budget_period_id=pPeriodId)); IF (pInterval='M') THEN SELECT (COALESCE(SUM(budget_amount),0)) INTO _priorBudget FROM budget, (SELECT COALESCE(pp.period_id,-1) AS prior_period_id FROM period cp, period pp WHERE ((cp.period_id=pPeriodId) AND (cp.period_start > pp.period_start)) ORDER BY pp.period_start DESC LIMIT 1) AS data WHERE ((budget_accnt_id=pAccntId) AND (budget_period_id=prior_period_id)); ELSE IF (pInterval='Q') THEN SELECT (COALESCE(SUM(budget_amount),0)) INTO _priorBudget FROM budget, (SELECT COALESCE(pp.period_id,-1) AS prior_period_id FROM period cp, period pp WHERE ((cp.period_id=pPeriodId) AND (cp.period_start > pp.period_start) AND (pp.period_quarter= CASE WHEN cp.period_quarter > 1 THEN cp.period_quarter - 1 ELSE 4 END) AND (pp.period_start >= cp.period_start - interval '1 year')) ORDER BY pp.period_start DESC LIMIT 1) AS data WHERE ((budget_accnt_id=pAccntId) AND (budget_period_id=prior_period_id)); ELSE SELECT (COALESCE(SUM(budget_amount),0)) INTO _priorBudget FROM budget, (SELECT pp.period_id AS prior_period_id FROM period cp, period pp, yearperiod cy, yearperiod py WHERE ((cp.period_id=pPeriodId) AND (cp.period_yearperiod_id=cy.yearperiod_id) AND (pp.period_yearperiod_id=py.yearperiod_id) AND (cy.yearperiod_start > py.yearperiod_start)) ORDER BY pp.period_start DESC LIMIT 1) AS data WHERE ((budget_accnt_id=pAccntId) AND (budget_period_id=prior_period_id)); END IF; END IF; IF _accntType='A' THEN _result := ((_priorBudget-_currentBudget) * -1 ); ELSE IF (_accntType IN ('L','Q')) THEN _result := ((_priorBudget-_currentBudget) *-1); ELSE RETURN -1; END IF; END IF; RETURN _result; END; $_$; ALTER FUNCTION public.calccashbudget(integer, integer, character) OWNER TO admin; -- -- Name: calccmheadamt(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calccmheadamt(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmheadid ALIAS FOR $1; _amount NUMERIC := 0; BEGIN SELECT SUM(COALESCE(extprice, 0)) INTO _amount FROM cmhead JOIN creditmemoitem ON (cmhead_id=cmitem_cmhead_id) WHERE (cmhead_id=pCmheadid); RETURN _amount; END; $_$; ALTER FUNCTION public.calccmheadamt(integer) OWNER TO admin; -- -- Name: calccmheadtax(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calccmheadtax(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmheadid ALIAS FOR $1; _headamount NUMERIC := 0; _itemamount NUMERIC := 0; _amount NUMERIC := 0; BEGIN SELECT COALESCE(SUM(taxhist_tax), 0) INTO _headamount FROM cmhead JOIN cmheadtax ON (taxhist_parent_id=cmhead_id) WHERE (cmhead_id=pCmheadid); SELECT SUM(COALESCE(tax, 0)) INTO _itemamount FROM cmhead JOIN creditmemoitem ON (cmhead_id=cmitem_cmhead_id) WHERE (cmhead_id=pCmheadid); _amount := _headamount + _itemamount; RETURN (_amount * -1.0); END; $_$; ALTER FUNCTION public.calccmheadtax(integer) OWNER TO admin; -- -- Name: calccobillamt(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calccobillamt(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCobillid ALIAS FOR $1; _amount NUMERIC := 0; BEGIN SELECT COALESCE(round((cobill_qty * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio), 2), 0) INTO _amount FROM cobill JOIN coitem ON (coitem_id=cobill_coitem_id) WHERE (cobill_id=pCobillid); RETURN _amount; END; $_$; ALTER FUNCTION public.calccobillamt(integer) OWNER TO admin; -- -- Name: calccobilltax(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calccobilltax(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCobillid ALIAS FOR $1; _amount NUMERIC := 0; BEGIN SELECT COALESCE(calculateTax(cobmisc_taxzone_id, cobill_taxtype_id, cobmisc_shipdate, cobmisc_curr_id, calcCobillAmt(cobill_id)), 0) INTO _amount FROM cobill JOIN coitem ON (coitem_id=cobill_coitem_id) JOIN cobmisc ON (cobmisc_id=cobill_cobmisc_id) WHERE (cobill_id=pCobillid); RETURN _amount; END; $_$; ALTER FUNCTION public.calccobilltax(integer) OWNER TO admin; -- -- Name: calccobmiscamt(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calccobmiscamt(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCobmiscid ALIAS FOR $1; _amount NUMERIC := 0; BEGIN SELECT SUM(COALESCE(calcCobillAmt(cobill_id), 0)) INTO _amount FROM cobmisc JOIN cobill ON (cobmisc_id=cobill_cobmisc_id) WHERE (cobmisc_id=pCobmiscid); RETURN _amount; END; $_$; ALTER FUNCTION public.calccobmiscamt(integer) OWNER TO admin; -- -- Name: calccobmisctax(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calccobmisctax(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCobmiscid ALIAS FOR $1; _amount NUMERIC := 0; BEGIN SELECT SUM( COALESCE(calculateTax(cobmisc_taxzone_id, cobill_taxtype_id, cobmisc_shipdate, cobmisc_curr_id, COALESCE(round((cobill_qty * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio), 2), 0)) , 0) ) INTO _amount FROM cobmisc JOIN cobill ON (cobmisc_id=cobill_cobmisc_id) JOIN coitem ON (coitem_id=cobill_coitem_id) WHERE (cobmisc_id=pCobmiscid); RETURN _amount; END; $_$; ALTER FUNCTION public.calccobmisctax(integer) OWNER TO admin; -- -- Name: calcinvoiceamt(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calcinvoiceamt(pinvcheadid integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN calcInvoiceAmt(pInvcheadid, 'T'); END; $$; ALTER FUNCTION public.calcinvoiceamt(pinvcheadid integer) OWNER TO admin; -- -- Name: calcinvoiceamt(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calcinvoiceamt(pinvcheadid integer, ptype text) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _subtotal NUMERIC := 0.0; _cost NUMERIC := 0.0; _tax NUMERIC := 0.0; _freight NUMERIC := 0.0; _misc NUMERIC := 0.0; _amount NUMERIC := 0.0; BEGIN -- pType: S = line item subtotal -- T = total -- X = tax -- M = margin SELECT COALESCE(SUM(ROUND((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / COALESCE(invcitem_price_invuomratio, 1.0)), 2)), 0.0), COALESCE(SUM(ROUND((invcitem_billed * invcitem_qty_invuomratio) * (currtolocal(invchead_curr_id, COALESCE(coitem_unitcost, itemCost(itemsite_id), 0.0), invchead_invcdate) / COALESCE(coitem_price_invuomratio, 1.0)), 2)), 0.0) INTO _subtotal, _cost FROM invcitem JOIN invchead ON (invchead_id = invcitem_invchead_id) LEFT OUTER JOIN coitem ON (coitem_id=invcitem_coitem_id) LEFT OUTER JOIN itemsite ON (itemsite_item_id=invcitem_item_id AND itemsite_warehous_id=invcitem_warehous_id) WHERE (invcitem_invchead_id=pInvcheadid); IF (pType IN ('T', 'X')) THEN SELECT COALESCE(SUM(tax), 0.0) INTO _tax FROM (SELECT COALESCE(ROUND(SUM(taxdetail_tax), 2), 0.0) AS tax FROM tax JOIN calculateTaxDetailSummary('I', pInvcheadid, 'T')ON (taxdetail_tax_id=tax_id) GROUP BY tax_id) AS data; END IF; IF (pType = 'T') THEN SELECT COALESCE(invchead_freight, 0), COALESCE(invchead_misc_amount, 0) INTO _freight, _misc FROM invchead WHERE (invchead_id=pinvcheadid); END IF; _amount := CASE pType WHEN 'S' THEN (_subtotal) WHEN 'T' THEN (_subtotal + _tax + _freight + _misc) WHEN 'X' THEN (_tax) WHEN 'M' THEN (_subtotal - _cost) ELSE 0.0 END; RETURN _amount; END; $$; ALTER FUNCTION public.calcinvoiceamt(pinvcheadid integer, ptype text) OWNER TO admin; -- -- Name: calcpendingarapplications(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calcpendingarapplications(integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE paropenid ALIAS FOR $1; _arcreditsum NUMERIC; _aropencurrid INTEGER; _cashrcptsum NUMERIC; _sense INTEGER; BEGIN SELECT aropen_curr_id, (CASE WHEN aropen_doctype IN ('I','D') THEN 1 ELSE -1 END) INTO _aropencurrid, _sense FROM aropen WHERE (aropen_id=paropenid); SELECT SUM(currToCurr(cashrcpt_curr_id, _aropencurrid, cashrcptitem_amount + cashrcptitem_discount, coalesce(cashrcpt_applydate, cashrcpt_distdate))) * _sense INTO _cashrcptsum FROM cashrcptitem, cashrcpt WHERE ((cashrcptitem_cashrcpt_id=cashrcpt_id) AND (NOT cashrcpt_posted) AND (NOT cashrcpt_void) AND (cashrcptitem_aropen_id=paropenid) ); SELECT SUM(currToCurr(arcreditapply_curr_id, _aropencurrid, arcreditapply_amount, CURRENT_DATE)) INTO _arcreditsum FROM arcreditapply WHERE ((arcreditapply_target_aropen_id=paropenid) ); RETURN round(COALESCE(_cashrcptsum, 0) + COALESCE(_arcreditsum, 0),2); END; $_$; ALTER FUNCTION public.calcpendingarapplications(integer) OWNER TO admin; -- -- Name: calcpurchaseorderamt(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calcpurchaseorderamt(ppoheadid integer) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN calcPurchaseOrderAmt(pPoheadid, 'T'); END; $$; ALTER FUNCTION public.calcpurchaseorderamt(ppoheadid integer) OWNER TO admin; -- -- Name: calcpurchaseorderamt(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calcpurchaseorderamt(ppoheadid integer, ptype text) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _subtotal NUMERIC := 0; _freightsub NUMERIC := 0; _tax NUMERIC := 0; _freight NUMERIC := 0; _currid INTEGER := 0; _effdate DATE := CURRENT_DATE; _amount NUMERIC := 0; BEGIN -- pType: S = line item subtotal -- T = total -- X = tax SELECT COALESCE(SUM(ROUND(poitem_qty_ordered * poitem_unitprice, 2)), 0), COALESCE(SUM(ROUND(poitem_freight, 2)), 0) INTO _subtotal, _freightsub FROM poitem WHERE (poitem_pohead_id=pPoheadid); SELECT COALESCE(SUM(tax), 0) INTO _tax FROM ( SELECT COALESCE(ROUND(SUM(taxdetail_tax), 2), 0.0) AS tax FROM tax JOIN calculateTaxDetailSummary('PO', pPoheadid, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id ) AS data; SELECT COALESCE(pohead_freight, 0), pohead_curr_id, pohead_orderdate INTO _freight, _currid, _effdate FROM pohead WHERE (pohead_id=pPoheadid); _amount := currToBase(_currid, CASE pType WHEN 'S' THEN (_subtotal) WHEN 'T' THEN (_subtotal + _tax + _freight + _freightsub) WHEN 'X' THEN (_tax) ELSE 0.0 END, _effdate); RETURN _amount; END; $$; ALTER FUNCTION public.calcpurchaseorderamt(ppoheadid integer, ptype text) OWNER TO admin; -- -- Name: calcpurchaseorderduedate(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calcpurchaseorderduedate(ppoheadid integer) RETURNS date LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _result DATE; BEGIN SELECT MIN(poitem_duedate) INTO _result FROM poitem WHERE (poitem_pohead_id=pPoheadid); RETURN _result; END; $$; ALTER FUNCTION public.calcpurchaseorderduedate(ppoheadid integer) OWNER TO admin; -- -- Name: calcquoteamt(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calcquoteamt(pquheadid integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN calcQuoteAmt(pQuheadid, 'T'); END; $$; ALTER FUNCTION public.calcquoteamt(pquheadid integer) OWNER TO admin; -- -- Name: calcquoteamt(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calcquoteamt(pquheadid integer, ptype text) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _subtotal NUMERIC := 0.0; _cost NUMERIC := 0.0; _tax NUMERIC := 0.0; _freight NUMERIC := 0.0; _misc NUMERIC := 0.0; _amount NUMERIC := 0.0; BEGIN -- pType: S = line item subtotal -- T = total -- X = tax -- M = margin SELECT COALESCE(SUM(ROUND((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio), 2)), 0.0), COALESCE(SUM(ROUND((quitem_qtyord * quitem_qty_invuomratio) * (quitem_unitcost / quitem_price_invuomratio), 2)), 0.0) INTO _subtotal, _cost FROM quitem WHERE (quitem_quhead_id=pQuheadid); IF (pType IN ('T', 'X')) THEN SELECT COALESCE(SUM(tax), 0.0) INTO _tax FROM (SELECT COALESCE(ROUND(SUM(taxdetail_tax), 2), 0.0) AS tax FROM tax JOIN calculateTaxDetailSummary('Q', pQuheadid, 'T')ON (taxdetail_tax_id=tax_id) GROUP BY tax_id) AS data; END IF; IF (pType = 'T') THEN SELECT COALESCE(quhead_freight, 0), COALESCE(quhead_misc, 0) INTO _freight, _misc FROM quhead WHERE (quhead_id=pQuheadid); END IF; _amount := CASE pType WHEN 'S' THEN (_subtotal) WHEN 'T' THEN (_subtotal + _tax + _freight + _misc) WHEN 'X' THEN (_tax) WHEN 'M' THEN (_subtotal - _cost) ELSE 0.0 END; RETURN _amount; END; $$; ALTER FUNCTION public.calcquoteamt(pquheadid integer, ptype text) OWNER TO admin; -- -- Name: calcsalesorderamt(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calcsalesorderamt(pcoheadid integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN calcSalesOrderAmt(pCoheadid, 'T'); END; $$; ALTER FUNCTION public.calcsalesorderamt(pcoheadid integer) OWNER TO admin; -- -- Name: calcsalesorderamt(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calcsalesorderamt(pcoheadid integer, ptype text) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _subtotal NUMERIC := 0.0; _cost NUMERIC := 0.0; _tax NUMERIC := 0.0; _freight NUMERIC := 0.0; _misc NUMERIC := 0.0; _credit NUMERIC := 0.0; _amount NUMERIC := 0.0; BEGIN -- pType: S = line item subtotal -- T = total -- B = balance due -- C = allocated credits -- X = tax -- M = margin SELECT COALESCE(SUM(ROUND((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio), 2)), 0.0), COALESCE(SUM(ROUND((coitem_qtyord * coitem_qty_invuomratio) * (CASE WHEN (coitem_subnumber > 0) THEN 0.0 ELSE coitem_unitcost END / coitem_price_invuomratio), 2)), 0.0) INTO _subtotal, _cost FROM coitem WHERE (coitem_cohead_id=pCoheadid) AND (coitem_status != 'X'); IF (pType IN ('T', 'B', 'X')) THEN SELECT COALESCE(SUM(tax), 0.0) INTO _tax FROM (SELECT COALESCE(ROUND(SUM(taxdetail_tax), 2), 0.0) AS tax FROM tax JOIN calculateTaxDetailSummary('S', pCoheadid, 'T')ON (taxdetail_tax_id=tax_id) GROUP BY tax_id) AS data; END IF; IF (pType IN ('T', 'B', 'C')) THEN SELECT COALESCE(cohead_freight, 0), COALESCE(cohead_misc, 0), COALESCE(SUM(currToCurr(aropenalloc_curr_id, cohead_curr_id, aropenalloc_amount, CURRENT_DATE)),0) INTO _freight, _misc, _credit FROM cohead LEFT OUTER JOIN aropenalloc ON (aropenalloc_doctype='S' AND aropenalloc_doc_id=cohead_id) WHERE (cohead_id=pCoheadid) GROUP BY cohead_freight, cohead_misc, cohead_curr_id; END IF; _amount := CASE pType WHEN 'S' THEN (_subtotal) WHEN 'T' THEN (_subtotal + _tax + _freight + _misc) WHEN 'B' THEN (_subtotal + _tax + _freight + _misc - _credit) WHEN 'C' THEN (_credit) WHEN 'X' THEN (_tax) WHEN 'M' THEN (_subtotal - _cost) ELSE 0.0 END; RETURN _amount; END; $$; ALTER FUNCTION public.calcsalesorderamt(pcoheadid integer, ptype text) OWNER TO admin; -- -- Name: calcshipfreight(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calcshipfreight(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipheadId ALIAS FOR $1; _result NUMERIC := 0; _order RECORD; _shipment RECORD; _weights RECORD; _price RECORD; _sales RECORD; _freightid INTEGER; _totalprice NUMERIC; _includepkgweight BOOLEAN := FALSE; _freight RECORD; _debug BOOLEAN := false; BEGIN --Get shipment SELECT shiphead_order_id, shiphead_order_type, shiphead_freight INTO _shipment FROM shiphead WHERE (shiphead_id=pShipheadId); IF (NOT FOUND) THEN RAISE EXCEPTION 'Shipment not found'; END IF; IF (_shipment.shiphead_order_type = 'SO') THEN --Sales Orders --Get the order header information SELECT cust_id AS cust_id, custtype_id, custtype_code, shipto_id, shipto_num, cohead_orderdate AS orderdate, cohead_shipvia AS shipvia, shipto_shipzone_id AS shipzone_id, cohead_curr_id AS curr_id, currConcat(cohead_curr_id) AS currAbbr, cohead_calcfreight, cohead_freight INTO _order FROM cohead JOIN custinfo ON (cust_id=cohead_cust_id) JOIN custtype ON (custtype_id=cust_custtype_id) LEFT OUTER JOIN shiptoinfo ON (shipto_id=cohead_shipto_id) WHERE (cohead_id=_shipment.shiphead_order_id); IF (NOT FOUND) THEN RAISE EXCEPTION 'Order not found'; END IF; IF (_debug) THEN RAISE NOTICE 'cust_id = %', _order.cust_id; RAISE NOTICE 'custtype_id = %', _order.custtype_id; RAISE NOTICE 'shipto_id = %', _order.shipto_id; RAISE NOTICE 'shipto_num = %', _order.shipto_num; RAISE NOTICE 'orderdate = %', _order.orderdate; RAISE NOTICE 'shipvia = %', _order.shipvia; RAISE NOTICE 'shipzone_id = %', _order.shipzone_id; RAISE NOTICE 'curr_id = %', _order.curr_id; RAISE NOTICE 'currAbbr = %', _order.currAbbr; RAISE NOTICE 'calcfreight = %', _order.cohead_calcfreight; RAISE NOTICE 'freight = %', _order.cohead_freight; END IF; IF (NOT _order.cohead_calcfreight) THEN SELECT noNeg( _order.cohead_freight - COALESCE((SELECT SUM(shiphead_freight) FROM shiphead WHERE (shiphead_order_id = _shipment.shiphead_order_id) AND (shiphead_shipped='true')), 0) ) INTO _result; RETURN _result; END IF; SELECT fetchMetricBool('IncludePackageWeight') INTO _includepkgweight; --Calculate Sales Order freight --Get a list of aggregated weights from sites and --freight classes used on order lines FOR _weights IN SELECT CASE WHEN (_includePkgWeight) THEN SUM(shipitem_qty * (item_prodweight + item_packweight)) ELSE SUM(shipitem_qty * item_prodweight) END AS weight, itemsite_warehous_id, item_freightclass_id FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id) JOIN coitem ON (shipitem_orderitem_id=coitem_id) JOIN itemsite ON (itemsite_id=coitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE ( (shiphead_id=pShipheadId) AND (item_freightclass_id IS NOT NULL) ) GROUP BY itemsite_warehous_id, item_freightclass_id LOOP IF (_debug) THEN RAISE NOTICE '_weights.weight - %', _weights.weight; RAISE NOTICE '_weights.itemsite_warehous_id = %', _weights.itemsite_warehous_id; RAISE NOTICE '_weights.item_freightclass_id = %', _weights.item_freightclass_id; END IF; -- First get a sales price if any so we when we find other prices -- we can determine if we want that price or this price. -- Check for a Sale Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, _order.curr_id, ipsfreight_price, _order.orderdate) ELSE currToCurr(ipshead_curr_id, _order.curr_id, (_weights.weight * ipsfreight_price), _order.orderdate) END AS price INTO _sales FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN sale ON (sale_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= _weights.weight) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=_weights.itemsite_warehous_id)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=_weights.item_freightclass_id)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=_order.shipzone_id)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=_order.shipvia)) AND (CURRENT_DATE BETWEEN sale_startdate AND sale_enddate) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_sales.price IS NOT NULL) THEN RAISE NOTICE 'Sales Price found, %', _sales.price; END IF; END IF; -- Check for a Customer Shipto Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, _order.curr_id, ipsfreight_price, _order.orderdate) ELSE currToCurr(ipshead_curr_id, _order.curr_id, (_weights.weight * ipsfreight_price), _order.orderdate) END AS price INTO _price FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= _weights.weight) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=_weights.itemsite_warehous_id)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=_weights.item_freightclass_id)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=_order.shipzone_id)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=_order.shipvia)) AND (CURRENT_DATE BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsass_shipto_id != -1) AND (ipsass_shipto_id=_order.shipto_id) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_price.price IS NOT NULL) THEN RAISE NOTICE 'Customer Shipto Price found, %', _price.price; END IF; END IF; IF (_price.price IS NULL) THEN -- Check for a Customer Shipto Pattern Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, _order.curr_id, ipsfreight_price, _order.orderdate) ELSE currToCurr(ipshead_curr_id, _order.curr_id, (_weights.weight * ipsfreight_price), _order.orderdate) END AS price INTO _price FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= _weights.weight) AND (CURRENT_DATE BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsass_cust_id=_order.cust_id) AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) AND (_order.shipto_num ~ ipsass_shipto_pattern) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=_weights.itemsite_warehous_id)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=_weights.item_freightclass_id)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=_order.shipzone_id)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=_order.shipvia)) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_price.price IS NOT NULL) THEN RAISE NOTICE 'Customer Shipto Pattern Price found, %', _price.price; END IF; END IF; END IF; IF (_price.price IS NULL) THEN -- Check for a Customer Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, _order.curr_id, ipsfreight_price, _order.orderdate) ELSE currToCurr(ipshead_curr_id, _order.curr_id, (_weights.weight * ipsfreight_price), _order.orderdate) END AS price INTO _price FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= _weights.weight) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=_weights.itemsite_warehous_id)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=_weights.item_freightclass_id)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=_order.shipzone_id)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=_order.shipvia)) AND (CURRENT_DATE BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsass_cust_id=_order.cust_id) AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) = 0) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_price.price IS NOT NULL) THEN RAISE NOTICE 'Customer Price found, %', _price.price; END IF; END IF; END IF; IF (_price.price IS NULL) THEN -- Check for a Customer Type Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, _order.curr_id, ipsfreight_price, _order.orderdate) ELSE currToCurr(ipshead_curr_id, _order.curr_id, (_weights.weight * ipsfreight_price), _order.orderdate) END AS price INTO _price FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= _weights.weight) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=_weights.itemsite_warehous_id)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=_weights.item_freightclass_id)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=_order.shipzone_id)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=_order.shipvia)) AND (CURRENT_DATE BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsass_custtype_id=_order.custtype_id) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_price.price IS NOT NULL) THEN RAISE NOTICE 'Customer Type Price found, %', _price.price; END IF; END IF; END IF; IF (_price.price IS NULL) THEN -- Check for a Customer Type Pattern Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, _order.curr_id, ipsfreight_price, _order.orderdate) ELSE currToCurr(ipshead_curr_id, _order.curr_id, (_weights.weight * ipsfreight_price), _order.orderdate) END AS price INTO _price FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= _weights.weight) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=_weights.itemsite_warehous_id)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=_weights.item_freightclass_id)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=_order.shipzone_id)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=_order.shipvia)) AND (CURRENT_DATE BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) AND (_order.custtype_code ~ ipsass_custtype_pattern) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_price.price IS NOT NULL) THEN RAISE NOTICE 'Customer Type Pattern Price found, %', _price.price; END IF; END IF; END IF; -- Select the lowest price IF ( (_price.price IS NOT NULL) AND ((_sales.price IS NULL) OR (_price.price < _sales.price)) ) THEN _freightid := _price.ipsfreight_id; _totalprice := _price.price; ELSE IF ( (_sales.price IS NOT NULL) AND ((_price.price IS NULL) OR (_sales.price <= _price.price)) ) THEN _freightid := _sales.ipsfreight_id; _totalprice := _sales.price; END IF; END IF; -- Total IF (_freightid IS NOT NULL) THEN _result := _result + _totalprice; END IF; END LOOP; RETURN ROUND(_result,2); END IF; IF (_shipment.shiphead_order_type = 'TO') THEN --Transfer Orders SELECT noNeg( (SELECT SUM(toitem_freight) + tohead_freight FROM tohead, toitem WHERE (toitem_tohead_id=tohead_id) AND (tohead_id = _shipment.shiphead_order_id) GROUP BY tohead_freight) - COALESCE((SELECT SUM(shiphead_freight) FROM shiphead WHERE (shiphead_order_id = _shipment.shiphead_order_id) AND (shiphead_shipped='true')), 0) ) INTO _result; RETURN _result; END IF; RETURN _result; END; $_$; ALTER FUNCTION public.calcshipfreight(integer) OWNER TO admin; -- -- Name: calctotalslipqty(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calctotalslipqty(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTagid ALIAS FOR $1; _qty NUMERIC := 0; BEGIN SELECT SUM(COALESCE(cntslip_qty, 0.0)) INTO _qty FROM cntslip WHERE (cntslip_cnttag_id=pTagid); RETURN _qty; END; $_$; ALTER FUNCTION public.calctotalslipqty(integer) OWNER TO admin; -- -- Name: calculatefreightdetail(integer, integer, text, integer, integer, text, date, text, integer, character varying, integer, integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calculatefreightdetail(integer, integer, text, integer, integer, text, date, text, integer, character varying, integer, integer, numeric) RETURNS SETOF freightdata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustId ALIAS FOR $1; pCustTypeId ALIAS FOR $2; pCustTypeCode ALIAS FOR $3; pShiptoId ALIAS FOR $4; pShipZoneId ALIAS FOR $5; pShiptoNum ALIAS FOR $6; pOrderDate ALIAS FOR $7; pShipVia ALIAS FOR $8; pCurrId ALIAS FOR $9; pCurrAbbr ALIAS FOR $10; pItemSiteWhsId ALIAS FOR $11; pItemFreightclassId ALIAS FOR $12; pWeight ALIAS FOR $13; _row freightData%ROWTYPE; _price RECORD; _sales RECORD; _freightid INTEGER; _totalprice NUMERIC; _asof DATE; _debug BOOLEAN := FALSE; BEGIN --Get pricing effectivity metric IF (SELECT fetchMetricText('soPriceEffective') = 'OrderDate') THEN _asof := pOrderDate; ELSE _asof := CURRENT_DATE; END IF; _freightid := NULL; _totalprice := 0.0; IF (_debug) THEN RAISE NOTICE 'pWeight - %', pWeight; RAISE NOTICE 'pItemSiteWhsId = %', pItemSiteWhsId; RAISE NOTICE 'pItemFreightclassId = %', pItemFreightclassId; END IF; -- First get a sales price if any so when we find other prices -- we can determine if we want that price or this sales price. -- Check for a Sale Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, pCurrId, ipsfreight_price, pOrderDate) ELSE currToCurr(ipshead_curr_id, pCurrId, (pWeight * ipsfreight_price), pOrderDate) END AS price INTO _sales FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN sale ON (sale_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= pWeight) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=pItemSiteWhsId)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=pItemFreightclassId)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=pShipZoneId)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=pShipVia)) AND (_asof BETWEEN sale_startdate AND sale_enddate) AND (pCustId IS NOT NULL) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_sales.price IS NOT NULL) THEN RAISE NOTICE 'Sales Price found, %', _sales.price; END IF; END IF; -- Check for a Customer Shipto Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, pCurrId, ipsfreight_price, pOrderDate) ELSE currToCurr(ipshead_curr_id, pCurrId, (pWeight * ipsfreight_price), pOrderDate) END AS price INTO _price FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= pWeight) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=pItemSiteWhsId)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=pItemFreightclassId)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=pShipZoneId)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=pShipVia)) AND (_asof BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsass_shipto_id != -1) AND (ipsass_shipto_id=pShiptoId) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_price.price IS NOT NULL) THEN RAISE NOTICE 'Customer Shipto Price found, %', _price.price; END IF; END IF; IF (_price.price IS NULL) THEN -- Check for a Customer Shipto Pattern Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, pCurrId, ipsfreight_price, pOrderDate) ELSE currToCurr(ipshead_curr_id, pCurrId, (pWeight * ipsfreight_price), pOrderDate) END AS price INTO _price FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= pWeight) AND (_asof BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsass_cust_id=pCustId) AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) AND (pShiptoNum ~ ipsass_shipto_pattern) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=pItemSiteWhsId)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=pItemFreightclassId)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=pShipZoneId)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=pShipVia)) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_price.price IS NOT NULL) THEN RAISE NOTICE 'Customer Shipto Pattern Price found, %', _price.price; END IF; END IF; END IF; IF (_price.price IS NULL) THEN -- Check for a Customer Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, pCurrId, ipsfreight_price, pOrderDate) ELSE currToCurr(ipshead_curr_id, pCurrId, (pWeight * ipsfreight_price), pOrderDate) END AS price INTO _price FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= pWeight) AND((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=pItemSiteWhsId)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=pItemFreightclassId)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=pShipZoneId)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=pShipVia)) AND (_asof BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsass_cust_id=pCustId) AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) = 0) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_price.price IS NOT NULL) THEN RAISE NOTICE 'Customer Price found, %', _price.price; END IF; END IF; END IF; IF (_price.price IS NULL) THEN -- Check for a Customer Type Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, pCurrId, ipsfreight_price, pOrderDate) ELSE currToCurr(ipshead_curr_id, pCurrId, (pWeight * ipsfreight_price), pOrderDate) END AS price INTO _price FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= pWeight) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=pItemSiteWhsId)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=pItemFreightclassId)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=pShipZoneId)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=pShipVia)) AND (_asof BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsass_custtype_id=pCustTypeId) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_price.price IS NOT NULL) THEN RAISE NOTICE 'Customer Type Price found, %', _price.price; END IF; END IF; END IF; IF (_price.price IS NULL) THEN -- Check for a Customer Type Pattern Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, pCurrId, ipsfreight_price, pOrderDate) ELSE currToCurr(ipshead_curr_id, pCurrId, (pWeight * ipsfreight_price), pOrderDate) END AS price INTO _price FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= pWeight) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=pItemSiteWhsId)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=pItemFreightclassId)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=pShipZoneId)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=pShipVia)) AND (_asof BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) AND (pCustTypeCode ~ ipsass_custtype_pattern) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_price.price IS NOT NULL) THEN RAISE NOTICE 'Customer Type Pattern Price found, %', _price.price; END IF; END IF; END IF; -- Select the lowest price IF ( (_price.price IS NOT NULL) AND ((_sales.price IS NULL) OR (_price.price < _sales.price)) ) THEN _freightid := _price.ipsfreight_id; _totalprice := _price.price; ELSE IF ( (_sales.price IS NOT NULL) AND ((_price.price IS NULL) OR (_sales.price <= _price.price)) ) THEN _freightid := _sales.ipsfreight_id; _totalprice := _sales.price; END IF; END IF; IF (_debug) THEN RAISE NOTICE '_freightid = %', _freightid; RAISE NOTICE '_totalprice = %', _totalprice; END IF; -- Get information for the selected ipsfreight -- and return IF (_freightid IS NULL) THEN _row.freightdata_schedule := 'N/A'; _row.freightdata_from := ''; _row.freightdata_to := ''; _row.freightdata_shipvia := ''; _row.freightdata_freightclass := ''; _row.freightdata_weight := 0; _row.freightdata_uom := ''; _row.freightdata_price := 0; _row.freightdata_type := ''; _row.freightdata_total := 0; _row.freightdata_currency := ''; RETURN NEXT _row; ELSE SELECT ipshead_name AS freightdata_schedule, COALESCE(warehous_code, 'Any') AS freightdata_from, COALESCE(shipzone_name, 'Any') AS freightdata_to, COALESCE(ipsfreight_shipvia, 'Any') AS freightdata_shipvia, COALESCE(freightclass_code, 'Any') AS freightdata_freightclass, pWeight AS freightdata_weight, uom_name AS freightdata_uom, currToCurr(ipshead_curr_id, pCurrId, ipsfreight_price, pOrderDate) AS freightdata_price, CASE WHEN (ipsfreight_type='F') THEN 'Flat Rate' ELSE 'Per UOM' END AS freightdata_type, _totalprice AS freightdata_total, pCurrAbbr AS freightdata_currency INTO _row FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) LEFT OUTER JOIN uom ON (uom_item_weight) LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id) LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id) LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id) WHERE (ipsfreight_id=_freightid); RETURN NEXT _row; END IF; RETURN; END; $_$; ALTER FUNCTION public.calculatefreightdetail(integer, integer, text, integer, integer, text, date, text, integer, character varying, integer, integer, numeric) OWNER TO admin; -- -- Name: calculatesubtax(integer, date, integer, numeric, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calculatesubtax(integer, date, integer, numeric, integer) RETURNS SETOF taxdetail LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxCodeId ALIAS FOR $1; pDate ALIAS FOR $2; pCurrId ALIAS FOR $3; pAmount ALIAS FOR $4; pLevel ALIAS FOR $5; _row taxdetail%ROWTYPE; _rownumber INTEGER := 1; _calc_tax Numeric :=0; _x RECORD; _y RECORD; BEGIN FOR _x IN SELECT tax_id, tax_code, tax_descrip, tax_basis_tax_id, taxrate_id, taxrate_percent, taxrate_curr_id, taxrate_amount, taxclass_id, taxclass_code, COALESCE(taxclass_sequence,0) AS taxclass_sequence, curr_id, curr_abbr FROM tax, taxrate, taxclass, curr_symbol WHERE ((tax_id = taxrate_tax_id) AND (tax_taxclass_id = taxclass_id) AND (taxrate_curr_id = curr_id) AND (tax_basis_tax_id = pTaxCodeId) AND (pDate BETWEEN taxrate_effective AND taxrate_expires) AND (taxrate_curr_id = pCurrId)) LOOP SELECT ROUND((_x.taxrate_percent * pAmount + currToCurr(_x.curr_id, pCurrId, _x.taxrate_amount, pDate)), 6) INTO _calc_tax; _row.taxdetail_tax_id = _x.tax_id; _row.taxdetail_tax_code = _x.tax_code; _row.taxdetail_tax_descrip = _x.tax_descrip; _row.taxdetail_tax_basis_tax_id = _x.tax_basis_tax_id ; _row.taxdetail_taxrate_percent = _x.taxrate_percent; _row.taxdetail_taxrate_amount = _x.taxrate_amount; _row.taxdetail_level = pLevel + 1; _row.taxdetail_taxclass_id = _x.taxclass_id ; _row.taxdetail_taxclass_code = _x.taxclass_code; _row.taxdetail_taxclass_sequence = _x.taxclass_sequence; _row.taxdetail_tax = _calc_tax; _row.taxdetail_curr_id = _x.curr_id; _row.taxdetail_curr_abbr = _x.curr_abbr; RETURN NEXT _row; _rownumber := _rownumber + 1; FOR _y IN SELECT * FROM calculateSubTax( _x.tax_id, pDate, pCurrId, _calc_tax, pLevel + 1) LOOP _row.taxdetail_tax_id = _y.taxdetail_tax_id; _row.taxdetail_tax_code = _y.taxdetail_tax_code; _row.taxdetail_tax_descrip = _y.taxdetail_tax_descrip; _row.taxdetail_tax_basis_tax_id = _y.taxdetail_tax_basis_tax_id ; _row.taxdetail_taxrate_percent = _y.taxdetail_taxrate_percent; _row.taxdetail_taxrate_amount = _y.taxdetail_taxrate_amount; _row.taxdetail_level = _y.taxdetail_level + 1; _row.taxdetail_taxclass_id = _y.taxdetail_taxclass_id ; _row.taxdetail_taxclass_code = _y.taxdetail_taxclass_code; _row.taxdetail_taxclass_sequence = _y.taxdetail_taxclass_sequence; _row.taxdetail_tax = _y.taxdetail_tax; _row.taxdetail_curr_id = _y.taxdetail_curr_id; _row.taxdetail_curr_abbr = _y.taxdetail_curr_abbr; RETURN NEXT _row; _rownumber := _rownumber + 1; END LOOP; END LOOP; END; $_$; ALTER FUNCTION public.calculatesubtax(integer, date, integer, numeric, integer) OWNER TO admin; -- -- Name: calculatetax(integer, integer, date, integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calculatetax(integer, integer, date, integer, numeric) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxZoneId ALIAS FOR $1; pTaxTypeId ALIAS FOR $2; pDate ALIAS FOR $3; pCurrId ALIAS FOR $4; pAmount ALIAS FOR $5; _tottax numeric := 0; -- total tax BEGIN SELECT COALESCE(ROUND(SUM(taxdetail_tax),6),0) INTO _tottax FROM calculateTaxDetail(pTaxZoneId, pTaxTypeId, pDate, pCurrId, pAmount); RETURN _tottax; END; $_$; ALTER FUNCTION public.calculatetax(integer, integer, date, integer, numeric) OWNER TO admin; -- -- Name: calculatetaxdetail(integer, integer, date, integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calculatetaxdetail(integer, integer, date, integer, numeric) RETURNS SETOF taxdetail LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxZoneId ALIAS FOR $1; pTaxTypeId ALIAS FOR $2; pDate ALIAS FOR $3; pCurrId ALIAS FOR $4; pAmount ALIAS FOR $5; _row taxdetail%ROWTYPE; _x RECORD; _y RECORD; _z RECORD; _currcum numeric := 0; -- Current cumulative tax _currseq numeric := 0; -- Current group sequence _prevcum numeric := 0; -- Previous cumulative tax _tax numeric := 0; -- Calculated tax amount _taxbasis numeric := 0; -- Used for calculating sub taxes BEGIN IF ((COALESCE(pTaxTypeId,-1) = -1) OR (COALESCE(pTaxZoneId,-1) = -1)) THEN RETURN; END IF; SELECT DISTINCT COALESCE(taxass_taxzone_id, -1) AS taxzone_id, COALESCE(taxass_taxtype_id, -1) AS taxtype_id, taxass_tax_id, CASE WHEN ((taxass_taxzone_id IS NOT NULL) AND (taxass_taxtype_id IS NOT NULL)) THEN 0 WHEN ((taxass_taxzone_id IS NOT NULL) AND (taxass_taxtype_id IS NULL)) THEN 1 WHEN ((taxass_taxzone_id IS NULL) AND (taxass_taxtype_id IS NOT NULL)) THEN 2 ELSE 3 END AS sequence INTO _x FROM taxass WHERE ((COALESCE(taxass_taxzone_id, pTaxZoneId, -1) = COALESCE(pTaxZoneId,-1)) AND (COALESCE(taxass_taxtype_id, pTaxTypeId, -1) = COALESCE(pTaxTypeId,-1))) ORDER BY sequence LIMIT 1; --Now loop through each tax detail record and return calculated result FOR _y IN SELECT --the data required by taxdetail type. Coalesce group sequence to 0 if no class. tax_id ,tax_code ,tax_descrip ,tax_basis_tax_id ,taxrate_percent ,taxrate_amount ,0 as taxdetail_level ,taxclass_id ,taxclass_code ,COALESCE(taxclass_sequence, 0) AS taxclass_sequence ,0 as taxdetail_tax ,curr_id ,curr_abbr FROM taxass, taxclass RIGHT OUTER JOIN tax LEFT OUTER JOIN taxrate ON (taxrate_tax_id=tax_id) ON (tax_taxclass_id=taxclass_id), curr_symbol WHERE taxass_tax_id=tax_id AND taxrate_curr_id=curr_id AND COALESCE(taxass_taxzone_id, -1) = _x.taxzone_id AND COALESCE(taxass_taxtype_id, -1) = _x.taxtype_id AND pDate BETWEEN COALESCE(taxrate_effective, startoftime()) AND COALESCE(taxrate_expires, endoftime()) ORDER BY COALESCE(taxclass_sequence, 0) LOOP -- If sequence has changed, cache the previous cumulative tax IF (_currseq != _x.sequence) THEN _prevcum := _currcum; END IF; -- Calculate the tax amount. Convert currency for flat rate amounts SELECT ROUND((_y.taxrate_percent * (pAmount + _prevcum) + currToCurr(_y.curr_id, pCurrId, _y.taxrate_amount, pDate)), 6) INTO _tax FROM tax JOIN taxrate ON (tax_id = taxrate_tax_id) WHERE (tax_id=_x.taxass_tax_id) AND (pDate BETWEEN COALESCE(taxrate_effective, startoftime()) AND COALESCE(taxrate_expires, endoftime())); --Map fields to _row _row.taxdetail_tax_id := _y.tax_id; _row.taxdetail_tax_code := _y.tax_code; _row.taxdetail_tax_descrip := _y.tax_descrip; _row.taxdetail_tax_basis_tax_id := _y.tax_basis_tax_id; _row.taxdetail_taxrate_percent := _y.taxrate_percent; _row.taxdetail_taxrate_amount := _y.taxrate_amount; _row.taxdetail_level := _y.taxdetail_level; _row.taxdetail_taxclass_id := _y.taxclass_id; _row.taxdetail_taxclass_code := _y.taxclass_code; _row.taxdetail_taxclass_sequence := _y.taxclass_sequence; _row.taxdetail_tax := _tax; _row.taxdetail_curr_id := _y.curr_id; _row.taxdetail_curr_abbr := _y.curr_abbr; RETURN NEXT _row; -- Increment cumulative balance and sequence number IF(_y.taxclass_sequence <> 0) THEN _currcum := _currcum + _tax; END IF; _currseq := _y.taxclass_sequence; -- Loop to Calculate sub taxes FOR _z IN SELECT * FROM calculateSubTax(_y.tax_id,pDate, pCurrId, _tax, 0) LOOP --Mapping of data _row.taxdetail_tax_id := _z.taxdetail_tax_id; _row.taxdetail_tax_code := _z.taxdetail_tax_code; _row.taxdetail_tax_descrip := _z.taxdetail_tax_descrip; _row.taxdetail_tax_basis_tax_id := _z.taxdetail_tax_basis_tax_id; _row.taxdetail_taxrate_percent := _z.taxdetail_taxrate_percent; _row.taxdetail_taxrate_amount := _z.taxdetail_taxrate_amount; _row.taxdetail_level := _z.taxdetail_level; _row.taxdetail_taxclass_id := _z.taxdetail_taxclass_id; _row.taxdetail_taxclass_code := _z.taxdetail_taxclass_code; _row.taxdetail_taxclass_sequence := _z.taxdetail_taxclass_sequence; _row.taxdetail_tax := _z.taxdetail_tax; _row.taxdetail_curr_id := _z.taxdetail_curr_id; _row.taxdetail_curr_abbr := _z.taxdetail_curr_abbr; RETURN NEXT _row; --Add to cumulative counter (_curcum) _currcum := _currcum + _z.taxdetail_tax ; END LOOP; END LOOP; END; $_$; ALTER FUNCTION public.calculatetaxdetail(integer, integer, date, integer, numeric) OWNER TO admin; -- -- Name: calculatetaxdetailline(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calculatetaxdetailline(text, integer) RETURNS SETOF taxdetail LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOrderType ALIAS FOR $1; pOrderId ALIAS FOR $2; _row taxdetail%ROWTYPE; _qry text; _totaltax numeric; _y RECORD; _table text; BEGIN _totaltax=0.0; IF pOrderType = 'II' THEN _table := 'invcitemtax'; ELSIF pOrderType = 'BI' THEN _table := 'cobilltax'; ELSIF pOrderType = 'CI' THEN _table := 'cmitemtax'; ELSIF pOrderType = 'VI' THEN _table := 'voitemtax'; ELSIF pOrderType = 'TI' THEN _table := 'toitemtax'; ELSIF pOrderType = 'AR' THEN _table := 'aropentax'; ELSIF pOrderType = 'AP' THEN _table := 'apopentax'; END IF; _qry := 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, COALESCE(taxhist_sequence,0) AS taxhist_sequence FROM ' || _table || ' JOIN tax ON (taxhist_tax_id=tax_id) WHERE ( (taxhist_parent_id = ' || pOrderId || ') );'; FOR _y IN EXECUTE _qry LOOP _row.taxdetail_tax_id=_y.tax_id; _row.taxdetail_tax_code = _y.tax_code; _row.taxdetail_tax_descrip = _y.tax_descrip; _row.taxdetail_tax = _y.taxhist_tax; _row.taxdetail_level= 0 ; _row.taxdetail_taxclass_sequence= _y.taxhist_sequence; _totaltax = _totaltax + _y.taxhist_tax; RETURN NEXT _row; END LOOP; END; $_$; ALTER FUNCTION public.calculatetaxdetailline(text, integer) OWNER TO admin; -- -- Name: calculatetaxdetailsummary(text, integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calculatetaxdetailsummary(text, integer, text) RETURNS SETOF taxdetail LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOrderType ALIAS FOR $1; pOrderId ALIAS FOR $2; pDisplayType ALIAS FOR $3; _row taxdetail%ROWTYPE; _qry text := ''; _qry1 text; _totaltax numeric; _x RECORD; _y RECORD; _table text; BEGIN _totaltax=0.0; IF pOrderType IN ('S','Q','RA','PO') THEN IF pOrderType = 'S' THEN _qry := 'SELECT ' || 'COALESCE(cohead_taxzone_id, -1) AS taxzone_id, cohead_orderdate AS order_date, cohead_curr_id AS curr_id, COALESCE(coitem_taxtype_id, -1) AS taxtype_id, ROUND((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio),2) AS amount FROM cohead, coitem WHERE ( (coitem_cohead_id = ' || pOrderId || ') AND (' || 'cohead_id = coitem_cohead_id) AND ( coitem_status != ''X'') )'; ELSEIF pOrderType = 'Q' THEN _qry := 'SELECT ' || 'COALESCE(quhead_taxzone_id, -1) AS taxzone_id, quhead_quotedate AS order_date, quhead_curr_id AS curr_id, COALESCE(quitem_taxtype_id, -1) AS taxtype_id, ROUND((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio),2) AS amount FROM quhead, quitem WHERE ( (quitem_quhead_id = ' || pOrderId || ') AND (quhead_id = quitem_quhead_id) )'; ELSEIF pOrderType = 'RA' THEN _qry := 'SELECT ' || 'COALESCE(rahead_taxzone_id, -1) AS taxzone_id, rahead_authdate AS order_date, rahead_curr_id AS curr_id, COALESCE(raitem_taxtype_id, -1) AS taxtype_id, ROUND((raitem_qtyauthorized * raitem_qty_invuomratio) * (raitem_unitprice / raitem_price_invuomratio),2) AS amount FROM rahead, raitem WHERE ( (raitem_rahead_id = ' || pOrderId || ') AND (rahead_id = raitem_rahead_id) )'; ELSEIF pOrderType = 'PO' THEN _qry := 'SELECT ' || 'COALESCE(pohead_taxzone_id, -1) AS taxzone_id, pohead_orderdate AS order_date, pohead_curr_id AS curr_id, COALESCE(poitem_taxtype_id, -1) AS taxtype_id, ROUND(poitem_qty_ordered * poitem_unitprice, 2) AS amount FROM pohead, poitem WHERE ( (poitem_pohead_id = ' || pOrderId || ') AND (pohead_id = poitem_pohead_id) )'; END IF; FOR _x IN EXECUTE _qry LOOP _qry1 := 'SELECT * from calculatetaxdetail(' || _x.taxzone_id || ',' || _x.taxtype_id || ',''' || _x.order_date || ''',' || _x.curr_id || ',' || _x.amount || ')'; FOR _y IN EXECUTE _qry1 LOOP _row.taxdetail_tax_id=_y.taxdetail_tax_id; _row.taxdetail_tax_code = _y.taxdetail_tax_code; _row.taxdetail_tax_descrip = _y.taxdetail_tax_descrip; _row.taxdetail_tax = _y.taxdetail_tax; _row.taxdetail_level=_y.taxdetail_level; _row.taxdetail_taxclass_sequence= _y.taxdetail_taxclass_sequence; _totaltax = _totaltax + _y.taxdetail_tax; RETURN NEXT _row; END LOOP; END LOOP; IF pDisplayType = 'T' AND pOrderType <> 'PO' THEN IF pOrderType = 'S' THEN _qry := 'SELECT COALESCE(cohead_taxzone_id, -1) AS taxzone_id, cohead_orderdate AS order_date, cohead_curr_id AS curr_id, cohead_freight AS freight FROM cohead WHERE cohead_id = ' || pOrderId ; ELSEIF pOrderType = 'Q' THEN _qry := 'SELECT COALESCE(quhead_taxzone_id, -1) AS taxzone_id, quhead_quotedate AS order_date, quhead_curr_id AS curr_id, COALESCE(quhead_freight,0) AS freight FROM quhead WHERE quhead_id = ' || pOrderId; ELSEIF pOrderType = 'RA' THEN _qry := 'SELECT COALESCE(rahead_taxzone_id, -1) AS taxzone_id, COALESCE(rahead_authdate,CURRENT_DATE) AS order_date, rahead_curr_id AS curr_id, COALESCE(rahead_freight,0) AS freight FROM rahead WHERE rahead_id = ' || pOrderId; END IF; FOR _x IN EXECUTE _qry LOOP _qry1 := 'SELECT * from calculatetaxdetail(' || _x.taxzone_id || ', getfreighttaxtypeid(),''' || _x.order_date || ''',' || _x.curr_id || ',' || _x.freight || ')'; FOR _y IN EXECUTE _qry1 LOOP _row.taxdetail_tax_id=_y.taxdetail_tax_id; _row.taxdetail_tax_code = _y.taxdetail_tax_code; _row.taxdetail_tax_descrip = _y.taxdetail_tax_descrip; _row.taxdetail_tax = _y.taxdetail_tax; _row.taxdetail_level=_y.taxdetail_level; _row.taxdetail_taxclass_sequence= _y.taxdetail_taxclass_sequence; _totaltax = _totaltax + _y.taxdetail_tax; RETURN NEXT _row; END LOOP; END LOOP; END IF; ELSEIF pOrderType IN ('I','B','CM', 'VO','TO') THEN IF (pOrderType='I') THEN _table := 'invcheadtax'; ELSIF (pOrderType='B') THEN _table := 'cobmisctax'; ELSIF (pOrderType='CM') THEN _table := 'cmheadtax'; ELSIF (pOrderType='VO') THEN _table := 'voheadtax'; ELSIF (pOrderType='TO') THEN _table := 'toheadtax'; END IF; IF pOrderType = 'I' AND (pDisplayType IN ('L','T')) THEN _qry := 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence FROM invchead, invcitemtax LEFT OUTER JOIN tax ON (taxhist_tax_id=tax_id) LEFT OUTER JOIN invcitem ON (invcitem_id=taxhist_parent_id) WHERE invcitem_invchead_id = ' || pOrderId || ' AND invchead_id = invcitem_invchead_id '; ELSIF pOrderType = 'B' AND (pDisplayType IN ('L','T')) THEN _qry := 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence FROM cobmisc, cobilltax LEFT OUTER JOIN tax ON (taxhist_tax_id=tax_id) LEFT OUTER JOIN cobill ON (cobill_id=taxhist_parent_id) WHERE cobill_cobmisc_id = ' || pOrderId || ' AND cobmisc_id = cobill_cobmisc_id '; ELSIF pOrderType = 'CM' AND (pDisplayType IN ('L','T')) THEN _qry := 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence FROM cmhead, cmitemtax LEFT OUTER JOIN tax ON (taxhist_tax_id=tax_id) LEFT OUTER JOIN cmitem ON (cmitem_id=taxhist_parent_id) WHERE cmitem_cmhead_id = ' || pOrderId || ' AND cmhead_id = cmitem_cmhead_id '; ELSIF pOrderType = 'VO' AND (pDisplayType IN ('L','T')) THEN _qry := 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence FROM vohead, voitemtax LEFT OUTER JOIN tax ON (taxhist_tax_id=tax_id) LEFT OUTER JOIN voitem ON (voitem_id=taxhist_parent_id) WHERE voitem_vohead_id = ' || pOrderId || ' AND vohead_id = voitem_vohead_id '; ELSIF pOrderType = 'TO' AND (pDisplayType IN ('L','T')) THEN _qry := 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence FROM tohead, toitemtax LEFT OUTER JOIN tax ON (taxhist_tax_id=tax_id) LEFT OUTER JOIN toitem ON (toitem_id=taxhist_parent_id) WHERE toitem_tohead_id = ' || pOrderId || ' AND tohead_id = toitem_tohead_id '; END IF; IF pDisplayType IN ('F','T') AND pOrderType <> 'VO' THEN IF (length(_qry) > 0) THEN _qry := _qry || ' UNION ALL '; END IF; _qry := _qry || 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence FROM ' || _table || ' JOIN tax ON (taxhist_tax_id=tax_id) WHERE ( (taxhist_parent_id = ' || pOrderId || ') AND (taxhist_taxtype_id=getfreighttaxtypeid()) )'; END IF; IF pDisplayType IN ('A','T') THEN IF (length(_qry) > 0) THEN _qry := _qry || ' UNION ALL '; END IF; _qry := _qry || 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence FROM ' || _table || ' JOIN tax ON (taxhist_tax_id=tax_id) WHERE ( (taxhist_parent_id = ' || pOrderId || ') AND (taxhist_taxtype_id=getadjustmenttaxtypeid()) )'; END IF; FOR _y IN EXECUTE _qry LOOP _row.taxdetail_tax_id=_y.tax_id; _row.taxdetail_tax_code = _y.tax_code; _row.taxdetail_tax_descrip = _y.tax_descrip; _row.taxdetail_tax = _y.taxhist_tax; _row.taxdetail_level= 0 ; _row.taxdetail_taxclass_sequence= COALESCE(_y.taxhist_sequence,0); _totaltax = _totaltax + _y.taxhist_tax; RETURN NEXT _row; END LOOP; END IF; END; $_$; ALTER FUNCTION public.calculatetaxdetailsummary(text, integer, text) OWNER TO admin; -- -- Name: calculatetaxhist(text, integer, integer, integer, date, integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calculatetaxhist(text, integer, integer, integer, date, integer, numeric) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTableName ALIAS FOR $1; pParentId ALIAS FOR $2; pTaxZoneId ALIAS FOR $3; pTaxTypeId ALIAS FOR $4; pDate ALIAS FOR $5; pCurrId ALIAS FOR $6; pAmount ALIAS FOR $7; _qry TEXT; BEGIN IF (pTableName IS NULL) THEN RAISE EXCEPTION 'A table name is required to calculate tax history'; ELSEIF (pParentId IS NULL) THEN RAISE EXCEPTION 'A parent ID is required to calculate tax history'; ELSEIF (pDate IS NULL) THEN RAISE EXCEPTION 'A date is required to calculate tax history'; ELSEIF (pAmount IS NULL) THEN RAISE EXCEPTION 'An amount is required to calculate tax history'; END IF; -- Build a query that deletes any previous tax history for this document record _qry := 'DELETE FROM ' || pTableName || ' WHERE taxhist_parent_id = ' || pParentId || ' AND taxhist_taxtype_id <> getadjustmenttaxtypeid();'; EXECUTE _qry; -- Next, build and execute query that inserts new rows. _qry := 'INSERT INTO ' || pTableName || ' ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate) SELECT ' || pParentId || ','; IF (pTaxTypeId IS NULL) THEN _qry := _qry || 'NULL'; ELSE _qry := _qry || pTaxTypeId; END If; _qry := _qry || ', taxdetail_tax_id,' || pAmount || ', taxdetail_tax_basis_tax_id, taxdetail_taxclass_sequence, taxdetail_taxrate_percent, taxdetail_taxrate_amount, taxdetail_tax, ''' || pDate || ''' FROM calculatetaxdetail(' || COALESCE(pTaxZoneId,-1) || ',' || COALESCE(pTaxTypeId,-1) ||',''' || pDate || ''',' || pCurrId || ',' || pAmount || ');'; EXECUTE _qry; RETURN true; END; $_$; ALTER FUNCTION public.calculatetaxhist(text, integer, integer, integer, date, integer, numeric) OWNER TO admin; -- -- Name: calcvoucheramt(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calcvoucheramt(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVoucherid ALIAS FOR $1; _amount NUMERIC := 0; BEGIN SELECT SUM(COALESCE(vodist_amount, 0)) INTO _amount FROM vodist WHERE (vodist_vohead_id=pVoucherid); RETURN _amount; END; $_$; ALTER FUNCTION public.calcvoucheramt(integer) OWNER TO admin; -- -- Name: calcvoucherfreight(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calcvoucherfreight(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVoucherid ALIAS FOR $1; _amount NUMERIC := 0; BEGIN SELECT SUM(COALESCE(voitem_freight, 0)) INTO _amount FROM voitem WHERE (voitem_vohead_id=pVoucherid); RETURN _amount; END; $_$; ALTER FUNCTION public.calcvoucherfreight(integer) OWNER TO admin; -- -- Name: calcvouchertax(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calcvouchertax(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVoucherid ALIAS FOR $1; _amount NUMERIC := 0; BEGIN SELECT COALESCE(calculateTax(vohead_taxzone_id, vohead_taxtype_id, vohead_docdate, vohead_curr_id, calcVoucherAmt(vohead_id)), 0) INTO _amount FROM vohead WHERE (vohead_id=pVoucherid); RETURN _amount; END; $_$; ALTER FUNCTION public.calcvouchertax(integer) OWNER TO admin; -- -- Name: calcwooperstartstub(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION calcwooperstartstub(integer, integer) RETURNS date LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoId ALIAS FOR $1; pBooitemSeqId ALIAS FOR $2; _result DATE; BEGIN IF ( SELECT ((metric_value='t') AND packageIsEnabled('xtmfg')) FROM metric WHERE(metric_name='Routings') ) THEN RETURN xtmfg.calcWooperStart(pWoId, pBooitemSeqId); END IF; RETURN null; END; $_$; ALTER FUNCTION public.calcwooperstartstub(integer, integer) OWNER TO admin; -- -- Name: cancelbillingselection(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION cancelbillingselection(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCobmiscid ALIAS FOR $1; BEGIN IF ( ( SELECT cobmisc_posted FROM cobmisc WHERE (cobmisc_id=pCobmiscid) ) ) THEN RETURN -1; END IF; DELETE FROM cobill WHERE (cobill_cobmisc_id=pCobmiscid); DELETE FROM cobmisc WHERE (cobmisc_id=pCobmiscid); RETURN 1; END; $_$; ALTER FUNCTION public.cancelbillingselection(integer) OWNER TO admin; -- -- Name: changeaccountingperioddates(integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION changeaccountingperioddates(integer, date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _check INTEGER; _r RECORD; BEGIN -- Check to make sure that the passed period is not closed IF ( ( SELECT period_closed FROM period WHERE (period_id=pPeriodid) ) ) THEN RETURN -1; END IF; -- Check to make sure that the passed start date does not fall -- into another period SELECT period_id INTO _check FROM period WHERE ( (pStartDate BETWEEN period_start AND period_end) AND (period_id <> pPeriodid) ) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; -- Check to make sure that the passed end date does not fall -- into another period SELECT period_id INTO _check FROM period WHERE ( (pEndDate BETWEEN period_start AND period_end) AND (period_id <> pPeriodid) ) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; -- Check to make sure that the new passed start and end dates do not -- orphan a posted G/L Transaction SELECT gltrans_id INTO _check FROM gltrans, period WHERE ( (gltrans_date BETWEEN period_start AND period_end) AND (gltrans_posted) AND (NOT (gltrans_date BETWEEN pStartDate AND pEndDate)) AND (period_id=pPeriodid) ) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; -- Alter the start and end dates of the pass period UPDATE period SET period_start=pStartDate, period_end=pEndDate WHERE (period_id=pPeriodid); -- Post any unposted G/L Transactions into the period FOR _r IN SELECT DISTINCT gltrans_sequence FROM gltrans WHERE ( (NOT gltrans_posted) AND (gltrans_date BETWEEN pStartDate AND pEndDate) ) LOOP PERFORM postIntoTrialBalance(_r.gltrans_sequence); END LOOP; -- All done RETURN 1; END; $_$; ALTER FUNCTION public.changeaccountingperioddates(integer, date, date) OWNER TO admin; -- -- Name: changeaccountingyearperioddates(integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION changeaccountingyearperioddates(integer, date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _check INTEGER; _checkBool BOOLEAN; _r RECORD; BEGIN -- Check to make sure that the passed yearperiod is not closed IF ( ( SELECT yearperiod_closed FROM yearperiod WHERE (yearperiod_id=pPeriodid) ) ) THEN RETURN -1; END IF; -- Check to make sure that the passed start date does not fall -- into another yearperiod SELECT yearperiod_id INTO _check FROM yearperiod WHERE ( (pStartDate BETWEEN yearperiod_start AND yearperiod_end) AND (yearperiod_id <> pPeriodid) ) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; -- Check to make sure that the passed end date does not fall -- into another yearperiod SELECT yearperiod_id INTO _check FROM yearperiod WHERE ( (pEndDate BETWEEN yearperiod_start AND yearperiod_end) AND (yearperiod_id <> pPeriodid) ) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; -- Check to make sure that the passed yearperiod is not closed IF ( ( SELECT (count(period_id) > 0) FROM period WHERE ((period_yearperiod_id=pPeriodid) AND (period_start < pStartDate OR period_end > pEndDate)) ) ) THEN RETURN -4; END IF; -- Make sure that the passed start is prior to the end date SELECT (pStartDate > pEndDate) INTO _checkBool; IF (_checkBool) THEN RETURN -5; END IF; -- Alter the start and end dates of the pass period UPDATE yearperiod SET yearperiod_start=pStartDate, yearperiod_end=pEndDate WHERE (yearperiod_id=pPeriodid); -- All done RETURN 1; END; $_$; ALTER FUNCTION public.changeaccountingyearperioddates(integer, date, date) OWNER TO admin; -- -- Name: changefkeypointers(text, text, integer, integer, text[], boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION changefkeypointers(text, text, integer, integer, text[], boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSchema ALIAS FOR $1; pTable ALIAS FOR $2; pSourceId ALIAS FOR $3; pTargetId ALIAS FOR $4; pIgnore ALIAS FOR $5; _purge BOOLEAN := COALESCE($6, FALSE); _counter INTEGER := 0; _count1 INTEGER := 0; _fk RECORD; _pk TEXT[]; BEGIN -- for all foreign keys that point to pSchema.pTable FOR _fk IN EXECUTE 'SELECT fkeyns.nspname AS schemaname, fkeytab.relname AS tablename, conkey, attname, typname FROM pg_constraint JOIN pg_class basetab ON (confrelid=basetab.oid) JOIN pg_namespace basens ON (basetab.relnamespace=basens.oid) JOIN pg_class fkeytab ON (conrelid=fkeytab.oid) JOIN pg_namespace fkeyns ON (fkeytab.relnamespace=fkeyns.oid) JOIN pg_attribute ON (attrelid=conrelid AND attnum=conkey[1]) JOIN pg_type ON (atttypid=pg_type.oid) WHERE basetab.relname = ' || quote_literal(pTable) || ' AND basens.nspname = ' || quote_literal(pSchema) || ' AND fkeytab.relname NOT IN (''' || ARRAY_TO_STRING(pIgnore, ''', ''') || ''')' LOOP IF (ARRAY_UPPER(_fk.conkey, 1) > 1) THEN RAISE EXCEPTION 'Cannot change the foreign key in %.% that refers to %.% because the foreign key constraint has multiple columns. [xtuple: changefkeypointers, -1, %.%, %.%]', _fk.schemaname, _fk.tablename, pSchema, pTable, _fk.schemaname, _fk.tablename, pSchema, pTable; END IF; -- optionally make a backup copy of the data IF (NOT _purge) THEN -- determine the primary key column of the fkey table _pk := primaryKeyFields(_fk.schemaname, _fk.tablename); IF (ARRAY_UPPER(_pk, 1) > 1) THEN RAISE EXCEPTION 'Cannot change foreign key references in %.% because it has a composite primary key. Try setting the purge option. [xtuple: changefkeypointers, -4, %.%]', _fk.schemaname, _fk.tablename, _fk.schemaname, _fk.tablename; END IF; -- make the backup copy EXECUTE 'INSERT INTO mrgundo ( mrgundo_schema, mrgundo_table, mrgundo_pkey_col, mrgundo_pkey_id, mrgundo_col, mrgundo_value, mrgundo_type, mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id ) SELECT ' || quote_literal(_fk.schemaname) || ', ' || quote_literal(_fk.tablename) || ', ' || quote_literal(_pk[1]) || ', ' || _pk[1] || ', ' || quote_literal(_fk.attname) || ', ' || _fk.attname || ', ' || quote_literal(_fk.typname) || ', ' || quote_literal(pSchema) || ', ' || quote_literal(pTable) || ', ' || pTargetId || ' FROM ' || _fk.schemaname || '.' || _fk.tablename || ' WHERE ('|| _fk.attname || '=' || pSourceId || ');'; END IF; -- actually change the foreign keys to point to the desired base table record EXECUTE 'UPDATE ' || _fk.schemaname || '.' || _fk.tablename || ' SET ' || _fk.attname || '=' || pTargetId || ' WHERE (' || _fk.attname || '=' || pSourceId || ');'; GET DIAGNOSTICS _count1 = ROW_COUNT; _counter := _counter + _count1; END LOOP; RETURN _counter; END; $_$; ALTER FUNCTION public.changefkeypointers(text, text, integer, integer, text[], boolean) OWNER TO admin; -- -- Name: FUNCTION changefkeypointers(text, text, integer, integer, text[], boolean); Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON FUNCTION changefkeypointers(text, text, integer, integer, text[], boolean) IS 'Change the data in all tables with foreign key relationships so they point to the pSchema.pTable record with primary key pTargetId instead of the record with primary key pSourceId. Ignore any tables listed in pIgnore. If the final arg is TRUE, make a backup copy of the original data in the mrgundo table.'; -- -- Name: changepoitemduedate(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION changepoitemduedate(ppoitemid integer, pdate date) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN changePoitemDueDate(pPoitemid, pDate, false); END; $$; ALTER FUNCTION public.changepoitemduedate(ppoitemid integer, pdate date) OWNER TO admin; -- -- Name: changepoitemduedate(integer, date, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION changepoitemduedate(ppoitemid integer, pdate date, pbyso boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF ( ( SELECT (poitem_status IN ('C')) FROM poitem WHERE (poitem_id=pPoitemid) ) ) THEN RETURN -1; END IF; UPDATE poitem SET poitem_duedate=pDate WHERE (poitem_id=pPoitemid); IF (pBySO) THEN --Generate the PoItemUpdatedBySo event PERFORM postEvent('PoItemUpdatedBySo', 'P', poitem_id, itemsite_warehous_id, (pohead_number || '-'|| poitem_linenumber || ': ' || item_number), NULL, NULL, NULL, NULL) FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id) JOIN itemsite ON (itemsite_id=poitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (poitem_id=pPoitemid) AND (poitem_duedate <= (CURRENT_DATE + itemsite_eventfence)); END IF; RETURN pPoitemid; END; $$; ALTER FUNCTION public.changepoitemduedate(ppoitemid integer, pdate date, pbyso boolean) OWNER TO admin; -- -- Name: changepoitemqty(integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION changepoitemqty(ppoitemid integer, pqty numeric) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN changePoitemQty(pPoitemid, pQty, false); END; $$; ALTER FUNCTION public.changepoitemqty(ppoitemid integer, pqty numeric) OWNER TO admin; -- -- Name: changepoitemqty(integer, numeric, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION changepoitemqty(ppoitemid integer, pqty numeric, pbyso boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF ( ( SELECT (poitem_status IN ('C')) FROM poitem WHERE (poitem_id=pPoitemid) ) ) THEN RETURN -1; END IF; UPDATE poitem SET poitem_qty_ordered=pQty WHERE (poitem_id=pPoitemid); IF (pBySO) THEN --Generate the PoItemUpdatedBySo event PERFORM postEvent('PoItemUpdatedBySo', 'P', poitem_id, itemsite_warehous_id, (pohead_number || '-'|| poitem_linenumber || ': ' || item_number), NULL, NULL, NULL, NULL) FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id) JOIN itemsite ON (itemsite_id=poitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (poitem_id=pPoitemid) AND (poitem_duedate <= (CURRENT_DATE + itemsite_eventfence)); END IF; RETURN pPoitemid; END; $$; ALTER FUNCTION public.changepoitemqty(ppoitemid integer, pqty numeric, pbyso boolean) OWNER TO admin; -- -- Name: changeprdate(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION changeprdate(integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrid ALIAS FOR $1; pDueDate ALIAS FOR $2; BEGIN UPDATE pr SET pr_duedate=pDueDate WHERE (pr_id=pPrid); RETURN 0; END; $_$; ALTER FUNCTION public.changeprdate(integer, date) OWNER TO admin; -- -- Name: changeprqty(integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION changeprqty(integer, numeric) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrid ALIAS FOR $1; pQty ALIAS FOR $2; BEGIN UPDATE pr SET pr_qtyreq=pQty WHERE (pr_id=pPrid); RETURN TRUE; END; $_$; ALTER FUNCTION public.changeprqty(integer, numeric) OWNER TO admin; -- -- Name: changeprqty(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION changeprqty(integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pPrid ALIAS FOR $1; pDueDate ALIAS FOR $2; BEGIN UPDATE pr SET pr_duedate=pDueDate WHERE (pr_id=pPrid); RETURN 0; END; $_$; ALTER FUNCTION public.changeprqty(integer, date) OWNER TO admin; -- -- Name: changepseudofkeypointers(text, text, text, integer, text, text, integer, text, text, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION changepseudofkeypointers(text, text, text, integer, text, text, integer, text, text, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSchema ALIAS FOR $1; pTable ALIAS FOR $2; pFkeyCol ALIAS FOR $3; pSourceId ALIAS FOR $4; pBaseSchema ALIAS FOR $5; pBaseTable ALIAS FOR $6; pTargetId ALIAS FOR $7; pTypeCol ALIAS FOR $8; pType ALIAS FOR $9; _purge BOOLEAN := COALESCE($10, FALSE); _counter INTEGER := 0; _coltype TEXT; _pk TEXT[]; BEGIN IF (NOT _purge) THEN EXECUTE 'SELECT typname FROM pg_type JOIN pg_attribute ON (pg_type.oid=atttypid) JOIN pg_class ON (attrelid=pg_class.oid) JOIN pg_namespace ON (relnamespace=pg_namespace.oid) WHERE (relname=' || quote_literal(pTable) || ') AND (nspname=' || quote_literal(pSchema) || ') AND (attname=' || quote_literal(pFkeyCol) || ')' INTO _coltype; _pk := primaryKeyFields(pSchema, pTable); IF (ARRAY_UPPER(_pk, 1) > 1) THEN RAISE EXCEPTION 'Cannot change pseudo-foreign key references in %.% because it has a composite primary key. Try setting the purge option. [xtuple: changepseudofkeypointers, -1, %.%', pSchema, pTable, pSchema, pTable; END IF; EXECUTE 'INSERT INTO mrgundo ( mrgundo_schema, mrgundo_table, mrgundo_pkey_col, mrgundo_pkey_id, mrgundo_col, mrgundo_value, mrgundo_type, mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id ) SELECT ' || quote_literal(pSchema) || ', ' || quote_literal(pTable) || ', ' || quote_literal(_pk[1]) || ', ' || quote_ident(_pk[1]) || ', ' || quote_literal(pFkeyCol) || ', ' || quote_ident(pFkeyCol) || ', ' || quote_literal(_coltype) || ', ' || quote_literal(pBaseSchema) || ', ' || quote_literal(pBaseTable) || ', ' || pTargetId || ' FROM ' || quote_ident(pSchema) || '.' || quote_ident(pTable) || ' WHERE (('|| quote_ident(pFkeyCol) || '=' || pSourceId || ') AND ('|| quote_ident(pTypeCol) || '=' || quote_literal(pType) || '));'; END IF; -- actually change the foreign keys to point to the desired base table record EXECUTE 'UPDATE ' || quote_ident(pSchema) || '.' || quote_ident(pTable) || ' SET ' || quote_ident(pFkeyCol) || '=' || pTargetId || ' WHERE ((' || quote_ident(pFkeyCol) || '=' || pSourceId || ') AND (' || quote_ident(pTypeCol) || '=' || quote_literal(pType) || '));'; GET DIAGNOSTICS _counter = ROW_COUNT; RETURN _counter; END; $_$; ALTER FUNCTION public.changepseudofkeypointers(text, text, text, integer, text, text, integer, text, text, boolean) OWNER TO admin; -- -- Name: FUNCTION changepseudofkeypointers(text, text, text, integer, text, text, integer, text, text, boolean); Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON FUNCTION changepseudofkeypointers(text, text, text, integer, text, text, integer, text, text, boolean) IS 'Change the data in pSchema.pTable with a pseudo-foreign key relationship to another (unnamed) table. Make pSchema.pTable point to the record with primary key pTargetId instead of the record with primary key pSourceId. pSchema.pTable cannot have a true foreign key relationship because it holds data that can point to any of several tables. The pType value in the pTypeCol column describes which table the data refer to (e.g. "T" may indicate that the current record refers to a "cntct"). If the final arg is TRUE, make a backup copy of the data in the mrgundo table.'; -- -- Name: changepurchasedropship(integer, integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION changepurchasedropship(pcoitemid integer, ppoitemid integer, pdropship boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _s RECORD; _w RECORD; _p RECORD; _result INTEGER; _poitemid INTEGER; BEGIN -- Check for existing poitem for this coitem SELECT * INTO _p FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id) WHERE (poitem_id=pPoitemId) AND (poitem_order_id=pCoitemId) AND (poitem_order_type='S'); IF (NOT FOUND) THEN RAISE EXCEPTION 'Change Purchase Drop Ship PO not found'; END IF; SELECT * INTO _s FROM coitem JOIN cohead ON (cohead_id = coitem_cohead_id) LEFT OUTER JOIN shiptoinfo ON (cohead_shipto_id = shipto_id) LEFT OUTER JOIN cntct ON (shipto_cntct_id = cntct_id) LEFT OUTER JOIN addr ON (shipto_addr_id = addr_id) WHERE (coitem_id = pCoitemId); IF (NOT FOUND) THEN RETURN -1; END IF; IF (_p.pohead_status != 'U') THEN RETURN -3; END IF; SELECT deletePoitem(_p.poitem_id) INTO _result; IF (_result < 0) THEN RETURN _result; END IF; SELECT createPurchaseToSale(_s.coitem_id, _p.poitem_itemsrc_id, pDropShip, _s.coitem_qtyord, _s.coitem_scheddate, NULL) INTO _poitemid; RETURN _poitemid; END; $$; ALTER FUNCTION public.changepurchasedropship(pcoitemid integer, ppoitemid integer, pdropship boolean) OWNER TO admin; -- -- Name: changewodates(integer, date, date, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION changewodates(integer, date, date, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pStartDate ALIAS FOR $2; pDueDate ALIAS FOR $3; changeChildren ALIAS FOR $4; _p RECORD; returnCode INTEGER; _vtemp NUMERIC; BEGIN SELECT wo_status, wo_startdate, itemsite_warehous_id INTO _p FROM wo Inner Join itemsite on wo_itemsite_id=itemsite_id WHERE (wo_id=pWoid); IF (_p.wo_status = 'C') THEN returnCode := 0; ELSIF (_p.wo_status IN ('R','I')) THEN PERFORM postEvent('RWoDueDateRequestChange', 'W', wo_id, itemsite_warehous_id, formatWoNumber(wo_id), NULL, NULL, pDueDate, wo_duedate) FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (wo_id=pWoid); returnCode := 0; END IF; -- Reschedule operations if routings enabled IF (fetchMetricBool('Routings')) THEN -- Reschedule wooper IF (fetchMetricBool('UseSiteCalendar')) THEN UPDATE xtmfg.wooper SET wooper_scheduled = calculatenextworkingdate(itemsite_warehous_id,DATE(pStartDate), CAST(calculateworkdays(itemsite_warehous_id, DATE(wo_startdate), DATE(wooper_scheduled)) as INTEGER)) FROM wo JOIN itemsite ON (wo_itemsite_id=itemsite_id) WHERE ( (wooper_wo_id=wo_id) AND (wo_id=pWoid) ); ELSE UPDATE xtmfg.wooper SET wooper_scheduled = (wooper_scheduled::DATE + (pStartDate - wo_startdate)) FROM wo WHERE ( (wooper_wo_id=wo_id) AND (wo_id=pWoid) ); END IF; -- Reschedule any womatl that is linked to wooper items -- and is set to be scheduled with the wooper in question UPDATE womatl SET womatl_duedate=wooper_scheduled FROM xtmfg.wooper WHERE ( (womatl_schedatwooper) AND (womatl_wooper_id=wooper_id) AND (womatl_wo_id=pWoid) ); END IF; -- Reschedule any womatl that is not linked to wooper items UPDATE womatl SET womatl_duedate=pStartDate WHERE ( (NOT womatl_schedatwooper) AND (womatl_wo_id=pWoid) ); -- Reschedule the W/O UPDATE wo SET wo_startdate=pStartDate, wo_duedate=pDueDate WHERE (wo_id=pWoid); -- Do the same for the children IF (changeChildren) THEN SELECT MAX(changeWoDates(wo_id, (pStartDate - itemsite_leadtime), pStartDate, TRUE)) INTO returnCode FROM wo, itemsite WHERE ( (wo_itemsite_id=itemsite_id) AND (wo_ordtype='W') AND (wo_ordid=pWoid) ); END IF; IF (returnCode IS NULL) THEN returnCode := 0; END IF; RETURN returnCode; END; $_$; ALTER FUNCTION public.changewodates(integer, date, date, boolean) OWNER TO admin; -- -- Name: changewoproject(integer, integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION changewoproject(integer, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pPrjid ALIAS FOR $2; changeChildren ALIAS FOR $3; woStatus CHAR(1); _result INTEGER; BEGIN SELECT wo_status INTO woStatus FROM wo WHERE (wo_id=pWoid); UPDATE wo SET wo_prj_id=pPrjid WHERE (wo_id=pWoid); IF (woStatus = 'E' AND changeChildren) THEN _result := ( SELECT MIN(changeWoProject(wo_id, pPrjid, TRUE)) FROM womatl, wo WHERE ((womatl_itemsite_id=wo_itemsite_id) AND (wo_ordtype='W') AND (womatl_wo_id=pWoid) AND (wo_ordid=pWoid)) ); UPDATE pr SET pr_prj_id=pPrjid FROM womatl WHERE ((womatl_wo_id=pWoid) AND (pr_order_type='W') AND (pr_order_id=womatl_id)); ELSE _result = 1; END IF; RETURN _result; END; $_$; ALTER FUNCTION public.changewoproject(integer, integer, boolean) OWNER TO admin; -- -- Name: changewoqty(integer, numeric, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION changewoqty(integer, numeric, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pQty ALIAS FOR $2; changeChildren ALIAS FOR $3; _r RECORD; _result INTEGER := 1; BEGIN SELECT wo_qtyord, wo_status, item_fractional INTO _r FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (wo_id=pWoid); IF (_r.wo_qtyord = pQty) THEN RETURN 0; END IF; IF (NOT _r.wo_status IN ('O','E','R','I')) THEN RETURN 1; END IF; IF (_r.wo_status IN ('R','I')) THEN PERFORM postEvent('RWoQtyRequestChange', 'W', wo_id, itemsite_warehous_id, formatWoNumber(wo_id), pQty, wo_qtyord, NULL, NULL) FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (wo_id=pWoid); _result = 0; END IF; UPDATE wo SET wo_qtyord=roundQty(_r.item_fractional, pQty) WHERE (wo_id=pWoid); UPDATE womatl SET womatl_qtyreq=(womatl_qtyfxd + wo_qtyord * womatl_qtyper) * (1 + womatl_scrap) FROM wo, itemsite WHERE ((womatl_wo_id=wo_id) AND (womatl_itemsite_id=itemsite_id) AND (wo_id=pWoid)); IF (fetchMetricBool('Routings')) THEN UPDATE xtmfg.wooper SET wooper_rntime = CASE WHEN ((booitem_rnqtyper = 0) OR (booitem_invproduomratio = 0)) THEN 0 WHEN (NOT booitem_rnrpt) THEN 0 ELSE ( ( booitem_rntime / booitem_rnqtyper / booitem_invproduomratio ) * wo_qtyord ) END FROM xtmfg.booitem, wo WHERE ((wooper_wo_id=wo_id) AND (wooper_booitem_id=booitem_id) AND (wo_id=pWoid)); END IF; IF (changeChildren) THEN _result := ( SELECT MIN(changeWoQty(wo_id, womatl_qtyreq, TRUE)) FROM womatl, wo WHERE ((womatl_itemsite_id=wo_itemsite_id) AND (wo_ordtype='W') AND (womatl_wo_id=pWoid) AND (wo_ordid=pWoid)) ); END IF; RETURN _result; END; $_$; ALTER FUNCTION public.changewoqty(integer, numeric, boolean) OWNER TO admin; -- -- Name: characteristicstostring(text, integer, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION characteristicstostring(text, integer, text, text) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTargetType ALIAS FOR $1; pTargetId ALIAS FOR $2; pValKeySep ALIAS FOR $3; pPairSep ALIAS FOR $4; _string TEXT := ''; _extra BOOLEAN := false; _r RECORD; BEGIN FOR _r IN SELECT char_name, charass_value FROM charass, char WHERE ((charass_char_id=char_id) AND (charass_target_type=pTargetType) AND (charass_target_id=pTargetId)) LOOP IF(_extra) THEN _string := _string || pPairSep; END IF; _extra := true; _string := _string || _r.char_name || pValKeySep || _r.charass_value; END LOOP; RETURN _string; END; $_$; ALTER FUNCTION public.characteristicstostring(text, integer, text, text) OWNER TO admin; -- -- Name: checkcreditmemositeprivs(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION checkcreditmemositeprivs(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmheadid ALIAS FOR $1; _check BOOLEAN; _result INTEGER; BEGIN IF (NOT fetchMetricBool('MultiWhs')) THEN RETURN true; END IF; IF (NOT fetchUsrPrefBool('selectedSites')) THEN RETURN true; END IF; SELECT COALESCE(COUNT(*), 0) INTO _result FROM ( SELECT cmitem_id FROM cmitem JOIN itemsite ON (itemsite_id=cmitem_itemsite_id) WHERE ( (cmitem_cmhead_id=pCmheadid) AND (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) ) AS data; IF (_result > 0) THEN RETURN false; END IF; RETURN true; END; $_$; ALTER FUNCTION public.checkcreditmemositeprivs(integer) OWNER TO admin; -- -- Name: checkdetailformatted(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION checkdetailformatted(integer, integer) RETURNS SETOF checkdata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCheckheadid ALIAS FOR $1; pMaxLines ALIAS FOR $2; _row checkdata%ROWTYPE; _checkhead RECORD; _checkdetail RECORD; _rowcount INTEGER := 0; _page INTEGER := 1; _docnumber TEXT := ''; _docreference TEXT := ''; _docdate TEXT := ''; _docamount TEXT := ''; _docdiscount TEXT := ''; _docnetamount TEXT := ''; BEGIN -- Check header information SELECT checkhead_number AS checknumber, INITCAP(spellAmount(checkhead_amount, curr_id)) AS checkwords, formatDate(checkhead_checkdate) AS checkdate, formatMoney(checkhead_amount) AS checkamount, curr_symbol AS checkcurrsymbol, curr_abbr AS checkcurrabbr, curr_name AS checkcurrname, CASE WHEN checkhead_recip_type = 'C' THEN (SELECT cust_name FROM custinfo WHERE cust_id=checkhead_recip_id) WHEN checkhead_recip_type = 'T' THEN (SELECT taxauth_name FROM taxauth WHERE taxauth_id=checkhead_recip_id) WHEN checkhead_recip_type = 'V' THEN COALESCE((SELECT vendaddr_name FROM vendaddrinfo WHERE((UPPER(vendaddr_code)='REMIT') AND (vendaddr_vend_id=checkhead_recip_id))), (SELECT vend_name FROM vendinfo WHERE(vend_id=checkhead_recip_id))) END AS checkpayto, formatAddr(CASE WHEN checkhead_recip_type = 'C' THEN (SELECT cntct_addr_id FROM cntct, custinfo WHERE((cust_cntct_id=cntct_id) AND (cust_id=checkhead_recip_id))) WHEN checkhead_recip_type = 'T' THEN (SELECT taxauth_addr_id FROM taxauth WHERE(taxauth_id=checkhead_recip_id)) WHEN checkhead_recip_type = 'V' THEN COALESCE((SELECT vendaddr_addr_id FROM vendaddrinfo WHERE((UPPER(vendaddr_code)='REMIT') AND (vendaddr_vend_id=checkhead_recip_id))), (SELECT vend_addr_id FROM vendinfo WHERE(vend_id=checkhead_recip_id))) END) AS checkaddress, checkhead_for AS checkmemo INTO _checkhead FROM checkhead, curr_symbol WHERE((checkhead_curr_id = curr_id) AND (checkhead_id=pCheckheadid) ); IF (NOT FOUND) THEN RETURN; END IF; _row.checkdata_page := _page; _row.checkdata_checknumber := _checkhead.checknumber; _row.checkdata_checkwords := _checkhead.checkwords; _row.checkdata_checkdate := _checkhead.checkdate; _row.checkdata_checkamount := _checkhead.checkamount; _row.checkdata_checkcurrsymbol := _checkhead.checkcurrsymbol; _row.checkdata_checkcurrabbr := _checkhead.checkcurrabbr; _row.checkdata_checkcurrname := _checkhead.checkcurrname; _row.checkdata_checkpayto := _checkhead.checkpayto; _row.checkdata_checkaddress := _checkhead.checkaddress; _row.checkdata_checkmemo := _checkhead.checkmemo; -- Check item details FOR _checkdetail IN SELECT --VOUCHER------------- 1 AS ord, 1 AS sequence_value, checkitem_invcnumber, checkitem_ponumber, formatMoney(checkitem_amount) AS docnetamount, 'Invoice#: ' || vohead_invcnumber AS docnumber, formatDate(vohead_docdate) AS docdate, vohead_reference AS docreference, 'Voucher: ' || checkitem_vouchernumber AS vouchernumber, formatMoney(apopen_amount) AS docamount, formatMoney(checkitem_discount) AS docdiscount FROM checkitem, vohead, apopen WHERE ((checkitem_checkhead_id=pCheckheadid) AND (checkitem_vouchernumber = vohead_number) AND (checkitem_apopen_id = apopen_id) AND (apopen_doctype = 'V')) UNION SELECT --DEBIT MEMO ------------------------- 2 AS ord, 1 AS sequence_value, checkitem_invcnumber, checkitem_ponumber, formatMoney(checkitem_amount) AS f_amount, 'Debit Memo PO#: ' || checkitem_ponumber AS doc_number, '' AS f_docdate, 'Debit Memo: ' || checkitem_vouchernumber AS doc_reference, checkitem_vouchernumber AS vouchernumber, formatMoney(apopen_amount) AS amount, formatMoney(checkitem_discount) AS disc_cred FROM checkitem, apopen WHERE ((checkitem_checkhead_id=pCheckheadid) AND (checkitem_apopen_id = apopen_id) AND (apopen_doctype = 'D')) UNION SELECT --CREDIT MEMO ------------------------- 2 AS ord, 1 AS sequence_value, checkitem_invcnumber, checkitem_ponumber, formatMoney(checkitem_amount * -1.0) AS f_amount, 'Credit Memo PO#: ' || checkitem_ponumber AS doc_number, '' AS f_docdate, 'Credit Memo: ' || checkitem_vouchernumber AS doc_reference, checkitem_vouchernumber AS vouchernumber, '' AS amount, formatMoney(checkitem_amount) AS disc_cred FROM checkitem, apopen WHERE ((checkitem_checkhead_id=pCheckheadid) AND (checkitem_apopen_id = apopen_id) AND (apopen_doctype = 'C')) UNION SELECT --CREDITs FOR VOUCHERS----------------- 3 AS ord, 1 AS sequence_value, checkitem_invcnumber, checkitem_ponumber, formatMoney(checkitem_amount) AS f_amount, 'Invoice#: ' || vohead_invcnumber AS doc_number, formatDate(vohead_docdate) AS f_docdate, 'Credit Applied: ' || apapply_source_doctype || ' ' || apapply_source_docnumber AS doc_reference, 'Voucher: ' || checkitem_vouchernumber AS vouchernumber, '' AS amount, formatMoney((apapply_amount)) AS disc_cred FROM checkitem, vohead, apapply WHERE ((checkitem_checkhead_id=pCheckheadid) AND (checkitem_vouchernumber = vohead_number) AND (apapply_target_docnumber = checkitem_vouchernumber) AND (apapply_target_doctype = 'V') AND (apapply_source_doctype = 'C')) UNION SELECT --CREDITs FOR DEBIT MEMOS----------- 3 AS ord, 1 AS sequence_value, checkitem_invcnumber, checkitem_ponumber, formatMoney(checkitem_amount) AS f_amount, 'Debit Memo PO#: ' || checkitem_ponumber AS doc_number, '' AS f_docdate, 'Credit Applied: ' || apapply_source_doctype || ' ' || apapply_source_docnumber AS doc_reference, 'Debit Memo: ' || checkitem_vouchernumber AS vouchernumber, '' AS amount, formatMoney((apapply_amount)) AS disc_cred FROM checkitem, apopen, apapply WHERE ((checkitem_checkhead_id=pCheckheadid) AND (checkitem_apopen_id = apopen_id) AND (apopen_doctype = 'D') AND (apapply_target_apopen_id = apopen_id) AND (apapply_target_doctype = 'D') AND (apapply_source_doctype = 'C')) UNION SELECT --NON-VENDOR----------------------- 4 AS ord, 1 AS sequence_value, checkitem_invcnumber, checkitem_ponumber, formatMoney(checkitem_amount) AS f_amount, checkitem_invcnumber AS doc_number, formatDate(checkitem_docdate) AS f_docdate, '' AS doc_reference, '' AS vouchernumber, '' AS amount, '' AS disc_cred FROM checkhead LEFT OUTER JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) WHERE ((checkhead_id=pCheckheadid) AND (checkhead_recip_type != 'V')) LOOP IF (_rowcount = pMaxLines) THEN _row.checkdata_docnumber := _docnumber; _row.checkdata_docreference := _docreference; _row.checkdata_docdate := _docdate; _row.checkdata_docamount := _docamount; _row.checkdata_docdiscount := _docdiscount; _row.checkdata_docnetamount := _docnetamount; RETURN NEXT _row; -- update/reset some variables _rowcount = 0; _page := _page + 1; _docnumber := ''; _docreference := ''; _docdate := ''; _docamount := ''; _docdiscount := ''; _docnetamount := ''; _row.checkdata_page := _page; _row.checkdata_checknumber := _checkhead.checknumber; _row.checkdata_checkwords := 'VOID VOID PAGE '||_page||' OF CHECK #'||_checkhead.checknumber||' VOID VOID'; _row.checkdata_checkdate := 'VOID VOID VOID'; _row.checkdata_checkamount := 'VOID VOID VOID'; --_row.checkdata_checkcurrsymbol := _checkhead.checkcurrsymbol; --_row.checkdata_checkcurrabbr := _checkhead.checkcurrabbr; --_row.checkdata_checkcurrname := _checkhead.checkcurrname; _row.checkdata_checkpayto := 'VOID VOID VOID'; --_row.checkdata_checkaddress := _checkhead.checkaddress; _row.checkdata_checkmemo := 'VOID VOID PAGE '||_page||' OF CHECK #'||_checkhead.checknumber||' VOID VOID'; END IF; _rowcount := _rowcount + 1; _docnumber := _docnumber || _checkdetail.docnumber || E'\n'; _docreference := _docreference || _checkdetail.docreference || E'\n'; _docdate := _docdate || _checkdetail.docdate || E'\n'; _docamount := _docamount || _checkdetail.docamount || E'\n'; _docdiscount := _docdiscount || _checkdetail.docdiscount || E'\n'; _docnetamount := _docnetamount || _checkdetail.docnetamount || E'\n'; END LOOP; _row.checkdata_docnumber := _docnumber; _row.checkdata_docreference := _docreference; _row.checkdata_docdate := _docdate; _row.checkdata_docamount := _docamount; _row.checkdata_docdiscount := _docdiscount; _row.checkdata_docnetamount := _docnetamount; RETURN NEXT _row; RETURN; END; $_$; ALTER FUNCTION public.checkdetailformatted(integer, integer) OWNER TO admin; -- -- Name: checkinvoicesiteprivs(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION checkinvoicesiteprivs(integer) RETURNS boolean LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvcheadid ALIAS FOR $1; _check BOOLEAN; _result INTEGER; BEGIN IF (NOT fetchMetricBool('MultiWhs')) THEN RETURN true; END IF; IF (NOT fetchUsrPrefBool('selectedSites')) THEN RETURN true; END IF; SELECT COALESCE(COUNT(*), 0) INTO _result FROM ( SELECT invcitem_id FROM invcitem WHERE ( (invcitem_invchead_id=pInvcheadid) AND (invcitem_warehous_id <> -1) AND (invcitem_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) ) AS data; IF (_result > 0) THEN RETURN false; END IF; RETURN true; END; $_$; ALTER FUNCTION public.checkinvoicesiteprivs(integer) OWNER TO admin; -- -- Name: checkpositeprivs(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION checkpositeprivs(integer) RETURNS boolean LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPoheadid ALIAS FOR $1; _check BOOLEAN; _result INTEGER; BEGIN IF (NOT fetchMetricBool('MultiWhs')) THEN RETURN true; END IF; IF (NOT fetchUsrPrefBool('selectedSites')) THEN RETURN true; END IF; SELECT COALESCE(COUNT(*), 0) INTO _result FROM ( SELECT poitem_id FROM poitem, itemsite WHERE ( (poitem_pohead_id=pPoheadid) AND (poitem_itemsite_id=itemsite_id) AND (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) UNION SELECT pohead_warehous_id FROM pohead WHERE ( (pohead_id=pPoheadid) AND (pohead_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) ) AS data; IF (_result > 0) THEN RETURN false; END IF; RETURN true; END; $_$; ALTER FUNCTION public.checkpositeprivs(integer) OWNER TO admin; -- -- Name: checkprivilege(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION checkprivilege(text) RETURNS boolean LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrivilege ALIAS FOR $1; _result TEXT; BEGIN SELECT priv_id INTO _result FROM priv, grppriv, usrgrp WHERE((usrgrp_grp_id=grppriv_grp_id) AND (grppriv_priv_id=priv_id) AND (priv_name=pPrivilege) AND (usrgrp_username=getEffectiveXtUser())); IF (FOUND) THEN RETURN true; END IF; SELECT priv_id INTO _result FROM priv, usrpriv WHERE ((priv_id=usrpriv_priv_id) AND (priv_name=pPrivilege) AND (usrpriv_username=getEffectiveXtUser())); IF (FOUND) THEN RETURN true; ELSE RETURN false; END IF; END; $_$; ALTER FUNCTION public.checkprivilege(text) OWNER TO admin; -- -- Name: checkquotesiteprivs(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION checkquotesiteprivs(integer) RETURNS boolean LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuheadid ALIAS FOR $1; BEGIN RETURN checkQuoteSitePrivs(pQuheadid, NULL); END; $_$; ALTER FUNCTION public.checkquotesiteprivs(integer) OWNER TO admin; -- -- Name: checkquotesiteprivs(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION checkquotesiteprivs(integer, integer) RETURNS boolean LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuheadid ALIAS FOR $1; pWarehousid ALIAS FOR $2; _result INTEGER := 0; BEGIN -- RAISE NOTICE 'checkQuoteSitePrivs, pQuheadid = %', pQuheadid; -- RAISE NOTICE 'checkQuoteSitePrivs, pWarehousid = %', pWarehousid; IF (NOT fetchMetricBool('MultiWhs')) THEN RETURN true; END IF; IF ( (NOT fetchUsrPrefBool('selectedSites')) AND (pWarehousid IS NULL) ) THEN RETURN true; END IF; IF (pWarehousid IS NULL) THEN SELECT COALESCE(COUNT(*), 0) INTO _result FROM quitem JOIN itemsite ON (itemsite_id=quitem_itemsite_id) JOIN site() ON (warehous_id=itemsite_warehous_id) WHERE (quitem_quhead_id=pQuheadid); ELSE SELECT COALESCE(COUNT(*), 0) INTO _result FROM quitem JOIN itemsite ON (itemsite_id=quitem_itemsite_id) JOIN site() ON (warehous_id=itemsite_warehous_id) WHERE ( (quitem_quhead_id=pQuheadid) AND (itemsite_warehous_id=pWarehousid) ); END IF; IF (_result > 0) THEN RETURN true; END IF; RETURN false; END; $_$; ALTER FUNCTION public.checkquotesiteprivs(integer, integer) OWNER TO admin; -- -- Name: checkrasiteprivs(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION checkrasiteprivs(integer) RETURNS boolean LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pRaheadid ALIAS FOR $1; _check BOOLEAN; _result INTEGER; BEGIN IF (NOT fetchMetricBool('MultiWhs')) THEN RETURN true; END IF; IF (NOT fetchUsrPrefBool('selectedSites')) THEN RETURN true; END IF; SELECT COALESCE(COUNT(*), 0) INTO _result FROM ( SELECT raitem_id FROM raitem, itemsite WHERE ( (raitem_rahead_id=pRaheadid) AND (raitem_itemsite_id=itemsite_id) AND (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) UNION SELECT raitem_id FROM raitem, itemsite WHERE ( (raitem_rahead_id=pRaheadid) AND (raitem_coitem_itemsite_id=itemsite_id) AND (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) ) AS data; IF (_result > 0) THEN RETURN false; END IF; RETURN true; END; $_$; ALTER FUNCTION public.checkrasiteprivs(integer) OWNER TO admin; -- -- Name: checkshipmentsiteprivs(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION checkshipmentsiteprivs(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipheadid ALIAS FOR $1; _check BOOLEAN; _result INTEGER; BEGIN IF (NOT fetchMetricBool('MultiWhs')) THEN RETURN true; END IF; IF (NOT fetchUsrPrefBool('selectedSites')) THEN RETURN true; END IF; SELECT COALESCE(COUNT(*), 0) INTO _result FROM ( SELECT coitem_id FROM shipitem, coitem, itemsite WHERE ( (shipitem_shiphead_id=pShipheadid) AND (coitem_id=shipitem_orderitem_id) AND (coitem_itemsite_id=itemsite_id) AND (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) UNION SELECT cohead_warehous_id FROM shipitem, coitem, cohead WHERE ( (shipitem_shiphead_id=pShipheadid) AND (coitem_id=shipitem_orderitem_id) AND (cohead_id=coitem_cohead_id) AND (cohead_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) ) AS data; IF (_result > 0) THEN RETURN false; END IF; RETURN true; END; $_$; ALTER FUNCTION public.checkshipmentsiteprivs(integer) OWNER TO admin; -- -- Name: checksositeprivs(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION checksositeprivs(integer) RETURNS boolean LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; _check BOOLEAN; _result INTEGER; BEGIN IF (NOT fetchMetricBool('MultiWhs')) THEN RETURN true; END IF; IF (NOT fetchUsrPrefBool('selectedSites')) THEN RETURN true; END IF; SELECT COALESCE(COUNT(*), 0) INTO _result FROM ( SELECT coitem_id FROM coitem, itemsite WHERE ( (coitem_cohead_id=pSoheadid) AND (coitem_itemsite_id=itemsite_id) AND (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) UNION SELECT cohead_warehous_id FROM cohead WHERE ( (cohead_id=pSoheadid) AND (cohead_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) ) AS data; IF (_result > 0) THEN RETURN false; END IF; RETURN true; END; $_$; ALTER FUNCTION public.checksositeprivs(integer) OWNER TO admin; -- -- Name: checkvouchersiteprivs(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION checkvouchersiteprivs(integer) RETURNS boolean LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVoheadid ALIAS FOR $1; _check BOOLEAN; _result INTEGER; BEGIN IF (NOT fetchMetricBool('MultiWhs')) THEN RETURN true; END IF; IF (NOT fetchUsrPrefBool('selectedSites')) THEN RETURN true; END IF; SELECT COALESCE(COUNT(*), 0) INTO _result FROM ( SELECT voitem_id FROM voitem, poitem, itemsite WHERE ( (voitem_vohead_id=pVoheadid) AND (poitem_id=voitem_poitem_id) AND (poitem_itemsite_id=itemsite_id) AND (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) UNION SELECT pohead_warehous_id FROM vohead, pohead WHERE ( (vohead_id=pVoheadid) AND (pohead_id=vohead_pohead_id) AND (pohead_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) ) AS data; IF (_result > 0) THEN RETURN false; END IF; RETURN true; END; $_$; ALTER FUNCTION public.checkvouchersiteprivs(integer) OWNER TO admin; -- -- Name: clearnumberissue(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION clearnumberissue(psequence text, pnumber integer) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE __seqiss seqiss[]; __newiss seqiss[] := ARRAY[]::seqiss[]; _i INTEGER; _result BOOLEAN := FALSE; _interval TEXT := fetchMetricText('NumberIssueResetIntervalDays') || ' day'; _number INTEGER; BEGIN -- get the sequence to update SELECT orderseq_seqiss INTO __seqiss FROM orderseq WHERE (orderseq_name=psequence); IF (NOT FOUND) THEN RAISE EXCEPTION 'Invalid orderseq_name %', psequence; END IF; IF(ARRAY_LENGTH(COALESCE(__seqiss,__newiss),1) IS NULL) THEN RETURN FALSE; END IF; -- build a new array sans the number we are releasing FOR _i IN 1..ARRAY_LENGTH(__seqiss,1) LOOP IF((__seqiss[_i]).seqiss_number = pnumber) THEN _result = TRUE; -- don't bother re-adding stale numbers ELSIF (now() - _interval::INTERVAL > (__seqiss[_i]).seqiss_time) THEN IF (_number IS NULL) THEN _number := (__seqiss[_i]).seqiss_number; ELSE _number := LEAST((__seqiss[_i]).seqiss_number, _number); END IF; ELSE __newiss := __newiss || __seqiss[_i]; END IF; END LOOP; -- update the order sequence with the result UPDATE orderseq SET orderseq_seqiss = __newiss WHERE (orderseq_name=psequence); -- reset to any cleared stale number IF(_number IS NOT NULL) THEN UPDATE orderseq SET orderseq_number = _number WHERE (orderseq_name=psequence); END IF; RETURN _result; END; $$; ALTER FUNCTION public.clearnumberissue(psequence text, pnumber integer) OWNER TO admin; -- -- Name: clearnumberissue(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION clearnumberissue(psequence text, pnumber text) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _castpnumber INTEGER; BEGIN -- for now, order numbers in the database are text but usually -- string representations of integers. allow for the occasional non-integer. BEGIN _castpnumber := CAST(pnumber AS INTEGER); EXCEPTION WHEN cannot_coerce OR invalid_text_representation OR numeric_value_out_of_range THEN RAISE DEBUG 'clearNumberIssue(%, %) received an unexpected pnumber', psequence, pnumber; RETURN FALSE; END; RETURN clearNumberIssue(psequence, _castpnumber); END; $$; ALTER FUNCTION public.clearnumberissue(psequence text, pnumber text) OWNER TO admin; -- -- Name: clearpayment(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION clearpayment(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pApselectid ALIAS FOR $1; BEGIN DELETE FROM apselect WHERE (apselect_id=pApselectid); RETURN 1; END; $_$; ALTER FUNCTION public.clearpayment(integer) OWNER TO admin; -- -- Name: closeaccountingperiod(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION closeaccountingperiod(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodid ALIAS FOR $1; _r RECORD; _nextPeriodid INTEGER; _trialbalid INTEGER; _ending NUMERIC; _currYear INTEGER; _nextYear INTEGER; BEGIN -- Bypass error checking is this the the initial period IF ( NOT ( SELECT period_initial FROM period WHERE (period_id=pPeriodid) ) ) THEN -- Check to make use that the period is not already closed IF ( ( SELECT period_closed FROM period WHERE (period_id=pPeriodid) ) ) THEN RETURN -1; END IF; -- Make sure that the day before this period belongs to another period SELECT prev.period_id AS periodid, prev.period_closed AS closed INTO _r FROM period AS prev, period AS curr WHERE ( (prev.period_end = (curr.period_start - 1)) AND (curr.period_id=pPeriodid) ); IF (NOT FOUND) THEN RETURN -2; END IF; -- Make sure that the previous period is closed IF (NOT _r.closed) THEN RETURN -3; END IF; END IF; -- Make sure that there the next period is defined SELECT next.period_id INTO _nextPeriodid FROM period AS next, period AS curr WHERE ( (next.period_start = (curr.period_end + 1)) AND (curr.period_id=pPeriodid) ); IF (NOT FOUND) THEN RETURN -4; END IF; -- Make sure that the user is not trying to prematurely close the Period IF ( ( SELECT (period_end >= CURRENT_DATE) FROM period WHERE (period_id=pPeriodid) ) ) THEN RETURN -5; END IF; SELECT yearperiod_id INTO _currYear FROM yearperiod, period WHERE ((period_end BETWEEN yearperiod_start and yearperiod_end) AND (period_id=pPeriodid)); IF (NOT FOUND) THEN _currYear := -1; END IF; SELECT yearperiod_id INTO _nextYear FROM yearperiod, period WHERE ((period_end BETWEEN yearperiod_start and yearperiod_end) AND (period_id=_nextPeriodid)); IF (NOT FOUND) THEN RETURN -6; END IF; -- Walk through the entire COA, calculating the ending balance and pushing -- it to the beginning balance for the next period FOR _r IN SELECT accnt_id, accnt_type IN ('E', 'R') AS revexp, trialbal_id, trialbal_beginning, trialbal_credits, trialbal_debits FROM accnt LEFT OUTER JOIN trialbal ON ( (trialbal_accnt_id=accnt_id) AND (trialbal_period_id=pPeriodid) ) ORDER BY accnt_id LOOP IF (_r.trialbal_id IS NULL) THEN _ending = 0; INSERT INTO trialbal ( trialbal_period_id, trialbal_accnt_id, trialbal_beginning, trialbal_ending, trialbal_dirty, trialbal_credits, trialbal_debits ) VALUES ( pPeriodid, _r.accnt_id, 0, 0, FALSE, 0, 0 ); ELSE _ending = (_r.trialbal_beginning - _r.trialbal_debits + _r.trialbal_credits); UPDATE trialbal SET trialbal_ending=_ending, trialbal_dirty = FALSE WHERE (trialbal_id=_r.trialbal_id); PERFORM forwardUpdateTrialBalance(_r.trialbal_id); END IF; IF (_r.revexp AND _currYear != _nextYear) THEN _ending := 0; END IF; -- Find the trialbal record for the next period SELECT trialbal_id INTO _trialbalid FROM trialbal WHERE ( (trialbal_period_id=_nextPeriodid) AND (trialbal_accnt_id=_r.accnt_id) ); IF (FOUND) THEN UPDATE trialbal SET trialbal_beginning = (_ending + trialbal_yearend), trialbal_ending = (_ending + trialbal_yearend - trialbal_debits + trialbal_credits) WHERE (trialbal_id=_trialbalid); ELSE INSERT INTO trialbal ( trialbal_period_id, trialbal_accnt_id, trialbal_beginning, trialbal_ending, trialbal_dirty, trialbal_credits, trialbal_debits ) VALUES(_nextPeriodid, _r.accnt_id, _ending, _ending, TRUE, 0, 0 ); END IF; END LOOP; -- Set the period_closed flag UPDATE period SET period_closed=TRUE WHERE (period_id=pPeriodid); RETURN pPeriodid; END; $_$; ALTER FUNCTION public.closeaccountingperiod(integer) OWNER TO admin; -- -- Name: closeaccountingyearperiod(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION closeaccountingyearperiod(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pYearPeriodid ALIAS FOR $1; _result INTEGER; BEGIN -- Check to make sure that the yearperiod is not already closed IF ( ( SELECT yearperiod_closed FROM yearperiod WHERE (yearperiod_id=pYearPeriodid) ) ) THEN RETURN -1; END IF; IF ( ( SELECT (count(period_id) > 0) FROM period WHERE ((period_yearperiod_id=pYearPeriodid) AND (NOT period_closed)) ) ) THEN RETURN -10; END IF; IF ( ( SELECT (count(yearperiod_id) > 0) FROM yearperiod WHERE ((yearperiod_end< ( SELECT yearperiod_end FROM yearperiod WHERE (yearperiod_id=pYearPeriodId)) ) AND (NOT yearperiod_closed)) ) ) THEN RETURN -11; END IF; -- Should we check for a previous yearperiod existing already ? -- If so then we should return -2 if one does not. -- If we did the previous yearperiod we should check to make sure that -- it is also closed. Returning -3 if it is not. -- Make sure that the user is not trying to prematurely close the YearPeriod IF ( ( SELECT (yearperiod_end >= CURRENT_DATE) FROM yearperiod WHERE (yearperiod_id=pYearPeriodid) ) ) THEN RETURN -5; END IF; -- Update the year end Retained Earnings SELECT updateRetainedEarnings(pYearPeriodid) INTO _result; IF (_result < 0) THEN RETURN _result; END IF; UPDATE yearperiod SET yearperiod_closed = TRUE WHERE yearperiod_id = pYearPeriodid; RETURN 0; END; $_$; ALTER FUNCTION public.closeaccountingyearperiod(integer) OWNER TO admin; -- -- Name: closepo(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION closepo(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPoheadid ALIAS FOR $1; BEGIN UPDATE poitem SET poitem_status='C' WHERE (poitem_pohead_id=pPoheadid); -- _poitemTrigger will close pohead when the last poitem is closed -- UPDATE pohead -- SET pohead_status='C' -- WHERE (pohead_id=pPoheadid); RETURN 1; END; $_$; ALTER FUNCTION public.closepo(integer) OWNER TO admin; -- -- Name: closewo(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION closewo(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pPostMaterialVariances ALIAS FOR $2; BEGIN RETURN closeWo(pWoid, pPostMaterialVariances, CURRENT_DATE); END; $_$; ALTER FUNCTION public.closewo(integer, boolean) OWNER TO admin; -- -- Name: closewo(integer, boolean, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION closewo(integer, boolean, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pPostMaterialVariances ALIAS FOR $2; pTransDate ALIAS FOR $3; _woNumber TEXT; _check CHAR; _itemlocSeries INTEGER := 0; BEGIN --Comment this out --In addition to IssueToShipping driving PostProduction, --not PostProduction can drive IssueToShipping. --Must allow closing of Job items --If this is item type Job then we cannot close here --SELECT itemsite_costmethod INTO _check --FROM wo,itemsite --WHERE ((wo_id=pWoid) --AND (wo_itemsite_id=itemsite_id) --AND (itemsite_costmethod = 'J')); --IF (FOUND) THEN -- RAISE EXCEPTION 'Work orders for Job items are closed when all quantities are shipped'; --END IF; SELECT formatWoNumber(pWoid) INTO _woNumber; -- If there are any tools issued on this job then we cannot close here IF ( SELECT (count(*) > 0) FROM womatl JOIN itemsite ON (womatl_itemsite_id=itemsite_id) JOIN item ON ((itemsite_item_id=item_id) AND (item_type='T')) WHERE ((womatl_wo_id=pWoid) AND (womatl_qtyiss > 0)) ) THEN RAISE EXCEPTION 'All Tools must be returned before the W/O can be closed'; END IF; -- Distribute any remaining wo_wipvalue to G/L - debit Inventory Cost, credit WIP PERFORM insertGLTransaction( 'W/O', 'WO', _woNumber, ('Manufacturing Inventory Cost Variance for ' || item_number), getPrjAccntId(wo_prj_id, costcat_wip_accnt_id), getPrjAccntId(wo_prj_id, costcat_invcost_accnt_id), -1, COALESCE(wo_wipvalue, 0), pTransDate ) FROM wo, itemsite, item, costcat WHERE ( (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (itemsite_costcat_id=costcat_id) AND (wo_id=pWoid) ); -- Distribute any remaining wo_brdvalue to G/L - debit Inventory Cost, credit WIP PERFORM insertGLTransaction( 'W/O', 'WO', _woNumber, ('Breeder Inventory Cost Variance for ' || item_number), getPrjAccntId(wo_prj_id, costcat_wip_accnt_id), CASE WHEN(itemsite_costmethod='A') THEN costcat_asset_accnt_id ELSE getPrjAccntId(wo_prj_id, costcat_invcost_accnt_id) END, -1, COALESCE(wo_brdvalue, 0), pTransDate ) FROM wo, itemsite, item, costcat WHERE ( (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (itemsite_costcat_id=costcat_id) AND (wo_id=pWoid) ); -- Don't bother with posting variances if the qtyrcv is 0 as -- they are meaningless. IF ( ( SELECT wo_qtyrcv FROM wo WHERE (wo_id=pWoid) ) > 0 ) THEN IF (pPostMaterialVariances) THEN -- Post womatl variances INSERT INTO womatlvar ( womatlvar_number, womatlvar_subnumber, womatlvar_posted, womatlvar_parent_itemsite_id, womatlvar_component_itemsite_id, womatlvar_qtyord, womatlvar_qtyrcv, womatlvar_qtyiss, womatlvar_qtyfxd, womatlvar_qtyper, womatlvar_scrap, womatlvar_wipscrap, womatlvar_bomitem_id, womatlvar_notes, womatlvar_ref ) SELECT wo_number, wo_subnumber, pTransDate, wo_itemsite_id, womatl_itemsite_id, wo_qtyord, wo_qtyrcv, itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyiss), itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyfxd), itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyper), womatl_scrap, itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtywipscrap), womatl_bomitem_id, womatl_notes, womatl_ref FROM wo, womatl, itemsite, item WHERE ((womatl_wo_id=wo_id) AND (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_type <> 'T') AND (wo_id=pWoid)); END IF; END IF; -- Delete any P/R's created for this W/O PERFORM deletePr('W', womatl_id) FROM womatl WHERE (womatl_wo_id=pWoid); UPDATE wo SET wo_wipvalue = 0, wo_brdvalue=0, wo_status='C' WHERE (wo_id=pWoid); RETURN 1; END; $_$; ALTER FUNCTION public.closewo(integer, boolean, date) OWNER TO admin; -- -- Name: cntct; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cntct ( cntct_id integer NOT NULL, cntct_crmacct_id integer, cntct_addr_id integer, cntct_first_name text, cntct_last_name text, cntct_honorific text, cntct_initials text, cntct_active boolean DEFAULT true, cntct_phone text, cntct_phone2 text, cntct_fax text, cntct_email text, cntct_webaddr text, cntct_notes text, cntct_title text, cntct_number text NOT NULL, cntct_middle text, cntct_suffix text, cntct_owner_username text, cntct_name text ); ALTER TABLE cntct OWNER TO admin; -- -- Name: TABLE cntct; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE cntct IS 'Contact - information on how to reach a living person'; -- -- Name: cntct(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION cntct() RETURNS SETOF cntct LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row cntct%ROWTYPE; _priv TEXT; _grant BOOLEAN; BEGIN -- This query will give us the most permissive privilege the user has been granted SELECT privilege, granted INTO _priv, _grant FROM privgranted WHERE privilege IN ('MaintainAllContacts','ViewAllContacts','MaintainPersonalContacts','ViewPersonalContacts') ORDER BY granted DESC, sequence LIMIT 1; -- If have an 'All' privilege return all results IF (_priv ~ 'All' AND _grant) THEN FOR _row IN SELECT * FROM cntct LOOP RETURN NEXT _row; END LOOP; -- Otherwise if have any other grant, must be personal privilege. ELSIF (_grant) THEN FOR _row IN SELECT * FROM cntct WHERE cntct_owner_username = getEffectiveXtUser() LOOP RETURN NEXT _row; END LOOP; END IF; RETURN; END; $$; ALTER FUNCTION public.cntct() OWNER TO admin; -- -- Name: FUNCTION cntct(); Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON FUNCTION cntct() IS 'A table function that returns Contact results according to privilege settings.'; -- -- Name: cntctdups(text, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION cntctdups(text, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS SETOF cntctdup LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSearchText ALIAS FOR $1; pSearchContactName ALIAS FOR $2; pSearchPhone ALIAS FOR $3; pSearchEmail ALIAS FOR $4; pSearchNumber ALIAS FOR $5; pSearchName ALIAS FOR $6; pShowInactive ALIAS FOR $7; pIgnoreBlanks ALIAS FOR $8; pIndentedDups ALIAS FOR $9; pCheckHnfc ALIAS FOR $10; pCheckFirst ALIAS FOR $11; pCheckMiddle ALIAS FOR $12; pCheckLast ALIAS FOR $13; pCheckSuffix ALIAS FOR $14; pCheckPhone ALIAS FOR $15; pCheckEmail ALIAS FOR $16; _cntct cntctdup%ROWTYPE; _cntctdup cntctdup%ROWTYPE; _rec RECORD; _operator TEXT := ''; _clause TEXT; _qry TEXT := ''; _return BOOLEAN := true; _text TEXT; _first BOOLEAN := true; BEGIN -- Validate IF (pIndentedDups AND NOT pCheckHnfc AND NOT pCheckFirst AND NOT pCheckMiddle AND NOT pCheckLast AND NOT pCheckSuffix AND NOT pCheckEmail AND NOT pCheckPhone) THEN RETURN; END IF; _text = quote_literal(pSearchText); IF (pIndentedDups) THEN _qry := 'SELECT -1 AS cntct_id, -1 AS cntct_crmacct_id, -1 AS cntct_addr_id,'; IF (NOT pCheckFirst) THEN _qry := _qry || ''''' AS '; END IF; _qry := _qry || ' cntct_first_name,'; IF (NOT pCheckLast) THEN _qry := _qry || ''''' AS '; END IF; _qry := _qry || ' cntct_last_name,'; IF (NOT pCheckHnfc) THEN _qry := _qry || ''''' AS '; END IF; _qry := _qry || ' cntct_honorific,'; _qry := _qry || ' '''' AS cntct_initials,'; _qry := _qry || ' NULL AS cntct_active,'; IF (NOT pCheckPhone) THEN _qry := _qry || ''''' AS '; END IF; _qry := _qry || ' cntct_phone,'; IF (NOT pCheckPhone) THEN _qry := _qry || ''''' AS '; END IF; _qry := _qry || ' cntct_phone2,'; _qry := _qry || ' '''' AS cntct_fax,'; IF (NOT pCheckEmail) THEN _qry := _qry || ''''' AS '; END IF; _qry := _qry || ' cntct_email,'; _qry := _qry || ' '''' AS cntct_webaddr,'; _qry := _qry || ' '''' AS cntct_notes,'; _qry := _qry || ' '''' AS cntct_title,'; _qry := _qry || ' '''' AS cntct_number,'; IF (NOT pCheckMiddle) THEN _qry := _qry || ''''' AS '; END IF; _qry := _qry || ' cntct_middle,'; IF (NOT pCheckSuffix) THEN _qry := _qry || ''''' AS '; END IF; _qry := _qry || ' cntct_suffix,'; _qry := _qry || ' '''' AS cntct_owner_username,'; _qry := _qry || ' '''' AS cntct_name,'; _qry := _qry || ' '''' AS crmacct_number, '; _qry := _qry || ' '''' AS crmacct_name, '; _qry := _qry || ' NULL AS addr_id, NULL AS addr_active, '''' AS addr_line1, '''' AS addr_line2, '''' AS addr_line3, '''' AS addr_city, '''' AS addr_state, '''' AS addr_postalcode, '''' AS addr_country, '''' AS addr_notes, '''' AS addr_number, cntctdup_level FROM ('; END IF; _clause := 'SELECT cntct_id, cntct_crmacct_id, cntct_addr_id, UPPER(cntct_first_name) AS cntct_first_name, UPPER(cntct_last_name) AS cntct_last_name, UPPER(cntct_honorific) AS cntct_honorific, cntct_initials, cntct_active, cntct_phone, cntct_phone2, cntct_fax, UPPER(cntct_email) AS cntct_email, cntct_webaddr, cntct_notes, cntct_title, cntct_number, UPPER(cntct_middle) AS cntct_middle, UPPER(cntct_suffix) AS cntct_suffix, cntct_owner_username, cntct_name, crmacct_number, crmacct_name, addr_id, addr_active, addr_line1, addr_line2, addr_line3, addr_city, addr_state, addr_postalcode, addr_country, addr_notes, addr_number, 0 AS cntctdup_level FROM cntct() LEFT OUTER JOIN crmacct ON (cntct_crmacct_id=crmacct_id) LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) WHERE '; IF (NOT pIndentedDups) THEN WHILE position('UPPER' in _clause) > 0 LOOP _clause := regexp_replace(_clause, 'UPPER', ''); END LOOP; END IF; _qry := _qry || _clause; IF (NOT pShowInactive) THEN _qry := _qry || ' cntct_active AND '; END IF; IF (pIgnoreBlanks) THEN _qry := _qry || ' (COALESCE(LENGTH(cntct_first_name || cntct_last_name),0) > 0) AND '; END IF; _qry := _qry || '(false '; IF (pSearchNumber) THEN _qry := _qry || ' OR (crmacct_number ~* ' || quote_literal(pSearchText) || ') '; END IF; IF (pSearchName) THEN _qry := _qry || ' OR (crmacct_name ~* ' || quote_literal(pSearchText) || ') '; END IF; IF (pSearchContactName) THEN _qry := _qry || ' OR (cntct_first_name || '' '' || cntct_last_name ~* ' || quote_literal(pSearchText) || ') '; END IF; IF (pSearchPhone) THEN _qry := _qry || ' OR (cntct_phone || '' '' || cntct_phone2 || '' '' || cntct_fax ~* ' || quote_literal(pSearchText) || ') '; END IF; IF (pSearchEmail) THEN _qry := _qry || ' OR (cntct_email ~* ' || quote_literal(pSearchText) || ') '; END IF; _qry := _qry || ' ) '; IF (pIndentedDups) THEN _qry := _qry || ') data'; _clause := ' GROUP BY cntctdup_level'; IF (pCheckHnfc) THEN _clause := _clause || ',cntct_honorific'; END IF; IF (pCheckFirst) THEN _clause := _clause || ',cntct_first_name'; END IF; IF (pCheckMiddle) THEN _clause := _clause || ',cntct_middle'; END IF; IF (pCheckLast) THEN _clause := _clause || ',cntct_last_name'; END IF; IF (pCheckSuffix) THEN _clause := _clause || ',cntct_suffix'; END IF; IF (pCheckEmail) THEN _clause := _clause || ',cntct_email'; END IF; IF (pCheckPhone) THEN _clause := _clause || ',cntct_phone'; _clause := _clause || ',cntct_phone2'; END IF; _qry := _qry || _clause; _clause := ' HAVING('; IF (pCheckHnfc) THEN _clause := _clause || 'OR COUNT(cntct_honorific) > 1 '; END IF; IF (pCheckFirst) THEN _clause := _clause || 'OR COUNT(cntct_first_name) > 1 '; END IF; IF (pCheckMiddle) THEN _clause := _clause || 'OR COUNT(cntct_middle) > 1 '; END IF; IF (pCheckLast) THEN _clause := _clause || 'OR COUNT(cntct_last_name) > 1 '; END IF; IF (pCheckSuffix) THEN _clause := _clause || 'OR COUNT(cntct_suffix) > 1 '; END IF; IF (pCheckEmail) THEN _clause := _clause || 'OR COUNT(cntct_email) > 1 '; END IF; IF (pCheckPhone) THEN _clause := _clause || 'OR (COUNT(cntct_phone) > 1 AND LENGTH(cntct_phone) > 0) '; _clause := _clause || 'OR (COUNT(cntct_phone2) > 1 AND LENGTH(cntct_phone2) > 0) '; END IF; _clause := _clause || ') '; _clause := overlay(_clause placing '' from 9 for 2); IF (pCheckHnfc) THEN _clause := _clause || 'AND LENGTH(cntct_honorific) > 0 '; END IF; IF (pCheckFirst) THEN _clause := _clause || 'AND LENGTH(cntct_first_name) > 0 '; END IF; IF (pCheckMiddle) THEN _clause := _clause || 'AND LENGTH(cntct_middle) > 0 '; END IF; IF (pCheckLast) THEN _clause := _clause || 'AND LENGTH(cntct_last_name) > 0 '; END IF; IF (pCheckSuffix) THEN _clause := _clause || 'AND LENGTH(cntct_suffix) > 0 '; END IF; IF (pCheckEmail) THEN _clause := _clause || 'AND LENGTH(cntct_email) > 0 '; END IF; _qry := _qry || _clause; END IF; _qry := _qry || ' ORDER BY cntct_last_name, cntct_first_name;'; -- raise exception '%',_qry; FOR _cntct IN EXECUTE _qry LOOP RETURN NEXT _cntct; -- If duplicates, get duplicates IF (pIndentedDups) THEN _qry := 'SELECT cntct.*, crmacct_number, crmacct_name, addr.*, 1 AS cntctdup_level FROM cntct() LEFT OUTER JOIN crmacct ON (cntct_crmacct_id=crmacct_id) LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) WHERE (true) '; IF (pCheckHnfc) THEN _qry := _qry || ' AND (UPPER(cntct_honorific)=' || quote_literal(_cntct.cntct_honorific) || ')'; END IF; IF (pCheckFirst) THEN _qry := _qry || ' AND (UPPER(cntct_first_name)=' || quote_literal(_cntct.cntct_first_name) || ')'; END IF; IF (pCheckMiddle) THEN _qry := _qry || ' AND (UPPER(cntct_middle)=' || quote_literal(_cntct.cntct_middle) || ')'; END IF; IF (pCheckLast) THEN _qry := _qry || ' AND (UPPER(cntct_last_name)=' || quote_literal(_cntct.cntct_last_name) || ')'; END IF; IF (pCheckSuffix) THEN _qry := _qry || ' AND (UPPER(cntct_suffix)=' || quote_literal(_cntct.cntct_suffix) || ')'; END IF; IF (pCheckPhone) THEN _qry := _qry || ' AND (cntct_phone=' || quote_literal(_cntct.cntct_phone) || ')'; END IF; IF (pCheckEmail) THEN _qry := _qry || ' AND (UPPER(cntct_email)=' || quote_literal(_cntct.cntct_email) || ')'; END IF; -- raise exception '%',_qry; FOR _cntctdup IN EXECUTE _qry LOOP RETURN NEXT _cntctdup; END LOOP; END IF; END LOOP; RETURN; END; $_$; ALTER FUNCTION public.cntctdups(text, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) OWNER TO admin; -- -- Name: cntctmerge(integer, integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION cntctmerge(integer, integer, boolean) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSourceCntctId ALIAS FOR $1; pTargetCntctId ALIAS FOR $2; pPurge ALIAS FOR $3; _fk RECORD; _pk RECORD; _sel RECORD; _seq INTEGER; _col TEXT; _pkcol TEXT; _qry TEXT; _multi BOOLEAN; BEGIN -- Validate IF (pSourceCntctId IS NULL) THEN RAISE EXCEPTION 'Source contact id can not be null'; ELSIF (pTargetCntctId IS NULL) THEN RAISE EXCEPTION 'Target contact id can not be null'; ELSIF (pPurge IS NULL) THEN RAISE EXCEPTION 'Purge flag can not be null'; END IF; -- Determine where this contact is used by analyzing foreign key linkages and update each FOR _fk IN SELECT pg_namespace.nspname AS schemaname, con.relname AS tablename, conkey AS seq, conrelid AS class_id FROM pg_constraint, pg_class f, pg_class con, pg_namespace WHERE confrelid=f.oid AND conrelid=con.oid AND f.relname = 'cntct' AND con.relnamespace=pg_namespace.oid AND con.relname NOT IN ('cntctsel', 'cntctmrgd', 'mrghist','trgthist') LOOP -- Validate IF (ARRAY_UPPER(_fk.seq,1) > 1) THEN RAISE EXCEPTION 'Updates to tables where the contact is one of multiple foreign key columns is not supported. Error on Table: %', pg_namespace.nspname || '.' || con.relname; END IF; _seq := _fk.seq[1]; -- Get the specific column name SELECT attname INTO _col FROM pg_attribute, pg_class WHERE ((attrelid=pg_class.oid) AND (pg_class.oid=_fk.class_id) AND (attnum=_seq)); IF (NOT pPurge) THEN -- Cache what we're going to do so we can restore if need be. -- Start by determining the primary key column for this table. _multi := false; _qry := 'SELECT pg_attribute.attname AS key FROM pg_attribute, pg_class WHERE pg_class.relnamespace = ( SELECT oid FROM pg_namespace WHERE pg_namespace.nspname = ''' || _fk.schemaname || ''') AND pg_class.oid IN ( SELECT indexrelid FROM pg_index WHERE indisprimary = true AND indrelid IN ( SELECT oid FROM pg_class WHERE lower(relname) = ''' || _fk.tablename || ''')) AND pg_attribute.attrelid = pg_class.oid AND pg_attribute.attisdropped = false ORDER BY pg_attribute.attnum;'; FOR _pk IN EXECUTE _qry LOOP IF (_multi) THEN RAISE EXCEPTION 'Reference tables with composite primary keys not supported. Try the merge and purge option.'; END IF; _pkcol := _pk.key; _multi := true; END LOOP; -- Gather and store the history _qry := 'INSERT INTO mrghist SELECT ' || pSourceCntctId || ', ''' || _fk.schemaname || '.' || _fk.tablename || ''', ''' || _pkcol || ''', ' || _pkcol || ', ''' || _col || ''' FROM ' || _fk.schemaname || '.' || _fk.tablename || ' WHERE (' || _col || '=' || pSourceCntctId || ');'; -- raise exception '%',_qry; EXECUTE _qry; END IF; -- Merge references _qry := 'UPDATE ' || _fk.schemaname || '.' || _fk.tablename || ' SET ' || _col || '=' || pTargetCntctId || ' WHERE (' || _col || '=' || pSourceCntctId || ');'; EXECUTE _qry; END LOOP; -- Merge cases with no foreign key IF (NOT pPurge) THEN INSERT INTO mrghist SELECT pSourceCntctId, 'comment', 'comment_id', comment_id, 'comment_source_id' FROM comment WHERE ((comment_source_id= pSourceCntctId) AND (comment_source='T')); INSERT INTO mrghist SELECT pSourceCntctId, 'docass', 'docass_id', docass_id, 'docass_source_id' FROM docass WHERE ((docass_source_id= pSourceCntctId) AND (docass_source_type='T')); INSERT INTO mrghist SELECT pSourceCntctId, 'docass', 'docass_id', docass_id, 'docass_target_id' FROM docass WHERE ((docass_target_id= pSourceCntctId) AND (docass_target_type='T')); INSERT INTO mrghist SELECT pSourceCntctId, 'vendinfo', 'vend_id', vend_id, 'vend_cntct1_id' FROM vendinfo WHERE (vend_cntct1_id=pSourceCntctId); INSERT INTO mrghist SELECT pSourceCntctId, 'vendinfo', 'vend_id', vend_id, 'vend_cntct2_id' FROM vendinfo WHERE (vend_cntct2_id=pSourceCntctId); IF (fetchMetricBool('EnableBatchManager') AND packageIsEnabled('xtbatch')) THEN INSERT INTO mrghist SELECT pSourceCntctId, 'xtbatch.emlassc', 'emlassc_id', emlassc_id, 'emlassc_assc_id' FROM xtbatch.emlassc WHERE ((emlassc_assc_id= pSourceCntctId) AND (emlassc_type='T')); END IF; END IF; UPDATE comment SET comment_source_id = pTargetCntctId WHERE ((comment_source = 'T') AND (comment_source_id = pSourceCntctId)); UPDATE docass SET docass_source_id = pTargetCntctId WHERE ((docass_source_type = 'T') AND (docass_source_id = pSourceCntctId)); UPDATE docass SET docass_target_id = pTargetCntctId WHERE ((docass_target_type = 'T') AND (docass_target_id = pSourceCntctId)); UPDATE vendinfo SET vend_cntct1_id = pTargetCntctId WHERE (vend_cntct1_id = pSourceCntctId); UPDATE vendinfo SET vend_cntct2_id = pTargetCntctId WHERE (vend_cntct2_id = pSourceCntctId); IF (fetchMetricBool('EnableBatchManager') AND packageIsEnabled('xtbatch')) THEN UPDATE xtbatch.emlassc SET emlassc_assc_id = pTargetCntctId WHERE ((emlassc_type = 'T') AND (emlassc_assc_id = pSourceCntctId)); END IF; IF (NOT pPurge) THEN -- Record that this has been merged if not already IF (SELECT (COUNT(cntctmrgd_cntct_id) = 0) FROM cntctmrgd WHERE (cntctmrgd_cntct_id=pSourceCntctId)) THEN INSERT INTO cntctmrgd (cntctmrgd_cntct_id, cntctmrgd_error) VALUES (pSourceCntctId,false); END IF; END IF; -- Merge field detail to target SELECT * INTO _sel FROM cntctsel JOIN cntct ON (cntctsel_cntct_id=cntct_id) WHERE (cntctsel_cntct_id=pSourceCntctId); IF (FOUND) THEN IF (_sel.cntctsel_mrg_crmacct_id) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_crmacct_id', cntct_crmacct_id::text || '::integer' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_crmacct_id=_sel.cntct_crmacct_id WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_addr_id) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_addr_id', cntct_addr_id::text || '::integer' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_addr_id=_sel.cntct_addr_id WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_first_name) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_first_name', '''' || cntct_first_name || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_first_name=_sel.cntct_first_name WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_last_name) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_last_name', '''' || cntct_last_name || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_last_name=_sel.cntct_last_name WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_honorific) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_honorific', '''' || cntct_honorific || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_honorific=_sel.cntct_honorific WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_initials) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_initials', '''' || cntct_initials || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_initials=_sel.cntct_initials WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_phone) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_phone', '''' || cntct_phone || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_phone=_sel.cntct_phone WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_phone2) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_phone2', '''' || cntct_phone2 || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_phone2=_sel.cntct_phone2 WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_fax) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_fax', '''' || cntct_fax || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_fax=_sel.cntct_fax WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_email) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_email', '''' || cntct_email || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_email=_sel.cntct_email WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_webaddr) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_webaddr', '''' || cntct_webaddr || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_webaddr=_sel.cntct_webaddr WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_notes) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_notes', '''' || cntct_notes || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_notes=cntct_notes || ' ' || _sel.cntct_notes WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_title) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_title', '''' || cntct_title || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_title=_sel.cntct_title WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_middle) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_middle', '''' || cntct_middle || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_middle=_sel.cntct_middle WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_suffix) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_suffix', '''' || cntct_suffix || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_suffix=_sel.cntct_suffix WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_owner_username) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_owner_username', '''' || cntct_owner_username || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_owner_username=_sel.cntct_owner_username WHERE (cntct_id=pTargetCntctId); END IF; ELSE RAISE EXCEPTION 'Source Contact not Found'; END IF; -- Disposition source contact IF (pPurge) THEN DELETE FROM cntct WHERE cntct_id = pSourceCntctId; END IF; -- Deactivate contact UPDATE cntct SET cntct_active = false WHERE (cntct_id=pSourceCntctId); -- Clean up DELETE FROM cntctsel WHERE (cntctsel_cntct_id=pSourceCntctId); RETURN true; END; $_$; ALTER FUNCTION public.cntctmerge(integer, integer, boolean) OWNER TO admin; -- -- Name: cntctrestore(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION cntctrestore(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCntctId ALIAS FOR $1; _r RECORD; _qry TEXT; BEGIN -- Validate SELECT * INTO _r FROM cntctmrgd WHERE (cntctmrgd_cntct_id=pCntctId); IF (NOT FOUND) THEN RETURN false; END IF; -- Gather the list of affected records FOR _r IN SELECT * FROM mrghist WHERE (mrghist_cntct_id=pCntctId) LOOP -- Restore the old references _qry := 'UPDATE ' || _r.mrghist_table || ' SET ' || _r.mrghist_cntct_col || '=' || pCntctId || ' WHERE (' || _r.mrghist_pkey_col || '=' || _r.mrghist_pkey_id || ');'; EXECUTE _qry; END LOOP; -- Gather the list of affected fields FOR _r IN SELECT * FROM trgthist WHERE (trgthist_src_cntct_id=pCntctId) LOOP -- Restore the old values _qry := 'UPDATE cntct SET ' || _r.trgthist_col || '=' || _r.trgthist_value || ' WHERE (cntct_id=' || _r.trgthist_trgt_cntct_id || ');'; EXECUTE _qry; END LOOP; -- Clean up UPDATE cntct SET cntct_active=true WHERE (cntct_id=pCntctId); DELETE FROM mrghist WHERE (mrghist_cntct_id=pCntctId); DELETE FROM trgthist WHERE (trgthist_src_cntct_id=pCntctId); DELETE FROM cntctmrgd WHERE (cntctmrgd_cntct_id=pCntctId); RETURN true; END; $_$; ALTER FUNCTION public.cntctrestore(integer) OWNER TO admin; -- -- Name: cntctselect(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION cntctselect(integer, boolean) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCntctId ALIAS FOR $1; pTarget ALIAS FOR $2; BEGIN -- If target, delete any other targets IF (pTarget) THEN DELETE FROM cntctsel WHERE cntctsel_target; END IF; -- Delete any previous selection of this contact DELETE FROM cntctsel WHERE cntctsel_cntct_id=pCntctId; -- Add this contact in appropriate selection state INSERT INTO cntctsel (cntctsel_cntct_id, cntctsel_target) VALUES (pCntctId,pTarget); RETURN true; END; $_$; ALTER FUNCTION public.cntctselect(integer, boolean) OWNER TO admin; -- -- Name: cntctselectcol(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION cntctselectcol(integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCntctId ALIAS FOR $1; pColNumber ALIAS FOR $2; BEGIN IF (pColNumber = 2 OR pColNumber = 3) THEN UPDATE cntctsel SET cntctsel_mrg_crmacct_id=false WHERE (cntctsel_mrg_crmacct_id AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_crmacct_id=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 4) THEN UPDATE cntctsel SET cntctsel_mrg_honorific=false WHERE (cntctsel_mrg_honorific AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_honorific=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 5) THEN UPDATE cntctsel SET cntctsel_mrg_first_name=false WHERE (cntctsel_mrg_first_name AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_first_name=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 6) THEN UPDATE cntctsel SET cntctsel_mrg_middle=false WHERE (cntctsel_mrg_middle AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_middle=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 7) THEN UPDATE cntctsel SET cntctsel_mrg_last_name=false WHERE (cntctsel_mrg_last_name AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_last_name=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 8) THEN UPDATE cntctsel SET cntctsel_mrg_suffix=false WHERE (cntctsel_mrg_suffix AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_suffix=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 9) THEN UPDATE cntctsel SET cntctsel_mrg_initials=false WHERE (cntctsel_mrg_initials AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_initials=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 10) THEN UPDATE cntctsel SET cntctsel_mrg_phone=false WHERE (cntctsel_mrg_phone AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_phone=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 11) THEN UPDATE cntctsel SET cntctsel_mrg_phone2=false WHERE (cntctsel_mrg_phone2 AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_phone2=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 12) THEN UPDATE cntctsel SET cntctsel_mrg_fax=false WHERE (cntctsel_mrg_fax AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_fax=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 13) THEN UPDATE cntctsel SET cntctsel_mrg_email=false WHERE (cntctsel_mrg_email AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_email=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 14) THEN UPDATE cntctsel SET cntctsel_mrg_webaddr=false WHERE (cntctsel_mrg_webaddr AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_webaddr=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 15) THEN UPDATE cntctsel SET cntctsel_mrg_title=false WHERE (cntctsel_mrg_title AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_title=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 16) THEN UPDATE cntctsel SET cntctsel_mrg_owner_username=false WHERE (cntctsel_mrg_owner_username AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_owner_username=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 17) THEN UPDATE cntctsel SET cntctsel_mrg_notes=false WHERE (cntctsel_mrg_notes AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_notes=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber >= 18) THEN UPDATE cntctsel SET cntctsel_mrg_addr_id=false WHERE (cntctsel_mrg_addr_id AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_addr_id=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; END IF; RETURN false; END; $_$; ALTER FUNCTION public.cntctselectcol(integer, integer) OWNER TO admin; -- -- Name: cntctused(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION cntctused(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCntctId ALIAS FOR $1; _fk RECORD; _r RECORD; _seq INTEGER; _col TEXT; _qry TEXT; BEGIN -- Determine where this contact is used by analyzing foreign key linkages -- but ignore child tables and those with impermanent relationships FOR _fk IN SELECT pg_namespace.nspname AS schemaname, con.relname AS tablename, conkey AS seq, conrelid AS class_id FROM pg_constraint, pg_class f, pg_class con, pg_namespace WHERE confrelid=f.oid AND conrelid=con.oid AND f.relname = 'cntct' AND con.relnamespace=pg_namespace.oid AND con.relname NOT IN ('cntctaddr', 'cntctdata', 'cntcteml', 'cohead', 'pohead', 'quhead', 'tohead', 'cntctsel', 'cntctmrgd', 'mrghist', 'trgthist') LOOP -- Validate IF (ARRAY_UPPER(_fk.seq,1) > 1) THEN RAISE EXCEPTION 'Cannot check dependencies when the contact is one of multiple foreign key columns (%.%) [xtuple: fkeycheck, -1, %, %]', _fk.nspname, _fk.relname, _fk.nspname, _fk.relname; END IF; _seq := _fk.seq[1]; -- Get the specific column name SELECT attname INTO _col FROM pg_attribute, pg_class WHERE ((attrelid=pg_class.oid) AND (pg_class.oid=_fk.class_id) AND (attnum=_seq)); -- See if there are dependencies _qry := 'SELECT * FROM ' || _fk.schemaname || '.' || _fk.tablename || ' WHERE ('|| _col || '=' || pCntctId || ');'; FOR _r IN EXECUTE _qry LOOP RETURN true; END LOOP; END LOOP; RETURN false; END; $_$; ALTER FUNCTION public.cntctused(integer) OWNER TO admin; -- -- Name: coheadstatecolor(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION coheadstatecolor(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCoheadId ALIAS FOR $1; _shipheadid INTEGER; _result TEXT := ''; BEGIN IF (pCoheadid IS NULL) THEN RAISE EXCEPTION 'Customer Id is required.'; END IF; SELECT shiphead_id INTO _shipheadid FROM cohead JOIN shiphead ON ((shiphead_order_id=cohead_id) AND (shiphead_order_type='SO')) JOIN shipitem ON (shiphead_id=shipitem_shiphead_id) WHERE ((cohead_id=pCoheadId) AND (NOT shipitem_invoiced)) ORDER BY shiphead_id DESC LIMIT 1; IF (FOUND) THEN SELECT CASE WHEN ((shiphead_shipped) AND (COALESCE(shiphead_order_id,0) > 0) AND (SUM(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned)) <= 0)) THEN 'altemphasis' WHEN ((COALESCE(cobmisc_cohead_id,0) > 0) AND (SUM(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned)) > 0)) THEN 'error' WHEN (NOT shiphead_shipped) THEN 'emphasis' END INTO _result FROM cohead JOIN coitem ON (cohead_id=coitem_cohead_id) JOIN shiphead ON ((shiphead_order_id=cohead_id) AND (shiphead_order_type='SO')) JOIN shipitem ON (shiphead_id=shipitem_shiphead_id) LEFT OUTER JOIN (SELECT DISTINCT cobmisc_cohead_id FROM cobmisc) AS cobmisc ON (cobmisc_cohead_id=cohead_id) WHERE (shiphead_id=_shipheadid) GROUP BY shiphead_id,shiphead_shipped,shiphead_order_id,cobmisc_cohead_id ORDER BY shiphead_id DESC; ELSE _result := ''; END IF; RETURN _result; END; $_$; ALTER FUNCTION public.coheadstatecolor(integer) OWNER TO admin; -- -- Name: compareversion(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION compareversion(pleft text, pright text DEFAULT split_part(version(), ' '::text, 2)) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- Returns 1 if the left version is greater than the right version -- -1 if the right is greater than the left -- 0 if the versions are equal. -- parameter two defaults to current server version DECLARE _left SMALLINT[] := _normalizeVersion(pLeft); _right SMALLINT[] := _normalizeVersion(pRight); _result SMALLINT := 0; _major SMALLINT := 1; -- 4 _minor SMALLINT := 2; -- .5 _point SMALLINT := 3; -- .6 _qual SMALLINT := 4; -- beta _qualn SMALLINT := 5; -- 2 _subq SMALLINT := 6; -- A BEGIN CASE WHEN _left[_major] > _right[_major] THEN _result := 1; WHEN _left[_major] < _right[_major] THEN _result := -1; WHEN _left[_minor] > _right[_minor] THEN _result := 1; WHEN _left[_minor] < _right[_minor] THEN _result := -1; WHEN _left[_point] > _right[_point] THEN _result := 1; WHEN _left[_point] < _right[_point] THEN _result := -1; WHEN _left[_qual] > _right[_qual] THEN _result := 1; WHEN _left[_qual] < _right[_qual] THEN _result := -1; WHEN _left[_qualn] > _right[_qualn] THEN _result := 1; WHEN _left[_qualn] < _right[_qualn] THEN _result := -1; WHEN _left[_subq] > _right[_subq] THEN _result := 1; WHEN _left[_subq] < _right[_subq] THEN _result := -1; WHEN _left[_subq] = _right[_subq] THEN _result := 0; END CASE; RETURN _result; END; $$; ALTER FUNCTION public.compareversion(pleft text, pright text) OWNER TO admin; -- -- Name: concataggsfunc(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION concataggsfunc(text, text) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE prevstate ALIAS FOR $1; newval ALIAS FOR $2; BEGIN RETURN prevstate || newval; END; $_$; ALTER FUNCTION public.concataggsfunc(text, text) OWNER TO admin; -- -- Name: consolidatelocations(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION consolidatelocations(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; _r RECORD; BEGIN UPDATE itemloc SET itemloc_consolflag = TRUE WHERE (itemloc_itemsite_id=pItemsiteid); FOR _r IN SELECT itemloc_location_id, SUM(itemloc_qty) AS qty FROM itemloc WHERE (itemloc_itemsite_id=pItemsiteid) GROUP BY itemloc_location_id LOOP INSERT INTO itemloc ( itemloc_itemsite_id, itemloc_location_id, itemloc_expiration, itemloc_qty, itemloc_consolflag ) VALUES ( pItemsiteid, _r.itemloc_location_id, endOfTime(), _r.qty, FALSE ); END LOOP; DELETE FROM itemloc WHERE ( (itemloc_itemsite_id=pItemsiteid) AND (itemloc_consolflag) ); RETURN 1; END; $_$; ALTER FUNCTION public.consolidatelocations(integer) OWNER TO admin; -- -- Name: convertcustomertoprospect(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION convertcustomertoprospect(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustId ALIAS FOR $1; _c RECORD; BEGIN SELECT * INTO _c FROM custinfo WHERE (cust_id=pCustId); INSERT INTO prospect ( prospect_id, prospect_active, prospect_number, prospect_name, prospect_cntct_id, prospect_taxzone_id, prospect_salesrep_id, prospect_warehous_id, prospect_comments ) VALUES ( _c.cust_id, _c.cust_active, _c.cust_number, _c.cust_name, _c.cust_cntct_id, _c.cust_taxzone_id, CASE WHEN(_c.cust_salesrep_id > 0) THEN _c.cust_salesrep_id ELSE NULL END, CASE WHEN(_c.cust_preferred_warehous_id > 0) THEN _c.cust_preferred_warehous_id ELSE NULL END, _c.cust_comments); DELETE FROM custinfo WHERE (cust_id=pCustId); RETURN pCustId; END; $_$; ALTER FUNCTION public.convertcustomertoprospect(integer) OWNER TO admin; -- -- Name: convertprospecttocustomer(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION convertprospecttocustomer(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN convertProspectToCustomer($1, FALSE); END; $_$; ALTER FUNCTION public.convertprospecttocustomer(integer) OWNER TO admin; -- -- Name: convertprospecttocustomer(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION convertprospecttocustomer(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pProspectId ALIAS FOR $1; pdoquotes ALIAS FOR $2; _p RECORD; _q RECORD; BEGIN SELECT * INTO _p FROM prospect WHERE (prospect_id=pProspectId); IF (EXISTS(SELECT cust_id FROM custinfo WHERE cust_id=pProspectId)) THEN RAISE EXCEPTION '[xtuple: convertProspectToCustomer, -10]'; END IF; INSERT INTO custinfo ( cust_id, cust_active, cust_number, cust_name, cust_cntct_id, cust_taxzone_id, cust_comments, cust_creditstatus, cust_salesrep_id, cust_preferred_warehous_id, cust_terms_id, cust_custtype_id, cust_shipform_id, cust_shipvia, cust_balmethod, cust_ffshipto, cust_backorder, cust_partialship, cust_creditlmt, cust_creditrating, cust_commprcnt, cust_discntprcnt, cust_blanketpos, cust_shipchrg_id, cust_ffbillto, cust_usespos, cust_emaildelivery, cust_autoupdatestatus, cust_autoholdorders, cust_soemaildelivery ) SELECT _p.prospect_id, _p.prospect_active, _p.prospect_number, _p.prospect_name, _p.prospect_cntct_id, _p.prospect_taxzone_id, _p.prospect_comments, 'G', salesrep_id, COALESCE(_p.prospect_warehous_id, -1), FetchMetricValue('DefaultTerms'), FetchMetricValue('DefaultCustType'), FetchMetricValue('DefaultShipFormId'), COALESCE(FetchMetricValue('DefaultShipViaId'),-1), FetchMetricText('DefaultBalanceMethod'), FetchMetricBool('DefaultFreeFormShiptos'), FetchMetricBool('DefaultBackOrders'), FetchMetricBool('DefaultPartialShipments'), FetchMetricValue('SOCreditLimit'), FetchMetricText('SOCreditRate'), salesrep_commission, 0, false, COALESCE(FetchMetricValue('DefaultShipChrgId'), -1), false, false, false, false, false, false FROM salesrep WHERE (salesrep_id=COALESCE(_p.prospect_salesrep_id, FetchMetricValue('DefaultSalesRep'))); DELETE FROM prospect WHERE (prospect_id=pprospectId); IF (pdoquotes) THEN BEGIN FOR _q IN SELECT quhead_number, convertQuote(quhead_id) AS err FROM quhead WHERE ((COALESCE(quhead_expire, endOfTime()) >= CURRENT_DATE) AND (quhead_cust_id=pProspectId)) LOOP IF (_q.err < 0) THEN RAISE WARNING 'Quote % for % didn''t convert to a Sales Order [xtuple: convertQuote, %]', _q.quhead_number, _p.prospect_number, _q.err; END IF; END LOOP; EXCEPTION WHEN OTHERS THEN RAISE WARNING 'Ignored errors convering quotes: % %', SQLSTATE, SQLERRM; END; END IF; RETURN pProspectId; END; $_$; ALTER FUNCTION public.convertprospecttocustomer(integer, boolean) OWNER TO admin; -- -- Name: convertquote(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION convertquote(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuheadid ALIAS FOR $1; _qunumber TEXT; _ponumber TEXT; _soheadid INTEGER; _soitemid INTEGER; _orderid INTEGER; _ordertype CHARACTER(1); _creditstatus TEXT; _usespos BOOLEAN := false; _blanketpos BOOLEAN := true; _showConvertedQuote BOOLEAN := false; _prospectid INTEGER; _r RECORD; _soNum TEXT; BEGIN -- Check to make sure the quote has not expired IF (SELECT COALESCE(quhead_expire, endOfTime()) < CURRENT_DATE FROM quhead WHERE(quhead_id=pQuheadid)) THEN RETURN -6; END IF; -- Check to make sure that all of the quote items have a valid itemsite SELECT quitem_id INTO _r FROM quitem LEFT OUTER JOIN itemsite ON (quitem_itemsite_id=itemsite_id) WHERE ((itemsite_id IS NULL) AND (quitem_quhead_id=pQuheadid)); IF (FOUND) THEN PERFORM postEvent('CannotConvertQuote', 'Q', quhead_id, quhead_warehous_id, quhead_number, NULL, NULL, NULL, NULL) FROM quhead WHERE (quhead_id=pQuheadid); RETURN -1; END IF; SELECT cust_creditstatus, cust_usespos, cust_blanketpos INTO _creditstatus, _usespos, _blanketpos FROM quhead, custinfo WHERE ((quhead_cust_id=cust_id) AND (quhead_id=pQuheadid)); IF (NOT FOUND) THEN SELECT prospect_id INTO _prospectid FROM quhead, prospect WHERE ((quhead_cust_id=prospect_id) AND (quhead_id=pQuheadid)); IF (NOT FOUND) THEN RETURN -2; ELSE RETURN -3; END IF; ELSIF (_creditstatus = 'H' AND NOT checkPrivilege('CreateSOForHoldCustomer')) THEN RETURN -4; ELSIF (_creditstatus = 'W' AND NOT checkPrivilege('CreateSOForWarnCustomer')) THEN RETURN -5; END IF; IF (_usespos) THEN SELECT quhead_number, COALESCE(quhead_custponumber, ''), cohead_id INTO _qunumber, _ponumber, _soheadid FROM quhead LEFT OUTER JOIN cohead ON ( (cohead_cust_id=quhead_cust_id) AND (UPPER(cohead_custponumber)=UPPER(quhead_custponumber)) ) WHERE (quhead_id=pQuheadid); IF (_ponumber = '') THEN RAISE EXCEPTION 'Customer PO required for Quote % [xtuple: convertQuote, -7, %]', _qunumber, _qunumber; END IF; IF ( (NOT _blanketpos) AND (_soheadid IS NOT NULL) ) THEN RAISE EXCEPTION 'Duplicate Customer PO % for Quote % [xtuple: convertQuote, -8, %, %]', _ponumber, _qunumber, _ponumber, _qunumber; END IF; END IF; PERFORM quhead_number, cohead_id FROM quhead, cohead WHERE quhead_id = pQuheadid AND cohead_number = quhead_number; IF (FOUND) THEN SELECT fetchSoNumber() INTO _soNum; ELSE SELECT quhead_number INTO _soNum FROM quhead WHERE quhead_id = pQuheadid; END IF; SELECT NEXTVAL('cohead_cohead_id_seq') INTO _soheadid; INSERT INTO cohead ( cohead_id, cohead_number, cohead_cust_id, cohead_orderdate, cohead_packdate, cohead_custponumber, cohead_warehous_id, cohead_billtoname, cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, cohead_billtocity, cohead_billtostate, cohead_billtozipcode, cohead_billtocountry, cohead_shipto_id, cohead_shiptoname, cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3, cohead_shiptocity, cohead_shiptostate, cohead_shiptozipcode, cohead_shiptocountry, cohead_salesrep_id, cohead_commission, cohead_terms_id, cohead_shipchrg_id, cohead_shipform_id, cohead_fob, cohead_shipvia, cohead_ordercomments, cohead_shipcomments, cohead_freight, cohead_misc, cohead_misc_accnt_id, cohead_misc_descrip, cohead_holdtype, cohead_quote_number, cohead_prj_id, cohead_curr_id, cohead_taxzone_id, cohead_taxtype_id, cohead_shipto_cntct_id, cohead_shipto_cntct_honorific, cohead_shipto_cntct_first_name, cohead_shipto_cntct_middle, cohead_shipto_cntct_last_name, cohead_shipto_cntct_suffix, cohead_shipto_cntct_phone, cohead_shipto_cntct_title, cohead_shipto_cntct_fax, cohead_shipto_cntct_email, cohead_billto_cntct_id, cohead_billto_cntct_honorific, cohead_billto_cntct_first_name, cohead_billto_cntct_middle, cohead_billto_cntct_last_name, cohead_billto_cntct_suffix, cohead_billto_cntct_phone, cohead_billto_cntct_title, cohead_billto_cntct_fax, cohead_billto_cntct_email, cohead_ophead_id, cohead_calcfreight, cohead_saletype_id, cohead_shipzone_id ) SELECT _soheadid, _soNum, quhead_cust_id, CURRENT_DATE, quhead_packdate, quhead_custponumber, quhead_warehous_id, quhead_billtoname, quhead_billtoaddress1, quhead_billtoaddress2, quhead_billtoaddress3, quhead_billtocity, quhead_billtostate, quhead_billtozip, quhead_billtocountry, quhead_shipto_id, quhead_shiptoname, quhead_shiptoaddress1, quhead_shiptoaddress2, quhead_shiptoaddress3, quhead_shiptocity, quhead_shiptostate, quhead_shiptozipcode, quhead_shiptocountry, quhead_salesrep_id, quhead_commission, quhead_terms_id, cust_shipchrg_id, cust_shipform_id, quhead_fob, quhead_shipvia, quhead_ordercomments, quhead_shipcomments, quhead_freight, quhead_misc, quhead_misc_accnt_id, quhead_misc_descrip, 'N', quhead_number, quhead_prj_id, quhead_curr_id, quhead_taxzone_id, quhead_taxtype_id, quhead_shipto_cntct_id, quhead_shipto_cntct_honorific, quhead_shipto_cntct_first_name, quhead_shipto_cntct_middle, quhead_shipto_cntct_last_name, quhead_shipto_cntct_suffix, quhead_shipto_cntct_phone, quhead_shipto_cntct_title, quhead_shipto_cntct_fax, quhead_shipto_cntct_email, quhead_billto_cntct_id, quhead_billto_cntct_honorific, quhead_billto_cntct_first_name, quhead_billto_cntct_middle, quhead_billto_cntct_last_name, quhead_billto_cntct_suffix, quhead_billto_cntct_phone, quhead_billto_cntct_title, quhead_billto_cntct_fax, quhead_billto_cntct_email, quhead_ophead_id, quhead_calcfreight, quhead_saletype_id, quhead_shipzone_id FROM quhead JOIN custinfo ON (cust_id=quhead_cust_id) WHERE (quhead_id=pQuheadid); -- Move Documents UPDATE url SET url_source_id = _soheadid, url_source = 'S' WHERE ((url_source='Q') AND (url_source_id = pQuheadid)); UPDATE imageass SET imageass_source_id = _soheadid, imageass_source = 'S' WHERE ((imageass_source='Q') AND (imageass_source_id = pQuheadid)); UPDATE docass SET docass_source_id = _soheadid, docass_source_type = 'S' WHERE ((docass_source_type='Q') AND (docass_source_id = pQuheadid)); -- Move Email IF (fetchMetricBool('EnableBatchManager')) THEN UPDATE xtbatch.emlassc SET emlassc_type='S', emlassc_assc_id=_soheadid WHERE ((emlassc_type='Q') AND (emlassc_assc_id=pQuheadid)); END IF; -- Copy Characteristics INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price) SELECT 'SO', _soheadid, charass_char_id, charass_value, charass_default, charass_price FROM charass WHERE ((charass_target_type='QU') AND (charass_target_id=pQuheadid)); -- Copy Comments INSERT INTO comment ( comment_cmnttype_id, comment_source, comment_source_id, comment_date, comment_user, comment_text, comment_public ) SELECT comment_cmnttype_id, 'S', _soheadid, comment_date, comment_user, ('Quote-' || comment_text), comment_public FROM comment WHERE ( (comment_source='Q') AND (comment_source_id=pQuheadid) ); FOR _r IN SELECT quitem.*, quhead_number, quhead_prj_id, quhead_saletype_id, itemsite_item_id, itemsite_leadtime, itemsite_createsopo, itemsite_createsopr, item_type, COALESCE(quitem_itemsrc_id, itemsrc_id, -1) AS itemsrcid FROM quhead JOIN quitem ON (quitem_quhead_id=quhead_id) JOIN itemsite ON (itemsite_id=quitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) LEFT OUTER JOIN itemsrc ON ( (itemsrc_item_id=item_id) AND (itemsrc_default) ) WHERE (quhead_id=pQuheadid) ORDER BY quitem_linenumber LOOP SELECT NEXTVAL('coitem_coitem_id_seq') INTO _soitemid; INSERT INTO coitem ( coitem_id, coitem_cohead_id, coitem_linenumber, coitem_itemsite_id, coitem_status, coitem_scheddate, coitem_promdate, coitem_price, coitem_custprice, coitem_qtyord, coitem_qtyshipped, coitem_qtyreturned, coitem_qty_uom_id, coitem_qty_invuomratio, coitem_price_uom_id, coitem_price_invuomratio, coitem_unitcost, coitem_prcost, coitem_custpn, coitem_memo, coitem_taxtype_id, coitem_order_id ) VALUES ( _soitemid, _soheadid, _r.quitem_linenumber, _r.quitem_itemsite_id, 'O', _r.quitem_scheddate, _r.quitem_promdate, _r.quitem_price, _r.quitem_custprice, _r.quitem_qtyord, 0, 0, _r.quitem_qty_uom_id, _r.quitem_qty_invuomratio, _r.quitem_price_uom_id, _r.quitem_price_invuomratio, _r.quitem_unitcost, _r.quitem_prcost, _r.quitem_custpn, _r.quitem_memo, _r.quitem_taxtype_id, -1 ); IF (fetchMetricBool('enablextcommissionission')) THEN PERFORM xtcommission.getSalesReps(quhead_cust_id, quhead_shipto_id, _r.itemsite_item_id, _r.quhead_saletype_id, _r.quitem_price, _r.quitem_custprice, _soitemid, 'SalesItem') FROM quhead WHERE (quhead_id=pQuheadid); END IF; -- Copy Characteristics INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price) SELECT 'SI', _soitemid, charass_char_id, charass_value, charass_default, charass_price FROM charass WHERE ((charass_target_type='QI') AND (charass_target_id=_r.quitem_id)); -- Copy Comments INSERT INTO comment ( comment_cmnttype_id, comment_source, comment_source_id, comment_date, comment_user, comment_text ) SELECT comment_cmnttype_id, 'SI', _soitemid, comment_date, comment_user, ('Quote-' || comment_text) FROM comment WHERE ( (comment_source='QI') AND (comment_source_id=_r.quitem_id) ); _orderid := -1; _ordertype := ''; IF (_r.quitem_createorder) THEN IF (_r.item_type IN ('M')) THEN SELECT createWo( CAST(_soNum AS INTEGER), supply.itemsite_id, 1, (_r.quitem_qtyord * _r.quitem_qty_invuomratio), _r.itemsite_leadtime, _r.quitem_scheddate, _r.quitem_memo, 'S', _soitemid, _r.quhead_prj_id ) INTO _orderId FROM itemsite sold, itemsite supply WHERE ((sold.itemsite_item_id=supply.itemsite_item_id) AND (supply.itemsite_warehous_id=_r.quitem_order_warehous_id) AND (sold.itemsite_id=_r.quitem_itemsite_id) ); _orderType := 'W'; INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value) SELECT 'W', _orderId, charass_char_id, charass_value FROM charass WHERE ((charass_target_type='QI') AND (charass_target_id=_r.quitem_id)); ELSIF ( (_r.item_type IN ('P', 'O')) AND (_r.itemsite_createsopr) ) THEN SELECT createPr( CAST(_soNum AS INTEGER), _r.quitem_itemsite_id, (_r.quitem_qtyord * _r.quitem_qty_invuomratio), _r.quitem_scheddate, '', 'S', _soitemid ) INTO _orderId; _orderType := 'R'; UPDATE pr SET pr_prj_id=_r.quhead_prj_id WHERE pr_id=_orderId; ELSIF ( (_r.item_type IN ('P', 'O')) AND (_r.itemsite_createsopo) ) THEN IF (_r.quitem_prcost=0) THEN SELECT createPurchaseToSale(_soitemid, _r.itemsrcid, _r.quitem_dropship) INTO _orderId; ELSE SELECT createPurchaseToSale(_soitemid, _r.itemsrcid, _r.quitem_dropship, _r.quitem_prcost) INTO _orderId; END IF; _orderType := 'P'; END IF; UPDATE coitem SET coitem_order_type=_ordertype, coitem_order_id=_orderid WHERE (coitem_id=_soitemid); END IF; END LOOP; SELECT metric_value INTO _showConvertedQuote FROM metric WHERE metric_name = 'ShowQuotesAfterSO'; -- bug 26513 - mobilized databases delete the quote in a cohead trigger when cohead_wasquote -- on INSERT. set the flag late, otherwise quitems may be removed before they can be copied UPDATE cohead SET cohead_wasquote = TRUE WHERE cohead_id = _soheadid; IF (_showConvertedQuote) THEN UPDATE quhead SET quhead_status= 'C' WHERE (quhead_id = pQuheadid); ELSE PERFORM deleteQuote(pQuheadid); END IF; RETURN _soheadid; END; $_$; ALTER FUNCTION public.convertquote(integer) OWNER TO admin; -- -- Name: convertquotetoinvoice(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION convertquotetoinvoice(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuheadid ALIAS FOR $1; _qunumber TEXT; _ponumber TEXT; _iheadid INTEGER; _iitemid INTEGER; _orderid INTEGER; _ordertype CHARACTER(1); _creditstatus TEXT; _usespos BOOLEAN := false; _blanketpos BOOLEAN := true; _showConvertedQuote BOOLEAN := false; _prospectid INTEGER; _r RECORD; _inNum TEXT; BEGIN -- Check to make sure the quote has not expired IF (SELECT COALESCE(quhead_expire, endOfTime()) < CURRENT_DATE FROM quhead WHERE(quhead_id=pQuheadid)) THEN RETURN -6; END IF; -- Check to make sure that all of the quote items have a valid itemsite SELECT quitem_id INTO _r FROM quitem LEFT OUTER JOIN itemsite ON (quitem_itemsite_id=itemsite_id) WHERE ((itemsite_id IS NULL) AND (quitem_quhead_id=pQuheadid)); IF (FOUND) THEN PERFORM postEvent('CannotConvertQuote', 'Q', quhead_id, quhead_warehous_id, quhead_number, NULL, NULL, NULL, NULL) FROM quhead WHERE (quhead_id=pQuheadid); RETURN -1; END IF; -- Get Credit Stat, Uses POs and Blanket POs SELECT cust_creditstatus, cust_usespos, cust_blanketpos INTO _creditstatus, _usespos, _blanketpos FROM quhead, custinfo WHERE ((quhead_cust_id=cust_id) AND (quhead_id=pQuheadid)); -- Check to see if customer or prospect IF (NOT FOUND) THEN SELECT prospect_id INTO _prospectid FROM quhead, prospect WHERE ((quhead_cust_id=prospect_id) AND (quhead_id=pQuheadid)); IF (NOT FOUND) THEN RETURN -2; ELSE RETURN -3; END IF; ELSIF (_creditstatus = 'H' AND NOT hasPriv('CreateSOForHoldCustomer')) THEN RETURN -4; ELSIF (_creditstatus = 'W' AND NOT hasPriv('CreateSOForWarnCustomer')) THEN RETURN -5; END IF; -- PO/blanket PO checks IF (_usespos) THEN SELECT quhead_number, COALESCE(quhead_custponumber, ''), invchead_id INTO _qunumber, _ponumber, _iheadid FROM quhead LEFT OUTER JOIN invchead ON ( (invchead_cust_id=quhead_cust_id) AND (UPPER(invchead_ponumber)=UPPER(quhead_custponumber)) ) WHERE (quhead_id=pQuheadid); IF (_ponumber = '') THEN RAISE EXCEPTION 'Customer PO required for Quote % [xtuple: convertQuote, -7, %]', _qunumber, _qunumber; END IF; IF ( (NOT _blanketpos) AND (_iheadid IS NOT NULL) ) THEN RAISE EXCEPTION 'Duplicate Customer PO % for Quote % [xtuple: convertQuote, -8, %, %]', _ponumber, _qunumber, _ponumber, _qunumber; END IF; END IF; IF (_usespos) THEN SELECT quhead_number INTO _qunumber FROM quhead WHERE (quhead_id=pQuheadid) AND (COALESCE(quhead_custponumber, '') = ''); IF (FOUND) THEN RAISE EXCEPTION 'Customer PO required for Quote % [xtuple: convertQuote, -7, %]', _qunumber, _qunumber; END IF; END IF; IF ( (_usespos) AND (NOT _blanketpos) ) THEN SELECT quhead_number, quhead_custponumber INTO _qunumber, _ponumber FROM quhead JOIN invchead ON ( (invchead_cust_id=quhead_cust_id) AND (UPPER(invchead_ponumber)=UPPER(quhead_custponumber)) ) WHERE (quhead_id=pQuheadid); IF (FOUND) THEN RAISE EXCEPTION 'Duplicate Customer PO % for Quote % [xtuple: convertQuote, -8, %, %]', _ponumber, _qunumber, _ponumber, _qunumber; END IF; END IF; --Check to see if an invoice exists with the quote number PERFORM quhead_number, invchead_id FROM quhead, invchead WHERE quhead_id = pQuheadid AND invchead_invcnumber = quhead_number; -- If it does then get a new Invoice number otherwise use the quote number as the invoice number IF (FOUND) THEN SELECT fetchinvcnumber() INTO _inNum; ELSE SELECT quhead_number INTO _inNum FROM quhead WHERE quhead_id = pQuheadid; END IF; --Insert quote info into invoice tables SELECT NEXTVAL('invchead_invchead_id_seq') INTO _iheadid; INSERT INTO invchead ( invchead_ordernumber, invchead_shipdate, invchead_recurring, invchead_id, invchead_invcnumber, invchead_cust_id, invchead_orderdate, invchead_ponumber, invchead_billto_name, invchead_billto_address1, invchead_billto_address2, invchead_billto_address3, invchead_billto_city, invchead_billto_state, invchead_billto_zipcode, invchead_billto_country, invchead_shipto_id, invchead_shipto_name, invchead_shipto_address1, invchead_shipto_address2, invchead_shipto_address3, invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode, invchead_shipto_country, invchead_salesrep_id, invchead_commission, invchead_terms_id, invchead_shipchrg_id, invchead_fob, invchead_shipvia, invchead_notes, invchead_freight, invchead_misc_amount, invchead_misc_accnt_id, invchead_misc_descrip, invchead_prj_id, invchead_curr_id, invchead_taxzone_id, invchead_posted, invchead_printed, invchead_invcdate, invchead_saletype_id, invchead_shipzone_id --invchead_taxtype_id, --invchead_shipto_cntct_id, invchead_shipto_cntct_honorific, invchead_shipto_cntct_first_name, --invchead_shipto_cntct_middle, invchead_shipto_cntct_last_name, invchead_shipto_cntct_suffix, --invchead_shipto_cntct_phone, invchead_shipto_cntct_title, invchead_shipto_cntct_fax, --invchead_shipto_cntct_email, --invchead_billto_cntct_id, invchead_billto_cntct_honorific, --invchead_billto_cntct_first_name, invchead_billto_cntct_middle, invchead_billto_cntct_last_name, --invchead_billto_cntct_suffix, invchead_billto_cntct_phone, invchead_billto_cntct_title, --invchead_billto_cntct_fax, invchead_billto_cntct_email, --invchead_ophead_id, --invchead_calcfreight ) SELECT quhead_number, quhead_packdate, 'f', _iheadid, _inNum, quhead_cust_id, CURRENT_DATE, quhead_custponumber, quhead_billtoname, quhead_billtoaddress1, quhead_billtoaddress2, quhead_billtoaddress3, quhead_billtocity, quhead_billtostate, quhead_billtozip, quhead_billtocountry, quhead_shipto_id, quhead_shiptoname, quhead_shiptoaddress1, quhead_shiptoaddress2, quhead_shiptoaddress3, quhead_shiptocity, quhead_shiptostate, quhead_shiptozipcode, quhead_shiptocountry, quhead_salesrep_id, quhead_commission, quhead_terms_id, cust_shipchrg_id, quhead_fob, quhead_shipvia, quhead_ordercomments, quhead_freight, quhead_misc, quhead_misc_accnt_id, quhead_misc_descrip, quhead_prj_id, quhead_curr_id, quhead_taxzone_id, 'f','f',current_date, quhead_saletype_id, quhead_shipzone_id --quhead_shipto_cntct_id, quhead_shipto_cntct_honorific, --quhead_shipto_cntct_first_name, quhead_shipto_cntct_middle, quhead_shipto_cntct_last_name, --quhead_shipto_cntct_suffix, quhead_shipto_cntct_phone, quhead_shipto_cntct_title, --quhead_shipto_cntct_fax, quhead_shipto_cntct_email, quhead_billto_cntct_id, --quhead_billto_cntct_honorific, quhead_billto_cntct_first_name, quhead_billto_cntct_middle, --quhead_billto_cntct_last_name, quhead_billto_cntct_suffix, quhead_billto_cntct_phone, --quhead_billto_cntct_title, quhead_billto_cntct_fax, quhead_billto_cntct_email, quhead_ophead_id, --quhead_calcfreight FROM quhead JOIN custinfo ON (cust_id=quhead_cust_id) WHERE (quhead_id=pQuheadid); -- Copy characteristics from the quhead to the invoice head INSERT INTO charass ( charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price ) SELECT 'INV', _iheadid, charass_char_id, charass_value, charass_default, charass_price FROM charass JOIN char ON char_id = charass_char_id JOIN charuse ON char_id = charuse_char_id AND charuse_target_type = 'INV' WHERE charass_target_type = 'QU' AND charass_target_id = pQuheadid; -- Attachments on Invoice not supported but leaving this in for future use: /* UPDATE url SET url_source_id = _iheadid, url_source = 'I' WHERE ((url_source='Q') AND (url_source_id = pQuheadid)); UPDATE imageass SET imageass_source_id = _iheadid, imageass_source = 'I' WHERE ((imageass_source='Q') AND (imageass_source_id = pQuheadid)); UPDATE docass SET docass_source_id = _iheadid, docass_source_type = 'I' WHERE ((docass_source_type='Q') AND (docass_source_id = pQuheadid)); */ -- Comments not supported on Invoice but leaving this in for future use: /* INSERT INTO comment ( comment_cmnttype_id, comment_source, comment_source_id, comment_date, comment_user, comment_text, comment_public ) SELECT comment_cmnttype_id, 'I', _iheadid, comment_date, comment_user, ('Quote-' || comment_text), comment_public FROM comment WHERE ( (comment_source='Q') AND (comment_source_id=pQuheadid) ); */ FOR _r IN SELECT quitem.*, quhead_number, quhead_prj_id, quhead_saletype_id, itemsite_item_id, itemsite_leadtime, itemsite_createsopo, itemsite_createsopr, item_type, COALESCE(quitem_itemsrc_id, itemsrc_id, -1) AS itemsrcid FROM quhead JOIN quitem ON (quitem_quhead_id=quhead_id) JOIN itemsite ON (itemsite_id=quitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) LEFT OUTER JOIN itemsrc ON ( (itemsrc_item_id=item_id) AND (itemsrc_default) ) WHERE (quhead_id=pQuheadid) LOOP SELECT NEXTVAL('invcitem_invcitem_id_seq') INTO _iitemid; INSERT INTO invcitem ( invcitem_id, invcitem_invchead_id, invcitem_linenumber, invcitem_item_id, invcitem_warehous_id, --invcitem_status, --invcitem_scheddate, invcitem_promdate, invcitem_price, invcitem_custprice, invcitem_ordered, invcitem_billed, invcitem_qty_uom_id, invcitem_qty_invuomratio, invcitem_price_uom_id, invcitem_price_invuomratio, invcitem_custpn, invcitem_notes, invcitem_taxtype_id ) VALUES ( _iitemid, _iheadid, _r.quitem_linenumber, (SELECT itemsite_item_id FROM itemsite WHERE itemsite_id = _r.quitem_itemsite_id), (SELECT itemsite_warehous_id FROM itemsite WHERE itemsite_id = _r.quitem_itemsite_id), --'O', --_r.quitem_scheddate, _r.quitem_promdate, _r.quitem_price, _r.quitem_custprice, _r.quitem_qtyord, _r.quitem_qtyord, _r.quitem_qty_uom_id, _r.quitem_qty_invuomratio, _r.quitem_price_uom_id, _r.quitem_price_invuomratio, _r.quitem_custpn, _r.quitem_memo, _r.quitem_taxtype_id ); IF (fetchMetricBool('enablextcommissionission')) THEN PERFORM xtcommission.getSalesReps(quhead_cust_id, quhead_shipto_id, _r.itemsite_item_id, _r.quhead_saletype_id, _r.quitem_price, _r.quitem_custprice, _iitemid, 'InvoiceItem') FROM quhead WHERE (quhead_id=pQuheadid); END IF; /* INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price) SELECT 'SI', _iitemid, charass_char_id, charass_value, charass_default, charass_price FROM charass WHERE ((charass_target_type='QI') AND (charass_target_id=_r.quitem_id)); */ -- Comments not supported but leaving in for future use /* INSERT INTO comment ( comment_cmnttype_id, comment_source, comment_source_id, comment_date, comment_user, comment_text ) SELECT comment_cmnttype_id, 'SI', _iitemid, comment_date, comment_user, ('Quote-' || comment_text) FROM comment WHERE ( (comment_source='QI') AND (comment_source_id=_r.quitem_id) ); */ _orderid := -1; _ordertype := ''; IF (_r.quitem_createorder) THEN IF (_r.item_type IN ('M')) THEN SELECT createWo( CAST(_r.quhead_number AS INTEGER), supply.itemsite_id, 1, (_r.quitem_qtyord * _r.quitem_qty_invuomratio), _r.itemsite_leadtime, _r.quitem_scheddate, _r.quitem_memo, 'Q', _iitemid, _r.quhead_prj_id ) INTO _orderId FROM itemsite sold, itemsite supply WHERE ((sold.itemsite_item_id=supply.itemsite_item_id) AND (supply.itemsite_warehous_id=_r.quitem_order_warehous_id) AND (sold.itemsite_id=_r.quitem_itemsite_id) ); _orderType := 'W'; INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value) SELECT 'W', _orderId, charass_char_id, charass_value FROM charass WHERE ((charass_target_type='QI') AND (charass_target_id=_r.quitem_id)); ELSIF ( (_r.item_type IN ('P', 'O')) AND (_r.itemsite_createsopr) ) THEN SELECT createPr( CAST(_r.quhead_number AS INTEGER), _r.quitem_itemsite_id, (_r.quitem_qtyord * _r.quitem_qty_invuomratio), _r.quitem_scheddate, '', 'S', _iitemid ) INTO _orderId; _orderType := 'R'; UPDATE pr SET pr_prj_id=_r.quhead_prj_id WHERE pr_id=_orderId; ELSIF ( (_r.item_type IN ('P', 'O')) AND (_r.itemsite_createsopo) ) THEN IF (_r.quitem_prcost=0) THEN SELECT createpurchasetoquote(_r.quitem_id, _r.itemsrcid, _r.quitem_dropship) INTO _orderId; ELSE SELECT createpurchasetoquote(_r.quitem_id, _r.itemsrcid, _r.quitem_dropship, _r.quitem_prcost) INTO _orderId; END IF; _orderType := 'P'; END IF; -- UPDATE invcitem SET invcitem_order_type=_ordertype, invcitem_order_id=_orderid -- WHERE (invcitem_id=_iitemid); END IF; END LOOP; SELECT metric_value INTO _showConvertedQuote FROM metric WHERE metric_name = 'ShowQuotesAfterSO'; IF (_showConvertedQuote) THEN UPDATE quhead SET quhead_status= 'C' WHERE (quhead_id = pQuheadid); ELSE PERFORM deleteQuote(pQuheadid); END IF; RETURN _iheadid; END; $_$; ALTER FUNCTION public.convertquotetoinvoice(integer) OWNER TO admin; -- -- Name: copyaccountingyearperiod(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copyaccountingyearperiod(pyearperiodid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _newYear INTEGER; BEGIN -- First create new fiscal year INSERT INTO yearperiod (yearperiod_start, yearperiod_end, yearperiod_closed) SELECT yearperiod_start + INTERVAL ' 1 year', yearperiod_end + INTERVAL ' 1 year', FALSE FROM yearperiod WHERE yearperiod_id = pYearPeriodid RETURNING yearperiod_id INTO _newYear; IF (NOT COALESCE(_newYear, -1) > 0) THEN RAISE EXCEPTION 'An error occurred creating the Fiscal Year [xtuple: copyaccountingyearperiod, -1]'; END IF; -- Copy corresponding fiscal periods across to the new fiscal year INSERT INTO period (period_start, period_end, period_closed, period_freeze, period_initial, period_name, period_yearperiod_id, period_quarter, period_number) SELECT (period_start + INTERVAL '1 year')::date, (period_end + INTERVAL '1 year')::date, FALSE, FALSE, FALSE, EXTRACT(year FROM period_start + INTERVAL '1 year') || '-' || to_char((period_start + INTERVAL '1 year'), 'Mon'), _newYear, period_quarter, period_number FROM period WHERE period_yearperiod_id = pYearPeriodid; -- Forward Update Accounting Periods for all G/L Accounts PERFORM forwardupdatetrialbalance(max(trialbal_id)) FROM accnt LEFT OUTER JOIN trialbal ON ( (trialbal_accnt_id=accnt_id) ) GROUP BY accnt_id HAVING max(trialbal_id) IS NOT NULL ORDER BY accnt_id; RETURN _newYear; END; $$; ALTER FUNCTION public.copyaccountingyearperiod(pyearperiodid integer) OWNER TO admin; -- -- Name: copybom(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copybom(psitemid integer, ptitemid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _result INTEGER; BEGIN SELECT copyBOM (pSItemid, PTItemid, FALSE) into _result; RETURN _result; END; $$; ALTER FUNCTION public.copybom(psitemid integer, ptitemid integer) OWNER TO admin; -- -- Name: copybom(integer, integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copybom(psitemid integer, ptitemid integer, pcopyusedat boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _bh RECORD; _bi RECORD; _bomheadfound BOOLEAN := FALSE; _bomheadid INTEGER; _bomitemid INTEGER; _bomworksetid INTEGER; _temp INTEGER; _schedatwooper BOOLEAN; _booitemseqid INTEGER; BEGIN -- Cache source bomhead SELECT * INTO _bh FROM bomhead WHERE ((bomhead_item_id=pSItemid) AND (bomhead_rev_id=getActiveRevID('BOM', pSItemid))); -- bomhead may not exist -- IF (NOT FOUND) THEN -- RETURN -1; -- END IF; IF (FOUND) THEN _bomheadfound := TRUE; END IF; -- Make sure that source bomitems exist SELECT bomitem_id INTO _bomitemid FROM bomitem WHERE ((bomitem_parent_item_id=pSItemid) AND (bomitem_rev_id=getActiveRevID('BOM', pSItemid))) LIMIT 1; IF (NOT FOUND) THEN RETURN -2; END IF; -- Make sure that target bomitems do not exist SELECT bomitem_id INTO _bomitemid FROM bomitem WHERE ((bomitem_parent_item_id=pTItemid) AND (bomitem_rev_id= -1)) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; -- Make sure that the parent is not used in the component at some level IF ( SELECT (item_type IN ('M', 'F')) FROM item WHERE (item_id=pSItemid) ) THEN SELECT indentedWhereUsed(pTItemid) INTO _bomworksetid; SELECT bomwork_id INTO _temp FROM bomwork WHERE ( (bomwork_set_id=_bomworksetid) AND (bomwork_item_id=pSItemid) ) LIMIT 1; IF (FOUND) THEN PERFORM deleteBOMWorkset(_bomworksetid); RETURN -4; END IF; PERFORM deleteBOMWorkset(_bomworksetid); END IF; -- Check for existing target bomhead SELECT bomhead_id INTO _bomheadid FROM bomhead WHERE ((bomhead_item_id=pTItemid) AND (bomhead_rev_id= -1)); IF (NOT FOUND) THEN IF (_bomheadfound) THEN INSERT INTO bomhead ( bomhead_item_id, bomhead_serial, bomhead_docnum, bomhead_batchsize, bomhead_requiredqtyper ) VALUES ( pTItemid, _bh.bomhead_serial, _bh.bomhead_docnum, _bh.bomhead_batchsize, _bh.bomhead_requiredqtyper ); END IF; END IF; FOR _bi IN SELECT bomitem.* FROM bomitem(pSItemid) WHERE (bomitem_expires>CURRENT_DATE) LOOP SELECT NEXTVAL('bomitem_bomitem_id_seq') INTO _bomitemid; IF (pCopyUsedAt) THEN _schedatwooper := _bi.bomitem_schedatwooper; _booitemseqid := _bi.bomitem_booitem_seq_id; ELSE _schedatwooper := FALSE; _booitemseqid := -1; END IF; INSERT INTO bomitem ( bomitem_id, bomitem_parent_item_id, bomitem_seqnumber, bomitem_item_id, bomitem_uom_id, bomitem_qtyfxd, bomitem_qtyper, bomitem_scrap, bomitem_schedatwooper, bomitem_booitem_seq_id, bomitem_effective, bomitem_expires, bomitem_ecn, bomitem_createwo, bomitem_issuemethod, bomitem_moddate, bomitem_subtype, bomitem_notes, bomitem_ref, bomitem_char_id, bomitem_value ) VALUES ( _bomitemid, pTItemid, _bi.bomitem_seqnumber, _bi.bomitem_item_id, _bi.bomitem_uom_id, _bi.bomitem_qtyfxd, _bi.bomitem_qtyper, _bi.bomitem_scrap, _schedatwooper, _booitemseqid, CURRENT_DATE, _bi.bomitem_expires, _bi.bomitem_ecn, _bi.bomitem_createwo, _bi.bomitem_issuemethod, CURRENT_DATE, _bi.bomitem_subtype, _bi.bomitem_notes, _bi.bomitem_ref, _bi.bomitem_char_id, _bi.bomitem_value ); INSERT INTO bomitemsub ( bomitemsub_bomitem_id, bomitemsub_item_id, bomitemsub_uomratio, bomitemsub_rank ) SELECT _bomitemid, bomitemsub_item_id, bomitemsub_uomratio, bomitemsub_rank FROM bomitemsub WHERE (bomitemsub_bomitem_id=_bi.bomitem_id); END LOOP; RETURN pTItemid; END; $$; ALTER FUNCTION public.copybom(psitemid integer, ptitemid integer, pcopyusedat boolean) OWNER TO admin; -- -- Name: copybudget(integer, text, text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copybudget(integer, text, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBudgheadid ALIAS FOR $1; pName ALIAS FOR $2; pDescrip ALIAS FOR $3; pInterval ALIAS FOR $4; _budgheadid INTEGER; _periodid INTEGER; _result INTEGER; BEGIN SELECT 1 INTO _result FROM budgitem WHERE ((budgitem_budghead_id=pBudgheadid) AND (nextPeriodByInterval(budgitem_period_id, pInterval)=-1)) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; SELECT nextval('budghead_budghead_id_seq') INTO _budgheadid; INSERT INTO budghead (budghead_id, budghead_name, budghead_descrip) VALUES(_budgheadid, pName, pDescrip); INSERT INTO budgitem (budgitem_budghead_id, budgitem_period_id, budgitem_accnt_id, budgitem_amount) SELECT _budgheadid, nextPeriodByInterval(budgitem_period_id, pInterval), budgitem_accnt_id, budgitem_amount FROM budgitem WHERE (budgitem_budghead_id=pBudgheadid); RETURN _budgheadid; END; $_$; ALTER FUNCTION public.copybudget(integer, text, text, integer) OWNER TO admin; -- -- Name: copycmd(integer, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copycmd(integer, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmdId ALIAS FOR $1; pModule ALIAS FOR $2; pTitle ALIAS FOR $3; _cmdId INTEGER; BEGIN SELECT nextval('cmd_cmd_id_seq') INTO _cmdId; INSERT INTO cmd SELECT _cmdId, pModule, pTitle, cmd_descrip, cmd_privname, cmd_executable FROM cmd WHERE (cmd_id=pCmdId); INSERT INTO cmdarg (cmdarg_cmd_id, cmdarg_order, cmdarg_arg) SELECT _cmdId, cmdarg_order, cmdarg_arg FROM cmdarg WHERE (cmdarg_cmd_id=pCmdId); RETURN 1; END; $_$; ALTER FUNCTION public.copycmd(integer, text, text) OWNER TO admin; -- -- Name: copycontract(integer, text, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copycontract(pcontrctid integer, pnumber text, peffective date, pexpires date) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _contrctid INTEGER; _itemsrcid INTEGER; _r RECORD; BEGIN INSERT INTO contrct ( contrct_number, contrct_vend_id, contrct_descrip, contrct_effective, contrct_expires, contrct_note ) SELECT pNumber, contrct_vend_id, contrct_descrip, pEffective, pExpires, contrct_note FROM contrct WHERE (contrct_id=pContrctid) RETURNING contrct_id INTO _contrctid; FOR _r IN SELECT * FROM itemsrc WHERE (itemsrc_contrct_id=pContrctid) LOOP INSERT INTO itemsrc ( itemsrc_item_id, itemsrc_vend_id, itemsrc_vend_item_number, itemsrc_vend_item_descrip, itemsrc_comments, itemsrc_vend_uom, itemsrc_invvendoruomratio, itemsrc_minordqty, itemsrc_multordqty, itemsrc_leadtime, itemsrc_ranking, itemsrc_active, itemsrc_manuf_name, itemsrc_manuf_item_number, itemsrc_manuf_item_descrip, itemsrc_default, itemsrc_upccode, itemsrc_effective, itemsrc_expires, itemsrc_contrct_id ) VALUES ( _r.itemsrc_item_id, _r.itemsrc_vend_id, _r.itemsrc_vend_item_number, _r.itemsrc_vend_item_descrip, _r.itemsrc_comments, _r.itemsrc_vend_uom, _r.itemsrc_invvendoruomratio, _r.itemsrc_minordqty, _r.itemsrc_multordqty, _r.itemsrc_leadtime, _r.itemsrc_ranking, _r.itemsrc_active, _r.itemsrc_manuf_name, _r.itemsrc_manuf_item_number, _r.itemsrc_manuf_item_descrip, _r.itemsrc_default, _r.itemsrc_upccode, pEffective, pExpires, _contrctid ) RETURNING itemsrc_id INTO _itemsrcid; INSERT INTO itemsrcp ( itemsrcp_itemsrc_id, itemsrcp_qtybreak, itemsrcp_price, itemsrcp_updated, itemsrcp_curr_id, itemsrcp_dropship, itemsrcp_warehous_id, itemsrcp_type, itemsrcp_discntprcnt, itemsrcp_fixedamtdiscount ) SELECT _itemsrcid, itemsrcp_qtybreak, itemsrcp_price, CURRENT_DATE, itemsrcp_curr_id, itemsrcp_dropship, itemsrcp_warehous_id, itemsrcp_type, itemsrcp_discntprcnt, itemsrcp_fixedamtdiscount FROM itemsrcp WHERE (itemsrcp_itemsrc_id=_r.itemsrc_id); END LOOP; RETURN _contrctid; END; $$; ALTER FUNCTION public.copycontract(pcontrctid integer, pnumber text, peffective date, pexpires date) OWNER TO admin; -- -- Name: copyfinancialgroup(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copyfinancialgroup(integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSourceGroup ALIAS FOR $1; pFlheadid ALIAS FOR $2; pParentFlgrpid ALIAS FOR $3; _flgrpid INTEGER; BEGIN SELECT nextval('flgrp_flgrp_id_seq') INTO _flgrpid; -- Copy the group item INSERT INTO flgrp (flgrp_id, flgrp_flhead_id, flgrp_flgrp_id, flgrp_order, flgrp_name, flgrp_descrip, flgrp_subtotal, flgrp_summarize, flgrp_subtract, flgrp_showstart, flgrp_showend, flgrp_showdelta, flgrp_showbudget, flgrp_showdiff, flgrp_showcustom, flgrp_showstartprcnt, flgrp_showendprcnt, flgrp_showdeltaprcnt, flgrp_showbudgetprcnt, flgrp_showdiffprcnt, flgrp_showcustomprcnt, flgrp_usealtsubtotal, flgrp_altsubtotal,flgrp_prcnt_flgrp_id) SELECT _flgrpid, pFlheadid, pParentFlgrpid, flgrp_order, flgrp_name, flgrp_descrip, flgrp_subtotal, flgrp_summarize, flgrp_subtract, flgrp_showstart, flgrp_showend, flgrp_showdelta, flgrp_showbudget, flgrp_showdiff, flgrp_showcustom, flgrp_showstartprcnt, flgrp_showendprcnt, flgrp_showdeltaprcnt, flgrp_showbudgetprcnt, flgrp_showdiffprcnt, flgrp_showcustomprcnt, flgrp_usealtsubtotal, flgrp_altsubtotal,flgrp_prcnt_flgrp_id FROM flgrp WHERE (flgrp_id=pSourceGroup); -- Store temporary cross ref info EXECUTE ' INSERT INTO tmp_flgrpxref' || getEffectiveXtUser() || ' (flgrpxref_oldid,flgrpxref_newid) VALUES (' || pSourceGroup || ',' || _flgrpid || ');'; -- Copy any children flitems INSERT INTO flitem (flitem_flhead_id, flitem_flgrp_id, flitem_order, flitem_accnt_id, flitem_showstart, flitem_showend, flitem_showdelta, flitem_showbudget, flitem_showdiff, flitem_showcustom, flitem_subtract, flitem_showstartprcnt, flitem_showendprcnt, flitem_showdeltaprcnt, flitem_showbudgetprcnt, flitem_showdiffprcnt, flitem_showcustomprcnt, flitem_custom_source, flitem_company, flitem_profit, flitem_number, flitem_sub, flitem_type, flitem_subaccnttype_code, flitem_prcnt_flgrp_id) SELECT pFlheadid, _flgrpid, flitem_order, flitem_accnt_id, flitem_showstart, flitem_showend, flitem_showdelta, flitem_showbudget, flitem_showdiff, flitem_showcustom, flitem_subtract, flitem_showstartprcnt, flitem_showendprcnt, flitem_showdeltaprcnt, flitem_showbudgetprcnt, flitem_showdiffprcnt, flitem_showcustomprcnt, flitem_custom_source, flitem_company, flitem_profit, flitem_number, flitem_sub, flitem_type, flitem_subaccnttype_code, flitem_prcnt_flgrp_id FROM flitem WHERE (flitem_flgrp_id=pSourceGroup); -- Copy any children flspecs INSERT INTO flspec (flspec_flhead_id, flspec_flgrp_id, flspec_order, flspec_name, flspec_type, flspec_showstart, flspec_showend, flspec_showdelta, flspec_showbudget, flspec_showdiff, flspec_showcustom, flspec_subtract, flspec_showstartprcnt, flspec_showendprcnt, flspec_showdeltaprcnt, flspec_showbudgetprcnt, flspec_showdiffprcnt, flspec_showcustomprcnt, flspec_custom_source, flspec_prcnt_flgrp_id) SELECT pFlheadid, _flgrpid, flspec_order, flspec_name, flspec_type, flspec_showstart, flspec_showend, flspec_showdelta, flspec_showbudget, flspec_showdiff, flspec_showcustom, flspec_subtract, flspec_showstartprcnt, flspec_showendprcnt, flspec_showdeltaprcnt, flspec_showbudgetprcnt, flspec_showdiffprcnt, flspec_showcustomprcnt, flspec_custom_source, flspec_prcnt_flgrp_id FROM flspec WHERE (flspec_flgrp_id=pSourceGroup); -- Copy the groups PERFORM copyFinancialGroup(flgrp_id, pFlheadid, _flgrpid) FROM flgrp WHERE (flgrp_flgrp_id=pSourceGroup); RETURN _flgrpid; END; $_$; ALTER FUNCTION public.copyfinancialgroup(integer, integer, integer) OWNER TO admin; -- -- Name: copyfinanciallayout(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copyfinanciallayout(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSourceFlheadid ALIAS FOR $1; pDestName ALIAS FOR $2; _flheadid INTEGER; _tblName TEXT; BEGIN -- Check for the flhead to be copy that it exists PERFORM flhead_id FROM flhead WHERE (flhead_id=pSourceFlheadid); IF (NOT FOUND) THEN RETURN -1; END IF; -- Check that the name is valid IF (pDestName IS NULL OR pDestName = '') THEN RETURN -2; END IF; -- Check for the name to copy to does not exist PERFORM flhead_id FROM flhead WHERE (flhead_name=pDestName); IF (FOUND) THEN RETURN -3; END IF; -- Copy the flhead record SELECT nextval('flhead_flhead_id_seq') INTO _flheadid; INSERT INTO flhead (flhead_id, flhead_name, flhead_descrip, flhead_showtotal, flhead_showstart, flhead_showend, flhead_showdelta, flhead_showbudget, flhead_showdiff, flhead_showcustom, flhead_custom_label, flhead_usealttotal, flhead_alttotal, flhead_usealtbegin, flhead_altbegin, flhead_usealtend, flhead_altend, flhead_usealtdebits, flhead_altdebits, flhead_usealtcredits, flhead_altcredits, flhead_usealtbudget, flhead_altbudget, flhead_usealtdiff, flhead_altdiff, flhead_type, flhead_active, flhead_sys ) SELECT _flheadid, pDestName, flhead_descrip, flhead_showtotal, flhead_showstart, flhead_showend, flhead_showdelta, flhead_showbudget, flhead_showdiff, flhead_showcustom, flhead_custom_label, flhead_usealttotal, flhead_alttotal, flhead_usealtbegin, flhead_altbegin, flhead_usealtend, flhead_altend, flhead_usealtdebits, flhead_altdebits, flhead_usealtcredits, flhead_altcredits, flhead_usealtbudget, flhead_altbudget, flhead_usealtdiff, flhead_altdiff, flhead_type, flhead_active, false FROM flhead WHERE (flhead_id=pSourceFlheadid); -- Create temporary table so old and new group ids can be stored SELECT relname FROM pg_class INTO _tblName WHERE relname = 'tmp_flgrpxref'; IF (_tblName IS NULL) THEN EXECUTE 'CREATE TEMPORARY TABLE tmp_flgrpxref' || getEffectiveXtUser() || ' ( flgrpxref_oldid int4, flgrpxref_newid int4 ) ON COMMIT DROP;'; END IF; -- Copy the top level groups PERFORM copyFinancialGroup(flgrp_id, _flheadid, -1) FROM flgrp WHERE ((flgrp_flhead_id=pSourceFlheadid) AND (flgrp_flgrp_id=-1)); -- Update Group Percent settings EXECUTE 'UPDATE flgrp SET flgrp_prcnt_flgrp_id=flgrpxref_newid FROM tmp_flgrpxref' || getEffectiveXtUser() || ' WHERE ((flgrp_flhead_id=' || _flheadid || ') AND (flgrp_prcnt_flgrp_id=flgrpxref_oldid));'; EXECUTE 'UPDATE flitem SET flitem_prcnt_flgrp_id=flgrpxref_newid FROM tmp_flgrpxref' || getEffectiveXtUser() || ' WHERE ((flitem_flhead_id=' || _flheadid || ') AND (flitem_prcnt_flgrp_id=flgrpxref_oldid));'; EXECUTE 'UPDATE flspec SET flspec_prcnt_flgrp_id=flgrpxref_newid FROM tmp_flgrpxref' || getEffectiveXtUser() || ' WHERE ((flspec_flhead_id=' || _flheadid || ') AND (flspec_prcnt_flgrp_id=flgrpxref_oldid));'; -- Copy Column Layounts INSERT INTO flcol (flcol_flhead_id, flcol_name, flcol_descrip, flcol_report_id, flcol_month, flcol_quarter, flcol_year, flcol_showdb, flcol_prcnt, flcol_priortype, flcol_priormonth, flcol_priorquarter, flcol_prioryear, flcol_priorprcnt, flcol_priordiff, flcol_priordiffprcnt, flcol_budget, flcol_budgetprcnt, flcol_budgetdiff, flcol_budgetdiffprcnt ) SELECT _flheadid,flcol_name,flcol_descrip, flcol_report_id,flcol_month,flcol_quarter, flcol_year,flcol_showdb,flcol_prcnt, flcol_priortype,flcol_priormonth,flcol_priorquarter, flcol_prioryear,flcol_priorprcnt,flcol_priordiff, flcol_priordiffprcnt,flcol_budget,flcol_budgetprcnt, flcol_budgetdiff,flcol_budgetdiffprcnt FROM flcol WHERE (flcol_flhead_id=pSourceFlheadid); RETURN _flheadid; END; $_$; ALTER FUNCTION public.copyfinanciallayout(integer, text) OWNER TO admin; -- -- Name: copyglseries(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copyglseries(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; _sequence INTEGER := fetchGLSequence(); _journal INTEGER; BEGIN SELECT gltrans_journalnumber INTO _journal FROM gltrans WHERE ( gltrans_sequence=pSequence ) LIMIT 1; IF (FOUND) THEN INSERT INTO glseries ( glseries_sequence, glseries_source, glseries_doctype, glseries_docnumber, glseries_notes, glseries_accnt_id, glseries_amount, glseries_distdate ) SELECT _sequence, gltrans_source, gltrans_doctype, gltrans_docnumber, gltrans_notes, gltrans_accnt_id, gltrans_amount, gltrans_date FROM gltrans WHERE ( gltrans_sequence=pSequence ); ELSE RAISE EXCEPTION 'g/l transaction sequence not found'; END IF; RETURN _sequence; END; $_$; ALTER FUNCTION public.copyglseries(integer) OWNER TO admin; -- -- Name: copyincdt(integer, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copyincdt(integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pparentid ALIAS FOR $1; ptimestamp TIMESTAMP WITH TIME ZONE := COALESCE($2, CURRENT_TIMESTAMP); _alarmid INTEGER; _incdtid INTEGER; _todoitemid INTEGER; BEGIN INSERT INTO incdt(incdt_number, incdt_crmacct_id, incdt_cntct_id, incdt_summary, incdt_descrip, incdt_item_id, incdt_timestamp, incdt_incdtcat_id, incdt_incdtseverity_id,incdt_incdtpriority_id, incdt_owner_username, incdt_recurring_incdt_id ) SELECT fetchIncidentNumber(), incdt_crmacct_id, incdt_cntct_id, incdt_summary, incdt_descrip, incdt_item_id, ptimestamp, incdt_incdtcat_id, incdt_incdtseverity_id,incdt_incdtpriority_id, incdt_owner_username, incdt_recurring_incdt_id FROM incdt WHERE (incdt_id=pparentid) RETURNING incdt_id INTO _incdtid; IF (_incdtid IS NULL) THEN RETURN -10; END IF; SELECT MIN(copyTodoitem(todoitem_id, CAST(ptimestamp AS DATE), _incdtid)) INTO _todoitemid FROM todoitem WHERE (todoitem_incdt_id=pparentid); IF (_todoitemid < 0) THEN RETURN _todoitemid; END IF; SELECT saveAlarm(NULL, NULL, CAST(ptimestamp AS DATE), CAST(alarm_time - DATE_TRUNC('day',alarm_time) AS TIME), alarm_time_offset, alarm_time_qualifier, alarm_event_recipient IS NOT NULL, alarm_event_recipient, alarm_email_recipient IS NOT NULL, alarm_email_recipient, alarm_sysmsg_recipient IS NOT NULL, alarm_sysmsg_recipient, 'INCDT', _incdtid, 'CHANGEONE') INTO _alarmid FROM alarm WHERE ((alarm_source='INCDT') AND (alarm_source_id=pparentid)); IF (_alarmid < 0) THEN RETURN _alarmid; END IF; INSERT INTO docass (docass_source_id, docass_source_type, docass_target_id, docass_target_type, docass_purpose ) SELECT _incdtid, 'INCDT', docass_target_id, docass_target_type, docass_purpose FROM docass WHERE ((docass_source_id=pparentid) AND (docass_source_type='INCDT')); RETURN _incdtid; END; $_$; ALTER FUNCTION public.copyincdt(integer, timestamp with time zone) OWNER TO admin; -- -- Name: copyinvoice(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copyinvoice(integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvcheadid ALIAS FOR $1; _invcheadid INTEGER; _invcnumber TEXT; _invcdate DATE := COALESCE($2, CURRENT_DATE); _i RECORD; _l RECORD; _invcitemid INTEGER; BEGIN SELECT * INTO _i FROM invchead WHERE(invchead_id=pInvcheadid); IF(NOT FOUND) THEN RETURN -1; END IF; _invcnumber := fetchInvcNumber(); _invcheadid := nextval('invchead_invchead_id_seq'); INSERT INTO invchead (invchead_id, invchead_cust_id, invchead_shipto_id, invchead_ordernumber, invchead_orderdate, invchead_posted, invchead_printed, invchead_invcnumber, invchead_invcdate, invchead_shipdate, invchead_ponumber, invchead_shipvia, invchead_fob, invchead_billto_name, invchead_billto_address1, invchead_billto_address2, invchead_billto_address3, invchead_billto_city, invchead_billto_state, invchead_billto_zipcode, invchead_billto_phone, invchead_shipto_name, invchead_shipto_address1, invchead_shipto_address2, invchead_shipto_address3, invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode, invchead_shipto_phone, invchead_salesrep_id, invchead_commission, invchead_terms_id, invchead_freight, invchead_misc_amount, invchead_misc_descrip, invchead_misc_accnt_id, invchead_payment, invchead_paymentref, invchead_notes, invchead_billto_country, invchead_shipto_country, invchead_prj_id, invchead_curr_id, invchead_taxzone_id, invchead_recurring_invchead_id, invchead_saletype_id, invchead_shipzone_id) VALUES(_invcheadid, _i.invchead_cust_id, _i.invchead_shipto_id, _i.invchead_ordernumber, _i.invchead_orderdate, false, false, _invcnumber, _invcdate, _i.invchead_shipdate, _i.invchead_ponumber, _i.invchead_shipvia, _i.invchead_fob, _i.invchead_billto_name, _i.invchead_billto_address1, _i.invchead_billto_address2, _i.invchead_billto_address3, _i.invchead_billto_city, _i.invchead_billto_state, _i.invchead_billto_zipcode, _i.invchead_billto_phone, _i.invchead_shipto_name, _i.invchead_shipto_address1, _i.invchead_shipto_address2, _i.invchead_shipto_address3, _i.invchead_shipto_city, _i.invchead_shipto_state, _i.invchead_shipto_zipcode, _i.invchead_shipto_phone, _i.invchead_salesrep_id, _i.invchead_commission, _i.invchead_terms_id, _i.invchead_freight, _i.invchead_misc_amount, _i.invchead_misc_descrip, _i.invchead_misc_accnt_id, _i.invchead_payment, _i.invchead_paymentref, _i.invchead_notes, _i.invchead_billto_country, _i.invchead_shipto_country, _i.invchead_prj_id, _i.invchead_curr_id, _i.invchead_taxzone_id, _i.invchead_recurring_invchead_id, _i.invchead_saletype_id, _i.invchead_shipzone_id); FOR _l IN SELECT * FROM invcitem WHERE (invcitem_invchead_id=pInvcheadid) LOOP SELECT NEXTVAL('invcitem_invcitem_id_seq') INTO _invcitemid; INSERT INTO invcitem (invcitem_id, invcitem_invchead_id, invcitem_linenumber, invcitem_item_id, invcitem_warehous_id, invcitem_custpn, invcitem_number, invcitem_descrip, invcitem_ordered, invcitem_billed, invcitem_custprice, invcitem_price, invcitem_notes, invcitem_salescat_id, invcitem_taxtype_id, invcitem_qty_uom_id, invcitem_qty_invuomratio, invcitem_price_uom_id, invcitem_price_invuomratio, invcitem_coitem_id) VALUES (_invcitemid, _invcheadid, _l.invcitem_linenumber, _l.invcitem_item_id, _l.invcitem_warehous_id, _l.invcitem_custpn, _l.invcitem_number, _l.invcitem_descrip, _l.invcitem_ordered, _l.invcitem_billed, _l.invcitem_custprice, _l.invcitem_price, _l.invcitem_notes, _l.invcitem_salescat_id, _l.invcitem_taxtype_id, _l.invcitem_qty_uom_id, _l.invcitem_qty_invuomratio, _l.invcitem_price_uom_id, _l.invcitem_price_invuomratio, _l.invcitem_coitem_id); END LOOP; RETURN _invcheadid; END; $_$; ALTER FUNCTION public.copyinvoice(integer, date) OWNER TO admin; -- -- Name: copyitem(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copyitem(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSItemid ALIAS FOR $1; pTItemNumber ALIAS FOR $2; _itemid INTEGER; _r RECORD; _id INTEGER; BEGIN SELECT NEXTVAL('item_item_id_seq') INTO _itemid; INSERT INTO item ( item_id, item_number, item_descrip1, item_descrip2, item_classcode_id, item_type, item_active, item_picklist, item_sold, item_fractional, item_maxcost, item_prodweight, item_packweight, item_prodcat_id,item_exclusive, item_listprice, item_listcost, item_config, item_comments, item_extdescrip, item_upccode, item_inv_uom_id, item_price_uom_id ) SELECT _itemid, pTItemNumber, item_descrip1, item_descrip2, item_classcode_id, item_type, item_active, item_picklist, item_sold, item_fractional, item_maxcost, item_prodweight, item_packweight, item_prodcat_id, item_exclusive, item_listprice, item_listcost, item_config, item_comments, item_extdescrip, item_upccode, item_inv_uom_id, item_price_uom_id FROM item WHERE (item_id=pSItemid); INSERT INTO imageass (imageass_source_id, imageass_source, imageass_image_id, imageass_purpose) SELECT _itemid, 'I', imageass_image_id, imageass_purpose FROM imageass WHERE ((imageass_source_id=pSItemid) AND (imageass_source='I')); INSERT INTO url (url_source_id, url_source, url_title, url_url) SELECT _itemid, 'I', url_title, url_url FROM url WHERE ((url_source_id=pSItemid) AND (url_source='I')); INSERT INTO itemtax (itemtax_item_id, itemtax_taxzone_id, itemtax_taxtype_id) SELECT _itemid, itemtax_taxzone_id, itemtax_taxtype_id FROM itemtax WHERE(itemtax_item_id=pSItemid); INSERT INTO charass ( charass_target_type, charass_target_id, charass_char_id, charass_value ) SELECT 'I', _itemid, charass_char_id, charass_value FROM charass WHERE ( (charass_target_type='I') AND (charass_target_id=pSItemid) ); FOR _r IN SELECT itemuomconv_id, itemuomconv_from_uom_id, itemuomconv_from_value, itemuomconv_to_uom_id, itemuomconv_to_value, itemuomconv_fractional FROM itemuomconv WHERE(itemuomconv_item_id=pSItemid) LOOP SELECT nextval('itemuomconv_itemuomconv_id_seq') INTO _id; INSERT INTO itemuomconv (itemuomconv_id, itemuomconv_item_id, itemuomconv_from_uom_id, itemuomconv_from_value, itemuomconv_to_uom_id, itemuomconv_to_value, itemuomconv_fractional) VALUES(_id, _itemid, _r.itemuomconv_from_uom_id, _r.itemuomconv_from_value, _r.itemuomconv_to_uom_id, _r.itemuomconv_to_value, _r.itemuomconv_fractional); INSERT INTO itemuom (itemuom_itemuomconv_id, itemuom_uomtype_id) SELECT _id, itemuom_uomtype_id FROM itemuom WHERE(itemuom_itemuomconv_id=_r.itemuomconv_id); END LOOP; RETURN _itemid; END; $_$; ALTER FUNCTION public.copyitem(integer, text) OWNER TO admin; -- -- Name: copyitem(integer, text, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copyitem(integer, text, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSItemid ALIAS FOR $1; pTItemNumber ALIAS FOR $2; pCopyBOM ALIAS FOR $3; pCopyCosts ALIAS FOR $4; _itemid INTEGER; BEGIN _itemid := copyItem(pSItemid, pTItemNumber); IF (pCopyBOM) THEN PERFORM copyBOM(pSItemid, _itemid, FALSE); END IF; IF (pCopyCosts) THEN INSERT INTO itemcost ( itemcost_item_id, itemcost_costelem_id, itemcost_lowlevel, itemcost_stdcost, itemcost_posted, itemcost_actcost, itemcost_curr_id, itemcost_updated ) SELECT _itemid, itemcost_costelem_id, itemcost_lowlevel, itemcost_stdcost, CURRENT_DATE, itemcost_actcost, itemcost_curr_id, CURRENT_DATE FROM itemcost WHERE (itemcost_item_id=pSItemid); END IF; RETURN _itemid; END; $_$; ALTER FUNCTION public.copyitem(integer, text, boolean, boolean) OWNER TO admin; -- -- Name: copyitem(integer, text, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copyitem(integer, text, boolean, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSItemid ALIAS FOR $1; pTItemNumber ALIAS FOR $2; pCopyBOM ALIAS FOR $3; pCopyBOO ALIAS FOR $4; -- deprecated - xtmfg-specific pCopyCosts ALIAS FOR $5; BEGIN RAISE WARNING 'copyItem(INTEGER, TEXT, BOOLEAN, BOOLEAN, BOOLEAN) has been deprecated. Use copyItem(INTEGER, TEXT) or copyItem(INTEGER, TEXT, BOOLEAN, BOOLEAN) or a package-specific version instead.'; RETURN copyItem(pSItemid, pTItemNumber, pCopyBOM, pCopyCosts); END; $_$; ALTER FUNCTION public.copyitem(integer, text, boolean, boolean, boolean) OWNER TO admin; -- -- Name: copyitem(integer, text, boolean, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copyitem(integer, text, boolean, boolean, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSItemid ALIAS FOR $1; pTItemNumber ALIAS FOR $2; pCopyBOM ALIAS FOR $3; pCopyBOO ALIAS FOR $4; -- deprecated - xtmfg-specific pCopyCosts ALIAS FOR $5; pCopyUsedAt ALIAS FOR $6; -- deprecated - xtmfg-specific BEGIN RETURN copyItem(pSItemid, pTItemNumber, pCopyBOM, pCopyCosts); END; $_$; ALTER FUNCTION public.copyitem(integer, text, boolean, boolean, boolean, boolean) OWNER TO admin; -- -- Name: copyitemsite(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copyitemsite(pitemsiteid integer, pdestwhsid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN copyItemSite(pItemsiteid, pDestWhsid, NULL); END; $$; ALTER FUNCTION public.copyitemsite(pitemsiteid integer, pdestwhsid integer) OWNER TO admin; -- -- Name: copyitemsite(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copyitemsite(pitemsiteid integer, pdestwhsid integer, pdestitemid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _destwhs whsinfo%ROWTYPE; _new itemsite%ROWTYPE; _supplywarehousid INTEGER := NULL; BEGIN -- make a copy of the old itemsite SELECT * INTO _new FROM itemsite WHERE (itemsite_id=pItemsiteid); IF (NOT FOUND) THEN RETURN -1; END IF; -- if there is no dest warehouse then perhaps the user is manually copying it IF (pDestWhsid IS NOT NULL) THEN SELECT * INTO _destwhs FROM whsinfo WHERE (warehous_id=pDestWhsid); IF (NOT FOUND) THEN RETURN -2; END IF; END IF; IF (NOT checkPrivilege('MaintainItemSites')) THEN RETURN -3; END IF; SELECT itemsite_id INTO _new.itemsite_id FROM itemsite WHERE ((itemsite_item_id=COALESCE(pDestItemid, _new.itemsite_item_id)) AND (itemsite_warehous_id=pDestWhsid OR (itemsite_warehous_id IS NULL AND pDestWhsid IS NULL))); IF (FOUND) THEN RETURN _new.itemsite_id; END IF; -- find supply itemsite IF (_new.itemsite_supply_itemsite_id IS NOT NULL) THEN SELECT itemsite_warehous_id INTO _supplywarehousid FROM itemsite WHERE (itemsite_id=_new.itemsite_supply_itemsite_id); IF (FOUND) THEN SELECT itemsite_id INTO _new.itemsite_supply_itemsite_id FROM itemsite WHERE (itemsite_warehous_id=_supplywarehousid) AND (itemsite_item_id=pDestItemid); END IF; END IF; -- now override the things we know have to change _new.itemsite_id := NEXTVAL('itemsite_itemsite_id_seq'); _new.itemsite_warehous_id := pDestWhsid; _new.itemsite_qtyonhand := 0; _new.itemsite_value := 0; _new.itemsite_datelastcount := NULL; _new.itemsite_datelastused := NULL; _new.itemsite_location_id := -1; _new.itemsite_recvlocation_id := -1; _new.itemsite_issuelocation_id := -1; _new.itemsite_location_dist := FALSE; _new.itemsite_recvlocation_dist := FALSE; _new.itemsite_issuelocation_dist := FALSE; IF (_destwhs.warehous_transit) THEN _new.itemsite_reorderlevel := 0; _new.itemsite_ordertoqty := 0; _new.itemsite_soldranking := NULL; _new.itemsite_posupply := FALSE; _new.itemsite_wosupply := FALSE; _new.itemsite_loccntrl := FALSE; _new.itemsite_safetystock := 0; _new.itemsite_minordqty := 0; _new.itemsite_multordqty := 0; _new.itemsite_leadtime := 0; _new.itemsite_controlmethod := 'R'; IF(_new.itemsite_costmethod='N') THEN _new.itemsite_costmethod := 'S'; END IF; _new.itemsite_active := TRUE; -- ? _new.itemsite_plancode_id := -1; -- ? _new.itemsite_costcat_id := -1; _new.itemsite_eventfence := 1; _new.itemsite_sold := FALSE; _new.itemsite_stocked := FALSE; _new.itemsite_location_id := -1; _new.itemsite_useparams := FALSE; _new.itemsite_useparamsmanual := FALSE; _new.itemsite_createpr := FALSE; _new.itemsite_location := NULL; _new.itemsite_location_comments := NULL; _new.itemsite_notes := 'Transit Warehouse'; _new.itemsite_createwo := FALSE; _new.itemsite_costcat_id := _destwhs.warehous_costcat_id; _new.itemsite_supply_itemsite_id := NULL; END IF; INSERT INTO itemsite ( itemsite_id, itemsite_item_id, itemsite_warehous_id, itemsite_qtyonhand, itemsite_costmethod, itemsite_value, itemsite_reorderlevel, itemsite_ordertoqty, itemsite_cyclecountfreq, itemsite_datelastcount, itemsite_datelastused, itemsite_posupply, itemsite_wosupply, itemsite_loccntrl, itemsite_safetystock, itemsite_minordqty, itemsite_multordqty, itemsite_leadtime, itemsite_abcclass, itemsite_issuemethod, itemsite_controlmethod, itemsite_active, itemsite_plancode_id, itemsite_costcat_id, itemsite_eventfence, itemsite_sold, itemsite_stocked, itemsite_freeze, itemsite_location_id, itemsite_useparams, itemsite_useparamsmanual, itemsite_soldranking, itemsite_createpr, itemsite_location, itemsite_location_comments, itemsite_notes, itemsite_perishable, itemsite_autoabcclass, itemsite_ordergroup, itemsite_disallowblankwip, itemsite_maxordqty, itemsite_mps_timefence, itemsite_createwo, itemsite_warrpurc, itemsite_autoreg, itemsite_planning_type, itemsite_supply_itemsite_id, itemsite_createsopr, itemsite_createsopo, itemsite_dropship, itemsite_recvlocation_id, itemsite_issuelocation_id, itemsite_location_dist, itemsite_recvlocation_dist, itemsite_issuelocation_dist ) VALUES ( _new.itemsite_id, COALESCE(pDestItemid, _new.itemsite_item_id), _new.itemsite_warehous_id, _new.itemsite_qtyonhand, _new.itemsite_costmethod, _new.itemsite_value, _new.itemsite_reorderlevel, _new.itemsite_ordertoqty, _new.itemsite_cyclecountfreq, _new.itemsite_datelastcount, _new.itemsite_datelastused, _new.itemsite_posupply, _new.itemsite_wosupply, _new.itemsite_loccntrl, _new.itemsite_safetystock, _new.itemsite_minordqty, _new.itemsite_multordqty, _new.itemsite_leadtime, _new.itemsite_abcclass, _new.itemsite_issuemethod, _new.itemsite_controlmethod, _new.itemsite_active, _new.itemsite_plancode_id, _new.itemsite_costcat_id, _new.itemsite_eventfence, _new.itemsite_sold, _new.itemsite_stocked, _new.itemsite_freeze, _new.itemsite_location_id, _new.itemsite_useparams, _new.itemsite_useparamsmanual, _new.itemsite_soldranking, _new.itemsite_createpr, _new.itemsite_location, _new.itemsite_location_comments, _new.itemsite_notes, _new.itemsite_perishable, _new.itemsite_autoabcclass, _new.itemsite_ordergroup, _new.itemsite_disallowblankwip, _new.itemsite_maxordqty, _new.itemsite_mps_timefence, _new.itemsite_createwo, _new.itemsite_warrpurc, _new.itemsite_autoreg, _new.itemsite_planning_type, _new.itemsite_supply_itemsite_id, _new.itemsite_createsopr, _new.itemsite_createsopo, _new.itemsite_dropship, _new.itemsite_recvlocation_id, _new.itemsite_issuelocation_id, _new.itemsite_location_dist, _new.itemsite_recvlocation_dist, _new.itemsite_issuelocation_dist ); RETURN _new.itemsite_id; END; $$; ALTER FUNCTION public.copyitemsite(pitemsiteid integer, pdestwhsid integer, pdestitemid integer) OWNER TO admin; -- -- Name: copylocale(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copylocale(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLocaleid ALIAS FOR $1; _localecode TEXT; _localeid INTEGER; BEGIN SELECT locale_code INTO _localecode FROM locale WHERE (locale_id=pLocaleid); IF (NOT FOUND) THEN RAISE EXCEPTION 'Attempt to copy a non-existent locale-id.'; END IF; IF (EXISTS(SELECT locale_id FROM locale WHERE (locale_code = (_localecode || '-COPY')))) THEN RAISE EXCEPTION 'Attempt to copy a Locale Code that already exists.'; END IF; SELECT NEXTVAL('locale_locale_id_seq') INTO _localeid; INSERT INTO locale (locale_id, locale_code, locale_descrip, locale_lang_file, locale_dateformat, locale_currformat, locale_qtyformat, locale_comments, locale_qtyperformat, locale_salespriceformat, locale_extpriceformat, locale_timeformat, locale_timestampformat, local_costformat, locale_costformat, locale_purchpriceformat, locale_uomratioformat, locale_intervalformat, locale_lang_id, locale_country_id, locale_error_color, locale_warning_color, locale_emphasis_color, locale_altemphasis_color, locale_expired_color, locale_future_color, locale_curr_scale, locale_salesprice_scale, locale_purchprice_scale, locale_extprice_scale, locale_cost_scale, locale_qty_scale, locale_qtyper_scale, locale_uomratio_scale) SELECT _localeid, locale_code || '-COPY', '', locale_lang_file, locale_dateformat, locale_currformat, locale_qtyformat, locale_comments, locale_qtyperformat, locale_salespriceformat, locale_extpriceformat, locale_timeformat, locale_timestampformat, local_costformat, locale_costformat, locale_purchpriceformat, locale_uomratioformat, locale_intervalformat, locale_lang_id, locale_country_id, locale_error_color, locale_warning_color, locale_emphasis_color, locale_altemphasis_color, locale_expired_color, locale_future_color, locale_curr_scale, locale_salesprice_scale, locale_purchprice_scale, locale_extprice_scale, locale_cost_scale, locale_qty_scale, locale_qtyper_scale, locale_uomratio_scale FROM locale WHERE(locale_id=pLocaleid); RETURN _localeid; END; $_$; ALTER FUNCTION public.copylocale(integer) OWNER TO admin; -- -- Name: copypo(integer, integer, date, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copypo(integer, integer, date, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSrcid ALIAS FOR $1; pVendid ALIAS FOR $2; pOrderdate ALIAS FOR $3; pRecheckVendinfo ALIAS FOR $4; _tgtid INTEGER; _orderdate DATE; _head RECORD; _itemsrc RECORD; _lineitem RECORD; _qty NUMERIC; _unitprice NUMERIC; _uomratio NUMERIC; _vend_restrictpurch BOOLEAN; BEGIN SELECT * INTO _head FROM pohead WHERE pohead_id = pSrcid; IF (NOT FOUND) THEN RETURN -1; END IF; IF (_head.pohead_vend_id != pVendid) THEN RETURN -2; -- not supported now but should be in the future END IF; -- when enabled, set pRecheckVendinfo if vendors don't match IF (pOrderdate IS NULL) THEN _orderdate := CURRENT_DATE; ELSE _orderdate := pOrderdate; END IF; INSERT INTO pohead (pohead_status, pohead_number, pohead_orderdate, pohead_vend_id, pohead_fob, pohead_shipvia, pohead_freight, pohead_printed, pohead_terms_id, pohead_warehous_id, pohead_vendaddr_id, pohead_agent_username, pohead_curr_id, pohead_saved, pohead_taxtype_id, pohead_taxzone_id, pohead_dropship, pohead_vend_cntct_id, pohead_vend_cntct_honorific, pohead_vend_cntct_first_name, pohead_vend_cntct_middle, pohead_vend_cntct_last_name, pohead_vend_cntct_suffix, pohead_vend_cntct_phone, pohead_vend_cntct_title, pohead_vend_cntct_fax, pohead_vend_cntct_email, pohead_vendaddress1, pohead_vendaddress2, pohead_vendaddress3, pohead_vendcity, pohead_vendstate, pohead_vendzipcode, pohead_vendcountry, pohead_shipto_cntct_id, pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name, pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name, pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone, pohead_shipto_cntct_title, pohead_shipto_cntct_fax, pohead_shipto_cntct_email, pohead_shiptoaddress_id, pohead_shiptoaddress1, pohead_shiptoaddress2, pohead_shiptoaddress3, pohead_shiptocity, pohead_shiptostate, pohead_shiptozipcode, pohead_shiptocountry ) VALUES ( 'U', fetchPoNumber(), _orderdate, _head.pohead_vend_id, _head.pohead_fob, _head.pohead_shipvia, _head.pohead_freight, false, _head.pohead_terms_id, _head.pohead_warehous_id, _head.pohead_vendaddr_id, _head.pohead_agent_username, _head.pohead_curr_id, true, _head.pohead_taxtype_id, _head.pohead_taxzone_id, false, _head.pohead_vend_cntct_id, _head.pohead_vend_cntct_honorific, _head.pohead_vend_cntct_first_name, _head.pohead_vend_cntct_middle, _head.pohead_vend_cntct_last_name, _head.pohead_vend_cntct_suffix, _head.pohead_vend_cntct_phone, _head.pohead_vend_cntct_title, _head.pohead_vend_cntct_fax, _head.pohead_vend_cntct_email, _head.pohead_vendaddress1, _head.pohead_vendaddress2, _head.pohead_vendaddress3, _head.pohead_vendcity, _head.pohead_vendstate, _head.pohead_vendzipcode, _head.pohead_vendcountry, _head.pohead_shipto_cntct_id, _head.pohead_shipto_cntct_honorific, _head.pohead_shipto_cntct_first_name, _head.pohead_shipto_cntct_middle, _head.pohead_shipto_cntct_last_name, _head.pohead_shipto_cntct_suffix, _head.pohead_shipto_cntct_phone, _head.pohead_shipto_cntct_title, _head.pohead_shipto_cntct_fax, _head.pohead_shipto_cntct_email, _head.pohead_shiptoaddress_id, _head.pohead_shiptoaddress1, _head.pohead_shiptoaddress2, _head.pohead_shiptoaddress3, _head.pohead_shiptocity, _head.pohead_shiptostate, _head.pohead_shiptozipcode, _head.pohead_shiptocountry); _tgtid := CURRVAL('pohead_pohead_id_seq'); IF (pRecheckVendinfo) THEN SELECT vend_restrictpurch INTO _vend_restrictpurch FROM vendinfo WHERE (vend_id = pVendid); FOR _lineitem IN SELECT * FROM poitem WHERE (poitem_pohead_id = pSrcid) LOOP SELECT * INTO _itemsrc FROM itemsrc, itemsite WHERE (itemsrc_active AND (itemsrc_id = _lineitem.poitem_itemsrc_id) AND (itemsite_id = _lineitem.poitem_itemsite_id)); IF (NOT FOUND AND _vend_restrictpurch) THEN RETURN -3; END IF; -- handle changes to the uom ratio and consequent qty changes _uomratio := COALESCE(_itemsrc.itemsrc_invvendoruomratio, _lineitem.poitem_invvenduomratio); IF (_itemsrc.itemsrc_invvendoruomratio IS NULL OR _itemsrc.itemsrc_invvendoruomratio != _lineitem.poitem_invvenduomratio) THEN _qty := _lineitem.poitem_qty_ordered; ELSE _qty := _lineitem.poitem_qty_ordered * _lineitem.poitem_invvenduomratio / _itemsrc.itemsrc_invvendoruomratio; IF (_itemsrc.itemsrc_minordqty IS NOT NULL) THEN IF (_qty < _itemsrc.itemsrc_minordqty) THEN _qty := _itemsrc.itemsrc_minordqty; ELSIF (_itemsrc.itemsrc_multordqty > 0 AND _qty % _itemsrc.itemsrc_multordqty > 0) THEN _qty = _qty % _itemsrc.itemsrc_multordqty + _itemsrc.itemsrc_multordqty; END IF; END IF; END IF; IF (_itemsrc.itemsrc_id IS NULL) THEN _unitprice = _lineitem.poitem_unitprice; ELSE SELECT itemsrcPrice(_itemsrc.itemsrc_id, _head.pohead_warehous_id, _head.pohead_dropship, _lineitem.poitem_qty_ordered, _head.pohead_curr_id, CURRENT_DATE) INTO _unitprice; IF (_unitprice IS NULL) THEN RETURN -4; END IF; END IF; INSERT INTO poitem (poitem_status, poitem_pohead_id, poitem_linenumber, poitem_duedate, poitem_itemsite_id, poitem_vend_item_descrip, poitem_vend_uom, poitem_invvenduomratio, poitem_qty_ordered, poitem_unitprice, poitem_vend_item_number, poitem_comments, poitem_expcat_id, poitem_itemsrc_id, poitem_freight, poitem_stdcost, poitem_manuf_name, poitem_manuf_item_number, poitem_manuf_item_descrip, poitem_taxtype_id ) VALUES ( 'U', _tgtid, _lineitem.poitem_linenumber, _orderdate + COALESCE(_itemsrc.itemsrc_leadtime, 0), _lineitem.poitem_itemsite_id, COALESCE(_itemsrc.itemsrc_vend_item_descrip, _lineitem.poitem_vend_item_descrip), COALESCE(_itemsrc.itemsrc_vend_uom, _lineitem.poitem_vend_uom), COALESCE(_itemsrc.itemsrc_invvendoruomratio, _lineitem.poitem_invvenduomratio), _qty, _unitprice, COALESCE(_itemsrc.itemsrc_vend_item_number, _lineitem.poitem_vend_item_number), _lineitem.poitem_comments, _lineitem.poitem_expcat_id, COALESCE(_itemsrc.itemsrc_id, -1), _lineitem.poitem_freight, stdcost(_itemsrc.itemsite_item_id), COALESCE(_itemsrc.itemsrc_manuf_name, _lineitem.poitem_manuf_name), COALESCE(_itemsrc.itemsrc_manuf_item_number, _lineitem.poitem_manuf_item_number), COALESCE(_itemsrc.itemsrc_manuf_item_descrip, _lineitem.poitem_manuf_item_descrip), _lineitem.poitem_taxtype_id); END LOOP; ELSE INSERT INTO poitem (poitem_status, poitem_pohead_id, poitem_linenumber, poitem_duedate, poitem_itemsite_id, poitem_vend_item_descrip, poitem_vend_uom, poitem_invvenduomratio, poitem_qty_ordered, poitem_unitprice, poitem_vend_item_number, poitem_comments, poitem_expcat_id, poitem_itemsrc_id, poitem_freight, poitem_stdcost, poitem_manuf_name, poitem_manuf_item_number, poitem_manuf_item_descrip, poitem_taxtype_id ) SELECT 'U', _tgtid, poitem_linenumber, _orderdate + COALESCE(itemsrc_leadtime, 0), poitem_itemsite_id, poitem_vend_item_descrip, poitem_vend_uom, poitem_invvenduomratio, poitem_qty_ordered, poitem_unitprice, poitem_vend_item_number, poitem_comments, poitem_expcat_id, poitem_itemsrc_id, poitem_freight, stdcost(itemsite_item_id), poitem_manuf_name, poitem_manuf_item_number, poitem_manuf_item_descrip, poitem_taxtype_id FROM poitem LEFT OUTER JOIN itemsrc ON (itemsrc_id=poitem_itemsrc_id) LEFT OUTER JOIN itemsite ON (itemsite_id=poitem_itemsite_id) WHERE (poitem_pohead_id = pSrcid); END IF; -- Todo: recalculate tax? RETURN _tgtid; END; $_$; ALTER FUNCTION public.copypo(integer, integer, date, boolean) OWNER TO admin; -- -- Name: copypricingschedule(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copypricingschedule(pipsheadid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _ipsheadid INTEGER; _ipsitemid INTEGER; _ipsfreightid INTEGER; _x RECORD; BEGIN _ipsheadid := nextval('ipshead_ipshead_id_seq'); INSERT INTO ipshead ( ipshead_id, ipshead_name, ipshead_descrip, ipshead_effective, ipshead_expires, ipshead_curr_id, ipshead_updated ) SELECT _ipsheadid, orig.ipshead_name || (SELECT CAST((COUNT(cnt.ipshead_id)+1) AS text) FROM ipshead cnt WHERE (SUBSTRING(cnt.ipshead_name FROM 0 FOR char_length(orig.ipshead_name)+1) = orig.ipshead_name)), orig.ipshead_descrip, orig.ipshead_effective, orig.ipshead_expires, orig.ipshead_curr_id, CURRENT_DATE FROM ipshead orig WHERE (orig.ipshead_id=pIpsheadId); FOR _x IN SELECT ipsitem_id FROM ipsiteminfo WHERE (ipsitem_ipshead_id=pIpsheadid) LOOP INSERT INTO ipsiteminfo (ipsitem_ipshead_id, ipsitem_item_id, ipsitem_prodcat_id, ipsitem_qtybreak, ipsitem_price, ipsitem_qty_uom_id, ipsitem_price_uom_id, ipsitem_discntprcnt, ipsitem_fixedamtdiscount, ipsitem_type, ipsitem_warehous_id) SELECT _ipsheadid, ipsitem_item_id, ipsitem_prodcat_id, ipsitem_qtybreak, ipsitem_price, ipsitem_qty_uom_id, ipsitem_price_uom_id, ipsitem_discntprcnt, ipsitem_fixedamtdiscount, ipsitem_type, ipsitem_warehous_id FROM ipsiteminfo WHERE (ipsitem_id=_x.ipsitem_id) RETURNING ipsitem_id INTO _ipsitemid; INSERT INTO ipsitemchar ( ipsitemchar_ipsitem_id, ipsitemchar_char_id, ipsitemchar_value, ipsitemchar_price) SELECT _ipsitemid, ipsitemchar_char_id, ipsitemchar_value, ipsitemchar_price FROM ipsitemchar WHERE (ipsitemchar_ipsitem_id=_x.ipsitem_id); END LOOP; FOR _x IN SELECT ipsfreight_id FROM ipsfreight WHERE (ipsfreight_ipshead_id=pIpsheadid) LOOP _ipsfreightid := nextval('ipsfreight_ipsfreight_id_seq'); INSERT INTO ipsfreight (ipsfreight_id, ipsfreight_ipshead_id, ipsfreight_qtybreak, ipsfreight_price, ipsfreight_type, ipsfreight_warehous_id, ipsfreight_shipzone_id,ipsfreight_freightclass_id, ipsfreight_shipvia) SELECT _ipsfreightid, _ipsheadid, ipsfreight_qtybreak, ipsfreight_price,ipsfreight_type, ipsfreight_warehous_id,ipsfreight_shipzone_id, ipsfreight_freightclass_id,ipsfreight_shipvia FROM ipsfreight WHERE (ipsfreight_id=_x.ipsfreight_id); END LOOP; RETURN _ipsheadid; END; $$; ALTER FUNCTION public.copypricingschedule(pipsheadid integer) OWNER TO admin; -- -- Name: copyprj(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copyprj(integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pparentid ALIAS FOR $1; _counter INTEGER; _duedate DATE := COALESCE($2, CURRENT_DATE); _alarmid INTEGER; _i INTEGER; _newnumber TEXT; _p RECORD; _prjid INTEGER; _testnumber TEXT; BEGIN RAISE DEBUG 'copyPrj(%, %) entered', pparentid, _duedate; SELECT * INTO _p FROM prj WHERE (prj_id=pparentid); -- new number = old number up to but not including -, followed by _duedate -- e.g. REPAIR-FRIDGE becomes REPAIR-2010-05-15 -- but REPAIR_FRIDGE becomes REPAIR_FRIDGE-2010-05-15 IF (_p.prj_recurring_prj_id IS NULL) THEN _newnumber := _p.prj_number; ELSE _newnumber := SUBSTRING(_p.prj_number FROM '[^-]*'); IF (_newnumber IS NULL) THEN _newnumber := _p.prj_number; END IF; END IF; _newnumber := _newnumber || '-' || to_char(_duedate, 'YYYY-MM-DD'); RAISE DEBUG 'copyPrj checking if _newnumber % exists', _newnumber; SELECT MAX(prj_number) INTO _testnumber FROM prj WHERE (prj_number ~ ('^' || _newnumber)); IF (_testnumber = _newnumber) THEN _newnumber := _newnumber || '-001'; ELSIF (_testnumber IS NOT NULL) THEN _counter := CAST(SUBSTRING(_testnumber FROM '...$') AS INTEGER); _counter := _counter + 1; _newnumber := REGEXP_REPLACE(_testnumber, '...$', to_char(_counter, 'FM009')); END IF; RAISE DEBUG 'copyPrj _newnumber is now %', _newnumber; INSERT INTO prj( prj_number, prj_name, prj_descrip, prj_status, prj_so, prj_wo, prj_po, prj_owner_username, prj_prjtype_id, prj_due_date, prj_username, prj_recurring_prj_id ) SELECT _newnumber, _p.prj_name, _p.prj_descrip, 'P', _p.prj_so, _p.prj_wo, _p.prj_po, _p.prj_owner_username, _p.prj_prjtype_id, _duedate, _p.prj_username, _p. prj_recurring_prj_id FROM prj WHERE (prj_id=pparentid) RETURNING prj_id INTO _prjid; IF (_prjid IS NULL) THEN RETURN -1; END IF; SELECT saveAlarm(NULL, NULL, _duedate, CAST(alarm_time - DATE_TRUNC('day',alarm_time) AS TIME), alarm_time_offset, alarm_time_qualifier, alarm_event_recipient IS NOT NULL, alarm_event_recipient, alarm_email_recipient IS NOT NULL, alarm_email_recipient, alarm_sysmsg_recipient IS NOT NULL, alarm_sysmsg_recipient, 'J', _prjid, 'CHANGEONE') INTO _alarmid FROM alarm WHERE ((alarm_source='J') AND (alarm_source_id=pparentid)); IF (_alarmid < 0) THEN RETURN _alarmid; END IF; RETURN _prjid; END; $_$; ALTER FUNCTION public.copyprj(integer, date) OWNER TO admin; -- -- Name: copyproject(integer, text, text, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copyproject(integer, text, text, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrjId ALIAS FOR $1; pPrjNumber ALIAS FOR $2; pPrjName ALIAS FOR $3; pDueDate ALIAS FOR $4; _prjid INTEGER; _offset INTEGER; BEGIN IF (COALESCE(pPrjNumber, '') = '') THEN RETURN -1; END IF; IF (COALESCE(pPrjName, '') = '') THEN RETURN -1; END IF; IF (EXISTS(SELECT prj_id FROM prj WHERE UPPER(prj_number)=UPPER(pPrjNumber))) THEN RETURN -2; END IF; IF (NOT EXISTS(SELECT prj_id FROM prj WHERE prj_id=pPrjId)) THEN RETURN -3; END IF; IF (pDueDate IS NULL) THEN RETURN -4; END IF; SELECT (pDueDate - prj_due_date) INTO _offset FROM prj WHERE (prj_id=pPrjId); SELECT NEXTVAL('prj_prj_id_seq') INTO _prjid; INSERT INTO prj ( prj_id, prj_number, prj_name, prj_descrip, prj_status, prj_prjtype_id, prj_so, prj_wo, prj_po, prj_owner_username, prj_start_date, prj_due_date, prj_assigned_date, prj_completed_date, prj_username, prj_recurring_prj_id, prj_crmacct_id, prj_cntct_id ) SELECT _prjid, UPPER(pPrjNumber), pPrjName, prj_descrip, 'P', prj_prjtype_id, prj_so, prj_wo, prj_po, prj_owner_username, NULL, (prj_due_date + COALESCE(_offset, 0)), CASE WHEN (prj_username IS NULL) THEN NULL ELSE CURRENT_DATE END, NULL, prj_username, prj_recurring_prj_id, prj_crmacct_id, prj_cntct_id FROM prj WHERE (prj_id=pPrjId); INSERT INTO prjtask ( prjtask_number, prjtask_name, prjtask_descrip, prjtask_prj_id, prjtask_anyuser, prjtask_status, prjtask_hours_budget, prjtask_hours_actual, prjtask_exp_budget, prjtask_exp_actual, prjtask_owner_username, prjtask_start_date, prjtask_due_date, prjtask_assigned_date, prjtask_completed_date, prjtask_username ) SELECT prjtask_number, prjtask_name, prjtask_descrip, _prjid, prjtask_anyuser, 'P', prjtask_hours_budget, 0.0, prjtask_exp_budget, 0.0, prjtask_owner_username, NULL, (prjtask_due_date + COALESCE(_offset, 0)), CASE WHEN (prjtask_username IS NULL) THEN NULL ELSE CURRENT_DATE END, NULL, prjtask_username FROM prjtask WHERE (prjtask_prj_id=pPrjId); INSERT INTO docass ( docass_source_id, docass_source_type, docass_target_id, docass_target_type, docass_purpose ) SELECT _prjid, docass_source_type, docass_target_id, docass_target_type, docass_purpose FROM docass WHERE ((docass_source_id=pPrjId) AND (docass_source_type='J')); RETURN _prjid; END; $_$; ALTER FUNCTION public.copyproject(integer, text, text, date) OWNER TO admin; -- -- Name: copyquote(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copyquote(integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuheadid ALIAS FOR $1; pSchedDate ALIAS FOR $2; _quheadid INTEGER; _qunumber TEXT; BEGIN SELECT NEXTVAL('quhead_quhead_id_seq') INTO _quheadid; IF (fetchMetricText('QUNumberGeneration') = 'S') THEN SELECT fetchSoNumber() INTO _qunumber; ELSE SELECT fetchQuNumber() INTO _qunumber; END IF; INSERT INTO quhead ( quhead_id, quhead_number, quhead_cust_id, quhead_prj_id, quhead_quotedate, quhead_packdate, quhead_fob, quhead_warehous_id, quhead_terms_id, quhead_salesrep_id, quhead_custponumber, quhead_shipvia, quhead_shipto_id, quhead_shiptoname, quhead_shiptoaddress1, quhead_shiptoaddress2, quhead_shiptoaddress3, quhead_shiptocity, quhead_shiptostate, quhead_shiptozipcode, quhead_shiptophone, quhead_shiptocountry, quhead_billtoname, quhead_billtoaddress1, quhead_billtoaddress2, quhead_billtoaddress3, quhead_billtocity, quhead_billtostate, quhead_billtozip, quhead_misc_accnt_id, quhead_misc_descrip, quhead_misc, quhead_freight, quhead_commission, quhead_ordercomments, quhead_shipcomments, quhead_imported, quhead_curr_id, quhead_taxzone_id, quhead_taxtype_id, quhead_ophead_id, quhead_status, quhead_shipto_cntct_id, quhead_shipto_cntct_honorific, quhead_shipto_cntct_first_name, quhead_shipto_cntct_middle, quhead_shipto_cntct_last_name, quhead_shipto_cntct_suffix, quhead_shipto_cntct_phone, quhead_shipto_cntct_title, quhead_shipto_cntct_fax, quhead_shipto_cntct_email, quhead_billto_cntct_id, quhead_billto_cntct_honorific, quhead_billto_cntct_first_name, quhead_billto_cntct_middle, quhead_billto_cntct_last_name, quhead_billto_cntct_suffix, quhead_billto_cntct_phone, quhead_billto_cntct_title, quhead_billto_cntct_fax, quhead_billto_cntct_email ) SELECT _quheadid, _qunumber, quhead_cust_id, quhead_prj_id, CURRENT_DATE, COALESCE(pSchedDate, quhead_packdate), quhead_fob, quhead_warehous_id, quhead_terms_id, quhead_salesrep_id, quhead_custponumber, quhead_shipvia, quhead_shipto_id, quhead_shiptoname, quhead_shiptoaddress1, quhead_shiptoaddress2, quhead_shiptoaddress3, quhead_shiptocity, quhead_shiptostate, quhead_shiptozipcode, quhead_shiptophone, quhead_shiptocountry, quhead_billtoname, quhead_billtoaddress1, quhead_billtoaddress2, quhead_billtoaddress3, quhead_billtocity, quhead_billtostate, quhead_billtozip, quhead_misc_accnt_id, quhead_misc_descrip, quhead_misc, quhead_freight, quhead_commission, quhead_ordercomments, quhead_shipcomments, FALSE, quhead_curr_id, quhead_taxzone_id, quhead_taxtype_id, quhead_ophead_id, 'O', quhead_shipto_cntct_id, quhead_shipto_cntct_honorific, quhead_shipto_cntct_first_name, quhead_shipto_cntct_middle, quhead_shipto_cntct_last_name, quhead_shipto_cntct_suffix, quhead_shipto_cntct_phone, quhead_shipto_cntct_title, quhead_shipto_cntct_fax, quhead_shipto_cntct_email, quhead_billto_cntct_id, quhead_billto_cntct_honorific, quhead_billto_cntct_first_name, quhead_billto_cntct_middle, quhead_billto_cntct_last_name, quhead_billto_cntct_suffix, quhead_billto_cntct_phone, quhead_billto_cntct_title, quhead_billto_cntct_fax, quhead_billto_cntct_email FROM quhead WHERE (quhead_id=pQuheadid); INSERT INTO quitem ( quitem_quhead_id, quitem_linenumber, quitem_itemsite_id, quitem_scheddate, quitem_promdate, quitem_qtyord, quitem_price, quitem_custprice, quitem_unitcost, quitem_qty_uom_id, quitem_price_uom_id, quitem_qty_invuomratio, quitem_price_invuomratio, quitem_memo, quitem_custpn, quitem_imported, quitem_taxtype_id, quitem_createorder, quitem_order_warehous_id, quitem_item_id, quitem_prcost, quitem_dropship, quitem_itemsrc_id, quitem_pricemode ) SELECT _quheadid, quitem_linenumber, quitem_itemsite_id, COALESCE(pSchedDate, quitem_scheddate), quitem_promdate, quitem_qtyord, quitem_price, quitem_custprice, stdCost(itemsite_item_id), quitem_qty_uom_id, quitem_price_uom_id, quitem_qty_invuomratio, quitem_price_invuomratio, quitem_memo, quitem_custpn, FALSE, quitem_taxtype_id, quitem_createorder, quitem_order_warehous_id, quitem_item_id, quitem_prcost, quitem_dropship, quitem_itemsrc_id, quitem_pricemode FROM quitem, itemsite WHERE ( (quitem_itemsite_id=itemsite_id) AND (quitem_quhead_id=pQuheadid)); INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value) SELECT charass_target_type, b.quitem_id, charass_char_id, charass_value FROM quitem a, charass, quitem b WHERE ((charass_target_type='QI') AND (charass_target_id=a.quitem_id) AND (a.quitem_quhead_id=pQuheadid) AND (b.quitem_quhead_id=_quheadid) AND (a.quitem_linenumber=b.quitem_linenumber) ); RETURN _quheadid; END; $_$; ALTER FUNCTION public.copyquote(integer, date) OWNER TO admin; -- -- Name: copyquotetocustomer(integer, integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copyquotetocustomer(pquheadid integer, pcustomerid integer, pscheddate date) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _isCustomer BOOLEAN; _quotecustomer INTEGER; _quheadid INTEGER; _qunumber TEXT; _b RECORD; BEGIN SELECT NEXTVAL('quhead_quhead_id_seq') INTO _quheadid; IF (fetchMetricText('QUNumberGeneration') = 'S') THEN SELECT fetchSoNumber() INTO _qunumber; ELSE SELECT fetchQuNumber() INTO _qunumber; END IF; SELECT * INTO _b FROM ( SELECT cust_name as name, addr_line1, addr_line2, addr_line3, addr_city, addr_state, addr_postalcode, addr_country, cntct_id, cntct_honorific, cntct_first_name, cntct_middle, cntct_last_name, cntct_suffix, cntct_phone, cntct_title, cntct_fax, cntct_email FROM custinfo LEFT JOIN cntct ON (cust_cntct_id = cntct_id) LEFT JOIN addr ON (cntct_addr_id = addr_id) WHERE cust_id = pCustomerid UNION SELECT prospect_name AS name, addr_line1, addr_line2, addr_line3, addr_city, addr_state, addr_postalcode, addr_country, cntct_id, cntct_honorific, cntct_first_name, cntct_middle, cntct_last_name, cntct_suffix, cntct_phone, cntct_title, cntct_fax, cntct_email FROM prospect LEFT JOIN cntct ON (prospect_cntct_id = cntct_id) LEFT JOIN addr ON (cntct_addr_id = addr_id) WHERE prospect_id = pCustomerid ) data; IF (NOT FOUND) THEN RAISE EXCEPTION 'Invalid Customer supplied: %', pCustomerid; END IF; INSERT INTO quhead ( quhead_id, quhead_number, quhead_cust_id, quhead_prj_id, quhead_quotedate, quhead_packdate, quhead_fob, quhead_warehous_id, quhead_terms_id, quhead_salesrep_id, quhead_custponumber, quhead_shipvia, quhead_shipto_id, quhead_shiptoname, quhead_shiptoaddress1, quhead_shiptoaddress2, quhead_shiptoaddress3, quhead_shiptocity, quhead_shiptostate, quhead_shiptozipcode, quhead_shiptophone, quhead_shiptocountry, quhead_billtoname, quhead_billtoaddress1, quhead_billtoaddress2, quhead_billtoaddress3, quhead_billtocity, quhead_billtostate, quhead_billtozip, quhead_misc_accnt_id, quhead_misc_descrip, quhead_misc, quhead_freight, quhead_commission, quhead_ordercomments, quhead_shipcomments, quhead_imported, quhead_curr_id, quhead_taxzone_id, quhead_taxtype_id, quhead_ophead_id, quhead_status, quhead_shipto_cntct_id, quhead_shipto_cntct_honorific, quhead_shipto_cntct_first_name, quhead_shipto_cntct_middle, quhead_shipto_cntct_last_name, quhead_shipto_cntct_suffix, quhead_shipto_cntct_phone, quhead_shipto_cntct_title, quhead_shipto_cntct_fax, quhead_shipto_cntct_email, quhead_billto_cntct_id, quhead_billto_cntct_honorific, quhead_billto_cntct_first_name, quhead_billto_cntct_middle, quhead_billto_cntct_last_name, quhead_billto_cntct_suffix, quhead_billto_cntct_phone, quhead_billto_cntct_title, quhead_billto_cntct_fax, quhead_billto_cntct_email ) SELECT _quheadid, _qunumber, pCustomerid, -- use new customer or prospect quhead_prj_id, CURRENT_DATE, COALESCE(pSchedDate, quhead_packdate), quhead_fob, quhead_warehous_id, quhead_terms_id, quhead_salesrep_id, quhead_custponumber, quhead_shipvia, NULL, -- shipto_id '', -- shipto_name '', -- addr_line1 '', -- addr_line2 '', -- addr_line3 '', -- addr_city '', -- addr_state '', -- addr_postalcode NULL, '', -- new billto info _b.name, -- quhead_billtoname, _b.addr_line1, -- quhead_billtoaddress1, _b.addr_line2, -- quhead_billtoaddress2 _b.addr_line3, -- quhead_billtoaddress3, _b.addr_city, -- quhead_billtocity _b.addr_state, -- quhead_billtostate, _b.addr_postalcode, -- quhead_billtozip, quhead_misc_accnt_id, quhead_misc_descrip, quhead_misc, quhead_freight, quhead_commission, quhead_ordercomments, quhead_shipcomments, FALSE, quhead_curr_id, quhead_taxzone_id, quhead_taxtype_id, quhead_ophead_id, 'O', NULL, -- quhead_shipto_cntct_id, '', -- quhead_shipto_cntct_honorific, '', -- quhead_shipto_cntct_first_name '', -- quhead_shipto_cntct_middle, '', -- quhead_shipto_cntct_last_name, '', -- quhead_shipto_cntct_suffix, '', -- quhead_shipto_cntct_phone, '', -- quhead_shipto_cntct_title, '', -- quhead_shipto_cntct_fax, '', -- quhead_shipto_cntct_email, _b.cntct_id, -- quhead_billto_cntct_id, _b.cntct_honorific, -- quhead_billto_cntct_honorific, _b.cntct_first_name, -- quhead_billto_cntct_first_name, _b.cntct_middle, -- quhead_billto_cntct_middle, _b.cntct_last_name, -- quhead_billto_cntct_last_name, _b.cntct_suffix, -- quhead_billto_cntct_suffix, _b.cntct_phone, -- quhead_billto_cntct_phone, _b.cntct_title, -- quhead_billto_cntct_title, _b.cntct_fax, -- quhead_billto_cntct_fax, _b.cntct_email -- quhead_billto_cntct_email FROM quhead WHERE (quhead_id=pquheadid); INSERT INTO quitem ( quitem_quhead_id, quitem_linenumber, quitem_itemsite_id, quitem_scheddate, quitem_promdate, quitem_qtyord, quitem_price, quitem_custprice, quitem_unitcost, quitem_qty_uom_id, quitem_price_uom_id, quitem_qty_invuomratio, quitem_price_invuomratio, quitem_memo, quitem_custpn, quitem_imported, quitem_taxtype_id, quitem_createorder, quitem_order_warehous_id, quitem_item_id, quitem_prcost, quitem_dropship, quitem_itemsrc_id, quitem_pricemode ) SELECT _quheadid, quitem_linenumber, quitem_itemsite_id, COALESCE(pSchedDate, quitem_scheddate), quitem_promdate, quitem_qtyord, quitem_price, quitem_custprice, stdCost(itemsite_item_id), quitem_qty_uom_id, quitem_price_uom_id, quitem_qty_invuomratio, quitem_price_invuomratio, quitem_memo, quitem_custpn, FALSE, quitem_taxtype_id, quitem_createorder, quitem_order_warehous_id, quitem_item_id, quitem_prcost, quitem_dropship, quitem_itemsrc_id, quitem_pricemode FROM quitem, itemsite WHERE ( (quitem_itemsite_id=itemsite_id) AND (quitem_quhead_id=pQuheadid)); INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value) SELECT charass_target_type, b.quitem_id, charass_char_id, charass_value FROM quitem a, charass, quitem b WHERE ((charass_target_type='SI') AND (charass_target_id=a.quitem_id) AND (a.quitem_quhead_id=pquheadid) AND (b.quitem_quhead_id=_quheadid) AND (a.quitem_linenumber=b.quitem_linenumber) ); RETURN _quheadid; END; $$; ALTER FUNCTION public.copyquotetocustomer(pquheadid integer, pcustomerid integer, pscheddate date) OWNER TO admin; -- -- Name: copyso(integer, integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copyso(psoheadid integer, pcustomer integer, pscheddate date) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _soheadid INTEGER; _soitemid INTEGER; _soitem RECORD; _newCustomer BOOLEAN; _customer RECORD; BEGIN SELECT NEXTVAL('cohead_cohead_id_seq') INTO _soheadid; -- Check whether we are copying to a new customer SELECT (cohead_cust_id <> COALESCE(pCustomer, cohead_cust_id)) INTO _newCustomer FROM cohead WHERE cohead_id = pSoheadid; IF (NOT _newCustomer) THEN INSERT INTO cohead ( cohead_id, cohead_number, cohead_cust_id, cohead_custponumber, cohead_type, cohead_orderdate, cohead_warehous_id, cohead_shipto_id, cohead_shiptoname, cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3, cohead_shiptoaddress4, cohead_shiptoaddress5, cohead_salesrep_id, cohead_terms_id, cohead_fob, cohead_shipvia, cohead_shiptocity, cohead_shiptostate, cohead_shiptozipcode, cohead_freight, cohead_misc, cohead_imported, cohead_ordercomments, cohead_shipcomments, cohead_shiptophone, cohead_shipchrg_id, cohead_shipform_id, cohead_billtoname, cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, cohead_billtocity, cohead_billtostate, cohead_billtozipcode, cohead_misc_accnt_id, cohead_misc_descrip, cohead_commission, cohead_miscdate, cohead_holdtype, cohead_packdate, cohead_prj_id, cohead_wasquote, cohead_lastupdated, cohead_shipcomplete, cohead_created, cohead_creator, cohead_quote_number, cohead_billtocountry, cohead_shiptocountry, cohead_curr_id, cohead_calcfreight, cohead_shipto_cntct_id, cohead_shipto_cntct_honorific, cohead_shipto_cntct_first_name, cohead_shipto_cntct_middle, cohead_shipto_cntct_last_name, cohead_shipto_cntct_suffix, cohead_shipto_cntct_phone, cohead_shipto_cntct_title, cohead_shipto_cntct_fax, cohead_shipto_cntct_email, cohead_billto_cntct_id, cohead_billto_cntct_honorific, cohead_billto_cntct_first_name, cohead_billto_cntct_middle, cohead_billto_cntct_last_name, cohead_billto_cntct_suffix, cohead_billto_cntct_phone, cohead_billto_cntct_title, cohead_billto_cntct_fax, cohead_billto_cntct_email, cohead_taxzone_id, cohead_taxtype_id, cohead_ophead_id, cohead_status, cohead_saletype_id, cohead_shipzone_id ) SELECT _soheadid, fetchSoNumber(), cohead_cust_id, cohead_custponumber, cohead_type, CURRENT_DATE, cohead_warehous_id, cohead_shipto_id, cohead_shiptoname, cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3, cohead_shiptoaddress4, cohead_shiptoaddress5, cohead_salesrep_id, cohead_terms_id, cohead_fob, cohead_shipvia, cohead_shiptocity, cohead_shiptostate, cohead_shiptozipcode, cohead_freight, cohead_misc, FALSE, cohead_ordercomments, cohead_shipcomments, cohead_shiptophone, cohead_shipchrg_id, cohead_shipform_id, cohead_billtoname, cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, cohead_billtocity, cohead_billtostate, cohead_billtozipcode, cohead_misc_accnt_id, cohead_misc_descrip, cohead_commission, cohead_miscdate, cohead_holdtype, COALESCE(pSchedDate, cohead_packdate), cohead_prj_id, FALSE, cohead_lastupdated, cohead_shipcomplete, NULL, getEffectiveXtUser(), NULL, cohead_billtocountry, cohead_shiptocountry, cohead_curr_id, cohead_calcfreight, cohead_shipto_cntct_id, cohead_shipto_cntct_honorific, cohead_shipto_cntct_first_name, cohead_shipto_cntct_middle, cohead_shipto_cntct_last_name, cohead_shipto_cntct_suffix, cohead_shipto_cntct_phone, cohead_shipto_cntct_title, cohead_shipto_cntct_fax, cohead_shipto_cntct_email, cohead_billto_cntct_id, cohead_billto_cntct_honorific, cohead_billto_cntct_first_name, cohead_billto_cntct_middle, cohead_billto_cntct_last_name, cohead_billto_cntct_suffix, cohead_billto_cntct_phone, cohead_billto_cntct_title, cohead_billto_cntct_fax, cohead_billto_cntct_email, cohead_taxzone_id, cohead_taxtype_id, cohead_ophead_id, cohead_status, cohead_saletype_id, cohead_shipzone_id FROM cohead WHERE (cohead_id=pSoheadid); ELSE -- Copy SO to New Customer -- Get Customer details SELECT cust_id, cust_name, cust_salesrep_id, cust_terms_id, cust_shipvia, cust_shipchrg_id, cust_shipform_id, cust_commprcnt, cust_partialship, cust_taxzone_id, cust_curr_id, bc.cntct_id AS billing_contact_id, bc.cntct_honorific AS billing_honorific, bc.cntct_first_name AS billing_first_name, bc.cntct_middle AS billing_middle, bc.cntct_last_name AS billing_last_name, bc.cntct_suffix AS billing_suffix, bc.cntct_phone AS billing_phone, bc.cntct_title AS billing_title, bc.cntct_fax AS billing_fax, bc.cntct_email AS billing_email, ba.addr_line1 AS billing1, ba.addr_line2 AS billing2, ba.addr_line3 AS billing3, ba.addr_city AS billing_city, ba.addr_state AS billing_state, ba.addr_postalcode AS billing_postalcode, ba.addr_country AS billing_country, shipto_id, shipto_name, sc.cntct_id AS shipto_contact_id, sc.cntct_honorific AS shipto_honorific, sc.cntct_phone AS shipto_phone, sc.cntct_first_name AS shipto_first_name, sc.cntct_middle AS shipto_middle, sc.cntct_last_name AS shipto_last_name, sc.cntct_suffix AS shipto_suffix, sc.cntct_phone AS shipto_phone, sc.cntct_title AS shipto_title, sc.cntct_fax AS shipto_fax, sc.cntct_email AS shipto_email, sa.addr_line1 AS shipto1, sa.addr_line2 AS shipto2, sa.addr_line3 AS shipto3, sa.addr_city AS shipto_city, sa.addr_state AS shipto_state, sa.addr_postalcode AS shipto_postalcode, sa.addr_country AS shipto_country INTO _customer FROM custinfo LEFT OUTER join cntct bc ON (cust_cntct_id=bc.cntct_id) LEFT OUTER JOIN addr ba ON (cntct_addr_id=ba.addr_id) LEFT OUTER JOIN shiptoinfo ON ((shipto_cust_id=cust_id) AND (shipto_default)) LEFT OUTER join cntct sc ON (shipto_cntct_id=sc.cntct_id) LEFT OUTER JOIN addr sa ON (shipto_addr_id=sa.addr_id) WHERE cust_id=pCustomer; INSERT INTO cohead ( cohead_id, cohead_number, cohead_cust_id, cohead_custponumber, cohead_type, cohead_orderdate, cohead_warehous_id, cohead_shipto_id, cohead_shiptoname, cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3, cohead_salesrep_id, cohead_terms_id, cohead_fob, cohead_shipvia, cohead_shiptocity, cohead_shiptostate, cohead_shiptozipcode, cohead_freight, cohead_misc, cohead_imported, cohead_ordercomments, cohead_shipcomments, cohead_shiptophone, cohead_shipchrg_id, cohead_shipform_id, cohead_billtoname, cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, cohead_billtocity, cohead_billtostate, cohead_billtozipcode, cohead_misc_accnt_id, cohead_misc_descrip, cohead_commission, cohead_miscdate, cohead_holdtype, cohead_packdate, cohead_prj_id, cohead_wasquote, cohead_lastupdated, cohead_shipcomplete, cohead_created, cohead_creator, cohead_quote_number, cohead_billtocountry, cohead_shiptocountry, cohead_curr_id, cohead_calcfreight, cohead_shipto_cntct_id, cohead_shipto_cntct_honorific, cohead_shipto_cntct_first_name, cohead_shipto_cntct_middle, cohead_shipto_cntct_last_name, cohead_shipto_cntct_suffix, cohead_shipto_cntct_phone, cohead_shipto_cntct_title, cohead_shipto_cntct_fax, cohead_shipto_cntct_email, cohead_billto_cntct_id, cohead_billto_cntct_honorific, cohead_billto_cntct_first_name, cohead_billto_cntct_middle, cohead_billto_cntct_last_name, cohead_billto_cntct_suffix, cohead_billto_cntct_phone, cohead_billto_cntct_title, cohead_billto_cntct_fax, cohead_billto_cntct_email, cohead_taxzone_id, cohead_taxtype_id, cohead_ophead_id, cohead_status, cohead_saletype_id, cohead_shipzone_id ) SELECT _soheadid, fetchSoNumber(), pCustomer, '', cohead_type, CURRENT_DATE, cohead_warehous_id, COALESCE(_customer.shipto_id, NULL), _customer.shipto_name, _customer.shipto1, _customer.shipto2, _customer.shipto3, _customer.cust_salesrep_id, _customer.cust_terms_id, cohead_fob, _customer.cust_shipvia, _customer.shipto_city, _customer.shipto_state, _customer.shipto_postalcode, cohead_freight, cohead_misc, FALSE, cohead_ordercomments, cohead_shipcomments, _customer.shipto_phone, _customer.cust_shipchrg_id, _customer.cust_shipform_id, _customer.cust_name, _customer.billing1, _customer.billing2, _customer.billing3, _customer.billing_city, _customer.billing_state, _customer.billing_postalcode, cohead_misc_accnt_id, cohead_misc_descrip, _customer.cust_commprcnt, cohead_miscdate, cohead_holdtype, COALESCE(pSchedDate, cohead_packdate), NULL, --cohead_prj_id, FALSE, CURRENT_DATE, _customer.cust_partialship, NULL, getEffectiveXtUser(), NULL, _customer.billing_country, _customer.shipto_country, _customer.cust_curr_id, cohead_calcfreight, _customer.shipto_contact_id, _customer.shipto_honorific, _customer.shipto_first_name, _customer.shipto_middle, _customer.shipto_last_name, _customer.shipto_suffix, _customer.shipto_phone, _customer.shipto_title, _customer.shipto_fax, _customer.shipto_email, _customer.billing_contact_id, _customer.billing_honorific, _customer.billing_first_name, _customer.billing_middle, _customer.billing_last_name, _customer.billing_suffix, _customer.billing_phone, _customer.billing_title, _customer.billing_fax, _customer.billing_email, _customer.cust_taxzone_id, cohead_taxtype_id, cohead_ophead_id, 'O', cohead_saletype_id, cohead_shipzone_id FROM cohead WHERE (cohead_id=pSoheadid); END IF; -- Order Header population INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value) SELECT charass_target_type, _soheadid, charass_char_id, charass_value FROM charass WHERE ((charass_target_type='SO') AND (charass_target_id=pSoheadid)); FOR _soitem IN SELECT * FROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id) WHERE ( (coitem_cohead_id=pSoheadid) AND (coitem_status <> 'X') AND (coitem_subnumber = 0) ) LOOP SELECT NEXTVAL('coitem_coitem_id_seq') INTO _soitemid; -- insert characteristics first so they can be copied to associated supply order INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value) SELECT charass_target_type, _soitemid, charass_char_id, charass_value FROM charass WHERE ((charass_target_type='SI') AND (charass_target_id=_soitem.coitem_id)); INSERT INTO coitem ( coitem_id, coitem_cohead_id, coitem_linenumber, coitem_itemsite_id, coitem_status, coitem_scheddate, coitem_promdate, coitem_qtyord, coitem_unitcost, coitem_price, coitem_custprice, coitem_qtyshipped, coitem_order_id, coitem_memo, coitem_imported, coitem_qtyreturned, coitem_closedate, coitem_custpn, coitem_order_type, coitem_close_username, -- coitem_lastupdated, coitem_substitute_item_id, coitem_created, coitem_creator, coitem_prcost, coitem_qty_uom_id, coitem_qty_invuomratio, coitem_price_uom_id, coitem_price_invuomratio, coitem_warranty, coitem_cos_accnt_id, coitem_qtyreserved, coitem_subnumber, coitem_firm, coitem_taxtype_id ) VALUES ( _soitemid, _soheadid, _soitem.coitem_linenumber, _soitem.coitem_itemsite_id, 'O', COALESCE(pSchedDate, _soitem.coitem_scheddate), _soitem.coitem_promdate, _soitem.coitem_qtyord, stdCost(_soitem.itemsite_item_id), _soitem.coitem_price, _soitem.coitem_custprice, 0.0, -1, _soitem.coitem_memo, FALSE, 0.0, NULL, _soitem.coitem_custpn, _soitem.coitem_order_type, NULL, -- NULL, _soitem.coitem_substitute_item_id, NULL, getEffectiveXtUser(), _soitem.coitem_prcost, _soitem.coitem_qty_uom_id, _soitem.coitem_qty_invuomratio, _soitem.coitem_price_uom_id, _soitem.coitem_price_invuomratio, _soitem.coitem_warranty, _soitem.coitem_cos_accnt_id, 0.0, _soitem.coitem_subnumber, _soitem.coitem_firm, _soitem.coitem_taxtype_id ); END LOOP; RETURN _soheadid; END; $$; ALTER FUNCTION public.copyso(psoheadid integer, pcustomer integer, pscheddate date) OWNER TO admin; -- -- Name: copytodoitem(integer, date, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copytodoitem(integer, date, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pparentid ALIAS FOR $1; _duedate DATE := COALESCE($2, CURRENT_DATE); pincdtid ALIAS FOR $3; _alarmid INTEGER; _todoitemid INTEGER; BEGIN INSERT INTO todoitem( todoitem_name, todoitem_description, todoitem_incdt_id, todoitem_creator_username, todoitem_status, todoitem_active, todoitem_due_date, todoitem_assigned_date, todoitem_seq, todoitem_notes, todoitem_crmacct_id, todoitem_ophead_id, todoitem_owner_username,todoitem_priority_id, todoitem_username, todoitem_recurring_todoitem_id ) SELECT todoitem_name, todoitem_description, CASE WHEN pincdtid IS NULL THEN todoitem_incdt_id ELSE pincdtid END, getEffectiveXtUser(), 'N', TRUE, _duedate, CASE WHEN (todoitem_username IS NOT NULL) THEN CURRENT_DATE ELSE NULL END, todoitem_seq, todoitem_notes, todoitem_crmacct_id, todoitem_ophead_id, todoitem_owner_username,todoitem_priority_id, todoitem_username, todoitem_recurring_todoitem_id FROM todoitem WHERE (todoitem_id=pparentid) RETURNING todoitem_id INTO _todoitemid; IF (_todoitemid IS NULL) THEN RETURN -10; END IF; SELECT saveAlarm(NULL, NULL, _duedate, CAST(alarm_time - DATE_TRUNC('day',alarm_time) AS TIME), alarm_time_offset, alarm_time_qualifier, (alarm_event_recipient IS NOT NULL), alarm_event_recipient, (alarm_email_recipient IS NOT NULL AND fetchMetricBool('EnableBatchManager')), alarm_email_recipient, (alarm_sysmsg_recipient IS NOT NULL), alarm_sysmsg_recipient, 'TODO', _todoitemid, 'CHANGEONE') INTO _alarmid FROM alarm WHERE ((alarm_source='TODO') AND (alarm_source_id=pparentid)); IF (_alarmid < 0) THEN RETURN _alarmid; END IF; RETURN _todoitemid; END; $_$; ALTER FUNCTION public.copytodoitem(integer, date, integer) OWNER TO admin; -- -- Name: copyvoucher(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION copyvoucher(integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVoheadid ALIAS FOR $1; _voheadid INTEGER; _vonumber TEXT; _vodate DATE := COALESCE($2, CURRENT_DATE); _i RECORD; _l RECORD; _vodistid INTEGER; BEGIN SELECT * INTO _i FROM vohead WHERE(vohead_id=pVoheadid); IF(NOT FOUND) THEN RETURN -1; END IF; _vonumber := fetchVoNumber(); _voheadid := nextval('vohead_vohead_id_seq'); INSERT INTO vohead (vohead_id, vohead_number, vohead_pohead_id, vohead_posted, vohead_duedate, vohead_invcnumber, vohead_amount, vohead_docdate, vohead_1099, vohead_distdate, vohead_reference, vohead_terms_id, vohead_vend_id, vohead_curr_id, vohead_adjtaxtype_id, vohead_freighttaxtype_id, vohead_gldistdate, vohead_misc, vohead_taxzone_id, vohead_taxtype_id, vohead_notes, vohead_recurring_vohead_id ) VALUES(_voheadid, _vonumber, _i.vohead_pohead_id, false, determineDueDate(_i.vohead_terms_id, _vodate), _i.vohead_invcnumber, _i.vohead_amount, _vodate, _i.vohead_1099, _vodate, _i.vohead_reference, _i.vohead_terms_id, _i.vohead_vend_id, _i.vohead_curr_id, _i.vohead_adjtaxtype_id, _i.vohead_freighttaxtype_id, _vodate, _i.vohead_misc, _i.vohead_taxzone_id, _i.vohead_taxtype_id, _i.vohead_notes, _i.vohead_recurring_vohead_id); FOR _l IN SELECT * FROM vodist WHERE (vodist_vohead_id=pVoheadid) LOOP SELECT NEXTVAL('vodist_vodist_id_seq') INTO _vodistid; INSERT INTO vodist (vodist_id, vodist_poitem_id, vodist_vohead_id, vodist_costelem_id, vodist_accnt_id, vodist_amount, vodist_qty, vodist_expcat_id, vodist_tax_id, vodist_discountable, vodist_notes) VALUES (_vodistid, _l.vodist_poitem_id, _voheadid, _l.vodist_costelem_id, _l.vodist_accnt_id, _l.vodist_amount, _l.vodist_qty, _l.vodist_expcat_id, _l.vodist_tax_id, _l.vodist_discountable, _l.vodist_notes); END LOOP; RETURN _voheadid; END; $_$; ALTER FUNCTION public.copyvoucher(integer, date) OWNER TO admin; -- -- Name: correctporeceipt(integer, numeric, numeric, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION correctporeceipt(integer, numeric, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPorecvid ALIAS FOR $1; pQty ALIAS FOR $2; pFreight ALIAS FOR $3; pItemlocSeries ALIAS FOR $4; BEGIN RETURN correctReceipt('PO', $1, $2, $3, $4, NULL, NULL); END; $_$; ALTER FUNCTION public.correctporeceipt(integer, numeric, numeric, integer) OWNER TO admin; -- -- Name: correctporeceipt(integer, numeric, numeric, integer, integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION correctporeceipt(integer, numeric, numeric, integer, integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN correctReceipt('PO', $1, $2, $3, $4, $5, $6); END; $_$; ALTER FUNCTION public.correctporeceipt(integer, numeric, numeric, integer, integer, date) OWNER TO admin; -- -- Name: correctproduction(integer, numeric, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION correctproduction(integer, numeric, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'correctProduction(INTEGER, NUMERIC, BOOLEAN, BOOLEAN) has been deprecated. Use corrrectProduction(INTEGER, NUMERIC, BOOLEAN, INTEGER) or a package-specific version instead.'; RETURN correctProduction($1, $2, $3, 0, now()); END; $_$; ALTER FUNCTION public.correctproduction(integer, numeric, boolean, boolean) OWNER TO admin; -- -- Name: correctproduction(integer, numeric, boolean, boolean, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION correctproduction(integer, numeric, boolean, boolean, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'correctProduction(INTEGER, NUMERIC, BOOLEAN, BOOLEAN, INTEGER) has been deprecated. Use corrrectProduction(INTEGER, NUMERIC, BOOLEAN, INTEGER) or a package-specific version instead.'; RETURN correctProduction($1, $2, $3, $5, now()); END; $_$; ALTER FUNCTION public.correctproduction(integer, numeric, boolean, boolean, integer) OWNER TO admin; -- -- Name: correctproduction(integer, numeric, boolean, integer, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION correctproduction(integer, numeric, boolean, integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pQty ALIAS FOR $2; pBackflush ALIAS FOR $3; pItemlocSeries ALIAS FOR $4; pGlDistTS ALIAS FOR $5; BEGIN RETURN correctProduction($1, $2, $3, $4, $5, NULL); END; $_$; ALTER FUNCTION public.correctproduction(integer, numeric, boolean, integer, timestamp with time zone) OWNER TO admin; -- -- Name: correctproduction(integer, numeric, boolean, integer, timestamp with time zone, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION correctproduction(integer, numeric, boolean, integer, timestamp with time zone, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pQty ALIAS FOR $2; pBackflush ALIAS FOR $3; pItemlocSeries ALIAS FOR $4; pGlDistTS ALIAS FOR $5; pInvhistId ALIAS FOR $6; _invhistid INTEGER; _itemlocSeries INTEGER; _r RECORD; _parentWIPAccntid INTEGER; _parentQty NUMERIC; _qty NUMERIC; _wipPost NUMERIC; _sense TEXT; _status TEXT; _type TEXT; _qtyfxd NUMERIC := 0; BEGIN -- Qty is positive for Assembly W/O -- Qty is negative for Disassembly W/O IF (pQty = 0) THEN RETURN pItemlocseries; ELSIF (pQty > 0) THEN _sense := 'from'; ELSE _sense := 'to'; END IF; SELECT item_type, roundQty(item_fractional, pQty), wo_status INTO _type, _parentQty, _status FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (wo_id=pWoid); IF (_status != 'I') THEN RETURN -1; END IF; IF (_type = 'J') THEN RETURN -2; END IF; IF (pItemlocSeries = 0) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; ELSE _itemlocSeries := pItemlocSeries; END IF; -- Calculate the WIP to correct SELECT CASE WHEN (wo_cosmethod = 'D') THEN wo_postedvalue ELSE round(((wo_postedvalue - wo_wipvalue) / wo_qtyrcv * _parentQty), 2) END INTO _wipPost FROM wo WHERE (wo_id=pWoid); -- Post the inventory transaction SELECT postInvTrans( itemsite_id, 'RM', (_parentQty * -1.0), 'W/O', 'WO', formatwonumber(pWoid), '', ('Correct Receive Inventory ' || item_number || ' ' || _sense || ' Manufacturing'), costcat_asset_accnt_id, getPrjAccntId(wo_prj_id, costcat_wip_accnt_id), _itemlocSeries, pGlDistTS, (_wipPost * -1.0), -- only used when cost is average pInvhistId) INTO _invhistid FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id) JOIN item ON (item_id=itemsite_item_id) JOIN costcat ON (costcat_id=itemsite_costcat_id) WHERE (wo_id=pWoid); -- Decrease this W/O's qty. received and increase its WIP value UPDATE wo SET wo_qtyrcv = (wo_qtyrcv - _parentQty), wo_wipvalue = (wo_wipvalue + (CASE WHEN(itemsite_costmethod IN ('A','J')) THEN _wipPost WHEN(itemsite_costmethod='S') THEN stdcost(itemsite_item_id) * _parentQty ELSE 0.0 END)) FROM itemsite WHERE ( (wo_itemsite_id=itemsite_id) AND (wo_id=pWoid) ); IF (pBackflush) THEN FOR _r IN SELECT item_id, item_fractional, itemsite_id, itemsite_warehous_id, itemsite_controlmethod, itemsite_loccntrl, itemsite_costmethod, wo_qtyrcv, wo_prj_id, womatl_id, womatl_qtyfxd, womatl_qtyper, womatl_scrap, womatl_issuemethod, womatl_uom_id FROM wo JOIN womatl ON (womatl_wo_id=wo_id AND womatl_issuemethod='L') JOIN itemsite ON (itemsite_id=womatl_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (wo_id=pWoid) LOOP -- Cache the qty to be issued -- If going back to beginning, unissue fixed qty as well IF (_r.wo_qtyrcv - _parentQty > 0) THEN _qtyfxd := 0; ELSE _qtyfxd := _r.womatl_qtyfxd; END IF; _qty = roundQty(_r.item_fractional, (_qtyfxd + _parentQty * _r.womatl_qtyper) * (1 + _r.womatl_scrap)); IF (_qty > 0) THEN SELECT returnWoMaterial(_r.womatl_id, _qty, _itemlocSeries, pGlDistTS) INTO _itemlocSeries; END IF; END LOOP; -- BEGIN ROB Decrease this W/O's WIP value for custom costing UPDATE wo SET wo_wipvalue = (wo_wipvalue - (itemcost_stdcost * _parentQty)) FROM costelem, itemcost, costcat, itemsite, item WHERE ((wo_id=pWoid) AND (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (costelem_id = itemcost_costelem_id) AND (itemcost_item_id = itemsite_item_id) AND (itemsite_costcat_id = costcat_id) AND (costelem_exp_accnt_id) IS NOT NULL AND (costelem_sys = false)); -- ROB Distribute to G/L - create Cost Variance, debit WIP PERFORM insertGLTransaction( 'W/O', 'WO', formatwonumber(pWoid), ('Correct Post Other Cost ' || item_number || ' ' || _sense || ' Manufacturing'), getPrjAccntId(wo_prj_id, costelem_exp_accnt_id), getPrjAccntId(wo_prj_id, costcat_wip_accnt_id), _invhistid, ((itemcost_stdcost * _parentQty)* -1), CURRENT_DATE ) FROM wo, costelem, itemcost, costcat, itemsite, item WHERE ((wo_id=pWoid) AND (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (costelem_id = itemcost_costelem_id) AND (itemcost_item_id = itemsite_item_id) AND (itemsite_costcat_id = costcat_id) AND (costelem_exp_accnt_id) IS NOT NULL AND (costelem_sys = false)); --End ROB END IF; RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.correctproduction(integer, numeric, boolean, integer, timestamp with time zone, integer) OWNER TO admin; -- -- Name: correctreceipt(integer, numeric, numeric, integer, integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION correctreceipt(integer, numeric, numeric, integer, integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ BEGIN RETURN correctReceipt($1, $2, $3, $4, $5, $6, NULL); END; $_$; ALTER FUNCTION public.correctreceipt(integer, numeric, numeric, integer, integer, date) OWNER TO admin; -- -- Name: correctreceipt(integer, numeric, numeric, integer, integer, date, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION correctreceipt(integer, numeric, numeric, integer, integer, date, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE precvid ALIAS FOR $1; pQty ALIAS FOR $2; pFreight ALIAS FOR $3; _itemlocSeries INTEGER := COALESCE($4, 0); _currid INTEGER := $5; pEffective ALIAS FOR $6; pRecvCost ALIAS FOR $7; _freight NUMERIC; _qty NUMERIC; _invhistid INTEGER; _o RECORD; _r RECORD; _recvcost NUMERIC; _tmp INTEGER; _pricevar NUMERIC := 0.00; _journalNumber INTEGER := fetchJournalNumber('GL-MISC'); BEGIN SELECT recv_qty, recv_date::DATE AS recv_date, recv_freight_curr_id, recv_orderitem_id, round(currToCurr(recv_freight_curr_id, COALESCE(_currid, recv_freight_curr_id), recv_freight, recv_date::DATE),2) AS recv_freight, recv_posted, recv_order_type, COALESCE(itemsite_id, -1) AS itemsiteid, itemsite_item_id, itemsite_costmethod, itemsite_controlmethod, (recv_splitfrom_id IS NOT NULL OR (SELECT (count(*) > 0) FROM recv WHERE (recv_splitfrom_id=recv_id))) AS split INTO _r FROM recv LEFT OUTER JOIN itemsite ON (recv_itemsite_id=itemsite_id) WHERE (recv_id=precvid); IF (NOT FOUND) THEN RETURN _itemlocSeries; END IF; IF (NOT _r.recv_order_type IN ('PO', 'RA', 'TO')) THEN RETURN -11; END IF; IF (_r.split) THEN RETURN -12; END IF; SELECT currToBase(orderitem_unitcost_curr_id, orderitem_unitcost, _r.recv_date::DATE) AS unitprice_base, orderhead_number, orderitem_linenumber, orderhead_curr_id AS freight_curr_id, orderitem_orderhead_type, orderitem_qty_invuomratio INTO _o FROM orderhead, orderitem WHERE ((orderhead_id=orderitem_orderhead_id) AND (orderhead_type=orderitem_orderhead_type) AND (orderitem_id=_r.recv_orderitem_id) AND (orderitem_orderhead_type=_r.recv_order_type)); IF (NOT FOUND) THEN RETURN _itemlocSeries; END IF; -- Default to _o.orderitem_unitcost if recv_purchcost is not supplied -- Note: this should never happen, a value is always supplied if (pRecvCost IS NULL) THEN _recvcost := _o.orderitem_unitcost; ELSE -- Note: if the receipt has already been posted, pRecvCost will always -- equal the original recv_purchcost (cannot be modified in GUI) _recvcost := pRecvCost; END IF; IF (_r.recv_posted) THEN _qty := (pQty - _r.recv_qty); IF (_qty <> 0) THEN IF (_r.itemsiteid = -1) THEN PERFORM insertGLTransaction( _journalNumber,'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Non-Inventory from ' || _r.recv_order_type, expcat_liability_accnt_id, getPrjAccntId(poitem_prj_id, expcat_exp_accnt_id), -1, ROUND(_o.unitprice_base * _qty, 2), pEffective ) FROM poitem, expcat WHERE ((poitem_expcat_id=expcat_id) AND (poitem_id=_r.recv_orderitem_id) AND (_o.orderitem_orderhead_type='PO')); UPDATE recv SET recv_qty=pQty, recv_value=(recv_value + ROUND(_o.unitprice_base * _qty, 2)), recv_date = pEffective WHERE (recv_id=precvid); ELSEIF (_r.itemsite_controlmethod = 'N') THEN PERFORM insertGLTransaction( _journalNumber,'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Non-Controlled Inventory from ' || _r.recv_order_type, costcat_liability_accnt_id, getPrjAccntId(poitem_prj_id, costcat_exp_accnt_id), -1, ROUND(_o.unitprice_base * _qty, 2), pEffective ) FROM poitem, itemsite, costcat WHERE ((poitem_itemsite_id=itemsite_id) AND (itemsite_costcat_id=costcat_id) AND (poitem_id=_r.recv_orderitem_id) AND (_o.orderitem_orderhead_type='PO')); UPDATE recv SET recv_qty=pQty, recv_value=(recv_value + ROUND(_o.unitprice_base * _qty, 2)), recv_date = pEffective WHERE (recv_id=precvid); ELSE IF (_itemlocSeries = 0 OR _itemlocSeries IS NULL) THEN _itemlocSeries := NEXTVAL('itemloc_series_seq'); END IF; SELECT postInvTrans( itemsite_id, 'RP', (_qty * _o.orderitem_qty_invuomratio), 'S/R', _r.recv_order_type, _o.orderhead_number::TEXT || '-' || _o.orderitem_linenumber::TEXT, '', 'Receive Inventory from ' || _r.recv_order_type, costcat_asset_accnt_id, costcat_liability_accnt_id, _itemlocSeries, pEffective, ROUND(_recvcost * _qty, 2) -- alway passing since it is ignored if not average costed item ) INTO _tmp FROM itemsite, costcat WHERE ((itemsite_costcat_id=costcat_id) AND (itemsite_id=_r.itemsiteid) ); IF(_r.itemsite_costmethod='A') THEN UPDATE recv SET recv_qty=pQty, recv_value=(recv_value + _recvcost * _qty * _o.orderitem_qty_invuomratio), recv_date = pEffective WHERE(recv_id=precvid); ELSE UPDATE recv SET recv_qty=pQty, recv_value=(recv_value + stdcost(_r.itemsite_item_id) * _qty * _o.orderitem_qty_invuomratio), recv_date = pEffective WHERE(recv_id=precvid); END IF; END IF; IF (_r.recv_order_type = 'PO') THEN UPDATE poitem SET poitem_qty_received=(poitem_qty_received + _qty) WHERE (poitem_id=_r.recv_orderitem_id); ELSIF (_r.recv_order_type = 'RA' AND fetchMetricBool('EnableReturnAuth')) THEN UPDATE raitem SET raitem_qtyreceived=(raitem_qtyreceived + _qty) WHERE (raitem_id=_r.recv_orderitem_id); ELSIF (_r.recv_order_type = 'TO' AND fetchMetricBool('MultiWhs')) THEN UPDATE toitem SET toitem_qty_received=(toitem_qty_received + _qty) WHERE (toitem_id=_r.recv_orderitem_id); END IF; END IF; IF (fetchMetricBool('RecordPPVonReceipt')) THEN -- If the 'Purchase Price Variance on Receipt' option is true _invhistid := _tmp; -- Find the difference in the purchase price value expected from the P/O and the value of the transaction SELECT (((currToBase(pohead_curr_id, COALESCE(recv_purchcost, poitem_unitprice), recv_date::DATE)) * _qty) - (invhist_value_after - invhist_value_before)) INTO _pricevar FROM invhist, recv, pohead, poitem WHERE ((recv_orderitem_id=poitem_id) AND (poitem_pohead_id=pohead_id) AND (recv_id=precvid) AND (invhist_id = _invhistid)); -- If difference exists then IF (_pricevar <> 0.00) THEN -- Record an additional GL Transaction for the purchase price variance SELECT insertGLTransaction( _journalNumber, 'S/R', _r.recv_order_type, _o.orderhead_number, 'Purchase price variance adjusted for P/O ' || _o.orderhead_number || ' for item ' || _o.orderitem_linenumber::TEXT, costcat_liability_accnt_id, getPrjAccntId(poitem_prj_id, costcat_purchprice_accnt_id), -1, _pricevar, pEffective, false ) INTO _tmp FROM itemsite, costcat, poitem, recv WHERE ((itemsite_costcat_id=costcat_id) AND (recv_id=precvid) AND (recv_orderitem_id=poitem_id) AND (itemsite_id=recv_itemsite_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Could not insert G/L transaction: no cost category found for itemsite_id %', _r.itemsite_id; ELSIF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction RETURN _tmp; ELSE -- Posting to trial balance is deferred to prevent locking INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries) VALUES ( _tmp, _itemlocSeries ); END IF; END IF; END IF; _freight := (pFreight - _r.recv_freight); IF (_freight <> 0) THEN IF (_r.itemsiteid = -1) THEN PERFORM insertGLTransaction( _journalNumber,'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Non-Inventory Freight from ' || _r.recv_order_type, expcat_liability_accnt_id, getPrjAccntId(poitem_prj_id, expcat_freight_accnt_id), -1, ROUND(currToBase(_currid, _freight, pEffective), 2), pEffective ) FROM poitem, expcat WHERE ((poitem_expcat_id=expcat_id) AND (poitem_id=_r.recv_orderitem_id) AND (_r.recv_order_type='PO')); ELSE PERFORM insertGLTransaction(_journalNumber,'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Non-Inventory Freight from ' || _r.recv_order_type, costcat_liability_accnt_id, costcat_freight_accnt_id, -1, round(currToBase(_currid, _freight, pEffective), 2), pEffective ) FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_r.itemsiteid) ); END IF; IF (_r.recv_order_type = 'PO') THEN UPDATE poitem SET poitem_freight_received=(poitem_freight_received + currToCurr(_currid, _o.freight_curr_id, _freight, pEffective)) WHERE (poitem_id=_r.recv_orderitem_id); -- raitem does not track freight ELSEIF (_r.recv_order_type = 'TO' AND fetchMetricBool('MultiWhs')) THEN UPDATE toitem SET toitem_freight_received=(toitem_freight_received + currToCurr(_currid, _o.freight_curr_id, _freight, pEffective)) WHERE (toitem_id=_r.recv_orderitem_id); END IF; UPDATE recv SET recv_freight=currToCurr(_currid, recv_freight_curr_id, pFreight, pEffective), recv_date = pEffective WHERE (recv_id=precvid); END IF; ELSE -- Receipt not posted yet UPDATE recv SET recv_qty=pQty, recv_freight=pFreight, recv_purchcost=_recvcost WHERE recv_id=precvid; END IF; RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.correctreceipt(integer, numeric, numeric, integer, integer, date, numeric) OWNER TO admin; -- -- Name: cosbycustomervalue(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION cosbycustomervalue(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; pPeriodid ALIAS FOR $2; _value NUMERIC; _startDate DATE; _endDate DATE; BEGIN _startDate := findPeriodStart(pPeriodid); _endDate := findPeriodEnd(pPeriodid); -- Returns value in base currency -- ToDo: is cohist_shipdate the right DATE to use? SELECT SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitcost, cohist_shipdate)) INTO _value FROM cohist WHERE ( (cohist_cust_id=pCustid) AND (cohist_invcdate BETWEEN _startDate AND _endDate) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; ALTER FUNCTION public.cosbycustomervalue(integer, integer) OWNER TO admin; -- -- Name: costsbycustomerbyitemsite(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION costsbycustomerbyitemsite(integer, integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pPeriodid ALIAS FOR $3; _value NUMERIC; _startDate DATE; _endDate DATE; BEGIN _startDate := findPeriodStart(pPeriodid); _endDate := findPeriodEnd(pPeriodid); -- Returns value in base currency -- ToDo: is cohist_shipdate the right DATE to use? SELECT SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitcost, cohist_shipdate)) INTO _value FROM cohist WHERE ( (cohist_itemsite_id<>pItemsiteid) AND (cohist_cust_id=pCustid) AND (cohist_invcdate BETWEEN _startDate AND _endDate) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; ALTER FUNCTION public.costsbycustomerbyitemsite(integer, integer, integer) OWNER TO admin; -- -- Name: costsbycustomervalue(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION costsbycustomervalue(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; pPeriodid ALIAS FOR $2; _value NUMERIC; _startDate DATE; _endDate DATE; BEGIN _startDate := findPeriodStart(pPeriodid); _endDate := findPeriodEnd(pPeriodid); -- Returns value in base currency -- ToDo: is cohist_shipdate the right DATE to use? SELECT SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitcost, cohist_shipdate)) INTO _value FROM cohist WHERE ( (cohist_itemsite_id<>-1) AND (cohist_cust_id=pCustid) AND (cohist_invcdate BETWEEN _startDate AND _endDate) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; ALTER FUNCTION public.costsbycustomervalue(integer, integer) OWNER TO admin; -- -- Name: costsbycustomervalue(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION costsbycustomervalue(integer, integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; pPeriodid ALIAS FOR $2; pProdcatid ALIAS FOR $3; _value NUMERIC; _startDate DATE; _endDate DATE; BEGIN _startDate := findPeriodStart(pPeriodid); _endDate := findPeriodEnd(pPeriodid); -- Returns value in base currency -- ToDo: is cohist_shipdate the right DATE to use? SELECT SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitcost, cohist_shipdate)) INTO _value FROM cohist, itemsite, item WHERE ( (cohist_cust_id=pCustid) AND (cohist_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_prodcat_id=pProdcatid) AND (cohist_invcdate BETWEEN _startDate AND _endDate) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; ALTER FUNCTION public.costsbycustomervalue(integer, integer, integer) OWNER TO admin; -- -- Name: costsbycustomervalue(integer, integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION costsbycustomervalue(integer, integer, text) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; pPeriodid ALIAS FOR $2; pProdcat ALIAS FOR $3; _value NUMERIC; _startDate DATE; _endDate DATE; BEGIN _startDate := findPeriodStart(pPeriodid); _endDate := findPeriodEnd(pPeriodid); -- Returns value in base currency -- ToDo: is cohist_shipdate the right date to use? SELECT SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitcost, cohist_shipdate)) INTO _value FROM cohist, itemsite, item, prodcat WHERE ( (cohist_cust_id=pCustid) AND (cohist_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_prodcat_id=prodcat_id) AND (prodcat_code ~ pProdcat) AND (cohist_invcdate BETWEEN _startDate AND _endDate) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; ALTER FUNCTION public.costsbycustomervalue(integer, integer, text) OWNER TO admin; -- -- Name: createaccountingperiod(date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createaccountingperiod(date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pStartDate ALIAS FOR $1; pEndDate ALIAS FOR $2; BEGIN RETURN createAccountingPeriod(pStartDate, pEndDate, NULL, NULL); END; $_$; ALTER FUNCTION public.createaccountingperiod(date, date) OWNER TO admin; -- -- Name: createaccountingperiod(date, date, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createaccountingperiod(date, date, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pStartDate ALIAS FOR $1; pEndDate ALIAS FOR $2; pYearPeriodId ALIAS FOR $3; pQuarter ALIAS FOR $4; _periodid INTEGER; _check INTEGER; _r RECORD; _initial BOOLEAN; _number INTEGER; BEGIN -- Make that the passed start date doesn't fall into any existing period SELECT period_id INTO _check FROM period WHERE (pStartDate BETWEEN period_start AND period_end); IF (FOUND) THEN RETURN -1; END IF; -- Make that the passed end date doesn't fall into any existing period SELECT period_id INTO _check FROM period WHERE (pEndDate BETWEEN period_start AND period_end); IF (FOUND) THEN RETURN -2; END IF; -- Make that the passed start and end dates don't enclose an existing period SELECT period_id INTO _check FROM period WHERE ( (period_start >= pStartDate) AND (period_end <= pEndDate) ); IF (FOUND) THEN RETURN -3; END IF; -- Make sure period is inside fiscal year SELECT yearperiod_id INTO _check FROM yearperiod WHERE ((yearperiod_id=pYearPeriodId) AND (pStartDate>=yearperiod_start) AND (pEndDate<=yearperiod_end)); IF NOT (FOUND) THEN RETURN -4; END IF; -- Determine if this is the initial accounting period SELECT CASE WHEN(count(*) > 0) THEN FALSE ELSE TRUE END INTO _initial FROM period; -- Determine the next number SELECT COALESCE(MAX(period_number),0) + 1 INTO _number FROM period WHERE (period_yearperiod_id=pYearPeriodId); -- Create the new accounting period SELECT NEXTVAL('period_period_id_seq') INTO _periodid; INSERT INTO period ( period_id, period_start, period_end, period_closed, period_freeze, period_initial, period_number, period_yearperiod_id, period_quarter ) VALUES ( _periodid, pStartDate, pEndDate, FALSE, FALSE, _initial, _number, pYearPeriodId, pQuarter ); -- Post any unposted G/L Transactions into the new period FOR _r IN SELECT DISTINCT gltrans_sequence FROM gltrans WHERE ( (NOT gltrans_posted) AND (gltrans_date BETWEEN pStartDate AND pEndDate) ) LOOP PERFORM postIntoTrialBalance(_r.gltrans_sequence); END LOOP; -- Forward Update Accounting Periods for all G/L Accounts PERFORM forwardupdatetrialbalance(max(trialbal_id)) FROM accnt LEFT OUTER JOIN trialbal ON ( (trialbal_accnt_id=accnt_id) ) GROUP BY accnt_id HAVING max(trialbal_id) IS NOT NULL ORDER BY accnt_id; RETURN _periodid; END; $_$; ALTER FUNCTION public.createaccountingperiod(date, date, integer, integer) OWNER TO admin; -- -- Name: createaccountingyearperiod(date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createaccountingyearperiod(date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pStartDate ALIAS FOR $1; pEndDate ALIAS FOR $2; _yearperiodid INTEGER; _check INTEGER; _checkBool BOOLEAN; _r RECORD; _initial BOOLEAN; BEGIN -- Make that the passed start date doesn't fall into any existing yearperiod SELECT yearperiod_id INTO _check FROM yearperiod WHERE (pStartDate BETWEEN yearperiod_start AND yearperiod_end); IF (FOUND) THEN RETURN -1; END IF; -- Make that the passed end date doesn't fall into any existing yearperiod SELECT yearperiod_id INTO _check FROM yearperiod WHERE (pEndDate BETWEEN yearperiod_start AND yearperiod_end); IF (FOUND) THEN RETURN -2; END IF; -- Make that the passed start and end dates don't enclose an existing yearperiod SELECT yearperiod_id INTO _check FROM yearperiod WHERE ( (yearperiod_start >= pStartDate) AND (yearperiod_end <= pEndDate) ); IF (FOUND) THEN RETURN -3; END IF; -- Make sure that the passed start is prior to the end date SELECT (pStartDate > pEndDate) INTO _checkBool; IF (_checkBool) THEN RETURN -5; END IF; -- Determine if this is the initial accounting yearperiod SELECT CASE WHEN(count(*) > 0) THEN FALSE ELSE TRUE END INTO _initial FROM yearperiod; -- Create the new accounting yearperiod SELECT NEXTVAL('yearperiod_yearperiod_id_seq') INTO _yearperiodid; INSERT INTO yearperiod ( yearperiod_id, yearperiod_start, yearperiod_end, yearperiod_closed ) VALUES ( _yearperiodid, pStartDate, pEndDate, FALSE ); RETURN _yearperiodid; END; $_$; ALTER FUNCTION public.createaccountingyearperiod(date, date) OWNER TO admin; -- -- Name: createapchecks(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createapchecks(integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'createAPChecks() is deprecated - use createChecks() instead'; RETURN createChecks($1, $2); END; $_$; ALTER FUNCTION public.createapchecks(integer, date) OWNER TO admin; -- -- Name: createapcreditmemo(integer, text, text, date, numeric, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createapcreditmemo(integer, text, text, date, numeric, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pDocNumber ALIAS FOR $2; pPoNumber ALIAS FOR $3; pDocDate ALIAS FOR $4; pAmount ALIAS FOR $5; pNotes ALIAS FOR $6; _result INTEGER; BEGIN SELECT createAPCreditMemo( pVendid, fetchJournalNumber('AP-MISC'), pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, -1, pDocDate, -1, baseCurrId() ) INTO _result; RETURN _result; END; $_$; ALTER FUNCTION public.createapcreditmemo(integer, text, text, date, numeric, text) OWNER TO admin; -- -- Name: createapcreditmemo(integer, integer, text, text, date, numeric, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createapcreditmemo(integer, integer, text, text, date, numeric, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pDocNumber ALIAS FOR $3; pPoNumber ALIAS FOR $4; pDocDate ALIAS FOR $5; pAmount ALIAS FOR $6; pNotes ALIAS FOR $7; BEGIN RETURN createAPCreditMemo(pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, -1, pDocDate, -1, baseCurrId() ); END; $_$; ALTER FUNCTION public.createapcreditmemo(integer, integer, text, text, date, numeric, text) OWNER TO admin; -- -- Name: createapcreditmemo(integer, text, text, date, numeric, text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createapcreditmemo(integer, text, text, date, numeric, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pDocNumber ALIAS FOR $2; pPoNumber ALIAS FOR $3; pDocDate ALIAS FOR $4; pAmount ALIAS FOR $5; pNotes ALIAS FOR $6; pAccntid ALIAS FOR $7; _result INTEGER; BEGIN SELECT createAPCreditMemo( pVendid, fetchJournalNumber('AP-MISC'), pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDocDate, -1, baseCurrId() ) INTO _result; RETURN _result; END; $_$; ALTER FUNCTION public.createapcreditmemo(integer, text, text, date, numeric, text, integer) OWNER TO admin; -- -- Name: createapcreditmemo(integer, integer, text, text, date, numeric, text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createapcreditmemo(integer, integer, text, text, date, numeric, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pDocNumber ALIAS FOR $3; pPoNumber ALIAS FOR $4; pDocDate ALIAS FOR $5; pAmount ALIAS FOR $6; pNotes ALIAS FOR $7; pAccntid ALIAS FOR $8; BEGIN RETURN createAPCreditMemo( pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDocDate, -1, baseCurrId() ); END; $_$; ALTER FUNCTION public.createapcreditmemo(integer, integer, text, text, date, numeric, text, integer) OWNER TO admin; -- -- Name: createapcreditmemo(integer, text, text, date, numeric, text, integer, date, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createapcreditmemo(integer, text, text, date, numeric, text, integer, date, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pDocNumber ALIAS FOR $2; pPoNumber ALIAS FOR $3; pDocDate ALIAS FOR $4; pAmount ALIAS FOR $5; pNotes ALIAS FOR $6; pAccntid ALIAS FOR $7; pDueDate ALIAS FOR $8; pTermsid ALIAS FOR $9; _result INTEGER; BEGIN SELECT createAPCreditMemo( pVendid, fetchJournalNumber('AP-MISC'), pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDueDate, pTermsid, baseCurrId() ) INTO _result; RETURN _result; END; $_$; ALTER FUNCTION public.createapcreditmemo(integer, text, text, date, numeric, text, integer, date, integer) OWNER TO admin; -- -- Name: createapcreditmemo(integer, integer, text, text, date, numeric, text, integer, date, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createapcreditmemo(integer, integer, text, text, date, numeric, text, integer, date, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pDocNumber ALIAS FOR $3; pPoNumber ALIAS FOR $4; pDocDate ALIAS FOR $5; pAmount ALIAS FOR $6; pNotes ALIAS FOR $7; pAccntid ALIAS FOR $8; pDueDate ALIAS FOR $9; pTermsid ALIAS FOR $10; BEGIN RETURN createAPCreditMemo( pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDueDate, pTermsid, baseCurrId() ); END; $_$; ALTER FUNCTION public.createapcreditmemo(integer, integer, text, text, date, numeric, text, integer, date, integer) OWNER TO admin; -- -- Name: createapcreditmemo(integer, integer, text, text, date, numeric, text, integer, date, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createapcreditmemo(integer, integer, text, text, date, numeric, text, integer, date, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pDocNumber ALIAS FOR $3; pPoNumber ALIAS FOR $4; pDocDate ALIAS FOR $5; pAmount ALIAS FOR $6; pNotes ALIAS FOR $7; pAccntid ALIAS FOR $8; pDueDate ALIAS FOR $9; pTermsid ALIAS FOR $10; pCurrId ALIAS FOR $11; BEGIN RETURN createAPCreditMemo( NULL, pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDueDate, pTermsid, pCurrId ); END; $_$; ALTER FUNCTION public.createapcreditmemo(integer, integer, text, text, date, numeric, text, integer, date, integer, integer) OWNER TO admin; -- -- Name: createapcreditmemo(integer, integer, integer, text, text, date, numeric, text, integer, date, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createapcreditmemo(integer, integer, integer, text, text, date, numeric, text, integer, date, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pId ALIAS FOR $1; pVendid ALIAS FOR $2; pJournalNumber ALIAS FOR $3; pDocNumber ALIAS FOR $4; pPoNumber ALIAS FOR $5; pDocDate ALIAS FOR $6; pAmount ALIAS FOR $7; pNotes ALIAS FOR $8; pAccntid ALIAS FOR $9; pDueDate ALIAS FOR $10; pTermsid ALIAS FOR $11; pCurrId ALIAS FOR $12; _vendName TEXT; _apAccntid INTEGER; _prepaidAccntid INTEGER; _accntid INTEGER; _glSequence INTEGER; _journalNumber INTEGER; _apopenid INTEGER; _baseAmount NUMERIC; _taxBaseValue NUMERIC; _test INTEGER; BEGIN _apopenid := pId; SELECT findAPAccount(pVendid) INTO _apAccntid; SELECT findAPPrepaidAccount(pVendid) INTO _prepaidAccntid; SELECT vend_name INTO _vendName FROM vendinfo WHERE (vend_id=pVendid); _accntid := pAccntid; PERFORM accnt_id FROM accnt WHERE (accnt_id=_accntid); IF (FOUND) THEN _prepaidAccntid := _accntid; ELSE _accntid := -1; END IF; IF(pJournalNumber IS NULL) THEN SELECT fetchJournalNumber('AP-MISC') INTO _journalNumber; ELSE _journalNumber := pJournalNumber; END IF; SELECT fetchGLSequence() INTO _glSequence; IF (_apopenid IS NOT NULL) THEN UPDATE apopen SET apopen_username=getEffectiveXtUser(), apopen_journalnumber=_journalNumber, apopen_vend_id=pVendid, apopen_docnumber=pDocNumber, apopen_doctype='C', apopen_ponumber=pPoNumber, apopen_docdate=pDocDate, apopen_duedate=pDueDate, apopen_distdate=pDocDate, apopen_terms_id=pTermsid, apopen_amount=pAmount, apopen_paid=0, apopen_open=(pAmount <> 0), apopen_notes=pNotes, apopen_accnt_id=_accntid, apopen_curr_id=pCurrId, apopen_closedate=CASE WHEN (pAmount = 0) THEN pDocdate END WHERE apopen_id = _apopenid; ELSE SELECT NEXTVAL('apopen_apopen_id_seq') INTO _apopenid; INSERT INTO apopen ( apopen_id, apopen_username, apopen_journalnumber, apopen_vend_id, apopen_docnumber, apopen_doctype, apopen_ponumber, apopen_docdate, apopen_duedate, apopen_distdate, apopen_terms_id, apopen_amount, apopen_paid, apopen_open, apopen_notes, apopen_accnt_id, apopen_curr_id, apopen_closedate ) VALUES ( _apopenid, getEffectiveXtUser(), _journalNumber, pVendid, pDocNumber, 'C', pPoNumber, pDocDate, pDueDate, pDocDate, pTermsid, pAmount, 0, (pAmount <> 0), pNotes, _accntid, pCurrId, CASE WHEN (pAmount = 0) THEN pDocDate END ); END IF; _baseAmount := round(currToBase(pCurrId, pAmount, pDocDate), 2); -- Debit the A/P account for the full amount SELECT insertIntoGLSeries ( _glSequence, 'A/P', 'CM', pDocNumber, _apAccntid, (_baseAmount * -1), pDocDate, (_vendName || ' ' || pNotes) ) INTO _test; -- Credit the Tax account for the tax amount _taxBaseValue := addTaxToGLSeries(_glSequence, 'A/P', 'CM', pDocNumber, pCurrId, pDocDate, pDocDate, 'apopentax', _apopenid, _vendName); UPDATE apopentax SET taxhist_journalnumber = _journalNumber WHERE taxhist_parent_id=_apopenid; -- Credit the Prepaid account for the basis amount SELECT insertIntoGLSeries ( _glSequence, 'A/P', 'CM', pDocNumber, _prepaidAccntid, (_baseAmount - _taxBaseValue), pDocDate, (_vendName || ' ' || pNotes) ) INTO _test; -- Commit the GLSeries; SELECT postGLSeries(_glSequence, _journalNumber) INTO _test; IF (_test < 0) THEN DELETE FROM apopen WHERE (apopen_id=_apopenid); PERFORM deleteGLSeries(_glSequence); RAISE EXCEPTION 'postGLSeries commit failed with %', _test; END IF; RETURN pJournalNumber; END; $_$; ALTER FUNCTION public.createapcreditmemo(integer, integer, integer, text, text, date, numeric, text, integer, date, integer, integer) OWNER TO admin; -- -- Name: createapcreditmemoapplication(integer, integer, numeric, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createapcreditmemoapplication(psourceapopenid integer, ptargetapopenid integer, pamount numeric, pcurrid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _apCreditApplyId INTEGER; BEGIN IF (pAmount > (SELECT ROUND(currToCurr(apopen_curr_id, pCurrId, (apopen_amount - apopen_paid), apopen_docdate), 2) FROM apopen WHERE (apopen_id=pTargetApopenId))) THEN RETURN -1; END IF; IF (pAmount > (SELECT ROUND((apopen_amount - apopen_paid) - COALESCE(SUM(currToCurr(apcreditapply_curr_id, apopen_curr_id, apcreditapply_amount, apopen_docdate)), 0), 2) FROM apopen LEFT OUTER JOIN apcreditapply ON ((apcreditapply_source_apopen_id=apopen_id) AND (apcreditapply_target_apopen_id<>pTargetApopenId)) WHERE (apopen_id=pSourceApopenId) GROUP BY apopen_amount, apopen_paid)) THEN RETURN -2; END IF; SELECT apcreditapply_id INTO _apCreditApplyId FROM apcreditapply WHERE ((apcreditapply_source_apopen_id=pSourceApopenId) AND (apcreditapply_target_apopen_id=pTargetApopenId)); IF (FOUND) THEN UPDATE apcreditapply SET apcreditapply_amount=pAmount, apcreditapply_curr_id=pCurrId WHERE (apcreditapply_id=_apCreditApplyId); ELSE INSERT INTO apcreditapply ( apcreditapply_source_apopen_id, apcreditapply_target_apopen_id, apcreditapply_amount, apcreditapply_curr_id ) VALUES ( pSourceApopenId, pTargetApopenId, pAmount, pCurrId) RETURNING apcreditapply_id INTO _apCreditApplyId; END IF; RETURN _apCreditApplyId; END; $$; ALTER FUNCTION public.createapcreditmemoapplication(psourceapopenid integer, ptargetapopenid integer, pamount numeric, pcurrid integer) OWNER TO admin; -- -- Name: createapdebitmemo(integer, text, text, date, numeric, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createapdebitmemo(integer, text, text, date, numeric, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pDocNumber ALIAS FOR $2; pPoNumber ALIAS FOR $3; pDocDate ALIAS FOR $4; pAmount ALIAS FOR $5; pNotes ALIAS FOR $6; _result INTEGER; BEGIN SELECT createAPDebitMemo( pVendid, fetchJournalNumber('AP-MISC'), pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, -1, pDocDate, -1, baseCurrId() ) INTO _result; RETURN _result; END; $_$; ALTER FUNCTION public.createapdebitmemo(integer, text, text, date, numeric, text) OWNER TO admin; -- -- Name: createapdebitmemo(integer, integer, text, text, date, numeric, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createapdebitmemo(integer, integer, text, text, date, numeric, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pDocNumber ALIAS FOR $3; pPoNumber ALIAS FOR $4; pDocDate ALIAS FOR $5; pAmount ALIAS FOR $6; pNotes ALIAS FOR $7; BEGIN RETURN createAPDebitMemo(pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, -1, pDocDate, -1, baseCurrId() ); END; $_$; ALTER FUNCTION public.createapdebitmemo(integer, integer, text, text, date, numeric, text) OWNER TO admin; -- -- Name: createapdebitmemo(integer, text, text, date, numeric, text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createapdebitmemo(integer, text, text, date, numeric, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pDocNumber ALIAS FOR $2; pPoNumber ALIAS FOR $3; pDocDate ALIAS FOR $4; pAmount ALIAS FOR $5; pNotes ALIAS FOR $6; pAccntid ALIAS FOR $7; _result INTEGER; BEGIN SELECT createAPDebitMemo( pVendid, fetchJournalNumber('AP-MISC'), pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDocDate, -1, baseCurrId() ) INTO _result; RETURN _result; END; $_$; ALTER FUNCTION public.createapdebitmemo(integer, text, text, date, numeric, text, integer) OWNER TO admin; -- -- Name: createapdebitmemo(integer, integer, text, text, date, numeric, text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createapdebitmemo(integer, integer, text, text, date, numeric, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pDocNumber ALIAS FOR $3; pPoNumber ALIAS FOR $4; pDocDate ALIAS FOR $5; pAmount ALIAS FOR $6; pNotes ALIAS FOR $7; pAccntid ALIAS FOR $8; BEGIN RETURN createAPDebitMemo( pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDocDate, -1, baseCurrId() ); END; $_$; ALTER FUNCTION public.createapdebitmemo(integer, integer, text, text, date, numeric, text, integer) OWNER TO admin; -- -- Name: createapdebitmemo(integer, text, text, date, numeric, text, integer, date, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createapdebitmemo(integer, text, text, date, numeric, text, integer, date, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pDocNumber ALIAS FOR $2; pPoNumber ALIAS FOR $3; pDocDate ALIAS FOR $4; pAmount ALIAS FOR $5; pNotes ALIAS FOR $6; pAccntid ALIAS FOR $7; pDueDate ALIAS FOR $8; pTermsid ALIAS FOR $9; _result INTEGER; BEGIN SELECT createAPDebitMemo( pVendid, fetchJournalNumber('AP-MISC'), pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDueDate, pTermsid, baseCurrId() ) INTO _result; RETURN _result; END; $_$; ALTER FUNCTION public.createapdebitmemo(integer, text, text, date, numeric, text, integer, date, integer) OWNER TO admin; -- -- Name: createapdebitmemo(integer, integer, text, text, date, numeric, text, integer, date, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createapdebitmemo(integer, integer, text, text, date, numeric, text, integer, date, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pDocNumber ALIAS FOR $3; pPoNumber ALIAS FOR $4; pDocDate ALIAS FOR $5; pAmount ALIAS FOR $6; pNotes ALIAS FOR $7; pAccntid ALIAS FOR $8; pDueDate ALIAS FOR $9; pTermsid ALIAS FOR $10; BEGIN RETURN createAPDebitMemo(pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDueDate, pTermsid, baseCurrId() ); END; $_$; ALTER FUNCTION public.createapdebitmemo(integer, integer, text, text, date, numeric, text, integer, date, integer) OWNER TO admin; -- -- Name: createapdebitmemo(integer, integer, text, text, date, numeric, text, integer, date, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createapdebitmemo(integer, integer, text, text, date, numeric, text, integer, date, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pDocNumber ALIAS FOR $3; pPoNumber ALIAS FOR $4; pDocDate ALIAS FOR $5; pAmount ALIAS FOR $6; pNotes ALIAS FOR $7; pAccntid ALIAS FOR $8; pDueDate ALIAS FOR $9; pTermsid ALIAS FOR $10; pCurrId ALIAS FOR $11; BEGIN RETURN createAPDebitMemo(NULL, pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDueDate, pTermsid, pCurrId ); END; $_$; ALTER FUNCTION public.createapdebitmemo(integer, integer, text, text, date, numeric, text, integer, date, integer, integer) OWNER TO admin; -- -- Name: createapdebitmemo(integer, integer, integer, text, text, date, numeric, text, integer, date, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createapdebitmemo(integer, integer, integer, text, text, date, numeric, text, integer, date, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pId ALIAS FOR $1; pVendid ALIAS FOR $2; pJournalNumber ALIAS FOR $3; pDocNumber ALIAS FOR $4; pPoNumber ALIAS FOR $5; pDocDate ALIAS FOR $6; pAmount ALIAS FOR $7; pNotes ALIAS FOR $8; pAccntid ALIAS FOR $9; pDueDate ALIAS FOR $10; pTermsid ALIAS FOR $11; pCurrId ALIAS FOR $12; _vendName TEXT; _apAccntid INTEGER; _prepaidAccntid INTEGER; _accntid INTEGER; _glSequence INTEGER; _journalNumber INTEGER; _apopenid INTEGER; _baseAmount NUMERIC; _taxBaseValue NUMERIC; _test INTEGER; BEGIN _apopenid := pId; SELECT findAPAccount(pVendid) INTO _apAccntid; SELECT findAPPrepaidAccount(pVendid) INTO _prepaidAccntid; SELECT vend_name INTO _vendName FROM vendinfo WHERE (vend_id=pVendid); _accntid := pAccntid; PERFORM accnt_id FROM accnt WHERE (accnt_id=_accntid); IF (FOUND) THEN _prepaidAccntid := _accntid; ELSE _accntid := -1; END IF; IF(pJournalNumber IS NULL) THEN SELECT fetchJournalNumber('AP-MISC') INTO _journalNumber; ELSE _journalNumber := pJournalNumber; END IF; SELECT fetchGLSequence() INTO _glSequence; IF (_apopenid IS NOT NULL) THEN UPDATE apopen SET apopen_username=getEffectiveXtUser(), apopen_journalnumber=_journalNumber, apopen_vend_id=pVendid, apopen_docnumber=pDocNumber, apopen_doctype='D', apopen_ponumber=pPoNumber, apopen_docdate=pDocDate, apopen_duedate=pDueDate, apopen_distdate=pDocDate, apopen_terms_id=pTermsid, apopen_amount=pAmount, apopen_paid=0, apopen_open=(pAmount <> 0), apopen_notes=pNotes, apopen_accnt_id=_accntid, apopen_curr_id=pCurrId, apopen_closedate=CASE WHEN (pAmount = 0) THEN pDocdate END WHERE apopen_id = _apopenid; ELSE SELECT NEXTVAL('apopen_apopen_id_seq') INTO _apopenid; INSERT INTO apopen ( apopen_id, apopen_username, apopen_journalnumber, apopen_vend_id, apopen_docnumber, apopen_doctype, apopen_ponumber, apopen_docdate, apopen_duedate, apopen_distdate, apopen_terms_id, apopen_amount, apopen_paid, apopen_discountable_amount, apopen_open, apopen_notes, apopen_accnt_id, apopen_curr_id, apopen_closedate ) VALUES ( _apopenid, getEffectiveXtUser(), _journalNumber, pVendid, pDocNumber, 'D', pPoNumber, pDocDate, pDueDate, pDocDate, pTermsid, pAmount, 0, 0, (pAmount <> 0), pNotes, _accntid, pCurrId, CASE WHEN (pAmount = 0) THEN pDocDate END ); END IF; _baseAmount := round(currToBase(pCurrId, pAmount, pDocDate), 2); -- Credit the A/P account for the full amount SELECT insertIntoGLSeries ( _glSequence, 'A/P', 'DM', pDocNumber, _apAccntid, _baseAmount, pDocDate, (_vendName || ' ' || pNotes) ) INTO _test; -- Debit the Tax account for the tax amount _taxBaseValue := addTaxToGLSeries(_glSequence, 'A/P', 'DM', pDocNumber, pCurrId, pDocDate, pDocDate, 'apopentax', _apopenid, _vendName); UPDATE apopentax SET taxhist_journalnumber = _journalNumber WHERE taxhist_parent_id=_apopenid; -- Debit the Prepaid account for the basis amount -- Note, the taxBaseValue is negative so it is added SELECT insertIntoGLSeries ( _glSequence, 'A/P', 'DM', pDocNumber, _prepaidAccntid, (_baseAmount + _taxBaseValue) * -1, pDocDate, (_vendName || ' ' || pNotes) ) INTO _test; -- Commit the GLSeries; SELECT postGLSeries(_glSequence, _journalNumber) INTO _test; IF (_test < 0) THEN DELETE FROM apopen WHERE (apopen_id=_apopenid); PERFORM deleteGLSeries(_glSequence); RAISE EXCEPTION 'postGLSeries commit failed with %', _test; END IF; RETURN _apopenid; END; $_$; ALTER FUNCTION public.createapdebitmemo(integer, integer, integer, text, text, date, numeric, text, integer, date, integer, integer) OWNER TO admin; -- -- Name: createapdiscount(integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createapdiscount(integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pApopenid ALIAS FOR $1; pAmount ALIAS FOR $2; _result INTEGER; BEGIN SELECT createAPDiscount(pApopenid, fetchJournalNumber('AP-MISC'), pAmount) INTO _result; RETURN _result; END; $_$; ALTER FUNCTION public.createapdiscount(integer, numeric) OWNER TO admin; -- -- Name: createapdiscount(integer, integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createapdiscount(integer, integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pApopenid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pAmount ALIAS FOR $3; _ap RECORD; _sequence INTEGER; _apopenid INTEGER; _apcreditapplyid INTEGER; _result INTEGER; _crAccnt INTEGER; _dbAccnt INTEGER; _reference TEXT; _discountDateAmt NUMERIC; BEGIN SELECT NEXTVAL('apopen_apopen_id_seq') INTO _apopenid; SELECT * INTO _ap FROM apopen WHERE (apopen_id = pApopenid); IF (NOT FOUND) THEN RETURN -1; END IF; _crAccnt := findAPDiscountAccount(_ap.apopen_vend_id); _dbAccnt := findAPAccount(_ap.apopen_vend_id); _reference := ('Discount for ' || _ap.apopen_doctype || ' ' || _ap.apopen_docnumber); SELECT fetchGLSequence() INTO _sequence; _discountDateAmt = round(pAmount / _ap.apopen_curr_rate, 2); PERFORM insertIntoGLSeries( _sequence, 'A/P', 'DS', _ap.apopen_docnumber, _dbAccnt, _discountDateAmt * -1, CURRENT_DATE, _reference); PERFORM insertIntoGLSeries( _sequence, 'A/P', 'DS', _ap.apopen_docnumber, _crAccnt, _discountDateAmt, CURRENT_DATE, _reference); PERFORM postGLSeries(_sequence, pJournalNumber); INSERT INTO apopen ( apopen_id, apopen_username, apopen_journalnumber, apopen_vend_id, apopen_docnumber, apopen_doctype, apopen_ponumber, apopen_docdate, apopen_duedate, apopen_distdate, apopen_terms_id, apopen_curr_id, apopen_amount, apopen_paid, apopen_open, apopen_notes, apopen_discount, apopen_curr_rate ) SELECT _apopenid, getEffectiveXtUser(), pJournalNumber, apopen_vend_id, apopen_docnumber, 'C', apopen_ponumber, CURRENT_DATE, CURRENT_DATE, CURRENT_DATE, -1, apopen_curr_id, pAmount, 0, TRUE, _reference, TRUE, apopen_curr_rate FROM apopen WHERE (apopen_id=pApopenid); SELECT apcreditapply_id INTO _apcreditapplyid FROM apcreditapply WHERE ( (apcreditapply_source_apopen_id=_apopenid) AND (apcreditapply_target_apopen_id=pApopenid) ); IF (FOUND) THEN UPDATE apcreditapply SET apcreditapply_amount=pAmount WHERE (apcreditapply_id=_apcreditapplyid); ELSE SELECT nextval('apcreditapply_apcreditapply_id_seq') INTO _apcreditapplyid; INSERT INTO apcreditapply ( apcreditapply_id, apcreditapply_source_apopen_id, apcreditapply_target_apopen_id, apcreditapply_amount, apcreditapply_curr_id ) VALUES ( _apcreditapplyid, _apopenid, pApopenid, pAmount, _ap.apopen_curr_id ); END IF; SELECT postAPCreditMemoApplication(_apopenid) INTO _result; IF (_result < 0) THEN RETURN _result; END IF; RETURN pJournalNumber; END; $_$; ALTER FUNCTION public.createapdiscount(integer, integer, numeric) OWNER TO admin; -- -- Name: createarcashdeposit(integer, text, text, date, numeric, text, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createarcashdeposit(integer, text, text, date, numeric, text, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; pDocNumber ALIAS FOR $2; pOrderNumber ALIAS FOR $3; pDocDate ALIAS FOR $4; pAmount ALIAS FOR $5; pNotes ALIAS FOR $6; pJournalNumber ALIAS FOR $7; pCurrId ALIAS FOR $8; _prepaidaccntid INTEGER; _deferredaccntid INTEGER; _glSequence INTEGER; _aropenid INTEGER; BEGIN IF (pAmount <= 0) THEN RETURN 0; END IF; _prepaidaccntid := findPrepaidAccount(pCustid); IF (_prepaidaccntid = -1) THEN RAISE EXCEPTION 'There was an error creating the Customer Deposit GL Transactions. No Prepaid Account is assigned.'; END IF; _deferredaccntid := findDeferredAccount(pCustid); IF (_deferredaccntid = -1) THEN RAISE EXCEPTION 'There was an error creating the Customer Deposit GL Transactions. No Deferred Account is assigned.'; END IF; SELECT NEXTVAL('aropen_aropen_id_seq') INTO _aropenid; SELECT insertGLTransaction( pJournalNumber, 'A/R', 'CD', pDocNumber, pNotes, _deferredaccntid, _prepaidaccntid, _aropenid, round(currToBase(pCurrId, pAmount, pDocDate), 2), pDocDate) INTO _glSequence; INSERT INTO aropen ( aropen_id, aropen_username, aropen_journalnumber, aropen_cust_id, aropen_docnumber, aropen_doctype, aropen_ordernumber, aropen_docdate, aropen_duedate, aropen_distdate, aropen_terms_id, aropen_salesrep_id, aropen_amount, aropen_paid, aropen_commission_due, aropen_commission_paid, aropen_applyto, aropen_ponumber, aropen_cobmisc_id, aropen_open, aropen_notes, aropen_rsncode_id, aropen_salescat_id, aropen_accnt_id, aropen_curr_id ) VALUES ( _aropenid, getEffectiveXtUser(), pJournalNumber, pCustid, pDocNumber, 'R', pOrderNumber, pDocDate, pDocDate, pDocDate, -1, NULL, round(pAmount, 2), 0, 0.0, FALSE, '', '', -1, TRUE, pNotes, -1, -1, -1, pCurrId ); RETURN _aropenid; END; $_$; ALTER FUNCTION public.createarcashdeposit(integer, text, text, date, numeric, text, integer, integer) OWNER TO admin; -- -- Name: createarcreditmemo(integer, integer, text, text, date, numeric, text, integer, integer, integer, date, integer, integer, numeric, integer, integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createarcreditmemo(pid integer, pcustid integer, pdocnumber text, pordernumber text, pdocdate date, pamount numeric, pnotes text, prsncodeid integer, psalescatid integer, paccntid integer, pduedate date, ptermsid integer, psalesrepid integer, pcommissiondue numeric DEFAULT 0, pjournalnumber integer DEFAULT NULL::integer, pcurrid integer DEFAULT basecurrid(), paraccntid integer DEFAULT NULL::integer, pcoccpayid integer DEFAULT NULL::integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _accntid INTEGER; _arAccntid INTEGER; _aropenid INTEGER; _cohistid INTEGER; _custName TEXT; _duedate DATE := COALESCE(pDueDate, pDocDate); _glSequence INTEGER; _journalNumber INTEGER; _prepaidAccntid INTEGER; _salescatid INTEGER; _taxBaseValue NUMERIC; _test INTEGER; _tmp INTEGER; BEGIN _aropenid := pId; _arAccntid := COALESCE(pARAccntid, findARAccount(pCustid)); _prepaidAccntid := findPrepaidAccount(pCustid); _accntid := pAccntid; _salescatid := pSalescatid; SELECT cust_name INTO _custName FROM custinfo WHERE (cust_id=pCustid); IF EXISTS(SELECT 1 FROM accnt WHERE (accnt_id=_accntid)) THEN _prepaidAccntid := _accntid; ELSE _accntid := -1; END IF; SELECT accnt_id INTO _tmp FROM salescat, accnt WHERE ((salescat_prepaid_accnt_id=accnt_id) AND (salescat_id=_salescatid)); IF (FOUND) THEN _accntid := -1; _prepaidAccntid := _tmp; ELSE _salescatid = -1; END IF; IF(pJournalNumber IS NULL) THEN SELECT fetchJournalNumber('AR-MISC') INTO _journalNumber; ELSE _journalNumber := pJournalNumber; END IF; _glSequence := fetchGLSequence(); -- CreatelUpdate aropen for full amount IF (_aropenid IS NOT NULL) THEN UPDATE aropen SET aropen_username=getEffectiveXtUser(), aropen_journalnumber=_journalNumber, aropen_cust_id=pCustid, aropen_docnumber=pDocNumber, aropen_doctype='C', aropen_ordernumber=pOrderNumber,aropen_docdate=pDocDate, aropen_duedate=_duedate, aropen_distdate=pDocDate, aropen_terms_id=pTermsid, aropen_salesrep_id=pSalesrepid, aropen_amount=round(pAmount, 2), aropen_paid=0, aropen_commission_due=pCommissiondue, aropen_commission_paid=FALSE, aropen_applyto='', aropen_ponumber='', aropen_cobmisc_id=-1, aropen_open=TRUE, aropen_notes=pNotes, aropen_rsncode_id=pRsncodeid, aropen_salescat_id=_salescatid, aropen_accnt_id=_accntid, aropen_curr_id=pCurrId WHERE aropen_id = pId; ELSE SELECT NEXTVAL('aropen_aropen_id_seq') INTO _aropenid; INSERT INTO aropen ( aropen_id, aropen_username, aropen_journalnumber, aropen_cust_id, aropen_docnumber, aropen_doctype, aropen_ordernumber, aropen_docdate, aropen_duedate, aropen_distdate, aropen_terms_id, aropen_salesrep_id, aropen_amount, aropen_paid, aropen_commission_due, aropen_commission_paid, aropen_applyto, aropen_ponumber, aropen_cobmisc_id, aropen_open, aropen_notes, aropen_rsncode_id, aropen_salescat_id, aropen_accnt_id, aropen_curr_id ) VALUES ( _aropenid, getEffectiveXtUser(), _journalNumber, pCustid, pDocNumber, 'C', pOrderNumber, pDocDate, _duedate, pDocDate, pTermsid, pSalesrepid, round(pAmount, 2), 0, pCommissiondue, FALSE, '', '', -1, TRUE, pNotes, pRsncodeid, _salescatid, _accntid, pCurrId ); END IF; -- Credit the A/R account for the full amount SELECT insertIntoGLSeries ( _glSequence, 'A/R', 'CM', pDocNumber, _arAccntid, round(currToBase(pCurrId, pAmount, pDocDate), 2), pDocDate, (_custName || ' ' || pNotes)) INTO _test; -- Debit the Tax account for the tax amount _taxBaseValue := addTaxToGLSeries(_glSequence, 'A/R', 'CM', pDocNumber, pCurrId, pDocDate, pDocDate, 'aropentax', _aropenid, (_custName || ' ' || pNotes)); UPDATE aropentax SET taxhist_journalnumber = _journalNumber WHERE taxhist_parent_id=_aropenid; -- Debit the Prepaid account for the basis amount -- Note, _taxBaseValue is negative so it is added to pAmount SELECT insertIntoGLSeries ( _glSequence, 'A/R', 'CM', pDocNumber, _prepaidAccntid, round(currToBase(pCurrId, pAmount * -1, pDocDate) + _taxBaseValue * -1, 2), pDocDate, (_custName || ' ' || pNotes)) INTO _test; -- Commit the GLSeries; SELECT postGLSeries(_glSequence, _journalNumber) INTO _test; IF (_test < 0) THEN DELETE FROM aropen WHERE (aropen_id=_aropenid); PERFORM deleteGLSeries(_glSequence); RAISE EXCEPTION 'postGLSeries commit failed with %', _test; END IF; -- Record Sales History INSERT INTO cohist ( cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_misc_type, cohist_misc_descrip, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_curr_id, cohist_sequence, cohist_cohead_ccpay_id) VALUES (CASE WHEN pCustid < 0 THEN NULL ELSE pCustid END, -1, -1, 'M', 'A/R Misc Credit Memo', pDocDate, '', pOrderNumber, '', pDocDate, 'C', pDocNumber, pDocDate, 1, (pAmount + _taxBaseValue) * -1, 0, -- taxBaseValue is negative, so we add CASE WHEN pSalesrepid < 0 THEN NULL ELSE pSalesrepid END, (pCommissiondue * -1.0), FALSE, pCurrId, _glSequence, pCoCcpayId) RETURNING cohist_id INTO _cohistid; INSERT INTO cohisttax ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM aropentax WHERE (taxhist_parent_id=_aropenid); RETURN _aropenid; END; $$; ALTER FUNCTION public.createarcreditmemo(pid integer, pcustid integer, pdocnumber text, pordernumber text, pdocdate date, pamount numeric, pnotes text, prsncodeid integer, psalescatid integer, paccntid integer, pduedate date, ptermsid integer, psalesrepid integer, pcommissiondue numeric, pjournalnumber integer, pcurrid integer, paraccntid integer, pcoccpayid integer) OWNER TO admin; -- -- Name: createardebitmemo(integer, integer, integer, text, text, date, numeric, text, integer, integer, integer, date, integer, integer, numeric, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createardebitmemo(integer, integer, integer, text, text, date, numeric, text, integer, integer, integer, date, integer, integer, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pId ALIAS FOR $1; pCustid ALIAS FOR $2; pJournalNumber ALIAS FOR $3; pDocNumber ALIAS FOR $4; pOrderNumber ALIAS FOR $5; pDocDate ALIAS FOR $6; pAmount ALIAS FOR $7; pNotes ALIAS FOR $8; pRsncodeid ALIAS FOR $9; pSalescatid ALIAS FOR $10; pAccntid ALIAS FOR $11; pDueDate ALIAS FOR $12; pTermsid ALIAS FOR $13; pSalesrepid ALIAS FOR $14; pCommissiondue ALIAS FOR $15; pCurrId ALIAS FOR $16; _custName TEXT; _journalNumber INTEGER; _arAccntid INTEGER; _prepaidAccntid INTEGER; _salescatid INTEGER; _accntid INTEGER; _glSequence INTEGER; _aropenid INTEGER; _cohistid INTEGER; _tmp INTEGER; _test INTEGER; _taxBaseValue NUMERIC; BEGIN _aropenid=pId; IF (pAmount <= 0) THEN RETURN 0; END IF; SELECT findARAccount(pCustid) INTO _arAccntid; SELECT findPrepaidAccount(pCustid) INTO _prepaidAccntid; _accntid := pAccntid; _salescatid := pSalescatid; SELECT cust_name INTO _custName FROM custinfo WHERE (cust_id=pCustid); PERFORM accnt_id FROM accnt WHERE (accnt_id=_accntid); IF (FOUND) THEN _prepaidAccntid := _accntid; ELSE _accntid := -1; END IF; SELECT accnt_id INTO _tmp FROM salescat, accnt WHERE ((salescat_prepaid_accnt_id=accnt_id) AND (salescat_id=_salescatid)); IF (FOUND) THEN _accntid := -1; _prepaidAccntid := _tmp; ELSE _salescatid = -1; END IF; IF (pJournalNumber IS NULL) THEN _journalNumber := fetchJournalNumber('AR-MISC'); ELSE _journalNumber := pJournalNumber; END IF; SELECT fetchGLSequence() INTO _glSequence; -- CreatelUpdate aropen for full amount IF (_aropenid IS NOT NULL) THEN UPDATE aropen SET aropen_username=getEffectiveXtUser(), aropen_journalnumber=_journalNumber, aropen_cust_id=pCustid, aropen_docnumber=pDocNumber, aropen_doctype='D', aropen_ordernumber=pOrderNumber,aropen_docdate=pDocDate, aropen_duedate=pDueDate, aropen_distdate=pDocDate, aropen_terms_id=pTermsid, aropen_salesrep_id=pSalesrepid, aropen_amount=round(pAmount, 2), aropen_paid=0, aropen_commission_due=pCommissiondue, aropen_commission_paid=FALSE, aropen_applyto='', aropen_ponumber='', aropen_cobmisc_id=-1, aropen_open=TRUE, aropen_notes=pNotes, aropen_rsncode_id=pRsncodeid, aropen_salescat_id=_salescatid, aropen_accnt_id=_accntid, aropen_curr_id=pCurrId WHERE aropen_id = pId; ELSE SELECT NEXTVAL('aropen_aropen_id_seq') INTO _aropenid; INSERT INTO aropen ( aropen_id, aropen_username, aropen_journalnumber, aropen_cust_id, aropen_docnumber, aropen_doctype, aropen_ordernumber, aropen_docdate, aropen_duedate, aropen_distdate, aropen_terms_id, aropen_salesrep_id, aropen_amount, aropen_paid, aropen_commission_due, aropen_commission_paid, aropen_applyto, aropen_ponumber, aropen_cobmisc_id, aropen_open, aropen_notes, aropen_rsncode_id, aropen_salescat_id, aropen_accnt_id, aropen_curr_id ) VALUES ( _aropenid, getEffectiveXtUser(), _journalNumber, pCustid, pDocNumber, 'D', pOrderNumber, pDocDate, pDueDate, pDocDate, pTermsid, pSalesrepid, round(pAmount, 2), 0, pCommissiondue, FALSE, '', '', -1, TRUE, pNotes, pRsncodeid, _salescatid, _accntid, pCurrId ); END IF; -- Debit the A/R account for the full amount SELECT insertIntoGLSeries ( _glSequence, 'A/R', 'DM', pDocNumber, _arAccntid, round(currToBase(pCurrId, pAmount, pDocDate) * -1, 2), pDocDate, (_custName || ' ' || pNotes)) INTO _test; -- Credit the Tax account for the tax amount _taxBaseValue := addTaxToGLSeries(_glSequence, 'A/R', 'DM', pDocNumber, pCurrId, pDocDate, pDocDate, 'aropentax', _aropenid, (_custName || ' ' || pNotes)); UPDATE aropentax SET taxhist_journalnumber = _journalNumber WHERE taxhist_parent_id=_aropenid; -- Credit the Prepaid account for the basis amount SELECT insertIntoGLSeries ( _glSequence, 'A/R', 'DM', pDocNumber, _prepaidAccntid, round(currToBase(pCurrId, (pAmount), pDocDate), 2) - _taxBaseValue, pDocDate, (_custName || ' ' || pNotes)) INTO _test; -- Commit the GLSeries; SELECT postGLSeries(_glSequence, _journalNumber) INTO _test; IF (_test < 0) THEN DELETE FROM aropen WHERE (aropen_id=_aropenid); PERFORM deleteGLSeries(_glSequence); RAISE EXCEPTION 'postGLSeries commit failed with %', _test; END IF; -- Record Sales History SELECT nextval('cohist_cohist_id_seq') INTO _cohistid; INSERT INTO cohist ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_misc_type, cohist_misc_descrip, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_curr_id, cohist_sequence ) VALUES ( _cohistid, pCustid, -1, -1, 'M', 'A/R Misc Debit Memo', pDocDate, '', '', '', pDocDate, 'D', pDocNumber, pDocDate, 1, (pAmount - _taxBaseValue), 0, pSalesrepid, pCommissiondue, FALSE, pCurrId, _glSequence ); INSERT INTO cohisttax ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM aropentax WHERE (taxhist_parent_id=_aropenid); RETURN _aropenid; END; $_$; ALTER FUNCTION public.createardebitmemo(integer, integer, integer, text, text, date, numeric, text, integer, integer, integer, date, integer, integer, numeric, integer) OWNER TO admin; -- -- Name: createbillingheader(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createbillingheader(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; _cobmiscid INTEGER; _cohead cohead%ROWTYPE; _miscApplied NUMERIC := 0.0; _freight NUMERIC; _freighttypeid INTEGER; _invcDate DATE; _schedDate DATE; _shipDate DATE; _shipVia TEXT; _tax NUMERIC; BEGIN -- Fetch cohead SELECT * INTO _cohead FROM cohead WHERE (cohead_id=pSoheadid); -- Check for an existing cobmisc SELECT cobmisc_id INTO _cobmiscid FROM cobmisc WHERE ( (NOT cobmisc_posted) AND (cobmisc_cohead_id=pSoheadid) ); IF (FOUND) THEN -- Find a Shipping-Entered freight charge SELECT SUM(currToCurr(shiphead_freight_curr_id, _cohead.cohead_curr_id, shiphead_freight, CURRENT_DATE)) INTO _freight FROM ( SELECT shiphead_id, shiphead_freight_curr_id, shiphead_freight FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id AND NOT shipitem_invoiced) WHERE ((shiphead_order_type='SO') AND (shiphead_order_id=pSoheadid)) GROUP BY shiphead_id, shiphead_freight_curr_id, shiphead_freight) AS data; IF (_freight IS NOT NULL) THEN UPDATE cobmisc SET cobmisc_freight = _freight WHERE (cobmisc_id=_cobmiscid); END IF; RETURN _cobmiscid; END IF; -- Find misc charges that have already been applied for the S/O SELECT COALESCE(SUM(cobmisc_misc), 0.0) INTO _miscApplied FROM cobmisc WHERE (cobmisc_cohead_id=pSoheadid); SELECT NEXTVAL('cobmisc_cobmisc_id_seq') INTO _cobmiscid; -- Check for a valid shipdate SELECT MIN(shiphead_shipdate) INTO _shipDate FROM shiphead, shipitem WHERE ( (shipitem_shiphead_id=shiphead_id) AND (NOT shipitem_invoiced) AND (shiphead_shipped) AND (shiphead_order_type='SO') AND (shiphead_order_id=pSoheadid) ); -- Schema shouldn't allow, but we'll try for now IF (_shipDate IS NULL) THEN SELECT MAX(shipitem_shipdate) INTO _shipDate FROM shipitem, shiphead WHERE ( (shipitem_shiphead_id=shiphead_id) AND (shiphead_order_type='SO') AND (shiphead_order_id=pSoheadid) ); -- How about a transaction date IF (_shipDate IS NULL) THEN SELECT COALESCE(MAX(shipitem_transdate), CURRENT_DATE) INTO _shipDate FROM shipitem, shiphead WHERE ((shipitem_shiphead_id=shiphead_id) AND (shiphead_order_type='SO') AND (shiphead_order_id=pSoheadid) ); END IF; END IF; -- Get the earliest schedule date for this order. SELECT MIN(coitem_scheddate) INTO _schedDate FROM coitem WHERE ((coitem_status <> 'X') AND (coitem_cohead_id=pSoheadid)); IF (_schedDate IS NULL) THEN _schedDate := _shipDate; END IF; -- Find a Shipping-Entered freight charge SELECT SUM(currToCurr(shiphead_freight_curr_id, _cohead.cohead_curr_id, shiphead_freight, CURRENT_DATE)), shiphead_shipvia INTO _freight, _shipVia FROM ( SELECT shiphead_id, shiphead_freight_curr_id, shiphead_freight, shiphead_shipvia FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id AND NOT shipitem_invoiced) WHERE ((shiphead_order_type='SO') AND (shiphead_order_id=pSoheadid)) GROUP BY shiphead_id, shiphead_freight_curr_id, shiphead_freight, shiphead_shipvia) AS data GROUP BY shiphead_shipvia; -- Nope, use the cohead freight charge IF (_freight IS NULL) THEN _freight := _cohead.cohead_freight; END IF; -- Finally, look for a Shipping-Entered Ship Via SELECT shiphead_shipvia INTO _shipVia FROM shiphead, shipitem WHERE ( (shipitem_shiphead_id=shiphead_id) AND (NOT shipitem_invoiced) AND (shiphead_order_type='SO') AND (shiphead_order_id=pSoheadid) ) LIMIT 1; IF (NOT FOUND) THEN _shipVia := _cohead.cohead_shipvia; END IF; --Determine any tax SELECT getFreightTaxTypeId() INTO _freighttypeid; SELECT SUM(COALESCE(taxdetail_tax, 0.00)) INTO _tax FROM calculatetaxdetail(_cohead.cohead_taxzone_id, _freighttypeid, _cohead.cohead_orderdate,_cohead.cohead_curr_id, _freight); -- Determine if we are using the _shipDate or _schedDate or current_date for the _invcDate IF( fetchMetricText('InvoiceDateSource')='scheddate') THEN _invcDate := _schedDate; ELSIF( fetchMetricText('InvoiceDateSource')='shipdate') THEN _invcDate := _shipDate; ELSE _invcDate := current_date; END IF; INSERT INTO cobmisc ( cobmisc_id, cobmisc_cohead_id, cobmisc_shipvia, cobmisc_freight, cobmisc_misc, cobmisc_payment ,cobmisc_notes,cobmisc_shipdate ,cobmisc_invcdate,cobmisc_posted ,cobmisc_misc_accnt_id ,cobmisc_misc_descrip,cobmisc_closeorder,cobmisc_curr_id ,cobmisc_taxtype_id,cobmisc_taxzone_id ) SELECT _cobmiscid,_cohead.cohead_id,_shipVia,_freight, CASE WHEN (_cohead.cohead_misc - _miscApplied = 0.0) THEN 0.0 ELSE (_cohead.cohead_misc - _miscApplied) END,0, _cohead.cohead_ordercomments,_shipDate,_invcDate,FALSE,_cohead.cohead_misc_accnt_id, _cohead.cohead_misc_descrip,NOT(cust_backorder),_cohead.cohead_curr_id, _cohead.cohead_taxtype_id,_cohead.cohead_taxzone_id FROM custinfo WHERE (cust_id=_cohead.cohead_cust_id); RETURN _cobmiscid; END; $_$; ALTER FUNCTION public.createbillingheader(integer) OWNER TO admin; -- -- Name: createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pBomitemid ALIAS FOR $1; pParentItemid ALIAS FOR $2; pComponentItemid ALIAS FOR $3; pSeqNumber ALIAS FOR $4; pIssueMethod ALIAS FOR $5; pUomId ALIAS FOR $6; pQtyPer ALIAS FOR $7; pScrap ALIAS FOR $8; pEffective ALIAS FOR $9; pExpires ALIAS FOR $10; pCreateWo ALIAS FOR $11; pBOOItemseqid ALIAS FOR $12; pSchedAtWooper ALIAS FOR $13; pECN ALIAS FOR $14; pSubType ALIAS FOR $15; pRevisionid ALIAS FOR $16; pCharId ALIAS FOR $17; pCharVal ALIAS FOR $18; _bomworksetid INTEGER; _temp INTEGER; _bomitemid INTEGER; BEGIN SELECT createBOMItem( pBomitemid, pParentItemid, pComponentItemid, pSeqNumber, pIssueMethod, pUomId, pQtyPer, pScrap, pEffective, pExpires, pCreateWo, pBOOItemseqid, pSchedAtWooper, pECN, pSubType, pRevisionid, pCharId, pCharVal, NULL, NULL ) INTO _bomitemid; RETURN _bomitemid; END; $_$; ALTER FUNCTION public.createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text) OWNER TO admin; -- -- Name: createbomitem(integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createbomitem(integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pBomitemid ALIAS FOR $1; pParentItemid ALIAS FOR $2; pComponentItemid ALIAS FOR $3; pIssueMethod ALIAS FOR $4; pUomId ALIAS FOR $5; pQtyPer ALIAS FOR $6; pScrap ALIAS FOR $7; pEffective ALIAS FOR $8; pExpires ALIAS FOR $9; pCreateWo ALIAS FOR $10; pBOOItemseqid ALIAS FOR $11; pSchedAtWooper ALIAS FOR $12; pECN ALIAS FOR $13; pSubType ALIAS FOR $14; pRevisionid ALIAS FOR $15; pCharId ALIAS FOR $16; pCharVal ALIAS FOR $17; pNotes ALIAS FOR $18; pRef ALIAS FOR $19; _seqNumber INTEGER; _bomitemid INTEGER; BEGIN -- Grab the next Sequence Number, if any SELECT MAX(bomitem_seqnumber) INTO _seqNumber FROM bomitem(pParentItemid,pRevisionid); IF (_seqNumber IS NOT NULL) THEN _seqNumber := (_seqNumber + 10); ELSE _seqNumber := 10; END IF; SELECT createBOMItem( pBomitemid, pParentItemid, pComponentItemid, _seqNumber, pIssueMethod, pUomId, pQtyPer, pScrap, pEffective, pExpires, pCreateWo, pBOOItemseqid, pSchedAtWooper, pECN, pSubType, pRevisionid, pCharId, pCharVal, pNotes, pRef ) INTO _bomitemid; RETURN _bomitemid; END; $_$; ALTER FUNCTION public.createbomitem(integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text) OWNER TO admin; -- -- Name: createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBomitemid ALIAS FOR $1; pParentItemid ALIAS FOR $2; pComponentItemid ALIAS FOR $3; pSeqNumber ALIAS FOR $4; pIssueMethod ALIAS FOR $5; pUomId ALIAS FOR $6; pQtyFxd ALIAS FOR $7; pQtyPer ALIAS FOR $8; pScrap ALIAS FOR $9; pEffective ALIAS FOR $10; pExpires ALIAS FOR $11; pCreateWo ALIAS FOR $12; pBOOItemseqid ALIAS FOR $13; pSchedAtWooper ALIAS FOR $14; pECN ALIAS FOR $15; pSubType ALIAS FOR $16; pRevisionid ALIAS FOR $17; pCharId ALIAS FOR $18; pCharVal ALIAS FOR $19; _bomworksetid INTEGER; _temp INTEGER; _bomitemid INTEGER; BEGIN SELECT createBOMItem( pBomitemid, pParentItemid, pComponentItemid, pSeqNumber, pIssueMethod, pUomId, pQtyFxd, pQtyPer, pScrap, pEffective, pExpires, pCreateWo, pBOOItemseqid, pSchedAtWooper, pECN, pSubType, pRevisionid, pCharId, pCharVal, NULL, NULL ) INTO _bomitemid; RETURN _bomitemid; END; $_$; ALTER FUNCTION public.createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text) OWNER TO admin; -- -- Name: createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pBomitemid ALIAS FOR $1; pParentItemid ALIAS FOR $2; pComponentItemid ALIAS FOR $3; pSeqNumber ALIAS FOR $4; pIssueMethod ALIAS FOR $5; pUomId ALIAS FOR $6; pQtyPer ALIAS FOR $7; pScrap ALIAS FOR $8; pEffective ALIAS FOR $9; pExpires ALIAS FOR $10; pCreateWo ALIAS FOR $11; pBOOItemseqid ALIAS FOR $12; pSchedAtWooper ALIAS FOR $13; pECN ALIAS FOR $14; pSubType ALIAS FOR $15; pRevisionid ALIAS FOR $16; pCharId ALIAS FOR $17; pCharVal ALIAS FOR $18; pNotes ALIAS FOR $19; pRef ALIAS FOR $20; _bomworksetid INTEGER; _temp INTEGER; BEGIN -- Make sure that the parent and component are not the same IF (pParentItemid = pComponentItemid) THEN RETURN -1; END IF; -- Make sure that the parent is not used in the component at some level IF ( SELECT (item_type IN ('M', 'F')) FROM item WHERE (item_id=pComponentItemid) ) THEN SELECT indentedWhereUsed(pParentItemid) INTO _bomworksetid; SELECT bomwork_id INTO _temp FROM bomwork WHERE ( (bomwork_set_id=_bomworksetid) AND (bomwork_item_id=pComponentItemid) ) LIMIT 1; IF (FOUND) THEN PERFORM deleteBOMWorkset(_bomworksetid); RETURN -2; END IF; END IF; PERFORM deleteBOMWorkset(_bomworksetid); -- Create the BOM Item INSERT INTO bomitem ( bomitem_id, bomitem_parent_item_id, bomitem_item_id, bomitem_seqnumber, bomitem_issuemethod, bomitem_uom_id, bomitem_qtyper, bomitem_scrap, bomitem_effective, bomitem_expires, bomitem_createwo, bomitem_booitem_seq_id, bomitem_schedatwooper, bomitem_ecn, bomitem_subtype, bomitem_moddate, bomitem_rev_id, bomitem_char_id, bomitem_value, bomitem_notes, bomitem_ref ) VALUES ( pBomitemid, pParentItemid, pComponentItemid, pSeqNumber, pIssueMethod, pUomId, pQtyPer, pScrap, pEffective, pExpires, pCreateWo, pBOOItemseqid, COALESCE(pSchedAtWooper, FALSE), pECN, pSubType, CURRENT_DATE, pRevisionid, pCharId,pCharVal,pNotes, pRef ); RETURN pBomitemid; END; $_$; ALTER FUNCTION public.createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text) OWNER TO admin; -- -- Name: createbomitem(integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createbomitem(integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBomitemid ALIAS FOR $1; pParentItemid ALIAS FOR $2; pComponentItemid ALIAS FOR $3; pIssueMethod ALIAS FOR $4; pUomId ALIAS FOR $5; pQtyFxd ALIAS FOR $6; pQtyPer ALIAS FOR $7; pScrap ALIAS FOR $8; pEffective ALIAS FOR $9; pExpires ALIAS FOR $10; pCreateWo ALIAS FOR $11; pBOOItemseqid ALIAS FOR $12; pSchedAtWooper ALIAS FOR $13; pECN ALIAS FOR $14; pSubType ALIAS FOR $15; pRevisionid ALIAS FOR $16; pCharId ALIAS FOR $17; pCharVal ALIAS FOR $18; pNotes ALIAS FOR $19; pRef ALIAS FOR $20; _seqNumber INTEGER; _bomitemid INTEGER; BEGIN -- Grab the next Sequence Number, if any SELECT MAX(bomitem_seqnumber) INTO _seqNumber FROM bomitem(pParentItemid,pRevisionid); IF (_seqNumber IS NOT NULL) THEN _seqNumber := (_seqNumber + 10); ELSE _seqNumber := 10; END IF; SELECT createBOMItem( pBomitemid, pParentItemid, pComponentItemid, _seqNumber, pIssueMethod, pUomId, pQtyFxd, pQtyPer, pScrap, pEffective, pExpires, pCreateWo, pBOOItemseqid, pSchedAtWooper, pECN, pSubType, pRevisionid, pCharId, pCharVal, pNotes, pRef ) INTO _bomitemid; RETURN _bomitemid; END; $_$; ALTER FUNCTION public.createbomitem(integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text) OWNER TO admin; -- -- Name: createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBomitemid ALIAS FOR $1; pParentItemid ALIAS FOR $2; pComponentItemid ALIAS FOR $3; pSeqNumber ALIAS FOR $4; pIssueMethod ALIAS FOR $5; pUomId ALIAS FOR $6; pQtyFxd ALIAS FOR $7; pQtyPer ALIAS FOR $8; pScrap ALIAS FOR $9; pEffective ALIAS FOR $10; pExpires ALIAS FOR $11; pCreateWo ALIAS FOR $12; pBOOItemseqid ALIAS FOR $13; pSchedAtWooper ALIAS FOR $14; pECN ALIAS FOR $15; pSubType ALIAS FOR $16; pRevisionid ALIAS FOR $17; pCharId ALIAS FOR $18; pCharVal ALIAS FOR $19; pNotes ALIAS FOR $20; pRef ALIAS FOR $21; _bomworksetid INTEGER; _temp INTEGER; BEGIN -- Make sure that the parent and component are not the same IF (pParentItemid = pComponentItemid) THEN RETURN -1; END IF; -- Make sure that the parent is not used in the component at some level SELECT indentedWhereUsed(pParentItemid) INTO _bomworksetid; SELECT bomwork_id INTO _temp FROM bomwork WHERE ( (bomwork_set_id=_bomworksetid) AND (bomwork_item_id=pComponentItemid) ) LIMIT 1; IF (FOUND) THEN PERFORM deleteBOMWorkset(_bomworksetid); RETURN -2; END IF; PERFORM deleteBOMWorkset(_bomworksetid); -- Create the BOM Item INSERT INTO bomitem ( bomitem_id, bomitem_parent_item_id, bomitem_item_id, bomitem_seqnumber, bomitem_issuemethod, bomitem_uom_id, bomitem_qtyfxd, bomitem_qtyper, bomitem_scrap, bomitem_effective, bomitem_expires, bomitem_createwo, bomitem_booitem_seq_id, bomitem_schedatwooper, bomitem_ecn, bomitem_subtype, bomitem_moddate, bomitem_rev_id, bomitem_char_id, bomitem_value, bomitem_notes, bomitem_ref ) VALUES ( pBomitemid, pParentItemid, pComponentItemid, pSeqNumber, pIssueMethod, pUomId, pQtyFxd, pQtyPer, pScrap, pEffective, pExpires, pCreateWo, pBOOItemseqid, COALESCE(pSchedAtWooper, FALSE), pECN, pSubType, CURRENT_DATE, pRevisionid, pCharId,pCharVal,pNotes, pRef ); RETURN pBomitemid; END; $_$; ALTER FUNCTION public.createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text) OWNER TO admin; -- -- Name: createcheck(integer, text, integer, date, numeric, integer, integer, integer, text, text, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createcheck(integer, text, integer, date, numeric, integer, integer, integer, text, text, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBankaccntid ALIAS FOR $1; pRecipType ALIAS FOR $2; pRecipId ALIAS FOR $3; pCheckDate ALIAS FOR $4; pAmount ALIAS FOR $5; pCurrid ALIAS FOR $6; pExpcatid ALIAS FOR $7; _journalNumber INTEGER := $8; pFor ALIAS FOR $9; pNotes ALIAS FOR $10; pMisc ALIAS FOR $11; _checkid INTEGER; BEGIN SELECT createCheck(pBankaccntid,pRecipType,pRecipId,pCheckDate,pAmount,pCurrid,pExpcatid,_journalNumber,pFor,pNotes,pMisc,NULL) INTO _checkid; RETURN _checkid; END; $_$; ALTER FUNCTION public.createcheck(integer, text, integer, date, numeric, integer, integer, integer, text, text, boolean) OWNER TO admin; -- -- Name: createcheck(integer, text, integer, date, numeric, integer, integer, integer, text, text, boolean, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createcheck(integer, text, integer, date, numeric, integer, integer, integer, text, text, boolean, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBankaccntid ALIAS FOR $1; pRecipType ALIAS FOR $2; pRecipId ALIAS FOR $3; pCheckDate ALIAS FOR $4; pAmount ALIAS FOR $5; pCurrid ALIAS FOR $6; pExpcatid ALIAS FOR $7; _journalNumber INTEGER := $8; pFor ALIAS FOR $9; pNotes ALIAS FOR $10; pMisc ALIAS FOR $11; pAropenid ALIAS FOR $12; _checkid INTEGER; _checknumber INTEGER := -1; _check_curr_rate NUMERIC; _bankaccnt_currid INTEGER; _bankaccnt_prnt_check BOOLEAN; BEGIN SELECT bankaccnt_curr_id,currRate(bankaccnt_curr_id,pCheckDate), bankaccnt_prnt_check INTO _bankaccnt_currid, _check_curr_rate, _bankaccnt_prnt_check FROM bankaccnt WHERE bankaccnt_id = pBankaccntid; IF (NOT FOUND) THEN RETURN -1; END IF; IF (pRecipType NOT IN ('C', 'T', 'V')) THEN RETURN -2; END IF; IF (pCheckDate IS NULL) THEN RETURN -3; END IF; IF (pAmount <= 0) THEN RETURN -4; END IF; IF (pCurrid IS NULL OR NOT EXISTS(SELECT * FROM curr_symbol WHERE (curr_id=pCurrid))) THEN RETURN -5; END IF; IF (pExpcatid IS NOT NULL AND NOT EXISTS(SELECT * FROM expcat WHERE (expcat_id=pExpcatid))) THEN RETURN -6; END IF; -- Do not assign Journal Number until check is posted -- if (_journalNumber IS NULL) THEN -- _journalNumber := fetchJournalNumber('AP-CK'); -- END IF; IF (NOT _bankaccnt_prnt_check) THEN SELECT fetchNextCheckNumber(pBankaccntid) INTO _checknumber; END IF; _checkid := NEXTVAL('checkhead_checkhead_id_seq'); INSERT INTO checkhead ( checkhead_id, checkhead_recip_type, checkhead_recip_id, checkhead_bankaccnt_id, checkhead_number, checkhead_amount, checkhead_checkdate, checkhead_misc, checkhead_expcat_id, checkhead_journalnumber, checkhead_for, checkhead_notes, checkhead_curr_id ) VALUES ( _checkid, pRecipType, pRecipId, pBankaccntid, _checknumber, currToCurr(pCurrid, _bankaccnt_currid, pAmount, pCheckDate), pCheckDate, COALESCE(pMisc, FALSE), pExpcatid, _journalNumber, pFor, pNotes, _bankaccnt_currid ); IF (pAropenid IS NOT NULL AND fetchmetricbool('EnableReturnAuth')) THEN INSERT INTO checkitem (checkitem_checkhead_id,checkitem_amount,checkitem_discount,checkitem_ponumber, checkitem_aropen_id,checkitem_docdate,checkitem_curr_id,checkitem_cmnumber, checkitem_ranumber, checkitem_curr_rate) SELECT _checkid, currToCurr(checkhead_curr_id, aropen_curr_id, pAmount, checkhead_checkdate), 0,cmhead_custponumber,pAropenid,aropen_docdate,aropen_curr_id,cmhead_number,rahead_number, 1 / (_check_curr_rate / aropen_curr_rate) FROM checkhead, aropen LEFT OUTER JOIN cmhead ON (aropen_docnumber=cmhead_number) LEFT OUTER JOIN rahead ON (cmhead_rahead_id=rahead_id) WHERE ((aropen_id=pAropenid) AND (checkhead_id=_checkid)); ELSIF (pAropenid IS NOT NULL) THEN INSERT INTO checkitem (checkitem_checkhead_id,checkitem_amount,checkitem_discount,checkitem_ponumber, checkitem_aropen_id,checkitem_docdate,checkitem_curr_id,checkitem_cmnumber, checkitem_ranumber, checkitem_curr_rate) SELECT _checkid,currToCurr(checkhead_curr_id, aropen_curr_id, pAmount, checkhead_checkdate), 0,cmhead_custponumber,pAropenid,aropen_docdate,aropen_curr_id,cmhead_number,NULL, 1 / (_check_curr_rate / aropen_curr_rate) FROM checkhead, aropen LEFT OUTER JOIN cmhead ON (aropen_docnumber=cmhead_number) WHERE ((aropen_id=pAropenid) AND (checkhead_id=_checkid)); END IF; RETURN _checkid; END; $_$; ALTER FUNCTION public.createcheck(integer, text, integer, date, numeric, integer, integer, integer, text, text, boolean, integer) OWNER TO admin; -- -- Name: createchecks(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createchecks(pbankaccntid integer, pcheckdate date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _v RECORD; _r RECORD; _c RECORD; _checkid INTEGER; _counter INTEGER := 0; _check_curr_id INTEGER; _check_curr_rate NUMERIC; BEGIN SELECT bankaccnt_curr_id, currRate(bankaccnt_curr_id, pCheckDate) INTO _check_curr_id, _check_curr_rate FROM bankaccnt WHERE ( bankaccnt_id = pBankaccntid ); FOR _v IN SELECT DISTINCT vend_id, vend_number, vend_name FROM apselect JOIN apopen ON (apselect_apopen_id=apopen_id) JOIN vendinfo ON (apopen_vend_id=vend_id) WHERE ((apselect_bankaccnt_id=pBankaccntid) AND (apselect_date <= pCheckDate)) LOOP -- if we owe this vendor anything (we might not) then create a check -- allow $0 checks IF ((SELECT SUM(CASE apopen_doctype WHEN 'C' THEN (apselect_amount * -1.0) ELSE apselect_amount END * _check_curr_rate / apopen_curr_rate) FROM apselect JOIN apopen ON (apopen_id=apselect_apopen_id) WHERE ((apopen_vend_id=_v.vend_id) AND (apselect_bankaccnt_id=pBankaccntid)) ) >= 0) THEN -- 0.01 is a temporary amount; we''ll update the check amount later _checkid := createCheck(pBankaccntid, 'V', _v.vend_id, pCheckDate, 0.01, _check_curr_id, NULL, NULL, '', '', FALSE); FOR _r IN SELECT apopen_id, apselect_id, apopen_docnumber, apopen_invcnumber, apopen_ponumber, apopen_docdate, apselect_curr_id, apselect_amount, apselect_discount FROM apselect, apopen WHERE ( (apselect_apopen_id=apopen_id) AND (apopen_vend_id=_v.vend_id) AND (apselect_bankaccnt_id=pBankaccntid) ) LOOP INSERT INTO checkitem ( checkitem_checkhead_id, checkitem_apopen_id, checkitem_vouchernumber, checkitem_invcnumber, checkitem_ponumber, checkitem_amount, checkitem_discount, checkitem_docdate, checkitem_curr_id, checkitem_curr_rate ) VALUES ( _checkid, _r.apopen_id, _r.apopen_docnumber, _r.apopen_invcnumber, _r.apopen_ponumber, _r.apselect_amount, _r.apselect_discount, _r.apopen_docdate, _r.apselect_curr_id, 1 / (_check_curr_rate / currRate(_r.apselect_curr_id, pCheckdate)) ); DELETE FROM apselect WHERE (apselect_id=_r.apselect_id); END LOOP; -- one check can pay for purchases on multiple dates in multiple currencies UPDATE checkhead SET checkhead_amount = (SELECT SUM(CASE WHEN (apopen_doctype='C') THEN checkitem_amount / checkitem_curr_rate * -1.0 ELSE checkitem_amount / checkitem_curr_rate END) FROM checkitem LEFT OUTER JOIN apopen ON (apopen_id=checkitem_apopen_id) WHERE (checkitem_checkhead_id=checkhead_id)) WHERE (checkhead_id=_checkid); _counter := (_counter + 1); END IF; END LOOP; RETURN _counter; END; $_$; ALTER FUNCTION public.createchecks(pbankaccntid integer, pcheckdate date) OWNER TO admin; -- -- Name: createcounttag(integer, text, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createcounttag(integer, text, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pComments ALIAS FOR $2; pPriority ALIAS FOR $3; pFreeze ALIAS FOR $4; BEGIN RETURN createCountTag(pItemsiteid, pComments, pPriority, pFreeze, NULL); END; $_$; ALTER FUNCTION public.createcounttag(integer, text, boolean, boolean) OWNER TO admin; -- -- Name: createcounttag(integer, text, boolean, boolean, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createcounttag(integer, text, boolean, boolean, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pComments ALIAS FOR $2; pPriority ALIAS FOR $3; pFreeze ALIAS FOR $4; pLocationid ALIAS FOR $5; _invcntid INTEGER; _whs RECORD; _type CHARACTER; _controlmethod CHARACTER; BEGIN SELECT item_type, itemsite_controlmethod INTO _type, _controlmethod FROM itemsite, item WHERE ((itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid)); IF (NOT FOUND OR _type IN ('F', 'R', 'L','J') OR _controlmethod = 'N') THEN RETURN 0; -- We simply do not do these item types. END IF; -- Test for existing tags IF (pLocationid IS NULL) THEN SELECT invcnt_id INTO _invcntid FROM invcnt WHERE ((NOT invcnt_posted) AND (invcnt_location_id IS NULL) AND (invcnt_itemsite_id=pItemsiteid)); ELSE SELECT invcnt_id INTO _invcntid FROM invcnt WHERE ((NOT invcnt_posted) AND (invcnt_itemsite_id=pItemsiteid) AND (invcnt_location_id=pLocationid)); END IF; IF (NOT FOUND) THEN SELECT NEXTVAL('invcnt_invcnt_id_seq') INTO _invcntid; SELECT whsinfo.* INTO _whs FROM whsinfo, itemsite WHERE ((warehous_id=itemsite_warehous_id) AND (itemsite_id=pItemsiteid)); INSERT INTO invcnt ( invcnt_id, invcnt_itemsite_id, invcnt_tagdate, invcnt_tagnumber, invcnt_tag_username, invcnt_posted, invcnt_priority, invcnt_comments, invcnt_location_id ) VALUES ( _invcntid, pItemsiteid, CURRENT_TIMESTAMP, (_whs.warehous_counttag_prefix || _whs.warehous_counttag_number::TEXT), getEffectiveXtUser(), FALSE, pPriority, pComments, pLocationid ); UPDATE whsinfo SET warehous_counttag_number=(warehous_counttag_number + 1) WHERE (warehous_id=_whs.warehous_id); IF (pFreeze) THEN UPDATE itemsite SET itemsite_freeze=TRUE WHERE (itemsite_id=pItemsiteid); END IF; END IF; RETURN _invcntid; END; $_$; ALTER FUNCTION public.createcounttag(integer, text, boolean, boolean, integer) OWNER TO admin; -- -- Name: createcustomer(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createcustomer(integer) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pcrmacctId ALIAS FOR $1; _custId INTEGER := 0; BEGIN IF (pcrmacctId < 0 OR pcrmacctId IS NULL) THEN RETURN -1; END IF; SELECT crmacct_cust_id INTO _custId FROM crmacct WHERE crmacct_id = pcrmacctId; IF (_custId IS NOT NULL AND _custId <= 0) THEN RETURN -2; END IF; INSERT INTO _customer (active, customer_number, customer_name) SELECT crmacct_active, crmacct_number, crmacct_name FROM crmacct WHERE crmacct_id = pcrmacctId; _custId := CURRVAL('cust_cust_id_seq'); UPDATE crmacct SET crmacct_prospect_id = NULL, crmacct_cust_id = _custId WHERE crmacct_id = pcrmacctId; RETURN _custId; END; $_$; ALTER FUNCTION public.createcustomer(integer) OWNER TO admin; -- -- Name: createcyclecountsbywarehouse(integer, integer, text, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createcyclecountsbywarehouse(integer, integer, text, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pMaxNumber ALIAS FOR $2; pComments ALIAS FOR $3; pPriority ALIAS FOR $4; pFreeze ALIAS FOR $5; BEGIN RETURN createCycleCountsByWarehouse(pWarehousid, pMaxNumber, pComments, pPriority, pFreeze, NULL, FALSE); END; $_$; ALTER FUNCTION public.createcyclecountsbywarehouse(integer, integer, text, boolean, boolean) OWNER TO admin; -- -- Name: createcyclecountsbywarehouse(integer, integer, integer, text, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createcyclecountsbywarehouse(integer, integer, integer, text, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pClasscodeid ALIAS FOR $2; pMaxNumber ALIAS FOR $3; pComments ALIAS FOR $4; pPriority ALIAS FOR $5; pFreeze ALIAS FOR $6; BEGIN RETURN createCycleCountsByWarehouseByClassCode(pWarehousid, pClasscodeid, pMaxNumber, pComments, pPriority, pFreeze, NULL, FALSE); END; $_$; ALTER FUNCTION public.createcyclecountsbywarehouse(integer, integer, integer, text, boolean, boolean) OWNER TO admin; -- -- Name: createcyclecountsbywarehouse(integer, text, integer, text, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createcyclecountsbywarehouse(integer, text, integer, text, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pClasscodePattern ALIAS FOR $2; pMaxNumber ALIAS FOR $3; pComments ALIAS FOR $4; pPriority ALIAS FOR $5; pFreeze ALIAS FOR $6; BEGIN RETURN createCycleCountsByWarehouseByClassCode(pWarehousid, pClasscodePattern, pMaxNumber, pComments, pPriority, pFreeze, NULL, FALSE); END; $_$; ALTER FUNCTION public.createcyclecountsbywarehouse(integer, text, integer, text, boolean, boolean) OWNER TO admin; -- -- Name: createcyclecountsbywarehouse(integer, integer, text, boolean, boolean, integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createcyclecountsbywarehouse(integer, integer, text, boolean, boolean, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pMaxNumber ALIAS FOR $2; pComments ALIAS FOR $3; pPriority ALIAS FOR $4; pFreeze ALIAS FOR $5; pLocationid ALIAS FOR $6; pIgnoreZeroBalance ALIAS FOR $7; _itemsites RECORD; _returnVal INTEGER; BEGIN IF (pLocationid IS NULL) THEN FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, itemsite_qtyonhand FROM itemsite, item WHERE ( (itemsite_active) AND (itemsite_item_id=item_id) AND (itemsite_cyclecountfreq > 0) AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE) AND (itemsite_id NOT IN ( SELECT invcnt_itemsite_id FROM invcnt, itemsite WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_warehous_id=pWarehousid) AND (invcnt_location_id IS NULL) AND (NOT invcnt_posted) ) ) ) AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0)) AND ((pLocationid IS NULL) OR (validLocation(pLocationid, itemsite_id))) AND (itemsite_warehous_id=pWarehousid) ) ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass, item_number LIMIT pMaxNumber LOOP _returnVal := createCountTag(_itemsites.itemsite_id, pComments, pPriority, pFreeze, pLocationid); IF (_returnVal < 0) THEN RETURN _returnVal; END IF; END LOOP; ELSE FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, SUM(itemloc_qty) FROM itemsite, itemloc WHERE ( (itemsite_active) AND (itemsite_cyclecountfreq > 0) AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE) AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0)) AND (pLocationid = itemloc_location_id) AND (itemloc_itemsite_id = itemsite_id) AND (itemsite_warehous_id=pWarehousid) ) GROUP BY itemsite_id, itemsite_warehous_id, itemsite_datelastcount, itemsite_cyclecountfreq, itemsite_abcclass ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass LIMIT pMaxNumber LOOP _returnVal := createCountTag(_itemsites.itemsite_id, pComments, pPriority, pFreeze, pLocationid); IF (_returnVal < 0) THEN RETURN _returnVal; END IF; END LOOP; END IF; RETURN 0; END; $_$; ALTER FUNCTION public.createcyclecountsbywarehouse(integer, integer, text, boolean, boolean, integer, boolean) OWNER TO admin; -- -- Name: createcyclecountsbywarehousebyclasscode(integer, integer, integer, text, boolean, boolean, integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createcyclecountsbywarehousebyclasscode(integer, integer, integer, text, boolean, boolean, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pClasscodeid ALIAS FOR $2; pMaxNumber ALIAS FOR $3; pComments ALIAS FOR $4; pPriority ALIAS FOR $5; pFreeze ALIAS FOR $6; pLocationid ALIAS FOR $7; pIgnoreZeroBalance ALIAS FOR $8; _itemsites RECORD; _returnVal INTEGER; BEGIN IF (pLocationid IS NULL) THEN FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, itemsite_qtyonhand FROM itemsite, item WHERE ( (itemsite_active) AND (itemsite_item_id=item_id) AND (itemsite_cyclecountfreq > 0) AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE) AND (itemsite_id NOT IN ( SELECT invcnt_itemsite_id FROM invcnt, itemsite WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_warehous_id=pWarehousid) AND (invcnt_location_id IS NULL) AND (NOT invcnt_posted) ) ) ) AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0)) AND ((pLocationid IS NULL) OR (validLocation(pLocationid, itemsite_id))) AND (itemsite_warehous_id=pWarehousid) AND (item_classcode_id=pClasscodeid) ) ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass, item_number LIMIT pMaxNumber LOOP _returnVal := createCountTag(_itemsites.itemsite_id, pComments, pPriority, pFreeze, pLocationid); IF (_returnVal < 0) THEN RETURN _returnVal; END IF; END LOOP; ELSE FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, SUM(itemloc_qty) FROM itemsite, item, itemloc WHERE ( (itemsite_active) AND (itemsite_item_id=item_id) AND (itemsite_cyclecountfreq > 0) AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE) AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0)) AND (pLocationid = itemloc_location_id) AND (itemloc_itemsite_id = itemsite_id) AND (itemsite_warehous_id=pWarehousid) AND (item_classcode_id=pClasscodeid) ) GROUP BY itemsite_id, itemsite_warehous_id, itemsite_datelastcount, itemsite_cyclecountfreq, itemsite_abcclass ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass LIMIT pMaxNumber LOOP _returnVal := createCountTag(_itemsites.itemsite_id, pComments, pPriority, pFreeze, pLocationid); IF (_returnVal < 0) THEN RETURN _returnVal; END IF; END LOOP; END IF; RETURN 0; END; $_$; ALTER FUNCTION public.createcyclecountsbywarehousebyclasscode(integer, integer, integer, text, boolean, boolean, integer, boolean) OWNER TO admin; -- -- Name: createcyclecountsbywarehousebyclasscode(integer, text, integer, text, boolean, boolean, integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createcyclecountsbywarehousebyclasscode(integer, text, integer, text, boolean, boolean, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pClasscodePattern ALIAS FOR $2; pMaxNumber ALIAS FOR $3; pComments ALIAS FOR $4; pPriority ALIAS FOR $5; pFreeze ALIAS FOR $6; pLocationid ALIAS FOR $7; pIgnoreZeroBalance ALIAS FOR $8; _itemsites RECORD; _returnVal INTEGER; BEGIN IF (pLocationid IS NULL) THEN FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, itemsite_qtyonhand FROM itemsite, item, classcode WHERE ( (itemsite_active) AND (itemsite_item_id=item_id) AND (item_classcode_id=classcode_id) AND (itemsite_cyclecountfreq > 0) AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE) AND (itemsite_id NOT IN ( SELECT invcnt_itemsite_id FROM invcnt, itemsite WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_warehous_id=pWarehousid) AND (invcnt_location_id IS NULL) AND (NOT invcnt_posted) ) ) ) AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0)) AND ((pLocationid IS NULL) OR (validLocation(pLocationid, itemsite_id))) AND (itemsite_warehous_id=pWarehousid) AND (classcode_code ~ pClasscodePattern) ) ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass, item_number LIMIT pMaxNumber LOOP _returnVal := createCountTag(_itemsites.itemsite_id, pComments, pPriority, pFreeze, pLocationid); IF (_returnVal < 0) THEN RETURN _returnVal; END IF; END LOOP; ELSE FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, SUM(itemloc_qty) FROM itemsite, item, classcode, itemloc WHERE ( (itemsite_active) AND (itemsite_item_id=item_id) AND (item_classcode_id=classcode_id) AND (itemsite_cyclecountfreq > 0) AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE) AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0)) AND (pLocationid = itemloc_location_id) AND (itemloc_itemsite_id = itemsite_id) AND (itemsite_warehous_id=pWarehousid) AND (classcode_code ~ pClasscodePattern) ) GROUP BY itemsite_id, itemsite_warehous_id, itemsite_datelastcount, itemsite_cyclecountfreq, itemsite_abcclass ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass LIMIT pMaxNumber LOOP _returnVal := createCountTag(_itemsites.itemsite_id, pComments, pPriority, pFreeze, pLocationid); IF (_returnVal < 0) THEN RETURN _returnVal; END IF; END LOOP; END IF; RETURN 0; END; $_$; ALTER FUNCTION public.createcyclecountsbywarehousebyclasscode(integer, text, integer, text, boolean, boolean, integer, boolean) OWNER TO admin; -- -- Name: createcyclecountsbywarehousebyplannercode(integer, text, integer, text, boolean, boolean, integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createcyclecountsbywarehousebyplannercode(integer, text, integer, text, boolean, boolean, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pPlancodePattern ALIAS FOR $2; pMaxNumber ALIAS FOR $3; pComments ALIAS FOR $4; pPriority ALIAS FOR $5; pFreeze ALIAS FOR $6; pLocationid ALIAS FOR $7; pIgnoreZeroBalance ALIAS FOR $8; _itemsites RECORD; _returnVal INTEGER; BEGIN IF (pLocationid IS NULL) THEN FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, itemsite_qtyonhand FROM itemsite, item, plancode WHERE ( (itemsite_active) AND (itemsite_item_id=item_id) AND (itemsite_plancode_id=plancode_id) AND (itemsite_cyclecountfreq > 0) AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE) AND (itemsite_id NOT IN ( SELECT invcnt_itemsite_id FROM invcnt, itemsite WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_warehous_id=pWarehousid) AND (invcnt_location_id IS NULL) AND (NOT invcnt_posted) ) ) ) AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0)) AND ((pLocationid IS NULL) OR (validLocation(pLocationid, itemsite_id))) AND (itemsite_warehous_id=pWarehousid) AND (plancode_code ~ pPlancodePattern) ) ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass, item_number LIMIT pMaxNumber LOOP _returnVal := createCountTag(_itemsites.itemsite_id, pComments, pPriority, pFreeze, pLocationid); IF (_returnVal < 0) THEN RETURN _returnVal; END IF; END LOOP; ELSE FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, SUM(itemloc_qty) FROM itemsite, plancode, itemloc WHERE ( (itemsite_active) AND (itemsite_plancode_id=plancode_id) AND (itemsite_cyclecountfreq > 0) AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE) AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0)) AND (pLocationid = itemloc_location_id) AND (itemloc_itemsite_id = itemsite_id) AND (itemsite_warehous_id=pWarehousid) AND (plancode_code ~ pPlancodePattern) ) GROUP BY itemsite_id, itemsite_warehous_id, itemsite_datelastcount, itemsite_cyclecountfreq, itemsite_abcclass ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass LIMIT pMaxNumber LOOP _returnVal := createCountTag(_itemsites.itemsite_id, pComments, pPriority, pFreeze, pLocationid); IF (_returnVal < 0) THEN RETURN _returnVal; END IF; END LOOP; END IF; RETURN 0; END; $_$; ALTER FUNCTION public.createcyclecountsbywarehousebyplannercode(integer, text, integer, text, boolean, boolean, integer, boolean) OWNER TO admin; -- -- Name: createcyclecountsbywarehousebyplannercode(integer, integer, integer, text, boolean, boolean, integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createcyclecountsbywarehousebyplannercode(integer, integer, integer, text, boolean, boolean, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pPlancodeid ALIAS FOR $2; pMaxNumber ALIAS FOR $3; pComments ALIAS FOR $4; pPriority ALIAS FOR $5; pFreeze ALIAS FOR $6; pLocationid ALIAS FOR $7; pIgnoreZeroBalance ALIAS FOR $8; _itemsites RECORD; _returnVal INTEGER; BEGIN IF (pLocationid IS NULL) THEN FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, itemsite_qtyonhand FROM itemsite, item WHERE ( (itemsite_active) AND (itemsite_item_id=item_id) AND (itemsite_cyclecountfreq > 0) AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE) AND (itemsite_id NOT IN ( SELECT invcnt_itemsite_id FROM invcnt, itemsite WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_warehous_id=pWarehousid) AND (invcnt_location_id IS NULL) AND (NOT invcnt_posted) ) ) ) AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0)) AND ((pLocationid IS NULL) OR (validLocation(pLocationid, itemsite_id))) AND (itemsite_warehous_id=pWarehousid) AND (itemsite_plancode_id=pPlancodeid) ) ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass, item_number LIMIT pMaxNumber LOOP _returnVal := createCountTag(_itemsites.itemsite_id, pComments, pPriority, pFreeze, pLocationid); IF (_returnVal < 0) THEN RETURN _returnVal; END IF; END LOOP; ELSE FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, SUM(itemloc_qty) FROM itemsite, itemloc WHERE ( (itemsite_active) AND (itemsite_cyclecountfreq > 0) AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE) AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0)) AND (itemloc_itemsite_id = itemsite_id) AND (itemsite_warehous_id=pWarehousid) AND (pLocationid = itemloc_location_id) AND (itemsite_plancode_id=pPlancodeid) ) GROUP BY itemsite_id, itemsite_warehous_id, itemsite_datelastcount, itemsite_cyclecountfreq, itemsite_abcclass ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass LIMIT pMaxNumber LOOP _returnVal := createCountTag(_itemsites.itemsite_id, pComments, pPriority, pFreeze, pLocationid); IF (_returnVal < 0) THEN RETURN _returnVal; END IF; END LOOP; END IF; RETURN 0; END; $_$; ALTER FUNCTION public.createcyclecountsbywarehousebyplannercode(integer, integer, integer, text, boolean, boolean, integer, boolean) OWNER TO admin; -- -- Name: createdoctype(integer, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createdoctype(pdocassnum integer, ptype text, pdocass text, pcharass text, pfull text, ptable text, pkey text, pnumber text, pname text, pdesc text, pwidget text DEFAULT ''::text, pjoin text DEFAULT ''::text, pparam text DEFAULT ''::text, pui text DEFAULT ''::text, ppriv text DEFAULT ''::text, pmodule text DEFAULT 'System'::text) RETURNS integer LANGUAGE plpgsql AS $$ /* Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. Create a record in the "source" table corresponding to this document type or update existing records. The pDocAssNum MUST match the corresponding Documents::DocumentSources (qt-client/widgets/documents.h) if the record type is there. Otherwise pass NULL or 0 and let the `source` table trigger set a value. See the source table comments for a description of the other arguments. */ declare _id integer := -1; begin select source_id into _id from source where source_name = pType for update; if not found then insert into source (source_docass_num, source_module, source_name, source_descrip, source_table, source_docass, source_charass, source_key_field, source_number_field, source_name_field, source_desc_field, source_joins, source_widget, source_key_param, source_uiform_name, source_create_priv ) values (coalesce(pDocAssNum, 0), pModule, pType, pFull, pTable, pDocAss, pCharAss, pKey, pNumber, pName, pDesc, pJoin, pWidget, pParam, pUi, pPriv) returning source_id into _id; else update source set source_docass_num = coalesce(pDocAssNum, 0), source_module = pModule, source_docass = pDocAss, source_charass = pCharass, source_descrip = pFull, source_table = pTable, source_key_field = pKey, source_number_field = pNumber, source_name_field = pName, source_desc_field = pDesc, source_joins = pJoin, source_widget = pWidget, source_key_param = pParam, source_uiform_name = pUi, source_create_priv = pPriv where source_name = pType returning source_id into _id; end if; return _id; end; $$; ALTER FUNCTION public.createdoctype(pdocassnum integer, ptype text, pdocass text, pcharass text, pfull text, ptable text, pkey text, pnumber text, pname text, pdesc text, pwidget text, pjoin text, pparam text, pui text, ppriv text, pmodule text) OWNER TO admin; -- -- Name: createfile(text, text, bytea); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createfile(text, text, bytea) RETURNS integer LANGUAGE plpgsql AS $_$ declare pTitle ALIAS FOR $1; pDescription ALIAS FOR $2; pStream ALIAS FOR $3; _id integer; begin _id := nextval('file_file_id_seq'); insert into file (file_id, file_title, file_descrip, file_stream) values (_id, pTitle, pDescription, pStream); return _id; end; $_$; ALTER FUNCTION public.createfile(text, text, bytea) OWNER TO admin; -- -- Name: createinvoice(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createinvoice(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCobmiscid ALIAS FOR $1; _invcheadid INTEGER; _invcitemid INTEGER; _qtyToInvoice NUMERIC; _r RECORD; _s RECORD; _lastlinenumber INTEGER := 1; BEGIN IF ( ( SELECT cobmisc_posted FROM cobmisc WHERE (cobmisc_id=pCobmiscid) ) ) THEN RETURN -1; END IF; SELECT NEXTVAL('invchead_invchead_id_seq') INTO _invcheadid; -- Give this selection a number if it has not been assigned one UPDATE cobmisc SET cobmisc_invcnumber=fetchInvcNumber() WHERE ( (cobmisc_invcnumber IS NULL) AND (cobmisc_id=pCobmiscid) ); -- Create the Invoice header INSERT INTO invchead ( invchead_id,invchead_cust_id,invchead_shipto_id,invchead_ordernumber,invchead_orderdate, invchead_posted,invchead_printed,invchead_invcnumber,invchead_invcdate,invchead_shipdate, invchead_ponumber,invchead_shipvia,invchead_fob,invchead_billto_name,invchead_billto_address1, invchead_billto_address2,invchead_billto_address3,invchead_billto_city,invchead_billto_state,invchead_billto_zipcode, invchead_billto_phone,invchead_billto_country,invchead_shipto_name,invchead_shipto_address1,invchead_shipto_address2, invchead_shipto_address3,invchead_shipto_city,invchead_shipto_state,invchead_shipto_zipcode,invchead_shipto_phone, invchead_shipto_country,invchead_salesrep_id,invchead_commission,invchead_terms_id,invchead_freight, invchead_misc_amount,invchead_misc_descrip,invchead_misc_accnt_id,invchead_payment, invchead_paymentref,invchead_notes,invchead_prj_id,invchead_curr_id, invchead_taxzone_id, invchead_shipchrg_id, invchead_saletype_id, invchead_shipzone_id ) SELECT _invcheadid,cohead_cust_id,cohead_shipto_id,cohead_number,cohead_orderdate, FALSE,FALSE,cobmisc_invcnumber,cobmisc_invcdate,cobmisc_shipdate, cohead_custponumber,cobmisc_shipvia,cohead_fob,cohead_billtoname,cohead_billtoaddress1, cohead_billtoaddress2,cohead_billtoaddress3,cohead_billtocity,cohead_billtostate,cohead_billtozipcode, cntct_phone AS cust_phone,cohead_billtocountry,cohead_shiptoname,cohead_shiptoaddress1,cohead_shiptoaddress2, cohead_shiptoaddress3,cohead_shiptocity,cohead_shiptostate,cohead_shiptozipcode,cohead_shipto_cntct_phone, cohead_shiptocountry,cohead_salesrep_id,COALESCE(cohead_commission,0),cohead_terms_id,cobmisc_freight, COALESCE(cobmisc_misc, 0.00),cobmisc_misc_descrip,cobmisc_misc_accnt_id,cobmisc_payment, cobmisc_paymentref,cobmisc_notes,cohead_prj_id,cobmisc_curr_id, cobmisc_taxzone_id, cohead_shipchrg_id, cohead_saletype_id, cohead_shipzone_id FROM cobmisc, cohead, custinfo LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) WHERE ( (cobmisc_cohead_id=cohead_id) AND (cohead_cust_id=cust_id) AND (cobmisc_id=pCobmiscid) ); INSERT INTO invcheadtax(taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate) SELECT _invcheadid,taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate FROM cobmisctax WHERE taxhist_parent_id = pCobmiscid AND taxhist_taxtype_id = getadjustmenttaxtypeid(); -- Create the Invoice Characteristic Assignments INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price) SELECT 'INV', _invcheadid, charass_char_id, charass_value, charass_default, charass_price FROM cobmisc JOIN cohead ON (cohead_id=cobmisc_cohead_id) JOIN charass ON charass_target_type = 'SO' AND charass_target_id = cohead_id JOIN char ON char_id = charass_char_id JOIN charuse ON char_id = charuse_char_id AND charuse_target_type = 'INV' WHERE cobmisc_id = pCobmiscid; -- Create the Invoice items FOR _r IN SELECT coitem_id, coitem_linenumber, coitem_subnumber, coitem_custpn, coitem_qtyord, cobill_qty, coitem_qty_uom_id, coitem_qty_invuomratio, coitem_custprice, coitem_price, coitem_price_uom_id, coitem_price_invuomratio, coitem_memo, coitem_rev_accnt_id, itemsite_item_id, itemsite_warehous_id, cobill_taxtype_id, formatSoItemNumber(coitem_id) AS ordnumber FROM coitem, cobill, itemsite WHERE ( (cobill_coitem_id=coitem_id) AND (coitem_itemsite_id=itemsite_id) AND (cobill_cobmisc_id=pCobmiscid) ) ORDER BY coitem_linenumber, coitem_subnumber LOOP SELECT NEXTVAL('invcitem_invcitem_id_seq') INTO _invcitemid; INSERT INTO invcitem ( invcitem_id, invcitem_invchead_id, invcitem_linenumber, invcitem_item_id, invcitem_warehous_id, invcitem_custpn, invcitem_number, invcitem_descrip, invcitem_ordered, invcitem_billed, invcitem_qty_uom_id, invcitem_qty_invuomratio, invcitem_custprice, invcitem_price, invcitem_price_uom_id, invcitem_price_invuomratio, invcitem_notes, invcitem_taxtype_id, invcitem_coitem_id, invcitem_rev_accnt_id ) VALUES ( _invcitemid, _invcheadid, _lastlinenumber, _r.itemsite_item_id, _r.itemsite_warehous_id, _r.coitem_custpn, '', '', _r.coitem_qtyord, _r.cobill_qty, _r.coitem_qty_uom_id, _r.coitem_qty_invuomratio, _r.coitem_custprice, _r.coitem_price, _r.coitem_price_uom_id, _r.coitem_price_invuomratio, _r.coitem_memo, _r.cobill_taxtype_id, _r.coitem_id, _r.coitem_rev_accnt_id ); -- Find and mark any Lot/Serial invdetail records associated with this bill UPDATE invdetail SET invdetail_invcitem_id = _invcitemid WHERE (invdetail_id IN (SELECT invdetail_id FROM invhist JOIN invdetail ON (invdetail_invhist_id=invhist_id) WHERE ( (invhist_ordnumber = _r.ordnumber) AND (invhist_ordtype = 'SO') AND (invhist_transtype = 'SH') AND (invdetail_invcitem_id IS NULL) ) )); -- Mark any shipped, uninvoiced shipitems for the current coitem as invoiced _qtyToInvoice := _r.cobill_qty; FOR _s IN SELECT shipitem.*, shipitem_qty = _r.cobill_qty AS matched FROM shipitem, shiphead WHERE ((shipitem_shiphead_id=shiphead_id) AND (shipitem_orderitem_id=_r.coitem_id) AND (shiphead_shipped) AND (shiphead_order_type='SO') AND (NOT shipitem_invoiced)) ORDER BY matched DESC, shipitem_qty DESC FOR UPDATE LOOP IF (_qtyToInvoice >= _s.shipitem_qty) THEN UPDATE shipitem SET shipitem_invoiced=TRUE, shipitem_invcitem_id=_invcitemid WHERE (shipitem_id=_s.shipitem_id); _qtyToInvoice := _qtyToInvoice - _s.shipitem_qty; END IF; IF (_qtyToInvoice <= 0) THEN EXIT; END IF; END LOOP; UPDATE cobill SET cobill_invcnum=cobmisc_invcnumber, cobill_invcitem_id=invcitem_id FROM invcitem, coitem, cobmisc WHERE ((invcitem_linenumber=_lastlinenumber) AND (coitem_id=cobill_coitem_id) AND (cobmisc_id=cobill_cobmisc_id) AND (cobill_cobmisc_id=pCobmiscid) AND (invcitem_invchead_id=_invcheadid)); _lastlinenumber := _lastlinenumber + 1; END LOOP; -- Close all requested coitem's IF ( ( SELECT cobmisc_closeorder FROM cobmisc WHERE (cobmisc_id=pCobmiscid) ) ) THEN UPDATE coitem SET coitem_status='C' FROM cobmisc WHERE ( (coitem_status NOT IN ('C', 'X')) AND (coitem_cohead_id=cobmisc_cohead_id) AND (cobmisc_id=pCobmiscid) ); ELSE UPDATE coitem SET coitem_status='C' FROM cobill WHERE ( (cobill_coitem_id=coitem_id) AND (coitem_status <> 'X') AND (cobill_toclose) AND (cobill_cobmisc_id=pCobmiscid) ); END IF; -- Mark the cobmisc as posted UPDATE cobmisc SET cobmisc_posted=TRUE, cobmisc_invchead_id=_invcheadid WHERE (cobmisc_id=pCobmiscid); -- All done RETURN _invcheadid; END; $_$; ALTER FUNCTION public.createinvoice(integer) OWNER TO admin; -- -- Name: createinvoiceconsolidated(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createinvoiceconsolidated(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; _invcheadid INTEGER; _invcitemid INTEGER; _qtyToInvoice NUMERIC; _r RECORD; _s RECORD; _c RECORD; _i RECORD; _count INTEGER; _invcnumber INTEGER; _lastlinenumber INTEGER; BEGIN _count := 0; FOR _c IN SELECT min(cobmisc_id) AS cobmisc_id, count(*) AS cnt, -- there are the key values for consolidation cohead_billtoname, cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, cohead_billtocity, cohead_billtostate, cohead_billtozipcode, cntct_phone AS cust_phone, cohead_billtocountry, cohead_salesrep_id, cohead_commission, cohead_terms_id, cobmisc_misc_accnt_id, cohead_prj_id, cobmisc_curr_id, cobmisc_taxzone_id, cohead_shipchrg_id, cohead_saletype_id, cohead_shipzone_id, -- the following are consolidated values to use in creating the header MIN(cohead_number) AS cohead_number, MIN(cohead_orderdate) AS cohead_orderdate, MIN(cobmisc_invcdate) AS cobmisc_invcdate, MIN(cobmisc_shipdate) AS cobmisc_shipdate, SUM(cobmisc_freight) AS cobmisc_freight, SUM(cobmisc_misc) AS cobmisc_misc, SUM(cobmisc_payment) AS cobmisc_payment FROM cobmisc JOIN cohead ON (cobmisc_cohead_id=cohead_id) JOIN custinfo ON (cohead_cust_id=cust_id) LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) WHERE(NOT cobmisc_posted AND (cohead_cust_id=pCustid) ) GROUP BY cohead_billtoname, cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, cohead_billtocity, cohead_billtostate, cohead_billtozipcode, cust_phone, cohead_billtocountry, cohead_salesrep_id, cohead_commission, cohead_terms_id, cobmisc_misc_accnt_id, cohead_prj_id, cobmisc_curr_id, cobmisc_taxzone_id, cohead_shipchrg_id, cohead_saletype_id, cohead_shipzone_id LOOP IF(_c.cnt = 1) THEN PERFORM createInvoice(_c.cobmisc_id); _count := (_count + 1); ELSE SELECT NEXTVAL('invchead_invchead_id_seq'), fetchInvcNumber() INTO _invcheadid, _invcnumber; -- Create the Invoice header INSERT INTO invchead ( invchead_id, invchead_cust_id, invchead_shipto_id, invchead_ordernumber, invchead_orderdate, invchead_posted, invchead_printed, invchead_invcnumber, invchead_invcdate, invchead_shipdate, invchead_ponumber, invchead_shipvia, invchead_fob, invchead_billto_name, invchead_billto_address1, invchead_billto_address2, invchead_billto_address3, invchead_billto_city, invchead_billto_state, invchead_billto_zipcode, invchead_billto_phone, invchead_billto_country, invchead_shipto_name, invchead_shipto_address1, invchead_shipto_address2, invchead_shipto_address3, invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode, invchead_shipto_phone, invchead_shipto_country, invchead_salesrep_id, invchead_commission, invchead_terms_id, invchead_freight, invchead_misc_amount, invchead_misc_descrip, invchead_misc_accnt_id, invchead_payment, invchead_paymentref, invchead_notes, invchead_prj_id, invchead_curr_id, invchead_taxzone_id, invchead_shipchrg_id, invchead_saletype_id, invchead_shipzone_id ) VALUES(_invcheadid, pCustid, -1, NULL, _c.cohead_orderdate, FALSE, FALSE, _invcnumber, _c.cobmisc_invcdate, _c.cobmisc_shipdate, 'MULTIPLE', '', '', _c.cohead_billtoname, _c.cohead_billtoaddress1, _c.cohead_billtoaddress2, _c.cohead_billtoaddress3, _c.cohead_billtocity, _c.cohead_billtostate, _c.cohead_billtozipcode, _c.cust_phone, _c.cohead_billtocountry, '', '', '', '', '', '', '', '', '', _c.cohead_salesrep_id, COALESCE(_c.cohead_commission, 0), _c.cohead_terms_id, _c.cobmisc_freight, _c.cobmisc_misc, CASE WHEN(_c.cobmisc_misc <> 0) THEN 'Multiple' ELSE '' END, _c.cobmisc_misc_accnt_id, _c.cobmisc_payment, '', 'Multiple Sales Order # Invoice', _c.cohead_prj_id, _c.cobmisc_curr_id, _c.cobmisc_taxzone_id, _c.cohead_shipchrg_id, _c.cohead_saletype_id, _c.cohead_shipzone_id ); _lastlinenumber := 1; FOR _i IN SELECT cobmisc_id FROM cobmisc JOIN cohead ON (cobmisc_cohead_id=cohead_id) JOIN custinfo ON (cohead_cust_id=cust_id) LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) WHERE(NOT cobmisc_posted AND (cohead_cust_id=pCustid) AND (COALESCE(cohead_billtoname,'') = COALESCE(_c.cohead_billtoname,'')) AND (COALESCE(cohead_billtoaddress1,'') = COALESCE(_c.cohead_billtoaddress1,'')) AND (COALESCE(cohead_billtoaddress2,'') = COALESCE(_c.cohead_billtoaddress2,'')) AND (COALESCE(cohead_billtoaddress3,'') = COALESCE(_c.cohead_billtoaddress3,'')) AND (COALESCE(cohead_billtocity,'') = COALESCE(_c.cohead_billtocity,'')) AND (COALESCE(cohead_billtostate,'') = COALESCE(_c.cohead_billtostate,'')) AND (COALESCE(cohead_billtozipcode,'') = COALESCE(_c.cohead_billtozipcode,'')) AND (COALESCE(cntct_phone,'') = COALESCE(_c.cust_phone,'')) AND (COALESCE(cohead_billtocountry,'') = COALESCE(_c.cohead_billtocountry,'')) AND (COALESCE(cohead_salesrep_id, 0) = COALESCE(_c.cohead_salesrep_id, 0)) AND (COALESCE(cohead_commission, 0) = COALESCE(_c.cohead_commission, 0)) AND (COALESCE(cohead_terms_id, 0) = COALESCE(_c.cohead_terms_id, 0)) AND (COALESCE(cobmisc_misc_accnt_id, 0) = COALESCE(_c.cobmisc_misc_accnt_id, 0)) AND (COALESCE(cohead_prj_id, 0) = COALESCE(_c.cohead_prj_id, 0)) AND (COALESCE(cobmisc_curr_id, 0) = COALESCE(_c.cobmisc_curr_id, 0)) AND (COALESCE(cobmisc_taxzone_id, 0) = COALESCE(_c.cobmisc_taxzone_id, 0)) AND (COALESCE(cohead_saletype_id, 0) = COALESCE(_c.cohead_saletype_id, 0)) AND (COALESCE(cohead_shipzone_id, 0) = COALESCE(_c.cohead_shipzone_id, 0)) ) LOOP -- Create the Invoice Head tax INSERT INTO invcheadtax(taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate) SELECT _invcheadid,taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate FROM cobmisctax WHERE taxhist_parent_id = _i.cobmisc_id AND taxhist_taxtype_id = getadjustmenttaxtypeid(); -- Give this selection a number if it has not been assigned one UPDATE cobmisc SET cobmisc_invcnumber=_invcnumber WHERE(cobmisc_id=_i.cobmisc_id); -- Create the Invoice items FOR _r IN SELECT coitem_id, coitem_linenumber, coitem_subnumber, coitem_custpn, coitem_qtyord, cobill_qty, coitem_qty_uom_id, coitem_qty_invuomratio, coitem_custprice, coitem_price, coitem_price_uom_id, coitem_price_invuomratio, coitem_memo, itemsite_item_id, itemsite_warehous_id, cobill_taxtype_id FROM cohead, coitem, cobill, itemsite WHERE((cobill_coitem_id=coitem_id) AND (cohead_id=coitem_cohead_id) AND (coitem_itemsite_id=itemsite_id) AND (cobill_cobmisc_id=_i.cobmisc_id) ) ORDER BY cohead_number, coitem_linenumber, coitem_subnumber LOOP SELECT NEXTVAL('invcitem_invcitem_id_seq') INTO _invcitemid; INSERT INTO invcitem ( invcitem_id, invcitem_invchead_id, invcitem_linenumber, invcitem_item_id, invcitem_warehous_id, invcitem_custpn, invcitem_number, invcitem_descrip, invcitem_ordered, invcitem_billed, invcitem_qty_uom_id, invcitem_qty_invuomratio, invcitem_custprice, invcitem_price, invcitem_price_uom_id, invcitem_price_invuomratio, invcitem_notes, invcitem_taxtype_id, invcitem_coitem_id ) VALUES ( _invcitemid, _invcheadid, _lastlinenumber, _r.itemsite_item_id, _r.itemsite_warehous_id, _r.coitem_custpn, '', '', _r.coitem_qtyord, _r.cobill_qty, _r.coitem_qty_uom_id, _r.coitem_qty_invuomratio, _r.coitem_custprice, _r.coitem_price, _r.coitem_price_uom_id, _r.coitem_price_invuomratio, _r.coitem_memo, _r.cobill_taxtype_id, _r.coitem_id ); -- Find and mark any Lot/Serial invdetail records associated with this bill UPDATE invdetail SET invdetail_invcitem_id = _invcitemid WHERE (invdetail_id IN (SELECT invdetail_id FROM coitem, cohead, invhist, invdetail WHERE ((coitem_cohead_id=cohead_id) AND (invdetail_invhist_id=invhist_id) AND (invhist_ordnumber = text(cohead_number||'-'||formatSoLineNumber(coitem_id))) AND (invdetail_invcitem_id IS NULL) AND (coitem_id=_r.coitem_id)) ) ); -- Mark any shipped, uninvoiced shipitems for the current coitem as invoiced _qtyToInvoice := _r.cobill_qty; FOR _s IN SELECT shipitem.*, shipitem_qty = _r.cobill_qty AS matched FROM shipitem, shiphead WHERE ((shipitem_shiphead_id=shiphead_id) AND (shipitem_orderitem_id=_r.coitem_id) AND (shiphead_shipped) AND (shiphead_order_type='SO') AND (NOT shipitem_invoiced)) ORDER BY matched DESC, shipitem_qty DESC FOR UPDATE LOOP IF (_qtyToInvoice >= _s.shipitem_qty) THEN UPDATE shipitem SET shipitem_invoiced=TRUE, shipitem_invcitem_id=_invcitemid WHERE (shipitem_id=_s.shipitem_id); _qtyToInvoice := _qtyToInvoice - _s.shipitem_qty; END IF; IF (_qtyToInvoice <= 0) THEN EXIT; END IF; END LOOP; UPDATE cobill SET cobill_invcnum=cobmisc_invcnumber, cobill_invcitem_id=invcitem_id FROM invcitem, coitem, cobmisc WHERE ((invcitem_linenumber=_lastlinenumber ) AND (coitem_id=cobill_coitem_id) AND (cobmisc_id=cobill_cobmisc_id) AND (cobill_cobmisc_id=_i.cobmisc_id) AND (invcitem_invchead_id=_invcheadid)); _lastlinenumber := _lastlinenumber + 1; END LOOP; -- Close all requested coitem's IF ( ( SELECT cobmisc_closeorder FROM cobmisc WHERE (cobmisc_id=_i.cobmisc_id) ) ) THEN UPDATE coitem SET coitem_status='C' FROM cobmisc WHERE ( (coitem_status NOT IN ('C', 'X')) AND (coitem_cohead_id=cobmisc_cohead_id) AND (cobmisc_id=_i.cobmisc_id) ); ELSE UPDATE coitem SET coitem_status='C' FROM cobill WHERE ( (cobill_coitem_id=coitem_id) AND (coitem_status <> 'X') AND (cobill_toclose) AND (cobill_cobmisc_id=_i.cobmisc_id) ); END IF; -- Mark the cobmisc as posted UPDATE cobmisc SET cobmisc_posted=TRUE, cobmisc_invchead_id=_invcheadid WHERE (cobmisc_id=_i.cobmisc_id); -- All done _count := (_count + 1); END LOOP; END IF; END LOOP; RETURN _count; END; $_$; ALTER FUNCTION public.createinvoiceconsolidated(integer) OWNER TO admin; -- -- Name: createinvoices(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createinvoices() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _counter INTEGER; _cobmisc RECORD; BEGIN _counter := 0; FOR _cobmisc IN SELECT cobmisc_id FROM cobmisc WHERE (NOT cobmisc_posted) LOOP PERFORM createinvoice(_cobmisc.cobmisc_id); _counter := (_counter + 1); END LOOP; RETURN _counter; END; $$; ALTER FUNCTION public.createinvoices() OWNER TO admin; -- -- Name: createinvoices(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createinvoices(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN createinvoices($1, false); END; $_$; ALTER FUNCTION public.createinvoices(integer) OWNER TO admin; -- -- Name: createinvoices(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createinvoices(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustTypeId ALIAS FOR $1; pConsolidate ALIAS FOR $2; _counter INTEGER; _tcounter INTEGER; _cobmisc RECORD; BEGIN _counter := 0; IF (pConsolidate) THEN FOR _cobmisc IN SELECT DISTINCT cust_id FROM cobmisc, cohead, custinfo WHERE((NOT cobmisc_posted) AND (cohead_id=cobmisc_cohead_id) AND (cust_id=cohead_cust_id) AND (cust_custtype_id=pCustTypeId)) LOOP SELECT createinvoiceConsolidated(_cobmisc.cust_id) INTO _tcounter; _counter := (_counter + _tcounter); END LOOP; ELSE FOR _cobmisc IN SELECT cobmisc_id FROM cobmisc, cohead, custinfo WHERE((NOT cobmisc_posted) AND (cohead_id=cobmisc_cohead_id) AND (cust_id=cohead_cust_id) AND (cust_custtype_id=pCustTypeId)) LOOP PERFORM createinvoice(_cobmisc.cobmisc_id); _counter := (_counter + 1); END LOOP; END IF; RETURN _counter; END; $_$; ALTER FUNCTION public.createinvoices(integer, boolean) OWNER TO admin; -- -- Name: createmiscapcheck(integer, integer, date, numeric, integer, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createmiscapcheck(integer, integer, date, numeric, integer, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'createMiscAPCheck() is deprecated - use createCheck() instead'; RETURN createCheck($1, 'V', $2, $3, $4, baseCurrId(), $5, NULL, $6, $7, FALSE); END; $_$; ALTER FUNCTION public.createmiscapcheck(integer, integer, date, numeric, integer, text, text) OWNER TO admin; -- -- Name: createmiscapcheck(integer, integer, date, numeric, integer, integer, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createmiscapcheck(integer, integer, date, numeric, integer, integer, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'createMiscAPCheck() is deprecated - use createCheck() instead'; RETURN createCheck($1, 'V', $2, $3, pAmount, $5, $6, NULL, $7, $8, FALSE); END; $_$; ALTER FUNCTION public.createmiscapcheck(integer, integer, date, numeric, integer, integer, text, text) OWNER TO admin; -- -- Name: createpkgschema(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createpkgschema(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pname ALIAS FOR $1; pcomment ALIAS FOR $2; _namespaceoid INTEGER := -1; _tabs TEXT[] := ARRAY['cmd', 'cmdarg', 'image', 'metasql', 'priv', 'report', 'script', 'uiform'] ; _pkgtab TEXT; BEGIN IF (LENGTH(COALESCE(pname, '')) <= 0) THEN RAISE EXCEPTION 'Cannot create a schema for this package without a name.'; END IF; SELECT oid INTO _namespaceoid FROM pg_namespace WHERE (LOWER(nspname)=LOWER(pname)); IF (NOT FOUND) THEN EXECUTE format('CREATE SCHEMA %s;', LOWER(pname)); EXECUTE format('GRANT ALL ON SCHEMA %s TO GROUP xtrole;', LOWER(pname)); SELECT oid INTO _namespaceoid FROM pg_namespace WHERE (LOWER(nspname)=LOWER(pname)); END IF; FOR i IN ARRAY_LOWER(_tabs,1)..ARRAY_UPPER(_tabs,1) LOOP _pkgtab := 'pkg' || _tabs[i]; IF NOT EXISTS(SELECT oid FROM pg_class WHERE ((relname=_pkgtab) AND (relnamespace=_namespaceoid))) THEN EXECUTE format('CREATE TABLE %s.%s () INHERITS (%s);', pname, _pkgtab, _tabs[i]); EXECUTE format($f$ALTER TABLE %s.%s ALTER %s_id SET NOT NULL, ADD PRIMARY KEY (%s_id), ALTER %s_id SET DEFAULT NEXTVAL('%s_%s_id_seq');$f$, pname, _pkgtab, _tabs[i], _tabs[i], _tabs[i], _tabs[i], _tabs[i]); EXECUTE format('REVOKE ALL ON %s.%s FROM PUBLIC;', pname, _pkgtab); EXECUTE format('GRANT ALL ON %s.%s TO GROUP xtrole;', pname, _pkgtab); IF (_tabs[i] = 'cmdarg') THEN EXECUTE format($f$ALTER TABLE %s.%s ADD FOREIGN KEY (cmdarg_cmd_id) REFERENCES %s.pkgcmd(cmd_id);$f$, pname, _pkgtab, pname); END IF; EXECUTE format('DROP TRIGGER IF EXISTS %sbeforetrigger ON %s.%s;', _pkgtab, pname, _pkgtab); EXECUTE format('CREATE TRIGGER %sbeforetrigger' || ' BEFORE INSERT OR UPDATE OR DELETE ON %s.%s' || ' FOR EACH ROW EXECUTE PROCEDURE _%sbeforetrigger();', _pkgtab, pname, _pkgtab, _pkgtab); EXECUTE format('DROP TRIGGER IF EXISTS %saltertrigger ON %s.%s;', _pkgtab, pname, _pkgtab); EXECUTE format('CREATE TRIGGER %saltertrigger' || ' BEFORE INSERT OR UPDATE OR DELETE ON %s.%s' || ' FOR EACH ROW EXECUTE PROCEDURE _%saltertrigger();', _pkgtab, pname, _pkgtab, _pkgtab); EXECUTE format('DROP TRIGGER IF EXISTS %saftertrigger ON %s.%s;', _pkgtab, pname, _pkgtab); EXECUTE format('CREATE TRIGGER %saftertrigger' || ' AFTER INSERT OR UPDATE OR DELETE ON %s.%s' || ' FOR EACH ROW EXECUTE PROCEDURE _%saftertrigger();', _pkgtab, pname, _pkgtab, _pkgtab); END IF; END LOOP; EXECUTE 'COMMENT ON SCHEMA ' || quote_ident(pname) || ' IS ' || quote_literal(pcomment) || ';'; RETURN _namespaceoid; END; $_$; ALTER FUNCTION public.createpkgschema(text, text) OWNER TO admin; -- -- Name: createpr(character, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createpr(character, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pParentType ALIAS FOR $1; pParentId ALIAS FOR $2; _orderNumber INTEGER; _prid INTEGER; BEGIN IF (pParentType = 'W') THEN SELECT wo_number INTO _orderNumber FROM wo, womatl WHERE ((womatl_wo_id=wo_id) AND (womatl_id=pParentId)); ELSIF (pParentType = 'S') THEN SELECT CAST(cohead_number AS INTEGER) INTO _orderNumber FROM cohead, coitem WHERE ((coitem_cohead_id=cohead_id) AND (coitem_id=pParentId)); ELSIF (pParentType = 'F') THEN SELECT fetchPrNumber() INTO _orderNumber; ELSE RETURN -2; END IF; IF (NOT FOUND) THEN RETURN -1; END IF; SELECT createPr(_orderNumber, pParentType, pParentId) INTO _prid; RETURN _prid; END; $_$; ALTER FUNCTION public.createpr(character, integer) OWNER TO admin; -- -- Name: createpr(integer, character, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createpr(integer, character, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOrderNumber ALIAS FOR $1; pParentType ALIAS FOR $2; pParentId ALIAS FOR $3; _parent RECORD; _prid INTEGER; _orderNumber INTEGER; BEGIN IF (pOrderNumber = -1) THEN SELECT fetchPrNumber() INTO _orderNumber; ELSE _orderNumber := pOrderNumber; END IF; IF (pParentType = 'W') THEN SELECT womatl_itemsite_id AS itemsiteid, itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq) AS qty, womatl_duedate AS duedate, wo_prj_id AS prjid, womatl_notes AS notes INTO _parent FROM wo, womatl, itemsite WHERE ((womatl_wo_id=wo_id) AND (womatl_itemsite_id=itemsite_id) AND (womatl_id=pParentId)); ELSIF (pParentType = 'S') THEN SELECT coitem_itemsite_id AS itemsiteid, (coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS qty, coitem_scheddate AS duedate, cohead_prj_id AS prjid, coitem_memo AS notes INTO _parent FROM coitem, cohead WHERE ((cohead_id=coitem_cohead_id) AND (coitem_id=pParentId)); ELSIF (pParentType = 'F') THEN SELECT planord_itemsite_id AS itemsiteid, planord_qty AS qty, planord_duedate AS duedate, NULL::INTEGER AS prjid, planord_comments AS notes INTO _parent FROM planord WHERE (planord_id=pParentId); ELSE RETURN -2; END IF; IF (NOT FOUND) THEN RETURN -1; END IF; SELECT NEXTVAL('pr_pr_id_seq') INTO _prid; INSERT INTO pr ( pr_id, pr_number, pr_subnumber, pr_status, pr_order_type, pr_order_id, pr_prj_id, pr_itemsite_id, pr_qtyreq, pr_duedate, pr_releasenote ) VALUES ( _prid, _orderNumber, nextPrSubnumber(_orderNumber), 'O', pParentType, pParentId, _parent.prjid, _parent.itemsiteid, validateOrderQty(_parent.itemsiteid, _parent.qty, TRUE), _parent.duedate, _parent.notes ); RETURN _prid; END; $_$; ALTER FUNCTION public.createpr(integer, character, integer) OWNER TO admin; -- -- Name: createpr(integer, character, integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createpr(integer, character, integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOrderNumber ALIAS FOR $1; pParentType ALIAS FOR $2; pParentId ALIAS FOR $3; pParentNotes ALIAS FOR $4; _parent RECORD; _prid INTEGER; _orderNumber INTEGER; BEGIN IF (pOrderNumber = -1) THEN SELECT fetchPrNumber() INTO _orderNumber; ELSE _orderNumber := pOrderNumber; END IF; IF (pParentType = 'W') THEN SELECT womatl_itemsite_id AS itemsiteid, itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq) AS qty, womatl_duedate AS duedate, wo_prj_id AS prjid INTO _parent FROM wo, womatl, itemsite WHERE ((womatl_wo_id=wo_id) AND (womatl_itemsite_id=itemsite_id) AND (womatl_id=pParentId)); ELSIF (pParentType = 'S') THEN SELECT coitem_itemsite_id AS itemsiteid, (coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS qty, coitem_scheddate AS duedate, cohead_prj_id AS prjid INTO _parent FROM coitem, cohead WHERE ((cohead_id=coitem_cohead_id) AND (coitem_id=pParentId)); ELSIF (pParentType = 'F') THEN SELECT planord_itemsite_id AS itemsiteid, planord_qty AS qty, planord_duedate AS duedate, NULL::INTEGER AS prjid INTO _parent FROM planord WHERE (planord_id=pParentId); ELSE RETURN -2; END IF; IF (NOT FOUND) THEN RETURN -1; END IF; SELECT NEXTVAL('pr_pr_id_seq') INTO _prid; INSERT INTO pr ( pr_id, pr_number, pr_subnumber, pr_status, pr_order_type, pr_order_id, pr_prj_id, pr_itemsite_id, pr_qtyreq, pr_duedate, pr_releasenote ) VALUES ( _prid, _orderNumber, nextPrSubnumber(_orderNumber), 'O', pParentType, pParentId, _parent.prjid, _parent.itemsiteid, validateOrderQty(_parent.itemsiteid, _parent.qty, TRUE), _parent.duedate, pParentNotes ); RETURN _prid; END; $_$; ALTER FUNCTION public.createpr(integer, character, integer, text) OWNER TO admin; -- -- Name: createpr(integer, integer, numeric, date, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createpr(integer, integer, numeric, date, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOrderNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pQty ALIAS FOR $3; pDueDate ALIAS FOR $4; pNotes ALIAS FOR $5; _prid INTEGER; BEGIN SELECT NEXTVAL('pr_pr_id_seq') INTO _prid; INSERT INTO pr ( pr_id, pr_number, pr_subnumber, pr_status, pr_order_type, pr_order_id, pr_itemsite_id, pr_qtyreq, pr_duedate, pr_releasenote ) VALUES ( _prid, pOrderNumber, nextPrSubnumber(pOrderNumber), 'O', 'M', -1, pItemsiteid, pQty, pDuedate, pNotes); RETURN _prid; END; $_$; ALTER FUNCTION public.createpr(integer, integer, numeric, date, text) OWNER TO admin; -- -- Name: createpr(integer, integer, numeric, date, text, character, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createpr(integer, integer, numeric, date, text, character, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOrderNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pQty ALIAS FOR $3; pDueDate ALIAS FOR $4; pNotes ALIAS FOR $5; pOrderType ALIAS FOR $6; pOrderId ALIAS FOR $7; _prid INTEGER; BEGIN SELECT NEXTVAL('pr_pr_id_seq') INTO _prid; INSERT INTO pr ( pr_id, pr_number, pr_subnumber, pr_status, pr_order_type, pr_order_id, pr_itemsite_id, pr_qtyreq, pr_duedate, pr_releasenote ) VALUES ( _prid, pOrderNumber, nextPrSubnumber(pOrderNumber), 'O', pOrderType, pOrderId, pItemsiteid, pQty, pDuedate, pNotes ); RETURN _prid; END; $_$; ALTER FUNCTION public.createpr(integer, integer, numeric, date, text, character, integer) OWNER TO admin; -- -- Name: createpriv(text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createpriv(text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pModule ALIAS FOR $1; pName ALIAS FOR $2; pDesc ALIAS FOR $3; _id INTEGER; BEGIN SELECT priv_id INTO _id FROM priv WHERE(priv_name=pName); IF (FOUND) THEN UPDATE priv SET priv_module=pModule, priv_descrip=pDesc WHERE(priv_id=_id); ELSE SELECT nextval('priv_priv_id_seq') INTO _id; INSERT INTO priv (priv_id, priv_module, priv_name, priv_descrip) VALUES(_id, pModule, pName, pDesc); END IF; RETURN _id; END; $_$; ALTER FUNCTION public.createpriv(text, text, text) OWNER TO admin; -- -- Name: createpurchasetoquote(integer, integer, boolean, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createpurchasetoquote(pquitemid integer, pitemsourceid integer, pdropship boolean, pprice numeric DEFAULT NULL::numeric) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _pohead INTEGER := NULL; -- Legacy parameter _s RECORD; _w RECORD; _i RECORD; _c RECORD; _shipto RECORD; _poheadid INTEGER := -1; _poitemid INTEGER := -1; _taxtypeid INTEGER := -1; _charassid INTEGER := -1; _polinenumber INTEGER; _ponumber NUMERIC; _price NUMERIC; _temp INTEGER; BEGIN -- Check for existing poitem for this quitem SELECT poitem_id INTO _poitemid FROM poitem WHERE (poitem_order_id=pQuitemId) AND (poitem_order_type='S'); IF (FOUND) THEN RETURN _poitemid; END IF; SELECT quhead_id, quhead_prj_id, quhead_shipcomments, quhead_shipto_cntct_email, quhead_shipto_cntct_fax, quhead_shipto_cntct_first_name, quhead_shipto_cntct_honorific, quhead_shipto_cntct_id, quhead_shipto_cntct_last_name, quhead_shipto_cntct_middle, quhead_shipto_cntct_phone, quhead_shipto_cntct_suffix, quhead_shipto_cntct_title, quhead_shiptoaddress1, quhead_shiptoaddress2, quhead_shiptoaddress3, quhead_shiptocity, quhead_shiptocountry, quhead_shiptoname, quhead_shiptostate, quhead_shiptozipcode, quhead_warehous_id, quitem_itemsite_id, quitem_memo, quitem_scheddate, addr_city, addr_country, addr_id, addr_line1, addr_line2, addr_line3, addr_postalcode, addr_state, cntct_email, cntct_fax, cntct_first_name, cntct_honorific, cntct_last_name cntct_middle, cntct_phone, cntct_suffix, cntct_title, itemsite_id, shipto_addr_id shipto_cntct_id, shipto_name, COALESCE(roundQty(item_fractional, (quitem_qtyord * quitem_qty_invuomratio)), 0.0) AS orderqty INTO _s FROM quitem JOIN quhead ON (quhead_id = quitem_quhead_id) LEFT OUTER JOIN shiptoinfo ON (quhead_shipto_id = shipto_id) LEFT OUTER JOIN addr ON (shipto_addr_id = addr_id) LEFT OUTER JOIN cntct ON (shipto_cntct_id = cntct_id) LEFT OUTER JOIN itemsite ON (quitem_itemsite_id = itemsite_id) LEFT OUTER JOIN item ON (item_id = itemsite_item_id) WHERE (quitem_id = pQuitemId); IF (NOT FOUND) THEN RETURN -1; END IF; SELECT addr_city, addr_country, addr_id, addr_line1, addr_line2, addr_line3, addr_postalcode, addr_state, cntct_email, cntct_fax, cntct_first_name, cntct_honorific, cntct_id, cntct_last_name, cntct_middle, cntct_phone, cntct_suffix, cntct_title INTO _w FROM itemsite JOIN whsinfo ON (warehous_id = itemsite_warehous_id) LEFT OUTER JOIN addr ON (warehous_addr_id = addr_id) LEFT OUTER JOIN cntct ON (warehous_cntct_id = cntct_id) WHERE (itemsite_id = _s.itemsite_id); SELECT itemsrc_vend_id, vend_taxzone_id, vend_curr_id, vend_shipvia, vend_terms_id, cntct_id, addr_city, addr_country, addr_line1, addr_line2, addr_line3, addr_postalcode, addr_state, cntct_email, cntct_fax, cntct_first_name, cntct_honorific, cntct_last_name, cntct_middle, cntct_phone, cntct_suffix, cntct_title, itemsrc_invvendoruomratio, itemsrc_item_id, itemsrc_manuf_item_descrip, itemsrc_manuf_item_number, itemsrc_manuf_name, itemsrc_vend_item_descrip, itemsrc_vend_item_number, itemsrc_vend_uom INTO _i FROM itemsrc JOIN vendinfo ON (itemsrc_vend_id = vend_id) LEFT OUTER JOIN cntct ON (vend_cntct1_id = cntct_id) LEFT OUTER JOIN addr ON (vend_addr_id = addr_id) WHERE (itemsrc_id = pItemSourceId); IF (NOT FOUND) THEN RETURN -2; END IF; -- _pohead - NULL=add to existing PO if one exists -- -1=must create new PO -- >0=must add to existing specified PO IF (pDropShip) THEN SELECT COALESCE(pohead_id, -1) INTO _temp FROM pohead WHERE ( (pohead_status = 'U') AND (pohead_vend_id = _i.itemsrc_vend_id) AND (COALESCE(pohead_shiptoname, '') = COALESCE(_s.quhead_shiptoname, _s.shipto_name, '')) AND (COALESCE(pohead_shiptoaddress1, '') = COALESCE(_s.quhead_shiptoaddress1, _s.addr_line1, '')) AND (COALESCE(pohead_shiptoaddress2, '') = COALESCE(_s.quhead_shiptoaddress2, _s.addr_line2, '')) AND (COALESCE(pohead_shiptoaddress3, '') = COALESCE(_s.quhead_shiptoaddress3, _s.addr_line3, '')) AND (COALESCE(pohead_shiptocity, '') = COALESCE(_s.quhead_shiptocity, _s.addr_city, '')) AND (COALESCE(pohead_shiptostate, '') = COALESCE(_s.quhead_shiptostate, _s.addr_state, '')) AND (COALESCE(pohead_shiptozipcode, '') = COALESCE(_s.quhead_shiptozipcode, _s.addr_postalcode, '')) AND (COALESCE(pohead_shiptocountry, '') = COALESCE(_s.quhead_shiptocountry, _s.addr_country, '')) AND ((pohead_id=_pohead) OR (_pohead IS NULL)) ); ELSE SELECT COALESCE(pohead_id, -1) INTO _temp FROM pohead WHERE ( (pohead_status = 'U') AND (pohead_vend_id = _i.itemsrc_vend_id) AND (COALESCE(pohead_shiptoaddress1, '') = COALESCE(_w.addr_line1, '')) AND (COALESCE(pohead_shiptoaddress2, '') = COALESCE(_w.addr_line2, '')) AND (COALESCE(pohead_shiptoaddress3, '') = COALESCE(_w.addr_line3, '')) AND (COALESCE(pohead_shiptocity, '') = COALESCE(_w.addr_city, '')) AND (COALESCE(pohead_shiptostate, '') = COALESCE(_w.addr_state, '')) AND (COALESCE(pohead_shiptozipcode, '') = COALESCE(_w.addr_postalcode, '')) AND (COALESCE(pohead_shiptocountry, '') = COALESCE(_w.addr_country, '')) AND ((pohead_id=_pohead) OR (_pohead IS NULL)) ); END IF; IF (FOUND) THEN -- Add to Existing _poheadid := _temp; UPDATE pohead SET pohead_dropship = pDropShip WHERE (pohead_id = _poheadid); ELSE -- Create New SELECT NEXTVAL('pohead_pohead_id_seq'), fetchPoNumber() INTO _poheadid, _ponumber; IF (pDropShip) THEN INSERT INTO pohead ( pohead_id, pohead_number, pohead_status, pohead_dropship, pohead_agent_username, pohead_vend_id, pohead_taxzone_id, pohead_orderdate, pohead_curr_id, pohead_warehous_id, pohead_shipvia, pohead_terms_id, pohead_shipto_cntct_id, pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name, pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name, pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone, pohead_shipto_cntct_title, pohead_shipto_cntct_fax, pohead_shipto_cntct_email, pohead_shiptoaddress_id, pohead_shiptoname, pohead_shiptoaddress1, pohead_shiptoaddress2, pohead_shiptoaddress3, pohead_shiptocity, pohead_shiptostate, pohead_shiptozipcode, pohead_shiptocountry, pohead_vend_cntct_id, pohead_vend_cntct_honorific, pohead_vend_cntct_first_name, pohead_vend_cntct_middle, pohead_vend_cntct_last_name, pohead_vend_cntct_suffix, pohead_vend_cntct_phone, pohead_vend_cntct_title, pohead_vend_cntct_fax, pohead_vend_cntct_email, pohead_vendaddress1, pohead_vendaddress2, pohead_vendaddress3, pohead_vendcity, pohead_vendstate, pohead_vendzipcode, pohead_vendcountry, pohead_comments ) VALUES ( _poheadid, _ponumber, 'U', pDropShip, getEffectiveXtUser(), _i.itemsrc_vend_id, _i.vend_taxzone_id, CURRENT_DATE, COALESCE(_i.vend_curr_id, basecurrid()), COALESCE(_s.quhead_warehous_id, -1), COALESCE(_i.vend_shipvia, TEXT('')), COALESCE(_i.vend_terms_id, -1), COALESCE(_s.quhead_shipto_cntct_id, _s.shipto_cntct_id), COALESCE(_s.quhead_shipto_cntct_honorific, _s.cntct_honorific), COALESCE(_s.quhead_shipto_cntct_first_name, _s.cntct_first_name), COALESCE(_s.quhead_shipto_cntct_middle, _s.cntct_middle), COALESCE(_s.quhead_shipto_cntct_last_name, _s.cntct_last_name), COALESCE(_s.quhead_shipto_cntct_suffix, _s.cntct_suffix), COALESCE(_s.quhead_shipto_cntct_phone, _s.cntct_phone), COALESCE(_s.quhead_shipto_cntct_title, _s.cntct_title), COALESCE(_s.quhead_shipto_cntct_fax, _s.cntct_fax), COALESCE(_s.quhead_shipto_cntct_email, _s.cntct_email), COALESCE(_s.shipto_addr_id, _s.addr_id), COALESCE(_s.quhead_shiptoname, _s.shipto_name, ''), COALESCE(_s.quhead_shiptoaddress1, _s.addr_line1, ''), COALESCE(_s.quhead_shiptoaddress2, _s.addr_line2, ''), COALESCE(_s.quhead_shiptoaddress3, _s.addr_line3, ''), COALESCE(_s.quhead_shiptocity, _s.addr_city, ''), COALESCE(_s.quhead_shiptostate, _s.addr_state, ''), COALESCE(_s.quhead_shiptozipcode, _s.addr_postalcode, ''), COALESCE(_s.quhead_shiptocountry, _s.addr_country, ''), _i.cntct_id, COALESCE(_i.cntct_honorific, TEXT('')), COALESCE(_i.cntct_first_name, TEXT('')), COALESCE(_i.cntct_middle, TEXT('')), COALESCE(_i.cntct_last_name, TEXT('')), COALESCE(_i.cntct_suffix, TEXT('')), COALESCE(_i.cntct_phone, TEXT('')), COALESCE(_i.cntct_title, TEXT('')), COALESCE(_i.cntct_fax, TEXT('')), COALESCE(_i.cntct_email, TEXT('')), COALESCE(_i.addr_line1, TEXT('')), COALESCE(_i.addr_line2, TEXT('')), COALESCE(_i.addr_line3, TEXT('')), COALESCE(_i.addr_city, TEXT('')), COALESCE(_i.addr_state, TEXT('')), COALESCE(_i.addr_postalcode, TEXT('')), COALESCE(_i.addr_country, TEXT('')), COALESCE(_s.quhead_shipcomments, TEXT('')) ); ELSE INSERT INTO pohead ( pohead_id, pohead_number, pohead_status, pohead_dropship, pohead_agent_username, pohead_vend_id, pohead_taxzone_id, pohead_orderdate, pohead_curr_id, pohead_warehous_id, pohead_shipvia, pohead_terms_id, pohead_shipto_cntct_id, pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name, pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name, pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone, pohead_shipto_cntct_title, pohead_shipto_cntct_fax, pohead_shipto_cntct_email, pohead_shiptoaddress_id, pohead_shiptoaddress1, pohead_shiptoaddress2, pohead_shiptoaddress3, pohead_shiptocity, pohead_shiptostate, pohead_shiptozipcode, pohead_shiptocountry, pohead_vend_cntct_id, pohead_vend_cntct_honorific, pohead_vend_cntct_first_name, pohead_vend_cntct_middle, pohead_vend_cntct_last_name, pohead_vend_cntct_suffix, pohead_vend_cntct_phone, pohead_vend_cntct_title, pohead_vend_cntct_fax, pohead_vend_cntct_email, pohead_vendaddress1, pohead_vendaddress2, pohead_vendaddress3, pohead_vendcity, pohead_vendstate, pohead_vendzipcode, pohead_vendcountry ) VALUES ( _poheadid, _ponumber, 'U', pDropShip, getEffectiveXtUser(), _i.itemsrc_vend_id, _i.vend_taxzone_id, CURRENT_DATE, COALESCE(_i.vend_curr_id, basecurrid()), COALESCE(_s.quhead_warehous_id, -1), COALESCE(_i.vend_shipvia, TEXT('')), COALESCE(_i.vend_terms_id, -1), _w.cntct_id, _w.cntct_honorific, _w.cntct_first_name, _w.cntct_middle, _w.cntct_last_name, _w.cntct_suffix, _w.cntct_phone, _w.cntct_title, _w.cntct_fax, _w.cntct_email, _w.addr_id, COALESCE(_w.addr_line1, ''), COALESCE(_w.addr_line2, ''), COALESCE(_w.addr_line3, ''), COALESCE(_w.addr_city, ''), COALESCE(_w.addr_state, ''), COALESCE(_w.addr_postalcode, ''), COALESCE(_w.addr_country, ''), _i.cntct_id, COALESCE(_i.cntct_honorific, TEXT('')), COALESCE(_i.cntct_first_name, TEXT('')), COALESCE(_i.cntct_middle, TEXT('')), COALESCE(_i.cntct_last_name, TEXT('')), COALESCE(_i.cntct_suffix, TEXT('')), COALESCE(_i.cntct_phone, TEXT('')), COALESCE(_i.cntct_title, TEXT('')), COALESCE(_i.cntct_fax, TEXT('')), COALESCE(_i.cntct_email, TEXT('')), COALESCE(_i.addr_line1, TEXT('')), COALESCE(_i.addr_line2, TEXT('')), COALESCE(_i.addr_line3, TEXT('')), COALESCE(_i.addr_city, TEXT('')), COALESCE(_i.addr_state, TEXT('')), COALESCE(_i.addr_postalcode, TEXT('')), COALESCE(_i.addr_country, TEXT('')) ); END IF; END IF; -- Copy characteristics from the quhead to the pohead -- while avoiding duplicates FOR _c IN SELECT charass.* FROM charass JOIN char ON char_id = charass_char_id JOIN charuse ON char_id = charuse_char_id AND charuse_target_type = 'PO' WHERE charass_target_type = 'QU' AND charass_target_id = _s.quhead_id LOOP SELECT charass_id INTO _charassid FROM charass WHERE ( (charass_target_type='PO') AND (charass_target_id=_poheadid) AND (charass_char_id=_c.charass_char_id) AND (charass_value=_c.charass_value) ); IF (NOT FOUND) THEN INSERT INTO charass ( charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price ) VALUES ( 'PO', _poheadid, _c.charass_char_id, _c.charass_value, _c.charass_default, _c.charass_price ); END IF; END LOOP; SELECT NEXTVAL('poitem_poitem_id_seq') INTO _poitemid; SELECT (COALESCE(MAX(poitem_linenumber), 0) + 1) INTO _polinenumber FROM poitem WHERE (poitem_pohead_id = _poheadid); SELECT COALESCE(itemtax_taxtype_id, -1) INTO _taxtypeid FROM itemtax WHERE (itemtax_item_id = _i.itemsrc_item_id); IF (pPrice IS NULL) THEN SELECT itemsrcPrice(pItemSourceId, COALESCE(_s.quhead_warehous_id, -1), pDropShip, (_s.orderqty / COALESCE(_i.itemsrc_invvendoruomratio, 1.00)), COALESCE(_i.vend_curr_id, baseCurrId()), CURRENT_DATE) INTO _price; ELSE _price := pPrice; END IF; INSERT INTO poitem ( poitem_id, poitem_status, poitem_pohead_id, poitem_linenumber, poitem_duedate, poitem_itemsite_id, poitem_vend_item_descrip, poitem_vend_uom, poitem_invvenduomratio, poitem_qty_ordered, poitem_unitprice, poitem_vend_item_number, poitem_itemsrc_id, poitem_order_id, poitem_order_type, poitem_prj_id, poitem_stdcost, poitem_manuf_name, poitem_manuf_item_number, poitem_manuf_item_descrip, poitem_taxtype_id, poitem_comments ) VALUES ( _poitemid, 'U', _poheadid, _polinenumber, _s.quitem_scheddate, _s.quitem_itemsite_id, COALESCE(_i.itemsrc_vend_item_descrip, TEXT('')), COALESCE(_i.itemsrc_vend_uom, TEXT('')), COALESCE(_i.itemsrc_invvendoruomratio, 1.00), (_s.orderqty / COALESCE(_i.itemsrc_invvendoruomratio, 1.00)), _price, COALESCE(_i.itemsrc_vend_item_number, TEXT('')), pItemSourceId, pQuitemId, 'Q', _s.quhead_prj_id, stdcost(_i.itemsrc_item_id), COALESCE(_i.itemsrc_manuf_name, TEXT('')), COALESCE(_i.itemsrc_manuf_item_number, TEXT('')), COALESCE(_i.itemsrc_manuf_item_descrip, TEXT('')), _taxtypeid, COALESCE(_s.quitem_memo, TEXT(''))); -- Copy characteristics from the quitem to the poitem INSERT INTO charass ( charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price ) SELECT 'PI', _poitemid, charass_char_id, charass_value, charass_default, charass_price FROM charass JOIN char ON char_id = charass_char_id JOIN charuse ON char_id = charuse_char_id AND charuse_target_type = 'PI' WHERE charass_target_type = 'QI' AND charass_target_id = pQuitemId; -- Generate the PoItemCreatedBySo event notice PERFORM postEvent('PoItemCreatedBySo', 'P', poitem_id, itemsite_warehous_id, (pohead_number || '-'|| poitem_linenumber || ': ' || item_number), NULL, NULL, NULL, NULL) FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id) JOIN itemsite ON (itemsite_id=poitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (poitem_id=_poitemid) AND (poitem_duedate <= (CURRENT_DATE + itemsite_eventfence)); RETURN _poitemid; END; $$; ALTER FUNCTION public.createpurchasetoquote(pquitemid integer, pitemsourceid integer, pdropship boolean, pprice numeric) OWNER TO admin; -- -- Name: createpurchasetosale(integer, integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createpurchasetosale(integer, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCoitemId ALIAS FOR $1; pItemSourceId ALIAS FOR $2; pDropShip ALIAS FOR $3; BEGIN RETURN createPurchaseToSale(pCoitemId, pItemSourceId, pDropShip, NULL, NULL, NULL); END; $_$; ALTER FUNCTION public.createpurchasetosale(integer, integer, boolean) OWNER TO admin; -- -- Name: createpurchasetosale(integer, integer, boolean, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createpurchasetosale(integer, integer, boolean, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCoitemId ALIAS FOR $1; pItemSourceId ALIAS FOR $2; pDropShip ALIAS FOR $3; pPrice ALIAS FOR $4; BEGIN RETURN createPurchaseToSale(pCoitemId, pItemSourceId, pDropShip, NULL, NULL, pPrice); END; $_$; ALTER FUNCTION public.createpurchasetosale(integer, integer, boolean, numeric) OWNER TO admin; -- -- Name: createpurchasetosale(integer, integer, boolean, numeric, date, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createpurchasetosale(integer, integer, boolean, numeric, date, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCoitemId ALIAS FOR $1; pItemSourceId ALIAS FOR $2; pDropShip ALIAS FOR $3; pQty ALIAS FOR $4; pDueDate ALIAS FOR $5; pPrice ALIAS FOR $6; BEGIN RETURN createPurchaseToSale(pCoitemId, pItemSourceId, pDropShip, pQty, pDueDate, pPrice, NULL); END; $_$; ALTER FUNCTION public.createpurchasetosale(integer, integer, boolean, numeric, date, numeric) OWNER TO admin; -- -- Name: createpurchasetosale(integer, integer, boolean, numeric, date, numeric, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createpurchasetosale(pcoitemid integer, pitemsourceid integer, pdropship boolean, pqty numeric, pduedate date, pprice numeric, ppoheadid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _s RECORD; _w RECORD; _i RECORD; _c RECORD; _poheadid INTEGER := -1; _poitemid INTEGER := -1; _taxtypeid INTEGER := -1; _charassid INTEGER := -1; _polinenumber INTEGER; _ponumber NUMERIC; _price NUMERIC; _temp INTEGER; BEGIN -- Check for existing poitem for this coitem SELECT poitem_id INTO _poitemid FROM poitem WHERE (poitem_order_id=pCoitemId) AND (poitem_order_type='S'); IF (FOUND) THEN RETURN _poitemid; END IF; SELECT *, COALESCE(roundQty(item_fractional, (coitem_qtyord * coitem_qty_invuomratio)), 0.0) AS orderqty INTO _s FROM coitem JOIN cohead ON (cohead_id = coitem_cohead_id) LEFT OUTER JOIN shiptoinfo ON (cohead_shipto_id = shipto_id) LEFT OUTER JOIN addr ON (shipto_addr_id = addr_id) LEFT OUTER JOIN cntct ON (shipto_cntct_id = cntct_id) LEFT OUTER JOIN itemsite ON (coitem_itemsite_id = itemsite_id) LEFT OUTER JOIN item ON (item_id = itemsite_item_id) WHERE (coitem_id = pCoitemId); IF (NOT FOUND) THEN RETURN -1; END IF; SELECT * INTO _w FROM itemsite JOIN whsinfo ON (warehous_id = itemsite_warehous_id) LEFT OUTER JOIN addr ON (warehous_addr_id = addr_id) LEFT OUTER JOIN cntct ON (warehous_cntct_id = cntct_id) WHERE (itemsite_id = _s.itemsite_id); SELECT * INTO _i FROM itemsrc JOIN vendinfo ON (itemsrc_vend_id = vend_id) LEFT OUTER JOIN cntct ON (vend_cntct1_id = cntct_id) LEFT OUTER JOIN addr ON (vend_addr_id = addr_id) WHERE (itemsrc_id = pItemSourceId); IF (NOT FOUND) THEN RETURN -2; END IF; -- pPoheadId - NULL=add to existing PO if one exists -- -1=must create new PO -- >0=must add to existing specified PO IF (pDropShip) THEN SELECT COALESCE(pohead_id, -1) INTO _temp FROM pohead WHERE ( (pohead_status = 'U') AND (pohead_vend_id = _i.itemsrc_vend_id) AND (COALESCE(pohead_shiptoname, '') = COALESCE(_s.cohead_shiptoname, _s.shipto_name, '')) AND (COALESCE(pohead_shiptoaddress1, '') = COALESCE(_s.cohead_shiptoaddress1, _s.addr_line1, '')) AND (COALESCE(pohead_shiptoaddress2, '') = COALESCE(_s.cohead_shiptoaddress2, _s.addr_line2, '')) AND (COALESCE(pohead_shiptoaddress3, '') = COALESCE(_s.cohead_shiptoaddress3, _s.addr_line3, '')) AND (COALESCE(pohead_shiptocity, '') = COALESCE(_s.cohead_shiptocity, _s.addr_city, '')) AND (COALESCE(pohead_shiptostate, '') = COALESCE(_s.cohead_shiptostate, _s.addr_state, '')) AND (COALESCE(pohead_shiptozipcode, '') = COALESCE(_s.cohead_shiptozipcode, _s.addr_postalcode, '')) AND (COALESCE(pohead_shiptocountry, '') = COALESCE(_s.cohead_shiptocountry, _s.addr_country, '')) AND ((pohead_id=pPoheadId) OR (pPoheadid IS NULL)) ); ELSE SELECT COALESCE(pohead_id, -1) INTO _temp FROM pohead WHERE ( (pohead_status = 'U') AND (pohead_vend_id = _i.itemsrc_vend_id) AND (COALESCE(pohead_shiptoaddress1, '') = COALESCE(_w.addr_line1, '')) AND (COALESCE(pohead_shiptoaddress2, '') = COALESCE(_w.addr_line2, '')) AND (COALESCE(pohead_shiptoaddress3, '') = COALESCE(_w.addr_line3, '')) AND (COALESCE(pohead_shiptocity, '') = COALESCE(_w.addr_city, '')) AND (COALESCE(pohead_shiptostate, '') = COALESCE(_w.addr_state, '')) AND (COALESCE(pohead_shiptozipcode, '') = COALESCE(_w.addr_postalcode, '')) AND (COALESCE(pohead_shiptocountry, '') = COALESCE(_w.addr_country, '')) AND ((pohead_id=pPoheadId) OR (pPoheadid IS NULL)) ); END IF; IF (FOUND) THEN IF (pPoheadId = -1) THEN RAISE EXCEPTION 'Problem creating new PO'; END IF; _poheadid := _temp; UPDATE pohead SET pohead_dropship = pDropShip WHERE (pohead_id = _poheadid); ELSE IF (pPoheadId > 0) THEN RAISE EXCEPTION 'Problem adding to existing PO'; END IF; SELECT NEXTVAL('pohead_pohead_id_seq') INTO _poheadid; SELECT fetchPoNumber() INTO _ponumber; IF (pDropShip) THEN INSERT INTO pohead ( pohead_id, pohead_number, pohead_status, pohead_dropship, pohead_agent_username, pohead_vend_id, pohead_taxzone_id, pohead_orderdate, pohead_curr_id, pohead_cohead_id, pohead_warehous_id, pohead_shipvia, pohead_terms_id, pohead_shipto_cntct_id, pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name, pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name, pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone, pohead_shipto_cntct_title, pohead_shipto_cntct_fax, pohead_shipto_cntct_email, pohead_shiptoaddress_id, pohead_shiptoname, pohead_shiptoaddress1, pohead_shiptoaddress2, pohead_shiptoaddress3, pohead_shiptocity, pohead_shiptostate, pohead_shiptozipcode, pohead_shiptocountry, pohead_vend_cntct_id, pohead_vend_cntct_honorific, pohead_vend_cntct_first_name, pohead_vend_cntct_middle, pohead_vend_cntct_last_name, pohead_vend_cntct_suffix, pohead_vend_cntct_phone, pohead_vend_cntct_title, pohead_vend_cntct_fax, pohead_vend_cntct_email, pohead_vendaddress1, pohead_vendaddress2, pohead_vendaddress3, pohead_vendcity, pohead_vendstate, pohead_vendzipcode, pohead_vendcountry, pohead_comments ) VALUES ( _poheadid, _ponumber, 'U', pDropShip, getEffectiveXtUser(), _i.itemsrc_vend_id, _i.vend_taxzone_id, CURRENT_DATE, COALESCE(_i.vend_curr_id, basecurrid()), _s.cohead_id, COALESCE(_s.cohead_warehous_id, -1), COALESCE(_i.vend_shipvia, TEXT('')), COALESCE(_i.vend_terms_id, -1), COALESCE(_s.cohead_shipto_cntct_id, _s.shipto_cntct_id), COALESCE(_s.cohead_shipto_cntct_honorific, _s.cntct_honorific), COALESCE(_s.cohead_shipto_cntct_first_name, _s.cntct_first_name), COALESCE(_s.cohead_shipto_cntct_middle, _s.cntct_middle), COALESCE(_s.cohead_shipto_cntct_last_name, _s.cntct_last_name), COALESCE(_s.cohead_shipto_cntct_suffix, _s.cntct_suffix), COALESCE(_s.cohead_shipto_cntct_phone, _s.cntct_phone), COALESCE(_s.cohead_shipto_cntct_title, _s.cntct_title), COALESCE(_s.cohead_shipto_cntct_fax, _s.cntct_fax), COALESCE(_s.cohead_shipto_cntct_email, _s.cntct_email), COALESCE(_s.shipto_addr_id, _s.addr_id), COALESCE(_s.cohead_shiptoname, _s.shipto_name, ''), COALESCE(_s.cohead_shiptoaddress1, _s.addr_line1, ''), COALESCE(_s.cohead_shiptoaddress2, _s.addr_line2, ''), COALESCE(_s.cohead_shiptoaddress3, _s.addr_line3, ''), COALESCE(_s.cohead_shiptocity, _s.addr_city, ''), COALESCE(_s.cohead_shiptostate, _s.addr_state, ''), COALESCE(_s.cohead_shiptozipcode, _s.addr_postalcode, ''), COALESCE(_s.cohead_shiptocountry, _s.addr_country, ''), _i.cntct_id, COALESCE(_i.cntct_honorific, TEXT('')), COALESCE(_i.cntct_first_name, TEXT('')), COALESCE(_i.cntct_middle, TEXT('')), COALESCE(_i.cntct_last_name, TEXT('')), COALESCE(_i.cntct_suffix, TEXT('')), COALESCE(_i.cntct_phone, TEXT('')), COALESCE(_i.cntct_title, TEXT('')), COALESCE(_i.cntct_fax, TEXT('')), COALESCE(_i.cntct_email, TEXT('')), COALESCE(_i.addr_line1, TEXT('')), COALESCE(_i.addr_line2, TEXT('')), COALESCE(_i.addr_line3, TEXT('')), COALESCE(_i.addr_city, TEXT('')), COALESCE(_i.addr_state, TEXT('')), COALESCE(_i.addr_postalcode, TEXT('')), COALESCE(_i.addr_country, TEXT('')), COALESCE(_s.cohead_shipcomments, TEXT('')) ); ELSE INSERT INTO pohead ( pohead_id, pohead_number, pohead_status, pohead_dropship, pohead_agent_username, pohead_vend_id, pohead_taxzone_id, pohead_orderdate, pohead_curr_id, pohead_cohead_id, pohead_warehous_id, pohead_shipvia, pohead_terms_id, pohead_shipto_cntct_id, pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name, pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name, pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone, pohead_shipto_cntct_title, pohead_shipto_cntct_fax, pohead_shipto_cntct_email, pohead_shiptoaddress_id, pohead_shiptoaddress1, pohead_shiptoaddress2, pohead_shiptoaddress3, pohead_shiptocity, pohead_shiptostate, pohead_shiptozipcode, pohead_shiptocountry, pohead_vend_cntct_id, pohead_vend_cntct_honorific, pohead_vend_cntct_first_name, pohead_vend_cntct_middle, pohead_vend_cntct_last_name, pohead_vend_cntct_suffix, pohead_vend_cntct_phone, pohead_vend_cntct_title, pohead_vend_cntct_fax, pohead_vend_cntct_email, pohead_vendaddress1, pohead_vendaddress2, pohead_vendaddress3, pohead_vendcity, pohead_vendstate, pohead_vendzipcode, pohead_vendcountry ) VALUES ( _poheadid, _ponumber, 'U', pDropShip, getEffectiveXtUser(), _i.itemsrc_vend_id, _i.vend_taxzone_id, CURRENT_DATE, COALESCE(_i.vend_curr_id, basecurrid()), _s.cohead_id, COALESCE(_s.cohead_warehous_id, -1), COALESCE(_i.vend_shipvia, TEXT('')), COALESCE(_i.vend_terms_id, -1), _w.cntct_id, _w.cntct_honorific, _w.cntct_first_name, _w.cntct_middle, _w.cntct_last_name, _w.cntct_suffix, _w.cntct_phone, _w.cntct_title, _w.cntct_fax, _w.cntct_email, _w.addr_id, COALESCE(_w.addr_line1, ''), COALESCE(_w.addr_line2, ''), COALESCE(_w.addr_line3, ''), COALESCE(_w.addr_city, ''), COALESCE(_w.addr_state, ''), COALESCE(_w.addr_postalcode, ''), COALESCE(_w.addr_country, ''), _i.cntct_id, COALESCE(_i.cntct_honorific, TEXT('')), COALESCE(_i.cntct_first_name, TEXT('')), COALESCE(_i.cntct_middle, TEXT('')), COALESCE(_i.cntct_last_name, TEXT('')), COALESCE(_i.cntct_suffix, TEXT('')), COALESCE(_i.cntct_phone, TEXT('')), COALESCE(_i.cntct_title, TEXT('')), COALESCE(_i.cntct_fax, TEXT('')), COALESCE(_i.cntct_email, TEXT('')), COALESCE(_i.addr_line1, TEXT('')), COALESCE(_i.addr_line2, TEXT('')), COALESCE(_i.addr_line3, TEXT('')), COALESCE(_i.addr_city, TEXT('')), COALESCE(_i.addr_state, TEXT('')), COALESCE(_i.addr_postalcode, TEXT('')), COALESCE(_i.addr_country, TEXT('')) ); END IF; END IF; -- Copy characteristics from the cohead to the pohead -- while avoiding duplicates FOR _c IN SELECT charass.* FROM charass JOIN char ON char_id = charass_char_id JOIN charuse ON char_id = charuse_char_id AND charuse_target_type = 'PO' WHERE charass_target_type = 'SO' AND charass_target_id = _s.cohead_id LOOP SELECT charass_id INTO _charassid FROM charass WHERE ( (charass_target_type='PO') AND (charass_target_id=_poheadid) AND (charass_char_id=_c.charass_char_id) AND (charass_value=_c.charass_value) ); IF (NOT FOUND) THEN INSERT INTO charass ( charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price ) VALUES ( 'PO', _poheadid, _c.charass_char_id, _c.charass_value, _c.charass_default, _c.charass_price ); END IF; END LOOP; SELECT NEXTVAL('poitem_poitem_id_seq') INTO _poitemid; SELECT (COALESCE(MAX(poitem_linenumber), 0) + 1) INTO _polinenumber FROM poitem WHERE (poitem_pohead_id = _poheadid); SELECT COALESCE(itemtax_taxtype_id, -1) INTO _taxtypeid FROM itemtax WHERE (itemtax_item_id = _i.itemsrc_item_id); IF (pPrice IS NULL) THEN SELECT itemsrcPrice(pItemSourceId, COALESCE(_s.cohead_warehous_id, -1), pDropShip, (COALESCE(pQty, _s.orderqty) / COALESCE(_i.itemsrc_invvendoruomratio, 1.00)), COALESCE(_i.vend_curr_id, baseCurrId()), CURRENT_DATE) INTO _price; ELSE _price := pPrice; END IF; IF (pDropShip) THEN INSERT INTO poitem ( poitem_id, poitem_status, poitem_pohead_id, poitem_linenumber, poitem_duedate, poitem_itemsite_id, poitem_vend_item_descrip, poitem_vend_uom, poitem_invvenduomratio, poitem_qty_ordered, poitem_unitprice, poitem_vend_item_number, poitem_itemsrc_id, poitem_order_id, poitem_order_type, poitem_prj_id, poitem_stdcost, poitem_manuf_name, poitem_manuf_item_number, poitem_manuf_item_descrip, poitem_taxtype_id, poitem_comments ) VALUES ( _poitemid, 'U', _poheadid, _polinenumber, COALESCE(pDueDate, _s.coitem_scheddate), _s.coitem_itemsite_id, COALESCE(_i.itemsrc_vend_item_descrip, TEXT('')), COALESCE(_i.itemsrc_vend_uom, TEXT('')), COALESCE(_i.itemsrc_invvendoruomratio, 1.00), (COALESCE(pQty, _s.orderqty) / COALESCE(_i.itemsrc_invvendoruomratio, 1.00)), _price, COALESCE(_i.itemsrc_vend_item_number, TEXT('')), pItemSourceId, pCoitemId, 'S', _s.cohead_prj_id, stdcost(_i.itemsrc_item_id), COALESCE(_i.itemsrc_manuf_name, TEXT('')), COALESCE(_i.itemsrc_manuf_item_number, TEXT('')), COALESCE(_i.itemsrc_manuf_item_descrip, TEXT('')), _taxtypeid, COALESCE(_s.coitem_memo, TEXT(''))); ELSE INSERT INTO poitem ( poitem_id, poitem_status, poitem_pohead_id, poitem_linenumber, poitem_duedate, poitem_itemsite_id, poitem_vend_item_descrip, poitem_vend_uom, poitem_invvenduomratio, poitem_qty_ordered, poitem_unitprice, poitem_vend_item_number, poitem_itemsrc_id, poitem_order_id, poitem_order_type, poitem_prj_id, poitem_stdcost, poitem_manuf_name, poitem_manuf_item_number, poitem_manuf_item_descrip, poitem_taxtype_id, poitem_comments ) VALUES ( _poitemid, 'U', _poheadid, _polinenumber, COALESCE(pDueDate, _s.coitem_scheddate), _s.coitem_itemsite_id, COALESCE(_i.itemsrc_vend_item_descrip, TEXT('')), COALESCE(_i.itemsrc_vend_uom, TEXT('')), COALESCE(_i.itemsrc_invvendoruomratio, 1.00), (COALESCE(pQty, _s.orderqty) / COALESCE(_i.itemsrc_invvendoruomratio, 1.00)), _price, COALESCE(_i.itemsrc_vend_item_number, TEXT('')), pItemSourceId, pCoitemId, 'S', _s.cohead_prj_id, stdcost(_i.itemsrc_item_id), COALESCE(_i.itemsrc_manuf_name, TEXT('')), COALESCE(_i.itemsrc_manuf_item_number, TEXT('')), COALESCE(_i.itemsrc_manuf_item_descrip, TEXT('')), _taxtypeid, COALESCE(_s.coitem_memo, TEXT(''))); END IF; -- Copy characteristics from the coitem to the poitem INSERT INTO charass ( charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price ) SELECT 'PI', _poitemid, charass_char_id, charass_value, charass_default, charass_price FROM charass JOIN char ON char_id = charass_char_id JOIN charuse ON char_id = charuse_char_id AND charuse_target_type = 'PI' WHERE charass_target_type = 'SI' AND charass_target_id = pCoitemId; UPDATE coitem SET coitem_order_type = 'P', coitem_order_id = _poitemid WHERE ( coitem_id = pCoitemId ); -- Generate the PoItemCreatedBySo event notice PERFORM postEvent('PoItemCreatedBySo', 'P', poitem_id, itemsite_warehous_id, (pohead_number || '-'|| poitem_linenumber || ': ' || item_number), NULL, NULL, NULL, NULL) FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id) JOIN itemsite ON (itemsite_id=poitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (poitem_id=_poitemid) AND (poitem_duedate <= (CURRENT_DATE + itemsite_eventfence)); RETURN _poitemid; END; $$; ALTER FUNCTION public.createpurchasetosale(pcoitemid integer, pitemsourceid integer, pdropship boolean, pqty numeric, pduedate date, pprice numeric, ppoheadid integer) OWNER TO admin; -- -- Name: createrecurringinvoices(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createrecurringinvoices() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'createRecurringInvoices() has been deprecated; use createRecurringItems(NULL, ''I'') instead.'; RETURN createRecurringItems(NULL, 'I'); END; $$; ALTER FUNCTION public.createrecurringinvoices() OWNER TO admin; -- -- Name: createrecurringitems(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createrecurringitems(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pParentid ALIAS FOR $1; -- if NULL then all items with the given pType pType TEXT := UPPER($2); -- if NULL then all types -- if both are null then all items of all types _copystmt TEXT; _count INTEGER := 0; _countstmt TEXT; _existcnt INTEGER; _id INTEGER; _interval TEXT; _last TIMESTAMP WITH TIME ZONE; _loopcount INTEGER := 1; _maxstmt TEXT; _maxdate TIMESTAMP WITH TIME ZONE := endOfTime(); _result INTEGER := 0; _next TIMESTAMP WITH TIME ZONE; _r RECORD; _rt RECORD; _tmp INTEGER; BEGIN RAISE DEBUG 'createRecurringItems(%, %) entered', pParentid, pType; FOR _r IN SELECT * FROM recur WHERE ((COALESCE(recur_end, endOfTime()) >= CURRENT_TIMESTAMP) AND (pParentid IS NULL OR recur_parent_id=pParentid) AND (pType IS NULL OR UPPER(recur_parent_type)=UPPER(pType))) LOOP RAISE DEBUG 'createRecurringItems looking at recur %, %', _r.recur_id, _r.recur_parent_type; _r.recur_max := COALESCE(_r.recur_max, CAST(fetchMetricValue('RecurringInvoiceBuffer') AS INTEGER), 1); _interval := CASE _r.recur_period WHEN 'Y' THEN ' year' WHEN 'M' THEN ' month' WHEN 'W' THEN ' week' WHEN 'D' THEN ' day' WHEN 'H' THEN ' hour' WHEN 'm' THEN ' minute' ELSE NULL END; IF (_interval IS NULL OR COALESCE(_r.recur_freq, 0) <= 0) THEN RAISE EXCEPTION 'Unknown recurrence frequency % % ON % %', _r.recur_freq, _r.recur_period, _r.recur_parent_type, _r.recur_parent_id; END IF; SELECT * INTO _rt FROM recurtype WHERE (UPPER(recurtype_type)=UPPER(pType)); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count <= 0) THEN RETURN -10; END IF; -- if the recurrence type has a max lookahead window, use it IF (_r.recur_parent_type = 'I') THEN _maxdate := CURRENT_TIMESTAMP + CAST(fetchMetricText('RecurringInvoiceBuffer') || ' days' AS INTERVAL); END IF; IF (_r.recur_parent_type = 'V') THEN _maxdate := CURRENT_TIMESTAMP + CAST(fetchMetricText('RecurringVoucherBuffer') || ' days' AS INTERVAL); END IF; IF (_maxdate > _r.recur_end) THEN -- if recur_end is null, _maxdate is ok _maxdate = _r.recur_end; END IF; -- build statements dynamically from the recurtype table because packages -- might also require recurring items. this way the algorithm is fixed -- and the details are data-driven _countstmt := 'SELECT COUNT(*) FROM [fulltable]' || ' WHERE (($1=[table]_recurring_[table]_id)' || ' AND NOT([done]) ' || ' AND ([limit]));'; _countstmt := REPLACE(_countstmt, '[fulltable]', _rt.recurtype_table); _countstmt := REPLACE(_countstmt, '[table]', REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', '')); _countstmt := REPLACE(_countstmt, '[done]', _rt.recurtype_donecheck); _countstmt := REPLACE(_countstmt, '[limit]', COALESCE(_rt.recurtype_limit, 'TRUE')); _maxstmt := 'SELECT MAX([schedcol]) FROM [fulltable]' || ' WHERE (($1=[table]_recurring_[table]_id)' || ' AND ([limit]));'; _maxstmt := REPLACE(_maxstmt, '[schedcol]', _rt.recurtype_schedcol); _maxstmt := REPLACE(_maxstmt, '[fulltable]',_rt.recurtype_table); _maxstmt := REPLACE(_maxstmt, '[table]', REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', '')); _maxstmt := REPLACE(_maxstmt, '[limit]', COALESCE(_rt.recurtype_limit, 'TRUE')); _copystmt := 'SELECT [copy]($1, [datetime] [more]);'; _copystmt := REPLACE(_copystmt, '[copy]', _rt.recurtype_copyfunc); _copystmt := REPLACE(_copystmt, '[datetime]', CASE WHEN UPPER(_rt.recurtype_copyargs[2])='DATE' THEN 'CAST(''$2'' AS DATE)' ELSE '''$2''' END); -- 8.4+: -- _copystmt := REPLACE(_copystmt, '[more]', -- REPEAT(', NULL', -- array_length(_rt.recurtype_copyargs) - 2)); _tmp := CAST(REPLACE(REGEXP_REPLACE(array_dims(_rt.recurtype_copyargs), '.*:', ''), ']', '') AS INTEGER); _copystmt := REPLACE(_copystmt, '[more]', REPEAT(', NULL', _tmp - 2)); EXECUTE REPLACE(_countstmt, '$1', _r.recur_parent_id::TEXT) INTO _existcnt; EXECUTE REPLACE(_maxstmt, '$1', _r.recur_parent_id::TEXT) INTO _last; RAISE DEBUG E'% got %, % got %', _countstmt, _existcnt, _maxstmt, _last; _next := _last; _loopcount := 1; WHILE (_existcnt < _r.recur_max AND _next < _maxdate) LOOP _next := _last + CAST(_r.recur_freq * _loopcount || _interval AS INTERVAL); RAISE DEBUG 'createrecurringitems looping, existcnt = %, max = %, is % between % and %?', _existcnt, _r.recur_max, _next, _r.recur_start, _r.recur_end; IF (_next BETWEEN _r.recur_start AND _maxdate) THEN RAISE DEBUG 'createrecurringitems executing % with % and %', _copystmt, _r.recur_parent_id, _next; -- 8.4+: EXECUTE _copystmt INTO _id USING _r.recur_parent_id, _next; EXECUTE REPLACE(REPLACE(_copystmt, '$1', _r.recur_parent_id::TEXT), '$2', _next::TEXT) INTO _id; RAISE DEBUG 'Copying for % returned %', _next, _id; _result := _result + 1; _existcnt := _existcnt + 1; END IF; _loopcount := _loopcount + 1; END LOOP; END LOOP; RETURN _result; END; $_$; ALTER FUNCTION public.createrecurringitems(integer, text) OWNER TO admin; -- -- Name: createtodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createtodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN createTodoItem($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, NULL); END; $_$; ALTER FUNCTION public.createtodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, text) OWNER TO admin; -- -- Name: createtodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createtodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ptodoid ALIAS FOR $1; pusername ALIAS FOR $2; pname ALIAS FOR $3; pdesc ALIAS FOR $4; pincdtid ALIAS FOR $5; pcrmacctid ALIAS FOR $6; pOpheadid ALIAS FOR $7; pstarted ALIAS FOR $8; pdue ALIAS FOR $9; pstatus ALIAS FOR $10; passigned ALIAS FOR $11; pcompleted ALIAS FOR $12; ppriority ALIAS FOR $13; pnotes ALIAS FOR $14; powner ALIAS FOR $15; pcntctid ALIAS FOR $16; _todoid INTEGER; _priority INTEGER := ppriority; _status CHARACTER(1) := pstatus; _incdtid INTEGER := pincdtid; _crmacctid INTEGER := pcrmacctid; _opheadid INTEGER := pOpheadid; _assigned DATE := passigned; _result INTEGER; BEGIN IF (pusername IS NULL OR pusername = '') THEN RETURN -1; END IF; IF (pname IS NULL OR pname = '') THEN RETURN -2; END IF; IF (pdue IS NULL) THEN RETURN -3; END IF; IF (pcompleted IS NOT NULL) THEN _status := 'C'; ELSIF (pstatus IS NULL AND pstarted IS NOT NULL) THEN _status := 'I'; ELSIF (pstatus IS NULL) THEN _status := 'N'; END IF; IF (_incdtid <= 0) THEN _incdtid := NULL; END IF; IF (_crmacctid <= 0) THEN _crmacctid := NULL; END IF; IF (_opheadid <= 0) THEN _opheadid := NULL; END IF; IF (_priority <= 0) THEN _priority := NULL; END IF; IF (_assigned IS NULL) THEN _assigned := CURRENT_DATE; END IF; IF (ptodoid IS NULL) THEN SELECT NEXTVAL('todoitem_todoitem_id_seq') INTO _todoid; ELSE _todoid := ptodoid; END IF; INSERT INTO todoitem ( todoitem_id, todoitem_username, todoitem_name, todoitem_description, todoitem_incdt_id, todoitem_creator_username, todoitem_status, todoitem_active, todoitem_start_date, todoitem_due_date, todoitem_assigned_date, todoitem_completed_date, todoitem_priority_id, todoitem_notes, todoitem_crmacct_id, todoitem_ophead_id, todoitem_owner_username, todoitem_cntct_id ) VALUES ( _todoid, pusername, pname, pdesc, _incdtid, getEffectiveXtUser(), _status, TRUE, pstarted, pdue, _assigned, pcompleted, _priority, pnotes, _crmacctid, _opheadid, powner, pcntctid ); RETURN _todoid; END; $_$; ALTER FUNCTION public.createtodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, text, integer) OWNER TO admin; -- -- Name: createurl(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createurl(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ declare pTitle ALIAS FOR $1; pUrl ALIAS FOR $2; _id integer; begin _id := nextval('urlinfo_url_id_seq'); insert into urlinfo (url_id, url_title, url_url) values (_id, pTitle, pUrl); return _id; end; $_$; ALTER FUNCTION public.createurl(text, text) OWNER TO admin; -- -- Name: createuser(text, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createuser(pusername text, pcreateusers boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pCreateUsers) THEN EXECUTE 'CREATE USER "' || pUsername || '" CREATEROLE IN GROUP xtrole;'; ELSE EXECUTE 'CREATE USER "' || pUsername || '" NOCREATEROLE IN GROUP xtrole;'; END IF; RETURN 1; END; $$; ALTER FUNCTION public.createuser(pusername text, pcreateusers boolean) OWNER TO admin; -- -- Name: createwo(integer, integer, numeric, integer, date, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createwo(integer, integer, numeric, integer, date, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pQtyOrdered ALIAS FOR $3; pLeadTime ALIAS FOR $4; pDueDate ALIAS FOR $5; pProductionNotes ALIAS FOR $6; BEGIN RETURN createWo( pWoNumber, pItemsiteid, 1, pQtyOrdered, (pDueDate - pLeadTime), pDueDate, pProductionNotes, NULL, NULL, -1 ); END; $_$; ALTER FUNCTION public.createwo(integer, integer, numeric, integer, date, text) OWNER TO admin; -- -- Name: createwo(integer, integer, numeric, date, date, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createwo(integer, integer, numeric, date, date, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pQtyOrdered ALIAS FOR $3; pStartDate ALIAS FOR $4; pDueDate ALIAS FOR $5; pProductionNotes ALIAS FOR $6; BEGIN RETURN createWo( pWoNumber, pItemsiteid, 1, pQtyOrdered, pStartDate, pDueDate, pProductionNotes, NULL, NULL, -1); END; $_$; ALTER FUNCTION public.createwo(integer, integer, numeric, date, date, text) OWNER TO admin; -- -- Name: createwo(integer, integer, numeric, integer, date, text, character, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createwo(integer, integer, numeric, integer, date, text, character, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pQtyOrdered ALIAS FOR $3; pLeadTime ALIAS FOR $4; pDueDate ALIAS FOR $5; pProductionNotes ALIAS FOR $6; pParentType ALIAS FOR $7; pParentId ALIAS FOR $8; BEGIN RETURN createWo( pWoNumber, pItemsiteid, 1, pQtyOrdered, (pDueDate - pLeadTime), pDueDate, pProductionNotes, pParentType, pParentId, -1 ); END; $_$; ALTER FUNCTION public.createwo(integer, integer, numeric, integer, date, text, character, integer) OWNER TO admin; -- -- Name: createwo(integer, integer, integer, numeric, integer, date, text, character, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createwo(integer, integer, integer, numeric, integer, date, text, character, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pPriority ALIAS FOR $3; pQtyOrdered ALIAS FOR $4; pLeadTime ALIAS FOR $5; pDueDate ALIAS FOR $6; pProductionNotes ALIAS FOR $7; pParentType ALIAS FOR $8; pParentId ALIAS FOR $9; BEGIN RETURN createWo(pWoNumber, pItemsiteid, pPriority, pQtyOrdered, (pDueDate - pLeadTime), pDueDate, pProductionNotes, pParentType, pParentId, -1); END; $_$; ALTER FUNCTION public.createwo(integer, integer, integer, numeric, integer, date, text, character, integer) OWNER TO admin; -- -- Name: createwo(integer, integer, integer, numeric, integer, date, text, character, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createwo(integer, integer, integer, numeric, integer, date, text, character, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pPriority ALIAS FOR $3; pQtyOrdered ALIAS FOR $4; pLeadTime ALIAS FOR $5; pDueDate ALIAS FOR $6; pProductionNotes ALIAS FOR $7; pParentType ALIAS FOR $8; pParentId ALIAS FOR $9; pProjectId ALIAS FOR $10; BEGIN RETURN createWo(pWoNumber, pItemsiteid, pPriority, pQtyOrdered, (pDueDate - pLeadTime), pDueDate, pProductionNotes, pParentType, pParentId, pProjectId); END; $_$; ALTER FUNCTION public.createwo(integer, integer, integer, numeric, integer, date, text, character, integer, integer) OWNER TO admin; -- -- Name: createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pPriority ALIAS FOR $3; pQtyOrdered ALIAS FOR $4; pStartDate ALIAS FOR $5; pDueDate ALIAS FOR $6; pProductionNotes ALIAS FOR $7; pParentType ALIAS FOR $8; pParentId ALIAS FOR $9; pProjectId ALIAS FOR $10; _woid INTEGER; _result INTEGER; _parentType char(1); _bomrevid INTEGER; _boorevid INTEGER; BEGIN SELECT getActiveRevId('BOM',itemsite_item_id) INTO _bomrevid FROM itemsite WHERE (itemsite_id=pItemsiteid); SELECT getActiveRevId('BOO',itemsite_item_id) INTO _boorevid FROM itemsite WHERE (itemsite_id=pItemsiteid); RETURN createWo(pWoNumber, pItemsiteid, pPriority, pQtyOrdered, pStartDate, pDueDate, pProductionNotes, pParentType, pParentId, pProjectId, _bomrevid, _boorevid, NULL); END; $_$; ALTER FUNCTION public.createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer) OWNER TO admin; -- -- Name: createwo(integer, integer, integer, numeric, integer, date, text, character, integer, integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createwo(integer, integer, integer, numeric, integer, date, text, character, integer, integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pPriority ALIAS FOR $3; pQtyOrdered ALIAS FOR $4; pLeadTime ALIAS FOR $5; pDueDate ALIAS FOR $6; pProductionNotes ALIAS FOR $7; pParentType ALIAS FOR $8; pParentId ALIAS FOR $9; pProjectId ALIAS FOR $10; pBomRevId ALIAS FOR $11; pBooRevId ALIAS FOR $12; BEGIN RETURN createWo(pWoNumber, pItemsiteid, pPriority, pQtyOrdered, (pDueDate - pLeadTime), pDueDate, pProductionNotes, pParentType, pParentId, pProjectId, pBomRevId, pBooRevId, NULL); END; $_$; ALTER FUNCTION public.createwo(integer, integer, integer, numeric, integer, date, text, character, integer, integer, integer, integer) OWNER TO admin; -- -- Name: createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pPriority ALIAS FOR $3; pQtyOrdered ALIAS FOR $4; pStartDate ALIAS FOR $5; pDueDate ALIAS FOR $6; pProductionNotes ALIAS FOR $7; pParentType ALIAS FOR $8; pParentId ALIAS FOR $9; pProjectId ALIAS FOR $10; pBomRevId ALIAS FOR $11; pBooRevId ALIAS FOR $12; BEGIN RETURN createWo(pWoNumber, pItemsiteid, pPriority, pQtyOrdered, pStartDate, pDueDate, pProductionNotes, pParentType, pParentId, pProjectId, pBomRevId, pBooRevId, NULL); END; $_$; ALTER FUNCTION public.createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer, integer, integer) OWNER TO admin; -- -- Name: createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer, integer, integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer, integer, integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pPriority ALIAS FOR $3; pQtyOrdered ALIAS FOR $4; pStartDate ALIAS FOR $5; pDueDate ALIAS FOR $6; pProductionNotes ALIAS FOR $7; pParentType ALIAS FOR $8; pParentId ALIAS FOR $9; pProjectId ALIAS FOR $10; pBomRevId ALIAS FOR $11; pBooRevId ALIAS FOR $12; pCosMethod ALIAS FOR $13; _startDate DATE; _woid INTEGER; _result INTEGER; _parentType char(1); _parentId INTEGER; _cosmethod char(1); _itemsite RECORD; BEGIN _parentType := COALESCE(pParentType, ' '); _parentId := COALESCE(pParentId, -1); SELECT * INTO _itemsite FROM itemsite WHERE itemsite_id = pItemsiteid; -- Check to make sure the itemsite specified is supplied at itemsite IF (NOT _itemsite.itemsite_wosupply) THEN RETURN -1; END IF; -- Check to make sure if this is a job item that it is tied to a sales order -- Or if it is just an avarage costed item IF (pCosMethod IN ('D', 'P')) THEN _cosmethod := pCosMethod; ELSE IF (_itemsite.itemsite_costmethod = 'J') THEN IF (_parentType = ' ' OR _parentId = -1) THEN RAISE EXCEPTION 'Work Orders for Item Sites that are Job cost must have a parent order.'; ELSE SELECT COALESCE(itemsite_cosdefault,fetchmetrictext('JobItemCosDefault'),'D') INTO _cosmethod FROM itemsite WHERE itemsite_id=pItemsiteid; END IF; ELSIF (_itemsite.itemsite_costmethod = 'A') THEN _cosmethod := COALESCE(_itemsite.itemsite_cosdefault,fetchmetrictext('JobItemCosDefault'),'D'); END IF; END IF; -- Check to see if the site calendar metric is set, and if so adjust the start date if necessary IF (fetchmetricbool('UseSiteCalendar')) THEN _startDate := calculatenextworkingdate(_itemsite.itemsite_warehous_id, pStartDate, 0); IF (_startDate != pStartDate) THEN _startDate := calculatenextworkingdate(_itemsite.itemsite_warehous_id, pDueDate, -_itemsite.itemsite_leadtime); END IF; ELSE _startDate := pStartDate; END IF; -- Grab the next wo_id SELECT NEXTVAL('wo_wo_id_seq') INTO _woid; -- Create the W/O INSERT INTO wo ( wo_id, wo_number, wo_subnumber, wo_itemsite_id, wo_priority, wo_ordtype, wo_ordid, wo_status, wo_startdate, wo_duedate, wo_qtyord, wo_qtyrcv, wo_prodnotes, wo_prj_id, wo_bom_rev_id, wo_boo_rev_id, wo_cosmethod ) SELECT _woid, pWoNumber, nextWoSubnumber(pWoNumber), itemsite_id, pPriority, _parentType, pParentId, 'O', _startDate, pDueDate, roundQty(item_fractional, pQtyOrdered), 0, pProductionNotes, pProjectId, pBomRevid, pBooRevid, _cosmethod FROM itemsite, item WHERE ((itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid)); -- Explode the newly created W/O according to metrics IF ( ( SELECT (metric_value='t') FROM metric WHERE (metric_name='AutoExplodeWO') ) ) THEN SELECT explodeWo( _woid, ( SELECT (metric_value = 'M') FROM metric WHERE (metric_name='WOExplosionLevel') ) ) INTO _result; ELSE _result := _woid; END IF; RETURN _result; END; $_$; ALTER FUNCTION public.createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer, integer, integer, text) OWNER TO admin; -- -- Name: createwomaterial(integer, integer, character, numeric, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createwomaterial(integer, integer, character, numeric, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pWoid ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pIssueMethod ALIAS FOR $3; pQtyPer ALIAS FOR $4; pScrap ALIAS FOR $5; _result INTEGER; BEGIN SELECT createWoMaterial(pWoid, pItemsiteid, pIssueMethod, item_inv_uom_id, pQtyPer, pScrap) INTO _result FROM itemsite JOIN item ON (itemsite_item_id=item_id) WHERE(itemsite_id=pItemsiteid); RETURN _result; END; $_$; ALTER FUNCTION public.createwomaterial(integer, integer, character, numeric, numeric) OWNER TO admin; -- -- Name: createwomaterial(integer, integer, character, integer, numeric, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createwomaterial(integer, integer, character, integer, numeric, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pWoid ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pIssueMethod ALIAS FOR $3; pUomId ALIAS FOR $4; pQtyPer ALIAS FOR $5; pScrap ALIAS FOR $6; _womatlid INTEGER; BEGIN SELECT createWoMaterial(pWoid,pItemsiteid,pIssueMethod,pUomId,pQtyPer,pScrap,-1, NULL, NULL) INTO _womatlid; RETURN _womatlid; END; $_$; ALTER FUNCTION public.createwomaterial(integer, integer, character, integer, numeric, numeric) OWNER TO admin; -- -- Name: createwomaterial(integer, integer, character, numeric, numeric, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createwomaterial(integer, integer, character, numeric, numeric, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pIssueMethod ALIAS FOR $3; pQtyFxd ALIAS FOR $4; pQtyPer ALIAS FOR $5; pScrap ALIAS FOR $6; _result INTEGER; BEGIN SELECT createWoMaterial(pWoid, pItemsiteid, pIssueMethod, item_inv_uom_id, pQtyFxd, pQtyPer, pScrap) INTO _result FROM itemsite JOIN item ON (itemsite_item_id=item_id) WHERE(itemsite_id=pItemsiteid); RETURN _result; END; $_$; ALTER FUNCTION public.createwomaterial(integer, integer, character, numeric, numeric, numeric) OWNER TO admin; -- -- Name: createwomaterial(integer, integer, character, integer, numeric, numeric, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createwomaterial(integer, integer, character, integer, numeric, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pWoid ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pIssueMethod ALIAS FOR $3; pUomId ALIAS FOR $4; pQtyPer ALIAS FOR $5; pScrap ALIAS FOR $6; pBomitemId ALIAS FOR $7; _womatlid INTEGER; BEGIN _womatlid := (SELECT NEXTVAL('womatl_womatl_id_seq')); INSERT INTO womatl ( womatl_id, womatl_wo_id, womatl_itemsite_id, womatl_issuemethod, womatl_uom_id, womatl_qtyper, womatl_scrap, womatl_qtyreq, womatl_qtyiss, womatl_qtywipscrap, womatl_wooper_id, womatl_bomitem_id, womatl_duedate ) SELECT _womatlid, wo_id, pItemsiteid, pIssueMethod, pUomId, pQtyPer, pScrap, roundQty(item_fractional, (wo_qtyord * (pQtyPer * (1 + pScrap)))), 0, 0, -1, pBomitemId, wo_startdate FROM wo, itemsite, item WHERE ( (itemsite_item_id=item_id) AND (wo_id=pWoid) AND (itemsite_id=pItemsiteid) ); UPDATE wo SET wo_adhoc=TRUE WHERE (wo_id=pWoid); UPDATE wo SET wo_status='E' WHERE ( (wo_status='O') AND (wo_id=pWoid) ); RETURN _womatlid; END; $_$; ALTER FUNCTION public.createwomaterial(integer, integer, character, integer, numeric, numeric, integer) OWNER TO admin; -- -- Name: createwomaterial(integer, integer, character, integer, numeric, numeric, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createwomaterial(integer, integer, character, integer, numeric, numeric, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pIssueMethod ALIAS FOR $3; pUomId ALIAS FOR $4; pQtyFxd ALIAS FOR $5; pQtyPer ALIAS FOR $6; pScrap ALIAS FOR $7; _womatlid INTEGER; BEGIN SELECT createWoMaterial(pWoid,pItemsiteid,pIssueMethod,pUomId,pQtyFxd,pQtyPer,pScrap,-1, NULL, NULL) INTO _womatlid; RETURN _womatlid; END; $_$; ALTER FUNCTION public.createwomaterial(integer, integer, character, integer, numeric, numeric, numeric) OWNER TO admin; -- -- Name: createwomaterial(integer, integer, character, integer, numeric, numeric, integer, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createwomaterial(integer, integer, character, integer, numeric, numeric, integer, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pWoid ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pIssueMethod ALIAS FOR $3; pUomId ALIAS FOR $4; pQtyPer ALIAS FOR $5; pScrap ALIAS FOR $6; pBomitemId ALIAS FOR $7; pNotes ALIAS FOR $8; pRef ALIAS FOR $9; _womatlid INTEGER; _p RECORD; BEGIN _womatlid := (SELECT NEXTVAL('womatl_womatl_id_seq')); INSERT INTO womatl ( womatl_id, womatl_wo_id, womatl_itemsite_id, womatl_issuemethod, womatl_uom_id, womatl_qtyper, womatl_scrap, womatl_qtyreq, womatl_qtyiss, womatl_qtywipscrap, womatl_wooper_id, womatl_bomitem_id, womatl_duedate, womatl_notes, womatl_ref ) SELECT _womatlid, wo_id, pItemsiteid, pIssueMethod, pUomId, pQtyPer, pScrap, roundQty(item_fractional, (wo_qtyord * (pQtyPer * (1 + pScrap)))), 0, 0, -1, pBomitemId, wo_startdate, pNotes, pRef FROM wo, itemsite, item WHERE ( (itemsite_item_id=item_id) AND (wo_id=pWoid) AND (itemsite_id=pItemsiteid) ); -- Handle all of the Phantom material requirements WHILE ( ( SELECT COUNT(*) FROM womatl, itemsite, item WHERE ( (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (womatl_wo_id=pWoid) AND (item_type='F') ) ) > 0 ) LOOP FOR _p IN SELECT wo_qtyord, wo_startdate, womatl_id, womatl_wooper_id FROM wo, womatl, itemsite, item WHERE ( (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_type='F') AND (womatl_wo_id=wo_id) AND (wo_id=pWoid) ) LOOP INSERT INTO womatl ( womatl_wo_id, womatl_itemsite_id, womatl_wooper_id, womatl_schedatwooper, womatl_duedate, womatl_uom_id, womatl_qtyper, womatl_scrap, womatl_qtyreq, womatl_qtyiss, womatl_qtywipscrap, womatl_lastissue, womatl_lastreturn, womatl_cost, womatl_picklist, womatl_createwo, womatl_issuemethod, womatl_notes, womatl_ref ) SELECT pWoid, cs.itemsite_id, _p.womatl_wooper_id, womatl_schedatwooper, womatl_duedate, bomitem_uom_id, (bomitem_qtyper * womatl_qtyper), bomitem_scrap, roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id), (_p.wo_qtyord * bomitem_qtyper * womatl_qtyper * (1 + bomitem_scrap))), 0, 0, startOfTime(), startOfTime(), 0, ci.item_picklist, ( (ci.item_type='M') AND (bomitem_createwo) ), bomitem_issuemethod, bomitem_notes, bomitem_ref FROM wo, womatl, bomitem, itemsite AS cs, itemsite AS ps, item AS ci, item AS pi WHERE ( (womatl_itemsite_id=ps.itemsite_id) AND (womatl_wo_id=wo_id) AND (bomitem_parent_item_id=pi.item_id) AND (bomitem_item_id=ci.item_id) AND (ps.itemsite_warehous_id=cs.itemsite_warehous_id) AND (cs.itemsite_item_id=ci.item_id) AND (ps.itemsite_item_id=pi.item_id) AND (woEffectiveDate(_p.wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND (womatl_id=_p.womatl_id)); DELETE FROM womatl WHERE (womatl_id=_p.womatl_id); END LOOP; END LOOP; UPDATE wo SET wo_adhoc=TRUE WHERE (wo_id=pWoid); UPDATE wo SET wo_status='E' WHERE ( (wo_status='O') AND (wo_id=pWoid) ); RETURN _womatlid; END; $_$; ALTER FUNCTION public.createwomaterial(integer, integer, character, integer, numeric, numeric, integer, text, text) OWNER TO admin; -- -- Name: createwomaterial(integer, integer, character, integer, numeric, numeric, numeric, integer, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createwomaterial(integer, integer, character, integer, numeric, numeric, numeric, integer, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pIssueMethod ALIAS FOR $3; pUomId ALIAS FOR $4; pQtyFxd ALIAS FOR $5; pQtyPer ALIAS FOR $6; pScrap ALIAS FOR $7; pBomitemId ALIAS FOR $8; pNotes ALIAS FOR $9; pRef ALIAS FOR $10; _womatlid INTEGER; BEGIN SELECT createWoMaterial(pWoid,pItemsiteid,pIssueMethod,pUomId,pQtyFxd,pQtyPer,pScrap,pBomitemId,pNotes,pRef,NULL,NULL) INTO _womatlid; RETURN _womatlid; END; $_$; ALTER FUNCTION public.createwomaterial(integer, integer, character, integer, numeric, numeric, numeric, integer, text, text) OWNER TO admin; -- -- Name: createwomaterial(integer, integer, character, integer, numeric, numeric, numeric, integer, text, text, integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createwomaterial(pwoid integer, pitemsiteid integer, pissuemethod character, puomid integer, pqtyfxd numeric, pqtyper numeric, pscrap numeric, pbomitemid integer, pnotes text, pref text, pwooperid integer, ppicklist boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _womatlid INTEGER; BEGIN SELECT createWoMaterial(pWoid, pItemsiteid, pIssueMethod, pUomId, pQtyFxd, pQtyPer, pScrap, pBomitemId, pNotes, pRef, pWooperId, pPickList, 0.0) INTO _womatlid; RETURN _womatlid; END; $$; ALTER FUNCTION public.createwomaterial(pwoid integer, pitemsiteid integer, pissuemethod character, puomid integer, pqtyfxd numeric, pqtyper numeric, pscrap numeric, pbomitemid integer, pnotes text, pref text, pwooperid integer, ppicklist boolean) OWNER TO admin; -- -- Name: createwomaterial(integer, integer, character, integer, numeric, numeric, numeric, integer, text, text, integer, boolean, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION createwomaterial(pwoid integer, pitemsiteid integer, pissuemethod character, puomid integer, pqtyfxd numeric, pqtyper numeric, pscrap numeric, pbomitemid integer, pnotes text, pref text, pwooperid integer, ppicklist boolean, pprice numeric) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _womatlid INTEGER; _p RECORD; BEGIN _womatlid := (SELECT NEXTVAL('womatl_womatl_id_seq')); INSERT INTO womatl ( womatl_id, womatl_wo_id, womatl_itemsite_id, womatl_issuemethod, womatl_uom_id, womatl_qtyfxd, womatl_qtyper, womatl_scrap, womatl_qtyreq, womatl_qtyiss, womatl_qtywipscrap, womatl_wooper_id, womatl_bomitem_id, womatl_duedate, womatl_notes, womatl_ref, womatl_picklist, womatl_price ) SELECT _womatlid, wo_id, pItemsiteid, pIssueMethod, pUomId, pQtyFxd, pQtyPer, pScrap, roundQty(item_fractional, (pQtyFxd + wo_qtyord * pQtyPer) * (1 + pScrap) ), 0, 0, COALESCE(pWooperId, -1), pBomitemId, wo_startdate, pNotes, pRef, COALESCE(pPickList, item_picklist), pPrice FROM wo, itemsite JOIN item ON (item_id=itemsite_item_id) WHERE ( (wo_id=pWoid) AND (itemsite_id=pItemsiteid) ); -- Handle all of the Phantom material requirements WHILE ( ( SELECT COUNT(*) FROM womatl, itemsite, item WHERE ( (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (womatl_wo_id=pWoid) AND (item_type='F') ) ) > 0 ) LOOP FOR _p IN SELECT wo_qtyord, wo_startdate, womatl_id, womatl_wooper_id FROM wo, womatl, itemsite, item WHERE ( (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_type='F') AND (womatl_wo_id=wo_id) AND (wo_id=pWoid) ) LOOP INSERT INTO womatl ( womatl_wo_id, womatl_itemsite_id, womatl_wooper_id, womatl_schedatwooper, womatl_duedate, womatl_uom_id, womatl_qtyfxd, womatl_qtyper, womatl_scrap, womatl_qtyreq, womatl_qtyiss, womatl_qtywipscrap, womatl_lastissue, womatl_lastreturn, womatl_cost, womatl_picklist, womatl_createwo, womatl_issuemethod, womatl_notes, womatl_ref ) SELECT pWoid, cs.itemsite_id, _p.womatl_wooper_id, womatl_schedatwooper, womatl_duedate, bomitem_uom_id, bomitem_qtyfxd, (bomitem_qtyper * womatl_qtyper), bomitem_scrap, roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id), ((bomitem_qtyfxd + _p.wo_qtyord * bomitem_qtyper) * womatl_qtyper * (1 + bomitem_scrap))), 0, 0, startOfTime(), startOfTime(), 0, ci.item_picklist, ( (ci.item_type='M') AND (bomitem_createwo) ), bomitem_issuemethod, bomitem_notes, bomitem_ref FROM wo, womatl, bomitem, itemsite AS cs, itemsite AS ps, item AS ci, item AS pi WHERE ( (womatl_itemsite_id=ps.itemsite_id) AND (womatl_wo_id=wo_id) AND (bomitem_parent_item_id=pi.item_id) AND (bomitem_item_id=ci.item_id) AND (ps.itemsite_warehous_id=cs.itemsite_warehous_id) AND (cs.itemsite_item_id=ci.item_id) AND (ps.itemsite_item_id=pi.item_id) AND (woEffectiveDate(_p.wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND (womatl_id=_p.womatl_id)); DELETE FROM womatl WHERE (womatl_id=_p.womatl_id); END LOOP; END LOOP; UPDATE wo SET wo_adhoc=TRUE WHERE (wo_id=pWoid); UPDATE wo SET wo_status='E' WHERE ( (wo_status='O') AND (wo_id=pWoid) ); RETURN _womatlid; END; $$; ALTER FUNCTION public.createwomaterial(pwoid integer, pitemsiteid integer, pissuemethod character, puomid integer, pqtyfxd numeric, pqtyper numeric, pscrap numeric, pbomitemid integer, pnotes text, pref text, pwooperid integer, ppicklist boolean, pprice numeric) OWNER TO admin; -- -- Name: creditmemototal(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION creditmemototal(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCreditmemoId ALIAS FOR $1; _result NUMERIC; BEGIN -- TO DO: Add in line item taxes SELECT COALESCE(cmhead_freight,0.0) + COALESCE(cmhead_misc,0.0) + ( SELECT COALESCE(ROUND(SUM((cmitem_qtycredit * cmitem_qty_invuomratio) * cmitem_unitprice / cmitem_price_invuomratio), 2), 0.0) FROM cmitem WHERE (cmitem_cmhead_id=cmhead_id) ) + (SELECT COALESCE(SUM(tax) * -1, 0) AS tax FROM ( SELECT ROUND(SUM(taxdetail_tax),2) AS tax FROM tax JOIN calculateTaxDetailSummary('CM', cmhead_id, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id) AS data) INTO _result FROM cmhead WHERE (cmhead_id=pCreditmemoId); IF (NOT FOUND) THEN return 0; ELSE RETURN _result; END IF; END; $_$; ALTER FUNCTION public.creditmemototal(integer) OWNER TO admin; -- -- Name: crmacct; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE crmacct ( crmacct_id integer NOT NULL, crmacct_number text NOT NULL, crmacct_name text, crmacct_active boolean DEFAULT true, crmacct_type character(1), crmacct_cust_id integer, crmacct_competitor_id integer, crmacct_partner_id integer, crmacct_prospect_id integer, crmacct_vend_id integer, crmacct_cntct_id_1 integer, crmacct_cntct_id_2 integer, crmacct_parent_id integer, crmacct_notes text, crmacct_taxauth_id integer, crmacct_owner_username text, crmacct_emp_id integer, crmacct_salesrep_id integer, crmacct_usr_username text, CONSTRAINT crmacct_crmacct_number_check CHECK ((crmacct_number <> ''::text)), CONSTRAINT crmacct_crmacct_type_check CHECK ((crmacct_type = ANY (ARRAY['I'::bpchar, 'O'::bpchar]))), CONSTRAINT crmacct_crmacct_usr_username_check CHECK ((btrim(crmacct_usr_username) <> ''::text)), CONSTRAINT crmacct_owner_username_check CHECK ((btrim(crmacct_owner_username) <> ''::text)) ); ALTER TABLE crmacct OWNER TO admin; -- -- Name: TABLE crmacct; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE crmacct IS 'CRM Accounts are umbrella records that tie together people and organizations with whom we have business relationships.'; -- -- Name: COLUMN crmacct.crmacct_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacct.crmacct_id IS 'Internal ID of this CRM Account.'; -- -- Name: COLUMN crmacct.crmacct_number; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacct.crmacct_number IS 'Abbreviated human-readable identifier for this CRM Account.'; -- -- Name: COLUMN crmacct.crmacct_name; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacct.crmacct_name IS 'Long name of this CRM Account.'; -- -- Name: COLUMN crmacct.crmacct_active; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacct.crmacct_active IS 'This CRM Account is available for new activity.'; -- -- Name: COLUMN crmacct.crmacct_type; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacct.crmacct_type IS 'This indicates whether the CRM Account represents an organization or an individual person.'; -- -- Name: COLUMN crmacct.crmacct_cust_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacct.crmacct_cust_id IS 'If this is not null, this CRM Account is a Customer.'; -- -- Name: COLUMN crmacct.crmacct_competitor_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacct.crmacct_competitor_id IS 'For now, > 0 indicates this CRM Account is a competitor. Eventually this may become a foreign key to a table of competitors.'; -- -- Name: COLUMN crmacct.crmacct_partner_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacct.crmacct_partner_id IS 'For now, > 0 indicates this CRM Account is a partner. Eventually this may become a foreign key to a table of partners.'; -- -- Name: COLUMN crmacct.crmacct_prospect_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacct.crmacct_prospect_id IS 'If this is not null, this CRM Account is a Prospect.'; -- -- Name: COLUMN crmacct.crmacct_vend_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacct.crmacct_vend_id IS 'If this is not null, this CRM Account is a Vendor.'; -- -- Name: COLUMN crmacct.crmacct_cntct_id_1; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacct.crmacct_cntct_id_1 IS 'The primary contact for the CRM Account.'; -- -- Name: COLUMN crmacct.crmacct_cntct_id_2; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacct.crmacct_cntct_id_2 IS 'The secondary contact for the CRM Account.'; -- -- Name: COLUMN crmacct.crmacct_parent_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacct.crmacct_parent_id IS 'The internal ID of an (optional) parent CRM Account. For example, if the current CRM Account is a subsidiary of another company, the crmacct_parent_id points to the CRM Account representing that parent company.'; -- -- Name: COLUMN crmacct.crmacct_notes; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacct.crmacct_notes IS 'Free-form comments pertaining to the CRM Account.'; -- -- Name: COLUMN crmacct.crmacct_taxauth_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacct.crmacct_taxauth_id IS 'If this is not null, this CRM Account is a Tax Authority.'; -- -- Name: COLUMN crmacct.crmacct_owner_username; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacct.crmacct_owner_username IS 'The application User responsible for this CRM Account.'; -- -- Name: COLUMN crmacct.crmacct_emp_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacct.crmacct_emp_id IS 'If this is not null, this CRM Account is an Employee.'; -- -- Name: COLUMN crmacct.crmacct_salesrep_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacct.crmacct_salesrep_id IS 'If this is not null, this CRM Account is a Sales Rep.'; -- -- Name: COLUMN crmacct.crmacct_usr_username; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacct.crmacct_usr_username IS 'If this is not null, this CRM Account is an application User.'; -- -- Name: crmacct(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION crmacct() RETURNS SETOF crmacct LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row crmacct%ROWTYPE; _priv TEXT; _grant BOOLEAN; BEGIN -- This query will give us the most permissive privilege the user has been granted SELECT privilege, granted INTO _priv, _grant FROM privgranted WHERE privilege IN ('MaintainAllCRMAccounts','ViewAllCRMAccounts','MaintainPersonalCRMAccounts','ViewPersonalCRMAccounts') ORDER BY granted DESC, sequence LIMIT 1; -- If have an 'All' privilege return all results IF (_priv ~ 'All' AND _grant) THEN FOR _row IN SELECT * FROM crmacct LOOP RETURN NEXT _row; END LOOP; -- Otherwise if have any other grant, must be personal privilege. ELSIF (_grant) THEN FOR _row IN SELECT * FROM crmacct WHERE crmacct_owner_username = getEffectiveXtUser() LOOP RETURN NEXT _row; END LOOP; END IF; RETURN; END; $$; ALTER FUNCTION public.crmacct() OWNER TO admin; -- -- Name: FUNCTION crmacct(); Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON FUNCTION crmacct() IS 'A table function that returns CRM Account results according to privilege settings.'; -- -- Name: crypt(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION crypt(text, text) RETURNS text LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_crypt'; ALTER FUNCTION public.crypt(text, text) OWNER TO admin; -- -- Name: currconcat(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION currconcat(integer) RETURNS character varying LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE id ALIAS FOR $1; returnVal VARCHAR(15) := ''; BEGIN SELECT currConcat(curr_abbr, curr_symbol) INTO returnVal FROM curr_symbol WHERE curr_id = id; RETURN returnVal; END; $_$; ALTER FUNCTION public.currconcat(integer) OWNER TO admin; -- -- Name: currconcat(character varying, character varying); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION currconcat(character varying, character varying) RETURNS character varying LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE curr_abbr ALIAS FOR $1; curr_symbol ALIAS FOR $2; returnVal VARCHAR(15) := ''; BEGIN IF length(trim(curr_abbr)) > 0 AND length(trim(curr_symbol)) > 0 THEN returnVal := trim(curr_abbr) || ' - ' || trim(curr_symbol); ELSIF length(trim(curr_abbr)) > 0 THEN returnVal := curr_abbr; ELSIF length(trim(curr_symbol)) > 0 THEN returnVal := curr_symbol; END IF; RETURN returnVal; END; $_$; ALTER FUNCTION public.currconcat(character varying, character varying) OWNER TO admin; -- -- Name: currentapmemonumber(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION currentapmemonumber() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _number INTEGER; BEGIN SELECT orderseq_number INTO _number FROM orderseq WHERE (orderseq_name='APMemoNumber'); IF (NOT FOUND) THEN _number := 0; END IF; RETURN _number; END; $$; ALTER FUNCTION public.currentapmemonumber() OWNER TO admin; -- -- Name: currentarmemonumber(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION currentarmemonumber() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _number INTEGER; BEGIN SELECT orderseq_number INTO _number FROM orderseq WHERE (orderseq_name='ARMemoNumber'); IF (NOT FOUND) THEN _number := 0; END IF; RETURN _number; END; $$; ALTER FUNCTION public.currentarmemonumber() OWNER TO admin; -- -- Name: currentcashrcptnumber(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION currentcashrcptnumber() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _number INTEGER; BEGIN SELECT orderseq_number INTO _number FROM orderseq WHERE (orderseq_name='CashRcptNumber'); IF (NOT FOUND) THEN _number := 0; END IF; RETURN _number; END; $$; ALTER FUNCTION public.currentcashrcptnumber() OWNER TO admin; -- -- Name: currentnumber(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION currentnumber(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pName ALIAS FOR $1; _number INTEGER; BEGIN SELECT orderseq_number INTO _number FROM orderseq WHERE (orderseq_name=pName); IF (NOT FOUND) THEN _number := 0; END IF; RETURN _number; END; $_$; ALTER FUNCTION public.currentnumber(text) OWNER TO admin; -- -- Name: currexchangecheckoverlap(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION currexchangecheckoverlap() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE numberOfOverlaps INTEGER NOT NULL := 0; curr_string VARCHAR(16); new_id INTEGER; BEGIN new_id := NEW.curr_id; -- ensure that effective date <= expiration date IF NEW.curr_effective > NEW.curr_expires THEN RAISE EXCEPTION 'Effective date % must be earlier than expiration date %', NEW.curr_effective, NEW.curr_expires; END IF; -- ensure new exchange rate does not overlap in time with any others SELECT count(*) INTO numberOfOverlaps FROM curr_rate WHERE curr_id = NEW.curr_id AND curr_rate_id != NEW.curr_rate_id AND ( (curr_effective BETWEEN NEW.curr_effective AND NEW.curr_expires OR curr_expires BETWEEN NEW.curr_effective AND NEW.curr_expires) OR (curr_effective <= NEW.curr_effective AND curr_expires >= NEW.curr_expires) ); IF numberOfOverlaps > 0 THEN SELECT currConcat(curr_symbol, curr_abbr) INTO curr_string FROM curr_symbol WHERE curr_id = new_id; RAISE EXCEPTION 'The date range % to % overlaps with another date range.', NEW.curr_effective, NEW.curr_expires; END IF; RETURN NEW; END; $$; ALTER FUNCTION public.currexchangecheckoverlap() OWNER TO admin; -- -- Name: currgain(integer, numeric, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION currgain(integer, numeric, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pId ALIAS FOR $1; pValue ALIAS FOR $2; pStart ALIAS FOR $3; pEnd ALIAS FOR $4; _start DATE; _end DATE; _gain NUMERIC; _multiplier INTEGER := 1; BEGIN IF (pEnd = pStart OR pValue = 0) THEN RETURN 0; END IF; IF (pStart > pEnd) THEN _start := pEnd; _end := pStart; _multiplier := -1; ELSE _start := pStart; _end := pEnd; END IF; _gain := currToBase(pId, pValue, _start) - currToBase(pId, pValue, _end); IF (_gain IS NULL) THEN RAISE EXCEPTION 'Missing exchange rate for curr_id % on % or %', pId, _start, _end; END IF; RETURN _gain * _multiplier; END; $_$; ALTER FUNCTION public.currgain(integer, numeric, date, date) OWNER TO admin; -- -- Name: curronebase(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION curronebase() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE baseCount INTEGER := 0; BEGIN IF NEW.curr_base = TRUE THEN SELECT count(*) INTO baseCount FROM curr_symbol WHERE curr_base = TRUE AND curr_id != NEW.curr_id; IF baseCount > 0 THEN RAISE EXCEPTION 'Cannot make % - % the base currency because one is already defined.', NEW.curr_symbol, NEW.curr_abbr; ELSE SELECT count(*) INTO baseCount FROM curr_rate WHERE curr_id = NEW.curr_id; IF baseCount = 0 THEN -- put a row in the curr_rate table to avoid special-case -- code for converting base currency to base currency INSERT INTO curr_rate (curr_id, curr_rate, curr_effective, curr_expires) VALUES (NEW.curr_id, 1, startOfTime(), endOfTime()); END IF; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public.curronebase() OWNER TO admin; -- -- Name: currrate(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION currrate(integer, date) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN currRate($1, NULL, $2); END; $_$; ALTER FUNCTION public.currrate(integer, date) OWNER TO admin; -- -- Name: currrate(integer, integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION currrate(pfromcurr integer, ptocurr integer, pdate date) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _fromRate NUMERIC := 1.0; _toRate NUMERIC := 1.0; _returnVal NUMERIC := 1.0; BEGIN IF pFromCurr = pToCurr THEN RETURN _returnVal; END IF; IF (pFromCurr IS NOT NULL) THEN SELECT curr_rate INTO _fromRate FROM curr_rate WHERE ( (curr_id=pFromCurr) AND (pDate BETWEEN curr_effective AND curr_expires) ); IF ( NOT FOUND) THEN RAISE EXCEPTION 'Currency exchange rate for currency % not found on %', pFromCurr, formatDate(pDate); END IF; END IF; IF (pToCurr IS NOT NULL) THEN SELECT curr_rate INTO _toRate FROM curr_rate WHERE ( (curr_id=pToCurr) AND (pDate BETWEEN curr_effective AND curr_expires) ); IF ( NOT FOUND) THEN RAISE EXCEPTION 'Currency exchange rate for currency % not found on %', pToCurr, formatDate(pDate); END IF; END IF; _returnVal := _fromRate / _toRate; RETURN _returnVal; END; $$; ALTER FUNCTION public.currrate(pfromcurr integer, ptocurr integer, pdate date) OWNER TO admin; -- -- Name: currtobase(integer, numeric, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION currtobase(integer, numeric, date) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pId ALIAS FOR $1; pValue ALIAS FOR $2; _date DATE; _output NUMERIC; BEGIN _date := $3; IF _date IS NULL THEN _date := 'now'; END IF; IF pValue = 0 OR pValue IS NULL THEN _output := 0; ELSIF (baseCurrId() = pId) THEN _output := pValue; ELSE SELECT pValue / curr_rate INTO _output FROM curr_rate WHERE curr_id = pId AND _date BETWEEN curr_effective AND curr_expires; IF (_output IS NULL OR NOT FOUND) THEN RAISE EXCEPTION 'No exchange rate for % on %', pId, _date; END IF; END IF; RETURN _output; END; $_$; ALTER FUNCTION public.currtobase(integer, numeric, date) OWNER TO admin; -- -- Name: currtocurr(integer, integer, numeric, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION currtocurr(integer, integer, numeric, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFromCurr ALIAS FOR $1; pToCurr ALIAS FOR $2; pValue ALIAS FOR $3; pEffective ALIAS FOR $4; _convertedValue NUMERIC; _fromRate NUMERIC; _toRate NUMERIC; BEGIN IF pFromCurr = pToCurr THEN RETURN pValue; END IF; IF pValue = 0 OR pValue IS NULL THEN RETURN 0; END IF; SELECT curr_rate INTO _fromRate FROM curr_rate WHERE curr_id = pFromCurr AND pEffective BETWEEN curr_effective AND curr_expires; IF (NOT FOUND) THEN RAISE EXCEPTION 'No exchange rate for % on %', pFromCurr, pEffective; END IF; SELECT curr_rate INTO _toRate FROM curr_rate WHERE curr_id = pToCurr AND pEffective BETWEEN curr_effective AND curr_expires; IF (NOT FOUND) THEN RAISE EXCEPTION 'No exchange rate for % on %', pToCurr, pEffective; END IF; _convertedValue := pValue * _toRate / _fromRate; RETURN _convertedValue; END; $_$; ALTER FUNCTION public.currtocurr(integer, integer, numeric, date) OWNER TO admin; -- -- Name: currtolocal(integer, numeric, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION currtolocal(integer, numeric, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pId ALIAS FOR $1; pValue ALIAS FOR $2; _date DATE; _output NUMERIC; BEGIN _date := $3; IF _date IS NULL THEN _date := 'now'; END IF; IF pValue = 0 OR pValue IS NULL THEN _output := 0; ELSIF (baseCurrId() = pId) THEN _output := pValue; ELSE SELECT pValue * curr_rate INTO _output FROM curr_rate WHERE curr_id = pId AND _date BETWEEN curr_effective AND curr_expires; IF (_output IS NULL OR NOT FOUND) THEN RAISE EXCEPTION 'No exchange rate for % on %', pId, _date; END IF; END IF; RETURN _output; END; $_$; ALTER FUNCTION public.currtolocal(integer, numeric, date) OWNER TO admin; -- -- Name: custitem(integer, integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION custitem(cust_id integer, shipto_id integer DEFAULT (-1), asof date DEFAULT ('now'::text)::date) RETURNS SETOF integer LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- Non Exclusive SELECT item_id FROM item WHERE (NOT item_exclusive) AND (item_sold) UNION -- Exclusive, Shipto match SELECT item_id FROM item JOIN ipsiteminfo ON (ipsitem_item_id=item_id) JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE (item_exclusive) AND (item_sold) AND ($2 != -1) AND (ipsass_shipto_id=$2) AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1)) UNION SELECT item_id FROM item JOIN ipsiteminfo ON (ipsitem_prodcat_id=item_prodcat_id) JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE (item_exclusive) AND (item_sold) AND ($2 != -1) AND (ipsass_shipto_id=$2) AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1)) UNION -- Exclusive, Shipto pattern match SELECT item_id FROM item JOIN ipsiteminfo ON (ipsitem_item_id=item_id) JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) JOIN shiptoinfo ON (shipto_num ~ ipsass_shipto_pattern) WHERE (item_exclusive) AND (item_sold) AND (COALESCE(length(ipsass_shipto_pattern), 0) > 0) AND (ipsass_cust_id=$1) AND ($2 != -1) AND (shipto_id=$2) AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1)) UNION SELECT item_id FROM item JOIN ipsiteminfo ON (ipsitem_prodcat_id=item_prodcat_id) JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) JOIN shiptoinfo ON (shipto_num ~ ipsass_shipto_pattern) WHERE (item_exclusive) AND (item_sold) AND (COALESCE(length(ipsass_shipto_pattern), 0) > 0) AND (ipsass_cust_id=$1) AND ($2 != -1) AND (shipto_id=$2) AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1)) UNION -- Exclusive, Customer match SELECT item_id FROM item JOIN ipsiteminfo ON (ipsitem_item_id=item_id) JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE (item_exclusive) AND (item_sold) AND (ipsass_cust_id=$1) AND (ipsass_shipto_id=-1) AND (ipsass_shipto_pattern='') AND (ipsass_custtype_id=-1) AND (ipsass_custtype_pattern='') AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1)) UNION SELECT item_id FROM item JOIN ipsiteminfo ON (ipsitem_prodcat_id=item_prodcat_id) JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE (item_exclusive) AND (item_sold) AND (ipsass_cust_id=$1) AND (ipsass_shipto_id=-1) AND (ipsass_shipto_pattern='') AND (ipsass_custtype_id=-1) AND (ipsass_custtype_pattern='') AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1)) UNION -- Exclusive, Customer Type match SELECT item_id FROM item JOIN ipsiteminfo ON (ipsitem_item_id=item_id) JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) JOIN custinfo ON (ipsass_custtype_id=cust_custtype_id) WHERE (item_exclusive) AND (item_sold) AND (cust_id=$1) AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1)) UNION SELECT item_id FROM item JOIN ipsiteminfo ON (ipsitem_prodcat_id=item_prodcat_id) JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) JOIN custinfo ON (ipsass_custtype_id=cust_custtype_id) WHERE (item_exclusive) AND (item_sold) AND (cust_id=$1) AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1)) UNION -- Exclusive, Customer Type pattern match SELECT item_id FROM item JOIN ipsiteminfo ON (ipsitem_item_id=item_id) JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) JOIN custtype ON (custtype_code ~ ipsass_custtype_pattern) JOIN custinfo ON (cust_custtype_id=custtype_id) WHERE (item_exclusive) AND (item_sold) AND (COALESCE(length(ipsass_custtype_pattern), 0) > 0) AND (cust_id=$1) AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1)) UNION SELECT item_id FROM item JOIN ipsiteminfo ON (ipsitem_prodcat_id=item_prodcat_id) JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) JOIN custtype ON (custtype_code ~ ipsass_custtype_pattern) JOIN custinfo ON (cust_custtype_id=custtype_id) WHERE (item_exclusive) AND (item_sold) AND (COALESCE(length(ipsass_custtype_pattern), 0) > 0) AND (cust_id=$1) AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1)) $_$; ALTER FUNCTION public.custitem(cust_id integer, shipto_id integer, asof date) OWNER TO admin; -- -- Name: customercanpurchase(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION customercanpurchase(integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pitemid ALIAS FOR $1; pCustid ALIAS FOR $2; BEGIN RETURN customerCanPurchase(pitemid, pCustid, -1); END; $_$; ALTER FUNCTION public.customercanpurchase(integer, integer) OWNER TO admin; -- -- Name: customercanpurchase(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION customercanpurchase(integer, integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pitemid ALIAS FOR $1; pCustid ALIAS FOR $2; pShiptoid AlIAS FOR $3; _id INTEGER; _item RECORD; BEGIN RETURN customerCanPurchase(pitemid, pCustid, pShiptoid, CURRENT_DATE); END; $_$; ALTER FUNCTION public.customercanpurchase(integer, integer, integer) OWNER TO admin; -- -- Name: customercanpurchase(integer, integer, integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION customercanpurchase(integer, integer, integer, date) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pitemid ALIAS FOR $1; pCustid ALIAS FOR $2; pShiptoid AlIAS FOR $3; pAsOf ALIAS FOR $4; _id INTEGER; _item RECORD; BEGIN SELECT item_sold, item_exclusive INTO _item FROM item WHERE(item_id=pItemid); -- Make sure that this is at least a sold Item IF (NOT _item.item_sold) THEN RETURN FALSE; END IF; -- Everyone can purchase a non-exclusive item IF (NOT _item.item_exclusive) THEN RETURN TRUE; END IF; IF(pShiptoid != -1) THEN -- Check for a shipto Assigned Price SELECT ipsitem_id INTO _id FROM ipsiteminfo, ipshead, ipsass WHERE((ipsitem_ipshead_id=ipshead_id) AND (ipsass_ipshead_id=ipshead_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsitem_item_id=pItemid) AND (ipsass_shipto_id != -1) AND (ipsass_shipto_id=pShiptoid)) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; SELECT ipsitem_id INTO _id FROM ipsiteminfo, item, ipshead, ipsass WHERE((ipsitem_ipshead_id=ipshead_id) AND (ipsitem_prodcat_id = item_prodcat_id) AND (ipsass_ipshead_id=ipshead_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (item_id=pItemid) AND (ipsass_shipto_id != -1) AND (ipsass_shipto_id=pShiptoid)) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; -- Check for a Shipto Pattern Assigned Price SELECT ipsitem_id INTO _id FROM ipsiteminfo, ipshead, ipsass, shiptoinfo WHERE((ipsitem_ipshead_id=ipshead_id) AND (ipsass_ipshead_id=ipshead_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (COALESCE(length(ipsass_shipto_pattern), 0) > 0) AND (shipto_num ~ ipsass_shipto_pattern) AND (ipsass_cust_id=pCustid) AND (ipsitem_item_id=pItemid) AND (shipto_id=pShiptoid)) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; SELECT ipsitem_id INTO _id FROM ipsiteminfo, item, ipshead, ipsass, shiptoinfo WHERE((ipsitem_ipshead_id=ipshead_id) AND (ipsitem_prodcat_id = item_prodcat_id) AND (ipsass_ipshead_id=ipshead_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (COALESCE(length(ipsass_shipto_pattern), 0) > 0) AND (shipto_num ~ ipsass_shipto_pattern) AND (ipsass_cust_id=pCustid) AND (item_id=pItemid) AND (shipto_id=pShiptoid)) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; END IF; -- Check for a Customer Assigned Price SELECT ipsitem_id INTO _id FROM ipsiteminfo, ipshead, ipsass WHERE((ipsitem_ipshead_id=ipshead_id) AND (ipsass_ipshead_id=ipshead_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsitem_item_id=pItemid) AND (COALESCE(length(ipsass_shipto_pattern), 0) = 0) AND (ipsass_cust_id=pCustid)) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; SELECT ipsitem_id INTO _id FROM ipsiteminfo, item, ipshead, ipsass WHERE((ipsitem_ipshead_id=ipshead_id) AND (ipsitem_prodcat_id = item_prodcat_id) AND (ipsass_ipshead_id=ipshead_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (item_id=pItemid) AND (COALESCE(length(ipsass_shipto_pattern), 0) = 0) AND (ipsass_cust_id=pCustid)) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; -- Check for a Customer Type Assigned Price SELECT ipsitem_id INTO _id FROM ipsiteminfo, ipshead, ipsass, custinfo WHERE( (ipsitem_ipshead_id=ipshead_id) AND (ipsass_ipshead_id=ipshead_id) AND (ipsass_custtype_id != -1) AND (cust_custtype_id = ipsass_custtype_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsitem_item_id=pItemid) AND (cust_id=pCustid)) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; SELECT ipsitem_id INTO _id FROM ipsiteminfo, item, ipshead, ipsass, custinfo WHERE( (ipsitem_ipshead_id=ipshead_id) AND (ipsitem_prodcat_id = item_prodcat_id) AND (ipsass_ipshead_id=ipshead_id) AND (ipsass_custtype_id != -1) AND (cust_custtype_id = ipsass_custtype_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (item_id=pItemid) AND (cust_id=pCustid)) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; -- Check for a Customer Type Pattern Assigned Price SELECT ipsitem_id INTO _id FROM ipsiteminfo, ipshead, ipsass, custtype, custinfo WHERE((ipsitem_ipshead_id=ipshead_id) AND (ipsass_ipshead_id=ipshead_id) AND (coalesce(length(ipsass_custtype_pattern), 0) > 0) AND (custtype_code ~ ipsass_custtype_pattern) AND (cust_custtype_id=custtype_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsitem_item_id=pItemid) AND (cust_id=pCustid)) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; SELECT ipsitem_id INTO _id FROM ipsiteminfo, item, ipshead, ipsass, custtype, custinfo WHERE((ipsitem_ipshead_id=ipshead_id) AND (ipsitem_prodcat_id = item_prodcat_id) AND (ipsass_ipshead_id=ipshead_id) AND (coalesce(length(ipsass_custtype_pattern), 0) > 0) AND (custtype_code ~ ipsass_custtype_pattern) AND (cust_custtype_id=custtype_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (item_id=pItemid) AND (cust_id=pCustid)) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; -- That's it, Sales don't count - yet RETURN FALSE; END; $_$; ALTER FUNCTION public.customercanpurchase(integer, integer, integer, date) OWNER TO admin; -- -- Name: dearmor(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION dearmor(text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_dearmor'; ALTER FUNCTION public.dearmor(text) OWNER TO admin; -- -- Name: decrypt(bytea, bytea, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION decrypt(bytea, bytea, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_decrypt'; ALTER FUNCTION public.decrypt(bytea, bytea, text) OWNER TO admin; -- -- Name: decrypt_iv(bytea, bytea, bytea, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION decrypt_iv(bytea, bytea, bytea, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_decrypt_iv'; ALTER FUNCTION public.decrypt_iv(bytea, bytea, bytea, text) OWNER TO admin; -- -- Name: defaultlocationname(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION defaultlocationname(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; _p RECORD; BEGIN SELECT itemsite_location_id, itemsite_location INTO _p FROM itemsite WHERE (itemsite_id=pItemsiteid); IF (NOT FOUND) THEN RETURN 'Error'; ELSIF (_p.itemsite_location_id = -1) THEN RETURN _p.itemsite_location; ELSE RETURN formatLocationName(_p.itemsite_location_id); END IF; END; $_$; ALTER FUNCTION public.defaultlocationname(integer) OWNER TO admin; -- -- Name: deleteaccount(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteaccount(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAccntid ALIAS FOR $1; _check INTEGER; BEGIN -- Check to see if the passed accnt is used in a Cost Category SELECT costcat_id INTO _check FROM costcat WHERE ( (costcat_asset_accnt_id=pAccntid) OR (costcat_liability_accnt_id=pAccntid) OR (costcat_adjustment_accnt_id=pAccntid) OR (costcat_matusage_accnt_id=pAccntid) OR (costcat_purchprice_accnt_id=pAccntid) OR (costcat_scrap_accnt_id=pAccntid) OR (costcat_invcost_accnt_id=pAccntid) OR (costcat_wip_accnt_id=pAccntid) OR (costcat_shipasset_accnt_id=pAccntid) OR (costcat_mfgscrap_accnt_id=pAccntid) OR (costcat_transform_accnt_id=pAccntid) OR (costcat_freight_accnt_id=pAccntid) OR (costcat_exp_accnt_id=pAccntid) ) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; IF (fetchMetricText('Application') = 'Standard') THEN SELECT costcat_id INTO _check FROM costcat WHERE ( (costcat_toliability_accnt_id=pAccntid) OR (costcat_laboroverhead_accnt_id=pAccntid) ) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; END IF; -- Check to see if the passed accnt is used in a Sales Account Assignment SELECT salesaccnt_id INTO _check FROM salesaccnt WHERE ( (salesaccnt_sales_accnt_id=pAccntid) OR (salesaccnt_credit_accnt_id=pAccntid) OR (salesaccnt_cos_accnt_id=pAccntid) ) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; IF (fetchMetricText('Application') = 'Standard') THEN SELECT salesaccnt_id INTO _check FROM salesaccnt WHERE ( (salesaccnt_returns_accnt_id=pAccntid) OR (salesaccnt_cor_accnt_id=pAccntid) OR (salesaccnt_cow_accnt_id=pAccntid) ) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; END IF; -- Check to see if the passed accnt is used in a Sales Category SELECT salescat_id INTO _check FROM salescat WHERE ( (salescat_sales_accnt_id=pAccntid) OR (salescat_prepaid_accnt_id=pAccntid) OR (salescat_ar_accnt_id=pAccntid) ) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; -- Check to see if the passed accnt is used in a A/R Account Assignment SELECT araccnt_id INTO _check FROM araccnt WHERE ( (araccnt_freight_accnt_id=pAccntid) OR (araccnt_ar_accnt_id=pAccntid) OR (araccnt_prepaid_accnt_id=pAccntid) OR (araccnt_deferred_accnt_id=pAccntid) OR (araccnt_discount_accnt_id=pAccntid) ) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; -- Check to see if the passed accnt is used in a Warehouse IF EXISTS (SELECT 1 FROM whsinfo WHERE (warehous_default_accnt_id=pAccntid)) THEN RETURN -4; END IF; -- Check to see if the passed accnt is used in a Bank Account SELECT bankaccnt_id INTO _check FROM bankaccnt WHERE (bankaccnt_accnt_id=pAccntid) LIMIT 1; IF (FOUND) THEN RETURN -5; END IF; SELECT bankadjtype_id INTO _check FROM bankadjtype WHERE (bankadjtype_accnt_id=pAccntid) LIMIT 1; IF (FOUND) THEN RETURN -5; END IF; -- Check to see if the passed accnt is used in an Expense Category SELECT expcat_id INTO _check FROM expcat WHERE ( (expcat_exp_accnt_id=pAccntid) OR (expcat_liability_accnt_id=pAccntid) OR (expcat_purchprice_accnt_id=pAccntid) OR (expcat_freight_accnt_id=pAccntid) ) LIMIT 1; IF (FOUND) THEN RETURN -6; END IF; -- Check to see if the passed accnt is used in a Tax Code SELECT tax_id INTO _check FROM tax WHERE ( (tax_sales_accnt_id=pAccntid) OR (tax_dist_accnt_id=pAccntid) ) LIMIT 1; IF (FOUND) THEN RETURN -7; END IF; -- Check to see if the passed accnt is used in a Standard Journal Item SELECT stdjrnlitem_id INTO _check FROM stdjrnlitem WHERE (stdjrnlitem_accnt_id=pAccntid) LIMIT 1; IF (FOUND) THEN RETURN -8; END IF; -- Check to see if the passed accnt is used in a A/P Account Assignment SELECT apaccnt_ap_accnt_id INTO _check FROM apaccnt WHERE ( (apaccnt_ap_accnt_id=pAccntid) OR (apaccnt_prepaid_accnt_id=pAccntid) OR (apaccnt_discount_accnt_id=pAccntid) ) LIMIT 1; IF (FOUND) THEN RETURN -9; END IF; -- Check to see if the passed accnt is used in an A/R Open Item record SELECT aropen_accnt_id INTO _check FROM aropen WHERE (aropen_accnt_id=pAccntid) LIMIT 1; IF (FOUND) THEN RETURN -11; END IF; -- Check to see if the passed accnt has been used in the G/L SELECT gltrans_accnt_id INTO _check FROM gltrans WHERE (gltrans_accnt_id=pAccntid) LIMIT 1; IF (FOUND) THEN RETURN -99; END IF; SELECT glseries_accnt_id INTO _check FROM glseries WHERE (glseries_accnt_id=pAccntid) LIMIT 1; IF (FOUND) THEN RETURN -99; END IF; SELECT trialbal_accnt_id INTO _check FROM trialbal WHERE (trialbal_accnt_id=pAccntid) AND (trialbal_beginning != 0 OR trialbal_ending != 0) LIMIT 1; IF (FOUND) THEN RETURN -99; END IF; SELECT cashrcptmisc_accnt_id INTO _check FROM cashrcptmisc WHERE (cashrcptmisc_accnt_id=pAccntid) LIMIT 1; IF (FOUND) THEN RETURN -99; END IF; -- Delete any non-critical use DELETE FROM flitem WHERE (flitem_accnt_id=pAccntid); -- only possible because of trialbal error-check above DELETE FROM trialbal WHERE (trialbal_accnt_id=pAccntid) AND (trialbal_beginning=0) AND (trialbal_ending=0); -- Delete the Account DELETE FROM accnt WHERE (accnt_id=pAccntid); RETURN 0; END; $_$; ALTER FUNCTION public.deleteaccount(integer) OWNER TO admin; -- -- Name: deleteaccountingperiod(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteaccountingperiod(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodid ALIAS FOR $1; _check RECORD; BEGIN -- Check to make sure that the passed period is not closed IF ( ( SELECT period_closed FROM period WHERE (period_id=pPeriodid) ) ) THEN RETURN -1; END IF; -- Check to make sure that there are not any posted G/L Transactions -- in the period. SELECT gltrans_id INTO _check FROM gltrans, period WHERE ( (gltrans_date BETWEEN period_start AND period_end) AND (gltrans_posted) AND (period_id=pPeriodid) ) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; SELECT b.period_id INTO _check FROM period AS a, period AS b WHERE((a.period_id=pPeriodid) AND (a.period_end < b.period_start)) LIMIT 1; IF (FOUND) THEN RETURN -5; END IF; -- Delete the period DELETE FROM period WHERE (period_id=pPeriodid); -- Also Delete the period from TrialBalance DELETE FROM trialbal WHERE (trialbal_period_id=pPeriodid); RETURN 1; END; $_$; ALTER FUNCTION public.deleteaccountingperiod(integer) OWNER TO admin; -- -- Name: deleteaccountingyearperiod(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteaccountingyearperiod(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodid ALIAS FOR $1; _check RECORD; BEGIN -- Check to make sure that the passed yearperiod is not closed IF ( ( SELECT yearperiod_closed FROM yearperiod WHERE (yearperiod_id=pPeriodid) ) ) THEN RETURN -1; END IF; -- this yearperiod is in use by existing periods IF (EXISTS(SELECT period_id FROM period WHERE (period_yearperiod_id=pPeriodid))) THEN RETURN -2; END IF; -- Delete the yearperiod DELETE FROM yearperiod WHERE (yearperiod_id=pPeriodid); RETURN 1; END; $_$; ALTER FUNCTION public.deleteaccountingyearperiod(integer) OWNER TO admin; -- -- Name: deleteaddress(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteaddress(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE paddrId ALIAS FOR $1; _count INTEGER := 0; BEGIN SELECT count(*) INTO _count FROM cntct WHERE (cntct_active AND (cntct_addr_id = paddrId)); IF (_count > 0) THEN RETURN -1; END IF; SELECT count(*) INTO _count FROM vendinfo WHERE (vend_active AND (vend_addr_id = paddrId)); IF (_count > 0) THEN RETURN -2; END IF; SELECT count(*) INTO _count FROM shiptoinfo WHERE (shipto_active AND (shipto_addr_id = paddrId)); IF (_count > 0) THEN RETURN -3; END IF; SELECT count(*) INTO _count FROM vendaddrinfo WHERE (vendaddr_addr_id = paddrId); IF (_count > 0) THEN RETURN -4; END IF; SELECT count(*) INTO _count FROM whsinfo WHERE (warehous_active AND (warehous_addr_id = paddrId)); IF (_count > 0) THEN RETURN -5; END IF; UPDATE cntct SET cntct_addr_id = NULL WHERE (cntct_addr_id = paddrId); UPDATE vendinfo SET vend_addr_id = NULL WHERE (vend_addr_id = paddrId); UPDATE shiptoinfo SET shipto_addr_id = NULL WHERE (shipto_addr_id =paddrId); UPDATE vendaddrinfo SET vendaddr_addr_id = NULL WHERE (vendaddr_addr_id = paddrId); UPDATE whsinfo SET warehous_addr_id = NULL WHERE (warehous_addr_id=paddrId); DELETE FROM addr WHERE addr_id = paddrId; RETURN 0; END; $_$; ALTER FUNCTION public.deleteaddress(integer) OWNER TO admin; -- -- Name: deleteapcheck(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteapcheck(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'deleteAPCheck() is deprecated - use deleteCheck() instead'; RETURN deleteCheck($1); END; $_$; ALTER FUNCTION public.deleteapcheck(integer) OWNER TO admin; -- -- Name: deletebankadjustmenttype(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletebankadjustmenttype(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBankadjtypeid ALIAS FOR $1; _check INTEGER; BEGIN -- Check to see if the the adjustment type is being used in any adjustments SELECT bankadj_bankadjtype_id INTO _check FROM bankadj WHERE (bankadj_bankadjtype_id=pBankadjtypeid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; -- Delete the Account DELETE FROM bankadjtype WHERE (bankadjtype_id=pbankadjtypeid); RETURN 0; END; $_$; ALTER FUNCTION public.deletebankadjustmenttype(integer) OWNER TO admin; -- -- Name: deletebankreconciliation(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletebankreconciliation(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pbankrecid ALIAS FOR $1; BEGIN DELETE FROM bankrecitem WHERE bankrecitem_bankrec_id=pbankrecid; DELETE FROM bankrec WHERE bankrec_id=pbankrecid; RETURN 0; END; $_$; ALTER FUNCTION public.deletebankreconciliation(integer) OWNER TO admin; -- -- Name: deletebom(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletebom(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; _result INTEGER; BEGIN IF (fetchmetricbool('RevControl')) THEN SELECT rev_id INTO _result FROM rev WHERE ((rev_target_id=pItemid) AND (rev_target_type = 'BOM')) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Bill of Materials has revision control records and may not be deleted.'; END IF; END IF; DELETE FROM bomhead WHERE (bomhead_item_id=pItemid); DELETE FROM bomitem WHERE (bomitem_parent_item_id=pItemid); RETURN 0; END; $_$; ALTER FUNCTION public.deletebom(integer) OWNER TO admin; -- -- Name: deletebomworkset(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletebomworkset(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWorksetid ALIAS FOR $1; BEGIN -- All done with the bomwork set indicated by pWorksetid, delete all of it DELETE FROM bomwork WHERE (bomwork_set_id=pWorksetid); RETURN 1; END; $_$; ALTER FUNCTION public.deletebomworkset(integer) OWNER TO admin; -- -- Name: deletebudget(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletebudget(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBudgheadid ALIAS FOR $1; BEGIN DELETE FROM budgitem WHERE (budgitem_budghead_id=pBudgheadid); DELETE FROM budghead WHERE (budghead_id=pBudgheadid); RETURN pBudgheadid; END; $_$; ALTER FUNCTION public.deletebudget(integer) OWNER TO admin; -- -- Name: deletebudgetitems(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletebudgetitems(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBudgheadid ALIAS FOR $1; BEGIN DELETE FROM budgitem WHERE (budgitem_budghead_id=pBudgheadid); RETURN pBudgheadid; END; $_$; ALTER FUNCTION public.deletebudgetitems(integer) OWNER TO admin; -- -- Name: deletecashrcpt(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletecashrcpt(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pcashrcptid ALIAS FOR $1; _ccreceipt BOOLEAN; BEGIN IF EXISTS(SELECT cashrcpt_id FROM cashrcpt JOIN ccpay ON (cashrcpt_cust_id=ccpay_cust_id) AND ((CASE WHEN TRIM(COALESCE(cashrcpt_docnumber, ''))='' THEN TEXT(cashrcpt_id) ELSE cashrcpt_docnumber END)=ccpay_order_number) WHERE ((cashrcpt_fundstype IN ('A', 'D', 'M', 'V')) AND (ccpay_status NOT IN ('D', 'X')) AND (ccpay_id NOT IN (SELECT payco_ccpay_id FROM payco)) AND (cashrcpt_id=pcashrcptid))) THEN RETURN -1; END IF; IF EXISTS(SELECT cashrcpt_id FROM cashrcpt WHERE ( (cashrcpt_id=pcashrcptid) AND (cashrcpt_posted) )) THEN RETURN -2; END IF; -- If there are applications for this Cash Receipt then -- it has been posted and reversed. Void instead of delete. IF EXISTS(SELECT cashrcpt_id FROM cashrcpt JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id) JOIN arapply ON ((arapply_reftype='CRA') AND (arapply_ref_id=cashrcptitem_id)) WHERE (cashrcpt_id=pcashrcptid)) OR EXISTS(SELECT cashrcpt_id FROM cashrcpt JOIN cashrcptmisc ON (cashrcptmisc_cashrcpt_id=cashrcpt_id) JOIN arapply ON ((arapply_reftype='CRD') AND (arapply_ref_id=cashrcptmisc_id)) WHERE (cashrcpt_id=pcashrcptid)) THEN UPDATE cashrcpt SET cashrcpt_void = TRUE WHERE (cashrcpt_id=pcashrcptid); RETURN 1; END IF; DELETE FROM cashrcptitem WHERE (cashrcptitem_cashrcpt_id=pcashrcptid); DELETE FROM cashrcptmisc WHERE (cashrcptmisc_cashrcpt_id=pcashrcptid); DELETE FROM cashrcpt WHERE (cashrcpt_id=pcashrcptid); RETURN 1; END; $_$; ALTER FUNCTION public.deletecashrcpt(integer) OWNER TO admin; -- -- Name: deletecharacteristic(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletecharacteristic(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCharid ALIAS FOR $1; _uses TEXT; BEGIN IF NOT EXISTS(SELECT 1 FROM char WHERE char_id = pCharid) THEN RETURN 0; END IF; SELECT string_agg(DISTINCT(charass_target_type), ':') INTO _uses FROM charass WHERE charass_char_id = pCharid; IF _uses IS NOT NULL THEN RAISE EXCEPTION 'This characteristic cannot be deleted because it is in use [xtuple: deleteCharacteristic, -99, %]', _uses; END IF; DELETE FROM "char" WHERE (char_id=pCharid); RETURN pCharid; END; $_$; ALTER FUNCTION public.deletecharacteristic(integer) OWNER TO admin; -- -- Name: deletecheck(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletecheck(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCheckid ALIAS FOR $1; BEGIN IF (SELECT (NOT checkhead_void) OR checkhead_posted OR checkhead_replaced OR checkhead_deleted OR (checkhead_ach_batch IS NOT NULL AND checkhead_printed) FROM checkhead WHERE (checkhead_id=pCheckid) ) THEN RETURN -1; END IF; UPDATE checkhead SET checkhead_deleted=TRUE WHERE (checkhead_id=pCheckid); RETURN 1; END; $_$; ALTER FUNCTION public.deletecheck(integer) OWNER TO admin; -- -- Name: deleteclasscode(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteclasscode(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pClasscodeid ALIAS FOR $1; _check INTEGER; BEGIN -- Check to see if any items are assigned to the passed classcode SELECT item_id INTO _check FROM item WHERE (item_classcode_id=pClasscodeid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; -- Delete the passed classcode DELETE FROM classcode WHERE (classcode_id=pClasscodeid); RETURN pClasscodeid; END; $_$; ALTER FUNCTION public.deleteclasscode(integer) OWNER TO admin; -- -- Name: deletecompany(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletecompany(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pcompanyid ALIAS FOR $1; BEGIN IF (EXISTS(SELECT accnt_id FROM accnt, company WHERE ((accnt_company=company_number) AND (company_id=pcompanyid)) )) THEN RETURN -1; END IF; DELETE FROM company WHERE (company_id=pcompanyid); RETURN pcompanyid; END; $_$; ALTER FUNCTION public.deletecompany(integer) OWNER TO admin; -- -- Name: deletecreditmemo(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletecreditmemo(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmheadid ALIAS FOR $1; BEGIN DELETE FROM cmitem WHERE (cmitem_cmhead_id=pCmheadid); DELETE FROM cmhead WHERE (cmhead_id=pCmheadid); RETURN TRUE; END; $_$; ALTER FUNCTION public.deletecreditmemo(integer) OWNER TO admin; -- -- Name: deletecustomer(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletecustomer(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; BEGIN PERFORM shipto_id FROM shiptoinfo WHERE (shipto_cust_id=pCustid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; PERFORM cohead_id FROM cohead WHERE (cohead_cust_id=pCustid) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; PERFORM cmhead_id FROM cmhead WHERE (cmhead_cust_id=pCustid) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; PERFORM cohist_id FROM cohist WHERE (cohist_cust_id=pCustid) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; PERFORM aropen_id FROM aropen WHERE (aropen_cust_id=pCustid) LIMIT 1; IF (FOUND) THEN RETURN -5; END IF; PERFORM checkhead_recip_id FROM checkhead WHERE ((checkhead_recip_id=pCustid) AND (checkhead_recip_type='C')) LIMIT 1; IF (FOUND) THEN RETURN -6; END IF; PERFORM invchead_id FROM invchead WHERE(invchead_cust_id=pCustid) LIMIT 1; IF (FOUND) THEN RETURN -7; END IF; PERFORM quhead_id FROM quhead WHERE(quhead_cust_id=pCustid) LIMIT 1; IF (FOUND) THEN RETURN -8; END IF; DELETE FROM taxreg WHERE ((taxreg_rel_type='C') AND (taxreg_rel_id=pCustid)); DELETE FROM ipsass WHERE (ipsass_cust_id=pCustid); DELETE FROM custinfo WHERE (cust_id=pCustid); UPDATE crmacct SET crmacct_cust_id = NULL WHERE (crmacct_cust_id=pCustid); RETURN 0; END; $_$; ALTER FUNCTION public.deletecustomer(integer) OWNER TO admin; -- -- Name: deletecustomertype(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletecustomertype(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCusttypeid ALIAS FOR $1; BEGIN IF EXISTS(SELECT 1 FROM custinfo WHERE (cust_custtype_id=pCusttypeid)) THEN RETURN -1; END IF; DELETE FROM ipsass WHERE (ipsass_custtype_id=pCusttypeid); DELETE FROM salesaccnt WHERE (salesaccnt_custtype_id=pCusttypeid); DELETE FROM araccnt WHERE (araccnt_custtype_id=pCusttypeid); DELETE FROM custform WHERE (custform_custtype_id=pCusttypeid); DELETE FROM custtype WHERE (custtype_id=pCusttypeid); RETURN pCusttypeid; END; $_$; ALTER FUNCTION public.deletecustomertype(integer) OWNER TO admin; -- -- Name: deleteempgrp(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteempgrp(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pempgrpid ALIAS FOR $1; BEGIN -- Check to see if any employees are assigned to the passed empgrp PERFORM empgrpitem_emp_id FROM empgrpitem WHERE (empgrpitem_empgrp_id=pempgrpid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; DELETE FROM empgrp WHERE (empgrp_id=pempgrpid); RETURN 0; END; $_$; ALTER FUNCTION public.deleteempgrp(integer) OWNER TO admin; -- -- Name: deleteexpiredips(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteexpiredips() RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; BEGIN FOR _r IN SELECT ipshead_id FROM ipshead WHERE (ipshead_expires <= current_date) LOOP DELETE FROM ipsass WHERE (ipsass_ipshead_id=_r.ipshead_id); DELETE FROM ipsiteminfo WHERE (ipsitem_ipshead_id=_r.ipshead_id); DELETE FROM ipsfreight WHERE (ipsfreight_ipshead_id=_r.ipshead_id); DELETE FROM ipshead WHERE (ipshead_id=_r.ipshead_id); END LOOP; RETURN TRUE; END; $$; ALTER FUNCTION public.deleteexpiredips() OWNER TO admin; -- -- Name: deletefile(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletefile(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ declare pId ALIAS FOR $1; begin delete from file where ( file_id in ( select file_id from file join docass on (docass_target_id=file_id) and (docass_target_type='FILE') where ( docass_id = pId ) ) ); delete from docass where docass_id = pId; return true; end; $_$; ALTER FUNCTION public.deletefile(integer) OWNER TO admin; -- -- Name: deleteflgrp(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteflgrp(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlgrpid ALIAS FOR $1; _r RECORD; BEGIN FOR _r IN SELECT flgrp_id FROM flgrp WHERE (flgrp_flgrp_id=pFlgrpid) LOOP PERFORM deleteFlgrp(_r.flgrp_id); END LOOP; DELETE FROM flitem WHERE (flitem_flgrp_id=pFlgrpid); DELETE FROM flspec WHERE (flspec_flgrp_id=pFlgrpid); DELETE FROM flgrp WHERE (flgrp_id=pFlgrpid); RETURN 1; END; $_$; ALTER FUNCTION public.deleteflgrp(integer) OWNER TO admin; -- -- Name: deleteform(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteform(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFormid ALIAS FOR $1; _key TEXT; _check INTEGER; BEGIN -- Cache the key of the passed form SELECT form_key INTO _key FROM form WHERE (form_id=pFormid); IF (NOT(FOUND)) THEN RETURN 0; END IF; -- Handle checks based on the type of the form IF (_key='Chck') THEN SELECT bankaccnt_id INTO _check FROM bankaccnt WHERE (bankaccnt_check_form_id=pFormid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; END IF; -- Delete the form DELETE FROM form WHERE (form_id=pFormid); RETURN pFormid; END; $_$; ALTER FUNCTION public.deleteform(integer) OWNER TO admin; -- -- Name: deletefreightclass(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletefreightclass(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFreightClassid ALIAS FOR $1; _check INTEGER; BEGIN -- Check to see if any items are assigned to the passed freightclass SELECT item_id INTO _check FROM item WHERE (item_freightclass_id=pFreightClassid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; -- Delete the passed freightclass DELETE FROM freightclass WHERE (freightclass_id=pFreightClassid); RETURN pFreightClassid; END; $_$; ALTER FUNCTION public.deletefreightclass(integer) OWNER TO admin; -- -- Name: deleteglseries(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteglseries(integer) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pSequence ALIAS FOR $1; BEGIN DELETE FROM glseries WHERE (glseries_sequence=pSequence); RETURN pSequence; END; $_$; ALTER FUNCTION public.deleteglseries(integer) OWNER TO admin; -- -- Name: deleteglseries(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteglseries(integer, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; pNotes ALIAS FOR $2; _trialbalid INTEGER; _count INTEGER; _r RECORD; BEGIN -- March through all of the G/L Transactions for the passed sequence FOR _r IN SELECT gltrans_id, gltrans_date, gltrans_accnt_id, gltrans_amount, gltrans_posted, gltrans_rec, accnt_forwardupdate, period_id, period_closed, period_freeze FROM accnt, gltrans LEFT OUTER JOIN period ON (gltrans_date BETWEEN period_start AND period_end) WHERE ( (gltrans_accnt_id=accnt_id) AND (NOT gltrans_deleted) AND (gltrans_sequence=pSequence) ) LOOP -- If we can post into a Trial Balance, do so IF ( (NOT _r.period_closed) AND ( (NOT _r.period_freeze) OR (checkPrivilege('PostFrozenPeriod')) ) AND ( NOT _r.gltrans_rec) AND ( _r.gltrans_posted ) ) THEN -- Try to find an existing trialbal SELECT trialbal_id INTO _trialbalid FROM trialbal WHERE ( (trialbal_period_id=_r.period_id) AND (trialbal_accnt_id=_r.gltrans_accnt_id) ); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count > 0) THEN -- We found a trialbal, update it with the G/L Transaction -- Note - two stage update to avoid any funny value caching logic IF (_r.gltrans_amount > 0) THEN UPDATE trialbal SET trialbal_credits = (trialbal_credits - _r.gltrans_amount) WHERE (trialbal_id=_trialbalid); ELSE UPDATE trialbal SET trialbal_debits = (trialbal_debits - (_r.gltrans_amount * -1)) WHERE (trialbal_id=_trialbalid); END IF; UPDATE trialbal SET trialbal_ending = (trialbal_beginning - trialbal_debits + trialbal_credits), trialbal_dirty=TRUE WHERE (trialbal_id=_trialbalid); ELSE RAISE EXCEPTION 'Can not delete G/L Series. Trial balance record not found.'; END IF; -- Forward update if we should IF (_r.accnt_forwardupdate AND fetchmetricbool('ManualForwardUpdate')) THEN PERFORM forwardUpdateTrialBalance(_trialbalid); END IF; -- Delete any bank reconciliation records if this was marked cleared but non reconciled DELETE FROM bankrecitem WHERE ((bankrecitem_source='GL') AND (bankrecitem_source_id=_r.gltrans_id)); -- Unflag any journals as posted as a result of this series UPDATE sltrans SET sltrans_posted=false, sltrans_gltrans_journalnumber=null FROM gltrans WHERE ((gltrans_sequence=pSequence) AND (sltrans_gltrans_journalnumber=gltrans_journalnumber)); -- Mark the G/L Transaction as deleted UPDATE gltrans SET gltrans_posted=false, gltrans_deleted=true, gltrans_notes=gltrans_notes || E'\n' || pNotes WHERE (gltrans_id=_r.gltrans_id); ELSIF (_r.period_freeze) THEN RAISE EXCEPTION 'Can not delete a G/L Transaction in a frozen period'; ELSIF (_r.period_closed) THEN RAISE EXCEPTION 'Can not delete a G/L Transaction on account % in a closed period', formatGlAccount(_r.gltrans_accnt_id); ELSIF (_r.gltrans_rec) THEN RAISE EXCEPTION 'Can not delete a G/L Transaction that has been reconciled'; ELSIF (NOT _r.gltrans_posted) THEN RAISE EXCEPTION 'Can not delete a G/L Transaction that has not been posted to Trial Balance'; END IF; END LOOP; RETURN true; END; $_$; ALTER FUNCTION public.deleteglseries(integer, text) OWNER TO admin; -- -- Name: deleteincident(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteincident(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pincdtid ALIAS FOR $1; _count INTEGER := 0; _incdtnbr INTEGER := 0; BEGIN SELECT COUNT(*) INTO _count FROM todoitem WHERE (todoitem_incdt_id=pincdtid); IF (_count > 0) THEN RETURN -1; END IF; DELETE FROM comment WHERE((comment_source='INCDT') AND (comment_source_id=pincdtid)); DELETE FROM incdthist WHERE (incdthist_incdt_id=pincdtid); DELETE FROM imageass WHERE ((imageass_source='INCDT') AND (imageass_source_id=pincdtid)); DELETE FROM url WHERE ((url_source='INCDT') AND (url_source_id=pincdtid)); SELECT incdt_number INTO _incdtnbr FROM incdt WHERE (incdt_id=pincdtid); DELETE FROM incdt WHERE (incdt_id=pincdtid); -- Incident #11538 needs to be fully resolved before release can be implemented -- PERFORM releaseIncidentNumber(_incdtnbr); RETURN 0; END; $_$; ALTER FUNCTION public.deleteincident(integer) OWNER TO admin; -- -- Name: deleteinvoice(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteinvoice(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvcheadid ALIAS FOR $1; _cobmiscid INTEGER := -1; _cobill RECORD; _cobillid INTEGER := -1; BEGIN UPDATE shipitem SET shipitem_invoiced=FALSE, shipitem_invcitem_id=NULL FROM invcitem WHERE ((shipitem_invoiced) AND (shipitem_invcitem_id=invcitem_id) AND (invcitem_invchead_id=pInvcheadid)); UPDATE coitem SET coitem_status = 'O' WHERE ((coitem_status = 'C') AND (coitem_id IN (SELECT cobill_coitem_id FROM cobill, invcitem WHERE ((cobill_invcitem_id=invcitem_id) AND (invcitem_invchead_id=pInvcheadid))))); UPDATE invdetail SET invdetail_invcitem_id=NULL FROM invcitem WHERE ((invdetail_invcitem_id=invcitem_id) AND (invcitem_invchead_id=pInvcheadid)); -- Check for unposted cobmisc for the same S/O -- If found then consolidate SELECT cobmisc_id INTO _cobmiscid FROM cobmisc WHERE ((NOT cobmisc_posted) AND (cobmisc_cohead_id IN (SELECT coitem_cohead_id FROM invcitem JOIN coitem ON (coitem_id=invcitem_coitem_id) WHERE (invcitem_invchead_id=pInvcheadid)))) LIMIT 1; IF (FOUND) THEN -- Check for uposted cobill for the same S/O Item -- If found then consolidate FOR _cobill IN SELECT cobill.* FROM invcitem JOIN cobill ON (cobill_invcitem_id=invcitem_id) WHERE (invcitem_invchead_id=pInvcheadid) LOOP SELECT cobill_id INTO _cobillid FROM cobill WHERE (cobill_cobmisc_id=_cobmiscid) AND (cobill_coitem_id=_cobill.cobill_coitem_id); IF (FOUND) THEN UPDATE cobill SET cobill_qty = cobill_qty + _cobill.cobill_qty WHERE (cobill_id=_cobillid); DELETE FROM cobill WHERE (cobill_id=_cobill.cobill_id); ELSE UPDATE cobill SET cobill_invcnum=NULL, cobill_invcitem_id=NULL, cobill_cobmisc_id=_cobmiscid WHERE (cobill_id=_cobill.cobill_id); END IF; END LOOP; DELETE FROM cobmisc WHERE (cobmisc_invchead_id=pInvcheadid); ELSE UPDATE cobill SET cobill_invcnum=NULL, cobill_invcitem_id=NULL FROM invcitem WHERE ((cobill_invcitem_id=invcitem_id) AND (invcitem_invchead_id=pInvcheadid)); UPDATE cobmisc SET cobmisc_invcnumber=NULL, cobmisc_invchead_id=NULL, cobmisc_posted=FALSE WHERE (cobmisc_invchead_id=pInvcheadid); END IF; DELETE FROM aropenalloc WHERE (aropenalloc_doctype='I') AND (aropenalloc_doc_id=pInvcheadid); DELETE FROM charass WHERE (charass_target_type='INV') AND (charass_target_id=pInvcheadid); DELETE FROM invcitem WHERE (invcitem_invchead_id=pInvcheadid); DELETE FROM invchead WHERE (invchead_id=pInvcheadid); RETURN pInvcheadid; END; $_$; ALTER FUNCTION public.deleteinvoice(integer) OWNER TO admin; -- -- Name: deleteipsitem(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteipsitem(pipsitemid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM ipsiteminfo WHERE ipsitem_id=pIpsItemId; RETURN 1; END; $$; ALTER FUNCTION public.deleteipsitem(pipsitemid integer) OWNER TO admin; -- -- Name: deleteipsprodcat(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteipsprodcat(pipsitemid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM ipsiteminfo WHERE ipsitem_id=pIpsItemId; RETURN 1; END; $$; ALTER FUNCTION public.deleteipsprodcat(pipsitemid integer) OWNER TO admin; -- -- Name: deleteitem(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteitem(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; _result INTEGER; BEGIN SELECT bomitem_id INTO _result FROM bomitem WHERE (bomitem_item_id=pItemid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; SELECT itemsite_id INTO _result FROM itemsite WHERE (itemsite_item_id=pItemid) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; SELECT itemsub_id INTO _result FROM itemsub WHERE (itemsub_sub_item_id=pItemid) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; IF (fetchmetricbool('RevControl')) THEN SELECT rev_id INTO _result FROM rev WHERE ((rev_target_id=pItemid) AND (rev_target_type = 'BOM')) LIMIT 1; IF (FOUND) THEN RETURN -6; END IF; END IF; DELETE FROM bomhead WHERE (bomhead_item_id=pItemid); DELETE FROM bomitem WHERE (bomitem_item_id=pItemid); DELETE FROM itemcost WHERE (itemcost_item_id=pItemid); DELETE FROM costhist WHERE (costhist_item_id=pItemid); DELETE FROM itemsub WHERE (itemsub_parent_item_id=pItemid); DELETE FROM itemsub WHERE (itemsub_sub_item_id=pItemid); DELETE FROM itemsrcp WHERE (itemsrcp_itemsrc_id IN (SELECT itemsrc_id FROM itemsrc WHERE (itemsrc_item_id=pItemid))); DELETE FROM itemsrc WHERE (itemsrc_item_id=pItemid); DELETE FROM itemalias WHERE (itemalias_item_id=pItemid); DELETE FROM itemgrpitem WHERE (itemgrpitem_item_id=pItemid); DELETE FROM ipsiteminfo WHERE (ipsitem_item_id=pItemid); DELETE FROM imageass WHERE ( (imageass_source='I') AND (imageass_source_id=pItemid) ); DELETE FROM locitem WHERE (locitem_item_id=pItemid); DELETE FROM itemtax WHERE(itemtax_item_id=pItemid); DELETE FROM itemsite WHERE (itemsite_item_id=pItemid); DELETE FROM itemuom WHERE(itemuom_itemuomconv_id IN (SELECT itemuomconv_id FROM itemuomconv WHERE(itemuomconv_item_id=pItemid))); DELETE FROM itemuomconv WHERE(itemuomconv_item_id=pItemid); DELETE FROM item WHERE (item_id=pItemid); RETURN 0; END; $_$; ALTER FUNCTION public.deleteitem(integer) OWNER TO admin; -- -- Name: deleteitemcost(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteitemcost(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemId ALIAS FOR $1; pCostElemId ALIAS FOR $2; _itemcost_id INTEGER; _postcost_return BOOLEAN; _std_cost NUMERIC; BEGIN SELECT itemcost_id INTO _itemcost_id FROM itemcost WHERE ( (itemcost_item_id = pItemId) AND (itemcost_costelem_id = pCostElemId) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'itemcost % not found for. ', pItemId || ' & ' || pCostElemId; END IF; SELECT itemcost_stdcost INTO _std_cost FROM itemcost WHERE (itemcost_id = _itemcost_id); IF (_std_cost > 0) THEN --Actual Cost is updated to zero to ensure inventory is valued correctly PERFORM updateCost(_itemcost_id, 0); END IF; DELETE FROM itemcost WHERE (itemcost_id=_itemcost_id); RETURN _itemcost_id; END; $_$; ALTER FUNCTION public.deleteitemcost(integer, integer) OWNER TO admin; -- -- Name: deleteitemsite(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteitemsite(pitemsiteid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _result INTEGER; _lotserial BOOLEAN; _bbom BOOLEAN; _mfg BOOLEAN; _standard BOOLEAN; BEGIN IF ( ( SELECT (itemsite_qtyonhand <> 0) FROM itemsite WHERE (itemsite_id=pItemsiteid) ) ) THEN RETURN -9; END IF; SELECT metric_value='t' INTO _bbom FROM metric WHERE (metric_name='BBOM'); SELECT metric_value='t' INTO _lotserial FROM metric WHERE (metric_name='LotSerialControl'); SELECT metric_value NOT IN ('PostBooks', 'Standard') INTO _mfg FROM metric WHERE (metric_name='Application'); SELECT metric_value='Standard' INTO _standard FROM metric WHERE (metric_name='Application'); SELECT invhist_id INTO _result FROM invhist WHERE (invhist_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; IF (_lotserial) THEN SELECT lsdetail_id INTO _result FROM lsdetail WHERE (lsdetail_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; END IF; SELECT wo_id INTO _result FROM wo WHERE (wo_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; SELECT womatl_id INTO _result FROM womatl WHERE (womatl_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; SELECT womatlvar_id INTO _result FROM womatlvar WHERE ( (womatlvar_parent_itemsite_id=pItemsiteid) OR (womatlvar_component_itemsite_id=pItemsiteid) ) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; IF (_bbom) THEN SELECT brdvar_id INTO _result FROM xtmfg.brdvar WHERE ( (brdvar_itemsite_id=pItemsiteid) OR (brdvar_parent_itemsite_id=pItemsiteid) ) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; END IF; SELECT coitem_id INTO _result FROM coitem WHERE (coitem_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; SELECT cohist_id INTO _result FROM cohist WHERE (cohist_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; SELECT quitem_id INTO _result FROM quitem WHERE (quitem_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; SELECT cmitem_id INTO _result FROM cmitem WHERE (cmitem_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; SELECT poitem_id INTO _result FROM poitem WHERE (poitem_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; SELECT recv_id INTO _result FROM recv WHERE (recv_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; SELECT poreject_id INTO _result FROM poreject WHERE (poreject_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; SELECT pr_id INTO _result FROM pr WHERE (pr_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; IF (_mfg OR _standard) THEN SELECT planord_id INTO _result FROM planord WHERE (planord_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -5; END IF; END IF; IF (_mfg) THEN SELECT pschitem_id INTO _result FROM xtmfg.pschitem WHERE (pschitem_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -6; END IF; SELECT woopervar_id INTO _result FROM xtmfg.woopervar WHERE (woopervar_parent_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; END IF; IF (_mfg OR _standard) THEN SELECT itemsite_id INTO _result FROM itemsite WHERE (itemsite_supply_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -7; END IF; END IF; DELETE FROM invcnt WHERE (invcnt_itemsite_id=pItemsiteid); DELETE FROM itemloc WHERE (itemloc_itemsite_id=pItemsiteid); DELETE FROM itemlocdist WHERE (itemlocdist_itemsite_id=pItemsiteid); IF (_bbom) THEN DELETE FROM xtmfg.brddist WHERE (brddist_itemsite_id=pItemsiteid); END IF; DELETE FROM itemsite WHERE (itemsite_id=pItemsiteid); RETURN 0; END; $$; ALTER FUNCTION public.deleteitemsite(pitemsiteid integer) OWNER TO admin; -- -- Name: deleteitemuom(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteitemuom(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemuomid ALIAS FOR $1; BEGIN DELETE FROM itemuom WHERE itemuom_id=pItemuomid; RETURN 0; END; $_$; ALTER FUNCTION public.deleteitemuom(integer) OWNER TO admin; -- -- Name: deleteitemuomconv(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteitemuomconv(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemuomconvid ALIAS FOR $1; _fromuomid INTEGER; _invuomid INTEGER; _itemid INTEGER; _touomid INTEGER; BEGIN SELECT itemuomconv_item_id, item_inv_uom_id, itemuomconv_from_uom_id, itemuomconv_to_uom_id INTO _itemid, _invuomid, _fromuomid, _touomid FROM itemuomconv JOIN item ON (itemuomconv_item_id=item_id) WHERE (itemuomconv_id=pItemuomconvid); IF EXISTS(SELECT * FROM uomusedforitem(_itemid) WHERE ((uom_id IN (_fromuomid, _touomid)) AND (uom_id != _invuomid)) ) THEN RETURN -1; END IF; DELETE FROM itemuom WHERE itemuom_itemuomconv_id=pItemuomconvid; DELETE FROM itemuomconv WHERE itemuomconv_id=pItemuomconvid; RETURN 0; END; $_$; ALTER FUNCTION public.deleteitemuomconv(integer) OWNER TO admin; -- -- Name: deletelocation(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletelocation(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLocationid ALIAS FOR $1; _check INTEGER; BEGIN -- Check to see if any itemsite used the passed location as their default SELECT itemsite_id INTO _check FROM itemsite WHERE (itemsite_location_id=pLocationid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; -- Check to see if any inventory is currently stored at the passed location SELECT itemloc_id INTO _check FROM itemloc WHERE (itemloc_location_id=pLocationid) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; -- Check to see if any undistributed inventory transactions are currently posted at the passed location SELECT itemlocdist_id INTO _check FROM itemlocdist WHERE ( (itemlocdist_source_type='L') AND (itemlocdist_source_id=pLocationid) ) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; -- Check to see if the passed location has any Inventory Detail posted against it SELECT invdetail_id INTO _check FROM invdetail WHERE (invdetail_location_id=pLocationid) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; -- Delete any associated locitem records DELETE FROM locitem WHERE (locitem_location_id=pLocationid); -- Delete the location record DELETE FROM location WHERE (location_id=pLocationid); RETURN pLocationid; END; $_$; ALTER FUNCTION public.deletelocation(integer) OWNER TO admin; -- -- Name: deletemetasql(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletemetasql(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pid ALIAS FOR $1; BEGIN DELETE FROM metasql WHERE metasql_id = pid; RETURN 0; END; $_$; ALTER FUNCTION public.deletemetasql(integer) OWNER TO admin; -- -- Name: deleteopenrecurringitems(integer, text, timestamp with time zone, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteopenrecurringitems(integer, text, timestamp with time zone, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pParentid ALIAS FOR $1; pType TEXT := UPPER($2); pDatetime TIMESTAMP WITH TIME ZONE := COALESCE($3, startOfTime()); pInclParent BOOLEAN := COALESCE($4, FALSE); _count INTEGER := 0; _delchildstmt TEXT; _delparentstmt TEXT; _rt RECORD; _tmp INTEGER; BEGIN RAISE DEBUG 'deleteOpenRecurringItems(%, %, %)', pParentid, pType, pDatetime; IF (pParentid IS NULL) THEN RETURN -11; END IF; SELECT * INTO _rt FROM recurtype WHERE (UPPER(recurtype_type)=pType); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count <= 0) THEN RETURN -10; END IF; -- 2 deletes avoid reparenting problems if the parent gets deleted first IF (_rt.recurtype_delfunc IS NULL) THEN _delchildstmt := 'DELETE FROM [fulltable] ' || ' WHERE (NOT ([done])' || ' AND ([schedcol]>''$2'')' || ' AND ([table]_recurring_[table]_id=$1)' || ' AND ([table]_id!=$1));'; _delparentstmt := 'DELETE FROM [fulltable] USING recur' || ' WHERE (NOT ([done])' || ' AND ([schedcol]>''$2'')' || ' AND ([table]_recurring_[table]_id=$1)' || ' AND ([table]_id=$1));'; ELSE _delchildstmt := 'SELECT [delfunc]([table]_id)' || ' FROM [fulltable] ' || ' WHERE (NOT ([done])' || ' AND ([schedcol]>''$2'')' || ' AND ([table]_recurring_[table]_id=$1)' || ' AND ([table]_id!=$1));'; _delparentstmt := 'SELECT [delfunc]([table]_id)' || ' FROM [fulltable] ' || ' WHERE (NOT ([done])' || ' AND ([schedcol]>''$2'')' || ' AND ([table]_recurring_[table]_id=$1)' || ' AND ([table]_id!=$1));'; _delchildstmt := REPLACE(_delchildstmt, '[delfunc]', _rt.recurtype_delfunc); _delparentstmt := REPLACE(_delparentstmt, '[delfunc]', _rt.recurtype_delfunc); END IF; RAISE DEBUG '_delchildstmt has been set to %', _delchildstmt; _delchildstmt := REPLACE(_delchildstmt, '[fulltable]', _rt.recurtype_table); _delchildstmt := REPLACE(_delchildstmt, '[table]', REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', '')); _delchildstmt := REPLACE(_delchildstmt, '[done]', _rt.recurtype_donecheck); _delchildstmt := REPLACE(_delchildstmt, '[schedcol]', _rt.recurtype_schedcol); _delparentstmt := REPLACE(_delparentstmt, '[fulltable]', _rt.recurtype_table); _delparentstmt := REPLACE(_delparentstmt, '[table]', REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', '')); _delparentstmt := REPLACE(_delparentstmt, '[done]', _rt.recurtype_donecheck); _delparentstmt := REPLACE(_delparentstmt, '[schedcol]', _rt.recurtype_schedcol); RAISE DEBUG 'substitutions changed _delchildstmt to %', _delchildstmt; IF (_rt.recurtype_delfunc IS NULL) THEN -- 8.4+: EXECUTE _delchildstmt USING pDatetime, pType; RAISE DEBUG '% with % and %', _delchildstmt, pType, pDatetime; EXECUTE REPLACE(REPLACE(_delchildstmt, '$1', pParentid::TEXT), '$2', pDatetime::TEXT); GET DIAGNOSTICS _count = ROW_COUNT; IF (pInclParent) THEN -- 8.4+: EXECUTE _delparentstmt USING pDatetime, pType; RAISE DEBUG '% with % and %', _delparentstmt, pType, pDatetime; EXECUTE REPLACE(REPLACE(_delparentstmt, '$1', pParentid::TEXT), '$2', pDatetime::TEXT); GET DIAGNOSTICS _tmp = ROW_COUNT; _count := _count + _tmp; END IF; ELSE -- 8.4+: FOR _tmp IN EXECUTE _delchildstmt USING pDatetime, pType LOOP FOR _tmp IN EXECUTE REPLACE(REPLACE(_delchildstmt, '$1', pParentid::TEXT), '$2', pDatetime::TEXT) LOOP IF _tmp < 0 THEN RETURN _tmp; END IF; _count := _count + 1; END LOOP; IF (pInclParent) THEN -- 8.4+: EXECUTE _delparentstmt INTO _tmp USING pDatetime, pType; EXECUTE REPLACE(REPLACE(_delparentstmt, '$1', pParentid::TEXT), '$2', pDatetime::TEXT) INTO _tmp; IF (_tmp < 0) THEN RETURN _tmp; END IF; _count := _count + 1; END IF; END IF; RAISE DEBUG 'deleteOpenrecurringItems() returning %', _count; RETURN _count; END; $_$; ALTER FUNCTION public.deleteopenrecurringitems(integer, text, timestamp with time zone, boolean) OWNER TO admin; -- -- Name: deleteopportunity(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteopportunity(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOpheadid ALIAS FOR $1; _test INTEGER; BEGIN SELECT todoitem_id INTO _test FROM todoitem WHERE(todoitem_ophead_id=pOpheadid) LIMIT 1; IF(FOUND) THEN RETURN -1; END IF; SELECT quhead_id INTO _test FROM quhead WHERE(quhead_ophead_id=pOpheadid) LIMIT 1; IF(FOUND) THEN RETURN -2; END IF; SELECT cohead_id INTO _test FROM cohead WHERE(cohead_ophead_id=pOpheadid) LIMIT 1; IF(FOUND) THEN RETURN -3; END IF; DELETE FROM charass WHERE((charass_target_type='OPP') AND (charass_target_id=pOpheadid)); DELETE FROM comment WHERE((comment_source='OPP') AND (comment_source_id=pOpheadid)); DELETE FROM ophead WHERE(ophead_id=pOpheadid); return 0; END; $_$; ALTER FUNCTION public.deleteopportunity(integer) OWNER TO admin; -- -- Name: deletepackage(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletepackage(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ppkgheadid ALIAS FOR $1; _i INTEGER := 0; _pkgname TEXT; _r RECORD; _tabs TEXT[] := ARRAY['cmd', 'cmdarg', 'image', 'metasql', 'priv', 'report', 'script', 'uiform']; _debug BOOL := false; BEGIN IF (EXISTS(SELECT * FROM pkgdep WHERE (pkgdep_parent_pkghead_id=ppkgheadid))) THEN RETURN -1; END IF; SELECT pkghead_name INTO _pkgname FROM pkghead WHERE (pkghead_id=ppkgheadid); IF (NOT FOUND) THEN RETURN -2; END IF; IF (LOWER(_pkgname) = 'public' OR LOWER(_pkgname) = 'api') THEN RETURN -3; END IF; FOR _i IN ARRAY_LOWER(_tabs,1)..ARRAY_UPPER(_tabs,1) LOOP EXECUTE 'ALTER TABLE ' || _pkgname || '.pkg' || _tabs[_i] || ' DISABLE TRIGGER pkg' || _tabs[_i] || 'altertrigger;'; END LOOP; DELETE FROM pkghead WHERE pkghead_id=ppkgheadid; RETURN ppkgheadid; END; $_$; ALTER FUNCTION public.deletepackage(integer) OWNER TO admin; -- -- Name: deletepo(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletepo(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPoheadid ALIAS FOR $1; _poitemid INTEGER; BEGIN IF ( ( SELECT pohead_status FROM pohead WHERE (pohead_id=pPoheadid) ) = 'U' ) THEN -- Unlink from any Sales Orders UPDATE coitem SET coitem_order_type=NULL, coitem_order_id=NULL FROM poitem WHERE ( (coitem_order_type='P') AND (coitem_order_id=poitem_id) AND (poitem_pohead_id=pPoheadid) ); DELETE FROM poitem WHERE (poitem_pohead_id=pPoheadid); DELETE FROM pohead WHERE (pohead_id=pPoheadid); RETURN TRUE; ELSE RETURN FALSE; END IF; END; $_$; ALTER FUNCTION public.deletepo(integer) OWNER TO admin; -- -- Name: deletepoitem(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletepoitem(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPoitemid ALIAS FOR $1; _poheadid INTEGER := -1; _status CHARACTER; BEGIN SELECT poitem_pohead_id, poitem_status INTO _poheadid, _status FROM poitem WHERE (poitem_id=pPoitemid); IF NOT(FOUND) THEN RETURN 0; END IF; IF ( _status = 'U' ) THEN DELETE FROM poitem WHERE (poitem_id=pPoitemid); ELSE IF ( _status = 'O' ) THEN PERFORM recv_id FROM recv WHERE ( (recv_order_type='PO') AND (recv_orderitem_id=pPoitemid) ); IF (FOUND) THEN RETURN -10; ELSE RETURN -20; END IF; ELSE RETURN -10; END IF; END IF; PERFORM poitem_id FROM poitem WHERE poitem_pohead_id = _poheadid; IF NOT(FOUND) THEN DELETE FROM pohead WHERE (pohead_id = _poheadid); END IF; RETURN 0; END; $_$; ALTER FUNCTION public.deletepoitem(integer) OWNER TO admin; -- -- Name: deletepr(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletepr(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrid ALIAS FOR $1; BEGIN DELETE FROM pr WHERE ( (pr_status='O') AND (pr_id=pPrid) ); RETURN TRUE; END; $_$; ALTER FUNCTION public.deletepr(integer) OWNER TO admin; -- -- Name: deletepr(character, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletepr(character, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pParentType ALIAS FOR $1; pParentId ALIAS FOR $2; BEGIN DELETE FROM pr WHERE ((pr_status='O') AND (pr_order_type=pParentType) AND (pr_order_id=pParentId)); RETURN TRUE; END; $_$; ALTER FUNCTION public.deletepr(character, integer) OWNER TO admin; -- -- Name: deleteproductcategory(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteproductcategory(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pProdcatid ALIAS FOR $1; _check INTEGER; BEGIN -- Check to see if any items are assigned to the passed classcode SELECT item_id INTO _check FROM item WHERE (item_prodcat_id=pProdcatid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; -- Delete any assocated records DELETE FROM salesaccnt WHERE (salesaccnt_prodcat_id=pProdcatid); -- Delete the passed prodcat DELETE FROM prodcat WHERE (prodcat_id=pProdcatid); RETURN pProdcatid; END; $_$; ALTER FUNCTION public.deleteproductcategory(integer) OWNER TO admin; -- -- Name: deleteprofitcenter(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteprofitcenter(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pid ALIAS FOR $1; BEGIN IF (EXISTS(SELECT accnt_id FROM accnt, prftcntr WHERE ((accnt_company=prftcntr_number) AND (prftcntr_id=pid)) )) THEN RETURN -1; END IF; DELETE FROM prftcntr WHERE (prftcntr_id=pid); RETURN pid; END; $_$; ALTER FUNCTION public.deleteprofitcenter(integer) OWNER TO admin; -- -- Name: deleteproject(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteproject(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrjid ALIAS FOR $1; _result INTEGER; BEGIN SELECT quhead_id INTO _result FROM quhead WHERE (quhead_prj_id=pPrjid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; SELECT cohead_id INTO _result FROM cohead WHERE (cohead_prj_id=pPrjid) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; SELECT wo_id INTO _result FROM wo WHERE (wo_prj_id=pPrjid) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; SELECT pr_id INTO _result FROM pr WHERE (pr_prj_id=pPrjid) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; SELECT poitem_id INTO _result FROM poitem WHERE (poitem_prj_id=pPrjid) LIMIT 1; IF (FOUND) THEN RETURN -5; END IF; SELECT invchead_id INTO _result FROM invchead WHERE (invchead_prj_id=pPrjid) LIMIT 1; IF (FOUND) THEN RETURN -6; END IF; DELETE FROM comment WHERE ((comment_source='J') AND (comment_source_id=pPrjid)); DELETE FROM comment WHERE ((comment_source='TA') AND (comment_source_id IN ( SELECT prjtask_id FROM prjtask WHERE (prjtask_prj_id=pPrjId)))); DELETE FROM prjtask WHERE (prjtask_prj_id=pPrjid); UPDATE prj SET prj_recurring_prj_id=null WHERE(prj_recurring_prj_id=pPrjid); DELETE FROM prj WHERE (prj_id=pPrjid); RETURN pPrjid; END; $_$; ALTER FUNCTION public.deleteproject(integer) OWNER TO admin; -- -- Name: deleteprojecttask(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteprojecttask(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrjtaskid ALIAS FOR $1; _row RECORD; _result INTEGER; BEGIN SELECT * INTO _row FROM prjtask WHERE (prjtask_id=pPrjtaskid) LIMIT 1; IF (NOT FOUND) THEN RETURN -1; END IF; IF (COALESCE(_row.prjtask_hours_actual, 0.0) > 0.0) THEN RETURN -2; END IF; IF (COALESCE(_row.prjtask_exp_actual, 0.0) > 0.0) THEN RETURN -3; END IF; DELETE FROM comment WHERE ((comment_source='TA') AND (comment_source_id=pPrjtaskid)); DELETE FROM prjtask WHERE (prjtask_id=pPrjtaskid); RETURN 0; END; $_$; ALTER FUNCTION public.deleteprojecttask(integer) OWNER TO admin; -- -- Name: deleteqryhead(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteqryhead(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pqryheadid ALIAS FOR $1; BEGIN DELETE FROM qryitem WHERE (qryitem_qryhead_id=pqryheadid); DELETE FROM qryhead WHERE (qryhead_id=pqryheadid); RETURN pqryheadid; END; $_$; ALTER FUNCTION public.deleteqryhead(integer) OWNER TO admin; -- -- Name: deletequote(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletequote(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuheadid ALIAS FOR $1; BEGIN RETURN deleteQuote(pQuheadid, NULL::TEXT); END; $_$; ALTER FUNCTION public.deletequote(integer) OWNER TO admin; -- -- Name: deletequote(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletequote(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuheadid ALIAS FOR $1; pQuoteNumber ALIAS FOR $2; _quNumberScheme TEXT; _quoteNumber TEXT; _quitemid INTEGER; _result INTEGER; BEGIN SELECT fetchMetricText('QUNumberGeneration') INTO _quNumberScheme; IF (pQuoteNumber IS NULL) THEN SELECT quhead_number INTO _quoteNumber FROM quhead WHERE (quhead_id=pQuheadid); ELSE _quoteNumber := pQuoteNumber; END IF; PERFORM deleteQuoteItem(quitem_id) FROM quitem WHERE (quitem_quhead_id=pQuheadid); DELETE FROM charass WHERE (charass_target_type='QU') AND (charass_target_id=pQuheadid); DELETE FROM quhead WHERE (quhead_id=pQuheadid); IF (_quoteNumber IS NOT NULL) THEN IF (_quNumberScheme IN ('A', 'O')) THEN -- do not release quote # if quote converted to sales order IF (NOT EXISTS (SELECT cohead_id FROM cohead WHERE (cohead_number=_quoteNumber))) THEN _result = releaseQuNumber(_quoteNumber); END IF; ELSEIF (_quNumberScheme = 'S') THEN _result = releaseSoNumber(_quoteNumber); END IF; END IF; -- Don't care about result of release number RETURN 0; END; $_$; ALTER FUNCTION public.deletequote(integer, text) OWNER TO admin; -- -- Name: deletequote(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletequote(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuheadid ALIAS FOR $1; pQuoteNumber ALIAS FOR $2; BEGIN RETURN deleteQuote(pQuheadid, pQuoteNumber::TEXT); END; $_$; ALTER FUNCTION public.deletequote(integer, integer) OWNER TO admin; -- -- Name: deletequoteitem(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletequoteitem(integer) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pQuitemid ALIAS FOR $1; _result INTEGER; BEGIN DELETE FROM charass WHERE (charass_target_type='QI') AND (charass_target_id=pQuitemid); DELETE FROM quitem WHERE (quitem_id=pQuitemid); RETURN 0; END; $_$; ALTER FUNCTION public.deletequoteitem(integer) OWNER TO admin; -- -- Name: deleterecvfororder(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleterecvfororder(text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; porderid ALIAS FOR $2; BEGIN DELETE FROM recv USING orderitem WHERE ((recv_orderitem_id=orderitem_id) AND (recv_order_type=orderitem_orderhead_type) AND (NOT recv_posted) AND (orderitem_orderhead_id=porderid) AND (orderitem_orderhead_type=pordertype)); RETURN 0; END; $_$; ALTER FUNCTION public.deleterecvfororder(text, integer) OWNER TO admin; -- -- Name: deletesalescategory(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletesalescategory(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSalescatid ALIAS FOR $1; BEGIN PERFORM invcitem_salescat_id FROM invchead, invcitem WHERE ( (invcitem_invchead_id=invchead_id) AND (NOT invchead_posted) AND (invcitem_salescat_id=pSalescatid) ); IF (FOUND) THEN RETURN -1; END IF; PERFORM invcitem_salescat_id FROM invchead, invcitem WHERE ( (invcitem_invchead_id=invchead_id) AND (invchead_posted) AND (invcitem_salescat_id=pSalescatid) ); IF (FOUND) THEN RETURN -2; END IF; PERFORM aropen_salescat_id FROM aropen WHERE (aropen_salescat_id=pSalescatid); IF (FOUND) THEN RETURN -3; END IF; DELETE FROM salescat WHERE (salescat_id=pSalescatid); RETURN 0; END; $_$; ALTER FUNCTION public.deletesalescategory(integer) OWNER TO admin; -- -- Name: deleteshippingcharge(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteshippingcharge(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipchrgid ALIAS FOR $1; BEGIN IF EXISTS(SELECT 1 FROM custinfo WHERE (cust_shipchrg_id=pShipchrgid)) THEN RETURN -1; END IF; DELETE FROM shipchrg WHERE (shipchrg_id=pShipchrgid); RETURN pShipchrgid; END; $_$; ALTER FUNCTION public.deleteshippingcharge(integer) OWNER TO admin; -- -- Name: deleteshippingchargetype(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteshippingchargetype(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipchrgid ALIAS FOR $1; _check INTEGER; BEGIN -- Check to see if the passed shipchrg is used as a default for any customers SELECT cust_id INTO _check FROM custinfo WHERE (cust_shipchrg_id=pShipchrgid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; -- Check to see if the passed shipchrg is used as a default for any shiptos SELECT shipto_id INTO _check FROM shiptoinfo WHERE (shipto_shipchrg_id=pShipchrgid) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; -- Check to see if the passed shipchrg is used on any sales orders SELECT cohead_id INTO _check FROM cohead WHERE (cohead_shipchrg_id=pShipchrgid) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; -- Check to see if the passed shipchrg is used on any shippers SELECT shiphead_id INTO _check FROM shiphead WHERE (shiphead_shipchrg_id=pShipchrgid) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; -- Check to see if the passed shipchrg is used on any invoices SELECT invchead_id INTO _check FROM invchead WHERE (invchead_shipchrg_id=pShipchrgid) LIMIT 1; IF (FOUND) THEN RETURN -5; END IF; -- Delete the passed shipchrg DELETE FROM shipchrg WHERE (shipchrg_id=pShipchrgid); RETURN pShipchrgid; END; $_$; ALTER FUNCTION public.deleteshippingchargetype(integer) OWNER TO admin; -- -- Name: deleteshipto(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteshipto(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShiptoid ALIAS FOR $1; BEGIN PERFORM asohist_id FROM asohist WHERE (asohist_shipto_id=pShiptoid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; PERFORM cohead_id FROM cohead WHERE (cohead_shipto_id=pShiptoid) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; PERFORM cmhead_id FROM cmhead WHERE (cmhead_shipto_id=pShiptoid) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; PERFORM cohist_id FROM cohist WHERE (cohist_shipto_id=pShiptoid) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; PERFORM quhead_id FROM quhead WHERE (quhead_shipto_id=pShiptoid) LIMIT 1; IF (FOUND) THEN RETURN -5; END IF; PERFORM invchead_id FROM invchead WHERE (invchead_shipto_id=pShiptoid) LIMIT 1; IF (FOUND) THEN RETURN -6; END IF; DELETE FROM ipsass WHERE (ipsass_shipto_id=pShiptoid); DELETE FROM shiptoinfo WHERE (shipto_id=pShiptoid); RETURN 0; END; $_$; ALTER FUNCTION public.deleteshipto(integer) OWNER TO admin; -- -- Name: deleteso(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteso(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; BEGIN RETURN deleteSo(pSoheadid, NULL); END; $_$; ALTER FUNCTION public.deleteso(integer) OWNER TO admin; -- -- Name: deleteso(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteso(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; pSonumber ALIAS FOR $2; _r RECORD; _coitemid INTEGER; _result INTEGER; _poStatus INTEGER := 0; BEGIN -- Get cohead SELECT * INTO _r FROM cohead WHERE (cohead_id=pSoheadid); IF (NOT FOUND) THEN IF (COALESCE(pSonumber,'') != '') THEN _result := releaseSoNumber(pSonumber); END IF; RETURN 0; END IF; -- Cannot delete if credit card payments IF (EXISTS(SELECT ccpay_id FROM ccpay, payco WHERE ((ccpay_status IN ('C')) AND (ccpay_id=payco_ccpay_id) AND (payco_cohead_id=pSoheadid)))) THEN RETURN -1; END IF; -- Cannot delete if credit card history IF (EXISTS(SELECT ccpay_id FROM ccpay, payco WHERE ((ccpay_status != 'C') AND (ccpay_id=payco_ccpay_id) AND (payco_cohead_id=pSoheadid)))) THEN RETURN -2; END IF; -- Delete Sales Order Items FOR _coitemid IN SELECT coitem_id FROM coitem WHERE ( (coitem_cohead_id=pSoheadid) AND (coitem_subnumber=0) ) LOOP SELECT deleteSoItem(_coitemid) INTO _result; IF (_result < 0) THEN IF (_result = -20) THEN _poStatus := _poStatus - 1; ELSE RETURN _result; END IF; END IF; END LOOP; DELETE FROM pack WHERE (pack_head_id=pSoheadid and pack_head_type = 'SO'); DELETE FROM charass WHERE (charass_target_type='SO') AND (charass_target_id=pSoheadid); DELETE FROM cohead WHERE (cohead_id=pSoheadid); IF (fetchMetricBool('AutoCreateProjectsForOrders')) THEN PERFORM deleteProject(_r.cohead_prj_id); END IF; DELETE FROM aropenalloc WHERE ((aropenalloc_doctype='S') AND (aropenalloc_doc_id=pSoheadid)); IF ( (NOT _r.cohead_wasquote) AND (NOT _r.cohead_imported) ) THEN IF (COALESCE(pSonumber,'') != '') THEN _result = releaseSoNumber(pSonumber); ELSEIF (_r.cohead_number IS NOT NULL) THEN _result = releaseSoNumber(_r.cohead_number); END IF; END IF; IF (_poStatus < 0) THEN RETURN -20; ELSE RETURN 0; END IF; END; $_$; ALTER FUNCTION public.deleteso(integer, text) OWNER TO admin; -- -- Name: deletesoitem(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletesoitem(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoitemid ALIAS FOR $1; _r RECORD; _s RECORD; _result INTEGER; _deletePO INTEGER := 0; _recvId INTEGER := -1; _poStatus TEXT; _jobItem BOOLEAN; BEGIN -- Get coitem SELECT * INTO _r FROM coitem WHERE (coitem_id=pSoitemid); IF (NOT FOUND) THEN RETURN -999; END IF; -- Cannot delete if shipped IF (_r.coitem_qtyshipped > 0) THEN RETURN -101; END IF; -- Cannot delete if issued to shipping SELECT shipitem_id INTO _result FROM shipitem JOIN shiphead ON (shiphead_id=shipitem_shiphead_id AND shiphead_order_type='SO') WHERE (shipitem_orderitem_id=pSoitemid) LIMIT 1; IF (FOUND) THEN RETURN -102; END IF; -- Cannot delete if returned IF (fetchMetricBool('MultiWhs')) THEN SELECT raitem_id INTO _result FROM raitem WHERE ( (raitem_orig_coitem_id=pSoitemid) OR (raitem_new_coitem_id=pSoitemid) ) LIMIT 1; IF (FOUND) THEN RETURN -103; END IF; END IF; -- Cannot delete if any inventory history SELECT invhist_id INTO _result FROM invhist WHERE ( (invhist_ordnumber=formatSoNumber(pSoitemid)) AND (invhist_ordtype='SO') ) LIMIT 1; IF (FOUND) THEN RETURN -105; END IF; -- If Kit, check deletion of component items IF (_r.coitem_subnumber = 0) THEN FOR _s IN SELECT * FROM coitem WHERE ((coitem_cohead_id = _r.coitem_cohead_id) AND (coitem_linenumber = _r.coitem_linenumber) AND (coitem_subnumber > 0)) LOOP IF ((COALESCE(_s.coitem_order_id, -1) > 0) AND (_s.coitem_order_type = 'P')) THEN SELECT poitem_status, COALESCE(recv_id, -1) INTO _poStatus, _recvId FROM poitem LEFT OUTER JOIN recv ON ((recv_orderitem_id=poitem_id) AND (recv_order_type='PO')) WHERE (poitem_id = _s.coitem_order_id); IF ((_recvId > 0) OR (_poStatus = 'C')) THEN RETURN -10; ELSIF ((_recvId = -1) AND (_poStatus = 'O')) THEN _deletePO := _deletePO - 1; END IF; END IF; END LOOP; END IF; SELECT (itemsite_costmethod='J') INTO _jobItem FROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id) WHERE (coitem_id=pSoitemid); IF (_jobItem AND _r.coitem_order_type='W') THEN -- Delete associated Job Work Order SELECT deleteWo(_r.coitem_order_id, TRUE, TRUE) INTO _result; IF (_result < 0) THEN RETURN -104; END IF; ELSIF (_r.coitem_order_type='W') THEN -- Delete associated Job Work Order SELECT deleteWo(_r.coitem_order_id, TRUE) INTO _result; IF (_result < 0) THEN -- Cannot delete so break association PERFORM changeWoProject(_r.coitem_order_id, -1, TRUE); END IF; ELSIF (_r.coitem_order_type='R') THEN -- Delete associated Purchase Request PERFORM deletePr(_r.coitem_order_id); ELSIF (_r.coitem_order_type='P') THEN -- Delete associated Purchase Order Item SELECT deletepoitem(_r.coitem_order_id) INTO _result; IF ((_result < 0) AND (_result <> -20)) THEN RETURN _result; ELSIF (_result = -20) THEN _deletePO := _deletePO - 1; END IF; END IF; -- Delete characteristic assignments DELETE FROM charass WHERE (charass_target_type='SI') AND (charass_target_id=pSoitemid); -- Delete reservations IF (fetchMetricBool('EnableSOReservationsByLocation')) THEN DELETE FROM reserve WHERE (reserve_demand_type='SO') AND (reserve_demand_id=pSoitemid); END IF; -- Delete the coitem DELETE FROM coitem WHERE (coitem_id=pSoitemid); IF (_deletePO < 0) THEN RETURN -20; ELSE RETURN 0; END IF; END; $_$; ALTER FUNCTION public.deletesoitem(integer) OWNER TO admin; -- -- Name: deletestandardjournal(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletestandardjournal(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pStdjrnlid ALIAS FOR $1; BEGIN DELETE FROM stdjrnlitem WHERE (stdjrnlitem_stdjrnl_id=pStdjrnlid); DELETE FROM stdjrnlgrpitem WHERE (stdjrnlgrpitem_stdjrnl_id=pStdjrnlid); DELETE FROM stdjrnl WHERE (stdjrnl_id=pStdjrnlid); RETURN 1; END; $_$; ALTER FUNCTION public.deletestandardjournal(integer) OWNER TO admin; -- -- Name: deletestandardjournalgroup(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletestandardjournalgroup(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pStdjrnlgrpid ALIAS FOR $1; BEGIN DELETE FROM stdjrnlgrpitem WHERE (stdjrnlgrpitem_stdjrnlgrp_id=pStdjrnlgrpid); DELETE FROM stdjrnlgrp WHERE (stdjrnlgrp_id=pStdjrnlgrpid); RETURN 1; END; $_$; ALTER FUNCTION public.deletestandardjournalgroup(integer) OWNER TO admin; -- -- Name: deletesubaccount(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletesubaccount(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pid ALIAS FOR $1; BEGIN IF (EXISTS(SELECT accnt_id FROM accnt, subaccnt WHERE ((accnt_company=subaccnt_number) AND (subaccnt_id=pid)) )) THEN RETURN -1; END IF; DELETE FROM subaccnt WHERE (subaccnt_id=pid); RETURN pid; END; $_$; ALTER FUNCTION public.deletesubaccount(integer) OWNER TO admin; -- -- Name: deletesubaccounttype(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletesubaccounttype(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSubAccntTypeid ALIAS FOR $1; _check INTEGER; BEGIN -- Check to see if the passed subaccnttype is used in any accounts SELECT accnt_id INTO _check FROM accnt, subaccnttype WHERE ( (accnt_subaccnttype_code=subaccnttype_code) AND (subaccnttype_id=pSubAccntTypeid) ) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; -- Delete the Sub Account Type DELETE FROM subaccnttype WHERE (subaccnttype_id=pSubAccntTypeid); RETURN 0; END; $_$; ALTER FUNCTION public.deletesubaccounttype(integer) OWNER TO admin; -- -- Name: deletetax(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletetax(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ptaxid ALIAS FOR $1; BEGIN -- these checks allow nice error reporting instead of throwing an SQL error IF EXISTS(SELECT taxass_id FROM taxass WHERE (taxass_tax_id=ptaxid)) THEN RETURN -10; END IF; IF EXISTS(SELECT taxhist_id FROM taxhist WHERE (taxhist_tax_id=ptaxid)) THEN RETURN -20; END IF; DELETE FROM taxrate WHERE (taxrate_tax_id = ptaxid); DELETE FROM tax WHERE (tax_id = ptaxid); RETURN ptaxid; END; $_$; ALTER FUNCTION public.deletetax(integer) OWNER TO admin; -- -- Name: deletetaxclass(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletetaxclass(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxclassid ALIAS FOR $1; _result INTEGER; BEGIN -- Check to find if the tax class is used in any tax code SELECT tax_id INTO _result FROM tax WHERE (tax_taxclass_id = pTaxclassid); IF (FOUND) THEN RETURN -1; END IF; -- Delete the tax class if the above condition doesn't match DELETE FROM taxclass WHERE taxclass_id = pTaxclassid ; RETURN pTaxclassid; END; $_$; ALTER FUNCTION public.deletetaxclass(integer) OWNER TO admin; -- -- Name: deletetaxtype(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletetaxtype(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxtypeid ALIAS FOR $1; _result INTEGER; BEGIN SELECT taxtype_id INTO _result FROM taxtype WHERE ((taxtype_sys) AND (taxtype_id=pTaxtypeid)); IF (FOUND) THEN RETURN -1; END IF; SELECT taxass_id INTO _result FROM taxass WHERE (taxass_taxtype_id=pTaxtypeid); IF (FOUND) THEN RETURN -2; END IF; SELECT taxhist_id INTO _result FROM taxhist WHERE (taxhist_taxtype_id=pTaxtypeid); IF (FOUND) THEN RETURN -3; END IF; DELETE FROM taxtype WHERE (taxtype_id=pTaxtypeid); RETURN pTaxtypeid; END; $_$; ALTER FUNCTION public.deletetaxtype(integer) OWNER TO admin; -- -- Name: deletetaxzone(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletetaxzone(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxzoneid ALIAS FOR $1; _result INTEGER; BEGIN -- Check to find if the tax zone is used in any tax assignment SELECT taxass_id INTO _result FROM taxass WHERE (taxass_taxzone_id=pTaxzoneid); IF (FOUND) THEN RETURN -1; END IF; -- Check to find if the tax zone has been referenced in any tax registration SELECT taxreg_id INTO _result FROM taxreg WHERE (taxreg_taxzone_id=pTaxzoneid); IF (FOUND) THEN RETURN -2; END IF; -- Delete the tax zone if none of the above conditions match DELETE FROM taxzone WHERE taxzone_id = pTaxzoneid ; RETURN pTaxzoneid; END; $_$; ALTER FUNCTION public.deletetaxzone(integer) OWNER TO admin; -- -- Name: deletetodoitem(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletetodoitem(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ptodoItemId ALIAS FOR $1; BEGIN DELETE FROM alarm WHERE ( (alarm_source='TODO') AND (alarm_source_id=ptodoItemId) ); DELETE FROM todoitem WHERE todoitem_id = ptodoItemId; RETURN 0; END; $_$; ALTER FUNCTION public.deletetodoitem(integer) OWNER TO admin; -- -- Name: deleteunusedclasscodes(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteunusedclasscodes() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN DELETE FROM classcode WHERE (classcode_id NOT IN (SELECT DISTINCT item_classcode_id FROM item)); RETURN 0; END; $$; ALTER FUNCTION public.deleteunusedclasscodes() OWNER TO admin; -- -- Name: deleteunusedfreightclasses(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteunusedfreightclasses() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN DELETE FROM freightclass WHERE (freightclass_id NOT IN (SELECT DISTINCT COALESCE(item_freightclass_id, 0) FROM item)); RETURN 0; END; $$; ALTER FUNCTION public.deleteunusedfreightclasses() OWNER TO admin; -- -- Name: deleteunusedproductcategories(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteunusedproductcategories() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Delete any associated records DELETE FROM salesaccnt WHERE ( (salesaccnt_prodcat_id <> -1) AND (salesaccnt_prodcat_id NOT IN (SELECT DISTINCT item_prodcat_id FROM item)) ); DELETE FROM prodcat WHERE (prodcat_id NOT IN (SELECT DISTINCT item_prodcat_id FROM item)); RETURN 0; END; $$; ALTER FUNCTION public.deleteunusedproductcategories() OWNER TO admin; -- -- Name: deleteuom(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteuom(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUomid ALIAS FOR $1; BEGIN DELETE FROM uomconv WHERE uomconv_from_uom_id=pUomid; DELETE FROM uomconv WHERE uomconv_to_uom_id=pUomid; DELETE FROM uom WHERE uom_id=pUomid; RETURN 0; END; $_$; ALTER FUNCTION public.deleteuom(integer) OWNER TO admin; -- -- Name: deleteuomconv(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteuomconv(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUomconvid ALIAS FOR $1; BEGIN DELETE FROM uomconv WHERE uomconv_id=pUomconvid; RETURN 0; END; $_$; ALTER FUNCTION public.deleteuomconv(integer) OWNER TO admin; -- -- Name: deleteurl(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteurl(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ declare pId ALIAS FOR $1; begin delete from urlinfo where ( url_id in ( select url_id from urlinfo join docass on (docass_target_id=url_id) and (docass_target_type='URL') where ( docass_id = pId ) ) ); delete from docass where docass_id = pId; return true; end; $_$; ALTER FUNCTION public.deleteurl(integer) OWNER TO admin; -- -- Name: deleteuserpreference(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteuserpreference(text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrefname ALIAS FOR $1; _return BOOLEAN; BEGIN SELECT deleteUserPreference(getEffectiveXtUser(), pPrefname) INTO _return; RETURN _return; END; $_$; ALTER FUNCTION public.deleteuserpreference(text) OWNER TO admin; -- -- Name: deleteuserpreference(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deleteuserpreference(text, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pPrefname ALIAS FOR $2; BEGIN DELETE FROM usrpref WHERE ( (usrpref_username=pUsername) AND (usrpref_name=pPrefname) ); RETURN TRUE; END; $_$; ALTER FUNCTION public.deleteuserpreference(text, text) OWNER TO admin; -- -- Name: deletevendoraddress(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletevendoraddress(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendaddrid ALIAS FOR $1; _test INTEGER; BEGIN -- Check to see if the passed vendor address is used in pohead SELECT pohead_id INTO _test FROM pohead WHERE (pohead_vendaddr_id=pVendaddrid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; -- Delete the passed vendor address DELETE FROM vendaddrinfo WHERE (vendaddr_id=pVendaddrid); RETURN 0; END; $_$; ALTER FUNCTION public.deletevendoraddress(integer) OWNER TO admin; -- -- Name: deletevendortype(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletevendortype(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendtypeid ALIAS FOR $1; _test INTEGER; BEGIN -- Check to see if the passed vendor type is used in vendinfo SELECT vend_id INTO _test FROM vendinfo WHERE (vend_vendtype_id=pVendtypeid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; -- Delete the passed vendor type DELETE FROM vendtype WHERE (vendtype_id=pVendtypeid); RETURN 0; END; $_$; ALTER FUNCTION public.deletevendortype(integer) OWNER TO admin; -- -- Name: deletewo(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletewo(pwoid integer, pdeletechildren boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN deleteWo(pWoid, pDeleteChildren, FALSE); END; $$; ALTER FUNCTION public.deletewo(pwoid integer, pdeletechildren boolean) OWNER TO admin; -- -- Name: deletewo(integer, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletewo(pwoid integer, pdeletechildren boolean, pdeleteforce boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE woStatus CHAR(1); itemType CHAR(1); ordtype CHAR(1); ordid INTEGER; returnCode INTEGER; _wotcCnt INTEGER; _routings BOOLEAN; BEGIN SELECT wo_status, wo_ordtype, wo_ordid, item_type INTO woStatus, ordtype, ordid, itemType FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (wo_id=pWoid); IF (pDeleteForce) THEN IF (NOT woStatus IN ('O', 'E', 'R', 'C')) THEN RETURN -3; END IF; ELSE IF (NOT woStatus IN ('O', 'E')) THEN RETURN -3; END IF; IF (itemType = 'J') THEN RETURN -2; END IF; END IF; SELECT fetchMetricBool('Routings') INTO _routings; IF (_routings AND woStatus != 'C') THEN SELECT count(*) INTO _wotcCnt FROM xtmfg.wotc WHERE (wotc_wo_id=pWoid); IF (_wotcCnt > 0) THEN RETURN -1; END IF; END IF; IF (woStatus = 'R') THEN PERFORM postEvent('RWoRequestCancel', 'W', wo_id, itemsite_warehous_id, formatWoNumber(wo_id), NULL, NULL, NULL, NULL) FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (wo_id=pWoid); RETURN 0; ELSE IF (woStatus = 'E') THEN returnCode := (SELECT implodeWo(pWoid, FALSE)); END IF; END IF; IF (woStatus IN ('O', 'E', 'C')) THEN DELETE FROM womatl WHERE (womatl_wo_id=pWoid); IF _routings THEN DELETE FROM xtmfg.wotc WHERE (wotc_wo_id=pWoid); DELETE FROM xtmfg.wooper WHERE (wooper_wo_id=pWoid); END IF; IF (ordtype = 'S') THEN UPDATE coitem SET coitem_order_type=NULL, coitem_order_id=NULL WHERE coitem_id=ordid; END IF; DELETE FROM wo WHERE (wo_id=pWoid); END IF; IF (pDeleteChildren) THEN returnCode := (SELECT MAX(deleteWo(wo_id, TRUE)) FROM wo WHERE ((wo_ordtype='W') AND (wo_ordid=pWoid))); END IF; RETURN 0; END; $$; ALTER FUNCTION public.deletewo(pwoid integer, pdeletechildren boolean, pdeleteforce boolean) OWNER TO admin; -- -- Name: deletewomaterial(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION deletewomaterial(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; BEGIN UPDATE wo SET wo_adhoc=TRUE FROM womatl WHERE ((womatl_wo_id=wo_id) AND (womatl_id=pWomatlid)); -- Delete any created P/R for this Womatl PERFORM deletePr('W', pWomatlid); DELETE FROM womatl WHERE (womatl_id=pWomatlid); RETURN 0; END; $_$; ALTER FUNCTION public.deletewomaterial(integer) OWNER TO admin; -- -- Name: detachccpayfromso(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION detachccpayfromso(integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pcoheadid ALIAS FOR $1; pwarehousid ALIAS FOR $2; pcustid ALIAS FOR $3; BEGIN RAISE WARNING 'detachCCPayFromSO(INTEGER, INTEGER, INTEGER): deprecated'; RETURN 0; END; $_$; ALTER FUNCTION public.detachccpayfromso(integer, integer, integer) OWNER TO admin; -- -- Name: detachcontact(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION detachcontact(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pcntctId ALIAS FOR $1; pcrmacctId ALIAS FOR $2; BEGIN UPDATE cntct SET cntct_crmacct_id = NULL WHERE cntct_id = pcntctId AND cntct_crmacct_id = pcrmacctId; UPDATE crmacct SET crmacct_cntct_id_1 = NULL WHERE crmacct_id = pcrmacctId AND crmacct_cntct_id_1 = pcntctId; UPDATE crmacct SET crmacct_cntct_id_2 = NULL WHERE crmacct_id = pcrmacctId AND crmacct_cntct_id_2 = pcntctId; RETURN 0; END; $_$; ALTER FUNCTION public.detachcontact(integer, integer) OWNER TO admin; -- -- Name: detag(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION detag(text) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSource ALIAS FOR $1; _result TEXT := ''; BEGIN SELECT regexp_replace(pSource, E'<[^>]*>', '', 'g') INTO _result; RETURN _result; END; $_$; ALTER FUNCTION public.detag(text) OWNER TO admin; -- -- Name: detailednnqoh(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION detailednnqoh(integer, boolean) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- -- Deprecated -- DECLARE pItemsiteid ALIAS FOR $1; pABS ALIAS FOR $2; _qoh NUMERIC; BEGIN IF (pABS) THEN SELECT SUM(noNeg(itemloc_qty)) INTO _qoh FROM itemloc, location WHERE ( (itemloc_location_id=location_id) AND (NOT location_netable) AND (itemloc_itemsite_id=pItemsiteid) ); ELSE SELECT SUM(itemloc_qty) INTO _qoh FROM itemloc, location WHERE ( (itemloc_location_id=location_id) AND (NOT location_netable) AND (itemloc_itemsite_id=pItemsiteid) ); END IF; IF (_qoh IS NULL) THEN _qoh := 0; END IF; RETURN _qoh; END; $_$; ALTER FUNCTION public.detailednnqoh(integer, boolean) OWNER TO admin; -- -- Name: detailedqoh(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION detailedqoh(pitemsiteid integer, pabs boolean) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _qoh NUMERIC; BEGIN IF (pABS) THEN SELECT SUM(noNeg(itemloc_qty)) INTO _qoh FROM itemloc WHERE (itemloc_itemsite_id=pItemsiteid); ELSE SELECT SUM(itemloc_qty) INTO _qoh FROM itemloc WHERE (itemloc_itemsite_id=pItemsiteid); END IF; IF (_qoh IS NULL) THEN _qoh := 0.0; END IF; RETURN _qoh; END; $$; ALTER FUNCTION public.detailedqoh(pitemsiteid integer, pabs boolean) OWNER TO admin; -- -- Name: determinediscountdate(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION determinediscountdate(integer, date) RETURNS date LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTermsid ALIAS FOR $1; pSourceDate ALIAS FOR $2; _discDate DATE; _p RECORD; BEGIN SELECT terms_type, terms_discdays, terms_cutoffday INTO _p FROM terms WHERE (terms_id=pTermsid); IF (NOT FOUND) THEN _discDate := pSourceDate; -- Handle type D terms ELSIF (_p.terms_type = 'D') THEN _discDate := (pSourceDate + _p.terms_discdays); -- Handle type P terms ELSIF (_p.terms_type = 'P') THEN IF (date_part('day', pSourceDate) <= _p.terms_cutoffday) THEN _discDate := (DATE(date_trunc('month', pSourceDate)) + (_p.terms_discdays - 1)); ELSE _discDate := (DATE(date_trunc('month', pSourceDate)) + (_p.terms_discdays - 1) + INTERVAL '1 month'); END IF; -- Handle unknown terms ELSE _discDate := pSourceDate; END IF; RETURN _discDate; END; $_$; ALTER FUNCTION public.determinediscountdate(integer, date) OWNER TO admin; -- -- Name: determineduedate(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION determineduedate(integer, date) RETURNS date LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTermsid ALIAS FOR $1; pSourceDate ALIAS FOR $2; _dueDate DATE; _p RECORD; BEGIN SELECT terms_type, terms_duedays, terms_cutoffday INTO _p FROM terms WHERE (terms_id=pTermsid); IF (NOT FOUND) THEN _dueDate := pSourceDate; -- Handle type D terms ELSIF (_p.terms_type = 'D') THEN _dueDate := (pSourceDate + _p.terms_duedays); -- Handle type P terms ELSIF (_p.terms_type = 'P') THEN IF (date_part('day', pSourceDate) <= _p.terms_cutoffday) THEN _dueDate := (DATE(date_trunc('month', pSourceDate)) + (_p.terms_duedays - 1)); ELSE _dueDate := (DATE(date_trunc('month', pSourceDate)) + (_p.terms_duedays - 1) + INTERVAL '1 month'); END IF; -- Handle unknown terms ELSE _dueDate := pSourceDate; END IF; RETURN _dueDate; END; $_$; ALTER FUNCTION public.determineduedate(integer, date) OWNER TO admin; -- -- Name: digest(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION digest(text, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_digest'; ALTER FUNCTION public.digest(text, text) OWNER TO admin; -- -- Name: digest(bytea, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION digest(bytea, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_digest'; ALTER FUNCTION public.digest(bytea, text) OWNER TO admin; -- -- Name: disablepackage(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION disablepackage(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ppkgname ALIAS FOR $1; _i INTEGER := 0; _tabs TEXT[] := ARRAY['cmd', 'cmdarg', 'image', 'metasql', 'priv', 'report', 'script', 'uiform']; BEGIN IF (version() < 'PostgreSQL 8.2') THEN RETURN -1; END IF; FOR _i IN ARRAY_LOWER(_tabs,1)..ARRAY_UPPER(_tabs,1) LOOP EXECUTE 'ALTER TABLE ' || ppkgname || '.pkg' || _tabs[_i] || ' NO INHERIT public.' || _tabs[_i] || ';'; END LOOP; RETURN 0; END; $_$; ALTER FUNCTION public.disablepackage(text) OWNER TO admin; -- -- Name: disablepackage(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION disablepackage(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ppkgheadid ALIAS FOR $1; _pkgname TEXT; BEGIN SELECT pkghead_name INTO _pkgname FROM pkghead WHERE (pkghead_id=ppkgheadid); IF (NOT FOUND) THEN RETURN -2; END IF; RETURN disablePackage(_pkgname); END; $_$; ALTER FUNCTION public.disablepackage(integer) OWNER TO admin; -- -- Name: distributeitemlocseries(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION distributeitemlocseries(pitemlocseries integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _distCounter INTEGER; _itemlocdist RECORD; _itemlocid INTEGER; _invhistid INTEGER; _check BOOLEAN; _debug BOOLEAN := false; BEGIN IF (_debug) THEN RAISE NOTICE 'distributeItemlocSeries, series=%', pItemlocSeries; END IF; _distCounter := 0; -- March through all of the itemlocdists for pItemlocSeries FOR _itemlocdist IN SELECT itemlocdist_id AS itemlocdistid, itemlocdist_source_type AS type, itemlocdist_source_id AS sourceid, itemlocdist_qty AS qty, itemlocdist_itemsite_id AS itemsiteid, itemsite_freeze, itemlocdist_invhist_id AS invhistid, itemlocdist_ls_id AS lotserialid, itemlocdist_expiration AS expiration, itemlocdist_flush, itemlocdist_warranty AS warranty, itemlocdist_series AS series FROM itemlocdist, itemsite WHERE ( (itemlocdist_itemsite_id=itemsite_id) AND (itemlocdist_series=pItemlocSeries) ) ORDER BY itemlocdist_flush DESC LOOP _distCounter := _distCounter + 1; IF (_debug) THEN RAISE NOTICE 'itemlocdist loop %', _distCounter; RAISE NOTICE 'itemlocdistid=%', _itemlocdist.itemlocdistid; RAISE NOTICE 'type=%', _itemlocdist.type; RAISE NOTICE 'sourceid=%', _itemlocdist.sourceid; RAISE NOTICE 'qty=%', _itemlocdist.qty; RAISE NOTICE 'itemsiteid=%', _itemlocdist.itemsiteid; RAISE NOTICE 'freeze=%', _itemlocdist.itemsite_freeze; RAISE NOTICE 'invhistid=%', _itemlocdist.invhistid; RAISE NOTICE 'lotserialid=%', _itemlocdist.lotserialid; RAISE NOTICE 'expiration=%', _itemlocdist.expiration; RAISE NOTICE 'flush=%', _itemlocdist.itemlocdist_flush; RAISE NOTICE 'warranty=%', _itemlocdist.warranty; END IF; -- Commit invhist to itemsite IF (NOT _itemlocdist.itemsite_freeze) THEN PERFORM postInvHist(_itemlocdist.invhistid); END IF; -- Mark the invhist tuple for the itemlocdist in question as having detail UPDATE invhist SET invhist_hasdetail=TRUE WHERE ( (NOT invhist_hasdetail) AND (invhist_id=_itemlocdist.invhistid) ); -- If this itemlocdist is a flush, write a invdetail tuple that records the empty IF (_itemlocdist.itemlocdist_flush) THEN INSERT INTO invdetail ( invdetail_invhist_id, invdetail_location_id, invdetail_ls_id, invdetail_qty, invdetail_qty_before, invdetail_qty_after, invdetail_expiration, invdetail_warrpurc ) SELECT _itemlocdist.invhistid, itemloc_location_id, itemloc_ls_id, (itemloc_qty * -1), itemloc_qty, 0, itemloc_expiration, _itemlocdist.warranty FROM itemloc WHERE ( (itemloc_qty <> 0) AND (itemloc_id=_itemlocdist.sourceid) ); -- Delete the flushed itemloc if its parent itemsite is not frozen IF (NOT _itemlocdist.itemsite_freeze) THEN DELETE FROM itemloc WHERE (itemloc_id=_itemlocdist.sourceid); END IF; ELSE -- If this is a location type distribution, check to see if the target itemloc -- already exists IF (_itemlocdist.type = 'L') THEN SELECT itemloc_id INTO _itemlocid FROM itemloc WHERE ( (itemloc_itemsite_id=_itemlocdist.itemsiteid) AND (itemloc_location_id=_itemlocdist.sourceid) AND (COALESCE(itemloc_ls_id,-1)=COALESCE(_itemlocdist.lotserialid,-1)) AND (COALESCE(itemloc_expiration,endOfTime())=COALESCE(_itemlocdist.expiration,endOfTime())) AND (COALESCE(itemloc_warrpurc,endoftime())=COALESCE(_itemlocdist.warranty,endoftime())) ); -- Nope, create it IF (NOT FOUND) THEN SELECT NEXTVAL('itemloc_itemloc_id_seq') INTO _itemlocid; INSERT INTO itemloc ( itemloc_id, itemloc_itemsite_id, itemloc_location_id, itemloc_qty, itemloc_ls_id, itemloc_expiration, itemloc_warrpurc ) VALUES ( _itemlocid, _itemlocdist.itemsiteid, _itemlocdist.sourceid, 0, _itemlocdist.lotserialid, _itemlocdist.expiration, _itemlocdist.warranty ); END IF; ELSE _itemlocid = _itemlocdist.sourceid; IF (_itemlocid IS NOT NULL AND (SELECT count(itemloc_id) = 0 FROM itemloc WHERE itemloc_id=_itemlocid)) THEN RAISE EXCEPTION 'No record to distribute against. Someone else may have already distributed this record.'; END IF; END IF; -- Record the invdetail INSERT INTO invdetail (invdetail_invhist_id, invdetail_location_id, invdetail_ls_id, invdetail_qty, invdetail_qty_before, invdetail_qty_after, invdetail_expiration, invdetail_warrpurc) SELECT _itemlocdist.invhistid, itemloc_location_id, _itemlocdist.lotserialid, _itemlocdist.qty, itemloc_qty, (itemloc_qty + _itemlocdist.qty), itemloc_expiration,_itemlocdist.warranty FROM itemloc WHERE (itemloc_id=_itemlocid); -- Update the itemloc_qty if its parent itemsite is not frozen IF (NOT _itemlocdist.itemsite_freeze) THEN UPDATE itemloc SET itemloc_qty = (itemloc_qty + _itemlocdist.qty) WHERE (itemloc_id=_itemlocid); END IF; END IF; -- If, after the distribution, the target itemloc_qty = 0, delete the itemloc -- if its parent itemsite is not frozen IF (NOT _itemlocdist.itemsite_freeze) THEN DELETE FROM itemloc WHERE ( (itemloc_qty=0) AND (itemloc_id=_itemlocid) ); END IF; END LOOP; DELETE FROM itemlocdist WHERE (itemlocdist_series=pItemlocSeries); RETURN _distCounter; END; $$; ALTER FUNCTION public.distributeitemlocseries(pitemlocseries integer) OWNER TO admin; -- -- Name: distributetodefault(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION distributetodefault(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemlocdistid ALIAS FOR $1; BEGIN RETURN distributeToDefault(pItemlocdistid, 'O'); END; $_$; ALTER FUNCTION public.distributetodefault(integer) OWNER TO admin; -- -- Name: distributetodefault(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION distributetodefault(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemlocdistid ALIAS FOR $1; pTranstype ALIAS FOR $2; _locationid INTEGER; _itemlocdistid INTEGER; _qty NUMERIC; BEGIN -- Make sure that the itemsite in question has a default location SELECT CASE WHEN (pTranstype='R') THEN itemsite_recvlocation_id WHEN (pTranstype='I') THEN itemsite_issuelocation_id ELSE itemsite_location_id END INTO _locationid FROM itemlocdist, itemsite WHERE ( (itemlocdist_itemsite_id=itemsite_id) AND (itemlocdist_id=pItemlocdistid) ); IF ( (NOT FOUND) OR (_locationid = -1) ) THEN RETURN -1; END IF; -- Determine the remaining qty required to distribute SELECT (p.itemlocdist_qty - COALESCE(SUM(c.itemlocdist_qty), 0)) INTO _qty FROM itemlocdist AS p LEFT OUTER JOIN itemlocdist AS c ON (c.itemlocdist_itemlocdist_id=p.itemlocdist_id) WHERE (p.itemlocdist_id=pItemlocdistid) GROUP BY p.itemlocdist_qty; IF (_qty = 0) THEN RETURN -2; END IF; -- Check to see if an itemlocdist with the correct location/lotserial/expiration already exists SELECT target.itemlocdist_id INTO _itemlocdistid FROM itemlocdist AS source, itemlocdist AS target, itemloc, itemsite WHERE ( (target.itemlocdist_source_type='L') AND (target.itemlocdist_source_id=_locationid) AND (target.itemlocdist_itemsite_id=source.itemlocdist_itemsite_id) AND (COALESCE(target.itemlocdist_ls_id)=COALESCE(source.itemlocdist_ls_id)) AND (target.itemlocdist_expiration=source.itemlocdist_expiration) AND (target.itemlocdist_itemlocdist_id=source.itemlocdist_itemlocdist_id) AND (target.itemlocdist_itemsite_id=itemsite_id) AND (source.itemlocdist_id=pItemlocdistid) ); IF (FOUND) THEN UPDATE itemlocdist SET itemlocdist_qty = (itemlocdist_qty + _qty) WHERE (itemlocdist_id=_itemlocdistid); RETURN _itemlocdistid; END IF; -- Create a new itemlocdist SELECT NEXTVAL('itemlocdist_itemlocdist_id_seq') INTO _itemlocdistid; INSERT INTO itemlocdist ( itemlocdist_id, itemlocdist_itemlocdist_id, itemlocdist_source_type, itemlocdist_ls_id, itemlocdist_expiration, itemlocdist_source_id, itemlocdist_itemsite_id, itemlocdist_qty ) SELECT _itemlocdistid, pItemlocdistid, 'L', itemlocdist_ls_id, itemlocdist_expiration, _locationid, itemlocdist_itemsite_id, _qty FROM itemlocdist WHERE (itemlocdist_id=pItemlocdistid); RETURN _itemlocdistid; END; $_$; ALTER FUNCTION public.distributetodefault(integer, text) OWNER TO admin; -- -- Name: distributetodefaultitemloc(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION distributetodefaultitemloc(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemlocdistid ALIAS FOR $1; BEGIN RETURN distributeToDefaultItemLoc(pItemlocdistid, 'O'); END; $_$; ALTER FUNCTION public.distributetodefaultitemloc(integer) OWNER TO admin; -- -- Name: distributetodefaultitemloc(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION distributetodefaultitemloc(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemlocdistid ALIAS FOR $1; pTranstype ALIAS FOR $2; _itemlocid INTEGER; _itemlocdistid INTEGER; _qty NUMERIC; BEGIN -- Make sure that the itemsite in question has a default location SELECT itemloc_id INTO _itemlocid FROM itemlocdist, itemsite, itemloc WHERE ((itemlocdist_itemsite_id=itemsite_id) AND ( (itemsite_location_id=itemloc_location_id AND pTranstype='O') OR (itemsite_recvlocation_id=itemloc_location_id AND pTranstype='R') OR (itemsite_issuelocation_id=itemloc_location_id AND pTranstype='I') ) AND (itemloc_itemsite_id=itemsite_id) AND (itemlocdist_id=pItemlocdistid)); IF ( (NOT FOUND) OR (_itemlocid = -1) ) THEN RETURN -1; END IF; -- Determine the remaining qty required to distribute SELECT (p.itemlocdist_qty - COALESCE(SUM(c.itemlocdist_qty), 0)) INTO _qty FROM itemlocdist AS p LEFT OUTER JOIN itemlocdist AS c ON (c.itemlocdist_itemlocdist_id=p.itemlocdist_id) WHERE (p.itemlocdist_id=pItemlocdistid) GROUP BY p.itemlocdist_qty; IF (_qty = 0) THEN RETURN -2; END IF; -- Check to see if an itemlocdist with the correct location/lotserial/expiration already exists SELECT target.itemlocdist_id INTO _itemlocdistid FROM itemlocdist AS source, itemlocdist AS target WHERE ( (target.itemlocdist_source_type='I') AND (target.itemlocdist_source_id=_itemlocid) AND (COALESCE(target.itemlocdist_ls_id,-1)=COALESCE(source.itemlocdist_ls_id,-1)) AND (target.itemlocdist_expiration=source.itemlocdist_expiration) AND (target.itemlocdist_itemlocdist_id=source.itemlocdist_id) AND (source.itemlocdist_id=pItemlocdistid) ); IF (FOUND) THEN UPDATE itemlocdist SET itemlocdist_qty = (itemlocdist_qty + _qty) WHERE (itemlocdist_id=_itemlocdistid); RETURN _itemlocdistid; END IF; -- Create a new itemlocdist SELECT NEXTVAL('itemlocdist_itemlocdist_id_seq') INTO _itemlocdistid; INSERT INTO itemlocdist ( itemlocdist_id, itemlocdist_itemlocdist_id, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_qty, itemlocdist_expiration ) VALUES ( _itemlocdistid, pItemlocdistid, 'I', _itemlocid, _qty, endOfTime() ); RETURN _itemlocdistid; END; $_$; ALTER FUNCTION public.distributetodefaultitemloc(integer, text) OWNER TO admin; -- -- Name: distributetolocations(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION distributetolocations(pitemlocdistid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _distCounter INTEGER; _itemlocdist RECORD; _itemlocid INTEGER; _runningQty NUMERIC; _tmp RECORD; BEGIN _distCounter := 0; _runningQty := 0; -- A scenario can occur where two people try to post distributions -- to the same itemsite against two or more lot/serial/mlc locations -- leading to a deadlock. This line tries to prevent that by locking -- ahead of time all the itemsites that the transaction will need -- before any of the other tables are locked individually. SELECT itemsite_id INTO _tmp FROM itemsite WHERE(itemsite_id in (SELECT DISTINCT itemlocdist_itemsite_id FROM itemlocdist WHERE(itemlocdist_id=pItemlocdistid))) FOR UPDATE; -- March through all of the itemlocdist owned by the passed parent itemlocdist FOR _itemlocdist IN SELECT c.itemlocdist_id AS itemlocdistid, c.itemlocdist_source_type AS type, c.itemlocdist_source_id AS sourceid, c.itemlocdist_qty AS qty, p.itemlocdist_itemsite_id AS itemsiteid, itemsite_freeze, p.itemlocdist_invhist_id AS invhistid, p.itemlocdist_ls_id AS lotserialid, p.itemlocdist_expiration AS expiration, p.itemlocdist_warranty AS warranty, p.itemlocdist_order_type AS ordertype, p.itemlocdist_order_id AS orderid, p.itemlocdist_series AS series FROM itemlocdist AS c, itemlocdist AS p, itemsite WHERE ( (c.itemlocdist_itemlocdist_id=p.itemlocdist_id) AND (p.itemlocdist_source_type='O') AND (p.itemlocdist_itemsite_id=itemsite_id) AND (p.itemlocdist_id=pItemlocdistid) ) LOOP _distCounter := _distCounter + 1; -- If the target for this itemlocdist is a location, check to see if the -- required itemloc already exists IF (_itemlocdist.type = 'L') THEN SELECT itemloc_id INTO _itemlocid FROM itemloc WHERE ( (itemloc_itemsite_id=_itemlocdist.itemsiteid) AND (itemloc_location_id=_itemlocdist.sourceid) AND (COALESCE(itemloc_ls_id, -1)=COALESCE(_itemlocdist.lotserialid, -1)) AND (COALESCE(itemloc_expiration,endOfTime())=COALESCE(_itemlocdist.expiration,endOfTime())) AND (COALESCE(itemloc_warrpurc,endoftime())=COALESCE(_itemlocdist.warranty,endoftime())) ); -- Nope, make it IF (NOT FOUND) THEN SELECT NEXTVAL('itemloc_itemloc_id_seq') INTO _itemlocid; INSERT INTO itemloc ( itemloc_id, itemloc_itemsite_id, itemloc_location_id, itemloc_qty, itemloc_ls_id, itemloc_expiration, itemloc_warrpurc ) VALUES ( _itemlocid, _itemlocdist.itemsiteid, _itemlocdist.sourceid, 0, _itemlocdist.lotserialid, _itemlocdist.expiration, _itemlocdist.warranty ); END IF; ELSE -- Yep, cache it _itemlocid = _itemlocdist.sourceid; IF (_itemlocid IS NOT NULL AND (SELECT count(itemloc_id) = 0 FROM itemloc WHERE itemloc_id=_itemlocid)) THEN RAISE EXCEPTION 'No record to distribute against. Someone else may have already distributed this record.'; END IF; END IF; -- Record the invdetail for this itemlocdist INSERT INTO invdetail ( invdetail_invhist_id, invdetail_location_id, invdetail_ls_id, invdetail_qty, invdetail_qty_before, invdetail_qty_after, invdetail_expiration, invdetail_warrpurc ) SELECT _itemlocdist.invhistid, itemloc_location_id, itemloc_ls_id, _itemlocdist.qty, itemloc_qty, (itemloc_qty + _itemlocdist.qty), itemloc_expiration,_itemlocdist.warranty FROM itemloc WHERE (itemloc_id=_itemlocid); -- Update the parent invhist to indicate that it has invdetail records UPDATE invhist SET invhist_hasdetail=TRUE WHERE ((invhist_hasdetail=FALSE) AND (invhist_id=_itemlocdist.invhistid)); -- Update the itemloc_qty if its parent itemsite is not frozen IF (NOT _itemlocdist.itemsite_freeze) THEN UPDATE itemloc SET itemloc_qty = (itemloc_qty + _itemlocdist.qty) WHERE (itemloc_id=_itemlocid); PERFORM postInvHist(_itemlocdist.invhistid); -- Handle reservation data IF ( (SELECT fetchMetricBool('EnableSOReservationsByLocation')) AND (_itemlocdist.qty < 0) ) THEN -- If a shipment on a sales order, record reservation change before updating -- so it can be reversed later if necessary IF (_itemlocdist.ordertype = 'SO') THEN INSERT INTO shipitemlocrsrv SELECT nextval('shipitemlocrsrv_shipitemlocrsrv_id_seq'), shipitem_id, itemloc_itemsite_id, itemloc_location_id, itemloc_ls_id, itemloc_expiration, itemloc_warrpurc, least((_itemlocdist.qty * -1.0), reserve_qty) FROM shipitem, itemloc JOIN reserve ON (itemloc_id=reserve_supply_id AND reserve_supply_type='I') WHERE ( (shipitem_invhist_id=_itemlocdist.invhistid) AND (itemloc_id=_itemlocid) AND (reserve_demand_type=_itemlocdist.ordertype) AND (reserve_demand_id=_itemlocdist.orderid) ); END IF; -- Update the reservation UPDATE reserve SET reserve_qty = (reserve_qty + _itemlocdist.qty) WHERE ( (reserve_supply_id=_itemlocid) AND (reserve_supply_type='I') AND (reserve_demand_type=_itemlocdist.ordertype) AND (reserve_demand_id=_itemlocdist.orderid) ); -- Delete reservation if fully distributed DELETE FROM reserve WHERE ( (reserve_supply_id=_itemlocid) AND (reserve_supply_type='I') AND (reserve_demand_type=_itemlocdist.ordertype) AND (reserve_demand_id=_itemlocdist.orderid) AND (reserve_qty=0) ); END IF; END IF; -- Cache the running qty. _runningQty := _runningQty + _itemlocdist.qty; -- Dene with the child itemlocdist, so delete it DELETE FROM itemlocdist WHERE (itemlocdist_id=_itemlocdist.itemlocdistid); -- If the target itemloc is now at qty=0, delete it if its parent -- itemsite is not frozen IF (NOT _itemlocdist.itemsite_freeze) THEN DELETE FROM itemloc WHERE ( (itemloc_qty=0) AND (itemloc_id=_itemlocid) ); END IF; END LOOP; -- If the running qty for the detailed distributions is the same as the -- total qty to distribute indicated by the parent itemlocdist, then the -- parent itemlocdist has been fully distributed and should be deleted. IF ( ( SELECT itemlocdist_qty FROM itemlocdist WHERE (itemlocdist_id=pItemlocdistid) ) = _runningQty) THEN DELETE FROM itemlocdist WHERE (itemlocdist_id=pItemlocdistid); ELSE -- There is still some more qty to distribute in the parent itemlocdist. -- Update the qty to distribute with the qty that has been distributed. UPDATE itemlocdist SET itemlocdist_qty = (itemlocdist_qty - _runningQty) WHERE (itemlocdist_id=pItemlocdistid); END IF; RETURN _distCounter; END; $$; ALTER FUNCTION public.distributetolocations(pitemlocdistid integer) OWNER TO admin; -- -- Name: distributevoucherline(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION distributevoucherline(integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVoucherId ALIAS FOR $1; pPoitemId ALIAS FOR $2; pCurrId ALIAS FOR $3; _count INTEGER; _costelemId INTEGER; _close BOOLEAN; _r RECORD; _qtyOrdered NUMERIC; _voitemId INTEGER; _taxtypeid INTEGER; BEGIN -- Make sure the P/O and Voucher are same currency SELECT COALESCE(COUNT(*),0) INTO _count FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id) WHERE ((poitem_id=pPoitemid) AND (pohead_curr_id=pCurrId)); IF (_count = 0) THEN RETURN -3; END IF; -- Validate and get cost element SELECT COALESCE(COUNT(*),0) INTO _count FROM itemcost, item, itemsite, poitem WHERE ((itemcost_item_id=item_id) AND (item_id=itemsite_item_id) AND (itemsite_id=poitem_itemsite_id) AND (poitem_id=pPoitemId)); IF (_count > 1) THEN RETURN -5; ELSEIF (_count = 1) THEN SELECT itemcost_costelem_id INTO _costelemId FROM itemcost, item, itemsite, poitem WHERE ((itemcost_item_id=item_id) AND (item_id=itemsite_item_id) AND (itemsite_id=poitem_itemsite_id) AND (poitem_id=pPoitemId)); ELSE SELECT costelem_id INTO _costelemId FROM costelem WHERE (costelem_type='Material'); END IF; -- Clear previous distributions UPDATE recv SET recv_vohead_id=NULL, recv_voitem_id=NULL WHERE ((recv_vohead_id=pVoucherId) AND (recv_orderitem_id=pPoitemId) AND (recv_order_type='PO')); UPDATE poreject SET poreject_vohead_id=NULL, poreject_voitem_id=NULL WHERE ((poreject_vohead_id=pVoucherId) AND (poreject_poitem_id=pPoitemId)); DELETE FROM vodist WHERE ((vodist_poitem_id=pPoitemId) AND (vodist_vohead_id=pVoucherId)); DELETE FROM voitem WHERE ((voitem_poitem_id=pPoitemId) AND (voitem_vohead_id=pVoucherId)); -- Determine Line balances SELECT COALESCE(SUM(qty_received),0) AS qty_received, COALESCE(SUM(qty_rejected),0) AS qty_rejected, COALESCE(SUM(qty_vouchered),0) AS qty_vouchered, round(COALESCE(SUM(balance),0),2) AS balance, round(COALESCE(SUM(freight),0),2) AS freight INTO _r FROM ( SELECT recv_qty AS qty_received, 0 AS qty_rejected, 0 AS qty_vouchered, (recv_qty * COALESCE(recv_purchcost, poitem_unitprice)) AS balance, recv_freight AS freight FROM poitem JOIN recv ON ((recv_orderitem_id=poitem_id) AND (recv_order_type='PO')) WHERE ( (recv_vohead_id IS NULL) AND (NOT recv_invoiced) AND (recv_posted) AND (poitem_id=pPoitemId) ) UNION ALL SELECT 0 AS qty_received, (poreject_qty) AS qty_rejected, 0 AS qty_vouchered, (poreject_qty * -1 * COALESCE(recv_purchcost, poitem_unitprice)) AS balance, 0 AS freight FROM poitem JOIN poreject ON (poreject_poitem_id=poitem_id) LEFT OUTER JOIN recv ON (recv_id=poreject_recv_id) WHERE ( (poreject_posted) AND (poreject_vohead_id IS NULL) AND (NOT poreject_invoiced) AND (poitem_id=pPoitemId) ) UNION ALL SELECT 0 AS qty_received, 0 AS qty_rejected, voitem_qty AS qty_vouchered, 0 AS balance, 0 AS freight FROM voitem, poitem WHERE ( (voitem_poitem_id=pPoitemId) AND (poitem_id=voitem_poitem_id) ) ) AS data; SELECT poitem_qty_ordered INTO _qtyOrdered FROM poitem WHERE (poitem_id=pPoitemId); IF _r.balance < 0 THEN RETURN -4; ELSEIF ( ((_r.qty_received <> 0) OR (_r.qty_received <> 0)) AND (_r.qty_received - _r.qty_rejected = 0) ) THEN RETURN -2; ELSEIF ((_r.qty_received - _r.qty_rejected) = 0) THEN RETURN 0; END IF; -- Determine whether to close P/O item IF (_r.qty_received -_r.qty_rejected + _r.qty_vouchered) >= _qtyOrdered THEN _close:=True; ELSE _close:=False; END IF; -- Create distribution INSERT INTO vodist (vodist_poitem_id,vodist_vohead_id,vodist_costelem_id,vodist_amount,vodist_qty,vodist_expcat_id) VALUES (pPoitemId,pVoucherId,_costelemId,_r.balance,(_r.qty_received -_r.qty_rejected),-1); -- Create voucher item SELECT poitem_taxtype_id INTO _taxtypeid FROM poitem WHERE (poitem_id=pPoitemId); SELECT NEXTVAL('voitem_voitem_id_seq') INTO _voitemId; INSERT INTO voitem (voitem_id,voitem_vohead_id,voitem_poitem_id,voitem_close,voitem_qty,voitem_freight, voitem_taxtype_id) VALUES (_voitemId,pVoucherId,pPoitemId,_close,(_r.qty_received -_r.qty_rejected),_r.freight, _taxtypeid); -- Tag receipt records UPDATE recv SET recv_vohead_id=pVoucherId, recv_voitem_id=_voitemId WHERE ((recv_orderitem_id=pPoitemId) AND (recv_order_type='PO') AND (recv_vohead_id IS NULL)); UPDATE poreject SET poreject_vohead_id=pVoucherId,poreject_voitem_id=_voitemId WHERE ((poreject_poitem_id=pPoitemId) AND (NOT poreject_invoiced) AND (poreject_vohead_id IS NULL)); RETURN 1; END; $_$; ALTER FUNCTION public.distributevoucherline(integer, integer, integer) OWNER TO admin; -- -- Name: dopostcosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION dopostcosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pMaterial ALIAS FOR $1; plowerMaterial ALIAS FOR $2; pdirectLabor ALIAS FOR $3; plowerDirectLabor ALIAS FOR $4; poverhead ALIAS FOR $5; plowerOverhead ALIAS FOR $6; pmachOverhead ALIAS FOR $7; plowerMachOverhead ALIAS FOR $8; pUser ALIAS FOR $9; plowerUser ALIAS FOR $10; prollUp ALIAS FOR $11; _item RECORD; _result INTEGER := 0; BEGIN PERFORM resetLowLevelCode(-1); FOR _item IN SELECT costUpdate_item_id FROM costUpdate ORDER BY costUpdate_lowlevel_code DESC LOOP PERFORM doPostCosts(_item.costUpdate_item_id, FALSE, pMaterial, plowerMaterial, pdirectLabor, plowerDirectLabor, poverhead, plowerOverhead, pmachOverhead, plowerMachOverhead, puser, plowerUser, prollUp); END LOOP; RETURN _result; END; $_$; ALTER FUNCTION public.dopostcosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) OWNER TO admin; -- -- Name: dopostcosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION dopostcosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemId ALIAS FOR $1; pResetLowLevel ALIAS FOR $2; pMaterial ALIAS FOR $3; plowerMaterial ALIAS FOR $4; pdirectLabor ALIAS FOR $5; plowerDirectLabor ALIAS FOR $6; poverhead ALIAS FOR $7; plowerOverhead ALIAS FOR $8; pmachOverhead ALIAS FOR $9; plowerMachOverhead ALIAS FOR $10; pUser ALIAS FOR $11; plowerUser ALIAS FOR $12; prollUp ALIAS FOR $13; _itemcost RECORD; _result INTEGER; BEGIN IF (pResetLowLevel) THEN PERFORM resetLowLevelCode(pItemId); END IF; FOR _itemcost IN SELECT itemcost_id, costelem_sys, costelem_type, itemcost_lowlevel, costUpdate_lowlevel_code, costUpdate_item_type FROM itemcost, costelem, costUpdate WHERE itemcost_item_id = pItemId AND costUpdate_item_id = itemcost_item_id AND itemcost_costelem_id = costelem_id LOOP IF (NOT _itemcost.costelem_sys) THEN IF ( (pUser) AND ( NOT _itemcost.itemcost_lowlevel) ) THEN PERFORM postCost(_itemcost.itemcost_id); _result := _result + 1; END IF; IF ( (plowerUser) AND ( _itemcost.itemcost_lowlevel) ) THEN PERFORM postCost(_itemcost.itemcost_id); _result := _result + 1; END IF; END IF; IF (_itemcost.costelem_type = 'Material') THEN IF ( (pMaterial) AND ( NOT _itemcost.itemcost_lowlevel) ) THEN PERFORM postCost(_itemcost.itemcost_id); _result := _result + 1; END IF; IF ( (plowerMaterial) AND ( _itemcost.itemcost_lowlevel) ) THEN PERFORM postCost(_itemcost.itemcost_id); _result := _result + 1; END IF; END IF; IF (_itemcost.costelem_type = 'Direct Labor') THEN IF ( (pdirectLabor) AND ( NOT _itemcost.itemcost_lowlevel) ) THEN PERFORM postCost(_itemcost.itemcost_id); _result := _result + 1; END IF; IF ( (plowerDirectLabor) AND ( _itemcost.itemcost_lowlevel) ) THEN PERFORM postCost(_itemcost.itemcost_id); _result := _result + 1; END IF; END IF; IF (_itemcost.costelem_type = 'Overhead') THEN IF ( (poverhead) AND ( NOT _itemcost.itemcost_lowlevel) ) THEN PERFORM postCost(_itemcost.itemcost_id); _result := _result + 1; END IF; IF ( (plowerOverhead) AND ( _itemcost.itemcost_lowlevel) ) THEN PERFORM postCost(_itemcost.itemcost_id); _result := _result + 1; END IF; END IF; IF (_itemcost.costelem_type = 'Machine Overhead') THEN IF ( (pmachOverhead) AND ( NOT _itemcost.itemcost_lowlevel) ) THEN PERFORM postCost(_itemcost.itemcost_id); _result := _result + 1; END IF; IF ( (plowerMachOverhead) AND ( _itemcost.itemcost_lowlevel) ) THEN PERFORM postCost(_itemcost.itemcost_id); _result := _result + 1; END IF; END IF; END LOOP; IF (prollUp) THEN PERFORM rollUpStandardCost(pItemId); _result := _result + 1; END IF; RETURN _result; END; $_$; ALTER FUNCTION public.dopostcosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) OWNER TO admin; -- -- Name: doupdatecosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION doupdatecosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE plowerMaterial ALIAS FOR $1; pdirectLabor ALIAS FOR $2; plowerDirectLabor ALIAS FOR $3; poverhead ALIAS FOR $4; plowerOverhead ALIAS FOR $5; pmachOverhead ALIAS FOR $6; plowerMachOverhead ALIAS FOR $7; plowerUser ALIAS FOR $8; prollUp ALIAS FOR $9; BEGIN RETURN doUpdateCosts(plowerMaterial, pdirectLabor, plowerDirectLabor, poverhead, plowerOverhead, pmachOverhead, plowerMachOverhead, plowerUser, prollUp, TRUE); END; $_$; ALTER FUNCTION public.doupdatecosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) OWNER TO admin; -- -- Name: doupdatecosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION doupdatecosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE plowerMaterial ALIAS FOR $1; pdirectLabor ALIAS FOR $2; plowerDirectLabor ALIAS FOR $3; poverhead ALIAS FOR $4; plowerOverhead ALIAS FOR $5; pmachOverhead ALIAS FOR $6; plowerMachOverhead ALIAS FOR $7; plowerUser ALIAS FOR $8; prollUp ALIAS FOR $9; pActual ALIAS FOR $10; _item RECORD; _bom RECORD; _result INTEGER := 0; BEGIN PERFORM resetLowLevelCode(-1); FOR _item IN SELECT costUpdate_item_id FROM costUpdate ORDER BY costUpdate_lowlevel_code DESC LOOP PERFORM doUpdateCosts(_item.costUpdate_item_id, false, plowerMaterial, pdirectLabor, plowerDirectLabor, poverhead, plowerOverhead, pmachOverhead, plowerMachOverhead, plowerUser, prollUp, pActual); END LOOP; RETURN _result; END; $_$; ALTER FUNCTION public.doupdatecosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) OWNER TO admin; -- -- Name: doupdatecosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION doupdatecosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemId ALIAS FOR $1; pResetLowLevel ALIAS FOR $2; plowerMaterial ALIAS FOR $3; pdirectLabor ALIAS FOR $4; plowerDirectLabor ALIAS FOR $5; poverhead ALIAS FOR $6; plowerOverhead ALIAS FOR $7; pmachOverhead ALIAS FOR $8; plowerMachOverhead ALIAS FOR $9; plowerUser ALIAS FOR $10; prollUp ALIAS FOR $11; BEGIN RETURN doUpdateCosts(pItemId, pResetLowLevel, plowerMaterial, pdirectLabor, plowerDirectLabor, poverhead, plowerOverhead, pmachOverhead, plowerMachOverhead, plowerUser, prollUp, TRUE); END; $_$; ALTER FUNCTION public.doupdatecosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) OWNER TO admin; -- -- Name: doupdatecosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION doupdatecosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemId ALIAS FOR $1; pResetLowLevel ALIAS FOR $2; plowerMaterial ALIAS FOR $3; pdirectLabor ALIAS FOR $4; plowerDirectLabor ALIAS FOR $5; poverhead ALIAS FOR $6; plowerOverhead ALIAS FOR $7; pmachOverhead ALIAS FOR $8; plowerMachOverhead ALIAS FOR $9; plowerUser ALIAS FOR $10; prollUp ALIAS FOR $11; pUpdateActual ALIAS FOR $12; _item RECORD; _bom RECORD; _result INTEGER := 0; _resultFromReset INTEGER; _counterNum INTEGER; _feedBackNum INTEGER; BEGIN IF (pResetLowLevel) THEN PERFORM resetLowLevelCode(pItemId); END IF; SELECT costUpdate_item_id AS item_id, costUpdate_item_type AS item_type INTO _item FROM costUpdate WHERE costUpdate_item_id = pItemId; IF ((plowerMaterial) AND ((_item.item_type <> 'P') AND (_item.item_type <> 'O'))) THEN PERFORM updateSorACost(_item.item_id, 'Material', TRUE, lowerCost(_item.item_id, 'Material', pUpdateActual), pUpdateActual); END IF; IF (pdirectLabor) THEN PERFORM updateSorACost(_item.item_id, 'Direct Labor', FALSE, xtmfg.directLaborCost(_item.item_id), pUpdateActual); END IF; IF (plowerDirectLabor) THEN PERFORM updateSorACost(_item.item_id, 'Direct Labor', TRUE, lowerCost(_item.item_id, 'Direct Labor', pUpdateActual), pUpdateActual); END IF; IF (poverhead) THEN PERFORM updateSorACost(_item.item_id, 'Overhead', FALSE, xtmfg.overheadCost(_item.item_id), pUpdateActual); END IF; IF (plowerOverhead) THEN PERFORM updateSorACost(_item.item_id, 'Overhead', TRUE, lowerCost(_item.item_id, 'Overhead', pUpdateActual), pUpdateActual); END IF; IF (pmachOverhead) THEN PERFORM updateSorACost(_item.item_id, 'Machine Overhead', FALSE, xtmfg.machineOverheadCost(_item.item_id), pUpdateActual); END IF; IF (plowerMachOverhead) THEN PERFORM updateSorACost(_item.item_id, 'Machine Overhead', TRUE, lowerCost(_item.item_id, 'Machine Overhead', pUpdateActual), pUpdateActual); END IF; IF (plowerUser) THEN PERFORM updateLowerUserCosts(_item.item_id, pUpdateActual); END IF; IF (prollUp) THEN PERFORM rollUpSorACost(_item.item_id, pUpdateActual); END IF; RETURN _result; END; $_$; ALTER FUNCTION public.doupdatecosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) OWNER TO admin; -- -- Name: dropifexists(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION dropifexists(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN dropIfExists($1, $2, 'public'); END; $_$; ALTER FUNCTION public.dropifexists(text, text) OWNER TO admin; -- -- Name: dropifexists(text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION dropifexists(text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN dropIfExists($1, $2, $3, false); END; $_$; ALTER FUNCTION public.dropifexists(text, text, text) OWNER TO admin; -- -- Name: dropifexists(text, text, text, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION dropifexists(text, text, text, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pType ALIAS FOR $1; pObject ALIAS FOR $2; pSchema ALIAS FOR $3; pCascade ALIAS FOR $4; _table TEXT; _query TEXT; BEGIN IF (UPPER(pType) = 'INDEX') THEN _query = 'DROP INDEX ' || quote_ident(LOWER(pSchema)) || '.' || quote_ident(LOWER(pObject)); BEGIN EXECUTE _query; EXCEPTION WHEN undefined_object OR invalid_schema_name THEN RETURN 0; WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM; END; ELSEIF (UPPER(pType) = 'TABLE') THEN _query = 'DROP TABLE ' || quote_ident(LOWER(pSchema)) || '.' || quote_ident(LOWER(pObject)); IF (pCascade) THEN _query = _query || ' CASCADE'; END IF; BEGIN EXECUTE _query; EXCEPTION WHEN undefined_table OR invalid_schema_name THEN RETURN 0; WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM; END; ELSIF (UPPER(pType) = 'VIEW') THEN _query = 'DROP VIEW ' || quote_ident(LOWER(pSchema)) || '.' || quote_ident(LOWER(pObject)); IF (pCascade) THEN _query = _query || ' CASCADE'; END IF; BEGIN EXECUTE _query; EXCEPTION WHEN undefined_table OR invalid_schema_name THEN RETURN 0; WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM; END; ELSIF (UPPER(pType) = 'TRIGGER') THEN SELECT relname INTO _table FROM pg_trigger, pg_class WHERE ((tgrelid=pg_class.oid) AND (UPPER(tgname)=UPPER(pObject))); IF (NOT FOUND) THEN _table := '[no table]'; END IF; _query = 'DROP TRIGGER ' || quote_ident(LOWER(pObject)) || ' ON ' || quote_ident(LOWER(pSchema)) || '.' || quote_ident(LOWER(_table)); BEGIN EXECUTE _query; EXCEPTION WHEN undefined_object THEN RETURN 0; WHEN undefined_table OR invalid_schema_name THEN RETURN 0; WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM; END; ELSIF (UPPER(pType) = 'FUNCTION') THEN _query = 'DROP FUNCTION ' || (LOWER(pSchema)) || '.' || (LOWER(pObject)); BEGIN EXECUTE _query; EXCEPTION WHEN undefined_object OR undefined_function OR invalid_schema_name THEN RETURN 0; WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM; END; ELSIF (UPPER(pType) = 'CONSTRAINT') THEN IF( (SELECT count(*) FROM pg_constraint, pg_class, pg_namespace WHERE((conrelid=pg_class.oid) AND (connamespace=pg_namespace.oid) AND (conname=pObject) AND (nspname=pSchema)) ) > 1 ) THEN RAISE EXCEPTION 'dropIfExists called on constraint name that matches more than 1 constraint.'; END IF; SELECT relname INTO _table FROM pg_constraint, pg_class, pg_namespace WHERE ((conrelid=pg_class.oid) AND (connamespace=pg_namespace.oid) AND (conname=pObject) AND (nspname=pSchema)); IF (NOT FOUND) THEN RETURN 0; END IF; _query = 'ALTER TABLE ' || quote_ident(LOWER(pSchema)) || '.' || quote_ident(LOWER(_table)) || ' DROP CONSTRAINT ' || quote_ident(LOWER(pObject)); BEGIN EXECUTE _query; EXCEPTION WHEN undefined_table OR invalid_schema_name THEN RETURN 0; WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM; END; ELSIF (UPPER(pType) = 'SCHEMA') THEN _query = 'DROP SCHEMA ' || quote_ident(LOWER(pObject)); BEGIN EXECUTE _query; EXCEPTION WHEN invalid_schema_name THEN RETURN 0; WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM; END; ELSIF (UPPER(pType) = 'TYPE') THEN _query = 'DROP TYPE ' || quote_ident(LOWER(pSchema)) || '.' || quote_ident(LOWER(pObject)); IF (pCascade) THEN _query = _query || ' CASCADE'; END IF; BEGIN EXECUTE _query; EXCEPTION WHEN undefined_object OR invalid_schema_name THEN RETURN 0; WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM; END; ELSE RAISE EXCEPTION 'dropIfExists(%, %): unknown pType %', pType, pObject, pType; END IF; RETURN 1; END; $_$; ALTER FUNCTION public.dropifexists(text, text, text, boolean) OWNER TO admin; -- -- Name: dropifexists(text, text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION dropifexists(text, text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pType ALIAS FOR $1; pObject ALIAS FOR $2; pSchema ALIAS FOR $3; pRelation ALIAS FOR $4; _table TEXT; _query TEXT; BEGIN IF (UPPER(pType) = 'CONSTRAINT') THEN SELECT relname INTO _table FROM pg_constraint, pg_class, pg_namespace WHERE ((conrelid=pg_class.oid) AND (connamespace=pg_namespace.oid) AND (conname=pObject) AND (relname=pRelation) AND (nspname=pSchema)); IF (NOT FOUND) THEN RETURN 0; END IF; _query = 'ALTER TABLE ' || quote_ident(LOWER(pSchema)) || '.' || quote_ident(LOWER(pRelation)) || ' DROP CONSTRAINT ' || quote_ident(LOWER(pObject)); BEGIN EXECUTE _query; EXCEPTION WHEN undefined_table OR invalid_schema_name THEN RETURN 0; WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM; END; ELSE RAISE EXCEPTION 'dropIfExists(%, %, %, %): pType % is not supported when relation is specified', pType, pObject, pSchema, pRelation, pType; END IF; RETURN 1; END; $_$; ALTER FUNCTION public.dropifexists(text, text, text, text) OWNER TO admin; -- -- Name: dropstdopntable(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION dropstdopntable() RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN IF((SELECT metric_value != 'Manufacturing' FROM metric WHERE metric_name = 'Application')) THEN PERFORM dropIfExists('TABLE', 'stdopn'); RETURN true; END IF; RETURN false; END; $$; ALTER FUNCTION public.dropstdopntable() OWNER TO admin; -- -- Name: editccnumber(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION editccnumber(text, text) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCcardnum ALIAS FOR $1; pCcardtype ALIAS FOR $2; card_length INTEGER; card_valid boolean := false; starting_digits TEXT; _sum INTEGER := 0; _digit INTEGER := 0; _timesTwo BOOLEAN := false; BEGIN -- Check the card type IF (pCcardtype NOT IN ('M', 'V', 'A', 'D')) THEN -- Unknown Card Type RETURN -1; END IF; card_length := length(pCcardnum); -- Process Master Card Checking length -- Process Master Card Starting digits IF (pCcardtype = 'M') THEN IF (card_length != 16) THEN -- Bad Card Length Card Type RETURN -2; END IF; starting_digits := substr(pCcardnum, 1, 2); IF (starting_digits < '51' OR starting_digits > '55') THEN -- Bad Starting digits RETURN -6; END IF; END IF; -- Process Visa Card Checking length -- Process Visa Card Starting digits IF (pCcardtype = 'V') THEN IF (card_length != 13 AND card_length != 16) THEN -- Bad Card Length Card Type RETURN -3; END IF; starting_digits := substr(pCcardnum, 1, 1); IF (starting_digits != '4') THEN -- Bad Starting digits RETURN -7; END IF; END IF; -- Process American Express Card Checking length -- Process American Express Card Starting digits IF (pCcardtype = 'A') THEN IF (card_length != 15) THEN -- Bad Card Length Card Type RETURN -4; END IF; starting_digits := substr(pCcardnum, 1, 2); IF (starting_digits != '34' AND starting_digits != '37') THEN -- Bad Starting digits RETURN -8; END IF; END IF; -- Process Discover Card Checking length -- Process Discover Card Starting digits IF (pCcardtype = 'D') THEN IF (card_length != 16) THEN -- Bad Card Length Card Type RETURN -5; END IF; starting_digits := substr(pCcardnum, 1, 4); IF (starting_digits != '6011') THEN -- Bad Starting digits RETURN -9; END IF; END IF; -- Now comes the fun part of doing the "check" for the check sum -- perform a luhn checksum FOR i IN REVERSE card_length .. 1 LOOP _digit := int4(substr(pCcardnum, i, 1)); IF (_timesTwo) THEN _digit := _digit * 2; IF (_digit > 9) THEN _digit := _digit - 9; END IF; END IF; _sum := _sum + _digit; _timesTwo := NOT _timesTwo; END LOOP; IF (mod(_sum, 10) != 0) THEN RETURN -10; END IF; RETURN 0; -- No Error END; $_$; ALTER FUNCTION public.editccnumber(text, text) OWNER TO admin; -- -- Name: enablepackage(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION enablepackage(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ppkgname ALIAS FOR $1; _i INTEGER := 0; _tabs TEXT[] := ARRAY['cmd', 'cmdarg', 'image', 'metasql', 'priv', 'report', 'script', 'uiform']; BEGIN IF (version() < 'PostgreSQL 8.2') THEN RETURN -1; END IF; FOR _i IN ARRAY_LOWER(_tabs,1)..ARRAY_UPPER(_tabs,1) LOOP EXECUTE 'ALTER TABLE ' || ppkgname || '.pkg' || _tabs[_i] || ' INHERIT public.' || _tabs[_i] || ';'; END LOOP; RETURN 0; END; $_$; ALTER FUNCTION public.enablepackage(text) OWNER TO admin; -- -- Name: enablepackage(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION enablepackage(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ppkgheadid ALIAS FOR $1; _pkgname TEXT; BEGIN SELECT pkghead_name INTO _pkgname FROM pkghead WHERE (pkghead_id=ppkgheadid); IF (NOT FOUND) THEN RETURN -2; END IF; RETURN enablePackage(_pkgname); END; $_$; ALTER FUNCTION public.enablepackage(integer) OWNER TO admin; -- -- Name: encrypt(bytea, bytea, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION encrypt(bytea, bytea, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_encrypt'; ALTER FUNCTION public.encrypt(bytea, bytea, text) OWNER TO admin; -- -- Name: encrypt_iv(bytea, bytea, bytea, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION encrypt_iv(bytea, bytea, bytea, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_encrypt_iv'; ALTER FUNCTION public.encrypt_iv(bytea, bytea, bytea, text) OWNER TO admin; -- -- Name: endoftime(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION endoftime() RETURNS date LANGUAGE sql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT DATE('2100-01-01') as result; $$; ALTER FUNCTION public.endoftime() OWNER TO admin; -- -- Name: entercount(integer, numeric, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION entercount(integer, numeric, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvcntid ALIAS FOR $1; pQty ALIAS FOR $2; pComments ALIAS FOR $3; BEGIN UPDATE invcnt SET invcnt_qoh_after = pQty, invcnt_comments = CASE WHEN ( (LENGTH(invcnt_comments) = 0) AND (LENGTH(pComments) > 0) ) THEN pComments WHEN (LENGTH(pComments) > 0) THEN (invcnt_comments || E'\n' || pComments) ELSE invcnt_comments END, invcnt_cntdate = CURRENT_TIMESTAMP, invcnt_cnt_username = getEffectiveXtUser() WHERE (invcnt_id=pInvcntid); RETURN 0; END; $_$; ALTER FUNCTION public.entercount(integer, numeric, text) OWNER TO admin; -- -- Name: enterporeceipt(integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION enterporeceipt(integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN enterReceipt('PO', $1, $2, 0.0, '', NULL, NULL); END; $_$; ALTER FUNCTION public.enterporeceipt(integer, numeric) OWNER TO admin; -- -- Name: enterporeceipt(integer, numeric, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION enterporeceipt(integer, numeric, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN enterPoReceipt('PO', $1, $2, 0.0, $3, NULL, NULL); END; $_$; ALTER FUNCTION public.enterporeceipt(integer, numeric, text) OWNER TO admin; -- -- Name: enterporeceipt(integer, numeric, numeric, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION enterporeceipt(integer, numeric, numeric, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN enterPoReceipt('PO', $1, $2, $3, $4, NULL, NULL); END; $_$; ALTER FUNCTION public.enterporeceipt(integer, numeric, numeric, text) OWNER TO admin; -- -- Name: enterporeceipt(integer, numeric, numeric, text, integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION enterporeceipt(integer, numeric, numeric, text, integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN enterReceipt('PO', $1, $2, $3, $4, $5, $6); END; $_$; ALTER FUNCTION public.enterporeceipt(integer, numeric, numeric, text, integer, date) OWNER TO admin; -- -- Name: enterporeturn(integer, numeric, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION enterporeturn(integer, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN enterPoReturn($1, $2, $3, NULL); END; $_$; ALTER FUNCTION public.enterporeturn(integer, numeric, integer) OWNER TO admin; -- -- Name: enterporeturn(integer, numeric, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION enterporeturn(integer, numeric, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPoitemid ALIAS FOR $1; pQty ALIAS FOR $2; pRjctcodeid ALIAS FOR $3; pRecvid ALIAS FOR $4; _porejectid INTEGER; BEGIN SELECT NEXTVAL('poreject_poreject_id_seq') INTO _porejectid; INSERT INTO poreject ( poreject_id, poreject_date, poreject_ponumber, poreject_poitem_id, poreject_trans_username, poreject_agent_username, poreject_itemsite_id, poreject_vend_id, poreject_vend_item_number, poreject_vend_item_descrip, poreject_vend_uom, poreject_qty, poreject_rjctcode_id, poreject_posted, poreject_invoiced, poreject_recv_id ) SELECT _porejectid, CURRENT_TIMESTAMP, pohead_number, poitem_id, getEffectiveXtUser(), pohead_agent_username, poitem_itemsite_id, pohead_vend_id, poitem_vend_item_number, poitem_vend_item_descrip, poitem_vend_uom, pQty, pRjctcodeid, FALSE, FALSE, pRecvid FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id) WHERE (poitem_id=pPoitemid); RETURN _porejectid; END; $_$; ALTER FUNCTION public.enterporeturn(integer, numeric, integer, integer) OWNER TO admin; -- -- Name: enterreceipt(text, integer, numeric, numeric, text, integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION enterreceipt(text, integer, numeric, numeric, text, integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN enterReceipt($1, $2, $3, $4, $5, $6, $7, NULL); END; $_$; ALTER FUNCTION public.enterreceipt(text, integer, numeric, numeric, text, integer, date) OWNER TO admin; -- -- Name: enterreceipt(text, integer, numeric, numeric, text, integer, date, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION enterreceipt(text, integer, numeric, numeric, text, integer, date, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; porderitemid ALIAS FOR $2; pQty ALIAS FOR $3; pFreight ALIAS FOR $4; pNotes ALIAS FOR $5; pcurrid ALIAS FOR $6; -- NULL is handled by SELECT ... INTO _o precvdate ALIAS FOR $7; -- NULL is handled by INSERT INTO recv pRecvCost ALIAS FOR $8; _timestamp TIMESTAMP; _o RECORD; _recvid INTEGER; _warehouseid INTEGER; _recvcost NUMERIC; BEGIN IF(precvdate IS NULL OR precvdate = CURRENT_DATE) THEN _timestamp := CURRENT_TIMESTAMP; ELSE _timestamp := precvdate; END IF; SELECT NEXTVAL('recv_recv_id_seq') INTO _recvid; DELETE FROM recv WHERE ((NOT recv_posted) AND (recv_order_type=pordertype) AND (recv_orderitem_id=porderitemid) ); IF (pQty > 0) THEN IF (pordertype='PO') THEN SELECT pohead_number AS orderhead_number, poitem_id AS orderitem_id, pohead_agent_username AS orderhead_agent_username, CASE WHEN (poitem_itemsite_id = -1) THEN NULL ELSE poitem_itemsite_id END AS itemsite_id, vend_id, COALESCE(poitem_vend_item_number, '') AS vend_item_number, COALESCE(poitem_vend_item_descrip, '') AS vend_item_descrip, COALESCE(poitem_vend_uom, '') AS vend_uom, poitem_duedate AS duedate, poitem_unitprice AS orderitem_unitcost, pohead_curr_id AS orderitem_unitcost_curr_id, pohead_curr_id AS freight_curr_id, poitem_rlsd_duedate AS rlsd_duedate INTO _o FROM pohead JOIN poitem ON (pohead_id=poitem_pohead_id) JOIN vendinfo ON (pohead_vend_id=vend_id) WHERE (poitem_id=porderitemid); ELSIF (pordertype='RA') THEN SELECT rahead_number AS orderhead_number, raitem_id AS orderitem_id, ''::text AS orderhead_agent_username, raitem_itemsite_id AS itemsite_id, NULL::integer AS vend_id, ''::text AS vend_item_number, ''::text AS vend_item_descrip, ''::text AS vend_uom, raitem_scheddate AS duedate, raitem_unitprice AS orderitem_unitcost, rahead_curr_id AS orderitem_unitcost_curr_id, rahead_curr_id AS freight_curr_id, raitem_scheddate AS rlsd_duedate INTO _o FROM rahead JOIN raitem ON (rahead_id=raitem_rahead_id) WHERE (raitem_id=porderitemid); ELSIF (pordertype='TO') THEN SELECT tohead_number AS orderhead_number, toitem_id AS orderitem_id, tohead_agent_username AS orderhead_agent_username, itemsite_id, NULL::integer AS vend_id, ''::text AS vend_item_number, ''::text AS vend_item_descrip, ''::text AS vend_uom, toitem_duedate AS duedate, toitem_stdcost AS orderitem_unitcost, baseCurrId() AS orderitem_unitcost_curr_id, toitem_freight_curr_id AS freight_curr_id, toitem_duedate AS rlsd_duedate INTO _o FROM itemsite, tohead JOIN toitem ON (tohead_id=toitem_tohead_id) WHERE ((toitem_id=porderitemid) AND (tohead_dest_warehous_id=itemsite_warehous_id) AND (toitem_item_id=itemsite_item_id)); END IF; --Make sure user has site privileges IF ((FOUND) AND (_o.itemsite_id IS NOT NULL)) THEN SELECT warehous_id INTO _warehouseid FROM itemsite,site() WHERE ((itemsite_id=_o.itemsite_id) AND (warehous_id=itemsite_warehous_id)); IF (NOT FOUND) THEN RETURN 0; END IF; END IF; --Make sure we aren't trying to receive a Kit IF ((FOUND) AND (_o.itemsite_id IS NOT NULL)) THEN IF (SELECT (item_type='K') FROM itemsite, item WHERE ((itemsite_id=_o.itemsite_id) AND (item_id=itemsite_item_id))) THEN RETURN 0; END IF; END IF; IF (NOT FOUND) THEN RETURN -1; END IF; -- default to orderitem_unitcost if recv_purchcost is not specified IF(pRecvCost IS NULL) THEN _recvcost := _o.orderitem_unitcost; ELSE _recvcost := pRecvCost; END IF; INSERT INTO recv ( recv_id, recv_date, recv_order_number, recv_order_type, recv_orderitem_id, recv_trans_usr_name, recv_agent_username, recv_itemsite_id, recv_vend_id, recv_vend_item_number, recv_vend_item_descrip, recv_vend_uom, recv_qty, recv_duedate, recv_purchcost, recv_purchcost_curr_id, recv_notes, recv_freight, recv_freight_curr_id, recv_rlsd_duedate ) VALUES ( _recvid, _timestamp, _o.orderhead_number, pordertype, _o.orderitem_id::INTEGER, getEffectiveXtUser(), _o.orderhead_agent_username, _o.itemsite_id::INTEGER, _o.vend_id::INTEGER, _o.vend_item_number, _o.vend_item_descrip, _o.vend_uom, pQty, _o.duedate, _recvcost, _o.orderitem_unitcost_curr_id::INTEGER, pNotes, pFreight, _o.freight_curr_id::INTEGER, _o.rlsd_duedate); END IF; RETURN _recvid; END; $_$; ALTER FUNCTION public.enterreceipt(text, integer, numeric, numeric, text, integer, date, numeric) OWNER TO admin; -- -- Name: expirecreditcard(integer, bytea); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION expirecreditcard(integer, bytea) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCust ALIAS FOR $1; pKey ALIAS FOR $2; num_updated INTEGER; cc_year INTEGER; cc_month INTEGER; cc_year_t TEXT; cc_month_t TEXT; _dr RECORD; _cc RECORD; bf TEXT; BEGIN num_updated := 0; bf := 'bf'; select cast(date_part('year', CURRENT_DATE) AS INTEGER) AS check_year, cast(date_part('month', CURRENT_DATE) AS INTEGER) AS check_month INTO _dr; FOR _cc IN SELECT ccard_id, decrypt(setbytea(ccard_month_expired), setbytea(pKey), 'bf') AS ccard_month_expired, decrypt(setbytea(ccard_year_expired), setbytea(pKey), 'bf') AS ccard_year_expired FROM ccard WHERE ( (ccard_cust_id=pCust) AND (ccard_active) ) LOOP SELECT formatbytea(_cc.ccard_month_expired) INTO cc_month_t; SELECT formatbytea(_cc.ccard_year_expired) INTO cc_year_t; SELECT cast(cc_month_t AS INTEGER) INTO cc_month; SELECT cast(cc_year_t AS INTEGER) INTO cc_year; IF (cc_year < _dr.check_year) THEN -- We have an expired card UPDATE ccard set ccard_active = FALSE where ccard_id = _cc.ccard_id; num_updated := num_updated + 1; ELSIF (cc_year = _dr.check_year AND cc_month < _dr.check_month) THEN -- We have an expired card UPDATE ccard set ccard_active = FALSE where ccard_id = _cc.ccard_id; num_updated := num_updated + 1; END IF; END LOOP; RETURN num_updated; END; $_$; ALTER FUNCTION public.expirecreditcard(integer, bytea) OWNER TO admin; -- -- Name: explodebom(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION explodebom(integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pParentid ALIAS FOR $2; pLevel ALIAS FOR $3; _revid INTEGER; BEGIN SELECT getActiveRevId('BOM',pItemid) INTO _revid; RETURN explodeBOM(pItemid, _revid, pParentid, pLevel); END; $_$; ALTER FUNCTION public.explodebom(integer, integer, integer) OWNER TO admin; -- -- Name: explodebom(integer, integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION explodebom(integer, integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pRevisionid ALIAS FOR $2; pParentid ALIAS FOR $3; pLevel ALIAS FOR $4; _bomworkid INTEGER; _level INTEGER; _p RECORD; _r RECORD; _temp TEXT; BEGIN _level := (pLevel + 1); -- Cache some parameters about the parent SELECT bomwork_item_id, bomwork_set_id, bomwork_qtyreq, bomwork_seqnumber, bomwork_effective, bomwork_expires INTO _p FROM bomwork WHERE (bomwork_id=pParentid); -- Step through all of the components of the parent component FOR _r IN SELECT bomitem.*, item_id, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS qtyfxd, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS qtyper, CASE WHEN (_p.bomwork_effective > bomitem_effective) THEN _p.bomwork_effective ELSE bomitem_effective END AS effective, CASE WHEN (_p.bomwork_expires < bomitem_expires) THEN _p.bomwork_expires ELSE bomitem_expires END AS expires, stdcost(item_id, bomitem_id) AS standardcost, actcost(item_id, bomitem_id) AS actualcost FROM bomitem(pItemid, pRevisionid), item WHERE ( (bomitem_item_id=item_id) AND (bomitem_expires > _p.bomwork_effective) ) LOOP -- Insert the current component and some bomitem parameters into the bomwork set SELECT NEXTVAL('bomwork_bomwork_id_seq') INTO _bomworkid; INSERT INTO bomwork ( bomwork_id, bomwork_set_id, bomwork_parent_id, bomwork_level, bomwork_parent_seqnumber, bomwork_seqnumber, bomwork_item_id, bomwork_createwo, bomwork_qtyreq, bomwork_qtyfxd, bomwork_qtyper, bomwork_scrap, bomwork_issuemethod, bomwork_effective, bomwork_expires, bomwork_stdunitcost, bomwork_actunitcost, bomwork_notes, bomwork_ref, bomwork_bomitem_id, bomwork_ecn ) VALUES ( _bomworkid, _p.bomwork_set_id, pParentid, _level, _p.bomwork_seqnumber, _r.bomitem_seqnumber, _r.item_id, _r.bomitem_createwo, (_p.bomwork_qtyreq * _r.qtyper + _r.qtyfxd), _r.qtyfxd, _r.qtyper, _r.bomitem_scrap, _r.bomitem_issuemethod, _r.effective, _r.expires, _r.standardcost, _r.actualcost, _r.bomitem_notes, _r.bomitem_ref, _r.bomitem_id, _r.bomitem_ecn ); -- Recursively repeat for this component's components PERFORM explodeBOM(_r.item_id, _bomworkid, _level); END LOOP; RETURN 1; END; $_$; ALTER FUNCTION public.explodebom(integer, integer, integer, integer) OWNER TO admin; -- -- Name: explodekit(integer, integer, integer, integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION explodekit(integer, integer, integer, integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; pLinenumber ALIAS FOR $2; pSubnumber ALIAS FOR $3; pItemsiteid ALIAS FOR $4; pQty ALIAS FOR $5; BEGIN RETURN explodeKit(pSoheadid, pLinenumber, pSubnumber, pItemsiteid, pQty, CURRENT_DATE, NULL); END; $_$; ALTER FUNCTION public.explodekit(integer, integer, integer, integer, numeric) OWNER TO admin; -- -- Name: explodekit(integer, integer, integer, integer, numeric, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION explodekit(integer, integer, integer, integer, numeric, date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; pLinenumber ALIAS FOR $2; pSubnumber ALIAS FOR $3; pItemsiteid ALIAS FOR $4; pQty ALIAS FOR $5; pScheddate ALIAS FOR $6; pPromdate ALIAS FOR $7; BEGIN RETURN explodeKit(pSoheadid, pLinenumber, pSubnumber, pItemsiteid, pQty, COALESCE(pScheddate, CURRENT_DATE), pPromdate, ''); END; $_$; ALTER FUNCTION public.explodekit(integer, integer, integer, integer, numeric, date, date) OWNER TO admin; -- -- Name: explodekit(integer, integer, integer, integer, numeric, date, date, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION explodekit(integer, integer, integer, integer, numeric, date, date, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; pLinenumber ALIAS FOR $2; pSubnumber ALIAS FOR $3; pItemsiteid ALIAS FOR $4; pQty ALIAS FOR $5; pScheddate ALIAS FOR $6; pPromdate ALIAS FOR $7; pMemo ALIAS FOR $8; _subnumber INTEGER := COALESCE(pSubnumber,0); _revid INTEGER; _itemid INTEGER; _warehousid INTEGER; _item RECORD; _type TEXT; _coitemid INTEGER; _count INTEGER; _orderid INTEGER := 0; _itemsrcid INTEGER; BEGIN SELECT getActiveRevId('BOM',itemsite_item_id), itemsite_warehous_id, itemsite_item_id INTO _revid, _warehousid, _itemid FROM itemsite WHERE(itemsite_id=pItemsiteid); IF(NOT FOUND) THEN RAISE EXCEPTION 'No Item Site for the specified line was found.'; END IF; FOR _item IN SELECT bomitem_id, itemsite_id, itemsite_warehous_id, COALESCE((itemsite_active AND item_active), false) AS active, COALESCE((itemsite_sold AND item_sold), false) AS sold, item_id, item_type, item_price_uom_id, itemsite_createsopr,itemsite_createwo,itemsite_createsopo, itemsite_dropship, bomitem_uom_id, itemuomtouomratio(item_id, bomitem_uom_id, item_inv_uom_id) AS invuomratio, roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id),(bomitem_qtyfxd + bomitem_qtyper * pQty) * (1 + bomitem_scrap)) AS qty FROM bomitem JOIN item ON (item_id=bomitem_item_id) LEFT OUTER JOIN itemsite ON ((itemsite_item_id=item_id) AND (itemsite_warehous_id=_warehousid)) WHERE((bomitem_parent_item_id=_itemid) AND (bomitem_rev_id=_revid) AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1))) ORDER BY bomitem_seqnumber LOOP IF (NOT _item.active) THEN RAISE EXCEPTION 'One or more of the components for the kit is inactive for the selected item site.'; ELSIF (NOT _item.sold) THEN RAISE EXCEPTION 'One or more of the components for the kit is not sold for the selected item site.'; ELSIF (_item.item_type='F') THEN SELECT explodeKit(pSoheadid, pLinenumber, _subnumber, _item.itemsite_id, _item.qty) INTO _subnumber; ELSE IF (_item.itemsite_createsopr) THEN _type := 'R'; ELSIF (_item.itemsite_createsopo) THEN _type := 'P'; ELSIF (_item.itemsite_createwo) THEN _type := 'W'; ELSE _type := NULL; END IF; _subnumber := _subnumber + 1; _coitemid = nextval('coitem_coitem_id_seq'); INSERT INTO coitem (coitem_id, coitem_cohead_id, coitem_linenumber, coitem_subnumber, coitem_itemsite_id, coitem_status, coitem_scheddate, coitem_promdate, coitem_qtyord, coitem_qty_uom_id, coitem_qty_invuomratio, coitem_qtyshipped, coitem_qtyreturned, coitem_unitcost, coitem_custprice, coitem_price, coitem_price_uom_id, coitem_price_invuomratio, coitem_order_type, coitem_order_id, coitem_custpn, coitem_memo, coitem_prcost) VALUES (_coitemid, pSoheadid, pLinenumber, _subnumber, _item.itemsite_id, 'O', pScheddate, pPromdate, _item.qty, _item.bomitem_uom_id, _item.invuomratio, 0, 0, stdCost(_item.item_id), 0, 0, _item.item_price_uom_id, 1, _type, -1, '', pMemo, 0); END IF; END LOOP; RETURN _subnumber; END; $_$; ALTER FUNCTION public.explodekit(integer, integer, integer, integer, numeric, date, date, text) OWNER TO admin; -- -- Name: explodephantomorder(integer, integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION explodephantomorder(integer, integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPlanordid ALIAS FOR $1; pPhantomid ALIAS FOR $2; pQty ALIAS FOR $3; _b RECORD; BEGIN FOR _b IN SELECT planord_number, c.itemsite_id AS componentsiteid, calculatenextworkingdate(c.itemsite_warehous_id, planord_startdate, (c.itemsite_leadtime * -1)) AS startdate, planord_startdate AS duedate, bomitem_createwo, c.itemsite_planning_type AS planningtype, (itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd + pQty * bomitem_qtyper) * (1 + bomitem_scrap))) AS qtyreq, item_type FROM bomitem, planord, itemsite AS p, itemsite AS c, item WHERE ((bomitem_parent_item_id=p.itemsite_item_id) AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id)) AND (bomitem_item_id=c.itemsite_item_id) AND (p.itemsite_warehous_id=c.itemsite_warehous_id) AND (c.itemsite_item_id=item_id) AND (woEffectiveDate(planord_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND (p.itemsite_id=pPhantomid) AND (planord_id=pPlanordid)) LOOP IF (_b.item_type = 'F') THEN PERFORM explodePhantomOrder(pPlanordid, _b.componentsiteid, _b.qtyreq); ELSE -- Create the Planned Requirement INSERT INTO planreq ( planreq_source, planreq_source_id, planreq_itemsite_id, planreq_qty ) VALUES ( 'P', pPlanordid, _b.componentsiteid, _b.qtyreq ); IF (_b.bomitem_createwo AND _b.planningtype != 'N') THEN PERFORM createPlannedOrder( pPlanordid, _b.planord_number, _b.componentsiteid, _b.qtyreq, _b.startdate, _b.duedate, FALSE, FALSE, NULL, NULL); END IF; END IF; END LOOP; RETURN pPlanordid; END; $_$; ALTER FUNCTION public.explodephantomorder(integer, integer, numeric) OWNER TO admin; -- -- Name: explodewo(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION explodewo(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pExplodeChildren ALIAS FOR $2; resultCode INTEGER; newWo RECORD; _newwoid INTEGER; _p RECORD; _r RECORD; _bbom BOOLEAN; BEGIN -- Find out if Breeder BOMs are enabled SELECT metric_value='t' INTO _bbom FROM metric WHERE (metric_name='BBOM'); -- Make sure that this W/O is Open SELECT wo_id INTO resultCode FROM wo WHERE ((wo_status='O') AND (wo_id=pWoid)); IF (NOT FOUND) THEN RETURN -4; END IF; -- Make sure that all Component Item Sites exist and are valid -- Item Sites must be active and not Job Costed SELECT bomitem_id INTO resultCode FROM wo, bomitem, itemsite WHERE ( (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=bomitem_parent_item_id) AND (woEffectiveDate(wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND (wo_id=pWoid) AND (bomitem_rev_id=wo_bom_rev_id) AND (bomitem_item_id NOT IN ( SELECT component.itemsite_item_id FROM itemsite AS component, itemsite AS parent WHERE ( (wo_itemsite_id=parent.itemsite_id) AND (parent.itemsite_item_id=bomitem_parent_item_id) AND (bomitem_item_id=component.itemsite_item_id) AND (woEffectiveDate(wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND (component.itemsite_active) AND (component.itemsite_warehous_id=parent.itemsite_warehous_id) ) ) ) ) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; -- If the Parent Item is a Breeder, make sure that all the -- Co-Product/By-Product Item Sites exist IF (_bbom) THEN IF ( ( SELECT (item_type='B') FROM wo, itemsite, item WHERE ( (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (wo_id=pWoid) ) ) ) THEN SELECT bbomitem_id INTO resultCode FROM wo, xtmfg.bbomitem, itemsite WHERE ( (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=bbomitem_parent_item_id) AND (woEffectiveDate(wo_startdate) BETWEEN bbomitem_effective AND (bbomitem_expires - 1)) AND (wo_id=pWoid) AND (bbomitem_item_id NOT IN ( SELECT component.itemsite_item_id FROM itemsite AS component, itemsite AS parent WHERE ( (wo_itemsite_id=parent.itemsite_id) AND (parent.itemsite_item_id=bbomitem_parent_item_id) AND (bbomitem_item_id=component.itemsite_item_id) AND (woEffectiveDate(wo_startdate) BETWEEN bbomitem_effective AND (bbomitem_expires - 1)) AND (component.itemsite_active) AND (component.itemsite_warehous_id=parent.itemsite_warehous_id) ) ) ) ) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; END IF; END IF; -- Create the W/O Material Requirements INSERT INTO womatl ( womatl_wo_id, womatl_bomitem_id, womatl_wooper_id, womatl_schedatwooper, womatl_itemsite_id, womatl_duedate, womatl_uom_id, womatl_qtyfxd, womatl_qtyper, womatl_scrap, womatl_qtyreq, womatl_qtyiss, womatl_qtywipscrap, womatl_lastissue, womatl_lastreturn, womatl_cost, womatl_picklist, womatl_createwo, womatl_issuewo, womatl_issuemethod, womatl_notes, womatl_ref, womatl_price ) SELECT wo_id, bomitem_id, bomitem_booitem_seq_id, bomitem_schedatwooper, matl_itemsite, duedate, bomitem_uom_id, bomitem_qtyfxd, bomitem_qtyper, bomitem_scrap, qtyreq, 0, 0, startOfTime(), startOfTime(), 0, item_picklist, ( (item_type='M') AND (bomitem_createwo) ), issuewo, bomitem_issuemethod, bomitem_notes, bomitem_ref, CASE WHEN (price=-9999.0) THEN 0.0 ELSE price END FROM (SELECT *, cs.itemsite_id AS matl_itemsite, CASE WHEN bomitem_schedatwooper THEN COALESCE(calcWooperStartStub(wo_id,bomitem_booitem_seq_id), wo_startdate) ELSE wo_startdate END AS duedate, roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id), (bomitem_qtyfxd + bomitem_qtyper * wo_qtyord) * (1 + bomitem_scrap)) AS qtyreq, CASE WHEN ( (item_type='M') AND (bomitem_issuewo) ) THEN TRUE WHEN (cs.itemsite_costmethod='J') THEN TRUE ELSE FALSE END AS issuewo, CASE WHEN (cohead_id IS NULL) THEN item_listprice ELSE (SELECT itemprice_price FROM itemIpsPrice(item_id, cohead_cust_id, cohead_shipto_id, roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id), (bomitem_qtyfxd + bomitem_qtyper * wo_qtyord) * (1 + bomitem_scrap)), bomitem_uom_id, bomitem_uom_id, cohead_curr_id, CURRENT_DATE, CURRENT_DATE, cohead_warehous_id) LIMIT 1) END AS price FROM wo JOIN itemsite ps ON (ps.itemsite_id=wo_itemsite_id) JOIN bomitem ON (bomitem_parent_item_id=ps.itemsite_item_id AND bomitem_rev_id=wo_bom_rev_id AND woEffectiveDate(wo_startdate) BETWEEN bomitem_effective and (bomitem_expires - 1)) JOIN itemsite cs ON (cs.itemsite_item_id=bomitem_item_id AND cs.itemsite_warehous_id=ps.itemsite_warehous_id) JOIN item ON (item_id=cs.itemsite_item_id) LEFT OUTER JOIN coitem ON (wo_ordtype='S' AND wo_ordid=coitem_id) LEFT OUTER JOIN cohead ON (cohead_id=coitem_cohead_id) WHERE ( (wo_id=pWoid) AND ((bomitem_char_id IS NULL) OR EXISTS ( SELECT charass_id FROM coitem,charass WHERE ((charass_target_type='SI') AND (charass_target_id=coitem_id) AND (charass_char_id=bomitem_char_id) AND (charass_value=bomitem_value) AND (wo_ordtype='S') AND (coitem_id=wo_ordid)))) ) ) AS data; -- Update any created P/R's the have the project id as the parent WO. UPDATE pr SET pr_prj_id=wo_prj_id FROM womatl, wo WHERE ((wo_id=pWoid) AND (womatl_wo_id=wo_id) AND (pr_order_type='W') AND (pr_order_id=womatl_id)); -- If the parent Item is a Breeder, create the brddist -- records for the Co-Products and By-Products IF (_bbom) THEN INSERT INTO xtmfg.brddist ( brddist_wo_id, brddist_wo_qty, brddist_itemsite_id, brddist_stdqtyper, brddist_qty, brddist_posted ) SELECT wo_id, 0, cs.itemsite_id, bbomitem_qtyper, 0, FALSE FROM wo, xtmfg.bbomitem, itemsite AS ps, itemsite AS cs, item WHERE ( (bbomitem_parent_item_id=ps.itemsite_item_id) AND (wo_itemsite_id=ps.itemsite_id) AND (ps.itemsite_item_id=item_id) AND (item_type='B') AND (bbomitem_item_id=cs.itemsite_item_id) AND (cs.itemsite_warehous_id=ps.itemsite_warehous_id) AND (wo_id=pWoid) ); END IF; -- Insert the W/O Operations if routings enabled IF ( ( SELECT (metric_value='t') FROM metric WHERE (metric_name='Routings') ) ) THEN INSERT INTO xtmfg.wooper ( wooper_wo_id, wooper_booitem_id, wooper_seqnumber, wooper_wrkcnt_id, wooper_stdopn_id, wooper_descrip1, wooper_descrip2, wooper_toolref, wooper_sutime, wooper_sucosttype, wooper_surpt, wooper_rntime, wooper_rncosttype, wooper_rnrpt, wooper_rnqtyper, wooper_produom, wooper_invproduomratio, wooper_issuecomp, wooper_rcvinv, wooper_suconsumed, wooper_sucomplete, wooper_rnconsumed, wooper_rncomplete, wooper_qtyrcv, wooper_instruc, wooper_scheduled, wooper_wip_location_id, wooper_price, wooper_opntype_id ) SELECT wo_id, booitem_id, booitem_seqnumber, booitem_wrkcnt_id, booitem_stdopn_id, booitem_descrip1, booitem_descrip2, booitem_toolref, CASE WHEN (booitem_surpt) THEN booitem_sutime ELSE 0 END, booitem_sucosttype, booitem_surpt, CASE WHEN ((booitem_rnqtyper = 0) OR (booitem_invproduomratio = 0)) THEN 0 WHEN (NOT booitem_rnrpt) THEN 0 ELSE ( ( booitem_rntime / booitem_rnqtyper * booitem_invproduomratio ) * wo_qtyord ) END, booitem_rncosttype, booitem_rnrpt, CASE WHEN (booitem_rnqtyper = 0) THEN 0 WHEN (NOT booitem_rnrpt) THEN 0 ELSE (booitem_rntime / booitem_rnqtyper) END, booitem_produom, booitem_invproduomratio, booitem_issuecomp, booitem_rcvinv, 0::NUMERIC, FALSE, 0::NUMERIC, FALSE, 0::NUMERIC, booitem_instruc, calculatenextworkingdate(itemsite_warehous_id,wo_startdate,booitem_execday-1), booitem_wip_location_id, (xtmfg.directlaborcostoper(booitem_id) + xtmfg.overheadcostoper(booitem_id) + xtmfg.machineoverheadcostoper(booitem_id)), booitem_opntype_id FROM xtmfg.booitem, wo, itemsite WHERE ((wo_itemsite_id=itemsite_id) AND (itemsite_item_id=booitem_item_id) AND (booitem_rev_id=wo_boo_rev_id) AND (woEffectiveDate(wo_startdate) BETWEEN booitem_effective AND (booitem_expires - 1)) AND (wo_id=pWoid)); -- Update womatls item to link to wooper items when the respective -- bomitem record indicates a booitem issue link. UPDATE womatl SET womatl_wooper_id=wooper_id FROM wo,xtmfg.wooper,xtmfg.booitem WHERE ((womatl_wooper_id=booitem_seq_id) AND (wooper_booitem_id=booitem_id) AND (womatl_wo_id=wo_id) AND (wooper_wo_id=wo_id) AND (wo_boo_rev_id=booitem_rev_id) AND (wo_id=pWoid)); END IF; -- Handle all of the Phantom material requirements WHILE ( ( SELECT COUNT(*) FROM womatl, itemsite, item WHERE ( (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (womatl_wo_id=pWoid) AND (item_type='F') ) ) > 0 ) LOOP FOR _p IN SELECT wo_qtyord, wo_startdate, womatl_id, womatl_wooper_id FROM wo, womatl, itemsite, item WHERE ( (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_type='F') AND (womatl_wo_id=wo_id) AND (wo_id=pWoid) ) LOOP INSERT INTO womatl ( womatl_wo_id, womatl_itemsite_id, womatl_wooper_id, womatl_schedatwooper, womatl_duedate, womatl_uom_id, womatl_qtyfxd, womatl_qtyper, womatl_scrap, womatl_qtyreq, womatl_qtyiss, womatl_qtywipscrap, womatl_lastissue, womatl_lastreturn, womatl_cost, womatl_picklist, womatl_createwo, womatl_issuewo, womatl_issuemethod, womatl_notes, womatl_ref ) SELECT pWoid, cs.itemsite_id, _p.womatl_wooper_id, womatl_schedatwooper, womatl_duedate, bomitem_uom_id, bomitem_qtyfxd, (bomitem_qtyper * womatl_qtyper), bomitem_scrap, roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id), (bomitem_qtyfxd + _p.wo_qtyord * bomitem_qtyper * womatl_qtyper) * (1 + bomitem_scrap)), 0, 0, startOfTime(), startOfTime(), 0, ci.item_picklist, ( (ci.item_type='M') AND (bomitem_createwo) ), ( (ci.item_type='M') AND (bomitem_issuewo) ), bomitem_issuemethod, bomitem_notes, bomitem_ref FROM womatl JOIN wo ON (wo_id=womatl_wo_id) JOIN itemsite ps ON (ps.itemsite_id=womatl_itemsite_id) JOIN item pi ON (pi.item_id=ps.itemsite_item_id) JOIN bomitem ON ( (bomitem_parent_item_id=pi.item_id) AND (woEffectiveDate(_p.wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND (bomitem_rev_id=getActiveRevId('BOM', pi.item_id)) ) JOIN item ci ON (ci.item_id=bomitem.bomitem_item_id) JOIN itemsite cs ON ( (cs.itemsite_item_id=ci.item_id) AND (cs.itemsite_warehous_id=ps.itemsite_warehous_id) ) WHERE (womatl_id=_p.womatl_id); DELETE FROM womatl WHERE (womatl_id=_p.womatl_id); END LOOP; END LOOP; -- Create W/Os for manufactured component items FOR newWo IN SELECT wo_number, nextWoSubnumber(wo_number) AS nextSubnumber, itemsite_id, itemsite_leadtime, womatl_duedate, womatl_wo_id, womatl_qtyreq, womatl_uom_id, wo_prj_id, item_id, item_inv_uom_id, womatl_id FROM womatl, wo, itemsite, item WHERE ( (womatl_wo_id=wo_id) AND (womatl_itemsite_id=itemsite_id) AND (womatl_createwo) AND (itemsite_wosupply) AND (itemsite_item_id=item_id) AND (wo_id=pWoid) ) ORDER BY womatl_id LOOP SELECT createWo( newWo.wo_number, newWo.itemsite_id, 1, itemuomtouom(newWo.item_id,newWo.womatl_uom_id,newWo.item_inv_uom_id,newWo.womatl_qtyreq), newWo.itemsite_leadtime, newWo.womatl_duedate, '', 'W', newWo.womatl_wo_id, newWo.wo_prj_id ) INTO _newwoid; UPDATE wo SET wo_womatl_id = newWo.womatl_id WHERE wo_id=_newwoid; END LOOP; UPDATE wo SET wo_status='E', wo_adhoc=FALSE WHERE (wo_id=pWoid); IF (pExplodeChildren) THEN SELECT MAX(explodeWo(wo_id, TRUE)) INTO resultCode FROM wo WHERE ( (wo_ordtype='W') AND (wo_ordid=pWoid) ); END IF; RETURN pWoid; END; $_$; ALTER FUNCTION public.explodewo(integer, boolean) OWNER TO admin; -- -- Name: explodewoeffective(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION explodewoeffective() RETURNS text LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _value TEXT; BEGIN SELECT metric_value INTO _value FROM metric WHERE (metric_name='ExplodeWOEffective'); RETURN _value; END; $$; ALTER FUNCTION public.explodewoeffective() OWNER TO admin; -- -- Name: fetchapmemonumber(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchapmemonumber() RETURNS integer LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('APMemoNumber')::INTEGER; $$; ALTER FUNCTION public.fetchapmemonumber() OWNER TO admin; -- -- Name: fetcharmemonumber(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetcharmemonumber() RETURNS text LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('ARMemoNumber'); $$; ALTER FUNCTION public.fetcharmemonumber() OWNER TO admin; -- -- Name: fetchcashrcptnumber(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchcashrcptnumber() RETURNS text LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('CashRcptNumber'); $$; ALTER FUNCTION public.fetchcashrcptnumber() OWNER TO admin; -- -- Name: fetchcmnumber(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchcmnumber() RETURNS text LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('CmNumber'); $$; ALTER FUNCTION public.fetchcmnumber() OWNER TO admin; -- -- Name: fetchcrmaccountnumber(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchcrmaccountnumber() RETURNS integer LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('CRMAccountNumber')::INTEGER; $$; ALTER FUNCTION public.fetchcrmaccountnumber() OWNER TO admin; -- -- Name: fetchdefaultfob(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchdefaultfob(pwarehousid integer) RETURNS text LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT warehous_fob FROM whsinfo WHERE (warehous_id=$1); $_$; ALTER FUNCTION public.fetchdefaultfob(pwarehousid integer) OWNER TO admin; -- -- Name: fetchdefaultshipvia(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchdefaultshipvia() RETURNS text LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal TEXT; BEGIN SELECT shipvia_code INTO _returnVal FROM shipvia WHERE shipvia_id= (SELECT CAST(metric_value AS integer) FROM metric WHERE metric_name = 'DefaultShipViaId'); RETURN _returnVal; END; $$; ALTER FUNCTION public.fetchdefaultshipvia() OWNER TO admin; -- -- Name: fetchglsequence(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchglsequence() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _sequence INTEGER; BEGIN SELECT NEXTVAL('gltrans_sequence_seq') INTO _sequence; RETURN _sequence; END; $$; ALTER FUNCTION public.fetchglsequence() OWNER TO admin; -- -- Name: fetchincidentnumber(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchincidentnumber() RETURNS integer LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('IncidentNumber')::integer; $$; ALTER FUNCTION public.fetchincidentnumber() OWNER TO admin; -- -- Name: fetchinvcnumber(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchinvcnumber() RETURNS integer LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('InvcNumber')::integer; $$; ALTER FUNCTION public.fetchinvcnumber() OWNER TO admin; -- -- Name: fetchitemuomconvtypes(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchitemuomconvtypes(integer) RETURNS text[] LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemUomConvId ALIAS FOR $1; _p RECORD; _result text[]; _cnt INTEGER; BEGIN _cnt := 0; FOR _p IN SELECT uomtype_name FROM itemuomconv, itemuom, uomtype WHERE ((itemuomconv_id=pItemUomConvId) AND (itemuomconv_id=itemuom_itemuomconv_id) AND (itemuom_uomtype_id=uomtype_id)) LOOP _result[_cnt] := _p.uomtype_name; _cnt := _cnt + 1; END LOOP; RETURN _result; END; $_$; ALTER FUNCTION public.fetchitemuomconvtypes(integer) OWNER TO admin; -- -- Name: fetchjournalnumber(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchjournalnumber(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUse ALIAS FOR $1; _number INTEGER; BEGIN SELECT nextval('journal_number_seq') INTO _number; INSERT INTO jrnluse (jrnluse_date, jrnluse_number, jrnluse_use) VALUES (CURRENT_TIMESTAMP, _number, pUse); RETURN _number; END; $_$; ALTER FUNCTION public.fetchjournalnumber(text) OWNER TO admin; -- -- Name: fetchmetricbool(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchmetricbool(text) RETURNS boolean LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _pMetricName ALIAS FOR $1; _returnVal BOOLEAN; BEGIN SELECT CASE WHEN MIN(metric_value) = 't' THEN true ELSE false END INTO _returnVal FROM metric WHERE metric_name = _pMetricName; RETURN _returnVal; END; $_$; ALTER FUNCTION public.fetchmetricbool(text) OWNER TO admin; -- -- Name: fetchmetrictext(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchmetrictext(text) RETURNS text LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _pMetricName ALIAS FOR $1; _returnVal TEXT; BEGIN SELECT metric_value::TEXT INTO _returnVal FROM metric WHERE metric_name = _pMetricName; RETURN _returnVal; END; $_$; ALTER FUNCTION public.fetchmetrictext(text) OWNER TO admin; -- -- Name: fetchmetricvalue(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchmetricvalue(text) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _pMetricName ALIAS FOR $1; _returnVal INTEGER; BEGIN SELECT CASE WHEN (isNumeric(metric_value)) THEN metric_value::INTEGER ELSE NULL END INTO _returnVal FROM metric WHERE metric_name = _pMetricName; RETURN _returnVal; END; $_$; ALTER FUNCTION public.fetchmetricvalue(text) OWNER TO admin; -- -- Name: fetchnextchecknumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchnextchecknumber(pbankaccntid integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBankaccntid ALIAS FOR $1; _nextChkNumber INTEGER; _checkheadid INTEGER; BEGIN SELECT bankaccnt_nextchknum INTO _nextChkNumber FROM bankaccnt WHERE (bankaccnt_id=pBankaccntid); WHILE (TRUE) LOOP SELECT checkhead_id INTO _checkheadid FROM checkhead WHERE (checkhead_number=_nextChkNumber) AND (checkhead_bankaccnt_id=pBankaccntid); IF (NOT FOUND) THEN EXIT; ELSE _nextChkNumber := _nextChkNumber + 1; END IF; END LOOP; UPDATE bankaccnt SET bankaccnt_nextchknum = (bankaccnt_nextchknum + 1) WHERE (bankaccnt_id=pBankaccntid); RETURN _nextChkNumber; END; $_$; ALTER FUNCTION public.fetchnextchecknumber(pbankaccntid integer) OWNER TO admin; -- -- Name: fetchnextnumber(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchnextnumber(text) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE psequence ALIAS FOR $1; _number TEXT; _numcol TEXT; _select TEXT; _table TEXT; _test TEXT; _nextnum INTEGER; _seqiss seqiss; __seqiss seqiss[]; _not_issued BOOLEAN; BEGIN SELECT CAST(orderseq_number AS text), orderseq_number, orderseq_table, orderseq_numcol, COALESCE(orderseq_seqiss, ARRAY[]::seqiss[]) INTO _number, _nextnum, _table, _numcol, __seqiss FROM orderseq WHERE (orderseq_name=psequence) FOR UPDATE; IF (NOT FOUND) THEN RAISE EXCEPTION 'Invalid orderseq_name %', psequence; END IF; LOOP _seqiss := (_nextnum, now()); SELECT count(*) = 0 INTO _not_issued FROM (SELECT UNNEST(__seqiss) AS issued) data WHERE (issued).seqiss_number = _nextnum; _nextnum := _nextnum + 1; -- Test if the number has been issued, but not committed IF (_not_issued) THEN -- Test if the number has been committed -- Have to factor in scenario where Quotes are set to use SO Numbering IF (psequence = 'SoNumber' AND fetchmetrictext('QUNumberGeneration') = 'S') THEN _select := 'SELECT ' || quote_ident(_numcol) || ' FROM ' || _table || ' WHERE (' || quote_ident(_numcol) || '=' || quote_literal(_number) || ') ' || ' UNION SELECT quhead_number FROM quhead WHERE (quhead_number = ' || quote_literal(_number) || ');'; ELSE _select := 'SELECT ' || quote_ident(_numcol) || ' FROM ' || _table || ' WHERE (' || quote_ident(_numcol) || '=' || quote_literal(_number) || ');'; END IF; EXECUTE _select INTO _test; IF (_test IS NULL OR NOT FOUND) THEN EXIT; END IF; END IF; -- Number in use, try again _number = _nextnum::text; END LOOP; UPDATE orderseq SET orderseq_number = _nextnum WHERE (orderseq_name=psequence); IF (fetchMetricBool('EnableGaplessNumbering')) THEN UPDATE orderseq SET orderseq_seqiss = orderseq_seqiss || _seqiss WHERE (orderseq_name=psequence); END IF; RETURN _number; END; $_$; ALTER FUNCTION public.fetchnextnumber(text) OWNER TO admin; -- -- Name: fetchponumber(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchponumber() RETURNS text LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('PoNumber'); $$; ALTER FUNCTION public.fetchponumber() OWNER TO admin; -- -- Name: fetchprefwarehousid(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchprefwarehousid() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _result INTEGER; BEGIN SELECT CAST(usrpref_value AS INTEGER) INTO _result FROM usrpref WHERE ((usrpref_username=getEffectiveXtUser()) AND (usrpref_name='PreferredWarehouse')); RETURN _result; END; $$; ALTER FUNCTION public.fetchprefwarehousid() OWNER TO admin; -- -- Name: fetchprnumber(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchprnumber() RETURNS integer LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('PrNumber')::INTEGER; $$; ALTER FUNCTION public.fetchprnumber() OWNER TO admin; -- -- Name: fetchqunumber(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchqunumber() RETURNS text LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('QuNumber'); $$; ALTER FUNCTION public.fetchqunumber() OWNER TO admin; -- -- Name: fetchshipmentnumber(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchshipmentnumber() RETURNS text LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _number TEXT; _test INTEGER; BEGIN LOOP SELECT CAST(nextval('shipment_number_seq') AS TEXT) INTO _number; SELECT shiphead_id INTO _test FROM shiphead WHERE (shiphead_number=_number); IF (NOT FOUND) THEN EXIT; END IF; END LOOP; RETURN _number; END; $$; ALTER FUNCTION public.fetchshipmentnumber() OWNER TO admin; -- -- Name: fetchsonumber(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchsonumber() RETURNS text LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('SoNumber'); $$; ALTER FUNCTION public.fetchsonumber() OWNER TO admin; -- -- Name: fetchtonumber(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchtonumber() RETURNS text LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('ToNumber'); $$; ALTER FUNCTION public.fetchtonumber() OWNER TO admin; -- -- Name: fetchusrprefbool(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchusrprefbool(text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _pPrefName ALIAS FOR $1; _returnVal BOOLEAN; BEGIN SELECT CASE WHEN MIN(usrpref_value) = 't' THEN true ELSE false END INTO _returnVal FROM usrpref WHERE ( (usrpref_username=getEffectiveXtUser()) AND (usrpref_name=_pPrefName) ); RETURN _returnVal; END; $_$; ALTER FUNCTION public.fetchusrprefbool(text) OWNER TO admin; -- -- Name: fetchvonumber(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchvonumber() RETURNS integer LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('VcNumber')::INTEGER; $$; ALTER FUNCTION public.fetchvonumber() OWNER TO admin; -- -- Name: fetchwonumber(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fetchwonumber() RETURNS integer LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('WoNumber')::INTEGER; $$; ALTER FUNCTION public.fetchwonumber() OWNER TO admin; -- -- Name: financialreport(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION financialreport(integer, integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlheadid ALIAS FOR $1; pPeriodid ALIAS FOR $2; pPrjid ALIAS FOR $3; _result bool; BEGIN SELECT financialreport(pFlheadid,pPeriodid,'M', pPrjid) INTO _result; RETURN _result; END; $_$; ALTER FUNCTION public.financialreport(integer, integer, integer) OWNER TO admin; -- -- Name: financialreport(integer, integer, character, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION financialreport(integer, integer, character, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. /* performance vs. history: versions prior to xTuple ERP 4.5.x (x ?= 1) used public.flrpt to build financial reports. after that release, the function creates a temporary table if necessary. with the temp table, flrpt self-joins no longer require comparing flrpt_username - temp tables are only visible within the current session. however, there are subsidiary functions (eg insertflgroup) that _do_ join on flrpt_username. in addition, flrpt_username has a not-null constraint. to reduce the risk of breakage, this function still sets flrpt_username. */ DECLARE pFlheadid ALIAS FOR $1; pPeriodid ALIAS FOR $2; pInterval ALIAS FOR $3; pPrjid ALIAS FOR $4; _r RECORD; _t RECORD; _s RECORD; _username TEXT := getEffectiveXtUser(); BEGIN -- Validate Interval IF pInterval <> 'M' AND pInterval <> 'Q' AND pInterval <> 'Y' THEN RAISE EXCEPTION 'Invalid Interval --> %', pInterval; END IF; CREATE TEMPORARY TABLE IF NOT EXISTS flrpt (LIKE public.flrpt INCLUDING ALL) ON COMMIT PRESERVE ROWS; -- clear even temp tables because every run builds on data upserted by itself DELETE FROM flrpt WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodId) AND (flrpt_interval=pInterval)); -- Find out if we need to show a Grand Total and which if any of the values -- we want to show in that grand total. SELECT flhead_showtotal, CASE WHEN(flhead_showstart) THEN 0.00 ELSE NULL END AS beginning, CASE WHEN(flhead_showend) THEN 0.00 ELSE NULL END AS ending, CASE WHEN(flhead_showdelta) THEN 0.00 ELSE NULL END AS debits, CASE WHEN(flhead_showdelta) THEN 0.00 ELSE NULL END AS credits, CASE WHEN(flhead_showbudget) THEN 0.00 ELSE NULL END AS budget, CASE WHEN(flhead_showdiff) THEN 0.00 ELSE NULL END AS diff, CASE WHEN(flhead_showcustom) THEN 0.00 ELSE NULL END AS custom, CASE WHEN(flhead_usealttotal) THEN flhead_alttotal ELSE NULL END AS altname INTO _r FROM flhead WHERE (flhead_id=pFlheadid); IF (NOT FOUND) THEN return FALSE; END IF; -- If showing a Grand Total then create a record as a Group which acts -- as a parent to the whole report. This allows the code to update as -- it would for normal group total values. IF (_r.flhead_showtotal) THEN INSERT INTO flrpt (flrpt_flhead_id, flrpt_period_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_beginning, flrpt_ending, flrpt_debits, flrpt_credits, flrpt_budget, flrpt_diff, flrpt_custom, flrpt_altname, flrpt_interval ) VALUES (pFlheadid, pPeriodid, _username, 0, -1, 'G', -1, _r.beginning, _r.ending, _r.debits, _r.credits, _r.budget, _r.diff, _r.custom, _r.altname, pInterval ); END IF; PERFORM insertFlGroup(pFlheadid, pPeriodid, -1, 0, FALSE, pInterval, pPrjid); -- go through the list of records that need percentages calculated and perform -- those calculations. FOR _t IN SELECT flrpt_order, CASE WHEN(flgrp_prcnt_flgrp_id = -1) THEN flgrp_flgrp_id ELSE flgrp_prcnt_flgrp_id END AS flgrp_id FROM flrpt, flgrp WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) AND (flrpt_type='G') AND (flrpt_type_id=flgrp_id)) UNION SELECT flrpt_order, CASE WHEN(flitem_prcnt_flgrp_id = -1) THEN flitem_flgrp_id ELSE flitem_prcnt_flgrp_id END AS flgrp_id FROM flrpt, flitem WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) AND (flrpt_type='I') AND (flrpt_type_id=flitem_id)) UNION SELECT flrpt_order, CASE WHEN(flspec_prcnt_flgrp_id = -1) THEN flspec_flgrp_id ELSE flspec_prcnt_flgrp_id END AS flgrp_id FROM flrpt, flspec WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) AND (flrpt_type='S') AND (flrpt_type_id=flspec_id)) LOOP IF( (_t.flgrp_id=-1) OR (NOT (SELECT flgrp_summarize FROM flgrp WHERE flgrp_id=_t.flgrp_id)) ) THEN SELECT COALESCE(SUM(flrpt_beginning),0) AS beginningTotal, COALESCE(SUM(flrpt_ending),0) AS endingTotal, COALESCE(SUM(flrpt_debits),0) AS debitsTotal, COALESCE(SUM(flrpt_credits),0) AS creditsTotal, COALESCE(SUM(flrpt_budget),0) AS budgetTotal, COALESCE(SUM(flrpt_diff), 0) AS diffTotal, COALESCE(SUM(flrpt_custom), 0) AS customTotal INTO _s FROM flrpt WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) AND (flrpt_type != 'T') AND (flrpt_parent_id=_t.flgrp_id)); ELSE SELECT COALESCE(SUM(flrpt_beginning),0) AS beginningTotal, COALESCE(SUM(flrpt_ending),0) AS endingTotal, COALESCE(SUM(flrpt_debits),0) AS debitsTotal, COALESCE(SUM(flrpt_credits),0) AS creditsTotal, COALESCE(SUM(flrpt_budget),0) AS budgetTotal, COALESCE(SUM(flrpt_diff), 0) AS diffTotal, COALESCE(SUM(flrpt_custom), 0) AS customTotal INTO _s FROM flrpt WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) AND (flrpt_type = 'G') AND (flrpt_type_id=_t.flgrp_id)); END IF; UPDATE flrpt SET flrpt_beginningprcnt = flrpt_beginningprcnt + flrpt_beginning / CASE WHEN (_s.beginningTotal=0) THEN 1 ELSE _s.beginningTotal END, flrpt_endingprcnt = flrpt_endingprcnt + flrpt_ending / CASE WHEN (_s.endingTotal=0) THEN 1 ELSE _s.endingTotal END, flrpt_debitsprcnt = flrpt_debitsprcnt + flrpt_debits / CASE WHEN (_s.debitsTotal=0) THEN 1 ELSE _s.debitsTotal END, flrpt_creditsprcnt = flrpt_creditsprcnt + flrpt_credits / CASE WHEN (_s.creditsTotal=0) THEN 1 ELSE _s.creditsTotal END, flrpt_budgetprcnt = flrpt_budgetprcnt + flrpt_budget / CASE WHEN (_s.budgetTotal=0) THEN 1 ELSE _s.budgetTotal END, flrpt_diffprcnt = flrpt_diffprcnt + flrpt_diff / CASE WHEN (_s.diffTotal=0) THEN 1 ELSE _s.diffTotal END, flrpt_customprcnt = flrpt_customprcnt + flrpt_custom / CASE WHEN (_s.customTotal=0) THEN 1 ELSE _s.customTotal END WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) AND (flrpt_order=_t.flrpt_order)); END LOOP; -- Update any subtotal records to reflect the percentage values of the parents -- since those are calculated after the subtotal records were created. FOR _t IN SELECT a.flrpt_order AS flrpt_order, b.flrpt_beginningprcnt AS flrpt_beginningprcnt, b.flrpt_endingprcnt AS flrpt_endingprcnt, b.flrpt_debitsprcnt AS flrpt_debitsprcnt, b.flrpt_creditsprcnt AS flrpt_creditsprcnt, b.flrpt_budgetprcnt AS flrpt_budgetprcnt, b.flrpt_diffprcnt AS flrpt_diffprcnt, b.flrpt_customprcnt AS flrpt_customprcnt FROM flrpt AS a, flrpt AS b WHERE ((a.flrpt_flhead_id=pFlheadid) AND (a.flrpt_period_id=pPeriodid) AND (a.flrpt_interval=pInterval) AND (a.flrpt_type='T') AND (b.flrpt_flhead_id=a.flrpt_flhead_id) AND (b.flrpt_period_id=a.flrpt_period_id) AND (b.flrpt_interval=pInterval) AND (b.flrpt_type='G') AND (b.flrpt_type_id=a.flrpt_parent_id)) LOOP UPDATE flrpt SET flrpt_beginningprcnt=flrpt_beginningprcnt + _t.flrpt_beginningprcnt, flrpt_endingprcnt=flrpt_endingprcnt + _t.flrpt_endingprcnt, flrpt_debitsprcnt=flrpt_debitsprcnt + _t.flrpt_debitsprcnt, flrpt_creditsprcnt=flrpt_creditsprcnt + _t.flrpt_creditsprcnt, flrpt_budgetprcnt=flrpt_budgetprcnt + _t.flrpt_budgetprcnt, flrpt_diffprcnt=flrpt_diffprcnt + _t.flrpt_diffprcnt, flrpt_customprcnt=flrpt_customprcnt + _t.flrpt_customprcnt WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) AND (flrpt_order=_t.flrpt_order)); END LOOP; -- If showing a Grand total then move the record we created early to the -- end of the report and marked as a Total record. IF (_r.flhead_showtotal) THEN UPDATE flrpt SET flrpt_order = COALESCE((SELECT MAX(flrpt_order) FROM flrpt WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) ) ), 0) + 1, flrpt_level = 0, flrpt_type = 'T' WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) AND (flrpt_order=0) AND (flrpt_level = -1) AND (flrpt_type = 'G') AND (flrpt_type_id=-1)); END IF; return TRUE; END; $_$; ALTER FUNCTION public.financialreport(integer, integer, character, integer) OWNER TO admin; -- -- Name: financialreport(integer, integer[], character, boolean, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION financialreport(integer, integer[], character, boolean, integer) RETURNS SETOF fltrenditem LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlheadId ALIAS FOR $1; pPeriodIds ALIAS FOR $2; pInterval ALIAS FOR $3; pShowNumbers ALIAS FOR $4; pPrjid ALIAS FOR $5; _row fltrenditem%ROWTYPE; _type CHAR; _p RECORD; _count INTEGER; _n NUMERIC; _fld NUMERIC[]; _grndttl NUMERIC; _i INTEGER; _first BOOLEAN; _prevlevel INTEGER; _subgrp INTEGER; BEGIN _first := true; _subgrp := 0; IF ARRAY_UPPER(pPeriodIds,1) <= 12 THEN _count := ARRAY_UPPER(pPeriodIds,1); ELSE _count := 12; END IF; --Get Type SELECT flhead_type FROM flhead INTO _type WHERE flhead_id=pFlheadId; --Build Financial Data FOR _i IN 1.._count LOOP PERFORM financialreport(pFlheadId,pPeriodIds[_i],pInterval,pPrjid); END LOOP; --Get Row Data FOR _p IN SELECT flrpt_flhead_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_parent_id, flrpt_accnt_id, formatindent(flgrp.flgrp_name,flrpt.flrpt_level) AS flrpt_name, CASE WHEN (flgrp_summarize AND (_type IN ('I','C'))) THEN (COALESCE(flrpt_diff,0)) WHEN (flgrp_summarize AND (_type = 'B')) THEN (COALESCE(flrpt_ending,0)) ELSE NULL END AS f_fld1, flgrp_summarize AS display FROM flrpt,flgrp WHERE ((flrpt_flhead_id=pFlheadId) AND (flgrp_id=flrpt_type_id) AND (flrpt_type='G') AND (flrpt_period_id=pPeriodIds[1]) AND (flrpt_interval=pInterval) ) UNION SELECT flrpt_flhead_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_parent_id, flrpt_accnt_id, formatindent(accnt_descrip,flrpt.flrpt_level) AS flrpt_name, CASE WHEN (_type IN ('I','C')) THEN (COALESCE(flrpt_diff,0)) WHEN (_type = 'B') THEN (COALESCE(flrpt_ending,0)) ELSE NULL END AS f_fld1, true AS display FROM flrpt,flitem,accnt WHERE ((flrpt_flhead_id=pFlheadId) AND (flrpt_accnt_id=accnt_id) AND (flitem_id=flrpt_type_id) AND (flrpt_type='I') AND (flrpt_period_id=pPeriodIds[1]) AND (flrpt_interval=pInterval) ) UNION SELECT flrpt_flhead_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_parent_id, flrpt_accnt_id, CASE WHEN (flrpt.flrpt_type='T' AND flrpt.flrpt_level=0) THEN COALESCE(flrpt.flrpt_altname, 'Total') WHEN (flrpt.flrpt_type='T') THEN formatindent(COALESCE(flrpt.flrpt_altname, 'Subtotal') ,flrpt.flrpt_level) ELSE formatindent(('Type ' || flrpt.flrpt_type || ' ' || text(flrpt.flrpt_type_id)), flrpt.flrpt_level) END AS flstmtitem_name, CASE WHEN (_type IN ('I','C')) THEN (COALESCE(flrpt_diff,0)) WHEN (_type = 'B') THEN (COALESCE(flrpt_ending,0)) ELSE NULL END AS f_fld1, true AS display FROM flrpt WHERE ((flrpt_flhead_id=pFlheadId) AND (flrpt_type NOT IN ('I','S','G')) AND (flrpt_period_id=pPeriodIds[1]) AND (flrpt_interval=pInterval) ) ORDER BY flrpt_order LOOP IF _type IN ('I','C') THEN _grndttl := _p.f_fld1; END IF; --Loop through and calculate period column values IF (_p.display) THEN FOR _i IN 2.._count LOOP SELECT CASE WHEN (_type IN ('I','C')) THEN COALESCE(flrpt_diff,0) WHEN (_type = 'B') THEN COALESCE(flrpt_ending,0) ELSE NULL END INTO _n FROM flrpt WHERE ((flrpt_flhead_id=pFlheadId) AND (flrpt_period_id=pPeriodIds[_i]) AND (flrpt_interval=pInterval) AND (flrpt_order=_p.flrpt_order)); _fld[_i-1] := _n; IF _type IN ('I','C') THEN _grndttl := _grndttl+_n; END IF; END LOOP; END IF; --Send it all back to the caller IF _prevlevel > _p.flrpt_level THEN _subgrp := _subgrp+1; END IF; _prevlevel:=_p.flrpt_level; _row.fltrenditem_subgrp := _subgrp; IF NOT _first THEN RETURN NEXT _row; END IF; _first := FALSE; _row.fltrenditem_flhead_id := _p.flrpt_flhead_id; _row.fltrenditem_username := _p.flrpt_username; _row.fltrenditem_order := _p.flrpt_order; _row.fltrenditem_level := _p.flrpt_level; _row.fltrenditem_type := _p.flrpt_type; _row.fltrenditem_type_id := _p.flrpt_type_id; _row.fltrenditem_parent_id := _p.flrpt_parent_id; _row.fltrenditem_accnt_id := _p.flrpt_accnt_id; _row.fltrenditem_name := _p.flrpt_name; IF (_p.display) THEN _row.fltrenditem_fld1 := (_p.f_fld1); _row.fltrenditem_fld2 := (_fld[1]); _row.fltrenditem_fld3 := (_fld[2]); _row.fltrenditem_fld4 := (_fld[3]); _row.fltrenditem_fld5 := (_fld[4]); _row.fltrenditem_fld6 := (_fld[5]); _row.fltrenditem_fld7 := (_fld[6]); _row.fltrenditem_fld8 := (_fld[7]); _row.fltrenditem_fld9 := (_fld[8]); _row.fltrenditem_fld10 := (_fld[9]); _row.fltrenditem_fld11 := (_fld[10]); _row.fltrenditem_fld12 := (_fld[11]); _row.fltrenditem_grndttl := (_grndttl); ELSE _row.fltrenditem_fld1 := NULL; _row.fltrenditem_fld2 := NULL; _row.fltrenditem_fld3 := NULL; _row.fltrenditem_fld4 := NULL; _row.fltrenditem_fld5 := NULL; _row.fltrenditem_fld6 := NULL; _row.fltrenditem_fld7 := NULL; _row.fltrenditem_fld8 := NULL; _row.fltrenditem_fld9 := NULL; _row.fltrenditem_fld10 := NULL; _row.fltrenditem_fld11 := NULL; _row.fltrenditem_fld12 := NULL; _row.fltrenditem_grndttl := NULL; END IF; END LOOP; _row.fltrenditem_subgrp := _subgrp + 1; RETURN NEXT _row; END; $_$; ALTER FUNCTION public.financialreport(integer, integer[], character, boolean, integer) OWNER TO admin; -- -- Name: financialreport(integer, integer, boolean, boolean, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION financialreport(integer, integer, boolean, boolean, integer) RETURNS SETOF flstmtitem LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- see "performance vs. history" in financialreport(integer,integer,bpchar,integer) DECLARE pFlcolid ALIAS FOR $1; pPeriodid ALIAS FOR $2; pShowNumbers ALIAS FOR $3; pIndentName ALIAS FOR $4; pPrjid ALIAS FOR $5; _row flstmtitem%ROWTYPE; _p RECORD; _x RECORD; _priorMoPeriodId INTEGER; _priorQtPeriodId INTEGER; _priorYrPeriodId INTEGER; _first BOOLEAN; _prevlevel INTEGER; _subgrp INTEGER; _qtrInterval TEXT; --_username TEXT := getEffectiveXtUser(); _yrInterval TEXT; BEGIN _priorMoPeriodId := -1; _priorQtPeriodId := -1; _priorYrPeriodId := -1; _first := TRUE; _prevlevel :=0; _subgrp := 0; --Get Layout Data SELECT flhead_id,flhead_type, flcol_month,flcol_quarter,flcol_year,flcol_priortype, flcol_priormonth,flcol_priorquarter,flcol_prioryear, flcol_priordiff,flcol_priordiffprcnt,flcol_priorprcnt, flcol_budget,flcol_budgetdiff,flcol_budgetdiffprcnt, flcol_budgetprcnt INTO _p FROM flhead,flcol WHERE ((flcol_id=pFlcolid) AND (flhead_id=flcol_flhead_id)); IF (_p.flhead_type='B') THEN _qtrInterval := 'M'; _yrInterval := 'M'; ELSE _qtrInterval := 'Q'; _yrInterval := 'Y'; END IF; CREATE TEMPORARY TABLE IF NOT EXISTS flrpt (LIKE public.flrpt INCLUDING ALL) ON COMMIT PRESERVE ROWS; -- clear even temp tables because every run builds on data upserted by itself DELETE FROM flrpt WHERE (flrpt_flhead_id=_p.flhead_id); --Populate report data... --...for Month IF (_p.flcol_month) THEN PERFORM financialreport(_p.flhead_id,pPeriodid,'M',pPrjid); IF ((_p.flcol_priortype = 'P') AND (_p.flcol_priormonth)) THEN SELECT COALESCE(pp.period_id,-1) INTO _priorMoPeriodId FROM period cp, period pp WHERE ((cp.period_id=pPeriodId) AND (cp.period_start > pp.period_start)) ORDER BY pp.period_start DESC LIMIT 1; IF (_priorMoPeriodId IS NOT NULL) THEN PERFORM financialreport(_p.flhead_id,_priorMoPeriodId,'M',pPrjid); END IF; ELSE IF ((_p.flcol_priortype='Y')AND (_p.flcol_priormonth)) THEN SELECT COALESCE(pp.period_id,-1) INTO _priorMoPeriodId FROM period cp, period pp WHERE ((cp.period_id=pPeriodId) AND (cp.period_id != pp.period_id) AND (cp.period_start > pp.period_start) AND (cp.period_number = pp.period_number)) ORDER BY pp.period_start DESC LIMIT 1; IF (_priorMoPeriodId IS NOT NULL) THEN PERFORM financialreport(_p.flhead_id,_priorMoPeriodId,'M',pPrjid); END IF; END IF; END IF; END IF; --...for Quarter IF (_p.flcol_quarter) THEN PERFORM financialreport(_p.flhead_id,pPeriodid,'Q',pPrjid); END IF; IF ((_p.flcol_priortype='P') AND (_p.flcol_priorquarter)) THEN SELECT COALESCE(pp.period_id,-1) INTO _priorQtPeriodId FROM period cp, period pp WHERE ((cp.period_id=pPeriodId) AND (cp.period_start > pp.period_start) AND (pp.period_quarter= CASE WHEN cp.period_quarter > 1 THEN cp.period_quarter - 1 ELSE 4 END) AND (pp.period_start >= cp.period_start - interval '1 year')) ORDER BY pp.period_start DESC LIMIT 1; IF (_priorQtPeriodId IS NOT NULL) THEN PERFORM financialreport(_p.flhead_id,_priorQtPeriodId,'Q',pPrjid); END IF; ELSE IF ((_p.flcol_priortype='Y')AND (_p.flcol_priorquarter)) THEN SELECT pp.period_id INTO _priorQtPeriodId FROM period cp, period pp, yearperiod cy, yearperiod py WHERE ((cp.period_id=pPeriodId) AND (cp.period_yearperiod_id=cy.yearperiod_id) AND (pp.period_yearperiod_id=py.yearperiod_id) AND (cp.period_quarter=pp.period_quarter) AND (cy.yearperiod_start > py.yearperiod_start)) ORDER BY py.yearperiod_start DESC, pp.period_start DESC LIMIT 1; IF (_priorQtPeriodId IS NOT NULL) THEN PERFORM financialreport(_p.flhead_id,_priorQtPeriodId,'Q',pPrjid); END IF; END IF; END IF; --...for Year IF (_p.flcol_year) THEN PERFORM financialreport(_p.flhead_id,pPeriodid,'Y',pPrjid); END IF; IF (_p.flcol_prioryear='D') THEN SELECT COALESCE(pp.period_id,-1) INTO _priorYrPeriodId FROM period cp, period pp WHERE ((cp.period_id = pPeriodId) AND (cp.period_number = pp.period_number) AND (cp.period_start > pp.period_start)) ORDER BY pp.period_start DESC LIMIT 1; IF (_priorYrPeriodId IS NOT NULL) THEN PERFORM financialreport(_p.flhead_id,_priorYrPeriodId,'Y',pPrjid); END IF; ELSE IF (_p.flcol_prioryear='F') THEN SELECT pp.period_id INTO _priorYrPeriodId FROM period cp, period pp, yearperiod cy, yearperiod py WHERE ((cp.period_id=pPeriodId) AND (cp.period_yearperiod_id=cy.yearperiod_id) AND (pp.period_yearperiod_id=py.yearperiod_id) AND (cy.yearperiod_start > py.yearperiod_start)) ORDER BY pp.period_start DESC LIMIT 1; IF (_priorYrPeriodId IS NOT NULL) THEN PERFORM financialreport(_p.flhead_id,_priorYrPeriodId,'Y',pPrjid); END IF; END IF; END IF; --Return the data FOR _x IN SELECT flrpt.flrpt_flhead_id AS flstmtitem_flhead_id, flrpt.flrpt_period_id AS flstmtitem_period_id, flrpt.flrpt_username AS flstmtitem_username, flrpt.flrpt_order AS flstmtitem_order, flrpt.flrpt_level AS flstmtitem_level, flrpt.flrpt_type AS flstmtitem_type, flrpt.flrpt_type_id AS flstmtitem_type_id, flrpt.flrpt_parent_id AS flstmtitem_parent_id, NULL AS flstmtitem_accnt_id, CASE WHEN (pIndentName) THEN formatindent(flgrp.flgrp_name,flrpt.flrpt_level) ELSE flgrp.flgrp_name END AS flstmtitem_name, CASE WHEN (flgrp_summarize AND (flhead_type IN ('I','C'))) THEN (COALESCE(flrptmo.flrpt_diff,0)) WHEN (flgrp_summarize AND (flhead_type = 'B')) THEN (COALESCE(flrptmo.flrpt_ending,0)) ELSE NULL END AS flstmtitem_month, CASE WHEN (flgrp_summarize) THEN (COALESCE(flrptmo.flrpt_debits,0)) ELSE NULL END AS flstmtitem_monthdb, CASE WHEN (flgrp_summarize) THEN (COALESCE(flrptmo.flrpt_credits,0)) ELSE NULL END AS flstmtitem_monthcr, CASE WHEN (flgrp_summarize AND flgrp_showdiffprcnt) THEN (COALESCE(flrptmo.flrpt_diffprcnt,0)) WHEN (flgrp_summarize AND flgrp_showendprcnt) THEN (COALESCE(flrptmo.flrpt_endingprcnt,0)) ELSE NULL END AS flstmtitem_monthprcnt, CASE WHEN (flgrp_summarize) THEN (flrptmo.flrpt_budget) ELSE NULL END AS flstmtitem_monthbudget, CASE WHEN (flgrp_summarize) THEN (flrptmo.flrpt_budgetprcnt) ELSE NULL END AS flstmtitem_monthbudgetprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE((flrptmo.flrpt_diff-flrptmo.flrpt_budget),0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE((flrptmo.flrpt_ending-flrptmo.flrpt_budget),0)) ELSE NULL END AS flstmtitem_monthbudgetdiff, CASE WHEN (flgrp_summarize AND (flhead_type IN ('I','C')) AND (flrptmo.flrpt_budget > 0)) THEN (COALESCE(((flrptmo.flrpt_diff-flrptmo.flrpt_budget)/flrptmo.flrpt_budget),0)) WHEN (flgrp_summarize AND (flhead_type='B') AND (flrptmo.flrpt_budget > 0)) THEN (COALESCE(((flrptmo.flrpt_ending-flrptmo.flrpt_budget)/flrptmo.flrpt_budget),0)) WHEN (flgrp_summarize AND (flrptmo.flrpt_budget = 0)) THEN NULL ELSE NULL END AS flstmtitem_monthbudgetdiffprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE(flrptqt.flrpt_diff,0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE(flrptqt.flrpt_ending,0)) ELSE NULL END AS flstmtitem_qtr, CASE WHEN (flgrp_summarize) THEN (COALESCE(flrptqt.flrpt_debits,0)) ELSE NULL END AS flstmtitem_qtrdb, CASE WHEN (flgrp_summarize) THEN (COALESCE(flrptqt.flrpt_credits,0)) ELSE NULL END AS flstmtitem_qtrcr, CASE WHEN (flgrp_summarize AND flgrp_showdiffprcnt) THEN (flrptqt.flrpt_diffprcnt) WHEN (flgrp_summarize AND flgrp_showendprcnt) THEN (flrptqt.flrpt_endingprcnt) ELSE NULL END AS flstmtitem_qtrprcnt, CASE WHEN (flgrp_summarize) THEN (COALESCE(flrptqt.flrpt_budget,0)) ELSE NULL END AS flstmtitem_qtrbudget, CASE WHEN (flgrp_summarize) THEN (flrptqt.flrpt_budgetprcnt) ELSE NULL END AS flstmtitem_qtrbudgetprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE((flrptqt.flrpt_diff-flrptqt.flrpt_budget),0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE((flrptqt.flrpt_ending-flrptqt.flrpt_budget),0)) ELSE NULL END AS flstmtitem_qtrbudgetdiff, CASE WHEN (flgrp_summarize AND (flhead_type IN ('I','C')) AND (flrptqt.flrpt_budget > 0)) THEN (COALESCE(((flrptqt.flrpt_diff-flrptqt.flrpt_budget)/flrptqt.flrpt_budget),0)) WHEN (flgrp_summarize AND (flhead_type='B') AND (flrptqt.flrpt_budget > 0)) THEN (COALESCE(((flrptqt.flrpt_ending-flrptqt.flrpt_budget)/flrptqt.flrpt_budget),0)) ELSE NULL END AS flstmtitem_qtrbudgetdiffprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE(flrptyr.flrpt_diff,0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE(flrptyr.flrpt_ending,0)) ELSE NULL END AS flstmtitem_year, CASE WHEN (flgrp_summarize) THEN (COALESCE(flrptyr.flrpt_debits,0)) ELSE NULL END AS flstmtitem_yeardb, CASE WHEN (flgrp_summarize) THEN (COALESCE(flrptyr.flrpt_credits,0)) ELSE NULL END AS flstmtitem_yearcr, CASE WHEN (flgrp_summarize AND flgrp_showdiffprcnt) THEN (COALESCE(flrptyr.flrpt_diffprcnt,0)) WHEN (flgrp_summarize AND flgrp_showendprcnt) THEN (COALESCE(flrptyr.flrpt_endingprcnt,0)) ELSE NULL END AS flstmtitem_yearprcnt, CASE WHEN (flgrp_summarize) THEN (flrptyr.flrpt_budget) ELSE NULL END AS flstmtitem_yearbudget, CASE WHEN (flgrp_summarize) THEN (flrptyr.flrpt_budgetprcnt) ELSE NULL END AS flstmtitem_yearbudgetprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE((flrptyr.flrpt_diff-flrptyr.flrpt_budget),0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE((flrptyr.flrpt_ending-flrptyr.flrpt_budget),0)) ELSE NULL END AS flstmtitem_yearbudgetdiff, CASE WHEN (flgrp_summarize AND (flhead_type IN ('I','C')) AND (flrptyr.flrpt_budget > 0)) THEN (COALESCE(((flrptyr.flrpt_diff-flrptyr.flrpt_budget)/flrptyr.flrpt_budget),0)) WHEN (flgrp_summarize AND (flhead_type = 'B') AND (flrptyr.flrpt_budget > 0)) THEN (COALESCE(((flrptyr.flrpt_ending-flrptyr.flrpt_budget)/flrptyr.flrpt_budget),0)) WHEN (flgrp_summarize AND (flrptyr.flrpt_budget = 0)) THEN NULL ELSE NULL END AS flstmtitem_yearbudgetdiffprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE(flrptprmo.flrpt_diff,0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE(flrptprmo.flrpt_ending,0)) ELSE NULL END AS flstmtitem_prmonth, CASE WHEN (flgrp_summarize AND flgrp_showdiffprcnt) THEN (flrptprmo.flrpt_diffprcnt) WHEN (flgrp_summarize AND flgrp_showendprcnt) THEN (flrptprmo.flrpt_endingprcnt) ELSE NULL END AS flstmtitem_prmonthprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE(flrptmo.flrpt_diff-flrptprmo.flrpt_diff,0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE(flrptmo.flrpt_ending-flrptprmo.flrpt_ending,0)) ELSE NULL END AS flstmtitem_prmonthdiff, CASE WHEN (flgrp_summarize AND (flhead_type IN ('I','C')) AND (flrptprmo.flrpt_diff > 0)) THEN (COALESCE((flrptmo.flrpt_diff-flrptprmo.flrpt_diff)/flrptprmo.flrpt_diff,0)) WHEN (flgrp_summarize AND (flhead_type = 'B') AND (flrptprmo.flrpt_ending > 0)) THEN (COALESCE((flrptmo.flrpt_ending-flrptprmo.flrpt_ending)/flrptprmo.flrpt_ending,0)) WHEN (flgrp_summarize AND (flrptprmo.flrpt_ending = 0)) THEN NULL ELSE NULL END AS flstmtitem_prmonthdiffprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE(flrptprqt.flrpt_diff,0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE(flrptprqt.flrpt_ending,0)) ELSE NULL END AS flstmtitem_prqtr, CASE WHEN (flgrp_summarize AND flgrp_showdiffprcnt) THEN (flrptprqt.flrpt_diffprcnt) WHEN (flgrp_summarize AND flgrp_showendprcnt) THEN (flrptprqt.flrpt_endingprcnt) ELSE NULL END AS flstmtitem_prqtrprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE(flrptqt.flrpt_diff-flrptprqt.flrpt_diff,0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE(flrptqt.flrpt_ending-flrptprqt.flrpt_ending,0)) ELSE NULL END AS flstmtitem_prqtrdiff, CASE WHEN (flgrp_summarize AND (flhead_type IN ('I','C')) AND (flrptprqt.flrpt_diff > 0)) THEN (COALESCE((flrptqt.flrpt_diff-flrptprqt.flrpt_diff)/flrptprqt.flrpt_diff,0)) WHEN (flgrp_summarize AND (flhead_type = 'B') AND (flrptprqt.flrpt_ending > 0)) THEN (COALESCE((flrptqt.flrpt_ending-flrptprqt.flrpt_ending)/flrptprqt.flrpt_ending,0)) WHEN (flgrp_summarize AND (flrptprqt.flrpt_ending = 0)) THEN NULL ELSE NULL END AS flstmtitem_prqtrdiffprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE(flrptpryr.flrpt_diff,0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE(flrptpryr.flrpt_ending,0)) ELSE NULL END AS flstmtitem_pryear, CASE WHEN (flgrp_summarize AND flgrp_showdiffprcnt) THEN (flrptpryr.flrpt_diffprcnt) WHEN (flgrp_summarize AND flgrp_showendprcnt) THEN (flrptpryr.flrpt_endingprcnt) ELSE NULL END AS flstmtitem_pryearprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE(flrptyr.flrpt_diff-flrptpryr.flrpt_diff,0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE(flrptyr.flrpt_ending-flrptpryr.flrpt_ending,0)) ELSE NULL END AS flstmtitem_pryeardiff, CASE WHEN (flgrp_summarize AND (flhead_type IN ('I','C')) AND (flrptpryr.flrpt_diff > 0)) THEN (COALESCE((flrptyr.flrpt_diff-flrptpryr.flrpt_diff)/flrptpryr.flrpt_diff,0)) WHEN (flgrp_summarize AND (flhead_type = 'B' ) AND (flrptpryr.flrpt_ending > 0)) THEN (COALESCE((flrptyr.flrpt_ending-flrptpryr.flrpt_ending)/flrptpryr.flrpt_ending,0)) WHEN (flgrp_summarize AND (flrptpryr.flrpt_ending = 0)) THEN NULL ELSE NULL END AS flstmtitem_pryeardiffprcnt FROM flgrp,flhead, (SELECT DISTINCT flrpt_flhead_id, flrpt_period_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_parent_id FROM flrpt WHERE ((flrpt_type='G') AND (flrpt_flhead_id=_p.flhead_id) AND (flrpt_period_id=pPeriodId) )) AS flrpt LEFT OUTER JOIN flrpt flrptmo ON ((flrptmo.flrpt_type=flrpt.flrpt_type) AND (flrptmo.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptmo.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptmo.flrpt_period_id=flrpt.flrpt_period_id) AND (flrptmo.flrpt_interval='M') AND (flrptmo.flrpt_order=flrpt.flrpt_order)) LEFT OUTER JOIN flrpt flrptqt ON ((flrptqt.flrpt_type=flrpt.flrpt_type) AND (flrptqt.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptqt.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptqt.flrpt_period_id=flrpt.flrpt_period_id) AND (flrptqt.flrpt_interval=_qtrInterval) AND (flrptqt.flrpt_order=flrpt.flrpt_order)) LEFT OUTER JOIN flrpt flrptyr ON ((flrptyr.flrpt_type=flrpt.flrpt_type) AND (flrptyr.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptyr.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptyr.flrpt_period_id=flrpt.flrpt_period_id) AND (flrptyr.flrpt_interval=_yrInterval) AND (flrptyr.flrpt_order=flrpt.flrpt_order)) LEFT OUTER JOIN flrpt flrptprmo ON ((flrptprmo.flrpt_type=flrpt.flrpt_type) AND (flrptprmo.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptprmo.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptprmo.flrpt_period_id=_priorMoPeriodId) AND (flrptprmo.flrpt_interval='M') AND (flrptprmo.flrpt_order=flrpt.flrpt_order)) LEFT OUTER JOIN flrpt flrptprqt ON ((flrptprqt.flrpt_type=flrpt.flrpt_type) AND (flrptprqt.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptprqt.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptprqt.flrpt_period_id=_priorQtPeriodId) AND (flrptprqt.flrpt_interval='Q') AND (flrptprqt.flrpt_order=flrpt.flrpt_order)) LEFT OUTER JOIN flrpt flrptpryr ON ((flrptpryr.flrpt_type=flrpt.flrpt_type) AND (flrptpryr.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptpryr.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptpryr.flrpt_period_id=_priorYrPeriodId) AND (flrptpryr.flrpt_interval='Y') AND (flrptpryr.flrpt_order=flrpt.flrpt_order)) WHERE ((flgrp_id = flrpt.flrpt_type_id) AND (flhead_id = flgrp_flhead_id)) UNION SELECT flrpt.flrpt_flhead_id AS flstmtitem_flhead_id, flrpt.flrpt_period_id AS flstmtitem_period_id, flrpt.flrpt_username AS flstmtitem_username, flrpt.flrpt_order AS flstmtitem_order, flrpt.flrpt_level AS flstmtitem_level, flrpt.flrpt_type AS flstmtitem_type, flrpt.flrpt_type_id AS flstmtitem_type_id, flrpt.flrpt_parent_id AS flstmtitem_parent_id, flrpt.flrpt_accnt_id AS flstmtitem_accnt_id, CASE WHEN (pIndentName) THEN formatindent(flrpt.flrpt_name,flrpt.flrpt_level) ELSE flrpt.flrpt_name END AS flstmtitem_name, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptmo.flrpt_diff,0)) ELSE (COALESCE(flrptmo.flrpt_ending,0)) END AS flstmtitem_month, (COALESCE(flrptmo.flrpt_debits,0)) AS flstmtitem_monthdb, (COALESCE(flrptmo.flrpt_credits,0)) AS flstmtitem_monthcr, CASE WHEN (flitem_showdiffprcnt) THEN (flrptmo.flrpt_diffprcnt) WHEN (flitem_showendprcnt) THEN (flrptmo.flrpt_endingprcnt) ELSE NULL END AS flstmtitem_monthprcnt, (COALESCE(flrptmo.flrpt_budget,0)) AS flstmtitem_monthbudget, (flrptmo.flrpt_budgetprcnt) AS flstmtitem_monthbudgetprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE((flrptmo.flrpt_diff-flrptmo.flrpt_budget),0)) ELSE (COALESCE((flrptmo.flrpt_ending-flrptmo.flrpt_budget),0)) END AS flstmtitem_monthbudgetdiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptmo.flrpt_budget > 0)) THEN (COALESCE(((flrptmo.flrpt_diff-flrptmo.flrpt_budget)/flrptmo.flrpt_budget),0)) WHEN ((flhead_type='B') AND (flrptmo.flrpt_budget > 0)) THEN (COALESCE(((flrptmo.flrpt_ending-flrptmo.flrpt_budget)/flrptmo.flrpt_budget),0)) ELSE NULL END AS flstmtitem_monthbudgetdiffprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptqt.flrpt_diff,0)) ELSE (COALESCE(flrptqt.flrpt_ending,0)) END AS flstmtitem_qtr, (COALESCE(flrptqt.flrpt_debits,0)) AS flstmtitem_qtrdb, (COALESCE(flrptqt.flrpt_credits,0)) AS flstmtitem_qtrcr, CASE WHEN (flitem_showdiffprcnt) THEN (COALESCE(flrptqt.flrpt_diffprcnt,0)) WHEN (flitem_showendprcnt) THEN (COALESCE(flrptqt.flrpt_endingprcnt,0)) ELSE NULL END AS flstmtitem_qtrprcnt, (COALESCE(flrptqt.flrpt_budget,0)) AS flstmtitem_qtrbudget, (flrptqt.flrpt_budgetprcnt) AS flstmtitem_qtrbudgetprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE((flrptqt.flrpt_diff-flrptqt.flrpt_budget),0)) ELSE (COALESCE((flrptqt.flrpt_ending-flrptqt.flrpt_budget),0)) END AS flstmtitem_qtrbudgetdiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptqt.flrpt_budget > 0)) THEN (COALESCE(((flrptqt.flrpt_diff-flrptqt.flrpt_budget)/flrptqt.flrpt_budget),0)) WHEN ((flhead_type='B') AND (flrptqt.flrpt_budget > 0)) THEN (COALESCE(((flrptqt.flrpt_ending-flrptqt.flrpt_budget)/flrptqt.flrpt_budget),0)) ELSE NULL END AS flstmtitem_qtrbudgetdiffprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptyr.flrpt_diff,0)) ELSE (COALESCE(flrptyr.flrpt_ending,0)) END AS flstmtitem_year, (COALESCE(flrptyr.flrpt_debits,0)) AS flstmtitem_yeardb, (COALESCE(flrptyr.flrpt_credits,0)) AS flstmtitem_yearcr, CASE WHEN (flitem_showdiffprcnt) THEN (flrptyr.flrpt_diffprcnt) WHEN (flitem_showendprcnt) THEN (flrptyr.flrpt_endingprcnt) ELSE NULL END AS flstmtitem_yearprcnt, (COALESCE(flrptyr.flrpt_budget,0)) AS flstmtitem_yearbudget, (flrptyr.flrpt_budgetprcnt) AS flstmtitem_yearbudgetprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE((flrptyr.flrpt_diff-flrptyr.flrpt_budget),0)) ELSE (COALESCE((flrptyr.flrpt_ending-flrptyr.flrpt_budget),0)) END AS flstmtitem_yearbudgetdiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptyr.flrpt_budget > 0)) THEN (COALESCE(((flrptyr.flrpt_diff-flrptyr.flrpt_budget)/flrptyr.flrpt_budget),0)) WHEN ((flhead_type = 'B') AND (flrptyr.flrpt_budget > 0)) THEN (COALESCE(((flrptyr.flrpt_ending-flrptyr.flrpt_budget)/flrptyr.flrpt_budget),0)) ELSE NULL END AS flstmtitem_yearbudgetdiffprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptprmo.flrpt_diff,0)) ELSE (COALESCE(flrptprmo.flrpt_ending,0)) END AS flstmtitem_prmonth, CASE WHEN (flitem_showdiffprcnt) THEN (flrptprmo.flrpt_diffprcnt) WHEN (flitem_showendprcnt) THEN (flrptprmo.flrpt_endingprcnt) ELSE NULL END AS flstmtitem_prmonthprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptmo.flrpt_diff-flrptprmo.flrpt_diff,0)) ELSE (COALESCE(flrptmo.flrpt_ending-flrptprmo.flrpt_ending,0)) END AS flstmtitem_prmonthdiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptprmo.flrpt_diff > 0)) THEN (COALESCE((flrptmo.flrpt_diff-flrptprmo.flrpt_diff)/flrptprmo.flrpt_diff,0)) WHEN ((flhead_type = 'B') AND (flrptprmo.flrpt_ending > 0)) THEN (COALESCE((flrptmo.flrpt_ending-flrptprmo.flrpt_ending)/flrptprmo.flrpt_ending,0)) ELSE NULL END AS flstmtitem_prmonthdiffprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptprqt.flrpt_diff,0)) ELSE (COALESCE(flrptprqt.flrpt_ending,0)) END AS flstmtitem_prqtr, CASE WHEN (flitem_showdiffprcnt) THEN (flrptprqt.flrpt_diffprcnt) WHEN (flitem_showendprcnt) THEN (flrptprqt.flrpt_endingprcnt) ELSE NULL END AS flstmtitem_prqtrprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptqt.flrpt_diff-flrptprqt.flrpt_diff,0)) ELSE (COALESCE(flrptqt.flrpt_ending-flrptprqt.flrpt_ending,0)) END AS flstmtitem_prqtrdiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptprqt.flrpt_diff > 0)) THEN (COALESCE((flrptqt.flrpt_diff-flrptprqt.flrpt_diff)/flrptprqt.flrpt_diff,0)) WHEN ((flhead_type = 'B') AND (flrptprqt.flrpt_ending > 0)) THEN (COALESCE((flrptqt.flrpt_ending-flrptprqt.flrpt_ending)/flrptprqt.flrpt_ending,0)) ELSE NULL END AS flstmtitem_prqtrdiffprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptpryr.flrpt_diff,0)) ELSE (COALESCE(flrptpryr.flrpt_ending,0)) END AS flstmtitem_pryear, CASE WHEN (flitem_showdiffprcnt) THEN (flrptpryr.flrpt_diffprcnt) WHEN (flitem_showendprcnt) THEN (flrptpryr.flrpt_endingprcnt) ELSE NULL END AS flstmtitem_pryearprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE((flrptyr.flrpt_diff-flrptpryr.flrpt_diff),0)) ELSE (COALESCE((flrptyr.flrpt_ending-flrptpryr.flrpt_ending),0)) END AS flstmtitem_pryeardiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptpryr.flrpt_diff > 0)) THEN (COALESCE((flrptyr.flrpt_diff-flrptpryr.flrpt_diff)/flrptpryr.flrpt_diff,0)) WHEN ((flhead_type = 'B' ) AND (flrptpryr.flrpt_ending > 0)) THEN (COALESCE((flrptyr.flrpt_ending-flrptpryr.flrpt_ending)/flrptpryr.flrpt_ending,0)) ELSE NULL END AS flstmtitem_pryeardiffprcnt FROM flitem,flhead, (SELECT DISTINCT flrpt_flhead_id, flrpt_period_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_parent_id, accnt_id AS flrpt_accnt_id, CASE WHEN (pShowNumbers) THEN (formatGLAccount(accnt_id) || '-' || accnt_descrip) ELSE accnt_descrip END AS flrpt_name FROM flrpt,accnt WHERE ((flrpt_type='I') AND (flrpt_flhead_id=_p.flhead_id) AND (flrpt_period_id=pPeriodid) AND (accnt_id=flrpt_accnt_id))) AS flrpt LEFT OUTER JOIN flrpt flrptmo ON ((flrptmo.flrpt_type=flrpt.flrpt_type) AND (flrptmo.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptmo.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptmo.flrpt_period_id=flrpt.flrpt_period_id) AND (flrptmo.flrpt_interval='M') AND (flrptmo.flrpt_order=flrpt.flrpt_order)) LEFT OUTER JOIN flrpt flrptqt ON ((flrptqt.flrpt_type=flrpt.flrpt_type) AND (flrptqt.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptqt.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptqt.flrpt_period_id=flrpt.flrpt_period_id) AND (flrptqt.flrpt_interval=_qtrInterval) AND (flrptqt.flrpt_order=flrpt.flrpt_order)) LEFT OUTER JOIN flrpt flrptyr ON ((flrptyr.flrpt_type=flrpt.flrpt_type) AND (flrptyr.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptyr.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptyr.flrpt_period_id=flrpt.flrpt_period_id) AND (flrptyr.flrpt_interval=_yrInterval) AND (flrptyr.flrpt_order=flrpt.flrpt_order)) LEFT OUTER JOIN flrpt flrptprmo ON ((flrptprmo.flrpt_type=flrpt.flrpt_type) AND (flrptprmo.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptprmo.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptprmo.flrpt_period_id=_priorMoPeriodId) AND (flrptprmo.flrpt_interval='M') AND (flrptprmo.flrpt_order=flrpt.flrpt_order)) LEFT OUTER JOIN flrpt flrptprqt ON ((flrptprqt.flrpt_type=flrpt.flrpt_type) AND (flrptprqt.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptprqt.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptprqt.flrpt_period_id=_priorQtPeriodId) AND (flrptprqt.flrpt_interval='Q') AND (flrptprqt.flrpt_order=flrpt.flrpt_order)) LEFT OUTER JOIN flrpt flrptpryr ON ((flrptpryr.flrpt_type=flrpt.flrpt_type) AND (flrptpryr.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptpryr.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptpryr.flrpt_period_id=_priorYrPeriodId) AND (flrptpryr.flrpt_interval='Y') AND (flrptpryr.flrpt_order=flrpt.flrpt_order) ) WHERE ((flitem_id = flrpt.flrpt_type_id) AND (flhead_id = flitem_flhead_id)) UNION SELECT flrpt.flrpt_flhead_id AS flstmtitem_flhead_id, flrpt.flrpt_period_id AS flstmtitem_period_id, flrpt.flrpt_username AS flstmtitem_username, flrpt.flrpt_order AS flstmtitem_order, flrpt.flrpt_level AS flstmtitem_level, flrpt.flrpt_type AS flstmtitem_type, flrpt.flrpt_type_id AS flstmtitem_type_id, flrpt.flrpt_parent_id AS flstmtitem_parent_id, NULL AS flstmtitem_accnt_id, CASE WHEN(flrpt.flrpt_type='T' AND flrpt.flrpt_level=0) THEN COALESCE(flrpt.flrpt_altname, 'Total') WHEN(flrpt.flrpt_type='T') THEN formatindent(COALESCE(flrpt.flrpt_altname, 'Subtotal') , (CASE WHEN pIndentName THEN flrpt.flrpt_level ELSE 0 END)) ELSE formatindent(('Type ' || flrpt.flrpt_type || ' ' || text(flrpt.flrpt_type_id)), (CASE WHEN pIndentName THEN flrpt.flrpt_level ELSE 0 END)) END AS flstmtitem_name, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptmo.flrpt_diff,0)) ELSE (COALESCE(flrptmo.flrpt_ending,0)) END AS flstmtitem_month, (COALESCE(flrptmo.flrpt_debits,0)) AS flstmtitem_monthdb, (COALESCE(flrptmo.flrpt_credits,0)) AS flstmtitem_monthcr, CASE WHEN (flhead_type IN ('I','C')) THEN (flrptmo.flrpt_diffprcnt) ELSE (flrptmo.flrpt_endingprcnt) END AS flstmtitem_monthprcnt, (COALESCE(flrptmo.flrpt_budget,0)) AS flstmtitem_monthbudget, (flrptmo.flrpt_budgetprcnt) AS flstmtitem_monthbudgetprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE((flrptmo.flrpt_diff-flrptmo.flrpt_budget),0)) ELSE (COALESCE((flrptmo.flrpt_ending-flrptmo.flrpt_budget),0)) END AS flstmtitem_monthbudgetdiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptmo.flrpt_budget > 0)) THEN (COALESCE(((flrptmo.flrpt_diff-flrptmo.flrpt_budget)/flrptmo.flrpt_budget),0)) WHEN ((flhead_type='B') AND (flrptmo.flrpt_budget > 0)) THEN (COALESCE(((flrptmo.flrpt_ending-flrptmo.flrpt_budget)/flrptmo.flrpt_budget),0)) ELSE NULL END AS flstmtitem_monthbudgetdiffprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptqt.flrpt_diff,0)) ELSE (COALESCE(flrptqt.flrpt_ending,0)) END AS flstmtitem_qtr, (COALESCE(flrptqt.flrpt_debits,0)) AS flstmtitem_qtrdb, (COALESCE(flrptqt.flrpt_credits,0)) AS flstmtitem_qtrcr, CASE WHEN (flhead_type IN ('I','C')) THEN (flrptqt.flrpt_diffprcnt) ELSE (flrptqt.flrpt_endingprcnt) END AS flstmtitem_qtrprcnt, (COALESCE(flrptqt.flrpt_budget,0)) AS flstmtitem_qtrbudget, (flrptqt.flrpt_budgetprcnt) AS flstmtitem_qtrbudgetprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE((flrptqt.flrpt_diff-flrptqt.flrpt_budget),0)) ELSE (COALESCE((flrptqt.flrpt_ending-flrptqt.flrpt_budget),0)) END AS flstmtitem_qtrbudgetdiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptqt.flrpt_budget > 0)) THEN (COALESCE(((flrptqt.flrpt_diff-flrptqt.flrpt_budget)/flrptqt.flrpt_budget),0)) WHEN ((flhead_type='B') AND (flrptqt.flrpt_budget > 0)) THEN (COALESCE(((flrptqt.flrpt_ending-flrptqt.flrpt_budget)/flrptqt.flrpt_budget),0)) ELSE NULL END AS flstmtitem_qtrbudgetdiffprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptyr.flrpt_diff,0)) ELSE (COALESCE(flrptyr.flrpt_ending,0)) END AS flstmtitem_year, (COALESCE(flrptyr.flrpt_debits,0)) AS flstmtitem_yeardb, (COALESCE(flrptyr.flrpt_credits,0)) AS flstmtitem_yearcr, CASE WHEN (flhead_type IN ('I','C')) THEN (flrptyr.flrpt_diffprcnt) ELSE (flrptyr.flrpt_endingprcnt) END AS flstmtitem_yearprcnt, (COALESCE(flrptyr.flrpt_budget,0)) AS flstmtitem_yearbudget, (flrptyr.flrpt_budgetprcnt) AS flstmtitem_yearbudgetprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE((flrptyr.flrpt_diff-flrptyr.flrpt_budget),0)) ELSE (COALESCE((flrptyr.flrpt_ending-flrptyr.flrpt_budget),0)) END AS flstmtitem_yearbudgetdiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptyr.flrpt_budget > 0)) THEN (COALESCE(((flrptyr.flrpt_diff-flrptyr.flrpt_budget)/flrptyr.flrpt_budget),0)) WHEN ((flhead_type = 'B') AND (flrptyr.flrpt_budget > 0)) THEN (COALESCE(((flrptyr.flrpt_ending-flrptyr.flrpt_budget)/flrptyr.flrpt_budget),0)) ELSE NULL END AS flstmtitem_yearbudgetdiffprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptprmo.flrpt_diff,0)) ELSE (COALESCE(flrptprmo.flrpt_ending,0)) END AS flstmtitem_prmonth, CASE WHEN (flhead_type IN ('I','C')) THEN (flrptprmo.flrpt_diffprcnt) ELSE (flrptprmo.flrpt_endingprcnt) END AS flstmtitem_prmonthprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptmo.flrpt_diff-flrptprmo.flrpt_diff,0)) ELSE (COALESCE(flrptmo.flrpt_ending-flrptprmo.flrpt_ending,0)) END AS flstmtitem_prmonthdiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptprmo.flrpt_diff > 0)) THEN (COALESCE((flrptmo.flrpt_diff-flrptprmo.flrpt_diff)/flrptprmo.flrpt_diff,0)) WHEN ((flhead_type = 'B') AND (flrptprmo.flrpt_ending > 0)) THEN (COALESCE((flrptmo.flrpt_ending-flrptprmo.flrpt_ending)/flrptprmo.flrpt_ending,0)) ELSE NULL END AS flstmtitem_prmonthdiffprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptprqt.flrpt_diff,0)) ELSE (COALESCE(flrptprqt.flrpt_ending,0)) END AS flstmtitem_prqtr, CASE WHEN (flhead_type IN ('I','C')) THEN (flrptprqt.flrpt_diffprcnt) ELSE (flrptprqt.flrpt_endingprcnt) END AS flstmtitem_prqtrprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptqt.flrpt_diff-flrptprqt.flrpt_diff,0)) ELSE (COALESCE(flrptqt.flrpt_ending-flrptprqt.flrpt_ending,0)) END AS flstmtitem_prqtrdiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptprqt.flrpt_diff > 0)) THEN (COALESCE((flrptqt.flrpt_diff-flrptprqt.flrpt_diff)/flrptprqt.flrpt_diff,0)) WHEN ((flhead_type = 'B') AND (flrptprqt.flrpt_ending > 0)) THEN (COALESCE((flrptqt.flrpt_ending-flrptprqt.flrpt_ending)/flrptprqt.flrpt_ending,0)) ELSE NULL END AS flstmtitem_prqtrdiffprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptpryr.flrpt_diff,0)) ELSE (COALESCE(flrptpryr.flrpt_ending,0)) END AS flstmtitem_pryear, CASE WHEN (flhead_type IN ('I','C')) THEN (flrptpryr.flrpt_diffprcnt) ELSE (flrptpryr.flrpt_endingprcnt) END AS flstmtitem_pryearprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptyr.flrpt_diff-flrptpryr.flrpt_diff,0)) ELSE (COALESCE(flrptyr.flrpt_ending-flrptpryr.flrpt_ending,0)) END AS flstmtitem_pryeardiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptpryr.flrpt_diff > 0)) THEN (COALESCE((flrptyr.flrpt_diff-flrptpryr.flrpt_diff)/flrptpryr.flrpt_diff,0)) WHEN ((flhead_type = 'B' ) AND (flrptpryr.flrpt_ending > 0)) THEN (COALESCE((flrptyr.flrpt_ending-flrptpryr.flrpt_ending)/flrptpryr.flrpt_ending,0)) ELSE NULL END AS flstmtitem_pryeardiffprcnt FROM flhead CROSS JOIN (SELECT DISTINCT flrpt_flhead_id, flrpt_period_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_parent_id, flrpt_altname FROM flrpt WHERE ((NOT (flrpt_type IN ('G','I','S'))) AND (flrpt_flhead_id=_p.flhead_id) AND (flrpt_period_id=pPeriodId) )) AS flrpt LEFT OUTER JOIN flrpt flrptmo ON ((flrptmo.flrpt_type=flrpt.flrpt_type) AND (flrptmo.flrpt_order=flrpt.flrpt_order) AND (flrptmo.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptmo.flrpt_period_id=flrpt.flrpt_period_id) AND (flrptmo.flrpt_interval='M') ) LEFT OUTER JOIN flrpt flrptqt ON ((flrptqt.flrpt_type=flrpt.flrpt_type) AND (flrptqt.flrpt_order=flrpt.flrpt_order) AND (flrptqt.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptqt.flrpt_period_id=flrpt.flrpt_period_id) AND (flrptqt.flrpt_interval=_qtrInterval) ) LEFT OUTER JOIN flrpt flrptyr ON ((flrptyr.flrpt_type=flrpt.flrpt_type) AND (flrptyr.flrpt_order=flrpt.flrpt_order) AND (flrptyr.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptyr.flrpt_period_id=flrpt.flrpt_period_id) AND (flrptyr.flrpt_interval=_yrInterval) ) LEFT OUTER JOIN flrpt flrptprmo ON ((flrptprmo.flrpt_type=flrpt.flrpt_type) AND (flrptprmo.flrpt_order=flrpt.flrpt_order) AND (flrptprmo.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptprmo.flrpt_period_id=_priorMoPeriodId) AND (flrptprmo.flrpt_interval='M') ) LEFT OUTER JOIN flrpt flrptprqt ON ((flrptprqt.flrpt_type=flrpt.flrpt_type) AND (flrptprqt.flrpt_order=flrpt.flrpt_order) AND (flrptprqt.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptprqt.flrpt_period_id=_priorQtPeriodId) AND (flrptprqt.flrpt_interval='Q') ) LEFT OUTER JOIN flrpt flrptpryr ON ((flrptpryr.flrpt_type=flrpt.flrpt_type) AND (flrptpryr.flrpt_order=flrpt.flrpt_order) AND (flrptpryr.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptpryr.flrpt_period_id=_priorYrPeriodId) AND (flrptpryr.flrpt_interval='Y') ) WHERE (flhead_id=flrpt.flrpt_flhead_id) ORDER BY flstmtitem_order LOOP IF _prevlevel > _x.flstmtitem_level THEN _subgrp := _subgrp+1; END IF; _prevlevel:=_x.flstmtitem_level; _row.flstmtitem_subgrp := _subgrp; IF NOT _first THEN RETURN NEXT _row; END IF; _first := FALSE; _row.flstmtitem_flhead_id := _x.flstmtitem_flhead_id; _row.flstmtitem_period_id := _x.flstmtitem_period_id; _row.flstmtitem_username := _x.flstmtitem_username; _row.flstmtitem_order := _x.flstmtitem_order; _row.flstmtitem_level := _x.flstmtitem_level; _row.flstmtitem_type := _x.flstmtitem_type; _row.flstmtitem_type_id := _x.flstmtitem_type_id; _row.flstmtitem_parent_id := _x.flstmtitem_parent_id; _row.flstmtitem_accnt_id := _x.flstmtitem_accnt_id; _row.flstmtitem_name := _x.flstmtitem_name; _row.flstmtitem_month := _x.flstmtitem_month; _row.flstmtitem_monthdb := _x.flstmtitem_monthdb; _row.flstmtitem_monthcr := _x.flstmtitem_monthcr; _row.flstmtitem_monthprcnt := _x.flstmtitem_monthprcnt; _row.flstmtitem_monthbudget := _x.flstmtitem_monthbudget; _row.flstmtitem_monthbudgetprcnt := _x.flstmtitem_monthbudgetprcnt; _row.flstmtitem_monthbudgetdiff := _x.flstmtitem_monthbudgetdiff; _row.flstmtitem_monthbudgetdiffprcnt := _x.flstmtitem_monthbudgetdiffprcnt; _row.flstmtitem_qtr := _x.flstmtitem_qtr; _row.flstmtitem_qtrdb := _x.flstmtitem_qtrdb; _row.flstmtitem_qtrcr := _x.flstmtitem_qtrcr; _row.flstmtitem_qtrprcnt := _x.flstmtitem_qtrprcnt; _row.flstmtitem_qtrbudget := _x.flstmtitem_qtrbudget; _row.flstmtitem_qtrbudgetprcnt := _x.flstmtitem_qtrbudgetprcnt; _row.flstmtitem_qtrbudgetdiff := _x.flstmtitem_qtrbudgetdiff; _row.flstmtitem_qtrbudgetdiffprcnt := _x.flstmtitem_qtrbudgetdiffprcnt; _row.flstmtitem_year := _x.flstmtitem_year; _row.flstmtitem_yeardb := _x.flstmtitem_yeardb; _row.flstmtitem_yearcr := _x.flstmtitem_yearcr; _row.flstmtitem_yearprcnt := _x.flstmtitem_yearprcnt; _row.flstmtitem_yearbudget := _x.flstmtitem_yearbudget; _row.flstmtitem_yearbudgetprcnt := _x.flstmtitem_yearbudgetprcnt; _row.flstmtitem_yearbudgetdiff := _x.flstmtitem_yearbudgetdiff; _row.flstmtitem_yearbudgetdiffprcnt := _x.flstmtitem_yearbudgetdiffprcnt; _row.flstmtitem_prmonth := _x.flstmtitem_prmonth; _row.flstmtitem_prmonthprcnt := _x.flstmtitem_prmonthprcnt; _row.flstmtitem_prmonthdiff := _x.flstmtitem_prmonthdiff; _row.flstmtitem_prmonthdiffprcnt := _x.flstmtitem_prmonthdiffprcnt; _row.flstmtitem_prqtr := _x.flstmtitem_prqtr; _row.flstmtitem_prqtrprcnt := _x.flstmtitem_prqtrprcnt; _row.flstmtitem_prqtrdiff := _x.flstmtitem_prqtrdiff; _row.flstmtitem_prqtrdiffprcnt := _x.flstmtitem_prqtrdiffprcnt; _row.flstmtitem_pryear := _x.flstmtitem_pryear; _row.flstmtitem_pryearprcnt := _x.flstmtitem_pryearprcnt; _row.flstmtitem_pryeardiff := _x.flstmtitem_pryeardiff; _row.flstmtitem_pryeardiffprcnt := _x.flstmtitem_pryeardiffprcnt; END LOOP; _row.flstmtitem_subgrp := _subgrp + 1; RETURN NEXT _row; END; $_$; ALTER FUNCTION public.financialreport(integer, integer, boolean, boolean, integer) OWNER TO admin; -- -- Name: findapaccount(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION findapaccount(integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; _accntid INTEGER; BEGIN IF (NOT fetchMetricBool('InterfaceAPToGL')) THEN RETURN 0; END IF; SELECT apaccnt_ap_accnt_id INTO _accntid FROM apaccnt JOIN vendinfo ON (apaccnt_vendtype_id=vend_vendtype_id) WHERE (vend_id=pVendid); IF (FOUND) THEN RETURN _accntid; END IF; SELECT apaccnt_ap_accnt_id INTO _accntid FROM apaccnt JOIN vendtype ON (vendtype_code ~ apaccnt_vendtype) JOIN vendinfo ON (vend_vendtype_id=vendtype_id) WHERE ((apaccnt_vendtype_id=-1) AND (vend_id=pVendid)); IF (FOUND) THEN RETURN _accntid; END IF; RETURN -1; END; $_$; ALTER FUNCTION public.findapaccount(integer) OWNER TO admin; -- -- Name: findapdiscountaccount(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION findapdiscountaccount(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; _accntid INTEGER; BEGIN IF (NOT fetchMetricBool('InterfaceAPToGL')) THEN RETURN 0; END IF; SELECT apaccnt_discount_accnt_id INTO _accntid FROM apaccnt JOIN vendinfo ON (apaccnt_vendtype_id=vend_vendtype_id) WHERE (vend_id=pVendid); IF (FOUND) THEN RETURN _accntid; END IF; SELECT apaccnt_discount_accnt_id INTO _accntid FROM apaccnt JOIN vendtype ON (vendtype_code ~ apaccnt_vendtype) JOIN vendinfo ON (vend_vendtype_id=vendtype_id) WHERE ((apaccnt_vendtype_id=-1) AND (vend_id=pVendid)); IF (FOUND) THEN RETURN _accntid; END IF; RETURN -1; END; $_$; ALTER FUNCTION public.findapdiscountaccount(integer) OWNER TO admin; -- -- Name: findapprepaidaccount(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION findapprepaidaccount(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; _accntid INTEGER; BEGIN IF (NOT fetchMetricBool('InterfaceAPToGL')) THEN RETURN 0; END IF; -- Check for a Vendor Type specific Account SELECT apaccnt_prepaid_accnt_id INTO _accntid FROM apaccnt JOIN vendinfo ON (apaccnt_vendtype_id=vend_vendtype_id) WHERE (vend_id=pVendid); IF (FOUND) THEN RETURN _accntid; END IF; -- Check for a Vendor Type pattern SELECT apaccnt_prepaid_accnt_id INTO _accntid FROM apaccnt JOIN vendtype ON (vendtype_code ~ apaccnt_vendtype) JOIN vendinfo ON (vend_vendtype_id=vendtype_id) WHERE ((apaccnt_vendtype_id=-1) AND (vend_id=pVendid)); IF (FOUND) THEN RETURN _accntid; END IF; RETURN -1; END; $_$; ALTER FUNCTION public.findapprepaidaccount(integer) OWNER TO admin; -- -- Name: findaraccount(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION findaraccount(integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; _accntid INTEGER; BEGIN IF (NOT fetchMetricBool('InterfaceARToGL')) THEN RETURN 0; END IF; -- Check for a Customer Type specific Account SELECT araccnt_ar_accnt_id INTO _accntid FROM araccnt, custinfo WHERE ( (araccnt_custtype_id=cust_custtype_id) AND (cust_id=pCustid) ); IF (FOUND) THEN RETURN _accntid; END IF; -- Check for a Customer Type pattern SELECT araccnt_ar_accnt_id INTO _accntid FROM araccnt, custinfo, custtype WHERE ( (custtype_code ~ araccnt_custtype) AND (araccnt_custtype_id=-1) AND (cust_custtype_id=custtype_id) AND (cust_id=pCustid) ); IF (FOUND) THEN RETURN _accntid; END IF; RETURN -1; END; $_$; ALTER FUNCTION public.findaraccount(integer) OWNER TO admin; -- -- Name: findardiscountaccount(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION findardiscountaccount(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; _accntid INTEGER; BEGIN IF (NOT fetchMetricBool('InterfaceARToGL')) THEN RETURN 0; END IF; -- Check for a Customer Type specific Account SELECT araccnt_discount_accnt_id INTO _accntid FROM araccnt, custinfo WHERE ( (araccnt_custtype_id=cust_custtype_id) AND (cust_id=pCustid) ); IF (FOUND) THEN RETURN _accntid; END IF; -- Check for a Customer Type pattern SELECT araccnt_discount_accnt_id INTO _accntid FROM araccnt, custinfo, custtype WHERE ( (custtype_code ~ araccnt_custtype) AND (cust_custtype_id=custtype_id) AND (araccnt_custtype_id=-1) AND (cust_id=pCustid) ); IF (FOUND) THEN RETURN _accntid; END IF; RETURN -1; END; $_$; ALTER FUNCTION public.findardiscountaccount(integer) OWNER TO admin; -- -- Name: findcalendarorigin(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION findcalendarorigin(integer) RETURNS date LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCalheadid ALIAS FOR $1; _originType CHAR(1); _origin DATE; BEGIN SELECT calhead_origin INTO _originType FROM calhead WHERE (calhead_id=pCalheadid); IF (NOT FOUND) THEN _origin := NULL; ELSIF (_originType = 'D') THEN _origin := CURRENT_DATE; ELSIF (_originType = 'E') THEN _origin := (CURRENT_DATE + 1); ELSIF (_originType = 'W') THEN _origin := (CURRENT_DATE - EXTRACT(DOW FROM CURRENT_DATE)::INTEGER); ELSIF (_originType = 'X') THEN _origin := ((CURRENT_DATE - EXTRACT(DOW FROM CURRENT_DATE)::INTEGER) + INTERVAL '1 week'); ELSIF (_originType = 'M') THEN _origin := date_trunc('month', CURRENT_DATE); ELSIF (_originType = 'N') THEN _origin := (date_trunc('month', CURRENT_DATE) + INTERVAL '1 month'); ELSIF (_originType = 'L') THEN _origin := (date_trunc('year', CURRENT_DATE) - INTERVAL '1 year'); ELSIF (_originType = 'Y') THEN _origin := date_trunc('year', CURRENT_DATE); ELSIF (_originType = 'Z') THEN _origin := (date_trunc('year', CURRENT_DATE) + INTERVAL '1 year'); ELSE _origin := NULL; END IF; RETURN _origin; END; $_$; ALTER FUNCTION public.findcalendarorigin(integer) OWNER TO admin; -- -- Name: findcustomerform(integer, character); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION findcustomerform(integer, character) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; pFormtype ALIAS FOR $2; _f RECORD; _found BOOLEAN; BEGIN -- Check for a Customer Type specific Form SELECT custform.* INTO _f FROM custform JOIN custinfo ON (custform_custtype_id=cust_custtype_id) WHERE (cust_id=pCustid); IF (FOUND) THEN _found := TRUE; ELSE -- Check for a Customer Type pattern SELECT custform.* INTO _f FROM custform JOIN custtype ON (custtype_code ~ custform_custtype) JOIN custinfo ON (cust_custtype_id=custtype_id) WHERE ((custform_custtype_id=-1) AND (cust_id=pCustid)); IF (FOUND) THEN _found := TRUE; ELSE _found := FALSE; END IF; END IF; IF (_found) THEN IF ( (pFormType = 'I') AND (_f.custform_invoice_report_name IS NOT NULL) ) THEN RETURN _f.custform_invoice_report_name; ELSIF ( (pFormType = 'C') AND (_f.custform_creditmemo_report_name IS NOT NULL) ) THEN RETURN _f.custform_creditmemo_report_name; ELSIF ( (pFormType = 'S') AND (_f.custform_statement_report_name IS NOT NULL) ) THEN RETURN _f.custform_statement_report_name; ELSIF ( (pFormType = 'Q') AND (_f.custform_quote_report_name IS NOT NULL) ) THEN RETURN _f.custform_quote_report_name; ELSIF ( (pFormType = 'P') AND (_f.custform_packinglist_report_name IS NOT NULL) ) THEN RETURN _f.custform_packinglist_report_name; ELSIF ( (pFormType = 'L') AND (_f.custform_sopicklist_report_name IS NOT NULL) ) THEN RETURN _f.custform_sopicklist_report_name; END IF; END IF; IF (pFormType = 'I') THEN RETURN 'Invoice'; ELSIF (pFormType = 'C') THEN RETURN 'CreditMemo'; ELSIF (pFormType = 'S') THEN RETURN 'Statement'; ELSIF (pFormType = 'Q') THEN RETURN 'Quote'; ELSIF (pFormType = 'P') THEN RETURN 'PackingList-Shipment'; ELSIF (pFormType = 'L') THEN RETURN 'PackingList'; END IF; END; $_$; ALTER FUNCTION public.findcustomerform(integer, character) OWNER TO admin; -- -- Name: finddeferredaccount(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION finddeferredaccount(integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; _accntid INTEGER; BEGIN IF (NOT fetchMetricBool('InterfaceARToGL')) THEN RETURN 0; END IF; -- Check for a Customer Type specific Account SELECT araccnt_deferred_accnt_id INTO _accntid FROM araccnt JOIN custinfo ON (araccnt_custtype_id=cust_custtype_id) WHERE (cust_id=pCustid); IF (FOUND) THEN RETURN _accntid; END IF; -- Check for a Customer Type pattern SELECT araccnt_deferred_accnt_id INTO _accntid FROM araccnt JOIN custtype ON (custtype_code ~ araccnt_custtype) JOIN custinfo ON (cust_custtype_id=custtype_id) WHERE ((araccnt_custtype_id=-1) AND (cust_id=pCustid)); IF (FOUND) THEN RETURN _accntid; END IF; RETURN -1; END; $_$; ALTER FUNCTION public.finddeferredaccount(integer) OWNER TO admin; -- -- Name: findfreightaccount(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION findfreightaccount(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; _accntid INTEGER; BEGIN IF (NOT fetchMetricBool('InterfaceARToGL')) THEN RETURN 0; END IF; -- Check for a Customer Type specific Account SELECT araccnt_freight_accnt_id INTO _accntid FROM araccnt, custinfo WHERE ( (araccnt_custtype_id=cust_custtype_id) AND (cust_id=pCustid) ); IF (FOUND) THEN RETURN _accntid; END IF; -- Check for a Customer Type pattern SELECT araccnt_freight_accnt_id INTO _accntid FROM araccnt, custinfo, custtype WHERE ( (custtype_code ~ araccnt_custtype) AND (cust_custtype_id=custtype_id) AND (araccnt_custtype_id=-1) AND (cust_id=pCustid) ); IF (FOUND) THEN RETURN _accntid; END IF; -- Find the default SELECT metric_value::INTEGER INTO _accntid FROM metric WHERE (metric_name='FreightAccount'); IF (FOUND) THEN RETURN _accntid; END IF; RETURN -1; END; $_$; ALTER FUNCTION public.findfreightaccount(integer) OWNER TO admin; -- -- Name: findperiodend(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION findperiodend(integer) RETURNS date LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCalitemid ALIAS FOR $1; _calType CHAR(1); _calItem RECORD; _start DATE; _loop INTEGER; BEGIN SELECT calhead_type INTO _calType FROM calhead, acalitem WHERE ((acalitem_calhead_id=calhead_id) AND (acalitem_id=pCalitemid)); IF (NOT FOUND) THEN SELECT calhead_type INTO _calType FROM calhead, rcalitem WHERE ((rcalitem_calhead_id=calhead_id) AND (rcalitem_id=pCalitemid)); IF (NOT FOUND) THEN RETURN NULL; END IF; END IF; IF (_calType = 'A') THEN RETURN ( SELECT (findPeriodStart(acalitem_id) + acalitem_periodlength - 1) FROM acalitem WHERE (acalitem_id=pCalitemid) ); ELSIF (_calType = 'R') THEN -- Grab the relative calitem's particulars SELECT rcalitem_periodtype, rcalitem_periodcount INTO _calitem FROM rcalitem WHERE (rcalitem_id=pCalitemid); IF (NOT FOUND) THEN RETURN NULL; END If; -- Grab the origin of the calitem SELECT findPeriodStart(pCalitemid) INTO _start; IF (_start IS NULL) THEN -- If days... ELSIF (_calitem.rcalitem_periodtype = 'D') THEN _start := (_start + _calitem.rcalitem_periodcount - 1); -- If weeks... (gotta be a better way) ELSIF (_calitem.rcalitem_periodtype = 'W') THEN _loop := _calitem.rcalitem_periodcount; WHILE (_loop > 0) LOOP _start := (_start + INTERVAL '1 week'); _loop := (_loop - 1); END LOOP; _start := (_start - 1); -- If months... (gotta be a better way) ELSIF (_calitem.rcalitem_periodtype = 'M') THEN _loop := _calitem.rcalitem_periodcount; WHILE (_loop > 0) LOOP _start := (_start + INTERVAL '1 month'); _loop := (_loop - 1); END LOOP; _start := (_start - 1); -- If years... (gotta be a better way) ELSIF (_calitem.rcalitem_periodtype = 'Y') THEN _loop := _calitem.rcalitem_periodcount; WHILE (_loop > 0) LOOP _start := (_start + INTERVAL '1 year'); _loop := (_loop - 1); END LOOP; _start := (_start - 1); ELSE _start := NULL; END IF; ELSE _start := NULL; END IF; RETURN _start; END; $_$; ALTER FUNCTION public.findperiodend(integer) OWNER TO admin; -- -- Name: findperiodstart(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION findperiodstart(integer) RETURNS date LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCalitemid ALIAS FOR $1; _calType CHAR(1); _calItem RECORD; _start DATE; _loop INTEGER; BEGIN SELECT calhead_type INTO _calType FROM calhead, acalitem WHERE ((acalitem_calhead_id=calhead_id) AND (acalitem_id=pCalitemid)); IF (NOT FOUND) THEN SELECT calhead_type INTO _calType FROM calhead, rcalitem WHERE ((rcalitem_calhead_id=calhead_id) AND (rcalitem_id=pCalitemid)); IF (NOT FOUND) THEN RETURN NULL; END IF; END IF; IF (_calType = 'A') THEN RETURN ( SELECT acalitem_periodstart FROM acalitem WHERE (acalitem_id=pCalitemid) ); ELSIF (_calType = 'R') THEN -- Grab the relative calitem's particulars SELECT rcalitem_offsettype, rcalitem_offsetcount INTO _calitem FROM rcalitem WHERE (rcalitem_id=pCalitemid); IF (NOT FOUND) THEN RETURN NULL; END If; -- Grab the origin of the calitem's parend calhead SELECT findCalendarOrigin(calhead_id) INTO _start FROM calhead, rcalitem WHERE ((rcalitem_calhead_id=calhead_id) AND (rcalitem_id=pCalitemid)); -- If days... IF (_calitem.rcalitem_offsettype = 'D') THEN _start := (_start + _calitem.rcalitem_offsetcount); -- If weeks... ELSIF (_calitem.rcalitem_offsettype = 'W') THEN _start := (_start + (_calitem.rcalitem_offsetcount * 7)); -- If months... (gotta be a better way) ELSIF (_calitem.rcalitem_offsettype = 'M') THEN _loop := _calitem.rcalitem_offsetcount; IF (_loop > 0) THEN WHILE (_loop > 0) LOOP _start := (_start + INTERVAL '1 month'); _loop := _loop - 1; END LOOP; ELSE WHILE (_loop < 0) LOOP _start := (_start - INTERVAL '1 month'); _loop := _loop + 1; END LOOP; END IF; -- If years... (gotta be a better way) ELSIF (_calitem.rcalitem_offsettype = 'Y') THEN _loop := _calitem.rcalitem_offsetcount; IF (_loop > 0) THEN WHILE (_loop > 0) LOOP _start := (_start + INTERVAL '1 year'); _loop := _loop - 1; END LOOP; ELSE WHILE (_loop < 0) LOOP _start := (_start - INTERVAL '1 year'); _loop := _loop + 1; END LOOP; END IF; ELSE _start := NULL; END IF; ELSE _start := NULL; END IF; RETURN _start; END; $_$; ALTER FUNCTION public.findperiodstart(integer) OWNER TO admin; -- -- Name: findprepaidaccount(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION findprepaidaccount(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; _accntid INTEGER; BEGIN IF (NOT fetchMetricBool('InterfaceARToGL')) THEN RETURN 0; END IF; -- Check for a Customer Type specific Account SELECT araccnt_prepaid_accnt_id INTO _accntid FROM araccnt JOIN custinfo ON (araccnt_custtype_id=cust_custtype_id) WHERE (cust_id=pCustid); IF (FOUND) THEN RETURN _accntid; END IF; -- Check for a Customer Type pattern SELECT araccnt_prepaid_accnt_id INTO _accntid FROM araccnt JOIN custtype ON (custtype_code ~ araccnt_custtype) JOIN custinfo ON (cust_custtype_id=custtype_id) WHERE ((araccnt_custtype_id=-1) AND (cust_id=pCustid) ); IF (FOUND) THEN RETURN _accntid; END IF; RETURN -1; END; $_$; ALTER FUNCTION public.findprepaidaccount(integer) OWNER TO admin; -- -- Name: findsalesaccnt(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION findsalesaccnt(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN findSalesAccnt($1, 'IS', $2, NULL, NULL); END; $_$; ALTER FUNCTION public.findsalesaccnt(integer, integer) OWNER TO admin; -- -- Name: findsalesaccnt(integer, text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION findsalesaccnt(integer, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN findSalesAccnt($1, $2, $3, NULL, NULL); END; $_$; ALTER FUNCTION public.findsalesaccnt(integer, text, integer) OWNER TO admin; -- -- Name: findsalesaccnt(integer, text, integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION findsalesaccnt(pid integer, pidtype text, pcustid integer, psaletypeid integer, pshipzoneid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _s RECORD; BEGIN IF (pidType = 'I') THEN -- Check for a custtype specific rule SELECT salesaccnt_id, CASE WHEN (salesaccnt_warehous_id<>-1) THEN 1 ELSE 0 END + CASE WHEN (salesaccnt_custtype_id<>-1) THEN 2 ELSE 0 END + CASE WHEN (salesaccnt_prodcat_id<>-1) THEN 3 ELSE 0 END + CASE WHEN (salesaccnt_shipzone_id<>-1) THEN 4 ELSE 0 END + CASE WHEN (salesaccnt_saletype_id<>-1) THEN 5 ELSE 0 END AS orderby INTO _s FROM salesaccnt, item, prodcat, custinfo, custtype WHERE ( (salesaccnt_warehous_id=-1) AND (item_prodcat_id=prodcat_id) AND (cust_custtype_id=custtype_id) AND ( (salesaccnt_prodcat='.*') OR ( (salesaccnt_prodcat_id=-1) AND (salesaccnt_prodcat<>'') AND (prodcat_code ~ salesaccnt_prodcat) ) OR ( (salesaccnt_prodcat_id=prodcat_id) ) ) AND ( (salesaccnt_custtype='.*') OR ( (salesaccnt_custtype_id=-1) AND (salesaccnt_custtype<>'') AND (custtype_code ~ salesaccnt_custtype) ) OR ( (salesaccnt_custtype_id=custtype_id) ) ) AND ( (salesaccnt_shipzone_id=-1) OR (salesaccnt_shipzone_id=pShipzoneid) ) AND ( (salesaccnt_saletype_id=-1) OR (salesaccnt_saletype_id=pSaletypeid) ) AND (item_id=pid) AND (cust_id=pCustid) ) ORDER BY orderby DESC, salesaccnt_custtype DESC, salesaccnt_prodcat DESC, salesaccnt_saletype_id DESC, salesaccnt_shipzone_id DESC LIMIT 1; ELSIF (pidType = 'IS') THEN -- Check for a custtype specific rule SELECT salesaccnt_id, CASE WHEN (salesaccnt_warehous_id<>-1) THEN 1 ELSE 0 END + CASE WHEN (salesaccnt_custtype_id<>-1) THEN 2 ELSE 0 END + CASE WHEN (salesaccnt_prodcat_id<>-1) THEN 3 ELSE 0 END + CASE WHEN (salesaccnt_shipzone_id<>-1) THEN 4 ELSE 0 END + CASE WHEN (salesaccnt_saletype_id<>-1) THEN 5 ELSE 0 END AS orderby INTO _s FROM salesaccnt, itemsite, item, prodcat, custinfo, custtype WHERE ( ( (salesaccnt_warehous_id=-1) OR (salesaccnt_warehous_id=itemsite_warehous_id) ) AND (itemsite_item_id=item_id) AND (item_prodcat_id=prodcat_id) AND (cust_custtype_id=custtype_id) AND ( (salesaccnt_prodcat='.*') OR ( (salesaccnt_prodcat_id=-1) AND (salesaccnt_prodcat<>'') AND (prodcat_code ~ salesaccnt_prodcat) ) OR ( (salesaccnt_prodcat_id=prodcat_id) ) ) AND ( (salesaccnt_custtype='.*') OR ( (salesaccnt_custtype_id=-1) AND (salesaccnt_custtype<>'') AND (custtype_code ~ salesaccnt_custtype) ) OR ( (salesaccnt_custtype_id=custtype_id) ) ) AND ( (salesaccnt_shipzone_id=-1) OR (salesaccnt_shipzone_id=pShipzoneid) ) AND ( (salesaccnt_saletype_id=-1) OR (salesaccnt_saletype_id=pSaletypeid) ) AND (itemsite_id=pid) AND (cust_id=pCustid) ) ORDER BY orderby DESC, salesaccnt_custtype DESC, salesaccnt_prodcat DESC, salesaccnt_warehous_id DESC, salesaccnt_saletype_id DESC, salesaccnt_shipzone_id DESC LIMIT 1; ELSE RETURN -2; -- invalid pidType END IF; IF (FOUND) THEN RETURN _s.salesaccnt_id; END IF; RETURN -1; END; $$; ALTER FUNCTION public.findsalesaccnt(pid integer, pidtype text, pcustid integer, psaletypeid integer, pshipzoneid integer) OWNER TO admin; -- -- Name: findspecialfinancial(text, text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION findspecialfinancial(text, text, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUnit ALIAS FOR $1; pType ALIAS FOR $2; pPeriodid ALIAS FOR $3; _value NUMERIC; BEGIN _value := 0.00; IF ('OpenAR' = pType) THEN IF ( pUnit IN ('D','E') ) THEN SELECT SUM( CASE WHEN (aropen_doctype IN ('C', 'R')) THEN ((aropen_amount - aropen_paid) * -1) ELSE (aropen_amount - aropen_paid) END ) INTO _value FROM aropen, period WHERE ((aropen_open) AND (aropen_duedate BETWEEN period_start AND period_end) AND (period_id=pPeriodid)); IF ('E' = pUnit) THEN _value := 0.00 - _value; END IF; END IF; END IF; IF ('OpenAP' = pType) THEN IF ( pUnit IN ('C','E') ) THEN SELECT SUM( CASE WHEN (apopen_doctype='C') THEN ((apopen_amount - apopen_paid) * -1) ELSE (apopen_amount - apopen_paid) END ) INTO _value FROM apopen, period WHERE ((apopen_open) AND (apopen_duedate BETWEEN period_start AND period_end) AND (period_id=pPeriodid)); END IF; END IF; RETURN _value; END; $_$; ALTER FUNCTION public.findspecialfinancial(text, text, integer) OWNER TO admin; -- -- Name: first_agg(anyelement, anyelement); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION first_agg(anyelement, anyelement) RETURNS anyelement LANGUAGE sql STABLE AS $_$ SELECT CASE WHEN $1 IS NULL THEN $2 ELSE $1 END; $_$; ALTER FUNCTION public.first_agg(anyelement, anyelement) OWNER TO admin; -- -- Name: firstline(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION firstline(text) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSource ALIAS FOR $1; _result TEXT := ''; BEGIN SELECT regexp_replace(pSource, E'^(\r?\n)*([^\r\n]*)\r?\n.*', E'\\2') INTO _result; RETURN _result; END; $_$; ALTER FUNCTION public.firstline(text) OWNER TO admin; -- -- Name: fixacl(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION fixacl() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; _count INTEGER := 0; _oldgrp BOOLEAN := false; _objtype TEXT; _table TEXT; _schema TEXT; BEGIN IF EXISTS(SELECT 1 FROM pg_group WHERE groname = 'openmfg') THEN _oldgrp := true; END IF; FOR _r IN SELECT relname, nspname, relkind, CASE relkind WHEN 'r' THEN 1 WHEN 'v' THEN 2 WHEN 'S' THEN 3 ELSE 4 END AS seq FROM pg_catalog.pg_class c, pg_namespace n WHERE ((n.oid=c.relnamespace) AND (nspname in ('public', 'api') OR nspname in (SELECT pkghead_name FROM pkghead)) AND (relkind in ('S', 'r', 'v'))) ORDER BY seq LOOP _schema := quote_ident(_r.nspname); _table := quote_ident(_r.relname); RAISE DEBUG '%.%', _schema, _table; IF (_oldgrp) THEN EXECUTE 'REVOKE ALL ON ' || _schema || '.' || _table || ' FROM openmfg;'; END IF; EXECUTE 'REVOKE ALL ON ' || _schema || '.' || _table || ' FROM PUBLIC;'; EXECUTE 'GRANT ALL ON ' || _schema || '.' || _table || ' TO GROUP xtrole;'; _count := _count + 1; _objtype := CASE _r.relkind WHEN 'S' THEN 'SEQUENCE' WHEN 'r' THEN 'TABLE' WHEN 'v' THEN 'VIEW' ELSE NULL END; IF (_objtype IS NOT NULL) THEN BEGIN EXECUTE 'ALTER ' || _objtype || ' ' || _schema || '.' || _table || ' OWNER TO admin;'; EXCEPTION WHEN OTHERS THEN RAISE WARNING 'Could not change ownership of %.% to admin', _schema, _table; END; END IF; END LOOP; RETURN _count; END; $$; ALTER FUNCTION public.fixacl() OWNER TO admin; -- -- Name: formatabachecks(integer, integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatabachecks(integer, integer, text) RETURNS SETOF achline LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pbankaccntid ALIAS FOR $1; -- all unprinted checks for this bankaccnt pcheckheadid ALIAS FOR $2; -- but if 2nd arg not null then just 1 check penckey ALIAS FOR $3; _bank RECORD; _batchcount INTEGER := 0; _batchdate DATE; _check RECORD; _vendnumber TEXT; _vendname TEXT; _filenum TEXT; _prevsec TEXT; _row achline%ROWTYPE; _totalcr NUMERIC := 0; _totaldb NUMERIC := 0; _detailcount INTEGER := 0; -- count of type 1 entries _vendbsb TEXT; BEGIN -- General notes: -- Numeric values are formatted using RPAD(TO_CHAR(#, '0..0SG', #)). -- TO_CHAR(#, ...) (at least in the default server locale) puts a space at -- the beginning of the string for numbers >= 0 and '-' for numbers < 0. -- 'SG' pushes the sign char to the end, then RPAD cuts it off. -- This whole thing is for Australian bank transactions only, and generates entries for an ABA file. -- Currently restricted to checks to Vendor; there's no support for checks to -- customers or tax authorities, or for debits or corrections. -- This function has been adapted from the US-centric ACH formatACHChecks function. IF (NOT fetchMetricBool('ACHEnabled')) THEN RAISE EXCEPTION 'Cannot format the ABA file because the system is not configured for ABA file generation.'; END IF; IF (LENGTH(COALESCE(penckey, '')) <= 0) THEN RAISE EXCEPTION 'Cannot format the ABA file because there is no encryption key.'; END IF; SELECT * INTO _bank FROM bankaccnt WHERE (bankaccnt_id=pbankaccntid); IF (NOT FOUND) THEN RAISE EXCEPTION 'Could not find the bank information to create the ABA file.'; ELSIF (NOT _bank.bankaccnt_ach_enabled) THEN RAISE EXCEPTION 'Cannot format the ABA file because the Bank Account % is not configured for ABA transactions.', _bank.bankaccnt_name; ELSIF (LENGTH(COALESCE(_bank.bankaccnt_routing, '')) <= 0) THEN RAISE EXCEPTION 'Cannot format the ABA file because the Bank Account % has no BSB number.', _bank.bankaccnt_name; END IF; -- Check the BSB number is in the right format and then re-format for output. -- Valid format is \d{3}-\d{3}|\d{6}000 IF (_bank.bankaccnt_routing ~ E'^(\\d{3})(?:-(?=\\d{3}$)|(?=\\d{3}0{3}$))(\\d{3})(0{3})?$') THEN _bank.bankaccnt_routing := regexp_replace( _bank.bankaccnt_routing, E'^(\\d{3})(?:-(?=\\d{3}$)|(?=\\d{3}0{3}$))(\\d{3})(0{3})?$', E'\\1-\\2' ); ELSE RAISE EXCEPTION 'Cannot format the ABA file because the Bank Account % has an invalid BSB number.', _bank.bankaccnt_name; END IF; _filenum := LPAD(fetchNextNumber('ACHBatch'), 8, '0'); IF (COALESCE(_bank.bankaccnt_ach_lastdate,startOfTime()) < CURRENT_DATE OR _bank.bankaccnt_ach_lastfileid IS NULL) THEN _bank.bankaccnt_ach_lastfileid = '0'; ELSIF (_bank.bankaccnt_ach_lastfileid = '9') THEN _bank.bankaccnt_ach_lastfileid = 'A'; ELSIF (_bank.bankaccnt_ach_lastfileid = 'Z') THEN RAISE EXCEPTION 'Cannot write % check % to an ABA file because too many files have been written for this bank already today.', _bank.bankaccnt_name, _check.checkhead_number; ELSE _bank.bankaccnt_ach_lastfileid = CHR(ASCII(_bank.bankaccnt_ach_lastfileid) + 1); END IF; _row.achline_checkhead_id := NULL; _row.achline_batch := _filenum; _row.achline_type := 'HEADER'; _row.achline_value := RPAD( RPAD('0',18) -- Record Type 0 blank filled with 17 spaces || '01' -- Reel sequence number || RPAD(_bank.bankaccnt_bankname,3) -- Approved financial instition abbreviation. || RPAD('',7) -- blank filled || RPAD(fetchMetricText('ACHCompanyName'), 26) -- Name of user supplying ABA file || LPAD(fetchMetricText('ACHCompanyId'),6) -- User identification number APCA issued || RPAD('PAYMENT',12) -- description of entries on file -- currently only use payment description || TO_CHAR(CURRENT_DATE, 'DDMMYY'), -- date to be processed 120 -- blank filled to 120 characters ); RETURN NEXT _row; FOR _check IN SELECT * FROM checkhead JOIN vendinfo ON (checkhead_recip_type='V' AND checkhead_recip_id=vend_id AND vend_ach_enabled) JOIN curr_symbol ON (checkhead_curr_id=curr_id) LEFT OUTER JOIN crmacct ON (crmacct_vend_id=vend_id) WHERE ((checkhead_bankaccnt_id=pbankaccntid) AND (checkhead_amount > 0) AND (checkhead_id=pcheckheadid OR pcheckheadid IS NULL) AND NOT checkhead_posted AND NOT checkhead_replaced AND NOT checkhead_deleted AND NOT checkhead_void AND NOT checkhead_printed AND (LENGTH(COALESCE(checkhead_ach_batch,'')) <= 0) AND (curr_abbr='AUD')) ORDER BY checkhead_checkdate, vend_name LOOP IF (COALESCE(_check.checkhead_number, -1) <= 0 AND _bank.bankaccnt_ach_genchecknum) THEN _check.checkhead_number := fetchNextCheckNumber(_check.checkhead_bankaccnt_id); END IF; -- Although a crmacct record is not required for used in this function -- this code is retained for consistancy with the original formatachchecks function. IF (_check.crmacct_id IS NULL) THEN RAISE WARNING 'Vendor % does not have a corresponding crmacct record.', _check.checkhead_recip_id; ELSIF (_check.crmacct_type IS NULL) THEN RAISE WARNING 'crmacct for vendor % does not have a valid crmacct_type.', _check.checkhead_recip_id; END IF; _vendnumber := CASE WHEN _check.vend_ach_use_vendinfo THEN _check.vend_number ELSE _check.vend_ach_indiv_number END; _vendname := CASE WHEN _check.vend_ach_use_vendinfo THEN _check.vend_name ELSE _check.vend_ach_indiv_name END; IF (COALESCE(_check.vend_ach_routingnumber, '') = '') THEN RAISE EXCEPTION 'Cannot write % check % to an ABA file because the BSB number for % has not been supplied.', _bank.bankaccnt_name, _check.checkhead_number, _vendnumber; ELSIF (COALESCE(_check.vend_ach_accntnumber, '') = '') THEN RAISE EXCEPTION 'Cannot write % check % to an ABA file because the account number for % has not been supplied.', _bank.bankaccnt_name, _check.checkhead_number, _vendnumber; END IF; _check.vend_ach_routingnumber := decrypt(setbytea(_check.vend_ach_routingnumber), setbytea(penckey), 'bf'); _check.vend_ach_accntnumber := decrypt(setbytea(_check.vend_ach_accntnumber), setbytea(penckey), 'bf'); -- Check the BSB number is in the right format and then re-format for output. -- Valid format is \d{3}-\d{3}|\d{6}000 IF (formatbytea(_check.vend_ach_routingnumber) ~ E'^(\\d{3})(?:-(?=\\d{3}$)|(?=\\d{3}0{3}$))(\\d{3})(0{3})?$') THEN _vendbsb := regexp_replace( formatbytea(_check.vend_ach_routingnumber), E'^(\\d{3})(?:-(?=\\d{3}$)|(?=\\d{3}0{3}$))(\\d{3})(0{3})?$', E'\\1-\\2' ); ELSE RAISE EXCEPTION 'Cannot write % check % to an ABA file because the BSB number for % is not valid.', _bank.bankaccnt_name, _check.checkhead_number, _vendnumber; END IF; _row.achline_checkhead_id := _check.checkhead_id; _row.achline_batch := _filenum; _row.achline_type := 'DETAIL'; _totaldb := _totaldb + _check.checkhead_amount; -- Total debits for balancing entry _detailcount := _detailcount + 1; -- Detail record counter (type 1) _totalcr := _totalcr + _check.checkhead_amount; -- Total credits from payments _row.achline_value := RPAD('1' -- record type 1 || _vendbsb -- vendor BSB # || LPAD(formatbytea(_check.vend_ach_accntnumber), 9) -- vendor account no. ||' ' -- withholding tax indicator ||'50' -- transaction code, this should be calculated. || LPAD(to_char(_check.checkhead_amount,'FM99999999V99'),10,'0') -- amount || RPAD(_vendname, 32) -- vendor name || RPAD('Deposit',8) || RPAD('#' , 2) || LPAD (_filenum,8,' ') -- Lodgement Reference || _bank.bankaccnt_routing -- BSB # || RPAD(_bank.bankaccnt_accntnumber, 9) -- company account number || RPAD(fetchMetricText('ACHCompanyName'), 16) -- company account name || LPAD('', 8, '0'), -- Witholding Tax Amount 120 -- line width ); RETURN NEXT _row; UPDATE checkhead SET checkhead_ach_batch=_filenum, checkhead_number=_check.checkhead_number WHERE (checkhead_id=_check.checkhead_id); END LOOP; IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot write an ABA file for % because there are no checks pending in AUD for EFT-enabled Vendors.', _bank.bankaccnt_name; END IF; -- Place a final balancing detail record. -- Check that the balancing record actually balances. IF (_totalcr != _totaldb) THEN RAISE EXCEPTION 'Cannot write an ABA file for % because the total credits: % does not equal the total debits: %, file will not balance.', _bank.bankaccnt_name, _totalcr, _totaldb; END IF; _detailcount := _detailcount + 1; _row.achline_checkhead_id := NULL; _row.achline_batch := _filenum; _row.achline_type := 'BALANCING'; -- keep in sync with the other batchcontrol record format above -- THE FOLLOWING IS THE DEBIT BALANCING RECORD _row.achline_value := RPAD('1' -- record type 1 || _bank.bankaccnt_routing -- Austalian BSB # || LPAD(_bank.bankaccnt_accntnumber, 9) -- company account no. || ' ' -- withholding tax indicator || '13' -- transaction code || to_char(_totaldb,'FM09999999V99') -- the balancing amount || RPAD(fetchMetricText('ACHCompanyName'), 32) -- company name || RPAD('DIRECT DEPOSIT',18) || _bank.bankaccnt_routing -- Austalian BSB # || RPAD(_bank.bankaccnt_accntnumber, 9) -- company account number || RPAD(fetchMetricText('ACHCompanyName'), 16) -- company account name || LPAD('', 8, '0'), -- Witholding Tax Amount 120 -- line width ); RETURN NEXT _row; RAISE DEBUG 'formatABAChecks building TRAILER with _totaldb %, _totalcr %, _detailcount %', _totaldb, _totalcr, _detailcount; -- file control record _row.achline_checkhead_id := NULL; _row.achline_batch := _filenum; _row.achline_type := 'TRAILER'; _row.achline_value := RPAD('7' -- record type 7 || RPAD('999-999', 7) -- BSB format filler || RPAD('' , 12) -- blank || LPAD(to_char((_totaldb - _totalcr),'FM09999999V99'),10,'0') -- net total amount || LPAD(to_char(_totalcr, 'FM09999999V99'),10,'0') -- total credit amount || LPAD(to_char(_totaldb, 'FM09999999V99'),10,'0') -- total debit amount || RPAD('', 24) -- blank || RPAD(to_char(_detailcount, 'FM000000'), 6,'0'), -- count of type 1 records 120 -- blank fill ); RETURN NEXT _row; UPDATE bankaccnt SET bankaccnt_ach_lastdate=CURRENT_DATE, bankaccnt_ach_lastfileid=_bank.bankaccnt_ach_lastfileid WHERE (bankaccnt_id=_bank.bankaccnt_id); RETURN; END; $_$; ALTER FUNCTION public.formatabachecks(integer, integer, text) OWNER TO admin; -- -- Name: formatachchecks(integer, integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatachchecks(integer, integer, text) RETURNS SETOF achline LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pbankaccntid ALIAS FOR $1; -- all unprinted checks for this bankaccnt pcheckheadid ALIAS FOR $2; -- but if 2nd arg not null then just 1 check penckey ALIAS FOR $3; _bank RECORD; _batchcount INTEGER := 0; _batchcr NUMERIC := 0; _batchdate DATE; _batchdb NUMERIC := 0; _batchhash INTEGER := 0; _check RECORD; _ccdnumber TEXT; _ccdname TEXT; _entrycount INTEGER := 0; _filenum TEXT; _prevsec TEXT; _row achline%ROWTYPE; _rowcount INTEGER := 0; _sec TEXT; _serviceclass TEXT := '200'; -- 220 = credits, 225 = debits, 200 = mixed _totalcr NUMERIC := 0; _totaldb NUMERIC := 0; _totalentrycnt INTEGER := 0; _totalhash INTEGER := 0; _transactionprefix TEXT; BEGIN -- General notes: -- Numeric values are formatted using RPAD(TO_CHAR(#, '0..0SG', #)). -- TO_CHAR(#, ...) (at least in the default server locale) puts a space at -- the beginning of the string for numbers >= 0 and '-' for numbers < 0. -- 'SG' pushes the sign char to the end, then RPAD cuts it off. -- This whole thing is US-centric, as that's where the NACHA is. -- Currently restricted to checks to Vendor; there's no support for checks to -- customers or tax authorities, or for debits or corrections. IF (NOT fetchMetricBool('ACHEnabled')) THEN RAISE EXCEPTION 'Cannot format the ACH file because the system is not configured for ACH file generation.'; END IF; IF (LENGTH(COALESCE(penckey, '')) <= 0) THEN RAISE EXCEPTION 'Cannot format the ACH file because there is no encryption key.'; END IF; SELECT * INTO _bank FROM bankaccnt WHERE (bankaccnt_id=pbankaccntid); IF (NOT FOUND) THEN RAISE EXCEPTION 'Could not find the bank information to create the ACH file.'; ELSIF (NOT _bank.bankaccnt_ach_enabled) THEN RAISE EXCEPTION 'Cannot format the ACH file because the Bank Account % is not configured for ACH transactions.', _bank.bankaccnt_name; ELSIF (LENGTH(COALESCE(_bank.bankaccnt_routing, '')) <= 0) THEN RAISE EXCEPTION 'Cannot format the ACH file because the Bank Account % has no routing number.', _bank.bankaccnt_name; END IF; _filenum := LPAD(fetchNextNumber('ACHBatch'), 8, '0'); IF (COALESCE(_bank.bankaccnt_ach_lastdate,startOfTime()) < CURRENT_DATE OR _bank.bankaccnt_ach_lastfileid IS NULL) THEN _bank.bankaccnt_ach_lastfileid = '0'; ELSIF (_bank.bankaccnt_ach_lastfileid = '9') THEN _bank.bankaccnt_ach_lastfileid = 'A'; ELSIF (_bank.bankaccnt_ach_lastfileid = 'Z') THEN RAISE EXCEPTION 'Cannot write % check % to an ACH file because too many files have been written for this bank already today.', _bank.bankaccnt_name, _check.checkhead_number; ELSE _bank.bankaccnt_ach_lastfileid = CHR(ASCII(_bank.bankaccnt_ach_lastfileid) + 1); END IF; _rowcount := _rowcount + 1; _row.achline_checkhead_id := NULL; _row.achline_batch := _filenum; _row.achline_type := 'FILEHEADER'; _row.achline_value := RPAD('1' || '01' || RPAD(CASE WHEN _bank.bankaccnt_ach_desttype = 'B' THEN ' ' || _bank.bankaccnt_routing WHEN _bank.bankaccnt_ach_desttype = 'F' THEN ' ' || _bank.bankaccnt_ach_fed_dest ELSE _bank.bankaccnt_ach_dest END, 10) || RPAD(CASE WHEN _bank.bankaccnt_ach_origintype = 'B' THEN ' ' || _bank.bankaccnt_routing WHEN _bank.bankaccnt_ach_origintype = 'I' THEN formatAchCompanyId() ELSE _bank.bankaccnt_ach_origin END, 10) || TO_CHAR(CURRENT_DATE, 'YYMMDD') || TO_CHAR(CURRENT_TIMESTAMP, 'HH24MM') || UPPER(_bank.bankaccnt_ach_lastfileid) || '094' || '10' || '1' || RPAD(CASE WHEN _bank.bankaccnt_ach_desttype = 'B' THEN _bank.bankaccnt_bankname WHEN _bank.bankaccnt_ach_desttype = 'F' THEN 'Federal Reserve' ELSE _bank.bankaccnt_ach_destname END, 23) || RPAD(CASE WHEN _bank.bankaccnt_ach_origintype = 'B' THEN ' ' || _bank.bankaccnt_bankname WHEN _bank.bankaccnt_ach_origintype = 'I' THEN fetchMetricText('ACHCompanyName') ELSE _bank.bankaccnt_ach_originname END, 23) || RPAD(_filenum, 8), 94); RETURN NEXT _row; FOR _check IN SELECT * FROM checkhead JOIN vendinfo ON (checkhead_recip_type='V' AND checkhead_recip_id=vend_id AND vend_ach_enabled) JOIN curr_symbol ON (checkhead_curr_id=curr_id) LEFT OUTER JOIN crmacct ON (crmacct_vend_id=vend_id) WHERE ((checkhead_bankaccnt_id=pbankaccntid) AND (checkhead_amount > 0) AND (checkhead_id=pcheckheadid OR pcheckheadid IS NULL) AND NOT checkhead_posted AND NOT checkhead_replaced AND NOT checkhead_deleted AND NOT checkhead_void AND NOT checkhead_printed AND (LENGTH(COALESCE(checkhead_ach_batch,'')) <= 0) AND (curr_abbr='USD')) ORDER BY checkhead_checkdate, vend_name LOOP IF (COALESCE(_check.checkhead_number, -1) <= 0 AND _bank.bankaccnt_ach_genchecknum) THEN _check.checkhead_number := fetchNextCheckNumber(_check.checkhead_bankaccnt_id); END IF; _prevsec := _sec; IF (_check.crmacct_type = 'I') THEN _sec := 'PPD'; ELSE _sec := 'CCD'; IF (_check.crmacct_id IS NULL) THEN RAISE WARNING 'Vendor % does not have a corresponding crmacct record.', _check.checkhead_recip_id; ELSIF (_check.crmacct_type IS NULL) THEN RAISE WARNING 'crmacct for vendor % does not have a valid crmacct_type.', _check.checkhead_recip_id; END IF; END IF; _ccdnumber := CASE WHEN _check.vend_ach_use_vendinfo THEN _check.vend_number ELSE _check.vend_ach_indiv_number END; _ccdname := CASE WHEN _check.vend_ach_use_vendinfo THEN _check.vend_name ELSE _check.vend_ach_indiv_name END; IF (COALESCE(_check.vend_ach_routingnumber, '') = '') THEN RAISE EXCEPTION 'Cannot write % check % to an ACH file because the routing number for % has not been supplied.', _bank.bankaccnt_name, _check.checkhead_number, _ccdnumber; ELSIF (COALESCE(_check.vend_ach_accntnumber, '') = '') THEN RAISE EXCEPTION 'Cannot write % check % to an ACH file because the account number for % has not been supplied.', _bank.bankaccnt_name, _check.checkhead_number, _ccdnumber; END IF; _check.vend_ach_routingnumber := decrypt(setbytea(_check.vend_ach_routingnumber), setbytea(penckey), 'bf'); _check.vend_ach_accntnumber := decrypt(setbytea(_check.vend_ach_accntnumber), setbytea(penckey), 'bf'); _transactionprefix := CASE WHEN (_check.vend_ach_accnttype = 'K') THEN '2' WHEN (_check.vend_ach_accnttype = 'C') THEN '3' END; -- create separate batches for each check date and for PPD vs CCD IF (COALESCE(_batchdate, startOfTime()) != _check.checkhead_checkdate OR (_prevsec != _sec)) THEN IF (_batchcount > 0) THEN _rowcount := _rowcount + 1; _row.achline_checkhead_id := NULL; _row.achline_batch := _filenum; _row.achline_type := 'BATCHCONTROL'; -- keep in sync with the other batchcontrol record format below _row.achline_value := RPAD('8' || _serviceclass || RPAD(TO_CHAR(_entrycount, '000000SG'), 6) || RPAD(TO_CHAR(_batchhash % 10000000000, '0000000000SG'), 10) || RPAD(TO_CHAR(_batchdb, '0000000000V99SG'), 12) || RPAD(TO_CHAR(_batchcr, '0000000000V99SG'), 12) || RPAD(formatAchCompanyId(), 10) || RPAD(' ', 19) || RPAD(' ', 6) || RPAD(_bank.bankaccnt_routing, 8) || RPAD(TO_CHAR(_batchcount, '0000000SG'), 7), 94); RETURN NEXT _row; END IF; _batchhash := 0; _batchcr := 0; _batchdb := 0; _batchdate := _check.checkhead_checkdate; _entrycount := 0; _rowcount := _rowcount + 1; _batchcount := _batchcount + 1; _row.achline_checkhead_id := NULL; _row.achline_batch := _filenum; _row.achline_type := 'BATCHHEADER'; -- effective entry date = 1 or 2 banking days after the banking day -- of processing (the following accounts for weekends but not holidays) _row.achline_value := RPAD('5' || _serviceclass || RPAD(fetchMetricText('ACHCompanyName'), 16) || RPAD('', 20) -- TODO: find a use || RPAD(formatAchCompanyId(), 10) || _sec || RPAD('xTuple ERP', 10) || TO_CHAR(_check.checkhead_checkdate, 'YYMMDD') || TO_CHAR(CURRENT_DATE + COALESCE(_bank.bankaccnt_ach_leadtime,1) + CASE WHEN EXTRACT(DOW FROM CURRENT_DATE) = 5 THEN 2 WHEN EXTRACT(DOW FROM CURRENT_DATE) = 6 THEN 1 ELSE 0 END, 'YYMMDD') || RPAD('', 3) || '1' || RPAD(_bank.bankaccnt_routing, 8) || RPAD(TO_CHAR(_batchcount, '0000000SG'), 7), 94); RETURN NEXT _row; END IF; _row.achline_checkhead_id := _check.checkhead_id; _row.achline_batch := _filenum; _row.achline_type := _sec; IF (_sec = 'CCD' OR _sec = 'PPD') THEN _rowcount := _rowcount + 1; _entrycount := _entrycount + 1; _totalentrycnt := _totalentrycnt + 1; _batchhash := _batchhash + CAST(SUBSTRING(_bank.bankaccnt_routing FOR 8) AS INTEGER); _totalhash := _totalhash + CAST(SUBSTRING(_bank.bankaccnt_routing FOR 8) AS INTEGER); _batchdb := _batchdb + _check.checkhead_amount; _totaldb := _totaldb + _check.checkhead_amount; _row.achline_value := RPAD('6' || _transactionprefix || '7' -- debit || RPAD(_bank.bankaccnt_routing, 9) -- 2 fields || RPAD(_bank.bankaccnt_accntnumber, 17) || RPAD(TO_CHAR(_check.checkhead_amount, '00000000V99SG'), 10) || RPAD(fetchMetricText('ACHCompanyId'), 15) || RPAD(fetchMetricText('ACHCompanyName'), 22) || RPAD(TO_CHAR(_check.checkhead_id % 100, '00SG'), 2) -- last 2 digits of checkhead_id || '0' || RPAD(_bank.bankaccnt_routing, 9) -- split field || RPAD(TO_CHAR(_entrycount, '000000SG'), 15-9), 94); RETURN NEXT _row; _rowcount := _rowcount + 1; _entrycount := _entrycount + 1; _totalentrycnt := _totalentrycnt + 1; _batchhash := _batchhash + CAST(SUBSTRING(formatbytea(_check.vend_ach_routingnumber) FOR 8) AS INTEGER); _totalhash := _totalhash + CAST(SUBSTRING(formatbytea(_check.vend_ach_routingnumber) FOR 8) AS INTEGER); _totalcr := _totalcr + _check.checkhead_amount; _batchcr := _batchcr + _check.checkhead_amount; _row.achline_value := RPAD('6' || _transactionprefix || '2' -- credit || RPAD(formatbytea(_check.vend_ach_routingnumber), 9) -- 2 fields || RPAD(formatbytea(_check.vend_ach_accntnumber), 17) || RPAD(TO_CHAR(_check.checkhead_amount, '00000000V99SG'), 10) || RPAD(_ccdnumber, 15) || RPAD(_ccdname, 22) || RPAD(TO_CHAR(_check.checkhead_id % 100, '00SG'), 2) -- last 2 digits of checkhead_id || '0' || RPAD(_bank.bankaccnt_routing, 9) -- split field || RPAD(TO_CHAR(_entrycount, '000000SG'), 15-9), 94); RETURN NEXT _row; ELSE RAISE EXCEPTION 'Cannot write % check % to an ACH file because % is not a supported SEC code.', _bank.bankaccnt_name, _check.checkhead_number, _sec; END IF; UPDATE checkhead SET checkhead_ach_batch=_filenum, checkhead_number=_check.checkhead_number WHERE (checkhead_id=_check.checkhead_id); END LOOP; IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot write an ACH file for % because there are no checks pending in USD for ACH-enabled Vendors.', _bank.bankaccnt_name; END IF; -- place a final batch control record IF (_batchcount > 0) THEN _rowcount := _rowcount + 1; _row.achline_checkhead_id := NULL; _row.achline_batch := _filenum; _row.achline_type := 'BATCHCONTROL'; -- keep in sync with the other batchcontrol record format above _row.achline_value := RPAD('8' || _serviceclass || RPAD(TO_CHAR(_entrycount, '000000SG'), 6) || RPAD(TO_CHAR(_batchhash % 10000000000, '0000000000SG'), 10) || RPAD(TO_CHAR(_batchdb, '0000000000V99SG'), 12) || RPAD(TO_CHAR(_batchcr, '0000000000V99SG'), 12) || RPAD(formatAchCompanyId(), 10) || RPAD(' ', 19) || RPAD(' ', 6) || RPAD(_bank.bankaccnt_routing, 8) || RPAD(TO_CHAR(_batchcount, '0000000SG'), 7), 94); RETURN NEXT _row; END IF; -- and end with a file control record _rowcount := _rowcount + 1; _row.achline_checkhead_id := NULL; _row.achline_batch := _filenum; _row.achline_type := 'FILECONTROL'; _row.achline_value := RPAD('9' || RPAD(TO_CHAR(_batchcount, '000000SG'), 6) || RPAD(TO_CHAR(_rowcount, '000000SG'), 6) || RPAD(TO_CHAR(_totalentrycnt, '00000000SG'), 8) || RPAD(TO_CHAR(_totalhash % 10000000000, '0000000000SG'), 10) || RPAD(TO_CHAR(_totaldb, '0000000000V99SG'), 12) || RPAD(TO_CHAR(_totalcr, '0000000000V99SG'), 12) || RPAD('', 39), 94); RETURN NEXT _row; -- file must be a multiple of 10 lines long _row.achline_checkhead_id := NULL; _row.achline_batch := _filenum; _row.achline_type := 'BLOCKFILL'; WHILE (_rowcount % 10 > 0) LOOP _rowcount := _rowcount + 1; _row.achline_value := RPAD('99999999999999999999' || '99999999999999999999' || '99999999999999999999' || '99999999999999999999' || '99999999999999999999', 94); RETURN NEXT _row; END LOOP; UPDATE bankaccnt SET bankaccnt_ach_lastdate=CURRENT_DATE, bankaccnt_ach_lastfileid=_bank.bankaccnt_ach_lastfileid WHERE (bankaccnt_id=_bank.bankaccnt_id); RETURN; END; $_$; ALTER FUNCTION public.formatachchecks(integer, integer, text) OWNER TO admin; -- -- Name: formatachcompanyid(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatachcompanyid() RETURNS text LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN CASE WHEN fetchMetricText('ACHCompanyIdType') = 'D' THEN '3' WHEN fetchMetricText('ACHCompanyIdType') = 'E' THEN '1' WHEN fetchMetricText('ACHCompanyIdType') = 'O' THEN '9' END || CASE WHEN fetchMetricText('ACHCompanyIdType') = 'D' OR fetchMetricText('ACHCompanyIdType') = 'E' THEN REPLACE(fetchMetricText('ACHCompanyId'), '-', '') ELSE fetchMetricText('ACHCompanyId') END; END; $$; ALTER FUNCTION public.formatachcompanyid() OWNER TO admin; -- -- Name: formataddr(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formataddr(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAddrId ALIAS FOR $1; _return TEXT; BEGIN -- US conventions SELECT formatAddr(addr_line1, addr_line2, addr_line3, (COALESCE(addr_city,'') || ', ' || COALESCE(addr_state,'') || ' ' || COALESCE(addr_postalcode,'')), addr_country) INTO _return FROM addr WHERE (addr_id=pAddrId); RETURN _return; END; $_$; ALTER FUNCTION public.formataddr(integer) OWNER TO admin; -- -- Name: formataddr(text, text, text, text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formataddr(text, text, text, text, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE f_addr1 ALIAS FOR $1; f_addr2 ALIAS FOR $2; f_addr3 ALIAS FOR $3; csz ALIAS FOR $4; line ALIAS FOR $5; BEGIN RETURN formatAddr(f_addr1, f_addr2, f_addr3, csz, '', line); END; $_$; ALTER FUNCTION public.formataddr(text, text, text, text, integer) OWNER TO admin; -- -- Name: formataddr(text, text, text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formataddr(text, text, text, text, text) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE f_addr1 ALIAS FOR $1; f_addr2 ALIAS FOR $2; f_addr3 ALIAS FOR $3; csz ALIAS FOR $4; country ALIAS FOR $5; addr TEXT:=''; BEGIN IF (LENGTH(TRIM(both from f_addr1)) > 0) THEN addr:=f_addr1; END IF; IF (LENGTH(TRIM(both from f_addr2)) > 0) THEN IF (LENGTH(TRIM(both from addr)) > 0) THEN addr:=addr || E'\n'; END IF; addr:=addr || f_addr2; END IF; IF (LENGTH(TRIM(both from f_addr3)) > 0) THEN IF (LENGTH(TRIM(both from addr)) > 0) THEN addr:=addr || E'\n'; END IF; addr:=addr || f_addr3; END IF; IF (LENGTH(TRIM(both from csz)) > 0) THEN IF (LENGTH(TRIM(both from addr)) > 0) THEN addr:=addr || E'\n'; END IF; addr:=addr || csz; END IF; IF (LENGTH(TRIM(both from country)) > 0) THEN IF (LENGTH(TRIM(both from addr)) > 0) THEN addr:=addr || E'\n'; END IF; addr:=addr || country; END IF; RETURN addr; END; $_$; ALTER FUNCTION public.formataddr(text, text, text, text, text) OWNER TO admin; -- -- Name: formataddr(text, text, text, text, text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formataddr(text, text, text, text, text, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE f_addr1 ALIAS FOR $1; f_addr2 ALIAS FOR $2; f_addr3 ALIAS FOR $3; csz ALIAS FOR $4; country ALIAS FOR $5; line ALIAS FOR $6; i int:=0; BEGIN IF (LENGTH(TRIM(both from f_addr1)) > 0) THEN i:=i+1; END IF; IF (i=line) THEN RETURN f_addr1; END IF; IF (LENGTH(TRIM(both from f_addr2)) > 0) THEN i:=i+1; END IF; IF (i=line) THEN RETURN f_addr2; END IF; IF (LENGTH(TRIM(both from f_addr3)) > 0) THEN i:=i+1; END IF; IF (i=line) THEN RETURN f_addr3; END IF; IF (LENGTH(TRIM(both from csz)) > 0) THEN i:=i+1; END IF; IF (i=line) THEN RETURN csz; END IF; IF (LENGTH(TRIM(both from country)) > 0) THEN i:=i+1; END IF; IF (i=line) THEN RETURN country; END IF; RETURN ' '; END; $_$; ALTER FUNCTION public.formataddr(text, text, text, text, text, integer) OWNER TO admin; -- -- Name: formatboolyn(boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatboolyn(boolean) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBool ALIAS FOR $1; BEGIN IF (pBool) THEN RETURN 'Yes'; ELSE RETURN 'No'; END IF; END; $_$; ALTER FUNCTION public.formatboolyn(boolean) OWNER TO admin; -- -- Name: formatbooseq(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatbooseq(integer, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pBooitemSeqId ALIAS FOR $2; _result TEXT; BEGIN IF (fetchMetricBool('Routings')) THEN SELECT booitem_seqnumber::text INTO _result FROM xtmfg.booitem(pItemid) WHERE (booitem_seq_id=pBooitemSeqId); RETURN _result; ELSE RETURN NULL; END IF; END; $_$; ALTER FUNCTION public.formatbooseq(integer, integer) OWNER TO admin; -- -- Name: formatbytea(bytea); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatbytea(bytea) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pField ALIAS FOR $1; output_field TEXT; BEGIN output_field := pField; RETURN output_field; END; $_$; ALTER FUNCTION public.formatbytea(bytea) OWNER TO admin; -- -- Name: formatccdashes(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatccdashes(text, text) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCCard ALIAS FOR $1; pCCardType ALIAS FOR $2; _returnCard text; card_length integer; BEGIN IF (pCCardType = 'A') THEN _returnCard := pCCard; RETURN _returnCard; END IF; card_length := length(pCcard); if (card_length = 16) THEN _returnCard := substr(pCCard, 1, 4) || '-' || substr(pCCard, 5, 4) || '-' || substr(pCCard, 9, 4) || '-' || substr(pCCard, 13, 4); ELSE _returnCard := substr(pCCard, 1, 4) || '-' || substr(pCCard, 5, 4) || '-' || substr(pCCard, 9, 4) || '-' || substr(pCCard, 13, 1); END IF; RETURN _returnCard; END; $_$; ALTER FUNCTION public.formatccdashes(text, text) OWNER TO admin; -- -- Name: formatccnumber(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatccnumber(text) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCcardnum ALIAS FOR $1; card_length INTEGER; output_cardnum TEXT; BEGIN card_length := length(pCcardnum); IF (card_length = 13) THEN output_cardnum := '*********' || substr(pCcardnum, 10, 4); END IF; IF (card_length = 14) THEN output_cardnum := '**********' || substr(pCcardnum, 11, 4); END IF; IF (card_length = 15) THEN output_cardnum := '***********' || substr(pCcardnum, 12, 4); END IF; IF (card_length = 16) THEN output_cardnum := '************' || substr(pCcardnum, 13, 4); END IF; RETURN output_cardnum; END; $_$; ALTER FUNCTION public.formatccnumber(text) OWNER TO admin; -- -- Name: formatccnumber(bytea); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatccnumber(bytea) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCcardnum ALIAS FOR $1; card_length INTEGER; output_cardnum TEXT; BEGIN card_length := length(pCcardnum); IF (card_length = 13) THEN output_cardnum := '*********' || substr(pCcardnum, 10, 4); END IF; IF (card_length = 14) THEN output_cardnum := '**********' || substr(pCcardnum, 11, 4); END IF; IF (card_length = 15) THEN output_cardnum := '***********' || substr(pCcardnum, 12, 4); END IF; IF (card_length = 16) THEN output_cardnum := '************' || substr(pCcardnum, 13, 4); END IF; RETURN output_cardnum; END; $_$; ALTER FUNCTION public.formatccnumber(bytea) OWNER TO admin; -- -- Name: formatcntctname(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatcntctname(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCntctId ALIAS FOR $1; _r RECORD; _rows NUMERIC; BEGIN SELECT cntct_honorific, cntct_first_name, cntct_middle, cntct_last_name, cntct_suffix INTO _r FROM cntct WHERE (cntct_id=pCntctId); GET DIAGNOSTICS _rows = ROW_COUNT; IF (_rows = 0) THEN RETURN ''; END IF; RETURN formatCntctName(_r.cntct_honorific, _r.cntct_first_name, _r.cntct_middle, _r.cntct_last_name, _r.cntct_suffix); END; $_$; ALTER FUNCTION public.formatcntctname(integer) OWNER TO admin; -- -- Name: formatcntctname(text, text, text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatcntctname(text, text, text, text, text) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pHonorific ALIAS FOR $1; pFirstName ALIAS FOR $2; pMiddle ALIAS FOR $3; pLastName ALIAS FOR $4; pSuffix ALIAS FOR $5; _name TEXT := ''; BEGIN IF (LENGTH(TRIM(both from COALESCE(pHonorific,''))) > 0) THEN IF (POSITION('.' IN COALESCE(pHonorific, '')) > 0) THEN _name:= pHonorific; ELSE _name:= pHonorific || '.'; END IF; END IF; IF (LENGTH(TRIM(both from COALESCE(pFirstName,''))) > 0) THEN IF (LENGTH(TRIM(both from _name)) > 0) THEN _name:=_name || ' '; END IF; _name:=_name || pFirstName; END IF; IF (LENGTH(TRIM(both from COALESCE(pMiddle,''))) > 0) THEN IF (LENGTH(TRIM(both from _name)) > 0) THEN _name:=_name || ' '; END IF; IF (POSITION('.' IN COALESCE(pHonorific, '')) > 0) THEN _name:=_name || pMiddle; ELSE _name:=_name || pMiddle || '.'; END IF; END IF; IF (LENGTH(TRIM(both from COALESCE(pLastName,''))) > 0) THEN IF (LENGTH(TRIM(both from _name)) > 0) THEN _name:=_name || ' '; END IF; _name:=_name || pLastName; END IF; IF (LENGTH(TRIM(both from COALESCE(pSuffix,''))) > 0) THEN IF (LENGTH(TRIM(both from _name)) > 0) THEN _name:=_name || ' '; END IF; _name:=_name || pSuffix; END IF; RETURN _name; END; $_$; ALTER FUNCTION public.formatcntctname(text, text, text, text, text) OWNER TO admin; -- -- Name: formatcost(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatcost(numeric) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN formatNumeric($1, 'cost'); END;$_$; ALTER FUNCTION public.formatcost(numeric) OWNER TO admin; -- -- Name: formatcounttagbarcode(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatcounttagbarcode(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCnttagid ALIAS FOR $1; _barcode TEXT; BEGIN SELECT ( E'\138CTXX' || LTRIM(TO_CHAR(LENGTH(invcnt_tagnumber), '00')) || invcnt_tagnumber ) INTO _barcode FROM invcnt WHERE (invcnt_id=pCnttagid); RETURN _barcode; END; $_$; ALTER FUNCTION public.formatcounttagbarcode(integer) OWNER TO admin; -- -- Name: formatcreditmemonumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatcreditmemonumber(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmheadid ALIAS FOR $1; BEGIN RETURN ( SELECT COALESCE(cmhead_number::TEXT, '') FROM cmhead WHERE (cmhead_id=pCmheadid) ); END; $_$; ALTER FUNCTION public.formatcreditmemonumber(integer) OWNER TO admin; -- -- Name: formatdate(date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatdate(date) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT TO_CHAR($1, COALESCE((SELECT locale_dateformat FROM locale, usr WHERE ((usr_locale_id=locale_id) AND (usr_username=getEffectiveXtUser())) ), 'yyyy-mm-dd') ) AS result $_$; ALTER FUNCTION public.formatdate(date) OWNER TO admin; -- -- Name: formatdate(timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatdate(timestamp with time zone) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT TO_CHAR($1, COALESCE((SELECT locale_dateformat FROM locale, usr WHERE ((usr_locale_id=locale_id) AND (usr_username=getEffectiveXtUser())) ), 'yyyy-mm-dd' )) AS result $_$; ALTER FUNCTION public.formatdate(timestamp with time zone) OWNER TO admin; -- -- Name: formatdate(date, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatdate(date, text) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pDate ALIAS FOR $1; pString ALIAS FOR $2; BEGIN IF ( (pDate = startOfTime()) OR (pDate = endOfTime()) OR (pDate IS NULL) ) THEN RETURN pString; ELSE RETURN formatDate(pDate); END IF; END; $_$; ALTER FUNCTION public.formatdate(date, text) OWNER TO admin; -- -- Name: formatdatetime(timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatdatetime(timestamp with time zone) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT TO_CHAR($1, COALESCE((SELECT locale_timestampformat FROM locale, usr WHERE ((usr_locale_id=locale_id) AND (usr_username=getEffectiveXtUser())) ), 'yyyy-mm-dd HH24:MI:SS')) AS result $_$; ALTER FUNCTION public.formatdatetime(timestamp with time zone) OWNER TO admin; -- -- Name: formatdatetime(timestamp without time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatdatetime(timestamp without time zone) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT TO_CHAR($1, COALESCE((SELECT locale_timestampformat FROM locale, usr WHERE ((usr_locale_id=locale_id) AND (usr_username=getEffectiveXtUser())) ), 'yyyy-mm-dd HH24:MI:SS')) AS result $_$; ALTER FUNCTION public.formatdatetime(timestamp without time zone) OWNER TO admin; -- -- Name: formatextprice(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatextprice(numeric) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN formatNumeric($1, 'extprice'); END;$_$; ALTER FUNCTION public.formatextprice(numeric) OWNER TO admin; -- -- Name: formatflitemdescrip(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatflitemdescrip(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlitemId ALIAS FOR $1; _x RECORD; _descrip TEXT; BEGIN SELECT flitem_accnt_id, flitem_company, flitem_profit, flitem_number, flitem_sub, flitem_type, flitem_subaccnttype_code, accnt_id, accnt_descrip INTO _x FROM flitem LEFT OUTER JOIN accnt ON flitem_accnt_id=accnt_id WHERE flitem_id=pFlitemId; IF _x.flitem_accnt_id > -1 THEN SELECT (formatGLAccount(_x.accnt_id) || '-' || _x.accnt_descrip) INTO _descrip; ELSE _descrip:=''; IF _x.flitem_type = 'A' THEN _descrip:='Type=' || 'Asset'; ELSE IF _x.flitem_type='L' THEN _descrip:='Type=' || 'Liability'; ELSE IF _x.flitem_type='R' THEN _descrip:='Type=' || 'Revenue'; ELSE IF _x.flitem_type='E' THEN _descrip:='Type=' || 'Expense'; ELSE IF _x.flitem_type='Q' THEN _descrip:='Type=' || 'Equity'; END IF; END IF; END IF; END IF; END IF; IF _x.flitem_subaccnttype_code <> 'All' THEN IF (LENGTH(TRIM(both from _descrip)) > 0) THEN _descrip:=_descrip || ', '; END IF; _descrip:=_descrip || 'Sub Accnt Type=' || _x.flitem_subaccnttype_code; END IF; IF _x.flitem_company <> 'All' THEN IF (LENGTH(TRIM(both from _descrip)) > 0) THEN _descrip:=_descrip || ', '; END IF; _descrip:=_descrip || 'Company=' || _x.flitem_company; END IF; IF _x.flitem_profit <> 'All' THEN IF (LENGTH(TRIM(both from _descrip)) > 0) THEN _descrip:=_descrip || ', '; END IF; _descrip:=_descrip || 'Profit=' || _x.flitem_profit; END IF; IF _x.flitem_number <> 'All' THEN IF (LENGTH(TRIM(both from _descrip)) > 0) THEN _descrip:=_descrip || ', '; END IF; _descrip:=_descrip || 'Number=' || _x.flitem_number; END IF; IF _x.flitem_sub <> 'All' THEN IF (LENGTH(TRIM(both from _descrip)) > 0) THEN _descrip:=_descrip || ', '; END IF; _descrip:=_descrip || 'Sub Accnt=' || _x.flitem_sub; END IF; END IF; RETURN _descrip; END; $_$; ALTER FUNCTION public.formatflitemdescrip(integer) OWNER TO admin; -- -- Name: formatglaccount(text, text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatglaccount(pcompany text, pprofit text, pnumber text, psub text) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _number TEXT := ''; BEGIN IF (fetchMetricValue('GLCompanySize') > 0) THEN _number := COALESCE(pCompany, '') || '-'; END IF; IF (fetchMetricValue('GLProfitSize') > 0) THEN _number := _number || COALESCE(pProfit, '') || '-'; END IF; _number := _number || pNumber; IF (fetchMetricValue('GLSubaccountSize') > 0) THEN _number := _number || '-' || COALESCE(pSub, ''); END IF; RETURN _number; END; $$; ALTER FUNCTION public.formatglaccount(pcompany text, pprofit text, pnumber text, psub text) OWNER TO admin; -- -- Name: formatglaccountlong(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatglaccountlong(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAccntid ALIAS FOR $1; _result TEXT; BEGIN SELECT (formatGLAccount(accnt_id) || '-' || accnt_descrip) INTO _result FROM accnt WHERE (accnt_id=pAccntid); RETURN _result; END; $_$; ALTER FUNCTION public.formatglaccountlong(integer) OWNER TO admin; -- -- Name: formatindent(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatindent(text, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pText ALIAS FOR $1; pIndent ALIAS FOR $2; _i INTEGER; _result TEXT; BEGIN _result := ''; _i := 0; WHILE _i < pIndent LOOP _result := _result || ' '; _i := _i + 1; END LOOP; _result := _result || pText; RETURN _result; END; $_$; ALTER FUNCTION public.formatindent(text, integer) OWNER TO admin; -- -- Name: formatinterval(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatinterval(numeric) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT TO_CHAR(('@ ' || trunc($1) || ' min ' || ($1 - trunc($1)) * 60 || ' sec')::INTERVAL, ( SELECT locale_intervalformat FROM locale, usr WHERE ((usr_locale_id=locale_id) AND (usr_username=getEffectiveXtUser())) ) ) AS result $_$; ALTER FUNCTION public.formatinterval(numeric) OWNER TO admin; -- -- Name: formatinterval(interval); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatinterval(interval) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT TO_CHAR($1, ( SELECT locale_intervalformat FROM locale, usr WHERE ((usr_locale_id=locale_id) AND (usr_username=getEffectiveXtUser())) ) ) AS result $_$; ALTER FUNCTION public.formatinterval(interval) OWNER TO admin; -- -- Name: formatinvcnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatinvcnumber(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCobmiscid ALIAS FOR $1; BEGIN RETURN ( SELECT COALESCE(cobmisc_invcnumber::TEXT, '') FROM cobmisc WHERE (cobmisc_id=pCobmiscid) ); END; $_$; ALTER FUNCTION public.formatinvcnumber(integer) OWNER TO admin; -- -- Name: formatitemsitebarcode(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatitemsitebarcode(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; _barcode TEXT; BEGIN SELECT ( E'\138ISXX' || LTRIM(TO_CHAR(LENGTH(item_number), '00')) || LENGTH(warehous_code)::TEXT || item_number || warehous_code ) INTO _barcode FROM itemsite, item, whsinfo WHERE ( (itemsite_item_id=item_id) AND (itemsite_warehous_id=warehous_id) AND (itemsite_id=pItemsiteid) ); RETURN _barcode; END; $_$; ALTER FUNCTION public.formatitemsitebarcode(integer) OWNER TO admin; -- -- Name: formatlocationbarcode(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatlocationbarcode(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLocationid ALIAS FOR $1; _barcode TEXT; BEGIN SELECT ( E'\138LOXX' || LENGTH(warehous_code)::TEXT || LTRIM(TO_CHAR(LENGTH(location_name::TEXT), '00')) || warehous_code || location_name ) INTO _barcode FROM location, whsinfo WHERE ( (location_warehous_id=warehous_id) AND (location_id=pLocationid) ); RETURN _barcode; END; $_$; ALTER FUNCTION public.formatlocationbarcode(integer) OWNER TO admin; -- -- Name: formatlocationcontentsbarcode(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatlocationcontentsbarcode(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLocationid ALIAS FOR $1; _barcode TEXT; BEGIN SELECT ( E'\138LOCN' || LENGTH(warehous_code)::TEXT || LTRIM(TO_CHAR(LENGTH(location_name), '00')) || warehous_code || location_name ) INTO _barcode FROM location, whsinfo WHERE ( (location_warehous_id=warehous_id) AND (location_id=pLocationid) ); RETURN _barcode; END; $_$; ALTER FUNCTION public.formatlocationcontentsbarcode(integer) OWNER TO admin; -- -- Name: formatlocationissuebarcode(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatlocationissuebarcode(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLocationid ALIAS FOR $1; _barcode TEXT; BEGIN SELECT ( E'\138LOIS' || LENGTH(warehous_code)::TEXT || LTRIM(TO_CHAR(LENGTH(location_name), '00')) || warehous_code || location_name ) INTO _barcode FROM location, whsinfo WHERE ( (location_warehous_id=warehous_id) AND (location_id=pLocationid) ); RETURN _barcode; END; $_$; ALTER FUNCTION public.formatlocationissuebarcode(integer) OWNER TO admin; -- -- Name: formatlotserialnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatlotserialnumber(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLotSerialId ALIAS FOR $1; _lotserial TEXT; BEGIN --See if lot serial control turned on (Postbooks will not ever have this) IF (fetchmetricbool('LotSerialControl')) THEN SELECT ls_number INTO _lotserial FROM ls WHERE (ls_id=pLotSerialId); END IF; RETURN COALESCE(_lotserial,''); END; $_$; ALTER FUNCTION public.formatlotserialnumber(integer) OWNER TO admin; -- -- Name: formatmoney(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatmoney(numeric) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN formatNumeric($1, 'curr'); END;$_$; ALTER FUNCTION public.formatmoney(numeric) OWNER TO admin; -- -- Name: formatnumeric(numeric, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatnumeric(numeric, text) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _value NUMERIC := $1; _type TEXT := LOWER(COALESCE($2, 'curr')); _abs NUMERIC; _magnitudecnt NUMERIC(1000); _wholefmt TEXT := '0'; _scale INTEGER; _neg TEXT; _decimal TEXT; _group TEXT; _string TEXT; _debug BOOL := false; _r RECORD; BEGIN -- If the value passed in is NULL then we want to pass back an empty string IF(_value IS NULL) THEN RETURN ''; END IF; SELECT * INTO _r FROM locale WHERE (locale_id=getUsrLocaleId()); _decimal := COALESCE(SUBSTRING(_r.locale_qtyformat FROM 1 FOR 1), '.'); _neg := COALESCE(SUBSTRING(_r.locale_qtyformat FROM 2 FOR 1), '-'); _group := COALESCE(SUBSTRING(_r.locale_qtyformat FROM 3 FOR 1), ','); _scale := CASE WHEN _type = 'cost' THEN _r.locale_cost_scale WHEN _type = 'extprice' THEN _r.locale_extprice_scale WHEN _type = 'percent' THEN _r.locale_percent_scale WHEN _type = 'purchprice' THEN _r.locale_purchprice_scale WHEN _type = 'qty' THEN _r.locale_qty_scale WHEN _type = 'qtyper' THEN _r.locale_qtyper_scale WHEN _type = 'salesprice' THEN _r.locale_salesprice_scale WHEN _type = 'uomratio' THEN _r.locale_uomratio_scale WHEN _type = 'weight' THEN _r.locale_weight_scale WHEN SUBSTRING(_type FOR 4) = 'curr' THEN _r.locale_curr_scale ELSE 2 END; _value := round(_value, _scale); _abs := ABS(_value); _magnitudecnt := TRUNC(_abs / 10); IF (_debug) THEN RAISE NOTICE '_value % _abs % _scale % _neg % _decimal % _group % ', _value, _abs, _scale, _decimal, _group, _scale; END IF; IF (_value < 0) THEN _string := _neg; ELSE _string := ''; END IF; WHILE (_magnitudecnt >= 1) LOOP _magnitudecnt := TRUNC(_magnitudecnt / 10); IF (LENGTH(_wholefmt) % 3 = 0) THEN _wholefmt := '"' || _group || '"' || _wholefmt; END IF; _wholefmt := '9' || _wholefmt; END LOOP; IF (_scale > 0) THEN _abs := (_abs * (10 ^ _scale)); _abs := TRUNC(_abs); _wholefmt := _wholefmt || '"' || _decimal || '"' || REPEAT('0', _scale); END IF; _wholefmt := 'FM' || _wholefmt; _string := _string || to_char(_abs, _wholefmt); RETURN _string; END;$_$; ALTER FUNCTION public.formatnumeric(numeric, text) OWNER TO admin; -- -- Name: formatperiodname(integer, character); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatperiodname(integer, character) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodId ALIAS FOR $1; pInterval ALIAS FOR $2; _result TEXT; BEGIN --...for Month IF (pInterval='M') THEN SELECT (CASE WHEN period_name='' THEN formatdate(period_start) || '-' || formatdate(period_end) ELSE period_name END) INTO _result FROM period WHERE (period_id=pPeriodId); RETURN _result; --...for Quarter ELSE IF (pInterval='Q') THEN SELECT ('Q' || period_quarter || '-' || EXTRACT(year from yearperiod_end)) INTO _result FROM period, yearperiod WHERE ((period_id=pPeriodId) AND (period_yearperiod_id=yearperiod_id)); RETURN _result; --...for Year ELSE SELECT EXTRACT(year FROM yearperiod_end) INTO _result FROM period,yearperiod WHERE ((period_id=pPeriodId) AND (period_yearperiod_id=yearperiod_id)); RETURN _result; END IF; END IF; RETURN 'Err'; END; $_$; ALTER FUNCTION public.formatperiodname(integer, character) OWNER TO admin; -- -- Name: formatplonumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatplonumber(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPlanordid ALIAS FOR $1; _result TEXT; BEGIN SELECT (TEXT(planord_number) || '-' || TEXT(planord_subnumber)) INTO _result FROM planord WHERE (planord_id=pPlanordid); RETURN _result; END; $_$; ALTER FUNCTION public.formatplonumber(integer) OWNER TO admin; -- -- Name: formatprcnt(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatprcnt(numeric) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT formatNumeric($1 * 100, 'percent') AS result $_$; ALTER FUNCTION public.formatprcnt(numeric) OWNER TO admin; -- -- Name: formatprice(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatprice(numeric) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT formatNumeric($1, 'salesprice') AS result; $_$; ALTER FUNCTION public.formatprice(numeric) OWNER TO admin; -- -- Name: formatpurchprice(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatpurchprice(numeric) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN formatNumeric($1, 'purchprice'); END;$_$; ALTER FUNCTION public.formatpurchprice(numeric) OWNER TO admin; -- -- Name: formatqty(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatqty(numeric) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN formatNumeric($1, 'qty'); END;$_$; ALTER FUNCTION public.formatqty(numeric) OWNER TO admin; -- -- Name: formatqtyper(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatqtyper(numeric) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN formatNumeric($1, 'qtyper'); END;$_$; ALTER FUNCTION public.formatqtyper(numeric) OWNER TO admin; -- -- Name: formatratio(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatratio(numeric) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT formatNumeric($1, 'uomratio'); $_$; ALTER FUNCTION public.formatratio(numeric) OWNER TO admin; -- -- Name: formatrevnumber(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatrevnumber(text, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pRevType ALIAS FOR $1; pRevId ALIAS FOR $2; _revision TEXT; BEGIN --See if revision control turned on (Postbooks will not ever have this) IF (fetchmetricbool('RevControl')) THEN SELECT rev_number INTO _revision FROM rev WHERE ((rev_target_type=pRevType) AND (rev_id=pRevId)); END IF; RETURN COALESCE(_revision,''); END; $_$; ALTER FUNCTION public.formatrevnumber(text, integer) OWNER TO admin; -- -- Name: formatsalesprice(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatsalesprice(numeric) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN formatNumeric($1, 'salesprice'); END;$_$; ALTER FUNCTION public.formatsalesprice(numeric) OWNER TO admin; -- -- Name: formatscrap(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatscrap(numeric) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT formatNumeric(($1 * 100), 'percent') AS result $_$; ALTER FUNCTION public.formatscrap(numeric) OWNER TO admin; -- -- Name: formatshipmentnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatshipmentnumber(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pshipheadid ALIAS FOR $1; BEGIN RETURN ( SELECT COALESCE(shiphead_number::TEXT, '') FROM shiphead WHERE (shiphead_id=pshipheadid) ); END; $_$; ALTER FUNCTION public.formatshipmentnumber(integer) OWNER TO admin; -- -- Name: formatsobarcode(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatsobarcode(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; _barcode TEXT; BEGIN SELECT ( E'\138SOXX' || LENGTH(TEXT(cohead_number)) || TEXT(cohead_number) ) INTO _barcode FROM cohead WHERE (cohead_id=pSoheadid); RETURN _barcode; END; $_$; ALTER FUNCTION public.formatsobarcode(integer) OWNER TO admin; -- -- Name: formatsoitembarcode(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatsoitembarcode(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoitemid ALIAS FOR $1; _barcode TEXT; BEGIN SELECT ( E'\138SOLI' || LENGTH(TEXT(cohead_number)) || LENGTH(formatsolinenumber(coitem_id)) || TEXT(cohead_number) || formatsolinenumber(coitem_id) ) INTO _barcode FROM cohead, coitem WHERE ( (coitem_cohead_id=cohead_id) AND (coitem_id=pSoitemid) ); RETURN _barcode; END; $_$; ALTER FUNCTION public.formatsoitembarcode(integer) OWNER TO admin; -- -- Name: formatsoitemnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatsoitemnumber(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE targetSoitemid ALIAS FOR $1; BEGIN RETURN ( SELECT (cohead_number::TEXT || '-' || formatsolinenumber(coitem_id)) FROM cohead, coitem WHERE ((coitem_cohead_id=cohead_id) AND (coitem_id=targetSoitemid)) ); END; $_$; ALTER FUNCTION public.formatsoitemnumber(integer) OWNER TO admin; -- -- Name: formatsonumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatsonumber(integer) RETURNS text LANGUAGE sql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT COALESCE((SELECT (text(cohead_number) || '-' || formatSoLineNumber(coitem_id)) FROM coitem JOIN cohead ON (coitem_cohead_id=cohead_id) WHERE (coitem_id=($1))),'DELETED'); $_$; ALTER FUNCTION public.formatsonumber(integer) OWNER TO admin; -- -- Name: formattime(timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formattime(timestamp with time zone) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT TO_CHAR($1, ( SELECT locale_timeformat FROM locale, usr WHERE ((usr_locale_id=locale_id) AND (usr_username=getEffectiveXtUser())) ) ) AS result $_$; ALTER FUNCTION public.formattime(timestamp with time zone) OWNER TO admin; -- -- Name: formattime(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formattime(numeric) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT LTRIM(TO_CHAR(COALESCE($1, 0), '999999990.0')); $_$; ALTER FUNCTION public.formattime(numeric) OWNER TO admin; -- -- Name: formatuomratio(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatuomratio(numeric) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN formatNumeric($1, 'uomratio'); END;$_$; ALTER FUNCTION public.formatuomratio(numeric) OWNER TO admin; -- -- Name: formatuserbarcode(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatuserbarcode(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUserid ALIAS FOR $1; _barcode TEXT; BEGIN SELECT formatUserBarcode(usr_username) INTO _barcode FROM usr WHERE(usr_id=pUserid); RETURN _barcode; END; $_$; ALTER FUNCTION public.formatuserbarcode(integer) OWNER TO admin; -- -- Name: formatuserbarcode(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatuserbarcode(text) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; _barcode TEXT; BEGIN _barcode := ( E'\138USER' || LENGTH(pUsername)::TEXT || pUsername ); RETURN _barcode; END; $_$; ALTER FUNCTION public.formatuserbarcode(text) OWNER TO admin; -- -- Name: formatweight(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatweight(numeric) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT formatNumeric($1, 'weight') AS result $_$; ALTER FUNCTION public.formatweight(numeric) OWNER TO admin; -- -- Name: formatwobarcode(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatwobarcode(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; _barcode TEXT; BEGIN SELECT ( E'\138WOXX' || LENGTH(wo_number::TEXT) || LENGTH(wo_subnumber::TEXT) || wo_number::TEXT || wo_subnumber::TEXT ) INTO _barcode FROM wo WHERE (wo_id=pWoid); RETURN _barcode; END; $_$; ALTER FUNCTION public.formatwobarcode(integer) OWNER TO admin; -- -- Name: formatwonumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatwonumber(pwoid integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN formatWoNumber(pWoid, 'wo'); END; $$; ALTER FUNCTION public.formatwonumber(pwoid integer) OWNER TO admin; -- -- Name: formatwonumber(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatwonumber(pid integer, ptype text) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pType = 'womatl') THEN RETURN ( SELECT (wo_number::TEXT || '-' || wo_subnumber::TEXT) FROM womatl JOIN wo ON (wo_id=womatl_id) WHERE (womatl_id=pId) ); ELSE RETURN ( SELECT (wo_number::TEXT || '-' || wo_subnumber::TEXT) FROM wo WHERE (wo_id=pId) ); END IF; END; $$; ALTER FUNCTION public.formatwonumber(pid integer, ptype text) OWNER TO admin; -- -- Name: formatwooperseq(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION formatwooperseq(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWooperId ALIAS FOR $1; _result TEXT; BEGIN IF pWooperId = -1 THEN RETURN ''; ELSE SELECT wooper_seqnumber INTO _result FROM xtmfg.wooper WHERE (wooper_id=pWooperId); END IF; RETURN _result; END; $_$; ALTER FUNCTION public.formatwooperseq(integer) OWNER TO admin; -- -- Name: forwardupdateaccount(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION forwardupdateaccount(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAccntid ALIAS FOR $1; _r RECORD; _trialbalid INTEGER; BEGIN SELECT trialbal_id, trialbal_dirty, CASE WHEN (trialbal_dirty) THEN 0 ELSE 1 END AS dirty_seq INTO _r FROM trialbal, period WHERE ((trialbal_period_id=period_id) AND (trialbal_accnt_id=pAccntid)) ORDER BY dirty_seq, period_start LIMIT 1; IF (FOUND) THEN IF (_r.trialbal_dirty) THEN RETURN forwardUpdateTrialBalance(_r.trialbal_id); ELSE RETURN _r.trialbal_id; END IF; ELSE _trialbalid := nextval('trialbal_trialbal_id_seq'); INSERT INTO trialbal ( trialbal_id, trialbal_period_id, trialbal_accnt_id, trialbal_beginning, trialbal_ending, trialbal_debits, trialbal_credits, trialbal_dirty ) SELECT _trialbalid, period_id, pAccntid, 0, 0, 0, 0, FALSE FROM period ORDER BY period_start LIMIT 1; RETURN forwardUpdateTrialBalance(_trialbalid); END IF; RETURN -1; END; $_$; ALTER FUNCTION public.forwardupdateaccount(integer) OWNER TO admin; -- -- Name: forwardupdateinvbalance(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION forwardupdateinvbalance(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvbalid ALIAS FOR $1; _p RECORD; _r RECORD; _qohEnding NUMERIC; _valueEnding NUMERIC; _nnEnding NUMERIC; _nnvalEnding NUMERIC; BEGIN SELECT invbal_itemsite_id, invbal_qoh_ending, invbal_value_ending, invbal_nn_ending, invbal_nnval_ending, period_end INTO _p FROM invbal JOIN period ON (invbal_period_id=period_id) JOIN itemsite ON (invbal_itemsite_id=itemsite_id) WHERE (invbal_id=pInvbalid); _qohEnding = _p.invbal_qoh_ending; _valueEnding = _p.invbal_value_ending; _nnEnding = _p.invbal_nn_ending; _nnvalEnding = _p.invbal_nnval_ending; -- Find all of the subsequent periods and their inventory balance, if they exist FOR _r IN SELECT period_id, period_end, invbal_id, invbal_qty_in, invbal_qty_out, invbal_value_in, invbal_value_out, invbal_nn_in, invbal_nn_out, invbal_nnval_in, invbal_nnval_out FROM period LEFT OUTER JOIN invbal ON ( (invbal_period_id=period_id) AND (invbal_itemsite_id=_p.invbal_itemsite_id) ) WHERE (period_start > _p.period_end) ORDER BY period_start LOOP IF (_r.invbal_id IS NULL) THEN INSERT INTO invbal ( invbal_period_id, invbal_itemsite_id, invbal_qoh_beginning, invbal_qoh_ending, invbal_qty_in, invbal_qty_out, invbal_value_beginning, invbal_value_ending, invbal_value_in, invbal_value_out, invbal_nn_beginning, invbal_nn_ending, invbal_nn_in, invbal_nn_out, invbal_nnval_beginning, invbal_nnval_ending, invbal_nnval_in, invbal_nnval_out, invbal_dirty ) VALUES ( _r.period_id, _p.invbal_itemsite_id, _qohEnding, _qohEnding, 0, 0, _valueEnding, _valueEnding, 0, 0, _nnEnding, _nnEnding, 0, 0, _nnvalEnding, _nnvalEnding, 0, 0, FALSE ); ELSE UPDATE invbal SET invbal_qoh_beginning = (_qohEnding), invbal_qoh_ending = (_qohEnding + _r.invbal_qty_in - _r.invbal_qty_out), invbal_value_beginning = (_valueEnding), invbal_value_ending = (_valueEnding + _r.invbal_value_in - _r.invbal_value_out), invbal_nn_beginning = (_nnEnding), invbal_nn_ending = (_nnEnding + _r.invbal_nn_in - _r.invbal_nn_out), invbal_nnval_beginning = (_nnvalEnding), invbal_nnval_ending = (_nnvalEnding + _r.invbal_nnval_in - _r.invbal_nnval_out), invbal_dirty = FALSE WHERE (invbal_id=_r.invbal_id); _qohEnding = (_qohEnding + _r.invbal_qty_in - _r.invbal_qty_out); _valueEnding = (_valueEnding + _r.invbal_value_in - _r.invbal_value_out); _nnEnding = (_nnEnding + _r.invbal_nn_in - _r.invbal_nn_out); _nnvalEnding = (_nnvalEnding + _r.invbal_nnval_in - _r.invbal_nnval_out); END IF; END LOOP; UPDATE invbal SET invbal_dirty = false WHERE (invbal_id=pInvbalid); RETURN pInvbalid; END; $_$; ALTER FUNCTION public.forwardupdateinvbalance(integer) OWNER TO admin; -- -- Name: forwardupdateitemsite(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION forwardupdateitemsite(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteId ALIAS FOR $1; _r RECORD; _invbalid INTEGER; BEGIN SELECT invbal_id INTO _r FROM invbal JOIN period ON (invbal_period_id=period_id) WHERE (invbal_itemsite_id=pItemsiteid) ORDER BY period_start LIMIT 1; IF (FOUND) THEN RETURN forwardUpdateInvbalance(_r.invbal_id); ELSE _invbalid := nextval('invbal_invbal_id_seq'); INSERT INTO invbal ( invbal_id, invbal_period_id, invbal_itemsite_id, invbal_qoh_beginning, invbal_qoh_ending, invbal_qty_in, invbal_qty_out, invbal_value_beginning, invbal_value_ending, invbal_value_in, invbal_value_out, invbal_nn_beginning, invbal_nn_ending, invbal_nn_in, invbal_nn_out, invbal_nnval_beginning, invbal_nnval_ending, invbal_nnval_in, invbal_nnval_out, invbal_dirty ) SELECT _invbalid, period_id, pItemsiteid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false FROM period ORDER BY period_start LIMIT 1; RETURN forwardUpdateInvbalance(_invbalid); END IF; RETURN -1; END; $_$; ALTER FUNCTION public.forwardupdateitemsite(integer) OWNER TO admin; -- -- Name: forwardupdatetrialbalance(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION forwardupdatetrialbalance(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTrialbalid ALIAS FOR $1; _p RECORD; _r RECORD; _ending NUMERIC; _prevYear INTEGER; _currYear INTEGER; _prevYearClosed BOOLEAN; _currYearClosed BOOLEAN; _result INTEGER; BEGIN SELECT trialbal_accnt_id, trialbal_ending, yearperiod_id, yearperiod_closed, period_end, accnt_type IN ('E', 'R') AS revexp INTO _p FROM trialbal, period, yearperiod, accnt WHERE ( (trialbal_period_id=period_id) AND (yearperiod_id=period_yearperiod_id) AND (trialbal_accnt_id=accnt_id) AND (trialbal_id=pTrialbalid) ); _ending = _p.trialbal_ending; SELECT yearperiod_id, yearperiod_closed INTO _prevYear, _prevYearClosed FROM yearperiod WHERE (_p.period_end BETWEEN yearperiod_start AND yearperiod_end); IF (NOT FOUND) THEN _prevYear := -1; _prevYearClosed := false; END IF; -- Find all of the subsequent periods and their trialbal, if they exist FOR _r IN SELECT period_id, period_end, trialbal_id, trialbal_debits, trialbal_credits, trialbal_yearend FROM period LEFT OUTER JOIN trialbal ON ( (trialbal_period_id=period_id) AND (trialbal_accnt_id=_p.trialbal_accnt_id) ) WHERE (period_start > _p.period_end) ORDER BY period_start LOOP SELECT yearperiod_id, yearperiod_closed INTO _currYear, _currYearClosed FROM yearperiod WHERE (_r.period_end BETWEEN yearperiod_start AND yearperiod_end); IF (NOT FOUND) THEN _currYear := -1; _currYearClosed := false; END IF; IF (_p.revexp AND _currYear != _prevYear) THEN _ending := 0; IF (_prevYearClosed) THEN SELECT updateRetainedEarnings(_prevYear) INTO _result; IF (_result < 0) THEN RETURN _result; END IF; END IF; END IF; _prevYear := _currYear; _prevYearClosed := _currYearClosed; IF (_r.trialbal_id IS NULL) THEN -- SELECT SUM(gltrans_amount) INTO _glAmount -- FROM gltrans -- WHERE ( (gltrans_date BETWEEN _r.period_start and _r.period_end ) -- AND (gltrans_accnt_id=_p.trialbal_accnt_id) -- AND (gltrans_posted) ); -- and change 2nd and 3rd VALUES line of INSERT to read -- _ending, _ending + _glAmount, -- noneg(0 - _glAmount), noneg(_glAmount), FALSE ); INSERT INTO trialbal ( trialbal_period_id, trialbal_accnt_id, trialbal_beginning, trialbal_ending, trialbal_debits, trialbal_credits, trialbal_dirty ) VALUES ( _r.period_id, _p.trialbal_accnt_id, _ending, _ending, 0, 0, FALSE ); ELSE UPDATE trialbal SET trialbal_beginning = (_ending + trialbal_yearend), trialbal_ending = (_ending + trialbal_yearend - _r.trialbal_debits + _r.trialbal_credits), trialbal_dirty = FALSE WHERE (trialbal_id=_r.trialbal_id); _ending = (_ending + _r.trialbal_yearend - _r.trialbal_debits + _r.trialbal_credits); END IF; END LOOP; UPDATE trialbal SET trialbal_dirty = FALSE WHERE (trialbal_id=pTrialbalid); RETURN pTrialbalid; END; $_$; ALTER FUNCTION public.forwardupdatetrialbalance(integer) OWNER TO admin; -- -- Name: freezeaccountingperiod(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION freezeaccountingperiod(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodid ALIAS FOR $1; BEGIN -- Check to make use that the period is not already frozen IF ( ( SELECT period_freeze FROM period WHERE (period_id=pPeriodid) ) ) THEN RETURN -2; END IF; -- Set the period_freeze flag UPDATE period SET period_freeze=TRUE WHERE (period_id=pPeriodid); RETURN pPeriodid; END; $_$; ALTER FUNCTION public.freezeaccountingperiod(integer) OWNER TO admin; -- -- Name: freightdetail(text, integer, integer, integer, date, text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION freightdetail(text, integer, integer, integer, date, text, integer) RETURNS SETOF freightdata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOrderType ALIAS FOR $1; pOrderId ALIAS FOR $2; pCustId ALIAS FOR $3; pShiptoId ALIAS FOR $4; pOrderDate ALIAS FOR $5; pShipVia ALIAS FOR $6; pCurrId ALIAS FOR $7; _row freightData%ROWTYPE; _order RECORD; _weights RECORD; _includepkgweight BOOLEAN := FALSE; _qry TEXT; _debug BOOLEAN := FALSE; BEGIN IF (_debug) THEN RAISE NOTICE 'pOrderType = %', pOrderType; RAISE NOTICE 'pOrderId = %', pOrderId; RAISE NOTICE 'pCustId = %', pCustId; RAISE NOTICE 'pShiptoId = %', pShiptoId; RAISE NOTICE 'pOrderDate = %', pOrderDate; RAISE NOTICE 'pShipVia = %', pShipVia; RAISE NOTICE 'pCurrId = %', pCurrId; END IF; SELECT fetchMetricBool('IncludePackageWeight') INTO _includepkgweight; --Get the order header information need to match --against price schedules IF (pOrderType = 'SO') THEN SELECT cust_id AS cust_id, custtype_id, custtype_code, COALESCE(shipto_id, -1) AS shipto_id, COALESCE(shipto_num, '') AS shipto_num, COALESCE(pOrderDate, cohead_orderdate) AS orderdate, COALESCE(pShipVia, cohead_shipvia) AS shipvia, shipto_shipzone_id AS shipzone_id, COALESCE(pCurrId, cohead_curr_id) AS curr_id, currConcat(COALESCE(pCurrId, cohead_curr_id)) AS currAbbr INTO _order FROM cohead JOIN custinfo ON (cust_id=COALESCE(pCustId, cohead_cust_id)) JOIN custtype ON (custtype_id=cust_custtype_id) LEFT OUTER JOIN shiptoinfo ON (shipto_id=COALESCE(pShiptoId, cohead_shipto_id)) WHERE (cohead_id=pOrderId); ELSIF (pOrderType = 'QU') THEN SELECT quhead_cust_id AS cust_id, custtype_id, custtype_code, COALESCE(shipto_id, -1) AS shipto_id, COALESCE(shipto_num, '') AS shipto_num, quhead_quotedate AS orderdate, quhead_shipvia AS shipvia, shipto_shipzone_id AS shipzone_id, quhead_curr_id AS curr_id, currConcat(quhead_curr_id) AS currAbbr INTO _order FROM quhead JOIN custinfo ON (cust_id=quhead_cust_id) JOIN custtype ON (custtype_id=cust_custtype_id) LEFT OUTER JOIN shiptoinfo ON (shipto_id=quhead_shipto_id) WHERE (quhead_id=pOrderId); ELSIF (pOrderType = 'RA') THEN SELECT cust_id AS cust_id, custtype_id, custtype_code, COALESCE(shipto_id, -1) AS shipto_id, COALESCE(shipto_num, '') AS shipto_num, COALESCE(pOrderDate, rahead_authdate) AS orderdate, ''::text AS shipvia, shipto_shipzone_id AS shipzone_id, COALESCE(pCurrId, rahead_curr_id) AS curr_id, currConcat(COALESCE(pCurrId, rahead_curr_id)) AS currAbbr INTO _order FROM rahead JOIN custinfo ON (cust_id=COALESCE(pCustId, rahead_cust_id)) JOIN custtype ON (custtype_id=cust_custtype_id) LEFT OUTER JOIN shiptoinfo ON (shipto_id=COALESCE(pShiptoId, rahead_shipto_id)) WHERE (rahead_id=pOrderId); ELSE RAISE EXCEPTION 'Invalid order type.'; END IF; IF (_debug) THEN RAISE NOTICE 'cust_id = %', _order.cust_id; RAISE NOTICE 'custtype_id = %', _order.custtype_id; RAISE NOTICE 'shipto_id = %', _order.shipto_id; RAISE NOTICE 'shipto_num = %', _order.shipto_num; RAISE NOTICE 'orderdate = %', _order.orderdate; RAISE NOTICE 'shipvia = %', _order.shipvia; RAISE NOTICE 'shipzone_id = %', _order.shipzone_id; RAISE NOTICE 'curr_id = %', _order.curr_id; RAISE NOTICE 'currAbbr = %', _order.currAbbr; END IF; --Get a list of aggregated weights from sites and --freight classes used on order lines IF (_includePkgWeight) THEN _qry := 'SELECT SUM(orderitem_qty_ordered * orderitem_qty_invuomratio * (item_prodweight + item_packweight)) AS weight, '; ELSE _qry := 'SELECT SUM(orderitem_qty_ordered * orderitem_qty_invuomratio * item_prodweight) AS weight, '; END IF; _qry := _qry || 'itemsite_warehous_id, COALESCE(item_freightclass_id, -1) AS item_freightclass_id FROM orderitem JOIN itemsite ON (itemsite_id=orderitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) '; IF (pOrderType = 'RA') THEN _qry := _qry || 'JOIN raitem ON ((orderitem_id=raitem_id) AND (raitem_disposition IN (''C'',''R'',''P''))) '; END IF; _qry := _qry || ' WHERE ( (orderitem_orderhead_type=' || quote_literal(pOrderType) || ') AND (orderitem_orderhead_id=' || quote_literal(pOrderId) || ') AND (orderitem_status <> ''X'') ) GROUP BY itemsite_warehous_id, item_freightclass_id;'; FOR _weights IN EXECUTE _qry LOOP _row := calculateFreightDetail( _order.cust_id, --pCustId _order.custtype_id, --pCustTypeId _order.custtype_code, --pCustTypeCode _order.shipto_id, --pShiptoId _order.shipzone_id, --pShipZoneId _order.shipto_num, --pShiptoNum _order.orderdate, --pOrderDate _order.shipvia, --pShipVia _order.curr_id, --pCurrId _order.currAbbr, --pCurrAbbr _weights.itemsite_warehous_id, --pItemSiteWhsId _weights.item_freightclass_id, --pItemFreightclassId _weights.weight --pWeight ); RETURN NEXT _row; END LOOP; RETURN; END; $_$; ALTER FUNCTION public.freightdetail(text, integer, integer, integer, date, text, integer) OWNER TO admin; -- -- Name: freightdetailquote(integer, text, integer, text, date, text, text, text[]); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION freightdetailquote(integer, text, integer, text, date, text, text, text[]) RETURNS SETOF freightdata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustId ALIAS FOR $1; pCustNumber ALIAS FOR $2; pShiptoId ALIAS FOR $3; pShiptoNum ALIAS FOR $4; pOrderDate ALIAS FOR $5; pShipVia ALIAS FOR $6; pItemArrayType ALIAS FOR $7; pItemQty ALIAS FOR $8; -- Array item_id format = ARRAY[['300','3'],['310','50']] -- Array item_number format = ARRAY[['YTRUCK1','3'],['RTRUCK1','50']] -- Array itemsite_id format = ARRAY[['293','3'],['302','50']] _cust RECORD; _shipto RECORD; _curr RECORD; _includepkgweight BOOLEAN := FALSE; _order_date DATE; _ship_via TEXT; _item_num RECORD; _item_id RECORD; _weights RECORD; _row freightData%ROWTYPE; _debug BOOLEAN := FALSE; BEGIN -- Parameters are setup to allow this function to be called multiple ways. -- Check parameters and lookup what is NULL. -- Check pCustId and pCustNumber. IF (pCustId IS NULL AND (pCustNumber IS NULL OR pCustNumber = '')) THEN RAISE EXCEPTION 'You must specify a Customer ID or Number to get a freight quote.'; ELSIF (pCustId IS NULL AND pCustNumber IS NOT NULL) THEN -- Get customer info using pCustNumber. SELECT cust_id, cust_number, custtype_id, custtype_code, cust_curr_id, cust_shipvia INTO _cust FROM custinfo LEFT JOIN custtype ON cust_custtype_id = custtype_id WHERE 1=1 AND cust_number = pCustNumber; ELSE -- Get customer info using pCustId. SELECT cust_id, cust_number, custtype_id, custtype_code, cust_curr_id, cust_shipvia INTO _cust FROM custinfo LEFT JOIN custtype ON cust_custtype_id = custtype_id WHERE 1=1 AND cust_id = pCustId; END IF; IF(NOT FOUND) THEN RAISE EXCEPTION 'Invalid Customer specified when trying to get a freight quote.'; END IF; -- Check pShiptoId and pShiptoNum. IF (pShiptoId IS NULL AND (pShiptoNum IS NULL OR pShiptoNum = '')) THEN -- Get Customer's default shipto. SELECT shipto_id, shipto_name, shipto_shipzone_id, shipto_shipvia, shipto_num INTO _shipto FROM shiptoinfo WHERE 1=1 AND shipto_cust_id = _cust.cust_id AND shipto_default; ELSIF (pShiptoId IS NULL AND pShiptoNum IS NOT NULL) THEN -- Get shipto info using pShiptoNum. SELECT shipto_id, shipto_name, shipto_shipzone_id, shipto_shipvia, shipto_num INTO _shipto FROM shiptoinfo WHERE 1=1 AND shipto_cust_id = _cust.cust_id AND shipto_num = pShiptoNum; ELSE -- Get shipto info using pShiptoId. SELECT shipto_id, shipto_name, shipto_shipzone_id, shipto_shipvia, shipto_num INTO _shipto FROM shiptoinfo WHERE 1=1 AND shipto_cust_id = _cust.cust_id AND shipto_id = pShiptoId; END IF; IF(NOT FOUND) THEN RAISE EXCEPTION 'Invalid Ship-to specified when trying to get a freight quote.'; END IF; -- Get curr info. SELECT curr_id, curr_abbr INTO _curr FROM curr_symbol WHERE 1=1 AND curr_id = _cust.cust_curr_id; IF(NOT FOUND) THEN RAISE EXCEPTION 'Could not find currency when trying to get a freight quote.'; END IF; -- Check pOrderDate. IF (pOrderDate IS NULL) THEN _order_date := CURRENT_DATE; ELSE _order_date := pOrderDate; END IF; -- Check pShipVia. IF (pShipVia IS NULL OR pShipVia = '') THEN IF (_shipto.shipto_shipvia IS NULL OR _shipto.shipto_shipvia = '') THEN _ship_via := _cust.cust_shipvia; ELSE _ship_via := _shipto.shipto_shipvia; END IF; ELSE _ship_via := pShipVia; END IF; -- Determine if package weight should be included in freight calculation. SELECT fetchMetricBool('IncludePackageWeight') INTO _includepkgweight; -- Check pItemQty. IF (pItemQty IS NULL OR array_upper(pItemQty,1) IS NULL) THEN -- Item Array is NULL. RAISE EXCEPTION 'You must specify an Item ID, Item Number or Itemsite ID to get a freight quote.'; ELSIF (pItemArrayType = 'item_number' AND (array_upper(pItemQty,1) > 0)) THEN -- Using item_number. FOR _weights IN -- Get a list of aggregated weights from sites and freight classes for items. SELECT CASE WHEN _includepkgweight THEN SUM(qty * (item_prodweight + item_packweight)) ELSE SUM(qty * (item_prodweight)) END AS weight, itemsite_warehous_id, COALESCE(item_freightclass_id, -1) AS item_freightclass_id FROM -- Create item_number -> qty record from array. (SELECT unnest((SELECT pItemQty[1:array_upper(pItemQty,1)][1])) AS item_number, unnest((SELECT pItemQty[1:array_upper(pItemQty,1)][2:array_ndims(pItemQty)]))::numeric AS qty ) AS itemnum_qty JOIN item USING (item_number) JOIN itemsite ON item_id=itemsite_item_id WHERE 1=1 AND itemsite_warehous_id = fetchprefwarehousid() GROUP BY itemsite_warehous_id, item_freightclass_id LOOP -- Calculate the freight detail for these item weights. _row := calculateFreightDetail( _cust.cust_id, --pCustId _cust.custtype_id, --pCustTypeId _cust.custtype_code, --pCustTypeCode _shipto.shipto_id, --pShiptoId _shipto.shipto_shipzone_id, --pShipZoneId _shipto.shipto_num, --pShiptoNum _order_date, --pOrderDate _ship_via, --pShipVia _curr.curr_id, --pCurrId _curr.curr_abbr, --pCurrAbbr _weights.itemsite_warehous_id, --pItemSiteWhsId _weights.item_freightclass_id, --pItemFreightclassId _weights.weight --pWeight ); RETURN NEXT _row; END LOOP; ELSIF (pItemArrayType = 'item_id' AND (array_upper(pItemQty,1) > 0)) THEN -- Using item_id. FOR _weights IN -- Get a list of aggregated weights from sites and freight classes for items. SELECT CASE WHEN _includepkgweight THEN SUM(qty * (item_prodweight + item_packweight)) ELSE SUM(qty * (item_prodweight)) END AS weight, itemsite_warehous_id, COALESCE(item_freightclass_id, -1) AS item_freightclass_id FROM -- Create item_id -> qty record from array. (SELECT unnest((SELECT pItemQty[1:array_upper(pItemQty,1)][1]))::integer AS item_id, unnest((SELECT pItemQty[1:array_upper(pItemQty,1)][2:array_ndims(pItemQty)]))::numeric AS qty ) AS itemid_qty JOIN item USING (item_id) JOIN itemsite ON item_id=itemsite_item_id WHERE 1=1 AND itemsite_warehous_id = fetchprefwarehousid() GROUP BY itemsite_warehous_id, item_freightclass_id LOOP -- Calculate the freight detail for these item weights. _row := calculateFreightDetail( _cust.cust_id, --pCustId _cust.custtype_id, --pCustTypeId _cust.custtype_code, --pCustTypeCode _shipto.shipto_id, --pShiptoId _shipto.shipto_shipzone_id, --pShipZoneId _shipto.shipto_num, --pShiptoNum _order_date, --pOrderDate _ship_via, --pShipVia _curr.curr_id, --pCurrId _curr.curr_abbr, --pCurrAbbr _weights.itemsite_warehous_id, --pItemSiteWhsId _weights.item_freightclass_id, --pItemFreightclassId _weights.weight --pWeight ); RETURN NEXT _row; END LOOP; ELSIF (pItemArrayType = 'itemsite_id' AND (array_upper(pItemQty,1) > 0)) THEN -- Using itemsite_id. FOR _weights IN -- Get a list of aggregated weights from sites and freight classes for items. SELECT CASE WHEN _includepkgweight THEN SUM(qty * (item_prodweight + item_packweight)) ELSE SUM(qty * (item_prodweight)) END AS weight, itemsite_warehous_id, COALESCE(item_freightclass_id, -1) AS item_freightclass_id FROM -- Create itemsite_id -> qty record from array. (SELECT unnest((SELECT pItemQty[1:array_upper(pItemQty,1)][1]))::integer AS itemsite_id, unnest((SELECT pItemQty[1:array_upper(pItemQty,1)][2:array_ndims(pItemQty)]))::numeric AS qty ) AS itemsiteid_qty JOIN itemsite USING (itemsite_id) JOIN item ON item_id=itemsite_item_id WHERE 1=1 GROUP BY itemsite_warehous_id, item_freightclass_id LOOP -- Calculate the freight detail for these item weights. _row := calculateFreightDetail( _cust.cust_id, --pCustId _cust.custtype_id, --pCustTypeId _cust.custtype_code, --pCustTypeCode _shipto.shipto_id, --pShiptoId _shipto.shipto_shipzone_id, --pShipZoneId _shipto.shipto_num, --pShiptoNum _order_date, --pOrderDate _ship_via, --pShipVia _curr.curr_id, --pCurrId _curr.curr_abbr, --pCurrAbbr _weights.itemsite_warehous_id, --pItemSiteWhsId _weights.item_freightclass_id, --pItemFreightclassId _weights.weight --pWeight ); RETURN NEXT _row; END LOOP; ELSE -- The item array provided is invalid. RAISE EXCEPTION 'The Item/Itemsite array provided when trying to get a freight quote is invalid.'; END IF; IF(NOT FOUND) THEN RAISE EXCEPTION 'Error trying to aggregated weights when getting a freight quote.'; END IF; -- Print debug. IF (_debug) THEN RAISE NOTICE 'pCustId = %', _cust.cust_id; RAISE NOTICE 'pCustTypeId = %', _cust.custtype_id; RAISE NOTICE 'pCustTypeCode = %', _cust.custtype_code; RAISE NOTICE 'pShiptoId = %', _shipto.shipto_id; RAISE NOTICE 'pShipZoneId = %', _shipto.shipto_shipzone_id; RAISE NOTICE 'pShiptoNum = %', _shipto.shipto_num; RAISE NOTICE 'pOrderDate = %', _order_date; RAISE NOTICE 'pShipVia = %', _ship_via; RAISE NOTICE 'pCurrId = %', _curr.curr_id; RAISE NOTICE 'pCurrAbbr = %', _curr.curr_abbr; END IF; RETURN; END; $_$; ALTER FUNCTION public.freightdetailquote(integer, text, integer, text, date, text, text, text[]) OWNER TO admin; -- -- Name: freightforrecv(text, integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION freightforrecv(text, integer, boolean) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; porderitemid ALIAS FOR $2; pposted ALIAS FOR $3; _freight NUMERIC; BEGIN IF (pordertype = 'TO' AND NOT fetchMetricBool('MultiWhs')) THEN RETURN 0; ELSIF (pordertype = 'RA' AND NOT fetchMetricBool('EnableReturnAuth')) THEN RETURN 0; END IF; SELECT SUM(COALESCE(recv_freight, 0)) INTO _freight FROM recv WHERE ((recv_orderitem_id=porderitemid) AND (recv_posted = pposted) AND (recv_order_type=pordertype)); RETURN COALESCE(_freight, 0.0); END; $_$; ALTER FUNCTION public.freightforrecv(text, integer, boolean) OWNER TO admin; -- -- Name: gen_salt(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION gen_salt(text) RETURNS text LANGUAGE c STRICT AS '$libdir/pgcrypto', 'pg_gen_salt'; ALTER FUNCTION public.gen_salt(text) OWNER TO admin; -- -- Name: gen_salt(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION gen_salt(text, integer) RETURNS text LANGUAGE c STRICT AS '$libdir/pgcrypto', 'pg_gen_salt_rounds'; ALTER FUNCTION public.gen_salt(text, integer) OWNER TO admin; -- -- Name: getactiverevid(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getactiverevid(text, integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTargetType ALIAS FOR $1; pTargetid ALIAS FOR $2; _revid INTEGER; BEGIN --See if revcontrol turned on IF (fetchmetricbool('RevControl')) THEN IF (pTargetType='BOM') THEN SELECT rev_id INTO _revid FROM rev WHERE ((rev_target_type='BOM') AND (rev_target_id=pTargetid) AND (rev_status='A')); IF (NOT FOUND) THEN _revid:=-1; END IF; ELSE IF (pTargetType='BOO') THEN SELECT rev_id INTO _revid FROM rev WHERE ((rev_target_type='BOO') AND (rev_target_id=pTargetid) AND (rev_status='A')); IF (NOT FOUND) THEN _revid:=-1; END IF; ELSE RAISE EXCEPTION 'Invalid Revision Type'; END IF; END IF; ELSE _revid:=-1; END IF; RETURN _revid; END; $_$; ALTER FUNCTION public.getactiverevid(text, integer) OWNER TO admin; -- -- Name: getaddrid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getaddrid(paddressnumber text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pAddressNumber IS NULL OR pAddressNumber = '') THEN RETURN NULL; END IF; SELECT addr_id INTO _returnVal FROM addr WHERE (addr_number=pAddressNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Address Number % not found.', pAddressNumber; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getaddrid(paddressnumber text) OWNER TO admin; -- -- Name: getadjustmenttaxtypeid(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getadjustmenttaxtypeid() RETURNS integer LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _taxtypeid INTEGER; BEGIN SELECT taxtype_id INTO _taxtypeid FROM taxtype WHERE (taxtype_name='Adjustment'); RETURN _taxtypeid; END; $$; ALTER FUNCTION public.getadjustmenttaxtypeid() OWNER TO admin; -- -- Name: getaropenid(text, character, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getaropenid(text, character, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustNumber ALIAS FOR $1; pDocType ALIAS FOR $2; pDocNumber ALIAS FOR $3; _returnVal INTEGER; BEGIN IF ((pCustNumber IS NULL) OR (pDocType IS NULL) OR (pDocNumber IS NULL)) THEN RETURN NULL; END IF; SELECT aropen_id INTO _returnVal FROM aropen WHERE ((aropen_cust_id=getCustId(pCustNumber,true)) AND (UPPER(aropen_doctype)=UPPER(pDocType)) AND (UPPER(aropen_docnumber)=UPPER(pDocNumber))); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'AR Open Item % not found.', pDocNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getaropenid(text, character, text) OWNER TO admin; -- -- Name: getbankaccntid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getbankaccntid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBankAccntName ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pBankAccntName IS NULL) THEN RETURN NULL; END IF; SELECT bankaccnt_id INTO _returnVal FROM bankaccnt WHERE (UPPER(bankaccnt_name)=UPPER(pBankAccntName)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Bank Account % not found.', pBankAccntName; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getbankaccntid(text) OWNER TO admin; -- -- Name: getbomitemid(text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getbomitemid(text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemNumber ALIAS FOR $1; pRevision ALIAS FOR $2; pSeqNumber ALIAS FOR $3; _returnVal INTEGER; BEGIN IF ((pItemNumber IS NULL) OR (pSeqNumber IS NULL) OR (pItemNumber = '') OR (pSeqNumber = '') ) THEN RETURN NULL; END IF; SELECT bomitem_id INTO _returnVal FROM bomitem(getItemId(pItemNumber),COALESCE(getRevId('BOM',pItemNumber,pRevision))) WHERE (bomitem_seqnumber=pSeqNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Sequence % on Bill of Material % Revision % not found.', pSeqNumber, pItemNumber, pRevision; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getbomitemid(text, text, text) OWNER TO admin; -- -- Name: getbooitemseqid(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getbooitemseqid(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemNumber ALIAS FOR $1; pSeqNumber ALIAS FOR $2; _revid INTEGER; _returnVal INTEGER; BEGIN IF ((pItemNumber IS NULL) OR (pSeqNumber IS NULL)) THEN RETURN NULL; END IF; IF (NOT fetchMetricBool('Routings')) THEN RETURN -1; ELSE SELECT booitem_seq_id INTO _returnVal FROM booitem(getItemId(pItemNumber)) WHERE (booitem_seqnumber=CAST(pSeqNumber AS integer)); END IF; IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Boo Sequence % for Item % not found.', pSeqNumber, pItemNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getbooitemseqid(text, text) OWNER TO admin; -- -- Name: getbudgheadid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getbudgheadid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBudghead ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pBudghead IS NULL) THEN RETURN NULL; END IF; SELECT budghead_id INTO _returnVal FROM budghead WHERE (budghead_name=(pBudghead)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Budget % not found.', pBudghead; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getbudgheadid(text) OWNER TO admin; -- -- Name: getcashrcptid(text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcashrcptid(text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustNumber ALIAS FOR $1; pFundsType ALIAS FOR $2; pDocNumber ALIAS FOR $3; _returnVal INTEGER; BEGIN IF ((pCustNumber IS NULL) OR (pFundsType IS NULL) OR (pDocNumber IS NULL)) THEN RETURN NULL; END IF; SELECT cashrcpt_id INTO _returnVal FROM cashrcpt WHERE ((cashrcpt_cust_id=getCustId(pCustNumber,true)) AND (UPPER(cashrcpt_fundstype)=UPPER(pFundsType)) AND (UPPER(cashrcpt_docnumber)=UPPER(pDocNumber))); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Cash Receipt % not found.', pDocNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getcashrcptid(text, text, text) OWNER TO admin; -- -- Name: getcharid(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcharid(pchar text, ptype text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (COALESCE(pChar, '') = '') THEN RETURN NULL; END IF; SELECT char_id INTO _returnVal FROM char JOIN charuse ON char_id = charuse_char_id WHERE char_name = pChar AND (charuse_target_type = pType OR (pType IN ('C', 'CT') AND charuse_target_type = 'C') OR (pType IN ('SI','QI','W','PI','TI') AND charuse_target_type = 'I') ) LIMIT 1; IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Characteristic % not found [xtuple: getCharId, -1, %]', pChar, pChar; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getcharid(pchar text, ptype text) OWNER TO admin; -- -- Name: getclasscodeid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getclasscodeid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pClassCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pClassCode IS NULL) THEN RETURN NULL; END IF; SELECT classcode_id INTO _returnVal FROM classcode WHERE (classcode_code=pClassCode); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Class Code % not found.', pClassCode; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getclasscodeid(text) OWNER TO admin; -- -- Name: getcmheadid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcmheadid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCreditMemoNumber ALIAS FOR $1; BEGIN RETURN getCmheadId(pCreditMemoNumber, NULL); END; $_$; ALTER FUNCTION public.getcmheadid(text) OWNER TO admin; -- -- Name: getcmheadid(text, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcmheadid(text, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCreditMemoNumber ALIAS FOR $1; pPosted ALIAS FOR $2; _returnVal INTEGER; BEGIN IF (pCreditMemoNumber IS NULL) THEN RETURN NULL; END IF; SELECT cmhead_id INTO _returnVal FROM cmhead WHERE (UPPER(cmhead_number)=UPPER(pCreditMemoNumber)) AND ((pPosted IS NULL) OR (cmhead_posted=pPosted)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Credit Memo % not found.', pCreditMemoNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getcmheadid(text, boolean) OWNER TO admin; -- -- Name: getcmnttypeid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcmnttypeid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmntType ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (COALESCE(TRIM(pCmntType), '') = '') THEN RETURN NULL; END IF; SELECT cmnttype_id INTO _returnVal FROM cmnttype WHERE (cmnttype_name=pCmntType) LIMIT 1; IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Comment Type % not found.', pCmntType; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getcmnttypeid(text) OWNER TO admin; -- -- Name: getcntctid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcntctid(pcontactnumber text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN SELECT getCntctId(pContactNumber,true) INTO _returnVal; RETURN _returnVal; END; $$; ALTER FUNCTION public.getcntctid(pcontactnumber text) OWNER TO admin; -- -- Name: getcntctid(text, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcntctid(pcontactnumber text, pnotfounderr boolean) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (COALESCE(TRIM(pContactNumber), '') = '') THEN RETURN NULL; END IF; SELECT cntct_id INTO _returnVal FROM cntct WHERE (cntct_number=pContactNumber); IF (_returnVal IS NULL AND pNotFoundErr) THEN RAISE EXCEPTION 'Contact Number % not found.', pContactNumber; ELSIF (_returnVal IS NULL) THEN RETURN NULL; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getcntctid(pcontactnumber text, pnotfounderr boolean) OWNER TO admin; -- -- Name: getcoheadid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcoheadid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSalesOrderNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pSalesOrderNumber IS NULL) THEN RETURN NULL; END IF; SELECT cohead_id INTO _returnVal FROM cohead WHERE (cohead_number=pSalesOrderNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Sales Order % not found.', pSalesOrderNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getcoheadid(text) OWNER TO admin; -- -- Name: getcoitemid(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcoitemid(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSalesOrderNumber ALIAS FOR $1; pLineNumber ALIAS FOR $2; _linenumber INTEGER; _subnumber INTEGER; _returnVal INTEGER; BEGIN IF (pSalesOrderNumber IS NULL OR pLineNumber IS NULL) THEN RETURN NULL; END IF; --Parse Line Number IF (position('.' in pLineNumber) > 0) THEN _linenumber := CAST(substring(pLineNumber from 1 for position('.' in pLineNumber)-1) AS INTEGER); _subnumber := CAST(substring(pLineNumber from position('.' in pLineNumber)+1 for length(pLineNumber)) AS INTEGER); ELSE _linenumber := CAST(pLineNumber AS INTEGER); _subnumber := 0; END IF; SELECT coitem_id INTO _returnVal FROM cohead, coitem WHERE ((cohead_number=pSalesOrderNumber) AND (coitem_cohead_id=cohead_id) AND (coitem_linenumber=_linenumber) AND (coitem_subnumber=_subnumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Sales Order % not found.', pSalesOrderNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getcoitemid(text, text) OWNER TO admin; -- -- Name: getcompanyid(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcompanyid(pglaccnt integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pGlAccnt IS NULL) THEN RETURN -1; END IF; SELECT accnt_company INTO _returnVal FROM accnt WHERE (accnt_id=pGlAccnt); IF (_returnVal IS NULL) THEN RETURN -1; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getcompanyid(pglaccnt integer) OWNER TO admin; -- -- Name: getcontrcteffective(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcontrcteffective(pcontrctnumber text) RETURNS date LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal DATE; BEGIN IF (pContrctNumber IS NULL) THEN RETURN NULL; END IF; SELECT contrct_effective INTO _returnVal FROM contrct WHERE (contrct_number=pContrctNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Contract Number % not found.', pContrctNumber; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getcontrcteffective(pcontrctnumber text) OWNER TO admin; -- -- Name: getcontrctexpires(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcontrctexpires(pcontrctnumber text) RETURNS date LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal DATE; BEGIN IF (pContrctNumber IS NULL) THEN RETURN NULL; END IF; SELECT contrct_expires INTO _returnVal FROM contrct WHERE (contrct_number=pContrctNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Contract Number % not found.', pContrctNumber; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getcontrctexpires(pcontrctnumber text) OWNER TO admin; -- -- Name: getcontrctid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcontrctid(pcontrctnumber text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pContrctNumber IS NULL) THEN RETURN NULL; END IF; SELECT contrct_id INTO _returnVal FROM contrct WHERE (contrct_number=pContrctNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Contract Number % not found.', pContrctNumber; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getcontrctid(pcontrctnumber text) OWNER TO admin; -- -- Name: getcostcatid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcostcatid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCostCat ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pCostCat IS NULL) THEN RETURN NULL; END IF; SELECT costcat_id INTO _returnVal FROM costcat WHERE (costcat_code=pCostCat); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Cost Category Code % not found.', pCostCat; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getcostcatid(text) OWNER TO admin; -- -- Name: getcostelemid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcostelemid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCostElemType ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pCostElemType IS NULL) THEN RETURN NULL; END IF; SELECT costelem_id INTO _returnVal FROM costelem WHERE (costelem_type=pCostElemType); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Cost Element % not found.', pCostElemType; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getcostelemid(text) OWNER TO admin; -- -- Name: getcrmacctid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcrmacctid(pacctnumber text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pAcctNumber IS NULL) THEN RETURN NULL; END IF; SELECT crmacct_id INTO _returnVal FROM crmacct WHERE (UPPER(crmacct_number)=UPPER(pAcctNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'CRM Account Number % not found.', pAcctNumber; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getcrmacctid(pacctnumber text) OWNER TO admin; -- -- Name: getcurrid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcurrid(pcurrname text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pCurrName IS NULL) THEN RETURN NULL; END IF; SELECT curr_id INTO _returnVal FROM curr_symbol WHERE (curr_abbr=pCurrName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Currency % not found.', pCurrName; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getcurrid(pcurrname text) OWNER TO admin; -- -- Name: getcustid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcustid(pcustnumber text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN SELECT getCustId(pCustNumber,false) INTO _returnVal; RETURN _returnVal; END; $$; ALTER FUNCTION public.getcustid(pcustnumber text) OWNER TO admin; -- -- Name: getcustid(text, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcustid(pcustnumber text, pinclprospects boolean) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pCustNumber IS NULL) THEN RETURN NULL; END IF; SELECT cust_id INTO _returnVal FROM custinfo WHERE (cust_number=UPPER(pCustNumber)); IF (_returnVal IS NULL) THEN IF (pInclProspects) THEN SELECT prospect_id INTO _returnVal FROM prospect WHERE (UPPER(prospect_number)=UPPER(pCustNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Neither Customer nor Prospect Number % found.', pCustNumber; END IF; ELSE RAISE EXCEPTION 'Customer Number % not found.', pCustNumber; END IF; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getcustid(pcustnumber text, pinclprospects boolean) OWNER TO admin; -- -- Name: getcustnamefrominfo(text, text, text, text, text, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcustnamefrominfo(text, text, text, text, text, boolean) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _email TEXT := COALESCE(UPPER($1), ''); _company TEXT := COALESCE(UPPER($2), ''); _first TEXT := COALESCE(UPPER($3), ''); _last TEXT := COALESCE(UPPER($4), ''); _fullname TEXT := COALESCE(UPPER($5), ''); _generate BOOLEAN := COALESCE($6, FALSE); _counter INTEGER; _custcount INTEGER := 0; _custname TEXT; _candidate RECORD; _r RECORD; BEGIN IF (_email != '') THEN SELECT count(*), cust_name INTO _custcount, _custname FROM custinfo LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) WHERE (UPPER(cntct_email)=_email) GROUP BY cust_name; IF (NOT FOUND) THEN _custcount := 0; ELSIF(_custcount = 1) THEN RETURN _custname; END IF; END IF; IF (_company != '') THEN SELECT count(*), cust_name INTO _custcount, _custname FROM custinfo WHERE (UPPER(cust_name)=_company) GROUP BY cust_name; IF (NOT FOUND) THEN _custcount := 0; ELSIF(_custcount = 1) THEN RETURN _custname; END IF; END IF; IF (_fullname = '' AND (_first != '' OR _last != '')) THEN _fullname := TRIM(_first || ' ' || _last); END IF; IF (_custcount <= 0 AND _fullname != '') THEN SELECT count(*), cust_name INTO _custcount, _custname FROM custinfo WHERE (UPPER(cust_name)=_fullname) GROUP BY cust_name; IF (NOT FOUND) THEN _custcount := 0; ELSIF(_custcount = 1) THEN RETURN _custname; END IF; END IF; IF (_custcount > 1) THEN RAISE EXCEPTION 'Found % possible Customers for % and % and %', _custcount, _email, _company, _fullname; END IF; IF (_custcount <= 0 AND _generate) THEN IF (_company != '') THEN RETURN _company; ELSIF (_email != '') THEN RETURN _email; ELSIF (_fullname != '') THEN RETURN _fullname; ELSE RAISE EXCEPTION 'Could not generate a new Customer Name without an email address or the name of a company or person'; END IF; END IF; IF (_custname IS NULL OR _custname = '') THEN RAISE EXCEPTION 'Could not find Customer Name for % and %', _company, _fullname; END IF; RETURN _custname; END; $_$; ALTER FUNCTION public.getcustnamefrominfo(text, text, text, text, text, boolean) OWNER TO admin; -- -- Name: getcustnumberfrominfo(text, text, text, text, text, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcustnumberfrominfo(text, text, text, text, text, boolean) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _email TEXT := COALESCE(UPPER($1), ''); _company TEXT := COALESCE(UPPER($2), ''); _first TEXT := COALESCE(UPPER($3), ''); _last TEXT := COALESCE(UPPER($4), ''); _fullname TEXT := COALESCE(UPPER($5), TRIM(_first || ' ' || _last)); _generate BOOLEAN := COALESCE($6, FALSE); _counter INTEGER; _custcount INTEGER := 0; _custnumber TEXT; _candidate TEXT := ''; _loopmax INTEGER := 0; _minlength INTEGER := 5; _maxlength INTEGER := 8; _numformat TEXT := ''; _testme TEXT; BEGIN IF (_email != '') THEN SELECT count(*), cust_number INTO _custcount, _custnumber FROM custinfo LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) WHERE (UPPER(cntct_email)=_email) GROUP BY cust_number; IF (NOT FOUND) THEN _custcount := 0; ELSIF(_custcount = 1) THEN RETURN _custnumber; END IF; END IF; IF (_company != '') THEN SELECT count(*), cust_number INTO _custcount, _custnumber FROM custinfo WHERE (UPPER(cust_name)=_company) GROUP BY cust_number; IF (NOT FOUND) THEN _custcount := 0; ELSIF(_custcount = 1) THEN RETURN _custnumber; END IF; END IF; IF (_fullname = '' AND (_first != '' OR _last != '')) THEN _fullname := TRIM(_first || ' ' || _last); END IF; IF (_custcount <= 0 AND _fullname != '') THEN SELECT count(*), cust_number INTO _custcount, _custnumber FROM custinfo WHERE (UPPER(cust_name)=_fullname) GROUP BY cust_number; IF (NOT FOUND) THEN _custcount := 0; ELSIF(_custcount = 1) THEN RETURN _custnumber; END IF; END IF; IF (_custcount > 1) THEN RAISE EXCEPTION 'Found % possible Customers for % and % and %', _custcount, _email, _company, _fullname; END IF; IF (_custcount <= 0 AND _generate) THEN IF (_maxlength < _minlength) THEN RAISE EXCEPTION 'Fix getCustNumberFromInfo: max length < min length'; END IF; IF (_company != '') THEN _candidate := _company; ELSIF (_email != '') THEN _candidate := SUBSTRING(_email FOR POSITION('@' IN _email) - 1); ELSIF (_last != '') THEN _candidate := _last; IF (_first != '') THEN _candidate := _candidate || _first; END IF; ELSIF (_fullname != '' AND (POSITION(' ' IN _fullname) > 0)) THEN _candidate := SUBSTRING(_fullname FROM POSITION(' ' IN _fullname) + 1) || SUBSTRING(_fullname FOR POSITION(' ' IN _fullname) - 1); END IF; WHILE (POSITION(' ' IN _candidate) > 0) LOOP _candidate := SUBSTRING(_candidate FOR POSITION(' ' IN _candidate) - 1) || SUBSTRING(_candidate FROM POSITION(' ' IN _candidate) + 1); END LOOP; FOR _counter IN _minlength.._maxlength LOOP _testme := SUBSTRING(_candidate FOR _counter); IF (NOT EXISTS(SELECT cust_number FROM custinfo WHERE (cust_number=_testme))) THEN _custnumber := _testme; EXIT; END IF; END LOOP; IF (_custnumber IS NULL OR _custnumber = '') THEN IF (LENGTH(_candidate) < _minlength) THEN _minlength := LENGTH(_candidate); END IF; FOR _counter IN _minlength.._maxlength LOOP _loopmax := _loopmax * 10 + 9; _numformat := _numformat || '0'; END LOOP; FOR _counter IN 1.._loopmax LOOP _testme := SUBSTRING(_candidate FOR _minlength) || TRIM(TO_CHAR(_counter, _numformat)); IF (NOT EXISTS(SELECT cust_number FROM custinfo WHERE (cust_number=_testme))) THEN _custnumber := _testme; EXIT; END IF; END LOOP; END IF; IF (_custnumber IS NULL OR _custnumber = '') THEN RAISE EXCEPTION 'Could not generate a new Customer Number'; END IF; END IF; IF (_custnumber IS NULL OR _custnumber = '') THEN RAISE EXCEPTION 'Could not find Customer Number for % and % and %', _email, _company, _fullname; END IF; RETURN _custnumber; END; $_$; ALTER FUNCTION public.getcustnumberfrominfo(text, text, text, text, text, boolean) OWNER TO admin; -- -- Name: getcusttypeid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getcusttypeid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustTypeCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pCustTypeCode IS NULL) THEN RETURN NULL; END IF; SELECT custtype_id INTO _returnVal FROM custtype WHERE (custtype_code=pCustTypeCode); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Customer Type % not found.', pCustTypeCode; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getcusttypeid(text) OWNER TO admin; -- -- Name: getdeptid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getdeptid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pDeptNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (COALESCE(TRIM(pDeptNumber), '') = '') THEN RETURN NULL; END IF; SELECT dept_id INTO _returnVal FROM dept WHERE (UPPER(dept_number)=UPPER(pDeptNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Department % not found.', pDeptNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getdeptid(text) OWNER TO admin; -- -- Name: getediprofileid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getediprofileid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pEdiProfileName ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pEdiProfileName IS NULL) THEN RETURN NULL; END IF; SELECT pkghead_id INTO _returnVal FROM pkghead WHERE(pkghead_name='xtbatch'); IF(NOT FOUND) THEN RETURN NULL; END IF; SELECT ediprofile_id INTO _returnVal FROM xtbatch.ediprofile WHERE (ediprofile_name=pEdiProfileName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'EDI Profile % not found.', pEdiProfileName; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getediprofileid(text) OWNER TO admin; -- -- Name: getediprofilename(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getediprofilename(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pEdiProfileId ALIAS FOR $1; _returnVal TEXT; BEGIN IF (pEdiProfileId IS NULL) THEN RETURN NULL; END IF; SELECT pkghead_name INTO _returnVal FROM pkghead WHERE(pkghead_name='xtbatch'); IF(NOT FOUND) THEN RETURN NULL; END IF; SELECT ediprofile_name INTO _returnVal FROM xtbatch.ediprofile WHERE (ediprofile_id=pEdiProfileId); RETURN _returnVal; END; $_$; ALTER FUNCTION public.getediprofilename(integer) OWNER TO admin; -- -- Name: getempid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getempid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pEmpCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (COALESCE(TRIM(pEmpCode), '') = '') THEN RETURN NULL; END IF; SELECT emp_id INTO _returnVal FROM emp WHERE (UPPER(emp_code)=UPPER(pEmpCode)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Employee % not found.', pEmpCode; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getempid(text) OWNER TO admin; -- -- Name: getexpcatid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getexpcatid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pExpcatCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (COALESCE(TRIM(pExpcatCode), '') = '') THEN RETURN NULL; END IF; SELECT expcat_id INTO _returnVal FROM expcat WHERE (expcat_code=UPPER(pExpcatCode)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Expense Category % not found.', pExpcatCode; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getexpcatid(text) OWNER TO admin; -- -- Name: getflcoldata(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getflcoldata(integer, integer) RETURNS SETOF flcoldata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlcolid ALIAS FOR $1; pPeriodid ALIAS FOR $2; _row flcoldata%ROWTYPE; _r RECORD; _start DATE; _end DATE; _col INTEGER := 1; _mult INTEGER; BEGIN --Get Layout Data SELECT * INTO _r FROM flcol WHERE (flcol_id=pFlcolid); -- Handle Month... IF (_r.flcol_month) THEN SELECT period_start, period_end INTO _start, _end FROM period WHERE (period_id=pPeriodid); IF (_r.flcol_showdb) THEN -- Debits Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; -- Credits Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; END IF; -- Month Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; -- These don't have drill down IF (_r.flcol_prcnt) THEN _col := _col + 1; END IF; IF (_r.flcol_budget) THEN _col := _col + 1; IF (_r.flcol_budgetprcnt) THEN _col := _col + 1; END IF; IF (_r.flcol_budgetdiff) THEN _col := _col + 1; END IF; IF (_r.flcol_budgetdiffprcnt) THEN _col := _col + 1; END IF; END IF; END IF; -- Handle Quarter... IF (_r.flcol_quarter) THEN SELECT min(qtr.period_start), max(qtr.period_end) INTO _start, _end FROM period p JOIN period qtr ON (p.period_quarter=qtr.period_quarter) AND (p.period_yearperiod_id=qtr.period_yearperiod_id) WHERE (p.period_id=pPeriodid); IF (_r.flcol_showdb) THEN -- Debits Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; -- Credits Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; END IF; -- Quarter Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; -- These don't have drill down IF (_r.flcol_prcnt) THEN _col := _col + 1; END IF; IF (_r.flcol_budget) THEN _col := _col + 1; IF (_r.flcol_budgetprcnt) THEN _col := _col + 1; END IF; IF (_r.flcol_budgetdiff) THEN _col := _col + 1; END IF; IF (_r.flcol_budgetdiffprcnt) THEN _col := _col + 1; END IF; END IF; END IF; -- Handle Year... IF (_r.flcol_year) THEN SELECT yearperiod_start, period_end INTO _start, _end FROM period p JOIN yearperiod ON (period_yearperiod_id=yearperiod_id) WHERE (p.period_id=pPeriodid); IF (_r.flcol_showdb) THEN -- Debits Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; -- Credits Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; END IF; -- Year Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; -- These don't have drill down IF (_r.flcol_prcnt) THEN _col := _col + 1; END IF; IF (_r.flcol_budget) THEN _col := _col + 1; IF (_r.flcol_budgetprcnt) THEN _col := _col + 1; END IF; IF (_r.flcol_budgetdiff) THEN _col := _col + 1; END IF; IF (_r.flcol_budgetdiffprcnt) THEN _col := _col + 1; END IF; END IF; END IF; -- Handle Prior Month... IF (_r.flcol_priormonth) THEN SELECT prv.period_start, prv.period_end INTO _start, _end FROM period p JOIN period prv ON (prv.period_start < p.period_start) WHERE (p.period_id=pPeriodid) ORDER BY prv.period_start DESC LIMIT 1; -- Prior Month Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; -- These don't have drill down IF (_r.flcol_priorprcnt) THEN _col := _col + 1; END IF; IF (_r.flcol_priordiff) THEN _col := _col + 1; END IF; IF (_r.flcol_priordiffprcnt) THEN _col := _col + 1; END IF; END IF; -- Handle Prior Quarter... IF (_r.flcol_priorquarter) THEN IF (_r.flcol_priortype = 'P') THEN -- Prior Quarter SELECT min(period_start), max(period_end) INTO _start, _end FROM ( SELECT prv.period_start, prv.period_end, prv.period_quarter, prv.period_yearperiod_id FROM period p JOIN period prv ON (prv.period_start < p.period_start) AND (prv.period_quarter != p.period_quarter) WHERE (p.period_id=pPeriodid)) data GROUP BY period_quarter, period_yearperiod_id ORDER BY min(period_start) DESC LIMIT 1; ELSE -- Prior Year Quarter SELECT min(period_start), max(period_end) INTO _start, _end FROM ( SELECT prv.period_start, prv.period_end, prv.period_quarter, prv.period_yearperiod_id FROM period p JOIN period prv ON (prv.period_start < p.period_start) AND (prv.period_yearperiod_id != p.period_yearperiod_id) AND (prv.period_quarter = p.period_quarter) WHERE (p.period_id=pPeriodid)) data GROUP BY period_quarter, period_yearperiod_id ORDER BY min(period_start) DESC LIMIT 1; END IF; -- Prior Quarter Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; -- These don't have drill down IF (_r.flcol_priorprcnt) THEN _col := _col + 1; END IF; IF (_r.flcol_priordiff) THEN _col := _col + 1; END IF; IF (_r.flcol_priordiffprcnt) THEN _col := _col + 1; END IF; END IF; -- Handle Prior Year... IF (_r.flcol_prioryear IN ('D','F')) THEN IF (_r.flcol_prioryear = 'D') THEN -- Prior Year to Date SELECT yearperiod_start, prv.period_end INTO _start, _end FROM period p JOIN period prv ON (prv.period_number = p.period_number) AND (prv.period_yearperiod_id != p.period_yearperiod_id) AND (prv.period_start < p.period_start) JOIN yearperiod ON (prv.period_yearperiod_id=yearperiod_id) WHERE (p.period_id=pPeriodid) ORDER BY prv.period_start DESC LIMIT 1; ELSE -- Prior Full Year SELECT prv.yearperiod_start, prv.yearperiod_end INTO _start, _end FROM period p JOIN yearperiod cur ON (cur.yearperiod_id=p.period_yearperiod_id) JOIN yearperiod prv ON (prv.yearperiod_start < cur.yearperiod_start) WHERE (p.period_id=pPeriodid) ORDER BY prv.yearperiod_start DESC LIMIT 1; END IF; -- Prior Year Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; END IF; RETURN; END; $_$; ALTER FUNCTION public.getflcoldata(integer, integer) OWNER TO admin; -- -- Name: getflcoldata(character, integer[], boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getflcoldata(character, integer[], boolean) RETURNS SETOF flcoldata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInterval ALIAS FOR $1; pPeriodids ALIAS FOR $2; pBudgets ALIAS FOR $3; _row flcoldata%ROWTYPE; _r RECORD; _start DATE; _end DATE; _col INTEGER := 1; _count INTEGER; _i INTEGER := 1; _incr INTEGER := 1; BEGIN IF (pBudgets) THEN _col := 2; _incr := 2; END IF; _count := ARRAY_UPPER(pPeriodIds,1); IF (pInterval = 'M') THEN FOR _i IN 1.._count LOOP SELECT period_start, period_end INTO _start, _end FROM period WHERE (period_id=pPeriodids[_i]); _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + _incr; END LOOP; ELSIF (pInterval = 'Q') THEN FOR _i IN 1.._count LOOP SELECT min(qtr.period_start), max(qtr.period_end) INTO _start, _end FROM period cur JOIN period qtr ON (cur.period_yearperiod_id=qtr.period_yearperiod_id) AND (cur.period_quarter=qtr.period_quarter) WHERE (cur.period_id=pPeriodids[_i]); _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + _incr; END LOOP; ELSE FOR _i IN 1.._count LOOP SELECT yearperiod_start, yearperiod_end INTO _start, _end FROM period JOIN yearperiod ON (period_yearperiod_id=yearperiod_id) WHERE (period_id=pPeriodids[_i]); _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + _incr; END LOOP; END IF; RETURN; END; $_$; ALTER FUNCTION public.getflcoldata(character, integer[], boolean) OWNER TO admin; -- -- Name: getflstmthead(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getflstmthead(integer, integer) RETURNS SETOF flstmthead LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlcolid ALIAS FOR $1; pPeriodid ALIAS FOR $2; _row flstmthead%ROWTYPE; _p RECORD; _month TEXT; _qtr TEXT; _year TEXT; _prmonth TEXT; _prqtr TEXT; _pryear TEXT; _err TEXT; BEGIN SELECT 'No Data' INTO _err; --Get Layout Data SELECT flcol_priortype, flcol_prioryear INTO _p FROM flcol WHERE (flcol_id=pFlcolid); --get data... --...for current Month SELECT (CASE WHEN period_name='' THEN formatdate(period_start) || '-' || formatdate(period_end) ELSE period_name END) INTO _month FROM period WHERE (period_id=pPeriodId); IF _month IS NULL THEN _month := _err; END IF; --...for Quarter SELECT ('Q' || period_quarter || '-' || EXTRACT(year from yearperiod_end)) INTO _qtr FROM period, yearperiod WHERE ((period_id=pPeriodId) AND (period_yearperiod_id=yearperiod_id)); IF _qtr IS NULL THEN _qtr := _err; END IF; --...for Year SELECT COALESCE((CASE WHEN period_name='' THEN (formatdate(period_start) || '-' || formatdate(period_end) || ' YTD') ELSE (period_name || ' YTD') END),'No Data') INTO _year FROM period WHERE (period_id=pPeriodId); IF _year IS NULL THEN _year := _err; END IF; --...for prior month IF (_p.flcol_priortype = 'P') THEN SELECT (CASE WHEN pp.period_name='' THEN formatdate(pp.period_start) || '-' || formatdate(pp.period_end) ELSE pp.period_name END) INTO _prmonth FROM period cp, period pp WHERE ((cp.period_id=pPeriodId) AND (cp.period_start > pp.period_start)) ORDER BY pp.period_start DESC LIMIT 1; ELSE SELECT (CASE WHEN pp.period_name='' THEN formatdate(pp.period_start) || '-' || formatdate(pp.period_end) ELSE pp.period_name END) INTO _prmonth FROM period cp, period pp WHERE ((cp.period_id=pPeriodId) AND (cp.period_id != pp.period_id) AND (cp.period_start > pp.period_start) AND (cp.period_number = pp.period_number)) ORDER BY pp.period_start DESC LIMIT 1; END IF; IF _prmonth IS NULL THEN _prmonth := _err; END IF; --...for prior quarter IF (_p.flcol_priortype='P') THEN SELECT ('Q' || pp.period_quarter || '-' || EXTRACT(year from yearperiod_end)) INTO _prqtr FROM period cp, period pp, yearperiod WHERE ((cp.period_id=pPeriodId) AND (cp.period_start > pp.period_start) AND (pp.period_quarter= CASE WHEN cp.period_quarter > 1 THEN cp.period_quarter - 1 ELSE 4 END) AND (pp.period_start >= cp.period_start - interval '1 year') AND (pp.period_yearperiod_id=yearperiod_id)) ORDER BY pp.period_start DESC LIMIT 1; ELSE SELECT ('Q' || pp.period_quarter || '-' || EXTRACT(year from pp.period_start)) INTO _prqtr FROM period cp, period pp, yearperiod cy, yearperiod py WHERE ((cp.period_id=pPeriodId) AND (cp.period_yearperiod_id=cy.yearperiod_id) AND (pp.period_yearperiod_id=py.yearperiod_id) AND (cp.period_quarter=pp.period_quarter) AND (cy.yearperiod_start > py.yearperiod_start)) ORDER BY py.yearperiod_start DESC, pp.period_start DESC LIMIT 1; END IF; IF _prqtr IS NULL THEN _prqtr := _err; END IF; --...for prior year IF (_p.flcol_prioryear='F') THEN SELECT (EXTRACT(year from py.yearperiod_end)||'') INTO _pryear FROM period cp, yearperiod cy, yearperiod py WHERE ((cp.period_id=pPeriodId) AND (cp.period_yearperiod_id = cy.yearperiod_id) AND (cy.yearperiod_start > py.yearperiod_start)) ORDER BY py.yearperiod_start DESC LIMIT 1; ELSE SELECT (CASE WHEN pp.period_name='' THEN formatdate(pp.period_start) || '-' || formatdate(pp.period_end) || ' YTD' ELSE pp.period_name || ' YTD' END) INTO _pryear FROM period cp, period pp WHERE ((cp.period_id=pPeriodId) AND (cp.period_number = pp.period_number) AND (cp.period_start > pp.period_start)) ORDER BY pp.period_start DESC LIMIT 1; END IF; IF _pryear IS NULL THEN _pryear := _err; END IF; -- RETURN RESULTS SELECT flhead_id AS flstmthead_flhead_id, flcol_id AS flstmthead_flcol_id, pPeriodid AS flstmthead_period, getEffectiveXtUser() AS flstmthead_username, CASE WHEN flhead_type = 'I' THEN 'Income Statement' WHEN flhead_type = 'B' THEN 'Balance Sheet' WHEN flhead_type = 'C' THEN 'Cash Flow Statement' ELSE 'N/A' END AS flstmthead_flhead_typedescrip1, CASE WHEN flhead_type = 'I' THEN 'Income' WHEN flhead_type = 'B' THEN 'Balance' WHEN flhead_type = 'C' THEN 'Cash' ELSE 'N/A' END AS flstmthead_flhead_typedescrip2, flhead_name AS flstmthead_flhead_name, flcol_name AS flstmthead_flcol_name, _month AS flstmthead_month, _qtr AS flstmthead_qtr, _year AS flstmthead_year, _prmonth AS flstmthead_prmonth, _prqtr AS flstmthead_prqtr, _pryear AS flstmthead_pryear INTO _p FROM flhead,flcol WHERE ((flcol_id=pFlcolid) AND (flhead_id=flcol_flhead_id)); _row.flstmthead_flhead_id := _p.flstmthead_flhead_id; _row.flstmthead_flcol_id := _p.flstmthead_flcol_id; _row.flstmthead_period_id := _p.flstmthead_period; _row.flstmthead_username := _p.flstmthead_username; _row.flstmthead_typedescrip1 := _p.flstmthead_flhead_typedescrip1; _row.flstmthead_typedescrip2 := _p.flstmthead_flhead_typedescrip2; _row.flstmthead_flhead_name := _p.flstmthead_flhead_name; _row.flstmthead_flcol_name := _p.flstmthead_flcol_name; _row.flstmthead_month := _p.flstmthead_month; _row.flstmthead_qtr := _p.flstmthead_qtr; _row.flstmthead_year := _p.flstmthead_year; _row.flstmthead_prmonth := _p.flstmthead_prmonth; _row.flstmthead_prqtr := _p.flstmthead_prqtr; _row.flstmthead_pryear := _p.flstmthead_pryear; RETURN NEXT _row; END; $_$; ALTER FUNCTION public.getflstmthead(integer, integer) OWNER TO admin; -- -- Name: getfltrendhead(integer, integer[], character); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getfltrendhead(integer, integer[], character) RETURNS SETOF fltrendhead LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlheadid ALIAS FOR $1; pPeriodids ALIAS FOR $2; pInterval ALIAS FOR $3; _row fltrendhead%ROWTYPE; _p RECORD; _count INTEGER; _i INTEGER; _t TEXT; _fld TEXT[]; _type CHAR; BEGIN -- Validate Interval IF pInterval <> 'M' AND pInterval <> 'Q' AND pInterval <> 'Y' THEN RAISE EXCEPTION 'Invalid Interval --> %', pInterval; END IF; IF ARRAY_UPPER(pPeriodIds,1) <= 12 THEN _count := ARRAY_UPPER(pPeriodIds,1); ELSE _count := 12; END IF; SELECT flhead_type INTO _type FROM flhead WHERE flhead_id = pFlheadId; --get data... --...for Month IF (pInterval = 'M') THEN FOR _i IN 1.._count LOOP SELECT (CASE WHEN period_name='' THEN formatdate(period_start) || '-' || formatdate(period_end) ELSE period_name END) INTO _t FROM period WHERE (period_id=pPeriodIds[_i]); _fld[_i] := _t; END LOOP; --...for Quarter ELSE IF (pInterval = 'Q') THEN FOR _i IN 1.._count LOOP SELECT ('Q' || period_quarter || '-' || EXTRACT(year from yearperiod_end)) INTO _t FROM period, yearperiod WHERE ((period_id=pPeriodIds[_i]) AND (period_yearperiod_id=yearperiod_id)); _fld[_i] := _t; END LOOP; --...for Year ELSE FOR _i IN 1.._count LOOP SELECT (EXTRACT(year from yearperiod_end)||'') INTO _t FROM period, yearperiod WHERE ((period_id=pPeriodIds[_i]) AND (period_yearperiod_id=yearperiod_id)); _fld[_i] := _t; END LOOP; END IF; END IF; -- RETURN RESULTS SELECT flhead_id AS fltrendhead_flhead_id, getEffectiveXtUser() AS fltrendhead_username, CASE WHEN flhead_type = 'I' THEN 'Income Statement' WHEN flhead_type = 'B' THEN 'Balance Sheet' WHEN flhead_type = 'C' THEN 'Cash Flow Statement' ELSE 'Ad Hoc' END AS fltrendhead_flhead_typedescrip, flhead_name AS fltrendhead_flhead_name INTO _p FROM flhead WHERE (flhead_id=pFlheadId); _row.fltrendhead_flhead_id := _p.fltrendhead_flhead_id; _row.fltrendhead_username := _p.fltrendhead_username; _row.fltrendhead_typedescrip := _p.fltrendhead_flhead_typedescrip; _row.fltrendhead_flhead_name := _p.fltrendhead_flhead_name; _row.fltrendhead_fld1 := _fld[1]; _row.fltrendhead_fld2 := _fld[2]; _row.fltrendhead_fld3 := _fld[3]; _row.fltrendhead_fld4 := _fld[4]; _row.fltrendhead_fld5 := _fld[5]; _row.fltrendhead_fld6 := _fld[6]; _row.fltrendhead_fld7 := _fld[7]; _row.fltrendhead_fld8 := _fld[8]; _row.fltrendhead_fld9 := _fld[9]; _row.fltrendhead_fld10 := _fld[10]; _row.fltrendhead_fld11 := _fld[11]; _row.fltrendhead_fld12 := _fld[12]; IF (_type IN ('I','C')) THEN _row.fltrendhead_grndttl := 'Total'; END IF; RETURN NEXT _row; END; $_$; ALTER FUNCTION public.getfltrendhead(integer, integer[], character) OWNER TO admin; -- -- Name: getfreightclassid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getfreightclassid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFreightClassCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pFreightClassCode IS NULL) THEN RETURN NULL; END IF; SELECT freightclass_id INTO _returnVal FROM freightclass WHERE (freightclass_code=pFreightClassCode); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Freight Class % not found.', pFreightClassCode; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getfreightclassid(text) OWNER TO admin; -- -- Name: getfreighttaxtypeid(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getfreighttaxtypeid() RETURNS integer LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _taxtypeid INTEGER; BEGIN SELECT taxtype_id INTO _taxtypeid FROM taxtype WHERE (taxtype_name='Freight'); RETURN _taxtypeid; END; $$; ALTER FUNCTION public.getfreighttaxtypeid() OWNER TO admin; -- -- Name: getgainlossaccntid(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getgainlossaccntid(integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAccntId ALIAS FOR $1; _returnVal INTEGER; BEGIN IF ( (pAccntId = 0) OR (pAccntId IS NULL) ) THEN RETURN 0; END IF; IF (fetchMetricValue('GLCompanySize') = 0) THEN _returnVal := fetchMetricValue('CurrencyGainLossAccount')::integer; ELSE SELECT company_gainloss_accnt_id INTO _returnVal FROM company JOIN accnt ON (company_number=accnt_company) WHERE (accnt_id=pAccntId); END IF; IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Currency Gain/Loss Account not found for %', formatGlAccountLong(pAccntId); END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getgainlossaccntid(integer) OWNER TO admin; -- -- Name: getglaccntid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getglaccntid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pGlAccnt ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pGlAccnt IS NULL) THEN RETURN NULL; END IF; SELECT accnt_id INTO _returnVal FROM accnt WHERE (formatglaccount(accnt_id)=pGlAccnt); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Account Number % not found.', pGlAccnt; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getglaccntid(text) OWNER TO admin; -- -- Name: getglaccntid(text, text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getglaccntid(text, text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCompany ALIAS FOR $1; pProfit ALIAS FOR $2; pGlAccnt ALIAS FOR $3; pSub ALIAS FOR $4; _account TEXT; _returnVal INTEGER; BEGIN IF (pGlAccnt IS NULL) THEN RETURN NULL; END IF; IF (pCompany is not null) THEN _account := pCompany || '-'; END IF; IF (pProfit is not null) THEN _account := _account || pProfit || '-'; END IF; IF (pGlAccnt is not null) THEN if (_account is null) then _account := pGlAccnt; else _account := _account || pGlAccnt; end if; END IF; IF (pSub is not null) THEN _account := _account || '-' || pSub; END IF; SELECT accnt_id INTO _returnVal FROM accnt WHERE (formatglaccount(accnt_id)=_account); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Account Number % not found.', _account; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getglaccntid(text, text, text, text) OWNER TO admin; -- -- Name: getimageid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getimageid(pimagename text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (COALESCE(TRIM(pImageName), '') = '') THEN RETURN NULL; END IF; SELECT image_id INTO _returnVal FROM image WHERE (image_name=pImageName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Image % not found.', pImageName; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getimageid(pimagename text) OWNER TO admin; -- -- Name: getincdtcatid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getincdtcatid(pincdtcatname text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pIncdtCatName IS NULL) THEN RETURN NULL; END IF; SELECT incdtcat_id INTO _returnVal FROM incdtcat WHERE (incdtcat_name=pIncdtCatName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Incident Category Name % not found.', pIncdtCatName; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getincdtcatid(pincdtcatname text) OWNER TO admin; -- -- Name: getincdtcrmacctid(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getincdtcrmacctid(pincidentnumber integer) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pIncidentNumber IS NULL) THEN RETURN NULL; END IF; SELECT incdt_crmacct_id INTO _returnVal FROM incdt WHERE (incdt_number=pIncidentNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Incident Number % not found.', pIncidentNumber; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getincdtcrmacctid(pincidentnumber integer) OWNER TO admin; -- -- Name: getincdtpriorityid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getincdtpriorityid(pincdtpriorityname text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pIncdtPriorityName IS NULL) THEN RETURN NULL; END IF; SELECT incdtpriority_id INTO _returnVal FROM incdtpriority WHERE (incdtpriority_name=pIncdtPriorityName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Incident Priority Name % not found.', pIncdtPriorityName; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getincdtpriorityid(pincdtpriorityname text) OWNER TO admin; -- -- Name: getincdtresolutionid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getincdtresolutionid(pincdtresolutionname text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pIncdtResolutionName IS NULL) THEN RETURN NULL; END IF; SELECT incdtresolution_id INTO _returnVal FROM incdtresolution WHERE (incdtresolution_name=pIncdtResolutionName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Incident Resolution Name % not found.', pIncdtResolutionName; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getincdtresolutionid(pincdtresolutionname text) OWNER TO admin; -- -- Name: getincdtseverityid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getincdtseverityid(pincdtseverityname text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pIncdtSeverityName IS NULL) THEN RETURN NULL; END IF; SELECT incdtseverity_id INTO _returnVal FROM incdtseverity WHERE (incdtseverity_name=pIncdtSeverityName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Incident Severity Name % not found.', pIncdtSeverityName; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getincdtseverityid(pincdtseverityname text) OWNER TO admin; -- -- Name: getincidentid(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getincidentid(pincidentnumber integer) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pIncidentNumber IS NULL) THEN RETURN NULL; END IF; SELECT incdt_id INTO _returnVal FROM incdt WHERE (incdt_number=pIncidentNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Incident Number % not found.', pIncidentNumber; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getincidentid(pincidentnumber integer) OWNER TO admin; -- -- Name: getinvcheadid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getinvcheadid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvcNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pInvcNumber IS NULL) THEN RETURN NULL; END IF; SELECT invchead_id INTO _returnVal FROM invchead WHERE (UPPER(invchead_invcnumber)=UPPER(pInvcNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Invoice % not found.', pInvcNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getinvcheadid(text) OWNER TO admin; -- -- Name: getinvcitemlotserial(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getinvcitemlotserial(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvcitemid ALIAS FOR $1; _lotserial text; _r RECORD; _first BOOLEAN; _newMethod BOOLEAN; BEGIN --Test to see if Lot/Serial Enabled SELECT metric_value INTO _lotserial FROM metric WHERE ((metric_name='LotSerialControl') AND (metric_value ='t')); IF (FOUND) THEN _lotserial := ''; _first := true; -- Two ways of doing this: old method and new method -- First, find out if new method employed. -- (new method is more accurate, but unfortunately no -- way to migrate or correct old data. Have to keep -- old method in case someone reprints an old invoice.) SELECT (COUNT(*) > 0) INTO _newMethod FROM shipitem WHERE ((shipitem_invcitem_id=pInvcitemid) AND (shipitem_invhist_id IS NOT NULL)); IF (_newMethod) THEN FOR _r IN SELECT DISTINCT ls_number FROM invdetail, invhist, shipitem, ls WHERE ((shipitem_invcitem_id=pInvcitemid) AND (shipitem_invhist_id=invhist_id) AND (invhist_id=invdetail_invhist_id) AND (invdetail_ls_id=ls_id)) LOOP IF (_first = false) THEN _lotserial := _lotserial || ', '; END IF; _lotserial := _lotserial || _r.ls_number; _first := false; END LOOP; RETURN _lotserial; ELSE -- Handle it old way FOR _r IN SELECT DISTINCT ls_number FROM ls, invdetail JOIN invhist ON (invdetail_invhist_id=invhist_id) WHERE ((invhist_transtype='SH') AND (invdetail_invcitem_id=pInvcitemid) AND (invdetail_ls_id=ls_id)) LOOP IF (_first = false) THEN _lotserial := _lotserial || ', '; END IF; _lotserial := _lotserial || _r.ls_number; _first := false; END LOOP; RETURN _lotserial; END IF; ELSE RETURN ''; END IF; END $_$; ALTER FUNCTION public.getinvcitemlotserial(integer) OWNER TO admin; -- -- Name: getipsheadid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getipsheadid(pipsname text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pIpsName IS NULL) THEN RETURN NULL; END IF; SELECT ipshead_id INTO _returnVal FROM ipshead WHERE (ipshead_name=pIpsName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Pricing Schedule % not found.', pIpsName; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getipsheadid(pipsname text) OWNER TO admin; -- -- Name: getipsitemid(text, text, numeric, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getipsitemid(pipsname text, pitemnumber text, pqtybreak numeric, pqtyuom text, ppriceuom text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pIpsName IS NULL AND pItemNumber IS NULL AND pQtyBreak IS NULL AND pQtyUom IS NULL AND pPriceUom IS NULL) THEN RETURN NULL; END IF; SELECT ipsitem_id INTO _returnVal FROM ipsiteminfo WHERE ((ipsitem_ipshead_id=getIpsheadId(pIpsName)) AND (ipsitem_item_id=getItemId(pItemNumber)) AND (ipsitem_qtybreak=pQtyBreak) AND (ipsitem_qty_uom_id=getUomId(pQtyUom)) AND (ipsitem_price_uom_id=getUomId(pPriceUom))); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Pricing Schedule Item for Schedule %, Item %,Qt Break %,Qty UOM %, Price UOM % not found.', pIpsName, pItemNumber, pQtyBreak, pQtyUom, pPriceUom; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getipsitemid(pipsname text, pitemnumber text, pqtybreak numeric, pqtyuom text, ppriceuom text) OWNER TO admin; -- -- Name: getipsprodcatid(text, text, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getipsprodcatid(pipsname text, pprodcat text, pqtybreak numeric) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pIpsName IS NULL AND pProdCat IS NULL AND pQtyBreak IS NULL) THEN RETURN NULL; END IF; SELECT ipsitem_id INTO _returnVal FROM ipsiteminfo WHERE ((ipsitem_ipshead_id=getIpsheadId(pIpsName)) AND (ipsitem_prodcat_id=getProdcatId(pProdCat)) AND (ipsitem_qtybreak=pQtyBreak)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Pricing Schedule Product Category for Schedule %, Product Category %,Qt Break % not found.', pIpsName, pProdCat, pQtyBreak; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getipsprodcatid(pipsname text, pprodcat text, pqtybreak numeric) OWNER TO admin; -- -- Name: getitemid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getitemid(text) RETURNS integer LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pItemNumber IS NULL) THEN RETURN NULL; END IF; SELECT item_id INTO _returnVal FROM item WHERE (item_number=UPPER(pItemNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Item % not found.', pItemNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getitemid(text) OWNER TO admin; -- -- Name: getitemidfromupc(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getitemidfromupc(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemUPC ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pItemUPC IS NULL) THEN RETURN NULL; END IF; SELECT item_id INTO _returnVal FROM item WHERE (item_upccode=UPPER(pItemUPC)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Item % not found.', pItemUPC; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getitemidfromupc(text) OWNER TO admin; -- -- Name: getitemsitecompanyid(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getitemsitecompanyid(pitemsite integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pItemSite IS NULL) THEN RETURN -1; END IF; SELECT getcompanyid(warehous_default_accnt_id) INTO _returnVal FROM whsinfo JOIN itemsite ON (itemsite_warehous_id=warehous_id) WHERE itemsite_id = pItemSite; IF (_returnVal IS NULL) THEN RETURN -1; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getitemsitecompanyid(pitemsite integer) OWNER TO admin; -- -- Name: getitemsiteid(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getitemsiteid(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehouseCode ALIAS FOR $1; pItemNumber ALIAS FOR $2; _returnVal INTEGER; BEGIN SELECT getItemsiteId(pWarehouseCode,pItemNumber,'ALL') INTO _returnVal; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getitemsiteid(text, text) OWNER TO admin; -- -- Name: getitemsiteid(text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getitemsiteid(text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehouseCode ALIAS FOR $1; pItemNumber ALIAS FOR $2; pType ALIAS FOR $3; _type TEXT; _p RECORD; BEGIN IF ((pWarehouseCode IS NULL) OR (pItemNumber IS NULL)) THEN RETURN NULL; END IF; IF UPPER(pType) NOT IN ('ALL','ACTIVE','SOLD') THEN RAISE EXCEPTION 'Invalid Type %. Valid Itemsite types are ALL and SOLD', pType; END IF; SELECT * INTO _p FROM itemsite, item WHERE ((itemsite_item_id=item_id) AND (itemsite_warehous_id=getWarehousId(pWarehouseCode,'ALL')) AND (item_number=UPPER(pItemNumber))); IF NOT (FOUND) THEN RAISE EXCEPTION 'Item % not found in Warehouse %', pItemNumber, pWarehouseCode; ELSIF ((UPPER(pType)='ACTIVE') OR (UPPER(pType)='SOLD')) THEN IF NOT (_p.item_active) THEN RAISE EXCEPTION 'Item % is inactive.', pItemNumber; ELSE IF NOT (_p.itemsite_active) THEN RAISE EXCEPTION 'Item % is inactive in Warehouse %', pItemNumber, pWarehouseCode; ELSE IF ((UPPER(pType)='SOLD') AND NOT _p.item_sold) THEN RAISE EXCEPTION 'Item % is not sold', pItemNumber; ELSE IF ((UPPER(pType)='SOLD') AND NOT _p.itemsite_sold) THEN RAISE EXCEPTION 'Item % is not sold from Warehouse %', pItemNumber, pWarehouseCode; END IF; END IF; END IF; END IF; END IF; RETURN _p.itemsite_id; END; $_$; ALTER FUNCTION public.getitemsiteid(text, text, text) OWNER TO admin; -- -- Name: getitemsrcid(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getitemsrcid(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemNumber ALIAS FOR $1; pVendNumber ALIAS FOR $2; _returnVal INTEGER; BEGIN IF ((pItemNumber IS NULL) OR (pVendNumber IS NULL)) THEN RETURN NULL; END IF; SELECT itemsrc_id INTO _returnVal FROM itemsrc WHERE ((itemsrc_item_id=getItemId(pItemNumber)) AND (itemsrc_vend_id=getVendId(pVendNumber))); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Item Source Item % Vendor % not found.', pItemNumber,pVendNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getitemsrcid(text, text) OWNER TO admin; -- -- Name: getlasttrialbalid(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getlasttrialbalid(integer, integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAccntId ALIAS FOR $1; pPeriodId ALIAS FOR $2; _p RECORD; _accntType TEXT; _result NUMERIC; BEGIN SELECT period_end,period_yearperiod_id INTO _p FROM period WHERE period_id=pPeriodId; SELECT accnt_type INTO _accntType FROM accnt WHERE accnt_id=pAccntId; IF (_accntType IN ('R','E')) THEN SELECT trialbal_id INTO _result FROM trialbal WHERE ((trialbal_accnt_id=pAccntId) AND (trialbal_period_id=pPeriodId)); ELSE SELECT trialbal_id INTO _result FROM (SELECT trialbal_id FROM trialbal,period WHERE ((trialbal_accnt_id=pAccntId) AND (trialbal_period_id=period_id) AND (period_end <= _p.period_end) AND (period_yearperiod_id=_p.period_yearperiod_id)) ORDER BY period_end DESC) AS data; END IF; RETURN _result; END; $_$; ALTER FUNCTION public.getlasttrialbalid(integer, integer) OWNER TO admin; -- -- Name: getlocationid(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getlocationid(pwarehouse text, plocation text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pLocation IS NULL) THEN RETURN NULL; END IF; SELECT location_id INTO _returnVal FROM location WHERE ((location_warehous_id=getWarehousId(pWarehouse,'ACTIVE')) AND (location_formatname=pLocation)) LIMIT 1; IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Location % not found in Warehouse %.', pLocation, pWarehouse; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getlocationid(pwarehouse text, plocation text) OWNER TO admin; -- -- Name: getlotserialid(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getlotserialid(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemNumber ALIAS FOR $1; pLotSerialNumber ALIAS FOR $2; _returnVal INTEGER; BEGIN IF ((pItemNumber IS NULL) OR (pLotSerialNumber IS NULL) OR (pLotSerialNumber='')) THEN RETURN NULL; END IF; SELECT ls_id INTO _returnVal FROM ls WHERE ((ls_item_id=getItemId(pItemNumber)) AND (UPPER(ls_number)=UPPER(pLotSerialNumber))); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'LotSerial % not found.', pLotSerialNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getlotserialid(text, text) OWNER TO admin; -- -- Name: getopenshipment(text, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getopenshipment(pordertype text, porderid integer, pwarehousid integer) RETURNS text LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _result TEXT := ''; BEGIN IF (pOrderType = 'SO') THEN SELECT shiphead_number INTO _result FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id) JOIN coitem ON (coitem_id=shipitem_orderitem_id) JOIN itemsite ON (itemsite_id=coitem_itemsite_id) WHERE (shiphead_order_id=pOrderId) AND (shiphead_order_type='SO') AND (NOT shiphead_shipped) AND (CASE WHEN (pWarehousId IS NULL) THEN TRUE ELSE itemsite_warehous_id=pWarehousId END) ORDER BY shiphead_number LIMIT 1; ELSEIF (pOrderType = 'TO') THEN SELECT shiphead_number INTO _result FROM shiphead JOIN tohead ON (tohead_id=shiphead_order_id) WHERE (shiphead_order_id=pOrderId) AND (shiphead_order_type='TO') AND (NOT shiphead_shipped) AND (CASE WHEN (pWarehousId IS NULL) THEN TRUE ELSE tohead_src_warehous_id=pWarehousId END) ORDER BY shiphead_number LIMIT 1; END IF; RETURN _result; END; $$; ALTER FUNCTION public.getopenshipment(pordertype text, porderid integer, pwarehousid integer) OWNER TO admin; -- -- Name: getopenshipmentid(text, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getopenshipmentid(pordertype text, porderid integer, pwarehousid integer) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _result INTEGER := -1; BEGIN IF (pOrderType = 'SO') THEN SELECT shiphead_id INTO _result FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id) JOIN coitem ON (coitem_id=shipitem_orderitem_id) JOIN itemsite ON (itemsite_id=coitem_itemsite_id) WHERE (shiphead_order_id=pOrderId) AND (shiphead_order_type='SO') AND (NOT shiphead_shipped) AND (CASE WHEN (pWarehousId IS NULL) THEN TRUE ELSE itemsite_warehous_id=pWarehousId END) ORDER BY shiphead_number LIMIT 1; ELSEIF (pOrderType = 'TO') THEN SELECT shiphead_id INTO _result FROM shiphead JOIN tohead ON (tohead_id=shiphead_order_id) WHERE (shiphead_order_id=pOrderId) AND (shiphead_order_type='TO') AND (NOT shiphead_shipped) AND (CASE WHEN (pWarehousId IS NULL) THEN TRUE ELSE tohead_src_warehous_id=pWarehousId END) ORDER BY shiphead_number LIMIT 1; END IF; RETURN _result; END; $$; ALTER FUNCTION public.getopenshipmentid(pordertype text, porderid integer, pwarehousid integer) OWNER TO admin; -- -- Name: getopheadid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getopheadid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOpHeadName ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pOpHeadName IS NULL) THEN RETURN NULL; END IF; SELECT ophead_id INTO _returnVal FROM ophead WHERE (UPPER(ophead_name)=UPPER(pOpHeadName)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Opportunity % not found.', pOpHeadName; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getopheadid(text) OWNER TO admin; -- -- Name: getpacklistcharname(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getpacklistcharname(integer, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipheadId ALIAS FOR $1; pOrderItemId ALIAS FOR $2; _charname text; _r RECORD; _first BOOLEAN; BEGIN -- If transfer order, get out SELECT shiphead_order_type INTO _r FROM shiphead WHERE ((shiphead_id=pShipheadId) AND (shiphead_order_type='TO')); IF (FOUND) THEN RETURN ''; END IF; _charname := ''; _first := true; FOR _r IN SELECT char_name FROM char, charass WHERE ((char_id=charass_char_id) AND (charass_target_type='SI') AND (charass_target_id=pOrderItemId)) LOOP IF (_first = false) THEN _charname := _charname || ' '; END IF; _charname := _charname || _r.char_name; _first := false; END LOOP; RETURN _charname; END $_$; ALTER FUNCTION public.getpacklistcharname(integer, integer) OWNER TO admin; -- -- Name: getpacklistcharvalue(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getpacklistcharvalue(integer, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipheadId ALIAS FOR $1; pOrderItemId ALIAS FOR $2; _charval text; _r RECORD; _first BOOLEAN; BEGIN -- If transfer order, get out SELECT shiphead_order_type INTO _r FROM shiphead WHERE ((shiphead_id=pShipheadId) AND (shiphead_order_type='TO')); IF (FOUND) THEN RETURN ''; END IF; _charval := ''; _first := true; FOR _r IN SELECT charass_value FROM char, charass WHERE ((char_id=charass_char_id) AND (charass_target_type='SI') AND (charass_target_id=pOrderItemId)) LOOP IF (_first = false) THEN _charval := _charval || ' '; END IF; _charval := _charval || _r.charass_value; _first := false; END LOOP; RETURN _charval; END $_$; ALTER FUNCTION public.getpacklistcharvalue(integer, integer) OWNER TO admin; -- -- Name: getpacklistitemlotserial(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getpacklistitemlotserial(integer, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipheadId ALIAS FOR $1; pOrderItemId ALIAS FOR $2; _lotserial text; _r RECORD; _first BOOLEAN; BEGIN --Test to see if Lot/Serial Enabled SELECT metric_value INTO _lotserial FROM metric WHERE ((metric_name='LotSerialControl') AND (metric_value ='t')); IF (FOUND) THEN _lotserial := ''; _first := true; FOR _r IN SELECT DISTINCT ls_number FROM invdetail, invhist, shipitem, ls WHERE ((shipitem_shiphead_id=pShipheadId) AND (shipitem_orderitem_id=pOrderItemId) AND (shipitem_invhist_id=invhist_id) AND (invhist_id=invdetail_invhist_id) AND (invdetail_ls_id=ls_id)) LOOP IF (_first = false) THEN _lotserial := _lotserial || ', '; END IF; _lotserial := _lotserial || _r.ls_number; _first := false; END LOOP; RETURN _lotserial; ELSE RETURN ''; END IF; END $_$; ALTER FUNCTION public.getpacklistitemlotserial(integer, integer) OWNER TO admin; -- -- Name: getperiodid(date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getperiodid(date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodDate ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pPeriodDate IS NULL) THEN RETURN NULL; END IF; SELECT period_id INTO _returnVal FROM period WHERE ((pPeriodDate) between period_start AND period_end); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Period for % not found.', pPeriodDate; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getperiodid(date) OWNER TO admin; -- -- Name: getperiodid(integer, character); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getperiodid(integer, character) RETURNS SETOF integer LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodId ALIAS FOR $1; pInterval ALIAS FOR $2; _x RECORD; BEGIN -- Validate Interval IF pInterval <> 'M' AND pInterval <> 'Q' AND pInterval <> 'Y' THEN RAISE EXCEPTION 'Invalid Interval --> %', pInterval; END IF; IF pInterval='M' THEN RETURN NEXT pPeriodId; ELSE IF pInterval='Q' THEN FOR _x IN SELECT qp.period_id AS period_id FROM period cp, period qp WHERE ((cp.period_id=pPeriodId) AND (cp.period_yearperiod_id=qp.period_yearperiod_id) AND (cp.period_quarter=qp.period_quarter) AND (cp.period_start>=qp.period_start)) ORDER BY qp.period_start LOOP RETURN NEXT _x.period_id; END LOOP; ELSE FOR _x IN SELECT yp.period_id AS period_id FROM period cp, period yp WHERE ((cp.period_id=pPeriodId) AND (cp.period_yearperiod_id=yp.period_yearperiod_id) AND (cp.period_start>=yp.period_start)) ORDER BY yp.period_start LOOP RETURN NEXT _x.period_id; END LOOP; END IF; END IF; RETURN; END; $_$; ALTER FUNCTION public.getperiodid(integer, character) OWNER TO admin; -- -- Name: getpkgheadid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getpkgheadid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ppkgname ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (ppkgname IS NULL) THEN RETURN NULL; END IF; SELECT pkghead_id INTO _returnVal FROM pkghead WHERE (UPPER(pkghead_name)=UPPER(ppkgname)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Package % not found.', ppkgname; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getpkgheadid(text) OWNER TO admin; -- -- Name: getplancodeid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getplancodeid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPlanCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pPlanCode IS NULL) THEN RETURN NULL; END IF; SELECT plancode_id INTO _returnVal FROM plancode WHERE (plancode_code=pPlanCode); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Plan Code % not found.', pPlanCode; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getplancodeid(text) OWNER TO admin; -- -- Name: getpoheadid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getpoheadid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPurchaseOrderNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pPurchaseOrderNumber IS NULL) THEN RETURN NULL; END IF; SELECT pohead_id INTO _returnVal FROM pohead WHERE (pohead_number=pPurchaseOrderNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Purchase Order % not found.', pPurchaseOrderNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getpoheadid(text) OWNER TO admin; -- -- Name: getpoitemid(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getpoitemid(text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPurchaseOrderNumber ALIAS FOR $1; pLineNumber ALIAS FOR $2; _returnVal INTEGER; BEGIN IF (pPurchaseOrderNumber IS NULL OR pLineNumber IS NULL) THEN RETURN NULL; END IF; SELECT poitem_id INTO _returnVal FROM pohead, poitem WHERE ((pohead_number=pPurchaseOrderNumber) AND (poitem_pohead_id=pohead_id) AND (poitem_linenumber=pLineNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Purchase Order % not found.', pSalesOrderNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getpoitemid(text, integer) OWNER TO admin; -- -- Name: getprjaccntid(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getprjaccntid(integer, integer) RETURNS integer LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrjid ALIAS FOR $1; pAccntid ALIAS FOR $2; BEGIN -- Project Accounting is required to fully implement this functionality RETURN pAccntId; END; $_$; ALTER FUNCTION public.getprjaccntid(integer, integer) OWNER TO admin; -- -- Name: getprjid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getprjid(pprjnumber text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pPrjNumber IS NULL) THEN RETURN NULL; END IF; SELECT prj_id INTO _returnVal FROM prj WHERE (prj_number=pPrjNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Project Number % not found.', pPrjNumber; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getprjid(pprjnumber text) OWNER TO admin; -- -- Name: getprjtaskid(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getprjtaskid(pprjnumber text, ptasknumber text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pPrjNumber IS NULL OR pTaskNumber IS NULL) THEN RETURN NULL; END IF; SELECT prjtask_id INTO _returnVal FROM prjtask JOIN prj ON (prj_id=prjtask_prj_id) WHERE ((prj_number=pPrjNumber) AND (prjtask_number=pTaskNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Project Task Number %-% not found.', pPrjNumber, pTaskNumber; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getprjtaskid(pprjnumber text, ptasknumber text) OWNER TO admin; -- -- Name: getprodcatid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getprodcatid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pProdCat ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pProdCat IS NULL) THEN RETURN NULL; END IF; SELECT prodcat_id INTO _returnVal FROM prodcat WHERE (prodcat_code=pProdCat); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Product Category % not found.', pProdCat; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getprodcatid(text) OWNER TO admin; -- -- Name: getprospectid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getprospectid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pProspectNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pProspectNumber IS NULL) THEN RETURN NULL; END IF; SELECT prospect_id INTO _returnVal FROM prospect WHERE(UPPER(prospect_number)=UPPER(pProspectNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Prospect Number % found.', pProspectNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getprospectid(text) OWNER TO admin; -- -- Name: getquoteid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getquoteid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuoteNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pQuoteNumber IS NULL) THEN RETURN NULL; END IF; SELECT quhead_id INTO _returnVal FROM quhead WHERE (quhead_number=pQuoteNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Quote Number % not found.', pQuoteNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getquoteid(text) OWNER TO admin; -- -- Name: getquotelineitemid(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getquotelineitemid(text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuoteNumber ALIAS FOR $1; pLineNumber ALIAS FOR $2; _returnVal INTEGER; BEGIN IF ((pQuoteNumber IS NULL) OR (pLineNumber IS NULL)) THEN RETURN NULL; END IF; SELECT quitem_id INTO _returnVal FROM quhead, quitem WHERE ((quhead_number=pQuoteNumber) AND (quhead_id=quitem_quhead_id) AND (quitem_linenumber=pLineNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Quote Line Item %-%not found.', pQuoteNumber,pLineNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getquotelineitemid(text, integer) OWNER TO admin; -- -- Name: getquotescheddate(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getquotescheddate(integer) RETURNS date LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuheadid ALIAS FOR $1; _minscheddate DATE; BEGIN SELECT MIN(quitem_scheddate) INTO _minscheddate FROM quitem WHERE (quitem_quhead_id=pQuheadid); RETURN _minscheddate; END; $_$; ALTER FUNCTION public.getquotescheddate(integer) OWNER TO admin; -- -- Name: getrevid(text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getrevid(text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pType ALIAS FOR $1; pItemNumber ALIAS FOR $2; pRevision ALIAS FOR $3; _returnVal INTEGER; BEGIN IF (pItemNumber IS NULL) THEN RETURN NULL; END IF; IF (NOT fetchMetricBool('RevControl')) THEN RETURN -1; ELSIF ( (pRevision IS NULL) OR (LENGTH(pRevision)=0) ) THEN SELECT getActiveRevId(pType, getItemId(pItemNumber)) INTO _returnVal; ELSE IF (pType='BOM') THEN SELECT rev_id INTO _returnVal FROM item, bomhead, rev WHERE ((item_id=bomhead_item_id) AND (bomhead_rev_id=rev_id) AND (UPPER(item_number)=UPPER(pItemNumber)) AND (rev_number=pRevision)); ELSIF (pType='BOO') THEN SELECT rev_id INTO _returnVal FROM item, xtmfg.boohead, rev WHERE ((item_id=boohead_item_id) AND (boohead_rev_id=rev_id) AND (UPPER(item_number)=UPPER(pItemNumber)) AND (rev_number=pRevision)); ELSE RAISE EXCEPTION 'Invalid Revision Type.'; END IF; END IF; IF (_returnVal IS NULL) THEN RAISE EXCEPTION '% revision % for % not found.', pType, pRevision, pItemNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getrevid(text, text, text) OWNER TO admin; -- -- Name: getrsnid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getrsnid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pRsnCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pRsnCode IS NULL) THEN RETURN NULL; END IF; SELECT rsncode_id INTO _returnVal FROM rsncode WHERE (rsncode_code=pRsnCode); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Reason Code % not found.', pRsnCode; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getrsnid(text) OWNER TO admin; -- -- Name: getsalescatid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getsalescatid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSalesCatName ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pSalesCatName IS NULL) THEN RETURN NULL; END IF; SELECT salescat_id INTO _returnVal FROM salescat WHERE (salescat_name=pSalesCatName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Sales Category % not found.', pSalesCatName; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getsalescatid(text) OWNER TO admin; -- -- Name: getsaleslineitemid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getsaleslineitemid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSalesOrderItem ALIAS FOR $1; _delpos INTEGER = 0; _order TEXT; _part TEXT; _ln INTEGER; _sn INTEGER; BEGIN IF (pSalesOrderItem IS NULL) THEN RETURN NULL; END IF; _delpos := strpos(pSalesOrderItem, '-'); IF (_delpos > 0) THEN _order := substr(pSalesOrderItem, 1, (_delpos - 1)); _part := substr(pSalesOrderItem, (_delpos + 1)); _delpos := strpos(_part, '.'); IF (_delpos > 0) THEN _ln := CAST(substr(_part, 1, (_delpos - 1)) AS INTEGER); _sn := CAST(substr(_part, (_delpos + 1)) AS INTEGER); ELSE _ln := CAST(_part AS INTEGER); _sn := 0; END IF; RETURN getSalesLineItemId( _order, _ln, _sn ); END IF; RETURN 0; END; $_$; ALTER FUNCTION public.getsaleslineitemid(text) OWNER TO admin; -- -- Name: getsaleslineitemid(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getsaleslineitemid(text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN getSalesLineItemId($1, $2, 0); END $_$; ALTER FUNCTION public.getsaleslineitemid(text, integer) OWNER TO admin; -- -- Name: getsaleslineitemid(text, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getsaleslineitemid(text, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSalesOrderNumber ALIAS FOR $1; pLineNumber ALIAS FOR $2; pSubNumber ALIAS FOR $3; _returnVal INTEGER; BEGIN IF ((pSalesOrderNumber IS NULL) OR (pLineNumber IS NULL)) THEN RETURN NULL; END IF; SELECT coitem_id INTO _returnVal FROM cohead, coitem WHERE ((cohead_number=pSalesOrderNumber) AND (cohead_id=coitem_cohead_id) AND (coitem_linenumber=pLineNumber) AND (coitem_subnumber=pSubNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Sales Line Item %-%not found.', pSalesOrderNumber,pLineNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getsaleslineitemid(text, integer, integer) OWNER TO admin; -- -- Name: getsalesorderid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getsalesorderid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSalesOrderNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pSalesOrderNumber IS NULL) THEN RETURN NULL; END IF; SELECT cohead_id INTO _returnVal FROM cohead WHERE (cohead_number=pSalesOrderNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Sales Order Number % not found.', pSalesOrderNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getsalesorderid(text) OWNER TO admin; -- -- Name: getsalesrepid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getsalesrepid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSalesRepNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pSalesRepNumber IS NULL) THEN RETURN NULL; END IF; SELECT salesrep_id INTO _returnVal FROM salesrep WHERE (salesrep_number=pSalesRepNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Sales Rep Number % not found.', pSalesRepNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getsalesrepid(text) OWNER TO admin; -- -- Name: getsaletypeid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getsaletypeid(psaletype text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pSaleType IS NULL) THEN RETURN NULL; END IF; SELECT saletype_id INTO _returnVal FROM saletype WHERE (saletype_code=UPPER(pSaleType)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Sale Type % not found.', pSaleType; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getsaletypeid(psaletype text) OWNER TO admin; -- -- Name: getshiftid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getshiftid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShiftNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (COALESCE(TRIM(pShiftNumber), '') = '') THEN RETURN NULL; END IF; SELECT shift_id INTO _returnVal FROM shift WHERE (UPPER(shift_number)=UPPER(pShiftNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Shift % not found.', pShiftNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getshiftid(text) OWNER TO admin; -- -- Name: getshipchrgid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getshipchrgid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipChrgName ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pShipChrgName IS NULL) THEN RETURN NULL; END IF; SELECT shipchrg_id INTO _returnVal FROM shipchrg WHERE (shipchrg_name=pShipChrgName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Ship Charge % not found.', pShipChrgName; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getshipchrgid(text) OWNER TO admin; -- -- Name: getshipformid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getshipformid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipFormName ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pShipFormName IS NULL) THEN RETURN NULL; END IF; SELECT shipform_id INTO _returnVal FROM shipform WHERE (shipform_name=pShipFormName) LIMIT 1; IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Ship Form % not found.', pShipFormName; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getshipformid(text) OWNER TO admin; -- -- Name: getshipheadid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getshipheadid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipmentNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pShipmentNumber IS NULL OR pShipmentNumber = '') THEN RETURN NULL; END IF; SELECT shiphead_id INTO _returnVal FROM shiphead WHERE (shiphead_number=pShipmentNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Shipment % not found.', pShipmentNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getshipheadid(text) OWNER TO admin; -- -- Name: getshiptoid(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getshiptoid(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustNumber ALIAS FOR $1; pShiptoNumber ALIAS FOR $2; _returnVal INTEGER; BEGIN IF ((pCustNumber IS NULL) OR (pShiptoNumber IS NULL)) THEN RETURN NULL; END IF; SELECT shipto_id INTO _returnVal FROM shiptoinfo WHERE ((shipto_cust_id=getCustId(pCustNumber,true)) AND (UPPER(shipto_num)=UPPER(pShiptoNumber))); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Shipto % not found.', pShiptoNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getshiptoid(text, text) OWNER TO admin; -- -- Name: getshiptonumberfrominfo(text, text, text, text, text, text, text, text, text, text, text, text, text, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getshiptonumberfrominfo(text, text, text, text, text, text, text, text, text, text, text, text, text, boolean, boolean) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _custname TEXT := COALESCE(TRIM(UPPER( $1)), ''); _email TEXT := COALESCE(TRIM(UPPER( $2)), ''); _company TEXT := COALESCE(TRIM(UPPER( $3)), ''); _first TEXT := COALESCE(TRIM(UPPER( $4)), ''); _last TEXT := COALESCE(TRIM(UPPER( $5)), ''); _fullname TEXT := COALESCE(TRIM(UPPER( $6)), ''); _addr1 TEXT := COALESCE(TRIM(UPPER( $7)), ''); _addr2 TEXT := COALESCE(TRIM(UPPER( $8)), ''); _addr3 TEXT := COALESCE(TRIM(UPPER( $9)), ''); _city TEXT := COALESCE(TRIM(UPPER($10)), ''); _state TEXT := COALESCE(TRIM(UPPER($11)), ''); _postalcode TEXT := COALESCE(TRIM(UPPER($12)), ''); _country TEXT := COALESCE(TRIM(UPPER($13)), ''); _generate BOOLEAN := COALESCE($14, FALSE); _create BOOLEAN := COALESCE($15, FALSE); _citytrunc TEXT; _counter INTEGER; _custid INTEGER; _custnumber TEXT; _candidate TEXT; _r RECORD; _statetrunc TEXT; BEGIN IF (_custname = '') THEN _custname := getCustNameFromInfo(_email, _company, _first, _last, _fullname, FALSE); END IF; SELECT COUNT(*) INTO _counter FROM custinfo, shiptoinfo, addr WHERE ((UPPER(cust_name)=UPPER(_custname)) AND UPPER(shipto_name)=UPPER(_fullname) AND (cust_id=shipto_cust_id) AND (shipto_addr_id=addr_id)); IF (_counter = 1) THEN SELECT shipto_num INTO _candidate FROM custinfo, shiptoinfo, addr WHERE ((UPPER(cust_name)=UPPER(_custname)) AND UPPER(shipto_name)=UPPER(_fullname) AND (cust_id=shipto_cust_id) AND (shipto_addr_id=addr_id)); RETURN _candidate; ELSE SELECT COUNT(*) INTO _counter FROM custinfo, shiptoinfo, addr WHERE ((UPPER(cust_name)=UPPER(_custname)) AND (cust_id=shipto_cust_id) AND (shipto_addr_id=addr_id)); IF (_counter = 1) THEN SELECT shipto_num INTO _candidate FROM custinfo, shiptoinfo, addr WHERE ((UPPER(cust_name)=UPPER(_custname)) AND (cust_id=shipto_cust_id) AND (shipto_addr_id=addr_id)); RETURN _candidate; ELSIF (_counter > 1) THEN SELECT shipto_num, CASE WHEN (UPPER(addr_country) = _country) THEN 1 ELSE 0 END + CASE WHEN (UPPER(addr_postalcode) = _postalcode) THEN 1 ELSE 0 END + CASE WHEN (UPPER(addr_state) = _state) THEN 1 ELSE 0 END + CASE WHEN (UPPER(addr_city) = _city) THEN 1 ELSE 0 END + CASE WHEN (UPPER(addr_line3) = _addr3) THEN 1 ELSE 0 END + CASE WHEN (UPPER(addr_line2) = _addr2) THEN 1 ELSE 0 END + CASE WHEN (UPPER(addr_line1) = _addr1) THEN 1 ELSE 0 END AS maxquotient INTO _candidate, _counter FROM custinfo, shiptoinfo, addr WHERE ((UPPER(cust_name)=_custname) AND (cust_id=shipto_cust_id) AND (shipto_addr_id=addr_id)) ORDER BY maxquotient desc LIMIT 1; RETURN _candidate; END IF; END IF; IF (_generate) THEN SELECT cust_number, cust_id INTO _custnumber, _custid FROM custinfo WHERE (UPPER(cust_name)=_custname); -- keep the number short _citytrunc := SUBSTRING(_city FOR 5); _statetrunc := SUBSTRING(_state FOR 5); IF (LENGTH(_citytrunc) > 0 AND NOT EXISTS(SELECT UPPER(shipto_num) FROM shiptoinfo WHERE ((shipto_cust_id=_custid) AND (UPPER(shipto_num)=_citytrunc)) )) THEN _candidate := _citytrunc; ELSIF (LENGTH(_last || _citytrunc) > 0 AND NOT EXISTS(SELECT UPPER(shipto_num) FROM shiptoinfo WHERE ((shipto_cust_id=_custid) AND (UPPER(shipto_num)=_last || _citytrunc)) )) THEN _candidate := _last || _citytrunc; ELSIF (LENGTH(_statetrunc) > 0 AND NOT EXISTS(SELECT UPPER(shipto_num) FROM shiptoinfo WHERE ((shipto_cust_id=_custid) AND (UPPER(shipto_num)=_statetrunc)) )) THEN _candidate := _statetrunc; ELSIF (LENGTH(_last || _statetrunc) > 0 AND NOT EXISTS(SELECT UPPER(shipto_num) FROM shiptoinfo WHERE ((shipto_cust_id=_custid) AND (UPPER(shipto_num)=_last || _statetrunc)) )) THEN _candidate := _last || _statetrunc; ELSIF (LENGTH(_citytrunc || _statetrunc) > 0 AND NOT EXISTS(SELECT UPPER(shipto_num) FROM shiptoinfo WHERE ((shipto_cust_id=_custid) AND (UPPER(shipto_num)=_citytrunc || _statetrunc)) )) THEN _candidate := _citytrunc || _statetrunc; ELSE SELECT CAST(COALESCE(MAX(CAST(shipto_num AS INTEGER)), 0) + 1 AS TEXT) INTO _candidate FROM shiptoinfo WHERE ((shipto_cust_id=_custid) AND (shipto_num~'^[0-9]*$')); END IF; IF (_create) THEN INSERT INTO api.custshipto ( customer_number, shipto_number, name, address1, address2, address3, city, state, postal_code, country, address_change, first, last, email, edi_profile ) VALUES ( _custnumber, _candidate, _candidate, _addr1, _addr2, _addr3, _city, _state, _postalcode, _country, 'CHANGEONE', _first, _last, LOWER(_email), 'No EDI' ); END IF; RETURN _candidate; END IF; RETURN ''; END; $_$; ALTER FUNCTION public.getshiptonumberfrominfo(text, text, text, text, text, text, text, text, text, text, text, text, text, boolean, boolean) OWNER TO admin; -- -- Name: getshipviaid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getshipviaid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipViaCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pShipViaCode IS NULL) THEN RETURN NULL; END IF; SELECT shipvia_id INTO _returnVal FROM shipvia WHERE (shipvia_code=pShipViaCode); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'ShipVia Code % not found.', pShipViaCode; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getshipviaid(text) OWNER TO admin; -- -- Name: getshipzoneid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getshipzoneid(pshipzonename text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pShipZoneName IS NULL) THEN RETURN NULL; END IF; SELECT shipzone_id INTO _returnVal FROM shipzone WHERE (shipzone_name=pShipZoneName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Ship Zone % not found.', pShipZoneName; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getshipzoneid(pshipzonename text) OWNER TO admin; -- -- Name: getsitetypeid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getsitetypeid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSiteType ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pSiteType IS NULL) THEN RETURN NULL; END IF; SELECT sitetype_id INTO _returnVal FROM sitetype WHERE (sitetype_name=pSiteType); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Site Type % not found.', pSiteType; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getsitetypeid(text) OWNER TO admin; -- -- Name: getsoitemstatus(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getsoitemstatus(pcoitemid integer) RETURNS text LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _result TEXT; BEGIN SELECT (CASE WHEN (coitem_status='O' AND (SELECT cust_creditstatus FROM custinfo WHERE cust_id=cohead_cust_id)='H') THEN 'H' WHEN (coitem_status='O' AND ((SELECT SUM(invcitem_billed) FROM invchead, invcitem WHERE ((CAST(invchead_ordernumber AS text)=cohead_number) AND (invcitem_invchead_id=invchead_id) AND (invcitem_item_id=itemsite_item_id) AND (invcitem_warehous_id=itemsite_warehous_id) AND (invcitem_linenumber=coitem_linenumber))) >= coitem_qtyord)) THEN 'I' WHEN (coitem_status='O' AND ((SELECT SUM(invcitem_billed) FROM invchead, invcitem WHERE ((CAST(invchead_ordernumber AS text)=cohead_number) AND (invcitem_invchead_id=invchead_id) AND (invcitem_item_id=itemsite_item_id) AND (invcitem_warehous_id=itemsite_warehous_id) AND (invcitem_linenumber=coitem_linenumber))) > 0)) THEN 'P' WHEN (coitem_status='O' AND (qtyAvailable(itemsite_id) - qtyAllocated(itemsite_id, CURRENT_DATE) + qtyOrdered(itemsite_id, CURRENT_DATE)) >= ((coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio)) THEN 'R' ELSE coitem_status END || CASE WHEN (coitem_firm) THEN 'F' ELSE '' END ) INTO _result FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id) JOIN custinfo ON (cust_id=cohead_cust_id) JOIN itemsite ON (itemsite_id=coitem_itemsite_id) WHERE (coitem_id=pCoitemid); RETURN _result; END; $$; ALTER FUNCTION public.getsoitemstatus(pcoitemid integer) OWNER TO admin; -- -- Name: getsoscheddate(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getsoscheddate(integer) RETURNS date LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCoheadid ALIAS FOR $1; _minscheddate DATE; BEGIN SELECT MIN(coitem_scheddate) INTO _minscheddate FROM cohead JOIN coitem ON (coitem_cohead_id=pCoheadid) WHERE true AND cohead_id=pCoheadid AND CASE WHEN (cohead_status='C') THEN coitem_status != 'X' ELSE coitem_status NOT IN ('C','X') END; RETURN _minscheddate; END; $_$; ALTER FUNCTION public.getsoscheddate(integer) OWNER TO admin; -- -- Name: getsostatus(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getsostatus(integer) RETURNS character LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCoheadid ALIAS FOR $1; _result char(1); BEGIN SELECT cohead_status INTO _result FROM cohead WHERE (cohead_id=pCoheadid); RETURN _result; END; $_$; ALTER FUNCTION public.getsostatus(integer) OWNER TO admin; -- -- Name: getsubtax(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getsubtax(integer, integer) RETURNS SETOF subtax LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxCodeId ALIAS FOR $1; pLevel ALIAS FOR $2; _row subtax%ROWTYPE; _x RECORD; _y RECORD; BEGIN FOR _x IN --Select all tax codes whose calculation basis is pTaxCodeId SELECT tax_id, tax_code, tax_descrip FROM tax WHERE tax_basis_tax_id = pTaxCodeId LOOP _row.subtax_taxcode_id := _x.tax_id; _row.subtax_taxcode_code := _x.tax_code; _row.subtax_taxcode_descrip := _x.tax_descrip; _row.subtax_taxcode_level := pLevel + 1; RETURN NEXT _row; FOR _y IN SELECT * from getSubTax(_x.tax_id, pLevel + 1) --This is the recursive part. LOOP _row.subtax_taxcode_id := _y.subtax_taxcode_id; _row.subtax_taxcode_code := _y.subtax_taxcode_code ; _row.subtax_taxcode_descrip := _y.subtax_taxcode_descrip; _row.subtax_taxcode_level := pLevel + 2; RETURN NEXT _row; END LOOP; END LOOP; END; $_$; ALTER FUNCTION public.getsubtax(integer, integer) OWNER TO admin; -- -- Name: gettaxauthid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION gettaxauthid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxAuthCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pTaxAuthCode IS NULL) THEN RETURN NULL; END IF; SELECT taxauth_id INTO _returnVal FROM taxauth WHERE (taxauth_code=pTaxAuthCode); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Tax Authority % not found.', pTaxAuthCode; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.gettaxauthid(text) OWNER TO admin; -- -- Name: gettaxid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION gettaxid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pTaxCode IS NULL) THEN RETURN NULL; END IF; SELECT tax_id INTO _returnVal FROM tax WHERE (tax_code=pTaxCode); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Tax Code % not found.', pTaxCode; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.gettaxid(text) OWNER TO admin; -- -- Name: gettaxtypeid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION gettaxtypeid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxType ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pTaxType IS NULL) THEN RETURN NULL; END IF; SELECT taxtype_id INTO _returnVal FROM taxtype WHERE (taxtype_name=pTaxType); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Tax Type % not found.', pTaxType; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.gettaxtypeid(text) OWNER TO admin; -- -- Name: gettaxzoneid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION gettaxzoneid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxZone ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pTaxZone IS NULL) THEN RETURN NULL; END IF; SELECT taxzone_id INTO _returnVal FROM taxzone WHERE (taxzone_code=pTaxZone); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Tax Zone % not found.', pTaxZone; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.gettaxzoneid(text) OWNER TO admin; -- -- Name: gettermsid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION gettermsid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTermsCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pTermsCode IS NULL) THEN RETURN NULL; END IF; SELECT terms_id INTO _returnVal FROM terms WHERE (terms_code=pTermsCode); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Terms Code % not found.', pTermsCode; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.gettermsid(text) OWNER TO admin; -- -- Name: getunassignedaccntid(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getunassignedaccntid(pcompanyid integer DEFAULT (-1)) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _test INTEGER; _returnVal INTEGER; BEGIN -- In a Multi-Company scenario we have to check the unassigned accnt for the -- correct Company. Otherwise choose the system metric IF (fetchMetricValue('GLCompanySize') > 0) THEN -- Multi-Company IF (pCompanyid = -1) THEN RAISE EXCEPTION 'Unassigned G/L Account could not be determined for an unknown Company [xtuple: getunassignedaccntid, -1]'; ELSE SELECT company_unassigned_accnt_id INTO _test FROM company WHERE company_id = pCompanyid; END IF; ELSE -- Single Company _test := fetchMetricValue('UnassignedAccount'); END IF; IF (_test IS NULL) THEN RAISE EXCEPTION 'Metric not found for UnassignedAccount [xtuple: getunassignedaccntid, -2]'; END IF; SELECT accnt_id INTO _returnVal FROM accnt WHERE (accnt_id=_test); IF (NOT FOUND) THEN RAISE EXCEPTION 'Metric UnassignedAccount is an invalid G/L Account [xtuple: getunassignedaccntid, -3, %1]', _test; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getunassignedaccntid(pcompanyid integer) OWNER TO admin; -- -- Name: getuomid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getuomid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUom ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pUom IS NULL) THEN RETURN NULL; END IF; SELECT uom_id INTO _returnVal FROM uom WHERE (uom_name=pUom); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Unit of Measure % not found.', pUom; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getuomid(text) OWNER TO admin; -- -- Name: getuomtypeid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getuomtypeid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUomType ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pUomType IS NULL) THEN RETURN NULL; END IF; SELECT uomtype_id INTO _returnVal FROM uomtype WHERE (UPPER(uomtype_name)=UPPER(pUomType)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Unit of Measuer Type % not found.', pUomType; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getuomtypeid(text) OWNER TO admin; -- -- Name: getuomtypeid(text[]); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getuomtypeid(text[]) RETURNS integer[] LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUomTypes ALIAS FOR $1; _returnVal INTEGER[]; _val INTEGER; _i INTEGER; BEGIN IF (pUomTypes IS NULL) OR (ARRAY_UPPER(pUomTypes,1) = 0) THEN RETURN NULL; END IF; FOR _i IN 1..ARRAY_UPPER(pUomTypes,1) LOOP SELECT uomtype_id INTO _val FROM uomtype WHERE (UPPER(uomtype_name)=UPPER(pUomTypes[_i])); IF (_val IS NULL) THEN RAISE EXCEPTION 'Unit of Measure Type % not found.', pUomTypes[_i]; ELSE _returnVal[_i] := _val; END IF; END LOOP; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getuomtypeid(text[]) OWNER TO admin; -- -- Name: getusrid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getusrid(pusr text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN SELECT usr_id INTO _returnVal FROM usr WHERE (usr_username=COALESCE(pUsr, getEffectiveXtUser())); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'User % not found.', pUsr; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getusrid(pusr text) OWNER TO admin; -- -- Name: getusrlocaleid(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getusrlocaleid() RETURNS integer LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN SELECT CAST(usrpref_value AS INTEGER) FROM usrpref WHERE (usrpref_username=getEffectiveXTUser()) AND (usrpref_name='locale_id') INTO _returnVal; IF (_returnVal IS NULL) THEN SELECT locale_id FROM locale WHERE (LOWER(locale_code) = 'default') LIMIT 1 INTO _returnVal; END IF; IF (_returnVal IS NULL) THEN SELECT locale_id FROM locale ORDER BY locale_id LIMIT 1 INTO _returnVal; END IF; IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'User Locale not found.'; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getusrlocaleid() OWNER TO admin; -- -- Name: getvendaddrid(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getvendaddrid(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendNumber ALIAS FOR $1; pVendAddrCode ALIAS FOR $2; _returnVal INTEGER; BEGIN IF ( (pVendNumber IS NULL) OR (pVendAddrCode IS NULL) ) THEN RETURN NULL; END IF; SELECT vendaddr_id INTO _returnVal FROM vendaddrinfo JOIN vendinfo ON (vend_id=vendaddr_vend_id) WHERE ( (vendaddr_code=pVendAddrCode) AND (vend_number=pVendNumber) ); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Vendor Number % Address % not found.', pVendNumber, pVendAddrCode; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getvendaddrid(text, text) OWNER TO admin; -- -- Name: getvendid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getvendid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pVendNumber IS NULL) THEN RETURN NULL; END IF; SELECT vend_id INTO _returnVal FROM vendinfo WHERE (vend_number=pVendNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Vendor Number % not found.', pVendNumber; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getvendid(text) OWNER TO admin; -- -- Name: getvendtypeid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getvendtypeid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendTypeCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pVendTypeCode IS NULL) THEN RETURN NULL; END IF; SELECT vendtype_id INTO _returnVal FROM vendtype WHERE (UPPER(vendtype_code)=UPPER(pVendTypeCode)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Vendor Type % not found.', pVendTypeCode; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getvendtypeid(text) OWNER TO admin; -- -- Name: getwarehousid(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getwarehousid(pwarehouscode text, ptype text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _active BOOL; _shipping BOOL; _returnVal INTEGER; BEGIN IF (pWarehousCode IS NULL) THEN RETURN NULL; END IF; IF (UPPER(pType) NOT IN ('ALL','ACTIVE','SHIPPING')) THEN RAISE EXCEPTION 'Warehouse lookip type % not valid. Valid types are ALL, ACTIVE and SHIPPING', pType; END IF; SELECT warehous_id, warehous_active, warehous_shipping INTO _returnVal, _active, _shipping FROM site() WHERE (warehous_code=UPPER(pWarehousCode)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Warehouse Code % not found.', pWarehousCode; ELSE IF ((pType='SHIPPING') AND (_shipping=false)) THEN RAISE EXCEPTION 'Warehouse Code % is not a vaild shipping warehouse.', pWarehousCode; ELSE IF ((pType IN ('SHIPPING','ACTIVE')) AND (_active=false)) THEN RAISE EXCEPTION 'Warehouse Code % is inactive.', pWarehousCode; END IF; END IF; END IF; RETURN _returnVal; END; $$; ALTER FUNCTION public.getwarehousid(pwarehouscode text, ptype text) OWNER TO admin; -- -- Name: getwhsezoneid(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION getwhsezoneid(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWhseCode ALIAS FOR $1; pWhseZoneName ALIAS FOR $2; _returnVal INTEGER; BEGIN IF ((pWhseCode IS NULL) OR (pWhseZoneName IS NULL)) THEN RETURN NULL; END IF; SELECT whsezone_id INTO _returnVal FROM whsezone WHERE ( (whsezone_warehous_id=getWarehousId(pWhseCode, 'ACTIVE')) AND (UPPER(whsezone_name)=UPPER(pWhseZoneName)) ); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Whsezone % not found.', pWhseZoneName; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.getwhsezoneid(text, text) OWNER TO admin; -- -- Name: grantallmodulecmnttypesource(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION grantallmodulecmnttypesource(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmnttypeid ALIAS FOR $1; pModuleName ALIAS FOR $2; _source RECORD; _sourceCounter INTEGER; BEGIN _sourceCounter := 0; FOR _source IN SELECT source_id FROM source WHERE (source_module=pModuleName) LOOP IF (SELECT grantCmnttypeSource(pCmnttypeid, _source.source_id)) THEN _sourceCounter := _sourceCounter + 1; END IF; END LOOP; RETURN _sourceCounter; END; $_$; ALTER FUNCTION public.grantallmodulecmnttypesource(integer, text) OWNER TO admin; -- -- Name: grantallmodulepriv(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION grantallmodulepriv(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pModuleName ALIAS FOR $2; _priv RECORD; _privCounter INTEGER; BEGIN _privCounter := 0; FOR _priv IN SELECT priv_id FROM priv WHERE (priv_module=pModuleName) LOOP IF (SELECT grantPriv(pUsername, _priv.priv_id)) THEN _privCounter := _privCounter + 1; END IF; END LOOP; RETURN _privCounter; END; $_$; ALTER FUNCTION public.grantallmodulepriv(text, text) OWNER TO admin; -- -- Name: grantallmoduleprivgroup(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION grantallmoduleprivgroup(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pGrpid ALIAS FOR $1; pModuleName ALIAS FOR $2; _priv RECORD; _privCounter INTEGER; BEGIN _privCounter := 0; FOR _priv IN SELECT priv_id FROM priv WHERE (priv_module=pModuleName) LOOP IF (SELECT grantPrivGroup(pGrpid, _priv.priv_id)) THEN _privCounter := _privCounter + 1; END IF; END LOOP; RETURN _privCounter; END; $_$; ALTER FUNCTION public.grantallmoduleprivgroup(integer, text) OWNER TO admin; -- -- Name: grantcmnttypesource(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION grantcmnttypesource(integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmnttypeid ALIAS FOR $1; pSourceid ALIAS FOR $2; _test INTEGER; BEGIN SELECT cmnttypesource_id INTO _test FROM cmnttypesource WHERE ( (cmnttypesource_cmnttype_id=pCmnttypeid) AND (cmnttypesource_source_id=pSourceid) ); IF (FOUND) THEN RETURN FALSE; END IF; INSERT INTO cmnttypesource ( cmnttypesource_cmnttype_id, cmnttypesource_source_id ) VALUES ( pCmnttypeid, pSourceid ); RETURN TRUE; END; $_$; ALTER FUNCTION public.grantcmnttypesource(integer, integer) OWNER TO admin; -- -- Name: grantgroup(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION grantgroup(text, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pGrpid ALIAS FOR $2; _test INTEGER; BEGIN SELECT usrgrp_id INTO _test FROM usrgrp WHERE ( (usrgrp_username=pUsername) AND (usrgrp_grp_id=pGrpid) ); IF (FOUND) THEN RETURN FALSE; END IF; INSERT INTO usrgrp ( usrgrp_username, usrgrp_grp_id ) VALUES ( pUsername, pGrpid ); RETURN TRUE; END; $_$; ALTER FUNCTION public.grantgroup(text, integer) OWNER TO admin; -- -- Name: grantpriv(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION grantpriv(text, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pPrivid ALIAS FOR $2; _test INTEGER; BEGIN SELECT usrpriv_id INTO _test FROM usrpriv WHERE ( (usrpriv_username=pUsername) AND (usrpriv_priv_id=pPrivid) ); IF (FOUND) THEN RETURN FALSE; END IF; INSERT INTO usrpriv ( usrpriv_username, usrpriv_priv_id ) VALUES ( pUsername, pPrivid ); NOTIFY "usrprivUpdated"; RETURN TRUE; END; $_$; ALTER FUNCTION public.grantpriv(text, integer) OWNER TO admin; -- -- Name: grantpriv(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION grantpriv(text, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pPrivname ALIAS FOR $2; _test INTEGER; BEGIN SELECT usrpriv_id INTO _test FROM usrpriv JOIN priv ON (usrpriv_priv_id=priv_id) WHERE ((usrpriv_username=pUsername) AND (priv_name=pPrivname) ); IF (FOUND) THEN RETURN FALSE; END IF; INSERT INTO usrpriv ( usrpriv_username, usrpriv_priv_id ) SELECT pUsername, priv_id FROM priv WHERE (priv_name=pPrivname); NOTIFY "usrprivUpdated"; RETURN TRUE; END; $_$; ALTER FUNCTION public.grantpriv(text, text) OWNER TO admin; -- -- Name: grantprivgroup(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION grantprivgroup(integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pGrpid ALIAS FOR $1; pPrivid ALIAS FOR $2; _test INTEGER; BEGIN SELECT grppriv_id INTO _test FROM grppriv WHERE ( (grppriv_grp_id=pGrpid) AND (grppriv_priv_id=pPrivid) ); IF (FOUND) THEN RETURN FALSE; END IF; INSERT INTO grppriv ( grppriv_grp_id, grppriv_priv_id ) VALUES ( pGrpid, pPrivid ); RETURN TRUE; END; $_$; ALTER FUNCTION public.grantprivgroup(integer, integer) OWNER TO admin; -- -- Name: hasalarms(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION hasalarms() RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _alarm RECORD; _alarmtype TEXT := ''; _batchId INTEGER; _evntlogordtype TEXT; _evnttypeid INTEGER; _evnttypename TEXT; _fromEmail TEXT; _itemid INTEGER; _longsource TEXT; _msgId INTEGER; _recipient TEXT; _recipientPart INTEGER; _returnVal BOOLEAN := FALSE; _summary TEXT; _whsId INTEGER := -1; BEGIN FOR _alarm IN SELECT * FROM alarm WHERE ((alarm_creator=getEffectiveXtUser()) AND (CURRENT_TIMESTAMP > alarm_trigger)) LOOP _returnVal := TRUE; IF (_alarm.alarm_source = 'TODO') THEN SELECT (todoitem_name || '-' || todoitem_description), 'T', 'TodoAlarm', 'To-Do Item' INTO _summary, _evntlogordtype, _evnttypename, _longsource FROM todoitem WHERE (todoitem_id = _alarm.alarm_source_id); _alarmtype = 'To-Do: '; ELSIF (_alarm.alarm_source = 'INCDT') THEN SELECT (incdt_number || '-' || incdt_summary), 'I', 'IncidentAlarm', 'Incident' INTO _summary, _evntlogordtype, _evnttypename, _longsource FROM incdt WHERE (incdt_id = _alarm.alarm_source_id); _alarmtype = 'Incident: '; ELSIF (_alarm.alarm_source = 'J') THEN SELECT (prj_number || ' ' || prj_name || '-' || prjtask_name), 'J', 'TaskAlarm', 'Project Task' INTO _summary, _evntlogordtype, _evnttypename, _longsource FROM prjtask JOIN prj ON (prj_id=prjtask_prj_id) WHERE (prjtask_id = _alarm.alarm_source_id); _alarmtype = 'Project: '; ELSE CONTINUE; -- there's nothing to do for this iteration of the loop END IF; -- if event alarm IF (_alarm.alarm_event) THEN SELECT evnttype_id INTO _evnttypeid FROM evnttype WHERE (evnttype_name=_evnttypename); _recipientPart := 1; LOOP _recipient := SPLIT_PART(_alarm.alarm_event_recipient, ',', _recipientPart); EXIT WHEN (LENGTH(_recipient) = 0); SELECT usrpref_value INTO _whsId FROM usrpref WHERE ( (usrpref_username = _recipient) AND (usrpref_name = 'PreferredWarehouse') ); INSERT INTO evntlog (evntlog_evnttime, evntlog_username, evntlog_evnttype_id, evntlog_ordtype, evntlog_ord_id, evntlog_warehous_id, evntlog_number ) VALUES (CURRENT_TIMESTAMP, _recipient, _evnttypeid, _evntlogordtype, _alarm.alarm_source_id, _whsId, _summary); _recipientPart := _recipientPart + 1; END LOOP; END IF; IF (_alarm.alarm_email) THEN SELECT usr_email INTO _fromEmail FROM usr WHERE (usr_username = _alarm.alarm_creator); _recipientPart := 1; LOOP _recipient := SPLIT_PART(_alarm.alarm_email_recipient, ',', _recipientPart); EXIT WHEN (LENGTH(_recipient) <= 0); _batchId := xtbatch.submitEmailToBatch(_fromEmail, _recipient, '', _alarmtype || _summary, 'Alarm reminder for ' || _longsource || '.', NULL, CURRENT_TIMESTAMP, FALSE, NULL, NULL); _recipientPart := _recipientPart + 1; END LOOP; END IF; IF (_alarm.alarm_sysmsg) THEN _recipientPart := 1; LOOP _recipient := SPLIT_PART(_alarm.alarm_sysmsg_recipient, ',', _recipientPart); EXIT WHEN (LENGTH(_recipient) <= 0); _msgId := postMessage(_recipient, (_longsource || ' - ' || _summary)); _recipientPart := _recipientPart + 1; END LOOP; END IF; DELETE FROM alarm WHERE alarm_id=_alarm.alarm_id; END LOOP; RETURN _returnVal; END; $$; ALTER FUNCTION public.hasalarms() OWNER TO admin; -- -- Name: hasevents(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION hasevents() RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN PERFORM evntlog_id FROM evntlog WHERE ( (evntlog_dispatched IS NULL) AND (evntlog_username=getEffectiveXtUser()) ) LIMIT 1; RETURN FOUND; END; $$; ALTER FUNCTION public.hasevents() OWNER TO admin; -- -- Name: hasmessages(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION hasmessages() RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN PERFORM msguser_id FROM msg, msguser WHERE ( (msguser_username=getEffectiveXtUser()) AND (msguser_msg_id=msg_id) AND (CURRENT_TIMESTAMP BETWEEN msg_scheduled AND msg_expires) AND (msguser_viewed IS NULL) ) LIMIT 1; RETURN FOUND; END; $$; ALTER FUNCTION public.hasmessages() OWNER TO admin; -- -- Name: haspriv(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION haspriv(text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrivName ALIAS FOR $1; _result INTEGER; _returnVal BOOLEAN; BEGIN RAISE WARNING 'hasPriv(TEXT) is deprecated. Use checkPrivilege(TEXT) instead.'; SELECT priv_id INTO _result FROM priv, grppriv, usrgrp WHERE((usrgrp_grp_id=grppriv_grp_id) AND (grppriv_priv_id=priv_id) AND (priv_name=pPrivName) AND (usrgrp_username=getEffectiveXtUser())); IF (FOUND) THEN RETURN true; END IF; SELECT COALESCE(usrpriv_id, 0) != 0 INTO _returnVal FROM priv LEFT OUTER JOIN usrpriv ON (priv_id=usrpriv_priv_id AND usrpriv_username = getEffectiveXtUser()) WHERE (priv_name=pPrivName); IF (_returnVal IS NULL) THEN _returnVal := FALSE; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.haspriv(text) OWNER TO admin; -- -- Name: hasprivonobject(text, text, integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION hasprivonobject(pprivtype text, pobjecttype text, pobjectid integer DEFAULT NULL::integer, puser text DEFAULT NULL::text) RETURNS boolean LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _haspriv BOOLEAN := FALSE; _privfound BOOLEAN := FALSE; _pkey TEXT[]; _privdesc RECORD; _qstr TEXT; BEGIN IF UPPER(pPrivType) NOT IN ('CREATE', 'EDIT', 'VIEW', 'DELETE') THEN RAISE EXCEPTION 'Cannot check if user has % on % [xtuple: hasPrivOnObject, -1, %, %]', pPrivType, pObjectType, pPrivType, pObjectType; END IF; /* TODO: create privdesc table? can't do it yet because this is a fix for a minor release NOTE: only include tables that have a single integer column as pkey NOTE: some of these are part of proprietary extensions. how do we make them part of the extension? */ FOR _privdesc IN WITH privdesc AS ( SELECT 'ADDR' AS otype, 'public' AS masterschema, 'addr' AS mastertable, 'MaintainAddressMasters' AS editall, 'ViewAddressMasters' AS viewall, NULL AS ownerfield, NULL AS editmine, NULL AS viewmine UNION ALL SELECT 'BBH', 'xtmfg', 'bbom', 'MaintainBBOMs', 'ViewBBOMs', NULL, NULL, NULL UNION ALL SELECT 'BBI', 'xtmfg', 'bbom', 'MaintainBBOMs', 'ViewBBOMs', NULL, NULL, NULL UNION ALL SELECT 'BMH', 'public', 'bom', 'MaintainBOMs', 'ViewBOMs', NULL, NULL, NULL UNION ALL SELECT 'BMI', 'public', 'bom', 'MaintainBOMs', 'ViewBOMs', NULL, NULL, NULL UNION ALL SELECT 'BOH', 'xtmfg', 'boo', 'MaintainBOOs', 'ViewBOOs', NULL, NULL, NULL UNION ALL SELECT 'BOI', 'xtmfg', 'boo', 'MaintainBOOs', 'ViewBOOs', NULL, NULL, NULL UNION ALL SELECT 'C', 'public', 'custinfo', 'MaintainCustomerMasters', 'ViewCustomerMasters', NULL, NULL, NULL UNION ALL SELECT 'CRMA', 'public', 'crmacct', 'MaintainAllCRMAccounts', 'ViewAllCRMAccounts', 'crmacct_owner_username', 'MaintainPersonalCRMAccounts', 'ViewPersonalCRMAccounts' UNION ALL SELECT 'EMP', 'public', 'emp', 'MaintainEmployees', 'ViewEmployees', NULL, NULL, NULL UNION ALL SELECT 'I', 'public', 'item', 'MaintainItemMasters', 'ViewItemMasters', NULL, NULL, NULL UNION ALL SELECT 'INCDT', 'public', 'incdt', 'MaintainAllIncidents', 'ViewAllIncidents', 'incdt_owner_username', 'MaintainPersonalIncidents', 'ViewPersonalIncidents' UNION ALL SELECT 'IR', 'public', 'itemsrc', 'MaintainItemSources', 'ViewItemSources', NULL, NULL, NULL UNION ALL SELECT 'IS', 'public', 'itemsite', 'MaintainItemSites', 'ViewItemSites', NULL, NULL, NULL UNION ALL SELECT 'J', 'public', 'prj', 'MaintainAllProjects', 'ViewAllProjects', 'prj_owner_username', 'MaintainPersonalProjects', 'ViewPersonalProjects' UNION ALL SELECT 'J', 'public', 'prj', 'MaintainAllProjects', 'ViewAllProjects', 'prj_username', 'MaintainPersonalProjects', 'ViewPersonalProjects' UNION ALL SELECT 'L', 'public', 'location', 'MaintainLocations', 'ViewLocations', NULL, NULL, NULL UNION ALL SELECT 'OPP', 'public', 'ophead', 'MaintainAllOpportunities', 'ViewAllOpportunities', 'ophead_owner_username', 'MaintainPersonalOpportunities', 'ViewPersonalOpportunities' UNION ALL SELECT 'P', 'public', 'pohead', 'MaintainPurchaseOrders', 'ViewPurchaseOrders', NULL, NULL, NULL UNION ALL SELECT 'PI', 'public', 'pohead', 'MaintainPurchaseOrders', 'ViewPurchaseOrders', NULL, NULL, NULL UNION ALL SELECT 'Q', 'public', 'quhead', 'MaintainQuotes', 'ViewQuotes', NULL, NULL, NULL UNION ALL SELECT 'QI', 'public', 'quhead', 'MaintainQuotes', 'ViewQuotes', NULL, NULL, NULL UNION ALL SELECT 'RA', 'public', 'rahead', 'MaintainReturns', 'ViewReturns', NULL, NULL, NULL UNION ALL SELECT 'RI', 'public', 'rahead', 'MaintainReturns', 'ViewReturns', NULL, NULL, NULL UNION ALL SELECT 'S', 'public', 'cohead', 'MaintainSalesOrders', 'ViewSalesOrders', NULL, NULL, NULL UNION ALL SELECT 'SI', 'public', 'cohead', 'MaintainSalesOrders', 'ViewSalesOrders', NULL, NULL, NULL UNION ALL SELECT 'T', 'public', 'cntct', 'MaintainAllContacts', 'ViewAllContacts', 'cntct_owner_username', 'MaintainPersonalContacts', 'ViewPersonalContacts' UNION ALL SELECT 'TE', 'te', 'tehead', 'MaintainTimeExpense', 'ViewTimeExpenseHistory', 'tehead_username', 'MaintainTimeExpenseSelf', NULL UNION ALL SELECT 'TE', 'te', 'tehead', 'MaintainTimeExpenseOthers', 'ViewTimeExpenseHistory', 'tehead_username', 'MaintainTimeExpenseSelf', NULL UNION ALL SELECT 'TI', 'public', 'tohead', 'MaintainTransferOrders', 'ViewTransferOrders', NULL, NULL, NULL UNION ALL SELECT 'TO', 'public', 'tohead', 'MaintainTransferOrders', 'ViewTransferOrders', NULL, NULL, NULL UNION ALL SELECT 'TODO', 'public', 'todoitem', 'MaintainAllToDoItems', 'ViewAllToDoItems', 'todoitem_owner_username', 'MaintainPersonalToDoItems', 'ViewPersonalToDoItems' UNION ALL SELECT 'V', 'public', 'vendinfo', 'MaintainVendors', 'ViewVendors', NULL, NULL, NULL UNION ALL SELECT 'W', 'public', 'wo', 'MaintainWorkOrders', 'ViewWorkOrders', NULL, NULL, NULL UNION ALL SELECT 'WH', 'public', 'whsinfo', 'MaintainWarehouses', 'ViewWarehouses', NULL, NULL, NULL) -- UNION ALL SELECT 'LS', 'public', 'ls', NULL, NULL, NULL, NULL, NULL -- UNION ALL SELECT 'P', 'public', 'pohead', 'MaintainPostedPurchaseOrders', 'ViewPurchaseOrders', NULL, NULL, NULL -- additional criteria? -- UNION ALL SELECT 'PI', 'public', 'pohead', 'MaintainPostedPurchaseOrders', 'ViewPurchaseOrders', NULL, NULL, NULL -- additional criteria? SELECT * FROM privdesc WHERE otype = pObjectType LOOP _privfound := TRUE; RAISE DEBUG '% % % % % % %', _privdesc.otype, _privdesc.masterschema, _privdesc.mastertable, _privdesc.editall, _privdesc.viewall, _privdesc.editmine, _privdesc.viewmine; IF checkPrivilege(CASE UPPER(pPrivType) WHEN 'CREATE' THEN _privdesc.editall WHEN 'EDIT' THEN _privdesc.editall WHEN 'DELETE' THEN _privdesc.editall WHEN 'VIEW' THEN _privdesc.viewall END) THEN _haspriv = TRUE; ELSIF checkPrivilege(CASE UPPER(pPrivType) WHEN 'CREATE' THEN _privdesc.editmine WHEN 'EDIT' THEN _privdesc.editmine WHEN 'DELETE' THEN _privdesc.editmine WHEN 'VIEW' THEN _privdesc.viewmine END) THEN IF pObjectId IS NULL THEN _haspriv = TRUE; ELSE _pkey := primaryKeyFields(_privdesc.masterschema, _privdesc.mastertable); -- SELECT ... FROM schema.table WHERE pkeyfield = pObjectId AND ownerfield = pUser _qstr := 'SELECT EXISTS(SELECT 1 FROM ' || quote_ident(_privdesc.masterschema) || '.' || quote_ident(_privdesc.mastertable) || ' WHERE ' || quote_ident(_pkey[1]) || ' = ' || pObjectId || ' AND ' || quote_ident(_privdesc.ownerfield) || '= ' || quote_literal(COALESCE(pUser, getEffectiveXtUser())) || ');'; RAISE DEBUG '%', _qstr; EXECUTE _qstr INTO _haspriv; END IF; END IF; EXIT WHEN _haspriv; END LOOP; RETURN _haspriv OR NOT _privfound; END; $$; ALTER FUNCTION public.hasprivonobject(pprivtype text, pobjecttype text, pobjectid integer, puser text) OWNER TO admin; -- -- Name: FUNCTION hasprivonobject(pprivtype text, pobjecttype text, pobjectid integer, puser text); Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON FUNCTION hasprivonobject(pprivtype text, pobjecttype text, pobjectid integer, puser text) IS 'Return if a user has permission to view or edit a specific database object. pPrivType is either CREATE, EDIT, DELETE, or VIEW, and controls which privilege is checked. pObjectType is one of the string constants used by the Documents widget, such as ADDR for Addresses. pObjectId is the internal id of the record in the table associated with pObjectType (defaults to NULL). pUser is the username to be checked for those pObjectTypes that restrict access to individual users (NULL == current user and is the default).'; -- -- Name: hmac(text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION hmac(text, text, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_hmac'; ALTER FUNCTION public.hmac(text, text, text) OWNER TO admin; -- -- Name: hmac(bytea, bytea, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION hmac(bytea, bytea, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_hmac'; ALTER FUNCTION public.hmac(bytea, bytea, text) OWNER TO admin; -- -- Name: implodewo(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION implodewo(pwoid integer, pimplodechildren boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE resultCode INTEGER; _routings BOOLEAN; _wo RECORD; BEGIN _routings := fetchMetricBool('Routings'); SELECT * INTO _wo FROM wo WHERE (wo_id=pWoid); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot find W/O id % [xtuple: implodeWo, -9]', pWoid; END IF; IF (_routings) THEN IF (EXISTS(SELECT wotc_wo_id FROM xtmfg.wotc WHERE (wotc_wo_id=pWoid))) THEN RAISE EXCEPTION 'Cannot implode W/O % with labor posting [xtuple: implodeWo, -1]', formatWoNumber(pWoid); END IF; END IF; IF (_wo.wo_status != 'E') THEN RAISE EXCEPTION 'Cannot implode W/O % with status % [xtuple: implodeWo, -2]', formatWoNumber(pWoid), _wo.wo_status; END IF; -- Delete any created P/R's for this W/O PERFORM deletePr('W', womatl_id) FROM womatl WHERE (womatl_wo_id=pWoid); DELETE FROM womatl WHERE (womatl_wo_id=pWoid); IF _routings THEN DELETE FROM xtmfg.wooper WHERE (wooper_wo_id=pWoid); END IF; UPDATE wo SET wo_status='O' WHERE (wo_id=pWoid); IF (pImplodeChildren) THEN resultCode := (SELECT MAX(implodeWo(wo_id, TRUE)) FROM wo WHERE ((wo_ordtype='W') AND (wo_ordid=pWoid))); resultCode := (SELECT MAX(deleteWo(wo_id, TRUE)) FROM wo WHERE ((wo_ordtype='W') AND (wo_ordid=pWoid))); END IF; RETURN 0; END; $$; ALTER FUNCTION public.implodewo(pwoid integer, pimplodechildren boolean) OWNER TO admin; -- -- Name: importbankreccleared(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION importbankreccleared(pbankrecid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _bankrecid INTEGER; _result INTEGER := 0; _cleared BOOLEAN; _doctype TEXT; _docid INTEGER := -1; _bankadjid INTEGER := -1; _debitbankadjtypeid INTEGER := -1; _creditbankadjtypeid INTEGER := -1; _b RECORD; _r RECORD; BEGIN -- cache some information IF (pBankrecid = -1) THEN _bankrecid := fetchMetricValue('ImportBankRecId'); ELSE _bankrecid := pBankrecid; END IF; SELECT * INTO _b FROM bankrec JOIN bankaccnt ON (bankaccnt_id=bankrec_bankaccnt_id) WHERE (bankrec_id=_bankrecid); IF (NOT FOUND) THEN RAISE EXCEPTION 'bankrec not found'; END IF; IF (_b.bankrec_posted) THEN RAISE EXCEPTION 'bankrec already posted'; END IF; _debitbankadjtypeid := fetchMetricValue('ImportBankRecDebitAdj'); IF (_debitbankadjtypeid = -1) THEN RAISE EXCEPTION 'Metric ImportBankRecDebitAdj not defined [xtuple: reconcileBankAccount, -1]'; END IF; _creditbankadjtypeid := fetchMetricValue('ImportBankRecCreditAdj'); IF (_creditbankadjtypeid = -1) THEN RAISE EXCEPTION 'Metric ImportBankRecCreditAdj not defined [xtuple: reconcileBankAccount, -2]'; END IF; -- loop thru bankrecimport and toggle cleared items FOR _r IN SELECT *, COALESCE(bankrecimport_debit_amount, 0.0) AS debit, COALESCE(bankrecimport_credit_amount, 0.0) AS credit FROM bankrecimport -- TODO how to handle multiple bank accounts -- WHERE (bankrecimport_?=_b.bankaccnt=?) LOOP -- TODO how to handle duplicate document numbers -- TODO how to handle amount differences -- TODO add support for Project Accounting (sltrans) IF ( (_r.debit > 0.0) AND (_r.credit > 0.0) ) THEN RAISE WARNING 'Bankrecimport % cannot determine if debit or credit', _r.bankrecimport_reference; CONTINUE; END IF; IF (_r.debit > 0.0) THEN -- handle receipts SELECT cashrcpt_id INTO _docid FROM cashrcpt WHERE (cashrcpt_docnumber=_r.bankrecimport_reference) AND (cashrcpt_posted) AND (NOT cashrcpt_void) -- TODO workaround for duplicates ORDER BY cashrcpt_id DESC LIMIT 1; IF (FOUND) THEN SELECT toggleBankrecCleared(_b.bankrec_id, 'GL', gltrans_id, cashrcpt_curr_rate, _r.debit, _r.bankrecimport_effdate) INTO _cleared FROM gltrans LEFT OUTER JOIN bankrecitem ON (bankrecitem_source='GL' AND bankrecitem_source_id=gltrans_id) WHERE (gltrans_source='A/R') AND (gltrans_doctype='CR') AND (gltrans_misc_id=_docid) AND (NOT gltrans_rec) AND (gltrans_accnt_id=_b.bankaccnt_accnt_id) AND (NOT COALESCE(bankrecitem_cleared, FALSE)); ELSE -- create and toggle bank adjustment -- TODO define bank adjustment names _bankadjid := -1; SELECT bankadj_id INTO _bankadjid FROM bankadj JOIN bankadjtype ON (bankadjtype_id=bankadj_bankadjtype_id) WHERE (bankadjtype_id=_debitbankadjtypeid) AND (bankadj_docnumber=_r.bankrecimport_reference) AND (bankadj_bankaccnt_id=_b.bankaccnt_id); IF (NOT FOUND) THEN INSERT INTO bankadj (bankadj_bankaccnt_id, bankadj_bankadjtype_id, bankadj_date, bankadj_docnumber, bankadj_amount, bankadj_notes, bankadj_curr_id) VALUES (_b.bankaccnt_id, _debitbankadjtypeid, _r.bankrecimport_effdate, _r.bankrecimport_reference, _r.debit, 'Import Bankrec Adjustment', _b.bankaccnt_curr_id) RETURNING bankadj_id INTO _bankadjid; END IF; SELECT toggleBankrecCleared(_b.bankrec_id, 'AD', _bankadjid, 1.0, _r.debit, _r.bankrecimport_effdate) INTO _cleared FROM bankadj LEFT OUTER JOIN bankrecitem ON (bankrecitem_source='AD' AND bankrecitem_source_id=bankadj_id) WHERE (bankadj_id=_bankadjid) AND (NOT COALESCE(bankrecitem_cleared, FALSE)); END IF; -- done with receipts ELSE -- handle checks SELECT checkhead_id INTO _docid FROM checkhead WHERE (checkhead_number::TEXT=_r.bankrecimport_reference) AND (checkhead_posted) AND (NOT checkhead_void); IF (FOUND) THEN SELECT toggleBankrecCleared(_b.bankrec_id, 'GL', gltrans_id, checkhead_curr_rate, _r.credit, _r.bankrecimport_effdate) INTO _cleared FROM gltrans LEFT OUTER JOIN bankrecitem ON (bankrecitem_source='GL' AND bankrecitem_source_id=gltrans_id) WHERE (gltrans_source='A/P') AND (gltrans_doctype='CK') AND (gltrans_misc_id=_docid) AND (NOT gltrans_rec) AND (gltrans_accnt_id=_b.bankaccnt_accnt_id) AND (NOT COALESCE(bankrecitem_cleared, FALSE)); ELSE -- create and toggle bank adjustment -- TODO define bank adjustment names _bankadjid := -1; SELECT bankadj_id INTO _bankadjid FROM bankadj JOIN bankadjtype ON (bankadjtype_id=bankadj_bankadjtype_id) WHERE (bankadjtype_id=_creditbankadjtypeid) AND (bankadj_docnumber=_r.bankrecimport_reference); IF (NOT FOUND) THEN INSERT INTO bankadj (bankadj_bankaccnt_id, bankadj_bankadjtype_id, bankadj_date, bankadj_docnumber, bankadj_amount, bankadj_notes, bankadj_curr_id) VALUES (_b.bankaccnt_id, _creditbankadjtypeid, _r.bankrecimport_effdate, _r.bankrecimport_reference, _r.credit, 'Import Bankrec Adjustment', _b.bankaccnt_curr_id) RETURNING bankadj_id INTO _bankadjid; END IF; SELECT toggleBankrecCleared(_b.bankrec_id, 'AD', _bankadjid, 1.0, _r.credit, _r.bankrecimport_effdate) INTO _cleared FROM bankadj LEFT OUTER JOIN bankrecitem ON (bankrecitem_source='AD' AND bankrecitem_source_id=_bankadjid) WHERE (NOT COALESCE(bankrecitem_cleared, FALSE)); END IF; -- done with checks END IF; END LOOP; RETURN _result; END; $$; ALTER FUNCTION public.importbankreccleared(pbankrecid integer) OWNER TO admin; -- -- Name: incdt; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE incdt ( incdt_id integer NOT NULL, incdt_number integer NOT NULL, incdt_crmacct_id integer, incdt_cntct_id integer, incdt_summary text, incdt_descrip text, incdt_item_id integer, incdt_timestamp timestamp without time zone DEFAULT now() NOT NULL, incdt_status character(1) DEFAULT 'N'::bpchar NOT NULL, incdt_assigned_username text, incdt_incdtcat_id integer, incdt_incdtseverity_id integer, incdt_incdtpriority_id integer, incdt_incdtresolution_id integer, incdt_lotserial text, incdt_ls_id integer, incdt_aropen_id integer, incdt_owner_username text, incdt_recurring_incdt_id integer, incdt_updated timestamp without time zone DEFAULT now() NOT NULL, incdt_prj_id integer, incdt_public boolean ); ALTER TABLE incdt OWNER TO admin; -- -- Name: TABLE incdt; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE incdt IS 'Incident table'; -- -- Name: COLUMN incdt.incdt_lotserial; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN incdt.incdt_lotserial IS 'incdt_lotserial is deprecated'; -- -- Name: COLUMN incdt.incdt_recurring_incdt_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN incdt.incdt_recurring_incdt_id IS 'The first incdt record in the series if this is a recurring Incident. If the incdt_recurring_incdt_id is the same as the incdt_id, this record is the first in the series.'; -- -- Name: incdt(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION incdt() RETURNS SETOF incdt LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row incdt%ROWTYPE; _priv TEXT; _grant BOOLEAN; BEGIN -- This query will give us the most permissive privilege the user has been granted SELECT privilege, granted INTO _priv, _grant FROM privgranted WHERE privilege IN ('MaintainAllIncidents','ViewAllIncidents','MaintainPersonalIncidents','ViewPersonalIncidents') ORDER BY granted DESC, sequence LIMIT 1; -- If have an 'All' privilege return all results IF (_priv ~ 'All' AND _grant) THEN FOR _row IN SELECT * FROM incdt LOOP RETURN NEXT _row; END LOOP; -- Otherwise if have any other grant, must be personal privilege. ELSIF (_grant) THEN FOR _row IN SELECT * FROM incdt WHERE getEffectiveXtUser() IN (incdt_owner_username, incdt_assigned_username) LOOP RETURN NEXT _row; END LOOP; END IF; RETURN; END; $$; ALTER FUNCTION public.incdt() OWNER TO admin; -- -- Name: FUNCTION incdt(); Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON FUNCTION incdt() IS 'A table function that returns Incident results according to privilege settings.'; -- -- Name: indentedbom(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION indentedbom(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; _revid INTEGER; BEGIN SELECT getActiveRevId('BOM',pItemid) INTO _revid; RETURN indentedBOM(pItemid, _revid); END; $_$; ALTER FUNCTION public.indentedbom(integer) OWNER TO admin; -- -- Name: indentedbom(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION indentedbom(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pRevisionid ALIAS FOR $2; _bomworkid INTEGER; _indexid INTEGER; _r RECORD; _batchsize NUMERIC; BEGIN -- Get the batch quantity SELECT COALESCE( ( SELECT bomhead_batchsize FROM bomhead WHERE ((bomhead_item_id=pItemId) AND (bomhead_rev_id=pRevisionid)) LIMIT 1),1) INTO _batchsize; -- Check on the temporary workspace -- PERFORM maintainBOMWorkspace(); -- Grab a new index for this bomwork set SELECT NEXTVAL('misc_index_seq') INTO _indexid; -- Step through all of the components of the passed pItemid FOR _r IN SELECT bomitem.*, item_id, itemuomtouom(item_id, item_inv_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') AS qtyreq, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS qtyfxd, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS qtyper, stdcost(item_id, bomitem_id) AS standardcost, actcost(item_id, bomitem_id) AS actualcost FROM bomitem(pItemId, pRevisionid), item WHERE ( (bomitem_item_id=item_id) ) LOOP -- Insert the component and bomitem parameters SELECT NEXTVAL('bomwork_bomwork_id_seq') INTO _bomworkid; INSERT INTO bomwork ( bomwork_id, bomwork_set_id, bomwork_parent_id, bomwork_level, bomwork_parent_seqnumber, bomwork_seqnumber, bomwork_item_id, bomwork_createwo, bomwork_qtyreq, bomwork_qtyfxd, bomwork_qtyper, bomwork_scrap, bomwork_issuemethod, bomwork_effective, bomwork_expires, bomwork_stdunitcost, bomwork_actunitcost, bomwork_char_id, bomwork_value, bomwork_notes, bomwork_ref, bomwork_bomitem_id, bomwork_ecn ) VALUES ( _bomworkid, _indexid, -1, 1, 0, _r.bomitem_seqnumber, _r.item_id, _r.bomitem_createwo, _r.qtyreq, _r.qtyfxd, _r.qtyper, _r.bomitem_scrap, _r.bomitem_issuemethod, _r.bomitem_effective, _r.bomitem_expires, _r.standardcost, _r.actualcost, _r.bomitem_char_id, _r.bomitem_value, _r.bomitem_notes, _r.bomitem_ref, _r.bomitem_id, _r.bomitem_ecn ); -- Explode the components of the current component PERFORM explodeBOM(_r.item_id, _bomworkid, 1); END LOOP; -- Return a key to the result RETURN _indexid; END; $_$; ALTER FUNCTION public.indentedbom(integer, integer) OWNER TO admin; -- -- Name: indentedbom(integer, integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION indentedbom(integer, integer, integer, integer) RETURNS SETOF bomdata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pRevisionid ALIAS FOR $2; pExpiredDays ALIAS FOR $3; pFutureDays ALIAS FOR $4; _row bomdata%ROWTYPE; _bomworksetid INTEGER; _x RECORD; _check CHAR(1); _inactive BOOLEAN := FALSE; _batchsize NUMERIC; BEGIN IF (pRevisionid != -1) THEN --Is this a deactivated revision? SELECT rev_status INTO _check FROM rev WHERE ((rev_id=pRevisionid) AND (rev_status='I')); IF (FOUND) THEN _inactive := TRUE; END IF; END IF; -- Get the batch quantity SELECT COALESCE( ( SELECT bomhead_batchsize FROM bomhead WHERE ((bomhead_item_id=pItemId) AND (bomhead_rev_id=pRevisionid)) LIMIT 1),1) INTO _batchsize; IF NOT (_inactive) THEN --We can explode this out based on current data SELECT indentedBOM(pItemid, pRevisionid) INTO _bomworksetid; FOR _x IN SELECT bomwork_id, bomwork_parent_id, bomwork_level, bomworkSequence(bomwork_id) AS seq_ord, bomwork_seqnumber, item_id, item_number, uom_name, item_descrip1, item_descrip2, (item_descrip1 || ' ' || item_descrip2) AS itemdescription, bomwork_qtyreq, bomwork_qtyfxd, bomwork_qtyper, bomwork_scrap, bomwork_createwo, CASE WHEN (bomwork_issuemethod='S') THEN 'Push' WHEN (bomwork_issuemethod='L') THEN 'Pull' WHEN (bomwork_issuemethod='M') THEN 'Mixed' ELSE 'Special' END AS issuemethod, bomwork_effective, bomwork_expires, (bomwork_expires <= CURRENT_DATE) AS expired, (bomwork_effective > CURRENT_DATE) AS future, bomwork_actunitcost AS actunitcost, bomwork_stdunitcost AS stdunitcost, CASE WHEN item_type NOT IN ('R','T') THEN itemuomtouom(item_id, item_inv_uom_id, NULL, (bomwork_qtyfxd/_batchsize + bomwork_qtyper) * (1 + bomwork_scrap), 'qtyper') * bomwork_actunitcost ELSE 0.0 END AS actextendedcost, CASE WHEN item_type NOT IN ('R','T') THEN itemuomtouom(item_id, item_inv_uom_id, NULL, (bomwork_qtyfxd/_batchsize + bomwork_qtyper) * (1 + bomwork_scrap), 'qtyper') * bomwork_stdunitcost ELSE 0.0 END AS stdextendedcost, bomwork_char_id, bomwork_value, bomwork_notes, bomwork_ref, bomwork_bomitem_id, bomwork_ecn FROM bomwork, item, uom WHERE ( (bomwork_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (bomwork_set_id=_bomworksetid) ) AND (bomwork_expires > (CURRENT_DATE - pExpiredDays)) AND (bomwork_effective <= (CURRENT_DATE + pFutureDays)) UNION SELECT -1, -1, 1, '0', NULL,-1, costelem_type AS bomdata_item_number, '', '', '', '', NULL, NULL, NULL, NULL, NULL, '', NULL, NULL, false, false, currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE) AS actunitcost, itemcost_stdcost AS stdunitcost, currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE) AS actextendedcost, itemcost_stdcost AS stdextendedcost, NULL, NULL,NULL,NULL, NULL,NULL FROM itemcost, costelem WHERE ( (itemcost_costelem_id=costelem_id) AND (NOT itemcost_lowlevel) AND (itemcost_item_id=pItemid) ) ORDER BY seq_ord LOOP _row.bomdata_bomwork_id := _x.bomwork_id; _row.bomdata_bomwork_parent_id := _x.bomwork_parent_id; _row.bomdata_bomwork_level := _x.bomwork_level; _row.bomdata_bomwork_seqnumber := _x.bomwork_seqnumber; _row.bomdata_bomitem_id := _x.bomwork_bomitem_id; _row.bomdata_item_id := _x.item_id; _row.bomdata_item_number := _x.item_number; _row.bomdata_uom_name := _x.uom_name; _row.bomdata_item_descrip1 := _x.item_descrip1; _row.bomdata_item_descrip2 := _x.item_descrip2; _row.bomdata_itemdescription := _x.itemdescription; _row.bomdata_batchsize := _batchsize; _row.bomdata_qtyreq := _x.bomwork_qtyreq; _row.bomdata_qtyfxd := _x.bomwork_qtyfxd; _row.bomdata_qtyper := _x.bomwork_qtyper; _row.bomdata_scrap := _x.bomwork_scrap; _row.bomdata_createchild := _x.bomwork_createwo; _row.bomdata_issuemethod := _x.issuemethod; _row.bomdata_effective := _x.bomwork_effective; _row.bomdata_expires := _x.bomwork_expires; _row.bomdata_expired := _x.expired; _row.bomdata_future := _x.future; _row.bomdata_actunitcost := _x.actunitcost; _row.bomdata_stdunitcost := _x.stdunitcost; _row.bomdata_actextendedcost := _x.actextendedcost; _row.bomdata_stdextendedcost := _x.stdextendedcost; _row.bomdata_ecn := _x.bomwork_ecn; _row.bomdata_char_id := _x.bomwork_char_id; _row.bomdata_value := _x.bomwork_value; _row.bomdata_notes := _x.bomwork_notes; _row.bomdata_ref := _x.bomwork_ref; RETURN NEXT _row; END LOOP; PERFORM deleteBOMWorkset(_bomworksetid); ELSE -- Use historical snapshot for inactive revisions FOR _x IN SELECT bomhist_id, bomhist_parent_id, bomhist_level, bomhistSequence(bomhist_seq_id) AS seq_ord, bomhist_seqnumber, item_id, item_number, uom_name, item_descrip1, item_descrip2, (item_descrip1 || ' ' || item_descrip2) AS itemdescription, bomhist_qtyreq, bomhist_qtyfxd, bomhist_qtyper, bomhist_scrap, bomhist_createwo, CASE WHEN (bomhist_issuemethod='S') THEN 'Push' WHEN (bomhist_issuemethod='L') THEN 'Pull' WHEN (bomhist_issuemethod='M') THEN 'Mixed' ELSE 'Special' END AS issuemethod, bomhist_effective, bomhist_expires, (bomhist_expires <= CURRENT_DATE) AS expired, (bomhist_effective > CURRENT_DATE) AS future, bomhist_actunitcost AS actunitcost, bomhist_stdunitcost AS stdunitcost, CASE WHEN item_type NOT IN ('R','T') THEN (bomhist_qtyfxd/_batchsize + bomhist_qtyper) * (1 + bomhist_scrap) * bomhist_actunitcost ELSE 0 END AS actextendedcost, CASE WHEN item_type NOT IN ('R','T') THEN (bomhist_qtyfxd/_batchsize + bomhist_qtyper) * (1 + bomhist_scrap) * bomhist_stdunitcost ELSE 0 END AS stdextendedcost, bomhist_char_id, bomhist_value, bomhist_notes, bomhist_ref FROM bomhist, item, uom WHERE ( (bomhist_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (bomhist_rev_id=pRevisionid) ) AND (bomhist_expires > (CURRENT_DATE - pExpiredDays)) AND (bomhist_effective <= (CURRENT_DATE + pFutureDays)) UNION SELECT -1, -1, 1, '0', NULL,-1, costelem_type AS bomdata_item_number, '', '', '', '', NULL, NULL, NULL, NULL, false, '', NULL, NULL, false, false, bomhist_actunitcost AS actunitcost, bomhist_stdunitcost AS stdunitcost, bomhist_actunitcost AS actextendedcost, bomhist_stdunitcost AS stdextendedcost, NULL,NULL,NULL,NULL FROM bomhist, costelem WHERE ((bomhist_rev_id=pRevisionid) AND (costelem_id=bomhist_item_id)) ORDER BY seq_ord LOOP _row.bomdata_bomwork_id := _x.bomhist_id; _row.bomdata_bomwork_parent_id := _x.bomhist_parent_id; _row.bomdata_bomwork_level := _x.bomhist_level; _row.bomdata_bomwork_seqnumber := _x.bomhist_seqnumber; _row.bomdata_bomitem_id := -1; _row.bomdata_item_id := _x.item_id; _row.bomdata_item_number := _x.item_number; _row.bomdata_uom_name := _x.uom_name; _row.bomdata_item_descrip1 := _x.item_descrip1; _row.bomdata_item_descrip2 := _x.item_descrip2; _row.bomdata_itemdescription := _x.itemdescription; _row.bomdata_batchsize := _batchsize; _row.bomdata_qtyreq := _x.bomhist_qtyreq; _row.bomdata_qtyfxd := _x.bomhist_qtyfxd; _row.bomdata_qtyper := _x.bomhist_qtyper; _row.bomdata_scrap := _x.bomhist_scrap; _row.bomdata_createchild := _x.bomhist_createwo; _row.bomdata_issuemethod := _x.issuemethod; _row.bomdata_effective := _x.bomhist_effective; _row.bomdata_expires := _x.bomhist_expires; _row.bomdata_expired := _x.expired; _row.bomdata_future := _x.future; _row.bomdata_actunitcost := _x.actunitcost; _row.bomdata_stdunitcost := _x.stdunitcost; _row.bomdata_actextendedcost := _x.actextendedcost; _row.bomdata_stdextendedcost := _x.stdextendedcost; _row.bomdata_ecn := ''; _row.bomdata_char_id := _x.bomhist_char_id; _row.bomdata_value := _x.bomhist_value; _row.bomdata_notes := _x.bomhist_notes; _row.bomdata_ref := _x.bomhist_ref; RETURN NEXT _row; END LOOP; END IF; RETURN; END; $_$; ALTER FUNCTION public.indentedbom(integer, integer, integer, integer) OWNER TO admin; -- -- Name: indentedwhereused(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION indentedwhereused(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; _indexid INTEGER; _level INTEGER; BEGIN -- Check on the temporary workspace -- PERFORM maintainBOMWorkspace(); _indexid := (SELECT NEXTVAL('misc_index_seq')); _level := 1; INSERT INTO bomwork ( bomwork_set_id, bomwork_parent_id, bomwork_level, bomwork_seqnumber, bomwork_item_id, bomwork_item_type, bomwork_createwo, bomwork_qtyfxd, bomwork_qtyper, bomwork_scrap, bomwork_issuemethod, bomwork_effective, bomwork_expires, bomwork_status, bomwork_stdunitcost, bomwork_actunitcost ) SELECT _indexid, -1, 1, bomitem_seqnumber, item_id, item_type, bomitem_createwo, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd), (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper), bomitem_scrap, bomitem_issuemethod, bomitem_effective, bomitem_expires, 'U', stdcost(item_id), actcost(item_id) FROM bomitem, item WHERE ((bomitem_item_id=pItemid) AND (bomitem_parent_item_id=item_id) AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id))); WHILE ( ( SELECT count(*) FROM bomwork WHERE ((bomwork_status='U') AND (bomwork_set_id=_indexid)) ) > 0) LOOP _level := _level + 1; INSERT INTO bomwork ( bomwork_set_id, bomwork_parent_id, bomwork_level, bomwork_seqnumber, bomwork_item_id, bomwork_item_type, bomwork_createwo, bomwork_qtyfxd, bomwork_qtyper, bomwork_scrap, bomwork_issuemethod, bomwork_effective, bomwork_expires, bomwork_status, bomwork_stdunitcost, bomwork_actunitcost ) SELECT _indexid, bomwork_id, _level, bomitem_seqnumber, item_id, item_type, bomitem_createwo, (bomwork_qtyper * (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd)), (bomwork_qtyper * (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper)), bomitem_scrap, bomitem_issuemethod, CASE WHEN bomitem_effective < bomwork_effective THEN bomwork_effective ELSE bomitem_effective END, CASE WHEN bomitem_expires > bomwork_expires THEN bomwork_expires ELSE bomitem_expires END, 'N', stdcost(item_id), actcost(item_id) FROM bomwork JOIN bomitem ON ( (bomitem_item_id=bomwork_item_id) AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id)) ) JOIN item ON (item_id=bomitem_parent_item_id) WHERE (bomwork_status='U'); UPDATE bomwork SET bomwork_status='C' WHERE ((bomwork_status='U') AND (bomwork_set_id=_indexid)); UPDATE bomwork SET bomwork_status='U' WHERE ((bomwork_status='N') AND (bomwork_set_id=_indexid)); END LOOP; RETURN _indexid; END; $_$; ALTER FUNCTION public.indentedwhereused(integer) OWNER TO admin; -- -- Name: indentedwo(integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION indentedwo(integer, boolean, boolean, boolean) RETURNS SETOF wodata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pwoid ALIAS FOR $1; pshowops ALIAS FOR $2; pshowmatl ALIAS FOR $3; pshowindent ALIAS FOR $4; _row wodata%ROWTYPE; _subrow wodata%ROWTYPE; _opx wodata%ROWTYPE; _x RECORD; _level INTEGER; BEGIN --The wodata_id_type column is used to indicate the source of the wodata_id --there are three different tables used wo, womatl and womatlvar --wodata_id_type = 1 = wo_id --wodata_id_type = 2 = womatl_id --wodata_id_type = 3 = wooper_id --initialise values _level := 0; --get top level works orders FOR _x IN SELECT wo_id,wo_number,wo_subnumber,wo_status,wo_startdate, wo_duedate,wo_adhoc,wo_itemsite_id,qtyAvailable(itemsite_id) AS availableqoh, wo_qtyord,wo_qtyrcv,wo_prodnotes, item_number, item_descrip1, item_descrip2, item_listprice, uom_name FROM wo, itemsite, item, uom WHERE ((wo_id = pwoid) AND (itemsite_id = wo_itemsite_id) AND (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id)) ORDER BY wo_number, wo_subnumber LOOP _row.wodata_id := _x.wo_id; _row.wodata_id_type := 1; _row.wodata_number := _x.wo_number; _row.wodata_subnumber := _x.wo_subnumber; _row.wodata_itemnumber := _x.item_number; _row.wodata_descrip := _x.item_descrip1 || '-' || _x.item_descrip2; _row.wodata_status := _x.wo_status; _row.wodata_startdate := _x.wo_startdate; _row.wodata_duedate := _x.wo_duedate; _row.wodata_adhoc := _x.wo_adhoc; _row.wodata_itemsite_id := _x.wo_itemsite_id; _row.wodata_custprice := _x.item_listprice; _row.wodata_listprice := _x.item_listprice; _row.wodata_qoh := _x.availableqoh; _row.wodata_short := noneg(_x.wo_qtyord - _x.wo_qtyrcv); _row.wodata_qtyrcv := _x.wo_qtyrcv; _row.wodata_qtyordreq := _x.wo_qtyord; _row.wodata_qtyuom := _x.uom_name; _row.wodata_scrap := 0; _row.wodata_notes := _x.wo_prodnotes; _row.wodata_level := _level; RETURN NEXT _row; IF (pshowmatl AND NOT pshowops) THEN --expand materials FOR _subrow IN SELECT * FROM indentedwomatl(pwoid, _level) LOOP RETURN NEXT _subrow; END LOOP; END IF; IF ((pshowmatl OR pshowindent) AND NOT pshowops) THEN --expand next level down FOR _subrow IN SELECT * FROM indentedwo(_x.wo_id, NULL, _level + 1, pshowmatl, pshowindent) LOOP RETURN NEXT _subrow; END LOOP; END IF; IF (pshowops) THEN --expand materials not on operations IF (pshowmatl) THEN FOR _subrow IN SELECT * FROM indentedwomatl(pwoid, -1, _level) LOOP RETURN NEXT _subrow; END LOOP; END IF; IF (pshowmatl OR pshowindent) THEN --expand next level down FOR _subrow IN SELECT * FROM indentedwo(_x.wo_id, -1, _level + 1, pshowmatl, pshowindent) LOOP RETURN NEXT _subrow; END LOOP; END IF; --expand opeartions FOR _opx IN SELECT * FROM xtmfg.indentedwoops(pwoid,_level) LOOP RETURN NEXT _opx; IF (pshowmatl) THEN --expand materials on operations FOR _subrow IN SELECT * FROM indentedwomatl(pwoid, _opx.wodata_id, _level + 1) LOOP RETURN NEXT _subrow; END LOOP; END IF; IF (pshowmatl OR pshowindent) THEN --expand next level down FOR _subrow IN SELECT * FROM indentedwo(_x.wo_id, _opx.wodata_id, _level + 2, pshowmatl, pshowindent) LOOP RETURN NEXT _subrow; END LOOP; END IF; END LOOP; END IF; END LOOP; RETURN; END; $_$; ALTER FUNCTION public.indentedwo(integer, boolean, boolean, boolean) OWNER TO admin; -- -- Name: indentedwo(integer, integer, integer, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION indentedwo(integer, integer, integer, boolean, boolean) RETURNS SETOF wodata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pwoid ALIAS FOR $1; pwooperid ALIAS FOR $2; plevel ALIAS FOR $3; pshowmatl ALIAS FOR $4; pshowindent ALIAS FOR $5; _row wodata%ROWTYPE; _opx wodata%ROWTYPE; _x RECORD; _subx RECORD; _index INTEGER; _level INTEGER; _qry TEXT; BEGIN --The wodata id column is used to indicate the source of the id --there are three different tables used wo, womatl and womatlvar --wodata_id_type = 1 = wo_id --wodata_id_type = 2 = womatl_id --wodata_id_type = 3 = wooper_id _level := (plevel + 1); --find all WO with the ordid of the next level up _qry := 'SELECT wo_id,wo_number,wo_subnumber,wo_status,wo_startdate,wo_duedate, wo_adhoc,wo_itemsite_id,qtyAvailable(itemsite_id) AS availableqoh,wo_qtyord,wo_qtyrcv, wo_prodnotes, item_number,item_descrip1, item_descrip2, item_listprice, uom_name, womatl_qtyiss, womatl_qtywipscrap, womatl_wooper_id FROM itemsite, wo, item, uom, womatl WHERE ((wo_ordid = ' || pwoid || ') AND (wo_ordtype = ''W'') AND (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (wo_womatl_id=womatl_id) AND (wo_itemsite_id = itemsite_id) '; IF (pwooperid IS NOT NULL) THEN _qry := _qry || ' AND (womatl_wooper_id=' || pwooperid || ') '; END IF; _qry := _qry || ') ORDER BY wo_number, wo_subnumber'; /* if (pwooperid IS NOT NULL) THEN raise exception 'stop %',_qry; END IF;*/ FOR _x IN EXECUTE _qry LOOP _row.wodata_id := _x.wo_id; _row.wodata_id_type := 1; _row.wodata_number := _x.wo_number; _row.wodata_subnumber := _x.wo_subnumber; _row.wodata_itemnumber := _x.item_number; _row.wodata_descrip := _x.item_descrip1 || '-' || _x.item_descrip2; _row.wodata_status := _x.wo_status; _row.wodata_startdate := _x.wo_startdate; _row.wodata_duedate := _x.wo_duedate; _row.wodata_adhoc := _x.wo_adhoc; _row.wodata_itemsite_id := _x.wo_itemsite_id; _row.wodata_custprice := _x.item_listprice; _row.wodata_listprice := _x.item_listprice; _row.wodata_qoh := _x.availableqoh; _row.wodata_short := noneg(_x.wo_qtyord - _x.wo_qtyrcv); _row.wodata_qtyiss := _x.womatl_qtyiss; _row.wodata_qtyrcv := _x.wo_qtyrcv; _row.wodata_qtyordreq := _x.wo_qtyord; _row.wodata_scrap := _x.womatl_qtywipscrap; _row.wodata_notes := _x.wo_prodnotes; _row.wodata_level := plevel; RETURN NEXT _row; --if indentation require expand next level IF (pshowindent AND pwooperid IS NULL) THEN IF (pshowmatl AND pshowindent) THEN --get materials for this level FOR _subx IN SELECT * FROM indentedwomatl(_x.wo_id, plevel) LOOP RETURN NEXT _subx; END LOOP; END IF; IF (pshowindent) THEN --expand lower levels FOR _subx IN SELECT * FROM indentedwo(_x.wo_id, NULL, _level, pshowmatl, pshowindent ) LOOP RETURN NEXT _subx; END LOOP; END IF; ELSIF (pshowindent) THEN --Handle operations --expand materials not on operations IF (pshowmatl) THEN FOR _subx IN SELECT * FROM indentedwomatl(_x.wo_id, -1, plevel) LOOP RETURN NEXT _subx; END LOOP; END IF; --expand next level down not on operations FOR _subx IN SELECT * FROM indentedwo(_x.wo_id, -1, _level, pshowmatl, pshowindent) LOOP RETURN NEXT _subx; END LOOP; --expand operations FOR _opx IN SELECT * FROM xtmfg.indentedwoops(_x.wo_id,plevel) LOOP RETURN NEXT _opx; IF (pshowmatl) THEN --expand materials on operations FOR _subx IN SELECT * FROM indentedwomatl(_x.wo_id, _opx.wodata_id, _level) LOOP RETURN NEXT _subx; -- raise exception 'stop %',_opx.wodata_id; END LOOP; END IF; --expand next level down FOR _subx IN SELECT * FROM indentedwo(_x.wo_id, _opx.wodata_id, _level + 2, pshowmatl, pshowindent) LOOP RETURN NEXT _subx; END LOOP; END LOOP; END IF; END LOOP; RETURN; END; $_$; ALTER FUNCTION public.indentedwo(integer, integer, integer, boolean, boolean) OWNER TO admin; -- -- Name: indentedwomatl(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION indentedwomatl(integer, integer) RETURNS SETOF wodata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pwoid ALIAS FOR $1; plevel ALIAS FOR $2; _subx RECORD; BEGIN FOR _subx IN SELECT * FROM indentedwomatl(pwoid, NULL::integer, plevel) LOOP RETURN NEXT _subx; END LOOP; RETURN; END; $_$; ALTER FUNCTION public.indentedwomatl(integer, integer) OWNER TO admin; -- -- Name: indentedwomatl(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION indentedwomatl(integer, integer, integer) RETURNS SETOF wodata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pwoid ALIAS FOR $1; pwooperid ALIAS FOR $2; plevel ALIAS FOR $3; _status TEXT; _subrow wodata%ROWTYPE; _subx RECORD; _level INTEGER; _qry TEXT; BEGIN --The wodata id column is used to indicate the source of the id --there are three different tables used wo, womatl and womatlvar --wodata_id_type = 1 = wo_id --wodata_id_type = 2 = womatl_id --wodata_id_type = 3 = wooper_id _qry := 'SELECT womatl_id, wo_number, wo_subnumber, wo_startdate, womatl_duedate, womatl_itemsite_id, qtyAvailable(itemsite_id) AS availableqoh, womatl_qtyreq, womatl_qtyiss, womatl_qtyper, womatl_qtyreq, womatl_qtywipscrap, womatl_ref, womatl_notes, womatl_price, item_listprice, item_number, item_descrip1, item_descrip2, uom_name FROM womatl, wo, itemsite, item, uom WHERE ((wo_id = womatl_wo_id) AND (wo_id = ' || pwoid || ') AND (womatl_itemsite_id = itemsite_id) AND (itemsite_item_id=item_id) AND (womatl_uom_id=uom_id) '; -- Need to display in case child w/o is deleted -- AND (NOT womatl_createwo OR womatl_createwo IS NULL) '; IF (pwooperid IS NOT NULL) THEN _qry := _qry || 'AND (womatl_wooper_id=' || pwooperid || ')'; END IF; _qry := _qry || ') ORDER BY item_number;'; _level := plevel + 1; SELECT wo_status FROM wo WHERE wo_id = pwoid LIMIT 1 INTO _status; FOR _subx IN EXECUTE _qry LOOP _subrow.wodata_id := _subx.womatl_id; _subrow.wodata_id_type := 2; _subrow.wodata_number := _subx.wo_number; _subrow.wodata_subnumber := _subx.wo_subnumber; _subrow.wodata_itemnumber := _subx.item_number; _subrow.wodata_descrip := _subx.item_descrip1 || '-' || _subx.item_descrip2; _subrow.wodata_status := _status; _subrow.wodata_startdate := _subx.wo_startdate; _subrow.wodata_duedate := _subx.womatl_duedate; _subrow.wodata_itemsite_id := _subx.womatl_itemsite_id; _subrow.wodata_custprice := _subx.womatl_price; _subrow.wodata_listprice := _subx.item_listprice; _subrow.wodata_qoh := _subx.availableqoh; IF((_subx.availableqoh > (_subx.womatl_qtyreq - _subx.womatl_qtyiss))) THEN _subrow.wodata_short := 0; ELSE _subrow.wodata_short := (_subx.womatl_qtyreq - _subx.womatl_qtyiss) - _subx.availableqoh; END IF; _subrow.wodata_qtyper := _subx.womatl_qtyper; _subrow.wodata_qtyiss := _subx.womatl_qtyiss; _subrow.wodata_qtyordreq := _subx.womatl_qtyreq; _subrow.wodata_qtyuom := _subx.uom_name; _subrow.wodata_scrap := _subx.womatl_qtywipscrap; _subrow.wodata_notes := _subx.womatl_notes; _subrow.wodata_ref := _subx.womatl_ref; _subrow.wodata_level := _level; RETURN NEXT _subrow; END LOOP; RETURN; END; $_$; ALTER FUNCTION public.indentedwomatl(integer, integer, integer) OWNER TO admin; -- -- Name: initeffectivextuser(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION initeffectivextuser() RETURNS void LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Effective users use a temporary table to store the user information -- and this function, called by the other functions, makes sure the temp -- tables exist first. PERFORM * FROM pg_catalog.pg_class WHERE relname = 'effective_user' AND relnamespace = pg_catalog.pg_my_temp_schema(); IF NOT FOUND THEN CREATE TEMPORARY TABLE effective_user ( effective_key TEXT, effective_value TEXT ); CREATE UNIQUE INDEX effective_user_pkey ON effective_user (effective_key); END IF; END; $$; ALTER FUNCTION public.initeffectivextuser() OWNER TO admin; -- -- Name: initialdistribution(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION initialdistribution(pitemsiteid integer, plocationid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _itemlocid INTEGER; _invhistid INTEGER; _itemlocSeries INTEGER; _r RECORD; BEGIN -- Make sure the passed itemsite points to a real item IF ( (SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J') FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ) ) ) THEN RETURN 0; END IF; _itemlocSeries := NEXTVAL('itemloc_series_seq'); -- Reassign the location_id for all existing itemlocs if -- the passed itemsite is already lot/serial controlled IF ( ( SELECT (itemsite_controlmethod IN ('L', 'S')) FROM itemsite WHERE (itemsite_id=pItemsiteid) ) ) THEN FOR _r IN SELECT itemloc_id, itemloc_ls_id, itemloc_qty FROM itemloc WHERE (itemloc_itemsite_id=pItemsiteid) LOOP -- Create the RL transaction SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid; INSERT INTO invhist ( invhist_id, invhist_itemsite_id, invhist_series, invhist_transtype, invhist_invqty, invhist_qoh_before, invhist_qoh_after, invhist_comments, invhist_invuom, invhist_unitcost, invhist_hasdetail, invhist_costmethod, invhist_value_before, invhist_value_after ) SELECT _invhistid, itemsite_id, _itemlocSeries, 'RL', 0, _r.itemloc_qty, _r.itemloc_qty, 'Initial Distribution', uom_name, stdCost(item_id), TRUE, itemsite_costmethod, itemsite_value, itemsite_value FROM item, itemsite, uom WHERE ( (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (itemsite_controlmethod <> 'N') AND (itemsite_id=pItemsiteid) ); -- Update the itemloc UPDATE itemloc SET itemloc_location_id=pLocationid WHERE (itemloc_id=_r.itemloc_id); -- Record the detail transaction INSERT INTO invdetail ( invdetail_invhist_id, invdetail_location_id, invdetail_ls_id, invdetail_qty, invdetail_qty_before, invdetail_qty_after ) VALUES ( _invhistid, pLocationid, _r.itemloc_ls_id, _r.itemloc_qty, 0, _r.itemloc_qty ); END LOOP; ELSE -- The passed itemsite is not lot/serial controlled -- Make sure that there are not any stagnent itemlocs DELETE FROM itemloc WHERE (itemloc_itemsite_id=pItemsiteid); -- Create the RL transaction SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid; INSERT INTO invhist ( invhist_id, invhist_itemsite_id, invhist_series, invhist_transtype, invhist_invqty, invhist_qoh_before, invhist_qoh_after, invhist_comments, invhist_invuom, invhist_unitcost, invhist_hasdetail, invhist_costmethod, invhist_value_before, invhist_value_after ) SELECT _invhistid, itemsite_id, _itemlocSeries, 'RL', 0, itemsite_qtyonhand, itemsite_qtyonhand, 'Initial Distribution', uom_name, stdCost(item_id), TRUE, itemsite_costmethod, itemsite_value, itemsite_value FROM item, itemsite, uom WHERE ( (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (itemsite_controlmethod <> 'N') AND (itemsite_id=pItemsiteid) ); -- Create the itemloc SELECT NEXTVAL('itemloc_itemloc_id_seq') INTO _itemlocid; INSERT INTO itemloc ( itemloc_id, itemloc_itemsite_id, itemloc_location_id, itemloc_expiration, itemloc_qty ) SELECT _itemlocid, itemsite_id, pLocationid, endOfTime(), itemsite_qtyonhand FROM itemsite WHERE (itemsite_id=pItemsiteid); -- Record the detail transaction INSERT INTO invdetail ( invdetail_invhist_id, invdetail_location_id, invdetail_qty, invdetail_qty_before, invdetail_qty_after ) SELECT _invhistid, pLocationid, itemsite_qtyonhand, 0, itemsite_qtyonhand FROM itemsite WHERE (itemsite_id=pItemsiteid); END IF; RETURN _itemlocid; END; $$; ALTER FUNCTION public.initialdistribution(pitemsiteid integer, plocationid integer) OWNER TO admin; -- -- Name: apopen; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE apopen ( apopen_id integer DEFAULT nextval(('"apopen_apopen_id_seq"'::text)::regclass) NOT NULL, apopen_docdate date, apopen_duedate date, apopen_terms_id integer, apopen_vend_id integer, apopen_doctype character(1), apopen_docnumber text, apopen_amount numeric(20,2), apopen_notes text, apopen_posted boolean, apopen_reference text, apopen_invcnumber text, apopen_ponumber text, apopen_journalnumber integer, apopen_paid numeric(20,2) DEFAULT 0, apopen_open boolean, apopen_username text, apopen_discount boolean DEFAULT false NOT NULL, apopen_accnt_id integer DEFAULT (-1), apopen_curr_id integer DEFAULT basecurrid(), apopen_closedate date, apopen_distdate date, apopen_void boolean DEFAULT false NOT NULL, apopen_curr_rate numeric NOT NULL, apopen_discountable_amount numeric(20,2) DEFAULT 0, apopen_status text, CONSTRAINT apopen_apopen_status_check CHECK ((((apopen_status = 'O'::text) OR (apopen_status = 'H'::text)) OR (apopen_status = 'C'::text))), CONSTRAINT apopen_apopen_status_notnull CHECK ((apopen_status IS NOT NULL)) ); ALTER TABLE apopen OWNER TO admin; -- -- Name: TABLE apopen; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE apopen IS 'Accounts Payable (A/P) open Items information'; -- -- Name: curr_symbol; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE curr_symbol ( curr_id integer NOT NULL, curr_base boolean DEFAULT false NOT NULL, curr_name character varying(50) NOT NULL, curr_symbol character varying(9) NOT NULL, curr_abbr character varying(3) NOT NULL ); ALTER TABLE curr_symbol OWNER TO admin; -- -- Name: TABLE curr_symbol; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE curr_symbol IS 'Currency Names, Symbols, and Abbreviations'; -- -- Name: terms; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE terms ( terms_id integer DEFAULT nextval(('terms_terms_id_seq'::text)::regclass) NOT NULL, terms_code text NOT NULL, terms_descrip text, terms_type character(1), terms_duedays integer, terms_discdays integer, terms_discprcnt numeric(10,6), terms_cutoffday integer, terms_ap boolean, terms_ar boolean, terms_fincharg boolean DEFAULT true NOT NULL, CONSTRAINT terms_terms_code_check CHECK ((terms_code <> ''::text)) ); ALTER TABLE terms OWNER TO admin; -- -- Name: TABLE terms; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE terms IS 'Billing Terms information'; -- -- Name: vendinfo; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE vendinfo ( vend_id integer DEFAULT nextval(('vend_vend_id_seq'::text)::regclass) NOT NULL, vend_name text, vend_lastpurchdate date, vend_active boolean, vend_po boolean, vend_comments text, vend_pocomments text, vend_number text NOT NULL, vend_1099 boolean, vend_exported boolean, vend_fobsource character(1), vend_fob text, vend_terms_id integer, vend_shipvia text, vend_vendtype_id integer, vend_qualified boolean, vend_ediemail text, vend_ediemailbody text, vend_edisubject text, vend_edifilename text, vend_accntnum text, vend_emailpodelivery boolean, vend_restrictpurch boolean, vend_edicc text, vend_curr_id integer DEFAULT basecurrid(), vend_cntct1_id integer, vend_cntct2_id integer, vend_addr_id integer, vend_match boolean DEFAULT false NOT NULL, vend_ach_enabled boolean DEFAULT false NOT NULL, vend_ach_accnttype text, vend_ach_use_vendinfo boolean DEFAULT true NOT NULL, vend_ach_indiv_number text DEFAULT ''::text NOT NULL, vend_ach_indiv_name text DEFAULT ''::text NOT NULL, vend_ediemailhtml boolean DEFAULT false NOT NULL, vend_ach_routingnumber bytea DEFAULT '\x00'::bytea NOT NULL, vend_ach_accntnumber bytea DEFAULT '\x00'::bytea NOT NULL, vend_taxzone_id integer, vend_accnt_id integer, vend_expcat_id integer DEFAULT (-1), vend_tax_id integer DEFAULT (-1), CONSTRAINT vendinfo_vend_ach_accnttype_check CHECK (((vend_ach_accnttype = 'K'::text) OR (vend_ach_accnttype = 'C'::text))), CONSTRAINT vendinfo_vend_number_check CHECK ((vend_number <> ''::text)) ); ALTER TABLE vendinfo OWNER TO admin; -- -- Name: TABLE vendinfo; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE vendinfo IS 'Vendor information'; -- -- Name: COLUMN vendinfo.vend_ach_accnttype; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN vendinfo.vend_ach_accnttype IS 'Type of bank account: K = checKing, C = Cash = savings. These values were chosen to be consistent with bankaccnt_type.'; SET search_path = api, pg_catalog; -- -- Name: apmemo; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW apmemo AS SELECT vendinfo.vend_number AS vendor_number, apopen.apopen_docdate AS document_date, apopen.apopen_duedate AS due_date, CASE WHEN (apopen.apopen_doctype = 'C'::bpchar) THEN 'Credit Memo'::text ELSE 'Debit Memo'::text END AS document_type, apopen.apopen_docnumber AS document_number, apopen.apopen_ponumber AS po_number, apopen.apopen_journalnumber AS journal_number, terms.terms_code AS terms, curr.curr_abbr AS currency, apopen.apopen_amount AS amount, apopen.apopen_paid AS paid, (apopen.apopen_amount - apopen.apopen_paid) AS balance, apopen.apopen_notes AS notes, CASE WHEN (apopen.apopen_accnt_id = (-1)) THEN NULL::text ELSE public.formatglaccount(apopen.apopen_accnt_id) END AS alternate_prepaid_account FROM (((public.apopen LEFT JOIN public.vendinfo ON ((vendinfo.vend_id = apopen.apopen_vend_id))) LEFT JOIN public.curr_symbol curr ON ((curr.curr_id = apopen.apopen_curr_id))) LEFT JOIN public.terms ON ((terms.terms_id = apopen.apopen_terms_id))) WHERE (apopen.apopen_doctype = ANY (ARRAY['C'::bpchar, 'D'::bpchar])); ALTER TABLE apmemo OWNER TO admin; -- -- Name: VIEW apmemo; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW apmemo IS 'A/P Credit and Debit Memo'; SET search_path = public, pg_catalog; -- -- Name: insertapmemo(api.apmemo); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION insertapmemo(api.apmemo) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNew ALIAS FOR $1; _result INTEGER; BEGIN IF (pNew.document_type = 'Credit Memo') THEN SELECT createAPCreditMemo( getVendId(pNew.vendor_number), pNew.document_number, pNew.po_number, pNew.document_date, pNew.amount, pNew.notes, getGLAccntId(pNew.alternate_prepaid_account), pNew.due_date, getTermsId(pNew.terms) ) INTO _result; IF (_result <= 0) THEN RAISE EXCEPTION 'Function createAPCreditMemo failed with result = %', _result; END IF; ELSE IF (pNew.document_type = 'Debit Memo') THEN SELECT createAPDebitMemo( null, getVendId(pNew.vendor_number), pNew.journal_number, pNew.document_number, pNew.po_number, pNew.document_date, pNew.amount, pNew.notes, getGLAccntId(pNew.alternate_prepaid_account), pNew.due_date, getTermsId(pNew.terms), COALESCE(getCurrId(pNew.currency), baseCurrId()) ) INTO _result; IF (_result <= 0) THEN RAISE EXCEPTION 'Function createAPDebitMemo failed with result = %', _result; END IF; ELSE RAISE EXCEPTION 'Function insertAPMemo failed, invalid Document Type'; END IF; END IF; RETURN TRUE; END; $_$; ALTER FUNCTION public.insertapmemo(api.apmemo) OWNER TO admin; -- -- Name: aropen; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE aropen ( aropen_id integer DEFAULT nextval(('"aropen_aropen_id_seq"'::text)::regclass) NOT NULL, aropen_docdate date NOT NULL, aropen_duedate date NOT NULL, aropen_terms_id integer, aropen_cust_id integer, aropen_doctype character(1), aropen_docnumber text, aropen_applyto text, aropen_ponumber text, aropen_amount numeric(20,2) NOT NULL, aropen_notes text, aropen_posted boolean DEFAULT false NOT NULL, aropen_salesrep_id integer, aropen_commission_due numeric(20,2), aropen_commission_paid boolean DEFAULT false, aropen_ordernumber text, aropen_cobmisc_id integer DEFAULT (-1), aropen_journalnumber integer, aropen_paid numeric(20,2) DEFAULT 0, aropen_open boolean, aropen_username text, aropen_rsncode_id integer, aropen_salescat_id integer DEFAULT (-1), aropen_accnt_id integer DEFAULT (-1), aropen_curr_id integer DEFAULT basecurrid(), aropen_closedate date, aropen_distdate date, aropen_curr_rate numeric NOT NULL, aropen_discount boolean DEFAULT false NOT NULL, aropen_fincharg_date date, aropen_fincharg_amount numeric(20,2) ); ALTER TABLE aropen OWNER TO admin; -- -- Name: TABLE aropen; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE aropen IS 'Accounts Receivable (A/R) open Items information'; -- -- Name: custinfo; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE custinfo ( cust_id integer DEFAULT nextval(('cust_cust_id_seq'::text)::regclass) NOT NULL, cust_active boolean NOT NULL, cust_custtype_id integer, cust_salesrep_id integer, cust_commprcnt numeric(10,6), cust_name text, cust_creditlmt integer, cust_creditrating text, cust_financecharge boolean, cust_backorder boolean NOT NULL, cust_partialship boolean NOT NULL, cust_terms_id integer, cust_discntprcnt numeric(10,6) NOT NULL, cust_balmethod character(1) NOT NULL, cust_ffshipto boolean NOT NULL, cust_shipform_id integer, cust_shipvia text, cust_blanketpos boolean NOT NULL, cust_shipchrg_id integer NOT NULL, cust_creditstatus character(1) NOT NULL, cust_comments text, cust_ffbillto boolean NOT NULL, cust_usespos boolean NOT NULL, cust_number text NOT NULL, cust_dateadded date DEFAULT ('now'::text)::date, cust_exported boolean DEFAULT false, cust_emaildelivery boolean DEFAULT false, cust_ediemail text, cust_edisubject text, cust_edifilename text, cust_ediemailbody text, cust_autoupdatestatus boolean NOT NULL, cust_autoholdorders boolean NOT NULL, cust_edicc text, cust_ediprofile_id integer, cust_preferred_warehous_id integer DEFAULT (-1) NOT NULL, cust_curr_id integer DEFAULT basecurrid(), cust_creditlmt_curr_id integer DEFAULT basecurrid(), cust_cntct_id integer, cust_corrcntct_id integer, cust_soemaildelivery boolean DEFAULT false, cust_soediemail text, cust_soedisubject text, cust_soedifilename text, cust_soediemailbody text, cust_soedicc text, cust_soediprofile_id integer, cust_gracedays integer, cust_ediemailhtml boolean DEFAULT false NOT NULL, cust_soediemailhtml boolean DEFAULT false NOT NULL, cust_taxzone_id integer, cust_statementcycle text, CONSTRAINT custinfo_balmethod_check CHECK (((cust_balmethod = 'B'::bpchar) OR (cust_balmethod = 'O'::bpchar))), CONSTRAINT custinfo_creditstatus_check CHECK ((((cust_creditstatus = 'G'::bpchar) OR (cust_creditstatus = 'W'::bpchar)) OR (cust_creditstatus = 'H'::bpchar))), CONSTRAINT custinfo_cust_number_check CHECK ((cust_number <> ''::text)) ); ALTER TABLE custinfo OWNER TO admin; -- -- Name: TABLE custinfo; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE custinfo IS 'Customer information'; -- -- Name: COLUMN custinfo.cust_ediemail; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN custinfo.cust_ediemail IS 'Deprecated column - DO NOT USE'; -- -- Name: COLUMN custinfo.cust_edisubject; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN custinfo.cust_edisubject IS 'Deprecated column - DO NOT USE'; -- -- Name: COLUMN custinfo.cust_edifilename; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN custinfo.cust_edifilename IS 'Deprecated column - DO NOT USE'; -- -- Name: COLUMN custinfo.cust_ediemailbody; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN custinfo.cust_ediemailbody IS 'Deprecated column - DO NOT USE'; -- -- Name: COLUMN custinfo.cust_edicc; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN custinfo.cust_edicc IS 'Deprecated column - DO NOT USE'; -- -- Name: COLUMN custinfo.cust_ediprofile_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN custinfo.cust_ediprofile_id IS 'Deprecated column - DO NOT USE'; -- -- Name: COLUMN custinfo.cust_soediemail; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN custinfo.cust_soediemail IS 'Deprecated column - DO NOT USE'; -- -- Name: COLUMN custinfo.cust_soedisubject; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN custinfo.cust_soedisubject IS 'Deprecated column - DO NOT USE'; -- -- Name: COLUMN custinfo.cust_soedifilename; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN custinfo.cust_soedifilename IS 'Deprecated column - DO NOT USE'; -- -- Name: COLUMN custinfo.cust_soediemailbody; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN custinfo.cust_soediemailbody IS 'Deprecated column - DO NOT USE'; -- -- Name: COLUMN custinfo.cust_soedicc; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN custinfo.cust_soedicc IS 'Deprecated column - DO NOT USE'; -- -- Name: COLUMN custinfo.cust_soediprofile_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN custinfo.cust_soediprofile_id IS 'Deprecated column - DO NOT USE'; -- -- Name: COLUMN custinfo.cust_ediemailhtml; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN custinfo.cust_ediemailhtml IS 'Deprecated column - DO NOT USE'; -- -- Name: COLUMN custinfo.cust_soediemailhtml; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN custinfo.cust_soediemailhtml IS 'Deprecated column - DO NOT USE'; -- -- Name: rsncode; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE rsncode ( rsncode_id integer NOT NULL, rsncode_code text NOT NULL, rsncode_descrip text, rsncode_doctype text, CONSTRAINT rsncode_rsncode_code_check CHECK ((rsncode_code <> ''::text)) ); ALTER TABLE rsncode OWNER TO admin; -- -- Name: TABLE rsncode; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE rsncode IS 'Debit/Credit Memo Reason Code information'; -- -- Name: salescat; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE salescat ( salescat_id integer NOT NULL, salescat_active boolean, salescat_name text NOT NULL, salescat_descrip text, salescat_sales_accnt_id integer, salescat_prepaid_accnt_id integer, salescat_ar_accnt_id integer, CONSTRAINT salescat_salescat_name_check CHECK ((salescat_name <> ''::text)) ); ALTER TABLE salescat OWNER TO admin; -- -- Name: TABLE salescat; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE salescat IS 'Sales Category information'; -- -- Name: salesrep; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE salesrep ( salesrep_id integer DEFAULT nextval(('salesrep_salesrep_id_seq'::text)::regclass) NOT NULL, salesrep_active boolean, salesrep_number text NOT NULL, salesrep_name text, salesrep_commission numeric(8,4), salesrep_method character(1), salesrep_emp_id integer, CONSTRAINT salesrep_salesrep_number_check CHECK ((salesrep_number <> ''::text)) ); ALTER TABLE salesrep OWNER TO admin; -- -- Name: TABLE salesrep; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE salesrep IS 'Sales Representative information'; -- -- Name: COLUMN salesrep.salesrep_emp_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN salesrep.salesrep_emp_id IS 'DEPRECATED - the relationship between Sales Rep and Employee is now maintained through the crmacct table.'; SET search_path = api, pg_catalog; -- -- Name: armemo; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW armemo AS SELECT custinfo.cust_number AS customer_number, aropen.aropen_docdate AS document_date, aropen.aropen_duedate AS due_date, CASE WHEN (aropen.aropen_doctype = 'C'::bpchar) THEN 'Credit Memo'::text ELSE 'Debit Memo'::text END AS document_type, aropen.aropen_docnumber AS document_number, aropen.aropen_applyto AS order_number, aropen.aropen_journalnumber AS journal_number, rsncode.rsncode_code AS reason_code, terms.terms_code AS terms, salesrep.salesrep_number AS sales_rep, curr.curr_abbr AS currency, aropen.aropen_amount AS amount, aropen.aropen_paid AS paid, (aropen.aropen_amount - aropen.aropen_paid) AS balance, aropen.aropen_commission_due AS commission_due, aropen.aropen_commission_paid AS commission_paid, aropen.aropen_notes AS notes, salescat.salescat_name AS alternate_prepaid_sales_category, CASE WHEN (aropen.aropen_accnt_id = (-1)) THEN NULL::text ELSE public.formatglaccount(aropen.aropen_accnt_id) END AS alternate_prepaid_account FROM ((((((public.aropen LEFT JOIN public.custinfo ON ((custinfo.cust_id = aropen.aropen_cust_id))) LEFT JOIN public.curr_symbol curr ON ((curr.curr_id = aropen.aropen_curr_id))) LEFT JOIN public.salesrep ON ((salesrep.salesrep_id = aropen.aropen_salesrep_id))) LEFT JOIN public.terms ON ((terms.terms_id = aropen.aropen_terms_id))) LEFT JOIN public.salescat ON ((salescat.salescat_id = aropen.aropen_salescat_id))) LEFT JOIN public.rsncode ON ((rsncode.rsncode_id = aropen.aropen_rsncode_id))) WHERE (aropen.aropen_doctype = ANY (ARRAY['C'::bpchar, 'D'::bpchar])); ALTER TABLE armemo OWNER TO admin; -- -- Name: VIEW armemo; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW armemo IS 'A/R Credit and Debit Memo'; SET search_path = public, pg_catalog; -- -- Name: insertarmemo(api.armemo); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION insertarmemo(api.armemo) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNew ALIAS FOR $1; _result INTEGER; BEGIN IF (pNew.document_type = 'Credit Memo') THEN SELECT createARCreditMemo( NULL, getCustId(pNew.customer_number), pNew.document_number, pNew.order_number, pNew.document_date, pNew.amount, pNew.notes, getRsnId(pNew.reason_code), getSalescatId(pNew.alternate_prepaid_sales_category), getGLAccntId(pNew.alternate_prepaid_account), pNew.due_date, getTermsId(pNew.terms), getSalesrepId(pNew.sales_rep), pNew.commission_due, pNew.journal_number, COALESCE(getCurrId(pNew.currency), baseCurrId()) ) INTO _result; IF (_result <= 0) THEN RAISE EXCEPTION 'Function createARCreditMemo failed with result = %', _result; END IF; ELSE IF (pNew.document_type = 'Debit Memo') THEN SELECT createARDebitMemo( null, getCustId(pNew.customer_number), pNew.journal_number, pNew.document_number, pNew.order_number, pNew.document_date, pNew.amount, pNew.notes, getRsnId(pNew.reason_code), getSalescatId(pNew.alternate_prepaid_sales_category), getGLAccntId(pNew.alternate_prepaid_account), pNew.due_date, getTermsId(pNew.terms), getSalesrepId(pNew.sales_rep), pNew.commission_due, COALESCE(getCurrId(pNew.currency), baseCurrId()) ) INTO _result; IF (_result <= 0) THEN RAISE EXCEPTION 'Function createARDebitMemo failed with result = %', _result; END IF; ELSE RAISE EXCEPTION 'Function insertARMemo failed, invalid Document Type'; END IF; END IF; RETURN TRUE; END; $_$; ALTER FUNCTION public.insertarmemo(api.armemo) OWNER TO admin; -- -- Name: insertccard(text, boolean, text, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION insertccard(text, boolean, text, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustomer ALIAS FOR $1; pActive ALIAS FOR $2; pType ALIAS FOR $3; pNumber ALIAS FOR $4; pName ALIAS FOR $5; pAddr1 ALIAS FOR $6; pAddr2 ALIAS FOR $7; pCity ALIAS FOR $8; pState ALIAS FOR $9; pPostal ALIAS FOR $10; pCountry ALIAS FOR $11; pMonth ALIAS FOR $12; pYear ALIAS FOR $13; pKey ALIAS FOR $14; _type CHAR; _number TEXT; _month INTEGER; _year INTEGER; _result INTEGER; BEGIN --Initialize _number = CAST(encode(pNumber, 'escape') AS text); _month = CAST(encode(pMonth, 'escape') AS integer); _year = CAST(encode(pYear, 'escape') AS integer); -- Check Card holder info IF (pName IS NULL) THEN RAISE EXCEPTION 'The name of the card holder must be entered'; END IF; IF (pAddr1 IS NULL OR pAddr1 = '') THEN RAISE EXCEPTION 'The first address line must be entered'; END IF; IF (pCity IS NULL OR pCity = '') THEN RAISE EXCEPTION 'The city must be entered'; END IF; IF (pState IS NULL OR pState = '') THEN RAISE EXCEPTION 'The state must be entered'; END IF; IF (pPostal IS NULL OR pPostal = '') THEN RAISE EXCEPTION 'The zip code must be entered'; END IF; IF (pCountry IS NULL OR pCountry = '') THEN RAISE EXCEPTION 'The country must be entered'; END IF; IF (pMonth IS NULL OR pMonth = '') THEN RAISE EXCEPTION 'The Expiration Month must be entered'; END IF; IF (_month < 1 OR _month > 12) THEN RAISE EXCEPTION 'Valid Expiration Months are 01 through 12'; END IF; IF (LENGTH(_year::text) <> 4) THEN RAISE EXCEPTION 'Valid Expiration Years are CCYY in format'; END IF; IF (_year < 1970 OR _year > 2100) THEN RAISE EXCEPTION 'Valid Expiration Years are 1970 through 2100'; END IF; -- Check Number Length IF ((NOT _number ~ '[0-9]{13,16}') OR (LENGTH(_number) = 14) OR (LENGTH(_number) > 16)) THEN RAISE EXCEPTION 'The credit card number must be all numeric (no spaces or hyphens) and must be 13, 15 or 16 characters in length'; END IF; -- Convert Type IF (pType = 'Visa') THEN _type = 'V'; ELSE IF (pType = 'Master Card') THEN _type = 'M'; ELSE IF (pType = 'American Express') THEN _type = 'A'; ELSE IF (pType = 'Discover') THEN _type = 'D'; ELSE RAISE EXCEPTION 'You must select Master Card, Visa, American Express or Discover as the credit card type.'; END IF; END IF; END IF; END IF; -- Check Card Specific Data SELECT editccnumber(_number, _type) INTO _result; IF (_result = -1) THEN RAISE EXCEPTION 'You must select Master Card, Visa, American Express or Discover as the credit card type.'; END IF; IF (_result = -2) THEN RAISE EXCEPTION 'The length of a Master Card credit card number has to be 16 digits.'; END IF; IF (_result = -3) THEN RAISE EXCEPTION 'The length of a Visa credit card number has to be either 13 or 16 digits.'; END IF; IF (_result = -4) THEN RAISE EXCEPTION 'The length of an American Express credit card number has to be 15 digits.'; END IF; IF (_result = -5) THEN RAISE EXCEPTION 'The length of a Discover credit card number has to be 16 digits.'; END IF; IF (_result = -6) THEN RAISE EXCEPTION 'The first two digits for a valid Master Card number must be between 51 and 55'; END IF; IF (_result = -7) THEN RAISE EXCEPTION 'The first digit for a valid Visa number must be 4'; END IF; IF (_result = -8) THEN RAISE EXCEPTION 'The first two digits for a valid American Express number must be 34 or 37.'; END IF; IF (_result = -9) THEN RAISE EXCEPTION 'The first four digits for a valid Discover Express number must be 6011.'; END IF; IF ((_result = -10) AND NOT fetchmetricbool('CCTest')) THEN RAISE EXCEPTION 'The credit card number that you have provided is not valid.'; END IF; IF (_result < -10) THEN RAISE EXCEPTION 'Invalid Credit Card Information'; END IF; -- Insert Record INSERT INTO ccard ( ccard_seq, ccard_cust_id, ccard_active, ccard_name, ccard_address1, ccard_address2, ccard_city, ccard_state, ccard_zip, ccard_country, ccard_number, ccard_month_expired, ccard_year_expired, ccard_type) VALUES ((SELECT COALESCE(MAX(ccard_seq), 0) + 10 FROM ccard WHERE (ccard_cust_id =getCustId(pCustomer))), getCustId(pCustomer), COALESCE(pActive), encrypt(setbytea(pName), setbytea(pKey), 'bf'), encrypt(setbytea(pAddr1), setbytea(pKey), 'bf'), encrypt(setbytea(pAddr2), setbytea(pKey), 'bf'), encrypt(setbytea(pCity), setbytea(pKey), 'bf'), encrypt(setbytea(pState), setbytea(pKey), 'bf'), encrypt(setbytea(pPostal), setbytea(pKey), 'bf'), encrypt(setbytea(pCountry), setbytea(pKey), 'bf'), encrypt(setbytea(pNumber), setbytea(pKey), 'bf'), encrypt(setbytea(pMonth), setbytea(pKey), 'bf'), encrypt(setbytea(pYear), setbytea(pKey), 'bf'), _type ); RETURN true; END; $_$; ALTER FUNCTION public.insertccard(text, boolean, text, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, text) OWNER TO admin; -- -- Name: FUNCTION insertccard(text, boolean, text, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, text); Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON FUNCTION insertccard(text, boolean, text, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, text) IS 'This function is generally used to support the _custcreditcard API view'; -- -- Name: cmhead; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cmhead ( cmhead_id integer DEFAULT nextval(('cmhead_cmhead_id_seq'::text)::regclass) NOT NULL, cmhead_number text NOT NULL, cmhead_posted boolean, cmhead_invcnumber text, cmhead_custponumber text, cmhead_cust_id integer, cmhead_docdate date, cmhead_shipto_id integer, cmhead_shipto_name text, cmhead_shipto_address1 text, cmhead_shipto_address2 text, cmhead_shipto_address3 text, cmhead_shipto_city text, cmhead_shipto_state text, cmhead_shipto_zipcode text, cmhead_salesrep_id integer, cmhead_freight numeric(16,4), cmhead_misc numeric(16,4), cmhead_comments text, cmhead_printed boolean, cmhead_billtoname text, cmhead_billtoaddress1 text, cmhead_billtoaddress2 text, cmhead_billtoaddress3 text, cmhead_billtocity text, cmhead_billtostate text, cmhead_billtozip text, cmhead_hold boolean, cmhead_commission numeric(8,4), cmhead_misc_accnt_id integer, cmhead_misc_descrip text, cmhead_rsncode_id integer, cmhead_curr_id integer DEFAULT basecurrid(), cmhead_freighttaxtype_id integer, cmhead_gldistdate date, cmhead_billtocountry text, cmhead_shipto_country text, cmhead_rahead_id integer, cmhead_taxzone_id integer, cmhead_prj_id integer, cmhead_void boolean DEFAULT false, cmhead_saletype_id integer, cmhead_shipzone_id integer, CONSTRAINT cmhead_cmhead_number_check CHECK ((cmhead_number <> ''::text)) ); ALTER TABLE cmhead OWNER TO admin; -- -- Name: TABLE cmhead; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE cmhead IS 'S/O Credit Memo header information'; -- -- Name: COLUMN cmhead.cmhead_freighttaxtype_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN cmhead.cmhead_freighttaxtype_id IS 'Deprecated column - DO NOT USE'; -- -- Name: COLUMN cmhead.cmhead_saletype_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN cmhead.cmhead_saletype_id IS 'Associated sale type for credit memo.'; -- -- Name: COLUMN cmhead.cmhead_shipzone_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN cmhead.cmhead_shipzone_id IS 'Associated shipping zone for credit memo.'; -- -- Name: shiptoinfo; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE shiptoinfo ( shipto_id integer DEFAULT nextval(('shipto_shipto_id_seq'::text)::regclass) NOT NULL, shipto_cust_id integer NOT NULL, shipto_name text, shipto_salesrep_id integer, shipto_comments text, shipto_shipcomments text, shipto_shipzone_id integer, shipto_shipvia text, shipto_commission numeric(10,4) NOT NULL, shipto_shipform_id integer, shipto_shipchrg_id integer, shipto_active boolean NOT NULL, shipto_default boolean, shipto_num text, shipto_ediprofile_id integer, shipto_cntct_id integer, shipto_addr_id integer, shipto_taxzone_id integer, shipto_preferred_warehous_id integer DEFAULT (-1) NOT NULL ); ALTER TABLE shiptoinfo OWNER TO admin; -- -- Name: TABLE shiptoinfo; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE shiptoinfo IS 'Ship-To information'; -- -- Name: COLUMN shiptoinfo.shipto_ediprofile_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN shiptoinfo.shipto_ediprofile_id IS 'Deprecated column - DO NOT USE'; -- -- Name: taxzone; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE taxzone ( taxzone_id integer NOT NULL, taxzone_code text NOT NULL, taxzone_descrip text, CONSTRAINT taxzone_taxzone_code_check CHECK ((taxzone_code <> ''::text)) ); ALTER TABLE taxzone OWNER TO admin; -- -- Name: TABLE taxzone; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE taxzone IS 'Tax zone information'; -- -- Name: COLUMN taxzone.taxzone_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxzone.taxzone_id IS 'Primary key'; -- -- Name: COLUMN taxzone.taxzone_code; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxzone.taxzone_code IS 'Code'; -- -- Name: COLUMN taxzone.taxzone_descrip; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxzone.taxzone_descrip IS 'Description'; SET search_path = api, pg_catalog; -- -- Name: creditmemo; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW creditmemo AS SELECT cmhead.cmhead_number AS memo_number, CASE WHEN (cmhead.cmhead_invcnumber = '-1'::text) THEN ''::text ELSE cmhead.cmhead_invcnumber END AS apply_to, cmhead.cmhead_docdate AS memo_date, CASE WHEN cmhead.cmhead_posted THEN 'Posted'::text ELSE 'Unposted'::text END AS status, salesrep.salesrep_number AS sales_rep, cmhead.cmhead_commission AS commission, COALESCE(taxzone.taxzone_code, 'None'::text) AS tax_zone, COALESCE(rsncode.rsncode_code, 'None'::text) AS reason_code, cmhead.cmhead_hold AS on_hold, custinfo.cust_number AS customer_number, cmhead.cmhead_billtoname AS billto_name, cmhead.cmhead_billtoaddress1 AS billto_address1, cmhead.cmhead_billtoaddress2 AS billto_address2, cmhead.cmhead_billtoaddress3 AS billto_address3, cmhead.cmhead_billtocity AS billto_city, cmhead.cmhead_billtostate AS billto_state, cmhead.cmhead_billtozip AS billto_postal_code, cmhead.cmhead_billtocountry AS billto_country, shiptoinfo.shipto_num AS shipto_number, cmhead.cmhead_shipto_name AS shipto_name, cmhead.cmhead_shipto_address1 AS shipto_address1, cmhead.cmhead_shipto_address2 AS shipto_address2, cmhead.cmhead_shipto_address3 AS shipto_address3, cmhead.cmhead_shipto_city AS shipto_city, cmhead.cmhead_shipto_state AS shipto_state, cmhead.cmhead_shipto_zipcode AS shipto_postal_code, cmhead.cmhead_shipto_country AS shipto_country, cmhead.cmhead_custponumber AS customer_po_number, cmhead.cmhead_comments AS notes, curr.curr_abbr AS currency, cmhead.cmhead_misc_descrip AS misc_charge_description, cmhead.cmhead_misc AS misc_charge_amount, CASE WHEN (cmhead.cmhead_misc_accnt_id = (-1)) THEN ''::text ELSE public.formatglaccount(cmhead.cmhead_misc_accnt_id) END AS misc_charge_credit_account, cmhead.cmhead_freight AS freight FROM ((((((public.cmhead LEFT JOIN public.custinfo ON ((custinfo.cust_id = cmhead.cmhead_cust_id))) LEFT JOIN public.shiptoinfo ON ((shiptoinfo.shipto_id = cmhead.cmhead_shipto_id))) LEFT JOIN public.curr_symbol curr ON ((curr.curr_id = cmhead.cmhead_curr_id))) LEFT JOIN public.salesrep ON ((salesrep.salesrep_id = cmhead.cmhead_salesrep_id))) LEFT JOIN public.taxzone ON ((taxzone.taxzone_id = cmhead.cmhead_taxzone_id))) LEFT JOIN public.rsncode ON ((rsncode.rsncode_id = cmhead.cmhead_rsncode_id))); ALTER TABLE creditmemo OWNER TO admin; -- -- Name: VIEW creditmemo; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW creditmemo IS 'Credit Memo Header'; SET search_path = public, pg_catalog; -- -- Name: insertcreditmemo(api.creditmemo); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION insertcreditmemo(api.creditmemo) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNew ALIAS FOR $1; BEGIN -- NOTE: (SELECT getCustId(...)) seems redundant, but it actually produces -- a HUGE performance increase because it makes the Postgres query planner -- use an index scan rather than an sequential table scan on cust_id INSERT INTO cmhead ( cmhead_number, cmhead_posted, cmhead_invcnumber, cmhead_custponumber, cmhead_cust_id, cmhead_docdate, cmhead_shipto_id, cmhead_shipto_name, cmhead_shipto_address1, cmhead_shipto_address2, cmhead_shipto_address3, cmhead_shipto_city, cmhead_shipto_state, cmhead_shipto_zipcode, cmhead_shipto_country, cmhead_salesrep_id, cmhead_freight, cmhead_misc, cmhead_comments, cmhead_printed, cmhead_billtoname, cmhead_billtoaddress1, cmhead_billtoaddress2, cmhead_billtoaddress3, cmhead_billtocity, cmhead_billtostate, cmhead_billtozip, cmhead_billtocountry, cmhead_hold, cmhead_commission, cmhead_misc_accnt_id, cmhead_misc_descrip, cmhead_rsncode_id, cmhead_curr_id, cmhead_taxzone_id, cmhead_gldistdate, cmhead_rahead_id ) SELECT (CASE -- use a case here so we don't unnecessarily fetch a new CM number WHEN pNew.memo_number IS NULL THEN fetchCMNumber() ELSE pNew.memo_number END), FALSE, -- posted pNew.apply_to, pNew.customer_po_number, cust_id, COALESCE(pNew.memo_date, CURRENT_DATE), COALESCE(shipto_id,-1), pNew.shipto_name, pNew.shipto_address1, pNew.shipto_address2, pNew.shipto_address3, pNew.shipto_city, pNew.shipto_state, pNew.shipto_postal_code, pNew.shipto_country, COALESCE(getSalesRepId(pNew.sales_rep),shipto_salesrep_id,cust_salesrep_id), COALESCE(pNew.freight, 0), COALESCE(pNew.misc_charge_amount, 0), pNew.notes, FALSE, -- printed COALESCE(pNew.billto_name, invchead_billto_name, cust_name), COALESCE(pNew.billto_address1, invchead_billto_address1, addr_line1), COALESCE(pNew.billto_address2, invchead_billto_address2, addr_line2), COALESCE(pNew.billto_address3, invchead_billto_address3, addr_line3), COALESCE(pNew.billto_city, invchead_billto_city, addr_city), COALESCE(pNew.billto_state, invchead_billto_state, addr_state), COALESCE(pNew.billto_postal_code, invchead_billto_zipcode, addr_postalcode), COALESCE(pNew.billto_country, invchead_billto_country, addr_country), COALESCE(pNew.on_hold, FALSE), COALESCE(pNew.commission, 0), COALESCE(getGlAccntId(pNew.misc_charge_credit_account),-1), pNew.misc_charge_description, (SELECT rsncode_id FROM rsncode WHERE rsncode_code = pNew.reason_code), COALESCE(getCurrId(pNew.currency),cust_curr_id,basecurrid()), CASE WHEN pNew.tax_zone = 'None' THEN NULL ELSE COALESCE(getTaxZoneID(pNew.tax_zone),cust_taxzone_id) END, NULL, NULL FROM custinfo LEFT OUTER JOIN shiptoinfo ON (shipto_id=(SELECT CASE WHEN getShiptoId(pNew.customer_number,pNew.shipto_number) IS NOT NULL THEN getShiptoId(pNew.customer_number,pNew.shipto_number) ELSE (SELECT shipto_id FROM shiptoinfo WHERE shipto_cust_id=cust_id AND shipto_default) END)) LEFT OUTER JOIN invchead ON (invchead_id=getInvcheadId(pNEW.apply_to)) LEFT OUTER JOIN cntct ON (cntct_id=cust_cntct_id) LEFT OUTER JOIN addr ON (addr_id=cntct_addr_id) WHERE cust_id = (CASE WHEN pNew.customer_number IS NOT NULL THEN (SELECT getCustId(pNew.customer_number)) ELSE (SELECT invchead_cust_id FROM invchead WHERE invchead_invcnumber = pNew.apply_to) END); RETURN TRUE; END; $_$; ALTER FUNCTION public.insertcreditmemo(api.creditmemo) OWNER TO admin; -- -- Name: cmitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cmitem ( cmitem_id integer DEFAULT nextval(('cmitem_cmitem_id_seq'::text)::regclass) NOT NULL, cmitem_cmhead_id integer NOT NULL, cmitem_linenumber integer NOT NULL, cmitem_itemsite_id integer NOT NULL, cmitem_qtycredit numeric(18,6) NOT NULL, cmitem_qtyreturned numeric(18,6) NOT NULL, cmitem_unitprice numeric(16,4) NOT NULL, cmitem_comments text, cmitem_rsncode_id integer, cmitem_taxtype_id integer, cmitem_qty_uom_id integer NOT NULL, cmitem_qty_invuomratio numeric(20,10) NOT NULL, cmitem_price_uom_id integer NOT NULL, cmitem_price_invuomratio numeric(20,10) NOT NULL, cmitem_raitem_id integer, cmitem_updateinv boolean DEFAULT true NOT NULL ); ALTER TABLE cmitem OWNER TO admin; -- -- Name: TABLE cmitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE cmitem IS 'S/O Credit Memo Line Item information'; SET search_path = api, pg_catalog; -- -- Name: creditmemoline; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW creditmemoline AS SELECT cmhead.cmhead_number AS memo_number, cmitem.cmitem_linenumber AS line_number, item.item_number, whsinfo.warehous_code AS recv_site, rsncode.rsncode_code AS reason_code, cmitem.cmitem_qtyreturned AS qty_returned, cmitem.cmitem_qtycredit AS qty_to_credit, COALESCE(qty_uom.uom_name, 'None'::text) AS qty_uom, cmitem.cmitem_unitprice AS net_unit_price, COALESCE(price_uom.uom_name, 'None'::text) AS price_uom, COALESCE(taxtype.taxtype_name, 'None'::text) AS tax_type, cmitem.cmitem_comments AS notes FROM ((((((((public.cmitem LEFT JOIN public.cmhead ON ((cmitem.cmitem_cmhead_id = cmhead.cmhead_id))) LEFT JOIN public.itemsite ON ((itemsite.itemsite_id = cmitem.cmitem_itemsite_id))) LEFT JOIN public.item ON ((item.item_id = itemsite.itemsite_item_id))) LEFT JOIN public.whsinfo ON ((whsinfo.warehous_id = itemsite.itemsite_warehous_id))) LEFT JOIN public.rsncode ON ((rsncode.rsncode_id = cmitem.cmitem_rsncode_id))) LEFT JOIN public.taxtype ON ((taxtype.taxtype_id = cmitem.cmitem_taxtype_id))) LEFT JOIN public.uom qty_uom ON ((qty_uom.uom_id = cmitem.cmitem_qty_uom_id))) LEFT JOIN public.uom price_uom ON ((price_uom.uom_id = cmitem.cmitem_price_uom_id))); ALTER TABLE creditmemoline OWNER TO admin; -- -- Name: VIEW creditmemoline; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW creditmemoline IS 'Credit Memo Line'; SET search_path = public, pg_catalog; -- -- Name: insertcreditmemoline(api.creditmemoline); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION insertcreditmemoline(api.creditmemoline) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNew ALIAS FOR $1; _check INTEGER; _r RECORD; BEGIN SELECT cmhead_id INTO _check FROM cmhead WHERE (cmhead_id=getCmheadId(pNew.memo_number, FALSE)); IF (NOT FOUND) THEN RAISE EXCEPTION 'Credit Memo # % not found', pNew.memo_number; END IF; INSERT INTO cmitem ( cmitem_cmhead_id, cmitem_linenumber, cmitem_itemsite_id, cmitem_qtycredit, cmitem_qtyreturned, cmitem_unitprice, cmitem_comments, cmitem_rsncode_id, cmitem_taxtype_id, cmitem_qty_uom_id, cmitem_qty_invuomratio, cmitem_price_uom_id, cmitem_price_invuomratio ) SELECT cmhead_id, COALESCE(pNew.line_number, (SELECT (COALESCE(MAX(cmitem_linenumber), 0) + 1) FROM cmitem WHERE (cmitem_cmhead_id=cmhead_id))), COALESCE(itemsite_id, -1), COALESCE(pNew.qty_to_credit, 0), COALESCE(pNew.qty_returned, 0), COALESCE(pNew.net_unit_price, 0), pNew.notes, getRsnId(pNew.reason_code), taxtype_id, COALESCE(getUomId(pNew.qty_uom), item_inv_uom_id), CASE WHEN item_id IS NOT NULL THEN itemuomtouomratio(item_id, COALESCE(getUomId(pNew.qty_uom),item_inv_uom_id),item_inv_uom_id) ELSE 1 END, COALESCE(getUomId(pNew.price_uom),item_price_uom_id), CASE WHEN item_id IS NOT NULL THEN itemuomtouomratio(item_id, COALESCE(getUomId(pNew.price_uom),item_price_uom_id),item_price_uom_id) ELSE 1 END FROM cmhead LEFT OUTER JOIN item ON (item_id=getItemId(pNew.item_number)) LEFT OUTER JOIN itemsite ON (itemsite_item_id=item_id AND itemsite_warehous_id=getWarehousId(pNew.recv_site, 'ALL')) LEFT OUTER JOIN taxtype ON (taxtype_id=CASE WHEN pNew.tax_type IS NULL THEN getItemTaxType(item_id,cmhead_taxzone_id) WHEN pNew.tax_type = 'None' THEN NULL ELSE getTaxTypeId(pNew.tax_type) END) WHERE (cmhead_id=getCmheadId(pNew.memo_number, FALSE)); RETURN TRUE; END; $_$; ALTER FUNCTION public.insertcreditmemoline(api.creditmemoline) OWNER TO admin; -- -- Name: insertflgroup(integer, integer, integer, integer, boolean, character, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION insertflgroup(pflheadid integer, pperiodid integer, pflgrpid integer, plevel integer, psummarize boolean, pinterval character DEFAULT NULL::bpchar, pprjid integer DEFAULT NULL::integer) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. /* see the "performance vs. history" comment in financialreport() */ DECLARE _subtotal BOOLEAN; _r RECORD; _g RECORD; _all BOOLEAN; _username TEXT := getEffectiveXtUser(); BEGIN _all = COALESCE(pPrjid,-1) = -1; -- Check to see if this group wants a subtotal _subtotal := FALSE; IF (pFlgrpid != -1) THEN SELECT COALESCE(flgrp_subtotal, FALSE) INTO _subtotal FROM flgrp WHERE ((flgrp_flhead_id=pFlheadid) AND (flgrp_id=pFlgrpid)); END IF; FOR _r IN SELECT 'G' AS type, flgrp_id AS type_id, flgrp_order AS orderby, flgrp_summarize AS summarize, flgrp_subtract AS subtract, CASE WHEN(flgrp_summarize AND (NOT flgrp_showstart)) THEN NULL ELSE 0.00 END AS beginning, CASE WHEN(flgrp_summarize AND (NOT flgrp_showend)) THEN NULL ELSE 0.00 END AS ending, CASE WHEN(flgrp_summarize AND (NOT flgrp_showdelta)) THEN NULL ELSE 0.00 END AS debits, CASE WHEN(flgrp_summarize AND (NOT flgrp_showdelta)) THEN NULL ELSE 0.00 END AS credits, CASE WHEN(flgrp_summarize AND (NOT flgrp_showbudget)) THEN NULL ELSE 0.00 END AS budget, CASE WHEN(flgrp_summarize AND (NOT flgrp_showdiff)) THEN NULL ELSE 0.00 END AS diff, CASE WHEN(flgrp_summarize AND (NOT flgrp_showcustom)) THEN NULL ELSE 0.00 END AS custom, CASE WHEN(flgrp_showstartprcnt) THEN 0.00 ELSE NULL END AS beginningprcnt, CASE WHEN(flgrp_showendprcnt) THEN 0.00 ELSE NULL END AS endingprcnt, CASE WHEN(flgrp_showdeltaprcnt) THEN 0.00 ELSE NULL END AS debitsprcnt, CASE WHEN(flgrp_showdeltaprcnt) THEN 0.00 ELSE NULL END AS creditsprcnt, CASE WHEN(flgrp_showbudgetprcnt) THEN 0.00 ELSE NULL END AS budgetprcnt, CASE WHEN(flgrp_showdiffprcnt) THEN 0.00 ELSE NULL END AS diffprcnt, CASE WHEN(flgrp_showcustomprcnt) THEN 0.00 ELSE NULL END AS customprcnt, -1 AS accnt_id, '' AS accnt_number FROM flgrp WHERE ((flgrp_flgrp_id=pFlgrpid) AND (flgrp_flhead_id=pFlheadid)) UNION ALL SELECT 'I' AS type, flitem_id AS type_id, flitem_order AS orderby, FALSE AS summarize, flitem_subtract AS subtract, CASE WHEN (flitem_showstart AND (first_trialbal_id IS NULL)) THEN 0.00 WHEN (flitem_showstart) THEN normalizeTrialBal(first_trialbal_id, 'B') ELSE NULL END AS beginning, CASE WHEN (flitem_showend AND (last_trialbal_id IS NULL)) THEN 0.00 WHEN (flitem_showend) THEN normalizeTrialBal(last_trialbal_id, 'E') ELSE NULL END AS ending, CASE WHEN (flitem_showdelta) THEN sum_trialbal_debits ELSE NULL END AS debits, CASE WHEN (flitem_showdelta) THEN sum_trialbal_credits ELSE NULL END AS credits, CASE WHEN ((flitem_showbudget) AND (accnt_type IN ('R','E')) AND flhead_type IN ('I','C','A')) THEN COALESCE(sum_budget_amount,0) WHEN ((flitem_showbudget) AND (accnt_type IN ('R','E')) AND flhead_type = 'B' ) THEN (SELECT COALESCE(SUM(b.budget_amount),0) FROM budget b, (SELECT ytd.period_id AS ytd_period_id FROM period cp, period ytd WHERE ((cp.period_id = last_flitem_period_id) AND (ytd.period_start <= cp.period_start) AND (ytd.period_yearperiod_id = cp.period_yearperiod_id))) AS periods WHERE ((b.budget_accnt_id=accnt_id) AND (b.budget_period_id=ytd_period_id))) WHEN ((flitem_showbudget) AND (accnt_type IN ('A','L','Q')) AND flhead_type = 'C') THEN calccashbudget(accnt_id,last_flitem_period_id,pInterval) ELSE COALESCE(last_budget_amount,0) END AS budget, CASE WHEN (flitem_showdiff AND (first_trialbal_id IS NULL)) THEN 0.00 WHEN (flitem_showdiff) THEN COALESCE(normalizeTrialBal(last_trialbal_id, 'E') - normalizeTrialBal(first_trialbal_id, 'B'), 0.00) ELSE NULL END AS diff, CASE WHEN (NOT flitem_showcustom) THEN NULL WHEN (flitem_custom_source='S' AND (first_trialbal_id IS NOT NULL)) THEN normalizeTrialBal(first_trialbal_id, 'B') WHEN (flitem_custom_source='E' AND (first_trialbal_id IS NOT NULL)) THEN normalizeTrialBal(last_trialbal_id, 'E') WHEN (flitem_custom_source='D') THEN sum_trialbal_debits WHEN (flitem_custom_source='C') THEN sum_trialbal_credits WHEN (flitem_custom_source='B') THEN ( CASE WHEN (accnt_type IN ('R','E')) THEN sum_budget_amount ELSE last_budget_amount END) WHEN (flitem_custom_source='F' AND (first_trialbal_id IS NOT NULL)) THEN COALESCE(normalizeTrialBal(last_trialbal_id, 'E') - normalizeTrialBal(first_trialbal_id, 'B'), 0.00) ELSE 0.00 END AS custom, CASE WHEN(flitem_showstartprcnt) THEN 0.00 ELSE NULL END AS beginningprcnt, CASE WHEN(flitem_showendprcnt) THEN 0.00 ELSE NULL END AS endingprcnt, CASE WHEN(flitem_showdeltaprcnt) THEN 0.00 ELSE NULL END AS debitsprcnt, CASE WHEN(flitem_showdeltaprcnt) THEN 0.00 ELSE NULL END AS creditsprcnt, CASE WHEN(flitem_showbudgetprcnt) THEN 0.00 ELSE NULL END AS budgetprcnt, CASE WHEN(flitem_showdiffprcnt) THEN 0.00 ELSE NULL END AS diffprcnt, CASE WHEN(flitem_showcustomprcnt) THEN 0.00 ELSE NULL END AS customprcnt, accnt_id, public.formatglaccount(accnt_id) AS accnt_number FROM (SELECT flhead_type,flitem_id,flitem_order,flitem_subtract,flitem_showstart,flitem_showend, flitem_showdelta,flitem_showbudget,flitem_showdiff,flitem_showcustom, flitem_custom_source,flitem_showstartprcnt,flitem_showendprcnt,flitem_showdeltaprcnt, flitem_showbudgetprcnt,flitem_showdiffprcnt,flitem_showcustomprcnt, accnt_id,accnt_type, FIRST(trialbal_id) AS first_trialbal_id, LAST(trialbal_id) AS last_trialbal_id, SUM(trialbal_debits) AS sum_trialbal_debits, SUM(trialbal_credits) AS sum_trialbal_credits, LAST(flitem_period_id) AS last_flitem_period_id, SUM(budget_amount) AS sum_budget_amount, LAST(budget_amount) AS last_budget_amount FROM (SELECT period_id AS flitem_period_id, period_start,flhead_type,flitem_id,flitem_order,flitem_subtract,flitem_showstart,flitem_showend, flitem_showdelta,flitem_showbudget,flitem_showdiff,flitem_showcustom, flitem_custom_source,flitem_showstartprcnt,flitem_showendprcnt,flitem_showdeltaprcnt, flitem_showbudgetprcnt,flitem_showdiffprcnt,flitem_showcustomprcnt, accnt_id,accnt_type,COALESCE(trialbal_id,getlasttrialbalid(accnt_id,period_id)) as trialbal_id,COALESCE(trialbal_debits,0) as trialbal_debits, COALESCE(trialbal_credits,0) AS trialbal_credits,COALESCE(budget_amount,0) AS budget_amount FROM (SELECT period_id, period_start, flhead_type, flitem_id,flitem_order,flitem_subtract,flitem_showstart,flitem_showend, flitem_showdelta,flitem_showbudget,flitem_showdiff,flitem_showcustom,flitem_custom_source,flitem_showstartprcnt, flitem_showendprcnt,flitem_showdeltaprcnt,flitem_showbudgetprcnt,flitem_showdiffprcnt,flitem_showcustomprcnt, accnt_id, accnt_type FROM period,flaccnt WHERE ((flitem_flhead_id=pFlheadid) AND (flitem_flgrp_id=pFlgrpid) AND (_all OR prj_id=pPrjId) AND (period_id IN (SELECT * FROM getperiodid(pPeriodId,pInterval)))) ORDER BY flitem_id ) AS flitem LEFT OUTER JOIN trialbal ON ((trialbal_accnt_id=accnt_id) AND (trialbal_period_id=period_id)) LEFT OUTER JOIN budget ON ((budget_accnt_id=accnt_id) AND (budget_period_id=period_id)) ORDER BY accnt_id, period_start) AS data GROUP BY flhead_type,flitem_id,flitem_order,flitem_subtract,flitem_showstart,flitem_showend, flitem_showdelta,flitem_showbudget,flitem_showdiff,flitem_showcustom, flitem_custom_source,flitem_showstartprcnt,flitem_showendprcnt,flitem_showdeltaprcnt, flitem_showbudgetprcnt,flitem_showdiffprcnt,flitem_showcustomprcnt,accnt_id,accnt_type) AS agg UNION ALL SELECT 'S' AS type, flspec_id AS type_id, flspec_order AS orderby, FALSE AS summarize, flspec_subtract AS subtract, CASE WHEN (flspec_showstart) THEN findSpecialFinancial('S', flspec_type, pPeriodid) ELSE NULL END AS beginning, CASE WHEN (flspec_showend) THEN findSpecialFinancial('E', flspec_type, pPeriodid) ELSE NULL END AS ending, CASE WHEN (flspec_showdelta) THEN findSpecialFinancial('D', flspec_type, pPeriodid) ELSE NULL END AS debits, CASE WHEN (flspec_showdelta) THEN findSpecialFinancial('C', flspec_type, pPeriodid) ELSE NULL END AS credits, CASE WHEN (flspec_showbudget) THEN findSpecialFinancial('B', flspec_type, pPeriodid) ELSE NULL END AS budget, CASE WHEN (flspec_showdiff) THEN findSpecialFinancial('E', flspec_type, pPeriodid) - findSpecialFinancial('S', flspec_type, pPeriodid) ELSE NULL END AS diff, CASE WHEN (NOT flspec_showcustom) THEN NULL WHEN (flspec_custom_source='F') THEN findSpecialFinancial('E', flspec_type, pPeriodid) - findSpecialFinancial('S', flspec_type, pPeriodid) WHEN (flspec_custom_source IN ('S', 'E', 'D', 'C', 'B')) THEN findSpecialFinancial(flspec_custom_source, flspec_type, pPeriodid) ELSE 0.00 END AS custom, CASE WHEN(flspec_showstartprcnt) THEN 0.00 ELSE NULL END AS beginningprcnt, CASE WHEN(flspec_showendprcnt) THEN 0.00 ELSE NULL END AS endingprcnt, CASE WHEN(flspec_showdeltaprcnt) THEN 0.00 ELSE NULL END AS debitsprcnt, CASE WHEN(flspec_showdeltaprcnt) THEN 0.00 ELSE NULL END AS creditsprcnt, CASE WHEN(flspec_showbudgetprcnt) THEN 0.00 ELSE NULL END AS budgetprcnt, CASE WHEN(flspec_showdiffprcnt) THEN 0.00 ELSE NULL END AS diffprcnt, CASE WHEN(flspec_showcustomprcnt) THEN 0.00 ELSE NULL END AS customprcnt, -1 AS accnt_id, '' AS accnt_number FROM flspec WHERE ((flspec_flgrp_id=pFlgrpid) AND (flspec_flhead_id=pFlheadid)) ORDER BY orderby, accnt_number LOOP IF (_r.type = 'G') THEN -- Create a record for the items sub items to be attached to and be able to update the total INSERT INTO flrpt (flrpt_flhead_id, flrpt_period_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_beginning, flrpt_ending, flrpt_debits, flrpt_credits, flrpt_budget, flrpt_diff, flrpt_custom, flrpt_beginningprcnt, flrpt_endingprcnt, flrpt_debitsprcnt, flrpt_creditsprcnt, flrpt_budgetprcnt, flrpt_diffprcnt, flrpt_customprcnt, flrpt_parent_id, flrpt_interval) VALUES (pFlheadid, pPeriodid, _username, (COALESCE(( SELECT MAX(flrpt_order) FROM flrpt WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) -- AND (flrpt_username=_username) ) ), 1) + 1), pLevel, _r.type, _r.type_id, _r.beginning, _r.ending, _r.debits, _r.credits, _r.budget, _r.diff, _r.custom, _r.beginningprcnt, _r.endingprcnt, _r.debitsprcnt, _r.creditsprcnt, _r.budgetprcnt, _r.diffprcnt, _r.customprcnt, pFlgrpid, pInterval); PERFORM insertFlGroup(pFlheadid, pPeriodid, _r.type_id, (pLevel + 1), (pSummarize OR _r.summarize), pInterval, pPrjid); -- Update the parent item SELECT COALESCE(flrpt_beginning, 0.00) AS beginning, COALESCE(flrpt_ending, 0.00) AS ending, COALESCE(flrpt_debits, 0.00) AS debits, COALESCE(flrpt_credits, 0.00) AS credits, COALESCE(flrpt_budget, 0.00) AS budget, COALESCE(flrpt_diff, 0.00) AS diff, COALESCE(flrpt_custom, 0.00) AS custom INTO _g FROM flrpt WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) -- AND (flrpt_username=_username) AND (flrpt_type=_r.type) AND (flrpt_type_id=_r.type_id)); IF (_r.subtract) THEN UPDATE flrpt SET flrpt_beginning = flrpt_beginning - _g.beginning, flrpt_ending = flrpt_ending - _g.ending, flrpt_debits = flrpt_debits - _g.debits, flrpt_credits = flrpt_credits - _g.credits, flrpt_budget = flrpt_budget - _g.budget, flrpt_diff = flrpt_diff - _g.diff, flrpt_custom = flrpt_custom - _g.custom WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) -- AND (flrpt_username=_username) AND (flrpt_type='G') AND (flrpt_type_id=pFlgrpid)); ELSE UPDATE flrpt SET flrpt_beginning = flrpt_beginning + _g.beginning, flrpt_ending = flrpt_ending + _g.ending, flrpt_debits = flrpt_debits + _g.debits, flrpt_credits = flrpt_credits + _g.credits, flrpt_budget = flrpt_budget + _g.budget, flrpt_diff = flrpt_diff + _g.diff, flrpt_custom = flrpt_custom + _g.custom WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) -- AND (flrpt_username=_username) AND (flrpt_type='G') AND (flrpt_type_id=pFlgrpid)); END IF; -- If we are summarizing then we need to remove the record we created now that we have updated the total IF (pSummarize) THEN DELETE FROM flrpt WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) -- AND (flrpt_username=_username) AND (flrpt_type=_r.type) AND (flrpt_type_id=_r.type_id)); END IF; ELSE IF (_r.type = 'I' OR _r.type = 'S' ) THEN -- If we are not summarizing then create a new entry for this record IF (NOT pSummarize) THEN INSERT INTO flrpt (flrpt_flhead_id, flrpt_period_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_beginning, flrpt_ending, flrpt_debits, flrpt_credits, flrpt_budget, flrpt_diff, flrpt_custom, flrpt_beginningprcnt, flrpt_endingprcnt, flrpt_debitsprcnt, flrpt_creditsprcnt, flrpt_budgetprcnt, flrpt_diffprcnt, flrpt_customprcnt, flrpt_parent_id,flrpt_accnt_id,flrpt_interval) VALUES (pFlheadid, pPeriodid, _username, (COALESCE(( SELECT MAX(flrpt_order) FROM flrpt WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) -- AND (flrpt_username=_username) ) ), 1) + 1), pLevel, _r.type, _r.type_id, _r.beginning, _r.ending, _r.debits, _r.credits, _r.budget, _r.diff, _r.custom, _r.beginningprcnt, _r.endingprcnt, _r.debitsprcnt, _r.creditsprcnt, _r.budgetprcnt, _r.diffprcnt, _r.customprcnt, pFlgrpid,_r.accnt_id,pInterval); END IF; -- Update the parent item IF (_r.subtract) THEN UPDATE flrpt SET flrpt_beginning = flrpt_beginning - COALESCE(_r.beginning, 0.00), flrpt_ending = flrpt_ending - COALESCE(_r.ending, 0.00), flrpt_debits = flrpt_debits - COALESCE(_r.debits, 0.00), flrpt_credits = flrpt_credits - COALESCE(_r.credits, 0.00), flrpt_budget = flrpt_budget - COALESCE(_r.budget, 0.00), flrpt_diff = flrpt_diff - COALESCE(_r.diff, 0.00), flrpt_custom = flrpt_custom - COALESCE(_r.custom, 0.00) WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) -- AND (flrpt_username=_username) AND (flrpt_type='G') AND (flrpt_type_id=pFlgrpid)); ELSE UPDATE flrpt SET flrpt_beginning = flrpt_beginning + COALESCE(_r.beginning, 0.00), flrpt_ending = flrpt_ending + COALESCE(_r.ending, 0.00), flrpt_debits = flrpt_debits + COALESCE(_r.debits, 0.00), flrpt_credits = flrpt_credits + COALESCE(_r.credits, 0.00), flrpt_budget = flrpt_budget + COALESCE(_r.budget, 0.00), flrpt_diff = flrpt_diff + COALESCE(_r.diff, 0.00), flrpt_custom = flrpt_custom + COALESCE(_r.custom, 0.00) WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_interval=pInterval) AND (flrpt_period_id=pPeriodid) -- AND (flrpt_username=_username) AND (flrpt_type='G') AND (flrpt_type_id=pFlgrpid)); END IF; END IF; END IF; END LOOP; IF (NOT pSummarize) THEN -- If this group wants a summarized line create it here. IF (_subtotal) THEN INSERT INTO flrpt (flrpt_flhead_id, flrpt_period_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_beginning, flrpt_ending, flrpt_debits, flrpt_credits, flrpt_budget, flrpt_diff, flrpt_custom, flrpt_beginningprcnt, flrpt_endingprcnt, flrpt_debitsprcnt, flrpt_creditsprcnt, flrpt_budgetprcnt, flrpt_diffprcnt, flrpt_customprcnt, flrpt_parent_id, flrpt_altname,flrpt_interval ) SELECT pFlheadid, pPeriodid, _username, (COALESCE(( SELECT MAX(flrpt_order) FROM flrpt WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) -- AND (flrpt_username=_username) ) ), 1) + 1), pLevel, 'T', -1, CASE WHEN (flgrp_showstart) THEN flrpt_beginning ELSE NULL END, CASE WHEN (flgrp_showend) THEN flrpt_ending ELSE NULL END, CASE WHEN (flgrp_showdelta) THEN flrpt_debits ELSE NULL END, CASE WHEN (flgrp_showdelta) THEN flrpt_credits ELSE NULL END, CASE WHEN (flgrp_showbudget) THEN flrpt_budget ELSE NULL END, CASE WHEN (flgrp_showdiff) THEN flrpt_diff ELSE NULL END, CASE WHEN (flgrp_showcustom) THEN flrpt_custom ELSE NULL END, CASE WHEN (flgrp_showstartprcnt) THEN flrpt_beginningprcnt ELSE NULL END, CASE WHEN (flgrp_showendprcnt) THEN flrpt_endingprcnt ELSE NULL END, CASE WHEN (flgrp_showdeltaprcnt) THEN flrpt_debitsprcnt ELSE NULL END, CASE WHEN (flgrp_showdeltaprcnt) THEN flrpt_creditsprcnt ELSE NULL END, CASE WHEN (flgrp_showbudgetprcnt) THEN flrpt_budgetprcnt ELSE NULL END, CASE WHEN (flgrp_showdiffprcnt) THEN flrpt_diffprcnt ELSE NULL END, CASE WHEN (flgrp_showcustomprcnt) THEN flrpt_customprcnt ELSE NULL END, pFlgrpid, CASE WHEN (flgrp_usealtsubtotal) THEN flgrp_altsubtotal ELSE NULL END, pInterval FROM flrpt, flgrp WHERE ((flrpt_flhead_id=flgrp_flhead_id) AND (flrpt_type_id=flgrp_id) AND (flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) -- AND (flrpt_username=_username) AND (flrpt_type='G') AND (flrpt_type_id=pFlgrpid)); END IF; END IF; return TRUE; END; $$; ALTER FUNCTION public.insertflgroup(pflheadid integer, pperiodid integer, pflgrpid integer, plevel integer, psummarize boolean, pinterval character, pprjid integer) OWNER TO admin; -- -- Name: insertgltransaction(text, text, text, text, integer, integer, integer, numeric, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION insertgltransaction(text, text, text, text, integer, integer, integer, numeric, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSource ALIAS FOR $1; pDocType ALIAS FOR $2; pDocNumber ALIAS FOR $3; pNotes ALIAS FOR $4; pCreditid ALIAS FOR $5; pDebitid ALIAS FOR $6; pMiscid ALIAS FOR $7; pAmount ALIAS FOR $8; pDistDate ALIAS FOR $9; _return INTEGER; BEGIN SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'), pSource, pDocType, pDocNumber, pNotes, pCreditid, pDebitid, pMiscid, pAmount, pDistDate) INTO _return; RETURN _return; END; $_$; ALTER FUNCTION public.insertgltransaction(text, text, text, text, integer, integer, integer, numeric, date) OWNER TO admin; -- -- Name: insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pJournalNumber ALIAS FOR $1; pSource ALIAS FOR $2; pDocType ALIAS FOR $3; pDocNumber ALIAS FOR $4; pNotes ALIAS FOR $5; pCreditid ALIAS FOR $6; pDebitid ALIAS FOR $7; pMiscid ALIAS FOR $8; pAmount ALIAS FOR $9; pDistDate ALIAS FOR $10; _return INTEGER; BEGIN SELECT insertGLTransaction( pJournalNumber, pSource, pDocType, pDocNumber, pNotes, pCreditid, pDebitid, pMiscid, pAmount, pDistDate, TRUE) INTO _return; RETURN _return; END; $_$; ALTER FUNCTION public.insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date) OWNER TO admin; -- -- Name: insertgltransaction(text, text, text, text, integer, integer, integer, numeric, date, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION insertgltransaction(text, text, text, text, integer, integer, integer, numeric, date, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSource ALIAS FOR $1; pDocType ALIAS FOR $2; pDocNumber ALIAS FOR $3; pNotes ALIAS FOR $4; pCreditid ALIAS FOR $5; pDebitid ALIAS FOR $6; pMiscid ALIAS FOR $7; pAmount ALIAS FOR $8; pDistDate ALIAS FOR $9; pPostTrialBal ALIAS FOR $10; _return INTEGER; BEGIN SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'), pSource, pDocType, pDocNumber, pNotes, pCreditid, pDebitid, pMiscid, pAmount, pDistDate, pPostTrialBal) INTO _return; RETURN _return; END; $_$; ALTER FUNCTION public.insertgltransaction(text, text, text, text, integer, integer, integer, numeric, date, boolean) OWNER TO admin; -- -- Name: insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pJournalNumber ALIAS FOR $1; pSource ALIAS FOR $2; pDocType ALIAS FOR $3; pDocNumber ALIAS FOR $4; pNotes ALIAS FOR $5; pCreditid ALIAS FOR $6; pDebitid ALIAS FOR $7; pMiscid ALIAS FOR $8; pAmount ALIAS FOR $9; pDistDate ALIAS FOR $10; pPostTrialBal ALIAS FOR $11; _return INTEGER; BEGIN SELECT insertGLTransaction( pJournalNumber, pSource, pDocType, pDocNumber, pNotes, pCreditid, pDebitid, pMiscid, pAmount, pDistDate, pPostTrialBal, false) INTO _return; RETURN _return; END; $_$; ALTER FUNCTION public.insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date, boolean) OWNER TO admin; -- -- Name: insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pJournalNumber ALIAS FOR $1; pSource ALIAS FOR $2; pDocType ALIAS FOR $3; pDocNumber ALIAS FOR $4; pNotes ALIAS FOR $5; pCreditid ALIAS FOR $6; pDebitid ALIAS FOR $7; pMiscid ALIAS FOR $8; pAmount ALIAS FOR $9; pDistDate ALIAS FOR $10; pPostTrialBal ALIAS FOR $11; pOnlyGL ALIAS FOR $12; _debitid INTEGER; _creditid INTEGER; _sequence INTEGER; _check INTEGER; BEGIN -- Check GL Interface metric IF (fetchMetricBool('InterfaceToGL') = false AND pSource IN ('I/M', 'P/D', 'S/R', 'W/O')) THEN RETURN 0; END IF; IF (fetchMetricBool('InterfaceAPToGL') = false AND pSource = 'A/P') THEN RETURN 0; END IF; IF (fetchMetricBool('InterfaceARToGL') = false AND pSource IN ('A/R', 'S/O', 'S/R')) THEN RETURN 0; END IF; -- Is there anything to post? -- ToDo - 2 should really be the scale of the base currency IF (round(pAmount, 2) = 0) THEN RETURN -3; END IF; /* Make sure we don't create an imbalance across companies. The 'IgnoreCompanyBalance' metric is a back door mechanism to allow legacy users to create transactions accross companies if they have been using the company segment for something else and they MUST continue to be able to do so. It can only be implemented by direct sql update to the metric table and should otherwise be discouraged. */ IF (COALESCE(fetchMetricValue('GLCompanySize'),0) > 0 AND fetchMetricBool('IgnoreCompany') = false) THEN IF (SELECT (COALESCE(d.accnt_company,'') != COALESCE(c.accnt_company,'')) FROM accnt d, accnt c WHERE ((d.accnt_id=pDebitid) AND (c.accnt_id=pCreditid))) THEN RAISE EXCEPTION 'G/L Transaction can not be posted because accounts % and % reference two different companies.', formatGlaccount(pDebitid), formatGlaccount(pCreditid); END IF; END IF; -- Validate pDebitid IF (pDebitid IN (SELECT accnt_id FROM accnt)) THEN _debitid := pDebitid; ELSE -- Try and work out the unassigned accnt from the credit accnt SELECT getUnassignedAccntId(getcompanyid(pCreditid)) INTO _debitid; END IF; -- Validate pCreditid IF (pCreditid IN (SELECT accnt_id FROM accnt)) THEN _creditid := pCreditid; ELSE -- Try and work out the unassigned accnt from the debit accnt SELECT getUnassignedAccntId(getcompanyid(pDebitid)) INTO _creditid; END IF; -- refuse to accept postings into closed periods IF (SELECT BOOL_AND(COALESCE(period_closed, FALSE)) FROM accnt LEFT OUTER JOIN period ON (pDistDate BETWEEN period_start AND period_end) WHERE (accnt_id IN (_creditid, _debitid))) THEN RAISE EXCEPTION 'Cannot post to closed period (%).', pDistDate; RETURN -4; -- remove raise exception when all callers check return code END IF; -- refuse to accept postings into frozen periods without proper priv IF (SELECT NOT BOOL_AND(checkPrivilege('PostFrozenPeriod')) AND BOOL_AND(COALESCE(period_freeze, FALSE)) FROM accnt LEFT OUTER JOIN period ON (pDistDate BETWEEN period_start AND period_end) WHERE (accnt_id IN (_creditid, _debitid))) THEN RAISE EXCEPTION 'Cannot post to frozen period (%).', pDistDate; RETURN -4; -- remove raise exception when all callers check return code END IF; -- refuse to accept postings into nonexistent periods IF NOT EXISTS(SELECT period_id FROM period WHERE (pDistDate BETWEEN period_start AND period_end)) THEN RAISE EXCEPTION 'Cannot post to nonexistent period (%).', pDistDate; END IF; -- Grab a sequence for the pair SELECT fetchGLSequence() INTO _sequence; IF (NOT pOnlyGL AND fetchMetricBool('UseJournals')) THEN -- First the credit INSERT INTO sltrans ( sltrans_journalnumber, sltrans_posted, sltrans_created, sltrans_date, sltrans_sequence, sltrans_accnt_id, sltrans_source, sltrans_doctype, sltrans_docnumber, sltrans_notes, sltrans_misc_id, sltrans_amount ) VALUES ( pJournalNumber, FALSE, CURRENT_TIMESTAMP, pDistDate, _sequence, _creditid, pSource, pDocType, pDocNumber, pNotes, pMiscid, pAmount ); -- Now the debit INSERT INTO sltrans ( sltrans_journalnumber, sltrans_posted, sltrans_created, sltrans_date, sltrans_sequence, sltrans_accnt_id, sltrans_source, sltrans_doctype, sltrans_docnumber, sltrans_notes, sltrans_misc_id, sltrans_amount ) VALUES ( pJournalNumber, FALSE, CURRENT_TIMESTAMP, pDistDate, _sequence, _debitid, pSource, pDocType, pDocNumber, pNotes, pMiscid, (pAmount * -1) ); ELSE -- First the credit INSERT INTO gltrans ( gltrans_journalnumber, gltrans_posted, gltrans_exported, gltrans_created, gltrans_date, gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_doctype, gltrans_docnumber, gltrans_notes, gltrans_misc_id, gltrans_amount ) VALUES ( pJournalNumber, FALSE, FALSE, CURRENT_TIMESTAMP, pDistDate, _sequence, _creditid, pSource, pDocType, pDocNumber, pNotes, pMiscid, pAmount ); -- Now the debit INSERT INTO gltrans ( gltrans_journalnumber, gltrans_posted, gltrans_exported, gltrans_created, gltrans_date, gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_doctype, gltrans_docnumber, gltrans_notes, gltrans_misc_id, gltrans_amount ) VALUES ( pJournalNumber, FALSE, FALSE, CURRENT_TIMESTAMP, pDistDate, _sequence, _debitid, pSource, pDocType, pDocNumber, pNotes, pMiscid, (pAmount * -1) ); IF (pPostTrialBal) THEN PERFORM postIntoTrialBalance(_sequence); END IF; END IF; RETURN _sequence; END; $_$; ALTER FUNCTION public.insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date, boolean, boolean) OWNER TO admin; -- -- Name: insertintoglseries(integer, text, text, text, integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION insertintoglseries(integer, text, text, text, integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; pSource ALIAS FOR $2; pDocType ALIAS FOR $3; pDocNumber ALIAS FOR $4; pAccntid ALIAS FOR $5; pAmount ALIAS FOR $6; _returnValue INTEGER; BEGIN SELECT insertIntoGLSeries( pSequence, pSource, pDocType, pDocNumber, pAccntid, pAmount, CURRENT_DATE, '' ) INTO _returnValue; RETURN _returnValue; END; $_$; ALTER FUNCTION public.insertintoglseries(integer, text, text, text, integer, numeric) OWNER TO admin; -- -- Name: insertintoglseries(integer, text, text, text, integer, numeric, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION insertintoglseries(integer, text, text, text, integer, numeric, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; pSource ALIAS FOR $2; pDocType ALIAS FOR $3; pDocNumber ALIAS FOR $4; pAccntid ALIAS FOR $5; pAmount ALIAS FOR $6; pDistDate ALIAS FOR $7; _returnValue INTEGER; BEGIN SELECT insertIntoGLSeries( pSequence, pSource, pDocType, pDocNumber, pAccntid, pAmount, pDistDate, '' ) INTO _returnValue; RETURN _returnValue; END; $_$; ALTER FUNCTION public.insertintoglseries(integer, text, text, text, integer, numeric, date) OWNER TO admin; -- -- Name: insertintoglseries(integer, text, text, text, integer, numeric, date, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION insertintoglseries(integer, text, text, text, integer, numeric, date, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; pSource ALIAS FOR $2; pDocType ALIAS FOR $3; pDocNumber ALIAS FOR $4; pAccntid ALIAS FOR $5; pAmount ALIAS FOR $6; pDistDate ALIAS FOR $7; pNotes ALIAS FOR $8; _returnValue INTEGER; BEGIN SELECT insertIntoGLSeries( pSequence, pSource, pDocType, pDocNumber, pAccntid, pAmount, pDistDate, pNotes, NULL ) INTO _returnValue; RETURN _returnValue; END; $_$; ALTER FUNCTION public.insertintoglseries(integer, text, text, text, integer, numeric, date, text) OWNER TO admin; -- -- Name: insertintoglseries(integer, text, text, text, integer, numeric, date, text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION insertintoglseries(integer, text, text, text, integer, numeric, date, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; pSource ALIAS FOR $2; pDocType ALIAS FOR $3; pDocNumber ALIAS FOR $4; pAccntid ALIAS FOR $5; pAmount ALIAS FOR $6; pDistDate ALIAS FOR $7; pNotes ALIAS FOR $8; pMiscid ALIAS FOR $9; _glseriesid INTEGER; BEGIN -- Check GL Interface metric IF (fetchMetricBool('InterfaceToGL') = false AND pSource IN ('I/M', 'P/D', 'S/R', 'W/O')) THEN RETURN 0; END IF; IF (fetchMetricBool('InterfaceAPToGL') = false AND pSource = 'A/P') THEN RETURN 0; END IF; IF (fetchMetricBool('InterfaceARToGL') = false AND pSource IN ('A/R', 'S/O', 'S/R')) THEN RETURN 0; END IF; -- Verify the target accnt IF ( (pAccntid IS NULL) OR (pAccntid = -1) ) THEN RETURN -1; END IF; -- refuse to accept postings into closed periods IF (SELECT BOOL_AND(COALESCE(period_closed, FALSE)) FROM accnt LEFT OUTER JOIN period ON (pDistDate BETWEEN period_start AND period_end) WHERE (accnt_id = pAccntid)) THEN RAISE EXCEPTION 'Cannot post to closed period (%).', pDistDate; RETURN -4; -- remove raise exception when all callers check return code END IF; -- refuse to accept postings into frozen periods without proper priv IF (SELECT NOT BOOL_AND(checkPrivilege('PostFrozenPeriod')) AND BOOL_AND(COALESCE(period_freeze, FALSE)) FROM accnt LEFT OUTER JOIN period ON (pDistDate BETWEEN period_start AND period_end) WHERE (accnt_id = pAccntid)) THEN RAISE EXCEPTION 'Cannot post to frozen period (%).', pDistDate; RETURN -4; -- remove raise exception when all callers check return code END IF; -- refuse to accept postings into nonexistent periods IF NOT EXISTS(SELECT period_id FROM period WHERE (pDistDate BETWEEN period_start AND period_end)) THEN RAISE EXCEPTION 'Cannot post to nonexistent period (%).', pDistDate; END IF; -- Insert into the glseries SELECT NEXTVAL('glseries_glseries_id_seq') INTO _glseriesid; INSERT INTO glseries ( glseries_id, glseries_sequence, glseries_source, glseries_doctype, glseries_docnumber, glseries_accnt_id, glseries_amount, glseries_distdate, glseries_notes, glseries_misc_id ) VALUES ( _glseriesid, pSequence, pSource, pDocType, pDocNumber, pAccntid, pAmount, pDistDate, pNotes, pMiscid ); RETURN _glseriesid; END; $_$; ALTER FUNCTION public.insertintoglseries(integer, text, text, text, integer, numeric, date, text, integer) OWNER TO admin; -- -- Name: invchead; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE invchead ( invchead_id integer NOT NULL, invchead_cust_id integer NOT NULL, invchead_shipto_id integer, invchead_ordernumber text, invchead_orderdate date, invchead_posted boolean NOT NULL, invchead_printed boolean NOT NULL, invchead_invcnumber text NOT NULL, invchead_invcdate date NOT NULL, invchead_shipdate date, invchead_ponumber text, invchead_shipvia text, invchead_fob text, invchead_billto_name text, invchead_billto_address1 text, invchead_billto_address2 text, invchead_billto_address3 text, invchead_billto_city text, invchead_billto_state text, invchead_billto_zipcode text, invchead_billto_phone text, invchead_shipto_name text, invchead_shipto_address1 text, invchead_shipto_address2 text, invchead_shipto_address3 text, invchead_shipto_city text, invchead_shipto_state text, invchead_shipto_zipcode text, invchead_shipto_phone text, invchead_salesrep_id integer, invchead_commission numeric(20,10) NOT NULL, invchead_terms_id integer, invchead_freight numeric(16,2) NOT NULL, invchead_misc_amount numeric(16,2) NOT NULL, invchead_misc_descrip text, invchead_misc_accnt_id integer, invchead_payment numeric(16,2), invchead_paymentref text, invchead_notes text, invchead_billto_country text, invchead_shipto_country text, invchead_prj_id integer, invchead_curr_id integer DEFAULT basecurrid(), invchead_gldistdate date, invchead_recurring boolean DEFAULT false NOT NULL, invchead_recurring_interval integer, invchead_recurring_type text, invchead_recurring_until date, invchead_recurring_invchead_id integer, invchead_shipchrg_id integer, invchead_taxzone_id integer, invchead_void boolean DEFAULT false, invchead_saletype_id integer, invchead_shipzone_id integer, CONSTRAINT invchead_invchead_invcnumber_check CHECK ((invchead_invcnumber <> ''::text)) ); ALTER TABLE invchead OWNER TO admin; -- -- Name: TABLE invchead; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE invchead IS 'Invoice header information'; -- -- Name: COLUMN invchead.invchead_recurring; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN invchead.invchead_recurring IS 'Deprecated.'; -- -- Name: COLUMN invchead.invchead_recurring_interval; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN invchead.invchead_recurring_interval IS 'Deprecated.'; -- -- Name: COLUMN invchead.invchead_recurring_type; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN invchead.invchead_recurring_type IS 'Deprecated.'; -- -- Name: COLUMN invchead.invchead_recurring_until; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN invchead.invchead_recurring_until IS 'Deprecated.'; -- -- Name: COLUMN invchead.invchead_saletype_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN invchead.invchead_saletype_id IS 'Associated sale type for invoice.'; -- -- Name: COLUMN invchead.invchead_shipzone_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN invchead.invchead_shipzone_id IS 'Associated shipping zone for invoice.'; -- -- Name: prj; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE prj ( prj_id integer NOT NULL, prj_number text NOT NULL, prj_name text NOT NULL, prj_descrip text, prj_status character(1) NOT NULL, prj_so boolean, prj_wo boolean, prj_po boolean, prj_owner_username text, prj_start_date date, prj_due_date date, prj_assigned_date date, prj_completed_date date, prj_username text, prj_recurring_prj_id integer, prj_crmacct_id integer, prj_cntct_id integer, prj_prjtype_id integer, CONSTRAINT prj_prj_number_check CHECK ((prj_number <> ''::text)), CONSTRAINT prj_prj_status_check CHECK ((prj_status = ANY (ARRAY['P'::bpchar, 'O'::bpchar, 'C'::bpchar]))) ); ALTER TABLE prj OWNER TO admin; -- -- Name: TABLE prj; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE prj IS 'Project information'; -- -- Name: COLUMN prj.prj_recurring_prj_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN prj.prj_recurring_prj_id IS 'The first prj record in the series if this is a recurring Project. If the prj_recurring_prj_id is the same as the prj_id, this record is the first in the series.'; -- -- Name: saletype; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE saletype ( saletype_id integer NOT NULL, saletype_code text NOT NULL, saletype_descr text, saletype_active boolean DEFAULT true NOT NULL, saletype_default boolean DEFAULT false NOT NULL ); ALTER TABLE saletype OWNER TO admin; -- -- Name: TABLE saletype; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE saletype IS 'Type or Origination of Sale.'; -- -- Name: COLUMN saletype.saletype_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN saletype.saletype_id IS 'Sequence identifier for sale type.'; -- -- Name: COLUMN saletype.saletype_code; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN saletype.saletype_code IS 'User defined identifier for sale type.'; -- -- Name: COLUMN saletype.saletype_descr; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN saletype.saletype_descr IS 'Description for sale type.'; -- -- Name: COLUMN saletype.saletype_active; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN saletype.saletype_active IS 'Boolean to deactivate a sale type.'; -- -- Name: shipzone; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE shipzone ( shipzone_id integer DEFAULT nextval(('shipzone_shipzone_id_seq'::text)::regclass) NOT NULL, shipzone_name text NOT NULL, shipzone_descrip text, CONSTRAINT shipzone_shipzone_name_check CHECK ((shipzone_name <> ''::text)) ); ALTER TABLE shipzone OWNER TO admin; -- -- Name: TABLE shipzone; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE shipzone IS 'Shipping Zone information'; SET search_path = api, pg_catalog; -- -- Name: invoice; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW invoice AS SELECT invchead.invchead_invcnumber AS invoice_number, invchead.invchead_ordernumber AS order_number, invchead.invchead_invcdate AS invoice_date, invchead.invchead_shipdate AS ship_date, invchead.invchead_orderdate AS order_date, saletype.saletype_code AS sale_type, salesrep.salesrep_number AS sales_rep, invchead.invchead_commission AS commission, COALESCE(taxzone.taxzone_code, 'None'::text) AS tax_zone, terms.terms_code AS terms, custinfo.cust_number AS customer_number, invchead.invchead_billto_name AS billto_name, invchead.invchead_billto_address1 AS billto_address1, invchead.invchead_billto_address2 AS billto_address2, invchead.invchead_billto_address3 AS billto_address3, invchead.invchead_billto_city AS billto_city, invchead.invchead_billto_state AS billto_state, invchead.invchead_billto_zipcode AS billto_postal_code, invchead.invchead_billto_country AS billto_country, invchead.invchead_billto_phone AS billto_phone, shiptoinfo.shipto_num AS shipto_number, invchead.invchead_shipto_name AS shipto_name, invchead.invchead_shipto_address1 AS shipto_address1, invchead.invchead_shipto_address2 AS shipto_address2, invchead.invchead_shipto_address3 AS shipto_address3, invchead.invchead_shipto_city AS shipto_city, invchead.invchead_shipto_state AS shipto_state, invchead.invchead_shipto_zipcode AS shipto_postal_code, invchead.invchead_shipto_country AS shipto_country, shipzone.shipzone_name AS shipto_shipzone, invchead.invchead_shipto_phone AS shipto_phone, invchead.invchead_ponumber AS po_number, invchead.invchead_shipvia AS ship_via, prj.prj_number AS project_number, invchead.invchead_fob AS fob, invchead.invchead_misc_descrip AS misc_charge_description, invchead.invchead_misc_amount AS misc_charge, CASE WHEN (invchead.invchead_misc_accnt_id = (-1)) THEN NULL::text ELSE public.formatglaccount(invchead.invchead_misc_accnt_id) END AS misc_charge_account_number, invchead.invchead_freight AS freight, curr.curr_abbr AS currency, invchead.invchead_payment AS payment, invchead.invchead_notes AS notes FROM (((((((((public.invchead LEFT JOIN public.custinfo ON ((custinfo.cust_id = invchead.invchead_cust_id))) LEFT JOIN public.shiptoinfo ON ((shiptoinfo.shipto_id = invchead.invchead_shipto_id))) LEFT JOIN public.prj ON ((prj.prj_id = invchead.invchead_prj_id))) LEFT JOIN public.curr_symbol curr ON ((curr.curr_id = invchead.invchead_curr_id))) LEFT JOIN public.salesrep ON ((salesrep.salesrep_id = invchead.invchead_salesrep_id))) LEFT JOIN public.terms ON ((terms.terms_id = invchead.invchead_terms_id))) LEFT JOIN public.taxzone ON ((taxzone.taxzone_id = invchead.invchead_taxzone_id))) LEFT JOIN public.saletype ON ((invchead.invchead_saletype_id = saletype.saletype_id))) LEFT JOIN public.shipzone ON ((invchead.invchead_shipzone_id = shipzone.shipzone_id))); ALTER TABLE invoice OWNER TO admin; -- -- Name: VIEW invoice; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW invoice IS ' This view can be used as an interface to import Invioce Header data directly into the system. Required fields will be checked and default values will be populated'; SET search_path = public, pg_catalog; -- -- Name: insertinvoice(api.invoice); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION insertinvoice(api.invoice) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNew ALIAS FOR $1; BEGIN -- NOTE: (SELECT getCustId(...)) seems redundant, but it actually produces -- a HUGE performance increase because it makes the Postgres query planner -- use an index scan rather than an sequential table scan on cust_id INSERT INTO invchead ( invchead_invcnumber, invchead_ordernumber, invchead_invcdate, invchead_shipdate, invchead_orderdate, invchead_printed, invchead_posted, invchead_salesrep_id, invchead_commission, invchead_taxzone_id, invchead_terms_id, invchead_cust_id, invchead_billto_name, invchead_billto_address1, invchead_billto_address2, invchead_billto_address3, invchead_billto_city, invchead_billto_state, invchead_billto_zipcode, invchead_billto_country, invchead_billto_phone, invchead_shipto_id, invchead_shipto_name, invchead_shipto_address1, invchead_shipto_address2, invchead_shipto_address3, invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode, invchead_shipto_country, invchead_shipto_phone, invchead_ponumber, invchead_shipvia, invchead_prj_id, invchead_fob, invchead_misc_descrip, invchead_misc_amount, invchead_misc_accnt_id, invchead_freight, invchead_curr_id, invchead_payment, invchead_notes, invchead_saletype_id, invchead_shipzone_id ) SELECT (CASE -- use a case here so we don't unnecessarily fetch a new invoice number WHEN pNew.invoice_number IS NULL THEN CAST(fetchInvcNumber() AS TEXT) WHEN pNew.invoice_number = '' THEN CAST(fetchInvcNumber() AS TEXT) ELSE pNew.invoice_number END), pNew.order_number, COALESCE(pNew.invoice_date, CURRENT_DATE), pNew.ship_date, pNew.order_date, FALSE, FALSE, COALESCE(getSalesRepId(pNew.sales_rep),shipto_salesrep_id,cust_salesrep_id), COALESCE(pNew.commission, 0), CASE WHEN pNew.tax_zone = 'None' THEN NULL ELSE COALESCE(getTaxZoneId(pNew.tax_zone),shipto_taxzone_id,cust_taxzone_id) END, COALESCE(getTermsId(pNew.terms),cust_terms_id), (SELECT getCustId(pNew.customer_number)), COALESCE(pNew.billto_name, cohead_billtoname, cust_name), COALESCE(pNew.billto_address1, cohead_billtoaddress1, addr_line1), COALESCE(pNew.billto_address2, cohead_billtoaddress2, addr_line2), COALESCE(pNew.billto_address3, cohead_billtoaddress3, addr_line3), COALESCE(pNew.billto_city, cohead_billtocity, addr_city), COALESCE(pNew.billto_state, cohead_billtostate, addr_state), COALESCE(pNew.billto_postal_code, cohead_billtozipcode, addr_postalcode), COALESCE(pNew.billto_country, cohead_billtocountry, addr_country), COALESCE(pNew.billto_phone, ''), COALESCE(shipto_id,-1), pNew.shipto_name, pNew.shipto_address1, pNew.shipto_address2, pNew.shipto_address3, pNew.shipto_city, pNew.shipto_state, pNew.shipto_postal_code, pNew.shipto_country, pNew.shipto_phone, COALESCE(pNew.po_number, ''), COALESCE(pNew.ship_via,shipto_shipvia,cust_shipvia), COALESCE(getPrjId(pNew.project_number),-1), COALESCE(pNew.fob,fetchDefaultFob(( SELECT CAST(usrpref_value AS INTEGER) FROM usrpref, whsinfo WHERE ((warehous_id=CAST(usrpref_value AS INTEGER)) AND (warehous_shipping) AND (warehous_active) AND (usrpref_username=getEffectiveXtUser()) AND (usrpref_name='PreferredWarehouse') ) ))), pNew.misc_charge_description, COALESCE(pNew.misc_charge, 0), COALESCE(getGlAccntId(pNew.misc_charge_account_number),-1), COALESCE(pNew.freight, 0), COALESCE(getCurrId(pNew.currency),( SELECT cust_curr_id FROM custinfo WHERE (cust_id=(SELECT getCustId(pNew.customer_number))) ),basecurrid()), COALESCE(pNew.payment,0), COALESCE(pNew.notes,''), getSaleTypeId(pNew.sale_type), getShipZoneId(pNew.shipto_shipzone) FROM custinfo LEFT OUTER JOIN shiptoinfo ON (shipto_id=(SELECT CASE WHEN getShiptoId(pNew.customer_number,pNew.shipto_number) IS NOT NULL THEN getShiptoId(pNew.customer_number,pNew.shipto_number) ELSE (SELECT shipto_id FROM shiptoinfo WHERE shipto_cust_id=cust_id AND shipto_default) END)) LEFT OUTER JOIN cohead ON (cohead_number=pNEW.order_number) LEFT OUTER JOIN cntct ON (cntct_id=cust_cntct_id) LEFT OUTER JOIN addr ON (addr_id=cntct_addr_id) WHERE cust_id = (SELECT getCustId(pNew.customer_number)); RETURN TRUE; END; $_$; ALTER FUNCTION public.insertinvoice(api.invoice) OWNER TO admin; -- -- Name: invcitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE invcitem ( invcitem_id integer NOT NULL, invcitem_invchead_id integer NOT NULL, invcitem_linenumber integer, invcitem_item_id integer, invcitem_warehous_id integer DEFAULT (-1), invcitem_custpn text, invcitem_number text, invcitem_descrip text, invcitem_ordered numeric(20,6) NOT NULL, invcitem_billed numeric(20,6) NOT NULL, invcitem_custprice numeric(20,4), invcitem_price numeric(20,4) NOT NULL, invcitem_notes text, invcitem_salescat_id integer, invcitem_taxtype_id integer, invcitem_qty_uom_id integer, invcitem_qty_invuomratio numeric(20,10) NOT NULL, invcitem_price_uom_id integer, invcitem_price_invuomratio numeric(20,10) NOT NULL, invcitem_coitem_id integer, invcitem_updateinv boolean DEFAULT false, invcitem_rev_accnt_id integer ); ALTER TABLE invcitem OWNER TO admin; -- -- Name: TABLE invcitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE invcitem IS 'Invoice Line Item information'; SET search_path = api, pg_catalog; -- -- Name: invoiceline; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW invoiceline AS SELECT invchead.invchead_invcnumber AS invoice_number, invcitem.invcitem_linenumber AS line_number, item.item_number, invcitem.invcitem_number AS misc_item_number, whsinfo.warehous_code AS site, invcitem.invcitem_descrip AS misc_item_description, salescat.salescat_name AS sales_category, invcitem.invcitem_custpn AS customer_part_number, invcitem.invcitem_ordered AS qty_ordered, invcitem.invcitem_billed AS qty_billed, invcitem.invcitem_updateinv AS update_inventory, invcitem.invcitem_price AS net_unit_price, COALESCE(taxtype.taxtype_name, 'None'::text) AS tax_type, COALESCE(qty_uom.uom_name, 'None'::text) AS qty_uom, COALESCE(price_uom.uom_name, 'None'::text) AS price_uom, invcitem.invcitem_notes AS notes, CASE WHEN (invcitem.invcitem_rev_accnt_id IS NOT NULL) THEN public.formatglaccount(invcitem.invcitem_rev_accnt_id) ELSE NULL::text END AS alternate_rev_account FROM (((((((public.invcitem LEFT JOIN public.invchead ON ((invcitem.invcitem_invchead_id = invchead.invchead_id))) LEFT JOIN public.item ON ((item.item_id = invcitem.invcitem_item_id))) LEFT JOIN public.whsinfo ON ((invcitem.invcitem_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.salescat ON ((salescat.salescat_id = invcitem.invcitem_salescat_id))) LEFT JOIN public.taxtype ON ((taxtype.taxtype_id = invcitem.invcitem_taxtype_id))) LEFT JOIN public.uom qty_uom ON ((qty_uom.uom_id = invcitem.invcitem_qty_uom_id))) LEFT JOIN public.uom price_uom ON ((price_uom.uom_id = invcitem.invcitem_price_uom_id))); ALTER TABLE invoiceline OWNER TO admin; -- -- Name: VIEW invoiceline; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW invoiceline IS ' This view can be used as an interface to import Invoice Line Items data directly into the system. Required fields will be checked and default values will be populated'; SET search_path = public, pg_catalog; -- -- Name: insertinvoicelineitem(api.invoiceline); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION insertinvoicelineitem(api.invoiceline) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNew ALIAS FOR $1; _r RECORD; BEGIN INSERT INTO invcitem ( invcitem_invchead_id, invcitem_linenumber, invcitem_item_id, invcitem_warehous_id, invcitem_custpn, invcitem_number, invcitem_descrip, invcitem_ordered, invcitem_billed, invcitem_updateinv, invcitem_custprice, invcitem_price, invcitem_notes, invcitem_salescat_id, invcitem_taxtype_id, invcitem_qty_uom_id, invcitem_qty_invuomratio, invcitem_price_uom_id, invcitem_price_invuomratio, invcitem_rev_accnt_id ) SELECT invchead_id, COALESCE(pNew.line_number,( SELECT (COALESCE(MAX(invcitem_linenumber), 0) + 1) FROM invcitem WHERE (invcitem_invchead_id=invchead_id) )), COALESCE(item_id, -1), COALESCE(getwarehousid(pNew.site,'ALL'),-1), pNew.customer_part_number, (CASE WHEN item_id IS NULL THEN pNew.misc_item_number ELSE NULL END), (CASE WHEN item_id IS NULL THEN pNew.misc_item_description ELSE NULL END), pNew.qty_ordered, COALESCE(pNew.qty_billed, 0), COALESCE(pNew.update_inventory,FALSE), 0, -- invcitem_custprice COALESCE(pNew.net_unit_price,itemPrice(item_id,invchead_cust_id, invchead_shipto_id,pNew.qty_ordered,invchead_curr_id,invchead_orderdate)), COALESCE(pNew.notes,''), CASE WHEN item_id IS NULL THEN (SELECT salescat_id FROM salescat WHERE salescat_name = pNew.sales_category) ELSE NULL END, taxtype_id, CASE WHEN item_id IS NOT NULL THEN COALESCE((SELECT uom_id FROM uom WHERE (uom_name=pNew.qty_uom)), item_price_uom_id) ELSE NULL END, CASE WHEN item_id IS NOT NULL THEN itemuomtouomratio(item_id, COALESCE((SELECT uom_id FROM uom WHERE uom_name=pNew.qty_uom),item_price_uom_id), item_price_uom_id ) ELSE 1 END, CASE WHEN item_id IS NOT NULL THEN COALESCE((SELECT uom_id FROM uom WHERE uom_name=pNew.price_uom),item_price_uom_id) ELSE NULL END, CASE WHEN item_id IS NOT NULL THEN itemuomtouomratio(item_id, COALESCE((SELECT uom_id FROM uom WHERE uom_name=pNew.price_uom),item_price_uom_id), item_price_uom_id ) ELSE 1 END, getGlAccntId(pNew.alternate_rev_account) FROM invchead LEFT OUTER JOIN item ON (item_id=getItemId(pNew.item_number)) LEFT OUTER JOIN taxtype ON (taxtype_id=CASE WHEN pNew.tax_type IS NULL THEN getItemTaxType(item_id,invchead_taxzone_id) WHEN pNew.tax_type = 'None' THEN NULL ELSE (SELECT taxtype_id FROM taxtype WHERE taxtype_name=pNew.tax_type) END) WHERE (invchead_invcnumber=pNew.invoice_number) AND (invchead_posted=FALSE); RETURN TRUE; END; $_$; ALTER FUNCTION public.insertinvoicelineitem(api.invoiceline) OWNER TO admin; -- -- Name: insertitemcost(integer, integer, integer, numeric, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION insertitemcost(integer, integer, integer, numeric, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemId ALIAS FOR $1; pCostElemId ALIAS FOR $2; pCurrId ALIAS FOR $3; pCost ALIAS FOR $4; pPostToStandard ALIAS FOR $5; _itemcost_id INTEGER; _update_return INTEGER; _postcost_return BOOLEAN; --This function is used with the api.itemcost View for updating and inserting --into the itemcosts table BEGIN IF (pCost IS NULL OR pCost < 0) THEN RAISE EXCEPTION 'itemcost Actual Cost Invalid ', pCost; END IF; -- Check for uniqueness SELECT itemcost_id INTO _itemcost_id FROM itemcost WHERE ( (itemcost_item_id = pItemId) AND (itemcost_costelem_id = pCostElemId) AND (NOT itemcost_lowlevel) ); IF (FOUND) THEN RAISE EXCEPTION 'itemcost already exists for this Item and Cost Element'; END IF; -- Check for valid combination of item_type and costelem_type IF (SELECT (COUNT(*) > 0) FROM item, costelem WHERE (item_id=pItemId) AND (costelem_id=pCostElemId) AND (item_type IN ('M', 'F', 'B', 'C', 'T')) AND (costelem_type IN ('Material'))) THEN RAISE EXCEPTION 'itemcost of this type is invalid for Manufactured Item'; END IF; IF (SELECT (COUNT(*) > 0) FROM item, costelem WHERE (item_id=pItemId) AND (costelem_id=pCostElemId) AND (item_type IN ('O', 'P')) AND (costelem_type IN ('Direct Labor', 'Overhead', 'Machine Overhead'))) THEN RAISE EXCEPTION 'itemcost of this type is invalid for Purchased Item'; END IF; IF (pCost > 0) THEN SELECT NEXTVAL('itemcost_itemcost_id_seq') INTO _itemcost_id; INSERT INTO itemcost ( itemcost_id, itemcost_item_id, itemcost_costelem_id, itemcost_lowlevel, itemcost_stdcost, itemcost_posted, itemcost_actcost, itemcost_updated, itemcost_curr_id ) VALUES ( _itemcost_id, pItemId, pCostElemId, FALSE, 0, startOfTime(), pCost, CURRENT_DATE, pCurrId ); --Only Post Cost to standard if the parameter is set to true IF (pPostToStandard) THEN IF (NOT checkPrivilege('PostStandardCosts')) THEN RAISE EXCEPTION 'You do not have privileges to poststandard itemcosts. Set api.itemcost post_to_standard to false'; END IF; SELECT postcost(_itemcost_id) INTO _postcost_return; IF (NOT _postcost_return) THEN RETURN -2; END IF; END IF; ELSE RETURN -1; END IF; RETURN _itemcost_id; END; $_$; ALTER FUNCTION public.insertitemcost(integer, integer, integer, numeric, boolean) OWNER TO admin; -- -- Name: insertsalesline(api.salesline); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION insertsalesline(api.salesline) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNEW ALIAS FOR $1; _r RECORD; BEGIN IF (NOT EXISTS (SELECT cohead_id FROM cohead WHERE cohead_number=pNEW.order_number)) THEN RAISE EXCEPTION 'Function insertSalesLine failed because Sales Order % not found', pNEW.order_number; END IF; IF (NOT EXISTS (SELECT item_id FROM item WHERE item_number=pNEW.item_number)) THEN RAISE EXCEPTION 'Function insertSalesLine failed because Item Number % not found', pNEW.item_number; END IF; SELECT * INTO _r FROM cohead, itemsite, item, whsinfo WHERE ((cohead_number=pNEW.order_number) AND (itemsite_warehous_id=warehous_id AND (itemsite_item_id=item_id) AND (itemsite_active) AND (item_number=pNEW.item_number) AND (warehous_active) AND (warehous_id=COALESCE(getWarehousId(pNEW.sold_from_site,'ALL'),cohead_warehous_id,fetchprefwarehousid())))); IF (NOT FOUND) THEN RAISE EXCEPTION 'Function insertSalesLine failed with unknown failure to retrieve Sales Order'; END IF; INSERT INTO coitem ( coitem_cohead_id, coitem_linenumber, coitem_itemsite_id, coitem_status, coitem_scheddate, coitem_promdate, coitem_qtyord, coitem_qty_uom_id, coitem_qty_invuomratio, coitem_qtyshipped, coitem_unitcost, coitem_price, coitem_price_uom_id, coitem_price_invuomratio, coitem_custprice, coitem_order_id, coitem_memo, coitem_imported, coitem_qtyreturned, coitem_custpn, coitem_order_type, coitem_substitute_item_id, coitem_prcost, coitem_taxtype_id, coitem_warranty, coitem_cos_accnt_id, coitem_rev_accnt_id) VALUES ( _r.cohead_id, pNEW.line_number::INTEGER, _r.itemsite_id, pNEW.status, pNEW.scheduled_date, pNEW.promise_date, pNEW.qty_ordered, COALESCE(getUomId(pNEW.qty_uom),_r.item_inv_uom_id), itemuomtouomratio(_r.item_id,COALESCE(getUomId(pNEW.qty_uom),_r.item_inv_uom_id),_r.item_inv_uom_id), 0, stdCost(_r.item_id), COALESCE(pNEW.net_unit_price,itemPrice(_r.item_id,_r.cohead_cust_id, _r.cohead_shipto_id,pNEW.qty_ordered,_r.cohead_curr_id,_r.cohead_orderdate)), COALESCE(getUomId(pNEW.price_uom),_r.item_price_uom_id), itemuomtouomratio(_r.item_id,COALESCE(getUomId(pNEW.price_uom),_r.item_price_uom_id),_r.item_price_uom_id), itemPrice(_r.item_id,_r.cohead_cust_id,_r.cohead_shipto_id,pNEW.qty_ordered,_r.cohead_curr_id,_r.cohead_orderdate), -1, pNEW.notes, true, 0, pNEW.customer_pn, CASE WHEN ((pNEW.create_order AND (_r.item_type = 'M')) OR ((pNEW.create_order IS NULL) AND _r.itemsite_createwo)) THEN 'W' WHEN ((pNEW.create_order AND (_r.item_type = 'P')) OR ((pNEW.create_order IS NULL) AND _r.itemsite_createsopr)) THEN 'R' WHEN ((pNEW.create_order AND (_r.item_type = 'P') AND (_r.itemsite_createsopo)) OR ((pNEW.create_order IS NULL) AND _r.itemsite_createsopo)) THEN 'P' END, getitemid(pNEW.substitute_for), pNEW.overwrite_po_price, COALESCE(getTaxTypeId(pNEW.tax_type), getItemTaxType(_r.itemsite_item_id, _r.cohead_taxzone_id)), pNEW.warranty, getGlAccntId(pNEW.alternate_cos_account), getGlAccntId(pNEW.alternate_rev_account) ); RETURN TRUE; END; $_$; ALTER FUNCTION public.insertsalesline(api.salesline) OWNER TO admin; -- -- Name: intervaltominutes(interval); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION intervaltominutes(interval) RETURNS numeric LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT (EXTRACT(DAY FROM $1) * 24 * 60 + EXTRACT(HOUR FROM $1) * 60 + EXTRACT(MINUTE FROM $1) + ROUND((EXTRACT(SECOND FROM $1) / 60)::NUMERIC, 4))::NUMERIC AS result $_$; ALTER FUNCTION public.intervaltominutes(interval) OWNER TO admin; -- -- Name: invadjustment(integer, numeric, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION invadjustment(integer, numeric, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN invAdjustment($1, $2, $3, $4, CURRENT_TIMESTAMP, NULL); END; $_$; ALTER FUNCTION public.invadjustment(integer, numeric, text, text) OWNER TO admin; -- -- Name: invadjustment(integer, numeric, text, text, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION invadjustment(integer, numeric, text, text, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN invAdjustment($1, $2, $3, $4, $5, NULL); END; $_$; ALTER FUNCTION public.invadjustment(integer, numeric, text, text, timestamp with time zone) OWNER TO admin; -- -- Name: invadjustment(integer, numeric, text, text, timestamp with time zone, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION invadjustment(integer, numeric, text, text, timestamp with time zone, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pQty ALIAS FOR $2; pDocumentNumber ALIAS FOR $3; pComments ALIAS FOR $4; pGlDistTS ALIAS FOR $5; pCostValue ALIAS FOR $6; _invhistid INTEGER; _itemlocSeries INTEGER; BEGIN -- Make sure the passed itemsite points to a real item IF ( ( SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J') FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ) ) ) THEN RETURN 0; END IF; SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; SELECT postInvTrans( itemsite_id, 'AD', pQty, 'I/M', 'AD', pDocumentNumber, '', ('Miscellaneous Adjustment for item ' || item_number || E'\n' || pComments), costcat_asset_accnt_id, costcat_adjustment_accnt_id, _itemlocSeries, pGlDistTS, pCostValue) INTO _invhistid FROM itemsite, item, costcat WHERE ( (itemsite_item_id=item_id) AND (itemsite_costcat_id=costcat_id) AND (itemsite_id=pItemsiteid) ); RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.invadjustment(integer, numeric, text, text, timestamp with time zone, numeric) OWNER TO admin; -- -- Name: invexpense(integer, numeric, integer, text, text, timestamp with time zone, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION invexpense(pitemsiteid integer, pqty numeric, pexpcatid integer, pdocumentnumber text, pcomments text, pgldistts timestamp with time zone DEFAULT now(), pprjid integer DEFAULT NULL::integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _invhistid INTEGER; _itemlocSeries INTEGER; BEGIN -- Make sure the passed itemsite points to a real item IF ( ( SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J') FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ) ) ) THEN RETURN 0; END IF; SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; SELECT postInvTrans( itemsite_id, 'EX', pQty, 'I/M', 'EX', pDocumentNumber, '', CASE WHEN (pQty < 0) THEN ('Reverse Material Expense for item ' || item_number || E'\n' || pComments) ELSE ('Material Expense for item ' || item_number || E'\n' || pComments) END, getPrjAccntId(pPrjid, expcat_exp_accnt_id), costcat_asset_accnt_id, _itemlocSeries, pGlDistTS) INTO _invhistid FROM itemsite, item, costcat, expcat WHERE ( (itemsite_item_id=item_id) AND (itemsite_costcat_id=costcat_id) AND (itemsite_id=pItemsiteid) AND (expcat_id=pExpcatid) ); INSERT INTO invhistexpcat (invhistexpcat_invhist_id, invhistexpcat_expcat_id) VALUES (_invhistid, pExpcatid); RETURN _itemlocSeries; END; $$; ALTER FUNCTION public.invexpense(pitemsiteid integer, pqty numeric, pexpcatid integer, pdocumentnumber text, pcomments text, pgldistts timestamp with time zone, pprjid integer) OWNER TO admin; -- -- Name: invhistsense(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION invhistsense(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvhistId ALIAS FOR $1; _count INTEGER; _row RECORD; _sense INTEGER; BEGIN SELECT invhist_transtype, invhist_ordnumber, itemsite_warehous_id INTO _row FROM invhist JOIN itemsite ON (itemsite_id=invhist_itemsite_id) WHERE (invhist_id=pInvhistId); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count = 0) THEN RAISE EXCEPTION 'Record not found for invhist_id=%',pInvhistId; END IF; -- increase inventory: AD RM RT RP RR RS RX RB TR -- decrease inventory: IM IB IT SH SI EX RI -- TS and TR are special: shipShipment and recallShipment should not change -- QOH at the Transfer Order src whs (as this was done by issueToShipping) -- but postReceipt should change QOH at the transit whs IF (_row.invhist_transtype='TS') THEN _sense := CASE WHEN (SELECT tohead_trns_warehous_id=_row.itemsite_warehous_id FROM tohead WHERE (tohead_number=_row.invhist_ordnumber)) THEN -1 ELSE 0 END; ELSIF (_row.invhist_transtype='TR') THEN _sense := CASE WHEN (SELECT tohead_src_warehous_id=_row.itemsite_warehous_id FROM tohead WHERE (tohead_number=_row.invhist_ordnumber)) THEN 0 ELSE 1 END; ELSIF (_row.invhist_transtype IN ('IM', 'IB', 'IT', 'SH', 'SI', 'EX', 'RI')) THEN _sense := -1; ELSE _sense := 1; END IF; RETURN _sense; END; $_$; ALTER FUNCTION public.invhistsense(integer) OWNER TO admin; -- -- Name: invhisttrig(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION invhisttrig() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Need to allow 'temporary' negative for average costed item that has been frozen. -- Check at itemsite after all of the transactions have been thawed will ensure -- that final Qty On Hand is positive. -- IF (NEW.invhist_qoh_after < 0 AND NEW.invhist_costmethod = 'A') THEN -- RAISE EXCEPTION 'Invhist (%) is recording with average costing and is not allowed to have a negative quantity on hand.', NEW.invhist_id; -- END IF; -- #19160 Exclude frozen check when "Edit Transaction" ABC analyze flag is amended IF ( (TG_OP = 'INSERT') OR (TG_OP = 'UPDATE' AND OLD.invhist_analyze = NEW.invhist_analyze)) THEN IF ( ( SELECT itemsite_freeze FROM itemsite WHERE (itemsite_id=NEW.invhist_itemsite_id) ) ) THEN NEW.invhist_posted = FALSE; END IF; END IF; -- never change the created timestamp, which defaults to CURRENT_TIMESTAMP IF (TG_OP != 'INSERT') THEN NEW.invhist_created = OLD.invhist_created; ELSE -- Always need a series id for distribution posting IF (NEW.invhist_series IS NULL) THEN RAISE EXCEPTION 'Column invhist_series may not be null.'; END IF; END IF; RETURN NEW; END; $$; ALTER FUNCTION public.invhisttrig() OWNER TO admin; -- -- Name: invoicetotal(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION invoicetotal(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvoiceId ALIAS FOR $1; _linesum NUMERIC; _linetax NUMERIC; _result NUMERIC; _allocated NUMERIC; _posted BOOLEAN; BEGIN SELECT SUM(ROUND(COALESCE((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / COALESCE(invcitem_price_invuomratio,1)), 0),2)) INTO _linesum FROM invcitem WHERE (invcitem_invchead_id=pInvoiceId); -- TODO: why sum on the result of select round(sum(), 2)? SELECT SUM(tax) INTO _linetax FROM (SELECT ROUND(SUM(COALESCE(taxdetail_tax, 0)),2) AS tax FROM tax JOIN calculateTaxDetailSummary('I', pInvoiceId, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id) AS data; SELECT noNeg(invchead_freight + invchead_misc_amount + COALESCE(_linetax, 0) + COALESCE(_linesum, 0)), invchead_posted INTO _result, _posted FROM invchead WHERE (invchead_id=pInvoiceId); IF NOT FOUND THEN RETURN 0; END IF; IF (_posted) THEN SELECT COALESCE(SUM(currToCurr(arapply_curr_id, aropen_curr_id, arapply_applied, aropen_docdate)),0) INTO _allocated FROM arapply, aropen, invchead WHERE ( (invchead_posted) AND (invchead_id=pInvoiceId) AND (aropen_docnumber=invchead_invcnumber) AND (aropen_doctype='I') AND (arapply_target_aropen_id=aropen_id) AND (arapply_reftype='S') AND (invchead_posted) ) ; ELSE SELECT COALESCE(SUM(CASE WHEN((aropen_amount - aropen_paid) >= currToCurr(aropenalloc_curr_id, aropen_curr_id, aropenalloc_amount, aropen_docdate)) THEN currToCurr(aropenalloc_curr_id, invchead_curr_id, aropenalloc_amount, aropen_docdate) ELSE currToCurr(aropen_curr_id, invchead_curr_id, aropen_amount - aropen_paid, aropen_docdate) END),0) INTO _allocated FROM invchead LEFT OUTER JOIN cohead ON (cohead_number=invchead_ordernumber) JOIN aropenalloc ON ((aropenalloc_doctype='I' AND aropenalloc_doc_id=invchead_id) OR (aropenalloc_doctype='S' AND aropenalloc_doc_id=cohead_id)) JOIN aropen ON (aropen_id=aropenalloc_aropen_id AND (aropen_amount - aropen_paid) > 0.0) WHERE ( (NOT invchead_posted) AND (invchead_id=pInvoiceId) ); END IF; RETURN _result - COALESCE(_allocated, 0); END; $_$; ALTER FUNCTION public.invoicetotal(integer) OWNER TO admin; -- -- Name: invreceipt(integer, numeric, text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION invreceipt(integer, numeric, text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN invReceipt($1, $2, $3, $4, $5, CURRENT_TIMESTAMP, NULL); END; $_$; ALTER FUNCTION public.invreceipt(integer, numeric, text, text, text) OWNER TO admin; -- -- Name: invreceipt(integer, numeric, text, text, text, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION invreceipt(integer, numeric, text, text, text, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN invReceipt($1, $2, $3, $4, $5, $6, NULL); END; $_$; ALTER FUNCTION public.invreceipt(integer, numeric, text, text, text, timestamp with time zone) OWNER TO admin; -- -- Name: invreceipt(integer, numeric, text, text, text, timestamp with time zone, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION invreceipt(integer, numeric, text, text, text, timestamp with time zone, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pQty ALIAS FOR $2; pOrdernumber ALIAS FOR $3; pDocumentNumber ALIAS FOR $4; pComments ALIAS FOR $5; pGlDistTS ALIAS FOR $6; pCostValue ALIAS FOR $7; _invhistid INTEGER; _itemlocSeries INTEGER; BEGIN -- Make sure the passed itemsite points to a real item IF ( ( SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J') FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ) ) ) THEN RETURN 0; END IF; SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; SELECT postInvTrans( itemsite_id, 'RX', pQty, 'I/M', 'RX', pDocumentNumber, '', ('Miscellaneous Receipt for item ' || item_number || E'\n' || pComments), costcat_asset_accnt_id, costcat_liability_accnt_id, _itemlocSeries, pGlDistTS, pCostValue) INTO _invhistid FROM itemsite, item, costcat WHERE ( (itemsite_item_id=item_id) AND (itemsite_costcat_id=costcat_id) AND (itemsite_id=pItemsiteid) ); RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.invreceipt(integer, numeric, text, text, text, timestamp with time zone, numeric) OWNER TO admin; -- -- Name: invscrap(integer, numeric, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION invscrap(integer, numeric, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN invScrap($1, $2, $3, $4, CURRENT_TIMESTAMP); END; $_$; ALTER FUNCTION public.invscrap(integer, numeric, text, text) OWNER TO admin; -- -- Name: invscrap(integer, numeric, text, text, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION invscrap(integer, numeric, text, text, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN invScrap($1, $2, $3, $4, $5, NULL); END; $_$; ALTER FUNCTION public.invscrap(integer, numeric, text, text, timestamp with time zone) OWNER TO admin; -- -- Name: invscrap(integer, numeric, text, text, timestamp with time zone, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION invscrap(integer, numeric, text, text, timestamp with time zone, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN invScrap($1, $2, $3, $4, $5, $6, NULL); END; $_$; ALTER FUNCTION public.invscrap(integer, numeric, text, text, timestamp with time zone, integer) OWNER TO admin; -- -- Name: invscrap(integer, numeric, text, text, timestamp with time zone, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION invscrap(integer, numeric, text, text, timestamp with time zone, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pQty ALIAS FOR $2; pDocumentNumber ALIAS FOR $3; pComments ALIAS FOR $4; pGlDistTS ALIAS FOR $5; pInvHistId ALIAS FOR $6; pPrjid ALIAS FOR $7; _invhistid INTEGER; _itemlocSeries INTEGER; BEGIN -- Make sure the passed itemsite points to a real item IF ( ( SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J') FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ) ) ) THEN RETURN 0; END IF; IF (pInvHistId IS NOT NULL) THEN SELECT invhist_series INTO _itemlocSeries FROM invhist WHERE invhist_id=pInvHistId; ELSE SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; END IF; SELECT postInvTrans( itemsite_id, 'SI', pQty, 'I/M', 'SI', pDocumentNumber, '', CASE WHEN (pQty < 0) THEN ('Reverse Material Scrap for item ' || item_number || E'\n' || pComments) ELSE ('Material Scrap for item ' || item_number || E'\n' || pComments) END, getPrjAccntId(pPrjid, costcat_scrap_accnt_id), costcat_asset_accnt_id, _itemlocSeries, pGlDistTS, NULL, pInvHistId) INTO _invhistid FROM itemsite, item, costcat WHERE ( (itemsite_item_id=item_id) AND (itemsite_costcat_id=costcat_id) AND (itemsite_id=pItemsiteid) ); RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.invscrap(integer, numeric, text, text, timestamp with time zone, integer, integer) OWNER TO admin; -- -- Name: isdba(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION isdba(text DEFAULT NULL::text) RETURNS boolean LANGUAGE sql AS $_$ SELECT (datdba=pg_roles.oid OR rolsuper) AS issuper FROM pg_database, pg_roles WHERE ((datname=current_database()) AND (rolname=COALESCE($1, getEffectiveXtUser()))); $_$; ALTER FUNCTION public.isdba(text) OWNER TO admin; -- -- Name: ismulticurr(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION ismulticurr() RETURNS boolean LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN (SELECT (count(*) > 1) FROM curr_symbol); END; $$; ALTER FUNCTION public.ismulticurr() OWNER TO admin; -- -- Name: isnumeric(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION isnumeric(text) RETURNS boolean LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pText ALIAS FOR $1; _cursor INTEGER; BEGIN IF ( (LENGTH(pText) = 0) OR (pText IS NULL) ) THEN RETURN FALSE; END IF; FOR _cursor IN 1..LENGTH(pText) LOOP IF (SUBSTRING(pText FROM _cursor FOR 1) NOT IN ( '0', '1', '2', '3', '4', '5' ,'6' ,'7' ,'8' ,'9' )) THEN RETURN FALSE; END IF; END LOOP; RETURN TRUE; END; $_$; ALTER FUNCTION public.isnumeric(text) OWNER TO admin; -- -- Name: issueallbalancetoshipping(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION issueallbalancetoshipping(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN issueAllBalanceToShipping('SO', $1, 0, NULL); END; $_$; ALTER FUNCTION public.issueallbalancetoshipping(integer) OWNER TO admin; -- -- Name: issueallbalancetoshipping(text, integer, integer, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION issueallbalancetoshipping(text, integer, integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; pheadid ALIAS FOR $2; _itemlocSeries INTEGER := $3; _timestamp TIMESTAMP WITH TIME ZONE := $4; _s RECORD; BEGIN IF (pordertype = 'SO') THEN FOR _s IN SELECT coitem_id, CASE WHEN (fetchMetricBool('RequireSOReservations')) THEN coitem_qtyreserved ELSE noNeg( coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping('SO', coitem_id) ) END AS _balance FROM coitem LEFT OUTER JOIN (itemsite JOIN item ON (itemsite_item_id=item_id)) ON (coitem_itemsite_id=itemsite_id) WHERE ( (coitem_status NOT IN ('C','X')) AND (item_type != 'K') AND (coitem_cohead_id=pheadid) ) LOOP IF (_s.balance <> 0) THEN _itemlocSeries := issueToShipping(pordertype, _s.coitem_id, _s.balance, _itemlocSeries, _timestamp); IF (_itemlocSeries < 0) THEN EXIT; END IF; END IF; END LOOP; ELSEIF (pordertype = 'TO') THEN FOR _s IN SELECT toitem_id, noNeg( toitem_qty_ordered - toitem_qty_shipped - qtyAtShipping('TO', toitem_id) ) AS balance FROM toitem WHERE ( (toitem_status NOT IN ('C','X')) AND (toitem_tohead_id=pheadid) ) LOOP IF (_s.balance <> 0) THEN _itemlocSeries := issueToShipping(pordertype, _s.toitem_id, _s.balance, _itemlocSeries, _timestamp); IF (_itemlocSeries < 0) THEN EXIT; END IF; END IF; END LOOP; ELSE RETURN -1; END IF; RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.issueallbalancetoshipping(text, integer, integer, timestamp with time zone) OWNER TO admin; -- -- Name: issuelinebalancetoshipping(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION issuelinebalancetoshipping(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN issueLineBalanceToShipping('SO', $1, NULL); END; $_$; ALTER FUNCTION public.issuelinebalancetoshipping(integer) OWNER TO admin; -- -- Name: issuelinebalancetoshipping(text, integer, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION issuelinebalancetoshipping(text, integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN issueLineBalanceToShipping($1, $2, $3, 0, NULL); END; $_$; ALTER FUNCTION public.issuelinebalancetoshipping(text, integer, timestamp with time zone) OWNER TO admin; -- -- Name: issuelinebalancetoshipping(text, integer, timestamp with time zone, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION issuelinebalancetoshipping(text, integer, timestamp with time zone, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; pitemid ALIAS FOR $2; ptimestamp ALIAS FOR $3; pitemlocseries ALIAS FOR $4; pinvhistid ALIAS FOR $5; _itemlocSeries INTEGER := 0; _qty NUMERIC; BEGIN _itemlocSeries := COALESCE(pitemlocseries,0); IF (pordertype = 'SO') THEN SELECT CASE WHEN (fetchMetricBool('RequireSOReservations')) THEN coitem_qtyreserved ELSE noNeg( coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping('SO', coitem_id) ) END INTO _qty FROM coitem WHERE (coitem_id=pitemid); ELSEIF (pordertype = 'TO') THEN SELECT noNeg( toitem_qty_ordered - toitem_qty_shipped - qtyAtShipping('TO', toitem_id) ) INTO _qty FROM toitem WHERE (toitem_id=pitemid); ELSE RETURN -1; END IF; IF (_qty > 0) THEN _itemlocSeries := issueToShipping(pordertype, pitemid, _qty, _itemlocSeries, ptimestamp, pinvhistid); END IF; RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.issuelinebalancetoshipping(text, integer, timestamp with time zone, integer, integer) OWNER TO admin; -- -- Name: issues(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION issues(text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTransType ALIAS FOR $1; BEGIN IF (pTransType IN ('IM', 'IB', 'IT')) THEN RETURN TRUE; ELSE RETURN FALSE; END IF; END; $_$; ALTER FUNCTION public.issues(text) OWNER TO admin; -- -- Name: issuetoshipping(integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION issuetoshipping(integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN issueToShipping('SO', $1, $2, 0, CURRENT_TIMESTAMP); END; $_$; ALTER FUNCTION public.issuetoshipping(integer, numeric) OWNER TO admin; -- -- Name: issuetoshipping(integer, numeric, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION issuetoshipping(integer, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN issueToShipping('SO', $1, $2, $3, CURRENT_TIMESTAMP); END; $_$; ALTER FUNCTION public.issuetoshipping(integer, numeric, integer) OWNER TO admin; -- -- Name: issuetoshipping(text, integer, numeric, integer, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION issuetoshipping(text, integer, numeric, integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN issueToShipping($1, $2, $3, $4, $5, NULL); END; $_$; ALTER FUNCTION public.issuetoshipping(text, integer, numeric, integer, timestamp with time zone) OWNER TO admin; -- -- Name: issuetoshipping(text, integer, numeric, integer, timestamp with time zone, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION issuetoshipping(pordertype text, pitemid integer, pqty numeric, pitemlocseries integer, ptimestamp timestamp with time zone, pinvhistid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _itemlocSeries INTEGER; _timestamp TIMESTAMP WITH TIME ZONE; _coholdtype TEXT; _balance NUMERIC; _invhistid INTEGER; _shipheadid INTEGER; _shipnumber INTEGER; _cntctid INTEGER; _p RECORD; _m RECORD; _value NUMERIC; _warehouseid INTEGER; _shipitemid INTEGER; _freight NUMERIC; BEGIN IF (pTimestamp IS NULL) THEN _timestamp := CURRENT_TIMESTAMP; ELSE _timestamp := pTimestamp; END IF; IF (pItemlocSeries = 0) THEN _itemlocSeries := NEXTVAL('itemloc_series_seq'); ELSE _itemlocSeries := pItemlocSeries; END IF; IF (pordertype = 'SO') THEN -- Check site security SELECT warehous_id INTO _warehouseid FROM coitem,itemsite,site() WHERE ((coitem_id=pitemid) AND (itemsite_id=coitem_itemsite_id) AND (warehous_id=itemsite_warehous_id)); IF (NOT FOUND) THEN RETURN 0; END IF; -- Check for average cost items going negative IF ( SELECT ( (itemsite_costmethod='A') AND ((itemsite_qtyonhand - round(pQty * coitem_qty_invuomratio, 6)) < 0.0) ) FROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id) WHERE (coitem_id=pitemid) ) THEN RETURN -20; END IF; -- Check auto registration IF ( SELECT COALESCE(itemsite_autoreg, FALSE) FROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id) WHERE (coitem_id=pitemid) ) THEN SELECT COALESCE(crmacct_cntct_id_1, -1) INTO _cntctid FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id) JOIN crmacct ON (crmacct_cust_id=cohead_cust_id) WHERE (coitem_id=pitemid); IF (_cntctid = -1) THEN RETURN -15; END IF; END IF; -- Check Credit Hold SELECT cohead_holdtype INTO _coholdtype FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id) WHERE (coitem_id=pitemid); SELECT calcSalesOrderAmt(cohead_id) - COALESCE(SUM(currToCurr(aropenalloc_curr_id, cohead_curr_id, aropenalloc_amount, cohead_orderdate)),0) INTO _balance FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id) LEFT OUTER JOIN aropenalloc ON (aropenalloc_doctype='S' AND aropenalloc_doc_id=cohead_id) WHERE (coitem_id=pitemid) GROUP BY cohead_id; --RAISE NOTICE 'issueToShipping - order balance is %', _balance; IF ( (_coholdtype = 'C') AND (_balance > 0.0) ) THEN RETURN -12; ELSIF (_coholdtype = 'P') THEN RETURN -13; ELSIF (_coholdtype = 'R') THEN RETURN -14; END IF; SELECT shiphead_id INTO _shipheadid FROM shiphead, coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id) WHERE ( (coitem_id=pitemid) AND (shiphead_number=getOpenShipment(pordertype, coitem_cohead_id, itemsite_warehous_id)) ); IF (NOT FOUND) THEN SELECT NEXTVAL('shiphead_shiphead_id_seq') INTO _shipheadid; _shipnumber := fetchShipmentNumber(); IF (_shipnumber < 0) THEN RETURN -10; END IF; INSERT INTO shiphead ( shiphead_id, shiphead_number, shiphead_order_id, shiphead_order_type, shiphead_shipped, shiphead_sfstatus, shiphead_shipvia, shiphead_shipchrg_id, shiphead_freight, shiphead_freight_curr_id, shiphead_shipdate, shiphead_notes, shiphead_shipform_id ) SELECT _shipheadid, _shipnumber, coitem_cohead_id, pordertype, FALSE, 'N', cohead_shipvia, CASE WHEN (cohead_shipchrg_id <= 0) THEN NULL ELSE cohead_shipchrg_id END, cohead_freight, cohead_curr_id, _timestamp::DATE, cohead_shipcomments, CASE WHEN cohead_shipform_id = -1 THEN NULL ELSE cohead_shipform_id END FROM cohead, coitem WHERE ((coitem_cohead_id=cohead_id) AND (coitem_id=pitemid) ); UPDATE pack SET pack_shiphead_id = _shipheadid, pack_printed = FALSE FROM coitem WHERE ((pack_head_id=coitem_cohead_id) AND (pack_shiphead_id IS NULL) AND (pack_head_type='SO') AND (coitem_id=pitemid)); ELSE UPDATE pack SET pack_printed = FALSE FROM coitem WHERE ((pack_head_id=coitem_cohead_id) AND (pack_shiphead_id=_shipheadid) AND (pack_head_type='SO') AND (coitem_id=pitemid)); END IF; -- Handle g/l transaction SELECT postInvTrans( itemsite_id, 'SH', (pQty * coitem_qty_invuomratio), 'S/R', porderType, formatSoNumber(coitem_id), shiphead_number, ('Issue ' || item_number || ' to Shipping for customer ' || cohead_billtoname), getPrjAccntId(cohead_prj_id, costcat_shipasset_accnt_id), costcat_asset_accnt_id, _itemlocSeries, _timestamp, NULL, pinvhistid ) INTO _invhistid FROM coitem, cohead, itemsite, item, costcat, shiphead WHERE ( (coitem_cohead_id=cohead_id) AND (coitem_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (itemsite_costcat_id=costcat_id) AND (coitem_id=pitemid) AND (shiphead_id=_shipheadid) ); SELECT (invhist_unitcost * invhist_invqty) INTO _value FROM invhist WHERE (invhist_id=_invhistid); _shipitemid := nextval('shipitem_shipitem_id_seq'); INSERT INTO shipitem ( shipitem_id, shipitem_shiphead_id, shipitem_orderitem_id, shipitem_qty, shipitem_transdate, shipitem_trans_username, shipitem_invoiced, shipitem_value, shipitem_invhist_id ) VALUES ( _shipitemid, _shipheadid, pitemid, pQty, _timestamp, getEffectiveXtUser(), FALSE, _value, CASE WHEN _invhistid = -1 THEN NULL ELSE _invhistid END ); -- Handle reservation IF (fetchmetricbool('EnableSOReservations')) THEN -- Remember what was reserved so we can re-reserve if this issue is returned INSERT INTO shipitemrsrv (shipitemrsrv_shipitem_id, shipitemrsrv_qty) SELECT _shipitemid, least(pQty,coitem_qtyreserved) FROM coitem WHERE ((coitem_id=pitemid) AND (coitem_qtyreserved > 0)); -- Update sales order UPDATE coitem SET coitem_qtyreserved = noNeg(coitem_qtyreserved - pQty) WHERE(coitem_id=pitemid); END IF; -- Calculate shipment freight SELECT calcShipFreight(_shipheadid) INTO _freight; UPDATE shiphead SET shiphead_freight=_freight WHERE (shiphead_id=_shipheadid); ELSEIF (pordertype = 'TO') THEN -- Check site security IF (fetchMetricBool('MultiWhs')) THEN SELECT warehous_id INTO _warehouseid FROM toitem, tohead, site() WHERE ( (toitem_id=pitemid) AND (tohead_id=toitem_tohead_id) AND (warehous_id=tohead_src_warehous_id) ); IF (NOT FOUND) THEN RETURN 0; END IF; END IF; SELECT postInvTrans( itemsite_id, 'SH', pQty, 'S/R', pordertype, formatToNumber(toitem_id), '', 'Issue to Shipping', costcat_shipasset_accnt_id, costcat_asset_accnt_id, _itemlocSeries, _timestamp) INTO _invhistid FROM tohead, toitem, itemsite, costcat WHERE ((tohead_id=toitem_tohead_id) AND (itemsite_item_id=toitem_item_id) AND (itemsite_warehous_id=tohead_src_warehous_id) AND (itemsite_costcat_id=costcat_id) AND (toitem_id=pitemid) ); SELECT (invhist_unitcost * invhist_invqty) INTO _value FROM invhist WHERE (invhist_id=_invhistid); SELECT shiphead_id INTO _shipheadid FROM shiphead, toitem JOIN tohead ON (tohead_id=toitem_tohead_id) WHERE ( (toitem_id=pitemid) AND (shiphead_number=getOpenShipment(pordertype, tohead_id, tohead_src_warehous_id)) ); IF (NOT FOUND) THEN _shipheadid := NEXTVAL('shiphead_shiphead_id_seq'); _shipnumber := fetchShipmentNumber(); IF (_shipnumber < 0) THEN RETURN -10; END IF; INSERT INTO shiphead ( shiphead_id, shiphead_number, shiphead_order_id, shiphead_order_type, shiphead_shipped, shiphead_sfstatus, shiphead_shipvia, shiphead_shipchrg_id, shiphead_freight, shiphead_freight_curr_id, shiphead_shipdate, shiphead_notes, shiphead_shipform_id ) SELECT _shipheadid, _shipnumber, tohead_id, pordertype, FALSE, 'N', tohead_shipvia, tohead_shipchrg_id, tohead_freight + SUM(toitem_freight), tohead_freight_curr_id, _timestamp::DATE, tohead_shipcomments, tohead_shipform_id FROM tohead, toitem WHERE ((toitem_tohead_id=tohead_id) AND (tohead_id IN (SELECT toitem_tohead_id FROM toitem WHERE (toitem_id=pitemid))) ) GROUP BY tohead_id, tohead_shipvia, tohead_shipchrg_id, tohead_freight, tohead_freight_curr_id, tohead_shipcomments, tohead_shipform_id; END IF; INSERT INTO shipitem ( shipitem_shiphead_id, shipitem_orderitem_id, shipitem_qty, shipitem_transdate, shipitem_trans_username, shipitem_invoiced, shipitem_value, shipitem_invhist_id ) VALUES ( _shipheadid, pitemid, pQty, _timestamp, getEffectiveXtUser(), FALSE, _value, CASE WHEN _invhistid = -1 THEN NULL ELSE _invhistid END ); ELSE RETURN -11; END IF; RETURN _itemlocSeries; END; $$; ALTER FUNCTION public.issuetoshipping(pordertype text, pitemid integer, pqty numeric, pitemlocseries integer, ptimestamp timestamp with time zone, pinvhistid integer) OWNER TO admin; -- -- Name: issuewomaterial(integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION issuewomaterial(integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pQty ALIAS FOR $2; _itemlocSeries INTEGER; BEGIN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; RETURN issueWoMaterial(pWomatlid, pQty, _itemlocSeries); END; $_$; ALTER FUNCTION public.issuewomaterial(integer, numeric) OWNER TO admin; -- -- Name: issuewomaterial(integer, numeric, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION issuewomaterial(integer, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pQty ALIAS FOR $2; pItemlocSeries ALIAS FOR $3; _p RECORD; _invhistid INTEGER; _itemlocSeries INTEGER; BEGIN RETURN issueWoMaterial(pWomatlid, pQty, pItemlocSeries, now()); END; $_$; ALTER FUNCTION public.issuewomaterial(integer, numeric, integer) OWNER TO admin; -- -- Name: issuewomaterial(integer, numeric, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION issuewomaterial(integer, numeric, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pQty ALIAS FOR $2; pMarkPush ALIAS FOR $3; _itemlocSeries INTEGER; BEGIN RETURN issueWoMaterial(pWomatlid, pQty, pMarkPush, now()); END; $_$; ALTER FUNCTION public.issuewomaterial(integer, numeric, boolean) OWNER TO admin; -- -- Name: issuewomaterial(integer, numeric, integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION issuewomaterial(integer, numeric, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pQty ALIAS FOR $2; pItemlocSeries ALIAS FOR $3; pMarkPush ALIAS FOR $4; _itemlocSeries INTEGER; BEGIN RETURN issueWoMaterial(pWomatlid, pQty, pItemlocSeries,now()); END; $_$; ALTER FUNCTION public.issuewomaterial(integer, numeric, integer, boolean) OWNER TO admin; -- -- Name: issuewomaterial(integer, numeric, integer, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION issuewomaterial(integer, numeric, integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN issueWoMaterial($1, $2, $3, $4, NULL); END; $_$; ALTER FUNCTION public.issuewomaterial(integer, numeric, integer, timestamp with time zone) OWNER TO admin; -- -- Name: issuewomaterial(integer, numeric, boolean, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION issuewomaterial(integer, numeric, boolean, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pQty ALIAS FOR $2; pMarkPush ALIAS FOR $3; pGlDistTS ALIAS FOR $4; _itemlocSeries INTEGER; BEGIN SELECT issueWoMaterial(pWomatlid, pQty, 0, pGlDistTS) INTO _itemlocSeries; IF (_itemlocSeries < 0) THEN RETURN _itemlocSeries; END IF; IF (pMarkPush) THEN UPDATE womatl SET womatl_issuemethod='S' WHERE ((womatl_issuemethod='M') AND (womatl_id=pWomatlid)); END IF; RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.issuewomaterial(integer, numeric, boolean, timestamp with time zone) OWNER TO admin; -- -- Name: issuewomaterial(integer, numeric, integer, boolean, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION issuewomaterial(integer, numeric, integer, boolean, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pQty ALIAS FOR $2; pItemlocSeries ALIAS FOR $3; pMarkPush ALIAS FOR $4; pGlDistTS ALIAS FOR $5; _itemlocSeries INTEGER; BEGIN SELECT issueWoMaterial(pWomatlid, pQty, pItemlocSeries, pGlDistTS) INTO _itemlocSeries; IF (pMarkPush) THEN UPDATE womatl SET womatl_issuemethod='S' WHERE ((womatl_issuemethod='M') AND (womatl_id=pWomatlid)); END IF; RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.issuewomaterial(integer, numeric, integer, boolean, timestamp with time zone) OWNER TO admin; -- -- Name: issuewomaterial(integer, numeric, integer, timestamp with time zone, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION issuewomaterial(integer, numeric, integer, timestamp with time zone, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pQty ALIAS FOR $2; pItemlocSeries ALIAS FOR $3; pGlDistTS ALIAS FOR $4; pInvhistid ALIAS FOR $5; _p RECORD; _invhistid INTEGER; _itemlocSeries INTEGER; BEGIN SELECT item_id, itemsite_id AS c_itemsite_id, wo_itemsite_id AS p_itemsite_id, itemsite_loccntrl, itemsite_controlmethod, womatl_wo_id, womatl_qtyreq, itemsite_item_id, womatl_uom_id, wo_prj_id, roundQty(item_fractional, itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, pQty)) AS qty, formatWoNumber(wo_id) AS woNumber, CASE WHEN(itemsite_costmethod='J' AND item_type='P' AND poitem_id IS NOT NULL) THEN poitem_unitprice WHEN(itemsite_costmethod IN ('A','J')) THEN avgcost(itemsite_id) WHEN(itemsite_costmethod='S') THEN stdcost(itemsite_item_id) ELSE 0.0 END AS cost, womatl_issuemethod AS issueMethod INTO _p FROM womatl JOIN wo ON (wo_id=womatl_wo_id) JOIN itemsite ON (itemsite_id=womatl_itemsite_id) JOIN item ON (item_id=itemsite_item_id) LEFT OUTER JOIN poitem ON (poitem_order_id=womatl_id AND poitem_order_type='W') WHERE (womatl_id=pWomatlid); IF (pQty < 0) THEN RETURN pItemlocSeries; END IF; IF (pItemlocSeries <> 0) THEN _itemlocSeries := pItemlocSeries; ELSE SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; END IF; SELECT postInvTrans( ci.itemsite_id, 'IM', _p.qty, 'W/O', 'WO', _p.woNumber, '', ('Material ' || item_number || ' Issue to Work Order'), getPrjAccntId(_p.wo_prj_id, pc.costcat_wip_accnt_id), cc.costcat_asset_accnt_id, _itemlocSeries, pGlDistTS, NULL, pInvhistid ) INTO _invhistid FROM itemsite AS ci, itemsite AS pi, costcat AS cc, costcat AS pc, item WHERE ( (ci.itemsite_costcat_id=cc.costcat_id) AND (pi.itemsite_costcat_id=pc.costcat_id) AND (ci.itemsite_id=_p.c_itemsite_id) AND (pi.itemsite_id=_p.p_itemsite_id) AND (ci.itemsite_item_id=item_id) ); -- Create linkage to the transaction created IF (_invhistid != -1) THEN INSERT INTO womatlpost (womatlpost_womatl_id,womatlpost_invhist_id) VALUES (pWomatlid,_invhistid); END IF; -- Increase the parent W/O's WIP value by the value of the issued components UPDATE wo SET wo_wipvalue = (wo_wipvalue + (_p.cost * _p.qty)), wo_postedvalue = (wo_postedvalue + (_p.cost * _p.qty)) WHERE (wo_id=_p.womatl_wo_id); UPDATE womatl SET womatl_qtyiss = (womatl_qtyiss + itemuomtouom(_p.itemsite_item_id, NULL, _p.womatl_uom_id, _p.qty)), womatl_lastissue = pGlDistTS::DATE WHERE (womatl_id=pWomatlid); UPDATE wo SET wo_status='I' WHERE ( (wo_status <> 'I') AND (wo_id=_p.womatl_wo_id) ); RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.issuewomaterial(integer, numeric, integer, timestamp with time zone, integer) OWNER TO admin; -- -- Name: issuewomaterialbatch(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION issuewomaterialbatch(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; _itemlocSeries INTEGER; _r RECORD; _woNumber TEXT; BEGIN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; FOR _r IN SELECT womatl_id, CASE WHEN (womatl_qtyreq >= 0) THEN roundQty(itemuomfractionalbyuom(item_id, womatl_uom_id), noNeg(womatl_qtyreq - womatl_qtyiss)) ELSE roundQty(itemuomfractionalbyuom(item_id, womatl_uom_id), noNeg(womatl_qtyiss * -1)) END AS qty FROM womatl, itemsite, item WHERE ( (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (womatl_issuemethod IN ('S', 'M')) AND (womatl_wo_id=pWoid) ) LOOP IF (_r.qty > 0) THEN SELECT issueWoMaterial(_r.womatl_id, _r.qty, _itemlocSeries, TRUE) INTO _itemlocSeries; END IF; END LOOP; RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.issuewomaterialbatch(integer) OWNER TO admin; -- -- Name: itemaltcapinvrat(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemaltcapinvrat(integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; BEGIN RETURN itemUOMRatioByType(pItemid, 'AltCapacity'); END; $_$; ALTER FUNCTION public.itemaltcapinvrat(integer) OWNER TO admin; -- -- Name: itemaltcapuom(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemaltcapuom(integer) RETURNS text LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; BEGIN RETURN itemUOMByType(pItemid, 'AltCapacity'); END; $_$; ALTER FUNCTION public.itemaltcapuom(integer) OWNER TO admin; -- -- Name: itemcapinvrat(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemcapinvrat(integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; BEGIN RETURN itemUOMRatioByType(pItemid, 'Capacity'); END; $_$; ALTER FUNCTION public.itemcapinvrat(integer) OWNER TO admin; -- -- Name: itemcapuom(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemcapuom(integer) RETURNS text LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; BEGIN RETURN itemUOMByType(pItemid, 'Capacity'); END; $_$; ALTER FUNCTION public.itemcapuom(integer) OWNER TO admin; -- -- Name: itemcharprice(integer, integer, text, integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemcharprice(integer, integer, text, integer, numeric) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCharid ALIAS FOR $2; pCharValue ALIAS FOR $3; pCustid ALIAS FOR $4; pQty ALIAS FOR $5; BEGIN RETURN itemCharPrice(pItemid, pCharid, pCharValue, pCustid, -1, pQty, baseCurrId(), CURRENT_DATE); END; $_$; ALTER FUNCTION public.itemcharprice(integer, integer, text, integer, numeric) OWNER TO admin; -- -- Name: itemcharprice(integer, integer, text, integer, integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemcharprice(integer, integer, text, integer, integer, numeric) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCharid ALIAS FOR $2; pCharValue ALIAS FOR $3; pCustid ALIAS FOR $4; pShiptoid ALIAS FOR $5; pQty ALIAS FOR $6; BEGIN RETURN itemCharPrice(pItemid, pCharid, pCharValue, pCustid, pShiptoid, pQty, baseCurrId(), CURRENT_DATE); END; $_$; ALTER FUNCTION public.itemcharprice(integer, integer, text, integer, integer, numeric) OWNER TO admin; -- -- Name: itemcharprice(integer, integer, text, integer, integer, numeric, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemcharprice(integer, integer, text, integer, integer, numeric, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCharid ALIAS FOR $2; pCharValue ALIAS FOR $3; pCustid ALIAS FOR $4; pShiptoid ALIAS FOR $5; pQty ALIAS FOR $6; pCurrid ALIAS FOR $7; BEGIN RETURN itemCharPrice(pItemid, pCharid, pCharValue, pCustid, pShiptoid, pQty, pCurrid, CURRENT_DATE); END; $_$; ALTER FUNCTION public.itemcharprice(integer, integer, text, integer, integer, numeric, integer) OWNER TO admin; -- -- Name: itemcharprice(integer, integer, text, integer, integer, numeric, integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemcharprice(integer, integer, text, integer, integer, numeric, integer, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCharid ALIAS FOR $2; pCharValue ALIAS FOR $3; pCustid ALIAS FOR $4; pShiptoid ALIAS FOR $5; pQty ALIAS FOR $6; pCurrid ALIAS FOR $7; pEffective ALIAS FOR $8; BEGIN RETURN itemCharPrice(pItemid, pCharid, pCharValue, pCustid, pShiptoid, pQty, pCurrid, CURRENT_DATE, CURRENT_DATE); END; $_$; ALTER FUNCTION public.itemcharprice(integer, integer, text, integer, integer, numeric, integer, date) OWNER TO admin; -- -- Name: itemcharprice(integer, integer, text, integer, integer, numeric, integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemcharprice(integer, integer, text, integer, integer, numeric, integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCharid ALIAS FOR $2; pCharValue ALIAS FOR $3; pCustid ALIAS FOR $4; pShiptoid ALIAS FOR $5; pQty ALIAS FOR $6; pCurrid ALIAS FOR $7; pEffective ALIAS FOR $8; pAsOf ALIAS FOR $9; _price NUMERIC; _sales NUMERIC; _item RECORD; _iteminvpricerat NUMERIC; BEGIN -- If the charass_value passed in is NULL, we can skip this function IF (pCharValue IS NULL) THEN RETURN 0; END IF; -- Return the itemCharPrice in the currency passed in as pCurrid -- Get a value here so we do not have to call the function several times SELECT iteminvpricerat(pItemid) INTO _iteminvpricerat; -- First get a sales price if any so we when we find other prices -- we can determine if we want that price or this price. -- Check for a Sale Price SELECT currToCurr(ipshead_curr_id, pCurrid, ipsprice_price - (ipsprice_price * cust_discntprcnt), pEffective) INTO _sales FROM ( SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id, itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) AS ipsprice_qtybreak, (ipsitemchar_price * itemuomtouomratio(ipsitem_item_id, NULL, ipsitem_price_uom_id)) * _iteminvpricerat AS ipsprice_price FROM ipsiteminfo,ipsitemchar WHERE((ipsitem_item_id=pItemid) AND (ipsitemchar_char_id=pCharid) AND (ipsitemchar_value=pCharValue) AND (ipsitemchar_ipsitem_id=ipsitem_id)) ) AS ipsprice, ipshead, sale, custinfo WHERE ( (ipsprice_ipshead_id=ipshead_id) AND (sale_ipshead_id=ipshead_id) AND (pAsOf BETWEEN sale_startdate AND sale_enddate) AND (ipsprice_qtybreak <= pQty) AND (cust_id=pCustid) ) ORDER BY ipsprice_qtybreak DESC, ipsprice_price ASC LIMIT 1; -- Check for a Customer Shipto Price SELECT currToCurr(ipshead_curr_id, pCurrid, ipsprice_price, pEffective) INTO _price FROM ( SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id, itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) AS ipsprice_qtybreak, (ipsitemchar_price * itemuomtouomratio(ipsitem_item_id, NULL, ipsitem_price_uom_id)) * _iteminvpricerat AS ipsprice_price FROM ipsiteminfo,ipsitemchar WHERE ((ipsitem_item_id=pItemid) AND (ipsitemchar_char_id=pCharid) AND (ipsitemchar_value=pCharValue) AND (ipsitemchar_ipsitem_id=ipsitem_id)) ) AS ipsprice, ipshead, ipsass WHERE ( (ipsprice_ipshead_id=ipshead_id) AND (ipsass_ipshead_id=ipshead_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsprice_qtybreak <= pQty) AND (ipsass_shipto_id != -1) AND (ipsass_shipto_id=pShiptoid) ) ORDER BY ipsprice_qtybreak DESC, ipsprice_price ASC LIMIT 1; IF (_price IS NOT NULL) THEN IF ((_sales IS NOT NULL) AND (_sales < _price)) THEN RETURN _sales; END IF; RETURN _price; END IF; -- Check for a Customer Shipto Pattern Price SELECT currToCurr(ipshead_curr_id, pCurrid, ipsprice_price, pEffective) INTO _price FROM ( SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id, itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) AS ipsprice_qtybreak, (ipsitemchar_price * itemuomtouomratio(ipsitem_item_id, NULL, ipsitem_price_uom_id)) * _iteminvpricerat AS ipsprice_price FROM ipsiteminfo,ipsitemchar WHERE ((ipsitem_item_id=pItemid) AND (ipsitemchar_char_id=pCharid) AND (ipsitemchar_value=pCharValue) AND (ipsitemchar_ipsitem_id=ipsitem_id)) ) AS ipsprice, ipshead, ipsass, shiptoinfo WHERE ( (ipsprice_ipshead_id=ipshead_id) AND (ipsass_ipshead_id=ipshead_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsprice_qtybreak <= pQty) AND (COALESCE(length(ipsass_shipto_pattern), 0) > 0) AND (shipto_num ~ ipsass_shipto_pattern) AND (ipsass_cust_id=pCustid) AND (shipto_id=pShiptoid) ) ORDER BY ipsprice_qtybreak DESC, ipsprice_price ASC LIMIT 1; IF (_price IS NOT NULL) THEN IF ((_sales IS NOT NULL) AND (_sales < _price)) THEN RETURN _sales; END IF; RETURN _price; END IF; -- Check for a Customer Price SELECT currToCurr(ipshead_curr_id, pCurrid, ipsprice_price, pEffective) INTO _price FROM ( SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id, itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) AS ipsprice_qtybreak, (ipsitemchar_price * itemuomtouomratio(ipsitem_item_id, NULL, ipsitem_price_uom_id)) * _iteminvpricerat AS ipsprice_price FROM ipsiteminfo,ipsitemchar WHERE ((ipsitem_item_id=pItemid) AND (ipsitemchar_char_id=pCharid) AND (ipsitemchar_value=pCharValue) AND (ipsitemchar_ipsitem_id=ipsitem_id)) ) AS ipsprice, ipshead, ipsass WHERE ( (ipsprice_ipshead_id=ipshead_id) AND (ipsass_ipshead_id=ipshead_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsprice_qtybreak <= pQty) AND (COALESCE(length(ipsass_shipto_pattern), 0) = 0) AND (ipsass_cust_id=pCustid) ) ORDER BY ipsprice_qtybreak DESC, ipsprice_price ASC LIMIT 1; IF (_price IS NOT NULL) THEN IF ((_sales IS NOT NULL) AND (_sales < _price)) THEN RETURN _sales; END IF; RETURN _price; END IF; -- Check for a Customer Type Price SELECT currToCurr(ipshead_curr_id, pCurrid, ipsprice_price, pEffective) INTO _price FROM ( SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id, itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) AS ipsprice_qtybreak, (ipsitemchar_price * itemuomtouomratio(ipsitem_item_id, NULL, ipsitem_price_uom_id)) * _iteminvpricerat AS ipsprice_price FROM ipsiteminfo,ipsitemchar WHERE((ipsitem_item_id=pItemid) AND (ipsitemchar_char_id=pCharid) AND (ipsitemchar_value=pCharValue) AND (ipsitemchar_ipsitem_id=ipsitem_id)) ) AS ipsprice, ipshead, ipsass, custinfo WHERE ( (ipsprice_ipshead_id=ipshead_id) AND (ipsass_ipshead_id=ipshead_id) AND (ipsass_custtype_id=cust_custtype_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsprice_qtybreak <= pQty) AND (cust_id=pCustid) ) ORDER BY ipsprice_qtybreak DESC, ipsprice_price ASC LIMIT 1; IF (_price IS NOT NULL) THEN IF ((_sales IS NOT NULL) AND (_sales < _price)) THEN RETURN _sales; END IF; RETURN _price; END IF; -- Check for a Customer Type Pattern Price SELECT currToCurr(ipshead_curr_id, pCurrid, ipsprice_price, pEffective) INTO _price FROM ( SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id, itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) AS ipsprice_qtybreak, (ipsitemchar_price * itemuomtouomratio(ipsitem_item_id, NULL, ipsitem_price_uom_id)) * _iteminvpricerat AS ipsprice_price FROM ipsiteminfo,ipsitemchar WHERE ((ipsitem_item_id=pItemid) AND (ipsitemchar_char_id=pCharid) AND (ipsitemchar_value=pCharValue) AND (ipsitemchar_ipsitem_id=ipsitem_id)) ) AS ipsprice, ipshead, ipsass, custtype, custinfo WHERE ( (ipsprice_ipshead_id=ipshead_id) AND (ipsass_ipshead_id=ipshead_id) AND (coalesce(length(ipsass_custtype_pattern), 0) > 0) AND (custtype_code ~ ipsass_custtype_pattern) AND (cust_custtype_id=custtype_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsprice_qtybreak <= pQty) AND (cust_id=pCustid) ) ORDER BY ipsprice_qtybreak DESC, ipsprice_price ASC LIMIT 1; IF (_price IS NOT NULL) THEN IF ((_sales IS NOT NULL) AND (_sales < _price)) THEN RETURN _sales; END IF; RETURN _price; END IF; -- If we have not found another price yet and we have a -- sales price we will use that. IF (_sales IS NOT NULL) THEN RETURN _sales; END IF; -- Check for a list price SELECT MIN(currToLocal(pCurrid, charass_price - (charass_price * COALESCE(cust_discntprcnt, 0)), pEffective)) AS price, item_exclusive INTO _item FROM charass,item LEFT OUTER JOIN custinfo ON (cust_id=pCustid) WHERE ((item_id=pItemid) AND (charass_char_id=pCharid) AND (charass_value=pCharValue) AND (charass_target_type='I') AND (charass_target_id=item_id)) GROUP BY item_exclusive; IF (FOUND) THEN IF (NOT _item.item_exclusive) THEN IF (_item.price < 0) THEN RETURN 0; ELSE RETURN _item.price; END IF; ELSE RETURN 0; END IF; ELSE RETURN 0; END IF; END; $_$; ALTER FUNCTION public.itemcharprice(integer, integer, text, integer, integer, numeric, integer, date, date) OWNER TO admin; -- -- Name: itemcharvalue(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemcharvalue(integer, text) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCharName ALIAS FOR $2; _value TEXT; BEGIN SELECT charass_value INTO _value FROM charass, char WHERE ( (charass_char_id=char_id) AND (charass_target_type='I') AND (charass_target_id=pItemid) AND (char_name=pCharName) ); IF (NOT FOUND) THEN _value = ''; END IF; RETURN _value; END; $_$; ALTER FUNCTION public.itemcharvalue(integer, text) OWNER TO admin; -- -- Name: itemcost(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemcost(pitemsiteid integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cost NUMERIC; BEGIN SELECT CASE WHEN (itemsite_costmethod='A' AND itemsite_qtyonhand != 0.0) THEN (itemsite_value / itemsite_qtyonhand) WHEN (itemsite_costmethod='A' AND itemsite_qtyonhand = 0.0) THEN stdCost(itemsite_item_id) WHEN (itemsite_costmethod='N') THEN 0.0 ELSE stdCost(itemsite_item_id) END INTO _cost FROM itemsite WHERE(itemsite_id=pItemsiteid); RETURN _cost; END; $$; ALTER FUNCTION public.itemcost(pitemsiteid integer) OWNER TO admin; -- -- Name: itemcost(integer, integer, integer, numeric, integer, integer, integer, date, date, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemcost(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- -- Overload for future costing enhancements -- BEGIN RETURN itemCost(pItemid, pCustid, pShiptoid, pQty, pQtyUOM, pPriceUOM, pCurrid, pEffective, pAsOf, pSiteid, FALSE); END; $$; ALTER FUNCTION public.itemcost(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer) OWNER TO admin; -- -- Name: itemcost(integer, integer, integer, numeric, integer, integer, integer, date, date, integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemcost(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer, pdropship boolean) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- -- Overload for future costing enhancements -- DECLARE _r RECORD; _cost NUMERIC := 0.0; BEGIN -- cache item info SELECT *, itemInvPriceRat(item_id) AS itempriceinvrat INTO _r FROM itemsite, item WHERE (itemsite_item_id=pItemid) AND (itemsite_warehous_id=pSiteid) AND (item_id=pItemid); IF (_r.item_type = 'K') THEN SELECT SUM(roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id), (bomitem_qtyfxd + bomitem_qtyper) * (1 + bomitem_scrap)) * stdCost(bomitem_item_id)) INTO _cost FROM bomitem WHERE (bomitem_parent_item_id=_r.item_id) AND (bomitem_rev_id=getActiveRevid('BOM', _r.item_id)) AND (pEffective BETWEEN bomitem_effective AND (bomitem_expires - 1)); ELSEIF (fetchMetricBool('WholesalePriceCosting')) THEN _cost := _r.item_listcost / _r.itempriceinvrat; ELSE SELECT itemcost(_r.itemsite_id) INTO _cost; END IF; RETURN _cost; END; $$; ALTER FUNCTION public.itemcost(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer, pdropship boolean) OWNER TO admin; -- -- Name: iteminventoryuominuse(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION iteminventoryuominuse(pitemid integer) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _uomid INTEGER; _result INTEGER; BEGIN SELECT item_inv_uom_id INTO _uomid FROM item WHERE(item_id=pItemid); SELECT itemuomconv_id INTO _result FROM itemuomconv WHERE(itemuomconv_item_id=pItemid) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; SELECT itemsite_id INTO _result FROM itemsite WHERE ( (itemsite_item_id=pItemid) AND (itemsite_qtyonhand <> 0) ) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; RETURN FALSE; END; $$; ALTER FUNCTION public.iteminventoryuominuse(pitemid integer) OWNER TO admin; -- -- Name: iteminvpricerat(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION iteminvpricerat(integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; _fromUomid INTEGER; _toUomid INTEGER; _ratio NUMERIC; BEGIN IF(pItemid IS NULL) THEN RETURN 1.0; END IF; SELECT item_inv_uom_id, item_price_uom_id INTO _fromUomid, _toUomid FROM item WHERE(item_id=pItemid); IF(NOT FOUND) THEN RAISE EXCEPTION 'No item record found for item_id %', pItemid; END IF; IF(_fromUomid = _toUomid) THEN RETURN 1.0; END IF; -- Return the ration as inventory / price SELECT CASE WHEN(itemuomconv_from_uom_id=_fromUomid) THEN itemuomconv_from_value / itemuomconv_to_value ELSE itemuomconv_to_value / itemuomconv_from_value END INTO _ratio FROM itemuomconv WHERE((((itemuomconv_from_uom_id=_fromUomid) AND (itemuomconv_to_uom_id=_toUomid)) OR ((itemuomconv_from_uom_id=_toUomid) AND (itemuomconv_to_uom_id=_fromUomid))) AND (itemuomconv_item_id=pItemid)); IF(NOT FOUND) THEN RAISE EXCEPTION 'No itemuomconv record found for item_id % to item_price_uomid %', pItemid, _toUomid; END IF; RETURN _ratio; END; $_$; ALTER FUNCTION public.iteminvpricerat(integer) OWNER TO admin; -- -- Name: itemipsprice(integer, integer, integer, numeric, integer, integer, integer, date, date, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemipsprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer) RETURNS SETOF itemprice LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row itemprice%ROWTYPE; _sale RECORD; _ips RECORD; _item RECORD; _cust RECORD; _shipto RECORD; _itempricepricerat NUMERIC := 1.0; _listprice NUMERIC := 0.0; _qty NUMERIC; _asof DATE; _wholesalepricecosting BOOLEAN := false; _long30markups BOOLEAN := false; _itempricingprecedence BOOLEAN := false; BEGIN _wholesalepricecosting := fetchMetricBool('WholesalePriceCosting'); _long30markups := fetchMetricBool('Long30Markups'); _itempricingprecedence := fetchMetricBool('ItemPricingPrecedence'); -- Return the itemPrice in the currency passed in as pCurrid _qty := itemuomtouom(pItemid, pQtyUOM, NULL, pQty); -- If no as of passed, use current date _asof := COALESCE(pAsOf, CURRENT_DATE); -- Cache Item, Customer and Shipto SELECT item.*, (itemCost(itemsite_id) / itemuomtouomratio(item_id, item_inv_uom_id, item_price_uom_id)) AS invcost INTO _item FROM item LEFT OUTER JOIN itemsite ON (itemsite_item_id=item_id AND itemsite_warehous_id=pSiteid) WHERE (item_id=pItemid); SELECT * INTO _cust FROM custinfo JOIN custtype ON (custtype_id=cust_custtype_id) WHERE (cust_id=pCustid); SELECT * INTO _shipto FROM shiptoinfo WHERE (shipto_id=pShiptoid); -- Get a value here so we do not have to call the function several times SELECT itemuomtouomratio(pItemid, pPriceUOM, _item.item_price_uom_id) AS ratio INTO _itempricepricerat; -- Price Schedule Assignment Order of Precedence -- 1. Specific Customer Shipto Id -- 2. Specific Customer Shipto Pattern -- 3. Any Customer Shipto Pattern -- 4. Specific Customer -- 5. Customer Type -- 6. Customer Type Pattern -- First get a sales price if any so we when we find other prices -- we can determine if we want that price or this price. -- Check for a Sale Price SELECT INTO _sale currToCurr(ipshead_curr_id, pCurrid, ipsprice_price, pEffective) AS rightprice, ipsitem_type AS righttype FROM ( SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id, ipsitem_type, CASE WHEN (ipsitem_type = 'N') THEN (ipsitem_price * itemuomtouomratio(_item.item_id, pPriceUOM, ipsitem_price_uom_id)) WHEN (ipsitem_type = 'D') THEN noNeg(_item.item_listprice - (_item.item_listprice * ipsitem_discntprcnt) - ipsitem_fixedamtdiscount) * _itempricepricerat WHEN ((ipsitem_type = 'M') AND _long30markups AND _wholesalepricecosting) THEN (_item.item_listcost / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat WHEN ((ipsitem_type = 'M') AND _long30markups) THEN (_item.invcost / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat WHEN (ipsitem_type = 'M' AND _wholesalepricecosting) THEN (_item.item_listcost + (_item.item_listcost * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat WHEN (ipsitem_type = 'M') THEN (_item.invcost + (_item.invcost * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat ELSE 0.00 END AS ipsprice_price, CASE WHEN (ipsitem_item_id=_item.item_id) THEN itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) ELSE ipsitem_qtybreak END AS ipsprice_qtybreak, (COALESCE(ipsitem_price_uom_id, -1)=COALESCE(pPriceUOM,-1)) AS uommatched, CASE WHEN (_itempricingprecedence) THEN (COALESCE(ipsitem_item_id, -1)=_item.item_id) ELSE true END AS itemmatched FROM ipsiteminfo WHERE(ipsitem_item_id=_item.item_id) OR (ipsitem_prodcat_id=_item.item_prodcat_id) ) AS ipsprice, ipshead, ipsass, sale WHERE ( (ipsprice_ipshead_id=ipshead_id) AND (sale_ipshead_id=ipsprice_ipshead_id) AND (_asof BETWEEN sale_startdate AND (sale_enddate - 1)) AND (ipsprice_qtybreak <= _qty) AND (ipsass_ipshead_id=ipshead_id) AND ( (ipsass_shipto_id=_shipto.shipto_id) OR ((COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) AND (ipsass_cust_id > -1) AND (_shipto.shipto_num ~ ipsass_shipto_pattern) AND (ipsass_cust_id = _cust.cust_id)) OR ((COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) AND (ipsass_cust_id = -1) AND (_shipto.shipto_num ~ ipsass_shipto_pattern)) OR ((COALESCE(LENGTH(ipsass_shipto_pattern), 0) = 0) AND (ipsass_cust_id=_cust.cust_id)) OR (ipsass_custtype_id=_cust.cust_custtype_id) OR ((COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) AND (_cust.custtype_code ~ ipsass_custtype_pattern)) ) ) ORDER BY itemmatched DESC, uommatched DESC, ipsprice_qtybreak DESC, ipsprice_price ASC LIMIT 1; -- Find the best Price Schedule Price SELECT INTO _ips currToCurr(ipshead_curr_id, pCurrid, protoprice, pEffective) AS rightprice, ipsitem_type AS righttype FROM ( SELECT *, CASE WHEN (COALESCE(ipsass_shipto_id, -1) > 0) THEN 1 WHEN (COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0 AND COALESCE(ipsass_cust_id, -1) > 0) THEN 2 WHEN (COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) THEN 3 WHEN (COALESCE(ipsass_cust_id, -1) > 0) THEN 4 WHEN (COALESCE(ipsass_custtype_id, -1) > 0) THEN 5 WHEN (COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) THEN 6 ELSE 99 END AS assignseq, CASE WHEN (ipsitem_type = 'N') THEN (ipsitem_price * itemuomtouomratio(_item.item_id, pPriceUOM, ipsitem_price_uom_id)) WHEN (ipsitem_type = 'D') THEN noNeg(_item.item_listprice - (_item.item_listprice * ipsitem_discntprcnt) - ipsitem_fixedamtdiscount) * _itempricepricerat WHEN ((ipsitem_type = 'M') AND _long30markups AND _wholesalepricecosting) THEN (_item.item_listcost / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat WHEN ((ipsitem_type = 'M') AND _long30markups) THEN (_item.invcost / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat WHEN (ipsitem_type = 'M' AND _wholesalepricecosting) THEN (_item.item_listcost + (_item.item_listcost * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat WHEN (ipsitem_type = 'M') THEN (_item.invcost + (_item.invcost * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat ELSE 0.00 END AS protoprice, CASE WHEN (ipsitem_item_id=_item.item_id) THEN itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) ELSE ipsitem_qtybreak END AS protoqtybreak, (COALESCE(ipsitem_price_uom_id, -1)=COALESCE(pPriceUOM,-1)) AS uommatched, CASE WHEN (_itempricingprecedence) THEN (COALESCE(ipsitem_item_id, -1)=_item.item_id) ELSE true END AS itemmatched FROM ipsass JOIN ipshead ON (ipshead_id=ipsass_ipshead_id) JOIN ipsiteminfo ON (ipsitem_ipshead_id=ipshead_id) WHERE ((ipsitem_item_id=_item.item_id) OR (ipsitem_prodcat_id=_item.item_prodcat_id)) AND (_asof BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND ((ipsitem_warehous_id=pSiteid) OR (ipsitem_warehous_id IS NULL)) AND ( (ipsass_shipto_id=_shipto.shipto_id) OR ((COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) AND (ipsass_cust_id > -1) AND (_shipto.shipto_num ~ ipsass_shipto_pattern) AND (ipsass_cust_id = _cust.cust_id)) OR ((COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) AND (ipsass_cust_id = -1) AND (_shipto.shipto_num ~ ipsass_shipto_pattern)) OR ((COALESCE(LENGTH(ipsass_shipto_pattern), 0) = 0) AND (ipsass_cust_id=_cust.cust_id)) OR (ipsass_custtype_id=_cust.cust_custtype_id) OR ((COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) AND (_cust.custtype_code ~ ipsass_custtype_pattern)) ) ) AS proto WHERE (protoqtybreak <= pQty) ORDER BY assignseq, itemmatched DESC, protoqtybreak DESC, rightprice LIMIT 1; IF (_ips.rightprice IS NOT NULL) THEN IF ((_sale.rightprice IS NOT NULL) AND (_sale.rightprice < _ips.rightprice)) THEN RAISE DEBUG 'itemprice, item=%, cust=%, shipto=%, sale price= %', pItemid, pCustid, pShiptoid, _sale.rightprice; _row.itemprice_price := _sale.rightprice; _row.itemprice_type := _sale.righttype; RETURN NEXT _row; END IF; RAISE DEBUG 'itemprice, item=%, cust=%, shipto=%, schedule price= %', pItemid, pCustid, pShiptoid, _ips.rightprice; _row.itemprice_price := _ips.rightprice; _row.itemprice_type := _ips.righttype; RETURN NEXT _row; END IF; -- If item is exclusive then list list price does not apply IF (_item.item_exclusive) THEN RAISE DEBUG 'itemprice, item=%, cust=%, shipto=%, item exclusive, price=-9999', pItemid, pCustid, pShiptoid; _row.itemprice_price := -9999.0; _row.itemprice_type := ''; RETURN NEXT _row; END IF; -- Check for a list price _listprice := noNeg(currToLocal(pCurrid, _item.item_listprice - (_item.item_listprice * COALESCE(_cust.cust_discntprcnt, 0.0)), pEffective) * itemuomtouomratio(pItemid, pPriceUOM, _item.item_price_uom_id)); RAISE DEBUG 'itemprice, item=%, cust=%, shipto=%, list price= %', pItemid, pCustid, pShiptoid, _listprice; _row.itemprice_price := _listprice; _row.itemprice_type := 'P'; RETURN NEXT _row; RETURN; END; $$; ALTER FUNCTION public.itemipsprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer) OWNER TO admin; -- -- Name: itemlocdistqty(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemlocdistqty(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLocationid ALIAS FOR $1; pParentid ALIAS FOR $2; _qty NUMERIC; _tempQty NUMERIC; BEGIN SELECT COALESCE(SUM(itemlocdist_qty), 0) INTO _qty FROM itemlocdist WHERE ( (itemlocdist_source_type='L') AND (itemlocdist_source_id=pLocationid) AND (itemlocdist_itemlocdist_id=pParentid) ); SELECT COALESCE(SUM(itemlocdist_qty), 0) INTO _tempQty FROM itemlocdist, itemloc WHERE ( (itemlocdist_source_type='I') AND (itemlocdist_source_id=itemloc_id) AND (itemloc_location_id=pLocationid) AND (itemlocdist_itemlocdist_id=pParentid) ); _qty := (_qty + _tempQty); RETURN _qty; END; $_$; ALTER FUNCTION public.itemlocdistqty(integer, integer) OWNER TO admin; -- -- Name: itemlocdistqty(text, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemlocdistqty(text, integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTypes ALIAS FOR $1; pLocationid ALIAS FOR $2; pParentid ALIAS FOR $3; _qty NUMERIC := 0; _tempQty NUMERIC; BEGIN IF (strpos(pTypes, 'L') > 0) THEN SELECT COALESCE(SUM(itemlocdist_qty), 0) INTO _tempQty FROM itemlocdist WHERE ( (itemlocdist_source_type='L') AND (itemlocdist_source_id=pLocationid) AND (itemlocdist_itemlocdist_id=pParentid) ); _qty := (_qty + _tempQty); END IF; IF (strpos(pTypes, 'I') > 0) THEN SELECT COALESCE(SUM(itemlocdist_qty), 0) INTO _tempQty FROM itemlocdist, itemloc WHERE ( (itemlocdist_source_type='I') AND (itemlocdist_source_id=itemloc_id) AND (itemloc_location_id=pLocationid) AND (itemlocdist_itemlocdist_id=pParentid) ); _qty := (_qty + _tempQty); END IF; RETURN _qty; END; $_$; ALTER FUNCTION public.itemlocdistqty(text, integer, integer) OWNER TO admin; -- -- Name: itemprice(integer, integer, integer, numeric, integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pcurrid integer, peffective date) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _item RECORD; BEGIN SELECT item_inv_uom_id, item_price_uom_id INTO _item FROM item WHERE(item_id=pItemid); IF (FOUND) THEN RETURN itemPrice(pItemid, pCustid, pShiptoid, pQty, _item.item_inv_uom_id, _item.item_price_uom_id, pCurrid, pEffective); END IF; RETURN -9999; END; $$; ALTER FUNCTION public.itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pcurrid integer, peffective date) OWNER TO admin; -- -- Name: itemprice(integer, integer, integer, numeric, integer, integer, integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN RETURN itemPrice(pItemid, pCustid, pShiptoid, pQty, pQtyUOM, pPriceUOM, pCurrid, pEffective, CURRENT_DATE); END; $$; ALTER FUNCTION public.itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date) OWNER TO admin; -- -- Name: itemprice(integer, integer, integer, numeric, integer, integer, integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN RETURN itemPrice(pItemid, pCustid, pShiptoid, pQty, pQtyUOM, pPriceUOM, pCurrid, pEffective, pAsOf, NULL); END; $$; ALTER FUNCTION public.itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date) OWNER TO admin; -- -- Name: itemprice(integer, integer, integer, numeric, integer, integer, integer, date, date, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; BEGIN SELECT * FROM itemIpsPrice(pItemid, pCustid, pShiptoid, pQty, pQtyUOM, pPriceUOM, pCurrid, pEffective, pAsOf, pSiteid) INTO _r; RETURN _r.itemprice_price; END; $$; ALTER FUNCTION public.itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer) OWNER TO admin; -- -- Name: itemsellinguom(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemsellinguom(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; BEGIN RETURN itemUOMByType(pItemid, 'Selling'); END; $_$; ALTER FUNCTION public.itemsellinguom(integer) OWNER TO admin; -- -- Name: itemsrcprice(integer, numeric, integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemsrcprice(pitemsrcid integer, pqty numeric, pcurrid integer, peffective date) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _price NUMERIC := 0.0; BEGIN SELECT itemsrcPrice(pItemsrcid, -1, FALSE, pQty, pCurrid, pEffective) INTO _price; RETURN _price; END; $$; ALTER FUNCTION public.itemsrcprice(pitemsrcid integer, pqty numeric, pcurrid integer, peffective date) OWNER TO admin; -- -- Name: itemsrcprice(integer, integer, boolean, numeric, integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemsrcprice(pitemsrcid integer, psiteid integer, pdropship boolean, pqty numeric, pcurrid integer, peffective date) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _price NUMERIC := 0.0; _r RECORD; _effective DATE; BEGIN -- Sometimes NULL itemsrc is passed (#25898) IF (pItemsrcid IS NULL) THEN RETURN NULL; END IF; -- If no pEffective passed, use current date _effective := COALESCE(pEffective, CURRENT_DATE); -- Cache Itemsrc and Item SELECT * INTO _r FROM itemsrc JOIN item ON (item_id=itemsrc_item_id) WHERE (itemsrc_id=pItemsrcid); IF (NOT FOUND) THEN RAISE EXCEPTION 'itemsrc % not found.', pItemsrcid; END IF; -- Determine price SELECT currToCurr(itemsrcp_curr_id, pCurrid, price, _effective) INTO _price FROM ( SELECT *, CASE WHEN (itemsrcp_dropship) THEN 0 ELSE 1 END AS seq, CASE itemsrcp_type WHEN ('N') THEN itemsrcp_price WHEN ('D') THEN (_r.item_listcost - (_r.item_listcost * itemsrcp_discntprcnt) - itemsrcp_fixedamtdiscount) ELSE 0.0 END AS price FROM itemsrcp WHERE ( (itemsrcp_itemsrc_id=_r.itemsrc_id) AND ((itemsrcp_warehous_id=pSiteid) OR (itemsrcp_warehous_id=-1)) AND ((itemsrcp_dropship=pDropship) OR (NOT itemsrcp_dropship)) AND (itemsrcp_qtybreak <= pQty) ) ORDER BY seq, itemsrcp_qtybreak DESC LIMIT 1 ) AS data ; RETURN _price; END; $$; ALTER FUNCTION public.itemsrcprice(pitemsrcid integer, psiteid integer, pdropship boolean, pqty numeric, pcurrid integer, peffective date) OWNER TO admin; -- -- Name: itemuombytype(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemuombytype(integer, text) RETURNS text LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pUomtype ALIAS FOR $2; _uom TEXT; BEGIN SELECT uom_name INTO _uom FROM ( SELECT uom_name FROM item JOIN itemuomconv ON (itemuomconv_item_id=item_id) JOIN itemuom ON (itemuom_itemuomconv_id=itemuomconv_id) JOIN uomtype ON (itemuom_uomtype_id=uomtype_id) JOIN uom ON (itemuomconv_to_uom_id=uom_id) WHERE((item_id=pItemid) AND (uomtype_name=pUomtype) AND (item_inv_uom_id != itemuomconv_to_uom_id)) UNION SELECT uom_name FROM item JOIN itemuomconv ON (itemuomconv_item_id=item_id) JOIN itemuom ON (itemuom_itemuomconv_id=itemuomconv_id) JOIN uomtype ON (itemuom_uomtype_id=uomtype_id) JOIN uom ON (itemuomconv_from_uom_id=uom_id) WHERE((item_id=pItemid) AND (uomtype_name=pUomtype) AND (item_inv_uom_id != itemuomconv_from_uom_id))) data LIMIT 1; IF (NOT FOUND) THEN SELECT uom_name INTO _uom FROM item JOIN uom ON (item_inv_uom_id=uom_id) WHERE(item_id=pItemid); END IF; RETURN _uom; END; $_$; ALTER FUNCTION public.itemuombytype(integer, text) OWNER TO admin; -- -- Name: itemuomfractionalbytype(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemuomfractionalbytype(integer, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pUomtype ALIAS FOR $2; _frac BOOLEAN; BEGIN SELECT itemuomconv_fractional INTO _frac FROM item JOIN itemuomconv ON (itemuomconv_item_id=item_id) JOIN itemuom ON (itemuom_itemuomconv_id=itemuomconv_id) JOIN uomtype ON (itemuom_uomtype_id=uomtype_id) WHERE((item_id=pItemid) AND (uomtype_name=pUomtype)) LIMIT 1; IF (NOT FOUND) THEN SELECT item_fractional INTO _frac FROM item JOIN uom ON (item_inv_uom_id=uom_id) WHERE(item_id=pItemid); END IF; RETURN _frac; END; $_$; ALTER FUNCTION public.itemuomfractionalbytype(integer, text) OWNER TO admin; -- -- Name: itemuomfractionalbyuom(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemuomfractionalbyuom(integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pUomid ALIAS FOR $2; _frac BOOLEAN; BEGIN SELECT itemuomconv_fractional INTO _frac FROM item JOIN itemuomconv ON (itemuomconv_item_id=item_id) WHERE((item_id=pItemid) AND ((itemuomconv_from_uom_id=item_inv_uom_id AND itemuomconv_to_uom_id=pUomid) OR (itemuomconv_to_uom_id=item_inv_uom_id AND itemuomconv_from_uom_id=pUomid))) LIMIT 1; IF (NOT FOUND) THEN SELECT item_fractional INTO _frac FROM item JOIN uom ON (item_inv_uom_id=uom_id) WHERE(item_id=pItemid); END IF; RETURN _frac; END; $_$; ALTER FUNCTION public.itemuomfractionalbyuom(integer, integer) OWNER TO admin; -- -- Name: itemuomratiobytype(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemuomratiobytype(integer, text) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pUomtype ALIAS FOR $2; _ratio NUMERIC; BEGIN -- Return the ration as alternate / inventory uom SELECT CASE WHEN(itemuomconv_from_uom_id=item_inv_uom_id) THEN itemuomconv_to_value / itemuomconv_from_value ELSE itemuomconv_from_value / itemuomconv_to_value END INTO _ratio FROM item JOIN itemuomconv ON (itemuomconv_item_id=item_id) JOIN itemuom ON (itemuom_itemuomconv_id=itemuomconv_id) JOIN uomtype ON (itemuom_uomtype_id=uomtype_id) WHERE((item_id=pItemid) AND (uomtype_name=pUomtype)) LIMIT 1; IF (NOT FOUND) THEN _ratio := 1.0; END IF; RETURN _ratio; END; $_$; ALTER FUNCTION public.itemuomratiobytype(integer, text) OWNER TO admin; -- -- Name: itemuomtouom(integer, integer, integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemuomtouom(integer, integer, integer, numeric) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN itemuomtouom($1, $2, $3, $4, 'qty'); END; $_$; ALTER FUNCTION public.itemuomtouom(integer, integer, integer, numeric) OWNER TO admin; -- -- Name: itemuomtouom(integer, integer, integer, numeric, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemuomtouom(pitemid integer, puomidfrom integer, puomidto integer, pqtyfrom numeric, plocale text) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _uomidFrom INTEGER; _uomidTo INTEGER; _uomidInv INTEGER; _valueFrom NUMERIC := 0.0; _valueTo NUMERIC := 0.0; _value NUMERIC := 0.0; _item RECORD; _conv RECORD; _frac BOOLEAN := FALSE; BEGIN SELECT item_inv_uom_id, item_fractional INTO _item FROM item WHERE(item_id=pItemid); IF(NOT FOUND) THEN RAISE EXCEPTION 'No item record was found for item id %', pItemid; END IF; _uomidFrom := COALESCE(pUomidFrom, _item.item_inv_uom_id); _uomidTo := COALESCE(pUomidTo, _item.item_inv_uom_id); _uomidInv := _item.item_inv_uom_id; -- Should we round the qty here or not? IF(_uomidFrom = _uomidTo) THEN -- Both from/to are the same. If it is the item inv uom -- then use the item fractional value otherwise assume -- it is fractional for now so the user gets the same value back. IF(_uomidFrom = _item.item_inv_uom_id) THEN _frac := _item.item_fractional; ELSE _frac := true; END IF; RETURN roundLocale(_frac, pQtyFrom, pLocale); END IF; -- Try a direct conversion SELECT itemuomconv_from_uom_id, itemuomconv_from_value, itemuomconv_to_uom_id, itemuomconv_to_value, itemuomconv_fractional INTO _conv FROM itemuomconv WHERE(((itemuomconv_from_uom_id=_uomidFrom AND itemuomconv_to_uom_id=_uomidTo) OR (itemuomconv_from_uom_id=_uomidTo AND itemuomconv_to_uom_id=_uomidFrom)) AND (itemuomconv_item_id=pItemid)); IF(FOUND) THEN IF(_conv.itemuomconv_from_uom_id=_uomidFrom) THEN _valueFrom := _conv.itemuomconv_from_value; _valueTo := _conv.itemuomconv_to_value; ELSE _valueFrom := _conv.itemuomconv_to_value; _valueTo := _conv.itemuomconv_from_value; END IF; -- If we are converting to the item inv uom use the item fractional value -- otherwise use the conversion fractional value. if(_uomidTo = _uomidInv) THEN _frac := _item.item_fractional; ELSE _frac := _conv.itemuomconv_fractional; END IF; _value := roundLocale(_frac, ((_valueTo/_valueFrom) * pQtyFrom), pLocale); ELSE -- Try to convert the from uom to the inventory uom SELECT itemuomconv_from_uom_id, itemuomconv_from_value, itemuomconv_to_uom_id, itemuomconv_to_value, itemuomconv_fractional INTO _conv FROM itemuomconv WHERE(((itemuomconv_from_uom_id=_uomidFrom AND itemuomconv_to_uom_id=_uomidInv) OR (itemuomconv_from_uom_id=_uomidInv AND itemuomconv_to_uom_id=_uomidFrom)) AND (itemuomconv_item_id=pItemid)); IF(NOT FOUND) THEN RAISE EXCEPTION 'A conversion for item_id % from uom_id % to inv_uom_id % was not found.', pItemid, _uomidFrom, _uomidInv; END IF; IF(_conv.itemuomconv_from_uom_id=_uomidInv) THEN _valueFrom := _conv.itemuomconv_from_value; _valueTo := _conv.itemuomconv_to_value; ELSE _valueFrom := _conv.itemuomconv_to_value; _valueTo := _conv.itemuomconv_from_value; END IF; _value := (_valueTo / _valueFrom); IF (_conv.itemuomconv_fractional OR _item.item_fractional) THEN _frac := TRUE; END IF; -- Try to convert the to uom to the inventory uom SELECT itemuomconv_from_uom_id, itemuomconv_from_value, itemuomconv_to_uom_id, itemuomconv_to_value, itemuomconv_fractional INTO _conv FROM itemuomconv WHERE(((itemuomconv_from_uom_id=_uomidInv AND itemuomconv_to_uom_id=_uomidTo) OR (itemuomconv_from_uom_id=_uomidTo AND itemuomconv_to_uom_id=_uomidInv)) AND (itemuomconv_item_id=pItemid)); IF(NOT FOUND) THEN RAISE EXCEPTION 'A conversion for item_id % from uom_id % to inv_uom_id % was not found.', pItemid, _uomidTo, _uomidInv; END IF; IF(_conv.itemuomconv_from_uom_id=_uomidInv) THEN _valueFrom := _conv.itemuomconv_from_value; _valueTo := _conv.itemuomconv_to_value; ELSE _valueFrom := _conv.itemuomconv_to_value; _valueTo := _conv.itemuomconv_from_value; END IF; _value := _value * (_valueTo / _valueFrom); IF (_conv.itemuomconv_fractional OR _item.item_fractional) THEN _frac := TRUE; END IF; _value := roundLocale(_frac, (_value * pQtyFrom), pLocale); END IF; RETURN _value; END; $$; ALTER FUNCTION public.itemuomtouom(pitemid integer, puomidfrom integer, puomidto integer, pqtyfrom numeric, plocale text) OWNER TO admin; -- -- Name: itemuomtouomratio(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION itemuomtouomratio(pitemid integer, puomidfrom integer, puomidto integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _uomidFrom INTEGER; _uomidTo INTEGER; _uomidInv INTEGER; _valueFrom NUMERIC := 0.0; _valueTo NUMERIC := 0.0; _value NUMERIC := 0.0; _item RECORD; _conv RECORD; BEGIN SELECT item_inv_uom_id INTO _item FROM item WHERE(item_id=pItemid); IF(NOT FOUND) THEN RAISE EXCEPTION 'No item record was found for item id %', pItemid; END IF; _uomidFrom := COALESCE(pUomidFrom, _item.item_inv_uom_id); _uomidTo := COALESCE(pUomidTo, _item.item_inv_uom_id); _uomidInv := _item.item_inv_uom_id; IF(_uomidFrom = _uomidTo) THEN RETURN 1.0; END IF; -- Try a direct conversion SELECT itemuomconv_from_uom_id, itemuomconv_from_value, itemuomconv_to_uom_id, itemuomconv_to_value INTO _conv FROM itemuomconv WHERE(((itemuomconv_from_uom_id=_uomidFrom AND itemuomconv_to_uom_id=_uomidTo) OR (itemuomconv_from_uom_id=_uomidTo AND itemuomconv_to_uom_id=_uomidFrom)) AND (itemuomconv_item_id=pItemid)); IF(FOUND) THEN IF(_conv.itemuomconv_from_uom_id=_uomidFrom) THEN _valueFrom := _conv.itemuomconv_from_value; _valueTo := _conv.itemuomconv_to_value; ELSE _valueFrom := _conv.itemuomconv_to_value; _valueTo := _conv.itemuomconv_from_value; END IF; _value := (_valueTo / _valueFrom); ELSE -- Try to convert the from uom to the inventory uom SELECT itemuomconv_from_uom_id, itemuomconv_from_value, itemuomconv_to_uom_id, itemuomconv_to_value INTO _conv FROM itemuomconv WHERE(((itemuomconv_from_uom_id=_uomidFrom AND itemuomconv_to_uom_id=_uomidInv) OR (itemuomconv_from_uom_id=_uomidInv AND itemuomconv_to_uom_id=_uomidFrom)) AND (itemuomconv_item_id=pItemid)); IF(NOT FOUND) THEN RAISE EXCEPTION 'A conversion for item_id % from uom_id % to inv_uom_id % was not found.', pItemid, _uomidFrom, _uomidInv; END IF; IF(_conv.itemuomconv_from_uom_id=_uomidInv) THEN _valueFrom := _conv.itemuomconv_from_value; _valueTo := _conv.itemuomconv_to_value; ELSE _valueFrom := _conv.itemuomconv_to_value; _valueTo := _conv.itemuomconv_from_value; END IF; _value := (_valueTo / _valueFrom); -- Try to convert the to uom to the inventory uom SELECT itemuomconv_from_uom_id, itemuomconv_from_value, itemuomconv_to_uom_id, itemuomconv_to_value INTO _conv FROM itemuomconv WHERE(((itemuomconv_from_uom_id=_uomidInv AND itemuomconv_to_uom_id=_uomidTo) OR (itemuomconv_from_uom_id=_uomidTo AND itemuomconv_to_uom_id=_uomidInv)) AND (itemuomconv_item_id=pItemid)); IF(NOT FOUND) THEN RAISE EXCEPTION 'A conversion for item_id % from uom_id % to inv_uom_id % was not found.', pItemid, _uomidTo, _uomidInv; END IF; IF(_conv.itemuomconv_from_uom_id=_uomidInv) THEN _valueFrom := _conv.itemuomconv_from_value; _valueTo := _conv.itemuomconv_to_value; ELSE _valueFrom := _conv.itemuomconv_to_value; _valueTo := _conv.itemuomconv_from_value; END IF; _value := _value * (_valueTo / _valueFrom); END IF; RETURN _value; END; $$; ALTER FUNCTION public.itemuomtouomratio(pitemid integer, puomidfrom integer, puomidto integer) OWNER TO admin; -- -- Name: last_agg(anyelement, anyelement); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION last_agg(anyelement, anyelement) RETURNS anyelement LANGUAGE sql STABLE AS $_$ SELECT $2; $_$; ALTER FUNCTION public.last_agg(anyelement, anyelement) OWNER TO admin; -- -- Name: login(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION login() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _p RECORD; BEGIN RETURN login(false); END; $$; ALTER FUNCTION public.login() OWNER TO admin; -- -- Name: login(boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION login(boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _setSearchPath ALIAS FOR $1; _p RECORD; BEGIN -- added support for PostgreSQL 9.2.0, Incident 21852 IF (compareversion('9.2.0') <= 0) THEN PERFORM pg_try_advisory_lock(datid::integer, pid) FROM pg_stat_activity WHERE(pid = pg_backend_pid()); ELSE PERFORM pg_try_advisory_lock(datid::integer, procpid) FROM pg_stat_activity WHERE(procpid = pg_backend_pid()); END IF; -- This is new to version 9.0 and higher and will error on older versions IF (compareversion('9.0.0') <= 0) THEN SET bytea_output TO escape; END IF; SELECT usr_id, userCanLogin(usr_username) AS usr_active INTO _p FROM usr WHERE (usr_username=getEffectiveXtUser()); IF (NOT FOUND) THEN RETURN -1; ELSIF (NOT _p.usr_active) THEN IF(SELECT metric_value='AdminOnly' FROM metric WHERE metric_name='AllowedUserLogins') THEN RETURN -3; END IF; RETURN -2; END IF; IF (_setSearchPath) THEN IF EXISTS(SELECT 1 FROM pg_proc JOIN pg_namespace ON (pronamespace=pg_namespace.oid) WHERE nspname='public' AND proname='buildsearchpath') THEN EXECUTE 'SET SEARCH_PATH TO ' || public.buildSearchPath(); END IF; END IF; RETURN 1; END; $_$; ALTER FUNCTION public.login(boolean) OWNER TO admin; -- -- Name: logout(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION logout() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (compareversion('9.2.0') <= 0) THEN PERFORM pg_advisory_unlock(datid::integer, pid) FROM pg_stat_activity WHERE(pid = pg_backend_pid()); ELSE PERFORM pg_advisory_unlock(datid::integer, procpid) FROM pg_stat_activity WHERE(procpid = pg_backend_pid()); END IF; RETURN 0; END; $$; ALTER FUNCTION public.logout() OWNER TO admin; -- -- Name: lowercost(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION lowercost(integer, text) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCosttype ALIAS FOR $2; BEGIN RETURN lowerCost(pItemid, pCosttype, TRUE); END; $_$; ALTER FUNCTION public.lowercost(integer, text) OWNER TO admin; -- -- Name: lowercost(integer, text, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION lowercost(integer, text, boolean) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCosttype ALIAS FOR $2; pActual ALIAS FOR $3; _type CHAR(1); _actCost NUMERIC; _actCost1 NUMERIC; _actCost2 NUMERIC; _stdCost NUMERIC; _stdCost1 NUMERIC; _stdCost2 NUMERIC; _cost NUMERIC; _cost1 NUMERIC; _cost2 NUMERIC; _batchsize NUMERIC; BEGIN SELECT item_type INTO _type FROM item WHERE (item_id=pItemid); _batchsize := COALESCE( ( SELECT bomhead_batchsize FROM bomhead WHERE ((bomhead_item_id=pItemId) AND (bomhead_rev_id=getActiveRevId('BOM',pItemId))) LIMIT 1), 1); -- find the lowercost in the base currency at the current conversion rate IF (_type IN ('M', 'F', 'B', 'T')) THEN IF (pActual) THEN SELECT SUM( CASE WHEN (bomitemcost_id IS NOT NULL AND bc.costelem_id IS NOT NULL) THEN round(currToBase(bomitemcost_curr_id, bomitemcost_actcost, CURRENT_DATE),6) * itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') ELSE round(currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE),6) * itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') END ) INTO _cost FROM bomitem(pItemid) JOIN item ON (item_id=bomitem_item_id AND item_type <> 'T') JOIN itemcost ON (itemcost_item_id=bomitem_item_id) JOIN costelem ic ON (ic.costelem_id=itemcost_costelem_id AND ic.costelem_type=pCosttype) LEFT OUTER JOIN bomitemcost ON (bomitemcost_bomitem_id=bomitem_id) LEFT OUTER JOIN costelem bc ON (bc.costelem_id=bomitemcost_costelem_id AND bc.costelem_type=pCosttype) WHERE ( CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1) ); ELSE SELECT SUM( CASE WHEN (bomitemcost_id IS NOT NULL AND bc.costelem_id IS NOT NULL) THEN bomitemcost_stdcost * itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') ELSE itemcost_stdcost * itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') END ) INTO _cost FROM bomitem(pItemid) JOIN item ON (item_id=bomitem_item_id AND item_type <> 'T') JOIN itemcost ON (itemcost_item_id=bomitem_item_id) JOIN costelem ON (costelem_id=itemcost_costelem_id AND costelem_type=pCosttype) LEFT OUTER JOIN bomitemcost ON (bomitemcost_bomitem_id=bomitem_id) LEFT OUTER JOIN costelem bc ON (bc.costelem_id=bomitemcost_costelem_id AND bc.costelem_type=pCosttype) WHERE ( CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1) ); END IF; IF (NOT FOUND) THEN _cost := NULL; END IF; ELSIF (_type IN ('C')) THEN SELECT SUM(CASE WHEN (bbomitem_qtyper = 0) THEN 0 ELSE currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE) / bbomitem_qtyper * bbomitem_costabsorb END), SUM(CASE WHEN (bbomitem_qtyper = 0) THEN 0 ELSE itemcost_stdcost / bbomitem_qtyper * bbomitem_costabsorb END) INTO _actCost1, _stdCost1 FROM itemcost JOIN costelem ON (itemcost_costelem_id=costelem_id) JOIN xtmfg.bbomitem ON (bbomitem_parent_item_id=itemcost_item_id) WHERE ( (bbomitem_item_id=pItemid) AND (CURRENT_DATE BETWEEN bbomitem_effective AND (bbomitem_expires - 1)) AND (costelem_type=pCosttype) ); SELECT SUM(CASE WHEN (t.bbomitem_qtyper = 0) THEN 0 ELSE currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE) * s.bbomitem_qtyper / t.bbomitem_qtyper * t.bbomitem_costabsorb END), SUM(CASE WHEN (t.bbomitem_qtyper = 0) THEN 0 ELSE itemcost_stdcost * s.bbomitem_qtyper / t.bbomitem_qtyper * t.bbomitem_costabsorb END) INTO _actCost2, _stdCost2 FROM costelem JOIN itemcost ON (costelem_id=itemcost_costelem_id) JOIN xtmfg.bbomitem AS s ON (itemcost_item_id=s.bbomitem_item_id) JOIN xtmfg.bbomitem AS t ON (s.bbomitem_parent_item_id=t.bbomitem_parent_item_id) JOIN item ON (s.bbomitem_item_id=item_id) WHERE ( (t.bbomitem_item_id=pItemid) AND ( CURRENT_DATE BETWEEN s.bbomitem_effective AND (s.bbomitem_expires - 1) ) AND ( CURRENT_DATE BETWEEN t.bbomitem_effective AND (t.bbomitem_expires - 1) ) AND (item_type='Y') AND (costelem_type=pCosttype) ); IF (pActual) THEN _cost = _actCost; _cost1 = _actCost1; _cost2 = _actCost2; ELSE _cost = _stdCost; _cost1 = _stdCost1; _cost2 = _stdCost2; -- should this be std or act? END IF; IF (_cost1 IS NULL AND _cost2 IS NULL) THEN _cost = NULL; ELSE _cost = COALESCE(_cost1, 0) + COALESCE(_cost2, 0); END IF; ELSE RETURN NULL; END IF; RETURN round(_cost,6); END; $_$; ALTER FUNCTION public.lowercost(integer, text, boolean) OWNER TO admin; -- -- Name: maintainbomworkspace(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION maintainbomworkspace() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _test TEXT; BEGIN SELECT tablename INTO _test FROM pg_tables WHERE (tablename='bomwork'); IF (NOT FOUND) THEN CREATE TEMPORARY TABLE bomwork ( bomwork_id INTEGER, bomwork_set_id INTEGER, bomwork_parent_id INTEGER, bomwork_seqnumber INTEGER, bomwork_parent_seqnumber INTEGER, bomwork_item_id INTEGER, bomwork_item_type CHARACTER(1), bomwork_status CHARACTER(1), bomwork_qtyper NUMERIC(20, 8), bomwork_scrap NUMERIC(20, 10), bomwork_level INTEGER, bomwork_effective DATE, bomwork_expires DATE, bomwork_stdunitcost NUMERIC(16, 4), bomwork_actunitcost NUMERIC(16, 4), bomwork_createwo BOOLEAN, bomwork_issuemethod CHARACTER(1) ); CREATE INDEX bomwork_set_id_idx ON bomwork(bomwork_set_id); END IF; RETURN 1; END; $$; ALTER FUNCTION public.maintainbomworkspace() OWNER TO admin; -- -- Name: markapcheckasposted(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION markapcheckasposted(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'markAPCheckAsPosted() is deprecated - use markCheckAsPosted() instead'; RETURN markCheckAsPosted($1); END; $_$; ALTER FUNCTION public.markapcheckasposted(integer) OWNER TO admin; -- -- Name: markapcheckasprinted(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION markapcheckasprinted(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'markAPCheckAsPrinted() is deprecated - use markCheckAsPrinted()'; RETURN markCheckAsPrinted($1); END; $_$; ALTER FUNCTION public.markapcheckasprinted(integer) OWNER TO admin; -- -- Name: markcheckasposted(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION markcheckasposted(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCheckid ALIAS FOR $1; BEGIN UPDATE checkhead SET checkhead_posted=TRUE WHERE (checkhead_id=pCheckid); RETURN 1; END; $_$; ALTER FUNCTION public.markcheckasposted(integer) OWNER TO admin; -- -- Name: markcheckasprinted(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION markcheckasprinted(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCheckid ALIAS FOR $1; BEGIN UPDATE checkhead SET checkhead_printed=TRUE WHERE (checkhead_id=pCheckid); RETURN 1; END; $_$; ALTER FUNCTION public.markcheckasprinted(integer) OWNER TO admin; -- -- Name: massexpirebomitem(integer, date, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION massexpirebomitem(integer, date, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pExpireDate ALIAS FOR $2; pECN ALIAS FOR $3; BEGIN UPDATE bomitem SET bomitem_expires=pExpireDate WHERE ( (bomitem_expires >= CURRENT_DATE) AND (bomitem_item_id=pItemid) AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id)) ); RETURN TRUE; END; $_$; ALTER FUNCTION public.massexpirebomitem(integer, date, text) OWNER TO admin; -- -- Name: massreplacebomitem(integer, integer, date, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION massreplacebomitem(integer, integer, date, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNewItemid ALIAS FOR $1; pOriginalItemid ALIAS FOR $2; pEffectiveDate ALIAS FOR $3; pECN ALIAS FOR $4; _effectiveDate DATE; _result INTEGER; BEGIN _effectiveDate := COALESCE(pEffectiveDate, CURRENT_DATE); IF (BOMContains(pOriginalItemid, pNewItemid) OR BOMContains(pNewItemid, pOriginalItemid)) THEN RETURN -1; END IF; INSERT INTO bomitem ( bomitem_parent_item_id, bomitem_seqnumber, bomitem_item_id, bomitem_qtyfxd, bomitem_qtyper, bomitem_uom_id, bomitem_scrap, bomitem_effective, bomitem_expires, bomitem_ecn, bomitem_createwo, bomitem_issuemethod, bomitem_subtype, bomitem_booitem_seq_id, bomitem_schedatwooper, bomitem_moddate, bomitem_rev_id, bomitem_char_id, bomitem_value ) SELECT bomitem_parent_item_id, bomitem_seqnumber, pNewItemid, bomitem_qtyfxd, bomitem_qtyper, bomitem_uom_id, bomitem_scrap, _effectiveDate, endOfTime(), pECN, bomitem_createwo, bomitem_issuemethod, 'I', bomitem_booitem_seq_id, bomitem_schedatwooper, CURRENT_DATE, getActiveRevId('BOM',bomitem_parent_item_id), bomitem_char_id, bomitem_value FROM bomitem WHERE ( (_effectiveDate < bomitem_expires) AND (bomitem_item_id=pOriginalItemid) AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id)) ); UPDATE bomitem SET bomitem_expires=_effectiveDate WHERE ( (_effectiveDate < bomitem_expires) AND (bomitem_item_id=pOriginalItemid) AND (bomitem_rev_id=getActiveRevid('BOM',bomitem_parent_item_id)) ); RETURN 1; END; $_$; ALTER FUNCTION public.massreplacebomitem(integer, integer, date, text) OWNER TO admin; -- -- Name: merge2crmaccts(integer, integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION merge2crmaccts(integer, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSourceId ALIAS FOR $1; pTargetId ALIAS FOR $2; _purge BOOLEAN := COALESCE($3, FALSE); _coldesc RECORD; _count INTEGER := 0; _hassubtype BOOLEAN; _mrgcol BOOLEAN; _result INTEGER := 0; _sel RECORD; _colname TEXT; _tmpid INTEGER; BEGIN -- Validate IF (pSourceId = pTargetId) THEN RAISE WARNING 'Tried to merge a CRM Account with itself: %.', pSourceId; RETURN 0; ELSIF (pSourceId IS NULL) THEN RAISE EXCEPTION 'Merge source id cannot be null [xtuple: merge, -1]'; ELSIF NOT(EXISTS(SELECT 1 FROM crmacct WHERE crmacct_id=pSourceId)) THEN RAISE EXCEPTION 'Merge source % not found [xtuple: merge, -2, %]', pSourceId, pSourceId; ELSIF (pTargetId IS NULL) THEN RAISE EXCEPTION 'Merge target id cannot be null [xtuple: merge, -3]'; ELSIF NOT(EXISTS(SELECT 1 FROM crmacct WHERE crmacct_id=pTargetId)) THEN RAISE EXCEPTION 'Merge target % not found [xtuple: merge, -4, %]', pTargetId, pTargetId; ELSIF NOT(EXISTS(SELECT 1 FROM crmacctsel WHERE (crmacctsel_src_crmacct_id=pSourceId) AND (crmacctsel_dest_crmacct_id=pTargetId))) THEN RAISE EXCEPTION 'Source % and target % have not been selected for merging [xtuple: merge, -5, %, %]', pSourceId, pTargetId, pSourceId, pTargetId; END IF; _result:= changeFkeyPointers('public', 'crmacct', pSourceId, pTargetId, ARRAY[ 'crmacctsel', 'crmacctmrgd' ], _purge) + changePseudoFKeyPointers('public', 'alarm', 'alarm_source_id', pSourceId, 'public', 'crmacct', pTargetId, 'alarm_source', 'CRMA', _purge) + changePseudoFKeyPointers('public', 'charass', 'charass_target_id', pSourceId, 'public', 'crmacct', pTargetId, 'charass_target_type', 'CRMACCT', _purge) + changePseudoFKeyPointers('public', 'comment', 'comment_source_id', pSourceId, 'public', 'crmacct', pTargetId, 'comment_source', 'CRMA', _purge) + changePseudoFKeyPointers('public', 'docass', 'docass_source_id', pSourceId, 'public', 'crmacct', pTargetId, 'docass_source_type', 'CRMA', _purge) + changePseudoFKeyPointers('public', 'docass', 'docass_target_id', pSourceId, 'public', 'crmacct', pTargetId, 'docass_target_type', 'CRMA', _purge) + changePseudoFKeyPointers('public', 'imageass', 'imageass_source_id', pSourceId, 'public', 'crmacct', pTargetId, 'imageass_source', 'CRMA', _purge) ; -- TODO: find a generic way to handle pseudofkeys in packages - see 9401 IF (fetchMetricBool('EnableBatchManager') AND packageIsEnabled('xtbatch')) THEN _result:= _result + changePseudoFKeyPointers('xtbatch', 'emlassc', 'emlassc_assc_id', pSourceId, 'public', 'crmacct', pTargetId, 'emlassc_type', 'CRMA', _purge); END IF; -- back up all of the values in the target record that are about to be changed FOR _coldesc IN SELECT attname, typname FROM pg_attribute JOIN pg_type ON (atttypid=pg_type.oid) JOIN pg_class ON (attrelid=pg_class.oid) JOIN pg_namespace ON (relnamespace=pg_namespace.oid) WHERE (attnum >= 0) AND (relname='crmacct') AND (nspname='public') AND (attname NOT IN ('crmacct_id', 'crmacct_number')) LOOP -- if we're supposed to merge this column at all EXECUTE 'SELECT ' || quote_ident('crmacctsel_mrg_' || _coldesc.attname) || ' FROM crmacctsel WHERE ((crmacctsel_src_crmacct_id=' || pSourceId || ') AND (crmacctsel_dest_crmacct_id=' || pTargetId || '))' INTO _mrgcol; IF (_mrgcol) THEN _colname := REPLACE(_coldesc.attname, 'crmacctsel_mrg_', ''); -- optionally back up the old value from the destination -- we'll back up the old value from the source further down IF (NOT _purge) THEN BEGIN EXECUTE 'INSERT INTO mrgundo ( mrgundo_schema, mrgundo_table, mrgundo_pkey_col, mrgundo_pkey_id, mrgundo_col, mrgundo_value, mrgundo_type, mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id ) SELECT ''public'', ''crmacct'', ''crmacct_id'', crmacct_id, ' || quote_literal(_colname) || ', ' || quote_ident(_colname) || ', ' || quote_literal(_coldesc.typname) || ', ''public'', ''crmacct'', crmacct_id FROM crmacct WHERE (crmacct_id=' || pTargetId || ');' ; EXCEPTION WHEN unique_violation THEN RAISE EXCEPTION 'Could not make a backup copy of % when merging % into % [xtuple: merge, -8, %, %, public, crmacct, %]', _colname, pSourceId, pTargetId, _colname, pSourceId, pTargetId; END; END IF; -- TODO: what do we do about users? /* update the destination crmacct in one of 3 different ways: - crmacct_notes might be concatenated from more than one source record - foreign keys to crm account subtype records (e.g. crmacct_cust_id) must not leave orphaned records and must avoid uniqueness violations - some fields can simply be updated in place */ IF (_colname = 'crmacct_notes') THEN EXECUTE 'UPDATE crmacct dest SET ' || quote_ident(_colname) || '=dest.' || quote_ident(_colname) || E' || E''\\n'' || src.' || _colname || ' FROM crmacct src JOIN crmacctsel ON (src.crmacct_id=crmacctsel_src_crmacct_id) WHERE ((dest.crmacct_id=crmacctsel_dest_crmacct_id) AND (dest.crmacct_id!=crmacctsel_src_crmacct_id));'; ELSIF (_colname IN ('crmacct_cust_id', 'crmacct_prospect_id', 'crmacct_vend_id', 'crmacct_taxauth_id', 'crmacct_emp_id', 'crmacct_salesrep_id')) THEN IF (_colname IN ('crmacct_cust_id', 'crmacct_prospect_id')) THEN EXECUTE 'SELECT src.' || quote_ident(_colname) || ' IS NOT NULL AND (dest.crmacct_prospect_id IS NOT NULL OR dest.crmacct_cust_id IS NOT NULL) FROM crmacct src JOIN crmacctsel ON (src.crmacct_id=crmacctsel_src_crmacct_id) JOIN crmacct dest ON (crmacctsel_dest_crmacct_id=dest.crmacct_id) WHERE ((src.crmacct_id=' || pSourceId || ') AND (dest.crmacct_id=' || pTargetId || '))' INTO _hassubtype; IF (_hassubtype) THEN RAISE EXCEPTION 'Cannot merge two CRM Accounts that both refer to Customers and/or Prospects [xtuple: merge, -6, %, %]', pSourceId, pTargetId; END IF; ELSE EXECUTE 'SELECT src.' || quote_ident(_colname) || ' IS NOT NULL AND dest.'|| quote_ident(_colname) || ' IS NOT NULL FROM crmacct src JOIN crmacctsel ON (src.crmacct_id=crmacctsel_src_crmacct_id) JOIN crmacct dest ON (crmacctsel_dest_crmacct_id=dest.crmacct_id) WHERE ((src.crmacct_id=' || pSourceId || ') AND (dest.crmacct_id=' || pTargetId || '))' INTO _hassubtype; IF (_hassubtype) THEN RAISE EXCEPTION 'Cannot merge CRM Accounts until the % child records have been merged [xtuple: merge, -7, %, %, %]', _colname, _colname, pSourceId, pTargetId; END IF; END IF; /* clearing the source separately from setting the target avoids problems with triggers updating the wrong records */ EXECUTE 'SELECT ' || quote_ident(_colname) || ' FROM crmacct WHERE crmacct_id=' || pSourceId INTO _tmpid; -- now we have the data to back up the source IF (NOT _purge) THEN BEGIN EXECUTE 'INSERT INTO mrgundo ( mrgundo_schema, mrgundo_table, mrgundo_pkey_col, mrgundo_pkey_id, mrgundo_col, mrgundo_value, mrgundo_type, mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id ) SELECT ''public'', ''crmacct'', ''crmacct_id'', crmacct_id, ' || quote_literal(_colname) || ', ' || quote_ident(_colname) || ', ' || quote_literal(_coldesc.typname) || ', ''public'', ''crmacct'', ' || pTargetId || ' FROM crmacct WHERE (crmacct_id=' || pSourceId || ');' ; EXCEPTION WHEN unique_violation THEN RAISE EXCEPTION 'Could not make a backup copy of % when merging % into % [xtuple: merge, -8, %, %, public, crmacct, %]', _colname, pSourceId, pTargetId, _colname, pSourceId, pTargetId; END; END IF; EXECUTE 'UPDATE crmacct SET ' || quote_ident(_colname) || '=NULL WHERE (crmacct_id=' || pSourceId || ');'; EXECUTE 'UPDATE crmacct SET ' || quote_ident(_colname) || '=' || quote_literal(_tmpid) || ' WHERE (crmacct_id=' || pTargetId || ');'; ELSE EXECUTE 'UPDATE crmacct dest SET ' || quote_ident(_colname) || ' =src.' || quote_ident(_colname) || ' FROM crmacct src WHERE ((dest.crmacct_id=' || pTargetId || ') AND (src.crmacct_id=' || pSourceId || '));'; END IF; GET DIAGNOSTICS _count = ROW_COUNT; _result := _result + _count; END IF; END LOOP; IF (_purge) THEN DELETE FROM crmacct WHERE crmacct = pSourceId; ELSE INSERT INTO mrgundo ( mrgundo_schema, mrgundo_table, mrgundo_pkey_col, mrgundo_pkey_id, mrgundo_col, mrgundo_value, mrgundo_type, mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id ) SELECT 'public', 'crmacct', 'crmacct_id', pSourceId, 'crmacct_active', crmacct_active, 'bool', 'public', 'crmacct', pTargetId FROM crmacct WHERE crmacct_active AND (crmacct_id = pSourceId); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count > 0) THEN _result := _result + _count; UPDATE crmacct SET crmacct_active = false WHERE (crmacct_id=pSourceId); END IF; -- make a special record of the source crm account so we can delete it later INSERT INTO mrgundo ( mrgundo_schema, mrgundo_table, mrgundo_pkey_col, mrgundo_pkey_id, mrgundo_col, mrgundo_value, mrgundo_type, mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id ) VALUES ( 'public', 'crmacct', 'crmacct_id', pSourceId, NULL, NULL, NULL, 'public', 'crmacct', pTargetId); END IF; DELETE FROM crmacctsel WHERE (crmacctsel_src_crmacct_id=pSourceId); RETURN _result; END; $_$; ALTER FUNCTION public.merge2crmaccts(integer, integer, boolean) OWNER TO admin; -- -- Name: FUNCTION merge2crmaccts(integer, integer, boolean); Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON FUNCTION merge2crmaccts(integer, integer, boolean) IS 'This function merges two crmacct records as decribed in crmacctsel records. For each field in the crmacctsel record marked TRUE, the data are copied from the crmacct record with crmacct_id=pSourceId to the record with crmacct_id=pTargetId. If the purge argument is TRUE, the source record is deleted. If it is FALSE, then mrgundo records are created so the merge can later be undone.'; -- -- Name: mergecrmaccts(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION mergecrmaccts(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTargetId ALIAS FOR $1; _purge BOOLEAN := COALESCE($2, FALSE); _retval INTEGER; BEGIN /* if crmacctsel says the target should not keep its original notes, clear them. notes are special because the merge allows concatenating them from multiple sources. this needs to be kept in sync with merge2crmaccts' similar check. */ IF NOT (SELECT crmacctsel_mrg_crmacct_notes FROM crmacctsel WHERE crmacctsel_src_crmacct_id=crmacctsel_dest_crmacct_id AND crmacctsel_dest_crmacct_id=pTargetId) THEN IF (NOT _purge) THEN INSERT INTO mrgundo ( mrgundo_schema, mrgundo_table, mrgundo_pkey_col, mrgundo_pkey_id, mrgundo_col, mrgundo_value, mrgundo_type, mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id) SELECT 'public', 'crmacct', crmacct_id, 'public', 'crmacct', 'crmacct_id', crmacct_id, 'crmacct_notes', crmacct_notes, 'text', 'public', 'crmacct', crmacct_id FROM crmacct WHERE (crmacct_id=pTargetId); END IF; UPDATE crmacct SET crmacct_notes = '' WHERE (crmacct_id=pTargetId); END IF; -- merge the data from the various source records SELECT SUM(merge2crmaccts(crmacctsel_src_crmacct_id, pTargetId, _purge)) INTO _retval FROM crmacctsel WHERE ((crmacctsel_dest_crmacct_id=pTargetId) AND (crmacctsel_dest_crmacct_id!=crmacctsel_src_crmacct_id)); DELETE FROM crmacctsel WHERE crmacctsel_dest_crmacct_id=pTargetId; RETURN COALESCE(_retval, 0); END; $_$; ALTER FUNCTION public.mergecrmaccts(integer, boolean) OWNER TO admin; -- -- Name: FUNCTION mergecrmaccts(integer, boolean); Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON FUNCTION mergecrmaccts(integer, boolean) IS 'This function uses the crmacctsel table to merge multiple crmacct records together. Only the merges into the specified target account are performed. Most of the work is done by repeated calls to the merge2crmaccts function. If the purge argument is FALSE, data are kept to allow reversing the merge.'; -- -- Name: movebomitemdown(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION movebomitemdown(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBomitemid ALIAS FOR $1; _nextBomitem RECORD; BEGIN SELECT nextbomitem.bomitem_seqnumber AS next_seqnumber, thisbomitem.bomitem_seqnumber AS this_seqnumber, thisbomitem.bomitem_parent_item_id AS parent_item_id, thisbomitem.bomitem_rev_id AS rev_id INTO _nextBomitem FROM bomitem AS nextbomitem, bomitem AS thisbomitem WHERE ((nextbomitem.bomitem_seqnumber > thisbomitem.bomitem_seqnumber) AND (nextbomitem.bomitem_parent_item_id=thisbomitem.bomitem_parent_item_id) AND (nextbomitem.bomitem_rev_id=thisbomitem.bomitem_rev_id) AND (thisbomitem.bomitem_id=pBomitemid)) ORDER BY next_seqnumber LIMIT 1; IF (FOUND) THEN -- Swap the seqnumber of the current bomitem and the next bomitem -- There is the potential for multiple bomitems with the same seqnumber UPDATE bomitem SET bomitem_seqnumber=0 WHERE (bomitem_seqnumber=_nextBomitem.next_seqnumber) AND (bomitem_parent_item_id=_nextBomitem.parent_item_id) AND (bomitem_rev_id=_nextBomitem.rev_id); UPDATE bomitem SET bomitem_seqnumber=_nextBomitem.next_seqnumber WHERE (bomitem_seqnumber=_nextBomitem.this_seqnumber) AND (bomitem_parent_item_id=_nextBomitem.parent_item_id) AND (bomitem_rev_id=_nextBomitem.rev_id); UPDATE bomitem SET bomitem_seqnumber=_nextBomitem.this_seqnumber WHERE (bomitem_seqnumber=0) AND (bomitem_parent_item_id=_nextBomitem.parent_item_id) AND (bomitem_rev_id=_nextBomitem.rev_id); END IF; RETURN 1; END; $_$; ALTER FUNCTION public.movebomitemdown(integer) OWNER TO admin; -- -- Name: movebomitemup(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION movebomitemup(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBomitemid ALIAS FOR $1; _nextBomitem RECORD; BEGIN SELECT nextbomitem.bomitem_seqnumber AS next_seqnumber, thisbomitem.bomitem_seqnumber AS this_seqnumber, thisbomitem.bomitem_parent_item_id AS parent_item_id, thisbomitem.bomitem_rev_id AS rev_id INTO _nextBomitem FROM bomitem AS nextbomitem, bomitem AS thisbomitem WHERE ((nextbomitem.bomitem_seqnumber < thisbomitem.bomitem_seqnumber) AND (nextbomitem.bomitem_parent_item_id=thisbomitem.bomitem_parent_item_id) AND (nextbomitem.bomitem_rev_id=thisbomitem.bomitem_rev_id) AND (thisbomitem.bomitem_id=pBomitemid)) ORDER BY next_seqnumber DESC LIMIT 1; IF (FOUND) THEN -- Swap the seqnumber of the current bomitem and the next bomitem -- There is the potential for multiple bomitems with the same seqnumber UPDATE bomitem SET bomitem_seqnumber=0 WHERE (bomitem_seqnumber=_nextBomitem.next_seqnumber) AND (bomitem_parent_item_id=_nextBomitem.parent_item_id) AND (bomitem_rev_id=_nextBomitem.rev_id); UPDATE bomitem SET bomitem_seqnumber=_nextBomitem.next_seqnumber WHERE (bomitem_seqnumber=_nextBomitem.this_seqnumber) AND (bomitem_parent_item_id=_nextBomitem.parent_item_id) AND (bomitem_rev_id=_nextBomitem.rev_id); UPDATE bomitem SET bomitem_seqnumber=_nextBomitem.this_seqnumber WHERE (bomitem_seqnumber=0) AND (bomitem_parent_item_id=_nextBomitem.parent_item_id) AND (bomitem_rev_id=_nextBomitem.rev_id); END IF; RETURN 1; END; $_$; ALTER FUNCTION public.movebomitemup(integer) OWNER TO admin; -- -- Name: moveccarddown(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION moveccarddown(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCcardid ALIAS FOR $1; _nextCcard RECORD; BEGIN SELECT nextCcard.ccard_id, nextCcard.ccard_seq AS next_seqnumber, thisCcard.ccard_seq AS this_seqnumber INTO _nextCcard FROM Ccard AS nextCcard, Ccard AS thisCcard WHERE ((nextCcard.ccard_seq > thisCcard.ccard_seq) AND (nextCcard.ccard_cust_id=thisCcard.ccard_cust_id) AND (thisCcard.ccard_id=pCcardid)) ORDER BY next_seqnumber LIMIT 1; IF (FOUND) THEN -- Swap the seqnumber of the current Ccard and the next Ccard UPDATE Ccard SET ccard_seq=_nextCcard.next_seqnumber WHERE (ccard_id=pCcardid); UPDATE Ccard SET ccard_seq=_nextCcard.this_seqnumber WHERE (ccard_id=_nextCcard.ccard_id); END IF; RETURN 1; END; $_$; ALTER FUNCTION public.moveccarddown(integer) OWNER TO admin; -- -- Name: moveccardup(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION moveccardup(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCcardid ALIAS FOR $1; _nextCcard RECORD; BEGIN SELECT nextCcard.ccard_id AS ccard_id, nextCcard.ccard_seq AS next_seqnumber, thisCcard.ccard_seq AS this_seqnumber INTO _nextCcard FROM ccard AS nextCcard, ccard AS thisCcard WHERE ((nextCcard.ccard_seq < thisCcard.ccard_seq) AND (nextCcard.ccard_cust_id=thisCcard.ccard_cust_id) AND (thisCcard.ccard_id=pCcardid)) ORDER BY next_seqnumber DESC LIMIT 1; IF (FOUND) THEN -- Swap the seqnumber of the current Ccard and the next Ccard UPDATE Ccard SET ccard_seq=_nextCcard.next_seqnumber WHERE (ccard_id=pCcardid); UPDATE Ccard SET ccard_seq=_nextCcard.this_seqnumber WHERE (ccard_id=_nextCcard.ccard_id); END IF; RETURN 1; END; $_$; ALTER FUNCTION public.moveccardup(integer) OWNER TO admin; -- -- Name: moveflgroupdown(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION moveflgroupdown(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlgrpid ALIAS FOR $1; _from RECORD; _to RECORD; BEGIN SELECT flgrp_id AS id, flgrp_flhead_id AS flhead_id, flgrp_flgrp_id AS flgrp_id, flgrp_order AS ord INTO _from FROM flgrp WHERE (flgrp_id=pFlgrpid); IF (NOT FOUND) THEN RETURN -1; END IF; SELECT id, type, ord INTO _to FROM (SELECT flitem_id AS id, 'I' AS type, flitem_order AS ord FROM flitem WHERE ((flitem_flgrp_id=_from.flgrp_id) AND (flitem_flhead_id=_from.flhead_id)) UNION SELECT flgrp_id AS id, 'G' AS type, flgrp_order AS ord FROM flgrp WHERE ((flgrp_flgrp_id=_from.flgrp_id) AND (flgrp_flhead_id=_from.flhead_id)) UNION SELECT flspec_id AS id, 'S' AS type, flspec_order AS ord FROM flspec WHERE ((flspec_flgrp_id=_from.flgrp_id) AND (flspec_flhead_id=_from.flhead_id)) ) AS data WHERE (ord > _from.ord) ORDER BY ord LIMIT 1; IF (FOUND) THEN UPDATE flgrp SET flgrp_order=_to.ord WHERE (flgrp_id=_from.id); IF (_to.type='I') THEN UPDATE flitem SET flitem_order=_from.ord WHERE (flitem_id=_to.id); ELSE IF (_to.type='G') THEN UPDATE flgrp SET flgrp_order=_from.ord WHERE (flgrp_id=_to.id); ELSE IF (_to.type='S') THEN UPDATE flspec SET flspec_order=_from.ord WHERE (flspec_id=_to.id); END IF; END IF; END IF; END IF; RETURN 0; END; $_$; ALTER FUNCTION public.moveflgroupdown(integer) OWNER TO admin; -- -- Name: moveflgroupup(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION moveflgroupup(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlgrpid ALIAS FOR $1; _from RECORD; _to RECORD; BEGIN SELECT flgrp_id AS id, flgrp_flhead_id AS flhead_id, flgrp_flgrp_id AS flgrp_id, flgrp_order AS ord INTO _from FROM flgrp WHERE (flgrp_id=pFlgrpid); IF (NOT FOUND) THEN RETURN -1; END IF; SELECT id, type, ord INTO _to FROM (SELECT flitem_id AS id, 'I' AS type, flitem_order AS ord FROM flitem WHERE ((flitem_flgrp_id=_from.flgrp_id) AND (flitem_flhead_id=_from.flhead_id)) UNION SELECT flgrp_id AS id, 'G' AS type, flgrp_order AS ord FROM flgrp WHERE ((flgrp_flgrp_id=_from.flgrp_id) AND (flgrp_flhead_id=_from.flhead_id)) UNION SELECT flspec_id AS id, 'S' AS type, flspec_order AS ord FROM flspec WHERE ((flspec_flgrp_id=_from.flgrp_id) AND (flspec_flhead_id=_from.flhead_id)) ) AS data WHERE (ord < _from.ord) ORDER BY ord DESC LIMIT 1; IF (FOUND) THEN UPDATE flgrp SET flgrp_order=_to.ord WHERE (flgrp_id=_from.id); IF (_to.type='I') THEN UPDATE flitem SET flitem_order=_from.ord WHERE (flitem_id=_to.id); ELSE IF (_to.type='G') THEN UPDATE flgrp SET flgrp_order=_from.ord WHERE (flgrp_id=_to.id); ELSE IF (_to.type='S') THEN UPDATE flspec SET flspec_order=_from.ord WHERE (flspec_id=_to.id); END IF; END IF; END IF; END IF; RETURN 0; END; $_$; ALTER FUNCTION public.moveflgroupup(integer) OWNER TO admin; -- -- Name: moveflitemdown(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION moveflitemdown(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlitemid ALIAS FOR $1; _from RECORD; _to RECORD; BEGIN SELECT flitem_id AS id, flitem_flhead_id AS flhead_id, flitem_flgrp_id AS flgrp_id, flitem_order AS ord INTO _from FROM flitem WHERE (flitem_id=pFlitemid); IF (NOT FOUND) THEN RETURN -1; END IF; SELECT id, type, ord INTO _to FROM (SELECT flitem_id AS id, 'I' AS type, flitem_order AS ord FROM flitem WHERE ((flitem_flgrp_id=_from.flgrp_id) AND (flitem_flhead_id=_from.flhead_id)) UNION SELECT flgrp_id AS id, 'G' AS type, flgrp_order AS ord FROM flgrp WHERE ((flgrp_flgrp_id=_from.flgrp_id) AND (flgrp_flhead_id=_from.flhead_id)) UNION SELECT flspec_id AS id, 'S' AS type, flspec_order AS ord FROM flspec WHERE ((flspec_flgrp_id=_from.flgrp_id) AND (flspec_flhead_id=_from.flhead_id)) ) AS data WHERE (ord > _from.ord) ORDER BY ord LIMIT 1; IF (FOUND) THEN UPDATE flitem SET flitem_order=_to.ord WHERE (flitem_id=_from.id); IF (_to.type='I') THEN UPDATE flitem SET flitem_order=_from.ord WHERE (flitem_id=_to.id); ELSE IF (_to.type='G') THEN UPDATE flgrp SET flgrp_order=_from.ord WHERE (flgrp_id=_to.id); ELSE IF (_to.type='S') THEN UPDATE flspec SET flspec_order=_from.ord WHERE (flspec_id=_to.id); END IF; END IF; END IF; END IF; RETURN 0; END; $_$; ALTER FUNCTION public.moveflitemdown(integer) OWNER TO admin; -- -- Name: moveflitemup(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION moveflitemup(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlitemid ALIAS FOR $1; _from RECORD; _to RECORD; BEGIN SELECT flitem_id AS id, flitem_flhead_id AS flhead_id, flitem_flgrp_id AS flgrp_id, flitem_order AS ord INTO _from FROM flitem WHERE (flitem_id=pFlitemid); IF (NOT FOUND) THEN RETURN -1; END IF; SELECT id, type, ord INTO _to FROM (SELECT flitem_id AS id, 'I' AS type, flitem_order AS ord FROM flitem WHERE ((flitem_flgrp_id=_from.flgrp_id) AND (flitem_flhead_id=_from.flhead_id)) UNION SELECT flgrp_id AS id, 'G' AS type, flgrp_order AS ord FROM flgrp WHERE ((flgrp_flgrp_id=_from.flgrp_id) AND (flgrp_flhead_id=_from.flhead_id)) UNION SELECT flspec_id AS id, 'S' AS type, flspec_order AS ord FROM flspec WHERE ((flspec_flgrp_id=_from.flgrp_id) AND (flspec_flhead_id=_from.flhead_id)) ) AS data WHERE (ord < _from.ord) ORDER BY ord DESC LIMIT 1; IF (FOUND) THEN UPDATE flitem SET flitem_order=_to.ord WHERE (flitem_id=_from.id); IF (_to.type='I') THEN UPDATE flitem SET flitem_order=_from.ord WHERE (flitem_id=_to.id); ELSE IF (_to.type='G') THEN UPDATE flgrp SET flgrp_order=_from.ord WHERE (flgrp_id=_to.id); ELSE IF (_to.type='S') THEN UPDATE flspec SET flspec_order=_from.ord WHERE (flspec_id=_to.id); END IF; END IF; END IF; END IF; RETURN 0; END; $_$; ALTER FUNCTION public.moveflitemup(integer) OWNER TO admin; -- -- Name: moveflspecdown(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION moveflspecdown(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlspecid ALIAS FOR $1; _from RECORD; _to RECORD; BEGIN SELECT flspec_id AS id, flspec_flhead_id AS flhead_id, flspec_flgrp_id AS flgrp_id, flspec_order AS ord INTO _from FROM flspec WHERE (flspec_id=pFlspecid); IF (NOT FOUND) THEN RETURN -1; END IF; SELECT id, type, ord INTO _to FROM (SELECT flitem_id AS id, 'I' AS type, flitem_order AS ord FROM flitem WHERE ((flitem_flgrp_id=_from.flgrp_id) AND (flitem_flhead_id=_from.flhead_id)) UNION SELECT flgrp_id AS id, 'G' AS type, flgrp_order AS ord FROM flgrp WHERE ((flgrp_flgrp_id=_from.flgrp_id) AND (flgrp_flhead_id=_from.flhead_id)) UNION SELECT flspec_id AS id, 'S' AS type, flspec_order AS ord FROM flspec WHERE ((flspec_flgrp_id=_from.flgrp_id) AND (flspec_flhead_id=_from.flhead_id)) ) AS data WHERE (ord > _from.ord) ORDER BY ord LIMIT 1; IF (FOUND) THEN UPDATE flspec SET flspec_order=_to.ord WHERE (flspec_id=_from.id); IF (_to.type='I') THEN UPDATE flitem SET flitem_order=_from.ord WHERE (flitem_id=_to.id); ELSE IF (_to.type='G') THEN UPDATE flgrp SET flgrp_order=_from.ord WHERE (flgrp_id=_to.id); ELSE IF (_to.type='S') THEN UPDATE flspec SET flspec_order=_from.ord WHERE (flspec_id=_to.id); END IF; END IF; END IF; END IF; RETURN 0; END; $_$; ALTER FUNCTION public.moveflspecdown(integer) OWNER TO admin; -- -- Name: moveflspecup(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION moveflspecup(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlspecid ALIAS FOR $1; _from RECORD; _to RECORD; BEGIN SELECT flspec_id AS id, flspec_flhead_id AS flhead_id, flspec_flgrp_id AS flgrp_id, flspec_order AS ord INTO _from FROM flspec WHERE (flspec_id=pFlspecid); IF (NOT FOUND) THEN RETURN -1; END IF; SELECT id, type, ord INTO _to FROM (SELECT flitem_id AS id, 'I' AS type, flitem_order AS ord FROM flitem WHERE ((flitem_flgrp_id=_from.flgrp_id) AND (flitem_flhead_id=_from.flhead_id)) UNION SELECT flgrp_id AS id, 'G' AS type, flgrp_order AS ord FROM flgrp WHERE ((flgrp_flgrp_id=_from.flgrp_id) AND (flgrp_flhead_id=_from.flhead_id)) UNION SELECT flspec_id AS id, 'S' AS type, flspec_order AS ord FROM flspec WHERE ((flspec_flgrp_id=_from.flgrp_id) AND (flspec_flhead_id=_from.flhead_id)) ) AS data WHERE (ord < _from.ord) ORDER BY ord DESC LIMIT 1; IF (FOUND) THEN UPDATE flspec SET flspec_order=_to.ord WHERE (flspec_id=_from.id); IF (_to.type='I') THEN UPDATE flitem SET flitem_order=_from.ord WHERE (flitem_id=_to.id); ELSE IF (_to.type='G') THEN UPDATE flgrp SET flgrp_order=_from.ord WHERE (flgrp_id=_to.id); ELSE IF (_to.type='S') THEN UPDATE flspec SET flspec_order=_from.ord WHERE (flspec_id=_to.id); END IF; END IF; END IF; END IF; RETURN 0; END; $_$; ALTER FUNCTION public.moveflspecup(integer) OWNER TO admin; -- -- Name: movescript(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION movescript(integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pscriptid ALIAS FOR $1; poldpkgid ALIAS FOR $2; pnewpkgid ALIAS FOR $3; _deletestr TEXT; _destination TEXT; _insertstr TEXT; _rows INTEGER; _selectstr TEXT; _source TEXT; _record RECORD; BEGIN IF (poldpkgid = pnewpkgid) THEN RETURN 0; END IF; IF (poldpkgid = -1) THEN _source = 'public.script'; ELSE SELECT pkghead_name || '.pkgscript' INTO _source FROM pkghead WHERE pkghead_id=poldpkgid; IF NOT FOUND THEN RETURN -1; END IF; END IF; IF (pnewpkgid = -1) THEN _destination = 'public.script'; ELSE SELECT pkghead_name || '.pkgscript' INTO _destination FROM pkghead WHERE pkghead_id=pnewpkgid; IF NOT FOUND THEN RETURN -2; END IF; END IF; _selectstr := ' SELECT * FROM ' || _source || ' WHERE script_id = ' || pscriptid; EXECUTE _selectstr INTO _record; _deletestr := 'DELETE FROM ONLY ' || _source || ' WHERE script_id = ' || pscriptid; EXECUTE _deletestr; GET DIAGNOSTICS _rows = ROW_COUNT; --RAISE NOTICE '% rows from %', _rows, _deletestr; IF (_rows < 1) THEN RETURN -3; ELSIF (_rows > 1) THEN RAISE EXCEPTION 'Tried to delete % scripts with the id % when there should be exactly 1', _rows, pscriptid; END IF; _insertstr := 'INSERT INTO ' || _destination || ' (script_id, script_name, script_order, script_enabled, ' || ' script_source, script_notes) VALUES (' || _record.script_id || ',' || quote_literal(_record.script_name) || ',' || _record.script_order || ',' || _record.script_enabled || ',' || quote_literal(_record.script_source) || ',' || quote_literal(_record.script_notes ) || ');' ; EXECUTE _insertstr; GET DIAGNOSTICS _rows = ROW_COUNT; --RAISE NOTICE '% rows from %', _rows, _insertstr; IF (_rows < 1) THEN RETURN -4; ELSIF (_rows > 1) THEN RAISE EXCEPTION 'Tried to insert % scripts with the id % when there should be exactly 1', _rows, pscriptid; END IF; RETURN pscriptid; END; $_$; ALTER FUNCTION public.movescript(integer, integer, integer) OWNER TO admin; -- -- Name: moveuiform(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION moveuiform(integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE puiformid ALIAS FOR $1; poldpkgid ALIAS FOR $2; pnewpkgid ALIAS FOR $3; _deletestr TEXT; _destination TEXT; _insertstr TEXT; _rows INTEGER; _selectstr TEXT; _source TEXT; _record RECORD; BEGIN IF (poldpkgid = pnewpkgid) THEN RETURN 0; END IF; IF (poldpkgid = -1) THEN _source = 'public.uiform'; ELSE SELECT pkghead_name || '.pkguiform' INTO _source FROM pkghead WHERE pkghead_id=poldpkgid; IF NOT FOUND THEN RETURN -1; END IF; END IF; IF (pnewpkgid = -1) THEN _destination = 'public.uiform'; ELSE SELECT pkghead_name || '.pkguiform' INTO _destination FROM pkghead WHERE pkghead_id=pnewpkgid; IF NOT FOUND THEN RETURN -2; END IF; END IF; _selectstr := ' SELECT * FROM ' || _source || ' WHERE uiform_id = ' || puiformid; EXECUTE _selectstr INTO _record; _deletestr := 'DELETE FROM ONLY ' || _source || ' WHERE uiform_id = ' || puiformid; EXECUTE _deletestr; GET DIAGNOSTICS _rows = ROW_COUNT; --RAISE NOTICE '% rows from %', _rows, _deletestr; IF (_rows < 1) THEN RETURN -3; ELSIF (_rows > 1) THEN RAISE EXCEPTION 'Tried to delete % uiforms with the id % when there should be exactly 1', _rows, puiformid; END IF; _insertstr := 'INSERT INTO ' || _destination || ' (uiform_id, uiform_name, uiform_order, uiform_enabled, ' || ' uiform_source, uiform_notes) VALUES (' || _record.uiform_id || ',' || quote_literal(_record.uiform_name) || ',' || _record.uiform_order || ',' || _record.uiform_enabled || ',' || quote_literal(_record.uiform_source) || ',' || quote_literal(_record.uiform_notes ) || ');' ; EXECUTE _insertstr; GET DIAGNOSTICS _rows = ROW_COUNT; --RAISE NOTICE '% rows from %', _rows, _insertstr; IF (_rows < 1) THEN RETURN -4; ELSIF (_rows > 1) THEN RAISE EXCEPTION 'Tried to insert % uiforms with the id % when there should be exactly 1', _rows, puiformid; END IF; RETURN puiformid; END; $_$; ALTER FUNCTION public.moveuiform(integer, integer, integer) OWNER TO admin; -- -- Name: moveupdown(integer, text, text, text, text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION moveupdown(pid integer, pschema text, ptable text, pseqcol text, pjoincol text, pextra text, pdir text) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE _keyfield TEXT; _keysize INTEGER; _qry TEXT; _r RECORD; _rowcnt INTEGER; _schema TEXT := COALESCE(pSchema, 'public'); BEGIN RAISE DEBUG 'moveUpDown(%, %, %, %, %, %, %) entered', pId, pSchema, pTable, pSeqCol, pJoinCol, pExtra, pDir; IF (UPPER(pDir) NOT IN ('UP', 'DOWN')) THEN RAISE EXCEPTION 'Cannot change the order of records; unsure what % means for sequencing [xtuple: moveUpDown, -1, %, %.%]', pDir, pDir, _schema, pTable; END IF; SELECT attname, ARRAY_UPPER(conkey, 1) INTO _keyfield, _keysize FROM pg_attribute JOIN pg_constraint ON (attrelid=conrelid AND attnum=conkey[1]) JOIN pg_class ON (conrelid=pg_class.oid) JOIN pg_namespace ON (relnamespace=pg_namespace.oid) WHERE ((contype='p') AND (nspname=_schema) AND (relname=pTable)); RAISE DEBUG 'SELECT attname... returned %, %', _keyfield, _keysize; IF (_keysize > 1) THEN RAISE EXCEPTION 'Cannot change the order of records because %.% has a composite primary key [xtuple: moveUpDown, -2, %.%]', _schema, pTable, _schema, pTable; END IF; /* SELECT next._keyfield AS nextid, next.pSeqCol AS nextseq, this.pSeqCol AS thisseq FROM _schema.pTable AS next, _schema.pTable AS this WHERE (this._keyfield=$1) AND (next.pSeqCol [> or <] this.pSeqCol) [ AND (next.pJoinCol=this.pJoinCol) ] [ AND (pExtra) ] ORDER BY nextseq [ DESC or ASC ] LIMIT 1; */ _qry := 'SELECT next.' || quote_ident(_keyfield) || ' AS nextid, next.' || quote_ident(pSeqCol) || ' AS nextseq, this.' || quote_ident(pSeqCol) || ' AS thisseq FROM ' || _schema || '.' || quote_ident(pTable) || ' AS next, ' || _schema || '.' || quote_ident(pTable) || ' AS this WHERE ((this.' || quote_ident(_keyfield) || '=$1) AND (next.' || quote_ident(pSeqCol) || CASE pDir WHEN 'UP' THEN ' < ' ELSE ' > ' END || 'this.' || quote_ident(pSeqCol) || ')' || CASE WHEN pJoinCol IS NULL THEN '' ELSE ' AND (next.' || quote_ident(pJoinCol) || '=this.' || quote_ident(pJoinCol) || ')' END || ' AND (' || COALESCE(pExtra, 'TRUE') || ')) ORDER BY nextseq ' || CASE pDir WHEN 'UP' THEN 'DESC' ELSE 'ASC' END || ' LIMIT 1;'; RAISE DEBUG 'moveUpDown about to use % when running %', pId, _qry; EXECUTE _qry INTO _r USING pId; GET DIAGNOSTICS _rowcnt = ROW_COUNT; RAISE DEBUG 'next id %, next seq %, this id %, this seq %', _r.nextid, _r.nextseq, pId, _r.thisseq; IF (_rowcnt > 0) THEN _qry := 'UPDATE ' || _schema || '.' || quote_ident(pTable) || ' SET ' || pSeqCol || '=CAST($1 AS INTEGER) WHERE (' || quote_ident(_keyfield) || '=$2);'; EXECUTE _qry USING -1, _r.nextid; EXECUTE _qry USING _r.nextseq, pId; EXECUTE _qry USING _r.thisseq, _r.nextid; RETURN _r.nextid; END IF; RETURN pId; END; $_$; ALTER FUNCTION public.moveupdown(pid integer, pschema text, ptable text, pseqcol text, pjoincol text, pextra text, pdir text) OWNER TO admin; -- -- Name: FUNCTION moveupdown(pid integer, pschema text, ptable text, pseqcol text, pjoincol text, pextra text, pdir text); Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON FUNCTION moveupdown(pid integer, pschema text, ptable text, pseqcol text, pjoincol text, pextra text, pdir text) IS 'moveUpDown moves a particular record up or down in an ordered list. pId argument names the record to move. pSchema (uses public if NULL) and pTable name the table holding the list. pSeqCol is the column that holds the sequence number. pJoinCol is the column that distinguishes one list from another in the same table, or NULL if the table holds only one list. pExtra is an extra join clause that may be required, or NULL. pDir is either UP, meaning move the pId record closer to the beginning, or DOWN. Returns the id of the record with which pId was swapped, or pId if the record was already at the end in the specified direction.'; -- -- Name: nextperiodbyinterval(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION nextperiodbyinterval(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodid ALIAS FOR $1; pInterval ALIAS FOR $2; _periodid INTEGER; BEGIN SELECT b.period_id INTO _periodid FROM period AS a, period AS b WHERE ((a.period_id=pPeriodid) AND (b.period_start >= a.period_start)) ORDER BY b.period_start LIMIT 1 OFFSET pInterval; IF (NOT FOUND) THEN RETURN -1; END IF; RETURN _periodid; END; $_$; ALTER FUNCTION public.nextperiodbyinterval(integer, integer) OWNER TO admin; -- -- Name: nextprsubnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION nextprsubnumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrNumber ALIAS FOR $1; _subNumber INTEGER; BEGIN SELECT MAX(pr_subnumber) INTO _subNumber FROM pr WHERE (pr_number=pPrNumber); IF (_subNumber IS NULL) THEN _subNumber := 0; END IF; RETURN (_subNumber + 1); END; $_$; ALTER FUNCTION public.nextprsubnumber(integer) OWNER TO admin; -- -- Name: nextwosubnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION nextwosubnumber(integer) RETURNS integer LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT COALESCE((MAX(wo_subnumber) + 1), 1) FROM wo WHERE (wo_number=($1)); $_$; ALTER FUNCTION public.nextwosubnumber(integer) OWNER TO admin; -- -- Name: noneg(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION noneg(numeric) RETURNS numeric LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pValue ALIAS FOR $1; BEGIN IF (pValue < 0) THEN RETURN 0; ELSE RETURN pValue; END IF; END; $_$; ALTER FUNCTION public.noneg(numeric) OWNER TO admin; -- -- Name: nopos(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION nopos(numeric) RETURNS numeric LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pValue ALIAS FOR $1; BEGIN IF (pValue > 0) THEN RETURN 0; ELSE RETURN pValue; END IF; END; $_$; ALTER FUNCTION public.nopos(numeric) OWNER TO admin; -- -- Name: normalizetrialbal(integer, character); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION normalizetrialbal(integer, character) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTrialbalid ALIAS FOR $1; pSide ALIAS FOR $2; _value NUMERIC; _r RECORD; BEGIN SELECT accnt_type, trialbal_beginning, trialbal_ending INTO _r FROM trialbal, accnt WHERE ( (trialbal_accnt_id=accnt_id) AND (trialbal_id=pTrialbalid) ); IF (NOT FOUND) THEN RETURN -1; END IF; -- If we are looking for the Ending Balance, cache it IF (pSide = 'E') THEN _value = _r.trialbal_ending; -- We had better been looking for the Beginning Balance! ELSE _value = _r.trialbal_beginning; END IF; -- If the accnt_type is Asset or Expense, swap the sense IF (_r.accnt_type IN ('A', 'E')) THEN _value := (_value * -1); END IF; RETURN _value; END; $_$; ALTER FUNCTION public.normalizetrialbal(integer, character) OWNER TO admin; -- -- Name: numofdatabaseusers(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION numofdatabaseusers() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN numOfDatabaseUsers(NULL); END; $$; ALTER FUNCTION public.numofdatabaseusers() OWNER TO admin; -- -- Name: numofdatabaseusers(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION numofdatabaseusers(pappname text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _count INTEGER; BEGIN -- in version 9.2.0 the column "procpid" was changed to just "pid" Incident #21852 IF (compareversion('9.2.0') <= 0) THEN SELECT count(*) INTO _count FROM pg_locks LEFT JOIN pg_stat_activity ON pg_stat_activity.pid = pg_locks.pid WHERE (pg_locks.objsubid = 2) AND (pg_stat_activity.datname = current_database()) AND CASE WHEN (trim(coalesce(pAppName, '')) = '') THEN true ELSE application_name = pAppName END; ELSE SELECT count(*) INTO _count FROM pg_locks LEFT JOIN pg_stat_activity ON pg_stat_activity.procpid = pg_locks.pid WHERE (pg_locks.objsubid = 2) AND (pg_stat_activity.datname = current_database()) AND CASE WHEN (trim(coalesce(pAppName, '')) = '') THEN true ELSE application_name = pAppName END; END IF; IF (_count IS NULL) THEN _count := 0; END IF; RETURN _count; END; $$; ALTER FUNCTION public.numofdatabaseusers(pappname text) OWNER TO admin; -- -- Name: numofserverusers(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION numofserverusers() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _count INTEGER; BEGIN SELECT COUNT(*) INTO _count FROM pg_stat_activity WHERE datname = current_database(); IF (_count IS NULL) THEN _count := 0; END IF; RETURN _count; END; $$; ALTER FUNCTION public.numofserverusers() OWNER TO admin; -- -- Name: openaccountingperiod(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION openaccountingperiod(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodid ALIAS FOR $1; _r RECORD; BEGIN -- Check to make use that the period is closed IF ( ( SELECT (NOT period_closed) FROM period WHERE (period_id=pPeriodid) ) ) THEN RETURN -1; END IF; IF ( ( SELECT (count(period_id) > 0) FROM period WHERE ((period_end > ( SELECT period_end FROM period WHERE (period_id=pPeriodId)) ) AND (period_closed)) ) ) THEN RETURN -3; END IF; -- Make sure the year is open IF ( ( SELECT (yearperiod_closed) FROM yearperiod JOIN period ON (period_yearperiod_id=yearperiod_id) WHERE (period_id=pPeriodid) ) ) THEN RETURN -4; END IF; -- Reset the period_closed flag UPDATE period SET period_closed=FALSE WHERE (period_id=pPeriodid); -- Post any unposted G/L Transactions into the new period FOR _r IN SELECT DISTINCT gltrans_sequence FROM gltrans, period WHERE ( (NOT gltrans_posted) AND (gltrans_date BETWEEN period_start AND period_end) AND (period_id=pPeriodid) ) LOOP PERFORM postIntoTrialBalance(_r.gltrans_sequence); END LOOP; RETURN pPeriodid; END; $_$; ALTER FUNCTION public.openaccountingperiod(integer) OWNER TO admin; -- -- Name: openaccountingyearperiod(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION openaccountingyearperiod(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pYearPeriodId ALIAS FOR $1; _r RECORD; BEGIN -- Check to make use that the yearperiod is closed IF ( ( SELECT (NOT yearperiod_closed) FROM yearperiod WHERE (yearperiod_id=pYearPeriodId) ) ) THEN RETURN -1; END IF; IF ( ( SELECT (count(yearperiod_id) > 0) FROM yearperiod WHERE ((yearperiod_end> ( SELECT yearperiod_end FROM yearperiod WHERE (yearperiod_id=pYearPeriodId)) ) AND (yearperiod_closed)) ) ) THEN RETURN -2; END IF; -- Reset the yearperiod_closed flag UPDATE yearperiod SET yearperiod_closed=FALSE WHERE (yearperiod_id=pYearPeriodId); RETURN pYearPeriodid; END; $_$; ALTER FUNCTION public.openaccountingyearperiod(integer) OWNER TO admin; -- -- Name: openapitemsvalue(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION openapitemsvalue(pvendid integer, pperiodid integer) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _value NUMERIC; BEGIN SELECT SUM( (apopen_amount - apopen_paid) / apopen_curr_rate * CASE WHEN (apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END ) INTO _value FROM apopen WHERE ( (apopen_open) AND (apopen_vend_id=pVendid) AND (apopen_duedate BETWEEN findPeriodStart(pPeriodid) AND findPeriodEnd(pPeriodid)) ); RETURN COALESCE(_value, 0.0); END; $$; ALTER FUNCTION public.openapitemsvalue(pvendid integer, pperiodid integer) OWNER TO admin; -- -- Name: openaritemsvalue(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION openaritemsvalue(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; pPeriodid ALIAS FOR $2; _value NUMERIC; BEGIN SELECT SUM( CASE WHEN (aropen_doctype IN ('C', 'R')) THEN ((aropen_amount - aropen_paid) * -1) ELSE (aropen_amount - aropen_paid) END ) INTO _value FROM aropen WHERE ( (aropen_open) AND (aropen_cust_id=pCustid) AND (aropen_duedate BETWEEN findPeriodStart(pPeriodid) AND findPeriodEnd(pPeriodid)) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; ALTER FUNCTION public.openaritemsvalue(integer, integer) OWNER TO admin; -- -- Name: openrecurringitems(integer, text, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION openrecurringitems(integer, text, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pParentid ALIAS FOR $1; pType TEXT := UPPER($2); pDatetime TIMESTAMP WITH TIME ZONE := COALESCE($3, CURRENT_TIMESTAMP); _count INTEGER := -1; _countstmt TEXT; _rt RECORD; BEGIN IF (pParentid IS NULL) THEN RETURN -11; END IF; SELECT * INTO _rt FROM recurtype WHERE (UPPER(recurtype_type)=pType); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count <= 0) THEN RETURN -10; END IF; _countstmt := 'SELECT COUNT(*) FROM [fulltable]' || ' WHERE (NOT ([done])' || ' AND ([schedcol]>=''$1'')' || ' AND ([table]_recurring_[table]_id=''$2''));'; _countstmt := REPLACE(_countstmt, '[fulltable]', _rt.recurtype_table); _countstmt := REPLACE(_countstmt, '[table]', REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', '')); _countstmt := REPLACE(_countstmt, '[done]', _rt.recurtype_donecheck); _countstmt := REPLACE(_countstmt, '[schedcol]', _rt.recurtype_schedcol); -- 8.4+: EXECUTE _countstmt INTO _count USING pDatetime, pParentid; EXECUTE REPLACE(REPLACE(_countstmt, '$1', pDatetime::TEXT), '$2', pParentid::TEXT) INTO _count; RETURN _count; END; $_$; ALTER FUNCTION public.openrecurringitems(integer, text, timestamp with time zone) OWNER TO admin; -- -- Name: ophead; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE ophead ( ophead_id integer NOT NULL, ophead_name text NOT NULL, ophead_crmacct_id integer, ophead_owner_username text, ophead_opstage_id integer, ophead_opsource_id integer, ophead_optype_id integer, ophead_probability_prcnt integer, ophead_amount numeric(20,4), ophead_target_date date, ophead_actual_date date, ophead_notes text, ophead_curr_id integer, ophead_active boolean DEFAULT true, ophead_cntct_id integer, ophead_username text, ophead_start_date date, ophead_assigned_date date, ophead_priority_id integer, ophead_number text NOT NULL, CONSTRAINT ophead_ophead_number_check CHECK ((ophead_number <> ''::text)) ); ALTER TABLE ophead OWNER TO admin; -- -- Name: TABLE ophead; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE ophead IS 'Opportunity header.'; -- -- Name: ophead(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION ophead() RETURNS SETOF ophead LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row ophead%ROWTYPE; _priv TEXT; _grant BOOLEAN; BEGIN -- This query will give us the most permissive privilege the user has been granted SELECT privilege, granted INTO _priv, _grant FROM privgranted WHERE privilege IN ('MaintainAllOpportunities','ViewAllOpportunities','MaintainPersonalOpportunities','ViewPersonalOpportunities') ORDER BY granted DESC, sequence LIMIT 1; -- If have an 'All' privilege return all results IF (_priv ~ 'All' AND _grant) THEN FOR _row IN SELECT * FROM ophead LOOP RETURN NEXT _row; END LOOP; -- Otherwise if have any other grant, must be personal privilege. ELSIF (_grant) THEN FOR _row IN SELECT * FROM ophead WHERE getEffectiveXtUser() IN (ophead_owner_username, ophead_username) LOOP RETURN NEXT _row; END LOOP; END IF; RETURN; END; $$; ALTER FUNCTION public.ophead() OWNER TO admin; -- -- Name: FUNCTION ophead(); Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON FUNCTION ophead() IS 'A table function that returns Opportunity results according to privilege settings.'; -- -- Name: orderedbypo(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION orderedbypo(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pLookAhead ALIAS FOR $2; _qty NUMERIC; BEGIN SELECT orderedByPo(pItemsiteid, startOfTime(), (CURRENT_DATE + pLookAhead)) INTO _qty; RETURN _qty; END; $_$; ALTER FUNCTION public.orderedbypo(integer, integer) OWNER TO admin; -- -- Name: orderedbypo(integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION orderedbypo(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _qty NUMERIC; BEGIN SELECT COALESCE(SUM(noNeg(poitem_qty_ordered - poitem_qty_received) * poitem_invvenduomratio), 0.0) INTO _qty FROM poitem WHERE ( (poitem_itemsite_id=pItemsiteid) AND (poitem_status <> 'C') AND (poitem_duedate BETWEEN pStartDate AND pEndDate) ); RETURN _qty; END; $_$; ALTER FUNCTION public.orderedbypo(integer, date, date) OWNER TO admin; -- -- Name: orderedbywo(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION orderedbywo(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pLookAheadDays ALIAS FOR $2; BEGIN RETURN orderedByWo(pItemsiteid, startOfTime(), (CURRENT_DATE + pLookAheadDays)); END; $_$; ALTER FUNCTION public.orderedbywo(integer, integer) OWNER TO admin; -- -- Name: orderedbywo(integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION orderedbywo(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _itemType CHARACTER(1); _qty NUMERIC := 0; BEGIN SELECT item_type INTO _itemType FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ); IF (_itemType NOT IN ('C','T')) THEN SELECT COALESCE(SUM(noNeg(wo_qtyord - wo_qtyrcv)), 0.0) INTO _qty FROM wo WHERE ( (wo_status <> 'C') AND (wo_itemsite_id=pItemsiteid) AND (wo_duedate BETWEEN pStartDate AND pEndDate) ); ELSIF (_itemType = 'C') THEN SELECT COALESCE(SUM((noNeg(wo_qtyord - wo_qtyrcv) * brddist_stdqtyper)), 0.0) INTO _qty FROM wo, xtmfg.brddist WHERE ( (wo_status <> 'C') AND (brddist_wo_id=wo_id) AND (brddist_itemsite_id=pItemsiteid) AND (wo_duedate BETWEEN pStartDate AND pEndDate) ); ELSIF (_itemType = 'T' AND fetchMetricBool('Routings')) THEN -- Tooling: Determine quantity already returned SELECT -- Qty Required COALESCE(SUM(noNeg(womatl_qtyreq)),0) - -- Qty Returned (SELECT COALESCE(SUM(abs(invhist_invqty)),0) FROM wo JOIN womatl ON (womatl_wo_id=wo_id) JOIN womatlpost ON (womatl_id=womatlpost_womatl_id) JOIN invhist ON ((womatlpost_invhist_id=invhist_id) AND (invhist_invqty < 0)) LEFT OUTER JOIN xtmfg.wooper ON (womatl_wooper_id=wooper_id) WHERE ( NOT (COALESCE(wooper_rncomplete,wo_status = 'C')) AND (womatl_itemsite_id=pItemsiteid) AND (wo_duedate BETWEEN pStartDate AND pEndDate) ) ) INTO _qty FROM wo JOIN womatl ON (womatl_wo_id=wo_id) LEFT OUTER JOIN xtmfg.wooper ON (womatl_wooper_id=wooper_id) WHERE ( NOT (COALESCE(wooper_rncomplete,wo_status = 'C')) AND (womatl_itemsite_id=pItemsiteid) AND (wo_duedate BETWEEN pStartDate AND pEndDate) ) GROUP BY womatl_qtyreq; ELSIF (_itemType = 'T') THEN -- Tooling: Determine quantity already returned SELECT -- Qty Required COALESCE(SUM(noNeg(womatl_qtyreq)),0) - -- Qty Returned (SELECT COALESCE(SUM(abs(invhist_invqty)),0) FROM wo JOIN womatl ON (womatl_wo_id=wo_id) JOIN womatlpost ON (womatl_id=womatlpost_womatl_id) JOIN invhist ON ((womatlpost_invhist_id=invhist_id) AND (invhist_invqty < 0)) WHERE ( NOT (wo_status = 'C') AND (womatl_itemsite_id=pItemsiteid) AND (wo_duedate BETWEEN pStartDate AND pEndDate) ) ) INTO _qty FROM wo JOIN womatl ON (womatl_wo_id=wo_id) WHERE ( NOT (wo_status = 'C') AND (womatl_itemsite_id=pItemsiteid) AND (wo_duedate BETWEEN pStartDate AND pEndDate) ) GROUP BY womatl_qtyreq; END IF; RETURN COALESCE(_qty,0); END; $_$; ALTER FUNCTION public.orderedbywo(integer, date, date) OWNER TO admin; -- -- Name: orderhead(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION orderhead() RETURNS SETOF ordhead LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row ordhead%ROWTYPE; _query TEXT; BEGIN _query := ' SELECT DISTINCT * FROM ( SELECT pohead_id AS orderhead_id, ''PO'' AS orderhead_type, pohead_number AS orderhead_number, pohead_status AS orderhead_status, pohead_orderdate AS orderhead_orderdate, (SELECT count(*) FROM poitem WHERE poitem_pohead_id=pohead_id) AS orderhead_linecount, pohead_vend_id AS orderhead_from_id, vend_name AS orderhead_from, NULL AS orderhead_to_id, '''' AS orderhead_to, pohead_curr_id AS orderhead_curr_id, pohead_agent_username AS orderhead_agent_username, pohead_shipvia AS orderhead_shipvia FROM pohead LEFT OUTER JOIN vendinfo ON (pohead_vend_id=vend_id) UNION SELECT cohead_id AS orderhead_id, ''SO'' AS orderhead_type, cohead_number AS orderhead_number, COALESCE(coitem_status,''C'') AS orderhead_status, cohead_orderdate AS orderhead_orderdate, (SELECT count(*) FROM coitem WHERE coitem_cohead_id=cohead_id) AS orderhead_linecount, NULL AS orderhead_from_id, '''' AS orderhead_from, cohead_cust_id AS orderhead_to_id, cust_name AS orderhead_to, cohead_curr_id AS orderhead_curr_id, '''' AS orderhead_agent_username, cohead_shipvia AS orderhead_shipvia FROM cohead LEFT OUTER JOIN custinfo ON (cohead_cust_id=cust_id) LEFT OUTER JOIN coitem ON ((cohead_id=coitem_cohead_id) AND (coitem_status=''O''))'; IF (fetchmetricbool('MultiWhs')) THEN _query := _query || ' UNION SELECT tohead_id AS orderhead_id, ''TO'' AS orderhead_type, tohead_number AS orderhead_number, tohead_status AS orderhead_status, tohead_orderdate AS orderhead_orderdate, (SELECT count(*) FROM toitem WHERE toitem_tohead_id=tohead_id) AS orderhead_linecount, tohead_src_warehous_id AS orderhead_from_id, tohead_srcname AS orderhead_from, tohead_dest_warehous_id AS orderhead_to_id, tohead_destname AS orderhead_to, tohead_freight_curr_id AS orderhead_curr_id, tohead_agent_username AS orderhead_agent_username, tohead_shipvia AS orderhead_shipvia FROM tohead'; END IF; IF (fetchmetricbool('EnableReturnAuth')) THEN _query := _query || ' UNION SELECT rahead_id AS orderhead_id, ''RA'' AS orderhead_type, rahead_number AS orderhead_number, COALESCE(raitem_status,''C'') AS orderhead_status, rahead_authdate AS orderhead_orderdate, (SELECT count(*) FROM raitem WHERE raitem_rahead_id=rahead_id) AS orderhead_linecount, rahead_cust_id AS orderhead_from_id, cust_name AS orderhead_from, NULL AS orderhead_to_id, '''' AS orderhead_to, rahead_curr_id AS orderhead_curr_id, '''' AS orderhead_agent_username, '''' AS orderhead_shipvia FROM rahead LEFT OUTER JOIN custinfo ON (rahead_cust_id=cust_id) LEFT OUTER JOIN raitem ON ((rahead_id=raitem_rahead_id) AND (raitem_status=''O''))'; END IF; _query := _query || ') AS data ORDER BY orderhead_type, orderhead_number ;'; FOR _row IN EXECUTE _query LOOP RETURN NEXT _row; END LOOP; RETURN; END; $$; ALTER FUNCTION public.orderhead() OWNER TO admin; -- -- Name: orderitem(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION orderitem() RETURNS SETOF orditem LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row orditem%ROWTYPE; _query TEXT; BEGIN _query := ' SELECT poitem_id AS orderitem_id, ''PO'' AS orderitem_orderhead_type, poitem_pohead_id AS orderitem_orderhead_id, poitem_linenumber AS orderitem_linenumber, poitem_status AS orderitem_status, poitem_itemsite_id AS orderitem_itemsite_id, poitem_duedate AS orderitem_scheddate, poitem_qty_ordered AS orderitem_qty_ordered, poitem_qty_returned AS orderitem_qty_shipped, poitem_qty_received AS orderitem_qty_received, uom_id AS orderitem_qty_uom_id, poitem_invvenduomratio AS orderitem_qty_invuomratio, poitem_unitprice AS orderitem_unitcost, pohead_curr_id AS orderitem_unitcost_curr_id, poitem_freight AS orderitem_freight, poitem_freight_received AS orderitem_freight_received, pohead_curr_id AS orderitem_freight_curr_id FROM poitem LEFT OUTER JOIN pohead ON (poitem_pohead_id=pohead_id) LEFT OUTER JOIN uom ON (uom_name=poitem_vend_uom) UNION SELECT coitem_id AS orderitem_id, ''SO'' AS orderitem_orderhead_type, coitem_cohead_id AS orderitem_orderhead_id, coitem_linenumber AS orderitem_linenumber, coitem_status AS orderitem_status, coitem_itemsite_id AS orderitem_itemsite_id, coitem_scheddate AS orderitem_scheddate, coitem_qtyord AS orderitem_qty_ordered, coitem_qtyshipped AS orderitem_qty_shipped, coitem_qtyreturned AS orderitem_qty_received, coitem_qty_uom_id AS orderitem_qty_uom_id, coitem_qty_invuomratio AS orderitem_qty_invuomratio, coitem_unitcost AS orderitem_unitcost, basecurrid() AS orderitem_unitcost_curr_id, NULL AS orderitem_freight, NULL AS orderitem_freight_received, basecurrid() AS orderitem_freight_curr_id FROM coitem'; IF (fetchmetricbool('MultiWhs')) THEN _query := _query || ' UNION SELECT toitem_id AS orderitem_id, ''TO'' AS orderitem_orderhead_type, toitem_tohead_id AS orderitem_orderhead_id, toitem_linenumber AS orderitem_linenumber, toitem_status AS orderitem_status, itemsite_id AS orderitem_itemsite_id, toitem_duedate AS orderitem_scheddate, toitem_qty_ordered AS orderitem_qty_ordered, toitem_qty_shipped AS orderitem_qty_shipped, toitem_qty_received AS orderitem_qty_received, uom_id AS orderitem_qty_uom_id, 1 AS orderitem_qty_invuomratio, toitem_stdcost AS orderitem_unitcost, basecurrid() AS orderitem_unitcost_curr_id, toitem_freight AS orderitem_freight, toitem_freight_received AS orderitem_freight_received, toitem_freight_curr_id AS orderitem_freight_curr_id FROM tohead, itemsite, toitem LEFT OUTER JOIN uom ON (uom_name=toitem_uom) WHERE ((toitem_tohead_id=tohead_id) AND (tohead_src_warehous_id=itemsite_warehous_id) AND (toitem_item_id=itemsite_item_id)) '; END IF; IF (fetchmetricbool('EnableReturnAuth')) THEN _query := _query || ' UNION SELECT raitem_id AS orderitem_id, ''RA'' AS orderitem_orderhead_type, raitem_rahead_id AS orderitem_orderhead_id, raitem_linenumber AS orderitem_linenumber, raitem_status AS orderitem_status, raitem_itemsite_id AS orderitem_itemsite_id, raitem_scheddate AS orderitem_scheddate, raitem_qtyauthorized AS orderitem_qty_ordered, 0 AS orderitem_qty_shipped, raitem_qtyreceived AS orderitem_qty_received, raitem_qty_uom_id AS orderitem_qty_uom_id, raitem_qty_invuomratio AS orderitem_qty_invuomratio, raitem_unitprice AS orderitem_unitcost, basecurrid() AS orderitem_unitcost_curr_id, NULL AS orderitem_freight, NULL AS orderitem_freight_received, basecurrid() AS orderitem_freight_curr_id FROM raitem'; END IF; FOR _row IN EXECUTE _query LOOP RETURN NEXT _row; END LOOP; RETURN; END; $$; ALTER FUNCTION public.orderitem() OWNER TO admin; -- -- Name: orderitemdata(text, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION orderitemdata(text, integer, integer) RETURNS SETOF orderitemtype LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOrdertype ALIAS FOR $1; pOrderheadid ALIAS FOR $2; pOrderitemid ALIAS FOR $3; _row orderitemtype%ROWTYPE; _set RECORD; BEGIN IF(UPPER(pOrdertype)='PO') THEN FOR _set IN SELECT poitem_id AS orderitem_id, 'PO' AS orderitem_orderhead_type, poitem_pohead_id AS orderitem_orderhead_id, poitem_linenumber AS orderitem_linenumber, poitem_status AS orderitem_status, poitem_itemsite_id AS orderitem_itemsite_id, poitem_duedate AS orderitem_scheddate, poitem_qty_ordered AS orderitem_qty_ordered, poitem_qty_returned AS orderitem_qty_shipped, poitem_qty_received AS orderitem_qty_received, uom_id AS orderitem_qty_uom_id, poitem_invvenduomratio AS orderitem_qty_invuomratio, poitem_unitprice AS orderitem_unitcost, (SELECT pohead_curr_id FROM pohead WHERE pohead_id=poitem_pohead_id) AS orderitem_unitcost_curr_id, poitem_freight AS orderitem_freight, poitem_freight_received AS orderitem_freight_received, (SELECT pohead_curr_id FROM pohead WHERE pohead_id=poitem_pohead_id) AS orderitem_freight_curr_id FROM poitem LEFT OUTER JOIN uom ON (uom_name=poitem_vend_uom) WHERE(((pOrderheadid IS NULL) OR (poitem_pohead_id=pOrderheadid)) AND ((pOrderitemid IS NULL) OR (poitem_id=pOrderitemid))) LOOP _row.orderitem_id := _set.orderitem_id; _row.orderitem_orderhead_type := _set.orderitem_orderhead_type; _row.orderitem_orderhead_id := _set.orderitem_orderhead_id; _row.orderitem_linenumber := _set.orderitem_linenumber; _row.orderitem_status := _set.orderitem_status; _row.orderitem_itemsite_id := _set.orderitem_itemsite_id; _row.orderitem_scheddate := _set.orderitem_scheddate; _row.orderitem_qty_ordered := _set.orderitem_qty_ordered; _row.orderitem_qty_shipped := _set.orderitem_qty_shipped; _row.orderitem_qty_received := _set.orderitem_qty_received; _row.orderitem_qty_uom_id := _set.orderitem_qty_uom_id; _row.orderitem_qty_invuomratio := _set.orderitem_qty_invuomratio; _row.orderitem_unitcost := _set.orderitem_unitcost; _row.orderitem_unitcost_curr_id := _set.orderitem_unitcost_curr_id; _row.orderitem_freight := _set.orderitem_freight; _row.orderitem_freight_received := _set.orderitem_freight_received; _row.orderitem_freight_curr_id := _set.orderitem_freight_curr_id; RETURN NEXT _row; END LOOP; ELSEIF(UPPER(pOrdertype)='SO') THEN FOR _set IN SELECT coitem_id AS orderitem_id, 'SO' AS orderitem_orderhead_type, coitem_cohead_id AS orderitem_orderhead_id, coitem_linenumber AS orderitem_linenumber, coitem_status AS orderitem_status, coitem_itemsite_id AS orderitem_itemsite_id, coitem_scheddate AS orderitem_scheddate, coitem_qtyord AS orderitem_qty_ordered, coitem_qtyshipped AS orderitem_qty_shipped, coitem_qtyreturned AS orderitem_qty_received, coitem_qty_uom_id AS orderitem_qty_uom_id, coitem_qty_invuomratio AS orderitem_qty_invuomratio, coitem_unitcost AS orderitem_unitcost, basecurrid() AS orderitem_unitcost_curr_id, NULL AS orderitem_freight, NULL AS orderitem_freight_received, basecurrid() AS orderitem_freight_curr_id FROM coitem WHERE(((pOrderheadid IS NULL) OR (coitem_cohead_id=pOrderheadid)) AND ((pOrderitemid IS NULL) OR (coitem_id=pOrderitemid))) LOOP _row.orderitem_id := _set.orderitem_id; _row.orderitem_orderhead_type := _set.orderitem_orderhead_type; _row.orderitem_orderhead_id := _set.orderitem_orderhead_id; _row.orderitem_linenumber := _set.orderitem_linenumber; _row.orderitem_status := _set.orderitem_status; _row.orderitem_itemsite_id := _set.orderitem_itemsite_id; _row.orderitem_scheddate := _set.orderitem_scheddate; _row.orderitem_qty_ordered := _set.orderitem_qty_ordered; _row.orderitem_qty_shipped := _set.orderitem_qty_shipped; _row.orderitem_qty_received := _set.orderitem_qty_received; _row.orderitem_qty_uom_id := _set.orderitem_qty_uom_id; _row.orderitem_qty_invuomratio := _set.orderitem_qty_invuomratio; _row.orderitem_unitcost := _set.orderitem_unitcost; _row.orderitem_unitcost_curr_id := _set.orderitem_unitcost_curr_id; _row.orderitem_freight := _set.orderitem_freight; _row.orderitem_freight_received := _set.orderitem_freight_received; _row.orderitem_freight_curr_id := _set.orderitem_freight_curr_id; RETURN NEXT _row; END LOOP; ELSEIF(UPPER(pOrdertype)='RA') THEN FOR _set IN SELECT raitem_id AS orderitem_id, 'RA' AS orderitem_orderhead_type, raitem_rahead_id AS orderitem_orderhead_id, raitem_linenumber AS orderitem_linenumber, raitem_status AS orderitem_status, raitem_itemsite_id AS orderitem_itemsite_id, raitem_scheddate AS orderitem_scheddate, raitem_qtyauthorized AS orderitem_qty_ordered, 0 AS orderitem_qty_shipped, raitem_qtyreceived AS orderitem_qty_received, raitem_qty_uom_id AS orderitem_qty_uom_id, raitem_qty_invuomratio AS orderitem_qty_invuomratio, raitem_unitprice AS orderitem_unitcost, basecurrid() AS orderitem_unitcost_curr_id, NULL AS orderitem_freight, NULL AS orderitem_freight_received, basecurrid() AS orderitem_freight_curr_id FROM raitem WHERE(((pOrderheadid IS NULL) OR (raitem_rahead_id=pOrderheadid)) AND ((pOrderitemid IS NULL) OR (raitem_id=pOrderitemid))) LOOP _row.orderitem_id := _set.orderitem_id; _row.orderitem_orderhead_type := _set.orderitem_orderhead_type; _row.orderitem_orderhead_id := _set.orderitem_orderhead_id; _row.orderitem_linenumber := _set.orderitem_linenumber; _row.orderitem_status := _set.orderitem_status; _row.orderitem_itemsite_id := _set.orderitem_itemsite_id; _row.orderitem_scheddate := _set.orderitem_scheddate; _row.orderitem_qty_ordered := _set.orderitem_qty_ordered; _row.orderitem_qty_shipped := _set.orderitem_qty_shipped; _row.orderitem_qty_received := _set.orderitem_qty_received; _row.orderitem_qty_uom_id := _set.orderitem_qty_uom_id; _row.orderitem_qty_invuomratio := _set.orderitem_qty_invuomratio; _row.orderitem_unitcost := _set.orderitem_unitcost; _row.orderitem_unitcost_curr_id := _set.orderitem_unitcost_curr_id; _row.orderitem_freight := _set.orderitem_freight; _row.orderitem_freight_received := _set.orderitem_freight_received; _row.orderitem_freight_curr_id := _set.orderitem_freight_curr_id; RETURN NEXT _row; END LOOP; ELSEIF(UPPER(pOrdertype)='TO') THEN FOR _set IN SELECT toitem_id AS orderitem_id, 'TO' AS orderitem_orderhead_type, toitem_tohead_id AS orderitem_orderhead_id, toitem_linenumber AS orderitem_linenumber, toitem_status AS orderitem_status, itemsite_id AS orderitem_itemsite_id, toitem_duedate AS orderitem_scheddate, toitem_qty_ordered AS orderitem_qty_ordered, toitem_qty_shipped AS orderitem_qty_shipped, toitem_qty_received AS orderitem_qty_received, uom_id AS orderitem_qty_uom_id, 1 AS orderitem_qty_invuomratio, toitem_stdcost AS orderitem_unitcost, basecurrid() AS orderitem_unitcost_curr_id, toitem_freight AS orderitem_freight, toitem_freight_received AS orderitem_freight_received, toitem_freight_curr_id AS orderitem_freight_curr_id FROM tohead, itemsite, toitem LEFT OUTER JOIN uom ON (uom_name=toitem_uom) WHERE((toitem_tohead_id=tohead_id) AND (tohead_src_warehous_id=itemsite_warehous_id) AND (toitem_item_id=itemsite_item_id) AND ((pOrderheadid IS NULL) OR (toitem_tohead_id=pOrderheadid)) AND ((pOrderitemid IS NULL) OR (toitem_id=pOrderitemid))) LOOP _row.orderitem_id := _set.orderitem_id; _row.orderitem_orderhead_type := _set.orderitem_orderhead_type; _row.orderitem_orderhead_id := _set.orderitem_orderhead_id; _row.orderitem_linenumber := _set.orderitem_linenumber; _row.orderitem_status := _set.orderitem_status; _row.orderitem_itemsite_id := _set.orderitem_itemsite_id; _row.orderitem_scheddate := _set.orderitem_scheddate; _row.orderitem_qty_ordered := _set.orderitem_qty_ordered; _row.orderitem_qty_shipped := _set.orderitem_qty_shipped; _row.orderitem_qty_received := _set.orderitem_qty_received; _row.orderitem_qty_uom_id := _set.orderitem_qty_uom_id; _row.orderitem_qty_invuomratio := _set.orderitem_qty_invuomratio; _row.orderitem_unitcost := _set.orderitem_unitcost; _row.orderitem_unitcost_curr_id := _set.orderitem_unitcost_curr_id; _row.orderitem_freight := _set.orderitem_freight; _row.orderitem_freight_received := _set.orderitem_freight_received; _row.orderitem_freight_curr_id := _set.orderitem_freight_curr_id; RETURN NEXT _row; END LOOP; END IF; RETURN; END; $_$; ALTER FUNCTION public.orderitemdata(text, integer, integer) OWNER TO admin; -- -- Name: packageisenabled(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION packageisenabled(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT COUNT(*) >= 8 FROM pg_inherits, pg_class, pg_namespace, pkghead WHERE ((inhrelid=pg_class.oid) AND (relnamespace=pg_namespace.oid) AND (nspname=lower(pkghead_name)) AND (pkghead_id=$1)); $_$; ALTER FUNCTION public.packageisenabled(integer) OWNER TO admin; -- -- Name: packageisenabled(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION packageisenabled(text) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT COUNT(*) >= 8 FROM pg_inherits, pg_class, pg_namespace WHERE ((inhrelid=pg_class.oid) AND (relnamespace=pg_namespace.oid) AND (nspname=lower($1))); $_$; ALTER FUNCTION public.packageisenabled(text) OWNER TO admin; -- -- Name: pgp_key_id(bytea); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION pgp_key_id(bytea) RETURNS text LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_key_id_w'; ALTER FUNCTION public.pgp_key_id(bytea) OWNER TO admin; -- -- Name: pgp_pub_decrypt(bytea, bytea); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION pgp_pub_decrypt(bytea, bytea) RETURNS text LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_pub_decrypt_text'; ALTER FUNCTION public.pgp_pub_decrypt(bytea, bytea) OWNER TO admin; -- -- Name: pgp_pub_decrypt(bytea, bytea, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION pgp_pub_decrypt(bytea, bytea, text) RETURNS text LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_pub_decrypt_text'; ALTER FUNCTION public.pgp_pub_decrypt(bytea, bytea, text) OWNER TO admin; -- -- Name: pgp_pub_decrypt(bytea, bytea, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION pgp_pub_decrypt(bytea, bytea, text, text) RETURNS text LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_pub_decrypt_text'; ALTER FUNCTION public.pgp_pub_decrypt(bytea, bytea, text, text) OWNER TO admin; -- -- Name: pgp_pub_decrypt_bytea(bytea, bytea); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION pgp_pub_decrypt_bytea(bytea, bytea) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_pub_decrypt_bytea'; ALTER FUNCTION public.pgp_pub_decrypt_bytea(bytea, bytea) OWNER TO admin; -- -- Name: pgp_pub_decrypt_bytea(bytea, bytea, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION pgp_pub_decrypt_bytea(bytea, bytea, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_pub_decrypt_bytea'; ALTER FUNCTION public.pgp_pub_decrypt_bytea(bytea, bytea, text) OWNER TO admin; -- -- Name: pgp_pub_decrypt_bytea(bytea, bytea, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION pgp_pub_decrypt_bytea(bytea, bytea, text, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_pub_decrypt_bytea'; ALTER FUNCTION public.pgp_pub_decrypt_bytea(bytea, bytea, text, text) OWNER TO admin; -- -- Name: pgp_pub_encrypt(text, bytea); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION pgp_pub_encrypt(text, bytea) RETURNS bytea LANGUAGE c STRICT AS '$libdir/pgcrypto', 'pgp_pub_encrypt_text'; ALTER FUNCTION public.pgp_pub_encrypt(text, bytea) OWNER TO admin; -- -- Name: pgp_pub_encrypt(text, bytea, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION pgp_pub_encrypt(text, bytea, text) RETURNS bytea LANGUAGE c STRICT AS '$libdir/pgcrypto', 'pgp_pub_encrypt_text'; ALTER FUNCTION public.pgp_pub_encrypt(text, bytea, text) OWNER TO admin; -- -- Name: pgp_pub_encrypt_bytea(bytea, bytea); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION pgp_pub_encrypt_bytea(bytea, bytea) RETURNS bytea LANGUAGE c STRICT AS '$libdir/pgcrypto', 'pgp_pub_encrypt_bytea'; ALTER FUNCTION public.pgp_pub_encrypt_bytea(bytea, bytea) OWNER TO admin; -- -- Name: pgp_pub_encrypt_bytea(bytea, bytea, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION pgp_pub_encrypt_bytea(bytea, bytea, text) RETURNS bytea LANGUAGE c STRICT AS '$libdir/pgcrypto', 'pgp_pub_encrypt_bytea'; ALTER FUNCTION public.pgp_pub_encrypt_bytea(bytea, bytea, text) OWNER TO admin; -- -- Name: pgp_sym_decrypt(bytea, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION pgp_sym_decrypt(bytea, text) RETURNS text LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_sym_decrypt_text'; ALTER FUNCTION public.pgp_sym_decrypt(bytea, text) OWNER TO admin; -- -- Name: pgp_sym_decrypt(bytea, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION pgp_sym_decrypt(bytea, text, text) RETURNS text LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_sym_decrypt_text'; ALTER FUNCTION public.pgp_sym_decrypt(bytea, text, text) OWNER TO admin; -- -- Name: pgp_sym_decrypt_bytea(bytea, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION pgp_sym_decrypt_bytea(bytea, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_sym_decrypt_bytea'; ALTER FUNCTION public.pgp_sym_decrypt_bytea(bytea, text) OWNER TO admin; -- -- Name: pgp_sym_decrypt_bytea(bytea, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION pgp_sym_decrypt_bytea(bytea, text, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_sym_decrypt_bytea'; ALTER FUNCTION public.pgp_sym_decrypt_bytea(bytea, text, text) OWNER TO admin; -- -- Name: pgp_sym_encrypt(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION pgp_sym_encrypt(text, text) RETURNS bytea LANGUAGE c STRICT AS '$libdir/pgcrypto', 'pgp_sym_encrypt_text'; ALTER FUNCTION public.pgp_sym_encrypt(text, text) OWNER TO admin; -- -- Name: pgp_sym_encrypt(text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION pgp_sym_encrypt(text, text, text) RETURNS bytea LANGUAGE c STRICT AS '$libdir/pgcrypto', 'pgp_sym_encrypt_text'; ALTER FUNCTION public.pgp_sym_encrypt(text, text, text) OWNER TO admin; -- -- Name: pgp_sym_encrypt_bytea(bytea, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION pgp_sym_encrypt_bytea(bytea, text) RETURNS bytea LANGUAGE c STRICT AS '$libdir/pgcrypto', 'pgp_sym_encrypt_bytea'; ALTER FUNCTION public.pgp_sym_encrypt_bytea(bytea, text) OWNER TO admin; -- -- Name: pgp_sym_encrypt_bytea(bytea, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION pgp_sym_encrypt_bytea(bytea, text, text) RETURNS bytea LANGUAGE c STRICT AS '$libdir/pgcrypto', 'pgp_sym_encrypt_bytea'; ALTER FUNCTION public.pgp_sym_encrypt_bytea(bytea, text, text) OWNER TO admin; -- -- Name: pkgmaybemodified(name); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION pkgmaybemodified(name) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pschemaname ALIAS FOR $1; _returnval BOOLEAN; BEGIN SELECT pkghead_indev INTO _returnval FROM pkghead WHERE (pkghead_name=pschemaname); IF (NOT FOUND) THEN RETURN FALSE; END IF; RETURN _returnval; END; $_$; ALTER FUNCTION public.pkgmaybemodified(name) OWNER TO admin; -- -- Name: plpgsql_call_handler(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION plpgsql_call_handler() RETURNS language_handler LANGUAGE c AS '$libdir/plpgsql', 'plpgsql_call_handler'; ALTER FUNCTION public.plpgsql_call_handler() OWNER TO admin; -- -- Name: plpgsql_validator(oid); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION plpgsql_validator(oid) RETURNS void LANGUAGE c AS '$libdir/plpgsql', 'plpgsql_validator'; ALTER FUNCTION public.plpgsql_validator(oid) OWNER TO admin; -- -- Name: postapcheck(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postapcheck(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'postAPCheck() is deprecated - use postCheck() instead'; RETURN postCheck($1, fetchJournalNumber('AP-CK')); END; $_$; ALTER FUNCTION public.postapcheck(integer) OWNER TO admin; -- -- Name: postapcheck(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postapcheck(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'postAPCheck() is deprecated - use postCheck() instead'; RETURN postCheck($1, $2); END; $_$; ALTER FUNCTION public.postapcheck(integer, integer) OWNER TO admin; -- -- Name: postapchecks(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postapchecks(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'postAPChecks() is deprecated - use postChecks() instead'; RETURN postChecks($1); END; $_$; ALTER FUNCTION public.postapchecks(integer) OWNER TO admin; -- -- Name: postapcreditmemoapplication(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postapcreditmemoapplication(papopenid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _src RECORD; _r RECORD; _totalAmount NUMERIC := 0.0; _exchGain NUMERIC := 0.0; _apaccntid INTEGER; BEGIN -- pApopenid is the apopen_id of the C/M being applied SELECT apopen_docnumber, (apopen_amount - apopen_paid) AS balance, SUM(apcreditapply_amount) AS toApply INTO _src FROM apopen JOIN apcreditapply ON (apcreditapply_source_apopen_id=apopen_id) WHERE (apopen_id=pApopenid) GROUP BY apopen_docnumber, apopen_amount, apopen_paid; IF (NOT FOUND) THEN RAISE EXCEPTION 'A/P Credit Memo applications not found [xtuple: postAPCreditMemoApplication, -1]'; ELSIF (_src.toApply = 0) THEN RAISE EXCEPTION 'A/P Credit Memo application amount is zero. [xtuple: postAPCreditMemoApplication, -2]'; ELSIF (_src.toApply > _src.balance) THEN RAISE EXCEPTION 'A/P Credit Memo application amount greater than balance. [xtuple: postAPCreditMemoApplication, -3]'; ELSIF (_src.toApply IS NULL) THEN RAISE EXCEPTION 'A/P Credit Memo application amount is null. [xtuple: postAPCreditMemoApplication, -4]'; END IF; -- cache the C/M SELECT * INTO _src FROM apopen WHERE (apopen_id=pApopenid); IF (NOT FOUND) THEN RAISE EXCEPTION 'The A/P Credit Memo to apply was not found. [xtuple: postAPCreditMemoApplication, -5]'; END IF; -- loop thru the pending applications FOR _r IN SELECT apcreditapply_id, apcreditapply_target_apopen_id, apcreditapply_amount AS apply_amountSource, currToCurr(apcreditapply_curr_id, apopen_curr_id, apcreditapply_amount, CURRENT_DATE) AS apply_amountTarget, apopen_id, apopen_doctype, apopen_docnumber, apopen_curr_id, apopen_curr_rate, apopen_docdate, (apopen_amount - apopen_paid) AS targetBalance FROM apcreditapply JOIN apopen ON (apcreditapply_target_apopen_id=apopen_id) WHERE (apcreditapply_source_apopen_id=pApopenid) LOOP IF (_r.apply_amountTarget IS NULL) THEN RAISE EXCEPTION 'A/P Credit Memo application amount is null. [xtuple: postAPCreditMemoApplication, -6]'; END IF; IF (_r.apply_amountTarget > _r.targetBalance) THEN RAISE EXCEPTION 'A/P Credit Memo application amount greater than target balance. [xtuple: postAPCreditMemoApplication, -7]'; END IF; IF (_r.apply_amountTarget > 0) THEN -- Update the apopen item to post the paid amount UPDATE apopen SET apopen_paid = (apopen_paid + _r.apply_amountTarget) WHERE (apopen_id=_r.apcreditapply_target_apopen_id); UPDATE apopen SET apopen_open = false, apopen_closedate = CURRENT_DATE WHERE ( (apopen_id=_r.apcreditapply_target_apopen_id) AND (apopen_amount <= apopen_paid) ); -- Cache the running amount posted _totalAmount := (_totalAmount + _r.apply_amountSource); -- Record the application INSERT INTO apapply ( apapply_vend_id, apapply_amount, apapply_source_apopen_id, apapply_source_doctype, apapply_source_docnumber, apapply_target_apopen_id, apapply_target_doctype, apapply_target_docnumber, apapply_postdate, apapply_journalnumber, apapply_username, apapply_curr_id ) VALUES ( _src.apopen_vend_id, round(_r.apply_amountSource, 2), pApopenid, 'C', _src.apopen_docnumber, _r.apopen_id, _r.apopen_doctype, _r.apopen_docnumber, CURRENT_DATE, 0, getEffectiveXtUser(), _src.apopen_curr_id ); END IF; -- Delete the posted apcreditapply record DELETE FROM apcreditapply WHERE (apcreditapply_id=_r.apcreditapply_id); END LOOP; -- Record the amount posted and mark the source apopen as closed if it is completely posted UPDATE apopen SET apopen_paid = (apopen_paid + _totalAmount) WHERE (apopen_id=pApopenid); UPDATE apopen SET apopen_open = false, apopen_closedate = CURRENT_DATE WHERE ( (apopen_id=pApopenid) AND (apopen_amount <= apopen_paid) ); IF (_r.apopen_curr_id = _src.apopen_curr_id) THEN IF (_r.apopen_docdate > _src.apopen_docdate) THEN _exchGain := (_totalAmount / _r.apopen_curr_rate - _totalAmount / _src.apopen_curr_rate) * -1; ELSE _exchGain := _totalAmount / _src.apopen_curr_rate - _totalAmount / _r.apopen_curr_rate; END IF; END IF; -- do not post gain/loss to alternate prepaid -- IF (_src.apopen_accnt_id > -1) THEN -- _apaccntid := _src.apopen_accnt_id; -- ELSE _apaccntid := findAPAccount(_src.apopen_vend_id); -- END IF; PERFORM insertGLTransaction(fetchJournalNumber('AP-MISC'), 'A/P', 'CM', _src.apopen_docnumber, 'CM Application', _apaccntid, getGainLossAccntId(_apaccntid), -1, _exchGain, CURRENT_DATE); RETURN pApopenid; END; $$; ALTER FUNCTION public.postapcreditmemoapplication(papopenid integer) OWNER TO admin; -- -- Name: postapopenitems(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postapopenitems() RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN UPDATE apopen SET apopen_posted=TRUE WHERE (NOT apopen_posted); RETURN TRUE; END; $$; ALTER FUNCTION public.postapopenitems() OWNER TO admin; -- -- Name: postarcreditmemoapplication(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postarcreditmemoapplication(paropenid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN postARCreditMemoApplication(pAropenid, CURRENT_DATE); END; $$; ALTER FUNCTION public.postarcreditmemoapplication(paropenid integer) OWNER TO admin; -- -- Name: postarcreditmemoapplication(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postarcreditmemoapplication(paropenid integer, papplydate date) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _applyDate DATE; _p RECORD; _r RECORD; _totalSource NUMERIC := 0; _totalTarget NUMERIC := 0; _exchGain NUMERIC := 0; _result NUMERIC; _araccntid INTEGER; BEGIN _applyDate := COALESCE(pApplyDate, CURRENT_DATE); -- find source CM and calc total amount to apply in CM currency SELECT ROUND(aropen_amount - aropen_paid, 2) AS balance, ROUND(SUM(currToCurr(arcreditapply_curr_id, aropen_curr_id, COALESCE(arcreditapply_amount, 0), _applyDate)), 2) AS toApply INTO _p FROM aropen JOIN arcreditapply ON (arcreditapply_source_aropen_id=aropen_id) WHERE (aropen_id=pAropenid) GROUP BY aropen_amount, aropen_paid; IF (NOT FOUND) THEN RETURN -1; ELSIF (_p.toApply = 0) THEN RETURN -2; ELSIF (_p.toApply > _p.balance) THEN RETURN -3; END IF; -- cache source CM SELECT aropen_cust_id, aropen_docnumber, aropen_doctype, aropen_amount, aropen_curr_id, aropen_docdate, aropen_accnt_id, aropen_cust_id, aropen_curr_id, aropen_curr_rate INTO _p FROM aropen WHERE (aropen_id=pAropenid); IF (NOT FOUND) THEN RETURN -5; END IF; -- loop thru each arcreditapply FOR _r IN SELECT arcreditapply_id, arcreditapply_target_aropen_id, arcreditapply_reftype, arcreditapply_ref_id, arcreditapply_curr_id, currToCurr(arcreditapply_curr_id, _p.aropen_curr_id, arcreditapply_amount, _applyDate) AS arcreditapply_amountSource, currToCurr(arcreditapply_curr_id, aropen_curr_id, arcreditapply_amount, _applyDate) AS arcreditapply_amountTarget, aropen_doctype, aropen_docnumber, aropen_docdate, aropen_curr_rate FROM arcreditapply JOIN aropen ON (aropen_id=arcreditapply_target_aropen_id) WHERE (arcreditapply_source_aropen_id=pAropenid) LOOP IF (_r.arcreditapply_amountTarget IS NULL) THEN RETURN -4; END IF; IF (_r.arcreditapply_amountTarget <> 0) THEN -- Update the target invoice aropen item to post the paid amount UPDATE aropen SET aropen_paid = round(aropen_paid + _r.arcreditapply_amountTarget, 2) WHERE (aropen_id=_r.arcreditapply_target_aropen_id); UPDATE aropen SET aropen_open = (round(aropen_amount, 2) > round(aropen_paid, 2)) WHERE (aropen_id=_r.arcreditapply_target_aropen_id); -- Cache the running amount posted _totalSource := (_totalSource + _r.arcreditapply_amountSource); _totalTarget := (_totalTarget + _r.arcreditapply_amountTarget); -- Record the application INSERT INTO arapply ( arapply_cust_id, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_applied, arapply_closed, arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_username, arapply_curr_id, arapply_reftype, arapply_ref_id ) VALUES ( _p.aropen_cust_id, pAropenid, _p.aropen_doctype, _p.aropen_docnumber, _r.arcreditapply_target_aropen_id, _r.aropen_doctype, _r.aropen_docnumber, '', '', round(_r.arcreditapply_amountSource, 2), TRUE, _applyDate, _applyDate, 0, getEffectiveXtUser(), _p.aropen_curr_id, _r.arcreditapply_reftype, _r.arcreditapply_ref_id ); END IF; -- Delete the posted arcreditapply record DELETE FROM arcreditapply WHERE (arcreditapply_id=_r.arcreditapply_id); IF (_r.aropen_docdate > _p.aropen_docdate) THEN _exchGain := (_totalTarget / _r.aropen_curr_rate - _totalSource / _p.aropen_curr_rate) * -1; ELSE _exchGain := _totalSource / _p.aropen_curr_rate - _totalTarget / _r.aropen_curr_rate; END IF; IF (_p.aropen_accnt_id > -1) THEN _araccntid := _p.aropen_accnt_id; ELSE _araccntid := findARAccount(_p.aropen_cust_id); END IF; IF (_exchGain <> 0) THEN PERFORM insertGLTransaction(fetchJournalNumber('AR-MISC'), 'A/R', 'CR', _p.aropen_docnumber, 'CM Application', _araccntid, getGainLossAccntId(_araccntid), -1, _exchGain * -1, _applyDate); END IF; END LOOP; -- TODO: If this is a Customer Deposit (aropen_doctype='R') -- the we need to convert the total to a base transaction IF(_p.aropen_doctype='R') THEN SELECT insertGLTransaction(fetchJournalNumber('AR-MISC'), 'A/R', 'CD', _p.aropen_docnumber, 'CM Application', cr.accnt_id, db.accnt_id, -1, (_totalSource / _p.aropen_curr_rate), _applyDate) INTO _result FROM accnt AS cr, accnt AS db WHERE ((db.accnt_id = findDeferredAccount(_p.aropen_cust_id)) AND (cr.accnt_id = findARAccount(_p.aropen_cust_id)) ); IF(NOT FOUND OR _result < 0) THEN RAISE EXCEPTION 'There was an error posting the Customer Deposit GL Transactions.'; END IF; END IF; -- Record the amount posted and mark the source CM aropen as closed if it is completely posted UPDATE aropen SET aropen_paid = round(aropen_paid + _totalSource, 2) WHERE (aropen_id=pAropenid); UPDATE aropen SET aropen_open = (round(aropen_amount, 2) > round(aropen_paid, 2)) WHERE (aropen_id=pAropenid); RETURN pAropenid; END; $$; ALTER FUNCTION public.postarcreditmemoapplication(paropenid integer, papplydate date) OWNER TO admin; -- -- Name: postaropenitems(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postaropenitems() RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN UPDATE aropen SET aropen_posted=TRUE WHERE (NOT aropen_posted); RETURN TRUE; END; $$; ALTER FUNCTION public.postaropenitems() OWNER TO admin; -- -- Name: postbankadjustment(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postbankadjustment(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBankadjid ALIAS FOR $1; _sequence INTEGER; _r RECORD; BEGIN -- Post the G/L transaction SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'), 'G/L', 'AD', bankadj_docnumber, (bankadjtype_name || '-' || bankadj_notes), bankadjtype_accnt_id, bankaccnt_accnt_id, bankadj_id, round(currToBase(bankaccnt_curr_id, CASE WHEN(bankadjtype_iscredit) THEN (bankadj_amount * -1) ELSE bankadj_amount END, bankadj_date), 2), bankadj_date, TRUE, TRUE ) INTO _sequence FROM bankadj, bankaccnt, bankadjtype WHERE ( (bankadj_bankaccnt_id=bankaccnt_id) AND (bankadj_bankadjtype_id=bankadjtype_id) AND (NOT bankadj_posted) AND (bankadj_id=pBankadjid) ); IF ( NOT FOUND ) THEN RETURN -1; END IF; IF (_sequence >= 0) THEN -- Update the bankadj record with this sequence and mark it posted UPDATE bankadj SET bankadj_sequence = _sequence, bankadj_posted = TRUE WHERE bankadj_id=pBankadjid; END IF; RETURN _sequence; END; $_$; ALTER FUNCTION public.postbankadjustment(integer) OWNER TO admin; -- -- Name: postbankreconciliation(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postbankreconciliation(pbankrecid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN bankReconciliation(pBankrecid, 'post'); END; $$; ALTER FUNCTION public.postbankreconciliation(pbankrecid integer) OWNER TO admin; -- -- Name: postbillingselection(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postbillingselection(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCobmiscid ALIAS FOR $1; BEGIN RAISE WARNING 'postBillingselection(integer) has been deprecated. Please use createInvoice(integer).'; RETURN createInvoice(pCobmiscid); END; $_$; ALTER FUNCTION public.postbillingselection(integer) OWNER TO admin; -- -- Name: postbillingselectionconsolidated(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postbillingselectionconsolidated(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; BEGIN RAISE WARNING 'postBillingselectionConsolidated(integer) has been deprecated. Please use createInvoiceConsolidated(integer).'; RETURN createInvoiceConsolidated(pCustid); END; $_$; ALTER FUNCTION public.postbillingselectionconsolidated(integer) OWNER TO admin; -- -- Name: postbillingselections(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postbillingselections() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'postBillingselections() has been deprecated. Please use createInvoices().'; RETURN createInvoices(); END; $$; ALTER FUNCTION public.postbillingselections() OWNER TO admin; -- -- Name: postbillingselections(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postbillingselections(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'postBillingselections(int) has been deprecated. Please use createInvoices(int).'; RETURN createInvoices($1, false); END; $_$; ALTER FUNCTION public.postbillingselections(integer) OWNER TO admin; -- -- Name: postbillingselections(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postbillingselections(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustTypeId ALIAS FOR $1; pConsolidate ALIAS FOR $2; BEGIN RAISE WARNING 'postBillingselections(int,bool) has been deprecated. Please use createInvoices(int,bool).'; RETURN createInvoices(pCustTypeId, pConsolidate); END; $_$; ALTER FUNCTION public.postbillingselections(integer, boolean) OWNER TO admin; -- -- Name: postcashreceipt(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postcashreceipt(pcashrcptid integer, pjournalnumber integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _ccpayid INTEGER; _cctype TEXT; _p RECORD; _r RECORD; _t RECORD; _v RECORD; _postToAR NUMERIC; _postToMisc NUMERIC; _postToCM NUMERIC; _posted_base NUMERIC := 0; _posted NUMERIC := 0; _sequence INTEGER; _aropenid INTEGER; _arMemoNumber TEXT; _arAccntid INTEGER; _closed BOOLEAN; _debitAccntid INTEGER; _exchGain NUMERIC; _comment TEXT; _predist BOOLEAN; _check INTEGER; BEGIN _posted := 0; _posted_base := 0; SELECT fetchGLSequence() INTO _sequence; SELECT accnt_id INTO _arAccntid FROM cashrcpt, accnt, salescat WHERE ((cashrcpt_salescat_id=salescat_id) AND (salescat_ar_accnt_id=accnt_id) AND (cashrcpt_id=pCashrcptid)); IF (NOT FOUND) THEN SELECT accnt_id INTO _arAccntid FROM cashrcpt LEFT OUTER JOIN accnt ON (accnt_id=findARAccount(cashrcpt_cust_id)) WHERE ( (findARAccount(cashrcpt_cust_id)=0 OR accnt_id > 0) -- G/L interface might be disabled AND (cashrcpt_id=pCashrcptid) ); IF (NOT FOUND) THEN RETURN -5; END IF; END IF; SELECT cashrcpt.*, (cust_number||'-'||cust_name) AS custnote, (cashrcpt_amount / cashrcpt_curr_rate) AS cashrcpt_amount_base, (cashrcpt_discount / cashrcpt_curr_rate) AS cashrcpt_discount_base, cashrcpt_bankaccnt_id AS bankaccnt_id, accnt_id AS prepaid_accnt_id, COALESCE(cashrcpt_applydate, cashrcpt_distdate) AS applydate INTO _p FROM cashrcpt LEFT OUTER JOIN custinfo ON (cashrcpt_cust_id=cust_id) LEFT OUTER JOIN accnt ON (accnt_id=findPrepaidAccount(cashrcpt_cust_id)) WHERE ( (findPrepaidAccount(cashrcpt_cust_id)=0 OR accnt_id > 0) -- G/L interface might be disabled AND (cashrcpt_id=pCashrcptid) ); IF (NOT FOUND) THEN RETURN -7; END IF; IF (COALESCE(_p.cashrcpt_distdate > _p.applydate, false)) THEN RAISE EXCEPTION 'Cannot post cashrcpt % because application date is before distribution date.', _p.cashrcpt_docnumber; END IF; IF (COALESCE(_p.cashrcpt_posted, false)) THEN RAISE EXCEPTION 'Cannot post cashrcpt % because the document has already been posted.', _p.cashrcpt_docnumber; END IF; IF (COALESCE(_p.cashrcpt_void, false)) THEN RAISE EXCEPTION 'Cannot post cashrcpt % because the document has been voided.', _p.cashrcpt_docnumber; END IF; _predist := COALESCE(_p.cashrcpt_distdate < _p.applydate, false); IF (_p.cashrcpt_fundstype IN ('A', 'D', 'M', 'V')) THEN SELECT ccpay_id, ccpay_type INTO _ccpayid, _cctype FROM ccpay WHERE ((ccpay_r_ordernum IN (CAST(pCashrcptid AS TEXT), _p.cashrcpt_docnumber)) AND (ccpay_status IN ('C', 'A'))); IF NOT FOUND THEN -- the following select seems to work except for xikar - bug 8848. why? -- raise warning so there is some visibility if people fall into this path. SELECT ccpay_id, ccpay_type INTO _ccpayid, _cctype FROM ccpay WHERE ((ccpay_order_number IN (CAST(pCashrcptid AS TEXT), _p.cashrcpt_docnumber)) AND (ccpay_status IN ('C', 'A'))); IF (NOT FOUND) THEN RETURN -8; ELSE RAISE WARNING 'PostCashReceipt() found ccpay_id % for order number %/% (ref 8848).', _ccpayid, pCashrcptid, _p.cashrcpt_docnumber; END IF; END IF; -- If there is a ccpay entry and the card was charged directly, use the prepaid account IF (_cctype = 'C' ) THEN _debitAccntid := findPrepaidAccount(_p.cashrcpt_cust_id); -- If there is a ccpay entry and the card was preauthed and then charged, use the Bank account ELSE SELECT accnt_id INTO _debitAccntid FROM cashrcpt, bankaccnt, accnt WHERE ( (cashrcpt_bankaccnt_id=bankaccnt_id) AND (bankaccnt_accnt_id=accnt_id) AND (cashrcpt_id=pCashrcptid) ); IF (NOT FOUND) THEN RETURN -6; END IF; END IF; ELSE SELECT accnt_id INTO _debitAccntid FROM cashrcpt, bankaccnt, accnt WHERE ( (cashrcpt_bankaccnt_id=bankaccnt_id) AND (bankaccnt_accnt_id=accnt_id) AND (cashrcpt_id=pCashrcptid) ); IF (NOT FOUND) THEN RETURN -6; END IF; END IF; -- Determine the amount to post to A/R Open Items SELECT COALESCE(SUM(cashrcptitem_amount), 0) INTO _postToAR FROM cashrcptitem JOIN aropen ON (aropen_id=cashrcptitem_aropen_id) WHERE (cashrcptitem_cashrcpt_id=pCashrcptid); IF (NOT FOUND) THEN _postToAR := 0; END IF; -- Determine the amount to post to Misc. Distributions SELECT COALESCE(SUM(cashrcptmisc_amount), 0) INTO _postToMisc FROM cashrcptmisc WHERE (cashrcptmisc_cashrcpt_id=pCashrcptid); IF (NOT FOUND) THEN _postToMisc := 0; END IF; -- Determine the amount to post to Discount Credit Memo SELECT COALESCE(SUM(cashrcptitem_discount), 0) INTO _postToCM FROM cashrcptitem JOIN aropen ON ( (aropen_id=cashrcptitem_aropen_id) AND (aropen_doctype IN ('I', 'D')) ) WHERE (cashrcptitem_cashrcpt_id=pCashrcptid); IF (NOT FOUND) THEN _postToCM := 0; END IF; -- Check to see if the C/R is over applied IF ((_postToAR + _postToMisc) > _p.cashrcpt_amount) THEN RETURN -1; END IF; -- Check to see if the C/R is positive amount IF (_p.cashrcpt_amount <= 0) THEN RETURN -2; END IF; -- Distribute A/R Applications FOR _r IN SELECT aropen_id, aropen_doctype, aropen_docnumber, aropen_docdate, aropen_duedate, aropen_curr_id, aropen_curr_rate, aropen_amount, round(aropen_amount - aropen_paid, 2) <= round(currToCurr(_p.cashrcpt_curr_id, aropen_curr_id,abs(cashrcptitem_amount + cashrcptitem_discount),_p.cashrcpt_distdate),2) AS closed, cashrcptitem_id, cashrcptitem_amount, cashrcptitem_discount, (cashrcptitem_amount / _p.cashrcpt_curr_rate) AS cashrcptitem_amount_base, (cashrcptitem_discount / _p.cashrcpt_curr_rate) AS cashrcptitem_discount_base, round(aropen_paid + currToCurr(_p.cashrcpt_curr_id, aropen_curr_id,abs(cashrcptitem_amount),_p.cashrcpt_distdate),2) AS new_paid, round(currToCurr(_p.cashrcpt_curr_id, aropen_curr_id,cashrcptitem_discount,_p.cashrcpt_distdate),2) AS new_discount FROM cashrcptitem JOIN aropen ON (aropen_id=cashrcptitem_aropen_id) WHERE ((cashrcptitem_cashrcpt_id=pCashrcptid) AND (NOT _predist OR aropen_doctype IN ('C','R'))) LOOP -- Handle discount IF (_r.cashrcptitem_discount_base > 0) THEN PERFORM postCashReceiptDisc(_r.cashrcptitem_id, pJournalNumber); END IF; -- Update the aropen item to post the paid amount UPDATE aropen SET aropen_paid = _r.new_paid + _r.new_discount, aropen_open = (NOT _r.closed), aropen_closedate = CASE WHEN _r.closed THEN _p.cashrcpt_distdate END WHERE (aropen_id=_r.aropen_id); -- Cache the running amount posted _posted_base := _posted_base + _r.cashrcptitem_amount_base; _posted := _posted + _r.cashrcptitem_amount; -- Record the cashrcpt application IF (_r.aropen_doctype IN ('I','D')) THEN INSERT INTO arapply ( arapply_cust_id, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_reftype, arapply_ref_id, arapply_applied, arapply_closed, arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_username, arapply_curr_id ) VALUES ( _p.cashrcpt_cust_id, -1, 'K', _p.cashrcpt_number, _r.aropen_id, _r.aropen_doctype, _r.aropen_docnumber, _p.cashrcpt_fundstype, _p.cashrcpt_docnumber, 'CRA', _r.cashrcptitem_id, round(_r.cashrcptitem_amount, 2), _r.closed, _p.applydate, _p.cashrcpt_distdate, pJournalNumber, getEffectiveXtUser(), _p.cashrcpt_curr_id); ELSE INSERT INTO arapply ( arapply_cust_id, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_reftype, arapply_ref_id, arapply_applied, arapply_closed, arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_username, arapply_curr_id ) VALUES ( _p.cashrcpt_cust_id, _r.aropen_id, _r.aropen_doctype, _r.aropen_docnumber, -1, 'R', _p.cashrcpt_number, '', '', 'CRA', _r.cashrcptitem_id, round(abs(_r.cashrcptitem_amount), 2), _r.closed, _p.applydate, _p.cashrcpt_distdate, pJournalNumber, getEffectiveXtUser(), _p.cashrcpt_curr_id ); END IF; _exchGain := arCurrGain(_r.aropen_id,_p.cashrcpt_curr_id, abs(_r.cashrcptitem_amount), _p.cashrcpt_distdate); PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', (_r.aropen_doctype || '-' || _r.aropen_docnumber), CASE WHEN _r.aropen_doctype != 'R' THEN _arAccntid ELSE findDeferredAccount(_p.cashrcpt_cust_id) END, round(_r.cashrcptitem_amount_base + _exchGain, 2), _p.cashrcpt_distdate, _p.custnote, pCashrcptid ); IF (_exchGain <> 0) THEN PERFORM insertIntoGLSeries(_sequence, 'A/R', 'CR', _r.aropen_doctype || '-' || _r.aropen_docnumber, getGainLossAccntId( CASE WHEN _r.aropen_doctype != 'R' THEN _arAccntid ELSE findDeferredAccount(_p.cashrcpt_cust_id) END ), round(_exchGain, 2) * -1, _p.cashrcpt_distdate, _p.custnote, pCashrcptid); END IF; END LOOP; -- Distribute Misc. Applications FOR _r IN SELECT cashrcptmisc_id, cashrcptmisc_accnt_id, cashrcptmisc_amount, (cashrcptmisc_amount / cashrcpt_curr_rate) AS cashrcptmisc_amount_base, cashrcptmisc_notes, cashrcpt_curr_id FROM cashrcptmisc JOIN cashrcpt ON (cashrcptmisc_cashrcpt_id = cashrcpt_id) WHERE (cashrcptmisc_cashrcpt_id=pCashrcptid) LOOP -- Cache the running amount posted _posted_base := (_posted_base + _r.cashrcptmisc_amount_base); _posted := (_posted + _r.cashrcptmisc_amount); -- Record the cashrcpt application INSERT INTO arapply ( arapply_cust_id, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_applied, arapply_closed, arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_username, arapply_curr_id, arapply_reftype, arapply_ref_id ) VALUES ( _p.cashrcpt_cust_id, -1, 'K', '', -1, 'Misc.', '', _p.cashrcpt_fundstype, _p.cashrcpt_docnumber, round(_r.cashrcptmisc_amount, 2), TRUE, _p.applydate, _p.cashrcpt_distdate, pJournalNumber, getEffectiveXtUser(), _r.cashrcpt_curr_id, 'CRD', _r.cashrcptmisc_id ); PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', _r.cashrcptmisc_notes, _r.cashrcptmisc_accnt_id, round(_r.cashrcptmisc_amount_base, 2), _p.cashrcpt_distdate, _p.custnote, pCashrcptid ); END LOOP; -- Post any remaining Cash to an A/R Cash Despoit (Credit Memo) -- this credit memo may absorb an occasional currency exchange rounding error IF (round(_posted_base, 2) < round(_p.cashrcpt_amount_base, 2)) THEN _comment := ('Unapplied from ' || _p.cashrcpt_fundstype || '-' || _p.cashrcpt_docnumber); PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', _comment, _p.prepaid_accnt_id, round(_p.cashrcpt_amount_base, 2) - round(_posted_base, 2), _p.cashrcpt_distdate, _p.custnote, pCashrcptid ); SELECT fetchArMemoNumber() INTO _arMemoNumber; IF(_p.cashrcpt_usecustdeposit) THEN -- Post Customer Deposit SELECT createARCashDeposit(_p.cashrcpt_cust_id, _arMemoNumber, '', _p.cashrcpt_distdate, (_p.cashrcpt_amount - _posted), _comment, pJournalNumber, _p.cashrcpt_curr_id) INTO _aropenid; ELSE -- Post A/R Credit Memo _aropenid := createARCreditMemo(NULL, _p.cashrcpt_cust_id, _arMemoNumber, '', _p.cashrcpt_distdate, (_p.cashrcpt_amount - _posted), _comment, -1, -1, -1, _p.cashrcpt_distdate, -1, NULL, 0, pJournalNumber, _p.cashrcpt_curr_id, _arAccntid); END IF; IF (_ccpayid IS NOT NULL) THEN INSERT INTO payaropen (payaropen_ccpay_id, payaropen_aropen_id, payaropen_amount, payaropen_curr_id ) VALUES (_ccpayid, _aropenid, _p.cashrcpt_amount, _p.cashrcpt_curr_id); END IF; -- Create Cash Receipt Item to capture posting IF (_predist=false) THEN INSERT INTO cashrcptitem ( cashrcptitem_cashrcpt_id, cashrcptitem_aropen_id, cashrcptitem_amount, cashrcptitem_applied ) VALUES ( pCashrcptid, _aropenid, (_p.cashrcpt_amount - _posted), false ); END IF; ELSIF (round(_posted_base, 2) > round((_p.cashrcpt_amount_base), 2)) THEN PERFORM insertIntoGLSeries(_sequence, 'A/R', 'CR', 'Currency Exchange Rounding - ' || _p.cashrcpt_docnumber, getGainLossAccntId(_debitAccntid), round(_posted_base, 2) - round((_p.cashrcpt_amount_base + _p.cashrcpt_discount_base), 2), _p.cashrcpt_distdate, _p.custnote, pCashrcptid); END IF; -- Debit Cash PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', (_p.cashrcpt_fundstype || '-' || _p.cashrcpt_docnumber), _debitAccntid, round(_p.cashrcpt_amount_base, 2) * -1, _p.cashrcpt_distdate, _p.custnote, pCashrcptid ); -- Post any gain/loss from the alternate currency exchange rate IF (COALESCE(_p.cashrcpt_alt_curr_rate, 0.0) <> 0.0) THEN _exchGain := ROUND((_p.cashrcpt_amount / _p.cashrcpt_alt_curr_rate) - (_p.cashrcpt_amount / _p.cashrcpt_curr_rate), 2); IF (_exchGain <> 0) THEN PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', (_p.cashrcpt_fundstype || '-' || _p.cashrcpt_docnumber), _debitAccntid, (_exchGain * -1.0), _p.cashrcpt_distdate, _p.custnote, pCashrcptid ); PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', (_p.cashrcpt_fundstype || '-' || _p.cashrcpt_docnumber), getGainLossAccntId(_debitAccntid), _exchGain, _p.cashrcpt_distdate, _p.custnote, pCashrcptid ); END IF; END IF; PERFORM postGLSeries(_sequence, pJournalNumber); -- convert the cashrcptitem records to applications against the cm/cd if we are _predist IF(_predist=true) THEN FOR _r IN SELECT * FROM cashrcptitem WHERE ((cashrcptitem_cashrcpt_id=pCashrcptid) AND (cashrcptitem_amount > 0)) LOOP -- Handle discount if applicable IF (_r.cashrcptitem_discount > 0) THEN PERFORM postCashReceiptDisc(_r.cashrcptitem_id, pJournalNumber); END IF; INSERT INTO arcreditapply (arcreditapply_source_aropen_id, arcreditapply_target_aropen_id, arcreditapply_amount, arcreditapply_curr_id) VALUES(_aropenid, _r.cashrcptitem_aropen_id, _r.cashrcptitem_amount, _p.cashrcpt_curr_id); _posted := (_posted + _r.cashrcptitem_amount); END LOOP; PERFORM postArCreditMemoApplication(_aropenid, _p.applydate); -- If there is any left over go ahead and create an additional cashrcptitem record for it with the amount IF (round(_posted, 2) < round(_p.cashrcpt_amount, 2)) THEN INSERT INTO cashrcptitem ( cashrcptitem_cashrcpt_id, cashrcptitem_aropen_id, cashrcptitem_amount, cashrcptitem_applied ) VALUES ( pCashrcptid, _aropenid, (_p.cashrcpt_amount - _posted), false ); END IF; END IF; -- Update the posted cashrcpt UPDATE cashrcpt SET cashrcpt_posted=TRUE, cashrcpt_posteddate=CURRENT_DATE, cashrcpt_postedby=getEffectiveXtUser() WHERE (cashrcpt_id=pCashrcptid); RETURN 1; END; $$; ALTER FUNCTION public.postcashreceipt(pcashrcptid integer, pjournalnumber integer) OWNER TO admin; -- -- Name: postcashreceiptdisc(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postcashreceiptdisc(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCashrcptItemId ALIAS FOR $1; pJournalNumber ALIAS FOR $2; _r RECORD; _t RECORD; _v RECORD; _ardiscountid INTEGER; _arMemoNumber TEXT; _arAccntid INTEGER; _discountAccntid INTEGER; _comment TEXT; _discprcnt NUMERIC; _check INTEGER; BEGIN -- Fetch base records for processing SELECT aropen_id, aropen_doctype, aropen_amount, cashrcptitem_discount, cashrcpt_cust_id, cashrcpt_distdate, cashrcpt_applydate, cashrcpt_curr_id, cashrcpt_fundstype, cashrcpt_docnumber, round(currToCurr(cashrcpt_curr_id, aropen_curr_id, cashrcptitem_discount, cashrcpt_distdate),2) AS aropen_discount INTO _r FROM cashrcptitem JOIN cashrcpt ON (cashrcptitem_cashrcpt_id=cashrcpt_id) JOIN aropen ON ( (aropen_id=cashrcptitem_aropen_id) AND (aropen_doctype IN ('I', 'D')) ) WHERE (cashrcptitem_id=pCashrcptItemId); -- Get discount account _discountAccntid := findardiscountaccount(_r.cashrcpt_cust_id); IF (_r.cashrcptitem_discount > 0) THEN -- Determine discount percentage _discprcnt := _r.aropen_discount / _r.aropen_amount; SELECT fetchArMemoNumber() INTO _arMemoNumber; _comment := 'Discount Credit from ' || _r.cashrcpt_fundstype || '-' || _r.cashrcpt_docnumber; -- Create misc credit memo record _ardiscountid := nextval('aropen_aropen_id_seq'); INSERT INTO aropen ( aropen_id, aropen_docdate, aropen_duedate, aropen_doctype, aropen_docnumber, aropen_curr_id, aropen_posted, aropen_amount) VALUES ( _ardiscountid, _r.cashrcpt_distdate, _r.cashrcpt_distdate, 'C', _arMemoNumber, _r.cashrcpt_curr_id, false,_r.cashrcptitem_discount); IF (fetchMetricBool('CreditTaxDiscount')) THEN -- proportional tax credits calculated and implemented for the credit memo generated by the discount IF (_r.aropen_doctype = 'I') THEN -- Tax for invoices SELECT aropen_cobmisc_id AS invcheadid, invchead_curr_id, invchead_invcdate INTO _t FROM aropen LEFT OUTER JOIN invchead ON (aropen_cobmisc_id = invchead_id) LEFT OUTER JOIN invcitem ON (invchead_id = invcitem_invchead_id) WHERE aropen_id = _r.aropen_id; FOR _v IN SELECT tax_sales_accnt_id, tax_id, round(sum(taxdetail_tax), 2) AS tax, currToBase(_t.invchead_curr_id, round(sum(taxdetail_tax), 2), _t.invchead_invcdate) AS taxbasevalue FROM tax JOIN calculateTaxDetailSummary('I', _t.invcheadid, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id, tax_sales_accnt_id LOOP INSERT INTO aropentax( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_basis) VALUES ( _ardiscountid, getadjustmenttaxtypeid(), _v.tax_id, 0.00, 0.00, (round((_v.tax * _discprcnt), 2) * -1), _r.cashrcpt_distdate, 0.00); END LOOP; ELSIF (_r.aropen_doctype = 'D') THEN -- Tax for debit memos INSERT INTO aropentax( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_basis) SELECT _ardiscountid, taxhist_taxtype_id, taxhist_tax_id, 0.00, 0.00, (round((taxhist_tax * _discprcnt), 2) * -1), _r.cashrcpt_distdate, 0.00 FROM aropentax WHERE (taxhist_parent_id=_r.aropen_id); END IF; END IF; -- End taxes -- Create credit memo for discount SELECT createARCreditMemo(_ardiscountid, _r.cashrcpt_cust_id, _arMemoNumber, '', _r.cashrcpt_distdate, _r.cashrcptitem_discount, _comment, -1, -1, _discountAccntid, _r.cashrcpt_distdate, -1, NULL, 0, pJournalNumber, _r.cashrcpt_curr_id) INTO _ardiscountid; -- Apply discount credit memo INSERT INTO arcreditapply ( arcreditapply_source_aropen_id, arcreditapply_target_aropen_id, arcreditapply_amount, arcreditapply_curr_id ) VALUES ( _ardiscountid, _r.aropen_id, _r.cashrcptitem_discount, _r.cashrcpt_curr_id ); SELECT postARCreditMemoApplication(_ardiscountid, _r.cashrcpt_applydate) INTO _check; IF (_check < 0) THEN RAISE EXCEPTION 'Error posting discount credit memo application. Code %', _check; END IF; END IF; -- End handle Discount RETURN 1; END; $_$; ALTER FUNCTION public.postcashreceiptdisc(integer, integer) OWNER TO admin; -- -- Name: postcccashreceipt(integer, integer, text, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postcccashreceipt(pccpay integer, pdocid integer, pdoctype text DEFAULT NULL::text, pamount numeric DEFAULT NULL::numeric) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _aropenid INTEGER; _bankaccnt_id INTEGER; _c RECORD; _ccOrderDesc TEXT; _journal INTEGER; _realaccnt INTEGER; _return INTEGER := 0; BEGIN SELECT * INTO _c FROM ccpay JOIN custinfo ON ccpay_cust_id = cust_id WHERE (ccpay_id = pCCpay); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot find the Credit Card transaction information [xtuple: postCCcashReceipt, -11, %]', pCCpay; END IF; IF (pamount IS NOT NULL) THEN _c.ccpay_amount = pamount; END IF; SELECT bankaccnt_id, bankaccnt_accnt_id INTO _bankaccnt_id, _realaccnt FROM ccbank JOIN bankaccnt ON (ccbank_bankaccnt_id=bankaccnt_id) WHERE (ccbank_ccard_type=_c.ccpay_card_type); IF (_bankaccnt_id IS NULL) THEN RAISE EXCEPTION 'Cannot find the default Bank Account for this Credit Card [xtuple: postCCcredit, -1, %]', _c.ccpay_card_type; END IF; _ccOrderDesc := (_c.ccpay_card_type || '-' || _c.ccpay_order_number::TEXT || '-' || _c.ccpay_order_number_seq::TEXT); _journal := fetchJournalNumber('C/R'); IF (pdoctype = 'cashrcpt') THEN IF (COALESCE(pdocid, -1) < 0) THEN INSERT INTO cashrcpt ( cashrcpt_cust_id, cashrcpt_amount, cashrcpt_curr_id, cashrcpt_fundstype, cashrcpt_docnumber, cashrcpt_notes, cashrcpt_distdate, cashrcpt_bankaccnt_id, cashrcpt_usecustdeposit ) VALUES ( _c.ccpay_cust_id, _c.ccpay_amount, _c.ccpay_curr_id, _c.ccpay_card_type, _c.ccpay_r_ordernum, _ccOrderDesc, CURRENT_DATE, _bankaccnt_id, fetchMetricBool('EnableCustomerDeposits')) RETURNING cashrcpt_id INTO _return; ELSE UPDATE cashrcpt SET cashrcpt_cust_id=_c.ccpay_cust_id, cashrcpt_amount=_c.ccpay_amount, cashrcpt_curr_id=_c.ccpay_curr_id, cashrcpt_fundstype=_c.ccpay_card_type, cashrcpt_docnumber=_c.ccpay_r_ordernum, cashrcpt_notes=_ccOrderDesc, cashrcpt_distdate=CURRENT_DATE, cashrcpt_bankaccnt_id=_bankaccnt_id WHERE (cashrcpt_id=pdocid); _return := pdocid; END IF; ELSIF (pdoctype = 'cohead') THEN SELECT createARCreditMemo(NULL, _c.ccpay_cust_id, fetchArMemoNumber(), cohead_number, CURRENT_DATE, _c.ccpay_amount, 'Unapplied from ' || _ccOrderDesc, NULL, NULL, NULL, CURRENT_DATE, NULL, cohead_salesrep_id, NULL, _journal, _c.ccpay_curr_id, NULL, pCCpay) INTO _aropenid FROM cohead WHERE cohead_id = pdocid; IF (COALESCE(_aropenid, -1) < 0) THEN -- coalesce handles not-found case RAISE EXCEPTION '[xtuple: createARCreditMemo, %]', _aropenid; END IF; INSERT INTO payaropen (payaropen_ccpay_id, payaropen_aropen_id, payaropen_amount, payaropen_curr_id) VALUES (pccpay, _aropenid, _c.ccpay_amount, _c.ccpay_curr_id); INSERT INTO aropenalloc (aropenalloc_aropen_id, aropenalloc_doctype, aropenalloc_doc_id, aropenalloc_amount, aropenalloc_curr_id) VALUES (_aropenid, 'S', pdocid, _c.ccpay_amount, _c.ccpay_curr_id); _return := _aropenid; END IF; PERFORM insertGLTransaction(_journal, 'A/R', 'CR', _ccOrderDesc, ('Cash Receipt from Credit Card ' || _c.cust_name), findPrepaidAccount(_c.ccpay_cust_id), _realaccnt, NULL, ROUND(currToBase(_c.ccpay_curr_id, _c.ccpay_amount, _c.ccpay_transaction_datetime::DATE),2), CURRENT_DATE); RETURN _return; END; $$; ALTER FUNCTION public.postcccashreceipt(pccpay integer, pdocid integer, pdoctype text, pamount numeric) OWNER TO admin; -- -- Name: postcccredit(integer, text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postcccredit(integer, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCCpay ALIAS FOR $1; preftype ALIAS FOR $2; prefid ALIAS FOR $3; _c RECORD; _ccOrderDesc TEXT; _cglaccnt INTEGER; _dglaccnt INTEGER; _glseriesres INTEGER; _notes TEXT := 'Credit via Credit Card'; _r RECORD; _sequence INTEGER; _dmaropenid INTEGER; BEGIN IF ((preftype = 'cohead') AND NOT EXISTS(SELECT cohead_id FROM cohead WHERE (cohead_id=prefid))) THEN RAISE EXCEPTION 'Cannot find original Sales Order for this Credit Card credit [xtuple: postCCcredit, -2, %, %, %]', pCCpay, preftype, prefid; ELSIF ((preftype = 'aropen') AND NOT EXISTS(SELECT aropen_id FROM aropen WHERE (aropen_id=prefid))) THEN RAISE EXCEPTION 'Cannot find original A/R Open record for this Credit Card credit [xtuple: postCCcredit, -2, %, %, %]', pCCpay, preftype, prefid; ELSIF ((preftype = 'cmhead') AND NOT EXISTS(SELECT cmhead_id FROM cmhead WHERE cmhead_id=prefid)) THEN RAISE EXCEPTION 'Cannot find original Credit Memo record for this Credit Card credit [xtuple: postCCcredit, -2, %, %, %]', pCCpay, preftype, prefid; END IF; SELECT * INTO _c FROM ccpay WHERE (ccpay_id = pCCpay); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot find the record for this Credit Card credit [xtuple: postCCcredit, -3, %, %, %]', pCCpay, preftype, prefid; END IF; IF (preftype = 'cohead') THEN _dglaccnt := findPrepaidAccount(_c.ccpay_cust_id); ELSE _dglaccnt := findARAccount(_c.ccpay_cust_id); END IF; SELECT bankaccnt_accnt_id INTO _cglaccnt FROM ccbank JOIN bankaccnt ON (ccbank_bankaccnt_id=bankaccnt_id) WHERE (ccbank_ccard_type=_c.ccpay_card_type); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot find the default Bank Account for this Credit Card [xtuple: postCCcredit, -1, %]', pCCpay; END IF; IF (_c.ccpay_type != 'R') THEN RAISE EXCEPTION 'This Credit Card transaction is not a credit/refund [xtuple: postCCcredit, -4, %]', pCCpay; END IF; _sequence := fetchGLSequence(); IF (_c.ccpay_r_ref IS NOT NULL) THEN _ccOrderDesc := (_c.ccpay_card_type || '-' || _c.ccpay_r_ref); ELSE _ccOrderDesc := (_c.ccpay_card_type || '-' || _c.ccpay_order_number::TEXT || '-' || COALESCE(_c.ccpay_order_number_seq::TEXT, '')); END IF; _glseriesres := insertIntoGLSeries(_sequence, 'A/R', 'CC', _ccOrderDesc, _dglaccnt, ROUND(currToBase(_c.ccpay_curr_id, _c.ccpay_amount, _c.ccpay_transaction_datetime::DATE), 2) * -1, CURRENT_DATE, _notes); IF (_glseriesres < 0) THEN RAISE EXCEPTION 'Could not write debit side of Credit Card credit to the G/L [xtuple: insertIntoGLSeries, %]', _glseriesres; END IF; _glseriesres := insertIntoGLSeries(_sequence, 'A/R', 'CC', _ccOrderDesc, _cglaccnt, ROUND(currToBase(_c.ccpay_curr_id, _c.ccpay_amount, _c.ccpay_transaction_datetime::DATE),2), CURRENT_DATE, _notes); IF (_glseriesres < 0) THEN RAISE EXCEPTION 'Could not write credit side of Credit Card credit to the G/L [xtuple: insertIntoGLSeries, %]', _glseriesres; END IF; _glseriesres := postGLSeries(_sequence, fetchJournalNumber('C/R') ); IF (_glseriesres < 0) THEN RAISE EXCEPTION 'Could not post Credit Card credit to the G/L [xtuple: postglseries, %]', _glseriesres; END IF; IF (preftype = 'aropen') THEN SELECT * INTO _r FROM aropen WHERE (aropen_id=prefid); ELSE SELECT aropen.* INTO _r FROM ccpay n JOIN ccpay o ON (o.ccpay_id=n.ccpay_ccpay_id) JOIN payaropen ON (payaropen_ccpay_id=o.ccpay_id) JOIN aropen ON (payaropen_aropen_id=aropen_id) WHERE (n.ccpay_id=pCCpay); END IF; IF (FOUND) THEN SELECT createardebitmemo( NULL, _r.aropen_cust_id, NULL, fetchARMemoNumber(), _r.aropen_ordernumber, current_date, _c.ccpay_amount, _notes, -1, -1, -1, CURRENT_DATE, -1, NULL, 0, _r.aropen_curr_id) INTO _dmaropenid; IF (_r.aropen_open) THEN PERFORM applyARCreditMemoToBalance(_r.aropen_id, _dmaropenid); PERFORM postARCreditMemoApplication(_r.aropen_id); END IF; END IF; IF (preftype = 'cohead') THEN INSERT INTO payco ( payco_ccpay_id, payco_cohead_id, payco_amount, payco_curr_id ) VALUES ( pCCpay, prefid, 0 - _c.ccpay_amount, _c.ccpay_curr_id ); END IF; RETURN 0; END; $_$; ALTER FUNCTION public.postcccredit(integer, text, integer) OWNER TO admin; -- -- Name: postccvoid(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postccvoid(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pccpayid ALIAS FOR $1; BEGIN -- for now this is very simple: mark the ccpay record voided. -- in the future this might be expanded to back out changes to other tables -- but for now the VOID request is sent to the credit card processing company -- before those other tables are modified. UPDATE ccpay SET ccpay_status = 'V' WHERE (ccpay_id=pccpayid); IF (NOT FOUND) THEN RETURN -1; END IF; RETURN 0; END; $_$; ALTER FUNCTION public.postccvoid(integer) OWNER TO admin; -- -- Name: postcheck(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postcheck(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pcheckid ALIAS FOR $1; _journalNumber INTEGER := $2; _amount_base NUMERIC := 0; _credit_glaccnt INTEGER; _exchGain NUMERIC := 0; _exchGainTmp NUMERIC := 0; _gltransNote TEXT; _p RECORD; _r RECORD; _t RECORD; _sequence INTEGER; _test INTEGER; _cm BOOLEAN; _amount_check NUMERIC := 0; BEGIN _cm := FALSE; SELECT fetchGLSequence() INTO _sequence; IF (_journalNumber IS NULL) THEN _journalNumber := fetchJournalNumber('AP-CK'); END IF; SELECT checkhead.*, checkhead_amount / checkhead_curr_rate AS checkhead_amount_base, bankaccnt_accnt_id AS bankaccntid INTO _p FROM checkhead JOIN bankaccnt ON (checkhead_bankaccnt_id=bankaccnt_id) WHERE (checkhead_id=pcheckid); IF (FOUND) THEN IF (_p.checkhead_recip_type = 'V') THEN SELECT vend_number AS checkrecip_number, vend_name AS checkrecip_name, findAPAccount(vend_id) AS checkrecip_accnt_id, 'A/P'::text AS checkrecip_gltrans_source INTO _t FROM vendinfo WHERE (vend_id=_p.checkhead_recip_id); ELSIF (_p.checkhead_recip_type = 'C') THEN SELECT cust_number AS checkrecip_number, cust_name AS checkrecip_name, findARAccount(cust_id) AS checkrecip_accnt_id, 'A/R'::text AS checkrecip_gltrans_source INTO _t FROM custinfo WHERE (cust_id=_p.checkhead_recip_id); ELSIF (_p.checkhead_recip_type = 'T') THEN SELECT taxauth_code AS checkrecip_number, taxauth_name AS checkrecip_name, taxauth_accnt_id AS checkrecip_accnt_id, 'G/L'::text AS checkrecip_gltrans_source INTO _t FROM taxauth WHERE (taxauth_id=_p.checkhead_recip_id); ELSE RETURN -11; END IF; ELSE RETURN -11; END IF; IF (_p.checkhead_posted) THEN RETURN -10; END IF; IF (_p.checkhead_recip_type = 'C') THEN SELECT checkitem_id FROM checkitem INTO _test WHERE (checkitem_checkhead_id=pcheckid) LIMIT 1; IF (FOUND) THEN _cm := TRUE; END IF; END IF; _gltransNote := _t.checkrecip_number || '-' || _t.checkrecip_name || '\n' || _p.checkhead_for || '\n' || _p.checkhead_notes; IF (_p.checkhead_misc AND NOT _cm) THEN IF (COALESCE(_p.checkhead_expcat_id, -1) < 0) THEN IF (_p.checkhead_recip_type = 'V') THEN PERFORM createAPCreditMemo( _p.checkhead_recip_id, _journalNumber, CAST(fetchAPMemoNumber() AS text), '', _p.checkhead_checkdate, _p.checkhead_amount, _gltransNote || ' ' || _p.checkhead_notes, -1, _p.checkhead_checkdate, -1, _p.checkhead_curr_id ); _credit_glaccnt := findAPPrepaidAccount(_p.checkhead_recip_id); ELSIF (_p.checkhead_recip_type = 'C') THEN PERFORM createARDebitMemo(NULL, _p.checkhead_recip_id, NULL, fetchARMemoNumber(), '', _p.checkhead_checkdate, _p.checkhead_amount, _gltransNote || ' ' || _p.checkhead_notes, -1, -1, -1, _p.checkhead_checkdate, -1, NULL, 0, _p.checkhead_curr_id ); _credit_glaccnt := findPrepaidAccount(_p.checkhead_recip_id); ELSIF (_p.checkhead_recip_type = 'T') THEN -- TODO: should we create a credit memo for the tax authority? how? _credit_glaccnt := _t.checkrecip_accnt_id; END IF; -- recip type ELSE IF (_cm) THEN _credit_glaccnt := findARAccount(_p.checkhead_recip_id); ELSE SELECT expcat_exp_accnt_id INTO _credit_glaccnt FROM expcat WHERE (expcat_id=_p.checkhead_expcat_id); IF (NOT FOUND) THEN RETURN -12; END IF; END IF; END IF; IF (COALESCE(_credit_glaccnt, -1) < 0) THEN RETURN -13; END IF; PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source, 'CK', CAST(_p.checkhead_number AS TEXT), _credit_glaccnt, round(_p.checkhead_amount_base, 2) * -1, _p.checkhead_checkdate, _gltransNote, pcheckid ); _amount_base := _p.checkhead_amount_base; ELSE FOR _r IN SELECT checkitem_amount, checkitem_discount, CASE WHEN (checkitem_apopen_id IS NOT NULL AND apopen_doctype='C') THEN checkitem_amount / apopen_curr_rate * -1.0 WHEN (checkitem_apopen_id IS NOT NULL) THEN checkitem_amount / apopen_curr_rate ELSE currToBase(checkitem_curr_id, checkitem_amount, COALESCE(checkitem_docdate, _p.checkhead_checkdate)) END AS checkitem_amount_base, currTocurr(checkitem_curr_id, _p.checkhead_curr_id, CASE WHEN (checkitem_apopen_id IS NOT NULL AND apopen_doctype='C') THEN checkitem_amount * -1.0 ELSE checkitem_amount END, _p.checkhead_checkdate) AS amount_check, apopen_id, apopen_doctype, apopen_docnumber, aropen_id, aropen_doctype, aropen_docnumber, checkitem_curr_id, checkitem_curr_rate, apopen_curr_rate, COALESCE(checkitem_docdate, _p.checkhead_checkdate) AS docdate FROM (checkitem LEFT OUTER JOIN apopen ON (checkitem_apopen_id=apopen_id)) LEFT OUTER JOIN aropen ON (checkitem_aropen_id=aropen_id) WHERE (checkitem_checkhead_id=pcheckid) LOOP _exchGainTmp := 0; IF (_r.apopen_id IS NOT NULL) THEN -- take the discount if specified before we do anything else IF(_r.checkitem_discount > 0.0) THEN PERFORM createAPDiscount(_r.apopen_id, _r.checkitem_discount); END IF; UPDATE apopen SET apopen_paid = round(apopen_paid + _r.checkitem_amount, 2), apopen_open = round(apopen_amount, 2) > round(apopen_paid + _r.checkitem_amount, 2), apopen_closedate = CASE WHEN (round(apopen_amount, 2) <= round(apopen_paid + _r.checkitem_amount, 2)) THEN _p.checkhead_checkdate END WHERE (apopen_id=_r.apopen_id); -- Post the application INSERT INTO apapply ( apapply_vend_id, apapply_postdate, apapply_username, apapply_source_apopen_id, apapply_source_doctype, apapply_source_docnumber, apapply_target_apopen_id, apapply_target_doctype, apapply_target_docnumber, apapply_journalnumber, apapply_amount, apapply_curr_id, apapply_checkhead_id ) VALUES ( _p.checkhead_recip_id, _p.checkhead_checkdate, getEffectiveXtUser(), -1, 'K', _p.checkhead_number, _r.apopen_id, _r.apopen_doctype, _r.apopen_docnumber, _journalNumber, _r.checkitem_amount, _r.checkitem_curr_id, _p.checkhead_id ); END IF; -- if check item's apopen_id is not null IF (_r.aropen_id IS NOT NULL) THEN UPDATE aropen SET aropen_paid = round(aropen_paid + _r.checkitem_amount, 2), aropen_open = round(aropen_amount, 2) > round(aropen_paid + _r.checkitem_amount, 2), aropen_closedate = CASE WHEN (round(aropen_amount, 2) <= round(aropen_paid + _r.checkitem_amount, 2)) THEN _p.checkhead_checkdate END WHERE (aropen_id=_r.aropen_id); -- Post the application INSERT INTO arapply ( arapply_cust_id, arapply_postdate, arapply_distdate, arapply_username, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_journalnumber, arapply_applied, arapply_curr_id ) VALUES ( _p.checkhead_recip_id, _p.checkhead_checkdate, _p.checkhead_checkdate, getEffectiveXtUser(), _r.aropen_id,_r.aropen_doctype, _r.aropen_docnumber, -1, 'K',_p.checkhead_number , _journalNumber, _r.checkitem_amount, _r.checkitem_curr_id ); END IF; -- if check item's aropen_id is not null IF (_r.apopen_id IS NOT NULL) THEN SELECT apCurrGain(_r.apopen_id,_r.checkitem_curr_id, _r.checkitem_amount, _p.checkhead_checkdate) INTO _exchGainTmp; ELSIF (_r.aropen_id IS NOT NULL) THEN SELECT arCurrGain(_r.aropen_id,_r.checkitem_curr_id, _r.checkitem_amount, _p.checkhead_checkdate) INTO _exchGainTmp; END IF; _exchGain := _exchGain + _exchGainTmp; PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source, 'CK', CAST(_p.checkhead_number AS TEXT), _t.checkrecip_accnt_id, round(_r.checkitem_amount_base, 2) * -1.0, _p.checkhead_checkdate, _gltransNote, pcheckid ); IF (_exchGainTmp <> 0) THEN PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source, 'CK', CAST(_p.checkhead_number AS TEXT), getGainLossAccntId(_t.checkrecip_accnt_id), round(_exchGainTmp,2), _p.checkhead_checkdate, _gltransNote, pcheckid ); END IF; _amount_check := (_amount_check + _r.amount_check); _amount_base := (_amount_base + _r.checkitem_amount_base); END LOOP; IF( (_amount_check - _p.checkhead_amount) <> 0.0 ) THEN _exchGainTmp := currToBase(_p.checkhead_curr_id, _amount_check - _p.checkhead_amount, _p.checkhead_checkdate); _exchGain := _exchGain + _exchGainTmp; END IF; -- ensure that the check balances, attribute rounding errors to gain/loss IF round(_amount_base, 2) - round(_exchGain, 2) <> round(_p.checkhead_amount_base, 2) THEN IF round(_amount_base - _exchGain, 2) = round(_p.checkhead_amount_base, 2) THEN PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source, 'CK', CAST(_p.checkhead_number AS TEXT), getGainLossAccntId(_p.bankaccntid), round(_amount_base, 2) - round(_exchGain, 2) - round(_p.checkhead_amount_base, 2), _p.checkhead_checkdate, _gltransNote, pcheckid ); ELSE RAISE EXCEPTION 'checkhead_id % does not balance (% - % <> %)', pcheckid, _amount_base, _exchGain, _p.checkhead_amount_base; END IF; END IF; END IF; PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source, 'CK', CAST(_p.checkhead_number AS TEXT), _p.bankaccntid, round(_p.checkhead_amount_base, 2), _p.checkhead_checkdate, _gltransNote, pcheckid ); -- Post any gain/loss from the alternate currency exchange rate IF (COALESCE(_p.checkhead_alt_curr_rate, 0.0) <> 0.0) THEN _exchGain := ROUND((_p.checkhead_curr_rate - _p.checkhead_alt_curr_rate) * _p.checkhead_amount_base, 2); IF (_exchGain <> 0) THEN PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source, 'CK', CAST(_p.checkhead_number AS TEXT), _p.bankaccntid, (_exchGain * -1.0), _p.checkhead_checkdate, _gltransNote, pcheckid ); PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source, 'CK', CAST(_p.checkhead_number AS TEXT), getGainLossAccntId(_p.bankaccntid), _exchGain, _p.checkhead_checkdate, _gltransNote, pcheckid ); END IF; END IF; PERFORM postGLSeries(_sequence, _journalNumber); UPDATE checkhead SET checkhead_posted=TRUE, checkhead_journalnumber=_journalNumber WHERE (checkhead_id=pcheckid); RETURN _journalNumber; END; $_$; ALTER FUNCTION public.postcheck(integer, integer) OWNER TO admin; -- -- Name: postchecks(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postchecks(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBankaccntid ALIAS FOR $1; _journalNumber INTEGER; BEGIN SELECT fetchJournalNumber('AP-CK') INTO _journalNumber; PERFORM postCheck(checkhead_id, _journalNumber) FROM checkhead JOIN bankaccnt ON (bankaccnt_id=checkhead_bankaccnt_id) WHERE ( (NOT checkhead_void) AND (NOT checkhead_posted) AND CASE WHEN (bankaccnt_prnt_check) THEN (checkhead_printed) ELSE 1=1 END AND (checkhead_bankaccnt_id=pBankaccntid) ); RETURN _journalNumber; END; $_$; ALTER FUNCTION public.postchecks(integer) OWNER TO admin; -- -- Name: postcomment(integer, text, integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postcomment(pcmnttypeid integer, psource text, psourceid integer, ptext text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN RETURN postComment(pCmnttypeid, pSource, pSourceid, pText, NULL); END $$; ALTER FUNCTION public.postcomment(pcmnttypeid integer, psource text, psourceid integer, ptext text) OWNER TO admin; -- -- Name: postcomment(text, text, integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postcomment(pcmnttypename text, psource text, psourceid integer, ptext text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; BEGIN SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name=pCmnttypename); IF (NOT FOUND) THEN RAISE EXCEPTION 'Comment type % not found.', pCmnttypename; END IF; RETURN postComment(_cmnttypeid, pSource, pSourceid, pText, NULL); END $$; ALTER FUNCTION public.postcomment(pcmnttypename text, psource text, psourceid integer, ptext text) OWNER TO admin; -- -- Name: postcomment(integer, text, integer, text, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postcomment(pcmnttypeid integer, psource text, psourceid integer, ptext text, ppublic boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _commentid INTEGER; _public BOOLEAN; BEGIN _public := COALESCE(pPublic, fetchmetricbool('CommentPublicDefault')); INSERT INTO comment ( comment_cmnttype_id, comment_source, comment_source_id, comment_date, comment_user, comment_text, comment_public ) VALUES ( pCmnttypeid, pSource, pSourceid, CURRENT_TIMESTAMP, getEffectiveXtUser(), pText, _public ) RETURNING comment_id INTO _commentid; RETURN _commentid; END; $$; ALTER FUNCTION public.postcomment(pcmnttypeid integer, psource text, psourceid integer, ptext text, ppublic boolean) OWNER TO admin; -- -- Name: postcost(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postcost(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemcostid ALIAS FOR $1; _p RECORD; BEGIN SELECT round(currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE),6) AS newcost, itemcost_curr_id, CURRENT_DATE AS effective, item_number, itemcost_stdcost AS oldcost INTO _p FROM itemcost, item WHERE ((itemcost_item_id=item_id) AND (itemcost_id=pItemcostid)); IF (_p.newcost IS NULL) THEN RAISE EXCEPTION 'There is no valid Exchange Rate for this currency. (%, %)', _p.itemcost_curr_id, _p.effective; RETURN FALSE; END IF; RETURN updateStdCost(pItemcostid, _p.newcost, _p.oldcost, 'Post Cost', ('Post Actual Cost to Standard for item ' || _p.item_number)); END; $_$; ALTER FUNCTION public.postcost(integer) OWNER TO admin; -- -- Name: postcountslip(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postcountslip(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCntslipid ALIAS FOR $1; _p RECORD; _comments TEXT; _temp TEXT; BEGIN SELECT itemsite_loccntrl, itemsite_controlmethod, cntslip_posted, cntslip_lotserial, cntslip_comments, cntslip_number, cntslip_qty INTO _p FROM cntslip, invcnt, itemsite WHERE ( (cntslip_cnttag_id=invcnt_id) AND (invcnt_itemsite_id=itemsite_id) AND (cntslip_id=pCntslipid) ); IF (NOT _p.cntslip_posted) THEN SELECT ( E'\nCount Slip #' || _p.cntslip_number || ' counted ' || formatQty(_p.cntslip_qty) ) INTO _comments; -- Add the Location name if the itemsite is MLC IF (_p.itemsite_loccntrl) THEN SELECT ( ', Location:' || location_name ) INTO _temp FROM location, cntslip WHERE ( (cntslip_location_id=location_id) AND (cntslip_id=pCntslipid) ); _comments := (_comments || _temp); END IF; -- Add the Lot/Serial if the itemsite is Lot or Serial controlled IF (_p.itemsite_controlmethod = 'L') THEN _comments := (_comments || ( ', Lot #:' || _p.cntslip_lotserial)); ELSIF (_p.itemsite_controlmethod = 'S') THEN _comments := (_comments || ( ', Serial #:' || _p.cntslip_lotserial)); END IF; _comments := (_comments || ' ' || _p.cntslip_comments); UPDATE cntslip SET cntslip_posted=TRUE WHERE (cntslip_id=pCntslipid); UPDATE invcnt SET invcnt_qoh_after = ( COALESCE(invcnt_qoh_after, 0) + cntslip_qty), invcnt_comments = (invcnt_comments || _comments) FROM cntslip WHERE ( (cntslip_cnttag_id=invcnt_id) AND (cntslip_id=pCntslipid) ); RETURN 1; ELSE RETURN -1; END IF; END; $_$; ALTER FUNCTION public.postcountslip(integer) OWNER TO admin; -- -- Name: postcounttag(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postcounttag(pinvcntid integer, pthaw boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _avgCostingMethod TEXT; _invhistid INTEGER; _postDate TIMESTAMP; _runningQty NUMERIC; _errorCode INTEGER; _itemlocSeries INTEGER := 0; _hasDetail BOOLEAN; _p RECORD; _itemloc RECORD; _cntslip RECORD; _lsid INTEGER; BEGIN SELECT COALESCE(fetchMetricText('CountAvgCostMethod'), 'STD') INTO _avgCostingMethod; SELECT invcnt_id, invcnt_tagnumber, invcnt_qoh_after, invcnt_location_id, item_number, itemsite_id, itemsite_freeze, itemsite_qtyonhand, itemsite_loccntrl, itemsite_location_id, CASE WHEN (itemsite_costmethod = 'N') THEN 0 WHEN ( (itemsite_costmethod = 'A') AND (itemsite_qtyonhand = 0) AND (_avgCostingMethod = 'ACT') ) THEN actcost(itemsite_item_id) WHEN ( (itemsite_costmethod = 'A') AND (_avgCostingMethod IN ('ACT', 'AVG')) ) THEN avgcost(itemsite_id) ELSE stdcost(itemsite_item_id) END AS cost, itemsite_costmethod, itemsite_controlmethod, itemsite_value INTO _p FROM invcnt, itemsite, item WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (invcnt_qoh_after IS NOT NULL) AND (NOT invcnt_posted) AND (invcnt_id=pInvcntid) ); IF (FOUND) THEN -- If the invcnt_location_id is not null then -- call a separate function so as not to affect -- the existing functionality. IF (_p.invcnt_location_id IS NOT NULL) THEN RETURN postCountTagLocation(pInvcntid, pThaw); END IF; SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid; IF (_p.itemsite_freeze) THEN SELECT invcnt_tagdate INTO _postDate FROM invcnt WHERE (invcnt_id=pInvcntid) ; ELSE _postDate = CURRENT_TIMESTAMP; END IF; _hasDetail = FALSE; -- Post the detail indicated by cntslips IF ( (_p.itemsite_loccntrl) OR (_p.itemsite_controlmethod IN ('L', 'S')) ) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; -- Adjust any existing detail to 0 FOR _itemloc IN SELECT itemloc_id, itemloc_location_id, itemloc_ls_id, itemloc_qty FROM itemloc WHERE (itemloc_itemsite_id=_p.itemsite_id) LOOP _hasDetail = TRUE; -- Create the itemlocdist flushing records INSERT INTO itemlocdist ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_expiration, itemlocdist_itemsite_id, itemlocdist_invhist_id, itemlocdist_flush ) VALUES ( _itemlocSeries, 'I', _itemloc.itemloc_id, endOfTime(), _p.itemsite_id, _invhistid, TRUE ); END LOOP; -- Clear the running detail Qty _runningQty := 0; -- Adjust the detail to the cntslip indicated value FOR _cntslip IN SELECT cntslip_location_id, cntslip_lotserial, cntslip_lotserial_expiration, cntslip_lotserial_warrpurc, SUM(cntslip_qty) AS qty, itemsite_item_id FROM cntslip, invcnt, itemsite WHERE ((cntslip_cnttag_id=pInvcntid) AND (cntslip_cnttag_id=invcnt_id) AND (invcnt_itemsite_id=itemsite_id)) GROUP BY cntslip_location_id, cntslip_lotserial, cntslip_lotserial_expiration, cntslip_lotserial_warrpurc,itemsite_item_id LOOP -- Handle the LotSerial IF (LENGTH(_cntslip.cntslip_lotserial)>0) THEN SELECT ls_id INTO _lsid FROM ls WHERE ((ls_item_id=_cntslip.itemsite_item_id) AND (UPPER(ls_number)=UPPER(_cntslip.cntslip_lotserial))); IF (NOT FOUND) THEN _lsid := NEXTVAL('ls_ls_id_seq'); INSERT INTO ls VALUES (_lsid,_cntslip.itemsite_item_id,UPPER(_cntslip.cntslip_lotserial)); END IF; END IF; -- Track the running Qty _runningQty := (_runningQty + _cntslip.qty); _hasDetail = TRUE; -- Create the itemlocdist populating record INSERT INTO itemlocdist ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_itemsite_id, itemlocdist_ls_id, itemlocdist_expiration, itemlocdist_warranty, itemlocdist_qty, itemlocdist_invhist_id ) VALUES ( _itemlocSeries, 'L', _cntslip.cntslip_location_id, _p.itemsite_id, _lsid, COALESCE(_cntslip.cntslip_lotserial_expiration, endOfTime()), _cntslip.cntslip_lotserial_warrpurc,_cntslip.qty, _invhistid ); END LOOP; IF (_runningQty > _p.invcnt_qoh_after) THEN -- The total Count Slip Qty is greater than the Count Tag Qty, -- Don't post the Count. _errorCode = -1; ELSIF ( (_runningQty < _p.invcnt_qoh_after) AND (_p.itemsite_controlmethod IN ('L', 'S')) ) THEN -- The total Count Slip Qty is less than the Count Tag Qty, -- and the Item Site is Lot/Serial controlled. -- Don't post the Count. _errorCode = -2; ELSIF (_runningQty < _p.invcnt_qoh_after) THEN IF ( (NOT _p.itemsite_loccntrl) OR (_p.itemsite_location_id = -1) ) THEN -- The total Count Slip Qty is less than the Count Tag Qty, -- and there isn't a default location to post into. -- Don't post the Count. _errorCode = -3; ELSIF ( SELECT (metric_value='f') FROM metric WHERE (metric_name='PostCountTagToDefault') ) THEN -- The total Count Slip Qty is less than the Count Tag Qty, -- and we don't post Count Tags to default Locations -- Don't post the Count. _errorCode = -4; ELSE -- Distribute the remaining qty into the default location. INSERT INTO itemlocdist ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_itemsite_id, itemlocdist_expiration, itemlocdist_qty, itemlocdist_invhist_id ) SELECT _itemlocSeries, 'L', _p.itemsite_location_id, _p.itemsite_id, endOfTime(), (_p.invcnt_qoh_after - _runningQty), _invhistid; _hasDetail = TRUE; _errorCode = 0; END IF; ELSE -- The Count Slip Qty. must equal the Count Tag Qty. _errorCode = 0; END IF; -- If we shouldn't post the count then delete the itemlocdist records, -- and return with the error. IF (_errorCode <> 0) THEN DELETE FROM itemlocdist WHERE (itemlocdist_series=_itemlocSeries); RETURN _errorCode; END IF; END IF; -- Mod. the Count Tag. UPDATE invcnt SET invcnt_qoh_before=_p.itemsite_qtyonhand, invcnt_postdate=_postDate, invcnt_posted=TRUE, invcnt_invhist_id=_invhistid, invcnt_post_username=getEffectiveXtUser() WHERE (invcnt_id=pInvcntid); -- Create the CC transaction INSERT INTO invhist ( invhist_id, invhist_itemsite_id, invhist_transdate, invhist_transtype, invhist_invqty, invhist_qoh_before, invhist_qoh_after, invhist_docnumber, invhist_comments, invhist_invuom, invhist_unitcost, invhist_hasdetail, invhist_costmethod, invhist_value_before, invhist_value_after, invhist_series ) SELECT _invhistid, itemsite_id, _postDate, 'CC', (invcnt_qoh_after - invcnt_qoh_before), invcnt_qoh_before, invcnt_qoh_after, invcnt_tagnumber, invcnt_comments, uom_name, _p.cost, _hasDetail, _p.itemsite_costmethod, _p.itemsite_value, _p.itemsite_value + (_p.cost * (invcnt_qoh_after - invcnt_qoh_before)), _itemlocSeries FROM itemsite, invcnt, item, uom WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (itemsite_controlmethod <> 'N') AND (invcnt_id=pInvcntid) ); IF ( SELECT metric_value FROM metric WHERE ((metric_name = 'EnableAsOfQOH') AND (metric_value = 't'))) THEN IF (NOT postIntoInvBalance(_invhistid)) THEN RAISE EXCEPTION 'Post into Inventory Balance for invhist_id=% was unsuccessful',_invhistid; END IF; END IF; -- Update the QOH -- Avoid negative value when average cost item UPDATE itemsite SET itemsite_qtyonhand=_p.invcnt_qoh_after, itemsite_value = CASE WHEN ((itemsite_costmethod='A') AND (_p.itemsite_value + (_p.cost * (_p.invcnt_qoh_after - itemsite_qtyonhand))) < 0.0) THEN 0.0 ELSE (_p.itemsite_value + (_p.cost * (_p.invcnt_qoh_after - itemsite_qtyonhand))) END, itemsite_datelastcount=_postDate WHERE (itemsite_id=_p.itemsite_id); -- Post the detail, if any IF (_hasDetail) THEN PERFORM distributeItemlocSeries(_itemlocSeries); END IF; -- Thaw the itemsite if it's frozen IF (pThaw) THEN PERFORM thawItemSite(invcnt_itemsite_id) FROM invcnt WHERE (invcnt_id=pInvcntid); END IF; -- Distribute to G/L PERFORM insertGLTransaction( 'I/M', 'CT', _p.invcnt_tagnumber, ('Post Count Tag #' || _p.invcnt_tagnumber || ' for Item ' || _p.item_number), costcat_adjustment_accnt_id, costcat_asset_accnt_id, _invhistid, ( (_p.invcnt_qoh_after - _p.itemsite_qtyonhand) * _p.cost), _postDate::DATE ) FROM invcnt, itemsite, costcat WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_costcat_id=costcat_id) AND (invcnt_id=pInvcntid) ); RETURN 0; ELSE RETURN -9; END IF; END; $$; ALTER FUNCTION public.postcounttag(pinvcntid integer, pthaw boolean) OWNER TO admin; -- -- Name: postcounttaglocation(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postcounttaglocation(pinvcntid integer, pthaw boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _avgCostingMethod TEXT; _invhistid INTEGER; _postDate TIMESTAMP; _runningQty NUMERIC; _errorCode INTEGER; _itemlocSeries INTEGER := 0; _hasDetail BOOLEAN; _p RECORD; _itemloc RECORD; _cntslip RECORD; _origLocQty NUMERIC; _lsid INTEGER; BEGIN SELECT COALESCE(fetchMetricText('CountAvgCostMethod'), 'STD') INTO _avgCostingMethod; SELECT invcnt_id, invcnt_tagnumber, invcnt_qoh_after, invcnt_location_id, invcnt_tagdate, item_number, itemsite_id, itemsite_freeze, itemsite_qtyonhand, itemsite_loccntrl, COALESCE(invcnt_location_id, -1) AS itemsite_location_id, CASE WHEN (itemsite_costmethod = 'N') THEN 0 WHEN ( (itemsite_costmethod = 'A') AND (itemsite_qtyonhand = 0.0) AND (_avgCostingMethod = 'ACT') ) THEN actcost(itemsite_item_id) WHEN ( (itemsite_costmethod = 'A') AND (_avgCostingMethod IN ('ACT', 'AVG')) ) THEN avgcost(itemsite_id) ELSE stdcost(itemsite_item_id) END AS cost, itemsite_costmethod, itemsite_controlmethod, itemsite_value INTO _p FROM invcnt, itemsite, item WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (invcnt_qoh_after IS NOT NULL) AND (NOT invcnt_posted) AND (invcnt_id=pInvcntid) ); IF (NOT FOUND) THEN RETURN -9; END IF; SELECT COALESCE(SUM(itemloc_qty),0.0) INTO _origLocQty FROM itemloc WHERE ((itemloc_itemsite_id=_p.itemsite_id) AND (itemloc_location_id=_p.invcnt_location_id)); IF (NOT FOUND) THEN _origLocQty := 0.0; END IF; SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid; IF (_p.itemsite_freeze) THEN _postDate := _p.invcnt_tagdate; ELSE _postDate := CURRENT_TIMESTAMP; END IF; _hasDetail = FALSE; -- Post the detail indicated by cntslips IF ( (_p.itemsite_loccntrl) OR (_p.itemsite_controlmethod IN ('L', 'S')) ) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; -- Adjust any existing detail to 0 FOR _itemloc IN SELECT itemloc_id, itemloc_location_id, itemloc_ls_id, itemloc_qty FROM itemloc WHERE ((itemloc_itemsite_id=_p.itemsite_id) AND (itemloc_location_id=_p.invcnt_location_id)) LOOP _hasDetail = TRUE; -- Create the itemlocdist flushing records INSERT INTO itemlocdist ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_expiration, itemlocdist_itemsite_id, itemlocdist_invhist_id, itemlocdist_flush ) VALUES ( _itemlocSeries, 'I', _itemloc.itemloc_id, endOfTime(), _p.itemsite_id, _invhistid, TRUE ); END LOOP; -- Clear the running detail Qty _runningQty := 0; -- Adjust the detail to the cntslip indicated value FOR _cntslip IN SELECT cntslip_location_id, cntslip_lotserial, cntslip_lotserial_expiration, cntslip_lotserial_warrpurc, SUM(cntslip_qty) AS qty, itemsite_item_id FROM cntslip,invcnt,itemsite WHERE ((cntslip_cnttag_id=pInvcntid) AND (cntslip_cnttag_id=invcnt_id) AND (invcnt_itemsite_id=itemsite_id)) GROUP BY cntslip_location_id, cntslip_lotserial, cntslip_lotserial_expiration, cntslip_lotserial_warrpurc, itemsite_item_id LOOP -- Handle the LotSerial IF (LENGTH(_cntslip.cntslip_lotserial)>0) THEN SELECT ls_id INTO _lsid FROM ls WHERE ((ls_item_id=_cntslip.itemsite_item_id) AND (UPPER(ls_number)=UPPER(_cntslip.cntslip_lotserial))); IF (NOT FOUND) THEN _lsid := NEXTVAL('ls_ls_id_seq'); INSERT INTO ls VALUES (_lsid,_cntslip.itemsite_item_id,UPPER(_cntslip.cntslip_lotserial)); END IF; END IF; -- Track the running Qty _runningQty := (_runningQty + _cntslip.qty); _hasDetail = TRUE; -- Create the itemlocdist populating record INSERT INTO itemlocdist ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_itemsite_id, itemlocdist_ls_id, itemlocdist_expiration, itemlocdist_warranty, itemlocdist_qty, itemlocdist_invhist_id ) VALUES ( _itemlocSeries, 'L', _cntslip.cntslip_location_id, _p.itemsite_id, _lsid, COALESCE(_cntslip.cntslip_lotserial_expiration, endOfTime()), _cntslip.cntslip_lotserial_warrpurc, _cntslip.qty, _invhistid ); END LOOP; IF (_runningQty > _p.invcnt_qoh_after) THEN -- The total Count Slip Qty is greater than the Count Tag Qty, -- Don't post the Count. _errorCode = -1; ELSIF ( (_runningQty < _p.invcnt_qoh_after) AND (_p.itemsite_controlmethod IN ('L', 'S')) ) THEN -- The total Count Slip Qty is less than the Count Tag Qty, -- and the Item Site is Lot/Serial controlled. -- Don't post the Count. _errorCode = -2; ELSIF (_runningQty < _p.invcnt_qoh_after) THEN IF ( (NOT _p.itemsite_loccntrl) OR (_p.itemsite_location_id = -1) ) THEN -- The total Count Slip Qty is less than the Count Tag Qty, -- and there isn't a default location to post into. -- Don't post the Count. _errorCode = -3; ELSIF ( SELECT (metric_value='f') FROM metric WHERE (metric_name='PostCountTagToDefault') ) THEN -- The total Count Slip Qty is less than the Count Tag Qty, -- and we don't post Count Tags to default Locations -- Don't post the Count. _errorCode = -4; ELSE -- Distribute the remaining qty into the default location. INSERT INTO itemlocdist ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_itemsite_id, itemlocdist_ls_id, itemlocdist_expiration, itemlocdist_qty, itemlocdist_invhist_id ) SELECT _itemlocSeries, 'L', _p.itemsite_location_id, _p.itemsite_id, _lsid, endOfTime(), (_p.invcnt_qoh_after - _runningQty), _invhistid; _hasDetail = TRUE; _errorCode = 0; END IF; ELSE -- The Count Slip Qty. must equal the Count Tag Qty. _errorCode = 0; END IF; -- If we shouldn't post the count then delete the itemlocdist records, -- and return with the error. IF (_errorCode <> 0) THEN DELETE FROM itemlocdist WHERE (itemlocdist_series=_itemlocSeries); RETURN _errorCode; END IF; END IF; -- Mod. the Count Tag. UPDATE invcnt SET invcnt_qoh_before=_origLocQty, invcnt_postdate=_postDate, invcnt_posted=TRUE, invcnt_invhist_id=_invhistid, invcnt_post_username=getEffectiveXtUser() WHERE (invcnt_id=pInvcntid); -- Create the CC transaction INSERT INTO invhist ( invhist_id, invhist_itemsite_id, invhist_transdate, invhist_transtype, invhist_invqty, invhist_qoh_before, invhist_qoh_after, invhist_docnumber, invhist_comments, invhist_invuom, invhist_unitcost, invhist_hasdetail, invhist_costmethod, invhist_value_before, invhist_value_after, invhist_series ) SELECT _invhistid, itemsite_id, _postDate, 'CC', (invcnt_qoh_after - invcnt_qoh_before), invcnt_qoh_before, invcnt_qoh_after, invcnt_tagnumber, invcnt_comments, uom_name, _p.cost, _hasDetail, _p.itemsite_costmethod, _p.itemsite_value, _p.itemsite_value + (_p.cost * (invcnt_qoh_after - invcnt_qoh_before)), _itemlocSeries FROM itemsite, invcnt, item, uom WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (itemsite_controlmethod <> 'N') AND (invcnt_id=pInvcntid) ); -- Update the QOH UPDATE itemsite SET itemsite_qtyonhand= itemsite_qtyonhand + (_p.invcnt_qoh_after - _origLocQty), itemsite_datelastcount=_postDate WHERE (itemsite_id=_p.itemsite_id); UPDATE itemsite SET itemsite_value = itemsite_qtyonhand * _p.cost WHERE (itemsite_id=_p.itemsite_id); -- Post the detail, if any IF (_hasDetail) THEN PERFORM distributeItemlocSeries(_itemlocSeries); END IF; -- Thaw the itemsite if it's frozen IF (pThaw) THEN PERFORM thawItemSite(invcnt_itemsite_id) FROM invcnt WHERE (invcnt_id=pInvcntid); END IF; -- Distribute to G/L PERFORM insertGLTransaction( 'I/M', 'CT', _p.invcnt_tagnumber, ('Post Count Tag #' || _p.invcnt_tagnumber || ' for Item ' || _p.item_number), costcat_adjustment_accnt_id, costcat_asset_accnt_id, _invhistid, ( (_p.invcnt_qoh_after - _origLocQty) * _p.cost), CURRENT_DATE ) FROM invcnt, itemsite, costcat WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_costcat_id=costcat_id) AND (invcnt_id=pInvcntid) ); RETURN 0; END; $$; ALTER FUNCTION public.postcounttaglocation(pinvcntid integer, pthaw boolean) OWNER TO admin; -- -- Name: postcounttaglocation(integer, boolean, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postcounttaglocation(integer, boolean, text) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pInvcntid ALIAS FOR $1; pThaw ALIAS FOR $2; pAvgCostingMethod ALIAS FOR $3; _invhistid INTEGER; _postDate TIMESTAMP; _runningQty NUMERIC; _errorCode INTEGER; _itemlocSeries INTEGER := 0; _hasDetail BOOLEAN; _p RECORD; _itemloc RECORD; _cntslip RECORD; _origLocQty NUMERIC; _netable BOOLEAN; _lsid INTEGER; BEGIN SELECT invcnt_id, invcnt_tagnumber, invcnt_qoh_after, invcnt_location_id, invcnt_tagdate, item_number, itemsite_id, itemsite_freeze, itemsite_qtyonhand, itemsite_loccntrl, COALESCE(invcnt_location_id, -1) AS itemsite_location_id, CASE WHEN (itemsite_costmethod = 'N') THEN 0 WHEN ( (itemsite_costmethod = 'A') AND (itemsite_qtyonhand = 0) AND (pAvgCostingMethod = 'ACT') ) THEN actcost(itemsite_item_id) WHEN ( (itemsite_costmethod = 'A') AND (pAvgCostingMethod IN ('ACT', 'AVG')) ) THEN avgcost(itemsite_id) ELSE stdcost(itemsite_item_id) END AS cost, itemsite_costmethod, itemsite_controlmethod, itemsite_value INTO _p FROM invcnt, itemsite, item WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (invcnt_qoh_after IS NOT NULL) AND (NOT invcnt_posted) AND (invcnt_id=pInvcntid) ); IF (NOT FOUND) THEN RETURN -9; END IF; SELECT COALESCE(SUM(itemloc_qty),0.0), location_netable INTO _origLocQty,_netable FROM itemloc,location WHERE ((itemloc_itemsite_id=_p.itemsite_id) AND (location_id=itemloc_location_id) AND (itemloc_location_id=_p.invcnt_location_id)) GROUP BY location_netable; IF (NOT FOUND) THEN _origLocQty := 0.0; _netable := TRUE; END IF; SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid; IF (_p.itemsite_freeze) THEN _postDate := _p.invcnt_tagdate; ELSE _postDate := CURRENT_TIMESTAMP; END IF; _hasDetail = FALSE; -- Post the detail indicated by cntslips IF ( (_p.itemsite_loccntrl) OR (_p.itemsite_controlmethod IN ('L', 'S')) ) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; -- Adjust any existing detail to 0 FOR _itemloc IN SELECT itemloc_id, itemloc_location_id, itemloc_ls_id, itemloc_qty FROM itemloc WHERE ((itemloc_itemsite_id=_p.itemsite_id) AND (itemloc_location_id=_p.invcnt_location_id)) LOOP _hasDetail = TRUE; -- Create the itemlocdist flushing records INSERT INTO itemlocdist ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_expiration, itemlocdist_itemsite_id, itemlocdist_invhist_id, itemlocdist_flush ) VALUES ( _itemlocSeries, 'I', _itemloc.itemloc_id, endOfTime(), _p.itemsite_id, _invhistid, TRUE ); END LOOP; -- Clear the running detail Qty _runningQty := 0; -- Adjust the detail to the cntslip indicated value FOR _cntslip IN SELECT cntslip_location_id, cntslip_lotserial, cntslip_lotserial_expiration, cntslip_lotserial_warrpurc, SUM(cntslip_qty) AS qty, itemsite_item_id FROM cntslip,invcnt,itemsite WHERE ((cntslip_cnttag_id=pInvcntid) AND (cntslip_cnttag_id=invcnt_id) AND (invcnt_itemsite_id=itemsite_id)) GROUP BY cntslip_location_id, cntslip_lotserial, cntslip_lotserial_expiration, cntslip_lotserial_warrpurc, itemsite_item_id LOOP -- Handle the LotSerial IF (LENGTH(_cntslip.cntslip_lotserial)>0) THEN SELECT ls_id INTO _lsid FROM ls WHERE ((ls_item_id=_cntslip.itemsite_item_id) AND (UPPER(ls_number)=UPPER(_cntslip.cntslip_lotserial))); IF (NOT FOUND) THEN _lsid := NEXTVAL('ls_ls_id_seq'); INSERT INTO ls VALUES (_lsid,_cntslip.itemsite_item_id,UPPER(_cntslip.cntslip_lotserial)); END IF; END IF; -- Track the running Qty _runningQty := (_runningQty + _cntslip.qty); _hasDetail = TRUE; -- Create the itemlocdist populating record INSERT INTO itemlocdist ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_itemsite_id, itemlocdist_ls_id, itemlocdist_expiration, itemlocdist_warranty, itemlocdist_qty, itemlocdist_invhist_id ) VALUES ( _itemlocSeries, 'L', _cntslip.cntslip_location_id, _p.itemsite_id, _lsid, COALESCE(_cntslip.cntslip_lotserial_expiration, endOfTime()), _cntslip.cntslip_lotserial_warrpurc, _cntslip.qty, _invhistid ); END LOOP; IF (_runningQty > _p.invcnt_qoh_after) THEN -- The total Count Slip Qty is greater than the Count Tag Qty, -- Don't post the Count. _errorCode = -1; ELSIF ( (_runningQty < _p.invcnt_qoh_after) AND (_p.itemsite_controlmethod IN ('L', 'S')) ) THEN -- The total Count Slip Qty is less than the Count Tag Qty, -- and the Item Site is Lot/Serial controlled. -- Don't post the Count. _errorCode = -2; ELSIF (_runningQty < _p.invcnt_qoh_after) THEN IF ( (NOT _p.itemsite_loccntrl) OR (_p.itemsite_location_id = -1) ) THEN -- The total Count Slip Qty is less than the Count Tag Qty, -- and there isn't a default location to post into. -- Don't post the Count. _errorCode = -3; ELSIF ( SELECT (metric_value='f') FROM metric WHERE (metric_name='PostCountTagToDefault') ) THEN -- The total Count Slip Qty is less than the Count Tag Qty, -- and we don't post Count Tags to default Locations -- Don't post the Count. _errorCode = -4; ELSE -- Distribute the remaining qty into the default location. INSERT INTO itemlocdist ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_itemsite_id, itemlocdist_ls_id, itemlocdist_expiration, itemlocdist_qty, itemlocdist_invhist_id ) SELECT _itemlocSeries, 'L', _p.itemsite_location_id, _p.itemsite_id, _lsid, endOfTime(), (_p.invcnt_qoh_after - _runningQty), _invhistid; _hasDetail = TRUE; _errorCode = 0; END IF; ELSE -- The Count Slip Qty. must equal the Count Tag Qty. _errorCode = 0; END IF; -- If we shouldn't post the count then delete the itemlocdist records, -- and return with the error. IF (_errorCode <> 0) THEN DELETE FROM itemlocdist WHERE (itemlocdist_series=_itemlocSeries); RETURN _errorCode; END IF; END IF; -- Mod. the Count Tag. UPDATE invcnt SET invcnt_qoh_before=_origLocQty, invcnt_postdate=_postDate, invcnt_posted=TRUE, invcnt_invhist_id=_invhistid, invcnt_post_username=CURRENT_USER WHERE (invcnt_id=pInvcntid); -- Create the CC transaction INSERT INTO invhist ( invhist_id, invhist_itemsite_id, invhist_transdate, invhist_transtype, invhist_invqty, invhist_qoh_before, invhist_qoh_after, invhist_docnumber, invhist_comments, invhist_invuom, invhist_unitcost, invhist_hasdetail, invhist_costmethod, invhist_value_before, invhist_value_after, invhist_series ) SELECT _invhistid, itemsite_id, _postDate, 'CC', (invcnt_qoh_after - invcnt_qoh_before), invcnt_qoh_before, invcnt_qoh_after, invcnt_tagnumber, invcnt_comments, uom_name, _p.cost, _hasDetail, _p.itemsite_costmethod, _p.itemsite_value, _p.itemsite_value + (_p.cost * (invcnt_qoh_after - invcnt_qoh_before)), _itemlocSeries FROM itemsite, invcnt, item, uom WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (itemsite_controlmethod <> 'N') AND (invcnt_id=pInvcntid) ); -- Update the QOH IF (_netable) THEN UPDATE itemsite SET itemsite_qtyonhand= itemsite_qtyonhand + (_p.invcnt_qoh_after - _origLocQty), itemsite_datelastcount=_postDate WHERE (itemsite_id=_p.itemsite_id); ELSE UPDATE itemsite SET itemsite_nnqoh = itemsite_nnqoh - _origLocQty, itemsite_qtyonhand = itemsite_qtyonhand + _p.invcnt_qoh_after, itemsite_datelastcount=_postDate WHERE (itemsite_id=_p.itemsite_id); END IF; -- Post the detail, if any IF (_hasDetail) THEN PERFORM distributeItemlocSeries(_itemlocSeries); END IF; -- Thaw the itemsite if it's frozen IF (pThaw) THEN PERFORM thawItemSite(invcnt_itemsite_id) FROM invcnt WHERE (invcnt_id=pInvcntid); END IF; -- Distribute to G/L PERFORM insertGLTransaction( 'I/M', 'CT', _p.invcnt_tagnumber, ('Post Count Tag #' || _p.invcnt_tagnumber || ' for Item ' || _p.item_number), costcat_adjustment_accnt_id, costcat_asset_accnt_id, _invhistid, ( (_p.invcnt_qoh_after - _origLocQty) * _p.cost), CURRENT_DATE ) FROM invcnt, itemsite, costcat WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_costcat_id=costcat_id) AND (invcnt_id=pInvcntid) ); RETURN 0; END; $_$; ALTER FUNCTION public.postcounttaglocation(integer, boolean, text) OWNER TO admin; -- -- Name: postcounttags(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postcounttags(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pThaw ALIAS FOR $2; _invcnt RECORD; _result INTEGER := 0; _return INTEGER := 0; BEGIN FOR _invcnt IN SELECT invcnt_id FROM invcnt, itemsite WHERE ( (invcnt_itemsite_id=itemsite_id) AND ( (pWarehousid=-1) OR (itemsite_warehous_id=pWarehousid) ) AND (invcnt_qoh_after IS NOT NULL) AND (NOT invcnt_posted) ) LOOP SELECT postCountTag(_invcnt.invcnt_id, pThaw) INTO _result; IF (_result < _return) THEN _return := _result; END IF; END LOOP; RETURN _return; END; $_$; ALTER FUNCTION public.postcounttags(integer, boolean) OWNER TO admin; -- -- Name: postcreditmemo(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postcreditmemo(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmheadid ALIAS FOR $1; pItemlocSeries ALIAS FOR $2; _return INTEGER; BEGIN SELECT postCreditMemo(pCmheadid, fetchJournalNumber('AR-CM'), pItemlocSeries) INTO _return; RETURN _return; END; $_$; ALTER FUNCTION public.postcreditmemo(integer, integer) OWNER TO admin; -- -- Name: postcreditmemo(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postcreditmemo(integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmheadid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pItemlocSeries ALIAS FOR $3; _r RECORD; _p RECORD; _aropenid INTEGER; _cohistid INTEGER; _sequence INTEGER; _itemlocSeries INTEGER; _invhistid INTEGER; _test INTEGER; _totalAmount NUMERIC := 0; _commissionDue NUMERIC := 0; _toApply NUMERIC; _toClose BOOLEAN; _glDate DATE; _taxBaseValue NUMERIC := 0; BEGIN -- Cache some parameters SELECT cmhead.*, findARAccount(cmhead_cust_id) AS ar_accnt_id, ( SELECT COALESCE(SUM(taxhist_tax), 0) FROM cmheadtax WHERE ( (taxhist_parent_id = cmhead_id) AND (taxhist_taxtype_id = getAdjustmentTaxtypeId()) ) ) AS adjtax INTO _p FROM cmhead WHERE (cmhead_id=pCmheadid); IF (_p.cmhead_posted) THEN RETURN -10; END IF; IF (_p.cmhead_hold) THEN RETURN -11; END IF; _glDate := COALESCE(_p.cmhead_gldistdate, _p.cmhead_docdate); _itemlocSeries = pItemlocSeries; SELECT fetchGLSequence() INTO _sequence; -- Start by handling taxes FOR _r IN SELECT tax_sales_accnt_id, round(sum(taxdetail_tax),2) AS tax, currToBase(_p.cmhead_curr_id, round(sum(taxdetail_tax),2), _p.cmhead_docdate) AS taxbasevalue FROM tax JOIN calculateTaxDetailSummary('CM', pCmheadid, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id, tax_sales_accnt_id LOOP PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CM', _p.cmhead_number, _r.tax_sales_accnt_id, _r.taxbasevalue, _glDate, _p.cmhead_billtoname ); _totalAmount := _totalAmount + _r.tax * -1; END LOOP; -- Update item tax records with posting data UPDATE cmitemtax SET taxhist_docdate=_p.cmhead_docdate, taxhist_distdate=_glDate, taxhist_curr_id=_p.cmhead_curr_id, taxhist_curr_rate=curr_rate, taxhist_journalnumber=pJournalNumber FROM cmhead JOIN cmitem ON (cmhead_id=cmitem_cmhead_id), curr_rate WHERE ((cmhead_id=pCmheadId) AND (taxhist_parent_id=cmitem_id) AND (_p.cmhead_curr_id=curr_id) AND (_p.cmhead_docdate BETWEEN curr_effective AND curr_expires) ); -- Update Header taxes (Freight and Adjustments) with posting data UPDATE cmheadtax SET taxhist_docdate=_p.cmhead_docdate, taxhist_distdate=_glDate, taxhist_curr_id=_p.cmhead_curr_id, taxhist_curr_rate=curr_rate, taxhist_journalnumber=pJournalNumber FROM curr_rate WHERE ((taxhist_parent_id=pCmheadId) AND (_p.cmhead_curr_id=curr_id) AND (_p.cmhead_docdate BETWEEN curr_effective AND curr_expires) ); -- Process line items -- Always use std cost FOR _r IN SELECT *, stdCost(item_id) AS std_cost FROM creditmemoitem WHERE ( (cmitem_cmhead_id=pCmheadid) AND (cmitem_qtycredit <> 0 ) ) LOOP -- Calcuate the Commission to be debited _commissionDue := (_commissionDue + (_r.extprice * _p.cmhead_commission)); IF (_r.extprice <> 0) THEN -- Debit the Sales Account for the current cmitem SELECT insertIntoGLSeries( _sequence, 'A/R', 'CM', _p.cmhead_number, CASE WHEN _p.cmhead_rahead_id IS NULL THEN getPrjAccntId(_p.cmhead_prj_id, salesaccnt_credit_accnt_id) ELSE getPrjAccntId(_p.cmhead_prj_id, salesaccnt_returns_accnt_id) END, round(currToBase(_p.cmhead_curr_id, _r.extprice * -1, _p.cmhead_docdate), 2), _glDate, _p.cmhead_billtoname) INTO _test FROM salesaccnt WHERE (salesaccnt_id=findSalesAccnt(_r.cmitem_itemsite_id, 'IS', _p.cmhead_cust_id, _p.cmhead_saletype_id, _p.cmhead_shipzone_id)); IF (NOT FOUND) THEN PERFORM deleteGLSeries(_sequence); RETURN -12; END IF; END IF; -- Record Sales History for this C/M Item SELECT nextval('cohist_cohist_id_seq') INTO _cohistid; INSERT INTO cohist ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_curr_id, cohist_taxtype_id, cohist_taxzone_id, cohist_shipzone_id, cohist_saletype_id ) VALUES ( _cohistid, _p.cmhead_cust_id, _r.cmitem_itemsite_id, _p.cmhead_shipto_id, _p.cmhead_docdate, '', _p.cmhead_number, _p.cmhead_custponumber, _p.cmhead_docdate, 'C', _p.cmhead_invcnumber, _p.cmhead_docdate, (_r.qty * -1), _r.unitprice, _r.std_cost, _p.cmhead_salesrep_id, (_p.cmhead_commission * _r.extprice * -1), FALSE, _p.cmhead_billtoname, _p.cmhead_billtoaddress1, _p.cmhead_billtoaddress2, _p.cmhead_billtoaddress3, _p.cmhead_billtocity, _p.cmhead_billtostate, _p.cmhead_billtozip, _p.cmhead_shipto_name, _p.cmhead_shipto_address1, _p.cmhead_shipto_address2, _p.cmhead_shipto_address3, _p.cmhead_shipto_city, _p.cmhead_shipto_state, _p.cmhead_shipto_zipcode, _p.cmhead_curr_id, _r.cmitem_taxtype_id, _p.cmhead_taxzone_id, _p.cmhead_shipzone_id, _p.cmhead_saletype_id ); INSERT INTO cohisttax ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM cmitemtax WHERE (taxhist_parent_id=_r.cmitem_id); _totalAmount := _totalAmount + round(_r.extprice, 2); END LOOP; -- Credit the Misc. Account for Miscellaneous Charges IF (_p.cmhead_misc <> 0) THEN SELECT insertIntoGLSeries( _sequence, 'A/R', 'CM', _p.cmhead_number, getPrjAccntId(_p.cmhead_prj_id, accnt_id), round(currToBase(_p.cmhead_curr_id, _p.cmhead_misc * -1, _p.cmhead_docdate), 2), _glDate, _p.cmhead_billtoname) INTO _test FROM accnt WHERE (accnt_id=_p.cmhead_misc_accnt_id); -- If the Misc. Charges Account was not found then punt IF (NOT FOUND) THEN PERFORM deleteGLSeries(_sequence); RETURN -14; END IF; -- Record the Sales History for any Misc. Charge INSERT INTO cohist ( cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_misc_type, cohist_misc_descrip, cohist_misc_id, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_curr_id, cohist_shipzone_id, cohist_saletype_id ) VALUES ( _p.cmhead_cust_id, -1, _p.cmhead_shipto_id, 'M', _p.cmhead_misc_descrip, _p.cmhead_misc_accnt_id, _p.cmhead_docdate, '', _p.cmhead_number, _p.cmhead_custponumber, _p.cmhead_docdate, 'C', _p.cmhead_invcnumber, _p.cmhead_docdate, 1, (_p.cmhead_misc * -1), (_p.cmhead_misc * -1), _p.cmhead_salesrep_id, 0, FALSE, _p.cmhead_billtoname, _p.cmhead_billtoaddress1, _p.cmhead_billtoaddress2, _p.cmhead_billtoaddress3, _p.cmhead_billtocity, _p.cmhead_billtostate, _p.cmhead_billtozip, _p.cmhead_shipto_name, _p.cmhead_shipto_address1, _p.cmhead_shipto_address2, _p.cmhead_shipto_address3, _p.cmhead_shipto_city, _p.cmhead_shipto_state, _p.cmhead_shipto_zipcode, _p.cmhead_curr_id, _p.cmhead_shipzone_id, _p.cmhead_saletype_id ); -- Cache the Misc. Amount distributed _totalAmount := _totalAmount + _p.cmhead_misc; END IF; -- Credit Tax Adjustments IF (_p.adjtax <> 0) THEN -- Record the Sales History for Tax Adjustment SELECT nextval('cohist_cohist_id_seq') INTO _cohistid; INSERT INTO cohist ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_misc_type, cohist_misc_descrip, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_curr_id, cohist_taxtype_id, cohist_taxzone_id, cohist_shipzone_id, cohist_saletype_id ) VALUES ( _cohistid, _p.cmhead_cust_id, -1, _p.cmhead_shipto_id, 'T', 'Misc Tax Adjustment', _p.cmhead_docdate, '', _p.cmhead_number, _p.cmhead_custponumber, _p.cmhead_docdate, 'C', _p.cmhead_invcnumber, _p.cmhead_docdate, 0, 0, 0, _p.cmhead_salesrep_id, 0, FALSE, _p.cmhead_billtoname, _p.cmhead_billtoaddress1, _p.cmhead_billtoaddress2, _p.cmhead_billtoaddress3, _p.cmhead_billtocity, _p.cmhead_billtostate, _p.cmhead_billtozip, _p.cmhead_shipto_name, _p.cmhead_shipto_address1, _p.cmhead_shipto_address2, _p.cmhead_shipto_address3, _p.cmhead_shipto_city, _p.cmhead_shipto_state, _p.cmhead_shipto_zipcode, _p.cmhead_curr_id, getAdjustmentTaxtypeId(), _p.cmhead_taxzone_id, _p.cmhead_shipzone_id, _p.cmhead_saletype_id ); INSERT INTO cohisttax ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id, (taxhist_basis * -1), taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM cmheadtax WHERE ( (taxhist_parent_id=_p.cmhead_id) AND (taxhist_taxtype_id=getAdjustmentTaxtypeId()) ); END IF; -- Debit the Freight Account IF (_p.cmhead_freight <> 0) THEN SELECT insertIntoGLSeries( _sequence, 'A/R', 'CM', _p.cmhead_number, getPrjAccntId(_p.cmhead_prj_id, accnt_id), round(currToBase(_p.cmhead_curr_id, _p.cmhead_freight * -1, _p.cmhead_docdate), 2), _glDate, _p.cmhead_billtoname) INTO _test FROM accnt WHERE (accnt_id=findFreightAccount(_p.cmhead_cust_id)); -- If the Freight Charges Account was not found then punt IF (NOT FOUND) THEN PERFORM deleteGLSeries(_sequence); RETURN -16; END IF; -- Cache the Amount Distributed to Freight _totalAmount := _totalAmount + _p.cmhead_freight; -- Record the Sales History for any Freight SELECT nextval('cohist_cohist_id_seq') INTO _cohistid; INSERT INTO cohist ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_misc_type, cohist_misc_descrip, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_curr_id, cohist_taxtype_id, cohist_taxzone_id, cohist_shipzone_id, cohist_saletype_id ) VALUES ( _cohistid, _p.cmhead_cust_id, -1, _p.cmhead_shipto_id, 'F', 'Freight Charge', _p.cmhead_docdate, '', _p.cmhead_number, _p.cmhead_custponumber, _p.cmhead_docdate, 'C', _p.cmhead_invcnumber, _p.cmhead_docdate, 1, (_p.cmhead_freight * -1), (_p.cmhead_freight * -1), _p.cmhead_salesrep_id, 0, FALSE, _p.cmhead_billtoname, _p.cmhead_billtoaddress1, _p.cmhead_billtoaddress2, _p.cmhead_billtoaddress3, _p.cmhead_billtocity, _p.cmhead_billtostate, _p.cmhead_billtozip, _p.cmhead_shipto_name, _p.cmhead_shipto_address1, _p.cmhead_shipto_address2, _p.cmhead_shipto_address3, _p.cmhead_shipto_city, _p.cmhead_shipto_state, _p.cmhead_shipto_zipcode, _p.cmhead_curr_id, getFreightTaxtypeId(), _p.cmhead_taxzone_id, _p.cmhead_shipzone_id, _p.cmhead_saletype_id ); INSERT INTO cohisttax ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id, (taxhist_basis * -1), taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM cmheadtax WHERE ( (taxhist_parent_id=_p.cmhead_id) AND (taxhist_taxtype_id=getFreightTaxtypeId()) ); END IF; _totalAmount := _totalAmount; -- Credit the A/R for the total Amount IF (_totalAmount <> 0) THEN IF (_p.ar_accnt_id != -1) THEN PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CM', _p.cmhead_number, _p.ar_accnt_id, round(currToBase(_p.cmhead_curr_id, _totalAmount, _p.cmhead_docdate), 2), _glDate, _p.cmhead_billtoname); ELSE PERFORM deleteGLSeries(_sequence); RETURN -18; END IF; END IF; -- Commit the GLSeries; PERFORM postGLSeries(_sequence, pJournalNumber); -- Create the Invoice aropen item SELECT NEXTVAL('aropen_aropen_id_seq') INTO _aropenid; INSERT INTO aropen ( aropen_id, aropen_username, aropen_journalnumber, aropen_open, aropen_posted, aropen_cust_id, aropen_ponumber, aropen_docnumber, aropen_applyto, aropen_doctype, aropen_docdate, aropen_duedate, aropen_distdate, aropen_terms_id, aropen_amount, aropen_paid, aropen_salesrep_id, aropen_commission_due, aropen_commission_paid, aropen_ordernumber, aropen_notes, aropen_rsncode_id, aropen_curr_id ) SELECT _aropenid, getEffectiveXtUser(), pJournalNumber, TRUE, FALSE, cmhead_cust_id, cmhead_custponumber, cmhead_number, CASE WHEN (cmhead_invcnumber='-1') THEN 'OPEN' ELSE (cmhead_invcnumber::TEXT) END, 'C', cmhead_docdate, cmhead_docdate, _glDate, -1, _totalAmount, 0, cmhead_salesrep_id, (_commissionDue * -1), FALSE, cmhead_number::TEXT, cmhead_comments, cmhead_rsncode_id, cmhead_curr_id FROM cmhead WHERE (cmhead_id=pCmheadid); -- Handle the Inventory and G/L Transactions for any returned Inventory where cmitem_updateinv is true FOR _r IN SELECT itemsite_id, itemsite_costmethod, item_number, stdCost(item_id) AS std_cost, costcat_asset_accnt_id, SUM(cmitem_qtyreturned * cmitem_qty_invuomratio) AS qty FROM cmhead JOIN cmitem ON (cmitem_cmhead_id=cmhead_id) JOIN itemsite ON (itemsite_id=cmitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) JOIN costcat ON (costcat_id=itemsite_costcat_id) WHERE ( (cmitem_qtyreturned <> 0) AND (cmitem_updateinv) AND (cmhead_id=pCmheadid) ) GROUP BY itemsite_id, itemsite_costmethod, item_number, item_id, costcat_asset_accnt_id LOOP -- Return credited stock to inventory IF (_itemlocSeries = 0) THEN _itemlocSeries := NEXTVAL('itemloc_series_seq'); END IF; IF (_r.itemsite_costmethod != 'J') THEN SELECT postInvTrans(_r.itemsite_id, 'RS', _r.qty, 'S/O', 'CM', _p.cmhead_number, '', ('Credit Return ' || _r.item_number), _r.costcat_asset_accnt_id, getPrjAccntId(_p.cmhead_prj_id, resolveCOSAccount(_r.itemsite_id, _p.cmhead_cust_id, _p.cmhead_saletype_id, _p.cmhead_shipzone_id)), _itemlocSeries, _glDate, (_r.std_cost * _r.qty)) INTO _invhistid; ELSE RAISE DEBUG 'postCreditMemo(%, %, %) tried to postInvTrans a %-costed item', pCmheadid, pJournalNumber, pItemlocSeries, _r.itemsite_costmethod; END IF; END LOOP; -- Update coitem to reflect the returned qty where cmitem_updateinv is true FOR _r IN SELECT cmitem_qtyreturned, cmitem_itemsite_id, cohead_id FROM cmitem, cmhead, invchead, cohead WHERE ( (cmitem_cmhead_id=cmhead_id) AND (cmhead_invcnumber=invchead_invcnumber) AND (invchead_ordernumber=cohead_number) AND (cmitem_qtyreturned <> 0) AND (cmitem_updateinv) AND (cmhead_id=pCmheadid) ) LOOP UPDATE coitem SET coitem_qtyreturned = (coitem_qtyreturned + _r.cmitem_qtyreturned) WHERE coitem_id IN ( SELECT coitem_id FROM coitem WHERE ( (coitem_cohead_id=_r.cohead_id) AND (coitem_itemsite_id = _r.cmitem_itemsite_id) ) LIMIT 1 ); END LOOP; -- Mark the cmhead as posted UPDATE cmhead SET cmhead_posted=TRUE, cmhead_gldistdate=_glDate WHERE (cmhead_id=pCmheadid); -- Find the apply-to document and make the application SELECT cmhead_number, cmhead_curr_id, cmhead_docdate, aropen_id, aropen_cust_id, aropen_docnumber, currToCurr(aropen_curr_id, cmhead_curr_id, aropen_amount - aropen_paid, cmhead_docdate) AS balance INTO _p FROM aropen, cmhead WHERE ( (aropen_doctype='I') AND (aropen_docnumber=cmhead_invcnumber) AND (cmhead_id=pCmheadid) ); IF (FOUND) THEN IF round(_totalAmount, 2) <= round(_p.balance, 2) THEN _toApply = _totalAmount; ELSE _toApply = _p.balance; END IF; UPDATE aropen SET aropen_paid = round(aropen_paid + currToCurr(_p.cmhead_curr_id, aropen_curr_id, _toApply, _p.cmhead_docdate), 2) WHERE (aropen_id=_p.aropen_id); -- Alter the new A/R Open Item to reflect the application UPDATE aropen SET aropen_paid = round(currToCurr(_p.cmhead_curr_id, aropen_curr_id, _toApply, _p.cmhead_docdate), 2) WHERE (aropen_id=_aropenid); -- Record the application INSERT INTO arapply ( arapply_cust_id, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_applied, arapply_closed, arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_curr_id ) VALUES ( _p.aropen_cust_id, _aropenid, 'C', _p.cmhead_number, _p.aropen_id, 'I', _p.aropen_docnumber, '', '', round(_toApply, 2), _toClose, CURRENT_DATE, _p.cmhead_docdate, 0, _p.cmhead_curr_id ); END IF; RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.postcreditmemo(integer, integer, integer) OWNER TO admin; -- -- Name: postcreditmemos(boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postcreditmemos(boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPostUnprinted ALIAS FOR $1; _cmhead RECORD; _result INTEGER; _return INTEGER := 0; _itemlocSeries INTEGER := 0; BEGIN _itemlocSeries := 0; FOR _cmhead IN SELECT cmhead_id FROM cmhead WHERE ( (NOT cmhead_posted) AND (NOT cmhead_hold) AND (checkCreditMemoSitePrivs(cmhead_id)) AND ((pPostUnprinted) OR (cmhead_printed)) ) LOOP SELECT postCreditMemo(_cmhead.cmhead_id, _itemlocSeries) INTO _result; IF (_result < _return) THEN _return := _result; END IF; END LOOP; RETURN _return; END; $_$; ALTER FUNCTION public.postcreditmemos(boolean) OWNER TO admin; -- -- Name: postcreditmemos(boolean, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postcreditmemos(boolean, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPostUnprinted ALIAS FOR $1; pJournalNumber ALIAS FOR $2; _r RECORD; _itemlocSeries INTEGER := 0; BEGIN _itemlocSeries := 0; FOR _r IN SELECT cmhead_id FROM cmhead WHERE ( (NOT cmhead_posted) AND (NOT cmhead_hold) AND (checkCreditMemoSitePrivs(cmhead_id)) AND ((pPostUnprinted) OR (cmhead_printed)) ) LOOP SELECT postCreditMemo(_r.cmhead_id, pJournalNumber, _itemlocSeries) INTO _itemlocSeries; END LOOP; RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.postcreditmemos(boolean, integer) OWNER TO admin; -- -- Name: postevent(text, text, integer, integer, text, numeric, numeric, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postevent(pevnttypename text, pordtype text, pordid integer, pwhsid integer, pnumber text, pnewvalue numeric, poldvalue numeric, pnewdate date, polddate date) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _evnttypeid INTEGER; _whsid INTEGER; BEGIN -- Find event type SELECT evnttype_id INTO _evnttypeid FROM evnttype WHERE (evnttype_name=pEvnttypename); IF (NOT FOUND) THEN RAISE EXCEPTION 'Event type % not found.', pEvnttypename; END IF; IF (pWhsid IS NULL) THEN -- Find user preferred warehouse SELECT usrpref_value INTO _whsid FROM usrpref WHERE usrpref_username = getEffectiveXtUser() AND usrpref_name = 'PreferredWarehouse'; ELSE _whsid := pWhsid; END IF; INSERT INTO evntlog ( evntlog_evnttime, evntlog_evnttype_id, evntlog_ordtype, evntlog_ord_id, evntlog_warehous_id, evntlog_number, evntlog_newvalue, evntlog_oldvalue, evntlog_newdate, evntlog_olddate, evntlog_username ) SELECT CURRENT_TIMESTAMP, evnttype_id, pOrdtype, pOrdid, _whsid, pNumber, pNewValue, pOldValue, pNewDate, pOldDate, evntnot_username FROM evnttype JOIN evntnot ON ( (evntnot_evnttype_id=evnttype_id) AND (evntnot_warehous_id=_whsid) ) WHERE (evnttype_id=_evnttypeid); RETURN 0; END $$; ALTER FUNCTION public.postevent(pevnttypename text, pordtype text, pordid integer, pwhsid integer, pnumber text, pnewvalue numeric, poldvalue numeric, pnewdate date, polddate date) OWNER TO admin; -- -- Name: postglseries(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postglseries(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; _journalNumber INTEGER; _returnValue INTEGER; BEGIN SELECT postGLSeries(pSequence, fetchJournalNumber('G/L')) INTO _returnValue; RETURN _returnValue; END; $_$; ALTER FUNCTION public.postglseries(integer) OWNER TO admin; -- -- Name: postglseries(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postglseries(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; pJournalNumber ALIAS FOR $2; _returnValue INTEGER; BEGIN SELECT postGLSeries(pSequence, pJournalNumber, true) INTO _returnValue; RETURN _returnValue; END; $_$; ALTER FUNCTION public.postglseries(integer, integer) OWNER TO admin; -- -- Name: postglseries(integer, integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postglseries(integer, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pPostZero ALIAS FOR $3; _glseries RECORD; _transCount INTEGER := 0; _delta NUMERIC; _discrepDate DATE; _discrepAccntid INTEGER; _rows INTEGER; BEGIN /* Make sure we don't create an imbalance across companies. The 'IgnoreCompanyBalance' metric is a back door mechanism to allow legacy users to create transactions accross companies if they have been using the company segment for something else and they MUST continue to be able to do so. It can only be implemented by direct sql update to the metric table and should otherwise be discouraged. */ IF (COALESCE(fetchMetricValue('GLCompanySize'),0) > 0 AND fetchMetricBool('IgnoreCompany') = false) THEN SELECT count(accnt_company) INTO _rows FROM ( SELECT DISTINCT accnt_company FROM accnt JOIN glseries ON (glseries_accnt_id=accnt_id) WHERE (glseries_sequence=pSequence)) _data; IF (_rows > 1) THEN RAISE EXCEPTION 'G/L Series can not be posted because multiple companies are referenced in the same series.'; END IF; END IF; -- Make sure that we balance SELECT SUM(glseries_amount), MAX(glseries_distdate) INTO _delta, _discrepDate FROM glseries WHERE (glseries_sequence=pSequence); IF ( _delta <> 0 ) THEN IF (COALESCE(fetchMetricValue('GLCompanySize'),0) = 0) THEN SELECT accnt_id INTO _discrepAccntid FROM accnt, metric WHERE ((metric_name='GLSeriesDiscrepancyAccount') AND (accnt_id=CAST(metric_value AS INTEGER))); ELSE SELECT company_dscrp_accnt_id INTO _discrepAccntid FROM company JOIN accnt ON (accnt_company=company_number) JOIN glseries ON (glseries_accnt_id=accnt_id) WHERE (glseries_sequence=pSequence) LIMIT 1; END IF; IF (NOT FOUND) THEN RETURN -5; END IF; INSERT INTO glseries ( glseries_sequence, glseries_source, glseries_doctype, glseries_docnumber, glseries_accnt_id, glseries_amount, glseries_distdate, glseries_notes ) SELECT glseries_sequence, glseries_source, glseries_doctype, glseries_docnumber, _discrepAccntid, (_delta * -1), _discrepDate, 'G/L Series Discrepancy' FROM glseries WHERE (glseries_sequence=pSequence) LIMIT 1; END IF; -- March through the glseries members, posting them one at a time FOR _glseries IN SELECT glseries_source, glseries_doctype, glseries_docnumber, glseries_accnt_id, glseries_distdate, glseries_notes, glseries_misc_id, SUM(glseries_amount) as amount FROM glseries WHERE ((glseries_amount<>0.0) AND (glseries_sequence=pSequence)) GROUP BY glseries_source, glseries_doctype, glseries_docnumber, glseries_accnt_id, glseries_distdate, glseries_notes, glseries_misc_id LOOP -- refuse to accept postings into closed periods IF (SELECT BOOL_AND(COALESCE(period_closed, FALSE)) FROM accnt LEFT OUTER JOIN period ON (_glseries.glseries_distdate BETWEEN period_start AND period_end) WHERE (accnt_id = _glseries.glseries_accnt_id)) THEN RAISE EXCEPTION 'Cannot post to closed period (%).', _glseries.glseries_distdate; RETURN -4; -- remove raise exception when all callers check return code END IF; -- refuse to accept postings into frozen periods without proper priv IF (SELECT NOT BOOL_AND(checkPrivilege('PostFrozenPeriod')) AND BOOL_AND(COALESCE(period_freeze, FALSE)) FROM accnt LEFT OUTER JOIN period ON (_glseries.glseries_distdate BETWEEN period_start AND period_end) WHERE (accnt_id = _glseries.glseries_accnt_id)) THEN RAISE EXCEPTION 'Cannot post to frozen period (%).', _glseries.glseries_distdate; RETURN -4; -- remove raise exception when all callers check return code END IF; -- refuse to accept postings into nonexistent periods IF NOT EXISTS(SELECT period_id FROM period WHERE (_glseries.glseries_distdate BETWEEN period_start AND period_end)) THEN RAISE EXCEPTION 'Cannot post to nonexistent period (%).', pDistDate; END IF; IF (_glseries.amount != 0 OR pPostZero) THEN IF (fetchMetricBool('UseJournals')) THEN INSERT INTO sltrans ( sltrans_posted, sltrans_created, sltrans_date, sltrans_misc_id, sltrans_sequence, sltrans_accnt_id, sltrans_source, sltrans_notes, sltrans_doctype, sltrans_docnumber, sltrans_amount, sltrans_journalnumber ) VALUES ( FALSE, CURRENT_TIMESTAMP, _glseries.glseries_distdate, _glseries.glseries_misc_id, pSequence, _glseries.glseries_accnt_id, _glseries.glseries_source, _glseries.glseries_notes, _glseries.glseries_doctype, _glseries.glseries_docnumber, _glseries.amount, pJournalNumber ); ELSE INSERT INTO gltrans ( gltrans_posted, gltrans_exported, gltrans_created, gltrans_date, gltrans_misc_id, gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_notes, gltrans_doctype, gltrans_docnumber, gltrans_amount, gltrans_journalnumber ) VALUES ( FALSE, FALSE, CURRENT_TIMESTAMP, _glseries.glseries_distdate, _glseries.glseries_misc_id, pSequence, _glseries.glseries_accnt_id, _glseries.glseries_source, _glseries.glseries_notes, _glseries.glseries_doctype, _glseries.glseries_docnumber, _glseries.amount, pJournalNumber ); END IF; _transCount := _transCount + 1; END IF; END LOOP; -- Delete all of the posted glseries members DELETE FROM glseries WHERE (glseries_sequence=pSequence); PERFORM postIntoTrialBalance(pSequence); RETURN _transCount; END; $_$; ALTER FUNCTION public.postglseries(integer, integer, boolean) OWNER TO admin; -- -- Name: postglseriesnosumm(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postglseriesnosumm(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; _journalNumber INTEGER; _returnValue INTEGER; BEGIN SELECT postGLSeriesNoSumm(pSequence, fetchJournalNumber('G/L')) INTO _returnValue; RETURN _returnValue; END; $_$; ALTER FUNCTION public.postglseriesnosumm(integer) OWNER TO admin; -- -- Name: postglseriesnosumm(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postglseriesnosumm(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; pJournalNumber ALIAS FOR $2; _glseries RECORD; _transCount INTEGER := 0; _rows INTEGER; BEGIN /* Make sure we don't create an imbalance across companies. The 'IgnoreCompanyBalance' metric is a back door mechanism to allow legacy users to create transactions accross companies if they have been using the company segment for something else and they MUST continue to be able to do so. It can only be implemented by direct sql update to the metric table and should otherwise be discouraged. */ IF (COALESCE(fetchMetricValue('GLCompanySize'),0) > 0 AND fetchMetricBool('IgnoreCompany') = false) THEN SELECT count(accnt_company) INTO _rows FROM ( SELECT DISTINCT accnt_company FROM accnt JOIN glseries ON (glseries_accnt_id=accnt_id) WHERE (glseries_sequence=pSequence)) _data; IF (_rows > 1) THEN RAISE EXCEPTION 'G/L Series can not be posted because multiple companies are referenced in the same series.'; END IF; END IF; -- Make sure that we balance IF ( ( SELECT SUM(glseries_amount) FROM glseries WHERE (glseries_sequence=pSequence) ) <> 0 ) THEN RETURN -1; END IF; -- March through the glseries members, posting them one at a time FOR _glseries IN SELECT glseries_source, glseries_doctype, glseries_docnumber, glseries_accnt_id, glseries_distdate, glseries_notes, glseries_misc_id, glseries_amount as amount FROM glseries WHERE ((glseries_amount<>0.0) AND (glseries_sequence=pSequence)) LOOP -- refuse to accept postings into closed periods IF (SELECT BOOL_AND(COALESCE(period_closed, FALSE)) FROM accnt LEFT OUTER JOIN period ON (_glseries.glseries_distdate BETWEEN period_start AND period_end) WHERE (accnt_id = _glseries.glseries_accnt_id)) THEN RAISE EXCEPTION 'Cannot post to closed period (%).', _glseries.glseries_distdate; RETURN -4; -- remove raise exception when all callers check return code END IF; -- refuse to accept postings into frozen periods without proper priv IF (SELECT NOT BOOL_AND(checkPrivilege('PostFrozenPeriod')) AND BOOL_AND(COALESCE(period_freeze, FALSE)) FROM accnt LEFT OUTER JOIN period ON (_glseries.glseries_distdate BETWEEN period_start AND period_end) WHERE (accnt_id = _glseries.glseries_accnt_id)) THEN RAISE EXCEPTION 'Cannot post to frozen period (%).', _glseries.glseries_distdate; RETURN -4; -- remove raise exception when all callers check return code END IF; -- refuse to accept postings into nonexistent periods IF NOT EXISTS(SELECT period_id FROM period WHERE (_glseries.glseries_distdate BETWEEN period_start AND period_end)) THEN RAISE EXCEPTION 'Cannot post to nonexistent period (%).', pDistDate; END IF; IF (fetchMetricBool('UseJournals')) THEN INSERT INTO sltrans ( sltrans_posted, sltrans_created, sltrans_date, sltrans_misc_id, sltrans_sequence, sltrans_accnt_id, sltrans_source, sltrans_notes, sltrans_doctype, sltrans_docnumber, sltrans_amount, sltrans_journalnumber ) VALUES ( FALSE, CURRENT_TIMESTAMP, _glseries.glseries_distdate, _glseries.glseries_misc_id, pSequence, _glseries.glseries_accnt_id, _glseries.glseries_source, _glseries.glseries_notes, _glseries.glseries_doctype, _glseries.glseries_docnumber, _glseries.amount, pJournalNumber ); ELSE INSERT INTO gltrans ( gltrans_posted, gltrans_exported, gltrans_created, gltrans_date, gltrans_misc_id, gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_notes, gltrans_doctype, gltrans_docnumber, gltrans_amount, gltrans_journalnumber ) VALUES ( FALSE, FALSE, CURRENT_TIMESTAMP, _glseries.glseries_distdate, _glseries.glseries_misc_id, pSequence, _glseries.glseries_accnt_id, _glseries.glseries_source, _glseries.glseries_notes, _glseries.glseries_doctype, _glseries.glseries_docnumber, _glseries.amount, pJournalNumber ); END IF; _transCount := _transCount + 1; END LOOP; -- Delete all of the posted glseries members DELETE FROM glseries WHERE (glseries_sequence=pSequence); PERFORM postIntoTrialBalance(pSequence); RETURN _transCount; END; $_$; ALTER FUNCTION public.postglseriesnosumm(integer, integer) OWNER TO admin; -- -- Name: postintoinvbalance(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postintoinvbalance(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvhistId ALIAS FOR $1; _invbalid INTEGER; _r RECORD; _count INTEGER; _qty NUMERIC; BEGIN -- Grab the invhist record to post -- Special fix for transit sites when transtype=TS and invqty<0 -- Set the sense to 1 to correct invhist populated incorrectly. SELECT invhist.*, CASE WHEN (invhist_transtype='TS' AND invhist_invqty < 0.0 AND warehous_transit) THEN 1 ELSE invhistSense(invhist_id) END AS sense, period_id INTO _r FROM invhist JOIN itemsite ON (itemsite_id=invhist_itemsite_id) JOIN whsinfo ON (warehous_id=itemsite_warehous_id) LEFT OUTER JOIN period ON (invhist_transdate::date BETWEEN period_start AND period_end) WHERE ( invhist_id=pInvhistId ); GET DIAGNOSTICS _count = ROW_COUNT; -- If we can post into a Inv Balance, do so IF ( _count > 0 ) THEN -- Validate IF (_r.period_id IS NULL) THEN RAISE EXCEPTION 'No accounting period exists for invhist_id %, transaction date %. Transaction can not be posted.', _r.invhist_id, formatDate(_r.invhist_transdate); END IF; -- If cycle count, then we need to reference balance which needs to be accurate -- IF (_r.invhist_transtype = 'CC') THEN -- PERFORM forwardupdateitemsite(_r.invhist_itemsite_id); -- END IF; -- Try to find an existing invbal SELECT invbal_id, -- CASE WHEN (_r.invhist_transtype != 'CC') THEN _r.invhist_invqty ELSE _r.invhist_invqty - invbal_qoh_ending END _r.invhist_invqty INTO _invbalid, _qty FROM invbal WHERE ( (invbal_period_id=_r.period_id) AND (invbal_itemsite_id=_r.invhist_itemsite_id) ); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count > 0) THEN -- We found a invbal, update it with the Inventory Transaction -- Note - two stage update to avoid any funny value caching logic IF (_r.sense * _qty > 0) THEN UPDATE invbal SET invbal_qty_in = (invbal_qty_in + abs(_qty)), invbal_value_in = (invbal_value_in + abs(_qty) * _r.invhist_unitcost) WHERE (invbal_id=_invbalid); ELSIF (_r.sense * _qty < 0) THEN UPDATE invbal SET invbal_qty_out = (invbal_qty_out + abs(_qty)), invbal_value_out = (invbal_value_out + abs(_qty) * _r.invhist_unitcost) WHERE (invbal_id=_invbalid); END IF; -- Non-netable transactions have their own balances IF (_r.invhist_transtype = 'NN') THEN UPDATE invbal SET invbal_nn_in = (invbal_nn_in + _qty * -1), invbal_nnval_in = (invbal_nnval_in + _qty * -1 * _r.invhist_unitcost) WHERE (invbal_id=_invbalid); END IF; UPDATE invbal SET invbal_qoh_ending = (invbal_qoh_beginning + invbal_qty_in - invbal_qty_out), invbal_value_ending = (invbal_value_beginning + invbal_value_in - invbal_value_out), invbal_nn_ending = (invbal_nn_beginning + invbal_nn_in - invbal_nn_out), invbal_nnval_ending = (invbal_nnval_beginning + invbal_nnval_in - invbal_nnval_out), invbal_dirty=true WHERE (invbal_id=_invbalid); ELSE -- No existing invbal, make one SELECT NEXTVAL('invbal_invbal_id_seq') INTO _invbalid; INSERT INTO invbal ( invbal_id, invbal_itemsite_id, invbal_period_id, invbal_qoh_beginning, invbal_qoh_ending, invbal_qty_in, invbal_qty_out, invbal_value_beginning, invbal_value_ending, invbal_value_in, invbal_value_out, invbal_nn_beginning, invbal_nn_ending, invbal_nn_in, invbal_nn_out, invbal_nnval_beginning, invbal_nnval_ending, invbal_nnval_in, invbal_nnval_out, invbal_dirty ) VALUES ( _invbalid, _r.invhist_itemsite_id, _r.period_id, -- Netable 0, _r.invhist_invqty * _r.sense, CASE WHEN (_r.sense > 0) THEN _r.invhist_invqty ELSE 0 END, CASE WHEN (_r.sense < 0) THEN (_r.invhist_invqty) ELSE 0 END, 0, _r.invhist_invqty * _r.invhist_unitcost * _r.sense, CASE WHEN (_r.sense > 0) THEN _r.invhist_invqty * _r.invhist_unitcost ELSE 0 END, CASE WHEN (_r.sense < 0) THEN (_r.invhist_invqty * _r.invhist_unitcost) ELSE 0 END, -- Non netable 0, CASE WHEN (_r.invhist_transtype='NN') THEN _r.invhist_invqty * -1 ELSE 0 END, CASE WHEN (_r.sense > 0 AND _r.invhist_transtype='NN') THEN _r.invhist_invqty * -1 ELSE 0 END, CASE WHEN (_r.sense < 0 AND _r.invhist_transtype='NN') THEN _r.invhist_invqty * -1 ELSE 0 END, 0, CASE WHEN (_r.invhist_transtype='NN') THEN _r.invhist_invqty * _r.invhist_unitcost * -1 ELSE 0 END, CASE WHEN (_r.sense > 0 AND _r.invhist_transtype='NN') THEN _r.invhist_invqty * -1 * _r.invhist_unitcost ELSE 0 END, CASE WHEN (_r.sense < 0 AND _r.invhist_transtype='NN') THEN (_r.invhist_invqty * -1 * _r.invhist_unitcost) ELSE 0 END, true ); END IF; ELSE RETURN FALSE; END IF; RETURN TRUE; END; $_$; ALTER FUNCTION public.postintoinvbalance(integer) OWNER TO admin; -- -- Name: postintotrialbalance(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postintotrialbalance(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; _trialbalid INTEGER; _r RECORD; BEGIN -- March through all of the G/L Transactions for the passed sequence that are not posted FOR _r IN SELECT gltrans_id, gltrans_date, gltrans_accnt_id, gltrans_amount, accnt_forwardupdate, period_id, period_closed, period_freeze FROM accnt, gltrans LEFT OUTER JOIN period ON (gltrans_date BETWEEN period_start AND period_end) WHERE ( (gltrans_accnt_id=accnt_id) AND (NOT gltrans_posted) AND (NOT gltrans_deleted) AND (gltrans_sequence=pSequence) ) LOOP -- If we can post into a Trial Balance, do so IF ( (NOT _r.period_closed) AND ( (NOT _r.period_freeze) OR (checkPrivilege('PostFrozenPeriod')) ) ) THEN -- Try to find an existing trialbal SELECT trialbal_id INTO _trialbalid FROM trialbal WHERE ( (trialbal_period_id=_r.period_id) AND (trialbal_accnt_id=_r.gltrans_accnt_id) ); IF (FOUND) THEN -- We found a trialbal, update it with the G/L Transaction -- Note - two stage update to avoid any funny value caching logic IF (_r.gltrans_amount > 0) THEN UPDATE trialbal SET trialbal_credits = (trialbal_credits + _r.gltrans_amount) WHERE (trialbal_id=_trialbalid); ELSE UPDATE trialbal SET trialbal_debits = (trialbal_debits + (_r.gltrans_amount * -1)) WHERE (trialbal_id=_trialbalid); END IF; UPDATE trialbal SET trialbal_ending = (trialbal_beginning - trialbal_debits + trialbal_credits), trialbal_dirty=TRUE WHERE (trialbal_id=_trialbalid); ELSE -- No existing trialbal, make one SELECT NEXTVAL('trialbal_trialbal_id_seq') INTO _trialbalid; INSERT INTO trialbal ( trialbal_id, trialbal_accnt_id, trialbal_period_id, trialbal_beginning, trialbal_dirty, trialbal_ending, trialbal_credits, trialbal_debits ) VALUES ( _trialbalid, _r.gltrans_accnt_id, _r.period_id, 0, TRUE, _r.gltrans_amount, CASE WHEN (_r.gltrans_amount > 0) THEN _r.gltrans_amount ELSE 0 END, CASE WHEN (_r.gltrans_amount < 0) THEN (_r.gltrans_amount * -1) ELSE 0 END ); END IF; -- Forward update if we should IF (_r.accnt_forwardupdate AND fetchmetricbool('ManualForwardUpdate')) THEN PERFORM forwardUpdateTrialBalance(_trialbalid); END IF; -- Mark the G/L Transaction as posted UPDATE gltrans SET gltrans_posted=TRUE WHERE (gltrans_id=_r.gltrans_id); END IF; END LOOP; RETURN 1; END; $_$; ALTER FUNCTION public.postintotrialbalance(integer) OWNER TO admin; -- -- Name: postinvhist(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postinvhist(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvhistId ALIAS FOR $1; _r RECORD; BEGIN IF ( SELECT metric_value FROM metric WHERE ((metric_name = 'EnableAsOfQOH') AND (metric_value = 't'))) THEN IF (NOT postIntoInvBalance(pInvhistId)) THEN RAISE EXCEPTION 'Post into Inventory Balance for invhist_id=% was unsuccessful',pInvhistId; END IF; END IF; --Update itemsite qoh and change posted flag UPDATE itemsite SET itemsite_qtyonhand = (itemsite_qtyonhand + (invhist_invqty * invhistSense(invhist_id))), itemsite_value = itemsite_value + invhist_value_after - invhist_value_before FROM invhist WHERE ( (itemsite_id=invhist_itemsite_id) AND (invhist_id=pInvhistId) AND (NOT invhist_posted) ); --Flag as posted UPDATE invhist SET invhist_posted=TRUE WHERE ( (invhist_id=pInvhistId) AND (invhist_posted=FALSE) ); RETURN TRUE; END; $_$; ALTER FUNCTION public.postinvhist(integer) OWNER TO admin; -- -- Name: postinvoice(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postinvoice(pinvcheadid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN postInvoice(pInvcheadid, fetchJournalNumber('AR-IN')); END; $$; ALTER FUNCTION public.postinvoice(pinvcheadid integer) OWNER TO admin; -- -- Name: postinvoice(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postinvoice(pinvcheadid integer, pjournalnumber integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _itemlocSeries INTEGER; BEGIN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; RETURN postInvoice(pInvcheadid, pJournalNumber, _itemlocseries); END; $$; ALTER FUNCTION public.postinvoice(pinvcheadid integer, pjournalnumber integer) OWNER TO admin; -- -- Name: postinvoice(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postinvoice(pinvcheadid integer, pjournalnumber integer, pitemlocseries integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _aropenid INTEGER; _cohistid INTEGER; _itemlocSeries INTEGER := 0; _invhistid INTEGER := 0; _amount NUMERIC; _roundedBase NUMERIC; _sequence INTEGER; _r RECORD; _p RECORD; _test INTEGER; _totalAmount NUMERIC := 0; _totalRoundedBase NUMERIC := 0; _totalAmountBase NUMERIC := 0; _appliedAmount NUMERIC := 0; _commissionDue NUMERIC := 0; _tmpAccntId INTEGER; _tmpCurrId INTEGER; _firstExchDate DATE; _glDate DATE; _exchGain NUMERIC := 0; BEGIN IF ( ( SELECT invchead_posted FROM invchead WHERE (invchead_id=pInvcheadid) ) ) THEN RETURN -10; END IF; -- Cache some parameters SELECT invchead.*, fetchGLSequence() AS sequence, findFreightAccount(invchead_cust_id) AS freightaccntid, findARAccount(invchead_cust_id) AS araccntid, ( SELECT COALESCE(SUM(taxhist_tax), 0) FROM invcheadtax WHERE ( (taxhist_parent_id = invchead_id) AND (taxhist_taxtype_id = getFreightTaxtypeId()) ) ) AS freighttax, ( SELECT COALESCE(SUM(taxhist_tax), 0) FROM invcheadtax WHERE ( (taxhist_parent_id = invchead_id) AND (taxhist_taxtype_id = getAdjustmentTaxtypeId()) ) ) AS adjtax INTO _p FROM invchead WHERE (invchead_id=pInvcheadid); _itemlocSeries = pItemlocSeries; _glDate := COALESCE(_p.invchead_gldistdate, _p.invchead_invcdate); IF (_p.invchead_salesrep_id < 0) THEN RAISE WARNING 'Patch negative invchead_salesrep_id until invchead_salesrep_id is a true fkey'; _p.invchead_salesrep_id := NULL; END IF; -- the 1st MC iteration used the cohead_orderdate so we could get curr exch -- gain/loss between the sales and invoice dates, but see issue 3892. leave -- this condition TRUE until we make this configurable or decide not to. IF TRUE THEN _firstExchDate := _p.invchead_invcdate; ELSE -- can we save a select by using: _firstExchDate := _p.invchead_orderdate; SELECT cohead_orderdate INTO _firstExchDate FROM cohead JOIN invchead ON (cohead_number = invchead_ordernumber) WHERE (invchead_id = pInvcheadid); END IF; -- Start by handling taxes FOR _r IN SELECT tax_sales_accnt_id, round(sum(taxdetail_tax),2) AS tax, currToBase(_p.invchead_curr_id, round(sum(taxdetail_tax),2), _firstExchDate) AS taxbasevalue FROM tax JOIN calculateTaxDetailSummary('I', pInvcheadid, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id, tax_sales_accnt_id LOOP PERFORM insertIntoGLSeries( _p.sequence, 'A/R', 'IN', _p.invchead_invcnumber, _r.tax_sales_accnt_id, _r.taxbasevalue, _glDate, _p.invchead_billto_name ); _totalAmount := _totalAmount + _r.tax; _totalRoundedBase := _totalRoundedBase + _r.taxbasevalue; END LOOP; -- Update item tax records with posting data UPDATE invcitemtax SET taxhist_docdate=_firstExchDate, taxhist_distdate=_glDate, taxhist_curr_id=_p.invchead_curr_id, taxhist_curr_rate=curr_rate, taxhist_journalnumber=pJournalNumber FROM invchead JOIN invcitem ON (invchead_id=invcitem_invchead_id), curr_rate WHERE ((invchead_id=pInvcheadId) AND (taxhist_parent_id=invcitem_id) AND (_p.invchead_curr_id=curr_id) AND ( _firstExchDate BETWEEN curr_effective AND curr_expires) ); -- Update Invchead taxes (Freight and Adjustments) with posting data UPDATE invcheadtax SET taxhist_docdate=_firstExchDate, taxhist_distdate=_glDate, taxhist_curr_id=_p.invchead_curr_id, taxhist_curr_rate=curr_rate, taxhist_journalnumber=pJournalNumber FROM curr_rate WHERE ((taxhist_parent_id=pInvcheadid) AND (_p.invchead_curr_id=curr_id) AND ( _firstExchDate BETWEEN curr_effective AND curr_expires) ); -- March through the Non-Misc. Invcitems FOR _r IN SELECT * FROM invoiceitem WHERE ( (invcitem_invchead_id = pInvcheadid) AND (invcitem_item_id <> -1) ) LOOP -- Cache the amount due for this line _amount := _r.extprice; IF (_amount > 0) THEN -- Credit the Sales Account for the invcitem item IF (_r.invcitem_rev_accnt_id IS NOT NULL) THEN SELECT getPrjAccntId(_p.invchead_prj_id, _r.invcitem_rev_accnt_id) INTO _tmpAccntId; ELSEIF (_r.itemsite_id IS NULL) THEN SELECT getPrjAccntId(_p.invchead_prj_id, salesaccnt_sales_accnt_id) INTO _tmpAccntId FROM salesaccnt WHERE (salesaccnt_id=findSalesAccnt(_r.invcitem_item_id, 'I', _p.invchead_cust_id, _p.invchead_saletype_id, _p.invchead_shipzone_id)); ELSE SELECT getPrjAccntId(_p.invchead_prj_id, salesaccnt_sales_accnt_id) INTO _tmpAccntId FROM salesaccnt WHERE (salesaccnt_id=findSalesAccnt(_r.itemsite_id, 'IS', _p.invchead_cust_id, _p.invchead_saletype_id, _p.invchead_shipzone_id)); END IF; -- If the Sales Account Assignment was not found then punt IF (NOT FOUND) THEN PERFORM deleteGLSeries(_p.sequence); DELETE FROM cohist WHERE ((cohist_sequence=_p.sequence) AND (cohist_invcnumber=_p.invchead_invcnumber)); RETURN -11; END IF; _roundedBase := round(currToBase(_p.invchead_curr_id, _amount, _firstExchDate), 2); SELECT insertIntoGLSeries( _p.sequence, 'A/R', 'IN', _p.invchead_invcnumber, _tmpAccntId, _roundedBase, _glDate, _p.invchead_billto_name ) INTO _test; _totalAmount := (_totalAmount + _amount); _totalRoundedBase := _totalRoundedBase + _roundedBase; _commissionDue := (_commissionDue + (_amount * _p.invchead_commission)); END IF; _totalAmount := _totalAmount; _totalRoundedBase := _totalRoundedBase; -- Record Sales History for this S/O Item SELECT nextval('cohist_cohist_id_seq') INTO _cohistid; INSERT INTO cohist ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_curr_id, cohist_sequence, cohist_taxtype_id, cohist_taxzone_id, cohist_shipzone_id, cohist_saletype_id ) VALUES ( _cohistid, _p.invchead_cust_id, _r.itemsite_id, _p.invchead_shipto_id, _p.invchead_shipdate, _p.invchead_shipvia, COALESCE(_p.invchead_ordernumber, _r.cohead_number), _p.invchead_ponumber, _p.invchead_orderdate, 'I', _p.invchead_invcnumber, _p.invchead_invcdate, _r.qty, _r.unitprice, _r.unitcost, _p.invchead_salesrep_id, (_p.invchead_commission * _r.extprice), FALSE, _p.invchead_billto_name, _p.invchead_billto_address1, _p.invchead_billto_address2, _p.invchead_billto_address3, _p.invchead_billto_city, _p.invchead_billto_state, _p.invchead_billto_zipcode, _p.invchead_shipto_name, _p.invchead_shipto_address1, _p.invchead_shipto_address2, _p.invchead_shipto_address3, _p.invchead_shipto_city, _p.invchead_shipto_state, _p.invchead_shipto_zipcode, _p.invchead_curr_id, _p.sequence, _r.invcitem_taxtype_id, _p.invchead_taxzone_id, _p.invchead_shipzone_id, _p.invchead_saletype_id ); INSERT INTO cohisttax ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM invcitemtax WHERE (taxhist_parent_id=_r.invcitem_id); END LOOP; -- March through the Misc. Invcitems FOR _r IN SELECT * FROM invoiceitem JOIN salescat ON (salescat_id = invcitem_salescat_id) WHERE ( (invcitem_item_id = -1) AND (invcitem_invchead_id=pInvcheadid) ) LOOP -- Cache the amount due for this line and the commission due for such _amount := _r.extprice; IF (_amount > 0) THEN -- Credit the Sales Account for the invcitem item _roundedBase = round(currToBase(_p.invchead_curr_id, _amount, _firstExchDate), 2); SELECT insertIntoGLSeries( _p.sequence, 'A/R', 'IN', _p.invchead_invcnumber, getPrjAccntId(_p.invchead_prj_id, COALESCE(_r.invcitem_rev_accnt_id, _r.salescat_sales_accnt_id)), _roundedBase, _glDate, _p.invchead_billto_name ) INTO _test; IF (_test < 0) THEN PERFORM deleteGLSeries(_p.sequence); DELETE FROM cohist WHERE ((cohist_sequence=_p.sequence) AND (cohist_invcnumber=_p.invchead_invcnumber)); RETURN _test; END IF; _totalAmount := (_totalAmount + _amount); _totalRoundedBase := _totalRoundedBase + _roundedBase; _commissionDue := (_commissionDue + (_amount * _p.invchead_commission)); END IF; -- Record Sales History for this S/O Item SELECT nextval('cohist_cohist_id_seq') INTO _cohistid; INSERT INTO cohist ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_misc_type, cohist_misc_descrip, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_curr_id, cohist_sequence, cohist_taxtype_id, cohist_taxzone_id, cohist_shipzone_id, cohist_saletype_id ) VALUES ( _cohistid, _p.invchead_cust_id, -1, _p.invchead_shipto_id, 'M', (_r.invcitem_number || '-' || _r.invcitem_descrip), _p.invchead_shipdate, _p.invchead_shipvia, COALESCE(_p.invchead_ordernumber, _r.cohead_number), _p.invchead_ponumber, _p.invchead_orderdate, 'I', _p.invchead_invcnumber, _p.invchead_invcdate, _r.qty, _r.unitprice, 0, _p.invchead_salesrep_id, (_p.invchead_commission * _r.extprice), FALSE, _p.invchead_billto_name, _p.invchead_billto_address1, _p.invchead_billto_address2, _p.invchead_billto_address3, _p.invchead_billto_city, _p.invchead_billto_state, _p.invchead_billto_zipcode, _p.invchead_shipto_name, _p.invchead_shipto_address1, _p.invchead_shipto_address2, _p.invchead_shipto_address3, _p.invchead_shipto_city, _p.invchead_shipto_state, _p.invchead_shipto_zipcode, _p.invchead_curr_id, _p.sequence, _r.invcitem_taxtype_id, _p.invchead_taxzone_id, _p.invchead_shipzone_id, _p.invchead_saletype_id ); INSERT INTO cohisttax ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM invcitemtax WHERE (taxhist_parent_id=_r.invcitem_id); END LOOP; -- Credit the Freight Account for Freight Charges IF (_p.invchead_freight <> 0) THEN IF (_p.freightaccntid <> -1) THEN _roundedBase = round(currToBase(_p.invchead_curr_id, _p.invchead_freight, _firstExchDate), 2); SELECT insertIntoGLSeries( _p.sequence, 'A/R', 'IN', _p.invchead_invcnumber, getPrjAccntId(_p.invchead_prj_id,_p.freightaccntid), _roundedBase, _glDate, _p.invchead_billto_name ) INTO _test; -- Cache the Freight Amount distributed _totalAmount := (_totalAmount + _p.invchead_freight); _totalRoundedBase := _totalRoundedBase + _roundedBase; ELSE _test := -14; END IF; -- If the Freight Account was not found then punt IF (_test < 0) THEN PERFORM deleteGLSeries(_p.sequence); DELETE FROM cohist WHERE ((cohist_sequence=_p.sequence) AND (cohist_invcnumber=_p.invchead_invcnumber)); RETURN _test; END IF; -- Record Sales History for the Freight SELECT nextval('cohist_cohist_id_seq') INTO _cohistid; INSERT INTO cohist ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_misc_type, cohist_misc_descrip, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_curr_id, cohist_sequence, cohist_taxtype_id, cohist_taxzone_id, cohist_shipzone_id, cohist_saletype_id ) VALUES ( _cohistid, _p.invchead_cust_id, -1, _p.invchead_shipto_id, 'F', 'Freight', _p.invchead_shipdate, _p.invchead_shipvia, _p.invchead_ordernumber, _p.invchead_ponumber, _p.invchead_orderdate, 'I', _p.invchead_invcnumber, _p.invchead_invcdate, 1, _p.invchead_freight, _p.invchead_freight, _p.invchead_salesrep_id, 0, FALSE, _p.invchead_billto_name, _p.invchead_billto_address1, _p.invchead_billto_address2, _p.invchead_billto_address3, _p.invchead_billto_city, _p.invchead_billto_state, _p.invchead_billto_zipcode, _p.invchead_shipto_name, _p.invchead_shipto_address1, _p.invchead_shipto_address2, _p.invchead_shipto_address3, _p.invchead_shipto_city, _p.invchead_shipto_state, _p.invchead_shipto_zipcode, _p.invchead_curr_id, _p.sequence, getFreightTaxtypeId(), _p.invchead_taxzone_id, _p.invchead_shipzone_id, _p.invchead_saletype_id ); INSERT INTO cohisttax ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM invcheadtax WHERE ( (taxhist_parent_id=_p.invchead_id) AND (taxhist_taxtype_id=getFreightTaxtypeId()) ); END IF; -- Credit the Misc. Account for Miscellaneous Charges IF (_p.invchead_misc_amount <> 0) THEN _roundedBase := round(currToBase(_p.invchead_curr_id, _p.invchead_misc_amount, _firstExchDate), 2); SELECT insertIntoGLSeries( _p.sequence, 'A/R', 'IN', _p.invchead_invcnumber, getPrjAccntId(_p.invchead_prj_id, _p.invchead_misc_accnt_id), _roundedBase, _glDate, _p.invchead_billto_name ) INTO _test; -- If the Misc. Charges Account was not found then punt IF (_test < 0) THEN PERFORM deleteGLSeries(_p.sequence); DELETE FROM cohist WHERE ((cohist_sequence=_p.sequence) AND (cohist_invcnumber=_p.invchead_invcnumber)); RETURN _test; END IF; -- Cache the Misc. Amount distributed _totalAmount := (_totalAmount + _p.invchead_misc_amount); _totalRoundedBase := _totalRoundedBase + _roundedBase; -- Record Sales History for the Misc. Charge INSERT INTO cohist ( cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_misc_type, cohist_misc_descrip, cohist_misc_id, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_curr_id, cohist_sequence, cohist_shipzone_id, cohist_saletype_id ) VALUES ( _p.invchead_cust_id, -1, _p.invchead_shipto_id, 'M', _p.invchead_misc_descrip, _p.invchead_misc_accnt_id, _p.invchead_shipdate, _p.invchead_shipvia, _p.invchead_ordernumber, _p.invchead_ponumber, _p.invchead_orderdate, 'I', _p.invchead_invcnumber, _p.invchead_invcdate, 1, _p.invchead_misc_amount, _p.invchead_misc_amount, _p.invchead_salesrep_id, 0, FALSE, _p.invchead_billto_name, _p.invchead_billto_address1, _p.invchead_billto_address2, _p.invchead_billto_address3, _p.invchead_billto_city, _p.invchead_billto_state, _p.invchead_billto_zipcode, _p.invchead_shipto_name, _p.invchead_shipto_address1, _p.invchead_shipto_address2, _p.invchead_shipto_address3, _p.invchead_shipto_city, _p.invchead_shipto_state, _p.invchead_shipto_zipcode, _p.invchead_curr_id, _p.sequence, _p.invchead_shipzone_id, _p.invchead_saletype_id ); END IF; -- Record Sales History for the Tax Adjustment IF (_p.adjtax <> 0) THEN SELECT nextval('cohist_cohist_id_seq') INTO _cohistid; INSERT INTO cohist ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_misc_type, cohist_misc_descrip, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_curr_id, cohist_sequence, cohist_taxtype_id, cohist_taxzone_id, cohist_shipzone_id, cohist_saletype_id ) VALUES ( _cohistid, _p.invchead_cust_id, -1, _p.invchead_shipto_id, 'T', 'Misc Tax Adjustment', _p.invchead_shipdate, _p.invchead_shipvia, _p.invchead_ordernumber, _p.invchead_ponumber, _p.invchead_orderdate, 'I', _p.invchead_invcnumber, _p.invchead_invcdate, 1, 0.0, 0.0, _p.invchead_salesrep_id, 0, FALSE, _p.invchead_billto_name, _p.invchead_billto_address1, _p.invchead_billto_address2, _p.invchead_billto_address3, _p.invchead_billto_city, _p.invchead_billto_state, _p.invchead_billto_zipcode, _p.invchead_shipto_name, _p.invchead_shipto_address1, _p.invchead_shipto_address2, _p.invchead_shipto_address3, _p.invchead_shipto_city, _p.invchead_shipto_state, _p.invchead_shipto_zipcode, _p.invchead_curr_id, _p.sequence, getAdjustmentTaxtypeId(), _p.invchead_taxzone_id, _p.invchead_shipzone_id, _p.invchead_saletype_id ); INSERT INTO cohisttax ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM invcheadtax WHERE ( (taxhist_parent_id=_p.invchead_id) AND (taxhist_taxtype_id=getAdjustmentTaxtypeId()) ); END IF; -- ToDo: handle rounding errors _exchGain := currGain(_p.invchead_curr_id, _totalAmount, _firstExchDate, _glDate); IF (_exchGain <> 0) THEN SELECT insertIntoGLSeries( _p.sequence, 'A/R', 'IN', _p.invchead_invcnumber, getGainLossAccntId(_p.araccntid), round(_exchGain, 2) * -1, _glDate, _p.invchead_billto_name ) INTO _test ; IF (_test < 0) THEN PERFORM deleteGLSeries(_p.sequence); DELETE FROM cohist WHERE ((cohist_sequence=_p.sequence) AND (cohist_invcnumber=_p.invchead_invcnumber)); RETURN _test; END IF; END IF; -- Debit A/R for the total Amount IF (_totalRoundedBase <> 0) THEN IF (_p.araccntid != -1) THEN PERFORM insertIntoGLSeries( _p.sequence, 'A/R', 'IN', _p.invchead_invcnumber, _p.araccntid, round(_totalRoundedBase * -1, 2), _glDate, _p.invchead_billto_name ); ELSE PERFORM deleteGLSeries(_p.sequence); DELETE FROM cohist WHERE ((cohist_sequence=_p.sequence) AND (cohist_invcnumber=_p.invchead_invcnumber)); RETURN -17; END IF; END IF; -- Commit the GLSeries; SELECT postGLSeries(_p.sequence, pJournalNumber) INTO _test; IF (_test < 0) THEN PERFORM deleteGLSeries(_p.sequence); DELETE FROM cohist WHERE ((cohist_sequence=_p.sequence) AND (cohist_invcnumber=_p.invchead_invcnumber)); RETURN _test; END IF; -- Create the Invoice aropen item SELECT nextval('aropen_aropen_id_seq') INTO _aropenid; INSERT INTO aropen ( aropen_id, aropen_username, aropen_journalnumber, aropen_open, aropen_posted, aropen_cust_id, aropen_ponumber, aropen_docnumber, aropen_applyto, aropen_doctype, aropen_docdate, aropen_duedate, aropen_distdate, aropen_terms_id, aropen_amount, aropen_paid, aropen_salesrep_id, aropen_commission_due, aropen_commission_paid, aropen_ordernumber, aropen_notes, aropen_cobmisc_id, aropen_curr_id ) VALUES ( _aropenid, getEffectiveXtUser(), pJournalNumber, TRUE, FALSE, _p.invchead_cust_id, _p.invchead_ponumber, _p.invchead_invcnumber, _p.invchead_invcnumber, 'I', _p.invchead_invcdate, determineDueDate(_p.invchead_terms_id, _p.invchead_invcdate), _glDate, _p.invchead_terms_id, round(_totalAmount, 2), 0, _p.invchead_salesrep_id, _commissionDue, FALSE, _p.invchead_ordernumber::text, _p.invchead_notes, pInvcheadid, _p.invchead_curr_id ); -- Handle the Inventory and G/L Transactions for any billed Inventory where invcitem_updateinv is true FOR _r IN SELECT itemsite_id AS itemsite_id, invcitem_id, (invcitem_billed * invcitem_qty_invuomratio) AS qty, invchead_invcnumber, invchead_cust_id AS cust_id, item_number, invchead_saletype_id AS saletype_id, invchead_shipzone_id AS shipzone_id, invchead_prj_id, itemsite_costmethod FROM invchead JOIN invcitem ON ( (invcitem_invchead_id=invchead_id) AND (invcitem_billed <> 0) AND (invcitem_updateinv) ) JOIN itemsite ON ( (itemsite_item_id=invcitem_item_id) AND (itemsite_warehous_id=invcitem_warehous_id) ) JOIN item ON (item_id=invcitem_item_id) WHERE (invchead_id=pInvcheadid) LOOP -- Issue billed stock from inventory IF (_itemlocSeries = 0) THEN _itemlocSeries := NEXTVAL('itemloc_series_seq'); END IF; IF (_r.itemsite_costmethod != 'J') THEN SELECT postInvTrans(itemsite_id, 'SH', _r.qty, 'S/O', 'IN', _r.invchead_invcnumber, '', ('Invoice Billed ' || _r.item_number), getPrjAccntId(_r.invchead_prj_id, resolveCOSAccount(itemsite_id, _r.cust_id, _r.saletype_id, _r.shipzone_id)), costcat_asset_accnt_id, _itemlocSeries, _glDate) INTO _invhistid FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_r.itemsite_id) ); ELSE RAISE DEBUG 'postInvoice(%, %, %) tried to postInvTrans a %-costed item', pInvcheadid, pJournalNumber, pItemlocSeries, _r.itemsite_costmethod; END IF; END LOOP; -- Mark the invoice as posted UPDATE invchead SET invchead_posted=TRUE, invchead_gldistdate=_glDate WHERE (invchead_id=pInvcheadid); -- Check for allocated CMs and Payments -- All amounts in invoice currency IF (_totalAmount > 0) THEN FOR _r IN SELECT aropen_id, CASE WHEN (currToCurr(aropen_curr_id, _p.invchead_curr_id, (aropen_amount - aropen_paid), _firstExchDate) >= currToCurr(aropenalloc_curr_id, _p.invchead_curr_id, aropenalloc_amount, _firstExchDate)) THEN currToCurr(aropenalloc_curr_id, _p.invchead_curr_id, aropenalloc_amount, _firstExchDate) ELSE currToCurr(aropen_curr_id, _p.invchead_curr_id, (aropen_amount - aropen_paid), _firstExchDate) END AS balance, aropenalloc_doctype, aropenalloc_doc_id FROM aropenalloc JOIN aropen ON (aropen_id=aropenalloc_aropen_id) WHERE ((aropenalloc_doctype='S' AND aropenalloc_doc_id=(SELECT cohead_id FROM cohead WHERE cohead_number=_p.invchead_ordernumber)) OR (aropenalloc_doctype='I' AND aropenalloc_doc_id=_p.invchead_id)) LOOP _appliedAmount := _r.balance; IF (_totalAmount < _appliedAmount) THEN _appliedAmount := _totalAmount; END IF; -- ignore if no appliable balance IF (_appliedAmount > 0) THEN -- create an arcreditapply record linking the source c/m and the target invoice -- for an amount that is equal to the balance on the invoice or the balance on -- c/m whichever is greater. INSERT INTO arcreditapply (arcreditapply_source_aropen_id, arcreditapply_target_aropen_id, arcreditapply_amount, arcreditapply_curr_id, arcreditapply_reftype, arcreditapply_ref_id) VALUES(_r.aropen_id, _aropenid, _appliedAmount, _p.invchead_curr_id, 'S', _r.aropenalloc_doc_id); -- call postARCreditMemoApplication(aropen_id of C/M) SELECT postARCreditMemoApplication(_r.aropen_id) into _test; -- if no error decrement the balance and contiue on IF (_test >= 0) THEN _totalAmount := _totalAmount - _appliedAmount; END IF; END IF; END LOOP; END IF; -- Delete any allocated CMs and Payments DELETE FROM aropenalloc WHERE ((aropenalloc_doctype='S' AND aropenalloc_doc_id=(SELECT cohead_id FROM cohead WHERE cohead_number=_p.invchead_ordernumber)) OR (aropenalloc_doctype='I' AND aropenalloc_doc_id=_p.invchead_id)); RETURN _itemlocSeries; END; $$; ALTER FUNCTION public.postinvoice(pinvcheadid integer, pjournalnumber integer, pitemlocseries integer) OWNER TO admin; -- -- Name: postinvoices(boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postinvoices(boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPostUnprinted ALIAS FOR $1; BEGIN RETURN postInvoices(pPostUnprinted, FALSE); END; $_$; ALTER FUNCTION public.postinvoices(boolean) OWNER TO admin; -- -- Name: postinvoices(boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postinvoices(boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPostUnprinted ALIAS FOR $1; pInclZeros ALIAS FOR $2; BEGIN RETURN postInvoices(pPostUnprinted, pInclZeros, fetchJournalNumber('AR-IN')); END; $_$; ALTER FUNCTION public.postinvoices(boolean, boolean) OWNER TO admin; -- -- Name: postinvoices(boolean, boolean, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postinvoices(boolean, boolean, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPostUnprinted ALIAS FOR $1; pInclZeros ALIAS FOR $2; pJournalNumber ALIAS FOR $3; _invcheadid INTEGER; _itemlocSeries INTEGER; _counter INTEGER; _r RECORD; BEGIN _itemlocSeries := 0; IF (pInclZeros) THEN FOR _invcheadid IN SELECT invchead_id FROM invchead WHERE ( (NOT invchead_posted) AND (checkInvoiceSitePrivs(invchead_id)) AND (pPostUnprinted OR invchead_printed) ) LOOP SELECT postInvoice(_invcheadid, pJournalNumber, _itemlocSeries) INTO _itemlocSeries; IF (_itemlocSeries < 0) THEN RETURN _itemlocSeries; END IF; END LOOP; ELSE FOR _invcheadid IN SELECT invchead_id FROM invchead LEFT OUTER JOIN invcitem ON (invchead_id=invcitem_invchead_id) LEFT OUTER JOIN item ON (invcitem_item_id=item_id) WHERE((NOT invchead_posted) AND (checkInvoiceSitePrivs(invchead_id)) AND (pPostUnprinted OR invchead_printed)) GROUP BY invchead_id, invchead_freight, invchead_misc_amount HAVING (COALESCE(SUM(round((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / CASE WHEN (item_id IS NULL) THEN 1 ELSE invcitem_price_invuomratio END), 2)),0) + invchead_freight + invchead_misc_amount) > 0 LOOP SELECT postInvoice(_invcheadid, pJournalNumber, _itemlocSeries) INTO _itemlocSeries; IF (_itemlocSeries < 0) THEN RETURN _itemlocSeries; END IF; END LOOP; END IF; RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.postinvoices(boolean, boolean, integer) OWNER TO admin; -- -- Name: postinvtrans(integer, text, numeric, text, text, text, text, text, integer, integer, integer, timestamp with time zone, numeric, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postinvtrans(pitemsiteid integer, ptranstype text, pqty numeric, pmodule text, pordertype text, pordernumber text, pdocnumber text, pcomments text, pdebitid integer, pcreditid integer, pitemlocseries integer, ptimestamp timestamp with time zone DEFAULT now(), pcostovrld numeric DEFAULT NULL::numeric, pinvhistid integer DEFAULT NULL::integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- pInvhistid is the original transaction to be returned, reversed, etc. DECLARE _creditid INTEGER; _debitid INTEGER; _glreturn INTEGER; _invhistid INTEGER; _itemlocdistid INTEGER; _r RECORD; _sense INTEGER; -- direction in which to adjust inventory QOH _t RECORD; _timestamp TIMESTAMP WITH TIME ZONE; _xferwhsid INTEGER; BEGIN -- Cache item and itemsite info SELECT CASE WHEN(itemsite_costmethod IN ('A','J')) THEN COALESCE(abs(pCostOvrld / pQty), avgcost(itemsite_id)) ELSE stdCost(itemsite_item_id) END AS cost, itemsite_costmethod, itemsite_qtyonhand, itemsite_warehous_id, ( (item_type = 'R') OR (itemsite_controlmethod = 'N') ) AS nocontrol, (itemsite_controlmethod IN ('L', 'S')) AS lotserial, (itemsite_loccntrl) AS loccntrl, itemsite_freeze AS frozen INTO _r FROM itemsite JOIN item ON (item_id=itemsite_item_id) WHERE (itemsite_id=pItemsiteid); --Post the Inventory Transactions IF (_r.nocontrol) THEN RETURN -1; -- non-fatal error so dont throw an exception? END IF; IF (COALESCE(pItemlocSeries,0) = 0) THEN RAISE EXCEPTION 'Transaction series must be provided'; END IF; SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid; IF ((pTimestamp IS NULL) OR (CAST(pTimestamp AS date)=CURRENT_DATE)) THEN _timestamp := CURRENT_TIMESTAMP; ELSE _timestamp := pTimestamp; END IF; IF (pTransType = 'TS' OR pTransType = 'TR') THEN SELECT * INTO _t FROM tohead WHERE (tohead_number=pDocNumber); IF (pTransType = 'TS') THEN _xferwhsid := CASE WHEN (_t.tohead_src_warehous_id=_r.itemsite_warehous_id) THEN _t.tohead_trns_warehous_id WHEN (_t.tohead_trns_warehous_id=_r.itemsite_warehous_id AND pComments ~* 'recall') THEN _t.tohead_src_warehous_id WHEN (_t.tohead_trns_warehous_id=_r.itemsite_warehous_id) THEN _t.tohead_dest_warehous_id WHEN (_t.tohead_dest_warehous_id=_r.itemsite_warehous_id) THEN _t.tohead_trns_warehous_id ELSE NULL END; ELSIF (pTransType = 'TR') THEN _xferwhsid := CASE WHEN (_t.tohead_src_warehous_id=_r.itemsite_warehous_id) THEN _t.tohead_trns_warehous_id WHEN (_t.tohead_trns_warehous_id=_r.itemsite_warehous_id AND pComments ~* 'recall') THEN _t.tohead_dest_warehous_id WHEN (_t.tohead_trns_warehous_id=_r.itemsite_warehous_id) THEN _t.tohead_src_warehous_id WHEN (_t.tohead_dest_warehous_id=_r.itemsite_warehous_id) THEN _t.tohead_trns_warehous_id ELSE NULL END; END IF; END IF; -- increase inventory: AD RM RT RP RR RS RX RB TR -- decrease inventory: IM IB IT SH SI EX RI -- TS and TR are special: shipShipment and recallShipment should not change -- QOH at the Transfer Order src whs (as this was done by issueToShipping) -- but postReceipt should change QOH at the transit whs IF (pTransType='TS') THEN _sense := CASE WHEN (SELECT tohead_trns_warehous_id=_r.itemsite_warehous_id FROM tohead WHERE (tohead_number=pDocNumber)) THEN -1 ELSE 0 END; ELSIF (pTransType='TR') THEN _sense := CASE WHEN (SELECT tohead_src_warehous_id=_r.itemsite_warehous_id FROM tohead WHERE (tohead_number=pDocNumber)) THEN 0 ELSE 1 END; ELSIF (pTransType IN ('IM', 'IB', 'IT', 'SH', 'SI', 'EX', 'RI')) THEN _sense := -1; ELSE _sense := 1; END IF; IF((_r.itemsite_costmethod='A') AND (_r.itemsite_qtyonhand + round(_sense * pQty, 6)) < 0) THEN -- Can not let average costed itemsites go negative RAISE EXCEPTION 'This transaction will cause an Average Costed item to go negative which is not allowed [xtuple: postinvtrans, -2]'; END IF; INSERT INTO invhist ( invhist_id, invhist_itemsite_id, invhist_transtype, invhist_transdate, invhist_invqty, invhist_qoh_before, invhist_qoh_after, invhist_costmethod, invhist_value_before, invhist_value_after, invhist_ordtype, invhist_ordnumber, invhist_docnumber, invhist_comments, invhist_invuom, invhist_unitcost, invhist_xfer_warehous_id, invhist_posted, invhist_series ) SELECT _invhistid, itemsite_id, pTransType, _timestamp, pQty, itemsite_qtyonhand, (itemsite_qtyonhand + (_sense * pQty)), itemsite_costmethod, itemsite_value, -- sanity check to ensure that value = 0 when qtyonhand = 0 CASE WHEN ((itemsite_qtyonhand + (_sense * pQty))) = 0.0 THEN 0.0 ELSE itemsite_value + (_r.cost * _sense * pQty) END, pOrderType, pOrderNumber, pDocNumber, pComments, uom_name, _r.cost, _xferwhsid, FALSE, pItemlocSeries FROM itemsite, item, uom WHERE ( (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (itemsite_id=pItemsiteid) ); IF (pCreditid IN (SELECT accnt_id FROM accnt)) THEN _creditid = pCreditid; ELSE SELECT warehous_default_accnt_id INTO _creditid FROM itemsite, whsinfo WHERE ( (itemsite_warehous_id=warehous_id) AND (itemsite_id=pItemsiteid) ); END IF; IF (pDebitid IN (SELECT accnt_id FROM accnt)) THEN _debitid = pDebitid; ELSE SELECT warehous_default_accnt_id INTO _debitid FROM itemsite, whsinfo WHERE ( (itemsite_warehous_id=warehous_id) AND (itemsite_id=pItemsiteid) ); END IF; -- Post the G/L Transaction IF (_creditid <> _debitid) THEN SELECT insertGLTransaction(pModule, pOrderType, pOrderNumber, pComments, _creditid, _debitid, _invhistid, (_r.cost * pQty), _timestamp::DATE, FALSE) INTO _glreturn; END IF; -- Distribute this if this itemsite is controlled IF ( _r.lotserial OR _r.loccntrl ) THEN _itemlocdistid := nextval('itemlocdist_itemlocdist_id_seq'); INSERT INTO itemlocdist ( itemlocdist_id, itemlocdist_itemsite_id, itemlocdist_source_type, itemlocdist_reqlotserial, itemlocdist_distlotserial, itemlocdist_expiration, itemlocdist_qty, itemlocdist_series, itemlocdist_invhist_id, itemlocdist_order_type, itemlocdist_order_id ) SELECT _itemlocdistid, pItemsiteid, 'O', (((pQty * _sense) > 0) AND _r.lotserial), ((pQty * _sense) < 0), endOfTime(), (_sense * pQty), pItemlocSeries, _invhistid, pOrderType, CASE WHEN pOrderType='SO' THEN getSalesLineItemId(pOrderNumber) ELSE NULL END; -- populate distributions if invhist_id parameter passed to undo IF (pInvhistid IS NOT NULL) THEN INSERT INTO itemlocdist ( itemlocdist_itemlocdist_id, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_itemsite_id, itemlocdist_ls_id, itemlocdist_expiration, itemlocdist_qty, itemlocdist_series, itemlocdist_invhist_id ) SELECT _itemlocdistid, 'L', COALESCE(invdetail_location_id, -1), invhist_itemsite_id, invdetail_ls_id, COALESCE(invdetail_expiration, endoftime()), (invdetail_qty * -1.0), pItemlocSeries, _invhistid FROM invhist JOIN invdetail ON (invdetail_invhist_id=invhist_id) WHERE (invhist_id=pInvhistid); IF ( _r.lotserial) THEN INSERT INTO lsdetail ( lsdetail_itemsite_id, lsdetail_ls_id, lsdetail_created, lsdetail_source_type, lsdetail_source_id, lsdetail_source_number ) SELECT invhist_itemsite_id, invdetail_ls_id, CURRENT_TIMESTAMP, 'I', _itemlocdistid, '' FROM invhist JOIN invdetail ON (invdetail_invhist_id=invhist_id) WHERE (invhist_id=pInvhistid); END IF; PERFORM distributeitemlocseries(pItemlocSeries); END IF; END IF; -- end of distributions -- These records will be used for posting G/L transactions to trial balance after records committed. -- If we try to do it now concurrency locking prevents any transactions while -- user enters item distribution information. Cant have that. INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries) VALUES ( _glreturn, pItemlocSeries ); RETURN _invhistid; END; $$; ALTER FUNCTION public.postinvtrans(pitemsiteid integer, ptranstype text, pqty numeric, pmodule text, pordertype text, pordernumber text, pdocnumber text, pcomments text, pdebitid integer, pcreditid integer, pitemlocseries integer, ptimestamp timestamp with time zone, pcostovrld numeric, pinvhistid integer) OWNER TO admin; -- -- Name: postitemlocseries(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postitemlocseries(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemlocseries ALIAS FOR $1; _result INTEGER; BEGIN PERFORM postIntoTrialBalance(itemlocpost_glseq) FROM ( SELECT DISTINCT itemlocpost_glseq, gltrans_accnt_id FROM itemlocpost JOIN gltrans ON (itemlocpost_glseq=gltrans_sequence) WHERE (itemlocpost_itemlocseries=pItemlocseries) ORDER BY gltrans_accnt_id ) AS data; PERFORM postInvHist(invhist_id) FROM invhist JOIN itemsite ON (invhist_itemsite_id=itemsite_id) WHERE ( (invhist_series=pItemlocseries) AND ( NOT invhist_posted) AND ( NOT itemsite_freeze) ); DELETE FROM itemlocpost WHERE (itemlocpost_itemlocseries=pItemlocseries); RETURN TRUE; END; $_$; ALTER FUNCTION public.postitemlocseries(integer) OWNER TO admin; -- -- Name: postjournals(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postjournals(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; _transCount INTEGER := 0; _journalnumber INTEGER := fetchJournalNumber('J/P'); _sequence INTEGER := fetchGLSequence(); _sltrans RECORD; BEGIN -- Make sure that we balance IF (SELECT SUM(sltrans_amount) != 0 FROM sltrans WHERE ((NOT sltrans_posted ) AND (sltrans_sequence=pSequence))) THEN RAISE EXCEPTION 'Can not post journals. Transactions do not balance in selected date range.'; END IF; -- March through the sltrans members, posting them one at a time FOR _sltrans IN SELECT sltrans_source, sltrans_accnt_id, SUM(sltrans_amount) as amount FROM sltrans WHERE ((sltrans_amount<>0.0) AND (NOT sltrans_posted) AND (sltrans_sequence=pSequence)) GROUP BY sltrans_source, sltrans_accnt_id LOOP -- refuse to accept postings into closed periods IF (SELECT BOOL_AND(COALESCE(period_closed, FALSE)) FROM accnt LEFT OUTER JOIN period ON (CURRENT_DATE BETWEEN period_start AND period_end) WHERE (accnt_id = _sltrans.sltrans_accnt_id)) THEN RAISE EXCEPTION 'Cannot post to closed period (%).', _sltrans.sltrans_distdate; RETURN -4; -- remove raise exception when all callers check return code END IF; -- refuse to accept postings into frozen periods without proper priv IF (SELECT NOT BOOL_AND(checkPrivilege('PostFrozenPeriod')) AND BOOL_AND(COALESCE(period_freeze, FALSE)) FROM accnt LEFT OUTER JOIN period ON (CURRENT_DATE BETWEEN period_start AND period_end) WHERE (accnt_id = _sltrans.sltrans_accnt_id)) THEN RAISE EXCEPTION 'Cannot post to frozen period (%).', _sltrans.sltrans_distdate; RETURN -4; -- remove raise exception when all callers check return code END IF; IF (_sltrans.amount != 0) THEN INSERT INTO gltrans ( gltrans_posted, gltrans_exported, gltrans_created, gltrans_date, gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_notes, gltrans_doctype, gltrans_docnumber, gltrans_amount, gltrans_journalnumber, gltrans_rec ) VALUES ( FALSE, FALSE, CURRENT_TIMESTAMP, CURRENT_DATE, _sequence, _sltrans.sltrans_accnt_id, _sltrans.sltrans_source, 'Journal Posting', 'JP', _journalnumber, _sltrans.amount, _journalnumber, TRUE ); _transCount := _transCount + 1; END IF; END LOOP; -- Update all of the posted sltrans members UPDATE sltrans SET sltrans_posted=true, sltrans_gltrans_journalnumber=_journalnumber WHERE ((NOT sltrans_posted) AND (sltrans_sequence=pSequence)); PERFORM postIntoTrialBalance(_sequence); RETURN _journalnumber; END; $_$; ALTER FUNCTION public.postjournals(integer) OWNER TO admin; -- -- Name: postjournals(text[], date, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postjournals(text[], date, date, date) RETURNS SETOF integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSources ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; pDistDate ALIAS FOR $4; _i INTEGER; BEGIN FOR _i IN 1..ARRAY_UPPER(pSources,1) LOOP RETURN NEXT postJournals(pSources[_i], pStartDate, pEndDate, pDistDate); END LOOP; RETURN; END; $_$; ALTER FUNCTION public.postjournals(text[], date, date, date) OWNER TO admin; -- -- Name: postjournals(text, date, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postjournals(text, date, date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSource ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; pDistDate ALIAS FOR $4; _transCount INTEGER := 0; _journalnumber INTEGER := fetchJournalNumber('J/P'); _sequence INTEGER := fetchGLSequence(); _sltrans RECORD; BEGIN -- Make sure that we balance IF (SELECT SUM(sltrans_amount) != 0 FROM sltrans WHERE ((NOT sltrans_posted ) AND (sltrans_source=pSource) AND (sltrans_date BETWEEN pStartDate AND pEndDate))) THEN RAISE EXCEPTION 'Can not post journals. Transactions do not balance in selected date range.'; END IF; -- March through the sltrans members, posting them one at a time FOR _sltrans IN SELECT sltrans_source, sltrans_accnt_id, SUM(sltrans_amount) as amount FROM sltrans WHERE ((sltrans_amount<>0.0) AND (NOT sltrans_posted) AND (sltrans_source=pSource) AND (sltrans_date BETWEEN pStartDate AND pEndDate)) GROUP BY sltrans_source, sltrans_accnt_id LOOP -- refuse to accept postings into frozen periods if any of the accounts disallow it IF (SELECT NOT BOOL_AND(checkPrivilege('PostFrozenPeriod')) AND BOOL_AND(COALESCE(period_freeze, FALSE)) FROM accnt LEFT OUTER JOIN period ON (pDistDate BETWEEN period_start AND period_end) WHERE (accnt_id = _sltrans.sltrans_accnt_id)) THEN RAISE EXCEPTION 'Cannot post to frozen period (%).', _sltrans.sltrans_distdate; RETURN -4; -- remove raise exception when all callers check return code END IF; IF (_sltrans.amount != 0) THEN INSERT INTO gltrans ( gltrans_posted, gltrans_exported, gltrans_created, gltrans_date, gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_notes, gltrans_doctype, gltrans_docnumber, gltrans_amount, gltrans_journalnumber ) VALUES ( FALSE, FALSE, CURRENT_TIMESTAMP, pDistDate, _sequence, _sltrans.sltrans_accnt_id, _sltrans.sltrans_source, 'Journal Posting', 'JP', _journalnumber, _sltrans.amount, _journalnumber ); _transCount := _transCount + 1; END IF; END LOOP; -- Update all of the posted sltrans members UPDATE sltrans SET sltrans_posted=true, sltrans_gltrans_journalnumber=_journalnumber WHERE ((NOT sltrans_posted) AND (sltrans_source=pSource) AND (sltrans_date BETWEEN pStartDate AND pEndDate)); PERFORM postIntoTrialBalance(_sequence); RETURN _journalnumber; END; $_$; ALTER FUNCTION public.postjournals(text, date, date, date) OWNER TO admin; -- -- Name: postmessage(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postmessage(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pText ALIAS FOR $2; _msgid INTEGER; BEGIN SELECT NEXTVAL('msg_msg_id_seq') INTO _msgid; INSERT INTO msg (msg_id, msg_posted, msg_scheduled, msg_expires, msg_username, msg_text) VALUES (_msgid, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, endOfTime(), getEffectiveXtUser(), pText); INSERT INTO msguser ( msguser_msg_id, msguser_username ) VALUES ( _msgid, pUsername ); NOTIFY "messagePosted"; RETURN _msgid; END; $_$; ALTER FUNCTION public.postmessage(text, text) OWNER TO admin; -- -- Name: postmessage(timestamp without time zone, timestamp without time zone, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postmessage(timestamp without time zone, timestamp without time zone, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pScheduled ALIAS FOR $1; pExpires ALIAS FOR $2; pText ALIAS FOR $3; _msgid INTEGER; BEGIN SELECT NEXTVAL('msg_msg_id_seq') INTO _msgid; INSERT INTO msg (msg_id, msg_posted, msg_scheduled, msg_expires, msg_username, msg_text) VALUES (_msgid, CURRENT_TIMESTAMP, pScheduled, pExpires, getEffectiveXtUser(), pText); INSERT INTO msguser ( msguser_msg_id, msguser_username ) SELECT _msgid, usr_username FROM usr WHERE (usr_username <> getEffectiveXtUser()); NOTIFY "messagePosted"; RETURN _msgid; END; $_$; ALTER FUNCTION public.postmessage(timestamp without time zone, timestamp without time zone, text) OWNER TO admin; -- -- Name: postmessage(timestamp without time zone, timestamp without time zone, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postmessage(timestamp without time zone, timestamp without time zone, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pScheduled ALIAS FOR $1; pExpires ALIAS FOR $2; pUsername ALIAS FOR $3; pText ALIAS FOR $4; _msgid INTEGER; BEGIN SELECT NEXTVAL('msg_msg_id_seq') INTO _msgid; INSERT INTO msg (msg_id, msg_posted, msg_scheduled, msg_expires, msg_username, msg_text) VALUES (_msgid, CURRENT_TIMESTAMP, pScheduled, pExpires, getEffectiveXtUser(), pText); INSERT INTO msguser ( msguser_msg_id, msguser_username ) VALUES ( _msgid, pUsername ); NOTIFY "messagePosted"; RETURN _msgid; END; $_$; ALTER FUNCTION public.postmessage(timestamp without time zone, timestamp without time zone, text, text) OWNER TO admin; -- -- Name: postmisccount(integer, numeric, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postmisccount(pitemsiteid integer, pqty numeric, pcomments text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pQty ALIAS FOR $2; pComments ALIAS FOR $3; _invcntid INTEGER; _result INTEGER; BEGIN IF (pItemsiteid IS NULL OR pQty IS NULL) THEN RAISE EXCEPTION 'You must enter an Item Site and a Quantity.'; END IF; -- Make sure the passed itemsite points to a real item IF ( ( SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J') FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ) ) ) THEN RETURN 0; END IF; SELECT invcnt_id INTO _invcntid FROM invcnt WHERE ( (NOT invcnt_posted) AND (invcnt_itemsite_id=pItemsiteid) ); IF (_invcntid IS NULL) THEN _invcntid := NEXTVAL('invcnt_invcnt_id_seq'); INSERT INTO invcnt ( invcnt_id, invcnt_itemsite_id, invcnt_tagdate, invcnt_qoh_before, invcnt_qoh_after, invcnt_tag_username, invcnt_cntdate, invcnt_cnt_username, invcnt_postdate, invcnt_post_username, invcnt_posted, invcnt_priority, invcnt_comments ) SELECT _invcntid, pItemsiteid, now(), itemsite_qtyonhand, pQty, getEffectiveXtUser(), now(), getEffectiveXtUser(), now(), getEffectiveXtUser(), FALSE, FALSE, pComments FROM itemsite WHERE (itemsite_id=pItemsiteid); SELECT postCountTag(_invcntid, FALSE) INTO _result; IF (_result < 0) THEN DELETE FROM invcnt WHERE (invcnt_id=_invcntid); END IF; RETURN _result; ELSE RETURN -2; END IF; END; $_$; ALTER FUNCTION public.postmisccount(pitemsiteid integer, pqty numeric, pcomments text) OWNER TO admin; -- -- Name: postpogltransactions(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postpogltransactions() RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN UPDATE gltrans SET gltrans_exported=TRUE WHERE ( (NOT gltrans_exported) AND (gltrans_source='A/P') AND (gltrans_doctype IN ('VO')) ); RETURN TRUE; END; $$; ALTER FUNCTION public.postpogltransactions() OWNER TO admin; -- -- Name: postporeceipt(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postporeceipt(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN postReceipt($1, $2); END; $_$; ALTER FUNCTION public.postporeceipt(integer, integer) OWNER TO admin; -- -- Name: postporeceipts(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postporeceipts(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN postReceipts('PO', $1, NULL); END; $_$; ALTER FUNCTION public.postporeceipts(integer) OWNER TO admin; -- -- Name: postporeturncreditmemo(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postporeturncreditmemo(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPorejectId ALIAS FOR $1; BEGIN RETURN postPoReturnCreditMemo(pPorejectId, NULL); END; $_$; ALTER FUNCTION public.postporeturncreditmemo(integer) OWNER TO admin; -- -- Name: postporeturncreditmemo(integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postporeturncreditmemo(integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPorejectId ALIAS FOR $1; pAmount ALIAS FOR $2; _p RECORD; _a RECORD; _itemsiteId INTEGER; _docNumber TEXT; _sequence INTEGER; _journalNumber INTEGER; _apopenid INTEGER; _exchGainItem NUMERIC; _itemAmount_base NUMERIC; _itemAmount NUMERIC; _glseriesTotal NUMERIC; _tmpTotal NUMERIC; _test INTEGER; _exchDate DATE; _tax RECORD; _taxAmount NUMERIC := 0; _taxAmount_base NUMERIC; _apaccntid INTEGER; BEGIN --Set things up SELECT NEXTVAL('apopen_apopen_id_seq') INTO _apopenid; SELECT fetchGLSequence() INTO _sequence; SELECT fetchJournalNumber('AP-MISC') INTO _journalNumber; SELECT fetchapmemonumber() INTO _docNumber; _glseriesTotal := 0; --Get poreject data SELECT pohead_vend_id, pohead_number, pohead_curr_id, pohead_orderdate, pohead_taxzone_id, poitem_id, poitem_itemsite_id,poitem_expcat_id, poitem_taxtype_id, itemsite_costcat_id, poreject_qty, poreject_date, ('Return of Item ' || COALESCE(item_number,poitem_vend_item_number) || ', qty. ' || formatqty(poreject_qty)) AS notes, poreject_value AS value, currToBase(pohead_curr_id,(poitem_unitprice * poreject_qty),CURRENT_DATE) AS itemAmount_base, (poitem_unitprice * poreject_qty) AS itemAmount INTO _p FROM pohead, poreject, poitem LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id) LEFT OUTER JOIN item ON (itemsite_item_id=item_id) WHERE ((poreject_poitem_id=poitem_id) AND (pohead_id=poitem_pohead_id) AND (poreject_id=pPorejectId)); _itemAmount := _p.itemAmount; _itemAmount_base := _p.itemAmount_base; IF (pAmount IS NOT NULL) THEN _itemAmount := pAmount; _itemAmount_base := currToBase(_p.pohead_curr_id, pAmount, CURRENT_DATE); END IF; -- Grab the G/L Accounts IF (COALESCE(_p.poitem_itemsite_id, -1) = -1) THEN SELECT pp.accnt_id AS pp_accnt_id, lb.accnt_id AS lb_accnt_id INTO _a FROM expcat, accnt AS pp, accnt AS lb WHERE ( (expcat_purchprice_accnt_id=pp.accnt_id) AND (expcat_liability_accnt_id=lb.accnt_id) AND (expcat_id=_p.poitem_expcat_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Post Credit Memo due to unassigned G/L Accounts.'; END IF; ELSE SELECT pp.accnt_id AS pp_accnt_id, lb.accnt_id AS lb_accnt_id INTO _a FROM costcat, accnt AS pp, accnt AS lb WHERE ( (costcat_purchprice_accnt_id=pp.accnt_id) AND (costcat_liability_accnt_id=lb.accnt_id) AND (costcat_id=_p.itemsite_costcat_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Post Credit Memo due to unassigned G/L Accounts.'; END IF; END IF; -- AP Open Item record INSERT INTO apopen ( apopen_id, apopen_username, apopen_journalnumber, apopen_vend_id, apopen_docnumber, apopen_doctype, apopen_ponumber, apopen_docdate, apopen_duedate, apopen_distdate, apopen_terms_id, apopen_amount, apopen_paid, apopen_open, apopen_notes, apopen_accnt_id, apopen_curr_id, apopen_closedate ) VALUES ( _apopenid, getEffectiveXtUser(), _journalNumber, _p.pohead_vend_id, _docNumber, 'C', _p.pohead_number, CURRENT_DATE, CURRENT_DATE, CURRENT_DATE, -1, round(_itemAmount, 2), 0, (round(_itemAmount, 2) <> 0), _p.notes, -1, _p.pohead_curr_id, CASE WHEN (round(_itemAmount, 2) = 0) THEN _p.poreject_date END ); -- Taxes FOR _tax IN SELECT taxdetail_tax_id, sum(taxdetail_tax) AS taxdetail_tax, currToBase(_p.pohead_curr_id, round(sum(taxdetail_tax),2), current_date) AS taxbasevalue FROM calculateTaxDetail(_p.pohead_taxzone_id, _p.poitem_taxtype_id, current_date, _p.pohead_curr_id, _itemAmount) GROUP BY taxdetail_tax_id LOOP INSERT INTO apopentax (taxhist_basis,taxhist_percent,taxhist_amount,taxhist_docdate, taxhist_tax_id, taxhist_tax, taxhist_taxtype_id, taxhist_parent_id, taxhist_journalnumber ) VALUES (0, 0, 0, current_date, _tax.taxdetail_tax_id, _tax.taxdetail_tax, getadjustmenttaxtypeid(), _apopenid, _journalNumber); _taxAmount := _taxAmount + _tax.taxdetail_tax; END LOOP; _taxAmount_base := addTaxToGLSeries(_sequence, 'A/P', 'CM', _docNumber, _p.pohead_curr_id, current_date, current_date, 'apopentax', _apopenid, _p.notes); UPDATE apopen SET apopen_amount = round(_itemAmount + _taxAmount,2) WHERE (apopen_id = _apopenid); -- Distribute from the clearing account PERFORM insertIntoGLSeries( _sequence, 'A/P', 'CM', _docNumber, _a.lb_accnt_id, round(_p.value, 2), current_date, _p.notes ); _glseriesTotal := _glseriesTotal + round(_p.value, 2); -- Distribute the remaining variance to the Purchase Price Variance account IF (round(_itemAmount_base, 2) <> round(_p.value, 2)) THEN _tmpTotal := round(_itemAmount_base, 2) - round(_p.value, 2); PERFORM insertIntoGLSeries( _sequence, 'A/P', 'CM', _docNumber, _a.pp_accnt_id, _tmpTotal, current_date, _p.notes ); _glseriesTotal := _glseriesTotal + _tmpTotal; END IF; -- Post the reject item for this P/O Item as Invoiced UPDATE poreject SET poreject_invoiced=TRUE WHERE poreject_id=pPorejectId; -- Update the qty vouchered field UPDATE poitem SET poitem_qty_vouchered = (poitem_qty_vouchered - _p.poreject_qty) WHERE (poitem_id=_p.poitem_id); -- Post to A/P SELECT findAPAccount(_p.pohead_vend_id) INTO _apaccntid; IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Post Credit Memo due to an unassigned A/P Account.'; END IF; SELECT insertIntoGLSeries( _sequence, 'A/P', 'CM', _docNumber, _apaccntid, round(_itemAmount_base + _taxAmount_base, 2) *-1, current_date, _p.notes ) INTO _test; IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Post Credit Memo.'; END IF; -- Clean up loose ends _glseriesTotal := _glseriesTotal + round(_itemAmount_base, 2)*-1; IF (round(_glseriesTotal, 2) != 0) THEN PERFORM insertIntoGLSeries(_sequence, 'A/P', 'CM', 'Currency Exchange Rounding - ' || _docNumber, getGainLossAccntId(_apaccntid), round(_glseriesTotal, 2) * -1, current_date, _p.notes); END IF; -- Post it all PERFORM postGLSeries(_sequence, _journalNumber); RETURN _journalNumber; END; $_$; ALTER FUNCTION public.postporeturncreditmemo(integer, numeric) OWNER TO admin; -- -- Name: postporeturns(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postporeturns(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPoheadid ALIAS FOR $1; _itemlocSeries INTEGER; _p RECORD; _returnval INTEGER; BEGIN _itemlocSeries := 0; SELECT postPoReturns(pPoheadid,false) INTO _itemlocseries; RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.postporeturns(integer) OWNER TO admin; -- -- Name: postporeturns(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postporeturns(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPoheadid ALIAS FOR $1; pCreateMemo ALIAS FOR $2; _itemlocSeries INTEGER; _p RECORD; _returnval INTEGER; _tmp INTEGER; _pricevar NUMERIC := 0.00; _invhistid INTEGER; _journalNumber INTEGER := fetchJournalNumber('GL-MISC'); BEGIN _itemlocSeries := 0; FOR _p IN SELECT pohead_number, pohead_curr_id, poreject_id, poitem_prj_id, poreject_poitem_id, poitem_id, poitem_expcat_id, poitem_linenumber, currToBase(COALESCE(recv_purchcost_curr_id, pohead_curr_id), COALESCE(recv_purchcost, poitem_unitprice), pohead_orderdate) AS poitem_unitprice_base, COALESCE(itemsite_id, -1) AS itemsiteid, poitem_invvenduomratio, SUM(poreject_qty) AS totalqty, itemsite_item_id, itemsite_costmethod, itemsite_controlmethod, recv_date FROM pohead JOIN poitem ON (poitem_pohead_id=pohead_id) JOIN poreject ON (poreject_poitem_id=poitem_id AND NOT poreject_posted) LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id) LEFT OUTER JOIN recv ON (recv_id=poreject_recv_id) WHERE (pohead_id=pPoheadid) GROUP BY poreject_id, pohead_number, poreject_poitem_id, poitem_id, poitem_prj_id, poitem_expcat_id, poitem_linenumber, poitem_unitprice, pohead_curr_id, pohead_orderdate, itemsite_id, poitem_invvenduomratio, itemsite_item_id, itemsite_costmethod, itemsite_controlmethod, recv_date, recv_purchcost_curr_id, recv_purchcost LOOP IF (_p.itemsiteid = -1) THEN SELECT insertGLTransaction( 'S/R', 'PO', _p.pohead_number, 'Return Non-Inventory to P/O', expcat_liability_accnt_id, getPrjAccntId(_p.poitem_prj_id, expcat_exp_accnt_id), -1, round(_p.poitem_unitprice_base * _p.totalqty * -1, 2), CURRENT_DATE ) INTO _returnval FROM expcat WHERE (expcat_id=_p.poitem_expcat_id); UPDATE poreject SET poreject_posted=TRUE, poreject_value= round(_p.poitem_unitprice_base * _p.totalqty, 2) WHERE (poreject_id=_p.poreject_id); ELSEIF (_p.itemsite_controlmethod='N') THEN SELECT insertGLTransaction('S/R', 'PO', _p.pohead_number, 'Return Non-Controlled Inventory from PO', costcat_liability_accnt_id, getPrjAccntId(_p.poitem_prj_id, costcat_exp_accnt_id), -1, round((_p.poitem_unitprice_base * _p.totalqty * -1), 2), CURRENT_DATE ) INTO _returnval FROM itemsite, costcat WHERE((itemsite_costcat_id=costcat_id) AND (itemsite_id=_p.itemsiteid)); IF (_returnval = -3) THEN -- zero value transaction _returnval := 0; END IF; UPDATE poreject SET poreject_posted=TRUE, poreject_value= round(_p.poitem_unitprice_base * _p.totalqty, 2) WHERE (poreject_id=_p.poreject_id); ELSE IF (_itemlocSeries = 0) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; END IF; SELECT postInvTrans( itemsite_id, 'RP', (_p.totalqty * _p.poitem_invvenduomratio * -1), 'S/R', 'PO', (_p.pohead_number || '-' || _p.poitem_linenumber::TEXT), '', 'Return Inventory to P/O', costcat_asset_accnt_id, costcat_liability_accnt_id, _itemlocSeries, CURRENT_TIMESTAMP) INTO _returnval FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_p.itemsiteid) ); UPDATE poreject SET poreject_posted=TRUE, poreject_value=(invhist_unitcost *_p.totalqty * _p.poitem_invvenduomratio) FROM invhist WHERE ((poreject_id=_p.poreject_id) AND (invhist_id=_returnval)); END IF; IF (_returnval < 0) THEN RETURN _returnval; END IF; UPDATE poitem SET poitem_qty_returned=(poitem_qty_returned + _p.totalqty), poitem_status='O' WHERE (poitem_id=_p.poitem_id); IF (fetchMetricBool('RecordPPVonReceipt')) THEN -- If the 'Purchase Price Variance on Receipt' option is true _invhistid := _returnval; -- Find the difference in the purchase price value expected from the P/O and the value of the transaction SELECT ((_p.poitem_unitprice_base * poitem_qty_returned) - (invhist_value_before - invhist_value_after)) INTO _pricevar FROM invhist, poitem WHERE ((invhist_id = _invhistid) AND (poitem_id=_p.poitem_id)); -- If difference exists then IF (_pricevar <> 0.00) THEN -- Record an additional GL Transaction for the purchase price variance SELECT insertGLTransaction( _journalNumber, 'S/R', 'PO', _p.pohead_number, 'Purchase price variance adjusted for P/O ' || _p.pohead_number || ' for item ' || _p.poitem_linenumber::TEXT, costcat_liability_accnt_id, getPrjAccntId(_p.poitem_prj_id, costcat_purchprice_accnt_id), -1, _pricevar, CURRENT_DATE, false ) INTO _tmp FROM itemsite, costcat, poitem WHERE ((itemsite_costcat_id=costcat_id) AND (itemsite_id=poitem_itemsite_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Could not insert G/L transaction: no cost category found for itemsite_id %', _p.itemsiteid; ELSIF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction RETURN _tmp; ELSE -- Posting to trial balance is deferred to prevent locking INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries) VALUES ( _tmp, _itemlocSeries ); END IF; END IF; END IF; IF (pCreateMemo) THEN SELECT postPoReturnCreditMemo(_p.poreject_id) INTO _returnval; END IF; IF (_returnval < 0) THEN RETURN _returnval; END IF; END LOOP; RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.postporeturns(integer, boolean) OWNER TO admin; -- -- Name: postproduction(integer, numeric, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postproduction(integer, numeric, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'postProduction(INTEGER, NUMERIC, BOOLEAN, BOOLEAN) is deprecated. please use postProduction(INTEGER, NUMERIC, BOOLEAN, INTEGER, TIMESTAMP WITH TIME ZONE) instead'; RETURN postProduction($1, $2, $3, 0, now()); END; $_$; ALTER FUNCTION public.postproduction(integer, numeric, boolean, boolean) OWNER TO admin; -- -- Name: postproduction(integer, numeric, boolean, boolean, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postproduction(integer, numeric, boolean, boolean, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'postProduction(INTEGER, NUMERIC, BOOLEAN, BOOLEAN, INTEGER) is deprecated. please use postProduction(INTEGER, NUMERIC, BOOLEAN, INTEGER, TIMESTAMP WITH TIME ZONE) instead'; RETURN postProduction($1, $2, $3, $5, now()); END; $_$; ALTER FUNCTION public.postproduction(integer, numeric, boolean, boolean, integer) OWNER TO admin; -- -- Name: postproduction(integer, numeric, boolean, integer, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postproduction(integer, numeric, boolean, integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pQty ALIAS FOR $2; pBackflush ALIAS FOR $3; pItemlocSeries ALIAS FOR $4; pGlDistTS ALIAS FOR $5; _test INTEGER; _invhistid INTEGER; _itemlocSeries INTEGER; _parentQty NUMERIC; _r RECORD; _sense TEXT; _wipPost NUMERIC; _woNumber TEXT; _ucost NUMERIC; BEGIN IF (pQty = 0) THEN RETURN 0; ELSIF (pQty > 0) THEN _sense = 'from'; ELSE _sense = 'to'; END IF; IF ( ( SELECT wo_status FROM wo WHERE (wo_id=pWoid) ) NOT IN ('R','E','I') ) THEN RETURN -1; END IF; -- Make sure that all Component Item Sites exist SELECT bomitem_id INTO _test FROM wo, bomitem, itemsite WHERE ( (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=bomitem_parent_item_id) AND (woEffectiveDate(wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND (wo_id=pWoid) AND (bomitem_rev_id=wo_bom_rev_id) AND (bomitem_item_id NOT IN ( SELECT component.itemsite_item_id FROM itemsite AS component, itemsite AS parent WHERE ( (wo_itemsite_id=parent.itemsite_id) AND (parent.itemsite_item_id=bomitem_parent_item_id) AND (bomitem_item_id=component.itemsite_item_id) AND (woEffectiveDate(wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND (bomitem_rev_id=wo_bom_rev_id) AND (component.itemsite_active) AND (component.itemsite_warehous_id=parent.itemsite_warehous_id) ) ) ) ) LIMIT 1; IF (FOUND AND pBackflush) THEN RETURN -2; END IF; SELECT formatWoNumber(pWoid) INTO _woNumber; SELECT roundQty(item_fractional, pQty) INTO _parentQty FROM wo, itemsite, item WHERE ((wo_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (wo_id=pWoid)); -- Create the material receipt transaction IF (pItemlocSeries = 0) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; ELSE _itemlocSeries = pItemlocSeries; END IF; IF (pBackflush) THEN FOR _r IN SELECT womatl_id, womatl_qtyiss + (CASE WHEN (womatl_qtywipscrap > ((womatl_qtyfxd + (_parentQty + wo_qtyrcv) * womatl_qtyper) * womatl_scrap)) THEN (womatl_qtyfxd + (_parentQty + wo_qtyrcv) * womatl_qtyper) * womatl_scrap ELSE womatl_qtywipscrap END) AS consumed, (womatl_qtyfxd + ((_parentQty + wo_qtyrcv) * womatl_qtyper)) * (1 + womatl_scrap) AS expected FROM womatl, wo, itemsite, item WHERE ((womatl_issuemethod IN ('L', 'M')) AND (womatl_wo_id=pWoid) AND (womatl_wo_id=wo_id) AND (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id)) LOOP -- Don't issue more than should have already been consumed at this point IF (pQty > 0) THEN IF (noNeg(_r.expected - _r.consumed) > 0) THEN SELECT issueWoMaterial(_r.womatl_id, noNeg(_r.expected - _r.consumed), _itemlocSeries, pGlDistTS) INTO _itemlocSeries; END IF; ELSE -- Used by postMiscProduction of disassembly SELECT returnWoMaterial(_r.womatl_id, (_r.expected * -1.0), _itemlocSeries, CURRENT_TIMESTAMP, true) INTO _itemlocSeries; END IF; UPDATE womatl SET womatl_issuemethod='L' WHERE ( (womatl_issuemethod='M') AND (womatl_id=_r.womatl_id) ); END LOOP; END IF; SELECT CASE WHEN (pQty < 0 AND itemsite_costmethod='S') THEN stdcost(itemsite_item_id) * pQty WHEN (pQty < 0) THEN avgcost(itemsite_id) * pQty WHEN (wo_cosmethod = 'D') THEN wo_wipvalue ELSE round((wo_wipvalue - (wo_postedvalue / wo_qtyord * (wo_qtyord - CASE WHEN (wo_qtyord < wo_qtyrcv + pQty) THEN wo_qtyord ELSE wo_qtyrcv + pQty END ))),2) END INTO _wipPost FROM wo JOIN itemsite ON (wo_itemsite_id=itemsite_id) WHERE (wo_id=pWoid); SELECT postInvTrans( itemsite_id, 'RM', _parentQty, 'W/O', 'WO', _woNumber, '', ('Receive Inventory ' || item_number || ' ' || _sense || ' Manufacturing'), costcat_asset_accnt_id, getPrjAccntId(wo_prj_id, costcat_wip_accnt_id), _itemlocSeries, pGlDistTS, -- the following is only actually used when the item is average or job costed _wipPost ) INTO _invhistid FROM wo, itemsite, item, costcat WHERE ( (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (itemsite_costcat_id=costcat_id) AND (wo_id=pWoid) ); IF (pQty < 0 ) THEN _wipPost := _wipPost * -1; END IF; -- Increase this W/O's received qty decrease its WIP value UPDATE wo SET wo_qtyrcv = (wo_qtyrcv + _parentQty), wo_wipvalue = (wo_wipvalue - (CASE WHEN (itemsite_costmethod IN ('A','J')) THEN _wipPost WHEN (itemsite_costmethod='S') THEN (stdcost(itemsite_item_id) * _parentQty) ELSE 0.0 END)) FROM itemsite, item WHERE ((wo_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (wo_id=pWoid)); -- ROB Increase this W/O's WIP value for custom costing SELECT SUM(itemcost_stdcost * _parentQty) INTO _ucost FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id) JOIN itemcost ON (itemcost_item_id=itemsite_item_id) JOIN costelem ON ((costelem_id=itemcost_costelem_id) AND (costelem_exp_accnt_id IS NOT NULL) AND (NOT costelem_sys)) WHERE (wo_id=pWoid); UPDATE wo SET wo_wipvalue = (wo_wipvalue + coalesce(_ucost,0)) WHERE (wo_id=pWoid); -- ROB Distribute to G/L - create Cost Variance, debit WIP PERFORM insertGLTransaction( 'W/O', 'WO', _woNumber, ('Post Other Cost ' || item_number || ' ' || _sense || ' Manufacturing'), getPrjAccntId(wo_prj_id, costelem_exp_accnt_id), getPrjAccntId(wo_prj_id,costcat_wip_accnt_id), _invhistid, (itemcost_stdcost * _parentQty), pGlDistTS::DATE ) FROM wo, costelem, itemcost, costcat, itemsite, item WHERE ((wo_id=pWoid) AND (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (costelem_id = itemcost_costelem_id) AND (itemcost_item_id = itemsite_item_id) AND (itemsite_costcat_id = costcat_id) AND (costelem_exp_accnt_id) IS NOT NULL AND (costelem_sys = false)); --End -- Make sure the W/O is at issue status UPDATE wo SET wo_status='I' WHERE (wo_id=pWoid); RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.postproduction(integer, numeric, boolean, integer, timestamp with time zone) OWNER TO admin; -- -- Name: postproduction(integer, numeric, boolean, boolean, integer, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postproduction(integer, numeric, boolean, boolean, integer, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'postProduction(INTEGER, NUMERIC, BOOLEAN, BOOLEAN, INTEGER, TEXT, TEXT) is deprecated. please use postProduction(INTEGER, NUMERIC, BOOLEAN, INTEGER, TIMESTAMP WITH TIME ZONE) instead'; RETURN postProduction($1, $2, $3, $5, now()); END; $_$; ALTER FUNCTION public.postproduction(integer, numeric, boolean, boolean, integer, text, text) OWNER TO admin; -- -- Name: postreceipt(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postreceipt(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE precvid ALIAS FOR $1; _itemlocSeries INTEGER := COALESCE($2, 0); _freightAccnt INTEGER; _glDate TIMESTAMP WITH TIME ZONE; _o RECORD; _ordertypeabbr TEXT; _r RECORD; _ra RECORD; _recvinvqty NUMERIC := 0.00; _recvvalue NUMERIC := 0.00; _pricevar NUMERIC := 0.00; _tmp INTEGER; _toitemitemid INTEGER; _coheadid INTEGER; _coitemid INTEGER; _linenumber INTEGER; _invhistid INTEGER; _shipheadid INTEGER; _ship BOOLEAN; _i RECORD; BEGIN SELECT recv_id, recv_order_type, recv_orderitem_id, recv_qty, round(currToBase(recv_freight_curr_id, recv_freight, recv_date::DATE), 2) AS recv_freight_base, recv_freight, recv_freight_curr_id, recv_date, recv_gldistdate, itemsite_id, itemsite_item_id, item_inv_uom_id, itemsite_costmethod, itemsite_controlmethod, vend_name, item_number, item_fractional INTO _r FROM recv LEFT OUTER JOIN itemsite ON (recv_itemsite_id=itemsite_id) LEFT OUTER JOIN item ON (itemsite_item_id=item_id) LEFT OUTER JOIN vendinfo ON (recv_vend_id=vend_id) WHERE ((recv_id=precvid) AND (NOT recv_posted)); IF (NOT FOUND) THEN IF (_itemlocSeries = 0) THEN RETURN -10; END IF; RETURN _itemlocSeries; ELSEIF (_r.recv_qty <= 0) THEN RETURN -11; ELSIF (_r.recv_order_type ='PO') THEN _ordertypeabbr := ('P/O for ' || _r.vend_name || ' for item ' || _r.item_number); SELECT pohead_number AS orderhead_number, poitem_id AS orderitem_id, poitem_linenumber AS orderitem_linenumber, currToBase(pohead_curr_id, COALESCE(recv_purchcost, poitem_unitprice), recv_date::DATE) AS item_unitprice_base, poitem_invvenduomratio AS invvenduomratio, pohead_orderdate AS orderdate, pohead_dropship, poitem_prj_id AS prj_id INTO _o FROM recv, pohead, poitem WHERE ((recv_orderitem_id=poitem_id) AND (poitem_pohead_id=pohead_id) AND (NOT recv_posted) AND (recv_id=precvid)); ELSIF (_r.recv_order_type ='RA') THEN _ordertypeabbr := 'R/A for item ' || _r.item_number; SELECT rahead_id AS orderhead_id, rahead_number AS orderhead_number, raitem_id AS orderitem_id, raitem_linenumber AS orderitem_linenumber, currToBase(rahead_curr_id, raitem_unitprice, recv_date::DATE) AS item_unitprice_base, raitem_qty_invuomratio AS invvenduomratio, rahead_authdate AS orderdate, raitem_unitcost AS unitcost, rahead_prj_id AS prj_id INTO _o FROM recv, rahead, raitem WHERE ((recv_orderitem_id=raitem_id) AND (raitem_rahead_id=rahead_id) AND (NOT recv_posted) AND (recv_id=precvid)); ELSIF (_r.recv_order_type ='TO') THEN _ordertypeabbr := 'T/O for item ' || _r.item_number; SELECT tohead_number AS orderhead_number, toitem_id AS orderitem_id, toitem_linenumber AS orderitem_linenumber, toitem_stdcost AS item_unitprice_base, 1.0 AS invvenduomratio, tohead_orderdate AS orderdate, NULL AS prj_id INTO _o FROM recv, tohead, toitem WHERE ((recv_orderitem_id=toitem_id) AND (toitem_tohead_id=tohead_id) AND (NOT recv_posted) AND (recv_id=precvid)); ELSE RETURN -13; -- don't know how to handle this order type END IF; IF (NOT FOUND) THEN IF (_itemlocSeries = 0) THEN RETURN -10; END IF; RETURN _itemlocSeries; END IF; IF (_itemlocSeries = 0) THEN _itemlocSeries := NEXTVAL('itemloc_series_seq'); ELSEIF (_itemlocSeries < 0) THEN RETURN _itemlocSeries; END IF; _glDate := COALESCE(_r.recv_gldistdate, _r.recv_date); _recvinvqty := roundQty(_r.item_fractional, (_r.recv_qty * _o.invvenduomratio)); IF ( (_r.recv_order_type = 'PO') AND (_r.itemsite_id = -1 OR _r.itemsite_id IS NULL OR _r.itemsite_controlmethod = 'N') ) THEN IF (_r.itemsite_id IS NOT NULL) THEN SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'), 'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Non-Controlled Inventory from ' || _ordertypeabbr, costcat_liability_accnt_id, getPrjAccntId(_o.prj_id, costcat_exp_accnt_id), -1, round((_o.item_unitprice_base * _r.recv_qty),2), _glDate::DATE, false ) INTO _tmp FROM poitem, itemsite, costcat WHERE((poitem_itemsite_id=itemsite_id) AND (itemsite_costcat_id=costcat_id) AND (poitem_id=_o.orderitem_id)); ELSE SELECT insertGLTransaction(fetchJournalNumber('GL-MISC'), 'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Non-Inventory from ' || 'P/O for ' || _r.vend_name || ' for ' || expcat_code, expcat_liability_accnt_id, getPrjAccntId(_o.prj_id, expcat_exp_accnt_id), -1, round((_o.item_unitprice_base * _r.recv_qty),2), _glDate::DATE, false ) INTO _tmp FROM poitem, expcat WHERE((poitem_expcat_id=expcat_id) AND (poitem_id=_o.orderitem_id)); END IF; IF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction RETURN _tmp; ELSE -- Posting to trial balance is deferred to prevent locking INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries) VALUES ( _tmp, _itemlocSeries ); END IF; SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'), 'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Non-Inventory Freight from ' || _ordertypeabbr, expcat_liability_accnt_id, getPrjAccntId(_o.prj_id, expcat_freight_accnt_id), -1, _r.recv_freight_base, _glDate::DATE, false ), expcat_freight_accnt_id INTO _tmp, _freightAccnt FROM poitem, expcat WHERE((poitem_expcat_id=expcat_id) AND (poitem_id=_o.orderitem_id)); IF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction RETURN _tmp; ELSE -- Posting to trial balance is deferred to prevent locking INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries) VALUES ( _tmp, _itemlocSeries ); END IF; _recvvalue := ROUND((_o.item_unitprice_base * _r.recv_qty),2); UPDATE poitem SET poitem_qty_received = (poitem_qty_received + _r.recv_qty), poitem_freight_received = (poitem_freight_received + _r.recv_freight) WHERE (poitem_id=_o.orderitem_id); ELSEIF ( (_r.recv_order_type = 'RA') AND (_r.itemsite_id = -1 OR _r.itemsite_id IS NULL) ) THEN RAISE WARNING 'itemsite controlmethod is %, cannot post receipt.', _r.itemsite_controlmethod; RETURN -14; -- otherwise how do we get the accounts? ELSEIF ( (_r.recv_order_type = 'TO') AND (_r.itemsite_id = -1 OR _r.itemsite_id IS NULL) ) THEN RAISE WARNING 'itemsite missing'; RETURN -14; -- otherwise how do we get the accounts? ELSE -- not ELSIF: some code is shared between diff order types IF (_r.recv_order_type = 'PO') THEN SELECT postInvTrans( itemsite_id, 'RP'::TEXT, _recvinvqty, 'S/R'::TEXT, _r.recv_order_type::TEXT, _o.orderhead_number::TEXT || '-' || _o.orderitem_linenumber::TEXT, ''::TEXT, 'Receive Inventory from ' || _ordertypeabbr, costcat_asset_accnt_id, costcat_liability_accnt_id, _itemlocSeries, _glDate, round((_o.item_unitprice_base * _r.recv_qty),2) -- always passing this in since it is ignored if it is not average costed item ) INTO _tmp FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_r.itemsite_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Could not post inventory transaction: no cost category found for itemsite_id %', _r.itemsite_id; ELSIF (_tmp < -1) THEN -- less than -1 because -1 means it is a none controlled item IF(_tmp = -3) THEN RETURN -12; -- The GL trans value was 0 which means we likely do not have a std cost END IF; RETURN _tmp; END IF; -- If the 'Purchase Price Variance on Receipt' option is true IF (fetchMetricBool('RecordPPVonReceipt')) THEN _invhistid := _tmp; -- Find the difference in the purchase price value expected from the P/O and the value of the transaction SELECT ((_o.item_unitprice_base * _r.recv_qty) - (invhist_value_after - invhist_value_before)) INTO _pricevar FROM invhist WHERE (invhist_id = _invhistid); -- If difference exists then IF (_pricevar <> 0.00) THEN -- Record an additional GL Transaction for the purchase price variance SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'), 'S/R', _r.recv_order_type, _o.orderhead_number, 'Purchase price variance adjusted for P/O ' || _o.orderhead_number || ' for item ' || _r.item_number, costcat_liability_accnt_id, getPrjAccntId(_o.prj_id, costcat_purchprice_accnt_id), -1, _pricevar, _glDate::DATE, false ) INTO _tmp FROM itemsite, costcat WHERE ((itemsite_costcat_id=costcat_id) AND (itemsite_id=_r.itemsite_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Could not insert G/L transaction: no cost category found for itemsite_id %', _r.itemsite_id; ELSIF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction RETURN _tmp; ELSE -- Posting to trial balance is deferred to prevent locking INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries) VALUES ( _tmp, _itemlocSeries ); END IF; END IF; END IF; SELECT insertGLTransaction(fetchJournalNumber('GL-MISC'), 'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Inventory Freight from ' || _o.orderhead_number || ' for item ' || _r.item_number, costcat_liability_accnt_id, getPrjAccntId(_o.prj_id, costcat_freight_accnt_id), -1, _r.recv_freight_base, _glDate::DATE, false ), costcat_freight_accnt_id INTO _tmp, _freightAccnt FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_r.itemsite_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Could not insert G/L transaction: no cost category found for itemsite_id %', _r.itemsite_id; ELSIF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction RETURN _tmp; ELSE -- Posting to trial balance is deferred to prevent locking INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries) VALUES ( _tmp, _itemlocSeries ); END IF; UPDATE poitem SET poitem_qty_received = (poitem_qty_received + _r.recv_qty), poitem_freight_received = (poitem_freight_received + _r.recv_freight) WHERE (poitem_id=_o.orderitem_id); ELSIF (_r.recv_order_type = 'RA') THEN SELECT rahead.*, raitem.* INTO _ra FROM rahead, raitem WHERE ((rahead_id=raitem_rahead_id) AND (raitem_id=_r.recv_orderitem_id)); IF (_r.itemsite_controlmethod = 'N') THEN SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'), 'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Non-Controlled Inventory from ' || _ordertypeabbr, costcat_liability_accnt_id, getPrjAccntId(_o.prj_id, costcat_exp_accnt_id), -1, round((_o.item_unitprice_base * _r.recv_qty),2), _glDate::DATE, false ) INTO _tmp FROM itemsite JOIN costcat ON (costcat_id=itemsite_costcat_id) WHERE(itemsite_id=_r.itemsite_id); IF (NOT FOUND) THEN RAISE EXCEPTION 'Could not post inventory transaction: no cost category found for itemsite_id %', _r.itemsite_id; -- ELSIF (_tmp < -1) THEN -- RETURN _tmp; END IF; ELSE SELECT postInvTrans(_r.itemsite_id, 'RR', _recvinvqty, 'S/R', _r.recv_order_type, _ra.rahead_number::TEXT || '-' || _ra.raitem_linenumber::TEXT, '', 'Receive Inventory from ' || _ordertypeabbr, costcat_asset_accnt_id, CASE WHEN(COALESCE(_ra.raitem_cos_accnt_id, -1) != -1) THEN getPrjAccntId(_o.prj_id, _ra.raitem_cos_accnt_id) WHEN (_ra.raitem_warranty) THEN getPrjAccntId(_o.prj_id, resolveCOWAccount(_r.itemsite_id, _ra.rahead_cust_id, _ra.rahead_saletype_id, _ra.rahead_shipzone_id)) ELSE getPrjAccntId(_o.prj_id, resolveCORAccount(_r.itemsite_id, _ra.rahead_cust_id, _ra.rahead_saletype_id, _ra.rahead_shipzone_id)) END, _itemlocSeries, _glDate, COALESCE(_o.unitcost,stdcost(itemsite_item_id)) * _recvinvqty) INTO _tmp FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_r.itemsite_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Could not post inventory transaction: no cost category found for itemsite_id %', _r.itemsite_id; ELSIF (_tmp < -1) THEN -- less than -1 because -1 means it is a none controlled item IF(_tmp = -3) THEN RAISE WARNING 'The GL trans value was 0 which means we likely do not have a std cost'; RETURN -12; -- The GL trans value was 0 which means we likely do not have a std cost END IF; RETURN _tmp; END IF; END IF; INSERT INTO rahist (rahist_itemsite_id, rahist_date, rahist_descrip, rahist_qty, rahist_uom_id, rahist_source, rahist_source_id, rahist_rahead_id ) VALUES (_r.itemsite_id, _glDate, 'Receive Inventory from ' || _ordertypeabbr, _recvinvqty, _r.item_inv_uom_id, 'RR', _r.recv_id, _ra.rahead_id ); SELECT insertGLTransaction(fetchJournalNumber('GL-MISC'), 'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Inventory Freight from ' || _o.orderhead_number || ' for item ' || _r.item_number, costcat_liability_accnt_id, getPrjAccntId(_o.prj_id, costcat_freight_accnt_id), -1, _r.recv_freight_base, _glDate::DATE, false ), costcat_freight_accnt_id INTO _tmp, _freightAccnt FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_r.itemsite_id) ); IF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction RETURN _tmp; ELSE -- Posting to trial balance is deferred to prevent locking INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries) VALUES ( _tmp, _itemlocSeries ); END IF; INSERT INTO rahist (rahist_date, rahist_descrip, rahist_source, rahist_source_id, rahist_curr_id, rahist_amount, rahist_rahead_id ) VALUES (_glDate, 'Receive Inventory Freight from ' || _ordertypeabbr, 'RR', _r.recv_id, _r.recv_freight_curr_id, _r.recv_freight, _ra.rahead_id ); UPDATE raitem SET raitem_qtyreceived = (raitem_qtyreceived + _r.recv_qty) WHERE (raitem_id=_o.orderitem_id); -- Expire date doesn't mean anything once the RA is received -- WARNING: INSERTING 'NULL' MIGHT CAUSE PROBLEMS!! UPDATE rahead SET rahead_expiredate = NULL WHERE (rahead_id=_o.orderhead_id); -- Look for 'ship' lines SELECT (count(*) > 0) INTO _ship FROM raitem WHERE ((raitem_disposition = 'S') AND (raitem_new_coitem_id IS NULL) AND (raitem_rahead_id=_ra.rahead_id)); -- If receiving a qty on a shippable and upon receipt item, create coitem IF ((_ra.rahead_timing='R') AND (_ship OR ( (_ra.raitem_disposition IN ('P','V')) AND (_ra.raitem_new_coitem_id IS NULL) AND (_ra.raitem_qtyauthorized > 0)))) THEN IF (_ra.rahead_new_cohead_id IS NOT NULL) THEN _coheadid = _ra.rahead_new_cohead_id; ELSE -- No header, so create a Sales Order header first. SELECT nextval('cohead_cohead_id_seq') INTO _coheadid; INSERT INTO cohead ( cohead_id,cohead_number,cohead_cust_id,cohead_custponumber, cohead_orderdate,cohead_salesrep_id,cohead_terms_id, cohead_shipvia,cohead_shipto_id,cohead_shiptoname, cohead_shiptoaddress1,cohead_shiptoaddress2,cohead_shiptoaddress3, cohead_shiptocity,cohead_shiptostate,cohead_shiptozipcode, cohead_shiptocountry,cohead_freight,cohead_shiptophone, cohead_shipto_cntct_id, cohead_shipto_cntct_honorific, cohead_shipto_cntct_first_name, cohead_shipto_cntct_middle, cohead_shipto_cntct_last_name, cohead_shipto_cntct_suffix, cohead_shipto_cntct_phone, cohead_shipto_cntct_title, cohead_shipto_cntct_fax, cohead_shipto_cntct_email, cohead_shipchrg_id, cohead_shipform_id,cohead_billtoname, cohead_billtoaddress1,cohead_billtoaddress2,cohead_billtoaddress3, cohead_billtocity,cohead_billtostate,cohead_billtozipcode, cohead_billtocountry,cohead_misc_accnt_id,cohead_misc_descrip, cohead_commission,cohead_holdtype,cohead_prj_id,cohead_shipcomplete, cohead_curr_id,cohead_taxzone_id,cohead_saletype_id,cohead_shipzone_id) SELECT _coheadid,fetchsonumber(),rahead_cust_id,rahead_custponumber, current_date,rahead_salesrep_id,COALESCE(cohead_terms_id,cust_terms_id), COALESCE(cohead_shipvia,cust_shipvia),rahead_shipto_id,rahead_shipto_name, rahead_shipto_address1,rahead_shipto_address2,rahead_shipto_address3, rahead_shipto_city,rahead_shipto_state,rahead_shipto_zipcode, rahead_shipto_country,0,COALESCE(cohead_shiptophone,''), cntct_id, cntct_honorific, cntct_first_name, cntct_middle, cntct_last_name, cntct_suffix, cntct_phone, cntct_title, cntct_fax, cntct_email, COALESCE(cohead_shipchrg_id,cust_shipchrg_id), COALESCE(cohead_shipform_id,cust_shipform_id), rahead_billtoname,rahead_billtoaddress1,rahead_billtoaddress2,rahead_billtoaddress3, rahead_billtocity,rahead_billtostate,rahead_billtozip, rahead_billtocountry,NULL,'',rahead_commission, 'N', rahead_prj_id, COALESCE(cohead_shipcomplete, CASE WHEN cust_partialship THEN false ELSE true END),rahead_curr_id,rahead_taxzone_id,rahead_saletype_id,rahead_shipzone_id FROM rahead JOIN custinfo ON (rahead_cust_id=cust_id) LEFT OUTER JOIN cohead ON (rahead_orig_cohead_id=cohead_id) LEFT OUTER JOIN shiptoinfo ON (rahead_shipto_id=shipto_id) LEFT OUTER JOIN cntct ON (shipto_cntct_id=cntct_id) WHERE (rahead_id=_ra.rahead_id); UPDATE rahead SET rahead_new_cohead_id=_coheadid WHERE rahead_id=_ra.rahead_id; END IF; -- Now enter the line item(s) IF (_ra.raitem_disposition IN ('P','V')) AND (_ra.raitem_new_coitem_id IS NULL) AND (_ra.raitem_qtyauthorized > 0) THEN SELECT nextval('coitem_coitem_id_seq') INTO _coitemid; SELECT COALESCE(MAX(coitem_linenumber),0)+1 INTO _linenumber FROM coitem WHERE (coitem_cohead_id=_coheadid); INSERT INTO coitem ( coitem_id,coitem_cohead_id,coitem_linenumber,coitem_itemsite_id, coitem_status,coitem_scheddate,coitem_promdate, coitem_qtyord, coitem_unitcost,coitem_price,coitem_custprice,coitem_qtyshipped, coitem_order_id,coitem_memo,coitem_qtyreturned, coitem_taxtype_id,coitem_qty_uom_id,coitem_qty_invuomratio, coitem_price_uom_id,coitem_price_invuomratio,coitem_warranty, coitem_cos_accnt_id,coitem_order_type, coitem_custpn) SELECT _coitemid,_coheadid,_linenumber,_ra.raitem_coitem_itemsite_id, 'O',_ra.raitem_scheddate,_ra.raitem_scheddate,_ra.raitem_qtyauthorized, stdcost(itemsite_item_id),COALESCE(_ra.raitem_saleprice,0),0,0, -1,_ra.raitem_notes,0, _ra.raitem_taxtype_id,_ra.raitem_qty_uom_id,_ra.raitem_qty_invuomratio, _ra.raitem_price_uom_id,_ra.raitem_price_invuomratio,_ra.raitem_warranty, _ra.raitem_cos_accnt_id, CASE WHEN itemsite_createwo THEN 'W' ELSE NULL END, _ra.raitem_custpn FROM itemsite WHERE (itemsite_id=_ra.raitem_coitem_itemsite_id); UPDATE raitem SET raitem_new_coitem_id=_coitemid WHERE (raitem_id=_ra.raitem_id); END IF; -- Create items to ship that have no direct relation to receipts. IF (_ship) THEN FOR _i IN SELECT raitem_id FROM raitem WHERE ((raitem_rahead_id=_ra.rahead_id) AND (raitem_disposition = 'S') AND (raitem_new_coitem_id IS NULL)) LOOP SELECT nextval('coitem_coitem_id_seq') INTO _coitemid; SELECT COALESCE(MAX(coitem_linenumber),0)+1 INTO _linenumber FROM coitem WHERE (coitem_cohead_id=_coheadid); INSERT INTO coitem ( coitem_id,coitem_cohead_id,coitem_linenumber,coitem_itemsite_id, coitem_status,coitem_scheddate,coitem_promdate, coitem_qtyord, coitem_unitcost,coitem_price,coitem_custprice,coitem_qtyshipped, coitem_order_id,coitem_memo,coitem_qtyreturned, coitem_taxtype_id,coitem_qty_uom_id,coitem_qty_invuomratio, coitem_price_uom_id,coitem_price_invuomratio,coitem_warranty, coitem_cos_accnt_id,coitem_order_type,coitem_custpn) SELECT _coitemid,_coheadid,_linenumber,raitem_coitem_itemsite_id, 'O',raitem_scheddate,raitem_scheddate,raitem_qtyauthorized, stdcost(itemsite_item_id),COALESCE(raitem_saleprice,0),0,0, -1,raitem_notes,0, raitem_taxtype_id,raitem_qty_uom_id,raitem_qty_invuomratio, raitem_price_uom_id,raitem_price_invuomratio,raitem_warranty, raitem_cos_accnt_id, CASE WHEN itemsite_createwo THEN 'W' ELSE NULL END,raitem_custpn FROM raitem JOIN itemsite ON (itemsite_id=raitem_itemsite_id) WHERE (raitem_id=_i.raitem_id); UPDATE raitem SET raitem_new_coitem_id=_coitemid WHERE (raitem_id=_i.raitem_id); END LOOP; END IF; END IF; ELSIF (_r.recv_order_type = 'TO' AND fetchMetricBool('MultiWhs')) THEN SELECT interWarehouseTransfer(toitem_item_id, tohead_trns_warehous_id, tohead_dest_warehous_id, _r.recv_qty, 'TO', formatToNumber(toitem_id), 'Receive from Transit To Dest Warehouse', _itemlocSeries, _glDate ) INTO _tmp FROM tohead, toitem WHERE ((tohead_id=toitem_tohead_id) AND (toitem_id=_r.recv_orderitem_id)); IF (_tmp < 0) THEN RETURN _tmp; END IF; SELECT insertGLTransaction(fetchJournalNumber('GL-MISC'), 'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Inventory Freight from ' || _o.orderhead_number || ' for item ' || _r.item_number, costcat_toliability_accnt_id, costcat_freight_accnt_id, -1, _r.recv_freight_base, _glDate::DATE, false ), costcat_freight_accnt_id INTO _tmp, _freightAccnt FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_r.itemsite_id) ); IF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction RETURN _tmp; ELSE -- Posting to trial balance is deferred to prevent locking INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries) VALUES ( _tmp, _itemlocSeries ); END IF; UPDATE toitem SET toitem_qty_received = (toitem_qty_received + _r.recv_qty), toitem_freight_received = (toitem_freight_received + currToCurr(_r.recv_freight_curr_id, toitem_freight_curr_id, _r.recv_freight, _glDate::DATE)) WHERE (toitem_id=_o.orderitem_id); END IF; IF(_r.itemsite_costmethod='A') THEN _recvvalue := ROUND((_o.item_unitprice_base * _r.recv_qty),2); ELSIF (fetchMetricBool('RecordPPVonReceipt')) THEN _recvvalue := ROUND((_o.item_unitprice_base * _r.recv_qty), 2); ELSE _recvvalue := ROUND(stdcost(_r.itemsite_item_id) * _recvinvqty, 2); END IF; END IF; UPDATE recv SET recv_value=_recvvalue, recv_recvcost=_recvvalue / recv_qty, recv_posted=TRUE, recv_gldistdate=_glDate::DATE WHERE (recv_id=precvid); IF (_r.recv_order_type = 'PO') THEN -- If this is a drop-shipped PO, then Issue the item to Shipping and Ship the item IF (_o.pohead_dropship = TRUE) THEN -- Generate the PoItemDropShipped event PERFORM postEvent('PoItemDropShipped', 'P', poitem_id, itemsite_warehous_id, (pohead_number || '-' || poitem_linenumber || ': ' || item_number), NULL, NULL, NULL, NULL) FROM poitem JOIN itemsite ON (itemsite_id=poitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) JOIN pohead ON (pohead_id=poitem_pohead_id) WHERE (poitem_id=_o.orderitem_id) AND (poitem_duedate <= (CURRENT_DATE + itemsite_eventfence)); END IF; END IF; RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.postreceipt(integer, integer) OWNER TO admin; -- -- Name: postreceipts(text, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postreceipts(text, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; porderid ALIAS FOR $2; _itemlocSeries INTEGER := $3; _qtyToRecv NUMERIC; _r RECORD; BEGIN SELECT SUM(qtyToReceive(pordertype, recv_orderitem_id)) INTO _qtyToRecv FROM recv, orderitem WHERE ((recv_orderitem_id=orderitem_id) AND (recv_order_type=pordertype) AND (orderitem_orderhead_type=pordertype) AND (orderitem_orderhead_id=porderid)); IF (_qtyToRecv <= 0) THEN RETURN -11; END IF; IF (_itemlocSeries IS NULL OR _itemlocSeries <= 0) THEN _itemlocSeries := NEXTVAL('itemloc_series_seq'); END IF; FOR _r IN SELECT postReceipt(recv_id, _itemlocSeries) AS postResult FROM recv, orderitem WHERE ((recv_orderitem_id=orderitem_id) AND (orderitem_orderhead_id=porderid) AND (orderitem_orderhead_type=pordertype) AND (NOT recv_posted) -- Check for multiple users receiving the same order AND (recv_trans_usr_name=getEffectiveXtUser()) AND (recv_order_type=pordertype)) LOOP IF (_r.postResult < 0 AND _r.postResult != -11) THEN RETURN _r.postResult; -- fail on 1st error but ignore lines with qty == 0 END IF; END LOOP; RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.postreceipts(text, integer, integer) OWNER TO admin; -- -- Name: postsogltransactions(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postsogltransactions() RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN UPDATE gltrans SET gltrans_exported=TRUE WHERE ( (NOT gltrans_exported) AND (gltrans_source='A/R') AND (gltrans_doctype IN ('IN', 'CM')) ); RETURN TRUE; END; $$; ALTER FUNCTION public.postsogltransactions() OWNER TO admin; -- -- Name: postsoitemproduction(integer, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postsoitemproduction(integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoitemId ALIAS FOR $1; pGlDistTS ALIAS FOR $2; _qty NUMERIC; BEGIN -- Issuing all, so determine line balance SELECT noNeg( coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - ( SELECT COALESCE(SUM(shipitem_qty), 0) FROM shipitem, shiphead WHERE ((shipitem_orderitem_id=coitem_id) AND (shipitem_shiphead_id=shiphead_id) AND (NOT shiphead_shipped) ) ) ) INTO _qty FROM coitem WHERE (coitem_id=pSoitemId); RETURN postSoItemProduction($1, _qty, $2); END; $_$; ALTER FUNCTION public.postsoitemproduction(integer, timestamp with time zone) OWNER TO admin; -- -- Name: postsoitemproduction(integer, numeric, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postsoitemproduction(integer, numeric, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoitemId ALIAS FOR $1; pQty ALIAS FOR $2; pGlDistTS ALIAS FOR $3; _itemlocSeries INTEGER := 0; BEGIN --If this cost method is not Job then we are using the wrong function IF (NOT EXISTS(SELECT itemsite_costmethod FROM coitem,itemsite WHERE ((coitem_id=pSoitemId) AND (coitem_itemsite_id=itemsite_id) AND (itemsite_costmethod = 'J')))) THEN RAISE EXCEPTION 'The postSoLineBalanceProduction function may only be used with Job costed item sites'; END IF; IF (pQty > 0) THEN SELECT COALESCE(postProduction(wo_id, (pQty * coitem_qty_invuomratio), true, 0, pGlDistTS),-1) INTO _itemlocSeries FROM wo, coitem WHERE ((wo_ordid=pSoItemid) AND (wo_ordtype='S') AND (coitem_id=pSoItemid)); UPDATE wo SET wo_status = 'C' WHERE ((wo_ordid=pSoItemid) AND (wo_ordtype='S') AND (wo_qtyrcv >= wo_qtyord)); END IF; RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.postsoitemproduction(integer, numeric, timestamp with time zone) OWNER TO admin; -- -- Name: poststandardjournal(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION poststandardjournal(pstdjrnlid integer, pdate date) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN postStandardJournal(pStdjrnlid, pDate, FALSE, fetchGLSequence()); END; $$; ALTER FUNCTION public.poststandardjournal(pstdjrnlid integer, pdate date) OWNER TO admin; -- -- Name: poststandardjournal(integer, date, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION poststandardjournal(pstdjrnlid integer, pdate date, pglsequence integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN postStandardJournal(pStdjrnlid, pDate, FALSE, pGlSequence); END; $$; ALTER FUNCTION public.poststandardjournal(pstdjrnlid integer, pdate date, pglsequence integer) OWNER TO admin; -- -- Name: poststandardjournal(integer, date, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION poststandardjournal(pstdjrnlid integer, pdate date, preverse boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN postStandardJournal(pStdjrnlid, pDate, pReverse, fetchGLSequence()); END; $$; ALTER FUNCTION public.poststandardjournal(pstdjrnlid integer, pdate date, preverse boolean) OWNER TO admin; -- -- Name: poststandardjournal(integer, date, boolean, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION poststandardjournal(pstdjrnlid integer, pdate date, preverse boolean, pglsequence integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN INSERT INTO glseries ( glseries_sequence, glseries_source, glseries_doctype, glseries_docnumber, glseries_notes, glseries_accnt_id, glseries_amount, glseries_distdate ) SELECT pGlSequence, 'G/L', 'ST', stdjrnl_name, (COALESCE(stdjrnl_notes, '') || ' ' || COALESCE(stdjrnlitem_notes, '')), stdjrnlitem_accnt_id, CASE WHEN (pReverse=TRUE) THEN (stdjrnlitem_amount * -1) ELSE stdjrnlitem_amount END, pDate FROM stdjrnl JOIN stdjrnlitem ON (stdjrnlitem_stdjrnl_id=stdjrnl_id) WHERE (stdjrnl_id=pStdjrnlid); RETURN pGlSequence; END; $$; ALTER FUNCTION public.poststandardjournal(pstdjrnlid integer, pdate date, preverse boolean, pglsequence integer) OWNER TO admin; -- -- Name: poststandardjournalgroup(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION poststandardjournalgroup(integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pStdjrnlgrpid ALIAS FOR $1; pDate ALIAS FOR $2; BEGIN RETURN postStandardJournalGroup(pStdjrnlgrpid, pDate, FALSE); END; $_$; ALTER FUNCTION public.poststandardjournalgroup(integer, date) OWNER TO admin; -- -- Name: poststandardjournalgroup(integer, date, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION poststandardjournalgroup(integer, date, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pStdjrnlgrpid ALIAS FOR $1; pDate ALIAS FOR $2; pReverse ALIAS FOR $3; _r RECORD; _glSequence INTEGER := -1; BEGIN FOR _r IN SELECT stdjrnlgrpitem_id, stdjrnlgrpitem_stdjrnl_id FROM stdjrnlgrpitem WHERE ( (stdjrnlgrpitem_stdjrnlgrp_id=pStdjrnlgrpid) AND (CURRENT_DATE BETWEEN stdjrnlgrpitem_effective AND (stdjrnlgrpitem_expires - 1)) AND ( (stdjrnlgrpitem_toapply = -1) OR (stdjrnlgrpitem_toapply > stdjrnlgrpitem_applied) ) ) LOOP IF (_glSequence = -1) THEN SELECT fetchGLSequence() INTO _glSequence; END IF; PERFORM postStandardJournal(_r.stdjrnlgrpitem_stdjrnl_id, pDate, pReverse, _glSequence); UPDATE stdjrnlgrpitem SET stdjrnlgrpitem_applied=(stdjrnlgrpitem_applied + 1) WHERE (stdjrnlgrpitem_id=_r.stdjrnlgrpitem_id); END LOOP; RETURN _glSequence; END; $_$; ALTER FUNCTION public.poststandardjournalgroup(integer, date, boolean) OWNER TO admin; -- -- Name: postvalueintoinvbalance(integer, date, numeric, numeric, numeric, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postvalueintoinvbalance(integer, date, numeric, numeric, numeric, numeric) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteId ALIAS FOR $1; pDate ALIAS FOR $2; pQoh ALIAS FOR $3; pNn ALIAS FOR $4; pOldCost ALIAS FOR $5; pNewCost ALIAS FOR $6; _invbalid INTEGER; _r RECORD; _count INTEGER; _valChange NUMERIC; _nnvalChange NUMERIC; BEGIN -- Grab the costhist record to post SELECT period_id INTO _r FROM period WHERE (pDate BETWEEN period_start AND period_end); GET DIAGNOSTICS _count = ROW_COUNT; -- Find an inventory balance to post into IF ( _count > 0 ) THEN -- Try to find an existing invbal SELECT invbal_id INTO _invbalid FROM invbal WHERE ( (invbal_period_id=_r.period_id) AND (invbal_itemsite_id=pItemsiteId) ); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count = 0) THEN -- Wasn't there, so forward update PERFORM forwardUpdateItemsite(pItemsiteId); -- Try to find an existing invbal again SELECT invbal_id INTO _invbalid FROM invbal WHERE ( (invbal_period_id=_r.period_id) AND (invbal_itemsite_id=pItemsiteId) ); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count = 0) THEN RAISE EXCEPTION 'An inventory balance record was not found for updating standard costs'; END IF; END IF; _valChange := round((pNewCost - pOldCost) * pQoh, 2); _nnvalChange := round((pNewCost - pOldCost) * pNn, 2); -- We found an invbal, update it with the change IF (_valChange > 0) THEN UPDATE invbal SET invbal_value_in = (invbal_value_in + _valChange) WHERE (invbal_id=_invbalid); ELSE UPDATE invbal SET invbal_value_out = (invbal_value_out - _valChange) WHERE (invbal_id=_invbalid); END IF; IF (_nnvalChange > 0) THEN UPDATE invbal SET invbal_nnval_in = (invbal_nnval_in + _nnvalChange) WHERE (invbal_id=_invbalid); ELSE UPDATE invbal SET invbal_nnval_out = (invbal_nnval_out - _nnvalChange) WHERE (invbal_id=_invbalid); END IF; UPDATE invbal SET invbal_value_ending = (invbal_value_beginning + invbal_value_in - invbal_value_out), invbal_nnval_ending = (invbal_nnval_beginning + invbal_nnval_in - invbal_nnval_out), invbal_dirty=true WHERE (invbal_id=_invbalid); ELSE RAISE EXCEPTION 'No period exists for date %.', pDate; END IF; RETURN TRUE; END; $_$; ALTER FUNCTION public.postvalueintoinvbalance(integer, date, numeric, numeric, numeric, numeric) OWNER TO admin; -- -- Name: postvoucher(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postvoucher(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVoheadid ALIAS FOR $1; pPostCosts ALIAS FOR $2; BEGIN RETURN postVoucher(pVoheadid, fetchJournalNumber('AP-VO'), pPostCosts); END; $_$; ALTER FUNCTION public.postvoucher(integer, boolean) OWNER TO admin; -- -- Name: postvoucher(integer, integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postvoucher(integer, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVoheadid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pPostCosts ALIAS FOR $3; _sequence INTEGER; _totalAmount_base NUMERIC; _totalAmount NUMERIC; _itemAmount_base NUMERIC; _itemAmount NUMERIC; _totalDiscountableAmount NUMERIC; _test INTEGER; _a RECORD; _d RECORD; _g RECORD; _p RECORD; _r RECORD; _costx RECORD; _pPostCosts BOOLEAN; _pExplain BOOLEAN; _pLowLevel BOOLEAN; _exchGainFreight NUMERIC; _taxBaseValue NUMERIC; _firstExchDateFreight DATE; _tmpTotal NUMERIC; _glDate DATE; BEGIN RAISE DEBUG 'postVoucher(%, %, %)', pVoheadid, pJournalNumber, pPostCosts; _pPostCosts := TRUE; _totalAmount_base := 0; _totalAmount := 0; _totalDiscountableAmount := 0; SELECT fetchGLSequence() INTO _sequence; -- Cache Voucher Infomation SELECT vohead.*, vend_number || '-' || vend_name || ' ' || vohead_reference AS glnotes, COALESCE(pohead_orderdate, vohead_docdate) AS pohead_orderdate, COALESCE(pohead_curr_id, vohead_curr_id) AS pohead_curr_id INTO _p FROM vendinfo, vohead LEFT OUTER JOIN pohead ON (vohead_pohead_id = pohead_id) WHERE ( (vohead_id=pVoheadid) AND (vend_id=vohead_vend_id) ) FOR UPDATE OF vohead; IF (_p.vohead_posted) THEN RAISE EXCEPTION 'Cannot post Voucher #% as it is already posted [xtuple: postVoucher, -10, %]', _p.vohead_number, _p.vohead_number; END IF; _glDate := COALESCE(_p.vohead_gldistdate, _p.vohead_distdate); -- If the vohead_distdate is NULL, assume that this is a NULL vohead and quietly delete it IF (_p.vohead_distdate IS NULL) THEN DELETE FROM vohead WHERE vohead_id = pVoheadid; RETURN 0; END IF; IF (_p.vohead_amount <= 0) THEN RAISE EXCEPTION 'Cannot Post Voucher #% for a negative or zero amount (%) [xtuple: postVoucher, -1, %, %]', _p.vohead_number, _p.vohead_amount, _p.vohead_number, _p.vohead_amount; END IF; -- there is no currency gain/loss on items, see issue 3892, -- but there might be on freight, which is first encountered at p/o receipt SELECT recv_date::DATE INTO _firstExchDateFreight FROM recv WHERE (recv_vohead_id = pVoheadid); SELECT round(SUM(amount),4) INTO _tmpTotal FROM ( SELECT SUM(vodist_amount) AS amount FROM vodist WHERE ( (vodist_vohead_id=pVoheadid) AND (vodist_tax_id=-1) ) UNION ALL SELECT SUM(voitem_freight) AS amount FROM voitem WHERE (voitem_vohead_id=pVoheadid) UNION ALL SELECT SUM(tax*-1) FROM (SELECT round(sum(taxdetail_tax),2) AS tax, currToBase(_p.vohead_curr_id, round(sum(taxdetail_tax),2), _p.vohead_docdate) AS taxbasevalue FROM tax JOIN calculateTaxDetailSummary('VO', pVoheadid, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id, tax_sales_accnt_id ) AS taxdata ) AS data; IF (_tmpTotal IS NULL OR _tmpTotal <= 0) THEN RAISE EXCEPTION 'Cannot Post Voucher #% with negative or zero distributions (%) [xtuple: postVoucher, -2, %, %]', _p.vohead_number, _tmpTotal, _p.vohead_number, _tmpTotal; END IF; IF (_tmpTotal > _p.vohead_amount) THEN RAISE EXCEPTION 'Cannot Post Voucher #% with distributions greater than the voucher amount (% > %) [xtuple: postVoucher, -3, %, %, %]', _p.vohead_number, _tmpTotal, _p.vohead_amount, _p.vohead_number, _tmpTotal, _p.vohead_amount; END IF; IF (_tmpTotal < _p.vohead_amount) THEN RAISE EXCEPTION 'Cannot Post Voucher #% with distributions less than the voucher amount (% < %) [xtuple: postVoucher, -4, %, %, %]', _p.vohead_number, _tmpTotal, _p.vohead_amount, _p.vohead_number, _tmpTotal, _p.vohead_amount; END IF; SELECT DISTINCT poitem_linenumber INTO _test FROM vodist, voitem, poitem WHERE ( (vodist_poitem_id=poitem_id) AND (voitem_poitem_id=poitem_id) AND (voitem_vohead_id=vodist_vohead_id) AND ((poitem_qty_received - poitem_qty_vouchered) = 0) AND (vodist_vohead_id=pVoheadid) ) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Cannot Post Voucher #% as one or more of the line items have already been fully vouchered. Check P/O Line #% [postVoucher, -6, %, %]', _p.vohead_number, _test, _p.vohead_number, _test; END IF; -- Start by handling taxes FOR _r IN SELECT tax_sales_accnt_id, round(sum(taxdetail_tax),2) AS tax, currToBase(_p.vohead_curr_id, round(sum(taxdetail_tax),2), _p.vohead_docdate) AS taxbasevalue FROM tax JOIN calculateTaxDetailSummary('VO', pVoheadid, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id, tax_sales_accnt_id LOOP PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', _p.vohead_number, _r.tax_sales_accnt_id, _r.taxbasevalue, _glDate, _p.glnotes ); RAISE DEBUG 'postVoucher: _r.tax=%', _r.tax; _totalAmount_base := (_totalAmount_base - _r.taxbasevalue); _totalAmount := (_totalAmount - _r.tax); END LOOP; -- Update item tax records with posting data UPDATE voitemtax SET taxhist_docdate=_p.vohead_docdate, taxhist_distdate=_glDate, taxhist_curr_id=_p.vohead_curr_id, taxhist_curr_rate=curr_rate, taxhist_journalnumber=pJournalNumber FROM vohead JOIN voitem ON (vohead_id=voitem_vohead_id), curr_rate WHERE ((vohead_id=pVoheadId) AND (taxhist_parent_id=voitem_id) AND (_p.vohead_curr_id=curr_id) AND (_p.vohead_docdate BETWEEN curr_effective AND curr_expires) ); -- Update Misc distributions with posting data UPDATE voheadtax SET taxhist_docdate=_p.vohead_docdate, taxhist_distdate=_glDate, taxhist_curr_id=_p.vohead_curr_id, taxhist_curr_rate=curr_rate, taxhist_journalnumber=pJournalNumber FROM curr_rate WHERE ((taxhist_parent_id=pVoheadid) AND (_p.vohead_curr_id=curr_id) AND (_p.vohead_docdate BETWEEN curr_effective AND curr_expires) ); -- Loop through the vodist records for the passed vohead that -- are posted against a P/O Item FOR _g IN SELECT DISTINCT poitem_id, voitem_id, voitem_qty, poitem_expcat_id, poitem_invvenduomratio, poitem_prj_id, COALESCE(itemsite_id, -1) AS itemsiteid, COALESCE(itemsite_costcat_id, -1) AS costcatid, COALESCE(itemsite_item_id, -1) AS itemsite_item_id, COALESCE(item_type, '') AS item_type, (SELECT SUM(value) FROM ( SELECT SUM(recv_value) AS value FROM recv WHERE (recv_voitem_id=voitem_id) UNION SELECT SUM(poreject_value)*-1 AS value FROM poreject WHERE (poreject_voitem_id=voitem_id)) as data) AS value_base, (poitem_freight_received - poitem_freight_vouchered) / (poitem_qty_received - poitem_qty_vouchered) * voitem_qty AS vouchered_freight, currToBase(_p.pohead_curr_id, (poitem_freight_received - poitem_freight_vouchered) / (poitem_qty_received - poitem_qty_vouchered) * voitem_qty, _firstExchDateFreight ) AS vouchered_freight_base, voitem_freight, currToBase(_p.vohead_curr_id, voitem_freight, _p.vohead_distdate) AS voitem_freight_base FROM vodist, voitem, poitem LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id) LEFT OUTER JOIN item ON (item_id=itemsite_item_id) WHERE ( (vodist_poitem_id=poitem_id) AND (voitem_poitem_id=poitem_id) AND (voitem_vohead_id=vodist_vohead_id) AND (vodist_vohead_id=pVoheadid)) LOOP -- Grab the G/L Accounts IF (_g.costcatid = -1) THEN SELECT getPrjAccntId(_g.poitem_prj_id, pp.accnt_id) AS pp_accnt_id, lb.accnt_id AS lb_accnt_id, fr.accnt_id AS freight_accnt_id INTO _a FROM expcat, accnt AS pp, accnt AS lb, accnt AS fr WHERE ( (expcat_purchprice_accnt_id=pp.accnt_id) AND (expcat_liability_accnt_id=lb.accnt_id) AND (expcat_freight_accnt_id=fr.accnt_id) AND (expcat_id=_g.poitem_expcat_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Post Voucher #% due to unassigned G/L Accounts [xtuple: postVoucher, -7, %]', _p.vohead_number, _p.vohead_number; END IF; ELSE SELECT getPrjAccntId(_g.poitem_prj_id, costcat_purchprice_accnt_id) AS pp_accnt_id, getPrjAccntId(_g.poitem_prj_id, costcat_liability_accnt_id) AS lb_accnt_id, getPrjAccntId(_g.poitem_prj_id, costcat_freight_accnt_id) AS freight_accnt_id INTO _a FROM costcat WHERE (costcat_id=_g.costcatid); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Post Voucher #% due to unassigned G/L Accounts [xtuple: postVoucher, -8, %]', _p.vohead_number, _p.vohead_number; END IF; END IF; -- Clear the Item Amount accumulator _itemAmount_base := 0; _itemAmount := 0; -- Figure out the total posted value for this line item FOR _d IN SELECT vodist_id, vodist_amount, vodist_discountable, _p.vohead_curr_id, vodist_costelem_id, currToBase(_p.vohead_curr_id, vodist_amount, _p.vohead_distdate) AS vodist_amount_base FROM vodist WHERE ( (vodist_vohead_id=pVoheadid) AND (vodist_poitem_id=_g.poitem_id) ) LOOP _pExplain := FALSE; SELECT * INTO _costx FROM itemcost WHERE ( (itemcost_item_id = _g.itemsite_item_id) AND (itemcost_costelem_id = _d.vodist_costelem_id) ); IF (FOUND) THEN _pExplain := _costx.itemcost_lowlevel; END IF; -- Post the cost to the Actual if requested -- and item type is not manufactured -- IF ( (pPostCosts) AND (_d.vodist_costelem_id <> -1) ) THEN IF ( (_d.vodist_costelem_id <> -1) AND (_g.itemsite_item_id <> -1) AND (_g.item_type <> 'M') ) THEN PERFORM updateCost( _g.itemsite_item_id, _d.vodist_costelem_id, _pExplain, (_d.vodist_amount / (_g.voitem_qty * _g.poitem_invvenduomratio)), _p.vohead_curr_id ); END IF; -- Add the Distribution Amount to the Item Amount RAISE DEBUG 'postVoucher: _d.vodist_amount=%', _d.vodist_amount; _itemAmount_base := _itemAmount_base + ROUND(_d.vodist_amount_base, 2); _itemAmount := _itemAmount + _d.vodist_amount; IF (_d.vodist_discountable) THEN _totalDiscountableAmount := (_totalDiscountableAmount + _d.vodist_amount); END IF; END LOOP; -- Distribute from the clearing account PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number), _a.lb_accnt_id, round(_g.value_base + _g.vouchered_freight_base, 2) * -1, _glDate, _p.glnotes ); -- Attribute the correct portion to currency gain/loss _exchGainFreight := 0; SELECT currGain(_p.pohead_curr_id, _g.vouchered_freight, _firstExchDateFreight, _p.vohead_distdate ) INTO _exchGainFreight; IF (round(_exchGainFreight, 2) <> 0) THEN PERFORM insertIntoGLSeries(_sequence, 'A/P', 'VO', text(_p.vohead_number), getGainLossAccntId(_a.lb_accnt_id), round(_exchGainFreight, 2), _glDate, _p.glnotes); END IF; -- Distribute the remaining variance to the Purchase Price Variance account IF (round(_itemAmount_base, 2) <> round(_g.value_base, 2)) THEN _tmpTotal := round(_itemAmount_base, 2) - round(_g.value_base, 2); PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number), _a.pp_accnt_id, _tmpTotal * -1, _glDate, _p.glnotes ); END IF; -- Distribute the remaining freight variance to the Purchase Price Variance account IF (round(_g.voitem_freight_base + _exchGainFreight, 2) <> round(_g.vouchered_freight_base, 2)) THEN _tmpTotal := round(_g.voitem_freight_base + _exchGainFreight, 2) - round(_g.vouchered_freight_base, 2); PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number), _a.freight_accnt_id, _tmpTotal * -1, _glDate, _p.glnotes ); END IF; -- Add the distribution amount to the total amount to distribute RAISE DEBUG 'postVoucher: _itemAmount=%', _itemAmount; _totalAmount_base := (_totalAmount_base + _itemAmount_base + _g.voitem_freight_base); _totalAmount := (_totalAmount + _itemAmount + _g.voitem_freight); -- Post all the Tagged Receivings for this P/O Item as Invoiced and -- record the purchase and receive costs -- Comment out because recv cost is set at receiving now. UPDATE recv SET recv_invoiced=TRUE, recv_recvcost_curr_id=basecurrid(), recv_recvcost=round(_g.value_base / _g.voitem_qty, 2) FROM poitem WHERE ((recv_orderitem_id=poitem_id) AND (recv_order_type='PO') AND (recv_orderitem_id=_g.poitem_id) AND (recv_vohead_id=pVoheadid) ); -- Post all the Tagged Rejections for this P/O Item as Invoiced UPDATE poreject SET poreject_invoiced=TRUE WHERE ( (poreject_poitem_id=_g.poitem_id) AND (poreject_vohead_id=pVoheadid) ); -- Update the qty and freight vouchered fields UPDATE poitem SET poitem_qty_vouchered = (poitem_qty_vouchered + _g.voitem_qty), poitem_freight_vouchered = (poitem_freight_vouchered + _g.vouchered_freight) WHERE (poitem_id=_g.poitem_id); END LOOP; -- Loop through the vodist records for the passed vohead that -- are not posted against a P/O Item -- Skip the tax distributions FOR _d IN SELECT vodist_id, vodist_discountable, currToBase(_p.vohead_curr_id, vodist_amount, _p.vohead_distdate) AS vodist_amount_base, vodist_amount, vodist_accnt_id, vodist_expcat_id FROM vodist WHERE ( (vodist_vohead_id=pVoheadid) AND (vodist_poitem_id=-1) AND (vodist_tax_id=-1) ) LOOP -- Distribute from the misc. account IF (_d.vodist_accnt_id = -1) THEN PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number), expcat_exp_accnt_id, round(_d.vodist_amount_base, 2) * -1, _glDate, _p.glnotes ) FROM expcat WHERE (expcat_id=_d.vodist_expcat_id); ELSE PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number), _d.vodist_accnt_id, round(_d.vodist_amount_base, 2) * -1, _glDate, _p.glnotes ); END IF; -- Add the Distribution Amount to the Total Amount RAISE DEBUG 'postVoucher: _d.vodist_amount=%', _d.vodist_amount; _totalAmount_base := _totalAmount_base + ROUND(_d.vodist_amount_base, 2); _totalAmount := _totalAmount + _d.vodist_amount; IF (_d.vodist_discountable) THEN _totalDiscountableAmount := (_totalDiscountableAmount + _d.vodist_amount); END IF; END LOOP; SELECT insertIntoGLSeries( _sequence, 'A/P', 'VO', text(vohead_number), accnt_id, round(_totalAmount_base, 2), _glDate, _p.glnotes ) INTO _test FROM vohead LEFT OUTER JOIN accnt ON (accnt_id=findAPAccount(vohead_vend_id)) WHERE ( (findAPAccount(vohead_vend_id)=0 OR accnt_id > 0) -- G/L interface might be disabled AND (vohead_id=pVoheadid) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Post Voucher #% due to an unassigned A/P Account [xtuple: postVoucher, -9, %]', _p.vohead_number, _p.vohead_number; END IF; PERFORM postGLSeries(_sequence, pJournalNumber); -- Create the A/P Open Item RAISE DEBUG 'postVoucher: _totalAmount=%, _totalDiscountableAmount=%', _totalAmount, _totalDiscountableAmount; INSERT INTO apopen ( apopen_journalnumber, apopen_docdate, apopen_duedate, apopen_distdate, apopen_open, apopen_terms_id, apopen_vend_id, apopen_doctype, apopen_docnumber, apopen_invcnumber, apopen_ponumber, apopen_reference, apopen_amount, apopen_paid, apopen_notes, apopen_username, apopen_posted, apopen_curr_id, apopen_discountable_amount ) -- TODO: SELECT pJournalNumber, vohead_docdate, vohead_duedate, _glDate, TRUE, vohead_terms_id, vohead_vend_id, 'V', vohead_number, vohead_invcnumber, COALESCE(TEXT(pohead_number), 'Misc.'), vohead_reference, round(_totalAmount, 2), 0, '', getEffectiveXtUser(), FALSE, vohead_curr_id, round(_totalDiscountableAmount, 2) FROM vohead LEFT OUTER JOIN pohead ON (vohead_pohead_id=pohead_id) WHERE (vohead_id=pVoheadid); -- Close all of the P/O Items that should be closed by this Voucher UPDATE poitem SET poitem_status='C' FROM voitem WHERE ( (voitem_poitem_id=poitem_id) AND (voitem_close) AND (voitem_vohead_id=pVoheadid) ); -- Check the P/O items and if they are all closed go ahead -- and close the P/O head. IF ( (SELECT (count(*) < 1) FROM vohead, poitem WHERE ((vohead_pohead_id=poitem_pohead_id) AND (poitem_status<>'C') AND (vohead_id=pVoheadid) ) ) ) THEN PERFORM closePo(vohead_pohead_id) FROM vohead WHERE (vohead_id=pVoheadid); END IF; -- Set the vohead as posted UPDATE vohead SET vohead_posted=TRUE, vohead_gldistdate=_glDate WHERE (vohead_id=pVoheadid); RETURN pJournalNumber; END; $_$; ALTER FUNCTION public.postvoucher(integer, integer, boolean) OWNER TO admin; -- -- Name: postvouchers(boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION postvouchers(boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPostCosts ALIAS FOR $1; _journalNumber INTEGER; BEGIN SELECT fetchJournalNumber('AP-VO') INTO _journalNumber; PERFORM postVoucher(vohead_id, _journalNumber, pPostCosts) FROM vohead WHERE (NOT vohead_posted); RETURN _journalNumber; END; $_$; ALTER FUNCTION public.postvouchers(boolean) OWNER TO admin; -- -- Name: primarykeyfields(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION primarykeyfields(text, text) RETURNS text[] LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSchema ALIAS FOR $1; pRelation ALIAS FOR $2; _colname TEXT; _counter INTEGER := 0; _result TEXT[]; BEGIN EXECUTE 'SELECT ARRAY(SELECT attname FROM pg_attribute JOIN pg_class idx ON (attrelid = idx.oid) JOIN pg_namespace ON (idx.relnamespace = pg_namespace.oid) JOIN pg_index ON (idx.oid = indexrelid) JOIN pg_class tab ON (indrelid = tab.oid) WHERE NOT attisdropped AND nspname = ''' || pSchema || ''' AND indisprimary AND LOWER(tab.relname) = ''' || pRelation || ''' ORDER BY attnum);' INTO _result; RETURN _result; END; $_$; ALTER FUNCTION public.primarykeyfields(text, text) OWNER TO admin; -- -- Name: FUNCTION primarykeyfields(text, text); Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON FUNCTION primarykeyfields(text, text) IS 'Return an array containing the names of the primary key fields of pSchema.pRelation. The first key field is in _result[1].'; -- -- Name: prj(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION prj() RETURNS SETOF prj LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row prj%ROWTYPE; _priv TEXT; _grant BOOLEAN; BEGIN -- This query will give us the most permissive privilege the user has been granted SELECT privilege, granted INTO _priv, _grant FROM privgranted WHERE privilege IN ('MaintainAllProjects','ViewAllProjects','MaintainPersonalProjects','ViewPersonalProjects') ORDER BY granted DESC, sequence LIMIT 1; -- If have an 'All' privilege return all results IF (_priv ~ 'All' AND _grant) THEN FOR _row IN SELECT * FROM prj LOOP RETURN NEXT _row; END LOOP; -- Otherwise if have any other grant, must be personal privilege. ELSIF (_grant) THEN FOR _row IN SELECT * FROM prj WHERE getEffectiveXtUser() IN (prj_owner_username, prj_username) LOOP RETURN NEXT _row; END LOOP; END IF; RETURN; END; $$; ALTER FUNCTION public.prj() OWNER TO admin; -- -- Name: FUNCTION prj(); Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON FUNCTION prj() IS 'A table function that returns Project results according to privilege settings.'; -- -- Name: prjtask; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE prjtask ( prjtask_id integer NOT NULL, prjtask_number text NOT NULL, prjtask_name text NOT NULL, prjtask_descrip text, prjtask_prj_id integer NOT NULL, prjtask_anyuser boolean, prjtask_status character(1) NOT NULL, prjtask_hours_budget numeric(18,6) NOT NULL, prjtask_hours_actual numeric(18,6) NOT NULL, prjtask_exp_budget numeric(16,4) NOT NULL, prjtask_exp_actual numeric(16,4) NOT NULL, prjtask_owner_username text, prjtask_start_date date, prjtask_due_date date, prjtask_assigned_date date, prjtask_completed_date date, prjtask_username text, CONSTRAINT prjtask_prjtask_status_check CHECK ((prjtask_status = ANY (ARRAY['P'::bpchar, 'O'::bpchar, 'C'::bpchar]))) ); ALTER TABLE prjtask OWNER TO admin; -- -- Name: TABLE prjtask; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE prjtask IS 'Project Task information'; -- -- Name: prjtask(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION prjtask() RETURNS SETOF prjtask LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row prjtask%ROWTYPE; _priv TEXT; _grant BOOLEAN; BEGIN -- This query will give us the most permissive privilege the user has been granted SELECT privilege, granted INTO _priv, _grant FROM privgranted WHERE privilege IN ('MaintainAllProjects','ViewAllProjects','MaintainPersonalProjects','ViewPersonalProjects') ORDER BY granted DESC, sequence LIMIT 1; -- If have an 'All' privilege return all results IF (_priv ~ 'All' AND _grant) THEN FOR _row IN SELECT * FROM prjtask LOOP RETURN NEXT _row; END LOOP; -- Otherwise if have any other grant, must be personal privilege. ELSIF (_grant) THEN FOR _row IN SELECT prjtask.* FROM prjtask JOIN prj ON prj_id=prjtask_prj_id WHERE getEffectiveXtUser() IN (prjtask_owner_username,prjtask_username,prj_username,prj_owner_username) LOOP RETURN NEXT _row; END LOOP; END IF; RETURN; END; $$; ALTER FUNCTION public.prjtask() OWNER TO admin; -- -- Name: FUNCTION prjtask(); Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON FUNCTION prjtask() IS 'A table function that returns Project results according to privilege settings.'; -- -- Name: purgecreditmemos(date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION purgecreditmemos(date) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCutoffDate ALIAS FOR $1; BEGIN DELETE FROM cmitem WHERE (cmitem_id IN ( SELECT cmitem_id FROM cmitem, cmhead WHERE ( (cmitem_cmhead_id=cmhead_id) AND (cmhead_posted) AND (cmhead_printed) AND (cmhead_docdate<=pCutoffDate) AND (checkCreditMemoSitePrivs(cmhead_id)) ) ) ); DELETE FROM cmhead WHERE ( (cmhead_posted) AND (cmhead_printed) AND (cmhead_docdate<=pCutoffDate) AND (checkCreditMemoSitePrivs(cmhead_id)) ); RETURN TRUE; END; $_$; ALTER FUNCTION public.purgecreditmemos(date) OWNER TO admin; -- -- Name: purgecrmacctmerge(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION purgecrmacctmerge(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pDestid ALIAS FOR $1; _result INTEGER := 0; _tmpcount INTEGER := 0; BEGIN IF EXISTS(SELECT 1 FROM crmacctsel WHERE crmacctsel_dest_crmacct_id=pDestid) THEN DELETE FROM crmacctsel WHERE crmacctsel_dest_crmacct_id = pDestid; GET DIAGNOSTICS _result = ROW_COUNT; ELSIF EXISTS(SELECT 1 FROM mrgundo WHERE mrgundo_base_schema='public' AND mrgundo_base_table='crmacct' AND mrgundo_base_id=pDestid) THEN DELETE FROM crmacct WHERE crmacct_id IN ( SELECT mrgundo_pkey_id FROM mrgundo WHERE mrgundo_schema = 'public' AND mrgundo_table = 'crmacct' and mrgundo_pkey_col = 'crmacct_id' AND mrgundo_col IS NULL AND mrgundo_base_schema = 'public' AND mrgundo_base_table = 'crmacct' AND mrgundo_base_id = pDestid) AND crmacct_id != pDestid; GET DIAGNOSTICS _result = ROW_COUNT; DELETE FROM mrgundo WHERE mrgundo_base_schema ='public' AND mrgundo_base_table ='crmacct' AND mrgundo_base_id = pDestid; GET DIAGNOSTICS _tmpcount = ROW_COUNT; _result := _result + _tmpcount; END IF; RETURN _result; END; $_$; ALTER FUNCTION public.purgecrmacctmerge(integer) OWNER TO admin; -- -- Name: purgeinvoicerecord(date, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION purgeinvoicerecord(date, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCutoffDate ALIAS FOR $1; pInvcheadId ALIAS FOR $2; _r RECORD; _ra RECORD; _raheadid INTEGER; _result INTEGER; _debug BOOLEAN := FALSE; BEGIN -- Purge records where the entire Invoice, Billing, Shipper, Sales Order -- chain of associated documents are closed and complete FOR _r IN SELECT invchead_id, cobmisc_id, shiphead_id, ordershipped.cohead_id AS ordship_id, orderinvoiced.cohead_id AS ordinv_id FROM invchead LEFT OUTER JOIN invcitem ON (invcitem_invchead_id=invchead_id) LEFT OUTER JOIN cobmisc ON (cobmisc_invcnumber::TEXT=invchead_invcnumber) LEFT OUTER JOIN shipitem ON (shipitem_invcitem_id=invcitem_id) LEFT OUTER JOIN shiphead ON (shiphead_id=shipitem_shiphead_id) LEFT OUTER JOIN cohead ordershipped ON (ordershipped.cohead_id=shiphead_order_id) LEFT OUTER JOIN coitem ON (coitem_id=invcitem_coitem_id) LEFT OUTER JOIN cohead orderinvoiced ON (orderinvoiced.cohead_id=coitem_cohead_id) WHERE ( (invchead_id = pInvcheadId) AND (invchead_posted) AND (checkInvoiceSitePrivs(invchead_id)) ) GROUP BY invchead_id, cobmisc_id, shiphead_id, ordship_id, ordinv_id LOOP -- Check Billing -- Billing header (cobmisc) must be posted SELECT cobmisc_id INTO _result FROM cobmisc WHERE ( (cobmisc_id=_r.cobmisc_id) AND (NOT cobmisc_posted) ); IF (FOUND) THEN RETURN 'Billing not closed'; END IF; -- Billing line items (cobill), associated Invoice line items, and -- associated Sales Order line items must be closed, posted, and after cutoff date SELECT cobill_id INTO _result FROM cobill JOIN invcitem ON (invcitem_id=cobill_invcitem_id) JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND ((NOT invchead_posted) OR (invchead_invcdate > pCutoffDate)) ) JOIN coitem ON ( (coitem_id=cobill_coitem_id) AND (coitem_status NOT IN ('C', 'X')) ) WHERE (cobill_cobmisc_id=_r.cobmisc_id); IF (FOUND) THEN RETURN 'Invoice/Sales Order associated with Billing not closed'; END IF; -- Check Shipping -- Shipping header (shiphead) must be shipped SELECT shiphead_id INTO _result FROM shiphead WHERE ( (shiphead_id=_r.shiphead_id) AND (NOT shiphead_shipped) ); IF (FOUND) THEN RETURN 'Shipper not closed'; END IF; -- Shipping line items (shipitem) and associated Sales Order line items -- must be closed SELECT shiphead_id INTO _result FROM shiphead, cohead, coitem WHERE ( (shiphead_id=_r.shiphead_id) AND ( (shiphead_order_type='SO') AND (shiphead_order_id=cohead_id) ) AND (coitem_cohead_id=cohead_id) AND (coitem_status NOT IN ('C', 'X')) ); IF (FOUND) THEN RETURN 'Sales Order associated with Shipper not closed'; END IF; -- Shipping line items (shipitem) and associated Invoices must be posted -- and after cutoff date SELECT shiphead_id INTO _result FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id) JOIN invcitem ON (invcitem_id=shipitem_invcitem_id) JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND ((NOT invchead_posted) OR (invchead_invcdate > pCutoffDate)) ) WHERE (shiphead_id=_r.shiphead_id); IF (FOUND) THEN RETURN 'Invoice associated with Shipper not closed'; END IF; -- Check Sales Order -- Sales Order line items (coitem) must be closed SELECT cohead_id INTO _result FROM cohead JOIN coitem ON ( (coitem_cohead_id=cohead_id) AND (coitem_status NOT IN ('C', 'X')) ) WHERE (cohead_id=_r.ordship_id); IF (FOUND) THEN RETURN 'Shipped Sales Order not closed'; END IF; SELECT cohead_id INTO _result FROM cohead JOIN coitem ON ( (coitem_cohead_id=cohead_id) AND (coitem_status NOT IN ('C', 'X')) ) WHERE (cohead_id=_r.ordinv_id); IF (FOUND) THEN RETURN 'Invoiced Sales Order not closed'; END IF; IF (fetchMetricBool('MultiWhs')) THEN -- Check Original Return Authorization and cross check to New Sales Order SELECT rahead_id INTO _result FROM rahead JOIN raitem ON ( (raitem_rahead_id=rahead_id) AND (raitem_status NOT IN ('C', 'X')) ) JOIN coitem ON ( (coitem_id=raitem_new_coitem_id) AND (coitem_status NOT IN ('C', 'X')) ) JOIN invcitem ON (invcitem_coitem_id=coitem_id) JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND ((NOT invchead_posted) OR (invchead_invcdate > pCutoffDate)) ) WHERE (rahead_orig_cohead_id=_r.ordship_id); IF (FOUND) THEN RETURN 'Shipped Original Return Authorization not closed'; END IF; SELECT rahead_id INTO _result FROM rahead JOIN raitem ON ( (raitem_rahead_id=rahead_id) AND (raitem_status NOT IN ('C', 'X')) ) JOIN coitem ON ( (coitem_id=raitem_new_coitem_id) AND (coitem_status NOT IN ('C', 'X')) ) JOIN invcitem ON (invcitem_coitem_id=coitem_id) JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND ((NOT invchead_posted) OR (invchead_invcdate > pCutoffDate)) ) WHERE (rahead_orig_cohead_id=_r.ordinv_id); IF (FOUND) THEN RETURN 'Invoiced Original Return Authorization not closed'; END IF; -- Check New Return Authorization SELECT rahead_id INTO _result FROM rahead JOIN raitem ON ( (raitem_rahead_id=rahead_id) AND (NOT raitem_status IN ('C', 'X')) ) JOIN coitem ON ( (coitem_id=raitem_orig_coitem_id) AND (NOT coitem_status IN ('C', 'X')) ) JOIN invcitem ON (invcitem_coitem_id=coitem_id) JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND ((NOT invchead_posted) OR (invchead_invcdate > pCutoffDate)) ) WHERE (rahead_new_cohead_id=_r.ordship_id); IF (FOUND) THEN RETURN 'Shipped New Return Authorization not closed'; END IF; SELECT rahead_id INTO _result FROM rahead JOIN raitem ON ( (raitem_rahead_id=rahead_id) AND (NOT raitem_status IN ('C', 'X')) ) JOIN coitem ON ( (coitem_id=raitem_orig_coitem_id) AND (NOT coitem_status IN ('C', 'X')) ) JOIN invcitem ON (invcitem_coitem_id=coitem_id) JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND ((NOT invchead_posted) OR (invchead_invcdate > pCutoffDate)) ) WHERE (rahead_new_cohead_id=_r.ordinv_id); IF (FOUND) THEN RETURN 'Invoiced New Return Authorization not closed'; END IF; END IF; -- Check Lot/Serial Registration IF (fetchMetricBool('MultiWhs')) THEN -- Registration associated with Sales Order must be expired SELECT lsreg_id INTO _result FROM lsreg WHERE ( (lsreg_cohead_id=_r.ordship_id) AND (lsreg_expiredate > CURRENT_DATE) ); IF (FOUND) THEN RETURN 'Shipped Sales Order Lot/Serial Registration not closed'; END IF; SELECT lsreg_id INTO _result FROM lsreg WHERE ( (lsreg_cohead_id=_r.ordinv_id) AND (lsreg_expiredate > CURRENT_DATE) ); IF (FOUND) THEN RETURN 'Invoiced Sales Order Lot/Serial Registration not closed'; END IF; -- Registration associated with Shipping must be expired SELECT lsreg_id INTO _result FROM lsreg WHERE ( (lsreg_cohead_id=_r.shiphead_id) AND (lsreg_expiredate > CURRENT_DATE) ); IF (FOUND) THEN RETURN 'Shipper Lot/Serial Registration not closed'; END IF; END IF; IF (fetchMetricBool('MultiWhs')) THEN -- Registration associated with Original Return Authorization must be expired SELECT rahead_id INTO _result FROM rahead JOIN raitem ON (raitem_rahead_id=rahead_id) JOIN raitemls ON (raitemls_raitem_id=raitem_id) JOIN lsreg ON ( (lsreg_ls_id=raitemls_ls_id) AND (lsreg_expiredate > CURRENT_DATE) ) WHERE (rahead_orig_cohead_id=_r.ordship_id); IF (FOUND) THEN RETURN 'Shipped Original Return Authorization Lot/Serial Registration not closed'; END IF; SELECT rahead_id INTO _result FROM rahead JOIN raitem ON (raitem_rahead_id=rahead_id) JOIN raitemls ON (raitemls_raitem_id=raitem_id) JOIN lsreg ON ( (lsreg_ls_id=raitemls_ls_id) AND (lsreg_expiredate > CURRENT_DATE) ) WHERE (rahead_orig_cohead_id=_r.ordinv_id); IF (FOUND) THEN RETURN 'Invoiced Original Return Authorization Lot/Serial Registration not closed'; END IF; -- Registration associated with New Return Authorization must be expired SELECT rahead_id INTO _result FROM rahead JOIN raitem ON (raitem_rahead_id=rahead_id) JOIN raitemls ON (raitemls_raitem_id=raitem_id) JOIN lsreg ON ( (lsreg_ls_id=raitemls_ls_id) AND (lsreg_expiredate > CURRENT_DATE) ) WHERE (rahead_new_cohead_id=_r.ordship_id); IF (FOUND) THEN RETURN 'Shipped New Return Authorization Lot/Serial Registration not closed'; END IF; SELECT rahead_id INTO _result FROM rahead JOIN raitem ON (raitem_rahead_id=rahead_id) JOIN raitemls ON (raitemls_raitem_id=raitem_id) JOIN lsreg ON ( (lsreg_ls_id=raitemls_ls_id) AND (lsreg_expiredate > CURRENT_DATE) ) WHERE (rahead_new_cohead_id=_r.ordinv_id); IF (FOUND) THEN RETURN 'Invoiced New Return Authorization Lot/Serial Registration not closed'; END IF; END IF; -- Cash Advances associated with Sales Order cannot exist SELECT aropenalloc_doc_id INTO _result FROM aropenalloc WHERE ((aropenalloc_doctype='S') AND (aropenalloc_doc_id=_r.ordship_id)); IF (FOUND) THEN RETURN 'Shipped Cash Advance not closed'; END IF; SELECT aropenalloc_doc_id INTO _result FROM aropenalloc WHERE ((aropenalloc_doctype='S') AND (aropenalloc_doc_id=_r.ordinv_id)); IF (FOUND) THEN RETURN 'Invoiced Cash Advance not closed'; END IF; END LOOP; -- Everything is OK, delete the chain FOR _r IN SELECT invchead_id, cobmisc_id, shiphead_id, ordershipped.cohead_id AS ordship_id, orderinvoiced.cohead_id AS ordinv_id FROM invchead LEFT OUTER JOIN invcitem ON (invcitem_invchead_id=invchead_id) LEFT OUTER JOIN cobmisc ON (cobmisc_invcnumber::TEXT=invchead_invcnumber) LEFT OUTER JOIN shipitem ON (shipitem_invcitem_id=invcitem_id) LEFT OUTER JOIN shiphead ON (shiphead_id=shipitem_shiphead_id) LEFT OUTER JOIN cohead ordershipped ON (ordershipped.cohead_id=shiphead_order_id) LEFT OUTER JOIN coitem ON (coitem_id=invcitem_coitem_id) LEFT OUTER JOIN cohead orderinvoiced ON (orderinvoiced.cohead_id=coitem_cohead_id) WHERE ( (invchead_id = pInvcheadId) AND (invchead_posted) AND (checkInvoiceSitePrivs(invchead_id)) ) GROUP BY invchead_id, cobmisc_id, shiphead_id, ordship_id, ordinv_id LOOP IF (fetchMetricBool('MultiWhs')) THEN FOR _ra IN SELECT rahead_id FROM rahead WHERE (rahead_orig_cohead_id=_r.ordship_id) LOOP IF (_debug) THEN RAISE NOTICE 'Deleting Original Return head id %', _ra.rahead_id; END IF; DELETE FROM raitemls WHERE (raitemls_raitem_id IN (SELECT raitem_id FROM raitem WHERE (raitem_rahead_id=_ra.rahead_id))); DELETE FROM rahist WHERE (rahist_rahead_id=_ra.rahead_id); DELETE FROM raitem WHERE (raitem_rahead_id=_ra.rahead_id); DELETE FROM rahead WHERE (rahead_id=_ra.rahead_id); END LOOP; FOR _ra IN SELECT rahead_id FROM rahead WHERE (rahead_orig_cohead_id=_r.ordinv_id) LOOP IF (_debug) THEN RAISE NOTICE 'Deleting Original Return head id %', _ra.rahead_id; END IF; DELETE FROM raitemls WHERE (raitemls_raitem_id IN (SELECT raitem_id FROM raitem WHERE (raitem_rahead_id=_ra.rahead_id))); DELETE FROM rahist WHERE (rahist_rahead_id=_ra.rahead_id); DELETE FROM raitem WHERE (raitem_rahead_id=_ra.rahead_id); DELETE FROM rahead WHERE (rahead_id=_ra.rahead_id); END LOOP; FOR _ra IN SELECT rahead_id FROM rahead WHERE (rahead_new_cohead_id=_r.ordship_id) LOOP IF (_debug) THEN RAISE NOTICE 'Deleting New Return head id %', _ra.rahead_id; END IF; DELETE FROM raitemls WHERE (raitemls_raitem_id IN (SELECT raitem_id FROM raitem WHERE (raitem_rahead_id=_ra.rahead_id))); DELETE FROM rahist WHERE (rahist_rahead_id=_ra.rahead_id); DELETE FROM raitem WHERE (raitem_rahead_id=_ra.rahead_id); DELETE FROM rahead WHERE (rahead_id=_ra.rahead_id); END LOOP; FOR _ra IN SELECT rahead_id FROM rahead WHERE (rahead_new_cohead_id=_r.ordinv_id) LOOP IF (_debug) THEN RAISE NOTICE 'Deleting New Return head id %', _ra.rahead_id; END IF; DELETE FROM raitemls WHERE (raitemls_raitem_id IN (SELECT raitem_id FROM raitem WHERE (raitem_rahead_id=_ra.rahead_id))); DELETE FROM rahist WHERE (rahist_rahead_id=_ra.rahead_id); DELETE FROM raitem WHERE (raitem_rahead_id=_ra.rahead_id); DELETE FROM rahead WHERE (rahead_id=_ra.rahead_id); END LOOP; END IF; IF (fetchMetricBool('MultiWhs')) THEN IF (_debug) THEN RAISE NOTICE 'Deleting Lot/Serial Registrations'; END IF; DELETE FROM lsreg WHERE (lsreg_cohead_id=_r.ordship_id); DELETE FROM lsreg WHERE (lsreg_cohead_id=_r.ordinv_id); DELETE FROM lsreg WHERE (lsreg_shiphead_id=_r.shiphead_id); END IF; IF (_debug) THEN RAISE NOTICE 'Deleting Shipped Sales Order head id %', _r.ordship_id; END IF; DELETE FROM payco WHERE (payco_cohead_id=_r.ordship_id); -- Delete kit components first DELETE FROM coitem WHERE (coitem_cohead_id=_r.ordship_id AND coitem_subnumber > 0); DELETE FROM coitem WHERE (coitem_cohead_id=_r.ordship_id); DELETE FROM cohead WHERE (cohead_id=_r.ordship_id); IF (_debug) THEN RAISE NOTICE 'Deleting Sales Order head id %', _r.ordinv_id; END IF; DELETE FROM payco WHERE (payco_cohead_id=_r.ordinv_id); -- Delete kit components first DELETE FROM coitem WHERE (coitem_cohead_id=_r.ordinv_id AND coitem_subnumber > 0); DELETE FROM coitem WHERE (coitem_cohead_id=_r.ordinv_id); DELETE FROM cohead WHERE (cohead_id=_r.ordinv_id); IF (_debug) THEN RAISE NOTICE 'Deleting Ship head id %', _r.shiphead_id; END IF; DELETE FROM shipitem WHERE (shipitem_shiphead_id=_r.shiphead_id); DELETE FROM pack WHERE (pack_shiphead_id=_r.shiphead_id); DELETE FROM shiphead WHERE (shiphead_id=_r.shiphead_id); IF (_debug) THEN RAISE NOTICE 'Deleting Billing head id %', _r.cobmisc_id; END IF; DELETE FROM cobill WHERE (cobill_cobmisc_id=_r.cobmisc_id); DELETE FROM cobmisc WHERE (cobmisc_id=_r.cobmisc_id); END LOOP; -- Everything is OK, delete the Invoice IF (_debug) THEN RAISE NOTICE 'Deleting Invoice head id %', _r.invchead_id; END IF; DELETE FROM invcitem WHERE (invcitem_invchead_id=_r.invchead_id); DELETE FROM invchead WHERE (invchead_id=_r.invchead_id); RETURN 'Purged'; END; $_$; ALTER FUNCTION public.purgeinvoicerecord(date, integer) OWNER TO admin; -- -- Name: purgeinvoicerecords(date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION purgeinvoicerecords(date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCutoffDate ALIAS FOR $1; BEGIN -- Remove the shipitem records DELETE FROM shipitem WHERE (shipitem_invcitem_id IN (SELECT invcitem_id FROM invcitem WHERE invcitem_invchead_id IN ( SELECT invchead_id FROM invchead WHERE ( (invchead_invcdate <= pCutoffDate) AND (checkInvoiceSitePrivs(invchead_id)) AND (invchead_posted) ) ) ) ); -- Remove the cobill and cobmisc records DELETE FROM cobill WHERE (cobill_cobmisc_id IN ( SELECT cobmisc_id FROM cobmisc, invchead WHERE ( (invchead_invcnumber=cobmisc_invcnumber::TEXT) AND (checkInvoiceSitePrivs(invchead_id)) AND (cobmisc_invcdate <= pCutoffDate) AND (cobmisc_posted)) ) ); DELETE FROM cobmisc WHERE ( (checkInvoiceSitePrivs(getInvcheadId(cobmisc_invcnumber::TEXT))) AND (cobmisc_invcdate <= pCutoffDate) AND (cobmisc_posted) ); -- Remove the invchead and invcitem records DELETE FROM invcitem WHERE (invcitem_invchead_id IN ( SELECT invchead_id FROM invchead WHERE ( (invchead_invcdate <= pCutoffDate) AND (checkInvoiceSitePrivs(invchead_id)) AND (invchead_posted) ) ) ); DELETE FROM invchead WHERE ( (invchead_invcdate <= pCutoffDate) AND (checkInvoiceSitePrivs(invchead_id)) AND (invchead_posted) ); RETURN 1; END; $_$; ALTER FUNCTION public.purgeinvoicerecords(date) OWNER TO admin; -- -- Name: purgepostedcountslips(date, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION purgepostedcountslips(date, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCutoffDate ALIAS FOR $1; pWarehousid ALIAS FOR $2; BEGIN IF (pWarehousid = -1) THEN DELETE FROM cntslip WHERE (cntslip_id IN ( SELECT cntslip_id FROM cntslip, invcnt WHERE ( (cntslip_cnttag_id=invcnt_id) AND (invcnt_posted) AND (cntslip_posted) AND (date(invcnt_postdate) <= pCutoffDate) ) ) ); ELSE DELETE FROM cntslip WHERE (cntslip_id IN ( SELECT cntslip_id FROM invcnt, itemsite WHERE ( (cntslip_cnttag_id=invcnt_id) AND (invcnt_posted) AND (cntslip_posted) AND (invcnt_itemsite_id=itemsite_id) AND (date(invcnt_postdate) <= pCutoffDate) AND (itemsite_warehous_id=pWarehousid) ) ) ); END IF; RETURN 1; END; $_$; ALTER FUNCTION public.purgepostedcountslips(date, integer) OWNER TO admin; -- -- Name: purgepostedcounttags(date, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION purgepostedcounttags(date, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCutoffDate ALIAS FOR $1; pWarehousid ALIAS FOR $2; BEGIN IF (pWarehousid = -1) THEN DELETE FROM cntslip WHERE (cntslip_cnttag_id IN ( SELECT invcnt_id FROM invcnt WHERE ( (invcnt_posted) AND (date(invcnt_postdate) <= pCutoffDate) ) ) ); DELETE FROM invcnt WHERE ((invcnt_posted) AND (date(invcnt_postdate) <= pCutoffDate)); ELSE DELETE FROM cntslip WHERE (cntslip_cnttag_id IN ( SELECT invcnt_id FROM invcnt, itemsite WHERE ( (invcnt_posted) AND (invcnt_itemsite_id=itemsite_id) AND (date(invcnt_postdate) <= pCutoffDate) AND (itemsite_warehous_id=pWarehousid) ) ) ); DELETE FROM invcnt WHERE (invcnt_id IN ( SELECT invcnt_id FROM invcnt, itemsite WHERE ( (invcnt_posted) AND (invcnt_itemsite_id=itemsite_id) AND (date(invcnt_postdate) <= pCutoffDate) AND (itemsite_warehous_id=pWarehousid) ) ) ); END IF; RETURN 1; END; $_$; ALTER FUNCTION public.purgepostedcounttags(date, integer) OWNER TO admin; -- -- Name: purgeshipments(date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION purgeshipments(date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pcutoff ALIAS FOR $1; _r RECORD; BEGIN -- Used for transfer orders shipments (which are never invoiced) FOR _r IN SELECT shiphead_id FROM shiphead WHERE ( (shiphead_order_type='TO') AND (shiphead_shipped) AND (shiphead_shipdate <= pcutoff) ) LOOP DELETE FROM shipitem WHERE (shipitem_shiphead_id=_r.shiphead_id); DELETE FROM shiphead WHERE (shiphead_id=_r.shiphead_id); END LOOP; RETURN 0; END; $_$; ALTER FUNCTION public.purgeshipments(date) OWNER TO admin; -- -- Name: qtyallocated(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtyallocated(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pLookAheaddays ALIAS FOR $2; BEGIN RETURN qtyAllocated(pItemsiteid, startOfTime(), (CURRENT_DATE + pLookAheadDays)); END; $_$; ALTER FUNCTION public.qtyallocated(integer, integer) OWNER TO admin; -- -- Name: qtyallocated(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtyallocated(integer, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pDate ALIAS FOR $2; BEGIN RETURN qtyAllocated(pItemsiteid, startOfTime(), pDate); END; $_$; ALTER FUNCTION public.qtyallocated(integer, date) OWNER TO admin; -- -- Name: qtyallocated(integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtyallocated(integer, date, date) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; BEGIN IF ( fetchMetricBool('MultiWhs')) THEN IF ( SELECT item_sold FROM itemsite, item WHERE ((itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid)) ) THEN RETURN (allocatedForTo(pItemsiteid, pStartDate, pEndDate) + allocatedForWo(pItemsiteid, pStartDate, pEndDate) + allocatedForSo(pItemsiteid, pStartDate, pEndDate)); ELSE RETURN (allocatedForTo(pItemsiteid, pStartDate, pEndDate) + allocatedForWo(pItemsiteid, pStartDate, pEndDate)); END IF; ELSE IF ( SELECT item_sold FROM itemsite, item WHERE ((itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid)) ) THEN RETURN (allocatedForWo(pItemsiteid, pStartDate, pEndDate) + allocatedForSo(pItemsiteid, pStartDate, pEndDate)); ELSE RETURN (allocatedForWo(pItemsiteid, pStartDate, pEndDate)); END IF; END IF; END; $_$; ALTER FUNCTION public.qtyallocated(integer, date, date) OWNER TO admin; -- -- Name: qtyatlocation(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtyatlocation(pitemsiteid integer, plocationid integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _qty NUMERIC := 0.0; BEGIN IF (pLocationid IS NULL) THEN SELECT COALESCE(itemsite_qtyonhand, 0.0) INTO _qty FROM itemsite WHERE (itemsite_id=pItemsiteid); ELSE SELECT COALESCE(SUM(itemloc_qty), 0.0) INTO _qty FROM itemsite LEFT OUTER JOIN itemloc ON (itemloc_itemsite_id=itemsite_id) WHERE ((itemsite_id=pItemsiteid) AND (itemloc_location_id=pLocationid)); END IF; RETURN _qty; END; $$; ALTER FUNCTION public.qtyatlocation(pitemsiteid integer, plocationid integer) OWNER TO admin; -- -- Name: qtyatshipping(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtyatshipping(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN qtyAtShipping('SO', $1); END; $_$; ALTER FUNCTION public.qtyatshipping(integer) OWNER TO admin; -- -- Name: qtyatshipping(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtyatshipping(text, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN qtyAtShipping($1, $2, 'U'); END; $_$; ALTER FUNCTION public.qtyatshipping(text, integer) OWNER TO admin; -- -- Name: qtyatshipping(text, integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtyatshipping(text, integer, text) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; plineitemid ALIAS FOR $2; pstatus ALIAS FOR $3; _qty NUMERIC := 0.0; BEGIN -- pstatus U=unshipped -- S=shipped -- B=both unshipped and shipped IF (pordertype NOT IN ('SO', 'TO')) THEN RAISE EXCEPTION '% is not a valid order type', pordertype; END IF; IF (pstatus NOT IN ('U', 'S', 'B')) THEN RAISE EXCEPTION '% is not a valid status', pstatus; END IF; SELECT COALESCE(SUM(shipitem_qty), 0.0) INTO _qty FROM shipitem, shiphead WHERE ((shipitem_shiphead_id=shiphead_id) AND (shiphead_order_type=pordertype) AND (shipitem_orderitem_id=plineitemid) AND (((shiphead_shipped) AND (pstatus IN ('S', 'B'))) OR ((NOT shiphead_shipped) AND (pstatus IN ('U', 'B')))) ); RETURN _qty; END; $_$; ALTER FUNCTION public.qtyatshipping(text, integer, text) OWNER TO admin; -- -- Name: qtyavailable(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtyavailable(pitemsiteid integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _qty NUMERIC = 0.0; BEGIN _qty := qtyAvailable(pItemsiteId, TRUE); RETURN _qty; END; $$; ALTER FUNCTION public.qtyavailable(pitemsiteid integer) OWNER TO admin; -- -- Name: qtyavailable(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtyavailable(pitemsiteid integer, plookaheaddays integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN RETURN ( ( SELECT qtyAvailable(itemsite_id) FROM itemsite WHERE (itemsite_id=pItemsiteid) ) + (SELECT qtyOrdered(pItemsiteid, pLookAheadDays)) - (SELECT qtyAllocated(pitemsiteid, pLookAheadDays)) ); END; $$; ALTER FUNCTION public.qtyavailable(pitemsiteid integer, plookaheaddays integer) OWNER TO admin; -- -- Name: qtyavailable(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtyavailable(pitemsiteid integer, pdate date) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN RETURN ( ( SELECT qtyAvailable(itemsite_id) FROM itemsite WHERE (itemsite_id=pItemsiteid) ) + (SELECT qtyOrdered(pItemsiteid, (pDate - CURRENT_DATE))) - (SELECT qtyAllocated(pItemsiteid, (pDate - CURRENT_DATE))) ); END; $$; ALTER FUNCTION public.qtyavailable(pitemsiteid integer, pdate date) OWNER TO admin; -- -- Name: qtyavailable(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtyavailable(pitemsiteid integer, pusable boolean) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _qty NUMERIC = 0.0; BEGIN IF (pUsable) THEN -- Summarize itemloc qty for this itemsite/usable locations -- or use itemsite_qtyonhand for regular/non-lot SELECT COALESCE(SUM(itemloc_qty), itemsite_qtyonhand) INTO _qty FROM itemsite LEFT OUTER JOIN itemloc ON (itemloc_itemsite_id=itemsite_id) LEFT OUTER JOIN location ON (location_id=itemloc_location_id) WHERE (itemsite_id=pItemsiteId) AND ((location_id IS NULL) OR (COALESCE(location_usable, true))) GROUP BY itemsite_qtyonhand; ELSE -- Summarize itemloc qty for this itemsite/non-usable locations SELECT COALESCE(SUM(itemloc_qty), 0.0) INTO _qty FROM itemloc JOIN location ON (location_id=itemloc_location_id) WHERE (itemloc_itemsite_id=pItemsiteId) AND (NOT COALESCE(location_usable, true)); END IF; RETURN _qty; END; $$; ALTER FUNCTION public.qtyavailable(pitemsiteid integer, pusable boolean) OWNER TO admin; -- -- Name: qtyinshipment(text, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtyinshipment(text, integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; plineitemid ALIAS FOR $2; pshipheadid ALIAS FOR $3; _qty NUMERIC; BEGIN IF (pordertype NOT IN ('SO', 'TO')) THEN RAISE EXCEPTION '% is not a valid order type', pordertype; END IF; IF (pshipheadid IS NULL) THEN RAISE EXCEPTION 'Cannot calculate quantity in a shipment with a NULL shipment'; END IF; SELECT SUM(COALESCE(shipitem_qty, 0.0)) INTO _qty FROM shipitem, shiphead WHERE ((shipitem_shiphead_id=shiphead_id) AND (shiphead_order_type=pordertype) AND (shipitem_orderitem_id=plineitemid) AND (shiphead_id=pshipheadid)); IF (NOT FOUND) THEN RAISE WARNING 'Quantity of % item % is 0 because shipment % does not exist.', pordertype, plineitemid, pshipheadid; END IF; RETURN _qty; END; $_$; ALTER FUNCTION public.qtyinshipment(text, integer, integer) OWNER TO admin; -- -- Name: qtylocation(integer, integer, date, date, integer, text, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtylocation(integer, integer, date, date, integer, text, integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLocationId ALIAS FOR $1; pLsId ALIAS FOR $2; pExpiration ALIAS FOR $3; pWarranty ALIAS FOR $4; pItemsiteId ALIAS FOR $5; pOrderType ALIAS FOR $6; pOrderId ALIAS FOR $7; pItemlocdistId ALIAS FOR $8; _qty NUMERIC = 0.0; _qtyDist NUMERIC = 0.0; _qtyReserved NUMERIC = 0.0; BEGIN -- Summarize itemloc qty for this location/itemsite SELECT COALESCE(SUM(itemloc_qty), 0) INTO _qty FROM itemloc WHERE ( (itemloc_itemsite_id=pItemsiteId) AND (itemloc_location_id=pLocationId) AND (COALESCE(itemloc_ls_id, -1)=COALESCE(pLsId, itemloc_ls_id, -1)) AND (COALESCE(itemloc_expiration, endoftime())=COALESCE(pExpiration, itemloc_expiration, endoftime())) AND (COALESCE(itemloc_warrpurc, endoftime())=COALESCE(pWarranty, itemloc_warrpurc, endoftime())) ); -- Summarize qty distributed but not yet committed by previous distributions SELECT COALESCE(SUM(loc.itemlocdist_qty), 0) INTO _qtyDist FROM itemlocdist loc JOIN itemlocdist ls ON ((ls.itemlocdist_source_type='O') AND (ls.itemlocdist_id=loc.itemlocdist_itemlocdist_id)) WHERE ( (ls.itemlocdist_itemsite_id=pItemsiteId) AND (loc.itemlocdist_source_type='L') AND (loc.itemlocdist_source_id=pLocationId) AND (COALESCE(ls.itemlocdist_ls_id, -1)=COALESCE(pLsId, ls.itemlocdist_ls_id, -1)) AND (COALESCE(ls.itemlocdist_expiration, endoftime())=COALESCE(pExpiration, ls.itemlocdist_expiration, endoftime())) AND (COALESCE(ls.itemlocdist_warranty, endoftime())=COALESCE(pWarranty, ls.itemlocdist_warranty, endoftime())) AND (ls.itemlocdist_id != pItemlocdistId ) ); -- Summarize reserved qty for this location/itemsite -- that is reserved for a different order IF (fetchMetricBool('EnableSOReservationsByLocation')) THEN SELECT COALESCE(SUM(reserve_qty), 0) INTO _qtyReserved FROM itemloc JOIN reserve ON ( (reserve_supply_id=itemloc_id AND reserve_supply_type='I') AND ((reserve_demand_type <> COALESCE(pOrderType, '')) OR (reserve_demand_id <> COALESCE(pOrderId, -1))) ) WHERE ( (itemloc_itemsite_id=pItemsiteId) AND (itemloc_location_id=pLocationId) AND (COALESCE(itemloc_ls_id, -1)=COALESCE(pLsId, itemloc_ls_id, -1)) AND (COALESCE(itemloc_expiration, endoftime())=COALESCE(pExpiration, itemloc_expiration, endoftime())) AND (COALESCE(itemloc_warrpurc, endoftime())=COALESCE(pWarranty, itemloc_warrpurc, endoftime())) ); END IF; RETURN (_qty + _qtyDist - _qtyReserved); END; $_$; ALTER FUNCTION public.qtylocation(integer, integer, date, date, integer, text, integer, integer) OWNER TO admin; -- -- Name: qtynetable(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtynetable(pitemsiteid integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _qty NUMERIC = 0.0; BEGIN _qty := qtyNetable(pItemsiteId, TRUE); RETURN _qty; END; $$; ALTER FUNCTION public.qtynetable(pitemsiteid integer) OWNER TO admin; -- -- Name: qtynetable(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtynetable(pitemsiteid integer, pnetable boolean) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _qty NUMERIC = 0.0; BEGIN IF (pNetable) THEN -- Summarize itemloc qty for this itemsite/netable locations -- or use itemsite_qtyonhand for regular/non-lot SELECT COALESCE(SUM(itemloc_qty), itemsite_qtyonhand) INTO _qty FROM itemsite LEFT OUTER JOIN itemloc ON (itemloc_itemsite_id=itemsite_id) LEFT OUTER JOIN location ON (location_id=itemloc_location_id) WHERE (itemsite_id=pItemsiteId) AND ((location_id IS NULL) OR (COALESCE(location_netable, true))) GROUP BY itemsite_qtyonhand; ELSE -- Summarize itemloc qty for this itemsite/non-netable locations SELECT COALESCE(SUM(itemloc_qty), 0.0) INTO _qty FROM itemloc JOIN location ON (location_id=itemloc_location_id) WHERE (itemloc_itemsite_id=pItemsiteId) AND (NOT COALESCE(location_netable, true)); END IF; RETURN _qty; END; $$; ALTER FUNCTION public.qtynetable(pitemsiteid integer, pnetable boolean) OWNER TO admin; -- -- Name: qtyordered(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtyordered(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pLookahead ALIAS FOR $2; _itemType TEXT; _result NUMERIC; BEGIN RETURN qtyOrdered(pItemsiteid, startOfTime(), (CURRENT_DATE + pLookahead)); END; $_$; ALTER FUNCTION public.qtyordered(integer, integer) OWNER TO admin; -- -- Name: qtyordered(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtyordered(integer, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pDate ALIAS FOR $2; BEGIN RETURN qtyOrdered(pItemsiteid, startOfTime(), pDate); END; $_$; ALTER FUNCTION public.qtyordered(integer, date) OWNER TO admin; -- -- Name: qtyordered(integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtyordered(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _itemType TEXT; BEGIN SELECT item_type INTO _itemType FROM item, itemsite WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ); IF ( SELECT metric_value FROM metric WHERE ((metric_name = 'MultiWhs') AND (metric_value = 't'))) THEN RETURN orderedByPo(pItemsiteid, pStartDate, pEndDate) + orderedByWo(pItemsiteid, pStartDate, pEndDate) + orderedByTo(pItemsiteid, pStartDate, pEndDate); ELSE RETURN orderedByPo(pItemsiteid, pStartDate, pEndDate) + orderedByWo(pItemsiteid, pStartDate, pEndDate); END IF; END; $_$; ALTER FUNCTION public.qtyordered(integer, date, date) OWNER TO admin; -- -- Name: qtypr(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtypr(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pLookahead ALIAS FOR $2; BEGIN RETURN qtypr(pItemsiteid, startOfTime(), (CURRENT_DATE + pLookahead)); END; $_$; ALTER FUNCTION public.qtypr(integer, integer) OWNER TO admin; -- -- Name: qtypr(integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtypr(integer, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pDate ALIAS FOR $2; BEGIN RETURN qtypr(pItemsiteid, startOfTime(), pDate); END; $_$; ALTER FUNCTION public.qtypr(integer, date) OWNER TO admin; -- -- Name: qtypr(integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtypr(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _prtotal NUMERIC; BEGIN SELECT SUM(pr_qtyreq) INTO _prtotal FROM pr WHERE ((pr_status = 'O') AND (pr_itemsite_id=pItemsiteid) AND (pr_duedate BETWEEN pStartDate AND pEndDate)); IF (_prtotal IS NULL) THEN RETURN 0.0; END IF; RETURN _prtotal; END; $_$; ALTER FUNCTION public.qtypr(integer, date, date) OWNER TO admin; -- -- Name: qtyreserved(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtyreserved(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/EULA for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; _qty NUMERIC; BEGIN SELECT COALESCE(SUM(coitem_qtyreserved),0) INTO _qty FROM coitem WHERE(coitem_itemsite_id=pItemsiteid); RETURN _qty; END; $_$; ALTER FUNCTION public.qtyreserved(integer) OWNER TO admin; -- -- Name: qtytoreceive(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION qtytoreceive(text, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; porderitemid ALIAS FOR $2; _qty NUMERIC; BEGIN IF (pordertype = 'TO' AND NOT fetchMetricBool('MultiWhs')) THEN RETURN 0; END IF; IF (pordertype = 'RA' AND NOT fetchMetricBool('EnableReturnAuth')) THEN RETURN 0; END IF; SELECT SUM(recv_qty) INTO _qty FROM recv WHERE ((recv_orderitem_id=porderitemid) AND (NOT recv_posted) AND (recv_order_type=pordertype)); RETURN COALESCE(_qty, 0.0); END; $_$; ALTER FUNCTION public.qtytoreceive(text, integer) OWNER TO admin; -- -- Name: recallshipment(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION recallshipment(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN recallShipment($1, CURRENT_TIMESTAMP); END; $_$; ALTER FUNCTION public.recallshipment(integer) OWNER TO admin; -- -- Name: recallshipment(integer, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION recallshipment(integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pshipheadid ALIAS FOR $1; _timestamp TIMESTAMP WITH TIME ZONE := $2; _allInvoiced BOOLEAN; _invoicePosted BOOLEAN; _in RECORD; _co RECORD; _cobill RECORD; _h RECORD; _result INTEGER; _invhistid INTEGER; _itemlocSeries INTEGER; _qty NUMERIC; _qtyFromDest NUMERIC; _qtyFromTransit NUMERIC; _qtyToBill NUMERIC; _shiphead RECORD; _to RECORD; _ti RECORD; _value NUMERIC; BEGIN IF (_timestamp IS NULL) THEN _timestamp := CURRENT_TIMESTAMP; END IF; SELECT * INTO _shiphead FROM shiphead WHERE (shiphead_id=pshipheadid); IF (NOT FOUND OR NOT _shiphead.shiphead_shipped) THEN RETURN -1; END IF; IF (_shiphead.shiphead_order_type = 'SO') THEN SELECT cohead_number AS head_number, cohead_cust_id AS cust_id, cohead_prj_id AS prj_id, cohead_saletype_id AS saletype_id, cohead_shipzone_id AS shipzone_id INTO _h FROM cohead WHERE (cohead_id=_shiphead.shiphead_order_id); IF (NOT FOUND) THEN RETURN -1; END IF; SELECT COALESCE(BOOL_AND(shipitem_invoiced), FALSE) INTO _allInvoiced FROM cobill, shipitem WHERE ((cobill_coitem_id=shipitem_orderitem_id) AND (shipitem_shiphead_id=pshipheadid)); IF (_allInvoiced AND NOT checkPrivilege('RecallInvoicedShipment')) THEN RETURN -2; END IF; -- Check for any associated posted Invoices SELECT COALESCE(BOOL_AND(invchead_posted), FALSE) INTO _invoicePosted FROM shipitem JOIN invcitem ON (invcitem_id=shipitem_invcitem_id) JOIN invchead ON (invchead_id=invcitem_invchead_id) WHERE (shipitem_shiphead_id=pshipheadid); IF (_invoicePosted) THEN RETURN -4; END IF; -- Delete any associated unposted Invoices FOR _in IN SELECT DISTINCT invchead_id FROM shipitem JOIN invcitem ON (invcitem_id=shipitem_invcitem_id) JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND (NOT invchead_posted) ) WHERE (shipitem_shiphead_id=pshipheadid) LOOP SELECT deleteInvoice(_in.invchead_id) INTO _result; IF (_result < 0) THEN RETURN _result; END IF; END LOOP; FOR _co IN SELECT coitem_id, coitem_itemsite_id, coitem_qty_invuomratio, coitem_warranty, coitem_cos_accnt_id, itemsite_controlmethod FROM coitem JOIN itemsite ON (coitem_itemsite_id=itemsite_id) WHERE(coitem_id IN (SELECT shipitem_orderitem_id FROM shipitem, shiphead WHERE((shipitem_shiphead_id=shiphead_id) AND (shiphead_shipped) AND (shiphead_id=pshipheadid)))) FOR UPDATE LOOP SELECT SUM(shipitem_qty),SUM(COALESCE(shipitem_value, 0)) INTO _qty, _value FROM shipitem WHERE ( (shipitem_orderitem_id=_co.coitem_id) AND (shipitem_shiphead_id=pshipheadid) ); UPDATE coitem SET coitem_qtyshipped = (coitem_qtyshipped - _qty) WHERE (coitem_id=_co.coitem_id); _qtyToBill := _qty; FOR _cobill IN SELECT cobill_id, cobill_qty FROM cobill, shipitem WHERE ((cobill_coitem_id=shipitem_orderitem_id) AND (shipitem_shiphead_id=pshipheadid) AND (cobill_coitem_id=_co.coitem_id)) FOR UPDATE LOOP IF (noNeg(_cobill.cobill_qty - _qtyToBill) = 0) THEN DELETE FROM cobill WHERE (cobill_id=_cobill.cobill_id); ELSE UPDATE cobill SET cobill_qty = noNeg(cobill_qty - _qtyToBill) WHERE (cobill_id=_cobill.cobill_id); END IF; _qtyToBill = _qtyToBill - _cobill.cobill_qty; EXIT WHEN (_qtyToBill <= 0.0); END LOOP; -- Check to see if all of the cobills have been deleted for this cobmisc IF (EXISTS(SELECT cobmisc_id FROM cobmisc JOIN cobill ON (cobill_cobmisc_id=cobmisc_id) WHERE (cobmisc_cohead_id=_shiphead.shiphead_order_id AND NOT cobmisc_posted))) THEN -- Lines exist, update the freight UPDATE cobmisc SET cobmisc_freight = (cobmisc_freight - _shiphead.shiphead_freight) WHERE (cobmisc_cohead_id=_shiphead.shiphead_order_id AND NOT cobmisc_posted); ELSE -- No lines exist, delete the cobmisc DELETE FROM cobmisc WHERE (cobmisc_cohead_id=_shiphead.shiphead_order_id AND NOT cobmisc_posted); END IF; -- Distribute to G/L, debit Shipping Asset, credit COS IF (_co.itemsite_controlmethod != 'N') THEN PERFORM insertGLTransaction( 'S/R', _shiphead.shiphead_order_type, _h.head_number::TEXT, 'Recall Shipment', CASE WHEN(COALESCE(_co.coitem_cos_accnt_id, -1) != -1) THEN getPrjAccntId(_h.prj_id, _co.coitem_cos_accnt_id) WHEN(_co.coitem_warranty = TRUE) THEN getPrjAccntId(_h.prj_id, resolveCOWAccount(itemsite_id, _h.cust_id, _h.saletype_id, _h.shipzone_id)) ELSE getPrjAccntId(_h.prj_id, resolveCOSAccount(itemsite_id, _h.cust_id, _h.saletype_id, _h.shipzone_id)) END, getPrjAccntId(_h.prj_id,costcat_shipasset_accnt_id), -1, _value, _timestamp::DATE ) FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_co.coitem_itemsite_id) ); END IF; END LOOP; -- Kit billing selection -- Set kit billing qty to zero since kits are shipped complete FOR _cobill IN SELECT cobill_id, cobill_qty FROM shipitem JOIN coitem sub ON (sub.coitem_id=shipitem_orderitem_id) JOIN coitem kit ON (kit.coitem_id <> sub.coitem_id AND kit.coitem_cohead_id = sub.coitem_cohead_id AND kit.coitem_linenumber = sub.coitem_linenumber AND kit.coitem_subnumber = 0) JOIN cobill ON (cobill_coitem_id=kit.coitem_id) WHERE (shipitem_shiphead_id=pshipheadid) AND (sub.coitem_subnumber > 0) GROUP BY cobill_id, cobill_qty LOOP UPDATE cobill SET cobill_qty = 0.0 WHERE (cobill_id=_cobill.cobill_id); END LOOP; ELSEIF (_shiphead.shiphead_order_type = 'TO') THEN SELECT * INTO _to FROM tohead WHERE (tohead_id=_shiphead.shiphead_order_id); IF (NOT FOUND) THEN RETURN -1; END IF; IF (_to.tohead_status = 'C') THEN RETURN -6; END IF; FOR _ti IN SELECT toitem_id, toitem_qty_received, sis.itemsite_id AS src_itemsite_id, tis.itemsite_id AS trns_itemsite_id, dis.itemsite_id AS dest_itemsite_id, scc.costcat_shipasset_accnt_id AS src_shipasset_accnt_id, tcc.costcat_asset_accnt_id AS trns_asset_accnt_id, itemcost(tis.itemsite_id) AS trns_cost, SUM(shipitem_qty) AS recall_qty FROM shipitem JOIN toitem ON (toitem_id=shipitem_orderitem_id) JOIN itemsite sis ON (sis.itemsite_item_id=toitem_item_id AND sis.itemsite_warehous_id=_to.tohead_src_warehous_id) JOIN itemsite tis ON (tis.itemsite_item_id=toitem_item_id AND tis.itemsite_warehous_id=_to.tohead_trns_warehous_id) JOIN itemsite dis ON (dis.itemsite_item_id=toitem_item_id AND dis.itemsite_warehous_id=_to.tohead_dest_warehous_id) JOIN costcat scc ON (scc.costcat_id=sis.itemsite_costcat_id) JOIN costcat tcc ON (tcc.costcat_id=tis.itemsite_costcat_id) WHERE (shipitem_shiphead_id=pshipheadid) GROUP BY toitem_id, toitem_qty_received, sis.itemsite_id, tis.itemsite_id, dis.itemsite_id, scc.costcat_shipasset_accnt_id, tcc.costcat_asset_accnt_id LOOP _itemlocSeries := NEXTVAL('itemloc_series_seq'); SELECT postInvTrans(_ti.src_itemsite_id, 'TS', (_ti.recall_qty * -1.0), 'I/M', _shiphead.shiphead_order_type, formatToNumber(_ti.toitem_id), _to.tohead_number, 'Recall TO Shipment To Src Warehouse', _ti.trns_asset_accnt_id, _ti.src_shipasset_accnt_id, _itemlocSeries, _timestamp, (_ti.trns_cost * _ti.recall_qty * -1.0)) INTO _invhistid; IF (_invhistid < 0) THEN RETURN _invhistid; END IF; -- post the inventory history if lot/serial or location control PERFORM postItemlocseries(_itemlocSeries); -- determine the qty to be recalled from destination warehouse and -- qty to be recalled from transit warehouse IF (_ti.toitem_qty_received >= _ti.recall_qty) THEN _qtyFromDest := _ti.recall_qty; _qtyFromTransit := 0.0; ELSE _qtyFromDest := _ti.toitem_qty_received; _qtyFromTransit := _ti.recall_qty - _qtyFromDest; END IF; -- record inventory history and qoh changes at destination warehouse but -- there is only one g/l account to touch IF (_qtyFromDest > 0.0) THEN SELECT postInvTrans(_ti.dest_itemsite_id, 'TR', (_qtyFromDest * -1.0), 'I/M', _shiphead.shiphead_order_type, formatToNumber(_ti.toitem_id), _to.tohead_number, 'Recall TO Shipment From Destination Warehouse', _ti.trns_asset_accnt_id, _ti.trns_asset_accnt_id, _itemlocSeries, _timestamp, (_ti.trns_cost * _qtyFromDest * -1.0)) INTO _invhistid; IF (_invhistid < 0) THEN RETURN _invhistid; END IF; END IF; -- record inventory history and qoh changes at transit warehouse but -- there is only one g/l account to touch IF (_qtyFromTransit > 0.0) THEN SELECT postInvTrans(_ti.trns_itemsite_id, 'TR', (_qtyFromTransit * -1.0), 'I/M', _shiphead.shiphead_order_type, formatToNumber(_ti.toitem_id), _to.tohead_number, 'Recall TO Shipment From Transit Warehouse', _ti.trns_asset_accnt_id, _ti.trns_asset_accnt_id, _itemlocSeries, _timestamp, (_ti.trns_cost * _qtyFromTransit * -1.0)) INTO _invhistid; IF (_invhistid < 0) THEN RETURN _invhistid; END IF; END IF; -- post the inventory history if lot/serial or location control PERFORM postItemlocseries(_itemlocSeries); UPDATE toitem SET toitem_qty_shipped = (toitem_qty_shipped - _ti.recall_qty), toitem_qty_received = (toitem_qty_received - _qtyFromDest) WHERE (toitem_id=_ti.toitem_id); UPDATE shipitem SET shipitem_shipdate=NULL, shipitem_shipped=FALSE, shipitem_value=(shipitem_qty * _ti.trns_cost) WHERE ((shipitem_orderitem_id=_ti.toitem_id) AND (shipitem_shiphead_id=pshipheadid)); DELETE FROM recv WHERE ((recv_orderitem_id=_ti.toitem_id) AND (recv_order_type='TO') AND (NOT recv_posted)); END LOOP; END IF; UPDATE shiphead SET shiphead_shipped=FALSE WHERE (shiphead_id=pshipheadid); RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.recallshipment(integer, timestamp with time zone) OWNER TO admin; -- -- Name: recallwo(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION recallwo(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; recallChildren ALIAS FOR $2; returnCode INTEGER; BEGIN UPDATE wo SET wo_status='E' WHERE ((wo_status='R') AND (wo_id=pWoid)); IF (recallChildren) THEN returnCode := (SELECT MAX(recallWo(wo_id, TRUE)) FROM wo WHERE ((wo_ordtype='W') AND (wo_ordid=pWoid))); END IF; RETURN 0; END; $_$; ALTER FUNCTION public.recallwo(integer, boolean) OWNER TO admin; -- -- Name: receipts(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION receipts(text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTransType ALIAS FOR $1; BEGIN IF (pTransType IN ('RM', 'RB', 'RT', 'RP', 'RR', 'RX', 'TR')) THEN RETURN TRUE; ELSE RETURN FALSE; END IF; END; $_$; ALTER FUNCTION public.receipts(text) OWNER TO admin; -- -- Name: releaseapmemonumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releaseapmemonumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('APMemoNumber', $1::INTEGER) > 0; $_$; ALTER FUNCTION public.releaseapmemonumber(integer) OWNER TO admin; -- -- Name: releasearmemonumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releasearmemonumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. select releaseNumber('ARMemoNumber', $1::INTEGER) > 0; $_$; ALTER FUNCTION public.releasearmemonumber(integer) OWNER TO admin; -- -- Name: releasecashrcptnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releasecashrcptnumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('CashRcptNumber', $1) > 0; $_$; ALTER FUNCTION public.releasecashrcptnumber(integer) OWNER TO admin; -- -- Name: releasecmnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releasecmnumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('CmNumber', $1) > 0; $_$; ALTER FUNCTION public.releasecmnumber(integer) OWNER TO admin; -- -- Name: releasecmnumber(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releasecmnumber(text) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('CmNumber', $1::INTEGER) > 0; $_$; ALTER FUNCTION public.releasecmnumber(text) OWNER TO admin; -- -- Name: releasecrmaccountnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releasecrmaccountnumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('CRMAccountNumber', $1::INTEGER) > 0; $_$; ALTER FUNCTION public.releasecrmaccountnumber(integer) OWNER TO admin; -- -- Name: releaseincidentnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releaseincidentnumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('IncidentNumber', $1) = 1; $_$; ALTER FUNCTION public.releaseincidentnumber(integer) OWNER TO admin; -- -- Name: releaseinvcnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releaseinvcnumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('InvcNumber', $1) > 0; $_$; ALTER FUNCTION public.releaseinvcnumber(integer) OWNER TO admin; -- -- Name: releaseinvcnumber(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releaseinvcnumber(text) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('InvcNumber', $1::INTEGER) > 0; $_$; ALTER FUNCTION public.releaseinvcnumber(text) OWNER TO admin; -- -- Name: releasenumber(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releasenumber(psequence text, pnumber integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _isManual BOOLEAN; _test INTEGER; _number INTEGER; _table TEXT; _numcol TEXT; _select TEXT; BEGIN IF (fetchMetricBool('EnableGaplessNumbering')) THEN -- drop the number back into the pool if it was not committed PERFORM clearNumberIssue(psequence, pnumber); UPDATE orderseq SET orderseq_number = LEAST(pnumber, orderseq_number) WHERE (orderseq_name=psequence); ELSE -- get the current state of the sequence SELECT orderseq_number::integer, orderseq_table, orderseq_numcol INTO _number, _table, _numcol FROM orderseq WHERE (orderseq_name=psequence); IF (NOT FOUND) THEN RAISE EXCEPTION 'Invalid orderseq_name %', psequence; END IF; -- check if an order exists with the given order number -- Have to factor in scenario where Quotes are set to use SO Numbering IF (psequence = 'SoNumber' AND fetchmetrictext('QUNumberGeneration') = 'S') THEN _select := 'SELECT ' || quote_ident(_numcol) || ' FROM ' || _table || ' WHERE (' || quote_ident(_numcol) || '=' || quote_literal(_number - 1) || ') ' || ' UNION SELECT quhead_number FROM quhead WHERE (quhead_number = ' || quote_literal(_number - 1) || ');'; ELSE _select := 'SELECT ' || quote_ident(_numcol) || ' FROM ' || _table || ' WHERE (' || quote_ident(_numcol) || '=' || quote_literal(_number - 1) || ');'; END IF; EXECUTE _select INTO _test; -- Check if order seq has been incremented past the given order number -- Problem occurred with open but not saved orders (i.e. open by two or more people -- at the same time) so need to check for that as well. IF ((FOUND AND (_test > pnumber)) OR ((_test IS NULL) AND ((_number - 1) > pnumber)) OR (_number = pnumber)) THEN RETURN 0; END IF; SELECT metric_value = 'M' INTO _isManual FROM metric WHERE (metric_name = CASE WHEN psequence='CmNumber' THEN 'CMNumberGeneration' WHEN psequence='SoNumber' THEN 'CONumberGeneration' WHEN psequence='InvcNumber' THEN 'InvcNumberGeneration' WHEN psequence='PoNumber' THEN 'PONumberGeneration' WHEN psequence='PrNumber' THEN 'PrNumberGeneration' WHEN psequence='QuNumber' THEN 'QUNumberGeneration' WHEN psequence='RaNumber' THEN 'RANumberGeneration' -- WHEN psequence='??Number' THEN 'ShipmentNumberGeneration' WHEN psequence='ToNumber' THEN 'TONumberGeneration' WHEN psequence='VcNumber' THEN 'VoucherNumberGeneration' WHEN psequence='WoNumber' THEN 'WONumberGeneration' ELSE NULL END); -- release the given order number for reuse IF (NOT FOUND OR NOT _isManual) THEN UPDATE orderseq SET orderseq_number = (_number - 1) WHERE (orderseq_name=psequence); ELSE RAISE WARNING 'cannot update orderseq'; END IF; END IF; RETURN 1; END; $$; ALTER FUNCTION public.releasenumber(psequence text, pnumber integer) OWNER TO admin; -- -- Name: releaseponumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releaseponumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('PoNumber', $1) > 0; $_$; ALTER FUNCTION public.releaseponumber(integer) OWNER TO admin; -- -- Name: releaseponumber(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releaseponumber(text) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('PoNumber', $1::INTEGER) > 0; $_$; ALTER FUNCTION public.releaseponumber(text) OWNER TO admin; -- -- Name: releasepr(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releasepr(pprid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _pr RECORD; _w RECORD; _i RECORD; _rows INTEGER := 0; _itemsrcid INTEGER := -1; _poheadid INTEGER := -1; _poitemid INTEGER := -1; _taxtypeid INTEGER := -1; _polinenumber INTEGER; _ponumber NUMERIC; _price NUMERIC; BEGIN -- Cache information SELECT *, CASE WHEN(pr_order_type='W') THEN pr_order_id ELSE -1 END AS parentwo, CASE WHEN(pr_order_type='S') THEN pr_order_id ELSE -1 END AS parentso INTO _pr FROM pr LEFT OUTER JOIN itemsite ON (pr_itemsite_id = itemsite_id) LEFT OUTER JOIN item ON (item_id = itemsite_item_id) LEFT OUTER JOIN prj ON (prj_id = pr_prj_id) WHERE (pr_id = pPrId); IF (NOT FOUND) THEN RETURN -1; END IF; SELECT * INTO _w FROM itemsite JOIN whsinfo ON (warehous_id = itemsite_warehous_id) LEFT OUTER JOIN addr ON (warehous_addr_id = addr_id) LEFT OUTER JOIN cntct ON (warehous_cntct_id = cntct_id) WHERE (itemsite_id = _pr.itemsite_id); -- Must either be a single itemsrc or a default itemsrc SELECT itemsrc_id INTO _itemsrcid FROM itemsrc WHERE (itemsrc_item_id = _pr.item_id) AND (_pr.pr_duedate BETWEEN COALESCE(itemsrc_effective, startOfTime()) AND COALESCE(itemsrc_expires, endOfTime())) AND (itemsrc_default); IF (NOT FOUND) THEN SELECT MAX(itemsrc_id), count(*) INTO _itemsrcid, _rows FROM itemsrc WHERE (itemsrc_item_id = _pr.item_id) AND (_pr.pr_duedate BETWEEN COALESCE(itemsrc_effective, startOfTime()) AND COALESCE(itemsrc_expires, endOfTime())) GROUP BY itemsrc_item_id; IF (NOT FOUND) THEN RETURN -2; END IF; IF (_rows > 1) THEN RETURN -2; END IF; END IF; SELECT * INTO _i FROM itemsrc JOIN vendinfo ON (itemsrc_vend_id = vend_id) LEFT OUTER JOIN cntct ON (vend_cntct1_id = cntct_id) LEFT OUTER JOIN addr ON (vend_addr_id = addr_id) WHERE (itemsrc_id = _itemsrcid); --RAISE NOTICE 'releasepr selected itemsrc_id = % for pr = %', _itemsrcid, _pr.pr_id; -- Find matching unreleased PO SELECT COALESCE(pohead_id, -1) INTO _poheadid FROM pohead WHERE ( (pohead_status = 'U') AND (pohead_vend_id = _i.itemsrc_vend_id) AND (COALESCE(pohead_shiptoaddress1, '') = COALESCE(_w.addr_line1, '')) AND (COALESCE(pohead_shiptoaddress2, '') = COALESCE(_w.addr_line2, '')) AND (COALESCE(pohead_shiptoaddress3, '') = COALESCE(_w.addr_line3, '')) AND (COALESCE(pohead_shiptocity, '') = COALESCE(_w.addr_city, '')) AND (COALESCE(pohead_shiptostate, '') = COALESCE(_w.addr_state, '')) AND (COALESCE(pohead_shiptozipcode, '') = COALESCE(_w.addr_postalcode, '')) AND (COALESCE(pohead_shiptocountry, '') = COALESCE(_w.addr_country, '')) ); IF (NOT FOUND) THEN -- Create new PO SELECT NEXTVAL('pohead_pohead_id_seq') INTO _poheadid; SELECT fetchPoNumber() INTO _ponumber; INSERT INTO pohead ( pohead_id, pohead_number, pohead_status, pohead_dropship, pohead_agent_username, pohead_vend_id, pohead_taxzone_id, pohead_orderdate, pohead_curr_id, pohead_cohead_id, pohead_warehous_id, pohead_shipvia, pohead_terms_id, pohead_shipto_cntct_id, pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name, pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name, pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone, pohead_shipto_cntct_title, pohead_shipto_cntct_fax, pohead_shipto_cntct_email, pohead_shiptoaddress_id, pohead_shiptoaddress1, pohead_shiptoaddress2, pohead_shiptoaddress3, pohead_shiptocity, pohead_shiptostate, pohead_shiptozipcode, pohead_shiptocountry, pohead_vend_cntct_id, pohead_vend_cntct_honorific, pohead_vend_cntct_first_name, pohead_vend_cntct_middle, pohead_vend_cntct_last_name, pohead_vend_cntct_suffix, pohead_vend_cntct_phone, pohead_vend_cntct_title, pohead_vend_cntct_fax, pohead_vend_cntct_email, pohead_vendaddress1, pohead_vendaddress2, pohead_vendaddress3, pohead_vendcity, pohead_vendstate, pohead_vendzipcode, pohead_vendcountry ) VALUES ( _poheadid, _ponumber, 'U', FALSE, getEffectiveXtUser(), _i.itemsrc_vend_id, _i.vend_taxzone_id, CURRENT_DATE, COALESCE(_i.vend_curr_id, basecurrid()), NULL, COALESCE(_pr.itemsite_warehous_id, -1), COALESCE(_i.vend_shipvia, TEXT('')), COALESCE(_i.vend_terms_id, -1), _w.cntct_id, _w.cntct_honorific, _w.cntct_first_name, _w.cntct_middle, _w.cntct_last_name, _w.cntct_suffix, _w.cntct_phone, _w.cntct_title, _w.cntct_fax, _w.cntct_email, _w.addr_id, COALESCE(_w.addr_line1, ''), COALESCE(_w.addr_line2, ''), COALESCE(_w.addr_line3, ''), COALESCE(_w.addr_city, ''), COALESCE(_w.addr_state, ''), COALESCE(_w.addr_postalcode, ''), COALESCE(_w.addr_country, ''), _i.cntct_id, COALESCE(_i.cntct_honorific, TEXT('')), COALESCE(_i.cntct_first_name, TEXT('')), COALESCE(_i.cntct_middle, TEXT('')), COALESCE(_i.cntct_last_name, TEXT('')), COALESCE(_i.cntct_suffix, TEXT('')), COALESCE(_i.cntct_phone, TEXT('')), COALESCE(_i.cntct_title, TEXT('')), COALESCE(_i.cntct_fax, TEXT('')), COALESCE(_i.cntct_email, TEXT('')), COALESCE(_i.addr_line1, TEXT('')), COALESCE(_i.addr_line2, TEXT('')), COALESCE(_i.addr_line3, TEXT('')), COALESCE(_i.addr_city, TEXT('')), COALESCE(_i.addr_state, TEXT('')), COALESCE(_i.addr_postalcode, TEXT('')), COALESCE(_i.addr_country, TEXT('')) ); END IF; SELECT NEXTVAL('poitem_poitem_id_seq') INTO _poitemid; SELECT (COALESCE(MAX(poitem_linenumber), 0) + 1) INTO _polinenumber FROM poitem WHERE (poitem_pohead_id = _poheadid); SELECT COALESCE(itemtax_taxtype_id, -1) INTO _taxtypeid FROM itemtax WHERE (itemtax_item_id = _i.itemsrc_item_id); SELECT itemsrcPrice(_i.itemsrc_id, COALESCE(_pr.itemsite_warehous_id, -1), FALSE, (_pr.pr_qtyreq / COALESCE(_i.itemsrc_invvendoruomratio, 1.00)), COALESCE(_i.vend_curr_id, baseCurrId()), CURRENT_DATE) INTO _price; -- Create PO Item INSERT INTO poitem ( poitem_id, poitem_status, poitem_pohead_id, poitem_linenumber, poitem_duedate, poitem_itemsite_id, poitem_vend_item_descrip, poitem_vend_uom, poitem_invvenduomratio, poitem_qty_ordered, poitem_unitprice, poitem_vend_item_number, poitem_itemsrc_id, poitem_order_id, poitem_order_type, poitem_prj_id, poitem_stdcost, poitem_manuf_name, poitem_manuf_item_number, poitem_manuf_item_descrip, poitem_taxtype_id, poitem_comments ) VALUES ( _poitemid, 'U', _poheadid, _polinenumber, _pr.pr_duedate, _pr.itemsite_id, COALESCE(_i.itemsrc_vend_item_descrip, TEXT('')), COALESCE(_i.itemsrc_vend_uom, TEXT('')), COALESCE(_i.itemsrc_invvendoruomratio, 1.00), (_pr.pr_qtyreq / COALESCE(_i.itemsrc_invvendoruomratio, 1.00)), _price, COALESCE(_i.itemsrc_vend_item_number, TEXT('')), _i.itemsrc_id, CASE WHEN (_pr.parentwo > 0) THEN _pr.parentwo WHEN (_pr.parentso > 0) THEN _pr.parentso ELSE -1 END, CASE WHEN (_pr.parentwo > 0) THEN 'W' WHEN (_pr.parentso > 0) THEN 'S' ELSE '' END, _pr.prj_id, stdcost(_i.itemsrc_item_id), COALESCE(_i.itemsrc_manuf_name, TEXT('')), COALESCE(_i.itemsrc_manuf_item_number, TEXT('')), COALESCE(_i.itemsrc_manuf_item_descrip, TEXT('')), _taxtypeid, COALESCE(_pr.pr_releasenote, TEXT(''))); -- Copy characteristics from the pr to the poitem INSERT INTO charass ( charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price ) SELECT 'PI', _poitemid, charass_char_id, charass_value, charass_default, charass_price FROM charass WHERE ( (charass_target_type='PR') AND (charass_target_id=pPrId) ); -- Copy characteristics from the coitem to the poitem IF (_pr.parentso > 0) THEN INSERT INTO charass ( charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price ) SELECT 'PI', _poitemid, charass_char_id, charass_value, charass_default, charass_price FROM charass WHERE ( (charass_target_type='SI') AND (charass_target_id=_pr.parentso) ); END IF; -- Copy price override from the coitem to the poitem IF (_pr.parentso > 0) THEN SELECT coitem_prcost INTO _price FROM coitem WHERE (coitem_id=_pr.parentso); IF (_price > 0) THEN UPDATE poitem SET poitem_unitprice=_price WHERE (poitem_id=_poitemid); END IF; END IF; -- Update coitem with the poitem_id IF (_pr.parentso > 0) THEN UPDATE coitem SET coitem_order_id=_poitemid WHERE (coitem_id=_pr.parentso); END IF; -- Delete the PR PERFORM deletePr(pPrId); RETURN _poitemid; END; $$; ALTER FUNCTION public.releasepr(pprid integer) OWNER TO admin; -- -- Name: releaseprnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releaseprnumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('PrNumber', $1) > 0; $_$; ALTER FUNCTION public.releaseprnumber(integer) OWNER TO admin; -- -- Name: releasepurchaseorder(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releasepurchaseorder(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPoheadid ALIAS FOR $1; BEGIN IF ( ( SELECT (COUNT(*) = 0) FROM poitem WHERE ( (poitem_pohead_id=pPoheadid) AND (poitem_status='U') ) ) ) THEN RETURN -1; END IF; IF ( ( SELECT (pohead_status='U') FROM pohead WHERE (pohead_id=pPoheadid) ) ) THEN --update status and store the date that the order was released on UPDATE pohead SET pohead_status='O', pohead_released = current_date WHERE (pohead_id=pPoheadid); END IF; --update status and store the duedates at release UPDATE poitem SET poitem_status='O', poitem_rlsd_duedate = poitem_duedate WHERE (poitem_pohead_id=pPoheadid); RETURN 1; END; $_$; ALTER FUNCTION public.releasepurchaseorder(integer) OWNER TO admin; -- -- Name: releasequnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releasequnumber(integer) RETURNS integer LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('QuNumber', $1); $_$; ALTER FUNCTION public.releasequnumber(integer) OWNER TO admin; -- -- Name: releasequnumber(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releasequnumber(text) RETURNS integer LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('QuNumber', $1::INTEGER); $_$; ALTER FUNCTION public.releasequnumber(text) OWNER TO admin; -- -- Name: releaseshipmentnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releaseshipmentnumber(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _test INTEGER; BEGIN -- Check to see if a Shipment exists with the passed number SELECT shiphead_id INTO _test FROM shiphead WHERE (shiphead_number=pNumber); IF (FOUND) THEN RETURN FALSE; END IF; -- Check to see if ShipmentNumber orderseq has been incremented past the passed number SELECT orderseq_number INTO _test FROM orderseq WHERE (orderseq_name='ShipmentNumber'); IF ((_test - 1) <> pNumber) THEN RETURN FALSE; END IF; -- Decrement the orderseq, releasing the passed number UPDATE orderseq SET orderseq_number = (orderseq_number - 1) WHERE (orderseq_name='ShipmentNumber'); RETURN TRUE; END; $_$; ALTER FUNCTION public.releaseshipmentnumber(integer) OWNER TO admin; -- -- Name: releasesohead(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releasesohead(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; BEGIN DELETE FROM soheadlock WHERE ( (soheadlock_sohead_id=pSoheadid) AND (soheadlock_username=getEffectiveXtUser()) AND (soheadlock_procpid=pg_backend_pid()) ); RETURN TRUE; END; $_$; ALTER FUNCTION public.releasesohead(integer) OWNER TO admin; -- -- Name: releasesonumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releasesonumber(integer) RETURNS integer LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('SoNumber', $1); $_$; ALTER FUNCTION public.releasesonumber(integer) OWNER TO admin; -- -- Name: releasesonumber(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releasesonumber(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (COALESCE($1, '') = '' OR $1 ~ '[^0-9]') THEN --do nothing; RETURN 1; ELSE RETURN releaseNumber('SoNumber', $1::INTEGER); END IF; END; $_$; ALTER FUNCTION public.releasesonumber(text) OWNER TO admin; -- -- Name: releaseunusedbillingheader(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releaseunusedbillingheader(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCobmiscid ALIAS FOR $1; _p RECORD; BEGIN IF ( ( SELECT cobmisc_posted FROM cobmisc WHERE (cobmisc_id=pCobmiscid) ) ) THEN RETURN -1; END IF; SELECT cobill_id INTO _p FROM cobill WHERE (cobill_cobmisc_id=pCobmiscid) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; DELETE FROM cobmisc WHERE (cobmisc_id=pCobmiscid); RETURN 0; END; $_$; ALTER FUNCTION public.releaseunusedbillingheader(integer) OWNER TO admin; -- -- Name: releasevonumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releasevonumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('VcNumber', $1) > 0; $_$; ALTER FUNCTION public.releasevonumber(integer) OWNER TO admin; -- -- Name: releasewo(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releasewo(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; releaseChildren ALIAS FOR $2; returnCode INTEGER; BEGIN UPDATE wo SET wo_status='R' WHERE ((wo_status='E') AND (wo_id=pWoid)); IF (releaseChildren) THEN returnCode := (SELECT MAX(releaseWo(wo_id, TRUE)) FROM wo WHERE ((wo_ordtype='W') AND (wo_ordid=pWoid))); END IF; RETURN 0; END; $_$; ALTER FUNCTION public.releasewo(integer, boolean) OWNER TO admin; -- -- Name: releasewonumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION releasewonumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('WoNumber', $1) > 0; $_$; ALTER FUNCTION public.releasewonumber(integer) OWNER TO admin; -- -- Name: relocateinventory(integer, integer, integer, numeric, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION relocateinventory(integer, integer, integer, numeric, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN relocateInventory($1, $2, $3, $4, $5, CURRENT_TIMESTAMP); END; $_$; ALTER FUNCTION public.relocateinventory(integer, integer, integer, numeric, text) OWNER TO admin; -- -- Name: relocateinventory(integer, integer, integer, numeric, text, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION relocateinventory(psourceitemlocid integer, ptargetlocationid integer, pitemsiteid integer, pqty numeric, pcomments text, pgldistts timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _GlDistTS TIMESTAMP WITH TIME ZONE; _targetItemlocid INTEGER; _invhistid INTEGER; _p RECORD; _rsrv RECORD; _qty NUMERIC; _qtyunreserved NUMERIC := 0.0; _qtytomove NUMERIC := 0.0; _result INTEGER := -1; _itemlocSeries INTEGER := NEXTVAL('itemloc_series_seq'); BEGIN IF ((pGlDistTS IS NULL) OR (CAST(pGlDistTS AS date)=CURRENT_DATE)) THEN _GlDistTS := CURRENT_TIMESTAMP; ELSE _GLDistTS := pGLDistTS; END IF; -- Make sure the passed itemsite points to a real item IF ( ( SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J') FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ) ) ) THEN RETURN 0; END IF; -- Cache some parameters SELECT itemloc_ls_id, itemloc_itemsite_id AS itemsiteid, itemloc_expiration, itemloc_warrpurc, itemloc_qty INTO _p FROM itemloc WHERE (itemloc_id=pSourceItemlocid); -- Check to make sure the qty being transfered exists IF (_p.itemloc_qty < pQty) THEN RETURN -1; END IF; -- Create the RL transaction SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid; INSERT INTO invhist ( invhist_id, invhist_itemsite_id, invhist_transtype, invhist_invqty, invhist_qoh_before, invhist_qoh_after, invhist_comments, invhist_transdate, invhist_invuom, invhist_unitcost, invhist_costmethod, invhist_value_before, invhist_value_after, invhist_series) SELECT _invhistid, itemsite_id, 'RL', 0, itemsite_qtyonhand, itemsite_qtyonhand, pComments, _GlDistTS, uom_name, CASE WHEN (itemsite_costmethod='A') THEN avgcost(itemsite_id) ELSE stdCost(item_id) END, itemsite_costmethod, itemsite_value, itemsite_value, _itemlocSeries FROM item, itemsite, uom WHERE ((itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (itemsite_controlmethod <> 'N') AND (itemsite_id=pItemsiteid)); -- Relocate the inventory from the source and record the transactions INSERT INTO invdetail ( invdetail_invhist_id, invdetail_location_id, invdetail_ls_id, invdetail_qty, invdetail_qty_before, invdetail_qty_after, invdetail_expiration, invdetail_warrpurc ) SELECT _invhistid, itemloc_location_id, itemloc_ls_id, (pQty * -1), itemloc_qty, (itemloc_qty - pQty), itemloc_expiration, itemloc_warrpurc FROM itemloc WHERE (itemloc_id=pSourceItemlocid); UPDATE itemloc SET itemloc_qty=(itemloc_qty - pQty) FROM itemsite WHERE ( (itemloc_itemsite_id=itemsite_id) AND (NOT itemsite_freeze) AND (itemloc_id=pSourceItemlocid) ); -- Check to see if any of the current Lot/Serial #/Expiration exists at the target location SELECT itemloc_id INTO _targetItemlocid FROM itemloc WHERE ( (COALESCE(itemloc_ls_id, -1)=COALESCE(_p.itemloc_ls_id,-1)) AND (COALESCE(itemloc_expiration,endOfTime())=COALESCE(_p.itemloc_expiration,endOfTime())) AND (COALESCE(itemloc_warrpurc,endOfTime())=COALESCE(_p.itemloc_warrpurc,endOfTime())) AND (itemloc_itemsite_id=pItemsiteid) AND (itemloc_location_id=pTargetLocationid) ); IF (NOT FOUND) THEN SELECT NEXTVAL('itemloc_itemloc_id_seq') INTO _targetItemlocid; INSERT INTO itemloc ( itemloc_id, itemloc_itemsite_id, itemloc_location_id, itemloc_ls_id, itemloc_expiration, itemloc_warrpurc, itemloc_qty ) VALUES ( _targetItemlocid, pItemsiteid, pTargetLocationid, _p.itemloc_ls_id, _p.itemloc_expiration, _p.itemloc_warrpurc, 0 ); END IF; -- Relocate the inventory to the resultant target and record the transactions INSERT INTO invdetail ( invdetail_invhist_id, invdetail_location_id, invdetail_ls_id, invdetail_qty, invdetail_qty_before, invdetail_qty_after, invdetail_expiration, invdetail_warrpurc ) SELECT _invhistid, pTargetLocationid, _p.itemloc_ls_id, pQty, itemloc_qty, (itemloc_qty + pQty), _p.itemloc_expiration, _p.itemloc_warrpurc FROM itemloc WHERE (itemloc_id=_targetItemlocid); UPDATE itemloc SET itemloc_qty=(itemloc_qty + pQty) FROM itemsite WHERE ( (itemloc_itemsite_id=itemsite_id) AND (NOT itemsite_freeze) AND (itemloc_id=_targetItemlocid) ); UPDATE invhist SET invhist_hasdetail=TRUE WHERE (invhist_id=_invhistid); -- Check to see if there is anything left at the target Itemloc and delete if not -- Could be zero if relocate increased a negative quantity to zero DELETE FROM itemloc WHERE ( (itemloc_qty=0) AND (itemloc_id=_targetItemlocid) ); -- Handle Reservations IF (fetchMetricBool('EnableSOReservationsByLocation')) THEN SELECT CASE WHEN (qtyReservedLocation(itemloc_id) > itemloc_qty) THEN (qtyReservedLocation(itemloc_id) - itemloc_qty) ELSE 0.0 END INTO _qtyunreserved FROM itemloc WHERE (itemloc_id=pSourceItemlocid); -- Move reservations as necessary WHILE (_qtyunreserved > 0.0) LOOP SELECT * INTO _rsrv FROM reserve WHERE ((reserve_supply_type='I') AND (reserve_supply_id=pSourceItemlocid)) ORDER BY reserve_qty; IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot find reservation to unreserve.'; END IF; IF (_rsrv.reserve_qty > _qtyunreserved) THEN _qtytomove := _qtyunreserved; ELSE _qtytomove := _rsrv.reserve_qty; END IF; -- Unreserve Source Location SELECT unreserveSOLineQty(_rsrv.reserve_demand_id, _qtytomove, pSourceItemlocid) INTO _result; IF (_result < 0) THEN RAISE EXCEPTION 'unreserveSOLineQty failed with result=%, reserve_id=%, qty=%', _result, _rsrv.reserve_id, _qtytomove; END IF; -- Reserve to new Location SELECT reserveSOLineQty(_rsrv.reserve_demand_id, TRUE, _qtytomove, _targetItemlocid) INTO _result; IF (_result < 0) THEN RAISE EXCEPTION 'reserveSOLineQty failed with result=%, reserve_id=%, qty=%', _result, _rsrv.reserve_id, _qtytomove; END IF; -- Calculate running total _qtyunreserved := _qtyunreserved - _qtytomove; END LOOP; END IF; -- Check to see if there is anything left at the source Itemloc and delete if not DELETE FROM itemloc WHERE ( (itemloc_qty=0) AND (itemloc_id=pSourceItemlocid) ); -- Return the invhist_id RETURN _invhistid; END; $$; ALTER FUNCTION public.relocateinventory(psourceitemlocid integer, ptargetlocationid integer, pitemsiteid integer, pqty numeric, pcomments text, pgldistts timestamp with time zone) OWNER TO admin; -- -- Name: reopenbankreconciliation(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION reopenbankreconciliation(pbankrecid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN bankReconciliation(pBankrecid, 'reopen'); END; $$; ALTER FUNCTION public.reopenbankreconciliation(pbankrecid integer) OWNER TO admin; -- -- Name: reorderdate(integer, integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION reorderdate(integer, integer, boolean) RETURNS date LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pLookAhead ALIAS FOR $2; pIncludePlanned ALIAS FOR $3; _runningAvailability NUMERIC; _reorderLevel NUMERIC; _availability RECORD; BEGIN -- Make sure that we know how to handle the passed part IF ( SELECT (NOT (item_type IN ('M', 'P'))) FROM item, itemsite WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ) ) THEN RETURN NULL; END IF; -- Load the initial QOH SELECT itemsite_qtyonhand INTO _runningAvailability FROM itemsite WHERE (itemsite_id=pItemsiteid); -- Grab the Reorder Level, if any IF ( ( SELECT itemsite_useparams FROM itemsite WHERE (itemsite_id=pItemsiteid) ) ) THEN SELECT itemsite_reorderlevel INTO _reorderLevel FROM itemsite WHERE (itemsite_id=pItemsiteid); ELSE _reorderLevel := 0; END IF; -- If we are already below the Reorder Level then we should order ASAP IF (_runningAvailability <= _reorderLevel) THEN RETURN CURRENT_DATE; END IF; -- Grab all of the availability trigger points FOR _availability IN SELECT 1 AS seq, wo_duedate AS orderdate, (noNeg(wo_qtyord - wo_qtyrcv)) AS balance FROM wo WHERE ((wo_status IN ('O', 'E', 'R', 'I')) AND (wo_duedate <= (CURRENT_DATE + pLookAhead)) AND (wo_itemsite_id=pItemsiteid)) UNION SELECT 2 AS seq, womatl_duedate AS orderdate, (noNeg(itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq - womatl_qtyiss)) * -1) AS balance FROM womatl, wo, itemsite WHERE ((wo_status IN ('O', 'E', 'R', 'I')) AND (womatl_wo_id=wo_id) AND (womatl_itemsite_id=itemsite_id) AND (womatl_duedate <= (CURRENT_DATE + pLookahead)) AND (womatl_itemsite_id=pItemsiteid)) UNION SELECT 1 AS seq, poitem_duedate AS orderdate, (noNeg(poitem_qty_ordered - poitem_qty_received) * poitem_invvenduomratio) AS balance FROM pohead, poitem WHERE ((poitem_pohead_id=pohead_id) AND (poitem_status = 'O') AND (poitem_duedate <= (CURRENT_DATE + pLookAhead)) AND (poitem_itemsite_id=pItemsiteid)) UNION SELECT 2 AS seq, coitem_scheddate AS orderdate, (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * -1) AS balance FROM coitem, cohead WHERE ((coitem_status = 'O') AND (coitem_cohead_id=cohead_id) AND (coitem_scheddate <= (CURRENT_DATE + pLookAhead)) AND (coitem_itemsite_id=pItemsiteid)) UNION SELECT 2 AS seq, planord_startdate AS orderdate, (planreq_qty * -1) AS balance FROM planreq, planord WHERE ( (pIncludePlanned) AND (planreq_source='P') AND (planreq_source_id=planord_id) AND (planord_startdate <= (CURRENT_DATE + pLookAhead)) AND (planord_itemsite_id=pItemsiteid) ) UNION SELECT 1 AS seq, planord_duedate AS orderdate, planord_qty AS balance FROM planord WHERE ( (pIncludePlanned) AND (planord_duedate <= (CURRENT_DATE + pLookAhead)) AND (planord_itemsite_id=pItemsiteid) ) ORDER BY orderdate, seq LOOP -- Calculate the new projected availability _runningAvailability := (_runningAvailability + _availability.balance); -- Check to see if the project availability drop below the reorder level IF (_runningAvailability < _reorderLevel) THEN RETURN _availability.orderdate; END IF; END LOOP; -- The reorder level was not reached within the look ahead period RETURN NULL; END; $_$; ALTER FUNCTION public.reorderdate(integer, integer, boolean) OWNER TO admin; -- -- Name: replaceallvoidedapchecks(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION replaceallvoidedapchecks(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'replaceAllVoidedAPChecks() is deprecated - use replaceAllVoidedChecks() instead'; RETURN replaceAllVoidedChecks($1); END; $_$; ALTER FUNCTION public.replaceallvoidedapchecks(integer) OWNER TO admin; -- -- Name: replaceallvoidedchecks(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION replaceallvoidedchecks(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBankaccntid ALIAS FOR $1; _returnValue INTEGER := 0; BEGIN SELECT MIN(replaceVoidedCheck(checkhead_id)) INTO _returnValue FROM checkhead WHERE ( (checkhead_void) AND (NOT checkhead_posted) AND (NOT checkhead_replaced) AND (NOT checkhead_deleted) AND (checkhead_bankaccnt_id=pBankaccntid) ); RETURN _returnValue; END; $_$; ALTER FUNCTION public.replaceallvoidedchecks(integer) OWNER TO admin; -- -- Name: replacevoidedapcheck(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION replacevoidedapcheck(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'replaceVoidedAPCheck() is deprecated - use replaceVoidedCheck()'; RETURN replaceVoidedCheck($1); END; $_$; ALTER FUNCTION public.replacevoidedapcheck(integer) OWNER TO admin; -- -- Name: replacevoidedcheck(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION replacevoidedcheck(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCheckid ALIAS FOR $1; _newCheckid INTEGER; BEGIN IF ( ( SELECT ( (NOT checkhead_void) OR checkhead_posted OR checkhead_replaced ) FROM checkhead WHERE (checkhead_id=pCheckid) ) ) THEN RETURN -1; END IF; -- has someone created a new check for one of the items while this was void? IF EXISTS (SELECT dup.checkitem_id FROM checkitem orig, checkitem dup, checkhead AS duphead WHERE ((COALESCE(orig.checkitem_aropen_id,-1)=COALESCE(dup.checkitem_aropen_id,-1)) AND (COALESCE(orig.checkitem_apopen_id,-1)=COALESCE(dup.checkitem_apopen_id,-1)) AND (orig.checkitem_checkhead_id!=dup.checkitem_checkhead_id) AND (dup.checkitem_checkhead_id=duphead.checkhead_id) AND (NOT duphead.checkhead_void) AND (orig.checkitem_checkhead_id=pCheckid))) THEN RETURN -2; END IF; SELECT NEXTVAL('checkhead_checkhead_id_seq') INTO _newCheckid; INSERT INTO checkhead ( checkhead_id, checkhead_recip_id, checkhead_recip_type, checkhead_bankaccnt_id, checkhead_checkdate, checkhead_number, checkhead_amount, checkhead_for, checkhead_journalnumber, checkhead_notes, checkhead_misc, checkhead_expcat_id, checkhead_curr_id ) SELECT _newCheckid, checkhead_recip_id, checkhead_recip_type, checkhead_bankaccnt_id, checkhead_checkdate, -1, -- fetchNextCheckNumber(checkhead_bankaccnt_id), checkhead_amount, checkhead_for, checkhead_journalnumber, checkhead_notes || ' Replaces voided check ' || checkhead_number, checkhead_misc, checkhead_expcat_id, checkhead_curr_id FROM checkhead WHERE (checkhead_id=pCheckid); INSERT INTO checkitem ( checkitem_checkhead_id, checkitem_amount, checkitem_discount, checkitem_ponumber, checkitem_vouchernumber, checkitem_invcnumber, checkitem_apopen_id, checkitem_aropen_id, checkitem_docdate, checkitem_curr_id, checkitem_curr_rate ) SELECT _newCheckid, checkitem_amount, checkitem_discount, checkitem_ponumber, checkitem_vouchernumber, checkitem_invcnumber, checkitem_apopen_id, checkitem_aropen_id, checkitem_docdate, checkitem_curr_id, checkitem_curr_rate FROM checkitem WHERE (checkitem_checkhead_id=pCheckid); UPDATE checkhead SET checkhead_replaced=TRUE WHERE (checkhead_id=pCheckid); RETURN _newCheckid; END; $_$; ALTER FUNCTION public.replacevoidedcheck(integer) OWNER TO admin; -- -- Name: reprioritizewo(integer, integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION reprioritizewo(integer, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pPriority ALIAS FOR $2; pChangeChildren ALIAS FOR $3; _status CHAR(1); _result INTEGER; BEGIN SELECT wo_status INTO _status FROM wo WHERE (wo_id=pWoid); IF (NOT (_status IN ('O', 'E','R','I'))) THEN return -1; END IF; UPDATE wo SET wo_priority=pPriority WHERE (wo_id=pWoid); IF ( (_status IN ('E','R','I')) AND (pChangeChildren) ) THEN SELECT COALESCE(MIN(reprioritizeWo(wo_id, pPriority, TRUE)), 1) INTO _result FROM wo WHERE ( (wo_ordtype='W') AND (wo_ordid=pWoid) ); ELSE _result = 1; END IF; RETURN _result; END; $_$; ALTER FUNCTION public.reprioritizewo(integer, integer, boolean) OWNER TO admin; -- -- Name: resetdbobjperms(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION resetdbobjperms() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _count INTEGER := 0; BEGIN SELECT SUM(resetDBObjPerms(nspname || '.' || relname)) INTO _count FROM pg_catalog.pg_class, pg_catalog.pg_namespace WHERE (relkind IN ('r', 'S', 'v') AND (relnamespace=pg_namespace.oid) AND (nspname IN ('public', 'api'))); RETURN _count; END; $$; ALTER FUNCTION public.resetdbobjperms() OWNER TO admin; -- -- Name: resetdbobjperms(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION resetdbobjperms(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pObjname ALIAS FOR $1; BEGIN EXECUTE 'ALTER TABLE ' || pObjname || ' OWNER TO ' || getEffectiveXtUser() || ';'; EXECUTE 'REVOKE ALL ON ' || pObjname || ' FROM PUBLIC;'; EXECUTE 'GRANT ALL ON ' || pObjname || ' TO GROUP xtrole;'; RETURN 1; END; $_$; ALTER FUNCTION public.resetdbobjperms(text) OWNER TO admin; -- -- Name: resetlowlevelcode(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION resetlowlevelcode(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemId ALIAS FOR $1; _result INTEGER; _counterNum INTEGER := 1; _feedBackNum INTEGER := 1; _r RECORD; BEGIN DELETE FROM costUpdate; IF pItemId = -1 THEN -- -1 is an invalid item_id => do them all INSERT INTO costUpdate ( costUpdate_item_id, costUpdate_item_type ) SELECT item_id, item_type FROM item; -- Recalculate the Item Lowlevel codes WHILE _feedBackNum > 0 LOOP SELECT updateLowlevel(_counterNum) INTO _feedBackNum; _counterNum := _counterNum + 1; END LOOP; ELSE INSERT INTO costUpdate ( costUpdate_item_id, costUpdate_item_type ) SELECT item_id, item_type FROM item WHERE (item_id=pItemId); FOR _r IN SELECT item_id, bomdata_bomwork_level, item_type FROM item, indentedBOM(pItemId, getActiveRevId('BOM',pItemId),0,0) WHERE (bomdata_item_id=item_id) ORDER BY bomdata_bomwork_level LOOP -- this only works because of the ORDER BY in the loop SELECT UPDATE costUpdate SET costupdate_lowlevel_code = _r.bomdata_bomwork_level WHERE (costupdate_item_id=_r.item_id); IF (NOT FOUND) THEN INSERT INTO costUpdate ( costUpdate_item_id, costUpdate_lowlevel_code, costUpdate_item_type ) VALUES ( _r.item_id, _r.bomdata_bomwork_level, _r.item_type ); END IF; END LOOP; END IF; SELECT count(*) INTO _result FROM costUpdate; RETURN _result; END; $_$; ALTER FUNCTION public.resetlowlevelcode(integer) OWNER TO admin; -- -- Name: resetqohbalance(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION resetqohbalance(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN resetQOHBalance($1, CURRENT_TIMESTAMP); END; $_$; ALTER FUNCTION public.resetqohbalance(integer) OWNER TO admin; -- -- Name: resetqohbalance(integer, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION resetqohbalance(integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pGlDistTS ALIAS FOR $2; _invhistid INTEGER; _itemlocSeries INTEGER; BEGIN IF ( ( SELECT ( (itemsite_controlmethod IN ('L', 'S')) OR (item_type = 'R') OR (itemsite_costmethod = 'J') OR (itemsite_loccntrl) OR (itemsite_qtyonhand > 0) ) FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ) ) ) THEN RETURN 0; END IF; _itemlocSeries := NEXTVAL('itemloc_series_seq'); SELECT postInvTrans( itemsite_id, 'AD', (itemsite_qtyonhand * -1), 'I/M', '', '', 'RESET', 'Reset QOH Balance to 0', costcat_asset_accnt_id, costcat_adjustment_accnt_id, _itemlocSeries, pGlDistTS ) INTO _invhistid FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=pItemsiteid) ); PERFORM postItemLocSeries(_itemlocSeries); RETURN _invhistid; END; $_$; ALTER FUNCTION public.resetqohbalance(integer, timestamp with time zone) OWNER TO admin; -- -- Name: resolvecosaccount(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION resolvecosaccount(integer, integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN resolveCOSAccount($1, $2, -1, -1); END; $_$; ALTER FUNCTION public.resolvecosaccount(integer, integer) OWNER TO admin; -- -- Name: resolvecosaccount(integer, integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION resolvecosaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _salesaccntid INTEGER; _accntid INTEGER; BEGIN SELECT findSalesAccnt(pItemsiteid, 'IS', pCustid, pSaletypeid, pShipzoneid) INTO _salesaccntid; IF (_salesaccntid = -1) THEN SELECT getUnassignedAccntId(getitemsitecompanyid(pItemsiteid)) INTO _accntid; ELSE SELECT salesaccnt_cos_accnt_id INTO _accntid FROM salesaccnt WHERE (salesaccnt_id=_salesaccntid); END IF; RETURN _accntid; END; $$; ALTER FUNCTION public.resolvecosaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer) OWNER TO admin; -- -- Name: resolvecowaccount(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION resolvecowaccount(integer, integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN resolveCOWAccount($1, $2, -1, -1); END; $_$; ALTER FUNCTION public.resolvecowaccount(integer, integer) OWNER TO admin; -- -- Name: resolvecowaccount(integer, integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION resolvecowaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _salesaccntid INTEGER; _accntid INTEGER; BEGIN SELECT findSalesAccnt(pItemsiteid, 'IS', pCustid, pSaletypeid, pShipzoneid) INTO _salesaccntid; IF (_salesaccntid = -1) THEN SELECT getUnassignedAccntId(getitemsitecompanyid(pItemsiteid)) INTO _accntid; ELSE SELECT salesaccnt_cow_accnt_id INTO _accntid FROM salesaccnt WHERE (salesaccnt_id=_salesaccntid); END IF; RETURN _accntid; END; $$; ALTER FUNCTION public.resolvecowaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer) OWNER TO admin; -- -- Name: resolvecreditaccount(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION resolvecreditaccount(integer, integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN resolveCreditAccount($1, $2, -1, -1); END; $_$; ALTER FUNCTION public.resolvecreditaccount(integer, integer) OWNER TO admin; -- -- Name: resolvecreditaccount(integer, integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION resolvecreditaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _salesaccntid INTEGER; _accntid INTEGER; BEGIN SELECT findSalesAccnt(pItemsiteid, 'IS', pCustid, pSaletypeid, pShipzoneid) INTO _salesaccntid; IF (_salesaccntid = -1) THEN SELECT getUnassignedAccntId(getitemsitecompanyid(pItemsiteid)) INTO _accntid; ELSE SELECT salesaccnt_credit_accnt_id INTO _accntid FROM salesaccnt WHERE (salesaccnt_id=_salesaccntid); END IF; RETURN _accntid; END; $$; ALTER FUNCTION public.resolvecreditaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer) OWNER TO admin; -- -- Name: resolvesalesaccount(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION resolvesalesaccount(integer, integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN resolveSalesAccount($1, $2, -1, -1); END; $_$; ALTER FUNCTION public.resolvesalesaccount(integer, integer) OWNER TO admin; -- -- Name: resolvesalesaccount(integer, integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION resolvesalesaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _salesaccntid INTEGER; _accntid INTEGER; BEGIN SELECT findSalesAccnt(pItemsiteid, 'IS', pCustid, pSaletypeid, pShipzoneid) INTO _salesaccntid; IF (_salesaccntid = -1) THEN SELECT getUnassignedAccntId(getitemsitecompanyid(pItemsiteid)) INTO _accntid; ELSE SELECT salesaccnt_sales_accnt_id INTO _accntid FROM salesaccnt WHERE (salesaccnt_id=_salesaccntid); END IF; RETURN _accntid; END; $$; ALTER FUNCTION public.resolvesalesaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer) OWNER TO admin; -- -- Name: restoresaleshistory(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION restoresaleshistory(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAsohistid ALIAS FOR $1; BEGIN INSERT INTO cohist ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipdate, cohist_invcdate, cohist_duedate, cohist_promisedate, cohist_ordernumber, cohist_invcnumber, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_shipto_id, cohist_shipvia, cohist_salesrep_id, cohist_misc_type, cohist_misc_descrip, cohist_misc_id, cohist_commission, cohist_commissionpaid, cohist_doctype, cohist_orderdate, cohist_imported, cohist_ponumber, cohist_curr_id, cohist_taxtype_id, cohist_taxzone_id ) SELECT asohist_id, CASE asohist_cust_id WHEN -1 THEN NULL ELSE asohist_cust_id END, asohist_itemsite_id, asohist_shipdate, asohist_invcdate, asohist_duedate, asohist_promisedate, asohist_ordernumber, asohist_invcnumber, asohist_qtyshipped, asohist_unitprice, asohist_unitcost, asohist_billtoname, asohist_billtoaddress1, asohist_billtoaddress2, asohist_billtoaddress3, asohist_billtocity, asohist_billtostate, asohist_billtozip, asohist_shiptoname, asohist_shiptoaddress1, asohist_shiptoaddress2, asohist_shiptoaddress3, asohist_shiptocity, asohist_shiptostate, asohist_shiptozip, asohist_shipto_id, asohist_shipvia, CASE asohist_salesrep_id WHEN -1 THEN NULL ELSE asohist_salesrep_id END, asohist_misc_type, asohist_misc_descrip, asohist_misc_id, asohist_commission, asohist_commissionpaid, asohist_doctype, asohist_orderdate, asohist_imported, asohist_ponumber, asohist_curr_id, asohist_taxtype_id, asohist_taxzone_id FROM asohist WHERE (asohist_id=pAsohistid); INSERT INTO cohisttax ( taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM asohisttax WHERE (taxhist_parent_id=pAsohistid); DELETE FROM asohisttax WHERE (taxhist_parent_id=pAsohistid); DELETE FROM asohist WHERE (asohist_id=pAsohistid); RETURN pAsohistid; END; $_$; ALTER FUNCTION public.restoresaleshistory(integer) OWNER TO admin; -- -- Name: returncompleteshipment(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION returncompleteshipment(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN returnCompleteShipment($1, 0, CURRENT_TIMESTAMP); END; $_$; ALTER FUNCTION public.returncompleteshipment(integer) OWNER TO admin; -- -- Name: returncompleteshipment(integer, integer, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION returncompleteshipment(integer, integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pshipheadid ALIAS FOR $1; _itemlocSeries INTEGER := $2; _timestamp TIMESTAMP WITH TIME ZONE := $3; _r RECORD; _result RECORD; _shiphead_number TEXT := ''; _count INTEGER := 0; _countsum INTEGER := 0; BEGIN FOR _r IN SELECT shipitem_id FROM shipitem, shiphead WHERE ( (shipitem_shiphead_id=shiphead_id) AND (NOT shiphead_shipped) AND (shiphead_id=pshipheadid) ) LOOP _itemlocSeries := returnShipmentTransaction(_r.shipitem_id, _itemlocSeries, _timestamp); END LOOP; FOR _result IN SELECT shiphead_number FROM shiphead WHERE ( (shiphead_id=pshipheadid) ) LOOP _shiphead_number := _result.shiphead_number; END LOOP; SELECT COUNT(*) INTO _count FROM shipdata WHERE(shipdata_shiphead_number=_shiphead_number); SELECT COUNT(*) INTO _countsum FROM shipdatasum WHERE(shipdatasum_shiphead_number=_shiphead_number); IF (_count > 0) THEN DELETE FROM shipdata WHERE(shipdata_shiphead_number=_shiphead_number); END IF; IF (_countsum > 0) THEN DELETE FROM shipdatasum WHERE(shipdatasum_shiphead_number=_shiphead_number); END IF; DELETE FROM pack WHERE(pack_shiphead_id=pshipheadid); DELETE FROM shiphead WHERE (shiphead_id=pshipheadid); RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.returncompleteshipment(integer, integer, timestamp with time zone) OWNER TO admin; -- -- Name: returnitemshipments(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION returnitemshipments(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN returnItemShipments('SO', $1, 0, CURRENT_TIMESTAMP); END; $_$; ALTER FUNCTION public.returnitemshipments(integer) OWNER TO admin; -- -- Name: returnitemshipments(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION returnitemshipments(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN returnItemShipments('SO', $1, $2, CURRENT_TIMESTAMP); END; $_$; ALTER FUNCTION public.returnitemshipments(integer, integer) OWNER TO admin; -- -- Name: returnitemshipments(text, integer, integer, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION returnitemshipments(text, integer, integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; pitemid ALIAS FOR $2; _itemlocSeries INTEGER := $3; _timestamp TIMESTAMP WITH TIME ZONE := $4; _invhistid INTEGER; _r RECORD; BEGIN IF (COALESCE(_itemlocSeries,0) = 0 ) THEN _itemlocSeries := NEXTVAL('itemloc_series_seq'); END IF; FOR _r IN SELECT shipitem_id FROM shipitem JOIN shiphead ON (shiphead_id=shipitem_shiphead_id) WHERE ((NOT shiphead_shipped) AND (shiphead_order_type=pordertype) AND (shipitem_orderitem_id=pitemid)) LOOP SELECT returnShipmentTransaction(_r.shipitem_id, _itemlocSeries, _timestamp) INTO _itemlocSeries; IF (_itemlocSeries < 0) THEN RETURN _itemlocSeries; END IF; END LOOP; RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.returnitemshipments(text, integer, integer, timestamp with time zone) OWNER TO admin; -- -- Name: returnshipmenttransaction(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION returnshipmenttransaction(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN returnShipmentTransaction($1, 0, CURRENT_TIMESTAMP); END; $_$; ALTER FUNCTION public.returnshipmenttransaction(integer) OWNER TO admin; -- -- Name: returnshipmenttransaction(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION returnshipmenttransaction(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN returnShipmentTransaction($1, $2, CURRENT_TIMESTAMP); END; $_$; ALTER FUNCTION public.returnshipmenttransaction(integer, integer) OWNER TO admin; -- -- Name: returnshipmenttransaction(integer, integer, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION returnshipmenttransaction(integer, integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipitemId ALIAS FOR $1; pItemlocSeries ALIAS FOR $2; pTimestamp ALIAS FOR $3; _itemlocSeries INTEGER; _invhistid INTEGER; _reserveid INTEGER; _coheadid INTEGER; _rows INTEGER; _r RECORD; _rsrv RECORD; BEGIN IF (COALESCE(pItemlocSeries, 0) = 0 ) THEN _itemlocSeries := NEXTVAL('itemloc_series_seq'); ELSE _itemlocSeries := pItemlocSeries; END IF; -- Find the shipment transaction record SELECT shipitem.*, shiphead_id, shiphead_number, shiphead_order_type, invhist_series, itemsite_loccntrl, itemsite_costmethod, itemsite_controlmethod, cohead_prj_id AS prj_id INTO _r FROM shipitem JOIN shiphead ON (shiphead_id=shipitem_shiphead_id) JOIN invhist ON (invhist_id=shipitem_invhist_id) JOIN itemsite ON (itemsite_id=invhist_itemsite_id) LEFT OUTER JOIN cohead ON ((shiphead_order_type = 'SO') AND (shiphead_order_id = cohead_id)) WHERE ((NOT shiphead_shipped) AND (shipitem_id=pShipitemId)); GET DIAGNOSTICS _rows = ROW_COUNT; IF (_rows = 0 ) THEN -- Was it a non-controlled sales order item? SELECT shipitem.*, shiphead_id, shiphead_number, shiphead_order_type, itemsite_loccntrl, itemsite_costmethod, itemsite_controlmethod, cohead_prj_id AS prj_id INTO _r FROM shipitem JOIN shiphead ON (shiphead_id=shipitem_shiphead_id) JOIN coitem ON (shipitem_orderitem_id=coitem_id) JOIN cohead ON (cohead_id=coitem_cohead_id) JOIN itemsite ON (itemsite_id=coitem_itemsite_id) WHERE ((NOT shiphead_shipped) AND (shipitem_id=pShipitemId) AND (shiphead_order_type = 'SO')); END IF; GET DIAGNOSTICS _rows = ROW_COUNT; IF (_rows = 0 AND fetchmetricbool('MultiWhs') ) THEN -- Was it a non-controlled transfer order item? SELECT shipitem.*, shiphead_id, shiphead_number, shiphead_order_type, itemsite_loccntrl, itemsite_costmethod, itemsite_controlmethod, NULL AS prj_id INTO _r FROM shipitem JOIN shiphead ON (shiphead_id=shipitem_shiphead_id) JOIN toitem ON (shipitem_orderitem_id=toitem_id) JOIN itemsite ON (itemsite_id=coitem_itemsite_id) WHERE ((NOT shiphead_shipped) AND (shipitem_id=pShipitemId) AND (shiphead_order_type = 'TO')); END IF; IF (_rows > 0 ) THEN IF (_r.shiphead_order_type = 'SO') THEN -- Handle inventory transaction IF (_r.itemsite_controlmethod != 'N' OR _r.itemsite_costmethod = 'J') THEN SELECT postInvTrans( itemsite_id, 'RS', (_r.shipitem_qty * coitem_qty_invuomratio), 'S/R', _r.shiphead_order_type, formatSoNumber(_r.shipitem_orderitem_id), shiphead_number, 'Return from Shipping', costcat_asset_accnt_id, getPrjAccntId(_r.prj_id, costcat_shipasset_accnt_id), _itemlocSeries, pTimestamp, _r.shipitem_value, _r.shipitem_invhist_id ) INTO _invhistid FROM coitem, itemsite, costcat, shiphead, shipitem WHERE ((coitem_itemsite_id=itemsite_id) AND (itemsite_costcat_id=costcat_id) AND (coitem_id=_r.shipitem_orderitem_id) AND (shiphead_order_type=_r.shiphead_order_type) AND (shiphead_id=shipitem_shiphead_id) AND (shipitem_orderitem_id=_r.shipitem_orderitem_id)); -- We know the distribution so post this through so the any w/o activity knows about it PERFORM postItemlocseries(_itemlocSeries); END IF; IF (_r.itemsite_costmethod = 'J') THEN -- Reopen the work order UPDATE wo SET wo_status = 'I' WHERE ((wo_ordtype='S') AND (wo_ordid=_r.shipitem_orderitem_id)); -- Job cost, so correct Production Posting referencing original receipt for reverse info. PERFORM correctProduction(wo_id, invhist_invqty, false, _itemlocSeries, pTimestamp, invhist_id) FROM wo, invhist WHERE ((wo_ordtype = 'S') AND (wo_ordid = _r.shipitem_orderitem_id) AND (invhist_series=_r.invhist_series) AND (invhist_transtype='RM')); -- Return eligble material PERFORM returnWoMaterial(womatlpost_womatl_id, _itemlocSeries, pTimestamp, womatlpost_invhist_id) FROM womatlpost, invhist m, invhist s WHERE ((womatlpost_invhist_id=m.invhist_id) AND (m.invhist_series=s.invhist_series) AND (m.invhist_transtype='IM') AND (s.invhist_id=_r.shipitem_invhist_id)); END IF; -- end Job Costing ELSIF (_r.shiphead_order_type = 'TO') THEN SELECT postInvTrans(itemsite_id, 'RS', _r.shipitem_qty, 'S/R', _r.shiphead_order_type, formatToNumber(toitem_id), tohead_number, 'Return from Shipping', costcat_asset_accnt_id, costcat_shipasset_accnt_id, _itemlocSeries, pTimestamp, _r.shipitem_value, _r.shipitem_invhist_id ) INTO _invhistid FROM toitem, tohead, itemsite, costcat WHERE ((toitem_item_id=itemsite_item_id) AND (toitem_tohead_id=tohead_id) AND (tohead_src_warehous_id=itemsite_warehous_id) AND (itemsite_costcat_id=costcat_id) AND (toitem_id=_r.shipitem_orderitem_id)); ELSE -- Don't know what kind of order this is RETURN -11; END IF; UPDATE shiphead SET shiphead_sfstatus='D' WHERE ((shiphead_id=_r.shiphead_id) AND (shiphead_sfstatus='P')); -- Handle reservation if applicable IF (fetchmetricbool('EnableSOReservations')) THEN UPDATE coitem SET coitem_qtyreserved = (coitem_qtyreserved + shipitemrsrv_qty) FROM shipitemrsrv WHERE ((coitem_id=_r.shipitem_orderitem_id) AND (shipitemrsrv_shipitem_id=_r.shipitem_id)); -- Handle location reservations if applicable FOR _rsrv IN SELECT * FROM shipitemlocrsrv WHERE (shipitemlocrsrv_shipitem_id=_r.shipitem_id) LOOP -- See if a reservation record still exists SELECT reserve_id INTO _reserveid FROM reserve JOIN itemloc ON (reserve_supply_id=itemloc_id) WHERE ((reserve_supply_type='I') AND (reserve_demand_type = 'SO') AND (reserve_demand_id = _r.shipitem_orderitem_id ) AND (itemloc_itemsite_id=_rsrv.shipitemlocrsrv_itemsite_id) AND (itemloc_location_id=_rsrv.shipitemlocrsrv_location_id) AND (COALESCE(itemloc_ls_id, -1)=COALESCE(_rsrv.shipitemlocrsrv_ls_id, -1)) AND (COALESCE(itemloc_expiration, endOfTime())=COALESCE(_rsrv.shipitemlocrsrv_expiration, endOfTime())) AND (COALESCE(itemloc_warrpurc, endoftime())=COALESCE(_rsrv.shipitemlocrsrv_warrpurc, endoftime())) ); GET DIAGNOSTICS _rows = ROW_COUNT; IF (_rows > 0 ) THEN -- Update existing UPDATE reserve SET reserve_qty = (reserve_qty + _rsrv.shipitemlocrsrv_qty) WHERE (reserve_id=_reserveid); ELSE -- Recreate record INSERT INTO reserve SELECT nextval('reserve_reserve_id_seq'), 'SO', _r.shipitem_orderitem_id, 'I', itemloc_id, _rsrv.shipitemlocrsrv_qty, 'R' FROM itemloc WHERE ((itemloc_itemsite_id=_rsrv.shipitemlocrsrv_itemsite_id) AND (itemloc_location_id=_rsrv.shipitemlocrsrv_location_id) AND (COALESCE(itemloc_ls_id, -1)=COALESCE(_rsrv.shipitemlocrsrv_ls_id, -1)) AND (COALESCE(itemloc_expiration, endOfTime())=COALESCE(_rsrv.shipitemlocrsrv_expiration, endOfTime())) AND (COALESCE(itemloc_warrpurc, endoftime())=COALESCE(_rsrv.shipitemlocrsrv_warrpurc, endoftime())) ); END IF; END LOOP; END IF; DELETE FROM shipitem WHERE (shipitem_id = _r.shipitem_id ); -- Clean up if this is the last shipitem on the shipment IF (NOT EXISTS(SELECT shipitem_shiphead_id FROM shipitem WHERE (shipitem_shiphead_id=_r.shiphead_id))) THEN DELETE FROM shipdata WHERE(shipdata_shiphead_number=_r.shiphead_number); DELETE FROM shipdatasum WHERE(shipdatasum_shiphead_number=_r.shiphead_number); DELETE FROM pack WHERE(pack_shiphead_id=_r.shiphead_id); DELETE FROM shiphead WHERE (shiphead_id=_r.shiphead_id); END IF; END IF; RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.returnshipmenttransaction(integer, integer, timestamp with time zone) OWNER TO admin; -- -- Name: returnwomaterial(integer, numeric, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION returnwomaterial(integer, numeric, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pQty ALIAS FOR $2; pGlDistTS ALIAS FOR $3; _itemlocSeries INTEGER; BEGIN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; RETURN returnWoMaterial(pWomatlid, pQty, _itemlocSeries, pGlDistTS); END; $_$; ALTER FUNCTION public.returnwomaterial(integer, numeric, timestamp with time zone) OWNER TO admin; -- -- Name: returnwomaterial(integer, integer, timestamp with time zone, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION returnwomaterial(integer, integer, timestamp with time zone, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pItemlocSeries ALIAS FOR $2; pGlDistTS ALIAS FOR $3; pInvhistId ALIAS FOR $4; _woNumber TEXT; _invhistid INTEGER; _itemlocSeries INTEGER; _invqty NUMERIC; _womatlqty NUMERIC; _cost NUMERIC := 0; _rows INTEGER; BEGIN _itemlocSeries := 0; SELECT invhist_invqty, invhist_invqty * invhist_unitcost INTO _invqty, _cost FROM invhist WHERE (invhist_id=pInvhistId); GET DIAGNOSTICS _rows = ROW_COUNT; IF (_rows = 0) THEN RAISE EXCEPTION 'No transaction found for invhist_id %', pInvhistId; END IF; SELECT itemuomtouom(itemsite_item_id, NULL, womatl_uom_id, _invqty) INTO _womatlqty FROM womatl, itemsite WHERE((womatl_itemsite_id=itemsite_id) AND (womatl_id=pWomatlid)); GET DIAGNOSTICS _rows = ROW_COUNT; IF (_rows = 0) THEN _womatlqty := _invqty; END IF; IF ( SELECT ( CASE WHEN (womatl_qtyreq >= 0) THEN womatl_qtyiss < _womatlqty ELSE womatl_qtyiss > _womatlqty END ) FROM womatl WHERE ( womatl_id=pWomatlid ) ) THEN RETURN pItemlocSeries; END IF; SELECT formatWoNumber(womatl_wo_id) INTO _woNumber FROM womatl WHERE (womatl_id=pWomatlid); IF (pItemlocSeries = 0) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; ELSE _itemlocSeries = pItemlocSeries; END IF; -- Post the transaction SELECT postInvTrans( ci.itemsite_id, 'IM', (_invqty * -1), 'W/O', 'WO', _woNumber, '', ('Return ' || item_number || ' from Work Order'), getPrjAccntId(wo_prj_id, pc.costcat_wip_accnt_id), cc.costcat_asset_accnt_id, _itemlocSeries, pGlDistTS, -- Cost will be ignored by Standard Cost items sites _cost, pInvhistId) INTO _invhistid FROM womatl, wo, itemsite AS ci, costcat AS cc, itemsite AS pi, costcat AS pc, item WHERE((womatl_itemsite_id=ci.itemsite_id) AND (ci.itemsite_costcat_id=cc.costcat_id) AND (womatl_wo_id=wo_id) AND (wo_itemsite_id=pi.itemsite_id) AND (pi.itemsite_costcat_id=pc.costcat_id) AND (ci.itemsite_item_id=item_id) AND (womatl_id=pWomatlid) ); -- Create linkage to the transaction created INSERT INTO womatlpost (womatlpost_womatl_id,womatlpost_invhist_id) VALUES (pWomatlid,_invhistid); -- Decrease the parent W/O's WIP value by the value of the returned components UPDATE wo SET wo_wipvalue = (wo_wipvalue - (CASE WHEN(itemsite_costmethod IN ('A','J')) THEN _cost WHEN(itemsite_costmethod='S') THEN stdcost(itemsite_item_id) * _invqty ELSE 0.0 END )), wo_postedvalue = (wo_postedvalue - (CASE WHEN(itemsite_costmethod IN ('A','J')) THEN _cost WHEN(itemsite_costmethod='S') THEN stdcost(itemsite_item_id) * _invqty ELSE 0.0 END )) FROM womatl, itemsite WHERE ( (wo_id=womatl_wo_id) AND (womatl_itemsite_id=itemsite_id) AND (womatl_id=pWomatlid) ); UPDATE womatl SET womatl_qtyiss = (womatl_qtyiss - _womatlqty), womatl_lastreturn = CURRENT_DATE WHERE (womatl_id=pWomatlid); RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.returnwomaterial(integer, integer, timestamp with time zone, integer) OWNER TO admin; -- -- Name: FUNCTION returnwomaterial(integer, integer, timestamp with time zone, integer); Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON FUNCTION returnwomaterial(integer, integer, timestamp with time zone, integer) IS 'Returns material by reversing a specific historical transaction'; -- -- Name: returnwomaterial(integer, numeric, integer, timestamp with time zone, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION returnwomaterial(integer, numeric, integer, timestamp with time zone, boolean DEFAULT false) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pQty ALIAS FOR $2; pItemlocSeries ALIAS FOR $3; pGlDistTS ALIAS FOR $4; pReqStdCost ALIAS FOR $5; _woNumber TEXT; _invhistid INTEGER; _itemlocSeries INTEGER; _qty NUMERIC; _cost NUMERIC := 0; BEGIN _itemlocSeries := 0; IF ( SELECT ( CASE WHEN (womatl_qtyreq >= 0) THEN womatl_qtyiss < pQty ELSE womatl_qtyiss > pQty END ) FROM womatl WHERE ( womatl_id=pWomatlid ) ) THEN RETURN pItemlocSeries; END IF; SELECT itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, pQty) INTO _qty FROM womatl, itemsite WHERE((womatl_itemsite_id=itemsite_id) AND (womatl_id=pWomatlid)); IF (NOT FOUND) THEN _qty := pQty; END IF; SELECT formatWoNumber(womatl_wo_id) INTO _woNumber FROM womatl WHERE (womatl_id=pWomatlid); IF (pItemlocSeries = 0) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; ELSE _itemlocSeries = pItemlocSeries; END IF; -- Get the cost average IF (pReqStdCost) THEN SELECT stdcost(itemsite_item_id) * _qty INTO _cost FROM womatl, itemsite WHERE((womatl_itemsite_id=itemsite_id) AND (womatl_id=pWomatlid)); ELSE SELECT SUM(invhist_value_before - invhist_value_after) / SUM(invhist_qoh_before - invhist_qoh_after) * _qty INTO _cost FROM invhist, womatlpost, womatl WHERE((womatlpost_womatl_id=womatl_id) AND (womatlpost_invhist_id=invhist_id) AND (invhist_qoh_before > invhist_qoh_after) AND (womatl_id=pWomatlId)); END IF; _cost := COALESCE(_cost, 0); -- make sure it's not a null value -- Post the transaction SELECT postInvTrans( ci.itemsite_id, 'IM', (_qty * -1), 'W/O', 'WO', _woNumber, '', ('Return ' || item_number || ' from Work Order'), getPrjAccntId(wo_prj_id, pc.costcat_wip_accnt_id), cc.costcat_asset_accnt_id, _itemlocSeries, pGlDistTS, -- Cost will be ignored by Standard Cost items sites _cost) INTO _invhistid FROM womatl, wo, itemsite AS ci, costcat AS cc, itemsite AS pi, costcat AS pc, item WHERE((womatl_itemsite_id=ci.itemsite_id) AND (ci.itemsite_costcat_id=cc.costcat_id) AND (womatl_wo_id=wo_id) AND (wo_itemsite_id=pi.itemsite_id) AND (pi.itemsite_costcat_id=pc.costcat_id) AND (ci.itemsite_item_id=item_id) AND (womatl_id=pWomatlid) ); -- Create linkage to the transaction created IF (_invhistid != -1) THEN INSERT INTO womatlpost (womatlpost_womatl_id,womatlpost_invhist_id) VALUES (pWomatlid,_invhistid); END IF; -- Decrease the parent W/O's WIP value by the value of the returned components UPDATE wo SET wo_wipvalue = (wo_wipvalue - (CASE WHEN(itemsite_costmethod IN ('A','J')) THEN _cost WHEN(itemsite_costmethod='S') THEN stdcost(itemsite_item_id) * _qty ELSE 0.0 END )), wo_postedvalue = (wo_postedvalue - (CASE WHEN(itemsite_costmethod IN ('A','J')) THEN _cost WHEN(itemsite_costmethod='S') THEN stdcost(itemsite_item_id) * _qty ELSE 0.0 END )) FROM womatl, itemsite WHERE ( (wo_id=womatl_wo_id) AND (womatl_itemsite_id=itemsite_id) AND (womatl_id=pWomatlid) ); UPDATE womatl SET womatl_qtyiss = (womatl_qtyiss - pQty), womatl_lastreturn = CURRENT_DATE WHERE (womatl_id=pWomatlid); RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.returnwomaterial(integer, numeric, integer, timestamp with time zone, boolean) OWNER TO admin; -- -- Name: returnwomaterialbatch(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION returnwomaterialbatch(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; _itemlocSeries INTEGER; _woid INTEGER; _r RECORD; BEGIN SELECT wo_id INTO _woid FROM wo WHERE ( (wo_status IN ('E','I')) AND (wo_id=pWoid) ); IF (FOUND) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; FOR _r IN SELECT womatl_id, CASE WHEN wo_qtyord >= 0 THEN womatl_qtyiss ELSE ((womatl_qtyreq - womatl_qtyiss) * -1) END AS qty FROM wo, womatl, itemsite WHERE ((wo_id=womatl_wo_id) AND (womatl_itemsite_id=itemsite_id) AND ( (wo_qtyord < 0) OR (womatl_issuemethod IN ('S','M')) ) AND (womatl_wo_id=pWoid)) LOOP IF (_r.qty != 0) THEN PERFORM returnWoMaterial(_r.womatl_id, _r.qty, _itemlocSeries, now()); END IF; END LOOP; -- Reset the W/O Status to E UPDATE wo SET wo_status='E' WHERE (wo_id=pWoid); RETURN _itemlocSeries; ELSE RETURN -1; END IF; END; $_$; ALTER FUNCTION public.returnwomaterialbatch(integer) OWNER TO admin; -- -- Name: reversecashreceipt(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION reversecashreceipt(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCashrcptid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; _p RECORD; _r RECORD; _postToAR NUMERIC; _postToMisc NUMERIC; _posted_base NUMERIC := 0; _posted NUMERIC := 0; _sequence INTEGER; _aropenid INTEGER; _arMemoNumber TEXT; _arAccntid INTEGER; _closed BOOLEAN; _debitAccntid INTEGER; _exchGain NUMERIC; _comment TEXT; _ccpayid INTEGER; _cctype TEXT; BEGIN _posted := 0; _posted_base := 0; SELECT fetchGLSequence() INTO _sequence; SELECT accnt_id INTO _arAccntid FROM cashrcpt, accnt, salescat WHERE ((cashrcpt_salescat_id=salescat_id) AND (salescat_ar_accnt_id=accnt_id) AND (cashrcpt_id=pCashrcptid)); IF (NOT FOUND) THEN SELECT accnt_id INTO _arAccntid FROM cashrcpt, accnt WHERE ( (findARAccount(cashrcpt_cust_id)=accnt_id) AND (cashrcpt_id=pCashrcptid) ); IF (NOT FOUND) THEN RETURN -5; END IF; END IF; SELECT cashrcpt_cust_id, ('Reverse Cash Receipt posting for ' || cust_number||'-'||cust_name) AS custnote, cashrcpt_fundstype, cashrcpt_number, cashrcpt_docnumber, cashrcpt_distdate, cashrcpt_amount, cashrcpt_discount, (cashrcpt_amount / cashrcpt_curr_rate) AS cashrcpt_amount_base, (cashrcpt_discount / cashrcpt_curr_rate) AS cashrcpt_discount_base, cashrcpt_notes, cashrcpt_bankaccnt_id AS bankaccnt_id, accnt_id AS prepaid_accnt_id, cashrcpt_usecustdeposit, cashrcpt_curr_id, cashrcpt_curr_rate INTO _p FROM accnt, cashrcpt LEFT OUTER JOIN custinfo ON (cashrcpt_cust_id=cust_id) WHERE ( (findPrepaidAccount(cashrcpt_cust_id)=accnt_id) AND (cashrcpt_id=pCashrcptid) ); IF (NOT FOUND) THEN RETURN -7; END IF; IF (_p.cashrcpt_fundstype IN ('A', 'D', 'M', 'V')) THEN SELECT ccpay_id, ccpay_type INTO _ccpayid, _cctype FROM ccpay WHERE ((ccpay_r_ordernum IN (CAST(pCashrcptid AS TEXT), _p.cashrcpt_docnumber)) AND (ccpay_status IN ('C', 'A'))); IF NOT FOUND THEN -- the following select seems to work except for xikar - bug 8848. why? -- raise warning so there is some visibility if people fall into this path. SELECT ccpay_id, ccpay_type INTO _ccpayid, _cctype FROM ccpay WHERE ((ccpay_order_number IN (CAST(pCashrcptid AS TEXT), _p.cashrcpt_docnumber)) AND (ccpay_status IN ('C', 'A'))); IF (NOT FOUND) THEN RETURN -8; ELSE RAISE WARNING 'PostCashReceipt() found ccpay_id % for order number %/% (ref 8848).', _ccpayid, pCashrcptid, _p.cashrcpt_docnumber; END IF; END IF; -- If there is a ccpay entry and the card was charged directly, use the prepaid account IF (_cctype = 'C' ) THEN _debitAccntid := findPrepaidAccount(_p.cashrcpt_cust_id); -- If there is a ccpay entry and the card was preauthed and then charged, use the Bank account ELSE SELECT accnt_id INTO _debitAccntid FROM cashrcpt, bankaccnt, accnt WHERE ( (cashrcpt_bankaccnt_id=bankaccnt_id) AND (bankaccnt_accnt_id=accnt_id) AND (cashrcpt_id=pCashrcptid) ); IF (NOT FOUND) THEN RETURN -6; END IF; END IF; ELSE SELECT accnt_id INTO _debitAccntid FROM cashrcpt, bankaccnt, accnt WHERE ( (cashrcpt_bankaccnt_id=bankaccnt_id) AND (bankaccnt_accnt_id=accnt_id) AND (cashrcpt_id=pCashrcptid) ); IF (NOT FOUND) THEN RETURN -6; END IF; END IF; -- Determine the amount to post to A/R Open Items SELECT COALESCE(SUM(cashrcptitem_amount),0) INTO _postToAR FROM cashrcptitem JOIN aropen ON (aropen_id=cashrcptitem_aropen_id) WHERE ((cashrcptitem_cashrcpt_id=pCashrcptid) AND (cashrcptitem_applied)); IF (NOT FOUND) THEN _postToAR := 0; END IF; -- Determine the amount to post to Misc. Distributions SELECT COALESCE(SUM(cashrcptmisc_amount),0) INTO _postToMisc FROM cashrcptmisc WHERE (cashrcptmisc_cashrcpt_id=pCashrcptid); IF (NOT FOUND) THEN _postToMisc := 0; END IF; -- Check to see if the C/R is over applied IF ((_postToAR + _postToMisc) > _p.cashrcpt_amount) THEN RETURN -1; END IF; -- Check to see if the C/R is positive amount IF (_p.cashrcpt_amount <= 0) THEN RETURN -2; END IF; -- Distribute A/R Applications FOR _r IN SELECT aropen_id, aropen_doctype, aropen_docnumber, aropen_docdate, aropen_duedate, aropen_curr_id, aropen_curr_rate, round(aropen_amount - aropen_paid, 2) <= round(aropen_paid + currToCurr(_p.cashrcpt_curr_id, aropen_curr_id,abs(cashrcptitem_amount + cashrcptitem_discount),_p.cashrcpt_distdate),2) AS closed, cashrcptitem_id, cashrcptitem_amount, cashrcptitem_discount, (cashrcptitem_amount / _p.cashrcpt_curr_rate) AS cashrcptitem_amount_base, (cashrcptitem_discount / _p.cashrcpt_curr_rate) AS cashrcptitem_discount_base, round(aropen_paid - currToCurr(_p.cashrcpt_curr_id, aropen_curr_id,abs(cashrcptitem_amount),_p.cashrcpt_distdate),2) AS new_paid, round(currToCurr(_p.cashrcpt_curr_id, aropen_curr_id,abs(cashrcptitem_discount),_p.cashrcpt_distdate),2) AS new_discount FROM cashrcptitem JOIN aropen ON (cashrcptitem_aropen_id=aropen_id) WHERE ((cashrcptitem_cashrcpt_id=pCashrcptid) AND (cashrcptitem_applied)) LOOP -- Handle discount IF (_r.cashrcptitem_discount_base > 0) THEN PERFORM reverseCashReceiptDisc(_r.cashrcptitem_id, pJournalNumber); END IF; -- Update the aropen item to post the paid amount UPDATE aropen SET aropen_paid = _r.new_paid - _r.new_discount, aropen_open = TRUE, aropen_closedate = NULL WHERE (aropen_id=_r.aropen_id); -- Cache the running amount posted _posted_base := _posted_base + _r.cashrcptitem_amount_base; _posted := _posted + _r.cashrcptitem_amount; -- Record the cashrcpt application IF (_r.aropen_doctype IN ('I','D')) THEN INSERT INTO arapply ( arapply_cust_id, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_reftype, arapply_ref_id, arapply_applied, arapply_closed, arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_username, arapply_curr_id ) VALUES ( _p.cashrcpt_cust_id, -1, 'K', _p.cashrcpt_number, _r.aropen_id, _r.aropen_doctype, _r.aropen_docnumber, _p.cashrcpt_fundstype, _p.cashrcpt_docnumber, 'CRA', _r.cashrcptitem_id, (round(_r.cashrcptitem_amount, 2) * -1.0), _r.closed, CURRENT_DATE, _p.cashrcpt_distdate, pJournalNumber, getEffectiveXtUser(), _p.cashrcpt_curr_id ); ELSE INSERT INTO arapply ( arapply_cust_id, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_reftype, arapply_ref_id, arapply_applied, arapply_closed, arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_username, arapply_curr_id ) VALUES ( _p.cashrcpt_cust_id, _r.aropen_id, _r.aropen_doctype, _r.aropen_docnumber, -1, 'R', _p.cashrcpt_number, '', '', 'CRA', _r.cashrcptitem_id, (round(abs(_r.cashrcptitem_amount), 2) * -1.0), _r.closed, CURRENT_DATE, _p.cashrcpt_distdate, pJournalNumber, getEffectiveXtUser(), _p.cashrcpt_curr_id ); END IF; _exchGain := arCurrGain(_r.aropen_id,_p.cashrcpt_curr_id, abs(_r.cashrcptitem_amount), _p.cashrcpt_distdate); PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', (_r.aropen_doctype || '-' || _r.aropen_docnumber), CASE WHEN _r.aropen_doctype != 'R' THEN _arAccntid ELSE findDeferredAccount(_p.cashrcpt_cust_id) END, (round(_r.cashrcptitem_amount_base + _exchGain, 2) * -1.0), _p.cashrcpt_distdate, _p.custnote ); IF (_exchGain <> 0) THEN PERFORM insertIntoGLSeries(_sequence, 'A/R', 'CR', _r.aropen_doctype || '-' || _r.aropen_docnumber, getGainLossAccntId( CASE WHEN _r.aropen_doctype != 'R' THEN _arAccntid ELSE findDeferredAccount(_p.cashrcpt_cust_id) END ), round(_exchGain, 2), _p.cashrcpt_distdate, _p.custnote); END IF; END LOOP; -- Distribute Misc. Applications FOR _r IN SELECT cashrcptmisc_id, cashrcptmisc_accnt_id, cashrcptmisc_amount, (cashrcptmisc_amount / _p.cashrcpt_curr_rate) AS cashrcptmisc_amount_base, cashrcptmisc_notes FROM cashrcptmisc WHERE (cashrcptmisc_cashrcpt_id=pCashrcptid) LOOP -- Cache the running amount posted _posted_base := (_posted_base + _r.cashrcptmisc_amount_base); _posted := (_posted + _r.cashrcptmisc_amount); -- Record the cashrcpt application INSERT INTO arapply ( arapply_cust_id, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_applied, arapply_closed, arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_username, arapply_curr_id, arapply_reftype, arapply_ref_id ) VALUES ( _p.cashrcpt_cust_id, -1, 'K', '', -1, 'Misc.', '', _p.cashrcpt_fundstype, _p.cashrcpt_docnumber, (round(_r.cashrcptmisc_amount, 2) * -1.0), TRUE, CURRENT_DATE, _p.cashrcpt_distdate, pJournalNumber, getEffectiveXtUser(), _p.cashrcpt_curr_id, 'CRD', _r.cashrcptmisc_id ); PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', _r.cashrcptmisc_notes, _r.cashrcptmisc_accnt_id, (round(_r.cashrcptmisc_amount_base, 2) * -1.0), _p.cashrcpt_distdate, _p.custnote ); END LOOP; -- Post any remaining Cash to an A/R Debit Memo -- this credit memo may absorb an occasional currency exchange rounding error IF (round(_posted_base, 2) < round(_p.cashrcpt_amount_base, 2)) THEN _comment := ('Unapplied from ' || _p.cashrcpt_fundstype || '-' || _p.cashrcpt_docnumber); PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', _comment, _p.prepaid_accnt_id, ((round(_p.cashrcpt_amount_base, 2) - round(_posted_base, 2)) * -1.0), _p.cashrcpt_distdate, _p.custnote ); SELECT fetchArMemoNumber() INTO _arMemoNumber; -- Post A/R Debit Memo SELECT createARDebitMemo(NULL, _p.cashrcpt_cust_id, pJournalNumber, _arMemoNumber, '', _p.cashrcpt_distdate, (_p.cashrcpt_amount - _posted), _comment, -1, -1, -1, _p.cashrcpt_distdate, -1, NULL, 0, _p.cashrcpt_curr_id) INTO _aropenid; -- Create Cash Receipt Item to capture posting INSERT INTO cashrcptitem ( cashrcptitem_cashrcpt_id, cashrcptitem_aropen_id, cashrcptitem_amount ) VALUES ( pCashrcptid, _aropenid, ((_p.cashrcpt_amount - _posted) * 1.0) ); ELSIF (round(_posted_base, 2) > round(_p.cashrcpt_amount_base, 2)) THEN PERFORM insertIntoGLSeries(_sequence, 'A/R', 'CR', 'Currency Exchange Rounding - ' || _p.cashrcpt_docnumber, getGainLossAccntId(_debitAccntid), ((round(_posted_base, 2) - round((_p.cashrcpt_amount_base + _p.cashrcpt_discount_base), 2)) * 1.0), _p.cashrcpt_distdate, _p.custnote); END IF; -- Debit Cash PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', (_p.cashrcpt_fundstype || '-' || _p.cashrcpt_docnumber), _debitAccntid, round(_p.cashrcpt_amount_base, 2), _p.cashrcpt_distdate, _p.custnote ); PERFORM postGLSeries(_sequence, pJournalNumber); -- Update and void the posted cashrcpt UPDATE cashrcpt SET cashrcpt_posted=FALSE, cashrcpt_posteddate=NULL, cashrcpt_postedby=NULL, cashrcpt_void=TRUE WHERE (cashrcpt_id=pCashrcptid); RETURN 1; END; $_$; ALTER FUNCTION public.reversecashreceipt(integer, integer) OWNER TO admin; -- -- Name: reversecashreceiptdisc(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION reversecashreceiptdisc(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCashrcptItemId ALIAS FOR $1; pJournalNumber ALIAS FOR $2; _r RECORD; _t RECORD; _v RECORD; _ardiscountid INTEGER; _arMemoNumber TEXT; _arAccntid INTEGER; _discountAccntid INTEGER; _comment TEXT; _discprcnt NUMERIC; _check INTEGER; BEGIN -- Fetch base records for processing SELECT aropen_id, aropen_doctype, aropen_amount, cashrcptitem_discount, cashrcpt_cust_id, cashrcpt_distdate, cashrcpt_applydate, cashrcpt_curr_id, cashrcpt_fundstype, cashrcpt_docnumber, round(currToCurr(cashrcpt_curr_id, aropen_curr_id, cashrcptitem_discount, cashrcpt_distdate),2) AS aropen_discount INTO _r FROM cashrcptitem JOIN cashrcpt ON (cashrcptitem_cashrcpt_id=cashrcpt_id) JOIN aropen ON ( (aropen_id=cashrcptitem_aropen_id) AND (aropen_doctype IN ('I', 'D')) ) WHERE (cashrcptitem_id=pCashrcptItemId); -- Get discount account _discountAccntid := findardiscountaccount(_r.cashrcpt_cust_id); IF (_r.cashrcptitem_discount > 0) THEN -- Determine discount percentage _discprcnt := _r.aropen_discount / _r.aropen_amount; SELECT fetchArMemoNumber() INTO _arMemoNumber; _comment := 'Discount Credit Reversal from ' || _r.cashrcpt_fundstype || '-' || _r.cashrcpt_docnumber; -- Create misc debit memo record _ardiscountid := nextval('aropen_aropen_id_seq'); INSERT INTO aropen ( aropen_id, aropen_docdate, aropen_duedate, aropen_doctype, aropen_docnumber, aropen_curr_id, aropen_posted, aropen_amount ) VALUES ( _ardiscountid, _r.cashrcpt_distdate, _r.cashrcpt_distdate, 'D', _arMemoNumber, _r.cashrcpt_curr_id, false,_r.cashrcptitem_discount); IF (fetchMetricBool('CreditTaxDiscount')) THEN -- proportional tax credits calculated and implemented for the debit memo generated by the discount IF (_r.aropen_doctype = 'I') THEN -- Tax for invoices SELECT aropen_cobmisc_id AS invcheadid, invchead_curr_id, invchead_invcdate INTO _t FROM aropen LEFT OUTER JOIN invchead ON (aropen_cobmisc_id = invchead_id) LEFT OUTER JOIN invcitem ON (invchead_id = invcitem_invchead_id) WHERE aropen_id = _r.aropen_id; FOR _v IN SELECT tax_sales_accnt_id, tax_id, round(sum(taxdetail_tax), 2) AS tax, currToBase(_t.invchead_curr_id, round(sum(taxdetail_tax), 2), _t.invchead_invcdate) AS taxbasevalue FROM tax JOIN calculateTaxDetailSummary('I', _t.invcheadid, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id, tax_sales_accnt_id LOOP INSERT INTO aropentax( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_basis) VALUES ( _ardiscountid, getadjustmenttaxtypeid(), _v.tax_id, 0.00, 0.00, (round((_v.tax * _discprcnt), 2)), _r.cashrcpt_distdate, 0.00); END LOOP; ELSIF (_r.aropen_doctype = 'D') THEN -- Tax for debit memos INSERT INTO aropentax( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_basis) SELECT _ardiscountid, taxhist_taxtype_id, taxhist_tax_id, 0.00, 0.00, (round((taxhist_tax * _discprcnt), 2)), _r.cashrcpt_distdate, 0.00 FROM aropentax WHERE (taxhist_parent_id=_r.aropen_id); END IF; END IF; -- End taxes -- Create negative credit memo for discount SELECT createARCreditMemo(_ardiscountid, _r.cashrcpt_cust_id, _arMemoNumber, '', _r.cashrcpt_distdate, (_r.cashrcptitem_discount * -1.0), _comment, -1, -1, _discountAccntid, _r.cashrcpt_distdate, -1, NULL, 0, pJournalNumber, _r.cashrcpt_curr_id) INTO _ardiscountid; -- Apply discount negative credit memo INSERT INTO arcreditapply ( arcreditapply_source_aropen_id, arcreditapply_target_aropen_id, arcreditapply_amount, arcreditapply_curr_id ) VALUES ( _ardiscountid, _r.aropen_id, (_r.cashrcptitem_discount * -1.0), _r.cashrcpt_curr_id ); SELECT postARCreditMemoApplication(_ardiscountid, _r.cashrcpt_applydate) INTO _check; IF (_check < 0) THEN RAISE EXCEPTION 'Error posting discount credit memo application. Code %', _check; END IF; END IF; -- End handle Discount RETURN 1; END; $_$; ALTER FUNCTION public.reversecashreceiptdisc(integer, integer) OWNER TO admin; -- -- Name: reverseglseries(integer, date, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION reverseglseries(integer, date, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; pDistDate ALIAS FOR $2; pNotes ALIAS FOR $3; _sequence INTEGER := fetchGLSequence(); _journal INTEGER; BEGIN IF (SELECT COUNT(gltrans_sequence) > 0 FROM gltrans WHERE gltrans_sequence = pSequence) THEN SELECT fetchJournalNumber(jrnluse_use) INTO _journal FROM gltrans JOIN jrnluse ON (gltrans_journalnumber=jrnluse_number) WHERE (gltrans_sequence=pSequence) LIMIT 1; INSERT INTO gltrans (gltrans_created, gltrans_posted, gltrans_exported, gltrans_date, gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_docnumber, gltrans_misc_id, gltrans_amount, gltrans_notes, gltrans_journalnumber, gltrans_doctype) SELECT CURRENT_TIMESTAMP, FALSE, FALSE, pDistDate, _sequence, gltrans_accnt_id, gltrans_source, gltrans_docnumber, gltrans_misc_id, (gltrans_amount * -1), pNotes, _journal, gltrans_doctype FROM gltrans WHERE (gltrans_sequence=pSequence); PERFORM postIntoTrialBalance(_sequence); ELSE SELECT fetchJournalNumber(jrnluse_use) INTO _journal FROM sltrans JOIN jrnluse ON (sltrans_journalnumber=jrnluse_number) WHERE (sltrans_sequence=pSequence) LIMIT 1; INSERT INTO sltrans (sltrans_created, sltrans_posted, sltrans_date, sltrans_sequence, sltrans_accnt_id, sltrans_source, sltrans_docnumber, sltrans_misc_id, sltrans_amount, sltrans_notes, sltrans_journalnumber, sltrans_doctype) SELECT CURRENT_TIMESTAMP, FALSE, pDistDate, _sequence, sltrans_accnt_id, sltrans_source, sltrans_docnumber, sltrans_misc_id, (sltrans_amount * -1), pNotes, _journal, sltrans_doctype FROM sltrans WHERE (sltrans_sequence=pSequence); END IF; RETURN _journal; END; $_$; ALTER FUNCTION public.reverseglseries(integer, date, text) OWNER TO admin; -- -- Name: revokeallmodulecmnttypesource(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION revokeallmodulecmnttypesource(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmnttypeid ALIAS FOR $1; pModuleName ALIAS FOR $2; BEGIN DELETE FROM cmnttypesource WHERE (cmnttypesource_id IN ( SELECT cmnttypesource_id FROM cmnttypesource, source WHERE ( (cmnttypesource_source_id=source_id) AND (cmnttypesource_cmnttype_id=pCmnttypeid) AND (source_module=pModuleName) ) ) ); RETURN 1; END; $_$; ALTER FUNCTION public.revokeallmodulecmnttypesource(integer, text) OWNER TO admin; -- -- Name: revokeallmodulepriv(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION revokeallmodulepriv(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pModuleName ALIAS FOR $2; BEGIN DELETE FROM usrpriv WHERE (usrpriv_id IN ( SELECT usrpriv_id FROM usrpriv, priv WHERE ( (usrpriv_priv_id=priv_id) AND (usrpriv_username=pUsername) AND (priv_module=pModuleName) ) ) ); NOTIFY "usrprivUpdated"; RETURN 1; END; $_$; ALTER FUNCTION public.revokeallmodulepriv(text, text) OWNER TO admin; -- -- Name: revokeallmoduleprivgroup(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION revokeallmoduleprivgroup(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pGrpid ALIAS FOR $1; pModuleName ALIAS FOR $2; BEGIN DELETE FROM grppriv WHERE (grppriv_id IN ( SELECT grppriv_id FROM grppriv, priv WHERE ( (grppriv_priv_id=priv_id) AND (grppriv_grp_id=pGrpid) AND (priv_module=pModuleName) ) ) ); RETURN 1; END; $_$; ALTER FUNCTION public.revokeallmoduleprivgroup(integer, text) OWNER TO admin; -- -- Name: revokecmnttypesource(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION revokecmnttypesource(integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmnttypeid ALIAS FOR $1; pSourceid ALIAS FOR $2; BEGIN DELETE FROM cmnttypesource WHERE ( (cmnttypesource_cmnttype_id=pCmnttypeid) AND (cmnttypesource_source_id=pSourceid) ); RETURN TRUE; END; $_$; ALTER FUNCTION public.revokecmnttypesource(integer, integer) OWNER TO admin; -- -- Name: revokegroup(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION revokegroup(text, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pGrpid ALIAS FOR $2; BEGIN DELETE FROM usrgrp WHERE ( (usrgrp_username=pUsername) AND (usrgrp_grp_id=pGrpid) ); RETURN TRUE; END; $_$; ALTER FUNCTION public.revokegroup(text, integer) OWNER TO admin; -- -- Name: revokepriv(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION revokepriv(text, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pPrivid ALIAS FOR $2; BEGIN DELETE FROM usrpriv WHERE ( (usrpriv_username=pUsername) AND (usrpriv_priv_id=pPrivid) ); NOTIFY "usrprivUpdated"; RETURN TRUE; END; $_$; ALTER FUNCTION public.revokepriv(text, integer) OWNER TO admin; -- -- Name: revokepriv(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION revokepriv(text, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pPrivname ALIAS FOR $2; BEGIN DELETE FROM usrpriv WHERE ( (usrpriv_username=pUsername) AND (usrpriv_priv_id IN (SELECT priv_id FROM priv WHERE priv_name=pPrivname) )); NOTIFY "usrprivUpdated"; RETURN TRUE; END; $_$; ALTER FUNCTION public.revokepriv(text, text) OWNER TO admin; -- -- Name: revokeprivgroup(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION revokeprivgroup(integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pGrpid ALIAS FOR $1; pPrivid ALIAS FOR $2; BEGIN DELETE FROM grppriv WHERE ( (grppriv_grp_id=pGrpid) AND (grppriv_priv_id=pPrivid) ); NOTIFY "usrprivUpdated"; RETURN TRUE; END; $_$; ALTER FUNCTION public.revokeprivgroup(integer, integer) OWNER TO admin; -- -- Name: rollupactualcost(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION rollupactualcost(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; BEGIN RETURN rollUpSorACost(pitemid, TRUE); END; $_$; ALTER FUNCTION public.rollupactualcost(integer) OWNER TO admin; -- -- Name: rollupsoracost(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION rollupsoracost(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pActual ALIAS FOR $2; _counter INTEGER; _setid INTEGER; _consumers RECORD; BEGIN _counter := 0; SELECT indentedWhereUsed(pItemid) INTO _setid; FOR _consumers IN SELECT bomwork_item_id FROM bomwork WHERE (bomwork_set_id=_setid) ORDER BY bomwork_level LOOP PERFORM updateSorACost( _consumers.bomwork_item_id, costelem_type, TRUE, lowerCost(_consumers.bomwork_item_id, costelem_type, pActual), pActual ) FROM costelem WHERE (costelem_sys); PERFORM updateLowerUserCosts(_consumers.bomwork_item_id, pActual); _counter := _counter + 1; END LOOP; PERFORM deleteBOMWorkset(_setid); RETURN _counter; END; $_$; ALTER FUNCTION public.rollupsoracost(integer, boolean) OWNER TO admin; -- -- Name: rollupstandardcost(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION rollupstandardcost(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; BEGIN RETURN rollUpSorACost(pItemid, FALSE); END; $_$; ALTER FUNCTION public.rollupstandardcost(integer) OWNER TO admin; -- -- Name: roundcost(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION roundcost(pcost numeric) RETURNS numeric LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _scale INTEGER; BEGIN IF (pCost IS NULL) THEN RETURN NULL; END IF; SELECT locale_cost_scale INTO _scale FROM locale WHERE (locale_id=getUsrLocaleId()); RETURN ROUND(pCost, _scale); END; $$; ALTER FUNCTION public.roundcost(pcost numeric) OWNER TO admin; -- -- Name: roundlocale(boolean, numeric, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION roundlocale(pfractional boolean, pqty numeric, plocale text) RETURNS numeric LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; _scale INTEGER; BEGIN IF (pFractional) THEN SELECT * INTO _r FROM locale WHERE (locale_id=getUsrLocaleId()); _scale := CASE pLocale WHEN 'qtyper' THEN _r.locale_qtyper_scale WHEN 'cost' THEN _r.locale_cost_scale ELSE _r.locale_qty_scale END; RETURN ROUND(pQty, _scale); ELSE IF (TRUNC(pQty) < pQty) THEN RETURN (TRUNC(pQty) + 1); ELSE RETURN TRUNC(pQty); END IF; END IF; END; $$; ALTER FUNCTION public.roundlocale(pfractional boolean, pqty numeric, plocale text) OWNER TO admin; -- -- Name: roundqty(boolean, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION roundqty(pfractional boolean, pqty numeric) RETURNS numeric LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _scale INTEGER; BEGIN SELECT locale_qty_scale INTO _scale FROM locale WHERE (locale_id=getUsrLocaleId()); IF (pFractional) THEN RETURN ROUND(pQty, _scale); ELSE IF (TRUNC(pQty) < ROUND(pQty, _scale)) THEN RETURN (TRUNC(pQty) + 1); ELSE RETURN TRUNC(pQty); END IF; END IF; END; $$; ALTER FUNCTION public.roundqty(pfractional boolean, pqty numeric) OWNER TO admin; -- -- Name: roundsale(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION roundsale(psale numeric) RETURNS numeric LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _scale INTEGER; BEGIN IF (pSale IS NULL) THEN RETURN NULL; END IF; SELECT locale_salesprice_scale INTO _scale FROM locale WHERE (locale_id=getUsrLocaleId()); RETURN ROUND(pSale, _scale); END; $$; ALTER FUNCTION public.roundsale(psale numeric) OWNER TO admin; -- -- Name: roundup(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION roundup(numeric) RETURNS numeric LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pValue ALIAS FOR $1; _checkValue integer; BEGIN _checkValue := pValue::integer; IF (_checkValue::numeric < pValue) THEN RETURN (_checkValue + 1)::numeric; ELSE RETURN _checkValue::numeric; END IF; END; $_$; ALTER FUNCTION public.roundup(numeric) OWNER TO admin; -- -- Name: saveaddr(integer, text, text, text, text, text, text, text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION saveaddr(integer, text, text, text, text, text, text, text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAddrId ALIAS FOR $1; pNumber ALIAS FOR $2; pAddr1 ALIAS FOR $3; pAddr2 ALIAS FOR $4; pAddr3 ALIAS FOR $5; pCity ALIAS FOR $6; pState ALIAS FOR $7; pPostalCode ALIAS FOR $8; pCountry ALIAS FOR $9; pFlag ALIAS FOR $10; _returnVal INTEGER; BEGIN SELECT saveAddr(pAddrId,pNumber, pAddr1,pAddr2,pAddr3,pCity,pState,pPostalCode,pCountry,true,'',pFlag) INTO _returnVal; RETURN _returnVal; END; $_$; ALTER FUNCTION public.saveaddr(integer, text, text, text, text, text, text, text, text, text) OWNER TO admin; -- -- Name: saveaddr(integer, text, text, text, text, text, text, text, text, boolean, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION saveaddr(integer, text, text, text, text, text, text, text, text, boolean, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAddrId ALIAS FOR $1; pNumber ALIAS FOR $2; pAddr1 ALIAS FOR $3; pAddr2 ALIAS FOR $4; pAddr3 ALIAS FOR $5; pCity ALIAS FOR $6; pState ALIAS FOR $7; pPostalCode ALIAS FOR $8; pCountry ALIAS FOR $9; pActive ALIAS FOR $10; pNotes ALIAS FOR $11; pFlag ALIAS FOR $12; _addrId INTEGER; _addrNumber INTEGER; _flag TEXT; _p RECORD; _cnt INTEGER; _notes TEXT; BEGIN --Validate IF ((pFlag IS NULL) OR (pFlag = '') OR (pFlag = 'CHECK') OR (pFlag = 'CHANGEONE') OR (pFlag = 'CHANGEALL')) THEN IF (pFlag='') THEN _flag := 'CHECK'; ELSE _flag := COALESCE(pFlag,'CHECK'); END IF; ELSE RAISE EXCEPTION 'Invalid Flag (%). Valid flags are CHECK, CHANGEONE or CHANGEALL', pFlag; END IF; _notes := COALESCE(pNotes,''); --If there is nothing here, get out IF ( (pNumber = '' OR pNumber IS NULL) AND (pAddr1 = '' OR pAddr1 IS NULL) AND (pAddr2 = '' OR pAddr2 IS NULL) AND (pAddr3 = '' OR pAddr3 IS NULL) AND (pCity = '' OR pCity IS NULL) AND (pState = '' OR pState IS NULL) AND (pPostalCode = '' OR pPostalCode IS NULL) AND (pCountry = '' OR pCountry IS NULL) ) THEN RETURN NULL; END IF; _addrId := COALESCE(pAddrId,-1); --If we have an ID see if anything has changed, if not get out IF (_addrId >= 0) THEN SELECT * FROM addr INTO _p WHERE ((pAddrId=addr_id) AND (COALESCE(pNumber,addr_number)=addr_number) AND (COALESCE(pAddr1, '')=COALESCE(addr_line1, '')) AND (COALESCE(pAddr2, '')=COALESCE(addr_line2, '')) AND (COALESCE(pAddr3, '')=COALESCE(addr_line3, '')) AND (COALESCE(pCity, '')=COALESCE(addr_city, '')) AND (COALESCE(pState, '')=COALESCE(addr_state, '')) AND (COALESCE(pPostalCode, '')=COALESCE(addr_postalcode, '')) AND (COALESCE(pCountry, '')=COALESCE(addr_country, '')) AND (pActive=addr_active) AND (_notes=COALESCE(addr_notes,''))); IF (FOUND) THEN RETURN _addrId; END IF; END IF; --Check to see if duplicate address exists SELECT addr_id, addr_notes INTO _p FROM addr WHERE ((_addrId <> addr_id) AND (COALESCE(UPPER(addr_line1),'') = COALESCE(UPPER(pAddr1),'')) AND (COALESCE(UPPER(addr_line2),'') = COALESCE(UPPER(pAddr2),'')) AND (COALESCE(UPPER(addr_line3),'') = COALESCE(UPPER(pAddr3),'')) AND (COALESCE(UPPER(addr_city),'') = COALESCE(UPPER(pCity),'')) AND (COALESCE(UPPER(addr_state),'') = COALESCE(UPPER(pState),'')) AND (COALESCE(UPPER(addr_postalcode),'') = COALESCE(UPPER(pPostalcode),'')) AND (COALESCE(UPPER(addr_country),'') = COALESCE(UPPER(pCountry),''))); IF (FOUND) THEN --Note: To prevent overwriting of existing notes, the application --needs to load any existing notes for a matching address before altering them. IF (_notes <> _p.addr_notes) THEN UPDATE addr SET addr_notes=addr_notes || ' ' || _notes WHERE addr_id=_p.addr_id; END IF; RETURN _p.addr_id; --A matching address exits END IF; IF (_addrId < 0) THEN _flag := 'CHANGEONE'; END IF; IF (_flag = 'CHECK') THEN IF addrUseCount(_addrId) > 1 THEN RETURN -2; ELSIF (SELECT COUNT(addr_id)=0 FROM addr WHERE (addr_id=_addrId)) THEN _flag := 'CHANGEONE'; ELSE _flag := 'CHANGEALL'; END IF; END IF; IF (_flag = 'CHANGEALL') THEN _addrNumber := pNumber; IF (_addrNumber IS NULL) THEN SELECT addr_number INTO _addrNumber FROM addr WHERE(addr_id = _addrId); IF (_addrNumber IS NULL) THEN _addrNumber := fetchNextNumber('AddressNumber'); END IF; END IF; UPDATE addr SET addr_line1 = pAddr1, addr_line2 = pAddr2, addr_line3 = pAddr3, addr_city = pCity, addr_state = pState, addr_postalcode = pPostalcode, addr_country = pCountry, addr_active = pActive, addr_notes = pNotes WHERE addr_id = _addrId; RETURN _addrId; ELSE SELECT NEXTVAL('addr_addr_id_seq') INTO _addrId; IF (_flag = 'CHANGEONE') THEN _addrNumber := fetchNextNumber('AddressNumber'); ELSE _addrNumber := COALESCE(pNumber::text,fetchNextNumber('AddressNumber')); END IF; INSERT INTO addr ( addr_id, addr_number, addr_line1, addr_line2, addr_line3, addr_city, addr_state, addr_postalcode, addr_country, addr_active, addr_notes ) VALUES ( _addrId, _addrNumber, pAddr1, pAddr2, pAddr3, pCity, pState, pPostalcode, pCountry, pActive, _notes); RETURN _addrId; END IF; END; $_$; ALTER FUNCTION public.saveaddr(integer, text, text, text, text, text, text, text, text, boolean, text, text) OWNER TO admin; -- -- Name: savealarm(integer, text, date, time without time zone, integer, text, boolean, text, boolean, text, boolean, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION savealarm(integer, text, date, time without time zone, integer, text, boolean, text, boolean, text, boolean, text, text, integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAlarmId ALIAS FOR $1; pAlarmNumber ALIAS FOR $2; pDate ALIAS FOR $3; pTime ALIAS FOR $4; pOffset ALIAS FOR $5; pQualifier ALIAS FOR $6; pEvent ALIAS FOR $7; pEventRecipient ALIAS FOR $8; pEmail ALIAS FOR $9; pEmailRecipient ALIAS FOR $10; pSysmsg ALIAS FOR $11; pSysmsgRecipient ALIAS FOR $12; pSource ALIAS FOR $13; pSourceId ALIAS FOR $14; pFlag ALIAS FOR $15; _alarmId INTEGER; _alarmNumber TEXT; _alarmTime TIMESTAMP; _alarmInterval INTERVAL; _alarmTrigger TIMESTAMP; _isNew BOOLEAN; _flag TEXT; _alarmCount INTEGER := 0; _debug BOOLEAN := false; BEGIN IF (_debug) THEN RAISE NOTICE 'pAlarmId = %', pAlarmId; RAISE NOTICE 'pAlarmNumber = %', pAlarmNumber; RAISE NOTICE 'pDate = %', pDate; RAISE NOTICE 'pTime = %', pTime; RAISE NOTICE 'pOffset = %', pOffset; RAISE NOTICE 'pQualifier = %', pQualifier; RAISE NOTICE 'pEvent = %', pEvent; RAISE NOTICE 'pEventRecipient = %', pEventRecipient; RAISE NOTICE 'pEmail = %', pEmail; RAISE NOTICE 'pEmailRecipient = %', pEmailRecipient; RAISE NOTICE 'pSysmsg = %', pSysmsg; RAISE NOTICE 'pSysmsgRecipient = %', pSysmsgRecipient; RAISE NOTICE 'pSource = %', pSource; RAISE NOTICE 'pSourceId = %', pSourceId; RAISE NOTICE 'pFlag = %', pFlag; END IF; --Validate IF ((pFlag IS NULL) OR (pFlag = '') OR (pFlag = 'CHECK') OR (pFlag = 'CHANGEONE') OR (pFlag = 'CHANGEALL')) THEN IF (pFlag='') THEN _flag := 'CHECK'; ELSE _flag := COALESCE(pFlag,'CHECK'); END IF; ELSE RAISE EXCEPTION 'Invalid Flag (%). Valid flags are CHECK, CHANGEONE or CHANGEALL', pFlag; END IF; --If there is nothing here get out IF ( (pAlarmId IS NULL OR pAlarmId = -1) AND (pOffset IS NULL) AND (pSourceId IS NULL) AND (COALESCE(pQualifier, '') = '') AND (COALESCE(pEventRecipient, '') = '') AND (COALESCE(pEmailRecipient, '') = '') AND (COALESCE(pSysmsgRecipient, '') = '') AND (COALESCE(pSource, '') = '') ) THEN RETURN NULL; END IF; IF (pAlarmId IS NULL OR pAlarmId = -1) THEN _isNew := true; _alarmId := nextval('alarm_alarm_id_seq'); _alarmNumber := fetchNextNumber('AlarmNumber'); ELSE SELECT COUNT(alarm_id) INTO _alarmCount FROM alarm WHERE ((alarm_id=pAlarmId) AND (alarm_source=pSource) AND (alarm_source_id=pSourceId)); -- ask whether new or update if name changes -- but only if this isn't a new record with a pre-allocated id IF (_alarmCount < 1 AND _flag = 'CHECK') THEN IF (EXISTS(SELECT alarm_id FROM alarm WHERE (alarm_id=pAlarmId))) THEN RETURN -10; ELSE _isNew := true; _alarmNumber := fetchNextNumber('AlarmNumber'); END IF; ELSIF (_flag = 'CHANGEONE') THEN _isNew := true; _alarmId := nextval('alarm_alarm_id_seq'); _alarmNumber := fetchNextNumber('AlarmNumber'); END IF; END IF; _alarmNumber := COALESCE(_alarmNumber,pAlarmNumber,fetchNextNumber('AlarmNumber')); _alarmTime := COALESCE(pDate, CURRENT_DATE) + COALESCE(pTime, CURRENT_TIME); IF (COALESCE(pOffset, 0) > 0) THEN _alarmInterval := CASE WHEN (pQualifier IN ('MB', 'MA')) THEN CAST(pOffset AS TEXT) || ' minutes' WHEN (pQualifier IN ('HB', 'HA')) THEN CAST(pOffset AS TEXT) || ' hours' WHEN (pQualifier IN ('DB', 'DA')) THEN CAST(pOffset AS TEXT) || ' days' ELSE '' END; _alarmTrigger := CASE WHEN (pQualifier IN ('MB', 'HB', 'DB')) THEN _alarmTime - _alarmInterval WHEN (pQualifier IN ('MA', 'HA', 'DA')) THEN _alarmTime + _alarmInterval ELSE _alarmTime END; ELSE _alarmTrigger := _alarmTime; END IF; IF (_isNew) THEN _alarmId := COALESCE(_alarmId,pAlarmId,nextval('alarm_alarm_id_seq')); INSERT INTO alarm ( alarm_id,alarm_number, alarm_event, alarm_email, alarm_sysmsg, alarm_trigger, alarm_time, alarm_time_offset, alarm_time_qualifier, alarm_creator, alarm_event_recipient, alarm_email_recipient, alarm_sysmsg_recipient, alarm_source, alarm_source_id ) VALUES ( _alarmId, _alarmNumber, pEvent, pEmail, pSysmsg, _alarmTrigger, _alarmTime, pOffset, pQualifier, getEffectiveXtUser(), pEventRecipient, pEmailRecipient, pSysmsgRecipient, pSource, pSourceId ); RETURN _alarmId; ELSE UPDATE alarm SET alarm_number=_alarmNumber, alarm_event=COALESCE(pEvent, alarm_event), alarm_email=COALESCE(pEmail, alarm_event), alarm_sysmsg=COALESCE(pSysmsg, alarm_event), alarm_trigger=_alarmTrigger, alarm_time=_alarmTime, alarm_time_offset=COALESCE(pOffset, alarm_time_offset), alarm_time_qualifier=COALESCE(pQualifier, alarm_time_qualifier), alarm_event_recipient=COALESCE(pEventRecipient, alarm_event_recipient), alarm_email_recipient=COALESCE(pEmailRecipient, alarm_email_recipient), alarm_sysmsg_recipient=COALESCE(pSysmsgRecipient, alarm_sysmsg_recipient) WHERE (alarm_id=pAlarmId); RETURN pAlarmId; END IF; END; $_$; ALTER FUNCTION public.savealarm(integer, text, date, time without time zone, integer, text, boolean, text, boolean, text, boolean, text, text, integer, text) OWNER TO admin; -- -- Name: savebomhead(integer, text, date, text, numeric, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION savebomhead(integer, text, date, text, numeric, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pRevision ALIAS FOR $2; pRevisionDate ALIAS FOR $3; pDocumentNumber ALIAS FOR $4; pBatchSize ALIAS FOR $5; pRequiredQtyPer ALIAS FOR $6; _seq INTEGER; _p RECORD; _revid INTEGER; BEGIN IF (NOT fetchMetricBool('RevControl')) THEN -- Deal with BOM if Rev Control Turned off SELECT bomhead_id INTO _seq FROM bomhead WHERE (bomhead_item_id=pItemid); IF (NOT FOUND) THEN -- No bomhead exists _seq := NEXTVAL('bomhead_bomhead_id_seq'); INSERT INTO bomhead (bomhead_id,bomhead_item_id,bomhead_docnum,bomhead_revision, bomhead_revisiondate,bomhead_batchsize,bomhead_requiredqtyper,bomhead_rev_id) VALUES (_seq,pItemid, pDocumentNumber, pRevision, pRevisionDate, pBatchSize, pRequiredQtyPer,-1); ELSE UPDATE bomhead SET bomhead_revision = pRevision, bomhead_revisiondate = pRevisionDate, bomhead_docnum = pDocumentNumber, bomhead_batchsize = pBatchSize, bomhead_requiredqtyper = pRequiredQtyPer WHERE (bomhead_id=_seq); END IF; RETURN _seq; ELSE -- Deal with Revision Control IF (COALESCE(pRevision,'') = '' AND getActiveRevId('BOM',pItemid) != -1) THEN RAISE EXCEPTION 'Revision Control records exist for item. You must provide a new or existing revision number.'; END IF; SELECT * INTO _p FROM bomhead LEFT OUTER JOIN rev ON (bomhead_rev_id=rev_id), item WHERE ((bomhead_item_id=pItemid) AND (COALESCE(bomhead_revision,'')=COALESCE(pRevision,'')) AND (bomhead_item_id=item_id)); IF (NOT FOUND) THEN -- This is a new bomhead record IF LENGTH(pRevision) > 0 THEN -- We need to create a revision record SELECT createbomrev(pItemid, pRevision) INTO _revid; UPDATE bomhead SET bomhead_revisiondate = pRevisiondate, bomhead_docnum = pDocumentNumber, bomhead_batchsize = pBatchsize, bomhead_requiredqtyper = pRequiredqtyper WHERE (bomhead_rev_id=_revid); SELECT bomhead_id INTO _seq FROM bomhead WHERE (bomhead_rev_id=_revid); RETURN _seq; ELSE -- Just create a regular bom header record _seq := NEXTVAL('bomhead_bomhead_id_seq'); INSERT INTO bomhead (bomhead_id,bomhead_item_id,bomhead_docnum,bomhead_revision, bomhead_revisiondate,bomhead_batchsize,bomhead_requiredqtyper,bomhead_rev_id) VALUES (_seq,pItemid, pDocumentNumber, pRevision, pRevisionDate, pBatchSize, pRequiredQtyPer,-1); RETURN _seq; END IF; ELSE -- We need to update a record IF (_p.rev_status = 'I') THEN RAISE EXCEPTION 'Revision % for % is inactive. Update not allowed.', _p.rev_number, _p.item_number; ELSIF (COALESCE(pRevision,'') = COALESCE(_p.bomhead_revision,'')) THEN -- No change, just update UPDATE bomhead SET bomhead_revisiondate = pRevisiondate, bomhead_docnum = pDocumentNumber, bomhead_batchsize = pBatchSize, bomhead_requiredqtyper = pRequiredqtyper WHERE (bomhead_id=_p.bomhead_id); RETURN _p.bomhead_id; ELSE -- Need a new revision SELECT createbomrev(pItemid, pRevision) INTO _revid; UPDATE bomhead SET bomhead_revisiondate = pRevisiondate, bomhead_docnum = pDocumentNumber, bomhead_batchsize = pBatchSize, bomhead_requiredqtyper = pRequiredqtyper WHERE (bomhead_rev_id=_revid); SELECT bomhead_id INTO _seq FROM bomhead WHERE (bomhead_rev_id=_revid); RETURN _seq; END IF; END IF; END IF; RETURN _seq; END; $_$; ALTER FUNCTION public.savebomhead(integer, text, date, text, numeric, numeric) OWNER TO admin; -- -- Name: savecntct(integer, text, integer, text, text, text, text, text, text, text, text, text, text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION savecntct(pcntctid integer, pcontactnumber text, paddrid integer, phonorific text, pfirstname text, pmiddlename text, plastname text, psuffix text, pphone text, pphone2 text, pfax text, pemail text, pwebaddr text, ptitle text, pflag text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN SELECT saveCntct(pCntctId,pContactNumber,NULL,pAddrId,pHonorific,pFirstName,pMiddleName,pLastName,pSuffix,NULL, NULL,pPhone,pPhone2,pFax,pEmail,pWebAddr,NULL,pTitle,pFlag, NULL) INTO _returnVal; RETURN _returnVal; END; $$; ALTER FUNCTION public.savecntct(pcntctid integer, pcontactnumber text, paddrid integer, phonorific text, pfirstname text, pmiddlename text, plastname text, psuffix text, pphone text, pphone2 text, pfax text, pemail text, pwebaddr text, ptitle text, pflag text) OWNER TO admin; -- -- Name: savecntct(integer, text, integer, integer, text, text, text, text, text, text, boolean, text, text, text, text, text, text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION savecntct(pcntctid integer, pcontactnumber text, pcrmacctid integer, paddrid integer, phonorific text, pfirstname text, pmiddlename text, plastname text, psuffix text, pinitials text, pactive boolean, pphone text, pphone2 text, pfax text, pemail text, pwebaddr text, pnotes text, ptitle text, pflag text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN SELECT saveCntct( pCntctId, pContactNumber, pCrmAcctId, pAddrId, pHonorific, pFirstName, pMiddleName, pLastName, pSuffix, pInitials, pActive, pPhone, pPhone2, pFax, pEmail, pWebAddr, pNotes, pTitle, pFlag, NULL) INTO _returnVal; RETURN _returnVal; END; $$; ALTER FUNCTION public.savecntct(pcntctid integer, pcontactnumber text, pcrmacctid integer, paddrid integer, phonorific text, pfirstname text, pmiddlename text, plastname text, psuffix text, pinitials text, pactive boolean, pphone text, pphone2 text, pfax text, pemail text, pwebaddr text, pnotes text, ptitle text, pflag text) OWNER TO admin; -- -- Name: savecntct(integer, text, integer, integer, text, text, text, text, text, text, boolean, text, text, text, text, text, text, text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION savecntct(pcntctid integer, pcontactnumber text, pcrmacctid integer, paddrid integer, phonorific text, pfirstname text, pmiddlename text, plastname text, psuffix text, pinitials text, pactive boolean, pphone text, pphone2 text, pfax text, pemail text, pwebaddr text, pnotes text, ptitle text, pflag text, pownerusername text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cntctId INTEGER; _cntctNumber TEXT; _isNew BOOLEAN; _flag TEXT; _contactCount INTEGER := 0; BEGIN --Validate IF ((pFlag IS NULL) OR (pFlag = '') OR (pFlag = 'CHECK') OR (pFlag = 'CHANGEONE') OR (pFlag = 'CHANGEALL')) THEN IF (pFlag='') THEN _flag := 'CHECK'; ELSE _flag := COALESCE(pFlag,'CHECK'); END IF; ELSE RAISE EXCEPTION 'Invalid Flag (%). Valid flags are CHECK, CHANGEONE or CHANGEALL', pFlag; END IF; --If there is nothing here get out IF ( (pCntctId IS NULL OR pCntctId = -1) AND (pAddrId IS NULL) AND (COALESCE(pFirstName, '') = '') AND (COALESCE(pMiddleName, '') = '') AND (COALESCE(pLastName, '') = '') AND (COALESCE(pSuffix, '') = '') AND (COALESCE(pHonorific, '') = '') AND (COALESCE(pInitials, '') = '') AND (COALESCE(pPhone, '') = '') AND (COALESCE(pPhone2, '') = '') AND (COALESCE(pFax, '') = '') AND (COALESCE(pEmail, '') = '') AND (COALESCE(pWebAddr, '') = '') AND (COALESCE(pNotes, '') = '') AND (COALESCE(pTitle, '') = '') ) THEN RETURN NULL; END IF; IF (pCntctId IS NULL OR pCntctId = -1) THEN _isNew := true; _cntctId := nextval('cntct_cntct_id_seq'); _cntctNumber := COALESCE(pContactNumber,fetchNextNumber('ContactNumber')); ELSE SELECT COUNT(cntct_id) INTO _contactCount FROM cntct WHERE ((cntct_id=pCntctId) AND (cntct_first_name=pFirstName) AND (cntct_last_name=pLastName)); -- ask whether new or update if name changes -- but only if this isn't a new record with a pre-allocated id IF (_contactCount < 1 AND _flag = 'CHECK') THEN IF (EXISTS(SELECT cntct_id FROM cntct WHERE (cntct_id=pCntctId))) THEN RETURN -10; ELSE _isNew := true; _cntctNumber := fetchNextNumber('ContactNumber'); END IF; ELSIF (_flag = 'CHANGEONE') THEN _isNew := true; _cntctId := nextval('cntct_cntct_id_seq'); _cntctNumber := fetchNextNumber('ContactNumber'); ELSIF (_flag = 'CHANGEALL') THEN _isNew := false; END IF; END IF; IF (pContactNumber = '') THEN _cntctNumber := fetchNextNumber('ContactNumber'); ELSE _cntctNumber := COALESCE(_cntctNumber,pContactNumber,fetchNextNumber('ContactNumber')); END IF; IF (_isNew) THEN _cntctId := COALESCE(_cntctId,pCntctId,nextval('cntct_cntct_id_seq')); INSERT INTO cntct ( cntct_id,cntct_number, cntct_crmacct_id,cntct_addr_id,cntct_first_name, cntct_last_name,cntct_honorific,cntct_initials, cntct_active,cntct_phone,cntct_phone2, cntct_fax,cntct_email,cntct_webaddr, cntct_notes,cntct_title,cntct_middle,cntct_suffix, cntct_owner_username ) VALUES ( _cntctId, COALESCE(_cntctNumber,fetchNextNumber('ContactNumber')) ,pCrmAcctId,pAddrId, pFirstName,pLastName,pHonorific, pInitials,COALESCE(pActive,true),pPhone,pPhone2,pFax, pEmail,pWebAddr,pNotes,pTitle,pMiddleName,pSuffix,pOwnerUsername ); RETURN _cntctId; ELSE UPDATE cntct SET cntct_number=COALESCE(_cntctNumber,fetchNextNumber('ContactNumber')), cntct_crmacct_id=COALESCE(pCrmAcctId,cntct_crmacct_id), cntct_addr_id=COALESCE(pAddrId,cntct_addr_id), cntct_first_name=COALESCE(pFirstName,cntct_first_name), cntct_last_name=COALESCE(pLastName,cntct_last_name), cntct_honorific=COALESCE(pHonorific,cntct_honorific), cntct_initials=COALESCE(pInitials,cntct_initials), cntct_active=COALESCE(pActive,cntct_active), cntct_phone=COALESCE(pPhone,cntct_phone), cntct_phone2=COALESCE(pPhone2,cntct_phone2), cntct_fax=COALESCE(pFax,cntct_fax), cntct_email=COALESCE(pEmail,cntct_email), cntct_webaddr=COALESCE(pWebAddr,cntct_webaddr), cntct_notes=COALESCE(pNotes,cntct_notes), cntct_title=COALESCE(pTitle,cntct_title), cntct_middle=COALESCE(pMiddleName,cntct_middle), cntct_suffix=COALESCE(pSuffix,cntct_suffix), cntct_owner_username=COALESCE(pOwnerUsername, cntct_owner_username) WHERE (cntct_id=pCntctId); RETURN pCntctId; END IF; END; $$; ALTER FUNCTION public.savecntct(pcntctid integer, pcontactnumber text, pcrmacctid integer, paddrid integer, phonorific text, pfirstname text, pmiddlename text, plastname text, psuffix text, pinitials text, pactive boolean, pphone text, pphone2 text, pfax text, pemail text, pwebaddr text, pnotes text, ptitle text, pflag text, pownerusername text) OWNER TO admin; -- -- Name: saveimageass(text, integer, character, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION saveimageass(text, integer, character, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSource ALIAS FOR $1; pSourceId ALIAS FOR $2; pPurpose ALIAS FOR $3; pImageid ALIAS FOR $4; _imageassId INTEGER = 0; BEGIN -- See if this link already exists SELECT imageass_id INTO _imageassId FROM imageass WHERE ((imageass_source_id=pSourceId) AND (imageass_source=pSource) AND (imageass_image_id=pImageId) AND (imageass_purpose=pPurpose)); IF (FOUND) THEN RETURN _imageassId; END IF; -- See if a record with this purpose already exists (item only) IF (pSource = 'I' AND pPurpose != 'M') THEN SELECT imageass_id INTO _imageassId FROM imageass WHERE ((imageass_source_id=pSourceId) AND (imageass_source=pSource) AND (imageass_purpose=pPurpose)); END IF; IF (_imageassId > 0) THEN UPDATE imageass SET imageass_image_id=pImageId WHERE (imageass_id=_imageassId); ELSE _imageassId := NEXTVAL('imageass_imageass_id_seq'); INSERT INTO imageass (imageass_id, imageass_source_id, imageass_source, imageass_image_id, imageass_purpose) VALUES (_imageassId, pSourceId, pSource, pImageid, CASE WHEN pSource='I' THEN pPurpose ELSE 'M' END); END IF; RETURN _imageassId; END; $_$; ALTER FUNCTION public.saveimageass(text, integer, character, integer) OWNER TO admin; -- -- Name: saveipsitem(integer, integer, integer, numeric, numeric, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION saveipsitem(integer, integer, integer, numeric, numeric, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pIpsItemId ALIAS FOR $1; pIpsHeadId ALIAS FOR $2; pItemId ALIAS FOR $3; pQtyBreak ALIAS FOR $4; pPrice ALIAS FOR $5; pQtyUomId ALIAS FOR $6; pPriceUomId ALIAS FOR $7; _ipsitemid INTEGER; _new BOOLEAN; BEGIN -- Validation IF (SELECT COUNT(item_id)=0 FROM item WHERE (item_id=pItemId)) THEN RAISE EXCEPTION 'You must provide a valid Item'; ELSIF (COALESCE(pQtyBreak,0) < 0) THEN RAISE EXCEPTION 'Quantity can not be a negative value'; ELSIF (COALESCE(pPrice,0) < 0) THEN RAISE EXCEPTION 'Price must be a negative value'; ELSIF ((pQtyUomId IS NOT NULL) AND (SELECT COUNT(item_id)=0 FROM (SELECT item_id FROM item WHERE ((item_id=pItemId) AND (item_inv_uom_id=pQtyUomId)) UNION SELECT item_id FROM item,itemuomconv,itemuom,uomtype WHERE ((item_id=pItemId) AND (itemuomconv_item_id=item_id) AND (itemuomconv_from_uom_id=pQtyUomId) AND (itemuom_itemuomconv_id=itemuomconv_id) AND (itemuom_uomtype_id=uomtype_id) AND (uomtype_name='Selling')) UNION SELECT item_id FROM item,itemuomconv,itemuom,uomtype WHERE ((item_id=pItemId) AND (itemuomconv_item_id=item_id) AND (itemuomconv_to_uom_id=pQtyUomId) AND (itemuom_itemuomconv_id=itemuomconv_id) AND (itemuom_uomtype_id=uomtype_id) AND (uomtype_name='Selling'))) AS data)) THEN RAISE EXCEPTION 'Qty UOM Must be a valid Selling UOM for the Item'; ELSIF ((pPriceUomId IS NOT NULL) AND (SELECT COUNT(item_id)=0 FROM (SELECT item_id FROM item WHERE ((item_id=pItemId) AND (item_inv_uom_id=pPriceUomId)) UNION SELECT item_id FROM item,itemuomconv,itemuom,uomtype WHERE ((item_id=pItemId) AND (itemuomconv_item_id=item_id) AND (itemuomconv_from_uom_id=pPriceUomId) AND (itemuom_itemuomconv_id=itemuomconv_id) AND (itemuom_uomtype_id=uomtype_id) AND (uomtype_name='Selling')) UNION SELECT item_id FROM item,itemuomconv,itemuom,uomtype WHERE ((item_id=pItemId) AND (itemuomconv_item_id=item_id) AND (itemuomconv_to_uom_id=pPriceUomId) AND (itemuom_itemuomconv_id=itemuomconv_id) AND (itemuom_uomtype_id=uomtype_id) AND (uomtype_name='Selling'))) AS data)) THEN RAISE EXCEPTION 'Price UOM Must be a valid Selling UOM for the Item'; END IF; _new := TRUE; IF (pIpsItemId IS NOT NULL) THEN SELECT ipsitem_id INTO _ipsitemid FROM ipsitem WHERE (ipsitem_id=pIpsItemId); IF (FOUND) THEN _new := FALSE; ELSE RAISE EXCEPTION 'Pricing Schedule Item not found.'; END IF; ELSE SELECT ipsitem_id INTO _ipsitemid FROM ipsitem WHERE ((ipsitem_ipshead_id = pIpsheadId) AND (ipsitem_item_id = pItemId) AND (ipsitem_qtybreak = pQtyBreak) AND (ipsitem_qty_uom_id = COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId))) AND (ipsitem_price_uom_id = CASE WHEN (pQtyUomId = (SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) THEN COALESCE(pPriceUomId,pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) ELSE COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) END)); END IF; IF (FOUND) THEN _new := false; ELSE _ipsitemid := nextval('ipsitem_ipsitem_id_seq'); END IF; IF (_new) THEN INSERT INTO ipsitem ( ipsitem_id, ipsitem_ipshead_id, ipsitem_item_id, ipsitem_qtybreak, ipsitem_price, ipsitem_qty_uom_id, ipsitem_price_uom_id, ipsitem_discntprcnt, ipsitem_fixedamtdiscount) VALUES ( _ipsitemid, pIpsheadId, pItemId, pQtyBreak, pPrice, COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)), CASE WHEN (pQtyUomId = (SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) THEN COALESCE(pPriceUomId,pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) ELSE COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) END, 0.0, 0.0); ELSE UPDATE ipsitem SET ipsitem_qtybreak = pQtyBreak, ipsitem_price = pPrice, ipsitem_qty_uom_id = COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)), ipsitem_price_uom_id = CASE WHEN (pQtyUomId = (SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) THEN COALESCE(pPriceUomId,pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) ELSE COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) END WHERE (ipsitem_id=_ipsitemid); END IF; RETURN _ipsitemid; END; $_$; ALTER FUNCTION public.saveipsitem(integer, integer, integer, numeric, numeric, integer, integer) OWNER TO admin; -- -- Name: saveipsitem(integer, integer, integer, numeric, numeric, integer, integer, numeric, numeric, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION saveipsitem(pipsitemid integer, pipsheadid integer, pitemid integer, pqtybreak numeric, pprice numeric, pqtyuomid integer, ppriceuomid integer, ppercent numeric, pfixedamt numeric, ptype text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _ipsitemid INTEGER; _new BOOLEAN; BEGIN -- Validation IF (SELECT COUNT(item_id)=0 FROM item WHERE (item_id=pItemId)) THEN RAISE EXCEPTION 'You must provide a valid Item'; ELSIF (COALESCE(pQtyBreak,0) < 0) THEN RAISE EXCEPTION 'Quantity can not be a negative value'; ELSIF (COALESCE(pPrice,0) < 0) THEN RAISE EXCEPTION 'Price must be a negative value'; ELSIF ((pQtyUomId IS NOT NULL) AND (SELECT COUNT(item_id)=0 FROM (SELECT item_id FROM item WHERE ((item_id=pItemId) AND (item_inv_uom_id=pQtyUomId)) UNION SELECT item_id FROM item,itemuomconv,itemuom,uomtype WHERE ((item_id=pItemId) AND (itemuomconv_item_id=item_id) AND (itemuomconv_from_uom_id=pQtyUomId) AND (itemuom_itemuomconv_id=itemuomconv_id) AND (itemuom_uomtype_id=uomtype_id) AND (uomtype_name='Selling')) UNION SELECT item_id FROM item,itemuomconv,itemuom,uomtype WHERE ((item_id=pItemId) AND (itemuomconv_item_id=item_id) AND (itemuomconv_to_uom_id=pQtyUomId) AND (itemuom_itemuomconv_id=itemuomconv_id) AND (itemuom_uomtype_id=uomtype_id) AND (uomtype_name='Selling'))) AS data)) THEN RAISE EXCEPTION 'Qty UOM Must be a valid Selling UOM for the Item'; ELSIF ((pPriceUomId IS NOT NULL) AND (SELECT COUNT(item_id)=0 FROM (SELECT item_id FROM item WHERE ((item_id=pItemId) AND (item_inv_uom_id=pPriceUomId)) UNION SELECT item_id FROM item,itemuomconv,itemuom,uomtype WHERE ((item_id=pItemId) AND (itemuomconv_item_id=item_id) AND (itemuomconv_from_uom_id=pPriceUomId) AND (itemuom_itemuomconv_id=itemuomconv_id) AND (itemuom_uomtype_id=uomtype_id) AND (uomtype_name='Selling')) UNION SELECT item_id FROM item,itemuomconv,itemuom,uomtype WHERE ((item_id=pItemId) AND (itemuomconv_item_id=item_id) AND (itemuomconv_to_uom_id=pPriceUomId) AND (itemuom_itemuomconv_id=itemuomconv_id) AND (itemuom_uomtype_id=uomtype_id) AND (uomtype_name='Selling'))) AS data)) THEN RAISE EXCEPTION 'Price UOM Must be a valid Selling UOM for the Item'; END IF; _new := TRUE; IF (pIpsItemId IS NOT NULL) THEN SELECT ipsitem_id INTO _ipsitemid FROM ipsiteminfo WHERE (ipsitem_id=pIpsItemId); IF (FOUND) THEN _new := FALSE; ELSE RAISE EXCEPTION 'Pricing Schedule Item not found.'; END IF; ELSE SELECT ipsitem_id INTO _ipsitemid FROM ipsiteminfo WHERE ((ipsitem_ipshead_id = pIpsheadId) AND (ipsitem_item_id = pItemId) AND (ipsitem_qtybreak = pQtyBreak) AND (ipsitem_qty_uom_id = COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId))) AND (ipsitem_price_uom_id = CASE WHEN (pQtyUomId = (SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) THEN COALESCE(pPriceUomId,pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) ELSE COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) END)); END IF; IF (FOUND) THEN _new := false; END IF; IF (_new) THEN INSERT INTO ipsiteminfo ( ipsitem_ipshead_id, ipsitem_item_id, ipsitem_qtybreak, ipsitem_price, ipsitem_qty_uom_id, ipsitem_price_uom_id, ipsitem_discntprcnt, ipsitem_fixedamtdiscount, ipsitem_type) VALUES ( pIpsheadId, pItemId, pQtyBreak, pPrice, COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)), CASE WHEN (pQtyUomId = (SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) THEN COALESCE(pPriceUomId,pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) ELSE COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) END, pPercent, pFixedAmt, pType) RETURNING ipsitem_id INTO _ipsitemid; ELSE UPDATE ipsiteminfo SET ipsitem_qtybreak = pQtyBreak, ipsitem_price = pPrice, ipsitem_qty_uom_id = COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)), ipsitem_price_uom_id = CASE WHEN (pQtyUomId = (SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) THEN COALESCE(pPriceUomId,pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) ELSE COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) END, ipsitem_discntprcnt=pPercent, ipsitem_fixedamtdiscount=pFixedAmt, ipsitem_type=pType WHERE (ipsitem_id=_ipsitemid); END IF; RETURN _ipsitemid; END; $$; ALTER FUNCTION public.saveipsitem(pipsitemid integer, pipsheadid integer, pitemid integer, pqtybreak numeric, pprice numeric, pqtyuomid integer, ppriceuomid integer, ppercent numeric, pfixedamt numeric, ptype text) OWNER TO admin; -- -- Name: saveipsprodcat(integer, integer, integer, numeric, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION saveipsprodcat(integer, integer, integer, numeric, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pIpsProdcatId ALIAS FOR $1; pIpsHeadId ALIAS FOR $2; pProdCatId ALIAS FOR $3; pQtyBreak ALIAS FOR $4; pDiscount ALIAS FOR $5; _ipsprodcatid INTEGER; _new BOOLEAN; BEGIN -- Validation IF (SELECT COUNT(*)=0 FROM prodcat WHERE (prodcat_id=pProdcatId)) THEN RAISE EXCEPTION 'You must provide a valid Product Category'; ELSIF (COALESCE(pQtyBreak,0) < 0) THEN RAISE EXCEPTION 'Quantity can not be a negative value'; ELSIF (COALESCE(pDiscount,0) < 0) THEN RAISE EXCEPTION 'Discount must be a negative value'; END IF; _new := TRUE; IF (pIpsProdcatId IS NOT NULL) THEN SELECT ipsprodcat_id INTO _ipsprodcatid FROM ipsprodcat WHERE (ipsprodcat_id=pIpsprodcatId); IF (FOUND) THEN _new := FALSE; ELSE RAISE EXCEPTION 'Pricing Schedule Product Category not found'; END IF; ELSE SELECT ipsprodcat_id INTO _ipsprodcatid FROM ipsprodcat WHERE ((ipsprodcat_ipshead_id=pIpsheadId) AND (ipsprodcat_prodcat_id=pProdcatId) AND (ipsprodcat_qtybreak=pQtyBreak)); IF (FOUND) THEN _new := false; ELSE _ipsprodcatid := nextval('ipsprodcat_ipsprodcat_id_seq'); END IF; END IF; IF (_new) THEN INSERT INTO ipsprodcat ( ipsprodcat_id, ipsprodcat_ipshead_id, ipsprodcat_prodcat_id, ipsprodcat_qtybreak, ipsprodcat_discntprcnt) VALUES ( _ipsprodcatid, pIpsheadId, pProdcatId, pQtyBreak, pDiscount * .01); ELSE UPDATE ipsprodcat SET ipsprodcat_qtybreak = pQtyBreak, ipsprodcat_discntprcnt = pDiscount * .01 WHERE (ipsprodcat_id=_ipsprodcatid); END IF; RETURN _ipsprodcatid; END; $_$; ALTER FUNCTION public.saveipsprodcat(integer, integer, integer, numeric, numeric) OWNER TO admin; -- -- Name: saveipsprodcat(integer, integer, integer, numeric, numeric, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION saveipsprodcat(integer, integer, integer, numeric, numeric, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pIpsProdcatId ALIAS FOR $1; pIpsHeadId ALIAS FOR $2; pProdCatId ALIAS FOR $3; pQtyBreak ALIAS FOR $4; pDiscount ALIAS FOR $5; pFixedAmtDiscount ALIAS FOR $6; _ipsprodcatid INTEGER; _new BOOLEAN; BEGIN -- Validation IF (SELECT COUNT(*)=0 FROM prodcat WHERE (prodcat_id=pProdcatId)) THEN RAISE EXCEPTION 'You must provide a valid Product Category'; ELSIF (COALESCE(pQtyBreak,0) < 0) THEN RAISE EXCEPTION 'Quantity can not be a negative value'; ELSIF (COALESCE(pDiscount,0) < 0) THEN RAISE EXCEPTION 'Discount must be a negative value'; END IF; _new := TRUE; IF (pIpsProdcatId IS NOT NULL) THEN SELECT ipsprodcat_id INTO _ipsprodcatid FROM ipsprodcat WHERE (ipsprodcat_id=pIpsprodcatId); IF (FOUND) THEN _new := FALSE; ELSE RAISE EXCEPTION 'Pricing Schedule Product Category not found'; END IF; ELSE SELECT ipsprodcat_id INTO _ipsprodcatid FROM ipsprodcat WHERE ((ipsprodcat_ipshead_id=pIpsheadId) AND (ipsprodcat_prodcat_id=pProdcatId) AND (ipsprodcat_qtybreak=pQtyBreak)); IF (FOUND) THEN _new := false; ELSE _ipsprodcatid := nextval('ipsprodcat_ipsprodcat_id_seq'); END IF; END IF; IF (_new) THEN INSERT INTO ipsprodcat ( ipsprodcat_id, ipsprodcat_ipshead_id, ipsprodcat_prodcat_id, ipsprodcat_qtybreak, ipsprodcat_discntprcnt, ipsprodcat_fixedamtdiscount) VALUES ( _ipsprodcatid, pIpsheadId, pProdcatId, pQtyBreak, pDiscount * .01, pFixedAmtDiscount); ELSE UPDATE ipsprodcat SET ipsprodcat_qtybreak = pQtyBreak, ipsprodcat_discntprcnt = pDiscount * .01, ipsprodcat_fixedamtdiscount = pFixedAmtDiscount WHERE (ipsprodcat_id=_ipsprodcatid); END IF; RETURN _ipsprodcatid; END; $_$; ALTER FUNCTION public.saveipsprodcat(integer, integer, integer, numeric, numeric, numeric) OWNER TO admin; -- -- Name: saveipsprodcat(integer, integer, integer, numeric, numeric, numeric, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION saveipsprodcat(pipsprodcatid integer, pipsheadid integer, pprodcatid integer, pqtybreak numeric, pdiscount numeric, pfixedamtdiscount numeric, ptype text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _ipsitemid INTEGER; _new BOOLEAN; BEGIN -- Validation IF (SELECT COUNT(*)=0 FROM prodcat WHERE (prodcat_id=pProdcatId)) THEN RAISE EXCEPTION 'You must provide a valid Product Category'; ELSIF (COALESCE(pQtyBreak,0) < 0) THEN RAISE EXCEPTION 'Quantity can not be a negative value'; ELSIF (COALESCE(pDiscount,0) < 0) THEN RAISE EXCEPTION 'Discount must be a negative value'; END IF; _new := TRUE; IF (pIpsProdcatId IS NOT NULL) THEN SELECT ipsitem_id INTO _ipsitemid FROM ipsiteminfo WHERE (ipsprodcat_id=pIpsprodcatId); IF (FOUND) THEN _new := FALSE; ELSE RAISE EXCEPTION 'Pricing Schedule Product Category not found'; END IF; ELSE SELECT ipsitem_id INTO _ipsitemid FROM ipsiteminfo WHERE ((ipsitem_ipshead_id=pIpsheadId) AND (ipsitem_prodcat_id=pProdcatId) AND (ipsitem_qtybreak=pQtyBreak)); IF (FOUND) THEN _new := false; ELSE _ipsitemid := nextval('ipsitem_ipsitem_id_seq'); END IF; END IF; IF (_new) THEN INSERT INTO ipsiteminfo ( ipsitem_id, ipsitem_ipshead_id, ipsitem_prodcat_id, ipsitem_qtybreak, ipsitem_price, ipsitem_discntprcnt, ipsitem_fixedamtdiscount, ipsitem_type) VALUES ( _ipsitemid, pIpsheadId, pProdcatId, pQtyBreak, 0.0, pDiscount * .01, pFixedAmtDiscount, pType); ELSE UPDATE ipsiteminfo SET ipsitem_qtybreak = pQtyBreak, ipsitem_discntprcnt = pDiscount * .01, ipsitem_fixedamtdiscount = pFixedAmtDiscount, ipsitem_type = pType WHERE (ipsitem_id=_ipsitemid); END IF; RETURN _ipsitemid; END; $$; ALTER FUNCTION public.saveipsprodcat(pipsprodcatid integer, pipsheadid integer, pprodcatid integer, pqtybreak numeric, pdiscount numeric, pfixedamtdiscount numeric, ptype text) OWNER TO admin; -- -- Name: saveitemimage(integer, character, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION saveitemimage(integer, character, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pPurpose ALIAS FOR $2; pImageid ALIAS FOR $3; _itemimageId INTEGER; BEGIN -- See if a record with this purpose already exists SELECT imageass_id INTO _itemimageId FROM imageass WHERE ( (imageass_source='I') AND (imageass_source_id=pItemid) AND (imageass_purpose=pPurpose) ); IF (FOUND) THEN UPDATE imageass SET imageass_image_id=pImageId WHERE (imageass_id=_itemimageId); ELSE _itemimageId := NEXTVAL('imageass_imageass_id_seq'); INSERT INTO imageass (imageass_id, imageass_source_id, imageass_source, imageass_image_id, imageass_purpose) VALUES (_itemimageId, pItemid, 'I', pImageid, pPurpose); END IF; RETURN _itemimageId; END; $_$; ALTER FUNCTION public.saveitemimage(integer, character, integer) OWNER TO admin; -- -- Name: saveitemuomconv(integer, integer, numeric, integer, numeric, boolean, integer[]); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION saveitemuomconv(integer, integer, numeric, integer, numeric, boolean, integer[]) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemId ALIAS FOR $1; pFromUomId ALIAS FOR $2; pFromValue ALIAS FOR $3; pToUomId ALIAS FOR $4; pToValue ALIAS FOR $5; pFractional ALIAS FOR $6; pUomTypes ALIAS FOR $7; _p RECORD; _fromUomId INTEGER; _fromValue NUMERIC; _toUomId INTEGER; _toValue NUMERIC; _fractional BOOLEAN; _seq INTEGER; _i INTEGER; _uomtype TEXT; BEGIN -- Make sure we have some itemtypes IF (pUomTypes IS NULL) OR (ARRAY_UPPER(pUomTypes,1) = 0) THEN RAISE EXCEPTION 'You must include at least one item type.'; END IF; -- If this is a global UOM, over-ride with global data. SELECT * INTO _p FROM uomconv WHERE ((((uomconv_from_uom_id=pFromUomId) AND (uomconv_to_uom_id=pToUomId)) OR ((uomconv_from_uom_id=pToUomId) AND (uomconv_to_uom_id=pFromUomId)))); IF (FOUND) THEN _fromUomId := _p.uomconv_from_uom_id; _toUomId := _p.uomconv_to_uom_id; _fromValue := _p.uomconv_from_value; _toValue := _p.uomconv_to_value; _fractional := _p.uomconv_fractional; --RAISE NOTICE 'Defaulted to global Unit of Measure conversion ratios.'; ELSE _fromUomId := pFromUomId; _fromValue := pFromValue; _toUomId := pToUomId; _toValue := pToValue; _fractional := pFractional; END IF; -- See if an item conversion exists going the other way SELECT f.uom_name AS f_uom, t.uom_name as t_uom INTO _p FROM itemuomconv,uom f, uom t WHERE ((itemuomconv_item_id=pItemId) AND (itemuomconv_from_uom_id=_toUomId) AND (itemuomconv_to_uom_id=_fromUomId) AND (f.uom_id=itemuomconv_from_uom_id) AND (t.uom_id=itemuomconv_to_uom_id)); IF (FOUND) THEN RAISE EXCEPTION 'Unit of measure conversion already exists going from % to %.',_p.f_uom,_p.t_uom; END IF; -- See if an item conversion record exists SELECT * INTO _p FROM itemuomconv WHERE ((itemuomconv_item_id=pItemId) AND (itemuomconv_from_uom_id=_fromUomId) AND (itemuomconv_to_uom_id=_toUomId)); -- Update if found IF (FOUND) THEN UPDATE itemuomconv SET itemuomconv_from_value=_fromValue, itemuomconv_to_value=_toValue, itemuomconv_fractional=_fractional WHERE (itemuomconv_id=_p.itemuomconv_id); _seq := _p.itemuomconv_id; --Delete old type list DELETE FROM itemuom WHERE itemuom_itemuomconv_id=_p.itemuomconv_id; ELSE -- Otherwise create a new one SELECT NEXTVAL('itemuomconv_itemuomconv_id_seq') INTO _seq; INSERT INTO itemuomconv VALUES (_seq, pItemId,_fromUomId,_fromValue,_toUomId,_toValue,_fractional); END IF; -- Build new type list FOR _i IN 1..ARRAY_UPPER(pUomTypes,1) LOOP SELECT uomtype_name INTO _uomtype FROM itemuomconv, itemuom, uomtype WHERE ((itemuom_uomtype_id=uomtype_id) AND (itemuomconv_id=itemuom_itemuomconv_id) AND (itemuomconv_item_id=pItemId) AND (uomtype_name != 'Selling') AND (itemuom_uomtype_id=pUomTypes[_i])); IF (FOUND) THEN RAISE EXCEPTION 'Unit of Measure Type % is already used on this item',_uomtype; ELSE INSERT INTO itemuom (itemuom_itemuomconv_id,itemuom_uomtype_id) VALUES (_seq,pUomTypes[_i]); END IF; END LOOP; RETURN _seq; END; $_$; ALTER FUNCTION public.saveitemuomconv(integer, integer, numeric, integer, numeric, boolean, integer[]) OWNER TO admin; -- -- Name: savemetasql(text, text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION savemetasql(text, text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN saveMetasql($1, $2, $3, $4, true, NULL, 0); END; $_$; ALTER FUNCTION public.savemetasql(text, text, text, text) OWNER TO admin; -- -- Name: savemetasql(text, text, text, text, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION savemetasql(text, text, text, text, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN saveMetasql($1, $2, $3, $4, $5, NULL, 0); END; $_$; ALTER FUNCTION public.savemetasql(text, text, text, text, boolean) OWNER TO admin; -- -- Name: savemetasql(text, text, text, text, boolean, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION savemetasql(text, text, text, text, boolean, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN saveMetasql($1, $2, $3, $4, $5, $6, 0); END; $_$; ALTER FUNCTION public.savemetasql(text, text, text, text, boolean, text) OWNER TO admin; -- -- Name: savemetasql(text, text, text, text, boolean, text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION savemetasql(text, text, text, text, boolean, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pGroup ALIAS FOR $1; pName ALIAS FOR $2; pNotes ALIAS FOR $3; pQuery ALIAS FOR $4; pSystem ALIAS FOR $5; pSchema ALIAS FOR $6; pGrade ALIAS FOR $7; _metasqlid INTEGER; _debug BOOL := false; _grade INTEGER; _insertstr TEXT; _table TEXT; BEGIN --See if Query already exists SELECT metasql_id INTO _metasqlid FROM metasql WHERE ((metasql_group=pGroup) AND (metasql_name=pName) AND (metasql_grade=pGrade)); IF (FOUND) THEN IF (_debug) THEN RAISE NOTICE 'update metasql'; END IF; UPDATE metasql SET metasql_group=pGroup, metasql_name=pName, metasql_notes=pNotes, metasql_query=pQuery WHERE (metasql_id=_metasqlid); ELSE IF (COALESCE(pSchema, 'public') = 'public' OR TRIM(pSchema) = '') THEN _table := 'metasql'; ELSE _table := pSchema || '.pkgmetasql'; END IF; IF (pGrade IS NULL) THEN SELECT MAX(metasql_grade) + 1 INTO _grade FROM metasql WHERE ((metasql_group=pGroup) AND (metasql_name=pName)); ELSE _grade := pGrade; END IF; _insertstr := 'INSERT INTO ' || _table || ' (metasql_group, metasql_name, metasql_notes, ' || ' metasql_query, metasql_grade) VALUES (' || COALESCE(quote_literal(pGroup),'NULL') || ',' || COALESCE(quote_literal(pName), 'NULL') || ',' || COALESCE(quote_literal(pNotes), 'NULL') || ',' || COALESCE(quote_literal(pQuery), 'NULL') ||',' || COALESCE(quote_literal(_grade), 'NULL') || ') RETURNING metasql_id;' ; IF (_debug) THEN RAISE NOTICE '%', _insertstr; END IF; EXECUTE _insertstr INTO _metasqlid; END IF; RETURN _metasqlid; END; $_$; ALTER FUNCTION public.savemetasql(text, text, text, text, boolean, text, integer) OWNER TO admin; -- -- Name: scraps(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION scraps(text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTransType ALIAS FOR $1; BEGIN IF (pTransType IN ('SI', 'SM', 'EX')) THEN RETURN TRUE; ELSE RETURN FALSE; END IF; END; $_$; ALTER FUNCTION public.scraps(text) OWNER TO admin; -- -- Name: scrapwomaterial(integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION scrapwomaterial(integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN scrapWoMaterial($1, $2, CURRENT_TIMESTAMP); END; $_$; ALTER FUNCTION public.scrapwomaterial(integer, numeric) OWNER TO admin; -- -- Name: scrapwomaterial(integer, numeric, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION scrapwomaterial(integer, numeric, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pQty ALIAS FOR $2; pGlDistTS ALIAS FOR $3; _costmethod CHAR(1); _scrapValue NUMERIC; _r RECORD; BEGIN -- Validate IF (pQty <= 0) THEN RAISE EXCEPTION 'Scrap quantity must be a positive number'; ELSIF ( ( SELECT (womatl_qtyiss < pQty) FROM womatl WHERE (womatl_id=pWomatlid) ) ) THEN RAISE EXCEPTION 'You may not scrap more material than has been issued'; END IF; -- Get the wip G/L account SELECT costcat_wip_accnt_id INTO _r FROM womatl, wo, itemsite, costcat WHERE((womatl_wo_id=wo_id) AND (wo_itemsite_id=itemsite_id) AND (itemsite_costcat_id=costcat_id) AND (womatl_id=pWomatlid)); -- Calculate scrap value SELECT itemsite_costmethod INTO _costmethod FROM womatl JOIN itemsite ON (womatl_itemsite_id=itemsite_id) WHERE (womatl_id=pWomatlid); IF (_costmethod = 'S') THEN SELECT ROUND((stdCost(itemsite_item_id) * itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, pQty)),2) INTO _scrapValue FROM womatl JOIN itemsite ON (womatl_itemsite_id=itemsite_id) WHERE (womatl_id=pWomatlid); ELSIF (_costmethod = 'A') THEN SELECT ROUND((SUM(invhist_invqty * invhist_unitcost)-womatl_scrapvalue)/ (CASE WHEN (SUM(invhist_invqty)-itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtywipscrap) = 0) THEN 1 ELSE SUM(invhist_invqty)-itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtywipscrap) END),2) * itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, pQty) INTO _scrapValue FROM womatl JOIN womatlpost ON (womatl_id=womatlpost_womatl_id) JOIN invhist ON (womatlpost_invhist_id=invhist_id) JOIN itemsite ON (womatl_itemsite_id=itemsite_id) WHERE (womatl_id=pWomatlid) GROUP BY itemsite_item_id,womatl_uom_id,womatl_qtywipscrap,womatl_scrapvalue; ELSE RAISE EXCEPTION 'Cost method not supported to scrap this item'; END IF; -- Distribute to G/L PERFORM insertGLTransaction( 'W/O', 'WO', formatWoNumber(womatl_wo_id), ('Scrap ' || item_number || ' from Work Order'), getPrjAccntId(wo_prj_id, _r.costcat_wip_accnt_id), getPrjAccntId(wo_prj_id, costcat_mfgscrap_accnt_id), -1, _scrapValue, date(pGlDistTS) ) FROM wo, womatl, itemsite, item, costcat WHERE ( (wo_id=womatl_wo_id) AND (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (itemsite_costcat_id=costcat_id) AND (womatl_id=pWomatlid) ); UPDATE womatl SET womatl_qtywipscrap=(womatl_qtywipscrap + pQty), womatl_scrapvalue = womatl_scrapvalue + _scrapValue, womatl_qtyiss=(womatl_qtyiss - pQty) WHERE (womatl_id=pWomatlid); UPDATE wo SET wo_wipvalue = wo_wipvalue-_scrapValue, wo_postedvalue = wo_postedvalue-_scrapValue FROM womatl WHERE ((womatl_id=pWomatlid) AND (wo_id=womatl_wo_id)); RETURN pWomatlid; END; $_$; ALTER FUNCTION public.scrapwomaterial(integer, numeric, timestamp with time zone) OWNER TO admin; -- -- Name: selectbalanceforbilling(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION selectbalanceforbilling(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; _returnval BOOLEAN := TRUE; _doSelect BOOLEAN; _result INTEGER; _soitem RECORD; BEGIN FOR _soitem IN -- Get the shipments for this SO. Kits are not shipped SELECT cust_partialship, coitem_id, coitem_linenumber, 'NOTK' AS item_type, SUM(shipitem_qty) AS qty, ( (SUM(shipitem_qty) >= (coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned + SUM(shipitem_qty))) OR (NOT cust_partialship) ) AS toclose FROM cohead JOIN custinfo ON (cust_id=cohead_cust_id) JOIN coitem ON (coitem_cohead_id=cohead_id) JOIN shipitem ON ( (shipitem_orderitem_id=coitem_id) AND (NOT shipitem_invoiced) ) JOIN shiphead ON ( (shiphead_id=shipitem_shiphead_id) AND (shiphead_order_type='SO') AND (shiphead_shipped) ) WHERE (cohead_id=pSoheadid) GROUP BY cust_partialship, coitem_id, item_type, coitem_linenumber, coitem_qtyord, coitem_qtyshipped, coitem_qtyreturned UNION -- Get the Kits for this SO SELECT cust_partialship, coitem_id, coitem_linenumber, 'K' AS item_type, coitem_qtyord AS qty, TRUE AS toclose FROM cohead JOIN custinfo ON (cust_id=cohead_cust_id) JOIN coitem ON (coitem_cohead_id=cohead_id AND coitem_status='O') JOIN itemsite ON (itemsite_id=coitem_itemsite_id) JOIN item ON ( (item_id=itemsite_item_id) AND (item_type='K') ) WHERE (cohead_id=pSoheadid) LOOP _doSelect := true; IF(_soitem.item_type = 'K') THEN -- see if all the sub items are shipped SELECT coitem_id INTO _result FROM coitem WHERE((coitem_cohead_id=pSoheadid) AND (coitem_linenumber=_soitem.coitem_linenumber) AND (coitem_subnumber > 0) AND ((coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) > 0)) LIMIT 1; IF( FOUND ) THEN _doSelect := false; END IF; END IF; IF (_doSelect) THEN -- do as much as we can but still report errors if they occur IF (selectForBilling(_soitem.coitem_id, _soitem.qty, _soitem.toclose) < 0) THEN _returnval := FALSE; END IF; END IF; END LOOP; RETURN _returnval; END; $_$; ALTER FUNCTION public.selectbalanceforbilling(integer) OWNER TO admin; -- -- Name: selectdiscountitemsforpayment(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION selectdiscountitemsforpayment(pvendid integer, pbankaccntid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _currid INTEGER; _r RECORD; BEGIN SELECT bankaccnt_curr_id INTO _currid FROM bankaccnt WHERE (bankaccnt_id=pBankaccntid); FOR _r IN SELECT apopen_id FROM apopen, terms WHERE((CURRENT_DATE <= determineDiscountDate(apopen_terms_id, apopen_docdate)) AND (terms_discprcnt > 0.0) AND (apopen_terms_id=terms_id) AND (apopen_open) AND (apopen_status = 'O') AND (apopen_doctype IN ('V', 'D')) AND (apopen_vend_id=pVendid) AND (apopen_curr_id=_currid) ) LOOP PERFORM selectPayment(_r.apopen_id, pBankaccntid); END LOOP; RETURN 1; END; $$; ALTER FUNCTION public.selectdiscountitemsforpayment(pvendid integer, pbankaccntid integer) OWNER TO admin; -- -- Name: selectdueitemsforpayment(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION selectdueitemsforpayment(pvendid integer, pbankaccntid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _currid INTEGER; BEGIN SELECT bankaccnt_curr_id INTO _currid FROM bankaccnt WHERE (bankaccnt_id=pBankaccntid); PERFORM selectPayment(apopen_id, pBankaccntid) FROM apopen WHERE((apopen_open) AND (apopen_vend_id=pVendid) AND (apopen_duedate <= CURRENT_DATE) AND (apopen_status = 'O') AND (apopen_doctype IN ('V', 'D')) AND (apopen_curr_id=_currid) ); RETURN 1; END; $$; ALTER FUNCTION public.selectdueitemsforpayment(pvendid integer, pbankaccntid integer) OWNER TO admin; -- -- Name: selectforbilling(integer, numeric, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION selectforbilling(integer, numeric, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoitemid ALIAS FOR $1; pQty ALIAS FOR $2; pClose ALIAS FOR $3; _itemid INTEGER := NULL; _taxzoneid INTEGER := NULL; _taxid INTEGER := NULL; _taxtypeid INTEGER := NULL; BEGIN SELECT cobmisc_taxzone_id, item_id, coitem_taxtype_id INTO _taxzoneid, _itemid, _taxtypeid FROM cobmisc, coitem, itemsite, item WHERE ((cobmisc_cohead_id = coitem_cohead_id) AND (NOT cobmisc_posted) AND (coitem_itemsite_id = itemsite_id) AND (itemsite_item_id = item_id) AND (coitem_id = pSoitemid) ) LIMIT 1; RETURN selectforbilling(pSoitemid, pQty, pClose, _taxtypeid); END; $_$; ALTER FUNCTION public.selectforbilling(integer, numeric, boolean) OWNER TO admin; -- -- Name: selectforbilling(integer, numeric, boolean, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION selectforbilling(integer, numeric, boolean, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoitemid ALIAS FOR $1; pQty ALIAS FOR $2; pClose ALIAS FOR $3; ptaxtypeid ALIAS FOR $4; _cobillid INTEGER; _r RECORD; BEGIN -- Get some information SELECT cobmisc_id, cobmisc_taxzone_id, coitem_id, coitem_price, coitem_price_invuomratio AS invpricerat, coitem_qty_invuomratio, item_id INTO _r FROM cobmisc, coitem, itemsite, item, site() WHERE ((cobmisc_cohead_id = coitem_cohead_id) AND (NOT cobmisc_posted) AND (coitem_itemsite_id = itemsite_id) AND (itemsite_item_id = item_id) AND (coitem_id = pSoitemid) AND (itemsite_warehous_id = warehous_id) ) LIMIT 1; -- check to make sure the qty to bill for is not less than -- the total un-invoiced shipped amount IF ((SELECT (pQty < SUM(shipitem_qty)) FROM shipitem, shiphead, coitem WHERE ( (shipitem_shiphead_id=shiphead_id) AND (shiphead_order_type='SO') AND (shiphead_order_id=coitem_cohead_id) AND (shipitem_orderitem_id=coitem_id) AND (shiphead_shipped) AND (NOT shipitem_invoiced) AND (coitem_id=pSoitemid) ) ) ) THEN RETURN -1; END IF; SELECT cobill_id INTO _cobillid FROM cobill, cobmisc, coitem WHERE ((cobill_cobmisc_id = cobmisc_id) AND (cobmisc_cohead_id = coitem_cohead_id) AND (cobill_coitem_id = coitem_id) AND (NOT cobmisc_posted) AND (coitem_id = pSoitemid)); IF (FOUND) THEN UPDATE cobill SET cobill_selectdate = CURRENT_DATE, cobill_select_username = getEffectiveXtUser(), cobill_qty = pQty, cobill_toclose = pClose, cobill_taxtype_id = ptaxtypeid WHERE (cobill_id=_cobillid); ELSE SELECT NEXTVAL('cobill_cobill_id_seq') INTO _cobillid; INSERT INTO cobill (cobill_id, cobill_coitem_id, cobill_cobmisc_id, cobill_selectdate, cobill_select_username, cobill_qty, cobill_toclose, cobill_taxtype_id) VALUES (_cobillid, _r.coitem_id, _r.cobmisc_id, CURRENT_DATE, getEffectiveXtUser(), pQty, pClose, ptaxtypeid); END IF; RETURN _cobillid; END; $_$; ALTER FUNCTION public.selectforbilling(integer, numeric, boolean, integer) OWNER TO admin; -- -- Name: selectpayment(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION selectpayment(papopenid integer, pbankaccntid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _p RECORD; _amount NUMERIC; _discount NUMERIC; BEGIN SELECT apopen_amount, apopen_paid, apopen_doctype, apopen_docdate, apopen_curr_id, apopen_amount - apopen_paid - apCheckPending(apopen_id) AS balance, noNeg(COALESCE(apopen_discountable_amount, 0) * CASE WHEN (CURRENT_DATE <= determineDiscountDate(apopen_terms_id, apopen_docdate)) THEN terms_discprcnt ELSE 0.0 END - discount_applied) AS discount_available INTO _p FROM apopen LEFT OUTER JOIN terms ON (apopen_terms_id=terms_id), (SELECT COALESCE(SUM(apapply_amount),0) AS discount_applied FROM apapply, apopen WHERE((apapply_target_apopen_id=pApopenid) AND (apapply_source_apopen_id=apopen_id) AND (apopen_discount)) ) AS data WHERE(apopen_id=pApopenid); IF(NOT FOUND OR (NOT _p.apopen_doctype IN ('V','D','C'))) THEN RAISE EXCEPTION 'Apopen not found or invalid document type [xtuple: selectPayment, -1]'; END IF; _discount := round(_p.discount_available, 2); _amount := noNeg(round(_p.balance, 2) - _discount); RETURN selectPayment(pApopenid, pBankaccntid, _p.apopen_docdate, _p.apopen_curr_id, _amount, _discount); END; $$; ALTER FUNCTION public.selectpayment(papopenid integer, pbankaccntid integer) OWNER TO admin; -- -- Name: selectpayment(integer, integer, date, integer, numeric, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION selectpayment(papopenid integer, pbankaccntid integer, pdocdate date, pcurrid integer, pamount numeric, pdiscount numeric) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _p RECORD; _bankcompany TEXT; _distcompany TEXT; _apselectid INTEGER; _amount NUMERIC; _discount NUMERIC; BEGIN SELECT apopen_amount, apopen_paid, apopen_doctype, apopen_docdate, apopen_docnumber, apopen_curr_id, apopen_amount - apopen_paid - apCheckPending(apopen_id) AS balance INTO _p FROM apopen WHERE(apopen_id=pApopenid); IF(NOT FOUND OR (NOT _p.apopen_doctype IN ('V','D','C'))) THEN RAISE EXCEPTION 'Apopen not found or invalid document type [xtuple: selectPayment, -1]'; END IF; IF (round(_p.balance,2) < (pDiscount + pAmount)) THEN RAISE EXCEPTION 'Apopen balance less than amount plus discount [xtuple: selectPayment, -2]'; END IF; IF (_p.apopen_doctype = 'V') THEN SELECT COALESCE(accnt_company, '') INTO _bankcompany FROM bankaccnt JOIN accnt ON (accnt_id=bankaccnt_accnt_id) WHERE (bankaccnt_id=pBankaccntid); SELECT COALESCE(accnt_company, '') INTO _distcompany FROM vohead JOIN vodist ON (vodist_vohead_id=vohead_id) JOIN accnt ON (accnt_id=vodist_accnt_id) WHERE (vohead_number=_p.apopen_docnumber) AND (COALESCE(accnt_company, '') != _bankcompany); IF (FOUND) THEN RAISE EXCEPTION 'Bank account company does not match Voucher distribution company [xtuple: selectPayment, -3]'; END IF; SELECT COALESCE(accnt_company, '') INTO _distcompany FROM vohead JOIN vodist ON (vodist_vohead_id=vohead_id) JOIN expcat ON (expcat_id=vodist_expcat_id) JOIN accnt ON (accnt_id=expcat_exp_accnt_id) WHERE (vohead_number=_p.apopen_docnumber) AND (COALESCE(accnt_company, '') != _bankcompany); IF (FOUND) THEN RAISE EXCEPTION 'Bank account company does not match Voucher distribution company [xtuple: selectPayment, -3]'; END IF; END IF; IF (pAmount > 0.0) THEN SELECT apselect_id INTO _apselectid FROM apselect WHERE (apselect_apopen_id=pApopenid); IF (FOUND) THEN UPDATE apselect SET apselect_amount=pAmount, apselect_discount=pDiscount, apselect_curr_id=pCurrid WHERE(apselect_id=_apselectid); ELSE INSERT INTO apselect ( apselect_apopen_id, apselect_amount, apselect_discount, apselect_bankaccnt_id, apselect_curr_id, apselect_date ) VALUES ( pApopenid, pAmount, pDiscount, pBankaccntid, pCurrid, pDocdate ) RETURNING apselect_id INTO _apselectid; END IF; ELSE _apselectid := 0; END IF; RETURN _apselectid; END; $$; ALTER FUNCTION public.selectpayment(papopenid integer, pbankaccntid integer, pdocdate date, pcurrid integer, pamount numeric, pdiscount numeric) OWNER TO admin; -- -- Name: selectuninvoicedshipment(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION selectuninvoicedshipment(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipheadid ALIAS FOR $1; _cobmiscid INTEGER; _coheadid INTEGER; _r RECORD; _cobillid INTEGER; BEGIN -- make a cobmisc head if it doesn't already exist for this cohead SELECT shiphead_order_id, createBillingHeader(shiphead_order_id) INTO _coheadid, _cobmiscid FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id) WHERE (shiphead_shipped AND NOT shipitem_invoiced AND (shiphead_id=pShipheadid)); -- Grab all of the uninvoiced shipitem records FOR _r IN SELECT cohead_id, coitem_id, SUM(shipitem_qty) AS qty, coitem_price, coitem_price_invuomratio AS invpricerat, coitem_qty_invuomratio, item_id, ( ((coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) <= 0) OR (NOT cust_partialship) ) AS toclose, coitem_taxtype_id FROM shiphead, shipitem, coitem, cohead, custinfo, itemsite, item WHERE ( (shipitem_shiphead_id=shiphead_id) AND (shipitem_orderitem_id=coitem_id) AND (coitem_cohead_id=cohead_id) AND (shiphead_shipped) AND (NOT shipitem_invoiced) AND (coitem_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (cohead_cust_id=cust_id) AND (item_type != 'K') AND (cohead_id=_coheadid) AND (shiphead_id=pShipheadid) ) GROUP BY cohead_id, coitem_id, cust_partialship, coitem_taxtype_id, coitem_qtyord, coitem_qtyshipped, coitem_qtyreturned, coitem_price, invpricerat, coitem_qty_invuomratio, item_id UNION SELECT cohead_id, coitem_id, coitem_qtyord AS qty, coitem_price, coitem_price_invuomratio AS invpricerat, coitem_qty_invuomratio, item_id, true AS toclose, coitem_taxtype_id FROM shiphead, cohead, custinfo, itemsite, item, coitem AS kit WHERE((shiphead_order_id=cohead_id) AND (coitem_cohead_id=cohead_id) AND (coitem_status='O') AND (shiphead_shipped) AND (coitem_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (cohead_cust_id=cust_id) AND (item_type = 'K') AND (cohead_id=_coheadid) AND (shiphead_id=pShipheadid) AND (coitem_linenumber NOT IN (SELECT sub.coitem_linenumber FROM coitem AS sub WHERE sub.coitem_cohead_id=cohead_id -- cohead for kit AND sub.coitem_linenumber=kit.coitem_linenumber AND sub.coitem_subnumber > 0 AND ((sub.coitem_qtyord - sub.coitem_qtyshipped + sub.coitem_qtyreturned) > 0) LIMIT 1) )) GROUP BY cohead_id, coitem_id, cust_partialship, coitem_taxtype_id, coitem_qtyord, coitem_qtyshipped, coitem_qtyreturned, coitem_price, invpricerat, coitem_qty_invuomratio, item_id, coitem_linenumber LOOP SELECT cobill_id INTO _cobillid FROM cobill, cobmisc, coitem WHERE ((cobill_cobmisc_id=cobmisc_id) AND (cobmisc_cohead_id=coitem_cohead_id) AND (cobill_coitem_id=coitem_id) AND (NOT cobmisc_posted) AND (cobill_cobmisc_id=_cobmiscid) AND (coitem_id=_r.coitem_id)) LIMIT 1; IF (FOUND) THEN UPDATE cobill SET cobill_selectdate = CURRENT_DATE, cobill_select_username = getEffectiveXtUser(), cobill_qty = cobill_qty + _r.qty, cobill_toclose = _r.toclose, cobill_taxtype_id = _r.coitem_taxtype_id WHERE (cobill_id=_cobillid); ELSE -- Now insert the cobill line INSERT INTO cobill ( cobill_cobmisc_id, cobill_coitem_id, cobill_selectdate, cobill_select_username, cobill_qty, cobill_toclose, cobill_taxtype_id ) VALUES ( _cobmiscid, _r.coitem_id, CURRENT_DATE, getEffectiveXtUser(), _r.qty, _r.toclose, _r.coitem_taxtype_id ); END IF; END LOOP; RETURN _cobmiscid; END; $_$; ALTER FUNCTION public.selectuninvoicedshipment(integer) OWNER TO admin; -- -- Name: selectuninvoicedshipments(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION selectuninvoicedshipments(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; _r RECORD; _recordCounter INTEGER := 0; BEGIN -- Grab all of the uninvoiced shipitem records FOR _r IN SELECT DISTINCT shiphead_id FROM shiphead, shipitem, coitem, itemsite WHERE ( (shiphead_order_type='SO') AND (shipitem_shiphead_id=shiphead_id) AND (shipitem_orderitem_id=coitem_id) AND (coitem_itemsite_id=itemsite_id) AND (coitem_status <> 'C') AND ( (pWarehousid = -1) OR (itemsite_warehous_id=pWarehousid) ) AND (shiphead_shipped) AND (NOT shipitem_invoiced) AND (coitem_id NOT IN ( SELECT cobill_coitem_id FROM cobmisc, cobill WHERE ((cobill_cobmisc_id=cobmisc_id) AND (NOT cobmisc_posted) ) ) ) ) LOOP PERFORM selectUninvoicedShipment(_r.shiphead_id); _recordCounter := _recordCounter + 1; END LOOP; RETURN _recordCounter; END; $_$; ALTER FUNCTION public.selectuninvoicedshipments(integer) OWNER TO admin; -- -- Name: selectuninvoicedshipments(integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION selectuninvoicedshipments(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pCusttype ALIAS FOR $2; _r RECORD; _recordCounter INTEGER := 0; BEGIN -- Grab all of the uninvoiced shipitem records FOR _r IN SELECT DISTINCT shiphead_id FROM shiphead, shipitem, coitem, itemsite, cohead, custinfo, custtype WHERE ( (shiphead_order_type='SO') AND (shipitem_shiphead_id=shiphead_id) AND (shipitem_orderitem_id=coitem_id) AND (coitem_itemsite_id=itemsite_id) AND (coitem_status <> 'C') AND (coitem_cohead_id=cohead_id) AND (cohead_cust_id=cust_id) AND (cust_custtype_id=custtype_id) AND ( (pWarehousid = -1) OR (itemsite_warehous_id=pWarehousid) ) AND (custtype_code ~ pCusttype) AND (shiphead_shipped) AND (NOT shipitem_invoiced) AND (coitem_id NOT IN ( SELECT cobill_coitem_id FROM cobmisc, cobill WHERE ((cobill_cobmisc_id=cobmisc_id) AND (NOT cobmisc_posted) ) ) ) ) LOOP PERFORM selectUninvoicedShipment(_r.shiphead_id); _recordCounter := _recordCounter + 1; END LOOP; RETURN _recordCounter; END; $_$; ALTER FUNCTION public.selectuninvoicedshipments(integer, text) OWNER TO admin; -- -- Name: selectuninvoicedshipments(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION selectuninvoicedshipments(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pCusttypeid ALIAS FOR $2; _r RECORD; _recordCounter INTEGER := 0; BEGIN -- Grab all of the uninvoiced shipitem records FOR _r IN SELECT DISTINCT shiphead_id FROM shiphead, shipitem, coitem, itemsite, cohead, custinfo WHERE ( (shiphead_order_type='SO') AND (shipitem_shiphead_id=shiphead_id) AND (shipitem_orderitem_id=coitem_id) AND (coitem_itemsite_id=itemsite_id) AND (coitem_status <> 'C') AND (coitem_cohead_id=cohead_id) AND (cohead_cust_id=cust_id) AND (cust_custtype_id=pCusttypeid) AND ( (pWarehousid = -1) OR (itemsite_warehous_id=pWarehousid) ) AND (shiphead_shipped) AND (NOT shipitem_invoiced) AND (coitem_id NOT IN ( SELECT cobill_coitem_id FROM cobmisc, cobill WHERE ((cobill_cobmisc_id=cobmisc_id) AND (NOT cobmisc_posted) ) ) ) ) LOOP PERFORM selectUninvoicedShipment(_r.shiphead_id); _recordCounter := _recordCounter + 1; END LOOP; RETURN _recordCounter; END; $_$; ALTER FUNCTION public.selectuninvoicedshipments(integer, integer) OWNER TO admin; -- -- Name: setapjournalnumber(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setapjournalnumber() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _journalNumber INTEGER; _r RECORD; BEGIN -- Fetch the next Journal Number SELECT fetchJournalNumber('A/P') INTO _journalNumber; -- Walk through all of the A/P Open Items FOR _r IN SELECT apopen_id, apopen_docnumber FROM apopen WHERE (NOT apopen_posted) LOOP -- Set the Journal Number for all of the G/L Transactions -- for the A/P Open Item UPDATE gltrans SET gltrans_journalnumber=_journalNumber WHERE ( (gltrans_source='P/O') AND (gltrans_doctype IN ('VO')) AND (gltrans_docnumber=_r.apopen_docnumber) AND (NOT gltrans_exported) ); -- Set the Journal Number for the A/P Open Item UPDATE apopen SET apopen_journalnumber=_journalNumber WHERE (apopen_id=_r.apopen_id); END LOOP; RETURN _journalNumber; END; $$; ALTER FUNCTION public.setapjournalnumber() OWNER TO admin; -- -- Name: setarjournalnumber(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setarjournalnumber() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _journalNumber INTEGER; _r RECORD; BEGIN -- Fetch the next Journal Number SELECT fetchJournalNumber('A/R') INTO _journalNumber; -- Walk through all of the A/R Open Items FOR _r IN SELECT aropen_id, aropen_docnumber FROM aropen WHERE (NOT aropen_posted) LOOP -- Set the Journal Number for all of the G/L Transactions -- for the A/R Open Item UPDATE gltrans SET gltrans_journalnumber=_journalNumber WHERE ( (gltrans_source='S/O') AND (gltrans_doctype IN ('CM', 'IN')) AND (gltrans_docnumber=_r.aropen_docnumber) AND (NOT gltrans_exported) ); -- Set the Journal Number for the A/R Open Item UPDATE aropen SET aropen_journalnumber=_journalNumber WHERE (aropen_id=_r.aropen_id); END LOOP; RETURN _journalNumber; END; $$; ALTER FUNCTION public.setarjournalnumber() OWNER TO admin; -- -- Name: setbudget(integer, integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setbudget(integer, integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodid ALIAS FOR $1; pAccntid ALIAS FOR $2; pAmount ALIAS FOR $3; BEGIN RETURN setBudget(1, pPeriodid, pAccntid, pAmount); END; $_$; ALTER FUNCTION public.setbudget(integer, integer, numeric) OWNER TO admin; -- -- Name: setbudget(integer, integer, integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setbudget(integer, integer, integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBudgheadid ALIAS FOR $1; pPeriodid ALIAS FOR $2; pAccntid ALIAS FOR $3; pAmount ALIAS FOR $4; _budgetid INTEGER; BEGIN SELECT budgitem_id INTO _budgetid FROM budgitem WHERE ((budgitem_period_id=pPeriodid) AND (budgitem_budghead_id=pBudgheadid) AND (budgitem_accnt_id=pAccntid)); IF (FOUND) THEN UPDATE budgitem SET budgitem_amount = pAmount WHERE (budgitem_id=_budgetid); ELSE SELECT nextval('budgitem_budgitem_id_seq') INTO _budgetid; INSERT INTO budgitem (budgitem_id, budgitem_budghead_id, budgitem_period_id, budgitem_accnt_id, budgitem_amount) VALUES(_budgetid, pBudgheadid, pPeriodid, pAccntid, pAmount); END IF; RETURN _budgetid; END; $_$; ALTER FUNCTION public.setbudget(integer, integer, integer, numeric) OWNER TO admin; -- -- Name: setbytea(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setbytea(text) RETURNS bytea LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pMetricName ALIAS FOR $1; _value bytea; BEGIN _value := decode(pMetricName, 'escape'); RETURN _value; END; $_$; ALTER FUNCTION public.setbytea(text) OWNER TO admin; -- -- Name: setbytea(bytea); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setbytea(bytea) RETURNS bytea LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pMetricName ALIAS FOR $1; _value bytea; BEGIN _value := pMetricName; RETURN _value; END; $_$; ALTER FUNCTION public.setbytea(bytea) OWNER TO admin; -- -- Name: setccbankaccnt(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setccbankaccnt(text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pccardtype ALIAS FOR $1; pbankaccntid ALIAS FOR $2; _ccbankid INTEGER; _numfound INTEGER; BEGIN RAISE DEBUG 'setCCBankAccount(%, %) entered', pccardtype, pbankaccntid; UPDATE ccbank SET ccbank_bankaccnt_id=pbankaccntid WHERE ccbank_ccard_type=pccardtype RETURNING ccbank_id INTO _ccbankid; GET DIAGNOSTICS _numfound = ROW_COUNT; IF (_numfound <= 0) THEN INSERT INTO ccbank (ccbank_ccard_type, ccbank_bankaccnt_id) VALUES (pccardtype, pbankaccntid) RETURNING ccbank_id INTO _ccbankid; END IF; RETURN _ccbankid; END; $_$; ALTER FUNCTION public.setccbankaccnt(text, integer) OWNER TO admin; -- -- Name: seteffectivextuser(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION seteffectivextuser(text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; BEGIN PERFORM initEffectiveXtUser(); PERFORM * FROM effective_user WHERE effective_key = 'username'; IF FOUND THEN UPDATE effective_user SET effective_value = pUsername WHERE effective_key = 'username'; ELSE INSERT INTO effective_user (effective_key, effective_value) VALUES('username', pUsername); END IF; RETURN true; END; $_$; ALTER FUNCTION public.seteffectivextuser(text) OWNER TO admin; -- -- Name: setgljournalnumber(date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setgljournalnumber(date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pStartDate ALIAS FOR $1; pEndDate ALIAS FOR $2; _journalNumber INTEGER; BEGIN -- Fetch the next Journal Number SELECT fetchJournalNumber('G/L') INTO _journalNumber; -- Set the Journal Number for all of the unposted G/L Transactions -- in the passed date range. UPDATE gltrans SET gltrans_journalnumber=_journalNumber WHERE ( (NOT gltrans_exported) AND (gltrans_date BETWEEN pStartDate and pEndDate) ); RETURN _journalNumber; END; $_$; ALTER FUNCTION public.setgljournalnumber(date, date) OWNER TO admin; -- -- Name: setmetric(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setmetric(text, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pMetricName ALIAS FOR $1; pMetricValue ALIAS FOR $2; _metricid INTEGER; BEGIN SELECT metric_id INTO _metricid FROM metric WHERE (metric_name=pMetricName); IF (FOUND) THEN UPDATE metric SET metric_value=pMetricValue WHERE (metric_id=_metricid); ELSE INSERT INTO metric (metric_name, metric_value) VALUES (pMetricName, pMetricValue); END IF; RETURN TRUE; END; $_$; ALTER FUNCTION public.setmetric(text, text) OWNER TO admin; -- -- Name: setmetricenc(text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setmetricenc(text, text, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pMetricName ALIAS FOR $1; pMetricValue ALIAS FOR $2; pMetricEnc ALIAS FOR $3; _metricid INTEGER; _value bytea; _key bytea; BEGIN _value = decode(pMetricValue, 'escape'); _key = decode(pMetricEnc, 'escape'); SELECT metricenc_id INTO _metricid FROM metricenc WHERE (metricenc_name=pMetricName); IF (FOUND) THEN UPDATE metricenc SET metricenc_value=encrypt(_value, _key, 'bf') WHERE (metricenc_id=_metricid); ELSE INSERT INTO metricenc (metricenc_name, metricenc_value) VALUES (pMetricName, encrypt(_value, _key, 'bf')); END IF; RETURN TRUE; END; $_$; ALTER FUNCTION public.setmetricenc(text, text, text) OWNER TO admin; -- -- Name: setnextapmemonumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setnextapmemonumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='APMemoNumber'); IF (FOUND) THEN UPDATE orderseq SET orderseq_number=pNumber WHERE (orderseq_id=_orderseqid); ELSE INSERT INTO orderseq (orderseq_name, orderseq_number) VALUES ('APMemoNumber', pNumber); END IF; RETURN 1; END; $_$; ALTER FUNCTION public.setnextapmemonumber(integer) OWNER TO admin; -- -- Name: setnextarmemonumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setnextarmemonumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='ARMemoNumber'); IF (FOUND) THEN UPDATE orderseq SET orderseq_number=pNumber WHERE (orderseq_id=_orderseqid); ELSE INSERT INTO orderseq (orderseq_name, orderseq_number) VALUES ('ARMemoNumber', pNumber); END IF; RETURN 1; END; $_$; ALTER FUNCTION public.setnextarmemonumber(integer) OWNER TO admin; -- -- Name: setnextcashrcptnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setnextcashrcptnumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='CashRcptNumber'); IF (FOUND) THEN UPDATE orderseq SET orderseq_number=pNumber WHERE (orderseq_id=_orderseqid); ELSE INSERT INTO orderseq (orderseq_name, orderseq_number) VALUES ('CashRcptNumber', pNumber); END IF; RETURN 1; END; $_$; ALTER FUNCTION public.setnextcashrcptnumber(integer) OWNER TO admin; -- -- Name: setnextchecknumber(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setnextchecknumber(pbankaccntid integer, pnextchecknumber integer) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _nextChkNumber INTEGER; _checkheadid INTEGER; BEGIN _nextChkNumber := pNextCheckNumber; WHILE (TRUE) LOOP SELECT checkhead_id INTO _checkheadid FROM checkhead WHERE (checkhead_number=_nextChkNumber) AND (checkhead_bankaccnt_id=pBankaccntid); IF (NOT FOUND) THEN EXIT; ELSE _nextChkNumber := _nextChkNumber + 1; END IF; END LOOP; UPDATE bankaccnt SET bankaccnt_nextchknum=_nextChkNumber WHERE (bankaccnt_id=pBankaccntid); RETURN TRUE; END; $$; ALTER FUNCTION public.setnextchecknumber(pbankaccntid integer, pnextchecknumber integer) OWNER TO admin; -- -- Name: setnextcmnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setnextcmnumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='CmNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'CmNumber', pNumber); ELSE UPDATE orderseq SET orderseq_number=pNumber WHERE (orderseq_name='CmNumber'); END IF; RETURN _orderseqid; END; $_$; ALTER FUNCTION public.setnextcmnumber(integer) OWNER TO admin; -- -- Name: setnextcrmaccountnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setnextcrmaccountnumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='CRMAccountNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'CRMAccountNumber', pNumber); ELSE UPDATE orderseq SET orderseq_number=pNumber WHERE (orderseq_name='CRMAccountNumber'); END IF; RETURN _orderseqid; END; $_$; ALTER FUNCTION public.setnextcrmaccountnumber(integer) OWNER TO admin; -- -- Name: setnextincidentnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setnextincidentnumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='IncidentNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'IncidentNumber', pNumber); ELSE UPDATE orderseq SET orderseq_number=pNumber WHERE (orderseq_name='IncidentNumber'); END IF; RETURN _orderseqid; END; $_$; ALTER FUNCTION public.setnextincidentnumber(integer) OWNER TO admin; -- -- Name: setnextinvcnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setnextinvcnumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='InvcNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'InvcNumber', pNumber); ELSE UPDATE orderseq SET orderseq_number=pNumber WHERE (orderseq_name='InvcNumber'); END IF; RETURN _orderseqid; END; $_$; ALTER FUNCTION public.setnextinvcnumber(integer) OWNER TO admin; -- -- Name: setnextnumber(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setnextnumber(text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE psequence ALIAS FOR $1; pnumber ALIAS FOR $2; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name=psequence); IF (NOT FOUND) THEN INSERT INTO orderseq (orderseq_name, orderseq_number, orderseq_table, orderseq_numcol) VALUES (psequence, pnumber, CASE WHEN (psequence='APMemoNumber') THEN 'apopen' WHEN (psequence='ARMemoNumber') THEN 'aropen' WHEN (psequence='CmNumber') THEN 'cmhead' WHEN (psequence='IncidentNumber') THEN 'incdt' WHEN (psequence='InvcNumber') THEN 'invchead' WHEN (psequence='JournalNumber') THEN 'gltrans' WHEN (psequence='PlanNumber') THEN 'planord' WHEN (psequence='PoNumber') THEN 'pohead' WHEN (psequence='PrNumber') THEN 'pr' WHEN (psequence='QuNumber') THEN 'quhead' WHEN (psequence='ShipmentNumber') THEN 'shiphead' WHEN (psequence='SoNumber') THEN 'cohead' WHEN (psequence='ToNumber') THEN 'tohead' WHEN (psequence='VcNumber') THEN 'vohead' WHEN (psequence='WoNumber') THEN 'wo' ELSE '' END, CASE WHEN (psequence='APMemoNumber') THEN 'apopen_docnumber' WHEN (psequence='ARMemoNumber') THEN 'aropen_docnumber' WHEN (psequence='CmNumber') THEN 'cmhead_number' WHEN (psequence='IncidentNumber') THEN 'incdt_number' WHEN (psequence='InvcNumber') THEN 'invchead_invcnumber' WHEN (psequence='JournalNumber') THEN 'gltrans_journalnumber' WHEN (psequence='PlanNumber') THEN 'planord_number' WHEN (psequence='PoNumber') THEN 'pohead_number' WHEN (psequence='PrNumber') THEN 'pr_number' WHEN (psequence='QuNumber') THEN 'quhead_number' WHEN (psequence='ShipmentNumber') THEN 'shiphead_number' WHEN (psequence='SoNumber') THEN 'cohead_number' WHEN (psequence='ToNumber') THEN 'tohead_number' WHEN (psequence='VcNumber') THEN 'vohead_number' WHEN (psequence='WoNumber') THEN 'wo_number' ELSE '' END ); ELSE UPDATE orderseq SET orderseq_number=pnumber WHERE (orderseq_name=psequence); END IF; RETURN 0; END; $_$; ALTER FUNCTION public.setnextnumber(text, integer) OWNER TO admin; -- -- Name: setnextponumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setnextponumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='PoNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'PoNumber', pNumber); ELSE UPDATE orderseq SET orderseq_number=pNumber WHERE (orderseq_name='PoNumber'); END IF; RETURN _orderseqid; END; $_$; ALTER FUNCTION public.setnextponumber(integer) OWNER TO admin; -- -- Name: setnextprnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setnextprnumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='PrNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'PrNumber', pNumber); ELSE UPDATE orderseq SET orderseq_number=pNumber WHERE (orderseq_name='PrNumber'); END IF; RETURN _orderseqid; END; $_$; ALTER FUNCTION public.setnextprnumber(integer) OWNER TO admin; -- -- Name: setnextqunumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setnextqunumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='QuNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'QuNumber', pQuNumber); ELSE UPDATE orderseq SET orderseq_number=pQuNumber WHERE (orderseq_name='QuNumber'); END IF; RETURN _orderseqid; END; $_$; ALTER FUNCTION public.setnextqunumber(integer) OWNER TO admin; -- -- Name: setnextshipmentnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setnextshipmentnumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipmentNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='ShipmentNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'ShipmentNumber', pShipmentNumber); ELSE UPDATE orderseq SET orderseq_number=pShipmentNumber WHERE (orderseq_name='ShipmentNumber'); END IF; RETURN _orderseqid; END; $_$; ALTER FUNCTION public.setnextshipmentnumber(integer) OWNER TO admin; -- -- Name: setnextsonumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setnextsonumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='SoNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'SoNumber', pSoNumber); ELSE UPDATE orderseq SET orderseq_number=pSoNumber WHERE (orderseq_name='SoNumber'); END IF; RETURN _orderseqid; END; $_$; ALTER FUNCTION public.setnextsonumber(integer) OWNER TO admin; -- -- Name: setnextvcnumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setnextvcnumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='VcNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'VcNumber', pNumber); ELSE UPDATE orderseq SET orderseq_number=pNumber WHERE (orderseq_name='VcNumber'); END IF; RETURN _orderseqid; END; $_$; ALTER FUNCTION public.setnextvcnumber(integer) OWNER TO admin; -- -- Name: setnextwonumber(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setnextwonumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='WoNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'WoNumber', pWoNumber); ELSE UPDATE orderseq SET orderseq_number=pWoNumber WHERE (orderseq_name='WoNumber'); END IF; RETURN _orderseqid; END; $_$; ALTER FUNCTION public.setnextwonumber(integer) OWNER TO admin; -- -- Name: setusercancreateusers(text, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setusercancreateusers(pusername text, pcreateuser boolean) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pCreateUser) THEN EXECUTE 'ALTER USER "' || pUsername || '" CREATEROLE;'; ELSE EXECUTE 'ALTER USER "' || pUsername || '" NOCREATEROLE;'; END IF; RETURN TRUE; END; $$; ALTER FUNCTION public.setusercancreateusers(pusername text, pcreateuser boolean) OWNER TO admin; -- -- Name: setuserpreference(text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setuserpreference(text, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrefName ALIAS FOR $1; pPrefValue ALIAS FOR $2; BEGIN RETURN setUserPreferences(getEffectiveXtUser(), pPrefName, pPrefValue); END; $_$; ALTER FUNCTION public.setuserpreference(text, text) OWNER TO admin; -- -- Name: setuserpreference(text, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION setuserpreference(text, text, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pPrefName ALIAS FOR $2; pPrefValue ALIAS FOR $3; _usrprefid INTEGER; BEGIN SELECT usrpref_id INTO _usrprefid FROM usrpref WHERE ( (usrpref_username=pUsername) AND (usrpref_name=pPrefName) ); IF (FOUND) THEN UPDATE usrpref SET usrpref_value=pPrefValue WHERE (usrpref_id=_usrprefid); ELSE INSERT INTO usrpref (usrpref_username, usrpref_name, usrpref_value) VALUES (pUsername, pPrefName, pPrefValue); END IF; RETURN TRUE; END; $_$; ALTER FUNCTION public.setuserpreference(text, text, text) OWNER TO admin; -- -- Name: shipments(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION shipments(text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTransType ALIAS FOR $1; BEGIN IF (pTransType IN ('SC', 'SV', 'SH', 'RS', 'TS')) THEN RETURN TRUE; ELSE RETURN FALSE; END IF; END; $_$; ALTER FUNCTION public.shipments(text) OWNER TO admin; -- -- Name: shipshipment(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION shipshipment(integer) RETURNS integer LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT shipShipment($1, CURRENT_TIMESTAMP); $_$; ALTER FUNCTION public.shipshipment(integer) OWNER TO admin; -- -- Name: shipshipment(integer, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION shipshipment(integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pshipheadid ALIAS FOR $1; _timestamp TIMESTAMP WITH TIME ZONE := $2; _billedQty NUMERIC; _c RECORD; _coholdtype TEXT; _gldate DATE; _invhistid INTEGER; _itemlocSeries INTEGER; _lineitemsToClose INTEGER[]; _newQty NUMERIC; _result INTEGER; _s RECORD; _shipcomplete BOOLEAN; _shiphead RECORD; _ti RECORD; _to RECORD; _variance NUMERIC; _k RECORD; BEGIN IF (_timestamp IS NULL) THEN _timestamp := CURRENT_TIMESTAMP; END IF; _gldate := _timestamp::DATE; SELECT * INTO _shiphead FROM shiphead WHERE (shiphead_id=pshipheadid); IF (NOT FOUND) THEN RETURN -50; END IF; IF (_shiphead.shiphead_order_type = 'SO') THEN SELECT cohead_shipcomplete, cohead_holdtype INTO _shipcomplete, _coholdtype FROM cohead, shiphead WHERE ((shiphead_order_id=cohead_id) AND (NOT shiphead_shipped) AND (shiphead_order_type=_shiphead.shiphead_order_type) AND (shiphead_id=pshipheadid)); IF (_coholdtype = 'C') THEN RETURN -12; ELSIF (_coholdtype = 'P') THEN RETURN -13; ELSIF (_coholdtype = 'R') THEN RETURN -14; ELSIF (_coholdtype = 'S') THEN RETURN -15; END IF; ---Must Ship Kit components (coitem_subnumber <> 0 complete--------------- IF (( -- Test to see if order's customer accepts backorders and partials -- If not then test for shipping kit components complete SELECT cohead_number FROM shiphead, cohead, custinfo WHERE (shiphead_order_id = cohead_id) AND (cohead_cust_id = cust_id) AND (shiphead_order_type = 'SO') AND (cust_partialship) AND (cust_backorder) AND (shiphead_id = pshipheadid) ) IS NULL) THEN FOR _k IN SELECT (coitem_qtyord - (COALESCE(SUM(shipitem_qty),0) + (coitem_qtyshipped - coitem_qtyreturned))) AS remain FROM (coitem LEFT OUTER JOIN (itemsite JOIN item ON (itemsite_item_id=item_id)) ON (coitem_itemsite_id=itemsite_id)) LEFT OUTER JOIN shipitem ON (shipitem_orderitem_id=coitem_id AND shipitem_shiphead_id=pshipheadid) WHERE ((coitem_status NOT IN ('C','X')) AND (item_type != 'K') AND (coitem_cohead_id=_shiphead.shiphead_order_id) AND (coitem_subnumber <> 0) ) GROUP BY coitem_id, coitem_qtyshipped, coitem_qtyord, coitem_qtyreturned LOOP IF (_k.remain > 0) THEN RAISE EXCEPTION 'Kit component item not shipped complete. Kits must be shipped and shipped complete or closed on the order.'; END IF; END LOOP; END IF; ---End-------------------------------------------------------------------- IF ( _shipcomplete ) THEN FOR _c IN SELECT (coitem_qtyord - (COALESCE(SUM(shipitem_qty),0) + (coitem_qtyshipped - coitem_qtyreturned))) AS remain FROM (coitem LEFT OUTER JOIN (itemsite JOIN item ON (itemsite_item_id=item_id)) ON (coitem_itemsite_id=itemsite_id)) LEFT OUTER JOIN shipitem ON (shipitem_orderitem_id=coitem_id AND shipitem_shiphead_id=pshipheadid) WHERE ((coitem_status<>'X') AND (item_type != 'K') AND (coitem_cohead_id=_shiphead.shiphead_order_id)) GROUP BY coitem_id, coitem_qtyshipped, coitem_qtyord, coitem_qtyreturned LOOP IF (_c.remain > 0) THEN RETURN -99; END IF; END LOOP; END IF; FOR _c IN SELECT coitem_id, cohead_number, cohead_cust_id, cohead_billtoname, cohead_prj_id, cohead_saletype_id, cohead_shipzone_id, itemsite_id, itemsite_item_id, coitem_qty_invuomratio, coitem_warranty, coitem_cos_accnt_id, SUM(shipitem_qty) AS _qty, SUM(shipitem_value) AS _value FROM coitem, cohead, shiphead, shipitem, itemsite WHERE ( (coitem_cohead_id=cohead_id) AND (coitem_itemsite_id=itemsite_id) AND (shiphead_order_id=cohead_id) AND (shipitem_shiphead_id=shiphead_id) AND (shipitem_orderitem_id=coitem_id) AND (NOT shiphead_shipped) AND (shiphead_id=pshipheadid) ) GROUP BY coitem_id, coitem_qty_invuomratio, cohead_number, cohead_cust_id, cohead_billtoname, itemsite_id, itemsite_item_id, coitem_warranty, coitem_cos_accnt_id, cohead_prj_id, cohead_saletype_id, cohead_shipzone_id LOOP IF _c._value > 0 THEN -- Distribute to G/L, credit Shipping Asset, debit COS SELECT MIN(insertGLTransaction( 'S/R', 'SH', _shiphead.shiphead_number, ('Ship Order ' || _c.cohead_number || ' for Customer ' || _c.cohead_billtoname), getPrjAccntId(_c.cohead_prj_id, costcat_shipasset_accnt_id), CASE WHEN (COALESCE(_c.coitem_cos_accnt_id, -1) != -1) THEN getPrjAccntId(_c.cohead_prj_id, _c.coitem_cos_accnt_id) WHEN (_c.coitem_warranty=TRUE) THEN getPrjAccntId(_c.cohead_prj_id, resolveCOWAccount(itemsite_id, _c.cohead_cust_id, _c.cohead_saletype_id, _c.cohead_shipzone_id)) ELSE getPrjAccntId(_c.cohead_prj_id, resolveCOSAccount(itemsite_id, _c.cohead_cust_id, _c.cohead_saletype_id, _c.cohead_shipzone_id)) END, -1, _c._value, _gldate )) INTO _result FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_c.itemsite_id) ); IF (_result < 0 AND _result != -3) THEN -- ignore -3 as it just means it's not posting a 0 value RETURN _result; END IF; END IF; UPDATE coitem SET coitem_qtyshipped = (coitem_qtyshipped + _c._qty) WHERE (coitem_id=_c.coitem_id); -- check to see if we have more invoiced than shipped items -- if we do we will need to mark some of these records as invoiced SELECT noNeg(( SELECT COALESCE(SUM(cobill_qty), 0.0) FROM cobill, cobmisc, coitem WHERE ( (cobill_cobmisc_id=cobmisc_id) AND (cobmisc_cohead_id=coitem_cohead_id) AND (cobill_coitem_id=coitem_id) AND (cobmisc_posted) AND (coitem_id=_c.coitem_id) ) ) - ( SELECT COALESCE(SUM(shipitem_qty), 0.0) FROM shipitem, shiphead, coitem WHERE ( (shipitem_shiphead_id=shiphead_id) AND (shiphead_order_id=coitem_cohead_id) AND (shipitem_orderitem_id=coitem_id) AND (shiphead_order_type=_shiphead.shiphead_order_type) AND (shiphead_shipped) AND (coitem_id=_c.coitem_id) ) ) ) INTO _billedQty; IF (_billedQty > 0.0) THEN FOR _s IN SELECT shipitem_id, shipitem_qty FROM shipitem, shiphead WHERE ( (shipitem_shiphead_id=shiphead_id) AND (shipitem_orderitem_id=_c.coitem_id) AND (shiphead_order_type=_shiphead.shiphead_order_type) AND (NOT shiphead_shipped) AND (shiphead_id=pshipheadid) ) ORDER BY shipitem_qty LOOP IF (_billedQty > 0.0) THEN IF (_billedQty >= _s.shipitem_qty) THEN UPDATE shipitem SET shipitem_invoiced=TRUE WHERE shipitem_id=_s.shipitem_id; -- must wait to close coitems until after shiphead_shipped -> true _lineitemsToClose := _lineitemsToClose || _c.coitem_id; ELSE _newQty := _s.shipitem_qty - _billedQty; UPDATE shipitem SET shipitem_invoiced=TRUE, shipitem_qty=_billedQty WHERE shipitem_id=_s.shipitem_id; INSERT INTO shipitem ( shipitem_orderitem_id, shipitem_shipdate, shipitem_qty, shipitem_transdate, shipitem_invoiced, shipitem_shiphead_id, shipitem_trans_username) SELECT shipitem_orderitem_id, shipitem_shipdate, _newQty, shipitem_transdate, FALSE, shipitem_shiphead_id, shipitem_trans_username FROM shipitem WHERE (shipitem_id=_s.shipitem_id); END IF; _billedQty := _billedQty - _s.shipitem_qty; END IF; END LOOP; END IF; END LOOP; ELSEIF (_shiphead.shiphead_order_type = 'TO') THEN IF (_shiphead.shiphead_shipped) THEN RETURN -8; END IF; SELECT tohead.* INTO _to FROM tohead WHERE (tohead_id=_shiphead.shiphead_order_id); IF ( _to.tohead_shipcomplete ) THEN -- use sufficientInventory...()? FOR _ti IN SELECT (toitem_qty_ordered - (COALESCE(SUM(shipitem_qty),0) + toitem_qty_shipped)) AS remain FROM toitem LEFT OUTER JOIN shipitem ON (shipitem_orderitem_id=toitem_id) WHERE ((toitem_status<>'X') AND (toitem_tohead_id=_shiphead.shiphead_order_id)) GROUP BY toitem_qty_shipped, toitem_qty_ordered LOOP IF (_ti.remain > 0) THEN RETURN -99; END IF; END LOOP; END IF; FOR _ti IN SELECT toitem_id, toitem_item_id, SUM(shipitem_qty) AS qty, SUM(shipitem_value) AS value FROM toitem, shipitem WHERE ((toitem_tohead_id=_to.tohead_id) AND (shipitem_orderitem_id=toitem_id) AND (shipitem_shiphead_id=pshipheadid)) GROUP BY toitem_id, toitem_item_id LOOP IF (NOT EXISTS(SELECT itemsite_id FROM itemsite WHERE ((itemsite_item_id=_ti.toitem_item_id) AND (itemsite_warehous_id = _to.tohead_trns_warehous_id)) )) THEN RETURN -6; END IF; _itemlocSeries := NEXTVAL('itemloc_series_seq'); SELECT postInvTrans(si.itemsite_id, 'TS', _ti.qty, 'I/M', _shiphead.shiphead_order_type, formatToNumber(_ti.toitem_id), _to.tohead_number, 'Ship from Src to Transit Warehouse', tc.costcat_asset_accnt_id, sc.costcat_shipasset_accnt_id, _itemlocSeries, _timestamp, _ti.value) INTO _invhistid FROM itemsite AS ti, costcat AS tc, itemsite AS si, costcat AS sc WHERE ( (ti.itemsite_costcat_id=tc.costcat_id) AND (si.itemsite_costcat_id=sc.costcat_id) AND (ti.itemsite_item_id=_ti.toitem_item_id) AND (si.itemsite_item_id=_ti.toitem_item_id) AND (ti.itemsite_warehous_id=_to.tohead_trns_warehous_id) AND (si.itemsite_warehous_id=_to.tohead_src_warehous_id) ); --We do not need to distribute lot/serial info for transit, post trans and discard dist detail PERFORM postIntoTrialBalance(itemlocpost_glseq) FROM itemlocpost WHERE (itemlocpost_itemlocseries=_itemlocSeries); IF (_invhistid > 0) THEN PERFORM postInvHist(_invhistid); END IF; DELETE FROM itemlocdist WHERE (itemlocdist_series=_itemlocSeries); DELETE FROM itemlocpost WHERE (itemlocpost_itemlocSeries=_itemlocSeries); IF (_result < 0) THEN RETURN _result; END IF; -- record inventory history and qoh changes at transit warehouse but -- there is only one g/l account to touch SELECT postInvTrans(ti.itemsite_id, 'TR', _ti.qty, 'I/M', _shiphead.shiphead_order_type, formatToNumber(_ti.toitem_id), _to.tohead_number, 'Receive into Transit from Src Warehouse', tc.costcat_asset_accnt_id, tc.costcat_asset_accnt_id, _itemlocSeries, _timestamp, _ti.value) INTO _invhistid FROM itemsite AS ti, costcat AS tc WHERE ((ti.itemsite_costcat_id=tc.costcat_id) AND (ti.itemsite_item_id=_ti.toitem_item_id) AND (ti.itemsite_warehous_id=_to.tohead_trns_warehous_id)); --We do not need to distribute lot/serial info for transit, post trans and discard dist detail PERFORM postIntoTrialBalance(itemlocpost_glseq) FROM itemlocpost WHERE (itemlocpost_itemlocseries=_itemlocSeries); IF (_invhistid > 0) THEN PERFORM postInvHist(_invhistid); END IF; DELETE FROM itemlocdist WHERE (itemlocdist_series=_itemlocSeries); DELETE FROM itemlocpost WHERE (itemlocpost_itemlocSeries=_itemlocSeries); --See if there was a change in values during the transfer, if so record the variance SELECT (invhist_invqty * invhist_unitcost - _ti.value) INTO _variance FROM invhist WHERE (invhist_id=_invhistid); IF (_variance > 0) THEN PERFORM insertGLTransaction( 'S/R', _shiphead.shiphead_order_type, _to.tohead_number, 'Transfer Order - Transfer Variance', tc.costcat_invcost_accnt_id, tc.costcat_asset_accnt_id, _invhistid, _variance, CAST(_timestamp AS DATE) ) FROM itemsite AS ti, costcat AS tc WHERE ( (ti.itemsite_costcat_id=tc.costcat_id) AND (ti.itemsite_item_id=_ti.toitem_item_id) AND (ti.itemsite_warehous_id=_to.tohead_trns_warehous_id) ); END IF; IF (_result < 0) THEN RETURN _result; END IF; UPDATE shipitem SET shipitem_shipdate=_timestamp, shipitem_shipped=TRUE WHERE ((shipitem_orderitem_id=_ti.toitem_id) AND (shipitem_shiphead_id=pshipheadid)); UPDATE toitem SET toitem_qty_shipped = (toitem_qty_shipped + _ti.qty) WHERE (toitem_id=_ti.toitem_id); END LOOP; END IF; UPDATE shiphead SET shiphead_shipped=TRUE, shiphead_shipdate=_gldate WHERE (shiphead_id=pshipheadid); -- now try to close line items that are fully shipped and invoiced IF (_shiphead.shiphead_order_type = 'SO') THEN UPDATE coitem SET coitem_status='C' WHERE ((coitem_id = ANY (_lineitemsToClose)) AND (coitem_qtyshipped >= coitem_qtyord)); END IF; RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.shipshipment(integer, timestamp with time zone) OWNER TO admin; -- -- Name: show_search_path(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION show_search_path() RETURNS text LANGUAGE plpgsql AS $$ declare path text; rec record; begin -- This exists because show search_path command doesn't work in plv8 for rec in execute 'show search_path' loop return rec.search_path::text; end loop; end; $$; ALTER FUNCTION public.show_search_path() OWNER TO admin; -- -- Name: singlecharacteristicstostring(text, integer, text, text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION singlecharacteristicstostring(text, integer, text, text, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTargetType ALIAS FOR $1; pTargetId ALIAS FOR $2; pValKeySep ALIAS FOR $3; pPairSep ALIAS FOR $4; pCharId ALIAS FOR $5; _string TEXT := ''; _extra BOOLEAN := false; _r RECORD; BEGIN FOR _r IN SELECT char_name, charass_value FROM charass, char WHERE ((charass_char_id=char_id) AND (charass_char_id=pCharId) AND (charass_target_type=pTargetType) AND (charass_target_id=pTargetId)) LOOP IF(_extra) THEN _string := _string || pPairSep; END IF; _extra := true; _string := _string || _r.char_name || pValKeySep || _r.charass_value; END LOOP; RETURN _string; END; $_$; ALTER FUNCTION public.singlecharacteristicstostring(text, integer, text, text, integer) OWNER TO admin; -- -- Name: singlelevelbom(integer, integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION singlelevelbom(integer, integer, integer, integer) RETURNS SETOF bomdata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pRevisionid ALIAS FOR $2; pExpiredDays ALIAS FOR $3; pFutureDays ALIAS FOR $4; _row bomdata%ROWTYPE; _bomworksetid INTEGER; _x RECORD; _check CHAR(1); _inactive BOOLEAN; _batchsize NUMERIC; BEGIN _inactive := FALSE; IF (pRevisionid != -1) THEN --Is this a deactivated revision? SELECT rev_status INTO _check FROM rev WHERE ((rev_id=pRevisionid) AND (rev_status='I')); IF (FOUND) THEN _inactive := TRUE; END IF; END IF; -- Get the batch quantity SELECT COALESCE( ( SELECT bomhead_batchsize FROM bomhead WHERE ((bomhead_item_id=pItemId) AND (bomhead_rev_id=pRevisionid))),1) INTO _batchsize; IF NOT (_inactive) THEN FOR _x IN SELECT bomitem_id, bomitem_seqnumber, bomitem_seqnumber AS f_bomitem_seqnumber, item_id, item_number, uom_name, item_descrip1, item_descrip2, (item_descrip1 || ' ' || item_descrip2) AS itemdescription, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS qtyfxd, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS qtyper, bomitem_scrap, bomitem_createwo, CASE WHEN (bomitem_issuemethod='S') THEN 'Push' WHEN (bomitem_issuemethod='L') THEN 'Pull' WHEN (bomitem_issuemethod='M') THEN 'Mixed' ELSE 'Special' END AS issuemethod, bomitem_effective, bomitem_expires, CASE WHEN (bomitem_expires <= CURRENT_DATE) THEN TRUE ELSE FALSE END AS expired, CASE WHEN (bomitem_effective > CURRENT_DATE) THEN TRUE ELSE FALSE END AS future, actcost(bomitem_item_id, bomitem_id) AS actunitcost, stdcost(bomitem_item_id, bomitem_id) AS stdunitcost, CASE WHEN item_type NOT IN ('R','T') THEN itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') * actcost(bomitem_item_id, bomitem_id) ELSE 0.0 END AS actextendedcost, CASE WHEN item_type NOT IN ('R','T') THEN itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') * stdcost(bomitem_item_id, bomitem_id) ELSE 0.0 END AS stdextendedcost, bomitem_char_id, bomitem_value, bomitem_notes, bomitem_ref FROM bomitem(pItemid,pRevisionid), item, uom WHERE ( (item_inv_uom_id=uom_id) AND (bomitem_item_id=item_id) AND (bomitem_expires > (CURRENT_DATE - pExpiredDays)) AND (bomitem_effective <= (CURRENT_DATE + pFutureDays)) ) UNION SELECT -1, -1, NULL, -1, costelem_type AS bomdata_item_number, '', '', '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, false,false, currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE) AS actunitcost, itemcost_stdcost AS stdunitcost, currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE) AS actextendedcost, itemcost_stdcost AS stdextendedcost, NULL, NULL, NULL, NULL FROM itemcost, costelem WHERE ( (itemcost_costelem_id=costelem_id) AND (NOT itemcost_lowlevel) AND (itemcost_item_id=pItemid) ) ORDER BY bomitem_seqnumber, bomitem_effective, item_number LOOP _row.bomdata_bomitem_id := _x.bomitem_id; _row.bomdata_bomwork_seqnumber := _x.f_bomitem_seqnumber; _row.bomdata_item_id := _x.item_id; _row.bomdata_item_number := _x.item_number; _row.bomdata_uom_name := _x.uom_name; _row.bomdata_item_descrip1 := _x.item_descrip1; _row.bomdata_item_descrip2 := _x.item_descrip2; _row.bomdata_itemdescription := _x.itemdescription; _row.bomdata_batchsize := _batchsize; _row.bomdata_qtyfxd := _x.qtyfxd; _row.bomdata_qtyper := _x.qtyper; _row.bomdata_scrap := _x.bomitem_scrap; _row.bomdata_createchild := _x.bomitem_createwo; _row.bomdata_issuemethod := _x.issuemethod; _row.bomdata_effective := _x.bomitem_effective; _row.bomdata_expires := _x.bomitem_expires; _row.bomdata_expired := _x.expired; _row.bomdata_future := _x.future; _row.bomdata_actunitcost := _x.actunitcost; _row.bomdata_stdunitcost := _x.stdunitcost; _row.bomdata_actextendedcost := _x.actextendedcost; _row.bomdata_stdextendedcost := _x.stdextendedcost; _row.bomdata_char_id := _x.bomitem_char_id; _row.bomdata_value := _x.bomitem_value; _row.bomdata_notes := _x.bomitem_notes; _row.bomdata_ref := _x.bomitem_ref; RETURN NEXT _row; END LOOP; ELSE -- Use historical snapshot for inactive revisions FOR _x IN SELECT bomitem_id, bomitem_seqnumber, bomitem_seqnumber AS f_bomitem_seqnumber, item_id, item_number, uom_name, item_descrip1, item_descrip2, (item_descrip1 || ' ' || item_descrip2) AS itemdescription, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS qtyfxd, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS qtyper, bomitem_scrap, bomitem_createwo, CASE WHEN (bomitem_issuemethod='S') THEN 'Push' WHEN (bomitem_issuemethod='L') THEN 'Pull' WHEN (bomitem_issuemethod='M') THEN 'Mixed' ELSE 'Special' END AS issuemethod, bomitem_effective, bomitem_expires, CASE WHEN (bomitem_expires <= CURRENT_DATE) THEN TRUE ELSE FALSE END AS expired, CASE WHEN (bomitem_effective > CURRENT_DATE) THEN TRUE ELSE FALSE END AS future, actcost(bomitem_item_id) AS actunitcost, stdcost(bomitem_item_id) AS stdunitcost, CASE WHEN item_type NOT IN ('R','T') THEN itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') * actcost(bomitem_item_id) ELSE 0.0 END AS actextendedcost, CASE WHEN item_type NOT IN ('R','T') THEN itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') * stdcost(bomitem_item_id) ELSE 0.0 END AS stdextendedcost, bomitem_char_id, bomitem_value, bomitem_notes, bomitem_ref FROM bomitem(pItemid,pRevisionid), item, uom WHERE ( (item_inv_uom_id=uom_id) AND (bomitem_item_id=item_id) AND (bomitem_expires > (CURRENT_DATE - pExpiredDays)) AND (bomitem_effective <= (CURRENT_DATE + pFutureDays)) ) UNION SELECT -1, -1, NULL, -1, costelem_type AS bomdata_item_number, '', '', '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, false,false, bomhist_actunitcost AS actunitcost, bomhist_stdunitcost AS stdunitcost, bomhist_actunitcost AS actextendedcost, bomhist_stdunitcost AS stdextendedcost, NULL, NULL, NULL, NULL FROM bomhist, costelem WHERE ( (bomhist_item_id=costelem_id) AND (bomhist_item_type='E') AND (bomhist_rev_id=pRevisionid) ) ORDER BY bomitem_seqnumber, bomitem_effective, item_number LOOP _row.bomdata_bomitem_id := _x.bomitem_id; _row.bomdata_bomwork_seqnumber := _x.f_bomitem_seqnumber; _row.bomdata_item_id := _x.item_id; _row.bomdata_item_number := _x.item_number; _row.bomdata_uom_name := _x.uom_name; _row.bomdata_item_descrip1 := _x.item_descrip1; _row.bomdata_item_descrip2 := _x.item_descrip2; _row.bomdata_itemdescription := _x.itemdescription; _row.bomdata_batchsize := _batchsize; _row.bomdata_qtyfxd := _x.qtyfxd; _row.bomdata_qtyper := _x.qtyper; _row.bomdata_scrap := _x.bomitem_scrap; _row.bomdata_createchild := _x.bomitem_createwo; _row.bomdata_issuemethod := _x.issuemethod; _row.bomdata_effective := _x.bomitem_effective; _row.bomdata_expires := _x.bomitem_expires; _row.bomdata_expired := _x.expired; _row.bomdata_future := _x.future; _row.bomdata_actunitcost := _x.actunitcost; _row.bomdata_stdunitcost := _x.stdunitcost; _row.bomdata_actextendedcost := _x.actextendedcost; _row.bomdata_stdextendedcost := _x.stdextendedcost; _row.bomdata_char_id := _x.bomitem_char_id; _row.bomdata_value := _x.bomitem_value; _row.bomdata_notes := _x.bomitem_notes; _row.bomdata_ref := _x.bomitem_ref; RETURN NEXT _row; END LOOP; END IF; RETURN; END; $_$; ALTER FUNCTION public.singlelevelbom(integer, integer, integer, integer) OWNER TO admin; -- -- Name: site(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION site() RETURNS SETOF whsinfo LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row whsinfo%ROWTYPE; _r RECORD; BEGIN IF ( (fetchMetricBool('MultiWhs')) AND (SELECT (COUNT(usrpref_id)=1) FROM usrpref WHERE ((usrpref_name='selectedSites') AND (usrpref_value='t') AND (usrpref_username=getEffectiveXtUser()))) ) THEN FOR _r IN SELECT * FROM whsinfo,usrsite WHERE ((warehous_id=usrsite_warehous_id) AND (usrsite_username=getEffectiveXtUser())) LOOP _row.warehous_id:=_r.warehous_id; _row.warehous_code:=_r.warehous_code; _row.warehous_descrip:=_r.warehous_descrip; _row.warehous_fob:=_r.warehous_fob; _row.warehous_active:=_r.warehous_active; _row.warehous_counttag_prefix:=_r.warehous_counttag_prefix; _row.warehous_counttag_number:=_r.warehous_counttag_number; _row.warehous_bol_prefix:=_r.warehous_bol_prefix; _row.warehous_bol_number:=_r.warehous_bol_number; _row.warehous_shipping:=_r.warehous_shipping; _row.warehous_useslips:=_r.warehous_useslips; _row.warehous_usezones:=_r.warehous_usezones; _row.warehous_aislesize:=_r.warehous_aislesize; _row.warehous_racksize:=_r.warehous_racksize; _row.warehous_binsize:=_r.warehous_binsize; _row.warehous_binalpha:=_r.warehous_binalpha; _row.warehous_locationsize:=_r.warehous_locationsize; _row.warehous_locationalpha:=_r.warehous_locationalpha; _row.warehous_enforcearbl:=_r.warehous_enforcearbl; _row.warehous_default_accnt_id:=_r.warehous_default_accnt_id; _row.warehous_shipping_commission:=_r.warehous_shipping_commission; _row.warehous_cntct_id:=_r.warehous_cntct_id; _row.warehous_addr_id:=_r.warehous_addr_id; _row.warehous_taxzone_id:=_r.warehous_taxzone_id; _row.warehous_transit:=_r.warehous_transit; _row.warehous_shipform_id:=_r.warehous_shipform_id; _row.warehous_shipvia_id:=_r.warehous_shipvia_id; _row.warehous_shipcomments:=_r.warehous_shipcomments; _row.warehous_costcat_id:=_r.warehous_costcat_id; _row.warehous_sitetype_id:=_r.warehous_sitetype_id; RETURN NEXT _row; END LOOP; ELSE FOR _r IN SELECT * FROM whsinfo LOOP _row.warehous_id:=_r.warehous_id; _row.warehous_code:=_r.warehous_code; _row.warehous_descrip:=_r.warehous_descrip; _row.warehous_fob:=_r.warehous_fob; _row.warehous_active:=_r.warehous_active; _row.warehous_counttag_prefix:=_r.warehous_counttag_prefix; _row.warehous_counttag_number:=_r.warehous_counttag_number; _row.warehous_bol_prefix:=_r.warehous_bol_prefix; _row.warehous_bol_number:=_r.warehous_bol_number; _row.warehous_shipping:=_r.warehous_shipping; _row.warehous_useslips:=_r.warehous_useslips; _row.warehous_usezones:=_r.warehous_usezones; _row.warehous_aislesize:=_r.warehous_aislesize; _row.warehous_racksize:=_r.warehous_racksize; _row.warehous_binsize:=_r.warehous_binsize; _row.warehous_binalpha:=_r.warehous_binalpha; _row.warehous_locationsize:=_r.warehous_locationsize; _row.warehous_locationalpha:=_r.warehous_locationalpha; _row.warehous_enforcearbl:=_r.warehous_enforcearbl; _row.warehous_default_accnt_id:=_r.warehous_default_accnt_id; _row.warehous_shipping_commission:=_r.warehous_shipping_commission; _row.warehous_cntct_id:=_r.warehous_cntct_id; _row.warehous_addr_id:=_r.warehous_addr_id; _row.warehous_taxzone_id:=_r.warehous_taxzone_id; _row.warehous_transit:=_r.warehous_transit; _row.warehous_shipform_id:=_r.warehous_shipform_id; _row.warehous_shipvia_id:=_r.warehous_shipvia_id; _row.warehous_shipcomments:=_r.warehous_shipcomments; _row.warehous_costcat_id:=_r.warehous_costcat_id; _row.warehous_sitetype_id:=_r.warehous_sitetype_id; RETURN NEXT _row; END LOOP; END IF; RETURN; END; $$; ALTER FUNCTION public.site() OWNER TO admin; -- -- Name: snoozemessage(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION snoozemessage(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pMsgid ALIAS FOR $1; snooze INTERVAL := '10 minutes'; BEGIN UPDATE msg SET msg_scheduled=(msg_scheduled + snooze) WHERE (msg_id=pMsgid); RETURN TRUE; END; $_$; ALTER FUNCTION public.snoozemessage(integer) OWNER TO admin; -- -- Name: spellamount(numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION spellamount(numeric) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN spellAmount($1, baseCurrId()); END; $_$; ALTER FUNCTION public.spellamount(numeric) OWNER TO admin; -- -- Name: spellamount(numeric, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION spellamount(numeric, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pN ALIAS FOR $1; pCurrId ALIAS FOR $2; _t text; _dollars text; _cents text; _l integer; _p integer; _words text; _word text; _hundreds char; _tens char; _ones char; _fractionalPartName text; _curr curr_symbol%ROWTYPE; BEGIN _t := ltrim(to_char(pN, '999999999990D99'),' '); IF strpos(_t, '.') > 0 THEN _dollars := split_part(_t, '.', 1); _cents := split_part(_t, '.', 2); ELSIF strpos(_t, ',') > 0 THEN _dollars := split_part(_t, ',', 1); _cents := split_part(_t, ',', 2); END IF; _p := 0; _l := length(_dollars); _words := ''; WHILE (_p < _l) LOOP IF((_l - _p - 2) < 1) THEN _hundreds := '0'; ELSE _hundreds := substr(_dollars, _l - _p - 2, 1); END IF; IF((_l - _p - 1) < 1) THEN _tens := '0'; ELSE _tens := substr(_dollars, _l - _p - 1, 1); END IF; IF((_l - _p) < 1) THEN _ones := '0'; ELSE _ones := substr(_dollars, _l - _p, 1); END IF; IF(_hundreds != '0' OR _tens != '0' OR _ones != '0') THEN IF (_p = 3) THEN _words := 'thousand ' || _words; ELSIF (_p = 6) THEN _words := 'million ' || _words; ELSIF (_p = 9) THEN _words := 'billion ' || _words; END IF; _word := ''; IF(_tens = '1') THEN IF(_ones = '0') THEN _word := 'ten'; ELSIF(_ones = '1') THEN _word := 'eleven'; ELSIF(_ones = '2') THEN _word := 'twelve'; ELSIF(_ones = '3') THEN _word := 'thirteen'; ELSIF(_ones = '4') THEN _word := 'fourteen'; ELSIF(_ones = '5') THEN _word := 'fifteen'; ELSIF(_ones = '6') THEN _word := 'sixteen'; ELSIF(_ones = '7') THEN _word := 'seventeen'; ELSIF(_ones = '8') THEN _word := 'eighteen'; ELSIF(_ones = '9') THEN _word := 'nineteen'; ELSE _word := 'ERROR'; END IF; ELSE IF(_ones = '1') THEN _word := 'one'; ELSIF(_ones = '2') THEN _word := 'two'; ELSIF(_ones = '3') THEN _word := 'three'; ELSIF(_ones = '4') THEN _word := 'four'; ELSIF(_ones = '5') THEN _word := 'five'; ELSIF(_ones = '6') THEN _word := 'six'; ELSIF(_ones = '7') THEN _word := 'seven'; ELSIF(_ones = '8') THEN _word := 'eight'; ELSIF(_ones = '9') THEN _word := 'nine'; ELSIF(_ones != '0') THEN _word := 'ERROR'; END IF; if(_tens != '0') THEN _word := '-' || _word; END IF; IF(_tens = '2') THEN _word := 'twenty' || _word; ELSIF(_tens = '3') THEN _word := 'thirty' || _word; ELSIF(_tens = '4') THEN _word := 'forty' || _word; ELSIF(_tens = '5') THEN _word := 'fifty' || _word; ELSIF(_tens = '6') THEN _word := 'sixty' || _word; ELSIF(_tens = '7') THEN _word := 'seventy' || _word; ELSIF(_tens = '8') THEN _word := 'eighty' || _word; ELSIF(_tens = '9') THEN _word := 'ninety' || _word; ELSIF(_tens != '0' AND _tens != '1') THEN _word := 'ERROR' || _word; END IF; END IF; if(_word != '') THEN _words := _word || ' ' || _words; END IF; _word := ''; IF(_hundreds = '1') THEN _word := 'one hundred'; ELSIF(_hundreds = '2') THEN _word := 'two hundred'; ELSIF(_hundreds = '3') THEN _word := 'three hundred'; ELSIF(_hundreds = '4') THEN _word := 'four hundred'; ELSIF(_hundreds = '5') THEN _word := 'five hundred'; ELSIF(_hundreds = '6') THEN _word := 'six hundred'; ELSIF(_hundreds = '7') THEN _word := 'seven hundred'; ELSIF(_hundreds = '8') THEN _word := 'eight hundred'; ELSIF(_hundreds = '9') THEN _word := 'nine hundred'; ELSIF(_hundreds != '0') THEN _words := 'ERROR'; END IF; if(_word != '') THEN _words := _word || ' ' || _words; END IF; END IF; _p := _p + 3; END LOOP; _words := rtrim(_words, ' '); IF(_words = '') THEN _words := 'zero'; END IF; SELECT * INTO _curr FROM curr_symbol WHERE curr_id = pCurrId; IF(_words = 'one') AND TRIM(_curr.curr_name) ~ '.*s' THEN _word := rtrim(_curr.curr_name, ' s'); ELSE _word := trim(_curr.curr_name); END IF; IF _curr.curr_abbr = 'USD' OR _curr.curr_abbr = 'CAD' THEN IF (_cents = '1') THEN _fractionalPartName = ' cent'; ELSE _fractionalPartName = ' cents'; END IF; ELSE _fractionalPartName = ' / 100 '; END IF; RETURN _words || ' ' || _word || ' and ' || _cents || _fractionalPartName; END; $_$; ALTER FUNCTION public.spellamount(numeric, integer) OWNER TO admin; -- -- Name: splitreceipt(integer, numeric, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION splitreceipt(integer, numeric, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE precvid ALIAS FOR $1; pqty ALIAS FOR $2; pfreight ALIAS FOR $3; _check RECORD; _seq INTEGER; BEGIN -- validate IF (COALESCE(pQty,0) <= 0) THEN RETURN -7; END IF; SELECT * INTO _check FROM recv WHERE (recv_id=precvid); IF (FOUND) THEN IF (_check.recv_order_type != 'PO') THEN RETURN -1; ELSIF ( NOT _check.recv_posted) THEN RETURN -2; ELSIF ( (_check.recv_invoiced) OR (_check.recv_vohead_id IS NOT NULL) OR (_check.recv_voitem_id IS NOT NULL) ) THEN RETURN -3; ELSIF (pqty >= _check.recv_qty) THEN RETURN -4; ELSIF (COALESCE(pfreight,0) > _check.recv_freight) THEN RETURN -5; END IF; ELSE RETURN -6; END IF; -- Create new receipt record _seq := nextval('recv_recv_id_seq'); INSERT INTO recv SELECT _seq, recv_order_type,recv_order_number, recv_orderitem_id, recv_agent_username, recv_itemsite_id, recv_vend_id, recv_vend_item_number, recv_vend_item_descrip, recv_vend_uom, recv_purchcost, recv_purchcost_curr_id, recv_duedate, pqty, recv_recvcost, recv_recvcost_curr_id, COALESCE(pfreight,0), recv_freight_curr_id, recv_date, ROUND(recv_value/recv_qty * pqty, 2), TRUE, FALSE, NULL, NULL, recv_trans_usr_name, recv_notes, recv_gldistdate, precvid FROM recv WHERE (recv_id=precvid); -- Update qty and value of old record UPDATE recv SET recv_qty = recv_qty-pqty, recv_value = recv_value - ROUND(recv_value/recv_qty * pqty, 2), recv_freight = recv_freight - COALESCE(pfreight,0) WHERE (recv_id=precvid); RETURN _seq; END; $_$; ALTER FUNCTION public.splitreceipt(integer, numeric, numeric) OWNER TO admin; -- -- Name: splitrecurrence(integer, text, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION splitrecurrence(integer, text, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pParentid ALIAS FOR $1; pType TEXT := UPPER($2); pDatetime TIMESTAMP WITH TIME ZONE := COALESCE($3, CURRENT_TIMESTAMP); _count INTEGER; _newrecurid INTEGER; _newparentid INTEGER; _newparentstmt TEXT; _rt RECORD; _updchildstmt TEXT; BEGIN IF (pParentid IS NULL) THEN RETURN -11; END IF; SELECT * INTO _rt FROM recurtype WHERE (UPPER(recurtype_type)=pType); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count <= 0) THEN RETURN -10; END IF; _newparentstmt := 'SELECT [table]_id FROM [fulltable]' || ' WHERE (([table]_recurring_[table]_id=$1)' || ' AND NOT ([done])' || ' AND ([schedcol]>=''$2''))' || ' ORDER BY [schedcol]' || ' LIMIT 1;'; _newparentstmt := REPLACE(_newparentstmt, '[fulltable]', _rt.recurtype_table); _newparentstmt := REPLACE(_newparentstmt, '[table]', REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', '')); _newparentstmt := REPLACE(_newparentstmt, '[done]', _rt.recurtype_donecheck); _newparentstmt := REPLACE(_newparentstmt, '[schedcol]', _rt.recurtype_schedcol); _updchildstmt := 'UPDATE [fulltable] SET [table]_recurring_[table]_id=$1' || ' WHERE (([table]_recurring_[table]_id=$2)' || ' AND NOT ([done])' || ' AND ([schedcol] > ''$3''));'; _updchildstmt := REPLACE(_updchildstmt, '[fulltable]', _rt.recurtype_table); _updchildstmt := REPLACE(_updchildstmt, '[table]', REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', '')); _updchildstmt := REPLACE(_updchildstmt, '[done]', _rt.recurtype_donecheck); _updchildstmt := REPLACE(_updchildstmt, '[schedcol]', _rt.recurtype_schedcol); -- 8.4+: EXECUTE _newparentstmt INTO _newparentid USING pParentid, pDatetime; EXECUTE REPLACE(REPLACE(_newparentstmt, '$1', pParentid::TEXT), '$2', pDatetime::TEXT) INTO _newparentid; -- if nothing to split IF (_newparentid = pParentid OR _newparentid IS NULL) THEN SELECT recur_id INTO _newrecurid FROM recur WHERE ((recur_parent_id=pParentid) AND (recur_parent_type=pType)); ELSE INSERT INTO recur (recur_parent_id, recur_parent_type, recur_period, recur_freq, recur_start, recur_end, recur_max, recur_data ) SELECT _newparentid, pType, recur_period, recur_freq, pDatetime, recur_end, recur_max, recur_data FROM recur WHERE ((recur_parent_id=pParentid) AND (recur_parent_type=pType)) RETURNING recur_id INTO _newrecurid; UPDATE recur SET recur_end=pDatetime WHERE ((recur_parent_id=pParentid) AND (recur_parent_type=pType)); -- 8.4+: EXECUTE _updchildstmt USING _newparentid, pParentid, pDatetime; EXECUTE REPLACE(REPLACE(REPLACE(_updchildstmt, '$1', _newparentid::TEXT), '$2', pParentid::TEXT), '$3', pDatetime::TEXT); END IF; RETURN _newrecurid; END; $_$; ALTER FUNCTION public.splitrecurrence(integer, text, timestamp with time zone) OWNER TO admin; -- -- Name: startoftime(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION startoftime() RETURNS date LANGUAGE sql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT DATE('1970-01-01') AS return; $$; ALTER FUNCTION public.startoftime() OWNER TO admin; -- -- Name: stdcost(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION stdcost(integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN stdCost($1, NULL); END; $_$; ALTER FUNCTION public.stdcost(integer) OWNER TO admin; -- -- Name: stdcost(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION stdcost(integer, integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pBomitemid ALIAS FOR $2; _cost NUMERIC; BEGIN SELECT SUM(COALESCE(bomitemcost_stdcost, itemcost_stdcost)) INTO _cost FROM itemcost LEFT OUTER JOIN bomitemcost ON (bomitemcost_bomitem_id=pBomitemid AND bomitemcost_costelem_id=itemcost_costelem_id) WHERE (itemcost_item_id=pItemid); IF (_cost IS NULL) THEN RETURN 0; ELSE RETURN _cost; END IF; END; $_$; ALTER FUNCTION public.stdcost(integer, integer) OWNER TO admin; -- -- Name: sufficientinventorytoshipitem(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION sufficientinventorytoshipitem(text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; porderitemid ALIAS FOR $2; BEGIN RETURN sufficientInventoryToShipItem(pordertype, porderitemid, NULL); END; $_$; ALTER FUNCTION public.sufficientinventorytoshipitem(text, integer) OWNER TO admin; -- -- Name: sufficientinventorytoshipitem(text, integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION sufficientinventorytoshipitem(text, integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; porderitemid ALIAS FOR $2; pqty ALIAS FOR $3; _returnVal INTEGER; _isqtyavail BOOLEAN; BEGIN IF (porderitemid IS NULL) THEN RETURN -1; END IF; IF (pordertype = 'SO') THEN IF ( SELECT fetchMetricBool('EnableSOReservations') ) THEN IF (SELECT (itemsite_costmethod = 'J') FROM coitem JOIN itemsite ON (coitem_itemsite_id=itemsite_id) WHERE (coitem_id=porderitemid)) THEN RETURN 0; END IF; SELECT (((COALESCE(pqty, roundQty(item_fractional, noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping(pordertype, coitem_id) ))) - coitem_qtyreserved) * coitem_qty_invuomratio ) <= qtyAvailable(itemsite_id)) AND (((COALESCE(pqty, roundQty(item_fractional, noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping(pordertype, coitem_id) ))) - coitem_qtyreserved) * coitem_qty_invuomratio ) <= qtyunreserved(itemsite_id)) INTO _isqtyavail FROM coitem, itemsite, item WHERE ((coitem_itemsite_id=itemsite_id) AND (coitem_status <> 'X') AND (NOT ((item_type IN ('R','J')) OR (itemsite_controlmethod = 'N'))) AND (itemsite_item_id=item_id) AND (coitem_id=porderitemid)); ELSE SELECT (COALESCE(pqty, roundQty(item_fractional, noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping(pordertype, coitem_id) - coitem_qtyreserved ) * coitem_qty_invuomratio ) ) <= qtyAvailable(itemsite_id)) INTO _isqtyavail FROM coitem, itemsite, item WHERE ((coitem_itemsite_id=itemsite_id) AND (coitem_status <> 'X') AND (NOT ((item_type IN ('R','J')) OR (itemsite_controlmethod = 'N'))) AND (itemsite_item_id=item_id) AND (coitem_id=porderitemid)); END IF; ELSEIF (pordertype = 'TO') THEN SELECT (COALESCE(pqty, roundQty(item_fractional, noNeg(toitem_qty_ordered - toitem_qty_shipped - qtyAtShipping(pordertype, toitem_id) ) ) ) <= qtyAvailable(itemsite_id)) INTO _isqtyavail FROM toitem, tohead, itemsite, item WHERE ((toitem_tohead_id=tohead_id) AND (tohead_src_warehous_id=itemsite_warehous_id) AND (toitem_item_id=itemsite_item_id) AND (itemsite_warehous_id=tohead_src_warehous_id) AND (itemsite_item_id=item_id) AND (toitem_status <> 'X') AND (NOT ((item_type IN ('R','J')) OR (itemsite_controlmethod = 'N'))) AND (toitem_id=porderitemid)); ELSE RETURN -11; END IF; IF (NOT _isqtyavail) THEN RETURN -2; END IF; IF (pordertype = 'SO') THEN SELECT (COALESCE((SELECT SUM(itemloc_qty) FROM itemloc WHERE (itemloc_itemsite_id=itemsite_id)), 0.0) >= roundQty(item_fractional, COALESCE(pQty, noNeg( coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping(pordertype, coitem_id) )) * coitem_qty_invuomratio )) INTO _isqtyavail FROM coitem, itemsite, item WHERE ((coitem_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (NOT ((item_type ='R') OR (itemsite_controlmethod = 'N'))) AND ((itemsite_controlmethod IN ('L', 'S')) OR (itemsite_loccntrl)) AND (coitem_id=porderitemid)); ELSEIF (pordertype = 'TO') THEN SELECT (COALESCE((SELECT SUM(itemloc_qty) FROM itemloc WHERE (itemloc_itemsite_id=itemsite_id)), 0.0) >= roundQty(item_fractional, noNeg( toitem_qty_ordered - toitem_qty_shipped - qtyAtShipping(pordertype, toitem_id) ) )) INTO _isqtyavail FROM toitem, tohead, itemsite, item WHERE ((toitem_tohead_id=tohead_id) AND (tohead_src_warehous_id=itemsite_warehous_id) AND (toitem_item_id=itemsite_item_id) AND (itemsite_item_id=item_id) AND (toitem_status <> 'X') AND (NOT ((item_type ='R') OR (itemsite_costmethod = 'J') OR (itemsite_controlmethod = 'N'))) AND ((itemsite_controlmethod IN ('L', 'S')) OR (itemsite_loccntrl)) AND (toitem_id=porderitemid)); END IF; IF (NOT _isqtyavail) THEN RETURN -3; END IF; IF (pordertype = 'SO') THEN IF ( SELECT fetchMetricBool('RequireSOReservations') ) THEN SELECT (COALESCE(pqty, coitem_qtyreserved) <= coitem_qtyreserved) INTO _isqtyavail FROM coitem, itemsite, item WHERE ((coitem_itemsite_id=itemsite_id) AND (coitem_status <> 'X') AND (NOT ((item_type IN ('R','J')) OR (itemsite_controlmethod = 'N'))) AND (itemsite_item_id=item_id) AND (coitem_id=porderitemid)); END IF; END IF; IF (NOT _isqtyavail) THEN RETURN -4; END IF; RETURN 0; END; $_$; ALTER FUNCTION public.sufficientinventorytoshipitem(text, integer, numeric) OWNER TO admin; -- -- Name: sufficientinventorytoshiporder(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION sufficientinventorytoshiporder(text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; porderid ALIAS FOR $2; _s RECORD; _returnVal INTEGER := 0; BEGIN IF (pordertype = 'SO') THEN FOR _s IN SELECT coitem_id FROM coitem JOIN itemsite ON (coitem_itemsite_id=itemsite_id) WHERE((coitem_cohead_id=porderid) AND (itemsite_costmethod != 'J')) LOOP _returnVal := sufficientInventoryToShipItem(pordertype, _s.coitem_id); EXIT WHEN (_returnVal < 0); END LOOP; ELSEIF (pordertype = 'TO') THEN FOR _s IN SELECT toitem_id FROM toitem WHERE(toitem_tohead_id=porderid) LOOP _returnVal := sufficientInventoryToShipItem(pordertype, _s.toitem_id); EXIT WHEN (_returnVal < 0); END LOOP; END IF; RETURN _returnVal; END; $_$; ALTER FUNCTION public.sufficientinventorytoshiporder(text, integer) OWNER TO admin; -- -- Name: summarizedbom(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summarizedbom(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; _revid INTEGER; BEGIN SELECT getActiveRevId('BOM',pItemid) INTO _revid; RETURN summarizedBOM(pItemid, _revid); END; $_$; ALTER FUNCTION public.summarizedbom(integer) OWNER TO admin; -- -- Name: summarizedbom(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summarizedbom(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pRevisionid ALIAS FOR $2; _bomworkid INTEGER; _indexid INTEGER; _r RECORD; BEGIN -- Check on the temporary workspace -- PERFORM maintainBOMWorkspace(); -- Grab a new index for this bomwork set SELECT NEXTVAL('misc_index_seq') INTO _indexid; -- Step through all of the components of the passed pItemid FOR _r IN SELECT bomitem.*, item_id, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS qtyfxd, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS qtyper, stdcost(item_id, bomitem_id) AS standardcost, actcost(item_id, bomitem_id) AS actualcost FROM bomitem(pItemid, pRevisionid), item WHERE (bomitem_item_id=item_id) LOOP -- Insert the component and bomitem parameters SELECT NEXTVAL('bomwork_bomwork_id_seq') INTO _bomworkid; INSERT INTO bomwork ( bomwork_id, bomwork_set_id, bomwork_parent_id, bomwork_level, bomwork_parent_seqnumber, bomwork_seqnumber, bomwork_item_id, bomwork_createwo, bomwork_qtyreq, bomwork_qtyfxd, bomwork_qtyper, bomwork_scrap, bomwork_issuemethod, bomwork_effective, bomwork_expires, bomwork_stdunitcost, bomwork_actunitcost ) VALUES ( _bomworkid, _indexid, -1, 1, 0, _r.bomitem_seqnumber, _r.item_id, _r.bomitem_createwo, (_r.qtyfxd + _r.qtyper), _r.qtyfxd, _r.qtyper, _r.bomitem_scrap, _r.bomitem_issuemethod, _r.bomitem_effective, _r.bomitem_expires, _r.standardcost, _r.actualcost, _r.bomitem_char_id, _r.bomitem_value, _r.bomitem_notes, _r.bomitem_ref, _r.bomitem_id, _r.bomitem_ecn ); -- Explode the components of the current component PERFORM explodeBOM(_r.item_id, _bomworkid, 1); END LOOP; -- Return a key to the result RETURN _indexid; END; $_$; ALTER FUNCTION public.summarizedbom(integer, integer) OWNER TO admin; -- -- Name: summarizedbom(integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summarizedbom(integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pExpired ALIAS FOR $2; pFuture ALIAS FOR $3; _revid INTEGER; BEGIN SELECT getActiveRevId('BOM',pItemid) INTO _revid; RETURN summarizedBOM(pItemid, _revid, pExpired, pFuture); END; $_$; ALTER FUNCTION public.summarizedbom(integer, integer, integer) OWNER TO admin; -- -- Name: summarizedbom(integer, integer, integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summarizedbom(integer, integer, integer, integer) RETURNS SETOF bomdata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pRevisionid ALIAS FOR $2; pExpiredDays INTEGER := COALESCE($3, 0); pFutureDays INTEGER := COALESCE($4, 0); _row bomdata%ROWTYPE; _bomworksetid INTEGER; _x RECORD; _check CHAR(1); _inactive BOOLEAN := FALSE; _batchsize NUMERIC; BEGIN IF (pRevisionid != -1) THEN --Is this a deactivated revision? SELECT rev_status INTO _check FROM rev WHERE ((rev_id=pRevisionid) AND (rev_status='I')); IF (FOUND) THEN _inactive := TRUE; END IF; END IF; -- Get the batch quantity SELECT COALESCE( ( SELECT bomhead_batchsize FROM bomhead WHERE ((bomhead_item_id=pItemId) AND (bomhead_rev_id=pRevisionid))),1) INTO _batchsize; IF NOT (_inactive) THEN --We can explode this out based on current data SELECT indentedBOM(pItemid, pRevisionid) INTO _bomworksetid; FOR _x IN SELECT item_number, uom_name, item_descrip1, item_descrip2, (item_descrip1 || ' ' || item_descrip2) AS itemdescription, SUM(bomwork_qtyreq) AS qtyreq, SUM(bomwork_qtyfxd * (1 + bomwork_scrap)) AS qtyfxd, SUM(bomwork_qtyper * (1 + bomwork_scrap)) AS qtyper, MAX(bomwork_actunitcost) AS actunitcost, MAX(bomwork_stdunitcost) AS stdunitcost, CASE WHEN item_type NOT IN ('R','T') THEN SUM(bomwork_actunitcost * bomwork_qtyreq) ELSE 0 END AS actextendedcost, CASE WHEN item_type NOT IN ('R','T') THEN SUM(bomwork_stdunitcost * bomwork_qtyreq) ELSE 0 END AS stdextendedcost, bomwork_effective, bomwork_expires, bomwork_effective > CURRENT_DATE AS future, bomwork_expires <= CURRENT_DATE AS expired FROM ( SELECT item_number, item_type, uom_name, item_descrip1, item_descrip2, bomwork_qtyreq, bomwork_qtyfxd, bomwork_qtyper, bomwork_scrap, bomwork_actunitcost, bomwork_stdunitcost, CASE WHEN (bomwork_effective > CURRENT_DATE) THEN (CURRENT_DATE + 1) ELSE CURRENT_DATE END AS bomwork_effective, CASE WHEN (bomwork_expires <= CURRENT_DATE) THEN (CURRENT_DATE - 1) ELSE (CURRENT_DATE + 1) END AS bomwork_expires FROM bomwork, item, uom WHERE ( (bomwork_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (bomwork_set_id=_bomworksetid) ) AND (bomwork_expires > (CURRENT_DATE - pExpiredDays)) AND (bomwork_effective <= (CURRENT_DATE + pFutureDays)) ) AS data GROUP BY item_number, uom_name, item_type, item_descrip1, item_descrip2, bomwork_effective, bomwork_expires ORDER BY item_number LOOP _row.bomdata_item_number := _x.item_number; _row.bomdata_uom_name := _x.uom_name; _row.bomdata_item_descrip1 := _x.item_descrip1; _row.bomdata_item_descrip2 := _x.item_descrip2; _row.bomdata_itemdescription := _x.itemdescription; _row.bomdata_qtyreq := _x.qtyreq; _row.bomdata_qtyfxd := _x.qtyfxd; _row.bomdata_qtyper := _x.qtyper; _row.bomdata_actunitcost := _x.actunitcost; _row.bomdata_stdunitcost := _x.stdunitcost; _row.bomdata_actextendedcost := _x.actextendedcost; _row.bomdata_stdextendedcost := _x.stdextendedcost; _row.bomdata_effective := _x.bomwork_effective; _row.bomdata_expires := _x.bomwork_expires; _row.bomdata_future := _x.future; _row.bomdata_expired := _x.expired; RETURN NEXT _row; END LOOP; PERFORM deleteBOMWorkset(_bomworksetid); ELSE -- Use historical snapshot for inactive revisions FOR _x IN SELECT item_number, uom_name, item_descrip1, item_descrip2, (item_descrip1 || ' ' || item_descrip2) AS itemdescription, SUM(bomhist_qtyreq * (1 + bomhist_scrap)) AS qtyreq, SUM(bomhist_qtyfxd * (1 + bomhist_scrap)) AS qtyfxd, SUM(bomhist_qtyper * (1 + bomhist_scrap)) AS qtyper, MAX(bomhist_actunitcost) AS actunitcost, MAX(bomhist_stdunitcost) AS stdunitcost, CASE WHEN item_type NOT IN ('R','T') THEN MAX(bomhist_actunitcost) * SUM((bomhist_qtyfxd/_batchsize + bomhist_qtyper) * (1 + bomhist_scrap)) ELSE 0 END AS actextendedcost, CASE WHEN item_type NOT IN ('R','T') THEN MAX(bomhist_stdunitcost) * SUM((bomhist_qtyfxd/_batchsize + bomhist_qtyper) * (1 + bomhist_scrap)) ELSE 0 END AS stdextendedcost FROM bomhist, item, uom WHERE ( (bomhist_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (bomhist_rev_id=pRevisionid) ) AND (bomhist_expires > (CURRENT_DATE - pExpiredDays)) AND (bomhist_effective <= (CURRENT_DATE + pFutureDays)) GROUP BY item_number, uom_name, item_type, item_descrip1, item_descrip2 ORDER BY item_number LOOP _row.bomdata_item_number := _x.item_number; _row.bomdata_uom_name := _x.uom_name; _row.bomdata_item_descrip1 := _x.item_descrip1; _row.bomdata_item_descrip2 := _x.item_descrip2; _row.bomdata_itemdescription := _x.itemdescription; _row.bomdata_qtyreq := _x.qtyreq; _row.bomdata_qtyfxd := _x.qtyfxd; _row.bomdata_qtyper := _x.qtyper; _row.bomdata_actunitcost := _x.actunitcost; _row.bomdata_stdunitcost := _x.stdunitcost; _row.bomdata_actextendedcost := _x.actextendedcost; _row.bomdata_stdextendedcost := _x.stdextendedcost; RETURN NEXT _row; END LOOP; END IF; RETURN; END; $_$; ALTER FUNCTION public.summarizedbom(integer, integer, integer, integer) OWNER TO admin; -- -- Name: summarizetransactions(integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summarizetransactions(integer, date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _startDate DATE; _endDate DATE; _invhist RECORD; _itemuom TEXT; _transCounter INTEGER; _itemlocSeries INTEGER; BEGIN -- Cache the uom_name SELECT uom_name INTO _itemuom FROM itemsite, item, uom WHERE ((itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (itemsite_id=pItemsiteid)); -- Can't summarize into the future... IF (pEndDate > CURRENT_DATE) THEN _endDate := CURRENT_DATE; ELSE _endDate := pEndDate; END IF; -- Verify date bounds IF (pStartDate > pEndDate) THEN _startDate := pEndDate; ELSE _startDate := pStartDate; END IF; -- Verify that history is not referenced elsewhere SELECT invhist_id INTO _transCounter FROM invhist JOIN womatlpost ON (womatlpost_invhist_id=invhist_id) WHERE ((invhist_itemsite_id=pItemsiteid) AND (invhist_transdate::DATE BETWEEN _startDate AND _endDate)) LIMIT 1; IF (FOUND) THEN RETURN 0; END IF; SELECT invhist_id INTO _transCounter FROM invhist JOIN shipitem ON (shipitem_invhist_id=invhist_id) WHERE ((invhist_itemsite_id=pItemsiteid) AND (invhist_transdate::DATE BETWEEN _startDate AND _endDate)) LIMIT 1; IF (FOUND) THEN RETURN 0; END IF; _transCounter := 0; _itemlocSeries := NEXTVAL('itemloc_series_seq'); FOR _invhist IN SELECT invhist_transtype, invhist_costmethod, SUM(invhist_invqty) AS qty FROM invhist WHERE ((invhist_itemsite_id=pItemsiteid) AND (invhist_transdate::DATE BETWEEN _startDate AND _endDate)) GROUP BY invhist_transtype, invhist_costmethod LOOP DELETE FROM invhist WHERE ((invhist_transdate::DATE BETWEEN _startDate AND _endDate) AND (invhist_transtype=_invhist.invhist_transtype) AND (invhist_itemsite_id=pItemsiteid)); INSERT INTO invhist ( invhist_itemsite_id, invhist_transdate, invhist_transtype, invhist_invqty, invhist_qoh_before, invhist_qoh_after, invhist_invuom, invhist_user, invhist_ordnumber, invhist_costmethod, invhist_value_before, invhist_value_after, invhist_series ) VALUES ( pItemsiteid, _endDate, _invhist.invhist_transtype, _invhist.qty, 0, 0, _itemuom, getEffectiveXtUser(), 'Summary', _invhist.invhist_costmethod, 0, 0, _itemlocSeries ); _transCounter := (_transCounter + 1); END LOOP; RETURN _transCounter; END; $_$; ALTER FUNCTION public.summarizetransactions(integer, date, date) OWNER TO admin; -- -- Name: summdemand(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summdemand(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pCalitemid ALIAS FOR $2; _value NUMERIC; BEGIN SELECT summDemand(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value; RETURN _value; END; $_$; ALTER FUNCTION public.summdemand(integer, integer) OWNER TO admin; -- -- Name: summdemand(integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summdemand(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _value NUMERIC; BEGIN SELECT SUM(wo_qtyord - wo_qtyrcv) INTO _value FROM wo WHERE ( (wo_itemsite_id=pItemsiteid) AND (wo_status IN ('R', 'I')) AND (wo_startdate::DATE BETWEEN pStartDate AND pEndDate) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; ALTER FUNCTION public.summdemand(integer, date, date) OWNER TO admin; -- -- Name: summprod(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summprod(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pCalitemid ALIAS FOR $2; _value NUMERIC; BEGIN SELECT summProd(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value; RETURN _value; END; $_$; ALTER FUNCTION public.summprod(integer, integer) OWNER TO admin; -- -- Name: summprod(integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summprod(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _value NUMERIC; BEGIN SELECT SUM(invhist_invqty) INTO _value FROM invhist WHERE ( (invhist_itemsite_id=pItemsiteid) AND (invhist_transtype IN ('RM', 'RB')) AND (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; ALTER FUNCTION public.summprod(integer, date, date) OWNER TO admin; -- -- Name: summtransa(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summtransa(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pCalitemid ALIAS FOR $2; _value NUMERIC; BEGIN SELECT summTransA(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value; RETURN _value; END; $_$; ALTER FUNCTION public.summtransa(integer, integer) OWNER TO admin; -- -- Name: summtransa(integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summtransa(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _value NUMERIC; BEGIN SELECT SUM(invhist_invqty) INTO _value FROM invhist WHERE ((invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) AND (invhist_transtype IN ('AD', 'CC')) AND (invhist_itemsite_id=pItemsiteid)); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; ALTER FUNCTION public.summtransa(integer, date, date) OWNER TO admin; -- -- Name: summtransc(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summtransc(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pCalitemid ALIAS FOR $2; _value NUMERIC; BEGIN SELECT summTransC(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value; RETURN _value; END; $_$; ALTER FUNCTION public.summtransc(integer, integer) OWNER TO admin; -- -- Name: summtransc(integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summtransc(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDAte ALIAS FOR $3; _value NUMERIC; BEGIN SELECT SUM(invhist_invqty) INTO _value FROM invhist WHERE ((invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) AND (invhist_transtype IN ('SI')) AND (invhist_itemsite_id=pItemsiteid)); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; ALTER FUNCTION public.summtransc(integer, date, date) OWNER TO admin; -- -- Name: summtransi(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summtransi(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pCalitemid ALIAS FOR $2; _value NUMERIC; BEGIN SELECT summTransI(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value; RETURN _value; END; $_$; ALTER FUNCTION public.summtransi(integer, integer) OWNER TO admin; -- -- Name: summtransi(integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summtransi(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _value NUMERIC; BEGIN SELECT SUM(invhist_invqty) INTO _value FROM invhist WHERE ((invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) AND (invhist_transtype IN ('IM', 'IC')) AND (invhist_itemsite_id=pItemsiteid)); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; ALTER FUNCTION public.summtransi(integer, date, date) OWNER TO admin; -- -- Name: summtransr(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summtransr(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pCalitemid ALIAS FOR $2; _value NUMERIC; BEGIN SELECT summTransR(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value; RETURN _value; END; $_$; ALTER FUNCTION public.summtransr(integer, integer) OWNER TO admin; -- -- Name: summtransr(integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summtransr(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _value NUMERIC; BEGIN SELECT SUM(invhist_invqty) INTO _value FROM invhist WHERE ((invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) AND (invhist_transtype IN ('RM', 'RP', 'RX')) AND (invhist_itemsite_id=pItemsiteid) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; ALTER FUNCTION public.summtransr(integer, date, date) OWNER TO admin; -- -- Name: summtranss(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summtranss(pitemsiteid integer, pcalitemid integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pCalitemid ALIAS FOR $2; _value NUMERIC; BEGIN SELECT summTransS(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value; RETURN _value; END; $_$; ALTER FUNCTION public.summtranss(pitemsiteid integer, pcalitemid integer) OWNER TO admin; -- -- Name: summtranss(integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summtranss(pitemsiteid integer, pstartdate date, penddate date) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _value NUMERIC; BEGIN SELECT SUM( CASE WHEN (invhist_transtype = 'RS') THEN (invhist_invqty * -1) ELSE (invhist_invqty) END ) INTO _value FROM invhist WHERE ( (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) AND (invhist_transtype IN ('SC', 'SH', 'SV', 'RS')) AND (invhist_ordtype != 'TO') AND (invhist_itemsite_id=pItemsiteid) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $$; ALTER FUNCTION public.summtranss(pitemsiteid integer, pstartdate date, penddate date) OWNER TO admin; -- -- Name: summtranst(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summtranst(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pCalitemid ALIAS FOR $2; _value NUMERIC; BEGIN SELECT summTransT(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value; RETURN _value; END; $_$; ALTER FUNCTION public.summtranst(integer, integer) OWNER TO admin; -- -- Name: summtranst(integer, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION summtranst(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _value NUMERIC; BEGIN SELECT SUM( CASE WHEN (invhist_transtype = 'TS') THEN (invhist_invqty * -1) ELSE (invhist_invqty) END ) INTO _value FROM invhist WHERE ( (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) AND (invhist_transtype IN ('TS', 'TR', 'TW')) AND (invhist_itemsite_id=pItemsiteid) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; ALTER FUNCTION public.summtranst(integer, date, date) OWNER TO admin; -- -- Name: taxassignments(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION taxassignments(integer, integer) RETURNS SETOF taxassign LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxZoneId ALIAS FOR $1; pTaxTypeId ALIAS FOR $2; _row taxassign%ROWTYPE; _qry text; _x RECORD; _y RECORD; _z RECORD; BEGIN _qry = 'SELECT DISTINCT COALESCE(taxass_taxzone_id, -1) AS taxass_taxzone_id, COALESCE(taxass_taxtype_id, -1) AS taxass_taxtype_id, '; _qry = _qry || 'taxzone_code, taxtype_name FROM taxass LEFT OUTER JOIN taxzone ON (taxass_taxzone_id=taxzone_id) '; _qry = _qry || 'LEFT OUTER JOIN taxtype ON (taxass_taxtype_id=taxtype_id) '; IF ((pTaxZoneId > 0) OR (pTaxTypeId > 0)) THEN _qry := _qry || ' WHERE '; IF (pTaxZoneId > 0) THEN _qry := _qry || ' (taxass_taxzone_id = ' || pTaxZoneId ||')'; IF (pTaxTypeId > 0) THEN _qry := _qry || ' AND '; END IF; END IF; IF (pTaxTypeId > 0) THEN _qry := _qry || ' (taxass_taxtype_id = ' || pTaxTypeId || ')'; END IF; END IF; --This first query gets all the distinct tax zone and type groupings as if it were its own table. --This allows us to have a level 0 record as pictured in Tax Assignments window that code assignements will --Subordinate to. FOR _x IN EXECUTE _qry LOOP --Map values to _row here _row.taxassign_taxzone_id = _x.taxass_taxzone_id; _row.taxassign_taxtype_id = _x.taxass_taxtype_id; _row.taxassign_level = 0; _row.taxassign_zone_code = _x.taxzone_code; _row.taxassign_type_descrip = _x.taxtype_name; _row.taxassign_taxclass_code = ''; _row.taxassign_taxclass_sequence = NULL; RETURN NEXT _row; --so we get a level tax zone/type 0 record. -- Now get all the tax code assignments that belong to this Zone and Type pair FOR _y IN SELECT taxass_id, COALESCE(taxzone_id, -1) AS taxzone_id, tax_id, tax_code, tax_descrip, COALESCE(taxtype_id, -1) AS taxtype_id, taxzone_code, taxtype_descrip, taxclass_code, COALESCE(taxclass_sequence, 0) AS taxclass_sequence FROM taxass JOIN tax LEFT OUTER JOIN taxclass ON (tax_taxclass_id = taxclass_id) ON (taxass_tax_id = tax_id) LEFT OUTER JOIN taxzone ON (taxass_taxzone_id = taxzone_id) LEFT OUTER JOIN taxtype ON (taxass_taxtype_id = taxtype_id) WHERE COALESCE(taxass_taxzone_id, -1) = _x.taxass_taxzone_id AND COALESCE(taxass_taxtype_id, -1) = _x.taxass_taxtype_id LOOP --Map results to _row _row.taxassign_taxzone_id = _y.taxzone_id; _row.taxassign_taxtype_id = _y.taxtype_id; _row.taxassign_level = 1; _row.taxassign_zone_code = _y.tax_code; _row.taxassign_type_descrip = _y.tax_descrip; _row.taxassign_taxclass_code = _y.taxclass_code; _row.taxassign_taxclass_sequence = _y.taxclass_sequence; RETURN NEXT _row; --to get code detail record; FOR _z IN SELECT * FROM getsubtax(_y.tax_id, 1) --a new recursive function described above LOOP --Map results to _row _row.taxassign_taxzone_id = _y.taxzone_id; _row.taxassign_taxtype_id = _y.taxtype_id; _row.taxassign_level = _z.subtax_taxcode_level; _row.taxassign_zone_code = _z.subtax_taxcode_code; _row.taxassign_type_descrip = _z.subtax_taxcode_descrip; _row.taxassign_taxclass_code = _y.taxclass_code; _row.taxassign_taxclass_sequence = _y.taxclass_sequence; RETURN NEXT _row; END LOOP; END LOOP; END LOOP; END; $_$; ALTER FUNCTION public.taxassignments(integer, integer) OWNER TO admin; -- -- Name: thawaccountingperiod(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION thawaccountingperiod(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodid ALIAS FOR $1; _r RECORD; BEGIN -- Check to make sure that the period is frozen IF ( ( SELECT (NOT period_freeze) FROM period WHERE (period_id=pPeriodid) ) ) THEN RETURN -2; END IF; -- Check to make sure that the period is not closed IF ( ( SELECT (period_closed) FROM period WHERE (period_id=pPeriodid) ) ) THEN RETURN -1; END IF; -- Reset the period_freeze flag UPDATE period SET period_freeze=FALSE WHERE (period_id=pPeriodid); -- Post any unposted G/L Transactions into the period FOR _r IN SELECT DISTINCT gltrans_sequence FROM gltrans, accnt, period WHERE ( (gltrans_accnt_id=accnt_id) AND (NOT gltrans_posted) AND (gltrans_date BETWEEN period_start AND period_end) AND (period_id=pPeriodid) ) LOOP PERFORM postIntoTrialBalance(_r.gltrans_sequence); END LOOP; RETURN pPeriodid; END; $_$; ALTER FUNCTION public.thawaccountingperiod(integer) OWNER TO admin; -- -- Name: thawitemsite(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION thawitemsite(pitemsiteid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _qoh NUMERIC := 0; _value NUMERIC := 0; _itemlocid INTEGER; _itemloc RECORD; _invhist RECORD; _coarse RECORD; _fine RECORD; BEGIN IF ( SELECT itemsite_freeze FROM itemsite WHERE (itemsite_id=pItemsiteid) ) THEN SELECT invhist_id INTO _invhist FROM invhist WHERE ( (invhist_itemsite_id=pItemsiteid) AND (NOT invhist_posted) ) LIMIT 1; IF (NOT FOUND) THEN -- no inventory transactions to thaw, update itemsite and return UPDATE itemsite SET itemsite_freeze=FALSE WHERE (itemsite_id=pItemsiteid); RETURN pItemsiteid; END IF; -- Run through any invdetail if this itemsite is still MLC and/or Lot/Serial IF ( SELECT ( (itemsite_loccntrl) OR (itemsite_controlmethod IN ('L', 'S')) ) FROM itemsite WHERE (itemsite_id=pItemsiteid) ) THEN -- Grab all of the itemsite/location/lot/serial combinations -- that have unposted detail FOR _coarse IN SELECT DISTINCT invdetail_location_id, invdetail_ls_id, invdetail_expiration, invdetail_warrpurc FROM invhist, invdetail WHERE ( (invdetail_invhist_id=invhist_id) AND (NOT invhist_posted) AND (invhist_itemsite_id=pItemsiteid) ) ORDER BY invdetail_location_id, invdetail_ls_id LOOP -- Cache the initial qty of the itemloc specified by the -- itemsite/location/lot/serial SELECT itemloc_id, itemloc_qty INTO _itemloc FROM itemloc WHERE ( (itemloc_itemsite_id=pItemsiteid) AND (itemloc_location_id=_coarse.invdetail_location_id) AND (COALESCE(itemloc_ls_id,-1)=COALESCE(_coarse.invdetail_ls_id,-1)) AND (COALESCE(itemloc_expiration,endOfTime())=COALESCE(_coarse.invdetail_expiration,endOfTime())) AND (COALESCE(itemloc_warrpurc,endOfTime())=COALESCE(_coarse.invdetail_warrpurc,endOfTime())) ); -- If the itemloc in question cannot be found, create it IF (NOT FOUND) THEN SELECT NEXTVAL('itemloc_itemloc_id_seq') INTO _itemlocid; INSERT INTO itemloc ( itemloc_id, itemloc_itemsite_id, itemloc_location_id, itemloc_ls_id, itemloc_qty, itemloc_expiration ) VALUES ( _itemlocid, pItemsiteid, _coarse.invdetail_location_id, _coarse.invdetail_ls_id, 0, endOfTime() ); _qoh := 0.0; ELSE _itemlocid := _itemloc.itemloc_id; _qoh := _itemloc.itemloc_qty; END IF; -- Now step through each unposted invdetail record for a given -- itemsite/location/lot/serial FOR _fine IN SELECT invdetail_id, invdetail_qty FROM invhist, invdetail WHERE ( (invdetail_invhist_id=invhist_id) AND (NOT invhist_posted) AND (invhist_itemsite_id=pItemsiteid) AND (invdetail_location_id=_coarse.invdetail_location_id) AND (COALESCE(invdetail_ls_id,-1)=COALESCE(_coarse.invdetail_ls_id,-1)) AND (COALESCE(invdetail_expiration,endOfTime())=COALESCE(_coarse.invdetail_expiration,endOfTime())) AND (COALESCE(invdetail_warrpurc,endOfTime())=COALESCE(_coarse.invdetail_warrpurc,endOfTime())) ) ORDER BY invhist_transdate LOOP -- Update the running qoh fields in the detail record UPDATE invdetail SET invdetail_qty_before = _qoh, invdetail_qty_after = (_qoh + invdetail_qty) WHERE (invdetail_id=_fine.invdetail_id); -- Update the running qoh _qoh = (_qoh + _fine.invdetail_qty); END LOOP; -- If the running qoh end up at 0, delete the itemloc in question IF (_qoh = 0) THEN DELETE FROM itemloc WHERE (itemloc_id=_itemlocid); -- Otherwise, update the itemloc in question with the resultant qty ELSE UPDATE itemloc SET itemloc_qty=_qoh WHERE (itemloc_id=_itemlocid); END IF; END LOOP; END IF; -- Cache the inital qoh of the itemsite SELECT itemsite_qtyonhand, itemsite_value INTO _qoh, _value FROM itemsite WHERE (itemsite_id=pItemsiteid); -- We have to un-freeze the itemsite before update-ing its QOH -- so that that itemsite trigger won't block the QOH update. -- Also so the invhist trigger won't block the posted update. UPDATE itemsite SET itemsite_freeze=FALSE WHERE (itemsite_id=pItemsiteid); FOR _invhist IN SELECT invhist_id, invhist_qoh_before, invhist_qoh_after, invhist_value_before, invhist_value_after FROM invhist WHERE((invhist_itemsite_id=pItemsiteid) AND (NOT invhist_posted)) ORDER BY invhist_transdate LOOP UPDATE invhist SET invhist_qoh_before = _qoh, invhist_qoh_after = ( _qoh + _invhist.invhist_qoh_after - _invhist.invhist_qoh_before ), invhist_value_before = _value, invhist_value_after = ( _value + _invhist.invhist_value_after - _invhist.invhist_value_before ), invhist_posted = TRUE WHERE (invhist_id=_invhist.invhist_id); _qoh := (_qoh + (_invhist.invhist_qoh_after - _invhist.invhist_qoh_before)); _value := (_value + (_invhist.invhist_value_after - _invhist.invhist_value_before)); END LOOP; UPDATE itemsite SET itemsite_qtyonhand = _qoh, itemsite_value = CASE WHEN ((itemsite_costmethod='A') AND (_value < 0.0)) THEN 0.0 ELSE _value END WHERE(itemsite_id=pItemsiteid); END IF; RETURN pItemsiteid; END; $$; ALTER FUNCTION public.thawitemsite(pitemsiteid integer) OWNER TO admin; -- -- Name: todoitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE todoitem ( todoitem_id integer NOT NULL, todoitem_name text NOT NULL, todoitem_description text, todoitem_incdt_id integer, todoitem_creator_username text DEFAULT geteffectivextuser() NOT NULL, todoitem_status character(1), todoitem_active boolean DEFAULT true NOT NULL, todoitem_start_date date, todoitem_due_date date, todoitem_assigned_date date, todoitem_completed_date date, todoitem_seq integer DEFAULT 0 NOT NULL, todoitem_notes text, todoitem_crmacct_id integer, todoitem_ophead_id integer, todoitem_owner_username text, todoitem_priority_id integer, todoitem_username text, todoitem_recurring_todoitem_id integer, todoitem_cntct_id integer ); ALTER TABLE todoitem OWNER TO admin; -- -- Name: TABLE todoitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE todoitem IS 'To-Do List items.'; -- -- Name: COLUMN todoitem.todoitem_recurring_todoitem_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN todoitem.todoitem_recurring_todoitem_id IS 'The first todoitem record in the series if this is a recurring To-Do item. If the todoitem_recurring_todoitem_id is the same as the todoitem_id, this record is the first in the series.'; -- -- Name: todoitem(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION todoitem() RETURNS SETOF todoitem LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row todoitem%ROWTYPE; _priv TEXT; _grant BOOLEAN; BEGIN -- This query will give us the most permissive privilege the user has been granted SELECT privilege, granted INTO _priv, _grant FROM privgranted WHERE privilege IN ('MaintainAllToDoItems','ViewAllToDoItems','MaintainPersonalToDoItems','ViewPersonalToDoItems') ORDER BY granted DESC, sequence LIMIT 1; -- If have an 'All' privilege return all results IF (_priv ~ 'All' AND _grant) THEN FOR _row IN SELECT * FROM todoitem LOOP RETURN NEXT _row; END LOOP; -- Otherwise if have any other grant, must be personal privilege. ELSIF (_grant) THEN FOR _row IN SELECT * FROM todoitem WHERE getEffectiveXtUser() IN (todoitem_owner_username, todoitem_username) LOOP RETURN NEXT _row; END LOOP; END IF; RETURN; END; $$; ALTER FUNCTION public.todoitem() OWNER TO admin; -- -- Name: FUNCTION todoitem(); Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON FUNCTION todoitem() IS 'A table function that returns To Do Items results according to privilege settings.'; -- -- Name: todoitemmove(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION todoitemmove(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ptodoItemId ALIAS FOR $1; pHowFar ALIAS FOR $2; -- -1 moves toward front of list, +1 toward back _howFar INTEGER := pHowFar; _username TEXT; _currseq INTEGER; BEGIN SELECT todoitem_username, todoitem_seq INTO _username, _currseq FROM todoitem WHERE todoitem_id = ptodoItemId; IF NOT FOUND THEN RETURN -1; END IF; IF (_currseq + pHowFar <= 0) THEN _howFar = 1 - _currseq; -- move to beginning END IF; UPDATE todoitem SET todoitem_seq=todoitem_seq - _howFar WHERE todoitem_seq >= _currseq + _howFar AND todoitem_id != ptodoItemId AND todoitem_username = _username AND todoitem_status != 'C'; UPDATE todoitem SET todoitem_seq=_currseq + _howFar WHERE todoitem_id = ptodoItemId; RETURN 0; END; $_$; ALTER FUNCTION public.todoitemmove(integer, integer) OWNER TO admin; -- -- Name: todoitemmovedown(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION todoitemmovedown(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ptodoItemId ALIAS FOR $1; BEGIN RETURN todoItemMove(ptodoItemId, 1); -- move toward end of list END; $_$; ALTER FUNCTION public.todoitemmovedown(integer) OWNER TO admin; -- -- Name: todoitemmoveup(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION todoitemmoveup(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ptodoItemId ALIAS FOR $1; BEGIN RETURN todoItemMove(ptodoItemId, -1); -- move toward front of list END; $_$; ALTER FUNCTION public.todoitemmoveup(integer) OWNER TO admin; -- -- Name: togglebankreccleared(integer, text, integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION togglebankreccleared(integer, text, integer, numeric) RETURNS boolean LANGUAGE plpgsql AS $_$ DECLARE pBankrecid ALIAS FOR $1; pSource ALIAS FOR $2; pSourceid ALIAS FOR $3; pCurrrate ALIAS FOR $4; _cleared BOOLEAN; _r RECORD; BEGIN SELECT bankrecitem_id, bankrecitem_cleared INTO _r FROM bankrecitem WHERE ( (bankrecitem_bankrec_id=pBankrecid) AND (bankrecitem_source=pSource) AND (bankrecitem_source_id=pSourceid) ); IF ( NOT FOUND ) THEN _cleared := TRUE; INSERT INTO bankrecitem (bankrecitem_bankrec_id, bankrecitem_source, bankrecitem_source_id, bankrecitem_cleared, bankrecitem_curr_rate) VALUES (pBankrecid, pSource, pSourceid, _cleared, pCurrrate); ELSE _cleared := (NOT _r.bankrecitem_cleared); UPDATE bankrecitem SET bankrecitem_cleared=_cleared, bankrecitem_curr_rate=pCurrrate WHERE (bankrecitem_id=_r.bankrecitem_id); END IF; RETURN _cleared; END; $_$; ALTER FUNCTION public.togglebankreccleared(integer, text, integer, numeric) OWNER TO admin; -- -- Name: togglebankreccleared(integer, text, integer, numeric, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION togglebankreccleared(pbankrecid integer, psource text, psourceid integer, pcurrrate numeric, pbaseamount numeric) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN toggleBankrecCleared(pBankrecid, pSource, pSourceid, pCurrrate, pBaseAmount, NULL); END; $$; ALTER FUNCTION public.togglebankreccleared(pbankrecid integer, psource text, psourceid integer, pcurrrate numeric, pbaseamount numeric) OWNER TO admin; -- -- Name: togglebankreccleared(integer, text, integer, numeric, numeric, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION togglebankreccleared(pbankrecid integer, psource text, psourceid integer, pcurrrate numeric, pbaseamount numeric, pdate date) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cleared BOOLEAN; _r RECORD; BEGIN SELECT bankrecitem_id, bankrecitem_cleared INTO _r FROM bankrecitem WHERE ( (bankrecitem_bankrec_id=pBankrecid) AND (bankrecitem_source=pSource) AND (bankrecitem_source_id=pSourceid) ); IF ( NOT FOUND ) THEN _cleared := TRUE; INSERT INTO bankrecitem (bankrecitem_bankrec_id, bankrecitem_source, bankrecitem_source_id, bankrecitem_cleared, bankrecitem_curr_rate, bankrecitem_amount, bankrecitem_effdate) VALUES (pBankrecid, pSource, pSourceid, _cleared, CASE WHEN (fetchMetricValue('CurrencyExchangeSense') = 1) THEN ROUND(1.0 / pCurrrate, 8) ELSE ROUND(pCurrrate,8) END, CASE WHEN (fetchMetricValue('CurrencyExchangeSense') = 1) THEN ROUND(pBaseAmount * ROUND(1.0 / pCurrrate,8),2) ELSE ROUND(pBaseAmount * ROUND(pCurrrate,8),2) END, pDate); ELSE _cleared := FALSE; DELETE FROM bankrecitem WHERE bankrecitem_id = _r.bankrecitem_id; END IF; RETURN _cleared; END; $$; ALTER FUNCTION public.togglebankreccleared(pbankrecid integer, psource text, psourceid integer, pcurrrate numeric, pbaseamount numeric, pdate date) OWNER TO admin; -- -- Name: togglebomitemcost(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION togglebomitemcost(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBomitemid ALIAS FOR $1; pEnabled ALIAS FOR $2; BEGIN IF (pEnabled) THEN INSERT INTO bomitemcost (bomitemcost_bomitem_id, bomitemcost_costelem_id, bomitemcost_lowlevel, bomitemcost_stdcost, bomitemcost_posted, bomitemcost_actcost, bomitemcost_updated, bomitemcost_curr_id) SELECT bomitem_id, itemcost_costelem_id, itemcost_lowlevel, itemcost_stdcost, itemcost_posted, itemcost_actcost, itemcost_updated, itemcost_curr_id FROM bomitem JOIN itemcost ON (itemcost_item_id=bomitem_item_id) WHERE (bomitem_id=pBomitemid); ELSE DELETE FROM bomitemcost WHERE (bomitemcost_bomitem_id=pBomitemid); END IF; RETURN 0; END; $_$; ALTER FUNCTION public.togglebomitemcost(integer, boolean) OWNER TO admin; -- -- Name: tonumeric(text, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION tonumeric(text, numeric) RETURNS numeric LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pText ALIAS FOR $1; pDefault ALIAS FOR $2; BEGIN IF (isNumeric(pText)) THEN RETURN TO_NUMBER(pText, '999999999999'); ELSE RETURN pDefault; END IF; END; $_$; ALTER FUNCTION public.tonumeric(text, numeric) OWNER TO admin; -- -- Name: transitwhs(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION transitwhs() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _id INTEGER; BEGIN _id = fetchMetricValue('TransitWarehouse'); IF (_id IS NOT NULL AND EXISTS(SELECT warehous_id FROM whsinfo WHERE (warehous_id=_id)) ) THEN RETURN _id; END IF; SELECT warehous_id INTO _id FROM whsinfo WHERE warehous_transit; IF (NOT FOUND) THEN _id := NEXTVAL('warehous_warehous_id_seq'); INSERT INTO whsinfo ( warehous_id, warehous_code, warehous_descrip, --warehous_fob, warehous_active, --warehous_counttag_prefix, --warehous_counttag_number, --warehous_bol_prefix, --warehous_bol_number, warehous_shipping, warehous_useslips, warehous_usezones, --warehous_aislesize, --warehous_aislealpha, --warehous_racksize, --warehous_rackalpha, --warehous_binsize, --warehous_binalpha, --warehous_locationsize, --warehous_locationalpha, warehous_enforcearbl, warehous_default_accnt_id, --warehous_shipping_commission, --warehous_cntct_id, --warehous_addr_id, warehous_taxzone_id ) VALUES ( _id, 'TRANSIT', 'Intermediate Warehouse for Inter-Warehouse Transfers', --text, TRUE, --text, --integer, --text, --integer, TRUE, FALSE, FALSE, --integer, --boolean, --integer, --boolean, --integer, --boolean, --integer, --boolean, FALSE, fetchMetricValue('UnassignedAccount'), --numeric(8,4) default 0.00, --integer, --integer, NULL ); END IF; PERFORM setMetric('TransitWarehouse', _id); RETURN _id; END; $$; ALTER FUNCTION public.transitwhs() OWNER TO admin; -- -- Name: transtype(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION transtype(text, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTransType ALIAS FOR $1; pTargetType ALIAS FOR $2; BEGIN IF (pTargetType = 255) THEN RETURN TRUE; ELSIF (pTargetType = 1) THEN RETURN receipts(pTransType); ELSIF (pTargetType = 2) THEN RETURN issues(pTransType); ELSIF (pTargetType = 4) THEN RETURN shipments(pTransType); ELSIF (pTargetType = 8) THEN RETURN adjustments(pTransType); ELSIF (pTargetType = 16) THEN RETURN transfers(pTransType); ELSIF (pTargetType = 32) THEN RETURN scraps(pTransType); ELSE RETURN TRUE; END IF; END; $_$; ALTER FUNCTION public.transtype(text, integer) OWNER TO admin; -- -- Name: trylock(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION trylock(integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pKey1 ALIAS FOR $1; pKey2 ALIAS FOR $2; _pid integer; BEGIN /* The standard try lock ignores locks made by the current user in same session. Check for ANY lock on this id, whether by this user or not */ SELECT pid INTO _pid FROM pg_locks WHERE ((classid=pKey1) AND (objid=pKey2) AND (objsubid=2)); IF (FOUND) THEN RETURN false; ELSE RETURN pg_try_advisory_lock(pKey1,pKey2); END IF; END; $_$; ALTER FUNCTION public.trylock(integer, integer) OWNER TO admin; -- -- Name: undomerge(text, text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION undomerge(text, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSchema ALIAS FOR $1; pTable ALIAS FOR $2; pId ALIAS FOR $3; _qry TEXT; _r RECORD; _result INTEGER; BEGIN FOR _r IN SELECT * FROM mrgundo WHERE mrgundo_base_schema = pSchema AND mrgundo_base_table = pTable AND mrgundo_base_id = pId AND mrgundo_col IS NOT NULL -- NULL mrgundo_col signals a row to delete on purge LOOP IF (_r.mrgundo_value IS NULL) THEN _qry := 'UPDATE ' || quote_ident(_r.mrgundo_schema) || '.' || quote_ident(_r.mrgundo_table) || ' SET ' || quote_ident(_r.mrgundo_col) || '= NULL WHERE (' || _r.mrgundo_pkey_col || '=' || _r.mrgundo_pkey_id || ');'; ELSE _qry := 'UPDATE ' || quote_ident(_r.mrgundo_schema) || '.' || quote_ident(_r.mrgundo_table) || ' SET ' || quote_ident(_r.mrgundo_col) || '= CAST(' || quote_literal(_r.mrgundo_value) || ' AS ' || quote_ident(_r.mrgundo_type) || ') WHERE (' || _r.mrgundo_pkey_col || '=' || _r.mrgundo_pkey_id || ');'; END IF; EXECUTE _qry; END LOOP; DELETE FROM mrgundo WHERE mrgundo_base_schema = pSchema AND mrgundo_base_table = pTable AND mrgundo_base_id = pId; GET DIAGNOSTICS _result = ROW_COUNT; RETURN _result; END; $_$; ALTER FUNCTION public.undomerge(text, text, integer) OWNER TO admin; -- -- Name: unreleasepurchaseorder(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION unreleasepurchaseorder(ppoheadid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF ( ( SELECT (COUNT(*) > 0) FROM poitem LEFT OUTER JOIN recv ON (recv_order_type='PO' AND recv_orderitem_id=poitem_id) WHERE ( (poitem_pohead_id=pPoheadid) AND ( (poitem_status='C') OR (poitem_qty_received > 0.0) OR (poitem_qty_returned > 0.0) OR (poitem_qty_vouchered > 0.0) OR (recv_id IS NOT NULL) ) ) ) ) THEN RETURN -1; END IF; IF ( ( SELECT (pohead_status='O') FROM pohead WHERE (pohead_id=pPoheadid) ) ) THEN --update status and erase the date that the order was released on UPDATE pohead SET pohead_status='U', pohead_released = NULL WHERE (pohead_id=pPoheadid); END IF; --update status and erase the duedates at release UPDATE poitem SET poitem_status='U', poitem_rlsd_duedate = NULL WHERE (poitem_pohead_id=pPoheadid); RETURN 1; END; $$; ALTER FUNCTION public.unreleasepurchaseorder(ppoheadid integer) OWNER TO admin; -- -- Name: uomusedforitem(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION uomusedforitem(integer) RETURNS SETOF uom LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pitemid ALIAS FOR $1; _row uom%ROWTYPE; BEGIN FOR _row IN SELECT DISTINCT * FROM uom WHERE uom_id IN ( SELECT bomitem_uom_id AS uom_id FROM bomitem WHERE (bomitem_item_id=pitemid) UNION SELECT cmitem_qty_uom_id FROM cmitem, itemsite WHERE ((cmitem_itemsite_id=itemsite_id) AND (itemsite_item_id=pitemid)) UNION SELECT cmitem_price_uom_id FROM cmitem, itemsite WHERE ((cmitem_itemsite_id=itemsite_id) AND (itemsite_item_id=pitemid)) UNION SELECT coitem_qty_uom_id FROM coitem, itemsite WHERE ((coitem_itemsite_id=itemsite_id) AND (itemsite_item_id=pitemid)) UNION SELECT coitem_price_uom_id FROM coitem, itemsite WHERE ((coitem_itemsite_id=itemsite_id) AND (itemsite_item_id=pitemid)) UNION SELECT invcitem_qty_uom_id FROM invcitem WHERE ((invcitem_item_id=pitemid)) UNION SELECT invcitem_price_uom_id FROM invcitem WHERE ((invcitem_item_id=pitemid)) UNION SELECT ipsitem_qty_uom_id FROM ipsiteminfo WHERE (ipsitem_item_id=pitemid) UNION SELECT ipsitem_price_uom_id FROM ipsiteminfo WHERE (ipsitem_item_id=pitemid) UNION SELECT quitem_qty_uom_id FROM quitem, itemsite WHERE ((quitem_itemsite_id=itemsite_id) AND (itemsite_item_id=pitemid)) UNION SELECT quitem_price_uom_id FROM quitem, itemsite WHERE ((quitem_itemsite_id=itemsite_id) AND (itemsite_item_id=pitemid)) UNION SELECT womatl_uom_id FROM womatl, itemsite WHERE ((womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=pitemid)) ) LOOP RETURN NEXT _row; END LOOP; IF (fetchmetricbool('MultiWhs')) THEN FOR _row IN SELECT DISTINCT * FROM uom WHERE uom_id IN ( SELECT rahist_uom_id FROM rahist, itemsite WHERE ((rahist_itemsite_id=itemsite_id) AND (itemsite_item_id=pitemid)) ) LOOP RETURN NEXT _row; END LOOP; END IF; RETURN; END; $_$; ALTER FUNCTION public.uomusedforitem(integer) OWNER TO admin; -- -- Name: updateabcclass(text, numeric, numeric, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updateabcclass(text, numeric, numeric, date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pClassCodePattern ALIAS FOR $1; pACutoff ALIAS FOR $2; pBCutoff ALIAS FOR $3; pStartDate ALIAS FOR $4; pEndDate ALIAS FOR $5; _result INTEGER; BEGIN SELECT updateABCClass(pClassCodePattern, -1, pACutoff, pBCutoff, pStartDate, pEndDate) INTO _result; RETURN _result; END; $_$; ALTER FUNCTION public.updateabcclass(text, numeric, numeric, date, date) OWNER TO admin; -- -- Name: updateabcclass(integer, numeric, numeric, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updateabcclass(integer, numeric, numeric, date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pClasscodeid ALIAS FOR $1; pACutoff ALIAS FOR $2; pBCutoff ALIAS FOR $3; pStartDate ALIAS FOR $4; pEndDate ALIAS FOR $5; _result INTEGER; BEGIN SELECT updateABCClass(pClassCodeid, -1, pACutoff, pBCutoff, pStartDate, pEndDate) INTO _result; RETURN _result; END; $_$; ALTER FUNCTION public.updateabcclass(integer, numeric, numeric, date, date) OWNER TO admin; -- -- Name: updateabcclass(text, integer, numeric, numeric, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updateabcclass(text, integer, numeric, numeric, date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pClassCodePattern ALIAS FOR $1; pWarehousid ALIAS FOR $2; pACutoff ALIAS FOR $3; pBCutoff ALIAS FOR $4; pStartDate ALIAS FOR $5; pEndDate ALIAS FOR $6; _updateCount INTEGER; _totalValue NUMERIC; _cumulativeValue NUMERIC; _itemsite RECORD; BEGIN SELECT COUNT(*) INTO _updateCount FROM itemsite, item, classcode WHERE ( (itemsite_item_id=item_id) AND (item_classcode_id=classcode_id) AND (itemsite_autoabcclass) AND (classcode_code ~ pClassCodePattern) AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) ); IF (_updateCount IS NULL) THEN RETURN 0; ELSE UPDATE itemsite SET itemsite_abcclass='T' FROM item, classcode WHERE ( (itemsite_item_id=item_id) AND (item_classcode_id=classcode_id) AND (itemsite_autoabcclass) AND (classcode_code ~ pClassCodePattern) AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) ); SELECT SUM(ABS(invhist_qoh_before - invhist_qoh_after) * invhist_unitcost) INTO _totalValue FROM invhist, itemsite, item, classcode WHERE ( (invhist_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_classcode_id=classcode_id) AND (invhist_analyze) AND (invhist_transtype ~ '^[IR]') AND (itemsite_autoabcclass) AND (classcode_code ~ pClassCodePattern) AND (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) ); IF ( (_totalValue IS NULL) OR (_totalValue = 0) ) THEN UPDATE itemsite SET itemsite_abcclass='A' WHERE (itemsite_abcclass='T'); ELSE _cumulativeValue := 0; FOR _itemsite IN SELECT itemsite_id, item_number, SUM(ABS(invhist_qoh_before - invhist_qoh_after) * invhist_unitcost) AS value FROM invhist, itemsite, item, classcode WHERE ( (invhist_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_classcode_id=classcode_id) AND (invhist_analyze) AND (invhist_transtype ~ '^[IR]') AND (itemsite_autoabcclass) AND (classcode_code ~ pClassCodePattern) AND (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) ) GROUP BY itemsite_id, item_number ORDER BY value DESC LOOP IF (_itemsite.value IS NOT NULL) THEN _cumulativeValue := _cumulativeValue + _itemsite.value; END IF; IF ((_cumulativeValue / _totalValue) <= pACutoff) THEN UPDATE itemsite SET itemsite_abcclass='A' WHERE (itemsite_id=_itemsite.itemsite_id); ELSE IF ((_cumulativeValue / _totalValue) <= pBCutoff) THEN UPDATE itemsite SET itemsite_abcclass='B' WHERE (itemsite_id=_itemsite.itemsite_id); ELSE UPDATE itemsite SET itemsite_abcclass='C' WHERE (itemsite_id=_itemsite.itemsite_id); END IF; END IF; END LOOP; UPDATE itemsite SET itemsite_abcclass='C' WHERE (itemsite_abcclass='T'); END IF; END IF; RETURN _updateCount; END; $_$; ALTER FUNCTION public.updateabcclass(text, integer, numeric, numeric, date, date) OWNER TO admin; -- -- Name: updateabcclass(integer, integer, numeric, numeric, date, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updateabcclass(integer, integer, numeric, numeric, date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pClasscodeid ALIAS FOR $1; pWarehousid ALIAS FOR $2; pACutoff ALIAS FOR $3; pBCutoff ALIAS FOR $4; pStartDate ALIAS FOR $5; pEndDate ALIAS FOR $6; _updateCount INTEGER; _totalValue NUMERIC; _cumulativeValue NUMERIC; _itemsite RECORD; BEGIN SELECT COUNT(*) INTO _updateCount FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND ((item_classcode_id=pClasscodeid) OR (pClasscodeid=-1)) AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) ); IF (_updateCount IS NULL) THEN _updateCount := 0; ELSE UPDATE itemsite SET itemsite_abcclass='T' FROM item WHERE ( (itemsite_item_id=item_id) AND ((item_classcode_id=pClasscodeid) OR (pClasscodeid=-1)) AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) ); SELECT SUM(ABS(invhist_qoh_before - invhist_qoh_after) * invhist_unitcost) INTO _totalValue FROM invhist, itemsite, item WHERE ( (invhist_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (invhist_analyze) AND (invhist_transtype ~ '^[IR]') AND ((item_classcode_id=pClasscodeid) OR (pClasscodeid=-1)) AND (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) ); IF ( (_totalValue IS NULL) OR (_totalValue = 0) ) THEN UPDATE itemsite SET itemsite_abcclass='A' WHERE (itemsite_abcclass='T'); ELSE _cumulativeValue := 0; FOR _itemsite IN SELECT itemsite_id, item_number, SUM(ABS(invhist_qoh_before - invhist_qoh_after) * invhist_unitcost) AS value FROM invhist, itemsite, item WHERE ( (invhist_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (invhist_analyze) AND (invhist_transtype ~ '^[IR]') AND ((item_classcode_id=pClasscodeid) OR (pClasscodeid=-1)) AND (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) ) GROUP BY itemsite_id, item_number ORDER BY value DESC LOOP IF (_itemsite.value IS NOT NULL) THEN _cumulativeValue := _cumulativeValue + _itemsite.value; END IF; IF ((_cumulativeValue / _totalValue) <= pACutoff) THEN UPDATE itemsite SET itemsite_abcclass='A' WHERE (itemsite_id=_itemsite.itemsite_id); ELSE IF ((_cumulativeValue / _totalValue) <= pBCutoff) THEN UPDATE itemsite SET itemsite_abcclass='B' WHERE (itemsite_id=_itemsite.itemsite_id); ELSE UPDATE itemsite SET itemsite_abcclass='C' WHERE (itemsite_id=_itemsite.itemsite_id); END IF; END IF; END LOOP; UPDATE itemsite SET itemsite_abcclass='C' WHERE (itemsite_abcclass='T'); END IF; END IF; RETURN _updateCount; END; $_$; ALTER FUNCTION public.updateabcclass(integer, integer, numeric, numeric, date, date) OWNER TO admin; -- -- Name: updatecharassignment(text, integer, integer, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatecharassignment(text, integer, integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTargetType ALIAS FOR $1; pTargetId ALIAS FOR $2; pCharId ALIAS FOR $3; pValue ALIAS FOR $4; _charassid INTEGER; BEGIN SELECT updateCharAssignment(pTargetType, pTargetId, pCharId, pValue, 0) INTO _charassid; RETURN _charassid; END; $_$; ALTER FUNCTION public.updatecharassignment(text, integer, integer, text) OWNER TO admin; -- -- Name: updatecharassignment(text, integer, integer, text, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatecharassignment(text, integer, integer, text, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTargetType ALIAS FOR $1; pTargetId ALIAS FOR $2; pCharId ALIAS FOR $3; pValue ALIAS FOR $4; pPrice ALIAS FOR $5; _charassid INTEGER; _charassprice NUMERIC; _explodedJob BOOLEAN = FALSE; _value TEXT; BEGIN -- Check for Valid Assignment IF (pTargetType='SI') THEN SELECT (item_config AND wo_status != 'O') INTO _explodedJob FROM coitem,itemsite,item,wo WHERE ((coitem_id=pTargetId) AND (itemsite_id=coitem_itemsite_id) AND (item_id=itemsite_item_id) AND (wo_ordtype='S') AND (wo_ordid=coitem_id)); END IF; SELECT charass_id,charass_value INTO _charassid, _value FROM charass WHERE ((charass_target_type=pTargetType) AND (charass_target_id=pTargetId) AND (charass_char_id=pCharId) ) LIMIT 1; IF (FOUND) THEN IF (_explodedJob AND pValue != _value) THEN RAISE EXCEPTION 'Characteristic may not be updated for Configured Item with exploded Work Order.'; ELSIF(COALESCE(pValue, '')!='') THEN UPDATE charass SET charass_value = pValue, charass_price = pPrice WHERE (charass_id=_charassid); ELSE DELETE FROM charass WHERE (charass_id=_charassid); _charassid := 0; END IF; ELSE IF ( (_explodedJob) AND (COALESCE(pValue, '')!='') ) THEN RAISE EXCEPTION 'Characteristics may not be updated for Configured Item with exploded Work Order.'; ELSIF(COALESCE(pValue, '')!='') THEN SELECT nextval('charass_charass_id_seq') INTO _charassid; INSERT INTO charass (charass_id, charass_target_type, charass_target_id, charass_char_id, charass_value, charass_price) VALUES(_charassid, pTargetType, pTargetId, pCharId, pValue, pPrice); ELSE _charassid := 0; END IF; END IF; RETURN _charassid; END; $_$; ALTER FUNCTION public.updatecharassignment(text, integer, integer, text, numeric) OWNER TO admin; -- -- Name: updatecost(integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatecost(integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemcostid ALIAS FOR $1; pCost ALIAS FOR $2; BEGIN RETURN updateCost(pItemcostid, pCost, baseCurrId()); END; $_$; ALTER FUNCTION public.updatecost(integer, numeric) OWNER TO admin; -- -- Name: updatecost(integer, numeric, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatecost(integer, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemcostid ALIAS FOR $1; pCost ALIAS FOR $2; pCurrId ALIAS FOR $3; BEGIN IF ( ( SELECT (itemcost_stdcost > 0) FROM itemcost WHERE (itemcost_id=pItemcostid) ) OR (pCost > 0) ) THEN UPDATE itemcost SET itemcost_actcost=pCost, itemcost_updated=CURRENT_DATE, itemcost_curr_id=pCurrId WHERE (itemcost_id=pItemcostid); RETURN pItemcostid; ELSE DELETE FROM itemcost WHERE (itemcost_id=pItemcostid); RETURN -1; END IF; END; $_$; ALTER FUNCTION public.updatecost(integer, numeric, integer) OWNER TO admin; -- -- Name: updatecost(integer, text, boolean, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatecost(integer, text, boolean, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE returnVal INTEGER; BEGIN SELECT updateCost($1, $2, $3, $4, baseCurrId()) INTO returnVal; RETURN returnVal; END; $_$; ALTER FUNCTION public.updatecost(integer, text, boolean, numeric) OWNER TO admin; -- -- Name: updatecost(integer, integer, boolean, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatecost(integer, integer, boolean, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE returnVal INTEGER; BEGIN SELECT updateCost($1, $2, $3, $4, baseCurrId()) INTO returnVal; RETURN returnVal; END; $_$; ALTER FUNCTION public.updatecost(integer, integer, boolean, numeric) OWNER TO admin; -- -- Name: updatecost(integer, text, boolean, numeric, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatecost(integer, text, boolean, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCosttype ALIAS FOR $2; pLevel ALIAS FOR $3; pCost ALIAS FOR $4; pCurrid ALIAS FOR $5; _cost NUMERIC; _currId INTEGER; _p RECORD; _itemcostid INTEGER; BEGIN IF (pCost IS NULL) THEN _cost = 0; ELSE _cost = pCost; END IF; IF (pCurrId IS NULL) THEN _currId := baseCurrID(); ELSE _currId := pCurrId; END IF; SELECT itemcost_id, itemcost_stdcost INTO _p FROM itemcost, costelem WHERE ( (itemcost_costelem_id=costelem_id) AND (itemcost_item_id=pItemid) AND (itemcost_lowlevel=pLevel) AND (costelem_type=pCosttype) ); IF (NOT FOUND) THEN IF (_cost > 0) THEN SELECT NEXTVAL('itemcost_itemcost_id_seq') INTO _itemcostid; INSERT INTO itemcost ( itemcost_id, itemcost_item_id, itemcost_costelem_id, itemcost_lowlevel, itemcost_stdcost, itemcost_posted, itemcost_actcost, itemcost_updated, itemcost_curr_id ) SELECT _itemcostid, pItemid, costelem_id, pLevel, 0, startOfTime(), _cost, CURRENT_DATE, _currId FROM costelem WHERE (costelem_type=pCosttype); RETURN _itemcostid; ELSE RETURN -1; END IF; ELSIF ( (_p.itemcost_stdcost > 0) OR (_cost > 0) ) THEN UPDATE itemcost SET itemcost_actcost=_cost, itemcost_curr_id = _currId, itemcost_updated=CURRENT_DATE WHERE (itemcost_id=_p.itemcost_id); RETURN _p.itemcost_id; ELSE DELETE FROM itemcost WHERE (itemcost_id=_p.itemcost_id); RETURN -1; END IF; END; $_$; ALTER FUNCTION public.updatecost(integer, text, boolean, numeric, integer) OWNER TO admin; -- -- Name: updatecost(integer, integer, boolean, numeric, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatecost(integer, integer, boolean, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCostelemid ALIAS FOR $2; pLevel ALIAS FOR $3; pCost ALIAS FOR $4; pCurrid ALIAS FOR $5; _cost NUMERIC; _currId INTEGER; _p RECORD; _itemcostid INTEGER; BEGIN IF (pCost IS NULL) THEN _cost = 0; ELSE _cost = pCost; END IF; IF (pCurrId IS NULL) THEN _currId := baseCurrID(); ELSE _currId := pCurrId; END IF; SELECT itemcost_id, itemcost_stdcost INTO _p FROM itemcost WHERE ((itemcost_costelem_id=pCostelemid) AND (itemcost_item_id=pItemid) AND (itemcost_lowlevel=pLevel) ); IF (NOT FOUND) THEN IF (_cost > 0) THEN SELECT NEXTVAL('itemcost_itemcost_id_seq') INTO _itemcostid; INSERT INTO itemcost ( itemcost_id, itemcost_item_id, itemcost_costelem_id, itemcost_lowlevel, itemcost_stdcost, itemcost_posted, itemcost_actcost, itemcost_updated, itemcost_curr_id ) SELECT _itemcostid, pItemid, costelem_id, pLevel, 0, startOfTime(), _cost, CURRENT_DATE, _currId FROM costelem WHERE (costelem_id=pCostelemid); RETURN _itemcostid; ELSE RETURN -1; END IF; ELSIF ( (_p.itemcost_stdcost > 0) OR (_cost > 0) ) THEN UPDATE itemcost SET itemcost_actcost=_cost, itemcost_curr_id = _currId, itemcost_updated=CURRENT_DATE WHERE (itemcost_id=_p.itemcost_id); RETURN _p.itemcost_id; ELSE DELETE FROM itemcost WHERE (itemcost_id=_p.itemcost_id); RETURN -1; END IF; END; $_$; ALTER FUNCTION public.updatecost(integer, integer, boolean, numeric, integer) OWNER TO admin; -- -- Name: updatecreditmemoline(api.creditmemoline, api.creditmemoline); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatecreditmemoline(api.creditmemoline, api.creditmemoline) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNew ALIAS FOR $1; pOld ALIAS FOR $2; _check INTEGER; _r RECORD; BEGIN SELECT cmitem_id INTO _check FROM cmitem WHERE ( (cmitem_cmhead_id=getCmheadId(pOld.memo_number, FALSE)) AND (cmitem_linenumber=pOld.line_number) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Credit Memo # % Line Number # not found', pOld.memo_number, pOld.line_number; END IF; UPDATE cmitem SET cmitem_itemsite_id=COALESCE(itemsite_id, -1), cmitem_qtycredit=pNew.qty_to_credit, cmitem_qtyreturned=pNew.qty_returned, cmitem_unitprice=pNew.net_unit_price, cmitem_comments=pNew.notes, cmitem_rsncode_id=getRsnId(pNew.reason_code), cmitem_taxtype_id=taxtype_id, cmitem_qty_uom_id=COALESCE(getUomId(pNew.qty_uom), item_inv_uom_id), cmitem_qty_invuomratio=CASE WHEN item_id IS NOT NULL THEN itemuomtouomratio(item_id, COALESCE(getUomId(pNew.qty_uom),item_inv_uom_id),item_inv_uom_id) ELSE 1 END, cmitem_price_uom_id=COALESCE(getUomId(pNew.price_uom),item_price_uom_id), cmitem_price_invuomratio=CASE WHEN item_id IS NOT NULL THEN itemuomtouomratio(item_id, COALESCE(getUomId(pNew.price_uom),item_price_uom_id),item_price_uom_id) ELSE 1 END FROM cmhead LEFT OUTER JOIN item ON (item_id=getItemId(pNew.item_number)) LEFT OUTER JOIN itemsite ON (itemsite_item_id=item_id AND itemsite_warehous_id=getWarehousId(pNew.recv_site, 'ALL')) LEFT OUTER JOIN taxtype ON (taxtype_id=CASE WHEN pNew.tax_type IS NULL THEN getItemTaxType(item_id,cmhead_taxzone_id) WHEN pNew.tax_type = 'None' THEN NULL ELSE getTaxTypeId(pNew.tax_type) END) WHERE cmitem_cmhead_id=cmhead_id AND cmhead_number=pOld.memo_number AND cmitem_linenumber=pOld.line_number AND cmhead_posted=FALSE; RETURN TRUE; END; $_$; ALTER FUNCTION public.updatecreditmemoline(api.creditmemoline, api.creditmemoline) OWNER TO admin; -- -- Name: updatecustomprivs(); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatecustomprivs() RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; BEGIN FOR _r IN SELECT priv_id FROM priv WHERE ((priv_name IN (SELECT priv_name FROM priv WHERE (priv_module='Custom') EXCEPT SELECT ('Custom'||cmd_privname) FROM cmd)) AND (priv_module='Custom')) LOOP -- TODO: something here DELETE FROM grppriv WHERE grppriv_priv_id=_r.priv_id; DELETE FROM usrpriv WHERE usrpriv_priv_id=_r.priv_id; DELETE FROM priv WHERE priv_id=_r.priv_id; END LOOP; FOR _r IN SELECT ('Custom'||cmd_privname) AS privname FROM cmd EXCEPT SELECT priv_name FROM priv WHERE (priv_module='Custom') LOOP -- TODO: something here INSERT INTO priv (priv_module, priv_name, priv_descrip) VALUES ('Custom', _r.privname, 'Auto Generated Custom Priv.'); END LOOP; RETURN TRUE; END; $$; ALTER FUNCTION public.updatecustomprivs() OWNER TO admin; -- -- Name: updateinvoicelineitem(api.invoiceline, api.invoiceline); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updateinvoicelineitem(api.invoiceline, api.invoiceline) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNew ALIAS FOR $1; pOld ALIAS FOR $2; _r RECORD; BEGIN UPDATE invcitem SET invcitem_linenumber=pNew.line_number, invcitem_item_id=COALESCE(item_id, -1), invcitem_custpn=pNew.customer_part_number, invcitem_number=(CASE WHEN item_id IS NULL THEN pNew.misc_item_number ELSE NULL END), invcitem_warehous_id=(CASE WHEN invcitem_warehous_id IS NULL THEN COALESCE(getwarehousid(pNew.site,'ALL'),-1) ELSE NULL END), invcitem_descrip=(CASE WHEN item_id IS NULL THEN pNew.misc_item_description ELSE NULL END), invcitem_ordered=pNew.qty_ordered, invcitem_billed=COALESCE(pNew.qty_billed, 0), invcitem_updateinv=COALESCE(pNew.update_inventory,FALSE), invcitem_price=COALESCE(pNew.net_unit_price,itemPrice(item_id,invchead_cust_id, invchead_shipto_id,pNew.qty_ordered,invchead_curr_id,invchead_orderdate)), invcitem_notes=COALESCE(pNew.notes,''), invcitem_salescat_id=CASE WHEN item_id IS NULL THEN (SELECT salescat_id FROM salescat WHERE salescat_name = pNew.sales_category) ELSE NULL END, invcitem_taxtype_id=taxtype_id, invcitem_qty_uom_id=CASE WHEN item_id IS NOT NULL THEN COALESCE((SELECT uom_id FROM uom WHERE (uom_name=pNew.qty_uom)), item_price_uom_id) ELSE NULL END, invcitem_qty_invuomratio=CASE WHEN item_id IS NOT NULL THEN itemuomtouomratio(item_id, COALESCE((SELECT uom_id FROM uom WHERE uom_name=pNew.qty_uom),item_price_uom_id), item_price_uom_id ) ELSE 1 END, invcitem_price_uom_id=CASE WHEN item_id IS NOT NULL THEN COALESCE((SELECT uom_id FROM uom WHERE uom_name=pNew.price_uom),item_price_uom_id) ELSE NULL END, invcitem_price_invuomratio=CASE WHEN item_id IS NOT NULL THEN itemuomtouomratio(item_id, COALESCE((SELECT uom_id FROM uom WHERE uom_name=pNew.price_uom),item_price_uom_id), item_price_uom_id ) ELSE 1 END, invcitem_rev_accnt_id=getGlAccntId(alternate_rev_account) FROM invchead LEFT OUTER JOIN item ON (item_id=getItemId(pNew.item_number)) LEFT OUTER JOIN taxtype ON (taxtype_id=CASE WHEN pNew.tax_type IS NULL THEN getItemTaxType(item_id,invchead_taxzone_id) WHEN pNew.tax_type = 'None' THEN NULL ELSE (SELECT taxtype_id FROM taxtype WHERE taxtype_name=pNew.tax_type) END) WHERE invcitem_invchead_id=invchead_id AND invcitem_linenumber=pOld.line_number AND invchead_invcnumber=pOld.invoice_number AND invchead_posted=FALSE; RETURN TRUE; END; $_$; ALTER FUNCTION public.updateinvoicelineitem(api.invoiceline, api.invoiceline) OWNER TO admin; -- -- Name: updateitemcost(integer, integer, integer, numeric, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updateitemcost(integer, integer, integer, numeric, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemId ALIAS FOR $1; pCostElemId ALIAS FOR $2; pCurrId ALIAS FOR $3; pCost ALIAS FOR $4; pPostToStandard ALIAS FOR $5; _itemcost_id INTEGER; _update_return INTEGER; _postcost_return BOOLEAN; --This function is used with the api.itemcost View for updating --the itemcost table BEGIN SELECT itemcost_id INTO _itemcost_id FROM itemcost WHERE ( (itemcost_item_id = pItemId) AND (itemcost_costelem_id = pCostElemId) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'itemcost % not found for. ', pItemId || ' & ' || pCostElemId; END IF; IF (pCost IS NULL OR pCost < 0) THEN RAISE EXCEPTION 'itemcost Actual Cost Invalid ', pCost; END IF; IF (pCost > 0) THEN UPDATE itemcost SET itemcost_actcost=pCost, itemcost_curr_id = pCurrId WHERE (itemcost_id=_itemcost_id); --Only Post Cost to standard if the parameter is set to true IF (pPostToStandard) THEN IF (NOT checkPrivilege('PostStandardCosts')) THEN RAISE EXCEPTION 'You do not have privileges to poststandard itemcosts. Set api.itemcost post_to_standard to false'; END IF; SELECT postcost(_itemcost_id) INTO _postcost_return; IF (NOT _postcost_return) THEN RETURN -2; END IF; END IF; ELSE RETURN -1; END IF; RETURN _itemcost_id; END; $_$; ALTER FUNCTION public.updateitemcost(integer, integer, integer, numeric, boolean) OWNER TO admin; -- -- Name: updateitemsiteleadtime(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updateitemsiteleadtime(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pPad ALIAS FOR $2; _p RECORD; _materialLeadTime INTEGER; _productionLeadTime INTEGER; _leadTime INTEGER; BEGIN SELECT item_type, itemsite_wosupply INTO _p FROM item, itemsite WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pitemsiteid) ); IF ( (_p.item_type IN ('M', 'P')) ) THEN IF (_p.item_type = 'M') THEN SELECT COALESCE(MAX(component.itemsite_leadtime), 0) INTO _materialLeadTime FROM bomitem, itemsite AS parent, itemsite AS component WHERE ( (bomitem_parent_item_id=parent.itemsite_item_id) AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id)) AND (bomitem_item_id=component.itemsite_item_id) AND (parent.itemsite_warehous_id=component.itemsite_warehous_id) AND (parent.itemsite_id=pItemsiteid) ); SELECT COALESCE(MAX(booitem_execday), 0) INTO _productionLeadTime FROM xtmfg.booitem, itemsite WHERE ( (booitem_item_id=itemsite_item_id) AND (booitem_rev_id=getActiveRevId('BOO',booitem_item_id)) AND (itemsite_id=pItemsiteid) ); _leadTime := (_materialLeadTime + _productionLeadTime + pPad); ELSIF (_p.item_type IN ('P')) THEN SELECT COALESCE(MAX(itemsrc_leadtime), 0) INTO _leadTime FROM itemsrc, itemsite WHERE ( (itemsite_item_id=itemsrc_item_id) AND (itemsite_id=pItemsiteid) ); _leadTime := (_leadTime + pPad); END IF; ELSE _leadTime = pPad; END IF; UPDATE itemsite SET itemsite_leadtime=_leadTime WHERE (itemsite_id=pItemsiteid); RETURN _leadTime; END; $_$; ALTER FUNCTION public.updateitemsiteleadtime(integer, integer) OWNER TO admin; -- -- Name: updatelistprice(integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatelistprice(integer, numeric) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pUpdateBy ALIAS FOR $2; BEGIN UPDATE item SET item_listprice = (item_listprice * pUpdateBy) WHERE (item_id=pItemid); RETURN 1; END; $_$; ALTER FUNCTION public.updatelistprice(integer, numeric) OWNER TO admin; -- -- Name: updatelowerusercosts(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatelowerusercosts(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; BEGIN RETURN updateLowerUserCosts(pItemid, TRUE); END; $_$; ALTER FUNCTION public.updatelowerusercosts(integer) OWNER TO admin; -- -- Name: updatelowerusercosts(integer, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatelowerusercosts(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pUpdateActual ALIAS FOR $2; _bomitem RECORD; _type CHAR(1); BEGIN SELECT item_type INTO _type FROM item WHERE (item_id=pItemid); IF (_type IN ('M', 'F', 'B', 'T')) THEN FOR _bomitem IN SELECT DISTINCT costelem_type FROM ( SELECT COALESCE(bc.costelem_type, ic.costelem_type) AS costelem_type FROM bomitem(pItemid) JOIN item ON (item_id=bomitem_item_id AND item_type <> 'T') JOIN itemcost ON (itemcost_item_id=bomitem_item_id) JOIN costelem ic ON (ic.costelem_id=itemcost_costelem_id AND NOT ic.costelem_sys) LEFT OUTER JOIN bomitemcost ON (bomitemcost_bomitem_id=bomitem_id) LEFT OUTER JOIN costelem bc ON (bc.costelem_id=bomitemcost_costelem_id AND NOT bc.costelem_sys) WHERE ( CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1) ) UNION SELECT costelem_type FROM itemcost, costelem WHERE ( (itemcost_costelem_id=costelem_id) AND (itemcost_item_id=pItemid) ) ) AS data LOOP PERFORM updateSorACost( pItemid, _bomitem.costelem_type, TRUE, lowerCost(pItemid, _bomitem.costelem_type, pUpdateActual), pUpdateActual); END LOOP; ELSIF (_type = 'C') THEN FOR _bomitem IN SELECT DISTINCT costelem_type FROM ( SELECT costelem_type FROM itemcost, costelem, xtmfg.bbomitem WHERE ( (bbomitem_item_id=pItemid) AND ( CURRENT_DATE BETWEEN bbomitem_effective AND (bbomitem_expires - 1) ) AND (NOT costelem_sys) AND (bbomitem_item_id=itemcost_item_id) AND (itemcost_costelem_id=costelem_id) ) UNION SELECT costelem_type FROM itemcost, costelem, xtmfg.bbomitem AS t, xtmfg.bbomitem AS s WHERE ( (t.bbomitem_item_id=pItemid) AND ( CURRENT_DATE BETWEEN s.bbomitem_effective AND (s.bbomitem_expires - 1) ) AND ( CURRENT_DATE BETWEEN t.bbomitem_effective AND (t.bbomitem_expires - 1) ) AND (s.bbomitem_parent_item_id=t.bbomitem_parent_item_id) AND (NOT costelem_sys) AND (s.bbomitem_item_id=itemcost_item_id) AND (itemcost_costelem_id=costelem_id) ) ) AS data LOOP PERFORM updateSorACost( pItemid, _bomitem.costelem_type, TRUE, lowerCost(pItemid, _bomitem.costelem_type, pUpdateActual), pUpdateActual); END LOOP; END IF; RETURN 1; END; $_$; ALTER FUNCTION public.updatelowerusercosts(integer, boolean) OWNER TO admin; -- -- Name: updatelowlevel(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatelowlevel(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLowlevel ALIAS FOR $1; _num_back INTEGER; BEGIN UPDATE costUpdate SET costUpdate_lowlevel_code = (pLowlevel + 1) WHERE costUpdate_item_id IN ( SELECT bomitem_item_id FROM bomitem JOIN costUpdate ON (bomitem_parent_item_id = costUpdate_item_id) WHERE ((costUpdate_lowlevel_code = pLowlevel) AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id)) AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1)))) AND costUpdate_lowlevel_code >= pLowlevel; GET DIAGNOSTICS _num_back = ROW_COUNT; RETURN _num_back; END; $_$; ALTER FUNCTION public.updatelowlevel(integer) OWNER TO admin; -- -- Name: updateoutlevel(integer, integer, integer[]); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updateoutlevel(integer, integer, integer[]) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pDays ALIAS FOR $2; pPeriods ALIAS FOR $3; _cursor INTEGER; _periodid INTEGER; _usage NUMERIC; _totalUsage NUMERIC; _totalDays INTEGER; _outLevel NUMERIC; _averageUsage NUMERIC; BEGIN _cursor := 1; _totalUsage := 0; _totalDays := 0; _periodid = pPeriods[_cursor]; WHILE (_periodid IS NOT NULL) LOOP SELECT COALESCE(SUM(invhist_invqty), 0) INTO _usage FROM invhist WHERE ( (invhist_itemsite_id=pItemsiteid) AND ( invhist_transdate::DATE BETWEEN findPeriodStart(_periodid) AND findPeriodEnd(_periodid) ) AND (invhist_transtype IN ('SH', 'IM')) ); _totalUsage := (_totalUsage + _usage); _totalDays := ( _totalDays + ( findPeriodEnd(_periodid) - findPeriodStart(_periodid) + 1 ) ); _cursor := (_cursor + 1); _periodid = pPeriods[_cursor]; END LOOP; IF (_totalDays > 0) THEN _outLevel := round(_totalUsage / _totalDays * pDays); IF (_outLevel > 0) THEN UPDATE itemsite SET itemsite_ordertoqty = _outLevel WHERE (itemsite_id=pItemsiteid); ELSE UPDATE itemsite SET itemsite_ordertoqty = 0 WHERE (itemsite_id=pItemsiteid); END IF; RETURN TRUE; ELSE RETURN FALSE; END IF; END; $_$; ALTER FUNCTION public.updateoutlevel(integer, integer, integer[]) OWNER TO admin; -- -- Name: updateprice(integer, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updateprice(integer, numeric) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pIpsitemid ALIAS FOR $1; pUpdateBy ALIAS FOR $2; BEGIN RETURN updatePrice(pIpsitemid, 'P', pUpdateBy); END; $_$; ALTER FUNCTION public.updateprice(integer, numeric) OWNER TO admin; -- -- Name: updateprice(integer, character, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updateprice(integer, character, numeric) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pIpsitemid ALIAS FOR $1; pUpdateType ALIAS FOR $2; pUpdateBy ALIAS FOR $3; BEGIN IF (pUpdateType IN('V')) THEN UPDATE ipsitem SET ipsitem_price = (ipsitem_price + pUpdateBy) WHERE (ipsitem_id=pIpsitemid); RETURN 1; ELSE UPDATE ipsitem SET ipsitem_price = (ipsitem_price * pUpdateBy) WHERE (ipsitem_id=pIpsitemid); RETURN 1; END IF; END; $_$; ALTER FUNCTION public.updateprice(integer, character, numeric) OWNER TO admin; -- -- Name: updatepricesbypricingschedule(integer, character, numeric, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatepricesbypricingschedule(pipsheadid integer, pupdatetype character, pupdateby numeric, pupdatecharprices boolean) RETURNS numeric LANGUAGE plpgsql AS $$ DECLARE _percentMultiplier NUMERIC; _currencyDecimals INTEGER; _itemRows INTEGER :=0; _charRows INTEGER :=0; BEGIN IF NOT (checkPrivilege('MaintainPricingSchedules')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Price Schedules.'; END IF; -- Get the current user's currency precision SELECT COALESCE(locale_curr_scale, 2) INTO _currencyDecimals FROM locale, usr WHERE usr_locale_id = locale_id AND usr_username = CURRENT_USER; IF (pUpdateType = 'V') THEN UPDATE ipsitem SET ipsitem_price = noNeg(ROUND( (ipsitem_price + pUpdateBy), _currencyDecimals)) WHERE (ipsitem_ipshead_id = pIpsHeadId); GET DIAGNOSTICS _itemRows = ROW_COUNT; ELSE _percentMultiplier := (1.0 + (pUpdateBy / 100.0)); UPDATE ipsitem SET ipsitem_price = noNeg(ROUND( (ipsitem_price * _percentMultiplier), _currencyDecimals)) WHERE (ipsitem_ipshead_id = pIpsHeadId); GET DIAGNOSTICS _itemRows = ROW_COUNT; IF (pUpdateCharPrices) THEN UPDATE ipsitemchar SET ipsitemchar_price = noNeg(ROUND( (ipsitemchar_price * _percentMultiplier), _currencyDecimals)) FROM ipsitem WHERE ipsitemchar_ipsitem_id = ipsitem_id AND ipsitem_ipshead_id = pIpsHeadId; GET DIAGNOSTICS _charRows = ROW_COUNT; END IF; END IF; RETURN _itemRows + _charRows; END; $$; ALTER FUNCTION public.updatepricesbypricingschedule(pipsheadid integer, pupdatetype character, pupdateby numeric, pupdatecharprices boolean) OWNER TO admin; -- -- Name: updatepricesbyproductcategory(integer, text, character, numeric, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatepricesbyproductcategory(pprodcatid integer, pprodcatpattern text, pupdatetype character, pupdateby numeric, pupdatecharprices boolean) RETURNS numeric LANGUAGE plpgsql AS $$ DECLARE _percentMultiplier NUMERIC; _currencyDecimals INTEGER; _itemRows INTEGER :=0; _charRows INTEGER :=0; BEGIN IF NOT (checkPrivilege('MaintainPricingSchedules')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Price Schedules.'; END IF; -- Get the current user's currency precision SELECT COALESCE(locale_curr_scale, 2) INTO _currencyDecimals FROM locale, usr WHERE usr_locale_id = locale_id AND usr_username = CURRENT_USER; _percentMultiplier := (1.0 + (pUpdateBy / 100.0)); IF (pUpdateType = 'V') THEN IF (pProdCatId IS NOT NULL) THEN -- Specified category id UPDATE ipsitem SET ipsitem_price = noNeg(ROUND( (ipsitem_price + pUpdateBy), _currencyDecimals )) FROM item WHERE ipsitem_item_id = item_id AND item_prodcat_id = pProdCatId; ELSIF (pProdCatPattern IS NOT NULL) THEN -- Pattern match category UPDATE ipsitem SET ipsitem_price = noNeg(ROUND( (ipsitem_price + pUpdateBy), _currencyDecimals )) FROM item WHERE ipsitem_item_id = item_id AND item_prodcat_id IN ( SELECT prodcat_id FROM prodcat WHERE (prodcat_code ~ pProdCatPattern) ); ELSE -- All categories UPDATE ipsitem SET ipsitem_price = noNeg(ROUND( (ipsitem_price + pUpdateBy), _currencyDecimals )); END IF; GET DIAGNOSTICS _itemRows = ROW_COUNT; ELSE IF (pProdCatId IS NOT NULL) THEN -- Specified category id UPDATE ipsitem SET ipsitem_price = noNeg(ROUND( (ipsitem_price * _percentMultiplier), _currencyDecimals )) FROM item WHERE ipsitem_item_id = item_id AND item_prodcat_id = pProdCatId; GET DIAGNOSTICS _itemRows = ROW_COUNT; IF(pUpdateCharPrices) THEN UPDATE ipsitemchar SET ipsitemchar_price = noNeg(ROUND( (ipsitemchar_price * _percentMultiplier), _currencyDecimals )) FROM ipsitem, item WHERE item_prodcat_id = pProdCatId AND ipsitem_item_id = item_id AND ipsitemchar_ipsitem_id = ipsitem_id; GET DIAGNOSTICS _charRows = ROW_COUNT; END IF; ELSIF (pProdCatPattern IS NOT NULL) THEN -- Pattern match category UPDATE ipsitem SET ipsitem_price = noNeg(ROUND( (ipsitem_price * _percentMultiplier), _currencyDecimals )) FROM item WHERE item_prodcat_id IN ( SELECT prodcat_id FROM prodcat WHERE (prodcat_code ~ pProdCatPattern ) ) AND ipsitem_item_id = item_id; GET DIAGNOSTICS _itemRows = ROW_COUNT; IF(pUpdateCharPrices) THEN UPDATE ipsitemchar SET ipsitemchar_price = noNeg(ROUND( (ipsitemchar_price * _percentMultiplier), _currencyDecimals )) FROM ipsitem, item WHERE item_prodcat_id IN ( SELECT prodcat_id FROM prodcat WHERE (prodcat_code ~ pProdCatPattern ) ) AND ipsitem_item_id = item_id AND ipsitemchar_ipsitem_id = ipsitem_id; GET DIAGNOSTICS _charRows = ROW_COUNT; END IF; ELSE -- All categories UPDATE ipsitem SET ipsitem_price = noNeg(ROUND( (ipsitem_price * _percentMultiplier), _currencyDecimals )); GET DIAGNOSTICS _itemRows = ROW_COUNT; IF(pUpdateCharPrices) THEN UPDATE ipsitemchar SET ipsitemchar_price = noNeg(ROUND( (ipsitemchar_price * _percentMultiplier), _currencyDecimals )); GET DIAGNOSTICS _charRows = ROW_COUNT; END IF; END IF; END IF; RETURN _itemRows + _charRows; END; $$; ALTER FUNCTION public.updatepricesbyproductcategory(pprodcatid integer, pprodcatpattern text, pupdatetype character, pupdateby numeric, pupdatecharprices boolean) OWNER TO admin; -- -- Name: updatereorderlevel(integer, integer, integer[]); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatereorderlevel(integer, integer, integer[]) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pDays ALIAS FOR $2; pPeriods ALIAS FOR $3; _cursor INTEGER; _periodid INTEGER; _usage NUMERIC; _totalUsage NUMERIC; _totalDays INTEGER; _reorderLevel INTEGER; _averageUsage NUMERIC; _result TEXT; BEGIN _cursor := 1; _totalUsage := 0; _totalDays := 0; _periodid = pPeriods[_cursor]; WHILE (_periodid IS NOT NULL) LOOP SELECT COALESCE(SUM(invhist_invqty), 0) INTO _usage FROM invhist WHERE ( (invhist_itemsite_id=pItemsiteid) AND ( invhist_transdate::DATE BETWEEN findPeriodStart(_periodid) AND findPeriodEnd(_periodid) ) AND (invhist_transtype IN ('SH', 'IM')) ); _totalUsage := (_totalUsage + _usage); _totalDays := ( _totalDays + ( findPeriodEnd(_periodid) - findPeriodStart(_periodid) + 1 ) ); _cursor := (_cursor + 1); _periodid = pPeriods[_cursor]; END LOOP; IF (_totalDays > 0) THEN _reorderLevel := round(_totalUsage / _totalDays * pDays); SELECT itemsite_stocked INTO _result from itemsite WHERE (itemsite_id=pItemsiteid); IF (_reorderLevel = 0 AND _result='t') THEN _reorderLevel := 1; END IF; IF (_reorderLevel > 0) THEN UPDATE itemsite SET itemsite_reorderlevel = _reorderLevel WHERE (itemsite_id=pItemsiteid); ELSE UPDATE itemsite SET itemsite_reorderlevel = 0 WHERE (itemsite_id=pItemsiteid); END IF; RETURN TRUE; ELSE RETURN FALSE; END IF; END; $_$; ALTER FUNCTION public.updatereorderlevel(integer, integer, integer[]) OWNER TO admin; -- -- Name: updatereorderlevel(integer[], integer, boolean, integer[]); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatereorderlevel(integer[], integer, boolean, integer[]) RETURNS SETOF reordlvl LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteids ALIAS FOR $1; pDays ALIAS FOR $2; pAddLeadtime ALIAS FOR $3; pPeriodIds ALIAS FOR $4; _icursor INTEGER := 1; _pcursor INTEGER := 1; _totalUsage NUMERIC := 0; _totalDays INTEGER := 0; _reorderLevel INTEGER := 0; _result TEXT; _usage NUMERIC; _averageUsage NUMERIC; _row reordlvl %ROWTYPE; BEGIN -- Validate IF (pItemsiteIds[1] IS NULL OR pPeriodIds[1] IS NULL) THEN RETURN; END IF; -- Calculate total days FOR _pcursor IN 1..ARRAY_UPPER(pPeriodIds,1) LOOP _totalDays := ( _totalDays + ( findPeriodEnd(pPeriodIds[_pcursor]) - findPeriodStart(pPeriodIds[_pcursor]) + 1 ) ); END LOOP; -- Loop through each itemsite id FOR _icursor IN 1..ARRAY_UPPER(pItemsiteIds,1) LOOP -- Get itemsite data SELECT itemsite_id, item_id, warehous_code, item_number, item_descrip1, itemsite_leadtime, 0, itemsite_reorderlevel, 0, 0, 0 INTO _row FROM itemsite JOIN item ON (itemsite_item_id=item_id) JOIN whsinfo ON (itemsite_warehous_id=warehous_id) WHERE (itemsite_id=pItemsiteIds[_icursor]); IF (FOUND) THEN IF (pAddLeadtime) THEN _row.reordlvl_daysofstock := pDays + _row.reordlvl_leadtime; ELSE _row.reordlvl_daysofstock := pDays; END IF; -- Loop through each period id FOR _pcursor IN 1..ARRAY_UPPER(pPeriodIds,1) LOOP -- Sum days and usage shipping and inventory transactions SELECT COALESCE(SUM(invhist_invqty), 0) INTO _usage FROM invhist WHERE ( (invhist_itemsite_id=pItemsiteIds[_icursor]) AND ( invhist_transdate::DATE BETWEEN findPeriodStart(pPeriodIds[_pcursor]) AND findPeriodEnd(pPeriodIds[_pcursor]) ) AND (invhist_transtype IN ('SH', 'IM')) ); _totalUsage := (_totalUsage + _usage); END LOOP; -- Calculate reorder level IF (_totalDays > 0) THEN _reorderLevel := round(_totalUsage / _totalDays * _row.reordlvl_daysofstock); END IF; IF (_reorderLevel <= 0) THEN _reorderLevel := 0; END IF; SELECT itemsite_stocked INTO _result from itemsite WHERE (itemsite_id=pItemsiteIds[_icursor]); IF (_reorderLevel = 0 AND _result='t') THEN _reorderLevel := 1; END IF; -- Set values _row.reordlvl_total_days := _totalDays; _row.reordlvl_total_usage := _totalUsage; _row.reordlvl_calc_level := _reorderLevel; -- Return result RETURN NEXT _row; END IF; _usage := 0; _averageUsage := 0; _totalUsage := 0; _reorderLevel := 0; END LOOP; RETURN; END; $_$; ALTER FUNCTION public.updatereorderlevel(integer[], integer, boolean, integer[]) OWNER TO admin; -- -- Name: updateretainedearnings(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updateretainedearnings(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pYearPeriodid ALIAS FOR $1; _r RECORD; _n RECORD; _c RECORD; _beginningPeriodid INTEGER; _trialbalid INTEGER; _accntid INTEGER; _totalProfitLoss NUMERIC; _periodid INTEGER; _forwardupdate INTEGER; BEGIN -- First thing we need to do is to get the yearperiod SELECT * INTO _r FROM yearperiod where yearperiod_id = pYearPeriodid; IF (NOT FOUND) THEN RETURN -6; END IF; -- Now we need to find the next yearperiod SELECT * INTO _n FROM yearperiod WHERE yearperiod_start = _r.yearperiod_end + interval '1 day'; IF (NOT FOUND) THEN RETURN -4; END IF; -- Now we have to find where to stick the end of year data SELECT period_id INTO _periodid FROM period WHERE period_start = _n.yearperiod_start; IF (NOT FOUND) THEN RETURN -8; END IF; -- Loop through companies and process each one IF (coalesce(fetchMetricValue('GLCompanySize'),0) = 0) THEN -- Process for installs not using company segment -- Now we need to get the default account number for year end closing SELECT CAST ( metric_value AS integer ) INTO _accntid FROM metric WHERE metric_name = 'YearEndEquityAccount'; IF (NOT FOUND) THEN RETURN -7; END IF; -- So far so good. Now we need to calculate the profit-loss for the year that we are closing SELECT SUM(gltrans_amount) INTO _totalProfitLoss FROM gltrans, accnt WHERE ( (gltrans_accnt_id = accnt_id) AND (accnt_type IN ( 'R', 'E' ) ) AND (gltrans_posted) AND (NOT gltrans_deleted) AND (gltrans_date between _r.yearperiod_start and _r.yearperiod_end ) ); IF (_totalProfitLoss IS NULL) THEN _totalProfitLoss := 0; END IF; -- Get the trailbal_id SELECT trialbal_id INTO _trialbalid FROM trialbal WHERE ( (trialbal_period_id = _periodid ) AND (trialbal_accnt_id = _accntid) ); IF (NOT FOUND) THEN RETURN -9; END IF; -- Lets do the update for the trialbal UPDATE trialbal SET trialbal_beginning = trialbal_beginning - trialbal_yearend + _totalProfitLoss, trialbal_ending = trialbal_beginning - trialbal_yearend - trialbal_debits + trialbal_credits + _totalProfitLoss, trialbal_yearend = _totalProfitLoss WHERE trialbal_id = _trialbalid; -- Now the forward update SELECT forwardupdatetrialbalance(_trialbalid) INTO _forwardupdate; ELSE -- Process for a multi-company set up FOR _c IN SELECT company_number, company_yearend_accnt_id FROM company LOOP -- Calculate the profit-loss for the year that we are closing SELECT SUM(gltrans_amount) INTO _totalProfitLoss FROM gltrans, accnt WHERE ( (gltrans_accnt_id = accnt_id) AND (accnt_type IN ( 'R', 'E' ) ) AND (gltrans_posted) AND (NOT gltrans_deleted) AND (accnt_company = _c.company_number) AND (gltrans_date between _r.yearperiod_start and _r.yearperiod_end ) ); IF(_totalProfitLoss IS NULL) THEN _totalProfitLoss := 0; END IF; -- Get the trailbal_id SELECT trialbal_id INTO _trialbalid FROM trialbal JOIN accnt ON (trialbal_accnt_id=accnt_id) WHERE ( (trialbal_period_id = _periodid ) AND (trialbal_accnt_id = _c.company_yearend_accnt_id) ); IF (NOT FOUND) THEN -- Create a trial balance record SELECT NEXTVAL('trialbal_trialbal_id_seq') INTO _trialbalid; INSERT INTO trialbal ( trialbal_id, trialbal_accnt_id, trialbal_period_id, trialbal_beginning, trialbal_dirty, trialbal_ending, trialbal_credits, trialbal_debits, trialbal_yearend ) VALUES ( _trialbalid, _c.company_yearend_accnt_id, _periodid, _totalProfitLoss, TRUE, _totalProfitLoss, 0, 0, _totalProfitLoss ); ELSE -- Lets do the update for the trialbal UPDATE trialbal SET trialbal_beginning = trialbal_beginning - trialbal_yearend + _totalProfitLoss, trialbal_ending = trialbal_beginning - trialbal_yearend - trialbal_debits + trialbal_credits + _totalProfitLoss, trialbal_yearend = _totalProfitLoss WHERE trialbal_id = _trialbalid; END IF; -- Now the forward update SELECT forwardupdatetrialbalance(_trialbalid) INTO _forwardupdate; END LOOP; END IF; RETURN 0; END; $_$; ALTER FUNCTION public.updateretainedearnings(integer) OWNER TO admin; -- -- Name: updatesoracost(integer, text, boolean, numeric, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatesoracost(integer, text, boolean, numeric, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCosttype ALIAS FOR $2; pLevel ALIAS FOR $3; pCost ALIAS FOR $4; pUpdateActual ALIAS FOR $5; BEGIN IF (pUpdateActual) THEN RETURN updateCost(pItemid, pCosttype, pLevel, pCost); ELSE RETURN updateStdCost(pItemid, pCosttype, pLevel, pCost); END IF; END; $_$; ALTER FUNCTION public.updatesoracost(integer, text, boolean, numeric, boolean) OWNER TO admin; -- -- Name: updatestdcost(integer, text, boolean, numeric); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatestdcost(integer, text, boolean, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCostType ALIAS FOR $2; pLevel ALIAS FOR $3; pCost ALIAS FOR $4; _newCost NUMERIC; _oldCost NUMERIC := 0; _itemcostid INTEGER; _updateRet BOOLEAN; _itemNumber TEXT; BEGIN IF (pCost IS NULL) THEN _newCost = 0; ELSE _newCost = pCost; END IF; SELECT itemcost_id, itemcost_stdCost, item_number INTO _itemcostid, _oldCost, _itemNumber FROM itemcost, costelem, item WHERE ((itemcost_costelem_id=costelem_id) AND (itemcost_item_id=item_id) AND (item_id=pItemid) AND (itemcost_lowlevel=pLevel) AND (costelem_type=pCosttype)); -- RAISE NOTICE 'updateStdCost(%, %, %, %) has itemcost_id % and stdcost %', -- pItemid, pCostType, plevel, _newCost, _itemcostid, _oldCost; IF (NOT FOUND) AND (_newCost > 0) THEN SELECT NEXTVAL('itemcost_itemcost_id_seq') INTO _itemcostid; -- RAISE NOTICE 'updateStdCost() inserting itemcost_id %', _itemcostid; INSERT INTO itemcost (itemcost_id, itemcost_item_id, itemcost_costelem_id, itemcost_lowlevel, itemcost_stdcost, itemcost_posted, itemcost_actcost, itemcost_updated) SELECT _itemcostid, pItemid, costelem_id, pLevel, _newCost, CURRENT_DATE, 0, CURRENT_DATE FROM costelem WHERE (costelem_type=pCosttype); END IF; IF (_itemcostid IS NOT NULL) THEN SELECT updateStdCost(_itemcostid, _newCost, _oldCost, 'Post Cost', ('Set Standard Cost - ' || pCosttype || ' for item ' || _itemNumber)) INTO _updateRet; IF (_updateRet) THEN RETURN _itemcostid; END IF; END IF; RETURN -1; END; $_$; ALTER FUNCTION public.updatestdcost(integer, text, boolean, numeric) OWNER TO admin; -- -- Name: updatestdcost(integer, numeric, numeric, text, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatestdcost(pitemcostid integer, pnewcost numeric, poldcost numeric, pdocnumber text, pnotes text) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _itemcostid INTEGER; _r RECORD; _newcost NUMERIC; _oldcost NUMERIC; BEGIN IF (pNewcost IS NULL) THEN _newcost := 0; ELSE _newcost := pNewcost; END IF; IF (pOldcost IS NULL) THEN _oldcost := 0; ELSE _oldcost := pOldcost; END IF; IF (_newcost > 0) THEN UPDATE itemcost SET itemcost_stdcost=_newcost, itemcost_posted=CURRENT_DATE WHERE (itemcost_id=pItemcostid); END IF; -- Distribute to G/L, debit Inventory Asset, credit Inventory Cost Variance FOR _r IN SELECT itemsite_id, itemsite_qtyonhand AS totalQty, costcat_invcost_accnt_id, costcat_asset_accnt_id, itemsite_costmethod FROM itemcost, itemsite, costcat WHERE ( (itemsite_item_id=itemcost_item_id) AND (itemsite_costcat_id=costcat_id) AND (itemsite_costmethod != 'A') AND (itemsite_qtyonhand <> 0.0) AND (itemcost_id=pItemcostid) ) LOOP -- IF (_newcost <> _oldcost) THEN -- RAISE NOTICE 'itemcost_id = %, Qty = %, Old Cost = %, New Cost = %', pItemcostid, _r.totalQty, _oldcost, _newcost; -- END IF; PERFORM insertGLTransaction( 'P/D', '', pDocNumber, pNotes, _r.costcat_invcost_accnt_id, _r.costcat_asset_accnt_id, _r.itemsite_id, ((_newcost - _oldcost) * _r.totalQty), CURRENT_DATE ); -- Update Itemsite Value if not Average Cost IF (_r.itemsite_costmethod <> 'A') THEN -- RAISE NOTICE 'itemsite_id = %, Qty = %, New Cost = %', _r.itemsite_id, _r.totalQty, _newcost; UPDATE itemsite SET itemsite_value=(_r.totalQty * stdCost(itemsite_item_id)) WHERE (itemsite_id=_r.itemsite_id); END IF; END LOOP; IF (_newcost = 0) THEN DELETE FROM itemcost WHERE (itemcost_id=pItemcostid); RETURN FALSE; END IF; IF ( SELECT metric_value FROM metric WHERE ((metric_name = 'EnableAsOfQOH') AND (metric_value = 't'))) THEN IF (pNewcost IS NOT NULL) THEN _newcost := pNewcost; END IF; IF (pOldcost IS NULL) THEN _oldcost := 0; ELSE _oldcost := pOldcost; END IF; -- Distribute to G/L, debit Inventory Asset, credit Inventory Cost Variance PERFORM postValueIntoInvBalance( itemsite_id, current_date, asofinvqty(itemsite_id,current_date), asofinvnn(itemsite_id,current_date), _oldcost, _newcost) FROM itemsite JOIN item ON (itemsite_item_id=item_id) JOIN itemcost ON (itemcost_item_id=item_id) WHERE((itemsite_costmethod = 'S') AND (itemcost_id=pItemcostid)); END IF; RETURN TRUE; END; $$; ALTER FUNCTION public.updatestdcost(pitemcostid integer, pnewcost numeric, poldcost numeric, pdocnumber text, pnotes text) OWNER TO admin; -- -- Name: updatetodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, boolean, text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatetodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, boolean, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN updateTodoItem($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, NULL); END; $_$; ALTER FUNCTION public.updatetodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, boolean, text) OWNER TO admin; -- -- Name: updatetodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, boolean, text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION updatetodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, boolean, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ptodoitemid ALIAS FOR $1; pusername ALIAS FOR $2; pname ALIAS FOR $3; pdesc ALIAS FOR $4; pincdtid ALIAS FOR $5; pcrmacctid ALIAS FOR $6; pOpheadid ALIAS FOR $7; pstarted ALIAS FOR $8; pdue ALIAS FOR $9; pstatus ALIAS FOR $10; passigned ALIAS FOR $11; pcompleted ALIAS FOR $12; ppriority ALIAS FOR $13; pnotes ALIAS FOR $14; pactive ALIAS FOR $15; powner ALIAS FOR $16; pcntctid ALIAS FOR $17; _priority INTEGER := ppriority; _status CHARACTER(1) := pstatus; _incdtid INTEGER := pincdtid; _crmacctid INTEGER := pcrmacctid; _opheadid INTEGER := pOpheadid; _assigned DATE := passigned; _active BOOL := pactive; _result INTEGER; BEGIN IF (pusername IS NULL OR pusername = '') THEN RETURN -1; END IF; IF (pname IS NULL OR pname = '') THEN RETURN -2; END IF; IF (pdue IS NULL) THEN RETURN -3; END IF; IF (ptodoitemid IS NULL OR ptodoitemid <= 0) THEN RETURN -10; END IF; IF (pcompleted IS NOT NULL) THEN _status := 'C'; ELSIF (pstatus IS NULL AND pstarted IS NOT NULL) THEN _status := 'I'; ELSIF (pstatus IS NULL) THEN _status := 'N'; END IF; IF (_incdtid <= 0) THEN _incdtid := NULL; END IF; IF (_crmacctid <= 0) THEN _crmacctid := NULL; END IF; IF (_opheadid <= 0) THEN _opheadid := NULL; END IF; IF (_priority <= 0) THEN _priority := NULL; END IF; IF (_assigned IS NULL) THEN _assigned := CURRENT_DATE; END IF; IF (_active IS NULL) THEN _active := TRUE; END IF; UPDATE todoitem SET todoitem_username=pusername, todoitem_name=pname, todoitem_description=pdesc, todoitem_incdt_id=_incdtid, todoitem_status=_status, todoitem_active=_active, todoitem_start_date=pstarted, todoitem_due_date=pdue, todoitem_assigned_date=_assigned, todoitem_completed_date=pcompleted, todoitem_priority_id=_priority, todoitem_notes=pnotes, todoitem_crmacct_id=_crmacctid, todoitem_ophead_id=_opheadid, todoitem_owner_username=powner, todoitem_cntct_id=pcntctid WHERE (todoitem_id=ptodoitemid); RETURN ptodoitemid; END; $_$; ALTER FUNCTION public.updatetodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, boolean, text, integer) OWNER TO admin; -- -- Name: usedefaultlocation(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION usedefaultlocation(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; _p RECORD; BEGIN SELECT itemsite_location_id, LENGTH(itemsite_location) AS locationlength INTO _p FROM itemsite WHERE (itemsite_id=pItemsiteid); IF (NOT FOUND) THEN RETURN FALSE; ELSIF (_p.itemsite_location_id <> -1) THEN RETURN TRUE; ELSIF (_p.locationlength > 0) THEN RETURN TRUE; ELSE RETURN FALSE; END IF; END; $_$; ALTER FUNCTION public.usedefaultlocation(integer) OWNER TO admin; -- -- Name: usercancreateusers(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION usercancreateusers(text) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT rolcreaterole OR rolsuper FROM pg_roles WHERE rolname=($1); $_$; ALTER FUNCTION public.usercancreateusers(text) OWNER TO admin; -- -- Name: usercanlogin(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION usercanlogin(pusername text) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _isactive BOOLEAN; _mode TEXT; BEGIN IF (isDBA(pUsername) OR userCanCreateUsers(pUsername)) THEN RETURN TRUE; ELSIF (pg_has_role(pUsername, 'xtrole', 'member')) THEN _mode := COALESCE(fetchMetricText('AllowedUserLogins'), ''); IF (_mode = 'AdminOnly') THEN RETURN FALSE; -- administrators were checked above END IF; IF (_mode NOT IN ('AdminOnly','ActiveOnly','Any')) THEN _mode := 'ActiveOnly'; END IF; SELECT (usrpref_value = 't') INTO _isactive FROM usrpref WHERE usrpref_username = pUsername AND usrpref_name = 'active'; IF (_isactive OR _mode = 'Any') THEN RETURN TRUE; END IF; END IF; RETURN FALSE; END; $$; ALTER FUNCTION public.usercanlogin(pusername text) OWNER TO admin; -- -- Name: userid(text); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION userid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; _userId INTEGER; BEGIN SELECT usesysid INTO _userId FROM pg_user WHERE (usename=pUsername); IF (FOUND) THEN RETURN _userId; ELSE RETURN -1; END IF; END; $_$; ALTER FUNCTION public.userid(text) OWNER TO admin; -- -- Name: validateorderqty(integer, numeric, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION validateorderqty(integer, numeric, boolean) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pQty ALIAS FOR $2; pManual ALIAS FOR $3; _p RECORD; _qty NUMERIC; BEGIN _qty := pQty; SELECT itemsite_useparams, CASE WHEN (itemsite_useparams) THEN itemsite_useparamsmanual ELSE FALSE END AS itemsite_useparamsmanual, CASE WHEN (itemsite_useparams) THEN itemsite_minordqty ELSE 0.0 END AS itemsite_minordqty, CASE WHEN (itemsite_useparams) THEN itemsite_multordqty ELSE 0.0 END AS itemsite_multordqty, item_fractional, item_type INTO _p FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ); IF ( (pManual AND (_p.itemsite_useparamsmanual)) OR ((NOT pManual) AND (_p.itemsite_useparams)) ) THEN IF (_qty < _p.itemsite_minordqty) THEN _qty := _p.itemsite_minordqty; END IF; IF ( (_p.itemsite_multordqty > 0) AND ((_qty % _p.itemsite_multordqty) > 0) ) THEN _qty := ((TRUNC(_qty / _p.itemsite_multordqty) * _p.itemsite_multordqty) + _p.itemsite_multordqty); END IF; END IF; _qty := roundQty(_p.item_fractional, _qty); RETURN _qty; END; $_$; ALTER FUNCTION public.validateorderqty(integer, numeric, boolean) OWNER TO admin; -- -- Name: validlocation(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION validlocation(integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLocationid ALIAS FOR $1; pItemsiteid ALIAS FOR $2; _p RECORD; BEGIN SELECT location_restrict INTO _p FROM location, itemsite WHERE ( (location_warehous_id=itemsite_warehous_id) AND (itemsite_id=pItemsiteid) AND (location_id=pLocationid) ); IF (FOUND) THEN IF (_p.location_restrict) THEN SELECT locitem_id INTO _p FROM locitem, itemsite WHERE ( (locitem_item_id=itemsite_item_id) AND (itemsite_id=pItemsiteid) AND (locitem_location_id=pLocationid) ); IF (FOUND) THEN RETURN TRUE; END IF; ELSE RETURN TRUE; END IF; ELSE RETURN FALSE; END IF; RETURN FALSE; END; $_$; ALTER FUNCTION public.validlocation(integer, integer) OWNER TO admin; -- -- Name: valueatshipping(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION valueatshipping(plineitemid integer) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN valueAtShipping('SO', plineitemid); END; $$; ALTER FUNCTION public.valueatshipping(plineitemid integer) OWNER TO admin; -- -- Name: valueatshipping(text, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION valueatshipping(pordertype text, plineitemid integer) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _value NUMERIC := 0.0; BEGIN IF (pordertype NOT IN ('SO', 'TO')) THEN RAISE EXCEPTION '% is not a valid order type', pordertype; END IF; SELECT COALESCE(SUM(shipitem_value), 0.0) INTO _value FROM shipitem JOIN shiphead ON (shipitem_shiphead_id=shiphead_id) WHERE ( (NOT shiphead_shipped) AND (shiphead_order_type=pordertype) AND (shipitem_orderitem_id=plineitemid) ); RETURN _value; END; $$; ALTER FUNCTION public.valueatshipping(pordertype text, plineitemid integer) OWNER TO admin; -- -- Name: voidapcheck(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION voidapcheck(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'voidAPCheck() is deprecated - use voidCheck() instead'; RETURN voidCheck($1); END; $_$; ALTER FUNCTION public.voidapcheck(integer) OWNER TO admin; -- -- Name: voidapopenvoucher(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION voidapopenvoucher(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pApopenid ALIAS FOR $1; BEGIN RETURN voidApopenVoucher(pApopenid, fetchJournalNumber('AP-VO')); END; $_$; ALTER FUNCTION public.voidapopenvoucher(integer) OWNER TO admin; -- -- Name: voidapopenvoucher(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION voidapopenvoucher(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pApopenid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; _apopenid INTEGER; _apcreditapplyid INTEGER; _reference TEXT; _result INTEGER; _sequence INTEGER; _totalAmount_base NUMERIC; _totalAmount NUMERIC; _itemAmount_base NUMERIC; _itemAmount NUMERIC; _test INTEGER; _a RECORD; _d RECORD; _g RECORD; _p RECORD; _n RECORD; _r RECORD; _costx RECORD; _pExplain BOOLEAN; _pLowLevel BOOLEAN; _exchGainFreight NUMERIC; _firstExchDateFreight DATE; _tmpTotal NUMERIC; _glDate DATE; BEGIN _totalAmount_base := 0; _totalAmount := 0; SELECT fetchGLSequence() INTO _sequence; -- Cache APOpen Information SELECT apopen.* INTO _n FROM apopen WHERE ( (apopen_doctype='V') AND (apopen_id=pApopenid) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Void Voucher Id % as apopen not found [xtuple: voidAPOpenVoucher, -10, %]', pApopenid, pApopenid; END IF; -- Cache Voucher Infomation SELECT vohead.*, vend_number || '-' || vend_name || ' ' || vohead_reference AS glnotes, COALESCE(pohead_orderdate, vohead_docdate) AS pohead_orderdate, COALESCE(pohead_curr_id, vohead_curr_id) AS pohead_curr_id INTO _p FROM vohead JOIN vendinfo ON (vend_id=vohead_vend_id) LEFT OUTER JOIN pohead ON (vohead_pohead_id = pohead_id) WHERE (vohead_number=_n.apopen_docnumber); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Void Voucher #% as vohead not found [xtuple: voidAPOpenVoucher, -20, %]', _n.apopen_docnumber, _n.apopen_docnumber; END IF; -- Check for APApplications SELECT apapply_id INTO _test FROM apapply WHERE (apapply_target_apopen_id=_n.apopen_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Cannot Void Voucher #% as applications exist [xtuple: voidAPOpenVoucher, -30, %]', _n.apopen_docnumber, _n.apopen_docnumber; END IF; _glDate := COALESCE(_p.vohead_gldistdate, _p.vohead_distdate); -- there is no currency gain/loss on items, see issue 3892, -- but there might be on freight, which is first encountered at p/o receipt SELECT recv_date::DATE INTO _firstExchDateFreight FROM recv WHERE (recv_vohead_id = _p.vohead_id); -- Start by handling taxes FOR _r IN SELECT tax_sales_accnt_id, round(sum(taxdetail_tax),2) AS tax, currToBase(_p.vohead_curr_id, round(sum(taxdetail_tax),2), _p.vohead_docdate) AS taxbasevalue FROM tax JOIN calculateTaxDetailSummary('VO', _p.vohead_id, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id, tax_sales_accnt_id LOOP PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', _p.vohead_number, _r.tax_sales_accnt_id, (_r.taxbasevalue * -1), _glDate, _p.glnotes ); _totalAmount_base := (_totalAmount_base - _r.taxbasevalue); _totalAmount := (_totalAmount - _r.tax); END LOOP; -- Loop through the vodist records for the passed vohead that -- are posted against a P/O Item FOR _g IN SELECT DISTINCT poitem_id, voitem_qty, poitem_expcat_id, poitem_invvenduomratio, COALESCE(itemsite_id, -1) AS itemsiteid, COALESCE(itemsite_costcat_id, -1) AS costcatid, COALESCE(itemsite_item_id, -1) AS itemsite_item_id, (SELECT SUM(value) FROM ( SELECT SUM(recv_value) AS value FROM recv WHERE (recv_voitem_id=voitem_id) UNION SELECT SUM(poreject_value)*-1 AS value FROM poreject WHERE (poreject_voitem_id=voitem_id)) as data) AS value_base, (poitem_freight_vouchered / poitem_qty_vouchered) * voitem_qty AS vouchered_freight, currToBase(_p.pohead_curr_id, (poitem_freight_vouchered / poitem_qty_vouchered) * voitem_qty, _firstExchDateFreight ) AS vouchered_freight_base, voitem_freight, currToBase(_p.vohead_curr_id, voitem_freight, _p.vohead_distdate) AS voitem_freight_base FROM vodist, voitem, poitem LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id) WHERE ( (vodist_poitem_id=poitem_id) AND (voitem_poitem_id=poitem_id) AND (voitem_vohead_id=vodist_vohead_id) AND (vodist_vohead_id=_p.vohead_id)) LOOP -- Grab the G/L Accounts IF (_g.costcatid = -1) THEN SELECT pp.accnt_id AS pp_accnt_id, lb.accnt_id AS lb_accnt_id INTO _a FROM expcat, accnt AS pp, accnt AS lb WHERE ( (expcat_purchprice_accnt_id=pp.accnt_id) AND (expcat_liability_accnt_id=lb.accnt_id) AND (expcat_id=_g.poitem_expcat_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Void Voucher #% due to unassigned G/L Accounts [xtuple: voidAPOpenVoucher, -40, %]', _p.vohead_number, _p.vohead_number; END IF; ELSE SELECT pp.accnt_id AS pp_accnt_id, lb.accnt_id AS lb_accnt_id INTO _a FROM costcat, accnt AS pp, accnt AS lb WHERE ( (costcat_purchprice_accnt_id=pp.accnt_id) AND (costcat_liability_accnt_id=lb.accnt_id) AND (costcat_id=_g.costcatid) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Void Voucher #% due to unassigned G/L Accounts [xtuple: voidAPOpenVoucher, -50, %]', _p.vohead_number, _p.vohead_number; END IF; END IF; -- Clear the Item Amount accumulator _itemAmount_base := 0; _itemAmount := 0; -- Figure out the total posted value for this line item FOR _d IN SELECT vodist_id, vodist_amount, _p.vohead_curr_id, vodist_costelem_id, currToBase(_p.vohead_curr_id, vodist_amount, _p.vohead_distdate) AS vodist_amount_base FROM vodist WHERE ( (vodist_vohead_id=_p.vohead_id) AND (vodist_poitem_id=_g.poitem_id) ) LOOP _pExplain := TRUE; SELECT * INTO _costx FROM itemcost WHERE ( (itemcost_item_id = _g.itemsite_item_id) AND (itemcost_costelem_id = _d.vodist_costelem_id) ); IF (FOUND) THEN _pExplain := _costx.itemcost_lowlevel; END IF; -- Add the Distribution Amount to the Item Amount _itemAmount_base := _itemAmount_base + ROUND(_d.vodist_amount_base, 2); _itemAmount := _itemAmount + _d.vodist_amount; END LOOP; -- Distribute from the clearing account PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number), _a.lb_accnt_id, round(_g.value_base + _g.vouchered_freight_base, 2), _glDate, _p.glnotes ); -- Attribute the correct portion to currency gain/loss _exchGainFreight := 0; SELECT currGain(_p.pohead_curr_id, _g.vouchered_freight, _firstExchDateFreight, _p.vohead_distdate ) INTO _exchGainFreight; IF (round(_exchGainFreight, 2) <> 0) THEN PERFORM insertIntoGLSeries(_sequence, 'A/P', 'VO', text(_p.vohead_number), getGainLossAccntId(_a.lb_accnt_id), round(_exchGainFreight, 2) * -1, _glDate, _p.glnotes); END IF; -- Distribute the remaining variance to the Purchase Price Variance account IF (round(_itemAmount_base, 2) <> round(_g.value_base, 2)) THEN _tmpTotal := round(_itemAmount_base, 2) - round(_g.value_base, 2); PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number), _a.pp_accnt_id, _tmpTotal, _glDate, _p.glnotes ); END IF; -- Distribute the remaining freight variance to the Purchase Price Variance account IF (round(_g.voitem_freight_base + _exchGainFreight, 2) <> round(_g.vouchered_freight_base, 2)) THEN _tmpTotal := round(_g.voitem_freight_base + _exchGainFreight, 2) - round(_g.vouchered_freight_base, 2); PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number), _a.pp_accnt_id, _tmpTotal, _glDate, _p.glnotes ); END IF; -- Add the distribution amount to the total amount to distribute _totalAmount_base := (_totalAmount_base + _itemAmount_base + _g.voitem_freight_base); _totalAmount := (_totalAmount + _itemAmount + _g.voitem_freight); -- Reverse the posting for all the Tagged Receivings for this P/O Item UPDATE recv SET recv_invoiced=FALSE, recv_recvcost_curr_id=basecurrid(), recv_recvcost=0, recv_vohead_id=NULL, recv_voitem_id=NULL FROM poitem WHERE ( (recv_orderitem_id=poitem_id) AND (recv_order_type='PO') AND (recv_orderitem_id=_g.poitem_id) AND (recv_vohead_id=_p.vohead_id) ); -- Reverse the posting for all the Tagged Rejections for this P/O Item UPDATE poreject SET poreject_invoiced=FALSE, poreject_vohead_id=NULL, poreject_voitem_id=NULL WHERE ( (poreject_poitem_id=_g.poitem_id) AND (poreject_vohead_id=_p.vohead_id) ); -- Update the qty and freight vouchered fields UPDATE poitem SET poitem_qty_vouchered = (poitem_qty_vouchered - _g.voitem_qty), poitem_freight_vouchered = (poitem_freight_vouchered - _g.voitem_freight) WHERE (poitem_id=_g.poitem_id); END LOOP; -- Loop through the vodist records for the passed vohead that -- are not posted against a P/O Item -- Skip the tax distributions FOR _d IN SELECT vodist_id, currToBase(_p.vohead_curr_id, vodist_amount, _p.vohead_distdate) AS vodist_amount_base, vodist_amount, vodist_accnt_id, vodist_expcat_id FROM vodist WHERE ( (vodist_vohead_id=_p.vohead_id) AND (vodist_poitem_id=-1) AND (vodist_tax_id=-1) ) LOOP -- Distribute from the misc. account IF (_d.vodist_accnt_id = -1) THEN PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number), expcat_exp_accnt_id, round(_d.vodist_amount_base, 2), _glDate, _p.glnotes ) FROM expcat WHERE (expcat_id=_d.vodist_expcat_id); ELSE PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number), _d.vodist_accnt_id, round(_d.vodist_amount_base, 2), _glDate, _p.glnotes ); END IF; -- Add the Distribution Amount to the Total Amount _totalAmount_base := _totalAmount_base + ROUND(_d.vodist_amount_base, 2); _totalAmount := _totalAmount + _d.vodist_amount; END LOOP; SELECT insertIntoGLSeries( _sequence, 'A/P', 'VO', text(vohead_number), accnt_id, round(_totalAmount_base, 2) * -1, _glDate, _p.glnotes ) INTO _test FROM vohead LEFT OUTER JOIN accnt ON (accnt_id=findAPAccount(vohead_vend_id)) WHERE ( (findAPAccount(vohead_vend_id)=0 OR accnt_id > 0) -- G/L interface might be disabled AND (vohead_id=_p.vohead_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Void Voucher #% due to an unassigned A/P Account [xtuple: voidAPOpenVoucher, -60, %]', _p.vohead_number, _p.vohead_number; END IF; PERFORM postGLSeries(_sequence, pJournalNumber); -- Create the A/P Open Item SELECT NEXTVAL('apopen_apopen_id_seq') INTO _apopenid; _reference := ('Void Voucher #' || _n.apopen_docnumber); INSERT INTO apopen ( apopen_id, apopen_username, apopen_journalnumber, apopen_vend_id, apopen_docnumber, apopen_doctype, apopen_ponumber, apopen_docdate, apopen_duedate, apopen_distdate, apopen_terms_id, apopen_curr_id, apopen_amount, apopen_paid, apopen_open, apopen_notes, apopen_discount, apopen_curr_rate ) SELECT _apopenid, getEffectiveXtUser(), pJournalnumber, apopen_vend_id, apopen_docnumber, 'C', apopen_ponumber, _glDate, _glDate, _glDate, -1, apopen_curr_id, apopen_amount - apopen_paid, 0, TRUE, _reference, TRUE, apopen_curr_rate FROM apopen WHERE (apopen_id=_n.apopen_id); SELECT apcreditapply_id INTO _apcreditapplyid FROM apcreditapply WHERE ( (apcreditapply_source_apopen_id=_apopenid) AND (apcreditapply_target_apopen_id=_n.apopen_id) ); IF (FOUND) THEN UPDATE apcreditapply SET apcreditapply_amount=_n.apopen_amount-_n.apopen_paid WHERE (apcreditapply_id=_apcreditapplyid); ELSE SELECT nextval('apcreditapply_apcreditapply_id_seq') INTO _apcreditapplyid; INSERT INTO apcreditapply ( apcreditapply_id, apcreditapply_source_apopen_id, apcreditapply_target_apopen_id, apcreditapply_amount, apcreditapply_curr_id ) VALUES ( _apcreditapplyid, _apopenid, _n.apopen_id, _n.apopen_amount-_n.apopen_paid, _n.apopen_curr_id ); END IF; SELECT postAPCreditMemoApplication(_apopenid) INTO _result; IF (_result < 0) THEN RAISE EXCEPTION 'Credit application failed with result % [xtuple: voidAPOpenVoucher, -70, %]', _result, _result; END IF; -- Reopen all of the P/O Items that were closed by this Voucher UPDATE poitem SET poitem_status='O' FROM voitem WHERE ( (voitem_poitem_id=poitem_id) AND (voitem_close) AND (voitem_vohead_id=_p.vohead_id) ); -- Reopen the P/O UPDATE pohead SET pohead_status='O' WHERE (pohead_id=_p.vohead_pohead_id); -- Delete any apselect approval records to prevent incorrect payment runs DELETE FROM apselect WHERE (apselect_apopen_id=_n.apopen_id); -- Mark as voided UPDATE apopen SET apopen_void=TRUE WHERE (apopen_id=_n.apopen_id); RETURN pJournalNumber; END; $_$; ALTER FUNCTION public.voidapopenvoucher(integer, integer) OWNER TO admin; -- -- Name: voidcheck(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION voidcheck(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCheckid ALIAS FOR $1; BEGIN IF ( SELECT (checkhead_void OR checkhead_posted OR checkhead_replaced) FROM checkhead WHERE (checkhead_id=pCheckid) ) THEN RETURN -1; END IF; UPDATE checkhead SET checkhead_void=TRUE WHERE (checkhead_id=pCheckid); RETURN 1; END; $_$; ALTER FUNCTION public.voidcheck(integer) OWNER TO admin; -- -- Name: voidcreditmemo(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION voidcreditmemo(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmheadid ALIAS FOR $1; _r RECORD; _p RECORD; _n RECORD; _glSequence INTEGER := 0; _glJournal INTEGER := 0; _itemlocSeries INTEGER := 0; _invhistid INTEGER; _test INTEGER; _amount NUMERIC; _roundedBase NUMERIC; _totalAmount NUMERIC := 0; _totalRoundedBase NUMERIC := 0; _commissionDue NUMERIC := 0; _toApply NUMERIC; _toClose BOOLEAN; _glDate DATE; _taxBaseValue NUMERIC := 0; BEGIN -- Cache C/M information SELECT cmhead.*, findARAccount(cmhead_cust_id) AS ar_accnt_id, ( SELECT COALESCE(SUM(taxhist_tax), 0) FROM cmheadtax WHERE ( (taxhist_parent_id = cmhead_id) AND (taxhist_taxtype_id = getAdjustmentTaxtypeId()) ) ) AS adjtax INTO _p FROM cmhead WHERE (cmhead_id=pCmheadid); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Void Credit Memo as cmhead not found'; END IF; IF (NOT _p.cmhead_posted) THEN RETURN -10; END IF; -- Cache AROpen Information SELECT aropen.* INTO _n FROM aropen WHERE ( (aropen_doctype='C') AND (aropen_docnumber=_p.cmhead_number) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Void Credit Memo as aropen not found'; END IF; -- Check for ARApplications SELECT arapply_id INTO _test FROM arapply WHERE (arapply_target_aropen_id=_n.aropen_id) OR (arapply_source_aropen_id=_n.aropen_id) LIMIT 1; IF (FOUND) THEN RETURN -20; END IF; _glDate := COALESCE(_p.cmhead_gldistdate, _p.cmhead_docdate); SELECT fetchGLSequence() INTO _glSequence; SELECT fetchJournalNumber('AR-IN') INTO _glJournal; -- Start by handling taxes (reverse sense) FOR _r IN SELECT tax_sales_accnt_id, round(sum(taxdetail_tax),2) AS tax, currToBase(_p.cmhead_curr_id, round(sum(taxdetail_tax),2), _p.cmhead_docdate) AS taxbasevalue FROM tax JOIN calculateTaxDetailSummary('CM', _p.cmhead_id, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id, tax_sales_accnt_id LOOP PERFORM insertIntoGLSeries( _glSequence, 'A/R', 'CM', _p.cmhead_number, _r.tax_sales_accnt_id, (_r.taxbasevalue * -1.0), _glDate, ('Void-' || _p.cmhead_billtoname) ); _totalAmount := _totalAmount + _r.tax * -1; _totalRoundedBase := _totalRoundedBase + _r.taxbasevalue * -1; END LOOP; -- Process line items FOR _r IN SELECT * FROM creditmemoitem WHERE ( (cmitem_cmhead_id=_p.cmhead_id) AND (cmitem_qtycredit <> 0 ) ) LOOP IF (_r.extprice <> 0) THEN -- Debit the Sales Account for the current cmitem (reverse sense) _roundedBase := round(currToBase(_p.cmhead_curr_id, _r.extprice, _p.cmhead_docdate), 2); SELECT insertIntoGLSeries( _glSequence, 'A/R', 'CM', _p.cmhead_number, CASE WHEN _p.cmhead_rahead_id IS NULL THEN getPrjAccntId(_p.cmhead_prj_id, salesaccnt_credit_accnt_id) ELSE getPrjAccntId(_p.cmhead_prj_id, salesaccnt_returns_accnt_id) END, _roundedBase, _glDate, ('Void-' || _p.cmhead_billtoname) ) INTO _test FROM salesaccnt WHERE (salesaccnt_id=findSalesAccnt(_r.cmitem_itemsite_id, 'IS', _p.cmhead_cust_id, _p.cmhead_saletype_id, _p.cmhead_shipzone_id)); IF (NOT FOUND) THEN PERFORM deleteGLSeries(_glSequence); RETURN -11; END IF; END IF; _totalAmount := _totalAmount + round(_r.extprice, 2); _totalRoundedBase := _totalRoundedBase + _roundedBase; END LOOP; -- Credit the Misc. Account for Miscellaneous Charges (reverse sense) IF (_p.cmhead_misc <> 0) THEN _roundedBase := round(currToBase(_p.cmhead_curr_id, _p.cmhead_misc, _p.cmhead_docdate), 2); SELECT insertIntoGLSeries( _glSequence, 'A/R', 'CM', _p.cmhead_number, getPrjAccntId(_p.cmhead_prj_id, accnt_id), _roundedBase, _glDate, ('Void-' ||_p.cmhead_billtoname) ) INTO _test FROM accnt WHERE (accnt_id=_p.cmhead_misc_accnt_id); -- If the Misc. Charges Account was not found then punt IF (NOT FOUND) THEN PERFORM deleteGLSeries(_glSequence); RETURN _test; END IF; -- Cache the Misc. Amount distributed _totalAmount := _totalAmount + _p.cmhead_misc; _totalRoundedBase := _totalRoundedBase + _roundedBase; END IF; -- Debit the Freight Account (reverse sense) IF (_p.cmhead_freight <> 0) THEN _roundedBase := round(currToBase(_p.cmhead_curr_id, _p.cmhead_freight, _p.cmhead_docdate), 2); SELECT insertIntoGLSeries( _glSequence, 'A/R', 'CM', _p.cmhead_number, getPrjAccntId(_p.cmhead_prj_id, accnt_id), _roundedBase, _glDate, ('Void-' || _p.cmhead_billtoname) ) INTO _test FROM accnt WHERE (accnt_id=findFreightAccount(_p.cmhead_cust_id)); -- If the Freight Charges Account was not found then punt IF (NOT FOUND) THEN PERFORM deleteGLSeries(_glSequence); RETURN _test; END IF; -- Cache the Amount Distributed to Freight _totalAmount := _totalAmount + _p.cmhead_freight; _totalRoundedBase := _totalRoundedBase + _roundedBase; END IF; _totalAmount := _totalAmount; -- Credit the A/R for the total Amount (reverse sense) IF (_totalAmount <> 0) THEN IF (_p.ar_accnt_id != -1) THEN SELECT insertIntoGLSeries( _glSequence, 'A/R', 'CM', _p.cmhead_number, _p.ar_accnt_id, (_totalRoundedBase * -1.0), _glDate, ('Void-' || _p.cmhead_billtoname) ) INTO _test; ELSE PERFORM deleteGLSeries(_glSequence); RETURN _test; END IF; END IF; -- Commit the GLSeries; SELECT postGLSeries(_glSequence, _glJournal) INTO _test; IF (_test < 0) THEN PERFORM deleteGLSeries(_glSequence); RETURN _test; END IF; -- Delete sales history DELETE FROM cohisttax WHERE (taxhist_parent_id IN (SELECT cohist_id FROM cohist WHERE (cohist_doctype='C' AND cohist_ordernumber=_p.cmhead_number))); DELETE FROM cohist WHERE (cohist_doctype='C' AND cohist_ordernumber=_p.cmhead_number); -- Delete the Invoice aropen item DELETE FROM aropen WHERE (aropen_doctype='C' AND aropen_docnumber=_p.cmhead_number); -- Handle the Inventory and G/L Transactions for any returned Inventory where cmitem_updateinv is true (reverse sense) FOR _r IN SELECT cmitem_itemsite_id AS itemsite_id, cmitem_id, (cmitem_qtyreturned * cmitem_qty_invuomratio) AS qty, cmhead_number, cmhead_cust_id AS cust_id, item_number, cmhead_prj_id AS prj_id, cmhead_saletype_id AS saletype_id, cmhead_shipzone_id AS shipzone_id FROM cmhead, cmitem, itemsite, item WHERE ( (cmitem_cmhead_id=cmhead_id) AND (cmitem_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (cmitem_qtyreturned <> 0) AND (cmitem_updateinv) AND (cmhead_id=_p.cmhead_id) ) LOOP -- Return credited stock to inventory IF (_itemlocSeries = 0) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; END IF; SELECT postInvTrans( itemsite_id, 'RS', (_r.qty * -1), 'S/O', 'CM', _r.cmhead_number, '', ('Credit Voided ' || _r.item_number), costcat_asset_accnt_id, getPrjAccntId(_r.prj_id, resolveCOSAccount(itemsite_id, _r.cust_id, _r.saletype_id, _r.shipzone_id)), _itemlocSeries, _glDate) INTO _invhistid FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_r.itemsite_id) ); END LOOP; -- Update coitem to reflect the returned qty where cmitem_updateinv is true (reverse sense) FOR _r IN SELECT cmitem_qtyreturned, cmitem_itemsite_id, cohead_id FROM cmitem, cmhead, invchead, cohead WHERE ( (cmitem_cmhead_id=cmhead_id) AND (cmhead_invcnumber=invchead_invcnumber) AND (invchead_ordernumber=cohead_number) AND (cmitem_qtyreturned <> 0) AND (cmitem_updateinv) AND (cmhead_id=_p.cmhead_id) ) LOOP UPDATE coitem SET coitem_qtyreturned = (coitem_qtyreturned + (_r.cmitem_qtyreturned * -1.0)) WHERE coitem_id IN ( SELECT coitem_id FROM coitem WHERE ( (coitem_cohead_id=_r.cohead_id) AND (coitem_itemsite_id = _r.cmitem_itemsite_id) ) LIMIT 1 ); END LOOP; -- Mark the cmhead as voided UPDATE cmhead SET cmhead_void=TRUE WHERE (cmhead_id=_p.cmhead_id); RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.voidcreditmemo(integer) OWNER TO admin; -- -- Name: voidinvoice(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION voidinvoice(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvcheadid ALIAS FOR $1; _glSequence INTEGER := 0; _glJournal INTEGER := 0; _itemlocSeries INTEGER := 0; _aropenid INTEGER := 0; _invhistid INTEGER := 0; _amount NUMERIC; _roundedBase NUMERIC; _r RECORD; _p RECORD; _n RECORD; _test INTEGER; _totalAmount NUMERIC := 0; _totalRoundedBase NUMERIC := 0; _totalAmountBase NUMERIC := 0; _appliedAmount NUMERIC := 0; _commissionDue NUMERIC := 0; _tmpAccntId INTEGER; _tmpCurrId INTEGER; _firstExchDate DATE; _glDate DATE; _exchGain NUMERIC := 0; BEGIN -- Cache Invoice information SELECT invchead.*, findFreightAccount(invchead_cust_id) AS freightaccntid, findARAccount(invchead_cust_id) AS araccntid, aropen_id, cohist_unitcost, ( SELECT COALESCE(SUM(taxhist_tax), 0) FROM invcheadtax WHERE ( (taxhist_parent_id = invchead_id) AND (taxhist_taxtype_id = getFreightTaxtypeId()) ) ) AS freighttax, ( SELECT COALESCE(SUM(taxhist_tax), 0) FROM invcheadtax WHERE ( (taxhist_parent_id = invchead_id) AND (taxhist_taxtype_id = getAdjustmentTaxtypeId()) ) ) AS adjtax INTO _p FROM invchead JOIN aropen ON (aropen_doctype='I' AND aropen_docnumber=invchead_invcnumber) JOIN cohist ON (cohist_doctype='I' AND cohist_invcnumber=invchead_invcnumber) WHERE (invchead_id=pInvcheadid); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Void Invoice as invchead not found'; END IF; IF (NOT _p.invchead_posted) THEN RETURN -10; END IF; -- Cache AROpen Information SELECT aropen.* INTO _n FROM aropen WHERE ( (aropen_doctype='I') AND (aropen_docnumber=_p.invchead_invcnumber) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Void Invoice as aropen not found'; END IF; -- Check for ARApplications SELECT arapply_id INTO _test FROM arapply WHERE (arapply_target_aropen_id=_n.aropen_id) LIMIT 1; IF (FOUND) THEN RETURN -20; END IF; SELECT fetchGLSequence() INTO _glSequence; SELECT fetchJournalNumber('AR-IN') INTO _glJournal; _glDate := COALESCE(_p.invchead_gldistdate, _p.invchead_invcdate); -- the 1st MC iteration used the cohead_orderdate so we could get curr exch -- gain/loss between the sales and invoice dates, but see issue 3892. leave -- this condition TRUE until we make this configurable or decide not to. IF TRUE THEN _firstExchDate := _p.invchead_invcdate; ELSE -- can we save a select by using: _firstExchDate := _p.invchead_orderdate; SELECT cohead_orderdate INTO _firstExchDate FROM cohead WHERE (cohead_number = _p.invchead_ordernumber); END IF; -- Start by handling taxes (reverse sense) FOR _r IN SELECT tax_sales_accnt_id, round(sum(taxdetail_tax),2) AS tax, currToBase(_p.invchead_curr_id, round(sum(taxdetail_tax),2), _firstExchDate) AS taxbasevalue FROM tax JOIN calculateTaxDetailSummary('I', _p.invchead_id, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id, tax_sales_accnt_id LOOP PERFORM insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber, _r.tax_sales_accnt_id, (_r.taxbasevalue * -1.0), _glDate, ('Void-' || _p.invchead_billto_name) ); _totalAmount := _totalAmount + _r.tax; _totalRoundedBase := _totalRoundedBase + _r.taxbasevalue; END LOOP; -- March through the Non-Misc. Invcitems FOR _r IN SELECT * FROM invoiceitem WHERE ( (invcitem_invchead_id = _p.invchead_id) AND (invcitem_item_id <> -1) ) LOOP -- Cache the amount due for this line _amount := _r.extprice; IF (_amount > 0) THEN -- Credit the Sales Account for the invcitem item (reverse sense) IF (_r.invcitem_rev_accnt_id IS NOT NULL) THEN SELECT getPrjAccntId(_p.invchead_prj_id, _r.invcitem_rev_accnt_id) INTO _tmpAccntId; ELSEIF (_r.itemsite_id IS NULL) THEN SELECT getPrjAccntId(_p.invchead_prj_id, salesaccnt_sales_accnt_id) INTO _tmpAccntId FROM salesaccnt WHERE (salesaccnt_id=findSalesAccnt(_r.invcitem_item_id, 'I', _p.invchead_cust_id, _p.invchead_saletype_id, _p.invchead_shipzone_id)); ELSE SELECT getPrjAccntId(_p.invchead_prj_id, salesaccnt_sales_accnt_id) INTO _tmpAccntId FROM salesaccnt WHERE (salesaccnt_id=findSalesAccnt(_r.itemsite_id, 'IS', _p.invchead_cust_id, _p.invchead_saletype_id, _p.invchead_shipzone_id)); END IF; -- If the Sales Account Assignment was not found then punt IF (NOT FOUND) THEN PERFORM deleteGLSeries(_glSequence); RETURN -11; END IF; _roundedBase := round(currToBase(_p.invchead_curr_id, _amount, _firstExchDate), 2); SELECT insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber, _tmpAccntId, (_roundedBase * -1.0), _glDate, ('Void-' || _p.invchead_billto_name) ) INTO _test; _totalAmount := (_totalAmount + _amount); _totalRoundedBase := _totalRoundedBase + _roundedBase; _commissionDue := (_commissionDue + (_amount * _p.invchead_commission)); END IF; _totalAmount := _totalAmount; _totalRoundedBase := _totalRoundedBase; END LOOP; -- March through the Misc. Invcitems FOR _r IN SELECT * FROM invoiceitem JOIN salescat ON (salescat_id = invcitem_salescat_id) WHERE ( (invcitem_item_id = -1) AND (invcitem_invchead_id=_p.invchead_id) ) LOOP -- Cache the amount due for this line and the commission due for such _amount := _r.extprice; IF (_amount > 0) THEN -- Credit the Sales Account for the invcitem item (reverse sense) _roundedBase = round(currToBase(_p.invchead_curr_id, _amount, _firstExchDate), 2); SELECT insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber, getPrjAccntId(_p.invchead_prj_id, COALESCE(_r.invcitem_rev_accnt_id, _r.salescat_sales_accnt_id)), (_roundedBase * -1.0), _glDate, ('Void-' || _p.invchead_billto_name) ) INTO _test; IF (_test < 0) THEN PERFORM deleteGLSeries(_glSequence); RETURN _test; END IF; _totalAmount := (_totalAmount + _amount); _totalRoundedBase := _totalRoundedBase + _roundedBase; _commissionDue := (_commissionDue + (_amount * _p.invchead_commission)); END IF; END LOOP; -- Credit the Freight Account for Freight Charges (reverse sense) IF (_p.invchead_freight <> 0) THEN IF (_p.freightaccntid <> -1) THEN _roundedBase = round(currToBase(_p.invchead_curr_id, _p.invchead_freight, _firstExchDate), 2); SELECT insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber, getPrjAccntId(_p.invchead_prj_id,_p.freightaccntid), (_roundedBase * -1.0), _glDate, ('Void-' || _p.invchead_billto_name) ) INTO _test; -- Cache the Freight Amount distributed _totalAmount := (_totalAmount + _p.invchead_freight); _totalRoundedBase := _totalRoundedBase + _roundedBase; ELSE _test := -14; END IF; -- If the Freight Account was not found then punt IF (_test < 0) THEN PERFORM deleteGLSeries(_glSequence); RETURN _test; END IF; END IF; -- Credit the Misc. Account for Miscellaneous Charges (reverse sense) IF (_p.invchead_misc_amount <> 0) THEN _roundedBase := round(currToBase(_p.invchead_curr_id, _p.invchead_misc_amount, _firstExchDate), 2); SELECT insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber, getPrjAccntId(_p.invchead_prj_id, _p.invchead_misc_accnt_id), (_roundedBase * -1.0), _glDate, ('Void-' || _p.invchead_billto_name) ) INTO _test; -- If the Misc. Charges Account was not found then punt IF (_test < 0) THEN PERFORM deleteGLSeries(_glSequence); RETURN _test; END IF; -- Cache the Misc. Amount distributed _totalAmount := (_totalAmount + _p.invchead_misc_amount); _totalRoundedBase := _totalRoundedBase + _roundedBase; END IF; -- ToDo: handle rounding errors (reverse sense) _exchGain := currGain(_p.invchead_curr_id, _totalAmount, _firstExchDate, _glDate); IF (_exchGain <> 0) THEN SELECT insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber, getGainLossAccntId(_p.araccntid), round(_exchGain, 2), _glDate, ('Void-' || _p.invchead_billto_name) ) INTO _test ; IF (_test < 0) THEN PERFORM deleteGLSeries(_glSequence); RETURN _test; END IF; END IF; -- Debit A/R for the total Amount (reverse sense) IF (_totalRoundedBase <> 0) THEN IF (_p.araccntid != -1) THEN SELECT insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber, _p.araccntid, round(_totalRoundedBase, 2), _glDate, ('Void-' || _p.invchead_billto_name) ) INTO _test; ELSE PERFORM deleteGLSeries(_glSequence); RETURN _test; END IF; END IF; -- Commit the GLSeries; SELECT postGLSeries(_glSequence, _glJournal) INTO _test; IF (_test < 0) THEN PERFORM deleteGLSeries(_glSequence); RETURN _test; END IF; -- Delete sales history DELETE FROM cohisttax WHERE (taxhist_parent_id IN (SELECT cohist_id FROM cohist WHERE (cohist_doctype='I' AND cohist_invcnumber=_p.invchead_invcnumber))); DELETE FROM cohist WHERE (cohist_doctype='I' AND cohist_invcnumber=_p.invchead_invcnumber); -- Create the Credit aropen item SELECT nextval('aropen_aropen_id_seq') INTO _aropenid; INSERT INTO aropen ( aropen_id, aropen_username, aropen_journalnumber, aropen_open, aropen_posted, aropen_cust_id, aropen_ponumber, aropen_docnumber, aropen_applyto, aropen_doctype, aropen_docdate, aropen_duedate, aropen_distdate, aropen_terms_id, aropen_amount, aropen_paid, aropen_salesrep_id, aropen_commission_due, aropen_commission_paid, aropen_ordernumber, aropen_notes, aropen_cobmisc_id, aropen_curr_id ) VALUES ( _aropenid, getEffectiveXtUser(), _glJournal, TRUE, FALSE, _p.invchead_cust_id, _p.invchead_ponumber, _p.invchead_invcnumber, _p.invchead_invcnumber, 'C', _p.invchead_invcdate, determineDueDate(_p.invchead_terms_id, _p.invchead_invcdate), _glDate, _p.invchead_terms_id, round(_totalAmount, 2), round(_totalAmount, 2), _p.invchead_salesrep_id, _commissionDue, FALSE, _p.invchead_ordernumber::text, _p.invchead_notes, pInvcheadid, _p.invchead_curr_id ); -- Alter the Invoice A/R Open Item to reflect the application UPDATE aropen SET aropen_paid = round(_totalAmount, 2) WHERE (aropen_id=_p.aropen_id); -- Record the application INSERT INTO arapply ( arapply_cust_id, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_applied, arapply_closed, arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_curr_id ) VALUES ( _p.invchead_cust_id, _aropenid, 'C', _p.invchead_invcnumber, _p.aropen_id, 'I', _p.invchead_invcnumber, '', '', round(_totalAmount, 2), TRUE, CURRENT_DATE, _p.invchead_invcdate, 0, _p.invchead_curr_id ); -- Handle the Inventory and G/L Transactions for any billed Inventory where invcitem_updateinv is true (reverse sense) FOR _r IN SELECT itemsite_id AS itemsite_id, invcitem_id, (invcitem_billed * invcitem_qty_invuomratio) AS qty, invchead_invcnumber, invchead_cust_id AS cust_id, item_number, invchead_prj_id AS prj_id, invchead_saletype_id AS saletype_id, invchead_shipzone_id AS shipzone_id FROM invchead JOIN invcitem ON ( (invcitem_invchead_id=invchead_id) AND (invcitem_billed <> 0) AND (invcitem_updateinv) ) JOIN itemsite ON ( (itemsite_item_id=invcitem_item_id) AND (itemsite_warehous_id=invcitem_warehous_id) ) JOIN item ON (item_id=invcitem_item_id) WHERE (invchead_id=_p.invchead_id) LOOP -- Return billed stock to inventory IF (_itemlocSeries = 0) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; END IF; SELECT postInvTrans( itemsite_id, 'SH', (_r.qty * -1.0), 'S/O', 'IN', _r.invchead_invcnumber, '', ('Invoice Voided ' || _r.item_number), getPrjAccntId(_r.prj_id, resolveCOSAccount(itemsite_id, _r.cust_id, _r.saletype_id, _r.shipzone_id)), costcat_asset_accnt_id, _itemlocSeries, _glDate, (_p.cohist_unitcost * _r.qty)) INTO _invhistid FROM itemsite JOIN costcat ON (itemsite_costcat_id=costcat_id) WHERE (itemsite_id=_r.itemsite_id); END LOOP; -- Reopen Sales Order UPDATE coitem SET coitem_status='O' WHERE (coitem_id IN (SELECT cobill_coitem_id FROM invcitem JOIN cobill ON (cobill_invcitem_id=invcitem_id) WHERE (invcitem_invchead_id=_p.invchead_id))); -- Reopen Billing UPDATE shipitem SET shipitem_invoiced=FALSE, shipitem_invcitem_id=NULL WHERE (shipitem_invcitem_id IN (SELECT invcitem_id FROM invcitem WHERE (invcitem_invchead_id=_p.invchead_id))); UPDATE cobill SET cobill_invcnum=NULL, cobill_invcitem_id=NULL WHERE (cobill_invcitem_id IN (SELECT invcitem_id FROM invcitem WHERE (invcitem_invchead_id=_p.invchead_id))); UPDATE cobmisc SET cobmisc_posted=FALSE, cobmisc_invcnumber=NULL, cobmisc_invchead_id=NULL WHERE (cobmisc_invchead_id=_p.invchead_id); -- Mark the invoice as voided UPDATE invchead SET invchead_void=TRUE, invchead_notes=(invchead_notes || 'Voided on ' || current_date || ' by ' || getEffectiveXtUser()) WHERE (invchead_id=_p.invchead_id); RETURN _itemlocSeries; END; $_$; ALTER FUNCTION public.voidinvoice(integer) OWNER TO admin; -- -- Name: voidpostedapcheck(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION voidpostedapcheck(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'voidPostedAPCheck() is deprecated - use voidPostedCheck() instead'; RETURN voidPostedCheck($1, fetchJournalNumber('AP-CK'), CURRENT_DATE); END; $_$; ALTER FUNCTION public.voidpostedapcheck(integer) OWNER TO admin; -- -- Name: voidpostedapcheck(integer, integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION voidpostedapcheck(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'voidPostedAPCheck() is deprecated - use voidPostedCheck() instead'; RETURN voidPostedCheck($1, $2, CURRENT_DATE); END; $_$; ALTER FUNCTION public.voidpostedapcheck(integer, integer) OWNER TO admin; -- -- Name: voidpostedapcheck(integer, integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION voidpostedapcheck(integer, integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'voidPostedAPCheck() is deprecated - use voidPostedCheck() instead'; RETURN voidPostedCheck($1, $2, $3); END; $_$; ALTER FUNCTION public.voidpostedapcheck(integer, integer, date) OWNER TO admin; -- -- Name: voidpostedcheck(integer, integer, date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION voidpostedcheck(integer, integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCheckid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pVoidDate ALIAS FOR $3; _amount_base NUMERIC := 0; _result INTEGER; _apopenid INTEGER; _credit_glaccnt INTEGER; _docnumber TEXT; _exchGain NUMERIC := 0; _exchGainTmp NUMERIC := 0; _gltransNote TEXT; _p RECORD; _r RECORD; _sequence INTEGER; _amount_check NUMERIC := 0; BEGIN SELECT fetchGLSequence() INTO _sequence; SELECT checkhead.*, checkhead_amount / checkhead_curr_rate AS checkhead_amount_base, bankaccnt_accnt_id AS bankaccntid, findPrepaidAccount(checkhead_recip_id) AS prepaidaccntid, checkrecip.* INTO _p FROM bankaccnt, checkhead LEFT OUTER JOIN checkrecip ON ((checkrecip_type=checkhead_recip_type) AND (checkrecip_id=checkhead_recip_id)) WHERE ((checkhead_bankaccnt_id=bankaccnt_id) AND (checkhead_id=pCheckid)); IF (NOT _p.checkhead_posted) THEN RETURN -10; END IF; IF (_p.checkrecip_id IS NULL) THEN -- outer join failed RETURN -11; END IF; -- Cannot void if already reconciled SELECT trans_id INTO _result FROM ( SELECT gltrans_id AS trans_id FROM gltrans LEFT OUTER JOIN bankrecitem ON (bankrecitem_source='GL' AND bankrecitem_source_id=gltrans_id) WHERE ( (gltrans_doctype='CK') AND (gltrans_misc_id=_p.checkhead_id) AND ((gltrans_rec) OR (bankrecitem_id IS NOT NULL)) ) UNION ALL SELECT sltrans_id AS trans_id FROM sltrans LEFT OUTER JOIN bankrecitem ON (bankrecitem_source='GL' AND bankrecitem_source_id=sltrans_id) WHERE ( (sltrans_doctype='CK') AND (sltrans_misc_id=_p.checkhead_id) AND ((sltrans_rec) OR (bankrecitem_id IS NOT NULL)) ) ) AS data; IF (FOUND) THEN RETURN -14; END IF; _gltransNote := 'Void Posted Check #' || _p.checkhead_number || ' ' || _p.checkrecip_number || '-' || _p.checkrecip_name; IF (_p.checkhead_misc) THEN IF (COALESCE(_p.checkhead_expcat_id, -1) < 0) THEN IF (_p.checkhead_recip_type = 'V') THEN PERFORM createAPDebitMemo(_p.checkhead_recip_id, pJournalNumber, CAST(fetchAPMemoNumber() AS text), '', pVoidDate, _p.checkhead_amount, _gltransNote || ' '|| _p.checkhead_notes, -1, pVoidDate, -1, _p.checkhead_curr_id ); _credit_glaccnt := findAPPrepaidAccount(_p.checkhead_recip_id); ELSIF (_p.checkhead_recip_type = 'C') THEN PERFORM createARCreditMemo(NULL, _p.checkhead_recip_id, fetchARMemoNumber(), '', pVoidDate, _p.checkhead_amount, _gltransNote || ' '|| _p.checkhead_notes, -1, -1, -1, pVoidDate, -1, NULL, 0.0, pJournalNumber, _p.checkhead_curr_id ); _credit_glaccnt := _p.prepaidaccntid; ELSIF (_p.checkhead_recip_type = 'T') THEN -- TODO: should we create a debit memo for the tax authority? how? _credit_glaccnt := _p.checkrecip_accnt_id; END IF; -- recip type ELSE SELECT expcat_exp_accnt_id INTO _credit_glaccnt FROM expcat WHERE (expcat_id=_p.checkhead_expcat_id); IF (NOT FOUND) THEN RETURN -12; END IF; END IF; IF (COALESCE(_credit_glaccnt, -1) < 0) THEN RETURN -13; END IF; PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source, 'CK', text(_p.checkhead_number), _credit_glaccnt, round(_p.checkhead_amount_base, 2), pVoidDate, _gltransNote, pCheckid); _amount_base := _p.checkhead_amount_base; ELSE FOR _r IN SELECT checkitem_amount, checkitem_discount, CASE WHEN (checkitem_apopen_id IS NOT NULL AND apopen_doctype='C') THEN checkitem_amount / apopen_curr_rate * -1.0 WHEN (checkitem_apopen_id IS NOT NULL) THEN checkitem_amount / apopen_curr_rate ELSE currToBase(checkitem_curr_id, checkitem_amount, COALESCE(checkitem_docdate, _p.checkhead_checkdate)) END AS checkitem_amount_base, currTocurr(checkitem_curr_id, _p.checkhead_curr_id, CASE WHEN (checkitem_apopen_id IS NOT NULL AND apopen_doctype='C') THEN checkitem_amount * -1.0 ELSE checkitem_amount END, _p.checkhead_checkdate) AS amount_check, apopen_id, apopen_doctype, apopen_docnumber, apopen_curr_rate, apopen_docdate, aropen_id, aropen_doctype, aropen_docnumber, checkitem_curr_id, checkitem_curr_rate, COALESCE(checkitem_docdate, _p.checkhead_checkdate) AS docdate FROM (checkitem LEFT OUTER JOIN apopen ON (checkitem_apopen_id=apopen_id)) LEFT OUTER JOIN aropen ON (checkitem_aropen_id=aropen_id) WHERE (checkitem_checkhead_id=pcheckid) LOOP _exchGainTmp := 0; IF (_r.apopen_id IS NOT NULL) THEN -- undo the APDiscount Credit Memo if a discount was taken IF(_r.checkitem_discount > 0) THEN SELECT NEXTVAL('apopen_apopen_id_seq') INTO _apopenid; SELECT fetchAPMemoNumber() INTO _docnumber; INSERT INTO apopen ( apopen_id, apopen_username, apopen_journalnumber, apopen_vend_id, apopen_docnumber, apopen_doctype, apopen_ponumber, apopen_docdate, apopen_duedate, apopen_distdate, apopen_terms_id, apopen_amount, apopen_paid, apopen_open, apopen_notes, apopen_accnt_id, apopen_curr_id, apopen_discount, apopen_curr_rate, apopen_closedate ) VALUES ( _apopenid, getEffectiveXtUser(), pJournalNumber, _p.checkhead_recip_id, _docnumber, 'D', '', pVoidDate, pVoidDate, pVoidDate, -1, _r.checkitem_discount, _r.checkitem_discount, FALSE, ('Reverse Posted Discount ' || _r.apopen_doctype || ' ' || _r.apopen_docnumber), -1, _p.checkhead_curr_id, TRUE, _r.apopen_curr_rate, current_date ); PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source, 'DS', _r.apopen_docnumber, findAPDiscountAccount(_p.checkhead_recip_id), round(_r.checkitem_discount / _r.apopen_curr_rate, 2) * -1, pVoidDate, _gltransNote, pCheckid); PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source, 'DS', _r.apopen_docnumber, findAPAccount(_p.checkhead_recip_id), round(_r.checkitem_discount / _r.apopen_curr_rate, 2), pVoidDate, _gltransNote, pCheckid); -- Post the application INSERT INTO apapply ( apapply_vend_id, apapply_postdate, apapply_username, apapply_source_apopen_id, apapply_source_doctype, apapply_source_docnumber, apapply_target_apopen_id, apapply_target_doctype, apapply_target_docnumber, apapply_journalnumber, apapply_amount, apapply_curr_id ) VALUES ( _p.checkhead_recip_id, pVoidDate, getEffectiveXtUser(), _apopenid, 'D', _docnumber, _r.apopen_id, _r.apopen_doctype, _r.apopen_docnumber, pJournalNumber, (_r.checkitem_discount * -1), _r.checkitem_curr_id ); END IF; -- discount was taken UPDATE apopen SET apopen_paid = round(apopen_paid - (_r.checkitem_amount + noNeg(_r.checkitem_discount)), 2), apopen_open = round(apopen_amount, 2) > round(apopen_paid - (_r.checkitem_amount + noNeg(_r.checkitem_discount)), 2), apopen_closedate = CASE WHEN (round(apopen_amount, 2) > round(apopen_paid - (_r.checkitem_amount + noNeg(_r.checkitem_discount)))) THEN NULL ELSE apopen_closedate END WHERE (apopen_id=_r.apopen_id); -- Post the application INSERT INTO apapply ( apapply_vend_id, apapply_postdate, apapply_username, apapply_source_apopen_id, apapply_source_doctype, apapply_source_docnumber, apapply_target_apopen_id, apapply_target_doctype, apapply_target_docnumber, apapply_journalnumber, apapply_amount, apapply_curr_id ) VALUES ( _p.checkhead_recip_id, pVoidDate, getEffectiveXtUser(), -1, 'K', _p.checkhead_number, _r.apopen_id, _r.apopen_doctype, _r.apopen_docnumber, pJournalNumber, (_r.checkitem_amount * -1), _r.checkitem_curr_id ); END IF; -- if check item's apopen_id is not null IF (_r.aropen_id IS NOT NULL) THEN UPDATE aropen SET aropen_paid = round(aropen_paid -_r.checkitem_amount, 2), aropen_open = round(aropen_amount, 2) > round(aropen_paid - _r.checkitem_amount, 2) WHERE (aropen_id=_r.aropen_id); -- Post the application INSERT INTO arapply ( arapply_cust_id, arapply_postdate, arapply_distdate, arapply_username, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_journalnumber, arapply_applied, arapply_curr_id ) VALUES ( _p.checkhead_recip_id, pVoidDate, pVoidDate, getEffectiveXtUser(), -1, 'K', _p.checkhead_number, _r.aropen_id, _r.aropen_doctype, _r.aropen_docnumber, pJournalNumber, (_r.checkitem_amount * -1), _r.checkitem_curr_id ); END IF; -- if check item's aropen_id is not null -- calculate currency gain/loss IF (_r.apopen_id IS NOT NULL) THEN IF (_p.checkhead_curr_id = _r.checkitem_curr_id) THEN IF (_r.apopen_docdate > _p.checkhead_checkdate) THEN _exchGainTmp := ((_r.checkitem_amount/_p.checkhead_curr_rate) - (_r.checkitem_amount / _r.apopen_curr_rate)) * -1; ELSE _exchGainTmp := ((_r.checkitem_amount / _r.apopen_curr_rate) - (_r.checkitem_amount/_p.checkhead_curr_rate)); END IF; ELSE -- unusual condition where bank overridden and different currency from voucher -- this does not work for all situations --IF (_r.apopen_docdate > _p.checkhead_checkdate) THEN -- _exchGainTmp := ((_r.checkitem_amount/_r.checkitem_curr_rate) - (_r.checkitem_amount / _r.apopen_curr_rate)) * -1; --ELSE -- _exchGainTmp := ((_r.checkitem_amount / _r.apopen_curr_rate) - (_r.checkitem_amount/_r.checkitem_curr_rate)); --END IF; _exchGainTmp := 0.0; END IF; ELSE SELECT arCurrGain(_r.aropen_id,_r.checkitem_curr_id, _r.checkitem_amount, _p.checkhead_checkdate) INTO _exchGainTmp; END IF; _exchGain := _exchGain + _exchGainTmp; PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source, 'CK', text(_p.checkhead_number), _p.checkrecip_accnt_id, round(_r.checkitem_amount_base, 2), pVoidDate, _gltransNote, pCheckid); IF (_exchGainTmp <> 0) THEN PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source, 'CK', text(_p.checkhead_number), getGainLossAccntId(_p.checkrecip_accnt_id), round(_exchGainTmp, 2) * -1, pVoidDate, _gltransNote, pCheckid); END IF; _amount_check := (_amount_check + _r.amount_check); _amount_base := (_amount_base + _r.checkitem_amount_base); END LOOP; IF( (_amount_check - _p.checkhead_amount) <> 0.0 ) THEN _exchGainTmp := (_amount_check - _p.checkhead_amount) / _p.checkhead_curr_rate; _exchGain := _exchGain + _exchGainTmp; END IF; -- ensure that the check balances, attribute rounding errors to gain/loss IF round(_amount_base, 2) - round(_exchGain, 2) <> round(_p.checkhead_amount_base, 2) THEN IF round(_amount_base - _exchGain, 2) = round(_p.checkhead_amount_base, 2) THEN PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source, 'CK', text(_p.checkhead_number), getGainLossAccntId(_p.bankaccntid), (round(_amount_base, 2) - round(_exchGain, 2) - round(_p.checkhead_amount_base, 2)) * -1, pVoidDate, _gltransNote, pCheckid); ELSE RAISE EXCEPTION 'checkhead_id % does not balance (% - % <> %)', pCheckid, _amount_base, _exchGain, _p.checkhead_amount_base; END IF; END IF; END IF; PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source, 'CK', text(_p.checkhead_number), _p.bankaccntid, round(_p.checkhead_amount_base, 2) * -1, pVoidDate, _gltransNote, pCheckid); PERFORM postGLSeries(_sequence, pJournalNumber); UPDATE gltrans SET gltrans_misc_id=pCheckid WHERE gltrans_sequence=_sequence; UPDATE checkhead SET checkhead_posted=false, checkhead_void=true, checkhead_journalnumber=pJournalNumber WHERE (checkhead_id=pCheckid); RETURN pJournalNumber; END; $_$; ALTER FUNCTION public.voidpostedcheck(integer, integer, date) OWNER TO admin; -- -- Name: woeffectivedate(date); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION woeffectivedate(date) RETURNS date LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pStartDate ALIAS FOR $1; BEGIN IF (explodeWoEffective() = 'E') THEN RETURN CURRENT_DATE; ELSE RETURN pStartDate; END IF; END; $_$; ALTER FUNCTION public.woeffectivedate(date) OWNER TO admin; -- -- Name: woinvavail(integer, integer, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION woinvavail(integer, integer, boolean, boolean) RETURNS SETOF woinvav LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pwoid ALIAS FOR $1; plevel ALIAS FOR $2; pshowshortage ALIAS FOR $3; pshowlowinventory ALIAS FOR $4; _row woinvav%ROWTYPE; _x RECORD; _subx RECORD; _index INTEGER; _level INTEGER; _qry TEXT; BEGIN FOR _x IN SELECT wo_id, itemsite_id, item_type, wo_number, wo_subnumber, item_number, item_descrip1, item_descrip2, uom_name, qoh, wobalance, allocated, ordered, reorderlevel, (qoh + ordered - wobalance) AS woavail, (qoh + ordered - allocated) AS totalavail FROM(SELECT wo_id, itemsite_id, item_type, wo_number, wo_subnumber, item_number, item_descrip1, item_descrip2, uom_name, noNeg(qtyAvailable(itemsite_id)) AS qoh, noNeg(wo_qtyord - wo_qtyrcv) AS wobalance, qtyAllocated(itemsite_id, wo_duedate) AS allocated, qtyOrdered(itemsite_id, wo_duedate) AS ordered, CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel FROM wo, itemsite, item, uom WHERE ((wo_ordid = pwoid AND wo_ordtype = 'W') AND NOT (wo_status = 'C') AND (itemsite_id = wo_itemsite_id) AND (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id)) ORDER BY wo_number, wo_subnumber) AS data LOOP _row.woinvav_itemsite_id := _x.itemsite_id; _row.woinvav_womatl_id := -1; _row.woinvav_type := _x.item_type; _row.woinvav_item_wo_number := _x.wo_number || '-' || _x.wo_subnumber; _row.woinvav_descrip := _x.item_descrip1 || ' ' || _x.item_descrip2; _row.woinvav_uomname := _x.uom_name; _row.woinvav_qoh := _x.qoh; _row.woinvav_balance := _x.wobalance; _row.woinvav_allocated := _x.allocated; _row.woinvav_ordered := _x.ordered; _row.woinvav_woavail := _x.woavail; _row.woinvav_totalavail := _x.totalavail; _row.woinvav_reorderlevel := _x.reorderlevel; _row.woinvav_level := plevel; RETURN NEXT _row; --get materials for this level FOR _subx IN SELECT * FROM woinvavailmatl(_x.wo_id, plevel + 1, pshowshortage, pshowlowinventory) LOOP RETURN NEXT _subx; END LOOP; --get next level wo FOR _subx IN SELECT * FROM woinvavail(_x.wo_id, plevel + 1, pshowshortage, pshowlowinventory) LOOP RETURN NEXT _subx; END LOOP; END LOOP; RETURN; END; $_$; ALTER FUNCTION public.woinvavail(integer, integer, boolean, boolean) OWNER TO admin; -- -- Name: woinvavail(integer, boolean, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION woinvavail(integer, boolean, boolean, boolean, boolean) RETURNS SETOF woinvav LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pwoid ALIAS FOR $1; pshowchildindent ALIAS FOR $2; pshowchildsum ALIAS FOR $3; pshowshortage ALIAS FOR $4; pshowlowinventory ALIAS FOR $5; _row woinvav%ROWTYPE; _subrow woinvav%ROWTYPE; _wonumber TEXT; _x RECORD; _subx RECORD; _qry TEXT; BEGIN IF(pshowchildindent) THEN --get top level order FOR _x IN SELECT wo_id, itemsite_id, item_type, wo_number, wo_subnumber, item_number, item_descrip1, item_descrip2, uom_name, qoh, wobalance, allocated, ordered, reorderlevel, (qoh + ordered - wobalance) AS woavail, (qoh + ordered - allocated) AS totalavail FROM(SELECT wo_id, itemsite_id, item_type, wo_number, wo_subnumber, item_number, item_descrip1, item_descrip2, uom_name, noNeg(qtyAvailable(itemsite_id)) AS qoh, noNeg(wo_qtyord - wo_qtyrcv) AS wobalance, qtyAllocated(itemsite_id, wo_duedate) AS allocated, qtyOrdered(itemsite_id, wo_duedate) AS ordered, CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel FROM wo, itemsite, item, uom WHERE ((wo_id = pwoid) AND (itemsite_id = wo_itemsite_id) AND (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id)) ORDER BY wo_number, wo_subnumber) AS data LOOP _row.woinvav_itemsite_id := _x.itemsite_id; _row.woinvav_womatl_id := -1; _row.woinvav_type := _x.item_type; _row.woinvav_item_wo_number := _x.wo_number || '-' || _x.wo_subnumber; _row.woinvav_descrip := _x.item_descrip1 || ' ' || _x.item_descrip2; _row.woinvav_uomname := _x.uom_name; _row.woinvav_qoh := _x.qoh; _row.woinvav_balance := _x.wobalance; _row.woinvav_allocated := _x.allocated; _row.woinvav_ordered := _x.ordered; _row.woinvav_woavail := _x.woavail; _row.woinvav_totalavail := _x.totalavail; _row.woinvav_reorderlevel := _x.reorderlevel; _row.woinvav_level := 0; RETURN NEXT _row; --get materials for this level FOR _subx IN SELECT * FROM woinvavailmatl(_x.wo_id, 1, pshowshortage, pshowlowinventory) LOOP RETURN NEXT _subx; END LOOP; FOR _subx IN SELECT * FROM woinvavail(_x.wo_id, 1, pshowshortage, pshowlowinventory) LOOP RETURN NEXT _subx; END LOOP; END LOOP; ELSE SELECT wo_number FROM wo WHERE wo_id=pwoid LIMIT 1 INTO _wonumber; --display a single level sum of work order requirements _qry := 'SELECT wo_id, itemsite_id, womatl_id, item_type, wo_number, item_number, item_descrip1, item_descrip2, uom_name, qoh, wobalance, allocated, ordered, reorderlevel, (qoh + ordered - wobalance) AS woavail, (qoh + ordered - allocated) AS totalavail FROM (SELECT wo_id, itemsite_id, womatl_id, item_type, wo_number, item_number, item_descrip1, item_descrip2, uom_name, noNeg(qtyAvailable(itemsite_id)) AS qoh, noNeg(itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq - womatl_qtyiss)) AS wobalance, qtyAllocated(itemsite_id, womatl_duedate) AS allocated, qtyOrdered(itemsite_id, womatl_duedate) AS ordered, CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel FROM wo, womatl, itemsite, item, uom WHERE (womatl_wo_id=wo_id) AND (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) '; IF(pshowchildsum) THEN _qry := _qry || ' AND (wo_number=' || _wonumber || ')'; ELSE _qry := _qry || ' AND (womatl_wo_id=' || pwoid || ')'; END IF; _qry := _qry || ' ORDER BY item_number) AS data '; IF(pshowshortage) THEN _qry := _qry || ' WHERE (((qoh + ordered - allocated) < 0) OR ((qoh + ordered - wobalance) < 0)) '; END IF; IF(pshowlowinventory AND NOT pshowshortage) THEN _qry := _qry || ' WHERE (((qoh - allocated) < 0) OR ((qoh - wobalance) < 0)) '; END IF; FOR _x IN EXECUTE _qry LOOP _row.woinvav_itemsite_id := _x.itemsite_id; _row.woinvav_womatl_id := _x.womatl_id; _row.woinvav_type := _x.item_type; _row.woinvav_item_wo_number := _x.item_number; _row.woinvav_descrip := _x.item_descrip1 || ' ' || _x.item_descrip2; _row.woinvav_uomname := _x.uom_name; _row.woinvav_qoh := _x.qoh; _row.woinvav_balance := _x.wobalance; _row.woinvav_allocated := _x.allocated; _row.woinvav_ordered := _x.ordered; _row.woinvav_woavail := _x.woavail; _row.woinvav_totalavail := _x.totalavail; _row.woinvav_reorderlevel := _x.reorderlevel; _row.woinvav_level := 0; RETURN NEXT _row; END LOOP; END IF; RETURN; END; $_$; ALTER FUNCTION public.woinvavail(integer, boolean, boolean, boolean, boolean) OWNER TO admin; -- -- Name: woinvavailmatl(integer, integer, boolean, boolean); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION woinvavailmatl(integer, integer, boolean, boolean) RETURNS SETOF woinvav LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pwoid ALIAS FOR $1; plevel ALIAS FOR $2; pshowshortage ALIAS FOR $3; pshowlowinventory ALIAS FOR $4; _subrow woinvav%ROWTYPE; _subx RECORD; _qry TEXT; BEGIN _qry := 'SELECT itemsite_id, womatl_id, item_type, wo_number, wo_subnumber, womatl_ref, womatl_notes, item_number, item_descrip1, item_descrip2, uom_name, qoh, wobalance, allocated, ordered, (qoh + ordered - wobalance) AS woavail, (qoh + ordered - allocated) AS totalavail, reorderlevel FROM(SELECT itemsite_id, womatl_id, item_type, wo_number, wo_subnumber, womatl_ref, womatl_notes, item_number, item_descrip1, item_descrip2, uom_name, noNeg(qtyAvailable(itemsite_id)) AS qoh, noNeg(itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq - womatl_qtyiss)) AS wobalance, qtyAllocated(itemsite_id, womatl_duedate) AS allocated, qtyOrdered(itemsite_id, womatl_duedate) AS ordered, CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel FROM womatl, wo, itemsite, item, uom WHERE ((wo_id = womatl_wo_id) AND (womatl_itemsite_id = itemsite_id) AND (itemsite_item_id=item_id) AND (womatl_uom_id=uom_id) AND (NOT womatl_createwo OR womatl_createwo IS NULL))'; _qry := _qry || ' AND (wo_id=' || pwoid || ') ORDER BY item_number) AS data'; IF(pshowshortage) THEN _qry := _qry || ' WHERE (((qoh + ordered - allocated) < 0) OR ((qoh + ordered - wobalance) < 0)) '; END IF; IF(pshowlowinventory AND NOT pshowshortage) THEN _qry := _qry || ' WHERE (((qoh - allocated) < 0) OR ((qoh - wobalance) < 0)) '; END IF; FOR _subx IN EXECUTE _qry LOOP _subrow.woinvav_itemsite_id := _subx.itemsite_id; _subrow.woinvav_womatl_id := _subx.womatl_id; _subrow.woinvav_type := _subx.item_type; _subrow.woinvav_item_wo_number := _subx.item_number; _subrow.woinvav_descrip := _subx.item_descrip1 || ' ' || _subx.item_descrip2; _subrow.woinvav_uomname := _subx.uom_name; _subrow.woinvav_qoh := _subx.qoh; _subrow.woinvav_balance := _subx.wobalance; _subrow.woinvav_allocated := _subx.allocated; _subrow.woinvav_ordered := _subx.ordered; _subrow.woinvav_woavail := _subx.woavail; _subrow.woinvav_totalavail := _subx.totalavail; _subrow.woinvav_reorderlevel := _subx.reorderlevel; _subrow.woinvav_level := plevel; RETURN NEXT _subrow; END LOOP; RETURN; END; $_$; ALTER FUNCTION public.woinvavailmatl(integer, integer, boolean, boolean) OWNER TO admin; -- -- Name: wostarted(integer); Type: FUNCTION; Schema: public; Owner: admin -- CREATE FUNCTION wostarted(pwoid integer) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _result BOOLEAN := FALSE; BEGIN -- is it really this simple? SELECT (wo_wipvalue > 0) INTO _result FROM wo WHERE wo_id=pWoid; RETURN COALESCE(_result, FALSE); END; $$; ALTER FUNCTION public.wostarted(pwoid integer) OWNER TO admin; SET search_path = te, pg_catalog; -- -- Name: calcrate(numeric, character); Type: FUNCTION; Schema: te; Owner: admin -- CREATE FUNCTION calcrate(numeric, character) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAmount ALIAS FOR $1; pPeriod ALIAS FOR $2; _state integer; _count integer; BEGIN -- Convert amount to hourly rate IF (pPeriod = 'H') THEN -- hourly RETURN round(pAmount,2); ELSIF (pPeriod = 'D') THEN -- daily RETURN round(pAmount / 8, 2); ELSIF (pPeriod = 'W') THEN -- weekly RETURN round(pAmount / 40, 2); ELSIF (pPeriod = 'BW') THEN -- bi-weekly RETURN round(pAmount / 80, 2); ELSIF (pPeriod = 'M') THEN -- monthly RETURN round(pAmount / 160, 2); ELSIF (pPeriod = 'Y') THEN -- annually RETURN round(pAmount / 2080, 2); ELSE RAISE EXCEPTION 'Unknown period type passed: %', pPeriod; END IF; END; $_$; ALTER FUNCTION te.calcrate(numeric, character) OWNER TO admin; -- -- Name: copyitem(integer, text); Type: FUNCTION; Schema: te; Owner: admin -- CREATE FUNCTION copyitem(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSItemid ALIAS FOR $1; pTItemNumber ALIAS FOR $2; _itemid INTEGER; _r RECORD; _id INTEGER; BEGIN _itemid := public.copyItem(pSItemid, pTItemNumber); INSERT INTO te.teexp SELECT _itemid, teexp_expcat_id, teexp_accnt_id FROM te.teexp src WHERE (src.teexp_id=pSItemid); RETURN _itemid; END; $_$; ALTER FUNCTION te.copyitem(integer, text) OWNER TO admin; -- -- Name: invoicesheets(integer[]); Type: FUNCTION; Schema: te; Owner: admin -- CREATE FUNCTION invoicesheets(pheadids integer[]) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN te.invoicesheets(pHeadIDs, CURRENT_DATE); END; $$; ALTER FUNCTION te.invoicesheets(pheadids integer[]) OWNER TO admin; -- -- Name: invoicesheets(integer[], date); Type: FUNCTION; Schema: te; Owner: admin -- CREATE FUNCTION invoicesheets(pheadids integer[], pinvcdate date) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _invcnum text; _invcheadid integer; _invcitemid integer; _s record; _t record; _linenum integer; BEGIN -- Loop through time sheet items with matching criteria and make invoices FOR _s in SELECT DISTINCT teitem_cust_id, teitem_po, prj_id, teitem_curr_id FROM te.tehead JOIN te.teitem ON (teitem_tehead_id=tehead_id AND teitem_billable) JOIN prjtask ON (teitem_prjtask_id=prjtask_id) JOIN prj ON (prjtask_prj_id=prj_id) WHERE ((tehead_id IN (SELECT * FROM te.unnest(pHeadIDs) ) ) AND (teitem_billable) AND (teitem_invcitem_id IS NULL)) -- loop thru records and create invoices by customer, by PO for the provided headid LOOP --select nextval('invchead_invchead_id_seq') into _invcid; _invcnum := CAST(fetchInvcNumber() AS TEXT); _invcheadid := nextval('invchead_invchead_id_seq'); _linenum := 1; INSERT INTO invchead (invchead_id, invchead_cust_id, invchead_shipto_id, invchead_ordernumber, invchead_orderdate, invchead_posted, invchead_printed, invchead_invcnumber, invchead_invcdate, invchead_shipdate, invchead_ponumber, invchead_shipvia, invchead_fob, invchead_billto_name, invchead_billto_address1, invchead_billto_address2, invchead_billto_address3, invchead_billto_city, invchead_billto_state, invchead_billto_zipcode, invchead_billto_phone, invchead_shipto_name, invchead_shipto_address1, invchead_shipto_address2, invchead_shipto_address3, invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode, invchead_shipto_phone, invchead_salesrep_id, invchead_commission, invchead_terms_id, invchead_freight, invchead_misc_amount, invchead_misc_descrip, invchead_misc_accnt_id, invchead_payment, invchead_paymentref, invchead_notes, invchead_billto_country, invchead_shipto_country, invchead_prj_id, invchead_curr_id, invchead_gldistdate, invchead_recurring, invchead_recurring_interval, invchead_recurring_type, invchead_recurring_until, invchead_recurring_invchead_id, invchead_shipchrg_id, invchead_taxzone_id, invchead_void, invchead_saletype_id, invchead_shipzone_id) SELECT _invcheadid, cust_id, -1, '', current_date, false, false, _invcnum, COALESCE(pInvcdate, current_date), current_date, _s.teitem_po, '', '', cust_name, COALESCE(addr_line1,''), COALESCE(addr_line2,''), COALESCE(addr_line3,''), COALESCE(addr_city,''), COALESCE(addr_state,''), COALESCE(addr_postalcode,''), cntct_phone, '', '', '', '', '', '', '', '', cust_salesrep_id, salesrep_commission, cust_terms_id, 0, 0, '', -1, 0, '', '', COALESCE(addr_country,''), '', _s.prj_id, _s.teitem_curr_id, current_date, false, null, null, null, null, null, cust_taxzone_id, false, null, null FROM custinfo JOIN salesrep ON (cust_salesrep_id=salesrep_id) LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) WHERE (cust_id=_s.teitem_cust_id); -- loop thru all lines of the sheet FOR _t IN SELECT teitem_id, teitem_linenumber, tehead_warehous_id, teitem_type, tehead_emp_id, cust_taxzone_id, item_number, teitem_cust_id, teitem_po, teitem_item_id, teitem_qty, teitem_uom_id, teitem_rate, teitem_notes FROM te.teitem JOIN te.tehead ON (teitem_tehead_id = tehead_id) JOIN custinfo ON (cust_id = teitem_cust_id) JOIN item ON (item_id = teitem_item_id) JOIN prjtask ON (teitem_prjtask_id=prjtask_id) JOIN prj ON (prjtask_prj_id=prj_id) WHERE ((tehead_id IN (SELECT * FROM te.unnest(pHeadIDs) ) ) AND (teitem_billable) AND (teitem_invcitem_id IS NULL) AND (item_id = teitem_item_id) AND (teitem_cust_id = _s.teitem_cust_id) AND (teitem_po = _s.teitem_po) AND (prj_id = _s.prj_id) AND (teitem_curr_id = _s.teitem_curr_id)) ORDER BY teitem_linenumber LOOP _invcitemid := nextval('invcitem_invcitem_id_seq'); INSERT INTO invcitem (invcitem_id, invcitem_invchead_id, invcitem_linenumber, invcitem_item_id, invcitem_warehous_id, invcitem_custpn, invcitem_number, invcitem_descrip, invcitem_ordered, invcitem_billed, invcitem_custprice, invcitem_price, invcitem_notes, invcitem_salescat_id, invcitem_taxtype_id, invcitem_qty_uom_id, invcitem_qty_invuomratio, invcitem_price_uom_id, invcitem_price_invuomratio, invcitem_coitem_id, invcitem_updateinv, invcitem_rev_accnt_id) SELECT _invcitemid, _invcheadid, _linenum, _t.teitem_item_id, _t.tehead_warehous_id, '', '', '', _t.teitem_qty, _t.teitem_qty, _t.teitem_rate, _t.teitem_rate, _t.teitem_notes, -1, getItemTaxType(item_id, _t.cust_taxzone_id), _t.teitem_uom_id, itemuomtouomratio(item_id, _t.teitem_uom_id, item_inv_uom_id), _t.teitem_uom_id, itemuomtouomratio(item_id, _t.teitem_uom_id, item_inv_uom_id), null, false, null FROM item WHERE (item_id=_t.teitem_item_id); _linenum := _linenum + 1; -- Update the time sheet item record UPDATE te.teitem SET teitem_invcitem_id = _invcitemid WHERE (teitem_id = _t.teitem_id); END LOOP; END LOOP; RETURN 1; END; $$; ALTER FUNCTION te.invoicesheets(pheadids integer[], pinvcdate date) OWNER TO admin; -- -- Name: postsheet(integer, text, text); Type: FUNCTION; Schema: te; Owner: admin -- CREATE FUNCTION postsheet(integer, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTeheadId ALIAS FOR $1; pPhrase1 ALIAS FOR $2; pPhrase2 ALIAS FOR $3; _r record; _notes TEXT; _value NUMERIC; _olaccntid INTEGER; _expaccntid INTEGER; _count INTEGER; BEGIN -- Validate: No posting for contractors IF (SELECT (count(teemp_id) > 0) FROM te.tehead JOIN te.teemp ON (tehead_emp_id=teemp_emp_id) WHERE ((tehead_id=pTeheadId) AND (teemp_contractor))) THEN RAISE EXCEPTION 'Time and Expense Sheets can not be posted for contractors. Voucher instead.'; END IF; -- Get labor and overhead account SELECT accnt_id INTO _olaccntid FROM accnt WHERE (accnt_id=fetchmetricvalue('PrjLaborAndOverhead')); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count = 0) THEN RAISE EXCEPTION 'No valid Project Labor and Overhead Account Defined'; END IF; -- Get applicable time sheets FOR _r IN SELECT tehead_number, teitem_id, teitem_linenumber, teitem_type, teitem_notes, item_descrip1, teitem_qty, teexp_expcat_id, teexp_accnt_id, emp_code, emp_wage, emp_wage_period, prj_id, prj_number FROM te.tehead JOIN te.teitem ON (teitem_tehead_id=tehead_id) JOIN item ON (teitem_item_id=item_id) JOIN te.teexp ON (teitem_item_id=teexp_id) JOIN emp ON (tehead_emp_id=emp_id) JOIN prjtask ON (prjtask_id=teitem_prjtask_id) JOIN prj ON (prj_id=prjtask_prj_id) WHERE ((tehead_id = pTeheadId) AND (NOT teitem_posted) AND (teitem_vodist_id IS NULL) AND (teitem_type = 'T')) LOOP -- Determine value _value := te.calcRate(_r.emp_wage, _r.emp_wage_period) * _r.teitem_qty; -- Determine G/L account to post to IF (_r.teexp_accnt_id > 1) THEN _expaccntid := getPrjAccntId(_r.prj_id, _r.teexp_accnt_id); ELSE SELECT getPrjAccntId(_r.prj_id, expcat_exp_accnt_id) INTO _expaccntid FROM expcat WHERE (expcat_id=_r.teexp_expcat_id); END IF; -- Execute the posting _notes := (pPhrase1 || _r.item_descrip1 || '/' || _r.emp_code || pPhrase2 || ' ' || _r.prj_number); PERFORM insertGLTransaction( 'T/E', 'TE', _r.tehead_number, _notes, _olaccntid, _expaccntid, -1, _value, current_date ); -- Update the time sheet item UPDATE te.teitem SET teitem_posted = true, teitem_postedvalue = teitem_postedvalue + _value WHERE (teitem_id=_r.teitem_id); END LOOP; RETURN 1; END; $_$; ALTER FUNCTION te.postsheet(integer, text, text) OWNER TO admin; -- -- Name: sheetstate(integer, character); Type: FUNCTION; Schema: te; Owner: admin -- CREATE FUNCTION sheetstate(integer, character) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTeheadId ALIAS FOR $1; pType ALIAS FOR $2; _state INTEGER := -1; BEGIN -- Check and return the process state of the sheet -- 1 = All processed -- 0 = Processing required -- -1 = Not Applicable IF (pType = 'I') THEN SELECT MIN(CASE teitem_invcitem_id IS NULL WHEN TRUE THEN 0 ELSE 1 END) INTO _state FROM te.teitem WHERE ((teitem_tehead_id=pTeheadId) AND (teitem_billable) AND (teitem_qty >= 0)); ELSIF (pType = 'V') THEN -- todo: why outer join then check teitem_type and vend_id is not null? SELECT MIN(CASE teitem_vodist_id IS NULL WHEN TRUE THEN 0 ELSE 1 END) INTO _state FROM te.tehead JOIN emp ON (tehead_emp_id=emp_id) LEFT OUTER JOIN te.teemp ON (emp_id=teemp_emp_id) LEFT OUTER JOIN te.teitem ON (teitem_tehead_id=tehead_id) LEFT OUTER JOIN vendinfo ON (UPPER(emp_code)=UPPER(vend_number)) WHERE ((teitem_tehead_id=pTeheadId) AND ((teitem_type = 'E' AND NOT teitem_prepaid) OR (teitem_type = 'T' AND COALESCE(teemp_contractor,false))) AND (vend_id IS NOT NULL) AND (teitem_qty > 0)); ELSIF (pType = 'P') THEN SELECT MIN(CASE teitem_posted WHEN FALSE THEN 0 ELSE 1 END) INTO _state FROM te.teitem JOIN te.tehead ON (teitem_tehead_id=tehead_id) LEFT JOIN te.teemp ON (tehead_emp_id=teemp_emp_id) WHERE ((teitem_tehead_id=pTeheadId) AND (teitem_type = 'T') AND (teemp_contractor IS NULL or teemp_contractor = false)); ELSE -- TODO: either make ErrorReporter::error find this or use xtuple RAISE EXCEPTION 'Unknown process type % [xtte: sheetstate, -2, %]', pType, pType; END IF; RETURN _state; END; $_$; ALTER FUNCTION te.sheetstate(integer, character) OWNER TO admin; -- -- Name: triggertehead(); Type: FUNCTION; Schema: te; Owner: admin -- CREATE FUNCTION triggertehead() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; _sense INTEGER := 0; BEGIN -- Determine whether we are adding or subtracting totals IF (TG_OP = 'UPDATE') THEN IF (OLD.tehead_status = 'O' AND NEW.tehead_status = 'A') THEN -- Approving so add _sense := 1; ELSIF (OLD.tehead_status = 'A' AND NEW.tehead_status = 'O') THEN -- Unapproving so subtract _sense := -1; END IF; END IF; IF (_sense != 0) THEN -- Loop thru all lines of the sheet and update project FOR _r in SELECT teitem_prjtask_id, teitem_type, teitem_qty, teitem_total FROM te.teitem WHERE teitem_tehead_id = NEW.tehead_id LOOP IF (_r.teitem_type = 'T') THEN UPDATE prjtask SET prjtask_hours_actual = prjtask_hours_actual + _r.teitem_qty * _sense WHERE prjtask_id = _r.teitem_prjtask_id; ELSE UPDATE prjtask SET prjtask_exp_actual = prjtask_exp_actual + _r.teitem_total * _sense WHERE prjtask_id = _r.teitem_prjtask_id; END IF; END LOOP; END IF; RETURN NEW; END; $$; ALTER FUNCTION te.triggertehead() OWNER TO admin; -- -- Name: triggerteitem(); Type: FUNCTION; Schema: te; Owner: admin -- CREATE FUNCTION triggerteitem() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; _status CHAR(1) := 'O'; BEGIN -- Validate whether we can take this action IF (TG_OP = 'UPDATE') THEN IF ((OLD.teitem_type != NEW.teitem_type) OR (OLD.teitem_workdate != NEW.teitem_workdate) OR (OLD.teitem_cust_id != NEW.teitem_cust_id) OR (OLD.teitem_po != NEW.teitem_po) OR (OLD.teitem_item_id != NEW.teitem_item_id) OR (OLD.teitem_qty != NEW.teitem_qty) OR (OLD.teitem_rate != NEW.teitem_rate) OR (OLD.teitem_total != NEW.teitem_total) OR (OLD.teitem_billable != NEW.teitem_billable) OR (OLD.teitem_prepaid != NEW.teitem_prepaid) OR (OLD.teitem_notes != NEW.teitem_notes)) THEN SELECT tehead_status INTO _status FROM te.tehead WHERE tehead_id=NEW.teitem_tehead_id; END IF; ELSIF (TG_OP = 'INSERT') THEN SELECT tehead_status INTO _status FROM te.tehead WHERE tehead_id=NEW.teitem_tehead_id; ELSE -- Must be delete SELECT tehead_status INTO _status FROM te.tehead WHERE tehead_id=OLD.teitem_tehead_id; END IF; IF (_status != 'O') THEN RAISE EXCEPTION 'Time and Expense Sheets may only be edited or deleted when the status is Open'; END IF; _status := 'C'; -- Update header status, default is to close if all processing complete IF (TG_OP = 'UPDATE') THEN IF ((COALESCE(OLD.teitem_invcitem_id,-1) != COALESCE(NEW.teitem_invcitem_id,-1)) OR (COALESCE(OLD.teitem_vodist_id,-1) != COALESCE(NEW.teitem_vodist_id,-1)) OR (OLD.teitem_posted != NEW.teitem_posted)) THEN SELECT te.sheetstate(NEW.teitem_tehead_id, 'I') AS invoiced, te.sheetstate(NEW.teitem_tehead_id, 'V') AS vouchered, te.sheetstate(NEW.teitem_tehead_id, 'P') AS posted INTO _r; IF (_r.invoiced = 0 OR _r.vouchered = 0 OR _r.posted = 0) THEN _status := 'A'; -- Something is still open, so approved END IF; UPDATE te.tehead SET tehead_status = _status WHERE (tehead_id=NEW.teitem_tehead_id); END IF; END IF; -- Update header with last use info IF (TG_OP = 'DELETE') THEN UPDATE te.tehead SET tehead_lastupdated=('now'::text)::timestamp(6) with time zone WHERE (tehead_id=OLD.teitem_tehead_id); ELSE UPDATE te.tehead SET tehead_lastupdated=('now'::text)::timestamp(6) with time zone, tehead_username=getEffectiveXtUser() WHERE (tehead_id=NEW.teitem_tehead_id); END IF; RETURN NEW; END; $$; ALTER FUNCTION te.triggerteitem() OWNER TO admin; -- -- Name: triggerteprj(); Type: FUNCTION; Schema: te; Owner: admin -- CREATE FUNCTION triggerteprj() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _update BOOLEAN := false; BEGIN IF (TG_OP = 'INSERT') THEN _update = true; ELSIF (TG_OP = 'UPDATE') THEN IF (COALESCE(OLD.teprj_cust_id,-1) != COALESCE(NEW.teprj_cust_id,-1)) THEN _update = true; END IF; END IF; IF (_update) THEN UPDATE te.teprjtask SET teprjtask_cust_id=NEW.teprj_cust_id FROM prjtask WHERE ((teprjtask_prjtask_id=prjtask_id) AND (prjtask_prj_id=NEW.teprj_prj_id)); END IF; RETURN NEW; END; $$; ALTER FUNCTION te.triggerteprj() OWNER TO admin; -- -- Name: unnest(anyarray); Type: FUNCTION; Schema: te; Owner: admin -- CREATE FUNCTION unnest(anyarray) RETURNS SETOF anyelement LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT $1[i] FROM generate_series(array_lower($1,1), array_upper($1,1)) i; $_$; ALTER FUNCTION te.unnest(anyarray) OWNER TO admin; -- -- Name: vouchersheet(integer); Type: FUNCTION; Schema: te; Owner: admin -- CREATE FUNCTION vouchersheet(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pHeadID ALIAS FOR $1; _distamt NUMERIC; _glaccnt INTEGER; _notes TEXT; _s RECORD; _total NUMERIC := 0; _v RECORD; _vodistid INTEGER; _voheadid INTEGER; BEGIN FOR _v IN -- distinct filters duplicate rows returned because of the teitem join -- TODO: can we push the teitem down into the loop and avoid the distinct? SELECT DISTINCT tehead_id, tehead_number, tehead_weekending, tehead_notes, teitem_curr_id, emp_wage, emp_wage_period, vend_id, vend_taxzone_id, vend_terms_id, vend_number, vend_1099, COALESCE(teemp_contractor, false) AS isContractor FROM te.tehead JOIN te.teitem ON (teitem_tehead_id=tehead_id) JOIN emp ON (tehead_emp_id=emp_id) JOIN vendinfo ON (UPPER(emp_code)=UPPER(vend_number)) LEFT OUTER JOIN te.teemp ON (emp_id=teemp_emp_id) WHERE ((tehead_id = pHeadID) AND (teitem_prepaid = false) AND (teitem_vodist_id IS NULL) AND (teitem_type = 'E' OR (COALESCE(teemp_contractor,false) AND (teitem_empcost > 0 OR emp_wage > 0 )))) LOOP INSERT INTO vohead (vohead_id, vohead_number, vohead_vend_id, vohead_distdate, vohead_docdate, vohead_duedate, vohead_terms_id, vohead_taxzone_id, vohead_invcnumber, vohead_reference, vohead_amount, vohead_1099, vohead_curr_id, vohead_notes, vohead_posted, vohead_misc, vohead_pohead_id) VALUES (DEFAULT, fetchVoNumber(), _v.vend_id, _v.tehead_weekending, _v.tehead_weekending, determineDueDate(_v.vend_terms_id, _v.tehead_weekending), _v.vend_terms_id, _v.vend_taxzone_id, 'N/A', ('T&E Sheet ' || _v.tehead_number), 0, _v.vend_1099, _v.teitem_curr_id, _v.tehead_notes, false, true, -1) RETURNING vohead_id INTO _voheadid; FOR _s IN SELECT teitem_id, teitem_linenumber, teitem_workdate, teitem_type, item_number, teitem_item_id, teitem_qty, prjtask_prj_id, CASE WHEN teitem_empcost > 0 THEN teitem_empcost ELSE te.calcRate(_v.emp_wage, _v.emp_wage_period) END AS rate, teitem_total, teitem_type, teitem_notes, teexp_expcat_id, teexp_accnt_id FROM te.teitem JOIN te.teexp ON (teitem_item_id=teexp_id) JOIN item ON (teitem_item_id=item_id) JOIN prjtask ON (teitem_prjtask_id=prjtask_id) WHERE ((teitem_tehead_id = _v.tehead_id) AND (teitem_curr_id = _v.teitem_curr_id) AND (teitem_prepaid = false) AND (teitem_vodist_id IS NULL) AND (teitem_type = 'E' OR (_v.isContractor AND (teitem_empcost > 0 OR _v.emp_wage > 0 )))) -- Loop thru records and create vouchers by supplier for the provided headid LOOP -- insert vodist records here _vodistid = nextval('vodist_vodist_id_seq'); -- Map expense directly to account so we can get project account mapping if applicable IF (_s.teexp_accnt_id > 1) THEN _glaccnt := getPrjAccntId(_s.prjtask_prj_id, _s.teexp_accnt_id); ELSE SELECT getPrjAccntId(_s.prjtask_prj_id, expcat_exp_accnt_id) INTO _glaccnt FROM expcat WHERE (expcat_id=_s.teexp_expcat_id); END IF; IF (_s.teitem_type = 'T') THEN -- Time sheet record _notes := formatdate(_s.teitem_workdate) || E'\t' || _s.item_number || E'\t' || formatQty(_s.teitem_qty) || ' hours' || E'\t'; _distamt := _s.rate * _s.teitem_qty; ELSE -- Expense record _notes := formatdate(_s.teitem_workdate) || E'\t' || _s.item_number || E'\t' || _s.teitem_notes || E'\t'; _distamt := _s.teitem_total; END IF; INSERT INTO vodist (vodist_id, vodist_vohead_id, vodist_poitem_id, vodist_costelem_id, vodist_accnt_id, vodist_amount, vodist_expcat_id, vodist_notes) VALUES (_vodistid, _voheadid, -1, -1, _glaccnt, _distamt, -1, _notes); _total := _total + _distamt; -- Update the te.teitem record with the relationship UPDATE te.teitem SET teitem_vodist_id = _vodistid WHERE teitem_id = _s.teitem_id; END LOOP; UPDATE vohead SET vohead_amount = _total WHERE (vohead_id=_voheadid); _total := 0; END LOOP; RETURN 1; END; $_$; ALTER FUNCTION te.vouchersheet(integer) OWNER TO admin; SET search_path = xt, pg_catalog; -- -- Name: add_column(text, text, text, text, text, text); Type: FUNCTION; Schema: xt; Owner: admin -- CREATE FUNCTION add_column(table_name text, column_name text, type_name text, constraint_text text DEFAULT NULL::text, schema_name text DEFAULT 'xt'::text, column_comment text DEFAULT NULL::text) RETURNS boolean LANGUAGE plpgsql AS $$ declare count integer; query text; comment_query text; begin perform * from pg_class c, pg_namespace n, pg_attribute a, pg_type t where c.relname = table_name and n.nspname = schema_name and a.attname = column_name and n.oid = c.relnamespace and a.attnum > 0 and a.attrelid = c.oid and a.atttypid = t.oid; get diagnostics count = row_count; if (count > 0) then return false; end if; query = 'alter table ' || schema_name || '.' || table_name || ' add column ' || column_name || ' ' || type_name || ' ' || coalesce(constraint_text, ''); execute query; if (column_comment is not null) then comment_query = 'comment on column ' || schema_name || '.' || table_name || '.' || column_name || ' is ' || quote_literal(column_comment); execute comment_query; end if; return true; end; $$; ALTER FUNCTION xt.add_column(table_name text, column_name text, type_name text, constraint_text text, schema_name text, column_comment text) OWNER TO admin; -- -- Name: add_comment_type(text, text, text); Type: FUNCTION; Schema: xt; Owner: admin -- CREATE FUNCTION add_comment_type(text, text, text) RETURNS boolean LANGUAGE plpgsql AS $_$ DECLARE _module ALIAS FOR $1; _comment ALIAS FOR $2; _descr ALIAS FOR $3; _cmntid INTEGER; BEGIN SELECT source_id INTO _cmntid FROM source WHERE source_name = _comment; IF (NOT FOUND) THEN INSERT INTO source (source_module, source_name, source_descrip) VALUES (_module, _comment, _descr) RETURNING source_id INTO _cmntid; INSERT INTO cmnttypesource (cmnttypesource_cmnttype_id, cmnttypesource_source_id) VALUES (1, _cmntid); -- General Comments INSERT INTO cmnttypesource (cmnttypesource_cmnttype_id, cmnttypesource_source_id) VALUES (2, _cmntid); -- ChangeLog Comments END IF; RETURN true; END; $_$; ALTER FUNCTION xt.add_comment_type(text, text, text) OWNER TO admin; -- -- Name: add_constraint(text, text, text, text); Type: FUNCTION; Schema: xt; Owner: admin -- CREATE FUNCTION add_constraint(table_name text, constraint_name text, constraint_text text, schema_name text DEFAULT 'xt'::text) RETURNS boolean LANGUAGE plpgsql AS $$ declare count integer; query text; begin perform * from pg_constraint join pg_namespace on (connamespace=pg_namespace.oid) join pg_class f on (conrelid=f.oid) where f.relname = table_name and nspname = schema_name and conname = constraint_name; get diagnostics count = row_count; if (count > 0) then return false; end if; query = 'alter table ' || schema_name || '.' || table_name || ' add constraint ' || constraint_name || ' ' || constraint_text || ';'; execute query; return true; end; $$; ALTER FUNCTION xt.add_constraint(table_name text, constraint_name text, constraint_text text, schema_name text) OWNER TO admin; -- -- Name: add_index(text, text, text, text, text); Type: FUNCTION; Schema: xt; Owner: admin -- CREATE FUNCTION add_index(table_name text, column_names text, index_name text, using_name text DEFAULT 'btree'::text, schema_name text DEFAULT 'xt'::text) RETURNS boolean LANGUAGE plpgsql AS $$ declare count integer; query text; begin perform * from pg_index join pg_class s on (indexrelid=s.oid) join pg_class f on (indrelid=f.oid) join pg_namespace on (f.relnamespace=pg_namespace.oid) where f.relname = table_name and nspname = schema_name and s.relname = index_name; get diagnostics count = row_count; if (count > 0) then return false; end if; query = 'create index ' || index_name || ' on ' || schema_name || '.' || table_name || ' using ' || using_name || '(' || column_names || ');'; execute query; return true; end; $$; ALTER FUNCTION xt.add_index(table_name text, column_names text, index_name text, using_name text, schema_name text) OWNER TO admin; -- -- Name: add_primary_key(text, text, text); Type: FUNCTION; Schema: xt; Owner: admin -- CREATE FUNCTION add_primary_key(table_name text, column_name text, schema_name text DEFAULT 'xt'::text) RETURNS boolean LANGUAGE plpgsql AS $$ declare count integer; query text; begin perform * from pg_constraint join pg_namespace on (connamespace=pg_namespace.oid) join pg_class f on (conrelid=f.oid) where f.relname = table_name and nspname = schema_name and contype = 'p'; get diagnostics count = row_count; if (count > 0) then return false; end if; query = 'alter table ' || schema_name || '.' || table_name || ' add primary key (' || column_name || ');'; execute query; return true; end; $$; ALTER FUNCTION xt.add_primary_key(table_name text, column_name text, schema_name text) OWNER TO admin; -- -- Name: create_table(text, text, boolean, text); Type: FUNCTION; Schema: xt; Owner: admin -- CREATE FUNCTION create_table(table_name text, schema_name text DEFAULT 'xt'::text, with_oids boolean DEFAULT false, inherit_table text DEFAULT NULL::text) RETURNS boolean LANGUAGE plpgsql AS $$ declare count integer; query text; with_clause text := ''; inherit_from text := ''; begin perform * from pg_tables where schemaname = schema_name and tablename = table_name; get diagnostics count = row_count; if (count > 0) then return false; end if; if (with_oids) then with_clause := 'with (OIDS=TRUE)'; end if; if (inherit_table is not null) then inherit_from := ' INHERITS (' || inherit_table || ') '; end if; query = 'create table ' || schema_name || '.' || table_name || '()' || inherit_from || with_clause || '; grant all on ' || schema_name || '.' || table_name || ' to xtrole;'; execute query; return true; end; $$; ALTER FUNCTION xt.create_table(table_name text, schema_name text, with_oids boolean, inherit_table text) OWNER TO admin; -- -- Name: install_js(text, text, text, text, boolean); Type: FUNCTION; Schema: xt; Owner: admin -- CREATE FUNCTION install_js(name_space text, type_name text, context text, javascript text, is_extension boolean DEFAULT false) RETURNS void LANGUAGE plv8 AS $_$ if(!name_space) throw new Error("A name space is required"); if(!type_name) throw new Error("A type is required"); if(!context) throw new Error("A context is required"); sql = 'select js_id as "id", ' + ' js_ext as "isExtension" ' + 'from xt.js ' + 'where js_namespace = $1 ' + ' and js_type = $2 ' + ' and js_context = $3'; js = plv8.execute(sql, [name_space, type_name, context])[0]; if(js) { if(js.isExtension !== is_extension) throw new Error("Can not change extension state for {namespace}.{type} in context {context}." .replace(/{namespace}/, name_space) .replace(/{type}/, type_name) .replace(/{context}/, context)); sql = 'update xt.js set ' + ' js_text = $1 ' + 'where js_id = $2'; plv8.execute(sql, [javascript, js.id]); } else { sql = 'insert into xt.js ( js_namespace, js_type, js_context, js_text, js_ext ) values ($1, $2, $3, $4, $5)'; plv8.execute(sql, [name_space, type_name, context, javascript, is_extension]); } // Reinitialize our plv8 code now that is has changed. plv8.execute("SELECT xt.js_init(false, true)"); $_$; ALTER FUNCTION xt.install_js(name_space text, type_name text, context text, javascript text, is_extension boolean) OWNER TO admin; -- -- Name: js_init(boolean, boolean); Type: FUNCTION; Schema: xt; Owner: admin -- CREATE FUNCTION js_init(debug boolean DEFAULT false, initialize boolean DEFAULT false) RETURNS void LANGUAGE plv8 AS $_$ return (function () { if (plv8.XT && !initialize && !debug) { return; } DEBUG = debug ? debug : false; if (plv8.version < '1.3.0'){ plv8.elog(ERROR, 'plv8 version 1.3.0 or greater required. This version is = ', plv8.version); } // .......................................................... // METHODS // /** Return whether an array contains an item. @param {Any} @returns Boolean */ Array.prototype.contains = function (item) { var i = this.length; while (i--) { if (this[i] === item) { return true; } } return false; } /** Return the index of an item in an array @param {Any} @returns Any */ Array.prototype.indexOf = function (item) { var i = this.length; while (i--) { if (this[i] === item) { return i; } } return -1; } /** Remove an item from an array and return it. @param {Any} @returns Any */ Array.prototype.remove = function (item) { return this.contains(item) ? this.splice(this.indexOf(item), 1) : false; } /** Returns an the first item in an array with a property matching the passed value. @param {String} property name to search on @param {Any} value to search for @param Object item found or null */ Array.prototype.findProperty = function (key, value) { for (var i = 0; i < this.length; i++) { for (var prop in this[i]) { if (prop === key && this[i][prop] === value) { return this[i]; } } } return false; } /** Remove duplicates from an array. @returns Array with no duplicates. */ /* TODO: Or add underscore.js support. */ Array.prototype.unique = function () { var a = this.concat(); for(var i=0; i 0) { sql = sql + ","; } sql = sql + "$" + (i + 1); if(cast) { sql = sql + "::" + cast; } } sql = sql + ") as result"; if (DEBUG) { XT.debug('sql =', sql); XT.debug('params =', params); } var result = plv8.execute(sql, params)[0].result; if(typeof result === 'number' && result < 0) { errorString = XT.errorToString(functionName, result); throw new handleError(errorString, 424); } else { return result; } }; /** * Wrap PostgreSQL's format() function to format SQL Injection safe queires or general strings. * http://www.postgresql.org/docs/9.1/interactive/functions-string.html#FUNCTIONS-STRING-OTHER * * Example: var query = XT.format("select * from %I", ["cntct"]); * Returns: 'select * from cntct' * Example: var query = XT.format("select %1$I.* from %2$I.%1$I {join} where %1$I.%3$I = $1", ["contact", "xm", "id"]); * Returns: 'select contact.* from xm.contact {join} where contact.number = $1' * * SQL Injection attemp: * Example: var query = XT.format("SELECT * FROM %I", ["cntct; select * from pg_roles; --"]); * Safely escaped/quoted query: * Returns: 'SELECT * FROM "cntct; select * from pg_roles; --"' * * @param {String} The string with format tokens to replace. * @param {Array} An array of replacement strings. * @returns {String} Safely escaped string with tokens replaced. */ XT.format = function (string, args) { if (typeof string !== 'string' || XT.typeOf(args) !== 'array' || !args.length) { return false; } var query = "select format($1", params = ""; for(var i = 0; i < args.length; i++) { params = params + ", $" + (i + 2); } query = query + params + ")"; /* Pass 'string' to format() as the first parameter. */ args.unshift(string); /* if (DEBUG) { XT.debug('XT.format sql =', query); XT.debug('XT.format args =', args); } */ string = plv8.execute(query, args)[0].format; /* Remove 'string' from args to prevent reference errors. */ args.shift(); return string; }; /** * Wrap formatDate() * * @param Object The date. * @returns {String} Date string in user's locale. */ XT.formatDate = function (string) { var query = "select formatdate($1);" if (DEBUG) { XT.debug('XT.formatDate sql =', query); XT.debug('XT.formatDate arg =', string); } ret = plv8.execute(query, [string])[0]; return ret; }; /** * Wrap formatCost() * * @param Number The cost. * @returns {Number} Cost number in user's locale & scale. */ XT.formatCost = function (numb) { var query = "select formatcost($1);" if (DEBUG) { XT.debug('XT.formatCost sql =', query); XT.debug('XT.formatCost arg =', numb); } ret = plv8.execute(query, [numb])[0]; return ret; }; /** * Wrap formatMoney() * * @param Number The money. * @returns {Number} Money in user's locale & scale. */ XT.formatMoney = function (numb) { var query = "select formatmoney($1);" if (DEBUG) { XT.debug('XT.formatMoney sql =', query); XT.debug('XT.formatMoney arg =', numb); } ret = plv8.execute(query, [numb])[0]; return ret; }; /** * Wrap formatSalesPrice() * * @param Number The price. * @returns {Number} Price in user's locale & scale. */ XT.formatSalesPrice = function (numb) { var query = "select formatsalesprice($1);" if (DEBUG) { XT.debug('XT.formatSalesPrice sql =', query); XT.debug('XT.formatSalesPrice arg =', numb); } ret = plv8.execute(query, [numb])[0]; return ret; }; /** * Wrap formatPurchPrice() * * @param Number The price. * @returns {Number} Price in user's locale & scale. */ XT.formatPurchPrice = function (numb) { var query = "select formatpurchprice($1);" if (DEBUG) { XT.debug('XT.formatPurchPrice sql =', query); XT.debug('XT.formatPurchPrice arg =', numb); } ret = plv8.execute(query, [numb])[0]; return ret; }; /** * Wrap formatExtPrice() * * @param Number The price. * @returns {Number} Price in user's locale & scale. */ XT.formatExtPrice = function (numb) { var query = "select formatExtPrice($1);" if (DEBUG) { XT.debug('XT.formatExtPrice sql =', query); XT.debug('XT.formatExtPrice arg =', numb); } ret = plv8.execute(query, [numb])[0]; return ret; }; /** * Wrap formatQty() * * @param Number The quantity. * @returns {Number} Quantity in user's locale & scale. */ XT.formatQty = function (numb) { var query = "select formatqty($1);" if (DEBUG) { XT.debug('XT.formatQty sql =', query); XT.debug('XT.formatQty arg =', numb); } ret = plv8.execute(query, [numb])[0]; return ret; }; /** * Wrap formatQtyPer() * * @param Number The quantity per. * @returns {Number} Quantity per in user's locale & scale. */ XT.formatQtyPer = function (numb) { var query = "select formatqtyper($1);" if (DEBUG) { XT.debug('XT.formatQtyPer sql =', query); XT.debug('XT.formatQtyPer arg =', numb); } ret = plv8.execute(query, [numb])[0]; return ret; }; /** * Wrap formatRatio() * * @param Number The ratio. * @returns {Number} Ratio in user's locale & scale. */ XT.formatRatio = function (numb) { var query = "select formatRatio($1);" if (DEBUG) { XT.debug('XT.formatRatio sql =', query); XT.debug('XT.formatRatio arg =', numb); } ret = plv8.execute(query, [numb])[0]; return ret; }; /** * Wrap formatPrcnt() * * @param Number The percent. * @returns {Number} Percent in user's locale & scale. */ XT.formatPrcnt = function (numb) { var query = "select formatprcnt($1);" if (DEBUG) { XT.debug('XT.formatPrcnt sql =', query); XT.debug('XT.formatPrcnt arg =', numb); } ret = plv8.execute(query, [numb])[0]; return ret; }; /** * Wrap formatWeight() * * @param Number The weight. * @returns {Number} Weight in user's locale & scale. */ XT.formatWeight = function (numb) { var query = "select formatweight($1);" if (DEBUG) { XT.debug('XT.formatWeight sql =', query); XT.debug('XT.formatWeight arg =', numb); } ret = plv8.execute(query, [numb])[0]; return ret; }; /** * Wrap formatNumeric() * * @param Number. * @returns {Number} Number in user's locale & scale. */ XT.formatNumeric = function (numb, text) { var query = "select formatNumeric($1, $2);" if (DEBUG) { XT.debug('XT.formatNumeric sql =', query); XT.debug('XT.formatNumeric arg1 =', numb); XT.debug('XT.formatNumeric arg2 =', text); } ret = plv8.execute(query, [numb, text])[0]; return ret; }; /** Return a universally unique identifier. We're using this solution: http://stackoverflow.com/a/8809472/251019 From here: http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript @return {String} */ XT.generateUUID = function () { var d = new Date().getTime(); var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = (d + Math.random() * 16) % 16 | 0; d = Math.floor(d / 16); return (c === 'x' ? r : (r&0x7|0x8)).toString(16); }); return uuid; }; XT.message = function (code, message) { var msg = {code: code, message: message.substring(0, 90)}; plv8.elog(INFO, JSON.stringify(msg)); return 'Handled by XT.message'; } /** Extended version of javascript 'typeof' that also recognizes arrays */ XT.typeOf = function(value) { var str = typeof value; if (str === 'object') { if (value) { if (typeof value.length === 'number' && !(value.propertyIsEnumerable('length')) && typeof value.splice === 'function') { str = 'array'; } } else str = 'null'; } return str; } XT.extend = function(obj) { Array.prototype.slice.call(arguments, 1).forEach(function(source) { for (var prop in source) { obj[prop] = source[prop]; } }); return obj; } // .......................................................... // PROCESS // var res, sql, path; /* put xt at the front of the search path */ path = plv8.execute('select show_search_path() as path'); path = path[0].path; plv8.execute('set search_path to xt,' + path); /* create namespace objects for all registered javascript */ sql = 'select distinct js_namespace as "nameSpace" ' + 'from xt.js ' + 'where js_active; ' res = plv8.execute(sql); if(res.length) { for(var i = 0; i < res.length; i++) { if(!plv8[res[i].nameSpace]) { plv8[res[i].nameSpace] = eval([res[i].nameSpace] + " = {}"); } } /* load up all active javascript installed in the database */ /* TODO: What about dependencies? */ sql = 'select js_type, js_text as "javascript" ' + 'from xt.js ' + 'where js_active ' + 'order by js_ext, ' + 'js_context = \'xtuple\' DESC'; res = plv8.execute(sql); if(res.length) { for(var i = 0; i < res.length; i++) { if(DEBUG) XT.debug('loading javascript for type->', res[i].js_type); eval(res[i].javascript); var ns = eval(res[i].js_namespace); if (ns && ns[js_type]) { if (Object.isFrozen(ns[js_type])) { plv8.elog(WARNING, 'object already frozen: '+ ns + '.' + js_type); } Object.freeze(ns[js_type]); } } } plv8.__initialized = true; } }()); $_$; ALTER FUNCTION xt.js_init(debug boolean, initialize boolean) OWNER TO admin; -- -- Name: parseediprofile(text, text); Type: FUNCTION; Schema: xt; Owner: admin -- CREATE FUNCTION parseediprofile(ediprofile text, options text DEFAULT '{}'::text) RETURNS text LANGUAGE plv8 AS $$ var editext = ''; /** * Call the parser with this functions parameters. */ try { editext += XT.EDIProfile.parser.parse(ediprofile, JSON.parse(options)); } catch (err) { plv8.elog(ERROR, 'Cannot parse EDI Profile Tokens. ERROR: ', err); } return editext; $$; ALTER FUNCTION xt.parseediprofile(ediprofile text, options text) OWNER TO admin; -- -- Name: parsemetasql(text, text); Type: FUNCTION; Schema: xt; Owner: admin -- CREATE FUNCTION parsemetasql(metasql text, options text DEFAULT '{}'::text) RETURNS text LANGUAGE plv8 AS $$ /** * xt.parsemetasql(text, text) * =========================== * * Wrapper function for the plv8 MetaSQL PEG parser: * - XT.MetaSQL.parser.parse(metasql, options); * * @param {string} metasql - The MetaSQL query text string. * @param {string} options - A JSON string of options in the format of: * '{"params":{"your-metasql-parameter-here":"your-value-here","Pn":"Vn"}}' * @returns {string} - Returns a query text string with the MetaSQL * - parameters replaced with your values * * Example Usage: * SELECT xt.parsemetasql( * 'SELECT AS baz;', * '{"params":{"foo":"bar"}}' * ); * * Returns: "SELECT 'bar' AS baz;" */ var sql = ''; /* * Call the parser with this functions parameters. */ try { sql += XT.MetaSQL.parser.parse(metasql, JSON.parse(options)); } catch (err) { plv8.elog(ERROR, 'Cannot parse MetaSQL. ERROR: ', err); } return sql; $$; ALTER FUNCTION xt.parsemetasql(metasql text, options text) OWNER TO admin; -- -- Name: parsemetasql(text, text, text); Type: FUNCTION; Schema: xt; Owner: admin -- CREATE FUNCTION parsemetasql(pgroup text, pname text, poptions text) RETURNS text LANGUAGE plpgsql AS $$ DECLARE qry TEXT; BEGIN -- Overload for xt.parsemetasql(text, text) that loads the MetaSQL from the -- metasql table based on pGroup and pName then passes it to the parser along -- with pOptions. SELECT metasql_query INTO qry FROM metasql WHERE metasql_name = pName AND metasql_group = pGroup ORDER BY metasql_grade DESC LIMIT 1; IF (NOT FOUND) THEN RAISE EXCEPTION 'MetaSQL Query %-% was not found.', pGroup, pName; END IF; RETURN xt.parsemetasql(qry, pOptions); END; $$; ALTER FUNCTION xt.parsemetasql(pgroup text, pname text, poptions text) OWNER TO admin; SET search_path = xtdesktop, pg_catalog; -- -- Name: fetchwelcomehtml(); Type: FUNCTION; Schema: xtdesktop; Owner: admin -- CREATE FUNCTION fetchwelcomehtml() RETURNS text LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _html TEXT; BEGIN _html := '

Welcome to xTuple


You are not connected to the internet at this time

'; RETURN _html; END; $$; ALTER FUNCTION xtdesktop.fetchwelcomehtml() OWNER TO admin; -- -- Name: fetchxtupleserverhtml(); Type: FUNCTION; Schema: xtdesktop; Owner: admin -- CREATE FUNCTION fetchxtupleserverhtml() RETURNS text LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _html TEXT; BEGIN _html := '

Welcome to xTuple


You are not connected to an xTuple Server at this time.

You require a suitable xTuple Server to view Dashboards.

'; RETURN _html; END; $$; ALTER FUNCTION xtdesktop.fetchxtupleserverhtml() OWNER TO admin; -- -- Name: usersonline(); Type: FUNCTION; Schema: xtdesktop; Owner: admin -- CREATE FUNCTION usersonline() RETURNS SETOF usersonline LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row xtdesktop.usersonline%ROWTYPE; _query TEXT; BEGIN -- first part of our query doesn't care what PG version it is _query := 'SELECT usr.usr_id, usr.usr_username, usr.usr_propername, usr.usr_email, ' || 'min(backend_start) AS client_start, max(query_start) AS query_start, ' || 'sum(CASE WHEN(database IS NULL) THEN 0 ELSE 1 END) AS cnt_internal, ' || 'sum(CASE WHEN(database IS NULL) THEN 1 ELSE 0 END) AS cnt_external, ' || 'client_addr ' || 'FROM pg_stat_activity ' || 'JOIN public.usr ON (usr.usr_id=usesysid) '; -- use the integer comparison to compare server version to 9.2.0, where procpid was changed to just pid IF (compareversion('9.2.0') <= 0) THEN _query := _query || 'LEFT OUTER JOIN pg_locks ON (database=datid AND classid=datid AND objid=pg_stat_activity.pid AND objsubid=2) '; ELSE _query := _query || 'LEFT OUTER JOIN pg_locks ON (database=datid AND classid=datid AND objid=procpid AND objsubid=2) '; END IF; -- the rest of the query _query := _query || 'WHERE(datname=current_database()) ' || 'GROUP BY usr_id, usr_username, usr_propername, usr_email, client_addr '; -- loop over the rows that executing this query returns, and return them to the calling user FOR _row IN EXECUTE _query LOOP RETURN NEXT _row; END LOOP; RETURN; END; $$; ALTER FUNCTION xtdesktop.usersonline() OWNER TO admin; -- -- Name: FUNCTION usersonline(); Type: COMMENT; Schema: xtdesktop; Owner: admin -- COMMENT ON FUNCTION usersonline() IS 'A table function that returns a PostgreSQL-version aware count of users online.'; SET search_path = public, pg_catalog; -- -- Name: concatagg(text); Type: AGGREGATE; Schema: public; Owner: admin -- CREATE AGGREGATE concatagg(text) ( SFUNC = concataggsfunc, STYPE = text, INITCOND = '' ); ALTER AGGREGATE public.concatagg(text) OWNER TO admin; -- -- Name: first(anyelement); Type: AGGREGATE; Schema: public; Owner: admin -- CREATE AGGREGATE first(anyelement) ( SFUNC = first_agg, STYPE = anyelement ); ALTER AGGREGATE public.first(anyelement) OWNER TO admin; -- -- Name: last(anyelement); Type: AGGREGATE; Schema: public; Owner: admin -- CREATE AGGREGATE last(anyelement) ( SFUNC = last_agg, STYPE = anyelement ); ALTER AGGREGATE public.last(anyelement) OWNER TO admin; -- -- Name: addr; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE addr ( addr_id integer NOT NULL, addr_active boolean DEFAULT true, addr_line1 text DEFAULT ''::text, addr_line2 text DEFAULT ''::text, addr_line3 text DEFAULT ''::text, addr_city text DEFAULT ''::text, addr_state text DEFAULT ''::text, addr_postalcode text DEFAULT ''::text, addr_country text DEFAULT ''::text, addr_notes text DEFAULT ''::text, addr_number text NOT NULL, CONSTRAINT addr_addr_number_check CHECK ((addr_number <> ''::text)) ); ALTER TABLE addr OWNER TO admin; -- -- Name: TABLE addr; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE addr IS 'Postal Address'; SET search_path = api, pg_catalog; -- -- Name: account; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW account AS SELECT (c.crmacct_number)::character varying AS account_number, p.crmacct_number AS parent_account, c.crmacct_name AS account_name, c.crmacct_active AS active, CASE WHEN (c.crmacct_type = 'O'::bpchar) THEN 'Organization'::text ELSE 'Individual'::text END AS type, pc.cntct_number AS primary_contact_number, pc.cntct_honorific AS primary_contact_honorific, pc.cntct_first_name AS primary_contact_first, pc.cntct_middle AS primary_contact_middle, pc.cntct_last_name AS primary_contact_last, pc.cntct_suffix AS primary_contact_suffix, pc.cntct_title AS primary_contact_job_title, pc.cntct_phone AS primary_contact_voice, pc.cntct_fax AS primary_contact_fax, pc.cntct_email AS primary_contact_email, ''::text AS primary_contact_change, m.addr_number AS primary_contact_address_number, m.addr_line1 AS primary_contact_address1, m.addr_line2 AS primary_contact_address2, m.addr_line3 AS primary_contact_address3, m.addr_city AS primary_contact_city, m.addr_state AS primary_contact_state, m.addr_postalcode AS primary_contact_postalcode, m.addr_country AS primary_contact_country, ''::text AS primary_contact_address_change, sc.cntct_number AS secondary_contact_number, sc.cntct_honorific AS secondary_contact_honorific, sc.cntct_first_name AS secondary_contact_first, sc.cntct_middle AS secondary_contact_middle, sc.cntct_last_name AS secondary_contact_last, sc.cntct_suffix AS secondary_contact_suffix, sc.cntct_title AS secondary_contact_job_title, sc.cntct_phone AS secondary_contact_voice, sc.cntct_fax AS secondary_contact_fax, sc.cntct_email AS secondary_contact_email, sc.cntct_webaddr AS secondary_contact_web, ''::text AS secondary_contact_change, s.addr_number AS secondary_contact_address_number, s.addr_line1 AS secondary_contact_address1, s.addr_line2 AS secondary_contact_address2, s.addr_line3 AS secondary_contact_address3, s.addr_city AS secondary_contact_city, s.addr_state AS secondary_contact_state, s.addr_postalcode AS secondary_contact_postalcode, s.addr_country AS secondary_contact_country, ''::text AS secondary_contact_address_change, c.crmacct_notes AS notes FROM (((((public.crmacct c LEFT JOIN public.crmacct p ON ((c.crmacct_parent_id = p.crmacct_id))) LEFT JOIN public.cntct pc ON ((c.crmacct_cntct_id_1 = pc.cntct_id))) LEFT JOIN public.addr m ON ((pc.cntct_addr_id = m.addr_id))) LEFT JOIN public.cntct sc ON ((c.crmacct_cntct_id_2 = sc.cntct_id))) LEFT JOIN public.addr s ON ((sc.cntct_addr_id = s.addr_id))); ALTER TABLE account OWNER TO admin; -- -- Name: VIEW account; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW account IS 'Account'; SET search_path = public, pg_catalog; -- -- Name: char; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE "char" ( char_id integer NOT NULL, char_name text NOT NULL, char_items boolean, char_options boolean, char_attributes boolean, char_lotserial boolean, char_notes text, char_customers boolean, char_crmaccounts boolean, char_addresses boolean, char_contacts boolean, char_opportunity boolean, char_employees boolean DEFAULT false, char_mask text, char_validator text, char_incidents boolean DEFAULT false, char_type integer DEFAULT 0 NOT NULL, char_order integer DEFAULT 0 NOT NULL, char_search boolean DEFAULT true NOT NULL, char_quotes boolean DEFAULT false, char_salesorders boolean DEFAULT false, char_invoices boolean DEFAULT false, char_vendors boolean DEFAULT false, char_purchaseorders boolean DEFAULT false, char_vouchers boolean DEFAULT false, char_projects boolean DEFAULT false, char_tasks boolean DEFAULT false, CONSTRAINT char_char_name_check CHECK ((char_name <> ''::text)) ); ALTER TABLE "char" OWNER TO admin; -- -- Name: TABLE "char"; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE "char" IS 'Characteristic information'; -- -- Name: COLUMN "char".char_items; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN "char".char_items IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type I'; -- -- Name: COLUMN "char".char_lotserial; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN "char".char_lotserial IS 'DEPRECATED - this column has been replaced by rows in the charuse table with target_types LS and LSR'; -- -- Name: COLUMN "char".char_customers; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN "char".char_customers IS 'DEPRECATED - this column has been replaced by rows in the charuse table with target_types C and CT'; -- -- Name: COLUMN "char".char_crmaccounts; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN "char".char_crmaccounts IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type CRMA'; -- -- Name: COLUMN "char".char_addresses; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN "char".char_addresses IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type ADDR'; -- -- Name: COLUMN "char".char_contacts; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN "char".char_contacts IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type CNTCT'; -- -- Name: COLUMN "char".char_opportunity; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN "char".char_opportunity IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type OPP'; -- -- Name: COLUMN "char".char_employees; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN "char".char_employees IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type EMP'; -- -- Name: COLUMN "char".char_incidents; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN "char".char_incidents IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type INCDT'; -- -- Name: COLUMN "char".char_quotes; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN "char".char_quotes IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type QU'; -- -- Name: COLUMN "char".char_salesorders; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN "char".char_salesorders IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type SO'; -- -- Name: COLUMN "char".char_invoices; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN "char".char_invoices IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type INV'; -- -- Name: COLUMN "char".char_vendors; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN "char".char_vendors IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type V'; -- -- Name: COLUMN "char".char_purchaseorders; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN "char".char_purchaseorders IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type PO'; -- -- Name: COLUMN "char".char_vouchers; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN "char".char_vouchers IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type VCH'; -- -- Name: COLUMN "char".char_projects; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN "char".char_projects IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type PROJ'; -- -- Name: COLUMN "char".char_tasks; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN "char".char_tasks IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type TASK'; -- -- Name: charass; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE charass ( charass_id integer NOT NULL, charass_target_type text, charass_target_id integer, charass_char_id integer, charass_value text, charass_default boolean DEFAULT false NOT NULL, charass_price numeric(16,4) DEFAULT 0 NOT NULL ); ALTER TABLE charass OWNER TO admin; -- -- Name: TABLE charass; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE charass IS 'Characteristic assignment information'; SET search_path = api, pg_catalog; -- -- Name: accountchar; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW accountchar AS SELECT (crmacct.crmacct_number)::character varying AS account_number, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value FROM public.crmacct, public."char", public.charass WHERE ((('CRMACCT'::text = charass.charass_target_type) AND (crmacct.crmacct_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id)); ALTER TABLE accountchar OWNER TO admin; -- -- Name: VIEW accountchar; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW accountchar IS 'Account Characteristics'; SET search_path = public, pg_catalog; -- -- Name: cmnttype; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cmnttype ( cmnttype_id integer NOT NULL, cmnttype_name text NOT NULL, cmnttype_descrip text NOT NULL, cmnttype_usedin text, cmnttype_sys boolean DEFAULT false NOT NULL, cmnttype_editable boolean DEFAULT false NOT NULL, cmnttype_order integer, CONSTRAINT cmnttype_cmnttype_name_check CHECK ((cmnttype_name <> ''::text)) ); ALTER TABLE cmnttype OWNER TO admin; -- -- Name: TABLE cmnttype; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE cmnttype IS 'Comment Type information'; -- -- Name: comment; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE comment ( comment_id integer DEFAULT nextval(('"comment_comment_id_seq"'::text)::regclass) NOT NULL, comment_source_id integer, comment_date timestamp with time zone, comment_user text, comment_text text, comment_cmnttype_id integer, comment_source text, comment_public boolean ); ALTER TABLE comment OWNER TO admin; -- -- Name: TABLE comment; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE comment IS 'Comment information'; SET search_path = api, pg_catalog; -- -- Name: accountcomment; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW accountcomment AS SELECT (crmacct.crmacct_number)::character varying AS account_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.crmacct, public.cmnttype, public.comment WHERE (((comment.comment_source = 'CRMA'::text) AND (comment.comment_source_id = crmacct.crmacct_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); ALTER TABLE accountcomment OWNER TO admin; -- -- Name: VIEW accountcomment; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW accountcomment IS 'Account Comment'; SET search_path = public, pg_catalog; -- -- Name: docass; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE docass ( docass_id integer NOT NULL, docass_source_id integer NOT NULL, docass_source_type text NOT NULL, docass_target_id integer NOT NULL, docass_target_type text DEFAULT 'URL'::text NOT NULL, docass_purpose character(1) DEFAULT 'S'::bpchar NOT NULL, CONSTRAINT docass_docass_purpose_check CHECK (((((((((docass_purpose = 'I'::bpchar) OR (docass_purpose = 'E'::bpchar)) OR (docass_purpose = 'M'::bpchar)) OR (docass_purpose = 'P'::bpchar)) OR (docass_purpose = 'A'::bpchar)) OR (docass_purpose = 'C'::bpchar)) OR (docass_purpose = 'S'::bpchar)) OR (docass_purpose = 'D'::bpchar))) ); ALTER TABLE docass OWNER TO admin; -- -- Name: TABLE docass; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE docass IS 'Document Assignement References'; -- -- Name: file; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE file ( file_id integer NOT NULL, file_title text NOT NULL, file_stream bytea, file_descrip text NOT NULL ); ALTER TABLE file OWNER TO admin; -- -- Name: urlinfo; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE urlinfo ( url_id integer NOT NULL, url_title text NOT NULL, url_url text NOT NULL ); ALTER TABLE urlinfo OWNER TO admin; -- -- Name: url; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW url AS SELECT docass.docass_id AS url_id, docass.docass_source_id AS url_source_id, docass.docass_source_type AS url_source, file.file_title AS url_title, file.file_descrip AS url_url, file.file_stream AS url_stream FROM (file JOIN docass ON (((docass.docass_target_id = file.file_id) AND (docass.docass_target_type = 'FILE'::text)))) UNION ALL SELECT docass.docass_id AS url_id, docass.docass_source_id AS url_source_id, docass.docass_source_type AS url_source, urlinfo.url_title, urlinfo.url_url, NULL::bytea AS url_stream FROM (urlinfo JOIN docass ON (((docass.docass_target_id = urlinfo.url_id) AND (docass.docass_target_type = 'URL'::text)))); ALTER TABLE url OWNER TO admin; SET search_path = api, pg_catalog; -- -- Name: accountfile; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW accountfile AS SELECT crmacct.crmacct_number AS account_number, url.url_title AS title, url.url_url AS url FROM public.crmacct, public.url WHERE ((crmacct.crmacct_id = url.url_source_id) AND (url.url_source = 'CRMA'::text)); ALTER TABLE accountfile OWNER TO admin; -- -- Name: VIEW accountfile; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW accountfile IS 'Account File'; SET search_path = public, pg_catalog; -- -- Name: docass_docass_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE docass_docass_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE docass_docass_id_seq OWNER TO admin; -- -- Name: docass_docass_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE docass_docass_id_seq OWNED BY docass.docass_id; -- -- Name: image; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE image ( image_id integer DEFAULT nextval(('"image_image_id_seq"'::text)::regclass) NOT NULL, image_name text, image_descrip text, image_data text ); ALTER TABLE image OWNER TO admin; -- -- Name: TABLE image; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE image IS 'Image information'; -- -- Name: imageass; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE imageass ( imageass_id integer DEFAULT nextval('docass_docass_id_seq'::regclass) NOT NULL, imageass_source_id integer NOT NULL, imageass_source text NOT NULL, imageass_image_id integer NOT NULL, imageass_purpose character(1) NOT NULL, CONSTRAINT imageass_imageass_purpose_check CHECK (((((((((imageass_purpose = 'I'::bpchar) OR (imageass_purpose = 'E'::bpchar)) OR (imageass_purpose = 'M'::bpchar)) OR (imageass_purpose = 'P'::bpchar)) OR (imageass_purpose = 'A'::bpchar)) OR (imageass_purpose = 'C'::bpchar)) OR (imageass_purpose = 'D'::bpchar)) OR (imageass_purpose = 'S'::bpchar))) ); ALTER TABLE imageass OWNER TO admin; -- -- Name: TABLE imageass; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE imageass IS 'Image Assignement References'; SET search_path = api, pg_catalog; -- -- Name: accountimage; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW accountimage AS SELECT crmacct.crmacct_number AS account_number, image.image_name FROM public.crmacct, public.imageass, public.image WHERE (((crmacct.crmacct_id = imageass.imageass_source_id) AND (imageass.imageass_source = 'CRMA'::text)) AND (imageass.imageass_image_id = image.image_id)); ALTER TABLE accountimage OWNER TO admin; -- -- Name: VIEW accountimage; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW accountimage IS 'Account Image'; -- -- Name: address; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW address AS SELECT (addr.addr_number)::character varying AS address_number, addr.addr_line1 AS address1, addr.addr_line2 AS address2, addr.addr_line3 AS address3, addr.addr_city AS city, addr.addr_state AS state, addr.addr_postalcode AS postal_code, addr.addr_country AS country, addr.addr_active AS active, addr.addr_notes AS notes, ''::text AS change FROM public.addr; ALTER TABLE address OWNER TO admin; -- -- Name: VIEW address; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW address IS 'Address'; -- -- Name: addresschar; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW addresschar AS SELECT (addr.addr_number)::character varying AS address_number, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value FROM public.addr, public."char", public.charass WHERE ((('ADDR'::text = charass.charass_target_type) AND (addr.addr_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id)); ALTER TABLE addresschar OWNER TO admin; -- -- Name: VIEW addresschar; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW addresschar IS 'Address Characteristics'; -- -- Name: addresscomment; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW addresscomment AS SELECT (addr.addr_number)::character varying AS address_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.addr, public.cmnttype, public.comment WHERE (((comment.comment_source = 'ADDR'::text) AND (comment.comment_source_id = addr.addr_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); ALTER TABLE addresscomment OWNER TO admin; -- -- Name: VIEW addresscomment; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW addresscomment IS 'Address Comment'; SET search_path = public, pg_catalog; -- -- Name: bomhead; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE bomhead ( bomhead_id integer DEFAULT nextval(('"bomhead_bomhead_id_seq"'::text)::regclass) NOT NULL, bomhead_item_id integer NOT NULL, bomhead_serial integer, bomhead_docnum text, bomhead_revision text, bomhead_revisiondate date, bomhead_batchsize numeric(18,6), bomhead_requiredqtyper numeric(20,8), bomhead_rev_id integer DEFAULT (-1), CONSTRAINT bomhead_bomhead_batchsize_check CHECK ((bomhead_batchsize > (0)::numeric)) ); ALTER TABLE bomhead OWNER TO admin; -- -- Name: TABLE bomhead; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE bomhead IS 'Bill of Materials (BOM) header information'; SET search_path = api, pg_catalog; -- -- Name: bom; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW bom AS SELECT (item.item_number)::character varying AS item_number, (bomhead.bomhead_revision)::character varying AS revision, bomhead.bomhead_docnum AS document_number, bomhead.bomhead_revisiondate AS revision_date, bomhead.bomhead_batchsize AS batch_size, bomhead.bomhead_requiredqtyper AS total_qty_per FROM public.bomhead, public.item WHERE (bomhead.bomhead_item_id = item.item_id); ALTER TABLE bom OWNER TO admin; -- -- Name: VIEW bom; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW bom IS 'Bill of Material Header'; -- -- Name: bomitem; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW bomitem AS SELECT bomitem.bomitem_id AS id, (p.item_number)::character varying AS bom_item_number, (bomhead.bomhead_revision)::character varying AS bom_revision, bomitem.bomitem_seqnumber AS sequence_number, i.item_number, CASE WHEN (bomitem.bomitem_effective = public.startoftime()) THEN 'Always'::text ELSE public.formatdate(bomitem.bomitem_effective) END AS effective, CASE WHEN (bomitem.bomitem_expires = public.endoftime()) THEN 'Never'::text ELSE public.formatdate(bomitem.bomitem_expires) END AS expires, bomitem.bomitem_qtyper AS qty_per, uom.uom_name AS issue_uom, bomitem.bomitem_scrap AS scrap, bomitem.bomitem_createwo AS create_child_wo, CASE WHEN (bomitem.bomitem_issuemethod = 'M'::bpchar) THEN 'Mixed'::text WHEN (bomitem.bomitem_issuemethod = 'L'::bpchar) THEN 'Pull'::text WHEN (bomitem.bomitem_issuemethod = 'S'::bpchar) THEN 'Push'::text ELSE NULL::text END AS issue_method, public.formatbooseq(p.item_id, bomitem.bomitem_booitem_seq_id) AS used_at, bomitem.bomitem_schedatwooper AS schedule_at_wo_operation, bomitem.bomitem_ecn AS ecn_number, bomitem.bomitem_notes AS notes, bomitem.bomitem_ref AS reference, CASE WHEN (bomitem.bomitem_subtype = 'N'::bpchar) THEN 'No'::text WHEN (bomitem.bomitem_subtype = 'I'::bpchar) THEN 'Item-Defined'::text WHEN (bomitem.bomitem_subtype = 'B'::bpchar) THEN 'BOM-Defined'::text ELSE NULL::text END AS substitutions, "char".char_name AS characteristic, bomitem.bomitem_value AS value FROM ((public.bomitem LEFT JOIN public.bomhead ON (((bomitem.bomitem_parent_item_id = bomhead.bomhead_item_id) AND (bomitem.bomitem_rev_id = bomhead.bomhead_rev_id)))) LEFT JOIN public."char" ON ((bomitem.bomitem_char_id = "char".char_id))), public.item p, public.item i, public.uom WHERE (((bomitem.bomitem_parent_item_id = p.item_id) AND (bomitem.bomitem_item_id = i.item_id)) AND (bomitem.bomitem_uom_id = uom.uom_id)) ORDER BY p.item_number, bomitem.bomitem_seqnumber; ALTER TABLE bomitem OWNER TO admin; -- -- Name: VIEW bomitem; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW bomitem IS 'Bill of Material Item'; -- -- Name: bomitemcomment; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW bomitemcomment AS SELECT bomitem.bomitem_id, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM (public.bomitem LEFT JOIN public.bomhead ON (((bomitem.bomitem_parent_item_id = bomhead.bomhead_item_id) AND (bomitem.bomitem_rev_id = bomhead.bomhead_rev_id)))), public.item, public.cmnttype, public.comment WHERE ((((comment.comment_source = 'BMI'::text) AND (comment.comment_source_id = bomitem.bomitem_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)) AND (bomitem.bomitem_parent_item_id = item.item_id)) ORDER BY item.item_number, bomhead.bomhead_revision, bomitem.bomitem_seqnumber, comment.comment_date; ALTER TABLE bomitemcomment OWNER TO admin; -- -- Name: VIEW bomitemcomment; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW bomitemcomment IS 'Bill of Material Comment'; SET search_path = public, pg_catalog; -- -- Name: bomitemsub; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE bomitemsub ( bomitemsub_id integer NOT NULL, bomitemsub_bomitem_id integer NOT NULL, bomitemsub_item_id integer NOT NULL, bomitemsub_uomratio numeric(20,10) NOT NULL, bomitemsub_rank integer NOT NULL ); ALTER TABLE bomitemsub OWNER TO admin; -- -- Name: TABLE bomitemsub; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE bomitemsub IS 'Bill of Materials (BOM) defined Substitutions information'; SET search_path = api, pg_catalog; -- -- Name: bomitemsubstitute; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW bomitemsubstitute AS SELECT bomitem.bomitem_id, (p.item_number)::character varying AS bom_item_number, (bomhead.bomhead_revision)::character varying AS bom_revision, bomitem.bomitem_seqnumber AS sequence_number, (s.item_number)::character varying AS substitute_item_number, bomitemsub.bomitemsub_uomratio AS sub_parent_uom_ratio, bomitemsub.bomitemsub_rank AS ranking FROM public.item p, public.item s, (public.bomitem LEFT JOIN public.bomhead ON (((bomitem.bomitem_parent_item_id = bomhead.bomhead_item_id) AND (bomitem.bomitem_rev_id = bomhead.bomhead_rev_id)))), public.bomitemsub WHERE (((p.item_id = bomitem.bomitem_parent_item_id) AND (s.item_id = bomitemsub.bomitemsub_item_id)) AND (bomitemsub.bomitemsub_bomitem_id = bomitem.bomitem_id)); ALTER TABLE bomitemsubstitute OWNER TO admin; -- -- Name: VIEW bomitemsubstitute; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW bomitemsubstitute IS 'Bill of Material Item Substitute'; SET search_path = public, pg_catalog; -- -- Name: budghead; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE budghead ( budghead_id integer NOT NULL, budghead_name text NOT NULL, budghead_descrip text, CONSTRAINT budghead_budghead_name_check CHECK ((budghead_name <> ''::text)) ); ALTER TABLE budghead OWNER TO admin; SET search_path = api, pg_catalog; -- -- Name: budget; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW budget AS SELECT budghead.budghead_name AS name, budghead.budghead_descrip AS description FROM public.budghead ORDER BY budghead.budghead_name; ALTER TABLE budget OWNER TO admin; -- -- Name: VIEW budget; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW budget IS 'Budget Header'; SET search_path = public, pg_catalog; -- -- Name: accnt; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE accnt ( accnt_id integer DEFAULT nextval(('accnt_accnt_id_seq'::text)::regclass) NOT NULL, accnt_number text, accnt_descrip text, accnt_comments text, accnt_profit text, accnt_sub text, accnt_type character(1) NOT NULL, accnt_extref text, accnt_company text, accnt_forwardupdate boolean, accnt_subaccnttype_code text, accnt_curr_id integer DEFAULT basecurrid(), accnt_active boolean DEFAULT true NOT NULL, accnt_name text, CONSTRAINT accnt_accnt_type_check CHECK ((accnt_type = ANY (ARRAY['A'::bpchar, 'E'::bpchar, 'L'::bpchar, 'Q'::bpchar, 'R'::bpchar]))) ); ALTER TABLE accnt OWNER TO admin; -- -- Name: TABLE accnt; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE accnt IS 'General Ledger (G/L) Account Number information'; -- -- Name: budgitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE budgitem ( budgitem_id integer NOT NULL, budgitem_budghead_id integer NOT NULL, budgitem_period_id integer NOT NULL, budgitem_accnt_id integer NOT NULL, budgitem_amount numeric(20,4) NOT NULL ); ALTER TABLE budgitem OWNER TO admin; -- -- Name: period; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE period ( period_id integer NOT NULL, period_start date, period_end date, period_closed boolean, period_freeze boolean, period_initial boolean DEFAULT false, period_name text, period_yearperiod_id integer, period_quarter integer, period_number integer NOT NULL ); ALTER TABLE period OWNER TO admin; -- -- Name: TABLE period; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE period IS 'Accounting Period information'; SET search_path = api, pg_catalog; -- -- Name: budgetentry; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW budgetentry AS SELECT budghead.budghead_name AS name, public.formatglaccount(accnt.accnt_id) AS account, period.period_start, budgitem.budgitem_amount AS amount FROM public.budgitem, public.budghead, public.period, public.accnt WHERE (((budgitem.budgitem_budghead_id = budghead.budghead_id) AND (budgitem.budgitem_period_id = period.period_id)) AND (budgitem.budgitem_accnt_id = accnt.accnt_id)) ORDER BY budghead.budghead_name, period.period_start, public.formatglaccount(accnt.accnt_id); ALTER TABLE budgetentry OWNER TO admin; -- -- Name: VIEW budgetentry; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW budgetentry IS 'Budget Entry'; SET search_path = public, pg_catalog; -- -- Name: bankaccnt; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE bankaccnt ( bankaccnt_id integer NOT NULL, bankaccnt_name text NOT NULL, bankaccnt_descrip text, bankaccnt_bankname text, bankaccnt_accntnumber text, bankaccnt_ar boolean, bankaccnt_ap boolean, bankaccnt_nextchknum integer, bankaccnt_type character(1), bankaccnt_accnt_id integer, bankaccnt_check_form_id integer, bankaccnt_userec boolean, bankaccnt_rec_accnt_id integer, bankaccnt_curr_id integer DEFAULT basecurrid(), bankaccnt_notes text, bankaccnt_routing text DEFAULT ''::text NOT NULL, bankaccnt_ach_enabled boolean DEFAULT false NOT NULL, bankaccnt_ach_origin text DEFAULT ''::text NOT NULL, bankaccnt_ach_genchecknum boolean DEFAULT false NOT NULL, bankaccnt_ach_leadtime integer, bankaccnt_ach_lastdate date, bankaccnt_ach_lastfileid character(1), bankaccnt_ach_origintype text, bankaccnt_ach_originname text, bankaccnt_ach_desttype text, bankaccnt_ach_fed_dest text, bankaccnt_ach_destname text, bankaccnt_ach_dest text, bankaccnt_prnt_check boolean DEFAULT true NOT NULL, CONSTRAINT bankaccnt_bankaccnt_name_check CHECK ((bankaccnt_name <> ''::text)) ); ALTER TABLE bankaccnt OWNER TO admin; -- -- Name: TABLE bankaccnt; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE bankaccnt IS 'Bank Account information'; -- -- Name: cashrcpt; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cashrcpt ( cashrcpt_id integer NOT NULL, cashrcpt_cust_id integer NOT NULL, cashrcpt_amount numeric(20,2) NOT NULL, cashrcpt_fundstype character(1) NOT NULL, cashrcpt_docnumber text, cashrcpt_bankaccnt_id integer NOT NULL, cashrcpt_notes text, cashrcpt_distdate date DEFAULT ('now'::text)::date, cashrcpt_salescat_id integer DEFAULT (-1), cashrcpt_curr_id integer DEFAULT basecurrid(), cashrcpt_usecustdeposit boolean DEFAULT false NOT NULL, cashrcpt_void boolean DEFAULT false NOT NULL, cashrcpt_number text NOT NULL, cashrcpt_docdate date, cashrcpt_posted boolean DEFAULT false NOT NULL, cashrcpt_posteddate date, cashrcpt_postedby text, cashrcpt_applydate date, cashrcpt_discount numeric(20,2) DEFAULT 0.00 NOT NULL, cashrcpt_curr_rate numeric NOT NULL, cashrcpt_alt_curr_rate numeric, CONSTRAINT cashrcpt_cashrcpt_number_check CHECK ((cashrcpt_number <> ''::text)) ); ALTER TABLE cashrcpt OWNER TO admin; -- -- Name: TABLE cashrcpt; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE cashrcpt IS 'Temporary table for storing Cash Receipt information before Cash Receipts are posted'; SET search_path = api, pg_catalog; -- -- Name: cashreceipt; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW cashreceipt AS SELECT (custinfo.cust_number)::character varying AS customer_number, cashrcpt.cashrcpt_number AS cashreceipt_number, CASE WHEN (cashrcpt.cashrcpt_fundstype = 'C'::bpchar) THEN 'Check'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'T'::bpchar) THEN 'Certified Check'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'M'::bpchar) THEN 'Master Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'V'::bpchar) THEN 'Visa'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'A'::bpchar) THEN 'American Express'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'D'::bpchar) THEN 'Discover Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'R'::bpchar) THEN 'Other Credit Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'K'::bpchar) THEN 'Cash'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'W'::bpchar) THEN 'Wire Transfer'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'O'::bpchar) THEN 'Other'::character varying ELSE NULL::character varying END AS funds_type, (cashrcpt.cashrcpt_docnumber)::character varying AS check_document_number, custinfo.cust_name AS customer_name, m.addr_line1 AS customer_address, curr_symbol.curr_abbr AS currency, cashrcpt.cashrcpt_amount AS amount_received, bankaccnt.bankaccnt_name AS post_to, public.formatdate(cashrcpt.cashrcpt_distdate) AS distribution_date, CASE WHEN cashrcpt.cashrcpt_usecustdeposit THEN 'Customer Deposit'::text ELSE 'Credit Memo'::text END AS apply_balance_as, salescat.salescat_name AS sales_category, cashrcpt.cashrcpt_notes AS notes FROM ((((((public.cashrcpt LEFT JOIN public.custinfo ON ((custinfo.cust_id = cashrcpt.cashrcpt_cust_id))) LEFT JOIN public.cntct mc ON ((custinfo.cust_cntct_id = mc.cntct_id))) LEFT JOIN public.addr m ON ((mc.cntct_addr_id = m.addr_id))) LEFT JOIN public.curr_symbol ON ((curr_symbol.curr_id = cashrcpt.cashrcpt_curr_id))) LEFT JOIN public.bankaccnt ON ((bankaccnt.bankaccnt_id = cashrcpt.cashrcpt_bankaccnt_id))) LEFT JOIN public.salescat ON ((salescat.salescat_id = cashrcpt.cashrcpt_salescat_id))); ALTER TABLE cashreceipt OWNER TO admin; -- -- Name: VIEW cashreceipt; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW cashreceipt IS ' This view can be used as an interface to import Cash Receipt data directly into the system. Required fields will be checked and default values will be populated'; SET search_path = public, pg_catalog; -- -- Name: cashrcptitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cashrcptitem ( cashrcptitem_id integer NOT NULL, cashrcptitem_cashrcpt_id integer NOT NULL, cashrcptitem_aropen_id integer NOT NULL, cashrcptitem_amount numeric(20,2) NOT NULL, cashrcptitem_discount numeric(20,2) DEFAULT 0.00 NOT NULL, cashrcptitem_applied boolean DEFAULT true ); ALTER TABLE cashrcptitem OWNER TO admin; -- -- Name: TABLE cashrcptitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE cashrcptitem IS 'Temporary table for storing information about applications of Cash Receipts before Cash Receipts are posted'; SET search_path = api, pg_catalog; -- -- Name: cashreceiptapply; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW cashreceiptapply AS SELECT (custinfo.cust_number)::character varying AS customer_number, CASE WHEN (cashrcpt.cashrcpt_fundstype = 'C'::bpchar) THEN 'Check'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'T'::bpchar) THEN 'Certified Check'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'M'::bpchar) THEN 'Master Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'V'::bpchar) THEN 'Visa'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'A'::bpchar) THEN 'American Express'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'D'::bpchar) THEN 'Discover Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'R'::bpchar) THEN 'Other Credit Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'K'::bpchar) THEN 'Cash'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'W'::bpchar) THEN 'Wire Transfer'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'O'::bpchar) THEN 'Other'::character varying ELSE NULL::character varying END AS funds_type, (cashrcpt.cashrcpt_docnumber)::character varying AS check_document_number, (aropen.aropen_doctype)::character varying AS doc_type, (aropen.aropen_docnumber)::character varying AS doc_number, custinfo.cust_name AS customer_name, m.addr_line1 AS customer_address, public.formatdate(aropen.aropen_docdate) AS doc_date, public.formatdate(aropen.aropen_duedate) AS due_date, curr_symbol.curr_abbr AS currency, aropen.aropen_amount AS open_amount, cashrcptitem.cashrcptitem_amount AS amount_to_apply, cashrcptitem.cashrcptitem_discount FROM ((((((public.cashrcptitem LEFT JOIN public.cashrcpt ON ((cashrcpt.cashrcpt_id = cashrcptitem.cashrcptitem_cashrcpt_id))) LEFT JOIN public.custinfo ON ((custinfo.cust_id = cashrcpt.cashrcpt_cust_id))) LEFT JOIN public.cntct mc ON ((custinfo.cust_cntct_id = mc.cntct_id))) LEFT JOIN public.addr m ON ((mc.cntct_addr_id = m.addr_id))) LEFT JOIN public.curr_symbol ON ((curr_symbol.curr_id = cashrcpt.cashrcpt_curr_id))) LEFT JOIN public.aropen ON ((aropen.aropen_id = cashrcptitem.cashrcptitem_aropen_id))); ALTER TABLE cashreceiptapply OWNER TO admin; -- -- Name: VIEW cashreceiptapply; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW cashreceiptapply IS ' This view can be used as an interface to import Cash Receipt Application data directly into the system. Required fields will be checked and default values will be populated'; SET search_path = public, pg_catalog; -- -- Name: cashrcptmisc; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cashrcptmisc ( cashrcptmisc_id integer NOT NULL, cashrcptmisc_cashrcpt_id integer NOT NULL, cashrcptmisc_accnt_id integer NOT NULL, cashrcptmisc_amount numeric(20,2) NOT NULL, cashrcptmisc_notes text ); ALTER TABLE cashrcptmisc OWNER TO admin; -- -- Name: TABLE cashrcptmisc; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE cashrcptmisc IS 'Cash Receipt Miscellaneous Application information'; SET search_path = api, pg_catalog; -- -- Name: cashreceiptapplymisc; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW cashreceiptapplymisc AS SELECT (custinfo.cust_number)::character varying AS customer_number, CASE WHEN (cashrcpt.cashrcpt_fundstype = 'C'::bpchar) THEN 'Check'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'T'::bpchar) THEN 'Certified Check'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'M'::bpchar) THEN 'Master Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'V'::bpchar) THEN 'Visa'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'A'::bpchar) THEN 'American Express'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'D'::bpchar) THEN 'Discover Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'R'::bpchar) THEN 'Other Credit Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'K'::bpchar) THEN 'Cash'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'W'::bpchar) THEN 'Wire Transfer'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'O'::bpchar) THEN 'Other'::character varying ELSE NULL::character varying END AS funds_type, (cashrcpt.cashrcpt_docnumber)::character varying AS check_document_number, (public.formatglaccount(accnt.accnt_id))::character varying AS account, custinfo.cust_name AS customer_name, m.addr_line1 AS customer_address, accnt.accnt_descrip AS account_description, curr_symbol.curr_abbr AS currency, cashrcptmisc.cashrcptmisc_amount AS amount_to_distribute, cashrcptmisc.cashrcptmisc_notes AS notes FROM ((((((public.cashrcptmisc LEFT JOIN public.cashrcpt ON ((cashrcpt.cashrcpt_id = cashrcptmisc.cashrcptmisc_cashrcpt_id))) LEFT JOIN public.custinfo ON ((custinfo.cust_id = cashrcpt.cashrcpt_cust_id))) LEFT JOIN public.cntct mc ON ((custinfo.cust_cntct_id = mc.cntct_id))) LEFT JOIN public.addr m ON ((mc.cntct_addr_id = m.addr_id))) LEFT JOIN public.curr_symbol ON ((curr_symbol.curr_id = cashrcpt.cashrcpt_curr_id))) LEFT JOIN public.accnt ON ((accnt.accnt_id = cashrcptmisc.cashrcptmisc_accnt_id))); ALTER TABLE cashreceiptapplymisc OWNER TO admin; -- -- Name: VIEW cashreceiptapplymisc; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW cashreceiptapplymisc IS ' This view can be used as an interface to import Cash Receipt Miscellaneous Application data directly into the system. Required fields will be checked and default values will be populated'; -- -- Name: contact; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW contact AS SELECT (cntct.cntct_number)::character varying AS contact_number, cntct.cntct_honorific AS honorific, cntct.cntct_first_name AS first, cntct.cntct_middle AS middle, cntct.cntct_last_name AS last, cntct.cntct_suffix AS suffix, cntct.cntct_initials AS initials, crmacct.crmacct_number AS crm_account, cntct.cntct_active AS active, cntct.cntct_title AS job_title, cntct.cntct_phone AS voice, cntct.cntct_phone2 AS alternate, cntct.cntct_fax AS fax, cntct.cntct_email AS email, cntct.cntct_webaddr AS web, ''::text AS contact_change, addr.addr_number AS address_number, addr.addr_line1 AS address1, addr.addr_line2 AS address2, addr.addr_line3 AS address3, addr.addr_city AS city, addr.addr_state AS state, addr.addr_postalcode AS postal_code, addr.addr_country AS country, cntct.cntct_notes AS notes, ''::text AS address_change FROM ((public.cntct LEFT JOIN public.addr ON ((cntct.cntct_addr_id = addr.addr_id))) LEFT JOIN public.crmacct ON ((cntct.cntct_crmacct_id = crmacct.crmacct_id))); ALTER TABLE contact OWNER TO admin; -- -- Name: VIEW contact; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW contact IS 'Contact'; -- -- Name: contactchar; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW contactchar AS SELECT cntct.cntct_number AS contact_number, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value FROM public.cntct, public."char", public.charass WHERE ((('CNTCT'::text = charass.charass_target_type) AND (cntct.cntct_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id)); ALTER TABLE contactchar OWNER TO admin; -- -- Name: VIEW contactchar; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW contactchar IS 'Contact Characteristics'; -- -- Name: contactcomment; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW contactcomment AS SELECT cntct.cntct_number AS contact_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.cntct, public.cmnttype, public.comment WHERE (((comment.comment_source = 'T'::text) AND (comment.comment_source_id = cntct.cntct_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); ALTER TABLE contactcomment OWNER TO admin; -- -- Name: VIEW contactcomment; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW contactcomment IS 'Contact Comment'; -- -- Name: custchar; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW custchar AS SELECT (custinfo.cust_number)::character varying AS customer_number, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value FROM public.custinfo, public."char", public.charass WHERE ((('C'::text = charass.charass_target_type) AND (custinfo.cust_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id)); ALTER TABLE custchar OWNER TO admin; -- -- Name: VIEW custchar; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW custchar IS 'Customer Characteristics'; -- -- Name: custcomment; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW custcomment AS SELECT (custinfo.cust_number)::character varying AS customer_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.custinfo, public.cmnttype, public.comment WHERE (((comment.comment_source = 'C'::text) AND (comment.comment_source_id = custinfo.cust_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); ALTER TABLE custcomment OWNER TO admin; -- -- Name: VIEW custcomment; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW custcomment IS 'Customer Comment'; SET search_path = public, pg_catalog; -- -- Name: ccard; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE ccard ( ccard_id integer NOT NULL, ccard_seq integer DEFAULT 10 NOT NULL, ccard_cust_id integer NOT NULL, ccard_active boolean DEFAULT true, ccard_name bytea, ccard_address1 bytea, ccard_address2 bytea, ccard_city bytea, ccard_state bytea, ccard_zip bytea, ccard_country bytea, ccard_number bytea, ccard_debit boolean DEFAULT false, ccard_month_expired bytea, ccard_year_expired bytea, ccard_type character(1) NOT NULL, ccard_date_added timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL, ccard_lastupdated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL, ccard_added_by_username text DEFAULT geteffectivextuser() NOT NULL, ccard_last_updated_by_username text DEFAULT geteffectivextuser() NOT NULL ); ALTER TABLE ccard OWNER TO admin; -- -- Name: TABLE ccard; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE ccard IS 'Credit Card Information - all bytea data is encrypted'; SET search_path = api, pg_catalog; -- -- Name: custcreditcard; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW custcreditcard AS SELECT (custinfo.cust_number)::character varying AS customer_number, CASE WHEN (ccard.ccard_type = 'V'::bpchar) THEN 'Visa'::text WHEN (ccard.ccard_type = 'M'::bpchar) THEN 'Master Card'::text WHEN (ccard.ccard_type = 'A'::bpchar) THEN 'American Express'::text WHEN (ccard.ccard_type = 'D'::bpchar) THEN 'Discover'::text ELSE 'Not Supported'::text END AS credit_card_type, ccard.ccard_active AS active, ccard.ccard_number AS credit_card_number, ccard.ccard_name AS name, ccard.ccard_address1 AS street_address1, ccard.ccard_address2 AS street_address2, ccard.ccard_city AS city, ccard.ccard_state AS state, ccard.ccard_zip AS postal_code, ccard.ccard_country AS country, ccard.ccard_month_expired AS expiration_month, ccard.ccard_year_expired AS expiration_year, ''::text AS key FROM public.ccard, public.custinfo WHERE (ccard.ccard_cust_id = custinfo.cust_id); ALTER TABLE custcreditcard OWNER TO admin; -- -- Name: VIEW custcreditcard; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW custcreditcard IS 'Customer Credit Cards.'; SET search_path = public, pg_catalog; -- -- Name: custtype; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE custtype ( custtype_id integer DEFAULT nextval(('custtype_custtype_id_seq'::text)::regclass) NOT NULL, custtype_code text NOT NULL, custtype_descrip text NOT NULL, custtype_char boolean DEFAULT false NOT NULL, CONSTRAINT custtype_custtype_code_check CHECK ((custtype_code <> ''::text)) ); ALTER TABLE custtype OWNER TO admin; -- -- Name: TABLE custtype; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE custtype IS 'Customer Type information'; -- -- Name: shipchrg; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE shipchrg ( shipchrg_id integer NOT NULL, shipchrg_name text NOT NULL, shipchrg_descrip text, shipchrg_custfreight boolean, shipchrg_handling character(1), CONSTRAINT shipchrg_shipchrg_name_check CHECK ((shipchrg_name <> ''::text)) ); ALTER TABLE shipchrg OWNER TO admin; -- -- Name: TABLE shipchrg; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE shipchrg IS 'Shipping Charge information'; -- -- Name: shipform; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE shipform ( shipform_id integer DEFAULT nextval(('"shipform_shipform_id_seq"'::text)::regclass) NOT NULL, shipform_name text NOT NULL, shipform_report_id integer, shipform_report_name text, CONSTRAINT shipform_shipform_name_check CHECK ((shipform_name <> ''::text)) ); ALTER TABLE shipform OWNER TO admin; -- -- Name: TABLE shipform; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE shipform IS 'Shipping Form information'; -- -- Name: COLUMN shipform.shipform_report_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN shipform.shipform_report_id IS 'Obsolete -- reference shipform_report_name instead.'; SET search_path = api, pg_catalog; -- -- Name: customer; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW customer AS SELECT (custinfo.cust_number)::character varying AS customer_number, custtype.custtype_code AS customer_type, custinfo.cust_name AS customer_name, custinfo.cust_active AS active, salesrep.salesrep_number AS sales_rep, (custinfo.cust_commprcnt * (100)::numeric) AS commission, custinfo.cust_shipvia AS ship_via, shipform.shipform_name AS ship_form, shipchrg.shipchrg_name AS shipping_charges, custinfo.cust_backorder AS accepts_backorders, custinfo.cust_partialship AS accepts_partial_shipments, custinfo.cust_ffshipto AS allow_free_form_shipto, custinfo.cust_ffbillto AS allow_free_form_billto, whsinfo.warehous_code AS preferred_selling_site, taxzone.taxzone_code AS default_tax_zone, terms.terms_code AS default_terms, CASE WHEN (custinfo.cust_balmethod = 'B'::bpchar) THEN 'Balance Forward'::text ELSE 'Open Item'::text END AS balance_method, custinfo.cust_discntprcnt AS default_discount, dc.curr_abbr AS default_currency, clc.curr_abbr AS credit_limit_currency, custinfo.cust_creditlmt AS credit_limit, CASE WHEN (COALESCE(custinfo.cust_gracedays, 0) > 0) THEN custinfo.cust_gracedays ELSE NULL::integer END AS alternate_grace_days, custinfo.cust_creditrating AS credit_rating, CASE WHEN (custinfo.cust_creditstatus = 'G'::bpchar) THEN 'In Good Standing'::text WHEN (custinfo.cust_creditstatus = 'W'::bpchar) THEN 'On Credit Warning'::text ELSE 'On Credit Hold'::text END AS credit_status, custinfo.cust_autoupdatestatus AS credit_status_exceed_warn, custinfo.cust_autoholdorders AS credit_status_exceed_hold, custinfo.cust_usespos AS uses_purchase_orders, custinfo.cust_blanketpos AS uses_blanket_pos, mc.cntct_number AS billing_contact_number, mc.cntct_honorific AS billing_contact_honorific, mc.cntct_first_name AS billing_contact_first, mc.cntct_middle AS billing_contact_middle, mc.cntct_last_name AS billing_contact_last, mc.cntct_suffix AS billing_contact_suffix, mc.cntct_title AS billing_contact_job_title, mc.cntct_phone AS billing_contact_voice, mc.cntct_phone2 AS billing_contact_alternate, mc.cntct_fax AS billing_contact_fax, mc.cntct_email AS billing_contact_email, mc.cntct_webaddr AS billing_contact_web, ''::text AS billing_contact_change, m.addr_number AS billing_contact_address_number, m.addr_line1 AS billing_contact_address1, m.addr_line2 AS billing_contact_address2, m.addr_line3 AS billing_contact_address3, m.addr_city AS billing_contact_city, m.addr_state AS billing_contact_state, m.addr_postalcode AS billing_contact_postalcode, m.addr_country AS billing_contact_country, ''::text AS billing_contact_address_change, cc.cntct_number AS correspond_contact_number, cc.cntct_honorific AS correspond_contact_honorific, cc.cntct_first_name AS correspond_contact_first, cc.cntct_middle AS correspond_contact_middle, cc.cntct_last_name AS correspond_contact_last, cc.cntct_suffix AS correspond_contact_suffix, cc.cntct_title AS correspond_contact_job_title, cc.cntct_phone AS correspond_contact_voice, cc.cntct_phone2 AS correspond_contact_alternate, cc.cntct_fax AS correspond_contact_fax, cc.cntct_email AS correspond_contact_email, cc.cntct_webaddr AS correspond_contact_web, ''::text AS correspond_contact_change, c.addr_number AS correspond_contact_address_number, c.addr_line1 AS correspond_contact_address1, c.addr_line2 AS correspond_contact_address2, c.addr_line3 AS correspond_contact_address3, c.addr_city AS correspond_contact_city, c.addr_state AS correspond_contact_state, c.addr_postalcode AS correspond_contact_postalcode, c.addr_country AS correspond_contact_country, ''::text AS correspond_contact_address_change, custinfo.cust_comments AS notes FROM ((((((((public.custinfo LEFT JOIN public.shipchrg ON ((custinfo.cust_shipchrg_id = shipchrg.shipchrg_id))) LEFT JOIN public.whsinfo ON ((custinfo.cust_preferred_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.cntct mc ON ((custinfo.cust_cntct_id = mc.cntct_id))) LEFT JOIN public.addr m ON ((mc.cntct_addr_id = m.addr_id))) LEFT JOIN public.cntct cc ON ((custinfo.cust_corrcntct_id = cc.cntct_id))) LEFT JOIN public.addr c ON ((cc.cntct_addr_id = c.addr_id))) LEFT JOIN public.taxzone ON ((custinfo.cust_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.shipform ON ((custinfo.cust_shipform_id = shipform.shipform_id))), public.custtype, public.salesrep, public.curr_symbol dc, public.curr_symbol clc, public.terms WHERE (((((custinfo.cust_custtype_id = custtype.custtype_id) AND (custinfo.cust_salesrep_id = salesrep.salesrep_id)) AND (custinfo.cust_curr_id = dc.curr_id)) AND (custinfo.cust_creditlmt_curr_id = clc.curr_id)) AND (custinfo.cust_terms_id = terms.terms_id)); ALTER TABLE customer OWNER TO admin; -- -- Name: VIEW customer; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW customer IS 'Customer'; SET search_path = public, pg_catalog; -- -- Name: taxauth; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE taxauth ( taxauth_id integer NOT NULL, taxauth_code text NOT NULL, taxauth_name text, taxauth_extref text, taxauth_addr_id integer, taxauth_curr_id integer, taxauth_county text, taxauth_accnt_id integer, CONSTRAINT taxauth_taxauth_code_check CHECK ((taxauth_code <> ''::text)) ); ALTER TABLE taxauth OWNER TO admin; -- -- Name: TABLE taxauth; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE taxauth IS 'The Tax Authority table.'; -- -- Name: COLUMN taxauth.taxauth_curr_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxauth.taxauth_curr_id IS 'The required currency for recording tax information as. NULL means no preference.'; -- -- Name: taxreg; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE taxreg ( taxreg_id integer NOT NULL, taxreg_rel_id integer NOT NULL, taxreg_rel_type character(1), taxreg_taxauth_id integer, taxreg_number text NOT NULL, taxreg_taxzone_id integer, taxreg_effective date DEFAULT startoftime(), taxreg_expires date DEFAULT endoftime(), taxreg_notes text DEFAULT ''::text, CONSTRAINT taxreg_taxreg_number_check CHECK ((taxreg_number <> ''::text)) ); ALTER TABLE taxreg OWNER TO admin; -- -- Name: TABLE taxreg; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE taxreg IS 'Stores Tax Registration numbers related to objects and a given tax authority. The rel_id specifies the object id and teh rel_type specifies the object type. See column comment for additional detail on types.'; -- -- Name: COLUMN taxreg.taxreg_rel_type; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxreg.taxreg_rel_type IS 'The type of relation this record is for. Known values are C=Customer, V=Vendor, NULL=This Manufacturer in which case taxreg_rel_id is meaningless and should be -1.'; SET search_path = api, pg_catalog; -- -- Name: customertaxreg; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW customertaxreg AS SELECT (custinfo.cust_number)::character varying AS customer_number, (COALESCE(taxzone.taxzone_code, 'Any'::text))::character varying AS tax_zone, (taxauth.taxauth_code)::character varying AS tax_authority, taxreg.taxreg_number AS registration_number, CASE WHEN (taxreg.taxreg_effective = public.startoftime()) THEN 'Always'::text ELSE public.formatdate(taxreg.taxreg_effective) END AS start_date, CASE WHEN (taxreg.taxreg_expires = public.endoftime()) THEN 'Never'::text ELSE public.formatdate(taxreg.taxreg_expires) END AS end_date, taxreg.taxreg_notes AS notes FROM (((public.taxreg LEFT JOIN public.custinfo ON ((custinfo.cust_id = taxreg.taxreg_rel_id))) LEFT JOIN public.taxauth ON ((taxauth.taxauth_id = taxreg.taxreg_taxauth_id))) LEFT JOIN public.taxzone ON ((taxzone.taxzone_id = taxreg.taxreg_taxzone_id))) WHERE (taxreg.taxreg_rel_type = 'C'::bpchar) ORDER BY custinfo.cust_number, taxreg.taxreg_number; ALTER TABLE customertaxreg OWNER TO admin; -- -- Name: VIEW customertaxreg; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW customertaxreg IS 'Customer Tax Registrations'; -- -- Name: customertype; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW customertype AS SELECT (custtype.custtype_code)::character varying AS code, custtype.custtype_descrip AS description, custtype.custtype_char AS enable_characteristics_profile FROM public.custtype ORDER BY custtype.custtype_code; ALTER TABLE customertype OWNER TO admin; -- -- Name: VIEW customertype; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW customertype IS 'Customer Type'; -- -- Name: customertypechar; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW customertypechar AS SELECT (custtype.custtype_code)::character varying AS customer_type, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value, charass.charass_default AS is_default FROM public.custtype, public."char", public.charass WHERE ((('CT'::text = charass.charass_target_type) AND (custtype.custtype_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id)); ALTER TABLE customertypechar OWNER TO admin; -- -- Name: VIEW customertypechar; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW customertypechar IS 'Customer Type Characteristics'; -- -- Name: custshipto; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW custshipto AS SELECT (custinfo.cust_number)::character varying AS customer_number, (shiptoinfo.shipto_num)::character varying AS shipto_number, shiptoinfo.shipto_active AS active, shiptoinfo.shipto_name AS name, shiptoinfo.shipto_default AS default_flag, addr.addr_number AS address_number, addr.addr_line1 AS address1, addr.addr_line2 AS address2, addr.addr_line3 AS address3, addr.addr_city AS city, addr.addr_state AS state, addr.addr_postalcode AS postal_code, addr.addr_country AS country, ''::text AS address_change, cntct.cntct_number AS contact_number, cntct.cntct_honorific AS honorific, cntct.cntct_first_name AS first, cntct.cntct_middle AS middle, cntct.cntct_last_name AS last, cntct.cntct_suffix AS suffix, cntct.cntct_title AS job_title, cntct.cntct_phone AS phone, cntct.cntct_fax AS fax, cntct.cntct_email AS email, ''::text AS contact_change, salesrep.salesrep_number AS sales_rep, (shiptoinfo.shipto_commission * 100.0) AS commission, shipzone.shipzone_name AS zone, taxzone.taxzone_code AS tax_zone, shiptoinfo.shipto_shipvia AS ship_via, shipform.shipform_name AS ship_form, shipchrg.shipchrg_name AS shipping_charges, CASE WHEN (shiptoinfo.shipto_ediprofile_id = (-1)) THEN 'No EDI'::text WHEN (shiptoinfo.shipto_ediprofile_id = (-2)) THEN 'Use Customer Master'::text ELSE public.getediprofilename(shiptoinfo.shipto_ediprofile_id) END AS edi_profile, shiptoinfo.shipto_comments AS general_notes, shiptoinfo.shipto_shipcomments AS shipping_notes FROM public.custinfo, ((((((public.shiptoinfo LEFT JOIN public.shipchrg ON ((shiptoinfo.shipto_shipchrg_id = shipchrg.shipchrg_id))) LEFT JOIN public.cntct ON ((shiptoinfo.shipto_cntct_id = cntct.cntct_id))) LEFT JOIN public.addr ON ((shiptoinfo.shipto_addr_id = addr.addr_id))) LEFT JOIN public.taxzone ON ((shiptoinfo.shipto_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.shipzone ON ((shiptoinfo.shipto_shipzone_id = shipzone.shipzone_id))) LEFT JOIN public.salesrep ON ((shiptoinfo.shipto_salesrep_id = salesrep.salesrep_id))), public.shipform WHERE ((custinfo.cust_id = shiptoinfo.shipto_cust_id) AND (custinfo.cust_shipform_id = shipform.shipform_id)); ALTER TABLE custshipto OWNER TO admin; -- -- Name: VIEW custshipto; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW custshipto IS 'Customer Shipto Address'; -- -- Name: custtax; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW custtax AS SELECT (custinfo.cust_number)::character varying AS customer_number, (taxauth.taxauth_code)::character varying AS tax_authority, taxreg.taxreg_number AS registration_number FROM public.custinfo, public.taxauth, public.taxreg WHERE (((taxreg.taxreg_rel_type = 'C'::bpchar) AND (taxreg.taxreg_rel_id = custinfo.cust_id)) AND (taxreg.taxreg_taxauth_id = taxauth.taxauth_id)); ALTER TABLE custtax OWNER TO admin; -- -- Name: VIEW custtax; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW custtax IS 'Customer Tax Registration'; SET search_path = public, pg_catalog; -- -- Name: dept; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE dept ( dept_id integer NOT NULL, dept_number text NOT NULL, dept_name text NOT NULL, CONSTRAINT dept_dept_number_check CHECK ((dept_number <> ''::text)) ); ALTER TABLE dept OWNER TO admin; -- -- Name: TABLE dept; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE dept IS 'List of Departments'; -- -- Name: emp; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE emp ( emp_id integer NOT NULL, emp_code text NOT NULL, emp_number text NOT NULL, emp_active boolean DEFAULT true NOT NULL, emp_cntct_id integer, emp_warehous_id integer, emp_mgr_emp_id integer, emp_wage_type text NOT NULL, emp_wage numeric, emp_wage_curr_id integer DEFAULT basecurrid(), emp_wage_period text NOT NULL, emp_dept_id integer, emp_shift_id integer, emp_notes text, emp_image_id integer, emp_username text, emp_extrate numeric, emp_extrate_period text NOT NULL, emp_startdate date DEFAULT ('now'::text)::date, emp_name text NOT NULL, CONSTRAINT emp_check CHECK (((((COALESCE(emp_wage_type, ''::text) = ''::text) OR (COALESCE(emp_wage_type, ''::text) = 'H'::text)) OR (COALESCE(emp_wage_type, ''::text) = 'S'::text)) AND ((COALESCE(emp_wage, (0)::numeric) = (0)::numeric) OR ((COALESCE(emp_wage_type, ''::text) <> ''::text) AND (emp_wage IS NOT NULL))))), CONSTRAINT emp_emp_code_check CHECK ((emp_code <> ''::text)), CONSTRAINT emp_emp_number_check CHECK ((emp_number <> ''::text)), CONSTRAINT emp_emp_wage_period_check CHECK ((((((((COALESCE(emp_wage_period, ''::text) = ''::text) OR (COALESCE(emp_wage_period, ''::text) = 'H'::text)) OR (COALESCE(emp_wage_period, ''::text) = 'D'::text)) OR (COALESCE(emp_wage_period, ''::text) = 'W'::text)) OR (COALESCE(emp_wage_period, ''::text) = 'BW'::text)) OR (COALESCE(emp_wage_period, ''::text) = 'M'::text)) OR (COALESCE(emp_wage_period, ''::text) = 'Y'::text))) ); ALTER TABLE emp OWNER TO admin; -- -- Name: TABLE emp; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE emp IS 'Employee table describing the basic properties of an employee. Employees need not be system users.'; -- -- Name: COLUMN emp.emp_code; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN emp.emp_code IS 'Short, human-readable name for employee. This value is kept synchronized with usr_username and salesrep_number, and so is unique across all three tables emp, usr, and salesrep.'; -- -- Name: COLUMN emp.emp_number; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN emp.emp_number IS 'Official employee number. This might be used for ID badges, payroll accounting, or other purposes.'; -- -- Name: COLUMN emp.emp_mgr_emp_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN emp.emp_mgr_emp_id IS 'Internal ID of this employee''s manager/supervisor.'; -- -- Name: COLUMN emp.emp_wage_type; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN emp.emp_wage_type IS 'The nature of the wage or employment agreement. ''H'' indicates this employee is paid on an hourly basis (or some other period) while ''S'' indicates this employee is salaried.'; -- -- Name: COLUMN emp.emp_wage_period; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN emp.emp_wage_period IS 'The periodicity of wage payment: ''H'' for hourly, ''D'' for daily, ''W'' for weekly, ''BW'' for biweekly, ''M'' for monthly, ''Y'' for yearly.'; -- -- Name: COLUMN emp.emp_username; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN emp.emp_username IS 'DEPRECATED - the relationship between Employee and User is now maintained through the crmacct table.'; -- -- Name: COLUMN emp.emp_extrate_period; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN emp.emp_extrate_period IS 'The periodicity of external rate payment: ''H'' for hourly, ''D'' for daily, ''W'' for weekly, ''BW'' for biweekly, ''M'' for monthly, ''Y'' for yearly.'; -- -- Name: shift; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE shift ( shift_id integer NOT NULL, shift_number text NOT NULL, shift_name text NOT NULL, CONSTRAINT shift_shift_number_check CHECK ((shift_number <> ''::text)) ); ALTER TABLE shift OWNER TO admin; -- -- Name: TABLE shift; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE shift IS 'List of work Shifts'; SET search_path = api, pg_catalog; -- -- Name: employee; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW employee AS SELECT (e.emp_code)::character varying AS code, (e.emp_number)::character varying AS number, e.emp_active AS active, e.emp_startdate AS start_date, cntct.cntct_number AS contact_number, cntct.cntct_honorific AS honorific, cntct.cntct_first_name AS first, cntct.cntct_middle AS middle, cntct.cntct_last_name AS last, cntct.cntct_suffix AS suffix, cntct.cntct_title AS job_title, cntct.cntct_phone AS voice, cntct.cntct_phone2 AS alternate, cntct.cntct_fax AS fax, cntct.cntct_email AS email, cntct.cntct_webaddr AS web, ''::text AS contact_change, addr.addr_number AS address_number, addr.addr_line1 AS address1, addr.addr_line2 AS address2, addr.addr_line3 AS address3, addr.addr_city AS city, addr.addr_state AS state, addr.addr_postalcode AS postalcode, addr.addr_country AS country, ''::text AS address_change, whsinfo.warehous_code AS site, m.emp_code AS manager_code, CASE WHEN (e.emp_wage_type = 'H'::text) THEN 'Hourly'::text WHEN (e.emp_wage_type = 'S'::text) THEN 'Salaried'::text WHEN (e.emp_wage_type IS NULL) THEN NULL::text ELSE 'Error'::text END AS wage_type, e.emp_wage AS wage, curr_symbol.curr_abbr AS wage_currency, CASE WHEN (e.emp_wage_period = 'H'::text) THEN 'Hour'::text WHEN (e.emp_wage_period = 'D'::text) THEN 'Day'::text WHEN (e.emp_wage_period = 'W'::text) THEN 'Week'::text WHEN (e.emp_wage_period = 'BW'::text) THEN 'Biweek'::text WHEN (e.emp_wage_period = 'M'::text) THEN 'Month'::text WHEN (e.emp_wage_period = 'Y'::text) THEN 'Year'::text WHEN (e.emp_wage_period IS NULL) THEN NULL::text ELSE 'Error'::text END AS wage_period, dept.dept_number AS department, shift.shift_number AS shift, (crmacct.crmacct_usr_username IS NOT NULL) AS is_user, (salesrep.salesrep_id IS NOT NULL) AS is_salesrep, (vendinfo.vend_id IS NOT NULL) AS is_vendor, e.emp_notes AS notes, image.image_name AS image, e.emp_extrate AS rate, curr_symbol.curr_abbr AS billing_currency, CASE WHEN (e.emp_extrate_period = 'H'::text) THEN 'Hour'::text WHEN (e.emp_extrate_period = 'D'::text) THEN 'Day'::text WHEN (e.emp_extrate_period = 'W'::text) THEN 'Week'::text WHEN (e.emp_extrate_period = 'BW'::text) THEN 'Biweek'::text WHEN (e.emp_extrate_period = 'M'::text) THEN 'Month'::text WHEN (e.emp_extrate_period = 'Y'::text) THEN 'Year'::text WHEN (e.emp_extrate_period IS NULL) THEN NULL::text ELSE 'Error'::text END AS billing_period FROM (((((((((((public.emp e JOIN public.crmacct ON ((e.emp_id = crmacct.crmacct_emp_id))) LEFT JOIN public.cntct ON ((e.emp_cntct_id = cntct.cntct_id))) LEFT JOIN public.addr ON ((cntct.cntct_addr_id = addr.addr_id))) LEFT JOIN public.whsinfo ON ((e.emp_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.emp m ON ((e.emp_mgr_emp_id = m.emp_id))) LEFT JOIN public.dept ON ((e.emp_dept_id = dept.dept_id))) LEFT JOIN public.shift ON ((e.emp_shift_id = shift.shift_id))) LEFT JOIN public.salesrep ON ((crmacct.crmacct_salesrep_id = salesrep.salesrep_id))) LEFT JOIN public.vendinfo ON ((crmacct.crmacct_vend_id = vendinfo.vend_id))) LEFT JOIN public.image ON ((e.emp_image_id = image.image_id))) LEFT JOIN public.curr_symbol ON ((e.emp_wage_curr_id = curr_symbol.curr_id))); ALTER TABLE employee OWNER TO admin; -- -- Name: VIEW employee; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW employee IS 'Employee'; -- -- Name: employeechar; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW employeechar AS SELECT (emp.emp_code)::character varying AS employee_code, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value FROM public.emp, public."char", public.charass WHERE ((('EMP'::text = charass.charass_target_type) AND (emp.emp_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id)); ALTER TABLE employeechar OWNER TO admin; -- -- Name: VIEW employeechar; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW employeechar IS 'Employee Characteristics'; -- -- Name: employeecomment; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW employeecomment AS SELECT (emp.emp_code)::character varying AS code, (cmnttype.cmnttype_name)::character varying AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.emp, public.cmnttype, public.comment WHERE (((comment.comment_source = 'EMP'::text) AND (comment.comment_source_id = emp.emp_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); ALTER TABLE employeecomment OWNER TO admin; -- -- Name: VIEW employeecomment; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW employeecomment IS 'Employee Comment'; SET search_path = public, pg_catalog; -- -- Name: shipdata; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE shipdata ( shipdata_cohead_number text NOT NULL, shipdata_cosmisc_tracknum text NOT NULL, shipdata_cosmisc_packnum_tracknum text NOT NULL, shipdata_weight numeric(16,4), shipdata_base_freight numeric(16,4), shipdata_total_freight numeric(16,4), shipdata_shipper text DEFAULT 'UPS'::text, shipdata_billing_option text, shipdata_package_type text, shipdata_void_ind character(1) NOT NULL, shipdata_lastupdated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL, shipdata_shiphead_number text, shipdata_base_freight_curr_id integer DEFAULT basecurrid(), shipdata_total_freight_curr_id integer DEFAULT basecurrid() ); ALTER TABLE shipdata OWNER TO admin; -- -- Name: TABLE shipdata; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE shipdata IS 'Shipping Interface information - note that the shipdata_cohead_nember is text and not int. That is due to ODBC chopping off during the transfer'; SET search_path = api, pg_catalog; -- -- Name: extshipmaint; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW extshipmaint AS SELECT (shipdata.shipdata_cohead_number)::character varying AS so_number, (shipdata.shipdata_shiphead_number)::character varying AS shipment_number, (shipdata.shipdata_shipper)::character varying AS shipper, (shipdata.shipdata_cosmisc_packnum_tracknum)::character varying AS package_tracking_number, shipdata.shipdata_void_ind AS void, shipdata.shipdata_billing_option AS billing_option, shipdata.shipdata_weight AS weight, shipdata.shipdata_base_freight AS base_freight, base.curr_abbr AS base_freight_currency, shipdata.shipdata_total_freight AS total_freight, total.curr_abbr AS total_freight_currency, shipdata.shipdata_package_type AS package_type, shipdata.shipdata_cosmisc_tracknum AS tracking_number, shipdata.shipdata_lastupdated AS last_updated FROM public.shipdata, public.curr_symbol base, public.curr_symbol total WHERE ((shipdata.shipdata_base_freight_curr_id = base.curr_id) AND (shipdata.shipdata_total_freight_curr_id = total.curr_id)) ORDER BY shipdata.shipdata_cohead_number, shipdata.shipdata_shiphead_number; ALTER TABLE extshipmaint OWNER TO admin; -- -- Name: VIEW extshipmaint; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW extshipmaint IS 'External Shipping Maintenance'; SET search_path = public, pg_catalog; -- -- Name: freightclass; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE freightclass ( freightclass_id integer NOT NULL, freightclass_code text NOT NULL, freightclass_descrip text, CONSTRAINT freightclass_freightclass_code_check CHECK ((freightclass_code <> ''::text)) ); ALTER TABLE freightclass OWNER TO admin; -- -- Name: TABLE freightclass; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE freightclass IS 'This table is the freight price schedules.'; -- -- Name: ipsfreight; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE ipsfreight ( ipsfreight_id integer NOT NULL, ipsfreight_ipshead_id integer NOT NULL, ipsfreight_qtybreak numeric DEFAULT 0 NOT NULL, ipsfreight_price numeric DEFAULT 0 NOT NULL, ipsfreight_type character(1) NOT NULL, ipsfreight_warehous_id integer, ipsfreight_shipzone_id integer, ipsfreight_freightclass_id integer, ipsfreight_shipvia text ); ALTER TABLE ipsfreight OWNER TO admin; -- -- Name: ipshead; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE ipshead ( ipshead_id integer DEFAULT nextval(('"ipshead_ipshead_id_seq"'::text)::regclass) NOT NULL, ipshead_name text NOT NULL, ipshead_descrip text, ipshead_effective date, ipshead_expires date, ipshead_curr_id integer DEFAULT basecurrid() NOT NULL, ipshead_updated date, CONSTRAINT ipshead_ipshead_name_check CHECK ((ipshead_name <> ''::text)) ); ALTER TABLE ipshead OWNER TO admin; -- -- Name: TABLE ipshead; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE ipshead IS 'Pricing Schedule header information'; SET search_path = api, pg_catalog; -- -- Name: freightpricingscheduleitem; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW freightpricingscheduleitem AS SELECT (ipshead.ipshead_name)::character varying AS pricing_schedule, ipsfreight.ipsfreight_qtybreak AS qty_break, (qtyuom.uom_name)::character varying AS qty_uom, ipsfreight.ipsfreight_price AS price, CASE WHEN (ipsfreight.ipsfreight_type = 'F'::bpchar) THEN 'Flat Rate'::text ELSE 'Price Per UOM'::text END AS price_type, COALESCE(whsinfo.warehous_code, 'Any'::text) AS from_site, COALESCE(shipzone.shipzone_name, 'Any'::text) AS to_shipzone, COALESCE(ipsfreight.ipsfreight_shipvia, 'Any'::text) AS ship_via, COALESCE(freightclass.freightclass_code, 'Any'::text) AS freight_class FROM (((((public.ipsfreight JOIN public.ipshead ON ((ipsfreight.ipsfreight_ipshead_id = ipshead.ipshead_id))) LEFT JOIN public.uom qtyuom ON (qtyuom.uom_item_weight)) LEFT JOIN public.whsinfo ON ((whsinfo.warehous_id = ipsfreight.ipsfreight_warehous_id))) LEFT JOIN public.shipzone ON ((shipzone.shipzone_id = ipsfreight.ipsfreight_shipzone_id))) LEFT JOIN public.freightclass ON ((freightclass.freightclass_id = ipsfreight.ipsfreight_freightclass_id))); ALTER TABLE freightpricingscheduleitem OWNER TO admin; -- -- Name: VIEW freightpricingscheduleitem; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW freightpricingscheduleitem IS 'Freight Pricing Schedule Item'; -- -- Name: glaccount; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW glaccount AS SELECT (accnt.accnt_company)::character varying AS company, (accnt.accnt_profit)::character varying AS profit_center, (accnt.accnt_number)::character varying AS account_number, (accnt.accnt_sub)::character varying AS sub_account, accnt.accnt_descrip AS description, accnt.accnt_extref AS ext_reference, CASE WHEN (accnt.accnt_type = 'A'::bpchar) THEN 'Asset'::text WHEN (accnt.accnt_type = 'L'::bpchar) THEN 'Liability'::text WHEN (accnt.accnt_type = 'E'::bpchar) THEN 'Expense'::text WHEN (accnt.accnt_type = 'R'::bpchar) THEN 'Revenue'::text WHEN (accnt.accnt_type = 'Q'::bpchar) THEN 'Equity'::text ELSE '?'::text END AS type, accnt.accnt_subaccnttype_code AS sub_type, accnt.accnt_forwardupdate AS forward_update_trial_balances, accnt.accnt_comments AS notes FROM public.accnt ORDER BY accnt.accnt_company, accnt.accnt_profit, accnt.accnt_number, accnt.accnt_sub; ALTER TABLE glaccount OWNER TO admin; -- -- Name: VIEW glaccount; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW glaccount IS 'GL Account'; SET search_path = public, pg_catalog; -- -- Name: incdtcat; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE incdtcat ( incdtcat_id integer NOT NULL, incdtcat_name text NOT NULL, incdtcat_order integer, incdtcat_descrip text, incdtcat_ediprofile_id integer, CONSTRAINT incdtcat_incdtcat_name_check CHECK ((incdtcat_name <> ''::text)) ); ALTER TABLE incdtcat OWNER TO admin; -- -- Name: TABLE incdtcat; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE incdtcat IS 'Incident Category table'; -- -- Name: incdtpriority; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE incdtpriority ( incdtpriority_id integer NOT NULL, incdtpriority_name text NOT NULL, incdtpriority_order integer, incdtpriority_descrip text, CONSTRAINT incdtpriority_incdtpriority_name_check CHECK ((incdtpriority_name <> ''::text)) ); ALTER TABLE incdtpriority OWNER TO admin; -- -- Name: TABLE incdtpriority; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE incdtpriority IS 'Incident Priority table'; -- -- Name: incdtresolution; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE incdtresolution ( incdtresolution_id integer NOT NULL, incdtresolution_name text NOT NULL, incdtresolution_order integer, incdtresolution_descrip text, CONSTRAINT incdtresolution_incdtresolution_name_check CHECK ((incdtresolution_name <> ''::text)) ); ALTER TABLE incdtresolution OWNER TO admin; -- -- Name: TABLE incdtresolution; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE incdtresolution IS 'Incident Resolution table'; -- -- Name: incdtseverity; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE incdtseverity ( incdtseverity_id integer NOT NULL, incdtseverity_name text NOT NULL, incdtseverity_order integer, incdtseverity_descrip text, CONSTRAINT incdtseverity_incdtseverity_name_check CHECK ((incdtseverity_name <> ''::text)) ); ALTER TABLE incdtseverity OWNER TO admin; -- -- Name: TABLE incdtseverity; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE incdtseverity IS 'Incident Severity table'; SET search_path = api, pg_catalog; -- -- Name: incident; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW incident AS SELECT incdt.incdt_number AS incident_number, incdtcat.incdtcat_name AS category, incdt.incdt_summary AS description, crmacct.crmacct_number AS crm_account, incdt.incdt_assigned_username AS assigned_to, CASE WHEN (incdt.incdt_status = 'N'::bpchar) THEN 'New'::text WHEN (incdt.incdt_status = 'F'::bpchar) THEN 'Feedback'::text WHEN (incdt.incdt_status = 'C'::bpchar) THEN 'Confirmed'::text WHEN (incdt.incdt_status = 'A'::bpchar) THEN 'Assigned'::text WHEN (incdt.incdt_status = 'R'::bpchar) THEN 'Resolved'::text WHEN (incdt.incdt_status = 'L'::bpchar) THEN 'Closed'::text ELSE '?'::text END AS status, incdtseverity.incdtseverity_name AS severity, incdtpriority.incdtpriority_name AS priority, incdtresolution.incdtresolution_name AS resolution, cntct.cntct_number AS contact_number, cntct.cntct_honorific AS honorific, cntct.cntct_first_name AS first, cntct.cntct_middle AS middle, cntct.cntct_last_name AS last, cntct.cntct_suffix AS suffix, cntct.cntct_title AS job_title, cntct.cntct_phone AS phone, cntct.cntct_fax AS fax, cntct.cntct_email AS email, ''::text AS contact_change, incdt.incdt_descrip AS notes, item.item_number, incdt.incdt_lotserial AS lot_serial_number, CASE WHEN (aropen.aropen_doctype = 'C'::bpchar) THEN 'C/M'::text WHEN (aropen.aropen_doctype = 'D'::bpchar) THEN 'D/M'::text WHEN (aropen.aropen_doctype = 'I'::bpchar) THEN 'Invoice'::text WHEN (aropen.aropen_doctype = 'R'::bpchar) THEN 'C/D'::text ELSE ''::text END AS ar_doc_type, aropen.aropen_docnumber AS ar_doc_number FROM ((((((((public.incdt LEFT JOIN public.incdtcat ON ((incdtcat.incdtcat_id = incdt.incdt_incdtcat_id))) LEFT JOIN public.crmacct ON ((crmacct.crmacct_id = incdt.incdt_crmacct_id))) LEFT JOIN public.incdtseverity ON ((incdtseverity.incdtseverity_id = incdt.incdt_incdtseverity_id))) LEFT JOIN public.incdtpriority ON ((incdtpriority.incdtpriority_id = incdt.incdt_incdtpriority_id))) LEFT JOIN public.incdtresolution ON ((incdtresolution.incdtresolution_id = incdt.incdt_incdtresolution_id))) LEFT JOIN public.cntct ON ((cntct.cntct_id = incdt.incdt_cntct_id))) LEFT JOIN public.item ON ((item.item_id = incdt.incdt_item_id))) LEFT JOIN public.aropen ON ((aropen.aropen_id = incdt.incdt_aropen_id))); ALTER TABLE incident OWNER TO admin; -- -- Name: VIEW incident; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW incident IS 'Incident'; -- -- Name: incidentchar; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW incidentchar AS SELECT incdt.incdt_number AS incident_number, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value FROM public.incdt, public."char", public.charass WHERE ((('INCDT'::text = charass.charass_target_type) AND (incdt.incdt_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id)); ALTER TABLE incidentchar OWNER TO admin; -- -- Name: VIEW incidentchar; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW incidentchar IS 'Incident Characteristics'; -- -- Name: incidentcomment; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW incidentcomment AS SELECT incdt.incdt_number AS incident_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text, comment.comment_public AS public FROM public.incdt, public.cmnttype, public.comment WHERE (((comment.comment_source = 'INCDT'::text) AND (comment.comment_source_id = incdt.incdt_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); ALTER TABLE incidentcomment OWNER TO admin; -- -- Name: VIEW incidentcomment; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW incidentcomment IS 'Incident Comment'; -- -- Name: incidentfile; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW incidentfile AS SELECT incdt.incdt_number AS incident_number, url.url_title AS title, url.url_url AS url FROM public.incdt, public.url WHERE ((incdt.incdt_id = url.url_source_id) AND (url.url_source = 'INCDT'::text)); ALTER TABLE incidentfile OWNER TO admin; -- -- Name: VIEW incidentfile; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW incidentfile IS 'Incident File'; -- -- Name: incidentimage; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW incidentimage AS SELECT incdt.incdt_number AS incident_number, image.image_name FROM public.incdt, public.imageass, public.image WHERE (((incdt.incdt_id = imageass.imageass_source_id) AND (imageass.imageass_source = 'INCDT'::text)) AND (imageass.imageass_image_id = image.image_id)); ALTER TABLE incidentimage OWNER TO admin; -- -- Name: VIEW incidentimage; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW incidentimage IS 'Incident Image'; SET search_path = public, pg_catalog; -- -- Name: classcode; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE classcode ( classcode_id integer DEFAULT nextval(('classcode_classcode_id_seq'::text)::regclass) NOT NULL, classcode_code text NOT NULL, classcode_descrip text, classcode_mfg boolean, classcode_creator text, classcode_created timestamp without time zone, classcode_modifier text, classcode_modified timestamp without time zone, classcode_type text, CONSTRAINT classcode_classcode_code_check CHECK ((classcode_code <> ''::text)) ); ALTER TABLE classcode OWNER TO admin; -- -- Name: TABLE classcode; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE classcode IS 'Class Code information'; -- -- Name: prodcat; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE prodcat ( prodcat_id integer DEFAULT nextval(('prodcat_prodcat_id_seq'::text)::regclass) NOT NULL, prodcat_code text NOT NULL, prodcat_descrip text, CONSTRAINT prodcat_prodcat_code_check CHECK ((prodcat_code <> ''::text)) ); ALTER TABLE prodcat OWNER TO admin; -- -- Name: TABLE prodcat; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE prodcat IS 'Product Category information'; SET search_path = api, pg_catalog; -- -- Name: item; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW item AS SELECT (item.item_number)::character varying AS item_number, item.item_active AS active, item.item_descrip1 AS description1, item.item_descrip2 AS description2, CASE WHEN (item.item_type = 'P'::bpchar) THEN 'Purchased'::text WHEN (item.item_type = 'M'::bpchar) THEN 'Manufactured'::text WHEN (item.item_type = 'J'::bpchar) THEN 'Job'::text WHEN (item.item_type = 'K'::bpchar) THEN 'Kit'::text WHEN (item.item_type = 'F'::bpchar) THEN 'Phantom'::text WHEN (item.item_type = 'R'::bpchar) THEN 'Reference'::text WHEN (item.item_type = 'S'::bpchar) THEN 'Costing'::text WHEN (item.item_type = 'T'::bpchar) THEN 'Tooling'::text WHEN (item.item_type = 'O'::bpchar) THEN 'Outside Process'::text WHEN (item.item_type = 'L'::bpchar) THEN 'Planning'::text WHEN (item.item_type = 'B'::bpchar) THEN 'Breeder'::text WHEN (item.item_type = 'C'::bpchar) THEN 'Co-Product'::text WHEN (item.item_type = 'Y'::bpchar) THEN 'By-Product'::text ELSE NULL::text END AS item_type, item.item_maxcost AS maximum_desired_cost, classcode.classcode_code AS class_code, i.uom_name AS inventory_uom, item.item_picklist AS pick_list_item, item.item_fractional AS fractional, item.item_config AS configured, item.item_sold AS item_is_sold, prodcat.prodcat_code AS product_category, item.item_exclusive AS exclusive, item.item_listprice AS list_price, item.item_listcost AS list_cost, p.uom_name AS list_price_uom, item.item_upccode AS upc_code, item.item_prodweight AS product_weight, item.item_packweight AS packaging_weight, item.item_comments AS notes, item.item_extdescrip AS ext_description FROM (public.item LEFT JOIN public.prodcat ON ((item.item_prodcat_id = prodcat.prodcat_id))), public.classcode, public.uom i, public.uom p WHERE (((item.item_classcode_id = classcode.classcode_id) AND (item.item_inv_uom_id = i.uom_id)) AND (item.item_price_uom_id = p.uom_id)) ORDER BY (item.item_number)::character varying; ALTER TABLE item OWNER TO admin; -- -- Name: VIEW item; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW item IS 'Item'; SET search_path = public, pg_catalog; -- -- Name: itemalias; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE itemalias ( itemalias_id integer DEFAULT nextval(('"itemalias_itemalias_id_seq"'::text)::regclass) NOT NULL, itemalias_item_id integer NOT NULL, itemalias_number text NOT NULL, itemalias_comments text, itemalias_usedescrip boolean NOT NULL, itemalias_descrip1 text, itemalias_descrip2 text, itemalias_crmacct_id integer, CONSTRAINT itemalias_itemalias_number_check CHECK ((itemalias_number <> ''::text)) ); ALTER TABLE itemalias OWNER TO admin; -- -- Name: TABLE itemalias; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE itemalias IS 'Item Alias information'; -- -- Name: COLUMN itemalias.itemalias_crmacct_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN itemalias.itemalias_crmacct_id IS 'Associated crmacct for item alias.'; SET search_path = api, pg_catalog; -- -- Name: itemalias; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW itemalias AS SELECT (item.item_number)::character varying AS item_number, itemalias.itemalias_number AS alias_number, COALESCE(crmacct.crmacct_number, ''::text) AS crmacct_number, itemalias.itemalias_usedescrip AS use_description, itemalias.itemalias_descrip1 AS description1, itemalias.itemalias_descrip2 AS description2, itemalias.itemalias_comments AS comments FROM ((public.item JOIN public.itemalias ON ((item.item_id = itemalias.itemalias_item_id))) LEFT JOIN public.crmacct ON ((crmacct.crmacct_id = itemalias.itemalias_crmacct_id))); ALTER TABLE itemalias OWNER TO admin; -- -- Name: VIEW itemalias; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW itemalias IS 'Item Alias'; -- -- Name: itemchar; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW itemchar AS SELECT (item.item_number)::character varying AS item_number, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value, charass.charass_default AS is_default FROM public.item, public."char", public.charass WHERE ((('I'::text = charass.charass_target_type) AND (item.item_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id)); ALTER TABLE itemchar OWNER TO admin; -- -- Name: VIEW itemchar; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW itemchar IS 'Item Characteristic'; -- -- Name: itemcomment; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW itemcomment AS SELECT (item.item_number)::character varying AS item_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.item, public.cmnttype, public.comment WHERE (((comment.comment_source = 'I'::text) AND (comment.comment_source_id = item.item_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); ALTER TABLE itemcomment OWNER TO admin; -- -- Name: VIEW itemcomment; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW itemcomment IS 'Item Comments'; SET search_path = public, pg_catalog; -- -- Name: costelem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE costelem ( costelem_id integer DEFAULT nextval(('costelem_costelem_id_seq'::text)::regclass) NOT NULL, costelem_type text NOT NULL, costelem_sys boolean, costelem_po boolean, costelem_active boolean, costelem_exp_accnt_id integer, costelem_cost_item_id integer, CONSTRAINT costelem_costelem_type_check CHECK ((costelem_type <> ''::text)) ); ALTER TABLE costelem OWNER TO admin; -- -- Name: TABLE costelem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE costelem IS 'Costing Element information'; -- -- Name: itemcost; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE itemcost ( itemcost_id integer DEFAULT nextval(('itemcost_itemcost_id_seq'::text)::regclass) NOT NULL, itemcost_item_id integer NOT NULL, itemcost_costelem_id integer NOT NULL, itemcost_lowlevel boolean DEFAULT false NOT NULL, itemcost_stdcost numeric(16,6) DEFAULT 0 NOT NULL, itemcost_posted date, itemcost_actcost numeric(16,6) DEFAULT 0 NOT NULL, itemcost_updated date, itemcost_curr_id integer DEFAULT basecurrid() NOT NULL ); ALTER TABLE itemcost OWNER TO admin; -- -- Name: TABLE itemcost; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE itemcost IS 'Item Cost information'; SET search_path = api, pg_catalog; -- -- Name: itemcost; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW itemcost AS SELECT (item.item_number)::character varying(100) AS item_number, (costelem.costelem_type)::character varying(100) AS costing_element, itemcost.itemcost_actcost AS actual_cost, curr_symbol.curr_abbr AS currency, false AS post_to_standard FROM (((public.itemcost LEFT JOIN public.item ON ((itemcost.itemcost_item_id = item.item_id))) LEFT JOIN public.costelem ON ((itemcost.itemcost_costelem_id = costelem.costelem_id))) LEFT JOIN public.curr_symbol ON ((itemcost.itemcost_curr_id = curr_symbol.curr_id))) ORDER BY (item.item_number)::character varying(100), (costelem.costelem_type)::character varying(100); ALTER TABLE itemcost OWNER TO admin; -- -- Name: VIEW itemcost; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW itemcost IS 'Item Cost'; -- -- Name: itemfile; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW itemfile AS SELECT (item.item_number)::character varying AS item_number, url.url_title AS title, url.url_url AS url FROM public.item, public.url WHERE ((item.item_id = url.url_source_id) AND (url.url_source = 'I'::text)); ALTER TABLE itemfile OWNER TO admin; -- -- Name: VIEW itemfile; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW itemfile IS 'Item File'; -- -- Name: itemimage; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW itemimage AS SELECT (item.item_number)::character varying AS item_number, CASE WHEN (imageass.imageass_purpose = 'P'::bpchar) THEN 'Product Description'::text WHEN (imageass.imageass_purpose = 'I'::bpchar) THEN 'Inventory Description'::text WHEN (imageass.imageass_purpose = 'E'::bpchar) THEN 'Engineering Reference'::text WHEN (imageass.imageass_purpose = 'M'::bpchar) THEN 'Miscellaneous'::text ELSE 'Other'::text END AS purpose, image.image_name FROM public.item, public.imageass, public.image WHERE (((item.item_id = imageass.imageass_source_id) AND (imageass.imageass_source = 'I'::text)) AND (imageass.imageass_image_id = image.image_id)); ALTER TABLE itemimage OWNER TO admin; -- -- Name: VIEW itemimage; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW itemimage IS 'Item Image'; SET search_path = public, pg_catalog; -- -- Name: costcat; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE costcat ( costcat_id integer DEFAULT nextval(('costcat_costcat_id_seq'::text)::regclass) NOT NULL, costcat_code text NOT NULL, costcat_descrip text, costcat_asset_accnt_id integer, costcat_liability_accnt_id integer, costcat_adjustment_accnt_id integer, costcat_matusage_accnt_id integer, costcat_purchprice_accnt_id integer, costcat_laboroverhead_accnt_id integer, costcat_scrap_accnt_id integer, costcat_invcost_accnt_id integer, costcat_wip_accnt_id integer, costcat_shipasset_accnt_id integer, costcat_mfgscrap_accnt_id integer, costcat_transform_accnt_id integer, costcat_freight_accnt_id integer, costcat_toliability_accnt_id integer, costcat_exp_accnt_id integer, CONSTRAINT costcat_costcat_code_check CHECK ((costcat_code <> ''::text)) ); ALTER TABLE costcat OWNER TO admin; -- -- Name: TABLE costcat; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE costcat IS 'Cost Category information'; -- -- Name: plancode; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE plancode ( plancode_id integer DEFAULT nextval(('plancode_plancode_id_seq'::text)::regclass) NOT NULL, plancode_code text NOT NULL, plancode_name text, plancode_mpsexplosion character(1), plancode_consumefcst boolean, plancode_mrpexcp_resched boolean, plancode_mrpexcp_delete boolean, CONSTRAINT plancode_plancode_code_check CHECK ((plancode_code <> ''::text)) ); ALTER TABLE plancode OWNER TO admin; -- -- Name: TABLE plancode; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE plancode IS 'Planner Code information'; SET search_path = api, pg_catalog; -- -- Name: itemsite; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW itemsite AS SELECT (item.item_number)::character varying AS item_number, (whsinfo.warehous_code)::character varying AS site, itemsite.itemsite_active AS active, itemsite.itemsite_wosupply AS wo_supplied_at_site, itemsite.itemsite_createwo AS create_wos, itemsite.itemsite_posupply AS po_supplied_at_site, itemsite.itemsite_createpr AS create_prs, itemsite.itemsite_createsopr AS create_soprs, itemsite.itemsite_createsopo AS create_sopos, itemsite.itemsite_dropship AS dropship, itemsite.itemsite_sold AS sold_from_site, itemsite.itemsite_soldranking AS ranking, CASE WHEN (itemsite.itemsite_costmethod = 'N'::bpchar) THEN 'None'::text WHEN (itemsite.itemsite_costmethod = 'A'::bpchar) THEN 'Average'::text WHEN (itemsite.itemsite_costmethod = 'S'::bpchar) THEN 'Standard'::text WHEN (itemsite.itemsite_costmethod = 'J'::bpchar) THEN 'Job'::text ELSE NULL::text END AS cost_method, CASE WHEN (itemsite.itemsite_controlmethod = 'N'::bpchar) THEN 'None'::text WHEN (itemsite.itemsite_controlmethod = 'R'::bpchar) THEN 'Regular'::text WHEN (itemsite.itemsite_controlmethod = 'S'::bpchar) THEN 'Serial #'::text WHEN (itemsite.itemsite_controlmethod = 'L'::bpchar) THEN 'Lot #'::text ELSE NULL::text END AS control_method, plancode.plancode_code AS planner_code, costcat.costcat_code AS cost_category, itemsite.itemsite_stocked AS stocked, itemsite.itemsite_abcclass AS abc_class, itemsite.itemsite_autoabcclass AS allow_automatic_updates, itemsite.itemsite_cyclecountfreq AS cycl_cnt_freq, itemsite.itemsite_eventfence AS event_fence, itemsite.itemsite_loccntrl AS multiple_location_control, public.formatlocationname(itemsite.itemsite_location_id) AS location, public.formatlocationname(itemsite.itemsite_recvlocation_id) AS receive_location, public.formatlocationname(itemsite.itemsite_issuelocation_id) AS issue_location, itemsite.itemsite_location_dist AS auto_distr_location, itemsite.itemsite_recvlocation_dist AS auto_distr_receive_location, itemsite.itemsite_issuelocation_dist AS auto_distr_issue_location, itemsite.itemsite_location AS user_defined_location, itemsite.itemsite_location_comments AS location_comment, itemsite.itemsite_disallowblankwip AS disallow_blank_wip_locations, itemsite.itemsite_useparams AS enforce_order_parameters, itemsite.itemsite_reorderlevel AS reorder_level, itemsite.itemsite_ordertoqty AS order_up_to, itemsite.itemsite_minordqty AS minimum_order, itemsite.itemsite_maxordqty AS maximum_order, itemsite.itemsite_multordqty AS order_multiple, itemsite.itemsite_useparamsmanual AS enforce_on_manual_orders, CASE WHEN (itemsite.itemsite_planning_type = 'N'::bpchar) THEN 'None'::text WHEN (itemsite.itemsite_planning_type = 'M'::bpchar) THEN 'MRP'::text WHEN (itemsite.itemsite_planning_type = 'S'::bpchar) THEN 'MPS'::text ELSE NULL::text END AS planning_system, itemsite.itemsite_ordergroup AS group_mps_mrp_orders, itemsite.itemsite_ordergroup_first AS first_group, itemsite.itemsite_mps_timefence AS mps_time_fence, itemsite.itemsite_leadtime AS lead_time, itemsite.itemsite_safetystock AS safety_stock, COALESCE((SELECT whsinfo.warehous_code FROM (public.itemsite supplysite JOIN public.whsinfo ON ((whsinfo.warehous_id = supplysite.itemsite_warehous_id))) WHERE (supplysite.itemsite_id = itemsite.itemsite_supply_itemsite_id)), 'None'::text) AS supplied_from_site, itemsite.itemsite_notes AS notes, itemsite.itemsite_perishable AS perishable, itemsite.itemsite_warrpurc AS require_warranty, itemsite.itemsite_autoreg AS auto_register FROM ((((public.itemsite JOIN public.item ON ((item.item_id = itemsite.itemsite_item_id))) JOIN public.plancode ON ((plancode.plancode_id = itemsite.itemsite_plancode_id))) JOIN public.costcat ON ((costcat.costcat_id = itemsite.itemsite_costcat_id))) JOIN public.whsinfo ON ((whsinfo.warehous_id = itemsite.itemsite_warehous_id))); ALTER TABLE itemsite OWNER TO admin; -- -- Name: VIEW itemsite; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW itemsite IS 'Item Site'; -- -- Name: itemsitecomment; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW itemsitecomment AS SELECT (item.item_number)::character varying AS item_number, (whsinfo.warehous_code)::character varying AS site, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.itemsite, public.item, public.whsinfo, public.cmnttype, public.comment WHERE ((itemsite.itemsite_item_id = item.item_id) AND ((((itemsite.itemsite_warehous_id = whsinfo.warehous_id) AND (comment.comment_source = 'IS'::text)) AND (comment.comment_source_id = itemsite.itemsite_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id))); ALTER TABLE itemsitecomment OWNER TO admin; -- -- Name: VIEW itemsitecomment; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW itemsitecomment IS 'Item Site Comments'; SET search_path = public, pg_catalog; -- -- Name: contrct; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE contrct ( contrct_id integer NOT NULL, contrct_number text NOT NULL, contrct_vend_id integer NOT NULL, contrct_descrip text, contrct_effective date NOT NULL, contrct_expires date NOT NULL, contrct_note text ); ALTER TABLE contrct OWNER TO admin; -- -- Name: TABLE contrct; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE contrct IS 'Grouping of Item Sources for a Vendor with common effective and expiration dates.'; -- -- Name: COLUMN contrct.contrct_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN contrct.contrct_id IS 'Sequence identifier for contract.'; -- -- Name: COLUMN contrct.contrct_number; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN contrct.contrct_number IS 'User defined identifier for contract.'; -- -- Name: COLUMN contrct.contrct_vend_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN contrct.contrct_vend_id IS 'Vendor associated with contract.'; -- -- Name: COLUMN contrct.contrct_descrip; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN contrct.contrct_descrip IS 'Description for contract.'; -- -- Name: COLUMN contrct.contrct_effective; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN contrct.contrct_effective IS 'Effective date for contract. Constraint for overlap.'; -- -- Name: COLUMN contrct.contrct_expires; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN contrct.contrct_expires IS 'Expiration date for contract. Constraint for overlap.'; -- -- Name: COLUMN contrct.contrct_note; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN contrct.contrct_note IS 'Notes for contract.'; -- -- Name: itemsrc; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE itemsrc ( itemsrc_id integer DEFAULT nextval(('"itemsrc_itemsrc_id_seq"'::text)::regclass) NOT NULL, itemsrc_item_id integer NOT NULL, itemsrc_vend_id integer NOT NULL, itemsrc_vend_item_number text, itemsrc_vend_item_descrip text, itemsrc_comments text, itemsrc_vend_uom text NOT NULL, itemsrc_invvendoruomratio numeric(20,10) NOT NULL, itemsrc_minordqty numeric(18,6) NOT NULL, itemsrc_multordqty numeric(18,6) NOT NULL, itemsrc_leadtime integer NOT NULL, itemsrc_ranking integer NOT NULL, itemsrc_active boolean NOT NULL, itemsrc_manuf_name text DEFAULT ''::text NOT NULL, itemsrc_manuf_item_number text DEFAULT ''::text NOT NULL, itemsrc_manuf_item_descrip text, itemsrc_default boolean, itemsrc_upccode text, itemsrc_effective date DEFAULT startoftime() NOT NULL, itemsrc_expires date DEFAULT endoftime() NOT NULL, itemsrc_contrct_id integer, itemsrc_contrct_max numeric(18,6) DEFAULT 0.0 NOT NULL, itemsrc_contrct_min numeric(18,6) DEFAULT 0.0 NOT NULL ); ALTER TABLE itemsrc OWNER TO admin; -- -- Name: TABLE itemsrc; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE itemsrc IS 'Item Source information'; -- -- Name: COLUMN itemsrc.itemsrc_effective; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN itemsrc.itemsrc_effective IS 'Effective date for item source. Constraint for overlap.'; -- -- Name: COLUMN itemsrc.itemsrc_expires; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN itemsrc.itemsrc_expires IS 'Expiration date for item source. Constraint for overlap.'; -- -- Name: COLUMN itemsrc.itemsrc_contrct_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN itemsrc.itemsrc_contrct_id IS 'Associated contract for item source. Inherits effective, expiration dates.'; SET search_path = api, pg_catalog; -- -- Name: itemsource; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW itemsource AS SELECT (item.item_number)::character varying AS item_number, (vendinfo.vend_number)::character varying AS vendor, itemsrc.itemsrc_vend_item_number AS vendor_item_number, itemsrc.itemsrc_active AS active, itemsrc.itemsrc_default, itemsrc.itemsrc_vend_uom AS vendor_uom, itemsrc.itemsrc_invvendoruomratio AS inventory_vendor_uom_ratio, itemsrc.itemsrc_minordqty AS minimum_order, itemsrc.itemsrc_multordqty AS order_multiple, itemsrc.itemsrc_ranking AS vendor_ranking, itemsrc.itemsrc_leadtime AS lead_time, itemsrc.itemsrc_comments AS notes, itemsrc.itemsrc_vend_item_descrip AS vendor_description, itemsrc.itemsrc_manuf_name AS manufacturer_name, itemsrc.itemsrc_manuf_item_number AS manufacturer_item_number, itemsrc.itemsrc_manuf_item_descrip AS manufacturer_description, itemsrc.itemsrc_upccode AS bar_code, contrct.contrct_number AS contract_number, itemsrc.itemsrc_effective AS effective_date, itemsrc.itemsrc_expires AS expires_date FROM (((public.itemsrc LEFT JOIN public.item ON ((itemsrc.itemsrc_item_id = item.item_id))) LEFT JOIN public.vendinfo ON ((itemsrc.itemsrc_vend_id = vendinfo.vend_id))) LEFT JOIN public.contrct ON ((itemsrc.itemsrc_contrct_id = contrct.contrct_id))) ORDER BY (item.item_number)::character varying(100), (vendinfo.vend_number)::character varying(100); ALTER TABLE itemsource OWNER TO admin; -- -- Name: VIEW itemsource; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW itemsource IS 'Item Source'; SET search_path = public, pg_catalog; -- -- Name: itemsrcp; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE itemsrcp ( itemsrcp_id integer DEFAULT nextval(('itemsrcp_itemsrcp_id_seq'::text)::regclass) NOT NULL, itemsrcp_itemsrc_id integer NOT NULL, itemsrcp_qtybreak numeric(18,6) NOT NULL, itemsrcp_price numeric(16,6), itemsrcp_updated date, itemsrcp_curr_id integer DEFAULT basecurrid() NOT NULL, itemsrcp_dropship boolean DEFAULT false NOT NULL, itemsrcp_warehous_id integer DEFAULT (-1) NOT NULL, itemsrcp_type character(1) NOT NULL, itemsrcp_discntprcnt numeric(16,6), itemsrcp_fixedamtdiscount numeric(16,6), CONSTRAINT valid_itemsrcp_type CHECK ((itemsrcp_type = ANY (ARRAY['N'::bpchar, 'D'::bpchar]))) ); ALTER TABLE itemsrcp OWNER TO admin; -- -- Name: TABLE itemsrcp; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE itemsrcp IS 'Item Source Price information'; -- -- Name: COLUMN itemsrcp.itemsrcp_dropship; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN itemsrcp.itemsrcp_dropship IS 'Used to determine if item source price applies only to drop ship purchase orders.'; -- -- Name: COLUMN itemsrcp.itemsrcp_warehous_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN itemsrcp.itemsrcp_warehous_id IS 'Used to determine if item source price applies only to specific site on purchase orders.'; -- -- Name: COLUMN itemsrcp.itemsrcp_type; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN itemsrcp.itemsrcp_type IS 'Pricing type for item source price. Valid values are N-nominal and D-discount.'; -- -- Name: COLUMN itemsrcp.itemsrcp_discntprcnt; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN itemsrcp.itemsrcp_discntprcnt IS 'Discount percent for item source price.'; -- -- Name: COLUMN itemsrcp.itemsrcp_fixedamtdiscount; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN itemsrcp.itemsrcp_fixedamtdiscount IS 'Fixed amount discount for item source price.'; SET search_path = api, pg_catalog; -- -- Name: itemsourceprice; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW itemsourceprice AS SELECT (item.item_number)::character varying AS item_number, (vendinfo.vend_number)::character varying AS vendor, itemsrcp.itemsrcp_qtybreak AS qty_break, CASE WHEN (itemsrcp.itemsrcp_type = 'N'::bpchar) THEN 'Nominal'::text ELSE 'Discount'::text END AS pricing_type, CASE WHEN (itemsrcp.itemsrcp_warehous_id = (-1)) THEN 'All'::text ELSE whsinfo.warehous_code END AS pricing_site, itemsrcp.itemsrcp_dropship AS dropship_only, itemsrcp.itemsrcp_price AS price_per_unit, curr_symbol.curr_abbr AS currency, (itemsrcp.itemsrcp_discntprcnt * 100.0) AS discount_percent, itemsrcp.itemsrcp_fixedamtdiscount AS discount_fixed_amount FROM (((((public.itemsrcp LEFT JOIN public.itemsrc ON ((itemsrc.itemsrc_id = itemsrcp.itemsrcp_itemsrc_id))) LEFT JOIN public.item ON ((itemsrc.itemsrc_item_id = item.item_id))) LEFT JOIN public.vendinfo ON ((itemsrc.itemsrc_vend_id = vendinfo.vend_id))) LEFT JOIN public.curr_symbol ON ((itemsrcp.itemsrcp_curr_id = curr_symbol.curr_id))) LEFT JOIN public.whsinfo ON ((itemsrcp.itemsrcp_warehous_id = whsinfo.warehous_id))) ORDER BY (item.item_number)::character varying(100), (vendinfo.vend_number)::character varying(100); ALTER TABLE itemsourceprice OWNER TO admin; -- -- Name: VIEW itemsourceprice; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW itemsourceprice IS 'Item Source Price'; SET search_path = public, pg_catalog; -- -- Name: itemsub; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE itemsub ( itemsub_id integer DEFAULT nextval(('itemsub_itemsub_id_seq'::text)::regclass) NOT NULL, itemsub_parent_item_id integer NOT NULL, itemsub_sub_item_id integer NOT NULL, itemsub_uomratio numeric(20,10) NOT NULL, itemsub_rank integer NOT NULL ); ALTER TABLE itemsub OWNER TO admin; -- -- Name: TABLE itemsub; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE itemsub IS 'Item Substitutes information'; SET search_path = api, pg_catalog; -- -- Name: itemsubstitute; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW itemsubstitute AS SELECT (p.item_number)::character varying AS root_item_number, (s.item_number)::character varying AS substitute_item_number, itemsub.itemsub_uomratio AS sub_parent_uom_ratio, itemsub.itemsub_rank AS ranking FROM public.item p, public.item s, public.itemsub WHERE ((p.item_id = itemsub.itemsub_parent_item_id) AND (s.item_id = itemsub.itemsub_sub_item_id)); ALTER TABLE itemsubstitute OWNER TO admin; -- -- Name: VIEW itemsubstitute; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW itemsubstitute IS 'Item Substitute'; SET search_path = public, pg_catalog; -- -- Name: itemtax; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE itemtax ( itemtax_id integer NOT NULL, itemtax_item_id integer NOT NULL, itemtax_taxtype_id integer NOT NULL, itemtax_taxzone_id integer ); ALTER TABLE itemtax OWNER TO admin; -- -- Name: TABLE itemtax; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE itemtax IS 'This table associates tax types in a specified tax authority for the given item.'; SET search_path = api, pg_catalog; -- -- Name: itemtaxtype; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW itemtaxtype AS SELECT (item.item_number)::character varying AS item_number, CASE WHEN (taxzone.taxzone_id IS NULL) THEN 'Any'::character varying ELSE (taxzone.taxzone_code)::character varying END AS tax_zone, taxtype.taxtype_name AS tax_type FROM public.item, (public.itemtax LEFT JOIN public.taxzone ON ((itemtax.itemtax_taxzone_id = taxzone.taxzone_id))), public.taxtype WHERE ((item.item_id = itemtax.itemtax_item_id) AND (itemtax.itemtax_taxtype_id = taxtype.taxtype_id)); ALTER TABLE itemtaxtype OWNER TO admin; -- -- Name: VIEW itemtaxtype; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW itemtaxtype IS 'Item Tax Type'; SET search_path = public, pg_catalog; -- -- Name: itemuomconv; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE itemuomconv ( itemuomconv_id integer NOT NULL, itemuomconv_item_id integer NOT NULL, itemuomconv_from_uom_id integer NOT NULL, itemuomconv_from_value numeric(20,10) NOT NULL, itemuomconv_to_uom_id integer NOT NULL, itemuomconv_to_value numeric(20,10) NOT NULL, itemuomconv_fractional boolean DEFAULT false NOT NULL, itemuomconv_active boolean DEFAULT true NOT NULL, CONSTRAINT itemuomconv_uom CHECK ((itemuomconv_from_uom_id <> itemuomconv_to_uom_id)) ); ALTER TABLE itemuomconv OWNER TO admin; -- -- Name: TABLE itemuomconv; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE itemuomconv IS 'UOM conversion information. From Unit to To Unit with a value per.'; -- -- Name: COLUMN itemuomconv.itemuomconv_active; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN itemuomconv.itemuomconv_active IS 'Item UOM conversion active/inactive'; SET search_path = api, pg_catalog; -- -- Name: itemuomconversion; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW itemuomconversion AS SELECT (item.item_number)::character varying AS item_number, (f.uom_name)::character varying AS uom, itemuomconv.itemuomconv_from_value AS uom_value, p.uom_name AS per_uom, itemuomconv.itemuomconv_to_value AS per_uom_value, itemuomconv.itemuomconv_fractional AS fractional, public.fetchitemuomconvtypes(itemuomconv.itemuomconv_id) AS selected_types FROM public.item, public.itemuomconv, public.uom f, public.uom p WHERE (((item.item_id = itemuomconv.itemuomconv_item_id) AND (itemuomconv.itemuomconv_from_uom_id = f.uom_id)) AND (itemuomconv.itemuomconv_to_uom_id = p.uom_id)); ALTER TABLE itemuomconversion OWNER TO admin; -- -- Name: VIEW itemuomconversion; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW itemuomconversion IS 'Item Unit of Measure Conversion'; SET search_path = public, pg_catalog; -- -- Name: gltrans; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE gltrans ( gltrans_id integer DEFAULT nextval(('"gltrans_gltrans_id_seq"'::text)::regclass) NOT NULL, gltrans_exported boolean, gltrans_created timestamp with time zone, gltrans_date date NOT NULL, gltrans_sequence integer, gltrans_accnt_id integer NOT NULL, gltrans_source text, gltrans_docnumber text, gltrans_misc_id integer, gltrans_amount numeric(20,2) NOT NULL, gltrans_notes text, gltrans_journalnumber integer, gltrans_posted boolean NOT NULL, gltrans_doctype text, gltrans_rec boolean DEFAULT false NOT NULL, gltrans_username text DEFAULT geteffectivextuser() NOT NULL, gltrans_deleted boolean DEFAULT false ); ALTER TABLE gltrans OWNER TO admin; -- -- Name: TABLE gltrans; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE gltrans IS 'General Ledger (G/L) transaction information'; SET search_path = api, pg_catalog; -- -- Name: journalentry; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW journalentry AS SELECT curr_symbol.curr_abbr AS currency, c.gltrans_amount AS amount, c.gltrans_date AS dist_date, c.gltrans_docnumber AS doc_number, public.formatglaccount(da.accnt_id) AS debit, public.formatglaccount(ca.accnt_id) AS credit, c.gltrans_notes AS notes FROM public.gltrans d, public.gltrans c, public.accnt da, public.accnt ca, public.curr_symbol WHERE ((((((((d.gltrans_sequence = c.gltrans_sequence) AND (d.gltrans_accnt_id = da.accnt_id)) AND (c.gltrans_accnt_id = ca.accnt_id)) AND (d.gltrans_amount < (0)::numeric)) AND (c.gltrans_amount > (0)::numeric)) AND (d.gltrans_doctype = 'JE'::text)) AND (c.gltrans_doctype = 'JE'::text)) AND (curr_symbol.curr_id = public.basecurrid())) ORDER BY d.gltrans_date DESC; ALTER TABLE journalentry OWNER TO admin; -- -- Name: VIEW journalentry; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW journalentry IS 'Journal Entry'; SET search_path = public, pg_catalog; -- -- Name: location; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE location ( location_id integer DEFAULT nextval(('location_location_id_seq'::text)::regclass) NOT NULL, location_warehous_id integer NOT NULL, location_name text NOT NULL, location_descrip text, location_restrict boolean, location_netable boolean, location_whsezone_id integer, location_aisle text, location_rack text, location_bin text, location_formatname text, location_usable boolean ); ALTER TABLE location OWNER TO admin; -- -- Name: TABLE location; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE location IS 'Warehouse Location information'; -- -- Name: whsezone; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE whsezone ( whsezone_id integer NOT NULL, whsezone_warehous_id integer NOT NULL, whsezone_name text NOT NULL, whsezone_descrip text ); ALTER TABLE whsezone OWNER TO admin; -- -- Name: TABLE whsezone; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE whsezone IS 'Warehouse Zone information'; SET search_path = api, pg_catalog; -- -- Name: location; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW location AS SELECT (whsinfo.warehous_code)::character varying AS site, (location.location_aisle)::character varying AS aisle, (location.location_rack)::character varying AS rack, (location.location_bin)::character varying AS bin, (location.location_name)::character varying AS location, whsezone.whsezone_name AS zone, location.location_netable AS netable, location.location_usable AS usable, location.location_restrict AS restricted, location.location_descrip AS description FROM ((public.location LEFT JOIN public.whsinfo ON ((whsinfo.warehous_id = location.location_warehous_id))) LEFT JOIN public.whsezone ON ((whsezone.whsezone_id = location.location_whsezone_id))); ALTER TABLE location OWNER TO admin; -- -- Name: VIEW location; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW location IS 'Location'; -- -- Name: misccounttag; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW misccounttag AS SELECT 'This view is for inserts only'::text AS site, 'This view is for inserts only'::text AS item_number, (0)::numeric AS quantity, 'This view is for inserts only'::text AS comment; ALTER TABLE misccounttag OWNER TO admin; -- -- Name: VIEW misccounttag; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW misccounttag IS 'Miscellaneous Count Tag'; -- -- Name: pricingschedule; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW pricingschedule AS SELECT (ipshead.ipshead_name)::character varying AS name, ipshead.ipshead_descrip AS description, public.formatdate(ipshead.ipshead_effective, 'Always'::text) AS effective, public.formatdate(ipshead.ipshead_expires, 'Never'::text) AS expires, curr_symbol.curr_abbr AS currency FROM public.ipshead, public.curr_symbol WHERE (curr_symbol.curr_id = ipshead.ipshead_curr_id); ALTER TABLE pricingschedule OWNER TO admin; -- -- Name: VIEW pricingschedule; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW pricingschedule IS 'Pricing Schedule'; SET search_path = public, pg_catalog; -- -- Name: ipsass; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE ipsass ( ipsass_id integer NOT NULL, ipsass_ipshead_id integer NOT NULL, ipsass_cust_id integer, ipsass_custtype_id integer, ipsass_custtype_pattern text, ipsass_shipto_id integer DEFAULT (-1), ipsass_shipto_pattern text ); ALTER TABLE ipsass OWNER TO admin; -- -- Name: TABLE ipsass; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE ipsass IS 'Pricing Schedule assignment information'; SET search_path = api, pg_catalog; -- -- Name: pricingscheduleassign; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW pricingscheduleassign AS SELECT (COALESCE(custinfo.cust_number, 'Any'::text))::character varying AS customer_number, (COALESCE(shiptoinfo.shipto_num, 'Any'::text))::character varying AS customer_shipto, (COALESCE(ipsass.ipsass_shipto_pattern, 'N/A'::text))::character varying AS customer_shipto_pattern, (COALESCE(custtype.custtype_code, 'N/A'::text))::character varying AS customer_type, (COALESCE(ipsass.ipsass_custtype_pattern, 'N/A'::text))::character varying AS customer_type_pattern, (ipshead.ipshead_name)::character varying AS pricing_schedule FROM ((((public.ipshead JOIN public.ipsass ON ((ipshead.ipshead_id = ipsass.ipsass_ipshead_id))) LEFT JOIN public.custinfo ON ((ipsass.ipsass_cust_id = custinfo.cust_id))) LEFT JOIN public.custtype ON ((ipsass.ipsass_custtype_id = custtype.custtype_id))) LEFT JOIN public.shiptoinfo ON ((ipsass.ipsass_shipto_id = shiptoinfo.shipto_id))) ORDER BY (COALESCE(custinfo.cust_number, 'Any'::text))::character varying, (COALESCE(shiptoinfo.shipto_num, 'Any'::text))::character varying, (COALESCE(custtype.custtype_code, 'N/A'::text))::character varying, (COALESCE(ipsass.ipsass_custtype_pattern, 'N/A'::text))::character varying, (ipshead.ipshead_name)::character varying; ALTER TABLE pricingscheduleassign OWNER TO admin; -- -- Name: VIEW pricingscheduleassign; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW pricingscheduleassign IS 'Pricing Schedule Assignments'; SET search_path = public, pg_catalog; -- -- Name: ipsiteminfo; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE ipsiteminfo ( ipsitem_id integer DEFAULT nextval(('"ipsitem_ipsitem_id_seq"'::text)::regclass) NOT NULL, ipsitem_ipshead_id integer, ipsitem_item_id integer, ipsitem_qtybreak numeric(18,6) NOT NULL, ipsitem_price numeric(16,4) NOT NULL, ipsitem_qty_uom_id integer, ipsitem_price_uom_id integer, ipsitem_discntprcnt numeric(10,6) DEFAULT 0.00 NOT NULL, ipsitem_fixedamtdiscount numeric(16,4) DEFAULT 0.00 NOT NULL, ipsitem_prodcat_id integer, ipsitem_type character(1) NOT NULL, ipsitem_warehous_id integer, CONSTRAINT valid_ipsitem_type CHECK ((ipsitem_type = ANY (ARRAY['N'::bpchar, 'D'::bpchar, 'M'::bpchar]))) ); ALTER TABLE ipsiteminfo OWNER TO admin; -- -- Name: TABLE ipsiteminfo; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE ipsiteminfo IS 'Pricing Schedule Item information'; -- -- Name: COLUMN ipsiteminfo.ipsitem_prodcat_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ipsiteminfo.ipsitem_prodcat_id IS 'Product category for pricing schedule item.'; -- -- Name: COLUMN ipsiteminfo.ipsitem_type; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ipsiteminfo.ipsitem_type IS 'Pricing type for pricing schedule item. Valid values are N-nominal, D-discount, and M-markup'; -- -- Name: COLUMN ipsiteminfo.ipsitem_warehous_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ipsiteminfo.ipsitem_warehous_id IS 'Site for pricing schedule item which enables pricing by site.'; SET search_path = api, pg_catalog; -- -- Name: pricingscheduleitem; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW pricingscheduleitem AS SELECT (ipshead.ipshead_name)::character varying AS pricing_schedule, CASE WHEN (COALESCE(ipsiteminfo.ipsitem_item_id, (-1)) > 0) THEN 'Item'::character varying ELSE 'Product Category'::character varying END AS type, (COALESCE(item.item_number, ''::text))::character varying AS item_number, (COALESCE(prodcat.prodcat_code, ''::text))::character varying AS product_category, ipsiteminfo.ipsitem_qtybreak AS qty_break, (qtyuom.uom_name)::character varying AS qty_uom, (priceuom.uom_name)::character varying AS price_uom, ipsiteminfo.ipsitem_price AS price, ipsiteminfo.ipsitem_discntprcnt AS percent, ipsiteminfo.ipsitem_fixedamtdiscount AS fixedamt, CASE WHEN (ipsiteminfo.ipsitem_type = 'N'::bpchar) THEN 'Nominal'::character varying WHEN (ipsiteminfo.ipsitem_type = 'D'::bpchar) THEN 'Discount'::character varying WHEN (ipsiteminfo.ipsitem_type = 'M'::bpchar) THEN 'Markup'::character varying ELSE NULL::character varying END AS pricing_type FROM (((((public.ipsiteminfo JOIN public.ipshead ON ((ipsiteminfo.ipsitem_ipshead_id = ipshead.ipshead_id))) LEFT JOIN public.item ON ((ipsiteminfo.ipsitem_item_id = item.item_id))) LEFT JOIN public.prodcat ON ((ipsiteminfo.ipsitem_prodcat_id = prodcat.prodcat_id))) LEFT JOIN public.uom qtyuom ON ((ipsiteminfo.ipsitem_qty_uom_id = qtyuom.uom_id))) LEFT JOIN public.uom priceuom ON ((ipsiteminfo.ipsitem_price_uom_id = priceuom.uom_id))); ALTER TABLE pricingscheduleitem OWNER TO admin; -- -- Name: VIEW pricingscheduleitem; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW pricingscheduleitem IS 'Pricing Schedule Item'; SET search_path = public, pg_catalog; -- -- Name: ipsitemchar; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE ipsitemchar ( ipsitemchar_id integer NOT NULL, ipsitemchar_ipsitem_id integer NOT NULL, ipsitemchar_char_id integer NOT NULL, ipsitemchar_value text NOT NULL, ipsitemchar_price numeric(16,4) ); ALTER TABLE ipsitemchar OWNER TO admin; -- -- Name: TABLE ipsitemchar; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE ipsitemchar IS 'Item Price Schedule Characteristic Prices.'; SET search_path = api, pg_catalog; -- -- Name: pricingscheduleitemchar; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW pricingscheduleitemchar AS SELECT (ipshead.ipshead_name)::character varying AS pricing_schedule, (item.item_number)::character varying AS item_number, ipsiteminfo.ipsitem_qtybreak AS qty_break, (qtyuom.uom_name)::character varying AS qty_uom, (priceuom.uom_name)::character varying AS price_uom, ("char".char_name)::character varying AS characteristic, (ipsitemchar.ipsitemchar_value)::character varying AS value, ipsitemchar.ipsitemchar_price AS price FROM public.ipshead, public.ipsiteminfo, public.ipsitemchar, public.item, public."char", public.uom qtyuom, public.uom priceuom WHERE ((((((ipshead.ipshead_id = ipsiteminfo.ipsitem_ipshead_id) AND (ipsiteminfo.ipsitem_id = ipsitemchar.ipsitemchar_ipsitem_id)) AND (ipsiteminfo.ipsitem_item_id = item.item_id)) AND (ipsiteminfo.ipsitem_qty_uom_id = qtyuom.uom_id)) AND (ipsiteminfo.ipsitem_price_uom_id = priceuom.uom_id)) AND (ipsitemchar.ipsitemchar_char_id = "char".char_id)); ALTER TABLE pricingscheduleitemchar OWNER TO admin; -- -- Name: VIEW pricingscheduleitemchar; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW pricingscheduleitemchar IS 'Pricing Schedule Item Characteristics'; -- -- Name: project; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW project AS SELECT prj.prj_number AS number, prj.prj_name AS name, prj.prj_descrip AS description, prj.prj_owner_username AS owner, prj.prj_username AS assigned_to, prj.prj_so AS sales_orders, prj.prj_wo AS work_orders, prj.prj_po AS purchase_orders, CASE WHEN (prj.prj_status = 'P'::bpchar) THEN 'Concept'::text WHEN (prj.prj_status = 'O'::bpchar) THEN 'In-Process'::text WHEN (prj.prj_status = 'C'::bpchar) THEN 'Closed'::text ELSE 'Error'::text END AS status, prj.prj_due_date AS due, prj.prj_assigned_date AS assigned, prj.prj_start_date AS started, prj.prj_completed_date AS completed FROM public.prj; ALTER TABLE project OWNER TO admin; -- -- Name: VIEW project; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW project IS 'Project'; -- -- Name: projectcomment; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW projectcomment AS SELECT (prj.prj_number)::character varying AS project_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.prj, public.cmnttype, public.comment WHERE (((comment.comment_source = 'J'::text) AND (comment.comment_source_id = prj.prj_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); ALTER TABLE projectcomment OWNER TO admin; -- -- Name: VIEW projectcomment; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW projectcomment IS 'Project Comment'; SET search_path = public, pg_catalog; -- -- Name: cust_cust_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cust_cust_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE cust_cust_id_seq OWNER TO admin; -- -- Name: prospect; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE prospect ( prospect_id integer DEFAULT nextval('cust_cust_id_seq'::regclass) NOT NULL, prospect_active boolean DEFAULT true NOT NULL, prospect_number text NOT NULL, prospect_name text NOT NULL, prospect_cntct_id integer, prospect_comments text, prospect_created date DEFAULT ('now'::text)::date NOT NULL, prospect_salesrep_id integer, prospect_warehous_id integer, prospect_taxzone_id integer, CONSTRAINT prospect_prospect_number_check CHECK ((prospect_number <> ''::text)) ); ALTER TABLE prospect OWNER TO admin; -- -- Name: TABLE prospect; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE prospect IS 'Prospect Information'; SET search_path = api, pg_catalog; -- -- Name: prospect; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW prospect AS SELECT (prospect.prospect_number)::character varying AS prospect_number, prospect.prospect_name, prospect.prospect_active AS active, salesrep.salesrep_number AS sales_rep, whsinfo.warehous_code AS site_code, taxzone.taxzone_code AS default_tax_zone, prospect.prospect_comments AS notes, cntct.cntct_number AS contact_number, cntct.cntct_honorific AS contact_honorific, cntct.cntct_first_name AS contact_first, cntct.cntct_middle AS contact_middle, cntct.cntct_last_name AS contact_last, cntct.cntct_suffix AS contact_suffix, cntct.cntct_title AS contact_job_title, cntct.cntct_phone AS contact_voice, cntct.cntct_phone2 AS contact_alternate, cntct.cntct_fax AS contact_fax, cntct.cntct_email AS contact_email, cntct.cntct_webaddr AS contact_web, ''::text AS contact_change, addr.addr_number AS contact_address_number, addr.addr_line1 AS contact_address1, addr.addr_line2 AS contact_address2, addr.addr_line3 AS contact_address3, addr.addr_city AS contact_city, addr.addr_state AS contact_state, addr.addr_postalcode AS contact_postalcode, addr.addr_country AS contact_country, ''::text AS contact_address_change FROM (((((public.prospect LEFT JOIN public.cntct ON ((prospect.prospect_cntct_id = cntct.cntct_id))) LEFT JOIN public.addr ON ((cntct.cntct_addr_id = addr.addr_id))) LEFT JOIN public.taxzone ON ((prospect.prospect_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.salesrep ON ((prospect.prospect_salesrep_id = salesrep.salesrep_id))) LEFT JOIN public.whsinfo ON ((prospect.prospect_warehous_id = whsinfo.warehous_id))); ALTER TABLE prospect OWNER TO admin; -- -- Name: VIEW prospect; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW prospect IS 'Prospect'; SET search_path = public, pg_catalog; -- -- Name: expcat; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE expcat ( expcat_id integer NOT NULL, expcat_code text NOT NULL, expcat_descrip text, expcat_exp_accnt_id integer, expcat_liability_accnt_id integer, expcat_active boolean, expcat_purchprice_accnt_id integer, expcat_freight_accnt_id integer, CONSTRAINT expcat_expcat_code_check CHECK ((expcat_code <> ''::text)) ); ALTER TABLE expcat OWNER TO admin; -- -- Name: TABLE expcat; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE expcat IS 'Expense Category information'; -- -- Name: womatl; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE womatl ( womatl_id integer DEFAULT nextval(('womatl_womatl_id_seq'::text)::regclass) NOT NULL, womatl_wo_id integer, womatl_itemsite_id integer, womatl_qtyper numeric(20,8) NOT NULL, womatl_scrap numeric(8,4) NOT NULL, womatl_qtyreq numeric(18,6) NOT NULL, womatl_qtyiss numeric(18,6) NOT NULL, womatl_qtywipscrap numeric(18,6) NOT NULL, womatl_lastissue date, womatl_lastreturn date, womatl_cost numeric(16,6), womatl_picklist boolean, womatl_status character(1), womatl_imported boolean DEFAULT false, womatl_createwo boolean, womatl_issuemethod character(1), womatl_wooper_id integer, womatl_bomitem_id integer, womatl_duedate date, womatl_schedatwooper boolean, womatl_uom_id integer NOT NULL, womatl_notes text, womatl_ref text, womatl_scrapvalue numeric(16,6) DEFAULT 0, womatl_qtyfxd numeric(20,8) DEFAULT 0 NOT NULL, womatl_issuewo boolean DEFAULT false NOT NULL, womatl_price numeric(16,6) DEFAULT 0 NOT NULL ); ALTER TABLE womatl OWNER TO admin; -- -- Name: TABLE womatl; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE womatl IS 'Work Order Material Requirements information'; -- -- Name: COLUMN womatl.womatl_qtyfxd; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN womatl.womatl_qtyfxd IS 'The fixed quantity required'; SET search_path = api, pg_catalog; -- -- Name: purchaseline; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW purchaseline AS SELECT (pohead.pohead_number)::character varying AS order_number, poitem.poitem_linenumber AS line_number, item.item_number, whsinfo.warehous_code AS site, expcat.expcat_code AS expense_category, poitem.poitem_qty_ordered AS qty_ordered, poitem.poitem_unitprice AS unit_price, poitem.poitem_freight AS freight, poitem.poitem_duedate AS due_date, prj.prj_number AS project_number, poitem.poitem_vend_item_number AS vend_item_number, poitem.poitem_vend_item_descrip AS vendor_description, poitem.poitem_manuf_name AS manufacturer_name, poitem.poitem_manuf_item_number AS manufacturer_item_number, poitem.poitem_manuf_item_descrip AS manufacturer_description, poitem.poitem_comments AS notes, public.formatrevnumber('BOM'::text, poitem.poitem_bom_rev_id) AS bill_of_materials_revision, public.formatrevnumber('BOO'::text, poitem.poitem_boo_rev_id) AS bill_of_operations_revision, public.formatsonumber(coitem.coitem_id) AS sales_order_number, public.formatwonumber(womatl.womatl_wo_id) AS work_order_number FROM ((((((((public.pohead JOIN public.poitem ON ((pohead.pohead_id = poitem.poitem_pohead_id))) LEFT JOIN public.prj ON ((poitem.poitem_prj_id = prj.prj_id))) LEFT JOIN public.expcat ON ((poitem.poitem_expcat_id = expcat.expcat_id))) LEFT JOIN public.itemsite ON ((poitem.poitem_itemsite_id = itemsite.itemsite_id))) LEFT JOIN public.item ON ((itemsite.itemsite_item_id = item.item_id))) LEFT JOIN public.whsinfo ON ((itemsite.itemsite_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.coitem ON (((coitem.coitem_id = poitem.poitem_order_id) AND (poitem.poitem_order_type = 'S'::bpchar)))) LEFT JOIN public.womatl ON (((womatl.womatl_id = poitem.poitem_order_id) AND (poitem.poitem_order_type = 'W'::bpchar)))) ORDER BY pohead.pohead_number, poitem.poitem_linenumber; ALTER TABLE purchaseline OWNER TO admin; -- -- Name: VIEW purchaseline; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW purchaseline IS 'Purchase Order Line'; -- -- Name: purchaselinechar; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW purchaselinechar AS SELECT (data.order_number)::character varying AS order_number, data.line_number, data.characteristic, COALESCE(pi.charass_value, i3.charass_value) AS value FROM (((((SELECT DISTINCT "char".char_id, poitem.poitem_id, poitem.poitem_itemsite_id, pohead.pohead_number AS order_number, poitem.poitem_linenumber AS line_number, "char".char_name AS characteristic FROM public.pohead, public.poitem, public.itemsite, public.item, public.charass, public."char" WHERE ((((((pohead.pohead_id = poitem.poitem_pohead_id) AND (poitem.poitem_itemsite_id = itemsite.itemsite_id)) AND (itemsite.itemsite_item_id = item.item_id)) AND (charass.charass_char_id = "char".char_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id))) data LEFT JOIN public.charass pi ON ((((data.poitem_id = pi.charass_target_id) AND ('PI'::text = pi.charass_target_type)) AND (pi.charass_char_id = data.char_id)))) LEFT JOIN public.itemsite i1 ON ((data.poitem_itemsite_id = i1.itemsite_id))) LEFT JOIN public.item i2 ON ((i1.itemsite_item_id = i2.item_id))) LEFT JOIN public.charass i3 ON (((((i2.item_id = i3.charass_target_id) AND ('I'::text = i3.charass_target_type)) AND (i3.charass_char_id = data.char_id)) AND i3.charass_default))) ORDER BY (data.order_number)::character varying, data.line_number, data.characteristic; ALTER TABLE purchaselinechar OWNER TO admin; -- -- Name: VIEW purchaselinechar; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW purchaselinechar IS 'Purchase Order Line Item Characteristic'; -- -- Name: purchaselinecomment; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW purchaselinecomment AS SELECT (pohead.pohead_number)::character varying AS order_number, poitem.poitem_linenumber AS line_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.pohead, public.poitem, public.cmnttype, public.comment WHERE ((((pohead.pohead_id = poitem.poitem_pohead_id) AND (comment.comment_source = 'PI'::text)) AND (comment.comment_source_id = poitem.poitem_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)) ORDER BY pohead.pohead_number, poitem.poitem_linenumber, comment.comment_date DESC; ALTER TABLE purchaselinecomment OWNER TO admin; -- -- Name: VIEW purchaselinecomment; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW purchaselinecomment IS 'Purchase Order Line Item Comment'; SET search_path = public, pg_catalog; -- -- Name: tax; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE tax ( tax_id integer DEFAULT nextval(('"tax_tax_id_seq"'::text)::regclass) NOT NULL, tax_code text NOT NULL, tax_descrip text, tax_sales_accnt_id integer, tax_taxclass_id integer, tax_taxauth_id integer, tax_basis_tax_id integer, tax_dist_accnt_id integer, CONSTRAINT tax_tax_code_check CHECK ((tax_code <> ''::text)) ); ALTER TABLE tax OWNER TO admin; -- -- Name: TABLE tax; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE tax IS 'Tax information'; -- -- Name: COLUMN tax.tax_sales_accnt_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN tax.tax_sales_accnt_id IS 'Deprecated column - DO NOT USE'; -- -- Name: vendaddrinfo; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE vendaddrinfo ( vendaddr_id integer DEFAULT nextval(('vendaddr_vendaddr_id_seq'::text)::regclass) NOT NULL, vendaddr_vend_id integer, vendaddr_code text, vendaddr_name text, vendaddr_comments text, vendaddr_cntct_id integer, vendaddr_addr_id integer, vendaddr_taxzone_id integer ); ALTER TABLE vendaddrinfo OWNER TO admin; -- -- Name: TABLE vendaddrinfo; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE vendaddrinfo IS 'Vendor Address information'; SET search_path = api, pg_catalog; -- -- Name: purchaseorder; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW purchaseorder AS SELECT (pohead.pohead_number)::character varying AS order_number, pohead.pohead_orderdate AS order_date, terms.terms_code AS terms, taxzone.taxzone_code AS tax_zone, whsinfo.warehous_code AS receiving_site, pohead.pohead_agent_username AS purchasing_agent, vendinfo.vend_number AS vendor_number, COALESCE(ua.vendaddr_code, 'MAIN'::text) AS alt_address, pohead.pohead_fob AS fob, pohead.pohead_shipvia AS ship_via, curr_symbol.curr_abbr AS currency, (SELECT COALESCE(sum(data.tax), 0.00) AS tax FROM (SELECT round(sum(calculatetaxdetailsummary.taxdetail_tax), 2) AS tax FROM (public.tax JOIN public.calculatetaxdetailsummary('PO'::text, pohead.pohead_id, 'T'::text) calculatetaxdetailsummary(taxdetail_tax_id, taxdetail_tax_code, taxdetail_tax_descrip, taxdetail_tax_basis_tax_id, taxdetail_taxrate_percent, taxdetail_taxrate_amount, taxdetail_level, taxdetail_taxclass_id, taxdetail_taxclass_code, taxdetail_taxclass_sequence, taxdetail_tax, taxdetail_curr_id, taxdetail_curr_abbr) ON ((calculatetaxdetailsummary.taxdetail_tax_id = tax.tax_id))) GROUP BY tax.tax_id) data) AS tax, pohead.pohead_freight AS freight, pohead.pohead_comments AS notes, pohead.pohead_dropship AS dropship, vc.cntct_number AS vend_contact_number, pohead.pohead_vend_cntct_honorific AS vend_cntct_honorific, pohead.pohead_vend_cntct_first_name AS vend_cntct_first_name, pohead.pohead_vend_cntct_middle AS vend_cntct_middle, pohead.pohead_vend_cntct_last_name AS vend_cntct_last_name, pohead.pohead_vend_cntct_suffix AS vend_cntct_suffix, pohead.pohead_vend_cntct_phone AS vend_cntct_phone, pohead.pohead_vend_cntct_title AS vend_cntct_title, pohead.pohead_vend_cntct_fax AS vend_cntct_fax, pohead.pohead_vend_cntct_email AS vend_cntct_email, pohead.pohead_vendaddress1 AS vendaddress1, pohead.pohead_vendaddress2 AS vendaddress2, pohead.pohead_vendaddress3 AS vendaddress3, pohead.pohead_vendcity AS vendcity, pohead.pohead_vendstate AS vendstate, pohead.pohead_vendzipcode AS vendzipcode, pohead.pohead_vendcountry AS vendcountry, sc.cntct_number AS shipto_contact_number, pohead.pohead_shipto_cntct_honorific AS shipto_cntct_honorific, pohead.pohead_shipto_cntct_first_name AS shipto_cntct_first_name, pohead.pohead_shipto_cntct_middle AS shipto_cntct_middle, pohead.pohead_shipto_cntct_last_name AS shipto_cntct_last_name, pohead.pohead_shipto_cntct_suffix AS shipto_cntct_suffix, pohead.pohead_shipto_cntct_phone AS shipto_cntct_phone, pohead.pohead_shipto_cntct_title AS shipto_cntct_title, pohead.pohead_shipto_cntct_fax AS shipto_cntct_fax, pohead.pohead_shipto_cntct_email AS shipto_cntct_email, addr.addr_number AS shiptoaddress_number, pohead.pohead_shiptoaddress1 AS shiptoaddress1, pohead.pohead_shiptoaddress2 AS shiptoaddress2, pohead.pohead_shiptoaddress3 AS shiptoaddress3, pohead.pohead_shiptocity AS shiptocity, pohead.pohead_shiptostate AS shiptostate, pohead.pohead_shiptozipcode AS shiptozipcode, pohead.pohead_shiptocountry AS shiptocountry, cohead.cohead_number AS sales_order_number FROM ((((((((((public.pohead LEFT JOIN public.cntct vc ON ((pohead.pohead_vend_cntct_id = vc.cntct_id))) LEFT JOIN public.cntct sc ON ((pohead.pohead_shipto_cntct_id = sc.cntct_id))) LEFT JOIN public.addr ON ((pohead.pohead_shiptoaddress_id = addr.addr_id))) LEFT JOIN public.terms ON ((pohead.pohead_terms_id = terms.terms_id))) LEFT JOIN public.taxzone ON ((pohead.pohead_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.whsinfo ON ((pohead.pohead_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.vendaddrinfo ua ON ((pohead.pohead_vendaddr_id = ua.vendaddr_id))) LEFT JOIN public.cohead ON ((pohead.pohead_cohead_id = cohead.cohead_id))) JOIN public.vendinfo ON ((pohead.pohead_vend_id = vendinfo.vend_id))) JOIN public.curr_symbol ON ((pohead.pohead_curr_id = curr_symbol.curr_id))) ORDER BY pohead.pohead_number; ALTER TABLE purchaseorder OWNER TO admin; -- -- Name: VIEW purchaseorder; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW purchaseorder IS 'Purchase Order'; -- -- Name: purchaseordercomment; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW purchaseordercomment AS SELECT (pohead.pohead_number)::character varying AS order_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.pohead, public.cmnttype, public.comment WHERE (((comment.comment_source = 'P'::text) AND (comment.comment_source_id = pohead.pohead_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); ALTER TABLE purchaseordercomment OWNER TO admin; -- -- Name: VIEW purchaseordercomment; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW purchaseordercomment IS 'Purchase Order Comment'; SET search_path = public, pg_catalog; -- -- Name: quhead; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE quhead ( quhead_id integer DEFAULT nextval(('"quhead_quhead_id_seq"'::text)::regclass) NOT NULL, quhead_number text NOT NULL, quhead_cust_id integer NOT NULL, quhead_quotedate date, quhead_shipto_id integer, quhead_shiptoname text, quhead_shiptoaddress1 text, quhead_shiptoaddress2 text, quhead_shiptoaddress3 text, quhead_shiptocity text, quhead_shiptostate text, quhead_shiptozipcode text, quhead_shiptophone text, quhead_salesrep_id integer, quhead_terms_id integer, quhead_freight numeric(16,4), quhead_ordercomments text, quhead_shipcomments text, quhead_billtoname text, quhead_billtoaddress1 text, quhead_billtoaddress2 text, quhead_billtoaddress3 text, quhead_billtocity text, quhead_billtostate text, quhead_billtozip text, quhead_commission numeric(16,4), quhead_custponumber text, quhead_fob text, quhead_shipvia text, quhead_warehous_id integer, quhead_packdate date, quhead_prj_id integer, quhead_misc numeric(16,4) DEFAULT 0 NOT NULL, quhead_misc_accnt_id integer, quhead_misc_descrip text, quhead_billtocountry text, quhead_shiptocountry text, quhead_curr_id integer DEFAULT basecurrid(), quhead_imported boolean DEFAULT false, quhead_expire date, quhead_calcfreight boolean DEFAULT false NOT NULL, quhead_shipto_cntct_id integer, quhead_shipto_cntct_honorific text, quhead_shipto_cntct_first_name text, quhead_shipto_cntct_middle text, quhead_shipto_cntct_last_name text, quhead_shipto_cntct_suffix text, quhead_shipto_cntct_phone text, quhead_shipto_cntct_title text, quhead_shipto_cntct_fax text, quhead_shipto_cntct_email text, quhead_billto_cntct_id integer, quhead_billto_cntct_honorific text, quhead_billto_cntct_first_name text, quhead_billto_cntct_middle text, quhead_billto_cntct_last_name text, quhead_billto_cntct_suffix text, quhead_billto_cntct_phone text, quhead_billto_cntct_title text, quhead_billto_cntct_fax text, quhead_billto_cntct_email text, quhead_taxzone_id integer, quhead_taxtype_id integer, quhead_ophead_id integer, quhead_status text, quhead_saletype_id integer, quhead_shipzone_id integer, CONSTRAINT quhead_check CHECK ((((quhead_misc = (0)::numeric) AND (quhead_misc_accnt_id IS NULL)) OR ((quhead_misc <> (0)::numeric) AND (quhead_misc_accnt_id IS NOT NULL)))), CONSTRAINT quhead_quhead_number_check CHECK ((quhead_number <> ''::text)), CONSTRAINT quhead_quhead_status_check CHECK ((((quhead_status = 'O'::text) OR (quhead_status = 'C'::text)) OR (quhead_status = 'X'::text))) ); ALTER TABLE quhead OWNER TO admin; -- -- Name: TABLE quhead; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE quhead IS 'Quote header information'; -- -- Name: COLUMN quhead.quhead_saletype_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN quhead.quhead_saletype_id IS 'Associated sale type for quote.'; -- -- Name: COLUMN quhead.quhead_shipzone_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN quhead.quhead_shipzone_id IS 'Associated shipping zone for quote.'; SET search_path = api, pg_catalog; -- -- Name: quote; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW quote AS SELECT (quhead.quhead_number)::character varying AS quote_number, whsinfo.warehous_code AS site, quhead.quhead_quotedate AS quote_date, quhead.quhead_packdate AS pack_date, saletype.saletype_code AS sale_type, salesrep.salesrep_number AS sales_rep, quhead.quhead_commission AS commission, taxzone.taxzone_code AS tax_zone, taxtype.taxtype_name AS tax_type, terms.terms_code AS terms, prj.prj_number AS project_number, COALESCE(custinfo.cust_number, prospect.prospect_number) AS customer_number, quhead.quhead_billtoname AS billto_name, quhead.quhead_billtoaddress1 AS billto_address1, quhead.quhead_billtoaddress2 AS billto_address2, quhead.quhead_billtoaddress3 AS billto_address3, quhead.quhead_billtocity AS billto_city, quhead.quhead_billtostate AS billto_state, quhead.quhead_billtozip AS billto_postal_code, quhead.quhead_billtocountry AS billto_country, shiptoinfo.shipto_num AS shipto_number, quhead.quhead_shiptoname AS shipto_name, quhead.quhead_shiptophone AS shipto_phone, quhead.quhead_shiptoaddress1 AS shipto_address1, quhead.quhead_shiptoaddress2 AS shipto_address2, quhead.quhead_shiptoaddress3 AS shipto_address3, quhead.quhead_shiptocity AS shipto_city, quhead.quhead_shiptostate AS shipto_state, quhead.quhead_shiptozipcode AS shipto_postal_code, quhead.quhead_shiptocountry AS shipto_country, shipzone.shipzone_name AS shipto_shipzone, quhead.quhead_custponumber AS cust_po_number, quhead.quhead_fob AS fob, quhead.quhead_shipvia AS ship_via, curr_symbol.curr_abbr AS currency, quhead.quhead_misc_descrip AS misc_charge_description, CASE WHEN (quhead.quhead_misc_accnt_id IS NULL) THEN NULL::text ELSE public.formatglaccount(quhead.quhead_misc_accnt_id) END AS misc_account_number, quhead.quhead_misc AS misc_charge, quhead.quhead_freight AS freight, quhead.quhead_ordercomments AS order_notes, quhead.quhead_shipcomments AS shipping_notes, false AS add_to_packing_list_batch, quhead.quhead_expire AS expire_date, CASE WHEN (quhead.quhead_status = 'C'::text) THEN 'Converted'::text ELSE 'Open'::text END AS status FROM public.curr_symbol, (((((((((((public.quhead LEFT JOIN public.whsinfo ON ((quhead.quhead_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.prj ON ((quhead.quhead_prj_id = prj.prj_id))) LEFT JOIN public.shiptoinfo ON ((quhead.quhead_shipto_id = shiptoinfo.shipto_id))) LEFT JOIN public.taxzone ON ((quhead.quhead_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.taxtype ON ((quhead.quhead_taxtype_id = taxtype.taxtype_id))) LEFT JOIN public.custinfo ON ((quhead.quhead_cust_id = custinfo.cust_id))) LEFT JOIN public.prospect ON ((quhead.quhead_cust_id = prospect.prospect_id))) LEFT JOIN public.salesrep ON ((quhead.quhead_salesrep_id = salesrep.salesrep_id))) LEFT JOIN public.terms ON ((quhead.quhead_terms_id = terms.terms_id))) LEFT JOIN public.saletype ON ((quhead.quhead_saletype_id = saletype.saletype_id))) LEFT JOIN public.shipzone ON ((quhead.quhead_shipzone_id = shipzone.shipzone_id))) WHERE (quhead.quhead_curr_id = curr_symbol.curr_id); ALTER TABLE quote OWNER TO admin; -- -- Name: VIEW quote; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW quote IS 'Quote'; -- -- Name: quotecomment; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW quotecomment AS SELECT quhead.quhead_number AS quote_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.quhead, public.cmnttype, public.comment WHERE (((comment.comment_source = 'Q'::text) AND (comment.comment_source_id = quhead.quhead_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); ALTER TABLE quotecomment OWNER TO admin; -- -- Name: VIEW quotecomment; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW quotecomment IS 'Quote Comment'; SET search_path = public, pg_catalog; -- -- Name: quitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE quitem ( quitem_id integer DEFAULT nextval(('"quitem_quitem_id_seq"'::text)::regclass) NOT NULL, quitem_quhead_id integer, quitem_linenumber integer, quitem_itemsite_id integer, quitem_scheddate date, quitem_qtyord numeric(18,6), quitem_unitcost numeric(16,6), quitem_price numeric(16,4), quitem_custprice numeric(16,4), quitem_memo text, quitem_custpn text, quitem_createorder boolean, quitem_order_warehous_id integer, quitem_item_id integer, quitem_prcost numeric(16,6), quitem_imported boolean DEFAULT false, quitem_qty_uom_id integer NOT NULL, quitem_qty_invuomratio numeric(20,10) NOT NULL, quitem_price_uom_id integer NOT NULL, quitem_price_invuomratio numeric(20,10) NOT NULL, quitem_promdate date, quitem_taxtype_id integer, quitem_dropship boolean DEFAULT false, quitem_itemsrc_id integer, quitem_pricemode character(1) DEFAULT 'D'::bpchar NOT NULL, CONSTRAINT valid_quitem_pricemode CHECK ((quitem_pricemode = ANY (ARRAY['D'::bpchar, 'M'::bpchar]))) ); ALTER TABLE quitem OWNER TO admin; -- -- Name: TABLE quitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE quitem IS 'Quote Line Item information'; -- -- Name: COLUMN quitem.quitem_pricemode; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN quitem.quitem_pricemode IS 'Pricing mode for quote item. Valid values are D-discount, and M-markup'; SET search_path = api, pg_catalog; -- -- Name: quoteline; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW quoteline AS SELECT quhead.quhead_number AS quote_number, quitem.quitem_linenumber AS line_number, l.item_number, quitem.quitem_custpn AS customer_pn, i.warehous_code AS sold_from_site, quitem.quitem_qtyord AS qty_ordered, q.uom_name AS qty_uom, quitem.quitem_price AS net_unit_price, p.uom_name AS price_uom, quitem.quitem_scheddate AS scheduled_date, COALESCE((SELECT taxtype.taxtype_name FROM public.taxtype WHERE (taxtype.taxtype_id = public.getitemtaxtype(l.item_id, quhead.quhead_taxzone_id))), 'None'::text) AS tax_type, CASE WHEN (quitem.quitem_price = (0)::numeric) THEN '100'::text WHEN (quitem.quitem_custprice = (0)::numeric) THEN 'N/A'::text ELSE (round((((1)::numeric - (quitem.quitem_price / quitem.quitem_custprice)) * (100)::numeric), 4))::text END AS discount_pct_from_list, quitem.quitem_createorder AS create_order, s.warehous_code AS supplying_site, quitem.quitem_prcost AS overwrite_po_price, quitem.quitem_memo AS notes FROM public.quhead, public.uom q, public.uom p, (public.quitem LEFT JOIN public.whsinfo s ON ((quitem.quitem_order_warehous_id = s.warehous_id))), public.itemsite il, public.item l, public.whsinfo i WHERE ((((((quhead.quhead_id = quitem.quitem_quhead_id) AND (quitem.quitem_itemsite_id = il.itemsite_id)) AND (il.itemsite_item_id = l.item_id)) AND (il.itemsite_warehous_id = i.warehous_id)) AND (quitem.quitem_qty_uom_id = q.uom_id)) AND (quitem.quitem_price_uom_id = p.uom_id)) ORDER BY quhead.quhead_number, quitem.quitem_linenumber; ALTER TABLE quoteline OWNER TO admin; -- -- Name: VIEW quoteline; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW quoteline IS 'Quote Line Item'; -- -- Name: quotelinechar; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW quotelinechar AS SELECT DISTINCT quhead.quhead_number AS quote_number, quitem.quitem_linenumber AS line_number, "char".char_name AS characteristic, COALESCE((SELECT b.charass_value FROM public.charass b WHERE (((b.charass_target_type = 'QI'::text) AND (b.charass_target_id = quitem.quitem_id)) AND (b.charass_char_id = "char".char_id))), (SELECT c.charass_value FROM public.charass c WHERE ((((c.charass_target_type = 'I'::text) AND (c.charass_target_id = item.item_id)) AND c.charass_default) AND (c.charass_char_id = "char".char_id)) LIMIT 1)) AS value FROM public.quhead, public.quitem, public.itemsite, public.item, public.charass a, public."char" WHERE ((((((quhead.quhead_id = quitem.quitem_quhead_id) AND (quitem.quitem_itemsite_id = itemsite.itemsite_id)) AND (itemsite.itemsite_item_id = item.item_id)) AND (a.charass_char_id = "char".char_id)) AND (a.charass_target_type = 'I'::text)) AND (a.charass_target_id = item.item_id)) ORDER BY quhead.quhead_number, quitem.quitem_linenumber, "char".char_name; ALTER TABLE quotelinechar OWNER TO admin; -- -- Name: VIEW quotelinechar; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW quotelinechar IS 'Quote Line Item Characteristics'; -- -- Name: quotelinecomment; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW quotelinecomment AS SELECT quhead.quhead_number AS quote_number, quitem.quitem_linenumber AS line_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.quhead, public.quitem, public.cmnttype, public.comment WHERE ((((quhead.quhead_id = quitem.quitem_quhead_id) AND (comment.comment_source = 'QI'::text)) AND (comment.comment_source_id = quitem.quitem_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)) ORDER BY quhead.quhead_number, quitem.quitem_linenumber, comment.comment_date DESC; ALTER TABLE quotelinecomment OWNER TO admin; -- -- Name: VIEW quotelinecomment; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW quotelinecomment IS 'Quote Line Item Comment'; SET search_path = public, pg_catalog; -- -- Name: aropenalloc; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE aropenalloc ( aropenalloc_aropen_id integer NOT NULL, aropenalloc_doctype character(1) NOT NULL, aropenalloc_doc_id integer NOT NULL, aropenalloc_amount numeric(20,2) DEFAULT 0.00 NOT NULL, aropenalloc_curr_id integer DEFAULT basecurrid() ); ALTER TABLE aropenalloc OWNER TO admin; SET search_path = api, pg_catalog; -- -- Name: salescredit; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW salescredit AS SELECT custinfo.cust_number AS customer_number, aropen.aropen_docnumber AS cm_number, cohead.cohead_number AS so_number, (aropenalloc.aropenalloc_amount)::numeric(16,4) AS amount, curr.curr_abbr AS currency FROM ((((public.aropenalloc LEFT JOIN public.aropen ON ((aropen.aropen_id = aropenalloc.aropenalloc_aropen_id))) LEFT JOIN public.custinfo ON ((custinfo.cust_id = aropen.aropen_cust_id))) LEFT JOIN public.cohead ON (((aropenalloc.aropenalloc_doctype = 'S'::bpchar) AND (cohead.cohead_id = aropenalloc.aropenalloc_doc_id)))) LEFT JOIN public.curr_symbol curr ON ((curr.curr_id = aropenalloc.aropenalloc_curr_id))) WHERE (aropenalloc.aropenalloc_doctype = 'S'::bpchar); ALTER TABLE salescredit OWNER TO admin; -- -- Name: VIEW salescredit; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW salescredit IS 'Payments (credit memos) pre-applied to sales orders'; SET search_path = public, pg_catalog; -- -- Name: cohist; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cohist ( cohist_id integer DEFAULT nextval(('cohist_cohist_id_seq'::text)::regclass) NOT NULL, cohist_cust_id integer, cohist_itemsite_id integer, cohist_shipdate date, cohist_shipvia text, cohist_ordernumber text, cohist_orderdate date, cohist_invcnumber text, cohist_invcdate date, cohist_qtyshipped numeric(18,6), cohist_unitprice numeric(16,4), cohist_shipto_id integer, cohist_salesrep_id integer, cohist_duedate date, cohist_imported boolean DEFAULT false, cohist_billtoname text, cohist_billtoaddress1 text, cohist_billtoaddress2 text, cohist_billtoaddress3 text, cohist_billtocity text, cohist_billtostate text, cohist_billtozip text, cohist_shiptoname text, cohist_shiptoaddress1 text, cohist_shiptoaddress2 text, cohist_shiptoaddress3 text, cohist_shiptocity text, cohist_shiptostate text, cohist_shiptozip text, cohist_commission numeric(16,4), cohist_commissionpaid boolean, cohist_unitcost numeric(18,6), cohist_misc_type character(1), cohist_misc_descrip text, cohist_misc_id integer, cohist_doctype text, cohist_promisedate date, cohist_ponumber text, cohist_curr_id integer DEFAULT basecurrid(), cohist_sequence integer, cohist_taxtype_id integer, cohist_taxzone_id integer, cohist_cohead_ccpay_id integer, cohist_saletype_id integer, cohist_shipzone_id integer ); ALTER TABLE cohist OWNER TO admin; -- -- Name: TABLE cohist; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE cohist IS 'Sales Order history'; -- -- Name: COLUMN cohist.cohist_cohead_ccpay_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN cohist.cohist_cohead_ccpay_id IS 'Credit card payments made at sales order time (as opposed to invoice time) need special treatment. This field allows checking for this case.'; -- -- Name: COLUMN cohist.cohist_saletype_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN cohist.cohist_saletype_id IS 'Associated sale type for sales history.'; -- -- Name: COLUMN cohist.cohist_shipzone_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN cohist.cohist_shipzone_id IS 'Associated shipping zone for sales history.'; -- -- Name: taxhist; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE taxhist ( taxhist_id integer NOT NULL, taxhist_parent_id integer NOT NULL, taxhist_taxtype_id integer, taxhist_tax_id integer NOT NULL, taxhist_basis numeric(16,2) NOT NULL, taxhist_basis_tax_id integer, taxhist_sequence integer, taxhist_percent numeric(10,6) NOT NULL, taxhist_amount numeric(16,2) NOT NULL, taxhist_tax numeric(16,6) NOT NULL, taxhist_docdate date NOT NULL, taxhist_distdate date, taxhist_curr_id integer, taxhist_curr_rate numeric, taxhist_journalnumber integer ); ALTER TABLE taxhist OWNER TO admin; -- -- Name: TABLE taxhist; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE taxhist IS 'A table type to record tax transaction history. Inherited by other tables that actually record history. As the parent, queries can be run against it that will join all child tables. '; -- -- Name: COLUMN taxhist.taxhist_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxhist.taxhist_id IS 'Primary key'; -- -- Name: COLUMN taxhist.taxhist_parent_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxhist.taxhist_parent_id IS 'Source parent id.'; -- -- Name: COLUMN taxhist.taxhist_taxtype_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxhist.taxhist_taxtype_id IS 'Tax type id'; -- -- Name: COLUMN taxhist.taxhist_tax_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxhist.taxhist_tax_id IS 'Tax code id.'; -- -- Name: COLUMN taxhist.taxhist_basis; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxhist.taxhist_basis IS 'Base price amount on which the tax calculation is based.'; -- -- Name: COLUMN taxhist.taxhist_basis_tax_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxhist.taxhist_basis_tax_id IS 'Tax rate calculation basis. If null, then the amount of the parent document, otherwise calculated on the result amount of the tax code id referenced.'; -- -- Name: COLUMN taxhist.taxhist_amount; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxhist.taxhist_amount IS 'Flat tax amount.'; -- -- Name: COLUMN taxhist.taxhist_tax; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxhist.taxhist_tax IS 'Calculated tax amount.'; -- -- Name: COLUMN taxhist.taxhist_docdate; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxhist.taxhist_docdate IS 'The date of the parent document.'; -- -- Name: COLUMN taxhist.taxhist_distdate; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxhist.taxhist_distdate IS 'The G/L distribution date of the parent document.'; -- -- Name: cohisttax; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cohisttax ( ) INHERITS (taxhist); ALTER TABLE cohisttax OWNER TO admin; SET search_path = api, pg_catalog; -- -- Name: saleshistory; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW saleshistory AS SELECT custinfo.cust_number AS customer_number, item.item_number, whsinfo.warehous_code AS site_code, cohist.cohist_shipdate AS ship_date, cohist.cohist_shipvia AS ship_via, cohist.cohist_ordernumber AS order_number, cohist.cohist_ponumber AS purchase_order_number, cohist.cohist_orderdate AS order_date, cohist.cohist_invcnumber AS invoice_number, cohist.cohist_invcdate AS invoice_date, cohist.cohist_qtyshipped AS quantity_shipped, cohist.cohist_unitprice AS unit_price, shiptoinfo.shipto_num AS shipto_number, salesrep.salesrep_number AS sales_rep, cohist.cohist_duedate AS due_date, cohist.cohist_promisedate AS promise_date, cohist.cohist_imported AS imported, cohist.cohist_billtoname AS billto_name, cohist.cohist_billtoaddress1 AS billto_address1, cohist.cohist_billtoaddress2 AS billto_address2, cohist.cohist_billtoaddress3 AS billto_address3, cohist.cohist_billtocity AS billto_city, cohist.cohist_billtostate AS billto_state, cohist.cohist_billtozip AS billto_zip, cohist.cohist_shiptoname AS shipto_name, cohist.cohist_shiptoaddress1 AS shipto_address1, cohist.cohist_shiptoaddress2 AS shipto_address2, cohist.cohist_shiptoaddress3 AS shipto_address3, cohist.cohist_shiptocity AS shipto_city, cohist.cohist_shiptostate AS shipto_state, cohist.cohist_shiptozip AS shipto_zip, cohist.cohist_commission AS commission, cohist.cohist_commissionpaid AS commission_paid, cohist.cohist_unitcost AS unit_cost, CASE WHEN (cohist.cohist_misc_type IS NULL) THEN ''::text WHEN (cohist.cohist_misc_type = 'M'::bpchar) THEN 'Misc. Charge'::text WHEN (cohist.cohist_misc_type = 'F'::bpchar) THEN 'Freight'::text ELSE 'Unknown'::text END AS misc_type, cohist.cohist_misc_descrip AS misc_description, CASE WHEN (cohist.cohist_misc_id IS NULL) THEN ''::text WHEN (cohist.cohist_misc_type = 'M'::bpchar) THEN public.formatglaccount(cohist.cohist_misc_id) ELSE 'Unknown'::text END AS misc_info, taxzone.taxzone_code AS tax_zone, taxtype.taxtype_name AS tax_type, CASE WHEN (cohist.cohist_doctype = 'I'::text) THEN 'Invoice'::text WHEN (cohist.cohist_doctype = 'C'::text) THEN 'Credit Memo'::text ELSE 'Unknown'::text END AS document_type, curr_symbol.curr_abbr AS currency, cohist.cohist_sequence AS gl_sequence, (SELECT sum(cohisttax.taxhist_tax) AS sum FROM public.cohisttax WHERE (cohisttax.taxhist_parent_id = cohist.cohist_id)) AS tax FROM (((((((((public.cohist LEFT JOIN public.custinfo ON ((cohist.cohist_cust_id = custinfo.cust_id))) LEFT JOIN public.shiptoinfo ON ((cohist.cohist_shipto_id = shiptoinfo.shipto_id))) LEFT JOIN public.taxzone ON ((cohist.cohist_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.taxtype ON ((cohist.cohist_taxtype_id = taxtype.taxtype_id))) LEFT JOIN public.salesrep ON ((cohist.cohist_salesrep_id = salesrep.salesrep_id))) LEFT JOIN public.itemsite ON ((cohist.cohist_itemsite_id = itemsite.itemsite_id))) LEFT JOIN public.item ON ((itemsite.itemsite_item_id = item.item_id))) LEFT JOIN public.whsinfo ON ((itemsite.itemsite_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.curr_symbol ON ((cohist.cohist_curr_id = curr_symbol.curr_id))); ALTER TABLE saleshistory OWNER TO admin; -- -- Name: VIEW saleshistory; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW saleshistory IS 'Sales History'; -- -- Name: saleslinechar; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW saleslinechar AS SELECT (data.order_number)::character varying AS order_number, data.line_number, data.characteristic, COALESCE(si.charass_value, i3.charass_value) AS value, (COALESCE(si.charass_price, public.itemcharprice(data.item_id, data.char_id, COALESCE(si.charass_value, i3.charass_value), data.cohead_cust_id, data.cohead_shipto_id, data.coitem_qtyord, data.cohead_curr_id, data.cohead_orderdate), (0)::numeric))::numeric(16,4) AS price FROM (((((SELECT DISTINCT cohead.cohead_cust_id, cohead.cohead_shipto_id, cohead.cohead_curr_id, cohead.cohead_orderdate, coitem.coitem_id, coitem.coitem_itemsite_id, coitem.coitem_qtyord, "char".char_id, item.item_id, cohead.cohead_number AS order_number, CASE WHEN (coitem.coitem_subnumber = 0) THEN ((coitem.coitem_linenumber)::character varying)::text ELSE ((((coitem.coitem_linenumber)::character varying)::text || ('.'::character varying)::text) || ((coitem.coitem_subnumber)::character varying)::text) END AS line_number, "char".char_name AS characteristic FROM public.cohead, public.coitem, public.itemsite, public.item, public.charass, public."char" WHERE ((((((cohead.cohead_id = coitem.coitem_cohead_id) AND (coitem.coitem_itemsite_id = itemsite.itemsite_id)) AND (itemsite.itemsite_item_id = item.item_id)) AND (charass.charass_char_id = "char".char_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id))) data LEFT JOIN public.charass si ON ((((data.coitem_id = si.charass_target_id) AND ('SI'::text = si.charass_target_type)) AND (si.charass_char_id = data.char_id)))) LEFT JOIN public.itemsite i1 ON ((data.coitem_itemsite_id = i1.itemsite_id))) LEFT JOIN public.item i2 ON ((i1.itemsite_item_id = i2.item_id))) LEFT JOIN public.charass i3 ON (((((i2.item_id = i3.charass_target_id) AND ('I'::text = i3.charass_target_type)) AND (i3.charass_char_id = data.char_id)) AND i3.charass_default))) ORDER BY (data.order_number)::character varying, data.line_number, data.characteristic; ALTER TABLE saleslinechar OWNER TO admin; -- -- Name: VIEW saleslinechar; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW saleslinechar IS 'Sales Order Line Item Characteristic'; -- -- Name: saleslinecomment; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW saleslinecomment AS SELECT (cohead.cohead_number)::character varying AS order_number, CASE WHEN (coitem.coitem_subnumber = 0) THEN ((coitem.coitem_linenumber)::character varying)::text ELSE ((((coitem.coitem_linenumber)::character varying)::text || ('.'::character varying)::text) || ((coitem.coitem_subnumber)::character varying)::text) END AS line_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.cohead, public.coitem, public.cmnttype, public.comment WHERE ((((cohead.cohead_id = coitem.coitem_cohead_id) AND (comment.comment_source = 'SI'::text)) AND (comment.comment_source_id = coitem.coitem_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)) ORDER BY cohead.cohead_number, coitem.coitem_linenumber, comment.comment_date DESC; ALTER TABLE saleslinecomment OWNER TO admin; -- -- Name: VIEW saleslinecomment; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW saleslinecomment IS 'Sales Order Line Item Comment'; -- -- Name: salesorder; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW salesorder AS SELECT (cohead.cohead_number)::character varying AS order_number, whsinfo.warehous_code AS site, cohead.cohead_orderdate AS order_date, cohead.cohead_packdate AS pack_date, saletype.saletype_code AS sale_type, salesrep.salesrep_number AS sales_rep, cohead.cohead_commission AS commission, COALESCE(taxzone.taxzone_code, 'None'::text) AS tax_zone, terms.terms_code AS terms, prj.prj_number AS project_number, custinfo.cust_number AS customer_number, bc.cntct_number AS billto_contact_number, cohead.cohead_billto_cntct_honorific AS billto_contact_name, cohead.cohead_billto_cntct_first_name AS billto_contact_first, cohead.cohead_billto_cntct_middle AS billto_contact_middle, cohead.cohead_billto_cntct_last_name AS billto_contact_last, cohead.cohead_billto_cntct_suffix AS billto_contact_suffix, cohead.cohead_billto_cntct_phone AS billto_contact_phone, cohead.cohead_billto_cntct_title AS billto_contact_title, cohead.cohead_billto_cntct_fax AS billto_contct_fax, cohead.cohead_billto_cntct_email AS billto_contact_email, cohead.cohead_billtoname AS billto_name, cohead.cohead_billtoaddress1 AS billto_address1, cohead.cohead_billtoaddress2 AS billto_address2, cohead.cohead_billtoaddress3 AS billto_address3, cohead.cohead_billtocity AS billto_city, cohead.cohead_billtostate AS billto_state, cohead.cohead_billtozipcode AS billto_postal_code, cohead.cohead_billtocountry AS billto_country, shiptoinfo.shipto_num AS shipto_number, sc.cntct_number AS shipto_contact_number, cohead.cohead_shipto_cntct_honorific AS shipto_contact_honorific, cohead.cohead_shipto_cntct_first_name AS shipto_contact_first, cohead.cohead_shipto_cntct_middle AS shipto_contact_middle, cohead.cohead_shipto_cntct_last_name AS shipto_contact_last, cohead.cohead_shipto_cntct_suffix AS shipto_contact_suffix, cohead.cohead_shipto_cntct_phone AS shipto_contact_phone, cohead.cohead_shipto_cntct_title AS shipto_contact_title, cohead.cohead_shipto_cntct_fax AS shipto_contact_fax, cohead.cohead_shipto_cntct_email AS shipto_contact_email, cohead.cohead_shiptoname AS shipto_name, cohead.cohead_shiptophone AS shipto_phone, cohead.cohead_shiptoaddress1 AS shipto_address1, cohead.cohead_shiptoaddress2 AS shipto_address2, cohead.cohead_shiptoaddress3 AS shipto_address3, cohead.cohead_shiptocity AS shipto_city, cohead.cohead_shiptostate AS shipto_state, cohead.cohead_shiptozipcode AS shipto_postal_code, cohead.cohead_shiptocountry AS shipto_country, shipzone.shipzone_name AS shipto_shipzone, cohead.cohead_custponumber AS cust_po_number, cohead.cohead_fob AS fob, cohead.cohead_shipvia AS ship_via, CASE WHEN (cohead.cohead_holdtype = 'N'::bpchar) THEN 'None'::text WHEN (cohead.cohead_holdtype = 'C'::bpchar) THEN 'Credit'::text WHEN (cohead.cohead_holdtype = 'S'::bpchar) THEN 'Shipping'::text WHEN (cohead.cohead_holdtype = 'P'::bpchar) THEN 'Packing'::text WHEN (cohead.cohead_holdtype = 'R'::bpchar) THEN 'Return'::text ELSE 'Error'::text END AS hold_type, shipchrg.shipchrg_name AS shipping_chgs, shipform.shipform_name AS shipping_form, cohead.cohead_shipcomplete AS ship_complete, curr_symbol.curr_abbr AS currency, cohead.cohead_misc_descrip AS misc_charge_description, CASE WHEN (cohead.cohead_misc_accnt_id IS NULL) THEN NULL::text ELSE public.formatglaccount(cohead.cohead_misc_accnt_id) END AS misc_account_number, cohead.cohead_misc AS misc_charge, cohead.cohead_freight AS freight, cohead.cohead_calcfreight AS calculate_freight, cohead.cohead_ordercomments AS order_notes, cohead.cohead_shipcomments AS shipping_notes, false AS add_to_packing_list_batch FROM (((((((((public.cohead LEFT JOIN public.cntct bc ON ((cohead.cohead_billto_cntct_id = bc.cntct_id))) LEFT JOIN public.cntct sc ON ((cohead.cohead_shipto_cntct_id = sc.cntct_id))) LEFT JOIN public.whsinfo ON ((cohead.cohead_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.prj ON ((cohead.cohead_prj_id = prj.prj_id))) LEFT JOIN public.shiptoinfo ON ((cohead.cohead_shipto_id = shiptoinfo.shipto_id))) LEFT JOIN public.shipchrg ON ((cohead.cohead_shipchrg_id = shipchrg.shipchrg_id))) LEFT JOIN public.taxzone ON ((cohead.cohead_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.saletype ON ((cohead.cohead_saletype_id = saletype.saletype_id))) LEFT JOIN public.shipzone ON ((cohead.cohead_shipzone_id = shipzone.shipzone_id))), public.custinfo, public.shipform, public.salesrep, public.terms, public.curr_symbol WHERE (((((cohead.cohead_cust_id = custinfo.cust_id) AND (cohead.cohead_shipform_id = shipform.shipform_id)) AND (cohead.cohead_salesrep_id = salesrep.salesrep_id)) AND (cohead.cohead_terms_id = terms.terms_id)) AND (cohead.cohead_curr_id = curr_symbol.curr_id)); ALTER TABLE salesorder OWNER TO admin; -- -- Name: VIEW salesorder; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW salesorder IS 'Sales Order'; -- -- Name: salesordercomment; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW salesordercomment AS SELECT (cohead.cohead_number)::character varying AS order_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.cohead, public.cmnttype, public.comment WHERE (((comment.comment_source = 'S'::text) AND (comment.comment_source_id = cohead.cohead_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); ALTER TABLE salesordercomment OWNER TO admin; -- -- Name: VIEW salesordercomment; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW salesordercomment IS 'Sales Order Comment'; -- -- Name: salesrep; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW salesrep AS SELECT (salesrep.salesrep_number)::character varying AS number, salesrep.salesrep_active AS active, salesrep.salesrep_name AS name, (salesrep.salesrep_commission * (100)::numeric) AS commission_percent, emp.emp_number AS employee FROM (public.salesrep LEFT JOIN public.emp ON ((emp.emp_id = salesrep.salesrep_emp_id))) ORDER BY salesrep.salesrep_number; ALTER TABLE salesrep OWNER TO admin; -- -- Name: VIEW salesrep; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW salesrep IS 'Sales Rep'; SET search_path = public, pg_catalog; -- -- Name: shipvia; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE shipvia ( shipvia_id integer DEFAULT nextval(('shipvia_shipvia_id_seq'::text)::regclass) NOT NULL, shipvia_code text NOT NULL, shipvia_descrip text, CONSTRAINT shipvia_shipvia_code_check CHECK ((shipvia_code <> ''::text)) ); ALTER TABLE shipvia OWNER TO admin; -- -- Name: TABLE shipvia; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE shipvia IS 'Ship Via information'; -- -- Name: sitetype; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE sitetype ( sitetype_id integer NOT NULL, sitetype_name text NOT NULL, sitetype_descrip text, CONSTRAINT sitetype_sitetype_name_check CHECK ((sitetype_name <> ''::text)) ); ALTER TABLE sitetype OWNER TO admin; -- -- Name: TABLE sitetype; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE sitetype IS 'This table is the different types of sites.'; SET search_path = api, pg_catalog; -- -- Name: site; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW site AS SELECT (whsinfo.warehous_code)::character varying AS code, st.sitetype_name AS type, whsinfo.warehous_active AS active, whsinfo.warehous_descrip AS description, m.addr_number AS address_number, m.addr_line1 AS address1, m.addr_line2 AS address2, m.addr_line3 AS address3, m.addr_city AS city, m.addr_state AS state, m.addr_postalcode AS postal_code, m.addr_country AS country, ''::text AS address_change, c.cntct_number AS contact_number, c.cntct_honorific AS honorific, c.cntct_first_name AS first, c.cntct_middle AS middle, c.cntct_last_name AS last, c.cntct_suffix AS suffix, c.cntct_title AS job_title, c.cntct_phone AS phone, c.cntct_fax AS fax, c.cntct_email AS email, ''::text AS contact_change, public.formatglaccount(a.accnt_id) AS post_unassigned_transactions_to, a.accnt_descrip AS post_unassigned_transactions_to_description, whsinfo.warehous_transit AS transit_type, CASE WHEN whsinfo.warehous_transit THEN false ELSE true END AS inventory_type, CASE WHEN whsinfo.warehous_transit THEN ''::text ELSE whsinfo.warehous_bol_prefix END AS next_bill_of_lading_prefix, CASE WHEN whsinfo.warehous_transit THEN 0 ELSE whsinfo.warehous_bol_number END AS next_bill_of_lading_number, CASE WHEN whsinfo.warehous_transit THEN false ELSE whsinfo.warehous_shipping END AS shipping_site, CASE WHEN whsinfo.warehous_transit THEN ''::text ELSE whsinfo.warehous_counttag_prefix END AS next_count_tag_prefix, CASE WHEN whsinfo.warehous_transit THEN 0 ELSE whsinfo.warehous_counttag_number END AS next_count_tag_number, CASE WHEN whsinfo.warehous_transit THEN false ELSE whsinfo.warehous_useslips END AS force_the_use_of_count_slips, CASE WHEN whsinfo.warehous_transit THEN false ELSE whsinfo.warehous_usezones END AS force_the_use_of_zones, CASE WHEN whsinfo.warehous_transit THEN 0 ELSE whsinfo.warehous_sequence END AS scheduling_sequence, CASE WHEN whsinfo.warehous_transit THEN (0)::numeric ELSE (whsinfo.warehous_shipping_commission * 100.0) END AS shipping_commission, CASE WHEN whsinfo.warehous_transit THEN ''::text ELSE t.taxzone_code END AS tax_zone, CASE WHEN whsinfo.warehous_transit THEN ''::text ELSE whsinfo.warehous_fob END AS default_fob, CASE WHEN whsinfo.warehous_transit THEN s.shipvia_code ELSE ''::text END AS default_ship_via, CASE WHEN whsinfo.warehous_transit THEN f.shipform_name ELSE ''::text END AS default_shipping_form, CASE WHEN whsinfo.warehous_transit THEN cc.costcat_code ELSE ''::text END AS default_cost_category, CASE WHEN whsinfo.warehous_transit THEN whsinfo.warehous_shipcomments ELSE ''::text END AS shipping_comments, CASE WHEN whsinfo.warehous_transit THEN false ELSE whsinfo.warehous_enforcearbl END AS enforce_arbl_naming_convention, CASE WHEN whsinfo.warehous_transit THEN 0 WHEN whsinfo.warehous_enforcearbl THEN whsinfo.warehous_aislesize ELSE 0 END AS aisle_size, CASE WHEN whsinfo.warehous_transit THEN false WHEN (whsinfo.warehous_enforcearbl AND whsinfo.warehous_aislealpha) THEN true ELSE false END AS aisle_allow_alpha_characters, CASE WHEN whsinfo.warehous_transit THEN 0 WHEN whsinfo.warehous_enforcearbl THEN whsinfo.warehous_racksize ELSE 0 END AS rack_size, CASE WHEN whsinfo.warehous_transit THEN false WHEN (whsinfo.warehous_enforcearbl AND whsinfo.warehous_rackalpha) THEN true ELSE false END AS rack_allow_alpha_characters, CASE WHEN whsinfo.warehous_transit THEN 0 WHEN whsinfo.warehous_enforcearbl THEN whsinfo.warehous_binsize ELSE 0 END AS bin_size, CASE WHEN whsinfo.warehous_transit THEN false WHEN (whsinfo.warehous_enforcearbl AND whsinfo.warehous_binalpha) THEN true ELSE false END AS bin_allow_alpha_characters, CASE WHEN whsinfo.warehous_transit THEN 0 WHEN whsinfo.warehous_enforcearbl THEN whsinfo.warehous_locationsize ELSE 0 END AS location_size, CASE WHEN whsinfo.warehous_transit THEN false WHEN (whsinfo.warehous_enforcearbl AND whsinfo.warehous_locationalpha) THEN true ELSE false END AS location_allow_alpha_characters FROM ((((((((public.whsinfo LEFT JOIN public.addr m ON ((whsinfo.warehous_addr_id = m.addr_id))) LEFT JOIN public.cntct c ON ((whsinfo.warehous_cntct_id = c.cntct_id))) LEFT JOIN public.accnt a ON ((whsinfo.warehous_default_accnt_id = a.accnt_id))) LEFT JOIN public.taxzone t ON ((whsinfo.warehous_taxzone_id = t.taxzone_id))) LEFT JOIN public.shipvia s ON ((whsinfo.warehous_shipvia_id = s.shipvia_id))) LEFT JOIN public.shipform f ON ((whsinfo.warehous_shipform_id = f.shipform_id))) LEFT JOIN public.costcat cc ON ((whsinfo.warehous_costcat_id = cc.costcat_id))) LEFT JOIN public.sitetype st ON ((whsinfo.warehous_sitetype_id = st.sitetype_id))) ORDER BY whsinfo.warehous_code; ALTER TABLE site OWNER TO admin; -- -- Name: VIEW site; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW site IS 'Site'; -- -- Name: sitezone; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW sitezone AS SELECT (whsinfo.warehous_code)::character varying AS site, (whsezone.whsezone_name)::character varying AS name, whsezone.whsezone_descrip AS description FROM (public.whsezone LEFT JOIN public.whsinfo ON ((whsinfo.warehous_id = whsezone.whsezone_warehous_id))); ALTER TABLE sitezone OWNER TO admin; -- -- Name: VIEW sitezone; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW sitezone IS 'Site Zone'; -- -- Name: task; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW task AS SELECT prj.prj_number AS project_number, prjtask.prjtask_number AS number, CASE WHEN (prjtask.prjtask_status = 'P'::bpchar) THEN 'Concept'::text WHEN (prjtask.prjtask_status = 'O'::bpchar) THEN 'In-Process'::text WHEN (prjtask.prjtask_status = 'C'::bpchar) THEN 'Closed'::text ELSE 'Error'::text END AS status, prjtask.prjtask_name AS name, prjtask.prjtask_descrip AS description, prjtask.prjtask_owner_username AS owner, prjtask.prjtask_username AS assigned_to, prjtask.prjtask_hours_budget AS hours_budgeted, prjtask.prjtask_hours_actual AS hours_actual, prjtask.prjtask_exp_budget AS expenses_budgeted, prjtask.prjtask_exp_actual AS expenses_actual, prjtask.prjtask_due_date AS due, prjtask.prjtask_assigned_date AS assigned, prjtask.prjtask_start_date AS started, prjtask.prjtask_completed_date AS completed FROM (public.prjtask JOIN public.prj ON ((prj.prj_id = prjtask.prjtask_prj_id))); ALTER TABLE task OWNER TO admin; -- -- Name: VIEW task; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW task IS 'Task'; -- -- Name: taskcomment; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW taskcomment AS SELECT (prj.prj_number)::character varying AS project_number, (prjtask.prjtask_number)::character varying AS task_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.prj, public.prjtask, public.cmnttype, public.comment WHERE ((((comment.comment_source = 'TA'::text) AND (prj.prj_id = prjtask.prjtask_prj_id)) AND (comment.comment_source_id = prjtask.prjtask_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); ALTER TABLE taskcomment OWNER TO admin; -- -- Name: VIEW taskcomment; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW taskcomment IS 'Task Comment'; -- -- Name: todo; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW todo AS SELECT todoitem.todoitem_id AS task_number, todoitem.todoitem_owner_username AS owner, todoitem.todoitem_username AS assigned_to, todoitem.todoitem_name AS task_name, incdtpriority.incdtpriority_name AS priority, incdt.incdt_number AS incident, ophead.ophead_name AS opportunity, crmacct.crmacct_number AS account, public.formatdate(todoitem.todoitem_due_date) AS date_due, public.formatdate(todoitem.todoitem_assigned_date) AS date_assigned, public.formatdate(todoitem.todoitem_start_date) AS date_started, public.formatdate(todoitem.todoitem_completed_date) AS date_completed, CASE WHEN (todoitem.todoitem_status = 'P'::bpchar) THEN 'Pending Input'::text WHEN (todoitem.todoitem_status = 'D'::bpchar) THEN 'Deferred'::text ELSE 'Neither'::text END AS status, todoitem.todoitem_active AS active, todoitem.todoitem_description AS description, todoitem.todoitem_notes AS notes FROM ((((public.todoitem LEFT JOIN public.incdt ON ((incdt.incdt_id = todoitem.todoitem_incdt_id))) LEFT JOIN public.ophead ON ((ophead.ophead_id = todoitem.todoitem_ophead_id))) LEFT JOIN public.crmacct ON ((crmacct.crmacct_id = todoitem.todoitem_crmacct_id))) LEFT JOIN public.incdtpriority ON ((incdtpriority.incdtpriority_id = todoitem.todoitem_priority_id))); ALTER TABLE todo OWNER TO admin; -- -- Name: VIEW todo; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW todo IS 'To-Do List'; SET search_path = public, pg_catalog; -- -- Name: vendtype; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE vendtype ( vendtype_id integer NOT NULL, vendtype_code text NOT NULL, vendtype_descrip text, CONSTRAINT vendtype_vendtype_code_check CHECK ((vendtype_code <> ''::text)) ); ALTER TABLE vendtype OWNER TO admin; -- -- Name: TABLE vendtype; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE vendtype IS 'Vendor Type information'; SET search_path = api, pg_catalog; -- -- Name: vendor; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW vendor AS SELECT (vendinfo.vend_number)::character varying AS vendor_number, vendtype.vendtype_code AS vendor_type, vendinfo.vend_name AS vendor_name, vendinfo.vend_active AS active, vendinfo.vend_accntnum AS account_number, addr.addr_number AS address_number, addr.addr_line1 AS address1, addr.addr_line2 AS address2, addr.addr_line3 AS address3, addr.addr_city AS city, addr.addr_state AS state, addr.addr_postalcode AS postalcode, addr.addr_country AS country, ''::text AS address_change, terms.terms_code AS default_terms, vendinfo.vend_shipvia AS ship_via, curr_symbol.curr_abbr AS default_currency, CASE WHEN (vendinfo.vend_fobsource = 'W'::bpchar) THEN 'Receiving Site'::text ELSE vendinfo.vend_fob END AS default_fob, vendinfo.vend_po AS sells_purchase_order_items, vendinfo.vend_restrictpurch AS may_only_sell_item_source, vendinfo.vend_qualified AS qualified, vendinfo.vend_match AS matching_vo_po_amounts, vendinfo.vend_1099 AS receives_1099, taxzone.taxzone_code AS default_tax_zone, CASE WHEN (accnt.accnt_id IS NULL) THEN 'N/A'::text ELSE public.formatglaccount(accnt.accnt_id) END AS default_dist_gl_account, CASE WHEN (expcat.expcat_id IS NULL) THEN 'N/A'::text ELSE expcat.expcat_code END AS default_dist_expense_category, CASE WHEN (tax.tax_id IS NULL) THEN 'N/A'::text ELSE tax.tax_code END AS default_dist_tax_code, c1.cntct_number AS contact1_number, c1.cntct_honorific AS contact1_honorific, c1.cntct_first_name AS contact1_first, c1.cntct_middle AS contact1_middle, c1.cntct_last_name AS contact1_last, c1.cntct_suffix AS contact1_suffix, c1.cntct_title AS contact1_job_title, c1.cntct_phone AS contact1_voice, c1.cntct_phone2 AS contact1_alternate, c1.cntct_fax AS contact1_fax, c1.cntct_email AS contact1_email, c1.cntct_webaddr AS contact1_web, ''::text AS contact1_change, c2.cntct_number AS contact2_number, c2.cntct_honorific AS contact2_honorific, c2.cntct_first_name AS contact2_first, c2.cntct_middle AS contact2_middle, c2.cntct_last_name AS contact2_last, c2.cntct_suffix AS contact2_suffix, c2.cntct_title AS contact2_job_title, c2.cntct_phone AS contact2_voice, c2.cntct_phone2 AS contact2_alternate, c2.cntct_fax AS contact2_fax, c2.cntct_email AS contact2_email, c2.cntct_webaddr AS contact2_web, ''::text AS contact2_change, vendinfo.vend_comments AS notes, vendinfo.vend_pocomments AS po_comments, vendinfo.vend_emailpodelivery AS allow_email_po_delivery, vendinfo.vend_ediemail AS po_edi_email, vendinfo.vend_edicc AS po_edi_cc, vendinfo.vend_edisubject AS po_edi_subject, vendinfo.vend_edifilename AS po_edi_filename, vendinfo.vend_ediemailbody AS po_edi_emailbody FROM ((((((((((public.vendinfo LEFT JOIN public.addr ON ((vendinfo.vend_addr_id = addr.addr_id))) LEFT JOIN public.cntct c1 ON ((vendinfo.vend_cntct1_id = c1.cntct_id))) LEFT JOIN public.cntct c2 ON ((vendinfo.vend_cntct2_id = c2.cntct_id))) LEFT JOIN public.taxzone ON ((vendinfo.vend_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.curr_symbol ON ((vendinfo.vend_curr_id = curr_symbol.curr_id))) LEFT JOIN public.terms ON ((vendinfo.vend_terms_id = terms.terms_id))) LEFT JOIN public.vendtype ON ((vendinfo.vend_vendtype_id = vendtype.vendtype_id))) LEFT JOIN public.accnt ON ((vendinfo.vend_accnt_id = accnt.accnt_id))) LEFT JOIN public.expcat ON ((vendinfo.vend_expcat_id = expcat.expcat_id))) LEFT JOIN public.tax ON ((vendinfo.vend_tax_id = tax.tax_id))) ORDER BY vendinfo.vend_number; ALTER TABLE vendor OWNER TO admin; -- -- Name: VIEW vendor; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW vendor IS 'vendor'; -- -- Name: vendoraddress; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW vendoraddress AS SELECT (vendinfo.vend_number)::character varying AS vendor_number, vendinfo.vend_name AS vendor_name, (vendaddrinfo.vendaddr_code)::character varying AS vendor_address_number, vendaddrinfo.vendaddr_name AS vendor_address_name, addr.addr_number AS address_number, addr.addr_line1 AS address1, addr.addr_line2 AS address2, addr.addr_line3 AS address3, addr.addr_city AS city, addr.addr_state AS state, addr.addr_postalcode AS postalcode, addr.addr_country AS country, ''::text AS address_change, cntct.cntct_number AS contact_number, cntct.cntct_honorific AS contact_honorific, cntct.cntct_first_name AS contact_first, cntct.cntct_middle AS contact_middle, cntct.cntct_last_name AS contact_last, cntct.cntct_suffix AS contact_suffix, cntct.cntct_title AS contact_job_title, cntct.cntct_phone AS contact_voice, cntct.cntct_phone2 AS contact_alternate, cntct.cntct_fax AS contact_fax, cntct.cntct_email AS contact_email, cntct.cntct_webaddr AS contact_web, ''::text AS contact_change, vendaddrinfo.vendaddr_comments AS notes FROM (((public.vendaddrinfo LEFT JOIN public.vendinfo ON ((vendinfo.vend_id = vendaddrinfo.vendaddr_vend_id))) LEFT JOIN public.addr ON ((vendaddrinfo.vendaddr_addr_id = addr.addr_id))) LEFT JOIN public.cntct ON ((vendaddrinfo.vendaddr_cntct_id = cntct.cntct_id))) ORDER BY vendaddrinfo.vendaddr_code; ALTER TABLE vendoraddress OWNER TO admin; -- -- Name: VIEW vendoraddress; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW vendoraddress IS 'vendor address'; -- -- Name: vendortype; Type: VIEW; Schema: api; Owner: admin -- CREATE VIEW vendortype AS SELECT (vendtype.vendtype_code)::character varying AS code, vendtype.vendtype_descrip AS description FROM public.vendtype ORDER BY vendtype.vendtype_code; ALTER TABLE vendortype OWNER TO admin; -- -- Name: VIEW vendortype; Type: COMMENT; Schema: api; Owner: admin -- COMMENT ON VIEW vendortype IS 'Vendor Type'; SET search_path = public, pg_catalog; -- -- Name: cmd; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cmd ( cmd_id integer NOT NULL, cmd_module text NOT NULL, cmd_title text NOT NULL, cmd_descrip text, cmd_privname text, cmd_executable text NOT NULL, cmd_name text ); ALTER TABLE cmd OWNER TO admin; -- -- Name: TABLE cmd; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE cmd IS 'Custom menu command table.'; -- -- Name: cmd_cmd_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cmd_cmd_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE cmd_cmd_id_seq OWNER TO admin; -- -- Name: cmd_cmd_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE cmd_cmd_id_seq OWNED BY cmd.cmd_id; SET search_path = fixcountry, pg_catalog; -- -- Name: pkgcmd; Type: TABLE; Schema: fixcountry; Owner: admin; Tablespace: -- CREATE TABLE pkgcmd ( cmd_id integer DEFAULT nextval('public.cmd_cmd_id_seq'::regclass) ) INHERITS (public.cmd); ALTER TABLE pkgcmd OWNER TO admin; SET search_path = public, pg_catalog; -- -- Name: cmdarg; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cmdarg ( cmdarg_id integer NOT NULL, cmdarg_cmd_id integer NOT NULL, cmdarg_order integer NOT NULL, cmdarg_arg text NOT NULL ); ALTER TABLE cmdarg OWNER TO admin; -- -- Name: TABLE cmdarg; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE cmdarg IS 'Command argument for custom menu command table.'; -- -- Name: cmdarg_cmdarg_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cmdarg_cmdarg_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE cmdarg_cmdarg_id_seq OWNER TO admin; -- -- Name: cmdarg_cmdarg_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE cmdarg_cmdarg_id_seq OWNED BY cmdarg.cmdarg_id; SET search_path = fixcountry, pg_catalog; -- -- Name: pkgcmdarg; Type: TABLE; Schema: fixcountry; Owner: admin; Tablespace: -- CREATE TABLE pkgcmdarg ( cmdarg_id integer DEFAULT nextval('public.cmdarg_cmdarg_id_seq'::regclass) ) INHERITS (public.cmdarg); ALTER TABLE pkgcmdarg OWNER TO admin; SET search_path = public, pg_catalog; -- -- Name: image_image_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE image_image_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE image_image_id_seq OWNER TO admin; SET search_path = fixcountry, pg_catalog; -- -- Name: pkgimage; Type: TABLE; Schema: fixcountry; Owner: admin; Tablespace: -- CREATE TABLE pkgimage ( image_id integer DEFAULT nextval('public.image_image_id_seq'::regclass) ) INHERITS (public.image); ALTER TABLE pkgimage OWNER TO admin; SET search_path = public, pg_catalog; -- -- Name: metasql; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE metasql ( metasql_id integer NOT NULL, metasql_group text, metasql_name text, metasql_notes text, metasql_query text, metasql_lastuser text, metasql_lastupdate date, metasql_grade integer DEFAULT 0 NOT NULL ); ALTER TABLE metasql OWNER TO admin; -- -- Name: TABLE metasql; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE metasql IS 'MetaSQL Table'; -- -- Name: metasql_metasql_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE metasql_metasql_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE metasql_metasql_id_seq OWNER TO admin; -- -- Name: metasql_metasql_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE metasql_metasql_id_seq OWNED BY metasql.metasql_id; SET search_path = fixcountry, pg_catalog; -- -- Name: pkgmetasql; Type: TABLE; Schema: fixcountry; Owner: admin; Tablespace: -- CREATE TABLE pkgmetasql ( metasql_id integer DEFAULT nextval('public.metasql_metasql_id_seq'::regclass) ) INHERITS (public.metasql); ALTER TABLE pkgmetasql OWNER TO admin; SET search_path = public, pg_catalog; -- -- Name: priv; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE priv ( priv_id integer DEFAULT nextval(('priv_priv_id_seq'::text)::regclass) NOT NULL, priv_module text, priv_name text, priv_descrip text, priv_seq integer ); ALTER TABLE priv OWNER TO admin; -- -- Name: TABLE priv; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE priv IS 'System Privilege information'; -- -- Name: priv_priv_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE priv_priv_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE priv_priv_id_seq OWNER TO admin; SET search_path = fixcountry, pg_catalog; -- -- Name: pkgpriv; Type: TABLE; Schema: fixcountry; Owner: admin; Tablespace: -- CREATE TABLE pkgpriv ( priv_id integer DEFAULT nextval('public.priv_priv_id_seq'::regclass) ) INHERITS (public.priv); ALTER TABLE pkgpriv OWNER TO admin; SET search_path = public, pg_catalog; -- -- Name: report; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE report ( report_id integer DEFAULT nextval(('report_report_id_seq'::text)::regclass) NOT NULL, report_name text, report_sys boolean, report_source text, report_descrip text, report_grade integer NOT NULL, report_loaddate timestamp without time zone ); ALTER TABLE report OWNER TO admin; -- -- Name: TABLE report; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE report IS 'Report definition information'; -- -- Name: report_report_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE report_report_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE report_report_id_seq OWNER TO admin; SET search_path = fixcountry, pg_catalog; -- -- Name: pkgreport; Type: TABLE; Schema: fixcountry; Owner: admin; Tablespace: -- CREATE TABLE pkgreport ( report_id integer DEFAULT nextval('public.report_report_id_seq'::regclass) ) INHERITS (public.report); ALTER TABLE pkgreport OWNER TO admin; SET search_path = public, pg_catalog; -- -- Name: script; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE script ( script_id integer NOT NULL, script_name text NOT NULL, script_order integer NOT NULL, script_enabled boolean DEFAULT false NOT NULL, script_source text NOT NULL, script_notes text ); ALTER TABLE script OWNER TO admin; -- -- Name: script_script_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE script_script_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE script_script_id_seq OWNER TO admin; -- -- Name: script_script_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE script_script_id_seq OWNED BY script.script_id; SET search_path = fixcountry, pg_catalog; -- -- Name: pkgscript; Type: TABLE; Schema: fixcountry; Owner: admin; Tablespace: -- CREATE TABLE pkgscript ( script_id integer DEFAULT nextval('public.script_script_id_seq'::regclass) ) INHERITS (public.script); ALTER TABLE pkgscript OWNER TO admin; SET search_path = public, pg_catalog; -- -- Name: uiform; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE uiform ( uiform_id integer NOT NULL, uiform_name text NOT NULL, uiform_order integer NOT NULL, uiform_enabled boolean DEFAULT false NOT NULL, uiform_source text NOT NULL, uiform_notes text ); ALTER TABLE uiform OWNER TO admin; -- -- Name: uiform_uiform_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE uiform_uiform_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE uiform_uiform_id_seq OWNER TO admin; -- -- Name: uiform_uiform_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE uiform_uiform_id_seq OWNED BY uiform.uiform_id; SET search_path = fixcountry, pg_catalog; -- -- Name: pkguiform; Type: TABLE; Schema: fixcountry; Owner: admin; Tablespace: -- CREATE TABLE pkguiform ( uiform_id integer DEFAULT nextval('public.uiform_uiform_id_seq'::regclass) ) INHERITS (public.uiform); ALTER TABLE pkguiform OWNER TO admin; SET search_path = public, pg_catalog; -- -- Name: acalitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE acalitem ( acalitem_id integer DEFAULT nextval(('"xcalitem_xcalitem_id_seq"'::text)::regclass) NOT NULL, acalitem_calhead_id integer, acalitem_periodstart date, acalitem_periodlength integer, acalitem_name text ); ALTER TABLE acalitem OWNER TO admin; -- -- Name: TABLE acalitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE acalitem IS 'Absolute Calendar Item information'; -- -- Name: accnt_accnt_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE accnt_accnt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE accnt_accnt_id_seq OWNER TO admin; -- -- Name: addr_addr_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE addr_addr_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE addr_addr_id_seq OWNER TO admin; -- -- Name: addr_addr_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE addr_addr_id_seq OWNED BY addr.addr_id; -- -- Name: address; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW address AS SELECT addr.addr_id, addr.addr_active, addr.addr_line1, addr.addr_line2, addr.addr_line3, addr.addr_city, addr.addr_state, addr.addr_postalcode, addr.addr_country, addr.addr_notes, addr.addr_number, COALESCE(addresses.crmacct_id, (-1)) AS crmacct_id, addresses.crmacct_number, addresses.crmacct_name FROM (addr LEFT JOIN ((((SELECT cntct.cntct_addr_id AS join_id, crmacct.crmacct_id, crmacct.crmacct_number, crmacct.crmacct_name FROM (cntct JOIN crmacct ON ((cntct.cntct_crmacct_id = crmacct.crmacct_id))) UNION SELECT vendinfo.vend_addr_id, crmacct.crmacct_id, crmacct.crmacct_number, crmacct.crmacct_name FROM (vendinfo JOIN crmacct ON ((vendinfo.vend_id = crmacct.crmacct_vend_id)))) UNION SELECT vendaddrinfo.vendaddr_addr_id, crmacct.crmacct_id, crmacct.crmacct_number, crmacct.crmacct_name FROM (vendaddrinfo JOIN crmacct ON ((vendaddrinfo.vendaddr_vend_id = crmacct.crmacct_vend_id)))) UNION SELECT taxauth.taxauth_addr_id, crmacct.crmacct_id, crmacct.crmacct_number, crmacct.crmacct_name FROM (taxauth JOIN crmacct ON ((taxauth.taxauth_id = crmacct.crmacct_taxauth_id)))) UNION SELECT shiptoinfo.shipto_addr_id, crmacct.crmacct_id, crmacct.crmacct_number, crmacct.crmacct_name FROM (shiptoinfo JOIN crmacct ON ((shiptoinfo.shipto_cust_id = crmacct.crmacct_cust_id)))) addresses ON ((addr.addr_id = addresses.join_id))); ALTER TABLE address OWNER TO admin; -- -- Name: alarm; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE alarm ( alarm_id integer NOT NULL, alarm_number text NOT NULL, alarm_event boolean DEFAULT false NOT NULL, alarm_email boolean DEFAULT false NOT NULL, alarm_sysmsg boolean DEFAULT false NOT NULL, alarm_trigger timestamp with time zone, alarm_time timestamp with time zone, alarm_time_offset integer, alarm_time_qualifier text, alarm_creator text, alarm_event_recipient text, alarm_email_recipient text, alarm_sysmsg_recipient text, alarm_source text, alarm_source_id integer ); ALTER TABLE alarm OWNER TO admin; -- -- Name: TABLE alarm; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE alarm IS 'This table is the open alarms.'; -- -- Name: alarm_alarm_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE alarm_alarm_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE alarm_alarm_id_seq OWNER TO admin; -- -- Name: alarm_alarm_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE alarm_alarm_id_seq OWNED BY alarm.alarm_id; -- -- Name: apaccnt; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE apaccnt ( apaccnt_id integer NOT NULL, apaccnt_vendtype_id integer, apaccnt_vendtype text, apaccnt_ap_accnt_id integer NOT NULL, apaccnt_prepaid_accnt_id integer, apaccnt_discount_accnt_id integer ); ALTER TABLE apaccnt OWNER TO admin; -- -- Name: TABLE apaccnt; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE apaccnt IS 'Accounts Payable (A/P) Account assignment information'; -- -- Name: apaccnt_apaccnt_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE apaccnt_apaccnt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE apaccnt_apaccnt_id_seq OWNER TO admin; -- -- Name: apaccnt_apaccnt_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE apaccnt_apaccnt_id_seq OWNED BY apaccnt.apaccnt_id; -- -- Name: apapply; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE apapply ( apapply_id integer NOT NULL, apapply_vend_id integer, apapply_postdate date, apapply_username text, apapply_source_apopen_id integer, apapply_source_doctype text, apapply_source_docnumber text, apapply_target_apopen_id integer, apapply_target_doctype text, apapply_target_docnumber text, apapply_journalnumber integer, apapply_amount numeric(20,2), apapply_curr_id integer DEFAULT basecurrid(), apapply_target_paid numeric(20,2), apapply_checkhead_id integer ); ALTER TABLE apapply OWNER TO admin; -- -- Name: TABLE apapply; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE apapply IS 'Applications (e.g., Payments, A/P Credit Memos) made to Accounts Payable (A/P) Documents'; -- -- Name: COLUMN apapply.apapply_source_apopen_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN apapply.apapply_source_apopen_id IS 'If apapply_source_doctype is "C" (credit memo) then apapply_source_apopen_id acts as a foreign key to the apopen table. If the source doctype is "K" (check) then the apapply_source_apopen_id acts as a foreign key to the checkhead table. If the apapply_source_apopen_id is -1 then the internal id of the source document is not known (always the case for checks posted before release 3.2.0BETA).'; -- -- Name: apapply_apapply_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE apapply_apapply_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE apapply_apapply_id_seq OWNER TO admin; -- -- Name: apapply_apapply_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE apapply_apapply_id_seq OWNED BY apapply.apapply_id; -- -- Name: checkhead; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE checkhead ( checkhead_id integer NOT NULL, checkhead_recip_id integer NOT NULL, checkhead_recip_type text NOT NULL, checkhead_bankaccnt_id integer NOT NULL, checkhead_printed boolean DEFAULT false NOT NULL, checkhead_checkdate date NOT NULL, checkhead_number integer NOT NULL, checkhead_amount numeric(20,2) NOT NULL, checkhead_void boolean DEFAULT false NOT NULL, checkhead_replaced boolean DEFAULT false NOT NULL, checkhead_posted boolean DEFAULT false NOT NULL, checkhead_rec boolean DEFAULT false NOT NULL, checkhead_misc boolean DEFAULT false NOT NULL, checkhead_expcat_id integer, checkhead_for text NOT NULL, checkhead_notes text NOT NULL, checkhead_journalnumber integer, checkhead_curr_id integer DEFAULT basecurrid() NOT NULL, checkhead_deleted boolean DEFAULT false NOT NULL, checkhead_ach_batch text, checkhead_curr_rate numeric NOT NULL, checkhead_alt_curr_rate numeric, CONSTRAINT checkhead_checkhead_amount_check CHECK ((checkhead_amount > (0)::numeric)), CONSTRAINT checkhead_checkhead_recip_type_check CHECK ((((checkhead_recip_type = 'C'::text) OR (checkhead_recip_type = 'V'::text)) OR (checkhead_recip_type = 'T'::text))) ); ALTER TABLE checkhead OWNER TO admin; -- -- Name: TABLE checkhead; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE checkhead IS 'Accounts Payable Check Information'; -- -- Name: apchk; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW apchk AS SELECT checkhead.checkhead_id AS apchk_id, checkhead.checkhead_recip_id AS apchk_vend_id, checkhead.checkhead_bankaccnt_id AS apchk_bankaccnt_id, checkhead.checkhead_printed AS apchk_printed, checkhead.checkhead_checkdate AS apchk_checkdate, checkhead.checkhead_number AS apchk_number, checkhead.checkhead_amount AS apchk_amount, checkhead.checkhead_void AS apchk_void, checkhead.checkhead_replaced AS apchk_replaced, checkhead.checkhead_posted AS apchk_posted, checkhead.checkhead_rec AS apchk_rec, checkhead.checkhead_misc AS apchk_misc, checkhead.checkhead_expcat_id AS apchk_expcat_id, checkhead.checkhead_for AS apchk_for, checkhead.checkhead_notes AS apchk_notes, checkhead.checkhead_journalnumber AS apchk_journalnumber, checkhead.checkhead_curr_id AS apchk_curr_id, checkhead.checkhead_deleted AS apchk_deleted FROM checkhead WHERE (checkhead.checkhead_recip_type = 'V'::text); ALTER TABLE apchk OWNER TO admin; -- -- Name: checkitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE checkitem ( checkitem_id integer NOT NULL, checkitem_checkhead_id integer NOT NULL, checkitem_amount numeric(20,2) DEFAULT 0.0 NOT NULL, checkitem_discount numeric(20,2) DEFAULT 0.0 NOT NULL, checkitem_ponumber text, checkitem_vouchernumber text, checkitem_invcnumber text, checkitem_apopen_id integer, checkitem_aropen_id integer, checkitem_docdate date, checkitem_curr_id integer DEFAULT basecurrid() NOT NULL, checkitem_cmnumber text, checkitem_ranumber text, checkitem_curr_rate numeric, CONSTRAINT checkitem_check CHECK ((NOT ((checkitem_apopen_id IS NOT NULL) AND (checkitem_aropen_id IS NOT NULL)))) ); ALTER TABLE checkitem OWNER TO admin; -- -- Name: TABLE checkitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE checkitem IS 'Accounts Payable Check Line Item Information'; -- -- Name: apchkitem; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW apchkitem AS SELECT checkitem.checkitem_id AS apchkitem_id, checkitem.checkitem_checkhead_id AS apchkitem_apchk_id, checkitem.checkitem_vouchernumber AS apchkitem_vouchernumber, checkitem.checkitem_ponumber AS apchkitem_ponumber, checkitem.checkitem_amount AS apchkitem_amount, checkitem.checkitem_invcnumber AS apchkitem_invcnumber, checkitem.checkitem_apopen_id AS apchkitem_apopen_id, checkitem.checkitem_docdate AS apchkitem_docdate, checkitem.checkitem_curr_id AS apchkitem_curr_id, checkitem.checkitem_discount AS apchkitem_discount FROM checkhead, checkitem WHERE ((checkitem.checkitem_checkhead_id = checkhead.checkhead_id) AND (checkhead.checkhead_recip_type = 'V'::text)); ALTER TABLE apchkitem OWNER TO admin; -- -- Name: apcreditapply; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE apcreditapply ( apcreditapply_id integer NOT NULL, apcreditapply_source_apopen_id integer, apcreditapply_target_apopen_id integer, apcreditapply_amount numeric(20,2), apcreditapply_curr_id integer DEFAULT basecurrid() ); ALTER TABLE apcreditapply OWNER TO admin; -- -- Name: TABLE apcreditapply; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE apcreditapply IS 'Temporary table for storing details of Accounts Payable (A/P) Credit Memo applications before those applications are posted'; -- -- Name: apcreditapply_apcreditapply_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE apcreditapply_apcreditapply_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE apcreditapply_apcreditapply_id_seq OWNER TO admin; -- -- Name: apcreditapply_apcreditapply_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE apcreditapply_apcreditapply_id_seq OWNED BY apcreditapply.apcreditapply_id; -- -- Name: apmemo; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW apmemo AS SELECT apopen.apopen_id, apopen.apopen_docnumber FROM apopen WHERE (apopen.apopen_doctype = ANY (ARRAY['D'::bpchar, 'C'::bpchar])); ALTER TABLE apmemo OWNER TO admin; -- -- Name: apopen_apopen_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE apopen_apopen_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE apopen_apopen_id_seq OWNER TO admin; -- -- Name: apopentax; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE apopentax ( ) INHERITS (taxhist); ALTER TABLE apopentax OWNER TO admin; -- -- Name: apselect; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE apselect ( apselect_id integer NOT NULL, apselect_apopen_id integer NOT NULL, apselect_amount numeric(20,2) NOT NULL, apselect_bankaccnt_id integer, apselect_curr_id integer DEFAULT basecurrid(), apselect_date date, apselect_discount numeric(20,2) DEFAULT 0.0 NOT NULL ); ALTER TABLE apselect OWNER TO admin; -- -- Name: TABLE apselect; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE apselect IS 'Temporary table for storing details of Accounts Payable (A/P) Payment selections'; -- -- Name: apselect_apselect_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE apselect_apselect_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE apselect_apselect_id_seq OWNER TO admin; -- -- Name: apselect_apselect_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE apselect_apselect_id_seq OWNED BY apselect.apselect_id; -- -- Name: araccnt; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE araccnt ( araccnt_id integer DEFAULT nextval(('araccnt_araccnt_id_seq'::text)::regclass) NOT NULL, araccnt_custtype_id integer, araccnt_custtype text, araccnt_freight_accnt_id integer, araccnt_ar_accnt_id integer, araccnt_prepaid_accnt_id integer, araccnt_deferred_accnt_id integer, araccnt_discount_accnt_id integer ); ALTER TABLE araccnt OWNER TO admin; -- -- Name: TABLE araccnt; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE araccnt IS 'Accounts Receivable (A/R) Account assignment information'; -- -- Name: araccnt_araccnt_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE araccnt_araccnt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE araccnt_araccnt_id_seq OWNER TO admin; -- -- Name: arapply; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE arapply ( arapply_id integer NOT NULL, arapply_postdate date, arapply_cust_id integer, arapply_source_doctype text, arapply_source_docnumber text, arapply_target_doctype text, arapply_target_docnumber text, arapply_fundstype text, arapply_refnumber text, arapply_applied numeric(20,2), arapply_closed boolean, arapply_journalnumber text, arapply_source_aropen_id integer, arapply_target_aropen_id integer, arapply_username text, arapply_curr_id integer DEFAULT basecurrid(), arapply_distdate date NOT NULL, arapply_target_paid numeric(20,2), arapply_reftype text, arapply_ref_id integer ); ALTER TABLE arapply OWNER TO admin; -- -- Name: TABLE arapply; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE arapply IS 'Applications (e.g., Cash Receipts, A/R Credit Memos) made to Accounts Receivable (A/R) Documents'; -- -- Name: arapply_arapply_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE arapply_arapply_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE arapply_arapply_id_seq OWNER TO admin; -- -- Name: arapply_arapply_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE arapply_arapply_id_seq OWNED BY arapply.arapply_id; -- -- Name: cashrcptitem_cashrcptitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cashrcptitem_cashrcptitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE cashrcptitem_cashrcptitem_id_seq OWNER TO admin; -- -- Name: cashrcptitem_cashrcptitem_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE cashrcptitem_cashrcptitem_id_seq OWNED BY cashrcptitem.cashrcptitem_id; -- -- Name: arcreditapply; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE arcreditapply ( arcreditapply_id integer DEFAULT nextval('cashrcptitem_cashrcptitem_id_seq'::regclass) NOT NULL, arcreditapply_source_aropen_id integer, arcreditapply_target_aropen_id integer, arcreditapply_amount numeric(20,2), arcreditapply_curr_id integer DEFAULT basecurrid(), arcreditapply_reftype text, arcreditapply_ref_id integer ); ALTER TABLE arcreditapply OWNER TO admin; -- -- Name: TABLE arcreditapply; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE arcreditapply IS 'Temporary table for storing details of Accounts Receivable (A/R) Credit Memo applications before those applications are posted'; -- -- Name: arcreditapply_arcreditapply_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE arcreditapply_arcreditapply_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE arcreditapply_arcreditapply_id_seq OWNER TO admin; -- -- Name: arcreditapply_arcreditapply_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE arcreditapply_arcreditapply_id_seq OWNED BY arcreditapply.arcreditapply_id; -- -- Name: armemo; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW armemo AS SELECT aropen.aropen_id, aropen.aropen_docnumber FROM aropen WHERE (aropen.aropen_doctype = ANY (ARRAY['D'::bpchar, 'C'::bpchar, 'R'::bpchar])) UNION SELECT cmhead.cmhead_id AS aropen_id, cmhead.cmhead_number AS aropen_docnumber FROM cmhead; ALTER TABLE armemo OWNER TO admin; -- -- Name: aropen_aropen_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE aropen_aropen_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE aropen_aropen_id_seq OWNER TO admin; -- -- Name: aropentax; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE aropentax ( ) INHERITS (taxhist); ALTER TABLE aropentax OWNER TO admin; -- -- Name: asohist; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE asohist ( asohist_id integer NOT NULL, asohist_cust_id integer, asohist_itemsite_id integer, asohist_shipdate date, asohist_invcdate date, asohist_duedate date, asohist_promisedate date, asohist_ordernumber text, asohist_invcnumber text, asohist_qtyshipped numeric(18,6), asohist_unitprice numeric(16,4), asohist_unitcost numeric(16,6), asohist_billtoname text, asohist_billtoaddress1 text, asohist_billtoaddress2 text, asohist_billtoaddress3 text, asohist_billtocity text, asohist_billtostate text, asohist_billtozip text, asohist_shiptoname text, asohist_shiptoaddress1 text, asohist_shiptoaddress2 text, asohist_shiptoaddress3 text, asohist_shiptocity text, asohist_shiptostate text, asohist_shiptozip text, asohist_shipto_id integer, asohist_shipvia text, asohist_salesrep_id integer, asohist_misc_type character(1), asohist_misc_descrip text, asohist_misc_id integer, asohist_commission numeric(16,4), asohist_commissionpaid boolean, asohist_doctype text, asohist_orderdate date, asohist_imported boolean, asohist_ponumber text, asohist_curr_id integer DEFAULT basecurrid(), asohist_taxtype_id integer, asohist_taxzone_id integer ); ALTER TABLE asohist OWNER TO admin; -- -- Name: TABLE asohist; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE asohist IS 'Archived Sales history'; -- -- Name: asohist_asohist_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE asohist_asohist_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE asohist_asohist_id_seq OWNER TO admin; -- -- Name: asohist_asohist_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE asohist_asohist_id_seq OWNED BY asohist.asohist_id; -- -- Name: asohisttax; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE asohisttax ( ) INHERITS (taxhist); ALTER TABLE asohisttax OWNER TO admin; -- -- Name: atlasmap; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE atlasmap ( atlasmap_id integer NOT NULL, atlasmap_name text NOT NULL, atlasmap_filter text NOT NULL, atlasmap_filtertype text NOT NULL, atlasmap_atlas text NOT NULL, atlasmap_map text NOT NULL, atlasmap_headerline boolean DEFAULT false NOT NULL, CONSTRAINT atlasmap_atlasmap_name_check CHECK ((atlasmap_name <> ''::text)) ); ALTER TABLE atlasmap OWNER TO admin; -- -- Name: TABLE atlasmap; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE atlasmap IS 'Describes heuristics for finding a CSVImp atlas for a given CSV file. When looking for a CSV Atlas to use when importing a CSV file, the first atlasmap record found that matches the CSV file is used to select the Atlas file and Map in that Atlas to import the CSV file.'; -- -- Name: COLUMN atlasmap.atlasmap_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN atlasmap.atlasmap_id IS 'The internal id of this CSVImp atlas mapping.'; -- -- Name: COLUMN atlasmap.atlasmap_name; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN atlasmap.atlasmap_name IS 'The human-readable name of this atlas mapping.'; -- -- Name: COLUMN atlasmap.atlasmap_filter; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN atlasmap.atlasmap_filter IS 'A regular expression that should match the CSV file. Which part of the file that matches is determined by the filter type.'; -- -- Name: COLUMN atlasmap.atlasmap_filtertype; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN atlasmap.atlasmap_filtertype IS 'A description of what aspect of the CSV file the filter should be compared with. Handled values are: ''filename'' - the filter is matched against the name of the file; and ''firstline'' - the filter is matched against the first line of the file contents.'; -- -- Name: COLUMN atlasmap.atlasmap_atlas; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN atlasmap.atlasmap_atlas IS 'The name of the CSVImp Atlas file. This should be a simple pathname, not an absolute or relative name if possible. The full path will be determined by concatenating the operating-system-specific CSV Atlas default directory with the value here unless this is an absolute pathname.'; -- -- Name: COLUMN atlasmap.atlasmap_map; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN atlasmap.atlasmap_map IS 'The name of the Map inside the Atlas to use if the filter and filter type match the CVS file.'; -- -- Name: COLUMN atlasmap.atlasmap_headerline; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN atlasmap.atlasmap_headerline IS 'An indicator of whether the first line of the CSV file should be treated as a header line or as data.'; -- -- Name: atlasmap_atlasmap_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE atlasmap_atlasmap_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE atlasmap_atlasmap_id_seq OWNER TO admin; -- -- Name: atlasmap_atlasmap_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE atlasmap_atlasmap_id_seq OWNED BY atlasmap.atlasmap_id; -- -- Name: backup_usr; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE backup_usr ( usr_id integer, usr_username text, usr_propername text, usr_passwd text, usr_locale_id integer, usr_initials text, usr_agent boolean, usr_active boolean, usr_email text, usr_dept_id integer, usr_shift_id integer, usr_window text ); ALTER TABLE backup_usr OWNER TO admin; -- -- Name: bankaccnt_bankaccnt_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE bankaccnt_bankaccnt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE bankaccnt_bankaccnt_id_seq OWNER TO admin; -- -- Name: bankaccnt_bankaccnt_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE bankaccnt_bankaccnt_id_seq OWNED BY bankaccnt.bankaccnt_id; -- -- Name: bankadj; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE bankadj ( bankadj_id integer NOT NULL, bankadj_bankaccnt_id integer NOT NULL, bankadj_bankadjtype_id integer NOT NULL, bankadj_created timestamp without time zone DEFAULT now() NOT NULL, bankadj_username text DEFAULT geteffectivextuser() NOT NULL, bankadj_date date NOT NULL, bankadj_docnumber text, bankadj_amount numeric(10,2) NOT NULL, bankadj_notes text, bankadj_sequence integer, bankadj_posted boolean DEFAULT false NOT NULL, bankadj_curr_id integer DEFAULT basecurrid(), bankadj_curr_rate numeric ); ALTER TABLE bankadj OWNER TO admin; -- -- Name: TABLE bankadj; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE bankadj IS 'Bank Adjustments information'; -- -- Name: bankadj_bankadj_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE bankadj_bankadj_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE bankadj_bankadj_id_seq OWNER TO admin; -- -- Name: bankadj_bankadj_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE bankadj_bankadj_id_seq OWNED BY bankadj.bankadj_id; -- -- Name: bankadjtype; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE bankadjtype ( bankadjtype_id integer NOT NULL, bankadjtype_name text NOT NULL, bankadjtype_descrip text, bankadjtype_accnt_id integer NOT NULL, bankadjtype_iscredit boolean DEFAULT false NOT NULL, CONSTRAINT bankadjtype_bankadjtype_name_check CHECK ((bankadjtype_name <> ''::text)) ); ALTER TABLE bankadjtype OWNER TO admin; -- -- Name: TABLE bankadjtype; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE bankadjtype IS 'Bank Adjustment Types information'; -- -- Name: bankadjtype_bankadjtype_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE bankadjtype_bankadjtype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE bankadjtype_bankadjtype_id_seq OWNER TO admin; -- -- Name: bankadjtype_bankadjtype_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE bankadjtype_bankadjtype_id_seq OWNED BY bankadjtype.bankadjtype_id; -- -- Name: bankrec; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE bankrec ( bankrec_id integer NOT NULL, bankrec_created timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL, bankrec_username text DEFAULT geteffectivextuser() NOT NULL, bankrec_bankaccnt_id integer, bankrec_opendate date, bankrec_enddate date, bankrec_openbal numeric(20,2), bankrec_endbal numeric(20,2), bankrec_posted boolean DEFAULT false, bankrec_postdate timestamp without time zone ); ALTER TABLE bankrec OWNER TO admin; -- -- Name: TABLE bankrec; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE bankrec IS 'Bank Reconciliation posting history'; -- -- Name: bankrec_bankrec_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE bankrec_bankrec_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE bankrec_bankrec_id_seq OWNER TO admin; -- -- Name: bankrec_bankrec_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE bankrec_bankrec_id_seq OWNED BY bankrec.bankrec_id; -- -- Name: bankrecimport; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE bankrecimport ( bankrecimport_id integer NOT NULL, bankrecimport_reference text, bankrecimport_descrip text, bankrecimport_comment text, bankrecimport_debit_amount numeric, bankrecimport_credit_amount numeric, bankrecimport_effdate date, bankrecimport_curr_rate numeric ); ALTER TABLE bankrecimport OWNER TO admin; -- -- Name: bankrecimport_bankrecimport_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE bankrecimport_bankrecimport_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE bankrecimport_bankrecimport_id_seq OWNER TO admin; -- -- Name: bankrecimport_bankrecimport_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE bankrecimport_bankrecimport_id_seq OWNED BY bankrecimport.bankrecimport_id; -- -- Name: bankrecitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE bankrecitem ( bankrecitem_id integer NOT NULL, bankrecitem_bankrec_id integer NOT NULL, bankrecitem_source text NOT NULL, bankrecitem_source_id integer NOT NULL, bankrecitem_cleared boolean DEFAULT false, bankrecitem_curr_rate numeric, bankrecitem_amount numeric, bankrecitem_effdate date ); ALTER TABLE bankrecitem OWNER TO admin; -- -- Name: TABLE bankrecitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE bankrecitem IS 'Posted Bank Reconciliation Line Item information'; -- -- Name: bankrecitem_bankrecitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE bankrecitem_bankrecitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE bankrecitem_bankrecitem_id_seq OWNER TO admin; -- -- Name: bankrecitem_bankrecitem_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE bankrecitem_bankrecitem_id_seq OWNED BY bankrecitem.bankrecitem_id; -- -- Name: bomhead_bomhead_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE bomhead_bomhead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE bomhead_bomhead_id_seq OWNER TO admin; -- -- Name: bomitem_bomitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE bomitem_bomitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE bomitem_bomitem_id_seq OWNER TO admin; -- -- Name: bomitemcost; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE bomitemcost ( bomitemcost_id integer NOT NULL, bomitemcost_bomitem_id integer NOT NULL, bomitemcost_costelem_id integer NOT NULL, bomitemcost_lowlevel boolean DEFAULT false NOT NULL, bomitemcost_stdcost numeric(16,6) DEFAULT 0 NOT NULL, bomitemcost_posted date, bomitemcost_actcost numeric(16,6) DEFAULT 0 NOT NULL, bomitemcost_updated date, bomitemcost_curr_id integer DEFAULT basecurrid() NOT NULL ); ALTER TABLE bomitemcost OWNER TO admin; -- -- Name: TABLE bomitemcost; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE bomitemcost IS 'Bomitem Cost information'; -- -- Name: bomitemcost_bomitemcost_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE bomitemcost_bomitemcost_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE bomitemcost_bomitemcost_id_seq OWNER TO admin; -- -- Name: bomitemcost_bomitemcost_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE bomitemcost_bomitemcost_id_seq OWNED BY bomitemcost.bomitemcost_id; -- -- Name: bomitemsub_bomitemsub_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE bomitemsub_bomitemsub_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE bomitemsub_bomitemsub_id_seq OWNER TO admin; -- -- Name: bomitemsub_bomitemsub_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE bomitemsub_bomitemsub_id_seq OWNED BY bomitemsub.bomitemsub_id; -- -- Name: bomwork; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE bomwork ( bomwork_id integer NOT NULL, bomwork_set_id integer, bomwork_seqnumber integer, bomwork_item_id integer, bomwork_item_type character(1), bomwork_qtyper numeric(20,8), bomwork_scrap numeric(20,10), bomwork_status character(1), bomwork_level integer, bomwork_parent_id integer, bomwork_effective date, bomwork_expires date, bomwork_stdunitcost numeric(16,6), bomwork_actunitcost numeric(16,6), bomwork_parent_seqnumber integer, bomwork_createwo boolean, bomwork_issuemethod character(1), bomwork_char_id integer, bomwork_value text, bomwork_notes text, bomwork_ref text, bomwork_bomitem_id integer, bomwork_ecn text, bomwork_qtyfxd numeric(20,8) DEFAULT 0 NOT NULL, bomwork_qtyreq numeric(20,8) DEFAULT 0 NOT NULL ); ALTER TABLE bomwork OWNER TO admin; -- -- Name: TABLE bomwork; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE bomwork IS 'Temporary table for storing information requested by Bill of Materials (BOM) displays and reports'; -- -- Name: COLUMN bomwork.bomwork_qtyfxd; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN bomwork.bomwork_qtyfxd IS 'The fixed quantity required'; -- -- Name: COLUMN bomwork.bomwork_qtyreq; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN bomwork.bomwork_qtyreq IS 'The total quantity required'; -- -- Name: bomwork_bomwork_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE bomwork_bomwork_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE bomwork_bomwork_id_seq OWNER TO admin; -- -- Name: bomwork_bomwork_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE bomwork_bomwork_id_seq OWNED BY bomwork.bomwork_id; -- -- Name: budget; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW budget AS SELECT budgitem.budgitem_id AS budget_id, budgitem.budgitem_period_id AS budget_period_id, budgitem.budgitem_accnt_id AS budget_accnt_id, budgitem.budgitem_amount AS budget_amount FROM budgitem; ALTER TABLE budget OWNER TO admin; -- -- Name: budghead_budghead_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE budghead_budghead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE budghead_budghead_id_seq OWNER TO admin; -- -- Name: budghead_budghead_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE budghead_budghead_id_seq OWNED BY budghead.budghead_id; -- -- Name: budgitem_budgitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE budgitem_budgitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE budgitem_budgitem_id_seq OWNER TO admin; -- -- Name: budgitem_budgitem_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE budgitem_budgitem_id_seq OWNED BY budgitem.budgitem_id; -- -- Name: calhead; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE calhead ( calhead_id integer DEFAULT nextval(('"calhead_calhead_id_seq"'::text)::regclass) NOT NULL, calhead_type character(1), calhead_name text NOT NULL, calhead_descrip text, calhead_origin character(1), CONSTRAINT calhead_calhead_name_check CHECK ((calhead_name <> ''::text)) ); ALTER TABLE calhead OWNER TO admin; -- -- Name: TABLE calhead; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE calhead IS 'Calendar header information'; -- -- Name: calhead_calhead_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE calhead_calhead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE calhead_calhead_id_seq OWNER TO admin; -- -- Name: carrier_carrier_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE carrier_carrier_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE carrier_carrier_id_seq OWNER TO admin; -- -- Name: cashrcpt_cashrcpt_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cashrcpt_cashrcpt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE cashrcpt_cashrcpt_id_seq OWNER TO admin; -- -- Name: cashrcpt_cashrcpt_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE cashrcpt_cashrcpt_id_seq OWNED BY cashrcpt.cashrcpt_id; -- -- Name: cashrcptmisc_cashrcptmisc_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cashrcptmisc_cashrcptmisc_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE cashrcptmisc_cashrcptmisc_id_seq OWNER TO admin; -- -- Name: cashrcptmisc_cashrcptmisc_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE cashrcptmisc_cashrcptmisc_id_seq OWNED BY cashrcptmisc.cashrcptmisc_id; -- -- Name: ccard_ccard_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE ccard_ccard_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE ccard_ccard_id_seq OWNER TO admin; -- -- Name: ccard_ccard_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE ccard_ccard_id_seq OWNED BY ccard.ccard_id; -- -- Name: ccardaud; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE ccardaud ( ccardaud_id integer NOT NULL, ccardaud_ccard_id integer, ccardaud_ccard_seq_old integer, ccardaud_ccard_seq_new integer, ccardaud_ccard_cust_id_old integer, ccardaud_ccard_cust_id_new integer, ccardaud_ccard_active_old boolean, ccardaud_ccard_active_new boolean, ccardaud_ccard_name_old bytea, ccardaud_ccard_name_new bytea, ccardaud_ccard_address1_old bytea, ccardaud_ccard_address1_new bytea, ccardaud_ccard_address2_old bytea, ccardaud_ccard_address2_new bytea, ccardaud_ccard_city_old bytea, ccardaud_ccard_city_new bytea, ccardaud_ccard_state_old bytea, ccardaud_ccard_state_new bytea, ccardaud_ccard_zip_old bytea, ccardaud_ccard_zip_new bytea, ccardaud_ccard_country_old bytea, ccardaud_ccard_country_new bytea, ccardaud_ccard_number_old bytea, ccardaud_ccard_number_new bytea, ccardaud_ccard_debit_old boolean, ccardaud_ccard_debit_new boolean, ccardaud_ccard_month_expired_old bytea, ccardaud_ccard_month_expired_new bytea, ccardaud_ccard_year_expired_old bytea, ccardaud_ccard_year_expired_new bytea, ccardaud_ccard_type_old character(1), ccardaud_ccard_type_new character(1), ccardaud_ccard_last_updated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL, ccardaud_ccard_last_updated_by_username text DEFAULT geteffectivextuser() NOT NULL ); ALTER TABLE ccardaud OWNER TO admin; -- -- Name: TABLE ccardaud; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE ccardaud IS 'Credit Card Information tracking data'; -- -- Name: ccardaud_ccardaud_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE ccardaud_ccardaud_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE ccardaud_ccardaud_id_seq OWNER TO admin; -- -- Name: ccardaud_ccardaud_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE ccardaud_ccardaud_id_seq OWNED BY ccardaud.ccardaud_id; -- -- Name: ccbank; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE ccbank ( ccbank_id integer NOT NULL, ccbank_ccard_type text NOT NULL, ccbank_bankaccnt_id integer, CONSTRAINT ccbank_ccbank_ccard_type_check CHECK ((ccbank_ccard_type = ANY (ARRAY['A'::text, 'D'::text, 'M'::text, 'P'::text, 'V'::text, 'O'::text]))) ); ALTER TABLE ccbank OWNER TO admin; -- -- Name: ccbank_ccbank_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE ccbank_ccbank_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE ccbank_ccbank_id_seq OWNER TO admin; -- -- Name: ccbank_ccbank_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE ccbank_ccbank_id_seq OWNED BY ccbank.ccbank_id; -- -- Name: ccpay; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE ccpay ( ccpay_id integer NOT NULL, ccpay_ccard_id integer, ccpay_cust_id integer, ccpay_amount numeric(20,2) DEFAULT 0.00 NOT NULL, ccpay_auth boolean DEFAULT true NOT NULL, ccpay_status character(1) NOT NULL, ccpay_type character(1) NOT NULL, ccpay_auth_charge character(1) NOT NULL, ccpay_order_number text, ccpay_order_number_seq integer, ccpay_r_avs text, ccpay_r_ordernum text, ccpay_r_error text, ccpay_r_approved text, ccpay_r_code text, ccpay_r_message text, ccpay_yp_r_time timestamp without time zone, ccpay_r_ref text, ccpay_yp_r_tdate text, ccpay_r_tax text, ccpay_r_shipping text, ccpay_yp_r_score integer, ccpay_transaction_datetime timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL, ccpay_by_username text DEFAULT geteffectivextuser() NOT NULL, ccpay_curr_id integer DEFAULT basecurrid(), ccpay_ccpay_id integer, ccpay_card_pan_trunc text, ccpay_card_type text ); ALTER TABLE ccpay OWNER TO admin; -- -- Name: TABLE ccpay; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE ccpay IS 'Track Credit Card PAYments, although really this table tracs communications with Credit Card processing companies. Records in this table may progress from preauthorizations through captures to credits, or they may simply remain in their original state if there is no further processing.'; -- -- Name: COLUMN ccpay.ccpay_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_id IS 'Internal ID of this ccpay record.'; -- -- Name: COLUMN ccpay.ccpay_ccard_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_ccard_id IS 'Internal ID of the Credit Card used for this transaction.'; -- -- Name: COLUMN ccpay.ccpay_cust_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_cust_id IS 'Internal ID of the Customer owning the Credit Card'; -- -- Name: COLUMN ccpay.ccpay_amount; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_amount IS 'Actual amount of this transaction.'; -- -- Name: COLUMN ccpay.ccpay_auth; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_auth IS 'Boolean indicator of whether this transaction started out as a pre-authorization or not.'; -- -- Name: COLUMN ccpay.ccpay_status; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_status IS 'The status of the last attempted transaction for this record. Values include A = Authorized, C = Charged, D = Declined or otherwise rejected, V = Voided, X = Error.'; -- -- Name: COLUMN ccpay.ccpay_type; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_type IS 'The most recent type of transaction attempted with this record. Values include A = Authorize, C = Capture or Charge, R = cRedit, V = reVerse or Void.'; -- -- Name: COLUMN ccpay.ccpay_auth_charge; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_auth_charge IS 'The original type of transaction attempted with this record. Values are the same as for ccpay_type.'; -- -- Name: COLUMN ccpay.ccpay_order_number; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_order_number IS 'The original xTuple ERP order for which this credit card transaction applies. This will usually be either a Sales Order number or Credit Memo number.'; -- -- Name: COLUMN ccpay.ccpay_order_number_seq; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_order_number_seq IS 'A sequence number to differentiate between different transactions for the same ccpay_order_number. For example, if a Customer makes a down payment and a final payment for a single order, there will be two distinct ccpay records with the same ccpay_order_number but different ccpay_order_number_seq values (1 and 2, respectively).'; -- -- Name: COLUMN ccpay.ccpay_r_avs; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_r_avs IS 'The Address Verification System code returned by the credit card processing company.'; -- -- Name: COLUMN ccpay.ccpay_r_ordernum; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_r_ordernum IS 'A transaction ID returned by the credit card processing company to be used when referring to this transaction later. It may be used for voiding, crediting, or capturing previous transactions.'; -- -- Name: COLUMN ccpay.ccpay_r_error; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_r_error IS 'Error message, if any, describing why this record failed to be processed properly.'; -- -- Name: COLUMN ccpay.ccpay_r_approved; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_r_approved IS 'English text stating whether the transaction was approved, declined, hit an error, or was held for review. Specific values differ depending on the credit card processor.'; -- -- Name: COLUMN ccpay.ccpay_r_code; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_r_code IS 'The transaction Approval code returned by the credit card processor. Specific values differ depending on the credit card processor.'; -- -- Name: COLUMN ccpay.ccpay_r_message; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_r_message IS 'Additional text that describes the status of the transaction. This may be empty.'; -- -- Name: COLUMN ccpay.ccpay_yp_r_time; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_yp_r_time IS 'The time the transaction was posted according to the credit card processing company. May be blank.'; -- -- Name: COLUMN ccpay.ccpay_r_ref; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_r_ref IS 'An additional reference number assigned to this transaction by the credit card processing company.'; -- -- Name: COLUMN ccpay.ccpay_yp_r_tdate; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_yp_r_tdate IS 'The date the transaction was posted according to the credit card processing company. May be blank.'; -- -- Name: COLUMN ccpay.ccpay_r_tax; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_r_tax IS '[ deprecated ]'; -- -- Name: COLUMN ccpay.ccpay_r_shipping; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_r_shipping IS '[ deprecated ]'; -- -- Name: COLUMN ccpay.ccpay_yp_r_score; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_yp_r_score IS 'A potential fraud score returned by the credit card company. May be blank.'; -- -- Name: COLUMN ccpay.ccpay_transaction_datetime; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_transaction_datetime IS 'The date and time this record was created, unless explicitly set by the application.'; -- -- Name: COLUMN ccpay.ccpay_by_username; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_by_username IS 'The user who created this record, unless explicitly set by the application.'; -- -- Name: COLUMN ccpay.ccpay_curr_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_curr_id IS 'The internal ID of the currency of the ccpay_amount.'; -- -- Name: COLUMN ccpay.ccpay_ccpay_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_ccpay_id IS 'Foreign key to another ccpay record. This will have a value if a new ccpay record is created to record a Refund for part or all of another ccpay record.'; -- -- Name: COLUMN ccpay.ccpay_card_pan_trunc; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_card_pan_trunc IS 'External Pre-Auth truncated PAN. Last four digits of the card.'; -- -- Name: COLUMN ccpay.ccpay_card_type; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN ccpay.ccpay_card_type IS 'External Pre-Auth card type: V=Visa, M=MasterCard, A=American Express, D=Discover.'; -- -- Name: ccpay_ccpay_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE ccpay_ccpay_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE ccpay_ccpay_id_seq OWNER TO admin; -- -- Name: ccpay_ccpay_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE ccpay_ccpay_id_seq OWNED BY ccpay.ccpay_id; -- -- Name: char_char_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE char_char_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE char_char_id_seq OWNER TO admin; -- -- Name: char_char_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE char_char_id_seq OWNED BY "char".char_id; -- -- Name: charass_charass_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE charass_charass_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE charass_charass_id_seq OWNER TO admin; -- -- Name: charass_charass_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE charass_charass_id_seq OWNED BY charass.charass_id; -- -- Name: charopt; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE charopt ( charopt_id integer NOT NULL, charopt_char_id integer, charopt_value text NOT NULL, charopt_order integer DEFAULT 0 NOT NULL ); ALTER TABLE charopt OWNER TO admin; -- -- Name: TABLE charopt; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE charopt IS 'Stores list options for characteristics'; -- -- Name: COLUMN charopt.charopt_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN charopt.charopt_id IS 'Primary key'; -- -- Name: COLUMN charopt.charopt_char_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN charopt.charopt_char_id IS 'Reference to char table'; -- -- Name: COLUMN charopt.charopt_value; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN charopt.charopt_value IS 'Option value'; -- -- Name: COLUMN charopt.charopt_order; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN charopt.charopt_order IS 'Option sort order'; -- -- Name: charopt_charopt_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE charopt_charopt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE charopt_charopt_id_seq OWNER TO admin; -- -- Name: charopt_charopt_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE charopt_charopt_id_seq OWNED BY charopt.charopt_id; -- -- Name: charuse; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE charuse ( charuse_id integer NOT NULL, charuse_char_id integer, charuse_target_type text DEFAULT ''::text NOT NULL, charuse_created timestamp with time zone DEFAULT now() NOT NULL, charuse_last_modified timestamp with time zone DEFAULT now() NOT NULL ); ALTER TABLE charuse OWNER TO admin; -- -- Name: COLUMN charuse.charuse_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN charuse.charuse_id IS 'Internal ID of this charuse record.'; -- -- Name: COLUMN charuse.charuse_target_type; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN charuse.charuse_target_type IS 'If a row exists in the charuse table for a given target type, characteristic assignments can be used'; -- -- Name: charuse_charuse_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE charuse_charuse_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE charuse_charuse_id_seq OWNER TO admin; -- -- Name: charuse_charuse_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE charuse_charuse_id_seq OWNED BY charuse.charuse_id; -- -- Name: checkhead_checkhead_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE checkhead_checkhead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE checkhead_checkhead_id_seq OWNER TO admin; -- -- Name: checkhead_checkhead_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE checkhead_checkhead_id_seq OWNED BY checkhead.checkhead_id; -- -- Name: checkitem_checkitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE checkitem_checkitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE checkitem_checkitem_id_seq OWNER TO admin; -- -- Name: checkitem_checkitem_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE checkitem_checkitem_id_seq OWNED BY checkitem.checkitem_id; -- -- Name: checkrecip; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW checkrecip AS (SELECT custinfo.cust_id AS checkrecip_id, 'C'::text AS checkrecip_type, custinfo.cust_number AS checkrecip_number, custinfo.cust_name AS checkrecip_name, 'A/R'::text AS checkrecip_gltrans_source, findaraccount(custinfo.cust_id) AS checkrecip_accnt_id, cntct.cntct_addr_id AS checkrecip_addr_id FROM (custinfo LEFT JOIN cntct ON ((custinfo.cust_cntct_id = cntct.cntct_id))) UNION ALL SELECT taxauth.taxauth_id AS checkrecip_id, 'T'::text AS checkrecip_type, taxauth.taxauth_code AS checkrecip_number, taxauth.taxauth_name AS checkrecip_name, 'G/L'::text AS checkrecip_gltrans_source, taxauth.taxauth_accnt_id AS checkrecip_accnt_id, taxauth.taxauth_addr_id AS checkrecip_addr_id FROM taxauth) UNION ALL SELECT vendinfo.vend_id AS checkrecip_id, 'V'::text AS checkrecip_type, vendinfo.vend_number AS checkrecip_number, vendinfo.vend_name AS checkrecip_name, 'A/P'::text AS checkrecip_gltrans_source, findapaccount(vendinfo.vend_id) AS checkrecip_accnt_id, vendaddrinfo.vendaddr_addr_id AS checkrecip_addr_id FROM (vendinfo LEFT JOIN vendaddrinfo ON (((vendinfo.vend_id = vendaddrinfo.vendaddr_vend_id) AND (upper(vendaddrinfo.vendaddr_code) = 'REMIT'::text)))); ALTER TABLE checkrecip OWNER TO admin; -- -- Name: classcode_classcode_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE classcode_classcode_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE classcode_classcode_id_seq OWNER TO admin; -- -- Name: cmhead_cmhead_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cmhead_cmhead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE cmhead_cmhead_id_seq OWNER TO admin; -- -- Name: cmheadtax; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cmheadtax ( ) INHERITS (taxhist); ALTER TABLE cmheadtax OWNER TO admin; -- -- Name: cmitem_cmitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cmitem_cmitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE cmitem_cmitem_id_seq OWNER TO admin; -- -- Name: cmitemtax; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cmitemtax ( ) INHERITS (taxhist); ALTER TABLE cmitemtax OWNER TO admin; -- -- Name: cmnttype_cmnttype_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cmnttype_cmnttype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE cmnttype_cmnttype_id_seq OWNER TO admin; -- -- Name: cmnttype_cmnttype_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE cmnttype_cmnttype_id_seq OWNED BY cmnttype.cmnttype_id; -- -- Name: cmnttypesource; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cmnttypesource ( cmnttypesource_id integer NOT NULL, cmnttypesource_cmnttype_id integer NOT NULL, cmnttypesource_source_id integer NOT NULL ); ALTER TABLE cmnttypesource OWNER TO admin; -- -- Name: TABLE cmnttypesource; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE cmnttypesource IS 'Description of which types of comment the user should be allowed to select for various types of document (source).'; -- -- Name: cmnttypesource_cmnttypesource_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cmnttypesource_cmnttypesource_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE cmnttypesource_cmnttypesource_id_seq OWNER TO admin; -- -- Name: cmnttypesource_cmnttypesource_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE cmnttypesource_cmnttypesource_id_seq OWNED BY cmnttypesource.cmnttypesource_id; -- -- Name: cntct_cntct_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cntct_cntct_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE cntct_cntct_id_seq OWNER TO admin; -- -- Name: cntct_cntct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE cntct_cntct_id_seq OWNED BY cntct.cntct_id; -- -- Name: cntctaddr; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cntctaddr ( cntctaddr_id integer NOT NULL, cntctaddr_cntct_id integer, cntctaddr_primary boolean NOT NULL, cntctaddr_addr_id integer NOT NULL, cntctaddr_type character(2) NOT NULL ); ALTER TABLE cntctaddr OWNER TO admin; -- -- Name: cntctaddr_cntctaddr_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cntctaddr_cntctaddr_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE cntctaddr_cntctaddr_id_seq OWNER TO admin; -- -- Name: cntctaddr_cntctaddr_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE cntctaddr_cntctaddr_id_seq OWNED BY cntctaddr.cntctaddr_id; -- -- Name: cntctdata; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cntctdata ( cntctdata_id integer NOT NULL, cntctdata_cntct_id integer, cntctdata_primary boolean NOT NULL, cntctdata_text text NOT NULL, cntctdata_type character(2) NOT NULL ); ALTER TABLE cntctdata OWNER TO admin; -- -- Name: cntctdata_cntctdata_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cntctdata_cntctdata_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE cntctdata_cntctdata_id_seq OWNER TO admin; -- -- Name: cntctdata_cntctdata_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE cntctdata_cntctdata_id_seq OWNED BY cntctdata.cntctdata_id; -- -- Name: cntcteml; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cntcteml ( cntcteml_id integer NOT NULL, cntcteml_cntct_id integer, cntcteml_primary boolean DEFAULT false NOT NULL, cntcteml_email text NOT NULL ); ALTER TABLE cntcteml OWNER TO admin; -- -- Name: TABLE cntcteml; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE cntcteml IS 'Stores email addresses for contacts'; -- -- Name: COLUMN cntcteml.cntcteml_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN cntcteml.cntcteml_id IS 'Primary key'; -- -- Name: COLUMN cntcteml.cntcteml_cntct_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN cntcteml.cntcteml_cntct_id IS 'Reference to contact table'; -- -- Name: COLUMN cntcteml.cntcteml_primary; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN cntcteml.cntcteml_primary IS 'Flags whether this is the primary email address'; -- -- Name: COLUMN cntcteml.cntcteml_email; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN cntcteml.cntcteml_email IS 'Alternate information'; -- -- Name: cntcteml_cntcteml_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cntcteml_cntcteml_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE cntcteml_cntcteml_id_seq OWNER TO admin; -- -- Name: cntcteml_cntcteml_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE cntcteml_cntcteml_id_seq OWNED BY cntcteml.cntcteml_id; -- -- Name: cntctmrgd; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cntctmrgd ( cntctmrgd_cntct_id integer NOT NULL, cntctmrgd_error boolean DEFAULT false ); ALTER TABLE cntctmrgd OWNER TO admin; -- -- Name: cntctsel; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cntctsel ( cntctsel_cntct_id integer NOT NULL, cntctsel_target boolean, cntctsel_mrg_crmacct_id boolean DEFAULT false, cntctsel_mrg_addr_id boolean DEFAULT false, cntctsel_mrg_first_name boolean DEFAULT false, cntctsel_mrg_last_name boolean DEFAULT false, cntctsel_mrg_honorific boolean DEFAULT false, cntctsel_mrg_initials boolean DEFAULT false, cntctsel_mrg_phone boolean DEFAULT false, cntctsel_mrg_phone2 boolean DEFAULT false, cntctsel_mrg_fax boolean DEFAULT false, cntctsel_mrg_email boolean DEFAULT false, cntctsel_mrg_webaddr boolean DEFAULT false, cntctsel_mrg_notes boolean DEFAULT false, cntctsel_mrg_title boolean DEFAULT false, cntctsel_mrg_middle boolean DEFAULT false, cntctsel_mrg_suffix boolean DEFAULT false, cntctsel_mrg_owner_username boolean DEFAULT false ); ALTER TABLE cntctsel OWNER TO admin; -- -- Name: cntslip_cntslip_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cntslip_cntslip_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE cntslip_cntslip_id_seq OWNER TO admin; -- -- Name: cobill; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cobill ( cobill_id integer DEFAULT nextval(('cobill_cobill_id_seq'::text)::regclass) NOT NULL, cobill_coitem_id integer, cobill_selectdate timestamp with time zone, cobill_qty numeric(18,6), cobill_invcnum integer, cobill_toclose boolean, cobill_cobmisc_id integer, cobill_select_username text, cobill_invcitem_id integer, cobill_taxtype_id integer ); ALTER TABLE cobill OWNER TO admin; -- -- Name: TABLE cobill; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE cobill IS 'Billing Selection Line Item information'; -- -- Name: cobill_cobill_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cobill_cobill_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE cobill_cobill_id_seq OWNER TO admin; -- -- Name: cobilltax; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cobilltax ( ) INHERITS (taxhist); ALTER TABLE cobilltax OWNER TO admin; -- -- Name: cobmisc; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cobmisc ( cobmisc_id integer DEFAULT nextval(('cobmisc_cobmisc_id_seq'::text)::regclass) NOT NULL, cobmisc_cohead_id integer, cobmisc_shipvia text, cobmisc_freight numeric(16,4), cobmisc_misc numeric(16,4), cobmisc_payment numeric(16,4), cobmisc_paymentref text, cobmisc_notes text, cobmisc_shipdate date, cobmisc_invcnumber integer, cobmisc_invcdate date, cobmisc_posted boolean, cobmisc_misc_accnt_id integer, cobmisc_misc_descrip text, cobmisc_closeorder boolean, cobmisc_curr_id integer DEFAULT basecurrid(), cobmisc_invchead_id integer, cobmisc_taxzone_id integer, cobmisc_taxtype_id integer ); ALTER TABLE cobmisc OWNER TO admin; -- -- Name: TABLE cobmisc; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE cobmisc IS 'General information about Billing Selections'; -- -- Name: cobmisc_cobmisc_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cobmisc_cobmisc_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE cobmisc_cobmisc_id_seq OWNER TO admin; -- -- Name: cobmisctax; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE cobmisctax ( ) INHERITS (taxhist); ALTER TABLE cobmisctax OWNER TO admin; -- -- Name: cohead_cohead_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cohead_cohead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE cohead_cohead_id_seq OWNER TO admin; -- -- Name: cohist_cohist_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cohist_cohist_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE cohist_cohist_id_seq OWNER TO admin; -- -- Name: coitem_coitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE coitem_coitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE coitem_coitem_id_seq OWNER TO admin; -- -- Name: comment_comment_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE comment_comment_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE comment_comment_id_seq OWNER TO admin; -- -- Name: company; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE company ( company_id integer NOT NULL, company_number text NOT NULL, company_descrip text, company_external boolean DEFAULT false NOT NULL, company_server text, company_port integer, company_database text, company_curr_id integer, company_yearend_accnt_id integer, company_gainloss_accnt_id integer, company_dscrp_accnt_id integer, company_unrlzgainloss_accnt_id integer, company_unassigned_accnt_id integer, CONSTRAINT company_company_number_check CHECK ((company_number <> ''::text)) ); ALTER TABLE company OWNER TO admin; -- -- Name: TABLE company; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE company IS 'Company information'; -- -- Name: company_company_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE company_company_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE company_company_id_seq OWNER TO admin; -- -- Name: company_company_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE company_company_id_seq OWNED BY company.company_id; -- -- Name: contrct_contrct_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE contrct_contrct_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE contrct_contrct_id_seq OWNER TO admin; -- -- Name: contrct_contrct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE contrct_contrct_id_seq OWNED BY contrct.contrct_id; -- -- Name: shiphead; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE shiphead ( shiphead_id integer NOT NULL, shiphead_order_id integer NOT NULL, shiphead_order_type text NOT NULL, shiphead_number text NOT NULL, shiphead_shipvia text, shiphead_freight numeric(16,4) DEFAULT 0.0 NOT NULL, shiphead_freight_curr_id integer DEFAULT basecurrid() NOT NULL, shiphead_notes text, shiphead_shipped boolean DEFAULT false NOT NULL, shiphead_shipdate date, shiphead_shipchrg_id integer, shiphead_shipform_id integer, shiphead_sfstatus character(1) NOT NULL, shiphead_tracknum text, CONSTRAINT shiphead_shiphead_number_check CHECK ((shiphead_number <> ''::text)), CONSTRAINT shiphead_shiphead_order_type_check CHECK (((shiphead_order_type = 'SO'::text) OR (shiphead_order_type = 'TO'::text))), CONSTRAINT shiphead_shiphead_sfstatus_check CHECK ((((shiphead_sfstatus = 'D'::bpchar) OR (shiphead_sfstatus = 'N'::bpchar)) OR (shiphead_sfstatus = 'P'::bpchar))) ); ALTER TABLE shiphead OWNER TO admin; -- -- Name: TABLE shiphead; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE shiphead IS 'General information about Shipments'; -- -- Name: shipitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE shipitem ( shipitem_id integer NOT NULL, shipitem_orderitem_id integer NOT NULL, shipitem_shiphead_id integer NOT NULL, shipitem_qty numeric(18,6) NOT NULL, shipitem_shipped boolean DEFAULT false NOT NULL, shipitem_shipdate timestamp with time zone, shipitem_transdate timestamp with time zone, shipitem_trans_username text, shipitem_invoiced boolean DEFAULT false NOT NULL, shipitem_invcitem_id integer, shipitem_value numeric(18,6), shipitem_invhist_id integer ); ALTER TABLE shipitem OWNER TO admin; -- -- Name: TABLE shipitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE shipitem IS 'Information about Shipment Line Items'; -- -- Name: coship; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW coship AS SELECT shipitem.shipitem_id AS coship_id, shipitem.shipitem_orderitem_id AS coship_coitem_id, shipitem.shipitem_shipdate AS coship_shipdate, shipitem.shipitem_qty AS coship_qty, shipitem.shipitem_transdate AS coship_transdate, shipitem.shipitem_shipped AS coship_shipped, shipitem.shipitem_invoiced AS coship_invoiced, shipitem.shipitem_shiphead_id AS coship_cosmisc_id, shipitem.shipitem_trans_username AS coship_trans_username, shipitem.shipitem_invcitem_id AS coship_invcitem_id FROM shipitem, shiphead WHERE ((shipitem.shipitem_shiphead_id = shiphead.shiphead_id) AND (shiphead.shiphead_order_type = 'SO'::text)); ALTER TABLE coship OWNER TO admin; -- -- Name: coship_coship_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE coship_coship_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE coship_coship_id_seq OWNER TO admin; -- -- Name: cosmisc; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW cosmisc AS SELECT shiphead.shiphead_id AS cosmisc_id, shiphead.shiphead_order_id AS cosmisc_cohead_id, shiphead.shiphead_shipvia AS cosmisc_shipvia, shiphead.shiphead_freight AS cosmisc_freight, shiphead.shiphead_notes AS cosmisc_notes, shiphead.shiphead_shipdate AS cosmisc_shipdate, shiphead.shiphead_shipchrg_id AS cosmisc_shipchrg_id, shiphead.shiphead_shipform_id AS cosmisc_shipform_id, shiphead.shiphead_shipped AS cosmisc_shipped, shiphead.shiphead_sfstatus AS cosmisc_sfstatus, shiphead.shiphead_tracknum AS cosmisc_tracknum, shiphead.shiphead_number AS cosmisc_number FROM shiphead WHERE (shiphead.shiphead_order_type = 'SO'::text); ALTER TABLE cosmisc OWNER TO admin; -- -- Name: cosmisc_cosmisc_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cosmisc_cosmisc_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE cosmisc_cosmisc_id_seq OWNER TO admin; -- -- Name: cosrc_cosrc_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cosrc_cosrc_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE cosrc_cosrc_id_seq OWNER TO admin; -- -- Name: costcat_costcat_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE costcat_costcat_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE costcat_costcat_id_seq OWNER TO admin; -- -- Name: costelem_costelem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE costelem_costelem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE costelem_costelem_id_seq OWNER TO admin; -- -- Name: costhist; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE costhist ( costhist_id integer DEFAULT nextval(('"costhist_costhist_id_seq"'::text)::regclass) NOT NULL, costhist_item_id integer, costhist_costelem_id integer, costhist_type character(1), costhist_date timestamp with time zone, costhist_oldcost numeric(16,6), costhist_newcost numeric(16,6), costhist_lowlevel boolean, costhist_oldcurr_id integer DEFAULT basecurrid(), costhist_newcurr_id integer DEFAULT basecurrid(), costhist_username text ); ALTER TABLE costhist OWNER TO admin; -- -- Name: TABLE costhist; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE costhist IS 'Item Cost history'; -- -- Name: costhist_costhist_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE costhist_costhist_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE costhist_costhist_id_seq OWNER TO admin; -- -- Name: costupdate; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE costupdate ( costupdate_item_id integer, costupdate_lowlevel_code integer DEFAULT 1 NOT NULL, costupdate_item_type character(1) ); ALTER TABLE costupdate OWNER TO admin; -- -- Name: TABLE costupdate; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE costupdate IS 'Scratch area for sequencing the updating of item costs'; -- -- Name: country; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE country ( country_id integer NOT NULL, country_abbr character(2), country_name text, country_curr_abbr character(3), country_curr_name text, country_curr_number character(3), country_curr_symbol character varying(9), country_qt_number integer, CONSTRAINT country_country_abbr_check CHECK ((country_abbr <> ''::bpchar)), CONSTRAINT country_country_name_check CHECK ((country_name <> ''::text)) ); ALTER TABLE country OWNER TO admin; -- -- Name: TABLE country; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE country IS 'Basic information and properties about countries.'; -- -- Name: country_country_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE country_country_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE country_country_id_seq OWNER TO admin; -- -- Name: country_country_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE country_country_id_seq OWNED BY country.country_id; -- -- Name: salesaccnt; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE salesaccnt ( salesaccnt_id integer DEFAULT nextval(('"salesaccnt_salesaccnt_id_seq"'::text)::regclass) NOT NULL, salesaccnt_custtype_id integer, salesaccnt_prodcat_id integer, salesaccnt_warehous_id integer, salesaccnt_sales_accnt_id integer, salesaccnt_credit_accnt_id integer, salesaccnt_cos_accnt_id integer, salesaccnt_custtype text, salesaccnt_prodcat text, salesaccnt_returns_accnt_id integer, salesaccnt_cor_accnt_id integer, salesaccnt_cow_accnt_id integer, salesaccnt_saletype_id integer, salesaccnt_shipzone_id integer ); ALTER TABLE salesaccnt OWNER TO admin; -- -- Name: TABLE salesaccnt; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE salesaccnt IS 'Sales Account assignment information'; -- -- Name: COLUMN salesaccnt.salesaccnt_saletype_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN salesaccnt.salesaccnt_saletype_id IS 'Associated sale type for sales account.'; -- -- Name: COLUMN salesaccnt.salesaccnt_shipzone_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN salesaccnt.salesaccnt_shipzone_id IS 'Associated shipping zone for sales account.'; -- -- Name: creditmemoeditlist; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW creditmemoeditlist AS ((((SELECT cmhead.cmhead_id AS orderid, (-2) AS itemid, ('C/M-'::text || formatcreditmemonumber(cmhead.cmhead_id)) AS documentnumber, custinfo.cust_number, cmhead.cmhead_billtoname AS billtoname, cmhead.cmhead_number AS ordernumber, (-1) AS linenumber, ''::text AS item, ''::text AS itemdescrip, ''::text AS iteminvuom, ''::text AS qtytobill, ''::text AS price, formatmoney((((calccmheadamt(cmhead.cmhead_id) + cmhead.cmhead_freight) + cmhead.cmhead_misc) + calccmheadtax(cmhead.cmhead_id))) AS extprice, 'Credit'::text AS sence, COALESCE((SELECT formatglaccountlong(accnt.accnt_id) AS formatglaccountlong FROM accnt WHERE (accnt.accnt_id = findaraccount(custinfo.cust_id))), 'Not Assigned'::text) AS account FROM custinfo, cmhead WHERE ((((cmhead.cmhead_cust_id = custinfo.cust_id) AND (cmhead.cmhead_cust_id = custinfo.cust_id)) AND (NOT cmhead.cmhead_posted)) AND (NOT cmhead.cmhead_hold)) UNION SELECT cmhead.cmhead_id AS orderid, (-1) AS itemid, ''::text AS documentnumber, ''::text AS cust_number, ''::text AS billtoname, cmhead.cmhead_number AS ordernumber, (-1) AS linenumber, 'Freight'::text AS item, 'Freight Charge'::text AS itemdescrip, ''::text AS iteminvuom, ''::text AS qtytobill, formatmoney(cmhead.cmhead_freight) AS price, formatmoney(cmhead.cmhead_freight) AS extprice, 'Debit'::text AS sence, CASE WHEN (accnt.accnt_id IS NULL) THEN 'Not Assigned'::text ELSE formatglaccountlong(accnt.accnt_id) END AS account FROM (cmhead LEFT JOIN accnt ON ((accnt.accnt_id = findfreightaccount(cmhead.cmhead_cust_id)))) WHERE (((NOT cmhead.cmhead_posted) AND (NOT cmhead.cmhead_hold)) AND (cmhead.cmhead_freight <> (0)::numeric))) UNION SELECT cmhead.cmhead_id AS orderid, (-1) AS itemid, ''::text AS documentnumber, ''::text AS cust_number, ''::text AS billtoname, cmhead.cmhead_number AS ordernumber, (-1) AS linenumber, 'Misc. Charge'::text AS item, cmhead.cmhead_misc_descrip AS itemdescrip, ''::text AS iteminvuom, ''::text AS qtytobill, formatmoney(cmhead.cmhead_misc) AS price, formatmoney(cmhead.cmhead_misc) AS extprice, 'Debit'::text AS sence, formatglaccountlong(cmhead.cmhead_misc_accnt_id) AS account FROM cmhead WHERE (((NOT cmhead.cmhead_posted) AND (NOT cmhead.cmhead_hold)) AND (cmhead.cmhead_misc <> (0)::numeric))) UNION SELECT cmhead.cmhead_id AS orderid, (-1) AS itemid, ''::text AS documentnumber, ''::text AS cust_number, ''::text AS billtoname, cmhead.cmhead_number AS ordernumber, (-1) AS linenumber, 'Sales Tax'::text AS item, tax.tax_descrip AS itemdescrip, ''::text AS iteminvuom, ''::text AS qtytobill, formatmoney((cmheadtax.taxhist_tax * (-1.0))) AS price, formatmoney((cmheadtax.taxhist_tax * (-1.0))) AS extprice, 'Debit'::text AS sence, CASE WHEN (accnt.accnt_id IS NULL) THEN 'Not Assigned'::text ELSE ((formatglaccountlong(accnt.accnt_id) || ' - '::text) || accnt.accnt_descrip) END AS account FROM (((cmhead JOIN cmheadtax ON ((cmheadtax.taxhist_parent_id = cmhead.cmhead_id))) JOIN tax ON ((tax.tax_id = cmheadtax.taxhist_tax_id))) LEFT JOIN accnt ON ((accnt.accnt_id = tax.tax_sales_accnt_id))) WHERE ((NOT cmhead.cmhead_posted) AND (NOT cmhead.cmhead_hold))) UNION SELECT cmhead.cmhead_id AS orderid, (-1) AS itemid, ''::text AS documentnumber, ''::text AS cust_number, ''::text AS billtoname, cmhead.cmhead_number AS ordernumber, (-1) AS linenumber, 'Sales Tax'::text AS item, tax.tax_descrip AS itemdescrip, ''::text AS iteminvuom, ''::text AS qtytobill, formatmoney((cmitemtax.taxhist_tax * (-1.0))) AS price, formatmoney((cmitemtax.taxhist_tax * (-1.0))) AS extprice, 'Debit'::text AS sence, CASE WHEN (accnt.accnt_id IS NULL) THEN 'Not Assigned'::text ELSE ((formatglaccountlong(accnt.accnt_id) || ' - '::text) || accnt.accnt_descrip) END AS account FROM ((((cmhead JOIN cmitem ON ((cmitem.cmitem_cmhead_id = cmhead.cmhead_id))) JOIN cmitemtax ON ((cmitemtax.taxhist_parent_id = cmitem.cmitem_id))) JOIN tax ON ((tax.tax_id = cmitemtax.taxhist_tax_id))) LEFT JOIN accnt ON ((accnt.accnt_id = tax.tax_sales_accnt_id))) WHERE ((NOT cmhead.cmhead_posted) AND (NOT cmhead.cmhead_hold))) UNION SELECT cmhead.cmhead_id AS orderid, cmitem.cmitem_id AS itemid, ''::text AS documentnumber, ''::text AS cust_number, ''::text AS billtoname, cmhead.cmhead_number AS ordernumber, cmitem.cmitem_linenumber AS linenumber, item.item_number AS item, item.item_descrip1 AS itemdescrip, uom.uom_name AS iteminvuom, formatqty(COALESCE((cmitem.cmitem_qtycredit * cmitem.cmitem_qty_invuomratio), (0)::numeric)) AS qtytobill, formatprice(COALESCE((cmitem.cmitem_unitprice / cmitem.cmitem_price_invuomratio), (0)::numeric)) AS price, formatmoney(COALESCE(round(((cmitem.cmitem_qtycredit * cmitem.cmitem_qty_invuomratio) * (cmitem.cmitem_unitprice / cmitem.cmitem_price_invuomratio)), 2), (0)::numeric)) AS extprice, 'Debit'::text AS sence, COALESCE((SELECT formatglaccountlong(accnt.accnt_id) AS formatglaccountlong FROM accnt, salesaccnt WHERE ((salesaccnt.salesaccnt_sales_accnt_id = accnt.accnt_id) AND (salesaccnt.salesaccnt_id = findsalesaccnt(cmitem.cmitem_itemsite_id, 'IS'::text, cmhead.cmhead_cust_id, cmhead.cmhead_saletype_id, cmhead.cmhead_shipzone_id)))), 'Not Assigned'::text) AS account FROM item, itemsite, cmhead, cmitem, uom WHERE ((((((cmitem.cmitem_cmhead_id = cmhead.cmhead_id) AND (cmitem.cmitem_itemsite_id = itemsite.itemsite_id)) AND (itemsite.itemsite_item_id = item.item_id)) AND (item.item_inv_uom_id = uom.uom_id)) AND (NOT cmhead.cmhead_posted)) AND (NOT cmhead.cmhead_hold)) ORDER BY 6, 7; ALTER TABLE creditmemoeditlist OWNER TO admin; -- -- Name: creditmemoitem; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW creditmemoitem AS SELECT cmitem.cmitem_id, cmitem.cmitem_cmhead_id, cmitem.cmitem_linenumber, cmitem.cmitem_itemsite_id, cmitem.cmitem_qtycredit, cmitem.cmitem_qtyreturned, cmitem.cmitem_unitprice, cmitem.cmitem_comments, cmitem.cmitem_rsncode_id, cmitem.cmitem_taxtype_id, cmitem.cmitem_qty_uom_id, cmitem.cmitem_qty_invuomratio, cmitem.cmitem_price_uom_id, cmitem.cmitem_price_invuomratio, cmitem.cmitem_raitem_id, cmitem.cmitem_updateinv, itemsite.itemsite_item_id AS item_id, COALESCE((cmitem.cmitem_qtycredit * cmitem.cmitem_qty_invuomratio), (0)::numeric) AS qty, COALESCE((cmitem.cmitem_unitprice / cmitem.cmitem_price_invuomratio), (0)::numeric) AS unitprice, COALESCE(round(((cmitem.cmitem_qtycredit * cmitem.cmitem_qty_invuomratio) * (cmitem.cmitem_unitprice / cmitem.cmitem_price_invuomratio)), 2), (0)::numeric) AS extprice, currtobase(cmhead.cmhead_curr_id, COALESCE(round(((cmitem.cmitem_qtycredit * cmitem.cmitem_qty_invuomratio) * (cmitem.cmitem_unitprice / cmitem.cmitem_price_invuomratio)), 2), (0)::numeric), cmhead.cmhead_docdate) AS baseextprice, (SELECT COALESCE(sum(cmitemtax.taxhist_tax), (0)::numeric) AS "coalesce" FROM cmitemtax WHERE (cmitemtax.taxhist_parent_id = cmitem.cmitem_id)) AS tax, CASE WHEN (itemsite.itemsite_costmethod = 'A'::bpchar) THEN avgcost(itemsite.itemsite_id) ELSE stdcost(itemsite.itemsite_item_id) END AS unitcost FROM ((cmitem JOIN cmhead ON ((cmhead.cmhead_id = cmitem.cmitem_cmhead_id))) LEFT JOIN itemsite ON ((itemsite.itemsite_id = cmitem.cmitem_itemsite_id))); ALTER TABLE creditmemoitem OWNER TO admin; -- -- Name: VIEW creditmemoitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON VIEW creditmemoitem IS 'Single point for credit memo item (cmitem) calculations.'; -- -- Name: crmacct_crmacct_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE crmacct_crmacct_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE crmacct_crmacct_id_seq OWNER TO admin; -- -- Name: crmacct_crmacct_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE crmacct_crmacct_id_seq OWNED BY crmacct.crmacct_id; -- -- Name: crmacctsel; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE crmacctsel ( crmacctsel_src_crmacct_id integer NOT NULL, crmacctsel_dest_crmacct_id integer, crmacctsel_mrg_crmacct_active boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_cntct_id_1 boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_cntct_id_2 boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_competitor_id boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_cust_id boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_emp_id boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_name boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_notes boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_owner_username boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_parent_id boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_partner_id boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_prospect_id boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_salesrep_id boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_taxauth_id boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_type boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_usr_username boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_vend_id boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_number boolean DEFAULT false NOT NULL ); ALTER TABLE crmacctsel OWNER TO admin; -- -- Name: TABLE crmacctsel; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE crmacctsel IS 'This table records the proposed conditions of a CRM Account merge. When this merge is performed, the BOOLEAN columns in this table indicate which values in the crmacct table will be copied to the target record. Data in this table are temporary and will be removed by a purge.'; -- -- Name: COLUMN crmacctsel.crmacctsel_src_crmacct_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacctsel.crmacctsel_src_crmacct_id IS 'This is the internal ID of the CRM Account record the data will come from during the merge.'; -- -- Name: COLUMN crmacctsel.crmacctsel_dest_crmacct_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN crmacctsel.crmacctsel_dest_crmacct_id IS 'This is the internal ID of the CRM Account record the data will go to during the merge. If crmacctsel_src_crmacct_id = crmacctsel_dest_crmacct_id, they indicate which crmacct record is the destination of the merge, meaning this is the record that will remain in the database after the merge has been completed and the intermediate data have been purged.'; -- -- Name: curr_rate; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE curr_rate ( curr_rate_id integer NOT NULL, curr_id integer NOT NULL, curr_rate numeric(16,8) NOT NULL, curr_effective date NOT NULL, curr_expires date NOT NULL, CONSTRAINT curr_rate_curr_rate_check CHECK ((curr_rate > (0)::numeric)) ); ALTER TABLE curr_rate OWNER TO admin; -- -- Name: TABLE curr_rate; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE curr_rate IS 'Exchange Rates Between Base and Foreign Currencies'; -- -- Name: curr_rate_curr_rate_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE curr_rate_curr_rate_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE curr_rate_curr_rate_id_seq OWNER TO admin; -- -- Name: curr_rate_curr_rate_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE curr_rate_curr_rate_id_seq OWNED BY curr_rate.curr_rate_id; -- -- Name: curr_symbol_curr_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE curr_symbol_curr_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE curr_symbol_curr_id_seq OWNER TO admin; -- -- Name: curr_symbol_curr_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE curr_symbol_curr_id_seq OWNED BY curr_symbol.curr_id; -- -- Name: cust; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW cust AS SELECT custinfo.cust_id, custinfo.cust_active, custinfo.cust_custtype_id, custinfo.cust_salesrep_id, custinfo.cust_commprcnt, custinfo.cust_name, m.addr_line1 AS cust_address1, m.addr_line2 AS cust_address2, m.addr_line3 AS cust_address3, m.addr_city AS cust_city, m.addr_state AS cust_state, m.addr_postalcode AS cust_zipcode, btrim(((mc.cntct_first_name || ' '::text) || mc.cntct_last_name)) AS cust_contact, mc.cntct_phone AS cust_phone, mc.cntct_fax AS cust_fax, mc.cntct_email AS cust_email, c.addr_line1 AS cust_corraddress1, c.addr_line2 AS cust_corraddress2, c.addr_line3 AS cust_corraddress3, c.addr_city AS cust_corrcity, c.addr_state AS cust_corrstate, c.addr_postalcode AS cust_corrzipcode, btrim(((cc.cntct_first_name || ' '::text) || cc.cntct_last_name)) AS cust_corrcontact, cc.cntct_phone AS cust_corrphone, cc.cntct_fax AS cust_corrfax, cc.cntct_email AS cust_corremail, custinfo.cust_creditlmt, custinfo.cust_creditrating, custinfo.cust_financecharge, custinfo.cust_backorder, custinfo.cust_partialship, custinfo.cust_terms_id, custinfo.cust_discntprcnt, custinfo.cust_taxzone_id, custinfo.cust_balmethod, custinfo.cust_ffshipto, custinfo.cust_shipform_id, custinfo.cust_shipvia, custinfo.cust_blanketpos, custinfo.cust_shipchrg_id, custinfo.cust_creditstatus, custinfo.cust_comments, custinfo.cust_ffbillto, m.addr_country AS cust_country, c.addr_country AS cust_corrcountry, custinfo.cust_usespos, custinfo.cust_number, custinfo.cust_dateadded, custinfo.cust_exported, custinfo.cust_emaildelivery, custinfo.cust_ediemail, custinfo.cust_edisubject, custinfo.cust_edifilename, custinfo.cust_ediemailbody, custinfo.cust_autoupdatestatus, custinfo.cust_autoholdorders, custinfo.cust_edicc, custinfo.cust_ediprofile_id, custinfo.cust_preferred_warehous_id, custinfo.cust_curr_id, custinfo.cust_creditlmt_curr_id FROM ((((custinfo LEFT JOIN cntct mc ON ((custinfo.cust_cntct_id = mc.cntct_id))) LEFT JOIN addr m ON ((mc.cntct_addr_id = m.addr_id))) LEFT JOIN cntct cc ON ((custinfo.cust_corrcntct_id = cc.cntct_id))) LEFT JOIN addr c ON ((cc.cntct_addr_id = c.addr_id))); ALTER TABLE cust OWNER TO admin; -- -- Name: cust_serial_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE cust_serial_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE cust_serial_seq OWNER TO admin; -- -- Name: custform; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE custform ( custform_id integer DEFAULT nextval(('"custform_custform_id_seq"'::text)::regclass) NOT NULL, custform_custtype_id integer, custform_custtype text, custform_invoice_report_id integer, custform_creditmemo_report_id integer, custform_quote_report_id integer, custform_packinglist_report_id integer, custform_statement_report_id integer, custform_sopicklist_report_id integer, custform_invoice_report_name text, custform_creditmemo_report_name text, custform_quote_report_name text, custform_packinglist_report_name text, custform_statement_report_name text, custform_sopicklist_report_name text ); ALTER TABLE custform OWNER TO admin; -- -- Name: TABLE custform; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE custform IS 'Customer Form assignment information'; -- -- Name: COLUMN custform.custform_invoice_report_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN custform.custform_invoice_report_id IS 'Obsolete -- reference custform_invoice_report_name instead.'; -- -- Name: COLUMN custform.custform_creditmemo_report_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN custform.custform_creditmemo_report_id IS 'Obsolete -- reference custform_creditmemo_report_name instead.'; -- -- Name: COLUMN custform.custform_quote_report_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN custform.custform_quote_report_id IS 'Obsolete -- reference custform_quote_report_name instead.'; -- -- Name: COLUMN custform.custform_packinglist_report_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN custform.custform_packinglist_report_id IS 'Obsolete -- reference custform_packinglist_report_name instead.'; -- -- Name: COLUMN custform.custform_statement_report_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN custform.custform_statement_report_id IS 'Obsolete -- reference custform_statement_report_name instead.'; -- -- Name: COLUMN custform.custform_sopicklist_report_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN custform.custform_sopicklist_report_id IS 'Obsolete -- reference custform_sopicklist_report_name instead.'; -- -- Name: custform_custform_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE custform_custform_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE custform_custform_id_seq OWNER TO admin; -- -- Name: custgrp; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE custgrp ( custgrp_id integer DEFAULT nextval(('"custgrp_custgrp_id_seq"'::text)::regclass) NOT NULL, custgrp_name text NOT NULL, custgrp_descrip text, CONSTRAINT custgrp_custgrp_name_check CHECK ((custgrp_name <> ''::text)) ); ALTER TABLE custgrp OWNER TO admin; -- -- Name: TABLE custgrp; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE custgrp IS 'Customer Group information'; -- -- Name: custgrp_custgrp_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE custgrp_custgrp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE custgrp_custgrp_id_seq OWNER TO admin; -- -- Name: custgrpitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE custgrpitem ( custgrpitem_id integer DEFAULT nextval(('"custgrpitem_custgrpitem_id_seq"'::text)::regclass) NOT NULL, custgrpitem_custgrp_id integer, custgrpitem_cust_id integer ); ALTER TABLE custgrpitem OWNER TO admin; -- -- Name: TABLE custgrpitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE custgrpitem IS 'Customer Group Item information'; -- -- Name: custgrpitem_custgrpitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE custgrpitem_custgrpitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE custgrpitem_custgrpitem_id_seq OWNER TO admin; -- -- Name: custtype_custtype_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE custtype_custtype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE custtype_custtype_id_seq OWNER TO admin; -- -- Name: dept_dept_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE dept_dept_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE dept_dept_id_seq OWNER TO admin; -- -- Name: dept_dept_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE dept_dept_id_seq OWNED BY dept.dept_id; -- -- Name: destination; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE destination ( destination_id integer DEFAULT nextval(('"destination_destination_id_seq"'::text)::regclass) NOT NULL, destination_name text, destination_city text, destination_state text, destination_comments text ); ALTER TABLE destination OWNER TO admin; -- -- Name: TABLE destination; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE destination IS 'Destination information'; -- -- Name: destination_destination_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE destination_destination_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE destination_destination_id_seq OWNER TO admin; -- -- Name: docinfo; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW docinfo AS SELECT outer_wrapper.id, outer_wrapper.target_number, outer_wrapper.target_type, outer_wrapper.target_id, outer_wrapper.source_type_docinfo, outer_wrapper.source_id_docinfo, outer_wrapper.name, outer_wrapper.description, outer_wrapper.purpose, outer_wrapper.source_type, outer_wrapper.source_id FROM (SELECT (unnest(inner_wrapper._docinfo)).id AS id, (unnest(inner_wrapper._docinfo)).target_number AS target_number, (unnest(inner_wrapper._docinfo)).target_type AS target_type, (unnest(inner_wrapper._docinfo)).target_id AS target_id, (unnest(inner_wrapper._docinfo)).source_type AS source_type_docinfo, (unnest(inner_wrapper._docinfo)).source_id AS source_id_docinfo, (unnest(inner_wrapper._docinfo)).name AS name, (unnest(inner_wrapper._docinfo)).description AS description, (unnest(inner_wrapper._docinfo)).purpose AS purpose, inner_wrapper.source_type, inner_wrapper.source_id FROM (SELECT docinfo.docass_source_type, docinfo.docass_source_id, docinfo.source_type, docinfo.source_id, ARRAY(SELECT _docinfo(docinfo.docass_source_id, docinfo.docass_source_type) AS _docinfo) AS _docinfo FROM (SELECT docass.docass_source_type, docass.docass_source_id, docass.docass_source_type AS source_type, docass.docass_source_id AS source_id FROM docass) docinfo) inner_wrapper) outer_wrapper; ALTER TABLE docinfo OWNER TO admin; -- -- Name: emp_emp_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE emp_emp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE emp_emp_id_seq OWNER TO admin; -- -- Name: emp_emp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE emp_emp_id_seq OWNED BY emp.emp_id; -- -- Name: empgrp; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE empgrp ( empgrp_id integer NOT NULL, empgrp_name text NOT NULL, empgrp_descrip text NOT NULL, CONSTRAINT empgrp_empgrp_name_check CHECK ((empgrp_name <> ''::text)) ); ALTER TABLE empgrp OWNER TO admin; -- -- Name: empgrp_empgrp_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE empgrp_empgrp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE empgrp_empgrp_id_seq OWNER TO admin; -- -- Name: empgrp_empgrp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE empgrp_empgrp_id_seq OWNED BY empgrp.empgrp_id; -- -- Name: empgrpitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE empgrpitem ( empgrpitem_id integer NOT NULL, empgrpitem_empgrp_id integer NOT NULL, empgrpitem_emp_id integer NOT NULL ); ALTER TABLE empgrpitem OWNER TO admin; -- -- Name: empgrpitem_empgrpitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE empgrpitem_empgrpitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE empgrpitem_empgrpitem_id_seq OWNER TO admin; -- -- Name: empgrpitem_empgrpitem_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE empgrpitem_empgrpitem_id_seq OWNED BY empgrpitem.empgrpitem_id; -- -- Name: evntlog; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE evntlog ( evntlog_id integer DEFAULT nextval(('evntlog_evntlog_id_seq'::text)::regclass) NOT NULL, evntlog_evnttime timestamp with time zone, evntlog_evnttype_id integer, evntlog_ord_id integer, evntlog_dispatched timestamp with time zone, evntlog_action text, evntlog_warehous_id integer, evntlog_number text, evntlog_newvalue numeric(20,10), evntlog_oldvalue numeric(20,10), evntlog_newdate date, evntlog_olddate date, evntlog_ordtype character(2), evntlog_username text ); ALTER TABLE evntlog OWNER TO admin; -- -- Name: TABLE evntlog; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE evntlog IS 'Event Notification history'; -- -- Name: evntlog_evntlog_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE evntlog_evntlog_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE evntlog_evntlog_id_seq OWNER TO admin; -- -- Name: evntnot; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE evntnot ( evntnot_id integer DEFAULT nextval(('evntnot_evntnot_id_seq'::text)::regclass) NOT NULL, evntnot_evnttype_id integer, evntnot_warehous_id integer, evntnot_username text ); ALTER TABLE evntnot OWNER TO admin; -- -- Name: TABLE evntnot; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE evntnot IS 'Temporary table for storing information about user Event Notification selections'; -- -- Name: evntnot_evntnot_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE evntnot_evntnot_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE evntnot_evntnot_id_seq OWNER TO admin; -- -- Name: evnttype; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE evnttype ( evnttype_id integer DEFAULT nextval(('evnttype_evnttype_id_seq'::text)::regclass) NOT NULL, evnttype_name text NOT NULL, evnttype_descrip text, evnttype_module text, CONSTRAINT evnttype_evnttype_name_check CHECK ((evnttype_name <> ''::text)) ); ALTER TABLE evnttype OWNER TO admin; -- -- Name: TABLE evnttype; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE evnttype IS 'Event Type information'; -- -- Name: evnttype_evnttype_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE evnttype_evnttype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE evnttype_evnttype_id_seq OWNER TO admin; -- -- Name: expcat_expcat_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE expcat_expcat_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE expcat_expcat_id_seq OWNER TO admin; -- -- Name: expcat_expcat_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE expcat_expcat_id_seq OWNED BY expcat.expcat_id; -- -- Name: file_file_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE file_file_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE file_file_id_seq OWNER TO admin; -- -- Name: file_file_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE file_file_id_seq OWNED BY file.file_id; -- -- Name: filter; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE filter ( filter_id integer NOT NULL, filter_screen text NOT NULL, filter_value text NOT NULL, filter_username text, filter_name text NOT NULL, filter_selected boolean DEFAULT false ); ALTER TABLE filter OWNER TO admin; -- -- Name: filter_filter_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE filter_filter_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE filter_filter_id_seq OWNER TO admin; -- -- Name: filter_filter_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE filter_filter_id_seq OWNED BY filter.filter_id; -- -- Name: fincharg; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE fincharg ( fincharg_id integer NOT NULL, fincharg_mincharg numeric NOT NULL, fincharg_graceperiod integer NOT NULL, fincharg_assessoverdue boolean NOT NULL, fincharg_calcfrom integer NOT NULL, fincharg_markoninvoice text NOT NULL, fincharg_air numeric NOT NULL, fincharg_accnt_id integer NOT NULL, fincharg_salescat_id integer NOT NULL, fincharg_lastfc_statementcyclefrom text, fincharg_lastfc_custidfrom text, fincharg_lastfc_custidto text, fincharg_lastfc_statementcycleto text ); ALTER TABLE fincharg OWNER TO admin; -- -- Name: TABLE fincharg; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE fincharg IS 'Finance Charge configuration information'; -- -- Name: fincharg_fincharg_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE fincharg_fincharg_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE fincharg_fincharg_id_seq OWNER TO admin; -- -- Name: fincharg_fincharg_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE fincharg_fincharg_id_seq OWNED BY fincharg.fincharg_id; -- -- Name: flhead; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE flhead ( flhead_id integer NOT NULL, flhead_name text NOT NULL, flhead_descrip text, flhead_showtotal boolean DEFAULT false NOT NULL, flhead_showstart boolean DEFAULT true NOT NULL, flhead_showend boolean DEFAULT true NOT NULL, flhead_showdelta boolean DEFAULT true NOT NULL, flhead_showbudget boolean DEFAULT true NOT NULL, flhead_showdiff boolean DEFAULT false NOT NULL, flhead_showcustom boolean DEFAULT false NOT NULL, flhead_custom_label text, flhead_usealttotal boolean DEFAULT false NOT NULL, flhead_alttotal text, flhead_usealtbegin boolean DEFAULT false NOT NULL, flhead_altbegin text, flhead_usealtend boolean DEFAULT false NOT NULL, flhead_altend text, flhead_usealtdebits boolean DEFAULT false NOT NULL, flhead_altdebits text, flhead_usealtcredits boolean DEFAULT false NOT NULL, flhead_altcredits text, flhead_usealtbudget boolean DEFAULT false NOT NULL, flhead_altbudget text, flhead_usealtdiff boolean DEFAULT false NOT NULL, flhead_altdiff text, flhead_type character(1) DEFAULT 'A'::bpchar NOT NULL, flhead_active boolean DEFAULT true NOT NULL, flhead_sys boolean DEFAULT false, flhead_notes text DEFAULT ''::text, CONSTRAINT flhead_flhead_name_check CHECK ((flhead_name <> ''::text)) ); ALTER TABLE flhead OWNER TO admin; -- -- Name: TABLE flhead; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE flhead IS 'Financial Layout header information'; -- -- Name: flitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE flitem ( flitem_id integer NOT NULL, flitem_flhead_id integer, flitem_flgrp_id integer, flitem_order integer, flitem_accnt_id integer, flitem_showstart boolean, flitem_showend boolean, flitem_showdelta boolean, flitem_showbudget boolean DEFAULT false NOT NULL, flitem_subtract boolean DEFAULT false NOT NULL, flitem_showstartprcnt boolean DEFAULT false NOT NULL, flitem_showendprcnt boolean DEFAULT false NOT NULL, flitem_showdeltaprcnt boolean DEFAULT false NOT NULL, flitem_showbudgetprcnt boolean DEFAULT false NOT NULL, flitem_prcnt_flgrp_id integer DEFAULT (-1) NOT NULL, flitem_showdiff boolean DEFAULT false NOT NULL, flitem_showdiffprcnt boolean DEFAULT false NOT NULL, flitem_showcustom boolean DEFAULT false NOT NULL, flitem_showcustomprcnt boolean DEFAULT false NOT NULL, flitem_custom_source character(1), flitem_company text, flitem_profit text, flitem_number text, flitem_sub text, flitem_type character(1), flitem_subaccnttype_code text ); ALTER TABLE flitem OWNER TO admin; -- -- Name: TABLE flitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE flitem IS 'Financial Layout Account information'; -- -- Name: flaccnt; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW flaccnt AS SELECT flhead.flhead_type, flitem.flitem_id, flitem.flitem_flhead_id, flitem.flitem_flgrp_id, flitem.flitem_order, flitem.flitem_accnt_id, flitem.flitem_showstart, flitem.flitem_showend, flitem.flitem_showdelta, flitem.flitem_showbudget, flitem.flitem_subtract, flitem.flitem_showstartprcnt, flitem.flitem_showendprcnt, flitem.flitem_showdeltaprcnt, flitem.flitem_showbudgetprcnt, flitem.flitem_prcnt_flgrp_id, flitem.flitem_showdiff, flitem.flitem_showdiffprcnt, flitem.flitem_showcustom, flitem.flitem_showcustomprcnt, flitem.flitem_custom_source, flitem.flitem_company, flitem.flitem_profit, flitem.flitem_number, flitem.flitem_sub, flitem.flitem_type, flitem.flitem_subaccnttype_code, accnt.accnt_id, accnt.accnt_type, accnt.accnt_company, accnt.accnt_profit, accnt.accnt_number, accnt.accnt_sub, (-1) AS prj_id FROM ((flhead JOIN flitem ON ((flhead.flhead_id = flitem.flitem_flhead_id))) JOIN accnt ON ((flitem.flitem_accnt_id = accnt.accnt_id))) UNION ALL SELECT flhead.flhead_type, flitem.flitem_id, flitem.flitem_flhead_id, flitem.flitem_flgrp_id, flitem.flitem_order, flitem.flitem_accnt_id, flitem.flitem_showstart, flitem.flitem_showend, flitem.flitem_showdelta, flitem.flitem_showbudget, flitem.flitem_subtract, flitem.flitem_showstartprcnt, flitem.flitem_showendprcnt, flitem.flitem_showdeltaprcnt, flitem.flitem_showbudgetprcnt, flitem.flitem_prcnt_flgrp_id, flitem.flitem_showdiff, flitem.flitem_showdiffprcnt, flitem.flitem_showcustom, flitem.flitem_showcustomprcnt, flitem.flitem_custom_source, flitem.flitem_company, flitem.flitem_profit, flitem.flitem_number, flitem.flitem_sub, flitem.flitem_type, flitem.flitem_subaccnttype_code, accnt.accnt_id, accnt.accnt_type, accnt.accnt_company, accnt.accnt_profit, accnt.accnt_number, accnt.accnt_sub, (-1) AS prj_id FROM (flhead JOIN flitem ON ((flhead.flhead_id = flitem.flitem_flhead_id))), accnt WHERE (((((((flitem.flitem_accnt_id = (-1)) AND ((flitem.flitem_type = ''::bpchar) OR (accnt.accnt_type = flitem.flitem_type))) AND ((flitem.flitem_company = 'All'::text) OR (accnt.accnt_company = flitem.flitem_company))) AND ((flitem.flitem_profit = 'All'::text) OR (accnt.accnt_profit = flitem.flitem_profit))) AND ((flitem.flitem_number = 'All'::text) OR (accnt.accnt_number = flitem.flitem_number))) AND ((flitem.flitem_sub = 'All'::text) OR (accnt.accnt_sub = flitem.flitem_sub))) AND ((flitem.flitem_subaccnttype_code = 'All'::text) OR (accnt.accnt_subaccnttype_code = flitem.flitem_subaccnttype_code))) ORDER BY 30, 31, 32, 33; ALTER TABLE flaccnt OWNER TO admin; -- -- Name: flcol; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE flcol ( flcol_id integer NOT NULL, flcol_flhead_id integer NOT NULL, flcol_name text, flcol_descrip text, flcol_report_id integer, flcol_month boolean, flcol_quarter boolean, flcol_year boolean, flcol_showdb boolean, flcol_prcnt boolean, flcol_priortype character(1), flcol_priormonth boolean, flcol_priorquarter boolean, flcol_prioryear character(1), flcol_priorprcnt boolean, flcol_priordiff boolean, flcol_priordiffprcnt boolean, flcol_budget boolean, flcol_budgetprcnt boolean, flcol_budgetdiff boolean, flcol_budgetdiffprcnt boolean ); ALTER TABLE flcol OWNER TO admin; -- -- Name: flcol_flcol_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE flcol_flcol_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE flcol_flcol_id_seq OWNER TO admin; -- -- Name: flcol_flcol_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE flcol_flcol_id_seq OWNED BY flcol.flcol_id; -- -- Name: flgrp; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE flgrp ( flgrp_id integer NOT NULL, flgrp_flhead_id integer, flgrp_flgrp_id integer, flgrp_order integer, flgrp_name text, flgrp_descrip text, flgrp_subtotal boolean DEFAULT false NOT NULL, flgrp_summarize boolean DEFAULT false NOT NULL, flgrp_subtract boolean DEFAULT false NOT NULL, flgrp_showstart boolean DEFAULT true NOT NULL, flgrp_showend boolean DEFAULT true NOT NULL, flgrp_showdelta boolean DEFAULT true NOT NULL, flgrp_showbudget boolean DEFAULT true NOT NULL, flgrp_showstartprcnt boolean DEFAULT false NOT NULL, flgrp_showendprcnt boolean DEFAULT false NOT NULL, flgrp_showdeltaprcnt boolean DEFAULT false NOT NULL, flgrp_showbudgetprcnt boolean DEFAULT false NOT NULL, flgrp_prcnt_flgrp_id integer DEFAULT (-1) NOT NULL, flgrp_showdiff boolean DEFAULT false NOT NULL, flgrp_showdiffprcnt boolean DEFAULT false NOT NULL, flgrp_showcustom boolean DEFAULT false NOT NULL, flgrp_showcustomprcnt boolean DEFAULT false NOT NULL, flgrp_usealtsubtotal boolean DEFAULT false NOT NULL, flgrp_altsubtotal text ); ALTER TABLE flgrp OWNER TO admin; -- -- Name: TABLE flgrp; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE flgrp IS 'Financial Layout Group information'; -- -- Name: flgrp_flgrp_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE flgrp_flgrp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE flgrp_flgrp_id_seq OWNER TO admin; -- -- Name: flgrp_flgrp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE flgrp_flgrp_id_seq OWNED BY flgrp.flgrp_id; -- -- Name: flhead_flhead_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE flhead_flhead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE flhead_flhead_id_seq OWNER TO admin; -- -- Name: flhead_flhead_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE flhead_flhead_id_seq OWNED BY flhead.flhead_id; -- -- Name: flitem_flitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE flitem_flitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE flitem_flitem_id_seq OWNER TO admin; -- -- Name: flitem_flitem_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE flitem_flitem_id_seq OWNED BY flitem.flitem_id; -- -- Name: flnotes; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE flnotes ( flnotes_id integer NOT NULL, flnotes_flhead_id integer, flnotes_period_id integer, flnotes_notes text DEFAULT ''::text ); ALTER TABLE flnotes OWNER TO admin; -- -- Name: flnotes_flnotes_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE flnotes_flnotes_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE flnotes_flnotes_id_seq OWNER TO admin; -- -- Name: flnotes_flnotes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE flnotes_flnotes_id_seq OWNED BY flnotes.flnotes_id; -- -- Name: flrpt; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE flrpt ( flrpt_flhead_id integer NOT NULL, flrpt_period_id integer NOT NULL, flrpt_username text NOT NULL, flrpt_order integer NOT NULL, flrpt_level integer NOT NULL, flrpt_type text NOT NULL, flrpt_type_id integer NOT NULL, flrpt_beginning numeric, flrpt_ending numeric, flrpt_debits numeric, flrpt_credits numeric, flrpt_budget numeric, flrpt_beginningprcnt numeric, flrpt_endingprcnt numeric, flrpt_debitsprcnt numeric, flrpt_creditsprcnt numeric, flrpt_budgetprcnt numeric, flrpt_parent_id integer, flrpt_diff numeric, flrpt_diffprcnt numeric, flrpt_custom numeric, flrpt_customprcnt numeric, flrpt_altname text, flrpt_accnt_id integer, flrpt_interval character(1), flrpt_id integer NOT NULL ); ALTER TABLE flrpt OWNER TO admin; -- -- Name: TABLE flrpt; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE flrpt IS 'Scratch table where financial reporting information is processed before being displayed.'; -- -- Name: flrpt_flrpt_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE flrpt_flrpt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE flrpt_flrpt_id_seq OWNER TO admin; -- -- Name: flrpt_flrpt_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE flrpt_flrpt_id_seq OWNED BY flrpt.flrpt_id; -- -- Name: flspec; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE flspec ( flspec_id integer NOT NULL, flspec_flhead_id integer NOT NULL, flspec_flgrp_id integer NOT NULL, flspec_order integer NOT NULL, flspec_name text, flspec_type text, flspec_showstart boolean DEFAULT true NOT NULL, flspec_showend boolean DEFAULT true NOT NULL, flspec_showdelta boolean DEFAULT true NOT NULL, flspec_showbudget boolean DEFAULT false NOT NULL, flspec_subtract boolean DEFAULT false NOT NULL, flspec_showstartprcnt boolean DEFAULT false NOT NULL, flspec_showendprcnt boolean DEFAULT false NOT NULL, flspec_showdeltaprcnt boolean DEFAULT false NOT NULL, flspec_showbudgetprcnt boolean DEFAULT false NOT NULL, flspec_showdiff boolean DEFAULT false NOT NULL, flspec_showdiffprcnt boolean DEFAULT false NOT NULL, flspec_prcnt_flgrp_id integer DEFAULT (-1) NOT NULL, flspec_showcustom boolean DEFAULT false NOT NULL, flspec_showcustomprcnt boolean DEFAULT false NOT NULL, flspec_custom_source character(1) ); ALTER TABLE flspec OWNER TO admin; -- -- Name: TABLE flspec; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE flspec IS 'Financial Layout Special entries.'; -- -- Name: flspec_flspec_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE flspec_flspec_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE flspec_flspec_id_seq OWNER TO admin; -- -- Name: flspec_flspec_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE flspec_flspec_id_seq OWNED BY flspec.flspec_id; -- -- Name: form; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE form ( form_id integer DEFAULT nextval(('"form_form_id_seq"'::text)::regclass) NOT NULL, form_name text NOT NULL, form_descrip text, form_report_id integer, form_key character varying(4), form_report_name text, CONSTRAINT form_form_name_check CHECK ((form_name <> ''::text)) ); ALTER TABLE form OWNER TO admin; -- -- Name: TABLE form; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE form IS 'Form information'; -- -- Name: COLUMN form.form_report_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN form.form_report_id IS 'Obsolete -- reference form_report_name instead.'; -- -- Name: form_form_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE form_form_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE form_form_id_seq OWNER TO admin; -- -- Name: freightclass_freightclass_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE freightclass_freightclass_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE freightclass_freightclass_id_seq OWNER TO admin; -- -- Name: freightclass_freightclass_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE freightclass_freightclass_id_seq OWNED BY freightclass.freightclass_id; -- -- Name: glseries; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE glseries ( glseries_id integer DEFAULT nextval(('"glseries_glseries_id_seq"'::text)::regclass) NOT NULL, glseries_sequence integer, glseries_doctype character(2), glseries_docnumber text, glseries_accnt_id integer, glseries_amount numeric(20,2), glseries_source text, glseries_distdate date, glseries_notes text, glseries_misc_id integer ); ALTER TABLE glseries OWNER TO admin; -- -- Name: TABLE glseries; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE glseries IS 'Temporary table for storing information about General Ledger (G/L) Series Entries before Series Entries are posted'; -- -- Name: glseries_glseries_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE glseries_glseries_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE glseries_glseries_id_seq OWNER TO admin; -- -- Name: gltrans_gltrans_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE gltrans_gltrans_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE gltrans_gltrans_id_seq OWNER TO admin; -- -- Name: gltrans_sequence_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE gltrans_sequence_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE gltrans_sequence_seq OWNER TO admin; -- -- Name: grp; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE grp ( grp_id integer NOT NULL, grp_name text NOT NULL, grp_descrip text, CONSTRAINT grp_grp_name_check CHECK ((grp_name <> ''::text)) ); ALTER TABLE grp OWNER TO admin; -- -- Name: TABLE grp; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE grp IS 'This table is the basic group information.'; -- -- Name: grp_grp_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE grp_grp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE grp_grp_id_seq OWNER TO admin; -- -- Name: grp_grp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE grp_grp_id_seq OWNED BY grp.grp_id; -- -- Name: grppriv; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE grppriv ( grppriv_id integer NOT NULL, grppriv_grp_id integer NOT NULL, grppriv_priv_id integer NOT NULL ); ALTER TABLE grppriv OWNER TO admin; -- -- Name: TABLE grppriv; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE grppriv IS 'This is a specific priv for a specific group.'; -- -- Name: grppriv_grppriv_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE grppriv_grppriv_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE grppriv_grppriv_id_seq OWNER TO admin; -- -- Name: grppriv_grppriv_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE grppriv_grppriv_id_seq OWNED BY grppriv.grppriv_id; -- -- Name: hnfc; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE hnfc ( hnfc_id integer NOT NULL, hnfc_code text NOT NULL, CONSTRAINT hnfc_hnfc_code_check CHECK ((hnfc_code <> ''::text)) ); ALTER TABLE hnfc OWNER TO admin; -- -- Name: TABLE hnfc; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE hnfc IS 'List of personal titles/honorifics used in cntct table.'; -- -- Name: hnfc_hnfc_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE hnfc_hnfc_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE hnfc_hnfc_id_seq OWNER TO admin; -- -- Name: hnfc_hnfc_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE hnfc_hnfc_id_seq OWNED BY hnfc.hnfc_id; -- -- Name: incdt_incdt_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE incdt_incdt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE incdt_incdt_id_seq OWNER TO admin; -- -- Name: incdt_incdt_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE incdt_incdt_id_seq OWNED BY incdt.incdt_id; -- -- Name: incdtcat_incdtcat_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE incdtcat_incdtcat_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE incdtcat_incdtcat_id_seq OWNER TO admin; -- -- Name: incdtcat_incdtcat_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE incdtcat_incdtcat_id_seq OWNED BY incdtcat.incdtcat_id; -- -- Name: incdthist; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE incdthist ( incdthist_id integer NOT NULL, incdthist_incdt_id integer NOT NULL, incdthist_change character(1), incdthist_target_id integer, incdthist_timestamp timestamp without time zone DEFAULT now() NOT NULL, incdthist_username text DEFAULT geteffectivextuser() NOT NULL, incdthist_descrip text ); ALTER TABLE incdthist OWNER TO admin; -- -- Name: TABLE incdthist; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE incdthist IS 'Incident history changes'; -- -- Name: incdthist_incdthist_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE incdthist_incdthist_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE incdthist_incdthist_id_seq OWNER TO admin; -- -- Name: incdthist_incdthist_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE incdthist_incdthist_id_seq OWNED BY incdthist.incdthist_id; -- -- Name: incdtpriority_incdtpriority_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE incdtpriority_incdtpriority_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE incdtpriority_incdtpriority_id_seq OWNER TO admin; -- -- Name: incdtpriority_incdtpriority_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE incdtpriority_incdtpriority_id_seq OWNED BY incdtpriority.incdtpriority_id; -- -- Name: incdtresolution_incdtresolution_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE incdtresolution_incdtresolution_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE incdtresolution_incdtresolution_id_seq OWNER TO admin; -- -- Name: incdtresolution_incdtresolution_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE incdtresolution_incdtresolution_id_seq OWNED BY incdtresolution.incdtresolution_id; -- -- Name: incdtseverity_incdtseverity_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE incdtseverity_incdtseverity_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE incdtseverity_incdtseverity_id_seq OWNER TO admin; -- -- Name: incdtseverity_incdtseverity_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE incdtseverity_incdtseverity_id_seq OWNED BY incdtseverity.incdtseverity_id; -- -- Name: invbal_invbal_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE invbal_invbal_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE invbal_invbal_id_seq OWNER TO admin; -- -- Name: invbal_invbal_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE invbal_invbal_id_seq OWNED BY invbal.invbal_id; -- -- Name: invc_invc_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE invc_invc_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE invc_invc_id_seq OWNER TO admin; -- -- Name: invchead_invchead_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE invchead_invchead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE invchead_invchead_id_seq OWNER TO admin; -- -- Name: invchead_invchead_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE invchead_invchead_id_seq OWNED BY invchead.invchead_id; -- -- Name: invcheadtax; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE invcheadtax ( ) INHERITS (taxhist); ALTER TABLE invcheadtax OWNER TO admin; -- -- Name: invcitem_invcitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE invcitem_invcitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE invcitem_invcitem_id_seq OWNER TO admin; -- -- Name: invcitem_invcitem_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE invcitem_invcitem_id_seq OWNED BY invcitem.invcitem_id; -- -- Name: invcitemtax; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE invcitemtax ( ) INHERITS (taxhist); ALTER TABLE invcitemtax OWNER TO admin; -- -- Name: invcnt_invcnt_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE invcnt_invcnt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE invcnt_invcnt_id_seq OWNER TO admin; -- -- Name: invdetail; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE invdetail ( invdetail_id integer DEFAULT nextval(('"invdetail_invdetail_id_seq"'::text)::regclass) NOT NULL, invdetail_transtype character(2), invdetail_invhist_id integer, invdetail_location_id integer, invdetail_qty numeric(18,6), invdetail_comments text, invdetail_qty_before numeric(18,6), invdetail_qty_after numeric(18,6), invdetail_invcitem_id integer, invdetail_expiration date, invdetail_warrpurc date, invdetail_ls_id integer ); ALTER TABLE invdetail OWNER TO admin; -- -- Name: TABLE invdetail; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE invdetail IS 'Detailed Inventory transaction information for Lot/Serial and Multiple Location Control (MLC) Items'; -- -- Name: invdetail_invdetail_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE invdetail_invdetail_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE invdetail_invdetail_id_seq OWNER TO admin; -- -- Name: invhist; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE invhist ( invhist_id integer DEFAULT nextval(('invhist_invhist_id_seq'::text)::regclass) NOT NULL, invhist_itemsite_id integer, invhist_transdate timestamp with time zone DEFAULT ('now'::text)::timestamp(6) with time zone, invhist_transtype character(2), invhist_invqty numeric(18,6), invhist_invuom text, invhist_ordnumber text, invhist_docnumber text, invhist_qoh_before numeric(18,6), invhist_qoh_after numeric(18,6), invhist_unitcost numeric(16,6), invhist_acct_id integer, invhist_xfer_warehous_id integer, invhist_comments text, invhist_posted boolean DEFAULT true, invhist_imported boolean, invhist_hasdetail boolean DEFAULT false, invhist_ordtype text, invhist_analyze boolean DEFAULT true, invhist_user text DEFAULT geteffectivextuser(), invhist_created timestamp with time zone DEFAULT now() NOT NULL, invhist_costmethod character(1) NOT NULL, invhist_value_before numeric(12,2) NOT NULL, invhist_value_after numeric(12,2) NOT NULL, invhist_series integer ); ALTER TABLE invhist OWNER TO admin; -- -- Name: TABLE invhist; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE invhist IS 'Inventory transaction history'; -- -- Name: invhist_invhist_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE invhist_invhist_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE invhist_invhist_id_seq OWNER TO admin; -- -- Name: invhistexpcat; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE invhistexpcat ( invhistexpcat_id integer NOT NULL, invhistexpcat_invhist_id integer NOT NULL, invhistexpcat_expcat_id integer NOT NULL ); ALTER TABLE invhistexpcat OWNER TO admin; -- -- Name: TABLE invhistexpcat; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE invhistexpcat IS 'Track the relationship between an EX transaction in the invhist table and the corresponding Expense Category.'; -- -- Name: invhistexpcat_invhistexpcat_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE invhistexpcat_invhistexpcat_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE invhistexpcat_invhistexpcat_id_seq OWNER TO admin; -- -- Name: invhistexpcat_invhistexpcat_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE invhistexpcat_invhistexpcat_id_seq OWNED BY invhistexpcat.invhistexpcat_id; -- -- Name: invoiceitem; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW invoiceitem AS SELECT invcitem.invcitem_id, invcitem.invcitem_invchead_id, invcitem.invcitem_linenumber, invcitem.invcitem_item_id, invcitem.invcitem_warehous_id, invcitem.invcitem_custpn, invcitem.invcitem_number, invcitem.invcitem_descrip, invcitem.invcitem_ordered, invcitem.invcitem_billed, invcitem.invcitem_custprice, invcitem.invcitem_price, invcitem.invcitem_notes, invcitem.invcitem_salescat_id, invcitem.invcitem_taxtype_id, invcitem.invcitem_qty_uom_id, invcitem.invcitem_qty_invuomratio, invcitem.invcitem_price_uom_id, invcitem.invcitem_price_invuomratio, invcitem.invcitem_coitem_id, invcitem.invcitem_updateinv, invcitem.invcitem_rev_accnt_id, itemsite.itemsite_id, cohead.cohead_number, COALESCE((invcitem.invcitem_billed * invcitem.invcitem_qty_invuomratio), (0)::numeric) AS qty, COALESCE((invcitem.invcitem_price / invcitem.invcitem_price_invuomratio), (0)::numeric) AS unitprice, COALESCE(round(((invcitem.invcitem_billed * invcitem.invcitem_qty_invuomratio) * (invcitem.invcitem_price / invcitem.invcitem_price_invuomratio)), 2), (0)::numeric) AS extprice, currtobase(invchead.invchead_curr_id, COALESCE(round(((invcitem.invcitem_billed * invcitem.invcitem_qty_invuomratio) * (invcitem.invcitem_price / invcitem.invcitem_price_invuomratio)), 2), (0)::numeric), invchead.invchead_invcdate) AS baseextprice, (SELECT COALESCE(sum(invcitemtax.taxhist_tax), (0)::numeric) AS "coalesce" FROM invcitemtax WHERE (invcitemtax.taxhist_parent_id = invcitem.invcitem_id)) AS tax, ((SELECT COALESCE(sum(shipitem.shipitem_value), (itemcost(itemsite.itemsite_id) * invcitem.invcitem_billed), 0.0) AS "coalesce" FROM shipitem WHERE (shipitem.shipitem_invcitem_id = invcitem.invcitem_id)) / CASE WHEN (invcitem.invcitem_billed <> (0)::numeric) THEN (invcitem.invcitem_billed * invcitem.invcitem_qty_invuomratio) ELSE (1)::numeric END) AS unitcost FROM ((((invcitem JOIN invchead ON ((invchead.invchead_id = invcitem.invcitem_invchead_id))) LEFT JOIN coitem ON ((coitem.coitem_id = invcitem.invcitem_coitem_id))) LEFT JOIN cohead ON ((cohead.cohead_id = coitem.coitem_cohead_id))) LEFT JOIN itemsite ON (((itemsite.itemsite_item_id = invcitem.invcitem_item_id) AND (itemsite.itemsite_warehous_id = invcitem.invcitem_warehous_id)))); ALTER TABLE invoiceitem OWNER TO admin; -- -- Name: VIEW invoiceitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON VIEW invoiceitem IS 'Single point for invoice item (invcitem) calculations.'; -- -- Name: ipsass_ipsass_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE ipsass_ipsass_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE ipsass_ipsass_id_seq OWNER TO admin; -- -- Name: ipsass_ipsass_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE ipsass_ipsass_id_seq OWNED BY ipsass.ipsass_id; -- -- Name: ipsctyp_ipsctyp_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE ipsctyp_ipsctyp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE ipsctyp_ipsctyp_id_seq OWNER TO admin; -- -- Name: ipscust_ipscust_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE ipscust_ipscust_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE ipscust_ipscust_id_seq OWNER TO admin; -- -- Name: ipsfreight_ipsfreight_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE ipsfreight_ipsfreight_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE ipsfreight_ipsfreight_id_seq OWNER TO admin; -- -- Name: ipsfreight_ipsfreight_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE ipsfreight_ipsfreight_id_seq OWNED BY ipsfreight.ipsfreight_id; -- -- Name: ipshead_ipshead_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE ipshead_ipshead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE ipshead_ipshead_id_seq OWNER TO admin; -- -- Name: ipsitem_ipsitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE ipsitem_ipsitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE ipsitem_ipsitem_id_seq OWNER TO admin; -- -- Name: ipsitemchar_ipsitemchar_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE ipsitemchar_ipsitemchar_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE ipsitemchar_ipsitemchar_id_seq OWNER TO admin; -- -- Name: ipsitemchar_ipsitemchar_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE ipsitemchar_ipsitemchar_id_seq OWNED BY ipsitemchar.ipsitemchar_id; -- -- Name: ipsprice; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW ipsprice AS SELECT ipsiteminfo.ipsitem_id AS ipsprice_id, 'I'::text AS ipsprice_source, ipsiteminfo.ipsitem_ipshead_id AS ipsprice_ipshead_id, ipsiteminfo.ipsitem_item_id AS ipsprice_item_id, itemuomtouom(ipsiteminfo.ipsitem_item_id, ipsiteminfo.ipsitem_qty_uom_id, NULL::integer, ipsiteminfo.ipsitem_qtybreak) AS ipsprice_qtybreak, CASE WHEN (ipsiteminfo.ipsitem_type = 'N'::bpchar) THEN ((ipsiteminfo.ipsitem_price * itemuomtouomratio(ipsiteminfo.ipsitem_item_id, NULL::integer, ipsiteminfo.ipsitem_price_uom_id)) * iteminvpricerat(ipsiteminfo.ipsitem_item_id)) WHEN (ipsiteminfo.ipsitem_type = 'D'::bpchar) THEN ((item.item_listprice - (item.item_listprice * ipsiteminfo.ipsitem_discntprcnt)) - ipsiteminfo.ipsitem_fixedamtdiscount) WHEN ((ipsiteminfo.ipsitem_type = 'M'::bpchar) AND fetchmetricbool('Long30Markups'::text)) THEN ((stdcost(item.item_id) / (1.0 - ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) WHEN (ipsiteminfo.ipsitem_type = 'M'::bpchar) THEN ((item.item_listcost + (item.item_listcost * ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) ELSE NULL::numeric END AS ipsprice_price, ipsiteminfo.ipsitem_qtybreak AS ipsprice_uomqtybreak, ipsiteminfo.ipsitem_qty_uom_id AS ipsprice_uomqtybreak_uom_id, CASE WHEN (ipsiteminfo.ipsitem_type = 'N'::bpchar) THEN ipsiteminfo.ipsitem_price WHEN (ipsiteminfo.ipsitem_type = 'D'::bpchar) THEN ((item.item_listprice - (item.item_listprice * ipsiteminfo.ipsitem_discntprcnt)) - ipsiteminfo.ipsitem_fixedamtdiscount) WHEN ((ipsiteminfo.ipsitem_type = 'M'::bpchar) AND fetchmetricbool('Long30Markups'::text)) THEN ((stdcost(item.item_id) / (1.0 - ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) WHEN (ipsiteminfo.ipsitem_type = 'M'::bpchar) THEN ((item.item_listcost + (item.item_listcost * ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) ELSE NULL::numeric END AS ipsprice_uomprice, ipsiteminfo.ipsitem_price_uom_id AS ipsprice_uomprice_uom_id, ipsiteminfo.ipsitem_discntprcnt AS ipsprice_discountpercent, ipsiteminfo.ipsitem_fixedamtdiscount AS ipsprice_discountfixed, ipsiteminfo.ipsitem_type AS ipsprice_type FROM (ipsiteminfo JOIN item ON ((item.item_id = ipsiteminfo.ipsitem_item_id))) UNION SELECT ipsiteminfo.ipsitem_id AS ipsprice_id, 'P'::text AS ipsprice_source, ipsiteminfo.ipsitem_ipshead_id AS ipsprice_ipshead_id, item.item_id AS ipsprice_item_id, ipsiteminfo.ipsitem_qtybreak AS ipsprice_qtybreak, CASE WHEN (ipsiteminfo.ipsitem_type = 'D'::bpchar) THEN ((item.item_listprice - (item.item_listprice * ipsiteminfo.ipsitem_discntprcnt)) - ipsiteminfo.ipsitem_fixedamtdiscount) WHEN ((ipsiteminfo.ipsitem_type = 'M'::bpchar) AND fetchmetricbool('Long30Markups'::text)) THEN ((stdcost(item.item_id) / (1.0 - ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) WHEN (ipsiteminfo.ipsitem_type = 'M'::bpchar) THEN ((item.item_listcost + (item.item_listcost * ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) ELSE NULL::numeric END AS ipsprice_price, ipsiteminfo.ipsitem_qtybreak AS ipsprice_uomqtybreak, item.item_inv_uom_id AS ipsprice_uomqtybreak_uom_id, CASE WHEN (ipsiteminfo.ipsitem_type = 'D'::bpchar) THEN ((item.item_listprice - (item.item_listprice * ipsiteminfo.ipsitem_discntprcnt)) - ipsiteminfo.ipsitem_fixedamtdiscount) WHEN ((ipsiteminfo.ipsitem_type = 'M'::bpchar) AND fetchmetricbool('Long30Markups'::text)) THEN ((stdcost(item.item_id) / (1.0 - ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) WHEN (ipsiteminfo.ipsitem_type = 'M'::bpchar) THEN ((item.item_listcost + (item.item_listcost * ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) ELSE NULL::numeric END AS ipsprice_uomprice, item.item_price_uom_id AS ipsprice_uomprice_uom_id, ipsiteminfo.ipsitem_discntprcnt AS ipsprice_discountpercent, ipsiteminfo.ipsitem_fixedamtdiscount AS ipsprice_discountfixed, ipsiteminfo.ipsitem_type AS ipsprice_type FROM (ipsiteminfo JOIN item ON ((ipsiteminfo.ipsitem_prodcat_id = item.item_prodcat_id))); ALTER TABLE ipsprice OWNER TO admin; -- -- Name: ipsprodcat_bak; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE ipsprodcat_bak ( ipsprodcat_id integer NOT NULL, ipsprodcat_ipshead_id integer NOT NULL, ipsprodcat_prodcat_id integer NOT NULL, ipsprodcat_qtybreak numeric(18,6) NOT NULL, ipsprodcat_discntprcnt numeric(10,6) NOT NULL, ipsprodcat_fixedamtdiscount numeric(16,4) DEFAULT 0.00 NOT NULL ); ALTER TABLE ipsprodcat_bak OWNER TO admin; -- -- Name: TABLE ipsprodcat_bak; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE ipsprodcat_bak IS 'Pricing Schedule Product Category information.'; -- -- Name: ipsprodcat_ipsprodcat_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE ipsprodcat_ipsprodcat_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE ipsprodcat_ipsprodcat_id_seq OWNER TO admin; -- -- Name: ipsprodcat_ipsprodcat_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE ipsprodcat_ipsprodcat_id_seq OWNED BY ipsprodcat_bak.ipsprodcat_id; -- -- Name: item_item_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE item_item_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE item_item_id_seq OWNER TO admin; -- -- Name: itemalias_itemalias_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE itemalias_itemalias_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE itemalias_itemalias_id_seq OWNER TO admin; -- -- Name: itematr_itematr_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE itematr_itematr_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE itematr_itematr_id_seq OWNER TO admin; -- -- Name: itemcost_itemcost_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE itemcost_itemcost_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE itemcost_itemcost_id_seq OWNER TO admin; -- -- Name: itemfrez_itemfrez_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE itemfrez_itemfrez_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE itemfrez_itemfrez_seq OWNER TO admin; -- -- Name: itemgrp; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE itemgrp ( itemgrp_id integer DEFAULT nextval(('"itemgrp_itemgrp_id_seq"'::text)::regclass) NOT NULL, itemgrp_name text NOT NULL, itemgrp_descrip text, itemgrp_catalog boolean DEFAULT false NOT NULL, CONSTRAINT itemgrp_itemgrp_name_check CHECK ((itemgrp_name <> ''::text)) ); ALTER TABLE itemgrp OWNER TO admin; -- -- Name: TABLE itemgrp; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE itemgrp IS 'Item Group information'; -- -- Name: itemgrp_itemgrp_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE itemgrp_itemgrp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE itemgrp_itemgrp_id_seq OWNER TO admin; -- -- Name: itemgrpitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE itemgrpitem ( itemgrpitem_id integer DEFAULT nextval(('"itemgrpitem_itemgrpitem_id_seq"'::text)::regclass) NOT NULL, itemgrpitem_itemgrp_id integer, itemgrpitem_item_id integer, itemgrpitem_item_type character(1) DEFAULT 'I'::bpchar NOT NULL, CONSTRAINT itemgrpitem_valid_item_type CHECK ((itemgrpitem_item_type = ANY (ARRAY['I'::bpchar, 'G'::bpchar]))) ); ALTER TABLE itemgrpitem OWNER TO admin; -- -- Name: TABLE itemgrpitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE itemgrpitem IS 'Item Group Item information'; -- -- Name: itemgrpitem_itemgrpitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE itemgrpitem_itemgrpitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE itemgrpitem_itemgrpitem_id_seq OWNER TO admin; -- -- Name: itemimage; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW itemimage AS SELECT imageass.imageass_id AS itemimage_id, imageass.imageass_source_id AS itemimage_item_id, imageass.imageass_image_id AS itemimage_image_id, imageass.imageass_purpose AS itemimage_purpose FROM imageass WHERE (imageass.imageass_source = 'I'::text); ALTER TABLE itemimage OWNER TO admin; -- -- Name: VIEW itemimage; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON VIEW itemimage IS 'Itemimage view for legacy support. Use of itemimage is deprecated. Use imageass table for future development'; -- -- Name: itemimage_itemimage_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE itemimage_itemimage_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE itemimage_itemimage_id_seq OWNER TO admin; -- -- Name: itemloc; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE itemloc ( itemloc_id integer DEFAULT nextval(('"itemloc_itemloc_id_seq"'::text)::regclass) NOT NULL, itemloc_itemsite_id integer NOT NULL, itemloc_location_id integer NOT NULL, itemloc_qty numeric(18,6) NOT NULL, itemloc_expiration date NOT NULL, itemloc_consolflag boolean, itemloc_ls_id integer, itemloc_warrpurc date ); ALTER TABLE itemloc OWNER TO admin; -- -- Name: TABLE itemloc; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE itemloc IS 'Detailed Location information for Lot/Serial and Multiple Location Control (MLC) Items'; -- -- Name: itemloc_itemloc_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE itemloc_itemloc_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE itemloc_itemloc_id_seq OWNER TO admin; -- -- Name: itemloc_series_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE itemloc_series_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE itemloc_series_seq OWNER TO admin; -- -- Name: itemlocdist; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE itemlocdist ( itemlocdist_id integer DEFAULT nextval(('"itemlocdist_itemlocdist_id_seq"'::text)::regclass) NOT NULL, itemlocdist_itemlocdist_id integer, itemlocdist_source_type character(1), itemlocdist_source_id integer, itemlocdist_qty numeric(18,6), itemlocdist_series integer, itemlocdist_invhist_id integer, itemlocdist_itemsite_id integer, itemlocdist_reqlotserial boolean DEFAULT false, itemlocdist_flush boolean DEFAULT false, itemlocdist_expiration date, itemlocdist_distlotserial boolean, itemlocdist_warranty date, itemlocdist_ls_id integer, itemlocdist_order_type text, itemlocdist_order_id integer ); ALTER TABLE itemlocdist OWNER TO admin; -- -- Name: TABLE itemlocdist; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE itemlocdist IS 'Temporary table for storing information about Inventory distributions involving Lot/Serial and Multiple Location Control (MLC) Items'; -- -- Name: itemlocdist_itemlocdist_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE itemlocdist_itemlocdist_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE itemlocdist_itemlocdist_id_seq OWNER TO admin; -- -- Name: itemlocpost; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE itemlocpost ( itemlocpost_id integer NOT NULL, itemlocpost_itemlocseries integer, itemlocpost_glseq integer ); ALTER TABLE itemlocpost OWNER TO admin; -- -- Name: TABLE itemlocpost; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE itemlocpost IS 'Temporary table for storing information about Inventory distribution G/L postings involving Lot/Serial and Multiple Location Control (MLC) Items'; -- -- Name: itemlocpost_itemlocpost_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE itemlocpost_itemlocpost_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE itemlocpost_itemlocpost_id_seq OWNER TO admin; -- -- Name: itemlocpost_itemlocpost_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE itemlocpost_itemlocpost_id_seq OWNED BY itemlocpost.itemlocpost_id; -- -- Name: itemopn_itemopn_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE itemopn_itemopn_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE itemopn_itemopn_id_seq OWNER TO admin; -- -- Name: itemsite_itemsite_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE itemsite_itemsite_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE itemsite_itemsite_id_seq OWNER TO admin; -- -- Name: itemsrc_itemsrc_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE itemsrc_itemsrc_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE itemsrc_itemsrc_id_seq OWNER TO admin; -- -- Name: itemsrcp_itemsrcp_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE itemsrcp_itemsrcp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE itemsrcp_itemsrcp_id_seq OWNER TO admin; -- -- Name: itemsub_itemsub_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE itemsub_itemsub_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE itemsub_itemsub_id_seq OWNER TO admin; -- -- Name: itemtax_itemtax_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE itemtax_itemtax_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE itemtax_itemtax_id_seq OWNER TO admin; -- -- Name: itemtax_itemtax_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE itemtax_itemtax_id_seq OWNED BY itemtax.itemtax_id; -- -- Name: itemtrans; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE itemtrans ( itemtrans_id integer NOT NULL, itemtrans_source_item_id integer, itemtrans_target_item_id integer ); ALTER TABLE itemtrans OWNER TO admin; -- -- Name: TABLE itemtrans; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE itemtrans IS 'Item Transformation information'; -- -- Name: itemtrans_itemtrans_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE itemtrans_itemtrans_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE itemtrans_itemtrans_id_seq OWNER TO admin; -- -- Name: itemtrans_itemtrans_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE itemtrans_itemtrans_id_seq OWNED BY itemtrans.itemtrans_id; -- -- Name: itemuom; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE itemuom ( itemuom_id integer NOT NULL, itemuom_itemuomconv_id integer NOT NULL, itemuom_uomtype_id integer NOT NULL ); ALTER TABLE itemuom OWNER TO admin; -- -- Name: TABLE itemuom; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE itemuom IS 'A UOM type relation for a specific conversion.'; -- -- Name: itemuom_itemuom_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE itemuom_itemuom_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE itemuom_itemuom_id_seq OWNER TO admin; -- -- Name: itemuom_itemuom_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE itemuom_itemuom_id_seq OWNED BY itemuom.itemuom_id; -- -- Name: itemuomconv_itemuomconv_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE itemuomconv_itemuomconv_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE itemuomconv_itemuomconv_id_seq OWNER TO admin; -- -- Name: itemuomconv_itemuomconv_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE itemuomconv_itemuomconv_id_seq OWNED BY itemuomconv.itemuomconv_id; -- -- Name: journal_number_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE journal_number_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE journal_number_seq OWNER TO admin; -- -- Name: jrnluse; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE jrnluse ( jrnluse_id integer DEFAULT nextval(('"jrnluse_jrnluse_id_seq"'::text)::regclass) NOT NULL, jrnluse_date timestamp without time zone, jrnluse_number integer, jrnluse_use text ); ALTER TABLE jrnluse OWNER TO admin; -- -- Name: TABLE jrnluse; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE jrnluse IS 'Journal entry and use information'; -- -- Name: jrnluse_jrnluse_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE jrnluse_jrnluse_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE jrnluse_jrnluse_id_seq OWNER TO admin; -- -- Name: labeldef; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE labeldef ( labeldef_id integer NOT NULL, labeldef_name text NOT NULL, labeldef_papersize text NOT NULL, labeldef_columns integer NOT NULL, labeldef_rows integer NOT NULL, labeldef_width integer NOT NULL, labeldef_height integer NOT NULL, labeldef_start_offset_x integer NOT NULL, labeldef_start_offset_y integer NOT NULL, labeldef_horizontal_gap integer NOT NULL, labeldef_vertical_gap integer NOT NULL ); ALTER TABLE labeldef OWNER TO admin; -- -- Name: labeldef_labeldef_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE labeldef_labeldef_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE labeldef_labeldef_id_seq OWNER TO admin; -- -- Name: labeldef_labeldef_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE labeldef_labeldef_id_seq OWNED BY labeldef.labeldef_id; -- -- Name: labelform; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE labelform ( labelform_id integer DEFAULT nextval(('"labelform_labelform_id_seq"'::text)::regclass) NOT NULL, labelform_name text NOT NULL, labelform_report_id integer, labelform_perpage integer, labelform_report_name text, CONSTRAINT labelform_labelform_name_check CHECK ((labelform_name <> ''::text)) ); ALTER TABLE labelform OWNER TO admin; -- -- Name: TABLE labelform; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE labelform IS 'Label Form information'; -- -- Name: COLUMN labelform.labelform_report_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN labelform.labelform_report_id IS 'Obsolete -- reference labelform_report_name instead.'; -- -- Name: labelform_labelform_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE labelform_labelform_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE labelform_labelform_id_seq OWNER TO admin; -- -- Name: lang; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE lang ( lang_id integer NOT NULL, lang_qt_number integer, lang_abbr3 text, lang_abbr2 text, lang_name text NOT NULL ); ALTER TABLE lang OWNER TO admin; -- -- Name: TABLE lang; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE lang IS 'Table mapping ISO 639-1 and 639-2 language codes to Qt''s enum QLocale::Language integer values. See http://www.loc.gov/standards/iso639-2/php/code_list.php and the QLocale documentation..'; -- -- Name: COLUMN lang.lang_abbr3; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN lang.lang_abbr3 IS 'ISO 639-2 code for language. Where there is a choice between bibliographic (B) and terminology (T) usage, this value is the T code'; -- -- Name: COLUMN lang.lang_abbr2; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN lang.lang_abbr2 IS 'ISO 639-1 code for language'; -- -- Name: COLUMN lang.lang_name; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN lang.lang_name IS 'Name of a human language, taken from the ISO 639-2 documentation'; -- -- Name: lang_lang_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE lang_lang_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE lang_lang_id_seq OWNER TO admin; -- -- Name: lang_lang_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE lang_lang_id_seq OWNED BY lang.lang_id; -- -- Name: locale; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE locale ( locale_id integer DEFAULT nextval(('locale_locale_id_seq'::text)::regclass) NOT NULL, locale_code text NOT NULL, locale_descrip text, locale_lang_file text, locale_dateformat text, locale_currformat text, locale_qtyformat text, locale_comments text, locale_qtyperformat text, locale_salespriceformat text, locale_extpriceformat text, locale_timeformat text, locale_timestampformat text, local_costformat text, locale_costformat text, locale_purchpriceformat text, locale_uomratioformat text, locale_intervalformat text, locale_lang_id integer, locale_country_id integer, locale_error_color text, locale_warning_color text, locale_emphasis_color text, locale_altemphasis_color text, locale_expired_color text, locale_future_color text, locale_curr_scale integer, locale_salesprice_scale integer, locale_purchprice_scale integer, locale_extprice_scale integer, locale_cost_scale integer, locale_qty_scale integer, locale_qtyper_scale integer, locale_uomratio_scale integer, locale_percent_scale integer DEFAULT 2, locale_weight_scale integer DEFAULT 2 NOT NULL, CONSTRAINT locale_locale_code_check CHECK ((locale_code <> ''::text)) ); ALTER TABLE locale OWNER TO admin; -- -- Name: TABLE locale; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE locale IS 'The locale table holds information required to show data to the user in a localized format. Colors are either names documented by the WWW Consortium or RGB colors. Format for RGB colors is #RGB, #RRGGBB, or #RRRGGGBBB, where the letters R, G, and B stand for hexidecimal digits.'; -- -- Name: COLUMN locale.locale_lang_file; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_lang_file IS 'Deprecated'; -- -- Name: COLUMN locale.locale_dateformat; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_dateformat IS 'Deprecated'; -- -- Name: COLUMN locale.locale_currformat; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_currformat IS 'Deprecated'; -- -- Name: COLUMN locale.locale_qtyformat; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_qtyformat IS 'Deprecated'; -- -- Name: COLUMN locale.locale_qtyperformat; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_qtyperformat IS 'Deprecated'; -- -- Name: COLUMN locale.locale_salespriceformat; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_salespriceformat IS 'Deprecated'; -- -- Name: COLUMN locale.locale_extpriceformat; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_extpriceformat IS 'Deprecated'; -- -- Name: COLUMN locale.locale_timeformat; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_timeformat IS 'Deprecated'; -- -- Name: COLUMN locale.locale_timestampformat; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_timestampformat IS 'Deprecated'; -- -- Name: COLUMN locale.local_costformat; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.local_costformat IS 'Deprecated'; -- -- Name: COLUMN locale.locale_costformat; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_costformat IS 'Deprecated'; -- -- Name: COLUMN locale.locale_purchpriceformat; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_purchpriceformat IS 'Deprecated'; -- -- Name: COLUMN locale.locale_uomratioformat; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_uomratioformat IS 'Deprecated'; -- -- Name: COLUMN locale.locale_intervalformat; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_intervalformat IS 'Deprecated'; -- -- Name: COLUMN locale.locale_error_color; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_error_color IS 'Color to use to mark data that require immediate attention.'; -- -- Name: COLUMN locale.locale_warning_color; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_warning_color IS 'Color to use to mark data that require attention soon.'; -- -- Name: COLUMN locale.locale_emphasis_color; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_emphasis_color IS 'Color to use to mark data that need to stand out but are not in error.'; -- -- Name: COLUMN locale.locale_altemphasis_color; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_altemphasis_color IS 'Color to use to mark data that need to stand out and be differentiated from other emphasized data.'; -- -- Name: COLUMN locale.locale_expired_color; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_expired_color IS 'Color to use to mark data that are no longer current.'; -- -- Name: COLUMN locale.locale_future_color; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_future_color IS 'Color to use to mark data that will not be effective until some point in the future.'; -- -- Name: COLUMN locale.locale_curr_scale; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_curr_scale IS 'Number of decimal places to show when displaying Currency values.'; -- -- Name: COLUMN locale.locale_salesprice_scale; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_salesprice_scale IS 'Number of decimal places to show when displaying Sales Prices.'; -- -- Name: COLUMN locale.locale_purchprice_scale; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_purchprice_scale IS 'Number of decimal places to show when displaying Purchase Prices.'; -- -- Name: COLUMN locale.locale_extprice_scale; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_extprice_scale IS 'Number of decimal places to show when displaying Extended Prices.'; -- -- Name: COLUMN locale.locale_cost_scale; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_cost_scale IS 'Number of decimal places to show when displaying Costs.'; -- -- Name: COLUMN locale.locale_qty_scale; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_qty_scale IS 'Number of decimal places to show when displaying Quantities.'; -- -- Name: COLUMN locale.locale_qtyper_scale; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_qtyper_scale IS 'Number of decimal places to show when displaying Quantities Per.'; -- -- Name: COLUMN locale.locale_uomratio_scale; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN locale.locale_uomratio_scale IS 'Number of decimal places to show when displaying UOM Ratios.'; -- -- Name: locale_locale_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE locale_locale_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE locale_locale_id_seq OWNER TO admin; -- -- Name: location_location_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE location_location_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE location_location_id_seq OWNER TO admin; -- -- Name: locitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE locitem ( locitem_id integer DEFAULT nextval(('"locitem_locitem_id_seq"'::text)::regclass) NOT NULL, locitem_location_id integer, locitem_item_id integer ); ALTER TABLE locitem OWNER TO admin; -- -- Name: TABLE locitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE locitem IS 'Restricted Warehouse Location Allowable Items information'; -- -- Name: locitem_locitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE locitem_locitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE locitem_locitem_id_seq OWNER TO admin; -- -- Name: log_log_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE log_log_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE log_log_id_seq OWNER TO admin; -- -- Name: metric; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE metric ( metric_id integer DEFAULT nextval(('metric_metric_id_seq'::text)::regclass) NOT NULL, metric_name text NOT NULL, metric_value text, metric_module text, CONSTRAINT metric_metric_name_check CHECK ((metric_name <> ''::text)) ); ALTER TABLE metric OWNER TO admin; -- -- Name: TABLE metric; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE metric IS 'Application-wide settings information'; -- -- Name: metric_metric_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE metric_metric_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE metric_metric_id_seq OWNER TO admin; -- -- Name: metricenc; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE metricenc ( metricenc_id integer NOT NULL, metricenc_name text NOT NULL, metricenc_value bytea, metricenc_module text, CONSTRAINT metricenc_metricenc_name_check CHECK ((metricenc_name <> ''::text)) ); ALTER TABLE metricenc OWNER TO admin; -- -- Name: TABLE metricenc; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE metricenc IS 'Application-wide settings information encrypted data'; -- -- Name: metricenc_metricenc_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE metricenc_metricenc_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE metricenc_metricenc_id_seq OWNER TO admin; -- -- Name: metricenc_metricenc_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE metricenc_metricenc_id_seq OWNED BY metricenc.metricenc_id; -- -- Name: misc_index_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE misc_index_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE misc_index_seq OWNER TO admin; -- -- Name: mrghist; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE mrghist ( mrghist_cntct_id integer NOT NULL, mrghist_table text NOT NULL, mrghist_pkey_col text NOT NULL, mrghist_pkey_id integer NOT NULL, mrghist_cntct_col text NOT NULL ); ALTER TABLE mrghist OWNER TO admin; -- -- Name: mrgundo; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE mrgundo ( mrgundo_base_schema text, mrgundo_base_table text, mrgundo_base_id integer, mrgundo_schema text, mrgundo_table text, mrgundo_pkey_col text, mrgundo_pkey_id integer, mrgundo_col text, mrgundo_value text, mrgundo_type text ); ALTER TABLE mrgundo OWNER TO admin; -- -- Name: TABLE mrgundo; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE mrgundo IS 'This table keeps track of the original values of changes made while merging two records. It is a generalization of mrghist and trgthist, which are specific to merging contacts. The schema, table, and pkey_id columns uniquely identify the record that was changed while the _base_ columns identify the merge target. The _base_ columns are required to allow finding all of the records that pertain to a particular merge (e.g. find changes to the comment table that pertain to a crmacct merge).'; -- -- Name: COLUMN mrgundo.mrgundo_base_schema; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN mrgundo.mrgundo_base_schema IS 'The schema in which the merge target resides.'; -- -- Name: COLUMN mrgundo.mrgundo_base_table; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN mrgundo.mrgundo_base_table IS 'The table in which the merge target resides.'; -- -- Name: COLUMN mrgundo.mrgundo_base_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN mrgundo.mrgundo_base_id IS 'The internal id of the merge target record.'; -- -- Name: COLUMN mrgundo.mrgundo_schema; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN mrgundo.mrgundo_schema IS 'The name of the schema in which the modified table resides.'; -- -- Name: COLUMN mrgundo.mrgundo_table; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN mrgundo.mrgundo_table IS 'The name of the table that was modified during a merge.'; -- -- Name: COLUMN mrgundo.mrgundo_pkey_col; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN mrgundo.mrgundo_pkey_col IS 'The name of the primary key column in the modified table. This could be derived during the undo processing but it is simpler just to store it during the merge.'; -- -- Name: COLUMN mrgundo.mrgundo_pkey_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN mrgundo.mrgundo_pkey_id IS 'The primary key of the modified record.'; -- -- Name: COLUMN mrgundo.mrgundo_col; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN mrgundo.mrgundo_col IS 'The column that was modified.'; -- -- Name: COLUMN mrgundo.mrgundo_value; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN mrgundo.mrgundo_value IS 'The value of the column before the change.'; -- -- Name: COLUMN mrgundo.mrgundo_type; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN mrgundo.mrgundo_type IS 'The data type of the modified column. This could be derived during the undo processing but it is simpler just to store it during the merge.'; -- -- Name: msg; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE msg ( msg_id integer DEFAULT nextval(('"msg_msg_id_seq"'::text)::regclass) NOT NULL, msg_posted timestamp with time zone, msg_scheduled timestamp with time zone, msg_text text, msg_expires timestamp with time zone, msg_username text ); ALTER TABLE msg OWNER TO admin; -- -- Name: TABLE msg; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE msg IS 'System Message information'; -- -- Name: msg_msg_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE msg_msg_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE msg_msg_id_seq OWNER TO admin; -- -- Name: msguser; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE msguser ( msguser_id integer DEFAULT nextval(('"msguser_msguser_id_seq"'::text)::regclass) NOT NULL, msguser_msg_id integer, msguser_viewed timestamp with time zone, msguser_username text ); ALTER TABLE msguser OWNER TO admin; -- -- Name: TABLE msguser; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE msguser IS 'System Message user information'; -- -- Name: msguser_msguser_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE msguser_msguser_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE msguser_msguser_id_seq OWNER TO admin; -- -- Name: nvend_nvend_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE nvend_nvend_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE nvend_nvend_id_seq OWNER TO admin; -- -- Name: obsolete_tax; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE obsolete_tax ( tax_id integer DEFAULT nextval(('"tax_tax_id_seq"'::text)::regclass) NOT NULL, tax_code text, tax_descrip text, tax_ratea numeric(8,4), tax_sales_accnt_id integer, tax_freight boolean DEFAULT false NOT NULL, tax_cumulative boolean DEFAULT false NOT NULL, tax_rateb numeric(8,4), tax_salesb_accnt_id integer, tax_ratec numeric(8,4), tax_salesc_accnt_id integer ); ALTER TABLE obsolete_tax OWNER TO admin; -- -- Name: TABLE obsolete_tax; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE obsolete_tax IS 'Tax information. Obsolete table structure.'; -- -- Name: COLUMN obsolete_tax.tax_freight; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN obsolete_tax.tax_freight IS 'Deprecated in 2.1 and moved to taxsel table where taxtype is the system defined Freight.'; -- -- Name: ophead_ophead_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE ophead_ophead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE ophead_ophead_id_seq OWNER TO admin; -- -- Name: ophead_ophead_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE ophead_ophead_id_seq OWNED BY ophead.ophead_id; -- -- Name: opsource; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE opsource ( opsource_id integer NOT NULL, opsource_name text NOT NULL, opsource_descrip text, CONSTRAINT opsource_opsource_name_check CHECK ((opsource_name <> ''::text)) ); ALTER TABLE opsource OWNER TO admin; -- -- Name: TABLE opsource; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE opsource IS 'Opportunity Lead Source values.'; -- -- Name: opsource_opsource_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE opsource_opsource_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE opsource_opsource_id_seq OWNER TO admin; -- -- Name: opsource_opsource_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE opsource_opsource_id_seq OWNED BY opsource.opsource_id; -- -- Name: opstage; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE opstage ( opstage_id integer NOT NULL, opstage_name text NOT NULL, opstage_descrip text, opstage_order integer DEFAULT 0 NOT NULL, opstage_opinactive boolean DEFAULT false, CONSTRAINT opstage_opstage_name_check CHECK ((opstage_name <> ''::text)) ); ALTER TABLE opstage OWNER TO admin; -- -- Name: TABLE opstage; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE opstage IS 'Opportunity stage values.'; -- -- Name: opstage_opstage_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE opstage_opstage_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE opstage_opstage_id_seq OWNER TO admin; -- -- Name: opstage_opstage_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE opstage_opstage_id_seq OWNED BY opstage.opstage_id; -- -- Name: optype; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE optype ( optype_id integer NOT NULL, optype_name text NOT NULL, optype_descrip text, CONSTRAINT optype_optype_name_check CHECK ((optype_name <> ''::text)) ); ALTER TABLE optype OWNER TO admin; -- -- Name: TABLE optype; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE optype IS 'Opportunity Type values.'; -- -- Name: optype_optype_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE optype_optype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE optype_optype_id_seq OWNER TO admin; -- -- Name: optype_optype_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE optype_optype_id_seq OWNED BY optype.optype_id; -- -- Name: orderhead; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW orderhead AS SELECT DISTINCT data.orderhead_id, data.orderhead_type, data.orderhead_number, data.orderhead_status, data.orderhead_orderdate, data.orderhead_linecount, data.orderhead_from_id, data.orderhead_from, data.orderhead_to_id, data.orderhead_to, data.orderhead_curr_id, data.orderhead_agent_username, data.orderhead_shipvia FROM (SELECT pohead.pohead_id AS orderhead_id, 'PO'::text AS orderhead_type, pohead.pohead_number AS orderhead_number, pohead.pohead_status AS orderhead_status, pohead.pohead_orderdate AS orderhead_orderdate, (SELECT count(*) AS count FROM poitem WHERE (poitem.poitem_pohead_id = pohead.pohead_id)) AS orderhead_linecount, pohead.pohead_vend_id AS orderhead_from_id, vendinfo.vend_name AS orderhead_from, NULL::integer AS orderhead_to_id, ''::text AS orderhead_to, pohead.pohead_curr_id AS orderhead_curr_id, pohead.pohead_agent_username AS orderhead_agent_username, pohead.pohead_shipvia AS orderhead_shipvia FROM (pohead LEFT JOIN vendinfo ON ((pohead.pohead_vend_id = vendinfo.vend_id))) UNION ALL SELECT cohead.cohead_id AS orderhead_id, 'SO'::text AS orderhead_type, cohead.cohead_number AS orderhead_number, cohead.cohead_status AS orderhead_status, cohead.cohead_orderdate AS orderhead_orderdate, (SELECT count(*) AS count FROM coitem WHERE (coitem.coitem_cohead_id = cohead.cohead_id)) AS orderhead_linecount, NULL::integer AS orderhead_from_id, ''::text AS orderhead_from, cohead.cohead_cust_id AS orderhead_to_id, CASE WHEN (length(cohead.cohead_shiptoname) > 0) THEN cohead.cohead_shiptoname ELSE cohead.cohead_billtoname END AS orderhead_to, cohead.cohead_curr_id AS orderhead_curr_id, ''::text AS orderhead_agent_username, cohead.cohead_shipvia AS orderhead_shipvia FROM cohead) data; ALTER TABLE orderhead OWNER TO admin; -- -- Name: VIEW orderhead; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON VIEW orderhead IS 'Union of all orders for use by widgets and stored procedures which process multiple types of order'; -- -- Name: orderitem; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW orderitem AS (SELECT poitem.poitem_id AS orderitem_id, 'PO'::text AS orderitem_orderhead_type, poitem.poitem_pohead_id AS orderitem_orderhead_id, poitem.poitem_linenumber AS orderitem_linenumber, poitem.poitem_status AS orderitem_status, poitem.poitem_itemsite_id AS orderitem_itemsite_id, poitem.poitem_duedate AS orderitem_scheddate, poitem.poitem_qty_ordered AS orderitem_qty_ordered, poitem.poitem_qty_returned AS orderitem_qty_shipped, poitem.poitem_qty_received AS orderitem_qty_received, uom.uom_id AS orderitem_qty_uom_id, poitem.poitem_invvenduomratio AS orderitem_qty_invuomratio, poitem.poitem_unitprice AS orderitem_unitcost, pohead.pohead_curr_id AS orderitem_unitcost_curr_id, poitem.poitem_freight AS orderitem_freight, poitem.poitem_freight_received AS orderitem_freight_received, pohead.pohead_curr_id AS orderitem_freight_curr_id FROM ((poitem LEFT JOIN pohead ON ((poitem.poitem_pohead_id = pohead.pohead_id))) LEFT JOIN uom ON ((uom.uom_name = poitem.poitem_vend_uom))) UNION ALL SELECT coitem.coitem_id AS orderitem_id, 'SO'::text AS orderitem_orderhead_type, coitem.coitem_cohead_id AS orderitem_orderhead_id, coitem.coitem_linenumber AS orderitem_linenumber, coitem.coitem_status AS orderitem_status, coitem.coitem_itemsite_id AS orderitem_itemsite_id, coitem.coitem_scheddate AS orderitem_scheddate, coitem.coitem_qtyord AS orderitem_qty_ordered, coitem.coitem_qtyshipped AS orderitem_qty_shipped, coitem.coitem_qtyreturned AS orderitem_qty_received, coitem.coitem_qty_uom_id AS orderitem_qty_uom_id, coitem.coitem_qty_invuomratio AS orderitem_qty_invuomratio, coitem.coitem_unitcost AS orderitem_unitcost, basecurrid() AS orderitem_unitcost_curr_id, NULL::numeric AS orderitem_freight, NULL::numeric AS orderitem_freight_received, basecurrid() AS orderitem_freight_curr_id FROM coitem) UNION ALL SELECT quitem.quitem_id AS orderitem_id, 'QU'::text AS orderitem_orderhead_type, quitem.quitem_quhead_id AS orderitem_orderhead_id, quitem.quitem_linenumber AS orderitem_linenumber, 'O'::bpchar AS orderitem_status, quitem.quitem_itemsite_id AS orderitem_itemsite_id, quitem.quitem_scheddate AS orderitem_scheddate, quitem.quitem_qtyord AS orderitem_qty_ordered, 0 AS orderitem_qty_shipped, 0 AS orderitem_qty_received, quitem.quitem_qty_uom_id AS orderitem_qty_uom_id, quitem.quitem_qty_invuomratio AS orderitem_qty_invuomratio, quitem.quitem_unitcost AS orderitem_unitcost, basecurrid() AS orderitem_unitcost_curr_id, NULL::numeric AS orderitem_freight, NULL::numeric AS orderitem_freight_received, basecurrid() AS orderitem_freight_curr_id FROM quitem; ALTER TABLE orderitem OWNER TO admin; -- -- Name: VIEW orderitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON VIEW orderitem IS 'Union of all order line items for use by widgets and stored procedures which process multiple types of order'; -- -- Name: orderseq; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE orderseq ( orderseq_id integer DEFAULT nextval(('orderseq_orderseq_id_seq'::text)::regclass) NOT NULL, orderseq_name text NOT NULL, orderseq_number integer, orderseq_table text, orderseq_numcol text, orderseq_seqiss seqiss[], CONSTRAINT orderseq_orderseq_name_check CHECK ((orderseq_name <> ''::text)) ); ALTER TABLE orderseq OWNER TO admin; -- -- Name: TABLE orderseq; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE orderseq IS 'Configuration information for common numbering sequences'; -- -- Name: orderseq_orderseq_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE orderseq_orderseq_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE orderseq_orderseq_id_seq OWNER TO admin; -- -- Name: pack; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE pack ( pack_id integer NOT NULL, pack_head_id integer NOT NULL, pack_head_type text NOT NULL, pack_shiphead_id integer, pack_printed boolean DEFAULT false NOT NULL, CONSTRAINT pack_pack_head_type_check CHECK (((pack_head_type = 'SO'::text) OR (pack_head_type = 'TO'::text))) ); ALTER TABLE pack OWNER TO admin; -- -- Name: TABLE pack; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE pack IS 'Temporary table for storing information about Orders added to the Packing List Batch'; -- -- Name: pack_pack_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE pack_pack_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE pack_pack_id_seq OWNER TO admin; -- -- Name: pack_pack_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE pack_pack_id_seq OWNED BY pack.pack_id; -- -- Name: payaropen; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE payaropen ( payaropen_ccpay_id integer NOT NULL, payaropen_aropen_id integer NOT NULL, payaropen_amount numeric(20,2) DEFAULT 0.00 NOT NULL, payaropen_curr_id integer DEFAULT basecurrid() ); ALTER TABLE payaropen OWNER TO admin; -- -- Name: TABLE payaropen; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE payaropen IS 'Credit Card payment to credit memo join table'; -- -- Name: payco; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE payco ( payco_ccpay_id integer NOT NULL, payco_cohead_id integer NOT NULL, payco_amount numeric(20,2) DEFAULT 0.00 NOT NULL, payco_curr_id integer DEFAULT basecurrid(), payco_id integer NOT NULL ); ALTER TABLE payco OWNER TO admin; -- -- Name: TABLE payco; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE payco IS 'Credit Card payment to sales order join table'; -- -- Name: COLUMN payco.payco_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN payco.payco_id IS 'payco table primary key.'; -- -- Name: payco_payco_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE payco_payco_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE payco_payco_id_seq OWNER TO admin; -- -- Name: payco_payco_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE payco_payco_id_seq OWNED BY payco.payco_id; -- -- Name: period_period_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE period_period_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE period_period_id_seq OWNER TO admin; -- -- Name: period_period_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE period_period_id_seq OWNED BY period.period_id; -- -- Name: pkgdep; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE pkgdep ( pkgdep_id integer NOT NULL, pkgdep_pkghead_id integer NOT NULL, pkgdep_parent_pkghead_id integer NOT NULL ); ALTER TABLE pkgdep OWNER TO admin; -- -- Name: TABLE pkgdep; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE pkgdep IS 'Package Dependencies list describing which packages are dependent on which other packages.'; -- -- Name: COLUMN pkgdep.pkgdep_pkghead_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN pkgdep.pkgdep_pkghead_id IS 'This is the internal ID of a package which requires at least one other package to be installed first to operate successfully'; -- -- Name: COLUMN pkgdep.pkgdep_parent_pkghead_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN pkgdep.pkgdep_parent_pkghead_id IS 'This is the internal ID of a package which must be installed for the package pointed to by pkgdep_pkghead_id to operate successfully.'; -- -- Name: pkgdep_pkgdep_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE pkgdep_pkgdep_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE pkgdep_pkgdep_id_seq OWNER TO admin; -- -- Name: pkgdep_pkgdep_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE pkgdep_pkgdep_id_seq OWNED BY pkgdep.pkgdep_id; -- -- Name: pkghead; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE pkghead ( pkghead_id integer NOT NULL, pkghead_name text NOT NULL, pkghead_descrip text, pkghead_version text NOT NULL, pkghead_developer text NOT NULL, pkghead_notes text, pkghead_created timestamp with time zone, pkghead_updated timestamp with time zone, pkghead_indev boolean DEFAULT false NOT NULL, CONSTRAINT pkghead_pkghead_name_check CHECK ((pkghead_name <> ''::text)) ); ALTER TABLE pkghead OWNER TO admin; -- -- Name: TABLE pkghead; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE pkghead IS 'Information about non-core Packages added to the database'; -- -- Name: COLUMN pkghead.pkghead_indev; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN pkghead.pkghead_indev IS 'Flag indicating whether the contents of this package may be modified in-place - this package is /in dev/elopment.'; -- -- Name: pkghead_pkghead_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE pkghead_pkghead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE pkghead_pkghead_id_seq OWNER TO admin; -- -- Name: pkghead_pkghead_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE pkghead_pkghead_id_seq OWNED BY pkghead.pkghead_id; -- -- Name: pkgitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE pkgitem ( pkgitem_id integer NOT NULL, pkgitem_pkghead_id integer, pkgitem_type text, pkgitem_item_id integer NOT NULL, pkgitem_name text NOT NULL, pkgitem_descrip text, CONSTRAINT pkgitem_pkgitem_type_check CHECK (((((((((((((pkgitem_type = 'C'::text) OR (pkgitem_type = 'D'::text)) OR (pkgitem_type = 'F'::text)) OR (pkgitem_type = 'G'::text)) OR (pkgitem_type = 'I'::text)) OR (pkgitem_type = 'M'::text)) OR (pkgitem_type = 'P'::text)) OR (pkgitem_type = 'R'::text)) OR (pkgitem_type = 'S'::text)) OR (pkgitem_type = 'T'::text)) OR (pkgitem_type = 'U'::text)) OR (pkgitem_type = 'V'::text))) ); ALTER TABLE pkgitem OWNER TO admin; -- -- Name: TABLE pkgitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE pkgitem IS 'Deprecated - the pkgitem table is no longer used to track package contents. It has been replaced by direct queries to the database schema and component tables. This table will be removed when all users have switched to Updater 2.2.0 or later.'; -- -- Name: pkgitem_pkgitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE pkgitem_pkgitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE pkgitem_pkgitem_id_seq OWNER TO admin; -- -- Name: pkgitem_pkgitem_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE pkgitem_pkgitem_id_seq OWNED BY pkgitem.pkgitem_id; -- -- Name: plancode_plancode_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE plancode_plancode_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE plancode_plancode_id_seq OWNER TO admin; -- -- Name: planord_planord_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE planord_planord_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE planord_planord_id_seq OWNER TO admin; -- -- Name: pohead_pohead_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE pohead_pohead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE pohead_pohead_id_seq OWNER TO admin; -- -- Name: poitem_poitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE poitem_poitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE poitem_poitem_id_seq OWNER TO admin; -- -- Name: recv; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE recv ( recv_id integer NOT NULL, recv_order_type text NOT NULL, recv_order_number text NOT NULL, recv_orderitem_id integer NOT NULL, recv_agent_username text, recv_itemsite_id integer, recv_vend_id integer, recv_vend_item_number text, recv_vend_item_descrip text, recv_vend_uom text, recv_purchcost numeric(16,6), recv_purchcost_curr_id integer, recv_duedate date, recv_qty numeric(18,6), recv_recvcost numeric(16,6), recv_recvcost_curr_id integer, recv_freight numeric(16,4), recv_freight_curr_id integer, recv_date timestamp with time zone, recv_value numeric(18,6), recv_posted boolean DEFAULT false NOT NULL, recv_invoiced boolean DEFAULT false NOT NULL, recv_vohead_id integer, recv_voitem_id integer, recv_trans_usr_name text DEFAULT geteffectivextuser() NOT NULL, recv_notes text, recv_gldistdate date, recv_splitfrom_id integer, recv_rlsd_duedate date, CONSTRAINT recv_recv_order_type_check CHECK ((((recv_order_type = 'PO'::text) OR (recv_order_type = 'RA'::text)) OR (recv_order_type = 'TO'::text))) ); ALTER TABLE recv OWNER TO admin; -- -- Name: TABLE recv; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE recv IS 'Information about Received Orders.'; -- -- Name: porecv; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW porecv AS SELECT recv.recv_id AS porecv_id, recv.recv_date AS porecv_date, recv.recv_rlsd_duedate AS porecv_rlsd_duedate, pohead.pohead_orderdate AS porecv_orderdate, pohead.pohead_released AS porecv_released, recv.recv_order_number AS porecv_ponumber, recv.recv_itemsite_id AS porecv_itemsite_id, recv.recv_vend_id AS porecv_vend_id, item.item_number AS porecv_item_number, recv.recv_vend_item_number AS porecv_vend_item_number, COALESCE(item.item_descrip1, recv.recv_vend_item_descrip) AS porecv_vend_item_descrip, recv.recv_vend_uom AS porecv_vend_uom, recv.recv_qty AS porecv_qty, recv.recv_posted AS porecv_posted, recv.recv_invoiced AS porecv_invoiced, (pg_user.usesysid)::integer AS porecv_trans_usr_id, recv.recv_orderitem_id AS porecv_poitem_id, NULL::integer AS porecv_linenumber, recv.recv_purchcost AS porecv_purchcost, recv.recv_vohead_id AS porecv_vohead_id, recv.recv_recvcost AS porecv_recvcost, recv.recv_duedate AS porecv_duedate, recv.recv_agent_username AS porecv_agent_username, recv.recv_notes AS porecv_notes, recv.recv_freight AS porecv_freight, recv.recv_freight_curr_id AS porecv_curr_id, recv.recv_gldistdate AS porecv_gldistdate, recv.recv_voitem_id AS porecv_voitem_id, recv.recv_value AS porecv_value FROM ((((recv LEFT JOIN pg_user ON ((recv.recv_trans_usr_name = (pg_user.usename)::text))) LEFT JOIN pohead ON ((recv.recv_order_number = pohead.pohead_number))) LEFT JOIN itemsite ON ((recv.recv_itemsite_id = itemsite.itemsite_id))) LEFT JOIN item ON ((itemsite.itemsite_item_id = item.item_id))) WHERE (recv.recv_order_type = 'PO'::text); ALTER TABLE porecv OWNER TO admin; -- -- Name: porecv_porecv_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE porecv_porecv_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE porecv_porecv_id_seq OWNER TO admin; -- -- Name: poreject; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE poreject ( poreject_id integer DEFAULT nextval(('"poreject_poreject_id_seq"'::text)::regclass) NOT NULL, poreject_date timestamp with time zone, poreject_ponumber text, poreject_itemsite_id integer, poreject_vend_id integer, poreject_vend_item_number text, poreject_vend_item_descrip text, poreject_vend_uom text, poreject_qty numeric(18,6), poreject_posted boolean, poreject_rjctcode_id integer, poreject_poitem_id integer, poreject_invoiced boolean, poreject_vohead_id integer, poreject_agent_username text, poreject_voitem_id integer, poreject_value numeric(18,6), poreject_trans_username text, poreject_recv_id integer ); ALTER TABLE poreject OWNER TO admin; -- -- Name: TABLE poreject; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE poreject IS 'The poreject table describes Purchase Order Items that were returned to Vendors.'; -- -- Name: COLUMN poreject.poreject_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN poreject.poreject_id IS 'This is the internal id of this poreject record'; -- -- Name: COLUMN poreject.poreject_date; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN poreject.poreject_date IS 'This is the date and time the return was entered into the database'; -- -- Name: COLUMN poreject.poreject_ponumber; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN poreject.poreject_ponumber IS 'This is the number of the original Purchase Order of this item'; -- -- Name: COLUMN poreject.poreject_itemsite_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN poreject.poreject_itemsite_id IS 'This is the Item Site into which the item had been received'; -- -- Name: COLUMN poreject.poreject_vend_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN poreject.poreject_vend_id IS 'This is the Vendor from which the item had been purchased'; -- -- Name: COLUMN poreject.poreject_vend_item_number; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN poreject.poreject_vend_item_number IS 'This is the Vendor''s item number for this item'; -- -- Name: COLUMN poreject.poreject_vend_item_descrip; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN poreject.poreject_vend_item_descrip IS 'This is the Vendor''s description of this item'; -- -- Name: COLUMN poreject.poreject_vend_uom; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN poreject.poreject_vend_uom IS 'This is the Unit of Measure in which the Vendor sold this item'; -- -- Name: COLUMN poreject.poreject_qty; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN poreject.poreject_qty IS 'This is the quantity of the item that was returned'; -- -- Name: COLUMN poreject.poreject_posted; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN poreject.poreject_posted IS 'This indicates whether or not the return has been recorded in the General Ledger, Inventory History, and Purchase Order Item'; -- -- Name: COLUMN poreject.poreject_rjctcode_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN poreject.poreject_rjctcode_id IS 'This indicates the reason for the return'; -- -- Name: COLUMN poreject.poreject_poitem_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN poreject.poreject_poitem_id IS 'This is the internal id of the original Purchase Order Item'; -- -- Name: COLUMN poreject.poreject_invoiced; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN poreject.poreject_invoiced IS 'This indicates whether the Credit Memo associated with the return has been posted'; -- -- Name: COLUMN poreject.poreject_vohead_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN poreject.poreject_vohead_id IS 'This is the Voucher associated with the Purchase Order Item'; -- -- Name: COLUMN poreject.poreject_agent_username; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN poreject.poreject_agent_username IS 'This is the Purchase Order Agent responsible for the original Purchase Order'; -- -- Name: COLUMN poreject.poreject_voitem_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN poreject.poreject_voitem_id IS 'This is the Voucher Item associated with the Purchase Order Item'; -- -- Name: COLUMN poreject.poreject_value; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN poreject.poreject_value IS 'This is the value (in base currency) of the return at the time it was posted to the General Ledger'; -- -- Name: COLUMN poreject.poreject_trans_username; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN poreject.poreject_trans_username IS 'This is the user who recorded the return'; -- -- Name: poreject_poreject_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE poreject_poreject_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE poreject_poreject_id_seq OWNER TO admin; -- -- Name: pr; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE pr ( pr_id integer DEFAULT nextval(('"pr_pr_id_seq"'::text)::regclass) NOT NULL, pr_number integer, pr_subnumber integer, pr_status character(1), pr_order_type character(1), pr_order_id integer, pr_poitem_id integer, pr_duedate date, pr_itemsite_id integer, pr_qtyreq numeric(18,6), pr_prj_id integer, pr_releasenote text, pr_createdate timestamp without time zone DEFAULT now() ); ALTER TABLE pr OWNER TO admin; -- -- Name: TABLE pr; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE pr IS 'Purchase Request information'; -- -- Name: pr_pr_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE pr_pr_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE pr_pr_id_seq OWNER TO admin; -- -- Name: prftcntr; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE prftcntr ( prftcntr_id integer NOT NULL, prftcntr_number text NOT NULL, prftcntr_descrip text, CONSTRAINT prftcntr_prftcntr_number_check CHECK ((prftcntr_number <> ''::text)) ); ALTER TABLE prftcntr OWNER TO admin; -- -- Name: TABLE prftcntr; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE prftcntr IS 'Profit Center information'; -- -- Name: prftcntr_prftcntr_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE prftcntr_prftcntr_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE prftcntr_prftcntr_id_seq OWNER TO admin; -- -- Name: prftcntr_prftcntr_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE prftcntr_prftcntr_id_seq OWNED BY prftcntr.prftcntr_id; -- -- Name: usrgrp; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE usrgrp ( usrgrp_id integer NOT NULL, usrgrp_grp_id integer NOT NULL, usrgrp_username text NOT NULL ); ALTER TABLE usrgrp OWNER TO admin; -- -- Name: TABLE usrgrp; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE usrgrp IS 'This is which group a user belongs to.'; -- -- Name: usrpriv; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE usrpriv ( usrpriv_id integer DEFAULT nextval(('usrpriv_usrpriv_id_seq'::text)::regclass) NOT NULL, usrpriv_priv_id integer, usrpriv_username text ); ALTER TABLE usrpriv OWNER TO admin; -- -- Name: TABLE usrpriv; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE usrpriv IS 'User Privileges information'; -- -- Name: privgranted; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW privgranted AS SELECT priv.priv_name AS privilege, (COALESCE(usrpriv.usrpriv_priv_id, grppriv.grppriv_priv_id, (-1)) > 0) AS granted, priv.priv_seq AS sequence FROM ((priv LEFT JOIN usrpriv ON (((priv.priv_id = usrpriv.usrpriv_priv_id) AND (usrpriv.usrpriv_username = geteffectivextuser())))) LEFT JOIN (SELECT DISTINCT grppriv.grppriv_priv_id FROM (grppriv JOIN usrgrp ON (((grppriv.grppriv_grp_id = usrgrp.usrgrp_grp_id) AND (usrgrp.usrgrp_username = geteffectivextuser()))))) grppriv ON ((grppriv.grppriv_priv_id = priv.priv_id))); ALTER TABLE privgranted OWNER TO admin; -- -- Name: prj_prj_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE prj_prj_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE prj_prj_id_seq OWNER TO admin; -- -- Name: prj_prj_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE prj_prj_id_seq OWNED BY prj.prj_id; -- -- Name: prjtask_prjtask_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE prjtask_prjtask_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE prjtask_prjtask_id_seq OWNER TO admin; -- -- Name: prjtask_prjtask_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE prjtask_prjtask_id_seq OWNED BY prjtask.prjtask_id; -- -- Name: prjtaskuser; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE prjtaskuser ( prjtaskuser_id integer NOT NULL, prjtaskuser_prjtask_id integer, prjtaskuser_username text ); ALTER TABLE prjtaskuser OWNER TO admin; -- -- Name: TABLE prjtaskuser; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE prjtaskuser IS 'Project Task user information'; -- -- Name: prjtaskuser_prjtaskuser_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE prjtaskuser_prjtaskuser_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE prjtaskuser_prjtaskuser_id_seq OWNER TO admin; -- -- Name: prjtaskuser_prjtaskuser_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE prjtaskuser_prjtaskuser_id_seq OWNED BY prjtaskuser.prjtaskuser_id; -- -- Name: prjtype; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE prjtype ( prjtype_id integer NOT NULL, prjtype_code text, prjtype_descr text, prjtype_active boolean DEFAULT true ); ALTER TABLE prjtype OWNER TO admin; -- -- Name: prjtype_prjtype_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE prjtype_prjtype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE prjtype_prjtype_id_seq OWNER TO admin; -- -- Name: prjtype_prjtype_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE prjtype_prjtype_id_seq OWNED BY prjtype.prjtype_id; -- -- Name: prodcat_prodcat_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE prodcat_prodcat_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE prodcat_prodcat_id_seq OWNER TO admin; -- -- Name: qryhead; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE qryhead ( qryhead_id integer NOT NULL, qryhead_name text NOT NULL, qryhead_descrip text, qryhead_notes text, qryhead_username text DEFAULT geteffectivextuser() NOT NULL, qryhead_updated date DEFAULT ('now'::text)::date NOT NULL, CONSTRAINT qryhead_qryhead_name_check CHECK ((qryhead_name <> ''::text)) ); ALTER TABLE qryhead OWNER TO admin; -- -- Name: TABLE qryhead; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE qryhead IS 'A header record for a set of queries to be run sequentially. One use is for data export.'; -- -- Name: COLUMN qryhead.qryhead_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN qryhead.qryhead_id IS 'The primary key, holding an internal value used to cross-reference this table.'; -- -- Name: COLUMN qryhead.qryhead_name; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN qryhead.qryhead_name IS 'The user-assigned short name for this set of queries.'; -- -- Name: COLUMN qryhead.qryhead_descrip; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN qryhead.qryhead_descrip IS 'A long description of the purpose of this set of queries.'; -- -- Name: COLUMN qryhead.qryhead_notes; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN qryhead.qryhead_notes IS 'General information about this queryset.'; -- -- Name: COLUMN qryhead.qryhead_username; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN qryhead.qryhead_username IS 'The name of the user who last modified this qryhead record.'; -- -- Name: COLUMN qryhead.qryhead_updated; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN qryhead.qryhead_updated IS 'The date this qryhead was last modified.'; -- -- Name: qryhead_qryhead_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE qryhead_qryhead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE qryhead_qryhead_id_seq OWNER TO admin; -- -- Name: qryhead_qryhead_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE qryhead_qryhead_id_seq OWNED BY qryhead.qryhead_id; -- -- Name: qryitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE qryitem ( qryitem_id integer NOT NULL, qryitem_qryhead_id integer NOT NULL, qryitem_name text NOT NULL, qryitem_order integer NOT NULL, qryitem_src text NOT NULL, qryitem_group text, qryitem_detail text NOT NULL, qryitem_notes text DEFAULT ''::text NOT NULL, qryitem_username text DEFAULT geteffectivextuser() NOT NULL, qryitem_updated date DEFAULT ('now'::text)::date NOT NULL, CONSTRAINT qryitem_qryitem_detail_check CHECK ((btrim(qryitem_detail) <> ''::text)), CONSTRAINT qryitem_qryitem_src_check CHECK ((qryitem_src = ANY (ARRAY['REL'::text, 'MQL'::text, 'CUSTOM'::text]))) ); ALTER TABLE qryitem OWNER TO admin; -- -- Name: TABLE qryitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE qryitem IS 'The description of a query to be run as part of a set (see qryhead).'; -- -- Name: COLUMN qryitem.qryitem_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN qryitem.qryitem_id IS 'The primary key, holding an internal value used to cross-reference this table.'; -- -- Name: COLUMN qryitem.qryitem_qryhead_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN qryitem.qryitem_qryhead_id IS 'The primary key of the query set to which this individual query belongs.'; -- -- Name: COLUMN qryitem.qryitem_order; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN qryitem.qryitem_order IS 'The order in which query items within a query set should be run.'; -- -- Name: COLUMN qryitem.qryitem_src; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN qryitem.qryitem_src IS 'The source of the query. If the qryitem_src is "REL" then the qryitem_group and _detail name a particular table or view and all rows will be returned. If the source is "MQL" then the qryitem_group and _detail name a pre-defined MetaSQL query in the metasql table. If the source is "CUSTOM" then the qryitem_detail contains the full MetaSQL text of the query to run.'; -- -- Name: COLUMN qryitem.qryitem_group; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN qryitem.qryitem_group IS 'Information to help find the query to run. If the qryitem_src is "REL" then this is the schema in which to find the table or view to query and all rows will be returned (the qryitem_detail names the table or view). If the qryitem_src is "MQL" then this is the group of the query in the metasql table to run (the name is in qryitem_detail). If the qryitem_src IS "CUSTOM" then this ignored.'; -- -- Name: COLUMN qryitem.qryitem_detail; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN qryitem.qryitem_detail IS 'The particular query to run. If the qryitem_src is "REL" then this is the name of the table or view to query and all rows will be returned. If the qryitem_src is "MQL" then this is the name of the query in the metasql table to run. If the qryitem_src IS "CUSTOM" then this is the actual MetaSQL query text to be parsed and run.'; -- -- Name: COLUMN qryitem.qryitem_notes; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN qryitem.qryitem_notes IS 'General information about this query.'; -- -- Name: COLUMN qryitem.qryitem_username; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN qryitem.qryitem_username IS 'The name of the user who last modified this qryitem record.'; -- -- Name: COLUMN qryitem.qryitem_updated; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN qryitem.qryitem_updated IS 'The date this qryitem was last modified.'; -- -- Name: qryitem_qryitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE qryitem_qryitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE qryitem_qryitem_id_seq OWNER TO admin; -- -- Name: qryitem_qryitem_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE qryitem_qryitem_id_seq OWNED BY qryitem.qryitem_id; -- -- Name: quhead_quhead_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE quhead_quhead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE quhead_quhead_id_seq OWNER TO admin; -- -- Name: quitem_quitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE quitem_quitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE quitem_quitem_id_seq OWNER TO admin; -- -- Name: rcalitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE rcalitem ( rcalitem_id integer DEFAULT nextval(('"xcalitem_xcalitem_id_seq"'::text)::regclass) NOT NULL, rcalitem_calhead_id integer, rcalitem_offsettype character(1), rcalitem_offsetcount integer, rcalitem_periodtype character(1), rcalitem_periodcount integer, rcalitem_name text ); ALTER TABLE rcalitem OWNER TO admin; -- -- Name: TABLE rcalitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE rcalitem IS 'Relative Calendar Item information'; -- -- Name: recur; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE recur ( recur_id integer NOT NULL, recur_parent_id integer NOT NULL, recur_parent_type text NOT NULL, recur_period text NOT NULL, recur_freq integer DEFAULT 1 NOT NULL, recur_start timestamp with time zone DEFAULT now(), recur_end timestamp with time zone, recur_max integer, recur_data text, CONSTRAINT recur_recur_period_check CHECK ((recur_period = ANY (ARRAY['m'::text, 'H'::text, 'D'::text, 'W'::text, 'M'::text, 'Y'::text, 'C'::text]))) ); ALTER TABLE recur OWNER TO admin; -- -- Name: TABLE recur; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE recur IS 'Track recurring events and objects.'; -- -- Name: COLUMN recur.recur_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN recur.recur_id IS 'Internal ID of this recurrence record.'; -- -- Name: COLUMN recur.recur_parent_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN recur.recur_parent_id IS 'The internal ID of the event/object that recurs.'; -- -- Name: COLUMN recur.recur_parent_type; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN recur.recur_parent_type IS 'The table in which the parent event or object is stored.'; -- -- Name: COLUMN recur.recur_period; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN recur.recur_period IS 'With recur_freq, how often this event recurs. Values are "m" for every minute, "H" for every hour, "D" for daily, "W" for weekly, "M" for monthly, "Y" for yearly, and "C" for customized or complex.'; -- -- Name: COLUMN recur.recur_freq; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN recur.recur_freq IS 'With recur_period, how often this event recurs. Values are integers counts of recur_periods. For example, if recur_freq = 2 and recur_period = w then the event recurs every 2 weeks.'; -- -- Name: COLUMN recur.recur_start; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN recur.recur_start IS 'The first date/time when the event should occur.'; -- -- Name: COLUMN recur.recur_end; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN recur.recur_end IS 'The last date/time when the event should occur. NULL means there is no end date/time and the event should recur forever.'; -- -- Name: COLUMN recur.recur_max; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN recur.recur_max IS 'The maximum number of recurrence events to create at one time. If this is NULL then when new events are created, a system-wide default will limit the number.'; -- -- Name: COLUMN recur.recur_data; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN recur.recur_data IS 'Not yet used and format still undetermined. Additional data to describe how to apply the period and frequency, particularly when period = "C".'; -- -- Name: recur_recur_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE recur_recur_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE recur_recur_id_seq OWNER TO admin; -- -- Name: recur_recur_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE recur_recur_id_seq OWNED BY recur.recur_id; -- -- Name: recurtype; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE recurtype ( recurtype_id integer NOT NULL, recurtype_type text NOT NULL, recurtype_table text NOT NULL, recurtype_donecheck text NOT NULL, recurtype_schedcol text NOT NULL, recurtype_limit text, recurtype_copyfunc text NOT NULL, recurtype_copyargs text[] NOT NULL, recurtype_delfunc text ); ALTER TABLE recurtype OWNER TO admin; -- -- Name: TABLE recurtype; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE recurtype IS 'Describes the properties of recurring items/events in way that can be used by stored procedures to maintain the recurrence.'; -- -- Name: COLUMN recurtype.recurtype_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN recurtype.recurtype_id IS 'The internal id of this recurrence description.'; -- -- Name: COLUMN recurtype.recurtype_type; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN recurtype.recurtype_type IS 'A code value used by the RecurrenceWidget and the code that uses it to describe the item/event that will recur. Examples include "INCDT" for CRM Incidents and "J" for Projects.'; -- -- Name: COLUMN recurtype.recurtype_table; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN recurtype.recurtype_table IS 'The table that holds the item/event that will recur.'; -- -- Name: COLUMN recurtype.recurtype_donecheck; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN recurtype.recurtype_donecheck IS 'A boolean expression that returns TRUE if an individual item/event record in the recurtype_table has already been completed.'; -- -- Name: COLUMN recurtype.recurtype_schedcol; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN recurtype.recurtype_schedcol IS 'The name of the column in the recurtype_table holding the date or timestamp by which the item is scheduled to be completed or at which the event is supposed to occur.'; -- -- Name: COLUMN recurtype.recurtype_limit; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN recurtype.recurtype_limit IS 'A boolean expression that returns TRUE if the current user should see the row in the recurtype_table. NULL indicates there is no specific limitation. For example, the maintainance of recurring TODO items should restricted to those items belonging to the user unless s/he has been granted the privilege to modify other people''s todo lists.'; -- -- Name: COLUMN recurtype.recurtype_copyfunc; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN recurtype.recurtype_copyfunc IS 'The name of the function to copy an existing item/event record. The copy function is expected to take at least 2 arguments: the id of the item to copy and the new date/timestamp. If the function accepts more than 2, it must be able to accept NULL values for the 3rd and following arguments.'; -- -- Name: COLUMN recurtype.recurtype_copyargs; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN recurtype.recurtype_copyargs IS 'An abbreviated argument list for the copy function. This is used to determine whether the second argument must be cast to a date or a timestamp, and to figure out how many additional arguments to pass.'; -- -- Name: COLUMN recurtype.recurtype_delfunc; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN recurtype.recurtype_delfunc IS 'The name of the function to delete an existing item/event record. The function is expected to take exactly one argument: the id of the item to delete. NULL indicates there is no delete function and that an SQL DELETE statement can be used. In this case, the id column name will be built as the recurtype_table concatenated with the "_id" suffix.'; -- -- Name: recurtype_recurtype_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE recurtype_recurtype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE recurtype_recurtype_id_seq OWNER TO admin; -- -- Name: recurtype_recurtype_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE recurtype_recurtype_id_seq OWNED BY recurtype.recurtype_id; -- -- Name: recv_recv_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE recv_recv_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE recv_recv_id_seq OWNER TO admin; -- -- Name: recv_recv_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE recv_recv_id_seq OWNED BY recv.recv_id; -- -- Name: remitto; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW remitto AS SELECT (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_name'::text)) AS remitto_name, (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_address1'::text)) AS remitto_address1, (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_address2'::text)) AS remitto_address2, (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_address3'::text)) AS remitto_address3, (((((SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_city'::text)) || ' '::text) || (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_state'::text))) || ' '::text) || (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_zipcode'::text))) AS remitto_citystatezip, (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_country'::text)) AS remitto_country, (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_phone'::text)) AS remitto_phone; ALTER TABLE remitto OWNER TO admin; -- -- Name: rjctcode; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE rjctcode ( rjctcode_id integer DEFAULT nextval(('"rjctcode_rjctcode_id_seq"'::text)::regclass) NOT NULL, rjctcode_code text NOT NULL, rjctcode_descrip text, CONSTRAINT rjctcode_rjctcode_code_check CHECK ((rjctcode_code <> ''::text)) ); ALTER TABLE rjctcode OWNER TO admin; -- -- Name: TABLE rjctcode; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE rjctcode IS 'Reject Code information'; -- -- Name: rjctcode_rjctcode_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE rjctcode_rjctcode_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE rjctcode_rjctcode_id_seq OWNER TO admin; -- -- Name: rsncode_rsncode_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE rsncode_rsncode_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE rsncode_rsncode_id_seq OWNER TO admin; -- -- Name: rsncode_rsncode_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE rsncode_rsncode_id_seq OWNED BY rsncode.rsncode_id; -- -- Name: sale; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE sale ( sale_id integer DEFAULT nextval(('"sale_sale_id_seq"'::text)::regclass) NOT NULL, sale_name text NOT NULL, sale_descrip text, sale_ipshead_id integer, sale_startdate date, sale_enddate date, CONSTRAINT sale_sale_name_check CHECK ((sale_name <> ''::text)) ); ALTER TABLE sale OWNER TO admin; -- -- Name: TABLE sale; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE sale IS 'Sale information'; -- -- Name: sale_sale_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE sale_sale_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE sale_sale_id_seq OWNER TO admin; -- -- Name: salesaccnt_salesaccnt_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE salesaccnt_salesaccnt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE salesaccnt_salesaccnt_id_seq OWNER TO admin; -- -- Name: salescat_salescat_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE salescat_salescat_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE salescat_salescat_id_seq OWNER TO admin; -- -- Name: salescat_salescat_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE salescat_salescat_id_seq OWNED BY salescat.salescat_id; -- -- Name: saleshistory; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW saleshistory AS SELECT data.cohist_id, data.cohist_cust_id, data.cohist_itemsite_id, data.cohist_shipdate, data.cohist_shipvia, data.cohist_ordernumber, data.cohist_orderdate, data.cohist_invcnumber, data.cohist_invcdate, data.cohist_qtyshipped, data.cohist_unitprice, data.cohist_shipto_id, data.cohist_salesrep_id, data.cohist_duedate, data.cohist_imported, data.cohist_billtoname, data.cohist_billtoaddress1, data.cohist_billtoaddress2, data.cohist_billtoaddress3, data.cohist_billtocity, data.cohist_billtostate, data.cohist_billtozip, data.cohist_shiptoname, data.cohist_shiptoaddress1, data.cohist_shiptoaddress2, data.cohist_shiptoaddress3, data.cohist_shiptocity, data.cohist_shiptostate, data.cohist_shiptozip, data.cohist_commission, data.cohist_commissionpaid, data.cohist_unitcost, data.cohist_misc_type, data.cohist_misc_descrip, data.cohist_misc_id, data.cohist_doctype, data.cohist_promisedate, data.cohist_ponumber, data.cohist_curr_id, data.cohist_sequence, data.cohist_taxtype_id, data.cohist_taxzone_id, data.cohist_cohead_ccpay_id, data.cohist_saletype_id, data.cohist_shipzone_id, data.cohead_id, data.cust_id, data.cust_number, data.cust_name, data.cust_curr_id, data.custtype_id, data.custtype_code, data.custtype_descrip, data.salesrep_id, data.salesrep_number, data.salesrep_name, data.shipzone_id, data.shipzone_name, data.shipzone_descrip, data.saletype_code, data.saletype_descr, data.itemsite_id, data.warehous_id, data.warehous_code, data.warehous_descrip, data.item_id, data.item_number, data.item_descrip1, data.item_descrip2, data.itemdescription, data.itemnumber, data.prodcat_id, data.prodcat_code, data.classcode_id, data.classcode_code, data.basecommission, data.baseunitprice, data.custunitprice, round((data.cohist_qtyshipped * data.cohist_unitprice), 2) AS extprice, round((data.cohist_qtyshipped * data.baseunitprice), 2) AS baseextprice, round((data.cohist_qtyshipped * data.custunitprice), 2) AS custextprice, round((data.cohist_qtyshipped * data.cohist_unitcost), 4) AS extcost, round(((data.cohist_qtyshipped * data.baseunitprice) - (data.cohist_qtyshipped * data.cohist_unitcost)), 2) AS margin, CASE WHEN (round((data.cohist_qtyshipped * data.baseunitprice), 2) > 0.0) THEN (round(((data.cohist_qtyshipped * data.baseunitprice) - (data.cohist_qtyshipped * data.cohist_unitcost)), 2) / round((data.cohist_qtyshipped * data.baseunitprice), 2)) ELSE 0.0 END AS marginpercent, currconcat(data.cohist_curr_id) AS currabbr, 'qty'::text AS cohist_qtyshipped_xtnumericrole, 'salesprice'::text AS cohist_unitprice_xtnumericrole, 'salesprice'::text AS baseunitprice_xtnumericrole, 'curr'::text AS custunitprice_xtnumericrole, 'curr'::text AS custextprice_xtnumericrole, 'curr'::text AS extprice_xtnumericrole, 'curr'::text AS baseextprice_xtnumericrole, 'cost'::text AS cohist_unitcost_xtnumericrole, 'curr'::text AS extcost_xtnumericrole, 'curr'::text AS margin_xtnumericrole, 'percent'::text AS marginpercent_xtnumericrole, 'curr'::text AS cohist_commission_xtnumericrole, 'curr'::text AS basecommission_xtnumericrole FROM (SELECT cohist.cohist_id, cohist.cohist_cust_id, cohist.cohist_itemsite_id, cohist.cohist_shipdate, cohist.cohist_shipvia, cohist.cohist_ordernumber, cohist.cohist_orderdate, cohist.cohist_invcnumber, cohist.cohist_invcdate, cohist.cohist_qtyshipped, cohist.cohist_unitprice, cohist.cohist_shipto_id, cohist.cohist_salesrep_id, cohist.cohist_duedate, cohist.cohist_imported, cohist.cohist_billtoname, cohist.cohist_billtoaddress1, cohist.cohist_billtoaddress2, cohist.cohist_billtoaddress3, cohist.cohist_billtocity, cohist.cohist_billtostate, cohist.cohist_billtozip, cohist.cohist_shiptoname, cohist.cohist_shiptoaddress1, cohist.cohist_shiptoaddress2, cohist.cohist_shiptoaddress3, cohist.cohist_shiptocity, cohist.cohist_shiptostate, cohist.cohist_shiptozip, cohist.cohist_commission, cohist.cohist_commissionpaid, cohist.cohist_unitcost, cohist.cohist_misc_type, cohist.cohist_misc_descrip, cohist.cohist_misc_id, cohist.cohist_doctype, cohist.cohist_promisedate, cohist.cohist_ponumber, cohist.cohist_curr_id, cohist.cohist_sequence, cohist.cohist_taxtype_id, cohist.cohist_taxzone_id, cohist.cohist_cohead_ccpay_id, cohist.cohist_saletype_id, cohist.cohist_shipzone_id, COALESCE(cohead.cohead_id, (-1)) AS cohead_id, custinfo.cust_id, custinfo.cust_number, custinfo.cust_name, custinfo.cust_curr_id, custtype.custtype_id, custtype.custtype_code, custtype.custtype_descrip, salesrep.salesrep_id, salesrep.salesrep_number, salesrep.salesrep_name, shipzone.shipzone_id, shipzone.shipzone_name, shipzone.shipzone_descrip, saletype.saletype_code, saletype.saletype_descr, itemsite.itemsite_id, site.warehous_id, site.warehous_code, site.warehous_descrip, item.item_id, item.item_number, item.item_descrip1, item.item_descrip2, ((item.item_descrip1 || ' '::text) || item.item_descrip2) AS itemdescription, COALESCE(item.item_number, cohist.cohist_misc_descrip) AS itemnumber, prodcat.prodcat_id, prodcat.prodcat_code, classcode.classcode_id, classcode.classcode_code, currtobase(cohist.cohist_curr_id, cohist.cohist_commission, cohist.cohist_invcdate) AS basecommission, currtobase(cohist.cohist_curr_id, cohist.cohist_unitprice, cohist.cohist_invcdate) AS baseunitprice, currtocurr(cohist.cohist_curr_id, custinfo.cust_curr_id, cohist.cohist_unitprice, cohist.cohist_invcdate) AS custunitprice FROM ((((((((((((cohist JOIN custinfo ON ((custinfo.cust_id = cohist.cohist_cust_id))) LEFT JOIN cohead ON ((cohead.cohead_number = cohist.cohist_ordernumber))) LEFT JOIN custtype ON ((custtype.custtype_id = custinfo.cust_custtype_id))) LEFT JOIN salesrep ON ((salesrep.salesrep_id = cohist.cohist_salesrep_id))) LEFT JOIN shiptoinfo ON ((shiptoinfo.shipto_id = cohist.cohist_shipto_id))) LEFT JOIN shipzone ON ((shipzone.shipzone_id = shiptoinfo.shipto_shipzone_id))) LEFT JOIN saletype ON ((saletype.saletype_id = cohist.cohist_saletype_id))) JOIN itemsite ON ((itemsite.itemsite_id = cohist.cohist_itemsite_id))) JOIN site() site(warehous_id, warehous_code, warehous_descrip, warehous_fob, warehous_active, warehous_counttag_prefix, warehous_counttag_number, warehous_bol_prefix, warehous_bol_number, warehous_shipping, warehous_useslips, warehous_usezones, warehous_aislesize, warehous_aislealpha, warehous_racksize, warehous_rackalpha, warehous_binsize, warehous_binalpha, warehous_locationsize, warehous_locationalpha, warehous_enforcearbl, warehous_default_accnt_id, warehous_shipping_commission, warehous_cntct_id, warehous_addr_id, warehous_transit, warehous_shipform_id, warehous_shipvia_id, warehous_shipcomments, warehous_costcat_id, warehous_sitetype_id, warehous_taxzone_id, warehous_sequence) ON ((site.warehous_id = itemsite.itemsite_warehous_id))) JOIN item ON ((item.item_id = itemsite.itemsite_item_id))) JOIN prodcat ON ((prodcat.prodcat_id = item.item_prodcat_id))) JOIN classcode ON ((classcode.classcode_id = item.item_classcode_id)))) data; ALTER TABLE saleshistory OWNER TO admin; -- -- Name: VIEW saleshistory; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON VIEW saleshistory IS 'Single point for sales history calculations.'; -- -- Name: saleshistorymisc; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW saleshistorymisc AS SELECT data.cohist_id, data.cohist_cust_id, data.cohist_itemsite_id, data.cohist_shipdate, data.cohist_shipvia, data.cohist_ordernumber, data.cohist_orderdate, data.cohist_invcnumber, data.cohist_invcdate, data.cohist_qtyshipped, data.cohist_unitprice, data.cohist_shipto_id, data.cohist_salesrep_id, data.cohist_duedate, data.cohist_imported, data.cohist_billtoname, data.cohist_billtoaddress1, data.cohist_billtoaddress2, data.cohist_billtoaddress3, data.cohist_billtocity, data.cohist_billtostate, data.cohist_billtozip, data.cohist_shiptoname, data.cohist_shiptoaddress1, data.cohist_shiptoaddress2, data.cohist_shiptoaddress3, data.cohist_shiptocity, data.cohist_shiptostate, data.cohist_shiptozip, data.cohist_commission, data.cohist_commissionpaid, data.cohist_unitcost, data.cohist_misc_type, data.cohist_misc_descrip, data.cohist_misc_id, data.cohist_doctype, data.cohist_promisedate, data.cohist_ponumber, data.cohist_curr_id, data.cohist_sequence, data.cohist_taxtype_id, data.cohist_taxzone_id, data.cohist_cohead_ccpay_id, data.cohist_saletype_id, data.cohist_shipzone_id, data.cohead_id, data.cust_id, data.cust_number, data.cust_name, data.cust_curr_id, data.custtype_id, data.custtype_code, data.custtype_descrip, data.salesrep_id, data.salesrep_number, data.salesrep_name, data.shipzone_id, data.shipzone_name, data.shipzone_descrip, data.saletype_code, data.saletype_descr, data.itemsite_id, data.warehous_id, data.warehous_code, data.warehous_descrip, data.item_id, data.item_number, data.item_descrip1, data.item_descrip2, data.itemdescription, data.itemnumber, data.prodcat_id, data.prodcat_code, data.classcode_id, data.classcode_code, data.basecommission, data.baseunitprice, data.custunitprice, round((data.cohist_qtyshipped * data.cohist_unitprice), 2) AS extprice, round((data.cohist_qtyshipped * data.baseunitprice), 2) AS baseextprice, round((data.cohist_qtyshipped * data.custunitprice), 2) AS custextprice, round((data.cohist_qtyshipped * data.cohist_unitcost), 4) AS extcost, round(((data.cohist_qtyshipped * data.baseunitprice) - (data.cohist_qtyshipped * data.cohist_unitcost)), 2) AS margin, CASE WHEN (round((data.cohist_qtyshipped * data.baseunitprice), 2) > 0.0) THEN (round(((data.cohist_qtyshipped * data.baseunitprice) - (data.cohist_qtyshipped * data.cohist_unitcost)), 2) / round((data.cohist_qtyshipped * data.baseunitprice), 2)) ELSE 0.0 END AS marginpercent, currconcat(data.cohist_curr_id) AS currabbr, 'qty'::text AS cohist_qtyshipped_xtnumericrole, 'salesprice'::text AS cohist_unitprice_xtnumericrole, 'salesprice'::text AS baseunitprice_xtnumericrole, 'curr'::text AS custunitprice_xtnumericrole, 'curr'::text AS custextprice_xtnumericrole, 'curr'::text AS extprice_xtnumericrole, 'curr'::text AS baseextprice_xtnumericrole, 'cost'::text AS cohist_unitcost_xtnumericrole, 'curr'::text AS extcost_xtnumericrole, 'curr'::text AS margin_xtnumericrole, 'percent'::text AS marginpercent_xtnumericrole, 'curr'::text AS cohist_commission_xtnumericrole, 'curr'::text AS basecommission_xtnumericrole FROM (SELECT cohist.cohist_id, cohist.cohist_cust_id, cohist.cohist_itemsite_id, cohist.cohist_shipdate, cohist.cohist_shipvia, cohist.cohist_ordernumber, cohist.cohist_orderdate, cohist.cohist_invcnumber, cohist.cohist_invcdate, cohist.cohist_qtyshipped, cohist.cohist_unitprice, cohist.cohist_shipto_id, cohist.cohist_salesrep_id, cohist.cohist_duedate, cohist.cohist_imported, cohist.cohist_billtoname, cohist.cohist_billtoaddress1, cohist.cohist_billtoaddress2, cohist.cohist_billtoaddress3, cohist.cohist_billtocity, cohist.cohist_billtostate, cohist.cohist_billtozip, cohist.cohist_shiptoname, cohist.cohist_shiptoaddress1, cohist.cohist_shiptoaddress2, cohist.cohist_shiptoaddress3, cohist.cohist_shiptocity, cohist.cohist_shiptostate, cohist.cohist_shiptozip, cohist.cohist_commission, cohist.cohist_commissionpaid, cohist.cohist_unitcost, cohist.cohist_misc_type, cohist.cohist_misc_descrip, cohist.cohist_misc_id, cohist.cohist_doctype, cohist.cohist_promisedate, cohist.cohist_ponumber, cohist.cohist_curr_id, cohist.cohist_sequence, cohist.cohist_taxtype_id, cohist.cohist_taxzone_id, cohist.cohist_cohead_ccpay_id, cohist.cohist_saletype_id, cohist.cohist_shipzone_id, COALESCE(cohead.cohead_id, (-1)) AS cohead_id, custinfo.cust_id, custinfo.cust_number, custinfo.cust_name, custinfo.cust_curr_id, custtype.custtype_id, custtype.custtype_code, custtype.custtype_descrip, salesrep.salesrep_id, salesrep.salesrep_number, salesrep.salesrep_name, shipzone.shipzone_id, shipzone.shipzone_name, shipzone.shipzone_descrip, saletype.saletype_code, saletype.saletype_descr, itemsite.itemsite_id, site.warehous_id, site.warehous_code, site.warehous_descrip, item.item_id, item.item_number, item.item_descrip1, item.item_descrip2, ((item.item_descrip1 || ' '::text) || item.item_descrip2) AS itemdescription, COALESCE(item.item_number, cohist.cohist_misc_descrip) AS itemnumber, prodcat.prodcat_id, prodcat.prodcat_code, classcode.classcode_id, classcode.classcode_code, currtobase(cohist.cohist_curr_id, cohist.cohist_commission, cohist.cohist_invcdate) AS basecommission, currtobase(cohist.cohist_curr_id, cohist.cohist_unitprice, cohist.cohist_invcdate) AS baseunitprice, currtocurr(cohist.cohist_curr_id, custinfo.cust_curr_id, cohist.cohist_unitprice, cohist.cohist_invcdate) AS custunitprice FROM ((((((((((((cohist JOIN custinfo ON ((custinfo.cust_id = cohist.cohist_cust_id))) LEFT JOIN cohead ON ((cohead.cohead_number = cohist.cohist_ordernumber))) LEFT JOIN custtype ON ((custtype.custtype_id = custinfo.cust_custtype_id))) LEFT JOIN salesrep ON ((salesrep.salesrep_id = cohist.cohist_salesrep_id))) LEFT JOIN shiptoinfo ON ((shiptoinfo.shipto_id = cohist.cohist_shipto_id))) LEFT JOIN shipzone ON ((shipzone.shipzone_id = shiptoinfo.shipto_shipzone_id))) LEFT JOIN saletype ON ((saletype.saletype_id = cohist.cohist_saletype_id))) LEFT JOIN itemsite ON ((itemsite.itemsite_id = cohist.cohist_itemsite_id))) LEFT JOIN site() site(warehous_id, warehous_code, warehous_descrip, warehous_fob, warehous_active, warehous_counttag_prefix, warehous_counttag_number, warehous_bol_prefix, warehous_bol_number, warehous_shipping, warehous_useslips, warehous_usezones, warehous_aislesize, warehous_aislealpha, warehous_racksize, warehous_rackalpha, warehous_binsize, warehous_binalpha, warehous_locationsize, warehous_locationalpha, warehous_enforcearbl, warehous_default_accnt_id, warehous_shipping_commission, warehous_cntct_id, warehous_addr_id, warehous_transit, warehous_shipform_id, warehous_shipvia_id, warehous_shipcomments, warehous_costcat_id, warehous_sitetype_id, warehous_taxzone_id, warehous_sequence) ON ((site.warehous_id = itemsite.itemsite_warehous_id))) LEFT JOIN item ON ((item.item_id = itemsite.itemsite_item_id))) LEFT JOIN prodcat ON ((prodcat.prodcat_id = item.item_prodcat_id))) LEFT JOIN classcode ON ((classcode.classcode_id = item.item_classcode_id))) WHERE ((COALESCE(cohist.cohist_misc_type, ''::bpchar) <> 'F'::bpchar) AND (COALESCE(cohist.cohist_misc_type, ''::bpchar) <> 'T'::bpchar))) data; ALTER TABLE saleshistorymisc OWNER TO admin; -- -- Name: VIEW saleshistorymisc; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON VIEW saleshistorymisc IS 'Single point for sales history (including misc. items) calculations.'; -- -- Name: salesrep_salesrep_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE salesrep_salesrep_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE salesrep_salesrep_id_seq OWNER TO admin; -- -- Name: saletype_saletype_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE saletype_saletype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE saletype_saletype_id_seq OWNER TO admin; -- -- Name: saletype_saletype_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE saletype_saletype_id_seq OWNED BY saletype.saletype_id; -- -- Name: schemaord; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE schemaord ( schemaord_id integer NOT NULL, schemaord_name text NOT NULL, schemaord_order integer NOT NULL, CONSTRAINT schemaord_schemaord_name_check CHECK ((length(schemaord_name) > 0)), CONSTRAINT schemaord_schemaord_name_check1 CHECK ((schemaord_name <> ''::text)) ); ALTER TABLE schemaord OWNER TO admin; -- -- Name: TABLE schemaord; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE schemaord IS 'Set the order in which db schemas will appear in the search path after login'; -- -- Name: schemaord_schemaord_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE schemaord_schemaord_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE schemaord_schemaord_id_seq OWNER TO admin; -- -- Name: schemaord_schemaord_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE schemaord_schemaord_id_seq OWNED BY schemaord.schemaord_id; -- -- Name: sequence; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE sequence ( sequence_value integer ); ALTER TABLE sequence OWNER TO admin; -- -- Name: TABLE sequence; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE sequence IS 'Pre-populated list of sequence numbers (1-1000) used for printing Labels and other uses'; -- -- Name: shift_shift_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE shift_shift_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE shift_shift_id_seq OWNER TO admin; -- -- Name: shift_shift_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE shift_shift_id_seq OWNED BY shift.shift_id; -- -- Name: shipchrg_shipchrg_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE shipchrg_shipchrg_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE shipchrg_shipchrg_id_seq OWNER TO admin; -- -- Name: shipchrg_shipchrg_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE shipchrg_shipchrg_id_seq OWNED BY shipchrg.shipchrg_id; -- -- Name: shipdatasum; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE shipdatasum ( shipdatasum_cohead_number text NOT NULL, shipdatasum_cosmisc_tracknum text NOT NULL, shipdatasum_cosmisc_packnum_tracknum text NOT NULL, shipdatasum_weight numeric(16,4), shipdatasum_base_freight numeric(16,4), shipdatasum_total_freight numeric(16,4), shipdatasum_shipper text DEFAULT 'UPS'::text, shipdatasum_billing_option text, shipdatasum_package_type text, shipdatasum_lastupdated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL, shipdatasum_shipped boolean DEFAULT false, shipdatasum_shiphead_number text, shipdatasum_base_freight_curr_id integer DEFAULT basecurrid(), shipdatasum_total_freight_curr_id integer DEFAULT basecurrid() ); ALTER TABLE shipdatasum OWNER TO admin; -- -- Name: TABLE shipdatasum; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE shipdatasum IS 'Shipping Interface information.'; -- -- Name: shipform_shipform_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE shipform_shipform_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE shipform_shipform_id_seq OWNER TO admin; -- -- Name: shiphead_shiphead_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE shiphead_shiphead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE shiphead_shiphead_id_seq OWNER TO admin; -- -- Name: shiphead_shiphead_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE shiphead_shiphead_id_seq OWNED BY shiphead.shiphead_id; -- -- Name: shipitem_shipitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE shipitem_shipitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE shipitem_shipitem_id_seq OWNER TO admin; -- -- Name: shipitem_shipitem_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE shipitem_shipitem_id_seq OWNED BY shipitem.shipitem_id; -- -- Name: shipment_number_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE shipment_number_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE shipment_number_seq OWNER TO admin; -- -- Name: shipto; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW shipto AS SELECT shiptoinfo.shipto_id, shiptoinfo.shipto_cust_id, shiptoinfo.shipto_name, m.addr_line1 AS shipto_address1, m.addr_line2 AS shipto_address2, m.addr_line3 AS shipto_address3, m.addr_city AS shipto_city, m.addr_state AS shipto_state, m.addr_postalcode AS shipto_zipcode, shiptoinfo.shipto_taxzone_id, shiptoinfo.shipto_salesrep_id, c1.cntct_phone AS shipto_phone, shiptoinfo.shipto_comments, shiptoinfo.shipto_shipcomments, btrim(((c1.cntct_first_name || ' '::text) || c1.cntct_last_name)) AS shipto_contact, c1.cntct_fax AS shipto_fax, c1.cntct_email AS shipto_email, shiptoinfo.shipto_shipzone_id, shiptoinfo.shipto_shipvia, shiptoinfo.shipto_commission, shiptoinfo.shipto_shipform_id, shiptoinfo.shipto_shipchrg_id, shiptoinfo.shipto_active, shiptoinfo.shipto_default, shiptoinfo.shipto_num, shiptoinfo.shipto_ediprofile_id, m.addr_country AS shipto_country FROM ((shiptoinfo LEFT JOIN cntct c1 ON ((shiptoinfo.shipto_cntct_id = c1.cntct_id))) LEFT JOIN addr m ON ((shiptoinfo.shipto_addr_id = m.addr_id))); ALTER TABLE shipto OWNER TO admin; -- -- Name: shipto_shipto_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE shipto_shipto_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE shipto_shipto_id_seq OWNER TO admin; -- -- Name: shipvia_shipvia_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE shipvia_shipvia_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE shipvia_shipvia_id_seq OWNER TO admin; -- -- Name: shipzone_shipzone_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE shipzone_shipzone_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE shipzone_shipzone_id_seq OWNER TO admin; -- -- Name: sitetype_sitetype_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE sitetype_sitetype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE sitetype_sitetype_id_seq OWNER TO admin; -- -- Name: sitetype_sitetype_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE sitetype_sitetype_id_seq OWNED BY sitetype.sitetype_id; -- -- Name: sltrans; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE sltrans ( sltrans_id integer DEFAULT nextval('gltrans_gltrans_id_seq'::regclass) NOT NULL, sltrans_created timestamp with time zone, sltrans_date date NOT NULL, sltrans_sequence integer, sltrans_accnt_id integer NOT NULL, sltrans_source text, sltrans_docnumber text, sltrans_misc_id integer, sltrans_amount numeric(20,2) NOT NULL, sltrans_notes text, sltrans_journalnumber integer, sltrans_posted boolean NOT NULL, sltrans_doctype text, sltrans_username text DEFAULT geteffectivextuser() NOT NULL, sltrans_gltrans_journalnumber integer, sltrans_rec boolean DEFAULT false NOT NULL ); ALTER TABLE sltrans OWNER TO admin; -- -- Name: TABLE sltrans; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE sltrans IS 'Journal transaction information'; -- -- Name: sltrans_backup; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE sltrans_backup ( sltrans_old_id integer, sltrans_new_id integer ); ALTER TABLE sltrans_backup OWNER TO admin; -- -- Name: TABLE sltrans_backup; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE sltrans_backup IS 'backup cross references of old and new ids for sltrans 4.0 upgrade.'; -- -- Name: sopack; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW sopack AS SELECT pack.pack_id AS sopack_id, pack.pack_head_id AS sopack_sohead_id, pack.pack_printed AS sopack_printed, pack.pack_shiphead_id AS sopack_cosmisc_id FROM pack WHERE (pack.pack_head_type = 'SO'::text); ALTER TABLE sopack OWNER TO admin; -- -- Name: sopack_sopack_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE sopack_sopack_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE sopack_sopack_id_seq OWNER TO admin; -- -- Name: source; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE source ( source_id integer NOT NULL, source_module text, source_name text NOT NULL, source_descrip text, source_docass_num integer DEFAULT 0 NOT NULL, source_docass text DEFAULT ''::text NOT NULL, source_charass text DEFAULT ''::text NOT NULL, source_table text DEFAULT ''::text NOT NULL, source_key_field text DEFAULT ''::text NOT NULL, source_number_field text DEFAULT ''::text NOT NULL, source_name_field text DEFAULT ''::text NOT NULL, source_desc_field text DEFAULT ''::text NOT NULL, source_widget text DEFAULT ''::text NOT NULL, source_joins text DEFAULT ''::text NOT NULL, source_key_param text DEFAULT ''::text NOT NULL, source_uiform_name text DEFAULT ''::text NOT NULL, source_create_priv text DEFAULT ''::text NOT NULL, source_created timestamp with time zone DEFAULT now() NOT NULL, source_last_modified timestamp with time zone DEFAULT now() NOT NULL, CONSTRAINT source_source_name_check CHECK ((source_name <> ''::text)) ); ALTER TABLE source OWNER TO admin; -- -- Name: TABLE source; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE source IS 'Used to describe different types of document for tax classes, document associations, comment associations, and characteristic associations'; -- -- Name: COLUMN source.source_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN source.source_id IS 'Primary key'; -- -- Name: COLUMN source.source_module; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN source.source_module IS 'Application module'; -- -- Name: COLUMN source.source_name; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN source.source_name IS 'Abbreviation for this document type used on comment associations.'; -- -- Name: COLUMN source.source_descrip; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN source.source_descrip IS 'Human-readable English name for this document type. The client application tries to translate this whenever possible.'; -- -- Name: COLUMN source.source_docass_num; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN source.source_docass_num IS 'Value from the desktop client''s Document::DocumentSources enumeration corresponding to this document type.'; -- -- Name: COLUMN source.source_docass; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN source.source_docass IS 'Abbreviation for this document type used on document associations (docass). Empty indicates cannot used for document associations (see source_widget).'; -- -- Name: COLUMN source.source_charass; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN source.source_charass IS 'Abbreviation for this document type used on characteristic associations (charass). Empty indicates not used for characteristics.'; -- -- Name: COLUMN source.source_table; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN source.source_table IS 'The primary table in which this document is stored.'; -- -- Name: COLUMN source.source_key_field; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN source.source_key_field IS 'The primary key field in the primary table for this document type.'; -- -- Name: COLUMN source.source_number_field; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN source.source_number_field IS 'The column holding the main human-readable identifier for this document (e.g. Bill of Materials document number).'; -- -- Name: COLUMN source.source_name_field; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN source.source_name_field IS 'The column holding the secondary description of this document (e.g. the Item built by a Bill of Materials).'; -- -- Name: COLUMN source.source_desc_field; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN source.source_desc_field IS 'The column holding the longer description of this document (e.g. the first line of the Item''s Description for a Bill of Materials).'; -- -- Name: COLUMN source.source_widget; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN source.source_widget IS 'A hint to the client application of how to let the user select a document to attach. "core" means that the C++ application handles this document type natively. A value starting with "SELECT" is interpreted as a query to populate a combobox, while values containing "Cluster" are treated as the name of a C++ VirtualCluster subclass to instantiate. Empty string means this cannot be used by the desktop client to create document associations (see source_docass).'; -- -- Name: COLUMN source.source_joins; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN source.source_joins IS 'An optional string to add to the FROM clause to get auxiliary information (e.g. "join item_id on bomhead_item_id=item_id").'; -- -- Name: COLUMN source.source_key_param; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN source.source_key_param IS 'The name of the parameter interpreted by the desktop client''s "set" method as containing the primary key to retrieve the main document record for editing or viewing (e.g. most desktop windows take the sales order id in a "sohead_id" parameter even though the database field is "cohead_id").'; -- -- Name: COLUMN source.source_uiform_name; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN source.source_uiform_name IS 'The name of the desktop client application window to open to view or edit this document (e.g. "salesOrder").'; -- -- Name: COLUMN source.source_create_priv; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN source.source_create_priv IS 'A space- or +-delimited set of privileges required to allow creating a new document. If this is specified, an item will be added to the desktop client''s "New" button menu.'; -- -- Name: COLUMN source.source_created; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN source.source_created IS 'The date this source record was created (or the date this column was added to the table:-).'; -- -- Name: COLUMN source.source_last_modified; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN source.source_last_modified IS 'The date this source record was last edited.'; -- -- Name: source_source_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE source_source_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE source_source_id_seq OWNER TO admin; -- -- Name: source_source_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE source_source_id_seq OWNED BY source.source_id; -- -- Name: state; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE state ( state_id integer NOT NULL, state_name text NOT NULL, state_abbr text, state_country_id integer, CONSTRAINT state_state_name_check CHECK ((state_name <> ''::text)) ); ALTER TABLE state OWNER TO admin; -- -- Name: TABLE state; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE state IS 'List of states, provinces, and territories associated with various countries.'; -- -- Name: state_state_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE state_state_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE state_state_id_seq OWNER TO admin; -- -- Name: state_state_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE state_state_id_seq OWNED BY state.state_id; -- -- Name: status; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE status ( status_id integer NOT NULL, status_type text NOT NULL, status_code character(1) NOT NULL, status_name text, status_seq integer, status_color text DEFAULT 'white'::text ); ALTER TABLE status OWNER TO admin; -- -- Name: status_status_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE status_status_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE status_status_id_seq OWNER TO admin; -- -- Name: status_status_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE status_status_id_seq OWNED BY status.status_id; -- -- Name: stdjrnl; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE stdjrnl ( stdjrnl_id integer NOT NULL, stdjrnl_name text NOT NULL, stdjrnl_descrip text, stdjrnl_notes text, CONSTRAINT stdjrnl_stdjrnl_name_check CHECK ((stdjrnl_name <> ''::text)) ); ALTER TABLE stdjrnl OWNER TO admin; -- -- Name: TABLE stdjrnl; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE stdjrnl IS 'Standard Journal information'; -- -- Name: stdjrnl_stdjrnl_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE stdjrnl_stdjrnl_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE stdjrnl_stdjrnl_id_seq OWNER TO admin; -- -- Name: stdjrnl_stdjrnl_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE stdjrnl_stdjrnl_id_seq OWNED BY stdjrnl.stdjrnl_id; -- -- Name: stdjrnlgrp; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE stdjrnlgrp ( stdjrnlgrp_id integer NOT NULL, stdjrnlgrp_name text NOT NULL, stdjrnlgrp_descrip text, CONSTRAINT stdjrnlgrp_stdjrnlgrp_name_check CHECK ((stdjrnlgrp_name <> ''::text)) ); ALTER TABLE stdjrnlgrp OWNER TO admin; -- -- Name: TABLE stdjrnlgrp; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE stdjrnlgrp IS 'Standard Journal Group information'; -- -- Name: stdjrnlgrp_stdjrnlgrp_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE stdjrnlgrp_stdjrnlgrp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE stdjrnlgrp_stdjrnlgrp_id_seq OWNER TO admin; -- -- Name: stdjrnlgrp_stdjrnlgrp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE stdjrnlgrp_stdjrnlgrp_id_seq OWNED BY stdjrnlgrp.stdjrnlgrp_id; -- -- Name: stdjrnlgrpitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE stdjrnlgrpitem ( stdjrnlgrpitem_id integer NOT NULL, stdjrnlgrpitem_stdjrnl_id integer, stdjrnlgrpitem_toapply integer, stdjrnlgrpitem_applied integer, stdjrnlgrpitem_effective date, stdjrnlgrpitem_expires date, stdjrnlgrpitem_stdjrnlgrp_id integer ); ALTER TABLE stdjrnlgrpitem OWNER TO admin; -- -- Name: TABLE stdjrnlgrpitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE stdjrnlgrpitem IS 'Standard Journal Group Item information'; -- -- Name: stdjrnlgrpitem_stdjrnlgrpitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE stdjrnlgrpitem_stdjrnlgrpitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE stdjrnlgrpitem_stdjrnlgrpitem_id_seq OWNER TO admin; -- -- Name: stdjrnlgrpitem_stdjrnlgrpitem_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE stdjrnlgrpitem_stdjrnlgrpitem_id_seq OWNED BY stdjrnlgrpitem.stdjrnlgrpitem_id; -- -- Name: stdjrnlitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE stdjrnlitem ( stdjrnlitem_id integer NOT NULL, stdjrnlitem_stdjrnl_id integer NOT NULL, stdjrnlitem_accnt_id integer NOT NULL, stdjrnlitem_amount numeric(20,2) NOT NULL, stdjrnlitem_notes text ); ALTER TABLE stdjrnlitem OWNER TO admin; -- -- Name: TABLE stdjrnlitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE stdjrnlitem IS 'Standard Journal Item information'; -- -- Name: stdjrnlitem_stdjrnlitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE stdjrnlitem_stdjrnlitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE stdjrnlitem_stdjrnlitem_id_seq OWNER TO admin; -- -- Name: stdjrnlitem_stdjrnlitem_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE stdjrnlitem_stdjrnlitem_id_seq OWNED BY stdjrnlitem.stdjrnlitem_id; -- -- Name: subaccnt; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE subaccnt ( subaccnt_id integer NOT NULL, subaccnt_number text NOT NULL, subaccnt_descrip text, CONSTRAINT subaccnt_subaccnt_number_check CHECK ((subaccnt_number <> ''::text)) ); ALTER TABLE subaccnt OWNER TO admin; -- -- Name: TABLE subaccnt; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE subaccnt IS 'Subaccount information'; -- -- Name: subaccnt_subaccnt_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE subaccnt_subaccnt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE subaccnt_subaccnt_id_seq OWNER TO admin; -- -- Name: subaccnt_subaccnt_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE subaccnt_subaccnt_id_seq OWNED BY subaccnt.subaccnt_id; -- -- Name: subaccnttype; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE subaccnttype ( subaccnttype_id integer NOT NULL, subaccnttype_accnt_type character(1) NOT NULL, subaccnttype_code text NOT NULL, subaccnttype_descrip text ); ALTER TABLE subaccnttype OWNER TO admin; -- -- Name: TABLE subaccnttype; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE subaccnttype IS 'User defined Sub Account Types.'; -- -- Name: subaccnttype_subaccnttype_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE subaccnttype_subaccnttype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE subaccnttype_subaccnttype_id_seq OWNER TO admin; -- -- Name: subaccnttype_subaccnttype_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE subaccnttype_subaccnttype_id_seq OWNED BY subaccnttype.subaccnttype_id; -- -- Name: tax_tax_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE tax_tax_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE tax_tax_id_seq OWNER TO admin; -- -- Name: taxass; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE taxass ( taxass_id integer NOT NULL, taxass_taxzone_id integer, taxass_taxtype_id integer, taxass_tax_id integer NOT NULL ); ALTER TABLE taxass OWNER TO admin; -- -- Name: TABLE taxass; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE taxass IS 'The tax assignment table associates different tax zones and tax types to a given set of tax codes.'; -- -- Name: COLUMN taxass.taxass_taxzone_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxass.taxass_taxzone_id IS 'The id of the tax zone. If NULL any tax zone will apply.'; -- -- Name: COLUMN taxass.taxass_taxtype_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxass.taxass_taxtype_id IS 'The id of the tax type. If NULL any tax type will apply.'; -- -- Name: COLUMN taxass.taxass_tax_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxass.taxass_tax_id IS 'The id of the tax code.'; -- -- Name: taxass_taxass_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE taxass_taxass_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE taxass_taxass_id_seq OWNER TO admin; -- -- Name: taxass_taxass_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE taxass_taxass_id_seq OWNED BY taxass.taxass_id; -- -- Name: taxauth_taxauth_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE taxauth_taxauth_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE taxauth_taxauth_id_seq OWNER TO admin; -- -- Name: taxauth_taxauth_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE taxauth_taxauth_id_seq OWNED BY taxauth.taxauth_id; -- -- Name: taxclass; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE taxclass ( taxclass_id integer NOT NULL, taxclass_code text NOT NULL, taxclass_descrip text, taxclass_sequence integer, CONSTRAINT taxclass_taxclass_code_check CHECK ((taxclass_code <> ''::text)) ); ALTER TABLE taxclass OWNER TO admin; -- -- Name: TABLE taxclass; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE taxclass IS 'Tax class information'; -- -- Name: COLUMN taxclass.taxclass_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxclass.taxclass_id IS 'Primary key'; -- -- Name: COLUMN taxclass.taxclass_code; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxclass.taxclass_code IS 'Code'; -- -- Name: COLUMN taxclass.taxclass_descrip; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxclass.taxclass_descrip IS 'Description'; -- -- Name: COLUMN taxclass.taxclass_sequence; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxclass.taxclass_sequence IS 'Group sequence'; -- -- Name: taxclass_taxclass_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE taxclass_taxclass_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE taxclass_taxclass_id_seq OWNER TO admin; -- -- Name: taxclass_taxclass_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE taxclass_taxclass_id_seq OWNED BY taxclass.taxclass_id; -- -- Name: taxhist_taxhist_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE taxhist_taxhist_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE taxhist_taxhist_id_seq OWNER TO admin; -- -- Name: taxhist_taxhist_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE taxhist_taxhist_id_seq OWNED BY taxhist.taxhist_id; -- -- Name: taxpay; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE taxpay ( taxpay_id integer NOT NULL, taxpay_taxhist_id integer NOT NULL, taxpay_apply_id integer NOT NULL, taxpay_distdate date NOT NULL, taxpay_tax numeric NOT NULL ); ALTER TABLE taxpay OWNER TO admin; -- -- Name: taxpay_taxpay_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE taxpay_taxpay_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE taxpay_taxpay_id_seq OWNER TO admin; -- -- Name: taxpay_taxpay_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE taxpay_taxpay_id_seq OWNED BY taxpay.taxpay_id; -- -- Name: taxrate; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE taxrate ( taxrate_id integer NOT NULL, taxrate_tax_id integer NOT NULL, taxrate_percent numeric(10,6) NOT NULL, taxrate_curr_id integer, taxrate_amount numeric(16,2) NOT NULL, taxrate_effective date, taxrate_expires date ); ALTER TABLE taxrate OWNER TO admin; -- -- Name: TABLE taxrate; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE taxrate IS 'Tax rates.'; -- -- Name: COLUMN taxrate.taxrate_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxrate.taxrate_id IS 'Primary key.'; -- -- Name: COLUMN taxrate.taxrate_tax_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxrate.taxrate_tax_id IS 'The id of the parent tax code.'; -- -- Name: COLUMN taxrate.taxrate_percent; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxrate.taxrate_percent IS 'Tax rate percentage.'; -- -- Name: COLUMN taxrate.taxrate_curr_id; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxrate.taxrate_curr_id IS 'The currency id of the flat rate amount.'; -- -- Name: COLUMN taxrate.taxrate_amount; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxrate.taxrate_amount IS 'Flat tax rate amount.'; -- -- Name: COLUMN taxrate.taxrate_effective; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxrate.taxrate_effective IS 'The effective date of the tax rate. NULL value means always.'; -- -- Name: COLUMN taxrate.taxrate_expires; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN taxrate.taxrate_expires IS 'The expire date of the tax rate. NULL value means never.'; -- -- Name: taxrate_taxrate_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE taxrate_taxrate_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE taxrate_taxrate_id_seq OWNER TO admin; -- -- Name: taxrate_taxrate_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE taxrate_taxrate_id_seq OWNED BY taxrate.taxrate_id; -- -- Name: taxreg_taxreg_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE taxreg_taxreg_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE taxreg_taxreg_id_seq OWNER TO admin; -- -- Name: taxreg_taxreg_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE taxreg_taxreg_id_seq OWNED BY taxreg.taxreg_id; -- -- Name: taxtype_taxtype_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE taxtype_taxtype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE taxtype_taxtype_id_seq OWNER TO admin; -- -- Name: taxtype_taxtype_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE taxtype_taxtype_id_seq OWNED BY taxtype.taxtype_id; -- -- Name: taxzone_taxzone_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE taxzone_taxzone_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE taxzone_taxzone_id_seq OWNER TO admin; -- -- Name: taxzone_taxzone_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE taxzone_taxzone_id_seq OWNED BY taxzone.taxzone_id; -- -- Name: terms_terms_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE terms_terms_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE terms_terms_id_seq OWNER TO admin; -- -- Name: todoitem_todoitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE todoitem_todoitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE todoitem_todoitem_id_seq OWNER TO admin; -- -- Name: todoitem_todoitem_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE todoitem_todoitem_id_seq OWNED BY todoitem.todoitem_id; -- -- Name: trgthist; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE trgthist ( trgthist_src_cntct_id integer NOT NULL, trgthist_trgt_cntct_id integer NOT NULL, trgthist_col text NOT NULL, trgthist_value text NOT NULL ); ALTER TABLE trgthist OWNER TO admin; -- -- Name: trialbal; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE trialbal ( trialbal_id integer NOT NULL, trialbal_period_id integer, trialbal_accnt_id integer, trialbal_beginning numeric(20,2), trialbal_ending numeric(20,2), trialbal_credits numeric(20,2), trialbal_debits numeric(20,2), trialbal_dirty boolean, trialbal_yearend numeric(20,2) DEFAULT 0.00 NOT NULL ); ALTER TABLE trialbal OWNER TO admin; -- -- Name: TABLE trialbal; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE trialbal IS 'Trial Balance information'; -- -- Name: trialbal_trialbal_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE trialbal_trialbal_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE trialbal_trialbal_id_seq OWNER TO admin; -- -- Name: trialbal_trialbal_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE trialbal_trialbal_id_seq OWNED BY trialbal.trialbal_id; -- -- Name: uom_uom_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE uom_uom_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE uom_uom_id_seq OWNER TO admin; -- -- Name: uom_uom_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE uom_uom_id_seq OWNED BY uom.uom_id; -- -- Name: uomconv; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE uomconv ( uomconv_id integer NOT NULL, uomconv_from_uom_id integer NOT NULL, uomconv_from_value numeric(20,10) NOT NULL, uomconv_to_uom_id integer NOT NULL, uomconv_to_value numeric(20,10) NOT NULL, uomconv_fractional boolean DEFAULT false NOT NULL ); ALTER TABLE uomconv OWNER TO admin; -- -- Name: TABLE uomconv; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE uomconv IS 'UOM conversion information. From Unit to To Unit with a value per ratio.'; -- -- Name: uomconv_uomconv_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE uomconv_uomconv_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE uomconv_uomconv_id_seq OWNER TO admin; -- -- Name: uomconv_uomconv_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE uomconv_uomconv_id_seq OWNED BY uomconv.uomconv_id; -- -- Name: uomtype; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE uomtype ( uomtype_id integer NOT NULL, uomtype_name text NOT NULL, uomtype_descrip text, uomtype_multiple boolean DEFAULT false NOT NULL, CONSTRAINT uomtype_uomtype_name_check CHECK ((uomtype_name <> ''::text)) ); ALTER TABLE uomtype OWNER TO admin; -- -- Name: TABLE uomtype; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE uomtype IS 'UOM Type values.'; -- -- Name: uomtype_uomtype_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE uomtype_uomtype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE uomtype_uomtype_id_seq OWNER TO admin; -- -- Name: uomtype_uomtype_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE uomtype_uomtype_id_seq OWNED BY uomtype.uomtype_id; -- -- Name: urlinfo_url_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE urlinfo_url_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE urlinfo_url_id_seq OWNER TO admin; -- -- Name: urlinfo_url_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE urlinfo_url_id_seq OWNED BY urlinfo.url_id; -- -- Name: usrpref; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE usrpref ( usrpref_id integer DEFAULT nextval(('usrpref_usrpref_id_seq'::text)::regclass) NOT NULL, usrpref_name text, usrpref_value text, usrpref_username text ); ALTER TABLE usrpref OWNER TO admin; -- -- Name: TABLE usrpref; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE usrpref IS 'User Preferences information'; -- -- Name: usr; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW usr AS SELECT (pg_user.usesysid)::integer AS usr_id, (pg_user.usename)::text AS usr_username, COALESCE((SELECT usrpref.usrpref_value FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'propername'::text))), ''::text) AS usr_propername, NULL::text AS usr_passwd, COALESCE((SELECT (usrpref.usrpref_value)::integer AS usrpref_value FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'locale_id'::text))), COALESCE((SELECT locale.locale_id FROM locale WHERE (lower(locale.locale_code) = 'default'::text) LIMIT 1), (SELECT locale.locale_id FROM locale ORDER BY locale.locale_id LIMIT 1))) AS usr_locale_id, COALESCE((SELECT usrpref.usrpref_value FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'initials'::text))), ''::text) AS usr_initials, COALESCE((SELECT CASE WHEN (usrpref.usrpref_value = 't'::text) THEN true ELSE false END AS "case" FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'agent'::text))), false) AS usr_agent, COALESCE((SELECT CASE WHEN (usrpref.usrpref_value = 't'::text) THEN true ELSE false END AS "case" FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'active'::text))), usercanlogin((pg_user.usename)::text)) AS usr_active, COALESCE((SELECT usrpref.usrpref_value FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'email'::text))), ''::text) AS usr_email, COALESCE((SELECT usrpref.usrpref_value FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'window'::text))), ''::text) AS usr_window FROM pg_user; ALTER TABLE usr OWNER TO admin; -- -- Name: usr_bak; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE usr_bak ( usr_id integer DEFAULT nextval(('usr_usr_id_seq'::text)::regclass) NOT NULL, usr_username text NOT NULL, usr_propername text, usr_passwd text, usr_locale_id integer NOT NULL, usr_initials text, usr_agent boolean NOT NULL, usr_active boolean NOT NULL, usr_email text, usr_window text ); ALTER TABLE usr_bak OWNER TO admin; -- -- Name: TABLE usr_bak; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE usr_bak IS 'User information'; -- -- Name: usr_usr_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE usr_usr_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE usr_usr_id_seq OWNER TO admin; -- -- Name: usrgrp_usrgrp_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE usrgrp_usrgrp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE usrgrp_usrgrp_id_seq OWNER TO admin; -- -- Name: usrgrp_usrgrp_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE usrgrp_usrgrp_id_seq OWNED BY usrgrp.usrgrp_id; -- -- Name: usrpref_usrpref_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE usrpref_usrpref_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE usrpref_usrpref_id_seq OWNER TO admin; -- -- Name: usrpriv_usrpriv_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE usrpriv_usrpriv_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE usrpriv_usrpriv_id_seq OWNER TO admin; -- -- Name: vend; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW vend AS SELECT vendinfo.vend_id, vendinfo.vend_name, m.addr_line1 AS vend_address1, m.addr_line2 AS vend_address2, m.addr_line3 AS vend_address3, m.addr_city AS vend_city, m.addr_state AS vend_state, m.addr_postalcode AS vend_zip, btrim(((c1.cntct_first_name || ' '::text) || c1.cntct_last_name)) AS vend_contact1, c1.cntct_phone AS vend_phone1, btrim(((c2.cntct_first_name || ' '::text) || c2.cntct_last_name)) AS vend_contact2, c2.cntct_phone AS vend_phone2, vendinfo.vend_lastpurchdate, vendinfo.vend_active, vendinfo.vend_po, vendinfo.vend_comments, vendinfo.vend_pocomments, vendinfo.vend_number, c1.cntct_fax AS vend_fax1, c2.cntct_fax AS vend_fax2, c1.cntct_email AS vend_email1, c2.cntct_email AS vend_email2, vendinfo.vend_1099, vendinfo.vend_exported, vendinfo.vend_fobsource, vendinfo.vend_fob, vendinfo.vend_terms_id, vendinfo.vend_shipvia, vendinfo.vend_vendtype_id, vendinfo.vend_qualified, vendinfo.vend_ediemail, vendinfo.vend_ediemailbody, vendinfo.vend_edisubject, vendinfo.vend_edifilename, vendinfo.vend_accntnum, vendinfo.vend_emailpodelivery, vendinfo.vend_restrictpurch, vendinfo.vend_edicc, m.addr_country AS vend_country, vendinfo.vend_curr_id, vendinfo.vend_taxzone_id FROM (((vendinfo LEFT JOIN cntct c1 ON ((vendinfo.vend_cntct1_id = c1.cntct_id))) LEFT JOIN addr m ON ((vendinfo.vend_addr_id = m.addr_id))) LEFT JOIN cntct c2 ON ((vendinfo.vend_cntct2_id = c2.cntct_id))); ALTER TABLE vend OWNER TO admin; -- -- Name: vend_vend_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE vend_vend_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE vend_vend_id_seq OWNER TO admin; -- -- Name: vendaddr; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW vendaddr AS SELECT vendaddrinfo.vendaddr_id, vendaddrinfo.vendaddr_vend_id, vendaddrinfo.vendaddr_code, vendaddrinfo.vendaddr_name, m.addr_line1 AS vendaddr_address1, m.addr_line2 AS vendaddr_address2, m.addr_line3 AS vendaddr_address3, btrim(((c1.cntct_first_name || ' '::text) || c1.cntct_last_name)) AS vendaddr_contact1, c1.cntct_phone AS vendaddr_phone1, c1.cntct_fax AS vendaddr_fax1, m.addr_city AS vendaddr_city, m.addr_state AS vendaddr_state, m.addr_postalcode AS vendaddr_zipcode, m.addr_country AS vendaddr_country FROM ((vendaddrinfo LEFT JOIN cntct c1 ON ((vendaddrinfo.vendaddr_cntct_id = c1.cntct_id))) LEFT JOIN addr m ON ((vendaddrinfo.vendaddr_addr_id = m.addr_id))); ALTER TABLE vendaddr OWNER TO admin; -- -- Name: vendaddr_vendaddr_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE vendaddr_vendaddr_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE vendaddr_vendaddr_id_seq OWNER TO admin; -- -- Name: vendtype_vendtype_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE vendtype_vendtype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE vendtype_vendtype_id_seq OWNER TO admin; -- -- Name: vendtype_vendtype_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE vendtype_vendtype_id_seq OWNED BY vendtype.vendtype_id; -- -- Name: vodist; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE vodist ( vodist_id integer DEFAULT nextval(('"vodist_vodist_id_seq"'::text)::regclass) NOT NULL, vodist_poitem_id integer, vodist_vohead_id integer, vodist_costelem_id integer, vodist_accnt_id integer, vodist_amount numeric(18,6), vodist_qty numeric(18,6), vodist_expcat_id integer DEFAULT (-1), vodist_tax_id integer DEFAULT (-1), vodist_discountable boolean DEFAULT true NOT NULL, vodist_notes text ); ALTER TABLE vodist OWNER TO admin; -- -- Name: TABLE vodist; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE vodist IS 'Voucher distribution information'; -- -- Name: vodist_vodist_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE vodist_vodist_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE vodist_vodist_id_seq OWNER TO admin; -- -- Name: vohead; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE vohead ( vohead_id integer DEFAULT nextval(('vohead_vohead_id_seq'::text)::regclass) NOT NULL, vohead_number text NOT NULL, vohead_pohead_id integer, vohead_posted boolean, vohead_duedate date, vohead_invcnumber text, vohead_amount numeric(16,4), vohead_docdate date, vohead_1099 boolean, vohead_distdate date, vohead_reference text, vohead_terms_id integer, vohead_vend_id integer, vohead_curr_id integer DEFAULT basecurrid(), vohead_adjtaxtype_id integer, vohead_freighttaxtype_id integer, vohead_gldistdate date, vohead_misc boolean, vohead_taxzone_id integer, vohead_taxtype_id integer, vohead_notes text, vohead_recurring_vohead_id integer, CONSTRAINT vohead_vohead_number_check CHECK ((vohead_number <> ''::text)) ); ALTER TABLE vohead OWNER TO admin; -- -- Name: TABLE vohead; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE vohead IS 'Voucher header information'; -- -- Name: vohead_vohead_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE vohead_vohead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE vohead_vohead_id_seq OWNER TO admin; -- -- Name: voheadtax; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE voheadtax ( ) INHERITS (taxhist); ALTER TABLE voheadtax OWNER TO admin; -- -- Name: voitem; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE voitem ( voitem_id integer DEFAULT nextval(('"voitem_voitem_id_seq"'::text)::regclass) NOT NULL, voitem_vohead_id integer, voitem_poitem_id integer, voitem_close boolean, voitem_qty numeric(18,6), voitem_freight numeric(16,4) DEFAULT 0.0 NOT NULL, voitem_taxtype_id integer ); ALTER TABLE voitem OWNER TO admin; -- -- Name: TABLE voitem; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE voitem IS 'Voucher Line Item information'; -- -- Name: voitem_voitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE voitem_voitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE voitem_voitem_id_seq OWNER TO admin; -- -- Name: voitemtax; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE voitemtax ( ) INHERITS (taxhist); ALTER TABLE voitemtax OWNER TO admin; -- -- Name: warehous; Type: VIEW; Schema: public; Owner: admin -- CREATE VIEW warehous AS SELECT whsinfo.warehous_id, whsinfo.warehous_code, whsinfo.warehous_descrip, m.addr_line1 AS warehous_addr1, m.addr_line2 AS warehous_addr2, m.addr_line3 AS warehous_addr3, m.addr_city AS warehous_addr4, m.addr_city AS warehous_city, m.addr_state AS warehous_state, m.addr_postalcode AS warehous_zip, m.addr_country AS warehous_country, whsinfo.warehous_fob, whsinfo.warehous_active, whsinfo.warehous_sitetype_id, whsinfo.warehous_counttag_prefix, whsinfo.warehous_counttag_number, whsinfo.warehous_bol_prefix, whsinfo.warehous_bol_number, whsinfo.warehous_shipping, whsinfo.warehous_useslips, whsinfo.warehous_usezones, whsinfo.warehous_aislesize, whsinfo.warehous_aislealpha, whsinfo.warehous_racksize, whsinfo.warehous_rackalpha, whsinfo.warehous_binsize, whsinfo.warehous_binalpha, whsinfo.warehous_locationsize, whsinfo.warehous_locationalpha, whsinfo.warehous_enforcearbl, whsinfo.warehous_default_accnt_id, whsinfo.warehous_shipping_commission FROM ((whsinfo LEFT JOIN cntct c1 ON ((whsinfo.warehous_cntct_id = c1.cntct_id))) LEFT JOIN addr m ON ((whsinfo.warehous_addr_id = m.addr_id))); ALTER TABLE warehous OWNER TO admin; -- -- Name: warehous_warehous_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE warehous_warehous_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE warehous_warehous_id_seq OWNER TO admin; -- -- Name: whsezone_whsezone_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE whsezone_whsezone_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE whsezone_whsezone_id_seq OWNER TO admin; -- -- Name: whsezone_whsezone_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE whsezone_whsezone_id_seq OWNED BY whsezone.whsezone_id; -- -- Name: wo; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE wo ( wo_id integer DEFAULT nextval(('wo_wo_id_seq'::text)::regclass) NOT NULL, wo_number integer, wo_subnumber integer, wo_status character(1), wo_itemsite_id integer, wo_startdate date, wo_duedate date, wo_ordtype character(1), wo_ordid integer, wo_qtyord numeric(18,6), wo_qtyrcv numeric(18,6), wo_adhoc boolean, wo_itemcfg_series integer, wo_imported boolean, wo_wipvalue numeric(16,6) DEFAULT 0, wo_postedvalue numeric(16,6) DEFAULT 0, wo_prodnotes text, wo_prj_id integer, wo_priority integer DEFAULT 1 NOT NULL, wo_brdvalue numeric(16,6) DEFAULT 0, wo_bom_rev_id integer DEFAULT (-1), wo_boo_rev_id integer DEFAULT (-1), wo_cosmethod character(1), wo_womatl_id integer, wo_username text DEFAULT geteffectivextuser(), CONSTRAINT chk_wo_cosmethod CHECK ((((wo_cosmethod = NULL::bpchar) OR (wo_cosmethod = 'D'::bpchar)) OR (wo_cosmethod = 'P'::bpchar))) ); ALTER TABLE wo OWNER TO admin; -- -- Name: TABLE wo; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE wo IS 'Work Order information'; -- -- Name: wo_wo_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE wo_wo_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE wo_wo_id_seq OWNER TO admin; -- -- Name: womatl_womatl_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE womatl_womatl_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE womatl_womatl_id_seq OWNER TO admin; -- -- Name: womatlpost; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE womatlpost ( womatlpost_id integer NOT NULL, womatlpost_womatl_id integer, womatlpost_invhist_id integer ); ALTER TABLE womatlpost OWNER TO admin; -- -- Name: TABLE womatlpost; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE womatlpost IS 'Table to tie work order to work order material transactions for efficient queries'; -- -- Name: womatlpost_womatlpost_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE womatlpost_womatlpost_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE womatlpost_womatlpost_id_seq OWNER TO admin; -- -- Name: womatlpost_womatlpost_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE womatlpost_womatlpost_id_seq OWNED BY womatlpost.womatlpost_id; -- -- Name: womatlvar; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE womatlvar ( womatlvar_id integer DEFAULT nextval(('"womatlvar_womatlvar_id_seq"'::text)::regclass) NOT NULL, womatlvar_number integer, womatlvar_subnumber integer, womatlvar_posted date, womatlvar_parent_itemsite_id integer, womatlvar_component_itemsite_id integer, womatlvar_qtyord numeric(18,6), womatlvar_qtyrcv numeric(18,6), womatlvar_qtyiss numeric(18,6), womatlvar_qtyper numeric(18,6), womatlvar_scrap numeric(18,6), womatlvar_wipscrap numeric(18,6), womatlvar_bomitem_id integer, womatlvar_ref text, womatlvar_notes text, womatlvar_qtyfxd numeric(20,8) DEFAULT 0 NOT NULL ); ALTER TABLE womatlvar OWNER TO admin; -- -- Name: TABLE womatlvar; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE womatlvar IS 'Work Order Material Requirements Variance information'; -- -- Name: COLUMN womatlvar.womatlvar_qtyfxd; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON COLUMN womatlvar.womatlvar_qtyfxd IS 'The fixed quantity required'; -- -- Name: womatlvar_womatlvar_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE womatlvar_womatlvar_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ALTER TABLE womatlvar_womatlvar_id_seq OWNER TO admin; -- -- Name: xcalitem_xcalitem_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE xcalitem_xcalitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE xcalitem_xcalitem_id_seq OWNER TO admin; -- -- Name: xsltmap; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE xsltmap ( xsltmap_id integer NOT NULL, xsltmap_name text NOT NULL, xsltmap_doctype text NOT NULL, xsltmap_system text NOT NULL, xsltmap_import text NOT NULL, xsltmap_export text DEFAULT ''::text NOT NULL, CONSTRAINT xsltmap_check CHECK (((xsltmap_doctype <> ''::text) OR (xsltmap_system <> ''::text))), CONSTRAINT xsltmap_xsltmap_importexport_check CHECK (((xsltmap_import <> ''::text) OR (xsltmap_export <> ''::text))), CONSTRAINT xsltmap_xsltmap_name_check CHECK ((xsltmap_name <> ''::text)) ); ALTER TABLE xsltmap OWNER TO admin; -- -- Name: TABLE xsltmap; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE xsltmap IS 'Mapping of XML System identifiers to XSLT transformation files'; -- -- Name: xsltmap_xsltmap_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE xsltmap_xsltmap_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE xsltmap_xsltmap_id_seq OWNER TO admin; -- -- Name: xsltmap_xsltmap_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE xsltmap_xsltmap_id_seq OWNED BY xsltmap.xsltmap_id; -- -- Name: yearperiod; Type: TABLE; Schema: public; Owner: admin; Tablespace: -- CREATE TABLE yearperiod ( yearperiod_id integer NOT NULL, yearperiod_start date NOT NULL, yearperiod_end date NOT NULL, yearperiod_closed boolean DEFAULT false NOT NULL ); ALTER TABLE yearperiod OWNER TO admin; -- -- Name: TABLE yearperiod; Type: COMMENT; Schema: public; Owner: admin -- COMMENT ON TABLE yearperiod IS 'Accounting Year Periods information'; -- -- Name: yearperiod_yearperiod_id_seq; Type: SEQUENCE; Schema: public; Owner: admin -- CREATE SEQUENCE yearperiod_yearperiod_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE yearperiod_yearperiod_id_seq OWNER TO admin; -- -- Name: yearperiod_yearperiod_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: admin -- ALTER SEQUENCE yearperiod_yearperiod_id_seq OWNED BY yearperiod.yearperiod_id; SET search_path = te, pg_catalog; -- -- Name: pkgcmd; Type: TABLE; Schema: te; Owner: admin; Tablespace: -- CREATE TABLE pkgcmd ( cmd_id integer DEFAULT nextval('public.cmd_cmd_id_seq'::regclass) ) INHERITS (public.cmd); ALTER TABLE pkgcmd OWNER TO admin; -- -- Name: pkgcmdarg; Type: TABLE; Schema: te; Owner: admin; Tablespace: -- CREATE TABLE pkgcmdarg ( cmdarg_id integer DEFAULT nextval('public.cmdarg_cmdarg_id_seq'::regclass) ) INHERITS (public.cmdarg); ALTER TABLE pkgcmdarg OWNER TO admin; -- -- Name: pkgimage; Type: TABLE; Schema: te; Owner: admin; Tablespace: -- CREATE TABLE pkgimage ( image_id integer DEFAULT nextval('public.image_image_id_seq'::regclass) ) INHERITS (public.image); ALTER TABLE pkgimage OWNER TO admin; -- -- Name: pkgmetasql; Type: TABLE; Schema: te; Owner: admin; Tablespace: -- CREATE TABLE pkgmetasql ( metasql_id integer DEFAULT nextval('public.metasql_metasql_id_seq'::regclass) ) INHERITS (public.metasql); ALTER TABLE pkgmetasql OWNER TO admin; -- -- Name: pkgpriv; Type: TABLE; Schema: te; Owner: admin; Tablespace: -- CREATE TABLE pkgpriv ( priv_id integer DEFAULT nextval('public.priv_priv_id_seq'::regclass) ) INHERITS (public.priv); ALTER TABLE pkgpriv OWNER TO admin; -- -- Name: pkgreport; Type: TABLE; Schema: te; Owner: admin; Tablespace: -- CREATE TABLE pkgreport ( report_id integer DEFAULT nextval('public.report_report_id_seq'::regclass) ) INHERITS (public.report); ALTER TABLE pkgreport OWNER TO admin; -- -- Name: pkgscript; Type: TABLE; Schema: te; Owner: admin; Tablespace: -- CREATE TABLE pkgscript ( script_id integer DEFAULT nextval('public.script_script_id_seq'::regclass) ) INHERITS (public.script); ALTER TABLE pkgscript OWNER TO admin; -- -- Name: pkguiform; Type: TABLE; Schema: te; Owner: admin; Tablespace: -- CREATE TABLE pkguiform ( uiform_id integer DEFAULT nextval('public.uiform_uiform_id_seq'::regclass) ) INHERITS (public.uiform); ALTER TABLE pkguiform OWNER TO admin; -- -- Name: tecustrate; Type: TABLE; Schema: te; Owner: admin; Tablespace: -- CREATE TABLE tecustrate ( tecustrate_cust_id integer NOT NULL, tecustrate_rate numeric(16,4) NOT NULL, tecustrate_id integer NOT NULL, tecustrate_curr_id integer DEFAULT public.basecurrid() NOT NULL ); ALTER TABLE tecustrate OWNER TO admin; -- -- Name: TABLE tecustrate; Type: COMMENT; Schema: te; Owner: admin -- COMMENT ON TABLE tecustrate IS 'Customer rate'; -- -- Name: tecustrate_tecustrate_id_seq; Type: SEQUENCE; Schema: te; Owner: admin -- CREATE SEQUENCE tecustrate_tecustrate_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE tecustrate_tecustrate_id_seq OWNER TO admin; -- -- Name: tecustrate_tecustrate_id_seq; Type: SEQUENCE OWNED BY; Schema: te; Owner: admin -- ALTER SEQUENCE tecustrate_tecustrate_id_seq OWNED BY tecustrate.tecustrate_id; -- -- Name: teemp; Type: TABLE; Schema: te; Owner: admin; Tablespace: -- CREATE TABLE teemp ( teemp_id integer NOT NULL, teemp_emp_id integer, teemp_contractor boolean DEFAULT false ); ALTER TABLE teemp OWNER TO admin; -- -- Name: TABLE teemp; Type: COMMENT; Schema: te; Owner: admin -- COMMENT ON TABLE teemp IS 'Time Expense Employee'; -- -- Name: teemp_teemp_id_seq; Type: SEQUENCE; Schema: te; Owner: admin -- CREATE SEQUENCE teemp_teemp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE teemp_teemp_id_seq OWNER TO admin; -- -- Name: teemp_teemp_id_seq; Type: SEQUENCE OWNED BY; Schema: te; Owner: admin -- ALTER SEQUENCE teemp_teemp_id_seq OWNED BY teemp.teemp_id; -- -- Name: teexp; Type: TABLE; Schema: te; Owner: admin; Tablespace: -- CREATE TABLE teexp ( teexp_id integer NOT NULL, teexp_expcat_id integer, teexp_accnt_id integer ); ALTER TABLE teexp OWNER TO admin; -- -- Name: TABLE teexp; Type: COMMENT; Schema: te; Owner: admin -- COMMENT ON TABLE teexp IS 'Time Expense Item Master'; -- -- Name: timesheet_seq; Type: SEQUENCE; Schema: te; Owner: admin -- CREATE SEQUENCE timesheet_seq START WITH 1000 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE timesheet_seq OWNER TO admin; -- -- Name: tehead; Type: TABLE; Schema: te; Owner: admin; Tablespace: -- CREATE TABLE tehead ( tehead_id integer NOT NULL, tehead_number text DEFAULT nextval('timesheet_seq'::regclass), tehead_weekending date, tehead_lastupdated timestamp without time zone DEFAULT now() NOT NULL, tehead_notes text, tehead_status character(1) DEFAULT 'O'::bpchar NOT NULL, tehead_emp_id integer, tehead_warehous_id integer NOT NULL, tehead_username text DEFAULT public.geteffectivextuser() NOT NULL, CONSTRAINT tehead_tehead_status_check CHECK ((tehead_status = ANY (ARRAY['O'::bpchar, 'A'::bpchar, 'C'::bpchar]))) ); ALTER TABLE tehead OWNER TO admin; -- -- Name: TABLE tehead; Type: COMMENT; Schema: te; Owner: admin -- COMMENT ON TABLE tehead IS 'Time/Expense Worksheet Header'; -- -- Name: tehead_tehead_id_seq; Type: SEQUENCE; Schema: te; Owner: admin -- CREATE SEQUENCE tehead_tehead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE tehead_tehead_id_seq OWNER TO admin; -- -- Name: tehead_tehead_id_seq; Type: SEQUENCE OWNED BY; Schema: te; Owner: admin -- ALTER SEQUENCE tehead_tehead_id_seq OWNED BY tehead.tehead_id; -- -- Name: teitem; Type: TABLE; Schema: te; Owner: admin; Tablespace: -- CREATE TABLE teitem ( teitem_id integer NOT NULL, teitem_tehead_id integer, teitem_linenumber integer NOT NULL, teitem_type character(1) NOT NULL, teitem_workdate date, teitem_cust_id integer, teitem_vend_id integer, teitem_po text, teitem_item_id integer NOT NULL, teitem_qty numeric NOT NULL, teitem_rate numeric NOT NULL, teitem_total numeric NOT NULL, teitem_prjtask_id integer, teitem_lastupdated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL, teitem_billable boolean, teitem_prepaid boolean, teitem_notes text, teitem_posted boolean DEFAULT false, teitem_curr_id integer DEFAULT public.basecurrid() NOT NULL, teitem_uom_id integer, teitem_invcitem_id integer, teitem_vodist_id integer, teitem_postedvalue numeric DEFAULT 0 NOT NULL, teitem_empcost numeric ); ALTER TABLE teitem OWNER TO admin; -- -- Name: TABLE teitem; Type: COMMENT; Schema: te; Owner: admin -- COMMENT ON TABLE teitem IS 'Time Expense Worksheet Item'; -- -- Name: COLUMN teitem.teitem_type; Type: COMMENT; Schema: te; Owner: admin -- COMMENT ON COLUMN teitem.teitem_type IS 'T or E'; -- -- Name: COLUMN teitem.teitem_vend_id; Type: COMMENT; Schema: te; Owner: admin -- COMMENT ON COLUMN teitem.teitem_vend_id IS 'future use - for payment of vendor for expenses'; -- -- Name: COLUMN teitem.teitem_prepaid; Type: COMMENT; Schema: te; Owner: admin -- COMMENT ON COLUMN teitem.teitem_prepaid IS 'Used for expenses only. CC paid expenses would be prepaid.'; -- -- Name: teitem_teitem_id_seq; Type: SEQUENCE; Schema: te; Owner: admin -- CREATE SEQUENCE teitem_teitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE teitem_teitem_id_seq OWNER TO admin; -- -- Name: teitem_teitem_id_seq; Type: SEQUENCE OWNED BY; Schema: te; Owner: admin -- ALTER SEQUENCE teitem_teitem_id_seq OWNED BY teitem.teitem_id; -- -- Name: teprj; Type: TABLE; Schema: te; Owner: admin; Tablespace: -- CREATE TABLE teprj ( teprj_id integer NOT NULL, teprj_prj_id integer, teprj_cust_id integer, teprj_rate numeric, teprj_curr_id integer ); ALTER TABLE teprj OWNER TO admin; -- -- Name: TABLE teprj; Type: COMMENT; Schema: te; Owner: admin -- COMMENT ON TABLE teprj IS 'Time/Expense Information for Projects'; -- -- Name: teprj_teprj_id_seq; Type: SEQUENCE; Schema: te; Owner: admin -- CREATE SEQUENCE teprj_teprj_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE teprj_teprj_id_seq OWNER TO admin; -- -- Name: teprj_teprj_id_seq; Type: SEQUENCE OWNED BY; Schema: te; Owner: admin -- ALTER SEQUENCE teprj_teprj_id_seq OWNED BY teprj.teprj_id; -- -- Name: teprjtask; Type: TABLE; Schema: te; Owner: admin; Tablespace: -- CREATE TABLE teprjtask ( teprjtask_id integer NOT NULL, teprjtask_cust_id integer, teprjtask_rate numeric, teprjtask_item_id integer, teprjtask_prjtask_id integer NOT NULL, teprjtask_curr_id integer DEFAULT public.basecurrid() ); ALTER TABLE teprjtask OWNER TO admin; -- -- Name: TABLE teprjtask; Type: COMMENT; Schema: te; Owner: admin -- COMMENT ON TABLE teprjtask IS 'Time Expense Project Task'; -- -- Name: teprjtask_teprjtask_id_seq; Type: SEQUENCE; Schema: te; Owner: admin -- CREATE SEQUENCE teprjtask_teprjtask_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE teprjtask_teprjtask_id_seq OWNER TO admin; -- -- Name: teprjtask_teprjtask_id_seq; Type: SEQUENCE OWNED BY; Schema: te; Owner: admin -- ALTER SEQUENCE teprjtask_teprjtask_id_seq OWNED BY teprjtask.teprjtask_id; SET search_path = xt, pg_catalog; -- -- Name: js; Type: TABLE; Schema: xt; Owner: admin; Tablespace: -- CREATE TABLE js ( js_id integer NOT NULL, js_text text NOT NULL, js_namespace text NOT NULL, js_type text NOT NULL, js_context text NOT NULL, js_ext boolean DEFAULT false NOT NULL, js_active boolean DEFAULT true NOT NULL ); ALTER TABLE js OWNER TO admin; -- -- Name: TABLE js; Type: COMMENT; Schema: xt; Owner: admin -- COMMENT ON TABLE js IS 'Core table for xTuple JavaScript Objects Reference'; -- -- Name: js_js_id_seq; Type: SEQUENCE; Schema: xt; Owner: admin -- CREATE SEQUENCE js_js_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ALTER TABLE js_js_id_seq OWNER TO admin; -- -- Name: js_js_id_seq; Type: SEQUENCE OWNED BY; Schema: xt; Owner: admin -- ALTER SEQUENCE js_js_id_seq OWNED BY js.js_id; SET search_path = xtdesktop, pg_catalog; -- -- Name: pkgcmd; Type: TABLE; Schema: xtdesktop; Owner: admin; Tablespace: -- CREATE TABLE pkgcmd ( cmd_id integer DEFAULT nextval('public.cmd_cmd_id_seq'::regclass) ) INHERITS (public.cmd); ALTER TABLE pkgcmd OWNER TO admin; -- -- Name: pkgcmdarg; Type: TABLE; Schema: xtdesktop; Owner: admin; Tablespace: -- CREATE TABLE pkgcmdarg ( cmdarg_id integer DEFAULT nextval('public.cmdarg_cmdarg_id_seq'::regclass) ) INHERITS (public.cmdarg); ALTER TABLE pkgcmdarg OWNER TO admin; -- -- Name: pkgimage; Type: TABLE; Schema: xtdesktop; Owner: admin; Tablespace: -- CREATE TABLE pkgimage ( image_id integer DEFAULT nextval('public.image_image_id_seq'::regclass) ) INHERITS (public.image); ALTER TABLE pkgimage OWNER TO admin; -- -- Name: pkgmetasql; Type: TABLE; Schema: xtdesktop; Owner: admin; Tablespace: -- CREATE TABLE pkgmetasql ( metasql_id integer DEFAULT nextval('public.metasql_metasql_id_seq'::regclass) ) INHERITS (public.metasql); ALTER TABLE pkgmetasql OWNER TO admin; -- -- Name: pkgpriv; Type: TABLE; Schema: xtdesktop; Owner: admin; Tablespace: -- CREATE TABLE pkgpriv ( priv_id integer DEFAULT nextval('public.priv_priv_id_seq'::regclass) ) INHERITS (public.priv); ALTER TABLE pkgpriv OWNER TO admin; -- -- Name: pkgreport; Type: TABLE; Schema: xtdesktop; Owner: admin; Tablespace: -- CREATE TABLE pkgreport ( report_id integer DEFAULT nextval('public.report_report_id_seq'::regclass) ) INHERITS (public.report); ALTER TABLE pkgreport OWNER TO admin; -- -- Name: pkgscript; Type: TABLE; Schema: xtdesktop; Owner: admin; Tablespace: -- CREATE TABLE pkgscript ( script_id integer DEFAULT nextval('public.script_script_id_seq'::regclass) ) INHERITS (public.script); ALTER TABLE pkgscript OWNER TO admin; -- -- Name: pkguiform; Type: TABLE; Schema: xtdesktop; Owner: admin; Tablespace: -- CREATE TABLE pkguiform ( uiform_id integer DEFAULT nextval('public.uiform_uiform_id_seq'::regclass) ) INHERITS (public.uiform); ALTER TABLE pkguiform OWNER TO admin; SET search_path = fixcountry, pg_catalog; -- -- Name: metasql_grade; Type: DEFAULT; Schema: fixcountry; Owner: admin -- ALTER TABLE ONLY pkgmetasql ALTER COLUMN metasql_grade SET DEFAULT 0; -- -- Name: script_enabled; Type: DEFAULT; Schema: fixcountry; Owner: admin -- ALTER TABLE ONLY pkgscript ALTER COLUMN script_enabled SET DEFAULT false; -- -- Name: uiform_enabled; Type: DEFAULT; Schema: fixcountry; Owner: admin -- ALTER TABLE ONLY pkguiform ALTER COLUMN uiform_enabled SET DEFAULT false; SET search_path = public, pg_catalog; -- -- Name: addr_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY addr ALTER COLUMN addr_id SET DEFAULT nextval('addr_addr_id_seq'::regclass); -- -- Name: alarm_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY alarm ALTER COLUMN alarm_id SET DEFAULT nextval('alarm_alarm_id_seq'::regclass); -- -- Name: apaccnt_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY apaccnt ALTER COLUMN apaccnt_id SET DEFAULT nextval('apaccnt_apaccnt_id_seq'::regclass); -- -- Name: apapply_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY apapply ALTER COLUMN apapply_id SET DEFAULT nextval('apapply_apapply_id_seq'::regclass); -- -- Name: apcreditapply_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY apcreditapply ALTER COLUMN apcreditapply_id SET DEFAULT nextval('apcreditapply_apcreditapply_id_seq'::regclass); -- -- Name: taxhist_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY apopentax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); -- -- Name: apselect_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY apselect ALTER COLUMN apselect_id SET DEFAULT nextval('apselect_apselect_id_seq'::regclass); -- -- Name: arapply_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY arapply ALTER COLUMN arapply_id SET DEFAULT nextval('arapply_arapply_id_seq'::regclass); -- -- Name: taxhist_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY aropentax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); -- -- Name: asohist_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY asohist ALTER COLUMN asohist_id SET DEFAULT nextval('asohist_asohist_id_seq'::regclass); -- -- Name: taxhist_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY asohisttax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); -- -- Name: atlasmap_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY atlasmap ALTER COLUMN atlasmap_id SET DEFAULT nextval('atlasmap_atlasmap_id_seq'::regclass); -- -- Name: bankaccnt_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY bankaccnt ALTER COLUMN bankaccnt_id SET DEFAULT nextval('bankaccnt_bankaccnt_id_seq'::regclass); -- -- Name: bankadj_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY bankadj ALTER COLUMN bankadj_id SET DEFAULT nextval('bankadj_bankadj_id_seq'::regclass); -- -- Name: bankadjtype_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY bankadjtype ALTER COLUMN bankadjtype_id SET DEFAULT nextval('bankadjtype_bankadjtype_id_seq'::regclass); -- -- Name: bankrec_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY bankrec ALTER COLUMN bankrec_id SET DEFAULT nextval('bankrec_bankrec_id_seq'::regclass); -- -- Name: bankrecimport_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY bankrecimport ALTER COLUMN bankrecimport_id SET DEFAULT nextval('bankrecimport_bankrecimport_id_seq'::regclass); -- -- Name: bankrecitem_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY bankrecitem ALTER COLUMN bankrecitem_id SET DEFAULT nextval('bankrecitem_bankrecitem_id_seq'::regclass); -- -- Name: bomitemcost_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY bomitemcost ALTER COLUMN bomitemcost_id SET DEFAULT nextval('bomitemcost_bomitemcost_id_seq'::regclass); -- -- Name: bomitemsub_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY bomitemsub ALTER COLUMN bomitemsub_id SET DEFAULT nextval('bomitemsub_bomitemsub_id_seq'::regclass); -- -- Name: bomwork_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY bomwork ALTER COLUMN bomwork_id SET DEFAULT nextval('bomwork_bomwork_id_seq'::regclass); -- -- Name: budghead_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY budghead ALTER COLUMN budghead_id SET DEFAULT nextval('budghead_budghead_id_seq'::regclass); -- -- Name: budgitem_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY budgitem ALTER COLUMN budgitem_id SET DEFAULT nextval('budgitem_budgitem_id_seq'::regclass); -- -- Name: cashrcpt_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY cashrcpt ALTER COLUMN cashrcpt_id SET DEFAULT nextval('cashrcpt_cashrcpt_id_seq'::regclass); -- -- Name: cashrcptitem_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY cashrcptitem ALTER COLUMN cashrcptitem_id SET DEFAULT nextval('cashrcptitem_cashrcptitem_id_seq'::regclass); -- -- Name: cashrcptmisc_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY cashrcptmisc ALTER COLUMN cashrcptmisc_id SET DEFAULT nextval('cashrcptmisc_cashrcptmisc_id_seq'::regclass); -- -- Name: ccard_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY ccard ALTER COLUMN ccard_id SET DEFAULT nextval('ccard_ccard_id_seq'::regclass); -- -- Name: ccardaud_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY ccardaud ALTER COLUMN ccardaud_id SET DEFAULT nextval('ccardaud_ccardaud_id_seq'::regclass); -- -- Name: ccbank_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY ccbank ALTER COLUMN ccbank_id SET DEFAULT nextval('ccbank_ccbank_id_seq'::regclass); -- -- Name: ccpay_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY ccpay ALTER COLUMN ccpay_id SET DEFAULT nextval('ccpay_ccpay_id_seq'::regclass); -- -- Name: char_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY "char" ALTER COLUMN char_id SET DEFAULT nextval('char_char_id_seq'::regclass); -- -- Name: charass_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY charass ALTER COLUMN charass_id SET DEFAULT nextval('charass_charass_id_seq'::regclass); -- -- Name: charopt_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY charopt ALTER COLUMN charopt_id SET DEFAULT nextval('charopt_charopt_id_seq'::regclass); -- -- Name: charuse_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY charuse ALTER COLUMN charuse_id SET DEFAULT nextval('charuse_charuse_id_seq'::regclass); -- -- Name: checkhead_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY checkhead ALTER COLUMN checkhead_id SET DEFAULT nextval('checkhead_checkhead_id_seq'::regclass); -- -- Name: checkitem_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY checkitem ALTER COLUMN checkitem_id SET DEFAULT nextval('checkitem_checkitem_id_seq'::regclass); -- -- Name: cmd_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmd ALTER COLUMN cmd_id SET DEFAULT nextval('cmd_cmd_id_seq'::regclass); -- -- Name: cmdarg_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmdarg ALTER COLUMN cmdarg_id SET DEFAULT nextval('cmdarg_cmdarg_id_seq'::regclass); -- -- Name: taxhist_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmheadtax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); -- -- Name: taxhist_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmitemtax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); -- -- Name: cmnttype_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmnttype ALTER COLUMN cmnttype_id SET DEFAULT nextval('cmnttype_cmnttype_id_seq'::regclass); -- -- Name: cmnttypesource_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmnttypesource ALTER COLUMN cmnttypesource_id SET DEFAULT nextval('cmnttypesource_cmnttypesource_id_seq'::regclass); -- -- Name: cntct_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY cntct ALTER COLUMN cntct_id SET DEFAULT nextval('cntct_cntct_id_seq'::regclass); -- -- Name: cntctaddr_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY cntctaddr ALTER COLUMN cntctaddr_id SET DEFAULT nextval('cntctaddr_cntctaddr_id_seq'::regclass); -- -- Name: cntctdata_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY cntctdata ALTER COLUMN cntctdata_id SET DEFAULT nextval('cntctdata_cntctdata_id_seq'::regclass); -- -- Name: cntcteml_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY cntcteml ALTER COLUMN cntcteml_id SET DEFAULT nextval('cntcteml_cntcteml_id_seq'::regclass); -- -- Name: taxhist_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY cobilltax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); -- -- Name: taxhist_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY cobmisctax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); -- -- Name: taxhist_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohisttax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); -- -- Name: company_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY company ALTER COLUMN company_id SET DEFAULT nextval('company_company_id_seq'::regclass); -- -- Name: contrct_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY contrct ALTER COLUMN contrct_id SET DEFAULT nextval('contrct_contrct_id_seq'::regclass); -- -- Name: country_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY country ALTER COLUMN country_id SET DEFAULT nextval('country_country_id_seq'::regclass); -- -- Name: crmacct_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY crmacct ALTER COLUMN crmacct_id SET DEFAULT nextval('crmacct_crmacct_id_seq'::regclass); -- -- Name: curr_rate_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY curr_rate ALTER COLUMN curr_rate_id SET DEFAULT nextval('curr_rate_curr_rate_id_seq'::regclass); -- -- Name: curr_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY curr_symbol ALTER COLUMN curr_id SET DEFAULT nextval('curr_symbol_curr_id_seq'::regclass); -- -- Name: dept_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY dept ALTER COLUMN dept_id SET DEFAULT nextval('dept_dept_id_seq'::regclass); -- -- Name: docass_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY docass ALTER COLUMN docass_id SET DEFAULT nextval('docass_docass_id_seq'::regclass); -- -- Name: emp_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY emp ALTER COLUMN emp_id SET DEFAULT nextval('emp_emp_id_seq'::regclass); -- -- Name: empgrp_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY empgrp ALTER COLUMN empgrp_id SET DEFAULT nextval('empgrp_empgrp_id_seq'::regclass); -- -- Name: empgrpitem_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY empgrpitem ALTER COLUMN empgrpitem_id SET DEFAULT nextval('empgrpitem_empgrpitem_id_seq'::regclass); -- -- Name: expcat_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY expcat ALTER COLUMN expcat_id SET DEFAULT nextval('expcat_expcat_id_seq'::regclass); -- -- Name: file_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY file ALTER COLUMN file_id SET DEFAULT nextval('file_file_id_seq'::regclass); -- -- Name: filter_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY filter ALTER COLUMN filter_id SET DEFAULT nextval('filter_filter_id_seq'::regclass); -- -- Name: fincharg_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY fincharg ALTER COLUMN fincharg_id SET DEFAULT nextval('fincharg_fincharg_id_seq'::regclass); -- -- Name: flcol_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY flcol ALTER COLUMN flcol_id SET DEFAULT nextval('flcol_flcol_id_seq'::regclass); -- -- Name: flgrp_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY flgrp ALTER COLUMN flgrp_id SET DEFAULT nextval('flgrp_flgrp_id_seq'::regclass); -- -- Name: flhead_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY flhead ALTER COLUMN flhead_id SET DEFAULT nextval('flhead_flhead_id_seq'::regclass); -- -- Name: flitem_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY flitem ALTER COLUMN flitem_id SET DEFAULT nextval('flitem_flitem_id_seq'::regclass); -- -- Name: flnotes_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY flnotes ALTER COLUMN flnotes_id SET DEFAULT nextval('flnotes_flnotes_id_seq'::regclass); -- -- Name: flrpt_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY flrpt ALTER COLUMN flrpt_id SET DEFAULT nextval('flrpt_flrpt_id_seq'::regclass); -- -- Name: flspec_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY flspec ALTER COLUMN flspec_id SET DEFAULT nextval('flspec_flspec_id_seq'::regclass); -- -- Name: freightclass_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY freightclass ALTER COLUMN freightclass_id SET DEFAULT nextval('freightclass_freightclass_id_seq'::regclass); -- -- Name: grp_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY grp ALTER COLUMN grp_id SET DEFAULT nextval('grp_grp_id_seq'::regclass); -- -- Name: grppriv_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY grppriv ALTER COLUMN grppriv_id SET DEFAULT nextval('grppriv_grppriv_id_seq'::regclass); -- -- Name: hnfc_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY hnfc ALTER COLUMN hnfc_id SET DEFAULT nextval('hnfc_hnfc_id_seq'::regclass); -- -- Name: incdt_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY incdt ALTER COLUMN incdt_id SET DEFAULT nextval('incdt_incdt_id_seq'::regclass); -- -- Name: incdtcat_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY incdtcat ALTER COLUMN incdtcat_id SET DEFAULT nextval('incdtcat_incdtcat_id_seq'::regclass); -- -- Name: incdthist_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY incdthist ALTER COLUMN incdthist_id SET DEFAULT nextval('incdthist_incdthist_id_seq'::regclass); -- -- Name: incdtpriority_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY incdtpriority ALTER COLUMN incdtpriority_id SET DEFAULT nextval('incdtpriority_incdtpriority_id_seq'::regclass); -- -- Name: incdtresolution_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY incdtresolution ALTER COLUMN incdtresolution_id SET DEFAULT nextval('incdtresolution_incdtresolution_id_seq'::regclass); -- -- Name: incdtseverity_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY incdtseverity ALTER COLUMN incdtseverity_id SET DEFAULT nextval('incdtseverity_incdtseverity_id_seq'::regclass); -- -- Name: invbal_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY invbal ALTER COLUMN invbal_id SET DEFAULT nextval('invbal_invbal_id_seq'::regclass); -- -- Name: invchead_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY invchead ALTER COLUMN invchead_id SET DEFAULT nextval('invchead_invchead_id_seq'::regclass); -- -- Name: taxhist_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY invcheadtax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); -- -- Name: invcitem_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY invcitem ALTER COLUMN invcitem_id SET DEFAULT nextval('invcitem_invcitem_id_seq'::regclass); -- -- Name: taxhist_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY invcitemtax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); -- -- Name: invhistexpcat_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY invhistexpcat ALTER COLUMN invhistexpcat_id SET DEFAULT nextval('invhistexpcat_invhistexpcat_id_seq'::regclass); -- -- Name: ipsass_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY ipsass ALTER COLUMN ipsass_id SET DEFAULT nextval('ipsass_ipsass_id_seq'::regclass); -- -- Name: ipsfreight_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY ipsfreight ALTER COLUMN ipsfreight_id SET DEFAULT nextval('ipsfreight_ipsfreight_id_seq'::regclass); -- -- Name: ipsitemchar_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY ipsitemchar ALTER COLUMN ipsitemchar_id SET DEFAULT nextval('ipsitemchar_ipsitemchar_id_seq'::regclass); -- -- Name: ipsprodcat_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY ipsprodcat_bak ALTER COLUMN ipsprodcat_id SET DEFAULT nextval('ipsprodcat_ipsprodcat_id_seq'::regclass); -- -- Name: itemlocpost_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemlocpost ALTER COLUMN itemlocpost_id SET DEFAULT nextval('itemlocpost_itemlocpost_id_seq'::regclass); -- -- Name: itemtax_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemtax ALTER COLUMN itemtax_id SET DEFAULT nextval('itemtax_itemtax_id_seq'::regclass); -- -- Name: itemtrans_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemtrans ALTER COLUMN itemtrans_id SET DEFAULT nextval('itemtrans_itemtrans_id_seq'::regclass); -- -- Name: itemuom_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemuom ALTER COLUMN itemuom_id SET DEFAULT nextval('itemuom_itemuom_id_seq'::regclass); -- -- Name: itemuomconv_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemuomconv ALTER COLUMN itemuomconv_id SET DEFAULT nextval('itemuomconv_itemuomconv_id_seq'::regclass); -- -- Name: labeldef_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY labeldef ALTER COLUMN labeldef_id SET DEFAULT nextval('labeldef_labeldef_id_seq'::regclass); -- -- Name: lang_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY lang ALTER COLUMN lang_id SET DEFAULT nextval('lang_lang_id_seq'::regclass); -- -- Name: metasql_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY metasql ALTER COLUMN metasql_id SET DEFAULT nextval('metasql_metasql_id_seq'::regclass); -- -- Name: metricenc_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY metricenc ALTER COLUMN metricenc_id SET DEFAULT nextval('metricenc_metricenc_id_seq'::regclass); -- -- Name: ophead_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY ophead ALTER COLUMN ophead_id SET DEFAULT nextval('ophead_ophead_id_seq'::regclass); -- -- Name: opsource_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY opsource ALTER COLUMN opsource_id SET DEFAULT nextval('opsource_opsource_id_seq'::regclass); -- -- Name: opstage_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY opstage ALTER COLUMN opstage_id SET DEFAULT nextval('opstage_opstage_id_seq'::regclass); -- -- Name: optype_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY optype ALTER COLUMN optype_id SET DEFAULT nextval('optype_optype_id_seq'::regclass); -- -- Name: pack_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY pack ALTER COLUMN pack_id SET DEFAULT nextval('pack_pack_id_seq'::regclass); -- -- Name: payco_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY payco ALTER COLUMN payco_id SET DEFAULT nextval('payco_payco_id_seq'::regclass); -- -- Name: period_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY period ALTER COLUMN period_id SET DEFAULT nextval('period_period_id_seq'::regclass); -- -- Name: pkgdep_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY pkgdep ALTER COLUMN pkgdep_id SET DEFAULT nextval('pkgdep_pkgdep_id_seq'::regclass); -- -- Name: pkghead_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY pkghead ALTER COLUMN pkghead_id SET DEFAULT nextval('pkghead_pkghead_id_seq'::regclass); -- -- Name: pkgitem_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY pkgitem ALTER COLUMN pkgitem_id SET DEFAULT nextval('pkgitem_pkgitem_id_seq'::regclass); -- -- Name: prftcntr_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY prftcntr ALTER COLUMN prftcntr_id SET DEFAULT nextval('prftcntr_prftcntr_id_seq'::regclass); -- -- Name: prj_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY prj ALTER COLUMN prj_id SET DEFAULT nextval('prj_prj_id_seq'::regclass); -- -- Name: prjtask_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY prjtask ALTER COLUMN prjtask_id SET DEFAULT nextval('prjtask_prjtask_id_seq'::regclass); -- -- Name: prjtaskuser_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY prjtaskuser ALTER COLUMN prjtaskuser_id SET DEFAULT nextval('prjtaskuser_prjtaskuser_id_seq'::regclass); -- -- Name: prjtype_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY prjtype ALTER COLUMN prjtype_id SET DEFAULT nextval('prjtype_prjtype_id_seq'::regclass); -- -- Name: qryhead_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY qryhead ALTER COLUMN qryhead_id SET DEFAULT nextval('qryhead_qryhead_id_seq'::regclass); -- -- Name: qryitem_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY qryitem ALTER COLUMN qryitem_id SET DEFAULT nextval('qryitem_qryitem_id_seq'::regclass); -- -- Name: recur_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY recur ALTER COLUMN recur_id SET DEFAULT nextval('recur_recur_id_seq'::regclass); -- -- Name: recurtype_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY recurtype ALTER COLUMN recurtype_id SET DEFAULT nextval('recurtype_recurtype_id_seq'::regclass); -- -- Name: recv_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY recv ALTER COLUMN recv_id SET DEFAULT nextval('recv_recv_id_seq'::regclass); -- -- Name: rsncode_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY rsncode ALTER COLUMN rsncode_id SET DEFAULT nextval('rsncode_rsncode_id_seq'::regclass); -- -- Name: salescat_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY salescat ALTER COLUMN salescat_id SET DEFAULT nextval('salescat_salescat_id_seq'::regclass); -- -- Name: saletype_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY saletype ALTER COLUMN saletype_id SET DEFAULT nextval('saletype_saletype_id_seq'::regclass); -- -- Name: schemaord_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY schemaord ALTER COLUMN schemaord_id SET DEFAULT nextval('schemaord_schemaord_id_seq'::regclass); -- -- Name: script_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY script ALTER COLUMN script_id SET DEFAULT nextval('script_script_id_seq'::regclass); -- -- Name: shift_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY shift ALTER COLUMN shift_id SET DEFAULT nextval('shift_shift_id_seq'::regclass); -- -- Name: shipchrg_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY shipchrg ALTER COLUMN shipchrg_id SET DEFAULT nextval('shipchrg_shipchrg_id_seq'::regclass); -- -- Name: shiphead_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY shiphead ALTER COLUMN shiphead_id SET DEFAULT nextval('shiphead_shiphead_id_seq'::regclass); -- -- Name: shipitem_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY shipitem ALTER COLUMN shipitem_id SET DEFAULT nextval('shipitem_shipitem_id_seq'::regclass); -- -- Name: sitetype_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY sitetype ALTER COLUMN sitetype_id SET DEFAULT nextval('sitetype_sitetype_id_seq'::regclass); -- -- Name: source_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY source ALTER COLUMN source_id SET DEFAULT nextval('source_source_id_seq'::regclass); -- -- Name: state_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY state ALTER COLUMN state_id SET DEFAULT nextval('state_state_id_seq'::regclass); -- -- Name: status_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY status ALTER COLUMN status_id SET DEFAULT nextval('status_status_id_seq'::regclass); -- -- Name: stdjrnl_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY stdjrnl ALTER COLUMN stdjrnl_id SET DEFAULT nextval('stdjrnl_stdjrnl_id_seq'::regclass); -- -- Name: stdjrnlgrp_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY stdjrnlgrp ALTER COLUMN stdjrnlgrp_id SET DEFAULT nextval('stdjrnlgrp_stdjrnlgrp_id_seq'::regclass); -- -- Name: stdjrnlgrpitem_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY stdjrnlgrpitem ALTER COLUMN stdjrnlgrpitem_id SET DEFAULT nextval('stdjrnlgrpitem_stdjrnlgrpitem_id_seq'::regclass); -- -- Name: stdjrnlitem_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY stdjrnlitem ALTER COLUMN stdjrnlitem_id SET DEFAULT nextval('stdjrnlitem_stdjrnlitem_id_seq'::regclass); -- -- Name: subaccnt_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY subaccnt ALTER COLUMN subaccnt_id SET DEFAULT nextval('subaccnt_subaccnt_id_seq'::regclass); -- -- Name: subaccnttype_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY subaccnttype ALTER COLUMN subaccnttype_id SET DEFAULT nextval('subaccnttype_subaccnttype_id_seq'::regclass); -- -- Name: taxass_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxass ALTER COLUMN taxass_id SET DEFAULT nextval('taxass_taxass_id_seq'::regclass); -- -- Name: taxauth_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxauth ALTER COLUMN taxauth_id SET DEFAULT nextval('taxauth_taxauth_id_seq'::regclass); -- -- Name: taxclass_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxclass ALTER COLUMN taxclass_id SET DEFAULT nextval('taxclass_taxclass_id_seq'::regclass); -- -- Name: taxhist_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxhist ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); -- -- Name: taxpay_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxpay ALTER COLUMN taxpay_id SET DEFAULT nextval('taxpay_taxpay_id_seq'::regclass); -- -- Name: taxrate_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxrate ALTER COLUMN taxrate_id SET DEFAULT nextval('taxrate_taxrate_id_seq'::regclass); -- -- Name: taxreg_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxreg ALTER COLUMN taxreg_id SET DEFAULT nextval('taxreg_taxreg_id_seq'::regclass); -- -- Name: taxtype_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxtype ALTER COLUMN taxtype_id SET DEFAULT nextval('taxtype_taxtype_id_seq'::regclass); -- -- Name: taxzone_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxzone ALTER COLUMN taxzone_id SET DEFAULT nextval('taxzone_taxzone_id_seq'::regclass); -- -- Name: todoitem_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY todoitem ALTER COLUMN todoitem_id SET DEFAULT nextval('todoitem_todoitem_id_seq'::regclass); -- -- Name: trialbal_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY trialbal ALTER COLUMN trialbal_id SET DEFAULT nextval('trialbal_trialbal_id_seq'::regclass); -- -- Name: uiform_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY uiform ALTER COLUMN uiform_id SET DEFAULT nextval('uiform_uiform_id_seq'::regclass); -- -- Name: uom_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY uom ALTER COLUMN uom_id SET DEFAULT nextval('uom_uom_id_seq'::regclass); -- -- Name: uomconv_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY uomconv ALTER COLUMN uomconv_id SET DEFAULT nextval('uomconv_uomconv_id_seq'::regclass); -- -- Name: uomtype_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY uomtype ALTER COLUMN uomtype_id SET DEFAULT nextval('uomtype_uomtype_id_seq'::regclass); -- -- Name: url_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY urlinfo ALTER COLUMN url_id SET DEFAULT nextval('urlinfo_url_id_seq'::regclass); -- -- Name: usrgrp_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY usrgrp ALTER COLUMN usrgrp_id SET DEFAULT nextval('usrgrp_usrgrp_id_seq'::regclass); -- -- Name: vendtype_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY vendtype ALTER COLUMN vendtype_id SET DEFAULT nextval('vendtype_vendtype_id_seq'::regclass); -- -- Name: taxhist_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY voheadtax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); -- -- Name: taxhist_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY voitemtax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); -- -- Name: whsezone_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY whsezone ALTER COLUMN whsezone_id SET DEFAULT nextval('whsezone_whsezone_id_seq'::regclass); -- -- Name: womatlpost_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY womatlpost ALTER COLUMN womatlpost_id SET DEFAULT nextval('womatlpost_womatlpost_id_seq'::regclass); -- -- Name: xsltmap_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY xsltmap ALTER COLUMN xsltmap_id SET DEFAULT nextval('xsltmap_xsltmap_id_seq'::regclass); -- -- Name: yearperiod_id; Type: DEFAULT; Schema: public; Owner: admin -- ALTER TABLE ONLY yearperiod ALTER COLUMN yearperiod_id SET DEFAULT nextval('yearperiod_yearperiod_id_seq'::regclass); SET search_path = te, pg_catalog; -- -- Name: metasql_grade; Type: DEFAULT; Schema: te; Owner: admin -- ALTER TABLE ONLY pkgmetasql ALTER COLUMN metasql_grade SET DEFAULT 0; -- -- Name: script_enabled; Type: DEFAULT; Schema: te; Owner: admin -- ALTER TABLE ONLY pkgscript ALTER COLUMN script_enabled SET DEFAULT false; -- -- Name: uiform_enabled; Type: DEFAULT; Schema: te; Owner: admin -- ALTER TABLE ONLY pkguiform ALTER COLUMN uiform_enabled SET DEFAULT false; -- -- Name: tecustrate_id; Type: DEFAULT; Schema: te; Owner: admin -- ALTER TABLE ONLY tecustrate ALTER COLUMN tecustrate_id SET DEFAULT nextval('tecustrate_tecustrate_id_seq'::regclass); -- -- Name: teemp_id; Type: DEFAULT; Schema: te; Owner: admin -- ALTER TABLE ONLY teemp ALTER COLUMN teemp_id SET DEFAULT nextval('teemp_teemp_id_seq'::regclass); -- -- Name: tehead_id; Type: DEFAULT; Schema: te; Owner: admin -- ALTER TABLE ONLY tehead ALTER COLUMN tehead_id SET DEFAULT nextval('tehead_tehead_id_seq'::regclass); -- -- Name: teitem_id; Type: DEFAULT; Schema: te; Owner: admin -- ALTER TABLE ONLY teitem ALTER COLUMN teitem_id SET DEFAULT nextval('teitem_teitem_id_seq'::regclass); -- -- Name: teprj_id; Type: DEFAULT; Schema: te; Owner: admin -- ALTER TABLE ONLY teprj ALTER COLUMN teprj_id SET DEFAULT nextval('teprj_teprj_id_seq'::regclass); -- -- Name: teprjtask_id; Type: DEFAULT; Schema: te; Owner: admin -- ALTER TABLE ONLY teprjtask ALTER COLUMN teprjtask_id SET DEFAULT nextval('teprjtask_teprjtask_id_seq'::regclass); SET search_path = xt, pg_catalog; -- -- Name: js_id; Type: DEFAULT; Schema: xt; Owner: admin -- ALTER TABLE ONLY js ALTER COLUMN js_id SET DEFAULT nextval('js_js_id_seq'::regclass); SET search_path = xtdesktop, pg_catalog; -- -- Name: metasql_grade; Type: DEFAULT; Schema: xtdesktop; Owner: admin -- ALTER TABLE ONLY pkgmetasql ALTER COLUMN metasql_grade SET DEFAULT 0; -- -- Name: script_enabled; Type: DEFAULT; Schema: xtdesktop; Owner: admin -- ALTER TABLE ONLY pkgscript ALTER COLUMN script_enabled SET DEFAULT false; -- -- Name: uiform_enabled; Type: DEFAULT; Schema: xtdesktop; Owner: admin -- ALTER TABLE ONLY pkguiform ALTER COLUMN uiform_enabled SET DEFAULT false; SET search_path = fixcountry, pg_catalog; -- -- Data for Name: pkgcmd; Type: TABLE DATA; Schema: fixcountry; Owner: admin -- COPY pkgcmd (cmd_id, cmd_module, cmd_title, cmd_descrip, cmd_privname, cmd_executable, cmd_name) FROM stdin; \. -- -- Data for Name: pkgcmdarg; Type: TABLE DATA; Schema: fixcountry; Owner: admin -- COPY pkgcmdarg (cmdarg_id, cmdarg_cmd_id, cmdarg_order, cmdarg_arg) FROM stdin; \. -- -- Data for Name: pkgimage; Type: TABLE DATA; Schema: fixcountry; Owner: admin -- COPY pkgimage (image_id, image_name, image_descrip, image_data) FROM stdin; \. -- -- Data for Name: pkgmetasql; Type: TABLE DATA; Schema: fixcountry; Owner: admin -- COPY pkgmetasql (metasql_id, metasql_group, metasql_name, metasql_notes, metasql_query, metasql_lastuser, metasql_lastupdate, metasql_grade) FROM stdin; 449 fixcountry strictcountrycheck select details about countries used throughout the database that do not match country.country_name a copy of crm_strictcountrycheck to avoid problems later if someone disables or removes the fixCountry package -- Group: fixcountry\n-- Name: strictcountrycheck\n-- Notes: select details about countries used throughout the database\n-- that do not match country.country_name\n-- a copy of crm_strictcountrycheck to avoid problems later if\n-- someone disables or removes the fixCountry package\n\nSELECT SUM(counter) AS counter FROM (\n\n SELECT COUNT(*) AS counter\n addr_id, 'Address' AS type, addr_number AS number, addr_country AS country, '' AS detail\n \n FROM addr\n WHERE addr_country != ''\n AND addr_country NOT IN (SELECT country_name\n FROM country\n WHERE country_name IS NOT NULL)\n UNION ALL\n SELECT COUNT(*)\n cmhead_id, 'Credit Memo', cmhead_number, cmhead_billtocountry, 'Bill-To'\n \n FROM cmhead\n WHERE cmhead_billtocountry != ''\n AND cmhead_billtocountry NOT IN (SELECT country_name\n FROM country\n WHERE country_name IS NOT NULL)\n AND (NOT cmhead_posted) \n UNION ALL\n SELECT COUNT(*)\n cmhead_id, 'Credit Memo', cmhead_number, cmhead_billtocountry, 'Ship-To'\n \n FROM cmhead\n WHERE cmhead_shipto_country != ''\n AND cmhead_shipto_country NOT IN (SELECT country_name\n FROM country\n WHERE country_name IS NOT NULL)\n AND (NOT cmhead_posted) \n UNION ALL\n SELECT COUNT(*)\n invchead_id, 'Invoice', invchead_invcnumber, invchead_billto_country, 'Bill-To'\n \n FROM invchead\n WHERE invchead_billto_country != ''\n AND invchead_billto_country NOT IN (SELECT country_name\n FROM country\n WHERE country_name IS NOT NULL)\n AND (NOT invchead_posted) \n UNION ALL\n SELECT COUNT(*)\n invchead_id, 'Invoice', invchead_invcnumber, invchead_shipto_country, 'Ship-To'\n \n FROM invchead\n WHERE invchead_shipto_country != ''\n AND invchead_shipto_country NOT IN (SELECT country_name\n FROM country\n WHERE country_name IS NOT NULL)\n AND (NOT invchead_posted) \n UNION ALL\n SELECT COUNT(*)\n quhead_id, 'Quote', CAST(quhead_number AS TEXT), quhead_billtocountry, 'Bill-To'\n \n FROM quhead\n WHERE quhead_billtocountry != ''\n AND quhead_billtocountry NOT IN (SELECT country_name\n FROM country\n WHERE country_name IS NOT NULL)\n AND (quhead_expire>=CURRENT_DATE) \n UNION ALL\n SELECT COUNT(*)\n quhead_id, 'Quote', CAST(quhead_number AS TEXT), quhead_shiptocountry, 'Ship-To'\n \n FROM quhead\n WHERE quhead_shiptocountry != ''\n AND quhead_shiptocountry NOT IN (SELECT country_name\n FROM country\n WHERE country_name IS NOT NULL)\n AND (quhead_expire>=CURRENT_DATE) \n UNION ALL\n SELECT COUNT(*)\n cohead_id, 'Sales Order', cohead_number, cohead_billtocountry, 'Bill-To'\n \n FROM cohead\n WHERE cohead_billtocountry != ''\n AND cohead_billtocountry NOT IN (SELECT country_name\n FROM country\n WHERE country_name IS NOT NULL)\n \n AND cohead_id IN (SELECT coitem_cohead_id\n FROM coitem\n WHERE COALESCE(coitem_status, 'O')='O')\n \n UNION ALL\n SELECT COUNT(*)\n cohead_id, 'Sales Order', cohead_number, cohead_shiptocountry, 'Ship-To'\n \n FROM cohead\n WHERE cohead_shiptocountry != ''\n AND cohead_shiptocountry NOT IN (SELECT country_name\n FROM country\n WHERE country_name IS NOT NULL)\n \n AND cohead_id IN (SELECT coitem_cohead_id\n FROM coitem\n WHERE COALESCE(coitem_status, 'O')='O')\n \n\n\n) AS dummy;\n\n \N \N 0 \. -- -- Data for Name: pkgpriv; Type: TABLE DATA; Schema: fixcountry; Owner: admin -- COPY pkgpriv (priv_id, priv_module, priv_name, priv_descrip, priv_seq) FROM stdin; \. -- -- Data for Name: pkgreport; Type: TABLE DATA; Schema: fixcountry; Owner: admin -- COPY pkgreport (report_id, report_name, report_sys, report_source, report_descrip, report_grade, report_loaddate) FROM stdin; \. -- -- Data for Name: pkgscript; Type: TABLE DATA; Schema: fixcountry; Owner: admin -- COPY pkgscript (script_id, script_name, script_order, script_enabled, script_source, script_notes) FROM stdin; 124 initMenu 0 t function sFixCountries()\n{\n try {\n var newdlg = toolbox.openWindow("fixCountries", 0, Qt.Window, Qt.NonModal);\n } catch(e) { print("sFixCountries exception: " + e); }\n}\n\nvar _crmutilsmenu = mainwindow.findChild("menu.crm.utilities");\nvar fixCountriesAction = _crmutilsmenu.addAction(\n qsTr("Fix Countries before setting Strict Countries option"));\nfixCountriesAction.enabled = privileges.value("MaintainAddresses") &&\n privileges.value("MaintainCreditMemos") &&\n privileges.value("MaintainMiscInvoices")&&\n privileges.value("MaintainSalesOrders") &&\n privileges.value("MaintainQuotes");\n\nfixCountriesAction.triggered.connect(sFixCountries);\n 125 fixCountries 0 t var _addCountry = mywindow.findChild("_addCountry");\nvar _edit = mywindow.findChild("_edit");\nvar _fixAbbr = mywindow.findChild("_fixAbbr");\nvar _fixBulk = mywindow.findChild("_fixBulk");\nvar _fixCase = mywindow.findChild("_fixCase");\nvar _list = mywindow.findChild("_list");\nvar _query = mywindow.findChild("_query");\nvar _showAll = mywindow.findChild("_showAll");\n\n_list.addColumn("Record Type", -1, Qt.AlignLeft, true, "type");\n_list.addColumn("Number", -1, Qt.AlignLeft, true, "number");\n_list.addColumn("Country", -1, Qt.AlignLeft, true, "country");\n_list.addColumn("Details", -1, Qt.AlignLeft, true, "detail");\n\nfunction sAddCountry()\n{\n try {\n var params = new Object;;\n params.mode = "new";\n\n var newdlg = toolbox.openWindow("country", mywindow, Qt.Dialog, Qt.WindowModal);\n toolbox.lastWindow().set(params);\n newdlg.exec();\n } catch (e) { print("sAddCountry exception: " + e); }\n}\n\nfunction openEditorWindow(pwindow, pidname, pparent)\n{\n try {\n var params = new Object;\n params[pidname] = _list.id();\n if (pidname == 'quhead_id')\n params.mode = "editQuote";\n else\n params.mode = "edit";\n\n var newdlg = toolbox.openWindow(pwindow, pparent, Qt.Dialog, Qt.WindowModal);\n toolbox.lastWindow().set(params);\n newdlg.exec();\n } catch(e) { print("openEditorWindow exception (" + e.lineNumber + "): " + e); }\n}\n\nfunction sEdit()\n{\n try {\n var currentItem = _list.currentItem();\n\n switch (currentItem.text(0))\n {\n case 'Address':\n openEditorWindow("address", "addr_id", mywindow);\n break;\n\n case 'Credit Memo':\n openEditorWindow("creditMemo", "cmhead_id", 0);\n break;\n\n case 'Invoice':\n openEditorWindow("invoice", "invchead_id", mywindow);\n break;\n\n case 'Quote':\n openEditorWindow("salesOrder", "quhead_id", 0);\n break;\n\n case 'Sales Order':\n openEditorWindow("salesOrder", "sohead_id", 0);\n break;\n }\n sFillList();\n } catch (e) { print("sEdit() exception: " + e); }\n}\n\nfunction sFixBulk()\n{\n print("sFixBulk() entered");\n try {\n var params = new Object;\n if (_showAll.checked)\n params.showAll = true;\n\n var newdlg = toolbox.openWindow("bulkFixCountry", mywindow,\n Qt.WindowModal, Qt.Dialog);\n toolbox.lastWindow().set(params);\n\n sFillList();\n } catch (e) { print("sFixBulk() exception: " + e); }\n}\n\nfunction sFixCase()\n{\n try {\n if (QMessageBox.question(mywindow, qsTr("Are you sure?"),\n qsTr("

Are you sure that you want to change all "\n + "countries that appear to be correct except "\n + "for upper- and lower-case differences in a "\n + "batch?

(This change will obey the status "\n + "of the 'Show closed records' check box."),\n QMessageBox.Yes, QMessageBox.No) == QMessageBox.No)\n return;\n\n var params = new Object;\n if (_showAll.checked)\n params.showAll = true;\n\n var qry = toolbox.executeQuery(\n "UPDATE addr SET addr_country = country_name"\n + " FROM country "\n + " WHERE addr_country != ''"\n + " AND UPPER(addr_country) = UPPER(country_name)"\n + " AND addr_country != country_name;", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Address: " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n "UPDATE cmhead SET cmhead_billtocountry = country_name"\n + " FROM country "\n + " WHERE cmhead_billtocountry != ''"\n + " AND UPPER(cmhead_billtocountry) = UPPER(country_name)"\n + " AND cmhead_billtocountry != country_name"\n + ' '\n + " AND NOT cmhead_posted"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Credit Memo (Bill-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n "UPDATE cmhead SET cmhead_shipto_country = country_name"\n + " FROM country "\n + " WHERE cmhead_shipto_country != ''"\n + " AND UPPER(cmhead_shipto_country) = UPPER(country_name)"\n + " AND cmhead_shipto_country != country_name"\n + ' '\n + " AND NOT cmhead_posted"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Credit Memo (Ship-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n "UPDATE invchead SET invchead_billto_country = country_name"\n + " FROM country "\n + " WHERE invchead_billto_country != ''"\n + " AND UPPER(invchead_billto_country) = UPPER(country_name)"\n + " AND invchead_billto_country != country_name"\n + ' '\n + " AND NOT invchead_posted"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Invoice (Bill-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n "UPDATE invchead SET invchead_shipto_country = country_name"\n + " FROM country "\n + " WHERE invchead_shipto_country != ''"\n + " AND UPPER(invchead_shipto_country) = UPPER(country_name)"\n + " AND invchead_shipto_country != country_name"\n + ' '\n + " AND NOT invchead_posted"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Invoice (Ship-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n "UPDATE quhead SET quhead_billtocountry = country_name"\n + " FROM country"\n + " WHERE quhead_billtocountry != ''"\n + " AND UPPER(quhead_billtocountry) = UPPER(country_name)"\n + " AND quhead_billtocountry != country_name"\n + ' '\n + " AND quhead_expire >= CURRENT_DATE"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Quote (Bill-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n "UPDATE quhead SET quhead_shiptocountry = country_name"\n + " FROM country"\n + " WHERE quhead_shiptocountry != ''"\n + " AND UPPER(quhead_shiptocountry) = UPPER(country_name)"\n + " AND quhead_shiptocountry != country_name"\n + ' '\n + " AND quhead_expire >= CURRENT_DATE"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Quote (Ship-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n "UPDATE cohead SET cohead_billtocountry = country_name"\n + ' FROM country , coitem'\n + " WHERE cohead_billtocountry != ''"\n + " AND UPPER(cohead_billtocountry) = UPPER(country_name)"\n + " AND cohead_billtocountry != country_name"\n + ' '\n + " AND cohead_id=coitem_cohead_id AND COALESCE(coitem_status, 'O')='O'"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Sales Order (Bill-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n "UPDATE cohead SET cohead_shiptocountry = country_name"\n + ' FROM country , coitem'\n + " WHERE cohead_shiptocountry != ''"\n + " AND UPPER(cohead_shiptocountry) = UPPER(country_name)"\n + " AND cohead_shiptocountry != country_name"\n + ' '\n + " AND cohead_id=coitem_cohead_id AND COALESCE(coitem_status, 'O')='O'"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Sales Order (Ship-To): " + qry.lastError().text);\n\n } catch (e) { QMessageBox.critical(mywindow, "sFixCase() exception", e); }\n\n sFillList();\n}\n\nfunction sFixAbbr()\n{\n try {\n if (QMessageBox.question(mywindow, qsTr("Are you sure?"),\n qsTr("

Are you sure that you want to replace all "\n + "country abbreviations to the corresponding "\n + "full country names?

(This change will obey "\n + "the status of the 'Show closed records' "\n + "check box."),\n QMessageBox.Yes, QMessageBox.No) == QMessageBox.No)\n return;\n\n var params = new Object;\n if (_showAll.checked)\n params.showAll = true;\n\n var qry = toolbox.executeQuery(\n "UPDATE addr SET addr_country = country_name"\n + " FROM country "\n + " WHERE addr_country != ''"\n + " AND UPPER(addr_country) = UPPER(country_abbr);", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Address: " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n "UPDATE cmhead SET cmhead_billtocountry = country_name"\n + " FROM country "\n + " WHERE cmhead_billtocountry != ''"\n + " AND UPPER(cmhead_billtocountry) = UPPER(country_abbr)"\n + ' '\n + " AND NOT cmhead_posted"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Credit Memo (Bill-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n "UPDATE cmhead SET cmhead_shipto_country = country_name"\n + " FROM country "\n + " WHERE cmhead_shipto_country != ''"\n + " AND UPPER(cmhead_shipto_country) = UPPER(country_abbr)"\n + ' '\n + " AND NOT cmhead_posted"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Credit Memo (Ship-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n "UPDATE invchead SET invchead_billto_country = country_name"\n + " FROM country "\n + " WHERE invchead_billto_country != ''"\n + " AND UPPER(invchead_billto_country) = UPPER(country_abbr)"\n + ' '\n + " AND NOT invchead_posted"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Invoice (Bill-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n "UPDATE invchead SET invchead_shipto_country = country_name"\n + " FROM country "\n + " WHERE invchead_shipto_country != ''"\n + " AND UPPER(invchead_shipto_country) = UPPER(country_abbr)"\n + ' '\n + " AND NOT invchead_posted"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Invoice (Ship-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n "UPDATE quhead SET quhead_billtocountry = country_name"\n + " FROM country"\n + " WHERE quhead_billtocountry != ''"\n + " AND UPPER(quhead_billtocountry) = UPPER(country_abbr)"\n + ' '\n + " AND quhead_expire >= CURRENT_DATE"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Quote (Bill-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n "UPDATE quhead SET quhead_shiptocountry = country_name"\n + " FROM country"\n + " WHERE quhead_shiptocountry != ''"\n + " AND UPPER(quhead_shiptocountry) = UPPER(country_abbr)"\n + ' '\n + " AND quhead_expire >= CURRENT_DATE"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Quote (Ship-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n "UPDATE cohead SET cohead_billtocountry = country_name"\n + ' FROM country , coitem'\n + " WHERE cohead_billtocountry != ''"\n + " AND UPPER(cohead_billtocountry) = UPPER(country_abbr)"\n + ' '\n + " AND cohead_id=coitem_cohead_id AND COALESCE(coitem_status, 'O')='O'"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Sales Order (Bill-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n "UPDATE cohead SET cohead_shiptocountry = country_name"\n + ' FROM country , coitem'\n + " WHERE cohead_shiptocountry != ''"\n + " AND UPPER(cohead_shiptocountry) = UPPER(country_abbr)"\n + ' '\n + " AND cohead_id=coitem_cohead_id AND COALESCE(coitem_status, 'O')='O'"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Sales Order (Ship-To): " + qry.lastError().text);\n\n } catch (e)\n {\n QMessageBox.critical(mywindow, "sFixAbbr() exception", e);\n }\n sFillList();\n}\n\nfunction sFillList()\n{\n try {\n var params = new Object;\n if (_showAll.checked)\n params.showAll = true;\n\n var qry = toolbox.executeDbQuery('fixcountry', 'strictcountrycheck', params);\n _list.populate(qry);\n if (qry.lastError().type != 0)\n {\n QMessageBox.critical(mywindow, qsTr("Database Error"),\n qry.lastError().text);\n return;\n }\n } catch (e) { print("sFillList exception: " + e); }\n}\n\n_addCountry.clicked.connect(sAddCountry);\n_edit.clicked.connect(sEdit);\n_fixAbbr.clicked.connect(sFixAbbr);\n_fixBulk.clicked.connect(sFixBulk);\n_fixCase.clicked.connect(sFixCase);\n_query.clicked.connect(sFillList);\n_showAll.toggled.connect(sFillList);\n\nsFillList();\n\nif (QMessageBox.question(mywindow, qsTr("Backed Up?"),\n qsTr("

Have you backed up your database? "\n + "You really should back up your database "\n + "before running this utility."),\n QMessageBox.Yes, QMessageBox.No) == QMessageBox.No)\n mywindow.close()\n\n 126 bulkFixCountry 0 t var _buttons = mywindow.findChild("_buttons");\nvar _oldCountry = mywindow.findChild("_oldCountry");\nvar _newCountry = mywindow.findChild("_newCountry");\nvar _params;\n\nfunction set(params)\n{\n _params = params;\n var qry = toolbox.executeQuery(\n "SELECT MIN(id), country, country AS code "\n + " FROM ("\n + " SELECT addr_id AS id, addr_country AS country"\n + " FROM addr"\n + " WHERE addr_country != ''"\n + " AND addr_country NOT IN (SELECT country_name"\n + " FROM country"\n + " WHERE country_name IS NOT NULL)"\n + " UNION ALL"\n + " SELECT cmhead_id, cmhead_billtocountry"\n + " FROM cmhead"\n + " WHERE cmhead_billtocountry != ''"\n + " AND cmhead_billtocountry NOT IN (SELECT country_name"\n + " FROM country"\n + " WHERE country_name IS NOT NULL)"\n + ' AND (NOT cmhead_posted) '\n + " UNION ALL"\n + " SELECT cmhead_id, cmhead_shipto_country"\n + " FROM cmhead"\n + " WHERE cmhead_shipto_country != ''"\n + " AND cmhead_shipto_country NOT IN (SELECT country_name"\n + " FROM country"\n + " WHERE country_name IS NOT NULL)"\n + ' AND (NOT cmhead_posted) '\n + " UNION ALL"\n + " SELECT invchead_id, invchead_billto_country"\n + " FROM invchead"\n + " WHERE invchead_billto_country != ''"\n + " AND invchead_billto_country NOT IN (SELECT country_name"\n + " FROM country"\n + " WHERE country_name IS NOT NULL)"\n + ' AND (NOT invchead_posted) '\n + " UNION ALL"\n + " SELECT invchead_id, invchead_shipto_country"\n + " FROM invchead"\n + " WHERE invchead_shipto_country != ''"\n + " AND invchead_shipto_country NOT IN (SELECT country_name"\n + " FROM country"\n + " WHERE country_name IS NOT NULL)"\n + ' AND (NOT invchead_posted) '\n + " UNION ALL"\n + " SELECT quhead_id, quhead_billtocountry"\n + " FROM quhead"\n + " WHERE quhead_billtocountry != ''"\n + " AND quhead_billtocountry NOT IN (SELECT country_name"\n + " FROM country"\n + " WHERE country_name IS NOT NULL)"\n + ' AND (quhead_expire>=CURRENT_DATE) '\n + " UNION ALL"\n + " SELECT quhead_id, quhead_shiptocountry"\n + " FROM quhead"\n + " WHERE quhead_shiptocountry != ''"\n + " AND quhead_shiptocountry NOT IN (SELECT country_name"\n + " FROM country"\n + " WHERE country_name IS NOT NULL)"\n + ' AND (quhead_expire>=CURRENT_DATE) '\n + " UNION ALL"\n + " SELECT cohead_id, cohead_billtocountry"\n + " FROM cohead"\n + " WHERE cohead_billtocountry != ''"\n + " AND cohead_billtocountry NOT IN (SELECT country_name"\n + " FROM country"\n + " WHERE country_name IS NOT NULL)"\n + ' '\n + " AND cohead_id IN (SELECT coitem_cohead_id"\n + " FROM coitem"\n + " WHERE COALESCE(coitem_status, 'O')='O')"\n + ' '\n + " UNION ALL"\n + " SELECT cohead_id, cohead_shiptocountry"\n + " FROM cohead"\n + " WHERE cohead_shiptocountry != ''"\n + " AND cohead_shiptocountry NOT IN (SELECT country_name"\n + " FROM country"\n + " WHERE country_name IS NOT NULL)"\n + ' '\n + " AND cohead_id IN (SELECT coitem_cohead_id"\n + " FROM coitem"\n + " WHERE COALESCE(coitem_status, 'O')='O')"\n + ' '\n + ") AS dummy "\n + "GROUP BY country "\n + "ORDER BY country;",\n\n params);\n _oldCountry.populate(qry);\n if (qry.lastError().type != 0)\n toolbox.messageBox("warning", mywindow, qsTr("Database Error"),\n qry.lastError().text);\n}\n\nfunction sSave()\n{\n try {\n var params = _params;\n params.oldCountry = _oldCountry.currentText;\n params.newCountry = _newCountry.currentText;\n\n var qry = toolbox.executeQuery(\n 'UPDATE addr SET addr_country = '\n + ' WHERE addr_country = ;', params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Address: " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n 'UPDATE cmhead SET cmhead_billtocountry = '\n + ' WHERE cmhead_billtocountry = '\n + ' '\n + " AND NOT cmhead_posted"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Credit Memo (Bill-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n 'UPDATE cmhead SET cmhead_shipto_country = '\n + ' WHERE cmhead_shipto_country = '\n + ' '\n + " AND NOT cmhead_posted"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Credit Memo (Ship-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n 'UPDATE invchead SET invchead_billto_country = '\n + ' WHERE invchead_billto_country = '\n + ' '\n + " AND NOT invchead_posted"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Invoice (Bill-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n 'UPDATE invchead SET invchead_shipto_country = '\n + ' WHERE invchead_shipto_country = '\n + ' '\n + " AND NOT invchead_posted"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Invoice (Ship-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n 'UPDATE quhead SET quhead_billtocountry = '\n + ' WHERE quhead_billtocountry = '\n + ' '\n + " AND quhead_expire >= CURRENT_DATE"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Quote (Bill-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n 'UPDATE quhead SET quhead_shiptocountry = '\n + ' WHERE quhead_shiptocountry = '\n + ' '\n + " AND quhead_expire >= CURRENT_DATE"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Quote (Ship-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n 'UPDATE cohead SET cohead_billtocountry = '\n + ' WHERE cohead_billtocountry = '\n + ' '\n + " AND cohead_id IN (SELECT coitem_cohead_id"\n + " FROM coitem"\n + " WHERE COALESCE(coitem_status, 'O')='O')"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Sales Order (Bill-To): " + qry.lastError().text);\n\n qry = toolbox.executeQuery(\n 'UPDATE cohead SET cohead_shiptocountry = '\n + ' WHERE cohead_shiptocountry = '\n + ' '\n + " AND cohead_id IN (SELECT coitem_cohead_id"\n + " FROM coitem"\n + " WHERE COALESCE(coitem_status, 'O')='O')"\n + " ", params);\n if (qry.lastError().type != 0)\n throw new Error("Error updating Sales Order (Ship-To): " + qry.lastError().text);\n\n }\n catch (e)\n {\n toolbox.messageBox("critical", mywindow,\n "bulkFixCountry::sSave() exception", e);\n\n }\n mywindow.close();\n}\n\n_buttons.accepted.connect(sSave);\n_buttons.rejected.connect(mywindow, "close()");\n \. -- -- Data for Name: pkguiform; Type: TABLE DATA; Schema: fixcountry; Owner: admin -- COPY pkguiform (uiform_id, uiform_name, uiform_order, uiform_enabled, uiform_source, uiform_notes) FROM stdin; 58 fixCountries 0 t \n\n fixCountries\n \n \n \n 0\n 0\n 800\n 600\n \n \n \n \n 1000\n 16777215\n \n \n \n fixCountries\n \n \n \n \n \n \n \n Query\n \n \n \n \n \n \n Qt::Vertical\n \n \n QSizePolicy::Fixed\n \n \n \n 20\n 15\n \n \n \n \n \n \n \n Fix Case Differences\n \n \n \n \n \n \n Replace Abbreviations\n \n \n \n \n \n \n Bulk Replace\n \n \n \n \n \n \n Qt::Vertical\n \n \n QSizePolicy::Fixed\n \n \n \n 20\n 15\n \n \n \n \n \n \n \n false\n \n \n Edit Selection\n \n \n \n \n \n \n Add Country\n \n \n \n \n \n \n Qt::Vertical\n \n \n \n 20\n 40\n \n \n \n \n \n \n \n \n \n \n 0\n 3\n \n \n \n \n \n \n \n Show closed records\n \n \n true\n \n \n \n \n \n \n <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">\n<html><head><meta name="qrichtext" content="1" /><style type="text/css">\np, li { white-space: pre-wrap; }\n</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;">\n<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You must fix the countries in the following records before turning on Strict Country Checking (System &gt; Configure Modules &gt; CRM...).</p>\n<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>\n<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Here is a short description of your options (assume the <span style=" font-style:italic;">country</span> table has a country named 'Homeland' with the abbreviation 'HL'):</p>\n<ul style="-qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Query</span> will requery the database for records with invalid countries.</li>\n<li style=" font-weight:600;" style=" margin-top:1px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Fix Case Differences<span style=" font-weight:400;"> will change all occurrences of 'HOMELAND' or 'HomeLand' to 'Homeland'.</span></li>\n<li style=" margin-top:1px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Replace Abbreviations</span> will change all occurrences of 'HL' to 'Homeland'.</li>\n<li style=" margin-top:1px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Bulk Replace</span> will replace all occurrences of an invalid country that you choose with a valid country that you choose.</li>\n<li style=" margin-top:1px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Edit Selection</span> will open the selected record for you to fix. If a changed address remains on the list, delete duplicates with CRM &gt; Address &gt; List....</li>\n<li style=" margin-top:1px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Add Country</span> is for the rare case where you must add a new country. Try not to use this.</li>\n<li style=" margin-top:1px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Show closed records</span> will show historical data, such as closed sales orders and posted credit memos &amp; invoices. These will continue to print properly if you don't fix them, but you will have to change the country if you edit and save them with Strict Country Checking turned on.</li></ul></body></html>\n \n \n Qt::RichText\n \n \n true\n \n \n \n \n \n \n \n XCheckBox\n QCheckBox\n

xcheckbox.h
\n \n \n XTreeWidget\n QTreeWidget\n
xtreewidget.h
\n
\n \n \n _list\n _showAll\n _query\n _fixCase\n _fixAbbr\n _edit\n _addCountry\n \n \n \n \n _list\n valid(bool)\n _edit\n setEnabled(bool)\n \n \n 551\n 512\n \n \n 616\n 503\n \n \n \n \n\n 59 bulkFixCountry 0 t \n\n bulkFixCountry\n \n \n \n 0\n 0\n 427\n 162\n \n \n \n Bulk Fix Invalid Country\n \n \n \n \n \n \n \n Replace all instances of this:\n \n \n _oldCountry\n \n \n \n \n \n \n with this country:\n \n \n _newCountry\n \n \n \n \n \n \n true\n \n \n XComboBox::Countries\n \n \n \n \n \n \n \n \n \n \n \n Qt::Vertical\n \n \n QDialogButtonBox::Cancel|QDialogButtonBox::SaveAll\n \n \n false\n \n \n \n \n \n \n \n XComboBox\n QComboBox\n
xcombobox.h
\n
\n
\n \n \n
\n \. SET search_path = public, pg_catalog; -- -- Data for Name: acalitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY acalitem (acalitem_id, acalitem_calhead_id, acalitem_periodstart, acalitem_periodlength, acalitem_name) FROM stdin; \. -- -- Data for Name: accnt; Type: TABLE DATA; Schema: public; Owner: admin -- COPY accnt (accnt_id, accnt_number, accnt_descrip, accnt_comments, accnt_profit, accnt_sub, accnt_type, accnt_extref, accnt_company, accnt_forwardupdate, accnt_subaccnttype_code, accnt_curr_id, accnt_active, accnt_name) FROM stdin; 83 1950 Unassigned Inv Transactions \N 01 A \N t IN 1 t 1950-01 89 1930 Transform Clearing \N 01 A \N t IN 1 t 1930-01 91 8910 Inventory Adjustment \N 01 E \N t EXP 1 t 8910-01 92 8920 Inventory Scrap \N 01 E \N t EXP 1 t 8920-01 93 8930 Manufacturing Scrap \N 01 E \N t EXP 1 t 8930-01 94 2320 Accrued Labor and Overhead Costs \N 01 L \N t CL 1 t 2320-01 96 1260 Shipping Asset \N 01 A \N t IN 1 t 1260-01 98 6550 P/O Line Item Freight Expense \N 01 E \N t EXP 1 t 6550-01 99 2000 Accounts Payable \N 01 L \N t AP 1 t 2000-01 101 4900 Promotions and Discounts Taken \N 01 R \N t SI 1 t 4900-01 103 4000 Revenue \N 01 R \N t SI 1 t 4000-01 104 2440 Prepaid Receivables \N 01 L \N t CL 1 t 2440-01 105 2490 Freight Liability - Sales \N 01 L \N t CL 1 t 2490-01 107 2450 Credit Memo \N 01 L \N t CL 1 t 2450-01 108 5000 Cost of Goods Sold \N 01 E \N t COGS 1 t 5000-01 110 6750 Finance Fees and Expenses \N 01 E \N t EXP 1 t 6750-01 111 1500 Fixed Assets \N 01 A \N t FA 1 t 1500-01 116 2700 Long Term Note Payable \N 01 L \N t LTL 1 t 2700-01 88 1470 Material Usage Variance \N 01 A \N t IN 1 t 1470-01 117 4050 State Sales Tax Revenue \N 01 R \N t SI 1 t 4050-01 118 4060 Shipping Charges Revenue \N 01 R \N t SI 1 t 4060-01 119 6050 State Sales Tax Expense \N 01 E \N t EXP 1 t 6050-01 122 5500 Currency Gain Loss \N 01 E \N t EXP 1 t 5500-01 97 6000 Office Supplies \N 01 E \N t EXP 1 t 6000-01 123 5550 G/L Discrepancy Holds tiny amounts caused by rounding errors. \N 01 E \N t EXP 1 t 5550-01 102 2360 State Sales Tax Liability \N 01 L \N t CL 1 t 2360-01 124 2100 Customer Deposits \N 01 L \N t CL 1 t 2100-01 95 2480 P/O Liability Clearing \N 01 L \N t CL 1 t 2480-01 84 3030 Retained Earnings Year End \N 01 Q \N t ERE 1 t 3030-01 113 3010 Paid-In Capital \N 01 Q \N t EDC 1 t 3010-01 86 1210 Inventory Asset \n \N 01 A \N t IN 1 t 1210-01 85 1250 WIP Asset \N 01 A \N t IN 1 t 1250-01 109 1000 Cash at Bank \N 01 A \N t CA 1 t 1000-01 125 1600 Accumulated Depreciation \N 01 A 1600-01 \N f AD 1 t 1600-01 106 1100 Accounts Receivable \N 01 A \N t AR 1 t 1100-01 127 6020 Shop Supplies \N 01 E 6020-01 \N f EXP 1 t 6020-01 120 6060 Inbound Freight Expense \N 01 E 6060-01 \N t EXP 1 t 6060-01 128 6070 Outbound Freight Expense \N 01 E 6070-01 \N f EXP 1 t 6070-01 112 6400 Depreciation Expense \N 01 E \N \N t DEP 1 t 6400-01 129 4010 Service Revenue \N 01 R 4010-01 \N f SI 1 t 4010-01 121 4800 Customer Credits \N 01 R 4800-01 \N t SI 1 t 4800-01 130 4810 Customer Discounts \N 01 R 4810-01 \N f SI 1 t 4810-01 131 6100 Expensed Inventory \N 01 E \N f EXP 1 t 6100-01 132 6200 Prepaid Expense \N 01 E \N f EXP 1 t 6200-01 133 5010 Inventory Cost Variance \N 01 E \N f COGS 1 t 5010-01 134 5030 Transform Clearing Expense \N 01 E \N f COGS 1 t 5030-01 135 5020 Purchase Price Variance \N 01 E \N f COGS 1 t 5020-01 126 8980 Purchase Expense Variance \N 01 E 8980-01 \N f COGS 1 t 8980-01 136 2600 Project Labor and Overhead \N 01 L \N f CL 1 t 2600-01 \. -- -- Name: accnt_accnt_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('accnt_accnt_id_seq', 136, true); -- -- Data for Name: addr; Type: TABLE DATA; Schema: public; Owner: admin -- COPY addr (addr_id, addr_active, addr_line1, addr_line2, addr_line3, addr_city, addr_state, addr_postalcode, addr_country, addr_notes, addr_number) FROM stdin; 2 t Warehouse Address Line 1 Warehouse Address Line 2 Warehouse Address Line 3 Warehouse Address Line 4 VA 9999-9999 United States 2 1 t Warehouse Address Line 1 Warehouse Address Line 2 Warehouse Address Line 3 Warehouse Address Line 4 United States 1 3 t Accounts Receivable Moving Forward Business Park 12100 Let's Go Norfolk VA 23100 United States 3 \. -- -- Name: addr_addr_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('addr_addr_id_seq', 3, true); -- -- Data for Name: alarm; Type: TABLE DATA; Schema: public; Owner: admin -- COPY alarm (alarm_id, alarm_number, alarm_event, alarm_email, alarm_sysmsg, alarm_trigger, alarm_time, alarm_time_offset, alarm_time_qualifier, alarm_creator, alarm_event_recipient, alarm_email_recipient, alarm_sysmsg_recipient, alarm_source, alarm_source_id) FROM stdin; \. -- -- Name: alarm_alarm_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('alarm_alarm_id_seq', 1, false); -- -- Data for Name: apaccnt; Type: TABLE DATA; Schema: public; Owner: admin -- COPY apaccnt (apaccnt_id, apaccnt_vendtype_id, apaccnt_vendtype, apaccnt_ap_accnt_id, apaccnt_prepaid_accnt_id, apaccnt_discount_accnt_id) FROM stdin; 20 -1 .* 99 132 101 \. -- -- Name: apaccnt_apaccnt_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('apaccnt_apaccnt_id_seq', 20, true); -- -- Data for Name: apapply; Type: TABLE DATA; Schema: public; Owner: admin -- COPY apapply (apapply_id, apapply_vend_id, apapply_postdate, apapply_username, apapply_source_apopen_id, apapply_source_doctype, apapply_source_docnumber, apapply_target_apopen_id, apapply_target_doctype, apapply_target_docnumber, apapply_journalnumber, apapply_amount, apapply_curr_id, apapply_target_paid, apapply_checkhead_id) FROM stdin; \. -- -- Name: apapply_apapply_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('apapply_apapply_id_seq', 1, false); -- -- Data for Name: apcreditapply; Type: TABLE DATA; Schema: public; Owner: admin -- COPY apcreditapply (apcreditapply_id, apcreditapply_source_apopen_id, apcreditapply_target_apopen_id, apcreditapply_amount, apcreditapply_curr_id) FROM stdin; \. -- -- Name: apcreditapply_apcreditapply_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('apcreditapply_apcreditapply_id_seq', 1, false); -- -- Data for Name: apopen; Type: TABLE DATA; Schema: public; Owner: admin -- COPY apopen (apopen_id, apopen_docdate, apopen_duedate, apopen_terms_id, apopen_vend_id, apopen_doctype, apopen_docnumber, apopen_amount, apopen_notes, apopen_posted, apopen_reference, apopen_invcnumber, apopen_ponumber, apopen_journalnumber, apopen_paid, apopen_open, apopen_username, apopen_discount, apopen_accnt_id, apopen_curr_id, apopen_closedate, apopen_distdate, apopen_void, apopen_curr_rate, apopen_discountable_amount, apopen_status) FROM stdin; \. -- -- Name: apopen_apopen_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('apopen_apopen_id_seq', 70, true); -- -- Data for Name: apopentax; Type: TABLE DATA; Schema: public; Owner: admin -- COPY apopentax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; \. -- -- Data for Name: apselect; Type: TABLE DATA; Schema: public; Owner: admin -- COPY apselect (apselect_id, apselect_apopen_id, apselect_amount, apselect_bankaccnt_id, apselect_curr_id, apselect_date, apselect_discount) FROM stdin; \. -- -- Name: apselect_apselect_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('apselect_apselect_id_seq', 501, true); -- -- Data for Name: araccnt; Type: TABLE DATA; Schema: public; Owner: admin -- COPY araccnt (araccnt_id, araccnt_custtype_id, araccnt_custtype, araccnt_freight_accnt_id, araccnt_ar_accnt_id, araccnt_prepaid_accnt_id, araccnt_deferred_accnt_id, araccnt_discount_accnt_id) FROM stdin; 39 -1 .* 118 106 121 124 130 \. -- -- Name: araccnt_araccnt_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('araccnt_araccnt_id_seq', 39, true); -- -- Data for Name: arapply; Type: TABLE DATA; Schema: public; Owner: admin -- COPY arapply (arapply_id, arapply_postdate, arapply_cust_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_applied, arapply_closed, arapply_journalnumber, arapply_source_aropen_id, arapply_target_aropen_id, arapply_username, arapply_curr_id, arapply_distdate, arapply_target_paid, arapply_reftype, arapply_ref_id) FROM stdin; \. -- -- Name: arapply_arapply_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('arapply_arapply_id_seq', 1, false); -- -- Data for Name: arcreditapply; Type: TABLE DATA; Schema: public; Owner: admin -- COPY arcreditapply (arcreditapply_id, arcreditapply_source_aropen_id, arcreditapply_target_aropen_id, arcreditapply_amount, arcreditapply_curr_id, arcreditapply_reftype, arcreditapply_ref_id) FROM stdin; \. -- -- Name: arcreditapply_arcreditapply_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('arcreditapply_arcreditapply_id_seq', 1, false); -- -- Data for Name: aropen; Type: TABLE DATA; Schema: public; Owner: admin -- COPY aropen (aropen_id, aropen_docdate, aropen_duedate, aropen_terms_id, aropen_cust_id, aropen_doctype, aropen_docnumber, aropen_applyto, aropen_ponumber, aropen_amount, aropen_notes, aropen_posted, aropen_salesrep_id, aropen_commission_due, aropen_commission_paid, aropen_ordernumber, aropen_cobmisc_id, aropen_journalnumber, aropen_paid, aropen_open, aropen_username, aropen_rsncode_id, aropen_salescat_id, aropen_accnt_id, aropen_curr_id, aropen_closedate, aropen_distdate, aropen_curr_rate, aropen_discount, aropen_fincharg_date, aropen_fincharg_amount) FROM stdin; \. -- -- Name: aropen_aropen_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('aropen_aropen_id_seq', 292, true); -- -- Data for Name: aropenalloc; Type: TABLE DATA; Schema: public; Owner: admin -- COPY aropenalloc (aropenalloc_aropen_id, aropenalloc_doctype, aropenalloc_doc_id, aropenalloc_amount, aropenalloc_curr_id) FROM stdin; \. -- -- Data for Name: aropentax; Type: TABLE DATA; Schema: public; Owner: admin -- COPY aropentax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; \. -- -- Data for Name: asohist; Type: TABLE DATA; Schema: public; Owner: admin -- COPY asohist (asohist_id, asohist_cust_id, asohist_itemsite_id, asohist_shipdate, asohist_invcdate, asohist_duedate, asohist_promisedate, asohist_ordernumber, asohist_invcnumber, asohist_qtyshipped, asohist_unitprice, asohist_unitcost, asohist_billtoname, asohist_billtoaddress1, asohist_billtoaddress2, asohist_billtoaddress3, asohist_billtocity, asohist_billtostate, asohist_billtozip, asohist_shiptoname, asohist_shiptoaddress1, asohist_shiptoaddress2, asohist_shiptoaddress3, asohist_shiptocity, asohist_shiptostate, asohist_shiptozip, asohist_shipto_id, asohist_shipvia, asohist_salesrep_id, asohist_misc_type, asohist_misc_descrip, asohist_misc_id, asohist_commission, asohist_commissionpaid, asohist_doctype, asohist_orderdate, asohist_imported, asohist_ponumber, asohist_curr_id, asohist_taxtype_id, asohist_taxzone_id) FROM stdin; \. -- -- Name: asohist_asohist_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('asohist_asohist_id_seq', 1, false); -- -- Data for Name: asohisttax; Type: TABLE DATA; Schema: public; Owner: admin -- COPY asohisttax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; \. -- -- Data for Name: atlasmap; Type: TABLE DATA; Schema: public; Owner: admin -- COPY atlasmap (atlasmap_id, atlasmap_name, atlasmap_filter, atlasmap_filtertype, atlasmap_atlas, atlasmap_map, atlasmap_headerline) FROM stdin; \. -- -- Name: atlasmap_atlasmap_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('atlasmap_atlasmap_id_seq', 1, false); -- -- Data for Name: backup_usr; Type: TABLE DATA; Schema: public; Owner: admin -- COPY backup_usr (usr_id, usr_username, usr_propername, usr_passwd, usr_locale_id, usr_initials, usr_agent, usr_active, usr_email, usr_dept_id, usr_shift_id, usr_window) FROM stdin; 1 mfgadmin OpenMFG Administrator \N 3 ADMIN t t admin@example.com 2 1 2 admin Administrator 3 ADMIN t t admin@example.com 2 1 \N \. -- -- Data for Name: bankaccnt; Type: TABLE DATA; Schema: public; Owner: admin -- COPY bankaccnt (bankaccnt_id, bankaccnt_name, bankaccnt_descrip, bankaccnt_bankname, bankaccnt_accntnumber, bankaccnt_ar, bankaccnt_ap, bankaccnt_nextchknum, bankaccnt_type, bankaccnt_accnt_id, bankaccnt_check_form_id, bankaccnt_userec, bankaccnt_rec_accnt_id, bankaccnt_curr_id, bankaccnt_notes, bankaccnt_routing, bankaccnt_ach_enabled, bankaccnt_ach_origin, bankaccnt_ach_genchecknum, bankaccnt_ach_leadtime, bankaccnt_ach_lastdate, bankaccnt_ach_lastfileid, bankaccnt_ach_origintype, bankaccnt_ach_originname, bankaccnt_ach_desttype, bankaccnt_ach_fed_dest, bankaccnt_ach_destname, bankaccnt_ach_dest, bankaccnt_prnt_check) FROM stdin; 13 Bank Bank Bank 0000000000 t t 5000 K 109 21 \N \N 1 \N f f \N \N \N I \N \N \N \N \N t \. -- -- Name: bankaccnt_bankaccnt_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('bankaccnt_bankaccnt_id_seq', 13, true); -- -- Data for Name: bankadj; Type: TABLE DATA; Schema: public; Owner: admin -- COPY bankadj (bankadj_id, bankadj_bankaccnt_id, bankadj_bankadjtype_id, bankadj_created, bankadj_username, bankadj_date, bankadj_docnumber, bankadj_amount, bankadj_notes, bankadj_sequence, bankadj_posted, bankadj_curr_id, bankadj_curr_rate) FROM stdin; \. -- -- Name: bankadj_bankadj_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('bankadj_bankadj_id_seq', 1, false); -- -- Data for Name: bankadjtype; Type: TABLE DATA; Schema: public; Owner: admin -- COPY bankadjtype (bankadjtype_id, bankadjtype_name, bankadjtype_descrip, bankadjtype_accnt_id, bankadjtype_iscredit) FROM stdin; \. -- -- Name: bankadjtype_bankadjtype_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('bankadjtype_bankadjtype_id_seq', 1, false); -- -- Data for Name: bankrec; Type: TABLE DATA; Schema: public; Owner: admin -- COPY bankrec (bankrec_id, bankrec_created, bankrec_username, bankrec_bankaccnt_id, bankrec_opendate, bankrec_enddate, bankrec_openbal, bankrec_endbal, bankrec_posted, bankrec_postdate) FROM stdin; \. -- -- Name: bankrec_bankrec_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('bankrec_bankrec_id_seq', 1, false); -- -- Data for Name: bankrecimport; Type: TABLE DATA; Schema: public; Owner: admin -- COPY bankrecimport (bankrecimport_id, bankrecimport_reference, bankrecimport_descrip, bankrecimport_comment, bankrecimport_debit_amount, bankrecimport_credit_amount, bankrecimport_effdate, bankrecimport_curr_rate) FROM stdin; \. -- -- Name: bankrecimport_bankrecimport_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('bankrecimport_bankrecimport_id_seq', 1, false); -- -- Data for Name: bankrecitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY bankrecitem (bankrecitem_id, bankrecitem_bankrec_id, bankrecitem_source, bankrecitem_source_id, bankrecitem_cleared, bankrecitem_curr_rate, bankrecitem_amount, bankrecitem_effdate) FROM stdin; \. -- -- Name: bankrecitem_bankrecitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('bankrecitem_bankrecitem_id_seq', 1, false); -- -- Data for Name: bomhead; Type: TABLE DATA; Schema: public; Owner: admin -- COPY bomhead (bomhead_id, bomhead_item_id, bomhead_serial, bomhead_docnum, bomhead_revision, bomhead_revisiondate, bomhead_batchsize, bomhead_requiredqtyper, bomhead_rev_id) FROM stdin; \. -- -- Name: bomhead_bomhead_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('bomhead_bomhead_id_seq', 54, true); -- -- Data for Name: bomitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY bomitem (bomitem_id, bomitem_parent_item_id, bomitem_seqnumber, bomitem_item_id, bomitem_qtyper, bomitem_scrap, bomitem_status, bomitem_effective, bomitem_expires, bomitem_createwo, bomitem_issuemethod, bomitem_schedatwooper, bomitem_ecn, bomitem_moddate, bomitem_subtype, bomitem_uom_id, bomitem_rev_id, bomitem_booitem_seq_id, bomitem_char_id, bomitem_value, bomitem_notes, bomitem_ref, bomitem_qtyfxd, bomitem_issuewo) FROM stdin; \. -- -- Name: bomitem_bomitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('bomitem_bomitem_id_seq', 167, true); -- -- Data for Name: bomitemcost; Type: TABLE DATA; Schema: public; Owner: admin -- COPY bomitemcost (bomitemcost_id, bomitemcost_bomitem_id, bomitemcost_costelem_id, bomitemcost_lowlevel, bomitemcost_stdcost, bomitemcost_posted, bomitemcost_actcost, bomitemcost_updated, bomitemcost_curr_id) FROM stdin; \. -- -- Name: bomitemcost_bomitemcost_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('bomitemcost_bomitemcost_id_seq', 1, false); -- -- Data for Name: bomitemsub; Type: TABLE DATA; Schema: public; Owner: admin -- COPY bomitemsub (bomitemsub_id, bomitemsub_bomitem_id, bomitemsub_item_id, bomitemsub_uomratio, bomitemsub_rank) FROM stdin; \. -- -- Name: bomitemsub_bomitemsub_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('bomitemsub_bomitemsub_id_seq', 1, false); -- -- Data for Name: bomwork; Type: TABLE DATA; Schema: public; Owner: admin -- COPY bomwork (bomwork_id, bomwork_set_id, bomwork_seqnumber, bomwork_item_id, bomwork_item_type, bomwork_qtyper, bomwork_scrap, bomwork_status, bomwork_level, bomwork_parent_id, bomwork_effective, bomwork_expires, bomwork_stdunitcost, bomwork_actunitcost, bomwork_parent_seqnumber, bomwork_createwo, bomwork_issuemethod, bomwork_char_id, bomwork_value, bomwork_notes, bomwork_ref, bomwork_bomitem_id, bomwork_ecn, bomwork_qtyfxd, bomwork_qtyreq) FROM stdin; \. -- -- Name: bomwork_bomwork_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('bomwork_bomwork_id_seq', 1, false); -- -- Data for Name: budghead; Type: TABLE DATA; Schema: public; Owner: admin -- COPY budghead (budghead_id, budghead_name, budghead_descrip) FROM stdin; 1 Default Default budget for conversion \. -- -- Name: budghead_budghead_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('budghead_budghead_id_seq', 2, true); -- -- Data for Name: budgitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY budgitem (budgitem_id, budgitem_budghead_id, budgitem_period_id, budgitem_accnt_id, budgitem_amount) FROM stdin; \. -- -- Name: budgitem_budgitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('budgitem_budgitem_id_seq', 1, true); -- -- Data for Name: calhead; Type: TABLE DATA; Schema: public; Owner: admin -- COPY calhead (calhead_id, calhead_type, calhead_name, calhead_descrip, calhead_origin) FROM stdin; 47 R 8WEEK_FORWARD 8 Week Forward Calendar D 48 R 3MONTH_BACK 3 Months Back Calendar D \. -- -- Name: calhead_calhead_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('calhead_calhead_id_seq', 48, true); -- -- Name: carrier_carrier_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('carrier_carrier_id_seq', 15, true); -- -- Data for Name: cashrcpt; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cashrcpt (cashrcpt_id, cashrcpt_cust_id, cashrcpt_amount, cashrcpt_fundstype, cashrcpt_docnumber, cashrcpt_bankaccnt_id, cashrcpt_notes, cashrcpt_distdate, cashrcpt_salescat_id, cashrcpt_curr_id, cashrcpt_usecustdeposit, cashrcpt_void, cashrcpt_number, cashrcpt_docdate, cashrcpt_posted, cashrcpt_posteddate, cashrcpt_postedby, cashrcpt_applydate, cashrcpt_discount, cashrcpt_curr_rate, cashrcpt_alt_curr_rate) FROM stdin; \. -- -- Name: cashrcpt_cashrcpt_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cashrcpt_cashrcpt_id_seq', 112, true); -- -- Data for Name: cashrcptitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cashrcptitem (cashrcptitem_id, cashrcptitem_cashrcpt_id, cashrcptitem_aropen_id, cashrcptitem_amount, cashrcptitem_discount, cashrcptitem_applied) FROM stdin; \. -- -- Name: cashrcptitem_cashrcptitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cashrcptitem_cashrcptitem_id_seq', 170, true); -- -- Data for Name: cashrcptmisc; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cashrcptmisc (cashrcptmisc_id, cashrcptmisc_cashrcpt_id, cashrcptmisc_accnt_id, cashrcptmisc_amount, cashrcptmisc_notes) FROM stdin; \. -- -- Name: cashrcptmisc_cashrcptmisc_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cashrcptmisc_cashrcptmisc_id_seq', 26, true); -- -- Data for Name: ccard; Type: TABLE DATA; Schema: public; Owner: admin -- COPY ccard (ccard_id, ccard_seq, ccard_cust_id, ccard_active, ccard_name, ccard_address1, ccard_address2, ccard_city, ccard_state, ccard_zip, ccard_country, ccard_number, ccard_debit, ccard_month_expired, ccard_year_expired, ccard_type, ccard_date_added, ccard_lastupdated, ccard_added_by_username, ccard_last_updated_by_username) FROM stdin; \. -- -- Name: ccard_ccard_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('ccard_ccard_id_seq', 1, false); -- -- Data for Name: ccardaud; Type: TABLE DATA; Schema: public; Owner: admin -- COPY ccardaud (ccardaud_id, ccardaud_ccard_id, ccardaud_ccard_seq_old, ccardaud_ccard_seq_new, ccardaud_ccard_cust_id_old, ccardaud_ccard_cust_id_new, ccardaud_ccard_active_old, ccardaud_ccard_active_new, ccardaud_ccard_name_old, ccardaud_ccard_name_new, ccardaud_ccard_address1_old, ccardaud_ccard_address1_new, ccardaud_ccard_address2_old, ccardaud_ccard_address2_new, ccardaud_ccard_city_old, ccardaud_ccard_city_new, ccardaud_ccard_state_old, ccardaud_ccard_state_new, ccardaud_ccard_zip_old, ccardaud_ccard_zip_new, ccardaud_ccard_country_old, ccardaud_ccard_country_new, ccardaud_ccard_number_old, ccardaud_ccard_number_new, ccardaud_ccard_debit_old, ccardaud_ccard_debit_new, ccardaud_ccard_month_expired_old, ccardaud_ccard_month_expired_new, ccardaud_ccard_year_expired_old, ccardaud_ccard_year_expired_new, ccardaud_ccard_type_old, ccardaud_ccard_type_new, ccardaud_ccard_last_updated, ccardaud_ccard_last_updated_by_username) FROM stdin; \. -- -- Name: ccardaud_ccardaud_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('ccardaud_ccardaud_id_seq', 1, false); -- -- Data for Name: ccbank; Type: TABLE DATA; Schema: public; Owner: admin -- COPY ccbank (ccbank_id, ccbank_ccard_type, ccbank_bankaccnt_id) FROM stdin; 4 P \N 1 A \N 2 D \N 3 M \N 5 V \N \. -- -- Name: ccbank_ccbank_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('ccbank_ccbank_id_seq', 5, true); -- -- Data for Name: ccpay; Type: TABLE DATA; Schema: public; Owner: admin -- COPY ccpay (ccpay_id, ccpay_ccard_id, ccpay_cust_id, ccpay_amount, ccpay_auth, ccpay_status, ccpay_type, ccpay_auth_charge, ccpay_order_number, ccpay_order_number_seq, ccpay_r_avs, ccpay_r_ordernum, ccpay_r_error, ccpay_r_approved, ccpay_r_code, ccpay_r_message, ccpay_yp_r_time, ccpay_r_ref, ccpay_yp_r_tdate, ccpay_r_tax, ccpay_r_shipping, ccpay_yp_r_score, ccpay_transaction_datetime, ccpay_by_username, ccpay_curr_id, ccpay_ccpay_id, ccpay_card_pan_trunc, ccpay_card_type) FROM stdin; \. -- -- Name: ccpay_ccpay_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('ccpay_ccpay_id_seq', 1, false); -- -- Data for Name: char; Type: TABLE DATA; Schema: public; Owner: admin -- COPY "char" (char_id, char_name, char_items, char_options, char_attributes, char_lotserial, char_notes, char_customers, char_crmaccounts, char_addresses, char_contacts, char_opportunity, char_employees, char_mask, char_validator, char_incidents, char_type, char_order, char_search, char_quotes, char_salesorders, char_invoices, char_vendors, char_purchaseorders, char_vouchers, char_projects, char_tasks) FROM stdin; 14 Lot Test Results f f f t Lot Test Results f f f f f f \N \N f 0 10 t f f f f f f f f 13 Cusotmer Feedback f f f f Feedback From Customer t f f f f f \N \N f 0 10 t f f f f f f f f 15 Item Color t f f f Item Color f f f f f f \N \N f 1 10 t f f f f f f f f \. -- -- Name: char_char_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('char_char_id_seq', 15, true); -- -- Data for Name: charass; Type: TABLE DATA; Schema: public; Owner: admin -- COPY charass (charass_id, charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price) FROM stdin; \. -- -- Name: charass_charass_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('charass_charass_id_seq', 1, false); -- -- Data for Name: charopt; Type: TABLE DATA; Schema: public; Owner: admin -- COPY charopt (charopt_id, charopt_char_id, charopt_value, charopt_order) FROM stdin; 1 15 Red 10 2 15 Green 20 3 15 Blue 30 \. -- -- Name: charopt_charopt_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('charopt_charopt_id_seq', 3, true); -- -- Data for Name: charuse; Type: TABLE DATA; Schema: public; Owner: admin -- COPY charuse (charuse_id, charuse_char_id, charuse_target_type, charuse_created, charuse_last_modified) FROM stdin; 1 13 C 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 2 13 CT 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 3 15 I 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 4 14 LS 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 5 14 LSR 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 \. -- -- Name: charuse_charuse_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('charuse_charuse_id_seq', 5, true); -- -- Data for Name: checkhead; Type: TABLE DATA; Schema: public; Owner: admin -- COPY checkhead (checkhead_id, checkhead_recip_id, checkhead_recip_type, checkhead_bankaccnt_id, checkhead_printed, checkhead_checkdate, checkhead_number, checkhead_amount, checkhead_void, checkhead_replaced, checkhead_posted, checkhead_rec, checkhead_misc, checkhead_expcat_id, checkhead_for, checkhead_notes, checkhead_journalnumber, checkhead_curr_id, checkhead_deleted, checkhead_ach_batch, checkhead_curr_rate, checkhead_alt_curr_rate) FROM stdin; \. -- -- Name: checkhead_checkhead_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('checkhead_checkhead_id_seq', 1, false); -- -- Data for Name: checkitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY checkitem (checkitem_id, checkitem_checkhead_id, checkitem_amount, checkitem_discount, checkitem_ponumber, checkitem_vouchernumber, checkitem_invcnumber, checkitem_apopen_id, checkitem_aropen_id, checkitem_docdate, checkitem_curr_id, checkitem_cmnumber, checkitem_ranumber, checkitem_curr_rate) FROM stdin; \. -- -- Name: checkitem_checkitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('checkitem_checkitem_id_seq', 1, false); -- -- Data for Name: classcode; Type: TABLE DATA; Schema: public; Owner: admin -- COPY classcode (classcode_id, classcode_code, classcode_descrip, classcode_mfg, classcode_creator, classcode_created, classcode_modifier, classcode_modified, classcode_type) FROM stdin; 35 SOLD Sold Items \N \N \N \N \N \N 34 OUTSIDE PROCESS Outside Process \N \N \N \N \N \N 36 SUB ASSEMBLY Sub Assembly \N \N \N \N \N \N 33 COMPONENT Component \N \N \N \N \N \N \. -- -- Name: classcode_classcode_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('classcode_classcode_id_seq', 36, true); -- -- Data for Name: cmd; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cmd (cmd_id, cmd_module, cmd_title, cmd_descrip, cmd_privname, cmd_executable, cmd_name) FROM stdin; \. -- -- Name: cmd_cmd_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cmd_cmd_id_seq', 6, true); -- -- Data for Name: cmdarg; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cmdarg (cmdarg_id, cmdarg_cmd_id, cmdarg_order, cmdarg_arg) FROM stdin; \. -- -- Name: cmdarg_cmdarg_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cmdarg_cmdarg_id_seq', 6, true); -- -- Data for Name: cmhead; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cmhead (cmhead_id, cmhead_number, cmhead_posted, cmhead_invcnumber, cmhead_custponumber, cmhead_cust_id, cmhead_docdate, cmhead_shipto_id, cmhead_shipto_name, cmhead_shipto_address1, cmhead_shipto_address2, cmhead_shipto_address3, cmhead_shipto_city, cmhead_shipto_state, cmhead_shipto_zipcode, cmhead_salesrep_id, cmhead_freight, cmhead_misc, cmhead_comments, cmhead_printed, cmhead_billtoname, cmhead_billtoaddress1, cmhead_billtoaddress2, cmhead_billtoaddress3, cmhead_billtocity, cmhead_billtostate, cmhead_billtozip, cmhead_hold, cmhead_commission, cmhead_misc_accnt_id, cmhead_misc_descrip, cmhead_rsncode_id, cmhead_curr_id, cmhead_freighttaxtype_id, cmhead_gldistdate, cmhead_billtocountry, cmhead_shipto_country, cmhead_rahead_id, cmhead_taxzone_id, cmhead_prj_id, cmhead_void, cmhead_saletype_id, cmhead_shipzone_id) FROM stdin; \. -- -- Name: cmhead_cmhead_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cmhead_cmhead_id_seq', 206, true); -- -- Data for Name: cmheadtax; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cmheadtax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; \. -- -- Data for Name: cmitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cmitem (cmitem_id, cmitem_cmhead_id, cmitem_linenumber, cmitem_itemsite_id, cmitem_qtycredit, cmitem_qtyreturned, cmitem_unitprice, cmitem_comments, cmitem_rsncode_id, cmitem_taxtype_id, cmitem_qty_uom_id, cmitem_qty_invuomratio, cmitem_price_uom_id, cmitem_price_invuomratio, cmitem_raitem_id, cmitem_updateinv) FROM stdin; \. -- -- Name: cmitem_cmitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cmitem_cmitem_id_seq', 83, true); -- -- Data for Name: cmitemtax; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cmitemtax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; \. -- -- Data for Name: cmnttype; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cmnttype (cmnttype_id, cmnttype_name, cmnttype_descrip, cmnttype_usedin, cmnttype_sys, cmnttype_editable, cmnttype_order) FROM stdin; 1 General General Comment ICVPL t f \N 2 ChangeLog Change Log ICVP t f \N 3 Notes to Comment Used by certain triggers to automatically create/update comment with content of notes. \N t f \N \. -- -- Name: cmnttype_cmnttype_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cmnttype_cmnttype_id_seq', 3, true); -- -- Data for Name: cmnttypesource; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cmnttypesource (cmnttypesource_id, cmnttypesource_cmnttype_id, cmnttypesource_source_id) FROM stdin; 8 1 1 9 2 1 10 1 2 11 2 2 12 1 3 13 2 3 14 1 4 15 2 4 16 1 5 17 2 5 18 1 6 19 2 6 20 1 7 21 2 7 22 1 8 23 2 8 24 1 9 25 2 9 26 1 10 27 2 10 28 1 11 29 2 11 30 1 12 31 2 12 32 1 13 33 2 13 34 1 14 35 2 14 36 1 15 37 2 15 38 1 16 39 2 16 40 1 17 41 2 17 42 1 18 43 2 18 44 1 19 45 2 19 46 1 20 47 2 20 48 1 21 49 2 21 50 1 22 51 2 22 52 1 23 53 2 23 54 1 24 55 2 24 56 1 25 57 2 25 58 1 26 59 2 26 60 1 27 61 2 27 62 1 28 63 2 28 64 1 29 65 2 29 66 1 30 67 2 30 68 1 31 69 2 31 70 1 32 71 2 32 72 1 33 73 2 33 74 1 34 75 2 34 76 3 12 \. -- -- Name: cmnttypesource_cmnttypesource_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cmnttypesource_cmnttypesource_id_seq', 76, true); -- -- Data for Name: cntct; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cntct (cntct_id, cntct_crmacct_id, cntct_addr_id, cntct_first_name, cntct_last_name, cntct_honorific, cntct_initials, cntct_active, cntct_phone, cntct_phone2, cntct_fax, cntct_email, cntct_webaddr, cntct_notes, cntct_title, cntct_number, cntct_middle, cntct_suffix, cntct_owner_username, cntct_name) FROM stdin; 2 \N 2 Main Warehouse \N \N t \N \N \N \N 2 \N \N \N Main Warehouse \. -- -- Name: cntct_cntct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cntct_cntct_id_seq', 2, true); -- -- Data for Name: cntctaddr; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cntctaddr (cntctaddr_id, cntctaddr_cntct_id, cntctaddr_primary, cntctaddr_addr_id, cntctaddr_type) FROM stdin; \. -- -- Name: cntctaddr_cntctaddr_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cntctaddr_cntctaddr_id_seq', 1, false); -- -- Data for Name: cntctdata; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cntctdata (cntctdata_id, cntctdata_cntct_id, cntctdata_primary, cntctdata_text, cntctdata_type) FROM stdin; \. -- -- Name: cntctdata_cntctdata_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cntctdata_cntctdata_id_seq', 1, false); -- -- Data for Name: cntcteml; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cntcteml (cntcteml_id, cntcteml_cntct_id, cntcteml_primary, cntcteml_email) FROM stdin; \. -- -- Name: cntcteml_cntcteml_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cntcteml_cntcteml_id_seq', 1, false); -- -- Data for Name: cntctmrgd; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cntctmrgd (cntctmrgd_cntct_id, cntctmrgd_error) FROM stdin; \. -- -- Data for Name: cntctsel; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cntctsel (cntctsel_cntct_id, cntctsel_target, cntctsel_mrg_crmacct_id, cntctsel_mrg_addr_id, cntctsel_mrg_first_name, cntctsel_mrg_last_name, cntctsel_mrg_honorific, cntctsel_mrg_initials, cntctsel_mrg_phone, cntctsel_mrg_phone2, cntctsel_mrg_fax, cntctsel_mrg_email, cntctsel_mrg_webaddr, cntctsel_mrg_notes, cntctsel_mrg_title, cntctsel_mrg_middle, cntctsel_mrg_suffix, cntctsel_mrg_owner_username) FROM stdin; \. -- -- Data for Name: cntslip; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cntslip (cntslip_id, cntslip_cnttag_id, cntslip_entered, cntslip_posted, cntslip_number, cntslip_qty, cntslip_comments, cntslip_location_id, cntslip_lotserial, cntslip_lotserial_expiration, cntslip_lotserial_warrpurc, cntslip_username) FROM stdin; \. -- -- Name: cntslip_cntslip_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cntslip_cntslip_id_seq', 97, true); -- -- Data for Name: cobill; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cobill (cobill_id, cobill_coitem_id, cobill_selectdate, cobill_qty, cobill_invcnum, cobill_toclose, cobill_cobmisc_id, cobill_select_username, cobill_invcitem_id, cobill_taxtype_id) FROM stdin; \. -- -- Name: cobill_cobill_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cobill_cobill_id_seq', 528, true); -- -- Data for Name: cobilltax; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cobilltax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; \. -- -- Data for Name: cobmisc; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cobmisc (cobmisc_id, cobmisc_cohead_id, cobmisc_shipvia, cobmisc_freight, cobmisc_misc, cobmisc_payment, cobmisc_paymentref, cobmisc_notes, cobmisc_shipdate, cobmisc_invcnumber, cobmisc_invcdate, cobmisc_posted, cobmisc_misc_accnt_id, cobmisc_misc_descrip, cobmisc_closeorder, cobmisc_curr_id, cobmisc_invchead_id, cobmisc_taxzone_id, cobmisc_taxtype_id) FROM stdin; \. -- -- Name: cobmisc_cobmisc_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cobmisc_cobmisc_id_seq', 204, true); -- -- Data for Name: cobmisctax; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cobmisctax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; \. -- -- Data for Name: cohead; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cohead (cohead_id, cohead_number, cohead_cust_id, cohead_custponumber, cohead_type, cohead_orderdate, cohead_warehous_id, cohead_shipto_id, cohead_shiptoname, cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3, cohead_shiptoaddress4, cohead_shiptoaddress5, cohead_salesrep_id, cohead_terms_id, cohead_fob, cohead_shipvia, cohead_shiptocity, cohead_shiptostate, cohead_shiptozipcode, cohead_freight, cohead_misc, cohead_imported, cohead_ordercomments, cohead_shipcomments, cohead_shiptophone, cohead_shipchrg_id, cohead_shipform_id, cohead_billtoname, cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, cohead_billtocity, cohead_billtostate, cohead_billtozipcode, cohead_misc_accnt_id, cohead_misc_descrip, cohead_commission, cohead_miscdate, cohead_holdtype, cohead_packdate, cohead_prj_id, cohead_wasquote, cohead_lastupdated, cohead_shipcomplete, cohead_created, cohead_creator, cohead_quote_number, cohead_billtocountry, cohead_shiptocountry, cohead_curr_id, cohead_calcfreight, cohead_shipto_cntct_id, cohead_shipto_cntct_honorific, cohead_shipto_cntct_first_name, cohead_shipto_cntct_middle, cohead_shipto_cntct_last_name, cohead_shipto_cntct_suffix, cohead_shipto_cntct_phone, cohead_shipto_cntct_title, cohead_shipto_cntct_fax, cohead_shipto_cntct_email, cohead_billto_cntct_id, cohead_billto_cntct_honorific, cohead_billto_cntct_first_name, cohead_billto_cntct_middle, cohead_billto_cntct_last_name, cohead_billto_cntct_suffix, cohead_billto_cntct_phone, cohead_billto_cntct_title, cohead_billto_cntct_fax, cohead_billto_cntct_email, cohead_taxzone_id, cohead_taxtype_id, cohead_ophead_id, cohead_status, cohead_saletype_id, cohead_shipzone_id) FROM stdin; \. -- -- Name: cohead_cohead_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cohead_cohead_id_seq', 2952, true); -- -- Data for Name: cohist; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cohist (cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_orderdate, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_shipto_id, cohist_salesrep_id, cohist_duedate, cohist_imported, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_commission, cohist_commissionpaid, cohist_unitcost, cohist_misc_type, cohist_misc_descrip, cohist_misc_id, cohist_doctype, cohist_promisedate, cohist_ponumber, cohist_curr_id, cohist_sequence, cohist_taxtype_id, cohist_taxzone_id, cohist_cohead_ccpay_id, cohist_saletype_id, cohist_shipzone_id) FROM stdin; \. -- -- Name: cohist_cohist_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cohist_cohist_id_seq', 493, true); -- -- Data for Name: cohisttax; Type: TABLE DATA; Schema: public; Owner: admin -- COPY cohisttax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; \. -- -- Data for Name: coitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY coitem (coitem_id, coitem_cohead_id, coitem_linenumber, coitem_itemsite_id, coitem_status, coitem_scheddate, coitem_promdate, coitem_qtyord, coitem_unitcost, coitem_price, coitem_custprice, coitem_qtyshipped, coitem_order_id, coitem_memo, coitem_imported, coitem_qtyreturned, coitem_closedate, coitem_custpn, coitem_order_type, coitem_close_username, coitem_lastupdated, coitem_substitute_item_id, coitem_created, coitem_creator, coitem_prcost, coitem_qty_uom_id, coitem_qty_invuomratio, coitem_price_uom_id, coitem_price_invuomratio, coitem_warranty, coitem_cos_accnt_id, coitem_qtyreserved, coitem_subnumber, coitem_firm, coitem_taxtype_id, coitem_rev_accnt_id, coitem_pricemode) FROM stdin; \. -- -- Name: coitem_coitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('coitem_coitem_id_seq', 564, true); -- -- Data for Name: comment; Type: TABLE DATA; Schema: public; Owner: admin -- COPY comment (comment_id, comment_source_id, comment_date, comment_user, comment_text, comment_cmnttype_id, comment_source, comment_public) FROM stdin; 39 2 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 40 3 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 41 4 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 42 5 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 43 6 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 44 7 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 45 8 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 46 9 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 47 10 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 48 11 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 49 12 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 50 13 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 51 14 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 52 15 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 53 16 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 54 17 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 55 18 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 56 19 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 57 20 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 58 21 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 59 22 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 60 23 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 61 24 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 62 25 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f 63 26 2011-08-19 15:27:57.826966+00 admin Created by admin 2 CRMA f \. -- -- Name: comment_comment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('comment_comment_id_seq', 63, true); -- -- Data for Name: company; Type: TABLE DATA; Schema: public; Owner: admin -- COPY company (company_id, company_number, company_descrip, company_external, company_server, company_port, company_database, company_curr_id, company_yearend_accnt_id, company_gainloss_accnt_id, company_dscrp_accnt_id, company_unrlzgainloss_accnt_id, company_unassigned_accnt_id) FROM stdin; \. -- -- Name: company_company_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('company_company_id_seq', 1, true); -- -- Data for Name: contrct; Type: TABLE DATA; Schema: public; Owner: admin -- COPY contrct (contrct_id, contrct_number, contrct_vend_id, contrct_descrip, contrct_effective, contrct_expires, contrct_note) FROM stdin; \. -- -- Name: contrct_contrct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('contrct_contrct_id_seq', 1, false); -- -- Name: coship_coship_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('coship_coship_id_seq', 441, true); -- -- Name: cosmisc_cosmisc_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cosmisc_cosmisc_id_seq', 202, true); -- -- Name: cosrc_cosrc_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cosrc_cosrc_id_seq', 1, false); -- -- Data for Name: costcat; Type: TABLE DATA; Schema: public; Owner: admin -- COPY costcat (costcat_id, costcat_code, costcat_descrip, costcat_asset_accnt_id, costcat_liability_accnt_id, costcat_adjustment_accnt_id, costcat_matusage_accnt_id, costcat_purchprice_accnt_id, costcat_laboroverhead_accnt_id, costcat_scrap_accnt_id, costcat_invcost_accnt_id, costcat_wip_accnt_id, costcat_shipasset_accnt_id, costcat_mfgscrap_accnt_id, costcat_transform_accnt_id, costcat_freight_accnt_id, costcat_toliability_accnt_id, costcat_exp_accnt_id) FROM stdin; 30 CATEGORY1 Cost Category 1 86 95 91 88 135 94 92 133 85 96 93 89 98 \N 131 \. -- -- Name: costcat_costcat_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('costcat_costcat_id_seq', 30, true); -- -- Data for Name: costelem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY costelem (costelem_id, costelem_type, costelem_sys, costelem_po, costelem_active, costelem_exp_accnt_id, costelem_cost_item_id) FROM stdin; 3 Material t t t \N -1 4 Direct Labor t f t \N -1 6 Machine Overhead t f t \N -1 5 Overhead t f t \N -1 \. -- -- Name: costelem_costelem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('costelem_costelem_id_seq', 23, true); -- -- Data for Name: costhist; Type: TABLE DATA; Schema: public; Owner: admin -- COPY costhist (costhist_id, costhist_item_id, costhist_costelem_id, costhist_type, costhist_date, costhist_oldcost, costhist_newcost, costhist_lowlevel, costhist_oldcurr_id, costhist_newcurr_id, costhist_username) FROM stdin; 979 295 19 D 2004-03-19 20:23:23.224219+00 1.500000 0.000000 f 1 1 \N 980 296 20 D 2004-03-19 20:23:23.224219+00 0.300000 0.000000 f 1 1 \N 981 297 20 D 2004-03-19 20:23:23.224219+00 0.250000 0.000000 f 1 1 \N 982 294 20 D 2004-03-19 20:23:23.224219+00 0.100000 0.000000 f 1 1 \N 983 293 20 D 2004-03-19 20:23:23.224219+00 0.100000 0.000000 f 1 1 \N 984 298 4 D 2004-03-19 20:23:23.224219+00 0.333300 0.000000 f 1 1 \N 985 298 5 D 2004-03-19 20:23:23.224219+00 0.333300 0.000000 f 1 1 \N 986 298 20 D 2004-03-19 20:23:23.224219+00 0.550000 0.000000 t 1 1 \N 987 292 4 D 2004-03-19 20:23:23.224219+00 0.850000 0.000000 f 1 1 \N 988 292 5 D 2004-03-19 20:23:23.224219+00 0.850000 0.000000 f 1 1 \N 989 292 4 D 2004-03-19 20:23:23.224219+00 0.333300 0.000000 t 1 1 \N 990 292 19 D 2004-03-19 20:23:23.224219+00 0.015000 0.000000 t 1 1 \N 991 292 5 D 2004-03-19 20:23:23.224219+00 0.333300 0.000000 t 1 1 \N 992 292 20 D 2004-03-19 20:23:23.224219+00 1.050000 0.000000 t 1 1 \N \. -- -- Name: costhist_costhist_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('costhist_costhist_id_seq', 992, true); -- -- Data for Name: costupdate; Type: TABLE DATA; Schema: public; Owner: admin -- COPY costupdate (costupdate_item_id, costupdate_lowlevel_code, costupdate_item_type) FROM stdin; \. -- -- Data for Name: country; Type: TABLE DATA; Schema: public; Owner: admin -- COPY country (country_id, country_abbr, country_name, country_curr_abbr, country_curr_name, country_curr_number, country_curr_symbol, country_qt_number) FROM stdin; 214 \N \N XTS Code reserved for testing 963 \N \N 5 AD Andorra EUR Euro 978 € 5 228 AE United Arab Emirates AED UAE Dirham 784 \N 223 1 AF Afghanistan AFN Afghani 971 \N 1 9 AG Antigua And Barbuda XCD East Caribbean Dollar 951 $ 9 7 AI Anguilla XCD East Caribbean Dollar 951 $ 7 2 AL Albania ALL Lek 8 \N 2 11 AM Armenia AMD Armenian Dram 51 \N 11 154 AN Netherlands Antilles ANG Netherlands Antillian Guilder 532 ƒ 152 6 AO Angola AOA Kwanza 973 \N 6 8 AQ Antarctica \N \N \N \N 8 10 AR Argentina ARS Argentine Peso 32 $ 10 4 AS American Samoa USD US Dollar 840 $ 4 14 AT Austria EUR Euro 978 € 14 13 AU Australia AUD Australian Dollar 36 $ 13 12 AW Aruba AWG Aruban Guilder 533 ƒ 12 15 AZ Azerbaijan AZN Azerbaijanian Manat 944 \N 15 27 BA Bosnia And Herzegovina BAM Convertible Marks 977 \N 27 19 BB Barbados BBD Barbados Dollar 52 $ 19 18 BD Bangladesh BDT Taka 50 \N 18 21 BE Belgium EUR Euro 978 € 21 35 BF Burkina Faso XOF CFA Franc BCEAO 952 \N 34 34 BG Bulgaria BGN Bulgarian Lev 975 \N 33 17 BH Bahrain BHD Bahraini Dinar 48 \N 17 36 BI Burundi BIF Burundi Franc 108 \N 35 23 BJ Benin XOF CFA Franc BCEAO 952 \N 23 24 BM Bermuda BMD Bermudian Dollar 60 $ 24 33 BN Brunei Darussalam BND Brunei Dollar 96 $ 32 26 BO Bolivia BOB Boliviano 68 $ 26 30 BR Brazil BRL Brazilian Real 986 R$ 30 16 BS Bahamas BSD Bahamian Dollar 44 $ 16 25 BT Bhutan BTN Ngultrum 64 \N 25 29 BV Bouvet Island NOK Norwegian Krone 578 \N 29 28 BW Botswana BWP Pula 72 \N 28 20 BY Belarus BYR Belarussian Ruble 974 \N 20 22 BZ Belize BZD Belize Dollar 84 $ 22 39 CA Canada CAD Canadian Dollar 124 $ 38 47 CC Cocos (Keeling) Islands AUD Australian Dollar 36 $ 46 51 CD Congo, The Democratic Republic Of CDF Franc Congolais 976 \N 49 42 CF Central African Republic XAF CFA Franc BEAC 950 \N 41 50 CG Congo XAF CFA Franc BEAC 950 \N 50 209 CH Switzerland CHF Swiss Franc 756 \N 206 107 CI Ivory Coast XOF CFA Frank BCEA 952 \N 53 52 CK Cook Islands NZD New Zealand Dollar 554 $ 51 44 CL Chile CLP Chilean Peso 152 $ 43 38 CM Cameroon XAF CFA Franc BEAC 950 \N 37 45 CN China CNY Yuan Renminbi 156 \N 44 48 CO Colombia COP Colombian Peso 170 ₱ 47 53 CR Costa Rica CRC Costa Rican Colon 188 ₡ 52 55 CU Cuba CUP Cuban Peso 192 ₱ 55 40 CV Cape Verde CVE Cape Verde Escudo 132 \N 39 46 CX Christmas Island AUD Australian Dollar 36 $ 45 56 CY Cyprus CYP Cyprus Pound 196 £ 56 57 CZ Czech Republic CZK Czech Koruna 203 \N 57 81 DE Germany EUR Euro 978 € 82 59 DJ Djibouti DJF Djibouti Franc 262 \N 59 58 DK Denmark DKK Danish Krone 208 kr 58 60 DM Dominica XCD East Caribbean Dollar 951 $ 60 61 DO Dominican Republic DOP Dominican Peso 214 ₱ 61 3 DZ Algeria DZD Algerian Dinar 12 \N 3 63 EC Ecuador USD US Dollar 840 $ 63 68 EE Estonia EEK Kroon 233 \N 68 64 EG Egypt EGP Egyptian Pound 818 £ 64 239 EH Western Sahara MAD Moroccan Dirham 504 \N 236 67 ER Eritrea ERN Nakfa 232 \N 67 202 ES Spain EUR Euro 978 € 197 69 ET Ethiopia ETB Ethiopian Birr 230 \N 69 73 FI Finland EUR Euro 978 € 73 72 FJ Fiji FJD Fiji Dollar 242 $ 72 70 FK Falkland Islands (Malvinas) FKP Falkland Islands Pound 238 £ 70 141 FM Micronesia, Federated States Of USD US Dollar 840 $ 140 71 FO Faroe Islands DKK Danish Krone 208 \N 71 74 FR France EUR Euro 978 € 74 78 GA Gabon XAF CFA Franc BEAC 950 \N 79 86 GD Grenada XCD East Caribbean Dollar 951 $ 87 80 GE Georgia GEL Lari 981 \N 81 75 GF French Guiana EUR Euro 978 € 76 82 GH Ghana GHC Cedi 288 \N 83 83 GI Gibraltar GIP Gibraltar Pound 292 £ 84 85 GL Greenland DKK Danish Krone 208 \N 86 79 GM Gambia GMD Dalasi 270 \N 80 90 GN Guinea GNF Guinea Franc 324 \N 91 87 GP Guadeloupe EUR Euro 978 € 88 66 GQ Equatorial Guinea XAF CFA Franc BEAC 950 \N 66 84 GR Greece EUR Euro 978 € 85 201 GS South Georgia And The South Sandwich Islands GBP Pound Sterling 826 \N 196 89 GT Guatemala GTQ Quetzal 320 \N 90 88 GU Guam USD US Dollar 840 $ 89 91 GW Guinea-Bissau XOF CFA Franc BCEAO 952 \N 92 92 GY Guyana GYD Guyana Dollar 328 $ 93 97 HK Hong Kong HKD Hong Kong Dollar 344 $ 97 94 HM Heard Island And Mcdonald Islands AUD Australian Dollar 36 $ 95 96 HN Honduras HNL Lempira 340 \N 96 54 HR Croatia HRK Croatian Kuna 191 \N 54 93 HT Haiti HTG Gourde 332 \N 94 98 HU Hungary HUF Forint 348 \N 98 101 ID Indonesia IDR Indonesia Rupiah 360 \N 101 104 IE Ireland EUR Euro 978 € 104 105 IL Israel ILS New Israeli Sheqel 376 ₪ 105 100 IN India INR Indian Rupee 356 ₨ 100 31 IO British Indian Ocean Territory USD US Dollar 840 $ 31 103 IQ Iraq IQD Iraqi Dinar 368 \N 103 102 IR Iran IRR Iranian Rial 364 ﷼ 102 99 IS Iceland ISK Iceland Krona 352 \N 99 106 IT Italy EUR Euro 978 € 106 108 JM Jamaica JMD Jamaican Dollar 388 $ 107 110 JO Jordan JOD Jordanian Dinar 400 \N 109 109 JP Japan JPY Yen 392 ¥ 108 112 KE Kenya KES Kenyan Shilling 404 \N 111 117 KG Kyrgyzstan KGS Som 417 \N 116 37 KH Cambodia KHR Riel 116 ៛ 36 113 KI Kiribati AUD Australian Dollar 36 $ 112 49 KM Comoros KMF Comoro Franc 174 \N 48 183 KN Saint Kitts And Nevis XCD East Caribbean Dollar 951 $ 180 114 KP Korea, Democratic Peoples Republic Of KPW North Korean Won 408 ₩ 113 115 KR Korea, Republic Of KRW South Korean Won 410 ₩ 114 116 KW Kuwait KWD Kuwaiti Dinar 414 \N 115 41 KY Cayman Islands KYD Cayman Islands Dollar 136 $ 40 111 KZ Kazakhstan KZT Tenge 398 \N 110 118 LA Laos LAK Kip 418 ₭ 117 120 LB Lebanon LBP Lebanese Pound 422 £ 119 184 LC Saint Lucia XCD East Caribbean Dollar 951 $ 181 124 LI Liechtenstein CHF Swiss Franc 756 \N 123 203 LK Sri Lanka LKR Sri Lanka Rupee 144 ௹ 198 122 LR Liberia LRD Liberian Dollar 430 $ 121 121 LS Lesotho LSL Loti 426 \N 120 125 LT Lithuania LTL Lithuanian Litas 440 \N 124 126 LU Luxembourg EUR Euro 978 € 125 119 LV Latvia LVL Latvian Lats 428 \N 118 123 LY Libyan Arab Jamahiriya LYD Libyan Dinar 434 \N 122 147 MA Morocco MAD Moroccan Dirham 504 \N 145 143 MC Monaco EUR Euro 978 € 142 142 MD Moldova MDL Moldovan Leu 498 \N 141 145 ME Montenegro EUR Euro 978 € 241 129 MG Madagascar MGA Malagascy Ariary 969 \N 128 135 MH Marshall Islands USD US Dollar 840 $ 134 128 MK Macedonia, Former Yugoslav Republic Of MKD Denar 807 \N 127 133 ML Mali XOF CFA Franc BCEAO 952 \N 132 149 MM Myanmar MMK Kyat 104 \N 147 144 MN Mongolia MNT Tugrik 496 ₮ 143 127 MO Macao MOP Pataca 446 \N 126 162 MP Northern Mariana Islands USD US Dollar 840 $ 160 136 MQ Martinique EUR Euro 978 € 135 137 MR Mauritania MRO Ouguiya 478 \N 136 146 MS Montserrat XCD East Caribbean Dollar 951 $ 144 134 MT Malta MTL Maltese Lira 470 ₤ 133 138 MU Mauritius MUR Mauritius Rupee 480 ₨ 137 132 MV Maldives MVR Rufiyaa 462 \N 131 130 MW Malawi MWK Malawi Kwacha 454 \N 129 140 MX Mexico MXN Mexican Peso 484 $ 139 131 MY Malaysia MYR Malaysian Ringgit 458 \N 130 148 MZ Mozambique MZN Metical 943 \N 146 150 NA Namibia NAD Namibian Dollar 516 $ 148 155 NC New Caledonia XPF CFP Franc 953 \N 153 158 NE Niger XOF CFA Franc BCEAO 952 \N 156 161 NF Norfolk Island AUD Australian Dollar 36 $ 159 159 NG Nigeria NGN Naira 566 ₦ 157 157 NI Nicaragua NIO Cordoba Oro 558 \N 155 153 NL Netherlands EUR Euro 978 € 151 163 NO Norway NOK Norwegian Krone 578 \N 161 152 NP Nepal NPR Nepalese Rupee 524 ₨ 150 151 NR Nauru AUD Australian Dollar 36 $ 149 160 NU Niue NZD New Zealand Dollar 554 $ 158 156 NZ New Zealand NZD New Zealand Dollar 554 $ 154 164 OM Oman OMR Rial Omani 512 ﷼ 162 168 PA Panama PAB Balboa 590 \N 166 171 PE Peru PEN Nuevo Sol 604 S/. 169 76 PF French Polynesia XPF CFP Franc 953 \N 77 169 PG Papua New Guinea PGK Kina 598 \N 167 172 PH Philippines PHP Philippine Peso 608 ₱ 170 165 PK Pakistan PKR Pakistan Rupee 586 ₨ 163 174 PL Poland PLN Zloty 985 \N 172 185 PM Saint Pierre And Miquelon EUR Euro 978 € 200 173 PN Pitcairn NZD New Zealand Dollar 554 $ 171 176 PR Puerto Rico USD US Dollar 840 $ 174 167 PS Palestinian Territories \N \N \N \N 165 175 PT Portugal EUR Euro 978 € 173 166 PW Palau USD US Dollar 840 $ 164 170 PY Paraguay PYG Guarani 600 \N 168 177 QA Qatar QAR Qatari Rial 634 \N 175 178 RE Reunion EUR Euro 978 € 176 179 RO Romania RON New Leu 946 \N 177 192 RS Serbia RSD Serbian Dinar 941 \N 241 180 RU Russian Federation RUB Russian Ruble 643 \N 178 181 RW Rwanda RWF Rwanda Franc 646 \N 179 190 SA Saudi Arabia SAR Saudi Riyal 682 ﷼ 186 198 SB Solomon Islands SBD Solomon Islands Dollar 90 $ 193 193 SC Seychelles SCR Seychelles Rupee 690 ₨ 188 204 SD Sudan SDD Sudanese Dinar 736 \N 201 208 SE Sweden SEK Swedish Krona 752 kr 205 195 SG Singapore SGD Singapore Dollar 702 $ 190 182 SH Saint Helena SHP Saint Helena Pound 654 £ 199 197 SI Slovenia SIT Tolar 705 \N 192 206 SJ Svalbard And Jan Mayen NOK Norwegian Krone 578 \N 203 196 SK Slovakia SKK Slovak Koruna 703 \N 191 194 SL Sierra Leone SLL Leone 694 \N 189 188 SM San Marino EUR Euro 978 € 184 191 SN Senegal XOF CFA Franc BCEAO 952 \N 187 199 SO Somalia SOS Somali Shilling 706 \N 194 205 SR Suriname SRD Surinam Dollar 968 $ 202 189 ST Sao Tome And Principe STD Dobra 678 \N 185 65 SV El Salvador SVC El Salvador Colon 222 ₡ 65 210 SY Syria SYP Syrian Pound 760 £ 207 207 SZ Swaziland SZL Lilangeni 748 \N 204 224 TC Turks And Caicos Islands USD US Dollar 840 $ 219 43 TD Chad XAF CFA Franc BEAC 950 \N 42 77 TF French Southern Territories EUR Euro 978 € 78 217 TG Togo XOF CFA Franc BCEAO 952 \N 212 215 TH Thailand THB Baht 764 ฿ 211 212 TJ Tajikistan TJS Somoni 972 \N 209 218 TK Tokelau NZD New Zealand Dollar 554 $ 213 216 TL Timor-Leste USD US Dollar 840 $ 62 223 TM Turkmenistan TMM Turkmenistan Manat 795 \N 218 221 TN Tunisia TND Tunisian Dinar 788 \N 216 219 TO Tonga TOP Paanga 776 \N 214 62 TP East Timor IDR Indonesia Rupiah 360 \N 62 222 TR Turkey TRY New Turkish Lira 949 ₤ 217 220 TT Trinidad And Tobago TTD Trinidad and Tobago Dollar 780 $ 215 225 TV Tuvalu AUD Australian Dollar 36 $ 220 211 TW Taiwan TWD New Taiwan Dollar 901 $ 208 213 TZ Tanzania TZS Tanzanian Shilling 834 \N 210 227 UA Ukraine UAH Hryvnia 980 \N 222 226 UG Uganda UGX Uganda Shilling 800 \N 221 229 UK United Kingdom GBP Pound Sterling 826 £ 224 232 UM U.S. Minor Outlying Islands USD US Dollar 840 $ 226 230 US United States USD US Dollar 840 $ 225 231 UY Uruguay UYU Peso Uruguayo 858 ₱ 227 234 UZ Uzbekistan UZS Uzbekistan Sum 860 \N 228 95 VA Holy See (Vatican City State) EUR Euro 978 € 230 186 VC Saint Vincent And The Grenadines XCD East Caribbean Dollar 951 $ 182 236 VE Venezuela VEB Bolivar 862 \N 231 32 VG British Virgin Islands USD US Dollar 840 $ 233 233 VI U.S. Virgin Islands USD US Dollar 840 $ 234 237 VN Viet Nam VND Dong 704 ₫ 232 235 VU Vanuatu VUV Vatu 548 \N 229 238 WF Wallis And Futuna XPF CFP Franc 953 \N 235 187 WS Samoa WST Tala 882 \N 183 240 YE Yemen YER Yemeni Rial 886 ﷼ 237 139 YT Mayotte EUR Euro 978 € 138 200 ZA South Africa ZAR Rand 710 R 195 241 ZM Zambia ZMK Zambian Kwacha 894 \N 239 242 ZW Zimbabwe ZWD Zimbabwe Dollar 716 $ 240 \. -- -- Name: country_country_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('country_country_id_seq', 242, true); -- -- Data for Name: crmacct; Type: TABLE DATA; Schema: public; Owner: admin -- COPY crmacct (crmacct_id, crmacct_number, crmacct_name, crmacct_active, crmacct_type, crmacct_cust_id, crmacct_competitor_id, crmacct_partner_id, crmacct_prospect_id, crmacct_vend_id, crmacct_cntct_id_1, crmacct_cntct_id_2, crmacct_parent_id, crmacct_notes, crmacct_taxauth_id, crmacct_owner_username, crmacct_emp_id, crmacct_salesrep_id, crmacct_usr_username) FROM stdin; 2 10 Inside Sales t I \N \N \N \N \N \N \N \N \N \N \N \N 29 \N 4 MFGADMIN OpenMFG Administrator t I \N \N \N \N \N \N \N \N \N \N \N 1 \N mfgadmin 3 ADMIN Administrator t I \N \N \N \N \N \N \N \N \N \N admin 2 \N admin 1 SALES TAX State Sales Tax Authority t O \N \N \N \N 78 \N \N \N 1 admin \N \N \N \. -- -- Name: crmacct_crmacct_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('crmacct_crmacct_id_seq', 26, true); -- -- Data for Name: crmacctsel; Type: TABLE DATA; Schema: public; Owner: admin -- COPY crmacctsel (crmacctsel_src_crmacct_id, crmacctsel_dest_crmacct_id, crmacctsel_mrg_crmacct_active, crmacctsel_mrg_crmacct_cntct_id_1, crmacctsel_mrg_crmacct_cntct_id_2, crmacctsel_mrg_crmacct_competitor_id, crmacctsel_mrg_crmacct_cust_id, crmacctsel_mrg_crmacct_emp_id, crmacctsel_mrg_crmacct_name, crmacctsel_mrg_crmacct_notes, crmacctsel_mrg_crmacct_owner_username, crmacctsel_mrg_crmacct_parent_id, crmacctsel_mrg_crmacct_partner_id, crmacctsel_mrg_crmacct_prospect_id, crmacctsel_mrg_crmacct_salesrep_id, crmacctsel_mrg_crmacct_taxauth_id, crmacctsel_mrg_crmacct_type, crmacctsel_mrg_crmacct_usr_username, crmacctsel_mrg_crmacct_vend_id, crmacctsel_mrg_crmacct_number) FROM stdin; \. -- -- Data for Name: curr_rate; Type: TABLE DATA; Schema: public; Owner: admin -- COPY curr_rate (curr_rate_id, curr_id, curr_rate, curr_effective, curr_expires) FROM stdin; 1 1 1.00000000 1970-01-01 2100-01-01 \. -- -- Name: curr_rate_curr_rate_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('curr_rate_curr_rate_id_seq', 1, true); -- -- Data for Name: curr_symbol; Type: TABLE DATA; Schema: public; Owner: admin -- COPY curr_symbol (curr_id, curr_base, curr_name, curr_symbol, curr_abbr) FROM stdin; 1 f Base Currency - Change As Necessary $ USD \. -- -- Name: curr_symbol_curr_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('curr_symbol_curr_id_seq', 1, true); -- -- Name: cust_cust_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cust_cust_id_seq', 96, true); -- -- Name: cust_serial_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('cust_serial_seq', 1, false); -- -- Data for Name: custform; Type: TABLE DATA; Schema: public; Owner: admin -- COPY custform (custform_id, custform_custtype_id, custform_custtype, custform_invoice_report_id, custform_creditmemo_report_id, custform_quote_report_id, custform_packinglist_report_id, custform_statement_report_id, custform_sopicklist_report_id, custform_invoice_report_name, custform_creditmemo_report_name, custform_quote_report_name, custform_packinglist_report_name, custform_statement_report_name, custform_sopicklist_report_name) FROM stdin; 8 -1 .* 1 3 172 80 261 346 Invoice CreditMemo Quote PackingList Statement PickingListSOClosedLines \. -- -- Name: custform_custform_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('custform_custform_id_seq', 8, true); -- -- Data for Name: custgrp; Type: TABLE DATA; Schema: public; Owner: admin -- COPY custgrp (custgrp_id, custgrp_name, custgrp_descrip) FROM stdin; \. -- -- Name: custgrp_custgrp_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('custgrp_custgrp_id_seq', 24, true); -- -- Data for Name: custgrpitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY custgrpitem (custgrpitem_id, custgrpitem_custgrp_id, custgrpitem_cust_id) FROM stdin; \. -- -- Name: custgrpitem_custgrpitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('custgrpitem_custgrpitem_id_seq', 47, true); -- -- Data for Name: custinfo; Type: TABLE DATA; Schema: public; Owner: admin -- COPY custinfo (cust_id, cust_active, cust_custtype_id, cust_salesrep_id, cust_commprcnt, cust_name, cust_creditlmt, cust_creditrating, cust_financecharge, cust_backorder, cust_partialship, cust_terms_id, cust_discntprcnt, cust_balmethod, cust_ffshipto, cust_shipform_id, cust_shipvia, cust_blanketpos, cust_shipchrg_id, cust_creditstatus, cust_comments, cust_ffbillto, cust_usespos, cust_number, cust_dateadded, cust_exported, cust_emaildelivery, cust_ediemail, cust_edisubject, cust_edifilename, cust_ediemailbody, cust_autoupdatestatus, cust_autoholdorders, cust_edicc, cust_ediprofile_id, cust_preferred_warehous_id, cust_curr_id, cust_creditlmt_curr_id, cust_cntct_id, cust_corrcntct_id, cust_soemaildelivery, cust_soediemail, cust_soedisubject, cust_soedifilename, cust_soediemailbody, cust_soedicc, cust_soediprofile_id, cust_gracedays, cust_ediemailhtml, cust_soediemailhtml, cust_taxzone_id, cust_statementcycle) FROM stdin; \. -- -- Data for Name: custtype; Type: TABLE DATA; Schema: public; Owner: admin -- COPY custtype (custtype_id, custtype_code, custtype_descrip, custtype_char) FROM stdin; 18 NORMAL Normal Customer f \. -- -- Name: custtype_custtype_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('custtype_custtype_id_seq', 18, true); -- -- Data for Name: dept; Type: TABLE DATA; Schema: public; Owner: admin -- COPY dept (dept_id, dept_number, dept_name) FROM stdin; 1 MFG Manufacturing 2 ADM Administration \. -- -- Name: dept_dept_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('dept_dept_id_seq', 2, true); -- -- Data for Name: destination; Type: TABLE DATA; Schema: public; Owner: admin -- COPY destination (destination_id, destination_name, destination_city, destination_state, destination_comments) FROM stdin; \. -- -- Name: destination_destination_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('destination_destination_id_seq', 12, true); -- -- Data for Name: docass; Type: TABLE DATA; Schema: public; Owner: admin -- COPY docass (docass_id, docass_source_id, docass_source_type, docass_target_id, docass_target_type, docass_purpose) FROM stdin; \. -- -- Name: docass_docass_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('docass_docass_id_seq', 1, true); -- -- Data for Name: emp; Type: TABLE DATA; Schema: public; Owner: admin -- COPY emp (emp_id, emp_code, emp_number, emp_active, emp_cntct_id, emp_warehous_id, emp_mgr_emp_id, emp_wage_type, emp_wage, emp_wage_curr_id, emp_wage_period, emp_dept_id, emp_shift_id, emp_notes, emp_image_id, emp_username, emp_extrate, emp_extrate_period, emp_startdate, emp_name) FROM stdin; 2 ADMIN admin t \N \N \N H \N 1 H 2 1 \N \N admin \N H \N Administrator 1 MFGADMIN mfgadmin t \N \N \N H \N 1 H 2 1 \N \N mfgadmin \N H \N OpenMFG Administrator \. -- -- Name: emp_emp_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('emp_emp_id_seq', 2, true); -- -- Data for Name: empgrp; Type: TABLE DATA; Schema: public; Owner: admin -- COPY empgrp (empgrp_id, empgrp_name, empgrp_descrip) FROM stdin; \. -- -- Name: empgrp_empgrp_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('empgrp_empgrp_id_seq', 1, false); -- -- Data for Name: empgrpitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY empgrpitem (empgrpitem_id, empgrpitem_empgrp_id, empgrpitem_emp_id) FROM stdin; \. -- -- Name: empgrpitem_empgrpitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('empgrpitem_empgrpitem_id_seq', 1, false); -- -- Data for Name: evntlog; Type: TABLE DATA; Schema: public; Owner: admin -- COPY evntlog (evntlog_id, evntlog_evnttime, evntlog_evnttype_id, evntlog_ord_id, evntlog_dispatched, evntlog_action, evntlog_warehous_id, evntlog_number, evntlog_newvalue, evntlog_oldvalue, evntlog_newdate, evntlog_olddate, evntlog_ordtype, evntlog_username) FROM stdin; \. -- -- Name: evntlog_evntlog_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('evntlog_evntlog_id_seq', 262, true); -- -- Data for Name: evntnot; Type: TABLE DATA; Schema: public; Owner: admin -- COPY evntnot (evntnot_id, evntnot_evnttype_id, evntnot_warehous_id, evntnot_username) FROM stdin; 782 -1 35 mfgadmin 783 4 35 mfgadmin 784 15 35 mfgadmin 785 13 35 mfgadmin 786 11 35 mfgadmin 787 10 35 mfgadmin 788 12 35 mfgadmin 789 14 35 mfgadmin 790 5 35 mfgadmin 791 6 35 mfgadmin 792 7 35 mfgadmin 793 8 35 mfgadmin 795 3 35 mfgadmin 796 1 35 mfgadmin 798 2 35 mfgadmin 801 24 35 mfgadmin 802 22 35 mfgadmin 803 25 35 mfgadmin 804 23 35 mfgadmin 805 9 35 mfgadmin 806 26 35 mfgadmin 807 28 35 mfgadmin 808 27 35 mfgadmin 809 31 35 mfgadmin 810 32 35 mfgadmin 812 29 35 mfgadmin 813 30 35 mfgadmin 814 16 35 mfgadmin 815 17 35 mfgadmin 816 21 35 mfgadmin 817 18 35 mfgadmin 818 19 35 mfgadmin 819 20 35 mfgadmin \. -- -- Name: evntnot_evntnot_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('evntnot_evntnot_id_seq', 819, true); -- -- Data for Name: evnttype; Type: TABLE DATA; Schema: public; Owner: admin -- COPY evnttype (evnttype_id, evnttype_name, evnttype_descrip, evnttype_module) FROM stdin; 1 WoDueDateChanged Work Order Due Date Changed W/O 2 WoQtyChanged Work Order Qty. Changed W/O 3 WoCreated Work Order Created W/O 4 QOHBelowZero QOH Dropped to a Negative Value I/M 5 RWoDueDateRequestChange Request to Change Released Due Date W/O 6 RWoQtyRequestChange Request to Change Released W/O Qty. W/O 7 RWoRequestCancel Request to Cancel Released W/O W/O 8 WoCancelled Work Order Canceled W/O 9 CannotDistributeTransToGL Cannot Distribute an Inventory Transaction to the G/L G/L 10 SoitemQtyChanged Sales Order Qty. Changed S/O 11 SoitemCreated Sales Order Item Added S/O 12 SoitemSchedDateChanged Sales Order Item Ship Date Changed S/O 13 SoitemCancelled Sales Order Item Cancelled S/O 14 SoReleased Sales Order Released S/O 16 CannotConvertQuote Cannot Convert a Quote to a Sales Order S/O 17 DetachCCPayFromSO Detached Credit Card payment from S/O S/O 18 WODoubleClockIn User clocked in to a Work Order without having previously clocked out W/O 19 WODoubleClockOut User clocked out of a Work Order without having previously clocked in W/O 20 WOClockInOnClosedJob User clocked in to a closed Work Order W/O 21 WOClockOutWNoClockIn User clocked out of a Work Order on which s/he was not clocked in W/O 22 NewIncident New Incident Created CRM 23 UpdatedIncident Incident Modified CRM 24 ClosedIncident Incident Closed CRM 25 ReopenedIncident Incident Which had been closed previously is being reopened CRM 27 ToitemCreated Transfer Order Item Created I/M 29 ToitemQtyChanged Transfer Order Item Qty. Changed I/M 30 ToitemSchedDateChanged Transfer Order Item Ship Date Changed I/M 31 ToitemNoDestItemSite Transfer Order Item created without an Item Site at the Destination Warehouse. I/M 32 ToitemNoTransitItemSite Transfer Order Item created without an Item Site at the Transit Warehouse. I/M 28 ToitemCancelled Transfer Order Item Cancelled I/M 15 SoNotesChanged Sales Order Order Comments Changed S/O 33 POitemCreate Purchase Order Purchased Item Line Added P/O 34 TodoAlarm To-Do Item Alarm CRM 35 IncidentAlarm Incident Alarm CRM 36 TaskAlarm Project Task Alarm CRM 37 CostExceedsMaxDesired Cost Exceeds Max Desired P/D 38 PoItemCreatedBySo Purchase Order Item Created by a Sales Order P/O 39 PoItemUpdatedBySo Purchase Order Item Updated by a Sales Order P/O 40 PoItemSoCancelled The Sales Order item has been cancelled for a linked Purchase Item P/O 41 PoItemDropShipped A Purchase Order Item has been Drop Shipped P/O 42 CashReceiptPosted A Cash Receipt has been posted G/L 45 NewCustomer A new Customer has been created S/O \. -- -- Name: evnttype_evnttype_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('evnttype_evnttype_id_seq', 45, true); -- -- Data for Name: expcat; Type: TABLE DATA; Schema: public; Owner: admin -- COPY expcat (expcat_id, expcat_code, expcat_descrip, expcat_exp_accnt_id, expcat_liability_accnt_id, expcat_active, expcat_purchprice_accnt_id, expcat_freight_accnt_id) FROM stdin; 16 SALES_TAX Sales Tax (Clear Liability) 102 95 t 126 98 19 FREIGHT_OUTBOUND Outbound Freight Expense 128 95 t 126 98 15 SUPPLIES_OFFICE Office Supplies 97 95 t 126 98 17 FREIGHT_INBOUND Inbound Freight Expense 120 95 t 126 98 18 SUPPLIES_SHOP Shop Supplies 97 95 t 126 98 \. -- -- Name: expcat_expcat_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('expcat_expcat_id_seq', 19, true); -- -- Data for Name: file; Type: TABLE DATA; Schema: public; Owner: admin -- COPY file (file_id, file_title, file_stream, file_descrip) FROM stdin; \. -- -- Name: file_file_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('file_file_id_seq', 1, false); -- -- Data for Name: filter; Type: TABLE DATA; Schema: public; Owner: admin -- COPY filter (filter_id, filter_screen, filter_value, filter_username, filter_name, filter_selected) FROM stdin; \. -- -- Name: filter_filter_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('filter_filter_id_seq', 1, false); -- -- Data for Name: fincharg; Type: TABLE DATA; Schema: public; Owner: admin -- COPY fincharg (fincharg_id, fincharg_mincharg, fincharg_graceperiod, fincharg_assessoverdue, fincharg_calcfrom, fincharg_markoninvoice, fincharg_air, fincharg_accnt_id, fincharg_salescat_id, fincharg_lastfc_statementcyclefrom, fincharg_lastfc_custidfrom, fincharg_lastfc_custidto, fincharg_lastfc_statementcycleto) FROM stdin; \. -- -- Name: fincharg_fincharg_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('fincharg_fincharg_id_seq', 1, false); -- -- Data for Name: flcol; Type: TABLE DATA; Schema: public; Owner: admin -- COPY flcol (flcol_id, flcol_flhead_id, flcol_name, flcol_descrip, flcol_report_id, flcol_month, flcol_quarter, flcol_year, flcol_showdb, flcol_prcnt, flcol_priortype, flcol_priormonth, flcol_priorquarter, flcol_prioryear, flcol_priorprcnt, flcol_priordiff, flcol_priordiffprcnt, flcol_budget, flcol_budgetprcnt, flcol_budgetdiff, flcol_budgetdiffprcnt) FROM stdin; 1 14 Current Current Month 331 t f f f t P f f N f f f f f f f 2 14 Current, Budget Current to Budget 332 t f f f f P f f N f f f t f t t 3 14 Current, Prior Month Current to Prior Month End 333 t f f f f P t f N f t t f f f f 4 14 Current, Prior Quarter Current to Prior Quarter End 342 t f f f f P f t N f t t f f f f 5 14 Current, Prior Year Current to Prior Year End 334 t f f f f P f f F f t t f f f f 6 14 Current, Year Ago Current to Month Prior Year 333 t f f f f Y t f N f t t f f f f 7 15 Month Current Month 331 t f f f t P f f N f f f f f f f 8 15 Month, Budget Current Month to Budget 332 t f f f f P f f N f f f t f t t 9 15 Month, Prior Month Current Month to Prior Month 333 t f f f f P t f N f t t f f f f 10 15 Month, YTD Month and Year to Date 330 t f t f t P f f N f f f f f f f 11 15 Month, QTD Month and Quarter to Date 335 t t f f t P f f N f f f f f f f 12 15 QTD, Budget Quarter to Date to Budget 337 f t f f f P f f N f f f t f t t 13 15 QTD, Prior Quarter Quarter to Date to Prior Quarter 338 f t f f f P f t N f t t f f f f 14 15 YTD Year To Date 339 f f t f t P f f N f f f f f f f 15 15 YTD, Budget Year to Date to Budget 340 f f t f f P f f N f f f t f t t 16 15 YTD, Prior Full Year Year to Date to Prior Full Year 341 f f t f f P f f F f t t f f f f 17 15 Month, Prior Year Month Current Month to Same Month Prior Year 333 t f f f f Y t f N f t t f f f f 19 15 YTD, Prior Year YTD Year to Date to Year to Date Prior Year 341 f f t f f P f f D f t t f f f f 20 15 QTD Quarter to Date 336 f t f f t P f f N f f f f f f f 18 15 QTD, Prior Year Quarter Quarter to Date to Same Quarter Prior Year 338 f t f f f Y f t N f t t f f f f 21 16 Current Current Period 331 t f f f t P f f N f f f f f f f 22 16 Current Period, YTD Current Period, YTD 330 t f t f f Y f f N f f f f f f f 23 16 Current, Prior Period Current, Prior Period 333 t f f f t P t f N f f f f f f f 24 16 Current Quarter, Prior Year Quarter Current Quarter, Prior Year Quarter 338 f t f f f Y f t N f f f f f f f \. -- -- Name: flcol_flcol_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('flcol_flcol_id_seq', 24, true); -- -- Data for Name: flgrp; Type: TABLE DATA; Schema: public; Owner: admin -- COPY flgrp (flgrp_id, flgrp_flhead_id, flgrp_flgrp_id, flgrp_order, flgrp_name, flgrp_descrip, flgrp_subtotal, flgrp_summarize, flgrp_subtract, flgrp_showstart, flgrp_showend, flgrp_showdelta, flgrp_showbudget, flgrp_showstartprcnt, flgrp_showendprcnt, flgrp_showdeltaprcnt, flgrp_showbudgetprcnt, flgrp_prcnt_flgrp_id, flgrp_showdiff, flgrp_showdiffprcnt, flgrp_showcustom, flgrp_showcustomprcnt, flgrp_usealtsubtotal, flgrp_altsubtotal) FROM stdin; 87 14 -1 1 ASSETS ASSETS t f f f t f t f f f f -1 f f f f t Total Assets 88 14 -1 2 LIABILITIES AND OWNERS EQUITY LIABILITIES AND OWNERS EQUITY t f t f t f t f f f f -1 f f f f t Total Liabilities and Owners Equity 89 14 88 1 LIABILITIES LIABILITIES t f f f t f t f t f t -1 f f f f t Total Liabilities 90 14 88 2 OWNERS EQUITY OWNERS EQUITY t f f f t f t f t f t -1 f f f f t Total Owners Equity 91 14 90 2 Net Income f t f f t f t f t f t -1 f f f f f 92 15 -1 1 INCOME INCOME t f f f f f t f f f f -1 t f f f t Net Income 93 15 92 2 REVENUE REVENUE t f f f f f t f f f f -1 t f f f t Total Net Revenue 94 15 92 3 EXPENSES EXPENSES t f t f f f t f f f f -1 t f f f t Total Net Expenses 96 16 -1 2 CASH POSITION CASH POSITION t f t f f t t f f t t -1 t t f f t TOTAL CASH POSITION 98 16 95 2 Cash Flow From Investing Activities Cash Flow From Investing Activities t f t f f t t f f t t -1 t t f f t Total Cash Flow From Investing Activities 99 16 95 3 Cash Flow from Financing Activities Cash Flow from Financing Activities t f f f f t t f f t t -1 t t f f t Total Cash Flow from Financing Activities 105 16 97 6 Change in Current Liability Change in Current Liability t f f f f t t f f t t -1 t t f f t Total Change in Current Liability 106 16 97 7 Accounts Payable Accounts Payable t f f f f t t f f t t -1 t t f f t Total Accounts Payable 107 16 98 1 Property Plant and Equipment Property Plant and Equipment t f f f f t t f f t t -1 t t f f t Total Property Plant and Equipment 108 16 98 2 Other Assets Other Assets t f f f f t t f f t t -1 t t f f t Total Other Assets 109 16 99 1 Long Term Debt Long Term Debt t f f f f t t f f t t -1 t t f f t Total Long Term Debt 110 16 99 2 Common Stock and Equity t f f f f t t f f t t -1 t t f f t Total Common Stock and Equity 97 16 95 1 Cash Flow From Operating Activities Cash Flow From Operating Activities t f f f f t t f f t t -1 t t f f t Total Cash Flow From Operating Activities 95 16 -1 1 STATEMENT OF CASH FLOWS STATEMENT OF CASH FLOWS t f f f f t t f f t t -1 t t f f t TOTAL STATEMENT OF CASH FLOWS 111 16 100 1 Net Income Net Income t t f f f t t f f t t -1 t t f f f 100 16 97 1 Cash Flow From Operating Activities Cash Flow From Operating Activities t f f f f t t f f t t -1 t t f f t Total Cash Flow From Operating Activities 101 16 97 2 Charges Not Using Cash Charges Not Using Cash t f f f f t t f f t t -1 t t f f t Total Charges Not Using Cash 102 16 97 3 Changes in Current Assets Changes in Current Assets t f t f f t t f f t t -1 t t f f t Total Changes in Current Assets 103 16 97 4 Net Receivables Net Receivables t f t f f t t f f t t -1 t t f f t Total Net Receivables 104 16 97 5 Inventory Inventory t f t f f t t f f t t -1 t t f f t Total Inventory \. -- -- Name: flgrp_flgrp_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('flgrp_flgrp_id_seq', 111, true); -- -- Data for Name: flhead; Type: TABLE DATA; Schema: public; Owner: admin -- COPY flhead (flhead_id, flhead_name, flhead_descrip, flhead_showtotal, flhead_showstart, flhead_showend, flhead_showdelta, flhead_showbudget, flhead_showdiff, flhead_showcustom, flhead_custom_label, flhead_usealttotal, flhead_alttotal, flhead_usealtbegin, flhead_altbegin, flhead_usealtend, flhead_altend, flhead_usealtdebits, flhead_altdebits, flhead_usealtcredits, flhead_altcredits, flhead_usealtbudget, flhead_altbudget, flhead_usealtdiff, flhead_altdiff, flhead_type, flhead_active, flhead_sys, flhead_notes) FROM stdin; 14 Basic Balance Sheet Balance Sheet Template f f f f f f f \N f \N f \N f \N f \N f \N f \N f \N B t t 15 Basic Income Statement Income Statement Template f f f f f f f f f f f f f f I t t 16 Basic Statement of Cash Flows Basic Statement of Cash Flows t f f t t t f t CHECKSUM (TOTAL STA. OF CASH FLOWS - TOTAL CASH) f f f f f f C t t \. -- -- Name: flhead_flhead_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('flhead_flhead_id_seq', 16, true); -- -- Data for Name: flitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY flitem (flitem_id, flitem_flhead_id, flitem_flgrp_id, flitem_order, flitem_accnt_id, flitem_showstart, flitem_showend, flitem_showdelta, flitem_showbudget, flitem_subtract, flitem_showstartprcnt, flitem_showendprcnt, flitem_showdeltaprcnt, flitem_showbudgetprcnt, flitem_prcnt_flgrp_id, flitem_showdiff, flitem_showdiffprcnt, flitem_showcustom, flitem_showcustomprcnt, flitem_custom_source, flitem_company, flitem_profit, flitem_number, flitem_sub, flitem_type, flitem_subaccnttype_code) FROM stdin; 237 14 87 1 -1 f t f t f f t f t -1 t f f f S All All All All A All 238 14 89 1 -1 f t f t f f t f t -1 t f f f S All All All All L All 239 14 90 1 -1 f t f t f f t f t -1 t f f f S All All All All Q All 240 14 91 1 -1 f t f t f f f f f -1 t f f f S All All All All R All 241 14 91 2 -1 f t f t t f f f f -1 t f f f S All All All All E All 242 15 93 1 -1 f f f t f f f f t -1 t t f f S All All All All R All 243 15 94 1 -1 f f f t f f f f t -1 t t f f S All All All All E All 245 16 111 2 -1 f f t t t f f t t -1 t t f f S All All All All E All 244 16 111 1 -1 f f t t f f f t t -1 t t f f S All All All All R All 246 16 101 1 -1 f f t t f f f t t -1 t t f f S All All All All E DEP 247 16 102 1 -1 f f t t f f f t t -1 t t f f S All All All All A CAS 248 16 103 1 -1 f f t t f f f t t -1 t t f f S All All All All A AR 249 16 104 1 -1 f f t t f f f t t -1 t t f f S All All All All A IN 250 16 105 1 -1 f f t t f f f t t -1 t t f f S All All All All L CL 251 16 106 1 -1 f f t t f f f t t -1 t t f f S All All All All L AP 252 16 107 1 -1 f f t t f f f t t -1 t t f f S All All All All A FA 253 16 109 1 -1 f f t t f f f t t -1 t t f f S All All All All L LTL 254 16 110 1 -1 f f t t f f f t t -1 t t f f S All All All All Q All 255 16 96 1 -1 f f t t f f f t t -1 t t f f S All All All All A CA \. -- -- Name: flitem_flitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('flitem_flitem_id_seq', 255, true); -- -- Data for Name: flnotes; Type: TABLE DATA; Schema: public; Owner: admin -- COPY flnotes (flnotes_id, flnotes_flhead_id, flnotes_period_id, flnotes_notes) FROM stdin; \. -- -- Name: flnotes_flnotes_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('flnotes_flnotes_id_seq', 1, false); -- -- Data for Name: flrpt; Type: TABLE DATA; Schema: public; Owner: admin -- COPY flrpt (flrpt_flhead_id, flrpt_period_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_beginning, flrpt_ending, flrpt_debits, flrpt_credits, flrpt_budget, flrpt_beginningprcnt, flrpt_endingprcnt, flrpt_debitsprcnt, flrpt_creditsprcnt, flrpt_budgetprcnt, flrpt_parent_id, flrpt_diff, flrpt_diffprcnt, flrpt_custom, flrpt_customprcnt, flrpt_altname, flrpt_accnt_id, flrpt_interval, flrpt_id) FROM stdin; 7 32 jsmith 4 2 I 12 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 1 7 32 jsmith 2 0 G 12 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 2 7 32 jsmith 3 1 G 13 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 \N \N \N \N \N \N \N 3 7 32 jsmith 5 2 I 13 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 4 7 32 jsmith 6 2 I 14 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 5 7 32 jsmith 7 2 I 15 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 6 7 32 jsmith 8 2 I 16 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 7 7 32 jsmith 9 2 I 17 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 8 7 32 jsmith 10 2 I 18 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 9 7 32 jsmith 11 2 I 19 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 10 7 32 jsmith 12 2 I 20 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 11 7 32 jsmith 13 2 I 21 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 12 7 32 jsmith 14 2 I 22 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 13 7 32 jsmith 16 1 G 14 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 \N \N \N \N \N \N \N 14 7 32 jsmith 17 2 I 23 \N 0.00 \N \N 0.00 \N \N \N \N \N 14 \N \N \N \N \N \N \N 15 7 32 jsmith 19 1 G 15 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 \N \N \N \N \N \N \N 16 7 32 jsmith 22 0 G 16 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 17 7 32 jsmith 23 1 G 17 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 16 \N \N \N \N \N \N \N 18 7 32 jsmith 24 2 G 18 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 \N \N \N \N \N \N \N 19 7 32 jsmith 25 3 I 24 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 20 7 32 jsmith 26 3 I 25 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 21 7 32 jsmith 27 3 I 26 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 22 7 32 jsmith 28 3 I 27 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 23 7 32 jsmith 29 3 I 28 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 24 7 32 jsmith 30 3 I 29 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 25 7 32 jsmith 32 2 G 20 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 \N \N \N \N \N \N \N 26 7 32 jsmith 35 1 G 21 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 16 \N \N \N \N \N \N \N 27 7 32 jsmith 36 2 G 22 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 21 \N \N \N \N \N \N \N 28 7 32 jsmith 37 3 I 30 \N 0.00 \N \N 0.00 \N \N \N \N \N 22 \N \N \N \N \N \N \N 29 7 32 jsmith 39 2 G 23 \N 0.00 \N \N 0.00 \N \N \N \N \N 21 \N \N \N \N \N \N \N 30 7 32 jsmith 40 2 G 24 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 21 \N \N \N \N \N \N \N 31 7 32 jsmith 41 3 I 31 \N 0.00 \N \N 0.00 \N \N \N \N \N 24 \N \N \N \N \N \N \N 32 7 32 jsmith 42 3 I 45 \N 0.00 \N \N 0.00 \N \N \N \N \N 24 \N \N \N \N \N \N \N 33 7 32 jsmith 21 1 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 12 \N \N \N \N \N \N \N 34 7 32 jsmith 15 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 35 7 32 jsmith 18 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 14 \N \N \N \N \N \N \N 36 7 32 jsmith 20 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 15 \N \N \N \N \N \N \N 37 7 32 jsmith 45 1 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 16 \N \N \N \N \N \N \N 38 7 32 jsmith 34 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 17 \N \N \N \N \N \N \N 39 7 32 jsmith 31 3 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 40 7 32 jsmith 33 3 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 20 \N \N \N \N \N \N \N 41 7 32 jsmith 44 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 21 \N \N \N \N \N \N \N 42 7 32 jsmith 38 3 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 22 \N \N \N \N \N \N \N 43 7 32 jsmith 43 3 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 24 \N \N \N \N \N \N \N 44 7 33 jsmith 2 0 G 12 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 45 7 33 jsmith 3 1 G 13 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 \N \N \N \N \N \N \N 46 7 33 jsmith 4 2 I 12 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 47 7 33 jsmith 5 2 I 13 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 48 7 33 jsmith 6 2 I 14 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 49 7 33 jsmith 7 2 I 15 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 50 7 33 jsmith 8 2 I 16 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 51 7 33 jsmith 9 2 I 17 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 52 7 33 jsmith 10 2 I 18 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 53 7 33 jsmith 11 2 I 19 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 54 7 33 jsmith 12 2 I 20 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 55 7 33 jsmith 13 2 I 21 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 56 7 33 jsmith 14 2 I 22 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 57 7 33 jsmith 16 1 G 14 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 \N \N \N \N \N \N \N 58 7 33 jsmith 17 2 I 23 \N 0.00 \N \N 0.00 \N \N \N \N \N 14 \N \N \N \N \N \N \N 59 7 33 jsmith 19 1 G 15 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 \N \N \N \N \N \N \N 60 7 33 jsmith 22 0 G 16 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 61 7 33 jsmith 23 1 G 17 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 16 \N \N \N \N \N \N \N 62 7 33 jsmith 24 2 G 18 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 \N \N \N \N \N \N \N 63 7 33 jsmith 25 3 I 24 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 64 7 33 jsmith 26 3 I 25 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 65 7 33 jsmith 27 3 I 26 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 66 7 33 jsmith 28 3 I 27 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 67 7 33 jsmith 29 3 I 28 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 68 7 33 jsmith 30 3 I 29 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 69 7 33 jsmith 32 2 G 20 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 \N \N \N \N \N \N \N 70 7 33 jsmith 35 1 G 21 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 16 \N \N \N \N \N \N \N 71 7 33 jsmith 36 2 G 22 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 21 \N \N \N \N \N \N \N 72 7 33 jsmith 37 3 I 30 \N 0.00 \N \N 0.00 \N \N \N \N \N 22 \N \N \N \N \N \N \N 73 7 33 jsmith 39 2 G 23 \N 0.00 \N \N 0.00 \N \N \N \N \N 21 \N \N \N \N \N \N \N 74 7 33 jsmith 40 2 G 24 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 21 \N \N \N \N \N \N \N 75 7 33 jsmith 41 3 I 31 \N 0.00 \N \N 0.00 \N \N \N \N \N 24 \N \N \N \N \N \N \N 76 7 33 jsmith 42 3 I 45 \N 0.00 \N \N 0.00 \N \N \N \N \N 24 \N \N \N \N \N \N \N 77 7 33 jsmith 21 1 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 12 \N \N \N \N \N \N \N 78 7 33 jsmith 15 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 79 7 33 jsmith 18 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 14 \N \N \N \N \N \N \N 80 7 33 jsmith 20 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 15 \N \N \N \N \N \N \N 81 7 33 jsmith 45 1 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 16 \N \N \N \N \N \N \N 82 7 33 jsmith 34 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 17 \N \N \N \N \N \N \N 83 7 33 jsmith 31 3 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 84 7 33 jsmith 33 3 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 20 \N \N \N \N \N \N \N 85 7 33 jsmith 44 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 21 \N \N \N \N \N \N \N 86 7 33 jsmith 38 3 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 22 \N \N \N \N \N \N \N 87 7 33 jsmith 43 3 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 24 \N \N \N \N \N \N \N 88 7 34 jsmith 2 0 G 12 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 89 7 34 jsmith 3 1 G 13 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 \N \N \N \N \N \N \N 90 7 34 jsmith 4 2 I 12 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 91 7 34 jsmith 5 2 I 13 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 92 7 34 jsmith 6 2 I 14 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 93 7 34 jsmith 7 2 I 15 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 94 7 34 jsmith 8 2 I 16 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 95 7 34 jsmith 9 2 I 17 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 96 7 34 jsmith 10 2 I 18 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 97 7 34 jsmith 11 2 I 19 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 98 7 34 jsmith 12 2 I 20 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 99 7 34 jsmith 13 2 I 21 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 100 7 34 jsmith 14 2 I 22 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 101 7 34 jsmith 16 1 G 14 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 \N \N \N \N \N \N \N 102 7 34 jsmith 17 2 I 23 \N 0.00 \N \N 0.00 \N \N \N \N \N 14 \N \N \N \N \N \N \N 103 7 34 jsmith 19 1 G 15 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 \N \N \N \N \N \N \N 104 7 34 jsmith 22 0 G 16 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 105 7 34 jsmith 23 1 G 17 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 16 \N \N \N \N \N \N \N 106 7 34 jsmith 24 2 G 18 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 \N \N \N \N \N \N \N 107 7 34 jsmith 25 3 I 24 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 108 7 34 jsmith 26 3 I 25 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 109 7 34 jsmith 27 3 I 26 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 110 7 34 jsmith 28 3 I 27 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 111 7 34 jsmith 29 3 I 28 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 112 7 34 jsmith 30 3 I 29 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 113 7 34 jsmith 32 2 G 20 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 \N \N \N \N \N \N \N 114 7 34 jsmith 35 1 G 21 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 16 \N \N \N \N \N \N \N 115 7 34 jsmith 36 2 G 22 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 21 \N \N \N \N \N \N \N 116 7 34 jsmith 37 3 I 30 \N 0.00 \N \N 0.00 \N \N \N \N \N 22 \N \N \N \N \N \N \N 117 7 34 jsmith 39 2 G 23 \N 0.00 \N \N 0.00 \N \N \N \N \N 21 \N \N \N \N \N \N \N 118 7 34 jsmith 40 2 G 24 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 21 \N \N \N \N \N \N \N 119 7 34 jsmith 41 3 I 31 \N 0.00 \N \N 0.00 \N \N \N \N \N 24 \N \N \N \N \N \N \N 120 7 34 jsmith 42 3 I 45 \N 0.00 \N \N 0.00 \N \N \N \N \N 24 \N \N \N \N \N \N \N 121 7 34 jsmith 21 1 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 12 \N \N \N \N \N \N \N 122 7 34 jsmith 15 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 123 7 34 jsmith 18 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 14 \N \N \N \N \N \N \N 124 7 34 jsmith 20 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 15 \N \N \N \N \N \N \N 125 7 34 jsmith 45 1 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 16 \N \N \N \N \N \N \N 126 7 34 jsmith 34 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 17 \N \N \N \N \N \N \N 127 7 34 jsmith 31 3 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 128 7 34 jsmith 33 3 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 20 \N \N \N \N \N \N \N 129 7 34 jsmith 44 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 21 \N \N \N \N \N \N \N 130 7 34 jsmith 38 3 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 22 \N \N \N \N \N \N \N 131 7 34 jsmith 43 3 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 24 \N \N \N \N \N \N \N 132 7 35 jsmith 2 0 G 12 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 133 7 35 jsmith 3 1 G 13 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 \N \N \N \N \N \N \N 134 7 35 jsmith 4 2 I 12 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 135 7 35 jsmith 5 2 I 13 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 136 7 35 jsmith 6 2 I 14 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 137 7 35 jsmith 7 2 I 15 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 138 7 35 jsmith 8 2 I 16 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 139 7 35 jsmith 9 2 I 17 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 140 7 35 jsmith 10 2 I 18 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 141 7 35 jsmith 11 2 I 19 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 142 7 35 jsmith 12 2 I 20 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 143 7 35 jsmith 13 2 I 21 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 144 7 35 jsmith 14 2 I 22 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 145 7 35 jsmith 16 1 G 14 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 \N \N \N \N \N \N \N 146 7 35 jsmith 17 2 I 23 \N 0.00 \N \N 0.00 \N \N \N \N \N 14 \N \N \N \N \N \N \N 147 7 35 jsmith 19 1 G 15 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 \N \N \N \N \N \N \N 148 7 35 jsmith 22 0 G 16 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 149 7 35 jsmith 23 1 G 17 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 16 \N \N \N \N \N \N \N 150 7 35 jsmith 24 2 G 18 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 \N \N \N \N \N \N \N 151 7 35 jsmith 25 3 I 24 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 152 7 35 jsmith 26 3 I 25 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 153 7 35 jsmith 27 3 I 26 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 154 7 35 jsmith 28 3 I 27 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 155 7 35 jsmith 29 3 I 28 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 156 7 35 jsmith 30 3 I 29 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 157 7 35 jsmith 32 2 G 20 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 \N \N \N \N \N \N \N 158 7 35 jsmith 35 1 G 21 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 16 \N \N \N \N \N \N \N 159 7 35 jsmith 36 2 G 22 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 21 \N \N \N \N \N \N \N 160 7 35 jsmith 37 3 I 30 \N 0.00 \N \N 0.00 \N \N \N \N \N 22 \N \N \N \N \N \N \N 161 7 35 jsmith 39 2 G 23 \N 0.00 \N \N 0.00 \N \N \N \N \N 21 \N \N \N \N \N \N \N 162 7 35 jsmith 40 2 G 24 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 21 \N \N \N \N \N \N \N 163 7 35 jsmith 41 3 I 31 \N 0.00 \N \N 0.00 \N \N \N \N \N 24 \N \N \N \N \N \N \N 164 7 35 jsmith 42 3 I 45 \N 0.00 \N \N 0.00 \N \N \N \N \N 24 \N \N \N \N \N \N \N 165 7 35 jsmith 21 1 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 12 \N \N \N \N \N \N \N 166 7 35 jsmith 15 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 167 7 35 jsmith 18 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 14 \N \N \N \N \N \N \N 168 7 35 jsmith 20 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 15 \N \N \N \N \N \N \N 169 7 35 jsmith 45 1 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 16 \N \N \N \N \N \N \N 170 7 35 jsmith 34 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 17 \N \N \N \N \N \N \N 171 7 35 jsmith 31 3 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 172 7 35 jsmith 33 3 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 20 \N \N \N \N \N \N \N 173 7 35 jsmith 44 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 21 \N \N \N \N \N \N \N 174 7 35 jsmith 38 3 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 22 \N \N \N \N \N \N \N 175 7 35 jsmith 43 3 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 24 \N \N \N \N \N \N \N 176 7 36 jsmith 2 0 G 12 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 177 7 36 jsmith 3 1 G 13 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 \N \N \N \N \N \N \N 178 7 36 jsmith 4 2 I 12 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 179 7 36 jsmith 5 2 I 13 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 180 7 36 jsmith 6 2 I 14 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 181 7 36 jsmith 7 2 I 15 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 182 7 36 jsmith 8 2 I 16 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 183 7 36 jsmith 9 2 I 17 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 184 7 36 jsmith 10 2 I 18 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 185 7 36 jsmith 11 2 I 19 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 186 7 36 jsmith 12 2 I 20 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 187 7 36 jsmith 13 2 I 21 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 188 7 36 jsmith 14 2 I 22 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 189 7 36 jsmith 16 1 G 14 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 \N \N \N \N \N \N \N 190 7 36 jsmith 17 2 I 23 \N 0.00 \N \N 0.00 \N \N \N \N \N 14 \N \N \N \N \N \N \N 191 7 36 jsmith 19 1 G 15 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 \N \N \N \N \N \N \N 192 7 36 jsmith 22 0 G 16 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 193 7 36 jsmith 23 1 G 17 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 16 \N \N \N \N \N \N \N 194 7 36 jsmith 24 2 G 18 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 \N \N \N \N \N \N \N 195 7 36 jsmith 25 3 I 24 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 196 7 36 jsmith 26 3 I 25 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 197 7 36 jsmith 27 3 I 26 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 198 7 36 jsmith 28 3 I 27 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 199 7 36 jsmith 29 3 I 28 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 200 7 36 jsmith 30 3 I 29 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 201 7 36 jsmith 32 2 G 20 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 \N \N \N \N \N \N \N 202 7 36 jsmith 35 1 G 21 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 16 \N \N \N \N \N \N \N 203 7 36 jsmith 36 2 G 22 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 21 \N \N \N \N \N \N \N 204 7 36 jsmith 37 3 I 30 \N 0.00 \N \N 0.00 \N \N \N \N \N 22 \N \N \N \N \N \N \N 205 7 36 jsmith 39 2 G 23 \N 0.00 \N \N 0.00 \N \N \N \N \N 21 \N \N \N \N \N \N \N 206 7 36 jsmith 40 2 G 24 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 21 \N \N \N \N \N \N \N 207 7 36 jsmith 41 3 I 31 \N 0.00 \N \N 0.00 \N \N \N \N \N 24 \N \N \N \N \N \N \N 208 7 36 jsmith 42 3 I 45 \N 0.00 \N \N 0.00 \N \N \N \N \N 24 \N \N \N \N \N \N \N 209 7 36 jsmith 21 1 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 12 \N \N \N \N \N \N \N 210 7 36 jsmith 15 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 13 \N \N \N \N \N \N \N 211 7 36 jsmith 18 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 14 \N \N \N \N \N \N \N 212 7 36 jsmith 20 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 15 \N \N \N \N \N \N \N 213 7 36 jsmith 45 1 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 16 \N \N \N \N \N \N \N 214 7 36 jsmith 34 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 17 \N \N \N \N \N \N \N 215 7 36 jsmith 31 3 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 18 \N \N \N \N \N \N \N 216 7 36 jsmith 33 3 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 20 \N \N \N \N \N \N \N 217 7 36 jsmith 44 2 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 21 \N \N \N \N \N \N \N 218 7 36 jsmith 38 3 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 22 \N \N \N \N \N \N \N 219 7 36 jsmith 43 3 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 24 \N \N \N \N \N \N \N 220 4 34 jsmith 1 0 G 3 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 \N \N \N \N \N \N \N 221 4 34 jsmith 2 1 G 4 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 \N \N \N \N \N \N \N 222 4 34 jsmith 3 2 I 2 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 223 4 34 jsmith 4 2 I 3 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 224 4 34 jsmith 6 1 G 5 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 \N \N \N \N \N \N \N 225 4 34 jsmith 7 2 I 4 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 5 \N \N \N \N \N \N \N 226 4 34 jsmith 8 1 G 6 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 \N \N \N \N \N \N \N 227 4 34 jsmith 10 0 G 7 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 \N \N \N \N \N \N \N 228 4 34 jsmith 11 1 G 8 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 \N \N \N \N \N \N \N 229 4 34 jsmith 12 2 I 5 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 230 4 34 jsmith 13 2 I 6 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 231 4 34 jsmith 14 2 I 7 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 232 4 34 jsmith 15 2 I 8 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 233 4 34 jsmith 16 2 I 9 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 234 4 34 jsmith 17 2 I 10 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 235 4 34 jsmith 18 2 I 11 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 236 4 34 jsmith 21 0 G 9 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 237 4 34 jsmith 5 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 238 4 34 jsmith 9 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 \N \N \N \N \N \N \N 239 4 34 jsmith 19 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 240 4 34 jsmith 20 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 \N \N \N \N \N \N \N 241 4 34 jsmith 22 0 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N \N \N \N \N \N \N \N \N 242 4 35 jsmith 1 0 G 3 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 \N \N \N \N \N \N \N 243 4 35 jsmith 2 1 G 4 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 \N \N \N \N \N \N \N 244 4 35 jsmith 3 2 I 2 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 245 4 35 jsmith 4 2 I 3 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 246 4 35 jsmith 6 1 G 5 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 \N \N \N \N \N \N \N 247 4 35 jsmith 7 2 I 4 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 5 \N \N \N \N \N \N \N 248 4 35 jsmith 8 1 G 6 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 \N \N \N \N \N \N \N 249 4 35 jsmith 10 0 G 7 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 \N \N \N \N \N \N \N 250 4 35 jsmith 11 1 G 8 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 \N \N \N \N \N \N \N 251 4 35 jsmith 12 2 I 5 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 252 4 35 jsmith 13 2 I 6 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 253 4 35 jsmith 14 2 I 7 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 254 4 35 jsmith 15 2 I 8 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 255 4 35 jsmith 16 2 I 9 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 256 4 35 jsmith 17 2 I 10 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 257 4 35 jsmith 18 2 I 11 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 258 4 35 jsmith 21 0 G 9 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 259 4 35 jsmith 5 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 260 4 35 jsmith 9 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 \N \N \N \N \N \N \N 261 4 35 jsmith 19 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 262 4 35 jsmith 20 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 \N \N \N \N \N \N \N 263 4 35 jsmith 22 0 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N \N \N \N \N \N \N \N \N 264 4 36 jsmith 1 0 G 3 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 \N \N \N \N \N \N \N 265 4 36 jsmith 2 1 G 4 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 \N \N \N \N \N \N \N 266 4 36 jsmith 3 2 I 2 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 267 4 36 jsmith 4 2 I 3 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 268 4 36 jsmith 6 1 G 5 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 \N \N \N \N \N \N \N 269 4 36 jsmith 7 2 I 4 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 5 \N \N \N \N \N \N \N 270 4 36 jsmith 8 1 G 6 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 \N \N \N \N \N \N \N 271 4 36 jsmith 10 0 G 7 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 \N \N \N \N \N \N \N 272 4 36 jsmith 11 1 G 8 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 \N \N \N \N \N \N \N 273 4 36 jsmith 12 2 I 5 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 274 4 36 jsmith 13 2 I 6 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 275 4 36 jsmith 14 2 I 7 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 276 4 36 jsmith 15 2 I 8 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 277 4 36 jsmith 16 2 I 9 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 278 4 36 jsmith 17 2 I 10 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 279 4 36 jsmith 18 2 I 11 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 280 4 36 jsmith 21 0 G 9 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 281 4 36 jsmith 5 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 282 4 36 jsmith 9 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 \N \N \N \N \N \N \N 283 4 36 jsmith 19 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 284 4 36 jsmith 20 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 \N \N \N \N \N \N \N 285 4 36 jsmith 22 0 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N \N \N \N \N \N \N \N \N 286 4 37 jsmith 1 0 G 3 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 \N \N \N \N \N \N \N 287 4 37 jsmith 2 1 G 4 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 \N \N \N \N \N \N \N 288 4 37 jsmith 3 2 I 2 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 289 4 37 jsmith 4 2 I 3 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 290 4 37 jsmith 6 1 G 5 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 \N \N \N \N \N \N \N 291 4 37 jsmith 7 2 I 4 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 5 \N \N \N \N \N \N \N 292 4 37 jsmith 8 1 G 6 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 \N \N \N \N \N \N \N 293 4 37 jsmith 10 0 G 7 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 \N \N \N \N \N \N \N 294 4 37 jsmith 11 1 G 8 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 \N \N \N \N \N \N \N 295 4 37 jsmith 12 2 I 5 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 296 4 37 jsmith 13 2 I 6 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 297 4 37 jsmith 14 2 I 7 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 298 4 37 jsmith 15 2 I 8 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 299 4 37 jsmith 16 2 I 9 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 300 4 37 jsmith 17 2 I 10 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 301 4 37 jsmith 18 2 I 11 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 302 4 37 jsmith 21 0 G 9 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 303 4 37 jsmith 5 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 304 4 37 jsmith 9 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 \N \N \N \N \N \N \N 305 4 37 jsmith 19 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 306 4 37 jsmith 20 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 \N \N \N \N \N \N \N 307 4 37 jsmith 22 0 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N \N \N \N \N \N \N \N \N 308 4 38 jsmith 1 0 G 3 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 \N \N \N \N \N \N \N 309 4 38 jsmith 2 1 G 4 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 \N \N \N \N \N \N \N 310 4 38 jsmith 3 2 I 2 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 311 4 38 jsmith 4 2 I 3 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 312 4 38 jsmith 6 1 G 5 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 \N \N \N \N \N \N \N 313 4 38 jsmith 7 2 I 4 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 5 \N \N \N \N \N \N \N 314 4 38 jsmith 8 1 G 6 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 \N \N \N \N \N \N \N 315 4 38 jsmith 10 0 G 7 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 \N \N \N \N \N \N \N 316 4 38 jsmith 11 1 G 8 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 \N \N \N \N \N \N \N 317 4 38 jsmith 12 2 I 5 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 318 4 38 jsmith 13 2 I 6 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 319 4 38 jsmith 14 2 I 7 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 320 4 38 jsmith 15 2 I 8 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 321 4 38 jsmith 16 2 I 9 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 322 4 38 jsmith 17 2 I 10 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 323 4 38 jsmith 18 2 I 11 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 324 4 38 jsmith 21 0 G 9 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 325 4 38 jsmith 5 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 326 4 38 jsmith 9 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 \N \N \N \N \N \N \N 327 4 38 jsmith 19 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 328 4 38 jsmith 20 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 \N \N \N \N \N \N \N 329 4 38 jsmith 22 0 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N \N \N \N \N \N \N \N \N 330 4 39 jsmith 1 0 G 3 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 \N \N \N \N \N \N \N 331 4 39 jsmith 2 1 G 4 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 \N \N \N \N \N \N \N 332 4 39 jsmith 3 2 I 2 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 333 4 39 jsmith 4 2 I 3 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 334 4 39 jsmith 6 1 G 5 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 \N \N \N \N \N \N \N 335 4 39 jsmith 7 2 I 4 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 5 \N \N \N \N \N \N \N 336 4 39 jsmith 8 1 G 6 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 \N \N \N \N \N \N \N 337 4 39 jsmith 10 0 G 7 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 \N \N \N \N \N \N \N 338 4 39 jsmith 11 1 G 8 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 \N \N \N \N \N \N \N 339 4 39 jsmith 12 2 I 5 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 340 4 39 jsmith 13 2 I 6 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 341 4 39 jsmith 14 2 I 7 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 342 4 39 jsmith 15 2 I 8 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 343 4 39 jsmith 16 2 I 9 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 344 4 39 jsmith 17 2 I 10 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 345 4 39 jsmith 18 2 I 11 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 346 4 39 jsmith 21 0 G 9 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 347 4 39 jsmith 5 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 348 4 39 jsmith 9 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 \N \N \N \N \N \N \N 349 4 39 jsmith 19 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 350 4 39 jsmith 20 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 \N \N \N \N \N \N \N 351 4 39 jsmith 22 0 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N \N \N \N \N \N \N \N \N 352 4 40 jsmith 1 0 G 3 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 \N \N \N \N \N \N \N 353 4 40 jsmith 2 1 G 4 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 \N \N \N \N \N \N \N 354 4 40 jsmith 3 2 I 2 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 355 4 40 jsmith 4 2 I 3 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 356 4 40 jsmith 6 1 G 5 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 \N \N \N \N \N \N \N 357 4 40 jsmith 7 2 I 4 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 5 \N \N \N \N \N \N \N 358 4 40 jsmith 8 1 G 6 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 \N \N \N \N \N \N \N 359 4 40 jsmith 10 0 G 7 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 \N \N \N \N \N \N \N 360 4 40 jsmith 11 1 G 8 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 \N \N \N \N \N \N \N 361 4 40 jsmith 12 2 I 5 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 362 4 40 jsmith 13 2 I 6 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 363 4 40 jsmith 14 2 I 7 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 364 4 40 jsmith 15 2 I 8 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 365 4 40 jsmith 16 2 I 9 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 366 4 40 jsmith 17 2 I 10 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 367 4 40 jsmith 18 2 I 11 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 368 4 40 jsmith 21 0 G 9 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 369 4 40 jsmith 5 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 370 4 40 jsmith 9 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 \N \N \N \N \N \N \N 371 4 40 jsmith 19 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 372 4 40 jsmith 20 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 \N \N \N \N \N \N \N 373 4 40 jsmith 22 0 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N \N \N \N \N \N \N \N \N 374 4 41 jsmith 1 0 G 3 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 \N \N \N \N \N \N \N 375 4 41 jsmith 2 1 G 4 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 \N \N \N \N \N \N \N 376 4 41 jsmith 3 2 I 2 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 377 4 41 jsmith 4 2 I 3 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 378 4 41 jsmith 6 1 G 5 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 \N \N \N \N \N \N \N 379 4 41 jsmith 7 2 I 4 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 5 \N \N \N \N \N \N \N 380 4 41 jsmith 8 1 G 6 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 \N \N \N \N \N \N \N 381 4 41 jsmith 10 0 G 7 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 \N \N \N \N \N \N \N 382 4 41 jsmith 11 1 G 8 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 \N \N \N \N \N \N \N 383 4 41 jsmith 12 2 I 5 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 384 4 41 jsmith 13 2 I 6 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 385 4 41 jsmith 14 2 I 7 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 386 4 41 jsmith 15 2 I 8 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 387 4 41 jsmith 16 2 I 9 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 388 4 41 jsmith 17 2 I 10 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 389 4 41 jsmith 18 2 I 11 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 390 4 41 jsmith 21 0 G 9 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 391 4 41 jsmith 5 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 392 4 41 jsmith 9 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 \N \N \N \N \N \N \N 393 4 41 jsmith 19 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 394 4 41 jsmith 20 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 \N \N \N \N \N \N \N 395 4 41 jsmith 22 0 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N \N \N \N \N \N \N \N \N 396 4 32 jsmith 1 0 G 3 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 \N \N \N \N \N \N \N 397 4 32 jsmith 2 1 G 4 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 \N \N \N \N \N \N \N 398 4 32 jsmith 3 2 I 2 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 399 4 32 jsmith 4 2 I 3 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 400 4 32 jsmith 6 1 G 5 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 \N \N \N \N \N \N \N 401 4 32 jsmith 7 2 I 4 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 5 \N \N \N \N \N \N \N 402 4 32 jsmith 8 1 G 6 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 \N \N \N \N \N \N \N 403 4 32 jsmith 10 0 G 7 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 \N \N \N \N \N \N \N 404 4 32 jsmith 11 1 G 8 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 \N \N \N \N \N \N \N 405 4 32 jsmith 12 2 I 5 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 406 4 32 jsmith 13 2 I 6 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 407 4 32 jsmith 14 2 I 7 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 408 4 32 jsmith 15 2 I 8 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 409 4 32 jsmith 16 2 I 9 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 410 4 32 jsmith 17 2 I 10 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 411 4 32 jsmith 18 2 I 11 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 412 4 32 jsmith 21 0 G 9 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 413 4 32 jsmith 5 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 414 4 32 jsmith 9 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 \N \N \N \N \N \N \N 415 4 32 jsmith 19 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 416 4 32 jsmith 20 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 \N \N \N \N \N \N \N 417 4 32 jsmith 22 0 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N \N \N \N \N \N \N \N \N 418 4 33 jsmith 1 0 G 3 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 \N \N \N \N \N \N \N 419 4 33 jsmith 2 1 G 4 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 \N \N \N \N \N \N \N 420 4 33 jsmith 3 2 I 2 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 421 4 33 jsmith 4 2 I 3 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 422 4 33 jsmith 6 1 G 5 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 \N \N \N \N \N \N \N 423 4 33 jsmith 7 2 I 4 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 5 \N \N \N \N \N \N \N 424 4 33 jsmith 8 1 G 6 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 \N \N \N \N \N \N \N 425 4 33 jsmith 10 0 G 7 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 \N \N \N \N \N \N \N 426 4 33 jsmith 11 1 G 8 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 \N \N \N \N \N \N \N 427 4 33 jsmith 12 2 I 5 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 428 4 33 jsmith 13 2 I 6 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 429 4 33 jsmith 14 2 I 7 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 430 4 33 jsmith 15 2 I 8 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 431 4 33 jsmith 16 2 I 9 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 432 4 33 jsmith 17 2 I 10 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 433 4 33 jsmith 18 2 I 11 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 434 4 33 jsmith 21 0 G 9 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 435 4 33 jsmith 5 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 \N \N \N \N \N \N \N 436 4 33 jsmith 9 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 \N \N \N \N \N \N \N 437 4 33 jsmith 19 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 \N \N \N \N \N \N \N 438 4 33 jsmith 20 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 \N \N \N \N \N \N \N 439 4 33 jsmith 22 0 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N \N \N \N \N \N \N \N \N 440 9 30 jsmith 1 0 G 26 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 441 9 30 jsmith 2 1 G 28 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 26 \N \N \N \N \N \N \N 442 9 30 jsmith 3 2 I 42 \N 0.00 \N \N \N \N \N \N \N \N 28 \N \N \N \N \N \N \N 443 9 30 jsmith 5 1 G 30 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 26 \N \N \N \N \N \N \N 444 9 30 jsmith 6 2 G 31 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 30 \N \N \N \N \N \N \N 445 9 30 jsmith 7 3 I 43 \N 0.00 \N \N \N \N \N \N \N \N 31 \N \N \N \N \N \N \N 446 9 30 jsmith 9 2 G 32 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 30 \N \N \N \N \N \N \N 447 9 30 jsmith 10 3 I 44 \N 0.00 \N \N \N \N \N \N \N \N 32 \N \N \N \N \N \N \N 448 9 30 jsmith 12 2 G 34 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 30 \N \N \N \N \N \N \N 449 9 30 jsmith 14 0 G 35 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 450 9 30 jsmith 4 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 28 \N \N \N \N \N \N \N 451 9 30 jsmith 8 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 31 \N \N \N \N \N \N \N 452 9 30 jsmith 11 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 32 \N \N \N \N \N \N \N 453 9 30 jsmith 13 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 30 \N \N \N \N \N \N \N 454 9 30 jsmith 15 0 T -1 \N 0.00 \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N 455 9 46 jsmith 1 0 G 26 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 456 9 46 jsmith 2 1 G 28 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 26 \N \N \N \N \N \N \N 457 9 46 jsmith 3 2 I 42 \N 0.00 \N \N \N \N \N \N \N \N 28 \N \N \N \N \N \N \N 458 9 46 jsmith 5 1 G 30 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 26 \N \N \N \N \N \N \N 459 9 46 jsmith 6 2 G 31 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 30 \N \N \N \N \N \N \N 460 9 46 jsmith 7 3 I 43 \N 0.00 \N \N \N \N \N \N \N \N 31 \N \N \N \N \N \N \N 461 9 46 jsmith 9 2 G 32 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 30 \N \N \N \N \N \N \N 462 9 46 jsmith 10 3 I 44 \N 0.00 \N \N \N \N \N \N \N \N 32 \N \N \N \N \N \N \N 463 9 46 jsmith 12 2 G 34 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 30 \N \N \N \N \N \N \N 464 9 46 jsmith 14 0 G 35 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 465 9 46 jsmith 4 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 28 \N \N \N \N \N \N \N 466 9 46 jsmith 13 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 30 \N \N \N \N \N \N \N 467 9 46 jsmith 8 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 31 \N \N \N \N \N \N \N 468 9 46 jsmith 11 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 32 \N \N \N \N \N \N \N 469 9 46 jsmith 15 0 T -1 \N 0.00 \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N 470 9 29 jsmith 1 0 G 26 0.00 500.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 471 9 29 jsmith 2 1 G 28 0.00 500.00 0.00 0.00 0.00 \N \N \N \N \N 26 \N \N \N \N \N \N \N 472 9 29 jsmith 3 2 I 42 \N 500.00 \N \N \N \N \N \N \N \N 28 \N \N \N \N \N \N \N 473 9 29 jsmith 5 1 G 30 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 26 \N \N \N \N \N \N \N 474 9 29 jsmith 6 2 G 31 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 30 \N \N \N \N \N \N \N 475 9 29 jsmith 7 3 I 43 \N 0.00 \N \N \N \N \N \N \N \N 31 \N \N \N \N \N \N \N 476 9 29 jsmith 9 2 G 32 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 30 \N \N \N \N \N \N \N 477 9 29 jsmith 10 3 I 44 \N 0.00 \N \N \N \N \N \N \N \N 32 \N \N \N \N \N \N \N 478 9 29 jsmith 12 2 G 34 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 30 \N \N \N \N \N \N \N 479 9 29 jsmith 14 0 G 35 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 480 9 29 jsmith 4 2 T -1 \N 500.00 \N \N \N \N \N \N \N \N 28 \N \N \N \N \N \N \N 481 9 29 jsmith 13 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 30 \N \N \N \N \N \N \N 482 9 29 jsmith 8 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 31 \N \N \N \N \N \N \N 483 9 29 jsmith 11 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 32 \N \N \N \N \N \N \N 484 9 29 jsmith 15 0 T -1 \N 500.00 \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N 485 9 28 jsmith 1 0 G 26 0.00 206.07 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 486 9 28 jsmith 2 1 G 28 0.00 200.00 0.00 0.00 0.00 \N \N \N \N \N 26 \N \N \N \N \N \N \N 487 9 28 jsmith 3 2 I 42 \N 200.00 \N \N \N \N \N \N \N \N 28 \N \N \N \N \N \N \N 488 9 28 jsmith 5 1 G 30 0.00 6.07 0.00 0.00 0.00 \N \N \N \N \N 26 \N \N \N \N \N \N \N 489 9 28 jsmith 6 2 G 31 0.00 1.07 0.00 0.00 0.00 \N \N \N \N \N 30 \N \N \N \N \N \N \N 490 9 28 jsmith 7 3 I 43 \N 1.07 \N \N \N \N \N \N \N \N 31 \N \N \N \N \N \N \N 491 9 28 jsmith 9 2 G 32 0.00 5.00 0.00 0.00 0.00 \N \N \N \N \N 30 \N \N \N \N \N \N \N 492 9 28 jsmith 10 3 I 44 \N 5.00 \N \N \N \N \N \N \N \N 32 \N \N \N \N \N \N \N 493 9 28 jsmith 12 2 G 34 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 30 \N \N \N \N \N \N \N 494 9 28 jsmith 14 0 G 35 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 \N \N \N \N \N \N \N 495 9 28 jsmith 4 2 T -1 \N 200.00 \N \N \N \N \N \N \N \N 28 \N \N \N \N \N \N \N 496 9 28 jsmith 13 2 T -1 \N 6.07 \N \N \N \N \N \N \N \N 30 \N \N \N \N \N \N \N 497 9 28 jsmith 8 3 T -1 \N 1.07 \N \N \N \N \N \N \N \N 31 \N \N \N \N \N \N \N 498 9 28 jsmith 11 3 T -1 \N 5.00 \N \N \N \N \N \N \N \N 32 \N \N \N \N \N \N \N 499 9 28 jsmith 15 0 T -1 \N 206.07 \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N 500 7 31 jsmith 1 0 G 12 0.00 1000.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 1000.00 \N \N \N \N 501 7 31 jsmith 2 1 G 13 0.00 1000.00 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 1000.00 \N \N \N \N 502 7 31 jsmith 3 2 I 12 \N 2000.00 \N \N \N \N \N \N \N \N 13 \N \N 2000.00 \N \N \N \N 503 7 31 jsmith 4 2 I 13 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 504 7 31 jsmith 5 2 I 14 \N -1000.00 \N \N \N \N \N \N \N \N 13 \N \N -1000.00 \N \N \N \N 505 7 31 jsmith 6 2 I 15 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 506 7 31 jsmith 7 2 I 16 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 507 7 31 jsmith 8 2 I 17 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 508 7 31 jsmith 9 2 I 18 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 509 7 31 jsmith 10 2 I 19 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 510 7 31 jsmith 11 2 I 20 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 511 7 31 jsmith 12 2 I 21 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 512 7 31 jsmith 13 2 I 22 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 513 7 31 jsmith 15 1 G 14 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 0.00 \N \N \N \N 514 7 31 jsmith 16 2 I 23 \N 0.00 \N \N \N \N \N \N \N \N 14 \N \N 0.00 \N \N \N \N 515 7 31 jsmith 18 1 G 15 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 0.00 \N \N \N \N 516 7 31 jsmith 21 0 G 16 0.00 1000.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 1000.00 \N \N \N \N 517 7 31 jsmith 22 1 G 17 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 16 0.00 \N 0.00 \N \N \N \N 518 7 31 jsmith 23 2 G 18 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 0.00 \N 0.00 \N \N \N \N 519 7 31 jsmith 24 3 I 24 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 520 7 31 jsmith 25 3 I 25 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 521 7 31 jsmith 26 3 I 26 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 522 7 31 jsmith 27 3 I 27 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 523 7 31 jsmith 28 3 I 28 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 524 7 31 jsmith 29 3 I 29 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 525 7 31 jsmith 31 2 G 20 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 0.00 \N 0.00 \N \N \N \N 526 7 31 jsmith 34 1 G 21 0.00 1000.00 0.00 0.00 0.00 \N \N \N \N \N 16 0.00 \N 1000.00 \N \N \N \N 527 7 31 jsmith 35 2 G 22 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 21 0.00 \N 0.00 \N \N \N \N 528 7 31 jsmith 36 3 I 30 \N 0.00 \N \N \N \N \N \N \N \N 22 \N \N 0.00 \N \N \N \N 529 7 31 jsmith 38 2 G 23 \N 1000.00 \N \N \N \N \N \N \N \N 21 \N \N 1000.00 \N \N \N \N 530 7 31 jsmith 39 2 G 24 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 21 0.00 \N 0.00 \N \N \N \N 531 7 31 jsmith 40 3 I 31 \N 0.00 \N \N \N \N \N \N \N \N 24 \N \N 0.00 \N \N \N \N 532 7 31 jsmith 41 3 I 45 \N 0.00 \N \N \N \N \N \N \N \N 24 \N \N 0.00 \N \N \N \N 533 7 31 jsmith 14 2 T -1 \N 1000.00 \N \N \N \N \N \N \N \N 13 \N \N 1000.00 \N \N \N \N 534 7 31 jsmith 17 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 14 \N \N 0.00 \N \N \N \N 535 7 31 jsmith 19 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 15 \N \N 0.00 \N \N \N \N 536 7 31 jsmith 20 1 T -1 \N 1000.00 \N \N \N \N \N \N \N \N 12 \N \N 1000.00 \N \N \N \N 537 7 31 jsmith 30 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 538 7 31 jsmith 32 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 20 \N \N 0.00 \N \N \N \N 539 7 31 jsmith 33 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 17 \N \N 0.00 \N \N \N \N 540 7 31 jsmith 37 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 22 \N \N 0.00 \N \N \N \N 541 7 31 jsmith 42 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 24 \N \N 0.00 \N \N \N \N 542 7 31 jsmith 43 2 T -1 \N 1000.00 \N \N \N \N \N \N \N \N 21 \N \N 1000.00 \N \N \N \N 543 7 31 jsmith 44 1 T -1 \N 1000.00 \N \N \N \N \N \N \N \N 16 \N \N 1000.00 \N \N \N \N 544 7 31 jsmith 45 0 T -1 \N 0.00 \N \N \N \N \N \N \N \N \N 0.00 \N 0.00 \N \N \N \N 545 11 31 jsmith 1 0 G 44 0.00 1000.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 1000.00 \N \N \N \N 546 11 31 jsmith 2 1 G 45 0.00 1000.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 1000.00 \N \N \N \N 547 11 31 jsmith 3 2 I 65 \N 2000.00 \N \N \N \N \N \N \N \N 45 \N \N 2000.00 \N \N \N \N 548 11 31 jsmith 4 2 I 66 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 549 11 31 jsmith 5 2 I 67 \N -1000.00 \N \N \N \N \N \N \N \N 45 \N \N -1000.00 \N \N \N \N 550 11 31 jsmith 6 2 I 68 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 551 11 31 jsmith 7 2 I 69 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 552 11 31 jsmith 8 2 I 70 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 553 11 31 jsmith 9 2 I 71 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 554 11 31 jsmith 10 2 I 72 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 555 11 31 jsmith 11 2 I 73 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 556 11 31 jsmith 12 2 I 74 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 557 11 31 jsmith 13 2 I 75 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 558 11 31 jsmith 15 1 G 46 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 559 11 31 jsmith 16 2 I 76 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 560 11 31 jsmith 18 1 G 47 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 561 11 31 jsmith 21 0 G 36 0.00 1000.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 1000.00 \N \N \N \N 562 11 31 jsmith 22 1 G 37 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 0.00 \N \N \N \N 563 11 31 jsmith 23 2 G 38 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 564 11 31 jsmith 24 3 I 47 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 565 11 31 jsmith 25 3 I 46 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 566 11 31 jsmith 26 3 I 48 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 567 11 31 jsmith 27 3 I 49 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 568 11 31 jsmith 28 3 I 50 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 569 11 31 jsmith 29 3 I 51 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 570 11 31 jsmith 31 2 G 39 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 571 11 31 jsmith 34 1 G 40 0.00 1000.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 1000.00 \N \N \N \N 572 11 31 jsmith 35 2 G 41 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 0.00 \N \N \N \N 573 11 31 jsmith 36 3 I 52 \N 0.00 \N \N \N \N \N \N \N \N 41 \N \N 0.00 \N \N \N \N 574 11 31 jsmith 38 2 G 42 \N 1000.00 \N \N \N \N \N \N \N \N 40 \N \N 1000.00 \N \N \N \N 575 11 31 jsmith 39 2 G 43 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 0.00 \N \N \N \N 576 11 31 jsmith 40 3 I 63 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 577 11 31 jsmith 41 3 I 64 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 578 11 31 jsmith 14 2 T -1 \N 1000.00 \N \N \N \N \N \N \N \N 45 \N \N 1000.00 \N \N \N \N 579 11 31 jsmith 17 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 580 11 31 jsmith 19 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 47 \N \N 0.00 \N \N \N \N 581 11 31 jsmith 20 1 T -1 \N 1000.00 \N \N \N \N \N \N \N \N 44 \N \N 1000.00 \N \N \N \N 582 11 31 jsmith 30 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 583 11 31 jsmith 32 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N \N \N \N 584 11 31 jsmith 33 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 37 \N \N 0.00 \N \N \N \N 585 11 31 jsmith 37 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 41 \N \N 0.00 \N \N \N \N 586 11 31 jsmith 42 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 587 11 31 jsmith 43 2 T -1 \N 1000.00 \N \N \N \N \N \N \N \N 40 \N \N 1000.00 \N \N \N \N 588 11 31 jsmith 44 1 T -1 \N 1000.00 \N \N \N \N \N \N \N \N 36 \N \N 1000.00 \N \N \N \N 589 11 31 jsmith 45 0 T -1 \N 0.00 \N \N \N \N \N \N \N \N \N \N \N 0.00 \N \N \N \N 590 4 31 jsmith 1 0 G 3 0.00 1000.00 0.00 0.00 0.00 \N 0.50000000000000000000 \N \N 0.00000000000000000000 -1 1000.00 0.50000000000000000000 1000.00 0.50000000000000000000 \N \N \N 591 4 31 jsmith 2 1 G 4 0.00 2000.00 0.00 0.00 0.00 \N \N \N \N \N 3 2000.00 1.00000000000000000000 2000.00 1.00000000000000000000 \N \N \N 592 4 31 jsmith 3 2 I 2 0.00 2000.00 \N \N 0.00 \N 1.00000000000000000000 \N \N 0.00000000000000000000 4 2000.00 1.00000000000000000000 2000.00 1.00000000000000000000 \N \N \N 593 4 31 jsmith 4 2 I 3 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 594 4 31 jsmith 6 1 G 5 0.00 -1000.00 0.00 0.00 0.00 \N \N \N \N \N 3 -1000.00 \N -1000.00 \N \N \N \N 595 4 31 jsmith 7 2 I 4 \N 1000.00 \N \N 0.00 \N 0.50000000000000000000 \N \N 0.00000000000000000000 5 1000.00 0.50000000000000000000 1000.00 0.50000000000000000000 \N \N \N 596 4 31 jsmith 8 1 G 6 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 0.00 \N 0.00 \N \N \N \N 597 4 31 jsmith 10 0 G 7 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 598 4 31 jsmith 11 1 G 8 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 599 4 31 jsmith 12 2 I 5 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 600 4 31 jsmith 13 2 I 6 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 601 4 31 jsmith 14 2 I 7 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 602 4 31 jsmith 15 2 I 8 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 603 4 31 jsmith 16 2 I 9 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 604 4 31 jsmith 17 2 I 10 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 605 4 31 jsmith 18 2 I 11 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 606 4 31 jsmith 20 0 G 9 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 607 4 31 jsmith 5 2 T -1 \N 2000.00 \N \N \N \N \N \N \N \N 4 2000.00 1.00000000000000000000 2000.00 1.00000000000000000000 \N \N \N 608 4 31 jsmith 9 1 T -1 \N 1000.00 \N \N 0.00 \N 0.50000000000000000000 \N \N 0.00000000000000000000 3 1000.00 0.50000000000000000000 1000.00 0.50000000000000000000 \N \N \N 609 4 31 jsmith 19 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 610 4 31 jsmith 21 0 T -1 0.00 1000.00 \N \N 0.00 \N \N \N \N \N \N 1000.00 \N 1000.00 \N \N \N \N 611 7 47 jsmith 1 0 G 12 0.00 15000.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 15000.00 \N \N \N \N 612 7 47 jsmith 2 1 G 13 0.00 15000.00 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 15000.00 \N \N \N \N 613 7 47 jsmith 3 2 I 12 \N 8000.00 \N \N \N \N \N \N \N \N 13 \N \N 8000.00 \N \N \N \N 614 7 47 jsmith 4 2 I 13 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 615 7 47 jsmith 5 2 I 14 \N 7000.00 \N \N \N \N \N \N \N \N 13 \N \N 7000.00 \N \N \N \N 616 7 47 jsmith 6 2 I 15 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 617 7 47 jsmith 7 2 I 16 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 618 7 47 jsmith 8 2 I 17 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 619 7 47 jsmith 9 2 I 18 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 620 7 47 jsmith 10 2 I 19 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 621 7 47 jsmith 11 2 I 20 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 622 7 47 jsmith 12 2 I 21 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 623 7 47 jsmith 13 2 I 22 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 624 7 47 jsmith 15 1 G 14 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 0.00 \N \N \N \N 625 7 47 jsmith 16 2 I 23 \N 0.00 \N \N \N \N \N \N \N \N 14 \N \N 0.00 \N \N \N \N 626 7 47 jsmith 18 1 G 15 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 0.00 \N \N \N \N 627 7 47 jsmith 21 0 G 16 0.00 15000.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 15000.00 \N \N \N \N 628 7 47 jsmith 22 1 G 17 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 16 0.00 \N 0.00 \N \N \N \N 629 7 47 jsmith 23 2 G 18 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 0.00 \N 0.00 \N \N \N \N 630 7 47 jsmith 24 3 I 24 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 631 7 47 jsmith 25 3 I 25 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 632 7 47 jsmith 26 3 I 26 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 633 7 47 jsmith 27 3 I 27 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 634 7 47 jsmith 28 3 I 28 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 635 7 47 jsmith 29 3 I 29 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 636 7 47 jsmith 31 2 G 20 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 0.00 \N 0.00 \N \N \N \N 637 7 47 jsmith 34 1 G 21 0.00 15000.00 0.00 0.00 0.00 \N \N \N \N \N 16 0.00 \N 15000.00 \N \N \N \N 638 7 47 jsmith 35 2 G 22 0.00 10000.00 0.00 0.00 0.00 \N \N \N \N \N 21 0.00 \N 10000.00 \N \N \N \N 639 7 47 jsmith 36 3 I 30 \N 10000.00 \N \N \N \N \N \N \N \N 22 \N \N 10000.00 \N \N \N \N 640 7 47 jsmith 38 2 G 23 \N 5000.00 \N \N \N \N \N \N \N \N 21 \N \N 5000.00 \N \N \N \N 641 7 47 jsmith 39 2 G 24 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 21 0.00 \N 0.00 \N \N \N \N 642 7 47 jsmith 40 3 I 31 \N 0.00 \N \N \N \N \N \N \N \N 24 \N \N 0.00 \N \N \N \N 643 7 47 jsmith 41 3 I 45 \N 0.00 \N \N \N \N \N \N \N \N 24 \N \N 0.00 \N \N \N \N 644 7 47 jsmith 14 2 T -1 \N 15000.00 \N \N \N \N \N \N \N \N 13 \N \N 15000.00 \N \N \N \N 645 7 47 jsmith 17 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 14 \N \N 0.00 \N \N \N \N 646 7 47 jsmith 19 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 15 \N \N 0.00 \N \N \N \N 647 7 47 jsmith 20 1 T -1 \N 15000.00 \N \N \N \N \N \N \N \N 12 \N \N 15000.00 \N \N \N \N 648 7 47 jsmith 30 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 649 7 47 jsmith 32 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 20 \N \N 0.00 \N \N \N \N 650 7 47 jsmith 33 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 17 \N \N 0.00 \N \N \N \N 651 7 47 jsmith 37 3 T -1 \N 10000.00 \N \N \N \N \N \N \N \N 22 \N \N 10000.00 \N \N \N \N 652 7 47 jsmith 42 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 24 \N \N 0.00 \N \N \N \N 653 7 47 jsmith 43 2 T -1 \N 15000.00 \N \N \N \N \N \N \N \N 21 \N \N 15000.00 \N \N \N \N 654 7 47 jsmith 44 1 T -1 \N 15000.00 \N \N \N \N \N \N \N \N 16 \N \N 15000.00 \N \N \N \N 655 7 47 jsmith 45 0 T -1 \N 0.00 \N \N \N \N \N \N \N \N \N 0.00 \N 0.00 \N \N \N \N 656 7 48 jsmith 4 2 I 13 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 657 7 48 jsmith 1 0 G 12 0.00 18000.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 18000.00 \N \N \N \N 658 7 48 jsmith 2 1 G 13 0.00 18000.00 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 18000.00 \N \N \N \N 659 7 48 jsmith 3 2 I 12 \N 14000.00 \N \N \N \N \N \N \N \N 13 \N \N 14000.00 \N \N \N \N 660 7 48 jsmith 5 2 I 14 \N 4000.00 \N \N \N \N \N \N \N \N 13 \N \N 4000.00 \N \N \N \N 661 7 48 jsmith 6 2 I 15 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 662 7 48 jsmith 7 2 I 16 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 663 7 48 jsmith 8 2 I 17 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 664 7 48 jsmith 9 2 I 18 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 665 7 48 jsmith 10 2 I 19 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 666 7 48 jsmith 11 2 I 20 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 667 7 48 jsmith 12 2 I 21 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 668 7 48 jsmith 13 2 I 22 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 669 7 48 jsmith 15 1 G 14 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 0.00 \N \N \N \N 670 7 48 jsmith 16 2 I 23 \N 0.00 \N \N \N \N \N \N \N \N 14 \N \N 0.00 \N \N \N \N 671 7 48 jsmith 18 1 G 15 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 0.00 \N \N \N \N 672 7 48 jsmith 21 0 G 16 0.00 18000.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 18000.00 \N \N \N \N 673 7 48 jsmith 22 1 G 17 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 16 0.00 \N 0.00 \N \N \N \N 674 7 48 jsmith 23 2 G 18 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 0.00 \N 0.00 \N \N \N \N 675 7 48 jsmith 24 3 I 24 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 676 7 48 jsmith 25 3 I 25 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 677 7 48 jsmith 26 3 I 26 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 678 7 48 jsmith 27 3 I 27 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 679 7 48 jsmith 28 3 I 28 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 680 7 48 jsmith 29 3 I 29 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 681 7 48 jsmith 31 2 G 20 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 0.00 \N 0.00 \N \N \N \N 682 7 48 jsmith 34 1 G 21 0.00 18000.00 0.00 0.00 0.00 \N \N \N \N \N 16 0.00 \N 18000.00 \N \N \N \N 683 7 48 jsmith 35 2 G 22 0.00 10000.00 0.00 0.00 0.00 \N \N \N \N \N 21 0.00 \N 10000.00 \N \N \N \N 684 7 48 jsmith 36 3 I 30 \N 10000.00 \N \N \N \N \N \N \N \N 22 \N \N 10000.00 \N \N \N \N 685 7 48 jsmith 38 2 G 23 \N 3000.00 \N \N \N \N \N \N \N \N 21 \N \N 3000.00 \N \N \N \N 686 7 48 jsmith 39 2 G 24 0.00 5000.00 0.00 0.00 0.00 \N \N \N \N \N 21 0.00 \N 5000.00 \N \N \N \N 687 7 48 jsmith 40 3 I 31 \N 5000.00 \N \N \N \N \N \N \N \N 24 \N \N 5000.00 \N \N \N \N 688 7 48 jsmith 41 3 I 45 \N 0.00 \N \N \N \N \N \N \N \N 24 \N \N 0.00 \N \N \N \N 689 7 48 jsmith 14 2 T -1 \N 18000.00 \N \N \N \N \N \N \N \N 13 \N \N 18000.00 \N \N \N \N 690 7 48 jsmith 17 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 14 \N \N 0.00 \N \N \N \N 691 7 48 jsmith 19 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 15 \N \N 0.00 \N \N \N \N 692 7 48 jsmith 20 1 T -1 \N 18000.00 \N \N \N \N \N \N \N \N 12 \N \N 18000.00 \N \N \N \N 693 7 48 jsmith 30 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 694 7 48 jsmith 32 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 20 \N \N 0.00 \N \N \N \N 695 7 48 jsmith 33 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 17 \N \N 0.00 \N \N \N \N 696 7 48 jsmith 37 3 T -1 \N 10000.00 \N \N \N \N \N \N \N \N 22 \N \N 10000.00 \N \N \N \N 697 7 48 jsmith 42 3 T -1 \N 5000.00 \N \N \N \N \N \N \N \N 24 \N \N 5000.00 \N \N \N \N 698 7 48 jsmith 43 2 T -1 \N 18000.00 \N \N \N \N \N \N \N \N 21 \N \N 18000.00 \N \N \N \N 699 7 48 jsmith 44 1 T -1 \N 18000.00 \N \N \N \N \N \N \N \N 16 \N \N 18000.00 \N \N \N \N 700 7 48 jsmith 45 0 T -1 \N 0.00 \N \N \N \N \N \N \N \N \N 0.00 \N 0.00 \N \N \N \N 701 7 46 jsmith 1 0 G 12 0.00 39000.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 39000.00 \N \N \N \N 702 7 46 jsmith 2 1 G 13 0.00 39000.00 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 39000.00 \N \N \N \N 703 7 46 jsmith 3 2 I 12 \N 36000.00 \N \N \N \N \N \N \N \N 13 \N \N 36000.00 \N \N \N \N 704 7 46 jsmith 4 2 I 13 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 705 7 46 jsmith 5 2 I 14 \N 3000.00 \N \N \N \N \N \N \N \N 13 \N \N 3000.00 \N \N \N \N 706 7 46 jsmith 6 2 I 15 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 707 7 46 jsmith 7 2 I 16 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 708 7 46 jsmith 8 2 I 17 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 709 7 46 jsmith 9 2 I 18 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 710 7 46 jsmith 10 2 I 19 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 711 7 46 jsmith 11 2 I 20 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 712 7 46 jsmith 12 2 I 21 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 713 7 46 jsmith 13 2 I 22 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 714 7 46 jsmith 15 1 G 14 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 0.00 \N \N \N \N 715 7 46 jsmith 16 2 I 23 \N 0.00 \N \N \N \N \N \N \N \N 14 \N \N 0.00 \N \N \N \N 716 7 46 jsmith 18 1 G 15 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 0.00 \N \N \N \N 717 7 46 jsmith 21 0 G 16 0.00 39000.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 36000.00 \N \N \N \N 718 7 46 jsmith 22 1 G 17 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 16 0.00 \N 0.00 \N \N \N \N 719 7 46 jsmith 23 2 G 18 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 0.00 \N 0.00 \N \N \N \N 720 7 46 jsmith 24 3 I 24 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 721 7 46 jsmith 25 3 I 25 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 722 7 46 jsmith 26 3 I 26 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 723 7 46 jsmith 27 3 I 27 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 724 7 46 jsmith 28 3 I 28 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 725 7 46 jsmith 29 3 I 29 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 726 7 46 jsmith 31 2 G 20 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 0.00 \N 0.00 \N \N \N \N 727 7 46 jsmith 34 1 G 21 0.00 39000.00 0.00 0.00 0.00 \N \N \N \N \N 16 0.00 \N 36000.00 \N \N \N \N 728 7 46 jsmith 35 2 G 22 0.00 20000.00 0.00 0.00 0.00 \N \N \N \N \N 21 0.00 \N 20000.00 \N \N \N \N 729 7 46 jsmith 36 3 I 30 \N 20000.00 \N \N \N \N \N \N \N \N 22 \N \N 20000.00 \N \N \N \N 730 7 46 jsmith 38 2 G 23 \N 14000.00 \N \N \N \N \N \N \N \N 21 \N \N 11000.00 \N \N \N \N 731 7 46 jsmith 39 2 G 24 0.00 5000.00 0.00 0.00 0.00 \N \N \N \N \N 21 0.00 \N 5000.00 \N \N \N \N 732 7 46 jsmith 40 3 I 31 \N 5000.00 \N \N \N \N \N \N \N \N 24 \N \N 5000.00 \N \N \N \N 733 7 46 jsmith 41 3 I 45 \N 0.00 \N \N \N \N \N \N \N \N 24 \N \N 0.00 \N \N \N \N 734 7 46 jsmith 14 2 T -1 \N 39000.00 \N \N \N \N \N \N \N \N 13 \N \N 39000.00 \N \N \N \N 735 7 46 jsmith 17 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 14 \N \N 0.00 \N \N \N \N 736 7 46 jsmith 19 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 15 \N \N 0.00 \N \N \N \N 737 7 46 jsmith 20 1 T -1 \N 39000.00 \N \N \N \N \N \N \N \N 12 \N \N 39000.00 \N \N \N \N 738 7 46 jsmith 30 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 739 7 46 jsmith 32 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 20 \N \N 0.00 \N \N \N \N 740 7 46 jsmith 33 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 17 \N \N 0.00 \N \N \N \N 741 7 46 jsmith 37 3 T -1 \N 20000.00 \N \N \N \N \N \N \N \N 22 \N \N 20000.00 \N \N \N \N 742 7 46 jsmith 42 3 T -1 \N 5000.00 \N \N \N \N \N \N \N \N 24 \N \N 5000.00 \N \N \N \N 743 7 46 jsmith 43 2 T -1 \N 39000.00 \N \N \N \N \N \N \N \N 21 \N \N 36000.00 \N \N \N \N 744 7 46 jsmith 44 1 T -1 \N 39000.00 \N \N \N \N \N \N \N \N 16 \N \N 36000.00 \N \N \N \N 745 7 46 jsmith 45 0 T -1 \N 0.00 \N \N \N \N \N \N \N \N \N 0.00 \N 3000.00 \N \N \N \N 746 7 29 jsmith 10 2 I 19 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 747 7 29 jsmith 1 0 G 12 0.00 39000.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 39000.00 \N \N \N \N 748 7 29 jsmith 2 1 G 13 0.00 39000.00 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 39000.00 \N \N \N \N 749 7 29 jsmith 3 2 I 12 \N 36000.00 \N \N \N \N \N \N \N \N 13 \N \N 36000.00 \N \N \N \N 750 7 29 jsmith 4 2 I 13 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 751 7 29 jsmith 5 2 I 14 \N 3000.00 \N \N \N \N \N \N \N \N 13 \N \N 3000.00 \N \N \N \N 752 7 29 jsmith 6 2 I 15 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 753 7 29 jsmith 7 2 I 16 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 754 7 29 jsmith 8 2 I 17 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 755 7 29 jsmith 9 2 I 18 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 756 7 29 jsmith 11 2 I 20 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 757 7 29 jsmith 12 2 I 21 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 758 7 29 jsmith 13 2 I 22 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 759 7 29 jsmith 15 1 G 14 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 0.00 \N \N \N \N 760 7 29 jsmith 16 2 I 23 \N 0.00 \N \N \N \N \N \N \N \N 14 \N \N 0.00 \N \N \N \N 761 7 29 jsmith 18 1 G 15 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 0.00 \N \N \N \N 762 7 29 jsmith 21 0 G 16 0.00 39000.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 25000.00 \N \N \N \N 763 7 29 jsmith 22 1 G 17 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 16 0.00 \N 0.00 \N \N \N \N 764 7 29 jsmith 23 2 G 18 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 0.00 \N 0.00 \N \N \N \N 765 7 29 jsmith 24 3 I 24 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 766 7 29 jsmith 25 3 I 25 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 767 7 29 jsmith 26 3 I 26 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 768 7 29 jsmith 27 3 I 27 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 769 7 29 jsmith 28 3 I 28 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 770 7 29 jsmith 29 3 I 29 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 771 7 29 jsmith 31 2 G 20 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 0.00 \N 0.00 \N \N \N \N 772 7 29 jsmith 34 1 G 21 0.00 39000.00 0.00 0.00 0.00 \N \N \N \N \N 16 0.00 \N 25000.00 \N \N \N \N 773 7 29 jsmith 35 2 G 22 0.00 20000.00 0.00 0.00 0.00 \N \N \N \N \N 21 0.00 \N 20000.00 \N \N \N \N 774 7 29 jsmith 36 3 I 30 \N 20000.00 \N \N \N \N \N \N \N \N 22 \N \N 20000.00 \N \N \N \N 775 7 29 jsmith 38 2 G 23 \N 14000.00 \N \N \N \N \N \N \N \N 21 \N \N 0.00 \N \N \N \N 776 7 29 jsmith 39 2 G 24 0.00 5000.00 0.00 0.00 0.00 \N \N \N \N \N 21 0.00 \N 5000.00 \N \N \N \N 777 7 29 jsmith 40 3 I 31 \N 5000.00 \N \N \N \N \N \N \N \N 24 \N \N 5000.00 \N \N \N \N 778 7 29 jsmith 41 3 I 45 \N 0.00 \N \N \N \N \N \N \N \N 24 \N \N 0.00 \N \N \N \N 779 7 29 jsmith 14 2 T -1 \N 39000.00 \N \N \N \N \N \N \N \N 13 \N \N 39000.00 \N \N \N \N 780 7 29 jsmith 17 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 14 \N \N 0.00 \N \N \N \N 781 7 29 jsmith 19 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 15 \N \N 0.00 \N \N \N \N 782 7 29 jsmith 20 1 T -1 \N 39000.00 \N \N \N \N \N \N \N \N 12 \N \N 39000.00 \N \N \N \N 783 7 29 jsmith 30 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 784 7 29 jsmith 32 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 20 \N \N 0.00 \N \N \N \N 785 7 29 jsmith 33 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 17 \N \N 0.00 \N \N \N \N 786 7 29 jsmith 37 3 T -1 \N 20000.00 \N \N \N \N \N \N \N \N 22 \N \N 20000.00 \N \N \N \N 787 7 29 jsmith 42 3 T -1 \N 5000.00 \N \N \N \N \N \N \N \N 24 \N \N 5000.00 \N \N \N \N 788 7 29 jsmith 43 2 T -1 \N 39000.00 \N \N \N \N \N \N \N \N 21 \N \N 25000.00 \N \N \N \N 789 7 29 jsmith 44 1 T -1 \N 39000.00 \N \N \N \N \N \N \N \N 16 \N \N 25000.00 \N \N \N \N 790 7 29 jsmith 45 0 T -1 \N 0.00 \N \N \N \N \N \N \N \N \N 0.00 \N 14000.00 \N \N \N \N 791 7 28 jsmith 1 0 G 12 0.00 1043286.24 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 1043286.24 \N \N \N \N 792 7 28 jsmith 2 1 G 13 0.00 1043286.24 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 1043286.24 \N \N \N \N 793 7 28 jsmith 3 2 I 12 \N 1027222.11 \N \N \N \N \N \N \N \N 13 \N \N 1027222.11 \N \N \N \N 794 7 28 jsmith 4 2 I 13 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 795 7 28 jsmith 5 2 I 14 \N 22195.81 \N \N \N \N \N \N \N \N 13 \N \N 22195.81 \N \N \N \N 796 7 28 jsmith 6 2 I 15 \N -1.06 \N \N \N \N \N \N \N \N 13 \N \N -1.06 \N \N \N \N 797 7 28 jsmith 7 2 I 16 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 798 7 28 jsmith 8 2 I 17 \N -76.85 \N \N \N \N \N \N \N \N 13 \N \N -76.85 \N \N \N \N 799 7 28 jsmith 9 2 I 18 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 800 7 28 jsmith 10 2 I 19 \N -6053.79 \N \N \N \N \N \N \N \N 13 \N \N -6053.79 \N \N \N \N 801 7 28 jsmith 11 2 I 20 \N 0.02 \N \N \N \N \N \N \N \N 13 \N \N 0.02 \N \N \N \N 802 7 28 jsmith 12 2 I 21 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 803 7 28 jsmith 13 2 I 22 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 804 7 28 jsmith 15 1 G 14 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 0.00 \N \N \N \N 805 7 28 jsmith 16 2 I 23 \N 0.00 \N \N \N \N \N \N \N \N 14 \N \N 0.00 \N \N \N \N 806 7 28 jsmith 18 1 G 15 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 0.00 \N \N \N \N 807 7 28 jsmith 21 0 G 16 0.00 1043286.24 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 1029286.24 \N \N \N \N 808 11 39 jsmith 13 2 I 75 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 895 7 28 jsmith 22 1 G 17 0.00 829.11 0.00 0.00 0.00 \N \N \N \N \N 16 0.00 \N 829.11 \N \N \N \N 809 7 28 jsmith 23 2 G 18 0.00 829.11 0.00 0.00 0.00 \N \N \N \N \N 17 0.00 \N 829.11 \N \N \N \N 810 7 28 jsmith 24 3 I 24 \N 250.00 \N \N \N \N \N \N \N \N 18 \N \N 250.00 \N \N \N \N 811 7 28 jsmith 25 3 I 25 \N 151.99 \N \N \N \N \N \N \N \N 18 \N \N 151.99 \N \N \N \N 812 7 28 jsmith 26 3 I 26 \N 0.00 \N \N \N \N \N \N \N \N 18 \N \N 0.00 \N \N \N \N 813 7 28 jsmith 27 3 I 27 \N 216.74 \N \N \N \N \N \N \N \N 18 \N \N 216.74 \N \N \N \N 814 7 28 jsmith 28 3 I 28 \N 238.77 \N \N \N \N \N \N \N \N 18 \N \N 238.77 \N \N \N \N 815 7 28 jsmith 29 3 I 29 \N -28.39 \N \N \N \N \N \N \N \N 18 \N \N -28.39 \N \N \N \N 816 7 28 jsmith 31 2 G 20 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 0.00 \N 0.00 \N \N \N \N 817 7 28 jsmith 34 1 G 21 0.00 1042457.13 0.00 0.00 0.00 \N \N \N \N \N 16 0.00 \N 1028457.13 \N \N \N \N 818 7 28 jsmith 35 2 G 22 0.00 1020000.00 0.00 0.00 0.00 \N \N \N \N \N 21 0.00 \N 1020000.00 \N \N \N \N 819 7 28 jsmith 36 3 I 30 \N 1020000.00 \N \N \N \N \N \N \N \N 22 \N \N 1020000.00 \N \N \N \N 820 7 28 jsmith 38 2 G 23 \N 17457.13 \N \N \N \N \N \N \N \N 21 \N \N 3457.13 \N \N \N \N 821 7 28 jsmith 39 2 G 24 0.00 5000.00 0.00 0.00 0.00 \N \N \N \N \N 21 0.00 \N 5000.00 \N \N \N \N 822 7 28 jsmith 40 3 I 31 \N 5000.00 \N \N \N \N \N \N \N \N 24 \N \N 5000.00 \N \N \N \N 823 7 28 jsmith 41 3 I 45 \N 0.00 \N \N \N \N \N \N \N \N 24 \N \N 0.00 \N \N \N \N 824 7 28 jsmith 14 2 T -1 \N 1043286.24 \N \N \N \N \N \N \N \N 13 \N \N 1043286.24 \N \N \N \N 825 7 28 jsmith 17 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 14 \N \N 0.00 \N \N \N \N 826 7 28 jsmith 19 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 15 \N \N 0.00 \N \N \N \N 827 7 28 jsmith 20 1 T -1 \N 1043286.24 \N \N \N \N \N \N \N \N 12 \N \N 1043286.24 \N \N \N \N 828 7 28 jsmith 30 3 T -1 \N 829.11 \N \N \N \N \N \N \N \N 18 \N \N 829.11 \N \N \N \N 829 7 28 jsmith 32 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 20 \N \N 0.00 \N \N \N \N 830 7 28 jsmith 33 2 T -1 \N 829.11 \N \N \N \N \N \N \N \N 17 \N \N 829.11 \N \N \N \N 831 7 28 jsmith 37 3 T -1 \N 1020000.00 \N \N \N \N \N \N \N \N 22 \N \N 1020000.00 \N \N \N \N 832 7 28 jsmith 42 3 T -1 \N 5000.00 \N \N \N \N \N \N \N \N 24 \N \N 5000.00 \N \N \N \N 833 7 28 jsmith 43 2 T -1 \N 1042457.13 \N \N \N \N \N \N \N \N 21 \N \N 1028457.13 \N \N \N \N 834 7 28 jsmith 44 1 T -1 \N 1043286.24 \N \N \N \N \N \N \N \N 16 \N \N 1029286.24 \N \N \N \N 835 7 28 jsmith 45 0 T -1 \N 0.00 \N \N \N \N \N \N \N \N \N 0.00 \N 14000.00 \N \N \N \N 836 7 30 jsmith 4 2 I 13 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 837 7 30 jsmith 1 0 G 12 0.00 1046057.66 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 1046057.66 \N \N \N \N 838 7 30 jsmith 2 1 G 13 0.00 1046057.66 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 1046057.66 \N \N \N \N 839 7 30 jsmith 3 2 I 12 \N 1030080.94 \N \N \N \N \N \N \N \N 13 \N \N 1030080.94 \N \N \N \N 840 7 30 jsmith 5 2 I 14 \N 70516.91 \N \N \N \N \N \N \N \N 13 \N \N 70516.91 \N \N \N \N 841 7 30 jsmith 6 2 I 15 \N -1.03 \N \N \N \N \N \N \N \N 13 \N \N -1.03 \N \N \N \N 842 7 30 jsmith 7 2 I 16 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 843 7 30 jsmith 8 2 I 17 \N -48695.01 \N \N \N \N \N \N \N \N 13 \N \N -48695.01 \N \N \N \N 844 7 30 jsmith 9 2 I 18 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 845 7 30 jsmith 10 2 I 19 \N -5868.79 \N \N \N \N \N \N \N \N 13 \N \N -5868.79 \N \N \N \N 846 7 30 jsmith 11 2 I 20 \N 24.64 \N \N \N \N \N \N \N \N 13 \N \N 24.64 \N \N \N \N 847 7 30 jsmith 12 2 I 21 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 848 7 30 jsmith 13 2 I 22 \N 0.00 \N \N \N \N \N \N \N \N 13 \N \N 0.00 \N \N \N \N 849 7 30 jsmith 15 1 G 14 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 0.00 \N \N \N \N 850 7 30 jsmith 16 2 I 23 \N 0.00 \N \N \N \N \N \N \N \N 14 \N \N 0.00 \N \N \N \N 851 7 30 jsmith 18 1 G 15 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 12 0.00 \N 0.00 \N \N \N \N 852 7 30 jsmith 21 0 G 16 0.00 1046057.66 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 1046057.66 \N \N \N \N 853 7 30 jsmith 22 1 G 17 0.00 726.06 0.00 0.00 0.00 \N \N \N \N \N 16 0.00 \N 726.06 \N \N \N \N 854 7 30 jsmith 23 2 G 18 0.00 726.06 0.00 0.00 0.00 \N \N \N \N \N 17 0.00 \N 726.06 \N \N \N \N 855 7 30 jsmith 24 3 I 24 \N -0.40 \N \N \N \N \N \N \N \N 18 \N \N -0.40 \N \N \N \N 856 7 30 jsmith 25 3 I 25 \N 215.73 \N \N \N \N \N \N \N \N 18 \N \N 215.73 \N \N \N \N 857 7 30 jsmith 26 3 I 26 \N -125.00 \N \N \N \N \N \N \N \N 18 \N \N -125.00 \N \N \N \N 858 7 30 jsmith 27 3 I 27 \N 335.48 \N \N \N \N \N \N \N \N 18 \N \N 335.48 \N \N \N \N 859 7 30 jsmith 28 3 I 28 \N 351.14 \N \N \N \N \N \N \N \N 18 \N \N 351.14 \N \N \N \N 860 7 30 jsmith 29 3 I 29 \N -50.89 \N \N \N \N \N \N \N \N 18 \N \N -50.89 \N \N \N \N 861 7 30 jsmith 31 2 G 20 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 17 0.00 \N 0.00 \N \N \N \N 862 7 30 jsmith 34 1 G 21 0.00 1045331.60 0.00 0.00 0.00 \N \N \N \N \N 16 0.00 \N 1045331.60 \N \N \N \N 863 7 30 jsmith 35 2 G 22 0.00 1020000.00 0.00 0.00 0.00 \N \N \N \N \N 21 0.00 \N 1020000.00 \N \N \N \N 864 7 30 jsmith 36 3 I 30 \N 1020000.00 \N \N \N \N \N \N \N \N 22 \N \N 1020000.00 \N \N \N \N 865 7 30 jsmith 38 2 G 23 \N 2874.47 \N \N \N \N \N \N \N \N 21 \N \N 2874.47 \N \N \N \N 866 11 38 mfgadmin 34 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N Total Long Term Liabilities \N \N 867 7 30 jsmith 39 2 G 24 0.00 22457.13 0.00 0.00 0.00 \N \N \N \N \N 21 0.00 \N 22457.13 \N \N \N \N 868 7 30 jsmith 40 3 I 31 \N 22457.13 \N \N \N \N \N \N \N \N 24 \N \N 22457.13 \N \N \N \N 869 7 30 jsmith 41 3 I 45 \N 0.00 \N \N \N \N \N \N \N \N 24 \N \N 0.00 \N \N \N \N 870 7 30 jsmith 14 2 T -1 \N 1046057.66 \N \N \N \N \N \N \N \N 13 \N \N 1046057.66 \N \N \N \N 871 7 30 jsmith 17 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 14 \N \N 0.00 \N \N \N \N 872 7 30 jsmith 19 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 15 \N \N 0.00 \N \N \N \N 873 7 30 jsmith 20 1 T -1 \N 1046057.66 \N \N \N \N \N \N \N \N 12 \N \N 1046057.66 \N \N \N \N 874 7 30 jsmith 30 3 T -1 \N 726.06 \N \N \N \N \N \N \N \N 18 \N \N 726.06 \N \N \N \N 875 7 30 jsmith 32 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 20 \N \N 0.00 \N \N \N \N 876 7 30 jsmith 33 2 T -1 \N 726.06 \N \N \N \N \N \N \N \N 17 \N \N 726.06 \N \N \N \N 877 7 30 jsmith 37 3 T -1 \N 1020000.00 \N \N \N \N \N \N \N \N 22 \N \N 1020000.00 \N \N \N \N 878 7 30 jsmith 42 3 T -1 \N 22457.13 \N \N \N \N \N \N \N \N 24 \N \N 22457.13 \N \N \N \N 879 7 30 jsmith 43 2 T -1 \N 1045331.60 \N \N \N \N \N \N \N \N 21 \N \N 1045331.60 \N \N \N \N 880 7 30 jsmith 44 1 T -1 \N 1046057.66 \N \N \N \N \N \N \N \N 16 \N \N 1046057.66 \N \N \N \N 881 7 30 jsmith 45 0 T -1 \N 0.00 \N \N \N \N \N \N \N \N \N 0.00 \N 0.00 \N \N \N \N 882 11 39 jsmith 1 0 G 44 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 883 11 39 jsmith 2 1 G 45 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 884 11 39 jsmith 3 2 I 65 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 885 11 39 jsmith 4 2 I 66 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 886 11 39 jsmith 5 2 I 67 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 887 11 39 jsmith 6 2 I 68 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 888 11 39 jsmith 7 2 I 69 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 889 11 39 jsmith 8 2 I 70 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 890 11 39 jsmith 9 2 I 71 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 891 11 39 jsmith 10 2 I 72 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 892 11 39 jsmith 11 2 I 73 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 893 11 39 jsmith 12 2 I 74 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 894 11 39 jsmith 15 1 G 46 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 896 11 39 jsmith 16 2 I 76 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 897 11 39 jsmith 18 1 G 47 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 898 11 39 jsmith 21 0 G 36 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 899 11 39 jsmith 22 1 G 37 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 0.00 \N \N \N \N 900 11 39 jsmith 23 2 G 38 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 901 11 39 jsmith 24 3 I 47 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 902 11 39 jsmith 25 3 I 46 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 903 11 39 jsmith 26 3 I 48 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 904 11 39 jsmith 27 3 I 49 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 905 11 39 jsmith 28 3 I 50 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 906 11 39 jsmith 29 3 I 51 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 907 11 39 jsmith 31 2 G 39 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 908 11 39 jsmith 32 3 I 140 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N \N \N \N 909 11 39 jsmith 35 1 G 40 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 0.00 \N \N \N \N 910 11 39 jsmith 36 2 G 41 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 0.00 \N \N \N \N 911 11 39 jsmith 37 3 I 52 \N 0.00 \N \N \N \N \N \N \N \N 41 \N \N 0.00 \N \N \N \N 912 11 39 jsmith 39 2 G 42 \N 0.00 \N \N \N \N \N \N \N \N 40 \N \N 0.00 \N \N \N \N 913 11 39 jsmith 40 2 G 43 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 0.00 \N \N \N \N 914 11 39 jsmith 41 3 I 63 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 915 11 39 jsmith 42 3 I 64 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 916 11 39 jsmith 20 1 T -1 \N 0.00 \N \N \N \N \N \N \N \N 44 \N \N 0.00 \N \N \N \N 917 11 39 jsmith 14 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 918 11 39 jsmith 17 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 919 11 39 jsmith 19 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 47 \N \N 0.00 \N \N \N \N 920 11 39 jsmith 45 1 T -1 \N 0.00 \N \N \N \N \N \N \N \N 36 \N \N 0.00 \N \N \N \N 921 11 39 jsmith 34 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 37 \N \N 0.00 \N \N \N \N 922 11 39 jsmith 30 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 923 11 39 jsmith 33 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N \N \N \N 924 11 39 jsmith 44 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 40 \N \N 0.00 \N \N \N \N 925 11 39 jsmith 38 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 41 \N \N 0.00 \N \N \N \N 926 11 39 jsmith 43 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 927 11 39 jsmith 46 0 T -1 \N 0.00 \N \N \N \N \N \N \N \N \N \N \N 0.00 \N \N \N \N 928 11 34 jsmith 1 0 G 44 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 929 11 34 jsmith 2 1 G 45 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 930 11 34 jsmith 3 2 I 65 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 931 11 34 jsmith 4 2 I 66 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 932 11 34 jsmith 5 2 I 67 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 933 11 34 jsmith 6 2 I 68 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 934 11 34 jsmith 7 2 I 69 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 935 11 34 jsmith 8 2 I 70 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 936 11 34 jsmith 9 2 I 71 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 937 11 34 jsmith 10 2 I 72 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 938 11 34 jsmith 11 2 I 73 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 939 11 34 jsmith 12 2 I 74 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 940 11 34 jsmith 13 2 I 75 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 941 11 34 jsmith 15 1 G 46 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 942 11 34 jsmith 16 2 I 76 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 943 11 34 jsmith 18 1 G 47 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 944 11 34 jsmith 21 0 G 36 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 945 11 34 jsmith 22 1 G 37 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 0.00 \N \N \N \N 946 11 34 jsmith 23 2 G 38 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 947 11 34 jsmith 24 3 I 47 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 948 11 34 jsmith 25 3 I 46 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 949 11 34 jsmith 26 3 I 48 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 950 11 34 jsmith 27 3 I 49 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 951 11 34 jsmith 28 3 I 50 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 952 11 34 jsmith 29 3 I 51 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 953 11 34 jsmith 31 2 G 39 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 954 11 34 jsmith 32 3 I 140 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N \N \N \N 955 11 34 jsmith 35 1 G 40 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 0.00 \N \N \N \N 956 11 34 jsmith 36 2 G 41 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 0.00 \N \N \N \N 957 11 34 jsmith 37 3 I 52 \N 0.00 \N \N \N \N \N \N \N \N 41 \N \N 0.00 \N \N \N \N 958 11 34 jsmith 39 2 G 42 \N 0.00 \N \N \N \N \N \N \N \N 40 \N \N 0.00 \N \N \N \N 959 11 34 jsmith 40 2 G 43 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 0.00 \N \N \N \N 960 11 34 jsmith 41 3 I 63 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 961 11 34 jsmith 42 3 I 64 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 962 11 34 jsmith 14 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 963 11 34 jsmith 17 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 964 11 34 jsmith 19 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 47 \N \N 0.00 \N \N \N \N 965 11 34 jsmith 20 1 T -1 \N 0.00 \N \N \N \N \N \N \N \N 44 \N \N 0.00 \N \N \N \N 966 11 34 jsmith 30 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 967 11 34 jsmith 33 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N \N \N \N 968 11 34 jsmith 34 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 37 \N \N 0.00 \N \N \N \N 969 11 34 jsmith 38 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 41 \N \N 0.00 \N \N \N \N 970 11 34 jsmith 43 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 971 11 34 jsmith 44 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 40 \N \N 0.00 \N \N \N \N 972 11 34 jsmith 45 1 T -1 \N 0.00 \N \N \N \N \N \N \N \N 36 \N \N 0.00 \N \N \N \N 973 11 34 jsmith 46 0 T -1 \N 0.00 \N \N \N \N \N \N \N \N \N \N \N 0.00 \N \N \N \N 974 11 35 jsmith 1 0 G 44 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 975 11 35 jsmith 2 1 G 45 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 976 11 35 jsmith 3 2 I 65 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 977 11 35 jsmith 4 2 I 66 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 978 11 35 jsmith 5 2 I 67 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 979 11 35 jsmith 6 2 I 68 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 980 11 35 jsmith 7 2 I 69 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 981 11 35 jsmith 8 2 I 70 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 982 11 35 jsmith 9 2 I 71 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 983 11 35 jsmith 10 2 I 72 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 984 11 35 jsmith 11 2 I 73 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 985 11 35 jsmith 12 2 I 74 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 986 11 35 jsmith 13 2 I 75 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 987 11 35 jsmith 15 1 G 46 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 988 11 35 jsmith 16 2 I 76 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 989 11 35 jsmith 18 1 G 47 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 990 11 35 jsmith 21 0 G 36 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 991 11 35 jsmith 22 1 G 37 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 0.00 \N \N \N \N 992 11 35 jsmith 23 2 G 38 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 993 11 35 jsmith 24 3 I 47 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 994 11 35 jsmith 25 3 I 46 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 995 11 35 jsmith 26 3 I 48 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 996 11 35 jsmith 27 3 I 49 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 997 11 35 jsmith 28 3 I 50 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 998 11 35 jsmith 29 3 I 51 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 999 11 35 jsmith 31 2 G 39 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 1000 11 35 jsmith 32 3 I 140 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N \N \N \N 1001 11 35 jsmith 35 1 G 40 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 0.00 \N \N \N \N 1002 11 35 jsmith 36 2 G 41 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 0.00 \N \N \N \N 1003 11 35 jsmith 37 3 I 52 \N 0.00 \N \N \N \N \N \N \N \N 41 \N \N 0.00 \N \N \N \N 1004 11 35 jsmith 39 2 G 42 \N 0.00 \N \N \N \N \N \N \N \N 40 \N \N 0.00 \N \N \N \N 1005 11 35 jsmith 40 2 G 43 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 0.00 \N \N \N \N 1006 11 35 jsmith 41 3 I 63 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 1007 11 35 jsmith 42 3 I 64 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 1008 11 35 jsmith 14 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1009 11 35 jsmith 17 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 1010 11 35 jsmith 19 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 47 \N \N 0.00 \N \N \N \N 1011 11 35 jsmith 20 1 T -1 \N 0.00 \N \N \N \N \N \N \N \N 44 \N \N 0.00 \N \N \N \N 1012 11 35 jsmith 30 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1013 11 35 jsmith 33 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N \N \N \N 1014 11 35 jsmith 34 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 37 \N \N 0.00 \N \N \N \N 1015 11 35 jsmith 38 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 41 \N \N 0.00 \N \N \N \N 1016 11 35 jsmith 43 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 1017 11 35 jsmith 44 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 40 \N \N 0.00 \N \N \N \N 1018 11 35 jsmith 45 1 T -1 \N 0.00 \N \N \N \N \N \N \N \N 36 \N \N 0.00 \N \N \N \N 1019 11 35 jsmith 46 0 T -1 \N 0.00 \N \N \N \N \N \N \N \N \N \N \N 0.00 \N \N \N \N 1020 11 47 jsmith 1 0 G 44 0.00 15000.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 15000.00 \N \N \N \N 1021 11 47 jsmith 2 1 G 45 0.00 15000.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 15000.00 \N \N \N \N 1022 11 47 jsmith 3 2 I 65 \N 8000.00 \N \N \N \N \N \N \N \N 45 \N \N 8000.00 \N \N \N \N 1023 11 47 jsmith 4 2 I 66 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1024 11 47 jsmith 5 2 I 67 \N 7000.00 \N \N \N \N \N \N \N \N 45 \N \N 7000.00 \N \N \N \N 1025 11 47 jsmith 6 2 I 68 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1026 11 47 jsmith 7 2 I 69 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1027 11 47 jsmith 8 2 I 70 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1028 11 47 jsmith 9 2 I 71 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1029 11 47 jsmith 10 2 I 72 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1030 11 47 jsmith 11 2 I 73 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1031 11 47 jsmith 12 2 I 74 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1032 11 47 jsmith 13 2 I 75 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1033 11 47 jsmith 15 1 G 46 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 1034 11 47 jsmith 16 2 I 76 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 1035 11 47 jsmith 18 1 G 47 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 1036 11 47 jsmith 21 0 G 36 0.00 15000.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 15000.00 \N \N \N \N 1037 11 47 jsmith 22 1 G 37 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 0.00 \N \N \N \N 1038 11 47 jsmith 23 2 G 38 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 1039 11 47 jsmith 24 3 I 47 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1040 11 47 jsmith 25 3 I 46 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1041 11 47 jsmith 26 3 I 48 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1042 11 47 jsmith 27 3 I 49 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1043 11 47 jsmith 28 3 I 50 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1044 11 47 jsmith 29 3 I 51 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1045 11 47 jsmith 30 3 I 215 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1046 11 47 jsmith 32 2 G 39 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 1047 11 47 jsmith 33 3 I 140 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N \N \N \N 1048 11 47 jsmith 36 1 G 40 0.00 15000.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 15000.00 \N \N \N \N 1049 11 47 jsmith 37 2 G 41 0.00 10000.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 10000.00 \N \N \N \N 1050 11 47 jsmith 38 3 I 52 \N 10000.00 \N \N \N \N \N \N \N \N 41 \N \N 10000.00 \N \N \N \N 1051 11 47 jsmith 40 2 G 42 \N 5000.00 \N \N \N \N \N \N \N \N 40 \N \N 5000.00 \N \N \N \N 1052 11 47 jsmith 41 2 G 43 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 0.00 \N \N \N \N 1053 11 47 jsmith 42 3 I 63 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 1054 11 47 jsmith 43 3 I 64 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 1055 11 47 jsmith 14 2 T -1 \N 15000.00 \N \N \N \N \N \N \N \N 45 \N \N 15000.00 \N \N \N \N 1056 11 47 jsmith 17 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 1057 11 47 jsmith 19 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 47 \N \N 0.00 \N \N \N \N 1058 11 47 jsmith 20 1 T -1 \N 15000.00 \N \N \N \N \N \N \N \N 44 \N \N 15000.00 \N \N \N \N 1059 11 47 jsmith 31 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1060 11 47 jsmith 34 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N \N \N \N 1061 11 47 jsmith 35 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 37 \N \N 0.00 \N \N \N \N 1062 11 47 jsmith 39 3 T -1 \N 10000.00 \N \N \N \N \N \N \N \N 41 \N \N 10000.00 \N \N \N \N 1063 11 47 jsmith 44 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 1064 11 47 jsmith 45 2 T -1 \N 15000.00 \N \N \N \N \N \N \N \N 40 \N \N 15000.00 \N \N \N \N 1065 11 47 jsmith 46 1 T -1 \N 15000.00 \N \N \N \N \N \N \N \N 36 \N \N 15000.00 \N \N \N \N 1066 11 47 jsmith 47 0 T -1 \N 0.00 \N \N \N \N \N \N \N \N \N \N \N 0.00 \N \N \N \N 1067 11 48 jsmith 1 0 G 44 0.00 18000.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 18000.00 \N \N \N \N 1068 11 48 jsmith 2 1 G 45 0.00 18000.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 18000.00 \N \N \N \N 1069 11 48 jsmith 3 2 I 65 \N 14000.00 \N \N \N \N \N \N \N \N 45 \N \N 14000.00 \N \N \N \N 1070 11 48 jsmith 4 2 I 66 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1071 11 48 jsmith 5 2 I 67 \N 4000.00 \N \N \N \N \N \N \N \N 45 \N \N 4000.00 \N \N \N \N 1072 11 48 jsmith 6 2 I 68 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1073 11 48 jsmith 7 2 I 69 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1074 11 48 jsmith 8 2 I 70 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1075 11 48 jsmith 9 2 I 71 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1076 11 48 jsmith 10 2 I 72 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1077 11 48 jsmith 11 2 I 73 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1078 11 48 jsmith 12 2 I 74 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1079 11 48 jsmith 13 2 I 75 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1080 11 48 jsmith 15 1 G 46 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 1081 11 48 jsmith 16 2 I 76 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 1082 11 48 jsmith 18 1 G 47 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 1083 11 48 jsmith 21 0 G 36 0.00 18000.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 18000.00 \N \N \N \N 1084 11 48 jsmith 22 1 G 37 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 0.00 \N \N \N \N 1085 11 48 jsmith 23 2 G 38 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 1086 11 48 jsmith 24 3 I 47 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1087 11 48 jsmith 25 3 I 46 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1088 11 48 jsmith 26 3 I 48 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1089 11 48 jsmith 27 3 I 49 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1090 11 48 jsmith 28 3 I 50 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1091 11 48 jsmith 29 3 I 51 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1092 11 48 jsmith 30 3 I 215 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1093 11 48 jsmith 32 2 G 39 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 1094 11 48 jsmith 33 3 I 140 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N \N \N \N 1095 11 48 jsmith 36 1 G 40 0.00 18000.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 18000.00 \N \N \N \N 1096 11 48 jsmith 37 2 G 41 0.00 10000.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 10000.00 \N \N \N \N 1097 11 48 jsmith 38 3 I 52 \N 10000.00 \N \N \N \N \N \N \N \N 41 \N \N 10000.00 \N \N \N \N 1098 11 48 jsmith 40 2 G 42 \N 3000.00 \N \N \N \N \N \N \N \N 40 \N \N 3000.00 \N \N \N \N 1099 11 48 jsmith 41 2 G 43 0.00 5000.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 5000.00 \N \N \N \N 1100 11 48 jsmith 42 3 I 63 \N 5000.00 \N \N \N \N \N \N \N \N 43 \N \N 5000.00 \N \N \N \N 1101 11 48 jsmith 43 3 I 64 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 1102 11 48 jsmith 14 2 T -1 \N 18000.00 \N \N \N \N \N \N \N \N 45 \N \N 18000.00 \N \N \N \N 1103 11 48 jsmith 17 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 1104 11 48 jsmith 19 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 47 \N \N 0.00 \N \N \N \N 1105 11 48 jsmith 20 1 T -1 \N 18000.00 \N \N \N \N \N \N \N \N 44 \N \N 18000.00 \N \N \N \N 1106 11 48 jsmith 31 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1107 11 48 jsmith 34 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N \N \N \N 1108 11 48 jsmith 35 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 37 \N \N 0.00 \N \N \N \N 1109 11 48 jsmith 39 3 T -1 \N 10000.00 \N \N \N \N \N \N \N \N 41 \N \N 10000.00 \N \N \N \N 1110 11 48 jsmith 44 3 T -1 \N 5000.00 \N \N \N \N \N \N \N \N 43 \N \N 5000.00 \N \N \N \N 1111 11 48 jsmith 45 2 T -1 \N 18000.00 \N \N \N \N \N \N \N \N 40 \N \N 18000.00 \N \N \N \N 1112 11 48 jsmith 46 1 T -1 \N 18000.00 \N \N \N \N \N \N \N \N 36 \N \N 18000.00 \N \N \N \N 1113 11 48 jsmith 47 0 T -1 \N 0.00 \N \N \N \N \N \N \N \N \N \N \N 0.00 \N \N \N \N 1114 11 46 jsmith 1 0 G 44 0.00 39000.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 39000.00 \N \N \N \N 1115 11 46 jsmith 2 1 G 45 0.00 39000.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 39000.00 \N \N \N \N 1116 11 46 jsmith 3 2 I 65 \N 36000.00 \N \N \N \N \N \N \N \N 45 \N \N 36000.00 \N \N \N \N 1117 11 46 jsmith 4 2 I 66 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1118 11 46 jsmith 5 2 I 67 \N 3000.00 \N \N \N \N \N \N \N \N 45 \N \N 3000.00 \N \N \N \N 1119 11 46 jsmith 6 2 I 68 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1120 11 46 jsmith 7 2 I 69 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1121 11 46 jsmith 8 2 I 70 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1122 11 46 jsmith 9 2 I 71 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1123 11 46 jsmith 10 2 I 72 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1124 11 46 jsmith 11 2 I 73 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1125 11 46 jsmith 12 2 I 74 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1126 11 46 jsmith 13 2 I 75 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1127 11 46 jsmith 15 1 G 46 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 1128 11 46 jsmith 16 2 I 76 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 1129 11 46 jsmith 18 1 G 47 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 1130 11 46 jsmith 21 0 G 36 0.00 39000.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 39000.00 \N \N \N \N 1131 11 46 jsmith 22 1 G 37 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 0.00 \N \N \N \N 1132 11 46 jsmith 23 2 G 38 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 1133 11 46 jsmith 24 3 I 47 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1134 11 46 jsmith 25 3 I 46 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1135 11 46 jsmith 26 3 I 48 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1136 11 46 jsmith 27 3 I 49 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1137 11 46 jsmith 28 3 I 50 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1138 11 46 jsmith 29 3 I 51 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1139 11 46 jsmith 30 3 I 215 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1140 11 46 jsmith 32 2 G 39 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 1141 11 46 jsmith 33 3 I 140 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N \N \N \N 1142 11 46 jsmith 36 1 G 40 0.00 39000.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 39000.00 \N \N \N \N 1143 11 46 jsmith 37 2 G 41 0.00 20000.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 20000.00 \N \N \N \N 1144 11 46 jsmith 38 3 I 52 \N 20000.00 \N \N \N \N \N \N \N \N 41 \N \N 20000.00 \N \N \N \N 1145 11 46 jsmith 40 2 G 42 \N 14000.00 \N \N \N \N \N \N \N \N 40 \N \N 14000.00 \N \N \N \N 1146 11 46 jsmith 41 2 G 43 0.00 5000.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 5000.00 \N \N \N \N 1147 11 46 jsmith 42 3 I 63 \N 5000.00 \N \N \N \N \N \N \N \N 43 \N \N 5000.00 \N \N \N \N 1148 11 46 jsmith 43 3 I 64 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 1149 11 46 jsmith 14 2 T -1 \N 39000.00 \N \N \N \N \N \N \N \N 45 \N \N 39000.00 \N \N \N \N 1150 11 46 jsmith 17 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 1151 11 46 jsmith 19 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 47 \N \N 0.00 \N \N \N \N 1152 11 46 jsmith 20 1 T -1 \N 39000.00 \N \N \N \N \N \N \N \N 44 \N \N 39000.00 \N \N \N \N 1153 11 46 jsmith 31 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1154 11 46 jsmith 34 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N \N \N \N 1155 11 46 jsmith 35 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 37 \N \N 0.00 \N \N \N \N 1156 11 46 jsmith 39 3 T -1 \N 20000.00 \N \N \N \N \N \N \N \N 41 \N \N 20000.00 \N \N \N \N 1157 11 46 jsmith 44 3 T -1 \N 5000.00 \N \N \N \N \N \N \N \N 43 \N \N 5000.00 \N \N \N \N 1158 11 46 jsmith 45 2 T -1 \N 39000.00 \N \N \N \N \N \N \N \N 40 \N \N 39000.00 \N \N \N \N 1159 11 46 jsmith 46 1 T -1 \N 39000.00 \N \N \N \N \N \N \N \N 36 \N \N 39000.00 \N \N \N \N 1160 11 46 jsmith 47 0 T -1 \N 0.00 \N \N \N \N \N \N \N \N \N \N \N 0.00 \N \N \N \N 1161 11 29 jsmith 1 0 G 44 0.00 40000.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 40000.00 \N \N \N \N 1162 11 29 jsmith 2 1 G 45 0.00 40000.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 40000.00 \N \N \N \N 1163 11 29 jsmith 3 2 I 65 \N 38000.00 \N \N \N \N \N \N \N \N 45 \N \N 38000.00 \N \N \N \N 1164 11 29 jsmith 4 2 I 66 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1165 11 29 jsmith 5 2 I 67 \N 2000.00 \N \N \N \N \N \N \N \N 45 \N \N 2000.00 \N \N \N \N 1166 11 29 jsmith 6 2 I 68 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1167 11 29 jsmith 7 2 I 69 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1168 11 29 jsmith 8 2 I 70 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1169 11 29 jsmith 9 2 I 71 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1170 11 29 jsmith 10 2 I 72 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1171 11 29 jsmith 11 2 I 73 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1172 11 29 jsmith 12 2 I 74 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1173 11 29 jsmith 13 2 I 75 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1174 11 29 jsmith 15 1 G 46 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 1175 11 29 jsmith 16 2 I 76 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 1176 11 29 jsmith 18 1 G 47 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 1177 11 29 jsmith 21 0 G 36 0.00 40000.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 40000.00 \N \N \N \N 1178 11 29 jsmith 22 1 G 37 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 0.00 \N \N \N \N 1179 11 29 jsmith 23 2 G 38 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 1180 11 29 jsmith 24 3 I 47 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1181 11 29 jsmith 25 3 I 46 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1182 11 29 jsmith 26 3 I 48 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1183 11 29 jsmith 27 3 I 49 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1184 11 29 jsmith 28 3 I 50 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1185 11 29 jsmith 29 3 I 51 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1186 11 29 jsmith 30 3 I 215 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1187 11 29 jsmith 32 2 G 39 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 1188 11 29 jsmith 33 3 I 140 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N \N \N \N 1189 11 29 jsmith 36 1 G 40 0.00 40000.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 40000.00 \N \N \N \N 1190 11 29 jsmith 37 2 G 41 0.00 20000.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 20000.00 \N \N \N \N 1191 11 29 jsmith 38 3 I 52 \N 20000.00 \N \N \N \N \N \N \N \N 41 \N \N 20000.00 \N \N \N \N 1192 11 29 jsmith 40 2 G 42 \N 15000.00 \N \N \N \N \N \N \N \N 40 \N \N 15000.00 \N \N \N \N 1193 11 29 jsmith 41 2 G 43 0.00 5000.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 5000.00 \N \N \N \N 1194 11 29 jsmith 42 3 I 63 \N 5000.00 \N \N \N \N \N \N \N \N 43 \N \N 5000.00 \N \N \N \N 1195 11 29 jsmith 43 3 I 64 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 1196 11 29 jsmith 14 2 T -1 \N 40000.00 \N \N \N \N \N \N \N \N 45 \N \N 40000.00 \N \N \N \N 1197 11 29 jsmith 17 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 1198 11 29 jsmith 19 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 47 \N \N 0.00 \N \N \N \N 1199 11 29 jsmith 20 1 T -1 \N 40000.00 \N \N \N \N \N \N \N \N 44 \N \N 40000.00 \N \N \N \N 1200 11 29 jsmith 31 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1201 11 29 jsmith 34 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N \N \N \N 1202 11 29 jsmith 35 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 37 \N \N 0.00 \N \N \N \N 1203 11 29 jsmith 39 3 T -1 \N 20000.00 \N \N \N \N \N \N \N \N 41 \N \N 20000.00 \N \N \N \N 1204 11 29 jsmith 44 3 T -1 \N 5000.00 \N \N \N \N \N \N \N \N 43 \N \N 5000.00 \N \N \N \N 1205 11 29 jsmith 45 2 T -1 \N 40000.00 \N \N \N \N \N \N \N \N 40 \N \N 40000.00 \N \N \N \N 1206 11 29 jsmith 46 1 T -1 \N 40000.00 \N \N \N \N \N \N \N \N 36 \N \N 40000.00 \N \N \N \N 1207 11 29 jsmith 47 0 T -1 \N 0.00 \N \N \N \N \N \N \N \N \N \N \N 0.00 \N \N \N \N 1208 11 28 jsmith 4 2 I 66 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1209 11 28 jsmith 1 0 G 44 0.00 1044286.24 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 1044286.24 \N \N \N \N 1210 11 28 jsmith 2 1 G 45 0.00 1044286.24 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 1044286.24 \N \N \N \N 1211 11 28 jsmith 3 2 I 65 \N 1029222.11 \N \N \N \N \N \N \N \N 45 \N \N 1029222.11 \N \N \N \N 1212 11 28 jsmith 5 2 I 67 \N 21195.81 \N \N \N \N \N \N \N \N 45 \N \N 21195.81 \N \N \N \N 1213 11 28 jsmith 6 2 I 68 \N -1.06 \N \N \N \N \N \N \N \N 45 \N \N -1.06 \N \N \N \N 1214 11 28 jsmith 7 2 I 69 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1215 11 28 jsmith 8 2 I 70 \N -76.85 \N \N \N \N \N \N \N \N 45 \N \N -76.85 \N \N \N \N 1216 11 28 jsmith 9 2 I 71 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1217 11 28 jsmith 10 2 I 72 \N -6053.79 \N \N \N \N \N \N \N \N 45 \N \N -6053.79 \N \N \N \N 1218 11 28 jsmith 11 2 I 73 \N 0.02 \N \N \N \N \N \N \N \N 45 \N \N 0.02 \N \N \N \N 1219 11 28 jsmith 12 2 I 74 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1220 11 28 jsmith 13 2 I 75 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1221 11 28 jsmith 15 1 G 46 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 1222 11 28 jsmith 16 2 I 76 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 1223 11 28 jsmith 18 1 G 47 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 1224 11 28 jsmith 21 0 G 36 0.00 1044286.24 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 1044286.24 \N \N \N \N 1225 11 28 jsmith 22 1 G 37 0.00 829.11 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 829.11 \N \N \N \N 1226 11 28 jsmith 23 2 G 38 0.00 829.11 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 829.11 \N \N \N \N 1227 11 28 jsmith 24 3 I 47 \N 250.00 \N \N \N \N \N \N \N \N 38 \N \N 250.00 \N \N \N \N 1228 11 28 jsmith 25 3 I 46 \N 151.99 \N \N \N \N \N \N \N \N 38 \N \N 151.99 \N \N \N \N 1229 11 28 jsmith 26 3 I 48 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1230 11 28 jsmith 27 3 I 49 \N 216.74 \N \N \N \N \N \N \N \N 38 \N \N 216.74 \N \N \N \N 1231 11 28 jsmith 28 3 I 50 \N 238.77 \N \N \N \N \N \N \N \N 38 \N \N 238.77 \N \N \N \N 1232 11 28 jsmith 29 3 I 51 \N -28.39 \N \N \N \N \N \N \N \N 38 \N \N -28.39 \N \N \N \N 1233 11 28 jsmith 30 3 I 215 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1234 11 28 jsmith 32 2 G 39 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 1235 11 28 jsmith 33 3 I 140 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N \N \N \N 1236 11 28 jsmith 36 1 G 40 0.00 1043457.13 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 1043457.13 \N \N \N \N 1237 11 28 jsmith 37 2 G 41 0.00 1020000.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 1020000.00 \N \N \N \N 1238 11 28 jsmith 38 3 I 52 \N 1020000.00 \N \N \N \N \N \N \N \N 41 \N \N 1020000.00 \N \N \N \N 1239 11 28 jsmith 40 2 G 42 \N 18457.13 \N \N \N \N \N \N \N \N 40 \N \N 18457.13 \N \N \N \N 1240 11 28 jsmith 41 2 G 43 0.00 5000.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 5000.00 \N \N \N \N 1241 11 28 jsmith 42 3 I 63 \N 5000.00 \N \N \N \N \N \N \N \N 43 \N \N 5000.00 \N \N \N \N 1242 11 28 jsmith 43 3 I 64 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 1243 11 28 jsmith 14 2 T -1 \N 1044286.24 \N \N \N \N \N \N \N \N 45 \N \N 1044286.24 \N \N \N \N 1244 11 28 jsmith 17 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 1245 11 28 jsmith 19 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 47 \N \N 0.00 \N \N \N \N 1246 11 28 jsmith 20 1 T -1 \N 1044286.24 \N \N \N \N \N \N \N \N 44 \N \N 1044286.24 \N \N \N \N 1247 11 28 jsmith 31 3 T -1 \N 829.11 \N \N \N \N \N \N \N \N 38 \N \N 829.11 \N \N \N \N 1248 11 28 jsmith 34 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N \N \N \N 1249 11 28 jsmith 35 2 T -1 \N 829.11 \N \N \N \N \N \N \N \N 37 \N \N 829.11 \N \N \N \N 1250 11 28 jsmith 39 3 T -1 \N 1020000.00 \N \N \N \N \N \N \N \N 41 \N \N 1020000.00 \N \N \N \N 1251 11 28 jsmith 44 3 T -1 \N 5000.00 \N \N \N \N \N \N \N \N 43 \N \N 5000.00 \N \N \N \N 1252 11 28 jsmith 45 2 T -1 \N 1043457.13 \N \N \N \N \N \N \N \N 40 \N \N 1043457.13 \N \N \N \N 1253 11 28 jsmith 46 1 T -1 \N 1044286.24 \N \N \N \N \N \N \N \N 36 \N \N 1044286.24 \N \N \N \N 1254 11 28 jsmith 47 0 T -1 \N 0.00 \N \N \N \N \N \N \N \N \N \N \N 0.00 \N \N \N \N 1255 11 30 jsmith 1 0 G 44 0.00 1053916.70 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 1053916.70 \N \N \N \N 1256 11 30 jsmith 2 1 G 45 0.00 1052916.70 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 1052916.70 \N \N \N \N 1257 11 30 jsmith 3 2 I 65 \N 1038296.40 \N \N \N \N \N \N \N \N 45 \N \N 1038296.40 \N \N \N \N 1258 11 30 jsmith 4 2 I 66 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1259 11 30 jsmith 5 2 I 67 \N 79945.44 \N \N \N \N \N \N \N \N 45 \N \N 79945.44 \N \N \N \N 1260 11 30 jsmith 6 2 I 68 \N -6.01 \N \N \N \N \N \N \N \N 45 \N \N -6.01 \N \N \N \N 1261 11 30 jsmith 7 2 I 69 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1262 11 30 jsmith 8 2 I 70 \N -59430.98 \N \N \N \N \N \N \N \N 45 \N \N -59430.98 \N \N \N \N 1263 11 30 jsmith 9 2 I 71 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1264 11 30 jsmith 10 2 I 72 \N -5912.79 \N \N \N \N \N \N \N \N 45 \N \N -5912.79 \N \N \N \N 1265 11 30 jsmith 11 2 I 73 \N 24.64 \N \N \N \N \N \N \N \N 45 \N \N 24.64 \N \N \N \N 1266 11 30 jsmith 12 2 I 74 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1267 11 30 jsmith 13 2 I 75 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1268 11 30 jsmith 15 1 G 46 0.00 1000.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 1000.00 \N \N \N \N 1269 11 30 jsmith 16 2 I 76 \N 1000.00 \N \N \N \N \N \N \N \N 46 \N \N 1000.00 \N \N \N \N 1270 11 30 jsmith 18 1 G 47 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 1271 11 30 jsmith 21 0 G 36 0.00 1053916.70 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 1053916.70 \N \N \N \N 1272 11 30 jsmith 22 1 G 37 0.00 5990.10 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 5990.10 \N \N \N \N 1273 11 30 jsmith 23 2 G 38 0.00 990.10 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 990.10 \N \N \N \N 1274 11 30 jsmith 24 3 I 47 \N -0.40 \N \N \N \N \N \N \N \N 38 \N \N -0.40 \N \N \N \N 1275 11 30 jsmith 25 3 I 46 \N 313.13 \N \N \N \N \N \N \N \N 38 \N \N 313.13 \N \N \N \N 1276 11 30 jsmith 26 3 I 48 \N -125.00 \N \N \N \N \N \N \N \N 38 \N \N -125.00 \N \N \N \N 1277 11 30 jsmith 27 3 I 49 \N 397.22 \N \N \N \N \N \N \N \N 38 \N \N 397.22 \N \N \N \N 1278 11 30 jsmith 28 3 I 50 \N 456.04 \N \N \N \N \N \N \N \N 38 \N \N 456.04 \N \N \N \N 1279 11 30 jsmith 29 3 I 51 \N -50.89 \N \N \N \N \N \N \N \N 38 \N \N -50.89 \N \N \N \N 1280 11 30 jsmith 30 3 I 215 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 1281 11 30 jsmith 32 2 G 39 0.00 5000.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 5000.00 \N \N \N \N 1282 11 30 jsmith 33 3 I 140 \N 5000.00 \N \N \N \N \N \N \N \N 39 \N \N 5000.00 \N \N \N \N 1283 11 30 jsmith 36 1 G 40 0.00 1047926.60 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 1047926.60 \N \N \N \N 1284 11 30 jsmith 37 2 G 41 0.00 1020000.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 1020000.00 \N \N \N \N 1285 11 30 jsmith 38 3 I 52 \N 1020000.00 \N \N \N \N \N \N \N \N 41 \N \N 1020000.00 \N \N \N \N 1286 11 30 jsmith 40 2 G 42 \N 4469.47 \N \N \N \N \N \N \N \N 40 \N \N 4469.47 \N \N \N \N 1287 11 30 jsmith 41 2 G 43 0.00 23457.13 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 23457.13 \N \N \N \N 1288 11 30 jsmith 42 3 I 63 \N 23457.13 \N \N \N \N \N \N \N \N 43 \N \N 23457.13 \N \N \N \N 1289 11 30 jsmith 43 3 I 64 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 1290 11 30 jsmith 14 2 T -1 \N 1052916.70 \N \N \N \N \N \N \N \N 45 \N \N 1052916.70 \N \N \N \N 1291 11 30 jsmith 17 2 T -1 \N 1000.00 \N \N \N \N \N \N \N \N 46 \N \N 1000.00 \N \N \N \N 1292 11 30 jsmith 19 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 47 \N \N 0.00 \N \N \N \N 1293 11 30 jsmith 20 1 T -1 \N 1053916.70 \N \N \N \N \N \N \N \N 44 \N \N 1053916.70 \N \N \N \N 1294 11 30 jsmith 31 3 T -1 \N 990.10 \N \N \N \N \N \N \N \N 38 \N \N 990.10 \N \N \N \N 1295 11 30 jsmith 34 3 T -1 \N 5000.00 \N \N \N \N \N \N \N \N 39 \N \N 5000.00 \N \N \N \N 1296 11 30 jsmith 35 2 T -1 \N 5990.10 \N \N \N \N \N \N \N \N 37 \N \N 5990.10 \N \N \N \N 1297 11 30 jsmith 39 3 T -1 \N 1020000.00 \N \N \N \N \N \N \N \N 41 \N \N 1020000.00 \N \N \N \N 1298 11 30 jsmith 44 3 T -1 \N 23457.13 \N \N \N \N \N \N \N \N 43 \N \N 23457.13 \N \N \N \N 1299 11 30 jsmith 45 2 T -1 \N 1047926.60 \N \N \N \N \N \N \N \N 40 \N \N 1047926.60 \N \N \N \N 1300 11 30 jsmith 46 1 T -1 \N 1053916.70 \N \N \N \N \N \N \N \N 36 \N \N 1053916.70 \N \N \N \N 1301 11 30 jsmith 47 0 T -1 \N 0.00 \N \N \N \N \N \N \N \N \N \N \N 0.00 \N \N \N \N 1302 4 47 jsmith 1 0 G 3 0.00 6000.00 0.00 0.00 0.00 \N 0.66666666666666666667 \N \N 0.00000000000000000000 -1 6000.00 0.66666666666666666667 6000.00 0.66666666666666666667 \N \N \N 1303 4 47 jsmith 2 1 G 4 0.00 9000.00 0.00 0.00 0.00 \N \N \N \N \N 3 9000.00 1.00000000000000000000 9000.00 1.00000000000000000000 \N \N \N 1304 4 47 jsmith 3 2 I 2 0.00 9000.00 \N \N 0.00 \N 1.00000000000000000000 \N \N 0.00000000000000000000 4 9000.00 1.00000000000000000000 9000.00 1.00000000000000000000 \N \N \N 1305 4 47 jsmith 4 2 I 3 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1306 4 47 jsmith 6 1 G 5 0.00 -3000.00 0.00 0.00 0.00 \N \N \N \N \N 3 -3000.00 \N -3000.00 \N \N \N \N 1307 4 47 jsmith 7 2 I 4 \N 3000.00 \N \N 0.00 \N 0.33333333333333333333 \N \N 0.00000000000000000000 5 3000.00 0.33333333333333333333 3000.00 0.33333333333333333333 \N \N \N 1308 4 47 jsmith 8 1 G 6 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 0.00 \N 0.00 \N \N \N \N 1309 4 47 jsmith 10 0 G 7 0.00 1000.00 0.00 0.00 0.00 \N \N \N \N \N -1 1000.00 \N 1000.00 \N \N \N \N 1310 4 47 jsmith 11 1 G 8 0.00 1000.00 0.00 0.00 0.00 \N 0.11111111111111111111 \N \N 0.00000000000000000000 7 1000.00 0.11111111111111111111 1000.00 0.11111111111111111111 \N \N \N 1311 4 47 jsmith 12 2 I 5 \N 1000.00 \N \N 0.00 \N 0.11111111111111111111 \N \N 0.00000000000000000000 8 1000.00 0.11111111111111111111 1000.00 0.11111111111111111111 \N \N \N 1312 4 47 jsmith 13 2 I 6 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1313 4 47 jsmith 14 2 I 7 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1314 4 47 jsmith 15 2 I 8 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1315 4 47 jsmith 16 2 I 9 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1316 4 47 jsmith 17 2 I 10 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1317 4 47 jsmith 18 2 I 11 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1318 4 47 jsmith 20 0 G 9 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 1319 4 47 jsmith 5 2 T -1 \N 9000.00 \N \N \N \N \N \N \N \N 4 9000.00 1.00000000000000000000 9000.00 1.00000000000000000000 \N \N \N 1320 4 47 jsmith 9 1 T -1 \N 6000.00 \N \N 0.00 \N 0.66666666666666666667 \N \N 0.00000000000000000000 3 6000.00 0.66666666666666666667 6000.00 0.66666666666666666667 \N \N \N 1321 4 47 jsmith 19 2 T -1 \N 1000.00 \N \N 0.00 \N 0.11111111111111111111 \N \N 0.00000000000000000000 8 1000.00 0.11111111111111111111 1000.00 0.11111111111111111111 \N \N \N 1322 4 47 jsmith 21 0 T -1 0.00 5000.00 \N \N 0.00 \N \N \N \N \N \N 5000.00 \N 5000.00 \N \N \N \N 1323 4 48 jsmith 1 0 G 3 0.00 3000.00 0.00 0.00 0.00 \N 0.50000000000000000000 \N \N 0.00000000000000000000 -1 3000.00 0.50000000000000000000 3000.00 0.50000000000000000000 \N \N \N 1324 4 48 jsmith 2 1 G 4 0.00 6000.00 0.00 0.00 0.00 \N \N \N \N \N 3 6000.00 1.00000000000000000000 6000.00 1.00000000000000000000 \N \N \N 1325 4 48 jsmith 3 2 I 2 0.00 6000.00 \N \N 0.00 \N 1.00000000000000000000 \N \N 0.00000000000000000000 4 6000.00 1.00000000000000000000 6000.00 1.00000000000000000000 \N \N \N 1326 4 48 jsmith 4 2 I 3 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1327 4 48 jsmith 6 1 G 5 0.00 -3000.00 0.00 0.00 0.00 \N \N \N \N \N 3 -3000.00 \N -3000.00 \N \N \N \N 1328 4 48 jsmith 7 2 I 4 \N 3000.00 \N \N 0.00 \N 0.50000000000000000000 \N \N 0.00000000000000000000 5 3000.00 0.50000000000000000000 3000.00 0.50000000000000000000 \N \N \N 1329 4 48 jsmith 8 1 G 6 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 0.00 \N 0.00 \N \N \N \N 1330 4 48 jsmith 10 0 G 7 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 1331 4 48 jsmith 11 1 G 8 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1332 4 48 jsmith 12 2 I 5 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1333 4 48 jsmith 13 2 I 6 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1334 4 48 jsmith 14 2 I 7 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1335 4 48 jsmith 15 2 I 8 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1336 4 48 jsmith 16 2 I 9 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1337 4 48 jsmith 17 2 I 10 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1338 4 48 jsmith 18 2 I 11 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1339 4 48 jsmith 20 0 G 9 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 1340 4 48 jsmith 5 2 T -1 \N 6000.00 \N \N \N \N \N \N \N \N 4 6000.00 1.00000000000000000000 6000.00 1.00000000000000000000 \N \N \N 1341 4 48 jsmith 9 1 T -1 \N 3000.00 \N \N 0.00 \N 0.50000000000000000000 \N \N 0.00000000000000000000 3 3000.00 0.50000000000000000000 3000.00 0.50000000000000000000 \N \N \N 1342 4 48 jsmith 19 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1343 4 48 jsmith 21 0 T -1 0.00 3000.00 \N \N 0.00 \N \N \N \N \N \N 3000.00 \N 3000.00 \N \N \N \N 1344 4 46 jsmith 1 0 G 3 6000.00 14000.00 0.00 0.00 0.00 \N 0.77777777777777777778 \N \N 0.00000000000000000000 -1 11000.00 0.91666666666666666667 11000.00 0.91666666666666666667 \N \N \N 1345 4 46 jsmith 2 1 G 4 6000.00 18000.00 0.00 0.00 0.00 \N \N \N \N \N 3 12000.00 1.00000000000000000000 12000.00 1.00000000000000000000 \N \N \N 1346 4 46 jsmith 3 2 I 2 6000.00 18000.00 \N \N 0.00 \N 1.00000000000000000000 \N \N 0.00000000000000000000 4 12000.00 1.00000000000000000000 12000.00 1.00000000000000000000 \N \N \N 1347 4 46 jsmith 4 2 I 3 \N 0.00 \N \N 0.00 \N 0.000000000000000000000000 \N \N 0.00000000000000000000 4 0.00 0.000000000000000000000000 0.00 0.000000000000000000000000 \N \N \N 1348 4 46 jsmith 6 1 G 5 0.00 -4000.00 0.00 0.00 0.00 \N \N \N \N \N 3 -1000.00 \N -1000.00 \N \N \N \N 1349 4 46 jsmith 7 2 I 4 \N 4000.00 \N \N 0.00 \N 0.22222222222222222222 \N \N 0.00000000000000000000 5 1000.00 0.08333333333333333333 1000.00 0.08333333333333333333 \N \N \N 1350 4 46 jsmith 8 1 G 6 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 0.00 \N 0.00 \N \N \N \N 1351 4 46 jsmith 10 0 G 7 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 1352 4 46 jsmith 11 1 G 8 0.00 0.00 0.00 0.00 0.00 \N 0.000000000000000000000000 \N \N 0.00000000000000000000 7 0.00 0.000000000000000000000000 0.00 0.000000000000000000000000 \N \N \N 1353 4 46 jsmith 12 2 I 5 \N 0.00 \N \N 0.00 \N 0.000000000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.000000000000000000000000 0.00 0.000000000000000000000000 \N \N \N 1354 4 46 jsmith 13 2 I 6 \N 0.00 \N \N 0.00 \N 0.000000000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.000000000000000000000000 0.00 0.000000000000000000000000 \N \N \N 1355 4 46 jsmith 14 2 I 7 \N 0.00 \N \N 0.00 \N 0.000000000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.000000000000000000000000 0.00 0.000000000000000000000000 \N \N \N 1356 4 46 jsmith 15 2 I 8 \N 0.00 \N \N 0.00 \N 0.000000000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.000000000000000000000000 0.00 0.000000000000000000000000 \N \N \N 1357 4 46 jsmith 16 2 I 9 \N 0.00 \N \N 0.00 \N 0.000000000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.000000000000000000000000 0.00 0.000000000000000000000000 \N \N \N 1358 4 46 jsmith 17 2 I 10 \N 0.00 \N \N 0.00 \N 0.000000000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.000000000000000000000000 0.00 0.000000000000000000000000 \N \N \N 1359 4 46 jsmith 18 2 I 11 \N 0.00 \N \N 0.00 \N 0.000000000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.000000000000000000000000 0.00 0.000000000000000000000000 \N \N \N 1360 4 46 jsmith 20 0 G 9 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 1361 4 46 jsmith 5 2 T -1 \N 18000.00 \N \N \N \N \N \N \N \N 4 12000.00 1.00000000000000000000 12000.00 1.00000000000000000000 \N \N \N 1362 4 46 jsmith 9 1 T -1 \N 14000.00 \N \N 0.00 \N 0.77777777777777777778 \N \N 0.00000000000000000000 3 11000.00 0.91666666666666666667 11000.00 0.91666666666666666667 \N \N \N 1363 4 46 jsmith 19 2 T -1 \N 0.00 \N \N 0.00 \N 0.000000000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.000000000000000000000000 0.00 0.000000000000000000000000 \N \N \N 1364 4 46 jsmith 21 0 T -1 6000.00 14000.00 \N \N 0.00 \N \N \N \N \N \N 11000.00 \N 11000.00 \N \N \N \N 1365 4 29 jsmith 1 0 G 3 18000.00 15500.00 0.00 0.00 0.00 \N 0.75609756097560975610 \N \N 0.00000000000000000000 -1 1500.00 0.60000000000000000000 1500.00 0.60000000000000000000 \N \N \N 1366 4 29 jsmith 2 1 G 4 18000.00 20500.00 0.00 0.00 0.00 \N \N \N \N \N 3 2500.00 1.00000000000000000000 2500.00 1.00000000000000000000 \N \N \N 1367 4 29 jsmith 3 2 I 2 18000.00 20500.00 \N \N 0.00 \N 1.00000000000000000000 \N \N 0.00000000000000000000 4 2500.00 1.00000000000000000000 2500.00 1.00000000000000000000 \N \N \N 1368 4 29 jsmith 4 2 I 3 \N 0.00 \N \N 0.00 \N 0.000000000000000000000000 \N \N 0.00000000000000000000 4 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1369 4 29 jsmith 6 1 G 5 0.00 -5000.00 0.00 0.00 0.00 \N \N \N \N \N 3 -1000.00 \N -1000.00 \N \N \N \N 1370 4 29 jsmith 7 2 I 4 \N 5000.00 \N \N 0.00 \N 0.24390243902439024390 \N \N 0.00000000000000000000 5 1000.00 0.40000000000000000000 1000.00 0.40000000000000000000 \N \N \N 1371 4 29 jsmith 8 1 G 6 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 0.00 \N 0.00 \N \N \N \N 1372 4 29 jsmith 10 0 G 7 0.00 500.00 0.00 0.00 0.00 \N \N \N \N \N -1 500.00 \N 500.00 \N \N \N \N 1373 4 29 jsmith 11 1 G 8 0.00 500.00 0.00 0.00 0.00 \N 0.02439024390243902439 \N \N 0.00000000000000000000 7 500.00 0.20000000000000000000 500.00 0.20000000000000000000 \N \N \N 1374 4 29 jsmith 12 2 I 5 \N 500.00 \N \N 0.00 \N 0.02439024390243902439 \N \N 0.00000000000000000000 8 500.00 0.20000000000000000000 500.00 0.20000000000000000000 \N \N \N 1375 4 29 jsmith 13 2 I 6 \N 0.00 \N \N 0.00 \N 0.000000000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1376 4 29 jsmith 14 2 I 7 \N 0.00 \N \N 0.00 \N 0.000000000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1377 4 29 jsmith 15 2 I 8 \N 0.00 \N \N 0.00 \N 0.000000000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1378 4 29 jsmith 16 2 I 9 \N 0.00 \N \N 0.00 \N 0.000000000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1379 4 29 jsmith 17 2 I 10 \N 0.00 \N \N 0.00 \N 0.000000000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1380 4 29 jsmith 18 2 I 11 \N 0.00 \N \N 0.00 \N 0.000000000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1381 4 29 jsmith 20 0 G 9 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 1382 4 29 jsmith 5 2 T -1 \N 20500.00 \N \N \N \N \N \N \N \N 4 2500.00 1.00000000000000000000 2500.00 1.00000000000000000000 \N \N \N 1383 4 29 jsmith 9 1 T -1 \N 15500.00 \N \N 0.00 \N 0.75609756097560975610 \N \N 0.00000000000000000000 3 1500.00 0.60000000000000000000 1500.00 0.60000000000000000000 \N \N \N 1384 4 29 jsmith 19 2 T -1 \N 500.00 \N \N 0.00 \N 0.02439024390243902439 \N \N 0.00000000000000000000 8 500.00 0.20000000000000000000 500.00 0.20000000000000000000 \N \N \N 1385 4 29 jsmith 21 0 T -1 18000.00 15000.00 \N \N 0.00 \N \N \N \N \N \N 1000.00 \N 1000.00 \N \N \N \N 1386 4 28 jsmith 1 0 G 3 20500.00 19203.19 0.00 0.00 0.00 \N 0.75198695206096347987 \N \N 0.00000000000000000000 -1 3703.19 0.73525592661716237144 3703.19 0.73525592661716237144 \N \N \N 1387 4 28 jsmith 2 1 G 4 20500.00 25536.60 0.00 0.00 0.00 \N \N \N \N \N 3 5036.60 1.00000000000000000000 5036.60 1.00000000000000000000 \N \N \N 1388 4 28 jsmith 3 2 I 2 20500.00 25255.20 \N \N 0.00 \N 0.98898052207419938441 \N \N 0.00000000000000000000 4 4755.20 0.94412897589643807330 4755.20 0.94412897589643807330 \N \N \N 1389 4 28 jsmith 4 2 I 3 \N 281.40 \N \N 0.00 \N 0.01101947792580061559 \N \N 0.00000000000000000000 4 281.40 0.05587102410356192670 281.40 0.05587102410356192670 \N \N \N 1390 4 28 jsmith 6 1 G 5 0.00 -6333.41 0.00 0.00 0.00 \N \N \N \N \N 3 -1333.41 \N -1333.41 \N \N \N \N 1391 4 28 jsmith 7 2 I 4 \N 6333.41 \N \N 0.00 \N 0.24801304793903652013 \N \N 0.00000000000000000000 5 1333.41 0.26474407338283762856 1333.41 0.26474407338283762856 \N \N \N 1392 4 28 jsmith 8 1 G 6 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 0.00 \N 0.00 \N \N \N \N 1393 4 28 jsmith 10 0 G 7 0.00 746.06 0.00 0.00 0.00 \N \N \N \N \N -1 246.06 \N 246.06 \N \N \N \N 1394 4 28 jsmith 11 1 G 8 0.00 746.06 0.00 0.00 0.00 \N 0.02921532232168730371 \N \N 0.00000000000000000000 7 246.06 0.04885438589524679347 246.06 0.04885438589524679347 \N \N \N 1395 4 28 jsmith 12 2 I 5 \N 700.00 \N \N 0.00 \N 0.02741163663134481489 \N \N 0.00000000000000000000 8 200.00 0.03970932772108168209 200.00 0.03970932772108168209 \N \N \N 1396 4 28 jsmith 13 2 I 6 \N 0.00 \N \N 0.00 \N 0.000000000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1397 4 28 jsmith 14 2 I 7 \N 29.99 \N \N 0.00 \N 0.00117439283224861571 \N \N 0.00000000000000000000 8 29.99 0.00595441369177619823 29.99 0.00595441369177619823 \N \N \N 1398 4 28 jsmith 15 2 I 8 \N 0.00 \N \N 0.00 \N 0.000000000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1399 4 28 jsmith 16 2 I 9 \N 5.00 \N \N 0.00 \N 0.00019579740450960582 \N \N 0.00000000000000000000 8 5.00 0.00099273319302704205 5.00 0.00099273319302704205 \N \N \N 1400 4 28 jsmith 17 2 I 10 \N 1.07 \N \N 0.00 \N 0.000041900644565055645622 \N \N 0.00000000000000000000 8 1.07 0.00021244490330778700 1.07 0.00021244490330778700 \N \N \N 1401 4 28 jsmith 18 2 I 11 \N 10.00 \N \N 0.00 \N 0.00039159480901921164 \N \N 0.00000000000000000000 8 10.00 0.00198546638605408410 10.00 0.00198546638605408410 \N \N \N 1402 4 28 jsmith 20 0 G 9 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 1403 4 28 jsmith 5 2 T -1 \N 25536.60 \N \N \N \N \N \N \N \N 4 5036.60 1.00000000000000000000 5036.60 1.00000000000000000000 \N \N \N 1404 13 47 jsmith 34 3 T -1 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1483 4 28 jsmith 9 1 T -1 \N 19203.19 \N \N 0.00 \N 0.75198695206096347987 \N \N 0.00000000000000000000 3 3703.19 0.73525592661716237144 3703.19 0.73525592661716237144 \N \N \N 1405 4 28 jsmith 19 2 T -1 \N 746.06 \N \N 0.00 \N 0.02921532232168730371 \N \N 0.00000000000000000000 8 246.06 0.04885438589524679347 246.06 0.04885438589524679347 \N \N \N 1406 4 28 jsmith 21 0 T -1 20500.00 18457.13 \N \N 0.00 \N \N \N \N \N \N 3457.13 \N 3457.13 \N \N \N \N 1407 4 30 jsmith 1 0 G 3 0.00 4212.49 0.00 0.00 0.00 \N 0.66370408417284549720 \N \N 0.00000000000000000000 -1 4212.49 0.66370408417284549720 4212.49 0.66370408417284549720 \N \N \N 1408 4 30 jsmith 2 1 G 4 0.00 6346.94 0.00 0.00 0.00 \N \N \N \N \N 3 6346.94 1.00000000000000000000 6346.94 1.00000000000000000000 \N \N \N 1409 4 30 jsmith 3 2 I 2 0.00 6344.54 \N \N 0.00 \N 0.99962186502472057401 \N \N 0.00000000000000000000 4 6344.54 0.99962186502472057401 6344.54 0.99962186502472057401 \N \N \N 1410 4 30 jsmith 4 2 I 3 \N 2.40 \N \N 0.00 \N 0.00037813497527942599 \N \N 0.00000000000000000000 4 2.40 0.00037813497527942599 2.40 0.00037813497527942599 \N \N \N 1411 4 30 jsmith 6 1 G 5 0.00 -2134.45 0.00 0.00 0.00 \N \N \N \N \N 3 -2134.45 \N -2134.45 \N \N \N \N 1412 4 30 jsmith 7 2 I 4 \N 2134.45 \N \N 0.00 \N 0.33629591582715450280 \N \N 0.00000000000000000000 5 2134.45 0.33629591582715450280 2134.45 0.33629591582715450280 \N \N \N 1413 4 30 jsmith 8 1 G 6 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 0.00 \N 0.00 \N \N \N \N 1414 4 30 jsmith 10 0 G 7 0.00 -256.98 0.00 0.00 0.00 \N \N \N \N \N -1 -256.98 \N -256.98 \N \N \N \N 1415 4 30 jsmith 11 1 G 8 0.00 -256.98 0.00 0.00 0.00 \N -0.04048880247804453800 \N \N 0.00000000000000000000 7 -256.98 -0.04048880247804453800 -256.98 -0.04048880247804453800 \N \N \N 1416 4 30 jsmith 12 2 I 5 \N 1010.00 \N \N 0.00 \N 0.15913180209675843792 \N \N 0.00000000000000000000 8 1010.00 0.15913180209675843792 1010.00 0.15913180209675843792 \N \N \N 1417 4 30 jsmith 13 2 I 6 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1418 4 30 jsmith 14 2 I 7 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1419 4 30 jsmith 15 2 I 8 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1420 4 30 jsmith 16 2 I 9 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1421 4 30 jsmith 17 2 I 10 \N 5.00 \N \N 0.00 \N 0.00078778119849880415 \N \N 0.00000000000000000000 8 5.00 0.00078778119849880415 5.00 0.00078778119849880415 \N \N \N 1422 4 30 jsmith 18 2 I 11 \N -1271.98 \N \N 0.00 \N -0.20040838577330178007 \N \N 0.00000000000000000000 8 -1271.98 -0.20040838577330178007 -1271.98 -0.20040838577330178007 \N \N \N 1423 4 30 jsmith 20 0 G 9 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 1424 4 30 jsmith 5 2 T -1 \N 6346.94 \N \N \N \N \N \N \N \N 4 6346.94 1.00000000000000000000 6346.94 1.00000000000000000000 \N \N \N 1425 4 30 jsmith 9 1 T -1 \N 4212.49 \N \N 0.00 \N 0.66370408417284549720 \N \N 0.00000000000000000000 3 4212.49 0.66370408417284549720 4212.49 0.66370408417284549720 \N \N \N 1426 4 30 jsmith 19 2 T -1 \N -256.98 \N \N 0.00 \N -0.04048880247804453800 \N \N 0.00000000000000000000 8 -256.98 -0.04048880247804453800 -256.98 -0.04048880247804453800 \N \N \N 1427 4 30 jsmith 21 0 T -1 0.00 4469.47 \N \N 0.00 \N \N \N \N \N \N 4469.47 \N 4469.47 \N \N \N \N 1428 13 47 jsmith 1 0 G 60 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 8000.00 \N 8000.00 \N \N \N \N 1429 13 47 jsmith 2 1 G 61 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 -2000.00 \N -2000.00 \N \N \N \N 1430 13 47 jsmith 3 2 G 62 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 5000.00 \N 5000.00 \N \N \N \N 1431 13 47 jsmith 4 3 G 63 \N \N \N \N \N \N \N \N \N \N 62 5000.00 \N 5000.00 \N \N \N \N 1432 13 47 jsmith 6 2 G 65 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1433 13 47 jsmith 7 3 I 119 \N \N \N \N \N \N \N \N \N \N 65 0.00 \N 0.00 \N \N \N \N 1434 13 47 jsmith 9 2 G 66 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1435 13 47 jsmith 10 2 G 67 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1436 13 47 jsmith 12 2 G 68 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1437 13 47 jsmith 13 3 I 120 \N \N \N \N \N \N \N \N \N \N 68 0.00 \N 0.00 \N \N \N \N 1438 13 47 jsmith 15 2 G 69 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 7000.00 \N 7000.00 \N \N \N \N 1439 13 47 jsmith 16 3 I 121 \N \N \N \N \N \N \N \N \N \N 69 7000.00 \N 7000.00 \N \N \N \N 1440 13 47 jsmith 17 3 I 122 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1441 13 47 jsmith 18 3 I 123 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1442 13 47 jsmith 19 3 I 124 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1443 13 47 jsmith 20 3 I 137 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1444 13 47 jsmith 21 3 I 138 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1445 13 47 jsmith 23 2 G 72 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1446 13 47 jsmith 24 3 I 125 \N \N \N \N \N \N \N \N \N \N 72 0.00 \N 0.00 \N \N \N \N 1447 13 47 jsmith 26 2 G 70 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1448 13 47 jsmith 27 2 G 71 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1449 13 47 jsmith 28 3 I 126 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1450 13 47 jsmith 29 3 I 127 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1451 13 47 jsmith 30 3 I 128 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1452 13 47 jsmith 31 3 I 129 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1453 13 47 jsmith 32 3 I 130 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1454 13 47 jsmith 33 3 I 131 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1455 13 47 jsmith 35 2 G 73 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1456 13 47 jsmith 37 2 G 74 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1457 13 47 jsmith 48 3 I 133 \N \N \N \N \N \N \N \N \N \N 79 0.00 \N 0.00 \N \N \N \N 1458 13 47 jsmith 39 2 G 75 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1459 13 47 jsmith 40 3 I 132 \N \N \N \N \N \N \N \N \N \N 75 0.00 \N 0.00 \N \N \N \N 1460 13 47 jsmith 42 2 G 76 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1461 13 47 jsmith 44 2 G 77 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1462 13 47 jsmith 46 1 G 78 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 0.00 \N 0.00 \N \N \N \N 1463 13 47 jsmith 47 2 G 79 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1464 13 47 jsmith 50 2 G 80 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1465 13 47 jsmith 52 2 G 81 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1466 13 47 jsmith 54 1 G 82 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 10000.00 \N 10000.00 \N \N \N \N 1467 13 47 jsmith 55 2 G 83 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 0.00 \N 0.00 \N \N \N \N 1468 13 47 jsmith 56 3 I 139 \N \N \N \N \N \N \N \N \N \N 83 0.00 \N 0.00 \N \N \N \N 1469 13 47 jsmith 58 2 G 84 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 10000.00 \N 10000.00 \N \N \N \N 1470 13 47 jsmith 59 3 I 134 \N \N \N \N \N \N \N \N \N \N 84 10000.00 \N 10000.00 \N \N \N \N 1471 13 47 jsmith 60 3 I 135 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1472 13 47 jsmith 61 3 I 136 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1473 13 47 jsmith 63 2 G 85 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 0.00 \N 0.00 \N \N \N \N 1474 13 47 jsmith 66 0 G 86 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 -8000.00 \N -8000.00 \N \N \N \N 1475 13 47 jsmith 67 1 I 108 \N \N \N \N \N \N \N \N \N \N 86 8000.00 \N 8000.00 \N \N \N \N 1476 13 47 jsmith 5 3 T -1 \N \N \N \N \N \N \N \N \N \N 62 5000.00 \N 5000.00 \N \N \N \N 1477 13 47 jsmith 8 3 T -1 \N \N \N \N \N \N \N \N \N \N 65 0.00 \N 0.00 \N \N \N \N 1478 13 47 jsmith 11 3 T -1 \N \N \N \N \N \N \N \N \N \N 67 0.00 \N 0.00 \N \N \N \N 1479 13 47 jsmith 14 3 T -1 \N \N \N \N \N \N \N \N \N \N 68 0.00 \N 0.00 \N \N \N \N 1480 13 47 jsmith 22 3 T -1 \N \N \N \N \N \N \N \N \N \N 69 7000.00 \N 7000.00 \N \N \N \N 1481 13 47 jsmith 25 3 T -1 \N \N \N \N \N \N \N \N \N \N 72 0.00 \N 0.00 \N \N \N \N 1482 13 47 jsmith 36 3 T -1 \N \N \N \N \N \N \N \N \N \N 73 0.00 \N 0.00 \N \N \N \N 1484 13 47 jsmith 38 3 T -1 \N \N \N \N \N \N \N \N \N \N 74 0.00 \N 0.00 \N \N \N \N 1485 13 47 jsmith 41 3 T -1 \N \N \N \N \N \N \N \N \N \N 75 0.00 \N 0.00 \N \N \N \N 1486 13 47 jsmith 43 3 T -1 \N \N \N \N \N \N \N \N \N \N 76 0.00 \N 0.00 \N \N \N \N 1487 13 47 jsmith 45 2 T -1 \N \N \N \N \N \N \N \N \N \N 61 -2000.00 \N -2000.00 \N \N \N \N 1488 13 47 jsmith 49 3 T -1 \N \N \N \N \N \N \N \N \N \N 79 0.00 \N 0.00 \N \N \N \N 1489 13 47 jsmith 51 3 T -1 \N \N \N \N \N \N \N \N \N \N 80 0.00 \N 0.00 \N \N \N \N 1490 13 47 jsmith 53 2 T -1 \N \N \N \N \N \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1491 13 47 jsmith 57 3 T -1 \N \N \N \N \N \N \N \N \N \N 83 0.00 \N 0.00 \N \N \N \N 1492 13 47 jsmith 62 3 T -1 \N \N \N \N \N \N \N \N \N \N 84 10000.00 \N 10000.00 \N \N \N \N 1493 13 47 jsmith 64 2 T -1 \N \N \N \N \N \N \N \N \N \N 82 10000.00 \N 10000.00 \N \N \N \N 1494 13 47 jsmith 65 1 T -1 \N \N \N \N \N \N \N \N \N \N 60 8000.00 \N 8000.00 \N \N \N \N 1495 13 47 jsmith 68 0 T -1 \N \N \N \N \N \N \N \N \N \N \N 0.00 \N 0.00 \N \N \N \N 1496 13 48 jsmith 1 0 G 60 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 6000.00 \N 6000.00 \N \N \N \N 1497 13 48 jsmith 2 1 G 61 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 6000.00 \N 6000.00 \N \N \N \N 1498 13 48 jsmith 3 2 G 62 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 3000.00 \N 3000.00 \N \N \N \N 1499 13 48 jsmith 4 3 G 63 \N \N \N \N \N \N \N \N \N \N 62 3000.00 \N 3000.00 \N \N \N \N 1500 13 48 jsmith 6 2 G 65 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1501 13 48 jsmith 7 3 I 119 \N \N \N \N \N \N \N \N \N \N 65 0.00 \N 0.00 \N \N \N \N 1502 13 48 jsmith 9 2 G 66 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1503 13 48 jsmith 10 2 G 67 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1504 13 48 jsmith 12 2 G 68 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1505 13 48 jsmith 13 3 I 120 \N \N \N \N \N \N \N \N \N \N 68 0.00 \N 0.00 \N \N \N \N 1506 13 29 jsmith 61 3 I 136 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1507 13 48 jsmith 15 2 G 69 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 -3000.00 \N -3000.00 \N \N \N \N 1508 13 48 jsmith 16 3 I 121 \N \N \N \N \N \N \N \N \N \N 69 -3000.00 \N -3000.00 \N \N \N \N 1509 13 48 jsmith 17 3 I 122 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1510 13 48 jsmith 18 3 I 123 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1511 13 48 jsmith 19 3 I 124 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1512 13 48 jsmith 20 3 I 137 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1513 13 48 jsmith 21 3 I 138 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1514 13 48 jsmith 23 2 G 72 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1515 13 48 jsmith 24 3 I 125 \N \N \N \N \N \N \N \N \N \N 72 0.00 \N 0.00 \N \N \N \N 1516 13 48 jsmith 26 2 G 70 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1517 13 48 jsmith 27 2 G 71 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1518 13 48 jsmith 28 3 I 126 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1519 13 48 jsmith 29 3 I 127 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1520 13 48 jsmith 30 3 I 128 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1521 13 48 jsmith 31 3 I 129 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1522 13 48 jsmith 32 3 I 130 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1523 13 48 jsmith 33 3 I 131 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1524 13 48 jsmith 35 2 G 73 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1525 13 48 jsmith 37 2 G 74 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1526 13 48 jsmith 39 2 G 75 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1527 13 48 jsmith 40 3 I 132 \N \N \N \N \N \N \N \N \N \N 75 0.00 \N 0.00 \N \N \N \N 1528 13 48 jsmith 42 2 G 76 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1529 13 48 jsmith 44 2 G 77 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1530 13 48 jsmith 46 1 G 78 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 0.00 \N 0.00 \N \N \N \N 1531 13 48 jsmith 47 2 G 79 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1532 13 48 jsmith 48 3 I 133 \N \N \N \N \N \N \N \N \N \N 79 0.00 \N 0.00 \N \N \N \N 1533 13 48 jsmith 50 2 G 80 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1534 13 48 jsmith 52 2 G 81 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1535 13 48 jsmith 54 1 G 82 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 0.00 \N 0.00 \N \N \N \N 1536 13 48 jsmith 55 2 G 83 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 0.00 \N 0.00 \N \N \N \N 1537 13 48 jsmith 56 3 I 139 \N \N \N \N \N \N \N \N \N \N 83 0.00 \N 0.00 \N \N \N \N 1538 13 48 jsmith 58 2 G 84 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 0.00 \N 0.00 \N \N \N \N 1539 13 48 jsmith 59 3 I 134 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1540 13 48 jsmith 60 3 I 135 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1541 13 48 jsmith 61 3 I 136 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1542 13 48 jsmith 63 2 G 85 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 0.00 \N 0.00 \N \N \N \N 1543 13 48 jsmith 66 0 G 86 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 -6000.00 \N -6000.00 \N \N \N \N 1544 13 48 jsmith 67 1 I 108 \N \N \N \N \N \N \N \N \N \N 86 6000.00 \N 6000.00 \N \N \N \N 1545 13 48 jsmith 5 3 T -1 \N \N \N \N \N \N \N \N \N \N 62 3000.00 \N 3000.00 \N \N \N \N 1546 13 48 jsmith 8 3 T -1 \N \N \N \N \N \N \N \N \N \N 65 0.00 \N 0.00 \N \N \N \N 1547 13 48 jsmith 11 3 T -1 \N \N \N \N \N \N \N \N \N \N 67 0.00 \N 0.00 \N \N \N \N 1548 13 48 jsmith 14 3 T -1 \N \N \N \N \N \N \N \N \N \N 68 0.00 \N 0.00 \N \N \N \N 1549 13 48 jsmith 22 3 T -1 \N \N \N \N \N \N \N \N \N \N 69 -3000.00 \N -3000.00 \N \N \N \N 1550 13 48 jsmith 25 3 T -1 \N \N \N \N \N \N \N \N \N \N 72 0.00 \N 0.00 \N \N \N \N 1551 13 48 jsmith 34 3 T -1 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1552 13 48 jsmith 36 3 T -1 \N \N \N \N \N \N \N \N \N \N 73 0.00 \N 0.00 \N \N \N \N 1553 13 48 jsmith 38 3 T -1 \N \N \N \N \N \N \N \N \N \N 74 0.00 \N 0.00 \N \N \N \N 1554 13 48 jsmith 41 3 T -1 \N \N \N \N \N \N \N \N \N \N 75 0.00 \N 0.00 \N \N \N \N 1555 13 48 jsmith 43 3 T -1 \N \N \N \N \N \N \N \N \N \N 76 0.00 \N 0.00 \N \N \N \N 1556 13 48 jsmith 45 2 T -1 \N \N \N \N \N \N \N \N \N \N 61 6000.00 \N 6000.00 \N \N \N \N 1557 13 48 jsmith 49 3 T -1 \N \N \N \N \N \N \N \N \N \N 79 0.00 \N 0.00 \N \N \N \N 1558 13 48 jsmith 51 3 T -1 \N \N \N \N \N \N \N \N \N \N 80 0.00 \N 0.00 \N \N \N \N 1559 13 48 jsmith 53 2 T -1 \N \N \N \N \N \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1560 13 48 jsmith 57 3 T -1 \N \N \N \N \N \N \N \N \N \N 83 0.00 \N 0.00 \N \N \N \N 1561 13 48 jsmith 62 3 T -1 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1562 13 48 jsmith 64 2 T -1 \N \N \N \N \N \N \N \N \N \N 82 0.00 \N 0.00 \N \N \N \N 1563 13 48 jsmith 65 1 T -1 \N \N \N \N \N \N \N \N \N \N 60 6000.00 \N 6000.00 \N \N \N \N 1564 13 48 jsmith 68 0 T -1 \N \N \N \N \N \N \N \N \N \N \N 0.00 \N 0.00 \N \N \N \N 1565 13 46 jsmith 1 0 G 60 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 22000.00 \N 22000.00 \N \N \N \N 1566 13 46 jsmith 2 1 G 61 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 12000.00 \N 12000.00 \N \N \N \N 1567 13 46 jsmith 3 2 G 62 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 11000.00 \N 11000.00 \N \N \N \N 1568 13 46 jsmith 4 3 G 63 \N \N \N \N \N \N \N \N \N \N 62 11000.00 \N 11000.00 \N \N \N \N 1569 13 46 jsmith 6 2 G 65 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1570 13 46 jsmith 7 3 I 119 \N \N \N \N \N \N \N \N \N \N 65 0.00 \N 0.00 \N \N \N \N 1571 13 46 jsmith 9 2 G 66 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1572 13 46 jsmith 10 2 G 67 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1573 13 46 jsmith 12 2 G 68 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1574 13 46 jsmith 13 3 I 120 \N \N \N \N \N \N \N \N \N \N 68 0.00 \N 0.00 \N \N \N \N 1575 13 46 jsmith 15 2 G 69 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 -1000.00 \N -1000.00 \N \N \N \N 1576 13 46 jsmith 16 3 I 121 \N \N \N \N \N \N \N \N \N \N 69 -1000.00 \N -1000.00 \N \N \N \N 1577 13 46 jsmith 17 3 I 122 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1578 13 46 jsmith 18 3 I 123 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1579 13 46 jsmith 19 3 I 124 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1580 13 46 jsmith 20 3 I 137 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1581 13 46 jsmith 21 3 I 138 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1582 13 46 jsmith 23 2 G 72 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1583 13 46 jsmith 24 3 I 125 \N \N \N \N \N \N \N \N \N \N 72 0.00 \N 0.00 \N \N \N \N 1584 13 46 jsmith 26 2 G 70 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1585 13 46 jsmith 27 2 G 71 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1586 13 46 jsmith 28 3 I 126 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1587 13 46 jsmith 29 3 I 127 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1588 13 46 jsmith 30 3 I 128 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1589 13 46 jsmith 31 3 I 129 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1590 13 46 jsmith 32 3 I 130 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1591 13 46 jsmith 33 3 I 131 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1592 13 46 jsmith 35 2 G 73 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1593 13 46 jsmith 37 2 G 74 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1594 13 46 jsmith 39 2 G 75 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1595 13 46 jsmith 40 3 I 132 \N \N \N \N \N \N \N \N \N \N 75 0.00 \N 0.00 \N \N \N \N 1596 13 46 jsmith 42 2 G 76 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1597 13 46 jsmith 44 2 G 77 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1598 13 46 jsmith 46 1 G 78 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 0.00 \N 0.00 \N \N \N \N 1599 13 46 jsmith 47 2 G 79 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1600 13 46 jsmith 48 3 I 133 \N \N \N \N \N \N \N \N \N \N 79 0.00 \N 0.00 \N \N \N \N 1601 13 46 jsmith 50 2 G 80 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1602 13 46 jsmith 52 2 G 81 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1603 13 46 jsmith 54 1 G 82 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 10000.00 \N 10000.00 \N \N \N \N 1604 13 46 jsmith 55 2 G 83 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 0.00 \N 0.00 \N \N \N \N 1605 13 46 jsmith 56 3 I 139 \N \N \N \N \N \N \N \N \N \N 83 0.00 \N 0.00 \N \N \N \N 1606 13 46 jsmith 58 2 G 84 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 10000.00 \N 10000.00 \N \N \N \N 1607 13 46 jsmith 59 3 I 134 \N \N \N \N \N \N \N \N \N \N 84 10000.00 \N 10000.00 \N \N \N \N 1608 13 46 jsmith 60 3 I 135 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1609 13 46 jsmith 61 3 I 136 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1610 13 46 jsmith 63 2 G 85 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 0.00 \N 0.00 \N \N \N \N 1611 13 46 jsmith 66 0 G 86 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 -22000.00 \N -22000.00 \N \N \N \N 1612 13 46 jsmith 67 1 I 108 \N \N \N \N \N \N \N \N \N \N 86 22000.00 \N 22000.00 \N \N \N \N 1613 13 46 jsmith 5 3 T -1 \N \N \N \N \N \N \N \N \N \N 62 11000.00 \N 11000.00 \N \N \N \N 1614 13 46 jsmith 8 3 T -1 \N \N \N \N \N \N \N \N \N \N 65 0.00 \N 0.00 \N \N \N \N 1615 13 46 jsmith 11 3 T -1 \N \N \N \N \N \N \N \N \N \N 67 0.00 \N 0.00 \N \N \N \N 1616 13 46 jsmith 14 3 T -1 \N \N \N \N \N \N \N \N \N \N 68 0.00 \N 0.00 \N \N \N \N 1617 13 46 jsmith 22 3 T -1 \N \N \N \N \N \N \N \N \N \N 69 -1000.00 \N -1000.00 \N \N \N \N 1618 13 46 jsmith 25 3 T -1 \N \N \N \N \N \N \N \N \N \N 72 0.00 \N 0.00 \N \N \N \N 1619 13 46 jsmith 34 3 T -1 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1620 13 46 jsmith 36 3 T -1 \N \N \N \N \N \N \N \N \N \N 73 0.00 \N 0.00 \N \N \N \N 1621 13 46 jsmith 38 3 T -1 \N \N \N \N \N \N \N \N \N \N 74 0.00 \N 0.00 \N \N \N \N 1622 13 46 jsmith 41 3 T -1 \N \N \N \N \N \N \N \N \N \N 75 0.00 \N 0.00 \N \N \N \N 1623 13 46 jsmith 43 3 T -1 \N \N \N \N \N \N \N \N \N \N 76 0.00 \N 0.00 \N \N \N \N 1624 13 46 jsmith 45 2 T -1 \N \N \N \N \N \N \N \N \N \N 61 12000.00 \N 12000.00 \N \N \N \N 1625 13 46 jsmith 49 3 T -1 \N \N \N \N \N \N \N \N \N \N 79 0.00 \N 0.00 \N \N \N \N 1626 13 46 jsmith 51 3 T -1 \N \N \N \N \N \N \N \N \N \N 80 0.00 \N 0.00 \N \N \N \N 1627 13 46 jsmith 53 2 T -1 \N \N \N \N \N \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1628 13 46 jsmith 57 3 T -1 \N \N \N \N \N \N \N \N \N \N 83 0.00 \N 0.00 \N \N \N \N 1629 13 46 jsmith 62 3 T -1 \N \N \N \N \N \N \N \N \N \N 84 10000.00 \N 10000.00 \N \N \N \N 1630 13 46 jsmith 64 2 T -1 \N \N \N \N \N \N \N \N \N \N 82 10000.00 \N 10000.00 \N \N \N \N 1631 13 46 jsmith 65 1 T -1 \N \N \N \N \N \N \N \N \N \N 60 22000.00 \N 22000.00 \N \N \N \N 1632 13 46 jsmith 68 0 T -1 \N \N \N \N \N \N \N \N \N \N \N 0.00 \N 0.00 \N \N \N \N 1633 13 29 jsmith 1 0 G 60 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 2000.00 \N 2000.00 \N \N \N \N 1634 13 29 jsmith 2 1 G 61 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 2000.00 \N 2000.00 \N \N \N \N 1635 13 29 jsmith 3 2 G 62 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 1000.00 \N 1000.00 \N \N \N \N 1636 13 29 jsmith 4 3 G 63 \N \N \N \N \N \N \N \N \N \N 62 1000.00 \N 1000.00 \N \N \N \N 1637 13 29 jsmith 6 2 G 65 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1638 13 29 jsmith 7 3 I 119 \N \N \N \N \N \N \N \N \N \N 65 0.00 \N 0.00 \N \N \N \N 1639 13 29 jsmith 9 2 G 66 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1640 13 29 jsmith 10 2 G 67 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1641 13 29 jsmith 12 2 G 68 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1642 13 29 jsmith 13 3 I 120 \N \N \N \N \N \N \N \N \N \N 68 0.00 \N 0.00 \N \N \N \N 1643 13 29 jsmith 15 2 G 69 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 -1000.00 \N -1000.00 \N \N \N \N 1644 13 29 jsmith 16 3 I 121 \N \N \N \N \N \N \N \N \N \N 69 -1000.00 \N -1000.00 \N \N \N \N 1645 13 29 jsmith 17 3 I 122 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1646 13 29 jsmith 18 3 I 123 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1647 13 29 jsmith 19 3 I 124 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1648 13 29 jsmith 20 3 I 137 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1649 13 29 jsmith 21 3 I 138 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1650 13 29 jsmith 23 2 G 72 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1651 13 29 jsmith 24 3 I 125 \N \N \N \N \N \N \N \N \N \N 72 0.00 \N 0.00 \N \N \N \N 1652 13 29 jsmith 26 2 G 70 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1653 13 29 jsmith 27 2 G 71 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1654 13 29 jsmith 28 3 I 126 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1655 13 29 jsmith 29 3 I 127 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1656 13 29 jsmith 30 3 I 128 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1657 13 29 jsmith 31 3 I 129 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1658 13 29 jsmith 32 3 I 130 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1659 13 29 jsmith 33 3 I 131 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1660 13 29 jsmith 35 2 G 73 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1661 13 29 jsmith 37 2 G 74 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1662 13 29 jsmith 39 2 G 75 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1663 13 29 jsmith 40 3 I 132 \N \N \N \N \N \N \N \N \N \N 75 0.00 \N 0.00 \N \N \N \N 1664 13 29 jsmith 42 2 G 76 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1665 13 29 jsmith 44 2 G 77 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1666 13 29 jsmith 46 1 G 78 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 0.00 \N 0.00 \N \N \N \N 1667 13 29 jsmith 47 2 G 79 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1668 13 29 jsmith 48 3 I 133 \N \N \N \N \N \N \N \N \N \N 79 0.00 \N 0.00 \N \N \N \N 1669 13 29 jsmith 50 2 G 80 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1670 13 29 jsmith 52 2 G 81 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1671 13 29 jsmith 54 1 G 82 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 0.00 \N 0.00 \N \N \N \N 1672 13 29 jsmith 55 2 G 83 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 0.00 \N 0.00 \N \N \N \N 1673 13 29 jsmith 56 3 I 139 \N \N \N \N \N \N \N \N \N \N 83 0.00 \N 0.00 \N \N \N \N 1674 13 29 jsmith 58 2 G 84 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 0.00 \N 0.00 \N \N \N \N 1675 13 29 jsmith 59 3 I 134 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1676 13 29 jsmith 60 3 I 135 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1677 13 29 jsmith 63 2 G 85 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 0.00 \N 0.00 \N \N \N \N 1678 13 29 jsmith 62 3 T -1 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1679 13 29 jsmith 66 0 G 86 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 -2000.00 \N -2000.00 \N \N \N \N 1680 13 29 jsmith 67 1 I 108 \N \N \N \N \N \N \N \N \N \N 86 2000.00 \N 2000.00 \N \N \N \N 1681 13 29 jsmith 5 3 T -1 \N \N \N \N \N \N \N \N \N \N 62 1000.00 \N 1000.00 \N \N \N \N 1682 13 29 jsmith 8 3 T -1 \N \N \N \N \N \N \N \N \N \N 65 0.00 \N 0.00 \N \N \N \N 1683 13 29 jsmith 11 3 T -1 \N \N \N \N \N \N \N \N \N \N 67 0.00 \N 0.00 \N \N \N \N 1684 13 29 jsmith 14 3 T -1 \N \N \N \N \N \N \N \N \N \N 68 0.00 \N 0.00 \N \N \N \N 1685 13 29 jsmith 22 3 T -1 \N \N \N \N \N \N \N \N \N \N 69 -1000.00 \N -1000.00 \N \N \N \N 1686 13 29 jsmith 25 3 T -1 \N \N \N \N \N \N \N \N \N \N 72 0.00 \N 0.00 \N \N \N \N 1687 13 29 jsmith 34 3 T -1 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1688 13 29 jsmith 36 3 T -1 \N \N \N \N \N \N \N \N \N \N 73 0.00 \N 0.00 \N \N \N \N 1689 13 29 jsmith 38 3 T -1 \N \N \N \N \N \N \N \N \N \N 74 0.00 \N 0.00 \N \N \N \N 1690 13 29 jsmith 41 3 T -1 \N \N \N \N \N \N \N \N \N \N 75 0.00 \N 0.00 \N \N \N \N 1691 13 29 jsmith 43 3 T -1 \N \N \N \N \N \N \N \N \N \N 76 0.00 \N 0.00 \N \N \N \N 1692 13 29 jsmith 45 2 T -1 \N \N \N \N \N \N \N \N \N \N 61 2000.00 \N 2000.00 \N \N \N \N 1693 13 29 jsmith 49 3 T -1 \N \N \N \N \N \N \N \N \N \N 79 0.00 \N 0.00 \N \N \N \N 1694 13 29 jsmith 51 3 T -1 \N \N \N \N \N \N \N \N \N \N 80 0.00 \N 0.00 \N \N \N \N 1695 13 29 jsmith 53 2 T -1 \N \N \N \N \N \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1696 13 29 jsmith 57 3 T -1 \N \N \N \N \N \N \N \N \N \N 83 0.00 \N 0.00 \N \N \N \N 1697 13 29 jsmith 64 2 T -1 \N \N \N \N \N \N \N \N \N \N 82 0.00 \N 0.00 \N \N \N \N 1698 13 29 jsmith 65 1 T -1 \N \N \N \N \N \N \N \N \N \N 60 2000.00 \N 2000.00 \N \N \N \N 1699 13 29 jsmith 68 0 T -1 \N \N \N \N \N \N \N \N \N \N \N 0.00 \N 0.00 \N \N \N \N 1700 13 28 jsmith 1 0 G 60 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 991222.11 \N 991222.11 \N \N \N \N 1701 13 28 jsmith 2 1 G 61 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 -8777.89 \N -8777.89 \N \N \N \N 1702 13 28 jsmith 3 2 G 62 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 3457.13 \N 3457.13 \N \N \N \N 1703 13 28 jsmith 4 3 G 63 \N \N \N \N \N \N \N \N \N \N 62 3457.13 \N 3457.13 \N \N \N \N 1704 13 28 jsmith 6 2 G 65 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1705 13 28 jsmith 7 3 I 119 \N \N \N \N \N \N \N \N \N \N 65 0.00 \N 0.00 \N \N \N \N 1706 13 28 jsmith 9 2 G 66 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1707 13 28 jsmith 10 2 G 67 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1708 13 28 jsmith 12 2 G 68 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1709 13 28 jsmith 13 3 I 120 \N \N \N \N \N \N \N \N \N \N 68 0.00 \N 0.00 \N \N \N \N 1710 13 28 jsmith 15 2 G 69 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 13064.13 \N 13064.13 \N \N \N \N 1711 13 28 jsmith 16 3 I 121 \N \N \N \N \N \N \N \N \N \N 69 19195.81 \N 19195.81 \N \N \N \N 1712 13 28 jsmith 17 3 I 122 \N \N \N \N \N \N \N \N \N \N 69 -76.85 \N -76.85 \N \N \N \N 1713 13 28 jsmith 18 3 I 123 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1714 13 28 jsmith 19 3 I 124 \N \N \N \N \N \N \N \N \N \N 69 -6053.79 \N -6053.79 \N \N \N \N 1715 13 28 jsmith 20 3 I 137 \N \N \N \N \N \N \N \N \N \N 69 0.02 \N 0.02 \N \N \N \N 1716 13 28 jsmith 21 3 I 138 \N \N \N \N \N \N \N \N \N \N 69 -1.06 \N -1.06 \N \N \N \N 1717 13 28 jsmith 23 2 G 72 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1718 13 28 jsmith 24 3 I 125 \N \N \N \N \N \N \N \N \N \N 72 0.00 \N 0.00 \N \N \N \N 1719 13 28 jsmith 26 2 G 70 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1720 13 28 jsmith 27 2 G 71 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 590.34 \N 590.34 \N \N \N \N 1721 13 28 jsmith 28 3 I 126 \N \N \N \N \N \N \N \N \N \N 71 250.00 \N 250.00 \N \N \N \N 1722 13 28 jsmith 29 3 I 127 \N \N \N \N \N \N \N \N \N \N 71 151.99 \N 151.99 \N \N \N \N 1723 13 28 jsmith 30 3 I 128 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1724 13 28 jsmith 31 3 I 129 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1725 13 28 jsmith 32 3 I 130 \N \N \N \N \N \N \N \N \N \N 71 216.74 \N 216.74 \N \N \N \N 1726 13 28 jsmith 33 3 I 131 \N \N \N \N \N \N \N \N \N \N 71 -28.39 \N -28.39 \N \N \N \N 1727 13 28 jsmith 35 2 G 73 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1728 13 28 jsmith 37 2 G 74 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1729 13 28 jsmith 39 2 G 75 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 238.77 \N 238.77 \N \N \N \N 1730 13 28 jsmith 40 3 I 132 \N \N \N \N \N \N \N \N \N \N 75 238.77 \N 238.77 \N \N \N \N 1731 13 28 jsmith 42 2 G 76 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1732 13 28 jsmith 44 2 G 77 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1733 13 28 jsmith 46 1 G 78 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 0.00 \N 0.00 \N \N \N \N 1734 13 28 jsmith 47 2 G 79 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1735 13 28 jsmith 48 3 I 133 \N \N \N \N \N \N \N \N \N \N 79 0.00 \N 0.00 \N \N \N \N 1736 13 28 jsmith 50 2 G 80 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1737 13 28 jsmith 52 2 G 81 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1738 13 28 jsmith 54 1 G 82 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 1000000.00 \N 1000000.00 \N \N \N \N 1739 13 28 jsmith 55 2 G 83 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 0.00 \N 0.00 \N \N \N \N 1740 13 28 jsmith 56 3 I 139 \N \N \N \N \N \N \N \N \N \N 83 0.00 \N 0.00 \N \N \N \N 1741 13 28 jsmith 58 2 G 84 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 1000000.00 \N 1000000.00 \N \N \N \N 1742 13 28 jsmith 59 3 I 134 \N \N \N \N \N \N \N \N \N \N 84 1000000.00 \N 1000000.00 \N \N \N \N 1743 13 28 jsmith 60 3 I 135 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1744 13 28 jsmith 61 3 I 136 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1745 13 28 jsmith 63 2 G 85 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 0.00 \N 0.00 \N \N \N \N 1746 13 28 jsmith 66 0 G 86 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 -991222.11 \N -991222.11 \N \N \N \N 1747 13 28 jsmith 67 1 I 108 \N \N \N \N \N \N \N \N \N \N 86 991222.11 \N 991222.11 \N \N \N \N 1748 13 28 jsmith 5 3 T -1 \N \N \N \N \N \N \N \N \N \N 62 3457.13 \N 3457.13 \N \N \N \N 1749 13 28 jsmith 8 3 T -1 \N \N \N \N \N \N \N \N \N \N 65 0.00 \N 0.00 \N \N \N \N 1750 13 28 jsmith 11 3 T -1 \N \N \N \N \N \N \N \N \N \N 67 0.00 \N 0.00 \N \N \N \N 1751 13 28 jsmith 14 3 T -1 \N \N \N \N \N \N \N \N \N \N 68 0.00 \N 0.00 \N \N \N \N 1752 13 28 jsmith 22 3 T -1 \N \N \N \N \N \N \N \N \N \N 69 13064.13 \N 13064.13 \N \N \N \N 1753 13 28 jsmith 25 3 T -1 \N \N \N \N \N \N \N \N \N \N 72 0.00 \N 0.00 \N \N \N \N 1754 13 28 jsmith 34 3 T -1 \N \N \N \N \N \N \N \N \N \N 71 590.34 \N 590.34 \N \N \N \N 1755 13 28 jsmith 36 3 T -1 \N \N \N \N \N \N \N \N \N \N 73 0.00 \N 0.00 \N \N \N \N 1756 13 28 jsmith 38 3 T -1 \N \N \N \N \N \N \N \N \N \N 74 0.00 \N 0.00 \N \N \N \N 1757 13 28 jsmith 41 3 T -1 \N \N \N \N \N \N \N \N \N \N 75 238.77 \N 238.77 \N \N \N \N 1758 13 28 jsmith 43 3 T -1 \N \N \N \N \N \N \N \N \N \N 76 0.00 \N 0.00 \N \N \N \N 1759 13 28 jsmith 45 2 T -1 \N \N \N \N \N \N \N \N \N \N 61 -8777.89 \N -8777.89 \N \N \N \N 1760 13 28 jsmith 49 3 T -1 \N \N \N \N \N \N \N \N \N \N 79 0.00 \N 0.00 \N \N \N \N 1761 13 28 jsmith 51 3 T -1 \N \N \N \N \N \N \N \N \N \N 80 0.00 \N 0.00 \N \N \N \N 1762 13 28 jsmith 53 2 T -1 \N \N \N \N \N \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1763 13 28 jsmith 57 3 T -1 \N \N \N \N \N \N \N \N \N \N 83 0.00 \N 0.00 \N \N \N \N 1764 13 28 jsmith 62 3 T -1 \N \N \N \N \N \N \N \N \N \N 84 1000000.00 \N 1000000.00 \N \N \N \N 1765 13 28 jsmith 64 2 T -1 \N \N \N \N \N \N \N \N \N \N 82 1000000.00 \N 1000000.00 \N \N \N \N 1766 13 28 jsmith 65 1 T -1 \N \N \N \N \N \N \N \N \N \N 60 991222.11 \N 991222.11 \N \N \N \N 1767 13 28 jsmith 68 0 T -1 \N \N \N \N \N \N \N \N \N \N \N 0.00 \N 0.00 \N \N \N \N 1768 13 30 jsmith 1 0 G 60 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 9074.29 \N 9074.29 \N \N \N \N 1769 13 30 jsmith 2 1 G 61 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 5074.29 \N 5074.29 \N \N \N \N 1770 13 30 jsmith 3 2 G 62 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 4469.47 \N 4469.47 \N \N \N \N 1771 13 30 jsmith 4 3 G 63 \N \N \N \N \N \N \N \N \N \N 62 4469.47 \N 4469.47 \N \N \N \N 1772 13 30 jsmith 6 2 G 65 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1773 13 30 jsmith 7 3 I 119 \N \N \N \N \N \N \N \N \N \N 65 0.00 \N 0.00 \N \N \N \N 1774 13 30 jsmith 9 2 G 66 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1775 13 30 jsmith 10 2 G 67 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1776 13 30 jsmith 12 2 G 68 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1777 13 30 jsmith 13 3 I 120 \N \N \N \N \N \N \N \N \N \N 68 0.00 \N 0.00 \N \N \N \N 1778 13 30 jsmith 15 2 G 69 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 -443.83 \N -443.83 \N \N \N \N 1779 13 30 jsmith 16 3 I 121 \N \N \N \N \N \N \N \N \N \N 69 58749.63 \N 58749.63 \N \N \N \N 1780 13 30 jsmith 17 3 I 122 \N \N \N \N \N \N \N \N \N \N 69 -59354.13 \N -59354.13 \N \N \N \N 1781 13 30 jsmith 18 3 I 123 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1782 13 30 jsmith 19 3 I 124 \N \N \N \N \N \N \N \N \N \N 69 141.00 \N 141.00 \N \N \N \N 1783 13 30 jsmith 20 3 I 137 \N \N \N \N \N \N \N \N \N \N 69 24.62 \N 24.62 \N \N \N \N 1784 13 30 jsmith 21 3 I 138 \N \N \N \N \N \N \N \N \N \N 69 -4.95 \N -4.95 \N \N \N \N 1785 13 30 jsmith 23 2 G 72 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1786 13 30 jsmith 24 3 I 125 \N \N \N \N \N \N \N \N \N \N 72 0.00 \N 0.00 \N \N \N \N 1787 13 30 jsmith 26 2 G 70 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1788 13 30 jsmith 27 2 G 71 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 -56.28 \N -56.28 \N \N \N \N 1789 13 30 jsmith 28 3 I 126 \N \N \N \N \N \N \N \N \N \N 71 -250.40 \N -250.40 \N \N \N \N 1790 13 30 jsmith 29 3 I 127 \N \N \N \N \N \N \N \N \N \N 71 161.14 \N 161.14 \N \N \N \N 1791 13 30 jsmith 30 3 I 128 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1792 13 30 jsmith 31 3 I 129 \N \N \N \N \N \N \N \N \N \N 71 -125.00 \N -125.00 \N \N \N \N 1793 13 30 jsmith 32 3 I 130 \N \N \N \N \N \N \N \N \N \N 71 180.48 \N 180.48 \N \N \N \N 1794 13 30 jsmith 33 3 I 131 \N \N \N \N \N \N \N \N \N \N 71 -22.50 \N -22.50 \N \N \N \N 1795 13 30 jsmith 35 2 G 73 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1796 13 30 jsmith 37 2 G 74 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1797 13 30 jsmith 39 2 G 75 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 217.27 \N 217.27 \N \N \N \N 1798 13 30 jsmith 40 3 I 132 \N \N \N \N \N \N \N \N \N \N 75 217.27 \N 217.27 \N \N \N \N 1799 13 30 jsmith 42 2 G 76 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1800 13 30 jsmith 44 2 G 77 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1801 13 30 jsmith 46 1 G 78 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 1000.00 \N 1000.00 \N \N \N \N 1802 13 30 jsmith 47 2 G 79 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 1000.00 \N 1000.00 \N \N \N \N 1803 13 30 jsmith 48 3 I 133 \N \N \N \N \N \N \N \N \N \N 79 1000.00 \N 1000.00 \N \N \N \N 1804 13 30 jsmith 50 2 G 80 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1805 13 30 jsmith 52 2 G 81 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1806 13 30 jsmith 54 1 G 82 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 5000.00 \N 5000.00 \N \N \N \N 1807 13 30 jsmith 55 2 G 83 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 5000.00 \N 5000.00 \N \N \N \N 1808 13 30 jsmith 56 3 I 139 \N \N \N \N \N \N \N \N \N \N 83 5000.00 \N 5000.00 \N \N \N \N 1809 13 30 jsmith 58 2 G 84 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 0.00 \N 0.00 \N \N \N \N 1810 13 30 jsmith 59 3 I 134 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1811 13 30 jsmith 60 3 I 135 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1812 13 30 jsmith 61 3 I 136 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1813 13 30 jsmith 63 2 G 85 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 0.00 \N 0.00 \N \N \N \N 1814 13 30 jsmith 66 0 G 86 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 -9074.29 \N -9074.29 \N \N \N \N 1815 13 30 jsmith 67 1 I 108 \N \N \N \N \N \N \N \N \N \N 86 9074.29 \N 9074.29 \N \N \N \N 1816 13 30 jsmith 5 3 T -1 \N \N \N \N \N \N \N \N \N \N 62 4469.47 \N 4469.47 \N \N \N \N 1817 13 30 jsmith 8 3 T -1 \N \N \N \N \N \N \N \N \N \N 65 0.00 \N 0.00 \N \N \N \N 1818 13 30 jsmith 11 3 T -1 \N \N \N \N \N \N \N \N \N \N 67 0.00 \N 0.00 \N \N \N \N 1819 13 30 jsmith 14 3 T -1 \N \N \N \N \N \N \N \N \N \N 68 0.00 \N 0.00 \N \N \N \N 1820 13 30 jsmith 22 3 T -1 \N \N \N \N \N \N \N \N \N \N 69 -443.83 \N -443.83 \N \N \N \N 1821 13 30 jsmith 25 3 T -1 \N \N \N \N \N \N \N \N \N \N 72 0.00 \N 0.00 \N \N \N \N 1822 13 30 jsmith 34 3 T -1 \N \N \N \N \N \N \N \N \N \N 71 -56.28 \N -56.28 \N \N \N \N 1823 13 30 jsmith 36 3 T -1 \N \N \N \N \N \N \N \N \N \N 73 0.00 \N 0.00 \N \N \N \N 1824 13 30 jsmith 38 3 T -1 \N \N \N \N \N \N \N \N \N \N 74 0.00 \N 0.00 \N \N \N \N 1825 13 30 jsmith 41 3 T -1 \N \N \N \N \N \N \N \N \N \N 75 217.27 \N 217.27 \N \N \N \N 1826 13 30 jsmith 43 3 T -1 \N \N \N \N \N \N \N \N \N \N 76 0.00 \N 0.00 \N \N \N \N 1827 13 30 jsmith 45 2 T -1 \N \N \N \N \N \N \N \N \N \N 61 5074.29 \N 5074.29 \N \N \N \N 1828 13 30 jsmith 49 3 T -1 \N \N \N \N \N \N \N \N \N \N 79 1000.00 \N 1000.00 \N \N \N \N 1829 13 30 jsmith 51 3 T -1 \N \N \N \N \N \N \N \N \N \N 80 0.00 \N 0.00 \N \N \N \N 1830 13 30 jsmith 53 2 T -1 \N \N \N \N \N \N \N \N \N \N 78 1000.00 \N 1000.00 \N \N \N \N 1831 13 30 jsmith 57 3 T -1 \N \N \N \N \N \N \N \N \N \N 83 5000.00 \N 5000.00 \N \N \N \N 1832 13 30 jsmith 62 3 T -1 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1833 13 30 jsmith 64 2 T -1 \N \N \N \N \N \N \N \N \N \N 82 5000.00 \N 5000.00 \N \N \N \N 1834 13 30 jsmith 65 1 T -1 \N \N \N \N \N \N \N \N \N \N 60 9074.29 \N 9074.29 \N \N \N \N 1835 13 30 jsmith 68 0 T -1 \N \N \N \N \N \N \N \N \N \N \N 0.00 \N 0.00 \N \N \N \N 1836 13 37 mfgadmin 13 3 I 120 \N \N \N \N \N \N \N \N \N \N 68 0.00 \N 0.00 \N \N \N \N 1837 4 39 mfgadmin 1 0 G 3 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1838 4 39 mfgadmin 2 1 G 4 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N \N 3 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1839 4 39 mfgadmin 3 2 I 2 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1840 4 39 mfgadmin 4 2 I 224 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1841 4 39 mfgadmin 5 2 I 225 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1842 4 39 mfgadmin 6 2 I 228 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 0.00 0.00000000000000000000 0.00 \N \N \N \N 1843 4 39 mfgadmin 7 2 I 3 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1844 4 39 mfgadmin 9 1 G 5 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1845 4 39 mfgadmin 10 2 I 4 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 5 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1846 4 39 mfgadmin 13 0 G 7 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1847 4 39 mfgadmin 14 1 G 8 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1848 4 39 mfgadmin 15 2 I 231 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1849 4 39 mfgadmin 16 2 I 232 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1850 4 39 mfgadmin 17 2 I 5 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1851 4 39 mfgadmin 18 2 I 8 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1852 4 39 mfgadmin 19 2 I 226 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1853 4 39 mfgadmin 20 2 I 227 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1854 4 39 mfgadmin 21 2 I 7 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1855 4 39 mfgadmin 22 2 I 6 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1856 4 39 mfgadmin 23 2 I 11 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1857 4 39 mfgadmin 24 2 I 9 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1858 4 39 mfgadmin 25 2 I 10 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1859 4 39 mfgadmin 8 2 T -1 \N 0.00 \N \N \N \N 0.00000000000000000000 \N \N \N 4 0.00 0.00000000000000000000 0.00 0.00000000000000000000 Total Sales \N \N 1860 4 39 mfgadmin 11 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 5 0.00 0.00000000000000000000 0.00 0.00000000000000000000 Total Cost of Goods Sold \N \N 1861 4 39 mfgadmin 12 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 0.00 0.00000000000000000000 0.00 0.00000000000000000000 Total Net Revenue \N \N 1862 4 39 mfgadmin 26 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 Total General Expenses \N \N 1863 4 39 mfgadmin 27 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 0.00 0.00000000000000000000 0.00 0.00000000000000000000 Total Expenses \N \N 1864 4 39 mfgadmin 28 0 T -1 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N \N 0.00 \N 0.00 \N Net Income \N \N 1865 4 38 mfgadmin 22 2 I 6 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1866 4 38 mfgadmin 23 2 I 11 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1867 4 38 mfgadmin 24 2 I 9 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1868 4 38 mfgadmin 25 2 I 10 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1869 4 38 mfgadmin 8 2 T -1 \N 0.00 \N \N \N \N 0.00000000000000000000 \N \N \N 4 0.00 0.00000000000000000000 0.00 0.00000000000000000000 Total Sales \N \N 1870 4 38 mfgadmin 16 2 I 232 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1871 4 37 mfgadmin 1 0 G 3 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1872 4 37 mfgadmin 2 1 G 4 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1873 4 37 mfgadmin 3 2 I 2 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1874 4 37 mfgadmin 4 2 I 224 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1875 4 37 mfgadmin 5 2 I 225 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1876 4 37 mfgadmin 6 2 I 228 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 0.00 0.00000000000000000000 0.00 \N \N \N \N 1877 4 37 mfgadmin 7 2 I 3 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1878 4 37 mfgadmin 9 1 G 5 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 0.00 \N 0.00 \N \N \N \N 1879 4 37 mfgadmin 10 2 I 4 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 5 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1880 4 37 mfgadmin 11 1 G 6 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 3 0.00 \N 0.00 \N \N \N \N 1881 4 37 mfgadmin 13 0 G 7 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 1882 4 37 mfgadmin 14 1 G 8 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1883 4 37 mfgadmin 15 2 I 231 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1884 4 37 mfgadmin 16 2 I 232 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1885 4 37 mfgadmin 17 2 I 5 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1886 4 37 mfgadmin 18 2 I 8 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1887 4 37 mfgadmin 19 2 I 226 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1888 4 37 mfgadmin 20 2 I 227 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1889 4 37 mfgadmin 21 2 I 7 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1890 4 37 mfgadmin 22 2 I 6 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1891 4 37 mfgadmin 23 2 I 11 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1892 4 37 mfgadmin 24 2 I 9 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1893 4 37 mfgadmin 25 2 I 10 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1894 4 37 mfgadmin 27 0 G 9 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 1895 4 37 mfgadmin 8 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 4 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1896 4 37 mfgadmin 12 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1897 4 37 mfgadmin 26 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1898 4 37 mfgadmin 28 0 T -1 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N \N 0.00 \N 0.00 \N \N \N \N 1899 13 37 mfgadmin 1 0 G 60 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 1900 13 37 mfgadmin 2 1 G 61 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 0.00 \N 0.00 \N \N \N \N 1901 13 37 mfgadmin 3 2 G 62 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1902 13 37 mfgadmin 4 3 G 63 \N \N \N \N \N \N \N \N \N \N 62 0.00 \N 0.00 \N \N \N \N 1903 13 37 mfgadmin 40 3 I 132 \N \N \N \N \N \N \N \N \N \N 75 0.00 \N 0.00 \N \N \N \N 1904 13 37 mfgadmin 6 2 G 65 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1905 13 37 mfgadmin 7 3 I 119 \N \N \N \N \N \N \N \N \N \N 65 0.00 \N 0.00 \N \N \N \N 1906 13 37 mfgadmin 9 2 G 66 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1907 13 37 mfgadmin 10 2 G 67 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1908 13 37 mfgadmin 12 2 G 68 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1909 13 37 mfgadmin 15 2 G 69 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1910 13 37 mfgadmin 16 3 I 121 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1911 13 37 mfgadmin 17 3 I 122 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1912 13 37 mfgadmin 18 3 I 123 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1913 13 37 mfgadmin 19 3 I 124 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1914 13 37 mfgadmin 20 3 I 137 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1915 13 37 mfgadmin 21 3 I 138 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1916 13 37 mfgadmin 23 2 G 72 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1917 13 37 mfgadmin 24 3 I 125 \N \N \N \N \N \N \N \N \N \N 72 0.00 \N 0.00 \N \N \N \N 1918 13 37 mfgadmin 26 2 G 70 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1919 13 37 mfgadmin 27 2 G 71 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1920 13 37 mfgadmin 28 3 I 126 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1921 13 37 mfgadmin 29 3 I 127 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1922 13 37 mfgadmin 30 3 I 128 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1923 13 37 mfgadmin 31 3 I 129 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1924 13 37 mfgadmin 32 3 I 130 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1925 13 37 mfgadmin 33 3 I 131 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1926 13 37 mfgadmin 35 2 G 73 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1927 13 37 mfgadmin 37 2 G 74 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1928 13 37 mfgadmin 39 2 G 75 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1929 13 37 mfgadmin 42 2 G 76 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1930 13 37 mfgadmin 44 2 G 77 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1931 13 37 mfgadmin 46 1 G 78 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 0.00 \N 0.00 \N \N \N \N 1932 13 37 mfgadmin 47 2 G 79 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1933 13 37 mfgadmin 48 3 I 133 \N \N \N \N \N \N \N \N \N \N 79 0.00 \N 0.00 \N \N \N \N 1934 13 37 mfgadmin 50 2 G 80 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1935 13 37 mfgadmin 52 2 G 81 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1936 13 37 mfgadmin 54 1 G 82 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 60 0.00 \N 0.00 \N \N \N \N 1937 13 37 mfgadmin 55 2 G 83 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 0.00 \N 0.00 \N \N \N \N 1938 13 37 mfgadmin 56 3 I 139 \N \N \N \N \N \N \N \N \N \N 83 0.00 \N 0.00 \N \N \N \N 1939 13 37 mfgadmin 58 2 G 84 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 0.00 \N 0.00 \N \N \N \N 1940 13 37 mfgadmin 59 3 I 134 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1941 13 37 mfgadmin 60 3 I 135 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1942 13 37 mfgadmin 61 3 I 136 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1943 13 37 mfgadmin 63 2 G 85 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 82 0.00 \N 0.00 \N \N \N \N 1944 13 37 mfgadmin 66 0 G 86 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 1945 13 37 mfgadmin 67 1 I 108 \N \N \N \N \N \N \N \N \N \N 86 0.00 \N 0.00 \N \N \N \N 1946 13 37 mfgadmin 5 3 T -1 \N \N \N \N \N \N \N \N \N \N 62 0.00 \N 0.00 \N \N \N \N 1947 13 37 mfgadmin 8 3 T -1 \N \N \N \N \N \N \N \N \N \N 65 0.00 \N 0.00 \N \N \N \N 1948 13 37 mfgadmin 11 3 T -1 \N \N \N \N \N \N \N \N \N \N 67 0.00 \N 0.00 \N \N \N \N 1949 13 37 mfgadmin 14 3 T -1 \N \N \N \N \N \N \N \N \N \N 68 0.00 \N 0.00 \N \N \N \N 1950 13 37 mfgadmin 22 3 T -1 \N \N \N \N \N \N \N \N \N \N 69 0.00 \N 0.00 \N \N \N \N 1951 13 37 mfgadmin 25 3 T -1 \N \N \N \N \N \N \N \N \N \N 72 0.00 \N 0.00 \N \N \N \N 1952 13 37 mfgadmin 34 3 T -1 \N \N \N \N \N \N \N \N \N \N 71 0.00 \N 0.00 \N \N \N \N 1953 13 37 mfgadmin 36 3 T -1 \N \N \N \N \N \N \N \N \N \N 73 0.00 \N 0.00 \N \N \N \N 1954 13 37 mfgadmin 38 3 T -1 \N \N \N \N \N \N \N \N \N \N 74 0.00 \N 0.00 \N \N \N \N 1955 13 37 mfgadmin 41 3 T -1 \N \N \N \N \N \N \N \N \N \N 75 0.00 \N 0.00 \N \N \N \N 1956 13 37 mfgadmin 43 3 T -1 \N \N \N \N \N \N \N \N \N \N 76 0.00 \N 0.00 \N \N \N \N 1957 13 37 mfgadmin 45 2 T -1 \N \N \N \N \N \N \N \N \N \N 61 0.00 \N 0.00 \N \N \N \N 1958 13 37 mfgadmin 49 3 T -1 \N \N \N \N \N \N \N \N \N \N 79 0.00 \N 0.00 \N \N \N \N 1959 13 37 mfgadmin 51 3 T -1 \N \N \N \N \N \N \N \N \N \N 80 0.00 \N 0.00 \N \N \N \N 1960 13 37 mfgadmin 53 2 T -1 \N \N \N \N \N \N \N \N \N \N 78 0.00 \N 0.00 \N \N \N \N 1961 13 37 mfgadmin 57 3 T -1 \N \N \N \N \N \N \N \N \N \N 83 0.00 \N 0.00 \N \N \N \N 1962 13 37 mfgadmin 62 3 T -1 \N \N \N \N \N \N \N \N \N \N 84 0.00 \N 0.00 \N \N \N \N 1963 13 37 mfgadmin 64 2 T -1 \N \N \N \N \N \N \N \N \N \N 82 0.00 \N 0.00 \N \N \N \N 1964 13 37 mfgadmin 65 1 T -1 \N \N \N \N \N \N \N \N \N \N 60 0.00 \N 0.00 \N \N \N \N 1965 13 37 mfgadmin 68 0 T -1 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N \N 0.00 \N 0.00 \N \N \N \N 1966 4 38 mfgadmin 11 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 5 0.00 0.00000000000000000000 0.00 0.00000000000000000000 Total Cost of Goods Sold \N \N 1967 4 38 mfgadmin 12 1 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 0.00 0.00000000000000000000 0.00 0.00000000000000000000 Total Net Revenue \N \N 1968 4 38 mfgadmin 26 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 Total General Expense \N \N 1969 4 38 mfgadmin 27 1 T -1 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 7 \N \N 0.00 0.00000000000000000000 Total Expenses \N \N 1970 4 38 mfgadmin 28 0 T -1 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N \N 0.00 \N 0.00 \N Net Income \N \N 1971 4 38 mfgadmin 1 0 G 3 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 -1 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1972 4 38 mfgadmin 2 1 G 4 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N \N 3 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1973 4 38 mfgadmin 3 2 I 2 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1974 4 38 mfgadmin 4 2 I 224 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1975 4 38 mfgadmin 5 2 I 225 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1976 4 38 mfgadmin 6 2 I 228 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 0.00 0.00000000000000000000 0.00 \N \N \N \N 1977 4 38 mfgadmin 7 2 I 3 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 4 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1978 4 38 mfgadmin 9 1 G 5 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 3 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1979 4 38 mfgadmin 10 2 I 4 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 5 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1980 4 38 mfgadmin 13 0 G 7 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 0.00000000000000000000 \N \N \N 1981 4 38 mfgadmin 14 1 G 8 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 7 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1982 4 38 mfgadmin 15 2 I 231 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1983 4 38 mfgadmin 17 2 I 5 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1984 4 38 mfgadmin 18 2 I 8 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1985 4 38 mfgadmin 19 2 I 226 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1986 4 38 mfgadmin 20 2 I 227 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1987 4 38 mfgadmin 21 2 I 7 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 8 0.00 0.00000000000000000000 0.00 0.00000000000000000000 \N \N \N 1988 11 39 mfgadmin 9 2 I 71 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1989 11 39 mfgadmin 10 2 I 72 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1990 11 39 mfgadmin 11 2 I 73 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1991 11 39 mfgadmin 12 2 I 74 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1992 11 39 mfgadmin 13 2 I 75 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 1993 11 39 mfgadmin 15 1 G 46 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 1994 11 39 mfgadmin 16 2 I 76 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 1995 11 39 mfgadmin 18 1 G 47 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 1996 11 39 mfgadmin 21 0 G 36 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 1997 11 39 mfgadmin 22 1 G 37 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 0.00 \N \N \N \N 1998 11 39 mfgadmin 23 2 G 38 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 1999 11 39 mfgadmin 24 3 I 47 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2000 11 39 mfgadmin 25 3 I 46 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2001 11 39 mfgadmin 26 3 I 48 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2002 11 39 mfgadmin 27 3 I 49 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2003 11 39 mfgadmin 28 3 I 50 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2004 11 39 mfgadmin 29 3 I 51 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2005 11 39 mfgadmin 30 3 I 215 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2006 11 39 mfgadmin 32 2 G 39 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 2007 11 39 mfgadmin 33 3 I 140 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N \N \N \N 2008 11 39 mfgadmin 36 1 G 40 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 0.00 \N \N \N \N 2009 11 39 mfgadmin 37 2 G 41 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 0.00 \N \N \N \N 2010 11 39 mfgadmin 38 3 I 52 \N 0.00 \N \N \N \N \N \N \N \N 41 \N \N 0.00 \N \N \N \N 2011 11 39 mfgadmin 40 2 G 42 \N 0.00 \N \N \N \N \N \N \N \N 40 \N \N 0.00 \N \N \N \N 2012 11 39 mfgadmin 41 2 G 43 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 0.00 \N \N \N \N 2013 11 39 mfgadmin 42 3 I 63 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 2014 11 39 mfgadmin 43 3 I 64 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 2015 11 39 mfgadmin 14 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N Total Current Assets \N \N 2016 11 39 mfgadmin 17 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N Total Fixed Assets \N \N 2017 11 39 mfgadmin 19 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 47 \N \N 0.00 \N Total Other Assets \N \N 2018 11 39 mfgadmin 20 1 T -1 \N 0.00 \N \N \N \N \N \N \N \N 44 \N \N 0.00 \N Total Assets \N \N 2019 11 39 mfgadmin 31 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N Total Current Liabilities \N \N 2020 11 39 mfgadmin 34 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N Total Long Term Liabilities \N \N 2021 11 39 mfgadmin 35 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 37 \N \N 0.00 \N Total Liabilities \N \N 2022 11 39 mfgadmin 39 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 41 \N \N 0.00 \N Total Shareholders Equity \N \N 2023 11 39 mfgadmin 44 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N Total Retained Earnings \N \N 2024 11 39 mfgadmin 45 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 40 \N \N 0.00 \N Total Owners Equity \N \N 2025 11 39 mfgadmin 46 1 T -1 \N 0.00 \N \N \N \N \N \N \N \N 36 \N \N 0.00 \N Total Liabilities and Owners Equity \N \N 2026 11 39 mfgadmin 47 0 T -1 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N \N 0.00 \N 0.00 \N Balance Check Sum \N \N 2027 11 39 mfgadmin 1 0 G 44 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 2028 11 39 mfgadmin 2 1 G 45 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 2029 11 39 mfgadmin 3 2 I 65 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2030 11 39 mfgadmin 4 2 I 66 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2031 11 39 mfgadmin 5 2 I 67 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2032 11 39 mfgadmin 6 2 I 68 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2033 11 39 mfgadmin 7 2 I 69 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2034 11 39 mfgadmin 8 2 I 70 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2035 11 38 mfgadmin 37 2 G 41 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 0.00 \N \N \N \N 2036 11 38 mfgadmin 38 3 I 52 \N 0.00 \N \N \N \N \N \N \N \N 41 \N \N 0.00 \N \N \N \N 2037 11 38 mfgadmin 40 2 G 42 \N 0.00 \N \N \N \N \N \N \N \N 40 \N \N 0.00 \N \N \N \N 2038 11 38 mfgadmin 41 2 G 43 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 0.00 \N \N \N \N 2039 11 38 mfgadmin 42 3 I 63 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 2040 11 38 mfgadmin 43 3 I 64 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 2041 11 38 mfgadmin 14 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N Total Current Assets \N \N 2042 11 38 mfgadmin 17 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N Total Fixed Assets \N \N 2043 11 38 mfgadmin 19 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 47 \N \N 0.00 \N Total Other Assets \N \N 2044 11 38 mfgadmin 20 1 T -1 \N 0.00 \N \N \N \N \N \N \N \N 44 \N \N 0.00 \N Total Assets \N \N 2045 11 38 mfgadmin 31 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N Total Current Liabilities \N \N 2046 11 38 mfgadmin 35 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 37 \N \N 0.00 \N Total Liabilities \N \N 2047 11 38 mfgadmin 39 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 41 \N \N 0.00 \N Total Shareholders Equity \N \N 2048 11 38 mfgadmin 44 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N Total Retained Earnings \N \N 2049 11 38 mfgadmin 45 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 40 \N \N 0.00 \N Total Owners Equity \N \N 2050 11 38 mfgadmin 46 1 T -1 \N 0.00 \N \N \N \N \N \N \N \N 36 \N \N 0.00 \N Total Liabilities and Owners Equity \N \N 2051 11 38 mfgadmin 47 0 T -1 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N \N 0.00 \N 0.00 \N Balance Check Sum \N \N 2052 11 38 mfgadmin 1 0 G 44 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 2053 11 38 mfgadmin 2 1 G 45 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 2054 11 38 mfgadmin 3 2 I 65 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2055 11 38 mfgadmin 4 2 I 66 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2056 11 38 mfgadmin 5 2 I 67 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2057 11 38 mfgadmin 6 2 I 68 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2058 11 38 mfgadmin 7 2 I 69 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2059 11 38 mfgadmin 8 2 I 70 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2060 11 38 mfgadmin 9 2 I 71 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2061 11 38 mfgadmin 10 2 I 72 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2062 11 37 mfgadmin 1 0 G 44 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 2063 11 37 mfgadmin 2 1 G 45 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 2064 11 37 mfgadmin 3 2 I 65 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2065 11 37 mfgadmin 4 2 I 66 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2066 11 37 mfgadmin 5 2 I 67 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2067 11 37 mfgadmin 6 2 I 68 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2068 11 37 mfgadmin 7 2 I 69 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2069 11 37 mfgadmin 8 2 I 70 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2070 11 37 mfgadmin 9 2 I 71 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2071 11 37 mfgadmin 10 2 I 72 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2072 11 37 mfgadmin 11 2 I 73 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2073 11 37 mfgadmin 12 2 I 74 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2074 11 37 mfgadmin 13 2 I 75 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2075 11 37 mfgadmin 15 1 G 46 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 2076 11 37 mfgadmin 16 2 I 76 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 2077 11 37 mfgadmin 18 1 G 47 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 2078 11 37 mfgadmin 21 0 G 36 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 2079 11 37 mfgadmin 22 1 G 37 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 0.00 \N \N \N \N 2080 11 37 mfgadmin 23 2 G 38 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 2081 11 37 mfgadmin 24 3 I 47 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2082 11 37 mfgadmin 25 3 I 46 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2083 11 37 mfgadmin 26 3 I 48 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2084 11 37 mfgadmin 27 3 I 49 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2085 11 37 mfgadmin 28 3 I 50 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2086 11 37 mfgadmin 29 3 I 51 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2087 11 37 mfgadmin 30 3 I 215 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2088 11 37 mfgadmin 32 2 G 39 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 2089 11 37 mfgadmin 33 3 I 140 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N \N \N \N 2090 11 37 mfgadmin 36 1 G 40 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 0.00 \N \N \N \N 2091 11 37 mfgadmin 37 2 G 41 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 0.00 \N \N \N \N 2092 11 37 mfgadmin 38 3 I 52 \N 0.00 \N \N \N \N \N \N \N \N 41 \N \N 0.00 \N \N \N \N 2093 11 37 mfgadmin 40 2 G 42 \N 0.00 \N \N \N \N \N \N \N \N 40 \N \N 0.00 \N \N \N \N 2094 11 37 mfgadmin 41 2 G 43 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 40 0.00 \N 0.00 \N \N \N \N 2095 11 37 mfgadmin 42 3 I 63 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 2096 11 37 mfgadmin 43 3 I 64 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N \N \N \N 2097 11 37 mfgadmin 14 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N Total Current Assets \N \N 2098 11 37 mfgadmin 17 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N Total Fixed Assets \N \N 2099 11 37 mfgadmin 19 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 47 \N \N 0.00 \N Total Other Assets \N \N 2100 11 37 mfgadmin 20 1 T -1 \N 0.00 \N \N \N \N \N \N \N \N 44 \N \N 0.00 \N Total Assets \N \N 2101 11 37 mfgadmin 31 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N Total Current Liabilities \N \N 2102 11 37 mfgadmin 34 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N Total Long Term Liabilities \N \N 2103 11 37 mfgadmin 35 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 37 \N \N 0.00 \N Total Liabilities \N \N 2104 11 37 mfgadmin 39 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 41 \N \N 0.00 \N Total Shareholders Equity \N \N 2105 11 37 mfgadmin 44 3 T -1 \N 0.00 \N \N \N \N \N \N \N \N 43 \N \N 0.00 \N Total Retained Earnings \N \N 2106 11 37 mfgadmin 45 2 T -1 \N 0.00 \N \N \N \N \N \N \N \N 40 \N \N 0.00 \N Total Owners Equity \N \N 2107 11 37 mfgadmin 46 1 T -1 \N 0.00 \N \N \N \N \N \N \N \N 36 \N \N 0.00 \N Total Liabilities and Owners Equity \N \N 2108 11 37 mfgadmin 47 0 T -1 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N \N 0.00 \N 0.00 \N Balance Check Sum \N \N 2109 11 38 mfgadmin 11 2 I 73 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2110 11 38 mfgadmin 12 2 I 74 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2111 11 38 mfgadmin 13 2 I 75 \N 0.00 \N \N \N \N \N \N \N \N 45 \N \N 0.00 \N \N \N \N 2112 11 38 mfgadmin 15 1 G 46 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 2113 11 38 mfgadmin 16 2 I 76 \N 0.00 \N \N \N \N \N \N \N \N 46 \N \N 0.00 \N \N \N \N 2114 11 38 mfgadmin 18 1 G 47 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 44 0.00 \N 0.00 \N \N \N \N 2115 11 38 mfgadmin 21 0 G 36 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N \N 2116 11 38 mfgadmin 22 1 G 37 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 0.00 \N \N \N \N 2117 11 38 mfgadmin 23 2 G 38 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 2118 11 38 mfgadmin 24 3 I 47 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2119 11 38 mfgadmin 25 3 I 46 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2120 11 38 mfgadmin 26 3 I 48 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2121 11 38 mfgadmin 27 3 I 49 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2122 11 38 mfgadmin 28 3 I 50 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2123 11 38 mfgadmin 29 3 I 51 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2124 11 38 mfgadmin 30 3 I 215 \N 0.00 \N \N \N \N \N \N \N \N 38 \N \N 0.00 \N \N \N \N 2125 11 38 mfgadmin 32 2 G 39 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 37 0.00 \N 0.00 \N \N \N \N 2126 11 38 mfgadmin 33 3 I 140 \N 0.00 \N \N \N \N \N \N \N \N 39 \N \N 0.00 \N \N \N \N 2127 11 38 mfgadmin 36 1 G 40 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 36 0.00 \N 0.00 \N \N \N \N 2128 15 44 mfgadmin 2 0 G 92 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N M 2129 15 44 mfgadmin 3 1 G 93 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 92 0.00 \N 0.00 \N \N \N M 2130 15 44 mfgadmin 4 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 103 M 2131 15 44 mfgadmin 5 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 117 M 2132 15 44 mfgadmin 6 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 118 M 2133 15 44 mfgadmin 7 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 121 M 2134 15 44 mfgadmin 8 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 101 M 2135 15 44 mfgadmin 9 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 115 M 2136 15 44 mfgadmin 11 1 G 94 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 92 0.00 \N 0.00 \N \N \N M 2137 15 44 mfgadmin 12 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 108 M 2138 15 44 mfgadmin 13 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 122 M 2139 15 44 mfgadmin 14 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 123 M 2140 15 44 mfgadmin 15 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 97 M 2141 15 44 mfgadmin 16 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 119 M 2142 15 44 mfgadmin 17 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 120 M 2143 15 44 mfgadmin 18 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 112 M 2144 15 44 mfgadmin 19 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 98 M 2145 15 44 mfgadmin 20 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 110 M 2146 15 44 mfgadmin 21 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 91 M 2147 15 44 mfgadmin 22 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 92 M 2148 15 44 mfgadmin 23 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 93 M 2149 15 44 mfgadmin 10 2 T -1 \N \N \N \N 0.00 \N \N \N \N \N 93 0.00 \N \N \N Total Net Revenue \N M 2150 15 44 mfgadmin 24 2 T -1 \N \N \N \N 0.00 \N \N \N \N \N 94 0.00 \N \N \N Total Net Expenses \N M 2151 15 44 mfgadmin 25 1 T -1 \N \N \N \N 0.00 \N \N \N \N \N 92 0.00 \N \N \N Net Income \N M 2152 14 39 mfgadmin 2 0 G 87 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N Y 2153 14 39 mfgadmin 3 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 109 Y 2154 14 39 mfgadmin 4 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 106 Y 2155 14 39 mfgadmin 5 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 86 Y 2156 14 39 mfgadmin 6 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 85 Y 2157 14 39 mfgadmin 7 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 96 Y 2158 14 39 mfgadmin 8 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 100 Y 2159 14 39 mfgadmin 9 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 87 Y 2160 14 39 mfgadmin 10 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 90 Y 2161 14 39 mfgadmin 11 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 88 Y 2162 14 39 mfgadmin 12 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 111 Y 2163 14 39 mfgadmin 13 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 89 Y 2164 14 39 mfgadmin 14 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 83 Y 2165 14 39 mfgadmin 16 0 G 88 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N Y 2166 14 39 mfgadmin 17 1 G 89 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 88 0.00 \N 0.00 \N \N \N Y 2167 14 39 mfgadmin 18 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 99 Y 2168 14 39 mfgadmin 19 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 124 Y 2169 14 39 mfgadmin 20 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 94 Y 2170 14 39 mfgadmin 21 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 102 Y 2171 14 39 mfgadmin 22 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 104 Y 2172 14 39 mfgadmin 23 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 107 Y 2173 14 39 mfgadmin 24 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 105 Y 2174 14 39 mfgadmin 25 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 95 Y 2175 14 39 mfgadmin 26 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 116 Y 2176 14 39 mfgadmin 28 1 G 90 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 88 0.00 \N 0.00 \N \N \N Y 2177 14 39 mfgadmin 29 2 I 239 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 90 0.00 \N \N \N \N 113 Y 2178 14 39 mfgadmin 30 2 I 239 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 90 0.00 \N \N \N \N 84 Y 2179 14 39 mfgadmin 31 2 G 91 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 90 \N \N \N \N \N \N Y 2180 14 39 mfgadmin 15 1 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 87 \N \N \N \N Total Assets \N Y 2181 14 39 mfgadmin 27 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 \N \N \N \N Total Liabilities \N Y 2182 14 39 mfgadmin 32 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 90 \N \N \N \N Total Owners Equity \N Y 2183 14 39 mfgadmin 33 1 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 88 \N \N \N \N Total Liabilities and Owners Equity \N Y 2184 14 63 mfgadmin 2 0 G 87 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N Y 2185 14 63 mfgadmin 3 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 109 Y 2186 14 63 mfgadmin 4 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 106 Y 2187 14 63 mfgadmin 5 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 86 Y 2188 14 63 mfgadmin 6 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 85 Y 2189 14 63 mfgadmin 7 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 96 Y 2190 14 63 mfgadmin 8 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 100 Y 2191 14 63 mfgadmin 9 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 87 Y 2192 14 63 mfgadmin 10 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 90 Y 2193 14 63 mfgadmin 11 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 88 Y 2194 14 63 mfgadmin 12 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 111 Y 2195 14 63 mfgadmin 13 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 89 Y 2196 14 63 mfgadmin 14 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 83 Y 2197 14 63 mfgadmin 16 0 G 88 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N Y 2198 14 63 mfgadmin 17 1 G 89 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 88 0.00 \N 0.00 \N \N \N Y 2199 14 63 mfgadmin 18 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 99 Y 2200 14 63 mfgadmin 19 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 124 Y 2201 14 63 mfgadmin 20 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 94 Y 2202 14 63 mfgadmin 21 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 102 Y 2203 14 63 mfgadmin 22 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 104 Y 2204 14 63 mfgadmin 23 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 107 Y 2205 14 63 mfgadmin 24 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 105 Y 2206 14 63 mfgadmin 25 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 95 Y 2207 14 63 mfgadmin 26 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 116 Y 2208 14 63 mfgadmin 28 1 G 90 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 88 0.00 \N 0.00 \N \N \N Y 2209 14 63 mfgadmin 29 2 I 239 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 90 0.00 \N \N \N \N 113 Y 2210 14 63 mfgadmin 30 2 I 239 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 90 0.00 \N \N \N \N 84 Y 2211 14 63 mfgadmin 31 2 G 91 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 90 \N \N \N \N \N \N Y 2212 14 63 mfgadmin 15 1 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 87 \N \N \N \N Total Assets \N Y 2213 14 63 mfgadmin 27 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 \N \N \N \N Total Liabilities \N Y 2214 14 63 mfgadmin 32 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 90 \N \N \N \N Total Owners Equity \N Y 2215 14 63 mfgadmin 33 1 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 88 \N \N \N \N Total Liabilities and Owners Equity \N Y 2216 14 51 mfgadmin 2 0 G 87 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N Y 2217 14 51 mfgadmin 3 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 109 Y 2218 14 51 mfgadmin 4 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 106 Y 2219 14 51 mfgadmin 5 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 86 Y 2220 14 51 mfgadmin 6 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 85 Y 2221 14 51 mfgadmin 7 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 96 Y 2222 14 51 mfgadmin 8 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 100 Y 2223 14 51 mfgadmin 9 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 87 Y 2224 14 51 mfgadmin 10 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 90 Y 2225 14 51 mfgadmin 11 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 88 Y 2226 14 51 mfgadmin 12 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 111 Y 2227 14 51 mfgadmin 13 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 89 Y 2228 14 51 mfgadmin 14 1 I 237 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 87 0.00 \N \N \N \N 83 Y 2229 14 51 mfgadmin 16 0 G 88 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N Y 2230 14 51 mfgadmin 17 1 G 89 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 88 0.00 \N 0.00 \N \N \N Y 2231 14 51 mfgadmin 18 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 99 Y 2232 14 51 mfgadmin 19 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 124 Y 2233 14 51 mfgadmin 20 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 94 Y 2234 14 51 mfgadmin 21 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 102 Y 2235 14 51 mfgadmin 22 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 104 Y 2236 14 51 mfgadmin 23 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 107 Y 2237 14 51 mfgadmin 24 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 105 Y 2238 14 51 mfgadmin 25 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 95 Y 2239 14 51 mfgadmin 26 2 I 238 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 0.00 \N \N \N \N 116 Y 2240 14 51 mfgadmin 28 1 G 90 0.00 0.00 0.00 0.00 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 88 0.00 \N 0.00 \N \N \N Y 2241 14 51 mfgadmin 29 2 I 239 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 90 0.00 \N \N \N \N 113 Y 2242 14 51 mfgadmin 30 2 I 239 \N 0.00 \N \N 0 \N 0.00000000000000000000 \N \N 0.00000000000000000000 90 0.00 \N \N \N \N 84 Y 2243 14 51 mfgadmin 31 2 G 91 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 90 \N \N \N \N \N \N Y 2244 14 51 mfgadmin 15 1 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 87 \N \N \N \N Total Assets \N Y 2245 14 51 mfgadmin 27 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 89 \N \N \N \N Total Liabilities \N Y 2246 14 51 mfgadmin 32 2 T -1 \N 0.00 \N \N 0.00 \N 0.00000000000000000000 \N \N 0.00000000000000000000 90 \N \N \N \N Total Owners Equity \N Y 2247 14 51 mfgadmin 33 1 T -1 \N 0.00 \N \N 0.00 \N \N \N \N \N 88 \N \N \N \N Total Liabilities and Owners Equity \N Y 2248 15 39 mfgadmin 2 0 G 92 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N Y 2249 15 39 mfgadmin 3 1 G 93 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 92 0.00 \N 0.00 \N \N \N Y 2250 15 39 mfgadmin 4 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 103 Y 2251 15 39 mfgadmin 5 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 117 Y 2252 15 39 mfgadmin 6 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 118 Y 2253 15 39 mfgadmin 7 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 121 Y 2254 15 39 mfgadmin 8 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 101 Y 2255 15 39 mfgadmin 9 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 115 Y 2256 15 39 mfgadmin 11 1 G 94 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 92 0.00 \N 0.00 \N \N \N Y 2257 15 39 mfgadmin 12 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 108 Y 2258 15 39 mfgadmin 13 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 122 Y 2259 15 39 mfgadmin 14 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 123 Y 2260 15 39 mfgadmin 15 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 97 Y 2261 15 39 mfgadmin 16 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 119 Y 2262 15 39 mfgadmin 17 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 120 Y 2263 15 39 mfgadmin 18 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 112 Y 2264 15 39 mfgadmin 19 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 98 Y 2265 15 39 mfgadmin 20 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 110 Y 2266 15 39 mfgadmin 21 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 91 Y 2267 15 39 mfgadmin 22 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 92 Y 2268 15 39 mfgadmin 23 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 93 Y 2269 15 39 mfgadmin 10 2 T -1 \N \N \N \N 0.00 \N \N \N \N \N 93 0.00 \N \N \N Total Net Revenue \N Y 2270 15 39 mfgadmin 24 2 T -1 \N \N \N \N 0.00 \N \N \N \N \N 94 0.00 \N \N \N Total Net Expenses \N Y 2271 15 39 mfgadmin 25 1 T -1 \N \N \N \N 0.00 \N \N \N \N \N 92 0.00 \N \N \N Net Income \N Y 2272 15 51 mfgadmin 4 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 103 Y 2273 15 51 mfgadmin 2 0 G 92 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N Y 2274 15 51 mfgadmin 3 1 G 93 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 92 0.00 \N 0.00 \N \N \N Y 2275 15 51 mfgadmin 5 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 117 Y 2276 15 51 mfgadmin 6 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 118 Y 2277 15 51 mfgadmin 7 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 121 Y 2278 15 51 mfgadmin 8 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 101 Y 2279 15 51 mfgadmin 9 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 115 Y 2280 15 51 mfgadmin 11 1 G 94 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 92 0.00 \N 0.00 \N \N \N Y 2281 15 51 mfgadmin 12 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 108 Y 2282 15 51 mfgadmin 13 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 122 Y 2283 15 51 mfgadmin 14 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 123 Y 2284 15 51 mfgadmin 15 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 97 Y 2285 15 51 mfgadmin 16 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 119 Y 2286 15 51 mfgadmin 17 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 120 Y 2287 15 51 mfgadmin 18 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 112 Y 2288 15 51 mfgadmin 19 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 98 Y 2289 15 51 mfgadmin 20 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 110 Y 2290 15 51 mfgadmin 21 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 91 Y 2291 15 51 mfgadmin 22 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 92 Y 2292 15 51 mfgadmin 23 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 93 Y 2293 15 51 mfgadmin 10 2 T -1 \N \N \N \N 0.00 \N \N \N \N \N 93 0.00 \N \N \N Total Net Revenue \N Y 2294 15 51 mfgadmin 24 2 T -1 \N \N \N \N 0.00 \N \N \N \N \N 94 0.00 \N \N \N Total Net Expenses \N Y 2295 15 51 mfgadmin 25 1 T -1 \N \N \N \N 0.00 \N \N \N \N \N 92 0.00 \N \N \N Net Income \N Y 2296 15 63 mfgadmin 2 0 G 92 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N -1 0.00 \N 0.00 \N \N \N Y 2297 15 63 mfgadmin 3 1 G 93 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 92 0.00 \N 0.00 \N \N \N Y 2298 15 63 mfgadmin 4 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 103 Y 2299 15 63 mfgadmin 5 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 117 Y 2300 15 63 mfgadmin 6 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 118 Y 2301 15 63 mfgadmin 7 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 121 Y 2302 15 63 mfgadmin 8 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 101 Y 2303 15 63 mfgadmin 9 2 I 242 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 93 0.00 0.00000000000000000000 \N \N \N 115 Y 2304 15 63 mfgadmin 11 1 G 94 0.00 0.00 0.00 0.00 0.00 \N \N \N \N \N 92 0.00 \N 0.00 \N \N \N Y 2305 15 63 mfgadmin 12 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 108 Y 2306 15 63 mfgadmin 13 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 122 Y 2307 15 63 mfgadmin 14 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 123 Y 2308 15 63 mfgadmin 15 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 97 Y 2309 15 63 mfgadmin 16 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 119 Y 2310 15 63 mfgadmin 17 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 120 Y 2311 15 63 mfgadmin 18 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 112 Y 2312 15 63 mfgadmin 19 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 98 Y 2313 15 63 mfgadmin 20 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 110 Y 2314 15 63 mfgadmin 21 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 91 Y 2315 15 63 mfgadmin 22 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 92 Y 2316 15 63 mfgadmin 23 2 I 243 \N \N \N \N 0 \N \N \N \N 0.00000000000000000000 94 0.00 0.00000000000000000000 \N \N \N 93 Y 2317 15 63 mfgadmin 10 2 T -1 \N \N \N \N 0.00 \N \N \N \N \N 93 0.00 \N \N \N Total Net Revenue \N Y 2318 15 63 mfgadmin 24 2 T -1 \N \N \N \N 0.00 \N \N \N \N \N 94 0.00 \N \N \N Total Net Expenses \N Y 2319 15 63 mfgadmin 25 1 T -1 \N \N \N \N 0.00 \N \N \N \N \N 92 0.00 \N \N \N Net Income \N Y 2320 16 73 admin 1 0 G 95 0.00 0.00 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 -1 0.00 0.00000000000000000000 0.00 \N \N \N M 2321 16 73 admin 2 1 G 97 0.00 0.00 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 95 0.00 0.00000000000000000000 0.00 \N \N \N M 2322 16 73 admin 3 2 G 100 0.00 0.00 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 97 0.00 0.00000000000000000000 0.00 \N \N \N M 2323 16 73 admin 4 3 G 111 \N \N 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 100 0.00 0.00000000000000000000 \N \N \N \N M 2324 16 73 admin 6 2 G 101 0.00 0.00 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 97 0.00 0.00000000000000000000 0.00 \N \N \N M 2325 16 73 admin 7 3 I 246 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 101 0.00 0.00000000000000000000 \N \N \N 112 M 2326 16 73 admin 9 2 G 102 0.00 0.00 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 97 0.00 0.00000000000000000000 0.00 \N \N \N M 2327 16 73 admin 10 3 I 247 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 102 0.00 0.00000000000000000000 \N \N \N 100 M 2328 16 73 admin 12 2 G 103 0.00 0.00 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 97 0.00 0.00000000000000000000 0.00 \N \N \N M 2329 16 73 admin 13 3 I 248 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 103 0.00 0.00000000000000000000 \N \N \N 106 M 2330 16 73 admin 15 2 G 104 0.00 0.00 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 97 0.00 0.00000000000000000000 0.00 \N \N \N M 2331 16 73 admin 16 3 I 249 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 104 0.00 0.00000000000000000000 \N \N \N 86 M 2332 16 73 admin 17 3 I 249 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 104 0.00 0.00000000000000000000 \N \N \N 85 M 2333 16 73 admin 18 3 I 249 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 104 0.00 0.00000000000000000000 \N \N \N 96 M 2334 16 73 admin 19 3 I 249 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 104 0.00 0.00000000000000000000 \N \N \N 87 M 2335 16 73 admin 20 3 I 249 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 104 0.00 0.00000000000000000000 \N \N \N 90 M 2336 16 73 admin 21 3 I 249 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 104 0.00 0.00000000000000000000 \N \N \N 88 M 2337 16 73 admin 22 3 I 249 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 104 0.00 0.00000000000000000000 \N \N \N 89 M 2338 16 73 admin 23 3 I 249 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 104 0.00 0.00000000000000000000 \N \N \N 83 M 2339 16 73 admin 25 2 G 105 0.00 0.00 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 97 0.00 0.00000000000000000000 0.00 \N \N \N M 2340 16 73 admin 26 3 I 250 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 105 0.00 0.00000000000000000000 \N \N \N 124 M 2341 16 73 admin 27 3 I 250 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 105 0.00 0.00000000000000000000 \N \N \N 94 M 2342 16 73 admin 28 3 I 250 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 105 0.00 0.00000000000000000000 \N \N \N 102 M 2343 16 73 admin 29 3 I 250 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 105 0.00 0.00000000000000000000 \N \N \N 104 M 2344 16 73 admin 30 3 I 250 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 105 0.00 0.00000000000000000000 \N \N \N 107 M 2345 16 73 admin 31 3 I 250 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 105 0.00 0.00000000000000000000 \N \N \N 95 M 2346 16 73 admin 32 3 I 250 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 105 0.00 0.00000000000000000000 \N \N \N 105 M 2347 16 73 admin 34 2 G 106 0.00 0.00 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 97 0.00 0.00000000000000000000 0.00 \N \N \N M 2348 16 73 admin 35 3 I 251 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 106 0.00 0.00000000000000000000 \N \N \N 99 M 2349 16 73 admin 38 1 G 98 0.00 0.00 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 95 0.00 0.00000000000000000000 0.00 \N \N \N M 2350 16 73 admin 39 2 G 107 0.00 0.00 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 98 0.00 0.00000000000000000000 0.00 \N \N \N M 2351 16 73 admin 40 3 I 252 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 107 0.00 0.00000000000000000000 \N \N \N 111 M 2352 16 73 admin 42 2 G 108 0.00 0.00 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 98 0.00 0.00000000000000000000 0.00 \N \N \N M 2353 16 73 admin 45 1 G 99 0.00 0.00 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 95 0.00 0.00000000000000000000 0.00 \N \N \N M 2354 16 73 admin 46 2 G 109 0.00 0.00 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 99 0.00 0.00000000000000000000 0.00 \N \N \N M 2355 16 73 admin 47 3 I 253 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 109 0.00 0.00000000000000000000 \N \N \N 116 M 2356 16 73 admin 49 2 G 110 0.00 0.00 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 99 0.00 0.00000000000000000000 0.00 \N \N \N M 2357 16 73 admin 50 3 I 254 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 110 0.00 0.00000000000000000000 \N \N \N 113 M 2358 16 73 admin 51 3 I 254 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 110 0.00 0.00000000000000000000 \N \N \N 84 M 2359 16 73 admin 55 0 G 96 0.00 0.00 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 -1 0.00 0.00000000000000000000 0.00 \N \N \N M 2360 16 73 admin 56 1 I 255 \N \N 0.00 0.00 0 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 96 0.00 0.00000000000000000000 \N \N \N 109 M 2361 16 73 admin 5 3 T -1 \N \N 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 100 0.00 0.00000000000000000000 \N \N Total Cash Flow From Operating Activities \N M 2362 16 73 admin 8 3 T -1 \N \N 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 101 0.00 0.00000000000000000000 \N \N Total Charges Not Using Cash \N M 2363 16 73 admin 11 3 T -1 \N \N 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 102 0.00 0.00000000000000000000 \N \N Total Changes in Current Assets \N M 2364 16 73 admin 14 3 T -1 \N \N 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 103 0.00 0.00000000000000000000 \N \N Total Net Receivables \N M 2365 16 73 admin 24 3 T -1 \N \N 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 104 0.00 0.00000000000000000000 \N \N Total Inventory \N M 2366 16 73 admin 33 3 T -1 \N \N 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 105 0.00 0.00000000000000000000 \N \N Total Change in Current Liability \N M 2367 16 73 admin 36 3 T -1 \N \N 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 106 0.00 0.00000000000000000000 \N \N Total Accounts Payable \N M 2368 16 73 admin 37 2 T -1 \N \N 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 97 0.00 0.00000000000000000000 \N \N Total Cash Flow From Operating Activities \N M 2369 16 73 admin 41 3 T -1 \N \N 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 107 0.00 0.00000000000000000000 \N \N Total Property Plant and Equipment \N M 2370 16 73 admin 43 3 T -1 \N \N 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 108 0.00 0.00000000000000000000 \N \N Total Other Assets \N M 2371 16 73 admin 44 2 T -1 \N \N 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 98 0.00 0.00000000000000000000 \N \N Total Cash Flow From Investing Activities \N M 2372 16 73 admin 48 3 T -1 \N \N 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 109 0.00 0.00000000000000000000 \N \N Total Long Term Debt \N M 2373 16 73 admin 52 3 T -1 \N \N 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 110 0.00 0.00000000000000000000 \N \N Total Common Stock and Equity \N M 2374 16 73 admin 53 2 T -1 \N \N 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 99 0.00 0.00000000000000000000 \N \N Total Cash Flow from Financing Activities \N M 2375 16 73 admin 54 1 T -1 \N \N 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 95 0.00 0.00000000000000000000 \N \N TOTAL STATEMENT OF CASH FLOWS \N M 2376 16 73 admin 57 1 T -1 \N \N 0.00 0.00 0.00 \N \N 0.00000000000000000000 0.00000000000000000000 0.00000000000000000000 96 0.00 0.00000000000000000000 \N \N TOTAL CASH POSITION \N M 2377 16 73 admin 58 0 T -1 \N \N 0.00 0.00 0.00 \N \N \N \N \N \N 0.00 \N \N \N CHECKSUM (TOTAL STA. OF CASH FLOWS - TOTAL CASH) \N M 2378 \. -- -- Name: flrpt_flrpt_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('flrpt_flrpt_id_seq', 2378, true); -- -- Data for Name: flspec; Type: TABLE DATA; Schema: public; Owner: admin -- COPY flspec (flspec_id, flspec_flhead_id, flspec_flgrp_id, flspec_order, flspec_name, flspec_type, flspec_showstart, flspec_showend, flspec_showdelta, flspec_showbudget, flspec_subtract, flspec_showstartprcnt, flspec_showendprcnt, flspec_showdeltaprcnt, flspec_showbudgetprcnt, flspec_showdiff, flspec_showdiffprcnt, flspec_prcnt_flgrp_id, flspec_showcustom, flspec_showcustomprcnt, flspec_custom_source) FROM stdin; \. -- -- Name: flspec_flspec_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('flspec_flspec_id_seq', 1, false); -- -- Data for Name: form; Type: TABLE DATA; Schema: public; Owner: admin -- COPY form (form_id, form_name, form_descrip, form_report_id, form_key, form_report_name) FROM stdin; 21 CHECK CHECK 188 Chck CheckMultiPage 22 SO Acknowledgement SO Acknowledgement 371 SO CustOrderAcknowledgement \. -- -- Name: form_form_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('form_form_id_seq', 22, true); -- -- Data for Name: freightclass; Type: TABLE DATA; Schema: public; Owner: admin -- COPY freightclass (freightclass_id, freightclass_code, freightclass_descrip) FROM stdin; \. -- -- Name: freightclass_freightclass_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('freightclass_freightclass_id_seq', 1, false); -- -- Data for Name: glseries; Type: TABLE DATA; Schema: public; Owner: admin -- COPY glseries (glseries_id, glseries_sequence, glseries_doctype, glseries_docnumber, glseries_accnt_id, glseries_amount, glseries_source, glseries_distdate, glseries_notes, glseries_misc_id) FROM stdin; \. -- -- Name: glseries_glseries_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('glseries_glseries_id_seq', 1563, true); -- -- Data for Name: gltrans; Type: TABLE DATA; Schema: public; Owner: admin -- COPY gltrans (gltrans_id, gltrans_exported, gltrans_created, gltrans_date, gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_docnumber, gltrans_misc_id, gltrans_amount, gltrans_notes, gltrans_journalnumber, gltrans_posted, gltrans_doctype, gltrans_rec, gltrans_username, gltrans_deleted) FROM stdin; \. -- -- Name: gltrans_gltrans_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('gltrans_gltrans_id_seq', 7008, true); -- -- Name: gltrans_sequence_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('gltrans_sequence_seq', 3583, true); -- -- Data for Name: grp; Type: TABLE DATA; Schema: public; Owner: admin -- COPY grp (grp_id, grp_name, grp_descrip) FROM stdin; 1 ADMIN Admin Users \. -- -- Name: grp_grp_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('grp_grp_id_seq', 1, true); -- -- Data for Name: grppriv; Type: TABLE DATA; Schema: public; Owner: admin -- COPY grppriv (grppriv_id, grppriv_grp_id, grppriv_priv_id) FROM stdin; 1 1 179 2 1 251 3 1 252 4 1 254 5 1 260 6 1 261 7 1 262 8 1 263 9 1 266 10 1 267 11 1 268 12 1 271 13 1 272 14 1 275 15 1 276 16 1 277 17 1 278 18 1 279 19 1 280 20 1 294 21 1 297 22 1 298 23 1 302 24 1 303 25 1 305 26 1 369 27 1 370 28 1 313 29 1 314 30 1 315 31 1 371 32 1 372 33 1 334 34 1 335 35 1 373 36 1 374 37 1 375 38 1 376 39 1 377 40 1 378 41 1 356 42 1 357 43 1 358 44 1 379 45 1 380 46 1 382 47 1 395 48 1 396 49 1 397 50 1 398 51 1 407 52 1 455 53 1 456 54 1 457 55 1 458 56 1 461 57 1 462 58 1 463 59 1 464 60 1 467 61 1 468 62 1 469 63 1 475 64 1 476 65 1 487 66 1 488 67 1 489 68 1 187 69 1 188 70 1 259 71 1 492 72 1 505 73 1 62 74 1 191 75 1 202 76 1 512 77 1 513 78 1 514 79 1 515 80 1 516 81 1 465 82 1 466 83 1 483 84 1 484 85 1 415 86 1 416 87 1 418 88 1 446 89 1 420 90 1 422 91 1 423 92 1 424 93 1 425 94 1 426 95 1 427 96 1 428 97 1 429 98 1 430 99 1 431 100 1 447 101 1 433 102 1 435 103 1 436 104 1 437 105 1 438 106 1 439 107 1 440 108 1 441 109 1 442 110 1 443 111 1 444 112 1 419 113 1 432 114 1 448 115 1 449 116 1 450 117 1 451 118 1 480 119 1 481 120 1 482 121 1 391 122 1 392 123 1 511 124 1 10 125 1 30 126 1 29 127 1 37 128 1 42 129 1 84 130 1 82 131 1 83 132 1 85 133 1 86 134 1 90 135 1 116 136 1 117 137 1 118 138 1 14 139 1 15 140 1 128 141 1 129 142 1 131 143 1 130 144 1 132 145 1 133 146 1 147 147 1 81 148 1 148 149 1 19 150 1 150 151 1 151 152 1 152 153 1 154 154 1 153 155 1 35 156 1 36 157 1 164 158 1 214 159 1 215 160 1 217 161 1 218 162 1 219 163 1 220 164 1 223 165 1 224 166 1 225 167 1 216 168 1 222 169 1 221 170 1 226 171 1 227 172 1 241 173 1 238 174 1 255 175 1 256 176 1 264 177 1 265 178 1 350 179 1 351 180 1 454 181 1 470 182 1 495 183 1 501 184 1 506 185 1 507 186 1 17 187 1 16 188 1 91 189 1 27 190 1 11 191 1 93 192 1 12 193 1 13 194 1 26 195 1 75 196 1 76 197 1 94 198 1 125 199 1 140 200 1 173 201 1 176 202 1 177 203 1 178 204 1 182 205 1 228 206 1 352 207 1 408 208 1 409 209 1 306 210 1 307 211 1 269 212 1 270 213 1 362 214 1 363 215 1 390 216 1 5 217 1 4 218 1 103 219 1 104 220 1 105 221 1 106 222 1 107 223 1 1 224 1 2 225 1 134 226 1 143 227 1 144 228 1 157 229 1 158 230 1 159 231 1 160 232 1 31 233 1 161 234 1 162 235 1 163 236 1 316 237 1 317 238 1 349 239 1 508 240 1 509 241 1 45 242 1 44 243 1 48 244 1 49 245 1 53 246 1 54 247 1 46 248 1 47 249 1 120 250 1 137 251 1 189 252 1 204 253 1 205 254 1 207 255 1 208 256 1 209 257 1 213 258 1 231 259 1 244 260 1 245 261 1 246 262 1 249 263 1 250 264 1 353 265 1 354 266 1 368 267 1 383 268 1 452 269 1 22 270 1 23 271 1 51 272 1 55 273 1 56 274 1 57 275 1 58 276 1 61 277 1 59 278 1 60 279 1 50 280 1 88 281 1 89 282 1 111 283 1 126 284 1 127 285 1 141 286 1 142 287 1 180 288 1 181 289 1 190 290 1 192 291 1 193 292 1 194 293 1 195 294 1 196 295 1 197 296 1 198 297 1 199 298 1 200 299 1 201 300 1 232 301 1 203 302 1 233 303 1 70 304 1 234 305 1 235 306 1 211 307 1 212 308 1 239 309 1 242 310 1 257 311 1 258 312 1 273 313 1 274 314 1 281 315 1 336 316 1 337 317 1 346 318 1 347 319 1 348 320 1 355 321 1 385 322 1 386 323 1 389 324 1 393 325 1 459 326 1 460 327 1 510 328 1 485 329 1 486 330 1 100 331 1 63 332 1 64 333 1 65 334 1 73 335 1 121 336 1 122 337 1 101 338 1 87 339 1 123 340 1 124 341 1 68 342 1 166 343 1 167 344 1 168 345 1 169 346 1 170 347 1 236 348 1 248 349 1 253 350 1 3 351 1 345 352 1 359 353 1 388 354 1 394 355 1 399 356 1 403 357 1 404 358 1 406 359 1 445 360 1 453 361 1 471 362 1 490 363 1 491 364 1 493 365 1 496 366 1 497 367 1 498 368 1 499 369 1 500 370 1 494 371 1 502 372 1 504 373 1 517 374 1 518 \. -- -- Name: grppriv_grppriv_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('grppriv_grppriv_id_seq', 374, true); -- -- Data for Name: hnfc; Type: TABLE DATA; Schema: public; Owner: admin -- COPY hnfc (hnfc_id, hnfc_code) FROM stdin; 1 Dr 2 Miss 3 Mr 4 Mrs 5 Ms \. -- -- Name: hnfc_hnfc_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('hnfc_hnfc_id_seq', 5, true); -- -- Data for Name: image; Type: TABLE DATA; Schema: public; Owner: admin -- COPY image (image_id, image_name, image_descrip, image_data) FROM stdin; 14 Blue Pinstripe Background Blue Pinstripe Background begin 644 internal\nMB5!.1PT*&@H````-24A$4@````(````""`(```#]U)IS````"7!(67,```L2\nM```+$@'2W7[\\````%DE$050(F6-DLNUD8&!@\\?+R8F!@```-9P&L)F@250``\n*``!)14Y$KD)@@@``\n`\nend\n 15 logo logo begin 644 internal\nMB5!.1PT*&@H````-24A$4@```3T```!D"`,```##LQ1T[/(Z5GD]"QR>A81>M>)JM]C\nMY>UU[Q5'&ZIL2Y%*;YKNVZTXO8+>Q\\MF*TZOH#>-FZW\\E?1.4$8O`6OV=3ZG\nMQ^A%?)M'/J?'Z76$7F@2?M6&;T*%X4)J].3[N>=^HNDF+\\E,\\G*@%WR`$R@9\nM@@]X,LI:F:U;]-W`5*+E#U89L.!&C%BC=T4';1H'!W1V3X7WO-%D]$P-ZHJ1\nM-#]3W9=NI(4)./8Z(9^V5_R\nMHC&WD.$C]+JIJ"5X%FJ)]"3=E8`%-TK$:^]Y+5WVFJICEVY)&[A)@1Y<'T('QWBS0K.$6@J]\\%T#B,!6&7#I\nM1HU8IX?/S_(XMXN)%BS`C1->E:DUZ/E/T:B8+%M,+DMEMXE8RILEA,#I#1:PX$:-6*$WT,(!/_:+`5(T2J''AR4%PR>.@LFRQ1VY[(I/VW+?.]*L\nMK)9&K[\\PJWE7Q8`%-VK$PEOC.A'+;`2--@B]1J*'=P&"8?0$DV6+:>L6+Z0H\nMW1*AED8/'[R"'@]8<*-&++US*;Z]]):!^7GH%0%;Z<7:PO0D?K]&+\\720Q`/\nMZ&?!C>NA%I!+>.S6]Q1^LX-'Z'+\\3<*N[DPF7F13:ZU6'KGII604&LGO3)@\nMP8T:L4SOMO1FJ>NLSO<@F#A72O,],J-ZD4R6+5Z=[\\4)W+[YWB-Z&'#I1HWX\nMX0[5-5W9\\"6?O-9(ZPF<`&3+@5$T*=!;66LLQO>M-11Z0L""&RUB;9<`7AS\\\nMG?1RR<;0;)W+EY3E4C24E"8%>FP!JJ]SA5J[Z$D!EVZTB%=WJ*++5C`^-,R2\nML$O0XZP<\\96SR*SS;=MC^?B%5V[<8U%G+%+`@ALY8HU>[*PCAL&;/N`J+6MT\nMK#SPH;;)_68F17KJ_E[/%S";]O?TV;(4L.!&C/@+Y[FM&.NINDGDO\\'-$]'[\nM<_=3KR3+]F]U\\T3TXM@S/X&X[/]F-\\]$C[Z\\#WQP=[AY)GIT>K+CJ/Y`-T]%\nM#S>3=F2)'.G&1T[/(Z5FTA5ZV;82Y4D\\\nM_UW:3:^=G!YH)[T./CF]R]YQ+\\MR='J[:CL]+J=G$=!KIOQ0'9*Q4ORX;3@`\nMO2R!>A;9P:+'*MGA#=:"E*\\FN(&MW44U$\\%K"^CA"0@"6?(W='H-_H\\BI_IX\nM3%4<'&KTVGQ3LF8B>&T!O3E(^\\7\nM[,Y2_"JQK%&.>UOI54@$KRU*;V[S^Y1R[-\\!U'YZ@0T:D)*S\\?KK1GH5$L%K\nMB^T2Q(G[>,G2%;]`;YGOTTZ0S<&@"-.M']"KD`A>6XQ>9#;W]0XXLOC)\\[9.\nM;\\FT3(/.XU7"%GKV1/#:8O3PAP:Q37T>?UK=#H_HX4(NJDS.9HG4V^C9$\\%K\nMB^_OX?8*W7EB/UA)?>H!O0Z8D/_AYM"2\\'K:1L^<"%Y;G![&3UM"XX]=YC$]\nMEA0.U7C1\\K.9M^WTK(G@M778>6[QP^6#=5(B.-=1],H?S1^ADQ+!51U$[W;.\nMDW-6(KBF(^CQWQ$=JI,2P34=2.^4GG!2(KBB(^CELY5C=5(BN"C/H;+(Z5GD\nM]"QR>A8Y/8N3T+')Z%CD]BYR>14[/(J=GD=.SR.E9\nEY/0L\nSELECT poitem_id, poitem_linenumber,\n formatDate(poitem_duedate),\n COALESCE(item_number, ),\n COALESCE(uom_name, ),\n warehous_code,\n poitem_vend_item_number,\n poitem_vend_uom,\n formatQty(poitem_qty_ordered),\n formatQty(poitem_qty_received),\n formatQty(qtyToReceive(, poitem_id))\nFROM poitem \n LEFT OUTER JOIN \n ( itemsite \n\n JOIN usrsite ON (itemsite_warehous_id=usrsite_warehous_id) \n\n JOIN item ON (itemsite_item_id=item_id) \n JOIN uom ON (item_inv_uom_id=uom_id)\n JOIN whsinfo ON (itemsite_warehous_id=warehous_id)\n ) ON (poitem_itemsite_id=itemsite_id) \nWHERE ( (poitem_status <> 'C')\n\n AND (usrsite_username=current_user) \n\n AND (poitem_pohead_id=) )\nORDER BY poitem_linenumber;\n\nSELECT raitem_id, raitem_linenumber,\n formatDate(rahead_expiredate),\n COALESCE(item_number, ),\n COALESCE(iu.uom_name, ),\n warehous_code,\n '' AS vend_item_number,\n ru.uom_name,\n formatQty(raitem_qtyauthorized),\n formatQty(raitem_qtyreceived),\n formatQty(qtyToReceive(, raitem_id))\nFROM rahead, raitem \n LEFT OUTER JOIN \n ( itemsite \n\n JOIN usrsite ON (itemsite_warehous_id=usrsite_warehous_id) \n\n JOIN item ON (itemsite_item_id=item_id) \n JOIN uom iu ON (item_inv_uom_id=uom_id)\n JOIN whsinfo ON (itemsite_warehous_id=warehous_id)\n ) ON (raitem_itemsite_id=itemsite_id), uom ru\nWHERE ( (raitem_status <> 'C')\n AND (raitem_qtyauthorized > 0)\n AND (raitem_disposition IN ('R','P','V'))\n AND (raitem_rahead_id=rahead_id)\n AND (raitem_qty_uom_id=ru.uom_id)\n\n AND (usrsite_username=current_user) \n\n AND (rahead_id=) )\nORDER BY raitem_linenumber;\n\nSELECT toitem_id, toitem_linenumber,\n formatDate(toitem_duedate),\n COALESCE(item_number, ),\n COALESCE(uom_name, ),\n warehous_code,\n '',\n toitem_uom,\n formatQty(toitem_qty_ordered),\n formatQty(toitem_qty_received),\n formatQty(qtyToReceive(, toitem_id))\nFROM tohead, itemsite\n\n JOIN usrsite ON (itemsite_warehous_id=usrsite_warehous_id) \n\n, whsinfo, toitem, item JOIN uom ON (item_inv_uom_id=uom_id)\nWHERE ((toitem_item_id=item_id)\n AND (tohead_id=toitem_tohead_id)\n AND (tohead_dest_warehous_id=itemsite_warehous_id)\n AND (tohead_dest_warehous_id=warehous_id)\n AND (toitem_item_id=itemsite_item_id)\n AND (toitem_status <> 'C')\n\n AND (usrsite_username=current_user) \n\n AND (toitem_tohead_id=) )\nORDER BY toitem_linenumber;\n\n admin 2008-09-03 0 43 breederDistributionVariance detail used by dspBreederDistributionVarianceByItem, dspBreederDistributionVarianceByWarehouse -- Group: breederDistributionVariance\n-- Name: detail\n-- Notes: used by dspBreederDistributionVarianceByItem, dspBreederDistributionVarianceByWarehouse\n\nSELECT brdvar_id, brdvar_postdate,\n pi.item_number AS pitem_number,\n ci.item_number AS citem_number,\n brdvar_stdqtyper,\n brdvar_stdqtyper * brdvar_wo_qty AS stdqty,\n brdvar_actqtyper,\n brdvar_actqtyper * brdvar_wo_qty AS actqty,\n brdvar_actqtyper-brdvar_stdqtyper AS qtypervariance,\n (brdvar_actqtyper-brdvar_stdqtyper) / brdvar_stdqtyper AS percentvariance,\n 'qtyper' AS brdvar_stdqtyper_xtnumericrole,\n 'qty' AS stdqty_xtnumericrole,\n 'qtyper' AS brdvar_actqtyper_xtnumericrole,\n 'qty' AS actqty_xtnumericrole,\n 'qtyper' AS qtypervariance_xtnumericrole,\n 'percent' AS percentvariance_xtnumericrole \nFROM brdvar, itemsite AS ps, itemsite AS cs, item AS ci, item AS pi\nWHERE ( (brdvar_parent_itemsite_id=ps.itemsite_id)\n AND (brdvar_itemsite_id=cs.itemsite_id)\n\n AND (ps.itemsite_item_id=)\n AND (pi.item_id=ci.item_id)\n\n AND (ps.itemsite_item_id=pi.item_id)\n\n AND (cs.itemsite_item_id=ci.item_id)\n AND (brdvar_postdate BETWEEN \n AND )\n\n AND (ps.itemsite_warehous_id=)\n\n) \nORDER BY brdvar_postdate, pitem_number\n\n , citem_number \n\n;\n admin 2008-11-07 0 61 manufacture laborvariance shared by dspLaborVarianceBy* -- Group: manufacture\n-- Name: laborvariance\n-- Notes: shared by dspLaborVarianceBy*\n\nSELECT woopervar.*,\n item_number, wrkcnt_code,\n (woopervar_sutime - woopervar_stdsutime) AS suvar,\n (woopervar_rntime - woopervar_stdrntime) AS rnvar,\n 'qty' AS woopervar_qtyord_xtnumericrole,\n 'qty' AS woopervar_qtyrcv_xtnumericrole,\n '1' AS woopervar_stdsutime_xtnumericrole,\n '1' AS woopervar_stdrntime_xtnumericrole,\n '1' AS woopervar_sutime_xtnumericrole,\n '1' AS woopervar_rntime_xtnumericrole,\n '1' AS suvar_xtnumericrole,\n '1' AS rnvar_xtnumericrole\nFROM woopervar\n\n JOIN wo ON ((woopervar_number=wo_number)\n AND (woopervar_subnumber=wo_subnumber))\n\n JOIN itemsite ON (woopervar_parent_itemsite_id=itemsite_id)\n JOIN item ON (itemsite_item_id=item_id)\n LEFT OUTER JOIN wrkcnt ON (woopervar_wrkcnt_id=wrkcnt_id)\nWHERE (true\n\n AND (woopervar_posted BETWEEN \n AND )\n\n\n AND (itemsite_item_id=)\n\n\n AND (woopervar_booitem_id=)\n\n\n AND (wrkcnt_id=)\n\n\n AND (wo_id=)\n\n\n AND (itemsite_warehous_id=)\n\n)\nORDER BY woopervar_posted DESC, woopervar_seqnumber;\n admin 2008-11-07 0 248 gleries checkeditable -- Group: gleries\n-- Name: checkeditable\n-- Notes: \nSELECT gltrans_id \nFROM accnt, gltrans \n LEFT OUTER JOIN period ON (gltrans_date BETWEEN period_start AND period_end) \nWHERE ( (gltrans_accnt_id=accnt_id) \n AND (gltrans_sequence=) \n AND ( (gltrans_deleted) \n OR (period_freeze) \n OR (gltrans_rec) \n OR (period_closed AND NOT accnt_closedpost) ) )\nLIMIT 1; admin 2010-09-10 0 484 assessFinanceCharges detail Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: assessFinanceCharges\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT aropen_id, aropen_docnumber, aropen_duedate, aropen_docdate,\n aropen_amount, aropen_paid, balance, aropen_fincharg_date, aropen_fincharg_amount,\n cust_number, cust_name,\n CASE WHEN (currToLocal(aropen_curr_id, fincharg_mincharg, aropen_distdate) >\n (CASE WHEN (fincharg_assessoverdue)\n THEN (balance + prevfincharge)\n ELSE balance END * fincharg_air / 100.0 / 365 * CASE WHEN (fincharg_calcfrom=1)\n THEN duedateoverdue\n ELSE docdateoverdue END))\n THEN currToLocal(aropen_curr_id, fincharg_mincharg, aropen_distdate)\n ELSE (CASE WHEN (fincharg_assessoverdue)\n THEN (balance + prevfincharge)\n ELSE balance END * fincharg_air / 100.0 / 365 * CASE WHEN (fincharg_calcfrom=1)\n THEN duedateoverdue\n ELSE docdateoverdue END)\n END AS fincharge\nFROM fincharg,\n (SELECT *,\n (aropen_amount - aropen_paid) AS balance,\n COALESCE(aropen_fincharg_amount, 0.0) AS prevfincharge,\n ( - COALESCE(aropen_fincharg_date, aropen_duedate)) AS duedateoverdue,\n ( - COALESCE(aropen_fincharg_date, aropen_docdate)) AS docdateoverdue\n FROM aropen JOIN custinfo ON (cust_id=aropen_cust_id)\n LEFT OUTER JOIN terms ON (terms_id=aropen_terms_id)\n LEFT OUTER JOIN custtype ON (cust_custtype_id=custtype_id)\n LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n WHERE ((aropen_doctype='I')\n AND (aropen_open)\n AND (COALESCE(terms_fincharg, FALSE))\n AND (COALESCE(cust_financecharge, TRUE))\n \n AND (aropen_cust_id=)\n \n \n AND (custtype_id=)\n \n \n AND (custtype_code~)\n \n \n AND (custgrpitem_custgrp_id=)\n \n )) AS data\nWHERE ((COALESCE(aropen_fincharg_date, aropen_duedate) + COALESCE(cust_gracedays, fincharg_graceperiod)) < )\nORDER BY cust_number, aropen_docnumber;\n admin 2014-03-20 0 481 contrct itemsources Selection of Contract Related Item Sources -- Group: contrct\n-- Name: itemsources\n-- Notes: Selection of Contract Related Item Sources\nSELECT itemsrc_id,\n\t-1 AS pohead_id, \n\t' ' AS seq,\n\t' ' AS poitem_ordnumber, \n item_number,\n\titem_descrip1,\n\titemsrc_vend_uom,\n\titemsrc_vend_item_number,\n\tmin(contisrc_min) AS contisrc_min,\n\tsum(poitem_qty_unreleased) AS poitem_qty_unreleased,\n\tsum(poitem_qty_ordered) AS poitem_qty_ordered,\n\tsum(poitem_qty_received) AS poitem_qty_received,\n\tsum(poitem_qty_returned) AS poitem_qty_returned,\n\tnull AS poitem_duedate,\n\tnull AS poitem_status,\n\t0 AS xtindentrole \n\tFROM (SELECT contrct_id, \n\t\titemsrc_id,\n\t\tpohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n\t\titem_number,\n\t\titem_descrip1,\n\t\titemsrc_vend_uom,\n\t\titemsrc_vend_item_number,\n\t\tcontisrc_min,\n\t\tCASE WHEN poitem_status = 'U' THEN poitem_qty_ordered\n\t\t ELSE 0\n\t\tEND AS poitem_qty_unreleased,\n\t\tCASE WHEN poitem_status = 'O' THEN poitem_qty_ordered\n\t\t WHEN poitem_status = 'C' THEN poitem_qty_ordered\n ELSE 0\n\t\tEND AS poitem_qty_ordered,\n\t\tpoitem_qty_received,\n\t\tpoitem_qty_returned,\n\t\tpoitem_duedate, \n\t\tpoitem_status\n\t\tFROM contrct JOIN itemsrc ON (itemsrc_contrct_id = contrct_id)\n\t\t LEFT OUTER JOIN contisrc ON (contisrc_itemsrc_id = itemsrc_id)\n\t\t LEFT OUTER JOIN poitem ON (poitem_itemsrc_id = itemsrc_id)\n\t\t LEFT OUTER JOIN pohead ON (pohead_id = poitem_pohead_id)\n\t\t\t JOIN item ON (itemsrc_item_id = item_id)\n\t\tWHERE (contrct_id = )) AS dummy1\n\tWHERE (contrct_id = )\n\tGROUP BY itemsrc_id, itemsrc_vend_item_number, itemsrc_vend_uom, item_number, item_descrip1\n\nUNION -- PO Line Items\n\nSELECT itemsrc_id,\n\tpohead_id, \n\tpohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS seq,\n pohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n null AS item_number,\n\tnull AS item_descrip1,\n\tnull AS itemsrc_vend_uom,\n\tnull AS itemsrc_vend_item_number,\n\tnull AS contisrc_min,\n\tCASE WHEN poitem_status = 'U' THEN poitem_qty_ordered\n\t ELSE 0\n\tEND AS poitem_qty_unreleased,\n\tCASE WHEN poitem_status = 'O' THEN poitem_qty_ordered\n\t WHEN poitem_status = 'C' THEN poitem_qty_ordered\n ELSE 0\n\tEND AS poitem_qty_ordered,\n\tpoitem_qty_received,\n\tpoitem_qty_returned,\n\tpoitem_duedate, \n\tCASE WHEN poitem_status = 'O' THEN 'Open'\n\t WHEN poitem_status = 'C' THEN 'Closed'\n\t ELSE 'Unreleased'\n\tEND AS poitem_status,\n\t1 AS xtindentrole \n\tFROM contrct JOIN itemsrc ON (itemsrc_contrct_id = contrct_id)\n\t LEFT OUTER JOIN contisrc ON (contisrc_itemsrc_id = itemsrc_id)\n\t\t JOIN poitem ON (poitem_itemsrc_id = itemsrc_id)\n\t\t JOIN pohead ON (pohead_id = poitem_pohead_id)\n\t\t JOIN itemsite ON (poitem_itemsite_id = itemsite_id)\n\t\t JOIN item ON (itemsite_item_id = item_id)\n\tWHERE (contrct_id = )\n\nUNION -- Receipts\n\nSELECT itemsrc_id,\n\tpohead_id, \n\tpoitem_ordnumber || 'R' || to_char(recv_date, 'YYYYMMDDHH24:MI:SS') AS seq,\n\t'Receipt' AS poitem_ordnumber,\n\tnull AS item_number,\n\tnull AS item_descrip1,\n\trecv_vend_uom AS vend_uom,\n\tnull AS itemsrc_vend_item_number,\n\tnull AS contisrc_min,\n\tnull AS poitem_qty_unreleased,\n\tnull AS poitem_qty_ordered,\n\trecv_qty AS poitem_qty_received,\n\tnull AS poitem_qty_returned,\n\trecv_date AS poitem_duedate,\n\trecv_trans_usr_name AS username,\n\t2 AS xtindentrole\n FROM recv JOIN (SELECT pohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n\t\t\t poitem_pohead_id, poitem_linenumber, poitem_id, pohead_id, \n\t\t\t poitem_itemsrc_id\n\t\t\tFROM poitem JOIN pohead ON (pohead_id = poitem_pohead_id)) AS dummy ON (poitem_id = recv_orderitem_id)\n JOIN itemsite ON (itemsite_id = recv_itemsite_id)\n JOIN item ON (item_id = itemsite_item_id)\n JOIN itemsrc ON (poitem_itemsrc_id = itemsrc_id)\n WHERE (itemsrc_contrct_id = ) \n\nUNION -- Returns\n\nSELECT itemsrc_id, \n\tpohead_id, \n\tpoitem_ordnumber || 'R' || to_char(poreject_date, 'YYYYMMDDHH24:MI:SS') AS seq,\n\t'Return' AS poitem_ordnumber,\n\tnull AS item_number,\n\tnull AS item_descrip1,\n\tporeject_vend_uom AS vend_uom,\n\tnull AS itemsrc_vend_item_number,\n\tnull AS contisrc_min,\n\tnull AS poitem_qty_unreleased,\n\tnull AS poitem_qty_ordered,\n\tnull AS poitem_qty_received,\n\tporeject_qty AS poitem_qty_returned,\n\tporeject_date AS poitem_duedate,\n\tporeject_trans_username AS username,\n\t2 AS xtindentrole \n FROM poreject JOIN (SELECT pohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n\t\t\t poitem_pohead_id, poitem_linenumber, poitem_id, pohead_id, \n\t\t\t poitem_itemsrc_id\n\t\t\tFROM poitem JOIN pohead ON (pohead_id = poitem_pohead_id)) AS dummy ON (poitem_id = poreject_poitem_id)\n JOIN itemsite ON (itemsite_id = poreject_itemsite_id)\n JOIN item ON (item_id = itemsite_item_id)\n JOIN itemsrc ON (poitem_itemsrc_id = itemsrc_id)\n WHERE (itemsrc_contrct_id = ) \n\nORDER BY itemsrc_id, seq, poitem_ordnumber, poitem_duedate, xtindentrole;\n admin 2013-11-11 0 42 arOpenItems detail used by arWorkBench, dspAROpenItems\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: arOpenItems\n-- Name: detail\n-- Notes: used by arWorkBench, dspAROpenItems\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT SUM(CASE WHEN (aropen_doctype IN ('C', 'R')) THEN\n (aropen_amount - aropen_paid) / aropen_curr_rate * -1\n ELSE (aropen_amount - aropen_paid) / aropen_curr_rate\n END) AS total_balance\nFROM aropen JOIN custinfo ON (aropen_cust_id=cust_id)\n LEFT OUTER JOIN custtype ON (cust_custtype_id=custtype_id)\n LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ( (aropen_open)\n\n AND (aropen_cust_id=)\n\n\n AND (custtype_id=)\n\n\n AND (custtype_code~)\n\n\n AND (custgrpitem_custgrp_id=)\n\n )\n;\n\n\n-- Get unposted invoices\n\n\nSELECT -1 AS id,\n 0 AS altId,\n invchead_invcnumber AS docnumber,\n invchead_id AS docnumber_xtidrole,\n invchead_posted AS posted,\n invchead_invcdate AS docdate,\n NULL::date AS aropen_duedate,\n invchead_ordernumber AS ordernumber,\n cohead_id AS ordernumber_xtidrole,\n AS doctype,\n NULL AS doctype_qtforegroundrole,\n invoicetotal(invchead_id) AS amount,\n currtobase(invchead_curr_id, invoicetotal(invchead_id), invchead_invcdate) AS base_amount,\n 0 AS paid,\n 0 AS base_paid,\n 0 AS balance,\n currConcat(invchead_curr_id) AS currAbbr,\n 0 AS base_balance,\n\n formatDate(invchead_invcdate) AS f_docdate,\n NULL::text AS f_duedate,\n formatMoney(0) AS f_amount,\n formatMoney(0) AS f_paid,\n formatMoney(0) AS f_balance,\n\n cust_id, cust_number, cust_name,\n (invchead_recurring_invchead_id IS NOT NULL) AS recurring,\n false AS open,\n NULL AS ccard_number,\n 'curr' AS amount_xtnumericrole,\n 'curr' AS base_amount_xtnumericrole,\n 0 AS base_amount_xttotalrole,\n 'curr' AS paid_xtnumericrole,\n 'curr' AS base_paid_xtnumericrole,\n 0 AS base_paid_xttotalrole,\n 'curr' AS balance_xtnumericrole,\n 'curr' AS base_balance_xtnumericrole,\n 0 AS base_balance_xttotalrole,\n NULL::text AS aropen_docnumber_qtdisplayrole,\n NULL::text AS aropen_docdate_qtdisplayrole,\n 0 AS xtindentrole,\n '' AS aropen_duedate_qtforegroundrole,\n NULL::integer AS ccard_number_xtidrole,\n firstLine(invchead_notes) AS notes\nFROM invchead\n LEFT OUTER JOIN cohead ON (invchead_ordernumber=cohead_number)\n JOIN custinfo ON (invchead_cust_id=cust_id)\n JOIN custtype ON (cust_custtype_id=custtype_id)\n\t LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ((NOT invchead_posted)\n\n AND (invchead_cust_id=)\n\n\n AND (custtype_id=)\n\n\n AND (custtype_code~)\n\n\n AND (custgrpitem_custgrp_id=)\n\n\n AND (invchead_invcdate BETWEEN AND )\n\n )\n GROUP BY id, altId, invchead_id,\n invchead_invcdate, invchead_posted, invchead_curr_id,\n invchead_recurring, invchead_invcnumber, invchead_posted,\n invchead_ordernumber, cohead_id,\n cust_id, cust_number, cust_name,\n invchead_recurring_invchead_id, invchead_notes\n\nUNION\n\n\n\n-- Get unposted credit memos\n\n\nSELECT -1 AS id,\n 1 AS altId,\n cmhead_number AS docnumber,\n cmhead_id AS docnumber_xtidrole,\n cmhead_posted AS posted,\n cmhead_docdate AS docdate,\n NULL::date AS aropen_duedate,\n NULL::text AS ordernumber,\n -1 AS ordernumber_xtidrole,\n AS doctype,\n CASE WHEN (NOT cmhead_posted) THEN 'emphasis'\n END AS doctype_qtforegroundrole,\n creditmemototal(cmhead_id) AS amount,\n currtobase(cmhead_curr_id, creditmemototal(cmhead_id), cmhead_docdate) AS base_amount,\n 0 AS paid,\n 0 AS base_paid,\n 0 AS balance,\n currConcat(cmhead_curr_id) AS currAbbr,\n 0 AS base_balance,\n\n formatDate(cmhead_docdate) AS f_docdate,\n NULL::text AS f_duedate,\n formatMoney(creditmemototal(cmhead_id)) AS f_amount,\n formatMoney(0) AS f_paid,\n formatMoney(0) AS f_balance,\n\n cust_id, cust_number, cust_name,\n false AS recurring,\n false AS open,\n NULL AS ccard_number,\n 'curr' AS amount_xtnumericrole,\n 'curr' AS base_amount_xtnumericrole,\n 0 AS base_amount_xttotalrole,\n 'curr' AS paid_xtnumericrole,\n 'curr' AS base_paid_xtnumericrole,\n 0 AS base_paid_xttotalrole,\n 'curr' AS balance_xtnumericrole,\n 'curr' AS base_balance_xtnumericrole,\n 0 AS base_balance_xttotalrole,\n NULL::text AS aropen_docnumber_qtdisplayrole,\n NULL::text AS aropen_docdate_qtdisplayrole,\n 0 AS xtindentrole,\n '' AS aropen_duedate_qtforegroundrole,\n NULL::integer AS ccard_number_xtidrole,\n firstLine(cmhead_comments) AS notes\nFROM cmhead\n JOIN custinfo ON (cmhead_cust_id=cust_id)\n JOIN custtype ON (cust_custtype_id=custtype_id)\n\t LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ((NOT cmhead_posted)\n\n AND (cmhead_cust_id=)\n\n\n AND (custtype_id=)\n\n\n AND (custtype_code~)\n\n\n AND (custgrpitem_custgrp_id=)\n\n\n AND (cmhead_docdate BETWEEN AND )\n\n )\n GROUP BY id, altId, cmhead_id,\n cmhead_docdate, cmhead_posted, cmhead_curr_id,\n cmhead_number, cmhead_posted, cmhead_comments,\n cust_id, cust_number, cust_name\n\nUNION\n\n\n\n-- Get Posted AR Open\nSELECT aropen_id AS id,\n CASE WHEN (aropen_doctype='I') THEN 0\n WHEN (aropen_doctype='C') THEN 1\n WHEN (aropen_doctype='D') THEN 2\n WHEN (aropen_doctype='R') THEN 3\n ELSE -1\n END AS altId,\n aropen_docnumber AS docnumber,\n COALESCE(invchead_id,cmhead_id,-1) AS docnumber_xtidrole,\n true AS posted,\n aropen_docdate AS docdate,\n aropen_duedate,\n aropen_ordernumber AS ordernumber,\n COALESCE(cohead_id,-1) AS ordernumber_xtidrole,\n CASE WHEN (aropen_doctype='I') THEN \n WHEN (aropen_doctype='C') THEN \n WHEN (aropen_doctype='D') THEN \n WHEN (aropen_doctype='R') THEN \n ELSE \n END AS doctype,\n CASE WHEN (aropen_doctype='C') THEN 'emphasis' \n ELSE CASE WHEN(aropen_doctype='R')THEN 'altemphasis'\n END\n END AS doctype_qtforegroundrole,\n aropen_amount AS amount,\n aropen_amount/aropen_curr_rate AS base_amount,\n (aropen_paid - (COALESCE(SUM(arapply_target_paid),0))) AS paid,\n (aropen_paid - (COALESCE(SUM(arapply_target_paid),0))/aropen_curr_rate) AS base_paid,\n (((aropen_amount-aropen_paid+COALESCE(SUM(arapply_target_paid),0))) *\n CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1 ELSE 1 END) AS balance,\n currConcat(aropen_curr_id) AS currAbbr,\n (((aropen_amount-aropen_paid+COALESCE(SUM(arapply_target_paid),0)))/aropen_curr_rate *\n CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1 ELSE 1 END) AS base_balance,\n\n formatDate(aropen_docdate) AS f_docdate,\n formatDate(aropen_duedate) AS f_duedate,\n formatMoney(aropen_amount) AS f_amount,\n formatMoney(aropen_paid - (COALESCE(SUM(arapply_target_paid),0))) AS f_paid,\n formatMoney((((aropen_amount-aropen_paid+COALESCE(SUM(arapply_target_paid),0))) *\n CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1 ELSE 1 END)) AS f_balance,\n\n cust_id, cust_number, cust_name,\n COALESCE(invchead_recurring_invchead_id IS NOT NULL, false) AS recurring,\n aropen_open AS open,\n formatccnumber(decrypt(setbytea(ccard_number),\n setbytea(), 'bf')) AS ccard_number,\n 'curr' AS amount_xtnumericrole,\n 'curr' AS base_amount_xtnumericrole,\n 0 AS base_amount_xttotalrole,\n 'curr' AS paid_xtnumericrole,\n 'curr' AS base_paid_xtnumericrole,\n 0 AS base_paid_xttotalrole,\n 'curr'AS balance_xtnumericrole,\n 'curr' AS base_balance_xtnumericrole,\n 0 AS base_balance_xttotalrole,\n NULL AS aropen_docnumber_qtdisplayrole,\n NULL AS aropen_docdate_qtdisplayrole,\n 0 AS xtindentrole,\n CASE WHEN ((COALESCE(aropen_duedate,current_date) < current_date) AND COALESCE(aropen_open,FALSE)) THEN 'error' \n END AS aropen_duedate_qtforegroundrole,\n ccpay_id AS ccard_number_xtidrole,\n firstLine(aropen_notes) AS notes\nFROM aropen \n\n JOIN incdt ON (incdt_aropen_id=aropen_id)\n\n JOIN custinfo ON (aropen_cust_id=cust_id)\n JOIN custtype ON (cust_custtype_id=custtype_id)\n\t LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n LEFT OUTER JOIN invchead ON ((aropen_docnumber=invchead_invcnumber)\n AND (aropen_doctype='I'))\n LEFT OUTER JOIN cohead ON (invchead_ordernumber=cohead_number)\n LEFT OUTER JOIN cmhead ON ((aropen_docnumber=cmhead_number)\n AND (aropen_doctype='C'))\n LEFT OUTER JOIN arapply ON (((aropen_id=arapply_source_aropen_id)\n OR (aropen_id=arapply_target_aropen_id))\n AND (arapply_distdate>COALESCE(,current_date)))\n LEFT OUTER JOIN payaropen ON (payaropen_aropen_id=aropen_id)\n LEFT OUTER JOIN ccpay ON (payaropen_ccpay_id=ccpay_id)\n LEFT OUTER JOIN ccard ON (ccpay_ccard_id=ccard_id)\nWHERE ((true)\n\n AND (aropen_docdate <= COALESCE(, current_date))\n AND (COALESCE(aropen_closedate, DATE() + 1, current_date + 1) > COALESCE(, current_date)) \n\n\n AND (aropen_doctype IN ('D','I'))\n\n AND (aropen_doctype IN ('C', 'R'))\n\n\n AND (aropen_cust_id=)\n\n\n AND (custtype_id=)\n\n\n AND (custgrpitem_custgrp_id=)\n\n\n AND (custtype_code~)\n\n\n AND (aropen_docdate BETWEEN AND )\n\n\n AND (aropen_duedate >= )\n\n\n AND (aropen_duedate <= )\n\n )\n GROUP BY id, altId,\t invchead_id,\n aropen_docdate, aropen_duedate, aropen_doctype, \n aropen_docnumber, aropen_amount, \n aropen_notes, aropen_posted, aropen_ordernumber,\n aropen_paid, aropen_open, aropen_curr_id,\n aropen_closedate, aropen_curr_rate, cmhead_id,\n cust_id, \t\t cust_number, cust_name,\n cohead_id, ccpay_id, ccard_number,\n invchead_recurring_invchead_id\nUNION\nSELECT -1,\n 4 AS altId,\n aropen_docnumber AS docnumber,\n -1 AS docnumber_xtidrole,\n NULL AS posted, \n aropen_docdate AS docdate,\n NULL AS aropen_duedate,\n CAST(incdt_number AS text) AS ordernumber,\n incdt_id AS ordernumber_xtidrole,\n NULL AS doctype,\n NULL AS doctype_qtforegroundrole,\n NULL AS amount,\n NULL AS base_amount,\n NULL AS paid,\n NULL AS base_paid,\n NULL AS balance,\n NULL AS currAbbr,\n NULL AS base_balance,\n\n NULL AS f_docdate,\n NULL AS f_duedate,\n NULL AS f_amount,\n NULL AS f_paid,\n NULL AS f_balance,\n\n NULL,incdt_assigned_username, incdt_summary,\n NULL AS recurring, NULL AS open,\n NULL AS ccard_number,\n 'curr' AS amount_xtnumericrole,\n 'curr' AS base_amount_xtnumericrole,\n 0 AS base_amount_xttotalrole,\n 'curr' AS paid_xtnumericrole,\n 'curr' AS base_paid_xtnumericrole,\n 0 AS base_paid_xttotalrole,\n 'curr' AS balance_xtnumericrole,\n 'curr' AS base_balance_xtnumericrole,\n 0 AS base_balance_xttotalrole,\n '' AS aropen_docnumber_qtdisplayrole,\n '' AS aropen_docdate_qtdisplayrole,\n 1 AS xtindentrole,\n CASE WHEN ((COALESCE(aropen_duedate,current_date) < current_date) AND COALESCE(aropen_open,FALSE)) THEN 'error' \n END AS aropen_duedate_qtforegroundrole,\n NULL::integer AS ccard_xtidrole,\n firstLine(incdt_descrip) AS notes\nFROM incdt JOIN aropen ON (aropen_id=incdt_aropen_id)\n JOIN custinfo ON (aropen_cust_id=cust_id)\n JOIN custtype ON (cust_custtype_id=custtype_id)\n\t LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ((true)\n\n AND (aropen_docdate <= COALESCE(, current_date))\n AND (COALESCE(aropen_closedate, DATE() + 1, current_date + 1) > COALESCE(, current_date)) \n\n\n AND (NOT aropen_doctype IN ('C', 'R'))\n\n\n AND (aropen_doctype IN ('C', 'R'))\n\n\n AND (aropen_cust_id=)\n\n\n AND (custtype_id=)\n\n\n AND (custtype_code~)\n\n\n AND (custgrpitem_custgrp_id=)\n\n\n AND (aropen_docdate BETWEEN AND )\n\n\n AND (aropen_duedate >= )\n\n\n AND (aropen_duedate <= )\n\n )\n\nORDER BY\n docdate DESC, docnumber DESC, xtindentrole\n;\n\n admin 2015-10-01 0 45 cashReceipts detail used by dspCashReceipts\n There are 2 display modes for this query:\n 1) Legacy mode which uses A/R Application information\n 2) Version 3.3.0 upgrade mode which uses Cash Receipt information\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: cashReceipts\n-- Name: detail\n-- Notes: used by dspCashReceipts\n-- There are 2 display modes for this query:\n-- 1) Legacy mode which uses A/R Application information\n-- 2) Version 3.3.0 upgrade mode which uses Cash Receipt information\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\n\n-- Posted cash receipts\nSELECT arapply_id, 1 AS type, '' AS cashrcpt_number, cust_number, cust_name,\n false AS voided, true AS posted, arapply_postdate AS postdate,\n ( CASE WHEN (arapply_source_doctype='C') THEN \n WHEN (arapply_source_doctype='R') THEN \n WHEN (arapply_fundstype='C') THEN \n WHEN (arapply_fundstype='T') THEN \n WHEN (arapply_fundstype='M') THEN \n WHEN (arapply_fundstype='V') THEN \n WHEN (arapply_fundstype='A') THEN \n WHEN (arapply_fundstype='D') THEN \n WHEN (arapply_fundstype='R') THEN \n WHEN (arapply_fundstype='K') THEN \n WHEN (arapply_fundstype='W') THEN \n WHEN (arapply_fundstype='O') THEN \n END || ' ' ||\n CASE WHEN (arapply_source_doctype IN ('C','R')) THEN TEXT(arapply_source_docnumber)\n ELSE arapply_refnumber\n END ) AS source,\n COALESCE(cashrcptitem_cashrcpt_id,cashrcptmisc_cashrcpt_id,-1) AS source_xtidrole,\n ( CASE WHEN (arapply_target_doctype='D') THEN \n WHEN (arapply_target_doctype='I') THEN \n ELSE \n END || ' ' || TEXT(arapply_target_docnumber) ) AS target,\n COALESCE(arapply_target_aropen_id,-1) AS target_xtidrole,\n arapply_applied AS applied,\n 'curr' AS applied_xtnumericrole,\n currtobase(arapply_curr_id,arapply_applied,arapply_postdate) AS base_applied,\n\n formatDate(arapply_postdate) AS f_postdate,\n formatMoney(arapply_applied) AS f_applied,\n formatMoney(currtobase(arapply_curr_id,arapply_applied,arapply_postdate)) AS f_base_applied,\n\n 'curr' AS base_applied_xtnumericrole,\n 0 AS base_applied_xttotalrole,\n currConcat(arapply_curr_id) AS currAbbr,\n arapply_postdate AS sortdate\nFROM custinfo LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id), arapply\n LEFT OUTER JOIN cashrcptitem ON ((arapply_reftype='CRA')\n AND (arapply_ref_id=cashrcptitem_id))\n LEFT OUTER JOIN cashrcptmisc ON ((arapply_reftype='CRD')\n AND (arapply_ref_id=cashrcptmisc_id))\nWHERE ( (arapply_cust_id=cust_id)\n AND (arapply_postdate BETWEEN AND )\n AND (arapply_source_doctype ='K')\n\n AND (cust_id=)\n\n AND (cust_custtype_id=)\n\n AND (custgrpitem_custgrp_id=)\n\n AND (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ )))\n\n )\n\n-- Unposted cash receipts\nUNION\nSELECT cashrcpt_id, 2 AS type, '' AS cashrcpt_number, cust_number, cust_name,\n false AS voided, false AS posted, cashrcpt_distdate AS postdate,\n ( CASE WHEN (cashrcpt_fundstype='C') THEN \n WHEN (cashrcpt_fundstype='T') THEN \n WHEN (cashrcpt_fundstype='M') THEN \n WHEN (cashrcpt_fundstype='V') THEN \n WHEN (cashrcpt_fundstype='A') THEN \n WHEN (cashrcpt_fundstype='D') THEN \n WHEN (cashrcpt_fundstype='R') THEN \n WHEN (cashrcpt_fundstype='K') THEN \n WHEN (cashrcpt_fundstype='W') THEN \n WHEN (cashrcpt_fundstype='O') THEN \n END || ' ' || cashrcpt_docnumber ) AS source,\n cashrcpt_id AS source_xtidrole,\n AS target,\n -1 AS target_xtidrole,\n cashrcpt_amount AS applied,\n 'curr' AS applied_xtnumericrole,\n (cashrcpt_amount / cashrcpt_curr_rate) AS base_applied,\n\n formatDate(cashrcpt_distdate) AS f_postdate,\n formatMoney(cashrcpt_amount) AS f_applied,\n formatMoney(cashrcpt_amount / cashrcpt_curr_rate) AS f_base_applied,\n\n 'curr' AS base_applied_xtnumericrole,\n 0 AS base_applied_xttotalrole,\n currConcat(cashrcpt_curr_id) AS currAbbr,\n cashrcpt_distdate AS sortdate\nFROM cashrcpt, custinfo LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ( (NOT cashrcpt_posted)\n AND (cashrcpt_cust_id=cust_id)\n AND (cashrcpt_distdate BETWEEN AND )\n\n AND (cust_id=)\n\n AND (cust_custtype_id=)\n\n AND (custgrpitem_custgrp_id=)\n\n AND (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ )))\n\n )\n\n-- Cash Advance\nUNION\nSELECT aropen_id, 3 AS type, '' AS cashrcpt_number, cust_number, cust_name,\n false AS voided, true AS posted, aropen_docdate AS postdate,\n ( CASE WHEN (substr(aropen_notes, 16, 1)='C') THEN \n WHEN (substr(aropen_notes, 16, 1)='T') THEN \n WHEN (substr(aropen_notes, 16, 1)='M') THEN \n WHEN (substr(aropen_notes, 16, 1)='V') THEN \n WHEN (substr(aropen_notes, 16, 1)='A') THEN \n WHEN (substr(aropen_notes, 16, 1)='D') THEN \n WHEN (substr(aropen_notes, 16, 1)='R') THEN \n WHEN (substr(aropen_notes, 16, 1)='K') THEN \n WHEN (substr(aropen_notes, 16, 1)='W') THEN \n WHEN (substr(aropen_notes, 16, 1)='O') THEN \n END || ' ' ||\n substr(aropen_notes, 18) ) AS source,\n cashrcptitem_cashrcpt_id AS source_xtidrole,\n CASE WHEN aropen_doctype = 'R' THEN\n \n ELSE \n END AS target,\n aropen_id AS target_xtidrole,\n aropen_amount AS applied,\n 'curr' AS applied_xtnumericrole,\n aropen_amount / aropen_curr_rate AS base_applied,\n\n formatDate(aropen_docdate) AS f_postdate,\n formatMoney(aropen_amount) AS f_applied,\n formatMoney(aropen_amount / aropen_curr_rate) AS f_base_applied,\n\n 'curr' AS base_applied_xtnumericrole,\n 0 AS base_applied_xttotalrole,\n currConcat(aropen_curr_id) AS currAbbr,\n aropen_duedate AS sortdate\nFROM custinfo LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id), aropen\n JOIN cashrcptitem ON (aropen_id=cashrcptitem_aropen_id)\nWHERE ( (aropen_cust_id=cust_id)\n AND (aropen_doctype IN ('R','C'))\n AND (aropen_docdate BETWEEN AND )\n\n AND (cust_id=)\n\n AND (cust_custtype_id=)\n\n AND (custgrpitem_custgrp_id=)\n\n AND (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ )))\n\n )\nORDER BY sortdate, source;\n\n\n\n-- New Display Mode\n\nSELECT id, type, cashrcpt_number, cust_number, cust_name,\n postdate, posted, voided,\n source, source_xtidrole,\n posted,\n target, target_xtidrole,\n applied,\n base_applied,\n\n formatDate(postdate) AS f_postdate,\n formatMoney(applied) AS f_applied,\n formatMoney(base_applied) AS f_base_applied,\n\n currAbbr,\n sortdate,\n 'curr' AS applied_xtnumericrole,\n 'curr' AS base_applied_xtnumericrole,\n base_applied_xttotalrole,\n type AS xtindentrole\nFROM (\n\n-- Cash Receipt headers\nSELECT cashrcpt_id AS id, 0 AS type, cashrcpt_number, cust_number, cust_name,\n cashrcpt_distdate AS postdate, cashrcpt_posted AS posted, cashrcpt_void AS voided,\n ( CASE WHEN (cashrcpt_fundstype='C') THEN \n WHEN (cashrcpt_fundstype='T') THEN \n WHEN (cashrcpt_fundstype='M') THEN \n WHEN (cashrcpt_fundstype='V') THEN \n WHEN (cashrcpt_fundstype='A') THEN \n WHEN (cashrcpt_fundstype='D') THEN \n WHEN (cashrcpt_fundstype='R') THEN \n WHEN (cashrcpt_fundstype='K') THEN \n WHEN (cashrcpt_fundstype='W') THEN \n WHEN (cashrcpt_fundstype='O') THEN \n END || ' ' || cashrcpt_docnumber ) AS source,\n cashrcpt_id AS source_xtidrole,\n CASE WHEN (cashrcpt_void) THEN \n WHEN (NOT cashrcpt_posted) THEN \n ELSE ''\n END AS target,\n -1 AS target_xtidrole,\n cashrcpt_amount AS applied,\n (cashrcpt_amount / cashrcpt_curr_rate) AS base_applied,\n currConcat(cashrcpt_curr_id) AS currAbbr,\n cashrcpt_distdate AS sortdate,\n 0 AS base_applied_xttotalrole,\n -1 AS arapply_id\nFROM cashrcpt JOIN custinfo ON (cust_id=cashrcpt_cust_id) LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ( (cashrcpt_distdate BETWEEN AND )\n\n AND (cust_id=)\n\n AND (cust_custtype_id=)\n\n AND (custgrpitem_custgrp_id=)\n\n AND (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ )))\n\n\n AND (cashrcpt_fundstype=)\n\n )\n\n-- Cash Receipt items\nUNION\nSELECT cashrcpt_id AS id, 1 AS type, '', '', '',\n cashrcpt_distdate AS postdate, cashrcpt_posted AS posted, cashrcpt_void AS voided,\n '' AS source,\n cashrcpt_id AS source_xtidrole,\n ( CASE WHEN (aropen_doctype='D') THEN \n WHEN (aropen_doctype='I') THEN \n WHEN (aropen_doctype='C') THEN \n WHEN (aropen_doctype='R') THEN \n ELSE \n END || ' ' || TEXT(aropen_docnumber) ) AS target,\n aropen_id AS target_xtidrole,\n COALESCE(arapply_applied, cashrcptitem_amount) AS applied,\n (COALESCE(arapply_applied,cashrcptitem_amount) / cashrcpt_curr_rate) AS base_applied,\n currConcat(cashrcpt_curr_id) AS currAbbr,\n cashrcpt_distdate AS sortdate,\n -1 AS base_applied_xttotalrole,\n arapply_id\nFROM cashrcpt JOIN custinfo ON (cust_id=cashrcpt_cust_id)\n LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id)\n JOIN aropen ON (aropen_id=cashrcptitem_aropen_id)\n LEFT OUTER JOIN arapply ON ((arapply_target_aropen_id=aropen_id OR\n arapply_source_aropen_id=aropen_id) AND\n arapply_reftype='CRA' AND\n arapply_ref_id=cashrcptitem_id)\nWHERE ( (cashrcpt_distdate BETWEEN AND )\n\n AND (cust_id=)\n\n AND (cust_custtype_id=)\n\n AND (custgrpitem_custgrp_id=)\n\n AND (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ )))\n\n\n AND (cashrcpt_fundstype=)\n\n )\n\n-- Cash Receipt misc\nUNION\nSELECT cashrcpt_id AS id, 1 AS type, '', '', '',\n cashrcpt_distdate AS postdate, cashrcpt_posted AS posted, cashrcpt_void AS voided,\n '' AS source,\n cashrcpt_id AS source_xtidrole,\n formatGLAccount(cashrcptmisc_accnt_id) AS target,\n -1 AS target_xtidrole,\n COALESCE(arapply_applied, cashrcptmisc_amount) AS applied,\n (COALESCE(arapply_applied, cashrcptmisc_amount) / cashrcpt_curr_rate) AS base_applied,\n currConcat(cashrcpt_curr_id) AS currAbbr,\n cashrcpt_distdate AS sortdate,\n -1 AS base_applied_xttotalrole,\n arapply_id\nFROM cashrcpt JOIN custinfo ON (cust_id=cashrcpt_cust_id)\n LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n JOIN cashrcptmisc ON (cashrcptmisc_cashrcpt_id=cashrcpt_id)\n LEFT OUTER JOIN arapply ON (arapply_reftype='CRD' AND\n arapply_ref_id=cashrcptmisc_id)\nWHERE ( (cashrcpt_distdate BETWEEN AND )\n\n AND (cust_id=)\n\n AND (cust_custtype_id=)\n\n AND (custgrpitem_custgrp_id=)\n\n AND (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ )))\n\n\n AND (cashrcpt_fundstype=)\n\n )\n ) AS data\nORDER BY sortdate, id, type, target;\n\n\n\n admin 2015-10-01 0 482 contract itemsources Selection of Contract Related Item Sources -- Group: contract\n-- Name: itemsources\n-- Notes: Selection of Contract Related Item Sources\nSELECT itemsrc_id,\n\t-1 AS pohead_id, \n\t' ' AS seq,\n\t' ' AS poitem_ordnumber, \n item_number,\n\titem_descrip1,\n\titemsrc_vend_uom,\n\titemsrc_vend_item_number,\n\titemsrc_contrct_min,\n\tsum(poitem_qty_unreleased) AS poitem_qty_unreleased,\n\tsum(poitem_qty_ordered) AS poitem_qty_ordered,\n\tsum(poitem_qty_received) AS poitem_qty_received,\n\tsum(poitem_qty_returned) AS poitem_qty_returned,\n\tnull AS poitem_duedate,\n\tnull AS poitem_status,\n\t0 AS xtindentrole \n\tFROM (SELECT contrct_id, \n\t\titemsrc_id,\n\t\tpohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n\t\titem_number,\n\t\titem_descrip1,\n\t\titemsrc_vend_uom,\n\t\titemsrc_vend_item_number,\n\t\titemsrc_contrct_min,\n\t\tCASE WHEN poitem_status = 'U' THEN poitem_qty_ordered\n\t\t ELSE 0\n\t\tEND AS poitem_qty_unreleased,\n\t\tCASE WHEN poitem_status = 'O' THEN poitem_qty_ordered\n\t\t WHEN poitem_status = 'C' THEN poitem_qty_ordered\n ELSE 0\n\t\tEND AS poitem_qty_ordered,\n\t\tpoitem_qty_received,\n\t\tpoitem_qty_returned,\n\t\tpoitem_duedate, \n\t\tpoitem_status\n\t\tFROM contrct JOIN itemsrc ON (itemsrc_contrct_id = contrct_id)\n\t\t LEFT OUTER JOIN poitem ON (poitem_itemsrc_id = itemsrc_id)\n\t\t LEFT OUTER JOIN pohead ON (pohead_id = poitem_pohead_id)\n\t\t\t JOIN item ON (itemsrc_item_id = item_id)\n\t\tWHERE (contrct_id = )) AS dummy1\n\tWHERE (contrct_id = )\n\tGROUP BY itemsrc_id, itemsrc_vend_item_number, itemsrc_vend_uom, itemsrc_contrct_min,\n item_number, item_descrip1\n\nUNION -- PO Line Items\n\nSELECT itemsrc_id,\n\tpohead_id, \n\tpohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS seq,\n pohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n null AS item_number,\n\tnull AS item_descrip1,\n\tnull AS itemsrc_vend_uom,\n\tnull AS itemsrc_vend_item_number,\n\tnull AS itemsrc_contrct_min,\n\tCASE WHEN poitem_status = 'U' THEN poitem_qty_ordered\n\t ELSE 0\n\tEND AS poitem_qty_unreleased,\n\tCASE WHEN poitem_status = 'O' THEN poitem_qty_ordered\n\t WHEN poitem_status = 'C' THEN poitem_qty_ordered\n ELSE 0\n\tEND AS poitem_qty_ordered,\n\tpoitem_qty_received,\n\tpoitem_qty_returned,\n\tpoitem_duedate, \n\tCASE WHEN poitem_status = 'O' THEN 'Open'\n\t WHEN poitem_status = 'C' THEN 'Closed'\n\t ELSE 'Unreleased'\n\tEND AS poitem_status,\n\t1 AS xtindentrole \n\tFROM contrct JOIN itemsrc ON (itemsrc_contrct_id = contrct_id)\n\t\t JOIN poitem ON (poitem_itemsrc_id = itemsrc_id)\n\t\t JOIN pohead ON (pohead_id = poitem_pohead_id)\n\t\t JOIN itemsite ON (poitem_itemsite_id = itemsite_id)\n\t\t JOIN item ON (itemsite_item_id = item_id)\n\tWHERE (contrct_id = )\n\nUNION -- Receipts\n\nSELECT itemsrc_id,\n\tpohead_id, \n\tpoitem_ordnumber || 'R' || to_char(recv_date, 'YYYYMMDDHH24:MI:SS') AS seq,\n\t'Receipt' AS poitem_ordnumber,\n\tnull AS item_number,\n\tnull AS item_descrip1,\n\trecv_vend_uom AS vend_uom,\n\tnull AS itemsrc_vend_item_number,\n\tnull AS itemsrc_contrct_min,\n\tnull AS poitem_qty_unreleased,\n\tnull AS poitem_qty_ordered,\n\trecv_qty AS poitem_qty_received,\n\tnull AS poitem_qty_returned,\n\trecv_date AS poitem_duedate,\n\trecv_trans_usr_name AS username,\n\t2 AS xtindentrole\n FROM recv JOIN (SELECT pohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n\t\t\t poitem_pohead_id, poitem_linenumber, poitem_id, pohead_id, \n\t\t\t poitem_itemsrc_id\n\t\t\tFROM poitem JOIN pohead ON (pohead_id = poitem_pohead_id)) AS dummy ON (poitem_id = recv_orderitem_id)\n JOIN itemsite ON (itemsite_id = recv_itemsite_id)\n JOIN item ON (item_id = itemsite_item_id)\n JOIN itemsrc ON (poitem_itemsrc_id = itemsrc_id)\n WHERE (itemsrc_contrct_id = ) \n\nUNION -- Returns\n\nSELECT itemsrc_id, \n\tpohead_id, \n\tpoitem_ordnumber || 'R' || to_char(poreject_date, 'YYYYMMDDHH24:MI:SS') AS seq,\n\t'Return' AS poitem_ordnumber,\n\tnull AS item_number,\n\tnull AS item_descrip1,\n\tporeject_vend_uom AS vend_uom,\n\tnull AS itemsrc_vend_item_number,\n\tnull AS itemsrc_contrct_min,\n\tnull AS poitem_qty_unreleased,\n\tnull AS poitem_qty_ordered,\n\tnull AS poitem_qty_received,\n\tporeject_qty AS poitem_qty_returned,\n\tporeject_date AS poitem_duedate,\n\tporeject_trans_username AS username,\n\t2 AS xtindentrole \n FROM poreject JOIN (SELECT pohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n\t\t\t poitem_pohead_id, poitem_linenumber, poitem_id, pohead_id, \n\t\t\t poitem_itemsrc_id\n\t\t\tFROM poitem JOIN pohead ON (pohead_id = poitem_pohead_id)) AS dummy ON (poitem_id = poreject_poitem_id)\n JOIN itemsite ON (itemsite_id = poreject_itemsite_id)\n JOIN item ON (item_id = itemsite_item_id)\n JOIN itemsrc ON (poitem_itemsrc_id = itemsrc_id)\n WHERE (itemsrc_contrct_id = ) \n\nORDER BY itemsrc_id, seq, poitem_ordnumber, poitem_duedate, xtindentrole;\n admin 2014-03-20 0 231 arOpenItems f_detail This version for printed reports that need a way to include formatted values\n since there is no good way to differentiate different printed parameters in \n display class. Used to be printed version got an extra parameter. Formatted\n values slow things down considerably on screen version otherwise. This\n should go away if/when we get OpenRPT to do its own formatting.\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: arOpenItems\n-- Name: f_detail\n-- Notes: This version for printed reports that need a way to include formatted values\n-- since there is no good way to differentiate different printed parameters in \n-- display class. Used to be printed version got an extra parameter. Formatted\n-- values slow things down considerably on screen version otherwise. This\n-- should go away if/when we get OpenRPT to do its own formatting.\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT SUM(CASE WHEN (aropen_doctype IN ('C', 'R')) THEN\n (aropen_amount - aropen_paid) / aropen_curr_rate * -1\n ELSE (aropen_amount - aropen_paid) / aropen_curr_rate\n END) AS total_balance\nFROM aropen JOIN custinfo ON (aropen_cust_id=cust_id)\n LEFT OUTER JOIN custtype ON (cust_custtype_id=custtype_id)\n LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ( (aropen_open)\n\n AND (aropen_cust_id=)\n\n\n AND (custtype_id=)\n\n\n AND (custtype_code~)\n\n\n AND (custgrpitem_custgrp_id=)\n\n )\n;\n\n\n-- Get unposted invoices\n\n\nSELECT -1 AS id,\n 0 AS altId,\n invchead_invcnumber AS docnumber,\n invchead_id AS docnumber_xtidrole,\n invchead_posted AS posted,\n invchead_invcdate AS docdate,\n NULL::date AS aropen_duedate,\n invchead_ordernumber AS ordernumber,\n cohead_id AS ordernumber_xtidrole,\n AS doctype,\n NULL AS doctype_qtforegroundrole,\n invoicetotal(invchead_id) AS amount,\n currtobase(invchead_curr_id, invoicetotal(invchead_id), invchead_invcdate) AS base_amount,\n 0 AS paid,\n 0 AS base_paid,\n 0 AS balance,\n currConcat(invchead_curr_id) AS currAbbr,\n 0 AS base_balance,\n formatDate(invchead_invcdate) AS f_docdate,\n NULL::text AS f_duedate,\n formatMoney(invoicetotal(invchead_id)) AS f_amount,\n formatMoney(0) AS f_paid,\n formatMoney(0) AS f_balance,\n cust_id, cust_number, cust_name,\n (invchead_recurring_invchead_id IS NOT NULL) AS recurring,\n false AS open,\n NULL AS ccard_number,\n 'curr' AS amount_xtnumericrole,\n 'curr' AS base_amount_xtnumericrole,\n 0 AS base_amount_xttotalrole,\n 'curr' AS paid_xtnumericrole,\n 'curr' AS base_paid_xtnumericrole,\n 0 AS base_paid_xttotalrole,\n 'curr' AS balance_xtnumericrole,\n 'curr' AS base_balance_xtnumericrole,\n 0 AS base_balance_xttotalrole,\n NULL::text AS aropen_docnumber_qtdisplayrole,\n NULL::text AS aropen_docdate_qtdisplayrole,\n 0 AS xtindentrole,\n '' AS aropen_duedate_qtforegroundrole,\n NULL::integer AS ccard_number_xtidrole,\n firstLine(invchead_notes) AS notes\nFROM invchead\n LEFT OUTER JOIN cohead ON (invchead_ordernumber=cohead_number)\n JOIN custinfo ON (invchead_cust_id=cust_id)\n JOIN custtype ON (cust_custtype_id=custtype_id)\n\t LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ((NOT invchead_posted)\n\n AND (invchead_cust_id=)\n\n\n AND (custtype_id=)\n\n\n AND (custtype_code~)\n\n\n AND (custgrpitem_custgrp_id=)\n\n\n AND (invchead_invcdate BETWEEN AND )\n\n )\n GROUP BY id, altId, invchead_id,\n invchead_invcdate, invchead_posted, invchead_curr_id,\n invchead_recurring, invchead_invcnumber, invchead_posted,\n invchead_ordernumber, cohead_id,\n cust_id, cust_number, cust_name,\n invchead_recurring_invchead_id, invchead_notes\n\nUNION\n\n\n\n-- Get unposted credit memos\n\n\nSELECT -1 AS id,\n 1 AS altId,\n cmhead_number AS docnumber,\n cmhead_id AS docnumber_xtidrole,\n cmhead_posted AS posted,\n cmhead_docdate AS docdate,\n NULL::date AS aropen_duedate,\n NULL::text AS ordernumber,\n -1 AS ordernumber_xtidrole,\n AS doctype,\n CASE WHEN (NOT cmhead_posted) THEN 'emphasis'\n END AS doctype_qtforegroundrole,\n creditmemototal(cmhead_id) AS amount,\n currtobase(cmhead_curr_id, creditmemototal(cmhead_id), cmhead_docdate) AS base_amount,\n 0 AS paid,\n 0 AS base_paid,\n 0 AS balance,\n currConcat(cmhead_curr_id) AS currAbbr,\n 0 AS base_balance,\n formatDate(cmhead_docdate) AS f_docdate,\n NULL::text AS f_duedate,\n formatMoney(creditmemototal(cmhead_id)) AS f_amount,\n formatMoney(0) AS f_paid,\n formatMoney(0) AS f_balance,\n cust_id, cust_number, cust_name,\n false AS recurring,\n false AS open,\n NULL AS ccard_number,\n 'curr' AS amount_xtnumericrole,\n 'curr' AS base_amount_xtnumericrole,\n 0 AS base_amount_xttotalrole,\n 'curr' AS paid_xtnumericrole,\n 'curr' AS base_paid_xtnumericrole,\n 0 AS base_paid_xttotalrole,\n 'curr' AS balance_xtnumericrole,\n 'curr' AS base_balance_xtnumericrole,\n 0 AS base_balance_xttotalrole,\n NULL::text AS aropen_docnumber_qtdisplayrole,\n NULL::text AS aropen_docdate_qtdisplayrole,\n 0 AS xtindentrole,\n '' AS aropen_duedate_qtforegroundrole,\n NULL::integer AS ccard_number_xtidrole,\n firstLine(cmhead_comments) AS notes\nFROM cmhead\n JOIN custinfo ON (cmhead_cust_id=cust_id)\n JOIN custtype ON (cust_custtype_id=custtype_id)\n\t LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ((NOT cmhead_posted)\n\n AND (cmhead_cust_id=)\n\n\n AND (custtype_id=)\n\n\n AND (custtype_code~)\n\n\n AND (custgrpitem_custgrp_id=)\n\n\n AND (cmhead_docdate BETWEEN AND )\n\n )\n GROUP BY id, altId, cmhead_id,\n cmhead_docdate, cmhead_posted, cmhead_curr_id,\n cmhead_number, cmhead_posted, cmhead_comments,\n cust_id, cust_number, cust_name\n\nUNION\n\n\n\n-- Get Posted AR Open\nSELECT aropen_id AS id,\n CASE WHEN (aropen_doctype='I') THEN 0\n WHEN (aropen_doctype='C') THEN 1\n WHEN (aropen_doctype='D') THEN 2\n WHEN (aropen_doctype='R') THEN 3\n ELSE -1\n END AS altId,\n aropen_docnumber AS docnumber,\n COALESCE(invchead_id,cmhead_id,-1) AS docnumber_xtidrole,\n true AS posted,\n aropen_docdate AS docdate,\n aropen_duedate,\n aropen_ordernumber AS ordernumber,\n COALESCE(cohead_id,-1) AS ordernumber_xtidrole,\n CASE WHEN (aropen_doctype='I') THEN \n WHEN (aropen_doctype='C') THEN \n WHEN (aropen_doctype='D') THEN \n WHEN (aropen_doctype='R') THEN \n ELSE \n END AS doctype,\n CASE WHEN (aropen_doctype='C') THEN 'emphasis' \n ELSE CASE WHEN(aropen_doctype='R')THEN 'altemphasis'\n END\n END AS doctype_qtforegroundrole,\n aropen_amount AS amount,\n aropen_amount/aropen_curr_rate AS base_amount,\n (aropen_paid - (COALESCE(SUM(arapply_target_paid),0))) AS paid,\n (aropen_paid - (COALESCE(SUM(arapply_target_paid),0))/aropen_curr_rate) AS base_paid,\n (((aropen_amount-aropen_paid+COALESCE(SUM(arapply_target_paid),0))) *\n CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1 ELSE 1 END) AS balance,\n currConcat(aropen_curr_id) AS currAbbr,\n (((aropen_amount-aropen_paid+COALESCE(SUM(arapply_target_paid),0)))/aropen_curr_rate *\n CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1 ELSE 1 END) AS base_balance,\n formatDate(aropen_docdate) AS f_docdate,\n formatDate(aropen_duedate) AS f_duedate,\n formatMoney(aropen_amount) AS f_amount,\n formatMoney(aropen_paid - (COALESCE(SUM(arapply_target_paid),0))) AS f_paid,\n formatMoney((((aropen_amount-aropen_paid+COALESCE(SUM(arapply_target_paid),0))) *\n CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1 ELSE 1 END)) AS f_balance,\n cust_id, cust_number, cust_name,\n COALESCE(invchead_recurring_invchead_id IS NOT NULL, false) AS recurring,\n aropen_open AS open,\n formatccnumber(decrypt(setbytea(ccard_number),\n setbytea(), 'bf')) AS ccard_number,\n 'curr' AS amount_xtnumericrole,\n 'curr' AS base_amount_xtnumericrole,\n 0 AS base_amount_xttotalrole,\n 'curr' AS paid_xtnumericrole,\n 'curr' AS base_paid_xtnumericrole,\n 0 AS base_paid_xttotalrole,\n 'curr'AS balance_xtnumericrole,\n 'curr' AS base_balance_xtnumericrole,\n 0 AS base_balance_xttotalrole,\n NULL AS aropen_docnumber_qtdisplayrole,\n NULL AS aropen_docdate_qtdisplayrole,\n 0 AS xtindentrole,\n CASE WHEN ((COALESCE(aropen_duedate,current_date) < current_date) AND COALESCE(aropen_open,FALSE)) THEN 'error' \n END AS aropen_duedate_qtforegroundrole,\n ccpay_id AS ccard_number_xtidrole,\n firstLine(aropen_notes) AS notes\nFROM aropen \n\n JOIN incdt ON (incdt_aropen_id=aropen_id)\n\n JOIN custinfo ON (aropen_cust_id=cust_id)\n JOIN custtype ON (cust_custtype_id=custtype_id)\n\t LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n LEFT OUTER JOIN invchead ON ((aropen_docnumber=invchead_invcnumber)\n AND (aropen_doctype='I'))\n LEFT OUTER JOIN cohead ON (invchead_ordernumber=cohead_number)\n LEFT OUTER JOIN cmhead ON ((aropen_docnumber=cmhead_number)\n AND (aropen_doctype='C'))\n LEFT OUTER JOIN arapply ON (((aropen_id=arapply_source_aropen_id)\n OR (aropen_id=arapply_target_aropen_id))\n AND (arapply_distdate>COALESCE(,current_date)))\n LEFT OUTER JOIN payaropen ON (payaropen_aropen_id=aropen_id)\n LEFT OUTER JOIN ccpay ON (payaropen_ccpay_id=ccpay_id)\n LEFT OUTER JOIN ccard ON (ccpay_ccard_id=ccard_id)\nWHERE ((true)\n\n AND (aropen_docdate <= COALESCE(, current_date))\n AND (COALESCE(aropen_closedate, DATE() + 1, current_date + 1) > COALESCE(, current_date)) \n\n\n AND (aropen_doctype IN ('D','I'))\n\n AND (aropen_doctype IN ('C', 'R'))\n\n\n AND (aropen_cust_id=)\n\n\n AND (custtype_id=)\n\n\n AND (custgrpitem_custgrp_id=)\n\n\n AND (custtype_code~)\n\n\n AND (aropen_docdate BETWEEN AND )\n\n\n AND (aropen_duedate >= )\n\n\n AND (aropen_duedate <= )\n\n )\n GROUP BY id, altId,\t invchead_id,\n aropen_docdate, aropen_duedate, aropen_doctype, \n aropen_docnumber, aropen_amount, \n aropen_notes, aropen_posted, aropen_ordernumber,\n aropen_paid, aropen_open, aropen_curr_id,\n aropen_closedate, aropen_curr_rate, cmhead_id,\n cust_id, \t\t cust_number, cust_name,\n cohead_id, ccpay_id, ccard_number,\n invchead_recurring_invchead_id\nUNION\nSELECT -1,\n 4 AS altId,\n aropen_docnumber AS docnumber,\n -1 AS docnumber_xtidrole,\n NULL AS posted, \n aropen_docdate AS docdate,\n NULL AS aropen_duedate,\n CAST(incdt_number AS text) AS ordernumber,\n incdt_id AS ordernumber_xtidrole,\n NULL AS doctype,\n NULL AS doctype_qtforegroundrole,\n NULL AS amount,\n NULL AS base_amount,\n NULL AS paid,\n NULL AS base_paid,\n NULL AS balance,\n NULL AS currAbbr,\n NULL AS base_balance,\n NULL AS f_docdate,\n NULL AS f_duedate,\n NULL AS f_amount,\n NULL AS f_paid,\n NULL AS f_balance,\n NULL,incdt_assigned_username, incdt_summary,\n NULL AS recurring, NULL AS open,\n NULL AS ccard_number,\n 'curr' AS amount_xtnumericrole,\n 'curr' AS base_amount_xtnumericrole,\n 0 AS base_amount_xttotalrole,\n 'curr' AS paid_xtnumericrole,\n 'curr' AS base_paid_xtnumericrole,\n 0 AS base_paid_xttotalrole,\n 'curr' AS balance_xtnumericrole,\n 'curr' AS base_balance_xtnumericrole,\n 0 AS base_balance_xttotalrole,\n '' AS aropen_docnumber_qtdisplayrole,\n '' AS aropen_docdate_qtdisplayrole,\n 1 AS xtindentrole,\n CASE WHEN ((COALESCE(aropen_duedate,current_date) < current_date) AND COALESCE(aropen_open,FALSE)) THEN 'error' \n END AS aropen_duedate_qtforegroundrole,\n NULL::integer AS ccard_xtidrole,\n firstLine(incdt_descrip) AS notes\nFROM incdt JOIN aropen ON (aropen_id=incdt_aropen_id)\n JOIN custinfo ON (aropen_cust_id=cust_id)\n JOIN custtype ON (cust_custtype_id=custtype_id)\n\t LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ((true)\n\n AND (aropen_docdate <= COALESCE(, current_date))\n AND (COALESCE(aropen_closedate, DATE() + 1, current_date + 1) > COALESCE(, current_date)) \n\n\n AND (NOT aropen_doctype IN ('C', 'R'))\n\n\n AND (aropen_doctype IN ('C', 'R'))\n\n\n AND (aropen_cust_id=)\n\n\n AND (custtype_id=)\n\n\n AND (custtype_code~)\n\n\n AND (custgrpitem_custgrp_id=)\n\n\n AND (aropen_docdate BETWEEN AND )\n\n\n AND (aropen_duedate >= )\n\n\n AND (aropen_duedate <= )\n\n )\n\nORDER BY\n docdate DESC, docnumber DESC, xtindentrole\n;\n\n admin 2015-10-01 0 479 salesAccounts detail Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: salesAccounts\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT salesaccnt_id,\n CASE WHEN (salesaccnt_warehous_id=-1) THEN \n ELSE (SELECT warehous_code FROM whsinfo WHERE (warehous_id=salesaccnt_warehous_id))\n END AS warehouscode,\n CASE WHEN ((salesaccnt_custtype_id=-1) AND (salesaccnt_custtype='.*')) THEN \n WHEN (salesaccnt_custtype_id=-1) THEN salesaccnt_custtype\n ELSE (SELECT custtype_code FROM custtype WHERE (custtype_id=salesaccnt_custtype_id))\n END AS custtypecode,\n CASE WHEN (salesaccnt_shipzone_id=-1) THEN \n ELSE (SELECT shipzone_name FROM shipzone WHERE (shipzone_id=salesaccnt_shipzone_id))\n END AS shipzonecode,\n CASE WHEN (salesaccnt_saletype_id=-1) THEN \n ELSE (SELECT saletype_code FROM saletype WHERE (saletype_id=salesaccnt_saletype_id))\n END AS saletypecode,\n CASE WHEN ((salesaccnt_custtype_id=-1) AND (salesaccnt_custtype='.*')) THEN \n WHEN (salesaccnt_custtype_id=-1) THEN salesaccnt_custtype\n ELSE (SELECT custtype_code FROM custtype WHERE (custtype_id=salesaccnt_custtype_id))\n END AS custtypecode,\n CASE WHEN ((salesaccnt_prodcat_id=-1) AND (salesaccnt_prodcat='.*')) THEN \n WHEN (salesaccnt_prodcat_id=-1) THEN salesaccnt_prodcat\n ELSE (SELECT prodcat_code FROM prodcat WHERE (prodcat_id=salesaccnt_prodcat_id))\n END AS prodcatcode,\n CASE WHEN (salesaccnt_sales_accnt_id IS NULL) THEN \n WHEN (salesaccnt_sales_accnt_id = -1) THEN \n ELSE formatGLAccount(salesaccnt_sales_accnt_id) END AS salesaccount,\n CASE WHEN (salesaccnt_credit_accnt_id IS NULL) THEN \n WHEN (salesaccnt_credit_accnt_id = -1) THEN \n ELSE formatGLAccount(salesaccnt_credit_accnt_id) END AS creditaccount,\n CASE WHEN (salesaccnt_cos_accnt_id IS NULL) THEN \n WHEN (salesaccnt_cos_accnt_id = -1) THEN \n ELSE formatGLAccount(salesaccnt_cos_accnt_id) END AS cosaccount,\n CASE WHEN (salesaccnt_returns_accnt_id IS NULL) THEN \n WHEN (salesaccnt_returns_accnt_id = -1) THEN \n ELSE formatGLAccount(salesaccnt_returns_accnt_id) END AS returnsaccount,\n CASE WHEN (salesaccnt_cor_accnt_id IS NULL) THEN \n WHEN (salesaccnt_cor_accnt_id = -1) THEN \n ELSE formatGLAccount(salesaccnt_cor_accnt_id) END AS coraccount,\n CASE WHEN (salesaccnt_cow_accnt_id IS NULL) THEN \n WHEN (salesaccnt_cow_accnt_id = -1) THEN \n ELSE formatGLAccount(salesaccnt_cow_accnt_id) END AS cowaccount\nFROM salesaccnt\nORDER BY warehouscode, custtypecode, prodcatcode\n;\n admin 2014-03-20 0 435 backlog detail \n Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: backlog\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n cohead_id, coitem_id, *, currconcat(cohead_curr_id) AS currAbbr,\n CASE WHEN xtindentrole = 0 THEN cohead_number\n END AS coitem_linenumber_qtdisplayrole,\n CASE WHEN xtindentrole = 0 THEN cust_name\n END AS item_number_qtdisplayrole,\n CASE WHEN (coitem_scheddate <= current_date AND qtybalance > 0) THEN 'error' \n WHEN (qtybalance > 0) THEN 'emphasis' \n END AS coitem_scheddate_qtforegroundrole,\n 'qty' AS coitem_qtyord_xtnumericrole,\n 'qty' AS coitem_qtyshipped_xtnumericrole,\n 'qty' AS coitem_qtyreturned_xtnumericrole,\n 'qty' AS qtyatshipping_xtnumericrole,\n 'qty' AS qtybalance_xtnumericrole,\n 'qty' AS qtyavailable_xtnumericrole,\n 'salesprice' AS coitem_price_xtnumericrole,\n 'salesprice' AS baseunitprice_xtnumericrole,\n 'curr' AS extprice_xtnumericrole,\n 'curr' AS baseextprice_xtnumericrole,\n 'curr' AS extpricebalance_xtnumericrole,\n 'curr' AS baseextpricebalance_xtnumericrole,\n 0 AS coitem_qtyord_xttotalrole,\n 0 AS coitem_qtyshipped_xttotalrole,\n 0 AS coitem_qtyreturned_xttotalrole,\n 0 AS qtybalance_xttotalrole,\n 0 AS baseextprice_xttotalrole,\n 0 AS baseextpricebalance_xttotalrole\nFROM (\n SELECT\n 0 AS xtindentrole,\n -- dummy coitem record\n -1 AS coitem_id, NULL::INTEGER AS coitem_cohead_id,\n -1 AS coitem_linenumber,NULL::INTEGER AS coitem_itemsite_id,\n NULL::TEXT AS coitem_status, NULL::DATE AS coitem_scheddate,\n getSoSchedDate(cohead_id) AS sort_scheddate,\n NULL::DATE AS coitem_promdate, NULL::NUMERIC AS coitem_qtyord,\n NULL::NUMERIC AS coitem_unitcost, NULL::NUMERIC AS coitem_price,\n NULL::NUMERIC AS coitem_custprice, NULL::NUMERIC AS coitem_qtyshipped,\n NULL::INTEGER AS coitem_order_id, NULL::TEXT AS coitem_memo,\n NULL::BOOLEAN AS coitem_imported, NULL::NUMERIC AS coitem_qtyreturned,\n NULL::TIMESTAMP AS coitem_closedate, NULL::BOOLEAN AS coitem_firm,\n NULL::TEXT AS coitem_custpn, NULL::TEXT AS coitem_order_type,\n NULL::TEXT AS coitem_close_username,\n NULL::TIMESTAMP AS coitem_lastupdated,\n NULL::INTEGER AS coitem_substitute_item_id,\n NULL::TIMESTAMP AS coitem_created, NULL::TEXT AS coitem_creator,\n NULL::NUMERIC AS coitem_prcost,\n NULL::INTEGER AS coitem_qty_uom_id,\n NULL::NUMERIC AS coitem_qty_invuomratio,\n NULL::INTEGER AS coitem_price_uom_id,\n NULL::NUMERIC AS coitem_price_invuomratio,\n NULL::BOOLEAN AS coitem_warranty,\n NULL::INTEGER AS coitem_cos_accnt_id,\n NULL::NUMERIC AS coitem_qtyreserved,\n NULL::INTEGER AS coitem_subnumber,\n cohead.*,\n cust_number, cust_name, saletype_descr,\n NULL::TEXT AS item_number, NULL::TEXT AS item_descrip1,\n NULL::TEXT AS itemdescription,\n NULL::TEXT AS uom_name,\n NULL::TEXT AS warehous_code,\n\n charass_alias.charass_value AS char,\n\n\n charass_alias.charass_value AS char,\n\n\n charass_alias.charass_value::date AS char,\n\n NULL::NUMERIC AS qtybalance,\n NULL::NUMERIC AS baseunitprice,\n NULL::NUMERIC AS extprice,\n NULL::NUMERIC AS baseextprice,\n NULL::NUMERIC AS extpricebalance,\n NULL::NUMERIC AS baseextpricebalance\n\n FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)\n JOIN custinfo ON (cust_id=cohead_cust_id)\n LEFT OUTER JOIN saletype ON (saletype_id=cohead_saletype_id)\n JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n JOIN site() ON (warehous_id=itemsite_warehous_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN uom ON (uom_id=coitem_qty_uom_id)\n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='SO') \n AND (charass_alias.charass_target_id=cohead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='SO') \n AND (charass_alias.charass_target_id=cohead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='SO') \n AND (charass_alias.charass_target_id=cohead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\n WHERE ( (coitem_status='O')\n \n AND (coitem_cohead_id=)\n \n \n AND (cohead_orderdate >= )\n \n \n AND (cohead_orderdate <= )\n \n \n AND (cohead_saletype_id = )\n \n \n AND (coitem_scheddate >= )\n \n \n AND (coitem_scheddate <= )\n \n \n AND (cohead_salesrep_id=)\n \n \n AND (cohead_shipto_id=)\n \n \n AND (cohead_cust_id=)\n \n \n AND (cust_custtype_id=)\n \n \n AND (cust_custtype_id IN (SELECT DISTINCT custtype_id\n FROM custtype\n WHERE (custtype_code ~ )))\n \n \n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrpitem))\n \n \n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrpitem\n WHERE (custgrpitem_custgrp_id=)))\n \n \n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrp, custgrpitem\n WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n AND (custgrp_name ~ ) )) )\n \n\n \n AND (itemsite_item_id=)\n \n \n AND (item_prodcat_id=)\n \n \n AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n FROM prodcat\n WHERE (prodcat_code ~ )))\n \n\n \n AND (itemsite_warehous_id=)\n \n \n )\n\n UNION\n\n SELECT \n 1 AS xtindentrole,\n coitem_id, coitem_cohead_id,\n coitem_linenumber,coitem_itemsite_id,\n coitem_status, coitem_scheddate,\n getSoSchedDate(cohead_id) AS sort_scheddate,\n coitem_promdate, coitem_qtyord,\n coitem_unitcost, coitem_price,\n coitem_custprice, coitem_qtyshipped,\n coitem_order_id, coitem_memo,\n coitem_imported, coitem_qtyreturned,\n coitem_closedate, coitem_firm,\n coitem_custpn, coitem_order_type,\n coitem_close_username,\n coitem_lastupdated,\n coitem_substitute_item_id,\n coitem_created, coitem_creator,\n coitem_prcost,\n coitem_qty_uom_id,\n coitem_qty_invuomratio,\n coitem_price_uom_id,\n coitem_price_invuomratio,\n coitem_warranty,\n coitem_cos_accnt_id,\n coitem_qtyreserved,\n coitem_subnumber,\n cohead.*,\n cust_number, cust_name, '' AS saletype_descr,\n item_number, item_descrip1, (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n uom_name,\n warehous_code,\n\n charass_alias.charass_value AS char,\n\n\n charass_alias.charass_value AS char,\n\n\n charass_alias.charass_value::date AS char,\n\n noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS qtybalance,\n currtobase(cohead_curr_id, coitem_price, cohead_orderdate) AS baseunitprice,\n round((coitem_qtyord * coitem_qty_invuomratio) *\n (coitem_price / coitem_price_invuomratio), 2) AS extprice,\n round((coitem_qtyord * coitem_qty_invuomratio) *\n (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS baseextprice,\n round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n (coitem_price / coitem_price_invuomratio), 2) AS extpricebalance,\n round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS baseextpricebalance\n\n FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)\n JOIN custinfo ON (cust_id=cohead_cust_id)\n LEFT OUTER JOIN saletype ON (saletype_id=cohead_saletype_id)\n JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n JOIN site() ON (warehous_id=itemsite_warehous_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN uom ON (uom_id=coitem_qty_uom_id)\n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='SO') \n AND (charass_alias.charass_target_id=cohead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='SO') \n AND (charass_alias.charass_target_id=cohead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='SO') \n AND (charass_alias.charass_target_id=cohead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\n WHERE ( (coitem_status='O')\n \n AND (coitem_cohead_id=)\n \n \n AND (cohead_orderdate >= )\n \n \n AND (cohead_orderdate <= )\n \n \n AND (cohead_saletype_id = )\n \n \n AND (coitem_scheddate >= )\n \n \n AND (coitem_scheddate <= )\n \n \n AND (cohead_salesrep_id=)\n \n \n AND (cohead_shipto_id=)\n \n \n AND (cohead_cust_id=)\n \n \n AND (cust_custtype_id=)\n \n \n AND (cust_custtype_id IN (SELECT DISTINCT custtype_id\n FROM custtype\n WHERE (custtype_code ~ )))\n \n \n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrpitem))\n \n \n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrpitem\n WHERE (custgrpitem_custgrp_id=)))\n \n \n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrp, custgrpitem\n WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n AND (custgrp_name ~ ) )) )\n \n\n \n AND (itemsite_item_id=)\n \n \n AND (item_prodcat_id=)\n \n \n AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n FROM prodcat\n WHERE (prodcat_code ~ )))\n \n\n \n AND (itemsite_warehous_id=)\n \n \n )\n\n) AS dummy\nORDER BY cohead_number, xtindentrole, coitem_linenumber;\n admin 2015-10-01 0 418 contactmerge contactused Checks to see if this contact is used anywhere\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: contactmerge\n-- Name: contactused\n-- Notes: Checks to see if this contact is used anywhere\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntctused() AS used;\n admin 2015-10-01 0 428 contactmerge select Processes contact selections\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: contactmerge\n-- Name: select\n-- Notes: Processes contact selections\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntctselect(\n , \n ) AS result;\n admin 2015-10-01 0 427 contactmerge selectcol Selects a specific column\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: contactmerge\n-- Name: selectcol\n-- Notes: Selects a specific column\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntctselectcol(, );\n admin 2015-10-01 0 415 glseries postjournal \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: glseries\n-- Name: postjournal\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT postJournals() AS result;\n admin 2015-10-01 0 59 maintainShipping detail used by maintainShipping\n order header info\n Copyright (c) 1999-2013 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: maintainShipping\n-- Name: detail\n-- Notes: used by maintainShipping\n-- order header info\n-- Copyright (c) 1999-2013 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n-- order header info\nSELECT shiphead_id AS parent_id, cohead_id AS child_id,\n shiphead_number, cohead_number AS linenumber,\n 'SO' AS ordertype,\n CASE WHEN (shiphead_sfstatus='N') THEN \n WHEN (shiphead_sfstatus='D') THEN \n WHEN (shiphead_sfstatus='P') THEN \n ELSE \n END AS sfstatus,\n cust_number AS dest, cust_name AS description,\n shiphead_shipvia, NULL AS uom_name,\n NULL AS shipqty, NULL AS shipvalue,\n\n NULL AS f_shipqty, NULL AS f_shipvalue,\n\n cohead_holdtype AS holdtype,\n shiphead_notes AS notes,\n shiphead_number AS shiphead_number_qtdisplayrole,\n 'SO' AS ordertype_qtdisplayrole,\n 'qty' AS shipqty_xtnumericrole,\n 'cost' AS shipvalue_xtnumericrole,\n 0 AS shipvalue_xttotalrole,\n 0 AS xtindentrole,\n shiphead_id AS seq1, shiphead_order_id AS seq2,\n 0 AS seq3, 0 AS seq4\nFROM shiphead, custinfo, cohead\n \n JOIN coitem ON (coitem_cohead_id=cohead_id)\n JOIN itemsite ON ((coitem_itemsite_id=itemsite_id)\n AND (itemsite_warehous_id=))\n \nWHERE ((NOT shiphead_shipped)\n AND (shiphead_order_type='SO')\n AND (shiphead_order_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n\n AND (cust_id=)\n\n\n AND (cohead_id=)\n\n) \n-- order line info\nUNION ALL\nSELECT cohead_id AS parent_id, coitem_id AS child_id,\n '' AS shiphead_number, CAST(coitem_linenumber AS TEXT) AS linenumber,\n 'SO Item' AS ordertype,\n NULL AS sfstatus,\n item_number AS dest, (item_descrip1 || ' ' || item_descrip2) AS description,\n NULL AS shiphead_shipvia, uom_name,\n qtyAtShipping('SO', coitem_id) AS shipqty,\n valueAtShipping('SO', coitem_id) AS shipvalue,\n\n formatQty(qtyAtShipping('SO', coitem_id)) AS f_shipqty,\n formatCost(valueAtShipping('SO', coitem_id)) AS f_shipvalue,\n\n cohead_holdtype AS holdtype,\n '' as notes,\n NULL AS shiphead_number_qtdisplayrole,\n NULL AS ordertype_qtdisplayrole,\n 'qty' AS shipqty_xtnumericrole,\n 'cost' AS shipvalue_xtnumericrole,\n 0 AS shipvalue_xttotalrole,\n 1 AS xtindentrole,\n shiphead_id AS seq1, shiphead_order_id AS seq2,\n coitem_id AS seq3, 0 AS seq4\nFROM shiphead, cohead, coitem, uom, itemsite, item\nWHERE ((NOT shiphead_shipped)\n AND (shiphead_order_type='SO')\n AND (shiphead_order_id=cohead_id)\n AND (cohead_id=coitem_cohead_id)\n AND (coitem_qty_uom_id=uom_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n \n AND (itemsite_warehous_id=)\n \n\n AND (cohead_cust_id=)\n\n\n AND (cohead_id=)\n\n) \n-- shipitem info\nUNION ALL\nSELECT shiphead_id AS parent_id, shipitem_id AS child_id,\n '' AS shiphead_number, '' AS linenumber,\n 'SO Ship' AS ordertype,\n NULL AS sfstatus,\n '' AS dest,\n formatDate(shipitem_transdate) || ' by ' || shipitem_trans_username AS description,\n '' AS shiphead_shipvia, '' AS uom_name,\n shipitem_qty AS shipqty,\n NULL AS shipvalue,\n\n formatQty(shipitem_qty) AS f_shipqty,\n NULL AS f_shipvalue,\n\n '' AS holdtype,\n '' AS notes,\n NULL AS shiphead_number_qtdisplayrole,\n NULL AS ordertype_qtdisplayrole,\n 'qty' AS shipqty_xtnumericrole,\n 'cost' AS shipvalue_xtnumericrole,\n 0 AS shipvalue_xttotalrole,\n 2 AS xtindentrole,\n shiphead_id AS seq1, shiphead_order_id AS seq2,\n shipitem_orderitem_id AS seq3, shipitem_id AS seq4\nFROM shiphead JOIN cohead ON (cohead_id=shiphead_order_id)\n JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)\n \n JOIN coitem ON ((shipitem_orderitem_id=coitem_id)\n AND (shiphead_order_type='SO'))\n JOIN itemsite ON ((coitem_itemsite_id=itemsite_id)\n AND (itemsite_warehous_id=))\n \nWHERE ((NOT shiphead_shipped)\n AND (shiphead_order_type='SO')\n\n AND (cohead_cust_id=)\n\n\n AND (cohead_id=)\n\n) \n\n-- distribution info\nUNION ALL\nSELECT shiphead_id AS parent_id, shipitem_id AS child_id,\n '' AS shiphead_number, '' AS linenumber,\n 'SO Dist' AS ordertype,\n NULL AS sfstatus,\n formatLocationName(invdetail_location_id) AS dest,\n formatLotSerialNumber(invdetail_ls_id) AS description,\n formatDate(invdetail_expiration) AS shiphead_shipvia, '' AS uom_name,\n invdetail_qty AS shipqty,\n NULL AS shipvalue,\n\n formatQty(invdetail_qty) AS f_shipqty,\n NULL AS f_shipvalue,\n\n '' AS holdtype,\n '' AS notes,\n NULL AS shiphead_number_qtdisplayrole,\n NULL AS ordertype_qtdisplayrole,\n 'qty' AS shipqty_xtnumericrole,\n 'cost' AS shipvalue_xtnumericrole,\n 0 AS shipvalue_xttotalrole,\n 3 AS xtindentrole,\n shiphead_id AS seq1, shiphead_order_id AS seq2,\n shipitem_orderitem_id AS seq3, shipitem_id AS seq4\nFROM shiphead JOIN cohead ON (cohead_id=shiphead_order_id)\n JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)\n LEFT OUTER JOIN invhist ON (invhist_id=shipitem_invhist_id)\n LEFT OUTER JOIN invdetail ON (invdetail_invhist_id=invhist_id)\n \n JOIN coitem ON ((shipitem_orderitem_id=coitem_id)\n AND (shiphead_order_type='SO'))\n JOIN itemsite ON ((coitem_itemsite_id=itemsite_id)\n AND (itemsite_warehous_id=))\n \nWHERE ((NOT shiphead_shipped)\n AND (shiphead_order_type='SO')\n\n AND (cohead_cust_id=)\n\n\n AND (cohead_id=)\n\n) \n\n\n\nUNION ALL\n-- order header info\nSELECT shiphead_id AS parent_id, tohead_id AS child_id,\n shiphead_number, tohead_number AS linenumber,\n 'TO' AS ordertype,\n CASE WHEN (shiphead_sfstatus='N') THEN \n WHEN (shiphead_sfstatus='D') THEN \n WHEN (shiphead_sfstatus='P') THEN \n ELSE \n END AS sfstatus,\n tohead_destname AS dest, tohead_destcntct_name AS description,\n shiphead_shipvia, NULL AS uom_name,\n NULL AS shipqty, NULL AS shipvalue,\n\n NULL AS f_shipqty, NULL AS f_shipvalue,\n\n 'TO' AS holdtype,\n shiphead_notes AS notes,\n shiphead_number AS shiphead_number_qtdisplayrole,\n 'TO' AS ordertype_qtdisplayrole,\n 'qty' AS shipqty_xtnumericrole,\n 'cost' AS shipvalue_xtnumericrole,\n 0 AS shipvalue_xttotalrole,\n 0 AS xtindentrole,\n shiphead_id AS seq1, shiphead_order_id AS seq2,\n 0 AS seq3, 0 AS seq4\nFROM shiphead, tohead\n \n JOIN toitem ON (toitem_tohead_id=tohead_id)\n JOIN itemsite ON ((toitem_item_id=itemsite_item_id)\n AND (itemsite_warehous_id=))\n \nWHERE ((NOT shiphead_shipped)\n AND (shiphead_order_type='TO')\n AND (shiphead_order_id=tohead_id)\n\n AND FALSE\n\n\n AND FALSE\n\n) \n-- order line info\nUNION ALL\nSELECT tohead_id AS parent_id, toitem_id AS child_id,\n '' AS shiphead_number, CAST(toitem_linenumber AS TEXT) AS linenumber,\n 'TO' AS ordertype,\n NULL AS sfstatus,\n item_number AS dest, (item_descrip1 || ' ' || item_descrip2) AS description,\n NULL AS shiphead_shipvia, toitem_uom AS uom_name,\n qtyAtShipping('TO', toitem_id) AS shipqty,\n valueAtShipping('TO', toitem_id) AS shipvalue,\n\n formatQty(qtyAtShipping('TO', toitem_id)) AS f_shipqty,\n formatCost(valueAtShipping('TO', toitem_id)) AS f_shipvalue,\n\n 'TO' AS holdtype,\n '' AS notes,\n NULL AS shiphead_number_qtdisplayrole,\n NULL AS ordertype_qtdisplayrole,\n 'qty' AS shipqty_xtnumericrole,\n 'cost' AS shipvalue_xtnumericrole,\n 0 AS shipvalue_xttotalrole,\n 1 AS xtindentrole,\n shiphead_id AS seq1, shiphead_order_id AS seq2,\n toitem_id AS seq3, 0 AS seq4\nFROM shiphead, tohead, item, toitem\n \n JOIN itemsite ON ((toitem_item_id=itemsite_item_id)\n AND (itemsite_warehous_id=))\n \nWHERE ((NOT shiphead_shipped)\n AND (shiphead_order_type='TO')\n AND (shiphead_order_id=tohead_id)\n AND (tohead_id=toitem_tohead_id)\n AND (toitem_item_id=item_id)\n\n AND FALSE\n\n\n AND FALSE\n\n) \n-- shipitem info\nUNION\nSELECT shiphead_id AS parent_id, shipitem_id AS child_id,\n '' AS shiphead_number, '' AS linenumber,\n 'TO' AS ordertype,\n NULL AS sfstatus,\n '' AS dest,\n formatDate(shipitem_transdate) || ' by ' || shipitem_trans_username AS description,\n '' AS shiphead_shipvia, '' AS uom_name,\n shipitem_qty AS shipqty,\n NULL AS shipvalue,\n\n formatQty(shipitem_qty) AS f_shipqty,\n NULL AS f_shipvalue,\n\n '' AS holdtype,\n '' AS notes,\n NULL AS shiphead_number_qtdisplayrole,\n NULL AS ordertype_qtdisplayrole,\n 'qty' AS shipqty_xtnumericrole,\n 'cost' AS shipvalue_xtnumericrole,\n 0 AS shipvalue_xttotalrole,\n 2 AS xtindentrole,\n shiphead_id AS seq1, shiphead_order_id AS seq2,\n shipitem_orderitem_id AS seq3, shipitem_id AS seq4\nFROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)\n \n JOIN toitem ON ((shipitem_orderitem_id=toitem_id)\n AND (shiphead_order_type='TO'))\n JOIN itemsite ON ((toitem_item_id=itemsite_item_id)\n AND (itemsite_warehous_id=))\n \nWHERE ((NOT shiphead_shipped)\n AND (shiphead_order_type='TO')\n\n AND FALSE\n\n\n AND FALSE\n\n) \n\n\nORDER BY seq1, seq2, seq3, seq4, xtindentrole;\n admin 2015-10-01 0 80 runningAvailability detail used by dspRunningAvailability, itemAvailabilityWorkbench\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: runningAvailability\n-- Name: detail\n-- Notes: used by dspRunningAvailability, itemAvailabilityWorkbench\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT orderid, altorderid, ordertype, ordernumber, sequence, item_number,\n duedate, amount, qtyordered, qtyreceived, balance,\n balance AS runningavail, balance AS runningnetable,\n\n CASE WHEN duedate = startOfTime() THEN ''\n ELSE formatDate(duedate) END AS f_duedate,\n formatMoney(amount) AS f_amount,\n formatQty(qtyordered) AS f_qtyordered,\n formatQty(qtyreceived) AS f_qtyreceived,\n formatQty(balance) AS f_balance,\n\n notes,\n 1 AS runningavail_xtrunningrole,\n 1 AS runningnetable_xtrunningrole,\n AS runningavail_xtrunninginit,\n AS runningnetable_xtrunninginit,\n CASE WHEN late THEN 'error' END AS duedate_qtforegroundrole,\n CASE WHEN duedate = startOfTime() THEN '' END AS duedate_qtdisplayrole,\n CASE WHEN ordertype ~ OR\n ordertype ~ OR\n ordertype ~ THEN\n 'emphasis' END AS qtforegroundrole,\n 'currency' AS amount_xtnumericrole,\n 'qty' AS qtyordered_xtnumericrole,\n 'qty' AS qtyreceived_xtnumericrole,\n 'qty' AS balance_xtnumericrole\nFROM (\n\nSELECT -1 AS orderid, -1 AS altorderid, 'QOH' AS ordertype,\n NULL AS ordernumber,\n 0 AS sequence,\n '' AS item_number,\n startOfTime() AS duedate,\n FALSE AS late,\n 0 AS amount,\n 0 AS qtyordered,\n 0 AS qtyreceived,\n AS balance,\n '' AS notes\nUNION\n\n\nSELECT tohead_id AS orderid, toitem_id AS altorderid, 'T/O' AS ordertype,\n TEXT(tohead_number) AS ordernumber,\n 1 AS sequence,\n tohead_srcname || '/' || tohead_destname AS item_number,\n toitem_duedate AS duedate,\n (toitem_duedate < CURRENT_DATE) AS late,\n (toitem_stdcost * toitem_qty_ordered) AS amount,\n toitem_qty_ordered AS qtyordered,\n toitem_qty_received AS qtyreceived,\n noNeg(toitem_qty_ordered - toitem_qty_received) AS balance,\n tohead_ordercomments AS notes\nFROM tohead, toitem\nWHERE ((toitem_tohead_id=tohead_id)\n AND (toitem_status NOT IN ('C', 'X'))\n AND (toitem_item_id=)\n AND (tohead_dest_warehous_id=)\n AND (toitem_qty_ordered > toitem_qty_received) )\n\nUNION\nSELECT tohead_id AS orderid, toitem_id AS altorderid, 'T/O' AS ordertype,\n TEXT(tohead_number) AS ordernumber,\n 1 AS sequence,\n tohead_srcname || '/' || tohead_destname AS item_number,\n toitem_duedate AS duedate,\n (toitem_duedate < CURRENT_DATE) AS late,\n (toitem_stdcost * toitem_qty_ordered) AS amount,\n toitem_qty_ordered AS qtyordered,\n toitem_qty_received AS qtyreceived,\n -1 * noNeg(toitem_qty_ordered - toitem_qty_shipped - qtyAtShipping('TO', toitem_id)) AS balance,\n tohead_ordercomments AS notes\n -- TODO: old code had ^^^^ for formatted balance and vvvv used to calc running avail! which is right?\n -- -1 * noNeg(toitem_qty_ordered - toitem_qty_received) AS balance\nFROM tohead, toitem\nWHERE ((toitem_tohead_id=tohead_id)\n AND (toitem_status NOT IN ('C', 'X'))\n AND (toitem_item_id=)\n AND (tohead_src_warehous_id=)\n AND (toitem_qty_ordered - toitem_qty_shipped - qtyAtShipping('TO', toitem_id)) > 0 )\n\nUNION\n\nSELECT wo_id AS orderid, -1 AS altorderid,\n 'W/O' AS ordertype,\n formatWoNumber(wo_id) AS ordernumber,\n 1 AS sequence,\n item_number,\n wo_duedate AS duedate,\n (wo_duedate < CURRENT_DATE) AS late,\n (itemCost(wo_itemsite_id) * wo_qtyord) AS amount,\n wo_qtyord AS qtyordered,\n wo_qtyrcv AS qtyreceived,\n noNeg(wo_qtyord - wo_qtyrcv) AS balance,\n wo_prodnotes AS notes\nFROM wo, itemsite, item\nWHERE ((wo_status<>'C')\n AND (wo_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=)\n AND (itemsite_item_id=)\n AND (item_type NOT IN ('C', 'Y')))\n\nUNION\n\n-- Tools on work orders to be returned\nSELECT wo_id AS orderid, -1 AS altorderid,\n 'W/O' AS ordertype,\n formatWoNumber(wo_id) AS ordernumber,\n 1 AS sequence,\n item_number,\n wo_duedate AS duedate,\n (wo_duedate < CURRENT_DATE) AS late,\n (womatl_cost * womatl_qtyreq) AS amount,\n womatl_qtyreq AS qtyordered,\n COALESCE(SUM(abs(invhist_invqty)),0) AS qtyreceived,\n noNeg(womatl_qtyreq - COALESCE(SUM(abs(invhist_invqty)),0)) AS balance,\n wo_prodnotes AS notes\nFROM womatl\n JOIN wo ON (wo_id=womatl_wo_id)\n JOIN itemsite ON (womatl_itemsite_id=itemsite_id)\n JOIN item ON (itemsite_item_id=item_id)\n LEFT OUTER JOIN womatlpost ON (womatl_id=womatlpost_womatl_id)\n LEFT OUTER JOIN invhist ON ((womatlpost_invhist_id=invhist_id)\n AND (invhist_invqty < 0))\nWHERE ((wo_status<>'C')\n AND (itemsite_warehous_id=)\n AND (itemsite_item_id=)\n AND (item_type = 'T'))\nGROUP BY wo_id, wo_duedate, item_number, womatl_qtyreq, womatl_cost, wo_prodnotes\n\n\nUNION\nSELECT wo_id AS orderid, -1 AS altorderid,\n 'W/O' AS ordertype,\n formatWoNumber(wo_id) AS ordernumber,\n 1 AS sequence,\n item_number,\n wo_duedate AS duedate,\n (wo_duedate < CURRENT_DATE) AS late,\n (itemCost(wo_itemsite_id) * wo_qtyord * brddist_stdqtyper) AS amount,\n (wo_qtyord * brddist_stdqtyper) AS qtyordered,\n (wo_qtyrcv * brddist_stdqtyper) AS qtyreceived,\n noNeg((wo_qtyord - wo_qtyrcv) * brddist_stdqtyper) AS balance,\n wo_prodnotes AS notes\nFROM xtmfg.brddist, wo, itemsite, item\nWHERE ((wo_status<>'C')\n AND (brddist_wo_id=wo_id)\n AND (wo_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (brddist_itemsite_id=itemsite_id)\n AND (itemsite_warehous_id=)\n AND (itemsite_item_id=)\n AND (item_type IN ('C', 'Y')) )\n\n\nUNION\nSELECT wo_id AS orderid, womatl_id AS altorderid,\n 'W/O' AS ordertype,\n formatWoNumber(wo_id) AS ordernumber,\n 2 AS sequence,\n woi.item_number,\n womatl_duedate AS duedate,\n FALSE AS late,\n (itemCost(womatl_itemsite_id) * itemuomtouom(womatlis.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq)) AS amount,\n itemuomtouom(womatlis.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq) AS qtyordered,\n itemuomtouom(womatlis.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyiss) AS qtyreceived,\n itemuomtouom(womatlis.itemsite_item_id, womatl_uom_id, NULL, (noNeg(womatl_qtyreq - womatl_qtyiss) * -1)) AS balance,\n wo_prodnotes AS notes\nFROM womatl, wo, itemsite AS wois, item AS woi, itemsite AS womatlis, item AS womatli\nWHERE ((wo_status<>'C')\n AND (wo_itemsite_id=wois.itemsite_id)\n AND (wois.itemsite_item_id=woi.item_id)\n AND (womatlis.itemsite_item_id=womatli.item_id)\n AND (womatli.item_type != 'T')\n AND (womatl_wo_id=wo_id)\n AND (womatlis.itemsite_item_id=)\n AND (womatlis.itemsite_warehous_id=)\n AND (womatl_itemsite_id=womatlis.itemsite_id) )\n\nUNION\n-- Special handling for tools\nSELECT wo_id AS orderid, womatl_id AS altorderid,\n 'W/O' AS ordertype,\n formatWoNumber(wo_id) AS ordernumber,\n 2 AS sequence,\n woi.item_number,\n womatl_duedate AS duedate,\n FALSE AS late,\n (womatl_cost * itemuomtouom(womatlis.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq)) AS amount,\n itemuomtouom(womatlis.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq) AS qtyordered,\n COALESCE(SUM(invhist_invqty),0) AS qtyreceived,\n (itemuomtouom(womatlis.itemsite_item_id, womatl_uom_id, NULL, (noNeg(womatl_qtyreq))) - COALESCE(SUM(invhist_invqty),0)) * -1 AS balance,\n wo_prodnotes AS notes\nFROM itemsite AS wois, item AS woi, itemsite AS womatlis, item AS womatli, wo, womatl\n LEFT OUTER JOIN womatlpost ON (womatl_id=womatlpost_womatl_id)\n LEFT OUTER JOIN invhist ON ((womatlpost_invhist_id=invhist_id)\n AND (invhist_invqty > 0))\nWHERE ((wo_status<>'C')\n AND (wo_itemsite_id=wois.itemsite_id)\n AND (wois.itemsite_item_id=woi.item_id)\n AND (womatlis.itemsite_item_id=womatli.item_id)\n AND (womatli.item_type = 'T')\n AND (womatl_wo_id=wo_id)\n AND (womatlis.itemsite_item_id=)\n AND (womatlis.itemsite_warehous_id=)\n AND (womatl_itemsite_id=womatlis.itemsite_id) )\nGROUP BY wo_id, woi.item_number, womatl_id, womatl_duedate, womatlis.itemsite_item_id, womatl_uom_id, womatl_qtyreq, womatl_cost, wo_prodnotes\n\nUNION\nSELECT pohead_id AS orderid, poitem_id AS altorderid,\n 'P/O' AS ordertype,\n TEXT(pohead_number) AS ordernumber,\n 1 AS sequence,\n vend_name AS item_number,\n poitem_duedate AS duedate,\n (poitem_duedate < CURRENT_DATE) AS late,\n (poitem_unitprice * poitem_qty_ordered) AS amount,\n (poitem_qty_ordered * poitem_invvenduomratio) AS qtyordered,\n (NoNeg(poitem_qty_received - poitem_qty_returned) * poitem_invvenduomratio) AS qtyreceived,\n (noNeg(poitem_qty_ordered - poitem_qty_received) * poitem_invvenduomratio) AS balance,\n pohead_comments AS notes\nFROM pohead, vendinfo, poitem, itemsite, item\nWHERE ((vend_id=pohead_vend_id)\n AND (poitem_pohead_id=pohead_id)\n AND (poitem_status <> 'C')\n AND (poitem_itemsite_id=itemsite_id)\n AND (itemsite_warehous_id=)\n AND (itemsite_item_id=item_id)\n AND (item_id=) )\n\nUNION\nSELECT cohead_id AS orderid, coitem_id AS altorderid,\n 'S/O' AS ordertype,\n TEXT(cohead_number) AS ordernumber,\n 2 AS sequence,\n cust_name AS item_number,\n coitem_scheddate AS duedate,\n (coitem_scheddate < CURRENT_DATE) AS late,\n (coitem_price * coitem_qtyord) AS amount,\n (coitem_qtyord * coitem_qty_invuomratio) AS qtyordered,\n (coitem_qty_invuomratio * (coitem_qtyshipped - coitem_qtyreturned + qtyAtShipping(coitem_id))) AS qtyreceived,\n (coitem_qty_invuomratio * noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping(coitem_id)) * -1) AS balance,\n cohead_ordercomments AS notes\nFROM coitem, cohead, custinfo, itemsite, item\nWHERE ((coitem_status='O')\n AND (cohead_cust_id=cust_id)\n AND (coitem_cohead_id=cohead_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_warehous_id=)\n AND (itemsite_item_id=item_id)\n AND (item_id=))\n\n\n\nUNION\nSELECT planord_id AS orderid, -1 AS altorderid,\n CASE WHEN (planord_firm) THEN \n \t ELSE \n END AS ordertype,\n CAST(planord_number AS text) AS ordernumber,\n 1 AS sequence,\n '' AS item_number,\n planord_duedate AS duedate,\n FALSE AS late,\n (itemCost(planord_itemsite_id) * planord_qty) AS amount,\n planord_qty AS qtyordered,\n NULL AS qtyreceived,\n planord_qty AS balance,\n planord_comments AS notes\nFROM planord, itemsite\nWHERE ((planord_type='P')\n AND (planord_itemsite_id=itemsite_id)\n AND (itemsite_warehous_id=)\n AND (itemsite_item_id=) )\n\nUNION\nSELECT planord_id AS orderid, -1 AS altorderid,\n CASE WHEN (planord_firm) THEN \n\t ELSE \n END AS ordertype,\n CAST(planord_number AS text) AS ordernumber,\n 1 AS sequence,\n '' AS item_number,\n planord_duedate AS duedate,\n FALSE AS late,\n (itemCost(planord_itemsite_id) * planord_qty) AS amount,\n planord_qty AS qtyordered,\n NULL AS qtyreceived,\n planord_qty AS balance,\n planord_comments AS notes\nFROM planord, itemsite\nWHERE ((planord_type='W')\n AND (planord_itemsite_id=itemsite_id)\n AND (itemsite_warehous_id=)\n AND (itemsite_item_id=) )\n\nUNION\n-- Tools on Planned Work Orders\nSELECT planord_id AS orderid, -1 AS altorderid,\n CASE WHEN (planord_firm) THEN \n\t ELSE \n END AS ordertype,\n CAST(planord_number AS text) AS ordernumber,\n 1 AS sequence,\n item_number,\n planord_duedate AS duedate,\n FALSE AS late,\n (itemCost(planreq_itemsite_id) * planreq_qty) AS amount,\n planreq_qty AS qtyordered,\n NULL AS qtyreceived,\n planreq_qty AS balance,\n planord_comments AS notes\nFROM planreq\n JOIN itemsite ON (itemsite_id=planreq_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN planord ON ((planreq_source_id=planord_id)\n AND (planreq_source='P'))\nWHERE ((itemsite_warehous_id=)\n AND (itemsite_item_id=)\n AND (item_type='T') )\n\nUNION\nSELECT planord_id AS orderid, -1 AS altorderid,\n CASE WHEN (planord_firm) THEN \n\t ELSE \n END AS ordertype,\n CAST(planord_number AS text) AS ordernumber,\n 1 AS sequence,\n srcwhsinfo.warehous_code || '/' || whsinfo.warehous_code AS item_number,\n planord_duedate AS duedate,\n FALSE AS late,\n (itemCost(planord_itemsite_id) * planord_qty) AS amount,\n planord_qty AS qtyordered,\n NULL AS qtyreceived,\n planord_qty AS balance,\n planord_comments AS notes\nFROM planord JOIN itemsite ON (itemsite.itemsite_id=planord_itemsite_id)\n JOIN whsinfo ON (whsinfo.warehous_id=itemsite.itemsite_warehous_id)\n JOIN itemsite srcitemsite ON (srcitemsite.itemsite_id=planord_supply_itemsite_id)\n JOIN whsinfo srcwhsinfo ON (srcwhsinfo.warehous_id=srcitemsite.itemsite_warehous_id)\nWHERE ((planord_type='T')\n AND (itemsite.itemsite_warehous_id=)\n AND (itemsite.itemsite_item_id=) )\n\nUNION\nSELECT planord_id AS orderid, -1 AS altorderid,\n CASE WHEN (planord_firm) THEN \n\t ELSE \n END AS ordertype,\n CAST(planord_number AS text) AS ordernumber,\n 1 AS sequence,\n srcwhsinfo.warehous_code || '/' || whsinfo.warehous_code AS item_number,\n planord_duedate AS duedate,\n FALSE AS late,\n (itemCost(planord_itemsite_id) * planord_qty) AS amount,\n planord_qty AS qtyordered,\n NULL AS qtyreceived,\n (planord_qty * -1) AS balance,\n planord_comments AS notes\nFROM planord JOIN itemsite ON (itemsite.itemsite_id=planord_itemsite_id)\n JOIN whsinfo ON (whsinfo.warehous_id=itemsite.itemsite_warehous_id)\n JOIN itemsite srcitemsite ON (srcitemsite.itemsite_id=planord_supply_itemsite_id)\n JOIN whsinfo srcwhsinfo ON (srcwhsinfo.warehous_id=srcitemsite.itemsite_warehous_id)\nWHERE ((planord_type='T')\n AND (srcitemsite.itemsite_warehous_id=)\n AND (srcitemsite.itemsite_item_id=) )\n\nUNION\nSELECT planreq_id AS orderid, -1 AS altorderid,\n CASE WHEN (planord_firm) THEN \n\t ELSE \n END AS ordertype,\n CAST(planord_number AS text) AS ordernumber,\n 1 AS sequence,\n--get the planned order number for the higher level demand\n (SELECT item_number\n FROM item, itemsite\n WHERE((itemsite_item_id=item_id)\n AND (itemsite_id=planord_itemsite_id))\n ) AS item_number,\n planord_startdate AS duedate,\n FALSE AS late,\n (itemCost(planreq_itemsite_id) * planreq_qty) AS amount,\n planreq_qty AS f_qtyordered,\n NULL AS qtyreceived,\n (planreq_qty * -1) AS balance,\n planreq_notes AS notes\nFROM planreq, planord, itemsite, item\nWHERE ((planreq_source='P')\n AND (planreq_source_id=planord_id)\n AND (planreq_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=)\n AND (itemsite_item_id=) )\n\n\nUNION\nSELECT pr_id AS orderid, -1 AS altorderid,\n AS ordertype,\n CAST(pr_number AS text) AS ordernumber, \n 1 AS sequence,\n '' AS item_number,\n pr_duedate AS duedate,\n FALSE AS late,\n (itemCost(pr_itemsite_id) * pr_qtyreq) AS amount,\n pr_qtyreq AS qtyordered,\n NULL AS qtyreceived,\n pr_qtyreq AS balance,\n pr_releasenote AS notes\nFROM pr, itemsite, item\nWHERE ((pr_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (pr_itemsite_id=itemsite_id)\n AND (itemsite_warehous_id=)\n AND (itemsite_item_id=) )\n\n) AS dummy\n\nORDER BY duedate, sequence;\n\n admin 2015-10-01 0 276 prices detail used by dspPricesByCustomerType, dspPricesByCustomer, dspPricesByItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: prices\n-- Name: detail\n-- Notes: used by dspPricesByCustomerType, dspPricesByCustomer, dspPricesByItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemid, sourcetype, schedulename, type,\n\n itemnumber, itemdescrip, priceuom,\n\n typename,\n\n CASE WHEN (qtybreak <> -1) THEN qtybreak END AS f_qtybreak,\n price,\n currConcat(curr_id) AS currConcat,\n 'qty' AS f_qtybreak_xtnumericrole,\n AS f_qtybreak_xtnullrole,\n 'salesprice' AS price_xtnumericrole\n\n \n , CASE WHEN ( <> 0) THEN END AS f_cost,\n CASE WHEN ((price <> 0) AND ( <> 0)) THEN ((price - ) / price) END AS f_margin,\n \n , CASE WHEN (cost IS NOT NULL) THEN cost END AS f_cost,\n CASE WHEN ((price <> 0) AND (cost <>0)) THEN ((price - cost) / price) END AS f_margin,\n \n 'cost' AS f_cost_xtnumericrole,\n AS f_cost_xtnullrole,\n 'percent' AS f_margin_xtnumericrole,\n AS f_margin_xtnullrole,\n \n CASE WHEN ( > price) THEN 'error' END AS f_margin_qtforegroundrole\n \n CASE WHEN (cost > price) THEN 'error' END AS f_margin_qtforegroundrole\n \n\nFROM (\n\n SELECT\n \n ipsprice_id AS itemid, 1 AS sourcetype,\n ipshead_name AS schedulename, AS type,\n item_number AS itemnumber, uom_name AS priceuom, iteminvpricerat(item_id) AS invpricerat,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n ipsprice_qtybreak AS qtybreak,\n ipsprice_price AS price, ipshead_curr_id AS curr_id,\n ipshead_updated AS effective\n \n , (stdcost(item_id) * iteminvpricerat(item_id)) AS cost\n \n , (actcost(item_id) * iteminvpricerat(item_id)) AS cost\n \n \n ipsprice_id AS itemid, 1 AS sourcetype,\n ipshead_name AS schedulename, AS type,\n cust_name AS typename,\n ipsprice_qtybreak AS qtybreak, ipsprice_price AS price, ipshead_curr_id AS curr_id\n \n FROM ipsass, ipshead, ipsprice, item,\n \n uom\n \n custinfo\n \n WHERE ((ipsass_ipshead_id=ipshead_id)\n AND (ipsprice_ipshead_id=ipshead_id)\n AND (ipsprice_item_id=item_id)\n \n AND (item_price_uom_id=uom_id)\n AND (ipsass_cust_id=)\n \n AND (item_id=)\n \n \n AND (ipsass_cust_id=cust_id)\n AND (item_id=)\n \n AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) = 0)\n \n AND (ipshead_expires > CURRENT_DATE)\n \n \n AND (ipshead_effective <= CURRENT_DATE)\n \n )\n\n UNION\n\n\n SELECT\n\n ipsprice_id AS itemid, 2 AS sourcetype,\n ipshead_name AS schedulename, AS type,\n (custtype_code || '-' || custtype_descrip) AS typename,\n ipsprice_qtybreak AS qtybreak, ipsprice_price AS price, ipshead_curr_id AS curr_id\n\n ipsprice_id AS itemid,\n \n 1 AS sourcetype,\n \n 2 AS sourcetype,\n \n ipshead_name AS schedulename, AS type,\n item_number AS itemnumber, uom_name AS priceuom, iteminvpricerat(item_id) AS invpricerat,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n ipsprice_qtybreak AS qtybreak,\n ipsprice_price AS price, ipshead_curr_id AS curr_id,\n ipshead_updated AS effective\n \n \n , (stdcost(\n \n ipsprice_item_id\n \n item_id\n \n ) * iteminvpricerat(item_id)) AS cost\n \n , (actcost(\n \n ipsprice_item_id\n \n item_id\n \n ) * iteminvpricerat(item_id)) AS cost\n \n \n\n FROM ipsass, ipshead, ipsprice, item,\n\n custtype\n\n uom\n\n\n , custinfo\n\n WHERE ((ipsass_ipshead_id=ipshead_id)\n AND (ipsprice_ipshead_id=ipshead_id)\n AND (ipsprice_item_id=item_id)\n\n AND (item_price_uom_id=uom_id)\n\n\n AND (ipsass_custtype_id=)\n\n AND (ipsass_custtype_id=cust_custtype_id)\n AND (cust_id=)\n \n AND (item_id=)\n \n\n AND (ipsass_custtype_id=custtype_id)\n AND (item_id=)\n\n\n AND (ipshead_expires > CURRENT_DATE)\n\n\n AND (ipshead_effective <= CURRENT_DATE)\n\n )\n\n UNION\n\n SELECT\n\n ipsprice_id AS itemid, 3 AS sourcetype,\n ipshead_name AS schedulename, AS type,\n (custtype_code || '-' || custtype_descrip) AS typename,\n ipsprice_qtybreak AS qtybreak, ipsprice_price AS price, ipshead_curr_id AS curr_id\n\n ipsprice_id AS itemid,\n \n 2 AS sourcetype,\n \n 3 AS sourcetype,\n \n ipshead_name AS schedulename, AS type,\n item_number AS itemnumber, uom_name AS priceuom, iteminvpricerat(item_id) AS invpricerat,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n ipsprice_qtybreak AS qtybreak,\n ipsprice_price AS price, ipshead_curr_id AS curr_id,\n ipshead_updated AS effective\n \n \n , (stdcost(\n \n ipsprice_item_id\n \n item_id\n \n ) * iteminvpricerat(item_id)) AS cost\n \n , (actcost(\n \n ipsprice_item_id\n \n item_id\n \n ) * iteminvpricerat(item_id)) AS cost\n \n \n\n FROM ipsass, ipshead, ipsprice, item, custtype\n\n , uom\n\n\n , custinfo\n\n WHERE ((ipsass_ipshead_id=ipshead_id)\n AND (ipsprice_ipshead_id=ipshead_id)\n AND (ipsprice_item_id=item_id)\n\n AND (item_price_uom_id=uom_id)\n\n AND (coalesce(length(ipsass_custtype_pattern), 0) > 0)\n AND (custtype_code ~ ipsass_custtype_pattern)\n\n AND (custtype_id=)\n\n AND (cust_id=)\n \n AND (item_id=)\n \n\n AND (item_id=)\n\n\n AND (ipshead_expires > CURRENT_DATE)\n\n\n AND (ipshead_effective <= CURRENT_DATE)\n\n )\n\n UNION\n\n SELECT\n\n ipsprice_id AS itemid, 4 AS sourcetype,\n ipshead_name AS schedulename, AS type,\n sale_name AS typename,\n ipsprice_qtybreak AS qtybreak, ipsprice_price AS price, ipshead_curr_id AS curr_id\n\n ipsprice_id AS itemid,\n\n 3\n\n 4\n AS sourcetype,\n ipshead_name AS schedulename, ( || '-' || sale_name) AS type,\n item_number AS itemnumber, uom_name AS priceuom, iteminvpricerat(item_id) AS invpricerat,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n ipsprice_qtybreak AS qtybreak,\n ipsprice_price AS price, ipshead_curr_id AS curr_id,\n ipshead_updated AS effective\n\n \n , (stdcost(\n \n ipsprice_item_id\n \n item_id\n \n ) * iteminvpricerat(item_id)) AS cost\n \n , (actcost(\n \n ipsprice_item_id\n \n item_id\n \n ) * iteminvpricerat(item_id)) AS cost\n \n \n\n FROM sale, ipshead, ipsprice, item\n\n , uom\n\n WHERE ((sale_ipshead_id=ipshead_id)\n AND (ipsprice_ipshead_id=ipshead_id)\n\n AND (item_price_uom_id=uom_id)\n\n\n AND (ipsprice_item_id=)\n \n AND (sale_enddate > CURRENT_DATE)\n \n \n AND (sale_startdate <= CURRENT_DATE)\n \n\n AND (ipsprice_item_id=item_id)\n \n AND (ipshead_expires > CURRENT_DATE)\n \n \n AND (ipshead_effective <= CURRENT_DATE)\n \n\n )\n\n\n\n UNION\n\n SELECT ipsprice_id AS itemid, 5 AS sourcetype,\n ipshead_name AS schedulename, AS type,\n (cust_name || '-' || shipto_num) AS typename,\n ipsprice_qtybreak AS qtybreak, ipsprice_price AS price, ipshead_curr_id AS curr_id\n FROM ipsass, ipshead, ipsprice, custinfo, shiptoinfo, item\n WHERE ((ipsass_ipshead_id=ipshead_id)\n AND (ipsprice_ipshead_id=ipshead_id)\n AND (ipsass_shipto_id=shipto_id)\n AND (shipto_cust_id=cust_id)\n AND (ipsprice_item_id=item_id)\n AND (item_id=)\n \n AND (ipshead_expires > CURRENT_DATE)\n \n \n AND (ipshead_effective <= CURRENT_DATE)\n \n )\n\n UNION\n\n SELECT ipsprice_id AS itemid, 6 AS sourcetype,\n ipshead_name AS schedulename, AS type,\n (cust_name || '-' || shipto_num) AS typename,\n ipsprice_qtybreak AS qtybreak, ipsprice_price AS price, ipshead_curr_id AS curr_id\n FROM ipsass, ipshead, ipsprice, custinfo, shiptoinfo, item\n WHERE ((ipsass_ipshead_id=ipshead_id)\n AND (ipsprice_ipshead_id=ipshead_id)\n AND (COALESCE(LENGTH(ipsass_shipto_pattern),0) > 0)\n AND (shipto_num ~ ipsass_shipto_pattern)\n AND (ipsass_cust_id=cust_id)\n AND (shipto_cust_id=cust_id)\n AND (ipsprice_item_id=item_id)\n AND (item_id=:item_id)\n \n AND (ipshead_expires > CURRENT_DATE)\n \n \n AND (ipshead_effective <= CURRENT_DATE)\n \n )\n\n\n UNION\n\n SELECT\n\n item_id AS itemid, 0 AS sourcetype,\n AS schedulename, AS type,\n '' AS typename,\n -1 AS qtybreak, item_listprice AS price, baseCurrId() AS curr_id\n\n item_id AS itemid, 0 AS sourcetype,\n '' AS schedulename, AS type,\n item_number AS itemnumber, uom_name AS priceuom, iteminvpricerat(item_id) AS invpricerat,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n -1 AS qtybreak,\n \n item_listprice AS price,\n \n (item_listprice - (item_listprice * cust_discntprcnt)) AS price,\n \n baseCurrId() AS curr_id,\n CURRENT_DATE AS effective\n \n , (stdcost(item_id) * iteminvpricerat(item_id)) AS cost\n \n , (actcost(item_id) * iteminvpricerat(item_id)) AS cost\n \n\n\n FROM item JOIN uom ON (item_price_uom_id=uom_id)\n\n FROM custinfo, item JOIN uom ON (item_price_uom_id=uom_id)\n\n FROM item\n\n WHERE (\n\n (item_sold)\n AND (item_active)\n\n (item_id=)\n\n AND (NOT item_exclusive)\n\n AND (cust_id=)\n \n AND (item_id=)\n \n\n )\n ) AS data\nORDER BY\n\n itemnumber,\n\n price;\n admin 2015-10-01 0 82 salesOrderItems detail used by dspBacklogByCustomer, dspBacklogByItem, dspBacklogByParameterList, dspBacklogBySalesOrder, dspBookingsByCustomer, dspBookingsByCustomerGroup, dspBookingsByItem, dspBookingsByProductCategory, dspBookingsBySalesRep, dspBookingsByShipTo, dspSalesOrdersByItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: salesOrderItems\n-- Name: detail\n-- Notes: used by dspBacklogByCustomer, dspBacklogByItem, dspBacklogByParameterList, dspBacklogBySalesOrder, dspBookingsByCustomer, dspBookingsByCustomerGroup, dspBookingsByItem, dspBookingsByProductCategory, dspBookingsBySalesRep, dspBookingsByShipTo, dspSalesOrdersByItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n cohead_id, coitem_id, *, currconcat(cohead_curr_id) AS currAbbr,\n\n CASE WHEN xtindentrole = 0 THEN cust_name\n END AS item_number_qtdisplayrole,\n\n-- no alterations to displayroles\n\n CASE WHEN xtindentrole = 0 THEN cohead_number\n END AS coitem_linenumber_qtdisplayrole,\n CASE WHEN xtindentrole = 0 THEN cust_name\n END AS item_number_qtdisplayrole,\n \n 'qty' AS coitem_qtyord_xtnumericrole,\n 'qty' AS coitem_qtyshipped_xtnumericrole,\n 'qty' AS coitem_qtyreturned_xtnumericrole,\n 'qty' AS qtyatshipping_xtnumericrole,\n 'qty' AS qtybalance_xtnumericrole,\n 'qty' AS qtyavailable_xtnumericrole,\n 'salesprice' AS coitem_price_xtnumericrole,\n 'salesprice' AS baseunitprice_xtnumericrole,\n 'curr' AS extprice_xtnumericrole,\n 'curr' AS baseextprice_xtnumericrole,\n 'curr' AS extpricebalance_xtnumericrole,\n 'curr' AS baseextpricebalance_xtnumericrole,\n 0 AS coitem_qtyord_xttotalrole,\n 0 AS coitem_qtyshipped_xttotalrole,\n 0 AS coitem_qtyreturned_xttotalrole,\n 0 AS qtybalance_xttotalrole,\n 0 AS baseextprice_xttotalrole,\n 0 AS baseextpricebalance_xttotalrole\nFROM (\n -- get cohead info\n \n \n SELECT \n 0 AS xtindentrole,\n -- dummy coitem record\n -1 AS coitem_id, NULL::INTEGER AS coitem_cohead_id,\n -1 AS coitem_linenumber,NULL::INTEGER AS coitem_itemsite_id,\n NULL::TEXT AS coitem_status, NULL::DATE AS coitem_scheddate,\n getSoSchedDate(cohead_id) AS sort_scheddate,\n NULL::DATE AS coitem_promdate, NULL::NUMERIC AS coitem_qtyord,\n NULL::NUMERIC AS coitem_unitcost, NULL::NUMERIC AS coitem_price,\n NULL::NUMERIC AS coitem_custprice, NULL::NUMERIC AS coitem_qtyshipped,\n NULL::INTEGER AS coitem_order_id, NULL::TEXT AS coitem_memo,\n NULL::BOOLEAN AS coitem_imported, NULL::NUMERIC AS coitem_qtyreturned,\n NULL::TIMESTAMP AS coitem_closedate,\n NULL::TEXT AS coitem_custpn, NULL::TEXT AS coitem_order_type,\n NULL::TEXT AS coitem_close_username,\n NULL::TIMESTAMP AS coitem_lastupdated,\n NULL::INTEGER AS coitem_substitute_item_id,\n NULL::TIMESTAMP AS coitem_created, NULL::TEXT AS coitem_creator,\n NULL::NUMERIC AS coitem_prcost,\n NULL::INTEGER AS coitem_qty_uom_id,\n NULL::NUMERIC AS coitem_qty_invuomratio,\n NULL::INTEGER AS coitem_price_uom_id,\n NULL::NUMERIC AS coitem_price_invuomratio,\n NULL::BOOLEAN AS coitem_warranty,\n NULL::INTEGER AS coitem_cos_accnt_id,\n NULL::NUMERIC AS coitem_qtyreserved,\n NULL::INTEGER AS coitem_subnumber,\n cohead.*,\n cust_number, cust_name,\n NULL::TEXT AS item_number, NULL::TEXT AS item_descrip1,\n NULL::TEXT AS itemdescription,\n NULL::TEXT AS uom_name,\n NULL::TEXT AS warehous_code,\n NULL::NUMERIC AS qtyatshipping,\n NULL::NUMERIC AS qtyavailable,\n NULL::BOOLEAN AS stockout,\n NULL::BOOLEAN AS reorder,\n NULL::NUMERIC AS qtybalance,\n NULL::NUMERIC AS baseunitprice,\n NULL::NUMERIC AS extprice,\n NULL::NUMERIC AS baseextprice,\n NULL::NUMERIC AS extpricebalance,\n NULL::NUMERIC AS baseextpricebalance,\n NULL::TEXT AS qtyavailable_qtforegroundrole\n\n FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)\n JOIN custinfo ON (cust_id=cohead_cust_id)\n JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n JOIN site() ON (warehous_id=itemsite_warehous_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN uom ON (uom_id=coitem_qty_uom_id)\n WHERE ( (coitem_status<>'X')\n \n AND (coitem_cohead_id=)\n \n \n AND (coitem_status<>'C')\n \n \n \n AND (cohead_orderdate BETWEEN AND )\n \n AND (coitem_scheddate BETWEEN AND )\n \n \n\n \n AND (cohead_salesrep_id=)\n \n \n AND (cohead_shipto_id=)\n \n \n AND (cohead_cust_id=)\n \n AND (cust_custtype_id=)\n \n AND (cust_custtype_id IN (SELECT DISTINCT custtype_id\n FROM custtype\n WHERE (custtype_code ~ )))\n \n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrpitem))\n \n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrpitem\n WHERE (custgrpitem_custgrp_id=)))\n \n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrp, custgrpitem\n WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n AND (custgrp_name ~ ) )) )\n \n\n \n AND (itemsite_item_id=)\n \n AND (item_prodcat_id=)\n \n AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n FROM prodcat\n WHERE (prodcat_code ~ )))\n \n\n \n AND (itemsite_warehous_id=)\n \n )\n\n UNION\n -- endif not exists "salesrep_id"\n -- endif not exists "item_id"\n -- endif not exists "cohead_id"\n\n SELECT \n 0\n 0\n 0\n 1 AS xtindentrole,\n coitem_id, coitem_cohead_id,\n coitem_linenumber,coitem_itemsite_id,\n coitem_status, coitem_scheddate,\n getSoSchedDate(cohead_id) AS sort_scheddate,\n coitem_promdate, coitem_qtyord,\n coitem_unitcost, coitem_price,\n coitem_custprice, coitem_qtyshipped,\n coitem_order_id, coitem_memo,\n coitem_imported, coitem_qtyreturned,\n coitem_closedate,\n coitem_custpn, coitem_order_type,\n coitem_close_username,\n coitem_lastupdated,\n coitem_substitute_item_id,\n coitem_created, coitem_creator,\n coitem_prcost,\n coitem_qty_uom_id,\n coitem_qty_invuomratio,\n coitem_price_uom_id,\n coitem_price_invuomratio,\n coitem_warranty,\n coitem_cos_accnt_id,\n coitem_qtyreserved,\n coitem_subnumber,\n cohead.*,\n cust_number, cust_name,\n item_number, item_descrip1, (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n uom_name,\n warehous_code,\n ( SELECT SUM(shipitem_qty)\n FROM shipitem JOIN shiphead ON ( (shipitem_shiphead_id=shiphead_id) AND (shiphead_order_type='SO') AND (NOT shiphead_shipped) )\n WHERE (shipitem_orderitem_id=coitem_id) ) AS qtyatshipping,\n qtyAvailable(itemsite_id, coitem_scheddate) AS qtyavailable,\n (qtyAvailable(itemsite_id, coitem_scheddate) < 0.0) AS stockout,\n CASE WHEN (itemsite_useparams) THEN (qtyAvailable(itemsite_id, coitem_scheddate) <= itemsite_reorderlevel)\n ELSE (qtyAvailable(itemsite_id, coitem_scheddate) <= 0.0)\n END AS reorder,\n noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS qtybalance,\n currtobase(cohead_curr_id, coitem_price, cohead_orderdate) AS baseunitprice,\n round((coitem_qtyord * coitem_qty_invuomratio) *\n (coitem_price / coitem_price_invuomratio), 2) AS extprice,\n round((coitem_qtyord * coitem_qty_invuomratio) *\n (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS baseextprice,\n round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n (coitem_price / coitem_price_invuomratio), 2) AS extpricebalance,\n round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS baseextpricebalance,\n CASE WHEN (qtyAvailable(itemsite_id, coitem_scheddate) < 0.0) THEN 'error'\n WHEN itemsite_useparams AND (qtyAvailable(itemsite_id, coitem_scheddate) <= itemsite_reorderlevel) THEN 'warning'\n WHEN NOT itemsite_useparams AND (qtyAvailable(itemsite_id, coitem_scheddate) <= 0.0) THEN 'warning'\n END AS qtyavailable_qtforegroundrole\n\n FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)\n JOIN custinfo ON (cust_id=cohead_cust_id)\n JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n JOIN site() ON (warehous_id=itemsite_warehous_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN uom ON (uom_id=coitem_qty_uom_id)\n WHERE ( (coitem_status<>'X')\n \n AND (coitem_cohead_id=)\n \n \n AND (coitem_status<>'C')\n \n \n \n AND (cohead_orderdate BETWEEN AND )\n \n AND (coitem_scheddate BETWEEN AND )\n \n \n\n \n AND (cohead_salesrep_id=)\n \n \n AND (cohead_shipto_id=)\n \n \n AND (cohead_cust_id=)\n \n AND (cust_custtype_id=)\n \n AND (cust_custtype_id IN (SELECT DISTINCT custtype_id\n FROM custtype\n WHERE (custtype_code ~ )))\n \n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrpitem))\n \n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrpitem\n WHERE (custgrpitem_custgrp_id=)))\n \n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrp, custgrpitem\n WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n AND (custgrp_name ~ ) )) )\n \n\n \n AND (itemsite_item_id=)\n \n AND (item_prodcat_id=)\n \n AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n FROM prodcat\n WHERE (prodcat_code ~ )))\n \n\n \n AND (itemsite_warehous_id=)\n \n )\n\n) AS dummy\n\n\n ORDER BY sort_scheddate, cohead_number, coitem_linenumber\n\n ORDER BY cohead_orderdate, cohead_number, coitem_linenumber\n\n ORDER BY cohead_number, coitem_linenumber\n\n;\n admin 2015-10-01 0 433 salesOrderItems list used by salesOrder\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: salesOrderItems\n-- Name: list\n-- Notes: used by salesOrder\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT coitem_id, coitem_altid, groupby,\n coitem_linenumber, coitem_subnumber, f_linenumber,\n warehous_code, item_number, item_type, description,\n item_number_cust, item_descrip1_cust, item_descrip2_cust, item_barcode,\n prodweight, packweight,\n enhanced_status, coitem_firm,\n qty_uom, price_uom, ship_uom,\n coitem_memo,\n-- always create formatted columns for scheduled reports\n formatDate(coitem_scheddate) AS f_scheddate,\n formatSalesPrice(coitem_price) AS f_price,\n formatSalesPrice(coitem_custprice) AS f_custprice,\n formatPrcnt(discountfromcust / 100) AS f_discountfromcust,\n formatQty(coitem_qtyord) AS f_qtyord,\n CASE WHEN (qtyshipped > 0.0) THEN formatQty(qtyshipped) ELSE NULL END AS f_qtyshipped,\n CASE WHEN (qtyshipped > 0.0) THEN formatQty(balance) ELSE NULL END AS f_balance,\n CASE WHEN (qtyatshipping > 0.0) THEN formatQty(qtyatshipping) ELSE NULL END AS f_qtyatshipping,\n formatMoney(extprice) AS f_extprice,\n CASE WHEN (extprice_shipped > 0.0) THEN formatMoney(extprice_shipped) ELSE NULL END AS f_extprice_shipped,\n-- end formatted columns\n coitem_scheddate, coitem_price, coitem_custprice, discountfromcust,\n coitem_unitcost, margin, marginpercent,\n coitem_qtyord, qtyshipped, balance, qtyatshipping,\n extprice, extprice_shipped,\n CASE WHEN (discountfromcust=100.0) THEN 'N/A' END AS discountfromcust_qtdisplayrole,\n CASE WHEN (margin=0.0) THEN 'N/A' END AS margin_qtdisplayrole,\n CASE WHEN (marginpercent=0.0) THEN 'N/A' END AS marginpercent_qtdisplayrole,\n 'qty' AS coitem_qtyord_xtnumericrole,\n 'qty' AS qtyshipped_xtnumericrole,\n 'qty' AS balance_xtnumericrole,\n 'qty' AS qtyatshipping_xtnumericrole,\n 'qty' AS prodweight_xtnumericrole,\n 'qty' AS packweight_xtnumericrole,\n 'salesprice' AS coitem_price_xtnumericrole,\n 'salesprice' AS coitem_custprice_xtnumericrole,\n 'cost' AS coitem_unitcost_xtnumericrole,\n 'curr' AS extprice_xtnumericrole,\n 'curr' AS extprice_shipped_xtnumericrole,\n 'curr' AS margin_xtnumericrole,\n 'percent' AS marginpercent_xtnumericrole,\n CASE WHEN fetchMetricBool('EnableSOShipping') AND\n coitem_scheddate > CURRENT_DATE AND\n (noNeg(coitem_qtyord) <> qtyAtShipping('SO', coitem_id)) THEN 'future'\n WHEN fetchMetricBool('EnableSOShipping') AND\n (noNeg(coitem_qtyord) <> qtyAtShipping('SO', coitem_id)) THEN 'expired'\n WHEN (coitem_status NOT IN ('C', 'X') AND\n EXISTS(SELECT coitem_id\n FROM coitem\n WHERE ((coitem_status='C')\n AND (coitem_cohead_id=)))) THEN 'error'\n END AS coitem_scheddate_qtforegroundrole,\n CASE WHEN coitem_subnumber = 0 THEN 0\n ELSE 1\n END AS xtindentrole,\n spplytype, ordrnumbr,\n availableqoh,\n 'qty' AS availableqoh_xtnumericrole\n\n ,\n reserved,\n reservable,\n 'qty' AS reserved_xtnumericrole,\n 'qty' AS reservable_xtnumericrole\n\nFROM (\nSELECT coitem_id,\n CASE WHEN (coitem_status='C') THEN 1\n WHEN (coitem_status='X') THEN 4\n WHEN ( (coitem_status='O') AND ( (qtyAtShipping('SO', coitem_id) > 0) OR (coitem_qtyshipped > 0) ) ) THEN 2\n ELSE 3\n END AS coitem_altid, 1 AS groupby,\n coitem_linenumber, coitem_subnumber, formatSoLineNumber(coitem_id) AS f_linenumber,\n warehous_code, item_number, item_type,\n (item_descrip1 || ' ' || item_descrip2) AS description,\n CASE WHEN (coitem_custpn != '') THEN coitem_custpn\n ELSE item_number\n END AS item_number_cust,\n CASE WHEN (coitem_custpn != '' AND itemalias_usedescrip=TRUE) THEN itemalias_descrip1\n ELSE item_descrip1\n END AS item_descrip1_cust,\n CASE WHEN (coitem_custpn != '' AND itemalias_usedescrip=TRUE) THEN itemalias_descrip2\n ELSE item_descrip2\n END AS item_descrip2_cust,\n formatitemsitebarcode(itemsite_id) AS item_barcode,\n (coitem_qtyord * coitem_qty_invuomratio * item_prodweight) AS prodweight,\n (coitem_qtyord * coitem_qty_invuomratio * item_packweight) AS packweight,\n coitem_status, coitem_firm,\n getSoitemStatus(coitem_id) AS enhanced_status,\n quom.uom_name AS qty_uom, puom.uom_name AS price_uom,\n itemSellingUOM(item_id) AS ship_uom,\n coitem_memo,\n coitem_scheddate, coitem_price, coitem_custprice, coitem_qtyord,\n CASE WHEN (coitem_custprice = 0.0) THEN 100.0\n ELSE ((1.0 - (coitem_price / coitem_custprice)) * 100.0)\n END AS discountfromcust,\n coitem_unitcost,\n CASE WHEN (coitem_price = 0.0) THEN 0.0\n ELSE ROUND(coitem_qtyord * coitem_qty_invuomratio * (coitem_price - coitem_unitcost) / coitem_price_invuomratio,2)\n END AS margin,\n CASE WHEN (coitem_price = 0.0) THEN 0.0\n ELSE ((coitem_price - coitem_unitcost) / coitem_price)\n END AS marginpercent,\n noNeg(coitem_qtyshipped - coitem_qtyreturned) AS qtyshipped,\n noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS balance,\n qtyAtShipping('SO', coitem_id) AS qtyatshipping,\n ROUND((coitem_qtyord * coitem_qty_invuomratio) *\n (coitem_price / coitem_price_invuomratio),2) AS extprice,\n ROUND(((coitem_qtyshipped - coitem_qtyreturned) * coitem_qty_invuomratio) *\n (coitem_price / coitem_price_invuomratio),2) AS extprice_shipped,\n CASE WHEN coitem_order_type='W' THEN TEXT( 'WO')\n WHEN coitem_order_type='P' THEN TEXT('PO' )\n WHEN coitem_order_type='R' THEN TEXT('PR')\n ELSE TEXT (' ')\n END AS spplytype,\n CASE WHEN coitem_order_type='W' THEN (wo_number || '-' || wo_subnumber)\n WHEN coitem_order_type='P' THEN (pohead_number || '-' || poitem_linenumber)\n WHEN coitem_order_type='R' THEN (pr_number || '-' || pr_subnumber)\n ELSE TEXT (' ')\n END AS ordrnumbr,\n qtyAvailable(itemsite_id) AS availableqoh\n\n ,\n coitem_qtyreserved AS reserved,\n qtyAvailable(itemsite_id) - qtyReserved(itemsite_id) AS reservable\n\n FROM cohead\n JOIN coitem ON (coitem_cohead_id=cohead_id)\n JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN whsinfo ON (warehous_id=itemsite_warehous_id)\n JOIN uom AS quom ON (quom.uom_id=coitem_qty_uom_id)\n JOIN uom AS puom ON (puom.uom_id=coitem_price_uom_id)\n LEFT OUTER JOIN itemalias ON ((itemalias_item_id=item_id) AND (itemalias_number=coitem_custpn))\n LEFT OUTER JOIN wo ON (coitem_order_id = wo_id)\n LEFT OUTER JOIN pr ON (coitem_order_id = pr_id)\n LEFT OUTER JOIN (pohead JOIN poitem ON (pohead_id = poitem_pohead_id))\n ON (coitem_order_id = poitem_id)\n WHERE (cohead_id=)\n\n\n AND (coitem_status != 'X')\n\n\n\n AND (coitem_status != 'C')\n\n\n\n AND (item_type != 'K')\n\n\n) AS data\nORDER BY coitem_linenumber, coitem_subnumber; admin 2015-10-01 0 102 todolist detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: todolist\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT * FROM (\n/* ---------TO DO-------------- */\n SELECT todoitem_id AS id, \n 1 AS altId, \n AS type, \n CAST(incdt_number AS text) AS number,\n todoitem_name AS name,\n CASE WHEN (todoitem_active AND todoitem_status != 'C') THEN TRUE\n ELSE FALSE\n END AS active,\n CASE WHEN (todoitem_status='C') THEN \n WHEN (todoitem_status='D') THEN \n WHEN (todoitem_status='P') THEN \n WHEN (todoitem_status='I') THEN \n WHEN (todoitem_status='N') THEN \n ELSE '?'\n END AS stage,\n incdtpriority_name AS priority, \n incdtpriority_order AS seq,\n todoitem_owner_username AS owner, \n todoitem_username AS assigned, \n firstLine(todoitem_description) AS notes, \n todoitem_start_date as start, \n todoitem_due_date AS due, \n formatDate(todoitem_due_date) AS f_due, \n todoitem_start_date is not null AS hasStartDate,\n todoitem_due_date is not null AS hasDueDate,\n crmacct_id,\n crmacct_number, \n crmacct_name, \n CASE WHEN (todoitem_ophead_id IS NOT NULL) THEN\n 'OPP'\n WHEN (todoitem_incdt_id IS NOT NULL) THEN\n 'INCDT'\n END AS parent,\n CASE WHEN (todoitem_ophead_id IS NOT NULL) THEN\n || '-' || ophead_number\n WHEN (todoitem_incdt_id IS NOT NULL) THEN\n || '-' || incdt_number\n END AS parent_qtdisplayrole,\n CASE WHEN (todoitem_ophead_id IS NOT NULL) THEN\n || '-' || ophead_number\n WHEN (todoitem_incdt_id IS NOT NULL) THEN\n || '-' || incdt_number\n END AS f_parent,\n COALESCE(todoitem_ophead_id, todoitem_incdt_id) AS parent_xtidrole,\n COALESCE(crmacct_cust_id,-1) > 0 AS cust_qtdisplayrole,\n crmacct_cust_id AS cust,\n CASE WHEN (todoitem_active AND todoitem_due_date < CURRENT_DATE) THEN 'expired'\n WHEN (todoitem_active AND todoitem_due_date > CURRENT_DATE) THEN 'future'\n END AS due_qtforegroundrole \n\n FROM todoitem\n\n FROM todoitem() \n\n LEFT OUTER JOIN incdt ON (incdt_id=todoitem_incdt_id) \n LEFT OUTER JOIN ophead ON (ophead_id=todoitem_ophead_id)\n LEFT OUTER JOIN crmacct ON (crmacct_id=todoitem_crmacct_id) \n LEFT OUTER JOIN incdtpriority ON (incdtpriority_id=todoitem_priority_id) \n\n WHERE false\n\n WHERE true\n\n\n AND (todoitem_start_date <= )\n\n\n AND (todoitem_start_date >= )\n\n\n AND (todoitem_due_date <= )\n\n\n AND (todoitem_due_date >= )\n\n\n AND (crmacct_id =)\n\n\n AND (todoitem_status = 'C')\t\t\t\n\n AND (todoitem_status != 'C')\t\t\t\n\n\n AND ( IN (todoitem_username, todoitem_owner_username))\n\n \n AND (todoitem_username=) \n\n AND (todoitem_username ~ ) \n\n \n AND (todoitem_owner_username=) \n\n AND (todoitem_owner_username ~ ) \n\nUNION ALL\n/* ---------INCIDENT-------------- */\n SELECT incdt_id AS id, \n 2 AS altId, \n AS type, \n CAST(incdt_number AS text) AS number,\n incdt_summary AS name, \n incdt_status != 'L' AS active,\n CASE WHEN (incdt_status='N') THEN \n WHEN (incdt_status='F') THEN \n WHEN (incdt_status='C') THEN \n WHEN (incdt_status='A') THEN \n WHEN (incdt_status='R') THEN \n WHEN (incdt_status='L') THEN \n ELSE '?'\n END AS stage,\n incdtpriority_name AS priority,\n incdtpriority_order AS seq,\n incdt_owner_username AS owner, \n incdt_assigned_username AS assigned,\n firstLine(incdt_descrip) AS notes, \n CAST(incdt_timestamp AS date) AS start, \n null AS due, \n null AS f_due, \n false AS hasStartDate,\n false AS hasDueDate,\n crmacct_id,\n crmacct_number, \n crmacct_name,\n '' AS parent,\n '' AS parent_qtdisplay_role,\n '' AS f_parent,\n NULL AS parent_xtidrole,\n COALESCE(crmacct_cust_id,-1) > 0 AS cust_qtdisplayrole,\n COALESCE(crmacct_cust_id,-1) AS cust,\n NULL AS due_qtforegroundrole \n\n FROM incdt\n\n FROM incdt()\n\n LEFT OUTER JOIN crmacct ON (crmacct_id=incdt_crmacct_id) \n LEFT OUTER JOIN custinfo ON (cust_id=crmacct_cust_id)\n LEFT OUTER JOIN incdtpriority ON (incdtpriority_id=incdt_incdtpriority_id) \n\n WHERE false\n\n WHERE true\n\n\n AND (incdt_timestamp::date <= )\n\n\n AND (incdt_timestamp::date >= )\n\n\n AND false\n\n\n AND false\n\n\n AND (crmacct_id =)\n\n\n AND (incdt_status = 'L')\t\t\t\n\n AND (incdt_status != 'L')\t\t\t\n\n\n AND ( IN (incdt_assigned_username, incdt_owner_username))\n\n \n AND (incdt_assigned_username=) \n\n AND (incdt_assigned_username ~ ) \n\n \n AND (incdt_owner_username=) \n\n AND (incdt_owner_username ~ ) \n\nUNION ALL\n/* ---------PROJECT TASK-------------- */\n SELECT prjtask_id AS id, \n 3 AS altId, \n AS type,\n prjtask_number AS number,\n prjtask_name AS name, \n prjtask_status != 'C' AS active,\n CASE WHEN (prjtask_status='P') THEN \n WHEN (prjtask_status='O') THEN \n WHEN (prjtask_status='C') THEN \n ELSE '?'\n END AS stage,\n NULL AS priority, \n NULL AS seq, \n prjtask_owner_username AS owner, \n prjtask_username AS assigned, \n firstLine(prjtask_descrip) AS notes, \n prjtask_start_date AS start, \n prjtask_due_date AS due, \n formatDate(prjtask_due_date) AS f_due, \n prjtask_start_date is not null AS hasStartDate,\n prjtask_due_date is not null AS hasDueDate,\n NULL AS crmacct_id,\n '' AS crmacct_number, \n '' AS crmacct_name,\n 'PRJ' AS parent,\n || '-' || prj_number AS parent_qtdisplay_role,\n || '-' || prj_number AS f_parent,\n prjtask_prj_id AS parent_xtidrole,\n false AS cust_qtdisplayrole, \n null AS cust,\n CASE WHEN (prjtask_status != 'C' AND prjtask_due_date < CURRENT_DATE) THEN 'expired'\n WHEN (prjtask_status != 'C' AND prjtask_due_date > CURRENT_DATE) THEN 'future'\n END AS due_qtforegroundrole \n\n FROM prjtask\n\n FROM prjtask()\n\n JOIN prj ON (prj_id=prjtask_prj_id)\n\n WHERE false\n\n WHERE true\n\n\n AND (prjtask_start_date <= )\n\n\n AND (prjtask_start_date >= )\n\n\n AND (prjtask_due_date <= )\n\n\n AND (prjtask_due_date >= )\n\n\n AND (prjtask_status = 'C')\t\t\t\n\n AND (prjtask_status != 'C')\t\t\t\n\n\n AND ( IN (prjtask_username, prjtask_owner_username))\n\n \n AND (prjtask_username=) \n\n AND (prjtask_username ~ ) \n\n \n AND (prjtask_owner_username=) \n\n AND (prjtask_owner_username ~ ) \n\nUNION ALL\n/* ---------PROJECT-------------- */\n SELECT prj_id AS id, \n 4 AS altId, \n AS type,\n prj_number AS number,\n prj_name AS name, \n prj_status != 'C' AS active,\n CASE WHEN (prj_status='P') THEN \n WHEN (prj_status='O') THEN \n WHEN (prj_status='C') THEN \n ELSE '?'\n END AS stage,\n NULL AS priority, \n NULL AS seq,\n prj_owner_username AS owner, \n prj_username AS assigned,\n firstLine(prj_descrip) AS notes, \n prj_start_date AS start, \n prj_due_date AS due, \n formatDate(prj_due_date) AS f_due, \n prj_start_date IS NOT NULL AS hasStartDate,\n prj_due_date IS NOT NULL AS hasDueDate,\n null AS crmacct_id,\n '' AS crmacct_number, \n '' AS crmacct_name,\n '' AS parent,\n '' AS parent_qtdisplayrole,\n '' AS f_parent,\n NULL AS parent_xtidrole,\n false AS cust_qtdisplayrole, \n null AS cust,\n CASE WHEN (prj_status != 'C'AND prj_due_date < CURRENT_DATE) THEN 'expired'\n WHEN (prj_status != 'C'AND prj_due_date > CURRENT_DATE) THEN 'future'\n END AS due_qtforegroundrole \n\n FROM prj\n\n FROM prj()\n\n\n WHERE false\n\n WHERE true\n\n\n AND (prj_start_date <= )\n\n\n AND (prj_start_date >= )\n\n\n AND (prj_due_date <= )\n\n\n AND (prj_due_date >= )\n\n\n AND (prj_status = 'C')\t\t\t\n\n AND (prj_status != 'C')\t\t\t\n\n\n AND ( IN (prj_username, prj_owner_username))\n\n \n AND (prj_username=) \n\n AND (prj_username ~ ) \n\n \n AND (prj_owner_username=) \n\n AND (prj_owner_username ~ ) \n\nUNION ALL\n/* ---------OPPORTUNITY-------------- */\n SELECT ophead_id AS id, \n 5 AS altId, \n AS type, \n ophead_number AS number,\n ophead_name AS name, \n ophead_active AS active,\n opstage_descrip AS stage, \n incdtpriority_name AS priority, \n incdtpriority_order AS seq,\n ophead_owner_username AS owner, \n ophead_username AS assigned, \n firstLine(ophead_notes) AS notes, \n ophead_start_date AS start, \n ophead_target_date AS due, \n formatDate(ophead_target_date) AS f_due,\n ophead_start_date is not null AS hasStartDate,\n ophead_target_date is not null AS hasDueDate,\n crmacct_id,\n crmacct_number, \n crmacct_name, \n '' AS parent,\n '' AS parent_qtdisplayrole,\n '' AS f_parent,\n NULL AS parent_xtidrole,\n COALESCE(crmacct_cust_id,-1) > 0 AS cust_qtdisplayrole,\n crmacct_cust_id AS cust,\n CASE WHEN (ophead_active AND ophead_target_date < CURRENT_DATE) THEN 'expired'\n WHEN (ophead_active AND ophead_target_date > CURRENT_DATE) THEN 'future'\n END AS due_qtforegroundrole \n\n FROM ophead\n\n FROM ophead()\n\n JOIN opstage ON (ophead_opstage_id=opstage_id)\n LEFT OUTER JOIN crmacct ON (crmacct_id=ophead_crmacct_id) \n LEFT OUTER JOIN incdtpriority ON (incdtpriority_id=ophead_priority_id) \n\n WHERE false\n\n WHERE true\n\n\n AND (ophead_start_date <= )\n\n\n AND (ophead_start_date >= )\n\n\n AND (ophead_target_date <= )\n\n\n AND (ophead_target_date >= )\n\n\n AND (crmacct_id =)\n\n\n AND (NOT ophead_active)\t\t\t\n\n AND (ophead_active)\t\t\t\n\n\n AND ( IN (ophead_username, ophead_owner_username))\n\n \n AND (ophead_username=) \n\n AND (ophead_username ~ ) \n\n \n AND (ophead_owner_username=) \n\n AND (ophead_owner_username ~ ) \n\n) AS data\nORDER BY hasDueDate desc, due, hasStartDate desc, start\n admin 2015-10-01 0 458 packingList getreport get the reportname should be used for a packing list or pick list\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: packingList\n-- Name: getreport\n-- Notes: get the reportname should be used for a packing list or pick list\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT findCustomerForm(cohead_cust_id,\n ) AS reportname\n FROM cohead \n WHERE (cohead_id=);\n\nSELECT findTOForm(,\n ) AS reportname;\n\n admin 2015-10-01 0 434 accountNumbers detail used by accountNumbers\n Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: accountNumbers\n-- Name: detail\n-- Notes: used by accountNumbers\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT accnt_id, *,\n CASE WHEN(accnt_type='A') THEN \n WHEN(accnt_type='E') THEN \n WHEN(accnt_type='L') THEN \n WHEN(accnt_type='Q') THEN \n WHEN(accnt_type='R') THEN \n ELSE accnt_type\n END AS accnt_type_qtdisplayrole,\n accnt_active \n FROM (ONLY accnt LEFT OUTER JOIN\n company ON (accnt_company=company_number)) \n LEFT OUTER JOIN subaccnttype ON (accnt_type=subaccnttype_accnt_type AND accnt_subaccnttype_code=subaccnttype_code)\n WHERE true\n\n AND (NOT COALESCE(company_external, false)) \n\n\n AND COALESCE(accnt_active, false)\n\n\n AND accnt_type = \n\n\n AND subaccnttype_id = \n\nORDER BY accnt_number, accnt_sub, accnt_profit;\n admin 2015-10-01 0 486 address uses used by address\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: address\n-- Name: uses\n-- Notes: used by address\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntct_id, 1, AS type, cntct_first_name,\n cntct_last_name, crmacct_number, cntct_phone,\n cntct_phone2, cntct_fax, cntct_email, cntct_webaddr\nFROM cntct LEFT OUTER JOIN crmacct ON (cntct_crmacct_id=crmacct_id)\nWHERE (cntct_addr_id=)\nUNION\nSELECT shipto_id, 2, , shipto_name,\n shipto_name, crmacct_number, '',\n '', '', '', ''\nFROM shiptoinfo LEFT OUTER JOIN crmacct ON (shipto_cust_id=crmacct_cust_id)\nWHERE (shipto_addr_id=)\nUNION\nSELECT vend_id, 3, , vend_number,\n vend_name, crmacct_number, '',\n '', '', '', ''\nFROM vendinfo LEFT OUTER JOIN crmacct ON (vend_id=crmacct_vend_id)\nWHERE (vend_addr_id=)\nUNION\nSELECT vendaddr_id, 4, , vendaddr_code,\n vendaddr_name, crmacct_number, '',\n '', '', '', ''\nFROM vendaddrinfo LEFT OUTER JOIN crmacct ON (vendaddr_vend_id=crmacct_vend_id)\nWHERE (vendaddr_addr_id=)\nUNION\nSELECT warehous_id, 5, , warehous_code,\n warehous_descrip, '', '',\n '', '', '', ''\nFROM whsinfo\nWHERE (warehous_addr_id=)\nORDER BY 3, 5, 4;\n admin 2015-10-01 0 230 addresses detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: addresses\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT ON (addr_country, addr_state, addr_city, addr_line1, addr_number) \n addr_id, addr_line1, addr_line2, addr_line3, \n addr_city, addr_state, addr_country, addr_postalcode \n\n , charass_alias.charass_value AS char\n\n\n , charass_alias.charass_value AS char\n\n\n , charass_alias.charass_value::date AS char\n\nFROM addr \n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='ADDR') \n AND (charass_alias.charass_target_id=addr_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='ADDR') \n AND (charass_alias.charass_target_id=addr_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='ADDR') \n AND (charass_alias.charass_target_id=addr_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\nWHERE true\n \n AND addr_active \n\n\nORDER BY addr_country, addr_state, addr_city, addr_line1, addr_number;\n admin 2015-10-01 0 35 allocations detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: allocations\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT source_id, type, order_number, item_number, totalqty, relievedqty, balanceqty, duedate,\n balanceqty AS runningbal,\n 'qty' AS totalqty_xtnumericrole,\n 'qty' AS relievedqty_xtnumericrole,\n 'qty' AS balanceqty_xtnumericrole,\n 0 AS runningbal_xtrunningrole,\n 'qty' AS runningbal_xtnumericrole,\n CASE WHEN (duedate < CURRENT_DATE) THEN 'error'\n END AS duedate_qtforegroundrole\nFROM\n(\nSELECT womatl_id AS source_id, TEXT('W/O') AS type,\n formatWoNumber(wo_id) AS order_number,\n paritem.item_number,\n itemuomtouom(component.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq) AS totalqty,\n itemuomtouom(component.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyiss) AS relievedqty,\n itemuomtouom(component.itemsite_item_id, womatl_uom_id, NULL, noNeg(womatl_qtyreq - womatl_qtyiss)) AS balanceqty,\n womatl_duedate AS duedate\n\nFROM womatl, wo, itemsite AS parent, itemsite AS component, item AS paritem, item AS compitem\nWHERE ((womatl_wo_id=wo_id)\n AND (wo_status<>'C')\n AND (wo_itemsite_id=parent.itemsite_id)\n AND (womatl_itemsite_id=component.itemsite_id)\n AND (parent.itemsite_item_id=paritem.item_id)\n AND (component.itemsite_item_id=compitem.item_id)\n AND (compitem.item_type != 'T')\n AND (component.itemsite_warehous_id=)\n AND (component.itemsite_item_id=)\n\n AND (womatl_duedate <= (CURRENT_DATE + component.itemsite_leadtime))\n\n AND (womatl_duedate <= (CURRENT_DATE + ))\n\n AND (womatl_duedate <= )\n\n AND (womatl_duedate BETWEEN AND )\n\n)\n\nUNION \n\n-- Special handling for tools\nSELECT womatl_id AS source_id, TEXT('W/O') AS type,\n formatWoNumber(wo_id) AS order_number,\n paritem.item_number,\n itemuomtouom(component.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq) AS totalqty,\n COALESCE(sum(invhist_invqty),0) AS relievedqty,\n noNeg(itemuomtouom(component.itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq) - COALESCE(sum(invhist_invqty),0)) AS balanceqty,\n womatl_duedate AS duedate\n\nFROM itemsite AS parent, itemsite AS component, item paritem, item AS compitem, wo, womatl\n LEFT OUTER JOIN womatlpost ON (womatl_id=womatlpost_womatl_id)\n LEFT OUTER JOIN invhist ON ((womatlpost_invhist_id=invhist_id)\n AND (invhist_invqty > 0))\nWHERE ((womatl_wo_id=wo_id)\n AND (wo_status<>'C')\n AND (wo_itemsite_id=parent.itemsite_id)\n AND (womatl_itemsite_id=component.itemsite_id)\n AND (parent.itemsite_item_id=paritem.item_id)\n AND (component.itemsite_item_id=compitem.item_id)\n AND (compitem.item_type='T')\n AND (component.itemsite_warehous_id=)\n AND (component.itemsite_item_id=)\n\n AND (womatl_duedate <= (CURRENT_DATE + component.itemsite_leadtime))\n\n AND (womatl_duedate <= (CURRENT_DATE + ))\n\n AND (womatl_duedate <= )\n\n AND (womatl_duedate BETWEEN AND )\n\n)\nGROUP BY womatl_id, wo_id, paritem.item_number, womatl_uom_id, womatl_qtyreq, womatl_duedate, component.itemsite_item_id\n\nUNION \nSELECT coitem_id AS source_id, TEXT('S/O') AS type,\n formatSoNumber(coitem_id) AS order_number,\n item_number,\n itemuomtouom(itemsite_item_id, coitem_qty_uom_id, NULL, coitem_qtyord) AS totalqty,\n itemuomtouom(itemsite_item_id, coitem_qty_uom_id, NULL, (coitem_qtyshipped + qtyAtShipping(coitem_id)) - coitem_qtyreturned) as relievedqty,\n itemuomtouom(itemsite_item_id, coitem_qty_uom_id, NULL, noNeg(coitem_qtyord - (coitem_qtyshipped + qtyAtShipping(coitem_id)) + coitem_qtyreturned)) AS balanceqty,\n coitem_scheddate as duedate\nFROM cohead, coitem, itemsite, item \nWHERE ( (coitem_cohead_id=cohead_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_sold)\n AND (coitem_status NOT IN ('C','X'))\n AND (itemsite_warehous_id=)\n AND (itemsite_item_id=)\n\n AND (coitem_scheddate <= (CURRENT_DATE + itemsite_leadtime))\n\n AND (coitem_scheddate <= (CURRENT_DATE + ))\n\n AND (coitem_scheddate <= )\n\n AND (coitem_scheddate BETWEEN AND )\n\n)\n\n\nUNION \nSELECT toitem_id AS source_id, TEXT('T/O') AS type,\n TEXT(tohead_number) AS order_number,\n item_number,\n toitem_qty_ordered AS totalqty,\n (toitem_qty_shipped + qtyAtShipping(toitem_id)) as relievedqty,\n noNeg(toitem_qty_ordered - (toitem_qty_shipped + qtyAtShipping(toitem_id))) AS balanceqty,\n toitem_schedshipdate as duedate\nFROM tohead, toitem, itemsite, item \nWHERE ((toitem_tohead_id=tohead_id)\n AND (toitem_item_id=itemsite_item_id)\n AND (tohead_src_warehous_id=)\n AND (itemsite_item_id=item_id)\n AND (toitem_status NOT IN ('C','X'))\n AND (itemsite_warehous_id=)\n AND (itemsite_item_id=)\n\n AND (toitem_schedshipdate <= (CURRENT_DATE + itemsite_leadtime))\n\n AND (toitem_schedshipdate <= (CURRENT_DATE + ))\n\n AND (toitem_schedshipdate <= )\n\n AND (toitem_schedshipdate BETWEEN AND )\n\n)\n\n) AS dummy\n\nORDER BY duedate;\n admin 2015-10-01 0 36 apAging detail used by dspTimePhasedOpenAPItems\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: apAging\n-- Name: detail\n-- Notes: used by dspTimePhasedOpenAPItems\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT apaging_vend_id, apaging_vend_number, apaging_vend_name,\n SUM(apaging_total_val) AS apaging_total_val_sum,\n SUM(apaging_cur_val) AS apaging_cur_val_sum,\n SUM(apaging_thirty_val) AS apaging_thirty_val_sum,\n SUM(apaging_sixty_val) AS apaging_sixty_val_sum,\n SUM(apaging_ninety_val) AS apaging_ninety_val_sum,\n SUM(apaging_plus_val) AS apaging_plus_val_sum,\n 'curr' AS apaging_total_val_sum_xtnumericrole,\n 'curr' AS apaging_cur_val_sum_xtnumericrole,\n 'curr' AS apaging_thirty_val_sum_xtnumericrole,\n 'curr' AS apaging_sixty_val_sum_xtnumericrole,\n 'curr' AS apaging_ninety_val_sum_xtnumericrole,\n 'curr' AS apaging_plus_val_sum_xtnumericrole,\n 0 AS apaging_total_val_sum_xttotalrole,\n 0 AS apaging_cur_val_sum_xttotalrole,\n 0 AS apaging_thirty_val_sum_xttotalrole,\n 0 AS apaging_sixty_val_sum_xttotalrole,\n 0 AS apaging_ninety_val_sum_xttotalrole,\n 0 AS apaging_plus_val_sum_xttotalrole\n\nFROM apaging(, )\n\nWHERE (apaging_vend_id=)\n\nWHERE (apaging_vend_vendtype_id=)\n\nWHERE (apaging_vendtype_code ~ )\n\nGROUP BY apaging_vend_number,apaging_vend_id,apaging_vend_name\nORDER BY apaging_vend_number;\n admin 2015-10-01 0 94 apApplications detail used by dspAPApplications\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: apApplications\n-- Name: detail\n-- Notes: used by dspAPApplications\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT apapply.*,\n vend_number, vend_name,\n CASE \n WHEN apapply_source_doctype = 'K' THEN\n apapply_checkhead_id\n ELSE\n apapply_source_apopen_id \n END AS apapply_source_docnumber_xtidrole,\n CASE WHEN (apapply_source_doctype='C') THEN \n WHEN (apapply_source_doctype='K') THEN \n ELSE apapply_source_doctype\n END AS apapply_source_doctype_qtdisplayrole,\n CASE WHEN (apapply_target_doctype='D') THEN apapply_target_apopen_id\n WHEN (apapply_target_doctype='V') THEN (SELECT vohead_id\n FROM vohead\n WHERE (vohead_number=apapply_target_docnumber))\n END AS apapply_target_docnumber_xtidrole,\n CASE WHEN (apapply_target_doctype='C') THEN \n WHEN (apapply_target_doctype='D') THEN \n WHEN (apapply_target_doctype='V') THEN \n WHEN (apapply_target_doctype='K') THEN \n ELSE apapply_target_doctype\n END AS apapply_target_doctype_qtdisplayrole,\n formatDate(apapply_postdate) AS f_postdate,-- for openrpt\n formatMoney(apapply_amount) AS f_amount, -- for openrpt\n currConcat(apapply_curr_id) AS currAbbr,\n currtobase(apapply_curr_id,apapply_amount,apapply_postdate) AS base_applied,\n 'curr' AS apapply_amount_xtnumericrole,\n 'curr' AS base_applied_xtnumericrole,\n 0 AS base_applied_xttotalrole\nFROM apapply, vendinfo\nWHERE ( (apapply_vend_id=vend_id)\n AND (apapply_postdate BETWEEN AND )\n\n AND (apapply_source_doctype IN ())\n\n\n AND (vend_id=)\n\n AND (vend_vendtype_id=)\n\n AND (vend_vendtype_id IN (SELECT vendtype_id FROM vendtype\n WHERE (vendtype_code ~ )))\n\n )\nORDER BY apapply_postdate, apapply_source_docnumber;\n admin 2015-10-01 0 129 apOpenItems detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: apOpenItems\n-- Name: detail\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT apopen_id, apopen_ponumber, apopen_docnumber,\n CASE WHEN (apopen_doctype='C') THEN \n WHEN (apopen_doctype='D') THEN \n WHEN (apopen_doctype='V') THEN \n ELSE \n END AS f_doctype,\n CASE WHEN (apopen_doctype='C') THEN 'emphasis' END AS f_doctype_qtforegroundrole,\n vend_number, vend_name,\n apopen_invcnumber AS invoicenumber,\n apopen_docdate, apopen_duedate, apopen_amount, apopen_status,\n\n formatDate(apopen_docdate) AS f_docdate,\n formatDate(apopen_duedate) AS f_duedate,\n formatMoney(apopen_amount) AS f_amount,\n formatMoney(apopen_paid - COALESCE(SUM(apapply_target_paid),0)) AS f_paid,\n formatMoney((apopen_amount - apopen_paid + COALESCE(SUM(apapply_target_paid),0)) *\n CASE WHEN apopen_doctype IN ('D', 'V') THEN 1 ELSE -1\n END) AS f_balance,\n formatMoney((apopen_amount - apopen_paid + COALESCE(SUM(apapply_target_paid),0))\n / apopen_curr_rate * (CASE WHEN apopen_doctype IN ('D', 'V') THEN 1 ELSE -1\n END)) AS f_base_balance,\n\n apopen_paid - COALESCE(SUM(apapply_target_paid),0) AS paid,\n (apopen_amount - apopen_paid + COALESCE(SUM(apapply_target_paid),0)) *\n CASE WHEN apopen_doctype IN ('D', 'V') THEN 1 ELSE -1\n END AS balance,\n currConcat(apopen_curr_id) AS currAbbr,\n (apopen_amount - apopen_paid + COALESCE(SUM(apapply_target_paid),0))\n / apopen_curr_rate * (CASE WHEN apopen_doctype IN ('D', 'V') THEN 1 ELSE -1\n END) AS base_balance,\n 'curr' AS apopen_amount_xtnumericrole,\n 'curr' AS paid_xtnumericrole,\n 'curr' AS balance_xtnumericrole,\n 'curr' AS base_balance_xtnumericrole,\n 0 AS base_balance_xttotalrole\n FROM apopen\n JOIN vendinfo ON (vend_id=apopen_vend_id)\n JOIN vendtype ON (vendtype_id=vend_vendtype_id)\n LEFT OUTER JOIN apapply ON (((apopen_id=apapply_target_apopen_id)\n OR (apopen_id=apapply_source_apopen_id))\n AND (apapply_postdate > ))\n WHERE ( (COALESCE(apopen_closedate,date + integer '1')>)\n AND (CASE WHEN () THEN apopen_docdate ELSE apopen_distdate END<=)\n\n AND (apopen_vend_id=)\n\n\n AND (vendtype_id=)\n\n\n AND (vendtype_code~)\n\n AND (apopen_duedate BETWEEN AND ) )\n GROUP BY apopen_id, apopen_ponumber, apopen_docnumber,apopen_doctype, apopen_invcnumber, apopen_docdate,\n apopen_duedate, apopen_docdate, apopen_amount, apopen_paid, apopen_curr_id, apopen_curr_rate,\n apopen.apopen_status, vend_number, vend_name\n ORDER BY apopen_docdate; admin 2015-10-01 0 308 apOpenItems selectedpayments \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: apOpenItems\n-- Name: selectedpayments\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n CASE WHEN (apopen_doctype='V') THEN \n WHEN (apopen_doctype='D') THEN \n WHEN (apopen_doctype='C') THEN \n END AS doctype,\n CASE WHEN (apopen_doctype='C') THEN 'emphasis' END AS doctype_qtforegroundrole,\n 'curr' AS apselect_amount_xtnumericrole,\n 'curr' AS apselect_amount_base_xtnumericrole,\n 'curr' AS apselect_running_base_xtnumericrole,\n 0 AS apselect_running_base_xtrunninginit,\n 1 AS apselect_running_base_xtrunningrole\nFROM (\n-- Vouchers and Debits\nSELECT apopen_id, apselect_id,\n (bankaccnt_name || '-' || bankaccnt_descrip) AS f_bank,\n (vend_number || '-' || vend_name) AS f_vendor,\n apopen_docnumber, apopen_ponumber, apselect_amount,\n apopen_invcnumber, apopen_doctype,\n currToBase(apselect_curr_id, apselect_amount, CURRENT_DATE) AS apselect_amount_base,\n currToBase(apselect_curr_id, apselect_amount, CURRENT_DATE) AS apselect_running_base,\n currConcat(apselect_curr_id) AS currAbbr\nFROM apopen, apselect, vendinfo, bankaccnt\nWHERE ( (apopen_vend_id=vend_id)\n AND (apselect_apopen_id=apopen_id)\n AND (apselect_bankaccnt_id=bankaccnt_id)\n AND (apopen_doctype IN ('V', 'D'))\n AND (apopen_open)\n\n AND (bankaccnt_id=)\n\n\n AND (vend_id=)\n\n AND (vend_vendtype_id=)\n\n AND (vend_vendtype_id IN (SELECT vendtype_id\n FROM vendtype\n WHERE (vendtype_code ~ )))\n\n )\nUNION\n-- Credits\nSELECT apopen_id, apselect_id,\n (bankaccnt_name || '-' || bankaccnt_descrip) AS f_bank,\n (vend_number || '-' || vend_name) AS f_vendor,\n apopen_docnumber, apopen_ponumber, -apselect_amount,\n apopen_invcnumber, apopen_doctype,\n currToBase(apselect_curr_id, apselect_amount, CURRENT_DATE) * -1.0 AS apselect_amount_base,\n currToBase(apselect_curr_id, apselect_amount, CURRENT_DATE) * -1.0 AS apselect_running_base,\n currConcat(apselect_curr_id) AS currAbbr\nFROM apopen, apselect, vendinfo, bankaccnt\nWHERE ( (apopen_vend_id=vend_id)\n AND (apselect_apopen_id=apopen_id)\n AND (apselect_bankaccnt_id=bankaccnt_id)\n AND (apopen_doctype='C')\n AND (apopen_open)\n\n AND (bankaccnt_id=)\n\n\n AND (vend_id=)\n\n AND (vend_vendtype_id=)\n\n AND (vend_vendtype_id IN (SELECT vendtype_id\n FROM vendtype\n WHERE (vendtype_code ~ )))\n\n )\nORDER BY f_bank, f_vendor, apopen_docnumber\n) AS data;\n admin 2015-10-01 0 309 apOpenItems selectpayments \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: apOpenItems\n-- Name: selectpayments\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n CASE WHEN (apopen_doctype='V') THEN \n WHEN (apopen_doctype='D') THEN \n WHEN (apopen_doctype='C') THEN \n END AS doctype,\n CASE WHEN (apopen_doctype='C') THEN 'emphasis' END AS doctype_qtforegroundrole,\n CASE WHEN (apopen_duedate < CURRENT_DATE) THEN 'error'\n WHEN(apopen_duedate > CURRENT_DATE) THEN 'emphasis'\n WHEN(CURRENT_DATE <= determineDiscountDate(apopen_terms_id, apopen_docdate)) THEN 'altemphasis'\n END AS apopen_duedate_qtforegroundrole,\n CASE WHEN (apopen_status = 'H') THEN 'error' END AS qtforegroundrole,\n 'curr' AS amount_xtnumericrole,\n 'curr' AS selected_xtnumericrole,\n 'curr' AS running_selected_xtnumericrole,\n 'curr' AS running_amount_xtnumericrole,\n 'curr' AS discount_xtnumericrole,\n 'curr' AS base_amount_xtnumericrole,\n 'curr' AS base_selected_xtnumericrole,\n 'curr' AS base_discount_xtnumericrole,\n 0 AS base_amount_xttotalrole,\n 0 AS base_selected_xttotalrole,\n 0 AS base_discount_xttotalrole,\n 0 AS running_selected_xtrunninginit,\n 0 AS running_amount_xtrunninginit,\n 1 AS running_selected_xtrunningrole,\n 1 AS running_amount_xtrunningrole\n FROM (\n-- Vouchers and Debits\nSELECT apopen_id, COALESCE(apselect_id, -1) AS apselectid,\n (vend_number || '-' || vend_name) AS vendor,\n apopen_doctype, apopen_docnumber, apopen_ponumber, apopen_invcnumber,\n apopen_duedate, apopen_terms_id, apopen_docdate, apopen_status,\n (apopen_amount - apopen_paid - apCheckPending(apopen_id)) AS amount,\n ((apopen_amount - apopen_paid - apCheckPending(apopen_id)) / apopen_curr_rate) AS base_amount,\n ((apopen_amount - apopen_paid - apCheckPending(apopen_id)) / apopen_curr_rate) AS running_amount,\n COALESCE(apselect_amount, 0.0) AS selected,\n (COALESCE(apselect_amount, 0.0) / apopen_curr_rate) AS base_selected,\n (COALESCE(apselect_amount, 0.0) / apopen_curr_rate) AS running_selected,\n COALESCE(apselect_discount,0.0) AS discount,\n (COALESCE(apselect_discount,0.0) / apopen_curr_rate)AS base_discount,\n currConcat(apopen_curr_id) AS curr_concat\nFROM vendinfo JOIN apopen ON (apopen_vend_id=vend_id)\n LEFT OUTER JOIN apselect ON (apselect_apopen_id=apopen_id)\nWHERE ( (apopen_open)\n AND (apopen_doctype IN ('V', 'D'))\n\n AND (vend_id=)\n\n AND (vend_vendtype_id=)\n\n AND (vend_vendtype_id IN (SELECT vendtype_id\n FROM vendtype\n WHERE (vendtype_code ~ )))\n\n\n AND (apopen_duedate <= )\n\n AND (apopen_duedate BETWEEN AND )\n\n\n AND (apopen_curr_id=)\n\n)\nUNION\n-- Credits\nSELECT apopen_id, COALESCE(apselect_id, -1) AS apselectid,\n (vend_number || '-' || vend_name) AS vendor,\n apopen_doctype, apopen_docnumber, apopen_ponumber, apopen_invcnumber,\n apopen_duedate, apopen_terms_id, apopen_docdate, apopen_status,\n (apopen_amount - apopen_paid - apCheckPending(apopen_id)) * -1.0 AS amount,\n ((apopen_amount - apopen_paid - apCheckPending(apopen_id)) / apopen_curr_rate) * -1.0 AS base_amount,\n ((apopen_amount - apopen_paid - apCheckPending(apopen_id)) / apopen_curr_rate) * -1.0 AS running_amount,\n COALESCE(apselect_amount, 0.0) * -1.0 AS selected,\n (COALESCE(apselect_amount, 0.0) / apopen_curr_rate) * -1.0 AS base_selected,\n (COALESCE(apselect_amount, 0.0) / apopen_curr_rate) * -1.0 AS running_selected,\n COALESCE(apselect_discount,0.0) AS discount,\n (COALESCE(apselect_discount,0.0) / apopen_curr_rate)AS base_discount,\n currConcat(apopen_curr_id) AS curr_concat\nFROM vendinfo JOIN apopen ON (apopen_vend_id=vend_id)\n LEFT OUTER JOIN apselect ON (apselect_apopen_id=apopen_id)\nWHERE ( (apopen_open)\n AND (apopen_doctype = 'C')\n\n AND (vend_id=)\n\n AND (vend_vendtype_id=)\n\n AND (vend_vendtype_id IN (SELECT vendtype_id\n FROM vendtype\n WHERE (vendtype_code ~ )))\n\n\n AND (apopen_duedate <= )\n\n AND (apopen_duedate BETWEEN AND )\n\n\n AND (apopen_curr_id=)\n\n)\nORDER BY apopen_duedate, amount DESC) AS data\nWHERE (amount != 0); admin 2015-10-01 0 37 arAging detail used by dspTimePhasedOpenARItems\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: arAging\n-- Name: detail\n-- Notes: used by dspTimePhasedOpenARItems\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT araging_cust_id, araging_cust_number, araging_cust_name,\n SUM(araging_total_val) AS araging_total_val_sum,\n SUM(araging_cur_val) AS araging_cur_val_sum,\n SUM(araging_thirty_val) AS araging_thirty_val_sum,\n SUM(araging_sixty_val) AS araging_sixty_val_sum,\n SUM(araging_ninety_val) AS araging_ninety_val_sum,\n SUM(araging_plus_val) AS araging_plus_val_sum,\n 'curr' AS araging_total_val_sum_xtnumericrole,\n 'curr' AS araging_cur_val_sum_xtnumericrole,\n 'curr' AS araging_thirty_val_sum_xtnumericrole,\n 'curr' AS araging_sixty_val_sum_xtnumericrole,\n 'curr' AS araging_ninety_val_sum_xtnumericrole,\n 'curr' AS araging_plus_val_sum_xtnumericrole,\n 0 AS araging_total_val_sum_xttotalrole,\n 0 AS araging_cur_val_sum_xttotalrole,\n 0 AS araging_thirty_val_sum_xttotalrole,\n 0 AS araging_sixty_val_sum_xttotalrole,\n 0 AS araging_ninety_val_sum_xttotalrole,\n 0 AS araging_plus_val_sum_xttotalrole\n\nFROM araging(, ) \n\nWHERE (araging_cust_id=)\n\nWHERE (araging_cust_custtype_id=)\n\nLEFT OUTER JOIN custgrpitem ON (araging_cust_id = custgrpitem_cust_id)\nWHERE (custgrpitem_custgrp_id=)\n\nWHERE (araging_custtype_code ~ )\n\nGROUP BY araging_cust_number,araging_cust_id,araging_cust_name\nORDER BY araging_cust_number;\n admin 2015-10-01 0 38 arApplications detail used by dspARApplications\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: arApplications\n-- Name: detail\n-- Notes: used by dspARApplications\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT arapply.*,\n cust_number, cust_name,\n CASE WHEN (arapply_source_doctype='C') THEN \n WHEN (arapply_source_doctype='R') THEN \n WHEN (arapply_fundstype='C') THEN \n WHEN (arapply_fundstype='T') THEN \n WHEN (arapply_fundstype='M') THEN \n WHEN (arapply_fundstype='V') THEN \n WHEN (arapply_fundstype='A') THEN \n WHEN (arapply_fundstype='D') THEN \n WHEN (arapply_fundstype='R') THEN \n WHEN (arapply_fundstype='K') THEN \n WHEN (arapply_fundstype='W') THEN \n WHEN (arapply_fundstype='O') THEN \n END AS doctype,\n CASE WHEN (arapply_source_doctype='C') THEN \n WHEN (arapply_source_doctype='R') THEN \n WHEN (arapply_source_doctype='K') THEN \n ELSE \n END AS sourcedoctype,\n CASE WHEN (arapply_target_doctype='D') THEN \n WHEN (arapply_target_doctype='I') THEN \n WHEN (arapply_target_doctype='K') THEN \n ELSE \n END AS targetdoctype,\n CASE WHEN (arapply_source_doctype IN ('C','R')) THEN TEXT(arapply_source_docnumber)\n ELSE arapply_refnumber\n END AS source,\n TEXT(arapply_target_docnumber) AS target,\n currConcat(arapply_curr_id) AS currAbbr,\n currtobase(arapply_curr_id,arapply_applied,arapply_postdate) AS base_applied,\n 'curr' AS arapply_applied_xtnumericrole,\n 'curr' AS base_applied_xtnumericrole,\n 0 AS base_applied_xttotalrole\nFROM arapply, custinfo\nWHERE ( (arapply_cust_id=cust_id)\n AND (arapply_postdate BETWEEN AND )\n AND (arapply_source_doctype IN (\n\n \n 'K', 'C', 'R'\n \n 'C', 'R'\n \n\n 'K'\n ))\n\n AND (cust_id=)\n\n AND (cust_custtype_id=)\n\n AND (cust_custtype_id IN (SELECT custtype_id FROM custtype\n WHERE (custtype_code ~ )))\n\n )\nORDER BY arapply_postdate, source;\n admin 2015-10-01 0 487 arCreditMemos unapplied used by unappliedARCreditMemos\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: arCreditMemos\n-- Name: unapplied\n-- Notes: used by unappliedARCreditMemos\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT aropen_id, aropen_docnumber,\n cust_number, cust_name,\n aropen_amount,\n (aropen_paid + COALESCE(prepared,0.0) + COALESCE(cashapplied,0.0)) AS applied,\n (aropen_amount - aropen_paid - COALESCE(prepared,0.0) - COALESCE(cashapplied,0.0)) AS balance,\n currConcat(aropen_curr_id) AS currAbbr,\n\n formatMoney(aropen_amount) AS f_amount,\n formatMoney(aropen_paid + COALESCE(prepared,0.0) + COALESCE(cashapplied,0.0)) AS f_applied,\n formatMoney(aropen_amount - aropen_paid - COALESCE(prepared,0.0) - COALESCE(cashapplied,0.0)) AS f_balance,\n\n 'curr' AS aropen_amount_xtnumericrole,\n 'curr' AS applied_xtnumericrole,\n 'curr' AS balance_xtnumericrole\nFROM aropen\n LEFT OUTER JOIN (SELECT aropen_id AS prepared_aropen_id,\n SUM(checkitem_amount + checkitem_discount) AS prepared\n FROM checkhead JOIN checkitem ON (checkitem_checkhead_id=checkhead_id)\n JOIN aropen ON (checkitem_aropen_id=aropen_id)\n WHERE ((NOT checkhead_posted)\n AND (NOT checkhead_void))\n GROUP BY aropen_id ) AS sub1\n ON (prepared_aropen_id=aropen_id)\n LEFT OUTER JOIN (SELECT aropen_id AS cash_aropen_id,\n SUM(cashrcptitem_amount + cashrcptitem_discount) * -1.0 AS cashapplied\n FROM cashrcpt JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id)\n JOIN aropen ON (cashrcptitem_aropen_id=aropen_id)\n WHERE (NOT cashrcpt_posted)\n GROUP BY aropen_id ) AS sub2\n ON (cash_aropen_id=aropen_id)\n JOIN custinfo ON (aropen_cust_id=cust_id)\nWHERE (aropen_doctype IN ('C', 'R'))\n AND (aropen_open)\n AND ((aropen_amount - aropen_paid - COALESCE(prepared,0.0) - COALESCE(cashapplied,0.0)) > 0.0)\nORDER BY aropen_docnumber;\n admin 2015-10-01 0 39 arHistory detail used by dspCustomerARHistory, dspCustomerInformation\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: arHistory\n-- Name: detail\n-- Notes: used by dspCustomerARHistory, dspCustomerInformation\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT aropen_id, applyid,\n sortdate, sortnumber, type,\n docnumber, open, documenttype,\n docdate, duedate, amount, balance, base_balance, currAbbr,\n formatBoolYN(open) AS f_open,\n formatDate(docdate) AS f_docdate, formatDate(duedate) AS f_duedate,\n 'curr' AS amount_xtnumericrole,\n 'curr' AS balance_xtnumericrole,\n 'curr' AS base_balance_xtnumericrole,\n 0 AS base_balance_xttotalrole,\n type AS xtindentrole\n FROM (\n SELECT 0 AS type, aropen_id, -1 AS applyid,\n aropen_docdate AS sortdate, (aropen_docnumber || aropen_doctype) AS sortnumber,\n aropen_docnumber AS docnumber,\n aropen_open AS open,\n CASE WHEN (aropen_doctype='I') THEN \n WHEN (aropen_doctype='C') THEN \n WHEN (aropen_doctype='D') THEN \n WHEN (aropen_doctype='R') then \n ELSE \n END AS documenttype,\n aropen_docdate AS docdate,\n aropen_duedate AS duedate,\n aropen_amount AS amount,\n (aropen_amount - aropen_paid) AS balance,\n CASE WHEN (aropen_doctype IN ('C', 'R')) THEN\n (currtobase(aropen_curr_id,(aropen_amount - aropen_paid),aropen_docdate) * -1.0)\n ELSE currtobase(aropen_curr_id,(aropen_amount - aropen_paid),aropen_docdate)\n END AS base_balance,\n currConcat(aropen_curr_id) AS currAbbr\n FROM aropen\n WHERE ( (aropen_cust_id=) \n \n AND (aropen_docdate BETWEEN AND )\n )\n\n UNION\n SELECT 1 AS type, -1 AS aropen_id, arapply_source_aropen_id AS applyid,\n aropen_docdate AS sortdate, (aropen_docnumber || aropen_doctype) AS sortnumber,\n CASE WHEN (arapply_source_doctype IN ('C','R')) THEN arapply_source_docnumber\n WHEN (arapply_source_doctype='K') THEN arapply_refnumber\n ELSE \n END AS docnumber,\n NULL AS open,\n CASE WHEN (arapply_source_doctype='C') THEN \n WHEN (arapply_source_doctype='R') THEN \n WHEN (arapply_fundstype='C') THEN \n WHEN (arapply_fundstype='T') THEN \n WHEN (arapply_fundstype='M') THEN \n WHEN (arapply_fundstype='V') THEN \n WHEN (arapply_fundstype='A') THEN \n WHEN (arapply_fundstype='D') THEN \n WHEN (arapply_fundstype='R') THEN \n WHEN (arapply_fundstype='K') THEN \n WHEN (arapply_fundstype='W') THEN \n WHEN (arapply_fundstype='O') THEN \n END AS documenttype,\n COALESCE(cashrcpt_docdate, arapply_postdate) AS docdate,\n arapply_distdate AS duedate,\n arapply_applied AS amount,\n 0 AS balance,\n 0 AS base_balance,\n currConcat(arapply_curr_id) AS currAbbr\n FROM arapply JOIN aropen ON (arapply_target_aropen_id=aropen_id)\n LEFT OUTER JOIN cashrcptitem ON ( (arapply_reftype='CR') AND\n (arapply_ref_id=cashrcptitem_id) )\n LEFT OUTER JOIN cashrcpt ON (cashrcpt_id=cashrcptitem_cashrcpt_id)\n WHERE ( (arapply_target_doctype IN ('I', 'D'))\n AND (arapply_cust_id=)\n AND (aropen_cust_id=)\n \n AND (aropen_docdate BETWEEN AND )\n )\n\n UNION\n SELECT 2 AS type, -1 AS aropen_id, arapply_target_aropen_id AS applyid,\n aropen_docdate AS sortdate, (aropen_docnumber || aropen_doctype) AS sortnumber,\n arapply_target_docnumber AS docnumber,\n NULL AS open,\n CASE WHEN (arapply_target_doctype='I') THEN \n WHEN (arapply_target_doctype='D') THEN \n ELSE \n END AS documenttype,\n arapply_postdate AS docdate,\n arapply_distdate AS duedate,\n arapply_applied AS amount,\n 0 AS balance,\n 0 AS base_balance,\n currConcat(arapply_curr_id) AS currAbbr\n FROM arapply, aropen\n WHERE ( (arapply_source_doctype IN ('K', 'C', 'R'))\n AND (arapply_source_aropen_id=aropen_id)\n AND (arapply_cust_id=)\n AND (aropen_cust_id=)\n \n AND (aropen_docdate BETWEEN AND )\n )\n\n UNION\n SELECT 0 AS type, -1 AS aropen_id, -1 AS applyid,\n invchead_invcdate AS sortdate, (invchead_invcnumber || 'I') AS sortnumber,\n invchead_invcnumber AS docnumber,\n false AS open,\n AS documenttype,\n invchead_invcdate AS docdate,\n invchead_invcdate AS duedate,\n 0 AS amount,\n 0 AS balance,\n 0 AS base_balance,\n currConcat(invchead_curr_id) AS currAbbr\n FROM invchead\n WHERE ( (invchead_cust_id=) \n \n AND (invchead_invcdate BETWEEN AND )\n \n AND (invchead_posted)\n AND ((SELECT SUM(invcitem_price)\n FROM invcitem\n WHERE (invcitem_invchead_id=invchead_id))=0) )\n ) AS data\n ORDER BY sortdate, sortnumber, type;\n admin 2015-10-01 0 40 arOpenApplications detail used by applyARCreditMemo, cashReceipt\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: arOpenApplications\n-- Name: detail\n-- Notes: used by applyARCreditMemo, cashReceipt\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n 'curr' AS balance_xtnumericrole,\n 'curr' AS applied_xtnumericrole,\n 'curr' AS pending_xtnumericrole,\n currConcat(balance_curr) AS balance_curr_qtdisplayrole,\n CASE WHEN (doctype='D') THEN \n WHEN (doctype='I') THEN \n WHEN (doctype='C') THEN \n WHEN (doctype='R') THEN \n END AS doctype_qtdisplayrole,\n CASE WHEN (doctype='C') THEN 'emphasis'\n WHEN (doctype='R') THEN 'altemphasis'\n END AS doctype_qtforegroundrole,\n\n CASE WHEN (pending - currtobase(cashrcpt_curr_id, applied, cashrcpt_distdate) - discount > balance) \n AND doctype IN ('I','D')\n AND NOT cashrcpt_posted\n\n CASE WHEN (pending - applied - discount > balance)\n \n THEN 'error' END AS qtforegroundrole\nFROM (SELECT\n aropen_id,\n\n COALESCE(s.cashrcptitem_id, -1) AS alt_id,\n COALESCE(cashrcpt_posted,FALSE) AS cashrcpt_posted,\n cashrcpt_curr_id,\n cashrcpt_distdate,\n\n aropen_doctype AS doctype,\n aropen_docnumber, aropen_ordernumber,\n aropen_docdate, aropen_duedate,\n (aropen_amount - aropen_paid - calcpendingarapplications(aropen_id)) *\n (CASE WHEN aropen_doctype IN ('C','R') THEN -1 ELSE 1 END ) AS balance,\n aropen_curr_id AS balance_curr,\n\n COALESCE(s.cashrcptitem_amount, 0.0) AS applied,\n COALESCE(s.cashrcptitem_discount, 0.0) AS discount,\n-- (SELECT COALESCE(SUM(p.cashrcptitem_amount), 0)\n-- FROM cashrcptitem p\n-- WHERE (p.cashrcptitem_aropen_id=aropen_id)\n-- AND (p.cashrcptitem_cashrcpt_id=))\n-- AS applied,\n-- (SELECT COALESCE(SUM(p.cashrcptitem_discount), 0)\n-- FROM cashrcptitem p\n-- WHERE (p.cashrcptitem_aropen_id=aropen_id)\n-- AND (p.cashrcptitem_cashrcpt_id=))\n-- AS discount,\n currConcat(cashrcpt_curr_id) AS applied_curr,\n\n COALESCE(arcreditapply_amount, 0) AS applied,\n 0 AS discount,\n currConcat(arcreditapply_curr_id) AS applied_curr,\n\n calcpendingarapplications(aropen_id) AS pending,\n currConcat(aropen_curr_id) AS pending_curr\n FROM aropen LEFT OUTER JOIN\n \n cashrcptitem s ON (s.cashrcptitem_aropen_id=aropen_id\n AND cashrcptitem_cashrcpt_id=)\n LEFT OUTER JOIN\n cashrcpt ON (cashrcptitem_cashrcpt_id = cashrcpt_id\n AND cashrcpt_id=)\n\n arcreditapply ON ((arcreditapply_source_aropen_id=)\n AND (arcreditapply_target_aropen_id=aropen_id) )\n\n WHERE (\n \n (s.cashrcptitem_aropen_id=aropen_id)\n\n (aropen_open)\n\n\n AND (aropen_doctype IN ('D', 'I'))\n\n\n AND (aropen_doctype IN ('D', 'I'))\n\n AND (aropen_cust_id=) )\n ) AS dummy\n ORDER BY aropen_duedate, balance;\n admin 2015-10-01 0 444 bankrec checks used by reconcileBankaccount\n Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: bankrec\n-- Name: checks\n-- Notes: used by reconcileBankaccount\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT COALESCE(SUM(amount),0.0) AS cleared_amount\n FROM ( SELECT COALESCE( bankrecitem_amount,\n currToLocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) ) AS amount\n FROM (bankaccnt CROSS JOIN gltrans)\n JOIN bankrecitem ON ((bankrecitem_source='GL')\n AND (bankrecitem_source_id=gltrans_id)\n AND (bankrecitem_bankrec_id=)\n AND (bankrecitem_cleared))\n WHERE ((gltrans_accnt_id=bankaccnt_accnt_id)\n AND (NOT gltrans_deleted)\n AND (NOT gltrans_rec)\n AND (gltrans_amount > 0)\n AND (gltrans_doctype != 'JP')\n AND (bankaccnt_id=) )\n UNION ALL\n SELECT COALESCE( bankrecitem_amount,\n currToLocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) ) AS amount\n FROM (bankaccnt CROSS JOIN sltrans)\n JOIN bankrecitem ON ((bankrecitem_source='SL')\n AND (bankrecitem_source_id=sltrans_id)\n AND (bankrecitem_bankrec_id=)\n AND (bankrecitem_cleared))\n WHERE ((sltrans_accnt_id=bankaccnt_accnt_id)\n AND (NOT sltrans_rec)\n AND (sltrans_amount > 0)\n AND (bankaccnt_id=) )\n UNION ALL\n SELECT CASE WHEN(bankadjtype_iscredit=false) THEN (bankadj_amount * -1) ELSE bankadj_amount END AS amount\n FROM bankadj, bankadjtype, bankrecitem\n WHERE ( (bankrecitem_source='AD')\n AND (bankrecitem_source_id=bankadj_id)\n AND (bankrecitem_bankrec_id=)\n AND (bankrecitem_cleared)\n AND (bankadj_bankadjtype_id=bankadjtype_id)\n AND (NOT bankadj_posted)\n AND (((bankadjtype_iscredit=true) AND (bankadj_amount > 0)) OR ((bankadjtype_iscredit=false) AND (bankadj_amount < 0)))\n AND (bankadj_bankaccnt_id=) ) ) AS data;\n\nSELECT gltrans_id AS id, 1 AS altid,\n COALESCE(bankrecitem_cleared, FALSE) AS cleared,\n COALESCE(bankrecitem_effdate, gltrans_date) AS transdate,\n gltrans_doctype AS doc_type,\n gltrans_docnumber AS doc_number,\n gltrans_notes AS notes,\n (SELECT currConcat(COALESCE(checkhead_curr_id, baseCurrId()))) AS doc_curr,\n CASE WHEN (fetchMetricValue('CurrencyExchangeSense') = 1) THEN\n ROUND(1.0 / COALESCE(bankrecitem_curr_rate, checkhead_curr_rate, currRate(bankaccnt_curr_id, gltrans_date)),6)\n ELSE\n ROUND(COALESCE(bankrecitem_curr_rate, checkhead_curr_rate, currRate(bankaccnt_curr_id, gltrans_date)),6)\n END AS doc_exchrate,\n gltrans_amount AS base_amount,\n CASE WHEN (bankaccnt_curr_id=checkhead_curr_id) THEN\n COALESCE( bankrecitem_amount,\n checkhead_amount,\n currToLocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) )\n ELSE\n COALESCE( bankrecitem_amount,\n currToLocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) )\n END AS amount,\n gltrans_date AS sortdate,\n '6' AS doc_exchrate_xtnumericrole,\n 'curr' AS base_amount_xtnumericrole,\n 'curr' AS amount_xtnumericrole\n FROM (bankaccnt CROSS JOIN gltrans)\n LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='GL')\n AND (bankrecitem_source_id=gltrans_id)\n AND (bankrecitem_bankrec_id=)\n AND (bankrecitem_cleared))\n LEFT OUTER JOIN checkhead ON ((gltrans_doctype='CK')\n AND (gltrans_misc_id=checkhead_id))\n WHERE ((gltrans_accnt_id=bankaccnt_accnt_id)\n AND (NOT gltrans_deleted)\n AND (NOT gltrans_rec)\n AND (NOT COALESCE(checkhead_void, false))\n AND (gltrans_amount > 0)\n AND (gltrans_doctype != 'JP')\n AND (bankaccnt_id=)\n\n AND ('GL' = )\n\n\n AND (gltrans_id = )\n\n )\n UNION ALL\nSELECT sltrans_id AS id, 2 AS altid,\n COALESCE(bankrecitem_cleared, FALSE) AS cleared,\n COALESCE(bankrecitem_effdate, sltrans_date) AS transdate,\n sltrans_doctype AS doc_type,\n sltrans_docnumber AS doc_number,\n sltrans_notes AS notes,\n (SELECT currConcat(COALESCE(checkhead_curr_id, baseCurrId()))) AS doc_curr,\n CASE WHEN (fetchMetricValue('CurrencyExchangeSense') = 1) THEN\n ROUND(1.0 / COALESCE(bankrecitem_curr_rate, checkhead_curr_rate, currRate(bankaccnt_curr_id, sltrans_date)),6)\n ELSE\n ROUND(COALESCE(bankrecitem_curr_rate, checkhead_curr_rate, currRate(bankaccnt_curr_id, sltrans_date)),6)\n END AS doc_exchrate,\n sltrans_amount AS base_amount,\n CASE WHEN (bankaccnt_curr_id=checkhead_curr_id) THEN\n COALESCE( bankrecitem_amount,\n checkhead_amount,\n currToLocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) )\n ELSE\n COALESCE( bankrecitem_amount,\n currToLocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) )\n END AS amount,\n sltrans_date AS sortdate,\n '6' AS doc_exchrate_xtnumericrole,\n 'curr' AS base_amount_xtnumericrole,\n 'curr' AS amount_xtnumericrole\n FROM (bankaccnt CROSS JOIN sltrans)\n LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='SL')\n AND (bankrecitem_source_id=sltrans_id)\n AND (bankrecitem_bankrec_id=)\n AND (bankrecitem_cleared))\n LEFT OUTER JOIN checkhead ON ((sltrans_doctype='CK')\n AND (sltrans_misc_id=checkhead_id))\n WHERE ((sltrans_accnt_id=bankaccnt_accnt_id)\n AND (NOT sltrans_rec)\n AND (NOT COALESCE(checkhead_void, false))\n AND (sltrans_amount > 0)\n AND (bankaccnt_id=)\n\n AND ('SL' = )\n\n\n AND (sltrans_id = )\n\n )\n UNION ALL\nSELECT bankadj_id AS id, 3 AS altid,\n COALESCE(bankrecitem_cleared, FALSE) AS cleared,\n COALESCE(bankrecitem_effdate, bankadj_date) AS transdate,\n 'ADJ' AS doc_type,\n bankadj_docnumber AS doc_number,\n bankadjtype_name AS notes,\n (SELECT currConcat(bankadj_curr_id)) AS doc_curr,\n 1.0 AS doc_exchrate,\n CASE WHEN(bankadjtype_iscredit=false) THEN (bankadj_amount * -1.0) ELSE bankadj_amount END AS base_amount,\n CASE WHEN(bankadjtype_iscredit=false) THEN (bankadj_amount * -1.0) ELSE bankadj_amount END AS amount,\n bankadj_date AS sortdate,\n '6' AS doc_exchrate_xtnumericrole,\n 'curr' AS base_amount_xtnumericrole,\n 'curr' AS amount_xtnumericrole\n FROM (bankadjtype CROSS JOIN bankadj)\n LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='AD')\n AND (bankrecitem_source_id=bankadj_id)\n AND (bankrecitem_bankrec_id=)\n AND (bankrecitem_cleared))\n WHERE ( (((bankadjtype_iscredit=true) AND (bankadj_amount > 0)) OR ((bankadjtype_iscredit=false) AND (bankadj_amount < 0)))\n AND (bankadj_bankadjtype_id=bankadjtype_id)\n AND (NOT bankadj_posted)\n AND (bankadj_bankaccnt_id=)\n\n AND ('AD' = )\n\n\n AND (bankadj_id = )\n\n )\nORDER BY sortdate;\n\n admin 2015-10-01 0 445 bankrec clearedbalance used by reconcileBankaccount\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: bankrec\n-- Name: clearedbalance\n-- Notes: used by reconcileBankaccount\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT (COALESCE(SUM(amount),0.0) + ) AS cleared_amount,\n AS end_amount,\n ( - ( + (COALESCE(SUM(amount),0.0)))) AS diff_amount,\n round( - ( + COALESCE(SUM(amount),0.0)), 2) AS diff_value\n FROM ( SELECT CASE WHEN (gltrans_amount > 0) THEN bankrecitem_amount * -1.0\n ELSE bankrecitem_amount END AS amount\n FROM bankaccnt, gltrans, bankrecitem\n WHERE ((gltrans_accnt_id=bankaccnt_accnt_id)\n AND (bankrecitem_source='GL')\n AND (bankrecitem_source_id=gltrans_id)\n AND (bankrecitem_bankrec_id=)\n AND (bankrecitem_cleared)\n AND (NOT gltrans_deleted)\n AND (NOT gltrans_rec)\n AND (bankaccnt_id=) ) \n UNION ALL\n SELECT CASE WHEN (sltrans_amount > 0) THEN bankrecitem_amount * -1.0\n ELSE bankrecitem_amount END AS amount\n FROM bankaccnt, sltrans, bankrecitem\n WHERE ((sltrans_accnt_id=bankaccnt_accnt_id)\n AND (bankrecitem_source='SL')\n AND (bankrecitem_source_id=sltrans_id)\n AND (bankrecitem_bankrec_id=)\n AND (bankrecitem_cleared)\n AND (NOT sltrans_rec)\n AND (bankaccnt_id=) )\n UNION ALL\n SELECT CASE WHEN(bankadjtype_iscredit=true) THEN (bankadj_amount * -1) ELSE bankadj_amount END AS amount\n FROM bankadj, bankadjtype, bankrecitem\n WHERE ( (bankrecitem_source='AD')\n AND (bankrecitem_source_id=bankadj_id)\n AND (bankrecitem_bankrec_id=)\n AND (bankrecitem_cleared)\n AND (bankadj_bankadjtype_id=bankadjtype_id)\n AND (NOT bankadj_posted)\n AND (bankadj_bankaccnt_id=) ) ) AS data;\n admin 2015-10-01 0 446 bankrec receipts used by reconcileBankaccount\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: bankrec\n-- Name: receipts\n-- Notes: used by reconcileBankaccount\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT COALESCE(SUM(amount),0.0) AS cleared_amount\n FROM ( SELECT COALESCE( bankrecitem_amount,\n (currToLocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) * -1.0) ) AS amount\n FROM (bankaccnt CROSS JOIN gltrans)\n JOIN bankrecitem ON ((bankrecitem_source='GL')\n AND (bankrecitem_source_id=gltrans_id)\n AND (bankrecitem_bankrec_id=)\n AND (bankrecitem_cleared))\n WHERE ((gltrans_accnt_id=bankaccnt_accnt_id)\n AND (NOT gltrans_deleted)\n AND (NOT gltrans_rec)\n AND (gltrans_amount < 0)\n AND (gltrans_doctype != 'JP')\n AND (bankaccnt_id=) )\n UNION ALL\n SELECT COALESCE( bankrecitem_amount,\n (currToLocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) * -1.0) ) AS amount\n FROM (bankaccnt CROSS JOIN sltrans)\n JOIN bankrecitem ON ((bankrecitem_source='SL')\n AND (bankrecitem_source_id=sltrans_id)\n AND (bankrecitem_bankrec_id=)\n AND (bankrecitem_cleared))\n WHERE ((sltrans_accnt_id=bankaccnt_accnt_id)\n AND (NOT sltrans_rec)\n AND (sltrans_amount < 0)\n AND (bankaccnt_id=) )\n UNION ALL\n SELECT CASE WHEN(bankadjtype_iscredit=true) THEN (bankadj_amount * -1) ELSE bankadj_amount END AS amount\n FROM bankrecitem, bankadj, bankadjtype\n WHERE ( (bankrecitem_source='AD')\n AND (bankrecitem_source_id=bankadj_id)\n AND (bankrecitem_bankrec_id=)\n AND (bankrecitem_cleared)\n AND (bankadj_bankadjtype_id=bankadjtype_id)\n AND (NOT bankadj_posted)\n AND (((bankadjtype_iscredit=false) AND (bankadj_amount > 0)) OR (bankadjtype_iscredit=true AND (bankadj_amount < 0)))\n AND (bankadj_bankaccnt_id=) ) ) AS data;\n\nSELECT gltrans_id AS id, 1 AS altid,\n jrnluse_use AS use, gltrans_journalnumber AS jrnlnum,\n COALESCE(date(jrnluse_date), gltrans_date) AS f_jrnldate,\n COALESCE(bankrecitem_cleared, FALSE) AS cleared,\n COALESCE(bankrecitem_effdate, gltrans_date) AS f_date,\n gltrans_doctype AS doc_type,\n gltrans_docnumber AS docnumber,\n gltrans_notes AS notes,\n currConcat(COALESCE(cashrcpt_curr_id, baseCurrId())) AS doc_curr,\n CASE WHEN (fetchMetricValue('CurrencyExchangeSense') = 1) THEN\n ROUND(1.0 / COALESCE(bankrecitem_curr_rate, cashrcpt_curr_rate, currRate(bankaccnt_curr_id, gltrans_date)),6)\n ELSE\n ROUND(COALESCE(bankrecitem_curr_rate, cashrcpt_curr_rate, currRate(bankaccnt_curr_id, gltrans_date)),6)\n END AS doc_exchrate,\n (gltrans_amount * -1.0) AS base_amount,\n CASE WHEN (bankaccnt_curr_id=cashrcpt_curr_id) THEN\n COALESCE( bankrecitem_amount,\n cashrcpt_amount,\n (currToLocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) * -1.0) )\n ELSE\n COALESCE( bankrecitem_amount,\n (currToLocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) * -1.0) )\n END AS amount,\n COALESCE(date(jrnluse_date), gltrans_date) AS jrnldate,\n gltrans_date AS sortdate,\n 'uomratio' AS doc_exchrate_xtnumericrole,\n 'curr' AS base_amount_xtnumericrole,\n 'curr' AS amount_xtnumericrole\n FROM bankaccnt\n JOIN gltrans ON (bankaccnt_accnt_id=gltrans_accnt_id)\n LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='GL')\n AND (bankrecitem_source_id=gltrans_id)\n AND (bankrecitem_bankrec_id=)\n AND (bankrecitem_cleared))\n LEFT OUTER JOIN jrnluse ON (jrnluse_number=gltrans_journalnumber AND jrnluse_use='C/R')\n LEFT OUTER JOIN cashrcpt ON ((gltrans_source='A/R')\n AND (gltrans_doctype='CR')\n AND (gltrans_misc_id=cashrcpt_id))\n LEFT OUTER JOIN checkhead ON ((gltrans_doctype='CK')\n AND (gltrans_misc_id=checkhead_id))\n WHERE ((NOT gltrans_deleted)\n AND (NOT gltrans_rec)\n AND (NOT COALESCE(checkhead_void, false))\n AND (gltrans_amount < 0)\n AND (gltrans_doctype != 'JP')\n AND (bankaccnt_id=)\n\n AND ('GL' = )\n\n\n AND (gltrans_id = )\n\n )\n UNION ALL\nSELECT sltrans_id AS id, 2 AS altid,\n jrnluse_use AS use, sltrans_journalnumber AS jrnlnum,\n COALESCE(date(jrnluse_date), sltrans_date) AS f_jrnldate,\n COALESCE(bankrecitem_cleared, FALSE) AS cleared,\n COALESCE(bankrecitem_effdate, sltrans_date) AS f_date,\n sltrans_doctype AS doc_type,\n sltrans_docnumber AS docnumber,\n sltrans_notes AS notes,\n currConcat(COALESCE(cashrcpt_curr_id, baseCurrId())) AS doc_curr,\n CASE WHEN (fetchMetricValue('CurrencyExchangeSense') = 1) THEN\n ROUND(1.0 / COALESCE(bankrecitem_curr_rate, cashrcpt_curr_rate, currRate(bankaccnt_curr_id, sltrans_date)),6)\n ELSE\n ROUND(COALESCE(bankrecitem_curr_rate, cashrcpt_curr_rate, currRate(bankaccnt_curr_id, sltrans_date)),6)\n END AS doc_exchrate,\n (sltrans_amount * -1.0) AS base_amount,\n CASE WHEN (bankaccnt_curr_id=cashrcpt_curr_id) THEN\n COALESCE( bankrecitem_amount,\n cashrcpt_amount,\n (currToLocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) * -1.0) )\n ELSE\n COALESCE( bankrecitem_amount,\n (currToLocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) * -1.0) )\n END AS amount,\n COALESCE(date(jrnluse_date), sltrans_date) AS jrnldate,\n sltrans_date AS sortdate,\n 'uomratio' AS doc_exchrate_xtnumericrole,\n 'curr' AS base_amount_xtnumericrole,\n 'curr' AS amount_xtnumericrole\n FROM bankaccnt\n JOIN sltrans ON (bankaccnt_accnt_id=sltrans_accnt_id)\n LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='SL')\n AND (bankrecitem_source_id=sltrans_id)\n AND (bankrecitem_bankrec_id=)\n AND (bankrecitem_cleared))\n LEFT OUTER JOIN jrnluse ON (jrnluse_number=sltrans_journalnumber AND jrnluse_use='C/R')\n LEFT OUTER JOIN cashrcpt ON ((sltrans_source='A/R')\n AND (sltrans_doctype='CR')\n AND (sltrans_misc_id=cashrcpt_id))\n LEFT OUTER JOIN checkhead ON ((sltrans_doctype='CK')\n AND (sltrans_misc_id=checkhead_id))\n WHERE ((NOT sltrans_rec)\n AND (NOT COALESCE(checkhead_void, false))\n AND (sltrans_amount < 0)\n AND (bankaccnt_id=)\n\n AND ('SL' = )\n\n\n AND (sltrans_id = )\n\n )\n UNION ALL\nSELECT bankadj_id AS id, 3 AS altid,\n '' AS use, NULL AS jrnlnum, bankadj_date AS f_jrnldate,\n COALESCE(bankrecitem_cleared, FALSE) AS cleared,\n COALESCE(bankrecitem_effdate, bankadj_date) AS f_date,\n 'ADJ' AS doc_type,\n bankadj_docnumber AS docnumber,\n bankadjtype_name AS notes,\n currConcat(bankadj_curr_id) AS doc_curr,\n 1.0 AS doc_exchrate,\n CASE WHEN(bankadjtype_iscredit=true) THEN (bankadj_amount * -1.0) ELSE bankadj_amount END AS base_amount,\n CASE WHEN(bankadjtype_iscredit=true) THEN (bankadj_amount * -1.0) ELSE bankadj_amount END AS amount,\n bankadj_date AS jrnldate,\n bankadj_date AS sortdate,\n 'uomratio' AS doc_exchrate_xtnumericrole,\n 'curr' AS base_amount_xtnumericrole,\n 'curr' AS amount_xtnumericrole\n FROM (bankadjtype CROSS JOIN bankadj)\n LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='AD')\n AND (bankrecitem_source_id=bankadj_id)\n AND (bankrecitem_bankrec_id=))\n WHERE ( (((bankadjtype_iscredit=false) AND (bankadj_amount > 0)) OR ((bankadjtype_iscredit=true) AND (bankadj_amount < 0)))\n AND (bankadj_bankadjtype_id=bankadjtype_id)\n AND (NOT bankadj_posted)\n AND (bankadj_bankaccnt_id=)\n\n AND ('AD' = )\n\n\n AND (bankadj_id = )\n\n )\nORDER BY jrnldate, jrnlnum, sortdate;\n\n admin 2015-10-01 0 105 bankrecHistory reconciled \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: bankrecHistory\n-- Name: reconciled\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT -1 AS gltrans_id, bankrec_opendate AS gltrans_date, formatDate(bankrec_opendate) AS f_date,\n AS gltrans_docnumber, AS type, 0 AS sort, NULL AS gltrans_notes, \n bankrec_openbal AS amount, formatMoney(bankrec_openbal) AS f_amount,\n 'curr' AS amount_xtnumericrole,\n 0 AS xtindentrole\n FROM bankrec\n WHERE (bankrec_id=)\n \nUNION\n\n\nSELECT gltrans_id, gltrans_date, formatDate(gltrans_date) AS f_date,\n gltrans_docnumber,\n CASE WHEN gltrans_doctype = 'CK' THEN \n WHEN gltrans_doctype = 'CR' THEN \n ELSE END AS type,\n CASE WHEN gltrans_doctype = 'CK' THEN 1\n WHEN gltrans_doctype = 'CR' THEN 2\n ELSE '3' END AS sort,\n gltrans_notes AS notes,\n COALESCE( bankrecitem_amount,\n (currtolocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) * -1.0) ) AS amount,\n formatMoney(COALESCE( bankrecitem_amount,\n (currtolocal(bankaccnt_curr_id, gltrans_amount, gltrans_date) * -1.0) ) ) AS f_amount,\n 'curr' AS amount_xtnumericrole,\n 1 AS xtindentrole\n FROM gltrans, bankrecitem \n JOIN bankrec ON (bankrecitem_bankrec_id=bankrec_id)\n JOIN bankaccnt ON (bankaccnt_id=bankrec_bankaccnt_id)\n WHERE ((bankrecitem_bankrec_id=)\n AND (bankrecitem_source='GL')\n AND (bankrecitem_source_id=gltrans_id)\n AND (NOT gltrans_deleted) ) \n\nUNION\n\nSELECT sltrans_id, sltrans_date, formatDate(sltrans_date) AS f_date,\n sltrans_docnumber,\n CASE WHEN sltrans_doctype = 'CK' THEN \n WHEN sltrans_doctype = 'CR' THEN \n ELSE END AS type,\n CASE WHEN sltrans_doctype = 'CK' THEN 1\n WHEN sltrans_doctype = 'CR' THEN 2\n ELSE '3' END AS sort,\n sltrans_notes AS notes,\n COALESCE( bankrecitem_amount,\n (currtolocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) * -1.0) ) AS amount,\n formatMoney(COALESCE( bankrecitem_amount,\n (currtolocal(bankaccnt_curr_id, sltrans_amount, sltrans_date) * -1.0) ) ) AS f_amount,\n 'curr' AS amount_xtnumericrole,\n 1 AS xtindentrole\n FROM sltrans, bankrecitem \n JOIN bankrec ON (bankrecitem_bankrec_id=bankrec_id)\n JOIN bankaccnt ON (bankaccnt_id=bankrec_bankaccnt_id)\n WHERE ((bankrecitem_bankrec_id=)\n AND (bankrecitem_source='SL')\n AND (bankrecitem_source_id=sltrans_id) ) \n\n\nUNION\n\nSELECT -1 AS gltrans_id, bankrec_enddate, formatDate(bankrec_enddate) AS f_date,\n , AS type, 7 AS sort, NULL, \n bankrec_endbal AS amount, formatMoney(bankrec_endbal) AS f_amount,\n 'curr' AS amount_xtnumericrole,\n 0 AS xtindentrole\n FROM bankrec\n WHERE (bankrec_id=)\n\nUNION\nSELECT -1, NULL, NULL, , NULL, 1, NULL, NULL, NULL, 'curr', 0 \nUNION\nSELECT -1, NULL, NULL, , NULL, 2, NULL, NULL, NULL, 'curr', 0 \nUNION\nSELECT -1, NULL, NULL, , NULL, 3, NULL, NULL, NULL, 'curr', 0 \n\n\nORDER BY sort, xtindentrole, type, f_date, gltrans_id\n admin 2015-10-01 0 106 bankrecHistory unreconciled \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: bankrecHistory\n-- Name: unreconciled\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT gltrans_id, gltrans_date, formatDate(gltrans_date) AS f_date,\n gltrans_docnumber,\n CASE WHEN gltrans_doctype = 'CK' THEN \n WHEN gltrans_doctype = 'CR' THEN \n ELSE END AS type,\n CASE WHEN gltrans_doctype = 'CK' THEN 1\n WHEN gltrans_doctype = 'CR' THEN 2\n ELSE '3' END AS sort,\n gltrans_notes AS notes,\n currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date) * -1 AS amount,\n formatMoney(currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date) * -1) AS f_amount,\n CASE WHEN gltrans_doctype = 'CK' THEN \n currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date) * -1\n ELSE 0 END AS rtcheck,\n CASE WHEN gltrans_doctype = 'CR' THEN \n currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date) * -1\n ELSE 0 END AS rtdep,\n CASE WHEN gltrans_doctype NOT IN ('CK','CR') THEN \n currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date) * -1\n ELSE 0 END AS rtadj,\n 'curr' AS amount_xtnumericrole,\n 1 AS xtindentrole\n FROM gltrans\n JOIN bankaccnt ON (bankaccnt_accnt_id = gltrans_accnt_id)\n JOIN bankrec selrec ON ((selrec.bankrec_bankaccnt_id = bankaccnt_id)\n AND (selrec.bankrec_id=))\n LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='GL')\n\n AND (bankrecitem_source_id=gltrans_id))\n LEFT OUTER JOIN bankrec actrec ON (actrec.bankrec_id = bankrecitem_bankrec_id)\n LEFT OUTER JOIN checkhead ON ((gltrans_doctype='CK')\n AND (gltrans_misc_id=checkhead_id))\n\n WHERE ((COALESCE(actrec.bankrec_postdate,endoftime()) > COALESCE(selrec.bankrec_postdate,now()))\n AND (NOT gltrans_deleted)\n AND (NOT COALESCE(checkhead_void, false)))\n AND (gltrans_doctype != 'JP')\n\n WHERE (false)\n\n\nUNION\n\nSELECT sltrans_id, sltrans_date, formatDate(sltrans_date) AS f_date,\n sltrans_docnumber,\n CASE WHEN sltrans_doctype = 'CK' THEN \n WHEN sltrans_doctype = 'CR' THEN \n ELSE END AS type,\n CASE WHEN sltrans_doctype = 'CK' THEN 1\n WHEN sltrans_doctype = 'CR' THEN 2\n ELSE '3' END AS sort,\n sltrans_notes AS notes,\n currtolocal(bankaccnt_curr_id,sltrans_amount,sltrans_date) * -1 AS amount,\n formatMoney(currtolocal(bankaccnt_curr_id,sltrans_amount,sltrans_date) * -1) AS f_amount,\n CASE WHEN sltrans_doctype = 'CK' THEN \n currtolocal(bankaccnt_curr_id,sltrans_amount,sltrans_date) * -1\n ELSE 0 END AS rtcheck,\n CASE WHEN sltrans_doctype = 'CR' THEN \n currtolocal(bankaccnt_curr_id,sltrans_amount,sltrans_date) * -1\n ELSE 0 END AS rtdep,\n CASE WHEN sltrans_doctype NOT IN ('CK','CR') THEN \n currtolocal(bankaccnt_curr_id,sltrans_amount,sltrans_date) * -1\n ELSE 0 END AS rtadj,\n 'curr' AS amount_xtnumericrole,\n 1 AS xtindentrole\n FROM sltrans\n JOIN bankaccnt ON (bankaccnt_accnt_id = sltrans_accnt_id)\n JOIN bankrec selrec ON ((selrec.bankrec_bankaccnt_id = bankaccnt_id)\n AND (selrec.bankrec_id=))\n LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='SL')\n\n AND (bankrecitem_source_id=sltrans_id))\n LEFT OUTER JOIN bankrec actrec ON (actrec.bankrec_id = bankrecitem_bankrec_id)\n LEFT OUTER JOIN checkhead ON ((sltrans_doctype='CK')\n AND (sltrans_misc_id=checkhead_id))\n\n WHERE ((COALESCE(actrec.bankrec_postdate,endoftime()) > COALESCE(selrec.bankrec_postdate,now()))\n AND (NOT COALESCE(checkhead_void, false)))\n\nUNION\nSELECT -1, NULL, NULL, , NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL,'curr', 0 \nUNION\nSELECT -1, NULL, NULL, , NULL, 2, NULL, NULL, NULL, NULL, NULL, NULL, 'curr', 0 \nUNION\nSELECT -1, NULL, NULL, , NULL, 3, NULL, NULL, NULL, NULL, NULL, NULL, 'curr', 0\n\n\nORDER BY sort, xtindentrole, type, f_date, gltrans_id\n\n WHERE (false)\n\n admin 2015-10-01 0 232 billingSelections detail used by dspBillingSelections\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: billingSelections\n-- Name: detail\n-- Notes: used by dspBillingSelections\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cobmisc_id, cohead_id,\n cohead_number, cust_number, cust_name,\n sum(round(coitem_price*cobill_qty,2)) AS subtotal,\n cobmisc_misc, cobmisc_freight, calcCobmiscTax(cobmisc_id) AS cobmisc_tax, cobmisc_payment,\n (sum(round(coitem_price * cobill_qty, 2)) +\n cobmisc_misc + cobmisc_freight +\n calcCobmiscTax(cobmisc_id)) AS total,\n 'curr' AS subtotal_xtnumericrole,\n 'curr' AS total_xtnumericrole,\n 'curr' AS cobmisc_misc_xtnumericrole,\n 'curr' AS cobmisc_freight_xtnumericrole,\n 'curr' AS cobmisc_tax_xtnumericrole,\n 'curr' AS cobmisc_payment_xtnumericrole\nFROM cobmisc, cohead, custinfo, coitem, cobill\nWHERE ((cobmisc_cohead_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n AND (coitem_cohead_id=cohead_id)\n AND (cobill_coitem_id=coitem_id) AND (COALESCE(cobill_invcnum,0) = 0)\n AND (NOT cobmisc_posted))\nGROUP BY cobmisc_id, cohead_id, cohead_number, cust_number,\n cust_name, cobmisc_misc, cobmisc_freight, cobmisc_tax, cobmisc_payment\nORDER BY cohead_number;\n admin 2015-10-01 0 233 bom detail used by dspIndentedBOM, dspSingleLevelBOM, dspSummarizedBOM\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: bom\n-- Name: detail\n-- Notes: used by dspIndentedBOM, dspSingleLevelBOM, dspSummarizedBOM\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n bomitem_item_id AS itemid, bomitem.*, item_number,\n invuom.uom_name AS invuomname, issueuom.uom_name AS issueuomname,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS invqtyfxd,\n (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS invqtyper,\n 'qty' AS bomitem_qtyfxd_xtnumericrole,\n 'qty' AS invqtyfxd_xtnumericrole,\n 'qtyper' AS bomitem_qtyper_xtnumericrole,\n 'qtyper' AS invqtyper_xtnumericrole,\n 'percent' AS bomitem_scrap_xtnumericrole,\n CASE WHEN COALESCE(bomitem_effective, startOfTime()) = startOfTime() \n THEN \n END AS bomitem_effective_qtdisplayrole,\n CASE WHEN COALESCE(bomitem_expires, endOfTime()) = endOfTime() \n THEN \n END AS bomitem_expires_qtdisplayrole,\n CASE WHEN (bomitem_expires < CURRENT_DATE) THEN 'expired'\n WHEN (bomitem_effective >= CURRENT_DATE) THEN 'future'\n WHEN (item_type='M') THEN 'altemphasis'\n END AS qtforegroundrole\n \n \n item_id AS itemid,\n \n bomdata_item_id AS itemid,\n \n *,'percent' AS bomdata_scrap_xtnumericrole,\n 'qtyper' AS bomdata_qtyreq_xtnumericrole,\n CASE WHEN COALESCE(bomdata_effective, startOfTime()) <=\n startOfTime() THEN \n END AS bomdata_effective_qtdisplayrole,\n CASE WHEN COALESCE(bomdata_expires, endOfTime()) >=\n endOfTime() THEN \n END AS bomdata_expires_qtdisplayrole,\n CASE WHEN (bomdata_expired) THEN 'expired'\n WHEN (bomdata_future) THEN 'future'\n END AS qtforegroundrole\n \n , bomdata_bomwork_level - 1 AS xtindentrole\n \n \nFROM \n bomitem(,),\n item, uom AS issueuom, uom AS invuom\n \n indentedBOM(,\n ,\n ,\n )\n \n summarizedBOM(,\n ,\n ,\n )\n JOIN item ON (bomdata_item_number=item_number)\n \nWHERE ((TRUE)\n\n AND (bomdata_item_id > 0)\n\n AND (bomitem_item_id=item_id)\n AND (item_inv_uom_id=invuom.uom_id)\n AND (bomitem_uom_id=issueuom.uom_id)\n \n AND (bomitem_expires > (CURRENT_DATE - ))\n \n AND (bomitem_expires > CURRENT_DATE)\n \n \n AND (bomitem_effective <= (CURRENT_DATE + ))\n \n AND (bomitem_effective <= CURRENT_DATE)\n \n\n )\n\n ORDER BY bomitem_seqnumber, bomitem_effective\n\n;\n admin 2015-10-01 0 117 bomItems detail used by bom, booItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: bomItems\n-- Name: detail\n-- Notes: used by bom, booItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT bomitem_id, item_id, *,\n (item_descrip1 || ' ' || item_descrip2) AS item_description,\n CASE WHEN (item_type='P') THEN text()\n WHEN (item_type='M') THEN text()\n WHEN (item_type='J') THEN text()\n WHEN (item_type='F') THEN text()\n WHEN (item_type='B') THEN text()\n WHEN (item_type='C') THEN text()\n WHEN (item_type='Y') THEN text()\n WHEN (item_type='R') THEN text()\n WHEN (item_type='S') THEN text()\n WHEN (item_type='T') THEN text()\n WHEN (item_type='A') THEN text()\n WHEN (item_type='O') THEN text()\n WHEN (item_type='L') THEN text()\n WHEN (item_type='K') THEN text()\n ELSE text()\n END AS itemtype,\n uom_name AS issueuom,\n CASE WHEN (bomitem_issuemethod = 'S') THEN \n WHEN (bomitem_issuemethod = 'L') THEN \n WHEN (bomitem_issuemethod = 'M') THEN \n ELSE \n END AS issuemethod,\n 'qty' AS bomitem_qtyfxd_xtnumericrole,\n 'qtyper' AS bomitem_qtyper_xtnumericrole,\n 'percent' AS bomitem_scrap_xtnumericrole,\n CASE WHEN (bomitem_effective = startOfTime()) THEN NULL\n ELSE bomitem_effective END AS effective,\n CASE WHEN (bomitem_expires = endOfTime()) THEN NULL\n ELSE bomitem_expires END AS expires,\n AS effective_xtnullrole,\n AS expires_xtnullrole,\n CASE WHEN (bomitem_expires <= CURRENT_DATE) THEN 'expired'\n WHEN (bomitem_effective > CURRENT_DATE) THEN 'future'\n WHEN (item_type='M') THEN 'altemphasis'\n END AS qtforegroundrole\n\nFROM bomitem(, ), item, uom, xtmfg.booitem\n\nFROM bomitem(, ), item, uom\n\nWHERE ((bomitem_item_id=item_id)\n AND (bomitem_uom_id=uom_id)\n\n AND (bomitem_expires > CURRENT_DATE)\n\n\n AND (bomitem_effective <= CURRENT_DATE)\n\n\n AND (booitem_id = )\n AND (bomitem_booitem_seq_id = booitem_seq_id)\n\n )\nORDER BY bomitem_seqnumber, bomitem_effective;\n admin 2015-10-01 0 417 bookings detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: bookings\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT coitem_id AS id, coitem_cohead_id AS altId,\n formatSoLineNumber(coitem_id) AS f_linenumber,\n getSoSchedDate(cohead_id) AS sort_scheddate,\n coitem.*, cohead.*,\n cust_number, cust_name,\n item_number, item_descrip1, (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n uom_name,\n warehous_code,\n qtyAtShipping(coitem_id) AS qtyatshipping,\n-- TODO - not needed, remove? (very slow)\n-- qtyAvailable(itemsite_id, coitem_scheddate) AS qtyavailable,\n-- (qtyAvailable(itemsite_id, coitem_scheddate) < 0.0) AS stockout,\n-- CASE WHEN (itemsite_useparams) THEN (qtyAvailable(itemsite_id, coitem_scheddate) <= itemsite_reorderlevel)\n-- ELSE (qtyAvailable(itemsite_id, coitem_scheddate) <= 0.0)\n-- END AS reorder,\n noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS qtybalance,\n currtobase(cohead_curr_id, coitem_price, cohead_orderdate) AS baseunitprice,\n round((coitem_qtyord * coitem_qty_invuomratio) *\n (coitem_price / coitem_price_invuomratio), 2) AS extprice,\n round((coitem_qtyord * coitem_qty_invuomratio) *\n (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS baseextprice,\n round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n (coitem_price / coitem_price_invuomratio), 2) AS extpricebalance,\n round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS baseextpricebalance,\n round((coitem_qtyord * coitem_qty_invuomratio) *\n (coitem_unitcost / coitem_price_invuomratio), 2) AS extcost,\n CASE WHEN (coitem_price = 0.0) THEN 0.0\n ELSE ROUND(coitem_qtyord * coitem_qty_invuomratio * (coitem_price - coitem_unitcost) / coitem_price_invuomratio,2)\n END AS margin,\n CASE WHEN (coitem_price = 0.0) THEN 0.0\n ELSE ((coitem_price - coitem_unitcost) / coitem_price)\n END AS marginpercent,\n curr_abbr AS currAbbr,\n\n charass_alias.charass_value AS char,\n\n\n charass_alias.charass_value AS char,\n\n\n charass_alias.charass_value::date AS char,\n\n-- TODO - not needed, remove? (very slow)\n-- CASE WHEN (qtyAvailable(itemsite_id, coitem_scheddate) < 0.0) THEN 'error'\n-- WHEN itemsite_useparams AND (qtyAvailable(itemsite_id, coitem_scheddate) <= itemsite_reorderlevel) THEN 'warning'\n-- WHEN NOT itemsite_useparams AND (qtyAvailable(itemsite_id, coitem_scheddate) <= 0.0) THEN 'warning'\n-- END AS qtyavailable_qtforegroundrole,\n 'qty' AS coitem_qtyord_xtnumericrole,\n 'qty' AS coitem_qtyshipped_xtnumericrole,\n 'qty' AS coitem_qtyreturned_xtnumericrole,\n 'qty' AS qtyatshipping_xtnumericrole,\n 'qty' AS qtybalance_xtnumericrole,\n 'qty' AS qtyavailable_xtnumericrole,\n 'salesprice' AS coitem_price_xtnumericrole,\n 'salesprice' AS baseunitprice_xtnumericrole,\n 'cost' AS coitem_unitcost_xtnumericrole,\n 'curr' AS extprice_xtnumericrole,\n 'curr' AS extcost_xtnumericrole,\n 'curr' AS margin_xtnumericrole,\n 'percent' AS marginpercent_xtnumericrole,\n 'curr' AS baseextprice_xtnumericrole,\n 'curr' AS extpricebalance_xtnumericrole,\n 'curr' AS baseextpricebalance_xtnumericrole,\n 0 AS coitem_qtyord_xttotalrole,\n 0 AS coitem_qtyshipped_xttotalrole,\n 0 AS coitem_qtyreturned_xttotalrole,\n 0 AS qtybalance_xttotalrole,\n 0 AS baseextprice_xttotalrole,\n 0 AS baseextpricebalance_xttotalrole\n FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)\n JOIN custinfo ON (cust_id=cohead_cust_id)\n JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n JOIN site() ON (warehous_id=itemsite_warehous_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN uom ON (uom_id=coitem_qty_uom_id)\n JOIN curr_symbol ON (curr_id=cohead_curr_id)\n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='SO') \n AND (charass_alias.charass_target_id=cohead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='SO') \n AND (charass_alias.charass_target_id=cohead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='SO') \n AND (charass_alias.charass_target_id=cohead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\n WHERE ( (coitem_status<>'X')\n \n AND (coitem_cohead_id=)\n \n \n AND (coitem_status<>'C')\n \n \n AND (cohead_orderdate BETWEEN AND )\n \n\n \n AND (cohead_salesrep_id=)\n \n \n AND (cohead_shipto_id=)\n \n \n AND (cohead_cust_id=)\n \n AND (cust_custtype_id=)\n \n AND (cust_custtype_id IN (SELECT DISTINCT custtype_id\n FROM custtype\n WHERE (custtype_code ~ )))\n \n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrpitem))\n \n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrpitem\n WHERE (custgrpitem_custgrp_id=)))\n \n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrp, custgrpitem\n WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n AND (custgrp_name ~ ) )) )\n \n\n \n AND (itemsite_item_id=)\n \n AND (item_prodcat_id=)\n \n AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n FROM prodcat\n WHERE (prodcat_code ~ )))\n \n\n \n AND (itemsite_warehous_id=)\n \n \n )\n\n\n ORDER BY sort_scheddate, cohead_number, coitem_linenumber, coitem_subnumber\n\n ORDER BY cohead_orderdate, cohead_number, coitem_linenumber, coitem_subnumber\n\n ORDER BY cohead_number, coitem_linenumber, coitem_subnumber\n\n;\n admin 2015-10-01 0 234 briefEarnedCommission detail used by dspBriefEarnedCommissions\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: briefEarnedCommission\n-- Name: detail\n-- Notes: used by dspBriefEarnedCommissions\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cohist_salesrep_id, salesrep_number, salesrep_name, cust_number, cust_name,\n cohist_ordernumber, cohist_orderdate, cohist_invcnumber, cohist_invcdate, currAbbr,\n SUM(extprice) AS sumextprice,\n SUM(cohist_commission) AS sumcommission,\n SUM(baseextprice) AS sumbaseextprice,\n SUM(basecommission) AS sumbasecommission,\n\n formatDate(cohist_orderdate) AS f_orderdate,\n formatDate(cohist_invcdate) AS f_invcdate,\n formatMoney(SUM(extprice)) AS f_sumextprice,\n formatMoney(SUM(baseextprice)) AS f_sumbaseextprice,\n formatMoney(SUM(cohist_commission)) AS f_sumcommission,\n formatMoney(SUM(basecommission)) AS f_sumbasecommission,\n\n AS cohist_invcdate_xtnullrole,\n 'curr' AS sumextprice_xtnumericrole,\n 'curr' AS sumcommission_xtnumericrole,\n 'curr' AS sumbaseextprice_xtnumericrole,\n 'curr' AS sumbasecommission_xtnumericrole,\n 0 AS sumbaseextprice_xttotalrole,\n 0 AS sumbasecommission_xttotalrole\n\nFROM saleshistorymisc\n\nFROM saleshistory\n\nWHERE ((cohist_commission <> 0)\n AND(cohist_invcdate BETWEEN AND )\n \n AND (cohist_salesrep_id=)\n \n )\nGROUP BY cohist_salesrep_id, salesrep_number, salesrep_name, cust_number, cust_name,\n cohist_ordernumber, cohist_orderdate, cohist_invcnumber, cohist_invcdate, currAbbr\nORDER BY salesrep_number, cust_number, cohist_invcdate;\n admin 2015-10-01 0 235 briefSalesHistory detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: briefSalesHistory\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cohead_id, cust_id, cohist_ponumber,\n custtype_id, custtype_code,\n cohist_cust_id, cohist_ordernumber,\n cust_number, cust_name, currAbbr,\n cohist_orderdate, cohist_invcdate,\n CASE WHEN (COALESCE(cohist_invcnumber, '-1') IN ('', '-1')) THEN \n ELSE cohist_invcnumber\n END AS invoicenumber,\n SUM(extprice) AS extprice,\n SUM(baseextprice) AS baseextprice,\n SUM(extcost) AS extcost,\n SUM(margin) AS margin,\n CASE WHEN (SUM(baseextprice) > 0.0) THEN\n ROUND(SUM(margin) / SUM(baseextprice), 4)\n ELSE 0.0\n END AS marginpercent,\n\n formatDate(cohist_orderdate) AS f_orderdate,\n formatDate(cohist_invcdate) AS f_invcdate,\n formatMoney(SUM(extprice)) AS f_extprice,\n formatMoney(SUM(baseextprice)) AS f_baseextprice,\n formatMoney(SUM(extcost)) AS f_extcost,\n formatMoney(SUM(margin)) AS f_margin,\n formatPrcnt(CASE WHEN (SUM(baseextprice) > 0.0) THEN\n ROUND(SUM(margin) / SUM(baseextprice), 4)\n ELSE 0.0\n END) AS f_marginpercent,\n\n AS cohist_invcdate_xtnullrole,\n 'curr' AS extprice_xtnumericrole,\n 'curr' AS baseextprice_xtnumericrole,\n 'curr' AS extcost_xtnumericrole,\n 'curr' AS margin_xtnumericrole,\n 'percent' AS marginpercent_xtnumericrole,\n 0 AS baseextprice_xttotalrole,\n 0 AS extcost_xttotalrole,\n 0 AS margin_xttotalrole\n\n FROM saleshistorymisc\n\n FROM saleshistory\n\nWHERE ( (true)\n\n AND (cohist_invcdate >= )\n\n\n AND (cohist_invcdate <= )\n\n\n AND (cohist_shipdate >= )\n\n\n AND (cohist_shipdate <= )\n\n\n AND (cohist_cust_id=)\n\n\n AND (cohist_shipto_id=)\n\n\n AND (custtype_id=)\n\n\n AND (custtype_code ~ )\n\n\n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrpitem\n WHERE (custgrpitem_custgrp_id=)))\n\n\n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrp, custgrpitem\n WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n AND (custgrp_name ~ ) )) )\n\n\n AND (warehous_id=)\n\n\n AND (item_id=)\n\n\n AND (prodcat_id=)\n\n\n AND (prodcat_id IN (SELECT prodcat_id\n FROM prodcat\n WHERE (prodcat_code ~ )))\n\n\n AND (cohist_salesrep_id=)\n\n\n AND (cohist_shipzone_id=)\n\n\n AND (cohist_saletype_id=)\n\n )\nGROUP BY cohead_id, cust_id, cust_number, custtype_id,\n cohist_cust_id, custtype_code, currAbbr,\n cust_name, cohist_ordernumber, cohist_ponumber,\n cohist_invcnumber, cohist_orderdate, cohist_invcdate\nORDER BY cohist_invcdate, cohist_orderdate;\n admin 2015-10-01 0 44 capacityUOMs detail used by dspCapacityUOMsByClassCode, dspCapacityUOMsByProductCategory\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: capacityUOMs\n-- Name: detail\n-- Notes: used by dspCapacityUOMsByClassCode, dspCapacityUOMsByProductCategory\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT item_id, item_number,\n\n classcode_code,\n\n (item_descrip1 || ' ' || item_descrip2) AS descrip,\n uom_name,\n itemcapuom(item_id) AS capuom,\n itemcapinvrat(item_id) AS capinvrat,\n itemaltcapuom(item_id) AS altcapuom,\n itemaltcapinvrat(item_id) AS altcapinvrat,\n 'uomratio' AS capinvrat_xtnumericrole,\n 'uomratio' AS altcapinvrat_xtnumericrole\nFROM item\n JOIN uom ON (item_inv_uom_id=uom_id)\n\n LEFT OUTER JOIN classcode ON (item_classcode_id=classcode_id)\n\nWHERE (\n true item_sold \n\n AND (item_prodcat_id=)\n\n AND (item_prodcat_id IN (SELECT prodcat_id\n FROM prodcat\n WHERE (prodcat_code ~ )))\n\n AND (classcode_id=)\n\n AND (classcode_code ~ )\n\n)\nORDER BY classcode_code, \n item_number;\n admin 2015-10-01 0 96 ccpayments list list credit card payments, optionally by customer\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: ccpayments\n-- Name: list\n-- Notes: list credit card payments, optionally by customer\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT ccpay_id AS id, \n CASE WHEN ((ccpay_status = 'A') AND \n (date_part('day', CURRENT_TIMESTAMP - ccpay_transaction_datetime) < COALESCE(,0))) THEN\n 1\n ELSE 0\n END AS altid, cohead_id,\n ccpay.*,\n cust_number, cust_name, \n ccpay_type AS type, \n CASE WHEN (ccpay_type='A') THEN \n WHEN (ccpay_type='C') THEN \n WHEN (ccpay_type='R') THEN \n ELSE ccpay_type\n END AS type_qtdisplayrole,\n ccpay_status AS status,\n CASE WHEN (ccpay_status='A') THEN \n WHEN (ccpay_status='C') THEN \n WHEN (ccpay_status='D') THEN \n WHEN (ccpay_status='V') THEN \n WHEN (ccpay_status='X') THEN \n ELSE ccpay_status\n END AS status_qtdisplayrole,\n currConcat(ccpay_curr_id) AS currAbbr,\n COALESCE(cohead_number, ccpay_order_number) AS docnumber,\n ABS(COALESCE(payco_amount, ccpay_amount)) AS allocated,\n currConcat(COALESCE(payco_curr_id, ccpay_curr_id)) AS payco_currAbbr,\n cust_number, cust_name,\n 'curr' AS ccpay_amount_xtnumericrole,\n 'curr' AS allocated_xtnumericrole,\n CASE WHEN ((ccpay_status = 'A')\n AND (date_part('day', CURRENT_TIMESTAMP - ccpay_transaction_datetime) >= COALESCE(,0))) THEN\n 'error'\n END AS qtforegroundrole\n FROM ccpay LEFT OUTER JOIN \n (payco JOIN cohead ON (payco_cohead_id=cohead_id))\n ON (payco_ccpay_id=ccpay_id)\n JOIN custinfo ON (ccpay_cust_id=cust_id)\n JOIN custtype ON (cust_custtype_id=custtype_id)\n LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n WHERE ((true)\n\n AND (ccpay_status != 'A')\n\n AND (ccpay_status = 'A')\n\n\n AND ((ccpay_status != 'A')\n OR (date_part('day', CURRENT_TIMESTAMP - ccpay_transaction_datetime) < ))\n\n\n AND (ccpay_cust_id=)\n\n\n AND (custtype_id=)\n\n\n AND (custtype_code~)\n\n\n AND (custgrpitem_custgrp_id=)\n)\n ORDER BY ccpay_transaction_datetime;\n admin 2015-10-01 0 456 charass populate Populate characteristic assignments combobox\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: charass\n-- Name: populate\n-- Notes: Populate characteristic assignments combobox\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT -1 AS charass_char_id, '' AS char_name\nUNION\nSELECT DISTINCT charass_char_id, char_name\n\nSELECT -1 AS charass_id, '' AS charass_value\nUNION\nSELECT DISTINCT charass_id, charass_value\n\nFROM charass, char\nWHERE ((charass_char_id=char_id)\n AND (charass_target_type=)\n AND (charass_target_id= ))\n\n AND (charass_char_id= )\n AND (COALESCE(charass_value,'')!='')\n\n\nORDER BY char_name;\n\nORDER BY charass_value;\n\n admin 2015-10-01 0 46 checkRegister detail used by dspCheckRegister and viewCheckRun;\n shows all the checks for a given date range, bank account, \n check number(optional), and recipient(optional), optionally restricted\n to 'new' (un-posted/replaced/deleted) checks for viewing check runs.\n fills in the check item detail if showDetail is passed.\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: checkRegister\n-- Name: detail\n-- Notes: used by dspCheckRegister and viewCheckRun;\n-- shows all the checks for a given date range, bank account, \n-- check number(optional), and recipient(optional), optionally restricted\n-- to 'new' (un-posted/replaced/deleted) checks for viewing check runs.\n-- fills in the check item detail if showDetail is passed.\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT checkhead_id AS checkid,\n CASE WHEN(checkhead_void) THEN -1\n WHEN(checkhead_posted) THEN 1\n ELSE 0\n END AS extra,\n -1 AS checkitem_id,\n checkhead_void, checkhead_misc,\n checkhead_printed, checkhead_posted,\n CASE when checkhead_number = -1 THEN\n 'Unspecified'\n ELSE TEXT(checkhead_number) END AS number,\n COALESCE((SELECT checkrecip_number || '-' || checkrecip_name\n FROM checkrecip\n WHERE ((checkhead_recip_id=checkrecip_id)\n\t\t AND (checkhead_recip_type=checkrecip_type)))\n ,\n\t\tcheckhead_recip_type || '-' || checkhead_recip_id ) AS description,\n checkhead_checkdate AS checkdate,\n checkhead_amount AS amount, \n checkhead_amount / checkhead_curr_rate AS base_amount, \n currConcat(checkhead_curr_id) AS currAbbr,\n checkhead_number,\n checkhead_ach_batch,\n 1 AS orderby,\n 'curr' AS amount_xtnumericrole,\n 'curr' AS base_amount_xtnumericrole,\n NULL AS checkhead_void_qtdisplayrole, NULL AS checkhead_misc_qtdisplayrole,\n NULL AS checkhead_printed_qtdisplayrole, NULL AS checkhead_posted_qtdisplayrole,\n 0 AS xtindentrole\n FROM checkhead\n WHERE ((checkhead_bankaccnt_id=)\n \n AND (checkhead_checkdate BETWEEN AND )\n \n AND (NOT checkhead_posted)\n AND (NOT checkhead_replaced)\n AND (NOT checkhead_deleted)\n \n \n AND (CAST(checkhead_number AS text) ~ )\n \n \n \n AND (checkhead_recip_type = 'V' )\n \n \n AND (checkhead_recip_type = 'C' )\n \n \n AND (checkhead_recip_type = 'T' )\n \n \n AND (checkhead_recip_id = )\n \n \n \n AND (checkhead_recip_type = 'V')\n AND (checkhead_recip_id = )\n \n AND (checkhead_recip_type = 'V')\n AND (checkhead_recip_id IN (SELECT vend_id\n FROM vendinfo\n WHERE (vend_vendtype_id=)))\n \n AND (checkhead_recip_type = 'V')\n AND (checkhead_recip_id IN (SELECT vend_id\n FROM vendinfo, vendtype\n WHERE (vend_vendtype_id=vendtype_id)\n AND (vendtype_code ~ )))\n \n)\n\nUNION\nSELECT checkitem_checkhead_id AS checkid, 0 AS extra, checkitem_id,\n checkhead_void, checkhead_misc,\n checkhead_printed, checkhead_posted,\n (CASE apopen_doctype WHEN 'V' THEN \n WHEN 'D' THEN \n WHEN 'C' THEN \n ELSE ''\n END || '-' || CAST(COALESCE(checkitem_ranumber, checkitem_vouchernumber) AS TEXT)) AS number,\n CAST(COALESCE(checkitem_invcnumber, checkitem_cmnumber) AS TEXT) AS description,\n CAST(NULL AS DATE) AS checkdate,\n checkitem_amount AS amount,\n currtobase(checkhead_curr_id,checkitem_amount,checkhead_checkdate) AS base_amount, \n currConcat(checkitem_curr_id) AS currAbbr, \n checkhead_number, \n NULL AS checkhead_ach_batch,\n 2 AS orderby,\n 'curr' AS amount_xtnumericrole,\n 'curr' AS base_amount_xtnumericrole,\n '' AS checkhead_void_qtdisplayrole, '' AS checkhead_misc_qtdisplayrole,\n '' AS checkhead_printed_qtdisplayrole, '' AS checkhead_posted_qtdisplayrole,\n 1 AS xtindentrole\n FROM checkhead JOIN checkitem ON (checkitem_checkhead_id=checkhead_id)\n LEFT OUTER JOIN apopen ON (apopen_id=checkitem_apopen_id)\n WHERE ((checkhead_bankaccnt_id=)\n \n AND (checkhead_checkdate BETWEEN AND )\n \n AND (NOT checkhead_posted)\n AND (NOT checkhead_replaced)\n AND (NOT checkhead_deleted)\n \n \n AND (CAST(checkhead_number AS text) ~ )\n \n \n \n AND (checkhead_recip_type = 'V' )\n \n \n AND (checkhead_recip_type = 'C' )\n \n \n AND (checkhead_recip_type = 'T' )\n \n \n AND (checkhead_recip_id = )\n \n \n \n AND (checkhead_recip_type = 'V')\n AND (checkhead_recip_id = )\n \n AND (checkhead_recip_type = 'V')\n AND (checkhead_recip_id IN (SELECT vend_id\n FROM vendinfo\n WHERE (vend_vendtype_id=)))\n \n AND (checkhead_recip_type = 'V')\n AND (checkhead_recip_id IN (SELECT vend_id\n FROM vendinfo, vendtype\n WHERE (vend_vendtype_id=vendtype_id)\n AND (vendtype_code ~ )))\n \n )\n\n ORDER BY checkhead_number, checkid, orderby;\n admin 2015-10-01 0 97 checks detail used by printChecks\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: checks\n-- Name: detail\n-- Notes: used by printChecks\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT checkhead.*, form_report_name AS report_name\nFROM checkhead\nLEFT OUTER JOIN vendinfo ON((checkhead_recip_id = vend_id)\n AND (checkhead_recip_type = 'V'))\nLEFT OUTER JOIN custinfo ON((checkhead_recip_id = cust_id)\n AND (checkhead_recip_type = 'C'))\nLEFT OUTER JOIN taxauth ON((checkhead_recip_id = taxauth_id)\n AND (checkhead_recip_type = 'T')),\n bankaccnt, form\nWHERE ( (checkhead_bankaccnt_id=bankaccnt_id)\n AND (bankaccnt_check_form_id=form_id)\n\n AND (NOT checkhead_printed)\n AND (NOT checkhead_void)\n\n\n AND (bankaccnt_id=)\n\n )\n\nORDER BY checkhead_recip_type DESC, COALESCE(vend_name, cust_name, taxauth_name)\n\nORDER BY checkhead_recip_type DESC, COALESCE(vend_number, cust_number, taxauth_code)\n\n\nLIMIT \n\n;\n admin 2015-10-01 0 450 contact muststayactive This query determines whether a given contact should be kept\n active because other active records depend on it.\n Todo - should this be moved to the cntctAfterTrigger?\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: contact\n-- Name: muststayactive\n-- Notes: This query determines whether a given contact should be kept\n-- active because other active records depend on it.\n-- Todo - should this be moved to the cntctAfterTrigger?\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT EXISTS(\n SELECT 1\n FROM crmacct\n WHERE(crmacct_active\n AND ( IN (crmacct_cntct_id_1, crmacct_cntct_id_2)))\n UNION SELECT 3\n FROM custinfo\n WHERE (cust_active\n AND ( IN (cust_cntct_id, cust_corrcntct_id)))\n UNION SELECT 5\n FROM vendinfo\n WHERE (vend_active\n AND ( IN (vend_cntct1_id, vend_cntct2_id)))\n UNION SELECT 7\n FROM prospect\n WHERE (prospect_active AND (prospect_cntct_id=))\n UNION SELECT 8\n FROM shiptoinfo\n WHERE (shipto_active AND (shipto_cntct_id=))\n UNION SELECT 9\n FROM vendaddrinfo\n JOIN vendinfo ON (vendaddr_vend_id=vend_id)\n WHERE (vend_active AND (vendaddr_cntct_id=))\n UNION SELECT 10\n FROM whsinfo\n WHERE (warehous_active AND (warehous_cntct_id=))\n UNION SELECT 11\n FROM emp\n WHERE (emp_active AND (emp_cntct_id=))\n UNION SELECT 21\n FROM todoitem\n WHERE (todoitem_completed_date IS NOT NULL\n AND (todoitem_cntct_id=))\n) AS inuse;\n admin 2015-10-01 0 99 contacts detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: contacts\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT ON (length(cntct_last_name)=0, length(cntct_first_name)=0, cntct_last_name, cntct_first_name, cntct_number) \n cntct_id AS id\n \n, addr_id AS altId, addr.*,\n crmacct_id, crmacct_number, crmacct_name,\n cntct.* \n\n , charass_alias.charass_value AS char\n\n\n , charass_alias.charass_value AS char\n\n\n , charass_alias.charass_value::date AS char\n\n\n\nFROM cntct\n\nFROM cntct()\n\n LEFT OUTER JOIN crmacct ON (cntct_crmacct_id=crmacct_id) \n LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) \n LEFT OUTER JOIN cntcteml ON (cntcteml_cntct_id=cntct_id)\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='CNTCT') \n AND (charass_alias.charass_target_id=cntct_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='CNTCT') \n AND (charass_alias.charass_target_id=cntct_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='CNTCT') \n AND (charass_alias.charass_target_id=cntct_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\nWHERE true\n \n AND (cntct_owner_username=) \n\n AND (cntct_owner_username ~ ) \n\n \n AND cntct_active\n\n\n AND (\n (crmacct_number ~* )\n OR (crmacct_name ~* )\n OR (COALESCE(cntct_first_name,'') || ' ' || COALESCE(cntct_last_name,'') ~* )\n OR (COALESCE(cntct_phone,'') || ' ' || COALESCE(cntct_phone2,'') || ' ' || COALESCE(cntct_fax,'') ~* )\n OR (COALESCE(cntcteml_email,'') ~* )\n OR (COALESCE(addr_line1,'') || ' ' || COALESCE(addr_line2,'') || ' ' || COALESCE(addr_line3,'') ~* )\n OR (COALESCE(addr_city,'') ~* )\n OR (COALESCE(addr_state,'') ~* )\n OR (COALESCE(addr_postalcode,'') ~* )\n OR (COALESCE(addr_country,'') ~* )\n)\n\n\n AND (cntct_id=)\n\n\n AND (crmacct_id=)\n\n\n AND (COALESCE(cntct_first_name,'') || ' ' || COALESCE(cntct_last_name,'') ~* )\n\n\n AND (COALESCE(cntct_phone,'') || ' ' || COALESCE(cntct_phone2,'') || ' ' || COALESCE(cntct_fax,'') ~* )\n\n\n AND (COALESCE(cntcteml_email,'') ~* )\n\n\n AND (COALESCE(addr_line1,'') || ' ' || COALESCE(addr_line2,'') || ' ' || COALESCE(addr_line3,'') ~* )\n\n\n AND (COALESCE(addr_city,'') ~* )\n\n\n AND (COALESCE(addr_state,'') ~* )\n\n\n AND (COALESCE(addr_postalcode,'') ~* )\n\n\n AND (COALESCE(addr_country,'') ~* )\n\n\n AND (cntct_id=)\n\n\n AND (addr_id=)\n\n\nORDER BY length(cntct_last_name)=0, length(cntct_first_name)=0, cntct_last_name, cntct_first_name, cntct_number, cntcteml_primary desc;\n admin 2015-10-01 0 438 contact uses Find and report uses of the contact\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: contact\n-- Name: uses\n-- Notes: Find and report uses of the contact\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT ::text || '.' || type_id::text || '.' || type_code::text,\n AS contact,\n *\nFROM (\n\n SELECT crmacct_id AS type_id, 1 AS type_code, AS type,\n crmacct_number AS number,\n crmacct_name AS name, AS role,\n (crmacct_active) AS active,\n crmacct_owner_username AS owner\n FROM crmacct WHERE (crmacct_cntct_id_1=)\n \n UNION ALL\n SELECT crmacct_id AS type_id, 2 AS type_code, AS type,\n crmacct_number AS number,\n crmacct_name AS name, AS role,\n (crmacct_active) AS active,\n crmacct_owner_username AS owner\n FROM crmacct WHERE (crmacct_cntct_id_2=)\n \n UNION ALL\n SELECT cust_id AS type_id, 3 AS type_code, AS type,\n cust_number AS number,\n cust_name AS name, AS role,\n (cust_active) AS active,\n '' AS owner\n FROM custinfo WHERE (cust_cntct_id=)\n \n UNION ALL\n SELECT cust_id AS type_id, 4 AS type_code, AS type,\n cust_number AS number,\n cust_name AS name, AS role,\n (cust_active) AS active,\n '' AS owner\n FROM custinfo WHERE (cust_corrcntct_id=)\n \n UNION ALL\n SELECT vend_id AS type_id, 5 AS type_code, AS type,\n vend_number AS number,\n vend_name AS name, AS role,\n (vend_active) AS active,\n '' AS owner\n FROM vendinfo WHERE (vend_cntct1_id=)\n \n UNION ALL\n SELECT vend_id AS type_id, 6 AS type_code, AS type,\n vend_number AS number,\n vend_name AS name, AS role,\n (vend_active) AS active,\n '' AS owner\n FROM vendinfo WHERE (vend_cntct2_id=)\n \n UNION ALL\n SELECT prospect_id AS type_id, 7 AS type_code, AS type,\n prospect_number AS number,\n prospect_name AS name, '' AS role,\n (prospect_active) AS active,\n '' AS owner\n FROM prospect WHERE (prospect_cntct_id=)\n \n UNION ALL\n SELECT shipto_id AS type_id, 8 AS type_code, AS type,\n shipto_num AS number,\n shipto_name AS name, AS role,\n (shipto_active) AS active,\n '' AS owner\n FROM shiptoinfo WHERE (shipto_cntct_id=)\n \n UNION ALL\n SELECT vendaddr_id AS type_id, 9 AS type_code, AS type,\n vendaddr_code AS number,\n vendaddr_name AS name, '' AS role,\n (true) AS active,\n '' AS owner\n FROM vendaddrinfo WHERE (vendaddr_cntct_id=)\n \n UNION ALL\n SELECT warehous_id AS type_id, 10 AS type_code, AS type,\n warehous_code AS number,\n warehous_descrip AS name, '' AS role,\n (warehous_active) AS active,\n '' AS owner\n FROM whsinfo WHERE (warehous_cntct_id=)\n \n UNION ALL\n SELECT emp_id AS type_id, 11 AS type_code, AS type,\n emp_code AS number,\n emp_number AS name, '' AS role,\n (emp_active) AS active,\n '' AS owner\n FROM emp WHERE (emp_cntct_id=)\n\n\n UNION ALL\n SELECT cohead_id AS id, 12 AS altId, AS type,\n cohead_number AS number,\n cust_number AS name, AS role,\n (cohead_status = 'O') AS active,\n '' AS owner\n FROM cohead JOIN custinfo ON (cohead_cust_id=cust_id)\n WHERE (=cohead_billto_cntct_id)\n\n UNION ALL\n SELECT cohead_id AS id, 13 AS altId, AS type,\n cohead_number AS number,\n cust_number AS name, AS role,\n (cohead_status = 'O') AS active,\n '' AS owner\n FROM cohead JOIN custinfo ON (cohead_cust_id=cust_id)\n WHERE (=cohead_shipto_cntct_id)\n\n\n UNION ALL\n SELECT incdt_id AS id, 14 AS altId, AS type,\n incdt_number::TEXT AS number,\n incdt_summary AS name, '' AS role,\n (incdt_status NOT IN ('R', 'L')) AS active,\n incdt_owner_username AS owner\n FROM incdt\n WHERE (incdt_cntct_id=)\n\n\n UNION ALL\n SELECT lsreg_id AS id, 15 AS altId, AS type,\n ls_number AS number,\n item_number AS name, '' AS role,\n (lsreg_expiredate > current_date) AS active,\n '' AS owner\n FROM lsreg JOIN ls ON (lsreg_ls_id=ls_id) JOIN item ON (ls_item_id=item_id)\n WHERE (lsreg_cntct_id=)\n\n\n UNION ALL\n SELECT ophead_id AS id, 16 AS altId, AS type,\n ophead_number AS number,\n ophead_name AS name, '' AS role,\n ophead_active AS active,\n ophead_owner_username AS owner\n FROM ophead\n WHERE (ophead_cntct_id=)\n\n\n UNION ALL\n SELECT pohead_id AS id, 17 AS altId, AS type,\n pohead_number AS number,\n vend_number AS name, AS role,\n (pohead_status != 'C') AS active,\n '' AS owner\n FROM pohead JOIN vendinfo ON (pohead_vend_id=vend_id)\n WHERE (=pohead_vend_cntct_id)\n\n UNION ALL\n SELECT pohead_id AS id, 18 AS altId, AS type,\n pohead_number AS number,\n vend_number AS name, AS role,\n (pohead_status != 'C') AS active,\n '' AS owner\n FROM pohead JOIN vendinfo ON (pohead_vend_id=vend_id)\n WHERE (=pohead_shipto_cntct_id)\n\n UNION ALL\n SELECT quhead_id AS id, 19 AS altId, AS type,\n quhead_number AS number,\n COALESCE(cust_number, prospect_number) AS name,\n AS role,\n (quhead_status = 'O') AS active,\n '' AS owner\n FROM quhead LEFT OUTER JOIN custinfo ON (quhead_cust_id=cust_id)\n LEFT OUTER JOIN prospect ON (quhead_cust_id=prospect_id)\n WHERE (=quhead_billto_cntct_id)\n\n UNION ALL\n SELECT quhead_id AS id, 20 AS altId, AS type,\n quhead_number AS number,\n COALESCE(cust_number, prospect_number) AS name,\n AS role,\n (quhead_status = 'O') AS active,\n '' AS owner\n FROM quhead LEFT OUTER JOIN custinfo ON (quhead_cust_id=cust_id)\n LEFT OUTER JOIN prospect ON (quhead_cust_id=prospect_id)\n WHERE (=quhead_shipto_cntct_id)\n\n\n UNION ALL\n SELECT todoitem_id, 21 AS altId, AS type,\n todoitem_seq::TEXT AS number,\n todoitem_name AS name, '' AS role,\n (todoitem_completed_date IS NULL) AS active,\n todoitem_owner_username AS owner\n FROM todoitem\n WHERE todoitem_cntct_id=\n\n\n \n UNION ALL\n SELECT tohead_id, 22 AS altId, AS type,\n tohead_number AS number,\n tohead_srcname || ' -> ' || tohead_destname AS name,\n AS role,\n (tohead_status = 'O') AS active,\n '' AS owner\n FROM tohead\n WHERE (=tohead_srccntct_id)\n UNION ALL\n SELECT tohead_id, 23 AS altId, AS type,\n tohead_number AS number,\n tohead_srcname || ' -> ' || tohead_destname AS name,\n AS role,\n (tohead_status = 'O') AS active,\n '' AS owner\n FROM tohead\n WHERE (=tohead_destcntct_id)\n \n\n\n\n) AS innerq\n\n ORDER BY type, number;\n admin 2015-10-01 0 419 contactmerge delete Delete a contact\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: contactmerge\n-- Name: delete\n-- Notes: Delete a contact\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM cntct WHERE (cntct_id=);\n admin 2015-10-01 0 420 contactmerge deselect Removes contact selection\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: contactmerge\n-- Name: deselect\n-- Notes: Removes contact selection\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM cntctsel\nWHERE (cntctsel_cntct_id=);\n admin 2015-10-01 0 422 contactmerge merge Merge contact selections\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: contactmerge\n-- Name: merge\n-- Notes: Merge contact selections\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntctmerge(\n src.cntctsel_cntct_id, \n trgt.cntctsel_cntct_id,\n ::boolean) AS result\nFROM cntctsel src, cntctsel trgt\nWHERE ((trgt.cntctsel_target)\nAND (NOT src.cntctsel_target));\n admin 2015-10-01 0 421 contactmerge merged Lists all merged contacts\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: contactmerge\n-- Name: merged\n-- Notes: Lists all merged contacts\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntct_id,\n CASE\n WHEN (cntctUsed(cntctmrgd_cntct_id)=false) THEN\n 3 -- Already merged contact\n ELSE\n 4 -- Already merged contact, but still has relationships\n END AS status,\n cntct.*,crmacct_number,crmacct_name,addr.*, \n 0 AS xtindentrole,\n CASE\n WHEN (cntctUsed(cntctmrgd_cntct_id)=false) THEN\n 'warning' -- Already merged contact\n ELSE\n 'error' -- Already merged contact, but still has relationships\n END AS qtforegroundrole\nFROM cntct\n JOIN cntctmrgd ON (cntct_id=cntctmrgd_cntct_id)\n LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n LEFT OUTER JOIN crmacct ON (cntct_crmacct_id=crmacct_id);\n admin 2015-10-01 0 423 contactmerge populate Queries selected contact info\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: contactmerge\n-- Name: populate\n-- Notes: Queries selected contact info\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntct.*,\n crmacct_number,\n crmacct_name,\n addr.*,\n CASE WHEN cntctsel_mrg_first_name THEN 'emphasis' END AS cntct_first_name_qtforegroundrole,\n CASE WHEN cntctsel_mrg_last_name THEN 'emphasis' END AS cntct_last_name_qtforegroundrole,\n CASE WHEN cntctsel_mrg_honorific THEN 'emphasis' END AS cntct_honorific_qtforegroundrole,\n CASE WHEN cntctsel_mrg_initials THEN 'emphasis' END AS cntct_initials_qtforegroundrole,\n CASE WHEN cntctsel_mrg_phone THEN 'emphasis' END AS cntct_phone_qtforegroundrole,\n CASE WHEN cntctsel_mrg_phone2 THEN 'emphasis' END AS cntct_phone2_qtforegroundrole,\n CASE WHEN cntctsel_mrg_fax THEN 'emphasis' END AS cntct_fax_qtforegroundrole,\n CASE WHEN cntctsel_mrg_email THEN 'emphasis' END AS cntct_email_qtforegroundrole,\n CASE WHEN cntctsel_mrg_webaddr THEN 'emphasis' END AS cntct_webaddr_qtforegroundrole,\n CASE WHEN cntctsel_mrg_notes THEN 'emphasis' END AS cntct_notes_qtforegroundrole,\n CASE WHEN cntctsel_mrg_title THEN 'emphasis' END AS cntct_title_qtforegroundrole,\n CASE WHEN cntctsel_mrg_middle THEN 'emphasis' END AS cntct_middle_qtforegroundrole,\n CASE WHEN cntctsel_mrg_suffix THEN 'emphasis' END AS cntct_suffix_qtforegroundrole,\n CASE WHEN cntctsel_mrg_owner_username THEN 'emphasis' END AS cntct_owner_username_qtforegroundrole,\n CASE WHEN cntctsel_mrg_crmacct_id THEN 'emphasis' END AS crmacct_number_qtforegroundrole,\n CASE WHEN cntctsel_mrg_crmacct_id THEN 'emphasis' END AS crmacct_name_qtforegroundrole,\n CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_line1_qtforegroundrole,\n CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_line2_qtforegroundrole,\n CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_line3_qtforegroundrole,\n CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_city_qtforegroundrole,\n CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_state_qtforegroundrole,\n CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_postalcode_qtforegroundrole,\n CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_country_qtforegroundrole,\n CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_notes_qtforegroundrole,\n CASE WHEN cntctsel_mrg_addr_id THEN 'emphasis' END AS addr_number_qtforegroundrole\nFROM cntctsel\n JOIN cntct ON (cntctsel_cntct_id=cntct_id)\n LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n LEFT OUTER JOIN crmacct ON (cntct_crmacct_id=crmacct_id)\nWHERE (cntctsel_target=);\n admin 2015-10-01 0 424 contactmerge purge Purge contact(s) that was/were previously merged\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: contactmerge\n-- Name: purge\n-- Notes: Purge contact(s) that was/were previously merged\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM cntct WHERE cntct_id IN\n(SELECT cntctmrgd_cntct_id\n FROM cntctmrgd\n WHERE (NOT cntctmrgd_error)\n\nAND (cntctmrgd_cntct_id=)\n)\nAND (NOT cntctUsed(cntct_id));\n admin 2015-10-01 0 425 contactmerge restore Restore a contact that was previously merged\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: contactmerge\n-- Name: restore\n-- Notes: Restore a contact that was previously merged\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntctrestore(cntctmrgd_cntct_id) AS result\nFROM cntctmrgd\n\nWHERE (cntctmrgd_cntct_id=)\n\n;\n admin 2015-10-01 0 426 contactmerge search Search for contacts\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: contactmerge\n-- Name: search\n-- Notes: Search for contacts\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntct_id,\n CASE\n WHEN (cntctsel_cntct_id IS NOT NULL AND cntctsel_target) THEN\n 1 -- Selected as target contact\n WHEN (cntctsel_cntct_id IS NOT NULL AND NOT cntctsel_target) THEN\n 2 -- Selected as contact to merge\n WHEN (cntctmrgd_cntct_id IS NOT NULL AND cntctUsed(cntctmrgd_cntct_id)=false) THEN\n 3 -- Already merged contact\n WHEN (cntctmrgd_cntct_id IS NOT NULL) THEN\n 4 -- Already merged contact, but still has relationships\n ELSE\n 0 -- No status\n END AS status,\n cntctdups.*, \n cntctdup_level AS xtindentrole,\n CASE\n WHEN (cntctsel_cntct_id IS NOT NULL AND cntctsel_target) THEN\n 'altemphasis' -- Selected as target contact\n WHEN (cntctsel_cntct_id IS NOT NULL AND NOT cntctsel_target) THEN\n 'emphasis' -- Selected as contact to merge\n WHEN (cntctmrgd_cntct_id IS NOT NULL AND cntctUsed(cntctmrgd_cntct_id)=false) THEN\n 'warning' -- Already merged contact\n WHEN (cntctmrgd_cntct_id IS NOT NULL) THEN\n 'error' -- Already merged contact, but still has relationships\n END AS qtforegroundrole\nFROM cntctdups(\n , \n , \n , \n , \n , \n , \n , \n ,\n , \n , \n , \n , \n , \n , \n , \n )\n LEFT OUTER JOIN cntctsel ON (cntct_id=cntctsel_cntct_id)\n LEFT OUTER JOIN cntctmrgd ON (cntct_id=cntctmrgd_cntct_id);\n admin 2015-10-01 0 54 inventoryHistory detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: inventoryHistory\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT invhist_id, invdetail_id, invhist_transdate AS sortdate,\n formatDateTime(invhist_transdate) AS transdate,\n CASE WHEN (level=0) THEN invhist_transdate END AS invhist_transdate,\n CASE WHEN (level=0) THEN invhist_created END AS invhist_created,\n CASE WHEN (level=0) THEN invhist_user END AS invhist_user,\n CASE WHEN (level=0) THEN invhist_transtype END AS invhist_transtype,\n CASE WHEN (level=0) THEN warehous_code END AS warehous_code,\n CASE WHEN (level=0) THEN ordernumber\n ELSE locationname\n END AS orderlocation,\n CASE WHEN (level=0) THEN item_number END AS item_number,\n CASE WHEN (level=0) THEN invhist_invuom END AS invhist_invuom,\n CASE WHEN (level=0 AND invhist_transtype IN ('EX','IM','SH','SI')) THEN (invhist_invqty * -1.0)\n WHEN (level=0) THEN invhist_invqty\n ELSE invdetail_qty\n END AS transqty,\n CASE WHEN (level=0) THEN invhist_value_after - invhist_value_before\n END AS transvalue,\n CASE WHEN (level=0) THEN locfrom END AS locfrom,\n CASE WHEN (level=0) THEN invhist_qoh_before\n ELSE invdetail_qty_before\n END AS qohbefore,\n CASE WHEN (level=0) THEN locto END AS locto,\n CASE WHEN (level=0) THEN invhist_qoh_after\n ELSE invdetail_qty_after\n END AS qohafter,\n CASE WHEN (level=0) THEN costmethod END AS costmethod,\n CASE WHEN (level=0) THEN invhist_value_before END AS invhist_value_before,\n CASE WHEN (level=0) THEN invhist_value_after END AS invhist_value_after,\n 'qty' AS transqty_xtnumericrole,\n 'curr' AS transvalue_xtnumericrole,\n 0 AS transvalue_xttotalrole,\n 'qty' AS qohbefore_xtnumericrole,\n 'qty' AS qohafter_xtnumericrole,\n 'curr' AS invhist_value_before_xtnumericrole,\n 'curr' AS invhist_value_after_xtnumericrole,\n CASE WHEN (NOT invhist_posted) THEN NULL END AS qohbefore_qtdisplayrole,\n CASE WHEN (NOT invhist_posted) THEN NULL END AS qohafter_qtdisplayrole,\n CASE WHEN (NOT invhist_posted) THEN NULL END AS invhist_value_before_qtdisplayrole,\n CASE WHEN (NOT invhist_posted) THEN NULL END AS invhist_value_after_qtdisplayrole,\n CASE WHEN (NOT invhist_posted) THEN NULL END AS costmethod_qtdisplayrole,\n CASE WHEN (NOT invhist_posted) THEN NULL END AS locto_qtdisplayrole,\n CASE WHEN (NOT invhist_posted) THEN NULL END AS locfrom_qtdisplayrole,\n CASE WHEN (NOT invhist_posted) THEN 'warning' END AS qtforegroundrole,\n level AS xtindentrole\nFROM (\nSELECT invhist.*, 0 AS level,\n whs1.warehous_code AS warehous_code, item_number,\n CASE WHEN (invhist_ordtype NOT LIKE '') THEN (invhist_ordtype || '-' || invhist_ordnumber)\n ELSE invhist_ordnumber\n END AS ordernumber,\n CASE WHEN (invhist_costmethod='A') THEN \n WHEN (invhist_costmethod='S') THEN \n WHEN (invhist_costmethod='J') THEN \n WHEN (invhist_costmethod='N') THEN \n ELSE \n END AS costmethod,\n 0 AS invdetail_id, '' AS locationname,\n 0 AS invdetail_qty, 0 AS invdetail_qty_before, 0 AS invdetail_qty_after,\n CASE WHEN (invhist_transtype='TW' AND invhist_invqty < 0) THEN whs1.warehous_code\n WHEN (invhist_transtype='TW') THEN whs2.warehous_code\n WHEN (invhist_transtype='AD' AND invhist_invqty < 0) THEN whs1.warehous_code\n WHEN (invhist_transtype='AD') THEN 'ADJ'\n WHEN (invhist_transtype='EX') THEN whs1.warehous_code\n WHEN (invhist_transtype='IB') THEN whs1.warehous_code\n WHEN (invhist_transtype='IM' AND invhist_invqty < 0) THEN 'WIP'\n WHEN (invhist_transtype='IM') THEN whs1.warehous_code\n WHEN (invhist_transtype='IT') THEN whs1.warehous_code\n WHEN (invhist_transtype='RB') THEN 'WIP'\n WHEN (invhist_transtype='RM') THEN 'WIP'\n WHEN (invhist_transtype='RP') THEN whs1.warehous_code\n WHEN (invhist_transtype='RR') THEN 'CUST'\n WHEN (invhist_transtype='RS') THEN 'SHIP'\n WHEN (invhist_transtype='SH') THEN whs1.warehous_code\n WHEN (invhist_transtype='SI') THEN whs1.warehous_code\n WHEN (invhist_transtype='SV') THEN whs1.warehous_code\n\t WHEN (invhist_transtype='TR') THEN whs2.warehous_code\n\t WHEN (invhist_transtype='TS') THEN whs1.warehous_code\n\t WHEN (invhist_transtype='RI') THEN whs1.warehous_code\n ELSE ''\n END AS locfrom,\n CASE WHEN (invhist_transtype='TW' AND invhist_invqty < 0) THEN whs2.warehous_code\n WHEN (invhist_transtype='TW') THEN whs1.warehous_code\n WHEN (invhist_transtype='AD' AND invhist_invqty < 0) THEN 'ADJ'\n WHEN (invhist_transtype='AD') THEN whs1.warehous_code\n WHEN (invhist_transtype='CC') THEN whs1.warehous_code\n WHEN (invhist_transtype='EX') THEN 'EXPENSE'\n WHEN (invhist_transtype='IB') THEN 'WIP'\n WHEN (invhist_transtype='IM' AND invhist_invqty < 0) THEN whs1.warehous_code\n WHEN (invhist_transtype='IM') THEN 'WIP'\n WHEN (invhist_transtype='NN') THEN whs1.warehous_code\n WHEN (invhist_transtype='RB') THEN whs1.warehous_code\n WHEN (invhist_transtype='RM') THEN whs1.warehous_code\n WHEN (invhist_transtype='RP') THEN 'PURCH'\n WHEN (invhist_transtype='RR') THEN whs1.warehous_code\n WHEN (invhist_transtype='RS') THEN whs1.warehous_code\n WHEN (invhist_transtype='RT') THEN whs1.warehous_code\n WHEN (invhist_transtype='RX') THEN whs1.warehous_code\n WHEN (invhist_transtype='SH') THEN 'SHIP'\n WHEN (invhist_transtype='SI') THEN 'SCRAP'\n WHEN (invhist_transtype='SV') THEN 'SHIP'\n WHEN (invhist_transtype='TR') THEN whs1.warehous_code\n WHEN (invhist_transtype='TS') THEN whs2.warehous_code\n WHEN (invhist_transtype='RI') THEN 'WIP'\n ELSE ''\n END AS locto \nFROM itemsite, item, whsinfo AS whs1, invhist\n LEFT OUTER JOIN whsinfo AS whs2 ON (invhist_xfer_warehous_id=whs2.warehous_id)\nWHERE ( (invhist_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id) \n AND (itemsite_warehous_id=whs1.warehous_id)\n AND (DATE(invhist_transdate) BETWEEN AND )\n AND (transType(invhist_transtype, ))\n\n AND (invhist_ordnumber ~ )\n\n\n AND (invhist_ordtype='SO')\n AND (invhist_ordnumber ~ (\n SELECT cohead_number \n FROM cohead \n WHERE cohead_id=))\n\n\n AND (invhist_ordtype='PO')\n AND (invhist_ordnumber ~ (\n SELECT pohead_number \n FROM pohead \n WHERE pohead_id=))\n\n\n AND (invhist_ordtype='TO')\n AND (invhist_ordnumber ~ (\n SELECT tohead_number \n FROM tohead \n WHERE tohead_id=))\n\n\n AND (invhist_ordtype='WO')\n AND (invhist_ordnumber ~ formatWoNumber())\n\n\n AND (itemsite_warehous_id=)\n\n\n AND (itemsite_item_id=)\n\n\n AND (item_classcode_id=)\n\n\n AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t FROM itemgrpitem\n\t\t WHERE (itemgrpitem_itemgrp_id=)))\n\n\n AND (itemsite_plancode_id=)\n\n\n AND (item_classcode_id IN (SELECT classcode_id\n\t\t\t FROM classcode\n\t\t\t WHERE (classcode_code ~ )))\n\n\n AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t FROM itemgrpitem, itemgrp\n\t\t WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n\t\t AND (itemgrp_name ~ ))))\n\n\n AND (itemsite_plancode_id IN (SELECT plancode_id\n\t\t\t\tFROM plancode\n\t\t\t\tWHERE (plancode_code ~ )))\n\n\n AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n\n) \nUNION SELECT invhist.*, 1 AS level,\n '' AS warehous_code, '' AS item_number,\n '' AS ordernumber,\n '' AS costmethod,\n invdetail_id,\n CASE WHEN (invdetail_location_id=-1) THEN formatlotserialnumber(invdetail_ls_id)\n WHEN (invdetail_ls_id IS NULL) THEN formatLocationName(invdetail_location_id)\n ELSE (formatLocationName(invdetail_location_id) || '-' || formatlotserialnumber(invdetail_ls_id))\n END AS locationname,\n invdetail_qty, invdetail_qty_before, invdetail_qty_after,\n '' AS locfrom,\n '' AS locto \nFROM itemsite, item, whsinfo AS whs1, invdetail, invhist LEFT OUTER JOIN\n whsinfo AS whs2 ON (invhist_xfer_warehous_id=whs2.warehous_id)\nWHERE ((invhist_hasdetail)\n AND (invhist_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=whs1.warehous_id)\n AND (invdetail_invhist_id=invhist_id)\n AND (DATE(invhist_transdate) BETWEEN AND )\n AND (transType(invhist_transtype, ))\n\n AND (invhist_ordtype=)\n\n\n AND (invhist_ordnumber ~ )\n\n\n AND (invhist_ordtype='SO')\n AND (invhist_ordnumber ~ (\n SELECT cohead_number \n FROM cohead \n WHERE cohead_id=))\n\n\n AND (invhist_ordtype='PO')\n AND (invhist_ordnumber ~ (\n SELECT pohead_number \n FROM pohead \n WHERE pohead_id=))\n\n\n AND (invhist_ordtype='TO')\n AND (invhist_ordnumber ~ (\n SELECT tohead_number \n FROM tohead \n WHERE tohead_id=))\n\n\n AND (invhist_ordtype='WO')\n AND (invhist_ordnumber ~ formatWoNumber())\n\n\n AND (itemsite_warehous_id=)\n\n\n AND (itemsite_item_id=)\n\n\n AND (item_classcode_id=)\n\n\n AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t FROM itemgrpitem\n\t\t WHERE (itemgrpitem_itemgrp_id=)))\n\n\n AND (itemsite_plancode_id=)\n\n\n AND (item_classcode_id IN (SELECT classcode_id\n\t\t\t FROM classcode\n\t\t\t WHERE (classcode_code ~ )))\n\n\n AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t FROM itemgrpitem, itemgrp\n\t\t WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n\t\t AND (itemgrp_name ~ ))))\n\n\n AND (itemsite_plancode_id IN (SELECT plancode_id\n\t\t\t\tFROM plancode\n\t\t\t\tWHERE (plancode_code ~ )))\n\n\n AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n\n)\n\n ) AS data\nORDER BY sortdate DESC, invhist_id, level;\n admin 2015-10-01 0 474 contracts detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: contracts\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT contrct_id, \n vend_number, vend_name, \n contrct.*,\n CASE WHEN COALESCE(contrct_effective, startOfTime()) <=\n startOfTime() THEN \n END AS contrct_effective_qtdisplayrole,\n CASE WHEN COALESCE(contrct_expires, endOfTime()) >=\n endOfTime() THEN \n END AS contrct_expires_qtdisplayrole,\n CASE WHEN (COALESCE(contrct_expires, endOfTime()) < CURRENT_DATE) THEN 'expired'\n WHEN (COALESCE(contrct_effective, startOfTime()) > CURRENT_DATE) THEN 'future'\n END AS qtforegroundrole,\n (SELECT count(*) FROM itemsrc WHERE (itemsrc_contrct_id=contrct_id)) AS item_count \nFROM contrct JOIN vendinfo ON (vend_id=contrct_vend_id)\nWHERE ((true)\n\n AND (contrct_vend_id=)\n\n\n AND (contrct_effective >= )\n\n\n AND (contrct_effective <= )\n\n\n AND (contrct_expires >= )\n\n\n AND (contrct_expires <= )\n\n\n AND ( (contrct_number ~* )\n OR (COALESCE(contrct_descrip,'') ~* ) )\n\n)\nORDER By vend_number, contrct_number\n;\n admin 2015-10-01 0 236 costedBOM detail used by dspCostedIndentedBOM, dspCostedSingleLevelBOM, dspCostedSummarizedBOM\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: costedBOM\n-- Name: detail\n-- Notes: used by dspCostedIndentedBOM, dspCostedSingleLevelBOM, dspCostedSummarizedBOM\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n\n bomdata_bomwork_id AS id,\n\n bomdata_bomitem_id AS id,\n\n -1,\n\n \n\n CASE WHEN bomdata_bomwork_parent_id = -1 AND bomdata_bomwork_id = -1 THEN -1\n ELSE bomdata_item_id\n END AS altid,\n\n CASE WHEN (bomdata_bomitem_id = -1) THEN -1\n ELSE bomdata_item_id\n END AS altid,\n\n *,\n\n\n bomdata_stdunitcost AS unitcost,\n bomdata_stdextendedcost AS extendedcost,\n\n bomdata_actunitcost AS unitcost,\n bomdata_actextendedcost AS extendedcost,\n\n\n 'qty' AS bomdata_batchsize_xtnumericrole,\n 'qty' AS bomdata_qtyfxd_xtnumericrole,\n 'qtyper' AS bomdata_qtyper_xtnumericrole,\n 'percent' AS bomdata_scrap_xtnumericrole,\n 'qtyper' AS bomdata_qtyreq_xtnumericrole,\n 'cost' AS unitcost_xtnumericrole,\n 'cost' AS extendedcost_xtnumericrole,\n CASE WHEN COALESCE(bomdata_effective, startOfTime()) <= startOfTime() THEN \n END AS bomdata_effective_qtdisplayrole,\n CASE WHEN COALESCE(bomdata_expires, endOfTime()) <= endOfTime() THEN \n END AS bomdata_expires_qtdisplayrole,\n CASE WHEN bomdata_expired THEN 'expired'\n WHEN bomdata_future THEN 'future'\n END AS qtforegroundrole\n\n , bomdata_bomwork_level - 1 AS xtindentrole\n\n , 0 AS extendedcost_xttotalrole\n\nFROM\n\n indentedbom(, , 0, 0);\n\n singlelevelbom(, , 0, 0);\n\n summarizedBOM(, , , );\n\n admin 2015-10-01 0 112 costelem unusedbyitem list the cost elements that can be applied to an item that have\n not already been applied to that item. takes an item_id and type.\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: costelem\n-- Name: unusedbyitem\n-- Notes: list the cost elements that can be applied to an item that have\n-- not already been applied to that item. takes an item_id and type.\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\n\nSELECT costelem_id, costelem_type\nFROM costelem\nWHERE ((costelem_active)\n AND (NOT costelem_sys\n OR (CASE WHEN fetchMetricBool('Routings') AND\n ( IN ('M', 'F', 'B', 'C', 'T')) THEN\n costelem_type IN ('Direct Labor', 'Overhead', 'Machine Overhead')\n WHEN ( IN ('O', 'P')) THEN\n costelem_type IN ('Material')\n END))\n AND (costelem_id NOT IN (SELECT itemcost_costelem_id\n FROM itemcost\n WHERE ((NOT itemcost_lowlevel)\n AND (itemcost_item_id=))))\n )\nORDER BY costelem_type;\n\n\n\nSELECT costelem_id, costelem_type\nFROM costelem\nWHERE ((costelem_active)\n AND (NOT costelem_sys\n OR (CASE WHEN fetchMetricBool('Routings') AND\n ( IN ('M', 'F', 'B', 'C', 'T')) THEN\n costelem_type IN ('Direct Labor', 'Overhead', 'Machine Overhead')\n WHEN ( IN ('O', 'P')) THEN\n costelem_type IN ('Material')\n END))\n AND (costelem_id NOT IN (SELECT bomitemcost_costelem_id\n FROM bomitemcost\n WHERE ((NOT bomitemcost_lowlevel)\n AND (bomitemcost_bomitem_id=))))\n )\nORDER BY costelem_type;\n\n\n\n admin 2015-10-01 0 237 countSlip detail used by dspCountSlipEditList, dspCountSlipsByWarehouse\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: countSlip\n-- Name: detail\n-- Notes: used by dspCountSlipEditList, dspCountSlipsByWarehouse\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cntslip_id,\n CASE WHEN (cntslip_posted) THEN 1\n ELSE 0\n END,\n cntslip_username AS user,\n\n toNumeric(cntslip_number, 0) AS cntslip_number,\n cntslip_number AS cntslip_number_qtdisplayrole,\n\n cntslip_number,\n\n CASE WHEN (cntslip_location_id=-1) THEN ''\n ELSE formatLocationName(cntslip_location_id)\n END AS locname,\n invcnt_tagnumber,\n\n warehous_code,\n item_number, (item_descrip1 || ' ' || item_descrip2) AS descrip,\n\n cntslip_lotserial, cntslip_posted,\n cntslip_entered, cntslip_qty,\n 'qty' AS cntslip_qty_xtnumericrole,\n cntslip_posted AS posted\nFROM cntslip, invcnt\n\n JOIN itemsite ON (invcnt_itemsite_id=itemsite_id)\n JOIN item ON (itemsite_item_id=item_id)\n JOIN whsinfo ON (itemsite_warehous_id=warehous_id)\n\nWHERE ((cntslip_cnttag_id=invcnt_id)\n\n AND (cntslip_entered BETWEEN AND (::DATE + 1))\n \n AND (cntslip_posted)\n \n \n AND (itemsite_warehous_id=)\n \n\n AND (NOT invcnt_posted)\n AND (invcnt_id=)\n\n )\nORDER BY cntslip_number;\n admin 2015-10-01 0 238 countTag detail used by dspCountTagEditList\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: countTag\n-- Name: detail\n-- Notes: used by dspCountTagEditList\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n CASE WHEN (xtindentrole = 1) THEN NULL\n \n WHEN (ABS(variancecost) > ) THEN 'error'\n \n WHEN (ABS(varianceprcnt * 100.0) > ) THEN 'error'\n \n ELSE NULL\n \n END AS qtforegroundrole,\n CASE WHEN (xtindentrole = 1) THEN NULL\n WHEN (qohafter IS NOT NULL) THEN 'emphasis'\n END AS qohafter_qtforegroundrole,\n CASE WHEN (xtindentrole = 0) THEN NULL ELSE '' END AS invcnt_priority_qtdisplayrole,\n 'qty' AS qoh_xtnumericrole,\n 'qty' AS qohafter_xtnumericrole,\n 'qty' AS variance_xtnumericrole,\n 'percent' AS varianceprcnt_xtnumericrole,\n 'curr' AS variancecost_xtnumericrole\nFROM (\n SELECT invcnt_id, -1 AS cntslip_id, invcnt_priority,\n COALESCE(invcnt_tagnumber, 'Misc.') AS tagnumber,\n invcnt_tagdate AS tagdate,\n item_number, (item_descrip1 || item_descrip2) AS item_descrip, warehous_code,\n\t CASE WHEN (location_id IS NOT NULL) THEN\n formatLocationName(location_id)\n ELSE END AS loc_specific,\n qtyAtLocation(invcnt_itemsite_id, invcnt_location_id) AS qoh,\n \n calcTotalSlipQty(invcnt_id) AS qohafter,\n (calcTotalSlipQty(invcnt_id) - qtyAtLocation(invcnt_itemsite_id, invcnt_location_id)) AS variance,\n CASE WHEN (calcTotalSlipQty(invcnt_id) IS NULL) THEN NULL\n WHEN ((qtyAtLocation(invcnt_itemsite_id, invcnt_location_id) = 0) AND (calcTotalSlipQty(invcnt_id) > 0)) THEN 1\n WHEN ((qtyAtLocation(invcnt_itemsite_id, invcnt_location_id) = 0) AND (calcTotalSlipQty(invcnt_id) < 0)) THEN -1\n WHEN ((qtyAtLocation(invcnt_itemsite_id, invcnt_location_id) = 0) AND (calcTotalSlipQty(invcnt_id) = 0)) THEN 0\n ELSE ((1 - (calcTotalSlipQty(invcnt_id) / qtyAtLocation(invcnt_itemsite_id, invcnt_location_id))) * -1)\n END AS varianceprcnt,\n (itemCost(itemsite_id) * (calcTotalSlipQty(invcnt_id) - qtyAtLocation(invcnt_itemsite_id, invcnt_location_id))) AS variancecost,\n \n COALESCE(invcnt_qoh_after, 0.0) AS qohafter,\n (invcnt_qoh_after - qtyAtLocation(invcnt_itemsite_id, invcnt_location_id)) AS variance,\n CASE WHEN (invcnt_qoh_after IS NULL) THEN NULL\n WHEN ((qtyAtLocation(invcnt_itemsite_id, invcnt_location_id) = 0) AND (invcnt_qoh_after > 0)) THEN 1\n WHEN ((qtyAtLocation(invcnt_itemsite_id, invcnt_location_id) = 0) AND (invcnt_qoh_after < 0)) THEN -1\n WHEN ((qtyAtLocation(invcnt_itemsite_id, invcnt_location_id) = 0) AND (invcnt_qoh_after = 0)) THEN 0\n ELSE ((1 - (invcnt_qoh_after / qtyAtLocation(invcnt_itemsite_id, invcnt_location_id))) * -1)\n END AS varianceprcnt,\n (itemCost(itemsite_id) * (invcnt_qoh_after - qtyAtLocation(invcnt_itemsite_id, invcnt_location_id))) AS variancecost,\n \n item_number AS orderby,\n 0 AS xtindentrole\n FROM invcnt LEFT OUTER JOIN location ON (invcnt_location_id=location_id),\n item, whsinfo, itemsite\n WHERE ((invcnt_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (NOT invcnt_posted)\n \n AND (itemsite_warehous_id=)\n \n \n AND (item_classcode_id=)\n \n AND (item_classcode_id IN (SELECT classcode_id FROM classcode WHERE (classcode_code ~ )))\n \n AND (itemsite_plancode_id=)\n \n AND (itemsite_plancode_id IN (SELECT plancode_id FROM plancode WHERE (plancode_code ~ )))\n \n \n )\n UNION\n SELECT invcnt_id, cntslip_id, invcnt_priority,\n cntslip_number AS tagnumber,\n cntslip_entered AS tagdate,\n CASE WHEN (cntslip_posted) THEN \n ELSE \n END AS item_number,\n '' AS item_descrip,\n '' AS warehous_code,\n '' AS loc_specific,\n NULL AS qoh,\n cntslip_qty AS qohafter,\n NULL AS variance, NULL AS varianceprcnt, 0 AS variancecost,\n item_number AS orderby,\n 1 AS xtindentrole\n FROM cntslip, invcnt, itemsite, item\n WHERE ((cntslip_cnttag_id=invcnt_id)\n AND (invcnt_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (NOT invcnt_posted)\n \n AND (itemsite_warehous_id=)\n \n \n AND (item_classcode_id=)\n \n AND (item_classcode_id IN (SELECT classcode_id FROM classcode WHERE (classcode_code ~ )))\n \n AND (itemsite_plancode_id=)\n \n AND (itemsite_plancode_id IN (SELECT plancode_id FROM plancode WHERE (plancode_code ~ )))\n \n \n )\n) AS dummy\nORDER BY invcnt_priority DESC, orderby, invcnt_id, cntslip_id;\n admin 2015-10-01 0 436 countTags create used by createCountTagsByParameterList\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: countTags\n-- Name: create\n-- Notes: used by createCountTagsByParameterList\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT createCountTag(itemsite_id, , , , )\nFROM ( SELECT itemsite_id\n FROM itemsite JOIN item ON (item_id=itemsite_item_id)\n\n JOIN itemloc ON ( (itemloc_location_id=)\n AND (itemloc_itemsite_id = itemsite_id)\n AND (validLocation(, itemsite_id)) )\n\n WHERE (itemsite_active)\n AND (item_active)\n\n AND (itemsite_warehous_id=)\n\n\n AND (item_classcode_id=)\n\n AND (item_classcode_id IN (SELECT classcode_id\n FROM classcode\n WHERE (classcode_code ~ )))\n\n\n AND (itemsite_plancode_id=)\n\n AND (itemsite_plancode_id IN (SELECT plancode_id\n FROM plancode\n WHERE (plancode_code ~ )))\n\n\n AND (itemsite_qtyonhand <> 0.0)\n\n ORDER BY item_number ) AS data;\n admin 2015-10-01 0 47 countTags detail used by dspCountTagsByClassCode, dspCountTagsByItem, dspCountTagsByWarehouse\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: countTags\n-- Name: detail\n-- Notes: used by dspCountTagsByClassCode, dspCountTagsByItem, dspCountTagsByWarehouse\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT invcnt_id, invcnt_tagnumber, warehous_code,\n item_number, (item_descrip1 || item_descrip2) AS item_descrip,\n invcnt_tagdate,\n CASE WHEN invcnt_tagdate IS NOT NULL THEN invcnt_tag_username\n END AS creator,\n invcnt_cntdate,\n CASE WHEN invcnt_cntdate IS NOT NULL THEN invcnt_cnt_username\n END AS counter,\n invcnt_postdate,\n CASE WHEN invcnt_postdate IS NOT NULL THEN invcnt_post_username\n END AS poster,\n CASE WHEN (NOT invcnt_posted) THEN NULL\n ELSE invcnt_qoh_before\n END AS qohbefore,\n invcnt_qoh_after,\n CASE WHEN (NOT invcnt_posted) THEN NULL\n ELSE (invcnt_qoh_after - invcnt_qoh_before)\n END AS variance,\n CASE WHEN (NOT invcnt_posted) THEN NULL\n WHEN ((invcnt_qoh_before = 0) AND (invcnt_qoh_after = 0)) THEN 0\n WHEN (invcnt_qoh_before = 0) THEN 1\n ELSE ((1 - (invcnt_qoh_after / invcnt_qoh_before)) * -1)\n END AS percent,\n 'qty' AS qohbefore_xtnumericrole,\n 'qty' AS invcnt_qoh_after_xtnumericrole,\n 'qty' AS variance_xtnumericrole,\n 'percent' AS percent_xtnumericrole \nFROM invcnt, itemsite, item, whsinfo\nWHERE ((invcnt_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (DATE(invcnt_tagdate) BETWEEN \n AND )\n\n AND invcnt_posted\n\n\n AND (itemsite_warehous_id=)\n\n\n AND (item_classcode_id=)\n\n AND (item_classcode_id IN (SELECT classcode_id\n FROM classcode\n WHERE (classcode_code ~ )))\n\n\n AND (item_id=)\n\n)\nORDER BY invcnt_tagdate;\n admin 2015-10-01 0 48 creditCards detail used by cashReceipt, customer, salesOrder\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: creditCards\n-- Name: detail\n-- Notes: used by cashReceipt, customer, salesOrder\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT ccard_id, ccard_seq,\n CASE WHEN (ccard_type='M') THEN \n WHEN (ccard_type='V') THEN \n WHEN (ccard_type='A') THEN \n WHEN (ccard_type='D') THEN \n ELSE \n END AS type,\n formatccnumber(decrypt(setbytea(ccard_number),\n setbytea(), 'bf')) AS f_number,\n ccard_active,\n formatbytea(decrypt(setbytea(ccard_name),\n setbytea(), 'bf')) AS ccard_name,\n formatbytea(decrypt(setbytea(ccard_month_expired),\n setbytea(), 'bf')) ||\n '-' ||\n formatbytea(decrypt(setbytea(ccard_year_expired),\n setbytea(),\n 'bf')) AS expiration \nFROM ccard \nWHERE ((ccard_cust_id=) \n\n AND (ccard_type=)\n\n\n AND (ccard_active)\n\n)\nORDER BY ccard_seq;\n admin 2015-10-01 0 310 creditMemo editlist used by creditMemoEditList\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: creditMemo\n-- Name: editlist\n-- Notes: used by creditMemoEditList\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n ('C/M-' || formatCreditMemoNumber(cmhead_id)) AS docnumber,\n currConcat(curr_id) AS currabbr,\n CASE WHEN seq != 0 THEN ''\n END AS docnumber_qtdisplayrole,\n 'qty' AS qtytobill_xtnumericrole,\n 'price' AS price_xtnumericrole,\n 'curr' AS extprice_xtnumericrole,\n CASE WHEN namedescrip = THEN 'error' END AS qtforegroundrole\nFROM (\n\nSELECT cmhead_id, -1 AS altid,\n cmhead_number AS ordernumber,\n cust_number AS custitemnumber,\n cmhead_billtoname AS namedescrip,\n CAST(NULL AS TEXT) AS uom_name,\n CAST(NULL AS NUMERIC) AS qtytobill,\n CAST(NULL AS NUMERIC) AS price,\n CAST(NULL AS NUMERIC) AS extprice,\n cmhead_curr_id AS curr_id,\n 0 AS cmitem_linenumber, 0 AS xtindentrole, 0 AS seq\nFROM cmhead JOIN custinfo ON (cmhead_cust_id=cust_id)\nWHERE ((NOT cmhead_posted)\n AND (NOT cmhead_hold))\n\nUNION\nSELECT cmhead_id, cmitem_id,\n NULL, item_number,\n item_descrip1,\n uom_name, cmitem_qtycredit * cmitem_qty_invuomratio,\n cmitem_unitprice / cmitem_price_invuomratio,\n cmitem_qtycredit * cmitem_qty_invuomratio * cmitem_unitprice / cmitem_price_invuomratio,\n cmhead_curr_id AS curr_id,\n cmitem_linenumber, 1 AS xtindentrole, 1 AS seq\nFROM cmhead, cmitem, itemsite, item, uom\nWHERE ((NOT cmhead_posted)\n AND (NOT cmhead_hold)\n AND (cmhead_id=cmitem_cmhead_id)\n AND (cmitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id))\n\nUNION\nSELECT cmhead_id, -1,\n NULL, ,\n COALESCE((SELECT formatGLAccountLong(accnt_id)\n FROM accnt, salesaccnt\n WHERE ((salesaccnt_sales_accnt_id=accnt_id)\n AND (salesaccnt_id=findSalesAccnt(itemsite_id, 'IS', cmhead_cust_id,\n cmhead_saletype_id, cmhead_shipzone_id)))), ),\n NULL, NULL, NULL,\n cmitem_qtycredit * cmitem_qty_invuomratio * cmitem_unitprice / cmitem_price_invuomratio,\n cmhead_curr_id AS curr_id,\n cmitem_linenumber, 2 AS xtindentrole, 2 AS seq\nFROM cmhead, cmitem, itemsite, item, uom\nWHERE ((NOT cmhead_posted)\n AND (NOT cmhead_hold)\n AND (cmhead_id=cmitem_cmhead_id)\n AND (cmitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id))\n\nUNION\nSELECT cmhead_id, -1,\n NULL, ,\n CASE WHEN (accnt_id IS NULL) THEN \n ELSE formatGLAccountLong(accnt_id)\n END,\n NULL, NULL, cmhead_freight,\n cmhead_freight,\n cmhead_curr_id AS curr_id,\n 99999, 1 AS xtindentrole, 3 AS seq\nFROM cmhead LEFT OUTER JOIN accnt ON (accnt_id=findFreightAccount(cmhead_cust_id))\nWHERE ((NOT cmhead_posted)\n AND (NOT cmhead_hold)\n AND (cmhead_freight <> 0))\n\nUNION\nSELECT cmhead_id, -1,\n NULL, ,\n formatGLAccountLong(cmhead_misc_accnt_id),\n NULL, NULL, cmhead_misc,\n cmhead_misc,\n cmhead_curr_id AS curr_id,\n 99999, 1 AS xtindentrole, 4 AS seq\nFROM cmhead LEFT OUTER JOIN accnt ON (accnt_id=findFreightAccount(cmhead_cust_id))\nWHERE ((NOT cmhead_posted)\n AND (NOT cmhead_hold)\n AND (cmhead_misc <> 0))\n\nUNION\nSELECT cmhead_id, -1,\n NULL, ,\n CASE WHEN (tax_sales_accnt_id IS NULL) THEN \n ELSE formatGLAccountLong(tax_sales_accnt_id)\n END,\n NULL, NULL, SUM(taxhist_tax * -1.0),\n SUM(taxhist_tax * -1.0),\n cmhead_curr_id AS curr_id,\n 99999, 1 AS xtindentrole, 5 AS seq\nFROM cmhead JOIN cmheadtax ON ((taxhist_parent_id=cmhead_id) AND (taxhist_tax <> 0.0))\n JOIN tax ON (tax_id=taxhist_tax_id)\nWHERE ((NOT cmhead_posted)\n AND (NOT cmhead_hold))\nGROUP BY cmhead_id, tax_sales_accnt_id, cmhead_curr_id\n\nUNION\nSELECT cmhead_id, -1,\n NULL, ,\n CASE WHEN (tax_sales_accnt_id IS NULL) THEN \n ELSE formatGLAccountLong(tax_sales_accnt_id)\n END,\n NULL, NULL, SUM(taxhist_tax * -1.0),\n SUM(taxhist_tax * -1.0),\n cmhead_curr_id AS curr_id,\n 99999, 1 AS xtindentrole, 5 AS seq\nFROM cmhead JOIN cmitem ON (cmitem_cmhead_id=cmhead_id)\n JOIN cmitemtax ON ((taxhist_parent_id=cmitem_id) AND (taxhist_tax <> 0.0))\n JOIN tax ON (tax_id=taxhist_tax_id)\nWHERE ((NOT cmhead_posted)\n AND (NOT cmhead_hold))\nGROUP BY cmhead_id, tax_sales_accnt_id, cmhead_curr_id\n\nUNION\nSELECT cmhead_id, -1,\n NULL, ,\n CASE WHEN (accnt_id IS NULL) THEN \n ELSE formatGLAccountLong(accnt_id)\n END,\n NULL, NULL, NULL,\n SUM((cmitem_qtycredit * cmitem_qty_invuomratio) *\n (cmitem_unitprice / cmitem_price_invuomratio)) +\n cmhead_freight + cmhead_misc +\n (SELECT COALESCE(SUM(taxhist_tax * -1.0), 0.0) FROM cmheadtax WHERE (taxhist_parent_id=cmhead_id)) +\n (SELECT COALESCE(SUM(taxhist_tax * -1.0), 0.0) FROM cmitem JOIN cmitemtax ON (taxhist_parent_id=cmitem_id)\n WHERE (cmitem_cmhead_id=cmhead_id))\n AS extprice,\n cmhead_curr_id AS curr_id,\n 99999, 1 AS xtindentrole, 6 AS seq\nFROM cmhead LEFT OUTER JOIN cmitem ON (cmhead_id=cmitem_cmhead_id)\n LEFT OUTER JOIN accnt ON (accnt_id=findARAccount(cmhead_cust_id))\nWHERE ((NOT cmhead_posted)\n AND (NOT cmhead_hold))\nGROUP BY cmhead_id, cmhead_cust_id, cmhead_freight, cmhead_misc, accnt_id, cmhead_curr_id\n\n) AS dummy\nORDER BY docnumber, cmitem_linenumber, seq;\n admin 2015-10-01 0 49 creditMemoCreditCards detail used by arWorkBench, returnAuthorization, returnAuthorizationWorkbench\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: creditMemoCreditCards\n-- Name: detail\n-- Notes: used by arWorkBench, returnAuthorization, returnAuthorizationWorkbench\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cmhead_number, cmhead_freight, cmhead_curr_id,\n SUM(ROUND((cmitem_qtycredit * cmitem_qty_invuomratio) * \n (cmitem_unitprice / cmitem_price_invuomratio), 2)) +\n cmhead_freight + cmhead_misc +\n COALESCE( (SELECT SUM(tax) * -1 AS tax FROM\n (SELECT ROUND(SUM(taxdetail_tax), 2) AS tax\n FROM tax\n JOIN calculateTaxDetailSummary('CM', , 'T') ON (taxdetail_tax_id=tax_id)\n GROUP BY tax_id) AS data), 0) AS total,\n COALESCE( (SELECT SUM(tax) * -1 AS tax FROM\n (SELECT ROUND(SUM(taxdetail_tax), 2) AS tax\n FROM tax\n JOIN calculateTaxDetailSummary('CM', , 'T') ON (taxdetail_tax_id=tax_id)\n GROUP BY tax_id) AS data), 0) AS tax_in_cmcurr,\n ccard_id, ccard_seq, ccpay_id,\n cohead_number\nFROM ccard, cmitem, cmhead LEFT OUTER JOIN\n rahead ON (cmhead_rahead_id=rahead_id) LEFT OUTER JOIN\n cohead ON (rahead_orig_cohead_id=cohead_id) LEFT OUTER JOIN\n ccpay ON (ccpay_order_number=cohead_number AND ccpay_type='C')\nWHERE ((cmitem_cmhead_id=cmhead_id)\n AND (cmhead_cust_id=ccard_cust_id)\n AND (ccard_active)\n AND (ccpay_ccard_id=ccard_id OR ccpay_ccard_id IS NULL)\n AND (cmhead_id=))\nGROUP BY cmhead_number, cmhead_curr_id, cmhead_freight,\n cmhead_misc, ccard_id, ccard_seq, ccpay_id,\n\t cohead_number\nORDER BY ccpay_id DESC, ccard_seq \nLIMIT 1;\n admin 2015-10-01 0 114 crm strictcountrycheck select details about countries used throughout the database\n that do not match country.country_name\n\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: crm\n-- Name: strictcountrycheck\n-- Notes: select details about countries used throughout the database\n-- that do not match country.country_name\n--\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT SUM(counter) AS counter FROM (\n\n SELECT COUNT(*) AS counter\n addr_id, 'Address' AS type, addr_number AS number, addr_country AS country, '' AS detail\n \n FROM addr\n WHERE addr_country != ''\n AND addr_country NOT IN (SELECT country_name\n FROM country\n WHERE country_name IS NOT NULL)\n UNION ALL\n SELECT COUNT(*)\n cmhead_id, 'Credit Memo', cmhead_number, cmhead_billtocountry, 'Bill-To'\n \n FROM cmhead\n WHERE cmhead_billtocountry != ''\n AND cmhead_billtocountry NOT IN (SELECT country_name\n FROM country\n WHERE country_name IS NOT NULL)\n AND (NOT cmhead_posted) \n UNION ALL\n SELECT COUNT(*)\n cmhead_id, 'Credit Memo', cmhead_number, cmhead_billtocountry, 'Ship-To'\n \n FROM cmhead\n WHERE cmhead_shipto_country != ''\n AND cmhead_shipto_country NOT IN (SELECT country_name\n FROM country\n WHERE country_name IS NOT NULL)\n AND (NOT cmhead_posted) \n UNION ALL\n SELECT COUNT(*)\n invchead_id, 'Invoice', invchead_invcnumber, invchead_billto_country, 'Bill-To'\n \n FROM invchead\n WHERE invchead_billto_country != ''\n AND invchead_billto_country NOT IN (SELECT country_name\n FROM country\n WHERE country_name IS NOT NULL)\n AND (NOT invchead_posted) \n UNION ALL\n SELECT COUNT(*)\n invchead_id, 'Invoice', invchead_invcnumber, invchead_shipto_country, 'Ship-To'\n \n FROM invchead\n WHERE invchead_shipto_country != ''\n AND invchead_shipto_country NOT IN (SELECT country_name\n FROM country\n WHERE country_name IS NOT NULL)\n AND (NOT invchead_posted) \n UNION ALL\n SELECT COUNT(*)\n quhead_id, 'Quote', quhead_number, quhead_billtocountry, 'Bill-To'\n \n FROM quhead\n WHERE quhead_billtocountry != ''\n AND quhead_billtocountry NOT IN (SELECT country_name\n FROM country\n WHERE country_name IS NOT NULL)\n AND (quhead_expire>=CURRENT_DATE) \n UNION ALL\n SELECT COUNT(*)\n quhead_id, 'Quote', quhead_number, quhead_shiptocountry, 'Ship-To'\n \n FROM quhead\n WHERE quhead_shiptocountry != ''\n AND quhead_shiptocountry NOT IN (SELECT country_name\n FROM country\n WHERE country_name IS NOT NULL)\n AND (quhead_expire>=CURRENT_DATE) \n UNION ALL\n SELECT COUNT(*)\n cohead_id, 'Sales Order', cohead_number, cohead_billtocountry, 'Bill-To'\n \n FROM cohead\n WHERE cohead_billtocountry != ''\n AND cohead_billtocountry NOT IN (SELECT country_name\n FROM country\n WHERE country_name IS NOT NULL)\n \n AND cohead_id IN (SELECT coitem_cohead_id\n FROM coitem\n WHERE COALESCE(coitem_status, 'O')='O')\n \n UNION ALL\n SELECT COUNT(*)\n cohead_id, 'Sales Order', cohead_number, cohead_shiptocountry, 'Ship-To'\n \n FROM cohead\n WHERE cohead_shiptocountry != ''\n AND cohead_shiptocountry NOT IN (SELECT country_name\n FROM country\n WHERE country_name IS NOT NULL)\n \n AND cohead_id IN (SELECT coitem_cohead_id\n FROM coitem\n WHERE COALESCE(coitem_status, 'O')='O')\n \n\n\n) AS dummy;\n\n admin 2015-10-01 0 447 crmaccountmerge pickdatasources Show the records the user has selected to merge crm accounts. Emphasize\n the particular fields in each record that s/he has selected.\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: crmaccountmerge\n-- Name: pickdatasources\n-- Notes: Show the records the user has selected to merge crm accounts. Emphasize\n-- the particular fields in each record that s/he has selected.\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT c.crmacct_id,\n crmacctsel_dest_crmacct_id,\n c.crmacct_active,\n formatCntctName(c.crmacct_cntct_id_1) AS primary,\n formatCntctName(c.crmacct_cntct_id_2) AS secondary,\n c.crmacct_competitor_id IS NOT NULL AS competitor,\n c.crmacct_cust_id IS NOT NULL AS cust,\n c.crmacct_emp_id IS NOT NULL AS emp,\n c.crmacct_name,\n c.crmacct_number,\n c.crmacct_owner_username AS owner,\n p.crmacct_number AS parent,\n c.crmacct_partner_id IS NOT NULL AS partner,\n c.crmacct_prospect_id IS NOT NULL AS prospect,\n c.crmacct_salesrep_id IS NOT NULL AS salesrep,\n c.crmacct_taxauth_id IS NOT NULL AS taxauth,\n c.crmacct_type,\n c.crmacct_usr_username IS NOT NULL AS usr,\n c.crmacct_vend_id IS NOT NULL AS vend,\n trim(firstline(c.crmacct_notes)) AS notes,\n\n CASE crmacctsel_src_crmacct_id=crmacctsel_dest_crmacct_id\n WHEN true THEN '#ccc'\n END AS qtbackgroundrole,\n\n CASE WHEN c.crmacct_active IS NULL THEN END AS crmacct_active_qtdisplayrole,\n CASE WHEN COALESCE(formatCntctName(c.crmacct_cntct_id_1), '') = '' THEN END AS primary_qtdisplayrole,\n CASE WHEN COALESCE(formatCntctName(c.crmacct_cntct_id_2), '') = '' THEN END AS secondary_qtdisplayrole,\n CASE WHEN COALESCE(c.crmacct_name, '') = '' THEN END AS crmacct_name_qtdisplayrole,\n CASE WHEN COALESCE(c.crmacct_number, '') = '' THEN END AS crmacct_number_qtdisplayrole,\n CASE WHEN COALESCE(c.crmacct_owner_username, '') = '' THEN END AS owner_qtdisplayrole,\n CASE WHEN COALESCE(p.crmacct_number, '') = '' THEN END AS parent_qtdisplayrole,\n CASE c.crmacct_type WHEN 'I' THEN \n WHEN 'O' THEN \n ELSE END AS crmacct_type_qtdisplayrole,\n CASE WHEN COALESCE(TRIM(firstline(c.crmacct_notes)), '') = '' THEN END AS notes_qtdisplayrole,\n\n CASE WHEN crmacctsel_mrg_crmacct_number THEN 'emphasis' END AS crmacct_number_qtforegroundrole,\n CASE WHEN crmacctsel_mrg_crmacct_active THEN 'emphasis' END AS crmacct_active_qtforegroundrole,\n CASE WHEN crmacctsel_mrg_crmacct_cntct_id_1 THEN 'emphasis' END AS primary_qtforegroundrole,\n CASE WHEN crmacctsel_mrg_crmacct_cntct_id_2 THEN 'emphasis' END AS secondary_qtforegroundrole,\n CASE WHEN crmacctsel_mrg_crmacct_competitor_id THEN 'emphasis' END AS competitor_qtforegroundrole,\n CASE WHEN crmacctsel_mrg_crmacct_cust_id THEN 'emphasis' END AS cust_qtforegroundrole,\n CASE WHEN crmacctsel_mrg_crmacct_emp_id THEN 'emphasis' END AS emp_qtforegroundrole,\n CASE WHEN crmacctsel_mrg_crmacct_name THEN 'emphasis' END AS crmacct_name_qtforegroundrole,\n CASE WHEN crmacctsel_mrg_crmacct_owner_username THEN 'emphasis' END AS owner_qtforegroundrole,\n CASE WHEN crmacctsel_mrg_crmacct_parent_id THEN 'emphasis' END AS parent_qtforegroundrole,\n CASE WHEN crmacctsel_mrg_crmacct_partner_id THEN 'emphasis' END AS partner_qtforegroundrole,\n CASE WHEN crmacctsel_mrg_crmacct_prospect_id THEN 'emphasis' END AS prospect_qtforegroundrole,\n CASE WHEN crmacctsel_mrg_crmacct_salesrep_id THEN 'emphasis' END AS salesrep_qtforegroundrole,\n CASE WHEN crmacctsel_mrg_crmacct_taxauth_id THEN 'emphasis' END AS taxauth_qtforegroundrole,\n CASE WHEN crmacctsel_mrg_crmacct_type THEN 'emphasis' END AS crmacct_type_qtforegroundrole,\n CASE WHEN crmacctsel_mrg_crmacct_usr_username THEN 'emphasis' END AS usr_qtforegroundrole,\n CASE WHEN crmacctsel_mrg_crmacct_vend_id THEN 'emphasis' END AS vend_qtforegroundrole,\n CASE WHEN crmacctsel_mrg_crmacct_notes THEN 'emphasis' END AS notes_qtforegroundrole,\n\n c.crmacct_cntct_id_1 AS primary_xtidrole,\n c.crmacct_cntct_id_2 AS secondary_xtidrole,\n c.crmacct_cust_id AS cust_xtidrole,\n c.crmacct_emp_id AS emp_xtidrole,\n c.crmacct_parent_id AS parent_xtidrole,\n c.crmacct_prospect_id AS prospect_xtidrole,\n c.crmacct_salesrep_id AS salesrep_xtidrole,\n c.crmacct_taxauth_id AS taxauth_xtidrole,\n c.crmacct_usr_username AS usr_xtidrole,\n c.crmacct_vend_id AS vend_xtidrole,\n\n c.crmacct_notes AS notes_qttooltiprole\n\n FROM crmacct c\n JOIN crmacctsel ON (c.crmacct_id=crmacctsel_src_crmacct_id)\n LEFT OUTER JOIN crmacct p ON (c.crmacct_parent_id=p.crmacct_id)\n WHERE crmacctsel_dest_crmacct_id=\n ORDER BY qtbackgroundrole DESC, c.crmacct_number;\n admin 2015-10-01 0 448 crmaccountmerge wip show an indented list of crm account merges that have\n data to purge. this includes those that have been started\n but not completed as well as those that have been completed\n but neither purged nor undone.\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: crmaccountmerge\n-- Name: wip\n-- Notes: show an indented list of crm account merges that have\n-- data to purge. this includes those that have been started\n-- but not completed as well as those that have been completed\n-- but neither purged nor undone.\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT\n d.crmacct_id, d.crmacct_id,\n d.crmacct_number, d.crmacct_name,\n d.crmacct_number AS destnumber,\n AS status,\n AS status_qtdisplayrole,\n 0 AS xtindentrole\n FROM crmacct d\n JOIN mrgundo ON (d.crmacct_id=mrgundo_base_id\n AND mrgundo_base_schema='public'\n AND mrgundo_base_table='crmacct')\n\n WHERE d.crmacct_id = \n\nUNION ALL\nSELECT s.crmacct_id, d.crmacct_id,\n s.crmacct_number, s.crmacct_name,\n d.crmacct_number AS destnumber,\n AS status,\n AS status_qtdisplayrole,\n\n 0\n\n 1\n\n FROM crmacct s\n JOIN mrgundo ON (mrgundo_schema='public'\n AND mrgundo_table='crmacct'\n AND mrgundo_pkey_col='crmacct_id'\n AND mrgundo_pkey_id=s.crmacct_id\n AND mrgundo_col IS NULL)\n JOIN crmacct d ON (mrgundo_base_id=d.crmacct_id\n AND mrgundo_base_schema='public')\n\n WHERE d.crmacct_id = \n\nUNION\nSELECT s.crmacct_id, d.crmacct_id,\n s.crmacct_number, s.crmacct_name,\n d.crmacct_number AS destnumber, \n AS status,\n AS status_qtdisplayrole,\n CASE WHEN s.crmacct_id=d.crmacct_id THEN 0\n ELSE 1\n END\n FROM crmacct d\n JOIN crmacctsel ON (d.crmacct_id=crmacctsel_dest_crmacct_id)\n JOIN crmacct s ON (crmacctsel_src_crmacct_id=s.crmacct_id)\n\n WHERE d.crmacct_id = \n\n\nORDER BY destnumber, xtindentrole, crmacct_number;\n admin 2015-10-01 0 239 crmaccounts detail \n Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: crmaccounts\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT ON (crmacct_number)\n crmacct_id AS id, crmacct_number, crmacct_name, crmacct_owner_username, crmacct_active,\n cntct.*, addr.*,\n (crmacct_cust_id IS NOT NULL) AS cust,\n (crmacct_prospect_id IS NOT NULL) AS prospect,\n (crmacct_vend_id IS NOT NULL) AS vend,\n (crmacct_competitor_id IS NOT NULL) AS competitor,\n (crmacct_partner_id IS NOT NULL) AS partner,\n (crmacct_taxauth_id IS NOT NULL) AS taxauth,\n (crmacct_usr_username IS NOT NULL) AS usr,\n (crmacct_emp_id IS NOT NULL) AS emp,\n (crmacct_salesrep_id IS NOT NULL) AS salesrep\n\n , charass_alias.charass_value AS char\n\n\n , charass_alias.charass_value AS char\n\n\n , charass_alias.charass_value::date AS char\n\nFROM crmacct() LEFT OUTER JOIN\n cntct ON (crmacct_cntct_id_1=cntct_id) LEFT OUTER JOIN\n addr ON (cntct_addr_id=addr_id) \n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='CRMACCT') \n AND (charass_alias.charass_target_id=crmacct_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='CRMACCT') \n AND (charass_alias.charass_target_id=crmacct_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='CRMACCT') \n AND (charass_alias.charass_target_id=crmacct_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\nWHERE true\n \n AND (crmacct_owner_username=) \n\n AND (crmacct_owner_username ~ ) \n\n \n AND crmacct_active \n\n\n AND ((crmacct_number ~* )\n OR (crmacct_name ~* )\n OR (COALESCE(cntct_first_name,'') || ' ' || COALESCE(cntct_last_name,'') ~* )\n OR (COALESCE(cntct_phone,'') || ' ' || COALESCE(cntct_phone2,'') || ' ' || COALESCE(cntct_fax,'') ~* )\n OR (COALESCE(cntct_email,'') ~* )\n OR (COALESCE(addr_line1,'') || ' ' || COALESCE(addr_line2,'') || ' ' || COALESCE(addr_line3,'') ~* )\n OR (COALESCE(addr_city,'') ~* )\n OR (COALESCE(addr_state,'') ~* )\n OR (COALESCE(addr_postalcode,'') ~* )\n OR (addr_country ~* ))\n\n\n AND (crmacct_number ~* )\n\n\n AND (crmacct_name ~* )\n\n\n AND (COALESCE(cntct_first_name,'') || ' ' || COALESCE(cntct_last_name,'') ~* )\n\n\n AND (COALESCE(cntct_phone,'') || ' ' || COALESCE(cntct_phone2,'') || ' ' || COALESCE(cntct_fax,'') ~* )\n\n\n AND (COALESCE(cntct_email,'') ~* )\n\n\n AND (COALESCE(addr_line1,'') || ' ' || COALESCE(addr_line2,'') || ' ' || COALESCE(addr_line3,'') ~* )\n\n\n AND (COALESCE(addr_city,'') ~* )\n\n\n AND (COALESCE(addr_state,'') ~* )\n\n\n AND (COALESCE(addr_postalcode,'') ~* )\n\n\n AND (COALESCE(addr_country,'') ~* )\n\n\n AND (crmacct_id=)\n\n\n\n\n AND (crmacct_id NOT IN (SELECT mrgundo_base_id\n FROM mrgundo\n WHERE (mrgundo_base_schema='public')\n AND (mrgundo_base_table='crmacct')\n UNION\n SELECT crmacctsel_src_crmacct_id\n FROM crmacctsel\n UNION\n SELECT crmacctsel_dest_crmacct_id\n FROM crmacctsel))\n\n\n AND CASE WHEN = 1 THEN crmacct_cust_id IS NOT NULL\n WHEN = 2 THEN crmacct_prospect_id IS NOT NULL\n WHEN = 3 THEN crmacct_vend_id IS NOT NULL\n WHEN = 4 THEN crmacct_competitor_id IS NOT NULL\n WHEN = 5 THEN crmacct_partner_id IS NOT NULL\n WHEN = 6 THEN crmacct_taxauth_id IS NOT NULL\n WHEN = 7 THEN crmacct_usr_username IS NOT NULL\n WHEN = 8 THEN crmacct_emp_id IS NOT NULL\n WHEN = 9 THEN crmacct_salesrep_id IS NOT NULL\n END\n\nORDER BY crmacct_number; admin 2015-10-01 0 95 currencyConversions detail used by currencyConversions\n the N in round(curr_rate, N) has to be SCALE - 1 of curr_rates\n NUMERIC(p, SCALE) type definition\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: currencyConversions\n-- Name: detail\n-- Notes: used by currencyConversions\n-- the N in round(curr_rate, N) has to be SCALE - 1 of curr_rates\n-- NUMERIC(p, SCALE) type definition\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT curr_rate_id, currConcat(curr_id) AS f_curr,\n\n round((1.0 / curr_rate),5) AS rate,\n\n round(curr_rate,5) AS rate,\n\n 'uomratio' AS rate_xtnumericrole,\n curr_effective, curr_expires\nFROM curr_symbol NATURAL JOIN curr_rate\nWHERE ( (curr_base = FALSE)\n AND (curr_expires >= )\n AND (curr_effective <= )\n\n AND (curr_id = )\n\n\n AND (currConcat(curr_id) ~ )\n\n )\nORDER BY f_curr, curr_effective, curr_expires;\n admin 2015-10-01 0 242 customers detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: customers\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT ON ( cust_number ) \n cust_id, cust_custtype_id, \n cust_active, cust_number, cust_name,\n custtype_code,\n bill_cntct.cntct_first_name AS bill_first_name,\n bill_cntct.cntct_last_name AS bill_last_name,\n bill_cntct.cntct_title AS bill_title,\n bill_cntct.cntct_phone AS bill_phone,\n bill_cntct.cntct_fax AS bill_fax,\n bill_cntct.cntct_email AS bill_email,\n bill_addr.addr_line1 AS bill_line1,\n bill_addr.addr_line2 AS bill_line2,\n bill_addr.addr_line3 AS bill_line3,\n bill_addr.addr_city AS bill_city,\n bill_addr.addr_state AS bill_state,\n bill_addr.addr_postalcode AS bill_postalcode,\n bill_addr.addr_country AS bill_country,\n corr_cntct.cntct_first_name AS corr_first_name,\n corr_cntct.cntct_last_name AS corr_last_name,\n corr_cntct.cntct_phone AS corr_phone,\n corr_cntct.cntct_fax AS corr_fax,\n corr_cntct.cntct_email AS corr_email,\n corr_addr.addr_line1 AS corr_line1,\n corr_addr.addr_line2 AS corr_line2,\n corr_addr.addr_line3 AS corr_line3,\n corr_addr.addr_city AS corr_city,\n corr_addr.addr_state AS corr_state,\n corr_addr.addr_postalcode AS corr_postalcode,\n corr_addr.addr_country AS corr_country\n\n , charass_alias.charass_value AS char\n\n\n , charass_alias.charass_value AS char\n\n\n , charass_alias.charass_value::date AS char\n\nFROM custinfo\n JOIN custtype ON (cust_custtype_id=custtype_id)\n LEFT OUTER JOIN cntct bill_cntct ON (cust_cntct_id=bill_cntct.cntct_id) \n LEFT OUTER JOIN addr bill_addr ON (bill_cntct.cntct_addr_id=bill_addr.addr_id)\n LEFT OUTER JOIN cntct corr_cntct ON (cust_corrcntct_id=corr_cntct.cntct_id) \n LEFT OUTER JOIN addr corr_addr ON (corr_cntct.cntct_addr_id=corr_addr.addr_id)\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='C') \n AND (charass_alias.charass_target_id=cust_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='C') \n AND (charass_alias.charass_target_id=cust_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='C') \n AND (charass_alias.charass_target_id=cust_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\nWHERE true\n \n AND cust_active \n\n\n AND ((cust_number ~* )\n OR (cust_name ~* )\n OR (custtype_code ~* )\n OR (COALESCE(bill_cntct.cntct_first_name,'') || ' ' || COALESCE(bill_cntct.cntct_last_name,'') ~* )\n OR (COALESCE(bill_cntct.cntct_phone,'') || ' ' || COALESCE(bill_cntct.cntct_phone2,'') || ' ' || COALESCE(bill_cntct.cntct_fax, '') ~* )\n OR (COALESCE(bill_cntct.cntct_email, '') ~* )\n OR (COALESCE(bill_addr.addr_line1,'') || ' ' || COALESCE(bill_addr.addr_line2,'') || ' ' || COALESCE(bill_addr.addr_line3,'') ~* )\n OR (COALESCE(bill_addr.addr_city,'') ~* )\n OR (COALESCE(bill_addr.addr_state,'') ~* )\n OR (COALESCE(bill_addr.addr_postalcode,'') ~* )\n OR (COALESCE(bill_addr.addr_country,'') ~* )\n OR (COALESCE(corr_cntct.cntct_first_name,'') || ' ' || COALESCE(corr_cntct.cntct_last_name,'') ~* )\n OR (COALESCE(corr_cntct.cntct_phone,'') || ' ' || COALESCE(corr_cntct.cntct_phone2,'') || ' ' || COALESCE(corr_cntct.cntct_fax, '') ~* )\n OR (COALESCE(corr_cntct.cntct_email, '') ~* )\n OR (COALESCE(corr_addr.addr_line1,'') || ' ' || COALESCE(corr_addr.addr_line2,'') || ' ' || COALESCE(corr_addr.addr_line3,'') ~* )\n OR (COALESCE(corr_addr.addr_city,'') ~* )\n OR (COALESCE(corr_addr.addr_state,'') ~* )\n OR (COALESCE(corr_addr.addr_postalcode,'') ~* )\n OR (COALESCE(corr_addr.addr_country,'') ~* ))\n\n\n AND (cust_number ~* )\n\n\n AND (cust_name ~* )\n\n\n AND (custtype_code ~* )\n\n\n AND (COALESCE(bill_cntct.cntct_first_name,'') || ' ' || COALESCE(bill_cntct.cntct_last_name, '') ~* \n OR COALESCE(corr_cntct.cntct_first_name,'') || ' ' || COALESCE(corr_cntct.cntct_last_name, '') ~* )\n\n\n AND (COALESCE(bill_cntct.cntct_phone,'') || ' ' || COALESCE(bill_cntct.cntct_phone2,'') || ' ' || COALESCE(bill_cntct.cntct_fax,'') ~* \n OR COALESCE(corr_cntct.cntct_phone,'') || ' ' || COALESCE(corr_cntct.cntct_phone2,'') || ' ' || COALESCE(corr_cntct.cntct_fax,'') ~* )\n\n\n AND (COALESCE(bill_cntct.cntct_email,'') ~* \n OR COALESCE(corr_cntct.cntct_email,'') ~* )\n\n\n AND (COALESCE(bill_addr.addr_line1,'') || ' ' || COALESCE(bill_addr.addr_line2,'') || ' ' || COALESCE(bill_addr.addr_line3,'') ~* \n OR COALESCE(corr_addr.addr_line1,'') || ' ' || COALESCE(corr_addr.addr_line2,'') || ' ' || COALESCE(corr_addr.addr_line3,'') ~* )\n\n\n AND (COALESCE(bill_addr.addr_city,'') ~* \n OR COALESCE(corr_addr.addr_city,'') ~* )\n\n\n AND (COALESCE(bill_addr.addr_state,'') ~* \n OR COALESCE(corr_addr.addr_state,'') ~* )\n\n\n AND (COALESCE(bill_addr.addr_postalcode,'') ~* \n OR COALESCE(corr_addr.addr_postalcode,'') ~* )\n\n\n AND (COALESCE(bill_addr.addr_country,'') ~* \n OR COALESCE(corr_addr.addr_country,'') ~* )\n\n\n AND (cust_salesrep_id = )\n\n\nORDER BY cust_number; \n admin 2015-10-01 0 439 customers statement used by printStatementsByCustomerType\nSELECT cust_id, (cust_number || '-' || cust_name) AS customer,\n findCustomerForm(cust_id, 'S') AS reportname\nFROM\n\n (SELECT araging_cust_id FROM araging(, true))AS data,\n\n custinfo, custtype, aropen\nWHERE (cust_custtype_id=custtype_id)\n AND (aropen_cust_id=cust_id)\n AND (aropen_open)\n\n AND (aropen_duedate < (CURRENT_DATE - ))\n\n\n AND (custtype_id=)\n\n AND (custtype_code ~ )\n\n\n AND (cust_id = araging_cust_id)\n\nGROUP BY cust_id, cust_number, cust_name\nHAVING (SUM((aropen_amount - aropen_paid) *\n CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1\n ELSE 1 END) > 0)\nORDER BY cust_number;\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: customers\n-- Name: statement\n-- Notes: used by printStatementsByCustomerType\n--SELECT cust_id, (cust_number || '-' || cust_name) AS customer,\n-- findCustomerForm(cust_id, 'S') AS reportname\n--FROM\n--\n-- (SELECT araging_cust_id FROM araging(, true))AS data,\n--\n-- custinfo, custtype, aropen\n--WHERE (cust_custtype_id=custtype_id)\n-- AND (aropen_cust_id=cust_id)\n-- AND (aropen_open)\n--\n-- AND (aropen_duedate < (CURRENT_DATE - ))\n--\n--\n-- AND (custtype_id=)\n--\n-- AND (custtype_code ~ )\n--\n--\n-- AND (cust_id = araging_cust_id)\n--\n--GROUP BY cust_id, cust_number, cust_name\n--HAVING (SUM((aropen_amount - aropen_paid) *\n-- CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1\n-- ELSE 1 END) > 0)\n--ORDER BY cust_number;\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT araging_cust_id AS cust_id,\n (araging_cust_number || '-' || araging_cust_name) AS customer,\n findCustomerForm(araging_cust_id, 'S') AS reportname\nFROM araging(, true)\nWHERE (true)\n\n AND (COALESCE(araging_duedate, startOfTime()) < (CURRENT_DATE - ))\n\n\n AND (araging_cust_custtype_id=)\n\n AND (araging_custtype_code ~ )\n\nGROUP BY araging_cust_id, araging_cust_number, araging_cust_name\nORDER BY araging_cust_number;\n admin 2015-10-01 0 243 depositesRegister detail used by dspDepositsRegister\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: depositesRegister\n-- Name: detail\n-- Notes: used by dspDepositsRegister\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT trans_id, trans_date, trans_source,\n CASE WHEN (trans_doctype='IN') THEN \n WHEN (trans_doctype='CM') THEN \n ELSE trans_doctype\n END AS doctype,\n trans_docnumber, firstLine(trans_notes) AS f_notes,\n (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS f_accnt,\n CASE WHEN (trans_amount < 0) THEN formatMoney(ABS(trans_amount))\n ELSE ''\n END AS f_debit,\n CASE WHEN (trans_amount < 0) THEN ABS(trans_amount)\n ELSE 0\n END AS debit,\n CASE WHEN (trans_amount > 0) THEN trans_amount\n ELSE 0\n END AS credit,\n (aropen_amount - aropen_paid) AS balance,\n currtobase(aropen_curr_id,(aropen_amount - aropen_paid),aropen_docdate) AS base_balance,\n currconcat(aropen_curr_id) AS currAbbr,\n 'curr' AS debit_xtnumericrole,\n 'curr' AS credit_xtnumericrole,\n 'curr' AS balance_xtnumericrole,\n 'curr' AS base_balance_xtnumericrole,\n 0 AS debit_xttotalrole,\n 0 AS credit_xttotalrole,\n 0 AS base_balance_xttotalrole\nFROM (\nSELECT gltrans_id AS trans_id, gltrans_date AS trans_date, gltrans_created AS trans_created,\n gltrans_source AS trans_source, gltrans_doctype AS trans_doctype, gltrans_sequence AS trans_sequence,\n gltrans_docnumber AS trans_docnumber, gltrans_notes AS trans_notes, gltrans_amount AS trans_amount,\n accnt_id, accnt_descrip,\n aropen_amount, aropen_paid, aropen_curr_id, aropen_docdate\nFROM gltrans LEFT OUTER JOIN aropen ON ((text(gltrans_docnumber) = 'I-' || text(aropen_docnumber))\n AND (aropen_doctype='I')), accnt\nWHERE ((gltrans_accnt_id=accnt_id)\n AND (gltrans_doctype = 'CR')\n AND (gltrans_date BETWEEN AND ) )\nUNION\nSELECT sltrans_id AS trans_id, sltrans_date AS trans_date, sltrans_created AS trans_created,\n sltrans_source AS trans_source, sltrans_doctype AS trans_doctype, sltrans_sequence AS trans_sequence,\n sltrans_docnumber AS trans_docnumber, sltrans_notes AS trans_notes, sltrans_amount AS trans_amount,\n accnt_id, accnt_descrip,\n aropen_amount, aropen_paid, aropen_curr_id, aropen_docdate\nFROM sltrans LEFT OUTER JOIN aropen ON ((text(sltrans_docnumber) = 'I-' || text(aropen_docnumber))\n AND (aropen_doctype='I')), accnt\nWHERE ((sltrans_accnt_id=accnt_id)\n AND (sltrans_doctype = 'CR')\n AND (sltrans_date BETWEEN AND ) )\n ) AS data\nORDER BY trans_created DESC, trans_sequence, trans_amount;\n admin 2015-10-01 0 244 detailedInventoryHistory detail used by dspDetailedInventoryHistoryByLocation, dspDetailedInventoryHistoryByLotSerial\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: detailedInventoryHistory\n-- Name: detail\n-- Notes: used by dspDetailedInventoryHistoryByLocation, dspDetailedInventoryHistoryByLotSerial\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n\n invhist_id, invhist_transdate, invhist_transtype,\n (invhist_ordtype || '-' || invhist_ordnumber) AS ordernumber,\n invhist_invuom,\n item_number, formatlotserialnumber(invdetail_ls_id) AS lotserial,\n CASE WHEN invhist_posted THEN invdetail_qty\n END AS transqty,\n CASE WHEN invhist_posted THEN invdetail_qty_before\n END AS qohbefore,\n CASE WHEN invhist_posted THEN invdetail_qty_after\n END AS qohafter,\n invhist_posted,\n 'qty' AS transqty_xtnumericrole,\n 'qty' AS qohbefore_xtnumericrole,\n 'qty' AS qohafter_xtnumericrole,\n CASE WHEN NOT invhist_posted THEN 'warning'\n END AS qtforegroundrole\n\n *\n\nFROM \n invdetail, invhist, itemsite, item\n \n lshist (,,,\n ,,,\n ,,1)\n \nWHERE (\n\n (invdetail_invhist_id=invhist_id)\n AND (invhist_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (invdetail_location_id=)\n AND (DATE(invhist_transdate) BETWEEN AND )\n AND (transType(invhist_transtype, ))\n\n (TRUE)\n\n )\n\nORDER BY invhist_transdate DESC, invhist_transtype\n\n;\n admin 2015-10-01 0 118 distributeInventory locations \n Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: distributeInventory\n-- Name: locations\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT id, type, locationname, defaultlocation,\n location_netable, location_usable, lotserial, f_expiration, expired,\n qty, qtytagged, (qty + qtytagged) AS balance,\n 'qty' AS qty_xtnumericrole,\n 'qty' AS qtytagged_xtnumericrole,\n 'qty' AS balance_xtnumericrole,\n CASE WHEN expired THEN 'error' END AS qtforegroundrole, \n CASE WHEN defaultlocation AND expired = false THEN 'altemphasis' \n WHEN expired THEN 'error' \n ELSE null END AS defaultlocation_qtforegroundrole, \n CASE WHEN expired THEN 'error' \n WHEN qty > 0 AND expired = false THEN 'altemphasis' \n ELSE null END AS qty_qtforegroundrole \nFROM ( \n \n SELECT location_id AS id, AS type,\n formatLocationName(location_id) AS locationname, location_whsezone_id,\n CASE WHEN ( = 'R' AND location_id=itemsite_recvlocation_id) THEN TRUE\n WHEN ( = 'I' AND location_id=itemsite_issuelocation_id) THEN TRUE\n WHEN ( = 'O' AND location_id=itemsite_location_id) THEN TRUE\n ELSE FALSE\n END AS defaultlocation,\n COALESCE(location_netable, true) AS location_netable,\n COALESCE(location_usable, true) AS location_usable,\n TEXT('') AS lotserial,\n TEXT() AS f_expiration, FALSE AS expired,\n qtyLocation(location_id, NULL, NULL, NULL,\n itemsite_id, itemlocdist_order_type, itemlocdist_order_id, itemlocdist_id) AS qty,\n itemlocdistQty(location_id, itemlocdist_id) AS qtytagged \n FROM itemlocdist, location, itemsite \n WHERE ( (itemlocdist_itemsite_id=itemsite_id)\n AND (itemsite_loccntrl)\n AND (itemsite_warehous_id=location_warehous_id)\n AND (validLocation(location_id, itemsite_id))\n AND (itemlocdist_id=) ) \n \n SELECT itemloc_id AS id, AS type,\n COALESCE(formatLocationName(location_id), \n ) AS locationname, location_whsezone_id,\n (location_id IS NOT NULL AND\n CASE WHEN ( = 'R' AND location_id=itemsite_recvlocation_id) THEN TRUE\n WHEN ( = 'I' AND location_id=itemsite_issuelocation_id) THEN TRUE\n WHEN ( = 'O' AND location_id=itemsite_location_id) THEN TRUE\n ELSE FALSE\n END) AS defaultlocation,\n COALESCE(location_netable, true) AS location_netable,\n COALESCE(location_usable, true) AS location_usable,\n ls_number AS lotserial,\n CASE WHEN (itemsite_perishable) THEN formatDate(itemloc_expiration)\n ELSE \n END AS f_expiration,\n CASE WHEN (itemsite_perishable) THEN (itemloc_expiration < CURRENT_DATE)\n ELSE FALSE \n END AS expired,\n qtyLocation(itemloc_location_id, itemloc_ls_id, itemloc_expiration,\n itemloc_warrpurc, itemsite_id, itemlocdist_order_type,\n itemlocdist_order_id, itemlocdist_id) AS qty,\n ( SELECT COALESCE(SUM(target.itemlocdist_qty), 0)\n FROM itemlocdist AS target\n WHERE ( (target.itemlocdist_source_type='I')\n AND (target.itemlocdist_source_id=itemloc_id)\n AND (target.itemlocdist_itemlocdist_id=source.itemlocdist_id)) ) AS qtytagged \n FROM itemlocdist AS source, itemsite, itemloc \n LEFT OUTER JOIN location ON (itemloc_location_id=location_id) \n LEFT OUTER JOIN ls ON (itemloc_ls_id=ls_id) \n WHERE ( (source.itemlocdist_itemsite_id=itemsite_id)\n AND (itemloc_itemsite_id=itemsite_id)\n AND (source.itemlocdist_id=) ) \n UNION \n SELECT location_id AS id, AS type,\n formatLocationName(location_id) AS locationname, location_whsezone_id,\n CASE WHEN ( = 'R' AND location_id=itemsite_recvlocation_id) THEN TRUE\n WHEN ( = 'I' AND location_id=itemsite_issuelocation_id) THEN TRUE\n WHEN ( = 'O' AND location_id=itemsite_location_id) THEN TRUE\n ELSE FALSE\n END AS defaultlocation,\n COALESCE(location_netable, true) AS location_netable,\n COALESCE(location_usable, true) AS location_usable,\n TEXT('') AS lotserial,\n TEXT() AS f_expiration, FALSE AS expired,\n qtyLocation(location_id, NULL, NULL, NULL,\n itemsite_id, itemlocdist_order_type, itemlocdist_order_id, itemlocdist_id) AS qty,\n itemlocdistQty(location_id, itemlocdist_id) AS qtytagged \n FROM itemlocdist, location, itemsite \n WHERE ( (itemlocdist_itemsite_id=itemsite_id)\n AND (itemsite_loccntrl)\n AND (itemsite_warehous_id=location_warehous_id)\n AND (validLocation(location_id, itemsite_id))\n AND (itemsite_id= ) \n AND (location_id NOT IN (SELECT DISTINCT itemloc_location_id\n FROM itemloc\n WHERE (itemloc_itemsite_id=itemsite_id)))\n AND (itemlocdist_id=) ) \n \n ) AS data \nWHERE ((TRUE) \n AND ( ( != 'I') OR ( = 'I' AND location_usable) )\n\n AND (qtytagged != 0) \n\n\n AND (qty > 0) \n\n\n AND (location_whsezone_id = )\n\n) ORDER BY locationname;\n admin 2015-10-01 0 465 employees detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: employees\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT emp_id, warehous_code, emp_active, emp_code, emp_number,\n cntct_first_name, cntct_last_name\n\n , charass_alias.charass_value AS char\n\n\n , charass_alias.charass_value AS char\n\n\n , charass_alias.charass_value::date AS char\n\nFROM emp\n LEFT OUTER JOIN cntct ON (emp_cntct_id=cntct_id)\n LEFT OUTER JOIN whsinfo ON (emp_warehous_id=warehous_id)\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='EMP') \n AND (charass_alias.charass_target_id=emp_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='EMP') \n AND (charass_alias.charass_target_id=emp_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='EMP') \n AND (charass_alias.charass_target_id=emp_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\nWHERE (true)\n\n AND (warehous_id=)\n\n \n AND emp_active \n\n\n AND ((emp_code ~* )\n OR (emp_number ~* )\n OR (COALESCE(cntct_first_name,'') || ' ' || COALESCE(cntct_last_name,'') ~* )\n OR (COALESCE(cntct_phone,'') || ' ' || COALESCE(cntct_phone2,'') || ' ' || COALESCE(cntct_fax,'') ~* )\n OR (COALESCE(cntct_email,'') ~* ))\n\n\nORDER BY emp_code;\n admin 2015-10-01 0 50 events detail used by eventManager\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: events\n-- Name: detail\n-- Notes: used by eventManager\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT evntlog_id, evntlog_ord_id, evntlog_newdate,\n evntlog_newvalue, warehous_code,\n evntlog_evnttime,\n evntlog_dispatched,\n evnttype_name, evntlog_number \n FROM evnttype, evntlog LEFT OUTER JOIN whsinfo ON (evntlog_warehous_id=warehous_id)\nWHERE ( (evntlog_evnttype_id=evnttype_id)\n AND (evntlog_username=)\n\n AND (warehous_id=)\n\n\n AND (evntlog_dispatched IS NULL)\n\n) \nORDER BY evntlog_evnttime;\n admin 2015-10-01 0 245 expiredInventory detail used by dspExpiredInventoryByClassCode\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: expiredInventory\n-- Name: detail\n-- Notes: used by dspExpiredInventoryByClassCode\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, itemloc_id, warehous_code, item_number, uom_name,\n ls_number, itemloc_expiration,\n itemloc_qty, costmethod, cost,\n noNeg(cost * itemloc_qty) AS value,\n 'qty' AS itemloc_qty_xtnumericrole,\n 'cost' AS cost_xtnumericrole,\n 'curr' AS value_xtnumericrole,\n 'red' AS qtforegroundrole \nFROM ( SELECT itemsite_id, itemloc_id, warehous_code, item_number,\n uom_name, ls_number,\n CASE WHEN ='Perishability' THEN \n itemloc_expiration\n ELSE itemloc_warrpurc\n END AS itemloc_expiration,\n itemloc_qty,\n CASE WHEN(itemsite_costmethod='A') THEN 'Average'\n WHEN(itemsite_costmethod='S') THEN 'Standard'\n WHEN(itemsite_costmethod='J') THEN 'Job'\n WHEN(itemsite_costmethod='N') THEN 'None'\n ELSE 'UNKNOWN'\n END AS costmethod,\n \n stdcost(itemsite_item_id) AS cost\n \n actcost(itemsite_item_id) AS cost\n \n (itemsite_value / CASE WHEN(itemsite_qtyonhand=0) THEN 1 ELSE itemsite_qtyonhand END) AS cost\n \n FROM itemloc, itemsite, item, whsinfo, uom, ls\n WHERE ((itemloc_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (itemloc_ls_id=ls_id)\n \n AND (itemsite_perishable)\n AND (itemloc_expiration < (CURRENT_DATE + ))\n \n AND (itemsite_warrpurc)\n AND (itemloc_warrpurc < (CURRENT_DATE + ))\n \n \n AND (itemsite_warehous_id=)\n \n \n AND (item_classcode_id=)\n \n AND (item_classcode_id IN (SELECT classcode_id\n FROM classcode\n WHERE classcode_code ~ ))\n \n )\n ) AS data\nORDER BY warehous_code, item_number;\n admin 2015-10-01 0 246 freightPrices detail used by dspFreightPricesByCustomer, dspFreightPricesByCustomerType\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: freightPrices\n-- Name: detail\n-- Notes: used by dspFreightPricesByCustomer, dspFreightPricesByCustomerType\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemid, sourcetype, ipshead_name, source, ipsfreight_qtybreak, ipsfreight_price,\n CASE WHEN (ipsfreight_type = 'F') THEN \n ELSE \n END AS method,\n currConcat(ipshead_curr_id) AS currConcat,\n warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia,\n 'qty' AS ipsfreight_qtybreak_xtnumericrole,\n AS ipsfreight_qtybreak_xtnullrole,\n 'salesprice' AS ipsfreight_price_xtnumericrole,\n AS warehous_code_xtnullrole,\n AS shipzone_name_xtnullrole,\n AS freightclass_code_xtnullrole,\n AS ipsfreight_shipvia_xtnullrole\nFROM (SELECT ipsfreight_id AS itemid, 1 AS sourcetype,\n ipshead_name,\n\n AS source,\n\n AS source,\n\n ipsfreight_qtybreak, ipsfreight_price,\n ipsfreight_type, ipshead_curr_id,\n warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\n FROM ipsass JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\n WHERE ((true)\n\n AND (ipsass_cust_id=)\n AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) = 0)\n\n AND (ipsass_custtype_id=)\n\n\n AND (ipshead_expires > CURRENT_DATE)\n\n\n AND (ipshead_effective <= CURRENT_DATE)\n\n )\n\n UNION\n\n SELECT ipsfreight_id AS itemid, 2 AS sourcetype,\n ipshead_name,\n\n AS source,\n\n AS source,\n\n ipsfreight_qtybreak, ipsfreight_price,\n ipsfreight_type, ipshead_curr_id,\n warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\n FROM ipsass\n\n JOIN custtype ON ((coalesce(length(ipsass_custtype_pattern), 0) > 0) AND\n (custtype_code ~ ipsass_custtype_pattern))\n\n JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n\n JOIN custinfo ON (cust_custtype_id=ipsass_custtype_id)\n\n LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\n WHERE ((true)\n\n AND (cust_id=)\n\n AND (custtype_id=)\n\n\n AND (ipshead_expires > CURRENT_DATE)\n\n\n AND (ipshead_effective <= CURRENT_DATE)\n\n )\n\n UNION\n\n SELECT ipsfreight_id AS itemid, 3 AS sourcetype,\n ipshead_name,\n\n AS source,\n\n ( || '-' || sale_name) AS source,\n\n ipsfreight_qtybreak, ipsfreight_price,\n ipsfreight_type, ipshead_curr_id,\n warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\n FROM\n\n custinfo JOIN custtype ON (custtype_id=cust_custtype_id)\n JOIN ipsass ON ((coalesce(length(ipsass_custtype_pattern), 0) > 0) AND\n (custtype_code ~ ipsass_custtype_pattern))\n JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n\n sale JOIN ipshead ON (ipshead_id=sale_ipshead_id)\n\n JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\n WHERE ((true)\n\n AND (cust_id=)\n\n AND (true)\n\n\n \n AND (ipshead_expires > CURRENT_DATE)\n \n AND (sale_enddate > CURRENT_DATE)\n \n\n\n \n AND (ipshead_effective <= CURRENT_DATE)\n \n AND (sale_startdate <= CURRENT_DATE)\n \n\n )\n\n\n UNION\n\n SELECT ipsfreight_id AS itemid, 4 AS sourcetype,\n ipshead_name, ( || '-' || sale_name) AS source,\n ipsfreight_qtybreak, ipsfreight_price,\n ipsfreight_type, ipshead_curr_id,\n warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\n FROM sale JOIN ipshead ON (ipshead_id=sale_ipshead_id)\n JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\n WHERE ((true)\n \n AND (sale_enddate > CURRENT_DATE)\n \n \n AND (sale_startdate <= CURRENT_DATE)\n \n )\n\n ) AS data\nORDER BY ipsfreight_qtybreak, ipsfreight_price;\n admin 2015-10-01 0 247 frozenItemSites detail used by dspFrozenItemSites\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: frozenItemSites\n-- Name: detail\n-- Notes: used by dspFrozenItemSites\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, warehous_code, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS descrip,\n COALESCE((SELECT invcnt_tagnumber\n FROM invcnt\n WHERE ((NOT invcnt_posted)\n AND (invcnt_itemsite_id=itemsite_id)) LIMIT 1), '') AS cnttag\nFROM itemsite, item, whsinfo\nWHERE ( (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (itemsite_freeze)\n\n AND (itemsite_warehous_id=)\n\n )\nORDER BY warehous_code, item_number;\n admin 2015-10-01 0 361 glseries checkeditable \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: glseries\n-- Name: checkeditable\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT gltrans_id \nFROM accnt, gltrans \n LEFT OUTER JOIN period ON (gltrans_date BETWEEN period_start AND period_end) \nWHERE ( (gltrans_accnt_id=accnt_id) \n AND (gltrans_sequence=) \n AND ( (gltrans_deleted) \n OR (period_closed) \n OR (gltrans_rec) \n OR (period_freeze AND NOT checkPrivilege('PostFrozenPeriod')) ) )\nLIMIT 1;\n admin 2015-10-01 0 249 glseries detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: glseries\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *, \n CASE WHEN _id = -1 THEN 0\n ELSE 1 END AS xtindentrole,\n CASE WHEN _id = -1 THEN _date\n END AS transdate, \n 'curr' AS debit_xtnumericrole,\n 'curr' AS credit_xtnumericrole \n FROM (SELECT DISTINCT \n _sequence AS sequence, \n -1 AS _id, \n _date, \n _source AS source, \n _journalnumber AS journalnumber,\n _doctype AS doctype, '' AS docnumber,\n -1 AS accnt_id, firstLine(_notes) AS accnt_id_qtdisplayrole,\n 0.0 AS amount,\n CAST(NULL AS NUMERIC) AS debit,\n CAST(NULL AS NUMERIC) AS credit,\n _posted AS posted \n FROM \n WHERE ( (true) \n \n AND (NOT gltrans_deleted) \n \n AND (_date BETWEEN \n AND )\n \n AND (_source=)\n \n \n AND (_journalnumber BETWEEN \n AND )\n \n ) \n UNION ALL \n SELECT _sequence AS sequence, \n _id, \n _date, \n NULL, NULL,\n NULL, _docnumber AS docnumber,\n accnt_id, (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS accnt_id_qtdisplayrole,\n _amount,\n CASE WHEN (_amount < 0) THEN (_amount * -1)\n END AS debit,\n CASE WHEN (_amount > 0) THEN _amount \n END AS credit,\n NULL AS posted \n FROM JOIN accnt ON (_accnt_id=accnt_id) \n WHERE ( (true) \n \n AND (NOT gltrans_deleted) \n \n AND (_date BETWEEN \n AND )\n \n AND (_source=)\n \n \n AND (_journalnumber BETWEEN \n AND )\n \n ) \n ) AS dummy \n ORDER BY sequence,\n xtindentrole, amount;\n admin 2015-10-01 0 133 gltransactions detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: gltransactions\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT gltrans_id, gltrans_accnt_id,gltrans_date,gltrans_created,gltrans_source,\n gltrans_doctype,gltrans_journalnumber,gltrans_posted,gltrans_username,\n CASE WHEN(gltrans_docnumber='Misc.' AND\n invhist_docnumber IS NOT NULL) THEN\n (gltrans_docnumber || ' - ' || invhist_docnumber)\n ELSE gltrans_docnumber\n END AS docnumber,\n firstLine(gltrans_notes) AS notes,\n (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n CASE WHEN (gltrans_amount < 0) THEN ABS(gltrans_amount)\n ELSE NULL\n END AS debit,\n CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n ELSE NULL\n END AS credit,\n CASE WHEN accnt_type IN ('A','E') THEN \n gltrans_amount * -1 \n ELSE gltrans_amount END AS running,\n 'curr' AS debit_xtnumericrole,\n 'curr' AS credit_xtnumericrole,\n 'curr' AS running_xtnumericrole,\n 0 AS running_xtrunningrole,\n gltrans_deleted AS xtdeletedrole,\n AS running_xtrunninginit \nFROM gltrans JOIN accnt ON (gltrans_accnt_id=accnt_id) \n LEFT OUTER JOIN invhist ON (gltrans_misc_id=invhist_id\n AND gltrans_docnumber='Misc.') \n\n JOIN company ON (accnt_company=company_number) \n\n\n JOIN prftcntr ON (accnt_profit=prftcntr_number) \n\n\n JOIN subaccnt ON (accnt_sub=subaccnt_number) \n\n\n JOIN subaccnttype ON (subaccnttype_code=accnt_subaccnttype_code) \n\nWHERE (\n\n \n (gltrans_date BETWEEN \n AND )\n \n (gltrans_date BETWEEN \n AND endoftime())\n \n\n \n (gltrans_date BETWEEN startoftime()\n AND )\n \n (gltrans_date BETWEEN startoftime()\n AND endoftime())\n \n\n\n AND (NOT gltrans_deleted)\n\n\n AND (company_id=)\n\n\n AND (prftcntr_id=)\n\n\n AND (accnt_number=)\n\n\n AND (subaccnt_id=)\n\n\n AND (subaccnttype_id=)\n\n\n AND (accnt_type= )\n\n\n AND (gltrans_accnt_id=)\n\n\n AND (gltrans_docnumber = case when = '' then \n gltrans_docnumber else \n end ) \n\n\n AND (gltrans_source=)\n\n) \nORDER BY\n\n gltrans_date,\n\n gltrans_created DESC,\n\n gltrans_sequence, gltrans_amount;\n admin 2015-10-01 0 100 incidents detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: incidents \n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT ON (incdt_number) incdt_id AS id,\nincdt_number, DATE(incdt_timestamp) AS incdt_timestamp,\ncrmacct_name,\nincdtcat_name, incdtseverity_name, \nincdtpriority_name, crmacct_name, \nCASE WHEN(incdt_status='N') THEN \nWHEN(incdt_status='F') THEN \nWHEN(incdt_status='C') THEN \nWHEN(incdt_status='A') THEN \nWHEN(incdt_status='R') THEN \nWHEN(incdt_status='L') THEN \nELSE incdt_status\nEND,\nincdt_assigned_username, incdt_owner_username,\nincdt_summary, cntct_name, incdt_updated::date AS incdt_updated,\nprj_number, incdt_public,\nitem_number,\n\nls_number,\n\nstatus_color AS qtbackgroundrole \n\n , charass_alias.charass_value AS char\n\n\n , charass_alias.charass_value AS char\n\n\n , charass_alias.charass_value::date AS char\n\nFROM crmacct, status, incdt()\n JOIN cntct ON (incdt_cntct_id=cntct_id)\n LEFT OUTER JOIN incdtcat ON (incdtcat_id=incdt_incdtcat_id) \n LEFT OUTER JOIN incdtseverity ON (incdtseverity_id=incdt_incdtseverity_id) \n LEFT OUTER JOIN incdtpriority ON (incdtpriority_id=incdt_incdtpriority_id) \n LEFT OUTER JOIN prj ON (incdt_prj_id=prj_id)\n LEFT OUTER JOIN item ON (item_id=incdt_item_id)\n\n LEFT OUTER JOIN ls ON (ls_id=incdt_ls_id)\n\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='INCDT') \n AND (charass_alias.charass_target_id=incdt_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='INCDT') \n AND (charass_alias.charass_target_id=incdt_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='INCDT') \n AND (charass_alias.charass_target_id=incdt_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\nWHERE ((incdt_crmacct_id=crmacct_id)\nAND (status_type='INCDT')\nAND (incdt_status=status_code)\n\nAND (status_seq IN (-1\n , \n ))\n\n \nAND (status_seq = ) \n\n \nAND (status_seq < ) \n\n \nAND (incdt_cntct_id = ) \n\n\nAND ( IN (incdt_assigned_username, incdt_owner_username))\n\n \nAND (incdt_owner_username=) \n\n\nAND (incdt_owner_username ~ ) \n\n \nAND (incdt_assigned_username=) \n\n\nAND (incdt_assigned_username ~ ) \n\n\nAND (incdt_incdtpriority_id IN (-1\n , \n ))\n\n\nAND (incdt_incdtcat_id IN (-1\n , \n ))\n\n \nAND (incdt_incdtcat_id=) \n \n \nAND (incdt_incdtseverity_id=) \n\n \nAND (incdt_crmacct_id=) \n \n \nAND (incdt_prj_id=) \n \n \nAND (incdt_public=) \n \n)\n \n \nAND ((incdt_number::text ~* )\nOR (incdt_summary ~* )\nOR (incdt_descrip ~* )\nOR (incdt_id IN (SELECT comment_source_id\nFROM comment\nWHERE((comment_source='INCDT')\nAND (comment_text ~* )))))\n\n\nAND (incdt_item_id=)\n\n\nAND (ls_number ~* )\n\n\nAND (incdt_id=)\n\nAND (incdt_timestamp BETWEEN COALESCE(, startOfTime()) AND COALESCE(, endOfTime())+1) \n\nORDER BY incdt_number;\n admin 2015-10-01 0 252 invalidBillsofMaterials detail used by dspInvalidBillsOfMaterials\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: invalidBillsofMaterials\n-- Name: detail\n-- Notes: used by dspInvalidBillsOfMaterials\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, parent.item_id AS pitem_id,\n component.item_id AS citem_id,\n warehous_id, warehous_code,\n parent.item_number AS parentitem,\n component.item_number AS componentitem,\n (component.item_descrip1 || ' ' || component.item_descrip2) AS descrip\nFROM bomitem, itemsite, item AS parent, item AS component, whsinfo\nWHERE ((bomitem_parent_item_id=parent.item_id)\n AND (bomitem_item_id=component.item_id)\n AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1))\n AND (itemsite_item_id=parent.item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (parent.item_type='M')\n AND (itemsite_wosupply)\n AND (itemsite_active)\n AND (component.item_id NOT IN ( SELECT itemsite_item_id\n FROM itemsite\n WHERE ((itemsite_warehous_id=warehous_id)\n AND (itemsite_active)) ) ) \n\n AND (warehous_id=)\n\n )\nORDER BY warehous_code, parentitem, componentitem;\n admin 2015-10-01 0 51 inventoryAvailability byCustOrSO query to get item availability by either customer id/type/pattern\n or by cohead_id\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: inventoryAvailability\n-- Name: byCustOrSO\n-- Notes: query to get item availability by either customer id/type/pattern\n-- or by cohead_id\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT id, altid, cohead_id,\n item_number, descrip, uom_name,\n qoh, sobalance, allocated, ordered,\n atshipping,\n CASE WHEN (xtindentrole=1) THEN\n\n coitem_qtyreserved\n\n (qoh + ordered - sobalance)\n\n WHEN (xtindentrole=2) THEN (qoh + ordered - sobalance)\n END AS orderavail,\n (qoh + ordered - allocated) AS totalavail,\n orderdate, duedate,\n reorderlevel,\n (xtindentrole - 1) AS xtindentrole, \n 'qty' AS qoh_xtnumericrole,\n 'qty' AS sobalance_xtnumericrole,\n 'qty' AS allocated_xtnumericrole,\n 'qty' AS ordered_xtnumericrole,\n 'qty' AS orderavail_xtnumericrole,\n 'qty' AS totalavail_xtnumericrole,\n 'qty' AS atshipping_xtnumericrole,\n CASE WHEN (pack_id IS NOT NULL) THEN 'altemphasis'\n END AS qtforegroundrole,\n CASE WHEN (qoh < 0) THEN 'error'\n WHEN (qoh < reorderlevel) THEN 'warning'\n END AS qoh_qtforegroundrole,\n CASE WHEN (\n\n coitem_qtyreserved < 0\n\n (qoh + ordered - sobalance) < 0\n\n ) THEN 'error'\n WHEN ((qoh + ordered - sobalance) <= reorderlevel) THEN 'warning'\n END AS orderavail_qtforegroundrole,\n CASE WHEN ((qoh + ordered - allocated) < 0) THEN 'error'\n WHEN ((qoh + ordered - allocated) <= reorderlevel) THEN 'warning'\n END AS totalavail_qtforegroundrole,\n CASE WHEN (xtindentrole = 2 AND (orderdate <= CURRENT_DATE)\n AND (descrip IN ('O','E','S','R'))) THEN 'error'\n END AS atshipping_qtforegroundrole,\n CASE WHEN (xtindentrole = 2 AND duedate<=CURRENT_DATE) THEN 'error'\n END AS orderdate_qtforegroundrole,\n CASE WHEN (xtindentrole = 2 AND duedate<=CURRENT_DATE) THEN 'error'\n END AS duedate_qtforegroundrole,\n\n CASE WHEN (coitem_qtyreserved > 0\n AND sobalance > coitem_qtyreserved) THEN 'emphasis'\n WHEN ((sobalance <> 0)\n AND ((sobalance - coitem_qtyreserved) = 0)) THEN 'altemphasis'\n END AS qtforegroundrole,\n\n CASE WHEN (xtindentrole = 2) THEN ''\n END AS sobalance_qtdisplayrole\nFROM (\n\n SELECT cohead_id AS id, -2 AS altid, cohead_id, cohead_number,\n cohead_number AS item_number,\n '' AS trueitem_number,\n (cust_number||'-'||cust_name) AS descrip,\n '' AS uom_name, CAST(NULL AS NUMERIC) AS qoh,\n CAST(NULL AS NUMERIC) AS sobalance,\n CAST(NULL AS NUMERIC) AS allocated,\n CAST(NULL AS NUMERIC) AS ordered,\n CAST(NULL AS NUMERIC) AS atshipping,\n CAST(NULL AS NUMERIC) AS coitem_qtyreserved,\n cohead_orderdate AS orderdate, MIN(coitem_scheddate) AS duedate,\n pack_id,\n CAST(NULL AS NUMERIC) AS reorderlevel,\n 0 AS xtindentrole\n FROM cohead\n LEFT OUTER JOIN pack ON (pack_head_type='SO' AND pack_head_id=cohead_id)\n JOIN custinfo ON (cohead_cust_id=cust_id)\n JOIN coitem ON (coitem_cohead_id=cohead_id)\n JOIN itemsite ON (coitem_itemsite_id=itemsite_id)\n WHERE ((coitem_status NOT IN ('C', 'X'))\n \n AND (cust_custtype_id=)\n \n AND (cust_custtype_id IN (SELECT custtype_id\n FROM custtype\n WHERE(custtype_code ~ )))\n \n )\n GROUP BY cohead_id, item_number, cust_number,\n cust_name, cohead_orderdate, pack_id, coitem_scheddate\n \n HAVING (MIN(noNeg(qtyAvailable(itemsite_id)) +\n qtyOrdered(itemsite_id, coitem_scheddate) -\n qtyAllocated(itemsite_id, coitem_scheddate)) < 0\n OR MIN(noNeg(qtyAvailable(itemsite_id)) +\n qtyOrdered(itemsite_id, coitem_scheddate) -\n noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned)) < 0\n )\n \n UNION\n\n SELECT itemsite_id AS id, coitem_id AS altid, cohead_id, cohead_number,\n item_number,\n item_number AS trueitem_number,\n (item_descrip1 || ' ' || item_descrip2) AS descrip,\n uom_name, noNeg(qtyAvailable(itemsite_id)) AS qoh,\n noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS sobalance,\n qtyAllocated(itemsite_id, coitem_scheddate) AS allocated,\n qtyOrdered(itemsite_id, coitem_scheddate) AS ordered,\n qtyatshipping(coitem_id) AS atshipping,\n itemuomtouom(item_id, coitem_qty_uom_id, null, coitem_qtyreserved) AS coitem_qtyreserved,\n CAST(NULL AS DATE) AS orderdate, coitem_scheddate AS duedate,\n CAST(NULL AS INTEGER) AS pack_id,\n CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel\n ELSE 0.0 END AS reorderlevel,\n 1 AS xtindentrole\n FROM cohead\n JOIN custinfo ON (cohead_cust_id=cust_id)\n , itemsite, item, uom, site(), coitem\n WHERE ((coitem_cohead_id=cohead_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (coitem_status NOT IN ('C', 'X'))\n\n AND (cohead_id=)\n\n AND (cust_custtype_id=)\n\n AND (cust_custtype_id IN (SELECT custtype_id\n FROM custtype\n WHERE(custtype_code ~ )))\n\n\n AND ((noNeg(qtyAvailable(itemsite_id)) + qtyOrdered(itemsite_id, coitem_scheddate) - qtyAllocated(itemsite_id, coitem_scheddate) < 0)\n OR (noNeg(qtyAvailable(itemsite_id)) + qtyOrdered(itemsite_id, coitem_scheddate) - noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) < 0))\n\n )\n\n UNION\n SELECT itemsite_id, -1, cohead_id, cohead_number,\n formatwonumber(wo_id),\n item_number AS trueitem_number,\n wo_status,\n NULL, NULL,\n noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS sobalance,\n NULL,\n noNeg((wo_qtyord-wo_qtyrcv)) AS ordered,\n NULL,\n NULL,\n wo_startdate, wo_duedate,\n NULL AS pack_id,\n CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel\n ELSE 0.0 END AS reorderlevel,\n 2 AS xtindentrole\n FROM cohead\n JOIN custinfo ON (cohead_cust_id=cust_id)\n , itemsite, item, uom, site(), coitem\n LEFT OUTER JOIN wo\n ON ((coitem_itemsite_id=wo_itemsite_id)\n AND (wo_status IN ('E','R','I'))\n AND (wo_qtyord-wo_qtyrcv > 0)\n AND (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned-qtyatshipping(coitem_id)) >\n (SELECT qtyAvailable(itemsite_id) FROM itemsite WHERE (itemsite_id=coitem_itemsite_id))))\n WHERE ((coitem_cohead_id=cohead_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (coitem_status NOT IN ('C', 'X'))\n \n AND (cohead_id=)\n \n AND (cust_custtype_id=)\n \n AND (cust_custtype_id IN (SELECT custtype_id\n FROM custtype\n WHERE(custtype_code ~ )))\n \n \n AND ((noNeg(qtyAvailable(itemsite_id)) + qtyOrdered(itemsite_id, coitem_scheddate) - qtyAllocated(itemsite_id, coitem_scheddate) < 0)\n OR (noNeg(qtyAvailable(itemsite_id)) + qtyOrdered(itemsite_id, coitem_scheddate) - noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) < 0))\n \n )\n\n) AS data\nORDER BY duedate, cohead_number, trueitem_number,\n xtindentrole;\n admin 2015-10-01 0 52 inventoryAvailability general \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: inventoryAvailability\n-- Name: general\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, altId,\n item_number, (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n uom_name,\n warehous_id, warehous_code, itemsite_leadtime,\n qoh, allocated, noNeg(qoh - allocated) AS unallocated, \n ordered, requests, reorderlevel, outlevel,\n (qoh - allocated + ordered) AS available,\n vend_number,\n 'qty' AS qoh_xtnumericrole,\n 'qty' AS allocated_xtnumericrole,\n 'qty' AS unallocated_xtnumericrole, \n 'qty' AS ordered_xtnumericrole,\n 'qty' AS requests_xtnumericrole,\n 'qty' AS reorderlevel_xtnumericrole,\n 'qty' AS outlevel_xtnumericrole,\n 'qty' AS available_xtnumericrole,\n \n 'grey' AS qoh_qtforegroundrole,\n \n CASE WHEN ((qoh - allocated + ordered) < 0) THEN 'error'\n WHEN ((qoh - allocated + ordered) <= reorderlevel) THEN 'warning'\n END AS available_qtforegroundrole\nFROM (SELECT \n \n DISTINCT\n \n itemsite_id,\n CASE WHEN (item_type IN ('P', 'O')) THEN 1\n WHEN (item_type IN ('M')) THEN 2\n ELSE 0\n END AS altId,\n item_number, item_descrip1, item_descrip2, item_inv_uom_id,\n warehous_id, warehous_code, itemsite_leadtime,\n qtyAvailable(itemsite_id) AS qoh,\n CASE WHEN itemsite_useparams THEN itemsite_reorderlevel\n ELSE 0.0\n END AS reorderlevel,\n CASE WHEN itemsite_useparams THEN itemsite_ordertoqty\n ELSE 0.0\n END AS outlevel,\n \n vend_number,\n \n NULL AS vend_number,\n \n \n qtyAllocated(itemsite_id, itemsite_leadtime) AS allocated,\n qtyOrdered(itemsite_id, itemsite_leadtime) AS ordered, \n qtypr(itemsite_id, itemsite_leadtime) AS requests\n \n qtyAllocated(itemsite_id, CAST( AS INTEGER)) AS allocated,\n qtyOrdered(itemsite_id, CAST( AS INTEGER)) AS ordered,\n qtypr(itemsite_id, CAST( AS INTEGER)) AS requests \n \n qtyAllocated(itemsite_id, ( - CURRENT_DATE)) AS allocated,\n qtyOrdered(itemsite_id, ( - CURRENT_DATE)) AS ordered,\n qtypr(itemsite_id, ( - CURRENT_DATE)) AS requests \n \n qtyAllocated(itemsite_id, , ) AS allocated,\n qtyOrdered(itemsite_id, , ) AS ordered,\n qtypr(itemsite_id, , ) AS requests\n \n FROM item, itemsite, whsinfo\n \n , vendinfo JOIN itemsrc ON (itemsrc_vend_id=vend_id)\n \n WHERE ( (itemsite_active)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n \n AND (warehous_id=)\n \n \n AND (item_id=)\n \n AND (item_classcode_id=)\n \n AND (item_classcode_id IN (SELECT classcode_id\n FROM classcode\n WHERE (classcode_code ~ )))\n \n AND (itemsite_plancode_id=)\n \n AND (itemsite_plancode_id IN (SELECT plancode_id\n FROM plancode\n WHERE (plancode_code ~ )))\n \n AND (item_id IN (SELECT itemgrpitem_item_id\n FROM itemgrpitem\n WHERE (itemgrpitem_itemgrp_id=)))\n \n AND (item_id IN (SELECT itemgrpitem_item_id\n FROM itemgrpitem, itemgrp\n WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n AND (itemgrp_name ~ ) ) ))\n \n AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n \n \n AND (itemsrc_item_id=item_id)\n \n \n AND (vend_id=)\n \n AND (vend_vendtype_id=)\n \n AND (vend_vendtype_id IN (SELECT vendtype_id\n FROM vendtype\n WHERE (vendtype_code ~ )))\n \n ) ) AS data, uom\nWHERE ((item_inv_uom_id=uom_id)\n\n AND ((qoh - allocated + ordered) <= reorderlevel) \n \n AND NOT ( ((qoh - allocated + ordered) = 0) AND (reorderlevel = 0))\n \n\n AND ((qoh - allocated + ordered) < 0) \n\n)\n\nORDER BY\n\n toNumeric(item_number, 999999999999999),\n\n vend_number,\n\n item_number, warehous_code DESC;\n admin 2015-10-01 0 253 inventoryAvailabilitybyWorkorder detail used by dspInventoryAvailabilityByWorkOrder\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: inventoryAvailabilitybyWorkorder\n-- Name: detail\n-- Notes: used by dspInventoryAvailabilityByWorkOrder\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *, 'qty' AS woinvav_qoh_xtnumericrole,\n 'qty' AS woinvav_balance_xtnumericrole,\n 'qty' AS woinvav_allocated_xtnumericrole,\n 'qty' AS woinvav_ordered_xtnumericrole,\n 'qty' AS woinvav_woavail_xtnumericrole,\n 'qty' AS woinvav_totalavail_xtnumericrole,\n CASE WHEN (woinvav_womatl_id) = -1 THEN 'altemphasis'\n WHEN (woinvav_qoh < 0) THEN 'error'\n WHEN (woinvav_qoh < woinvav_reorderlevel) THEN 'warning'\n WHEN ((woinvav_qoh - woinvav_balance) < 0) THEN 'altemphasis'\n WHEN ((woinvav_qoh - woinvav_allocated) < 0) THEN 'altemphasis'\n END AS woinvav_qoh_qtforegroundrole,\n CASE WHEN (woinvav_womatl_id) = -1 THEN 'altemphasis'\n WHEN ((woinvav_qoh + woinvav_ordered - woinvav_balance) < 0) THEN 'error'\n WHEN ((woinvav_qoh + woinvav_ordered - woinvav_balance) < woinvav_reorderlevel) THEN 'warning'\n END AS woinvav_woavail_qtforegroundrole,\n CASE WHEN (woinvav_womatl_id) = -1 THEN 'altemphasis'\n WHEN ((woinvav_qoh + woinvav_ordered - woinvav_allocated) < 0) THEN 'error'\n WHEN ((woinvav_qoh + woinvav_ordered - woinvav_allocated) < woinvav_reorderlevel) THEN 'warning'\n END AS woinvav_totalavail_qtforegroundrole,\n CASE WHEN (woinvav_womatl_id = -1) THEN 'altemphasis'\n ELSE null\n END AS qtforegroundrole,\n woinvav_level AS xtindentrole\nFROM woinvavail(,\n\n true,\n\n false,\n\n\n true,\n\n false,\n\n\n true,\n\n false,\n\n\n true\n\n false\n\n ) AS data;\n admin 2015-10-01 0 254 inventoryLocator detail used by dspInventoryLocator\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n Lot/Serial Characteristics additions by Specter Vision Solutions, Inc.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: inventoryLocator\n-- Name: detail\n-- Notes: used by dspInventoryLocator\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- Lot/Serial Characteristics additions by Specter Vision Solutions, Inc.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n AS locationname_xtnullrole,\n AS netable_xtnullrole,\n AS usable_xtnullrole,\n AS lotserial_xtnullrole,\n AS expiration_xtnullrole,\n AS warranty_xtnullrole,\n CASE WHEN (itemsite_perishable\n AND itemloc_expiration <= CURRENT_DATE) THEN 'error'\n WHEN (itemsite_warrpurc\n AND itemloc_warrpurc <= CURRENT_DATE) THEN 'error'\n END AS qtforegroundrole,\n 'qty' AS qoh_xtnumericrole\nFROM (SELECT itemloc_id, 1 AS type, warehous_code,\n itemsite_perishable, itemloc_expiration,\n itemsite_warrpurc, itemloc_warrpurc,\n CASE WHEN (location_id IS NOT NULL) THEN\n (formatLocationName(location_id) || '-' || firstLine(location_descrip))\n END AS locationname,\n CASE WHEN (location_id IS NOT NULL) THEN location_netable\n END AS netable,\n CASE WHEN (location_id IS NOT NULL) THEN location_usable\n END AS usable,\n CASE WHEN (itemsite_controlmethod IN ('L', 'S')) THEN\n formatlotserialnumber(itemloc_ls_id)\n END AS lotserial,\n CASE WHEN (itemsite_perishable) THEN itemloc_expiration\n END AS expiration,\n CASE WHEN (itemsite_warrpurc) THEN itemloc_warrpurc\n END AS warranty,\n itemloc_qty AS qoh\n\n , charass_alias.charass_value AS char\n\n\n , charass_alias.charass_value AS char\n\n\n , CASE WHEN (charass_alias.charass_value = '') THEN NULL::date\n ELSE charass_alias.charass_value::date \n END AS char\n\n FROM itemsite, whsinfo,\n itemloc LEFT OUTER JOIN location ON (itemloc_location_id=location_id)\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='LS')\n AND (charass_alias.charass_target_id=itemloc_ls_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='LS')\n AND (charass_alias.charass_target_id=itemloc_ls_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='LS')\n AND (charass_alias.charass_target_id=itemloc_ls_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\n WHERE ((itemsite_loccntrl OR (itemsite_controlmethod IN ('L', 'S')))\n AND (itemloc_itemsite_id=itemsite_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (itemsite_item_id=)\n \n AND (itemsite_warehous_id=)\n \n \n AND (itemsite_warehous_id=)\n \n \n AND (formatlotserialnumber(itemloc_ls_id)=)\n \n \n AND (formatLocationName(location_id)=)\n \n \n )\n UNION\n SELECT itemsite_id, 2 AS type, warehous_code,\n itemsite_perishable, NULL AS itemloc_expiration,\n itemsite_warrpurc, NULL AS itemloc_warrpurc,\n NULL AS locationname,\n NULL AS netable,\n NULL AS usable,\n NULL AS lotserial,\n NULL AS expiration,\n NULL AS warranty,\n itemsite_qtyonhand AS qoh\n\n , NULL AS char\n\n\n , NULL AS char\n\n\n , NULL AS char\n\n FROM itemsite, whsinfo\n WHERE ((NOT itemsite_loccntrl)\n AND (itemsite_controlmethod NOT IN ('L', 'S'))\n AND (itemsite_warehous_id=warehous_id)\n AND (itemsite_item_id=)\n \n AND (itemsite_warehous_id=)\n \n )\n ) AS dummy\nORDER BY warehous_code, locationname, lotserial;\n admin 2015-10-01 0 255 invoiceInformation detail used by dspInvoiceInformation\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: invoiceInformation\n-- Name: detail\n-- Notes: used by dspInvoiceInformation\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT arapply_id,\n CASE WHEN (arapply_source_doctype = 'C') THEN \n WHEN (arapply_source_doctype = 'R') THEN \n WHEN (arapply_fundstype='C') THEN \n WHEN (arapply_fundstype='T') THEN \n WHEN (arapply_fundstype='M') THEN \n WHEN (arapply_fundstype='V') THEN \n WHEN (arapply_fundstype='A') THEN \n WHEN (arapply_fundstype='D') THEN \n WHEN (arapply_fundstype='R') THEN \n WHEN (arapply_fundstype='K') THEN \n WHEN (arapply_fundstype='W') THEN \n WHEN (arapply_fundstype='O') THEN \n END AS doctype,\n CASE WHEN (arapply_source_doctype IN ('C','R')) THEN arapply_source_docnumber\n WHEN (arapply_source_doctype = 'K') THEN arapply_refnumber\n ELSE \n END AS docnumber,\n arapply_postdate, arapply_applied,\n currConcat(arapply_curr_id) AS currabbr,\n currToBase(arapply_curr_id, arapply_applied, arapply_postdate) AS baseapplied,\n 'curr' AS arapply_applied_xtnumericrole,\n 'curr' AS baseapplied_xtnumericrole\nFROM arapply\nWHERE ((arapply_target_doctype='I')\n AND (arapply_target_docnumber=))\nORDER BY arapply_postdate;\n admin 2015-10-01 0 256 invoiceRegister detail used by dspInvoiceRegister\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: invoiceRegister\n-- Name: detail\n-- Notes: used by dspInvoiceRegister\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT *\nFROM (\n-- G/L Transactions\nSELECT DISTINCT\n -1 AS gltrans_id, -1 AS altId,\n gltrans_date, '' AS gltrans_source,\n '' AS doctype, '' AS gltrans_docnumber,\n '' AS notes, '' AS account,\n CAST(NULL AS NUMERIC) AS debit,\n CAST(NULL AS NUMERIC) AS credit,\n 'curr' AS debit_xtnumericrole,\n 'curr' AS credit_xtnumericrole,\n 0 AS xtindentrole,\n gltrans_date AS transdate\nFROM gltrans\nWHERE ((gltrans_doctype IN ('IN', 'CM', 'DM', 'CD'))\n AND (gltrans_source = 'A/R')\n AND (gltrans_date BETWEEN AND )\n\n AND (gltrans_accnt_id=)\n\n )\n\nUNION\n-- Journals\nSELECT DISTINCT\n -1 AS gltrans_id, -1 AS altId,\n sltrans_date AS gltrans_date, '' AS gltrans_source,\n '' AS doctype, '' AS gltrans_docnumber,\n '' AS notes, '' AS account,\n CAST(NULL AS NUMERIC) AS debit,\n CAST(NULL AS NUMERIC) AS credit,\n 'curr' AS debit_xtnumericrole,\n 'curr' AS credit_xtnumericrole,\n 0 AS xtindentrole,\n sltrans_date AS transdate\nFROM sltrans\nWHERE ((sltrans_doctype IN ('IN', 'CM', 'DM', 'CD'))\n AND (sltrans_source = 'A/R')\n AND (sltrans_date BETWEEN AND )\n\n AND (sltrans_accnt_id=)\n\n )\n) AS data\n\nUNION\n-- G/L Transactions\nSELECT gltrans_id,\n CASE WHEN(gltrans_doctype='IN') THEN 1\n WHEN(gltrans_doctype='CM') THEN 2\n WHEN(gltrans_doctype='DM') THEN 3\n WHEN(gltrans_doctype='CD') THEN 4\n ELSE -1\n END AS altId,\n gltrans_date, gltrans_source,\n CASE WHEN(gltrans_doctype='IN') THEN \n WHEN(gltrans_doctype='CM') THEN \n WHEN(gltrans_doctype='DM') THEN \n WHEN(gltrans_doctype='CD') THEN \n ELSE gltrans_doctype\n END AS doctype,\n gltrans_docnumber,\n CASE WHEN(gltrans_doctype='IN') THEN\n (SELECT invchead_shipto_name\n FROM aropen LEFT OUTER JOIN\n invchead\n ON (invchead_id=aropen_cobmisc_id\n AND invchead_cust_id=aropen_cust_id)\n WHERE ((aropen_docnumber=gltrans_docnumber)\n AND (aropen_doctype='I')))\n ELSE firstLine(gltrans_notes)\n END AS f_notes,\n (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS f_accnt,\n CASE WHEN (gltrans_amount < 0) THEN ABS(gltrans_amount)\n ELSE 0\n END AS debit,\n CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n ELSE 0\n END AS credit,\n 'curr' AS debit_xtnumericrole,\n 'curr' AS credit_xtnumericrole,\n 1 AS xtindentrole,\n NULL AS transdate\nFROM gltrans, accnt\nWHERE ((gltrans_accnt_id=accnt_id)\n AND (gltrans_doctype IN ('IN', 'CM', 'DM', 'CD'))\n AND (gltrans_source = 'A/R')\n AND (gltrans_date BETWEEN AND )\n\n AND (gltrans_accnt_id=)\n\n )\n\nUNION\n-- Journals\nSELECT sltrans_id,\n CASE WHEN(sltrans_doctype='IN') THEN 1\n WHEN(sltrans_doctype='CM') THEN 2\n WHEN(sltrans_doctype='DM') THEN 3\n WHEN(sltrans_doctype='CD') THEN 4\n ELSE -1\n END AS altId,\n sltrans_date AS gltrans_date, sltrans_source AS gltrans_date,\n CASE WHEN(sltrans_doctype='IN') THEN \n WHEN(sltrans_doctype='CM') THEN \n WHEN(sltrans_doctype='DM') THEN \n WHEN(sltrans_doctype='CD') THEN \n ELSE sltrans_doctype\n END AS doctype,\n sltrans_docnumber AS gltrans_docnumber,\n CASE WHEN(sltrans_doctype='IN') THEN\n (SELECT invchead_shipto_name\n FROM aropen LEFT OUTER JOIN\n invchead\n ON (invchead_id=aropen_cobmisc_id\n AND invchead_cust_id=aropen_cust_id)\n WHERE ((aropen_docnumber=sltrans_docnumber)\n AND (aropen_doctype='I')))\n ELSE firstLine(sltrans_notes)\n END AS f_notes,\n (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS f_accnt,\n CASE WHEN (sltrans_amount < 0) THEN ABS(sltrans_amount)\n ELSE 0\n END AS debit,\n CASE WHEN (sltrans_amount > 0) THEN sltrans_amount\n ELSE 0\n END AS credit,\n 'curr' AS debit_xtnumericrole,\n 'curr' AS credit_xtnumericrole,\n 1 AS xtindentrole,\n NULL AS transdate\nFROM sltrans, accnt\nWHERE ((sltrans_accnt_id=accnt_id)\n AND (sltrans_doctype IN ('IN', 'CM', 'DM', 'CD'))\n AND (sltrans_source = 'A/R')\n AND (sltrans_date BETWEEN AND )\n\n AND (sltrans_accnt_id=)\n\n )\nORDER BY gltrans_date, gltrans_docnumber, xtindentrole;\n admin 2015-10-01 0 55 invoices detail used by reprintInvoices, unpostedInvoices, dspRecurringInvoices\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: invoices\n-- Name: detail\n-- Notes: used by reprintInvoices, unpostedInvoices, dspRecurringInvoices\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT invchead_id, cust_id,\n invchead.*,\n cust_number, cust_name,\n (TEXT(cust_number) || ' - ' || cust_name) AS customer,\n COALESCE(invchead_gldistdate, invchead_invcdate) AS gldistdate,\n invoicetotal(invchead_id) AS extprice,\n CASE WHEN (aropen_open) THEN (aropen_amount - aropen_paid)\n ELSE 0\n END AS balance,\n (invchead_recurring_invchead_id IS NOT NULL) AS isRecurring,\n recur_freq,\n recur_period,\n CASE WHEN (recur_period='D') THEN \n WHEN (recur_period='W') THEN \n WHEN (recur_period='M') THEN \n WHEN (recur_period='Y') THEN \n WHEN (recur_period='m') THEN \n WHEN (recur_period='H') THEN \n ELSE \n END AS recur_period_qtdisplayrole,\n recur_end,\n \n invchead_invcnumber AS docnumber,\n findCustomerForm(cust_id, 'I') AS reportname,\n \n CASE WHEN (calcInvoiceAmt(invchead_id,'S') != 0.0)\n THEN calcInvoiceAmt(invchead_id,'M')\n ELSE 0.0\n END AS margin,\n CASE WHEN (calcInvoiceAmt(invchead_id,'S') != 0.0)\n THEN (calcInvoiceAmt(invchead_id,'M') / calcInvoiceAmt(invchead_id,'S'))\n ELSE 1.0\n END AS marginpercent,\n 'percent' AS marginpercent_xtnumericrole,\n 'curr' AS margin_xtnumericrole,\n 'curr' AS extprice_xtnumericrole,\n 'curr' AS balance_xtnumericrole,\n CASE WHEN (aropen_id IS NULL) THEN 'Unposted' END AS balance_qtdisplayrole\nFROM invchead JOIN custinfo ON (cust_id=invchead_cust_id)\n LEFT OUTER JOIN aropen ON ( (aropen_doctype='I') AND (aropen_docnumber=invchead_invcnumber) )\n LEFT OUTER JOIN recur ON (invchead_recurring_invchead_id=recur_parent_id AND recur_parent_type='I')\nWHERE ( (true)\n\n AND (NOT invchead_posted)\n\n\n AND (invchead_posted)\n\n\n AND (invchead_recurring_invchead_id IS NOT NULL)\n\n\n AND (invchead_cust_id=)\n\n\n AND (invchead_invcdate BETWEEN AND )\n\n\n AND (invchead_invcnumber ~ )\n\n\n AND (aropen_open AND (aropen_amount - aropen_paid > 0))\n\n AND (checkInvoiceSitePrivs(invchead_id)) )\nORDER BY invchead_invcnumber\n;\n admin 2015-10-01 0 429 invoices print used by printInvoices\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: invoices\n-- Name: print\n-- Notes: used by printInvoices\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT invchead_id, invchead_id AS docid,\n invchead_invcnumber, invchead_invcnumber AS docnumber,\n invchead_ordernumber, invchead_posted AS posted,\n findCustomerForm(invchead_cust_id, 'I') AS reportname\n FROM invchead\n WHERE (NOT invchead_printed)\n AND (NOT invchead_posted)\n AND (checkInvoiceSitePrivs(invchead_id))\n\n AND (invchead_shipvia=) \n\nORDER BY invchead_ordernumber;\n admin 2015-10-01 0 475 issueToShipping detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: issueToShipping\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n noNeg(qtyord - qtyshipped + qtyreturned) AS balance,\n indent AS xtindentrole,\n 'qty' AS qtyord_xtnumericrole,\n 'qty' AS qtyshipped_xtnumericrole,\n 'qty' AS qtyreturned_xtnumericrole,\n 'qty' AS balance_xtnumericrole,\n 'qty' AS atshipping_xtnumericrole,\n CASE WHEN (scheddate > CURRENT_DATE AND\n noNeg(qtyord - qtyshipped + qtyreturned) <> atshipping) THEN 'future'\n WHEN (noNeg(qtyord - qtyshipped + qtyreturned) <> atshipping) THEN 'expired'\n END AS qtforegroundrole \nFROM (\n\nSELECT coitem_id AS lineitem_id, \n CASE WHEN (itemsite_costmethod = 'J') THEN 1 \n ELSE 0 \n END AS job, 0 AS indent,\n getOpenShipment('SO', , ) AS shiphead_number, \n formatSoLineNumber(coitem_id) AS linenumber, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n warehous_code,\n coitem_scheddate AS scheddate,\n uom_name,\n coitem_qtyord AS qtyord,\n coitem_qtyshipped AS qtyshipped,\n coitem_qtyreturned AS qtyreturned,\n qtyAtShipping(coitem_id) AS atshipping, \n coitem_scheddate AS seq1, coitem_linenumber AS seq2, coitem_subnumber AS seq3 \nFROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN site() ON (warehous_id=itemsite_warehous_id)\n JOIN uom ON (uom_id=coitem_qty_uom_id)\nWHERE ( (coitem_status NOT IN ('C','X'))\n AND (item_type != 'K')\n\n AND (itemsite_warehous_id=) \n\n AND (coitem_cohead_id=) ) \n\n\nUNION ALL\nSELECT coitem_id AS lineitem_id, \n CASE WHEN (itemsite_costmethod = 'J') THEN 1 \n ELSE 0 \n END AS job, 1 AS indent,\n '' AS shiphead_number, \n '' AS linenumber, formatLocationName(itemloc_location_id) AS item_number,\n formatLotSerialNumber(itemloc_ls_id) AS itemdescrip,\n '' AS warehous_code,\n NULL AS scheddate,\n '' AS uom_name,\n reserve_qty AS qtyord,\n NULL AS qtyshipped,\n NULL AS qtyreturned,\n NULL AS atshipping, \n coitem_scheddate AS seq1, coitem_linenumber AS seq2, coitem_subnumber AS seq3 \nFROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN site() ON (warehous_id=itemsite_warehous_id)\n JOIN reserve ON (reserve_demand_id=coitem_id AND\n reserve_demand_type='SO' AND\n reserve_supply_type='I')\n JOIN itemloc ON (itemloc_id=reserve_supply_id)\nWHERE ( (coitem_status NOT IN ('C','X'))\n AND (item_type != 'K')\n AND ((itemsite_controlmethod IN ('L', 'S')) OR (itemsite_loccntrl))\n\n AND (itemsite_warehous_id=) \n\n AND (coitem_cohead_id=) ) \nUNION ALL\nSELECT coitem_id AS lineitem_id, \n CASE WHEN (itemsite_costmethod = 'J') THEN 1 \n ELSE 0 \n END AS job, 1 AS indent,\n '' AS shiphead_number, \n '' AS linenumber, 'N/A',\n 'N/A' AS itemdescrip,\n '' AS warehous_code,\n NULL AS scheddate,\n '' AS uom_name,\n coitem_qtyreserved AS qtyord,\n NULL AS qtyshipped,\n NULL AS qtyreturned,\n NULL AS atshipping, \n coitem_scheddate AS seq1, coitem_linenumber AS seq2, coitem_subnumber AS seq3 \nFROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN site() ON (warehous_id=itemsite_warehous_id)\nWHERE ( (coitem_status NOT IN ('C','X'))\n AND (item_type != 'K')\n AND ((itemsite_controlmethod = 'R') AND (NOT itemsite_loccntrl))\n AND (coitem_qtyreserved > 0.0)\n\n AND (itemsite_warehous_id=) \n\n AND (coitem_cohead_id=) ) \n\n\n\n\nSELECT toitem_id AS lineitem_id, \n 0 AS lsJob, 0 AS indent,\n getOpenShipment('TO', , ) AS shiphead_number, \n toitem_linenumber AS linenumber, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n tohead_srcname AS warehous_code,\n toitem_schedshipdate AS scheddate,\n uom_name,\n toitem_qty_ordered AS qtyord,\n toitem_qty_shipped AS qtyshipped,\n 0 AS qtyreturned,\n qtyAtShipping('TO', toitem_id) AS atshipping, \n toitem_schedshipdate AS seq1, toitem_linenumber AS seq2, 0 AS seq3 \nFROM item, tohead, site(), uom, toitem\nWHERE ( (toitem_item_id=item_id)\n AND (toitem_status NOT IN ('C','X'))\n AND (toitem_tohead_id=tohead_id)\n AND (tohead_src_warehous_id=warehous_id)\n AND (item_inv_uom_id=uom_id)\n\n AND (tohead_src_warehous_id=) \n\n AND (tohead_id=) ) \n\n) AS sub \nORDER BY seq1, seq2, seq3, indent;\n admin 2015-10-01 0 257 itemCost detail used by dspItemCostSummary, dspItemCostsByClassCode, dspItemCostHistory\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: itemCost\n-- Name: detail\n-- Notes: used by dspItemCostSummary, dspItemCostsByClassCode, dspItemCostHistory\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n \n costhist_id, costelem_type,\n formatBoolYN(costhist_lowlevel) AS lowlevel,\n CASE WHEN costhist_type='A' THEN \n WHEN costhist_type='S' THEN \n WHEN costhist_type='D' THEN \n WHEN costhist_type='N' THEN \n END AS type,\n costhist_date,\n costhist_username AS username,\n costhist_oldcost,\n currConcat(costhist_oldcurr_id) AS oldcurr, \n\tcosthist_newcost,\n currConcat(costhist_newcurr_id) AS newcurr,\n 'cost' AS costhist_oldcost_xtnumericrole,\n 'cost' AS costhist_newcost_xtnumericrole\n \n item_id, item_number, description, item_active, \n uom_name, scost, acost, \n CASE WHEN (scost = 0) THEN NULL \n ELSE ((acost - scost) / scost) \n END AS percent_variance,\n 'percent' AS percent_variance_xtnumericrole, \n CASE WHEN (scost = 0) THEN NULL \n WHEN (((acost - scost) / scost) < 0) THEN 'error' \n ELSE NULL \n END AS percent_variance_qtforegroundrole, \n \n CASE WHEN (scost != acost\n AND ABS(scost - acost) < 10 ^ (-1 * ))\n THEN 'altemphasis' \n END AS qtforegroundrole,\n \n 'cost' AS scost_xtnumericrole,\n 'cost' AS acost_xtnumericrole \n \n itemcost_id,\n CASE WHEN (costelem_sys) THEN 1\n ELSE 0\n END,\n costelem_type, formatBoolYN(itemcost_lowlevel) AS lowlevel,\n itemcost_stdcost,\n currToBase(itemcost_curr_id, itemcost_actcost, NULL) AS itemcost_actcost,\n itemcost_updated, itemcost_posted,\n 'cost' AS itemcost_stdcost_xtnumericrole,\n 'cost' AS itemcost_actcost_xtnumericrole,\n 0 AS itemcost_stdcost_xttotalrole,\n 0 AS itemcost_actcost_xttotalrole,\n CASE WHEN COALESCE(itemcost_posted, endOfTime()) >= endOfTime() \n THEN \n END AS itemcost_posted_qtdisplayrole,\n CASE WHEN COALESCE(itemcost_updated, endOfTime()) >= endOfTime()\n THEN \n END AS itemcost_updated_qtdisplayrole\n \nFROM \n (SELECT item_id, item_number, item_active,\n (item_descrip1 || ' ' || item_descrip2) AS description,\n uom_name, stdcost(item_id) AS scost, actcost(item_id) AS acost\n FROM item, classcode, uom\n WHERE ((item_classcode_id=classcode_id)\n AND (item_inv_uom_id=uom_id)\n \n AND (classcode_id=)\n \n AND (classcode_code ~ )\n \n ) ) AS data \n \n costhist,costelem\n \n itemcost, costelem\n \nWHERE ( \n (costhist_costelem_id=costelem_id)\n AND (costhist_item_id=)\n \n true \n \n AND ((scost=0) OR (acost=0)) \n \n \n AND (scost != acost) \n AND (ABS(scost - acost) > 10 ^ (-1 * ))\n \n \n AND (item_active) \n \n \n (itemcost_costelem_id=costelem_id)\n AND (itemcost_item_id=)\n \n ) \nORDER BY \n costhist_date, costelem_type;\n \n item_number;\n \n itemcost_lowlevel, costelem_type;\n \n admin 2015-10-01 0 457 itemCost list used by maintainItemCosts, bomItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: itemCost\n-- Name: list\n-- Notes: used by maintainItemCosts, bomItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n-- The order of checking for item_id first is important.\n\n\n\nSELECT itemcost_id,\n CASE WHEN (costelem_sys) THEN 1\n ELSE 0\n END,\n CASE WHEN itemcost_costelem_id = -1 THEN :error\n\t ELSE costelem_type\n END AS costelem_type, itemcost_lowlevel,\n itemcost_stdcost, currConcat(baseCurrID()) AS baseCurr,\n itemcost_posted,\n itemcost_actcost, currConcat(itemcost_curr_id) AS costCurr,\n itemcost_updated,\n currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE) AS actcostBase,\n itemcost_curr_id,\n CASE WHEN (COALESCE(itemcost_posted, startOfTime()) <= startOfTime()) THEN :never\n END AS itemcost_posted_qtdisplayrole,\n 'cost' AS itemcost_stdcost_xtnumericrole,\n 'cost' AS itemcost_actcost_xtnumericrole\nFROM itemcost LEFT OUTER JOIN costelem ON (itemcost_costelem_id=costelem_id)\nWHERE (itemcost_item_id=)\nORDER BY itemcost_lowlevel, costelem_type;\n\n\n\nSELECT bomitemcost_id AS itemcost_id,\n CASE WHEN (costelem_sys) THEN 1\n ELSE 0\n END,\n CASE WHEN bomitemcost_costelem_id = -1 THEN :error\n\t ELSE costelem_type\n END AS costelem_type,\n bomitemcost_lowlevel AS itemcost_lowlevel,\n bomitemcost_stdcost AS itemcost_stdcost, currConcat(baseCurrID()) AS baseCurr,\n bomitemcost_posted AS itemcost_posted,\n bomitemcost_actcost AS itemcost_actcost,\n currConcat(bomitemcost_curr_id) AS costCurr,\n bomitemcost_updated AS itemcost_updated,\n currToBase(bomitemcost_curr_id, bomitemcost_actcost, CURRENT_DATE) AS actcostBase,\n bomitemcost_curr_id AS itemcost_curr_id,\n CASE WHEN (COALESCE(bomitemcost_posted, startOfTime()) <= startOfTime()) THEN :never\n END AS itemcost_posted_qtdisplayrole,\n 'cost' AS itemcost_stdcost_xtnumericrole,\n 'cost' AS itemcost_actcost_xtnumericrole\nFROM bomitemcost LEFT OUTER JOIN costelem ON (bomitemcost_costelem_id=costelem_id)\nWHERE (bomitemcost_bomitem_id=)\nORDER BY bomitemcost_lowlevel, costelem_type;\n\n\n admin 2015-10-01 0 430 itemPricingSchedule detail used by itemPricingSchedule\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: itemPricingSchedule\n-- Name: detail\n-- Notes: used by itemPricingSchedule\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT ipsitem_id AS id, 1 AS altid,\n CASE WHEN (ipsitem_item_id IS NOT NULL) THEN \n ELSE \n END AS target,\n COALESCE(item_number, prodcat_code) AS number,\n COALESCE(item_descrip1 || ' ' || item_descrip2, prodcat_descrip) AS descrip,\n qty.uom_name AS qtyuom, ipsitem_qtybreak AS qtybreak,\n price.uom_name AS priceuom,\n ((COALESCE(ipsitem_discntprcnt, 0.0) * 100) + ipsitem_price) AS price,\n (COALESCE(ipsitem_fixedamtdiscount, 0.0) + 0.00) AS fixedAmt,\n noNeg(CASE WHEN (ipsitem_item_id IS NULL) THEN\n NULL\n WHEN (ipsitem_type='N') THEN\n ipsitem_price\n WHEN (ipsitem_type='D') THEN\n (item_listprice - (item_listprice * COALESCE(ipsitem_discntprcnt, 0.0)) - COALESCE(ipsitem_fixedamtdiscount, 0.0))\n WHEN ((ipsitem_type = 'M') AND fetchMetricBool('Long30Markups') AND fetchMetricBool('WholesalePriceCosting')) THEN\n (item_listcost / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n WHEN ((ipsitem_type = 'M') AND fetchMetricBool('Long30Markups')) THEN\n (itemCost(itemsite_id) / itemuomtouomratio(item_id, ipsitem_qty_uom_id, ipsitem_price_uom_id) /\n (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n WHEN (ipsitem_type = 'M' AND fetchMetricBool('WholesalePriceCosting')) THEN\n (item_listcost + (item_listcost * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n WHEN (ipsitem_type = 'M') THEN\n (itemCost(itemsite_id) / itemuomtouomratio(item_id, ipsitem_qty_uom_id, ipsitem_price_uom_id) +\n (itemCost(itemsite_id) / itemuomtouomratio(item_id, ipsitem_qty_uom_id, ipsitem_price_uom_id) * ipsitem_discntprcnt) +\n ipsitem_fixedamtdiscount)\n ELSE 0.0\n END) AS netPrice,\n CASE WHEN (ipsitem_type='N') THEN \n WHEN (ipsitem_type='D') THEN \n WHEN (ipsitem_type='M') THEN \n ELSE 'error'\n END AS type,\n CASE WHEN (ipsitem_type='N') THEN \n WHEN ((ipsitem_type IN ('D', 'M')) AND (COALESCE(ipsitem_discntprcnt, 0.0)=0.0) AND (COALESCE(ipsitem_fixedamtdiscount, 0.0)<>0.0)) THEN \n WHEN ((ipsitem_type IN ('D', 'M')) AND (COALESCE(ipsitem_discntprcnt, 0.0)<>0.0) AND (COALESCE(ipsitem_fixedamtdiscount, 0.0)=0.0)) THEN \n WHEN (ipsitem_type IN ('D', 'M')) THEN \n ELSE 'error'\n END AS method,\n 'qty' AS qtybreak_xtnumericrole,\n 'salesprice' AS netPrice_xtnumericrole,\n 'salesprice' AS price_xtnumericrole\nFROM ipsiteminfo LEFT OUTER JOIN item ON (item_id=ipsitem_item_id)\n LEFT OUTER JOIN prodcat ON (prodcat_id=ipsitem_prodcat_id)\n LEFT OUTER JOIN uom AS qty ON (qty.uom_id=ipsitem_qty_uom_id)\n LEFT OUTER JOIN uom AS price ON (price.uom_id=ipsitem_price_uom_id)\n LEFT OUTER JOIN itemsite ON (itemsite_item_id=item_id AND itemsite_warehous_id=)\nWHERE (ipsitem_ipshead_id=)\n\nUNION\n\nSELECT ipsfreight_id AS id, 2 AS altid, AS type,\n CASE WHEN (ipsfreight_type='F') THEN \n ELSE \n END AS number,\n ('From ' || COALESCE(warehous_code, ) || ' To ' || COALESCE(shipzone_name, )) AS descrip,\n CASE WHEN (ipsfreight_type='P') THEN uom_name END AS qtyuom,\n CASE WHEN (ipsfreight_type='P') THEN ipsfreight_qtybreak END AS qtybreak,\n uom_name AS priceuom, ipsfreight_price AS price,\n 0.00 AS fixedAmt,\n NULL AS netPrice,\n NULL AS type,\n NULL AS method,\n 'weight' AS qtybreak_xtnumericrole,\n 'salesprice' AS netPrice_xtnumericrole,\n 'salesprice' AS price_xtnumericrole\nFROM ipsfreight LEFT OUTER JOIN uom ON (uom_item_weight)\n LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\nWHERE ( (ipsfreight_ipshead_id=) )\nORDER BY altid, number, qtybreak;\n admin 2015-10-01 0 56 itemReceipt populateEdit used by enterPoitemReceipt, splitReceipt\n----PURCHASE ORDER----------\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: itemReceipt\n-- Name: populateEdit\n-- Notes: used by enterPoitemReceipt, splitReceipt\n------PURCHASE ORDER----------\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pohead_number AS order_number, poitem_linenumber AS orderitem_linenumber,\n (poitem_itemsite_id > 0) AS inventoryitem,\n COALESCE(poitem_itemsite_id, -1) AS itemsiteid,\n COALESCE(poitem_vend_item_number, '') AS vend_item_number,\n COALESCE(poitem_vend_uom, '') AS vend_uom,\n COALESCE(poitem_vend_item_descrip, '') AS vend_item_descrip,\n poitem_invvenduomratio AS orderitem_qty_invuomratio,\n poitem_duedate AS duedate,\n poitem_qty_ordered AS orderitem_qty_ordered,\n recv_qty AS qtyreceived,\n poitem_qty_returned AS qtyreturned,\n qtyToReceive('PO', poitem_id) AS qtytoreceive,\n (poitem_qty_ordered) AS receivable,\n recv_notes AS notes, recv_freight, recv_order_type,\n recv_freight_curr_id AS curr_id, recv_date AS effective,\n recv_purchcost, recv_purchcost_curr_id,\n CASE WHEN (itemsite_costmethod='A' AND NOT(recv_posted)) THEN TRUE\n ELSE FALSE\n END AS costmethod_average,\n 'uomratio' AS orderitem_qty_invuomratio_xtnumericrole,\n 'qty' AS orderitem_qty_ordered_xtnumericrole, \n 'qty' AS qtyreceived_xtnumericrole, \n 'qty' AS qtyreturned_xtnumericrole, \n 'qty' AS qtytoreceive_xtnumericrole, \n 'qty' AS receivable_xtnumericrole,\n 'purchprice' AS recv_purchcost_xtnumericrole \nFROM recv \n JOIN poitem ON ((recv_orderitem_id=poitem_id)\n AND (recv_order_type='PO'))\n JOIN pohead ON (poitem_pohead_id=pohead_id)\n LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\nWHERE (recv_id=)\n\nUNION\n-------RETURN AUTHORIZATIONS-----------\nSELECT rahead_number AS order_number, raitem_linenumber AS orderitem_linenumber,\n (raitem_itemsite_id > 0) AS inventoryitem,\n COALESCE(raitem_itemsite_id, -1) AS itemsiteid,\n '' AS vend_item_number,\n '' AS vend_uom,\n '' AS vend_item_descrip,\n raitem_qty_invuomratio AS orderitem_qty_invuomratio,\n raitem_scheddate AS duedate,\n raitem_qtyauthorized AS orderitem_qty_ordered,\n recv_qty AS qtyreceived,\n 0 AS qtyreturned,\n qtyToReceive('RA', raitem_id) AS qtytoreceive,\n (raitem_qtyauthorized) AS receivable,\n recv_notes AS notes, recv_freight, recv_order_type,\n recv_freight_curr_id AS curr_id, recv_date AS effective,\n NULL AS recv_purchcost, NULL AS recv_purchcost_curr_id,\n NULL AS costmethod_average,\n 'uomratio' AS orderitem_qty_invuomratio_xtnumericrole,\n 'qty' AS orderitem_qty_ordered_xtnumericrole, \n 'qty' AS qtyreceived_xtnumericrole, \n 'qty' AS qtyreturned_xtnumericrole, \n 'qty' AS qtytoreceive_xtnumericrole, \n 'qty' AS receivable_xtnumericrole,\n 'purchprice' AS recv_purchcost_xtnumericrole \nFROM recv\n JOIN raitem ON ((recv_orderitem_id=raitem_id)\n AND (recv_order_type='RA'))\n JOIN rahead ON (raitem_rahead_id=rahead_id)\nWHERE (recv_id=)\n\n\nUNION\n----------TRANSFER ORDERS---------\nSELECT tohead_number AS order_number, toitem_linenumber AS orderitem_linenumber,\n (itemsite_id > 0) AS inventoryitem,\n itemsite_id AS itemsiteid,\n '' AS vend_item_number,\n '' AS vend_uom,\n '' AS vend_item_descrip,\n 1 AS orderitem_qty_invuomratio,\n toitem_duedate AS duedate,\n toitem_qty_ordered AS orderitem_qty_ordered,\n recv_qty AS qtyreceived,\n 0 AS qtyreturned,\n qtyToReceive('TO', toitem_id) AS qtytoreceive,\n (toitem_qty_ordered) AS receivable,\n recv_notes AS notes, recv_freight, recv_order_type,\n recv_freight_curr_id AS curr_id, recv_date AS effective,\n NULL AS recv_purchcost, NULL AS recv_purchcost_curr_id,\n NULL AS costmethod_average,\n 'uomratio' AS orderitem_qty_invuomratio_xtnumericrole,\n 'qty' AS orderitem_qty_ordered_xtnumericrole, \n 'qty' AS qtyreceived_xtnumericrole, \n 'qty' AS qtyreturned_xtnumericrole, \n 'qty' AS qtytoreceive_xtnumericrole, \n 'qty' AS receivable_xtnumericrole,\n 'purchprice' AS recv_purchcost_xtnumericrole \nFROM itemsite, recv\n JOIN toitem ON ((recv_orderitem_id=toitem_id)\n AND (recv_order_type='TO'))\n JOIN tohead ON (toitem_tohead_id=tohead_id)\nWHERE ((recv_id=)\n AND (tohead_dest_warehous_id=itemsite_warehous_id)\n AND (toitem_item_id=itemsite_item_id))\n;\n admin 2015-10-01 0 57 itemReceipt populateNew used by enterPoitemReceipt\n-------PURCHASE ORDERS-------------\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: itemReceipt\n-- Name: populateNew\n-- Notes: used by enterPoitemReceipt\n---------PURCHASE ORDERS-------------\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pohead_number AS order_number, poitem_linenumber AS orderitem_linenumber,\n (poitem_itemsite_id > 0) AS inventoryitem,\n COALESCE(poitem_itemsite_id, -1) AS itemsiteid,\n COALESCE(poitem_vend_item_number, '') AS vend_item_number,\n COALESCE(poitem_vend_uom, '') AS vend_uom,\n COALESCE(poitem_vend_item_descrip, '') AS vend_item_descrip,\n poitem_invvenduomratio AS orderitem_qty_invuomratio,\n poitem_duedate AS duedate,\n poitem_qty_ordered AS orderitem_qty_ordered,\n poitem_qty_received AS qtyreceived,\n poitem_qty_returned AS qtyreturned,\n qtyToReceive('PO', poitem_id) AS qtytoreceive,\n (poitem_qty_ordered - poitem_qty_received) AS receivable,\n ( SELECT recv_notes\n FROM recv\n WHERE ((recv_orderitem_id=poitem_id)\n\t AND (recv_order_type='PO')\n AND (NOT recv_posted))\n\t LIMIT 1 ) AS notes,\n COALESCE(freightForRecv('PO', poitem_id, false),\n\t\tpoitem_freight - freightForRecv('PO', poitem_id, true),\n\t\tfreightForRecv('PO', poitem_id, true)) AS recv_freight,\n pohead_curr_id AS curr_id, CURRENT_DATE AS effective, \n poitem_unitprice AS recv_purchcost,\n pohead_curr_id AS recv_purchcost_curr_id,\n CASE WHEN (itemsite_costmethod='A') THEN TRUE \n\t ELSE FALSE \n END AS costmethod_average,\n 'uomratio' AS orderitem_qty_invuomratio_xtnumericrole,\n 'qty' AS orderitem_qty_ordered_xtnumericrole, \n 'qty' AS qtyreceived_xtnumericrole, \n 'qty' AS qtyreturned_xtnumericrole, \n 'qty' AS qtytoreceive_xtnumericrole, \n 'qty' AS receivable_xtnumericrole,\n 'purchprice' AS recv_purchcost_xtnumericrole \nFROM pohead\n JOIN poitem ON (pohead_id=poitem_pohead_id)\n LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\nWHERE ((poitem_status <> 'C')\n AND (poitem_id=)\n AND ('PO'=) )\n\nUNION\n---------RETURN AUTHORIZATIONS-------------\nSELECT rahead_number AS order_number, raitem_linenumber AS orderitem_linenumber,\n (raitem_itemsite_id > 0) AS inventoryitem,\n COALESCE(raitem_itemsite_id, -1) AS itemsiteid,\n '' AS vend_item_number,\n '' AS vend_uom,\n '' AS vend_item_descrip,\n raitem_qty_invuomratio AS orderitem_qty_invuomratio,\n raitem_scheddate AS duedate,\n raitem_qtyauthorized AS orderitem_qty_ordered,\n raitem_qtyreceived AS qtyreceived,\n 0 AS qtyreturned,\n qtyToReceive('RA', raitem_id) AS qtytoreceive,\n (raitem_qtyauthorized - raitem_qtyreceived) AS receivable,\n ( SELECT recv_notes\n FROM recv\n WHERE ((recv_orderitem_id=raitem_id)\n\t AND (recv_order_type='RA')\n AND (NOT recv_posted))\n\t LIMIT 1 ) AS notes,\n COALESCE(freightForRecv('RA', raitem_id, false),\n\t\tfreightForRecv('RA', raitem_id, true)) AS recv_freight,\n rahead_curr_id AS curr_id, CURRENT_DATE AS effective, \n NULL AS recv_purchcost, NULL AS recv_purchcost_curr_id,\n NULL AS costmethod_average,\n 'uomratio' AS orderitem_qty_invuomratio_xtnumericrole,\n 'qty' AS orderitem_qty_ordered_xtnumericrole, \n 'qty' AS qtyreceived_xtnumericrole, \n 'qty' AS qtyreturned_xtnumericrole, \n 'qty' AS qtytoreceive_xtnumericrole, \n 'qty' AS receivable_xtnumericrole,\n 'purchprice' AS recv_purchcost_xtnumericrole \nFROM rahead\n JOIN raitem ON (rahead_id=raitem_rahead_id)\nWHERE ((raitem_status <> 'C')\n AND (raitem_id=)\n AND ('RA'=) )\n\n\nUNION\n-------------TRANSFER ORDERS--------------\nSELECT tohead_number AS order_number, toitem_linenumber AS orderitem_linenumber,\n (itemsite_id > 0) AS inventoryitem,\n COALESCE(itemsite_id, -1) AS itemsiteid,\n '' AS vend_item_number,\n '' AS vend_uom,\n '' AS vend_item_descrip,\n 1 AS orderitem_qty_invuomratio,\n toitem_duedate AS duedate,\n toitem_qty_ordered AS orderitem_qty_ordered,\n toitem_qty_received AS qtyreceived,\n toitem_qty_shipped AS qtyreturned,\n qtyToReceive('TO', toitem_id) AS qtytoreceive,\n (toitem_qty_ordered - toitem_qty_received) AS receivable,\n ( SELECT recv_notes\n FROM recv\n WHERE ((recv_orderitem_id=toitem_id)\n\t AND (recv_order_type='TO')\n AND (NOT recv_posted))\n\t LIMIT 1 ) AS notes,\n COALESCE(freightForRecv('TO', toitem_id, false),\n\t\tfreightForRecv('TO', toitem_id, true)) AS recv_freight,\n baseCurrId() AS curr_id, CURRENT_DATE AS effective, \n NULL AS recv_purchcost, NULL AS recv_purchcost_curr_id,\n NULL AS costmethod_average,\n 'uomratio' AS orderitem_qty_invuomratio_xtnumericrole,\n 'qty' AS orderitem_qty_ordered_xtnumericrole, \n 'qty' AS qtyreceived_xtnumericrole, \n 'qty' AS qtyreturned_xtnumericrole, \n 'qty' AS qtytoreceive_xtnumericrole, \n 'qty' AS receivable_xtnumericrole,\n 'purchprice' AS recv_purchcost_xtnumericrole \nFROM itemsite, tohead\n JOIN toitem ON (tohead_id=toitem_tohead_id) \nWHERE ((toitem_status NOT IN ('C', 'X'))\n AND (toitem_id=)\n AND ('TO'=)\n AND (tohead_dest_warehous_id=itemsite_warehous_id)\n AND (toitem_item_id=itemsite_item_id))\n;\n admin 2015-10-01 0 58 itemReceipt sourceItemSite used by enterPoitemReceipt\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: itemReceipt\n-- Name: sourceItemSite\n-- Notes: used by enterPoitemReceipt\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\t\t\t-- this should never be called\n SELECT -1 AS itemsite_id, -1 AS warehous_id;\n\n SELECT itemsite_id, tohead_dest_warehous_id AS warehous_id\n FROM tohead, toitem, itemsite \n WHERE ((itemsite_item_id=toitem_item_id)\n AND (itemsite_warehous_id=tohead_src_warehous_id)\n AND (toitem_tohead_id=tohead_id)\n AND (toitem_id=));\n\t\t\t-- this should never be called\n SELECT itemsite_id, tohead_dest_warehous_id AS warehous_id\n FROM tohead, toitem, itemsite, recv\n WHERE ((itemsite_item_id=toitem_item_id)\n AND (itemsite_warehous_id=tohead_src_warehous_id)\n AND (toitem_tohead_id=tohead_id)\n AND (toitem_id=recv_orderitem_id)\n AND (recv_id=));\n\n admin 2015-10-01 0 259 itemSites detail \n Notes:\n Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: itemSites\n-- Name: detail\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id,warehous_code,itemsite_qtyonhand, itemsite_active, \n CASE WHEN ( (itemsite_loccntrl) OR\n (itemsite_controlmethod IN ('L', 'S')) ) THEN 1\n ELSE 0\n END AS altId,\n CASE WHEN itemsite_controlmethod='R' THEN \n WHEN itemsite_controlmethod='N' THEN \n WHEN itemsite_controlmethod='L' THEN \n WHEN itemsite_controlmethod='S' THEN \n END AS controlmethod,\n itemsite_loccntrl,\n item_number,\n (item_descrip1 || ' ' || item_descrip2) AS description, \n uom_name,\n CASE WHEN (itemsite_sold) THEN TEXT(itemsite_soldranking)\n END AS soldranking,\n CASE WHEN (itemsite_datelastcount=startOfTime()) THEN NULL\n ELSE itemsite_datelastcount\n END AS datelastcount,\n CASE WHEN (itemsite_datelastused=startOfTime()) THEN NULL\n ELSE itemsite_datelastused\n END AS datelastused,\n itemsite_abcclass, itemsite_cyclecountfreq,\n 'qty' AS itemsite_qtyonhand_xtnumericrole,\n AS soldranking_xtnullrole,\n AS datelastused_xtnullrole,\n AS datelastcount_xtnullrole \nFROM item, uom, itemsite, whsinfo\nWHERE ((itemsite_warehous_id=warehous_id)\n AND (itemsite_item_id=item_id)\n AND(item_inv_uom_id=uom_id)\n \n AND ((item_number ~* )\n OR (COALESCE(item_descrip1,'') || ' ' || COALESCE(item_descrip2,'') ~* )\n OR (warehous_code ~* ))\n \n \n AND (item_id=)\n \n \n AND (item_classcode_id=)\n \n \n AND (item_id IN (SELECT itemgrpitem_item_id \n FROM itemgrpitem \n WHERE (itemgrpitem_itemgrp_id=)))\n \n \n AND (itemsite_plancode_id=)\n \n \n AND (itemsite_costcat_id=)\n \n \n AND (item_classcode_id IN (SELECT classcode_id \n FROM classcode \n WHERE (classcode_code ~ )))\n \n \n AND (item_id IN (SELECT itemgrpitem_item_id \n FROM itemgrpitem, itemgrp \n WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id) \n AND (itemgrp_name ~ ) ) ))\n \n \n AND (itemsite_plancode_id IN (SELECT plancode_id \n FROM plancode \n WHERE (plancode_code ~ )))\n \n \n AND (itemsite_costcat_id IN (SELECT costcat_id \n FROM costcat \n WHERE (costcat_code ~ )))\n \n \n AND (warehous_id=)\n \n \n AND (itemsite_loccntrl = )\n \n \n AND (itemsite_active)\n \n )\nORDER BY item_number, warehous_code;\n admin 2015-10-01 0 260 itemSources detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: itemSources\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n SELECT itemsrc_id, \n vend_number, vend_name, \n item_number, uom_name,\n (item_descrip1 || ' ' || item_descrip2) AS item_descrip,\n contrct_number,\n COALESCE( (SELECT SUM(poitem_qty_ordered)\n FROM poitem\n WHERE (poitem_itemsrc_id=itemsrc_id)), 0.0) AS purchased_qty,\n itemsrc.*,\n 'qty' AS itemsrc_invvendoruomratio_xtnumericrole,\n CASE WHEN COALESCE(itemsrc_effective, startOfTime()) <=\n startOfTime() THEN \n END AS itemsrc_effective_qtdisplayrole,\n CASE WHEN COALESCE(itemsrc_expires, endOfTime()) >=\n endOfTime() THEN \n END AS itemsrc_expires_qtdisplayrole,\n CASE WHEN (COALESCE(itemsrc_expires, endOfTime()) < CURRENT_DATE) THEN 'expired'\n WHEN (COALESCE(itemsrc_effective, startOfTime()) > CURRENT_DATE) THEN 'future'\n END AS qtforegroundrole\n FROM itemsrc JOIN vendinfo ON (vend_id=itemsrc_vend_id AND vend_active)\n JOIN item ON (item_id=itemsrc_item_id)\n JOIN uom ON (uom_id=item_inv_uom_id)\n LEFT OUTER JOIN contrct ON (contrct_id=itemsrc_contrct_id) \n WHERE ((true)\n\n AND (itemsrc_active)\n\n\n AND (itemsrc_item_id=)\n\n\n AND (itemsrc_vend_id=)\n\n\n AND (itemsrc_contrct_id=)\n\n\n AND (contrct_number ~* )\n\n\n AND (itemsrc_expires > CURRENT_DATE)\n\n\n AND (itemsrc_effective <= CURRENT_DATE)\n\n)\n\nORDER BY itemsrc_contrct_id, itemsrc_ranking, vend_name,\n itemsrc_vend_item_number, itemsrc_manuf_name,\n itemsrc_manuf_item_number\n\nORDER By item_number, vend_name\n\n\n SELECT itemsrc_id, 0 AS ranked FROM itemsrc, contrct \n WHERE ((itemsrc_item_id= ) AND (itemsrc_default) \n AND (contrct_id = itemsrc_contrct_id)) \n UNION \n SELECT itemsrc_id, 2 AS ranked \n FROM itemsrc JOIN (SELECT * FROM \n (SELECT CASE WHEN ((itemsrc_item_id=) AND (NOT itemsrc_default)\n AND (contrct_id = itemsrc_contrct_id)) THEN -1\n ELSE itemsrc_id\n END AS dummy_id FROM itemsrc, contrct \n WHERE ((itemsrc_item_id=) AND (NOT itemsrc_default) \n AND (contrct_id = itemsrc_contrct_id))\n UNION \n SELECT itemsrc_id AS dummy_id \n FROM itemsrc \n WHERE ((itemsrc_item_id=) AND (itemsrc_default))\n ) AS dummy\n LIMIT 1) AS dummy2\n ON (itemsrc_id=dummy_id)\n WHERE ((itemsrc_item_id=) AND (itemsrc_default) AND (COALESCE(itemsrc_contrct_id,0)=0))\n\nORDER by ranked\n\n;\n admin 2015-10-01 0 476 itemSources prices \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: itemSources\n-- Name: prices\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsrcp_id, itemsrc_id,\n vend_number, vend_name,\n currConcat(vend_curr_id) AS vend_curr,\n item_number,\n (item_descrip1 || ' ' || item_descrip2) AS item_descrip,\n warehous_code, uom_name,\n contrct_number,\n itemsrc.*,\n (itemsrc_vend_item_number || '/' || itemsrc_manuf_item_number) AS itemsrc_descrip,\n itemsrcp.*,\n currConcat(itemsrcp_curr_id) AS item_curr,\n noNeg(CASE WHEN (itemsrcp_type='N') THEN currToBase(itemsrcp_curr_id, itemsrcp_price, itemsrcp_updated)\n WHEN (itemsrcp_type='D') THEN (item_listcost - (item_listcost * COALESCE(itemsrcp_discntprcnt, 0.0)) - COALESCE(itemsrcp_fixedamtdiscount, 0.0))\n ELSE 0.0\n END) AS price_base,\n noNeg(CASE WHEN (itemsrcp_type='N') THEN itemsrcp_price\n WHEN (itemsrcp_type='D') THEN (item_listcost - (item_listcost * COALESCE(itemsrcp_discntprcnt, 0.0)) - COALESCE(itemsrcp_fixedamtdiscount, 0.0))\n ELSE 0.0\n END) AS price_local,\n CASE WHEN (itemsrcp_type='N') THEN \n WHEN (itemsrcp_type='D') THEN \n ELSE 'error'\n END AS type,\n CASE WHEN (itemsrcp_type='N') THEN \n WHEN ((itemsrcp_type='D') AND (COALESCE(itemsrcp_discntprcnt, 0.0)=0.0) AND (COALESCE(itemsrcp_fixedamtdiscount, 0.0)<>0.0)) THEN \n WHEN ((itemsrcp_type='D') AND (COALESCE(itemsrcp_discntprcnt, 0.0)<>0.0) AND (COALESCE(itemsrcp_fixedamtdiscount, 0.0)=0.0)) THEN \n WHEN (itemsrcp_type='D') THEN \n ELSE 'error'\n END AS method,\n 'qty' AS itemsrc_invvendoruomratio_xtnumericrole,\n 'qty' AS itemsrc_minordqty_xtnumericrole,\n 'qty' AS itemsrc_ordqtymult_xtnumericrole,\n 'qty' AS itemsrcp_qtybreak_xtnumericrole,\n 'purchprice' AS price_local_xtnumericrole,\n 'purchprice' AS price_base_xtnumericrole,\n 'percent' AS itemsrcp_discntprcnt_xtnumericrole,\n CASE WHEN (warehous_code IS NULL) THEN \n END AS warehous_code_qtdisplayrole,\n CASE WHEN (itemsrcp_dropship) THEN \n ELSE \n END AS itemsrcp_dropship_qtdisplayrole,\n CASE WHEN COALESCE(itemsrc_effective, startOfTime()) <=\n startOfTime() THEN \n END AS itemsrc_effective_qtdisplayrole,\n CASE WHEN COALESCE(itemsrc_expires, endOfTime()) >=\n endOfTime() THEN \n END AS itemsrc_expires_qtdisplayrole,\n CASE WHEN (COALESCE(itemsrc_expires, endOfTime()) < CURRENT_DATE) THEN 'expired'\n WHEN (COALESCE(itemsrc_effective, startOfTime()) > CURRENT_DATE) THEN 'future'\n END AS qtforegroundrole\nFROM itemsrc JOIN vendinfo ON (vend_id=itemsrc_vend_id AND vend_active)\n JOIN item ON (item_id=itemsrc_item_id)\n JOIN uom ON (uom_id=item_inv_uom_id)\n JOIN itemsrcp ON (itemsrcp_itemsrc_id=itemsrc_id)\n LEFT OUTER JOIN contrct ON (contrct_id=itemsrc_contrct_id)\n LEFT OUTER JOIN whsinfo ON (warehous_id=itemsrcp_warehous_id)\nWHERE ((true)\n\n AND (itemsrc_active)\n\n\n AND (itemsrc_item_id=)\n\n\n AND (itemsrc_vend_id=)\n\n\n AND (itemsrc_id=)\n\n\n AND (itemsrcp_warehous_id=)\n\n\n AND (itemsrcp_dropship)\n\n\n AND ( (item_number ~* )\n OR (COALESCE(item_descrip1,'') || COALESCE(item_descrip2,'') ~* ) )\n\n\n AND (item_number ~* )\n\n\n AND (COALESCE(item_descrip1,'') || COALESCE(item_descrip2,'') ~* )\n\n\n AND (itemsrc_contrct_id=)\n\n\n AND (contrct_number ~* )\n\n\n AND (vend_name ~* )\n\n\n AND (itemsrc_vend_item_number ~* )\n\n\n AND (itemsrc_manuf_name ~* )\n\n\n AND (itemsrc_manuf_item_number ~* )\n\n\n AND (COALESCE(contrct_effective, itemsrc_effective) >= )\n\n\n AND (COALESCE(contrct_effective, itemsrc_effective) <= )\n\n\n AND (COALESCE(contrct_expires, itemsrc_expires) >= )\n\n\n AND (COALESCE(contrct_expires, itemsrc_expires) <= )\n\n)\nORDER By item_number, vend_name, itemsrcp_qtybreak\n;\n admin 2015-10-01 0 477 itemSources search \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: itemSources\n-- Name: search\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n SELECT itemsrc_id AS id,\n 1 AS altid,\n item_number,\n (item_descrip1 || ' ' || item_descrip2) AS item_descrip,\n vend_name,\n itemsrc_vend_item_number,\n itemsrc_vend_item_descrip,\n itemsrc_manuf_name,\n itemsrc_manuf_item_number,\n itemsrc_manuf_item_descrip,\n contrct_number\n FROM vendinfo JOIN itemsrc ON (itemsrc_vend_id=vend_id)\n JOIN item ON (item_id=itemsrc_item_id)\n LEFT OUTER JOIN contrct ON (itemsrc_contrct_id = contrct_id)\n WHERE (vend_id=)\n AND ( (FALSE)\n\n OR (item_number ~* )\n\n\n OR (itemsrc_vend_item_number ~* )\n\n\n OR (item_descrip1 ~* )\n\n\n OR (item_descrip2 ~* )\n\n\n OR (itemsrc_vend_item_descrip ~* )\n\n\n OR (itemsrc_manuf_name ~* )\n\n\n OR (itemsrc_manuf_item_number ~* )\n\n )\n UNION\n SELECT DISTINCT poitem_expcat_id AS id,\n 2 AS altid,\n AS item_number,\n (expcat_code || ' ' || expcat_descrip) AS item_descrip,\n vend_name,\n poitem_vend_item_number,\n poitem_vend_item_descrip,\n poitem_manuf_name,\n poitem_manuf_item_number,\n poitem_manuf_item_descrip,\n null AS contrct_id \n FROM vendinfo JOIN pohead ON (pohead_vend_id=vend_id)\n JOIN poitem ON (poitem_pohead_id=pohead_id)\n LEFT OUTER JOIN expcat ON (poitem_expcat_id=expcat_id)\n WHERE (vend_id=)\n AND (COALESCE(poitem_vend_item_number, '')!='')\n AND (poitem_itemsite_id IS NULL)\n AND ( (FALSE)\n\n OR (poitem_vend_item_number ~* )\n\n\n OR (expcat_code ~* )\n OR (expcat_descrip ~* )\n\n\n OR (poitem_vend_item_descrip ~* )\n\n\n OR (poitem_manuf_name ~* )\n\n\n OR (poitem_manuf_item_number ~* )\n\n )\n ORDER BY item_number, vend_name;\n admin 2015-10-01 0 113 itemcostdetail detail dspItemCostDetail\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: itemcostdetail\n-- Name: detail\n-- Notes: dspItemCostDetail\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT id, item.item_id, seqnumber, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescrip, uom_name,\n qtyper, 'qtyper' AS qtyper_xtnumericrole,\n scrap, 'scrap' AS scrap_xtnumericrole,\n cost, 'cost' AS cost_xtnumericrole,\n extendedcost, 'cost' AS extendedcost_xtnumericrole,\n 0 AS extendedcost_xttotalrole \nFROM uom, item, (\n\n SELECT bomitem_id AS id, bomitem_seqnumber AS seqnumber,\n (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS qtyper,\n bomitem_scrap AS scrap,\n bomitem_item_id AS item_id,\n \n itemcost_stdcost AS cost,\n (itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL,\n (bomitem_qtyfxd/bomhead_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') * itemcost_stdcost) AS extendedcost\n \n currToBase(itemcost_curr_id, itemcost_actcost, NULL) AS cost,\n (itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL,\n (bomitem_qtyfxd/bomhead_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') *\n currToBase(itemcost_curr_id, itemcost_actcost, NULL)) AS extendedcost \n \n FROM bomitem\n JOIN itemcost ON (itemcost_item_id=bomitem_item_id)\n JOIN costelem ON (itemcost_costelem_id=costelem_id)\n JOIN bomhead ON (bomhead_item_id=bomitem_parent_item_id AND bomhead_rev_id=bomitem_rev_id)\n \n LEFT OUTER JOIN rev ON ((bomitem_rev_id=rev_id) AND (COALESCE(rev_status, 'A')='A')) \n \n WHERE ((CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires-1))\n AND (bomitem_parent_item_id=)\n AND (costelem_id=) ) \n\n SELECT bbomitem_id AS id, bbomitem_seqnumber AS seqnumber,\n bbomitem_qtyper AS qtyper,\n bbomitem_costabsorb AS scrap,\n bbomitem_parent_item_id AS item_id,\n \n itemcost_stdcost AS cost,\n (itemcost_stdcost / bbomitem_qtyper *\n bbomitem_costabsorb) AS extendedcost \n \n currToBase(itemcost_curr_id, itemcost_actcost, NULL) AS cost,\n (currToBase(itemcost_curr_id, itemcost_actcost, NULL) / bbomitem_qtyper *\n bbomitem_costabsorb) AS extendedcost \n \n FROM xtmfg.bbomitem\n JOIN itemcost ON (itemcost_item_id=bbomitem_parent_item_id)\n WHERE ((CURRENT_DATE BETWEEN bbomitem_effective AND (bbomitem_expires-1))\n AND (itemcost_costelem_id=)\n AND (bbomitem_item_id=) )\n UNION\n SELECT source.bbomitem_id, source.bbomitem_seqnumber AS seqnumber,\n source.bbomitem_qtyper, target.bbomitem_costabsorb,\n item_id,\n \n itemcost_stdcost AS cost,\n (itemcost_stdcost * source.bbomitem_qtyper /\n target.bbomitem_qtyper * target.bbomitem_costabsorb) AS extendedcost \n \n currToBase(itemcost_curr_id, itemcost_actcost, NULL) AS cost,\n (currToBase(itemcost_curr_id, itemcost_actcost, NULL) * source.bbomitem_qtyper /\n target.bbomitem_qtyper * target.bbomitem_costabsorb) AS extendedcost \n \n FROM xtmfg.bbomitem AS source\n JOIN item ON (source.bbomitem_item_id=item_id)\n JOIN itemcost ON (source.bbomitem_item_id=itemcost_item_id)\n JOIN xtmfg.bbomitem AS target\n ON (source.bbomitem_parent_item_id=target.bbomitem_parent_item_id)\n WHERE ((CURRENT_DATE BETWEEN source.bbomitem_effective\n AND (source.bbomitem_expires-1))\n AND (CURRENT_DATE BETWEEN target.bbomitem_effective\n AND (target.bbomitem_expires-1))\n AND (item_type='Y')\n AND (target.bbomitem_item_id=)\n AND (itemcost_costelem_id=) )\n\n) AS data \nWHERE ((data.item_id=item.item_id)\n AND (item_inv_uom_id=uom_id)) \nORDER BY seqnumber;\n admin 2015-10-01 0 258 items detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: items\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n SELECT\n \n DISTINCT ON ( toNumeric(item_number, 999999999999999), item_number )\n \n DISTINCT ON ( item_number )\n \n item.*, classcode.*, uom.*, prodcat.*, freightclass.*,\n \n charass_alias.charass_value AS char,\n \n \n charass_alias.charass_value AS char,\n \n \n charass_alias.charass_value::date AS char,\n \n (COALESCE(item_descrip1,'') || ' ' || COALESCE(item_descrip2,'')) as item_descrip,\n CASE WHEN (item_type='P') THEN text()\n WHEN (item_type='M') THEN text()\n WHEN (item_type='F') THEN text()\n WHEN (item_type='B') THEN text()\n WHEN (item_type='C') THEN text()\n WHEN (item_type='Y') THEN text()\n WHEN (item_type='R') THEN text()\n WHEN (item_type='S') THEN text()\n WHEN (item_type='T') THEN text()\n WHEN (item_type='A') THEN text()\n WHEN (item_type='O') THEN text()\n WHEN (item_type='L') THEN text()\n WHEN (item_type='K') THEN text()\n ELSE text()\n END AS f_item_type,\n CASE WHEN (item_type='P') THEN text()\n WHEN (item_type='M') THEN text()\n WHEN (item_type='F') THEN text()\n WHEN (item_type='B') THEN text()\n WHEN (item_type='C') THEN text()\n WHEN (item_type='Y') THEN text()\n WHEN (item_type='R') THEN text()\n WHEN (item_type='S') THEN text()\n WHEN (item_type='T') THEN text()\n WHEN (item_type='A') THEN text()\n WHEN (item_type='O') THEN text()\n WHEN (item_type='L') THEN text()\n WHEN (item_type='K') THEN text()\n ELSE text()\n END AS item_type_qtdisplayrole\n FROM item\n JOIN classcode ON (item_classcode_id=classcode_id)\n JOIN uom ON (item_inv_uom_id=uom_id)\n LEFT OUTER JOIN prodcat ON (item_prodcat_id=prodcat_id)\n LEFT OUTER JOIN freightclass ON (item_freightclass_id=freightclass_id)\n \n JOIN itemgrpitem ON (item_id=itemgrpitem_item_id)\n JOIN itemgrp ON (itemgrp_id=itemgrpitem_itemgrp_id)\n \n \n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='I') \n AND (charass_alias.charass_target_id=item_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n \n \n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='I') \n AND (charass_alias.charass_target_id=item_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n \n \n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='I') \n AND (charass_alias.charass_target_id=item_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n \n WHERE ( true\n \n AND ( (item_number ~* )\n OR (COALESCE(item_descrip1,'') || COALESCE(item_descrip2,'') ~* ) )\n \n \n AND (item_type IN ('P', 'O'))\n \n AND (item_type IN ('M', 'F', 'B','K'))\n \n AND (item_sold)\n \n \n AND (item_type=)\n \n \n AND (item_active)\n \n \n AND (item_classcode_id=)\n \n \n AND (item_prodcat_id=)\n \n \n AND (item_freightclass_id=)\n \n \n AND (itemgrp_id=)\n \n \n AND (item_number ~* )\n \n \n AND (COALESCE(item_descrip1,'') || COALESCE(item_descrip2,'') ~* )\n \n \n AND (classcode_code ~* )\n \n \n AND (prodcat_code ~* )\n \n \n AND (freightclass_code ~* )\n \n \n ) ORDER BY\n \n toNumeric(item_number, 999999999999999),\n \n item_number;\n admin 2015-10-01 0 261 itemsWithoutItemSources detail used by dspItemsWithoutItemSources\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: itemsWithoutItemSources\n-- Name: detail\n-- Notes: used by dspItemsWithoutItemSources\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT item_id, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS descrip,\n CASE WHEN (item_type = 'P') THEN \n WHEN (item_type = 'O') THEN \n END AS type \nFROM item \nWHERE ( (item_type IN ('P', 'O'))\n AND (item_active)\n AND (item_id NOT IN (SELECT DISTINCT itemsrc_item_id\n FROM itemsrc \n WHERE (itemsrc_active))) ) \nORDER BY item_number;\n admin 2015-10-01 0 412 journals detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: journals\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT sltrans.*,\n CASE WHEN(sltrans_docnumber='Misc.' AND\n invhist_docnumber IS NOT NULL) THEN\n (sltrans_docnumber || ' - ' || invhist_docnumber)\n ELSE sltrans_docnumber\n END AS docnumber,\n firstLine(sltrans_notes) AS notes,\n sltrans_journalnumber,\n (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n CASE WHEN (sltrans_amount < 0) THEN ABS(sltrans_amount)\n ELSE NULL\n END AS debit,\n CASE WHEN (sltrans_amount > 0) THEN sltrans_amount\n ELSE NULL\n END AS credit,\n sltrans_gltrans_journalnumber,\n 'curr' AS debit_xtnumericrole,\n 'curr' AS credit_xtnumericrole\nFROM sltrans JOIN accnt ON (sltrans_accnt_id=accnt_id) \n LEFT OUTER JOIN invhist ON (sltrans_misc_id=invhist_id\n AND sltrans_docnumber='Misc.') \n\n JOIN company ON (accnt_company=company_number) \n\n\n JOIN prftcntr ON (accnt_profit=prftcntr_number) \n\n\n JOIN subaccnt ON (accnt_sub=subaccnt_number) \n\n\n JOIN subaccnttype ON (subaccnttype_code=accnt_subaccnttype_code) \n\nWHERE (\n\n \n (sltrans_date BETWEEN \n AND )\n \n (sltrans_date BETWEEN \n AND endoftime())\n \n\n \n (sltrans_date BETWEEN startoftime()\n AND )\n \n (sltrans_date BETWEEN startoftime()\n AND endoftime())\n \n\n\n AND (company_id=)\n\n\n AND (prftcntr_id=)\n\n\n AND (accnt_number=)\n\n\n AND (subaccnt_id=)\n\n\n AND (subaccnttype_id=)\n\n\n AND (accnt_type= )\n\n\n AND (sltrans_accnt_id=)\n\n\n AND (sltrans_docnumber = case when = '' then \n sltrans_docnumber else \n end ) \n\n\n AND (sltrans_source=)\n\n\n AND (sltrans_source ~* )\n\n\n AND (sltrans_posted=)\n\n\n AND (sltrans_gltrans_journalnumber::text=)\n\n) \nORDER BY sltrans_created,\n sltrans_sequence, sltrans_amount;\n admin 2015-10-01 0 60 manufacture jobcosting used by dspJobCosting\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: manufacture\n-- Name: jobcosting\n-- Notes: used by dspJobCosting\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *, 0 AS cost_xttotalrole,\n 'qty' AS qty_xtnumericrole,\n 'cost' AS cost_xtnumericrole\nFROM (\n SELECT womatl_id AS id, 3 AS sort,\n AS type, item_number AS code,\n item_descrip1 AS descrip,\n (SUM(COALESCE(invhist_invqty,0))) AS qty,\n uom_name AS uom,\n SUM(COALESCE(invhist_invqty * invhist_unitcost,0)) AS cost,\n NULL as wooper_seqnumber\n FROM womatl\n LEFT OUTER JOIN womatlpost ON (womatl_id=womatlpost_womatl_id)\n LEFT OUTER JOIN invhist ON (womatlpost_invhist_id=invhist_id),\n itemsite, item, uom\n WHERE ((womatl_wo_id=)\n AND (womatl_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id))\n GROUP BY womatl_id, item_number, item_descrip1, uom_name\n ) AS data\nORDER BY sort, code;\n admin 2015-10-01 0 451 metasqls detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: metasqls\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT metasql_id, metasql_group, metasql_name,\n firstline(metasql_notes) AS metasql_notes, metasql_grade,\n CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n CASE nspname WHEN 'public' THEN 0\n ELSE 1 END AS xtindentrole,\n metasql_notes AS metasql_notes_qttooltiprole \n FROM metasql\n JOIN pg_class ON (metasql.tableoid=pg_class.oid)\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n UNION \nSELECT -1, pkghead_name, NULL,\n firstline(pkghead_descrip), NULL,\n pkghead_name, 0, pkghead_descrip\n FROM metasql, pg_class, pg_namespace\n RIGHT OUTER JOIN pkghead ON (nspname=pkghead_name)\n WHERE ((metasql.tableoid=pg_class.oid)\n AND (relnamespace=pg_namespace.oid))\nORDER BY pkgname, xtindentrole, metasql_group, metasql_name,\n metasql_grade DESC, metasql_id;\n\nSELECT metasql_id, metasql_group, metasql_name,\n firstline(metasql_notes) AS metasql_notes,\n metasql_grade,\n CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n metasql_notes AS metasql_notes_qttooltiprole \n FROM metasql\n JOIN pg_class ON (metasql.tableoid=pg_class.oid)\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nORDER BY metasql_group, metasql_name,\n metasql_grade DESC, metasql_id;\n \n admin 2015-10-01 0 262 mrpDetail detail used by dspMRPDetail\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: mrpDetail\n-- Name: detail\n-- Notes: used by dspMRPDetail\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT qtyNetable(itemsite_id) AS qoh, formatQty(qtyNetable(itemsite_id)) AS f_qoh,\n qtyAllocated(itemsite_id, findPeriodStart(),\n findPeriodEnd()) AS allocations,\n qtyOrdered(itemsite_id, findPeriodStart(),\n findPeriodEnd()) AS orders,\n qtyFirmedAllocated(itemsite_id, findPeriodStart(),\n findPeriodEnd()) AS firmedallocations,\n qtyFirmed(itemsite_id, findPeriodStart(),\n findPeriodEnd()) AS firmedorders\nFROM itemsite\nWHERE (itemsite_id=);\n admin 2015-10-01 0 263 mrpDetail item used by dspMRPDetail\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: mrpDetail\n-- Name: item\n-- Notes: used by dspMRPDetail\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, item_type, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS descrip,\n warehous_code\nFROM itemsite, item, whsinfo\nWHERE ( (itemsite_active)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (itemsite_planning_type='M')\n\n AND (itemsite_plancode_id=)\n\n AND (itemsite_plancode_id IN (SELECT plancode_id \n FROM plancode \n WHERE (plancode_code ~ )))\n\n\n AND (warehous_id=)\n\n )\nORDER BY item_number, warehous_code;\n admin 2015-10-01 0 440 openVouchers populate used by openVouchers\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: openVouchers\n-- Name: populate\n-- Notes: used by openVouchers\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT vohead_id, COALESCE(pohead_id, -1), vohead_number,\n COALESCE(TEXT(pohead_number), TEXT()) AS ponumber,\n (vend_number || '-' || vend_name) AS vendor, vendtype_code, vohead_invcnumber,\n vohead_distdate, COALESCE(vohead_gldistdate, vohead_distdate) AS postdate,\n vohead_amount, 'curr' AS vohead_amount_xtnumericrole,\n formatDate(vohead_distdate) AS f_distdate,\n formatDate(COALESCE(vohead_gldistdate, vohead_distdate)) AS f_postdate,\n formatMoney(vohead_amount) AS f_amount\n FROM vendinfo JOIN vendtype ON (vendtype_id=vend_vendtype_id)\n JOIN vohead ON (vohead_vend_id=vend_id)\n LEFT OUTER JOIN pohead ON (vohead_pohead_id=pohead_id) \n WHERE (NOT vohead_posted)\n\n AND (vend_id=)\n\n AND (vend_vendtype_id=)\n\n AND (vendtype_code ~ )\n\n ORDER BY vohead_number;\n \n admin 2015-10-01 0 264 openpurchaseorders detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: openpurchaseorders\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT\n pohead_id AS id, COALESCE(pohead_cohead_id, -1) AS altid,\n pohead.*,\n calcPurchaseOrderDueDate(pohead_id) AS min_duedate,\n calcPurchaseOrderAmt(pohead_id) AS order_total,\n vend_name, vend_number, vendtype_code,\n\n charass_alias.charass_value AS char,\n\n\n charass_alias.charass_value AS char,\n\n\n charass_alias.charass_value::date AS char,\n\n CASE WHEN(pohead_status='C') THEN \n WHEN(pohead_status='U') THEN \n WHEN(pohead_status='O') THEN \n ELSE pohead_status\n END AS pohead_status_qtdisplayrole,\n 'currency' AS order_total_xtnumericrole\nFROM pohead \n JOIN vendinfo ON (pohead_vend_id=vend_id)\n JOIN vendtype ON (vend_vendtype_id=vendtype_id)\n\n JOIN usr ON (pohead_agent_username=usr_username)\n \n\n JOIN poitem ON (poitem_pohead_id=pohead_id) \n JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\n \n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='PO') \n AND (charass_alias.charass_target_id=pohead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='PO') \n AND (charass_alias.charass_target_id=pohead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='PO') \n AND (charass_alias.charass_target_id=pohead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\nWHERE ( true\n \n AND ((pohead_number::text ~* ) \n OR (vend_number ~* )\n OR (vend_name ~* )\n OR (pohead_agent_username ~* )\n OR (vendtype_code ~* )\n OR (COALESCE(pohead_vend_cntct_first_name,'') || ' ' || COALESCE(pohead_vend_cntct_last_name,'') ~* )\n OR (COALESCE(pohead_vend_cntct_phone,'') ||' ' || COALESCE(pohead_vend_cntct_fax,'') ~* )\n OR (COALESCE(pohead_vend_cntct_email,'') ~* )\n OR (COALESCE(pohead_vendaddress1,'') || ' ' || COALESCE(pohead_vendaddress2,'') || ' ' || COALESCE(pohead_vendaddress3,'') ~* )\n OR (COALESCE(pohead_vendcity,'') ~* )\n OR (COALESCE(pohead_vendstate,'') ~* )\n OR (COALESCE(pohead_vendzipcode,'') ~* )\n OR (COALESCE(pohead_vendcountry,'') ~* )\n OR (COALESCE(pohead_shipto_cntct_first_name,'') || ' ' || COALESCE(pohead_shipto_cntct_last_name,'') ~* )\n OR (COALESCE(pohead_shipto_cntct_phone,'') || ' ' || COALESCE(pohead_shipto_cntct_fax,'') ~* )\n OR (COALESCE(pohead_shipto_cntct_email,'') ~* )\n OR (COALESCE(pohead_shiptoaddress1,'') || ' ' || COALESCE(pohead_vendaddress2,'') || ' ' || COALESCE(pohead_vendaddress3,'') ~* )\n OR (COALESCE(pohead_shiptocity,'') ~* )\n OR (COALESCE(pohead_shiptostate,'') ~* )\n OR (COALESCE(pohead_shiptozipcode,'') ~* )\n OR (COALESCE(pohead_shiptocountry,'') ~* )\n )\n \n \n AND (pohead_status ='U') \n \n\n AND (pohead_status='O' )\n \n \n AND (pohead_status IN ('U', 'O') ) \n \n \n AND (pohead_status NOT IN ('U', 'O', 'C')) \n \n\n AND (vend_id=)\n \n\n AND (vend_vendtype_id=)\n \n\n AND (vendtype_code ~* )\n \n\n AND (usr_id = )\n \n\n AND (itemsite_warehous_id = )\n \n\n ) \nORDER BY pohead_number;\n admin 2015-10-01 0 265 opensalesorders detail \n Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: opensalesorders\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT\n cohead.*,\n COALESCE(cust_number, :error) AS cust_number,\n COALESCE(saletype_descr, :error) AS saletype_descr,\n getSoSchedDate(cohead_id) AS scheddate, \n getSoStatus(cohead_id) AS status,\n\n charass_alias.charass_value AS char,\n\n\n charass_alias.charass_value AS char,\n\n\n charass_alias.charass_value::date AS char,\n\n firstline(cohead_ordercomments) AS notes,\n calcSalesOrderAmt(cohead_id) AS ordertotal,\n CASE WHEN (calcSalesOrderAmt(cohead_id,'S') != 0.0)\n THEN calcSalesOrderAmt(cohead_id,'M')\n ELSE 0.0\n END AS ordermargin,\n CASE WHEN (calcSalesOrderAmt(cohead_id,'S') != 0.0)\n THEN (calcSalesOrderAmt(cohead_id,'M') / calcSalesOrderAmt(cohead_id,'S'))\n ELSE 1.0\n END AS ordermarginpercent,\n 'percent' AS ordermarginpercent_xtnumericrole,\n 'extprice' AS ordertotal_xtnumericrole,\n 'extprice' AS ordermargin_xtnumericrole\nFROM cohead \n JOIN custinfo ON (cohead_cust_id=cust_id) \n JOIN custtype ON (cust_custtype_id=custtype_id)\n LEFT OUTER JOIN saletype ON (cohead_saletype_id=saletype_id)\n \n JOIN coitem ON (coitem_cohead_id=cohead_id) \n JOIN itemsite ON (coitem_itemsite_id=itemsite_id) \n JOIN site() ON (itemsite_warehous_id=warehous_id) \n \n LEFT OUTER JOIN coitem ON (coitem_cohead_id=cohead_id) \n LEFT OUTER JOIN itemsite ON (coitem_itemsite_id=itemsite_id) \n LEFT OUTER JOIN whsinfo ON (itemsite_warehous_id=warehous_id) \n \n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='SO') \n AND (charass_alias.charass_target_id=cohead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='SO') \n AND (charass_alias.charass_target_id=cohead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='SO') \n AND (charass_alias.charass_target_id=cohead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\nWHERE((true) \n\n AND (cust_id= )\n\n\n AND (cust_custtype_id=)\n\n\n AND (custtype_code ~* )\n\n\n AND (cohead_custponumber~*)\n\n\n AND (cohead_orderdate BETWEEN AND )\n\n \n AND (cohead_status='O')\n\n\n AND (warehous_id=)\n\n\n AND (cohead_salesrep_id=)\n\n\n AND (cohead_saletype_id=)\n\n\n ) \nORDER BY cohead_number;\n admin 2015-10-01 0 63 opportunities detail used by opportunityList\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: opportunities\n-- Name: detail\n-- Notes: used by opportunityList\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT ON (incdtpriority_order, ophead_target_date, ophead_name, ophead_id) \n ophead_id AS id,\n CASE WHEN (ophead_active) THEN 0 ELSE 1 END AS altId,\n ophead_number,\n ophead_name,\n ophead_active,\n crmacct_number,\n ophead_owner_username,\n ophead_username,\n opstage_name,\n incdtpriority_name,\n opsource_name,\n optype_name,\n (ophead_probability_prcnt * .01) AS ophead_probability_prcnt,\n ophead_amount,\n (COALESCE(ophead_amount,0) * COALESCE(ophead_probability_prcnt * 0.01)) AS value,\t\n currConcat(ophead_curr_id) As f_currency,\n ophead_target_date,\n ophead_actual_date,\n formatMoney(ophead_amount) AS f_amount,\n formatMoney(COALESCE(ophead_amount,0) * COALESCE(ophead_probability_prcnt * 0.01)) AS f_value,\t\n formatDate(ophead_target_date) AS f_targetdate,\n formatDate(ophead_actual_date) AS f_actualdate,\n 'extprice' AS ophead_amount_xtnumericrole,\n 'extprice' AS value_xtnumericrole,\n 0 AS ophead_amount_xttotalrole,\n 0 AS value_xttotalrole,\n 'percent' AS ophead_probability_prcnt_xtnumericrole\n\n , charass_alias.charass_value AS char\n\n\n , charass_alias.charass_value AS char\n\n\n , charass_alias.charass_value::date AS char\n\nFROM ophead()\n LEFT OUTER JOIN incdtpriority ON (ophead_priority_id=incdtpriority_id)\n LEFT OUTER JOIN crmacct ON (ophead_crmacct_id=crmacct_id)\n LEFT OUTER JOIN opstage ON (ophead_opstage_id=opstage_id)\n LEFT OUTER JOIN opsource ON (ophead_opsource_id=opsource_id)\n LEFT OUTER JOIN optype ON (ophead_optype_id=optype_id)\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='OPP') \n AND (charass_alias.charass_target_id=ophead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='OPP') \n AND (charass_alias.charass_target_id=ophead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='OPP') \n AND (charass_alias.charass_target_id=ophead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\nWHERE((true)\n\n AND ((ophead_target_date >= )\n OR ( <= startOfTime()) AND (ophead_target_date IS NULL))\n\n\n AND ((ophead_target_date <= )\n OR ( >= endOfTime()) AND (ophead_target_date IS NULL))\n\n\n AND (ophead_opsource_id=)\n\n\n AND (opsource_name ~ )\n\n\n AND (ophead_opstage_id=)\n\n\n AND (opstage_name ~ )\n\n\n AND (ophead_optype_id=)\n\n\n AND (optype_name ~ )\n\n\n AND ( IN (ophead_username, ophead_owner_username))\n\n\n AND (ophead_username=)\n\n\n AND (ophead_username ~ )\n\n\n AND (ophead_owner_username=)\n\n\n AND (ophead_owner_username ~ )\n\n\n AND (ophead_crmacct_id = )\n\n \n AND (ophead_name ~* )\n\n \n AND (ophead_active)\n\n\n AND (ophead_id=\n\n\n )\nORDER BY incdtpriority_order, ophead_target_date, ophead_name, ophead_id;\n admin 2015-10-01 0 62 opportunitiesByCRM detail used by crmaccount\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: opportunitiesByCRM\n-- Name: detail\n-- Notes: used by crmaccount\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT ophead_id, *,\n currConcat(ophead_curr_id) AS ophead_currabbr,\n 'currval' AS ophead_amount_xtnumericrole\n FROM ophead\n LEFT OUTER JOIN crmacct ON (ophead_crmacct_id=crmacct_id)\n LEFT OUTER JOIN opstage ON (ophead_opstage_id=opstage_id)\n LEFT OUTER JOIN opsource ON (ophead_opsource_id=opsource_id)\n LEFT OUTER JOIN optype ON (ophead_optype_id=optype_id)\n WHERE((crmacct_id=)\n\n AND (ophead_owner_username=)\n\n AND (ophead_owner_username ~ )\n\n )\n ORDER BY ophead_target_date;\n admin 2015-10-01 0 266 orderActivityByProject detail All projects\n -- Group: orderActivityByProject\n-- Name: detail\n-- Notes: All projects\n\nSELECT *, \n formatQty(qty) AS f_qty,\n formatMoney(value) AS f_value,\n 'curr' AS qty_xtnumericrole,\n 'curr' AS value_xtnumericrole,\n CASE WHEN COALESCE(hrs_balance,0) < 0 THEN 'red' END AS hrs_balance_qtforegroundrole,\n CASE WHEN COALESCE(exp_balance,0) < 0 THEN 'red' END AS exp_balance_qtforegroundrole\nFROM (\nSELECT prj_id AS id,\n 1 AS type,\n '0' AS subtype,\n 0 AS section,\n NULL AS section_qtdisplayrole,\n prj_number AS name,\n CASE \n WHEN prj_status = 'C' THEN \n WHEN prj_status = 'O' THEN \n WHEN prj_status = 'P' THEN \n END AS status,\n prjtype_code AS project_type,\n prj_name AS item,\n firstline(prj_descrip) AS descrip,\n crmacct_name AS customer, \n cntct_name AS contact,\n addr_city AS city,\n addr_state AS state,\n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n prj_due_date AS due,\n prj_assigned_date AS assigned,\n prj_start_date AS started,\n prj_completed_date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n CASE WHEN (prj_status = 'O' AND prj_due_date < current_date) THEN 'red' \n WHEN (prj_status = 'O' AND prj_due_date BETWEEN current_date AND current_date + (fetchmetricvalue('ProjectDueDateWarning')||' days')::interval) THEN 'orange' \n END AS due_qtforegroundrole,\n 0 AS xtindentrole\n FROM prj\n LEFT OUTER JOIN prjtype ON (prj_prjtype_id=prjtype_id)\n LEFT OUTER JOIN crmacct ON (prj_crmacct_id=crmacct_id)\n LEFT OUTER JOIN cntct ON (crmacct_cntct_id_1=cntct_id)\n LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n\n WHERE (prj_id = )\n \nUNION ALL\n----- TASKS -----\nSELECT DISTINCT -1 AS id, \n 3 AS type,\n '0' AS subtype,\n 1 AS section,\n 'Tasks' AS section_qtdisplayrole,\n 'Tasks' AS name,\n NULL::text AS status,\n NULL::text AS project_type,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n NULL::text AS due_qtforegroundrole,\n 1 AS xtindentrole\n\nUNION ALL\n\nSELECT prjtask_id AS id,\n 5 AS type,\n '0' AS subtype,\n 1 AS section,\n NULL AS section_qtdisplayrole,\n prjtask_number AS name,\n CASE \n WHEN prjtask_status = 'C' THEN \n WHEN prjtask_status = 'O' THEN \n WHEN prjtask_status = 'P' THEN \n END AS status,\n NULL::text AS project_type,\n prjtask_name AS item,\n prjtask_descrip AS descrip,\n cust_name as customer,\n cntct_name AS contact,\n addr_city AS city,\n addr_state AS state,\n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n prjtask_due_date AS due,\n prjtask_assigned_date AS assigned,\n prjtask_start_date AS started,\n prjtask_completed_date AS completed,\n prjtask_hours_budget AS hrs_budget,\n prjtask_hours_actual AS hrs_actual,\n (prjtask_hours_budget-prjtask_hours_actual) AS hrs_balance,\n prjtask_exp_budget AS exp_budget,\n prjtask_exp_actual AS exp_actual,\n (prjtask_exp_budget-prjtask_exp_actual) AS exp_balance,\n CASE WHEN (prjtask_status = 'O' AND prjtask_due_date < current_date) THEN 'red' \n WHEN (prjtask_status = 'O' AND prjtask_due_date BETWEEN current_date AND current_date + (fetchmetricvalue('ProjectDueDateWarning')||' days')::interval) THEN 'orange' \n END AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM prjtask\n LEFT OUTER JOIN te.teprjtask ON (prjtask_id = teprjtask_prjtask_id)\n LEFT OUTER JOIN custinfo ON (teprjtask_cust_id=cust_id)\n LEFT OUTER JOIN cntct ON (cust_corrcntct_id=cntct_id)\n LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n\n WHERE (prjtask_prj_id = )\n GROUP BY prjtask_prj_id, custinfo.cust_name, prjtask.prjtask_id, addr.addr_city, addr.addr_state, cntct_name, prjtask.prjtask_number, prjtask.prjtask_status, prjtask_username, prjtask.prjtask_owner_username, prjtask_name, prjtask_descrip, prjtask_due_date, prjtask_assigned_date, prjtask_start_date, prjtask_completed_date, prjtask_hours_budget, prjtask_hours_actual, prjtask_exp_budget, prjtask_exp_actual\n\n\nUNION ALL\n----- INCIDENTS -----\n\nSELECT DISTINCT -1 AS id, \n 100 AS type,\n '0' AS subtype,\n 1 AS section,\n 'Incidents' AS section_qtdisplayrole,\n 'Incidents' AS name,\n NULL::text AS status,\n NULL::text AS project_type,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n NULL::text AS due_qtforegroundrole,\n 1 AS xtindentrole\n FROM incdt\nUNION ALL\n\nSELECT incdt_id AS id,\n 105 AS type,\n '0' AS subtype,\n 1 AS section,\n NULL AS section_qtdisplayrole,\n incdt_number::text AS name,\n CASE \n WHEN incdt_status = 'L' THEN \n WHEN incdt_status = 'N' THEN \n WHEN incdt_status = 'F' THEN \n WHEN incdt_status = 'A' THEN \t\n WHEN incdt_status = 'R' THEN \n WHEN incdt_status = 'C' THEN \n END AS status,\n NULL::text AS project_type,\n incdt_number::text AS item,\n incdt_summary AS descrip,\n crmacct_number AS customer,\n crmacct_name AS contact,\n addr_city AS city,\n addr_state AS state,\n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n NULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM incdt\n LEFT OUTER JOIN crmacct ON (incdt_crmacct_id=crmacct_id)\n LEFT OUTER JOIN cntct ON (incdt_cntct_id=cntct_id)\n LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n\n WHERE (incdt_prj_id = )\n GROUP BY incdt_id, incdt_prj_id, incdt_number, crmacct_number, crmacct_name, addr.addr_city, addr.addr_state, cntct_name, incdt_number, incdt_status, incdt_assigned_username, incdt_owner_username, incdt_number, incdt_summary \n\n \n\nUNION ALL\n\n----- QUOTES -----\nSELECT DISTINCT -1 AS id, \n 10 AS type,\n '0' AS subtype,\n 2 AS section,\n AS section_qtdisplayrole,\n AS name,\n NULL::text AS status,\n NULL::text AS project_type,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value, \n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n NULL::text AS due_qtforegroundrole,\n 1 AS xtindentrole\n FROM quhead\n\n JOIN prj ON (prj_id=quhead_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n WHERE (quhead_prj_id = )\n\n AND (quhead_owner_username=)\n\n\nUNION ALL\n\nSELECT quhead_id AS id, \n 15 AS type,\n quhead_number AS subtype,\n 2 AS section,\n AS section_qtdisplayrole,\n quhead_number AS name,\n CASE WHEN (quhead_status = 'C') THEN \n \n WHEN (quhead_status = 'X') THEN\n \n WHEN (COALESCE(quhead_expire, current_date + 1) > current_date) THEN\n \n ELSE\n \n END AS status,\n NULL::text AS project_type,\n NULL::text AS item,\n NULL::text AS descrip,\n cust_name AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n NULL AS qty,\n NULL::text AS uom,\n NULL AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n NULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM quhead\n JOIN custinfo ON (quhead_cust_id=cust_id)\n\n JOIN prj ON (prj_id=quhead_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n JOIN quitem ON (quitem_quhead_id = quhead_id)\n WHERE (quhead_prj_id = )\n\n AND (quhead_owner_username=)\n\nGROUP BY quhead_id, quhead_number, quhead_status, quhead_expire, quhead_freight, quhead_misc, custinfo.cust_name\n\nUNION ALL\n\nSELECT quitem_id AS id, \n 17 AS type,\n quhead_number AS subtype,\n 2 AS section,\n AS section_qtdisplayrole,\n quitem_linenumber::text AS name, \n CASE WHEN (quhead_status = 'C') THEN \n \n WHEN (quhead_status = 'X') THEN\n \n WHEN (COALESCE(quhead_expire, current_date + 1) > current_date) THEN\n \n ELSE\n \n END AS status,\n NULL::text AS project_type,\n item_number AS item,\n item_descrip1 || ' ' || item_descrip2 AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n quitem_qtyord,\n uom_name AS uom,\n (quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n NULL::text AS due_qtforegroundrole,\n 3 AS xtindentrole\n FROM quhead\n\n JOIN prj ON (prj_id=quhead_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n JOIN quitem ON (quitem_quhead_id = quhead_id)\n JOIN uom ON (quitem_qty_uom_id = uom_id)\n JOIN itemsite ON (quitem_itemsite_id = itemsite_id)\n JOIN item ON (itemsite_item_id = item_id)\n WHERE (quhead_prj_id = )\n\n AND (quhead_owner_username=)\n\n\nUNION ALL\n\nSELECT quhead_id AS id, \n 18 AS type,\n quhead_number AS subtype,\n 2 AS section,\n AS section_qtdisplayrole,\n AS name,\n NULL AS status,\n NULL::text AS project_type,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n NULL AS qty,\n NULL::text AS uom,\n SUM((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio)) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM quhead\n\n JOIN prj ON (prj_id=quhead_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n JOIN quitem ON (quitem_quhead_id = quhead_id)\n WHERE (quhead_prj_id = )\n\n AND (quhead_owner_username=)\n\nGROUP BY quhead_id, quhead_number\n\nUNION ALL\n\nSELECT -1 AS id, \n 19 AS type,\n MAX(quhead_number) AS subtype,\n 2 AS section,\n AS section_qtdisplayrole,\n || ' ' || AS name,\n NULL AS status,\n NULL::text AS project_type,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n NULL AS qty,\n NULL::text AS uom,\n SUM((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio)) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM quhead\n\n JOIN prj ON (prj_id=quhead_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n JOIN quitem ON (quitem_quhead_id = quhead_id)\n WHERE (quhead_prj_id = )\n\n AND (quhead_owner_username=)\n\n\nUNION ALL\n\n------ SALES ORDERS ------\nSELECT DISTINCT -1 AS id, \n 20 AS type,\n '0' AS subtype,\n 3 AS section,\n AS section_qtdisplayrole,\n AS name,\n NULL::text AS status,\n NULL::text AS project_type,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 1 AS xtindentrole\n FROM cohead\n\n JOIN prj ON (prj_id=cohead_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n WHERE (cohead_prj_id = )\n\nUNION ALL\n\nSELECT cohead_id AS id, \n 25 AS type,\n cohead_number::text AS subtype,\n 3 AS section,\n AS section_qtdisplayrole,\n cohead_number::text AS name,\n COALESCE((SELECT CASE coitem_status WHEN 'O' THEN \n WHEN 'C' THEN \n ELSE \n END\n FROM coitem\n WHERE (coitem_cohead_id=cohead_id)\n ORDER BY CASE coitem_status WHEN 'O' THEN 1\n WHEN 'C' THEN 2\n ELSE 3\n END\n LIMIT 1),'O')\n AS status,\n NULL::text AS project_type,\n shipto_num AS item,\n shipto_name AS descrip,\n cust_name AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n NULL AS qty,\n NULL::text AS uom,\n NULL AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM cohead\n JOIN custinfo ON (cust_id = cohead_cust_id)\n LEFT OUTER JOIN shiptoinfo ON (cohead_shipto_id = shipto_id)\n\n JOIN prj ON (prj_id=cohead_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n JOIN coitem ON (coitem_cohead_id = cohead_id)\n WHERE (cohead_prj_id = )\nGROUP BY cohead_id, cohead_number, shipto_num, shipto_name, cust_name\n\nUNION ALL\n\nSELECT coitem_id AS id, \n 27 AS type,\n cohead_number::text AS subtype,\n 3 AS section,\n AS section_qtdisplayrole,\n coitem_linenumber::text AS name, \n CASE WHEN (coitem_status = 'O') THEN\n \n WHEN (coitem_status = 'C') THEN\n \n WHEN (coitem_status = 'X') THEN\n \n END AS status,\n NULL::text AS project_type,\n item_number AS item,\n item_descrip1 || ' ' || item_descrip2 AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n coitem_qtyord,\n uom_name AS uom,\n (coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 3 AS xtindentrole\n FROM cohead\n\n JOIN prj ON (prj_id=cohead_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n JOIN coitem ON (coitem_cohead_id = cohead_id)\n JOIN uom ON (coitem_qty_uom_id = uom_id)\n JOIN itemsite ON (coitem_itemsite_id = itemsite_id)\n JOIN item ON (itemsite_item_id = item_id)\n WHERE (cohead_prj_id = )\n\nUNION ALL\n\nSELECT cohead_id AS id, \n 28 AS type,\n cohead_number::text AS subtype,\n 3 AS section,\n AS section_qtdisplayrole,\n AS name,\n NULL AS status,\n NULL::text AS project_type,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n NULL AS qty,\n NULL::text AS uom,\n SUM((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio)) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM cohead\n\n JOIN prj ON (prj_id=cohead_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n JOIN coitem ON (coitem_cohead_id = cohead_id)\n WHERE (cohead_prj_id = )\nGROUP BY cohead_id, cohead_number\n\nUNION ALL\n\nSELECT -1 AS id, \n 29 AS type,\n MAX(cohead_number::text) AS subtype,\n 3 AS section,\n AS section_qtdisplayrole,\n || ' ' || AS name,\n NULL AS status,\n NULL::text AS project_type,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n NULL AS qty,\n NULL::text AS uom,\n SUM((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio)) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \t\n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM cohead\n\n JOIN prj ON (prj_id=cohead_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n JOIN coitem ON (coitem_cohead_id = cohead_id)\n WHERE (cohead_prj_id = )\n\nUNION ALL\n\n------ INVOICES -------\nSELECT DISTINCT -1 AS id, \n 30 AS type,\n '0' AS subtype,\n 4 AS section,\n AS section_qtdisplayrole,\n AS name,\n NULL::text AS status,\n NULL::text AS project_type,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 1 AS xtindentrole\n FROM invchead\n\n JOIN prj ON (prj_id=invchead_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n WHERE (invchead_prj_id = )\n\nUNION ALL\n\nSELECT invchead_id AS id,\n 35 AS type,\n invchead_invcnumber::text AS subtype,\n 4 AS section,\n AS section_qtdisplayrole,\n invchead_invcnumber::text AS name,\n CASE WHEN (invchead_posted) THEN\n \n ELSE \n END AS status,\n NULL::text AS project_type,\n shipto_num AS item,\n shipto_name AS descrip,\n cust_name AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n NULL AS qty,\n NULL::text AS uom,\n NULL AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM invchead\n JOIN custinfo ON (cust_id=invchead_cust_id)\n LEFT OUTER JOIN shiptoinfo ON (invchead_shipto_id = shipto_id)\n\n JOIN prj ON (prj_id=invchead_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n WHERE (invchead_prj_id = )\nGROUP BY invchead_id, invchead_invcnumber, shipto_num, shipto_name, invchead_freight, invchead_misc_amount, invchead_posted, cust_name\n\nUNION ALL\n\nSELECT invcitem_id AS id, \n 37 AS type,\n invchead_invcnumber::text AS subtype,\n 4 AS section,\n AS section_qtdisplayrole,\n invcitem_linenumber::text AS name, \n CASE WHEN (invchead_posted) THEN\n \n ELSE \n END AS status,\n NULL::text AS project_type,\n COALESCE(item_number,invcitem_number) AS item,\n COALESCE(item_descrip1 || ' ' || item_descrip2,invcitem_descrip) AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n invcitem_billed AS qty,\n uom_name AS uom,\n (invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 3 AS xtindentrole\n FROM invchead\n\n JOIN prj ON (prj_id=invchead_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n LEFT OUTER JOIN item ON (invcitem_item_id = item_id)\n LEFT OUTER JOIN uom ON (invcitem_qty_uom_id = uom_id)\n WHERE (invchead_prj_id = )\n\nUNION ALL\n\nSELECT invchead_id AS id, \n 38 AS type,\n invchead_invcnumber::text AS subtype,\n 4 AS section,\n AS section_qtdisplayrole,\n AS name,\n NULL AS status,\n NULL::text AS project_type,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n NULL AS qty,\n NULL::text AS uom,\n SUM((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio)) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM invchead\n\n JOIN prj ON (prj_id=invchead_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n WHERE (invchead_prj_id = )\nGROUP BY invchead_id, invchead_invcnumber\n\nUNION ALL\n\nSELECT -1 AS id, \n 39 AS type,\n MAX(invchead_invcnumber::text) AS subtype,\n 4 AS section,\n AS section_qtdisplayrole,\n || ' ' || AS name,\n NULL AS status,\n NULL::text AS project_type,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n NULL AS qty,\n NULL::text AS uom,\n SUM((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio)) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM invchead\n\n JOIN prj ON (prj_id=invchead_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n WHERE (invchead_prj_id = )\n\n\n\n\n\nUNION ALL\n\n------ WORK ORDERS -------\nSELECT DISTINCT -1 AS id, \n 40 AS type,\n '0' AS subtype,\n 5 AS section,\n AS section_qtdisplayrole,\n AS name,\n NULL::text AS status,\n NULL::text AS project_type,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 1 AS xtindentrole\n FROM wo\n\n JOIN prj ON (prj_id=wo_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n WHERE (wo_prj_id = )\n\nUNION ALL\n\nSELECT wo_id AS id, \n 45 AS type,\n formatWoNumber(wo_id) AS subtype,\n 5 AS section,\n AS section_qtdisplayrole,\n formatWoNumber(wo_id) AS name,\n CASE WHEN (wo_status = 'O') THEN\n \n WHEN (wo_status = 'E') THEN\n \n WHEN (wo_status = 'R') THEN\n \n WHEN (wo_status = 'I') THEN\n \n WHEN (wo_status = 'C') THEN\n \n END AS status,\n NULL::text AS project_type,\n item_number AS item,\n item_descrip1 || ' ' || item_descrip2 AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n wo_qtyord AS qty,\n uom_name AS uom,\n wo_postedvalue AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM wo\n\n JOIN prj ON (prj_id=wo_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n JOIN itemsite ON (itemsite_id=wo_itemsite_id)\n JOIN item ON (itemsite_item_id=item_id)\n JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (wo_prj_id = )\n\nUNION ALL\n\nSELECT -1 AS id, \n 49 AS type,\n MAX(formatWoNumber(wo_id)) AS subtype,\n 5 AS section,\n AS section_qtdisplayrole,\n || ' ' || AS name,\n NULL AS status,\n NULL::text AS project_type,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n NULL AS qty,\n NULL::text AS uom,\n SUM(wo_postedvalue) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM wo\n\n JOIN prj ON (prj_id=wo_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n WHERE (wo_prj_id = )\n\n\n\n\n\n UNION ALL\n\n------ PURCHASE REQUESTS ------\nSELECT DISTINCT -1 AS id, \n 50 AS type,\n '0' AS subtype,\n 6 AS section,\n AS section_qtdisplayrole,\n AS name,\n NULL::text AS status,\n NULL::text AS project_type,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 1 AS xtindentrole\n FROM pr\n\n JOIN prj ON (prj_id=pr_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n WHERE (pr_prj_id = )\n\nUNION ALL\n\nSELECT pr_id AS id, \n 55 AS type,\n pr_number::text || '-' || pr_subnumber::text AS subtype,\n 6 AS section,\n AS section_qtdisplayrole,\n pr_number::text || '-' || pr_subnumber::text AS name,\n AS status, \n NULL::text AS project_type,\n item_number AS item,\n (item_descrip1 || ' ' || item_descrip2) AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n pr_qtyreq AS qty,\n uom_name AS uom,\n stdcost(item_id) * pr_qtyreq AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM pr\n\n JOIN prj ON (prj_id=pr_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n JOIN itemsite ON (itemsite_id = pr_itemsite_id)\n JOIN item ON (itemsite_item_id = item_id)\n JOIN uom ON (item_inv_uom_id = uom_id)\n WHERE (pr_prj_id=)\n\nUNION ALL\n\nSELECT -1 AS id, \n 59 AS type,\n MAX(pr_number::text || '-' || pr_subnumber::text) AS subtype,\n 6 AS section,\n AS section_qtdisplayrole,\n || ' ' || AS name,\n NULL AS status,\n NULL::text AS project_type,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer, \n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n NULL AS qty,\n NULL::text AS uom,\n SUM(stdcost(item_id) * pr_qtyreq) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM pr\n\n JOIN prj ON (prj_id=pr_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n JOIN itemsite ON (itemsite_id = pr_itemsite_id)\n JOIN item ON (itemsite_item_id = item_id)\n WHERE (pr_prj_id = )\n\nUNION ALL\n\n------ PURCHASE ORDERS ------\nSELECT DISTINCT -1 AS id, \n 60 AS type,\n '0' AS subtype,\n 7 AS section,\n AS section_qtdisplayrole,\n AS name,\n NULL::text AS status,\n NULL::text AS project_type,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 1 AS xtindentrole\n FROM poitem\n\n JOIN prj ON (prj_id=poitem_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n WHERE (poitem_prj_id = )\n\nUNION ALL\n\nSELECT pohead_id AS id,\n 65 AS type,\n pohead_number::text AS subtype,\n 7 AS section,\n AS section_qtdisplayrole,\n pohead_number::text AS name,\n CASE WHEN (pohead_status = 'U') THEN\n \n WHEN (pohead_status = 'O') THEN\n \n WHEN (pohead_status = 'C') THEN\n \n END AS status,\n NULL::text AS project_type,\n NULL AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n NULL AS qty,\n NULL AS uom,\n NULL AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM pohead\n JOIN poitem ON (poitem_pohead_id = pohead_id)\n\n JOIN prj ON (prj_id=poitem_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n WHERE (poitem_prj_id = )\nGROUP BY pohead_id, pohead_number, pohead_freight, pohead_status\n\nUNION ALL\n\nSELECT poitem_id AS id, \n 67 AS type,\n pohead_number::text AS subtype,\n 7 AS section,\n AS section_qtdisplayrole,\n poitem_linenumber::text AS name, \n CASE WHEN (poitem_status = 'U') THEN\n \n WHEN (poitem_status = 'O') THEN\n \n WHEN (poitem_status = 'C') THEN\n \n END AS status,\n NULL::text AS project_type,\n COALESCE(item_number,poitem_vend_item_number) AS item,\n COALESCE((item_descrip1 || ' ' || item_descrip2),poitem_vend_item_descrip) AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n poitem_qty_ordered,\n poitem_vend_uom AS uom,\n (poitem_qty_ordered * poitem_unitprice) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 3 AS xtindentrole\n FROM pohead\n JOIN poitem ON (poitem_pohead_id = pohead_id)\n\n JOIN prj ON (prj_id=poitem_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id = item_id)\n WHERE (poitem_prj_id = )\n\nUNION ALL\n\nSELECT pohead_id AS id, \n 68 AS type,\n pohead_number::text AS subtype,\n 7 AS section,\n AS section_qtdisplayrole,\n AS name,\n NULL AS status,\n NULL::text AS project_type,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n NULL AS qty,\n NULL::text AS uom,\n SUM(poitem_qty_ordered * poitem_unitprice) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM pohead\n JOIN poitem ON (poitem_pohead_id = pohead_id)\n\n JOIN prj ON (prj_id=poitem_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n WHERE (poitem_prj_id = )\nGROUP BY pohead_id, pohead_number\n\nUNION ALL\n\nSELECT -1 AS id, \n 69 AS type,\n MAX(pohead_number::text) AS subtype,\n 7 AS section,\n AS section_qtdisplayrole,\n || ' ' || AS name,\n NULL AS status,\n NULL::text AS project_type,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state, \n NULL AS qty,\n NULL::text AS uom,\n SUM(poitem_qty_ordered * poitem_unitprice) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n \n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM pohead\n JOIN poitem ON (poitem_pohead_id = pohead_id)\n\n JOIN prj ON (prj_id=poitem_prj_id\n AND ((prj_owner_username=) OR (prj_username=)))\n\n WHERE (poitem_prj_id = )\n\n\n\n) data\nORDER BY section, subtype, type, id;\n admin 2015-10-01 0 64 orders detail used by dspOrders\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: orders\n-- Name: detail\n-- Notes: used by dspOrders\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT source_id, type, order_type, order_status, order_number, duedate,\n totalqty, relievedqty, balanceqty, balanceqty AS runningbalanceqty,\n 'qty' AS totalqty_xtnumericrole,\n 'qty' AS relievedqty_xtnumericrole,\n 'qty' AS balanceqty_xtnumericrole,\n 0 AS runningbalanceqty_xtrunningrole,\n CASE WHEN (late) THEN 'error' END AS duedate_qtforegroundrole\nFROM\n(\nSELECT poitem_id AS source_id, 1 AS type, TEXT('P/O') AS order_type,\n pohead_status AS order_status,\n TEXT(pohead_number) AS order_number,\n poitem_qty_ordered AS totalqty,\n poitem_qty_received AS relievedqty,\n noNeg(poitem_qty_ordered - poitem_qty_received) AS balanceqty,\n poitem_duedate AS duedate,\n (poitem_duedate < CURRENT_DATE) AS late\nFROM pohead, poitem, itemsite\nWHERE ((poitem_pohead_id=pohead_id)\n AND (poitem_status IN ('O','U'))\n AND (poitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=)\n AND (itemsite_warehous_id=)\n\n AND (poitem_duedate <= (CURRENT_DATE + itemsite_leadtime))\n\n AND (poitem_duedate <= (CURRENT_DATE + ))\n\n AND (poitem_duedate<=)\n\n AND (poitem_duedate BETWEEN AND )\n\n )\n\nUNION\nSELECT wo_id AS source_id, 2 AS type, TEXT('W/O') AS order_type,\n wo_status AS order_status,\n formatWONumber(wo_id) AS order_number,\n wo_qtyord AS totalqty,\n wo_qtyrcv AS relievedqty,\n noNeg(wo_qtyord - wo_qtyrcv) AS balanceqty,\n wo_duedate AS duedate,\n (wo_duedate < CURRENT_DATE) AS late \nFROM wo, itemsite\nWHERE ((wo_status<>'C')\n AND (wo_itemsite_id=itemsite_id)\n AND (itemsite_item_id=)\n AND (itemsite_warehous_id=)\n AND ( NOT IN ('C', 'Y'))\n\n AND (wo_duedate <= (CURRENT_DATE + itemsite_leadtime))\n\n AND (wo_duedate <= (CURRENT_DATE + ))\n\n AND (wo_duedate<=)\n\n AND (wo_duedate BETWEEN AND )\n\n )\n\n-- Tooling is also supply on Work Orders\nUNION\nSELECT wo_id AS source_id, 2 AS type, TEXT('W/O') AS order_type,\n wo_status AS order_status,\n formatWONumber(wo_id) AS order_number,\n womatl_qtyreq AS totalqty,\n COALESCE(sum(abs(invhist_invqty)),0) AS relievedqty,\n noNeg(womatl_qtyreq - COALESCE(sum(abs(invhist_invqty)),0)) AS balanceqty,\n wo_duedate AS duedate,\n (wo_duedate < CURRENT_DATE) AS late \nFROM womatl\n JOIN wo ON (wo_id=womatl_wo_id)\n JOIN itemsite ON (itemsite_id=womatl_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n LEFT OUTER JOIN womatlpost ON (womatl_id=womatlpost_womatl_id)\n LEFT OUTER JOIN invhist ON ((womatlpost_invhist_id=invhist_id)\n AND (invhist_invqty < 0))\nWHERE ((wo_status<>'C')\n AND (itemsite_item_id=)\n AND (itemsite_warehous_id=)\n AND (item_type = 'T')\n\n AND (wo_duedate <= (CURRENT_DATE + itemsite_leadtime))\n\n AND (wo_duedate <= (CURRENT_DATE + ))\n\n AND (wo_duedate<=)\n\n AND (wo_duedate BETWEEN AND )\n\n )\nGROUP BY wo_id, wo_status, womatl_qtyreq, wo_duedate\n\n\nUNION\nSELECT wo_id AS source_id, 2 AS type, TEXT('W/O') AS order_type,\n wo_status AS order_status,\n formatWONumber(wo_id) AS order_number,\n wo_qtyord AS totalqty,\n wo_qtyrcv AS relievedqty,\n noNeg(wo_qtyord - wo_qtyrcv) AS balanceqty,\n wo_duedate AS duedate,\n (wo_duedate < CURRENT_DATE) AS late\nFROM wo, xtmfg.brddist, itemsite\nWHERE ((brddist_wo_id=wo_id)\n AND (wo_status<>'C')\n AND (brddist_itemsite_id=itemsite_id)\n AND (itemsite_item_id=)\n AND (itemsite_warehous_id=)\n AND ( IN ('C', 'Y'))\n\n AND (wo_duedate <= (CURRENT_DATE + itemsite_leadtime))\n\n AND (wo_duedate <= (CURRENT_DATE + ))\n\n AND (wo_duedate<=)\n\n AND (wo_duedate BETWEEN AND )\n\n )\n\n\n\nUNION\nSELECT toitem_id AS source_id, 3 AS type, TEXT('T/O') AS order_type,\n tohead_status AS order_status,\n TEXT(tohead_number) AS order_number,\n toitem_qty_ordered AS totalqty,\n toitem_qty_received AS relievedqty,\n noNeg(toitem_qty_ordered - toitem_qty_received) AS balanceqty,\n toitem_duedate AS duedate,\n (toitem_duedate < CURRENT_DATE) AS late\nFROM tohead, toitem, itemsite\nWHERE ((toitem_tohead_id=tohead_id)\n AND (toitem_status='O')\n AND (toitem_item_id=itemsite_item_id)\n AND (tohead_dest_warehous_id=itemsite_warehous_id)\n AND (itemsite_item_id=)\n AND (itemsite_warehous_id=)\n\n AND (toitem_duedate <= (CURRENT_DATE + itemsite_leadtime))\n\n AND (toitem_duedate <= (CURRENT_DATE + ))\n\n AND (toitem_duedate<=)\n\n AND (toitem_duedate BETWEEN AND )\n\n )\n\n\n) AS data\n\nORDER BY duedate;\n admin 2015-10-01 0 111 package items replace the not-so-old pkgitem table with direct query of catalogs\n and tables so we never miss anything and do not have to maintain the\n data\n TODO: is there a better sort order?\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: package\n-- Name: items\n-- Notes: replace the not-so-old pkgitem table with direct query of catalogs\n-- and tables so we never miss anything and do not have to maintain the\n-- data\n-- TODO: is there a better sort order?\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n CASE WHEN pkgitem_type='C' THEN \n WHEN pkgitem_type='D' THEN \n WHEN pkgitem_type='F' THEN \n WHEN pkgitem_type='G' THEN \n WHEN pkgitem_type='I' THEN \n WHEN pkgitem_type='M' THEN \n WHEN pkgitem_type='P' THEN \n WHEN pkgitem_type='R' THEN \n WHEN pkgitem_type='S' THEN \n WHEN pkgitem_type='T' THEN \n WHEN pkgitem_type='U' THEN \n WHEN pkgitem_type='V' THEN \n WHEN pkgitem_type='sequence' THEN \n WHEN pkgitem_type='index' THEN \n ELSE pkgitem_type END AS pkgitem_type_qtdisplayrole\nFROM (\nSELECT script_id AS pkgitem_id, 'C' AS pkgitem_type,\n script_id AS pkgitem_item_id,\n script_name AS pkgitem_name,\n script_notes AS pkgitem_descrip\n FROM .pkgscript \nUNION \nSELECT cmd_id AS pkgitem_id, 'D' AS pkgitem_type,\n cmd_id AS pkgitem_item_id,\n cmd_name AS pkgitem_name,\n cmd_descrip AS pkgitem_descrip \n FROM .pkgcmd \nUNION \nSELECT pg_proc.oid AS pkgitem_id, 'F' AS pkgitem_type,\n pg_proc.oid AS pkgitem_item_id,\n proname || '(' || oidvectortypes(proargtypes)\n || ')' AS pkgitem_name,\n pg_catalog.obj_description(pg_proc.oid, 'pg_proc') AS pkgitem_descrip \n FROM pg_proc\n JOIN pg_namespace ON (pronamespace=pg_namespace.oid)\n WHERE (nspname=) \nUNION \nSELECT t.oid AS pkgitem_id, 'G' AS pkgitem_type,\n t.oid AS pkgitem_item_id,\n tgname AS pkgitem_name,\n pg_catalog.obj_description(t.oid, 'pg_trigger') AS pkgitem_descrip \n FROM pg_trigger t\n JOIN pg_class ON (tgrelid=pg_class.oid)\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n WHERE ((nspname=) \n\n AND (tgconstraint = 0)\n AND (tgname !~ '^pkg(cmd(arg)?|image|metasql|priv|report|script|uiform)')\n\n )\nUNION \nSELECT image_id AS pkgitem_id, 'I' AS pkgitem_type,\n image_id AS pkgitem_item_id,\n image_name AS pkgitem_name,\n image_descrip AS pkgitem_descrip \n FROM .pkgimage \nUNION \nSELECT metasql_id AS pkgitem_id, 'M' AS pkgitem_type,\n metasql_id AS pkgitem_item_id,\n metasql_group || '-' || metasql_name AS pkgitem_name,\n metasql_notes AS pkgitem_descrip \n FROM .pkgmetasql \nUNION \nSELECT priv_id AS pkgitem_id, 'P' AS pkgitem_type,\n priv_id AS pkgitem_item_id,\n priv_module || '.' || priv_name AS pkgitem_name,\n priv_descrip AS pkgitem_descrip \n FROM .pkgpriv \nUNION \nSELECT report_id AS pkgitem_id, 'R' AS pkgitem_type,\n report_id AS pkgitem_item_id,\n report_name AS pkgitem_name,\n report_descrip AS pkgitem_descrip \n FROM .pkgreport \nUNION \nSELECT n.oid AS pkgitem_id, 'S' AS pkgitem_type,\n n.oid AS pkgitem_item_id,\n nspname AS pkgitem_name,\n pg_catalog.obj_description(n.oid, 'pg_namespace') AS pkgitem_descrip \n FROM pg_namespace n\n WHERE (nspname=) \nUNION \nSELECT c.oid AS pkgitem_id, 'T' AS pkgitem_type,\n c.oid AS pkgitem_item_id,\n relname AS pkgitem_name,\n pg_catalog.obj_description(c.oid, 'pg_class') AS pkgitem_descrip \n FROM pg_class c\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n WHERE ((nspname=)\n AND (relkind='r')\n\n AND (relname !~ '^pkg(cmd(arg)?|image|metasql|priv|report|script|uiform)$')\n\n )\nUNION \nSELECT uiform_id AS pkgitem_id, 'U' AS pkgitem_type,\n uiform_id AS pkgitem_item_id,\n uiform_name AS pkgitem_name,\n uiform_notes AS pkgitem_descrip \n FROM .pkguiform \nUNION \nSELECT c.oid AS pkgitem_id, 'V' AS pkgitem_type,\n c.oid AS pkgitem_item_id,\n relname AS pkgitem_name,\n pg_catalog.obj_description(c.oid, 'pg_class') AS pkgitem_descrip \n FROM pg_class c\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n WHERE ((nspname=)\n AND (relkind='v'))\n\nUNION\nSELECT c.oid AS pkgitem_id, 'sequence' AS pkgitem_type,\n c.oid AS pkgitem_item_id,\n relname AS pkgitem_name,\n pg_catalog.obj_description(c.oid, 'pg_class') AS pkgitem_descrip \n FROM pg_class c\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n WHERE ((nspname=)\n AND (relkind='S'))\nUNION\nSELECT c.oid AS pkgitem_id, 'index' AS pkgitem_type,\n c.oid AS pkgitem_item_id,\n relname AS pkgitem_name,\n pg_catalog.obj_description(c.oid, 'pg_class') AS pkgitem_descrip \n FROM pg_class c\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n WHERE ((nspname=)\n AND (relkind='i'))\n\n) AS pkgitem \nORDER BY pkgitem_type_qtdisplayrole, pkgitem_name;\n admin 2015-10-01 0 69 packingList shipment used by printPackingList\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: packingList\n-- Name: shipment\n-- Notes: used by printPackingList\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT shiphead_order_id, shiphead_order_type, shiphead_shipform_id, cohead_number AS number\nFROM shiphead, cohead\nWHERE ((shiphead_id=)\n AND (cohead_id=shiphead_order_id)\n AND (shiphead_order_type='SO'))\n\nUNION\nSELECT shiphead_order_id, shiphead_order_type, shiphead_shipform_id, tohead_number AS number\nFROM shiphead, tohead\nWHERE ((shiphead_id=)\n AND (tohead_id=shiphead_order_id)\n AND (shiphead_order_type='TO'))\n\n;\n admin 2015-10-01 0 485 packingListBatch clear used by packingListBatch\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: packingListBatch\n-- Name: clear\n-- Notes: used by packingListBatch\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM pack WHERE pack_id IN\n (SELECT pack_id\n FROM pack JOIN cohead ON (cohead_id=pack_head_id)\n JOIN coitem ON (coitem_cohead_id=cohead_id)\n JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n WHERE ( (checkSOSitePrivs(cohead_id))\n AND (pack_head_type='SO')\n AND (pack_printed) \n\n AND (itemsite_warehous_id = )\n\n )\n );\n\n\nDELETE FROM pack WHERE pack_id IN\n (SELECT pack_id\n FROM pack JOIN tohead ON (tohead_id=pack_head_id)\n WHERE ( (pack_head_type='TO')\n AND (pack_printed)\n\n AND (tohead_src_warehous_id = )\n\n )\n );\n\n admin 2015-10-01 0 67 packingListBatch detail used by packingListBatch\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: packingListBatch\n-- Name: detail\n-- Notes: used by packingListBatch\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT\n cohead_id, pack_shiphead_id, \n cohead_number AS order_number, pack_head_type,\n cohead_shipvia AS shipvia,\n formatShipmentNumber(pack_shiphead_id) AS shipment_number, \n cust_number AS number, cohead_billtoname AS name,\n CASE WHEN (cohead_holdtype='N') THEN \n WHEN (cohead_holdtype='C') THEN \n WHEN (cohead_holdtype='S') THEN \n WHEN (cohead_holdtype='P') THEN \n WHEN (cohead_holdtype='R') THEN \n ELSE \n END AS f_holdtype,\n pack_printed\nFROM pack JOIN cohead ON (cohead_id=pack_head_id)\n JOIN custinfo ON (cust_id=cohead_cust_id)\n JOIN coitem ON (coitem_cohead_id=cohead_id)\n JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\nWHERE ( (pack_head_type='SO')\n AND (checkSOSitePrivs(cohead_id))\n\n AND (itemsite_warehous_id = )\n\n )\n\n\nUNION ALL \nSELECT tohead_id, pack_shiphead_id, \n tohead_number AS order_number, pack_head_type,\n tohead_shipvia AS shipvia,\n formatShipmentNumber(pack_shiphead_id) AS shipment_number, \n tohead_destname AS number, tohead_destcntct_name AS name,\n '' AS f_holdtype,\n pack_printed\nFROM pack JOIN tohead ON (tohead_id=pack_head_id) \nWHERE ( (pack_head_type='TO') \n\n AND (tohead_src_warehous_id = )\n\n )\n\nORDER BY 3;\n admin 2015-10-01 0 68 packingListBatch print used by packingListBatch\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: packingListBatch\n-- Name: print\n-- Notes: used by packingListBatch\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT\n pack_id, pack_head_id, pack_head_type, pack_shiphead_id,\n COALESCE(shipform_report_name, findCustomerForm(cohead_cust_id, 'P')) AS packform,\n findCustomerForm(cohead_cust_id, 'L') AS pickform \nFROM pack JOIN cohead ON (cohead_id=pack_head_id)\n JOIN coitem ON (coitem_cohead_id=cohead_id)\n JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n LEFT OUTER JOIN shipform ON (shipform_id=cohead_shipform_id)\nWHERE ( (checkSOSitePrivs(cohead_id))\n AND (pack_head_type='SO')\n AND (NOT pack_printed) \n\n AND (itemsite_warehous_id = )\n\n )\n\n\nUNION ALL\nSELECT pack_id, pack_head_id, pack_head_type, pack_shiphead_id,\n COALESCE(shipform_report_name, findTOForm(tohead_id, 'P')) AS packform,\n findTOForm(tohead_id, 'L') AS pickform \nFROM pack JOIN tohead ON (tohead_id=pack_head_id)\n LEFT OUTER JOIN shipform ON (shipform_id=tohead_shipform_id)\nWHERE ( (pack_head_type='TO')\n AND (NOT pack_printed)\n\n AND (tohead_src_warehous_id = )\n\n )\n\n;\n admin 2015-10-01 0 65 packingListBatchByShipVia print used by printPackingListBatchByShipVia\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: packingListBatchByShipVia\n-- Name: print\n-- Notes: used by printPackingListBatchByShipVia\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT pack_head_id, pack_head_type, pack_shiphead_id, getSoStatus(cohead_id) AS orderhead_status,\n COALESCE(shipform_report_name, findCustomerForm(cohead_cust_id, 'P')) AS packform,\n findCustomerForm(cohead_cust_id, 'L') AS pickform\nFROM pack JOIN cohead ON (cohead_id=pack_head_id)\n JOIN coitem ON (coitem_cohead_id=cohead_id)\n JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n LEFT OUTER JOIN shipform ON (shipform_id=cohead_shipform_id)\nWHERE ( (NOT pack_printed)\n AND (pack_head_type='SO')\n AND (getSoStatus(cohead_id) <> 'C') \n\n AND (cohead_shipvia=)\n\n AND (checkSOSitePrivs(cohead_id))\n AND\t(coitem_scheddate BETWEEN AND )\n\n AND (itemsite_warehous_id = )\n\n )\n\n\nUNION ALL\nSELECT DISTINCT pack_head_id, pack_head_type, pack_shiphead_id, tohead_status AS orderhead_status,\n COALESCE(shipform_report_name, findTOForm(tohead_id, 'P')) AS packform,\n findTOForm(tohead_id, 'L') AS pickform\nFROM pack JOIN tohead ON (tohead_id=pack_head_id)\n JOIN toitem ON (toitem_tohead_id = tohead_id) \n LEFT OUTER JOIN shipform ON (shipform_id=tohead_shipform_id)\nWHERE ( (NOT pack_printed)\n AND (pack_head_type='TO')\n AND (tohead_status <> 'C') \n\n AND (tohead_shipvia=)\n\n AND\t(toitem_duedate BETWEEN AND )\n\n AND (tohead_src_warehous_id = )\n\n )\n\n\n;\n admin 2015-10-01 0 66 packingListBatchByShipVia shipVia used by printPackingListBatchByShipVia\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: packingListBatchByShipVia\n-- Name: shipVia\n-- Notes: used by printPackingListBatchByShipVia\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT max(id), shipvia\nFROM (\nSELECT max(cohead_id) AS id, cohead_shipvia AS shipvia\nFROM pack JOIN cohead ON (cohead_id=pack_head_id)\n JOIN coitem ON (coitem_cohead_id=cohead_id AND coitem_status='O')\n JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\nWHERE ( (NOT pack_printed)\n AND (pack_head_type='SO')\n\n AND (itemsite_warehous_id = )\n\n )\nGROUP BY cohead_shipvia\n\nUNION\nSELECT max(tohead_id) AS id, tohead_shipvia AS shipvia\nFROM pack JOIN tohead ON (tohead_id=pack_head_id AND tohead_status='O')\nWHERE ( (NOT pack_printed)\n AND (pack_head_type='TO')\n\n AND (tohead_src_warehous_id = )\n\n )\nGROUP BY tohead_shipvia\n\n) data\nGROUP BY shipvia\nORDER BY shipvia\n admin 2015-10-01 0 267 partiallyShippedOrders detail used by dspPartiallyShippedOrders\n Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: partiallyShippedOrders\n-- Name: detail\n-- Notes: used by dspPartiallyShippedOrders\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT CASE WHEN (cohead_holdtype IN ('P', 'C', 'R')) THEN -1\n ELSE cohead_id\n END AS _coheadid, cohead_id,\n cohead_holdtype, cohead_number, cust_name, saletype_descr,\n CASE WHEN (cohead_holdtype='N') THEN \n WHEN (cohead_holdtype='C') THEN \n WHEN (cohead_holdtype='S') THEN \n WHEN (cohead_holdtype='P') THEN \n WHEN (cohead_holdtype='R') THEN \n ELSE \n END AS f_holdtype,\n cohead_orderdate,\n (MIN(coitem_scheddate)) AS minscheddate,\n cohead_packdate,\n SUM( (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n (coitem_price / coitem_price_invuomratio) ) AS extprice,\n currConcat(cohead_curr_id) AS currAbbr,\n SUM(currToBase(cohead_curr_id,\n (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n (coitem_price / coitem_price_invuomratio),\n CURRENT_DATE)) AS extprice_base,\n 'curr' AS extprice_xtnumericrole,\n 'curr' AS extprice_base_xtnumericrole,\n \n 0 AS extprice_xttotalrole \n \n 0 AS extprice_base_xttotalrole \n \nFROM cohead\n LEFT OUTER JOIN saletype ON (saletype_id=cohead_saletype_id)\n JOIN custinfo ON (cust_id=cohead_cust_id)\n JOIN coitem ON (coitem_cohead_id=cohead_id)\n JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\nWHERE ( (coitem_status='O')\n AND (cohead_id IN ( SELECT DISTINCT coitem_cohead_id\n FROM coitem\n WHERE (coitem_qtyshipped > 0) ))\n AND (coitem_qtyshipped < coitem_qtyord)\n AND (coitem_scheddate BETWEEN \n AND )\n \n AND (itemsite_warehous_id=)\n \n ) \nGROUP BY cohead_id, saletype_descr, cohead_number, cust_name, \n cohead_holdtype, cohead_orderdate, cohead_packdate,\n cohead_curr_id \nORDER BY minscheddate, cohead_number;\n admin 2015-10-01 0 268 pendingAvailability detail used by dspPendingAvailability\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: pendingAvailability\n-- Name: detail\n-- Notes: used by dspPendingAvailability\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\n\n-- Indented BOM\nSELECT itemsite_id, reorderlevel,\n bomdata_bomwork_level,\n bomdata_bomwork_id,\n bomdata_bomwork_parent_id,\n bomdata_bomwork_seqnumber AS bomitem_seqnumber,\n bomdata_item_number AS item_number,\n bomdata_itemdescription AS item_descrip,\n bomdata_uom_name AS uom_name,\n pendalloc,\n ordered,\n qoh,\n (totalalloc + pendalloc) AS totalalloc,\n (qoh + ordered - (totalalloc + pendalloc)) AS totalavail,\n 'qty' AS pendalloc_xtnumericrole,\n 'qty' AS ordered_xtnumericrole,\n 'qty' AS qoh_xtnumericrole,\n 'qty' AS totalalloc_xtnumericrole,\n 'qty' AS totalavail_xtnumericrole,\n CASE WHEN (qoh < pendalloc) THEN 'error' END AS qoh_qtforegroundrole,\n CASE WHEN ((qoh + ordered - (totalalloc + pendalloc)) < reorderlevel) THEN 'error'\n WHEN ((qoh + ordered - (totalalloc + pendalloc)) = reorderlevel) THEN 'warning'\n END AS totalavail_qtforegroundrole,\n bomdata_bomwork_level - 1 AS xtindentrole\n FROM ( SELECT itemsite_id,\n CASE WHEN(itemsite_useparams)\n THEN itemsite_reorderlevel\n ELSE 0.0\n END AS reorderlevel,\n ib.*,\n ((bomdata_qtyreq::NUMERIC * ) * (1 + bomdata_scrap::NUMERIC)) AS pendalloc,\n qtyAllocated(itemsite_id, DATE()) AS totalalloc,\n noNeg(qtyAvailable(itemsite_id)) AS qoh,\n qtyOrdered(itemsite_id, DATE()) AS ordered\n FROM indentedBOM(,\n getActiveRevId('BOM', ),\n 0,0) ib LEFT OUTER JOIN\n itemsite ON ((itemsite_item_id=bomdata_item_id)\n AND (itemsite_warehous_id=))\n WHERE (bomdata_item_id > 0)\n \n AND (CURRENT_DATE BETWEEN bomdata_effective AND (bomdata_expires-1))\n \n AND ( BETWEEN bomdata_effective AND (bomdata_expires-1))\n \n ) AS data\n\n WHERE ((qoh + ordered - (totalalloc + pendalloc)) < 0)\n \nORDER BY bomworkSequence(bomdata_bomwork_id);\n\n\n\n-- Single Level BOM\nSELECT itemsite_id, bomitem_seqnumber, item_number, item_descrip, uom_name,\n pendalloc, (totalalloc + pendalloc) AS totalalloc,\n qoh, (qoh + ordered - (totalalloc + pendalloc)) AS totalavail,\n reorderlevel,\n 'qty' AS pendalloc_xtnumericrole,\n 'qty' AS totalalloc_xtnumericrole,\n 'qty' AS qoh_xtnumericrole,\n 'qty' AS totalavail_xtnumericrole,\n CASE WHEN (qoh < pendalloc) THEN 'error' END AS qoh_qtforegroundrole,\n CASE WHEN ((qoh + ordered - (totalalloc + pendalloc)) < reorderlevel) THEN 'error'\n WHEN ((qoh + ordered - (totalalloc + pendalloc)) = reorderlevel) THEN 'warning'\n END AS totalavail_qtforegroundrole\nFROM ( SELECT itemsite_id, bomitem_seqnumber, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS item_descrip, uom_name,\n ((itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL,\n (bomitem_qtyfxd + bomitem_qtyper * ) * (1 + bomitem_scrap)))) AS pendalloc,\n qtyAllocated(itemsite_id, DATE()) AS totalalloc,\n noNeg(qtyAvailable(itemsite_id)) AS qoh,\n qtyOrdered(itemsite_id, DATE()) AS ordered,\n CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel\n FROM itemsite, item, bomitem(), uom\n WHERE ( (bomitem_item_id=itemsite_item_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_warehous_id=)\n \n AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires-1))\n \n AND ( BETWEEN bomitem_effective AND (bomitem_expires-1))\n \n )\n ) AS data\n\n WHERE ((qoh + ordered - (totalalloc + pendalloc)) < 0)\n \nORDER BY bomitem_seqnumber;\n\n \n admin 2015-10-01 0 269 pendingBOMChanges detail used by dspPendingBOMChanges\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: pendingBOMChanges\n-- Name: detail\n-- Notes: used by dspPendingBOMChanges\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT bomitem_id, actiondate, action,\n bomitem_seqnumber, item_number, description,\n uom_name, qtyfxd, qtyper,\n bomitem_scrap, actiondate,\n 'qty' AS qtyfxd_xtnumericrole,\n 'qtyper' AS qtyper_xtnumericrole,\n 'percent' AS bomitem_scrap_xtnumericrole \nFROM (SELECT bomitem_id, AS action,\n bomitem_seqnumber, item_number, (item_descrip1 || ' ' || item_descrip2) AS description,\n uom_name,\n (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS qtyfxd,\n (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS qtyper,\n bomitem_scrap, bomitem_effective AS actiondate \n FROM bomitem(,), item, uom \n WHERE ((bomitem_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (bomitem_effective BETWEEN CURRENT_DATE AND )) \n UNION \n SELECT bomitem_id, AS action, \n bomitem_seqnumber, item_number, (item_descrip1 || ' ' || item_descrip2) AS description,\n uom_name,\n (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS qtyfxd,\n (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS qtyper,\n bomitem_scrap, bomitem_expires AS actiondate \n FROM bomitem(,), item, uom \n WHERE ((bomitem_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n \n AND (bomitem_expires BETWEEN CURRENT_DATE AND ) )\n \n ) AS data \nORDER BY action, actiondate, bomitem_seqnumber;\n admin 2015-10-01 0 488 permissions privileges User Permissions (individual and role permissions)\n Notes: used by dspUserPrivileges\n Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: permissions\n-- Name: privileges\n-- Notes: User Permissions (individual and role permissions)\n-- Notes: used by dspUserPrivileges\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n-- Role Privileges\nSELECT usr_id, grp_id AS altid, usrgrp_username as priv_username, grp_name, priv_module, priv_name, priv_descrip \nFROM usrgrp\nJOIN usr ON (usrgrp_username=usr_username)\nJOIN grp ON (grp_id=usrgrp_grp_id)\nJOIN grppriv ON (grp_id=grppriv_grp_id)\nJOIN priv ON (priv_id=grppriv_priv_id)\nWHERE ((usr_active=true)\n\n AND (usrgrp_username=)\n\n\n AND (grp_id=)\n\n\n AND (priv_name ~* )\n\n)\n\nUNION \n\n-- Individual Privileges\nSELECT usr_id, -1 AS altid, usrpriv_username, 'User Privilege' AS grp_name, priv_module, priv_name, priv_descrip \nFROM usrpriv \nJOIN usr ON (usrpriv_username=usr_username)\nJOIN priv ON (priv_id=usrpriv_priv_id)\nWHERE ((usr_active=true)\n\n AND (usrpriv_username=)\n\n\n AND (priv_name ~* )\n\n\n AND (false)\n\n)\n\nORDER BY priv_username, priv_module, priv_name, grp_name;\n admin 2015-10-01 0 489 permissions role used by dspUserPrivileges\n User Permissions (Role permissions)\n Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: permissions\n-- Name: role\n-- Notes: used by dspUserPrivileges\n-- User Permissions (Role permissions)\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT usrgrp_username as role_username,grp_name, grp_descrip \nFROM usrgrp\nJOIN usr ON (usr_username=usrgrp_username)\nJOIN grp ON grp_id=usrgrp_grp_id\nWHERE (usr_active=true)\n\n AND usrgrp_username=\n\n\n AND (grp_id=)\n\nORDER BY usrgrp_username,grp_name admin 2015-10-01 0 270 poDeliveryDateVariances detail used by dspPoDeliveryDateVariancesByItem, dspPoDeliveryDateVariancesByVendor\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: poDeliveryDateVariances\n-- Name: detail\n-- Notes: used by dspPoDeliveryDateVariancesByItem, dspPoDeliveryDateVariancesByVendor\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n recv.*, vend_name,\n firstLine(recv_vend_item_number) AS itemnumber,\n firstLine(recv_vend_item_descrip) AS itemdescrip,\n DATE(recv_rlsd_duedate) - DATE(COALESCE(pohead_released, pohead_orderdate)) AS req_leadtime,\n DATE(recv_duedate) - DATE(COALESCE(pohead_released, pohead_orderdate)) AS agrd_leadtime,\n DATE(recv_date) - DATE(COALESCE(pohead_released, pohead_orderdate)) AS real_leadtime,\n DATE(recv_date) - DATE(recv_rlsd_duedate) AS req_diff,\n\t DATE(recv_date) - DATE(recv_duedate) AS argd_diff,\n DATE(recv_date) AS receivedate,\n formatDate(COALESCE(pohead_released, pohead_orderdate)) AS orderdate,\n formatDate(recv_date) AS f_recv_date,\n recv_rlsd_duedate AS release_duedate, \n\t recv_duedate AS argd_duedate,\n CASE WHEN (DATE(recv_date) - DATE(recv_rlsd_duedate) > 0) THEN 'error'\n END AS req_diff_qtforegroundrole,\n CASE WHEN (DATE(recv_date) - DATE(recv_duedate) > 0) THEN 'error'\n END AS argd_diff_qtforegroundrole, \n\t CASE WHEN (DATE(recv_date) > DATE(recv_duedate)) THEN 'error'\t\t\t \n END AS receivedate_qtforegroundrole,\t\t\t \n 'qty' AS recv_qty_xtnumericrole\n \n recv_id, recv_order_number, vend_name,\n DATE(recv_date) AS receivedate,\n formatDate(COALESCE(pohead_released, pohead_orderdate)) AS orderdate,\n firstLine(recv_vend_item_number) AS venditemnumber,\n firstLine(recv_vend_item_descrip) AS venditemdescrip,\n recv_qty, recv_duedate, recv_date,\n formatDate(recv_date) AS f_recv_date,\n DATE(recv_rlsd_duedate) - DATE(COALESCE(pohead_released, pohead_orderdate)) AS req_leadtime,\n DATE(recv_duedate) - DATE(COALESCE(pohead_released, pohead_orderdate)) AS agrd_leadtime,\n DATE(recv_date) - DATE(COALESCE(pohead_released, pohead_orderdate)) AS real_leadtime,\n DATE(recv_date) - DATE(recv_rlsd_duedate) AS req_diff,\n DATE(recv_date) - DATE(recv_duedate) AS argd_diff,\n firstLine(item.item_number) AS itemnumber,\n recv_rlsd_duedate AS release_duedate,\n recv_duedate AS argd_duedate,\n CASE WHEN (DATE(recv_date) - DATE(recv_rlsd_duedate) > 0) THEN 'error'\n END AS req_diff_qtforegroundrole,\n CASE WHEN (DATE(recv_date) - DATE(recv_duedate) > 0) THEN 'error'\n END AS argd_diff_qtforegroundrole,\n CASE WHEN (DATE(recv_date) > DATE(recv_duedate)) THEN 'error'\n END AS receivedate_qtforegroundrole,\n 'qty' AS recv_qty_xtnumericrole\n \n\nFROM recv LEFT OUTER JOIN vendinfo ON (vend_id=recv_vend_id)\n LEFT OUTER JOIN pohead ON (pohead_number=recv_order_number AND recv_order_type='PO')\n LEFT OUTER JOIN (itemsite JOIN item ON (item_id=itemsite_item_id)) ON (itemsite_id=recv_itemsite_id)\nWHERE ( TRUE\n\n AND (itemsite_item_id=)\n\n\n AND (DATE(recv_date) BETWEEN AND )\n\n\n AND (itemsite_warehous_id=)\n\n\n AND (recv_agent_username=)\n\n\n AND (vend_id=)\n\n\n AND (recv_agent_username=)\n\n )\nORDER BY\n recv_date DESC;\n admin 2015-10-01 0 271 poHistory detail used by dspPoHistory\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: poHistory\n-- Name: detail\n-- Notes: used by dspPoHistory\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT poitem_id, poitem.*,\n COALESCE(item_number, ) AS itemnumber,\n COALESCE(uom_name, ) AS uomname,\n CASE WHEN (LENGTH(TRIM(BOTH ' ' FROM poitem_vend_item_descrip)) <= 0)\n THEN(item_descrip1 || ' ' || item_descrip2)\n ELSE poitem_vend_item_descrip\n END AS itemdescription,\n 'qty' AS poitem_qty_ordered_xtnumericrole,\n 'qty' AS poitem_qty_received_xtnumericrole,\n 'qty' AS poitem_qty_returned_xtnumericrole\nFROM poitem LEFT OUTER JOIN\n ( itemsite JOIN item\n ON (itemsite_item_id=item_id) JOIN uom ON (item_inv_uom_id=uom_id))\n ON (poitem_itemsite_id=itemsite_id)\nWHERE (poitem_pohead_id=)\nORDER BY poitem_linenumber;\n admin 2015-10-01 0 272 poItems detail used by dspPoItemsByVendor, dspPoItemsByItem, dspPoItemsByDate\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: poItems\n-- Name: detail\n-- Notes: used by dspPoItemsByVendor, dspPoItemsByItem, dspPoItemsByDate\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pohead_id, poitem_id, pohead_number, poitem_status,\n CASE WHEN(poitem_status='C') THEN \n WHEN(poitem_status='U') THEN \n WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) \n AND (poitem_qty_ordered>(poitem_qty_received-poitem_qty_returned))) \n THEN \n WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) \n AND (poitem_qty_ordered<=(poitem_qty_received-poitem_qty_returned))) \n THEN \n WHEN(poitem_status='O') THEN \n ELSE poitem_status\n END AS f_poitem_status,\n vend_name,\n (SELECT warehous_code\n FROM whsinfo\n WHERE (COALESCE(itemsite_warehous_id, pohead_warehous_id)=warehous_id)) AS warehous_code,\n COALESCE(item_number, ) AS itemnumber,\n poitem_vend_item_number, poitem_vend_uom,\n COALESCE(item_descrip1, firstLine(poitem_vend_item_descrip)) AS itemdescrip,\n COALESCE(uom_name, poitem_vend_uom) AS itemuom,\n poitem_duedate, poitem_qty_ordered, poitem_qty_received, poitem_qty_returned,\n CASE WHEN (poitem_duedate < CURRENT_DATE) THEN 'error' END AS poitem_duedate_qtforegroundrole,\n 'qty' AS poitem_qty_ordered_xtnumericrole,\n 'qty' AS poitem_qty_received_xtnumericrole,\n 'qty' AS poitem_qty_returned_xtnumericrole \n FROM pohead\n JOIN poitem ON (pohead_id=poitem_pohead_id)\n JOIN vendinfo ON (pohead_vend_id=vend_id)\n LEFT OUTER JOIN (itemsite\n JOIN item ON (itemsite_item_id=item_id)\n JOIN uom ON (item_inv_uom_id=uom_id))\n ON (poitem_itemsite_id=itemsite_id)\nWHERE (TRUE\n\n AND (poitem_duedate BETWEEN AND )\n\n\n AND (((itemsite_id IS NULL) AND\n (pohead_warehous_id=) )\n OR\n ((itemsite_id IS NOT NULL) AND\n (itemsite_warehous_id=) ) )\n\n\n AND (pohead_agent_username=)\n\n\n AND (poitem_status='O')\n\n\n AND (poitem_status='C')\n\n\n AND (pohead_number=)\n\n\n AND (pohead_vend_id=) \n\n AND (vend_vendtype_id=)\n\n AND (vend_vendtype_id IN (SELECT vendtype_id\n FROM vendtype\n WHERE (vendtype_code ~ )))\n\n\n AND (itemsite_item_id=) \n\n )\nORDER BY poitem_duedate, pohead_number, poitem_linenumber\n;\n admin 2015-10-01 0 432 poItems list used by purchaseOrder\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: poItems\n-- Name: list\n-- Notes: used by purchaseOrder\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT poitem.*,\n CASE WHEN(poitem_status='C') THEN \n WHEN(poitem_status='U') THEN \n WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) AND (poitem_qty_ordered>(poitem_qty_received-poitem_qty_returned))) THEN \n WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) AND (poitem_qty_ordered<=(poitem_qty_received-poitem_qty_returned))) THEN \n WHEN(poitem_status='O') THEN \n ELSE poitem_status\n END AS poitemstatus,\n CASE WHEN (poitem_order_type='S') THEN \n WHEN (poitem_order_type='W') THEN \n ELSE ''\n END AS demand_type,\n CASE WHEN (poitem_order_type='S') THEN formatSoNumber(coitem_id)\n WHEN (poitem_order_type='W') THEN formatWoNumber(womatl_wo_id)\n ELSE ''\n END AS order_number,\n CASE WHEN (itemsite_id IS NULL) THEN poitem_vend_item_number\n ELSE item_number\n END AS item_number,\n CASE WHEN (itemsite_id IS NULL) THEN firstLine(poitem_vend_item_descrip)\n ELSE (item_descrip1 || ' ' || item_descrip2)\n END AS item_descrip,\n contrct_number, \n poitem_rlsd_duedate AS orgl_duedate,\n (poitem_unitprice * poitem_qty_ordered) AS extprice,\n CASE WHEN(poitem_status='C') THEN \n WHEN(poitem_status='U') THEN \n WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) AND (poitem_qty_ordered>(poitem_qty_received-poitem_qty_returned))) THEN \n WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) AND (poitem_qty_ordered<=(poitem_qty_received-poitem_qty_returned))) THEN \n WHEN(poitem_status='O') THEN \n ELSE poitem_status\n END AS poitem_status_qtdisplayrole,\n 'qty' AS poitem_qty_ordered_xtnumericrole,\n 'qty' AS poitem_qty_received_xtnumericrole,\n 'qty' AS poitem_qty_returned_xtnumericrole,\n 'qty' AS poitem_qty_vouchered_xtnumericrole,\n 'purchprice' AS poitem_unitprice_xtnumericrole,\n 'curr' AS extprice_xtnumericrole,\n 'curr' AS poitem_freight_xtnumericrole,\n 'curr' AS poitem_freight_received_xtnumericrole,\n 'curr' AS poitem_freight_vouchered_xtnumericrole,\n 'curr' AS poitem_stdcost_xtnumericrole\nFROM pohead JOIN poitem ON (poitem_pohead_id=pohead_id)\n LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id=item_id)\n LEFT OUTER JOIN coitem ON (poitem_order_type='S' AND poitem_order_id = coitem_id)\n LEFT OUTER JOIN womatl ON (poitem_order_type='W' AND poitem_order_id = womatl_id)\n LEFT OUTER JOIN itemsrc ON (poitem_itemsrc_id=itemsrc_id)\n LEFT OUTER JOIN contrct ON (itemsrc_contrct_id=contrct_id)\nWHERE (poitem_pohead_id=)\nORDER BY poitem_linenumber;\n admin 2015-10-01 0 130 poPriceVariances detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: poPriceVariances\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *\n,\n formatDate(distdate) AS f_date,\n formatQty(recv_qty) AS f_qty,\n formatCost(recv_recvcost) AS f_recv_recvcost,\n formatMoney(recv_value) AS f_recv_value,\n formatPrice(vouchercost) AS f_vouchercost,\n formatMoney(voucher_value) AS f_voucher_value,\n formatMoney(variance) AS f_variance, \n formatPrcnt(varprcnt/100) AS f_varprcnt\n\n FROM (\nSELECT recv_id, recv_order_number, recv_date, recv_order_type,\n DATE(recv_date) AS receivedate,\n vohead_distdate AS distdate,\n vend_number, vend_name,\n COALESCE(item_number, ( || recv_vend_item_number)) AS itemnumber,\n firstLine(COALESCE(item_descrip1, recv_vend_item_descrip)) AS itemdescrip,\n recv_qty,\n recv_purchcost,\n currConcat(recv_freight_curr_id) AS poCurrAbbr,\n\n COALESCE((recv_value / CASE WHEN (recv_qty <> 0.0) THEN recv_qty ELSE 1.0 END), 0.0) AS recv_recvcost,\n COALESCE(recv_value, 0.0) AS recv_value,\n COALESCE(currToBase(vohead_curr_id, SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END, vohead_distdate), 0.0) AS vouchercost,\n COALESCE(currToBase(vohead_curr_id, SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END, vohead_distdate) * recv_qty, 0.0) AS voucher_value,\n COALESCE(currToBase(vohead_curr_id, SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END, vohead_distdate) * recv_qty - recv_value, 0.0) AS variance,\n CASE WHEN (COALESCE(recv_value, 0.0) <> 0.0) THEN\n ((currToBase(vohead_curr_id, SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END, vohead_distdate) *\n recv_qty / recv_value) -1.0) * 100.0\n ELSE 100.0 END AS varprcnt, \n currConcat(baseCurrId()) AS currAbbr,\n '0' AS recv_value_xttotalrole,\n '0' AS voucher_value_xttotalrole,\n '0' AS variance_xttotalrole,\n -- local Currency\n COALESCE(currToLocal(vohead_curr_id, (recv_value / CASE WHEN (recv_qty <> 0.0) THEN recv_qty ELSE 1.0 END), vohead_distdate), 0.0) AS recv_recvcost,\n COALESCE(currToLocal(vohead_curr_id, recv_value, vohead_distdate), 0.0) AS recv_value,\n COALESCE(SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END, 0.0) AS vouchercost,\n COALESCE(SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END * recv_qty, 0.0) AS voucher_value,\n COALESCE(SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END * recv_qty - currToLocal(vohead_curr_id, recv_value, vohead_distdate), 0.0) AS variance,\n CASE WHEN (COALESCE(recv_value, 0.0) <> 0.0) THEN\n ((SUM(vodist_amount) / CASE WHEN (SUM(vodist_qty) <> 0.0) THEN SUM(vodist_qty) ELSE 1.0 END *\n recv_qty / currToLocal(vohead_curr_id, recv_value, vohead_distdate)) -1.0) * 100.0\n ELSE 100.0 END AS varprcnt, \n currConcat(vohead_curr_id) AS currAbbr,\n\n 'qty' AS recv_qty_xtnumericrole,\n 'purchprice' AS recv_purchcost_xtnumericrole,\n 'curr' AS recv_value_xtnumericrole,\n 'purchprice' AS vouchercost_xtnumericrole,\n 'curr' AS voucher_value_xtnumericrole,\n 'cost' AS recv_recvcost_xtnumericrole,\n 'curr' AS variance_xtnumericrole,\n 'prcnt' AS varprcnt_xtnumericrole\nFROM vendinfo\n JOIN vendtype ON (vend_vendtype_id=vendtype_id), recv\n LEFT OUTER JOIN (\n itemsite JOIN item ON (itemsite_item_id=item_id) )\n ON (recv_itemsite_id=itemsite_id)\n JOIN vodist ON ((vodist_poitem_id=recv_orderitem_id)\n AND (vodist_vohead_id=recv_vohead_id))\n JOIN vohead ON ((vodist_vohead_id=vohead_id) \n AND (vohead_posted))\nWHERE ( (recv_vend_id=vend_id)\nAND (recv_order_type='PO')\n\n AND (vend_id=)\n\n AND (vendtype_id=)\n\n AND (vendtype_code ~ )\n\n AND (DATE(vohead_distdate) BETWEEN AND ) \n\n AND (itemsite_warehous_id=)\n\n\n AND (itemsite_item_id=)\n\n\n AND (recv_agent_username=)\n\n )\nGROUP BY recv_id, recv_order_number, recv_order_type, recv_date, item_number, recv_vend_item_number,\n item_descrip1, recv_vend_item_descrip, recv_qty, recv_purchcost, recv_recvcost,\n vohead_curr_id, recv_freight_curr_id, vohead_docdate, vend_number, vend_name,\n recv_value, vohead_distdate\n) data\n\nWHERE (variance != 0)\n\nORDER BY distdate, recv_order_number DESC;\n admin 2015-10-01 0 273 poReturns detail used by dspPoReturnsByVendor\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: poReturns\n-- Name: detail\n-- Notes: used by dspPoReturnsByVendor\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT poreject_id, poreject_ponumber, vend_name,\n poreject_date, poreject_qty,\n poreject_vend_item_number, poreject_vend_item_descrip,\n rjctcode_code,\n 'qty' AS poreject_qty_xtnumericrole \nFROM poreject, vendinfo, itemsite, rjctcode\nWHERE ((poreject_posted)\n AND (poreject_vend_id=vend_id)\n AND (poreject_rjctcode_id=rjctcode_id)\n AND (poreject_itemsite_id=itemsite_id)\n AND (vend_id=)\n AND (DATE(poreject_date) BETWEEN AND )\n\n AND (itemsite_warehous_id=)\n\n\n AND (poreject_agent_username=)\n\n ) \nORDER BY poreject_date DESC;\n admin 2015-10-01 0 297 trialBalances detail used by dspTrialBalances\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: trialBalances\n-- Name: detail\n-- Notes: used by dspTrialBalances\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT accnt_id, period_id, accnt_descrip, trialbal_dirty,\n period_start, period_end,\n formatGLAccount(accnt_id) AS account,\n (trialbal_debits) AS debits,\n (trialbal_credits) AS credits,\n trialbal_beginning AS beginning,\n trialbal_ending AS ending,\n (trialbal_debits - trialbal_credits) AS diff,\n CASE WHEN ((trialbal_beginning*-1.0)<0.0) THEN 'CR' END AS beginningsense,\n CASE WHEN ((trialbal_ending*-1.0)<0.0) THEN 'CR' END AS endingsense,\n CASE WHEN ((trialbal_debits - trialbal_credits)<0.0) THEN 'CR' END AS diffsense,\n 'curr' AS beginning_xtnumericrole,\n 'curr' AS debits_xtnumericrole,\n 'curr' AS credits_xtnumericrole,\n 'curr' AS ending_xtnumericrole,\n 'curr' AS diff_xtnumericrole,\n 0 AS beginning_xttotalrole,\n 0 AS debits_xttotalrole,\n 0 AS credits_xttotalrole,\n 0 AS ending_xttotalrole,\n 0 AS diff_xttotalrole,\n CASE WHEN (trialbal_beginning < 0.0) THEN ABS(trialbal_beginning) END AS beginning_qtdisplayrole,\n CASE WHEN (trialbal_ending < 0.0) THEN ABS(trialbal_ending) END AS ending_qtdisplayrole,\n CASE WHEN ((trialbal_debits - trialbal_credits) < 0.0) THEN ABS(trialbal_debits - trialbal_credits) END AS diff_qtdisplayrole,\n CASE WHEN (trialbal_dirty) THEN 'warning' END AS ending_qtforegroundrole\nFROM trialbal, accnt, period\n\n ,company\n\nWHERE ((trialbal_accnt_id=accnt_id)\n AND (trialbal_period_id=period_id)\n\n AND (trialbal_accnt_id=)\n\n\n AND (accnt_company=company_number)\n AND (company_id=)\n\n\n AND (period_id=)\n\n\n AND (abs(trialbal_beginning)+abs(trialbal_ending)+abs(trialbal_debits)+abs(trialbal_credits) > 0)\n\n )\nORDER BY period_start, formatGLAccount(accnt_id);\n admin 2015-10-01 0 441 postCountTags post \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: postCountTags\n-- Name: post\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT MIN(postCountTag(invcnt_id, )) AS result\n FROM invcnt, itemsite, item\n WHERE ((invcnt_itemsite_id=itemsite_id)\n AND (invcnt_qoh_after IS NOT NULL)\n AND (NOT invcnt_posted)\n AND (itemsite_item_id=item_id)\n\n AND (itemsite_warehous_id=)\n\n\n\n AND (item_classcode_id=)\n\n AND (item_classcode_id IN (SELECT classcode_id\n FROM classcode\n WHERE (classcode_code ~ )))\n\n AND (itemsite_plancode_id=)\n\n AND (itemsite_plancode_id IN (SELECT plancode_id\n FROM plancode\n WHERE (plancode_code ~ )))\n\n);\n admin 2015-10-01 0 414 postJournals detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: postJournals\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *\nFROM (\n SELECT 0 AS id,\n sltrans_source,\n 0 AS xtindentrole,\n CASE WHEN sltrans_source = 'A/P' THEN \n WHEN sltrans_source = 'A/R' THEN \n WHEN sltrans_source = 'G/L' THEN \n WHEN sltrans_source = 'I/M' THEN \n WHEN sltrans_source = 'P/D' THEN \n WHEN sltrans_source = 'S/O' THEN \n WHEN sltrans_source = 'S/R' THEN \n WHEN sltrans_source = 'W/O' THEN \n ELSE \n END AS description, \n NULL AS debit, \n NULL AS credit, \n count(sltrans_id) AS journals\n FROM sltrans\n WHERE ((NOT sltrans_posted)\n AND (sltrans_amount > 0)\n AND (sltrans_date BETWEEN AND ))\n GROUP BY sltrans_source\n\nUNION ALL\n SELECT \n sltrans_accnt_id AS id,\n sltrans_source,\n 1 AS xtindentrole,\n formatGLAccountLong(sltrans_accnt_id) AS description,\n CASE WHEN SUM(sltrans_amount) < 0 THEN ABS(SUM(sltrans_amount))\n END AS debit,\n CASE WHEN SUM(sltrans_amount) > 0 THEN SUM(sltrans_amount)\n END AS credit,\n NULL AS journals\n FROM sltrans\n WHERE ((NOT sltrans_posted)\n AND (sltrans_date BETWEEN AND ))\n GROUP BY sltrans_accnt_id, sltrans_source\n\n) data\nORDER BY sltrans_source, xtindentrole\n admin 2015-10-01 0 413 postJournals post \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: postJournals\n-- Name: post\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT * \nFROM postJournals(\nARRAY[\n\n \n,\n \n \n\n], \n, \n, \n) AS result;\n admin 2015-10-01 0 229 pricelist detail This query displays price lists and the data used to perform\n price calculations. It avoids price calculations where possible.\n The UNION sets the sourcecode column to show how the price list entry\n was derived: customer vs customer type vs customer type regex ..., etc.\n Then the outer query modifies the sourcecode to indicate\n item vs product category.\n TODO: possible improvements include removing OUTER JOINs with uom table\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: pricelist\n-- Name: detail\n-- Notes: This query displays price lists and the data used to perform\n-- price calculations. It avoids price calculations where possible.\n-- The UNION sets the sourcecode column to show how the price list entry\n-- was derived: customer vs customer type vs customer type regex ..., etc.\n-- Then the outer query modifies the sourcecode to indicate\n-- item vs product category.\n-- TODO: possible improvements include removing OUTER JOINs with uom table\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT sourcecode + CASE WHEN source='P' THEN 10 ELSE 0 END AS source,\n sourceid, schedulename, type,\n invqty AS qty_break,\n CASE WHEN (qtybreak = -1) THEN \n END AS qty_break_qtdisplayrole,\n invuom.uom_name AS qty_uom,\n price,\n currConcat(curr_id) AS currency,\n priceuom.uom_name AS price_uom,\n currToCurr(curr_id, ,\n price, ) AS base_price,\n discountpercent,\n discountfixed,\n CASE WHEN (price_type='N') THEN \n WHEN (price_type='D') THEN \n WHEN (price_type='M') THEN \n END AS price_type,\n 'qty' AS qty_break_xtnumericrole,\n 'salesprice' AS price_xtnumericrole,\n 'salesprice' AS base_price_xtnumericrole,\n 'percent' AS discountpercent_xtnumericrole,\n 'salesprice' AS discountfixed_xtnumericrole\nFROM ( \n\n SELECT 4 AS sourcecode,\n ipsitem_id AS sourceid,\n CASE WHEN (ipsitem_item_id=) THEN 'I'\n WHEN (ipsitem_prodcat_id=) THEN 'P'\n ELSE 'Error'\n END AS source,\n ipshead_id,\n ipshead_name AS schedulename,\n ( || '-' || sale_name) AS type,\n CASE WHEN (ipsitem_item_id=) THEN itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak)\n ELSE ipsitem_qtybreak\n END AS invqty,\n ipsitem_qtybreak AS qtybreak,\n CASE WHEN (ipsitem_type = 'N') THEN\n (ipsitem_price * itemuomtouomratio(, NULL, ipsitem_price_uom_id)) * iteminvpricerat(ipsitem_item_id)\n WHEN (ipsitem_type = 'D') THEN\n noNeg( - ( * ipsitem_discntprcnt) - ipsitem_fixedamtdiscount)\n WHEN ((ipsitem_type = 'M') AND fetchMetricBool('Long30Markups') AND fetchMetricBool('WholesalePriceCosting')) THEN\n ( / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n WHEN ((ipsitem_type = 'M') AND fetchMetricBool('Long30Markups')) THEN\n ( / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n WHEN (ipsitem_type = 'M' AND fetchMetricBool('WholesalePriceCosting')) THEN\n ( + ( * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n WHEN (ipsitem_type = 'M') THEN\n ( + ( * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n ELSE 0.00\n END AS price,\n ipsitem_qty_uom_id AS qtybreak_uom_id,\n ipsitem_price_uom_id AS price_uom_id,\n ipsitem_discntprcnt AS discountpercent,\n ipsitem_fixedamtdiscount AS discountfixed,\n ipshead_curr_id AS curr_id,\n ipsitem_type AS price_type\n FROM sale JOIN ipshead ON (ipshead_id=sale_ipshead_id)\n JOIN ipsiteminfo ON (ipsitem_ipshead_id=ipshead_id)\n JOIN ipsass ON (ipsass_ipshead_id=ipshead_id)\n WHERE ((ipsitem_item_id=) OR (ipsitem_prodcat_id=))\n AND ( BETWEEN sale_startdate AND sale_enddate)\n AND ( ((COALESCE(ipsass_shipto_id, -1) > 0) AND (ipsass_shipto_id=))\n OR ((COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) AND ( ~ ipsass_shipto_pattern))\n OR (ipsass_cust_id=)\n OR (ipsass_custtype_id=)\n OR ((COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) AND ( ~ ipsass_custtype_pattern)) )\n\n UNION\n\n SELECT CASE WHEN (COALESCE(ipsass_shipto_id, -1) > 0) THEN 6\n WHEN (COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) THEN 7\n WHEN (COALESCE(ipsass_cust_id, -1) > 0) THEN 1\n WHEN (COALESCE(ipsass_custtype_id, -1) > 0) THEN 2\n WHEN (COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) THEN 3\n ELSE 99\n END AS sourcecode,\n ipsitem_id AS sourceid,\n CASE WHEN (ipsitem_item_id=) THEN 'I'\n WHEN (ipsitem_prodcat_id=) THEN 'P'\n ELSE 'Error'\n END AS source,\n ipshead_id,\n ipshead_name AS schedulename,\n CASE WHEN (COALESCE(ipsass_shipto_id, -1) > 0) THEN \n WHEN (COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) THEN \n WHEN (COALESCE(ipsass_cust_id, -1) > 0) THEN \n WHEN (COALESCE(ipsass_custtype_id, -1) > 0) THEN \n WHEN (COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) THEN \n ELSE 'Error'\n END AS type,\n CASE WHEN (ipsitem_item_id=) THEN itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak)\n ELSE ipsitem_qtybreak\n END AS invqty,\n ipsitem_qtybreak AS qtybreak,\n CASE WHEN ipsitem_type = 'N' THEN\n (ipsitem_price * itemuomtouomratio(, NULL, ipsitem_price_uom_id)) * iteminvpricerat(ipsitem_item_id)\n WHEN ipsitem_type = 'D' THEN\n noNeg( - ( * ipsitem_discntprcnt) - ipsitem_fixedamtdiscount)\n WHEN ((ipsitem_type = 'M') AND fetchMetricBool('Long30Markups') AND fetchMetricBool('WholesalePriceCosting')) THEN\n ( / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n WHEN ((ipsitem_type = 'M') AND fetchMetricBool('Long30Markups')) THEN\n ( / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n WHEN (ipsitem_type = 'M' AND fetchMetricBool('WholesalePriceCosting')) THEN\n ( + ( * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n WHEN (ipsitem_type = 'M') THEN\n ( + ( * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount)\n ELSE 0.00\n END AS price,\n ipsitem_qty_uom_id AS qtybreak_uom_id,\n ipsitem_price_uom_id AS price_uom_id,\n ipsitem_discntprcnt AS discountpercent,\n ipsitem_fixedamtdiscount AS discountfixed,\n ipshead_curr_id AS curr_id,\n ipsitem_type AS price_type\n FROM ipsass JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n JOIN ipsiteminfo ON (ipsitem_ipshead_id=ipshead_id)\n WHERE ((ipsitem_item_id=) OR (ipsitem_prodcat_id=))\n AND ( BETWEEN ipshead_effective AND ipshead_expires)\n AND ( ((COALESCE(ipsass_shipto_id, -1) > 0) AND (ipsass_shipto_id=))\n OR ((COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) AND ( ~ ipsass_shipto_pattern))\n OR (ipsass_cust_id=)\n OR (ipsass_custtype_id=)\n OR ((COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) AND ( ~ ipsass_custtype_pattern))\n )\n\n UNION\n\n SELECT 5 AS sourcecode,\n item_id AS sourceid,\n NULL AS source,\n NULL AS ipshead_id,\n '' AS schedulename,\n AS type,\n -1 AS invqty,\n -1 AS qtybreak,\n (item_listprice - (item_listprice * cust_discntprcnt)) AS price,\n item_inv_uom_id AS qtybreak_uom_id,\n item_price_uom_id AS price_uom_id,\n cust_discntprcnt AS discountpercent,\n NULL AS discountfixed,\n baseCurrId() AS curr_id,\n NULL AS price_type\n FROM item, custinfo\n WHERE (item_sold\n AND (NOT item_exclusive)\n AND (item_id=)\n AND (cust_id=) ) ) AS data\n\n LEFT OUTER JOIN uom AS invuom ON (invuom.uom_id=qtybreak_uom_id)\n LEFT OUTER JOIN uom AS priceuom ON (priceuom.uom_id=price_uom_id)\n\n ORDER BY price_uom_id, price;\n admin 2015-10-01 0 442 pricingFreight detail used by itemPricingScheduleItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: pricingFreight\n-- Name: detail\n-- Notes: used by itemPricingScheduleItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT ipsfreight.*\n FROM ipsfreight\n WHERE ( (true)\n\n \n AND (ipsfreight_ipshead_id=)\n \n \n AND (ipsfreight_warehous_id=)\n \n AND (ipsfreight_warehous_id IS NULL)\n \n \n AND (ipsfreight_shipzone_id=)\n \n AND (ipsfreight_shipzone_id IS NULL)\n \n \n AND (ipsfreight_freightclass_id=)\n \n AND (ipsfreight_freightclass_id IS NULL)\n \n \n AND (ipsfreight_shipvia=)\n \n AND (ipsfreight_shipvia IS NULL)\n \n \n AND (ipsfreight_qtybreak=)\n \n AND (ipsfreight_id <> )\n\n AND (ipsfreight_id=)\n\n );\n admin 2015-10-01 0 459 projectTasks detail \n Copyright (c) 1999-2013 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: projectTasks\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2013 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT prjtask_id, prjtask_number, prjtask_name,\n COALESCE(prjtask_hours_budget - prjtask_hours_actual, 0.0) as prjtaskhrbal,\n COALESCE(prjtask_exp_budget - prjtask_exp_actual, 0.0) as prjtaskexpbal,\n firstLine(prjtask_descrip) AS prjtask_descrip,\n totalhrbud, totalhract, totalhrbal,\n totalexpbud, totalexpact, totalexpbal\nFROM (SELECT COALESCE(SUM(prjtask_hours_budget), 0.0) AS totalhrbud,\n COALESCE(SUM(prjtask_hours_actual), 0.0) AS totalhract,\n COALESCE(SUM(prjtask_hours_budget - prjtask_hours_actual), 0.0) AS totalhrbal,\n COALESCE(SUM(prjtask_exp_budget), 0.0) AS totalexpbud,\n COALESCE(SUM(prjtask_exp_actual), 0.0) AS totalexpact,\n COALESCE(SUM(prjtask_exp_budget - prjtask_exp_actual), 0.0) AS totalexpbal\n FROM prjtask\n WHERE prjtask_prj_id = ) foo, prjtask\nWHERE (prjtask_prj_id=)\nORDER BY prjtask_number;\n admin 2015-10-01 0 122 updateprices createselsched \n Notes:\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: updateprices\n-- Name: createselsched\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nCREATE TEMPORARY TABLE selsched (\n selsched_ipshead_id INTEGER PRIMARY KEY );\n admin 2015-10-01 0 480 projects detail_nohierarchy Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n\n Non-hierarchical view to support CSV export from Project List screen\n -- Group: projects\n-- Name: detail_nohierarchy\n-- Notes: Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n--\n-- Non-hierarchical view to support CSV export from Project List screen\n\nSELECT prj_id AS id, 1 AS altId,\n prj.*, crmacct_name, cntct_name,\n addr_city, addr_state,\n prjtype_descr AS project_type,\n CASE WHEN (prj_status='P') THEN \n WHEN (prj_status='O') THEN \n WHEN (prj_status='C') THEN \n ELSE END AS project_status\n\n , charass_alias.charass_value AS char\n\n\n , charass_alias.charass_value AS char\n\n\n , charass_alias.charass_value::date AS char\n\nFROM prj()\nLEFT JOIN prjtype ON (prj_prjtype_id=prjtype_id)\nLEFT JOIN crmacct ON (prj_crmacct_id=crmacct_id)\nLEFT JOIN cntct ON (crmacct_cntct_id_1=cntct_id)\nLEFT JOIN addr ON (cntct_addr_id=addr_id)\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='PROJ')\n AND (charass_alias.charass_target_id=prj_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='PROJ')\n AND (charass_alias.charass_target_id=prj_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias ON ((charass_alias.charass_target_type='PROJ')\n AND (charass_alias.charass_target_id=prj_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias ON (charass_alias.charass_char_id=char_alias.char_id)\n\nWHERE (true)\n\n AND ( (prj_number ~* )\n OR (prj_name ~* )\n OR (prj_descrip ~* ) )\n\n\n AND (prj_username= OR prj_owner_username=)\n\n\n AND (prj_username=)\n\n AND (prj_username ~ )\n\n\n AND (prj_owner_username=)\n\n AND (prj_owner_username ~ )\n\n\n AND (prj_crmacct_id=)\n\n\n AND (prj_cntct_id=)\n\n\n AND (prj_prjtype_id=)\n\n\n AND (prj_status=)\n\n AND (prj_status <> 'C')\n\n\n AND (prj_start_date >= )\n\n\n AND (prj_start_date <= )\n\n\n AND (prj_due_date >= )\n\n\n AND (prj_due_date <= )\n\n\n AND (prj_assigned_date >= )\n\n\n AND (prj_assigned_date <= )\n\n\n AND (prj_completed_date >= )\n\n\n AND (prj_completed_date <= )\n\n\n AND (prj_id=)\n\n\n AND (prj_id=)\n\n\n AND prj_id IN (SELECT DISTINCT prjtask_prj_id FROM prjtask where ((prjtask_number ~* )\n\t\t\t\t\t\tOR (prjtask_name ~* )\n\t\t\t\t\t\tOR (prjtask_descrip ~* )))\n\n\n AND prj_id IN (SELECT cohead_prj_id FROM cohead where cohead_id=)\n\n\n AND prj_id IN (SELECT wo_prj_id FROM wo WHERE wo_id=)\n\n\n AND prj_id IN (SELECT poitem_prj_id FROM pohead JOIN poitem ON (pohead_id=poitem_pohead_id)\n\t\t\tWHERE pohead_id=)\n\n\nORDER BY prj_number; admin 2015-10-01 0 277 projects detail \n Copyright (c) 1999-2013 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n\n xTuple version 4.2.0 - Modified to significantly amend the display of this screen and its filters.\n xTuple version 4.3.0 - Add Incidents to hierarchy display\n -- Group: projects\n-- Name: detail\n-- Notes:\n-- Copyright (c) 1999-2013 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n--\n-- xTuple version 4.2.0 - Modified to significantly amend the display of this screen and its filters.\n-- xTuple version 4.3.0 - Add Incidents to hierarchy display\nSELECT *,\n formatQty(qty) AS f_qty,\n formatMoney(value) AS f_value,\n 'curr' AS qty_xtnumericrole,\n 'curr' AS value_xtnumericrole,\n CASE WHEN COALESCE(hrs_balance,0) < 0 THEN 'red' END AS hrs_balance_qtforegroundrole,\n CASE WHEN COALESCE(exp_balance,0) < 0 THEN 'red' END AS exp_balance_qtforegroundrole\nFROM (\nSELECT prj_id AS id,\n 1 AS type,\n '0' AS subtype,\n 0 AS section,\n prj_id AS project,\n NULL AS section_qtdisplayrole,\n prj_number AS name,\n CASE\n WHEN prj_status = 'C' THEN \n WHEN prj_status = 'O' THEN \n WHEN prj_status = 'P' THEN \n END AS status,\n COALESCE(prjtype_descr, 'Undefined') AS project_type,\n prj_username,\n prj_owner_username,\n prj_name AS item,\n firstline(prj_descrip) AS descrip,\n crmacct_name AS customer,\n cntct_name AS contact,\n addr_city AS city,\n addr_state AS state,\n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n prj_due_date AS due,\n prj_assigned_date AS assigned,\n prj_start_date AS started,\n prj_completed_date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n CASE WHEN (prj_status = 'O' AND prj_due_date < current_date) THEN 'red'\n WHEN (prj_status = 'O' AND prj_due_date BETWEEN current_date AND current_date + (fetchmetricvalue('ProjectDueDateWarning')||' days')::interval) THEN 'orange'\n END AS due_qtforegroundrole,\n 0 AS xtindentrole\n FROM prj()\n LEFT OUTER JOIN prjtype ON (prj_prjtype_id=prjtype_id)\n LEFT OUTER JOIN crmacct ON (prj_crmacct_id=crmacct_id)\n LEFT OUTER JOIN cntct ON (crmacct_cntct_id_1=cntct_id)\n LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n\n WHERE (1=1 )\n\nUNION ALL\n----- TASKS -----\nSELECT DISTINCT -1 AS id,\n 3 AS type,\n '0' AS subtype,\n 1 AS section,\n prjtask_prj_id AS project,\n AS section_qtdisplayrole,\n AS name,\n NULL::text AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n NULL::text AS due_qtforegroundrole,\n 1 AS xtindentrole\n FROM prjtask\nUNION ALL\n\nSELECT prjtask_id AS id,\n 5 AS type,\n '0' AS subtype,\n 1 AS section,\n prjtask_prj_id AS project,\n NULL AS section_qtdisplayrole,\n prjtask_number AS name,\n CASE\n WHEN prjtask_status = 'C' THEN \n WHEN prjtask_status = 'O' THEN \n WHEN prjtask_status = 'P' THEN \n END AS status,\n NULL::text AS project_type,\n prjtask_username AS prj_username,\n prjtask_owner_username AS prj_owner_username,\n prjtask_name AS item,\n prjtask_descrip AS descrip,\n cust_name as customer,\n cntct_name AS contact,\n addr_city AS city,\n addr_state AS state,\n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n prjtask_due_date AS due,\n prjtask_assigned_date AS assigned,\n prjtask_start_date AS started,\n prjtask_completed_date AS completed,\n prjtask_hours_budget AS hrs_budget,\n prjtask_hours_actual AS hrs_actual,\n (prjtask_hours_budget-prjtask_hours_actual) AS hrs_balance,\n prjtask_exp_budget AS exp_budget,\n prjtask_exp_actual AS exp_actual,\n (prjtask_exp_budget-prjtask_exp_actual) AS exp_balance,\n CASE WHEN (prjtask_status = 'O' AND prjtask_due_date < current_date) THEN 'red'\n WHEN (prjtask_status = 'O' AND prjtask_due_date BETWEEN current_date AND current_date + (fetchmetricvalue('ProjectDueDateWarning')||' days')::interval) THEN 'orange'\n END AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM prjtask\n LEFT OUTER JOIN te.teprjtask ON (prjtask_id = teprjtask_prjtask_id)\n LEFT OUTER JOIN custinfo ON (teprjtask_cust_id=cust_id)\n LEFT OUTER JOIN cntct ON (cust_corrcntct_id=cntct_id)\n LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n\n WHERE (1=1 )\n GROUP BY prjtask_prj_id, custinfo.cust_name, prjtask.prjtask_id, addr.addr_city, addr.addr_state, cntct_name, prjtask.prjtask_number, prjtask.prjtask_status, prjtask_username, prjtask.prjtask_owner_username, prjtask_name, prjtask_descrip, prjtask_due_date, prjtask_assigned_date, prjtask_start_date, prjtask_completed_date, prjtask_hours_budget, prjtask_hours_actual, prjtask_exp_budget, prjtask_exp_actual\n\n\n\nUNION ALL\n----- INCIDENTS -----\nSELECT DISTINCT -1 AS id,\n 100 AS type,\n '0' AS subtype,\n 1 AS section,\n incdt_prj_id AS project,\n 'Incidents' AS section_qtdisplayrole,\n 'Incidents' AS name,\n NULL::text AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n NULL::text AS due_qtforegroundrole,\n 1 AS xtindentrole\n FROM incdt\nUNION ALL\n\nSELECT incdt_id AS id,\n 105 AS type,\n '0' AS subtype,\n 1 AS section,\n incdt_prj_id AS project,\n NULL AS section_qtdisplayrole,\n incdt_number::text AS name,\n CASE\n WHEN incdt_status = 'L' THEN \n WHEN incdt_status = 'N' THEN \n WHEN incdt_status = 'F' THEN \n WHEN incdt_status = 'A' THEN \n WHEN incdt_status = 'R' THEN \n WHEN incdt_status = 'C' THEN \n END AS status,\n NULL::text AS project_type,\n incdt_assigned_username AS prj_username,\n incdt_owner_username AS prj_owner_username,\n incdt_number::text AS item,\n incdt_summary AS descrip,\n crmacct_number AS customer,\n crmacct_name AS contact,\n addr_city AS city,\n addr_state AS state,\n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n NULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM incdt\n LEFT OUTER JOIN crmacct ON (incdt_crmacct_id=crmacct_id)\n LEFT OUTER JOIN cntct ON (incdt_cntct_id=cntct_id)\n LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n\n WHERE (1=1 )\n GROUP BY incdt_id, incdt_prj_id, incdt_number, crmacct_number, crmacct_name, addr.addr_city, addr.addr_state, cntct_name, incdt_number, incdt_status, incdt_assigned_username, incdt_owner_username, incdt_number, incdt_summary\n\n\n\nUNION ALL\n\n----- QUOTES -----\nSELECT DISTINCT -1 AS id,\n 10 AS type,\n '0' AS subtype,\n 1 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n AS name,\n NULL::text AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n NULL::text AS due_qtforegroundrole,\n 1 AS xtindentrole\n FROM quhead\n JOIN prj() ON (quhead_prj_id=prj_id)\n WHERE (1=1)\nUNION ALL\n\nSELECT quhead_id AS id,\n 15 AS type,\n quhead_number AS subtype,\n 1 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n quhead_number AS name,\n CASE WHEN (quhead_status = 'C') THEN\n \n WHEN (quhead_status = 'X') THEN\n \n WHEN (COALESCE(quhead_expire, current_date + 1) > current_date) THEN\n \n ELSE\n \n END AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n NULL::text AS item,\n NULL::text AS descrip,\n cust_name AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL AS qty,\n NULL::text AS uom,\n NULL AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n NULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM quhead\n JOIN prj() ON (quhead_prj_id=prj_id)\n JOIN custinfo ON (quhead_cust_id=cust_id)\n JOIN quitem ON (quitem_quhead_id = quhead_id)\n WHERE (1=1)\nGROUP BY prj_id, quhead_id, quhead_number, quhead_status, quhead_expire, quhead_freight, quhead_misc, custinfo.cust_name\n\nUNION ALL\n\nSELECT quitem_id AS id,\n 17 AS type,\n quhead_number AS subtype,\n 1 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n quitem_linenumber::text AS name,\n CASE WHEN (quhead_status = 'C') THEN\n \n WHEN (quhead_status = 'X') THEN\n \n WHEN (COALESCE(quhead_expire, current_date + 1) > current_date) THEN\n \n ELSE\n \n END AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n item_number AS item,\n item_descrip1 || ' ' || item_descrip2 AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n quitem_qtyord,\n uom_name AS uom,\n (quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n NULL::text AS due_qtforegroundrole,\n 3 AS xtindentrole\n FROM quhead\n JOIN prj() ON (quhead_prj_id=prj_id)\n JOIN quitem ON (quitem_quhead_id = quhead_id)\n JOIN uom ON (quitem_qty_uom_id = uom_id)\n JOIN itemsite ON (quitem_itemsite_id = itemsite_id)\n JOIN item ON (itemsite_item_id = item_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT quhead_id AS id,\n 18 AS type,\n quhead_number AS subtype,\n 1 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n AS name,\n NULL AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL AS qty,\n NULL::text AS uom,\n SUM((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio)) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM quhead\n JOIN prj() ON (quhead_prj_id=prj_id)\n JOIN quitem ON (quitem_quhead_id = quhead_id)\n WHERE (1=1)\nGROUP BY prj_id, quhead_id, quhead_number\n\nUNION ALL\n\nSELECT -1 AS id,\n 19 AS type,\n MAX(quhead_number) AS subtype,\n 1 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n || ' ' || AS name,\n NULL AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL AS qty,\n NULL::text AS uom,\n SUM((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio)) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM quhead\n JOIN prj() ON (quhead_prj_id=prj_id)\n JOIN quitem ON (quitem_quhead_id = quhead_id)\n WHERE (1=1)\n GROUP BY prj_id\n\nUNION ALL\n\n------ SALES ORDERS ------\nSELECT DISTINCT -1 AS id,\n 20 AS type,\n '0' AS subtype,\n 2 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n AS name,\n NULL::text AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 1 AS xtindentrole\n FROM cohead\n JOIN prj() ON (cohead_prj_id=prj_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT cohead_id AS id,\n 25 AS type,\n cohead_number::text AS subtype,\n 2 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n cohead_number::text AS name,\n COALESCE((SELECT\n CASE WHEN (coitem_status = 'O') THEN\n \n WHEN (coitem_status = 'C') THEN\n \n ELSE\n \n END\n FROM\n (SELECT coitem_status,\n CASE\n WHEN (coitem_status = 'O') THEN 1\n WHEN (coitem_status = 'C') then 2\n ELSE 3\n END AS type\n FROM coitem\n WHERE (coitem_cohead_id=cohead_id)\n ORDER BY type\n LIMIT 1) AS sts) ,'O')\n AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n shipto_num AS item,\n shipto_name AS descrip,\n cust_name AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL AS qty,\n NULL::text AS uom,\n NULL AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM cohead\n JOIN prj() ON (cohead_prj_id=prj_id)\n JOIN custinfo ON (cust_id = cohead_cust_id)\n LEFT OUTER JOIN shiptoinfo ON (cohead_shipto_id = shipto_id)\n JOIN coitem ON (coitem_cohead_id = cohead_id)\n WHERE (1=1)\nGROUP BY prj_id,cohead_id, cohead_number, shipto_num, shipto_name, cust_name\n\nUNION ALL\n\nSELECT coitem_id AS id,\n 27 AS type,\n cohead_number::text AS subtype,\n 2 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n coitem_linenumber::text AS name,\n CASE WHEN (coitem_status = 'O') THEN\n \n WHEN (coitem_status = 'C') THEN\n \n WHEN (coitem_status = 'X') THEN\n \n END AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n item_number AS item,\n item_descrip1 || ' ' || item_descrip2 AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n coitem_qtyord,\n uom_name AS uom,\n (coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 3 AS xtindentrole\n FROM cohead\n JOIN prj() ON (cohead_prj_id=prj_id)\n JOIN coitem ON (coitem_cohead_id = cohead_id)\n JOIN uom ON (coitem_qty_uom_id = uom_id)\n JOIN itemsite ON (coitem_itemsite_id = itemsite_id)\n JOIN item ON (itemsite_item_id = item_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT cohead_id AS id,\n 28 AS type,\n cohead_number::text AS subtype,\n 2 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n AS name,\n NULL AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL AS qty,\n NULL::text AS uom,\n SUM((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio)) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM cohead\n JOIN prj() ON (cohead_prj_id=prj_id)\n JOIN coitem ON (coitem_cohead_id = cohead_id)\n WHERE (1=1)\nGROUP BY prj_id,cohead_id, cohead_number\n\nUNION ALL\n\nSELECT -1 AS id,\n 29 AS type,\n MAX(cohead_number::text) AS subtype,\n 2 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n || ' ' || AS name,\n NULL AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL AS qty,\n NULL::text AS uom,\n SUM((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio)) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM cohead\n JOIN prj() ON (cohead_prj_id=prj_id)\n JOIN coitem ON (coitem_cohead_id = cohead_id)\n WHERE (1=1)\n GROUP BY prj_id\n\nUNION ALL\n\n------ INVOICES -------\nSELECT DISTINCT -1 AS id,\n 30 AS type,\n '0' AS subtype,\n 3 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n AS name,\n NULL::text AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 1 AS xtindentrole\n FROM invchead\n JOIN prj() ON (invchead_prj_id=prj_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT invchead_id AS id,\n 35 AS type,\n invchead_invcnumber::text AS subtype,\n 3 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n invchead_invcnumber::text AS name,\n CASE WHEN (invchead_posted) THEN\n \n ELSE \n END AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n shipto_num AS item,\n shipto_name AS descrip,\n cust_name AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL AS qty,\n NULL::text AS uom,\n NULL AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM invchead\n JOIN prj() ON (invchead_prj_id=prj_id)\n JOIN custinfo ON (cust_id=invchead_cust_id)\n LEFT OUTER JOIN shiptoinfo ON (invchead_shipto_id = shipto_id)\n\n JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n WHERE (1=1)\nGROUP BY prj_id,invchead_id, invchead_invcnumber, shipto_num, shipto_name, invchead_freight, invchead_misc_amount, invchead_posted, cust_name\n\nUNION ALL\n\nSELECT invcitem_id AS id,\n 37 AS type,\n invchead_invcnumber::text AS subtype,\n 3 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n invcitem_linenumber::text AS name,\n CASE WHEN (invchead_posted) THEN\n \n ELSE \n END AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n COALESCE(item_number,invcitem_number) AS item,\n COALESCE(item_descrip1 || ' ' || item_descrip2,invcitem_descrip) AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n invcitem_billed AS qty,\n uom_name AS uom,\n (invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 3 AS xtindentrole\n FROM invchead\n JOIN prj() ON (invchead_prj_id=prj_id)\n JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n LEFT OUTER JOIN item ON (invcitem_item_id = item_id)\n LEFT OUTER JOIN uom ON (invcitem_qty_uom_id = uom_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT invchead_id AS id,\n 38 AS type,\n invchead_invcnumber::text AS subtype,\n 3 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n AS name,\n NULL AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL AS qty,\n NULL::text AS uom,\n SUM((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio)) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM invchead\n JOIN prj() ON (invchead_prj_id=prj_id)\n JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n WHERE (1=1)\nGROUP BY prj_id,invchead_id, invchead_invcnumber\n\nUNION ALL\n\nSELECT -1 AS id,\n 39 AS type,\n MAX(invchead_invcnumber::text) AS subtype,\n 3 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n || ' ' || AS name,\n NULL AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL AS qty,\n NULL::text AS uom,\n SUM((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio)) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM invchead\n JOIN prj() ON (invchead_prj_id=prj_id)\n JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n WHERE (1=1)\n GROUP BY prj_id\n\n\n\n\nUNION ALL\n\n------ WORK ORDERS -------\nSELECT DISTINCT -1 AS id,\n 40 AS type,\n '0' AS subtype,\n 4 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n AS name,\n NULL::text AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 1 AS xtindentrole\n FROM wo\n JOIN prj() ON (wo_prj_id=prj_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT wo_id AS id,\n 45 AS type,\n formatWoNumber(wo_id) AS subtype,\n 4 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n formatWoNumber(wo_id) AS name,\n CASE WHEN (wo_status = 'O') THEN\n \n WHEN (wo_status = 'E') THEN\n \n WHEN (wo_status = 'R') THEN\n \n WHEN (wo_status = 'I') THEN\n \n WHEN (wo_status = 'C') THEN\n \n END AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n item_number AS item,\n item_descrip1 || ' ' || item_descrip2 AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n wo_qtyord AS qty,\n uom_name AS uom,\n wo_postedvalue AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM wo\n JOIN prj() ON (wo_prj_id=prj_id)\n JOIN itemsite ON (itemsite_id=wo_itemsite_id)\n JOIN item ON (itemsite_item_id=item_id)\n JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT -1 AS id,\n 49 AS type,\n MAX(formatWoNumber(wo_id)) AS subtype,\n 4 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n || ' ' || AS name,\n NULL AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL AS qty,\n NULL::text AS uom,\n SUM(wo_postedvalue) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM wo\n JOIN prj() ON (wo_prj_id=prj_id)\n WHERE (1=1)\n GROUP BY prj_id\n\n\n\n\n\n UNION ALL\n------ PURCHASE REQUESTS ------\nSELECT DISTINCT -1 AS id,\n 50 AS type,\n '0' AS subtype,\n 5 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n AS name,\n NULL::text AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 1 AS xtindentrole\n FROM pr\n JOIN prj() ON (pr_prj_id=prj_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT pr_id AS id,\n 55 AS type,\n pr_number::text || '-' || pr_subnumber::text AS subtype,\n 5 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n pr_number::text || '-' || pr_subnumber::text AS name,\n AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n item_number AS item,\n (item_descrip1 || ' ' || item_descrip2) AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n pr_qtyreq AS qty,\n uom_name AS uom,\n stdcost(item_id) * pr_qtyreq AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM pr\n JOIN prj() ON (pr_prj_id=prj_id)\n JOIN itemsite ON (itemsite_id = pr_itemsite_id)\n JOIN item ON (itemsite_item_id = item_id)\n JOIN uom ON (item_inv_uom_id = uom_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT -1 AS id,\n 59 AS type,\n MAX(pr_number::text || '-' || pr_subnumber::text) AS subtype,\n 5 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n || ' ' || AS name,\n NULL AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL AS qty,\n NULL::text AS uom,\n SUM(stdcost(item_id) * pr_qtyreq) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM pr\n JOIN prj() ON (pr_prj_id=prj_id)\n JOIN itemsite ON (itemsite_id = pr_itemsite_id)\n JOIN item ON (itemsite_item_id = item_id)\n WHERE (1=1)\n GROUP BY prj_id\n\nUNION ALL\n\n------ PURCHASE ORDERS ------\nSELECT DISTINCT -1 AS id,\n 60 AS type,\n '0' AS subtype,\n 6 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n AS name,\n NULL::text AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL::numeric AS qty,\n NULL::text AS uom,\n NULL::numeric AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 1 AS xtindentrole\n FROM poitem\n JOIN prj() ON (poitem_prj_id=prj_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT pohead_id AS id,\n 65 AS type,\n pohead_number::text AS subtype,\n 6 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n pohead_number::text AS name,\n CASE WHEN (pohead_status = 'U') THEN\n \n WHEN (pohead_status = 'O') THEN\n \n WHEN (pohead_status = 'C') THEN\n \n END AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n NULL AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL AS qty,\n NULL AS uom,\n NULL AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM pohead\n JOIN poitem ON (poitem_pohead_id = pohead_id)\n JOIN prj() ON (poitem_prj_id=prj_id)\n WHERE (1=1)\nGROUP BY prj_id,pohead_id, pohead_number, pohead_freight, pohead_status\n\nUNION ALL\n\nSELECT poitem_id AS id,\n 67 AS type,\n pohead_number::text AS subtype,\n 6 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n poitem_linenumber::text AS name,\n CASE WHEN (poitem_status = 'U') THEN\n \n WHEN (poitem_status = 'O') THEN\n \n WHEN (poitem_status = 'C') THEN\n \n END AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n COALESCE(item_number,poitem_vend_item_number) AS item,\n COALESCE((item_descrip1 || ' ' || item_descrip2),poitem_vend_item_descrip) AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n poitem_qty_ordered,\n poitem_vend_uom AS uom,\n (poitem_qty_ordered * poitem_unitprice) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 3 AS xtindentrole\n FROM pohead\n JOIN poitem ON (poitem_pohead_id = pohead_id)\n JOIN prj() ON (poitem_prj_id=prj_id)\n LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id = item_id)\n WHERE (1=1)\n\nUNION ALL\n\nSELECT pohead_id AS id,\n 68 AS type,\n pohead_number::text AS subtype,\n 6 AS section,\n prj_id AS project,\n AS section_qtdisplayrole,\n AS name,\n NULL AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL AS qty,\n NULL::text AS uom,\n SUM(poitem_qty_ordered * poitem_unitprice) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM pohead\n JOIN poitem ON (poitem_pohead_id = pohead_id)\n JOIN prj() ON (poitem_prj_id=prj_id)\n WHERE (1=1)\nGROUP BY prj_id,pohead_id, pohead_number\n\nUNION ALL\n\nSELECT -1 AS id,\n 69 AS type,\n MAX(pohead_number::text) AS subtype,\n 6 AS section,\n prj_id AS project,\n 'qty' AS section_qtdisplayrole,\n || ' ' || AS name,\n NULL AS status,\n NULL::text AS project_type,\n NULL::text AS prj_username,\n NULL::text AS prj_owner_username,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL::text AS customer,\n NULL::text AS contact,\n NULL::text AS city,\n NULL::text AS state,\n NULL AS qty,\n NULL::text AS uom,\n SUM(poitem_qty_ordered * poitem_unitprice) AS value,\n NULL::date AS due,\n NULL::date AS assigned,\n NULL::date AS started,\n NULL::date AS completed,\n NULL::numeric AS hrs_budget,\n NULL::numeric AS hrs_actual,\n NULL::numeric AS hrs_balance,\n NULL::numeric AS exp_budget,\n NULL::numeric AS exp_actual,\n NULL::numeric AS exp_balance,\n\n\tNULL::text AS due_qtforegroundrole,\n 2 AS xtindentrole\n FROM pohead\n JOIN poitem ON (poitem_pohead_id = pohead_id)\n JOIN prj() ON (poitem_prj_id=prj_id)\n WHERE (1=1)\n GROUP BY prj_id\n\n\n\n) data\n\nWHERE (true)\n\n AND project IN (SELECT prj_id FROM prj WHERE ( (prj_number ~* )\n OR (prj_name ~* )\n OR (prj_descrip ~* ) ))\n\n\n AND (prj_username= OR prj_owner_username=)\n\n\n AND (prj_username=)\n\n AND (prj_username ~ )\n\n\n AND (prj_owner_username=)\n\n AND (prj_owner_username ~ )\n\n\n AND project IN (SELECT prj_id FROM prj WHERE (prj_crmacct_id=))\n\n\n AND project IN (SELECT prj_id FROM prj WHERE (prj_cntct_id=))\n\n\n AND project IN (SELECT prj_id FROM prj WHERE (prj_start_date >= ))\n\n\n AND project IN (SELECT prj_id FROM prj WHERE (prj_start_date <= ))\n\n\n AND project IN (SELECT prj_id FROM prj WHERE (prj_due_date >= ))\n\n\n AND project IN (SELECT prj_id FROM prj WHERE (prj_due_date <= ))\n\n\n AND project IN (SELECT prj_id FROM prj WHERE (prj_assigned_date >= ))\n\n\n AND project IN (SELECT prj_id FROM prj WHERE (prj_assigned_date <= ))\n\n\n AND project IN (SELECT prj_id FROM prj WHERE (prj_completed_date >= ))\n\n\n AND project IN (SELECT prj_id FROM prj WHERE (prj_completed_date <= ))\n\n\n AND project IN (SELECT prj_id FROM prj WHERE prj_status <> 'C')\n\n\n AND (project=)\n\n\n AND project IN (SELECT prj_id FROM prj WHERE (prj_prjtype_id=))\n\n\n AND project IN (SELECT DISTINCT prjtask_prj_id FROM prjtask where ((prjtask_number ~* )\n\t\t\t\t\t\tOR (prjtask_name ~* )\n\t\t\t\t\t\tOR (prjtask_descrip ~* )))\n\n\n AND project IN (SELECT cohead_prj_id FROM cohead where cohead_id=)\n\n\n AND project IN (SELECT wo_prj_id FROM wo WHERE wo_id=)\n\n\n AND project IN (SELECT poitem_prj_id FROM pohead JOIN poitem ON (pohead_id=poitem_pohead_id)\n\t\t\tWHERE pohead_id=)\n\n\nORDER BY project, section, subtype, type, id;\n admin 2015-10-01 0 278 prospects detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: prospects\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n prospect.*,\n cntct.*, addr.*\nFROM prospect \n LEFT OUTER JOIN cntct ON (prospect_cntct_id=cntct_id) \n LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) \nWHERE true\n \n AND prospect_active \n\n \n AND (prospect_owner_username=) \n\n AND (prospect_owner_username ~ ) \n\n\n AND ((prospect_number ~* )\n OR (prospect_name ~* )\n OR (COALESCE(cntct_first_name,'') || ' ' || COALESCE(cntct_last_name,'') ~* )\n OR (COALESCE(cntct_phone,'') || ' ' || COALESCE(cntct_phone2,'') || ' ' || COALESCE(cntct_fax,'') ~* )\n OR (COALESCE(cntct_email,'') ~* )\n OR (COALESCE(addr_line1,'') || ' ' || COALESCE(addr_line2,'') || ' ' || COALESCE(addr_line3,'') ~* )\n OR (COALESCE(addr_city,'') ~* )\n OR (COALESCE(addr_state,'') ~* )\n OR (COALESCE(addr_postalcode,'') ~* )\n OR (COALESCE(addr_country,'') ~* ))\n\n\n AND (prospect_number ~* )\n\n\n AND (prospect_name ~* )\n\n\n AND (COALESCE(cntct_first_name,'') || ' ' || COALESCE(cntct_last_name,'') ~* )\n\n\n AND (COALESCE(cntct_phone,'') || ' ' || COALESCE(cntct_phone2,'') || ' ' || COALESCE(cntct_fax,'') ~* )\n\n\n AND (COALESCE(cntct_email,'') ~* )\n\n\n AND (COALESCE(addr_line1,'') || ' ' || COALESCE(addr_line2,'') || ' ' || COALESCE(addr_line3,'') ~* )\n\n\n AND (COALESCE(addr_city,'') ~* )\n\n\n AND (COALESCE(addr_state,'') ~* )\n\n\n AND (COALESCE(addr_postalcode,'') ~* )\n\n\n AND (COALESCE(addr_country,'') ~* )\n\n\n AND (prospect_id=\n\nORDER BY prospect_number; \n admin 2015-10-01 0 73 purchase purchaserequests \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: purchase\n-- Name: purchaserequests\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pr_id, itemsite_id, itemsite_qtyonhand, itemsite_reorderlevel,\n qtyNetable(itemsite_id) AS netableqoh, qtyNetable(itemsite_id, FALSE) AS nonnetableqoh,\n item_number, (item_descrip1 || ' ' || item_descrip2) AS description,\n pr.*,\n CASE WHEN (pr_order_type='W') THEN ('W/O ' || ( SELECT formatWoNumber(womatl_wo_id)\n FROM womatl\n WHERE (womatl_id=pr_order_id) ) )\n WHEN (pr_order_type='S') THEN ('S/O ' || (SELECT formatSoNumber(pr_order_id)))\n WHEN (pr_order_type='F') THEN ('Planned Order')\n WHEN (pr_order_type='M') THEN \n ELSE \n END AS parent,\n 'qty' AS itemsite_qtyonhand_xtnumericrole, \n 'qty' AS itemsite_reorderlevel_xtnumericrole,\n 'qty' AS pr_qtyreq_xtnumericrole \nFROM pr, itemsite, item \nWHERE ((pr_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n\n AND (pr_duedate BETWEEN AND )\n\n\n AND (itemsite_warehous_id=)\n\n\n AND (itemsite_item_id=)\n\n AND (itemsite_plancode_id=)\n\n AND (itemsite_plancode_id IN (SELECT plancode_id FROM\n plancode\n WHERE (plancode_code ~ ) ) )\n\n) \nORDER BY pr_duedate;\n admin 2015-10-01 0 443 purchaseOrderItems detail used by purchaseOrderItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: purchaseOrderItems\n-- Name: detail\n-- Notes: used by purchaseOrderItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pohead_number, pohead_taxzone_id,\n pohead_curr_id, pohead_orderdate,\n COALESCE(pohead_cohead_id, -1) AS pohead_cohead_id,\n poitem_linenumber, poitem_vend_item_number,\n poitem_vend_item_descrip, poitem_vend_uom,\n poitem_invvenduomratio, poitem_status,\n poitem_duedate, poitem_qty_ordered,\n poitem_qty_received, poitem_unitprice,\n poitem_freight, poitem_taxtype_id,\n poitem_tax_recoverable, poitem_comments,\n poitem_prj_id, poitem_bom_rev_id,\n poitem_boo_rev_id, poitem_manuf_name,\n poitem_manuf_item_number, poitem_manuf_item_descrip,\n COALESCE(poitem_itemsite_id, -1) AS poitem_itemsite_id,\n COALESCE(poitem_itemsrc_id, -1) AS poitem_itemsrc_id,\n COALESCE(poitem_expcat_id, -1) AS poitem_expcat_id,\n COALESCE(poitem_order_id, -1) AS poitem_order_id,\n CASE WHEN (poitem_order_type='S') THEN TEXT()\n WHEN (poitem_order_type='W') THEN TEXT()\n ELSE ''\n END AS demand_type,\n CASE WHEN (poitem_order_type='S') THEN formatSoNumber(coitem_id)\n WHEN (poitem_order_type='W') THEN formatWoNumber(womatl_wo_id)\n ELSE ''\n END AS order_number,\n poitem_unitprice * poitem_qty_ordered AS extended_price,\n COALESCE(coitem_prcost, 0.0) AS override_cost,\n contrct_number,\n itemsrc.*\n FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id)\n LEFT OUTER JOIN itemsrc ON (itemsrc_id=poitem_itemsrc_id)\n LEFT OUTER JOIN coitem ON (poitem_order_type='S' AND coitem_id=poitem_order_id)\n LEFT OUTER JOIN womatl ON (poitem_order_type='W' AND womatl_id=poitem_order_id)\n LEFT OUTER JOIN contrct ON (itemsrc_contrct_id=contrct_id)\n WHERE ( (TRUE)\n\n AND (poitem_id=)\n\n);\n admin 2015-10-01 0 72 purchaseOrders detail used by dspPosByVendor, dspPOsByDate\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: purchaseOrders\n-- Name: detail\n-- Notes: used by dspPosByVendor, dspPOsByDate\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pohead_id, pohead_number,\n warehous_code AS warehousecode,\n poitem_status, pohead_orderdate,\n CASE WHEN(poitem_status='C') THEN TEXT()\n WHEN(poitem_status='U') THEN TEXT()\n WHEN(poitem_status='O'\n AND (SUM(poitem_qty_received-poitem_qty_returned) > 0) \n AND (SUM(poitem_qty_ordered)>SUM(poitem_qty_received-poitem_qty_returned))) \n THEN TEXT()\n WHEN(poitem_status='O'\n AND (SUM(poitem_qty_received-poitem_qty_returned) > 0) \n AND (SUM(poitem_qty_ordered)<=SUM(poitem_qty_received-poitem_qty_returned))) \n THEN TEXT()\n WHEN(poitem_status='O') THEN TEXT()\n ELSE poitem_status\n END AS poitem_status_qtdisplayrole,\n\n vend_name,\n MIN(poitem_duedate) AS minDueDate,\n CASE WHEN (MIN(poitem_duedate) < CURRENT_DATE) THEN 'error'\n END AS minDueDate_qtforegroundrole,\n\n vend_number,\n\n\n MIN(date(recv_date)) AS sortDate,\n\n MIN(poitem_duedate) AS sortDate,\n\n pohead_orderdate AS sortDate,\n\n CASE WHEN (MIN(poitem_duedate) < CURRENT_DATE) THEN 'error' END AS sortDate_qtforegroundrole,\n-- Report formatting\n formatDate(pohead_orderdate) AS f_orderdate,\n formatDate(MIN(poitem_duedate)) AS f_duedate, \n CASE WHEN(poitem_status='C') THEN TEXT()\n WHEN(poitem_status='U') THEN TEXT()\n WHEN(poitem_status='O'\n AND (SUM(poitem_qty_received-poitem_qty_returned) > 0) \n AND (SUM(poitem_qty_ordered)>SUM(poitem_qty_received-poitem_qty_returned))) \n THEN TEXT()\n WHEN(poitem_status='O'\n AND (SUM(poitem_qty_received-poitem_qty_returned) > 0) \n AND (SUM(poitem_qty_ordered)<=SUM(poitem_qty_received-poitem_qty_returned))) \n THEN TEXT()\n WHEN(poitem_status='O') THEN TEXT()\n ELSE poitem_status\n END AS f_status\n-- End Report formatting\n FROM vendinfo, poitem,\n\n recv,\n\n pohead LEFT OUTER JOIN whsinfo ON (pohead_warehous_id=warehous_id)\n WHERE ((poitem_pohead_id=pohead_id)\n AND (pohead_vend_id=vend_id)\n\n AND (recv_itemsite_id=poitem_itemsite_id)\n AND (recv_order_number=pohead_number)\n AND (date(recv_date) BETWEEN AND )\n AND (recv_order_type='PO')\n\n AND (poitem_duedate BETWEEN AND )\n\n AND (pohead_orderdate BETWEEN AND )\n\n\n AND (vend_id=)\n\n AND (vend_vendtype_id=)\n\n AND (vend_vendtype_id IN (SELECT vendtype_id\n FROM vendtype\n WHERE (vendtype_code ~ )))\n\n\n AND (pohead_warehous_id=)\n\n\n AND (poitem_status!='C')\n\n\n AND (pohead_agent_username=)\n\n\n AND ((poitem_vend_item_descrip ~* )\n OR (poitem_itemsite_id IN (\n SELECT itemsite_id\n FROM itemsite, item\n WHERE ((itemsite_item_id=item_id)\n AND ((item_descrip1 ~* )\n OR (item_descrip2 ~* )))\n )))\n\n\n)\nGROUP BY pohead_id, pohead_number, warehous_code,\n poitem_status, pohead_orderdate,\n\n vend_name \n\n vend_number\n\nORDER BY\n\n minDueDate\n\n sortDate\n;\n admin 2015-10-01 0 279 qoh detail \n Quantity on Hand By Location\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: qoh\n-- Name: detail\n-- Notes: \n-- Quantity on Hand By Location\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT itemloc_id, alt_id, warehous_code, item_number,\n f_descrip, f_lotserial, uom_name,\n qoh, reservedqty,\n 'qty' AS qoh_xtnumericrole,\n 'qty' AS reservedqty_xtnumericrole,\n level AS xtindentrole\nFROM (\n SELECT itemloc_id, 0 AS alt_id, 0 AS level, item_number AS sortkey, warehous_code, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS f_descrip,\n formatlotserialnumber(itemloc_ls_id) AS f_lotserial, uom_name,\n itemloc_qty AS qoh,\n \n qtyReservedLocation(itemloc_id) AS reservedqty\n \n 0 AS reservedqty\n \n FROM itemloc, itemsite, whsinfo, item, uom\n WHERE ((itemloc_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (itemloc_location_id=))\n UNION\n SELECT -1 AS itemloc_id, 0 AS alt_id, 0 AS level, item_number AS sortkey, warehous_code, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS f_descrip,\n AS f_lotserial, uom_name,\n itemsite_qtyonhand AS qoh,\n 0 AS reservedqty\n FROM itemsite, whsinfo, item, uom\n WHERE ((itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (NOT itemsite_loccntrl)\n AND (itemsite_location_id=))\n \n UNION\n SELECT itemloc_id, -1 AS alt_id, 1 AS level, item_number AS sortkey, '' AS warehous_code, '' AS item_number,\n (reserve_demand_type || '-' || formatSOItemNumber(reserve_demand_id)) AS f_descrip,\n '' AS f_lotserial, '' AS uom_name,\n NULL AS qoh,\n reserve_qty AS reservedqty\n FROM reserve, itemloc, itemsite, item\n WHERE ((reserve_supply_id=itemloc_id)\n AND (reserve_supply_type='I')\n AND (itemsite_id=itemloc_itemsite_id)\n AND(item_id=itemsite_item_id)\n AND(itemloc_location_id=))\n \n \n UNION\n SELECT itemloc_id, coitem_cohead_id AS alt_id, 1 AS level, item_number AS sortkey, '' AS warehous_code, '' AS item_number,\n (|| '-' || formatSOItemNumber(coitem_id)) AS f_descrip,\n '' AS f_lotserial, '' AS uom_name,\n itemUOMtoUOM(item_id, coitem_qty_uom_id, NULL, (coitem_qtyord - coitem_qtyshipped - qtyAtShipping(coitem_id))) AS qoh,\n 0 AS reservedqty\n FROM itemloc JOIN itemsite ON (itemsite_id=itemloc_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN coitem ON (coitem_itemsite_id=itemloc_itemsite_id AND coitem_status='O')\n WHERE ((coitem_qtyord > (coitem_qtyshipped + qtyAtShipping(coitem_id)))\n AND(itemloc_location_id=))\n UNION\n SELECT itemloc_id, -1 AS alt_id, 1 AS level, item_number AS sortkey, '' AS warehous_code, '' AS item_number,\n (|| '-' || formatWONumber(womatl_wo_id)) AS f_descrip,\n '' AS f_lotserial, '' AS uom_name,\n (womatl_qtyreq - womatl_qtyiss) AS qoh,\n 0 AS reservedqty\n FROM itemloc JOIN itemsite ON (itemsite_id=itemloc_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN womatl ON (womatl_itemsite_id=itemloc_itemsite_id)\n WHERE ((womatl_qtyreq > womatl_qtyiss)\n AND(itemloc_location_id=))\n UNION\n SELECT itemloc_id, -1 AS alt_id, 1 AS level, item_number AS sortkey, '' AS warehous_code, '' AS item_number,\n (|| '-' || formatTONumber(toitem_id)) AS f_descrip,\n '' AS f_lotserial, '' AS uom_name,\n (toitem_qty_ordered - toitem_qty_shipped - qtyAtShipping('TO', toitem_id)) AS qoh,\n 0 AS reservedqty\n FROM itemloc JOIN itemsite ON (itemsite_id=itemloc_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN toitem ON (toitem_item_id=item_id AND toitem_status='O')\n JOIN tohead ON (tohead_id=toitem_tohead_id AND tohead_src_warehous_id=itemsite_warehous_id)\n WHERE ((toitem_qty_ordered > (toitem_qty_shipped + qtyAtShipping('TO', toitem_id)))\n AND(itemloc_location_id=))\n \n ) AS data\nORDER BY\n sortkey, itemloc_id, level;\n\n\nSELECT forwardupdateinvbalance(invbal_id)\nFROM (\n SELECT DISTINCT ON (itemsite_id) invbal_id\n FROM invbal, itemsite, item, whsinfo, classcode, uom, costcat, period\n WHERE ((invbal_dirty)\n AND (invbal_period_id=period_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (itemsite_active)\n AND (item_inv_uom_id=uom_id)\n AND (item_classcode_id=classcode_id)\n AND (itemsite_costcat_id=costcat_id)\n \n AND (itemsite_item_id=)\n \n \n AND (classcode_id=)\n \n \n AND (classcode_id IN (SELECT classcode_id\n FROM classcode\n WHERE classcode_code ~ ))\n \n \n AND (costcat_id=)\n \n \n AND (costcat_id IN (SELECT costcat_id\n FROM costcat\n WHERE costcat_code ~ ))\n \n \n AND (item_id IN (SELECT itemgrpitem_item_id\n FROM itemgrpitem\n WHERE (itemgrpitem_itemgrp_id=)))\n \n \n AND (item_id IN (SELECT itemgrpitem_item_id\n FROM itemgrpitem, itemgrp\n WHERE ((itemgrpitem_itemgrp_id=itemgrp_id)\n AND (itemgrp_name ~ ))))\n \n \n AND (itemsite_qtyonhand > 0)\n \n AND (itemsite_qtyonhand < 0)\n \n \n AND (itemsite_warehous_id=)\n \n )\n ORDER BY itemsite_id, period_start\n ) AS data\n;\n\n-- Quantity on Hand\nSELECT itemsite_id, detail,warehous_code,\n classcode_code, item_number, uom_name,\n costcat_code,\n item_descrip1, item_descrip2,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n defaultlocation,\n reorderlevel, formatQty(reorderlevel) AS f_reorderlevel,\n qoh, formatQty(qoh) AS f_qoh,\n availqoh, formatQty(availqoh) AS f_availqoh,\n nonavailqoh, formatQty(nonavailqoh) AS f_nonavailqoh,\n netqoh, formatQty(netqoh) AS f_netqoh,\n nonnetqoh, formatQty(nonnetqoh) AS f_nonnetqoh,\n cost, (cost * qoh) AS value,\n (cost * availqoh) AS availvalue,\n (cost * nonavailqoh) AS nonavailvalue,\n (cost * netqoh) AS netvalue,\n (cost * nonnetqoh) AS nonnetvalue,\n CASE WHEN(itemsite_costmethod='A') THEN 'Average'\n WHEN(itemsite_costmethod='S') THEN 'Standard'\n WHEN(itemsite_costmethod='J') THEN 'Job'\n WHEN(itemsite_costmethod='N') THEN 'None'\n ELSE 'UNKNOWN'\n END AS costmethod,\n \n formatMoney(cost) AS f_cost, (cost * qoh) AS f_value,\n formatMoney(cost * availqoh) AS f_availvalue,\n formatMoney(cost * nonavailqoh) AS f_nonavailvalue,\n formatMoney(cost * netqoh) AS f_netvalue,\n formatMoney(cost * nonnetqoh) AS f_nonnetvalue,\n CASE WHEN(itemsite_costmethod='A') THEN 'Average'\n WHEN(itemsite_costmethod='S') THEN 'Standard'\n WHEN(itemsite_costmethod='J') THEN 'Job'\n WHEN(itemsite_costmethod='N') THEN 'None'\n ELSE 'UNKNOWN'\n END AS f_costmethod,\n \n 'qty' AS reorderlevel_xtnumericrole,\n 'qty' AS qoh_xtnumericrole,\n 'qty' AS availqoh_xtnumericrole,\n 'qty' AS nonavailqoh_xtnumericrole,\n 'qty' AS netqoh_xtnumericrole,\n 'qty' AS nonnetqoh_xtnumericrole,\n 0 AS qoh_xttotalrole,\n 0 AS availqoh_xttotalrole,\n 0 AS nonavailqoh_xttotalrole,\n 0 AS netqoh_xttotalrole,\n 0 AS nonnetqoh_xttotalrole,\n 'cost' AS cost_xtnumericrole,\n 'curr' AS value_xtnumericrole,\n 'curr' AS availvalue_xtnumericrole,\n 'curr' AS nonavailvalue_xtnumericrole,\n 'curr' AS netvalue_xtnumericrole,\n 'curr' AS nonnetvalue_xtnumericrole,\n 0 AS value_xttotalrole,\n 0 AS availvalue_xttotalrole,\n 0 AS nonavailvalue_xttotalrole,\n 0 AS netvalue_xttotalrole,\n 0 AS nonnetvalue_xttotalrole,\n AS availqoh_xtnullrole,\n AS nonavailqoh_xtnullrole,\n AS availvalue_xtnullrole,\n AS nonavailvalue_xtnullrole,\n AS netqoh_xtnullrole,\n AS nonnetqoh_xtnullrole,\n AS netvalue_xtnullrole,\n AS nonnetvalue_xtnullrole,\n CASE WHEN (qoh < 0) THEN 'error' END AS qoh_qtforegroundrole,\n CASE WHEN (reorderlevel > qoh) THEN 'warning' END AS qoh_qtforegroundrole\nFROM (\n SELECT itemsite_id, itemsite_loccntrl, itemsite_costmethod,\n ((itemsite_loccntrl) OR (itemsite_controlmethod IN ('L', 'S')) ) AS detail,\n classcode_code, item_number, uom_name, item_descrip1, item_descrip2,\n costcat_code, \n CASE WHEN (NOT useDefaultLocation(itemsite_id)) THEN \n ELSE defaultLocationName(itemsite_id)\n END AS defaultlocation,\n warehous_code,\n CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel,\n \n COALESCE(invbal_qoh_ending,0) AS qoh,\n COALESCE(invbal_qoh_ending,0) AS availqoh,\n COALESCE(invbal_nn_ending,0) AS nonavailqoh,\n COALESCE(invbal_qoh_ending,0) AS netqoh,\n COALESCE(invbal_nn_ending,0) AS nonnetqoh,\n \n itemsite_qtyonhand AS qoh,\n qtyAvailable(itemsite_id) AS availqoh,\n qtyAvailable(itemsite_id, FALSE) AS nonavailqoh,\n qtyNetable(itemsite_id) AS netqoh,\n qtyNetable(itemsite_id, FALSE) AS nonnetqoh,\n \n \n stdcost(item_id) AS cost\n \n actcost(item_id) AS cost\n \n \n COALESCE((invbal_value_ending / CASE WHEN(invbal_qoh_ending=0) THEN 1\n ELSE invbal_qoh_ending END),0) AS cost\n \n (itemsite_value / CASE WHEN(itemsite_qtyonhand=0) THEN 1\n ELSE itemsite_qtyonhand END) AS cost\n \n \n FROM item, whsinfo, classcode, uom, costcat, itemsite\n \n LEFT OUTER JOIN invbal ON ((itemsite_id=invbal_itemsite_id)\n AND (invbal_period_id=))\n \n WHERE ((itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (itemsite_active)\n AND (item_inv_uom_id=uom_id)\n AND (item_classcode_id=classcode_id)\n AND (itemsite_costcat_id=costcat_id)\n \n AND (itemsite_item_id=)\n \n \n AND (classcode_id=)\n \n \n AND (classcode_id IN (SELECT classcode_id\n FROM classcode\n WHERE classcode_code ~ ))\n \n \n AND (costcat_id=)\n \n \n AND (costcat_id IN (SELECT costcat_id\n FROM costcat\n WHERE costcat_code ~ ))\n \n \n AND (item_id IN (SELECT itemgrpitem_item_id\n FROM itemgrpitem\n WHERE (itemgrpitem_itemgrp_id=)))\n \n \n AND (item_id IN (SELECT itemgrpitem_item_id\n FROM itemgrpitem, itemgrp\n WHERE ((itemgrpitem_itemgrp_id=itemgrp_id)\n AND (itemgrp_name ~ ))))\n \n \n \n AND (COALESCE(invbal_qoh_ending,0) > 0)\n \n AND (itemsite_qtyonhand > 0)\n \n \n \n AND (COALESCE(invbal_qoh_ending,0) < 0)\n \n AND (itemsite_qtyonhand < 0)\n \n \n \n AND (itemsite_warehous_id=)\n \n )\n ) AS data\nORDER BY warehous_code, item_number;\n\n admin 2015-10-01 0 123 updateprices dropselsched \n Notes:\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: updateprices\n-- Name: dropselsched\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDROP TABLE selsched;\n admin 2015-10-01 0 74 quoteItems detail used by dspQuotesByItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: quoteItems\n-- Name: detail\n-- Notes: used by dspQuotesByItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT quitem_id, quhead_id,\n quitem.*, quhead.*,\n COALESCE(cust_number, prospect_number) AS cust_number,\n COALESCE(cust_name, prospect_name) AS cust_name,\n 'qty' AS quitem_qtyord_xtnumericrole\nFROM quitem JOIN quhead ON (quhead_id=quitem_quhead_id)\n LEFT OUTER JOIN custinfo ON (cust_id=quhead_cust_id)\n LEFT OUTER JOIN prospect ON (prospect_id=quhead_cust_id)\n JOIN itemsite ON (itemsite_id=quitem_itemsite_id)\n JOIN site() ON (warehous_id=itemsite_warehous_id)\nWHERE ( (1=1)\n\n AND (itemsite_item_id=)\n\n\n AND (quhead_status IN ('C','O'))\n\n AND (quhead_status NOT IN ('C','X'))\n\n\n AND (quhead_quotedate BETWEEN AND )\n\n )\nORDER BY quhead_number;\n\n admin 2015-10-01 0 483 quoteItems list used by salesOrder\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: quoteItems\n-- Name: list\n-- Notes: used by salesOrder\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT quitem_id,\n quitem_linenumber AS f_linenumber,\n 0 AS coitem_subnumber, item_type,\n item_number, (item_descrip1 || ' ' || item_descrip2) AS description,\n warehous_code, '' AS enhanced_status,\n quitem_scheddate AS coitem_scheddate,\n quom.uom_name AS qty_uom,\n quitem_qtyord AS coitem_qtyord,\n 0 AS qtyshipped, 0 AS qtyatshipping, 0 AS balance,\n puom.uom_name AS price_uom,\n quitem_price AS coitem_price,\n ROUND((quitem_qtyord * quitem_qty_invuomratio) *\n (quitem_price / quitem_price_invuomratio),2) AS extprice,\n quitem_custprice AS coitem_custprice,\n CASE WHEN (quitem_custprice = 0.0) THEN 100.0\n ELSE ((1.0 - (quitem_price / quitem_custprice)) * 100.0)\n END AS discountfromcust,\n quitem_unitcost AS coitem_unitcost,\n CASE WHEN (quitem_price = 0.0) THEN 0.0\n ELSE ROUND((quitem_qtyord * quitem_qty_invuomratio) *\n ((quitem_price / quitem_price_invuomratio) - (quitem_unitcost / quitem_price_invuomratio)),2)\n END AS margin,\n CASE WHEN (quitem_price = 0.0) THEN 0.0\n ELSE ((quitem_price - quitem_unitcost) / quitem_price)\n END AS marginpercent,\n CASE WHEN (quitem_custpn != '') THEN quitem_custpn\n ELSE item_number\n END AS item_number_cust,\n (quitem_qtyord * quitem_qty_invuomratio * item_prodweight) AS prodweight,\n (quitem_qtyord * quitem_qty_invuomratio * item_packweight) AS packweight,\n qtyAvailable(itemsite_id) AS availableqoh,\n 'qty' AS coitem_qtyord_xtnumericrole,\n 'qty' AS qtyshipped_xtnumericrole,\n 'qty' AS balance_xtnumericrole,\n 'qty' AS qtyatshipping_xtnumericrole,\n 'qty' AS prodweight_xtnumericrole,\n 'qty' AS packweight_xtnumericrole,\n 'qty' AS availableqoh_xtnumericrole,\n 'salesprice' AS coitem_price_xtnumericrole,\n 'cost' AS coitem_unitcost_xtnumericrole,\n 'curr' AS margin_xtnumericrole,\n 'percent' AS marginpercent_xtnumericrole,\n 'curr' AS extprice_xtnumericrole\n FROM item, uom AS quom, uom AS puom,\n quitem LEFT OUTER JOIN (itemsite JOIN whsinfo ON (itemsite_warehous_id=warehous_id)) ON (quitem_itemsite_id=itemsite_id)\n WHERE ( (quitem_item_id=item_id)\n AND (quitem_qty_uom_id=quom.uom_id)\n AND (quitem_price_uom_id=puom.uom_id)\n AND (quitem_quhead_id=) )\nORDER BY quitem_linenumber; admin 2015-10-01 0 75 quotes detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: quotes\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT quhead.*, firstline(quhead_ordercomments) AS notes, quhead_id AS id,\n calcQuoteAmt(quhead_id) AS ordertotal,\n 'extprice' AS ordertotal_xtnumericrole,\n \n charass_alias.charass_value AS char,\n \n \n charass_alias.charass_value AS char,\n \n \n charass_alias.charass_value::date AS char,\n \n CASE WHEN quhead_status = 'O' THEN \n WHEN quhead_status = 'C' THEN \n ELSE \n END AS quhead_status_qtdisplayrole,\n\n cust_id, cust_number, cust_name,\n\n ( SELECT MIN(quitem_scheddate)\n FROM quitem\n WHERE (quitem_quhead_id=quhead_id) ) AS min_scheddate,\n CASE WHEN (quhead_expire < current_date) THEN\n 'error'\n END AS quhead_expire_qtforegroundrole\nFROM quhead\n\n LEFT OUTER \n\n JOIN custinfo ON (quhead_cust_id=cust_id)\n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='QU') \n AND (charass_alias.charass_target_id=quhead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='QU') \n AND (charass_alias.charass_target_id=quhead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='QU') \n AND (charass_alias.charass_target_id=quhead_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\nWHERE (checkQuoteSitePrivs(quhead_id, ))\n \n AND (quhead_owner_username=) \n\n AND (quhead_owner_username ~ ) \n\n\n AND (quhead_status IN ('C','O'))\n\n AND (quhead_status NOT IN ('C','X'))\n\n\n AND ((quhead_expire IS NULL) OR (quhead_expire >= CURRENT_DATE))\n\n\n AND (quhead_cust_id=)\n\n\n AND (cust_custtype_id=)\n\n\n AND (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ )))\n\n\n AND (quhead_custponumber=)\n\n\n AND (quhead_quotedate >= )\n\n\n AND (quhead_quotedate <= )\n\n\n AND (quhead_salesrep_id = )\n\n\n AND (quhead_id = )\n\n\n\nORDER BY cust_number, quhead_number;\n\nORDER BY quhead_number;\n\n\n admin 2015-10-01 0 76 receipt detail used by enterPoReceipt\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: receipt\n-- Name: detail\n-- Notes: used by enterPoReceipt\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT poitem_id AS orderitem_id, COALESCE(poitem_itemsite_id,-1) AS itemsite_id, poitem_linenumber AS linenumber,\n poitem_duedate AS duedate,\n COALESCE(item_number, ) AS item_number,\n CASE WHEN (LENGTH(TRIM(BOTH ' ' FROM poitem_vend_item_descrip)) <= 0) THEN\n (item_descrip1 || ' ' || item_descrip2)\n ELSE poitem_vend_item_descrip\n END AS itemdescription,\n COALESCE(uom_name, ) AS inv_uom,\n warehous_code,\n poitem_vend_item_number AS vend_item_number,\n poitem_vend_uom AS vend_uom,\n poitem_manuf_name AS manuf_name,\n poitem_manuf_item_number AS manuf_item_number,\n poitem_qty_ordered AS qty_ordered,\n poitem_qty_received AS qty_received,\n poitem_qty_returned AS qty_returned,\n qtyToReceive(, poitem_id) AS qty_toreceive,\n 'qty' AS qty_ordered_xtnumericrole,\n 'qty' AS qty_received_xtnumericrole,\n 'qty' AS qty_returned_xtnumericrole,\n 'qty' AS qty_toreceive_xtnumericrole\nFROM poitem \n LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id) \n\n LEFT OUTER JOIN usrsite ON (itemsite_warehous_id=usrsite_warehous_id) \n\n LEFT OUTER JOIN item ON (itemsite_item_id=item_id) \n LEFT OUTER JOIN uom ON (item_inv_uom_id=uom_id)\n LEFT OUTER JOIN whsinfo ON (itemsite_warehous_id=warehous_id)\n LEFT OUTER JOIN itemsrc ON (itemsrc_id=poitem_itemsrc_id)\nWHERE ( (poitem_status <> 'C')\n\n AND (usrsite_username=getEffectiveXtUser()) \n\n\n AND ( (item_number=) OR\n (item_upccode=) OR \n (poitem_vend_item_number=) OR \n (poitem_manuf_item_number=) OR \n (COALESCE(itemsrc_upccode, '')=) ) \n\n AND (poitem_pohead_id=) )\nORDER BY poitem_linenumber;\n\nSELECT raitem_id AS orderitem_id, itemsite_id, raitem_linenumber AS linenumber,\n rahead_expiredate AS duedate,\n COALESCE(item_number, ) AS item_number,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n COALESCE(iu.uom_name, ) AS inv_uom,\n warehous_code,\n '' AS vend_item_number,\n ru.uom_name AS vend_uom,\n '' AS manuf_name,\n '' AS manuf_item_number,\n raitem_qtyauthorized AS qty_ordered,\n raitem_qtyreceived AS qty_received,\n 0 AS qty_returned,\n qtyToReceive(, raitem_id) AS qty_toreceive,\n 'qty' AS qty_ordered_xtnumericrole,\n 'qty' AS qty_received_xtnumericrole,\n 'qty' AS qty_returned_xtnumericrole,\n 'qty' AS qty_toreceive_xtnumericrole\n\nFROM rahead, raitem \n LEFT OUTER JOIN \n ( itemsite \n\n JOIN usrsite ON (itemsite_warehous_id=usrsite_warehous_id) \n\n JOIN item ON (itemsite_item_id=item_id) \n JOIN uom iu ON (item_inv_uom_id=uom_id)\n JOIN whsinfo ON (itemsite_warehous_id=warehous_id)\n ) ON (raitem_itemsite_id=itemsite_id), uom ru\nWHERE ( (raitem_status <> 'C')\n AND (item_type <> 'K')\n AND (raitem_qtyauthorized > 0)\n AND (raitem_disposition IN ('R','P','V'))\n AND (raitem_rahead_id=rahead_id)\n AND (raitem_qty_uom_id=ru.uom_id)\n\n AND (usrsite_username=getEffectiveXtUser()) \n\n\n AND ( (item_number=) OR\n (item_upccode=) )\n\n AND (rahead_id=) )\nORDER BY raitem_linenumber;\n\nSELECT toitem_id AS orderitem_id, itemsite_id, toitem_linenumber AS linenumber,\n toitem_duedate AS duedate,\n COALESCE(item_number, ) AS item_number,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n COALESCE(uom_name, ) AS inv_uom,\n warehous_code,\n '' AS vend_item_number,\n toitem_uom AS vend_uom,\n '' AS manuf_name,\n '' AS manuf_item_number,\n toitem_qty_ordered AS qty_ordered,\n toitem_qty_received AS qty_received,\n 0 AS qty_returned,\n qtyToReceive(, toitem_id) AS qty_toreceive,\n 'qty' AS qty_ordered_xtnumericrole,\n 'qty' AS qty_received_xtnumericrole,\n 'qty' AS qty_returned_xtnumericrole,\n 'qty' AS qty_toreceive_xtnumericrole\nFROM tohead, itemsite\n\n JOIN usrsite ON (itemsite_warehous_id=usrsite_warehous_id) \n\n, whsinfo, toitem, item JOIN uom ON (item_inv_uom_id=uom_id)\nWHERE ((toitem_item_id=item_id)\n AND (tohead_id=toitem_tohead_id)\n AND (tohead_dest_warehous_id=itemsite_warehous_id)\n AND (tohead_dest_warehous_id=warehous_id)\n AND (toitem_item_id=itemsite_item_id)\n AND (toitem_status NOT IN ('C','X'))\n AND (toitem_qty_shipped > toitem_qty_received)\n\n AND (usrsite_username=getEffectiveXtUser()) \n\n\n AND ( (item_number=) OR\n (item_upccode=) )\n\n AND (toitem_tohead_id=) )\nORDER BY toitem_linenumber;\n\n admin 2015-10-01 0 77 receipt receiveAll used by enterPoReceipt, returnAuthorization, shipOrder\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: receipt\n-- Name: receiveAll\n-- Notes: used by enterPoReceipt, returnAuthorization, shipOrder\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\n SELECT enterReceipt(,\n shipitem_orderitem_id,\n shipitem_qty,\n (orderitem_freight - orderitem_freight_received),\n '',\n orderitem_freight_curr_id,\n CURRENT_DATE) AS result\n FROM shipitem, orderitemData(,\n ,\n NULL) AS orderitem\n LEFT OUTER JOIN recv ON ((recv_orderitem_id=orderitem_id)\n AND (recv_order_type=orderitem_orderhead_type))\n \n LEFT OUTER JOIN raitem ON ((raitem_id=orderitem_id)\n AND ('RA' = orderitem_orderhead_type))\n \n WHERE ( (shipitem_shiphead_id=)\n AND (shipitem_orderitem_id=orderitem_id)\n \n AND ((orderitem_orderhead_type != 'RA') OR (raitem_disposition IN (NULL,'R','V','P')))\n \n )\n\n\n SELECT enterReceipt(orderitem_orderhead_type,\n orderitem_id,\n\n (orderitem_qty_shipped - orderitem_qty_received),\n\n (orderitem_qty_ordered - orderitem_qty_received),\n\n (orderitem_freight - orderitem_freight_received),\n '',\n orderitem_freight_curr_id,\n CURRENT_DATE) AS result\n FROM orderitemData(,\n ,\n NULL) AS orderitem\n LEFT OUTER JOIN recv ON ((recv_orderitem_id=orderitem_id)\n AND (recv_order_type=orderitem_orderhead_type))\n\n LEFT OUTER JOIN raitem ON ((raitem_id=orderitem_id)\n AND ('RA' = orderitem_orderhead_type))\n\n WHERE (orderitem_status NOT IN ('C', 'X'))\n\n AND (orderitem_qty_shipped > orderitem_qty_received)\n\n\n AND (((orderitem_orderhead_type != 'RA') OR (raitem_disposition IN (NULL,'R','V','P'))))\n\n\n admin 2015-10-01 0 124 updateprices remove \n Notes:\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: updateprices\n-- Name: remove\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM selsched\n\nWHERE (selsched_ipshead_id=)\n\n;\n admin 2015-10-01 0 125 updateprices selsched \n Notes:\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: updateprices\n-- Name: selsched\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT selsched_ipshead_id, ipshead_name, ipshead_descrip\nFROM selsched\n JOIN ipshead ON (selsched_ipshead_id=ipshead_id)\nORDER BY ipshead_name\n admin 2015-10-01 0 78 receivings detail used by dspPoItemReceivingsByDate, dspPoItemReceivingsByItem, dspPoItemReceivingsByVendor\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: receivings\n-- Name: detail\n-- Notes: used by dspPoItemReceivingsByDate, dspPoItemReceivingsByItem, dspPoItemReceivingsByVendor\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT recv_id, 1 AS altid, recv_order_number AS ponumber,\n vend_name,\n recv_duedate AS duedate,\n recv_date AS recvdate,\n recv_vend_item_number AS itemnumber,\n recv_vend_item_descrip AS itemdescrip,\n COALESCE(item_number,\n ( || recv_vend_item_number)) AS venditemnumber,\n COALESCE(item_descrip1, recv_vend_item_descrip) AS venditemdescrip,\n CASE WHEN (recv_vohead_id IS NOT NULL) THEN\n \n ELSE \n END AS sense,\n recv_qty AS qty,\n currToBase(recv_purchcost_curr_id, recv_purchcost, CAST(recv_date AS DATE)) AS purchcost,\n CASE WHEN (recv_qty > 0) THEN\n COALESCE(recv_value,0) / recv_qty\n ELSE 0 END AS recvcost,\n recv_value AS value,\n recv_invoiced AS invoiced,\n recv_date AS sortdate,\n\n formatDate(recv_duedate) AS f_duedate,\n formatDate(recv_date) AS f_recvdate,\n formatQty(recv_qty) AS f_qty,\n \n formatCost(currToBase(recv_purchcost_curr_id, recv_purchcost, CAST(recv_date AS DATE))) AS f_purchcost,\n formatCost(CASE WHEN (recv_qty > 0) THEN COALESCE(recv_value,0) / recv_qty\n ELSE 0\n END) AS f_recvcost,\n formatMoney(recv_value) AS f_value,\n \n NULL AS f_purchcost,\n NULL AS f_recvcost,\n NULL AS f_value,\n \n\n 'qty' AS qty_xtnumericrole,\n 'cost' AS purchcost_xtnumericrole,\n 'cost' AS recvcost_xtnumericrole,\n 'curr' AS value_xtnumericrole,\n AS duedate_xtnullrole,\n AS purchcost_xtnullrole,\n AS recvcost_xtnullrole\nFROM vendinfo, recv LEFT OUTER JOIN\n (itemsite JOIN\n item ON (itemsite_item_id=item_id)) ON (recv_itemsite_id=itemsite_id)\nWHERE ( (recv_vend_id=vend_id)\n AND (recv_order_type='PO')\n AND (recv_posted)\n AND (DATE(recv_date) BETWEEN AND )\n\n AND (vend_id=)\n\n\n AND (itemsite_item_id=)\n\n\n AND (itemsite_warehous_id=)\n\n\n AND (recv_agent_username=)\n\n\n AND (recv_vohead_id IS NOT NULL)\n AND (recv_invoiced)\n\n)\nUNION\nSELECT poreject_id, 2, poreject_ponumber,\n vend_name,\n NULL,\n poreject_date,\n poreject_vend_item_number,\n poreject_vend_item_descrip,\n COALESCE(item_number,\n ( || poreject_vend_item_number)),\n COALESCE(item_descrip1, poreject_vend_item_descrip),\n ,\n poreject_qty,\n NULL,\n NULL,\n poreject_value,\n poreject_invoiced,\n poreject_date,\n\n NULL AS f_duedate,\n formatDate(poreject_date) AS f_recvdate,\n formatQty(poreject_qty) AS f_qty,\n NULL AS f_purchcost,\n NULL AS f_recvcost,\n formatMoney(poreject_value) AS f_value,\n\n 'qty',\n 'cost',\n 'cost',\n 'curr',\n AS duedate_xtnullrole,\n AS purchcost_xtnullrole,\n AS recvcost_xtnullrole\nFROM vendinfo, poreject LEFT OUTER JOIN\n (itemsite JOIN\n item ON (itemsite_item_id=item_id)) ON (poreject_itemsite_id=itemsite_id)\nWHERE ( (poreject_vend_id=vend_id)\n AND (poreject_posted)\n AND (DATE(poreject_date) BETWEEN AND )\n\n AND (vend_id=)\n\n\n AND (itemsite_item_id=)\n\n\n AND (itemsite_warehous_id=)\n\n\n AND (poreject_agent_username=)\n\n\n AND (poreject_vohead_id IS NOT NULL)\n AND (poreject_invoiced)\n\n)\nORDER BY sortdate DESC;\n admin 2015-10-01 0 280 reorderExceptionsByPlannerCode detail used by dspReorderExceptionsByPlannerCode\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: reorderExceptionsByPlannerCode\n-- Name: detail\n-- Notes: used by dspReorderExceptionsByPlannerCode\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, itemtype, warehous_code, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n reorderdate, reorderlevel,\n (qtyNetable(itemsite_id) - qtyAllocated(itemsite_id, reorderdate) +\n qtyOrdered(itemsite_id, reorderdate)) AS projavail,\n 'qty' AS reorderlevel_xtnumericrole,\n 'qty' AS projavail_xtnumericrole\nFROM (SELECT itemsite_id,\n CASE WHEN (item_type IN ('M', 'B', 'T')) THEN 1\n WHEN (item_type IN ('P', 'O')) THEN 2\n ELSE 3\n END AS itemtype,\n warehous_code, item_number, item_descrip1,\n item_descrip2,\n reorderDate(itemsite_id,\n ,\n )\n AS reorderdate,\n reorderlevel\n FROM (SELECT itemsite_id, itemsite_item_id,\n itemsite_warehous_id,\n CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel\n ELSE 0.0\n END AS reorderlevel\n FROM itemsite\n WHERE ((true)\n \n AND (itemsite_warehous_id=)\n \n \n AND (itemsite_plancode_id=)\n \n AND (itemsite_plancode_id IN (SELECT plancode_id\n FROM plancode\n WHERE (plancode_code ~ )))\n \n )\n ) AS itemsitedata, item, whsinfo\n WHERE ((itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id))\n ) AS data\nWHERE (reorderdate IS NOT NULL)\nORDER BY reorderdate, item_number;\n admin 2015-10-01 0 452 reports detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: reports\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\n SELECT report_id, report_name,\n firstline(report_descrip) AS report_descrip, report_grade,\n CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n CASE nspname WHEN 'public' THEN 0\n ELSE 1 END AS xtindentrole,\n report_descrip AS report_descrip_qttooltiprole\n FROM report\n JOIN pg_class ON (report.tableoid=pg_class.oid)\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n UNION\n SELECT -1, pkghead_name,\n firstline(pkghead_descrip), NULL,\n pkghead_name, 0, pkghead_descrip\n FROM report, pg_class, pg_namespace\n RIGHT OUTER JOIN pkghead ON (nspname=pkghead_name)\n WHERE ((report.tableoid=pg_class.oid)\n AND (relnamespace=pg_namespace.oid))\n ORDER BY pkgname, xtindentrole, report_name,\n report_grade DESC, report_id;\n\n SELECT report_id, report_name,\n firstline(report_descrip) AS report_descrip,\n report_grade,\n CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n report_descrip AS report_descrip_qttooltiprole\n FROM report\n JOIN pg_class ON (report.tableoid=pg_class.oid)\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n ORDER BY report_name,\n report_grade DESC, report_id;\n\n admin 2015-10-01 0 79 reservations detail used by dspReservations\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: reservations\n-- Name: detail\n-- Notes: used by dspReservations\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT source_id, order_number, scheddate,\n totalqty, relievedqty, reservedqty, balanceqty,\n CASE WHEN (scheddate < CURRENT_DATE) THEN 'error' END AS scheddate_qtforegroundrold,\n 'qty' AS totalqty_xtnumericrole,\n 'qty' AS relievedqty_xtnumericrole,\n 'qty' AS reservedqty_xtnumericrole,\n 'qty' AS balanceqty_xtnumericrole,\n 0 AS balanceqty_xtrunningrole,\n level AS xtindentrole\nFROM (\nSELECT coitem_scheddate AS sortkey, 0 AS level, coitem_id AS source_id,\n formatSoNumber(coitem_id) AS order_number,\n (coitem_qtyord * coitem_qty_invuomratio) AS totalqty,\n ((coitem_qtyshipped + qtyAtShipping(coitem_id) - coitem_qtyreturned) * coitem_qty_invuomratio) as relievedqty,\n (coitem_qtyreserved * coitem_qty_invuomratio) AS reservedqty,\n (coitem_qtyreserved * coitem_qty_invuomratio) AS balanceqty,\n coitem_scheddate AS scheddate\nFROM cohead, coitem, itemsite, item \nWHERE((coitem_cohead_id=cohead_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (coitem_qtyreserved > 0)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=)\n AND (itemsite_item_id=))\nUNION\nSELECT coitem_scheddate AS sortkey, 1 AS level, coitem_id AS source_id,\n (formatLocationName(itemloc_location_id) || ' ' || formatLotSerialNumber(itemloc_ls_id)) AS order_number,\n NULL AS totalqty, NULL AS relievedqty,\n (reserve_qty * coitem_qty_invuomratio) AS reservedqty,\n NULL AS balanceqty, NULL AS scheddate\nFROM reserve, itemloc, coitem, itemsite\nWHERE ( (itemloc_id=reserve_supply_id)\n AND (reserve_supply_type='I')\n AND (coitem_id=reserve_demand_id)\n AND (reserve_demand_type='SO')\n AND (itemsite_id=coitem_itemsite_id)\n AND (itemsite_warehous_id=)\n AND (itemsite_item_id=) )\n ) AS data\nORDER BY sortkey, source_id, level;\n admin 2015-10-01 0 101 returnAuthorizations detail \n Notes:\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: returnAuthorizations\n-- Name: detail\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT rahead_id, rahead_number, rahead_billtoname,\n rahead_authdate,rahead_expiredate,\n COALESCE(cust_number, 'Undefined') AS custnumber,\n CASE\n WHEN rahead_disposition = 'C' THEN\n \n WHEN rahead_disposition = 'R' THEN\n \n WHEN rahead_disposition = 'P' THEN\n \n WHEN rahead_disposition = 'V' THEN\n \n WHEN rahead_disposition = 'M' THEN\n \n END AS disposition,\n formatDate(rahead_authdate) AS f_authorized,\n formatDate(rahead_expiredate) AS f_expires,\n CASE WHEN (rahead_expiredate < current_date) THEN\n 'error'\n END AS rahead_expiredate_qtforegroundrole\n FROM rahead LEFT OUTER JOIN custinfo ON (rahead_cust_id=cust_id)\n \n JOIN raitem ON (raitem_rahead_id=rahead_id) \n JOIN itemsite ON (raitem_itemsite_id=itemsite_id) \n JOIN site() ON (itemsite_warehous_id=warehous_id) \n \n LEFT OUTER JOIN raitem ON (raitem_rahead_id=rahead_id) \n LEFT OUTER JOIN itemsite ON (raitem_itemsite_id=itemsite_id) \n LEFT OUTER JOIN whsinfo ON (itemsite_warehous_id=warehous_id) \n \n WHERE ((true)\n \n AND ((raitem_status = 'O') OR (raitem_status IS NULL)) \n\n \n AND (raitem_qtyauthorized > 0) \n\n\n AND (COALESCE(rahead_expiredate,CURRENT_DATE) >= CURRENT_DATE)\n\n\n AND (itemsite_warehous_id=)\n\n\n AND (rahead_cust_id=)\n\n )\n GROUP BY cust_number,rahead_id,rahead_number,rahead_authdate,rahead_expiredate,\n rahead_billtoname,rahead_disposition\n ORDER BY rahead_number\n admin 2015-10-01 0 127 updateprices update \n Notes:\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: updateprices\n-- Name: update\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nUPDATE ipsiteminfo SET\n ipsitem_price=\n\n ipsitem_price + \n\n roundSale(ipsitem_price * (1.0 + ( / 100.0)))\n\nFROM selsched, item\n\n JOIN itemgrpitem ON (itemgrpitem_item_id=item_id)\n JOIN itemgrp ON (itemgrpitem_itemgrp_id=itemgrp_id)\n\n JOIN prodcat ON (prodcat_id=item_prodcat_id)\n\nWHERE ( ipsitem_item_id=item_id\n AND selsched_ipshead_id=ipsitem_ipshead_id\n AND ipsitem_type='N'\n\n AND item_id=\n\n AND itemgrp_id=\n\n AND itemgrp_name ~ \n\n AND prodcat_id=\n\n AND prodcat_code ~ \n\n);\n\n\n\nUPDATE ipsiteminfo SET\n ipsitem_discntprcnt=\n\n ipsitem_discntprcnt + ( / 100.0)\n\n roundSale(ipsitem_discntprcnt * (1.0 + ( / 100.0)))\n\nFROM selsched, item\n\n JOIN itemgrpitem ON (itemgrpitem_item_id=item_id)\n JOIN itemgrp ON (itemgrpitem_itemgrp_id=itemgrp_id)\n\n JOIN prodcat ON (prodcat_id=item_prodcat_id)\n\nWHERE ( ipsitem_item_id=item_id\n AND selsched_ipshead_id=ipsitem_ipshead_id\n AND ipsitem_type='D'\n\n AND item_id=\n\n AND itemgrp_id=\n\n AND itemgrp_name ~ \n\n AND prodcat_id=\n\n AND prodcat_code ~ \n\n);\n\n\n\nUPDATE ipsiteminfo SET\n ipsitem_discntprcnt=\n\n ipsitem_discntprcnt + ( / 100.0)\n\n roundSale(ipsitem_discntprcnt * (1.0 + ( / 100.0)))\n\nFROM selsched, item\n\n JOIN itemgrpitem ON (itemgrpitem_item_id=item_id)\n JOIN itemgrp ON (itemgrpitem_itemgrp_id=itemgrp_id)\n\n JOIN prodcat ON (prodcat_id=item_prodcat_id)\n\nWHERE ( ipsitem_item_id=item_id\n AND selsched_ipshead_id=ipsitem_ipshead_id\n AND ipsitem_type='M'\n\n AND item_id=\n\n AND itemgrp_id=\n\n AND itemgrp_name ~ \n\n AND prodcat_id=\n\n AND prodcat_code ~ \n\n);\n\n admin 2015-10-01 0 81 salesHistory detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: salesHistory\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n CASE WHEN (COALESCE(cohist_invcnumber, '-1') IN ('', '-1')) THEN \n ELSE cohist_invcnumber\n END AS invoicenumber,\n\n formatDate(cohist_orderdate) AS f_orderdate,\n formatDate(cohist_invcdate) AS f_invcdate,\n formatQty(cohist_qtyshipped) AS f_qtyshipped,\n formatBoolYN(cohist_commissionpaid) AS f_commissionpaid,\n formatSalesPrice(baseunitprice) AS f_baseunitprice,\n formatMoney(extprice) AS f_extprice,\n formatMoney(baseextprice) AS f_baseextprice,\n formatMoney(extcost) AS f_extcost,\n formatMoney(margin) AS f_margin,\n formatPrcnt(marginpercent) AS f_marginpercent,\n formatMoney(basecommission) AS f_basecommission,\n\n AS cohist_invcdate_xtnullrole,\n 0 AS cohist_qtyshipped_xttotalrole,\n 0 AS baseextprice_xttotalrole,\n 0 AS extcost_xttotalrole,\n 0 AS margin_xttotalrole,\n 0 AS basecommission_xttotalrole\n\n FROM saleshistorymisc\n\n FROM saleshistory\n\nWHERE ( (true)\n\n AND (cohist_invcdate >= )\n\n\n AND (cohist_invcdate <= )\n\n\n AND (cohist_shipdate >= )\n\n\n AND (cohist_shipdate <= )\n\n\n AND (cohist_salesrep_id=)\n\n\n AND (cohist_shipto_id=)\n\n\n AND (UPPER(cohist_billtoname) ~ UPPER())\n\n\n AND (cohist_cust_id=)\n\n\n AND (custtype_id=)\n\n AND (custtype_id IN (SELECT DISTINCT custtype_id\n FROM custtype\n WHERE (custtype_code ~ )))\n\n\n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrpitem))\n\n\n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrpitem\n WHERE (custgrpitem_custgrp_id=)))\n\n\n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrp, custgrpitem\n WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n AND (custgrp_name ~ ) )) )\n\n\n\n AND (item_id=)\n\n\n AND (itemnumber ~* )\n\n\n AND (prodcat_id=)\n\n\n AND (prodcat_id IN (SELECT DISTINCT prodcat_id\n FROM prodcat\n WHERE (prodcat_code ~ )))\n\n\n AND (classcode_id=)\n\n\n AND (warehous_id=)\n\n\n AND (cohist_shipzone_id=)\n\n\n AND (cohist_saletype_id=)\n\n\n AND (cohead_id=)\n\n )\nORDER BY cohist_invcdate, itemnumber;\n\n admin 2015-10-01 0 281 salesOrderStatus detail used by dspSalesOrderStatus\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: salesOrderStatus\n-- Name: detail\n-- Notes: used by dspSalesOrderStatus\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT coitem_id, coitem_linenumber, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n warehous_code,\n coitem_qtyord, coitem_qtyshipped, coitem_qtyreturned,\n SUM(COALESCE(cobill_qty, 0)) AS invoiced,\n noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS balance,\n CASE WHEN (coitem_status='C') THEN coitem_closedate END AS closedate,\n CASE WHEN (coitem_status='C') THEN coitem_close_username END AS closeuser,\n CASE WHEN (coitem_order_id=-1) THEN ''\n WHEN (coitem_order_type='W') THEN ( SELECT (formatWoNumber(wo_id) || '/' || wo_status)\n FROM wo\n WHERE (wo_id=coitem_order_id) )\n ELSE ''\n END AS childinfo,\n 'qty' AS coitem_qtyord_xtnumericrole,\n 'qty' AS coitem_qtyshipped_xtnumericrole,\n 'qty' AS coitem_qtyreturned_xtnumericrole,\n 'qty' AS invoiced_xtnumericrole,\n 'qty' AS balance_xtnumericrole \nFROM itemsite, item, whsinfo, coitem LEFT OUTER JOIN\n cobill ON (coitem_id=cobill_coitem_id AND\n cobill_invcitem_id IS NOT NULL)\nWHERE ( (coitem_itemsite_id=itemsite_id)\n AND (coitem_status <> 'X')\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (coitem_cohead_id=) ) \nGROUP BY coitem_id, coitem_linenumber, item_number, \n item_descrip1, item_descrip2, warehous_code, \n coitem_qtyord, coitem_qtyshipped, coitem_status, \n coitem_closedate, coitem_close_username, \n coitem_qtyreturned, coitem_order_id, \n coitem_order_type \nORDER BY coitem_linenumber;\n admin 2015-10-01 0 83 salesOrders detail used by dspSalesOrders, dspSalesOrdersByCustomer, dspSalesOrdersByCustomerPO, dspSalesOrdersByParameterList\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: salesOrders\n-- Name: detail\n-- Notes: used by dspSalesOrders, dspSalesOrdersByCustomer, dspSalesOrdersByCustomerPO, dspSalesOrdersByParameterList\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cohead_id, cust_id,\n cohead.*,\n cust_number, cust_name,\n saletype_descr,\n getSoSchedDate(cohead_id) AS min_scheddate,\n CASE\n WHEN ( (SELECT COUNT(*)\n FROM coitem\n WHERE ((coitem_status<>'X') AND (coitem_cohead_id=cohead_id))) = 0) THEN \n WHEN ( ( (SELECT COUNT(*)\n FROM coitem\n WHERE ((coitem_status='C')\n AND (coitem_cohead_id=cohead_id))) > 0)\n AND ( (SELECT COUNT(*)\n FROM coitem\n WHERE ((coitem_status NOT IN ('C','X'))\n AND (coitem_cohead_id=cohead_id))) = 0) ) THEN \n WHEN ( ( (SELECT COUNT(*)\n FROM coitem\n WHERE ((coitem_status='C')\n AND (coitem_cohead_id=cohead_id))) = 0)\n AND ( (SELECT COUNT(*)\n FROM coitem\n WHERE ((coitem_status NOT IN ('C','X'))\n AND (coitem_cohead_id=cohead_id))) > 0) ) THEN \n ELSE \n END AS order_status\nFROM cohead \n JOIN custinfo ON (cust_id=cohead_cust_id)\n LEFT OUTER JOIN saletype ON (saletype_id=cohead_saletype_id)\nWHERE ( (1=1)\n\n AND (cohead_warehous_id = )\n\n\n AND (cohead_cust_id=)\n\n\n AND (cust_custtype_id=)\n\n\n AND (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ )))\n\n\n AND (cohead_custponumber~*)\n\n\n AND (cohead_prj_id = )\n\n\n AND (cohead_salesrep_id = )\n\n\n AND (cohead_saletype_id = )\n\n\n AND (cohead_status NOT IN ('C', 'X'))\n\n\n AND (cohead_orderdate >= )\n\n\n AND (cohead_orderdate <= )\n\n\n AND ((SELECT COUNT(*)\n FROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n JOIN site() ON (warehous_id=itemsite_warehous_id)\n WHERE (coitem_cohead_id=cohead_id)) > 0) )\n\n ORDER BY cust_number, cohead_number;\n\nORDER BY cohead_number;\n\n\n admin 2015-10-01 0 478 saletype table maintain saletype table\n Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: saletype\n-- Name: table\n-- Notes: maintain saletype table\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\n SELECT saletype_id\n FROM saletype\n WHERE true\n \n AND (saletype_id != ) \n \n \n AND (UPPER(saletype_code)=UPPER()) \n \n ORDER BY saletype_code;\n\n\n SELECT *\n FROM saletype\n WHERE true\n \n AND (saletype_id=) \n \n \n AND (UPPER(saletype_code)=UPPER()) \n \n ORDER BY saletype_code;\n\n\n INSERT INTO saletype\n ( saletype_code,\n saletype_descr,\n saletype_active,\n saletype_default )\n VALUES\n ( UPPER(),\n ,\n ,\n )\n RETURNING saletype_id;\n\n\n UPDATE saletype\n SET saletype_code=UPPER(),\n saletype_descr=,\n saletype_active=,\n saletype_default=\n WHERE (saletype_id=);\n\n\n DELETE FROM saletype WHERE saletype_id=;\n\n\n SELECT deleteUnusedSaleTypes() AS result;\n\n\n RAISE EXCEPTION 'saletype invalid mode';\n\n admin 2015-10-01 0 84 schedule plannedorders used by dpsPlannedOrdersByItem, dspPlannedOrdersByPlannerCode, dspPlannedRevenueExpensesByPlannerCode\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: schedule\n-- Name: plannedorders\n-- Notes: used by dpsPlannedOrdersByItem, dspPlannedOrdersByPlannerCode, dspPlannedRevenueExpensesByPlannerCode\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n SELECT *,\n plorevenue - plocost AS profit,\n formatMoney(plorevenue - plocost) AS f_profit,\n CASE WHEN plocost > plorevenue THEN 'error'\n END AS plorevenue_xtforegroundrole,\n CASE WHEN (planord_firm) THEN 'emphasis'\n END AS qtforegroundrole,\n 'qty' AS planord_qty_xtnumericrole,\n 'curr' AS plocost_xtnumericrole,\n 'curr' AS plorevenue_xtnumericrole,\n 'curr' AS profit_xtnumericrole,\n 0 AS plocost_xttotalrole,\n 0 AS plorevenue_xttotalrole,\n 0 AS profit_xttotalrole\n FROM (\n SELECT planord_id, planord_itemsite_id,\n planord.*,\n (select plancode_code from plancode where plancode_id = itemsite.itemsite_plancode_id) as plancode,\n formatPloNumber(planord_id) AS ordernum,\n CASE WHEN (planord_type='P') THEN 'P/O'\n WHEN (planord_type='W') THEN 'W/O'\n WHEN (planord_type='T') THEN 'T/O'\n ELSE '?'\n END AS ordtype,\n formatDate(planord_duedate) AS f_duedate,\n formatDate(planord_startdate) AS f_startdate,\n formatQty(planord_qty) AS f_qty,\n formatboolYN(planord_firm) AS f_firm,\n whsinfo.warehous_code AS warehous_code,\n supplywhsinfo.warehous_code AS supply_warehous_code,\n item_number,\n (item_descrip1 || ' ' || item_descrip2) AS item_descrip,\n firstline(planord_comments) AS comments,\n uom_name,\n (classcode_code || '-' || classcode_descrip) AS f_classcode,\n \n (actcost(item_id) * planord_qty)\n \n (stdcost(item_id) * planord_qty)\n \n 0\n AS plocost,\n \n (item_listprice * planord_qty)\n \n (CASE WHEN(averageSalesPrice(itemsite.itemsite_id,\n ,\n )=0)\n THEN item_listprice\n ELSE averageSalesPrice(itemsite.itemsite_id,\n ,\n )\n END * planord_qty)\n \n 0\n AS plorevenue,\n \n formatMoney(actcost(item_id) * planord_qty)\n \n formatMoney(stdcost(item_id) * planord_qty)\n \n formatMoney(0)\n AS f_plocost,\n \n formatMoney(item_listprice * planord_qty)\n \n formatMoney(CASE WHEN(averageSalesPrice(itemsite.itemsite_id,\n ,\n )=0)\n THEN item_listprice\n ELSE averageSalesPrice(itemsite.itemsite_id,\n ,\n )\n END * planord_qty)\n \n formatMoney(0)\n AS f_plorevenue\n FROM planord JOIN itemsite ON (planord_itemsite_id=itemsite.itemsite_id)\n JOIN whsinfo ON (itemsite.itemsite_warehous_id=whsinfo.warehous_id)\n JOIN item ON (itemsite.itemsite_item_id=item_id)\n JOIN uom ON (item_inv_uom_id=uom_id)\n LEFT OUTER JOIN classcode ON (classcode_id=item_classcode_id)\n LEFT OUTER JOIN itemsite supplyitemsite ON (planord_supply_itemsite_id=supplyitemsite.itemsite_id)\n LEFT OUTER JOIN whsinfo supplywhsinfo ON (supplyitemsite.itemsite_warehous_id=supplywhsinfo.warehous_id)\n \n JOIN itemgrpitem ON (itemgrpitem_item_id=item_id)\n JOIN itemgrp ON (itemgrp_id=itemgrpitem_itemgrp_id AND itemgrp_id=)\n \n WHERE (TRUE\n \n AND (itemsite.itemsite_item_id=)\n \n \n AND (item.item_classcode_id=)\n \n \n AND (itemsite.itemsite_plancode_id=)\n \n AND (itemsite.itemsite_plancode_id IN (SELECT plancode_id\n FROM plancode\n WHERE (plancode_code ~ )))\n \n \n AND (itemsite.itemsite_warehous_id=)\n \n \n AND (planord_duedate BETWEEN AND )\n \n \n AND (item_sold)\n \n \n AND (\n \n (planord_type=) OR\n \n FALSE )\n \n ) ) AS data\n ORDER BY planord_duedate, item_number;\n admin 2015-10-01 0 453 scripts detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: scripts\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT script_id, script_name, script_enabled,\n firstline(script_notes) AS script_notes, script_order,\n CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n CASE nspname WHEN 'public' THEN 0\n ELSE 1 END AS xtindentrole,\n script_notes AS script_notes_qttooltiprole\n FROM script\n JOIN pg_class ON (script.tableoid=pg_class.oid)\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n UNION \nSELECT -1, pkghead_name, NULL,\n firstline(pkghead_descrip), NULL,\n pkghead_name, 0, pkghead_descrip \n FROM script, pg_class, pg_namespace\n RIGHT OUTER JOIN pkghead ON (nspname=pkghead_name)\n WHERE ((script.tableoid=pg_class.oid)\n AND (relnamespace=pg_namespace.oid))\n ORDER BY pkgname, xtindentrole, script_name, script_order, script_id;\n\nSELECT script_id, script_name, script_enabled,\n firstline(script_notes) AS script_notes, script_order,\n CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n script_notes AS script_notes_qttooltiprole\n FROM script\n JOIN pg_class ON (script.tableoid=pg_class.oid)\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nORDER BY script_name, script_order, script_id;\n\n admin 2015-10-01 0 131 selectPayments applyallcredits used by selectPayments\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: selectPayments\n-- Name: applyallcredits\n-- Notes: used by selectPayments\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT applyapcredits(vend_id) AS result\nFROM vendinfo\nWHERE ((TRUE)\n\n AND (vend_id = )\n\n AND (vend_vendtype_id = )\n\n AND (vend_vendtype_id IN (SELECT vendtype_id\n FROM vendtype\n WHERE (vendtype_code ~ )))\n\n );\n admin 2015-10-01 0 490 selectPayments clearall used by selectPayments\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: selectPayments\n-- Name: clearall\n-- Notes: used by selectPayments\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT clearPayment(apselect_id) AS result\nFROM vendinfo JOIN apopen ON (apopen_vend_id=vend_id)\n JOIN apselect ON (apselect_apopen_id=apopen_id)\nWHERE ((TRUE)\n\n AND (vend_id = )\n\n AND (vend_vendtype_id = )\n\n AND (vend_vendtype_id IN (SELECT vendtype_id\n FROM vendtype\n WHERE (vendtype_code ~ )))\n\n );\n admin 2015-10-01 0 491 selectPayments discountitems used by selectPayments\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: selectPayments\n-- Name: discountitems\n-- Notes: used by selectPayments\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT selectDiscountItemsForPayment(vend_id, ) AS result\nFROM vendinfo\n\nWHERE (vend_id=)\n\nWHERE (vend_vendtype_id=)\n\nWHERE (vend_vendtype_id IN (SELECT vendtype_id\n FROM vendtype\n WHERE (vendtype_code ~ )))\n\n;\n admin 2015-10-01 0 492 selectPayments dueitems used by selectPayments\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: selectPayments\n-- Name: dueitems\n-- Notes: used by selectPayments\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT selectDueItemsForPayment(vend_id, ) AS result\nFROM vendinfo\n\nWHERE (vend_id=)\n\nWHERE (vend_vendtype_id=)\n\nWHERE (vend_vendtype_id IN (SELECT vendtype_id\n FROM vendtype\n WHERE (vendtype_code ~ )))\n\n;\n admin 2015-10-01 0 85 shipments detail used by dspShipmentsByDate, dspShipmentsBySalesOrder, dspShipmentsByShipment\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: shipments\n-- Name: detail\n-- Notes: used by dspShipmentsByDate, dspShipmentsBySalesOrder, dspShipmentsByShipment\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT shiphead_id, lineitem_id,\n CASE WHEN (level=0) THEN order_number\n ELSE item_number\n END AS order_item,\n CASE WHEN (level=0) THEN customer\n ELSE itemdescription\n END AS cust_desc,\n shiphead_order_type,\n shiphead_number, \n order_number, \n customer,\n shiphead_shipdate,\n formatDate(shiphead_shipdate) AS f_shipdate,\n shiphead_tracknum,\n shiphead_freight,\n freight_curr_abbr,\n linenumber,\n item_number,\n itemdescription,\n warehous_code,\n qtyord,\n formatQty(qtyord) AS f_qtyord,\n qtyshipped,\n formatQty(qtyshipped) AS f_qtyshipped,\n notes,\n 'qty' AS qtyord_xtnumericrole,\n 'qty' AS qtyshipped_xtnumericrole,\n 'curr' AS shiphead_freight_xtnumericrole,\n CASE WHEN (COALESCE(linenumber, 0) = 0) THEN '' END AS linenumber_qtdisplayrole,\n CASE WHEN (COALESCE(qtyord, 0) = 0) THEN '' END AS qtyord_qtdisplayrole,\n CASE WHEN (COALESCE(qtyshipped, 0) = 0) THEN '' END AS qtyshipped_qtdisplayrole,\n CASE WHEN (COALESCE(shiphead_freight, 0) = 0) THEN '' END AS shiphead_freight_qtdisplayrole,\n level AS xtindentrole\nFROM (\nSELECT DISTINCT\n shiphead_id, -1 AS lineitem_id, cohead_number AS sortkey1, shiphead_number AS sortkey2, 0 AS level,\n shiphead_order_type,\n shiphead_number,\n cohead_number AS order_number, \n (cust_number || '-' || cust_name) AS customer,\n shiphead_shipdate,\n shiphead_tracknum,\n shiphead_freight,\n currConcat(shiphead_freight_curr_id) AS freight_curr_abbr, \n 0 AS linenumber, '' AS item_number,\n '' AS itemdescription,\n '' AS warehous_code,\n 0 AS qtyord,\n 0 AS qtyshipped,\n firstline(shiphead_notes) AS notes\nFROM shiphead JOIN cohead ON (cohead_id=shiphead_order_id)\n JOIN custinfo ON (cust_id=cohead_cust_id)\n\n JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)\n JOIN coitem ON (coitem_id=shipitem_orderitem_id)\n JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n\nWHERE ( (shiphead_order_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n AND (shiphead_shipped)\n AND (shiphead_order_type='SO')\n\n AND (shiphead_shipdate BETWEEN and )\n\n\n AND (itemsite_warehous_id = )\n\n\n AND (cohead_id = )\n\n\n AND (shiphead_id = )\n\n ) \nUNION\nSELECT shiphead_id, coitem_id AS lineitem_id, cohead_number AS sortkey1, shiphead_number AS sortkey2, 1 AS level,\n '' AS shiphead_order_type,\n '' AS shiphead_number,\n '' AS order_number, \n '' AS customer,\n CAST(NULL AS DATE) AS shiphead_shipdate,\n '' AS shiphead_tracknum,\n 0 AS shiphead_freight,\n '' AS freight_curr_abbr, \n coitem_linenumber AS linenumber, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n warehous_code,\n coitem_qtyord AS qtyord,\n SUM(shipitem_qty) AS qtyshipped,\n '' AS notes\nFROM shipitem, shiphead, coitem, cohead, custinfo, itemsite, item, whsinfo\nWHERE ( (shipitem_shiphead_id=shiphead_id)\n AND (shipitem_orderitem_id=coitem_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (coitem_status <> 'X')\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (shiphead_order_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n AND (shiphead_shipped)\n AND (shiphead_order_type='SO')\n\n AND (shiphead_shipdate BETWEEN and )\n\n\n AND (itemsite_warehous_id = )\n\n\n AND (cohead_id = )\n\n\n AND (shiphead_id = )\n\n ) \nGROUP BY shiphead_id, coitem_id, shiphead_order_type, shiphead_number,\n cohead_number, cust_number, cust_name, shiphead_shipdate,\n coitem_linenumber, item_number, item_descrip1, item_descrip2,\n warehous_code, shiphead_tracknum, coitem_qtyord, \n shiphead_freight, shiphead_freight_curr_id \n\nUNION\nSELECT shiphead_id, -1 AS lineitem_id, tohead_number AS sortkey1, shiphead_number AS sortkey2, 0 AS level,\n shiphead_order_type,\n shiphead_number,\n tohead_number AS order_number, \n tohead_destname AS customer,\n shiphead_shipdate,\n shiphead_tracknum,\n shiphead_freight,\n currConcat(shiphead_freight_curr_id) AS freight_curr_abbr, \n 0 AS linenumber, '' AS item_number,\n '' AS itemdescription,\n '' AS warehous_code,\n 0 AS qtyord,\n 0 AS qtyshipped,\n firstline(shiphead_notes) AS notes\nFROM shiphead, tohead \nWHERE ( (shiphead_order_id=tohead_id)\n AND (shiphead_shipped)\n AND (shiphead_order_type='TO')\n\n AND (shiphead_shipdate BETWEEN and )\n\n\n AND (tohead_src_warehous_id = )\n\n\n AND (tohead_id = )\n\n\n AND (shiphead_id = )\n\n ) \nUNION\nSELECT shiphead_id, toitem_id AS lineitem_id, tohead_number AS sortkey1, shiphead_number AS sortkey2, 1 AS level,\n '' AS shiphead_order_type,\n '' AS shiphead_number,\n '' AS order_number, \n '' AS customer,\n CAST(NULL AS DATE) AS shiphead_shipdate,\n '' AS shiphead_tracknum,\n 0 AS shiphead_freight,\n '' AS freight_curr_abbr, \n toitem_linenumber AS linenumber, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n tohead_srcname AS warehous_code,\n toitem_qty_ordered AS qtyord,\n SUM(shipitem_qty) AS qtyshipped,\n '' AS notes\nFROM shipitem, shiphead, toitem, tohead, item \nWHERE ( (shipitem_shiphead_id=shiphead_id)\n AND (shipitem_orderitem_id=toitem_id)\n AND (toitem_status <> 'X')\n AND (toitem_item_id=item_id)\n AND (shiphead_order_id=tohead_id)\n AND (shiphead_shipped)\n AND (shiphead_order_type='TO')\n\n AND (shiphead_shipdate BETWEEN and )\n\n\n AND (tohead_src_warehous_id = )\n\n\n AND (tohead_id = )\n\n\n AND (shiphead_id = )\n\n ) \nGROUP BY shiphead_id, toitem_id, shiphead_order_type, shiphead_number,\n tohead_number, shiphead_shipdate,\n toitem_linenumber, item_number, item_descrip1, item_descrip2,\n tohead_srcname, shiphead_tracknum, toitem_qty_ordered, \n shiphead_freight, shiphead_freight_curr_id, notes\n\n ) AS data\nORDER BY sortkey1, sortkey2, level, linenumber DESC;\n admin 2015-10-01 0 86 shippingForm shipment used by printShippingForm\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: shippingForm\n-- Name: shipment\n-- Notes: used by printShippingForm\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cohead_id AS order_id, cohead_shiptoname AS shipto, \n cohead_shiptoaddress1 AS addr1, shiphead_order_type, \n shiphead_id, shiphead_shipchrg_id, shiphead_shipped, \n\tCOALESCE(shiphead_shipform_id, cohead_shipform_id) AS shipform_id \nFROM cohead, shiphead \nWHERE ((cohead_id=shiphead_order_id)\n AND (shiphead_order_type='SO')\n AND (shiphead_id= )\n\n AND (cohead_id= )\n\n) \n\nUNION \nSELECT tohead_id AS order_id, tohead_destname AS shipto, \n tohead_destaddress1 AS addr1, shiphead_order_type, \n shiphead_id, shiphead_shipchrg_id, shiphead_shipped, \n\tCOALESCE(shiphead_shipform_id, tohead_shipform_id) AS shipform_id \nFROM tohead, shiphead \nWHERE ((tohead_id=shiphead_order_id)\n AND (shiphead_order_type='TO')\n AND (shiphead_id= )\n\n AND (tohead_id= )\n\n) \nORDER BY shiphead_shipped \n\nLIMIT 1;\n admin 2015-10-01 0 282 slowMovingInventoryByClassCode detail used by dspSlowMovingInventoryByClassCode\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: slowMovingInventoryByClassCode\n-- Name: detail\n-- Notes: used by dspSlowMovingInventoryByClassCode\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, warehous_code, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescrip, uom_name,\n itemsite_qtyonhand, itemsite_datelastused, cost,\n noNeg(cost * itemsite_qtyonhand) AS value,\n CASE WHEN (COALESCE(itemsite_datelastused, startOfTime()) <= startOfTime()) THEN 'N/A'\n END AS itemsite_datelastused_qtdisplayrole,\n 'qty' AS itemsite_qtyonhand_xtnumericrole,\n 'cost' AS cost_xtnumericrole,\n 'curr' AS value_xtnumericrole,\n 0 AS itemsite_qtyonhand_xttotalrole,\n 0 AS value_xttotalrole\nFROM ( SELECT itemsite_id, warehous_code, item_number,\n item_descrip1, item_descrip2, uom_name,\n itemsite_qtyonhand, itemsite_datelastused,\n \n actcost(itemsite_item_id) \n \n stdcost(itemsite_item_id) \n AS cost \n FROM itemsite, item, whsinfo, uom\n WHERE ((itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (itemsite_active)\n AND (itemsite_datelastused < )\n \n AND (itemsite_warehous_id=)\n \n \n AND (item_classcode_id=)\n \n AND (item_classcode_id IN (SELECT classcode_id FROM classcode WHERE classcode_code ~ ))\n \n )\n ) AS data \nORDER BY warehous_code, \n \n item_number\n \n itemsite_datelastused\n \n noNeg(cost * itemsite_qtyonhand) DESC\n \n;\n admin 2015-10-01 0 283 standardJournalHistory detail used by dspStandardJournalHistory\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: standardJournalHistory\n-- Name: detail\n-- Notes: used by dspStandardJournalHistory\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT gltrans_sequence, gltrans_id,\n sortdate, sortdoc, level, gltrans_amount,\n gltrans_date, gltrans_journalnumber, gltrans_posted,\n gltrans_docnumber, account,\n debit, credit,\n 'curr' AS debit_xtnumericrole,\n 'curr' AS credit_xtnumericrole,\n CASE WHEN (debit = 0) THEN '' END AS debit_qtdisplayrole,\n CASE WHEN (credit = 0) THEN '' END AS credit_qtdisplayrole,\n level AS xtindentrole \nFROM (SELECT DISTINCT gltrans_sequence, -1 AS gltrans_id,\n gltrans_date AS sortdate, gltrans_docnumber AS sortdoc, 0 AS level, 0 AS gltrans_amount,\n gltrans_date, gltrans_journalnumber, gltrans_posted,\n NULL AS gltrans_docnumber,\n NULL AS account,\n 0 AS debit, 0 AS credit\n FROM gltrans, accnt \n WHERE ( (gltrans_accnt_id=accnt_id)\n AND (NOT gltrans_deleted) \n AND (gltrans_date BETWEEN AND )\n AND (gltrans_doctype='ST') ) \n UNION \n SELECT DISTINCT gltrans_sequence, -1 AS gltrans_id,\n gltrans_date AS sortdate, gltrans_docnumber AS sortdoc, 1 AS level, 0 AS gltrans_amount,\n CAST(NULL AS DATE) AS gltrans_date, CAST(NULL AS INTEGER) AS gltrans_journalnumber, \n CAST(NULL AS BOOLEAN) AS gltrans_posted,\n CASE WHEN (COALESCE(gltrans_docnumber, '') = '') THEN 'Unnamed'\n ELSE gltrans_docnumber\n END AS gltrans_docnumber,\n NULL AS account,\n 0 AS debit, 0 AS credit \n FROM gltrans, accnt \n WHERE ( (gltrans_accnt_id=accnt_id)\n AND (NOT gltrans_deleted)\n AND (gltrans_date BETWEEN AND )\n AND (gltrans_doctype='ST') ) \n UNION \n SELECT gltrans_sequence, gltrans_id,\n gltrans_date AS sortdate, gltrans_docnumber AS sortdoc, 2 AS level, gltrans_amount,\n CAST(NULL AS DATE) AS gltrans_date, CAST(NULL AS INTEGER) AS gltrans_journalnumber,\n CAST(NULL AS BOOLEAN) AS gltrans_posted,\n NULL AS gltrans_docnumber,\n (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n CASE WHEN (gltrans_amount < 0) THEN (gltrans_amount * -1)\n END AS debit,\n CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n END AS credit \n FROM gltrans, accnt \n WHERE ( (gltrans_accnt_id=accnt_id)\n AND (NOT gltrans_deleted) \n AND (gltrans_date BETWEEN AND )\n AND (gltrans_doctype='ST') ) \n ) AS data \nORDER BY sortdate, gltrans_sequence, sortdoc, level, gltrans_amount;\n admin 2015-10-01 0 285 substituteAvailability detail used by dspSubstituteAvailabilityByItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: substituteAvailability\n-- Name: detail\n-- Notes: used by dspSubstituteAvailabilityByItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT s_itemsite_id, warehous_code, item_number, itemdescrip,\n availableqoh, reorderlevel, leadtime, itemsub_rank,\n allocated, ordered, available,\n 'qty' AS availableqoh_xtnumericrole,\n 'qty' AS allocated_xtnumericrole,\n 'qty' AS ordered_xtnumericrole,\n 'qty' AS reorderlevel_xtnumericrole,\n 'qty' AS available_xtnumericrole,\n CASE WHEN (reorderlevel >= available) THEN 'error' END AS available_qtforegroundrole\nFROM (SELECT sub.itemsite_id AS s_itemsite_id,\n warehous_code, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n\n (qtyAvailable(sub.itemsite_id) * itemsub_uomratio) AS availableqoh,\n (CASE WHEN(sub.itemsite_useparams)\n THEN sub.itemsite_reorderlevel\n ELSE 0.0\n END * itemsub_uomratio) AS reorderlevel,\n sub.itemsite_leadtime AS leadtime, itemsub_rank,\n\n (qtyAvailable(sub.itemsite_id)) AS availableqoh,\n CASE WHEN(sub.itemsite_useparams) THEN sub.itemsite_reorderlevel\n ELSE 0.0\n END AS reorderlevel,\n sub.itemsite_leadtime AS leadtime, itemsub_rank,\n\n\n \n (qtyAllocated(sub.itemsite_id, sub.itemsite_leadtime) * itemsub_uomratio) AS allocated,\n (qtyOrdered(sub.itemsite_id, sub.itemsite_leadtime) * itemsub_uomratio) AS ordered,\n ((qtyAvailable(sub.itemsite_id) * itemsub_uomratio)\n + (qtyOrdered(sub.itemsite_id, sub.itemsite_leadtime) * itemsub_uomratio)\n - (qtyAllocated(sub.itemsite_id, sub.itemsite_leadtime) * itemsub_uomratio)) AS available\n \n (qtyAllocated(sub.itemsite_id, sub.itemsite_leadtime)) AS allocated,\n (qtyOrdered(sub.itemsite_id, sub.itemsite_leadtime)) AS ordered,\n (qtyAvailable(sub.itemsite_id) + qtyOrdered(sub.itemsite_id, sub.itemsite_leadtime)\n - qtyAllocated(sub.itemsite_id, sub.itemsite_leadtime)) AS available\n \n\n \n (qtyAllocated(sub.itemsite_id, ) * itemsub_uomratio) AS allocated,\n (qtyOrdered(sub.itemsite_id, ) * itemsub_uomratio) AS ordered,\n ((qtyAvailable(sub.itemsite_id) * itemsub_uomratio) + (qtyOrdered(sub.itemsite_id, ) * itemsub_uomratio)\n - (qtyAllocated(sub.itemsite_id, ) * itemsub_uomratio)) AS available\n \n (qtyAllocated(sub.itemsite_id, )) AS allocated,\n (qtyOrdered(sub.itemsite_id, )) AS ordered,\n (qtyAvailable(sub.itemsite_id) + qtyOrdered(sub.itemsite_id, )\n - qtyAllocated(sub.itemsite_id, )) AS available\n \n\n \n (qtyAllocated(sub.itemsite_id, ( - CURRENT_DATE)) * itemsub_uomratio) AS allocated,\n (qtyOrdered(sub.itemsite_id, ( - CURRENT_DATE)) * itemsub_uomratio) AS ordered,\n ((qtyAvailable(sub.itemsite_id) * itemsub_uomratio) + (qtyOrdered(sub.itemsite_id, ( - CURRENT_DATE)) * itemsub_uomratio)\n - (qtyAllocated(sub.itemsite_id, ( - CURRENT_DATE)) * itemsub_uomratio)) AS available\n \n (qtyAllocated(sub.itemsite_id, ( - CURRENT_DATE))) AS allocated,\n (qtyOrdered(sub.itemsite_id, ( - CURRENT_DATE))) AS ordered,\n (qtyAvailable(sub.itemsite_id) + qtyOrdered(sub.itemsite_id,\n ( - CURRENT_DATE)) - qtyAllocated(sub.itemsite_id, ( - CURRENT_DATE))) AS available\n \n\n FROM item, itemsite AS sub, itemsite AS root, whsinfo, itemsub\n WHERE ((sub.itemsite_item_id=item_id)\n AND (root.itemsite_item_id=itemsub_parent_item_id)\n AND (sub.itemsite_item_id=itemsub_sub_item_id)\n AND (root.itemsite_warehous_id=sub.itemsite_warehous_id)\n AND (sub.itemsite_warehous_id=warehous_id)\n AND (root.itemsite_item_id=)\n\n AND (root.itemsite_warehous_id=)\n\n )\n ) AS data\nORDER BY itemsub_rank;\n admin 2015-10-01 0 107 summarizedBacklogByWarehouse counts \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: summarizedBacklogByWarehouse\n-- Name: counts\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT COUNT(coitem.*) AS totalitems \n FROM cohead, coitem, itemsite, custinfo\n\t\t WHERE ( (coitem_cohead_id=cohead_id)\n\t\t AND (coitem_itemsite_id=itemsite_id)\n\t\t AND (cohead_cust_id=cust_id)\n\t\t AND (coitem_status NOT IN ('C','X'))\n\t\t AND (coitem_scheddate BETWEEN \n\t\t AND )\n\t\t \n\t\t AND (itemsite_warehous_id=)\n\t\t \n\t\t \n\t\t AND (cust_custtype_id=)\n\t\t \n\t\t AND (cust_custtype_id IN (SELECT custtype_id FROM custtype\n\t\t WHERE (custtype_code ~ )))\n\t\t \n\t\t );\n admin 2015-10-01 0 294 timePhasedSales detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timePhasedSales\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n\n cust_id, cust_number, cust_name, \n\n prodcat_id, prodcat_code, prodcat_descrip,\n\n item_id, item_number, item_descrip1,\n\n uom, warehous_code\n-- Loop through each period bucket to find bookings for period\n\n , SUM(CASE WHEN (cohist_invcdate BETWEEN findPeriodStart() AND findPeriodEnd()) THEN\n amount ELSE 0 END) AS bucket_,\n \n 'curr' AS bucket__xtnumericrole, \n 0 AS bucket__xttotalrole\n \n 'qty' AS bucket__xtnumericrole, \n 0 AS bucket__xttotalrole \n \n\nFROM ( \n SELECT cohist_invcdate,\n\n cust_id, cust_number, cust_name\n\n prodcat_id, prodcat_code, prodcat_descrip\n\n item_id, item_number, item_descrip1\n\n , warehous_code\n\n , round((cohist_qtyshipped * currtobase(cohist_curr_id, cohist_unitprice, cohist_invcdate)), 2) AS amount\n , ::text AS uom\n\n , cohist_qtyshipped\n \n * itemcapinvrat(itemsite_item_id)\n \n * itemaltcapinvrat(itemsite_item_id)\n \n AS amount\n \n , uom_name AS uom\n \n , itemcapuom(item_id) AS uom\n \n , itemaltcapuom(item_id) AS uom\n \n\n FROM cohist JOIN itemsite ON (itemsite_id=cohist_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n\n JOIN uom ON (item_inv_uom_id=uom_id)\n\n JOIN site() ON (itemsite_warehous_id=warehous_id)\n\n JOIN custinfo ON (cohist_cust_id=cust_id)\n \n\n JOIN custgrpitem ON (cohist_cust_id=custgrpitem_cust_id)\n JOIN custgrp ON (custgrp_id=custgrpitem_custgrp_id)\n \n\n JOIN prodcat ON (item_prodcat_id=prodcat_id)\n\n WHERE ((cohist_invcdate BETWEEN \n\n \n findPeriodStart()\n \n \n AND findPeriodEnd()\n \n)\n \n AND (item_id=)\n\n \n AND (cust_id=)\n\n \n AND (cust_custtype_id=)\n\n\n AND (cust_custtype_id IN (SELECT custtype_id \n FROM custtype \n WHERE (custtype_code ~ )))\n\n \n AND (item_prodcat_id=) \n\n\n AND (item_prodcat_id IN (SELECT prodcat_id \n FROM prodcat \n WHERE (prodcat_code ~ )))\n\n \n AND (custgrp_id=) \n\n\n AND (custgrp_name ~ )\n\n \n AND(itemsite_warehous_id=) \n\n )) data\nGROUP BY\n\n cust_id, cust_number, cust_name, \n\n prodcat_id, prodcat_code, prodcat_descrip,\n\n item_id, item_number, item_descrip1,\n\n uom, warehous_code\nORDER BY \n\n cust_number,\n\n prodcat_code,\n\n item_number,\n\n uom, warehous_code;\n admin 2015-10-01 0 108 summarizedBacklogByWarehouse detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: summarizedBacklogByWarehouse\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT * FROM (\n(SELECT cohead_id, 0 AS xtindentrole, salesrep_name, cohead_holdtype, cohead_number, \n coheadstatecolor(cohead_id) AS qtforegroundrole, \n cust_name, \n cohead_created, cohead_orderdate, cohead_packdate, pack_head_id, \n CASE WHEN (cohead_holdtype='N') THEN \n WHEN (cohead_holdtype='C') THEN \n WHEN (cohead_holdtype='S') THEN \n WHEN (cohead_holdtype='P') THEN \n WHEN (cohead_holdtype='R') THEN \n ELSE \n END AS f_holdtype, \n MIN(coitem_scheddate) AS scheddate, \n SUM((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) * \n (currToBase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio) ) AS sales, \n SUM((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) * stdcost(item_id) ) AS cost,\n SUM((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n ((currToBase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio) - stdcost(item_id)) ) AS margin,\n 'curr' AS sales_xtnumericrole,\n 'curr' AS cost_xtnumericrole,\n 'curr' AS margin_xtnumericrole,\n NULL AS shiphead_id, \n NULL AS shiphead_number, \n NULL AS shipstatus,\n NULL AS shipvia,\n CASE WHEN (pack_head_id IS NOT NULL) THEN TRUE\n ELSE FALSE\n END AS packed \n \n , 0 AS sales_xttotalrole, 0 AS cost_xttotalrole, 0 AS margin_xttotalrole \n ,\n cohead_number AS seq\n FROM coitem, itemsite, item, custinfo, cohead\n LEFT OUTER JOIN pack ON (cohead_id = pack_head_id), salesrep \n WHERE ( (coitem_cohead_id=cohead_id)\n AND (salesrep_id = cohead_salesrep_id) \n AND (cohead_cust_id=cust_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (coitem_status NOT IN ('C','X'))\n AND (coitem_scheddate BETWEEN \n AND )\n \n AND (itemsite_warehous_id=)\n \n \n AND (cust_custtype_id=)\n \n AND (cust_custtype_id IN (SELECT custtype_id FROM custtype\n WHERE (custtype_code ~ )))\n \n ) \n GROUP BY cohead_id, salesrep_number, salesrep_name, cohead_number, cust_name,\n cohead_holdtype, cohead_orderdate, cohead_packdate,\n cohead_created, pack_head_id )\n UNION \n (SELECT cohead_id, 1 AS xtindentrole, NULL, NULL, \n shiphead_number AS cohead_number, \n CASE WHEN (shiphead_shipped IS NULL) THEN '' \n WHEN (shiphead_shipped) THEN 'altemphasis' \n WHEN (NOT shiphead_shipped) THEN 'emphasis' \n WHEN ( (COALESCE(cobmisc_cohead_id,0) > 0) \n AND (SUM(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned)) > 0) \n ) THEN 'error' \n END AS qtforegroundrole, \n COALESCE(shiphead_shipvia, ''), NULL, shiphead_shipdate AS cohead_orderdate, \n NULL, NULL,\n CASE WHEN (shiphead_shipped) THEN \n ELSE \n END AS f_holdtype, MIN(coitem_scheddate), NULL, NULL, NULL, NULL, NULL, NULL, NULL, \n formatShipmentNumber(shiphead_id) AS shiphead_number, \n NULL, \n COALESCE(shiphead_shipvia, '') AS shipvia \n \n , NULL, NULL, NULL \n \n , NULL,\n cohead_number AS seq \n FROM coitem, itemsite, item, custinfo, cohead\n LEFT OUTER JOIN shiphead ON ((shiphead_order_id=cohead_id) \n AND (shiphead_order_type='SO'))\n LEFT OUTER JOIN (SELECT DISTINCT cobmisc_cohead_id FROM cobmisc) AS cobmisc ON (cobmisc_cohead_id=cohead_id) \n LEFT OUTER JOIN pack ON (cohead_id = pack_head_id), salesrep \n WHERE ( (coitem_cohead_id=cohead_id)\n AND (salesrep_id = cohead_salesrep_id) \n AND (cohead_cust_id=cust_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (coitem_status NOT IN ('C','X'))\n AND (coitem_scheddate BETWEEN \n AND )\n \n AND (itemsite_warehous_id=)\n \n \n AND (cust_custtype_id=)\n \n AND (cust_custtype_id IN (SELECT custtype_id FROM custtype\n WHERE (custtype_code ~ )))\n \n AND ((SELECT (count(*)>0) FROM shipitem WHERE ((shipitem_shiphead_id=shiphead_id) AND (NOT shipitem_invoiced))))) \n GROUP BY cohead_id, salesrep_number, salesrep_name, cohead_number, cust_name, \n cohead_holdtype, cohead_orderdate, cohead_packdate, \n shiphead_shipped, shiphead_shipvia, shiphead_shipdate, \n shiphead_id, cobmisc_cohead_id, cohead_created, pack_head_id,\n shiphead_number )) AS data\n ORDER BY seq, cohead_number;\n\n\n admin 2015-10-01 0 109 summarizedBacklogByWarehouse qtys \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: summarizedBacklogByWarehouse\n-- Name: qtys\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT formatQty(COALESCE(SUM(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned), 0)) AS f_totalqty \n FROM cohead, coitem, itemsite, item, custinfo\n\t\t WHERE ( (coitem_cohead_id=cohead_id)\n\t\t AND (coitem_itemsite_id=itemsite_id)\n\t\t AND (itemsite_item_id=item_id)\n\t\t AND (cohead_cust_id=cust_id)\n\t\t AND (coitem_status NOT IN ('C','X'))\n\t\t AND (coitem_scheddate BETWEEN \n\t\t AND )\n\t\t \n\t\t AND (itemsite_warehous_id=)\n\t\t \n\t\t \n\t\t AND (cust_custtype_id=)\n\t\t \n\t\t AND (cust_custtype_id IN (SELECT custtype_id FROM custtype\n\t\t WHERE (custtype_code ~ )))\n\t\t \n\t\t );\n admin 2015-10-01 0 110 summarizedBacklogByWarehouse totals \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: summarizedBacklogByWarehouse\n-- Name: totals\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT COUNT(cohead_id) AS totalorders \n\t\t FROM ( SELECT DISTINCT cohead_id \n FROM cohead, coitem, itemsite, custinfo\n\t\t WHERE ( (coitem_cohead_id=cohead_id)\n\t\t AND (coitem_itemsite_id=itemsite_id)\n\t\t AND (cohead_cust_id=cust_id)\n\t\t AND (coitem_status NOT IN ('C','X'))\n\t\t AND (coitem_scheddate BETWEEN \n\t\t AND )\n\t\t \n\t\t AND (itemsite_warehous_id=)\n\t\t \n\t\t \n\t\t AND (cust_custtype_id=)\n\t\t \n\t\t AND (cust_custtype_id IN (SELECT custtype_id FROM custtype\n\t\t WHERE (custtype_code ~ )))\n\t\t \n\t\t ) ) AS data;\n admin 2015-10-01 0 286 summarizedBankrecHistory detail used by dspSummarizedBankrecHistory\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: summarizedBankrecHistory\n-- Name: detail\n-- Notes: used by dspSummarizedBankrecHistory\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n 'curr' AS bankrec_openbal_xtnumericrole,\n 'curr' AS bankrec_endbal_xtnumericrole\nFROM bankrec\nWHERE (bankrec_bankaccnt_id=)\nORDER BY bankrec_created;\n admin 2015-10-01 0 287 summarizedGLTransactions detail used by dspSummarizedGLTransactions\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: summarizedGLTransactions\n-- Name: detail\n-- Notes: used by dspSummarizedGLTransactions\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT accnt_id, gltrans_id,\n account, accnt_descrip,\n gltrans_date, gltrans_source, gltrans_doctype, gltrans_docnumber,\n f_notes,\n debit, credit,\n gltrans_username, gltrans_created,\n CASE WHEN (level=0) THEN accnt_descrip\n ELSE f_notes \n END AS descrip_notes, \n 'curr' AS debit_xtnumericrole,\n 'curr' AS credit_xtnumericrole,\n 0 AS debit_xtnumericrole,\n 0 AS credit_xtnumericrole,\n CASE WHEN (debit=0) THEN '' END AS debit_qtdisplayrole,\n CASE WHEN (credit=0) THEN '' END AS credit_qtdisplayrole,\n level AS xtindentrole \nFROM ( \nSELECT DISTINCT accnt_id, -1 AS gltrans_id, 0 AS level,\n accnt_number, accnt_profit, accnt_sub, \n formatGLAccount(accnt_id) AS account, accnt_descrip,\n CAST(NULL AS DATE) AS gltrans_date, '' AS gltrans_source, '' AS gltrans_doctype, '' AS gltrans_docnumber,\n '' AS f_notes,\n SUM( CASE WHEN (gltrans_amount < 0) THEN (gltrans_amount * -1) \n ELSE 0 \n END ) AS debit, \n SUM( CASE WHEN (gltrans_amount > 0) THEN gltrans_amount \n ELSE 0 \n END ) AS credit, \n '' AS gltrans_username, CAST(NULL AS TIMESTAMP) AS gltrans_created \nFROM gltrans, accnt \nWHERE ( (gltrans_accnt_id=accnt_id)\n AND (NOT gltrans_deleted) \n AND (gltrans_date BETWEEN AND ) \n\n \n\n AND (gltrans_source=)\n\n \n\n AND (NOT gltrans_posted)\n\n AND (gltrans_posted)\n\n ) GROUP BY accnt_id, accnt_number, accnt_profit, accnt_sub, accnt_descrip \n UNION \n SELECT accnt_id, gltrans_id, 1 AS level,\n accnt_number, accnt_profit, accnt_sub, \n '' AS account, '' AS accnt_descrip,\n gltrans_date, gltrans_source, gltrans_doctype, gltrans_docnumber,\n firstLine(gltrans_notes) AS f_notes,\n CASE WHEN (gltrans_amount < 0) THEN (gltrans_amount * -1)\n ELSE 0\n END AS debit,\n CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n ELSE 0\n END AS credit,\n gltrans_username, gltrans_created \n FROM gltrans, accnt \n WHERE ((gltrans_accnt_id=accnt_id)\n AND (NOT gltrans_deleted) \n AND (gltrans_date BETWEEN AND ) \n\n\n AND (gltrans_source=)\n\n\n\n AND (NOT gltrans_posted)\n\n AND (gltrans_posted)\n\n\n)) AS data \n ORDER BY accnt_number, accnt_profit, accnt_sub, level, gltrans_date DESC, gltrans_created;\n admin 2015-10-01 0 295 timePhasedUsageStatisticsByItem detail used by dspTimePhasedUsageStatisticsByItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timePhasedUsageStatisticsByItem\n-- Name: detail\n-- Notes: used by dspTimePhasedUsageStatisticsByItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT itemsite_id, AS label, warehous_code\n \n , summTransR(itemsite_id, ) AS bucket_\n \nFROM itemsite, whsinfo\nWHERE ((itemsite_warehous_id=warehous_id)\n\n AND (itemsite_item_id=)\n\n\n AND (itemsite_warehous_id=)\n\n )\nUNION ALL\nSELECT itemsite_id, AS label, warehous_code\n \n , summTransI(itemsite_id, ) AS bucket_\n \nFROM itemsite, whsinfo\nWHERE ((itemsite_warehous_id=warehous_id)\n\n AND (itemsite_item_id=)\n\n\n AND (itemsite_warehous_id=)\n\n )\nUNION ALL\nSELECT itemsite_id, AS label, warehous_code\n \n , summTransS(itemsite_id, ) AS bucket_\n \nFROM itemsite, whsinfo\nWHERE ((itemsite_warehous_id=warehous_id)\n\n AND (itemsite_item_id=)\n\n\n AND (itemsite_warehous_id=)\n\n )\nUNION ALL\nSELECT itemsite_id, AS label, warehous_code\n \n , summTransC(itemsite_id, ) AS bucket_\n \nFROM itemsite, whsinfo\nWHERE ((itemsite_warehous_id=warehous_id)\n\n AND (itemsite_item_id=)\n\n\n AND (itemsite_warehous_id=)\n\n )\nUNION ALL\nSELECT itemsite_id, AS label, warehous_code\n \n , summTransA(itemsite_id, ) AS bucket_\n \nFROM itemsite, whsinfo\nWHERE ((itemsite_warehous_id=warehous_id)\n\n AND (itemsite_item_id=)\n\n\n AND (itemsite_warehous_id=)\n\n )\nORDER BY warehous_code;\n admin 2015-10-01 0 288 summarizedSalesHistory detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: summarizedSalesHistory\n-- Name: detail\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT 1 AS dummy,\n-- Columns added to match columns of Printed Report\n\n \n \n || E'\\n' ||\n \n AS groupsLit,\n\n substring( from 1 for 15)\n \n || E'\\n' ||\n \n AS groups,\n\n substring( from 1 for 30)\n \n || E'\\n' ||\n \n AS groupsDescrip,\n-- End of columns for printed report\n \n cust_number, cohist_cust_id AS cust_number_xtidrole, cust_name,\n \n \n custtype_code, custtype_id AS custtype_code_xtidrole,\n \n \n item_number, item_id AS item_number_xtidrole, itemdescription,\n \n \n salesrep_number, salesrep_id AS salesrep_number_xtidrole, salesrep_name,\n \n \n shipzone_name, shipzone_id AS shipzone_name_xtidrole,\n \n \n warehous_code, warehous_id AS warehous_code_xtidrole,\n \n \n currAbbr,\n MIN(custunitprice) AS minprice, MAX(custunitprice) AS maxprice,\n AVG(custunitprice) AS avgprice,\n SUM(custextprice) AS totalsales,\n CASE WHEN (SUM(cohist_qtyshipped) = 0) THEN 0\n ELSE SUM(custextprice) / SUM(cohist_qtyshipped)\n END AS wtavgprice,\n \n currConcat(baseCurrId()) AS currAbbr,\n MIN(baseunitprice) AS minprice, MAX(baseunitprice) AS maxprice,\n AVG(baseunitprice) AS avgprice,\n SUM(baseextprice) AS totalsales,\n CASE WHEN (SUM(cohist_qtyshipped) = 0) THEN 0\n ELSE SUM(baseextprice) / SUM(cohist_qtyshipped)\n END AS wtavgprice,\n \n SUM(cohist_qtyshipped) AS totalunits,\n MIN(cohist_invcdate) AS firstdate,\n MAX(cohist_invcdate) AS lastdate,\n SUM(cohist_qtyshipped) AS qtyshipped,\n 'salesprice' AS minprice_xtnumericrole,\n 'salesprice' AS maxprice_xtnumericrole,\n 'salesprice' AS avgprice_xtnumericrole,\n 'salesprice' AS wtavgprice_xtnumericrole,\n 'qty' AS qtyshipped_xtnumericrole,\n 'curr' AS extprice_xtnumericrole,\n 'qty' AS totalunits_xtnumericrole,\n 'curr' AS totalsales_xtnumericrole,\n 'qty' AS totalunits_xtnumericrole,\n 'curr' AS totalsales_xtnumericrole,\n 0 AS totalunits_xttotalrole,\n 0 AS totalsales_xttotalrole\n\n FROM saleshistorymisc\n\n FROM saleshistory\n\nWHERE ( (TRUE)\n\n AND (cohist_invcdate >= )\n\n\n\n AND (cohist_invcdate <= )\n\n\n\n AND (cohist_shipdate >= )\n\n\n\n AND (cohist_shipdate <= )\n\n\n\n AND (warehous_id=)\n\n\n\n AND (item_id=)\n\n\n\n AND (cohist_cust_id=)\n\n\n\n AND (cohist_shipto_id=)\n\n\n\n AND (salesrep_id=)\n\n\n\n AND (prodcat_id=)\n\n\n\n AND (prodcat_code ~ )\n\n\n\n AND (custtype_id=)\n\n\n\n AND (custtype_code ~ )\n\n\n\n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrpitem\n WHERE (custgrpitem_custgrp_id=)))\n\n\n\n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrp, custgrpitem\n WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n AND (custgrp_name ~ ) )) )\n\n\n\n AND (shipzone_id=)\n\n\n\n AND cust_curr_id = \n\n\n\n AND (currAbbr ~ )\n\n)\nGROUP BY dummy\n\n , salesrep_id, salesrep_number, salesrep_name\n\n\n , shipzone_id, shipzone_name, shipzone_descrip\n\n\n , cohist_cust_id, cust_number, cust_name\n\n\n , custtype_id, custtype_code, custtype_descrip\n\n\n , item_id, item_number, itemdescription\n\n\n , warehous_id, warehous_code, warehous_descrip\n\n\n , cust_curr_id, currAbbr\n\n ORDER BY dummy\n\n , salesrep_number\n\n\n , shipzone_name\n\n\n , cust_number\n\n\n , custtype_code\n\n\n , item_number\n\n\n , warehous_code\n\n; admin 2015-10-01 0 289 taxAuthorities detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: taxAuthorities\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n taxauth_id, taxauth_code, taxauth_name,\n addr.*\nFROM taxauth\n LEFT OUTER JOIN addr ON (taxauth_addr_id=addr_id) \nWHERE true\n\n AND ((taxauth_code ~* )\n OR (taxauth_name ~* )\n OR (COALESCE(addr_line1,'') || ' ' || COALESCE(addr_line2,'') || ' ' || COALESCE(addr_line3,'') ~* )\n OR (COALESCE(addr_city,'') ~* )\n OR (COALESCE(addr_state,'') ~* )\n OR (COALESCE(addr_postalcode,'') ~* )\n OR (COALESCE(addr_country,'') ~* ))\n\n\n AND (taxauth_code ~* )\n\n\n AND (taxauth_name ~* )\n\n\n AND (COALESCE(addr_line1,'') || ' ' || COALESCE(addr_line2,'') || ' ' || COALESCE(addr_line3,'') ~* )\n\n\n AND (COALESCE(addr_city,'') ~* )\n\n\n AND (COALESCE(addr_state,'') ~* )\n\n\n AND (COALESCE(addr_postalcode,'') ~* )\n\n\n AND (COALESCE(addr_country,'') ~* )\n\nORDER BY taxauth_code; \n admin 2015-10-01 0 103 taxBreakdown detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: taxBreakdown\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\n SELECT head.*, linetax.*, freighttax.*, adjtax.* \n FROM\n (SELECT \n invchead_invcnumber AS number, invchead_taxzone_id AS taxzone_id, \n invchead_curr_id AS curr_id, invchead_curr_id AS tax_curr_id, invchead_invcdate AS date, \n SUM(ROUND(((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price) / \n (CASE WHEN(item_id IS NULL) THEN 1 ELSE invcitem_price_invuomratio END)), 2)) AS line, \n invchead_freight AS freight, \n getFreightTaxTypeId() AS freightTax, getAdjustmentTaxTypeId() AS adjTax \n FROM invchead\n LEFT OUTER JOIN invcitem ON (invcitem_invchead_id=invchead_id) \n LEFT OUTER JOIN item ON (invcitem_item_id=item_id) \n WHERE (invchead_id=) \n GROUP BY number, taxzone_id, curr_id, tax_curr_id, date, freight, freightTax, adjTax) head, \n (SELECT ROUND(SUM(group_tax), 2) AS total_tax FROM\n (SELECT ROUND(SUM(invcitemtax.taxhist_tax),2) AS group_tax \n FROM invcitemtax \n LEFT OUTER JOIN invcitem ON (taxhist_parent_id = invcitem_id) \n WHERE (invcitem_invchead_id=)\n GROUP BY taxhist_tax_id) AS data\n ) linetax,\n (SELECT ROUND(SUM(group_tax), 2) AS freighttaxamt FROM\n (SELECT ROUND(SUM(taxhist_tax),2) AS group_tax \n FROM invchead \n LEFT OUTER JOIN invcheadtax ON (taxhist_parent_id = invchead_id \n AND taxhist_taxtype_id = getfreighttaxtypeid()) \n WHERE (invchead_id=)\n GROUP BY taxhist_tax_id) AS data\n ) freighttax, \n (SELECT ROUND(SUM(group_tax), 2) AS adjtaxamt FROM\n (SELECT ROUND(SUM(taxhist_tax),2) AS group_tax \n FROM invchead \n LEFT OUTER JOIN invcheadtax ON (taxhist_parent_id = invchead_id \n AND taxhist_taxtype_id = getadjustmenttaxtypeid()) \n WHERE (invchead_id=)\n GROUP BY taxhist_tax_id) AS data\n ) adjtax;\n\n SELECT head.*, linetax.*, freighttax.*, adjtax.* \n FROM\n (SELECT \n cmhead_number AS number, cmhead_taxzone_id AS taxzone_id, \n cmhead_curr_id AS curr_id, cmhead_curr_id AS tax_curr_id, cmhead_docdate AS date, \n SUM(ROUND(((cmitem_qtycredit * cmitem_qty_invuomratio) * (cmitem_unitprice) / \n cmitem_price_invuomratio), 2)) AS line, \n cmhead_freight AS freight, \n getFreightTaxTypeId() AS freightTax, getAdjustmentTaxTypeId() AS adjTax \n FROM cmhead \n LEFT OUTER JOIN cmitem ON (cmitem_cmhead_id=cmhead_id) \n WHERE (cmhead_id=) \n GROUP BY number, taxzone_id, curr_id, tax_curr_id, date, freight, freightTax, adjTax) head, \n (SELECT ROUND(SUM(group_tax), 2) AS total_tax FROM\n (SELECT ROUND(SUM(cmitemtax.taxhist_tax * -1),2) AS group_tax \n FROM cmitemtax \n LEFT OUTER JOIN cmitem ON (taxhist_parent_id = cmitem_id) \n WHERE (cmitem_cmhead_id=)\n GROUP BY taxhist_tax_id) AS data\n ) linetax,\n (SELECT ROUND(SUM(group_tax), 2) AS freighttaxamt FROM\n (SELECT ROUND(SUM(taxhist_tax * -1),2) AS group_tax \n FROM cmhead \n LEFT OUTER JOIN cmheadtax ON (taxhist_parent_id = cmhead_id \n AND taxhist_taxtype_id = getfreighttaxtypeid()) \n WHERE (cmhead_id=)\n GROUP BY taxhist_tax_id) AS data\n ) freighttax, \n (SELECT ROUND(SUM(group_tax), 2) AS adjtaxamt FROM\n (SELECT ROUND(SUM(taxhist_tax * -1),2) AS group_tax \n FROM cmhead \n LEFT OUTER JOIN cmheadtax ON (taxhist_parent_id = cmhead_id \n AND taxhist_taxtype_id = getadjustmenttaxtypeid()) \n WHERE (cmhead_id=)\n GROUP BY taxhist_tax_id) AS data\n ) adjtax;\n\n SELECT head.*, linetax.*, frighttax.*, adjtax.* \n FROM \n (SELECT cohead_number AS number, cobmisc_taxzone_id AS taxzone_id, \n cobmisc_curr_id AS curr_id, cobmisc_curr_id AS tax_curr_id, \n cobmisc_invcdate AS date, SUM(ROUND((cobill_qty * coitem_price) / \n (CASE WHEN(item_id IS NULL) THEN 1 ELSE coitem_price_invuomratio END), 2)) AS line, \n cobmisc_freight AS freight, \n getFreightTaxTypeId() AS freightTax, getAdjustmentTaxTypeId() AS adjTax \t \n FROM cobmisc\n JOIN cohead ON (cobmisc_cohead_id=cohead_id) \n LEFT OUTER JOIN cobill ON (cobill_cobmisc_id=cobmisc_id) \n LEFT OUTER JOIN coitem ON (cobill_coitem_id=coitem_id) \n LEFT OUTER JOIN itemsite ON (coitem_itemsite_id=itemsite_id) \n LEFT OUTER JOIN item ON (itemsite_item_id=item_id) \n WHERE (cobmisc_id=) \n GROUP BY number, cobmisc_taxzone_id, curr_id, tax_curr_id, \n date, freight, freightTax,adjTax) head, \n (SELECT ROUND(SUM(group_tax), 2) AS total_tax FROM\n (SELECT ROUND(SUM(cobilltax.taxhist_tax),2) AS group_tax\n FROM cobilltax\n LEFT OUTER JOIN cobill ON (cobill_id=taxhist_parent_id) \n WHERE (cobill_cobmisc_id=)\n GROUP BY taxhist_tax_id) AS data\n ) linetax, \n (SELECT ROUND(SUM(group_tax), 2) AS freighttaxamt FROM\n (SELECT ROUND(SUM(taxhist_tax),2) AS group_tax\n FROM cobmisctax\n LEFT OUTER JOIN cobmisc ON (taxhist_parent_id = cobmisc_id AND taxhist_taxtype_id = getfreighttaxtypeid()) \n WHERE (cobmisc_id=)\n GROUP BY taxhist_tax_id) AS data\n ) frighttax, \n (SELECT ROUND(SUM(group_tax), 2) AS adjtaxamt FROM\n (SELECT ROUND(SUM(taxhist_tax),2) AS group_tax\n FROM cobmisctax\n LEFT OUTER JOIN cobmisc ON (taxhist_parent_id = cobmisc_id AND taxhist_taxtype_id = getadjustmenttaxtypeid()) \n WHERE (cobmisc_id=)\n GROUP BY taxhist_tax_id) AS data\n ) adjtax;\n\n SELECT cohead_number AS number,\n cohead_taxzone_id AS taxzone_id,\n cohead_curr_id AS curr_id,\n cohead_curr_id AS tax_curr_id,\n cohead_orderdate AS date,\n SUM(ROUND((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio),\n 2)) AS line,\n ROUND(SUM(calculateTax(cohead_taxzone_id, coitem_taxtype_id, cohead_orderdate, cohead_curr_id, ROUND((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price /\n coitem_price_invuomratio), 2))),2) as total_tax, \n cohead_freight AS freight,\n getFreightTaxTypeId() AS freightTax, \n ROUND(calculateTax(cohead_taxzone_id, getfreighttaxtypeid(), cohead_orderdate, cohead_curr_id, cohead_freight), 2) AS freighttaxamt\n FROM coitem, item, itemsite, cohead \n LEFT OUTER JOIN taxzone ON (cohead_taxzone_id=taxzone_id) \n LEFT OUTER JOIN taxtype ON (taxtype_id=getFreightTaxTypeId())\n WHERE ((coitem_cohead_id=)\n AND (coitem_cohead_id=cohead_id)\n AND (coitem_status != 'X')\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id))\n GROUP BY number, cohead_taxzone_id, curr_id, tax_curr_id,\n date, freight, freightTax,freighttaxamt;\n\n SELECT quhead_number AS number,\n quhead_taxzone_id AS taxzone_id,\n quhead_curr_id AS curr_id,\n quhead_curr_id AS tax_curr_id,\n quhead_quotedate AS date,\n SUM(ROUND((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio),\n 2)) AS line,\n ROUND(SUM(calculateTax(quhead_taxzone_id, quitem_taxtype_id, quhead_quotedate, quhead_curr_id, ROUND((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price /\n quitem_price_invuomratio), 2))),2) as total_tax, \n quhead_freight AS freight,\n taxtype_id AS freightTax,\n ROUND(calculateTax(quhead_taxzone_id, getfreighttaxtypeid(), quhead_quotedate, quhead_curr_id, quhead_freight), 2) AS freighttaxamt\n FROM quitem, item, quhead \n LEFT OUTER JOIN taxzone ON (quhead_taxzone_id=taxzone_id) \n LEFT OUTER JOIN taxtype ON (taxtype_id=getFreightTaxTypeId())\n WHERE ((quitem_quhead_id=)\n AND (quitem_quhead_id=quhead_id)\n AND (quitem_item_id=item_id))\n GROUP BY number, quhead_taxzone_id, curr_id, tax_curr_id,\n date, freight, freightTax,freighttaxamt;\n\n SELECT rahead_number AS number,\n rahead_taxzone_id AS taxzone_id,\n rahead_curr_id AS curr_id,\n rahead_curr_id AS tax_curr_id,\n rahead_authdate AS date,\n COALESCE(SUM(ROUND((raitem_qtyauthorized * raitem_qty_invuomratio) * (raitem_unitprice / raitem_price_invuomratio),\n 2)),0) AS line,\n COALESCE(ROUND(SUM(calculateTax(rahead_taxzone_id, raitem_taxtype_id, rahead_authdate, rahead_curr_id, ROUND((raitem_qtyauthorized * raitem_qty_invuomratio) * (raitem_unitprice /\n raitem_price_invuomratio), 2))),2),0) as total_tax, \n rahead_freight AS freight,\n taxtype_id AS freightTax,\n ROUND(calculateTax(rahead_taxzone_id, getfreighttaxtypeid(), rahead_authdate, rahead_curr_id, rahead_freight), 2) AS freighttaxamt\n FROM rahead \n LEFT OUTER JOIN raitem ON (raitem_rahead_id=rahead_id)\n LEFT OUTER JOIN taxzone ON (rahead_taxzone_id=taxzone_id) \n LEFT OUTER JOIN taxtype ON (taxtype_id=getFreightTaxTypeId())\n WHERE (raitem_rahead_id=)\n GROUP BY number, rahead_taxzone_id, curr_id, tax_curr_id,\n date, freight, freightTax;\n\n SELECT tohead_number AS number,\n tohead_taxzone_id AS taxzone_id,\n tohead_freight_curr_id AS curr_id,\n tohead_freight_curr_id AS tax_curr_id,\n tohead_orderdate AS date,\n-------- SUM(ROUND(toitem_freight, 2)) AS line,\n-------- COALESCE(ROUND(SUM(calculateTax(tohead_taxzone_id, getfreighttaxtypeid(), tohead_orderdate, baseCurrId(), toitem_freight)),2),0) as total_tax,\n 0.0 AS line, 0.0 AS total_tax, \n tohead_freight + SUM(ROUND(toitem_freight, 2)) AS freight,\n getFreightTaxTypeId() AS freightTax,\n COALESCE(ROUND(SUM(calculateTax(tohead_taxzone_id, getfreighttaxtypeid(), tohead_orderdate, baseCurrId(), toitem_freight)),2),0) +\n COALESCE(ROUND(calculateTax(tohead_taxzone_id, getfreighttaxtypeid(), tohead_orderdate, baseCurrId(), tohead_freight),2),0) AS freighttaxamt \n FROM toitem, tohead \n WHERE ((toitem_tohead_id=)\n AND (toitem_tohead_id=tohead_id)\n AND (toitem_status!='X')) \n GROUP BY number, taxzone_id, curr_id, tax_curr_id,\n date,\t\ttohead_freight,\tfreightTax\n\n SELECT pohead_number AS number,\n pohead_taxzone_id AS taxzone_id,\n pohead_curr_id AS curr_id,\n pohead_curr_id AS tax_curr_id,\n pohead_orderdate AS date,\n COALESCE(SUM(ROUND(poitem_unitprice * poitem_qty_ordered, 2)),0) AS line,\n (SELECT SUM(tax) AS tax \n FROM (\n SELECT ROUND(SUM(taxdetail_tax),2) AS tax \n FROM tax \n JOIN calculateTaxDetailSummary('PO', , 'T') ON (taxdetail_tax_id=tax_id)\n GROUP BY tax_id) data\n ) as total_tax,\n (COALESCE(SUM(poitem_freight),0)+COALESCE(pohead_freight,0)) AS freight,\n taxtype_id AS freightTax,\n 0 AS freighttaxamt\n FROM pohead \n LEFT OUTER JOIN poitem ON (poitem_pohead_id=pohead_id)\n LEFT OUTER JOIN taxzone ON (pohead_taxzone_id=taxzone_id) \n LEFT OUTER JOIN taxtype ON (taxtype_id=getFreightTaxTypeId())\n WHERE (poitem_pohead_id=)\n GROUP BY number, pohead_taxzone_id, curr_id, tax_curr_id,\n date, pohead_freight, freightTax;\n\n SELECT head.*, linetax.*, adjtax.* \n FROM\n (SELECT \n vohead_number AS number, vohead_taxzone_id AS taxzone_id, \n vohead_curr_id AS curr_id, vohead_curr_id AS tax_curr_id, vohead_docdate AS date, \n COALESCE(SUM(ROUND(voitem_qty * poitem_unitprice, 2)), 0) AS line, \n COALESCE(SUM(voitem_freight), 0) AS freight, \n getAdjustmentTaxTypeId() AS adjTax \n FROM voitem \n LEFT OUTER JOIN poitem ON (voitem_poitem_id=poitem_id) \n LEFT OUTER JOIN vohead ON (voitem_vohead_id=vohead_id) \n WHERE (voitem_vohead_id=) \n GROUP BY number, taxzone_id, curr_id, tax_curr_id, date, adjTax) head, \n (SELECT SUM(voitemtax.taxhist_tax * -1) AS total_tax \n FROM voitemtax \n LEFT OUTER JOIN voitem ON (taxhist_parent_id = voitem_id) \n WHERE (voitem_vohead_id=)) linetax,\n (SELECT SUM(taxhist_tax * -1) AS adjtaxamt \n FROM vohead \n LEFT OUTER JOIN voheadtax ON (taxhist_parent_id = vohead_id \n AND taxhist_taxtype_id = getadjustmenttaxtypeid()) \n WHERE vohead_id=) adjtax;\n;\n admin 2015-10-01 0 104 taxHistory detail \n---------BEGIN SUMMARY----------\n Notes:\n Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: taxHistory\n-- Name: detail\n-- Notes:\n-----------BEGIN SUMMARY----------\n-- Notes:\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT , \n _descrip AS description, \n SUM(salesbase) AS salesbase,\n SUM(freightbase) AS freightbase, \n CASE WHEN (SUM(freighttax) > 0) THEN true ELSE false END AS freighttax, \n SUM(salestaxbase) AS salestaxbase,\n SUM(purchasebase) AS purchasebase,\n SUM(purchasetaxbase) * -1 AS purchasetaxbase, \n SUM(salestaxbase) + SUM(purchasetaxbase) AS nettaxbase,\n 'curr' AS salesbase_xtnumericrole,\n 'curr' AS freightbase_xtnumericrole,\n 'curr' AS salestaxbase_xtnumericrole,\n 'curr' AS purchasebase_xtnumericrole,\n 'curr' AS purchasetaxbase_xtnumericrole,\n 'curr' AS nettaxbase_xtnumericrole,\n 0 AS salestaxbase_xttotalrole,\n 0 AS purchasetaxbase_xttotalrole,\n 0 AS nettaxbase_xttotalrole\nFROM (\n\n------------END SUMMARY--------------\n\n------------BEGIN SALES--------------\n-- All sales tax history including memos \nSELECT \n COALESCE(taxpay_distdate, taxhist_distdate) AS taxhist_distdate,\n taxhist_journalnumber, tax_code AS tax, tax_descrip,\n COALESCE(taxtype_name,) AS taxtype, taxtype_descrip,\n COALESCE(taxclass_code,) AS taxclass, taxclass_descrip,\n COALESCE(taxauth_code,) AS taxauth, taxauth_name AS taxauth_descrip,\n COALESCE(taxzone_code,) AS taxzone, taxzone_descrip, curr_abbr, \n cohist_invcnumber AS docnumber, \n AS source,\n CASE\n WHEN (cohist_doctype='I') THEN\n \n WHEN (cohist_doctype='C') THEN\n \n WHEN (cohist_doctype='D') THEN\n \n ELSE\n \n END AS doctype,\n item_number, COALESCE(item_descrip1,cohist_misc_descrip) AS description,\n CASE\n WHEN (cohist_doctype != 'C') THEN\n cohist_ordernumber \n END AS ordernumber, cohist_invcdate AS docdate,\n cust_name AS name,\n cohist_qtyshipped AS qty, \n cohist_unitprice AS unitprice, (cohist_qtyshipped * cohist_unitprice) AS amount,\n CASE\n WHEN (cohist_misc_type IS NULL OR cohist_misc_type IN ('M','F')) THEN\n currToBase(cohist_curr_id, cohist_qtyshipped * cohist_unitprice, cohist_invcdate) \n ELSE 0\n END AS salesbase,\n CASE\n WHEN (cohist_misc_type = 'F') THEN\n currToBase(cohist_curr_id, cohist_qtyshipped * cohist_unitprice, cohist_invcdate) \n ELSE 0\n END AS freightbase,\n CASE\n WHEN (cohist_misc_type = 'F') THEN\n COALESCE(taxpay_tax, taxhist_tax) / taxhist_curr_rate\n ELSE 0\n END AS freighttax,\n 0 AS purchasebase,\n COALESCE(taxpay_tax, taxhist_tax) AS taxlocal,\n COALESCE(taxpay_tax, taxhist_tax) / taxhist_curr_rate AS taxbase,\n COALESCE(taxpay_tax, taxhist_tax) / taxhist_curr_rate AS salestaxbase,\n 0 AS purchasetaxbase,\n 'qty' AS qty_xtnumericrole,\n 'saleprice' AS unitprice_xtnumericrole,\n 'extprice' AS amount_xtnumericrole,\n 'curr' AS taxhist_tax_xtnumericrole,\n 'curr' AS taxbase_xtnumericrole,\n 0 AS taxbase_xttotalrole\nFROM cohisttax\n JOIN cohist ON (cohist_id=taxhist_parent_id)\n JOIN custinfo ON (cohist_cust_id=cust_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (cohist_taxzone_id=taxzone_id)\n LEFT OUTER JOIN itemsite ON (cohist_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id=item_id)\n LEFT OUTER JOIN taxpay ON (taxpay_taxhist_id=taxhist_id)\nWHERE ((true)\n\n AND (taxhist_distdate BETWEEN \n AND )\n\n AND (taxhist_docdate BETWEEN \n AND )\n\n\n AND (taxhist_tax_id=)\n\n\n AND (taxhist_taxtype_id=)\n\n\n AND (taxclass_id=)\n\n\n AND (taxauth_id=)\n\n\n AND (taxzone_id=)\n\n\n AND (taxpay_id IS NOT NULL)\n\n)\n\n--------------END SALES--------------------\n\n\n-- Union because sales and purchase shown together\nUNION ALL\n\n\n------------BEGIN PURCHASE----------------\n\n-- A/P Memo history\nSELECT \n COALESCE(taxpay_distdate, taxhist_distdate) AS taxhist_distdate,\n taxhist_journalnumber, tax_code AS tax, tax_descrip,\n COALESCE(taxtype_name,) AS taxtype, taxtype_descrip,\n COALESCE(taxclass_code,) AS taxclass, taxclass_descrip,\n COALESCE(taxauth_code,) AS taxauth, taxauth_name AS taxauth_descrip,\n AS taxzone,'' AS taxzone_descrip, curr_abbr, \n apopen_docnumber AS docnumber, \n AS source,\n CASE\n WHEN (apopen_doctype='C') THEN\n \n WHEN (apopen_doctype='D') THEN\n \n ELSE\n \n END AS doctype,\n '' AS item_number, apopen_notes AS description,\n apopen_ponumber AS ordernumber, apopen_docdate AS docdate,\n vend_name AS name, \n 1 AS qty, \n apopen_amount AS unitprice, \n apopen_amount - ABS(COALESCE(taxpay_tax, taxhist_tax)) AS amount,\n 0 AS salesbase,\n 0 AS freightbase,\n 0 AS freighttax,\n (apopen_amount / apopen_curr_rate) - ABS(COALESCE(taxpay_tax, taxhist_tax) / taxhist_curr_rate) AS purchasebase,\n COALESCE(taxpay_tax, taxhist_tax) AS taxlocal,\n COALESCE(taxpay_tax, taxhist_tax) / taxhist_curr_rate AS taxbase,\n 0 AS salestaxbase,\n COALESCE(taxpay_tax, taxhist_tax) / taxhist_curr_rate AS purchasetaxbase,\n 'qty' AS qty_xtnumericrole,\n 'purchaseprice' AS unitprice_xtnumericrole,\n 'extprice' AS extension_xtnumericrole,\n 'curr' AS taxhist_tax_xtnumericrole,\n 'curr' AS taxbase_xtnumericrole,\n 0 AS taxbase_xttotalrole\nFROM apopentax\n JOIN apopen ON (apopen_id=taxhist_parent_id)\n JOIN vendinfo ON (apopen_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxpay ON (taxpay_taxhist_id=taxhist_id)\nWHERE ((true)\n\n AND (taxhist_distdate BETWEEN \n AND )\n\n AND (taxhist_docdate BETWEEN \n AND )\n\n\n AND (taxhist_tax_id=)\n\n\n AND (taxhist_taxtype_id=)\n\n\n AND (taxclass_id=)\n\n\n AND (taxauth_id=)\n\n\n AND (false)\n\n AND (taxhist_distdate IS NOT NULL)\n\n AND (taxpay_id IS NOT NULL)\n\n)\nUNION ALL\n--Voucher Header History\nSELECT \n COALESCE(taxpay_distdate, taxhist_distdate) AS taxhist_distdate,\n taxhist_journalnumber, tax_code AS tax, tax_descrip,\n COALESCE(taxtype_name,) AS taxtype, taxtype_descrip,\n COALESCE(taxclass_code,) AS taxclass, taxclass_descrip,\n COALESCE(taxauth_code,) AS taxauth, taxauth_name AS taxauth_descrip,\n COALESCE(taxzone_code,) AS taxzone, taxzone_descrip, curr_abbr, \n vohead_number AS docnumber, \n AS source,\n AS doctype,\n '', vohead_notes AS description,\n pohead_number AS ordernumber, vohead_docdate AS docdate,\n vend_name AS name, \n 1 AS qty, \n 0 AS unitprice, \n vohead_amount - ABS(COALESCE(taxpay_tax, taxhist_tax)) AS amount,\n 0 AS salesbase,\n 0 AS freightbase,\n 0 AS freighttax,\n (vohead_amount / taxhist_curr_rate) - ABS(COALESCE(taxpay_tax, taxhist_tax) / taxhist_curr_rate) AS purchasebase,\n COALESCE(taxpay_tax, taxhist_tax) AS taxlocal,\n COALESCE(taxpay_tax, taxhist_tax) / taxhist_curr_rate AS taxbase,\n 0 AS salestaxbase,\n COALESCE(taxpay_tax, taxhist_tax) / taxhist_curr_rate AS purchasetaxbase,\n 'qty' AS qty_xtnumericrole,\n 'purchaseprice' AS unitprice_xtnumericrole,\n 'extprice' AS amount_xtnumericrole,\n 'curr' AS taxhist_tax_xtnumericrole,\n 'curr' AS taxbase_xtnumericrole,\n 0 AS taxbase_xttotalrole\nFROM voheadtax\n JOIN vohead ON (vohead_id=taxhist_parent_id)\n LEFT OUTER JOIN pohead ON (vohead_pohead_id=pohead_id)\n JOIN vendinfo ON (vohead_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (vohead_taxzone_id=taxzone_id)\n LEFT OUTER JOIN taxpay ON (taxpay_taxhist_id=taxhist_id)\nWHERE ((true)\n\n AND (taxhist_distdate BETWEEN \n AND )\n\n AND (taxhist_docdate BETWEEN \n AND )\n\n\n AND (taxhist_tax_id=)\n\n\n AND (taxhist_taxtype_id=)\n\n\n AND (taxclass_id=)\n\n\n AND (taxauth_id=)\n\n\n AND (taxzone_id=)\n\n AND (taxhist_distdate IS NOT NULL)\n\n AND (taxpay_id IS NOT NULL)\n\n)\nUNION ALL\n--Voucher Line Item\nSELECT \n COALESCE(taxpay_distdate, taxhist_distdate) AS taxhist_distdate,\n taxhist_journalnumber, tax_code AS tax, tax_descrip,\n COALESCE(taxtype_name,) AS taxtype, taxtype_descrip,\n COALESCE(taxclass_code,) AS taxclass, taxclass_descrip,\n COALESCE(taxauth_code,) AS taxauth, taxauth_name AS taxauth_descrip,\n COALESCE(taxzone_code,) AS taxzone, taxzone_descrip, curr_abbr, \n vohead_number AS docnumber, \n AS source,\n AS doctype,\n COALESCE(item_number,expcat_code), COALESCE(item_descrip1,expcat_descrip) AS description,\n pohead_number AS ordernumber, vohead_docdate AS docdate,\n vend_name AS name, \n voitem_qty AS qty, \n COALESCE(SUM(vodist_amount),0)/voitem_qty AS unitprice, COALESCE(SUM(vodist_amount),0) AS amount,\n 0 AS salesbase,\n 0 AS freightbase,\n 0 AS freighttax,\n currToBase(vohead_curr_id, COALESCE(SUM(vodist_amount),0), vohead_distdate) AS purchasebase,\n COALESCE(taxpay_tax, taxhist_tax) AS taxlocal,\n COALESCE(taxpay_tax, taxhist_tax) / taxhist_curr_rate AS taxbase,\n 0 AS salestaxbase,\n COALESCE(taxpay_tax, taxhist_tax) / taxhist_curr_rate AS purchasetaxbase,\n 'qty' AS qty_xtnumericrole,\n 'purchaseprice' AS unitprice_xtnumericrole,\n 'extprice' AS amount_xtnumericrole,\n 'curr' AS taxhist_tax_xtnumericrole,\n 'curr' AS taxbase_xtnumericrole,\n 0 AS taxbase_xttotalrole\nFROM voitemtax\n JOIN voitem ON (voitem_id=taxhist_parent_id)\n JOIN vohead ON (vohead_id=voitem_vohead_id)\n JOIN pohead ON (vohead_pohead_id=pohead_id)\n JOIN poitem ON (voitem_poitem_id=poitem_id)\n JOIN vodist ON ((vodist_poitem_id=poitem_id)\n AND (vodist_vohead_id=vohead_id))\n JOIN vendinfo ON (vohead_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (vohead_taxzone_id=taxzone_id)\n LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id=item_id)\n LEFT OUTER JOIN expcat ON (expcat_id=poitem_expcat_id)\n LEFT OUTER JOIN taxpay ON (taxpay_taxhist_id=taxhist_id)\nWHERE ((true)\n\n AND (taxhist_distdate BETWEEN \n AND )\n\n AND (taxhist_docdate BETWEEN \n AND )\n\n\n AND (taxhist_tax_id=)\n\n\n AND (taxhist_taxtype_id=)\n\n\n AND (taxclass_id=)\n\n\n AND (taxauth_id=)\n\n\n AND (taxzone_id=)\n\n AND (taxhist_distdate IS NOT NULL)\n\n AND (taxpay_id IS NOT NULL)\n\n)\nGROUP BY taxhist_id, taxpay_distdate,taxhist_distdate,tax_code,tax_descrip,\n taxtype_name,taxtype_descrip,taxclass_code,taxclass_descrip,\n taxauth_code,taxauth_descrip,taxzone,taxzone_descrip,curr_abbr,\n vohead_number,pohead_number,item_number,item_descrip1,\n vohead_curr_id,vohead_distdate,vohead_docdate,vend_name,\n expcat_code,expcat_descrip,taxhist_tax,taxhist_curr_rate,\n voitem_qty, taxhist_journalnumber, taxpay_tax\n\n-------------END PURCHASE--------------\nORDER BY docdate DESC, docnumber DESC\n\n\n) AS data\nGROUP BY , _descrip\nORDER BY \n\n\n admin 2015-10-01 0 290 timePhasedAvailability detail used by dspTimePhasedAvailability\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timePhasedAvailability\n-- Name: detail\n-- Notes: used by dspTimePhasedAvailability\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, itemtype,\n item_number, uom_name, warehous_code,\n reorderlevel \n \n , bucket_,\n 'qty' AS bucket__xtnumericrole,\n CASE WHEN (bucket_ < reorderlevel) THEN 'error' END AS bucket__qtforegroundrole \n \n FROM (SELECT itemsite_id,\n CASE WHEN (item_type IN ('F', 'B', 'C', 'Y', 'R')) THEN 0\n WHEN (item_type IN ('M')) THEN 1\n WHEN (item_type IN ('P', 'O')) THEN 2\n ELSE 0\n END AS itemtype,\n item_number, uom_name, warehous_code,\n CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel \n\n \n , qtyAvailable(itemsite_id, findPeriodStart()) AS bucket_ \n \n FROM itemsite, item, whsinfo, uom\n WHERE ((itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id) \n AND (itemsite_warehous_id=warehous_id) \n \n AND (itemsite_warehous_id=) \n \n \n AND (itemsite_plancode_id=)\n \n AND (itemsite_plancode_id IN (SELECT plancode_id FROM plancode WHERE (plancode_code ~ )))\n \n )) AS data\n ORDER BY item_number;\n admin 2015-10-01 0 291 timePhasedBookings detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timePhasedBookings\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n\n cust_id, cust_number, cust_name, \n\n prodcat_id, prodcat_code, prodcat_descrip,\n\n item_id, item_number, item_descrip1,\n\n uom, warehous_code\n-- Loop through each period bucket to find bookings for period\n\n , SUM(CASE WHEN (cohead_orderdate BETWEEN findPeriodStart() AND findPeriodEnd()) THEN\n amount ELSE 0 END) AS bucket_,\n \n 'curr' AS bucket__xtnumericrole, \n 0 AS bucket__xttotalrole\n \n 'qty' AS bucket__xtnumericrole, \n 0 AS bucket__xttotalrole \n \n\nFROM ( \n SELECT cohead_orderdate,\n\n cust_id, cust_number, cust_name\n\n prodcat_id, prodcat_code, prodcat_descrip\n\n item_id, item_number, item_descrip1\n\n , warehous_code\n\n , round((coitem_qtyord * coitem_qty_invuomratio) * (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) AS amount\n , ::text AS uom\n\n , coitem_qtyord\n \n * itemcapinvrat(itemsite_item_id)\n \n * itemaltcapinvrat(itemsite_item_id)\n \n AS amount\n \n , uom_name AS uom\n \n , itemcapuom(item_id) AS uom\n \n , itemaltcapuom(item_id) AS uom\n \n\n FROM coitem\n JOIN cohead ON (coitem_cohead_id=cohead_id)\n JOIN itemsite ON (coitem_itemsite_id=itemsite_id)\n JOIN item ON (itemsite_item_id=item_id)\n\n JOIN uom ON (item_inv_uom_id=uom_id)\n\n JOIN site() ON (itemsite_warehous_id=warehous_id)\n\n JOIN custinfo ON (cohead_cust_id=cust_id)\n \n\n JOIN prodcat ON (item_prodcat_id=prodcat_id)\n\n WHERE ((coitem_status != 'X')\n AND (cohead_orderdate BETWEEN \n\n \n findPeriodStart()\n \n \n AND findPeriodEnd()\n \n)\n \n AND (item_id=)\n\n \n AND (cust_id=)\n\n \n AND (cust_custtype_id=)\n\n\n AND (cust_custtype_id IN (SELECT custtype_id \n FROM custtype \n WHERE (custtype_code ~ )))\n\n \n AND (item_prodcat_id=) \n\n\n AND (item_prodcat_id IN (SELECT prodcat_id \n FROM prodcat \n WHERE (prodcat_code ~ )))\n\n \n AND(itemsite_warehous_id=) \n\n )) data\nGROUP BY\n\n cust_id, cust_number, cust_name, \n\n prodcat_id, prodcat_code, prodcat_descrip,\n\n item_id, item_number, item_descrip1,\n\n uom, warehous_code\nORDER BY \n\n cust_number,\n\n prodcat_code,\n\n item_number,\n\n uom, warehous_code;\n admin 2015-10-01 0 454 uiforms detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: uiforms\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT uiform_id, uiform_name, uiform_enabled,\n firstline(uiform_notes) AS uiform_notes, uiform_order,\n CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n CASE nspname WHEN 'public' THEN 0\n ELSE 1 END AS xtindentrole,\n uiform_notes AS uiform_notes_qttooltiprole\n FROM uiform\n JOIN pg_class ON (uiform.tableoid=pg_class.oid)\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nUNION \nSELECT -1, pkghead_name, NULL,\n firstline(pkghead_descrip), NULL,\n pkghead_name, 0, pkghead_descrip\n FROM uiform, pg_class, pg_namespace\n RIGHT OUTER JOIN pkghead ON (nspname=pkghead_name) \n WHERE ((uiform.tableoid=pg_class.oid)\n AND (relnamespace=pg_namespace.oid))\n ORDER BY pkgname, xtindentrole, uiform_name,\n uiform_order, uiform_id;\n\nSELECT uiform_id, uiform_name, uiform_enabled,\n firstline(uiform_notes) AS uiform_notes,\n uiform_order,\n CASE nspname WHEN 'public' THEN '' ELSE nspname END AS pkgname,\n uiform_notes AS uiform_notes_qttooltiprole\n FROM uiform\n JOIN pg_class ON (uiform.tableoid=pg_class.oid)\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nORDER BY uiform_name, uiform_order, uiform_id;\n\n admin 2015-10-01 0 298 unbalancedQOHByClassCode detail used by dspUnbalancedQOHByClassCode\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: unbalancedQOHByClassCode\n-- Name: detail\n-- Notes: used by dspUnbalancedQOHByClassCode\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT itemsite_id, warehous_code, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescrip, uom_name,\n itemsite_qtyonhand,\n detailedQOH(itemsite_id, FALSE) AS detailedqoh,\n 'qty' AS itemsite_qtyonhand_xtnumericrole,\n 'qty' AS detailedqoh_xtnumericrole\nFROM whsinfo, item, itemsite, uom\nWHERE ( (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_warehous_id=warehous_id)\n AND ((itemsite_loccntrl) OR (itemsite_controlmethod IN ('L', 'S')))\n AND (itemsite_qtyonhand <> detailedQOH(itemsite_id, FALSE))\n\n AND (item_classcode_id=)\n\n AND (item_classcode_id IN (SELECT classcode_id\n FROM classcode\n WHERE (classcode_code ~ )))\n\n\n AND (warehous_id=)\n\n )\nORDER BY item_number;\n admin 2015-10-01 0 299 undefinedManufacturedItems detail used by dspUndefinedManufacturedItems\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: undefinedManufacturedItems\n-- Name: detail\n-- Notes: used by dspUndefinedManufacturedItems\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT item_id, 2, item_number, (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n item_type, item_active, AS exception\nFROM item\nWHERE ((item_type IN ('M', 'F'))\n AND (item_id NOT IN (SELECT DISTINCT bomitem_parent_item_id\n FROM bomitem))\n\n AND (item_active)\n\n )\nORDER BY item_number;\n admin 2015-10-01 0 300 uninvoicedReceivings detail used by dspUninvoicedReceivings\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: uninvoicedReceivings\n-- Name: detail\n-- Notes: used by dspUninvoicedReceivings\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT recv_id AS id,\n CASE WHEN(poitem_status='C') THEN 2\n ELSE 1\n END AS doctype,\n recv_date AS thedate,\n recv_trans_usr_name AS f_user,\n recv_order_number AS ponumber, poitem_linenumber,\n vend_name,\n COALESCE(item_number,\n ('Misc. - ' || recv_vend_item_number)) AS itemnumber,\n recv_qty AS qty, 'qty' AS qty_xtnumericrole,\n 'Receipt' AS type,\n recv_value AS value,\n 'curr' AS value_xtnumericrole, 0 AS value_xttotalrole\nFROM recv, vendinfo,\n poitem LEFT OUTER JOIN (itemsite JOIN item ON (itemsite_item_id=item_id))\n ON (poitem_itemsite_id=itemsite_id)\nWHERE ((recv_orderitem_id=poitem_id)\n AND (recv_order_type='PO')\n AND (recv_vend_id=vend_id)\n AND (recv_posted)\n AND (recv_vohead_id IS NULL)\n AND (NOT recv_invoiced)\n\n AND (itemsite_warehous_id=)\n\n\n AND (recv_agent_username=)\n\n )\n\nUNION\n\nSELECT poreject_id AS id,\n 3 AS doctype,\n poreject_date AS thedate,\n poreject_trans_username AS f_user,\n poreject_ponumber AS ponumber, poitem_linenumber,\n vend_name,\n COALESCE(item_number,\n ('Misc. - ' || poreject_vend_item_number)) AS itemnumber,\n poreject_qty, 'qty' AS qty_xtnumericrole,\n 'Return' AS type,\n poreject_value * -1 AS value,\n 'curr' AS value_xtnumericrole, 0 AS value_xtotalrole\nFROM poreject, vendinfo,\n poitem LEFT OUTER JOIN (itemsite JOIN item ON (itemsite_item_id=item_id))\n ON (poitem_itemsite_id=itemsite_id)\nWHERE ((poreject_poitem_id=poitem_id)\n AND (poreject_vend_id=vend_id)\n AND (poreject_posted)\n AND (NOT poreject_invoiced)\n\n AND (itemsite_warehous_id=)\n\n\n AND (poreject_agent_username=)\n\n )\nORDER BY ponumber, poitem_linenumber;\n admin 2015-10-01 0 460 uninvoicedShipments detail used by uninvoicedShipments\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: uninvoicedShipments\n-- Name: detail\n-- Notes: used by uninvoicedShipments\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cohead_id, shipitem_id, cohead_number, coitem_linenumber,\n cust_number, cust_name,\n item_number, description,\n uom_name, shipped, selected,\n CASE WHEN (level=0) THEN cohead_number\n ELSE CAST(coitem_linenumber AS TEXT)\n END AS orderline,\n CASE WHEN (level=0) THEN cust_number\n ELSE item_number\n END AS custitem,\n CASE WHEN (level=0) THEN cust_name\n ELSE description\n END AS custdescrip,\n 'qty' AS shipped_xtnumericrole,\n 'qty' AS selected_xtnumericrole,\n level AS xtindentrole\nFROM (\nSELECT cohead_id, -1 AS shipitem_id, cohead_number, -1 AS coitem_linenumber, 0 AS level,\n cust_number, cust_name,\n '' AS item_number, '' AS description,\n '' AS uom_name,\n COALESCE(SUM(shipitem_qty), 0) AS shipped,\n COALESCE(SUM(cobill_qty), 0) AS selected\nFROM cohead, custinfo, itemsite, item, whsinfo, shipitem, shiphead, uom,\n coitem LEFT OUTER JOIN\n ( cobill JOIN cobmisc\n ON ( (cobill_cobmisc_id=cobmisc_id) AND (NOT cobmisc_posted) ) )\n ON (cobill_coitem_id=coitem_id)\nWHERE ( (cohead_cust_id=cust_id)\n AND (shipitem_orderitem_id=coitem_id)\n AND (shipitem_shiphead_id=shiphead_id)\n AND (shiphead_order_type='SO')\n AND (coitem_cohead_id=cohead_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (coitem_qty_uom_id=uom_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (shiphead_shipped)\n AND (NOT shipitem_invoiced)\n\n AND (itemsite_warehous_id=)\n\n )\nGROUP BY cohead_id, cohead_number, cust_number, cust_name\n\nUNION\nSELECT cohead_id, shipitem_id, cohead_number, coitem_linenumber, 1 AS level,\n cust_number, cust_name,\n item_number, (item_descrip1 || ' ' || item_descrip2) AS description,\n uom_name,\n COALESCE(SUM(shipitem_qty), 0) AS shipped,\n COALESCE(SUM(cobill_qty), 0) AS selected\nFROM cohead, custinfo, itemsite, item, whsinfo, shipitem, shiphead, uom,\n coitem LEFT OUTER JOIN\n ( cobill JOIN cobmisc\n ON ( (cobill_cobmisc_id=cobmisc_id) AND (NOT cobmisc_posted) ) )\n ON (cobill_coitem_id=coitem_id)\nWHERE ( (cohead_cust_id=cust_id)\n AND (shipitem_orderitem_id=coitem_id)\n AND (shipitem_shiphead_id=shiphead_id)\n AND (shiphead_order_type='SO')\n AND (coitem_cohead_id=cohead_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (coitem_qty_uom_id=uom_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (shiphead_shipped)\n AND (NOT shipitem_invoiced)\n\n AND (itemsite_warehous_id=)\n\n )\nGROUP BY cohead_number, cust_number, cust_name,\n coitem_id, coitem_linenumber, item_number,\n item_descrip1, item_descrip2, cohead_id, shipitem_id, uom_name\n \n ) AS data\n\n\n WHERE (selected = 0)\n\n\nORDER BY cohead_number DESC, level, coitem_linenumber DESC;\n admin 2015-10-01 0 88 unpostedCashReceipts detail Used by arWorkBench, cashReceiptsEditList\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: unpostedCashReceipts\n-- Name: detail\n-- Notes: Used by arWorkBench, cashReceiptsEditList\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT\n cashrcpt_id, \n cashrcpt_number,\n cust_number,\n cust_name,\n cashrcpt_docnumber, \n bankaccnt_name,\n cashrcpt_distdate,\n cashrcpt_amount, \n currConcat(cashrcpt_curr_id) AS currabbr,\n CASE\n WHEN (cashrcpt_fundstype ='C') THEN \n WHEN (cashrcpt_fundstype ='T') THEN \n WHEN (cashrcpt_fundstype ='M') THEN \n WHEN (cashrcpt_fundstype ='V') THEN \n WHEN (cashrcpt_fundstype ='A') THEN \n WHEN (cashrcpt_fundstype ='D') THEN \n WHEN (cashrcpt_fundstype ='O') THEN \n WHEN (cashrcpt_fundstype ='K') THEN \n WHEN (cashrcpt_fundstype ='W') THEN \n WHEN (cashrcpt_fundstype ='R') THEN \n END AS cashrcpt_fundstype,\n 'curr' AS cashrcpt_amount_xtnumericrole \nFROM cashrcpt, bankaccnt, custinfo\n\n JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n JOIN custgrp ON (custgrp_id=custgrpitem_custgrp_id)\n\n, custtype\nWHERE ( (NOT cashrcpt_posted)\n AND (NOT cashrcpt_void)\n AND (cashrcpt_bankaccnt_id=bankaccnt_id)\n AND (cashrcpt_cust_id=cust_id)\n AND (cust_custtype_id=custtype_id)\n\n AND (cashrcpt_cust_id=)\n\n\n AND (custgrp_id=)\n\n\n AND (custtype_id=)\n\n\n AND (custtype_code~)\n\n)\nORDER BY cashrcpt_distdate;\n\n admin 2015-10-01 0 89 unpostedReceipts detail used by unpostedPoReceipts\n-------PURCHASE ORDERS----------\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: unpostedReceipts\n-- Name: detail\n-- Notes: used by unpostedPoReceipts\n---------PURCHASE ORDERS----------\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT recv_id, recv_orderitem_id, recv_order_number, recv_order_type,\n vend_name AS orderhead_from,\n poitem_linenumber AS orderitem_linenumber,\n formatDate(recv_duedate) AS recv_duedate,\n warehous_code,\n COALESCE(item_number, ) AS item_number,\n COALESCE(uom_name, ) AS uom_name,\n recv_vend_item_number,\n recv_vend_uom,\n poitem_qty_ordered AS orderitem_qty_ordered, \n poitem_qty_received AS orderitem_qty_received,\n recv_qty, recv_date,\n COALESCE(recv_gldistdate, recv_date) AS recv_gldistdate,\n 'qty' AS orderitem_qty_ordered_xtnumericrole,\n 'qty' AS orderitem_qty_received_xtnumericrole,\n 'qty' AS recv_qty_xtnumericrole\nFROM pohead JOIN\n poitem ON (poitem_pohead_id=pohead_id) JOIN \n recv ON ((recv_orderitem_id=poitem_id)\n\t AND (recv_order_type='PO')) LEFT OUTER JOIN\n (itemsite JOIN item ON (itemsite_item_id=item_id)\n\t JOIN uom ON (item_inv_uom_id=uom_id)\n JOIN site() ON (itemsite_warehous_id=warehous_id)\n )\n ON (recv_itemsite_id=itemsite_id) JOIN\n vendinfo ON (pohead_vend_id=vend_id)\nWHERE (NOT recv_posted)\n\n-------RETURN AUTHORIZATIONS--------------\nUNION\nSELECT recv_id, recv_orderitem_id, recv_order_number, recv_order_type,\n cust_name AS orderhead_from,\n raitem_linenumber AS orderitem_linenumber,\n formatDate(recv_duedate) AS recv_duedate,\n warehous_code,\n COALESCE(item_number, ) AS item_number,\n COALESCE(uom_name, ) AS uom_name,\n recv_vend_item_number,\n recv_vend_uom,\n raitem_qtyauthorized AS orderitem_qty_ordered, \n raitem_qtyreceived AS orderitem_qty_received,\n recv_qty, recv_date,\n COALESCE(recv_gldistdate, recv_date) AS recv_gldistdate,\n 'qty' AS orderitem_qty_ordered_xtnumericrole,\n 'qty' AS orderitem_qty_received_xtnumericrole,\n 'qty' AS recv_qty_xtnumericrole\nFROM rahead JOIN\n raitem ON (raitem_rahead_id=rahead_id) JOIN \n recv ON ((recv_orderitem_id=raitem_id)\n\t AND (recv_order_type='RA')) LEFT OUTER JOIN\n (itemsite JOIN item ON (itemsite_item_id=item_id)\n\t JOIN uom ON (item_inv_uom_id=uom_id)\n JOIN site() ON (itemsite_warehous_id=warehous_id)\n )\n ON (recv_itemsite_id=itemsite_id) LEFT OUTER JOIN\n custinfo ON (rahead_cust_id=cust_id)\nWHERE (NOT recv_posted)\n\n\n------TRANSFER ORDERS---------\nUNION\nSELECT recv_id, recv_orderitem_id, recv_order_number, recv_order_type,\n tohead_srcname AS orderhead_from,\n toitem_linenumber AS orderitem_linenumber,\n formatDate(recv_duedate) AS recv_duedate,\n warehous_code,\n COALESCE(item_number, ) AS item_number,\n COALESCE(uom_name, ) AS uom_name,\n recv_vend_item_number,\n recv_vend_uom,\n toitem_qty_ordered AS orderitem_qty_ordered, \n toitem_qty_received AS orderitem_qty_received,\n recv_qty, recv_date,\n COALESCE(recv_gldistdate, recv_date) AS recv_gldistdate,\n 'qty' AS orderitem_qty_ordered_xtnumericrole,\n 'qty' AS orderitem_qty_received_xtnumericrole,\n 'qty' AS recv_qty_xtnumericrole\nFROM tohead JOIN\n toitem ON (toitem_tohead_id=tohead_id) JOIN \n recv ON ((recv_orderitem_id=toitem_id)\n\t AND (recv_order_type='TO')) LEFT OUTER JOIN\n (itemsite JOIN item ON (itemsite_item_id=item_id)\n\t JOIN uom ON (item_inv_uom_id=uom_id)\n JOIN site() ON (itemsite_warehous_id=warehous_id)\n )\n ON (recv_itemsite_id=itemsite_id) \nWHERE (NOT recv_posted)\n\nORDER BY recv_order_number, orderitem_linenumber;\n admin 2015-10-01 0 301 unusedPurchasedItems detail used by dspUnusedPurchasedItems.cpp\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: unusedPurchasedItems\n-- Name: detail\n-- Notes: used by dspUnusedPurchasedItems.cpp\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT DISTINCT item_id, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescrip, uom_name,\n SUM(itemsite_qtyonhand) AS qoh,\n MAX(itemsite_datelastcount) AS lastcount,\n MAX(itemsite_datelastused) AS lastused,\n 'qty' AS qoh_xtnumericrole,\n CASE WHEN (COALESCE(MAX(itemsite_datelastcount), startOfTime()) = startOfTime()) THEN 'Never' END AS lastcount_qtdisplayrole,\n CASE WHEN (COALESCE(MAX(itemsite_datelastused), startOfTime()) = startOfTime()) THEN 'Never' END AS lastused_qtdisplayrole \nFROM item, itemsite, uom \nWHERE ((itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (item_id NOT IN (SELECT DISTINCT bomitem_item_id FROM bomitem))\n AND (NOT item_sold)\n AND (item_type IN ('P', 'O')) \n\n AND (item_classcode_id=) \n\n AND (item_classcode_id IN (SELECT classcode_id FROM classcode WHERE (classcode_code ~ ))) \n\n\n AND (itemsite_controlmethod <> 'N')\n\n) \nGROUP BY item_id, item_number, uom_name, item_descrip1, item_descrip2 \nORDER BY item_number;\n admin 2015-10-01 0 461 uoms item used by item, bomItem, salesOrderItem, invoiceItem, creditMemoItem, woMaterialItem,\n returnAuthorizationItem, itemPricingScheduleItem\n Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: uoms\n-- Name: item\n-- Notes: used by item, bomItem, salesOrderItem, invoiceItem, creditMemoItem, woMaterialItem,\n-- returnAuthorizationItem, itemPricingScheduleItem\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT uom_id, uom_name\n FROM uom\n WHERE(uom_id=)\nUNION\n\n\nSELECT uom_id, uom_name\n FROM uom\n WHERE(uom_id=)\nUNION\n\nSELECT uom_id, uom_name\n FROM item\n JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE(item_id=)\nUNION\nSELECT uom_id, uom_name\n FROM item\n JOIN itemuomconv ON (itemuomconv_item_id=item_id)\n JOIN uom ON (itemuomconv_to_uom_id=uom_id),\n itemuom, uomtype\n WHERE (itemuomconv_from_uom_id=item_inv_uom_id)\n AND (item_id=)\n AND (itemuom_itemuomconv_id=itemuomconv_id)\n AND (uomtype_id=itemuom_uomtype_id)\n AND (itemuomconv_active)\n\n AND (uomtype_name=)\n\nUNION\nSELECT uom_id, uom_name\n FROM item\n JOIN itemuomconv ON (itemuomconv_item_id=item_id)\n JOIN uom ON (itemuomconv_from_uom_id=uom_id),\n itemuom, uomtype\n WHERE (itemuomconv_to_uom_id=item_inv_uom_id)\n AND (item_id=)\n AND (itemuom_itemuomconv_id=itemuomconv_id)\n AND (uomtype_id=itemuom_uomtype_id)\n AND (itemuomconv_active)\n\n AND (uomtype_name=)\n\n ORDER BY uom_name;\n admin 2015-10-01 0 119 updateListPrices update Calculates and immediately updates list prices to the database\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: updateListPrices\n-- Name: update\n-- Notes: Calculates and immediately updates list prices to the database\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE item SET item_listprice=\n\n item_listprice + \n\n item_listprice * (1.0 + ( / 100.0))\n\nWHERE (item_sold)\n\n AND (item_prodcat_id=)\n\n AND (item_prodcat_id IN (SELECT prodcat_id FROM prodcat WHERE (prodcat_code ~ )))\n\n admin 2015-10-01 0 120 updateprices add \n Notes:\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: updateprices\n-- Name: add\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n INSERT INTO selsched\n\n VALUES ();\n\n SELECT ipshead_id\n FROM ipshead\n WHERE ( (ipshead_id NOT IN (\n \tSELECT selsched_ipshead_id\n \tFROM selsched\n \tWHERE (selsched_ipshead_id=ipshead_id)))\n\n AND (ipshead_effective <= CURRENT_DATE)\n\n\n AND (ipshead_expires > CURRENT_DATE)\n\n\n AND (CURRENT_DATE NOT BETWEEN ipshead_effective AND ipshead_expires -1)\n\n );\n\n admin 2015-10-01 0 121 updateprices availsched \n Notes:\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: updateprices\n-- Name: availsched\n-- Notes:\n-- Notes:\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT ipshead_id, ipshead_name, ipshead_descrip,\n ipshead_effective, ipshead_expires,\n CASE WHEN COALESCE(ipshead_effective, startOfTime()) <= startOfTime() THEN \n\t'Always' END AS ipshead_effective_qtdisplayrole,\n CASE WHEN COALESCE(ipshead_expires, endOfTime()) >= endOfTime() THEN \n\t'Never' END AS ipshead_expires_qtdisplayrole\nFROM ipshead\nWHERE ( (ipshead_id NOT IN (\n \tSELECT selsched_ipshead_id\n \tFROM selsched\n \tWHERE (selsched_ipshead_id=ipshead_id)))\n\n AND (ipshead_effective <= CURRENT_DATE)\n\n\n AND (ipshead_expires > CURRENT_DATE)\n\n\n AND (CURRENT_DATE NOT BETWEEN ipshead_effective AND ipshead_expires -1)\n\n )\nORDER BY ipshead_effective, ipshead_name;\n admin 2015-10-01 0 126 updateprices updatechar used by updatePrices\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: updateprices\n-- Name: updatechar\n-- Notes: used by updatePrices\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE ipsitemchar SET\n ipsitemchar_price=\n\n ipsitemchar_price + \n\n roundSale(ipsitemchar_price * (1.0 + ( / 100.0)))\n\nFROM selsched, ipsiteminfo, item\n\n JOIN itemgrpitem ON (itemgrpitem_item_id=item_id)\n JOIN itemgrp ON (itemgrpitem_itemgrp_id=itemgrp_id)\n\n JOIN prodcat ON (prodcat_id=item_prodcat_id)\n\nWHERE ( ipsitemchar_ipsitem_id=ipsitem_id\n AND ipsitem_item_id=item_id\n AND selsched_ipshead_id=ipsitem_ipshead_id\n\n AND item_id=\n\n AND itemgrp_id=\n\n AND itemgrp_name ~ \n\n AND prodcat_id=\n\n AND prodcat_code ~ \n\n);\n admin 2015-10-01 0 90 updateReorderLevels post itemsite with new reorder level\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: updateReorderLevels\n-- Name: post\n-- Notes: itemsite with new reorder level\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE itemsite SET\n itemsite_reorderlevel=,\n itemsite_stocked=CASE WHEN ( = 0) THEN false\n ELSE itemsite_stocked END,\n itemsite_useparams=CASE WHEN ( = 0) THEN false\n ELSE itemsite_useparams END\nWHERE (itemsite_id=)\n admin 2015-10-01 0 91 updateReorderLevels query Calculates reorder point levels and returns a proposed result set\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: updateReorderLevels\n-- Name: query\n-- Notes: Calculates reorder point levels and returns a proposed result set\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n 'qty' AS reordlvl_curr_level_xtnumericrole,\n 'qty' AS reordlvl_total_usage_xtnumericrole\nFROM updateReorderLevel((\n SELECT array(\n SELECT itemsite_id\n FROM itemsite\n JOIN item ON (itemsite_item_id=item_id)\n LEFT OUTER JOIN plancode ON (itemsite_plancode_id=plancode_id)\n LEFT OUTER JOIN classcode ON (item_classcode_id=classcode_id)\n WHERE ( (itemsite_active)\n\n AND (itemsite_warehous_id=)\n\n\n AND (item_id=)\n\n AND (item_classcode_id=)\n\n AND (classcode_code ~ )\n\n AND (itemsite_plancode_id=)\n\n AND (plancode_code ~ )\n\n )\n )\n),\n, \n\n true,\n\n false,\n\n\nARRAY[\n \n \n ,\n \n \n ]\n)\nORDER BY reordlvl_warehous_code, reordlvl_item_number;\n admin 2015-10-01 0 92 updateReorderLevels update Calculates and immediatly updates reorder point levels to the database\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: updateReorderLevels\n-- Name: update\n-- Notes: Calculates and immediatly updates reorder point levels to the database\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT updateReorderLevel(itemsite_id,, \nARRAY[\n \n \n ,\n \n \n ]\n) AS result\nFROM itemsite\n JOIN item ON (itemsite_item_id=item_id)\n LEFT OUTER JOIN plancode ON (itemsite_plancode_id=plancode_id)\n LEFT OUTER JOIN classcode ON (item_classcode_id=classcode_id)\nWHERE ( (itemsite_active)\n AND (itemsite_useparams)\n\n AND (itemsite_warehous_id=)\n\n\n AND (item_id=)\n\n AND (item_classcode_id=)\n\n AND (classcode_code ~ )\n\n AND (itemsite_plancode_id=)\n\n AND (plancode_code ~ )\n\n)\n admin 2015-10-01 0 134 usageStatistics detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: usageStatistics\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n \n formatQty(transfer) AS f_transfer,\n \n formatQty(received) AS f_received,\n formatQty(issued) AS f_issued,\n formatQty(sold) AS f_sold,\n formatQty(scrap) AS f_scrap,\n formatQty(adjust) AS f_adjust,\n 'qty' AS received_xtnumericrole,\n 'qty' AS issued_xtnumericrole,\n 'qty' AS sold_xtnumericrole,\n 'qty' AS scrap_xtnumericrole,\n 'qty' AS adjust_xtnumericrole,\n 'qty' AS transfer_xtnumericrole\nFROM (\nSELECT itemsite_id, item_id, warehous_code,\n item_number, (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n \n summTransT(itemsite_id, , ) AS transfer,\n \n summTransR(itemsite_id, , ) AS received,\n summTransI(itemsite_id, , ) AS issued,\n summTransS(itemsite_id, , ) AS sold,\n summTransC(itemsite_id, , ) AS scrap,\n summTransA(itemsite_id, , ) AS adjust\nFROM item JOIN itemsite ON (itemsite_item_id=item_id)\n JOIN whsinfo ON (warehous_id=itemsite_warehous_id)\nWHERE (1=1)\n\n\n AND (item_id=)\n\n\n\n AND (itemsite_warehous_id=)\n\n\n\n AND (item_classcode_id=)\n\n AND (item_id IN (SELECT itemgrpitem_item_id\n FROM itemgrpitem\n\t\t WHERE (itemgrpitem_itemgrp_id=)))\n\n AND (itemsite_plancode_id=)\n\n AND (item_classcode_id IN (SELECT classcode_id\n\t\t\t FROM classcode\n\t\t\t WHERE (classcode_code ~ )))\n\n AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t FROM itemgrpitem, itemgrp\n\t\t WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n\t\t AND (itemgrp_name ~ ))))\n\n AND (itemsite_plancode_id IN (SELECT plancode_id\n\t\t\t\tFROM plancode\n\t\t\t\tWHERE (plancode_code ~ )))\n\n AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n\n) AS data\n\nORDER BY warehous_code, item_number;\n admin 2015-10-01 0 302 validLocationsByItem detail used by dspValidLocationsByItem.cpp\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: validLocationsByItem\n-- Name: detail\n-- Notes: used by dspValidLocationsByItem.cpp\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT location_id, warehous_code,\n formatLocationName(location_id) AS locationname,\n firstLine(location_descrip) AS locationdescrip,\n location_restrict, location_netable\nFROM itemsite, location, whsinfo\nWHERE ((validLocation(location_id, itemsite_id))\n AND ((itemsite_loccntrl) OR (itemsite_location_id=location_id))\n AND (itemsite_item_id=)\n AND (itemsite_warehous_id=warehous_id)\n\n AND (warehous_id=)\n\n )\nORDER BY warehous_code, locationname;\n admin 2015-10-01 0 303 vendorAPHistory detail used by dspVendorAPHistory\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: vendorAPHistory\n-- Name: detail\n-- Notes: used by dspVendorAPHistory\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT apopen_id, -1 AS applyid, 0 AS type,\n apopen_docdate AS sortdate, apopen_docnumber AS sortnumber,\n apopen_docnumber AS docnumber,\n formatBoolYN(apopen_open) AS f_open,\n CASE WHEN (apopen_doctype='V') THEN \n WHEN (apopen_doctype='C') THEN \n WHEN (apopen_doctype='D') THEN \n ELSE \n END AS documenttype,\n apopen_invcnumber AS invoicenumber,\n apopen_ponumber AS ponumber,\n apopen_docdate AS docdate, apopen_duedate AS duedate, apopen_amount AS amount,\n (apopen_amount - apopen_paid) AS balance,\n currconcat(apopen_curr_id) AS currAbbr,\n CASE WHEN (apopen_doctype='C') THEN apopen_amount / apopen_curr_rate * -1.0\n ELSE apopen_amount / apopen_curr_rate\n END AS base_amount,\n 0 AS base_applied,\n CASE WHEN (apopen_doctype='C') THEN (apopen_amount - apopen_paid) / apopen_curr_rate * -1.0\n ELSE (apopen_amount - apopen_paid) / apopen_curr_rate\n END AS base_balance,\n 'curr' AS amount_xtnumericrole,\n 'curr' AS base_amount_xtnumericrole,\n 0 AS base_amount_xttotalrole,\n 'curr' AS base_applied_xtnumericrole,\n 0 AS base_applied_xttotalrole,\n 'curr' AS balance_xtnumericrole,\n 'curr' AS base_balance_xtnumericrole,\n 0 AS base_balance_xttotalrole,\n 0 AS xtindentrole \nFROM apopen \nWHERE ( (apopen_vend_id=) \n AND (apopen_docdate BETWEEN AND ) ) \n\nUNION \nSELECT apopen_id, apapply_source_apopen_id AS applyid, 1 AS type,\n apopen_docdate AS sortdate, apopen_docnumber AS sortnumber,\n apapply_source_docnumber AS docnumber,\n '' AS f_open,\n CASE WHEN (apapply_source_doctype='C') THEN \n WHEN (apapply_source_doctype='K') THEN \n ELSE \n END AS documenttype,\n ' ' AS invoicenumber,\n '' AS ponumber,\n apapply_postdate AS docdate, CAST(NULL AS DATE) AS duedate,\n apapply_amount AS amount,\n 0 AS balance,\n currconcat(apapply_curr_id) AS currAbbr,\n 0 AS base_amount,\n (apapply_amount / apopen_curr_rate) AS base_applied, \n 0 AS base_balance,\n 'curr' AS amount_xtnumericrole,\n 'curr' AS base_amount_xtnumericrole,\n 0 AS base_amount_xttotalrole,\n 'curr' AS base_applied_xtnumericrole,\n 0 AS base_applied_xttotalrole,\n 'curr' AS balance_xtnumericrole,\n 'curr' AS base_balance_xtnumericrole,\n 0 AS base_balance_xttotalrole,\n 1 AS xtindentrole \nFROM apapply, apopen \nWHERE ( (apapply_target_apopen_id=apopen_id)\n AND (apapply_vend_id=)\n AND (apopen_vend_id=)\n AND (apopen_docdate BETWEEN AND ) ) \n\nUNION \nSELECT apopen_id, apapply_target_apopen_id AS applyid, 2 AS type,\n apopen_docdate AS sortdate, apopen_docnumber AS sortnumber,\n apapply_target_docnumber AS docnumber,\n '' AS f_open,\n CASE WHEN (apapply_target_doctype='V') THEN \n WHEN (apapply_target_doctype='D') THEN \n ELSE \n END AS documenttype,\n apopen_invcnumber AS invoicenumber,\n '' AS ponumber,\n apapply_postdate AS docdate, CAST(NULL AS DATE) AS duedate,\n apapply_amount AS amount,\n 0 AS balance,\n currconcat(apapply_curr_id) AS currAbbr,\n 0 AS base_amount,\n (apapply_amount / apopen_curr_rate) AS base_applied, \n 0 AS base_balance,\n 'curr' AS amount_xtnumericrole,\n 'curr' AS base_amount_xtnumericrole,\n 0 AS base_amount_xttotalrole,\n 'curr' AS base_applied_xtnumericrole,\n 0 AS base_applied_xttotalrole,\n 'curr' AS balance_xtnumericrole,\n 'curr' AS base_balance_xtnumericrole,\n 0 AS base_balance_xttotalrole,\n 1 AS xtindentrole \nFROM apapply, apopen \nWHERE ( (apapply_source_doctype IN ('C', 'K'))\n AND (apapply_source_doctype=apopen_doctype)\n AND (apapply_source_docnumber=apopen_docnumber)\n AND (apapply_vend_id=)\n AND (apopen_vend_id=)\n AND (apopen_docdate BETWEEN AND ) ) \nORDER BY sortdate, apopen_id, type;\n admin 2015-10-01 0 304 vendors detail \n Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: vendors\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n vend_id, vend_vendtype_id, \n vend_active, vend_number, vend_name,\n vendtype_code,\n\n charass_alias.charass_value AS char,\n\n\n charass_alias.charass_value AS char,\n\n\n charass_alias.charass_value::date AS char,\n\n cntct.*,\n CASE WHEN (cntctaddr.addr_id IS NOT NULL) THEN cntctaddr.addr_id ELSE vendaddr.addr_id END AS addr_id,\n CASE WHEN (cntctaddr.addr_id IS NOT NULL) THEN cntctaddr.addr_active ELSE vendaddr.addr_active END AS addr_active,\n CASE WHEN (cntctaddr.addr_id IS NOT NULL) THEN cntctaddr.addr_line1 ELSE vendaddr.addr_line1 END AS addr_line1,\n CASE WHEN (cntctaddr.addr_id IS NOT NULL) THEN cntctaddr.addr_line2 ELSE vendaddr.addr_line2 END AS addr_line2,\n CASE WHEN (cntctaddr.addr_id IS NOT NULL) THEN cntctaddr.addr_line3 ELSE vendaddr.addr_line3 END AS addr_line3,\n CASE WHEN (cntctaddr.addr_id IS NOT NULL) THEN cntctaddr.addr_city ELSE vendaddr.addr_city END AS addr_city,\n CASE WHEN (cntctaddr.addr_id IS NOT NULL) THEN cntctaddr.addr_state ELSE vendaddr.addr_state END AS addr_state,\n CASE WHEN (cntctaddr.addr_id IS NOT NULL) THEN cntctaddr.addr_postalcode ELSE vendaddr.addr_postalcode END AS addr_postalcode,\n CASE WHEN (cntctaddr.addr_id IS NOT NULL) THEN cntctaddr.addr_country ELSE vendaddr.addr_country END AS addr_country,\n CASE WHEN (cntctaddr.addr_id IS NOT NULL) THEN cntctaddr.addr_notes ELSE vendaddr.addr_notes END AS addr_notes,\n CASE WHEN (cntctaddr.addr_id IS NOT NULL) THEN cntctaddr.addr_number ELSE vendaddr.addr_number END AS addr_number\nFROM vendinfo \n JOIN vendtype ON (vend_vendtype_id=vendtype_id)\n LEFT OUTER JOIN cntct ON (vend_cntct1_id=cntct_id) \n LEFT OUTER JOIN addr AS vendaddr ON (vend_addr_id=vendaddr.addr_id)\n LEFT OUTER JOIN addr AS cntctaddr ON (cntct_addr_id=cntctaddr.addr_id) \n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='V') \n AND (charass_alias.charass_target_id=vend_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='V') \n AND (charass_alias.charass_target_id=vend_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\n\n LEFT OUTER JOIN charass charass_alias \n ON ((charass_alias.charass_target_type='V') \n AND (charass_alias.charass_target_id=vend_id)\n AND (charass_alias.charass_char_id=))\n LEFT OUTER JOIN char char_alias \n ON (charass_alias.charass_char_id=char_alias.char_id)\n\nWHERE true\n \n AND vend_active \n\n\n AND ((vend_number ~* )\n OR (vend_name ~* )\n OR (vendtype_code ~* )\n OR (COALESCE(cntct_first_name,'') || ' ' || COALESCE(cntct_last_name,'') ~* )\n OR (COALESCE(cntct_phone,'') || ' ' || COALESCE(cntct_phone2,'') || ' ' || COALESCE(cntct_fax,'') ~* )\n OR (COALESCE(cntct_email,'') ~* )\n OR (COALESCE(cntctaddr.addr_line1, vendaddr.addr_line1, '') || ' ' || COALESCE(cntctaddr.addr_line2, vendaddr.addr_line2,'') || ' ' || COALESCE(cntctaddr.addr_line3, vendaddr.addr_line3, '') ~* )\n OR (COALESCE(cntctaddr.addr_city, vendaddr.addr_city,'') ~* )\n OR (COALESCE(cntctaddr.addr_state, vendaddr.addr_state,'') ~* )\n OR (COALESCE(cntctaddr.addr_postalcode, vendaddr.addr_postalcode,'') ~* )\n OR (COALESCE(cntctaddr.addr_country, vendaddr.addr_country,'') ~* ))\n\n\n AND (vend_number ~* )\n\n\n AND (vend_name ~* )\n\n\n AND (vendtype_code ~* )\n\n\n AND (COALESCE(cntct_first_name,'') || ' ' || COALESCE(cntct_last_name,'') ~* )\n\n\n AND (COALESCE(cntct_phone,'') || ' ' || COALESCE(cntct_phone2,'') || ' ' || COALESCE(cntct_fax,'') ~* )\n\n\n AND (COALESCE(cntct_email,'') ~* )\n\n\n AND (COALESCE(cntctaddr.addr_line1, vendaddr.addr_line1,'') || ' ' || COALESCE(cntctaddr.addr_line2,vendaddr.addr_line2,'') || ' ' || COALESCE(cntctaddr.addr_line3,vendaddr.addr_line3, '') ~* )\n\n\n AND (COALESCE(cntctaddr.addr_city, vendaddr.addr_city,'') ~* )\n\n\n AND (COALESCE(cntctaddr.addr_state,vendaddr.addr_state,'') ~* )\n\n\n AND (COALESCE(cntctaddr.addr_postalcode,vendaddr.addr_postalcode,'') ~* )\n\n\n AND (COALESCE(cntctaddr.addr_country, vendaddr.addr_country,'') ~* )\n\n\nORDER BY vend_number; \n admin 2015-10-01 0 455 voucher editlist used by voucheringEditList\n indent: order\n line item\n credit account\n line item\n credit account\n debit account for entire order\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: voucher\n-- Name: editlist\n-- Notes: used by voucheringEditList\n-- indent: order\n-- line item\n-- credit account\n-- line item\n-- credit account\n-- debit account for entire order\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT orderid, seq,\n CASE WHEN seq = 0 THEN vouchernumber\n ELSE ''\n END AS vouchernumber, ponumber, itemnumber,\n vendnumber, description, itemtype, iteminvuom, f_qty, cost,\n 'curr' AS cost_xtnumericrole,\n 0 AS cost_xttotalrole,\n CASE WHEN seq = 3 THEN 1\n ELSE seq END AS xtindentrole,\n CASE WHEN findAPAccount(vendid) < 0 THEN 'error'\n END AS qtforegroundrole\nFROM (SELECT orderid,\n CASE WHEN length(ponumber) > 0 THEN 0 ELSE 1 END AS seq,\n vouchernumber, ponumber,\n CASE WHEN (itemid = 1) THEN invoicenumber\n ELSE itemnumber END AS itemnumber,\n CASE WHEN (itemid = 1) THEN itemnumber\n ELSE '' END AS vendnumber,\n vendid, description,\n itemtype, iteminvuom, f_qty, cost\nFROM voucheringEditList\nUNION\n-- pull out the credits\nSELECT DISTINCT orderid, 2 AS seq, vouchernumber, '' AS ponumber,\n AS itemnumber, '' AS vendnumber, vendid,\n account AS description,\n '' AS itemtype, '' AS iteminvuom, NULL as f_qty, cost\nFROM voucheringEditList\nWHERE itemid = 2\nUNION\n-- calculate the debits\nSELECT orderid, 3 AS seq, vouchernumber, '' AS ponumber,\n AS itemnumber, '' AS vendnumber, vendid,\n CASE WHEN findAPAccount(vendid) < 0 THEN \n ELSE formatGLAccountLong(findAPAccount(vendid))\n END AS description,\n '' AS itemtype, '' AS iteminvuom, NULL as f_qty,\n SUM(cost) AS cost\nFROM voucheringEditList\nWHERE itemid = 2\nGROUP BY orderid, vouchernumber, vendid\nORDER BY vouchernumber, ponumber desc, seq) AS sub;\n admin 2015-10-01 0 466 voucherItem distributions used by voucherItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: voucherItem\n-- Name: distributions\n-- Notes: used by voucherItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT vodist_id, vodist_amount,\n COALESCE(costelem_type, ) AS costelem_type,\n 'currval' AS vodist_amount_xtnumericrole\nFROM vodist\n LEFT OUTER JOIN costelem ON (vodist_costelem_id=costelem_id)\nWHERE ( (vodist_poitem_id=)\n AND (vodist_vohead_id=) );\n admin 2015-10-01 0 467 voucherItem receipts used by voucherItem\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: voucherItem\n-- Name: receipts\n-- Notes: used by voucherItem\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT recv_id AS item_id, 1 AS item_type, 'REC' AS action,\n recv_date AS item_date,\n recv_qty AS qty, 'qty' AS qty_xtnumericrole,\n recv_purchcost AS unitprice,\n 'purchprice' AS unitprice_xtnumericrole,\n formatBoolYN(recv_vohead_id=) AS f_tagged,\n AS action_qtdisplayrole,\n 0 AS qty_xttotalrole\nFROM recv\nWHERE ( (NOT recv_invoiced)\n AND (recv_posted)\n AND ((recv_vohead_id IS NULL) OR (recv_vohead_id=))\n AND (recv_order_type='PO')\n AND (recv_orderitem_id=) )\n\nUNION\nSELECT poreject_id AS item_id, 2 AS item_type, 'REJ' AS action,\n poreject_date AS item_date,\n poreject_qty * -1 AS qty, 'qty',\n COALESCE(recv_purchcost, poitem_unitprice) AS unitprice,\n 'purchprice' AS unitprice_xtnumericrole,\n formatBoolYN(poreject_vohead_id=) AS f_tagged,\n AS action_qtdisplayrole,\n 0 AS qty_xttotalrole\nFROM poreject LEFT OUTER JOIN recv ON (recv_id=poreject_recv_id)\n LEFT OUTER JOIN poitem ON (poitem_id=poreject_poitem_id)\nWHERE ( (poreject_posted)\n AND (NOT poreject_invoiced)\n AND ((poreject_vohead_id IS NULL) OR (poreject_vohead_id=))\n AND (poreject_poitem_id=) );\n admin 2015-10-01 0 305 voucherRegister detail used by dspVoucherRegister\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: voucherRegister\n-- Name: detail\n-- Notes: used by dspVoucherRegister\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT gltrans_id, gltrans_date,\n vend_number, vend_name,\n gltrans_doctype, gltrans_docnumber, firstLine(gltrans_notes) AS reference,\n (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n CASE WHEN (gltrans_amount < 0) THEN ABS(gltrans_amount)\n ELSE 0\n END AS debit,\n CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n ELSE 0\n END AS credit,\n gltrans_username,\n 'curr' AS debit_xtnumericrole,\n 'curr' AS credit_xtnumericrole\nFROM accnt, gltrans LEFT OUTER JOIN vohead JOIN vendinfo\n ON (vohead_vend_id=vend_id)\n ON (gltrans_doctype='VO' and gltrans_docnumber=vohead_number)\nWHERE ((gltrans_accnt_id=accnt_id)\n AND (gltrans_date BETWEEN AND )\n AND (gltrans_source='A/P')\n\n AND (gltrans_accnt_id=)\n\n )\nORDER BY gltrans_created DESC, gltrans_sequence, gltrans_amount;\n admin 2015-10-01 0 306 whereUsed detail used by dspSingleLevelWhereUsed, dspIndentedWhereUsed\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: whereUsed\n-- Name: detail\n-- Notes: used by dspSingleLevelWhereUsed, dspIndentedWhereUsed\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n bomwork_id, item_id, bomwork_parent_id,\n bomworkitemsequence(bomwork_id) AS seqord, \n bomwork_seqnumber, item_number,\n bomwork_qtyfxd ,bomwork_qtyper,\n 'qty' AS bomwork_qtyfxd_xtnumericrole,\n 'qtyper' AS bomwork_qtyper_xtnumericrole,\n 'scrap' AS bomwork_scrap_xtnumericrole,\n bomwork_scrap,\n bomwork_effective,\n bomwork_expires,\n CASE WHEN COALESCE(bomwork_effective,startOfTime())=startOfTime() \n THEN 'Always' \n END AS bomwork_effective_qtdisplayrole,\n CASE WHEN COALESCE(bomwork_expires,endOfTime())=endOfTime() \n THEN 'Never' \n END AS bomwork_expires_qtdisplayrole,\n bomwork_level - 1 AS xtindentrole, \n \n bomitem_parent_item_id, item_id, bomitem_seqnumber,\n item_number,\n itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd AS qtyfxd,\n itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper AS qtyper,\n 'qty' AS qtyfxd_xtnumericrole,\n 'qtyper' AS qtyper_xtnumericrole,\n 'scrap' AS bomitem_scrap_xtnumericrole,\n bomitem_scrap,\n bomitem_effective, bomitem_expires,\n CASE WHEN (COALESCE(bomitem_effective, startoftime()) = startoftime()) \n THEN 'Always' \n END AS bomitem_effective_qtdisplayrole,\n CASE WHEN (COALESCE(bomitem_expires, endoftime()) = endoftime()) \n THEN 'Never' \n END AS bomitem_expires_qtdisplayrole,\n-- formatted for report\n item_descrip1, item_descrip2,\n formatQty(itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS f_qtyfxd,\n formatQtyper(itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS f_qtyper,\n formatScrap(bomitem_scrap) AS f_scrap,\n formatDate(bomitem_effective, ) AS f_effective,\n formatDate(bomitem_expires, ) AS f_expires,\n formatBoolYN(bomitem_createwo) AS f_createwo,\n CASE WHEN (bomitem_issuemethod='S') THEN \n WHEN (bomitem_issuemethod='L') THEN \n WHEN (bomitem_issuemethod='M') THEN \n ELSE \n END AS f_issuemethod,\n formatQtyper(itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * (bomitem_qtyfxd + bomitem_qtyper) * (1 + bomitem_scrap)) as f_qtyreq,\n \n (item_descrip1 || ' ' || item_descrip2) AS descrip,\n uom_name\nFROM item, uom, \n \n bomwork\n \n bomitem\n \nWHERE ((item_inv_uom_id=uom_id)\n \n AND (bomwork_item_id=item_id)\n AND (bomwork_set_id=)\n \n AND (bomwork_expires > CURRENT_DATE)\n \n \n AND (bomwork_effective <= CURRENT_DATE)\n \n \n AND (bomitem_parent_item_id=item_id)\n AND (bomitem_item_id=)\n AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id))\n \n AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires-1)) \n \n AND ( BETWEEN bomitem_effective AND (bomitem_expires-1))\n \n \n )\n\nORDER BY seqord\n\nORDER BY item_number\n\n;\n admin 2015-10-01 0 93 workOrderHistory detail used by dspWoHistoryByNumber, dspWoHistoryByItem, dspWoHistoryByClassCode\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: workOrderHistory\n-- Name: detail\n-- Notes: used by dspWoHistoryByNumber, dspWoHistoryByItem, dspWoHistoryByClassCode\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n\n wo_id, formatWoNumber(wo_id) AS wonumber, wo_status,\n wo_qtyord, wo_qtyrcv, wo_postedvalue,\n wo_startdate, wo_duedate,\n\n wo_id, formatWoNumber(wo_id) AS wonumber, wo_status,\n wo_qtyord, wo_qtyrcv, wo_postedvalue,\n wo_startdate, wo_duedate,\n\n wo.*, COALESCE((prj_number || ' ' || prj_name), '') AS project,\n \n COALESCE(bom.rev_number, '') AS bom_rev_number,\n COALESCE(boo.rev_number, '') AS boo_rev_number,\n \n 'cost' AS wo_wipvalue_xtnumericrole,\n\n\n item_number, (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n item_descrip1, item_descrip2, uom_name,\n\n warehous_code,\n formatDate(wo_startdate) AS f_wo_startdate,\n formatDate(wo_duedate) AS f_wo_duedate,\n formatQty(wo_qtyord) AS f_wo_qtyord,\n formatQty(wo_qtyrcv) AS f_wo_qtyrcv,\n \n formatCost(wo_postedvalue) AS f_wo_postedvalue,\n \n 'qty' AS wo_qtyord_xtnumericrole,\n 'qty' AS wo_qtyrcv_xtnumericrole,\n 'cost' AS wo_postedvalue_xtnumericrole\nFROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id)\n JOIN whsinfo ON (warehous_id=itemsite_warehous_id)\n\n JOIN item ON (item_id=itemsite_item_id)\n JOIN uom ON (uom_id=item_inv_uom_id)\n\n\n LEFT OUTER JOIN rev bom ON (bom.rev_id=wo_bom_rev_id)\n LEFT OUTER JOIN rev boo ON (boo.rev_id=wo_boo_rev_id)\n\n LEFT OUTER JOIN prj ON (prj_id=wo_prj_id)\nWHERE ((true)\n\n AND (itemsite_item_id=)\n AND (wo_duedate BETWEEN AND )\n\n\n AND (itemsite_warehous_id=)\n\n\n AND (CAST(wo_number AS TEXT) ~ )\n\n\n AND (itemsite_item_id=item_id)\n AND (wo_duedate BETWEEN AND )\n \n AND (item_classcode_id=)\n \n AND (item_classcode_id IN (SELECT classcode_id FROM classcode\n WHERE (classcode_code ~ )))\n \n\n\n AND ((wo_ordtype<>'W') OR (wo_ordtype IS NULL))\n\n )\n\n\n ORDER BY wo_startdate DESC, wo_number, wo_subnumber\n\n ORDER BY item_number\n\n ORDER BY wo_number, wo_subnumber\n\n;\n admin 2015-10-01 0 132 workOrderMaterial detail used by dspWoMaterialsByItem, dspWoMaterialsByWorkOrder\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: workOrderMaterial\n-- Name: detail\n-- Notes: used by dspWoMaterialsByItem, dspWoMaterialsByWorkOrder\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT womatl.*, formatWONumber(wo_id) AS wonumber, item_number,\n item_descrip1, item_descrip2,\n\n formatwooperseq(womatl_wooper_id) AS wooperseq,\n\n CASE WHEN (womatl_issuemethod = 'S') THEN \n WHEN (womatl_issuemethod = 'L') THEN \n WHEN (womatl_issuemethod = 'M') THEN \n ELSE \n END AS issuemethod,\n uom_name,\n noNeg(womatl_qtyreq - womatl_qtyiss) AS balance,\n\n formatDate(womatl_duedate) AS f_duedate,\n formatQty(womatl_qtyfxd) AS f_qtyfxd,\n formatQtyPer(womatl_qtyper) AS f_qtyper,\n formatPrcnt(womatl_scrap) AS f_scrap,\n formatQty(womatl_qtyreq) AS f_qtyreq,\n formatQty(womatl_qtyiss) AS f_qtyiss,\n formatQty(womatl_qtywipscrap) AS f_qtywipscrap,\n formatQty(noNeg(womatl_qtyreq - womatl_qtyiss)) AS f_balance,\n\n CASE WHEN (womatl_duedate <= CURRENT_DATE) THEN 'error' END AS womatl_duedate_qtforegroundrole,\n 'qty' AS womatl_qtyfxd_xtnumericrole,\n 'qtyper' AS womatl_qtyper_xtnumericrole,\n 'percent' AS womatl_scrap_xtnumericrole,\n 'qty' AS womatl_qtyreq_xtnumericrole,\n 'qty' AS womatl_qtyiss_xtnumericrole,\n 'qty' AS womatl_qtywipscrap_xtnumericrole,\n 'qty' AS balance_xtnumericrole,\n 0 AS womatl_qtyreq_xttotalrole,\n 0 AS womatl_qtyiss_xttotalrole,\n 0 AS womatl_qtywipscrap_xttotalrole,\n 0 AS balance_xttotalrole\nFROM wo JOIN womatl ON (womatl_wo_id=wo_id)\n JOIN uom ON (uom_id=womatl_uom_id)\n JOIN itemsite parentsite ON (parentsite.itemsite_id=wo_itemsite_id)\n JOIN itemsite componentsite ON (componentsite.itemsite_id=womatl_itemsite_id)\n\n JOIN item ON (item_id=parentsite.itemsite_item_id)\n\n JOIN item ON (item_id=componentsite.itemsite_item_id)\n\nWHERE (1=1)\n\n AND (componentsite.itemsite_item_id=)\n AND (wo_status <> 'C')\n\n\n AND (componentsite.itemsite_warehous_id=)\n\n\n AND (wo_id=)\n\n\nORDER BY wo_startdate, item_number\n\n\n \n ORDER BY wooperseq, item_number\n \n ORDER BY item_number\n \n\n;\n admin 2015-10-01 0 115 workOrderSchedule detail \n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: workOrderSchedule\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT wo_id,\n CASE WHEN (wo_ordid IS NULL) THEN -1\n ELSE wo_ordid\n END AS orderid,\n wo.*, warehous_code, uom_name,\n item_number, (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n item_descrip1, item_descrip2, prj_number,\n CASE wo_ordtype WHEN ('S') THEN formatSoitemNumber(wo_ordid)\n WHEN ('W') THEN formatWoNumber(wo_ordid)\n END AS parentorder,\n formatQty(wo_qtyord) AS ordered,\n formatQty(wo_qtyrcv) AS received,\n formatDate(wo_startdate) AS startdate,\n formatDate(wo_duedate) AS duedate,\n formatWONumber(wo_id) AS wonumber,\n 'qty' AS wo_qtyord_xtnumericrole,\n 'qty' AS wo_qtyrcv_xtnumericrole,\n CASE WHEN ((wo_startdate<=CURRENT_DATE) AND (wo_status IN ('O','E','S','R'))) THEN 'error'\n END AS wo_startdate_qtforegroundrole,\n CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'error'\n END AS wo_duedate_qtforegroundrole,\n CASE WHEN (wo_duedate<=CURRENT_DATE) THEN \n ELSE \n END AS condition,\n CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'error' END AS condition_qtforegroundrole,\n CASE wo_status WHEN ('O') THEN \n WHEN ('E') THEN \n WHEN ('R') THEN \n WHEN ('I') THEN \n WHEN ('C') THEN \n ELSE '?'\n END AS wo_status_qtdisplayrole,\n CASE wo_ordtype WHEN ('') THEN ''\n WHEN ('W') THEN \n WHEN ('M') THEN \n WHEN ('P') THEN \n WHEN ('S') THEN \n ELSE '?'\n END AS wo_ordtype_qtdisplayrole\nFROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN uom ON (uom_id=item_inv_uom_id)\n JOIN whsinfo ON (warehous_id=itemsite_warehous_id)\n LEFT OUTER JOIN prj ON (prj_id=wo_prj_id)\n\n JOIN coitem ON ((coitem_order_id=wo_id) AND (coitem_order_type='W'))\n\nWHERE ( (true)\n\n AND ( (wo_number::TEXT ~* )\n OR (item_number ~* )\n OR (item_descrip1 || item_descrip2 ~* ) )\n\n\n AND (coitem_status <> 'X')\n\n AND (coitem_status='C')\n\n\n AND (wo_prj_id=)\n\n\n AND (wo_startdate >= )\n\n\n AND (wo_startdate <= )\n\n\n AND (itemsite_warehous_id=)\n\n\n AND (itemsite_item_id=)\n\n\n AND (wo_number IN (SELECT wo_number\n FROM wo\n WHERE (wo_id=)))\n\n\n\n \n AND (wo_status=\n \n OR wo_status=\n \n \n )\n \n\n\n AND (wo_status IN ('R','I'))\n\n AND (wo_status<>'C')\n\n\n AND (wo_ordtype<>'W')\n\n\n AND (item_classcode_id=)\n\n\n AND (item_id IN (SELECT itemgrpitem_item_id\n FROM itemgrpitem\n WHERE (itemgrpitem_itemgrp_id=)))\n\n\n AND (itemsite_plancode_id=)\n\n\n AND (wo_id IN (SELECT wooper_wo_id\n FROM wooper\n WHERE (wooper_wrkcnt_id=)))\n\n\n AND (item_classcode_id IN (SELECT classcode_id\n FROM classcode\n WHERE (classcode_code ~ )))\n\n\n AND (item_id IN (SELECT itemgrpitem_item_id\n FROM itemgrpitem, itemgrp\n WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id) AND (itemgrp_name ~ ) ) ))\n\n\n AND (itemsite_plancode_id IN (SELECT plancode_id\n FROM plancode\n WHERE (plancode_code ~ )))\n\n\n AND (wo_id IN (SELECT wooper_wo_id\n FROM wooper, wrkcnt\n WHERE ((wooper_wrkcnt_id=wrkcnt_id) AND (wrkcnt_code ~ ))))\n\n )\nORDER BY \n\n wo_startdate,\n\n wo_duedate,\n\n item_number,\n\n wo_number, wo_subnumber;\n admin 2015-10-01 0 116 workOrderSchedule parameterlist used by dspWoScheduleByParameterList\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: workOrderSchedule\n-- Name: parameterlist\n-- Notes: used by dspWoScheduleByParameterList\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT wo_id,\n CASE WHEN (wo_ordid IS NULL) THEN -1\n ELSE wo_ordid\n END AS orderid,\n wo.*, warehous_code, uom_name,\n item_number, (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n item_descrip1, item_descrip2,\n formatQty(wo_qtyord) AS ordered,\n formatQty(wo_qtyrcv) AS received,\n formatDate(wo_startdate) AS startdate,\n formatDate(wo_duedate) AS duedate,\n formatWONumber(wo_id) AS wonumber,\n 'qty' AS wo_qtyord_xtnumericrole,\n 'qty' AS wo_qtyrcv_xtnumericrole,\n CASE WHEN ((wo_startdate<=CURRENT_DATE) AND (wo_status IN ('O','E','S','R'))) THEN 'error'\n END AS wo_startdate_qtforegroundrole,\n CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'error'\n END AS wo_duedate_qtforegroundrole,\n CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'Overdue'\n ELSE 'On Time'\n END AS condition,\n CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'error' END AS condition_qtforegroundrole\nFROM wo, itemsite, whsinfo, item, uom\nWHERE ( (wo_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (wo_startdate BETWEEN AND )\n\n AND (itemsite_warehous_id=)\n\n\n AND (itemsite_item_id=)\n\n\n AND (wo_number IN (SELECT wo_number\n FROM wo\n WHERE (wo_id=)))\n\n\n AND (wo_status IN (\n\n \n ,\n \n \n ))\n\n AND (wo_status IN ('R','I'))\n\n AND (wo_status<>'C')\n\n\n AND (wo_ordtype<>'W')\n\n\n AND (item_classcode_id=)\n\n AND (item_id IN (SELECT itemgrpitem_item_id\n FROM itemgrpitem\n WHERE (itemgrpitem_itemgrp_id=)))\n\n AND (itemsite_plancode_id=)\n\n AND (wo_id IN (SELECT wooper_wo_id\n FROM wooper\n WHERE (wooper_wrkcnt_id=)))\n\n AND (item_classcode_id IN (SELECT classcode_id\n FROM classcode\n WHERE (classcode_code ~ )))\n\n AND (item_id IN (SELECT itemgrpitem_item_id\n FROM itemgrpitem, itemgrp\n WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id) AND (itemgrp_name ~ ) ) ))\n\n AND (itemsite_plancode_id IN (SELECT plancode_id\n FROM plancode\n WHERE (plancode_code ~ )))\n\n AND (wo_id IN (SELECT wooper_wo_id\n FROM wooper, wrkcnt\n WHERE ((wooper_wrkcnt_id=wrkcnt_id) AND (wrkcnt_code ~ ))))\n\n\n AND (wo_username=)\n\n )\nORDER BY \n\n wo_startdate,\n\n wo_duedate,\n\n item_number,\n\n wo_number, wo_subnumber;\n admin 2015-10-01 0 128 workOrderVariance material used by dspMaterialUsageVarianceByBOMItem, dspMaterialUsageVarianceByComponentItem,\n dspMaterialUsageVarianceByItem, dspMaterialUsageVarianceByWarehouse,\n dspMaterialUsageVarianceByWorkOrder\n Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: workOrderVariance\n-- Name: material\n-- Notes: used by dspMaterialUsageVarianceByBOMItem, dspMaterialUsageVarianceByComponentItem,\n-- dspMaterialUsageVarianceByItem, dspMaterialUsageVarianceByWarehouse,\n-- dspMaterialUsageVarianceByWorkOrder\n-- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT womatlvar_id, posted, \n parentitemnumber, parentdescrip,\n componentitemnumber, componentdescrip,\n ordered, received,\n projreq, projqtyper,\n actiss, actqtyper,\n (actqtyper - projqtyper) AS qtypervar,\n CASE WHEN (actqtyper=projqtyper) THEN 0\n WHEN (projqtyper=0) THEN actqtyper\n ELSE ((1 - (actqtyper / projqtyper)) * -1)\n END AS qtypervarpercent,\n womatlvar_notes, womatlvar_ref,\n\n formatDate(posted) AS f_posted,\n formatQty(ordered) AS f_ordered,\n formatQty(received) AS f_received,\n formatQty(projreq) AS f_projreq,\n formatQtyPer(projqtyper) AS f_projqtyper,\n formatQty(actiss) AS f_actiss,\n formatQty(actqtyper) AS f_actqtyper,\n formatQty(actqtyper - projqtyper) AS f_qtypervar,\n CASE WHEN (actqtyper=projqtyper) THEN formatQty(0)\n WHEN (projqtyper=0) THEN formatQty(actqtyper)\n ELSE formatPrcnt((1 - (actqtyper / projqtyper)) * -1)\n END AS f_qtypervarpercent,\n\n 'qty' AS ordered_xtnumericrole,\n 'qty' AS received_xtnumericrole,\n 'qty' AS projreq_xtnumericrole,\n 'qtyper' AS projqtyper_xtnumericrole,\n 'qty' AS actiss_xtnumericrole,\n 'qtyper' AS actqtyper_xtnumericrole,\n 'qtyper' AS qtypervar_xtnumericrole,\n 'percent' AS qtypervarpercent_xtnumericrole\nFROM ( SELECT womatlvar_id, womatlvar_posted AS posted,\n parentitem.item_number AS parentitemnumber,\n parentitem.item_descrip1 || ' ' || parentitem.item_descrip2 as parentdescrip,\n componentitem.item_number AS componentitemnumber,\n componentitem.item_descrip1 || ' ' || componentitem.item_descrip2 as componentdescrip,\n womatlvar_notes, womatlvar_ref,\n womatlvar_qtyord AS ordered, womatlvar_qtyrcv AS received,\n ((womatlvar_qtyfxd + womatlvar_qtyrcv * womatlvar_qtyper) * (1 + womatlvar_scrap)) AS projreq,\n womatlvar_qtyper AS projqtyper,\n (womatlvar_qtyiss) AS actiss, (NONEG(womatlvar_qtyiss - womatlvar_qtyfxd) / (womatlvar_qtyrcv * (1 + womatlvar_scrap))) AS actqtyper\n FROM womatlvar LEFT OUTER JOIN wo ON ( (wo_number=womatlvar_number) AND\n (wo_subnumber=womatlvar_subnumber) )\n LEFT OUTER JOIN itemsite parent ON (parent.itemsite_id=womatlvar_parent_itemsite_id)\n LEFT OUTER JOIN item parentitem ON (parentitem.item_id=parent.itemsite_item_id)\n LEFT OUTER JOIN itemsite component ON (component.itemsite_id=womatlvar_component_itemsite_id)\n LEFT OUTER JOIN item componentitem ON (componentitem.item_id=component.itemsite_item_id)\n WHERE ( (1=1)\n\n AND (womatlvar_posted BETWEEN AND )\n\n\n AND (wo_id=)\n\n\n AND (parent.itemsite_warehous_id=)\n\n\n AND (parent.itemsite_item_id=)\n\n\n AND (womatlvar_bomitem_id=)\n\n\n AND (component.itemsite_item_id=)\n\n ) ) AS data\nORDER BY posted;\n admin 2015-10-01 0 \. -- -- Name: metasql_metasql_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('metasql_metasql_id_seq', 494, true); -- -- Data for Name: metric; Type: TABLE DATA; Schema: public; Owner: admin -- COPY metric (metric_id, metric_name, metric_value, metric_module) FROM stdin; 22 FreightAccount 1 \N 23 DefaultARAccount 2 \N 44 DefaultAPAccount 3 \N 20 InvoiceCustomer t \N 21 InvoiceBilling 0 \N 51 DatabaseName! Schema Benchmark \N 70 InvoiceWatermark2 \N 72 InvoiceWatermark3 \N 73 InvoiceShowPrices3 102 \N 49 AccountingSystemImportPath C:/OpenMFG \N 50 AccountingSystemExportPath C:/OpenMFG \N 78 CreditMemoWatermark2 \N 80 CreditMemoWatermark3 \N 81 CreditMemoShowPrices3 116 \N 48 AccountingSystem Native \N 62 MaxLocationNameSize 10 \N 3 PostCountTagToDefault f \N 4 CountSlipAuditing B \N 14 AllowDiscounts t \N 15 AllowASAPShipSchedules t \N 16 CONumberGeneration A \N 17 QUNumberGeneration A \N 18 CMNumberGeneration A \N 26 DefaultPartialShipments t \N 27 DefaultBackOrders t \N 28 DefaultFreeFormShiptos t \N 29 SOCreditLimit 20000 \N 31 DefaultBalanceMethod B \N 32 BOLShipper t \N 33 BOLCustomer f \N 34 BOLTraffic f \N 35 BOLBilling f \N 36 BOLMisc 0 \N 55 remitto_address1 Accounts Receivable \N 60 remitto_zipcode 23100 \N 37 PONumberGeneration A \N 38 VoucherNumberGeneration A \N 39 PrNumberGeneration A \N 40 POAllowFFVendorAddresses t \N 43 DefaultPOShipVia UPS \N 53 CustListSerial 30 \N 8 AutoExplodeSO t \N 10 ExplodeSOEffective E \N 11 SOExplosionLevel M \N 84 AutoExplodeWO t \N 86 ExplodeWOEffective S \N 87 WOExplosionLevel M \N 12 PostMaterialVariances t \N 45 GLMainSize 4 \N 46 GLProfitSize 0 \N 47 GLSubaccountSize 2 \N 91 YearEndEquityAccount 84 \N 97 AllowInactiveBomItems f \N 7 DefaultWomatlIssueMethod M \N 9 WONumberGeneration A \N 103 RestrictCreditMemos f \N 104 AutoSelectForBilling t \N 105 AlwaysShowSaveAndAdd t \N 106 DisableSalesOrderPriceOverride f \N 107 AutoAllocateCreditMemos f \N 108 HideSOMiscCharge f \N 111 InvoiceDateSource shipdate \N 114 ShippingFormShowPrices0 t \N 115 DisallowReceiptExcessQty f \N 54 remitto_name Getting Started Inc \N 56 remitto_address2 Moving Forward Business Park \N 57 remitto_address3 12100 Let's Go \N 58 remitto_city Norfolk \N 59 remitto_state VA \N 61 remitto_phone 888-512-8040 \N 92 MandatoryGLEntryNotes t \N 25 DefaultShipViaId 13 \N 110 DefaultCustType 18 \N 24 DefaultShipFormId 12 \N 6 DefaultSoldItemsExclusive f \N 117 UseProjects t \N 118 AutoCreateProjectsForOrders f \N 95 ItemSiteChangeLog t \N 96 WarehouseChangeLog t \N 98 ItemChangeLog t \N 121 DefaultMSCalendar 47 \N 85 WorkOrderChangeLog t \N 99 POChangeLog t \N 100 VendorChangeLog t \N 101 CustomerChangeLog t \N 102 SalesOrderChangeLog t \N 30 SOCreditRate Not checked \N 64 InvoiceCopies 2 \N 66 InvoiceWatermark0 Customer \N 67 InvoiceShowPrices0 t \N 68 InvoiceWatermark1 Internal \N 69 InvoiceShowPrices1 t \N 65 CreditMemoCopies 2 \N 74 CreditMemoWatermark0 Customer \N 75 CreditMemoShowPrices0 t \N 76 CreditMemoWatermark1 Internal \N 77 CreditMemoShowPrices1 t \N 112 ShippingFormCopies 2 \N 113 ShippingFormWatermark0 Customer \N 122 ShippingFormWatermark1 Internal \N 123 ShippingFormShowPrices1 t \N 124 remitto_country United States \N 119 CurrencyExchangeSense 1 \N 125 CurrencyGainLossAccount 122 \N 126 GLSeriesDiscrepancyAccount 123 \N 127 UseEarliestAvailDateOnPOItem t \N 128 RequireStdCostForPOItem t \N 129 UpdatePriceLineEdit 2 \N 130 ShipmentNumberGeneration A \N 131 WarnIfReceiptQtyDiffers t \N 132 ReceiptQtyTolerancePct 10 \N 133 AllowManualGLAccountEntry t \N 134 DefaultTaxAuthority -1 \N 147 TransferOrderChangeLog f \N 148 EnableTOShipping t \N 150 MultiWhs f \N 151 BBOM f \N 152 Transforms f \N 153 Routings f \N 154 BufferMgt f \N 155 LotSerialControl f \N 156 Application PostBooks \N 157 TrackMachineOverhead G \N 158 RevControl f \N 159 TONumberGeneration M \N 160 DefaultPrintPOOnSave t \N 161 AutoFillPostOperationQty f \N 13 PostLaborVariances f \N 162 WOTCPostStyle Operations \N 1 InterfaceToGL t \N 163 JobItemCosDefault P \N 164 DefaultSalesRep 29 \N 165 DefaultTerms 42 \N 166 DefaultPrintSOOnSave t \N 167 UsePromiseDate t \N 168 EnableReturnAuth f \N 169 EnableSOReservations f \N 71 InvoiceShowPrices2 f \N 79 CreditMemoShowPrices2 f \N 170 EnableCustomerDeposits t \N 88 GLCompanySize 0 \N 89 GLFFProfitCenters f \N 90 GLFFSubaccounts f \N 109 EnableSOShipping f \N 2 DefaultEventFence 1 \N 52 DatabaseComments Quick Start DB \N 171 CCConfirmPreauth f \N 172 CCConfirmCharge f \N 173 CCConfirmChargePreauth f \N 174 CCConfirmCredit f \N 175 CCEnablePreauth f \N 176 CCEnableCharge f \N 177 CCAvsCheck W \N 178 CCTestResult P \N 180 RecurringInvoiceBuffer 7 \N 181 EmployeeChangeLog t \N 183 AllowAvgCostMethod f \N 184 AllowStdCostMethod t \N 186 AutoUpdateLocaleHasRun t \N 187 LegacyCashReceipts f \N 188 VerboseCommentList t \N 193 MultiCompanyFinancialConsolidation f \N 194 ManualForwardUpdate f \N 195 SetDefaultLocations f \N 196 KitComponentInheritCOS f \N 190 AutoCreditWarnLateCustomers t \N 197 DefaultAutoCreditWarnGraceDays 30 \N 185 AllowJobCostMethod t \N 199 EFTRoutingRegex ^\\d{9}$ \N 200 EFTAccountRegex ^\\d{4,17}$ \N 201 EFTFunction formatAchChecks \N 202 CRMAccountNumberGeneration M \N 205 StrictAddressCountry t \N 203 OpportunityChangeLog t \N 19 InvcNumberGeneration A \N 208 CreditTaxDiscount t \N 209 POCopies 0 \N 210 POWatermark0 Vendor Copy \N 211 NumberIssueResetIntervalDays 1 \N 212 InterfaceAPToGL t \N 213 InterfaceARToGL t \N 214 ACHEnabled f \N 218 UseJournals f \N 198 ACHSupported t \N 283 CSVAtlasDefaultDirMac \N 284 CSVAtlasDefaultDirWindows \N 285 XMLSuccessSuffix \N 286 XMLSuccessDir \N 287 ImportFailureTreatment \N \N 288 ImportFailureSuffix \N 289 ImportFailureDir \N 300 RegistrationKey JEEJT-CTWEJ-ZGY8Z-MXJZK-ECVCB \N 299 AutoVersionUpdate t \N 215 ReqInvRegVoucher t \N 216 ReqInvMiscVoucher t \N 217 RecurringVoucherBuffer 3 \N 116 HideApplyToBalance t \N 191 DefaultARIncidentStatus 1 \N 192 AutoCloseARIncident t \N 219 ShowQuotesAfterSO t \N 220 FirmSalesOrderPackingList t \N 221 CalculateFreight f \N 222 IncludePackageWeight f \N 223 EnableSOReservationsByLocation f \N 224 SOReservationLocationMethod 1 \N 225 soPriceEffective CurrentDate \N 226 IgnoreCustDisc f \N 227 DisallowMismatchClientVersion f \N 228 ForceLicenseLimit f \N 229 updateTickInterval 1 \N 230 AllowedUserLogins ActiveOnly \N 231 DisableAutoComplete f \N 290 ImportXMLCreateErrorFile f \N 233 IncidentsPublicPrivate t \N 234 IncidentPublicDefault t \N 204 DefaultAddressCountry \N 235 EnableDropShipments f \N 236 BillDropShip f \N 237 RequirePOTax f \N 238 CopyPRtoPOItem t \N 63 DatabaseName xTuple Quick Start DB \N 239 CCAccept f \N 240 CCTest f \N 241 CCValidDays 1 \N 242 CCCompany \N \N 243 CCServer \N 244 CCPort \N 245 CCUseProxyServer f \N 246 CCProxyServer \N 247 CCProxyPort \N 248 CCYPWinPathPEM \N 249 CCYPLinPathPEM \N 250 CCYPMacPathPEM \N 251 CCYPLinkShield f \N 252 CCYPLinkShieldMax 0 \N 253 CCEnableChargePreauth f \N 254 CCEnableCredit f \N 255 CCPrintReceipt f \N 256 CCRequireCVV f \N 257 CCCVVCheck X \N 258 CCCVVErrors \N \N 259 CCANVer 3.1 \N 260 CCANDelim \N 261 CCANEncap \N 262 CCANDuplicateWindow 0 \N 263 CCANMD5HashSetOnGateway f \N 264 CCANCurrency TRANS \N 265 CCANWellsFargoSecureSource f \N 266 CCANIgnoreSSLErrors f \N 267 CCEncKeyName \N 268 CCWinEncKey \N 269 CCLinEncKey \N 270 CCMacEncKey \N 271 XMLSuccessTreatment \N \N 272 XSLTLibrary f \N 273 XSLTDefaultDirLinux \N 274 XSLTDefaultDirMac \N 275 XSLTDefaultDirWindows \N 276 XSLTProcessorLinux \N 277 XSLTProcessorMac \N 278 XSLTProcessorWindows xsltproc \N 279 XMLDefaultDirLinux \N 280 XMLDefaultDirMac \N 281 XMLDefaultDirWindows \N 282 CSVAtlasDefaultDirLinux \N 291 XMLExportDefaultDirLinux \N 292 XMLExportDefaultDirMac \N 293 XMLExportDefaultDirWindows \N 294 AllowReceiptCostOverride f \N 295 CountAvgCostMethod STD \N 296 RecordPPVonReceipt f \N 297 EnableAsOfQOH t \N 298 AllowBOMItemDelete f \N 232 PrjLaborAndOverhead 136 \N 301 UnifiedBuild true \N 189 ServerVersion 4.9.2 \N 206 desktop/welcome http://welcome.xtuple.org/index.html \N 207 desktop/timer 900000 \N \. -- -- Name: metric_metric_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('metric_metric_id_seq', 301, true); -- -- Data for Name: metricenc; Type: TABLE DATA; Schema: public; Owner: admin -- COPY metricenc (metricenc_id, metricenc_name, metricenc_value, metricenc_module) FROM stdin; \. -- -- Name: metricenc_metricenc_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('metricenc_metricenc_id_seq', 1, false); -- -- Name: misc_index_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('misc_index_seq', 1166, true); -- -- Data for Name: mrghist; Type: TABLE DATA; Schema: public; Owner: admin -- COPY mrghist (mrghist_cntct_id, mrghist_table, mrghist_pkey_col, mrghist_pkey_id, mrghist_cntct_col) FROM stdin; \. -- -- Data for Name: mrgundo; Type: TABLE DATA; Schema: public; Owner: admin -- COPY mrgundo (mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id, mrgundo_schema, mrgundo_table, mrgundo_pkey_col, mrgundo_pkey_id, mrgundo_col, mrgundo_value, mrgundo_type) FROM stdin; \. -- -- Data for Name: msg; Type: TABLE DATA; Schema: public; Owner: admin -- COPY msg (msg_id, msg_posted, msg_scheduled, msg_text, msg_expires, msg_username) FROM stdin; \. -- -- Name: msg_msg_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('msg_msg_id_seq', 16, true); -- -- Data for Name: msguser; Type: TABLE DATA; Schema: public; Owner: admin -- COPY msguser (msguser_id, msguser_msg_id, msguser_viewed, msguser_username) FROM stdin; \. -- -- Name: msguser_msguser_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('msguser_msguser_id_seq', 12, true); -- -- Name: nvend_nvend_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('nvend_nvend_id_seq', 1, false); -- -- Data for Name: obsolete_tax; Type: TABLE DATA; Schema: public; Owner: admin -- COPY obsolete_tax (tax_id, tax_code, tax_descrip, tax_ratea, tax_sales_accnt_id, tax_freight, tax_cumulative, tax_rateb, tax_salesb_accnt_id, tax_ratec, tax_salesc_accnt_id) FROM stdin; 12 Sales Tax Sales Tax 0.0500 102 f f 0.0000 -1 0.0000 -1 \. -- -- Data for Name: ophead; Type: TABLE DATA; Schema: public; Owner: admin -- COPY ophead (ophead_id, ophead_name, ophead_crmacct_id, ophead_owner_username, ophead_opstage_id, ophead_opsource_id, ophead_optype_id, ophead_probability_prcnt, ophead_amount, ophead_target_date, ophead_actual_date, ophead_notes, ophead_curr_id, ophead_active, ophead_cntct_id, ophead_username, ophead_start_date, ophead_assigned_date, ophead_priority_id, ophead_number) FROM stdin; \. -- -- Name: ophead_ophead_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('ophead_ophead_id_seq', 1, true); -- -- Data for Name: opsource; Type: TABLE DATA; Schema: public; Owner: admin -- COPY opsource (opsource_id, opsource_name, opsource_descrip) FROM stdin; \. -- -- Name: opsource_opsource_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('opsource_opsource_id_seq', 1, false); -- -- Data for Name: opstage; Type: TABLE DATA; Schema: public; Owner: admin -- COPY opstage (opstage_id, opstage_name, opstage_descrip, opstage_order, opstage_opinactive) FROM stdin; \. -- -- Name: opstage_opstage_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('opstage_opstage_id_seq', 1, false); -- -- Data for Name: optype; Type: TABLE DATA; Schema: public; Owner: admin -- COPY optype (optype_id, optype_name, optype_descrip) FROM stdin; \. -- -- Name: optype_optype_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('optype_optype_id_seq', 1, false); -- -- Data for Name: orderseq; Type: TABLE DATA; Schema: public; Owner: admin -- COPY orderseq (orderseq_id, orderseq_name, orderseq_number, orderseq_table, orderseq_numcol, orderseq_seqiss) FROM stdin; 10 PlanNumber 10000 planord planord_number \N 15 ToNumber 100 tohead tohead_number \N 17 ContactNumber 3 cntct cntct_number \N 18 LsRegNumber 1 lsreg lsreg_number \N 19 AlarmNumber 1 alarm alarm_number \N 21 ACHBatch 1 checkhead checkhead_ach_batch \N 23 OpportunityNumber 1 ophead ophead_number \N 16 AddressNumber 4 addr addr_number {} 12 APMemoNumber 20000 apmemo apopen_docnumber \N 11 ARMemoNumber 70000 armemo aropen_docnumber \N 20 CashRcptNumber 10000 cashrcpt cashrcpt_number \N 6 PoNumber 20000 pohead pohead_number \N 7 VcNumber 30000 vohead vohead_number \N 8 PrNumber 10000 pr pr_number \N 2 SoNumber 50000 cohead cohead_number \N 3 QuNumber 40000 quhead quhead_number \N 4 CmNumber 60000 armemo aropen_docnumber \N 5 InvcNumber 70000 invchead invchead_invcnumber \N 1 WoNumber 20000 wo wo_number \N 13 IncidentNumber 10000 incdt incdt_number \N 22 CRMAccountNumber 0 crmacct crmacct_number \N \. -- -- Name: orderseq_orderseq_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('orderseq_orderseq_id_seq', 23, true); -- -- Data for Name: pack; Type: TABLE DATA; Schema: public; Owner: admin -- COPY pack (pack_id, pack_head_id, pack_head_type, pack_shiphead_id, pack_printed) FROM stdin; \. -- -- Name: pack_pack_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('pack_pack_id_seq', 1, true); -- -- Data for Name: payaropen; Type: TABLE DATA; Schema: public; Owner: admin -- COPY payaropen (payaropen_ccpay_id, payaropen_aropen_id, payaropen_amount, payaropen_curr_id) FROM stdin; \. -- -- Data for Name: payco; Type: TABLE DATA; Schema: public; Owner: admin -- COPY payco (payco_ccpay_id, payco_cohead_id, payco_amount, payco_curr_id, payco_id) FROM stdin; \. -- -- Name: payco_payco_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('payco_payco_id_seq', 1, false); -- -- Data for Name: period; Type: TABLE DATA; Schema: public; Owner: admin -- COPY period (period_id, period_start, period_end, period_closed, period_freeze, period_initial, period_name, period_yearperiod_id, period_quarter, period_number) FROM stdin; 52 2008-01-01 2008-01-31 f f t 2008 - Jan 3 1 1 53 2008-02-01 2008-02-29 f f f 2008 - Feb 3 1 2 54 2008-03-01 2008-03-31 f f f 2008 - Mar 3 1 3 55 2008-04-01 2008-04-30 f f f 2008 - Apr 3 2 4 56 2008-05-01 2008-05-31 f f f 2008 - May 3 2 5 57 2008-06-01 2008-06-30 f f f 2008 - Jun 3 2 6 58 2008-07-01 2008-07-31 f f f 2008 - Jul 3 3 7 59 2008-08-01 2008-08-31 f f f 2008 - Aug 3 3 8 60 2008-09-01 2008-09-30 f f f 2008 - Sep 3 3 9 61 2008-10-01 2008-10-31 f f f 2008 - Oct 3 4 10 62 2008-11-01 2008-11-30 f f f 2008 - Nov 3 4 11 63 2008-12-01 2008-12-31 f f f 2008 - Dec 3 4 12 64 2009-01-01 2009-01-31 f f f 2009 - Jan 4 1 1 65 2009-02-01 2009-02-28 f f f 2009 - Feb 4 1 2 66 2009-03-01 2009-03-31 f f f 2009 - Mar 4 1 3 67 2009-04-01 2009-04-30 f f f 2009 - Apr 4 2 4 68 2009-05-01 2009-05-31 f f f 2009 - May 4 2 5 69 2009-06-01 2009-06-30 f f f 2009 - Jun 4 2 6 70 2009-07-01 2009-07-31 f f f 2009 - Jul 4 3 7 71 2009-08-01 2009-08-31 f f f 2009 - Aug 4 3 8 72 2009-09-01 2009-09-30 f f f 2009 - Sep 4 3 9 73 2009-10-01 2009-10-31 f f f 2009 - Oct 4 4 10 74 2009-11-01 2009-11-30 f f f 2009 - Nov 4 4 11 75 2009-12-01 2009-12-31 f f f 2009 - Dec 4 4 12 76 2010-01-01 2010-01-31 f f f 2010 - Jan 6 1 1 77 2010-02-01 2010-02-28 f f f 2010 - Feb 6 1 2 78 2010-03-01 2010-03-31 f f f 2010 - Mar 6 1 3 79 2010-04-01 2010-04-30 f f f 2010 - Apr 6 2 4 80 2010-05-01 2010-05-31 f f f 2010 - May 6 2 5 81 2010-06-01 2010-06-30 f f f 2010 - Jun 6 2 6 82 2010-07-01 2010-07-31 f f f 2010 - Jul 6 3 7 83 2010-08-01 2010-08-31 f f f 2010 - Aug 6 3 8 84 2010-09-01 2010-09-30 f f f 2010 - Sep 6 3 9 85 2010-10-01 2010-10-31 f f f 2010 - Oct 6 4 10 86 2010-11-01 2010-11-30 f f f 2010 - Nov 6 4 11 87 2010-12-01 2010-12-31 f f f 2010 - Dec 6 4 12 88 2011-01-01 2011-01-31 f f f 2011 - Jan 7 1 1 89 2011-02-01 2011-02-28 f f f 2011 - Feb 7 1 2 90 2011-03-01 2011-03-31 f f f 2011 - Mar 7 1 3 91 2011-04-01 2011-04-30 f f f 2011 - Apr 7 2 4 92 2011-05-01 2011-05-31 f f f 2011 - May 7 2 5 93 2011-06-01 2011-06-30 f f f 2011 - Jun 7 2 6 94 2011-07-01 2011-07-31 f f f 2011 - Jul 7 3 7 95 2011-08-01 2011-08-31 f f f 2011 - Aug 7 3 8 96 2011-09-01 2011-09-30 f f f 2011 - Sep 7 3 9 97 2011-10-01 2011-10-31 f f f 2011 - Oct 7 4 10 98 2011-11-01 2011-11-30 f f f 2011 - Nov 7 4 11 99 2011-12-01 2011-12-31 f f f 2011 - Dec 7 4 12 100 2012-01-01 2012-01-31 f f f 2012 - Jan 8 1 1 101 2012-02-01 2012-02-29 f f f 2012 - Feb 8 1 2 102 2012-03-01 2012-03-31 f f f 2012 - Mar 8 1 3 103 2012-04-01 2012-04-30 f f f 2012 - Apr 8 2 4 104 2012-05-01 2012-05-31 f f f 2012 - May 8 2 5 105 2012-06-01 2012-06-30 f f f 2012 - Jun 8 2 6 106 2012-07-01 2012-07-31 f f f 2012 - Jul 8 3 7 107 2012-08-01 2012-08-31 f f f 2012 - Aug 8 3 8 108 2012-09-01 2012-09-30 f f f 2012 - Sep 8 3 9 109 2012-10-01 2012-10-31 f f f 2012 - Oct 8 4 10 110 2012-11-01 2012-11-30 f f f 2012 - Nov 8 4 11 111 2012-12-01 2012-12-31 f f f 2012 - Dec 8 4 12 112 2013-01-01 2013-01-31 f f f 2013 - Jan 9 1 1 113 2013-02-01 2013-02-28 f f f 2013 - Feb 9 1 2 114 2013-03-01 2013-03-31 f f f 2013 - Mar 9 1 3 115 2013-04-01 2013-04-30 f f f 2013 - Apr 9 2 4 116 2013-05-01 2013-05-31 f f f 2013 - May 9 2 5 117 2013-06-01 2013-06-30 f f f 2013 - Jun 9 2 6 118 2013-07-01 2013-07-31 f f f 2013 - Jul 9 3 7 119 2013-08-01 2013-08-31 f f f 2013 - Aug 9 3 8 120 2013-09-01 2013-09-30 f f f 2013 - Sep 9 3 9 121 2013-10-01 2013-10-31 f f f 2013 - Oct 9 4 10 122 2013-11-01 2013-11-30 f f f 2013 - Nov 9 4 11 123 2013-12-01 2013-12-31 f f f 2013 - Dec 9 4 12 124 2014-01-01 2014-01-31 f f f 2014 - Jan 10 1 1 125 2014-02-01 2014-02-28 f f f 2014 - Feb 10 1 2 126 2014-03-01 2014-03-31 f f f 2014 - Mar 10 1 3 127 2014-04-01 2014-04-30 f f f 2014 - Apr 10 2 4 128 2014-05-01 2014-05-31 f f f 2014 - May 10 2 5 129 2014-06-01 2014-06-30 f f f 2014 - Jun 10 2 6 130 2014-07-01 2014-07-31 f f f 2014 - Jul 10 3 7 131 2014-08-01 2014-08-31 f f f 2014 - Aug 10 3 8 132 2014-09-01 2014-09-30 f f f 2014 - Sep 10 3 9 133 2014-10-01 2014-10-31 f f f 2014 - Oct 10 4 10 134 2014-11-01 2014-11-30 f f f 2014 - Nov 10 4 11 135 2014-12-01 2014-12-31 f f f 2014 - Dec 10 4 12 136 2015-01-01 2015-01-31 f f f 2015 - Jan 11 1 1 137 2015-02-01 2015-02-28 f f f 2015 - Feb 11 1 2 138 2015-03-01 2015-03-31 f f f 2015 - Mar 11 1 3 139 2015-04-01 2015-04-30 f f f 2015 - Apr 11 2 4 140 2015-05-01 2015-05-31 f f f 2015 - May 11 2 5 141 2015-06-01 2015-06-30 f f f 2015 - Jun 11 2 6 142 2015-07-01 2015-07-31 f f f 2015 - Jul 11 3 7 143 2015-08-01 2015-08-31 f f f 2015 - Aug 11 3 8 144 2015-09-01 2015-09-30 f f f 2015 - Sep 11 3 9 145 2015-10-01 2015-10-31 f f f 2015 - Oct 11 4 10 146 2015-11-01 2015-11-30 f f f 2015 - Nov 11 4 11 147 2015-12-01 2015-12-31 f f f 2015 - Dec 11 4 12 \. -- -- Name: period_period_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('period_period_id_seq', 147, true); -- -- Data for Name: pkgdep; Type: TABLE DATA; Schema: public; Owner: admin -- COPY pkgdep (pkgdep_id, pkgdep_pkghead_id, pkgdep_parent_pkghead_id) FROM stdin; \. -- -- Name: pkgdep_pkgdep_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('pkgdep_pkgdep_id_seq', 1, true); -- -- Data for Name: pkghead; Type: TABLE DATA; Schema: public; Owner: admin -- COPY pkghead (pkghead_id, pkghead_name, pkghead_descrip, pkghead_version, pkghead_developer, pkghead_notes, pkghead_created, pkghead_updated, pkghead_indev) FROM stdin; 7 fixcountry xTuple package to fix non-standard countries 3.4.0 xTuple \n This package contains components to help fix addresses with non-standard countries.\n 2011-10-27 14:11:52.132321+00 2012-07-16 13:52:28.960876+00 f 6 te Time and Expense System 2.3.1 xTuple Time and Expense System add-on package for xTuple ERP.\n\n This file is part of the xtte package for xTuple ERP: PostBooks Edition,\n a free and open source Enterprise Resource Planning software suite,\n Copyright (c) 1999-2013 by OpenMFG LLC, d/b/a xTuple.\n It is licensed to you under the Common Public Attribution License\n version 1.0, the full text of which (including xTuple-specific Exhibits)\n is available at www.xtuple.com/CPAL. By using this software, you agree\n to be bound by its terms.\n 2010-10-26 18:15:18.464115+00 2015-10-01 17:21:38.526219+00 f 5 xtdesktop xTuple Desktop 4.0.2 xTuple \n xTuple Desktop navigational interface for the xTuple main window.\n\n This package is an extension for xTuple ERP: PostBooks Edition,\n a free and open source Enterprise Resource Planning software suite,\n Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n It is licensed to you under the Common Public Attribution License\n version 1.0, the full text of which (including xTuple-specific Exhibits)\n is available at www.xtuple.com/CPAL. By using this software, you agree\n to be bound by its terms.\n 2010-06-18 15:46:03.623626+00 2015-10-01 17:43:27.759741+00 f \. -- -- Name: pkghead_pkghead_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('pkghead_pkghead_id_seq', 7, true); -- -- Data for Name: pkgitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY pkgitem (pkgitem_id, pkgitem_pkghead_id, pkgitem_type, pkgitem_item_id, pkgitem_name, pkgitem_descrip) FROM stdin; \. -- -- Name: pkgitem_pkgitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('pkgitem_pkgitem_id_seq', 1, false); -- -- Data for Name: plancode; Type: TABLE DATA; Schema: public; Owner: admin -- COPY plancode (plancode_id, plancode_code, plancode_name, plancode_mpsexplosion, plancode_consumefcst, plancode_mrpexcp_resched, plancode_mrpexcp_delete) FROM stdin; 24 RM1 Raw Materials - 1 M f \N \N 25 AS1 Assemblies - 1 M f \N \N 26 FG1 Finished Product - 1 M f \N \N \. -- -- Name: plancode_plancode_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('plancode_plancode_id_seq', 26, true); -- -- Name: planord_planord_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('planord_planord_id_seq', 1022, true); -- -- Data for Name: pohead; Type: TABLE DATA; Schema: public; Owner: admin -- COPY pohead (pohead_id, pohead_status, pohead_number, pohead_orderdate, pohead_vend_id, pohead_fob, pohead_shipvia, pohead_comments, pohead_freight, pohead_printed, pohead_terms_id, pohead_warehous_id, pohead_vendaddr_id, pohead_agent_username, pohead_curr_id, pohead_saved, pohead_taxzone_id, pohead_taxtype_id, pohead_dropship, pohead_vend_cntct_id, pohead_vend_cntct_honorific, pohead_vend_cntct_first_name, pohead_vend_cntct_middle, pohead_vend_cntct_last_name, pohead_vend_cntct_suffix, pohead_vend_cntct_phone, pohead_vend_cntct_title, pohead_vend_cntct_fax, pohead_vend_cntct_email, pohead_vendaddress1, pohead_vendaddress2, pohead_vendaddress3, pohead_vendcity, pohead_vendstate, pohead_vendzipcode, pohead_vendcountry, pohead_shipto_cntct_id, pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name, pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name, pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone, pohead_shipto_cntct_title, pohead_shipto_cntct_fax, pohead_shipto_cntct_email, pohead_shiptoaddress_id, pohead_shiptoaddress1, pohead_shiptoaddress2, pohead_shiptoaddress3, pohead_shiptocity, pohead_shiptostate, pohead_shiptozipcode, pohead_shiptocountry, pohead_cohead_id, pohead_released, pohead_shiptoname) FROM stdin; \. -- -- Name: pohead_pohead_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('pohead_pohead_id_seq', 344, true); -- -- Data for Name: poitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY poitem (poitem_id, poitem_status, poitem_pohead_id, poitem_linenumber, poitem_duedate, poitem_itemsite_id, poitem_vend_item_descrip, poitem_vend_uom, poitem_invvenduomratio, poitem_qty_ordered, poitem_qty_received, poitem_qty_returned, poitem_qty_vouchered, poitem_unitprice, poitem_vend_item_number, poitem_comments, poitem_qty_toreceive, poitem_expcat_id, poitem_itemsrc_id, poitem_freight, poitem_freight_received, poitem_freight_vouchered, poitem_prj_id, poitem_stdcost, poitem_bom_rev_id, poitem_boo_rev_id, poitem_manuf_name, poitem_manuf_item_number, poitem_manuf_item_descrip, poitem_taxtype_id, poitem_tax_recoverable, poitem_rlsd_duedate, poitem_order_id, poitem_order_type) FROM stdin; \. -- -- Name: poitem_poitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('poitem_poitem_id_seq', 426, true); -- -- Name: porecv_porecv_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('porecv_porecv_id_seq', 127, true); -- -- Data for Name: poreject; Type: TABLE DATA; Schema: public; Owner: admin -- COPY poreject (poreject_id, poreject_date, poreject_ponumber, poreject_itemsite_id, poreject_vend_id, poreject_vend_item_number, poreject_vend_item_descrip, poreject_vend_uom, poreject_qty, poreject_posted, poreject_rjctcode_id, poreject_poitem_id, poreject_invoiced, poreject_vohead_id, poreject_agent_username, poreject_voitem_id, poreject_value, poreject_trans_username, poreject_recv_id) FROM stdin; \. -- -- Name: poreject_poreject_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('poreject_poreject_id_seq', 41, true); -- -- Data for Name: pr; Type: TABLE DATA; Schema: public; Owner: admin -- COPY pr (pr_id, pr_number, pr_subnumber, pr_status, pr_order_type, pr_order_id, pr_poitem_id, pr_duedate, pr_itemsite_id, pr_qtyreq, pr_prj_id, pr_releasenote, pr_createdate) FROM stdin; \. -- -- Name: pr_pr_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('pr_pr_id_seq', 185, true); -- -- Data for Name: prftcntr; Type: TABLE DATA; Schema: public; Owner: admin -- COPY prftcntr (prftcntr_id, prftcntr_number, prftcntr_descrip) FROM stdin; \. -- -- Name: prftcntr_prftcntr_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('prftcntr_prftcntr_id_seq', 1, true); -- -- Data for Name: priv; Type: TABLE DATA; Schema: public; Owner: admin -- COPY priv (priv_id, priv_module, priv_name, priv_descrip, priv_seq) FROM stdin; 485 System MaintainPreferencesSelf Can Maintain the preferences for their own user only. \N 486 System MaintainPreferencesOthers Can Maintain the preferences of other users. \N 306 Misc. MaintainShippingChargeTypes Can Add/Edit/Delete Shipping Charge Types \N 307 Misc. ViewShippingChargeTypes Can View Shipping Charge Types \N 269 Misc. MaintainExpenseCategories Can Add/Edit/Delete Expense Categories \N 270 Misc. ViewExpenseCategories Can View Expense Categories \N 362 Misc. MaintainSalesCategories Can Add/Edit/Delete Sales Categories \N 363 Misc. ViewSalesCategories Can View Sales Categories \N 446 CRM MaintainTitles Can Add/Edit/Delete Titles (Honorifics). \N 420 CRM MaintainAddresses Can Add/Edit/Delete Addresses \N 422 CRM MaintainCompetitorMasters Can Add/Edit/Delete Competitor Masters \N 426 CRM MaintainPartners Can Add/Edit/Delete Partner Masters \N 429 CRM MaintainWarrantyTerms Can Add/Edit/Delete Warranty Terms \N 447 CRM ViewTitles Can View Titles (Honorifics). \N 433 CRM ViewAddresses Can View Addresses \N 435 CRM ViewCommLog Can View the Communications Log \N 436 CRM ViewCompetitorMasters Can View Competitor Masters \N 441 CRM ViewPartners Can View Partner Masters \N 444 CRM ViewWarrantyTerms Can View Warranty Terms \N 448 CRM MaintainIncidentCategories Can Add/Edit/Delete Incident Categories \N 449 CRM MaintainIncidentPriorities Can Add/Edit/Delete Incident Priorities \N 450 CRM MaintainIncidentSeverities Can Add/Edit/Delete Incident Severities \N 451 CRM MaintainIncidentResolutions Can Add/Edit/Delete Incident Resolutions \N 390 Products PostStandardCosts Can Post Product Standard Costs \N 480 CRM MaintainOpportunitySources Can Add/Edit/Delete Opportunity Sources \N 481 CRM MaintainOpportunityStages Can Add/Edit/Delete Opportunity Stages \N 482 CRM MaintainOpportunityTypes Can Add/Edit/Delete Opportunity Types \N 5 Products MaintainBOMs Can Add/Edit/Delete Bills of Materials \N 4 Products ViewBOMs Can View Bills of Materials \N 103 Products EnterActualCosts Can Enter Free Form Actual Costs \N 104 Products UpdateActualCosts Can Update Actual Costs via P/O or P/D \N 105 Products PostActualCosts Can Post Actual Costs to Standard Costs \N 106 Products ViewCosts Can View Actual and Standard Costs \N 107 Products MaintainUserCostingElements Can Add/Edit/Delete User Costing Elements \N 1 Products ViewItemMasters Can View Item Masters \N 2 Products MaintainItemMasters Can Add/Edit/Delete Item Masters \N 134 Products MaintainItemGroups Can Add/Edit/Delete Item Groups \N 143 Products ViewClassCodes Can View Class Codes \N 144 Products MaintainClassCodes Can Add/Edit/Delete Class Codes \N 160 Products ViewItemOptions Can View Item Options \N 31 Products MaintainProductCategories Add/Edit/Delete Product Categories \N 161 Products DeleteCosts Can Delete Item Costs \N 162 Products CreateCosts Can Create User Costs \N 163 Products ViewProductCategories Can View Product Categories \N 316 Products MaintainUOMs Can Add/Edit/Delete Unit of Measures \N 317 Products ViewUOMs Can View Unit of Measures \N 349 Products DeleteItemMasters Can Delete Item Masters \N 10 Inventory ViewInventoryHistory Can View Inventory History \N 30 Inventory ViewWarehouses Can View Warehouses \N 29 Inventory MaintainWarehouses Can Add/Edit/Delete Warehouses \N 37 Inventory UpdateABCClass Can Run Update ABC Class Utility \N 42 Inventory FreezeInventory Can Freeze Inventory \N 84 Inventory EnterMiscCounts Can Enter Misc. Counts \N 82 Inventory IssueCountTags Can Issue Count Tags \N 83 Inventory EnterCountTags Can Enter Count Tags \N 85 Inventory MaintainLocations Can Add/Edit/Delete Warehouse Locations \N 86 Inventory ViewLocations Can View Warehouse Locations \N 90 Inventory ViewInventoryAvailability Can View Inventory Availability \N 116 Inventory CreateAdjustmentTrans Can Create an Adjustment Transaction \N 117 Inventory CreateScrapTrans Can Create a Scrap Transaction \N 118 Inventory CreateReceiptTrans Can Create a Misc. Receipt Transaction \N 14 Inventory MaintainItemSites Can Add/Edit/Delete Item Sites \N 15 Inventory ViewItemSites Can View Item Sites \N 128 Inventory PostCountSlips Can Post Count Slips \N 129 Inventory EnterCountSlips Can Create and Enter Count Slips \N 131 Inventory DeleteCountTags Delete Count Tags \N 130 Inventory ZeroCountTags Can Zero Uncounted Count Tags \N 132 Inventory ViewCountTags View Count Tags \N 133 Inventory PostCountTags Can Post Count Tags \N 147 Inventory PurgeCountSlips Can Purge Posted Count Slips \N 81 Inventory PurgeCountTags Cost Purge Posted Count Tags \N 148 Inventory ViewInventoryValue Can View Inventory Values \N 19 Inventory RelocateInventory Can Relocate Inventory \N 150 Inventory ViewQOH Can View QOH \N 151 Inventory UpdateCycleCountFreq Can Update an Item Site's Cycle Count Frequency \N 152 Inventory UpdateLeadTime Can Update an Item Site's Lead Time \N 154 Inventory SummarizeInventoryTransactions Can Summarized Inventory Transactions \N 153 Inventory ThawInventory Can Thaw Inventory \N 35 Inventory MaintainCostCategories Can Add/Edit/Delete Cost Categories \N 36 Inventory ViewCostCategories Can View Cost Categories \N 164 Inventory DeleteCountSlips Can Delete Count Slips \N 214 Inventory ViewShipping Can View Stock at Shipping \N 215 Inventory PrintBillsOfLading Can Print Bills of Lading \N 217 Inventory ShipOrders Can Ship Orders from Shipping \N 218 Inventory ReturnStockFromShipping Can Return Stock from Shipping \N 219 Inventory IssueStockToShipping Can Issue Stock to Shipping \N 220 Inventory PurgeShippingRecords Can Purge Shipping Records \N 223 Inventory ViewDestinations Can View Destinations \N 224 Inventory MaintainDestinations Can Add/Edit/Delete Destinations \N 225 Inventory EnterShippingInformation Can Enter Shipping Information \N 216 Inventory RecallOrders Can Recall Orders to Shipping \N 222 Inventory ViewCarriers Can View Shippers \N 221 Inventory MaintainCarriers Can Add/Edit/Delete Shippers \N 226 Inventory EnterReceipts Can Enter Receipts \N 227 Inventory EnterReturns Can Enter Returns \N 241 Inventory UpdateOUTLevels Can Update Order Up To Levels \N 238 Inventory UpdateReorderLevels Can Update Reorder Levels \N 255 Inventory MaintainPackingListBatch Can Modify Packing List Batch \N 256 Inventory ViewPackingListBatch Can View Packing List Batch \N 264 Inventory MaintainCharacteristics Can Add/Edit/Delete Characteristics \N 265 Inventory ViewCharacteristics Can View Characteristics \N 350 Inventory DeleteItemSites Can Delete Item Sites \N 351 Inventory CreateExpenseTrans Can Create an Expense Transaction \N 454 Inventory RecallInvoicedShipment Can recall shipments that have already been invoiced. \N 470 Inventory ViewItemAvailabilityWorkbench Can View Item Availability Workbench. \N 45 Purchase ViewVendors Can View Vendors \N 44 Purchase MaintainVendors Can Add/Edit/Delete Vendors \N 48 Purchase MaintainItemSources Can Add/Edit/Delete P/O Item Sources \N 49 Purchase ViewItemSources Can View P/O Item Sources \N 53 Purchase MaintainPurchaseOrders Can Add/Edit/Delete Purchase Orders \N 54 Purchase ViewPurchaseOrders Can View Orders \N 46 Purchase MaintainPlannerCodes Can Add/Edit/Delete Planner Codes \N 47 Purchase ViewPlannerCodes Can View Planner Codes \N 120 Purchase AssignItemsToPlannerCode Can Assign Items to a Planner Code \N 189 Purchase PrintPurchaseOrders Can Print Purchase Orders \N 204 Purchase MaintainRejectCodes Can Add/Edit/Delete Reject Codes \N 205 Purchase ViewRejectCodes Can View Reject Codes \N 207 Purchase ViewVendorPerformance Can View Vendor Performance \N 208 Purchase ViewCashRequirements Can View Cash Requirements \N 209 Purchase ViewPurchaseRequests Can View Purchase Requests \N 213 Purchase MaintainPurchaseRequests Can Add/Edit/Delete Purchase Requests \N 231 Purchase ViewReceiptsReturns View Receipts and Returns \N 244 Purchase ViewBuyCard Can View Buy Cards \N 245 Purchase ViewVendorAddresses Can View Vendor Addresses \N 246 Purchase MaintainVendorAddresses Can Add/Edit/Delete Vendor Addresses \N 249 Purchase MaintainVendorTypes Can Add/Edit/Delete Vendor Types \N 250 Purchase ViewVendorTypes Can View Vendor Types \N 353 Purchase ReschedulePurchaseOrders Can Reschedule Purchase Orders \N 354 Purchase ChangePurchaseOrderQty Can Change Purchase Order Item Quantities \N 368 Purchase MaintainUninvoicedReceipts Can Mark as invoiced and Correct Receiving on uninvoiced receipts \N 383 Purchase ViewUninvoicedReceipts User is allowed to View Uninvoiced Receivings. \N 452 Purchase MaintainPostedPurchaseOrders Can Edit Purchase Orders which have already been Posted \N 17 Manufacture ReturnWoMaterials Can Return Work Order Materials \N 16 Manufacture IssueWoMaterials Can Issue Work Order Materials \N 91 Manufacture MaintainWoMaterials Can Add/Edit/Delete Work Order Materials \N 27 Manufacture PostProduction Can Post Production \N 11 Manufacture ViewWorkOrders Can View Work Orders \N 93 Manufacture ViewWoMaterials Can View Work Order Materials \N 12 Manufacture MaintainWorkOrders Can Add/Edit/Delete Work Orders \N 13 Manufacture ExplodeWorkOrders Can Explode Work Orders \N 26 Manufacture ImplodeWorkOrders Can Implode Work Orders \N 75 Manufacture RescheduleWorkOrders Can Reschedule Work Orders \N 76 Manufacture ChangeWorkOrderQty Can Change Work Order Quantities \N 94 Manufacture CloseWorkOrders Can Close Work Orders \N 125 Manufacture PostMiscProduction Can Make Miscellaneous Production Postings \N 140 Manufacture PurgeWorkOrders Can Purge Closed Work Orders \N 173 Manufacture ViewMaterialVariances Can View W/O Material Variances \N 176 Manufacture PrintWorkOrderPaperWork Can Print Work Order Paper Work \N 177 Manufacture ReleaseWorkOrders Can Release Work Orders \N 178 Manufacture RecallWorkOrders Can Recall Work Orders \N 182 Manufacture ScrapWoMaterials \N \N 228 Manufacture DeleteWorkOrders Can Delete Open Work Orders \N 352 Manufacture ReprioritizeWorkOrders Can Reprioritize Work Orders \N 408 Manufacture ChangeNonPickItems Can change the Issue Items Not On Pick List flag on Post Production. \N 409 Manufacture ChangeReceiveInventory Can change the Receive Inventory List flag on Post Operations. \N 22 Sales MaintainCustomerMasters Can Add/Edit/Delete Customer Masters \N 23 Sales ViewCustomerMasters Can View Customer Masters \N 51 Sales ViewShipVias Can View Ship Via's \N 55 Sales ViewCustomerTypes Can View Customer Types \N 56 Sales MaintainCustomerTypes Can Add/Edit/Delete Customer Types \N 57 Sales ViewSalesReps Can View Sales Reps. \N 58 Sales MaintainSalesReps Can Add/Edit/Delete Sales Reps. \N 61 Sales ViewTerms Can View Terms \N 59 Sales MaintainTaxCodes Can Add/Edit/Delete Tax Codes \N 60 Sales ViewTaxCodes Can View Tax Codes \N 50 Sales MaintainShipVias Can Add/Edit/Delete Ship Via's \N 88 Sales MaintainShiptos Can Add/Edit/Delete Ship-Tos \N 89 Sales ViewShiptos Can View Ship-Tos \N 111 Sales OverridePrice Can Override Item Sales Prices \N 126 Sales MaintainSalesAccount Can Add/Edit/Delete Sales Account Assignments \N 127 Sales ViewSalesAccount Can View Sales Account Assignments \N 141 Sales MaintainSalesOrders Can Add/Edit/Delete Sales Orders \N 142 Sales ViewSalesOrders Can View Sales Orders \N 180 Sales MaintainPricingSchedules Can Add/Edit/Delete Pricing Schedules \N 181 Sales ViewPricingSchedules Can View Pricing Schedules \N 190 Sales SelectBilling Can Select an Order for Billing \N 192 Sales MaintainShippingForms Can Add/Edit/Delete Shipping Forms \N 193 Sales MaintainShippingZones Can Add/Edit/Delete Shipping Zones \N 194 Sales AssignPricingSchedules Can Assign Pricing Schedules \N 195 Sales CreateSales Can Create Sales \N 196 Sales UpdatePricingSchedules Can Update Pricing Schedules \N 197 Sales MaintainCreditMemos Can Add/Edit/Delete Unposted Credit Memos \N 198 Sales ViewCreditMemos Can View Unposted Credit Memos \N 199 Sales PrintCreditMemos Print Credit Memos \N 200 Sales PurgeCreditMemos Purge Credit Memos \N 201 Sales PurgeInvoices Purge Invoices \N 232 Sales MaintainQuotes Can Add/Edit/Delete Quotes \N 203 Sales ViewCommissions Can View Earned Commissions \N 233 Sales ViewQuotes Can View Quotes \N 70 Sales ViewCustomerPrices Can View Customer Type Prices \N 234 Sales ConvertQuotes Can Convert Quotes to Sales Orders \N 235 Sales PrintPackingLists \N \N 211 Sales ViewShippingZones Can View Shipping Zones \N 212 Sales ViewSalesHistory \N \N 239 Sales PrintQuotes Can Print Quotes \N 242 Sales OverrideSODate Can Override S/O Enter Dates \N 257 Sales MaintainCustomerGroups Can Add/Edit/Delete/Modify Customer Groups \N 258 Sales ViewCustomerGroups Can View Customer Groups \N 273 Sales MaintainListPrices Can Modify List Prices \N 274 Sales ViewListPrices Can View List Prices \N 281 Sales EditSalesHistory Can Edit Posted Sales History \N 336 Sales CreateSOForHoldCustomer Can Create an Sales Order for a Customer on Credit Hold \N 337 Sales CreateSOForWarnCustomer Can Create an Sales Order for a Customer on Credit Warning \N 346 Sales UpdateCustomerCreditStatus Can Update a Customer's Credit Status \N 347 Sales ArchiveSalesHistory Can Archive Sales History \N 348 Sales RestoreSalesHistory Can Restore Sales History \N 355 Sales AlterPackDate Can Alter a Sales Order Pack Date \N 385 Sales MaintainCustomerMastersCustomerType Users are allowed to edit the Customer Type for a customer. \N 386 Sales MaintainCustomerMastersCustomerTypeOnCreate Users are allowed to edit the Customer Type for a customer when creating a new customer. \N 389 Sales AllowSelectOrderEditing Users are allowed to edit some additional information on the Select Order for Billing screen. \N 393 Sales ShowMarginsOnSalesOrder Users will see the margins on the Sales Order and Quote Screens for that older. \N 459 Sales MaintainProspectMasters Can Add/Edit/Delete Prospect information. \N 460 Sales ViewProspectMasters Can View Prospect information. \N 179 Accounting MaintainChartOfAccounts Can Add/Edit/Delete Accounts in the Chart of Accounts \N 251 Accounting MaintainStandardJournals Can Add/Edit/Delete Standard Journals \N 252 Accounting ViewStandardJournals Can View Standard Journals \N 254 Accounting PostStandardJournals Can Post Standard Journals \N 260 Accounting MaintainVendorAccounts Can Add/Edit/Delete Vendor Account Assignments \N 261 Accounting ViewVendorAccounts Can View Vendor Account Assignments \N 262 Accounting MaintainCheckFormats Can Add/Edit/Delete A/P Check Formats \N 263 Accounting ViewCheckFormats Can View A/P Check Formats \N 266 Accounting MaintainStandardJournalGroups Can Add/Edit/Delete Standard Journal Groups \N 267 Accounting ViewStandardJournalGroups Can View Standard Journal Groups \N 268 Accounting PostStandardJournalGroups Can Post Standard Journal Groups \N 271 Accounting MaintainAccountingPeriods Can Add/Edit/Delete Accounting Periods \N 272 Accounting ViewAccountingPeriods Can View Accounting Periods \N 275 Accounting MaintainARMemos Can Add/Edit/Delete A/R Credit/Demo Memos \N 276 Accounting ViewARMemos Can View A/R Credit/Demo Memos \N 277 Accounting ApplyARMemos Can Apply A/R Credit/Demo Memos \N 278 Accounting MaintainMiscInvoices Can Add/Edit/Delete Misc. Invoices \N 279 Accounting ViewMiscInvoices Can View Misc. Invoices \N 280 Accounting PostMiscInvoices Can Post Misc. Invoices \N 294 Accounting PostJournalEntries Can Post Journal Entries \N 297 Accounting ViewGLTransactions Can View G/L Transactions \N 298 Accounting ViewTrialBalances Can View Trial Balances \N 302 Accounting MaintainCashReceipts Can Add/Edit/Delete Cash Receipts \N 303 Accounting ViewCashReceipts Can View Cash Receipts \N 305 Accounting PostCashReceipts Can Post Cash Receipts \N 369 Accounting MaintainPayments Can Maintain Payment and Check information. \N 370 Accounting ViewAPOpenItems Can view A/P Open Item infomation and related screens that use that information. \N 313 Accounting MaintainFinancialLayouts Can Add/Edit/Delete Financial Layouts \N 314 Accounting ViewFinancialLayouts Can View Financial Layouts \N 315 Accounting ViewFinancialReports Can View Financial Reports \N 371 Accounting PrintAPJournals Can view A/P Open Item infomation and related screens that use that information. \N 372 Accounting ViewAROpenItems Can view A/R Open Item infomation and related screens that use that information. \N 334 Accounting EditAPOpenItem Can Edit A/P Open Items \N 335 Accounting EditAROpenItem Can Edit A/R Open Items \N 373 Accounting PrintARJournals Can view A/R Open Item infomation and related screens that use that information. \N 374 Accounting MaintainAdjustmentTypes Can Add/Edit/Delete Adjustment Types \N 375 Accounting ViewAdjustmentTypes Can View Adjustment Types \N 376 Accounting MaintainBankAdjustments Can Add/Edit/Delete Bank Adjustments \N 377 Accounting ViewBankAdjustments Can View Bank Adjustments \N 378 Accounting PostBankAdjustments Can Post Bank Adjustments \N 356 Accounting MaintainAPMemos Can Add/Edit/Post A/P Memos \N 357 Accounting ViewAPMemos Can View A/P Memos \N 358 Accounting ApplyAPMemos Can Apply A/P Memos \N 379 Accounting MaintainBankRec Can Maintain Bank Reconciliations \N 380 Accounting ViewBankRec Can View Bank Reconciliation Information \N 512 Accounting ViewTaxZones Can view Tax Zones \N 382 Accounting MaintainReasonCodes User is allowed to maintain the Reason Codes. \N 395 Accounting CreateNewCurrency Create New Currencies \N 396 Accounting MaintainCurrencies Modify Existing Currencies \N 397 Accounting MaintainCurrencyRates Add and Modify Currency Exchange Rates \N 398 Accounting ViewCurrencyRates View Currency Exchange Rates \N 407 Accounting VoidPostedAPCheck Can void a posted A/P Check. \N 455 Accounting ChangeARInvcDistDate Can distribute an Invoice to the G/L using a date other than the Invoice Date \N 456 Accounting ChangePORecvPostDate Can post a Purchase Order Receipt to the G/L using a date other than the actual Receipt Date \N 457 Accounting ChangeSOMemoPostDate Can post a Sales Order Credit Memo to the G/L using a date other than the Credit Memo Document Date \N 458 Accounting ChangeVOPostDate Can post a Voucher to the G/L using a date other than the Voucher Distribution Date \N 461 Accounting MaintainTaxAuthorities Can Add/Edit/Delete Tax Authorities. \N 462 Accounting ViewTaxAuthorities Can View Tax Authorities. \N 463 Accounting MaintainTaxTypes Can Add/Edit/Delete Tax Types. \N 464 Accounting ViewTaxTypes Can View Tax Types. \N 467 Accounting OverrideTax Can manually override the system-selected Tax Code and/or tax % for individual Invoice line items. \N 468 Accounting MaintainTaxReconciliations Can Add/Edit/Delete unposted Tax Reconciliation records and associated data. \N 469 Accounting ViewTaxReconciliations Can View Tax Reconciliation records and associated data. \N 475 Accounting MaintainBudgets Can maintain budget information \N 476 Accounting ViewBudgets Can view budget information, not affecting FRE ability to view budgets. \N 100 System DispatchOtherEvents Can Dispatch Other User's Events \N 63 System ConfigureIM Configure I/M Module Parameters \N 64 System ConfigurePO Configure P/O Module Parameters \N 65 System ConfigurePD Configure P/D Module Parameters \N 73 System ConfigDatabaseInfo Can Configure the Database Information \N 121 System DeleteOwnEvents Can Delete Own Events \N 122 System DeleteOtherEvents Can Delete Other Users' Events \N 101 System ViewOtherEvents Can View Other User's Events \N 87 System ConfigureWO Configure S/O Module Parameters \N 123 System DispatchOwnEvents Can Dispatch Own Events \N 124 System ConfigureSR Configure S/R Module Parameters \N 68 System ConfigureSO Configure S/O Module Parameters \N 166 System MaintainImages Can Add/Edit/Delete Images \N 167 System MaintainReports Can Add/Edit/Delete Reports \N 168 System MaintainForms Can Add/Edit/Delete Forms \N 169 System MaintainCalendars Can Add/Edit/Delete Calendars \N 170 System MaintainLocales Can Add/Edit/Delete Locales \N 236 System ConfigureGL Can Configure the G/L Module \N 248 System ConfigureAR Can Configure the A/R Module \N 253 System MaintainBankAccounts Can Add/Edit/Delete Bank Accounts \N 3 System MaintainUsers Can Add/Edit/List Users \N 345 System MaintainCommentTypes Can Add/Edit/Delete Comment Types \N 359 System ConfigureAP Can Configure the A/P Module \N 388 System ConfigureCC User is allowed to alter the Credit Card Configuration. \N 394 System ConfigurePM Users will be able to view and edit the configuration options for the P/M Module. \N 399 System MaintainCustomCommands User can Create/Edit/View Custom commands \N 403 System MaintainDepartments Can create and modify Department definitions. \N 404 System ViewDepartments Can view Department definitions. \N 406 System ViewShifts Can view Shift definitions. \N 445 System ConfigureCRM Can change the CRM configuration module options. \N 453 System MaintainCountries Can Add/Edit/Delete Country information. \N 471 System FixSerial Can fix problems with serial values used to assign primary keys. \N 487 Accounting PostPayments Can Post Payments/Checks. \N 488 Accounting ViewDepositsRegister Can view the Deposits Register. \N 489 Accounting ViewInvoiceRegister Can view the Invoice Register. \N 490 System ConfigureImportExport Can Change or Create Settings For Importing and Exporting Data \N 491 System ImportXML Can Import Data From XML Sources \N 187 Accounting MaintainVouchers Can Add/Edit/Delete Vouchers \N 188 Accounting PostVouchers Can Post Vouchers \N 259 Accounting ViewVouchers Can View Vouchers \N 492 Accounting ProcessCreditCards Can Process Credit Card Transactions \N 493 System MaintainScripts Can Change or Create Scripts that are executed by windows when they are opened. \N 495 Inventory AlterTransactionDates Can set the Transaction Date written to the G/L and Inventory History tables for inventory transactions. \N 496 System MaintainEmployees Can Change or Create Employee records. \N 497 System ViewEmployees Can view Employee records. \N 498 System MaintainGroups Can Change or Create Settings For Groups \N 499 System MaintainEmployeeGroups Can Change or Create Employee Groups. \N 500 System ViewEmployeeGroups Can view Employee Group records. \N 494 System MaintainScreens Can Change or Create UI Forms that are executed by custom windows when they are opened. \N 501 Inventory MaintainExternalShipping Can Change or Create External Shipping Records. \N 502 System fixACL Can fix Access Control List problems at the database level. \N 504 System ViewPackages Can View installed Packages. \N 505 Accounting SynchronizeCompanies Can run company trial balance synchronization utility. \N 506 Inventory MaintainSiteTypes Can Change or Create Settings For Site Types \N 507 Inventory ViewSiteTypes Can View Settings For Site Types \N 62 Accounting MaintainTerms Can Add/Edit/Delete Terms \N 191 Accounting PrintInvoices Can Print Invoices \N 202 Accounting PostARDocuments Can Post Invoices and Credit Memos \N 508 Products MaintainFreightClasses Can Add/Edit/Delete Freight Classes \N 509 Products ViewFreightClasses Can View Freight Classes \N 510 Sales FirmSalesOrder Can Firm a Sales Order line item to prevent editing \N 511 CRM EditOwner Can Edit Owner in CRM documents \N 513 Accounting MaintainTaxZones Can Add/Edit/Delete Tax Zones \N 514 Accounting ViewTaxClasses Can view Tax Classes \N 515 Accounting MaintainTaxClasses Can Add/Edit/Delete Tax Classes \N 517 System EditOwnComments User is allowed to edit comments they have entered that are of an editable comment type. \N 518 System EditOthersComments User is allowed to edit iany comments entered that are of an editable comment type. \N 465 Accounting MaintainTaxAssignments Can Add/Edit/Delete Tax Assignments \N 466 Accounting ViewTaxAssignments Can View Tax Assignments \N 519 System MaintainStates User is allowed to edit the list of States and Provinces \N 520 System MaintainMetaSQL User is allowed to edit MetaSQL statements with the MetaSQL editor. \N 521 System ViewMetaSQL User is allowed to view MetaSQL statements with the MetaSQL editor. \N 522 System ExecuteMetaSQL User is allowed to execute MetaSQL statements with the MetaSQL editor that change the database. \N 137 Purchase ReleasePurchaseOrders Can Release Purchase Orders \N 523 Sys ConfigureEncryption Allowed to view and change the Encryption Key File \N 524 System ExportXML Can Export XML Files \N 599 Accounting DeletePostedJournals Can delete posted Standard Journals and Journal Entries \N 600 Accounting EditPostedJournals Can edit posted Journal Entries \N 601 Accounting ViewJournals Can view Journals \N 602 Accounting PostJournals Can post Journals \N 614 CRM MergeContacts Can use Contact Merge utility \N 615 System MaintainTranslations User is allowed to maintain/download translations to their local computer. \N 616 System MaintainDictionaries User is allowed to maintain/download spell check dictionaries to their local computer. \N 431 CRM ReassignToDoItems Can Reassign ToDoItems to other people \N 416 CRM CloseAllIncidents Can Close all Incidents after confirming that it has been satisfactorily resolved \N 626 CRM ClosePersonalIncidents Can Incidents when Owner or Assigned after confirming that it has been resolved \N 425 CRM MaintainAllToDoItems Can Add/Edit/Delete all ToDoItems 0 423 CRM MaintainAllContacts Can Add/Edit/Delete all Contacts 0 419 CRM MaintainAllCRMAccounts Can Add/Edit/Delete all CRM Accounts 0 483 CRM MaintainAllOpportunities Can Add/Edit/Delete all Opportunities 0 424 CRM MaintainAllIncidents Can Add/Edit/Delete all Incidents 0 392 CRM MaintainAllProjects Can Add/Edit/Delete all Projects 0 440 CRM ViewAllToDoItems Can View all ToDoItems 1 437 CRM ViewAllContacts Can View all Contacts 1 432 CRM ViewAllCRMAccounts Can View all CRM Accounts 1 484 CRM ViewAllOpportunities Can View all Opportunities 1 439 CRM ViewAllIncidents Can View all Incidents 1 391 CRM ViewAllProjects Can View all Projects 1 427 CRM MaintainPersonalToDoItems Can Add/Edit/Delete ToDoItems when Owner or Assigned 2 618 CRM MaintainPersonalContacts Can Add/Edit/Delete Contacts when Owner or Assigned 2 620 CRM MaintainPersonalCRMAccounts Can Add/Edit/Delete CRM Accounts when Owner or Assigned 2 622 CRM MaintainPersonalOpportunities Can Add/Edit/Delete Opportunities when Owner or Assigned 2 624 CRM MaintainPersonalIncidents Can Add/Edit/Delete Incidents when Owner or Assigned 2 628 CRM MaintainPersonalProjects Can Add/Edit/Delete Projects when Owner or Assigned 2 442 CRM ViewPersonalToDoItems Can View ToDoItems when Owner or Assigned 4 617 CRM ViewPersonalContacts Can View Contacts when Owner or Assigned 4 619 CRM ViewPersonalCRMAccounts Can View CRM Accounts when Owner or Assigned 4 621 CRM ViewPersonalOpportunities Can View Opportunities when Owner or Assigned 4 623 CRM ViewPersonalIncidents Can View Incidents when Owner or Assigned 4 625 CRM ViewPersonalIncidentHistory Can View Incident History when Owner or Assigned 4 627 CRM ViewPersonalProjects Can View Projects when Owner or Assigned 4 629 Accounting VoidPostedVouchers Can void posted A/P Vouchers. \N 630 Accounting VoidPostedARCreditMemos Can void posted A/R Credit Memos. \N 631 Accounting VoidPostedInvoices Can void posted A/R Invoices. \N 516 Accounting VoidPostedCashReceipts Can void posted A/R Cash Receipts. \N 632 Accounting MaintainTaxRegistrations Can Add/Edit/Delete Tax Registrations. \N 633 Accounting ViewTaxRegistrations Can View Tax Registrations. \N 634 Accounting PostFrozenPeriod Can Post into frozen Accounting Period \N 639 Sales MaintainSaleTypes Can Add/Edit/Delete Sale Types. \N 640 Sales ViewSaleTypes Can View Sale Types. \N 643 Sales ConvertQuotesInvoice Can Convert Quote to Invoice. \N 644 System MaintainRegistrationKey Can Configure the Registration Key. \N 646 CRM MaintainProjectTypes Maintain Project Types \N 645 Purchase UnreleasePurchaseOrders Can Unrelease Purchase Orders. \N 647 Accounting ChangeCashRecvPostDate Can change the distribution date when posting Cash Receipts \N 648 Sales OverrideSOHoldType Allowed to override the Sales Order Hold Type \N \. -- -- Name: priv_priv_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('priv_priv_id_seq', 649, true); -- -- Data for Name: prj; Type: TABLE DATA; Schema: public; Owner: admin -- COPY prj (prj_id, prj_number, prj_name, prj_descrip, prj_status, prj_so, prj_wo, prj_po, prj_owner_username, prj_start_date, prj_due_date, prj_assigned_date, prj_completed_date, prj_username, prj_recurring_prj_id, prj_crmacct_id, prj_cntct_id, prj_prjtype_id) FROM stdin; \. -- -- Name: prj_prj_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('prj_prj_id_seq', 1, true); -- -- Data for Name: prjtask; Type: TABLE DATA; Schema: public; Owner: admin -- COPY prjtask (prjtask_id, prjtask_number, prjtask_name, prjtask_descrip, prjtask_prj_id, prjtask_anyuser, prjtask_status, prjtask_hours_budget, prjtask_hours_actual, prjtask_exp_budget, prjtask_exp_actual, prjtask_owner_username, prjtask_start_date, prjtask_due_date, prjtask_assigned_date, prjtask_completed_date, prjtask_username) FROM stdin; \. -- -- Name: prjtask_prjtask_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('prjtask_prjtask_id_seq', 1, false); -- -- Data for Name: prjtaskuser; Type: TABLE DATA; Schema: public; Owner: admin -- COPY prjtaskuser (prjtaskuser_id, prjtaskuser_prjtask_id, prjtaskuser_username) FROM stdin; \. -- -- Name: prjtaskuser_prjtaskuser_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('prjtaskuser_prjtaskuser_id_seq', 1, false); -- -- Data for Name: prjtype; Type: TABLE DATA; Schema: public; Owner: admin -- COPY prjtype (prjtype_id, prjtype_code, prjtype_descr, prjtype_active) FROM stdin; 1 Standard Standard Projects t \. -- -- Name: prjtype_prjtype_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('prjtype_prjtype_id_seq', 1, false); -- -- Data for Name: prodcat; Type: TABLE DATA; Schema: public; Owner: admin -- COPY prodcat (prodcat_id, prodcat_code, prodcat_descrip) FROM stdin; 28 STANDARD Standard \. -- -- Name: prodcat_prodcat_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('prodcat_prodcat_id_seq', 30, true); -- -- Data for Name: prospect; Type: TABLE DATA; Schema: public; Owner: admin -- COPY prospect (prospect_id, prospect_active, prospect_number, prospect_name, prospect_cntct_id, prospect_comments, prospect_created, prospect_salesrep_id, prospect_warehous_id, prospect_taxzone_id) FROM stdin; \. -- -- Data for Name: qryhead; Type: TABLE DATA; Schema: public; Owner: admin -- COPY qryhead (qryhead_id, qryhead_name, qryhead_descrip, qryhead_notes, qryhead_username, qryhead_updated) FROM stdin; \. -- -- Name: qryhead_qryhead_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('qryhead_qryhead_id_seq', 1, false); -- -- Data for Name: qryitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY qryitem (qryitem_id, qryitem_qryhead_id, qryitem_name, qryitem_order, qryitem_src, qryitem_group, qryitem_detail, qryitem_notes, qryitem_username, qryitem_updated) FROM stdin; \. -- -- Name: qryitem_qryitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('qryitem_qryitem_id_seq', 1, false); -- -- Data for Name: quhead; Type: TABLE DATA; Schema: public; Owner: admin -- COPY quhead (quhead_id, quhead_number, quhead_cust_id, quhead_quotedate, quhead_shipto_id, quhead_shiptoname, quhead_shiptoaddress1, quhead_shiptoaddress2, quhead_shiptoaddress3, quhead_shiptocity, quhead_shiptostate, quhead_shiptozipcode, quhead_shiptophone, quhead_salesrep_id, quhead_terms_id, quhead_freight, quhead_ordercomments, quhead_shipcomments, quhead_billtoname, quhead_billtoaddress1, quhead_billtoaddress2, quhead_billtoaddress3, quhead_billtocity, quhead_billtostate, quhead_billtozip, quhead_commission, quhead_custponumber, quhead_fob, quhead_shipvia, quhead_warehous_id, quhead_packdate, quhead_prj_id, quhead_misc, quhead_misc_accnt_id, quhead_misc_descrip, quhead_billtocountry, quhead_shiptocountry, quhead_curr_id, quhead_imported, quhead_expire, quhead_calcfreight, quhead_shipto_cntct_id, quhead_shipto_cntct_honorific, quhead_shipto_cntct_first_name, quhead_shipto_cntct_middle, quhead_shipto_cntct_last_name, quhead_shipto_cntct_suffix, quhead_shipto_cntct_phone, quhead_shipto_cntct_title, quhead_shipto_cntct_fax, quhead_shipto_cntct_email, quhead_billto_cntct_id, quhead_billto_cntct_honorific, quhead_billto_cntct_first_name, quhead_billto_cntct_middle, quhead_billto_cntct_last_name, quhead_billto_cntct_suffix, quhead_billto_cntct_phone, quhead_billto_cntct_title, quhead_billto_cntct_fax, quhead_billto_cntct_email, quhead_taxzone_id, quhead_taxtype_id, quhead_ophead_id, quhead_status, quhead_saletype_id, quhead_shipzone_id) FROM stdin; \. -- -- Name: quhead_quhead_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('quhead_quhead_id_seq', 86, true); -- -- Data for Name: quitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY quitem (quitem_id, quitem_quhead_id, quitem_linenumber, quitem_itemsite_id, quitem_scheddate, quitem_qtyord, quitem_unitcost, quitem_price, quitem_custprice, quitem_memo, quitem_custpn, quitem_createorder, quitem_order_warehous_id, quitem_item_id, quitem_prcost, quitem_imported, quitem_qty_uom_id, quitem_qty_invuomratio, quitem_price_uom_id, quitem_price_invuomratio, quitem_promdate, quitem_taxtype_id, quitem_dropship, quitem_itemsrc_id, quitem_pricemode) FROM stdin; \. -- -- Name: quitem_quitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('quitem_quitem_id_seq', 89, true); -- -- Data for Name: rcalitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY rcalitem (rcalitem_id, rcalitem_calhead_id, rcalitem_offsettype, rcalitem_offsetcount, rcalitem_periodtype, rcalitem_periodcount, rcalitem_name) FROM stdin; 135 47 W 0 W 1 W1 136 47 W 1 W 1 W2 137 47 W 2 W 1 W3 138 47 W 3 W 1 W4 139 47 W 4 W 1 W5 140 47 W 5 W 1 W6 141 47 W 6 W 1 W7 142 47 W 7 W 1 W8 143 48 M -1 M 1 1M 144 48 M -2 M 1 2M 145 48 M -3 M 1 3M \. -- -- Data for Name: recur; Type: TABLE DATA; Schema: public; Owner: admin -- COPY recur (recur_id, recur_parent_id, recur_parent_type, recur_period, recur_freq, recur_start, recur_end, recur_max, recur_data) FROM stdin; \. -- -- Name: recur_recur_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('recur_recur_id_seq', 1, false); -- -- Data for Name: recurtype; Type: TABLE DATA; Schema: public; Owner: admin -- COPY recurtype (recurtype_id, recurtype_type, recurtype_table, recurtype_donecheck, recurtype_schedcol, recurtype_limit, recurtype_copyfunc, recurtype_copyargs, recurtype_delfunc) FROM stdin; 4 I invchead invchead_posted invchead_invcdate \N copyinvoice {integer,date} deleteinvoice 3 J prj (prj_completed_date IS NOT NULL OR prj_status = 'C') prj_due_date \N copyprj {int,date} \N 5 V vohead vohead_posted vohead_docdate \N copyvoucher {integer,date} \N 2 INCDT incdt incdt_status IN ('R', 'L') incdt_timestamp \N copyincdt {int,timestamp} deleteincident 1 TODO todoitem todoitem_completed_date IS NOT NULL todoitem_due_date checkprivilege('MaintainAllToDoItems') OR (checkprivilege('MaintainPersonalToDoItems') AND CURRENT_USER IN (todoitem_owner_username, todoitem_username)) copytodoitem {int,date,NULL} \N \. -- -- Name: recurtype_recurtype_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('recurtype_recurtype_id_seq', 5, true); -- -- Data for Name: recv; Type: TABLE DATA; Schema: public; Owner: admin -- COPY recv (recv_id, recv_order_type, recv_order_number, recv_orderitem_id, recv_agent_username, recv_itemsite_id, recv_vend_id, recv_vend_item_number, recv_vend_item_descrip, recv_vend_uom, recv_purchcost, recv_purchcost_curr_id, recv_duedate, recv_qty, recv_recvcost, recv_recvcost_curr_id, recv_freight, recv_freight_curr_id, recv_date, recv_value, recv_posted, recv_invoiced, recv_vohead_id, recv_voitem_id, recv_trans_usr_name, recv_notes, recv_gldistdate, recv_splitfrom_id, recv_rlsd_duedate) FROM stdin; \. -- -- Name: recv_recv_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('recv_recv_id_seq', 1, true); -- -- Data for Name: report; Type: TABLE DATA; Schema: public; Owner: admin -- COPY report (report_id, report_name, report_sys, report_source, report_descrip, report_grade, report_loaddate) FROM stdin; 452 BacklogByParameterList \N \n\n Backlog By Parameter List\n BacklogByParameterList\n \n \n \n \n \n \n \n \n \n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT CASE WHEN (checkPrivilege('ViewCustomerPrices') \n AND isMultiCurr()) THEN\n text('Amount(base)')\n WHEN (checkPrivilege('ViewCustomerPrices')) THEN\n text('Amount')\n ELSE\n text('')\n END\n AS lbl_baseamount,\n CASE WHEN (checkPrivilege('ViewCustomerPrices') \n AND isMultiCurr()) THEN\n text('Amount(foreign)')\n ELSE\n text('')\n END\n AS lbl_foreignamount;\n \n \n detail\n SELECT cohead_number, coitem_linenumber, cust_name,\n formatDate(cohead_orderdate) AS f_orderdate,\n formatDate(coitem_scheddate) AS f_scheddate,\n item_number, uom_name,\n item_descrip1, item_descrip2,\n formatQty(coitem_qtyord) AS f_qtyord,\n formatQty(coitem_qtyshipped) AS f_qtyship,\n formatQty(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned)) AS f_balance, \n CASE WHEN (checkPrivilege('ViewCustomerPrices')) THEN\nformatMoney(round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio)\n * (currtobase(cohead_curr_id,coitem_price,cohead_orderdate) / coitem_price_invuomratio),2))\n ELSE\n text('')\n END\n AS f_ammount,\n CASE WHEN (checkPrivilege('ViewCustomerPrices') AND isMultiCurr()) THEN\nformatMoney(round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio)\n * (coitem_price / coitem_price_invuomratio),2))\n ELSE\n text('')\n END\n AS foreign_ammount,\nround((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio)\n * (currtobase(cohead_curr_id,coitem_price,cohead_orderdate) / coitem_price_invuomratio),2) AS backlog \n FROM cohead, coitem, itemsite, item, cust, uom\n WHERE ((coitem_cohead_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (coitem_status='O')\n <? if exists("cohead_id") ?>\n AND (coitem_cohead_id=<? value("cohead_id") ?>)\n <? endif ?>\n <? if exists("startDate") ?>\n AND (cohead_orderdate >= <? value("startDate") ?>)\n <? endif ?>\n <? if exists("endDate") ?>\n AND (cohead_orderdate <= <? value("endDate") ?>)\n <? endif ?>\n <? if exists("startDateSched") ?>\n AND (coitem_scheddate >= <? value("startDateSched") ?>)\n <? endif ?>\n <? if exists("endDateSched") ?>\n AND (coitem_scheddate >= <? value("endDateSched") ?>)\n <? endif ?>\n <? if exists("salesrep_id") ?>\n AND (cohead_salesrep_id=<? value("salesrep_id") ?>)\n <? endif ?>\n <? if exists("shipto_id") ?>\n AND (cohead_shipto_id=<? value("shipto_id") ?>)\n <? endif ?>\n <? if exists("cust_id") ?>\n AND (cohead_cust_id=<? value("cust_id") ?>)\n <? endif ?>\n <? if exists("custtype_id") ?>\n AND (cust_custtype_id=<? value("custtype_id") ?>)\n <? endif ?>\n <? if exists("custtype_pattern") ?>\n AND (cust_custtype_id IN (SELECT DISTINCT custtype_id\n FROM custtype\n WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n <? endif ?>\n <? if exists("custgrp") ?>\n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrpitem))\n <? endif ?>\n <? if exists("custgrp_id") ?>\n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrpitem\n WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)))\n <? endif ?>\n <? if exists("custgrp_pattern") ?>\n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrp, custgrpitem\n WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n AND (custgrp_name ~ <? value("custgrp_pattern") ?>) )) )\n <? endif ?>\n\n <? if exists("item_id") ?>\n AND (itemsite_item_id=<? value("item_id") ?>)\n <? endif ?>\n <? if exists("prodcat_id") ?>\n AND (item_prodcat_id=<? value("prodcat_id") ?>)\n <? endif ?>\n <? if exists("prodcat_pattern") ?>\n AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n FROM prodcat\n WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n <? endif ?>\n\n <? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n <? endif ?>\n)\nORDER BY coitem_scheddate, cohead_number, coitem_linenumber;\n \n \n total\n SELECT now()\n WHERE 't' =\nCASE WHEN (checkPrivilege('ViewCustomerPrices') \n 't'\nELSE\n 'f'\nEND\n \n \n 226\n \n \n \n \n \n 660\n 185\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_baseamount\n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n 660\n 200\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_foreignamount\n \n \n \n \n \n \n \n \n \n \n \n \n \n 5\n 28\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n \n \n \n \n \n \n \n 660\n 0\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_baseamount\n \n \n \n \n 660\n 15\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_foreignamount\n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 52\n \n \n 305\n 30\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 65\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n coitem_linenumber\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 305\n 15\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 507\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyship\n \n \n \n \n 671\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n foreign_ammount\n \n \n \n \n 305\n 0\n 140\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 670\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ammount\n \n \n \n \n 450\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n \n 225\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_orderdate\n \n \n \n \n 507\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyord\n \n \n \n \n 225\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_scheddate\n \n \n \n \n 112\n 0\n 110\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_name\n \n \n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_balance\n \n \n \n \n 5\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cohead_number\n \n \n \n
\n
\n totals\n \n \n total\n \n 18\n \n \n \n 670\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n backlog\n \n money\n \n \n \n
\n \n 18\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n \N 0 2011-02-16 10:09:03.839762 29 TimePhasedUsageStatisticsByItem \N \n\n Time Phased Usage Statistics By Item\n TimePhasedUsageStatisticsByItem\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number, item_descrip1, item_descrip2,\n CASE WHEN (%2=-1) THEN 'All Warehouses'\n ELSE ( SELECT warehous_code\n FROM warehous\n WHERE (warehous_id=%2) )\n END AS warehouse\nFROM item\nWHERE (item_id=%1);\n \n \n detail\n SELECT findPeriodStart(rcalitem_id) AS pstart,\n findPeriodEnd(rcalitem_id) AS pend,\n (formatDate(findPeriodStart(rcalitem_id)) || '-' || formatDate(findPeriodEnd(rcalitem_id))) AS period,\n warehous_code,\n formatQty(summTransR(itemsite_id, rcalitem_id)) AS received,\n formatQty(summTransI(itemsite_id, rcalitem_id)) AS issued,\n formatQty(summTransS(itemsite_id, rcalitem_id)) AS sold,\n formatQty(summTransC(itemsite_id, rcalitem_id)) AS scrap,\n formatQty(summTransA(itemsite_id, rcalitem_id)) AS adjustments\n FROM rcalitem, itemsite, warehous\n WHERE ((rcalitem_id in (%4))\n AND (itemsite_warehous_id=warehous_id)\n AND (itemsite_item_id=%1)\n AND ((%2=-1) OR (itemsite_warehous_id=%2)) )\n UNION\nSELECT findPeriodStart(acalitem_id) AS pstart,\n findPeriodEnd(acalitem_id) AS pend,\n (formatDate(findPeriodStart(acalitem_id)) || '-' || formatDate(findPeriodEnd(acalitem_id))) AS period,\n warehous_code,\n formatQty(summTransR(itemsite_id, acalitem_id)) AS received,\n formatQty(summTransI(itemsite_id, acalitem_id)) AS issued,\n formatQty(summTransS(itemsite_id, acalitem_id)) AS sold,\n formatQty(summTransC(itemsite_id, acalitem_id)) AS scrap,\n formatQty(summTransA(itemsite_id, acalitem_id)) AS adjustments\n FROM acalitem, itemsite, warehous\n WHERE ((acalitem_id IN (%4))\n AND (itemsite_warehous_id=warehous_id)\n AND (itemsite_item_id=%1)\n AND ((%2=-1) OR (itemsite_warehous_id=%2)) )\nORDER BY pstart, warehous_code;\n \n \n 221\n \n \n \n \n \n \n 140\n 140\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n 140\n 120\n 385\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n 5\n 215\n 740\n 215\n 2\n \n \n \n \n \n \n 140\n 100\n 385\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n \n \n 140\n 80\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n \n \n 5\n 15\n 740\n 15\n 2\n \n \n \n \n
\n detail\n \n detail\n pstart\n \n 6\n \n \n 10\n 5\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n period\n \n \n \n \n \n \n detail\n \n 16\n \n \n 490\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n sold\n \n \n \n \n 575\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n scrap\n \n \n \n \n 405\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n issued\n \n \n \n \n 270\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 660\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n adjustments\n \n \n \n \n 320\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n received\n \n \n \n
\n \n 16\n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 690\n 0\n 51\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2004-02-10 10:24:16.076157 480 ContractActivity \N \n\n Contract Activity Summary Report\n ContractActivity\n \n \n \n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 25\n 25\n \n head\n select contrct_id,\n contrct_number,\n contrct_vend_id,\n contrct_descrip,\n contrct_effective,\n contrct_expires,\n contrct_note,\n vend_number,\n vend_name\n from contrct JOIN vendinfo ON (vend_id = contrct_vend_id)\n where contrct_id = <? value("contrct_id") ?>;\n \n \n \n detail\n -- Group: contrct\n-- Name: itemsources\n-- Notes: Selection of Contract Related Item Sources\nSELECT itemsrc_id,\n\t-1 AS pohead_id, \n\t' ' AS seq,\n\t' ' AS poitem_ordnumber, \n item_number,\n\titem_descrip1,\n\titemsrc_vend_uom,\n\titemsrc_vend_item_number,\n\titemsrc_contrct_min,\n\tsum(poitem_qty_unreleased) AS poitem_qty_unreleased,\n\tsum(poitem_qty_ordered) AS poitem_qty_ordered,\n\tsum(poitem_qty_received) AS poitem_qty_received,\n\tsum(poitem_qty_returned) AS poitem_qty_returned,\n\tnull AS poitem_duedate,\n\tnull AS poitem_status,\n\t0 AS xtindentrole \n\tFROM (SELECT contrct_id, \n\t\titemsrc_id,\n\t\tpohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n\t\titem_number,\n\t\titem_descrip1,\n\t\titemsrc_vend_uom,\n\t\titemsrc_vend_item_number,\n\t\titemsrc_contrct_min,\n\t\tCASE WHEN poitem_status = 'U' THEN poitem_qty_ordered\n\t\t ELSE 0\n\t\tEND AS poitem_qty_unreleased,\n\t\tCASE WHEN poitem_status = 'O' THEN poitem_qty_ordered\n\t\t WHEN poitem_status = 'C' THEN poitem_qty_ordered\n ELSE 0\n\t\tEND AS poitem_qty_ordered,\n\t\tpoitem_qty_received,\n\t\tpoitem_qty_returned,\n\t\tpoitem_duedate, \n\t\tpoitem_status\n\t\tFROM contrct JOIN itemsrc ON (itemsrc_contrct_id = contrct_id)\n\t\t LEFT OUTER JOIN poitem ON (poitem_itemsrc_id = itemsrc_id)\n\t\t LEFT OUTER JOIN pohead ON (pohead_id = poitem_pohead_id)\n\t\t\t JOIN item ON (itemsrc_item_id = item_id)\n\t\tWHERE (contrct_id = <? value("contrct_id") ?>)) AS dummy1\n\tWHERE (contrct_id = <? value("contrct_id") ?>)\n\tGROUP BY itemsrc_id, itemsrc_vend_item_number, itemsrc_vend_uom, itemsrc_contrct_min,\n item_number, item_descrip1\n\nUNION -- PO Line Items\n\nSELECT itemsrc_id,\n\tpohead_id, \n\tpohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS seq,\n pohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n null AS item_number,\n\tnull AS item_descrip1,\n\tnull AS itemsrc_vend_uom,\n\tnull AS itemsrc_vend_item_number,\n\tnull AS itemsrc_contrct_min,\n\tCASE WHEN poitem_status = 'U' THEN poitem_qty_ordered\n\t ELSE 0\n\tEND AS poitem_qty_unreleased,\n\tCASE WHEN poitem_status = 'O' THEN poitem_qty_ordered\n\t WHEN poitem_status = 'C' THEN poitem_qty_ordered\n ELSE 0\n\tEND AS poitem_qty_ordered,\n\tpoitem_qty_received,\n\tpoitem_qty_returned,\n\tto_char(poitem_duedate, 'YYYY-MM-DD HH24:MI:SS'), \n\tCASE WHEN poitem_status = 'O' THEN 'Open'\n\t WHEN poitem_status = 'C' THEN 'Closed'\n\t ELSE 'Unreleased'\n\tEND AS poitem_status,\n\t1 AS xtindentrole \n\tFROM contrct JOIN itemsrc ON (itemsrc_contrct_id = contrct_id)\n\t\t JOIN poitem ON (poitem_itemsrc_id = itemsrc_id)\n\t\t JOIN pohead ON (pohead_id = poitem_pohead_id)\n\t\t JOIN item ON (itemsrc_item_id = item_id)\n\tWHERE (contrct_id = <? value("contrct_id") ?>)\n\nUNION -- Receipts\n\nSELECT itemsrc_id,\n\tpohead_id, \n\tpoitem_ordnumber || 'R' || to_char(recv_date, 'YYYYMMDDHH24:MI:SS') AS seq,\n\t'Receipt' AS poitem_ordnumber,\n\tnull AS item_number,\n\tnull AS item_descrip1,\n\trecv_vend_uom AS vend_uom,\n\tnull AS itemsrc_vend_item_number,\n\tnull AS itemsrc_contrct_min,\n\tnull AS poitem_qty_unreleased,\n\tnull AS poitem_qty_ordered,\n\trecv_qty AS poitem_qty_received,\n\tnull AS poitem_qty_returned,\n\tto_char(recv_date, 'YYYY-MM-DD HH24:MI:SS') AS poitem_duedate,\n\trecv_trans_usr_name AS username,\n\t2 AS xtindentrole\n FROM recv JOIN (SELECT pohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n\t\t\t poitem_pohead_id, poitem_linenumber, poitem_id, pohead_id, \n\t\t\t poitem_itemsrc_id\n\t\t\tFROM poitem JOIN pohead ON (pohead_id = poitem_pohead_id)) AS dummy ON (poitem_id = recv_orderitem_id)\n JOIN itemsite ON (itemsite_id = recv_itemsite_id)\n JOIN item ON (item_id = itemsite_item_id)\n JOIN itemsrc ON (poitem_itemsrc_id = itemsrc_id)\n WHERE (itemsrc_contrct_id = <? value("contrct_id") ?>) \n\nUNION -- Returns\n\nSELECT itemsrc_id, \n\tpohead_id, \n\tpoitem_ordnumber || 'R' || to_char(poreject_date, 'YYYYMMDDHH24:MI:SS') AS seq,\n\t'Return' AS poitem_ordnumber,\n\tnull AS item_number,\n\tnull AS item_descrip1,\n\tporeject_vend_uom AS vend_uom,\n\tnull AS itemsrc_vend_item_number,\n\tnull AS itemsrc_contrct_min,\n\tnull AS poitem_qty_unreleased,\n\tnull AS poitem_qty_ordered,\n\tnull AS poitem_qty_received,\n\tporeject_qty AS poitem_qty_returned,\n\tto_char(poreject_date, 'YYYY-MM-DD HH24:MI:SS') AS poitem_duedate,\n\tporeject_trans_username AS username,\n\t2 AS xtindentrole \n FROM poreject JOIN (SELECT pohead_number || '-' || ltrim(to_char(poitem_linenumber, '999')) AS poitem_ordnumber, \n\t\t\t poitem_pohead_id, poitem_linenumber, poitem_id, pohead_id, \n\t\t\t poitem_itemsrc_id\n\t\t\tFROM poitem JOIN pohead ON (pohead_id = poitem_pohead_id)) AS dummy ON (poitem_id = poreject_poitem_id)\n JOIN itemsite ON (itemsite_id = poreject_itemsite_id)\n JOIN item ON (item_id = itemsite_item_id)\n JOIN itemsrc ON (poitem_itemsrc_id = itemsrc_id)\n WHERE (itemsrc_contrct_id = <? value("contrct_id") ?>) \n\nORDER BY itemsrc_id, seq, poitem_ordnumber, poitem_duedate, xtindentrole;\n\n \n \n 183\n \n \n 135\n 55\n 598\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n contrct_descrip\n \n \n \n \n 85\n 120\n 275\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n vend_name\n \n \n \n \n 205\n 10\n 171\n 35\n \n \n Arial\n 18\n bold\n \n \n \n \n head\n contrct_number\n \n \n \n \n \n \n \n \n 85\n 140\n 150\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n contrct_effective\n \n \n \n \n \n 85\n 160\n 150\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n contrct_expires\n \n \n \n \n 85\n 100\n 140\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n vend_number\n \n \n \n \n \n \n 415\n 100\n 330\n 20\n \n 0\n \n Arial\n 10\n normal\n \n \n \n \n head\n contrct_note\n \n \n \n \n \n 6\n \n \n 36\n \n 5\n 30\n 1045\n 30\n 1\n \n \n
\n detail\n \n ItemSource\n itemsrc_id\n \n 30\n \n 3.5\n 23.5\n 1043.5\n 23.5\n 1\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 10\n \n \n \n PurchaseOrder\n pohead_id\n \n 10\n \n 458.5\n 3.5\n 1043.5\n 3.5\n 1\n \n \n \n \n \n detail\n \n 25\n \n \n 885\n 5\n 110\n 20\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n poitem_duedate\n \n \n \n \n 5\n 5\n 65\n 20\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n item_number\n \n \n \n \n 810\n 5\n 65\n 20\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n poitem_qty_returned\n \n qty\n \n \n \n 345\n 5\n 155\n 20\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 740\n 5\n 65\n 20\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n poitem_qty_received\n \n qty\n \n \n \n 530\n 5\n 65\n 20\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n itemsrc_contrct_min\n \n qty\n \n \n \n 670\n 5\n 65\n 20\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n poitem_qty_ordered\n \n qty\n \n \n \n 80\n 5\n 185\n 20\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 1000\n 5\n 45\n 20\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n poitem_status\n \n \n \n \n 460\n 5\n 65\n 20\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n poitem_ordnumber\n \n \n \n \n 275\n 5\n 65\n 20\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n itemsrc_vend_item_number\n \n \n \n \n 600\n 5\n 65\n 20\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n poitem_qty_unreleased\n \n qty\n \n \n
\n \n 27.4814\n \n \n \n 1000\n 7.4814\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 95\n 7.4814\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 27.5186\n \n
\n \N 0 2014-03-20 16:31:52.238383 138 ExpediteExceptionsByPlannerCode \N \n\n Expedite Exceptions by Planner Code\n ExpediteExceptionsByPlannerCode\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("plancode_id") ?>\n ( SELECT (plancode_code || '-' || plancode_name)\n FROM plancode\n WHERE (plancode_id=<? value("plancode_id") ?>) )\n <? elseif exists("plancode_pattern") ?>\n text(<? value("plancode_pattern") ?>)\n <? else ?>\n text('All Planner Codes')\n <? endif ?>\n AS plannercode,\n <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM warehous\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse;\n \n \n detail\n SELECT planord_id AS order_id, 1 AS order_code,\n CASE WHEN (planord_type='W') THEN ('PW/O-' || formatPloNumber(planord_id))\n WHEN (planord_type='P') THEN ('PP/O-' || formatPloNumber(planord_id))\n ELSE text(planord_number)\n END AS order_number,\n warehous_code, item_number, item_descrip1, item_descrip2,\n CASE WHEN (planord_type='W') THEN formatDate(planord_startdate)\n ELSE formatDate(planord_duedate)\n END AS f_keydate,\n CASE WHEN (planord_type='W') THEN planord_startdate\n ELSE planord_duedate\n END AS keydate, 'Release Order' AS exception \n FROM planord, itemsite, item, warehous \n WHERE ( (planord_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND ( ( (planord_type='W') AND (planord_startdate <= (CURRENT_DATE + <? value("lookAheadDays") ?>)) )\n OR ( (planord_type='P') AND (planord_duedate <= (CURRENT_DATE + <? value("lookAheadDays") ?>)) ) ) \n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("plancode_id") ?>\n AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n AND (itemsite_plancode_id IN (SELECT plancode_id FROM plancode WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? endif ?>\n)\n\nUNION SELECT wo_id AS order_id, 2 AS order_code, ('W/O-' || formatWoNumber(wo_id)) AS order_number,\n warehous_code, item_number, item_descrip1, item_descrip2,\n formatDate(wo_startdate) AS f_keydate, wo_startdate AS keydate, 'Start Production' AS exception \nFROM wo, itemsite, item, warehous \nWHERE ( (wo_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (wo_status IN ('O', 'E', 'R'))\n AND (wo_startdate <= (CURRENT_DATE + <? value("lookAheadDays") ?>))\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("plancode_id") ?>\n AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n AND (itemsite_plancode_id IN (SELECT plancode_id FROM plancode WHERE (plancode_code ~ <? value("plancode_pattern")?>)))\n<? endif ?>\n)\n\nUNION SELECT wo_id AS order_id, 2 AS order_code, ('W/O-' || formatWoNumber(wo_id)) AS order_number,\n warehous_code, item_number, item_descrip1, item_descrip2,\n formatDate(wo_startdate) AS f_keydate, wo_startdate AS keydate, 'Expedite Production' AS exception \nFROM wo, itemsite, item, warehous \nWHERE ( (wo_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (wo_status='I')\n AND (wo_startdate <= (CURRENT_DATE + <? value("lookAheadDays") ?>))\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("plancode_id") ?>\n AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n AND (itemsite_plancode_id IN (SELECT plancode_id FROM plancode WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? endif ?>\n)\norder by keydate;\n \n \n 223\n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n 140\n 140\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n lookAheadDays\n \n \n \n \n \n \n \n \n 140\n 100\n 385\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n plannercode\n \n \n \n \n \n 140\n 120\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n \n \n \n 7\n \n \n 42\n \n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n \n
\n detail\n \n \n detail\n \n 53\n \n \n 490\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_keydate\n \n \n \n \n 595\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n exception\n \n \n \n \n 105\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 150\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 150\n 15\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 150\n 0\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 5\n 0\n 95\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n order_number\n \n \n \n
\n \n 18\n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n \N 0 2008-07-25 16:13:56.085815 202 PurchaseRequestsByPlannerCode \N \n\n Purchase Requests By Planner Code\n PurchaseRequestsByPlannerCode\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT CASE WHEN('%1'='-1') THEN 'All Planner Codes'\n WHEN((SELECT count(*)\n FROM plancode\n WHERE plancode_code = '%1') = 1) THEN\n (SELECT ()\n FROM plancode\n WHERE plancode_code = '%1')\n ELSE '%1'::text\n END AS plancode,\n CASE WHEN(%2=-1) THEN 'All Warehouses'\n ELSE (SELECT warehous_code\n FROM warehous\n WHERE warehous_id=%2)\n END AS warehouse;\n \n \n detail\n SELECT item_number,\n (item_descrip1 || ' ' || item_descrip2) as item_descrip,\n pr_status,\n CASE WHEN (pr_order_type='W') THEN ('W/O ' || ( SELECT formatWoNumber(womatl_wo_id)\n FROM womatl\n WHERE (womatl_id=pr_order_id) ) )\n WHEN (pr_order_type='S') THEN ('S/O ' || (SELECT formatSoNumber(pr_order_id)))\n WHEN (pr_order_type='F') THEN ('Planned Order')\n WHEN (pr_order_type='M') THEN 'Manual'\n ELSE 'Other'\n END AS f_type,\n formatDate(pr_duedate) AS f_duedate,\n formatQty(pr_qtyreq) AS f_qtyreq\n FROM pr, itemsite, item\n WHERE ( (pr_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=%2)\n AND (itemsite_plancode_id IN (SELECT plancode_id FROM plancode WHERE (plancode_code ~ '%1') ) )\n)\nORDER BY pr_duedate;\n \n \n 171\n \n \n \n \n \n \n \n 135\n 65\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n plancode\n \n \n \n \n 555\n 65\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n 3\n \n \n \n \n 135\n 85\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n 5\n 165\n 745\n 165\n 2\n \n \n \n \n \n \n \n 555\n 85\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n 4\n \n \n \n \n \n \n \n 6\n \n \n 26\n \n \n \n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 340\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n pr_status\n \n \n \n \n 135\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip\n \n \n \n \n 425\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_type\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyreq\n \n \n \n \n 10\n 0\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_duedate\n \n \n \n
\n \n 16\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 105\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2004-02-10 10:24:16.076157 204 APAssignments Master List \N \n\n A/P Account Assignments Master List\n APAssignments Master List\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT CASE WHEN apaccnt_vendtype_id=-1 THEN apaccnt_vendtype\n ELSE (SELECT vendtype_code FROM vendtype WHERE (vendtype_id=apaccnt_vendtype_id))\n END AS vendtypecode,\n formatGLAccount(apaccnt_ap_accnt_id) AS f_account\nFROM apaccnt\nORDER BY vendtypecode;\n \n \n 77\n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n \n 7\n \n \n 22\n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 17\n \n \n 10\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n venttypecode\n \n \n \n \n 120\n 0\n 500\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_account\n \n \n \n
\n \n 17\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n
\n 0 2004-02-10 10:24:16.076157 51 SequencedBOM \N \n\n Sequenced Bill of Materials\n SequencedBOM\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n uom_name AS item_invuom,\n item_descrip1,\n item_descrip2\n FROM item, uom\n WHERE ((item_id=<? value("item_id") ?>)\n AND (item_inv_uom_id=uom_id));\n \n \n \n detail\n SELECT text(booitem_seqnumber) AS booseqnumber, bomitem_seqnumber,\n item_number, uom_name AS item_invuom, item_descrip1, item_descrip2,\n formatQtyPer(bomitem_qtyper) AS qtyper,\n formatScrap(bomitem_scrap) AS scrap,\n formatQtyPer(bomitem_qtyper + (1 * bomitem_scrap)) AS qtyreq,\n formatDate(bomitem_effective, 'Always') AS effective,\n formatDate(bomitem_expires, 'Never') AS expires,\n formatBoolYN(bomitem_createwo) AS createchild,\n CASE WHEN (bomitem_issuemethod='S') THEN 'Push'\n WHEN (bomitem_issuemethod='L') THEN 'Pull'\n WHEN (bomitem_issuemethod='M') THEN 'Mixed'\n ELSE 'Special'\n END AS issuemethod\n FROM booitem(<? value("item_id") ?>), bomitem(<? value("item_id") ?>,<? value("revision_id") ?>), item, uom\n WHERE ((bomitem_item_id=item_id)\n AND (bomitem_booitem_seq_id=booitem_seq_id)\n AND (item_inv_uom_id=uom_id)\n<? if not exists("showExpired") ?>\n AND (bomitem_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (bomitem_effective <= CURRENT_DATE)\n<? endif ?>\n)\nUNION\nSELECT text('') AS booseqnumber, bomitem_seqnumber,\n item_number, uom_name AS item_invuom, item_descrip1, item_descrip2,\n formatQtyPer(bomitem_qtyper) AS qtyper,\n formatScrap(bomitem_scrap) AS scrap,\n formatQtyPer(bomitem_qtyper + (1 * bomitem_scrap)) AS qtyreq,\n formatDate(bomitem_effective, 'Always') AS effective,\n formatDate(bomitem_expires, 'Never') AS expires,\n formatBoolYN(bomitem_createwo) AS createchild,\n CASE WHEN (bomitem_issuemethod='S') THEN 'Push'\n WHEN (bomitem_issuemethod='L') THEN 'Pull'\n WHEN (bomitem_issuemethod='M') THEN 'Mixed'\n ELSE 'Special'\n END AS issuemethod\n FROM bomitem(<? value("item_id") ?>,<? value("revision_id") ?>), item, uom\n WHERE ((bomitem_item_id=item_id)\n AND (bomitem_booitem_seq_id=-1)\n AND (item_inv_uom_id=uom_id)\n<? if not exists("showExpired") ?>\n AND (bomitem_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (bomitem_effective <= CURRENT_DATE)\n<? endif ?>\n)\nORDER BY booseqnumber, bomitem_seqnumber;\n\n \n \n bomhead\n SELECT bomhead_docnum, bomhead_revision,\nformatDate(bomhead_revisiondate) AS f_revisiondate\nFROM bomhead\nWHERE ((bomhead_item_id=<? value("item_id") ?>)\nAND (bomhead_rev_id=<? value("revision_id") ?>));\n \n \n 233\n \n \n 100\n 160\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n 505\n 160\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n bomhead_revision\n \n \n \n \n 100\n 140\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n 505\n 140\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n f_revisiondate\n \n \n \n \n \n \n \n 505\n 120\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n bomhead_docnum\n \n \n \n \n \n \n \n \n \n \n \n \n 100\n 120\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n \n \n 5\n 228\n 745\n 228\n 2\n \n \n \n \n \n 6\n \n \n 36\n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 57\n \n \n 675\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n issuemethod\n \n \n \n 3\n 50\n 745\n 50\n 0\n \n \n \n 315\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyper\n \n \n \n \n 75\n 0\n 228\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 10\n 0\n 65\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n booseqnumber\n \n \n \n \n 443\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n scrap\n \n \n \n \n 75\n 15\n 228\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 675\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n expires\n \n \n \n \n 10\n 15\n 65\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n bomitem_seqnumber\n \n \n \n \n 403\n 0\n 37\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_invuom\n \n \n \n \n 525\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyreq\n \n \n \n \n 600\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n effective\n \n \n \n \n 600\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n createchild\n \n \n \n \n 75\n 30\n 228\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n
\n \n 18\n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n \N 0 2008-08-08 12:40:53.055185 293 BankrecHistory \N \n\n Bank Reconciliation History\n BankrecHistory\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n reconciled\n bankrecHistory\n reconciled\n \n \n head\n SELECT (bankaccnt_name || '-' || bankaccnt_descrip) AS f_bankaccnt,\n (formatDate(bankrec_opendate) || '-' || formatDate(bankrec_enddate)) AS f_bankrec,\n bankrec_username AS f_username, formatDate(bankrec_postdate) AS f_postdate,\n formatDate(bankrec_opendate) AS f_opendate,\n formatDate(bankrec_enddate) AS f_enddate,\n formatMoney(bankrec_openbal) AS f_openbal,\n formatMoney(bankrec_endbal) AS f_endbal,\n text('Opening Balance') AS f_opendescrip,\n text('Ending Balance') AS f_enddescrip\n FROM bankrec, bankaccnt\n WHERE ((bankrec_bankaccnt_id=bankaccnt_id)\n AND (bankrec_id=<? value("bankrec_id") ?>));\n \n \n Subtotal\n SELECT \n formatMoney(COALESCE(MAX(selrec.bankrec_endbal) +\n SUM(currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date) * -1),0)) AS amount\n-- SUM(currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date)),0)) AS amount\n FROM gltrans\n JOIN bankaccnt ON (bankaccnt_accnt_id = gltrans_accnt_id)\n JOIN bankrec selrec ON ((selrec.bankrec_bankaccnt_id = bankaccnt_id)\n AND (selrec.bankrec_id=<? value("bankrec_id") ?>))\n LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='GL')\n AND (bankrecitem_source_id=gltrans_id))\n LEFT OUTER JOIN bankrec actrec ON (actrec.bankrec_id = bankrecitem_bankrec_id)\n WHERE ((COALESCE(actrec.bankrec_postdate,endoftime()) > COALESCE(selrec.bankrec_postdate,now()))\n AND (gltrans_doctype='CK'))\n \n \n ActualAmount\n SELECT \n formatMoney(COALESCE(MAX(selrec.bankrec_endbal) +\n SUM(currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date) * -1),0)) AS amount\n-- SUM(currtolocal(bankaccnt_curr_id,gltrans_amount,gltrans_date)),0)) AS amount\n FROM gltrans\n JOIN bankaccnt ON (bankaccnt_accnt_id = gltrans_accnt_id)\n JOIN bankrec selrec ON ((selrec.bankrec_bankaccnt_id = bankaccnt_id)\n AND (selrec.bankrec_id=<? value("bankrec_id") ?>))\n LEFT OUTER JOIN bankrecitem ON ((bankrecitem_source='GL')\n\n AND (bankrecitem_source_id=gltrans_id))\n LEFT OUTER JOIN bankrec actrec ON (actrec.bankrec_id = bankrecitem_bankrec_id)\n WHERE (COALESCE(actrec.bankrec_postdate,endoftime()) > COALESCE(selrec.bankrec_postdate,now()))\n \n \n unreconciled\n bankrecHistory\n unreconciled\n \n \n 166\n \n \n \n \n 100\n 148\n 535\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_opendescrip\n \n \n \n \n \n 145\n 65\n 220\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_bankrec\n \n \n \n 5\n 115\n 745\n 115\n 2\n \n \n \n \n 145\n 50\n 245\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_bankaccnt\n \n \n \n \n 475\n 65\n 220\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_postdate\n \n \n \n \n \n \n 9\n 148\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_opendate\n \n \n \n \n 475\n 50\n 220\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_username\n \n \n \n \n \n \n 644\n 148\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_openbal\n \n \n \n \n \n \n 0\n \n \n 31\n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n
\n reconciled\n \n reconciled-group\n amount_xtnumericrole\n \n 21\n \n \n 645\n 3.28\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_endbal\n \n \n \n \n 10\n 3.28\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_enddate\n \n \n \n \n 100\n 3.28\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_enddescrip\n \n \n \n \n \n reconciled-type\n sort\n \n 27\n \n \n 10\n 6.78\n 94\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n reconciled\n type\n \n \n \n \n 18\n \n \n 645\n 2\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n reconciled\n amount\n \n qty\n \n \n \n \n 438\n 2\n 168\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n reconciled\n type\n \n \n \n \n \n \n \n reconciled\n \n 18\n \n \n 206\n 0\n 430\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n reconciled\n notes\n \n \n \n \n 645\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n reconciled\n f_amount\n \n \n \n \n 10\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n reconciled\n f_date\n \n \n \n \n 100\n -0.182\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n reconciled\n gltrans_docnumber\n \n \n \n
\n
\n unreconciled\n \n unreconciled-group\n amount_xtnumericrole\n \n 33\n \n \n \n 136.499\n \n \n \n \n \n \n \n 640\n 28\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_endbal\n \n \n \n \n 640\n 43\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n unreconciled\n rtcheck\n \n money\n \n \n \n \n \n 640\n 58\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Subtotal\n amount\n \n \n \n \n 640\n 73\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n unreconciled\n rtdep\n \n money\n \n \n \n \n 640\n 88\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n unreconciled\n rtadj\n \n money\n \n \n \n \n 640\n 103\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n ActualAmount\n amount\n \n \n \n \n \n \n unreconciled-type\n type\n \n 26.0233\n \n \n 10\n 4.9\n 94\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n unreconciled\n type\n \n \n \n \n \n \n unreconciled\n \n 21.9767\n \n \n 204\n 0.687\n 430\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n unreconciled\n notes\n \n \n \n \n 10\n 0.687\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n unreconciled\n f_date\n \n \n \n \n 98.5\n 0.687\n 94\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n unreconciled\n gltrans_docnumber\n \n \n \n \n 643\n 0.687\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n unreconciled\n f_amount\n \n \n \n
\n \n 15\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 80\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 143\n \n
\n 0 2015-10-01 17:15:58.47729 443 Bookings \N \n\n Bookings\n Bookings\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT cohead_number AS sonumber,\n formatDate(cohead_orderdate) AS orddate,\n cust_number, cust_name,\n item_number, item_descrip1, item_descrip2,\n formatQty(coitem_qtyord) AS ordered,\nformatPrice(currtobase(cohead_curr_id,coitem_price,cohead_orderdate) / coitem_price_invuomratio) AS unitprice,\nformatExtPrice(round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio)\n * (currtobase(cohead_curr_id,coitem_price,cohead_orderdate) / coitem_price_invuomratio),2)) AS f_extprice\n FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id)\n JOIN custinfo ON (cust_id=cohead_cust_id)\n JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n JOIN site() ON (warehous_id=itemsite_warehous_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN uom ON (uom_id=coitem_qty_uom_id)\n JOIN curr_symbol ON (curr_id=cohead_curr_id)\n WHERE ( (coitem_status<>'X')\n <? if exists("cohead_id") ?>\n AND (coitem_cohead_id=<? value("cohead_id") ?>)\n <? endif ?>\n <? if exists("openOnly") ?>\n AND (coitem_status<>'C')\n <? endif ?>\n <? if exists("startDate") ?>\n AND (cohead_orderdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n <? endif ?>\n\n <? if exists("salesrep_id") ?>\n AND (cohead_salesrep_id=<? value("salesrep_id") ?>)\n <? endif ?>\n <? if exists("shipto_id") ?>\n AND (cohead_shipto_id=<? value("shipto_id") ?>)\n <? endif ?>\n <? if exists("cust_id") ?>\n AND (cohead_cust_id=<? value("cust_id") ?>)\n <? endif ?>\n <? if exists("custtype_id") ?>\n AND (cust_custtype_id=<? value("custtype_id") ?>)\n <? endif ?>\n <? if exists("custtype_pattern") ?>\n AND (cust_custtype_id IN (SELECT DISTINCT custtype_id\n FROM custtype\n WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n <? endif ?>\n <? if exists("custgrp") ?>\n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrpitem))\n <? endif ?>\n <? if exists("custgrp_id") ?>\n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrpitem\n WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)))\n <? endif ?>\n <? if exists("custgrp_pattern") ?>\n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrp, custgrpitem\n WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n AND (custgrp_name ~ <? value("custgrp_pattern") ?>) )) )\n <? endif ?>\n\n <? if exists("item_id") ?>\n AND (itemsite_item_id=<? value("item_id") ?>)\n <? endif ?>\n <? if exists("prodcat_id") ?>\n AND (item_prodcat_id=<? value("prodcat_id") ?>)\n <? endif ?>\n <? if exists("prodcat_pattern") ?>\n AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n FROM prodcat\n WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n <? endif ?>\n\n <? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n <? endif ?>\n)\nORDER BY cohead_orderdate;\n \n \n \n 237\n \n \n \n \n 5\n 233\n 745\n 233\n 2\n \n \n \n \n \n \n \n \n \n \n 10\n 41\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 7\n \n \n 37\n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 52\n \n \n 585\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ordered\n \n \n \n \n 432\n 15\n 225\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 5\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n sonumber\n \n \n \n \n 432\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 665\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_extprice\n \n \n \n \n 200\n 15\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_name\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n unitprice\n \n \n \n 4\n 47\n 744\n 47\n 0\n \n \n \n 200\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_number\n \n \n \n \n 432\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 110\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n orddate\n \n \n \n
\n \n 17\n \n \n \n 102\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 270 CheckFormat \N \n\n Sample Check Format\n CheckFormat\n OpenMFG Sample A/P Check Format\n Letter\n \n 50\n 50\n 50\n 50\n \n Head\n SELECT vend_name,\n vend_address1,\n vend_address3,\n vend_address3,\n vend_city,\n vend_state,\n vend_zip,\n formatDate(apchk_checkdate) AS f_checkdate,\n formatMoney(apchk_amount) AS f_amount,\n spellAmount(apchk_amount) AS f_words,\n CASE WHEN(apchk_void) THEN text('V O I D')\n ELSE text('')\n END AS f_void,\n apchk_for\n FROM apchk, vend\n WHERE ( (apchk_vend_id=vend_id)\n AND (apchk_id=<? value("apchk_id") ?>) );\n \n \n Detail\n SELECT apchkitem_invcnumber, apchkitem_ponumber,\n formatMoney(apchkitem_amount) AS f_amount\nFROM apchkitem\nWHERE (apchkitem_apchk_id=%1)\nORDER BY apchkitem_invcnumber;\n \n \n \n 197\n \n \n \n \n \n \n 300\n 75\n 150\n 40\n \n \n Arial\n 18\n bold\n \n \n \n \n Head\n f_void\n \n \n \n \n 60\n 30\n 150\n 40\n \n \n Arial\n 18\n bold\n \n \n \n \n Head\n f_void\n \n \n \n \n \n 60\n 155\n 325\n 20\n \n \n Helvetica\n 12\n normal\n \n \n \n \n Head\n apchk_for\n \n \n \n \n 555\n 30\n 150\n 40\n \n \n Arial\n 18\n bold\n \n \n \n \n Head\n f_void\n \n \n \n \n 60\n 120\n 150\n 40\n \n \n Arial\n 18\n bold\n \n \n \n \n Head\n f_void\n \n \n \n \n 85\n 75\n 185\n 20\n \n \n Helvetica\n 12\n normal\n \n \n \n \n Head\n vend_name\n \n \n \n \n 555\n 20\n 121\n 20\n \n \n Helvetica\n 12\n normal\n \n \n \n \n Head\n f_checkdate\n \n \n \n \n 45\n 100\n 675\n 20\n \n \n Helvetica\n 12\n normal\n \n \n \n \n Head\n f_words\n \n \n \n \n 555\n 120\n 150\n 40\n \n \n Arial\n 18\n bold\n \n \n \n \n Head\n f_void\n \n \n \n \n 555\n 75\n 150\n 20\n \n \n Helvetica\n 12\n normal\n \n \n \n \n Head\n f_amount\n \n \n \n
\n Apchkitem\n \n \n Detail\n \n 22\n \n \n 509\n 0\n 100\n 20\n \n \n Helvetica [Urw]\n 10\n normal\n \n \n \n \n Detail\n f_amount\n \n \n \n \n 390\n 0\n 100\n 20\n \n \n Helvetica [Urw]\n 10\n normal\n \n \n \n \n Detail\n apchkitem_ponumber\n \n \n \n \n 270\n 0\n 100\n 20\n \n \n Helvetica [Urw]\n 10\n normal\n \n \n \n \n Detail\n apchkitem_invcnumber\n \n \n \n
\n
\n OpenMFG Sample A/P Check Format 0 2004-08-26 10:48:34.979983 254 APOpenItemsByVendor \N \n\n Open Payables\n APOpenItemsByVendor\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT \n<? if exists("vend_id") ?>\n (SELECT vend_name FROM vendinfo WHERE vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n (SELECT vendtype_code FROM vendtype WHERE vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n ('Vendor Type pattern = ' || <? value("vendtype_pattern") ?>)\n<? else ?>\n 'All Vendors'\n<? endif ?>\n AS selection,\n currConcat(baseCurrId()) AS baseCurr,\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n formatDate(<? value("asofDate") ?>) AS asofDate;\n \n \n detail\n apOpenItems\n detail\n \n \n 166\n \n 5\n 160\n 745\n 160\n 2\n \n \n \n \n \n \n 550\n 108\n 100\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n asofDate\n \n \n \n \n \n \n 550\n 65\n 100\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n \n \n 550\n 83\n 100\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n \n \n 695\n 143\n 50\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n baseCurr\n \n \n \n \n \n \n 110\n 65\n 250\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n selection\n \n \n \n \n \n \n 6\n \n \n 26\n \n \n \n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n \n \n \n 695\n 4\n 50\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n baseCurr\n \n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 305\n 2\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_docdate\n \n \n \n \n 250\n 2\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n apopen_ponumber\n \n \n \n \n 585\n 2\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_balance\n \n \n \n \n 530\n 2\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_paid\n \n \n \n \n 5\n 2\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_doctype\n \n \n \n \n 390\n 2\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_duedate\n \n \n \n \n 475\n 2\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_amount\n \n \n \n \n 75\n 2\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n apopen_docnumber\n \n \n \n \n 695\n 2\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_base_balance\n \n \n \n \n 640\n 2\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n currAbbr\n \n \n \n \n 130\n 2\n 115\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_name\n \n \n \n
\n \n 16\n \n \n 102\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 16\n \n \n \n 642\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n base_balance\n \n qty\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 415 ListOpenReturnAuthorizations \N \n\n List Open Return Authorizations\n ListOpenReturnAuthorizations\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM warehous\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Warehouses')\n <? endif ?>\n AS warehouse;\n\n \n \n detail\n returnAuthorizations\n detail\n \n \n 221\n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n \n \n 100\n 104\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 18\n \n \n 100\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n custnumber\n \n \n \n \n 425\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n disposition\n \n \n \n \n 535\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_authorized\n \n \n \n \n 645\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_expires\n \n \n \n \n 5\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n rahead_number\n \n \n \n \n 195\n 0\n 225\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n rahead_billtoname\n \n \n \n
\n \n 18\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n \N 0 2012-11-07 15:44:48.305076 66 EarnedCommissions \N \n\n Earned Commissions\n EarnedCommissions\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("salesrep_id") ?>\n ( SELECT salesrep_name\n FROM salesrep\n WHERE (salesrep_id=<? value("salesrep_id") ?>) )\n <? else ?>\n text('All Sales Reps')\n <? endif ?>\n AS salesrep,\n formatDate(<? value("startDate") ?>) AS startdate,\n formatDate(<? value("endDate") ?>) AS enddate;\n \n \n detail\n salesHistory\n detail\n \n \n 221\n \n \n \n \n \n 140\n 120\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n \n \n 140\n 140\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n \n \n 140\n 100\n 385\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n salesrep\n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 395\n 0\n 110\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemnumber\n \n \n \n \n 565\n 0\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_baseextprice\n \n \n \n \n 155\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_number\n \n \n \n \n 105\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cohist_ordernumber\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_commissionpaid\n \n \n \n \n 5\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n salesrep_name\n \n \n \n \n 315\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_invcdate\n \n \n \n \n 505\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyshipped\n \n \n \n \n 635\n 0\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_basecommission\n \n \n \n \n 200\n 0\n 110\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cohist_shiptoname\n \n \n \n
\n \n 16\n \n \n \n \n 90\n 1\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 1\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 16\n \n \n \n 565\n 1\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n baseextprice\n \n qty\n \n \n \n \n 635\n 1\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n basecommission\n \n qty\n \n \n \n \n 495\n 1\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cohist_qtyshipped\n \n qty\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 210 PurchaseOrder \N \n\n Purchase Order\n PurchaseOrder\n Selecting an Alt Address on the PO will cause the printed PO to display that address as the Ship To on the printed document.\n \n \n \n \n \n Head\n title\n \n 25\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 28\n 28\n 20\n 20\n \n Head\n SELECT pohead_number,\n formatDate(pohead_orderdate) AS f_orderdate,\n pohead_fob,\n pohead_shipvia,\n terms_descrip,\n vend_number,\n vend_name,\n warehous_descrip,\n pohead_agent_username,\n usr.usr_propername AS username,\n pohead_comments,\n text(<? value("title") ?>) AS title\n FROM pohead\n LEFT OUTER JOIN usr ON (pohead_agent_username = usr_username)\n LEFT OUTER JOIN terms ON (pohead_terms_id = terms_id)\n LEFT OUTER JOIN vendinfo ON (pohead_vend_id = vend_id)\n LEFT OUTER JOIN whsinfo ON (pohead_warehous_id = warehous_id)\n WHERE (pohead_id=<? value("pohead_id") ?>);\n \n \n Detail\n SELECT poitem_linenumber,\n poitem_comments,\n poitem_linenumber AS f_line,\n item_number,\n poitem_vend_item_number, \n CASE WHEN (LENGTH(TRIM(BOTH '\t' FROM poitem_vend_item_descrip)) <= 0) THEN\n (item_descrip1 || '' || item_descrip2)\n ELSE (poitem_vend_item_descrip)\n END AS itemdescription,\n formatQty(poitem_qty_ordered) AS f_ordered,\n CASE WHEN (poitem_vend_uom LIKE '') THEN (uom_name)\n ELSE (poitem_vend_uom)\n END AS itemuom,\n formatPurchPrice(poitem_unitprice) AS f_price,\n formatExtPrice(poitem_unitprice * poitem_qty_ordered) AS f_extended,\n formatDate(poitem_duedate) AS f_duedate,\n characteristicsToString('PI', poitem_id, '=', ', ') AS poitem_characteristics\nFROM poitem\n\tLEFT OUTER JOIN itemsite ON (poitem_itemsite_id = itemsite_id)\n\tLEFT OUTER JOIN (item JOIN uom ON (item_inv_uom_id=uom_id)) ON (itemsite_item_id = item_id)\nWHERE \t(poitem_pohead_id=<? value("pohead_id") ?>) \nORDER BY poitem_linenumber;\n \n \n Foot\n SELECT formatExtPrice(subtotal) AS f_subtotal,\n formatExtPrice(totalfreight) AS f_totalfreight,\n formatExtPrice(tax) AS f_tax,\n formatExtPrice(subtotal + totalfreight + tax) AS f_totaldue\nFROM\n( SELECT COALESCE(SUM(poitem_qty_ordered * poitem_unitprice), 0) AS subtotal,\n COALESCE(SUM(poitem_freight)+pohead_freight,0) AS totalfreight,\n (SELECT COALESCE(SUM(tax), 0.0)\n FROM (SELECT ROUND(SUM(taxdetail_tax),2) AS tax\n FROM tax\n JOIN calculateTaxDetailSummary('PO', <? value("pohead_id") ?>, 'T') ON (taxdetail_tax_id=tax_id)\n GROUP BY tax_id) AS taxdata) AS tax\n FROM pohead JOIN poitem ON (poitem_pohead_id=pohead_id)\n WHERE (pohead_id=<? value("pohead_id") ?>)\n GROUP BY pohead_freight ) AS data;\n\n \n \n Logo\n SELECT image_data \nFROM image \nWHERE ((image_name='logo'));\n \n \n Currency\n SELECT\n curr_symbol\nFROM\n pohead,\n curr_symbol\nWHERE (pohead_id = <? value("pohead_id") ?>) AND\n pohead_curr_id = curr_id;\n \n \n Address\n SELECT\n warehous_descrip,\n formatAddr(addr_line1, addr_line2, addr_line3, ( addr_city || ' ' || addr_state || ' ' || addr_postalcode), addr_country) AS warehouse_address\nFROM\n whsinfo, \n addr, \n pohead\nWHERE \n addr_id = warehous_addr_id\n and pohead_warehous_id = warehous_id\n AND pohead_id=<? value("pohead_id") ?> ;\n \n \n ShipToAddress\n SELECT pohead_number,\n formatDate(pohead_orderdate) AS f_orderdate,\n pohead_fob,\n pohead_shipvia,\n terms_descrip,\n vend_number,\n vend_name,\n va.addr_line1 AS vend_address1,\n va.addr_line2 AS vend_address2,\n va.addr_line3 AS vend_address3,\n (va.addr_city || ' ' || va.addr_state || ' ' || va.addr_postalcode) AS vendcitystatezip,\n formatcntctname(pohead_vend_cntct_id) AS vend_contact,\n formataddr(pohead_vendaddress1, pohead_vendaddress2, pohead_vendaddress3, (pohead_vendcity || ' ' || pohead_vendstate || ' ' || pohead_vendzipcode), pohead_vendcountry) as vend_address,\n warehous_descrip,\n wa.addr_line1 as warehous_addr1,\n wa.addr_line2 as warehous_addr2,\n wa.addr_line3 as warehous_addr3,\n wa.addr_city as warehous_addr4,\n wa.addr_postalcode as zip,\n wa.addr_state,\n wa.addr_country,\n pohead_shiptoname AS shipto_name,\n formatcntctname(pohead_shipto_cntct_id) AS shipto_contact,\n formataddr(pohead_shiptoaddress1, pohead_shiptoaddress2, pohead_shiptoaddress3, (pohead_shiptocity || ' ' || pohead_shiptostate || ' ' || pohead_shiptozipcode), pohead_shiptocountry) as shipto_address,\n pohead_agent_username AS username,\n pohead_comments,\n text(<? value("title") ?>) AS title\n FROM pohead\n LEFT OUTER JOIN terms ON (pohead_terms_id = terms_id),\n vendinfo\n LEFT OUTER JOIN addr va ON (vend_addr_id=va.addr_id),\n whsinfo\n LEFT OUTER JOIN addr wa ON (warehous_addr_id = wa.addr_id)\n WHERE ((pohead_vend_id=vend_id)\n AND (pohead_warehous_id = warehous_id)\n AND (pohead_id=<? value("pohead_id") ?>) );\n \n \n 376\n \n \n 290\n 10\n 225\n 75\n \n stretch\n \n Logo\n image_data\n \n \n \n \n 0\n 130\n 270\n 130\n 0\n \n \n 5\n 315\n 805\n 315\n 0\n \n \n \n 535\n 130\n 810\n 130\n 0\n \n \n 535\n 0\n 535\n 130\n 0\n \n \n \n \n \n \n 645\n 60\n 140\n 17\n \n \n Arial\n 12\n normal\n \n \n \n \n Head\n f_orderdate\n \n \n \n \n 500\n 142\n 300\n 17\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n ShipToAddress\n shipto_contact\n \n \n \n \n \n 5\n 25\n 265\n 17\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n Address\n warehouse_address\n \n \n \n \n 5\n 5\n 267\n 17\n \n \n Arial\n 12\n normal\n \n \n \n \n Address\n warehous_descrip\n \n \n \n \n 645\n 40\n 126\n 17\n \n \n Arial\n 12\n normal\n \n \n \n \n Head\n pohead_number\n \n \n \n 5\n 360\n 805\n 360\n 0\n \n \n \n \n 75\n 155\n 300\n 17\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n ShipToAddress\n vend_contact\n \n \n \n 270\n 0\n 270\n 130\n 0\n \n \n \n \n \n 5\n 290\n 187\n 17\n \n \n Arial\n 11\n normal\n \n \n \n \n Head\n pohead_fob\n \n \n \n \n 202\n 290\n 252\n 17\n \n \n Arial\n 11\n normal\n \n \n \n \n Head\n pohead_shipvia\n \n \n \n \n \n \n \n \n \n \n \n 655\n 290\n 117\n 17\n \n \n Arial\n 11\n normal\n \n \n \n \n Head\n username\n \n \n \n \n 442\n 290\n 202\n 17\n \n \n Arial\n 11\n normal\n \n \n \n \n Head\n terms_descrip\n \n \n \n \n \n 645\n 85\n 35\n 16\n \n \n Arial\n 12\n normal\n \n \n \n \n Context Query\n page_number\n \n \n \n 5\n 285\n 805\n 285\n 0\n \n \n \n \n \n \n \n 75\n 137\n 300\n 20\n \n \n Arial\n 12\n normal\n \n \n \n \n Head\n vend_name\n \n \n \n \n 645\n 107\n 140\n 17\n \n \n Arial\n 12\n normal\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 500\n 172\n 300\n 17\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n ShipToAddress\n shipto_address\n \n \n \n \n 75\n 172\n 300\n 17\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n ShipToAddress\n vend_address\n \n \n \n \n 500\n 157\n 300\n 17\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n ShipToAddress\n shipto_name\n \n \n \n
\n detail\n \n \n Detail\n \n 107\n \n \n 625\n 25\n 55\n 16\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n itemuom\n \n \n \n \n 50\n 65\n 605\n 17\n \n 0\n \n Arial\n 10\n normal\n \n \n \n \n Detail\n poitem_comments\n \n \n \n \n 700\n 25\n 100\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n f_duedate\n \n \n \n \n 700\n 5\n 92\n 16\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n f_extended\n \n \n \n \n 50\n 45\n 750\n 17\n \n \n Arial\n 9\n normal\n \n \n \n \n Detail\n poitem_characteristics\n \n \n \n \n 545\n 25\n 75\n 16\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n f_ordered\n \n \n \n \n 555\n 5\n 75\n 16\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n f_price\n \n \n \n \n 505\n 5\n 25\n 16\n \n \n Arial\n 10\n normal\n \n \n \n \n Currency\n curr_symbol\n \n \n \n \n 150\n 5\n 350\n 17\n \n 0\n \n Arial\n 10\n normal\n \n \n \n \n Detail\n itemdescription\n \n \n \n \n 50\n 25\n 225\n 17\n \n \n Arial\n 9\n normal\n \n \n \n \n Detail\n poitem_vend_item_number\n \n \n \n \n 50\n 5\n 92\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n item_number\n \n \n \n \n 10\n 5\n 36\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n f_line\n \n \n \n
\n \n \n 113\n \n \n 670\n 85\n 25\n 16\n \n \n Arial\n 10\n normal\n \n \n \n \n Currency\n curr_symbol\n \n \n \n \n 35\n 10\n 530\n 17\n \n 14\n \n Arial\n 10\n normal\n \n \n \n \n Head\n pohead_comments\n \n \n \n \n \n 705\n 55\n 100\n 16\n \n \n Arial\n 10\n normal\n \n \n \n \n Foot\n f_tax\n \n \n \n \n 705\n 85\n 100\n 16\n \n \n Arial\n 10\n normal\n \n \n \n \n Foot\n f_totaldue\n \n \n \n \n 670\n 12\n 25\n 16\n \n \n Arial\n 10\n normal\n \n \n \n \n Currency\n curr_symbol\n \n \n \n \n 670\n 55\n 25\n 16\n \n \n Arial\n 10\n normal\n \n \n \n \n Currency\n curr_symbol\n \n \n \n 585\n 75\n 806\n 75\n 0\n \n \n \n \n \n 705\n 35\n 100\n 16\n \n \n Arial\n 10\n normal\n \n \n \n \n Foot\n f_totalfreight\n \n \n \n 10\n 5\n 805\n 5\n 0\n \n \n \n 705\n 12\n 100\n 16\n \n \n Arial\n 10\n normal\n \n \n \n \n Foot\n f_subtotal\n \n \n \n \n \n 670\n 35\n 25\n 16\n \n \n Arial\n 10\n normal\n \n \n \n \n Currency\n curr_symbol\n \n \n \n \n 57\n \n \n
\n Selecting an Alt Address on the PO will cause the printed PO to display that address as the Ship To on the printed document. 0 2015-10-01 17:15:58.47729 184 UsageStatisticsByItemGroup \N \n\n Item Usage Statistics by Item Group\n UsageStatisticsByItemGroup\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT formatDate(<? value("startDate") ?>) AS startdate,\n formatDate(<? value("endDate") ?>) AS enddate,\n <? if exists("itemgrp_id") ?>\n ( SELECT (itemgrp_name || '-' || itemgrp_descrip)\n FROM itemgrp\n WHERE (itemgrp_id=<? value("itemgrp_id") ?>) )\n <? elseif exists("itemgrp_pattern") ?>\n text(<? value("itemgrp_pattern") ?>)\n <? else ?>\n text('All Item Groups')\n <? endif ?>\n AS itemgroup,\n <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM warehous\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse;\n \n \n detail\n usageStatistics\n detail\n \n \n 221\n \n \n \n \n \n \n \n \n \n \n \n \n \n 140\n 120\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n 140\n 100\n 250\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n itemgroup\n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n 550\n 120\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n 550\n 100\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 56\n \n 5\n 50\n 745\n 50\n 0\n \n \n \n 665\n 2\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_transfer\n \n \n \n \n 65\n 0\n 175\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 585\n 2\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_adjust\n \n \n \n \n 425\n 2\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_sold\n \n \n \n \n 65\n 30\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 10\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 65\n 15\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 505\n 2\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_scrap\n \n \n \n \n 345\n 2\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_issued\n \n \n \n \n 260\n 2\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_received\n \n \n \n
\n \n 16\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n \N 0 2010-06-01 10:42:38.474432 446 QOHByParameterList \N \n\n Quantities on Hand by Parameter List\n QOHByParameterList\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("onlyShowPositive") ?>\n text('Only Showing Positive Quantities')\n <? elseif exists("onlyShowNegative") ?>\n text('Only Showing Negative Quantities')\n <? else ?>\n text('Showing All Quantities')\n <? endif ?>\n AS showquantities,\n <? if exists("showValue") ?>\n text('Unit Cost') AS lbl_unitcost,\n text('Value') AS lbl_value,\n text('NN Value') AS lbl_nnvalue,\n text('Cost Method') AS lbl_costmethod,\n <? else ?>\n text('') AS lbl_unitcost,\n text('') AS lbl_value,\n text('') AS lbl_nnvalue,\n text('') AS lbl_costmethod,\n <? endif ?>\n <? if exists("showValue") ?>\n <? if exists("useActualCosts") ?>\n text('Showing Actual Costs')\n <? elseif exists("useStandardCosts") ?>\n text('Showing Standard Costs')\n <? else ?>\n text('Showing Posted Costs')\n <? endif ?>\n <? else ?>\n text('')\n <? endif ?>\n AS showvalues;\n\n \n \n detail\n SELECT itemsite_id,\n detail,\n item_number,\n item_descrip1,\n item_descrip2,\n uom_name,\n warehous_code,\n formatQty(reorderlevel) AS f_reorderlevel,\n formatQty(qoh) AS f_qoh,\n CASE WHEN (NOT useDefaultLocation(itemsite_id)) THEN 'None'\n ELSE defaultLocationName(itemsite_id)\n END AS defaultlocation,\n formatQty(nonnetable) AS f_nonnetable,\n <? if exists("showValue") ?>\n formatCost(standardcost)\n <? else ?>\n text('')\n <? endif ?>\n AS f_unitcost,\n <? if exists("showValue") ?>\n formatExtPrice((standardcost * qoh))\n <? else ?>\n text('')\n <? endif ?>\n AS f_value,\n <? if exists("showValue") ?>\n CASE WHEN (itemsite_loccntrl) THEN formatExtPrice((standardcost * nonnetable))\n ELSE 'N/A'\n END\n <? else ?>\n text('')\n <? endif ?>\n AS f_nonnetvalue,\n standardcost,\n qoh,\n nonnetable,\n qoh AS r_qoh,\n nonnetable AS r_nonnetable,\n <? if exists("showValue") ?>\n (standardcost * qoh)\n <? else ?>\n 0\n <? endif ?>\n AS r_value,\n <? if exists("showValue") ?>\n CASE WHEN (itemsite_loccntrl) THEN (standardcost * nonnetable)\n ELSE 0\n END\n <? else ?>\n 0\n <? endif ?>\n AS r_nonnetvalue,\n <? if exists("showValue") ?>\n <? if exists("usePostedCosts") ?>\n CASE WHEN(itemsite_costmethod='A') THEN text('Average')\n WHEN(itemsite_costmethod='S') THEN text('Standard')\n WHEN(itemsite_costmethod='J') THEN text('Job')\n WHEN(itemsite_costmethod='N') THEN text('None')\n ELSE text('UNKNOWN')\n END\n <? else ?>\n text('')\n <? endif ?>\n <? else ?>\n text('')\n <? endif ?>\n AS f_costmethod\nFROM ( SELECT itemsite_id, itemsite_costmethod,\n item_number,\n item_descrip1, item_descrip2, itemsite_loccntrl,\n warehous_code,\n uom_name,\n CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel,\n itemsite_qtyonhand AS qoh,\n CASE WHEN ((itemsite_loccntrl) OR (itemsite_controlmethod IN ('L', 'S'))) THEN 1\n ELSE 0\n END AS detail,\n itemsite_nnqoh AS nonnetable,\n <? if exists("useActualCosts") ?>\n actcost(itemsite_item_id)\n <? elseif exists("useStandardCosts") ?>\n stdcost(itemsite_item_id)\n <? else ?>\n (itemsite_value / CASE WHEN(itemsite_qtyonhand=0) THEN 1 ELSE itemsite_qtyonhand END)\n <? endif ?>\n AS standardcost\n FROM itemsite, item, uom, warehous, costcat\n WHERE ((itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (itemsite_costcat_id=costcat_id)\n AND (itemsite_active)\n<? if exists("classcode_id") ?>\n AND (item_classcode_id=<? value("classcode_id") ?>)\n<? endif ?>\n<? if exists("classcode_pattern") ?>\n AND (item_classcode_id IN (SELECT classcode_id\n FROM classcode\n WHERE (classcode_code ~ <? value("classcode_pattern") ?>) ) )\n<? endif ?>\n<? if exists("costcat_id") ?>\n AND (costcat_id=<? value("costcat_id") ?>)\n<? endif ?>\n<? if exists("costcat_pattern") ?>\n AND (costcat_id IN (SELECT costcat_id\n FROM costcat\n WHERE (costcat_code ~ <? value("costcat_pattern") ?>) ) )\n<? endif ?>\n<? if exists("itemgrp_id") ?>\n AND (item_id IN (SELECT itemgrpitem_item_id FROM itemgrpitem WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n<? endif ?>\n<? if exists("itemgrp_pattern") ?>\n AND (item_id IN (SELECT itemgrpitem_item_id\n FROM itemgrpitem, itemgrp\n WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n AND (itemgrp_name ~ <? value("itemgrp_pattern") ?>) ) ))\n<? endif ?>\n<? if exists("onlyShowPositive") ?>\n AND (itemsite_qtyonhand > 0)\n<? elseif exists("onlyShowNegative") ?>\n AND (itemsite_qtyonhand < 0)\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n) ) AS data\nORDER BY warehous_code, item_number;\n\n \n \n 234\n \n \n \n 590\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_value\n \n \n \n \n 509\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_unitcost\n \n \n \n \n \n 185\n 43\n 300\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n showvalues\n \n \n \n 8\n 231.167\n 748\n 231.167\n 2\n \n \n \n \n \n \n 670\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_nnvalue\n \n \n \n \n \n 10\n 43\n 300\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n showquantities\n \n \n \n \n 670\n 215\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_costmethod\n \n \n \n \n \n 10\n 58\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n \n 6\n \n \n 36\n \n \n 590\n 0\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_value\n \n \n \n \n \n 670\n 0\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_nnvalue\n \n \n \n \n 509\n 0\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_unitcost\n \n \n \n \n \n \n \n 670\n 15\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_costmethod\n \n \n \n \n \n \n 10\n 33.3333\n 750\n 33.3333\n 2\n \n \n
\n detail\n \n \n detail\n \n 51\n \n \n 265\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_reorderlevel\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 104\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 104\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 5\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 10\n 15\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n defaultlocation\n \n \n \n \n 585\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_value\n \n \n \n \n 345\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qoh\n \n \n \n \n 104\n 15\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_nonnetvalue\n \n \n \n \n 670\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_costmethod\n \n \n \n \n 505\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_unitcost\n \n \n \n \n 425\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_nonnetable\n \n \n \n
\n \n 16\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 16\n \n \n 425\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n r_nonnetable\n \n %.02f\n \n \n \n \n 585\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n r_value\n \n %.02f\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n r_nonnetvalue\n \n %.02f\n \n \n \n \n 345\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n r_qoh\n \n %.02f\n \n \n \n \n
\n \N 0 2011-01-31 14:52:26.88383 444 BriefSalesHistory \N \n\n Brief Sales History\n BriefSalesHistory\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("startDate") ?>\n formatDate(date(<? value("startDate") ?>))\n <? else ?>\n text('Earliest')\n <? endif ?> AS startDate,\n <? if exists("endDate") ?>\n formatDate(date(<? value("endDate") ?>))\n <? else ?>\n text('Latest')\n <? endif ?> AS endDate,\n <? if exists("showPrices") ?>\n text('Unit Price') AS lbl_unitprice,\n text('Total') AS lbl_total,\n <? else ?>\n text('') AS lbl_unitprice,\n text('') AS lbl_total,\n <? endif ?>\n <? if exists("warehous_id") ?>\n (SELECT warehous_code FROM whsinfo WHERE warehous_id=<? value("warehous_id") ?>)\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("cust_id") ?>\n (SELECT cust_name FROM custinfo WHERE cust_id=<? value("cust_id") ?>)\n <? else ?>\n text('All Customers')\n <? endif ?>\n AS cust_name,\n <? if exists("custtype_id") ?>\n (SELECT custtype_code FROM custtype WHERE custtype_id=<? value("custtype_id") ?>)\n <? else ?>\n text('All Customer Types')\n <? endif ?>\n AS custtype_code,\n <? if exists("custtype_pattern") ?>\n text(<? value("custtype_pattern") ?>)\n <? else ?>\n text('Not Applicable')\n <? endif ?>\n AS custtype_pattern,\n <? if exists("custgrp_id") ?>\n (SELECT custgrp_name FROM custgrp WHERE custgrp_id=<? value("custgrp_id") ?>)\n <? else ?>\n text('All Customer Groups')\n <? endif ?>\n AS custgrp_name,\n <? if exists("custgrp_pattern") ?>\n text(<? value("custgrp_pattern") ?>)\n <? else ?>\n text('Not Applicable')\n <? endif ?>\n AS custgrp_pattern,\n <? if exists("prodcat_id") ?>\n (SELECT prodcat_code FROM prodcat WHERE prodcat_id=<? value("prodcat_id") ?>)\n <? else ?>\n text('All Product Categories')\n <? endif ?>\n AS prodcat_code,\n <? if exists("prodcat_pattern") ?>\n text(<? value("prodcat_pattern") ?>)\n <? else ?>\n text('Not Applicable')\n <? endif ?>\n AS prodcat_pattern,\n <? if exists("item_id") ?>\n (SELECT item_number FROM item WHERE item_id=<? value("item_id") ?>)\n <? else ?>\n text('All Item Numbers')\n <? endif ?>\n AS item_number,\n <? if exists("cohead_id") ?>\n (SELECT cohead_number FROM cohead WHERE cohead_id=<? value("cohead_id") ?>)\n <? else ?>\n text('All Orders')\n <? endif ?>\n AS docnumber; \n \n \n detail\n briefSalesHistory\n detail\n \n \n 221\n \n \n \n \n \n \n \n 0\n 218\n 745\n 218\n 2\n \n \n \n 10\n 38\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n \n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 37\n \n \n 5\n 17\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cohist_ordernumber\n \n \n \n \n 110\n 17\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n invoicenumber\n \n \n \n \n 565\n 17\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_margin\n \n \n \n \n 305\n 17\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_invcdate\n \n \n \n \n 220\n 17\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_orderdate\n \n \n \n \n 5\n 2\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_number\n \n \n \n \n 110\n 2\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n custtype_code\n \n \n \n \n 225\n 2\n 320\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_name\n \n \n \n \n 390\n 17\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_baseextprice\n \n \n \n \n 475\n 17\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_extcost\n \n \n \n \n 655\n 17\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_marginpercent\n \n \n \n
\n \n 16\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 103\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 21\n \n \n \n 390\n 5\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n baseextprice\n \n money\n \n \n \n \n 475\n 5\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n extcost\n \n money\n \n \n \n \n 565\n 5\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n margin\n \n money\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 429 InventoryHistory \N \n\n Inventory History\n InventoryHistory\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT invhist_id,\n invhist_transdate,\n formatDateTime(invhist_transdate) AS f_transdate,\n invhist_transtype,\n whs1.warehous_code AS warehous_code,\n item_number,\n item_descrip1,\n item_descrip2,\n formatQty(invhist_invqty) AS transqty,\n (invhist_value_after-invhist_value_before) AS transvalue,\n formatMoney(invhist_value_after-invhist_value_before) AS f_transvalue,\n invhist_invuom,\n CASE WHEN (invhist_ordtype NOT LIKE '') THEN (invhist_ordtype || '-' || invhist_ordnumber)\n ELSE invhist_ordnumber\n END AS ordernumber,\n formatQty(invhist_qoh_before) AS qohbefore,\n formatQty(invhist_qoh_after) AS qohafter,\n CASE WHEN (invhist_costmethod='A') THEN <? value("average") ?>\n WHEN (invhist_costmethod='S') THEN <? value("standard") ?>\n WHEN (invhist_costmethod='J') THEN <? value("job") ?>\n WHEN (invhist_costmethod='N') THEN <? value("none") ?>\n ELSE <? value("unknown") ?>\n END AS costmethod,\n formatMoney(invhist_value_before) AS valbefore,\n formatMoney(invhist_value_after) AS valafter,\n invhist_user AS username,\n invhist_posted,\n 0 AS invdetail_id,\n '' AS locationname,\n '' AS detailqty,\n '' AS locationqtybefore,\n '' AS locationqtyafter,\n CASE WHEN (invhist_transtype='TW') THEN whs1.warehous_code\n WHEN (invhist_transtype='IB') THEN whs1.warehous_code\n WHEN (invhist_transtype='IM') THEN whs1.warehous_code\n WHEN (invhist_transtype='IT') THEN whs1.warehous_code\n WHEN (invhist_transtype='RB') THEN 'WIP'\n WHEN (invhist_transtype='RM') THEN 'WIP'\n WHEN (invhist_transtype='RP') THEN 'PURCH'\n WHEN (invhist_transtype='RR') THEN 'CUST'\n WHEN (invhist_transtype='RS') THEN 'SHIP'\n WHEN (invhist_transtype='SH') THEN whs1.warehous_code\n WHEN (invhist_transtype='SI') THEN whs1.warehous_code\n WHEN (invhist_transtype='SV') THEN whs1.warehous_code\n\t WHEN (invhist_transtype='TR') THEN whs2.warehous_code\n\t WHEN (invhist_transtype='TS') THEN whs1.warehous_code\n ELSE ''\n END AS locfrom,\n CASE WHEN (invhist_transtype='TW') THEN whs2.warehous_code\n WHEN (invhist_transtype='AD') THEN whs1.warehous_code\n WHEN (invhist_transtype='CC') THEN whs1.warehous_code\n WHEN (invhist_transtype='IB') THEN 'WIP'\n WHEN (invhist_transtype='IM') THEN 'WIP'\n WHEN (invhist_transtype='NN') THEN whs1.warehous_code\n WHEN (invhist_transtype='RB') THEN whs1.warehous_code\n WHEN (invhist_transtype='RM') THEN whs1.warehous_code\n WHEN (invhist_transtype='RP') THEN whs1.warehous_code\n WHEN (invhist_transtype='RR') THEN whs1.warehous_code\n WHEN (invhist_transtype='RS') THEN whs1.warehous_code\n WHEN (invhist_transtype='RT') THEN whs1.warehous_code\n WHEN (invhist_transtype='RX') THEN whs1.warehous_code\n WHEN (invhist_transtype='SH') THEN 'SHIP'\n WHEN (invhist_transtype='SI') THEN 'SCRAP'\n WHEN (invhist_transtype='SV') THEN 'SHIP'\n\t WHEN (invhist_transtype='TR') THEN whs1.warehous_code\n\t WHEN (invhist_transtype='TS') THEN whs2.warehous_code\n ELSE ''\n END AS locto\n FROM itemsite, item, whsinfo AS whs1, invhist LEFT OUTER JOIN whsinfo AS whs2 ON (invhist_xfer_warehous_id=whs2.warehous_id)\n WHERE ( (NOT invhist_hasdetail)\n AND (invhist_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=whs1.warehous_id)\n AND (DATE(invhist_transdate) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?> )\n AND (transType(invhist_transtype, <? value("transType") ?>))\n<? if exists("orderType") ?>\n AND (invhist_ordtype=<? value("orderType") ?>)\n<? endif ?>\n<? if exists("orderNumber") ?>\n AND (invhist_ordnumber ~ <? value("orderNumber") ?>)\n<? endif ?>\n<? if exists("cohead_id") ?>\n AND (invhist_ordtype='SO')\n AND (invhist_ordnumber ~ (\n SELECT cohead_number \n FROM cohead \n WHERE cohead_id=<? value("cohead_id") ?>))\n<? endif ?>\n<? if exists("pohead_id") ?>\n AND (invhist_ordtype='PO')\n AND (invhist_ordnumber ~ (\n SELECT pohead_number \n FROM pohead \n WHERE pohead_id=<? value("pohead_id") ?>))\n<? endif ?>\n<? if exists("tohead_id") ?>\n AND (invhist_ordtype='TO')\n AND (invhist_ordnumber ~ (\n SELECT tohead_number \n FROM tohead \n WHERE tohead_id=<? value("tohead_id") ?>))\n<? endif ?>\n<? if exists("wo_id") ?>\n AND (invhist_ordtype='WO')\n AND (invhist_ordnumber ~ formatWoNumber(<? value("wo_id") ?>))\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("classcode_id") ?>\n AND (item_classcode_id=<? value("classcode_id") ?>)\n<? endif ?>\n<? if exists("itemgrp_id") ?>\n AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t FROM itemgrpitem\n\t\t WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n<? endif ?>\n<? if exists("plancode_id") ?>\n AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? endif ?>\n<? if exists("classcode_pattern") ?>\n AND (item_classcode_id IN (SELECT classcode_id\n\t\t\t FROM classcode\n\t\t\t WHERE (classcode_code ~ <? value ("classcode_pattern") ?>)))\n<? endif ?>\n<? if exists("itemgrp_pattern") ?>\n AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t FROM itemgrpitem, itemgrp\n\t\t WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n\t\t AND (itemgrp_name ~ <? value ("itemgrp_pattern") ?>))))\n<? endif ?>\n<? if exists("plancode_pattern") ?>\n AND (itemsite_plancode_id IN (SELECT plancode_id\n\t\t\t\tFROM plancode\n\t\t\t\tWHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? endif ?>\n<? if exists("itemgrp") ?>\n AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n<? endif ?>\n)\nUNION\nSELECT invhist_id,\n invhist_transdate,\n formatDateTime(invhist_transdate) AS transdate,\n invhist_transtype,\n whs1.warehous_code AS warehous_code,\n item_number,\n item_descrip1,\n item_descrip2,\n formatQty(invhist_invqty) AS transqty,\n 0 AS transvalue,\n formatMoney(invhist_value_after-invhist_value_before) AS f_transvalue,\n invhist_invuom,\n CASE WHEN (invhist_ordtype NOT LIKE '') THEN (invhist_ordtype || '-' || invhist_ordnumber)\n ELSE invhist_ordnumber\n END AS ordernumber,\n formatQty(invhist_qoh_before) AS qohbefore,\n formatQty(invhist_qoh_after) AS qohafter,\n CASE WHEN(invhist_costmethod='A') THEN text('Average')\n WHEN(invhist_costmethod='S') THEN text('Standard')\n WHEN(invhist_costmethod='J') THEN text('Job')\n WHEN(invhist_costmethod='N') THEN text('None')\n ELSE 'UNKNOWN'\n END AS costmethod,\n formatMoney(invhist_value_before) AS valbefore,\n formatMoney(invhist_value_after) AS valafter,\n invhist_user AS username,\n invhist_posted,\n invdetail_id,\n CASE WHEN (invdetail_location_id=-1) THEN formatlotserialnumber(invdetail_ls_id)\n WHEN (invdetail_ls_id IS NULL) THEN formatLocationName(invdetail_location_id)\n ELSE (formatLocationName(invdetail_location_id) || '-' || formatlotserialnumber(invdetail_ls_id))\n END AS locationname,\n formatQty(invdetail_qty) AS detailqty,\n formatQty(invdetail_qty_before) AS locationqtybefore,\n formatQty(invdetail_qty_after) AS locationqtyafter,\n CASE WHEN (invhist_transtype='TW') THEN whs1.warehous_code\n WHEN (invhist_transtype='IB') THEN whs1.warehous_code\n WHEN (invhist_transtype='IM') THEN whs1.warehous_code\n WHEN (invhist_transtype='IT') THEN whs1.warehous_code\n WHEN (invhist_transtype='RB') THEN 'WIP'\n WHEN (invhist_transtype='RM') THEN 'WIP'\n WHEN (invhist_transtype='RP') THEN 'PURCH'\n WHEN (invhist_transtype='RR') THEN 'CUST'\n WHEN (invhist_transtype='RS') THEN 'SHIP'\n WHEN (invhist_transtype='SH') THEN whs1.warehous_code\n WHEN (invhist_transtype='SI') THEN whs1.warehous_code\n WHEN (invhist_transtype='SV') THEN whs1.warehous_code\n\t WHEN (invhist_transtype='TR') THEN whs2.warehous_code\n\t WHEN (invhist_transtype='TS') THEN whs1.warehous_code\n ELSE ''\n END AS locfrom,\n CASE WHEN (invhist_transtype='TW') THEN whs2.warehous_code\n WHEN (invhist_transtype='AD') THEN whs1.warehous_code\n WHEN (invhist_transtype='CC') THEN whs1.warehous_code\n WHEN (invhist_transtype='IB') THEN 'WIP'\n WHEN (invhist_transtype='IM') THEN 'WIP'\n WHEN (invhist_transtype='NN') THEN whs1.warehous_code\n WHEN (invhist_transtype='RB') THEN whs1.warehous_code\n WHEN (invhist_transtype='RM') THEN whs1.warehous_code\n WHEN (invhist_transtype='RP') THEN whs1.warehous_code\n WHEN (invhist_transtype='RR') THEN whs1.warehous_code\n WHEN (invhist_transtype='RS') THEN whs1.warehous_code\n WHEN (invhist_transtype='RT') THEN whs1.warehous_code\n WHEN (invhist_transtype='RX') THEN whs1.warehous_code\n WHEN (invhist_transtype='SH') THEN 'SHIP'\n WHEN (invhist_transtype='SI') THEN 'SCRAP'\n WHEN (invhist_transtype='SV') THEN 'SHIP'\n\t WHEN (invhist_transtype='TR') THEN whs1.warehous_code\n\t WHEN (invhist_transtype='TS') THEN whs2.warehous_code\n ELSE ''\n END AS locto\n FROM itemsite, item, whsinfo AS whs1, invdetail, invhist LEFT OUTER JOIN whsinfo AS whs2 ON (invhist_xfer_warehous_id=whs2.warehous_id)\n WHERE ((invhist_hasdetail)\n AND (invhist_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=whs1.warehous_id)\n AND (invdetail_invhist_id=invhist_id)\n AND (DATE(invhist_transdate) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?> )\n AND (transType(invhist_transtype, <? value("transType") ?>))\n<? if exists("orderType") ?>\n AND (invhist_ordtype=<? value("orderType") ?>)\n<? endif ?>\n<? if exists("orderNumber") ?>\n AND (invhist_ordnumber ~ <? value("orderNumber") ?>)\n<? endif ?>\n<? if exists("cohead_id") ?>\n AND (invhist_ordtype='SO')\n AND (invhist_ordnumber ~ (\n SELECT cohead_number \n FROM cohead \n WHERE cohead_id=<? value("cohead_id") ?>))\n<? endif ?>\n<? if exists("pohead_id") ?>\n AND (invhist_ordtype='PO')\n AND (invhist_ordnumber ~ (\n SELECT pohead_number \n FROM pohead \n WHERE pohead_id=<? value("pohead_id") ?>))\n<? endif ?>\n<? if exists("tohead_id") ?>\n AND (invhist_ordtype='TO')\n AND (invhist_ordnumber ~ (\n SELECT tohead_number \n FROM tohead \n WHERE tohead_id=<? value("tohead_id") ?>))\n<? endif ?>\n<? if exists("wo_id") ?>\n AND (invhist_ordtype='WO')\n AND (invhist_ordnumber ~ formatWoNumber(<? value("wo_id") ?>))\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("classcode_id") ?>\n AND (item_classcode_id=<? value("classcode_id") ?>)\n<? endif ?>\n<? if exists("itemgrp_id") ?>\n AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t FROM itemgrpitem\n\t\t WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n<? endif ?>\n<? if exists("plancode_id") ?>\n AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? endif ?>\n<? if exists("classcode_pattern") ?>\n AND (item_classcode_id IN (SELECT classcode_id\n\t\t\t FROM classcode\n\t\t\t WHERE (classcode_code ~ <? value ("classcode_pattern") ?>)))\n<? endif ?>\n<? if exists("itemgrp_pattern") ?>\n AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t FROM itemgrpitem, itemgrp\n\t\t WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n\t\t AND (itemgrp_name ~ <? value ("itemgrp_pattern") ?>))))\n<? endif ?>\n<? if exists("plancode_pattern") ?>\n AND (itemsite_plancode_id IN (SELECT plancode_id\n\t\t\t\tFROM plancode\n\t\t\t\tWHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? endif ?>\n<? if exists("itemgrp") ?>\n AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n<? endif ?>\n);\n \n \n footer\n SELECT formatMoney(sum(invhist_value_after-invhist_value_before)) AS transvalue_total\nFROM itemsite, item, whsinfo AS whs1, invhist LEFT OUTER JOIN\n whsinfo AS whs2 ON (invhist_xfer_warehous_id=whs2.warehous_id)\nWHERE ( (invhist_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id) \n AND (itemsite_warehous_id=whs1.warehous_id)\n AND (DATE(invhist_transdate) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?> )\n AND (transType(invhist_transtype, <? value("transType") ?>))\n<? if exists("orderType") ?>\n AND (invhist_ordtype=<? value("orderType") ?>)\n<? endif ?>\n<? if exists("orderNumber") ?>\n AND (invhist_ordnumber ~ <? value("orderNumber") ?>)\n AND (invhist_ordtype = 'SO')\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("item_id") ?>\n AND (itemsite_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("classcode_id") ?>\n AND (item_classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("itemgrp_id") ?>\n AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t FROM itemgrpitem\n\t\t WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n<? elseif exists("plancode_id") ?>\n AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n AND (item_classcode_id IN (SELECT classcode_id\n\t\t\t FROM classcode\n\t\t\t WHERE (classcode_code ~ <? value ("classcode_pattern") ?>)))\n<? elseif exists("itemgrp_pattern") ?>\n AND (item_id IN (SELECT itemgrpitem_item_id\n\t\t FROM itemgrpitem, itemgrp\n\t\t WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n\t\t AND (itemgrp_name ~ <? value ("itemgrp_pattern") ?>))))\n<? elseif exists("plancode_pattern") ?>\n AND (itemsite_plancode_id IN (SELECT plancode_id\n\t\t\t\tFROM plancode\n\t\t\t\tWHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? elseif exists("itemgrp") ?>\n AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n<? endif ?>\n)\n \n \n 242\n \n \n \n \n \n \n \n \n 5\n 237\n 745\n 237\n 2\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 10\n 37\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 2\n \n \n 51\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 5\n 45\n 745\n 45\n 2\n \n \n \n \n \n \n
\n detail\n \n invhist_id\n invhist_id\n \n 45\n \n \n 60\n 0\n 132\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_transdate\n \n \n \n \n 200\n 0\n 228\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 200\n 25\n 228\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 660\n 25\n 72\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n valafter\n \n \n \n \n 60\n 12\n 132\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ordernumber\n \n \n \n \n 585\n 0\n 72\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qohbefore\n \n \n \n \n 5\n 0\n 50\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 432\n 0\n 72\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n invhist_invuom\n \n \n \n \n 60\n 25\n 132\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n username\n \n \n \n \n 585\n 25\n 72\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n valbefore\n \n \n \n \n 660\n 12\n 72\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n locto\n \n \n \n \n 660\n 0\n 72\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qohafter\n \n \n \n \n 5\n 12\n 50\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n invhist_transtype\n \n \n \n \n 510\n 0\n 72\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n transqty\n \n \n \n \n 585\n 12\n 72\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n locfrom\n \n \n \n \n 200\n 12\n 228\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 510\n 12\n 72\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n costmethod\n \n \n \n \n 510\n 25\n 72\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_transvalue\n \n \n \n \n 9\n \n 5\n 5\n 745\n 5\n 0\n \n \n \n \n \n detail\n \n 16\n \n \n 585\n 0\n 72\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n locationqtybefore\n \n \n \n \n 200\n 0\n 228\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n locationname\n \n \n \n \n 508\n 0\n 72\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n detailqty\n \n \n \n \n 660\n 0\n 72\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n locationqtyafter\n \n \n \n
\n \n 14\n \n \n \n 705\n 0\n 40\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 90\n 0\n 100\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 20\n \n \n 510\n 5\n 72\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n footer\n transvalue_total\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 442 Journals \N \n\n Journals\n Journals\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("source") ?>\n text(<? value("source") ?>)\n <? else ?>\n text('All Sources')\n <? endif ?>\n AS source,\n <? if exists("accnt_id") ?>\n ( SELECT (accnt_number || '-' || accnt_descrip)\n FROM accnt\n WHERE (accnt_id=<? value("accnt_id") ?>) )\n <? else ?>\n text('All Accounts')\n <? endif ?>\n AS accnt,\n <? if exists("showUsernames") ?>\n text('Username')\n <? else ?>\n text('')\n <? endif ?>\n AS f_username\n \n \n detail\n SELECT sltrans_id,\n sltrans_created, formatDate(sltrans_date) AS transdate,\n sltrans_source, sltrans_doctype, sltrans_docnumber, invhist_docnumber,\n firstLine(sltrans_notes) AS transnotes,\n (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n-- Debits:\n CASE WHEN (sltrans_amount < 0) THEN formatMoney(ABS(sltrans_amount))\n ELSE ''\n END AS f_debit, \n CASE WHEN (sltrans_amount < 0) THEN ABS(sltrans_amount)\n ELSE 0\n END AS debit_amt, \n--Credits:\n CASE WHEN (sltrans_amount > 0) THEN formatMoney(sltrans_amount)\n ELSE ''\n END AS f_credit,\n CASE WHEN (sltrans_amount > 0) THEN sltrans_amount\n ELSE 0\n END AS credit_amt,\n--Balance:\n sltrans_amount * -1 as balance_amt,\n--\n sltrans_amount,\n CASE WHEN accnt_type IN ('A','E') THEN \n sltrans_amount * -1\n ELSE sltrans_amount END AS running,\n formatBoolYN(sltrans_posted) AS f_posted,\n sltrans_username AS f_username,\n sltrans_sequence\nFROM sltrans\n JOIN accnt ON (sltrans_accnt_id=accnt_id) \n LEFT OUTER JOIN invhist ON (sltrans_misc_id=invhist_id\n AND sltrans_docnumber='Misc.') \n<? if exists("company_id") ?>\n JOIN company ON (accnt_company=company_number) \n<? endif ?>\n<? if exists("prfcntr_id") ?>\n JOIN prftcntr ON (accnt_profit=prftcntr_number) \n<? endif ?>\n<? if exists("subaccnt_id") ?>\n JOIN subaccnt ON (accnt_sub=subaccnt_number) \n<? endif ?>\n<? if exists("subType") ?>\n JOIN subaccnttype ON (subaccnttype_code=accnt_subaccnttype_code) \n<? endif ?>\nWHERE (\n<? if exists("startDate") ?>\n <? if exists("endDate") ?>\n (sltrans_date BETWEEN <? value("startDate") ?>\n AND <? value("endDate") ?>)\n <? else ?>\n (sltrans_date BETWEEN <? value("startDate") ?>\n AND endoftime())\n <? endif ?>\n<? else ?>\n <? if exists("endDate") ?>\n (sltrans_date BETWEEN startoftime()\n AND <? value("endDate") ?>)\n <? else ?>\n (sltrans_date BETWEEN startoftime()\n AND endoftime())\n <? endif ?>\n<? endif ?>\n<? if exists("company_id") ?>\n AND (company_id=<? value("company_id") ?>)\n<? endif ?>\n<? if exists("prfcntr_id") ?>\n AND (prftcntr_id=<? value("prfcntr_id") ?>)\n<? endif ?>\n<? if exists("accnt_number") ?>\n AND (accnt_number=<? value("accnt_number") ?>)\n<? endif ?>\n<? if exists("subaccnt_id") ?>\n AND (subaccnt_id=<? value("subaccnt_id") ?>)\n<? endif ?>\n<? if exists("subType") ?>\n AND (subaccnttype_id=<? value("subType") ?>)\n<? endif ?>\n<? if exists("accntType") ?>\n AND (accnt_type= <? value("accntType") ?>)\n<? endif ?>\n<? if exists("accnt_id") ?>\n AND (sltrans_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n<? if exists("docnum") ?>\n AND (sltrans_docnumber = case when <? value("docnum") ?> = '' then \n sltrans_docnumber else \n<? value("docnum") ?> end ) \n<? endif ?>\n<? if exists("source") ?>\n AND (sltrans_source=<? value("source") ?>)\n<? endif ?>\n<? if exists("source_pattern") ?>\n AND (sltrans_source ~* <? value("source_pattern") ?>)\n<? endif ?>\n<? if exists("journalnumber") ?>\n AND (sltrans_gltrans_journalnumber=<? value("journalnumber") ?>)\n<? endif ?>\n<? if exists("posted") ?>\n AND (sltrans_posted=<? value("posted") ?>)\n<? endif ?>\n )\nORDER BY sltrans_created,\n sltrans_sequence, sltrans_amount;\n \n \n 205\n \n \n \n \n \n \n \n 0\n 200\n 1000\n 200\n 2\n \n \n \n \n \n \n \n \n 10\n 40\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 5\n \n \n 45\n \n \n \n \n 0\n 40\n 1000\n 40\n 2\n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 31\n \n \n 882.19\n -0.890523\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_username\n \n \n \n \n 790.907\n -0.890523\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_credit\n \n \n \n \n 240\n 15\n 265\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n transnotes\n \n \n \n \n 954.846\n -0.891\n 42.1539\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_posted\n \n \n \n \n 12500\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_doctype\n \n \n \n \n 125\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n sltrans_doctype\n \n \n \n \n 0\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n transdate\n \n \n \n \n 180\n 15\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n invhist_docnumber\n \n \n \n \n 180\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n sltrans_docnumber\n \n \n \n \n 681.65\n -0.890523\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_debit\n \n \n \n \n 240\n 0\n 270\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n account\n \n \n \n \n 65\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n sltrans_source\n \n \n \n
\n \n \n 75\n \n \n 765.907\n 8.08006\n 105\n 14\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n credit_amt\n \n money\n \n \n \n 632.141\n 5.07044\n 1000\n 5\n 2\n \n \n \n 960\n 60\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 60\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 656.65\n 8.08006\n 105\n 14\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n debit_amt\n \n money\n \n \n \n \n \n \n 15\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 960\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 290 CashReceipts \N \n\n Cash Receipts\n CashReceipts\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("cust_id") ?>\n (SELECT (cust_number || '-' || cust_name)\n FROM custinfo\n WHERE (cust_id=<? value("cust_id") ?>) )\n <? elseif exists("custtype_id") ?>\n (select (custtype_code||'-'||custtype_descrip)\n FROM custtype\n WHERE (custtype_id=<? value("custtype_id") ?>) )\n <? elseif exists("custtype_pattern") ?>\n text(<? value("custtype_pattern") ?>)\n <? else ?>\n text('All Customers')\n <? endif ?>\n AS f_value,\n <? if exists("custtype_id") ?>\n text('Cust. Type:')\n <? elseif exists("custtype_pattern") ?>\n text('Cust. Type Pattern:')\n <? else ?>\n text('Customer:')\n <? endif ?>\n AS f_label,\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate;\n \n \n detail\n cashReceipts\n detail\n \n \n foot\n SELECT formatMoney(SUM(base_applied)) AS f_base_applied_total\nFROM (\n<? if exists("LegacyDisplayMode") ?>\n-- Posted cash receipts\nSELECT currtobase(arapply_curr_id,arapply_applied,arapply_postdate) AS base_applied\nFROM custinfo LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id), arapply\nWHERE ( (arapply_cust_id=cust_id)\n AND (arapply_postdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n AND (arapply_source_doctype ='K')\n<? if exists("cust_id") ?>\n AND (cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\n AND (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n AND (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n )\n\n-- Unposted cash receipts\nUNION ALL\nSELECT currtobase(cashrcpt_curr_id,cashrcpt_amount,cashrcpt_distdate) AS base_applied\nFROM cashrcpt, custinfo LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\nWHERE ( (NOT cashrcpt_posted)\n AND (cashrcpt_cust_id=cust_id)\n AND (cashrcpt_distdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("cust_id") ?>\n AND (cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\n AND (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n AND (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n )\n\n-- Cash Advance\nUNION ALL\nSELECT aropen_amount / aropen_curr_rate AS base_applied\nFROM custinfo LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id), aropen\n JOIN cashrcptitem ON (aropen_id=cashrcptitem_aropen_id)\nWHERE ( (aropen_cust_id=cust_id)\n AND (aropen_doctype IN ('R','C'))\n AND (aropen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("cust_id") ?>\n AND (cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\n AND (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n AND (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n )\n<? else ?>\n-- New mode\nSELECT (cashrcpt_amount / cashrcpt_curr_rate) AS base_applied\nFROM cashrcpt JOIN custinfo ON (cust_id=cashrcpt_cust_id)\n<? if exists("custgrp_id") ?>\n LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n<? endif ?>\nWHERE ( (cashrcpt_distdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("cust_id") ?>\n AND (cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\n AND (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n AND (cust_custtype_id IN (SELECT custtype_id FROM custtype WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n )\n<? endif ?>\n) data\n;\n\n \n \n 146\n \n \n 10\n 65\n 125\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n f_label\n \n \n \n \n \n \n 140\n 65\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_value\n \n \n \n \n 565\n 85\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n 5\n 140\n 745\n 140\n 2\n \n \n \n 565\n 65\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n \n \n \n \n \n \n 6\n \n \n 28\n \n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 20\n \n \n 55\n 0\n 155\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_name\n \n \n \n \n 215\n 0\n 65\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_postdate\n \n \n \n \n 600\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n currAbbr\n \n \n \n \n 400\n 0\n 110\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n target\n \n \n \n \n 5\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_number\n \n \n \n \n 285\n 0\n 115\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n source\n \n \n \n \n 645\n 0\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_base_applied\n \n \n \n \n 509\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_applied\n \n \n \n
\n \n 18\n \n \n \n 700.755\n 2\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 103\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 100\n \n \n \n 646\n 10.7068\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n foot\n f_base_applied_total\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 46 CostedSingleLevelBOM \N \n\n Costed Single Level Bill of Materials\n CostedSingleLevelBOM\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n uom_name AS item_invuom,\n item_descrip1,\n item_descrip2,\n formatCost(stdcost(item_id)) AS standardcost,\n formatCost(actcost(item_id)) AS actualcost,\n <? if exists("useActualCosts") ?>\n text('Actual Cost')\n <? else ?>\n text('Standard Cost')\n <? endif ?>\n AS costtype\n FROM item JOIN uom ON (uom_id=item_inv_uom_id)\n WHERE (item_id=<? value("item_id") ?>);\n \n \n \n detail\n SELECT bomdata_bomwork_seqnumber AS orderby,\n CASE WHEN bomdata_bomwork_seqnumber > 0 THEN\n text(bomdata_bomwork_seqnumber)\n ELSE NULL\n END AS seqnumber,\n bomdata_item_number AS item_number,\n bomdata_uom_name AS item_invuom,\n bomdata_item_descrip1 AS item_descrip1,\n bomdata_item_descrip2 AS item_descrip2,\n bomdata_issuemethod AS issuemethod,\n formatQty(bomdata_qtyfxd) AS qtyfxd,\n formatQtyPer(bomdata_qtyper) AS qtyper,\n formatScrap(bomdata_scrap) AS scrap,\n CASE\n WHEN item_inv_uom_id IS NOT NULL THEN\n formatqtyper((bomitem_qtyfxd + bomitem_qtyper) * (1 + bomitem_scrap) * itemuomtouomratio(bomitem_item_id,bomitem_uom_id,item_inv_uom_id)) \n ELSE\n ''\n END AS qtyreq,\n CASE WHEN COALESCE(bomdata_effective, startOfTime()) <= startOfTime() THEN\n <? value("always") ?>\n ELSE formatDate(bomdata_effective)\n END AS effective,\n CASE WHEN COALESCE(bomdata_expires, endOfTime()) >= endOfTime() THEN\n <? value("never") ?>\n ELSE formatDate(bomdata_expires)\n END AS expires,\n<? if exists("useActualCosts") ?>\n formatCost(bomdata_actunitcost)\n<? else ?>\n formatCost(bomdata_stdunitcost)\n<? endif ?>\n AS unitcost,\n<? if exists("useActualCosts") ?>\n formatCost(bomdata_actextendedcost)\n<? else ?>\n formatCost(bomdata_stdextendedcost)\n<? endif ?>\n AS extcost\nFROM singlelevelbom(<? value("item_id") ?>,<? value("revision_id") ?>,0,0)\n LEFT OUTER JOIN bomitem ON (bomdata_bomitem_id=bomitem_id)\n LEFT OUTER JOIN item ON (bomitem_item_id=item_id)\nORDER BY orderby;\n \n \n \n bomhead\n SELECT bomhead_docnum, bomhead_revision,\nformatDate(bomhead_revisiondate) AS f_revisiondate\nFROM bomhead\nWHERE ((bomhead_item_id=<? value("item_id") ?>)\nAND (bomhead_rev_id=<? value("revision_id") ?>));\n \n \n 217\n \n \n \n 510\n 100\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n f_revisiondate\n \n \n \n \n \n \n \n 125\n 80\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n 510\n 120\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n bomhead_revision\n \n \n \n \n \n \n \n \n 125\n 120\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n 5\n 210\n 745\n 210\n 2\n \n \n \n \n \n 510\n 80\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n bomhead_docnum\n \n \n \n \n \n \n \n \n \n 430\n 50\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n costtype\n \n \n \n \n \n \n 125\n 100\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 53\n \n \n 405\n 0\n 37\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_invuom\n \n \n \n \n 675\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n expires\n \n \n \n \n 315\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyfxd\n \n \n \n \n 70\n 0\n 228\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 315\n 31\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n unitcost\n \n \n \n \n 675\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n issuemethod\n \n \n \n \n 443\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n extcost\n \n \n \n \n 70\n 15\n 228\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 443\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n scrap\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 70\n 30\n 228\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 15\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n seqnumber\n \n \n \n \n 600\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n effective\n \n \n \n \n 600\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n createchild\n \n \n \n \n 525\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyreq\n \n \n \n \n 315\n 16\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyper\n \n \n \n
\n \n 18\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 53\n \n \n \n \n 443\n 35\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n standardcost\n \n \n \n \n \n 443\n 20\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n actualcost\n \n \n \n \n 443\n 5\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n extcost\n \n %9.4f\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 315 CostedSummarizedBOM \N \n\n Costed Summarized Bill of Materials\n CostedSummarizedBOM\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n uom_name AS item_invuom,\n item_descrip1,\n item_descrip2,\n<? if exists("useActualCosts") ?>\n text('Actual Costs') AS f_costtype\n<? else ?>\n text('Standard Costs') AS f_costtype\n<? endif ?>\n FROM item JOIN uom ON (uom_id=item_inv_uom_id)\n WHERE (item_id=<? value("item_id") ?>);\n \n \n \n detail\n select bomdata_item_number AS item_number,\n bomdata_uom_name AS item_invuom,\n bomdata_item_descrip1 AS item_descrip1,\n bomdata_item_descrip2 AS item_descrip2,\n formatQtyPer(bomdata_qtyreq) AS qtyreq,\n<? if exists("useActualCosts") ?>\n formatCost(bomdata_actunitcost) AS f_cost,\n formatCost(bomdata_actextendedcost) AS f_extcost\n<? else ?>\n formatCost(bomdata_stdunitcost) AS f_cost,\n formatCost(bomdata_stdextendedcost) AS f_extcost\n<? endif ?>\n FROM summarizedBOM(<? value("item_id") ?>,<? value("revision_id") ?>,<? value("expiredDays") ?>,<? value("futureDays") ?>);\n \n \n bomhead\n SELECT bomhead_docnum, bomhead_revision,\nformatDate(bomhead_revisiondate) AS f_revisiondate\nFROM bomhead\nWHERE ((bomhead_item_id=<? value("item_id") ?>)\nAND (bomhead_rev_id=<? value("revision_id") ?>));\n \n \n 242\n \n \n 100\n 104\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n 315\n 104\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_invuom\n \n \n \n \n 100\n 125\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n \n 100\n 145\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n \n \n \n 580\n 125\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n f_revisiondate\n \n \n \n \n \n \n 410\n 50\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_costtype\n \n \n \n \n 580\n 145\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n bomhead_revision\n \n \n \n \n \n 5\n 235\n 745\n 235\n 2\n \n \n \n \n \n 580\n 104\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n bomhead_docnum\n \n \n \n \n \n \n 6\n \n \n 36\n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 52\n \n \n 665\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_extcost\n \n \n \n \n 425\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyreq\n \n \n \n \n 585\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_cost\n \n \n \n \n 113\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 113\n 15\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 113\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 275\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_invuom\n \n \n \n
\n \n 18\n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 36 CountSlipsByWarehouse \N \n\n Count Slips By Site\n CountSlipsByWarehouse\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n formatDate(<? value("startDate") ?>) AS startdate,\n formatDate(<? value("endDate") ?>) AS enddate\n\n \n \n detail\n SELECT invcnt_tagnumber AS tagnum,\n <? if exists("asNumeric") ?>\n int4(cntslip_number)\n <? else ?>\n cntslip_number\n <? endif ?>\n AS slipnum,\n warehous_code,\n item_number,\n item_descrip1,\n item_descrip2,\n formatDate(cntslip_entered) AS date_entered,\n ('( ' || cntslip_username || ' )') AS enteredby,\n formatQty(cntslip_qty) AS f_qtycounted,\n formatBoolYN(cntslip_posted) AS f_posted\n FROM cntslip, invcnt, itemsite, item, whsinfo\n WHERE ((cntslip_cnttag_id=invcnt_id)\n AND (invcnt_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (cntslip_entered BETWEEN <? value("startDate") ?> AND (<? value("endDate") ?>::DATE + 1))\n<? if not exists("showUnposted") ?>\n AND (cntslip_posted)\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n)\nORDER BY slipnum;\n \n \n 191\n \n \n 515\n 110\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n \n \n \n \n 100\n 90\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n 5\n 185\n 745\n 185\n 2\n \n \n \n \n \n \n \n \n 515\n 90\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 56\n \n \n 300\n 15\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n tagnum\n \n \n \n \n 50\n 0\n 245\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtycounted\n \n \n \n 5\n 50\n 745\n 50\n 0\n \n \n \n 50\n 15\n 245\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 10\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 50\n 30\n 245\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 484\n 15\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n enteredby\n \n \n \n \n 300\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n slipnum\n \n \n \n \n 484\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n date_entered\n \n \n \n \n 670\n 0\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_posted\n \n \n \n
\n \n 16\n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 710\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 35 CountTagEditList \N \n\n Count Tag Edit List\n CountTagEditList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("classcode_id") ?>\n ( SELECT (classcode_code ||'-'||classcode_descrip)\n FROM classcode\n WHERE (classcode_id=<? value("classcode_id") ?>) ) AS code,\n\t text('Class Code:') AS codelbl\n <? elseif exists("classcode_pattern") ?>\n text(<? value("classcode_pattern") ?>) AS code,\n text('Class Code:') AS codelbl\n <? elseif exists("plancode_id") ?>\n ( SELECT (plancode_code ||'-'|| plancode_name)\n FROM plancode\n WHERE (plancode_id=<? value("plancode_id") ?>) ) AS code,\n\t text('Planner Code:') AS codelbl\n <? elseif exists("plancode_pattern") ?>\n text(<? value("plancode_pattern") ?>) AS code,\n text('Planner Code:') AS codelbl\n <? else ?>\n text('') AS code,\n text('') AS codelbl\n <? endif ?>\n \n \n \n detail\n SELECT formatBoolYN(invcnt_priority) AS f_priority,\n CASE WHEN (invcnt_tagnumber IS NULL) THEN 'Misc.'\n ELSE invcnt_tagnumber\n END AS f_tagnumber, \n formatDate(invcnt_tagdate) AS f_tagdate,\n item_number,\n item_descrip1,\n item_descrip2,\n warehous_code,\n CASE WHEN (invcnt_location_id IS NOT NULL)\n THEN (SELECT formatQty(SUM(itemloc_qty))\n FROM itemloc\n WHERE ((itemloc_itemsite_id=itemsite_id)\n AND (itemloc_location_id=invcnt_location_id)) )\n ELSE formatQty(itemsite_qtyonhand)\n END AS f_qoh,\n CASE WHEN (location_id IS NOT NULL)\n THEN location_name\n ELSE 'All' END AS location_name,\n CASE WHEN (invcnt_qoh_after IS NULL) THEN ''\n ELSE formatQty(invcnt_qoh_after)\n END AS f_cntqty,\n CASE WHEN (invcnt_qoh_after IS NULL) THEN ''\n ELSE formatQty(invcnt_qoh_after - itemsite_qtyonhand)\n END AS f_variance,\n CASE WHEN (invcnt_qoh_after IS NULL) THEN ''\n WHEN ((itemsite_qtyonhand = 0) AND (invcnt_qoh_after > 0)) THEN formatPrcnt(1)\n WHEN ((itemsite_qtyonhand = 0) AND (invcnt_qoh_after < 0)) THEN formatPrcnt(-1)\n WHEN ((itemsite_qtyonhand = 0) AND (invcnt_qoh_after = 0)) THEN formatPrcnt(0)\n ELSE formatPrcnt((1 - (invcnt_qoh_after / itemsite_qtyonhand)) * -1)\n END AS f_percent,\n formatExtPrice(stdcost(item_id) * (invcnt_qoh_after - itemsite_qtyonhand)) AS f_amount\n FROM invcnt LEFT OUTER JOIN location ON (invcnt_location_id=location_id),\n item, whsinfo, itemsite\n WHERE ((invcnt_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (NOT invcnt_posted)\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("classcode_id") ?>\n AND (item_classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n AND (item_classcode_id IN ( SELECT classcode_id\n FROM classcode\n WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n<? elseif exists("plancode_id") ?>\n AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n AND (itemsite_plancode_id IN ( SELECT plancode_id\n FROM plancode\n WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? endif ?>\n)\nORDER BY f_priority DESC, item_number\n<? if exists("maxTags") ?>\n LIMIT <? value("maxTags") ?>\n<? endif ?>\n \n \n 205\n \n \n \n \n 5\n 200\n 745\n 200\n 2\n \n \n \n \n 100\n 100\n 330\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n \n \n \n \n 100\n 80\n 330\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n code\n \n \n \n \n \n 0\n 80\n 95\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n codelbl\n \n \n \n \n \n \n \n \n 8\n \n \n 38\n \n \n \n \n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n
\n detail\n \n \n detail\n \n 55\n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_variance\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 295\n 15\n 104\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_tagdate\n \n \n \n \n 408\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n location_name\n \n \n \n \n 580\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_percent\n \n \n \n \n 494\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_cntqty\n \n \n \n \n 60\n 0\n 225\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_amount\n \n \n \n \n 295\n 0\n 104\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_tagnumber\n \n \n \n \n 408\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qoh\n \n \n \n \n 10\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 10\n 15\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_priority\n \n \n \n \n 60\n 15\n 225\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 60\n 30\n 225\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n
\n \n 21\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 39 CountTagsByClassCode \N \n\n Count Tags By Class Code\n CountTagsByClassCode\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("classcode_id") ?>\n ( SELECT (classcode_code || '-' || classcode_descrip)\n FROM classcode\n WHERE (classcode_id=<? value("classcode_id") ?>) )\n <? elseif exists("classcode_pattern") ?>\n text(<? value("classcode_pattern") ?>)\n <? else ?>\n text('All Class Codes')\n <? endif ?>\n AS classcode,\n <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse;\n \n \n detail\n SELECT invcnt_id, invcnt_tagnumber, warehous_code,\n item_number, item_descrip1, item_descrip2,\n formatDate(invcnt_tagdate) AS createddate,\n invcnt_tag_username AS createdby,\n CASE WHEN (invcnt_cntdate IS NULL) THEN ''\n ELSE formatDate(invcnt_cntdate)\n END AS entereddate,\n CASE WHEN (invcnt_cntdate IS NULL) THEN ''\n ELSE invcnt_cnt_username\n END AS enteredby,\n CASE WHEN (NOT invcnt_posted) THEN ''\n ELSE formatDate(invcnt_postdate)\n END AS posteddate,\n CASE WHEN (NOT invcnt_posted) THEN ''\n ELSE invcnt_post_username\n END AS postedby,\n CASE WHEN (NOT invcnt_posted) THEN ''\n ELSE formatQty(invcnt_qoh_before)\n END AS qohbefore,\n CASE WHEN (invcnt_qoh_after IS NULL) THEN ''\n ELSE formatQty(invcnt_qoh_after)\n END AS qohafter,\n CASE WHEN (NOT invcnt_posted) THEN ''\n ELSE formatQty(invcnt_qoh_after - invcnt_qoh_before)\n END AS variance,\n CASE WHEN (NOT invcnt_posted) THEN ''\n WHEN (invcnt_qoh_before=0) THEN formatScrap(1)\n ELSE formatScrap((1 - (invcnt_qoh_after / invcnt_qoh_before)) * -1)\n END AS percentage\n FROM invcnt, itemsite, item, whsinfo\n WHERE ((invcnt_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (date(invcnt_tagdate) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if not exists("showUnposted") ?>\n AND (invcnt_posted)\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("classcode_id") ?>\n AND (item_classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n AND (item_classcode_id IN (SELECT classcode_id\n FROM classcode\n WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n<? endif ?>\n)\nORDER BY invcnt_tagdate;\n \n \n 236\n \n \n \n \n \n \n \n \n 100\n 90\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n classcode\n \n \n \n \n \n \n \n \n \n \n \n 500\n 110\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n 500\n 90\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n 100\n 110\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n 5\n 229\n 745\n 229\n 2\n \n \n \n \n \n \n \n \n 6\n \n \n 66\n \n \n \n \n \n \n \n \n 5\n 60\n 745\n 60\n 2\n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 66\n \n \n 60\n 15\n 225\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 295\n 0\n 105\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n invcnt_tagnumber\n \n \n \n \n 409\n 45\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qohbefore\n \n \n \n \n 409\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n createddate\n \n \n \n 5\n 60\n 745\n 60\n 0\n \n \n \n 580\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n postedby\n \n \n \n \n 495\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n enteredby\n \n \n \n \n 60\n 30\n 225\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 580\n 45\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n variance\n \n \n \n \n 409\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n createdby\n \n \n \n \n 10\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n posteddate\n \n \n \n \n 60\n 0\n 225\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 665\n 45\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n percentage\n \n \n \n \n 495\n 45\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qohafter\n \n \n \n \n 495\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n entereddate\n \n \n \n
\n \n 17\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 171 ItemMaster \N \n\n Item Master\n ItemMaster\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n formatBoolYN(item_active) AS f_item_active,\n item_descrip1, item_descrip2,\n CASE WHEN(item_type='P') THEN 'Purchased'\n WHEN(item_type='M') THEN 'Manufactured'\n WHEN(item_type='J') THEN 'Job'\n WHEN(item_type='F') THEN 'Phantom'\n WHEN(item_type='B') THEN 'Breeder'\n WHEN(item_type='C') THEN 'Co-Product'\n WHEN(item_type='Y') THEN 'By-Product'\n WHEN(item_type='R') THEN 'Reference'\n WHEN(item_type='T') THEN 'Tooling'\n WHEN(item_type='O') THEN 'Outside Process'\n WHEN(item_type='K') THEN 'Kit'\n ELSE item_type\n END AS f_item_type,\n formatBoolYN(item_config) AS f_item_config,\n (classcode_code||' - '||classcode_descrip) AS f_classcode,\n CASE WHEN (COALESCE(freightclass_id, -1) <> -1) THEN (freightclass_code||' - '||freightclass_descrip) END AS f_freightclass,\n iuom.uom_name AS invuom,\n formatBoolYN(item_picklist) AS f_item_picklist,\n formatBoolYN(item_fractional) AS f_item_fractional,\n itemcapuom(item_id) AS capuom, itemaltcapuom(item_id) AS altcapuom, puom.uom_name AS shipuom,\n formatUOMRatio(itemcapinvrat(item_id)) AS f_capinvrat,\n formatUOMRatio(itemaltcapinvrat(item_id)) AS f_altcapinvrat,\n formatUOMRatio(iteminvpricerat(item_id)) AS f_shipinvrat,\n formatWeight(item_prodweight) AS f_item_prodweight,\n formatWeight(item_packweight) AS f_item_packweight,\n formatBoolYN(item_sold) AS f_item_sold\n FROM item JOIN classcode ON (classcode_id=item_classcode_id)\n JOIN uom iuom ON (iuom.uom_id=item_inv_uom_id)\n JOIN uom puom ON (puom.uom_id=item_price_uom_id)\n LEFT OUTER JOIN freightclass ON (freightclass_id=item_freightclass_id)\n WHERE (item_id=<? value("item_id") ?>)\n;\n \n \n sold\n SELECT uom_name,\n formatUOMRatio(iteminvpricerat(item_id)) AS f_iteminvpricerat,\n (prodcat_code||' - '||prodcat_descrip) AS f_prodcat,\n formatBoolYN(item_exclusive) AS f_item_exclusive,\n formatPrice(item_listprice) AS f_item_listprice,\n formatExtPrice(item_listprice / iteminvpricerat(item_id)) AS f_extprice\n FROM item, prodcat, uom\n WHERE ((item_id=<? value("item_id") ?>)\n AND (item_price_uom_id=uom_id)\n AND (item_sold)\n AND (item_prodcat_id=prodcat_id) );\n \n \n notes\n SELECT item_comments, item_extdescrip\n FROM item\n WHERE (item_id=<? value("item_id") ?>);\n \n \n itemchar\n SELECT 1 as one,\n char_name as charass_name,\n charass_value\n FROM charass, char\n WHERE ((charass_target_type='I')\n AND (charass_char_id=char_id)\n AND (charass_target_id=<? value("item_id") ?>))\nORDER BY char_name;\n \n \n imglist\n SELECT 1 as one,\n image_name, firstLine(image_descrip) as f_descrip,\n CASE WHEN (imageass_purpose='I') THEN 'Inventory Description'\n WHEN (imageass_purpose='P') THEN 'Product Description'\n WHEN (imageass_purpose='E') THEN 'Engineering Reference'\n WHEN (imageass_purpose='M') THEN 'Miscellaneous'\n ELSE 'Other'\n END as f_purpose\nFROM imageass, image\nWHERE ( (imageass_image_id=image_id)\n AND (imageass_source='I')\n AND (imageass_source_id=<? value("item_id") ?>) )\nORDER BY image_name;\n \n \n comments\n SELECT 1 as one,\n formatDate(comment_date) as f_date,\n comment_user,\n comment_text\nFROM comment\nWHERE ( (comment_source='I')\n AND (comment_source_id=<? value("item_id") ?>) )\nORDER BY comment_date;\n \n \n 333\n \n \n 135\n 310\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_item_sold\n \n \n \n \n \n 465\n 252\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_shipinvrat\n \n \n \n \n \n \n \n 505\n 135\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_item_config\n \n \n \n \n 505\n 155\n 225\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_freightclass\n \n \n \n \n \n 135\n 227\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n altcapuom\n \n \n \n \n 390\n 285\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_item_packweight\n \n \n \n \n 465\n 207\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_capinvrat\n \n \n \n \n 135\n 102\n 400\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n \n \n \n 135\n 155\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_classcode\n \n \n \n \n 135\n 135\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_item_type\n \n \n \n \n 135\n 65\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n 135\n 185\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n invuom\n \n \n \n \n \n \n \n 465\n 227\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_altcapinvrat\n \n \n \n \n \n \n \n 135\n 252\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n shipuom\n \n \n \n \n 135\n 285\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_item_prodweight\n \n \n \n \n 135\n 207\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n capuom\n \n \n \n \n 135\n 85\n 400\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n 565\n 65\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_item_active\n \n \n \n \n \n \n \n \n \n 590\n 185\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_item_fractional\n \n \n \n \n 370\n 185\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_item_picklist\n \n \n \n
\n sold\n \n \n sold\n \n 93\n \n \n \n 207\n 45\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n sold\n f_item_listprice\n \n \n \n \n 640\n 45\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n sold\n f_item_exclusive\n \n \n \n \n \n \n \n 207\n 25\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n sold\n f_prodcat\n \n \n \n \n 545\n 5\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n sold\n f_iteminvpricerat\n \n \n \n \n \n 207\n 65\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n sold\n f_extprice\n \n \n \n \n \n 207\n 5\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n sold\n uom_name\n \n \n \n \n
\n
\n notes\n \n \n notes\n \n 36\n \n \n \n 120\n 5\n 615\n 20\n \n 5\n \n Arial\n 10\n bold\n \n \n \n \n notes\n item_comments\n \n \n \n
\n
\n extdescrip\n \n \n notes\n \n 36\n \n \n \n 120\n 5\n 615\n 20\n \n 5\n \n Arial\n 10\n bold\n \n \n \n \n notes\n item_extdescrip\n \n \n \n
\n
\n itemchar\n \n itemchar\n one\n \n 57\n \n 120\n 50\n 690\n 50\n 0\n \n \n \n \n \n \n \n \n itemchar\n \n 21\n \n \n 300\n 0\n 385\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n itemchar\n charass_value\n \n \n \n \n 125\n 0\n 160\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n itemchar\n charass_name\n \n \n \n
\n
\n imglist\n \n imglist\n one\n \n 57\n \n \n \n \n \n 120\n 50\n 690\n 50\n 0\n \n \n \n \n \n imglist\n \n 21\n \n \n 565\n 0\n 130\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n imglist\n f_purpose\n \n \n \n \n 125\n 0\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n imglist\n image_name\n \n \n \n \n 250\n 0\n 315\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n imglist\n f_descrip\n \n \n \n
\n
\n comments\n \n comments\n one\n \n 57\n \n \n \n \n 120\n 50\n 690\n 50\n 0\n \n \n \n \n \n \n comments\n \n 21\n \n \n 315\n 0\n 370\n 15\n \n 5\n \n Arial\n 8\n bold\n \n \n \n \n comments\n comment_text\n \n \n \n \n 207\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n comments\n comment_user\n \n \n \n \n 125\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n comments\n f_date\n \n \n \n
\n \n 21\n \n \n \n \n 102\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 460 ItemSites \N \n\n Item Sites\n ItemSites\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT warehous_code,\n formatBoolYN(itemsite_active) AS active,\n item_number,\n item_descrip1,\n item_descrip2,\n formatBoolYN(itemsite_wosupply) AS supplied,\n formatBoolYN(itemsite_sold) AS sold,\n itemsite_soldranking,\n formatBoolYN(itemsite_stocked) AS stocked,\n formatBoolYN(itemsite_createpr) AS createpr,\n CASE WHEN (itemsite_controlmethod='N') THEN 'None'\n WHEN (itemsite_controlmethod='R') THEN 'Regular'\n WHEN (itemsite_controlmethod='L') THEN 'Lot #'\n WHEN (itemsite_controlmethod='S') THEN 'Serial #'\n ELSE '?'\n END AS controlmethod,\n formatBoolYN(itemsite_loccntrl) AS locationcontrol,\n CASE WHEN (itemsite_location_id=-1) THEN 'None'\n ELSE ( SELECT location_name\n FROM location\n WHERE (location_id=itemsite_location_id) )\n END AS defaultlocation,\n formatBoolYN(itemsite_useparams) AS enforceparams,\n formatBoolYN(itemsite_useparamsmanual) AS onmanualorders,\n formatQty(itemsite_reorderlevel) AS reorderlevel,\n formatQty(itemsite_ordertoqty) AS orderupto,\n formatQty(itemsite_multordqty) AS ordermult,\n formatQty(itemsite_safetystock) AS safetystock,\n itemsite_abcclass,\n itemsite_cyclecountfreq,\n itemsite_leadtime,\n itemsite_eventfence,\n formatQty(itemsite_qtyonhand) AS qoh,\n formatDate(itemsite_datelastused, 'Never') AS lastused,\n formatDate(itemsite_datelastcount, 'Never') AS lastcounted,\n CASE WHEN(itemsite_plancode_id=-1) THEN 'Error'\n ELSE (SELECT (plancode_code || '-' || plancode_name)\n FROM plancode\n WHERE (plancode_id=itemsite_plancode_id) )\n END AS plannercode\n FROM item, uom, itemsite, whsinfo\n WHERE ((itemsite_warehous_id=warehous_id)\n AND (itemsite_item_id=item_id)\n AND(item_inv_uom_id=uom_id)\n <? if exists("search_pattern") ?>\n AND ((item_number ~* <? value("search_pattern") ?>)\n OR (item_descrip1 || ' ' || item_descrip2 ~* <? value("search_pattern") ?>)\n OR (warehous_code ~* <? value("search_pattern") ?>))\n <? endif ?>\n <? if exists("item_id") ?>\n AND (item_id=<? value("item_id") ?>)\n <? endif ?>\n <? if exists("classcode_id") ?>\n AND (item_classcode_id=<? value("classcode_id") ?>)\n <? endif ?>\n <? if exists("itemgrp_id") ?>\n AND (item_id IN (SELECT itemgrpitem_item_id \n FROM itemgrpitem \n WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n <? endif ?>\n <? if exists("plancode_id") ?>\n AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n <? endif ?>\n <? if exists("costcat_id") ?>\n AND (itemsite_costcat_id=<? value("costcat_id") ?>)\n <? endif ?>\n <? if exists("classcode_pattern") ?>\n AND (item_classcode_id IN (SELECT classcode_id \n FROM classcode \n WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n <? endif ?>\n <? if exists("itemgrp_pattern") ?>\n AND (item_id IN (SELECT itemgrpitem_item_id \n FROM itemgrpitem, itemgrp \n WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id) \n AND (itemgrp_name ~ <? value("itemgrp_pattern") ?>) ) ))\n <? endif ?>\n <? if exists("plancode_pattern") ?>\n AND (itemsite_plancode_id IN (SELECT plancode_id \n FROM plancode \n WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n <? endif ?>\n <? if exists("costcat_pattern") ?>\n AND (itemsite_costcat_id IN (SELECT costcat_id \n FROM costcat \n WHERE (costcat_code ~ <? value("costcat_pattern") ?>)))\n <? endif ?>\n <? if exists("warehous_id") ?>\n AND (warehous_id=<? value("warehous_id") ?>)\n <? endif ?>\n <? if not exists("showInactive") ?>\n AND (itemsite_active)\n <? endif ?>\n)\nORDER BY item_number, warehous_code;\n \n \n 281\n \n \n \n \n \n \n \n \n \n \n \n \n 5\n 275\n 745\n 275\n 2\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 10\n 38\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 6\n \n \n 81\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 5\n 75\n 745\n 75\n 2\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 81\n \n \n 580\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n orderupto\n \n \n \n \n 490\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n enforceparams\n \n \n \n \n 10\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 260\n 60\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qoh\n \n \n \n \n 430\n 60\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n lastcounted\n \n \n \n \n 580\n 45\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n safetystock\n \n \n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n reorderlevel\n \n \n \n \n 409\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n controlmethod\n \n \n \n \n 50\n 0\n 229\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 280\n 0\n 45\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n supplied\n \n \n \n \n 330\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n createpr\n \n \n \n \n 280\n 30\n 45\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n stocked\n \n \n \n \n 330\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemsite_soldranking\n \n \n \n \n 409\n 30\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n defaultlocation\n \n \n \n \n 409\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n locationcontrol\n \n \n \n \n 10\n 15\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n active\n \n \n \n 5\n 75\n 745\n 75\n 0\n \n \n \n 670\n 15\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemsite_cyclecountfreq\n \n \n \n \n 280\n 15\n 45\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n sold\n \n \n \n \n 50\n 30\n 229\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 670\n 0\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemsite_abcclass\n \n \n \n \n 50\n 15\n 229\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 490\n 15\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n onmanualorders\n \n \n \n \n 50\n 45\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n plannercode\n \n \n \n \n 345\n 60\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n lastused\n \n \n \n \n 670\n 45\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemsite_eventfence\n \n \n \n \n 580\n 30\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ordermult\n \n \n \n \n 670\n 30\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemsite_leadtime\n \n \n \n
\n \n 16\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 67 PricesByItem \N \n\n Prices By Item\n PricesByItem\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n item_descrip1,\n item_descrip2,\n <? if exists("showExpired") ?>\n text('Yes')\n <? else ?>\n text('No')\n <? endif ?>\n AS f_showexpired,\n <? if exists("showFuture") ?>\n text('Yes')\n <? else ?>\n text('No')\n <? endif ?>\n AS f_showfuture,\n <? if exists("showCosts") ?>\n <? if exists("actualCosts") ?>\n text('Show Costs and Margins using Actual Costs')\n <? else ?>\n text('Show Costs and Margins using Standard Costs')\n <? endif ?>\n AS f_showcosts,\n text('Cost') AS f_costlabel,\n text('Margin') AS f_marginlabel\n <? else ?>\n text('') AS f_showcosts,\n text('') AS f_costlabel,\n text('') AS f_marginlabel\n <? endif ?>\n FROM item\n WHERE (item_id=<? value("item_id") ?>);\n\n \n \n detail\n SELECT itemid, sourcetype, schedulename, type, typename,\n CASE WHEN (qtybreak = -1) THEN 'N/A'\n ELSE formatQty(qtybreak)\n END AS f_qtybreak,\n price, formatPrice(price) AS f_price,\n <? if exists("showCosts") ?>\n cost AS cost,\n formatCost(cost) AS f_cost,\n CASE WHEN ((price = 0) OR (cost = 0)) THEN 'N/A'\n ELSE formatScrap((price - cost) / price)\n END AS f_margin\n <? else ?>\n 0 AS cost,\n text('') AS f_cost,\n text('') AS f_margin\n <? endif ?>\nFROM ( SELECT ipsprice_id AS itemid, 1 AS sourcetype,\n ipshead_name AS schedulename, 'Customer' AS type,\n cust_name AS typename,\n ipsprice_qtybreak AS qtybreak,\n ipsprice_price AS price,\n <? if exists("actualCosts") ?>\n (actcost(item_id) * iteminvpricerat(item_id))\n <? else ?>\n (stdcost(item_id) * iteminvpricerat(item_id))\n <? endif ?>\n AS cost\n FROM ipsass, ipshead, ipsprice, custinfo, item\n WHERE ( (ipsass_ipshead_id=ipshead_id)\n AND (ipsprice_ipshead_id=ipshead_id)\n AND (ipsass_cust_id=cust_id)\n AND (ipsprice_item_id=item_id)\n AND (item_id=<? value("item_id") ?>)\n<? if not exists("showExpired") ?>\n AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n )\n\n UNION\n SELECT ipsprice_id AS itemid, 2 AS sourcetype,\n ipshead_name AS schedulename, 'Cust. Type' AS type,\n (custtype_code || '-' || custtype_descrip) AS typename,\n ipsprice_qtybreak AS qtybreak,\n ipsprice_price AS price,\n <? if exists("actualCosts") ?>\n (actcost(item_id) * iteminvpricerat(item_id))\n <? else ?>\n (stdcost(item_id) * iteminvpricerat(item_id))\n <? endif ?>\n AS cost\n FROM ipsass, ipshead, ipsprice, custtype, item\n WHERE ( (ipsass_ipshead_id=ipshead_id)\n AND (ipsprice_ipshead_id=ipshead_id)\n AND (ipsass_custtype_id=custtype_id)\n AND (ipsprice_item_id=item_id)\n AND (item_id=<? value("item_id") ?>)\n<? if not exists("showExpired") ?>\n AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n )\n\n UNION\n SELECT ipsprice_id AS itemid, 3 AS sourcetype,\n ipshead_name AS schedulename, 'Cust. Type Pattern' AS type,\n (custtype_code || '-' || custtype_descrip) AS typename,\n ipsprice_qtybreak AS qtybreak,\n ipsprice_price AS price,\n <? if exists("actualCosts") ?>\n (actcost(item_id) * iteminvpricerat(item_id))\n <? else ?>\n (stdcost(item_id) * iteminvpricerat(item_id))\n <? endif ?>\n AS cost\n FROM ipsass, ipshead, ipsprice, custtype, item\n WHERE ( (ipsass_ipshead_id=ipshead_id)\n AND (ipsprice_ipshead_id=ipshead_id)\n AND (COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0)\n AND (custtype_code ~ ipsass_custtype_pattern)\n AND (ipsprice_item_id=item_id)\n AND (item_id=<? value("item_id") ?>)\n<? if not exists("showExpired") ?>\n AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n )\n\n UNION\n SELECT ipsprice_id AS itemid, 4 AS sourcetype,\n ipshead_name AS schedulename, 'Sale' AS type,\n sale_name AS typename,\n ipsprice_qtybreak AS qtybreak,\n ipsprice_price AS price,\n <? if exists("actualCosts") ?>\n (actcost(item_id) * iteminvpricerat(item_id))\n <? else ?>\n (stdcost(item_id) * iteminvpricerat(item_id))\n <? endif ?>\n AS cost\n FROM sale, ipshead, ipsprice, item\n WHERE ( (sale_ipshead_id=ipshead_id)\n AND (ipsprice_ipshead_id=ipshead_id)\n AND (ipsprice_item_id=item_id)\n AND (item_id=<? value("item_id") ?>)\n<? if not exists("showExpired") ?>\n AND (sale_enddate > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (sale_startdate <= CURRENT_DATE)\n<? endif ?>\n )\n\n UNION\n SELECT ipsprice_id AS itemid, 5 AS sourcetype,\n ipshead_name AS schedulename, 'Cust. Ship-To' AS type,\n (cust_name || '-' || shipto_num) AS typename,\n ipsprice_qtybreak AS qtybreak,\n ipsprice_price AS price,\n <? if exists("actualCosts") ?>\n (actcost(item_id) * iteminvpricerat(item_id))\n <? else ?>\n (stdcost(item_id) * iteminvpricerat(item_id))\n <? endif ?>\n AS cost\n FROM ipsass, ipshead, ipsprice, custinfo, shiptoinfo, item\n WHERE ( (ipsass_ipshead_id=ipshead_id)\n AND (ipsprice_ipshead_id=ipshead_id)\n AND (ipsass_shipto_id=shipto_id)\n AND (shipto_cust_id=cust_id)\n AND (ipsprice_item_id=item_id)\n AND (item_id=<? value("item_id") ?>)\n<? if not exists("showExpired") ?>\n AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n )\n\n UNION\n SELECT ipsprice_id AS itemid, 5 AS sourcetype,\n ipshead_name AS schedulename, 'Cust. Ship-To Pattern' AS type,\n (cust_name || '-' || shipto_num) AS typename,\n ipsprice_qtybreak AS qtybreak,\n ipsprice_price AS price,\n <? if exists("actualCosts") ?>\n (actcost(item_id) * iteminvpricerat(item_id))\n <? else ?>\n (stdcost(item_id) * iteminvpricerat(item_id))\n <? endif ?>\n AS cost\n FROM ipsass, ipshead, ipsprice, custinfo, shiptoinfo, item\n WHERE ( (ipsass_ipshead_id=ipshead_id)\n AND (ipsprice_ipshead_id=ipshead_id)\n AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0)\n AND (shipto_num ~ ipsass_shipto_pattern)\n AND (shipto_cust_id=cust_id)\n AND (ipsprice_item_id=item_id)\n AND (item_id=<? value("item_id") ?>)\n<? if not exists("showExpired") ?>\n AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n )\n\n UNION\n SELECT item_id AS itemid, 0 AS sourcetype,\n 'List Price' AS schedulename, 'N/A' AS type,\n '' AS typename,\n -1 AS qtybreak,\n item_listprice AS price,\n <? if exists("actualCosts") ?>\n (actcost(item_id) * iteminvpricerat(item_id))\n <? else ?>\n (stdcost(item_id) * iteminvpricerat(item_id))\n <? endif ?>\n AS cost\n FROM item\n WHERE ( (NOT item_exclusive)\n AND (item_id=<? value("item_id") ?>) ) ) AS data\nORDER BY price;\n \n \n 221\n \n \n 565\n 80\n 114\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_showexpired\n \n \n \n \n 100\n 80\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n 665\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_marginlabel\n \n \n \n \n \n \n \n 100\n 100\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n 585\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_costlabel\n \n \n \n \n \n 405\n 120\n 335\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_showcosts\n \n \n \n \n \n 565\n 100\n 114\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_showfuture\n \n \n \n \n 100\n 120\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n \n \n 6\n \n \n 26\n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n \n \n 585\n 5\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_costlabel\n \n \n \n \n \n 665\n 5\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_costlabel\n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 505\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_price\n \n \n \n \n 135\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n type\n \n \n \n \n 10\n 0\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n schedulename\n \n \n \n \n 585\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_cost\n \n \n \n \n 425\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtybreak\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_margin\n \n \n \n \n 240\n 0\n 185\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n typename\n \n \n \n
\n \n 16\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 479 ProjectsList \N \n\n Projects Detailed List\n ProjectsList\n List of Projects and details\n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n projects\n detail\n \n \n 55\n \n \n
\n section\n \n project\n project\n \n 55\n \n \n \n 115\n 25\n 415\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n item\n \n \n \n \n 115\n 5\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n name\n \n \n \n \n \n \n 540\n 5\n 205\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n project_type\n \n \n \n \n 635\n 25\n 110\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n status\n \n \n \n \n 0\n 5\n 750\n 5\n 2\n \n \n 0\n 50\n 750\n 50\n 2\n \n \n \n \n type\n section\n \n 53\n \n \n 0\n 45\n 750\n 45\n 2\n \n \n \n \n 77\n 45\n 77\n 45\n 0\n \n \n \n \n \n 90\n 5\n 610\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n section_qtdisplayrole\n \n \n \n \n \n 33\n \n 305\n 5\n 750\n 5\n 0\n \n \n \n \n \n detail\n \n 18\n \n \n 305\n 2\n 135\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item\n \n \n \n \n 210\n 2\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n status\n \n \n \n \n 445\n 2\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qty\n \n \n \n \n 545\n 2\n 165\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_value\n \n \n \n \n 30\n 2\n 175\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n name\n \n \n \n
\n \n 41\n \n \n \n 700\n 16\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 0\n -11\n 750\n -11\n 2\n \n \n \n 75\n 16\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n List of Projects and details 0 2014-03-20 16:31:52.238383 149 POHistory \N \n\n P/O History\n POHistory\n \n \n \n select pohead_id, pohead_number from pohead order by pohead_number desc;\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT pohead_number, \n vend_name \n FROM pohead, vendinfo \n WHERE ((pohead_id=<? value("pohead_id") ?>) \n AND (pohead_vend_id=vend_id));\n \n \n detail\n SELECT \npoitem_linenumber as f_number, \nitem_number as f_item, \nuom_name as f_uom1, \nformatDate(poitem_duedate) as f_duedate, \npoitem_vend_item_number as f_vend_item, \npoitem_vend_uom as f_uom2, \nformatQty(poitem_qty_ordered) as f_ordered, \nformatqty(poitem_qty_received) as f_received \nFROM poitem, itemsite, item, uom \nWHERE ((poitem_itemsite_id=itemsite_id) \nAND (itemsite_item_id=item_id) \nAND (item_inv_uom_id=uom_id) \nAND (poitem_pohead_id=<? value("pohead_id") ?>)) \n \nUNION \n \nSELECT \npoitem_linenumber as f_number, \npoitem_vend_item_number as f_item, \nexpcat_code as f_uom1, \nformatDate(poitem_duedate) as f_duedate, \npoitem_vend_item_descrip as f_vend_item, \nexpcat_descrip as f_uom2, \nformatQty(poitem_qty_ordered) as f_ordered, \nformatqty(poitem_qty_received) as f_received \nFROM poitem, expcat \nWHERE ((poitem_expcat_id = expcat_id) \nAND (poitem_pohead_id=<? value("pohead_id") ?>)) \n \nORDER BY f_number;\n \n \n 205\n \n 5\n 200\n 990\n 200\n 2\n \n \n \n \n \n \n \n \n 105\n 120\n 385\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n vend_name\n \n \n \n \n \n \n \n \n 105\n 100\n 385\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n pohead_number\n \n \n \n \n \n \n \n \n \n 8\n \n \n 42\n \n \n \n \n \n \n \n \n \n 5\n 37\n 990\n 37\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 18\n \n \n 45\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_item\n \n \n \n \n 805\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ordered\n \n \n \n \n 900\n 0\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_received\n \n \n \n \n 180\n 0\n 145\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_uom1\n \n \n \n \n 5\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_number\n \n \n \n \n 730\n 0\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_duedate\n \n \n \n \n 525\n 0\n 195\n 15\n \n 1\n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_vend_item\n \n \n \n \n 325\n 0\n 190\n 15\n \n 1\n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_uom2\n \n \n \n
\n \n 32\n \n \n \n 945\n 17\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 85\n 17\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 156 PartiallyShippedOrders \N \n\n Partially Shipped Orders\n PartiallyShippedOrders\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT CASE WHEN (cohead_holdtype IN ('P', 'C', 'R')) THEN -1\n ELSE cohead_id\n END AS _coheadid, cohead_id,\n cohead_holdtype, cohead_number, cust_name,\n CASE WHEN (cohead_holdtype='N') THEN <? value("none") ?>\n WHEN (cohead_holdtype='C') THEN <? value("credit") ?>\n WHEN (cohead_holdtype='S') THEN <? value("ship") ?>\n WHEN (cohead_holdtype='P') THEN <? value("pack") ?>\n WHEN (cohead_holdtype='R') THEN <? value("return") ?>\n ELSE <? value("Other") ?>\n END AS f_holdtype,\n formatDate(cohead_orderdate) AS f_orderdate,\n formatDate(MIN(coitem_scheddate)) AS f_scheddate,\n formatDate(cohead_packdate) AS f_packdate,\n <? if exists("showPrices") ?>\n formatExtPrice( SUM( (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n (coitem_price / coitem_price_invuomratio) ) )\n <? else ?>\n text('')\n <? endif ?>\n AS f_extprice,\n SUM( (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n (coitem_price / coitem_price_invuomratio) ) AS backlog,\n MIN(coitem_scheddate) AS scheddate,\n COALESCE(MIN(shipitem_id), 0) AS shipped\n FROM cohead, itemsite, item, custinfo,\n coitem LEFT OUTER JOIN shipitem ON (shipitem_orderitem_id=coitem_id) \n WHERE ( (coitem_cohead_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (coitem_status='O')\n AND (cohead_id IN ( SELECT DISTINCT coitem_cohead_id\n FROM coitem\n WHERE (coitem_qtyshipped > 0) ))\n AND (coitem_qtyshipped < coitem_qtyord)\n AND (coitem_scheddate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n)\nGROUP BY cohead_id, cohead_number, cust_name, cohead_holdtype,\n cohead_orderdate, cohead_packdate\nORDER BY scheddate, cohead_number;\n \n \n head\n SELECT <? if exists("warehous_id") ?>\n ( SELECT (warehous_code||'-'||warehous_descrip)\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("showPrices") ?>\n text('$ Amount')\n <? else ?>\n text('')\n <? endif ?>\n AS f_amount,\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate;\n \n \n 205\n \n \n \n 484\n 75\n 220\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n 113\n 75\n 220\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n \n 484\n 95\n 220\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n 5\n 200\n 745\n 200\n 2\n \n \n \n \n \n \n \n 665\n 185\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_amount\n \n \n \n \n \n \n 8\n \n \n 28\n \n \n \n \n \n \n 665\n 5\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_amount\n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 18\n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_packdate\n \n \n \n \n 409\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_orderdate\n \n \n \n \n 75\n 0\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_name\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_extprice\n \n \n \n \n 325\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_holdtype\n \n \n \n \n 495\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_scheddate\n \n \n \n \n 5\n 0\n 65\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cohead_number\n \n \n \n
\n \n 19\n \n \n 80\n 0\n 140\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 715\n 0\n 30\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 181 ReceiptsReturnsByDate \N \n\n Receipts and Returns By Date\n ReceiptsReturnsByDate\n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("warehous_id") ?>\n (SELECT warehous_code FROM whsinfo WHERE warehous_id=<? value("warehous_id") ?>)\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("agentUsername") ?>\n TEXT(<? value("agentUsername" ?>)\n <? else ?>\n TEXT('All Agents')\n <? endif ?>\n AS agentUsername,\n <? if exists("showVariances") ?>\n text('Purch. Cost') AS f_purchcost,\n text('Recv. Cost') AS f_recvcost\n <? else ?>\n text('') AS f_purchcost,\n text('') AS f_recvcost\n <? endif ?>\n \n \n detail\n receivings\n detail\n \n \n 221\n \n \n \n \n 645\n 185\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_purchcost\n \n \n \n \n \n 455\n 70\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n 120\n 70\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n 645\n 200\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_recvcost\n \n \n \n \n \n \n 455\n 95\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n \n 120\n 95\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n agentUsername\n \n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n \n \n 6\n \n \n 41\n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n \n \n \n \n 645\n 20\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_recvcost\n \n \n \n \n 645\n 5\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_purchcost\n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 56\n \n \n 215\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n venditemnumber\n \n \n \n \n 530\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qty\n \n \n \n \n 645\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_recvcost\n \n \n \n \n 215\n 15\n 400\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n venditemdescrip\n \n \n \n \n 645\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_purchcost\n \n \n \n \n 5\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_name\n \n \n \n \n 110\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_duedate\n \n \n \n \n 110\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_recvdate\n \n \n \n 5\n 50\n 745\n 50\n 0\n \n \n \n 5\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ponumber\n \n \n \n \n 418\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n sense\n \n \n \n
\n \n 16\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 85\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 182 ReceiptsReturnsByItem \N \n\n Receipts and Returns By Item\n ReceiptsReturnsByItem\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n item_descrip1,\n item_descrip2,\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("warehous_id") ?>\n (SELECT warehous_code FROM whsinfo WHERE warehous_id=<? value("warehous_id") ?>)\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("agentUsername") ?>\n TEXT(<? value("agentUsername" ?>)\n <? else ?>\n TEXT('All Agents')\n <? endif ?>\n AS agentUsername,\n <? if exists("showVariances") ?>\n text('Purch. Cost') AS f_purchcost,\n text('Recv. Cost') AS f_recvcost\n <? else ?>\n text('') AS f_purchcost,\n text('') AS f_recvcost\n <? endif ?>\n FROM item\n WHERE (item_id=<? value("item_id") ?>);\n \n \n detail\n receivings\n detail\n \n \n 221\n \n \n 120\n 90\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n 455\n 90\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n 120\n 155\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n agentUsername\n \n \n \n \n \n 645\n 185\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_purchcost\n \n \n \n \n 645\n 200\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_recvcost\n \n \n \n \n \n 455\n 70\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n \n \n \n \n 120\n 70\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n 120\n 110\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n 120\n 135\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n \n 6\n \n \n 41\n \n \n 645\n 20\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_recvcost\n \n \n \n \n \n \n \n 645\n 5\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_purchcost\n \n \n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n \n
\n detail\n \n \n detail\n \n 37\n \n \n 215\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n venditemnumber\n \n \n \n \n 110\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_recvdate\n \n \n \n \n 215\n 15\n 400\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n venditemdescrip\n \n \n \n \n 418\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n sense\n \n \n \n \n 5\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_name\n \n \n \n \n 110\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_duedate\n \n \n \n \n 5\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ponumber\n \n \n \n \n 645\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_recvcost\n \n \n \n \n 645\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_purchcost\n \n \n \n \n 530\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qty\n \n \n \n 5\n 30\n 745\n 30\n 0\n \n \n
\n \n 17\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 85\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 403 SalesOrderAcknowledgement \N \n\n Sales Order Acknowledgement\n SalesOrderAcknowledgement\n Sales Order Acknowledgement Omits Closed Lines -- With Barcodes formatitemsitebarcode(itemsite_id) -- SO # barcoded formatsobarcode(cohead_id) -- With Logo, place logo graphic in images DB with name "logo"\n \n \n \n 0.05\n 0.05\n \n Letter\n \n 25\n 25\n 25\n 25\n \n head\n SELECT cust_number,\n formatsobarcode(cohead_id) AS order_barcode,\n\n formataddr(cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, (cohead_billtocity || ' ' || cohead_billtostate || ' ' || cohead_billtozipcode), cohead_billtocountry) AS billing_address, \n\n formataddr(cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3, (cohead_shiptocity || ' ' || cohead_shiptostate || ' ' || cohead_shiptozipcode), cohead_shiptocountry) AS shipping_address, \n\n trim(cntct_first_name || ' ' || cntct_last_name) AS cust_contact,\n cohead_billtoname,\n cohead_billtoaddress1,\n cohead_billtoaddress2,\n cohead_billtoaddress3,\n (cohead_billtocity || ' ' || cohead_billtostate || ' ' || cohead_billtozipcode) AS billtocitystatezip,\n cntct_phone AS cust_phone,\n cohead_shiptoname,\n cohead_shiptoaddress1,\n cohead_shiptoaddress2,\n cohead_shiptoaddress3,\n (cohead_shiptocity || ' ' || cohead_shiptostate || ' ' || cohead_shiptozipcode) AS shiptocitystatezip,\n cohead_number,\n cohead_shipvia,\n cohead_shiptophone,\n cohead_custponumber,\n formatDate(cohead_orderdate) AS orderdate,\n cohead_shipcomments, \n terms_descrip\n FROM cohead, custinfo, terms, cntct\n WHERE ((cohead_cust_id=cust_id)\n AND (cust_cntct_id=cntct_id)\n AND (cohead_terms_id=terms_id)\n AND (cohead_id=<? value("sohead_id") ?>)\n);\n \n \n scheddate\n SELECT formatDate(MIN(coitem_scheddate)) AS scheddate\n FROM coitem\n WHERE ((coitem_status <> 'X') AND (coitem_cohead_id=<? value("sohead_id") ?>));\n \n \n detail\n salesOrderItems\n list\n \n \n logo\n SELECT image_data \nFROM image \nWHERE ((image_name='logo'));\n \n \n 477\n \n \n 375\n 0\n 425\n 85\n \n stretch\n \n logo\n image_data\n \n \n \n \n 120\n 400\n 253\n 25\n \n \n Arial\n 12\n normal\n \n \n \n \n head\n cust_contact\n \n \n \n \n \n 175\n 195\n 100\n 20\n \n \n helvetica\n 14\n normal\n \n \n \n \n head\n orderdate\n \n \n \n \n \n 469\n 400\n 320\n 20\n \n \n Arial\n 12\n normal\n \n \n \n \n head\n terms_descrip\n \n \n \n \n \n 375\n 130\n 177\n 25\n \n 3of9\n 10\n \n 0.01\n \n head\n cust_number\n \n \n \n \n 375\n 160\n 307\n 25\n \n 3of9\n 20\n \n 0.01\n \n head\n cohead_custponumber\n \n \n \n \n \n 170\n 155\n 170\n 20\n \n \n helvetica\n 14\n normal\n \n \n \n \n head\n cohead_custponumber\n \n \n \n \n \n \n 433\n 215\n 331\n 20\n \n \n helvetica\n 14\n normal\n \n \n \n \n head\n cohead_shipvia\n \n \n \n \n \n 170\n 95\n 100\n 20\n \n \n helvetica\n 14\n normal\n \n \n \n \n head\n cohead_number\n \n \n \n \n 375\n 95\n 234\n 25\n \n 128\n 10\n \n 0.01\n \n head\n order_barcode\n \n \n \n \n 25\n 465\n 823\n 465\n 0\n \n \n \n \n 75\n 260\n 305\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cohead_billtoname\n \n \n \n \n 75\n 280\n 295\n 20\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n head\n billing_address\n \n \n \n \n \n \n \n 465\n 280\n 305\n 20\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n head\n shipping_address\n \n \n \n \n 170\n 125\n 170\n 20\n \n \n helvetica\n 14\n normal\n \n \n \n \n head\n cust_number\n \n \n \n \n \n \n 465\n 260\n 305\n 20\n \n \n helvetica\n 14\n normal\n \n \n \n \n head\n cohead_shiptoname\n \n \n \n \n \n 175\n 215\n 100\n 20\n \n \n helvetica\n 14\n normal\n \n \n \n \n scheddate\n scheddate\n \n \n \n 25\n 425\n 823\n 425\n 0\n \n \n \n \n \n \n
\n detail\n \n detail\n groupby\n \n 72\n \n \n 50\n 5\n 625\n 17\n \n 14\n \n helvetica\n 10\n normal\n \n \n \n \n head\n cohead_shipcomments\n \n \n \n \n \n lineitem\n coitem_linenumber\n \n 28\n \n 5\n 5\n 843\n 5\n 0\n \n \n \n \n \n detail\n \n 153\n \n \n 425\n 0\n 100\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n detail\n f_qtyshipped\n \n \n \n \n 635\n 0\n 100\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n detail\n f_qtyatshipping\n \n \n \n \n 365\n 30\n 469\n 35\n \n 128\n 15\n \n 0.01\n \n detail\n item_barcode\n \n \n \n \n 630\n 95\n 85\n 15\n \n \n helvetica\n 10\n normal\n \n \n \n \n detail\n enhanced_status\n \n \n \n \n 100\n 120\n 700\n 17\n \n 14\n \n helvetica\n 10\n normal\n \n \n \n \n detail\n coitem_memo\n \n \n \n 80\n 80\n 170\n 80\n 0\n \n \n \n \n 415\n 80\n 500\n 80\n 0\n \n \n \n \n 530\n 0\n 100\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n detail\n f_balance\n \n \n \n \n 80\n 110\n 170\n 110\n 0\n \n \n \n 25\n 40\n 295\n 20\n \n \n Arial\n 11\n bold\n \n \n \n \n detail\n item_descrip2_cust\n \n \n \n 305\n 110\n 395\n 110\n 0\n \n \n \n 25\n 0\n 200\n 20\n \n \n Arial\n 11\n bold\n \n \n \n \n detail\n item_number_cust\n \n \n \n \n 25\n 20\n 295\n 20\n \n \n Arial\n 11\n bold\n \n \n \n \n detail\n item_descrip1_cust\n \n \n \n 745\n 15\n 795\n 15\n 1\n \n \n 190\n 80\n 280\n 80\n 0\n \n \n 632\n 80\n 720\n 80\n 0\n \n \n 190\n 110\n 280\n 110\n 0\n \n \n \n 228\n 0\n 85\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n detail\n qty_uom\n \n \n \n \n 415\n 110\n 500\n 110\n 0\n \n \n 305\n 80\n 395\n 80\n 0\n \n \n \n 320\n 0\n 100\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n detail\n f_qtyord\n \n \n \n
\n \n 57\n \n \n 90\n 5\n 95\n 17\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 455\n 5\n 80\n 17\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n cohead_number\n \n \n \n \n \n \n 735\n 5\n 45\n 17\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 113\n \n 185\n 25\n 363\n 25\n 0\n \n \n 186\n 90\n 360\n 90\n 0\n \n \n \n \n
\n Sales Order Acknowledgement Omits Closed Lines -- With Barcodes formatitemsitebarcode(itemsite_id) -- SO # barcoded formatsobarcode(cohead_id) -- With Logo, place logo graphic in images DB with name "logo" 0 2015-10-01 17:15:58.47729 247 SelectPaymentsList \N \n\n Approve Payments List\n SelectPaymentsList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT apopen_id, apselectid, vendor, apopen_docnumber, apopen_ponumber,\n formatDate(apopen_duedate) AS f_duedate,\n formatDate(apopen_docdate) AS f_docdate,\n formatMoney(amount) AS f_amount,\n f_selected, f_late, status\n FROM (SELECT apopen_id, COALESCE(apselect_id, -1) AS apselectid,\n (vend_number || '-' || vend_name) AS vendor,\n apopen_docnumber, apopen_ponumber,\n apopen_duedate, apopen_docdate,\n (apopen_amount - apopen_paid -\n COALESCE((SELECT SUM(checkitem_amount / checkitem_curr_rate)\n FROM checkitem, checkhead\n WHERE ((checkitem_checkhead_id=checkhead_id)\n AND (checkitem_apopen_id=apopen_id)\n AND (NOT checkhead_void)\n AND (NOT checkhead_posted))\n ), 0)) AS amount,\n formatMoney(COALESCE(SUM(apselect_amount), 0)) AS f_selected,\n formatBoolYN(apopen_duedate <= CURRENT_DATE) AS f_late,\n CASE WHEN (apopen_status='O') THEN TEXT('Open')\n ELSE CASE WHEN (apopen_status='H') THEN TEXT('On Hold')\n ELSE CASE WHEN (apopen_status='C') THEN TEXT('Close')\n END\n END\n END AS status\n FROM vendinfo, apopen LEFT OUTER JOIN apselect ON (apselect_apopen_id=apopen_id)\n WHERE ( (apopen_open)\n AND (apopen_doctype IN ('V', 'D'))\n AND (apopen_vend_id=vend_id)\n<? if exists("vend_id") ?>\n AND (vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n AND (vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n AND (vend_vendtype_id IN (SELECT vendtype_id\n FROM vendtype\n WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n<? endif ?>\n )\nGROUP BY apopen_id, apselect_id, vend_number, vend_name,\n apopen_docnumber, apopen_ponumber,\n apopen_duedate, apopen_docdate, apopen_amount, apopen_paid, apopen_curr_id, apopen_status) AS data\n WHERE (amount <> 0.0)\nORDER BY apopen_duedate, amount DESC;\n \n \n head\n SELECT <? if exists("vend_id") ?>\n ( SELECT vend_name\n FROM vendinfo\n WHERE (vend_id=<? value("vend_id") ?>) )\n <? elseif exists("vendtype_id") ?>\n ( SELECT (vendtype_code || '-' || vendtype_descrip)\n FROM vendtype\n WHERE (vendtype_id=<? value("vendtype_id") ?>) )\n <? elseif exists("vendtype_pattern") ?>\n text(<? value("vendtype_pattern") ?>)\n <? else ?>\n text('All Vendors')\n <? endif ?>\n AS f_value,\n <? if reExists("vendtype_.*") ?>\n text('Vendor Type:')\n <? else ?>\n text('Vendor:')\n <? endif ?>\n AS f_label;\n \n \n \n 141\n \n \n 20\n 65\n 125\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n f_label\n \n \n \n \n \n \n \n \n \n \n \n 150\n 65\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_value\n \n \n \n \n 5\n 135\n 745\n 135\n 2\n \n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 17\n \n \n 205\n -1\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n apopen_ponumber\n \n \n \n \n 280\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_duedate\n \n \n \n \n 590\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_selected\n \n \n \n \n 505\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_amount\n \n \n \n \n 360\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_docdate\n \n \n \n \n 680\n 0\n 65\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_late\n \n \n \n \n 130\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n apopen_docnumber\n \n \n \n \n 5\n 0\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vendor\n \n \n \n \n 435\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n status\n \n \n \n
\n \n 17\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 49 SingleLevelBOM \N \n\n Single Level Bill of Materials\n SingleLevelBOM\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number, uom_name AS item_invuom, item_descrip1, item_descrip2\nFROM item, uom\nWHERE ((item_id=<? value("item_id") ?>)\nAND (item_inv_uom_id=uom_id));\n \n \n \n detail\n SELECT bomitem_seqnumber, item_number,\n invuom.uom_name AS invuomname, issueuom.uom_name AS issueuomname,\n item_descrip1, item_descrip2,\n formatBoolYN(bomitem_createwo) AS createchild,\n CASE WHEN (bomitem_issuemethod='S') THEN 'Push'\n WHEN (bomitem_issuemethod='L') THEN 'Pull'\n WHEN (bomitem_issuemethod='M') THEN 'Mixed'\n ELSE 'Special'\n END AS issuemethod,\n formatQty(bomitem_qtyfxd) AS issueqtyfxd,\n formatQty(itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyfxd)) AS invqtyfxd,\n formatQtyPer(bomitem_qtyper) AS issueqtyper,\n formatQtyPer(itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyper)) AS invqtyper,\n formatScrap(bomitem_scrap) AS scrap,\n formatQtyPer((bomitem_qtyfxd + bomitem_qtyper) * (1 + bomitem_scrap)) AS qtyreq,\n formatDate(bomitem_effective, <? value("always") ?>) AS effective,\n formatDate(bomitem_expires, <? value("never") ?>) AS expires,\n bomitem_ecn\n<? if exists("revision_id") ?>\n FROM bomitem(<? value("item_id") ?>,<? value("revision_id") ?>)\n<? else ?>\n FROM bomitem(<? value("item_id") ?>)\n<? endif ?>\n, item, uom AS issueuom, uom AS invuom\nWHERE ((bomitem_item_id=item_id)\nAND (item_inv_uom_id=invuom.uom_id)\nAND (bomitem_uom_id=issueuom.uom_id)\n<? if exists("expiredDays") ?>\n AND (bomitem_expires > (CURRENT_DATE - <? value("expiredDays") ?>))\n<? else ?>\n AND (bomitem_expires > CURRENT_DATE)\n<? endif ?>\n\n<? if exists("effectiveDays") ?>\n AND (bomitem_effective <= (CURRENT_DATE + <? value("effectiveDays") ?>))\n<? else ?>\n AND (bomitem_effective <= CURRENT_DATE)\n<? endif ?>\n\n)\nORDER BY bomitem_seqnumber, bomitem_effective;\n\n \n \n bomhead\n SELECT bomhead_docnum, bomhead_revision,\n formatDate(bomhead_revisiondate) AS f_revisiondate\nFROM bomhead\nWHERE ((bomhead_item_id=<? value("item_id") ?>)\n<? if exists("revision_id") ?>\nAND (bomhead_rev_id=<? value("revision_id") ?>)\n<? else ?>\nAND (bomhead_rev_id=getActiveRevId('BOM',<? value("item_id") ?>))\n<? endif ?>\n);\n \n \n 208\n \n \n \n \n 120\n 110\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n \n \n \n 482\n 130\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n bomhead_revision\n \n \n \n \n \n \n \n \n \n \n 120\n 90\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n \n \n 482\n 110\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n f_revisiondate\n \n \n \n \n 482\n 90\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n bomhead_docnum\n \n \n \n \n \n \n 120\n 130\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n 5\n 202\n 745\n 202\n 2\n \n \n \n \n \n \n \n \n 7\n \n \n 37\n \n \n \n \n \n \n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 57\n \n \n 405\n 18\n 37\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n invuomname\n \n \n \n \n 675\n 18\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n issuemethod\n \n \n \n \n 675\n 3\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n expires\n \n \n \n \n 440\n 3\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n scrap\n \n \n \n \n 15\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n bomitem_seqnumber\n \n \n \n \n 315\n 33\n 227\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 315\n 18\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n invqtyper\n \n \n \n \n 70\n 0\n 115\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 600\n 3\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n effective\n \n \n \n \n 455\n 18\n 135\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n bomitem_ecn\n \n \n \n \n 525\n 3\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyreq\n \n \n \n \n 600\n 18\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n createchild\n \n \n \n \n 70\n 33\n 227\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 315\n 3\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n issueqtyper\n \n \n \n \n 405\n 3\n 37\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n issueuomname\n \n \n \n \n 235\n 3\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n issueqtyfxd\n \n \n \n \n 235\n 18\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n invqtyfxd\n \n \n \n
\n \n 21\n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 52 SingleLevelWhereUsed \N \n\n Single Level Where Used\n SingleLevelWhereUsed\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n uom_name,\n item_descrip1,\n item_descrip2,\n <? if exists("effective") ?>\n formatDate(<? value("effective") ?>)\n <? else ?>\n text('Now')\n <? endif ?>\n AS effective\n FROM item JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (item_id=<? value("item_id") ?>);\n \n \n \n detail\n whereUsed\n detail\n \n \n 241\n \n \n \n \n 5\n 235\n 745\n 235\n 2\n \n \n \n 114\n 140\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n \n \n \n \n \n \n 450\n 120\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n effective\n \n \n \n \n 114\n 160\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n \n \n 114\n 120\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n \n 450\n 138\n 185\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n uom_name\n \n \n \n \n \n \n \n 6\n \n \n 41\n \n \n \n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 56\n \n \n 444\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_scrap\n \n \n \n \n 75\n 15\n 229\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 75\n 30\n 229\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 404\n 0\n 38\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n \n 675\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_issuemethod\n \n \n \n \n 675\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_expires\n \n \n \n \n 75\n 0\n 229\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n 4\n 50\n 745\n 50\n 0\n \n \n \n 5\n 0\n 65\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n bomitem_seqnumber\n \n \n \n \n 525\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyreq\n \n \n \n \n 600\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_createwo\n \n \n \n \n 315\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyper\n \n \n \n \n 600\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_effective\n \n \n \n \n 315\n 17\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyfxd\n \n \n \n
\n \n 16\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 175 SlowMovingInventoryByClassCode \N \n\n Slow Moving Inventory By Class Code\n SlowMovingInventoryByClassCode\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("warehous_id") ?>\n (SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("classcode_id") ?>\n (SELECT (classcode_code || '-' || classcode_descrip)\n FROM classcode\n WHERE (classcode_id=<? value("classcode_id") ?>) )\n <? elseif exists("classcode_pattern") ?>\n text(<? value("classcode_pattern") ?>)\n <? else ?>\n text('All Class Codes')\n <? endif ?>\n AS classcode,\n <? if exists("showValue") ?>\n <? if exists("useActualCosts") ?>\n text('Show Inventory Value with Actual Costs')\n <? else ?>\n text('Show Inventory Value with Standard Costs')\n <? endif ?>\n AS showvalues,\n text('Unit Cost') AS f_unitcost,\n text('Value') AS f_value,\n <? else ?>\n text('') AS showvalues,\n text('') AS f_unitcost,\n text('') AS f_value,\n <? endif ?>\n formatDate(<? value("cutoffDate") ?>) AS f_cutoff;\n \n \n detail\n SELECT warehous_code,\n item_number,\n item_descrip1,\n item_descrip2,\n uom_name,\n formatQty(itemsite_qtyonhand) AS f_qoh,\n formatDate(itemsite_datelastused) AS f_datelastused,\n <? if exists("showValue") ?>\n formatCost(cost)\n <? else ?>\n text('')\n <? endif ?>\n AS f_unitcost,\n noNeg(cost * itemsite_qtyonhand) AS value,\n <? if exists("showValue") ?>\n formatExtPrice(noNeg(cost * itemsite_qtyonhand))\n <? else ?>\n text('')\n <? endif ?>\n AS f_value\n FROM ( SELECT itemsite_id,\n warehous_code,\n item_number,\n item_descrip1,\n item_descrip2, uom_name,\n itemsite_qtyonhand,\n itemsite_datelastused,\n <? if exists("useActualCosts") ?>\n actcost(itemsite_item_id)\n <? else ?>\n stdcost(itemsite_item_id)\n <? endif ?>\n AS cost\n FROM itemsite, item, whsinfo, uom\n WHERE ((itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (itemsite_active)\n AND (itemsite_datelastused < <? value("cutoffDate") ?>)\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("classcode_id") ?>\n AND (item_classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n AND (item_classcode_id IN (SELECT classcode_id\n FROM classcode\n WHERE classcode_code ~ <? value("classcode_pattern") ?>) )\n<? endif ?>\n )\n ) AS data\nORDER BY warehous_code,\n<? if exists("orderByInventoryValue") ?>\n value DESC\n<? elseif exists("orderByDateLastUsed") ?>\n itemsite_datelastused\n<? else ?>\n item_number\n<? endif ?>\n \n \n 236\n \n \n 575\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_unitcost\n \n \n \n \n 130\n 140\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n 5\n 229\n 745\n 229\n 2\n \n \n \n \n \n \n \n \n \n 440\n 140\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n showvalues\n \n \n \n \n \n \n 660\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_value\n \n \n \n \n \n \n 130\n 120\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n classcode\n \n \n \n \n 540\n 120\n 195\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_cutoff\n \n \n \n \n \n 6\n \n \n 41\n \n \n 5\n 35\n 745\n 34\n 2\n \n \n \n \n \n \n 660\n 5\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_value\n \n \n \n \n \n 575\n 5\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_unitcost\n \n \n \n \n
\n detail\n \n \n detail\n \n 51\n \n \n 380\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_datelastused\n \n \n \n \n 105\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 660\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_value\n \n \n \n \n 105\n 15\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 25\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 490\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qoh\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 105\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 265\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n \n 575\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_unitcost\n \n \n \n
\n \n 16\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 16\n \n
\n 0 2015-10-01 17:15:58.47729 195 StandardBOL \N \n\n Standard Bill of Lading\n StandardBOL\n \n Letter\n \n 50\n 50\n 0\n 0\n \n head\n SELECT shiphead_shipvia, formatDate(shiphead_shipdate) AS shipdate,\n cust_name, cust_number, cohead_number, cohead_fob, cohead_custponumber,\n warehous_descrip, addr_line1 AS warehous_addr1, addr_line2 AS warehous_addr2, addr_line3 AS warehous_addr3, addr_city AS warehous_addr4, warehous_fob,\n cohead_shiptoname, cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3,\n (cohead_shiptocity || ' ' || cohead_shiptostate || ' ' || cohead_shiptozipcode) AS shiptocitystatezip,\n cohead_shiptophone\n FROM shiphead, cohead, whsinfo, custinfo\n LEFT OUTER JOIN addr ON (warehous_addr_id=addr_id)\n WHERE ((shiphead_order_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n AND (cohead_warehous_id=warehous_id)\n AND (shiphead_id=%1));\n \n \n detail\n SELECT coitem_linenumber, formatQty(SUM(shipitem_qty)) AS invqty, uom_name, roundUp(SUM(shipitem_qty) / itemuomratiobytype(item_id, 'Selling'))::integer AS shipqty,\n itemsellinguom(item_id) AS shipuom, item_number, item_descrip1, item_descrip2,\n formatQty(SUM(shipitem_qty) * item_prodweight) AS netweight,\n formatQty(SUM(shipitem_qty) * (item_prodweight + item_packweight)) AS grossweight\n FROM shipitem, coitem, itemsite, item, uom\n WHERE ((shipitem_orderitem_id=coitem_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (shipitem_shiphead_id=%1))\n GROUP BY coitem_linenumber, item_number, uom_name, shipuom,\n item_descrip1, item_descrip2, item_prodweight, item_packweight\n ORDER BY coitem_linenumber;\n \n \n \n foot\n SELECT formatQty(SUM(shipitem_qty * item_prodweight)) AS netweight,\n formatQty(SUM(shipitem_qty * (item_prodweight + item_packweight))) AS grossweight,\n CASE\n WHEN ('%3' = 'C') THEN 'X'\n ELSE ' '\n END AS collectflag,\n CASE\n WHEN ('%3' = 'C') THEN 'Therm-O-Rock East, Inc.'\n ELSE ' '\n END AS section7,\n CASE\n WHEN ('%3' = 'C') THEN 'Therm-O-Rock, East, Inc.'\n ELSE ' '\n END AS collect_name,\n CASE\n WHEN ('%3' = 'C') THEN 'Pine Street'\n ELSE ' '\n END AS collect_address1,\n CASE\n WHEN ('%3' = 'C') THEN ''\n ELSE ' '\n END AS collect_address2,\n CASE\n WHEN ('%3' = 'C') THEN 'New Eagle PA 15067'\n ELSE ' '\n END AS collect_address3\n FROM shipitem, coitem, itemsite, item\n WHERE ((shipitem_orderitem_id=coitem_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (shipitem_shiphead_id=%1));\n \n \n notes\n SELECT shiphead_notes\n FROM shiphead\n WHERE (shiphead_id=%1);\n \n \n \n 242\n \n \n 95\n 125\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n warehous_addr2\n \n \n \n \n 600\n 5\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n shipdate\n \n \n \n \n 530\n 165\n 300\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n shiptocitystatezip\n \n \n \n \n 95\n 165\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n warehous_addr4\n \n \n \n \n 530\n 145\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_shiptoaddress3\n \n \n \n \n 530\n 125\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_shiptoaddress2\n \n \n \n \n 95\n 145\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n warehous_addr3\n \n \n \n \n 95\n 85\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n warehous_descrip\n \n \n \n \n 530\n 85\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_shiptoname\n \n \n \n \n 530\n 105\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_shiptoaddress1\n \n \n \n \n 115\n 35\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n shiphead_shipvia\n \n \n \n \n 95\n 105\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n warehous_addr1\n \n \n \n \n 530\n 185\n 300\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_shiptophone\n \n \n \n
\n detail\n \n \n detail\n \n 57\n \n \n 200\n 40\n 300\n 14\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 95\n 30\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n uom_name\n \n \n \n \n 10\n 30\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n invqty\n \n \n \n \n 200\n 5\n 300\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n item_number\n \n \n \n \n 520\n 5\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n netweight\n \n \n \n \n 10\n 5\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n shipqty\n \n \n \n \n 520\n 25\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n grossweight\n \n \n \n \n 94\n 5\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n shipuom\n \n \n \n \n 200\n 25\n 300\n 14\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n item_descrip1\n \n \n \n
\n \n \n 287\n \n \n 230\n 180\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n foot\n collect_address2\n \n \n \n \n 438\n 261\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n foot\n section7\n \n \n \n \n \n 520\n 5\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n foot\n netweight\n \n \n \n \n 614\n 60\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_fob\n \n \n \n \n 20\n 180\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n foot\n collect_name\n \n \n \n \n \n 520\n 25\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n foot\n grossweight\n \n \n \n \n \n 230\n 200\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n foot\n collect_address3\n \n \n \n \n 728\n 261\n 46\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n foot\n collectflag\n \n \n \n \n 614\n 100\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_number\n \n \n \n \n 614\n 120\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_custponumber\n \n \n \n \n 614\n 80\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cust_number\n \n \n \n \n \n 20\n 200\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n foot\n collect_address1\n \n \n \n \n 50\n 10\n 400\n 100\n \n \n Arial\n 10\n normal\n \n \n \n \n notes\n shiphead_notes\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 250 SummarizedGLTransactions \N \n\n Summarized G/L Transactions\n SummarizedGLTransactions\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("source") ?>\n text(<? value("source") ?>)\n <? else ?>\n text('All Sources')\n <? endif ?>\n AS source,\n <? if exists("showUsernames") ?>\n text('Username')\n <? else ?>\n text('')\n <? endif ?>\n AS f_username;\n \n \n detail\n SELECT data.accnt_id AS accnt_id,\n-- account information\n formatGLAccount(data.accnt_id) AS account,\n accnt_descrip,\n f_debit,\n f_credit,\n-- transactionn details\n formatDate(gltrans_date) AS transdate,\n gltrans_source,\n gltrans_doctype,\n gltrans_docnumber,\n gltrans_notes,\n f_debitdetail,\n f_creditdetail,\n <? if exists("showUsernames") ?>\n gltrans_username\n <? else ?>\n text('')\n <? endif ?>\n AS f_username\n FROM ( SELECT accnt_id,\n accnt_number,\n accnt_profit,\n accnt_sub,\n accnt_descrip,\n formatMoney( SUM( CASE WHEN (gltrans_amount < 0) THEN (gltrans_amount * -1)\n ELSE 0\n END ) ) AS f_debit,\n formatMoney( SUM( CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n ELSE 0\n END ) ) AS f_credit\n FROM gltrans, accnt\n WHERE ( (gltrans_accnt_id=accnt_id)\n AND (NOT gltrans_deleted)\n AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n <? if exists("source") ?>\n AND (gltrans_source=<? value("source") ?>)\n <? endif ?>\n <? if exists("unpostedTransactions") ?>\n AND (NOT gltrans_posted)\n <? elseif exists("postedTransactions") ?>\n AND (gltrans_posted)\n <? endif ?>\n )\n GROUP BY accnt_id, accnt_number, accnt_profit, accnt_sub, accnt_descrip\n ) AS data LEFT OUTER JOIN\n ( SELECT accnt_id,\n gltrans_date,\n gltrans_created,\n gltrans_source,\n gltrans_doctype,\n gltrans_docnumber,\n gltrans_notes,\n gltrans_username,\n CASE WHEN (gltrans_amount < 0) THEN formatMoney(gltrans_amount * -1)\n ELSE ''\n END AS f_debitdetail,\n CASE WHEN (gltrans_amount > 0) THEN formatMoney(gltrans_amount)\n ELSE ''\n END AS f_creditdetail\n FROM gltrans, accnt\n WHERE ((gltrans_accnt_id=accnt_id)\n AND (NOT gltrans_deleted)\n AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n <? if exists("source") ?>\n AND (gltrans_source=<? value("source") ?>)\n <? endif ?>\n <? if exists("unpostedTransactions") ?>\n AND (NOT gltrans_posted)\n <? elseif exists("postedTransactions") ?>\n AND (gltrans_posted)\n <? endif ?>\n )\n ) AS data2 ON (data.accnt_id=data2.accnt_id)\nORDER BY accnt_number, accnt_profit, accnt_sub, gltrans_date DESC, gltrans_created;\n \n \n 201\n \n \n 5\n 200\n 745\n 200\n 2\n \n \n \n 545\n 90\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n 140\n 70\n 290\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n source\n \n \n \n \n \n 665\n 185\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_username\n \n \n \n \n \n \n \n \n 545\n 70\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n \n \n \n 17\n \n \n 28\n \n \n \n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n 665\n 5\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_username\n \n \n \n \n \n
\n detail\n \n detail\n accnt_id\n \n 23\n \n \n 10\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n account\n \n \n \n \n 595\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_credit\n \n \n \n \n 120\n 0\n 305\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n accnt_descrip\n \n \n \n \n 509\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_debit\n \n \n \n \n 14\n \n 112\n 5\n 744\n 5\n 0\n \n \n \n \n \n detail\n \n 24\n \n \n 10\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n transdate\n \n \n \n \n 375\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_doctype\n \n \n \n \n 595\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_creditdetail\n \n \n \n \n 330\n 0\n 36\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_source\n \n \n \n \n 434\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_docnumber\n \n \n \n \n 120\n 0\n 200\n 15\n \n 5\n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_notes\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_username\n \n \n \n \n 509\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_debitdetail\n \n \n \n
\n \n 26\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 419 TaxHistorySummary \N \n\n Tax History Summary\n TaxHistorySummary\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("showSales") ?>\n 'Yes'\n <? else ?>\n 'No'\n <? endif ?>\n AS showSales,\n <? if exists("showPurchases") ?>\n 'Yes'\n <? else ?>\n 'No'\n <? endif ?>\n AS showPurchases,\n <? value("groupProper") ?> AS group,\n <? value("groupProper") ?> || ':' AS selectionLit,\n <? value("selection") ?> AS selection,\n <? if exists("distDate") ?>\n text('Distribution Date')\n <? else ?>\n text('Document Date')\n <? endif ?>\n AS basis,\n formatDate(<? value("startDate") ?>) AS startdate,\n formatDate(<? value("endDate") ?>) AS enddate;\n \n \n detail\n -----------BEGIN SUMMARY----------\nSELECT <? literal("groupBy") ?> AS group, \n <? literal("groupBy") ?>_descrip AS description, \n formatMoney(SUM(salesbase)) AS f_salesbase,\n formatMoney(SUM(freightbase)) AS f_freightbase, \n CASE WHEN (SUM(freighttax) > 0) THEN true ELSE false END AS freighttax, \n SUM(salestaxbase) AS salestaxbase,\n formatMoney(SUM(salestaxbase)) AS f_salestaxbase,\n formatMoney(SUM(purchasebase)) AS f_purchasebase,\n SUM(purchasetaxbase) * -1 AS purchasetaxbase, \n formatMoney(SUM(purchasetaxbase) * -1) AS f_purchasetaxbase, \n SUM(salestaxbase) + SUM(purchasetaxbase) AS nettaxbase,\n formatMoney(SUM(salestaxbase) + SUM(purchasetaxbase)) AS f_nettaxbase\nFROM (\n------------END SUMMARY--------------\n<? if exists("showSales") ?>\n------------BEGIN SALES--------------\n-- All sales tax history including memos \nSELECT \n taxhist_distdate, \n tax_code AS tax, tax_descrip,\n COALESCE(taxtype_name,<? value("none") ?>) AS taxtype, taxtype_descrip,\n COALESCE(taxclass_code,<? value("none") ?>) AS taxclass, taxclass_descrip,\n COALESCE(taxauth_code,<? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n COALESCE(taxzone_code,<? value("none") ?>) AS taxzone, taxzone_descrip, curr_abbr, \n CASE\n WHEN (cohist_doctype != 'C') THEN\n cohist_invcnumber\n ELSE\n cohist_ordernumber\n END AS docnumber, \n <? value("sales") ?> AS source,\n CASE\n WHEN (cohist_doctype='I') THEN\n <? value("invoice") ?>\n WHEN (cohist_doctype='C') THEN\n <? value("creditmemo") ?> \n WHEN (cohist_doctype='D') THEN\n <? value("debitmemo") ?>\n ELSE\n <? value("other") ?>\n END AS doctype,\n item_number, COALESCE(item_descrip1,cohist_misc_descrip) AS description,\n CASE\n WHEN (cohist_doctype != 'C') THEN\n cohist_ordernumber \n END AS ordernumber, cohist_invcdate AS docdate,\n cohist_billtoname AS name, \n cohist_qtyshipped AS qty, \n cohist_unitprice AS unitprice, (cohist_qtyshipped * cohist_unitprice) AS amount,\n CASE\n WHEN (cohist_misc_type IS NULL OR cohist_misc_type IN ('M','F')) THEN\n currToBase(cohist_curr_id, cohist_qtyshipped * cohist_unitprice, cohist_invcdate) \n ELSE 0\n END AS salesbase,\n CASE\n WHEN (cohist_misc_type = 'F') THEN\n currToBase(cohist_curr_id, cohist_qtyshipped * cohist_unitprice, cohist_invcdate) \n ELSE 0\n END AS freightbase,\n CASE\n WHEN (cohist_misc_type = 'F') THEN\n taxhist_tax / taxhist_curr_rate\n ELSE 0\n END AS freighttax,\n 0 AS purchasebase,\n taxhist_tax AS taxlocal,\n taxhist_tax / taxhist_curr_rate AS taxbase,\n taxhist_tax / taxhist_curr_rate AS salestaxbase,\n 0 AS purchasetaxbase\nFROM cohisttax\n JOIN cohist ON (cohist_id=taxhist_parent_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (cohist_taxzone_id=taxzone_id)\n LEFT OUTER JOIN itemsite ON (cohist_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id=item_id)\n<? if exists("distDate") ?>\nWHERE ((taxhist_distdate BETWEEN <? value("startDate") ?>\n AND <? value("endDate") ?>)\n<? else ?>\nWHERE ((taxhist_docdate BETWEEN <? value("startDate") ?>\n AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("tax_id") ?>\n AND (taxhist_tax_id=<? value("tax_id") ?>)\n<? endif ?>\n<? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=<? value("taxtype_id") ?>)\n<? endif ?>\n<? if exists("taxclass_id") ?>\n AND (taxclass_id=<? value("taxclass_id") ?>)\n<? endif ?>\n<? if exists("taxauth_id") ?>\n AND (taxauth_id=<? value("taxauth_id") ?>)\n<? endif ?>\n<? if exists("taxzone_id") ?>\n AND (taxzone_id=<? value("taxzone_id") ?>)\n<? endif ?>\n)\n<? endif ?>\n--------------END SALES--------------------\n<? if exists("showPurchases") ?>\n<? if exists("showSales") ?>\n-- Union because sales and purchase shown together\nUNION ALL\n<? endif ?>\n<? endif ?>\n------------BEGIN PURCHASE----------------\n<? if exists("showPurchases") ?>\n-- A/P Memo history\nSELECT \n taxhist_distdate, \n tax_code AS tax, tax_descrip,\n COALESCE(taxtype_name,<? value("none") ?>) AS taxtype, taxtype_descrip,\n COALESCE(taxclass_code,<? value("none") ?>) AS taxclass, taxclass_descrip,\n COALESCE(taxauth_code,<? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n <? value("none") ?> AS taxzone,'' AS taxzone_descrip, curr_abbr, \n apopen_docnumber AS docnumber, \n <? value("purchase") ?> AS source,\n CASE\n WHEN (apopen_doctype='C') THEN\n <? value("creditmemo") ?> \n WHEN (apopen_doctype='D') THEN\n <? value("debitmemo") ?>\n ELSE\n <? value("other") ?>\n END AS doctype,\n '' AS item_number, apopen_notes AS description,\n apopen_ponumber AS ordernumber, apopen_docdate AS docdate,\n vend_name AS name, \n 1 AS qty, \n apopen_amount AS unitprice, apopen_amount AS amount,\n 0 AS salesbase,\n 0 AS freightbase,\n 0 AS freighttax,\n apopen_amount / apopen_curr_rate AS purchasebase,\n taxhist_tax AS taxlocal,\n taxhist_tax / taxhist_curr_rate AS taxbase,\n 0 AS salestaxbase,\n taxhist_tax / taxhist_curr_rate AS purchasetaxbase\nFROM apopentax\n JOIN apopen ON (apopen_id=taxhist_parent_id)\n JOIN vendinfo ON (apopen_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n<? if exists("distDate") ?>\nWHERE ((taxhist_distdate BETWEEN <? value("startDate") ?>\n AND <? value("endDate") ?>)\n<? else ?>\nWHERE ((taxhist_docdate BETWEEN <? value("startDate") ?>\n AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("tax_id") ?>\n AND (taxhist_tax_id=<? value("tax_id") ?>)\n<? endif ?>\n<? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=<? value("taxtype_id") ?>)\n<? endif ?>\n<? if exists("taxclass_id") ?>\n AND (taxclass_id=<? value("taxclass_id") ?>)\n<? endif ?>\n<? if exists("taxauth_id") ?>\n AND (taxauth_id=<? value("taxauth_id") ?>)\n<? endif ?>\n<? if exists("taxzone_id") ?>\n AND (false)\n<? endif ?>\n AND (taxhist_distdate IS NOT NULL)\n)\nUNION ALL\n--Voucher Header History\nSELECT \n taxhist_distdate, \n tax_code AS tax, tax_descrip,\n COALESCE(taxtype_name,<? value("none") ?>) AS taxtype, taxtype_descrip,\n COALESCE(taxclass_code,<? value("none") ?>) AS taxclass, taxclass_descrip,\n COALESCE(taxauth_code,<? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n COALESCE(taxzone_code,<? value("none") ?>) AS taxzone, taxzone_descrip, curr_abbr, \n vohead_number AS docnumber, \n <? value("purchase") ?> AS source,\n <? value("voucher") ?> AS doctype,\n '', vohead_notes AS description,\n pohead_number AS ordernumber, vohead_docdate AS docdate,\n vend_name AS name, \n 1 AS qty, \n 0 AS unitprice, 0 AS amount,\n 0 AS salesbase,\n 0 AS freightbase,\n 0 AS freighttax,\n 0 AS purchasebase,\n taxhist_tax AS taxlocal,\n taxhist_tax / taxhist_curr_rate AS taxbase,\n 0 AS salestaxbase,\n taxhist_tax / taxhist_curr_rate AS purchasetaxbase\nFROM voheadtax\n JOIN vohead ON (vohead_id=taxhist_parent_id)\n LEFT OUTER JOIN pohead ON (vohead_pohead_id=pohead_id)\n JOIN vendinfo ON (vohead_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (vohead_taxzone_id=taxzone_id)\n<? if exists("distDate") ?>\nWHERE ((taxhist_distdate BETWEEN <? value("startDate") ?>\n AND <? value("endDate") ?>)\n<? else ?>\nWHERE ((taxhist_docdate BETWEEN <? value("startDate") ?>\n AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("tax_id") ?>\n AND (taxhist_tax_id=<? value("tax_id") ?>)\n<? endif ?>\n<? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=<? value("taxtype_id") ?>)\n<? endif ?>\n<? if exists("taxclass_id") ?>\n AND (_taxclass_id=<? value("taxclass_id") ?>)\n<? endif ?>\n<? if exists("taxauth_id") ?>\n AND (taxauth_id=<? value("taxauth_id") ?>)\n<? endif ?>\n<? if exists("taxzone_id") ?>\n AND (taxzone_id=<? value("taxzone_id") ?>)\n<? endif ?>\n AND (taxhist_distdate IS NOT NULL)\n)\nUNION ALL\n--Voucher Line Item\nSELECT \n taxhist_distdate, \n tax_code AS tax, tax_descrip,\n COALESCE(taxtype_name,<? value("none") ?>) AS taxtype, taxtype_descrip,\n COALESCE(taxclass_code,<? value("none") ?>) AS taxclass, taxclass_descrip,\n COALESCE(taxauth_code,<? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n COALESCE(taxzone_code,<? value("none") ?>) AS taxzone, taxzone_descrip, curr_abbr, \n vohead_number AS docnumber, \n <? value("purchase") ?> AS source,\n <? value("voucher") ?> AS doctype,\n COALESCE(item_number,expcat_code), COALESCE(item_descrip1,expcat_descrip) AS description,\n pohead_number AS ordernumber, vohead_docdate AS docdate,\n vend_name AS name, \n voitem_qty AS qty, \n COALESCE(SUM(vodist_amount),0)/voitem_qty AS unitprice, COALESCE(SUM(vodist_amount),0) AS amount,\n 0 AS salesbase,\n 0 AS freightbase,\n 0 AS freighttax,\n currToBase(vohead_curr_id, COALESCE(SUM(vodist_amount),0), vohead_distdate) AS purchasebase,\n taxhist_tax AS taxlocal,\n taxhist_tax / taxhist_curr_rate AS taxbase,\n 0 AS salestaxbase,\n taxhist_tax / taxhist_curr_rate AS purchasetaxbase\nFROM voitemtax\n JOIN voitem ON (voitem_id=taxhist_parent_id)\n JOIN vohead ON (vohead_id=voitem_vohead_id)\n JOIN pohead ON (vohead_pohead_id=pohead_id)\n JOIN poitem ON (voitem_poitem_id=poitem_id)\n JOIN vodist ON ((vodist_poitem_id=poitem_id)\n AND (vodist_vohead_id=vohead_id))\n JOIN vendinfo ON (vohead_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (vohead_taxzone_id=taxzone_id)\n LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id=item_id)\n LEFT OUTER JOIN expcat ON (expcat_id=poitem_expcat_id)\n<? if exists("distDate") ?>\nWHERE ((taxhist_distdate BETWEEN <? value("startDate") ?>\n AND <? value("endDate") ?>)\n<? else ?>\nWHERE ((taxhist_docdate BETWEEN <? value("startDate") ?>\n AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("tax_id") ?>\n AND (taxhist_tax_id=<? value("tax_id") ?>)\n<? endif ?>\n<? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=<? value("taxtype_id") ?>)\n<? endif ?>\n<? if exists("taxclass_id") ?>\n AND (taxclass_id=<? value("taxclass_id") ?>)\n<? endif ?>\n<? if exists("taxauth_id") ?>\n AND (taxauth_id=<? value("taxauth_id") ?>)\n<? endif ?>\n<? if exists("taxzone_id") ?>\n AND (taxzone_id=<? value("taxzone_id") ?>)\n<? endif ?>\n AND (taxhist_distdate IS NOT NULL)\n)\nGROUP BY taxhist_id,taxhist_distdate,tax_code,tax_descrip,\n taxtype_name,taxtype_descrip,taxclass_code,taxclass_descrip,\n taxauth_code,taxauth_descrip,taxzone,taxzone_descrip,curr_abbr,\n vohead_number,pohead_number,item_number,item_descrip1,\n vohead_curr_id,vohead_distdate,vohead_docdate,vend_name,\n expcat_code,expcat_descrip,taxhist_tax,taxhist_curr_rate,\n voitem_qty\n<? endif ?>\n-------------END PURCHASE--------------\nORDER BY docdate DESC, docnumber DESC\n\n) AS data\nGROUP BY <? literal("groupBy") ?>, <? literal("groupBy") ?>_descrip\nORDER BY <? literal("groupBy") ?>\n\n\n \n \n 221\n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n 141\n 138\n 230\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n selection\n \n \n \n \n \n \n 460.577\n 137.571\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n \n 460.577\n 116.571\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n \n 461\n 96\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n basis\n \n \n \n \n \n 141\n 117\n 230\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n group\n \n \n \n \n 65.6\n 138\n 65.9\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n selectionLit\n \n \n \n \n 4\n 199\n 100\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n group\n \n \n \n \n \n \n 141\n 97\n 230\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n showPurchases\n \n \n \n \n \n 141\n 76\n 230\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n showSales\n \n \n \n \n \n \n 6\n \n \n 26\n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n \n \n \n \n 0\n 2\n 100\n 20\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n group\n \n \n \n \n
\n detail\n \n \n detail\n \n 19\n \n \n 200\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_freightbase\n \n \n \n \n 100\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_salesbase\n \n \n \n \n 550\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_purchasetaxbase\n \n \n \n \n 450\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_purchasebase\n \n \n \n \n 0\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n group\n \n \n \n \n 350\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_salestaxbase\n \n \n \n \n 300\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n freighttax\n \n \n \n \n 650\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_nettaxbase\n \n \n \n
\n \n 16\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 20\n \n \n 650\n 3\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n nettaxbase\n \n money\n \n \n \n 350\n 3\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n salestaxbase\n \n qty\n \n \n \n 551\n 3\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n purchasetaxbase\n \n money\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 273 TimePhasedPlannedRevenueExpensesByPlannerCode \N \n\n Time Phased Planned Revenue/Expenses By Planner Code\n TimePhasedPlannedRevenueExpensesByPlannerCode\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("plancode_id") ?>\n ( SELECT (plancode_code || '-' || plancode_name)\n FROM plancode\n WHERE (plancode_id=<? value("plancode_id") ?>) )\n <? elseif exists("plancode_pattern") ?>\n text(<? value("plancode_pattern") ?>)\n <? else ?>\n text('All Planner Codes')\n <? endif ?>\n AS plncode;\n \n \n detail\n SELECT (formatDate(calitem_startdate) || '-' || formatDate(calitem_enddate)) AS period,\n formatMoney(COALESCE(cost,0.0)) AS f_cost,\n formatMoney(COALESCE(revenue,0.0)) AS f_revenue,\n formatMoney(COALESCE(revenue,0.0) - COALESCE(cost,0.0)) AS f_profit\n FROM ( SELECT calitem_startdate,\n calitem_enddate,\n SUM(plannedCost(plancode_id, warehous_id,\n <? if exists("actualCost") ?>'A'<? else ?>'S'<? endif ?>\n , calitem_id))\n AS cost,\n <? if exists("averagePrice") ?>\n SUM(plannedRevenue(plancode_id, warehous_id, 'A', calitem_id,\n <? value("startEvalDate") ?>, <? value("endEvalDate") ?>))\n <? else ?>\n SUM(plannedRevenue(plancode_id, warehous_id, 'L', calitem_id))\n <? endif ?>\n AS revenue\n FROM plancode, whsinfo,\n ( SELECT rcalitem_id AS calitem_id,\n findPeriodStart(rcalitem_id) AS calitem_startdate,\n findPeriodEnd(rcalitem_id) AS calitem_enddate\n FROM rcalitem\n WHERE (rcalitem_id in (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n ))\n UNION\n SELECT acalitem_id AS calitem_id,\n findPeriodStart(acalitem_id) AS calitem_startdate,\n findPeriodEnd(acalitem_id) AS calitem_enddate\n FROM acalitem\n WHERE (acalitem_id in (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n ))\n ) AS calitem\n WHERE ((TRUE)\n<? if exists("warehous_id") ?>\n AND (warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("plancode_id") ?>\n AND (plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n AND (plancode_code ~ <? value("plancode_pattern") ?>)\n<? endif ?>\n )\n GROUP BY calitem_startdate, calitem_enddate\n ) AS data\nORDER BY calitem_startdate\n \n \n 221\n \n \n 140\n 105\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n \n \n \n \n \n 140\n 80\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n plncode\n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n 6\n \n \n 26\n \n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 430\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_cost\n \n \n \n \n 10\n 0\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n period\n \n \n \n \n 640\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_profit\n \n \n \n \n 535\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_revenue\n \n \n \n
\n \n 16\n \n \n 690\n 0\n 51\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 200 TimePhasedProductionByPlannerCode \N \n\n Time Phased Production By Planner Code\n TimePhasedProductionByPlannerCode\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("plancode_id") ?>\n ( SELECT (plancode_code||'-'||plancode_name)\n FROM plancode\n WHERE plancode_id=<? value("plancode_id") ?>)\n <? elseif exists("plancode_pattern") ?>\n text(<? value("plancode_pattern") ?>)\n <? else ?>\n text('All Planner Codes')\n <? endif ?>\n AS plancode,\n <? if exists("inventoryUnits") ?>\n text('Qty.')\n <? elseif exists("capacityUnits") ?>\n text('Capacity')\n <? elseif exists("altCapacityUnits") ?>\n text('Alt. Capacity')\n <? else ?>\n text('ERROR')\n <? endif ?>\n AS lbl_unittype,\n <? if exists("showInactive") ?>\n text('Showing Active and Inactive Item Sites')\n <? else ?>\n text('Showing Active Item Sites Only')\n <? endif ?>\n AS lbl_showing ;\n \n \n detail\n SELECT findPeriodStart(calitem_id) AS pstart,\n findPeriodEnd(calitem_id) AS pend,\n (formatDate(findPeriodStart(calitem_id)) || '-' || formatDate(findPeriodEnd(calitem_id))) AS period,\n plancode_code,\n <? if exists("inventoryUnits") ?>\n uom_name\n <? elseif exists("capacityUnits") ?>\n itemcapuom(item_id)\n <? elseif exists("altCapacityUnits") ?>\n itemaltcapuom(item_id)\n <? else ?>\n text('')\n <? endif ?>\n AS f_uom,\n warehous_code,\n <? if exists("inventoryUnits") ?>\n formatQty(SUM(summProd(itemsite_id, calitem_id)))\n <? elseif exists("capacityUnits") ?>\n formatQty(SUM(summProd(itemsite_id, calitem_id) * itemcapinvrat(item_id)))\n <? elseif exists("altCapacityUnits") ?>\n formatQty(SUM(summProd(itemsite_id, calitem_id) * itemaltcapinvrat(item_id)))\n <? else ?>\n formatQty(SUM(summProd(itemsite_id, calitem_id)))\n <? endif ?>\n AS f_unit\n FROM itemsite, item, uom, whsinfo, plancode,\n (SELECT rcalitem_id AS calitem_id\n FROM rcalitem\n WHERE (rcalitem_id in (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n ))\n UNION\n SELECT acalitem_id as calitem_id\n FROM acalitem\n WHERE (acalitem_id in (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n ))\n ) AS calitem\n WHERE ((itemsite_warehous_id=warehous_id)\n<? if not exists("showInactive") ?>\n AND (itemsite_active)\n<? endif ?>\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_plancode_id=plancode_id)\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("plancode_id") ?>\n AND (plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n AND (plancode_code ~ <? value("plancode_pattern") ?>)\n<? endif ?>\n )\nGROUP BY pstart, pend, period, plancode_code, warehous_code, f_uom\nORDER BY pstart, plancode_code, warehous_code, f_uom;\n \n \n 221\n \n \n \n 140\n 105\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n 140\n 80\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n plancode\n \n \n \n \n \n 660\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_unittype\n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n 360\n 80\n 380\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n lbl_showing\n \n \n \n \n \n \n \n \n \n 6\n \n \n 21\n \n \n 660\n 0\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_unittype\n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n
\n detail\n \n detail\n pstart\n \n 6\n \n \n 10\n 5\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n period\n \n \n \n \n \n \n detail\n \n 16\n \n \n 530\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_uom\n \n \n \n \n 615\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 660\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_unit\n \n \n \n \n 320\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n plancode_code\n \n \n \n
\n \n 16\n \n \n \n 690\n 0\n 51\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 221 TimePhasedStatisticsByItem \N \n\n Time Phased Usage Statistics By Item\n TimePhasedStatisticsByItem\n Shows graph\n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n item_descrip1,\n item_descrip2,\n <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Warehouses')\n <? endif ?>\n AS warehouse\n FROM item\n WHERE (item_id=<? value("item_id") ?>);\n \n \n detail\n SELECT calitem_pstart AS pstart,\n calitem_pend AS pend,\n (formatDate(calitem_pstart) || '-' || formatDate(calitem_pend)) AS period,\n warehous_code,\n formatQty(summTransR(itemsite_id, calitem_id)) AS received,\n formatQty(summTransI(itemsite_id, calitem_id)) AS issued,\n formatQty(summTransS(itemsite_id, calitem_id)) AS sold,\n formatQty(summTransC(itemsite_id, calitem_id)) AS scrap,\n formatQty(summTransA(itemsite_id, calitem_id)) AS adjustments,\n--\n summTransR(itemsite_id, calitem_id) AS a_received,\n summTransI(itemsite_id, calitem_id) AS a_issued,\n summTransS(itemsite_id, calitem_id) AS a_sold,\n summTransC(itemsite_id, calitem_id) AS a_scrap,\n summTransA(itemsite_id, calitem_id) AS a_adjustments\n\n FROM itemsite, whsinfo,\n\n ( SELECT rcalitem_id as calitem_id,\n findPeriodStart(rcalitem_id) as calitem_pstart,\n findPeriodEnd(rcalitem_id) as calitem_pend\n FROM rcalitem\n WHERE (rcalitem_id in (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n ))\n UNION\n SELECT acalitem_id as calitem_id,\n findPeriodStart(acalitem_id) as calitem_pstart,\n findPeriodEnd(acalitem_id) as calitem_pend\n FROM acalitem\n WHERE (acalitem_id in (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n ))\n ORDER BY calitem_pstart, calitem_pend\n ) as calitem\n\n WHERE ((itemsite_warehous_id=warehous_id)\n AND (itemsite_item_id=<? value("item_id") ?>)\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n)\nORDER BY calitem_pstart, warehous_code;\n \n \n Blue\n 0\n 0\n 255\n \n \n BlueGreen\n 0\n 255\n 255\n \n \n Green\n 0\n 255\n 0\n \n \n Red\n 255\n 0\n 0\n \n \n RedBlue\n 255\n 0\n 255\n \n \n RedGreen\n 255\n 255\n 0\n \n \n 683\n \n \n 130\n 63\n 385\n 18\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n \n \n 130\n 50\n 200\n 18\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n 0\n 675\n 735\n 675\n 2\n \n \n \n \n \n \n \n \n 35\n 116\n 712\n 467\n \n \n Arial\n 8\n normal\n \n \n detail\n \n \n \n <string>Time Phased Activity Graph</string>\n \n \n \n <string>Date Range</string>\n \n period\n \n \n \n <string>Quantity</string>\n \n 0\n 0\n true\n \n \n IssuedQuanity\n a_issued\n Green\n \n \n \n Received\n a_received\n BlueGreen\n \n \n \n Sold\n a_sold\n Blue\n \n \n \n Scrapped\n a_scrap\n RedGreen\n \n \n \n Adjusted\n a_adjustments\n RedBlue\n \n \n \n \n \n \n 543\n 43\n 200\n 18\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n 130\n 80\n 385\n 18\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n \n \n 9\n \n \n 23\n \n \n \n \n \n 5\n 13\n 738\n 13\n 2\n \n \n \n \n \n
\n detail\n \n detail\n pstart\n \n 15\n \n \n 10\n 5\n 250\n 13\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n period\n \n \n \n \n \n \n detail\n \n 18\n \n \n 405\n 0\n 80\n 13\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n issued\n \n \n \n \n 575\n 0\n 80\n 13\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n scrap\n \n \n \n \n 318\n 0\n 80\n 13\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n received\n \n \n \n \n 268\n 0\n 35\n 13\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 488\n 0\n 80\n 13\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n sold\n \n \n \n \n 660\n 0\n 80\n 13\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n adjustments\n \n \n \n
\n \n 18\n \n \n \n 688\n 0\n 51\n 13\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 93\n 0\n 100\n 13\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n Shows graph 0 2015-10-01 17:15:58.47729 232 UniformBOL \N \n\n Uniform Bill of Lading\n UniformBOL\n \n \n \n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 25\n 25\n \n head\n SELECT shiphead_shipvia, formatDate(shiphead_shipdate) AS shipdate,\n cust_name, cust_number, cohead_number, cohead_fob, cohead_custponumber,\n warehous_descrip, addr_line1 AS warehous_addr1, addr_line2 AS warehous_addr2, addr_line3 AS warehous_addr3, addr_city AS warehous_addr4, warehous_fob,\n cohead_shiptoname, cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3,\n (cohead_shiptocity || ' ' || cohead_shiptostate || ' ' || cohead_shiptozipcode) AS shiptocitystatezip,\n cohead_shiptophone\n FROM shiphead JOIN cohead ON (cohead_id=shiphead_order_id)\n LEFT OUTER JOIN whsinfo ON (warehous_id=cohead_warehous_id)\n JOIN custinfo ON (cust_id=cohead_cust_id)\n LEFT OUTER JOIN addr ON (warehous_addr_id=addr_id)\n WHERE (shiphead_id=<? value("shiphead_id") ?>);\n \n \n detail\n SELECT 1 as one,\n coitem_linenumber,\n formatQty(SUM(shipitem_qty)) AS invqty,\n uom_name,\n itemsellinguom(item_id) AS shipuom,\n roundUp(SUM(shipitem_qty) / iteminvpricerat(item_id))::integer AS shipqty,\n item_number, item_descrip1, item_descrip2,\n formatQty(SUM(shipitem_qty) * item_prodweight) AS netweight,\n formatQty(SUM(shipitem_qty) * (item_prodweight + item_packweight)) AS grossweight\n FROM shipitem, coitem, itemsite, item, uom\n WHERE ((shipitem_orderitem_id=coitem_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (shipitem_shiphead_id=<? value("shiphead_id") ?>))\nGROUP BY coitem_linenumber, item_number, item_id,\n uom_name, shipuom,\n item_descrip1,\n item_descrip2, item_prodweight,\n item_packweight\nORDER BY coitem_linenumber;\n \n \n \n foot\n SELECT formatQty(SUM(shipitem_qty * item_prodweight)) AS netweight,\n formatQty(SUM(shipitem_qty * (item_prodweight + item_packweight))) AS grossweight \n FROM shipitem, coitem, itemsite, item\n WHERE ((shipitem_orderitem_id=coitem_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (shipitem_shiphead_id=<? value("shiphead_id") ?>));\n \n \n notes\n SELECT shiphead_notes\n FROM shiphead\n WHERE (shiphead_id=<? value("shiphead_id") ?>);\n \n \n legal1\n SELECT \n text('*If the shipment moves between two ports by carrier by water, the law requires that the Bill Of Lading shall state whether it is ''carrier''s or shipper''s weight''.\\n\\nNOTE: Where the rate is dependent on value, shippers are required to state specifically in writing the agreed or declared value of the property. The agreed or declared value of the property is hereby specifically stated by the shipper to be not exceeding:\\n\\n_________________________\\n\\nper ______________________') AS legal3\n \n \n 42\n \n \n 5\n 35\n 795\n 35\n 2\n \n \n \n \n \n \n \n \n \n 332\n \n \n 145\n 5\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cust_number\n \n \n \n \n 405\n 85\n 405\n 185\n 0\n \n \n \n 419\n 160\n 370\n 25\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n shiphead_shipvia\n \n \n \n \n \n 100\n 305\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehous_addr4\n \n \n \n 795\n 85\n 795\n 185\n 0\n \n \n 405\n 185\n 795\n 185\n 0\n \n \n \n 145\n 45\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_fob\n \n \n \n \n 405\n 150\n 795\n 150\n 0\n \n \n 600\n 112\n 600\n 150\n 0\n \n \n \n 100\n 285\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehous_addr3\n \n \n \n \n 100\n 190\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cohead_shiptophone\n \n \n \n \n \n 100\n 130\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cohead_shiptoaddress2\n \n \n \n \n \n 100\n 225\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehous_descrip\n \n \n \n \n \n \n 145\n 25\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_number\n \n \n \n \n 100\n 170\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n shiptocitystatezip\n \n \n \n \n \n \n \n 615\n 125\n 175\n 25\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cohead_custponumber\n \n \n \n \n 100\n 150\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cohead_shiptoaddress3\n \n \n \n \n \n 100\n 265\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehous_addr2\n \n \n \n \n 415\n 200\n 380\n 15\n \n 0\n \n Arial\n 8\n bold\n \n \n \n \n notes\n shiphead_notes\n \n \n \n \n \n 100\n 90\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cohead_shiptoname\n \n \n \n \n \n \n \n 100\n 245\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehous_addr1\n \n \n \n 405\n 85\n 795\n 85\n 0\n \n \n \n 635\n 50\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n shipdate\n \n \n \n 405\n 112\n 795\n 112\n 0\n \n \n \n \n \n \n 100\n 110\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cohead_shiptoaddress1\n \n \n \n \n
\n detail\n \n \n detail\n \n 52\n \n \n 150\n 35\n 380\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 540\n 0\n 120\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n grossweight\n \n \n \n \n 5\n 0\n 80\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n shipqty\n \n \n \n \n 150\n 20\n 380\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 145\n 0\n 390\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n item_number\n \n \n \n
\n \n \n 466\n \n \n \n 5\n 90\n 795\n 90\n 0\n \n \n \n \n \n \n \n \n \n 220\n 80\n 228\n 80\n 0\n \n \n \n 560\n 75\n 570\n 75\n 0\n \n \n 400\n 90\n 400\n 245\n 0\n \n \n \n \n 5\n 5\n 5\n 445\n 0\n \n \n 210\n 220\n 385\n 220\n 0\n \n \n \n \n \n \n \n 220\n 70\n 228\n 70\n 0\n \n \n 220\n 55\n 220\n 65\n 0\n \n \n 600\n 90\n 600\n 245\n 0\n \n \n \n \n \n \n \n 560\n 65\n 560\n 75\n 0\n \n \n \n \n 560\n 60\n 570\n 60\n 0\n \n \n 600\n 135\n 795\n 135\n 0\n \n \n 560\n 50\n 570\n 50\n 0\n \n \n \n \n \n \n \n 540\n 5\n 120\n 25\n \n \n Arial\n 10\n bold\n \n \n \n \n foot\n grossweight\n \n \n \n 795\n 5\n 795\n 445\n 0\n \n \n \n \n \n \n \n \n 560\n 50\n 560\n 60\n 0\n \n \n 765\n 70\n 765\n 80\n 0\n \n \n \n 570\n 75\n 570\n 65\n 0\n \n \n 5\n 320\n 795\n 320\n 0\n \n \n 228\n 65\n 228\n 55\n 0\n \n \n 200\n 90\n 200\n 245\n 0\n \n \n \n \n \n 665\n 5\n 665\n 30\n 0\n \n \n \n \n 220\n 70\n 220\n 80\n 0\n \n \n \n 580\n 30\n 580\n 90\n 0\n \n \n 5\n 340\n 795\n 340\n 0\n \n \n \n 210\n 30\n 210\n 90\n 0\n \n \n 390\n 30\n 390\n 90\n 0\n \n \n 220\n 65\n 228\n 65\n 0\n \n \n 5\n 408\n 795\n 408\n 0\n \n \n 433\n 240\n 586\n 240\n 0\n \n \n 765\n 80\n 775\n 80\n 0\n \n \n \n 5\n 375\n 795\n 375\n 0\n \n \n \n 5\n 50\n 210\n 50\n 0\n \n \n \n 408\n 220\n 586\n 220\n 0\n \n \n 560\n 65\n 570\n 65\n 0\n \n \n 670\n 170\n 762\n 170\n 0\n \n \n 5\n 30\n 795\n 30\n 0\n \n \n 5\n 445\n 795\n 445\n 0\n \n \n \n \n \n \n \n \n 775\n 80\n 775\n 70\n 0\n \n \n \n \n 765\n 70\n 775\n 70\n 0\n \n \n 5\n 245\n 795\n 245\n 0\n \n \n \n \n 685\n 408\n 685\n 445\n 0\n \n \n \n 400\n 320\n 400\n 445\n 0\n \n \n \n \n 228\n 80\n 228\n 70\n 0\n \n \n \n \n 5\n 5\n 795\n 5\n 0\n \n \n \n 535\n 5\n 535\n 30\n 0\n \n \n \n \n \n \n \n 600\n 110\n 795\n 110\n 0\n \n \n 220\n 55\n 228\n 55\n 0\n \n \n \n \n \n \n 570\n 60\n 570\n 50\n 0\n \n \n
\n 0 2015-10-01 17:15:58.47729 159 UninvoicedReceipts \N \n\n Uninvoiced Receipts\n UninvoicedReceipts\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("warehous_id") ?> \n ( SELECT warehous_code \n FROM whsinfo \n WHERE (warehous_id=<? value("warehous_id") ?>) ) \n <? else ?> \n text('All Sites') \n <? endif ?> \n AS warehouse, \n <? if exists("agentUsername") ?> \n TEXT(<? value("agentUsername" ?>) \n <? else ?> \n TEXT('All Agents') \n <? endif ?> \n AS agentUsername; \n\n \n \n detail\n SELECT recv_id,\n formatDate(recv_date) as f_date,\n recv_trans_usr_name as f_user,\n recv_order_number AS f_ponumber, poitem_linenumber,\n vend_name, \n COALESCE(item_number, ('Misc. - ' || recv_vend_item_number)) AS item_number,\n formatQty(recv_qty) as f_qty,\n 'Receipt' AS f_type,\n recv_value AS value,\n formatMoney(recv_value) AS f_value\n FROM recv\n LEFT OUTER JOIN itemsite ON (recv_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id=item_id),\n poitem, vendinfo\n WHERE ((recv_orderitem_id=poitem_id)\n AND (recv_order_type='PO')\n AND (recv_vend_id=vend_id)\n AND (recv_posted)\n AND (recv_vohead_id IS NULL)\n AND (NOT recv_invoiced)\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("agentUsername") ?>\n AND (recv_agent_username=<? value("agentUsername") ?>)\n<? endif ?>\n)\nUNION\nSELECT poreject_id,\n formatDate(poreject_date) as f_date,\n poreject_trans_username as f_user,\n poreject_ponumber AS f_ponumber, poitem_linenumber,\n vend_name, \n COALESCE(item_number, ('Misc. - ' || poreject_vend_item_number)) AS item_number,\n formatQty(poreject_qty) as f_qty,\n 'Return' AS f_type,\n poreject_value *-1 AS value,\n formatMoney(poreject_value*-1) AS f_value\n FROM poreject\n LEFT OUTER JOIN itemsite ON (poreject_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id=item_id),\n poitem, vendinfo\n WHERE ((poreject_poitem_id=poitem_id)\n-- AND (poreject_itemsite_id=itemsite_id)\n-- AND (itemsite_item_id=item_id)\n AND (poreject_vend_id=vend_id)\n AND (poreject_posted)\n AND (NOT poreject_invoiced)\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("agentUsername") ?>\n AND (poreject_agent_username=<? value("agentUsername") ?>)\n<? endif ?>\n)\nORDER BY f_ponumber, poitem_linenumber;\n \n \n 221\n \n \n \n 145\n 90\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n \n \n \n 145\n 110\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n agentUsername\n \n \n \n \n \n 6\n \n \n 29\n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 18\n \n \n 85\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_user\n \n \n \n \n 520\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qty\n \n \n \n \n 170\n 0\n 65\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ponumber\n \n \n \n \n 285\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_name\n \n \n \n \n 400\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 5\n 0\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_date\n \n \n \n \n 245\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n poitem_linenumber\n \n \n \n \n 590\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_type\n \n \n \n \n 665\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_value\n \n \n \n
\n \n 18\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 104\n \n \n \n 665\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n value\n \n qty\n \n \n
\n 0 2015-10-01 17:15:58.47729 77 UninvoicedShipments \N \n\n Uninvoiced Shipments\n UninvoicedShipments\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse;\n\n \n \n detail\n SELECT cohead_id, shipitem_id, cohead_number, coitem_linenumber,\n item_number, item_descrip1, item_descrip2,\n uom_name,\n shipped, formatQty(shipped) AS f_shipped,\n selected, formatQty(selected) AS f_selected\nFROM (\nSELECT cohead_id, shipitem_id, cohead_number, coitem_linenumber,\n item_number, item_descrip1, item_descrip2,\n uom_name,\n COALESCE(SUM(shipitem_qty), 0) AS shipped,\n COALESCE(SUM(cobill_qty), 0) AS selected\nFROM cohead, itemsite, item, uom,\n whsinfo, shipitem, shiphead,\n coitem LEFT OUTER JOIN\n ( cobill JOIN cobmisc\n ON ( (cobill_cobmisc_id=cobmisc_id) AND (NOT cobmisc_posted) ) )\n ON (cobill_coitem_id=coitem_id)\nWHERE ( (shipitem_orderitem_id=coitem_id)\n AND (shipitem_shiphead_id=shiphead_id)\n AND (coitem_cohead_id=cohead_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (coitem_qty_uom_id=uom_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (shiphead_shipped)\n AND (NOT shipitem_invoiced)\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n )\nGROUP BY cohead_number, coitem_id, coitem_linenumber, item_number,\n item_descrip1, item_descrip2, cohead_id, shipitem_id, uom_name\n) AS data\n<? if exists("showUnselected") ?>\n WHERE (selected = 0)\n<? endif ?>\n;\n \n \n 236\n \n \n 100\n 104\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n 5\n 229\n 745\n 229\n 2\n \n \n \n \n \n \n \n \n \n \n \n \n \n 6\n \n \n 37\n \n \n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n
\n detail\n \n \n detail\n \n 57\n \n \n 5\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cohead_number\n \n \n \n \n 494\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_selected\n \n \n \n \n 150\n 15\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 95\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n coitem_linenumber\n \n \n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_shipped\n \n \n \n \n 150\n 0\n 229\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 150\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n 5\n 50\n 745\n 50\n 0\n \n \n
\n \n 18\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 236 VendorAPHistory \N \n\n Vendor AP History\n VendorAPHistory\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT vend_number,\n vend_name,\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate\n FROM vendinfo\n WHERE (vend_id=<? value("vend_id") ?>);\n \n \n detail\n SELECT 1 AS type, apopen_id, -1 AS applyid,\n apopen_docdate AS sortdate, apopen_docnumber AS sortnumber,\n apopen_docnumber AS docnumber,\n formatBoolYN(apopen_open) AS f_open,\n CASE WHEN (apopen_doctype='V') THEN text('Voucher')\n WHEN (apopen_doctype='C') THEN text('C/M')\n WHEN (apopen_doctype='D') THEN text('D/M')\n ELSE text('Other')\n END AS documenttype,\n apopen_invcnumber AS invoicenumber,\n apopen_ponumber AS ponumber,\n formatDate(apopen_docdate) AS f_docdate,\n formatDate(apopen_duedate) AS f_duedate,\n formatMoney(apopen_amount) AS f_amount,\n formatMoney((apopen_amount - apopen_paid)) AS f_balance\nFROM apopen\nWHERE ( (apopen_vend_id=<? value("vend_id") ?>)\n AND (apopen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) )\n\nUNION\nSELECT 2 AS type, apopen_id, apapply_source_apopen_id AS applyid,\n apopen_docdate AS sortdate, apopen_docnumber AS sortnumber,\n apapply_source_docnumber AS docnumber,\n '' AS f_open,\n CASE WHEN (apapply_source_doctype='C') THEN text('C/M')\n WHEN (apapply_source_doctype='K') THEN text('Check')\n ELSE text('Other')\n END AS documenttype,\n '' AS invoicenumber,\n '' AS ponumber,\n formatDate(apapply_postdate) AS f_docdate,\n '' AS f_duedate,\n formatMoney(apapply_amount) AS f_amount,\n '' AS f_balance\nFROM apapply, apopen\nWHERE ( (apapply_target_apopen_id=apopen_id)\n AND (apapply_vend_id=<? value("vend_id") ?>)\n AND (apopen_vend_id=<? value("vend_id") ?>)\n AND (apopen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) )\n\nUNION\nSELECT 3 AS type, apopen_id, apapply_target_apopen_id AS applyid,\n apopen_docdate AS sortdate, apopen_docnumber AS sortnumber,\n apapply_target_docnumber AS docnumber,\n '' AS f_open,\n CASE WHEN (apapply_target_doctype='V') THEN text('Voucher')\n WHEN (apapply_target_doctype='D') THEN text('D/M')\n ELSE text('Other')\n END AS documenttype,\n apopen_invcnumber AS invoicenumber,\n '' AS ponumber,\n formatDate(apapply_postdate) AS f_docdate,\n '' AS f_duedate,\n formatMoney(apapply_amount) AS f_amount,\n '' AS f_balance\nFROM apapply, apopen\nWHERE ( (apapply_source_doctype IN ('C', 'K'))\n AND (apapply_source_doctype=apopen_doctype)\n AND (apapply_source_docnumber=apopen_docnumber)\n AND (apapply_vend_id=<? value("vend_id") ?>)\n AND (apopen_vend_id=<? value("vend_id") ?>)\n AND (apopen_docdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) )\n\nORDER BY sortdate, apopen_id, type;\n \n \n 162\n \n \n \n 550\n 85\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n 95\n 65\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n vend_number\n \n \n \n \n \n \n \n \n \n \n 5\n 155\n 745\n 155\n 2\n \n \n \n \n \n 95\n 85\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n vend_name\n \n \n \n \n \n 550\n 65\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n \n 6\n \n \n 21\n \n 5\n 15\n 745\n 14\n 2\n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 17\n \n \n 400\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_docdate\n \n \n \n \n 570\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_amount\n \n \n \n \n 655\n 0\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_balance\n \n \n \n \n 315\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ponumber\n \n \n \n \n 60\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n documenttype\n \n \n \n \n 485\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_duedate\n \n \n \n \n 5\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_open\n \n \n \n \n 145\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n docnumber\n \n \n \n \n 230\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n invoicenumber\n \n \n \n
\n \n 17\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 104\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 412 VendorInformation \N \n\n Vendor Information\n VendorInformation\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT vend_name, vend_vendtype_id, vend_terms_id,\n vend_shipvia, vend_active, vend_cntct1_id,\n vend_cntct2_id, crmacct_id, vend_number,\n MIN(pohead_orderdate) AS minpodate, \n MAX(pohead_orderdate) AS maxpodate, \n formatMoney(SUM(currToBase(pohead_curr_id,\n (poitem_qty_ordered - poitem_qty_received) * poitem_unitprice,\n CURRENT_DATE))) AS backlog ,\n c1.cntct_first_name || ' ' || c1.cntct_last_name AS contact1_name,\n c1.cntct_phone AS contact1_phone, c1.cntct_phone2 AS contact1_phone, \n formataddr(a1.addr_id) AS contact1_address,\n c1.cntct_fax as contact1_fax, c1.cntct_email AS contct1_email,\n c2.cntct_first_name || ' ' || c2.cntct_last_name AS contact2_name,\n c2.cntct_phone AS contact2_phone, c2.cntct_phone2 AS contact2_phone, \n c2.cntct_fax as contact2_fax, c2.cntct_email AS contct2_email,\n formataddr(a2.addr_id) AS contact2_address,\n vend_comments\n FROM vendinfo\n LEFT OUTER JOIN cntct c1 ON (vend_cntct1_id = c1.cntct_id)\n LEFT OUTER JOIN addr a1 ON (c1.cntct_addr_id = a1.addr_id)\n LEFT OUTER JOIN cntct c2 ON (vend_cntct2_id = c2.cntct_id)\n LEFT OUTER JOIN addr a2 ON (c2.cntct_addr_id = a2.addr_id)\n LEFT OUTER JOIN pohead ON (pohead_vend_id=vend_id)\n LEFT OUTER JOIN poitem ON (poitem_pohead_id=pohead_id\n AND poitem_status='O')\n JOIN crmacct ON (crmacct_vend_id=vend_id)\n WHERE (vend_id=<? value("vend_id") ?>) \n GROUP BY vend_name, vend_vendtype_id, vend_terms_id,\n vend_shipvia, vend_active,vend_cntct1_id,\n vend_cntct2_id, crmacct_id,\n c1.cntct_first_name, c1.cntct_last_name,\n c1.cntct_phone, c1.cntct_phone2, \n a1.addr_id,c1.cntct_fax, c1.cntct_email,\n c2.cntct_first_name,c2.cntct_last_name ,\n c2.cntct_phone, c2.cntct_phone2, \n c2.cntct_fax, c2.cntct_email,a2.addr_id,\n vend_comments, vend_number;\n \n \n lypurch\n SELECT formatMoney(SUM(currToBase(vohead_curr_id,\n vohead_amount,\n vohead_gldistdate))) AS purchases \n FROM vohead \n WHERE (vohead_posted\n AND (vohead_gldistdate \n BETWEEN (DATE_TRUNC('year', CURRENT_DATE) - INTERVAL '1 year')\n AND (DATE_TRUNC('year', CURRENT_DATE) - INTERVAL '1 day'))\n AND (vohead_vend_id=<? value("vend_id") ?>));\n \n \n ytdpurch\n SELECT formatMoney(SUM(currToBase(vohead_curr_id,\n vohead_amount,\n vohead_gldistdate))) AS purchases \n FROM vohead \n WHERE (vohead_posted\n AND (vohead_gldistdate \n BETWEEN (DATE_TRUNC('year', CURRENT_DATE))\n AND (CURRENT_DATE - INTERVAL '1 day'))\n AND (vohead_vend_id=<? value("vend_id") ?>));\n \n \n backlog\n SELECT formatMoney( COALESCE( SUM( (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio) ), 0 ) ) AS backlog FROM cohead, coitem, itemsite, item WHERE ( (coitem_cohead_id=cohead_id) AND (coitem_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (coitem_status='O') AND (cohead_cust_id=<? value("cust_id") ?>) );\n \n \n OpenBalance\n SELECT formatMoney(COALESCE(SUM((apopen_amount-apopen_paid) / apopen_curr_rate * \n CASE WHEN (apopen_doctype IN ('D','V')) THEN 1 \n ELSE -1 END), 0.0)) AS balance \n FROM apopen \n WHERE ((apopen_open)\n AND (apopen_vend_id=<? value("vend_id") ?>));\n\n \n \n podate\n SELECT formatDate(MIN(pohead_orderdate)) AS firstpodate, formatDate(MAX(pohead_orderdate)) AS lastpodate\nFROM pohead\nWHERE (pohead_vend_id=<? value("vend_id") ?>)\n \n \n 392\n \n \n \n 105\n 368\n 575\n 15\n \n 0\n \n Arial\n 8\n bold\n \n \n \n \n head\n vend_comments\n \n \n \n \n 134\n 305\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n podate\n firstpodate\n \n \n \n 370\n 160\n 370\n 295\n 0\n \n \n 5\n 155\n 360\n 155\n 0\n \n \n \n \n 99.8\n 229\n 260\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n contact1_name\n \n \n \n \n 100\n 260\n 260\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n contact1_fax\n \n \n \n \n \n 474\n 229\n 260\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n contact2_name\n \n \n \n \n \n 5\n 295\n 740\n 295\n 2\n \n \n \n \n \n 400\n 305\n 145\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n lypurch\n purchases\n \n \n \n \n 475\n 275\n 260\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n contact2_email\n \n \n \n \n 100\n 275\n 260\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n contact1_email\n \n \n \n \n 475\n 260\n 260\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n contact2_fax\n \n \n \n \n \n 100\n 75\n 295\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n vend_name\n \n \n \n \n \n 400\n 325\n 145\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n ytdpurch\n purchases\n \n \n \n \n \n \n 475\n 245\n 260\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n contact2_phone\n \n \n \n \n 380\n 155\n 735\n 155\n 0\n \n \n \n \n \n \n 130\n 344.893\n 103\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n backlog\n \n \n \n \n 100\n 245\n 260\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n contact1_phone\n \n \n \n \n 130\n 325\n 105\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n podate\n lastpodate\n \n \n \n \n 410\n 345\n 134.643\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n OpenBalance\n balance\n \n \n \n \n \n \n 100\n 95\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n vend_number\n \n \n \n \n \n \n \n 21\n 163\n 341\n 12\n \n 0\n \n Arial\n 8\n bold\n \n \n \n \n head\n contact1_address\n \n \n \n \n 399\n 164\n 333\n 12\n \n 0\n \n Arial\n 8\n bold\n \n \n \n \n head\n contact2_address\n \n \n \n \n 18\n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n\n 0 2015-10-01 17:15:58.47729 260 ViewAPCheckRunEditList \N \n\n View Payment Run Edit List\n ViewAPCheckRunEditList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT CASE WHEN checkhead_void THEN 0\n ELSE checkhead_amount END AS amt_check,\n CASE WHEN checkhead_void THEN 0\n ELSE currToBase(checkhead_curr_id,checkhead_amount,\n checkhead_checkdate)\n END AS base_amt_check,\n checkhead_id AS primaryid,\n -1 AS secondaryid,\n formatBoolYN(checkhead_void) AS f_void,\n formatBoolYN(checkhead_printed) AS f_printed,\n TEXT(checkhead_number) AS number,\n (checkrecip_number || '-' || checkrecip_name) AS description,\n formatDate(checkhead_checkdate) AS f_checkdate,\n formatMoney(checkhead_amount) AS f_amount,\n formatMoney(currtobase(checkhead_curr_id,checkhead_amount,checkhead_checkdate)) AS f_baseamount,\n currconcat(checkhead_curr_id) AS currAbbr,\n checkhead_number,\n 1 AS orderby\n FROM checkhead LEFT OUTER JOIN\n checkrecip ON ((checkrecip_id=checkhead_recip_id)\n\t\t AND (checkrecip_type=checkhead_recip_type))\n WHERE ((checkhead_bankaccnt_id=<? value("bankaccnt_id") ?>)\n AND (NOT checkhead_posted)\n AND (NOT checkhead_replaced)\n AND (NOT checkhead_deleted)\n<? if exists("vend_id") ?>\n AND (checkrecip_type='V')\n AND (checkrecip_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n AND (checkrecip_type='V')\n AND (checkrecip_id IN (SELECT vend_id\n FROM vendinfo\n WHERE (vend_vendtype_id=<? value("vendtype_id") ?>)))\n<? elseif exists("vendtype_pattern") ?>\n AND (checkrecip_type='V')\n AND (checkrecip_id IN (SELECT vend_id\n FROM vendinfo, vendtype\n WHERE ((vend_vendtype_id=vendtype_id)\n AND (vendtype_code ~ <? value("vendtype_pattern") ?>))))\n<? endif ?>\n )\n\nUNION SELECT 0 AS amt_check,\n 0 AS base_amt_check,\n checkitem_checkhead_id AS primaryid,\n checkitem_id AS secondaryid,\n '' AS f_void,\n '' AS f_printed,\n CASE WHEN (checkitem_ranumber IS NOT NULL) THEN checkitem_ranumber::TEXT\n\t ELSE checkitem_vouchernumber\n\t END AS number,\n CASE WHEN (checkitem_cmnumber IS NOT NULL) THEN checkitem_cmnumber::TEXT\n\t ELSE checkitem_invcnumber\n\t END AS description,\n '' AS f_checkdate,\n formatMoney(checkitem_amount) AS f_amount,\n formatMoney(currtobase(checkitem_curr_id,checkitem_amount,checkhead_checkdate)) AS f_baseamount,\n currconcat(checkitem_curr_id) AS currAbbr,\n checkhead_number,\n 2 AS orderby\n FROM checkitem, checkhead\n WHERE ( (checkitem_checkhead_id=checkhead_id)\n AND (checkhead_bankaccnt_id=<? value("bankaccnt_id") ?>)\n AND (NOT checkhead_posted)\n AND (NOT checkhead_replaced)\n AND (NOT checkhead_deleted)\n<? if exists("vend_id") ?>\n AND (checkhead_recip_type='V')\n AND (checkhead_recip_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n AND (checkhead_recip_type='V')\n AND (checkhead_recip_id IN (SELECT vend_id\n FROM vendinfo\n WHERE (vend_vendtype_id=<? value("vendtype_id") ?>)))\n<? elseif exists("vendtype_pattern") ?>\n AND (checkhead_recip_type='V')\n AND (checkhead_recip_id IN (SELECT vend_id\n FROM vendinfo, vendtype\n WHERE ((vend_vendtype_id=vendtype_id)\n AND (vendtype_code ~ <? value("vendtype_pattern") ?>))))\n<? endif ?>\n )\nORDER BY checkhead_number, primaryid, orderby;\n \n \n head\n SELECT (bankaccnt_name || '-' || bankaccnt_descrip) AS bankaccnt\n FROM bankaccnt\n WHERE (bankaccnt_id=<? value("bankaccnt_id") ?>);\n \n \n 127\n \n \n 5\n 112\n 745\n 112\n 2\n \n \n \n \n \n \n 145\n 55\n 350\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n bankaccnt\n \n \n \n \n \n \n \n \n \n \n \n \n 11\n \n \n 28\n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n \n \n \n
\n detail\n \n detail\n orderid\n \n \n \n detail\n \n 21\n \n \n 130\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n number\n \n \n \n \n 585\n 0\n 53\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n currAbbr\n \n \n \n \n 5\n 0\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_void\n \n \n \n \n 65\n 0\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_printed\n \n \n \n \n 465\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_checkdate\n \n \n \n \n 245\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n description\n \n \n \n \n 645\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_amount\n \n \n \n
\n \n 21\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 61\n \n \n 645\n 5\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n amt_check\n \n qty\n \n \n \n 645\n 20\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n base_amt_check\n \n qty\n \n \n \n 567\n 2\n 745\n 2\n 2\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 287 VoucherRegister \N \n\n Voucher Register\n VoucherRegister\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("accnt_id") ?>\n ( SELECT (accnt_number || '-' || accnt_descrip)\n FROM accnt\n WHERE (accnt_id=<? value("accnt_id") ?>) )\n <? else ?>\n text('All Accounts')\n <? endif ?>\n AS accnt,\n <? if exists("showUsernames") ?>\n text('Username')\n <? else ?>\n text('')\n <? endif ?>\n AS f_username\n \n \n detail\n SELECT gltrans_id,\n formatDate(gltrans_date) AS transdate,\n vend_number, vend_name,\n gltrans_doctype,\n gltrans_docnumber,\n firstLine(gltrans_notes) AS transnotes,\n (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n CASE WHEN (gltrans_amount < 0) THEN formatMoney(ABS(gltrans_amount))\n ELSE ''\n END AS f_debit,\n CASE WHEN (gltrans_amount > 0) THEN formatMoney(gltrans_amount)\n ELSE ''\n END AS f_credit,\n <? if exists("showUsernames") ?>\n gltrans_username\n <? else ?>\n text('')\n <? endif ?>\n AS f_username\n FROM accnt, gltrans LEFT OUTER JOIN vohead JOIN vendinfo ON (vohead_vend_id=vend_id) ON (gltrans_doctype='VO' and gltrans_docnumber=vohead_number)\n WHERE ((gltrans_accnt_id=accnt_id)\n AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("accnt_id") ?>\n AND (gltrans_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n AND (gltrans_source='A/P')\n )\nORDER BY gltrans_created DESC, gltrans_sequence, gltrans_amount;\n \n \n 221\n \n \n 545\n 70\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n 670\n 170\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_username\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 545\n 90\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n 140\n 70\n 290\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n accnt\n \n \n \n \n \n 6\n \n \n 56\n \n \n \n \n \n \n \n \n \n \n \n 670\n 5\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_username\n \n \n \n 5\n 50\n 745\n 50\n 2\n \n \n
\n detail\n \n \n detail\n \n 46\n \n \n 245\n 0\n 260\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n transnotes\n \n \n \n \n 15\n 30\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_number\n \n \n \n \n 245\n 15\n 260\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n account\n \n \n \n \n 160\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_doctype\n \n \n \n \n 10\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n transdate\n \n \n \n \n 510\n 30\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_debit\n \n \n \n \n 105\n 30\n 265\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_name\n \n \n \n \n 595\n 30\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_credit\n \n \n \n \n 620\n 0\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_username\n \n \n \n \n 160\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_docnumber\n \n \n \n
\n \n 18\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 194 WOHistoryByClassCode \N \n\n Work Order History By Class Code\n WOHistoryByClassCode\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n Detail\n workOrderHistory\n detail\n \n \n head\n SELECT <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("classcode_id") ?>\n ( SELECT (classcode_code||'-'||classcode_descrip)\n FROM classcode\n WHERE (classcode_id=<? value("classcode_id") ?>) )\n <? elseif exists("classcode_pattern") ?>\n text(<? value("classcode_pattern") ?>)\n <? else ?>\n text('All Class Codes')\n <? endif ?>\n AS classcode,\n <? if exists("showOnlyTopLevel") ?>\n text('Only Show Top level Work Orders')\n <? else ?>\n text('')\n <? endif ?>\n AS lbl_toplevel,\n <? if exists("showCosts") ?>\n text('Cost')\n <? else ?>\n text('')\n <? endif ?>\n AS lbl_cost\n;\n \n \n 172\n \n \n \n \n \n 5\n 165\n 740\n 165\n 2\n \n \n \n \n \n \n \n \n \n 135\n 85\n 170\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n classcode\n \n \n \n \n \n 365\n 85\n 355\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n lbl_toplevel\n \n \n \n \n 135\n 105\n 170\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n 665\n 151\n 70\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_cost\n \n \n \n \n \n 7\n \n \n 32\n \n \n \n \n \n \n \n 5\n 25\n 740\n 25\n 2\n \n \n \n \n \n \n 660\n 8\n 70\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_cost\n \n \n \n
\n detail\n \n \n Detail\n \n 52\n \n \n 5\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n wonumber\n \n \n \n \n 85\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n warehous_code\n \n \n \n \n 509\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n f_wo_duedate\n \n \n \n \n 45\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n wo_status\n \n \n \n \n 125\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n item_number\n \n \n \n \n 229\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n uom_name\n \n \n \n \n 125\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n item_descrip2\n \n \n \n \n 670\n 0\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n f_wo_postedvalue\n \n \n \n \n 270\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n f_wo_qtyord\n \n \n \n \n 125\n 15\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n item_descrip1\n \n \n \n \n 350\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n f_wo_qtyrcv\n \n \n \n 5\n 45\n 740\n 45\n 0\n \n \n \n 430\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n f_wo_startdate\n \n \n \n
\n \n 17\n \n \n \n 95\n 0\n 113\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 86 WOHistoryByItem \N \n\n Work Order History by Item\n WOHistoryByItem\n \n Letter\n \n 50\n 50\n 50\n 50\n \n Detail\n SELECT formatWONumber(wo_id) AS wonumber,\n wo_status, warehous_code,\n formatQty(wo_qtyord) AS ordered,\n formatQty(wo_qtyrcv) AS received,\n formatDate(wo_startdate) AS startdate,\n formatDate(wo_duedate) AS duedate,\n <? if exists("showCosts") ?>\n formatCost(wo_postedvalue)\n <? else ?>\n text('')\n <? endif ?>\n AS value\n FROM wo, itemsite, whsinfo\n WHERE ((wo_itemsite_id=itemsite_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (itemsite_item_id=<? value("item_id") ?>)\n<? if exists("showOnlyTopLevel") ?>\n AND ((wo_ordtype<>'W') OR (wo_ordtype IS NULL))\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n AND (wo_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) )\nORDER BY wo_startdate DESC, wo_number, wo_subnumber;\n \n \n \n head\n SELECT item_number,\n item_descrip1,\n item_descrip2,\n <? if exists("warehous_id") ?>\n (SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>))\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("showOnlyTopLevel") ?>\n text('Only Show Top Level Work Orders')\n <? else ?>\n text('')\n <? endif ?>\n AS lbl_toplevel,\n <? if exists("showCosts") ?>\n text('Cost')\n <? else ?>\n text('')\n <? endif ?>\n AS lbl_cost,\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate\n FROM item\n WHERE (item_id=<? value("item_id") ?>);\n \n \n 191\n \n \n \n \n 135\n 85\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n 550\n 85\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n 445\n 105\n 250\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n lbl_toplevel\n \n \n \n \n \n \n \n \n 550\n 65\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n 135\n 105\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n 5\n 185\n 740\n 185\n 2\n \n \n \n \n \n \n 135\n 125\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n 135\n 65\n 305\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n \n 660\n 170\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_cost\n \n \n \n \n \n \n 6\n \n \n 31\n \n \n \n \n 5\n 25\n 740\n 25\n 2\n \n \n \n \n 660\n 10\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_cost\n \n \n \n \n \n \n
\n detail\n \n \n Detail\n \n 16\n \n \n 405\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n startdate\n \n \n \n \n 170\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n warehous_code\n \n \n \n \n 490\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n duedate\n \n \n \n \n 10\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n wonumber\n \n \n \n \n 114\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n wo_status\n \n \n \n \n 235\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n ordered\n \n \n \n \n 320\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n received\n \n \n \n \n 660\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n value\n \n \n \n
\n \n 16\n \n \n 95\n 0\n 114\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 88 WOMaterialRequirementsByComponentItem \N \n\n W/O Material Requirements By Component Item\n WOMaterialRequirementsByComponentItem\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number, item_descrip1, item_descrip2,\n <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse\n FROM item\n WHERE (item_id=<? value("item_id") ?>);\n\n \n \n detail\n workOrderMaterial\n detail\n \n \n total\n SELECT formatQty(SUM(womatl_qtyreq)) AS required,\n formatQty(SUM(womatl_qtyiss)) AS issued,\n formatQty(SUM(noNeg(womatl_qtyreq - womatl_qtyiss))) AS balance\n FROM wo, womatl, itemsite AS parentsite, itemsite AS componentsite, item, uom\nWHERE ((womatl_wo_id=wo_id)\n AND (womatl_uom_id=uom_id)\n AND (wo_status <> 'C')\n AND (wo_itemsite_id=parentsite.itemsite_id)\n AND (womatl_itemsite_id=componentsite.itemsite_id)\n AND (parentsite.itemsite_item_id=item_id)\n AND (componentsite.itemsite_item_id=<? value("item_id") ?>)\n<? if exists("warehous_id") ?>\n AND (componentsite.itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n )\n;\n \n \n 236\n \n \n 100\n 120\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n \n \n \n 100\n 145\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n \n \n \n 100\n 100\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n \n \n 100\n 80\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n 5\n 229\n 745\n 229\n 2\n \n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n
\n detail\n \n \n detail\n \n 51\n \n \n 10\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n wonumber\n \n \n \n \n 95\n 32\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 590\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_balance\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 515\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyiss\n \n \n \n \n 670\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_duedate\n \n \n \n \n 200\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n issuemethod\n \n \n \n \n 360\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_scrap\n \n \n \n \n 400\n 32\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 440\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyreq\n \n \n \n \n 280\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyper\n \n \n \n \n 280\n 17\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyfxd\n \n \n \n
\n \n 16\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 16\n \n \n 595\n 1\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n total\n balance\n \n \n \n \n \n 520\n 1\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n total\n issued\n \n \n \n \n 445\n 1\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n total\n required\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 89 WOMaterialRequirementsByWorkOrder \N \n\n W/O Material Requirements By Work Order\n WOMaterialRequirementsByWorkOrder\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT formatWONumber(wo_id) AS wonumber,\n warehous_code as warehouse,\n item_number, item_descrip1,\n item_descrip2, uom_name,\n wo_status AS status\n FROM wo, itemsite, item, uom, whsinfo\n WHERE ((wo_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (wo_id=<? value("wo_id") ?>) );\n \n \n detail\n workOrderMaterial\n detail\n \n \n 236\n \n \n \n 100\n 165\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n status\n \n \n \n \n 100\n 100\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n \n \n \n \n \n \n 100\n 140\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n \n \n \n 100\n 75\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n 100\n 120\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n 100\n 55\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n wonumber\n \n \n \n \n \n 5\n 229\n 745\n 229\n 2\n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 51\n \n \n 10\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 430\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyreq\n \n \n \n \n 190\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n issuemethod\n \n \n \n \n 350\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_scrap\n \n \n \n \n 509\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyiss\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 10\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 670\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_duedate\n \n \n \n \n 590\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_balance\n \n \n \n \n 10\n 15\n 255\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 270\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyper\n \n \n \n \n 270\n 17\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyfxd\n \n \n \n
\n \n 16\n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 456 Items \N \n\n Items\n Items\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT\n <? if exists("ListNumericItemNumbersFirst") ?>\n DISTINCT ON ( toNumeric(item_number, 999999999999999), item_number )\n <? else ?>\n DISTINCT ON ( item_number )\n <? endif ?>\n item_number,\n item_descrip1,\n item_descrip2,\n formatBoolYN(item_active) AS active,\n CASE WHEN (item_type='M') THEN 'Manufactured'\n WHEN (item_type='P') THEN 'Purchased'\n WHEN (item_type='F') THEN 'Phantom'\n WHEN (item_type='B') THEN 'Breeder'\n WHEN (item_type='C') THEN 'Co-Product'\n WHEN (item_type='Y') THEN 'By-Product'\n WHEN (item_type='R') THEN 'Reference'\n WHEN (item_type='T') THEN 'Tooling'\n WHEN (item_type='O') THEN 'Outside Process'\n WHEN (item_type='J') THEN 'Job'\n WHEN (item_type='K') THEN 'Kit'\n WHEN (item_type='L') THEN 'Planning'\n ELSE item_type\n END AS itemtype,\n iuom.uom_name AS invuom,\n itemcapuom(item_id) AS capuom,\n itemaltcapuom(item_id) AS altcapuom,\n puom.uom_name AS priceuom,\n puom.uom_name AS shipuom,\n formatRatio(itemcapinvrat(item_id)) AS capratio,\n formatRatio(itemaltcapinvrat(item_id)) AS altcapratio,\n formatRatio(iteminvpricerat(item_id)) AS shipratio,\n formatRatio(iteminvpricerat(item_id)) AS priceratio,\n formatBoolYN(item_sold) AS sold,\n formatBoolYN(item_exclusive) AS exclusive,\n formatBoolYN(item_picklist) AS picklist,\n formatBoolYN(item_config) AS configured,\n formatWeight(item_prodweight) AS prodweight,\n formatWeight(item_packweight) AS packweight,\n classcode_code\nFROM item\n JOIN classcode ON (item_classcode_id=classcode_id)\n JOIN prodcat ON (item_prodcat_id=prodcat_id)\n JOIN uom iuom ON (item_inv_uom_id=iuom.uom_id)\n JOIN uom puom ON (item_price_uom_id=puom.uom_id)\n<? if exists("itemgrp_id") ?>\n JOIN itemgrpitem ON (item_id=itemgrpitem_item_id)\n JOIN itemgrp ON (itemgrp_id=itemgrpitem_itemgrp_id)\n<? endif ?>\n<? foreach("char_id_text_list") ?>\n LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> \n ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='I') \n AND (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=item_id)\n AND (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> \n ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> \n ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='I') \n AND (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=item_id)\n AND (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> \n ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> \n ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='I') \n AND (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=item_id)\n AND (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> \n ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE ( true\n<? if exists("search_pattern") ?>\n AND ( (item_number ~* <? value("search_pattern") ?>)\n OR (item_descrip1 || item_descrip2 ~* <? value("search_pattern") ?>) )\n<? endif ?>\n<? if exists("showPurchased") ?>\n AND (item_type IN ('P', 'O'))\n<? elseif exists("showManufactured") ?>\n AND (item_type IN ('M', 'F', 'B','K'))\n<? elseif exists("showSold") ?>\n AND (item_sold)\n<? endif ?>\n<? if exists("item_type") ?>\n AND (item_type=<? value("item_type") ?>)\n<? endif ?>\n<? if not exists("showInactive") ?>\n AND (item_active)\n<? endif ?>\n<? if exists("classcode_id") ?>\n AND (item_classcode_id=<? value("classcode_id") ?>)\n<? endif ?>\n<? if exists("prodcat_id") ?>\n AND (item_prodcat_id=<? value("prodcat_id") ?>)\n<? endif ?>\n<? if exists("freightclass_id") ?>\n AND (item_freightclass_id=<? value("freightclass_id") ?>)\n<? endif ?>\n<? if exists("itemgrp_id") ?>\n AND (itemgrp_id=<? value("itemgrp_id") ?>)\n<? endif ?>\n<? if exists("item_number_pattern") ?>\n AND (item_number ~* <? value("item_number_pattern") ?>)\n<? endif ?>\n<? if exists("item_descrip_pattern") ?>\n AND (item_descrip1 || item_descrip2 ~* <? value("item_descrip_pattern") ?>)\n<? endif ?>\n<? if exists("classcode_pattern") ?>\n AND (classcode_code ~* <? value("classcode_pattern") ?>)\n<? endif ?>\n<? if exists("prodcat_pattern") ?>\n AND (prodcat_code ~* <? value("prodcat_pattern") ?>)\n<? endif ?>\n<? if exists("freightclass_pattern") ?>\n AND (freightclass_code ~* <? value("freightclass_pattern") ?>)\n<? endif ?>\n<? literal("charClause") ?>\n) ORDER BY\n<? if exists("ListNumericItemNumbersFirst") ?>\n toNumeric(item_number, 999999999999999),\n<? endif ?>\n item_number;\n \n \n 241\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 5\n 235\n 745\n 235\n 2\n \n \n \n \n 10\n 28\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 6\n \n \n 81\n \n \n \n 5\n 75\n 745\n 75\n 2\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n unnamed\n \n \n detail\n \n 81\n \n \n 565\n 30\n 60\n 15\n \n \n Arial\n 8\n 40\n \n \n \n \n detail\n picklist\n \n \n \n \n 10\n 15\n 250\n 15\n \n \n Arial\n 8\n 40\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 565\n 15\n 60\n 15\n \n \n Arial\n 8\n 40\n \n \n \n \n detail\n exclusive\n \n \n \n \n 433\n 45\n 90\n 15\n \n \n Arial\n 8\n 40\n \n \n \n \n detail\n priceratio\n \n \n \n \n 10\n 45\n 250\n 15\n \n \n Arial\n 8\n 40\n \n \n \n \n detail\n itemtype\n \n \n \n \n 640\n 0\n 100\n 15\n \n \n Arial\n 8\n 40\n \n \n \n \n detail\n packweight\n \n \n \n \n 10\n 30\n 250\n 15\n \n \n Arial\n 8\n 40\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 433\n 30\n 90\n 15\n \n \n Arial\n 8\n 40\n \n \n \n \n detail\n altcapratio\n \n \n \n \n 275\n 60\n 100\n 15\n \n \n Arial\n 8\n 40\n \n \n \n \n detail\n shipuom\n \n \n \n \n 10\n 0\n 250\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n item_number\n \n \n \n 5\n 75\n 745\n 75\n 0\n \n \n \n 565\n 0\n 60\n 15\n \n \n Arial\n 8\n 40\n \n \n \n \n detail\n sold\n \n \n \n \n 565\n 45\n 60\n 15\n \n \n Arial\n 8\n 40\n \n \n \n \n detail\n configured\n \n \n \n \n 275\n 45\n 100\n 15\n \n \n Arial\n 8\n 40\n \n \n \n \n detail\n priceuom\n \n \n \n \n 275\n 0\n 100\n 15\n \n \n Arial\n 8\n 40\n \n \n \n \n detail\n invuom\n \n \n \n \n 10\n 60\n 50\n 15\n \n \n Arial\n 8\n 40\n \n \n \n \n detail\n active\n \n \n \n \n 433\n 15\n 90\n 15\n \n \n Arial\n 8\n 40\n \n \n \n \n detail\n capratio\n \n \n \n \n 104\n 60\n 66\n 15\n \n \n Arial\n 8\n 40\n \n \n \n \n detail\n classcode_code\n \n \n \n \n 275\n 30\n 100\n 15\n \n \n Arial\n 8\n 40\n \n \n \n \n detail\n altcapuom\n \n \n \n \n 275\n 15\n 100\n 15\n \n \n Arial\n 8\n 40\n \n \n \n \n detail\n capuom\n \n \n \n \n 640\n 15\n 100\n 15\n \n \n Arial\n 8\n 40\n \n \n \n \n detail\n prodweight\n \n \n \n \n 433\n 60\n 90\n 15\n \n \n Arial\n 8\n 40\n \n \n \n \n detail\n shipratio\n \n \n \n
\n \n 16\n \n \n \n \n 80\n 0\n 140\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 715\n 0\n 30\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 283 APAging \N \n\n AP 30 60 90 Aging\n APAging\n Enhanced AP Aging - Uses 30-60-90 columns - User provides Relative Date - all amounts in base currency based on Document Date.\n \n Date Relative to Today\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT \n\tapaging_docdate,\n\tapaging_duedate,\n\tapaging_ponumber,\n\tapaging_docnumber,\n apaging_invcnumber,\n\tapaging_doctype,\n\tapaging_vend_id,\n\tapaging_vend_number,\n\tapaging_vend_name,\n\tapaging_vend_vendtype_id,\n\tapaging_vendtype_code,\n\tapaging_terms_descrip,\n\tformatMoney(apaging_apopen_amount) AS apaging_apopen_amount,\n\tapaging_cur_val, formatMoney(apaging_cur_val) AS apaging_cur_amt,\n\tapaging_thirty_val,formatMoney(apaging_thirty_val) AS apaging_thirty_amt,\n\tapaging_sixty_val, formatMoney(apaging_sixty_val) AS apaging_sixty_amt,\n\tapaging_ninety_val,formatMoney(apaging_ninety_val) AS apaging_ninety_amt,\n\tapaging_plus_val, formatMoney(apaging_plus_val) AS apaging_plus_amt,\n\tapaging_total_val, formatMoney(apaging_total_val) AS apaging_total_amt,\n\tapaging_disc_val, formatMoney(apaging_disc_val) AS apaging_disc_amt,\n\tapaging_discdate,\n\tapaging_discdays,\n\tapaging_discprcnt\nFROM apaging(<? value("relDate") ?>, <? value("useDocDate") ?>)\n<? if exists("vend_id") ?>\n WHERE (apaging_vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n WHERE (apaging_vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n WHERE (apaging_vendtype_code ~ <? value("vendtype_pattern") ?>)\n<? endif ?>;\n \n \n 77\n \n \n \n 45\n 40\n 110\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n Parameter Query\n relDate\n \n \n \n \n
\n detail\n \n Vendor\n apaging_vend_number\n \n \n 113\n \n \n \n \n \n \n \n \n \n \n \n 125\n 25\n 220\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_vend_number\n \n \n \n \n \n \n \n \n \n 0\n 105\n 1000\n 105\n 0\n \n \n \n 125\n 40\n 220\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_terms_descrip\n \n \n \n 0\n 5\n 1000\n 5\n 0\n \n \n \n \n \n \n \n 125\n 10\n 220\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_vend_name\n \n \n \n \n \n \n 96\n \n \n \n 0\n 50\n 220\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_name\n \n \n \n \n 530\n 5\n 75\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_thirty_val\n \n qty\n \n \n \n 237\n 32\n 237\n 32\n 0\n \n \n \n 450\n 5\n 75\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_cur_val\n \n qty\n \n \n \n 220\n 50\n 75\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_total_val\n \n qty\n \n \n \n 938\n 5\n 55\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_disc_val\n \n qty\n \n \n \n \n 620\n 5\n 70\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_sixty_val\n \n qty\n \n \n \n 705\n 5\n 70\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_ninety_val\n \n qty\n \n \n 0\n 0\n 1000\n 0\n 0\n \n \n \n 780\n 5\n 75\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_plus_val\n \n qty\n \n \n \n \n \n detail\n \n 18\n \n \n 860\n 0\n 70\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_discdate\n \n \n \n \n 939\n 0\n 55\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_disc_amt\n \n \n \n \n 270\n 0\n 85\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_duedate\n \n \n \n \n 20\n 0\n 80\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_invcnumber\n \n \n \n \n 0\n 0\n 15\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_doctype\n \n \n \n \n 530\n 0\n 75\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_thirty_amt\n \n \n \n \n 110\n 0\n 80\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_docnumber\n \n \n \n \n 450\n 0\n 75\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_cur_amt\n \n \n \n \n 795\n 0\n 55\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_plus_amt\n \n \n \n \n 355\n 0\n 80\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_apopen_amount\n \n \n \n \n 620\n 0\n 70\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_sixty_amt\n \n \n \n \n 705\n 0\n 70\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_ninety_amt\n \n \n \n \n 200\n 0\n 85\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_docdate\n \n \n \n
\n \n \n 102\n \n \n 220\n 35\n 75\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_total_val\n \n qty\n \n \n \n 620\n 5\n 70\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_sixty_val\n \n qty\n \n \n \n 530\n 5\n 75\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_thirty_val\n \n qty\n \n \n \n \n 450\n 5\n 75\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_cur_val\n \n qty\n \n \n \n \n \n 710\n 5\n 70\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_ninety_val\n \n qty\n \n \n \n 780\n 5\n 75\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_plus_val\n \n qty\n \n \n \n \n 942\n 5\n 55\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_disc_val\n \n qty\n \n \n \n \n 515\n 80\n 42\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n page_number\n \n \n \n 1\n 2\n 1000\n 2\n 2\n \n \n \n 47\n \n \n 515\n 25\n 42\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n Enhanced AP Aging - Uses 30-60-90 columns - User provides Relative Date - all amounts in base currency based on Document Date. 0 2015-10-01 17:15:58.47729 481 APAgingSummary \N \n\n AP 30 60 90 Aging Summary\n APAgingSummary\n Enhanced AP Aging - Uses 30-60-90 columns - User provides Relative Date - all amounts in base currency based on Document Date.\n\nVendor Summary\n \n Date Relative to Today\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT \n\tapaging_vend_id,\n\tapaging_vend_number,\n\tapaging_vend_name,\n\tapaging_vend_vendtype_id,\n\tapaging_vendtype_code,\n\tapaging_terms_descrip,\n\tformatMoney(SUM(apaging_apopen_amount)) AS apaging_apopen_amount,\n\tSUM(apaging_cur_val) AS apaging_cur_val, formatMoney(SUM(apaging_cur_val)) AS apaging_cur_amt,\n\tSUM(apaging_thirty_val) AS apaging_thirty_val, formatMoney(SUM(apaging_thirty_val)) AS apaging_thirty_amt,\n\tSUM(apaging_sixty_val) AS apaging_sixty_val, formatMoney(SUM(apaging_sixty_val)) AS apaging_sixty_amt,\n\tSUM(apaging_ninety_val) AS apaging_ninety_val, formatMoney(SUM(apaging_ninety_val)) AS apaging_ninety_amt,\n\tSUM(apaging_plus_val) AS apaging_plus_val, formatMoney(SUM(apaging_plus_val)) AS apaging_plus_amt,\n\tSUM(apaging_total_val) AS apaging_total_val, formatMoney(SUM(apaging_total_val)) AS apaging_total_amt,\n\tSUM(apaging_disc_val) AS apaging_disc_val, formatMoney(SUM(apaging_disc_val)) AS apaging_disc_amt\nFROM apaging(<? value("relDate") ?>, <? value("useDocDate") ?>)\n<? if exists("vend_id") ?>\n WHERE (apaging_vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n WHERE (apaging_vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n WHERE (apaging_vendtype_code ~ <? value("vendtype_pattern") ?>)\n<? endif ?>\nGROUP BY \tapaging_vend_id,\n\tapaging_vend_number,\n\tapaging_vend_name,\n\tapaging_vend_vendtype_id,\n\tapaging_vendtype_code,\n\tapaging_terms_descrip;\n \n \n 77\n \n \n \n 45\n 35\n 110\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n Parameter Query\n relDate\n \n \n \n \n \n \n \n \n \n \n \n \n \n 1\n 72\n 1000\n 72\n 2\n \n \n
\n detail\n \n \n detail\n \n 18\n \n \n 935\n 3\n 55\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_disc_amt\n \n \n \n \n 0\n 5\n 80\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_vend_number\n \n \n \n \n 530\n 5\n 75\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_thirty_amt\n \n \n \n \n 90\n 5\n 265\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_vend_name\n \n \n \n \n 450\n 5\n 75\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_cur_amt\n \n \n \n \n 795\n 5\n 55\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_plus_amt\n \n \n \n \n 620\n 5\n 70\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_sixty_amt\n \n \n \n \n 705\n 5\n 70\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_ninety_amt\n \n \n \n \n 365\n 5\n 80\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apaging_total_amt\n \n \n \n
\n \n \n 102\n \n \n 340\n 10\n 105\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n apaging_total_val\n \n qty\n \n \n \n \n 620\n 10\n 70\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n apaging_sixty_val\n \n qty\n \n \n \n \n 530\n 10\n 75\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n apaging_thirty_val\n \n qty\n \n \n \n \n \n 450\n 10\n 75\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n apaging_cur_val\n \n qty\n \n \n \n \n \n \n 710\n 10\n 70\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n apaging_ninety_val\n \n qty\n \n \n \n \n 780\n 10\n 75\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n apaging_plus_val\n \n qty\n \n \n \n \n 940\n 10\n 55\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n apaging_disc_val\n \n qty\n \n \n \n \n \n 515\n 80\n 42\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n page_number\n \n \n \n 2\n 4\n 1001\n 4\n 2\n \n \n \n 47\n \n \n 515\n 23\n 42\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 1 2015-10-01 17:15:58.47729 411 APApplications \N \n\n A/P Applications\n APApplications\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("showChecks") ?>\n <? if exists("showCreditMemos") ?>\n 'Show Checks and Credit Memos'\n <? else ?>\n 'Show Checks'\n <? endif ?>\n <? elseif exists("showCreditMemos") ?>\n 'Show Credit Memos'\n <? else ?>\n ''\n <? endif ?> AS f_show,\n <? if exists("vend_id") ?>\n 'Vendor:' AS f_label, vend_number AS f_value\n <? elseif exists("vendtype_id") ?>\n 'Vendor Type:' AS f_label, vendtype_code AS f_value\n <? elseif exists("vendtype_pattern") ?>\n 'Vendor Type matches:' AS f_label,\n <? value("vendtype_pattern") ?> AS f_value\n <? else ?>\n 'Vendors:' AS f_label, 'All' AS f_value\n <? endif ?>\n<? if exists("vend_id") ?>\n FROM vendinfo\n WHERE vend_id=<? value("vend_id") ?>\n<? elseif exists("vendtype_id") ?>\n FROM vendtype\n WHERE vendtype_id=<? value("vendtype_id")\n<? endif ?>\n;\n \n \n detail\n apApplications\n detail\n \n \n 146\n \n 5\n 140\n 745\n 140\n 2\n \n \n \n 565\n 63\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n 565\n 83\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n \n \n 10\n 63\n 139\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n f_label\n \n \n \n \n 159\n 83\n 350\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_show\n \n \n \n \n \n \n \n \n 157\n 63\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_value\n \n \n \n \n \n \n 6\n \n \n 26\n \n \n \n \n \n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 5\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_number\n \n \n \n \n 620\n 0\n 65\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_amount\n \n \n \n \n 200\n 0\n 81\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_postdate\n \n \n \n \n 500\n 0\n 110\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n apapply_target_docnumber\n \n \n \n \n 700\n 0\n 45\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n currAbbr\n \n \n \n \n 340\n 0\n 110\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n apapply_source_docnumber\n \n \n \n \n 90\n 0\n 115\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_name\n \n \n \n \n 291\n 0\n 40\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apapply_source_doctype_qtdisplayrole\n \n \n \n \n 460\n 0\n 40\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n apapply_target_doctype_qtdisplayrole\n \n \n \n
\n \n 16\n \n \n \n 104\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 16\n \n \n 585\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n base_applied\n \n money\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 205 APAssignmentsMasterList \N \n\n A/P Account Assignments Master List\n APAssignmentsMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT CASE WHEN (apaccnt_vendtype_id=-1) THEN apaccnt_vendtype\n ELSE (SELECT vendtype_code FROM vendtype WHERE (vendtype_id=apaccnt_vendtype_id))\n END AS vendtypecode,\n formatGLAccount(apaccnt_ap_accnt_id) AS apaccnt,\n formatGLAccount(apaccnt_prepaid_accnt_id) AS prepaidaccnt,\n formatGLAccount(apaccnt_discount_accnt_id) AS discountaccnt\nFROM apaccnt\nORDER BY vendtypecode;\n \n \n 77\n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n \n \n \n 7\n \n \n 22\n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 17\n \n \n 10\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vendtypecode\n \n \n \n \n 120\n 0\n 175\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n apaccnt\n \n \n \n \n 320\n -1\n 190\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n prepaidaccnt\n \n \n \n \n 530\n -1\n 195\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n discountaccnt\n \n \n \n
\n \n 17\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 188 APCheck \N \n\n Sample Check Format - 3 Part - MC - Remit\n APCheck\n Sample Check Format - 3 Part - MC - Uses primary Vendor or address with names: REMIT, Remit, or remit if one exists.\n Letter\n \n 0\n 0\n 0\n 50\n \n Head\n SELECT\ncheckhead_id, checkhead_number, checkhead_for AS memo,\nformatDate(checkhead_checkdate) AS f_checkdate,\nformatMoney(checkhead_amount) AS f_amount,\nINITCAP(spellAmount(checkhead_amount, curr_id)) AS f_words,\nCASE WHEN(checkhead_void) THEN TEXT('V O I D')\n ELSE TEXT('')\nEND AS f_void,\nCASE WHEN checkhead_recip_type = 'C' THEN (SELECT cust_number\n FROM custinfo\n WHERE (cust_id=checkhead_recip_id))\n WHEN checkhead_recip_type = 'T' THEN (SELECT taxauth_code\n FROM taxauth\n WHERE (taxauth_id=checkhead_recip_id))\n WHEN checkhead_recip_type = 'V' THEN (SELECT vend_number\n FROM vendinfo\n WHERE (vend_id=checkhead_recip_id))\n ELSE 'Unknown Recipient Type'\nEND AS recip_number,\nformatAddr(CASE WHEN checkhead_recip_type = 'C' THEN\n (SELECT cntct_addr_id\n FROM cntct, custinfo\n WHERE ((cust_cntct_id=cntct_id)\n AND (cust_id=checkhead_recip_id)))\n WHEN checkhead_recip_type = 'T' THEN \n (SELECT taxauth_addr_id\n FROM taxauth\n WHERE (taxauth_id=checkhead_recip_id))\n WHEN checkhead_recip_type = 'V' THEN\n COALESCE((SELECT vendaddr_addr_id\n FROM vendaddrinfo\n WHERE ((UPPER(vendaddr_code)='REMIT')\n AND (vendaddr_vend_id=checkhead_recip_id))),\n (SELECT vend_addr_id\n FROM vendinfo\n WHERE (vend_id=checkhead_recip_id)))\n END) AS check_address,\nCASE WHEN checkhead_recip_type = 'C' THEN (SELECT cust_name\n FROM custinfo\n WHERE cust_id=checkhead_recip_id)\n WHEN checkhead_recip_type = 'T' THEN (SELECT taxauth_name\n FROM taxauth\n WHERE taxauth_id=checkhead_recip_id)\n WHEN checkhead_recip_type = 'V' THEN\n COALESCE((SELECT vendaddr_name\n FROM vendaddrinfo\n WHERE ((UPPER(vendaddr_code)='REMIT')\n AND (vendaddr_vend_id=checkhead_recip_id))),\n (SELECT vend_name\n FROM vendinfo\n WHERE (vend_id=checkhead_recip_id)))\nEND AS recip_name, \ncurr_symbol, curr_abbr, curr_name\nFROM checkhead, curr_symbol\nWHERE ((checkhead_curr_id = curr_id)\n AND (checkhead_id=<? value("checkhead_id") ?>) );\n\n \n \n TopDetail2\n SELECT --VOUCHER-------------\n 1 AS ord,\n 1 AS sequence_value,\n checkitem_invcnumber,\n checkitem_ponumber,\n formatMoney(checkitem_amount) AS f_amount,\n 'Invoice#: ' || vohead_invcnumber AS doc_number,\n formatDate(vohead_docdate) AS f_docdate,\n vohead_reference AS doc_reference,\n 'Voucher: ' || checkitem_vouchernumber AS vouchernumber,\n formatMoney(apopen_amount) AS amount,\n formatMoney(checkitem_discount) AS disc_cred\nFROM checkitem, vohead, apopen\nWHERE ((checkitem_checkhead_id= <? value("checkhead_id") ?>)\n AND (checkitem_vouchernumber = vohead_number)\n AND (apopen_docnumber = checkitem_vouchernumber)\n AND (apopen_doctype = 'V'))\n\nUNION\n\nSELECT --DEBIT MEMO -------------------------\n 2 AS ord,\n 1 AS sequence_value,\n checkitem_invcnumber,\n checkitem_ponumber,\n formatMoney(checkitem_amount) AS f_amount,\n 'Debit Memo PO#: ' || checkitem_ponumber AS doc_number,\n '' AS f_docdate,\n 'Debit Memo: ' || checkitem_vouchernumber AS doc_reference,\n checkitem_vouchernumber AS vouchernumber,\n formatMoney(apopen_amount) AS amount,\n formatMoney(checkitem_discount) AS disc_cred\nFROM checkitem, apopen\nWHERE ((checkitem_checkhead_id= <? value("checkhead_id") ?>)\n AND (checkitem_vouchernumber = apopen_docnumber)\n AND (apopen_doctype = 'D'))\n\nUNION\n\nSELECT --CREDITs--------------------------\n 3 AS ord,\n 1 AS sequence_value,\n checkitem_invcnumber,\n checkitem_ponumber,\n formatMoney(checkitem_amount) AS f_amount,\n 'Invoice#: ' || vohead_invcnumber AS doc_number,\n formatDate(vohead_docdate) AS f_docdate,\n 'Credit Applied: ' || apapply_source_doctype || ' ' ||\n apapply_source_docnumber AS doc_reference,\n 'Voucher ' || checkitem_vouchernumber AS vouchernumber,\n '' AS amount,\n formatMoney((apapply_amount)) AS disc_cred\nFROM checkitem, vohead, apapply\nWHERE ((checkitem_checkhead_id=<? value("checkhead_id") ?>)\n AND (checkitem_vouchernumber = vohead_number)\n AND (apapply_target_docnumber = checkitem_vouchernumber ))\n\nUNION \n\nSELECT --NON-VENDOR-----------------------\n 4 AS ord,\n 1 AS sequence_value,\n checkitem_invcnumber,\n checkitem_ponumber,\n formatMoney(checkitem_amount) AS f_amount,\n checkitem_invcnumber AS doc_number,\n formatDate(checkitem_docdate) AS f_docdate,\n '' AS doc_reference,\n '' AS vouchernumber,\n '' AS amount,\n '' AS disc_cred\nFROM checkhead LEFT OUTER JOIN\n checkitem ON (checkitem_checkhead_id=checkhead_id)\nWHERE ((checkhead_id=<? value("checkhead_id") ?>) \n AND (checkhead_recip_type != 'V'))\n\nUNION \n\nSELECT --BLANK LINES FOR SPACING------------------\n 5 AS ord,\n sequence_value,\n '' AS checkkitem_invcnumber,\n '' AS checkitem_ponumber,\n '' AS f_amount,\n '' AS vohead_invcnumber,\n '' AS f_docdate,\n '' AS doc_reference,\n '' AS vouchernumber,\n '' AS amount,\n '' AS disc_cred\nFROM sequence\n\nORDER BY ord \nLIMIT 16;\n \n \n 6\n \n
\n Top Detail Header\n \n \n Head\n \n 51\n \n \n 305\n 30\n 147\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 305\n 15\n 155\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n Head\n recip_name\n \n \n \n \n 5\n 45\n 805\n 45\n 0\n \n \n 51\n 7\n 51\n 7\n 0\n \n \n \n 705\n 15\n 90\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n Head\n checkhead_number\n \n \n \n \n \n \n 494\n 15\n 104\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n Head\n recip_number\n \n \n \n \n
\n
\n Top Detail\n \n \n TopDetail2\n \n 16\n \n \n 5\n 0\n 155\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n TopDetail2\n doc_number\n \n \n \n \n 610\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n TopDetail2\n disc_cred\n \n \n \n \n 310\n 0\n 100\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n TopDetail2\n docdate\n \n \n \n \n 175\n 0\n 120\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n TopDetail2\n doc_reference\n \n \n \n \n 468\n 0\n 100\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n TopDetail2\n amount\n \n \n \n
\n
\n Top Detail Amount\n \n \n Head\n \n 36\n \n \n \n 468\n 0\n 100\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n Head\n f_amount\n \n \n \n \n \n 70\n 15\n 690\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n Head\n memo\n \n \n \n \n 395\n 0\n 55\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n Head\n curr_symbol\n \n \n \n
\n
\n Apchkitem\n \n \n Head\n \n 301\n \n \n 25\n 120\n 225\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Head\n recip_name\n \n \n \n \n 420\n 100\n 121\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Head\n f_checkdate\n \n \n \n \n 615\n 100\n 125\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Head\n f_amount\n \n \n \n \n 30\n 55\n 560\n 24\n \n \n Arial\n 12\n normal\n \n \n \n \n Head\n f_words\n \n \n \n \n 25\n 135\n 270\n 15\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n Head\n check_address\n \n \n \n \n 70\n 280\n 690\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n Head\n memo\n \n \n \n \n \n 560\n 100\n 55\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Head\n curr_symbol\n \n \n \n
\n
\n Bottom Detail Header\n \n \n Head\n \n 41\n \n \n \n \n \n 520\n 0\n 104\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n Head\n recip_number\n \n \n \n \n \n 320\n 15\n 147\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 710\n 0\n 90\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n Head\n checkhead_number\n \n \n \n 0\n 35\n 800\n 35\n 0\n \n \n \n 320\n 0\n 155\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n Head\n recip_name\n \n \n \n
\n
\n Bottom Detail\n \n \n TopDetail2\n \n 16\n \n \n 175\n 0\n 155\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n TopDetail2\n doc_reference\n \n \n \n \n 5\n 0\n 160\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n TopDetail2\n doc_number\n \n \n \n \n 468\n 0\n 100\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n TopDetail2\n amount\n \n \n \n \n 610\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n TopDetail2\n disc_cred\n \n \n \n \n 340\n 0\n 100\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n TopDetail2\n docdate\n \n \n \n
\n
\n Bottom Detail Amount\n \n \n Head\n \n 37\n \n \n 70\n 15\n 690\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n Head\n memo\n \n \n \n \n 408\n 0\n 55\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n Head\n curr_symbol\n \n \n \n \n \n \n 468\n 0\n 100\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n Head\n f_amount\n \n \n \n
\n
\n Sample Check Format - 3 Part - MC - Uses primary Vendor or address with names: REMIT, Remit, or remit if one exists. 0 2015-10-01 17:15:58.47729 284 ARAging \N \n\n AR 30 60 90 Aging\n ARAging\n Enhanced AR Aging - Uses 30-60-90 columns - User provides Relative Date - all amounts in base currency based on Document Date.\n \n \n \n 0.05\n 0.05\n \n Letter\n \n 100\n 100\n 50\n 50\n \n detail\n SELECT \n\taraging_docdate,\n\taraging_duedate,\n\taraging_ponumber,\n\taraging_docnumber,\n\taraging_doctype,\n\taraging_cust_id,\n\taraging_cust_number,\n\taraging_cust_name,\n\taraging_cust_custtype_id,\n\taraging_custtype_code,\n\taraging_terms_descrip,\n\tformatMoney(araging_aropen_amount) AS araging_aropen_amount,\n\taraging_cur_val, formatMoney(araging_cur_val) AS araging_cur_amt,\n\taraging_thirty_val,formatMoney(araging_thirty_val) AS araging_thirty_amt,\n\taraging_sixty_val, formatMoney(araging_sixty_val) AS araging_sixty_amt,\n\taraging_ninety_val,formatMoney(araging_ninety_val) AS araging_ninety_amt,\n\taraging_plus_val, formatMoney(araging_plus_val) AS araging_plus_amt,\n\taraging_total_val, formatMoney(araging_total_val) AS araging_total_amt\nFROM araging(<? value("relDate") ?>, <? value("useDocDate") ?>)\n<? if exists("cust_id") ?>\n WHERE (araging_cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n WHERE (araging_cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\n LEFT OUTER JOIN custgrpitem ON (araging_cust_id=custgrpitem_cust_id)\n WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n WHERE (araging_custtype_code ~ <? value("custtype_pattern") ?>)\n<? endif ?>;\n \n \n 81\n \n \n \n 60\n 40\n 110\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n Parameter Query\n relDate\n \n \n \n \n
\n detail\n \n Customer\n araging_cust_number\n \n \n 113\n \n \n 0\n 100\n 980\n 100\n 0\n \n \n \n \n \n \n 0\n 5\n 967\n 5\n 0\n \n \n \n 125\n 40\n 220\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_terms_descrip\n \n \n \n \n \n \n \n \n \n 125\n 25\n 220\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_cust_number\n \n \n \n \n \n \n 125\n 10\n 220\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_cust_name\n \n \n \n \n \n \n \n \n \n 111\n \n \n 825\n 8\n 70\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_ninety_val\n \n qty\n \n \n \n \n 740\n 8\n 70\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_sixty_val\n \n qty\n \n \n \n \n 250\n 50\n 75\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_total_val\n \n qty\n \n \n \n \n 570\n 8\n 75\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_cur_val\n \n qty\n \n \n \n \n 650\n 8\n 75\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_thirty_val\n \n qty\n \n \n \n \n \n 5\n 50\n 220\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n araging_cust_name\n \n \n \n 0\n 5\n 967\n 5\n 0\n \n \n \n 900\n 8\n 70\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_plus_val\n \n qty\n \n \n \n \n \n 237\n 31\n 237\n 31\n 0\n \n \n \n \n \n \n detail\n \n 18\n \n \n 740\n 0\n 70\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_sixty_amt\n \n \n \n \n 480\n 0\n 80\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_aropen_amount\n \n \n \n \n 0\n 0\n 25\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_doctype\n \n \n \n \n 40\n 0\n 61\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_docnumber\n \n \n \n \n 215\n 0\n 85\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_duedate\n \n \n \n \n 910\n 0\n 55\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_plus_amt\n \n \n \n \n 825\n 0\n 70\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_ninety_amt\n \n \n \n \n 120\n 0\n 85\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_docdate\n \n \n \n \n 340\n 0\n 61\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_ponumber\n \n \n \n \n 570\n 0\n 75\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_cur_amt\n \n \n \n \n 650\n 0\n 75\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_thirty_amt\n \n \n \n
\n \n \n 103\n \n \n \n 650\n 5\n 75\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_thirty_val\n \n qty\n \n \n \n \n 740\n 5\n 70\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_sixty_val\n \n qty\n \n \n \n \n \n \n 570\n 5\n 75\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_cur_val\n \n qty\n \n \n \n \n 910\n 5\n 55\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_plus_val\n \n qty\n \n \n \n 1\n 1\n 967\n 1\n 2\n \n \n \n 440\n 75\n 41\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 250\n 50\n 75\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_total_val\n \n qty\n \n \n \n \n \n \n 825\n 5\n 70\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_ninety_val\n \n qty\n \n \n \n \n 57\n \n \n 440\n 20\n 41\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n Enhanced AR Aging - Uses 30-60-90 columns - User provides Relative Date - all amounts in base currency based on Document Date. 0 2015-10-01 17:15:58.47729 482 ARAgingSummary \N \n\n AR 30 60 90 Aging Customer Summary\n ARAgingSummary\n Enhanced AR Aging - Uses 30-60-90 columns - User provides Relative Date - all amounts in base currency based on Document Date.\n\nCustomer Summarised Report\n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 40\n 40\n \n detail\n SELECT \n\taraging_cust_id,\n\taraging_cust_number,\n\taraging_cust_name,\n\taraging_cust_custtype_id,\n\taraging_custtype_code,\n\taraging_terms_descrip,\n\tformatMoney(SUM(araging_aropen_amount)) AS araging_aropen_amount,\n\tSUM(araging_cur_val) AS araging_cur_val, formatMoney(SUM(araging_cur_val)) AS araging_cur_amt,\n\tSUM(araging_thirty_val) AS araging_thirty_val, formatMoney(SUM(araging_thirty_val)) AS araging_thirty_amt,\n\tSUM(araging_sixty_val) AS araging_sixty_val, formatMoney(SUM(araging_sixty_val)) AS araging_sixty_amt,\n\tSUM(araging_ninety_val) AS araging_ninety_val, formatMoney(SUM(araging_ninety_val)) AS araging_ninety_amt,\n\tSUM(araging_plus_val) AS araging_plus_val, formatMoney(SUM(araging_plus_val)) AS araging_plus_amt,\n\tSUM(araging_total_val) AS araging_total_val, formatMoney(SUM(araging_total_val)) AS araging_total_amt\nFROM araging(<? value("relDate") ?>, <? value("useDocDate") ?>)\n<? if exists("cust_id") ?>\n WHERE (araging_cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n WHERE (araging_cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\n LEFT OUTER JOIN custgrpitem ON (araging_cust_id=custgrpitem_cust_id)\n WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n WHERE (araging_custtype_code ~ <? value("custtype_pattern") ?>)\n<? endif ?>\nGROUP BY \taraging_cust_id,\n\taraging_cust_number,\n\taraging_cust_name,\n\taraging_cust_custtype_id,\n\taraging_custtype_code,\n\taraging_terms_descrip ;\n \n \n 81\n \n \n \n 60\n 40\n 110\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n Parameter Query\n relDate\n \n \n \n \n \n \n \n \n \n 6\n 76\n 1013\n 76\n 0\n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 19\n \n \n 695\n 4\n 75\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_thirty_amt\n \n \n \n \n 935\n 4\n 75\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_plus_amt\n \n \n \n \n 860\n 4\n 75\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_ninety_amt\n \n \n \n \n 615\n 4\n 75\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_cur_amt\n \n \n \n \n 785\n 4\n 70\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_sixty_amt\n \n \n \n \n 5\n 4\n 80\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_cust_number\n \n \n \n \n 90\n 4\n 275\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_cust_name\n \n \n \n \n 375\n 4\n 140\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_terms_descrip\n \n \n \n \n 525\n 4\n 85\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n araging_total_amt\n \n \n \n
\n \n \n 103\n \n \n \n 695\n 10\n 75\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n araging_thirty_val\n \n qty\n \n \n \n \n 785\n 10\n 70\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n araging_sixty_val\n \n qty\n \n \n \n \n \n 615\n 10\n 75\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n araging_cur_val\n \n qty\n \n \n \n \n 935\n 10\n 75\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n araging_plus_val\n \n qty\n \n \n \n 6\n 4\n 1018\n 4\n 2\n \n \n \n 440\n 75\n 41\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 525\n 10\n 85\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n araging_total_val\n \n qty\n \n \n \n \n \n \n 860\n 10\n 75\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n araging_ninety_val\n \n qty\n \n \n \n \n 57\n \n \n 440\n 22\n 41\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 1 2015-10-01 17:15:58.47729 262 ARApplications \N \n\n A/R Applications\n ARApplications\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("cust_id") ?>\n (SELECT (cust_number || '-' || cust_name)\n FROM custinfo\n WHERE (cust_id=<? value("cust_id") ?>) )\n <? elseif exists("custtype_id") ?>\n (select (custtype_code||'-'||custtype_descrip)\n FROM custtype\n WHERE (custtype_id=<? value("custtype_id") ?>) )\n <? elseif exists("custtype_pattern") ?>\n text(<? value("custtype_pattern") ?>)\n <? else ?>\n text('All Customers')\n <? endif ?>\n AS f_value,\n <? if exists("custtype_id") ?>\n text('Cust. Type:')\n <? elseif exists("custtype_pattern") ?>\n text('Cust. Type Pattern:')\n <? else ?>\n text('Customer:')\n <? endif ?>\n AS f_label,\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("includeCashReceipts") ?>\n <? if exists("includeCreditMemos") ?>\n text('Show Cash Receipts and Credit Memos')\n <? else ?>\n text('Show Cash Receipts')\n <? endif ?>\n <? elseif exists("includeCreditMemos") ?>\n text('Show Credit Memos')\n <? else ?>\n text('Error: No transaction type selected.')\n <? endif ?>\n AS f_show;\n \n \n detail\n SELECT arapply_id,\n formatDate(arapply_postdate) AS f_postdate,\n formatMoney(arapply_applied) AS f_applied,\n cust_number, cust_name,\n (CASE WHEN (arapply_source_doctype='C') THEN <? value("creditMemo") ?>\n WHEN (arapply_source_doctype='R') THEN <? value("cashdeposit") ?>\n WHEN (arapply_fundstype='C') THEN <? value("check") ?>\n WHEN (arapply_fundstype='T') THEN <? value("certifiedCheck") ?>\n WHEN (arapply_fundstype='M') THEN <? value("masterCard") ?>\n WHEN (arapply_fundstype='V') THEN <? value("visa") ?>\n WHEN (arapply_fundstype='A') THEN <? value("americanExpress") ?>\n WHEN (arapply_fundstype='D') THEN <? value("discoverCard") ?>\n WHEN (arapply_fundstype='R') THEN <? value("otherCreditCard") ?>\n WHEN (arapply_fundstype='K') THEN <? value("cash") ?>\n WHEN (arapply_fundstype='W') THEN <? value("wireTransfer") ?>\n WHEN (arapply_fundstype='O') THEN <? value("other") ?>\n END || ' ' ||\n CASE WHEN (arapply_source_doctype IN ('C','R')) THEN TEXT(arapply_source_docnumber)\n ELSE arapply_refnumber\n END) AS source,\n (CASE WHEN (arapply_target_doctype='D') THEN <? value("debitMemo") ?>\n WHEN (arapply_target_doctype='I') THEN <? value("invoice") ?>\n WHEN (arapply_target_doctype='K') THEN <? value("apcheck") ?>\n ELSE <? value("other") ?>\n END || ' ' ||\n TEXT(arapply_target_docnumber)) AS target,\n currConcat(arapply_curr_id) AS currAbbr,\n currtobase(arapply_curr_id,arapply_applied,arapply_postdate) AS base_applied\nFROM arapply, custinfo\nWHERE ( (arapply_cust_id=cust_id)\n AND (arapply_postdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n AND (arapply_source_doctype IN (\n<? if exists("includeCreditMemos") ?>\n <? if exists("includeCashReceipts") ?>\n 'K', 'C', 'R'\n <? else ?>\n 'C', 'R'\n <? endif ?>\n<? else ?>\n 'K'\n<? endif ?> ))\n<? if exists("cust_id") ?>\n AND (cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n AND (cust_custtype_id IN (SELECT custtype_id FROM custtype\n WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n )\nORDER BY arapply_postdate, source;\n\n \n \n 146\n \n 5\n 140\n 745\n 140\n 2\n \n \n \n 565\n 65\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n 565\n 85\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n \n \n 10\n 65\n 125\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n f_label\n \n \n \n \n 95\n 90\n 350\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_show\n \n \n \n \n \n \n \n \n 140\n 65\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_value\n \n \n \n \n \n \n 6\n \n \n 26\n \n \n \n \n \n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 5\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_number\n \n \n \n \n 620\n 0\n 65\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_applied\n \n \n \n \n 220\n 0\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_postdate\n \n \n \n \n 460\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n target\n \n \n \n \n 700\n 0\n 45\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n currAbbr\n \n \n \n \n 300\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n source\n \n \n \n \n 90\n 0\n 115\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_name\n \n \n \n
\n \n 16\n \n \n \n 104\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 16\n \n \n 585\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n base_applied\n \n qty\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 414 AROpenItem \N \n\n AROpenItem\n AROpenItem\n A report showing details of a single AR Open Item\n \n \n \n \n \n \n \n \n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT aropen_cust_id, aropen_docdate, aropen_duedate, \naropen_doctype,\nCASE WHEN (aropen_doctype = 'C' AND ((SELECT COUNT(*) AS num_rows FROM cmhead, aropen WHERE cmhead_number = aropen_ordernumber AND aropen_id = <? value("aropen_id") ?> ) = 0)) THEN 'Misc. Credit Memo'\n WHEN (aropen_doctype = 'D' AND ((SELECT COUNT(*) AS num_rows FROM cmhead, aropen WHERE cmhead_number = aropen_ordernumber AND aropen_id = <? value("aropen_id") ?> ) = 0)) THEN 'Misc. Debit Memo'\n WHEN (aropen_doctype = 'C' AND ((SELECT COUNT(*) AS num_rows FROM cmhead, aropen WHERE cmhead_number = aropen_ordernumber AND aropen_id = <? value("aropen_id") ?> ) > 0)) THEN 'Credit Memo'\n WHEN (aropen_doctype = 'D' AND ((SELECT COUNT(*) AS num_rows FROM cmhead, aropen WHERE cmhead_number = aropen_ordernumber AND aropen_id = <? value("aropen_id") ?> ) > 0)) THEN 'Debit Memo'\n END AS doc_name, \naropen_docnumber, \naropen_ordernumber, aropen_journalnumber, \naropen_amount, aropen_amount, \naropen_paid, \n(aropen_amount - aropen_paid) AS f_balance, \naropen_terms_id, aropen_salesrep_id, \naropen_commission_due, \naropen_notes, aropen_rsncode_id, aropen_salescat_id, \naropen_accnt_id, aropen_curr_id, cust_name, salesrep_name, terms_code, \nrsncode_code, formatboolyn(aropen_commission_paid) AS commission_paid \nFROM aropen \nJOIN custinfo ON(cust_id = aropen_cust_id)\nLEFT OUTER JOIN salesrep ON(aropen_salesrep_id = salesrep_id)\nLEFT OUTER JOIN terms ON(terms_id = aropen_terms_id)\nLEFT OUTER JOIN rsncode ON(rsncode_id = aropen_rsncode_id)\nWHERE (aropen_id=<? value("aropen_id") ?>)\n \n \n applications\n <? if exists("docTypeID") ?>\nSELECT arapply_id, arapply_source_aropen_id,\n CASE WHEN (arapply_source_doctype = 'C') THEN <? value("creditMemo") ?>\n WHEN (arapply_source_doctype = 'R') THEN <? value("cashdeposit") ?>\n WHEN (arapply_fundstype='C') THEN <? value("check") ?>\n WHEN (arapply_fundstype='T') THEN <? value("certifiedCheck") ?>\n WHEN (arapply_fundstype='M') THEN <? value("masterCard") ?>\n WHEN (arapply_fundstype='V') THEN <? value("visa") ?>\n WHEN (arapply_fundstype='A') THEN <? value("americanExpress") ?>\n WHEN (arapply_fundstype='D') THEN <? value("discoverCard") ?> \n WHEN (arapply_fundstype='R') THEN <? value("otherCreditCard") ?>\n WHEN (arapply_fundstype='K') THEN <? value("cash") ?>\n WHEN (arapply_fundstype='W') THEN <? value("wireTransfer") ?>\n WHEN (arapply_fundstype='O') THEN <? value("other") ?>\n END AS doctype,\n CASE WHEN (arapply_source_doctype IN ('C','R')) THEN arapply_source_docnumber\n WHEN (arapply_source_doctype = 'K') THEN arapply_refnumber\n ELSE 'Other'\n END AS docnumber,\narapply_postdate, arapply_applied, \ncurrConcat(arapply_curr_id) AS currabbr, \ncurrToBase(arapply_curr_id, arapply_applied, arapply_postdate) AS baseapplied, \n'curr' AS arapply_applied_xtnumericrole, \n'curr' AS baseapplied_xtnumericrole \nFROM arapply \nWHERE (arapply_target_aropen_id=<? value("aropen_id") ?> ) \nORDER BY arapply_postdate\n\n<? elseif exists("docTypeRC") ?>\n\nSELECT arapply_id, arapply_target_aropen_id, \n CASE WHEN (arapply_target_doctype = 'I') THEN <? value("invoice") ?>\n WHEN (arapply_target_doctype = 'D') THEN <? value("debitMemo") ?>\n WHEN (arapply_target_doctype = 'K') THEN <? value("apcheck") ?>\n WHEN (arapply_target_doctype = 'R') THEN <? value("cashreceipt") ?>\n ELSE <? value("other") ?>\n END AS doctype, \narapply_target_docnumber AS docnumber, \narapply_postdate, arapply_applied, \ncurrConcat(arapply_curr_id) AS currabbr, \ncurrToBase(arapply_curr_id, arapply_applied, arapply_postdate) AS baseapplied, \n'curr' AS arapply_applied_xtnumericrole, \n'curr' AS baseapplied_xtnumericrole \nFROM arapply \nWHERE (arapply_source_aropen_id=<? value("aropen_id") ?> )\nORDER BY arapply_postdate\n\n<? endif ?>\n \n \n 445\n \n \n 530\n 160\n 196\n 25\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n head\n aropen_paid\n \n \n \n \n 530\n 185\n 195\n 25\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n head\n f_balance\n \n \n \n \n 140\n 70\n 201\n 25\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n head\n aropen_docdate\n \n \n \n \n \n \n \n 140\n 235\n 250\n 25\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n head\n rsncode_code\n \n \n \n \n \n \n 530\n 135\n 216\n 25\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n head\n aropen_amount\n \n \n \n \n 535\n 70\n 210\n 25\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n head\n terms_code\n \n \n \n \n \n \n 140\n 160\n 210\n 25\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n head\n aropen_docnumber\n \n \n \n \n 140\n 90\n 216\n 25\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n head\n aropen_duedate\n \n \n \n \n 140\n 45\n 432.315\n 25\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n head\n cust_name\n \n \n \n \n \n \n \n 140\n 135\n 175\n 25\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n head\n aropen_doctype\n \n \n \n \n 87.7597\n 271.717\n 624\n 127.611\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n \n head\n aropen_notes\n \n \n \n \n 140\n 210\n 177\n 25\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n head\n aropen_journalnumber\n \n \n \n \n \n 530\n 235\n 199\n 25\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n head\n commission_paid\n \n \n \n \n \n \n 535\n 90\n 210\n 25\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n head\n salesrep_name\n \n \n \n \n \n 530\n 210\n 198\n 25\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n head\n aropen_commission_due\n \n \n \n \n 140\n 185\n 176\n 25\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n head\n aropen_ordernumber\n \n \n \n \n \n \n \n \n \n \n \n 4\n 434\n 737\n 434\n 2\n \n \n \n 30.7855\n 9.22414\n 698.682\n 37.1\n \n \n Sans Serif\n 20\n bold\n \n \n \n \n head\n doc_name\n \n \n \n
\n applications_detail\n \n \n applications\n \n 23\n \n \n 8\n 1.71311\n 100\n 25\n \n \n Sans Serif\n 12\n normal\n \n \n \n \n applications\n doctype\n \n \n \n \n 124\n 1.71311\n 100\n 25\n \n \n Sans Serif\n 12\n normal\n \n \n \n \n applications\n docnumber\n \n \n \n \n 241\n 1.71311\n 100\n 25\n \n \n Sans Serif\n 12\n normal\n \n \n \n \n applications\n arapply_postdate\n \n \n \n \n 352\n 1.71311\n 100\n 25\n \n \n Sans Serif\n 12\n normal\n \n \n \n \n applications\n arapply_applied\n \n \n \n \n 474\n 1.71311\n 100\n 25\n \n \n Sans Serif\n 12\n normal\n \n \n \n \n applications\n currabbr\n \n \n \n \n 611\n 1.71311\n 100\n 25\n \n \n Sans Serif\n 12\n normal\n \n \n \n \n applications\n baseapplied\n \n \n \n
\n
\n A report showing details of a single AR Open Item 0 2015-10-01 17:15:58.47729 288 AROpenItems \N \n\n A/R Open Items\n AROpenItems\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT \nCASE WHEN (<? value("asofDate") ?> = endOfTime()) THEN 'Latest'\n ELSE formatDate(<? value("asofDate") ?>) END AS asOfDate,\n<? if exists("creditsOnly") ?>\n 'Credits Only' AS type,\n<? elseif exists("debitsOnly") ?>\n 'Debits Only' AS type,\n<? else ?>\n 'Debits and Credits' AS type,\n<? endif ?>\n<? if exists("cust_id") ?>\n (SELECT cust_name FROM custinfo WHERE cust_id=<? value("cust_id") ?>) AS selection,\n<? elseif exists("custtype_id") ?>\n (SELECT custtype_code FROM custtype WHERE custtype_id=<? value("custtype_id") ?>) AS selection,\n<? elseif exists("custtype_pattern") ?>\n ('Customer Type pattern = ' || <? value("custtype_pattern") ?>) AS selection,\n<? elseif exists("custgrp_id") ?>\n (SELECT custgrp_name FROM custgrp WHERE \n custgrp_id=<? value("custgrp_id") ?>) AS selection,\n<? else ?>\n 'All Customers' AS selection,\n<? endif ?>\n<? if exists("startDate") ?>\n 'Start Doc Date:' AS start_label,\n 'End Doc Date:' AS end_label,\n<? else ?>\n 'Start Due Date:' AS start_label, \n 'End Due Date:' AS end_label,\n<? endif ?>\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n currConcat(baseCurrId()) AS baseAbbr,\n<? if exists("incidentsOnly") ?>\n 'Yes' AS incidentsOnly\n<? else ?>\n 'No' AS incidentsOnly\n<? endif ?>;\n \n \n detail\n arOpenItems\n f_detail\n \n \n 178\n \n \n \n \n \n \n \n 514\n 69.7785\n 100\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n \n \n \n \n 514\n 52.6662\n 100\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n 5\n 170\n 745\n 170\n 2\n \n \n \n 410\n 52.6662\n 100\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n start_label\n \n \n \n \n 410.317\n 69.7785\n 100\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n end_label\n \n \n \n \n 141.375\n 69.7785\n 200\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n type\n \n \n \n \n 142\n 52.6662\n 250\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n selection\n \n \n \n \n 141.375\n 88.4798\n 200\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n incidentsOnly\n \n \n \n \n 514.049\n 88.4798\n 100\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n asOfDate\n \n \n \n \n \n \n \n \n \n 5\n \n \n 52\n \n \n 5\n 45\n 745\n 45\n 2\n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 18\n \n \n 350\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_duedate\n \n \n \n \n 600\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_balance\n \n \n \n \n 85\n 0\n 77\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n docnumber\n \n \n \n \n 700\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n currAbbr\n \n \n \n \n 440\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_amount\n \n \n \n \n 520\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_paid\n \n \n \n \n 5\n 0\n 78.9\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n doctype\n \n \n \n \n 270\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_docdate\n \n \n \n \n 165\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_name\n \n \n \n
\n \n 18\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 104\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 18\n \n \n 700\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n baseAbbr\n \n \n \n \n 600\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n base_balance\n \n qty\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 107 AccountNumberMasterList \N \n\n Chart of Accounts Master List\n AccountNumberMasterList\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT accnt_company,\n accnt_profit,\n accnt_number,\n accnt_sub,\n accnt_descrip,\n accnt_comments,\n CASE WHEN(accnt_type='A') THEN text('Asset')\n WHEN(accnt_type='L') THEN text('Liability')\n WHEN(accnt_type='E') THEN text('Expense')\n WHEN(accnt_type='R') THEN text('Revenue')\n WHEN(accnt_type='Q') THEN text('Equity')\n ELSE text(accnt_type)\n END AS f_type\nFROM accnt\nLEFT OUTER JOIN subaccnttype ON (accnt_type=subaccnttype_accnt_type AND accnt_subaccnttype_code=subaccnttype_code)\nWHERE ((true)\n<? if exists("accnt_type") ?>\n AND (accnt_type = <? value("accnt_type") ?>)\n<? endif ?>\n<? if exists("subaccnt_type") ?>\n AND (subaccnttype_id = <? value("subaccnt_type") ?>)\n<? endif ?>\n)\nORDER BY accnt_number, accnt_sub, accnt_profit;\n \n \n 77\n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n \n \n \n 6\n \n \n 21\n \n \n 10\n 15\n 750\n 15\n 2\n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 17\n \n \n 325\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n accnt_sub\n \n \n \n \n 220\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n accnt_number\n \n \n \n \n 115\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n accnt_profit\n \n \n \n \n 10\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n accnt_company\n \n \n \n \n 494\n 0\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n accnt_descrip\n \n \n \n \n 430\n 0\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_type\n \n \n \n
\n \n 17\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 237 AccountingPeriodsMasterList \N \n\n Accounting Periods Master List\n AccountingPeriodsMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT period_id,\n formatDate(period_start) AS f_start,\n formatDate(period_end) AS f_end,\n formatBoolYN(period_closed) AS f_closed,\n formatBoolYN(period_freeze) AS f_frozen\n FROM period\nORDER BY period_start;\n \n \n 77\n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n \n 7\n \n \n 22\n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n
\n detail\n \n \n detail\n \n 17\n \n \n 420\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_closed\n \n \n \n \n 114\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_end\n \n \n \n \n 515\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_frozen\n \n \n \n \n 10\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_start\n \n \n \n
\n \n 17\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 425 MetaSQLMasterList \N \n\n List of MetaSQL statements\n MetaSQLMasterList\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 100\n 100\n 100\n 100\n \n Detail\n metasqls\n detail\n \n \n 100\n \n \n
\n Detail\n \n \n Detail\n \n 27.4992\n \n \n 100\n 0\n 100\n 12.5\n \n \n Arial\n 9\n bold\n \n \n \n \n Detail\n metasql_group\n \n \n \n \n 200\n 0\n 150\n 12.5\n \n \n Arial\n 9\n bold\n \n \n \n \n Detail\n metasql_name\n \n \n \n \n 350\n 0\n 300\n 14\n \n 12\n \n Arial\n 9\n normal\n \n \n \n \n Detail\n metasql_notes_qttooltiprole\n \n \n \n \n 0\n 0\n 100\n 12.5\n \n \n Arial\n 9\n bold\n \n \n \n \n Detail\n pkgname\n \n \n \n
\n \n 65.9806\n \n \n \n 330\n 22.5008\n 100\n 25\n \n \n Arial\n 10\n normal\n \n \n \n \n Context Query\n page_count\n \n \n \n \n 200\n 22.5008\n 100\n 25\n \n \n Arial\n 10\n normal\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 301 AccountingYearPeriodsMasterList \N \n\n Accounting Year Periods Master List\n AccountingYearPeriodsMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT yearperiod_id,\n formatDate(yearperiod_start) AS f_start,\n formatDate(yearperiod_end) AS f_end,\n formatBoolYN(yearperiod_closed) AS f_closed\n FROM yearperiod\nORDER BY yearperiod_start;\n \n \n 75\n \n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n 6\n \n \n 21\n \n \n 5\n 14\n 745\n 14\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 17\n \n \n 113\n 0\n 100\n 14\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_end\n \n \n \n \n 10\n 0\n 100\n 14\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_start\n \n \n \n \n 420\n 0\n 80\n 14\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_closed\n \n \n \n
\n \n 15\n \n \n \n 90\n 0\n 100\n 14\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 14\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 311 AddressesMasterList \N \n\n Addresses Master List\n AddressesMasterList\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT * \nFROM (\nSELECT 'Contact' AS type, cntct_first_name AS first,\n cntct_last_name AS last, crmacct_number, cntct_phone AS phone,\n cntct_email AS email, cntct_fax AS fax, addr.*\nFROM addr, cntct LEFT OUTER JOIN crmacct ON (cntct_crmacct_id=crmacct_id)\nWHERE (cntct_addr_id=addr_id)\nUNION\nSELECT 'Ship-To' AS type, shipto_num AS first,\n shipto_name AS last, crmacct_number, '' AS phone,\n '' AS email, '' AS fax, addr.*\nFROM addr, shiptoinfo LEFT OUTER JOIN crmacct ON (shipto_cust_id=crmacct_cust_id\n)\nWHERE (shipto_addr_id=addr_id)\nUNION\nSELECT 'Vendor' AS type, vend_number AS first,\n vend_name AS last, crmacct_number, '' AS phone,\n '' AS email, '' AS fax, addr.*\nFROM addr, vendinfo LEFT OUTER JOIN crmacct ON (vend_id=crmacct_vend_id)\nWHERE (vend_addr_id=addr_id)\nUNION\nSELECT 'Vendor Address' AS type, vendaddr_code AS first,\n vendaddr_name AS last, crmacct_number, '' AS phone,\n '' AS email, '' AS fax, addr.*\nFROM addr, vendaddrinfo LEFT OUTER JOIN crmacct ON (vendaddr_vend_id=crmacct_vend_id)\nWHERE (vendaddr_addr_id=addr_id)\nUNION\nSELECT 'Site' AS type, warehous_code AS first,\n warehous_descrip AS last, '' AS crmacct_number, '' AS phone,\n '' AS email, '' AS fax, addr.*\nFROM addr, whsinfo\nWHERE (warehous_addr_id=addr_id)\n\nUNION\nSELECT '' AS type, '' AS first, '' AS last,\n '' AS crmacct_number, '' AS phone,\n '' AS email,\n '' AS fax, addr.*\nFROM addr\nWHERE addr_id NOT IN (\n SELECT cntct_addr_id FROM cntct WHERE (cntct_addr_id IS NOT NULL)\n UNION SELECT shipto_addr_id FROM shiptoinfo WHERE (shipto_addr_id IS NOT NULL) \n UNION SELECT vend_addr_id FROM vendinfo WHERE (vend_addr_id IS NOT NULL)\n UNION SELECT vendaddr_addr_id FROM vendaddrinfo WHERE (vendaddr_addr_id IS NOT NULL)\n UNION SELECT warehous_addr_id FROM whsinfo WHERE (warehous_addr_id IS NOT NULL))\n) data\n<? foreach("char_id_text_list") ?>\n LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='ADDR') \n AND (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=addr_id)\n AND (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='ADDR') \n AND (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=addr_id)\n AND (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='ADDR') \n AND (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=addr_id)\n AND (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE true\n<? if not exists("showInactive") ?> AND addr_active <? endif ?>\n<? literal("charClause") ?>\nORDER BY addr_country, addr_state, addr_city,\n addr_postalcode, addr_line1, addr_line2,\n addr_line3, type, last, first;\n \n \n 156\n \n \n \n \n \n \n 6.33333\n 150.333\n 995.333\n 150.333\n 2\n \n \n \n \n \n \n \n \n \n \n \n \n \n 5\n 36\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 6\n \n \n 38\n \n \n \n \n \n \n \n \n 5\n 31\n 992\n 31\n 2\n \n \n \n \n \n \n \n \n \n
\n detail\n \n Address\n addr_id\n \n 22\n \n \n 375\n 5\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n addr_city\n \n \n \n \n 750\n 5\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n addr_postalcode\n \n \n \n \n 625\n 5\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n addr_country\n \n \n \n \n 140\n 5\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n addr_line2\n \n \n \n \n 10\n 5\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n addr_line1\n \n \n \n \n 500\n 5\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n addr_state\n \n \n \n \n 270\n 5\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n addr_line3\n \n \n \n \n \n \n detail\n \n 12\n \n \n 375\n 0\n 100\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n last\n \n \n \n \n 750\n 0\n 120\n 12\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n fax\n \n \n \n \n 500\n 0\n 100\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n crmacct_number\n \n \n \n \n 625\n 0\n 100\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n phone\n \n \n \n \n 270\n 0\n 100\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n first\n \n \n \n \n 875\n 0\n 100\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n email\n \n \n \n \n 140\n 0\n 100\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n type\n \n \n \n
\n \n 17\n \n \n 90\n -1\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 945\n -1\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 291 AdjustmentTypes \N \n\n Adjustment Types\n AdjustmentTypes\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT bankadjtype_name, bankadjtype_descrip,\n formatGLAccountLong(bankadjtype_accnt_id) AS f_accnt,\n CASE WHEN(bankadjtype_iscredit) THEN text('Credit')\n ELSE text('Debit')\n END AS f_type\n FROM bankadjtype;\n \n \n 121\n \n \n \n \n 5\n 115\n 745\n 115\n 2\n \n \n \n \n \n \n 9\n \n \n 36\n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 18\n \n \n 5\n 0\n 155\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n bankadjtype_name\n \n \n \n \n 165\n 0\n 170\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n bankadjtype_descrip\n \n \n \n \n 340\n 0\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_accnt\n \n \n \n \n 645\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_type\n \n \n \n
\n \n 18\n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 104 Alignment \N \n\n Alignment\n Alignment\n \n Letter\n \n 0\n 0\n 0\n 0\n \n 1152\n \n \n \n 0\n 919\n 850\n 919\n 1\n \n \n 580\n 0\n 580\n 1150\n 1\n \n \n 280\n 0\n 280\n 1150\n 1\n \n \n 0\n 470\n 850\n 470\n 1\n \n \n 0\n 869\n 850\n 869\n 1\n \n \n 0\n 800\n 850\n 800\n 1\n \n \n \n 0\n 459\n 850\n 459\n 1\n \n \n 340\n 0\n 340\n 1150\n 1\n \n \n 0\n 690\n 850\n 690\n 1\n \n \n 0\n 960\n 850\n 960\n 1\n \n \n 0\n 1090\n 850\n 1090\n 1\n \n \n 0\n 380\n 850\n 380\n 1\n \n \n 560\n 0\n 560\n 1150\n 1\n \n \n 0\n 300\n 850\n 300\n 1\n \n \n 0\n 1120\n 850\n 1120\n 1\n \n \n 0\n 819\n 850\n 819\n 1\n \n \n 350\n 0\n 350\n 1150\n 1\n \n \n 0\n 30\n 850\n 30\n 1\n \n \n 170\n 0\n 170\n 1150\n 1\n \n \n 0\n 990\n 850\n 990\n 1\n \n \n 0\n 760\n 850\n 760\n 1\n \n \n 0\n 0\n 0\n 1150\n 1\n \n \n 0\n 220\n 850\n 220\n 1\n \n \n \n 360\n 0\n 360\n 1150\n 1\n \n \n 0\n 10\n 850\n 10\n 1\n \n \n 0\n 1150\n 850\n 1150\n 1\n \n \n 0\n 210\n 850\n 210\n 1\n \n \n 0\n 570\n 850\n 570\n 1\n \n \n 70\n 0\n 70\n 1150\n 1\n \n \n 0\n 100\n 850\n 100\n 1\n \n \n 400\n 0\n 400\n 1150\n 1\n \n \n 540\n 0\n 540\n 1150\n 1\n \n \n \n 730\n 0\n 730\n 1150\n 1\n \n \n \n \n 20\n 0\n 20\n 1150\n 1\n \n \n 0\n 900\n 850\n 900\n 1\n \n \n 220\n 0\n 220\n 1150\n 1\n \n \n 200\n 0\n 200\n 1150\n 1\n \n \n 0\n 509\n 850\n 509\n 1\n \n \n 300\n 0\n 300\n 1150\n 1\n \n \n 0\n 740\n 850\n 740\n 1\n \n \n \n 490\n 0\n 490\n 1150\n 1\n \n \n 0\n 530\n 850\n 530\n 1\n \n \n 0\n 930\n 850\n 930\n 1\n \n \n 630\n 0\n 630\n 1150\n 1\n \n \n 0\n 980\n 850\n 980\n 1\n \n \n 0\n 620\n 850\n 620\n 1\n \n \n 780\n 0\n 780\n 1150\n 1\n \n \n 0\n 670\n 850\n 670\n 1\n \n \n 420\n 0\n 420\n 1150\n 1\n \n \n 0\n 180\n 850\n 180\n 1\n \n \n 0\n 150\n 850\n 150\n 1\n \n \n 0\n 730\n 850\n 730\n 1\n \n \n 80\n 0\n 80\n 1150\n 1\n \n \n 0\n 400\n 850\n 400\n 1\n \n \n 0\n 110\n 850\n 110\n 1\n \n \n 0\n 310\n 850\n 310\n 1\n \n \n 0\n 940\n 850\n 940\n 1\n \n \n 0\n 640\n 850\n 640\n 1\n \n \n 0\n 1040\n 850\n 1040\n 1\n \n \n 140\n 0\n 140\n 1150\n 1\n \n \n \n 440\n 0\n 440\n 1150\n 1\n \n \n 0\n 280\n 850\n 280\n 1\n \n \n 0\n 660\n 850\n 660\n 1\n \n \n 30\n 0\n 30\n 1150\n 1\n \n \n 130\n 0\n 130\n 1150\n 1\n \n \n 0\n 950\n 850\n 950\n 1\n \n \n 0\n 40\n 850\n 40\n 1\n \n \n 0\n 650\n 850\n 650\n 1\n \n \n 0\n 700\n 850\n 700\n 1\n \n \n 470\n 0\n 470\n 1150\n 1\n \n \n 0\n 130\n 850\n 130\n 1\n \n \n 0\n 260\n 850\n 260\n 1\n \n \n 0\n 360\n 850\n 360\n 1\n \n \n 0\n 890\n 850\n 890\n 1\n \n \n \n 0\n 350\n 850\n 350\n 1\n \n \n 0\n 480\n 850\n 480\n 1\n \n \n 260\n 0\n 260\n 1150\n 1\n \n \n \n \n \n 0\n 370\n 850\n 370\n 1\n \n \n 550\n 0\n 550\n 1150\n 1\n \n \n 250\n 0\n 250\n 1150\n 1\n \n \n 0\n 600\n 850\n 600\n 1\n \n \n 600\n 0\n 600\n 1150\n 1\n \n \n 0\n 0\n 850\n 0\n 1\n \n \n 509\n 0\n 509\n 1150\n 1\n \n \n 640\n 0\n 640\n 1150\n 1\n \n \n 409\n 0\n 409\n 1150\n 1\n \n \n 0\n 250\n 850\n 250\n 1\n \n \n 480\n 0\n 480\n 1150\n 1\n \n \n 0\n 50\n 850\n 50\n 1\n \n \n 0\n 720\n 850\n 720\n 1\n \n \n 0\n 1070\n 850\n 1070\n 1\n \n \n 819\n 0\n 819\n 1150\n 1\n \n \n 0\n 770\n 850\n 770\n 1\n \n \n 0\n 560\n 850\n 560\n 1\n \n \n 0\n 20\n 850\n 20\n 1\n \n \n 0\n 90\n 850\n 90\n 1\n \n \n 0\n 860\n 850\n 860\n 1\n \n \n 660\n 0\n 660\n 1150\n 1\n \n \n 790\n 0\n 790\n 1150\n 1\n \n \n 0\n 580\n 850\n 580\n 1\n \n \n 459\n 0\n 459\n 1150\n 1\n \n \n 0\n 170\n 850\n 170\n 1\n \n \n 50\n 0\n 50\n 1150\n 1\n \n \n \n 150\n 0\n 150\n 1150\n 1\n \n \n 0\n 1100\n 850\n 1100\n 1\n \n \n 500\n 0\n 500\n 1150\n 1\n \n \n 0\n 70\n 850\n 70\n 1\n \n \n 0\n 610\n 850\n 610\n 1\n \n \n 0\n 1140\n 850\n 1140\n 1\n \n \n 110\n 0\n 110\n 1150\n 1\n \n \n 770\n 0\n 770\n 1150\n 1\n \n \n 0\n 590\n 850\n 590\n 1\n \n \n 740\n 0\n 740\n 1150\n 1\n \n \n 0\n 630\n 850\n 630\n 1\n \n \n 0\n 1030\n 850\n 1030\n 1\n \n \n 690\n 0\n 690\n 1150\n 1\n \n \n \n 0\n 550\n 850\n 550\n 1\n \n \n 0\n 140\n 850\n 140\n 1\n \n \n 0\n 1050\n 850\n 1050\n 1\n \n \n 0\n 1019\n 850\n 1019\n 1\n \n \n 520\n 0\n 520\n 1150\n 1\n \n \n 0\n 1000\n 850\n 1000\n 1\n \n \n 100\n 0\n 100\n 1150\n 1\n \n \n 450\n 0\n 450\n 1150\n 1\n \n \n 720\n 0\n 720\n 1150\n 1\n \n \n 160\n 0\n 160\n 1150\n 1\n \n \n 0\n 60\n 850\n 60\n 1\n \n \n 0\n 450\n 850\n 450\n 1\n \n \n 760\n 0\n 760\n 1150\n 1\n \n \n 0\n 420\n 850\n 420\n 1\n \n \n 680\n 0\n 680\n 1150\n 1\n \n \n 0\n 850\n 850\n 850\n 1\n \n \n 650\n 0\n 650\n 1150\n 1\n \n \n 620\n 0\n 620\n 1150\n 1\n \n \n 0\n 190\n 850\n 190\n 1\n \n \n 0\n 409\n 850\n 409\n 1\n \n \n 40\n 0\n 40\n 1150\n 1\n \n \n 700\n 0\n 700\n 1150\n 1\n \n \n 0\n 1010\n 850\n 1010\n 1\n \n \n 800\n 0\n 800\n 1150\n 1\n \n \n 240\n 0\n 240\n 1150\n 1\n \n \n 310\n 0\n 310\n 1150\n 1\n \n \n 710\n 0\n 710\n 1150\n 1\n \n \n 0\n 540\n 850\n 540\n 1\n \n \n 10\n 0\n 10\n 1150\n 1\n \n \n 570\n 0\n 570\n 1150\n 1\n \n \n 0\n 810\n 850\n 810\n 1\n \n \n 0\n 1130\n 850\n 1130\n 1\n \n \n 390\n 0\n 390\n 1150\n 1\n \n \n 229\n 0\n 229\n 1150\n 1\n \n \n \n 0\n 680\n 850\n 680\n 1\n \n \n 0\n 270\n 850\n 270\n 1\n \n \n 180\n 0\n 180\n 1150\n 1\n \n \n 850\n 0\n 850\n 1150\n 1\n \n \n 0\n 80\n 850\n 80\n 1\n \n \n 0\n 240\n 850\n 240\n 1\n \n \n 0\n 750\n 850\n 750\n 1\n \n \n 0\n 160\n 850\n 160\n 1\n \n \n 0\n 290\n 850\n 290\n 1\n \n \n 0\n 910\n 850\n 910\n 1\n \n \n 840\n 0\n 840\n 1150\n 1\n \n \n 0\n 229\n 850\n 229\n 1\n \n \n 670\n 0\n 670\n 1150\n 1\n \n \n 0\n 330\n 850\n 330\n 1\n \n \n 0\n 710\n 850\n 710\n 1\n \n \n 0\n 840\n 850\n 840\n 1\n \n \n 60\n 0\n 60\n 1150\n 1\n \n \n 0\n 790\n 850\n 790\n 1\n \n \n 0\n 1060\n 850\n 1060\n 1\n \n \n 190\n 0\n 190\n 1150\n 1\n \n \n 590\n 0\n 590\n 1150\n 1\n \n \n 810\n 0\n 810\n 1150\n 1\n \n \n 530\n 0\n 530\n 1150\n 1\n \n \n 0\n 520\n 850\n 520\n 1\n \n \n 0\n 340\n 850\n 340\n 1\n \n \n 0\n 390\n 850\n 390\n 1\n \n \n 90\n 0\n 90\n 1150\n 1\n \n \n 0\n 120\n 850\n 120\n 1\n \n \n \n \n 0\n 830\n 850\n 830\n 1\n \n \n 0\n 880\n 850\n 880\n 1\n \n \n \n 0\n 200\n 850\n 200\n 1\n \n \n 830\n 0\n 830\n 1150\n 1\n \n \n 0\n 780\n 850\n 780\n 1\n \n \n 0\n 500\n 850\n 500\n 1\n \n \n 120\n 0\n 120\n 1150\n 1\n \n \n 0\n 440\n 850\n 440\n 1\n \n \n 320\n 0\n 320\n 1150\n 1\n \n \n 370\n 0\n 370\n 1150\n 1\n \n \n 0\n 430\n 850\n 430\n 1\n \n \n 210\n 0\n 210\n 1150\n 1\n \n \n 610\n 0\n 610\n 1150\n 1\n \n \n 290\n 0\n 290\n 1150\n 1\n \n \n 330\n 0\n 330\n 1150\n 1\n \n \n 0\n 1080\n 850\n 1080\n 1\n \n \n 430\n 0\n 430\n 1150\n 1\n \n \n 380\n 0\n 380\n 1150\n 1\n \n \n 750\n 0\n 750\n 1150\n 1\n \n \n 0\n 969\n 850\n 969\n 1\n \n \n 0\n 490\n 850\n 490\n 1\n \n \n 270\n 0\n 270\n 1150\n 1\n \n \n 0\n 1110\n 850\n 1110\n 1\n \n \n 0\n 320\n 850\n 320\n 1\n \n \n\n 0 2015-10-01 17:15:58.47729 459 Backlog \N \n\n Backlog\n Backlog\n \n \n \n \n \n \n \n \n \n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT CASE WHEN (checkPrivilege('ViewCustomerPrices') AND isMultiCurr()) THEN text('Amount(base)')\n WHEN (checkPrivilege('ViewCustomerPrices')) THEN text('Amount')\n ELSE text('')\n END AS lbl_baseamount,\n CASE WHEN (checkPrivilege('ViewCustomerPrices') AND isMultiCurr()) THEN text('Amount(foreign)')\n ELSE text('')\n END AS lbl_foreignamount;\n \n \n detail\n SELECT cohead_number, coitem_linenumber, cust_name,\n formatDate(cohead_orderdate) AS f_orderdate,\n formatDate(coitem_scheddate) AS f_scheddate,\n item_number, uom_name,\n item_descrip1, item_descrip2,\n formatQty(coitem_qtyord) AS f_qtyord,\n formatQty(coitem_qtyshipped) AS f_qtyship,\n formatQty(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned)) AS f_balance, \n CASE WHEN (checkPrivilege('ViewCustomerPrices')) THEN\nformatMoney(round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio)\n * (currtobase(cohead_curr_id,coitem_price,cohead_orderdate) / coitem_price_invuomratio),2))\n ELSE\n text('')\n END\n AS f_ammount,\n CASE WHEN (checkPrivilege('ViewCustomerPrices') AND isMultiCurr()) THEN\nformatMoney(round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio)\n * (coitem_price / coitem_price_invuomratio),2))\n ELSE\n text('')\n END\n AS foreign_ammount,\nround((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio)\n * (currtobase(cohead_curr_id,coitem_price,cohead_orderdate) / coitem_price_invuomratio),2) AS backlog \n FROM cohead, coitem, itemsite, item, custinfo, uom\n WHERE ((coitem_cohead_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (coitem_status='O')\n <? if exists("cohead_id") ?>\n AND (coitem_cohead_id=<? value("cohead_id") ?>)\n <? endif ?>\n <? if exists("startDate") ?>\n AND (cohead_orderdate >= <? value("startDate") ?>)\n <? endif ?>\n <? if exists("endDate") ?>\n AND (cohead_orderdate <= <? value("endDate") ?>)\n <? endif ?>\n <? if exists("startDateSched") ?>\n AND (coitem_scheddate >= <? value("startDateSched") ?>)\n <? endif ?>\n <? if exists("endDateSched") ?>\n AND (coitem_scheddate <= <? value("endDateSched") ?>)\n <? endif ?>\n <? if exists("salesrep_id") ?>\n AND (cohead_salesrep_id=<? value("salesrep_id") ?>)\n <? endif ?>\n <? if exists("shipto_id") ?>\n AND (cohead_shipto_id=<? value("shipto_id") ?>)\n <? endif ?>\n <? if exists("cust_id") ?>\n AND (cohead_cust_id=<? value("cust_id") ?>)\n <? endif ?>\n <? if exists("custtype_id") ?>\n AND (cust_custtype_id=<? value("custtype_id") ?>)\n <? endif ?>\n <? if exists("custtype_pattern") ?>\n AND (cust_custtype_id IN (SELECT DISTINCT custtype_id\n FROM custtype\n WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n <? endif ?>\n <? if exists("custgrp") ?>\n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrpitem))\n <? endif ?>\n <? if exists("custgrp_id") ?>\n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrpitem\n WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)))\n <? endif ?>\n <? if exists("custgrp_pattern") ?>\n AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id\n FROM custgrp, custgrpitem\n WHERE ( (custgrpitem_custgrp_id=custgrp_id)\n AND (custgrp_name ~ <? value("custgrp_pattern") ?>) )) )\n <? endif ?>\n\n <? if exists("item_id") ?>\n AND (itemsite_item_id=<? value("item_id") ?>)\n <? endif ?>\n <? if exists("prodcat_id") ?>\n AND (item_prodcat_id=<? value("prodcat_id") ?>)\n <? endif ?>\n <? if exists("prodcat_pattern") ?>\n AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id\n FROM prodcat\n WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n <? endif ?>\n\n <? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n <? endif ?>\n)\nORDER BY coitem_scheddate, cohead_number, coitem_linenumber;\n \n \n total\n SELECT now()\n WHERE 't' = CASE WHEN (checkPrivilege('ViewCustomerPrices')) THEN 't'\n ELSE 'f'\n END\n;\n \n \n 226\n \n \n \n \n \n 660\n 185\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_baseamount\n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n 660\n 200\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_foreignamount\n \n \n \n \n \n \n \n \n \n \n \n \n \n 5\n 28\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n \n \n \n \n \n \n \n 660\n 0\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_baseamount\n \n \n \n \n 660\n 15\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_foreignamount\n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 52\n \n \n 305\n 30\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 65\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n coitem_linenumber\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 305\n 15\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 507\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyship\n \n \n \n \n 671\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n foreign_ammount\n \n \n \n \n 305\n 0\n 140\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 670\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ammount\n \n \n \n \n 450\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n \n 225\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_orderdate\n \n \n \n \n 507\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyord\n \n \n \n \n 225\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_scheddate\n \n \n \n \n 112\n 0\n 110\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_name\n \n \n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_balance\n \n \n \n \n 5\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cohead_number\n \n \n \n
\n
\n totals\n \n \n total\n \n 18\n \n \n \n 670\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n backlog\n \n money\n \n \n \n
\n \n 18\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 240 BankAccountsMasterList \N \n\n Bank Accounts Master List\n BankAccountsMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT bankaccnt_id,\n bankaccnt_name AS f_name,\n bankaccnt_descrip AS f_descrip,\n CASE WHEN (bankaccnt_type='K') THEN text('Checking')\n WHEN (bankaccnt_type='C') THEN text('Cash')\n WHEN (bankaccnt_type='R') THEN text('Credit Card')\n ELSE text('?')\n END AS f_type,\n formatBoolYN(bankaccnt_ap) AS f_ap,\n formatBoolYN(bankaccnt_ar) AS f_ar\n FROM bankaccnt\nORDER BY bankaccnt_name;\n \n \n 77\n \n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n \n 7\n \n \n 22\n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 17\n \n \n 495\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_type\n \n \n \n \n 95\n 0\n 395\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_descrip\n \n \n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ap\n \n \n \n \n 10\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_name\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ar\n \n \n \n
\n \n 17\n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 292 BankAdjustmentEditList \N \n\n Bank Adjustment Edit List\n BankAdjustmentEditList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT bankadj_id, (bankaccnt_name || '-' || bankaccnt_descrip) AS f_bank,\n bankadjtype_name, formatDate(bankadj_date) AS f_date, bankadj_docnumber,\n formatMoney(bankadj_amount) AS f_amount\n FROM bankadj LEFT OUTER JOIN bankaccnt ON (bankadj_bankaccnt_id=bankaccnt_id)\n LEFT OUTER JOIN bankadjtype ON (bankadj_bankadjtype_id=bankadjtype_id)\n WHERE ( (NOT bankadj_posted)\n AND (bankadj_bankaccnt_id=<? value("bankaccnt_id") ?>) );\n \n \n 121\n \n 5\n 115\n 745\n 115\n 2\n \n \n \n \n \n \n \n \n \n \n 9\n \n \n 21\n \n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 18\n \n \n 5\n 0\n 155\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_bank\n \n \n \n \n 165\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n bankadjtype_name\n \n \n \n \n 340\n 0\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n bankadj_docnumber\n \n \n \n \n 645\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_amount\n \n \n \n \n 250\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_date\n \n \n \n
\n \n 18\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 263 BillingSelections \N \n\n Billing Selections\n BillingSelections\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT cobmisc_id,\n cohead_id,\n COALESCE(TEXT(cobmisc_invcnumber), '?') AS docnumber,\n cohead_number,\n cust_number,\n cust_name\n FROM cobmisc, cohead, custinfo\n WHERE ((cobmisc_cohead_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n AND (NOT cobmisc_posted) )\nORDER BY docnumber;\n \n \n 123\n \n \n \n 5\n 112\n 745\n 112\n 2\n \n \n \n \n \n \n 102\n \n \n 80\n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n \n
\n detail\n \n \n detail\n \n 18\n \n \n 110\n 1\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_number\n \n \n \n \n 5\n 1\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cohead_number\n \n \n \n \n 214\n 1\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_name\n \n \n \n
\n \n 18\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 312 ContactsMasterList \N \n\n Contacts Master List\n ContactsMasterList\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n contacts\n detail\n \n \n 143\n \n \n \n \n \n 6\n 137\n 995\n 137\n 2\n \n \n \n \n \n \n \n \n \n 5\n 33\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n 5\n 15\n 994\n 15\n 2\n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 17\n \n \n 250\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n crmacct_number\n \n \n \n \n 10\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cntct_first_name\n \n \n \n \n 725\n 0\n 145\n 15\n \n 0\n \n Arial\n 8\n bold\n \n \n \n \n detail\n cntct_email\n \n \n \n \n 875\n 0\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cntct_webaddr\n \n \n \n \n 545\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cntct_phone2\n \n \n \n \n 450\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cntct_phone\n \n \n \n \n 120\n 0\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cntct_last_name\n \n \n \n \n 625\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cntct_fax\n \n \n \n \n 325\n 0\n 100\n 15\n \n 0\n \n Arial\n 8\n bold\n \n \n \n \n detail\n crmacct_name\n \n \n \n
\n \n 17\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 945\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 103 OpenWorkOrdersWithClosedParentSalesOrders \N \n\n Open Work Orders With Closed Parent Sales Orders\n OpenWorkOrdersWithClosedParentSalesOrders\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse;\n \n \n detail\n SELECT formatWONumber(wo_id) AS wonumber,\n wo_status, item_number, uom_name,\n item_descrip1, item_descrip2,\n warehous_code,\n cohead_number,\n formatQty(wo_qtyord) AS qtyord,\n formatQty(wo_qtyrcv) AS qtyrcv,\n formatDate(wo_startdate) AS startdate,\n formatDate(wo_duedate) AS duedate \n FROM coitem, cohead, wo, itemsite, whsinfo, item, uom\n WHERE ((coitem_cohead_id=cohead_id)\n AND (coitem_order_id=wo_id)\n AND (coitem_status='C')\n AND (wo_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (wo_status IN ('O', 'E', 'R', 'I'))\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n)\nORDER BY wo_duedate;\n \n \n 236\n \n \n \n \n \n \n \n \n \n \n \n \n 5\n 229\n 745\n 229\n 2\n \n \n \n 140\n 110\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n 6\n \n \n 36\n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 51\n \n \n 265\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 85\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 5\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n wonumber\n \n \n \n \n 85\n 0\n 175\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 405\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyord\n \n \n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n startdate\n \n \n \n \n 315\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cohead_number\n \n \n \n \n 85\n 15\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 5\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n wo_status\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n duedate\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 490\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyrcv\n \n \n \n
\n \n 16\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 155 BriefEarnedCommissions \N \n\n Brief Earned Commissions\n BriefEarnedCommissions\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("salesrep_id") ?>\n ( SELECT salesrep_name\n FROM salesrep\n WHERE (salesrep_id=<? value("salesrep_id") ?>) )\n <? else ?>\n text('All Sales Reps')\n <? endif ?>\n AS salesrep,\n formatDate(<? value("startDate") ?>) AS startdate,\n formatDate(<? value("endDate") ?>) AS enddate;\n \n \n detail\n briefEarnedCommission\n detail\n \n \n 221\n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n 140\n 100\n 385\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n salesrep\n \n \n \n \n \n \n \n \n \n \n \n \n 140\n 120\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n 140\n 140\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n \n 6\n \n \n 26\n \n \n \n \n \n \n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 345\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cohist_ordernumber\n \n \n \n \n 585\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_sumbaseextprice\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_sumbasecommission\n \n \n \n \n 165\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_number\n \n \n \n \n 505\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_invcdate\n \n \n \n \n 220\n 0\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_name\n \n \n \n \n 60\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n salesrep_name\n \n \n \n \n 425\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cohist_invcnumber\n \n \n \n \n 5\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n salesrep_number\n \n \n \n
\n \n 16\n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 16\n \n \n \n 585\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n sumbaseextprice\n \n money\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n sumbasecommission\n \n money\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 359 Budget \N \n\n Budget\n Budget\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT formatDate(period_start) AS f_firstperiod,\n formatDate(period_end) AS f_lastperiod,\n formatGLAccountLong(budgitem_accnt_id) AS f_accnt,\n formatMoney(budgitem_amount) AS f_amount\n FROM budgitem \n JOIN period ON (budgitem_period_id=period_id)\n WHERE(budgitem_budghead_id=<? value("budghead_id") ?>)\n ORDER BY period_start, f_accnt;\n \n \n head\n SELECT budghead_name,\n budghead_descrip\n FROM budghead\n WHERE(budghead_id=<? value("budghead_id") ?>);\n \n \n 161\n \n \n \n \n 160\n 80\n 375\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n budghead_descrip\n \n \n \n \n \n 160\n 65\n 375\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n budghead_name\n \n \n \n \n 5\n 155\n 745\n 155\n 2\n \n \n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n
\n detail\n \n \n detail\n \n 17\n \n \n 110\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_lastperiod\n \n \n \n \n 5\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_firstperiod\n \n \n \n \n 215\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_accnt\n \n \n \n \n 370\n 0\n 375\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_amount\n \n \n \n
\n \n 17\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 358 BudgetsMasterList \N \n\n Budgets Master List\n BudgetsMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT formatDate(min(period_start)) AS f_firstperiod,\n formatDate(max(period_end)) AS f_lastperiod,\n budghead_name,\n budghead_descrip\n FROM budghead LEFT OUTER JOIN budgitem \n JOIN period ON (budgitem_period_id=period_id)\n ON (budgitem_budghead_id=budghead_id)\n GROUP BY budghead_name, budghead_descrip\n ORDER BY budghead_name;\n \n \n 76\n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n \n 6\n \n \n 21\n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 215\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n budghead_name\n \n \n \n \n 5\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_firstperiod\n \n \n \n \n 370\n 0\n 375\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n budghead_descrip\n \n \n \n \n 110\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_lastperiod\n \n \n \n
\n \n 16\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 160 BuyCard \N \n\n Buy Card\n BuyCard\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT vend_number, vend_name,\n itemsrc_vend_item_number,\n itemsrc_vend_item_descrip\n FROM vendinfo, itemsrc\n WHERE ((vend_id=<? value("vend_id") ?>)\n AND (itemsrc_id=<? value("itemsrc_id") ?>) )\n \n \n detail\n SELECT poitem_id, pohead_number, poitem_linenumber,\n CASE WHEN(poitem_status='C') THEN TEXT('Closed')\n WHEN(poitem_status='U') THEN TEXT('Unposted')\n WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) AND (poitem_qty_ordered>(poitem_qty_received-poitem_qty_returned))) THEN TEXT('Partial')\n WHEN(poitem_status='O' AND ((poitem_qty_received-poitem_qty_returned) > 0) AND (poitem_qty_ordered=(poitem_qty_received-poitem_qty_returned))) THEN TEXT('Received')\n WHEN(poitem_status='O') THEN TEXT('Open')\n ELSE poitem_status\n END AS poitemstatus,\n formatDate(poitem_duedate) as f_duedate,\n formatQty(poitem_qty_ordered) as f_qtyord,\n formatQty(COALESCE(SUM(recv_qty), 0)) as f_qty,\n formatPrice(poitem_unitprice) as f_unitprice\nFROM pohead, poitem LEFT OUTER JOIN recv ON (recv_orderitem_id=poitem_id)\nWHERE ( (poitem_pohead_id=pohead_id)\n AND (recv_order_type='PO')\n AND (pohead_vend_id=<? value("vend_id") ?>)\n AND (poitem_vend_item_number=(select itemsrc_vend_item_number from itemsrc where itemsrc_id=<? value("itemsrc_id") ?>)) ) \nGROUP BY poitem_id, pohead_number, poitem_linenumber,\n poitem_status, poitem_qty_received, poitem_qty_returned,\n poitem_duedate, poitem_qty_ordered, poitem_unitprice\nORDER BY pohead_number, poitem_linenumber;\n \n \n foot\n SELECT itemsrc_comments\n FROM itemsrc\n WHERE itemsrc_id=<? value("itensrc_id") ?>;\n \n \n 221\n \n \n 135\n 114\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n itemsrc_vend_item_number\n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n \n \n \n \n 135\n 65\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n vend_number\n \n \n \n \n \n \n 135\n 85\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n vend_name\n \n \n \n \n \n \n 135\n 135\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n itemsrc_vend_item_descrip\n \n \n \n \n \n 6\n \n \n 26\n \n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 260\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyord\n \n \n \n \n 455\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_unitprice\n \n \n \n \n 175\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_duedate\n \n \n \n \n 5\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n pohead_number\n \n \n \n \n 60\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n poitem_linenumber\n \n \n \n \n 370\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qty\n \n \n \n \n 114\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n poitemstatus\n \n \n \n
\n \n 16\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 104\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 31\n \n \n \n 125\n 5\n 615\n 20\n \n 5\n \n Arial\n 10\n bold\n \n \n \n \n foot\n itemsrc_comments\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 369 CCReceipt \N \n\n Credit Card Receipt\n CCReceipt\n \n Letter\n \n 100\n 100\n 100\n 100\n \n header\n SELECT remitto.*,\n formatAddr(remitto_address1, remitto_address2,\n remitto_address3, remitto_citystatezip,\n remitto_country) AS remitto_addr\nFROM remitto;\n \n \n detail\n SELECT *,\n formatbytea(decrypt(setbytea(ccard_name),\n setbytea(<? value("key") ?>),\n 'bf')) AS holder,\n formatccnumber(decrypt(setbytea(ccard_number),\n setbytea(<? value("key") ?>),\n 'bf')) AS xxxx,\n CASE WHEN (ccpay_type='A') THEN <? value("preauth") ?>\n WHEN (ccpay_type='C') THEN <? value("charge") ?>\n WHEN (ccpay_type='R') THEN <? value("refund") ?>\n ELSE ccpay_type\n END AS type,\n CASE WHEN (ccpay_status='A') THEN <? value("authorized") ?>\n WHEN (ccpay_status='C') THEN <? value("approved") ?>\n WHEN (ccpay_status='D') THEN <? value("declined") ?>\n WHEN (ccpay_status='R') THEN <? value("reversed") ?>\n WHEN (ccpay_status='V') THEN <? value("voided") ?>\n WHEN (ccpay_status='X') THEN <? value("noapproval") ?>\n ELSE ccpay_status\n END AS status\n\nFROM ccpay JOIN\n ccard ON (ccpay_ccard_id=ccard_id) JOIN\n custinfo ON (ccard_cust_id=cust_id)\nWHERE (ccpay_id=<? value("ccpay_id") ?>);\n \n \n 101\n \n \n 0\n 60\n 250\n 15\n \n 40\n \n Arial\n 10\n normal\n \n \n \n \n header\n remitto_addr\n \n \n \n \n \n 0\n 40\n 150\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n header\n remitto_name\n \n \n \n \n \n 160\n 20\n 100\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n Header\n \n \n header\n \n 101\n \n
\n
\n Detail\n \n \n detail\n \n 231\n \n \n 130\n 160\n 200\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n ccpay_r_ref\n \n \n \n \n \n 130\n 200\n 200\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n ccpay_r_ordernum\n \n \n \n \n \n \n 130\n 60\n 200\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n ccpay_transaction_datetime\n \n \n \n \n 130\n 80\n 200\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n type\n \n \n \n \n 130\n 100\n 200\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n ccpay_amount\n \n \n \n \n \n \n \n \n 130\n 180\n 200\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n ccpay_by_username\n \n \n \n \n 130\n 20\n 200\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n holder\n \n \n \n \n 130\n 0\n 200\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n cust_name\n \n \n \n \n \n \n 130\n 140\n 200\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n status\n \n \n \n \n \n 130\n 40\n 200\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n xxxx\n \n \n \n
\n
\n 0 2015-10-01 17:15:58.47729 313 CRMAccountMasterList \N \n\n Accounts Master List\n CRMAccountMasterList\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n crmaccounts\n detail\n \n \n 160\n \n \n \n \n 4.76465\n 156.293\n 744.765\n 156.293\n 2\n \n \n \n \n \n \n \n \n \n \n \n \n 5\n 40\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 6\n \n \n 34\n \n \n \n \n 4.23535\n 30.2931\n 744.235\n 30.2931\n 2\n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 32\n \n \n 550\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n competitor\n \n \n \n \n 10\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n crmacct_number\n \n \n \n \n 615\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n partner\n \n \n \n \n 418.235\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n prospect\n \n \n \n \n 115\n 0\n 234\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n crmacct_name\n \n \n \n \n 680\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n taxauth\n \n \n \n \n 355\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust\n \n \n \n \n 485\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend\n \n \n \n \n 302.941\n 15.3526\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cntct_phone\n \n \n \n \n 115\n 15.3526\n 185\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cntct_name\n \n \n \n \n 417.941\n 15.3526\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cntct_email\n \n \n \n
\n \n 18\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 286 OpenWorkOrdersWithParentSalesOrders \N \n\n Open Work Orders With Parent Sales Orders\n OpenWorkOrdersWithParentSalesOrders\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse;\n \n \n detail\n SELECT formatWONumber(wo_id) AS wonumber,\n wo_status, item_number, uom_name,\n item_descrip1, item_descrip2,\n warehous_code,\n cohead_number,\n formatQty(wo_qtyord) AS qtyord,\n formatQty(wo_qtyrcv) AS qtyrcv,\n formatDate(wo_startdate) AS startdate,\n formatDate(wo_duedate) AS duedate \n FROM coitem, cohead, wo, itemsite, whsinfo, item, uom\n WHERE ((coitem_cohead_id=cohead_id)\n AND (coitem_order_id=wo_id)\n AND (coitem_status<>'X')\n AND (wo_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (wo_status IN ('O', 'E', 'R', 'I'))\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n)\nORDER BY wo_duedate;\n \n \n 236\n \n \n 5\n 230\n 745\n 230\n 2\n \n \n \n \n \n \n 140\n 110\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n \n \n \n \n \n \n \n 6\n \n \n 36\n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 51\n \n \n 5\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n wo_status\n \n \n \n \n 85\n 0\n 175\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 5\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n wonumber\n \n \n \n \n 85\n 15\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 85\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 490\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyrcv\n \n \n \n \n 315\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cohead_number\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n startdate\n \n \n \n \n 265\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 405\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyord\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n duedate\n \n \n \n
\n \n 16\n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 56 CapacityUOMsByClassCode \N \n\n Capacity UOMs By Class Code\n CapacityUOMsByClassCode\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("classcode_id") ?>\n ( SELECT (classcode_code || '-' || classcode_descrip)\n FROM classcode\n WHERE (classcode_id=<? value("classcode_id") ?>) )\n <? elseif exists("classcode_pattern") ?>\n text(<? value("classcode_pattern") ?>)\n <? else ?>\n text('All Class Codes')\n <? endif ?>\n AS classcode;\n \n \n detail\n SELECT classcode_code,\n item_number,\n item_descrip1,\n item_descrip2,\n uom_name,\n itemcapuom(item_id) AS capuom,\n formatRatio(itemcapinvrat(item_id)) AS capratio,\n itemaltcapuom(item_id) AS altcapuom,\n formatRatio(itemaltcapinvrat(item_id)) AS altcapratio,\n itemsellinguom(item_id) AS shipuom,\n formatRatio(iteminvpricerat(item_id)) AS shipratio\n FROM item, classcode, uom\n WHERE ((item_classcode_id=classcode_id)\n AND (item_inv_uom_id=uom_id)\n<? if exists("classcode_id") ?>\n AND (classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n AND (classcode_code ~ <? value("classcode_pattern") ?>)\n<? endif ?>\n)\nORDER BY classcode_code, item_number;\n \n \n \n 234\n \n \n \n 120\n 120\n 565\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n classcode\n \n \n \n \n \n \n \n \n \n \n \n \n 5\n 228\n 745\n 228\n 2\n \n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 51\n \n \n 600\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shipratio\n \n \n \n \n 5\n 0\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n classcode_code\n \n \n \n \n 600\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shipuom\n \n \n \n \n 300\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n \n 400\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n capuom\n \n \n \n \n 500\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n altcapuom\n \n \n \n \n 500\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n altcapratio\n \n \n \n \n 100\n 15\n 228\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 400\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n capratio\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 100\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 100\n 30\n 228\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n
\n \n 16\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 57 CapacityUOMsByProductCategory \N \n\n Capacity UOMs by Product Category\n CapacityUOMsByProductCategory\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT prodcat_code,\n item_number,\n item_descrip1,\n item_descrip2,\n uom_name,\n itemcapuom(item_id) AS capuom,\n formatRatio(itemcapinvrat(item_id)) AS capratio,\n itemaltcapuom(item_id) AS altcapuom,\n formatRatio(itemaltcapinvrat(item_id)) AS altcapratio,\n itemsellinguom(item_id) AS shipuom,\n formatRatio(iteminvpricerat(item_id)) AS shipratio\n FROM item, prodcat, uom\n WHERE ((item_sold)\n AND (item_inv_uom_id=uom_id)\n AND (item_prodcat_id=prodcat_id)\n<? if exists("prodcat_id") ?>\n AND (prodcat_id=<? value("prodcat_id") ?>)\n<? elseif exists("prodcat_pattern") ?>\n AND (prodcat_code ~ <? value("prodcat_pattern") ?>)\n<? endif ?>\n)\nORDER BY prodcat_code, item_number;\n \n \n \n head\n SELECT <? if exists("prodcat_id") ?>\n ( SELECT (prodcat_code||'-'||prodcat_descrip)\n FROM prodcat\n WHERE (prodcat_id=<? value("prodcat_id") ?>) )\n <? elseif exists("prodcat_pattern") ?>\n text(<? value("prodcat_pattern") ?>)\n <? else ?>\n text('All Product Categories')\n <? endif ?>\n AS prodcat;\n \n \n 234\n \n \n \n \n \n \n \n \n \n \n \n \n 160\n 120\n 483\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n prodcat\n \n \n \n \n 5\n 228\n 745\n 228\n 2\n \n \n \n \n \n 6\n \n \n 36\n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 51\n \n \n 600\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shipratio\n \n \n \n \n 5\n 0\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n prodcat_code\n \n \n \n \n 70\n 15\n 228\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 500\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n altcapratio\n \n \n \n \n 70\n 0\n 228\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 600\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shipuom\n \n \n \n \n 400\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n capratio\n \n \n \n \n 300\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n \n 500\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n altcapuom\n \n \n \n \n 70\n 30\n 228\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 400\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n capuom\n \n \n \n
\n \n 16\n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 211 CashReceiptsEditList \N \n\n Cash Receipt Edit List\n CashReceiptsEditList\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT cashrcpt_id, 1 AS orderBy,\n cust_number, cust_name,\n formatDate(cashrcpt_distdate) AS f_distdate,\n CASE WHEN (cashrcpt_fundstype = 'C') THEN <? value("check") ?>\n WHEN (cashrcpt_fundstype = 'T') THEN <? value("certifiedCheck") ?>\n WHEN (cashrcpt_fundstype = 'M') THEN <? value("masterCard") ?>\n WHEN (cashrcpt_fundstype = 'V') THEN <? value("visa") ?>\n WHEN (cashrcpt_fundstype = 'A') THEN <? value("americanExpress") ?>\n WHEN (cashrcpt_fundstype = 'D') THEN <? value("discoverCard") ?>\n WHEN (cashrcpt_fundstype = 'R') THEN <? value("otherCreditCard") ?>\n WHEN (cashrcpt_fundstype = 'K') THEN <? value("cash") ?>\n WHEN (cashrcpt_fundstype = 'W') THEN <? value("wireTransfer") ?>\n ELSE <? value("other") ?>\n END AS f_fundstype,\n 'C/R' AS doctype,\n cashrcpt_docnumber AS docnumber,\n cashrcpt_amount AS amount,\n formatMoney(cashrcpt_amount) AS f_amount,\n 0 AS detailedamount,\n formatMoney(0) AS f_detailedamount,\n bankaccnt_name\nFROM cashrcpt, bankaccnt, custinfo\nWHERE ( (cashrcpt_bankaccnt_id=bankaccnt_id)\n AND (cashrcpt_cust_id=cust_id)\n AND (NOT cashrcpt_posted)\n AND (NOT cashrcpt_void) )\n\nUNION\nSELECT cashrcpt_id, 2 AS orderBy,\n '' AS cust_number, '' AS cust_name,\n '' AS f_distdate,\n '' AS f_fundstype,\n aropen_doctype AS doctype,\n aropen_docnumber AS docnumber,\n 0 AS amount,\n formatMoney(0) AS f_amount,\n cashrcptitem_amount AS detailedamount,\n formatMoney(cashrcptitem_amount) AS f_detailedamount,\n '' AS bankaccnt_name\nFROM cashrcptitem, cashrcpt, aropen\nWHERE ( (cashrcptitem_cashrcpt_id=cashrcpt_id)\n AND (cashrcptitem_aropen_id=aropen_id)\n AND (NOT cashrcpt_posted)\n AND (NOT cashrcpt_void) )\n\nUNION\nSELECT cashrcpt_id, 3 AS orderBy,\n '' AS cust_number, '' AS cust_name,\n '' AS f_distdate,\n '' AS f_fundstype,\n 'Misc.' AS doctype,\n (formatGLAccount(accnt_id) || '-' || accnt_descrip) AS docnumber,\n 0 AS amount,\n formatMoney(0) AS f_amount,\n cashrcptmisc_amount AS detailedamount,\n formatMoney(cashrcptmisc_amount) AS f_detailedamount,\n '' AS bankaccnt_name\nFROM cashrcptmisc, cashrcpt, accnt\nWHERE ( (cashrcptmisc_cashrcpt_id=cashrcpt_id)\n AND (cashrcptmisc_accnt_id=accnt_id)\n AND (NOT cashrcpt_posted)\n AND (NOT cashrcpt_void) )\n\nORDER BY cashrcpt_id, orderBy;\n\n\n \n \n 145\n \n \n \n \n \n \n \n \n \n 5\n 130\n 745\n 130\n 2\n \n \n \n \n \n
\n detail\n \n detail\n cashrcpt_id\n \n 18\n \n \n 540\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_amount\n \n \n \n \n 85\n 0\n 130\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_name\n \n \n \n \n 615\n 0\n 125\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n bankaccnt_name\n \n \n \n \n 10\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_number\n \n \n \n \n 315\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_fundstype\n \n \n \n \n 409\n 0\n 110\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n docnumber\n \n \n \n \n 229\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_distdate\n \n \n \n \n 41\n \n \n 670\n 5\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n detailedamount\n \n extprice\n \n \n \n 5\n 25\n 740\n 25\n 2\n \n \n \n \n \n \n detail\n \n 18\n \n \n 85\n 0\n 315\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n docnumber\n \n \n \n \n 15\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n doctype\n \n \n \n \n 540\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_detailedamount\n \n \n \n
\n \n 28\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 43\n \n \n 670\n 5\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n amount\n \n extprice\n \n \n \n \n 7\n 28\n 742\n 28\n 2\n \n \n
\n 0 2015-10-01 17:15:58.47729 187 CharacteristicsMasterList \N \n\n Characteristics Master List\n CharacteristicsMasterList\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT char_id,\n char_name,\n string_agg(source_charass, ', ') AS abbrs,\n string_agg(source_descrip, ', ') AS names,\n char_notes\n FROM char\n LEFT OUTER JOIN charuse ON char_id = charuse_char_id\n LEFT OUTER JOIN source ON charuse_target_type = source_charass GROUP BY char_id, char_name, char_notes\nORDER BY char_name;\n \n \n 86\n \n \n \n \n 5\n 80\n 745\n 80\n 2\n \n \n \n \n \n 6\n \n \n 41\n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 17\n \n \n 10\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n char_name\n \n \n \n \n 425\n 0\n 320\n 13\n \n 5\n \n Arial\n 8\n bold\n \n \n \n \n detail\n char_notes\n \n \n \n \n 220\n 2\n 200\n 15\n \n 0\n \n Arial\n 8\n bold\n \n \n \n \n detail\n names\n \n \n \n
\n \n 17\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 365 CheckMultiPage \N \n\n Sample Check Format - 3 Part - MC - Remit - Multi Page\n CheckMultiPage\n Sample Check Format - 3 Part - MC - Uses primary Vendor or address with names: REMIT, Remit, or remit if one exists. Multi-Page.\n Letter\n \n 50\n 0\n 50\n 50\n \n Head\n SELECT\ncheckhead_id, checkhead_number, checkhead_for AS memo,\nformatDate(checkhead_checkdate) AS f_checkdate,\nformatMoney(checkhead_amount) AS f_amount,\nINITCAP(spellAmount(checkhead_amount, curr_id)) AS f_words,\nCASE WHEN(checkhead_void) THEN TEXT('V O I D')\n ELSE TEXT('')\nEND AS f_void,\nCASE WHEN checkhead_recip_type = 'C' THEN (SELECT cust_number\n FROM custinfo\n WHERE (cust_id=checkhead_recip_id))\n WHEN checkhead_recip_type = 'T' THEN (SELECT taxauth_code\n FROM taxauth\n WHERE (taxauth_id=checkhead_recip_id))\n WHEN checkhead_recip_type = 'V' THEN (SELECT vend_number\n FROM vendinfo\n WHERE (vend_id=checkhead_recip_id))\n ELSE 'Unknown Recipient Type'\nEND AS recip_number,\nformatAddr(CASE WHEN checkhead_recip_type = 'C' THEN\n (SELECT cntct_addr_id\n FROM cntct, custinfo\n WHERE ((cust_cntct_id=cntct_id)\n AND (cust_id=checkhead_recip_id)))\n WHEN checkhead_recip_type = 'T' THEN \n (SELECT taxauth_addr_id\n FROM taxauth\n WHERE (taxauth_id=checkhead_recip_id))\n WHEN checkhead_recip_type = 'V' THEN\n COALESCE((SELECT vendaddr_addr_id\n FROM vendaddrinfo\n WHERE ((UPPER(vendaddr_code)='REMIT')\n AND (vendaddr_vend_id=checkhead_recip_id))),\n (SELECT vend_addr_id\n FROM vendinfo\n WHERE (vend_id=checkhead_recip_id)))\n END) AS check_address,\nCASE WHEN checkhead_recip_type = 'C' THEN (SELECT cust_name\n FROM custinfo\n WHERE cust_id=checkhead_recip_id)\n WHEN checkhead_recip_type = 'T' THEN (SELECT taxauth_name\n FROM taxauth\n WHERE taxauth_id=checkhead_recip_id)\n WHEN checkhead_recip_type = 'V' THEN\n COALESCE((SELECT vendaddr_name\n FROM vendaddrinfo\n WHERE ((UPPER(vendaddr_code)='REMIT')\n AND (vendaddr_vend_id=checkhead_recip_id))),\n (SELECT vend_name\n FROM vendinfo\n WHERE (vend_id=checkhead_recip_id)))\nEND AS recip_name, \ncurr_symbol, curr_abbr, curr_name\nFROM checkhead, curr_symbol\nWHERE ((checkhead_curr_id = curr_id)\n AND (checkhead_id=<? value("checkhead_id") ?>) );\n\n \n \n CheckDetail\n SELECT checkdata_page,\n checkdata_checknumber,\n checkdata_checkwords,\n checkdata_checkdate,\n checkdata_checkamount,\n checkdata_checkcurrsymbol,\n checkdata_checkcurrabbr,\n checkdata_checkcurrname,\n checkdata_checkpayto,\n checkdata_checkaddress,\n checkdata_checkmemo,\n checkdata_docnumber,\n checkdata_docreference,\n checkdata_docdate,\n checkdata_docamount,\n checkdata_docdiscount,\n checkdata_docnetamount\n FROM checkDetailFormatted(<? value("checkhead_id") ?>, 12);\n \n
\n Check\n \n Line Detail\n checkdata_page\n \n \n 351\n \n \n 175\n 50\n 120\n 250\n \n \n Arial\n 8\n normal\n \n \n \n \n \n CheckDetail\n checkdata_docreference\n \n \n \n \n \n 555\n 50\n 80\n 250\n \n \n Arial\n 8\n normal\n \n \n \n \n \n CheckDetail\n checkdata_docdiscount\n \n \n \n \n 85\n 325\n 660\n 20\n \n \n Arial\n 8\n normal\n \n \n \n \n Head\n memo\n \n \n \n \n 645\n 50\n 100\n 250\n \n \n Arial\n 8\n normal\n \n \n \n \n \n CheckDetail\n checkdata_docnetamount\n \n \n \n \n 305\n 25\n 147\n 20\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n \n 5\n 50\n 155\n 250\n \n \n Arial\n 8\n normal\n \n \n \n \n \n CheckDetail\n checkdata_docnumber\n \n \n \n \n 145\n 0\n 175\n 25\n \n \n Arial\n 8\n normal\n \n \n \n \n Head\n recip_name\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n 450\n 305\n 745\n 305\n 0\n \n \n \n 650\n 0\n 95\n 25\n \n \n Arial\n 10\n normal\n \n \n \n \n Head\n checkhead_number\n \n \n \n \n 640\n 305\n 104\n 20\n \n \n Arial\n 8\n normal\n \n \n \n \n Head\n f_amount\n \n \n \n \n 444\n 50\n 100\n 250\n \n \n Arial\n 8\n normal\n \n \n \n \n \n CheckDetail\n checkdata_docamount\n \n \n \n \n 10\n 0\n 135\n 25\n \n \n Arial\n 8\n normal\n \n \n \n \n Head\n recip_number\n \n \n \n \n 580\n 305\n 55\n 20\n \n \n Arial\n 8\n normal\n \n \n \n \n Head\n curr_symbol\n \n \n \n \n 310\n 50\n 100\n 250\n \n \n Arial\n 8\n normal\n \n \n \n \n \n CheckDetail\n checkdata_docdate\n \n \n \n \n \n \n \n \n 351\n \n \n 645\n 0\n 95\n 25\n \n \n Arial\n 10\n normal\n \n \n \n \n Head\n checkhead_number\n \n \n \n \n 5\n 50\n 155\n 250\n \n \n Arial\n 8\n normal\n \n \n \n \n \n CheckDetail\n checkdata_docnumber\n \n \n \n \n 550\n 50\n 80\n 250\n \n \n Arial\n 8\n normal\n \n \n \n \n \n CheckDetail\n checkdata_docdiscount\n \n \n \n \n \n \n \n 445\n 305\n 740\n 305\n 0\n \n \n \n 170\n 50\n 120\n 250\n \n \n Arial\n 8\n normal\n \n \n \n \n \n CheckDetail\n checkdata_docreference\n \n \n \n \n 440\n 50\n 100\n 250\n \n \n Arial\n 8\n normal\n \n \n \n \n \n CheckDetail\n checkdata_docamount\n \n \n \n \n \n 80\n 325\n 660\n 20\n \n \n Arial\n 8\n normal\n \n \n \n \n Head\n memo\n \n \n \n \n \n 575\n 305\n 55\n 20\n \n \n Arial\n 8\n normal\n \n \n \n \n Head\n curr_symbol\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 300\n 25\n 147\n 20\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 140\n 0\n 175\n 25\n \n \n Arial\n 8\n normal\n \n \n \n \n Head\n recip_name\n \n \n \n \n 640\n 50\n 100\n 250\n \n \n Arial\n 8\n normal\n \n \n \n \n \n CheckDetail\n checkdata_docnetamount\n \n \n \n \n 305\n 50\n 100\n 250\n \n \n Arial\n 8\n normal\n \n \n \n \n \n CheckDetail\n checkdata_docdate\n \n \n \n \n \n \n 635\n 305\n 104\n 20\n \n \n Arial\n 8\n normal\n \n \n \n \n Head\n f_amount\n \n \n \n \n 5\n 0\n 135\n 25\n \n \n Arial\n 8\n normal\n \n \n \n \n Head\n recip_number\n \n \n \n \n \n \n CheckDetail\n \n 292\n \n \n 10\n 100\n 225\n 25\n \n \n Arial\n 10\n normal\n \n \n \n \n CheckDetail\n checkdata_checkpayto\n \n \n \n \n 15\n 40\n 560\n 30\n \n \n Arial\n 12\n normal\n \n \n \n \n CheckDetail\n checkdata_checkwords\n \n \n \n \n 405\n 85\n 121\n 25\n \n \n Arial\n 10\n normal\n \n \n \n \n CheckDetail\n checkdata_checkdate\n \n \n \n \n 80\n 260\n 650\n 20\n \n \n Arial\n 8\n normal\n \n \n \n \n CheckDetail\n checkdata_checkmemo\n \n \n \n \n \n 10\n 125\n 300\n 20\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n CheckDetail\n checkdata_checkaddress\n \n \n \n \n 545\n 85\n 55\n 25\n \n \n Arial\n 10\n normal\n \n \n \n \n CheckDetail\n checkdata_checkcurrsymbol\n \n \n \n \n 600\n 85\n 125\n 25\n \n \n Arial\n 10\n normal\n \n \n \n \n CheckDetail\n checkdata_checkamount\n \n \n \n
\n
\n Sample Check Format - 3 Part - MC - Uses primary Vendor or address with names: REMIT, Remit, or remit if one exists. Multi-Page. 0 2015-10-01 17:15:58.47729 277 CheckRegister \N \n\n Payment Register\n CheckRegister\n \n \n \n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT bankaccnt_name,\n bankaccnt_descrip,\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n curr_symbol\n FROM bankaccnt, curr_symbol\n WHERE ((bankaccnt_id=<? value("bankaccnt_id") ?>)\n AND (bankaccnt_curr_id = curr_id));\n \n \n detail\n SELECT checkhead_id AS checkid,\n CASE WHEN(checkhead_void) THEN -1\n WHEN(checkhead_posted) THEN 1\n ELSE 0\n END AS extra,\n -1 AS checkitem_id,\n formatBoolYN(checkhead_void) AS f_void,\n formatBoolYN(checkhead_misc) AS f_misc,\n formatBoolYN(checkhead_printed) AS f_printed,\n formatBoolYN(checkhead_posted) AS f_posted,\n CASE when checkhead_number = -1 THEN\n 'Unspecified'\n ELSE TEXT(checkhead_number) END AS number,\n COALESCE(checkrecip_number || '-' || checkrecip_name,\n\t\tcheckhead_recip_type || '-' || checkhead_recip_id ) AS description,\n formatDate(checkhead_checkdate) AS f_checkdate,\n formatMoney(checkhead_amount) AS f_amount, \n currConcat(checkhead_curr_id) AS currAbbr,\n checkhead_number,\n checkhead_ach_batch,\n 1 AS orderby\n FROM checkhead LEFT OUTER JOIN\n checkrecip ON ((checkhead_recip_id=checkrecip_id)\n\t\t AND (checkhead_recip_type=checkrecip_type))\n WHERE ((checkhead_checkdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n AND (checkhead_bankaccnt_id=<? value("bankaccnt_id") ?>)\n <? if exists("check_number") ?>\n AND (CAST(checkhead_number AS text) ~ <? value("check_number") ?>)\n <? endif ?>\n <? if exists("recip") ?>\n <? if exists("recip_type_v") ?>\n\t AND (checkhead_recip_type = 'V' )\n <? endif ?>\n <? if exists("recip_type_c") ?>\n\t AND (checkhead_recip_type = 'C' )\n <? endif ?>\n <? if exists("recip_type_t") ?>\n\t AND (checkhead_recip_type = 'T' )\n <? endif ?>\n <? if exists("recip_id") ?>\n\t AND (checkhead_recip_id = <? value("recip_id") ?> )\n <? endif ?>\n <? endif ?> \n )\n<? if exists("showDetail") ?>\nUNION\nSELECT checkitem_checkhead_id AS checkid, 0 AS extra, checkitem_id,\n '' AS f_void, '' AS f_misc, '' AS f_printed, '' AS f_posted,\n checkitem_vouchernumber AS number,\n checkitem_invcnumber AS description,\n '' AS f_checkdate,\n formatMoney(checkitem_amount) AS f_amount,\n currConcat(checkitem_curr_id) AS currAbbr, \n checkhead_number, \n NULL,\n 2 AS orderby \n FROM checkitem, checkhead \n WHERE ( (checkitem_checkhead_id=checkhead_id)\n AND (checkhead_checkdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n AND (checkhead_bankaccnt_id=<? value("bankaccnt_id") ?>)\n <? if exists("check_number") ?>\n AND (CAST(checkhead_number AS text) ~ <? value("check_number") ?>)\n <? endif ?>\n <? if exists("recip") ?>\n <? if exists("recip_type_v") ?>\n AND (checkhead_recip_type = 'V' )\n <? endif ?>\n <? if exists("recip_type_c") ?>\n AND (checkhead_recip_type = 'C' )\n <? endif ?>\n <? if exists("recip_type_t") ?>\n AND (checkhead_recip_type = 'T' )\n <? endif ?>\n <? if exists("recip_id") ?>\n AND (checkhead_recip_id = <? value("recip_id") ?> )\n <? endif ?>\n <? endif ?> )\n<? endif ?>\n ORDER BY checkhead_number, checkid, orderby;\n \n \n total\n SELECT formatMoney(SUM(currToCurr(checkhead_curr_id, bankaccnt_curr_id, checkhead_amount, checkhead_checkdate))) AS f_amount,\n currConcat(bankaccnt_curr_id) AS currAbbr\n FROM checkhead, checkrecip, bankaccnt\n WHERE ( (checkhead_recip_id=checkrecip_id)\n AND (checkhead_recip_type=checkrecip_type)\n AND (NOT checkhead_void)\n AND (checkhead_checkdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n AND (checkhead_bankaccnt_id=bankaccnt_id)\n AND (checkhead_bankaccnt_id=<? value("bankaccnt_id") ?>)\n <? if exists("check_number") ?>\n AND (CAST(checkhead_number AS text) ~ <? value("check_number") ?>)\n <? endif ?>\n <? if exists("recip") ?>\n <? if exists("recip_type_v") ?>\n AND (checkhead_recip_type = 'V' )\n <? endif ?>\n <? if exists("recip_type_c") ?>\n AND (checkhead_recip_type = 'C' )\n <? endif ?>\n <? if exists("recip_type_t") ?>\n AND (checkhead_recip_type = 'T' )\n <? endif ?>\n <? if exists("recip_id") ?>\n AND (checkhead_recip_id = <? value("recip_id") ?> )\n <? endif ?>\n <? endif ?> )\nGROUP BY bankaccnt_curr_id;\n \n \n 168\n \n \n 550\n 65\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n 140\n 65\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n bankaccnt_name\n \n \n \n \n \n \n 550\n 85\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n 140\n 85\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n bankaccnt_descrip\n \n \n \n \n \n 5\n 155\n 745\n 155\n 2\n \n \n \n \n \n \n \n \n \n \n 12\n \n \n 28\n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 31\n \n \n 111\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_printed\n \n \n \n \n 560\n 0\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_checkdate\n \n \n \n \n 170\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_posted\n \n \n \n \n 5\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_void\n \n \n \n \n 330\n 0\n 225\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n description\n \n \n \n \n 225\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n checkhead_ach_batch\n \n \n \n \n 225\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n number\n \n \n \n \n 750\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n currAbbr\n \n \n \n \n 60\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_misc\n \n \n \n \n 655\n 0\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_amount\n \n \n \n
\n \n 28\n \n \n \n 101\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 28\n \n 565\n 0\n 745\n 0\n 0\n \n \n \n 750\n 0\n 35\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n curr_symbol\n \n \n \n \n 655\n 0\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n total\n f_amount\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 43 ClassCodesMasterList \N \n\n Class Codes Master List\n ClassCodesMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n select classcode_code, classcode_descrip\n from classcode\norder by classcode_code;\n \n \n 76\n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n \n 6\n \n \n 21\n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n
\n detail\n \n \n detail\n \n \n 16\n \n \n 10\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n classcode_code\n \n \n \n \n 175\n 0\n 565\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n classcode_descrip\n \n \n \n
\n \n 16\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 477 Contracts \N \n\n Contracts\n Contracts\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n contracts\n detail\n \n \n 76\n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n \n \n \n \n \n \n 6\n \n \n 21\n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 22\n \n \n 10\n 2\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_number\n \n \n \n \n 90\n 2\n 135\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_name\n \n \n \n \n 235\n 2\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n contrct_number\n \n \n \n \n 320\n 2\n 135\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n contrct_descrip\n \n \n \n \n 470\n 2\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n contrct_effective\n \n \n \n \n 565\n 2\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n contrct_expires\n \n \n \n \n 655\n 2\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_count\n \n \n \n
\n \n 25\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 32 CostCategoriesMasterList \N \n\n Cost Categories Master List\n CostCategoriesMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT costcat_code, costcat_descrip,\n CASE WHEN (costcat_asset_accnt_id IS NOT NULL) THEN formatGlAccountLong(costcat_asset_accnt_id) ELSE '' END AS asset,\n CASE WHEN (costcat_wip_accnt_id IS NOT NULL) THEN formatGlAccountLong(costcat_wip_accnt_id) ELSE '' END AS wip,\n CASE WHEN (costcat_invcost_accnt_id IS NOT NULL) THEN formatGlAccountLong(costcat_invcost_accnt_id) ELSE '' END AS invcost,\n CASE WHEN (costcat_purchprice_accnt_id IS NOT NULL) THEN formatGlAccountLong(costcat_purchprice_accnt_id) ELSE '' END AS purchprice,\n CASE WHEN (costcat_adjustment_accnt_id IS NOT NULL) THEN formatGlAccountLong(costcat_adjustment_accnt_id) ELSE '' END AS adjustment,\n CASE WHEN (costcat_scrap_accnt_id IS NOT NULL) THEN formatGlAccountLong(costcat_scrap_accnt_id) ELSE '' END AS scrap,\n CASE WHEN fetchMetricBool('Routings') THEN 'Labor and Overhead Costs:' ELSE '' END AS laboroverheadLit,\n CASE WHEN (fetchMetricBool('Routings') AND\n costcat_laboroverhead_accnt_id IS NOT NULL) THEN formatGlAccountLong(costcat_laboroverhead_accnt_id) ELSE '' END AS laboroverhead,\n CASE WHEN (costcat_liability_accnt_id IS NOT NULL) THEN formatGlAccountLong(costcat_liability_accnt_id) ELSE '' END AS liability,\n CASE WHEN fetchMetricBool('MultiWhs') THEN 'Transfer Order Liability Clearing:' ELSE '' END AS toliabilityLit,\n CASE WHEN (fetchMetricBool('MultiWhs') AND\n costcat_toliability_accnt_id IS NOT NULL) THEN formatGlAccountLong(costcat_toliability_accnt_id) ELSE '' END AS toliability,\n CASE WHEN fetchMetricBool('Transforms') THEN 'Transform Clearing:' ELSE '' END AS transformLit,\n CASE WHEN (fetchMetricBool('Transforms') AND\n costcat_transform_accnt_id IS NOT NULL) THEN formatGlAccountLong(costcat_transform_accnt_id) ELSE '' END AS transform\n FROM costcat\nORDER BY costcat_code;\n \n \n 61\n \n \n 5\n 55\n 745\n 55\n 2\n \n \n
\n detail\n \n \n detail\n \n 161\n \n \n 415\n 55\n 160\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n transformLit\n \n \n \n \n 575\n 55\n 250\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n transform\n \n \n \n \n \n 165\n 55\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n wip\n \n \n \n \n 575\n 70\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n toliability\n \n \n \n \n 415\n 70\n 160\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n toliabilityLit\n \n \n \n \n 165\n 100\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n adjustment\n \n \n \n \n \n 120\n 20\n 600\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n costcat_descrip\n \n \n \n \n 165\n 131\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n liability\n \n \n \n \n 165\n 40\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n asset\n \n \n \n \n 20\n 150\n 760\n 150\n 0\n \n \n \n 120\n 5\n 600\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n costcat_code\n \n \n \n \n 415\n 40\n 160\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n laboroverheadLit\n \n \n \n \n 165\n 84\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n purchprice\n \n \n \n \n \n 575\n 40\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n laboroverhead\n \n \n \n \n 165\n 70\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n invcost\n \n \n \n \n \n 165\n 115\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n scrap\n \n \n \n \n \n \n \n
\n \n 15\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 189 CostedIndentedBOM \N \n\n Costed Indented Bill of Materials\n CostedIndentedBOM\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n uom_name AS item_invuom,\n item_descrip1,\n item_descrip2,\n <? if exists("useActualCosts") ?>\n text('Using Actual Costs') AS lbl_usecosts,\n (SELECT formatCost(SUM(bomdata_actextendedcost))\n FROM indentedbom(<? value("item_id") ?>,<? value("revision_id") ?>,0,0)\n WHERE (bomdata_bomwork_level=1)) as t_extendedcost,\n <? else ?>\n text('Using Standard Costs') AS lbl_usecosts,\n (SELECT formatCost(SUM(bomdata_stdextendedcost))\n FROM indentedbom(<? value("item_id") ?>,<? value("revision_id") ?>,0,0)\n WHERE (bomdata_bomwork_level=1)) as t_extendedcost,\n <? endif ?>\n formatCost(actcost(item_id)) AS f_actual,\n formatCost(stdcost(item_id)) AS f_standard\n FROM item JOIN uom ON (uom_id=item_inv_uom_id)\n WHERE (item_id=<? value("item_id") ?>);\n \n \n \n detail\n select (REPEAT(' ',(bomdata_bomwork_level-1)*3) || bomdata_bomwork_seqnumber) AS f_seqnumber,\n 1 AS seq_ord,\n bomdata_item_number AS item_number,\n bomdata_uom_name AS item_invuom,\n bomdata_item_descrip1 AS item_descrip1,\n bomdata_item_descrip2 AS item_descrip2,\n bomdata_createchild as createchild,\n bomdata_issuemethod AS issuemethod,\n formatQtyPer(bomdata_qtyreq) AS qtyreq,\n formatScrap(bomdata_scrap) AS scrap,\n CASE WHEN COALESCE(bomdata_effective, startOfTime()) <= startOfTime() THEN\n <? value("always") ?> \n ELSE formatDate(bomdata_effective)\n END AS effective,\n CASE WHEN COALESCE(bomdata_expires, endOfTime()) <= endOfTime() THEN\n <? value("never") ?>\n ELSE formatDate(bomdata_expires)\n END AS expires,\n<? if exists("useActualCosts") ?>\n formatCost(bomdata_actunitcost) AS f_unitcost,\n formatCost(bomdata_actextendedcost) AS f_extendedcost,\n CASE WHEN(bomdata_bomwork_parent_id=-1) THEN bomdata_actextendedcost\n ELSE 0\n END AS extendedcost,\n<? else ?>\n formatCost(bomdata_stdunitcost) AS f_unitcost,\n formatCost(bomdata_stdextendedcost) AS f_extendedcost,\n CASE WHEN(bomdata_bomwork_parent_id=-1) THEN bomdata_stdextendedcost\n ELSE 0\n END AS extendedcost,\n<? endif ?>\n bomdata_bomwork_level\nFROM indentedBOM(<? value("item_id") ?>,<? value("revision_id") ?>,0,0);\n\n \n \n bomhead\n SELECT bomhead_docnum, bomhead_revision,\nformatDate(bomhead_revisiondate) AS f_revisiondate\nFROM bomhead\nWHERE ((bomhead_item_id=<? value("item_id") ?>)\nAND (bomhead_rev_id=<? value("revision_id") ?>));\n \n \n 242\n \n \n \n 100\n 104\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n \n 5\n 235\n 745\n 235\n 2\n \n \n \n 585\n 104\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n bomhead_docnum\n \n \n \n \n \n \n 100\n 145\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n \n \n 585\n 145\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n bomhead_revision\n \n \n \n \n \n \n 315\n 104\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_invuom\n \n \n \n \n \n \n 350\n 60\n 205\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n lbl_usecosts\n \n \n \n \n \n \n 100\n 125\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n \n \n 585\n 125\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n f_revisiondate\n \n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 52\n \n \n 500\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n effective\n \n \n \n \n 114\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 114\n 15\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 5\n 0\n 104\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_seqnumber\n \n \n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n expires\n \n \n \n \n 665\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_extendedcost\n \n \n \n \n 340\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyreq\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 275\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_invuom\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_unitcost\n \n \n \n \n 419\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n scrap\n \n \n \n \n 580\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n issuemethod\n \n \n \n \n 500\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n createchild\n \n \n \n \n 114\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n
\n \n 18\n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 47\n \n \n \n 665\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_actual\n \n \n \n \n 665\n 30\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_standard\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n t_extendedcost\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 34 CountSlipEditList \N \n\n Count Slip Edit List\n CountSlipEditList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n item_descrip1,\n item_descrip2,\n warehous_code as warehouse,\n invcnt_tagnumber\n FROM item, itemsite, invcnt, whsinfo\n WHERE ((itemsite_item_id=item_id)\n AND (invcnt_itemsite_id=itemsite_id)\n AND (invcnt_id=<? value("cnttag_id") ?>)\n AND (itemsite_warehous_id=warehous_id) );\n\n \n \n detail\n SELECT cntslip_username AS f_username,\n cntslip_number,\n formatBoolYN(cntslip_posted) AS f_posted,\n formatDateTime(cntslip_entered) AS f_entered,\n formatQty(cntslip_qty) AS f_qty\n FROM cntslip\n WHERE (cntslip_cnttag_id=<? value("cnttag_id") ?>)\nORDER BY cntslip_number;\n \n \n 221\n \n \n \n \n \n \n 100\n 95\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n 100\n 135\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n \n 100\n 75\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n invcnt_tagnumber\n \n \n \n \n \n \n \n 100\n 114\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n 100\n 155\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 165\n 0\n 275\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cntslip_number\n \n \n \n \n 540\n 0\n 114\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_entered\n \n \n \n \n 455\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_posted\n \n \n \n \n 665\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qty\n \n \n \n \n 50\n 0\n 105\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_username\n \n \n \n
\n \n 16\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 37 CountTagsByItem \N \n\n Count Tags By Item\n CountTagsByItem\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n item_descrip1,\n item_descrip2,\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse\n FROM item\n WHERE (item_id=<? value("item_id") ?>);\n\n \n \n detail\n SELECT invcnt_tagnumber, warehous_code,\n formatDate(invcnt_tagdate) AS createddate,\n invcnt_tag_username AS createdby,\n CASE WHEN (invcnt_cntdate IS NULL) THEN ''\n ELSE formatDate(invcnt_cntdate)\n END AS entereddate,\n CASE WHEN (invcnt_cntdate IS NULL) THEN ''\n ELSE invcnt_cnt_username\n END AS enteredby,\n CASE WHEN (NOT invcnt_posted) THEN ''\n ELSE formatDate(invcnt_postdate)\n END AS posteddate,\n CASE WHEN (NOT invcnt_posted) THEN ''\n ELSE invcnt_post_username\n END AS postedby,\n CASE WHEN (NOT invcnt_posted) THEN ''\n ELSE formatQty(invcnt_qoh_before)\n END AS qohbefore,\n CASE WHEN (invcnt_qoh_after IS NULL) THEN ''\n ELSE formatQty(invcnt_qoh_after)\n END AS qohafter,\n CASE WHEN (NOT invcnt_posted) THEN ''\n ELSE formatQty(invcnt_qoh_after - invcnt_qoh_before)\n END AS variance,\n CASE WHEN (NOT invcnt_posted) THEN ''\n WHEN (invcnt_qoh_before=0) THEN formatScrap(1)\n ELSE formatScrap((1 - (invcnt_qoh_after / invcnt_qoh_before)) * -1)\n END AS percentage\n FROM invcnt, itemsite, whsinfo\n WHERE ((invcnt_itemsite_id=itemsite_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (itemsite_item_id=<? value("item_id") ?>)\n AND (invcnt_tagdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if not exists("showUnposted") ?>\n AND (invcnt_posted)\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n)\nORDER BY invcnt_tagdate;\n \n \n 236\n \n \n \n \n \n 515\n 80\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n \n 100\n 120\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n 5\n 229\n 740\n 229\n 2\n \n \n \n \n 100\n 145\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n 515\n 100\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n 100\n 80\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n \n \n 100\n 100\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n 5\n 30\n 740\n 30\n 2\n \n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 41\n \n 5\n 35\n 740\n 35\n 0\n \n \n \n 409\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qohbefore\n \n \n \n \n 50\n 0\n 105\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n invcnt_tagnumber\n \n \n \n \n 245\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n enteredby\n \n \n \n \n 165\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n createddate\n \n \n \n \n 325\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n posteddate\n \n \n \n \n 495\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qohafter\n \n \n \n \n 10\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 665\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n percentage\n \n \n \n \n 165\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n createdby\n \n \n \n \n 325\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n postedby\n \n \n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n variance\n \n \n \n \n 245\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n entereddate\n \n \n \n
\n \n 16\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 38 CountTagsByWarehouse \N \n\n Count Tags By Site\n CountTagsByWarehouse\n With Barcoded Count Tag\n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse;\n \n \n detail\n SELECT invcnt_id,\n formatcounttagbarcode(invcnt_id) AS countag_barcode, \n invcnt_tagnumber, \n warehous_code,\n item_number, item_descrip1, item_descrip2,\n formatDate(invcnt_tagdate) AS createddate,\n invcnt_tag_username AS createdby,\n CASE WHEN (invcnt_cntdate IS NULL) THEN ''\n ELSE formatDate(invcnt_cntdate)\n END AS entereddate,\n CASE WHEN (invcnt_cntdate IS NULL) THEN ''\n ELSE invcnt_cnt_username\n END AS enteredby,\n CASE WHEN (NOT invcnt_posted) THEN ''\n ELSE formatDate(invcnt_postdate)\n END AS posteddate,\n CASE WHEN (NOT invcnt_posted) THEN ''\n ELSE invcnt_post_username\n END AS postedby,\n CASE WHEN (NOT invcnt_posted) THEN ''\n ELSE formatQty(invcnt_qoh_before)\n END AS qohbefore,\n CASE WHEN (invcnt_qoh_after IS NULL) THEN ''\n ELSE formatQty(invcnt_qoh_after)\n END AS qohafter,\n CASE WHEN (NOT invcnt_posted) THEN ''\n ELSE formatQty(invcnt_qoh_after - invcnt_qoh_before)\n END AS variance,\n CASE WHEN (NOT invcnt_posted) THEN ''\n WHEN ((invcnt_qoh_before = 0) AND (invcnt_qoh_after = 0)) THEN formatScrap(0)\n WHEN (invcnt_qoh_before=0) THEN formatScrap(1)\n ELSE formatScrap((1 - (invcnt_qoh_after / invcnt_qoh_before)) * -1)\n END AS percentage\n FROM invcnt, itemsite, item, whsinfo\n WHERE ((invcnt_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (DATE(invcnt_tagdate) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if not exists("showUnposted") ?>\n AND (invcnt_posted)\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n)\nORDER BY invcnt_tagdate;\n \n \n 246\n \n \n \n \n \n \n \n \n 100\n 100\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n 494\n 120\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n \n 494\n 100\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n \n \n 5\n 235\n 745\n 235\n 2\n \n \n \n \n \n \n \n \n \n 12\n \n \n 71\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 5\n 60\n 745\n 60\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 113\n \n \n 419\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n createdby\n \n \n \n \n 45\n 0\n 225\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 419\n 45\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qohbefore\n \n \n \n \n 419\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n createddate\n \n \n \n \n 5\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 5\n 40\n 225\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 590\n 45\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n variance\n \n \n \n \n 300\n 70\n 370\n 30\n \n 128\n 12\n \n \n detail\n countag_barcode\n \n \n \n \n 505\n 45\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qohafter\n \n \n \n \n 295\n 0\n 104\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n invcnt_tagnumber\n \n \n \n 15\n 105\n 750\n 105\n 0\n \n \n \n 505\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n entereddate\n \n \n \n \n 590\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n posteddate\n \n \n \n \n 675\n 45\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n percentage\n \n \n \n \n 505\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n enteredby\n \n \n \n \n 590\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n postedby\n \n \n \n \n 5\n 25\n 225\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n
\n \n 24\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n With Barcoded Count Tag 0 2015-10-01 17:15:58.47729 3 CreditMemo \N \n\n Return\n CreditMemo\n Sales Module Return with Logo and CM Currency\n \n \n select cmhead_id, cmhead_number from cmhead;\n \n Letter\n \n 28\n 28\n 0\n 0\n \n GroupHead\n SELECT remitto.*,\n cmhead_number,\n formatDate(cmhead_docdate) AS docdate,\n cust_number,\n cust_name,\n formatAddr(cmhead_billtoaddress1, cmhead_billtoaddress2, cmhead_billtoaddress3,\n COALESCE(cmhead_billtocity,'') || ' ' || COALESCE(cmhead_billtostate,'') || ' ' || COALESCE(cmhead_billtozip,''),\n cmhead_billtocountry)\n AS f_custaddr,\n cntct_phone AS cust_phone,\n cmhead_shipto_name,\n formatAddr(cmhead_shipto_address1, cmhead_shipto_address2, cmhead_shipto_address3,\n COALESCE(cmhead_shipto_city,'') ||' '|| COALESCE(cmhead_shipto_state,'') || ' '|| COALESCE(cmhead_shipto_zipcode,''),\n cmhead_shipto_country)\n AS f_shiptoaddr,\n CASE \n WHEN (cmhead_invcnumber='-1') THEN ''\n --note: must now set explicit type for Postgres 8.3+\n --add ' '\n ELSE text(cmhead_invcnumber)\n END AS invcnumber,\n cmhead_custponumber,\n cmhead_comments,\n cmhead_misc_descrip,\n curr_symbol,\n curr_name\n FROM remitto, cmhead, curr_symbol, custinfo\n LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n WHERE ((cmhead_cust_id=cust_id)\n AND (cmhead_curr_id = curr_id)\n AND (cmhead_id=<? value("cmhead_id") ?>))\nORDER BY cmhead_number;\n \n \n Detail\n SELECT cmitem_linenumber,\n formatQty(cmitem_qtycredit) AS qtycredit,\n formatQty(cmitem_qtyreturned) AS qtyreturned,\n uom_name,\n item_number,\n item_descrip1,\n item_descrip2,\n formatSalesPrice(cmitem_unitprice) AS unitprice,\n formatMoney((cmitem_qtycredit * cmitem_qty_invuomratio) * (cmitem_unitprice / cmitem_price_invuomratio)) AS extprice,\n cmitem_comments\n FROM cmitem, itemsite, item, uom\n WHERE ((cmitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (cmitem_cmhead_id=<? value("cmhead_id") ?>))\nORDER BY cmitem_linenumber;\n \n \n GroupFoot\n SELECT formatExtPrice(SUM((cmitem_qtycredit * cmitem_qty_invuomratio) * cmitem_unitprice / cmitem_price_invuomratio)) AS extprice\n FROM cmhead, cmitem, itemsite, item\n WHERE ((cmitem_cmhead_id=cmhead_id)\n AND (cmitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (cmhead_id=<? value("cmhead_id") ?>));\n \n \n GroupExtended\n SELECT formatExtPrice( COALESCE(cmhead_freight,0.0) +\n ( SELECT COALESCE(SUM(tax * -1.0), 0)\n FROM ( SELECT ROUND(SUM(taxdetail_tax), 2) AS tax\n FROM tax JOIN calculateTaxDetailSummary('CM', cmhead_id, 'T')\n ON (taxdetail_tax_id=tax_id)\n GROUP BY tax_id ) AS data ) +\n COALESCE(cmhead_misc,0.0) +\n ( SELECT COALESCE(SUM((cmitem_qtycredit * cmitem_qty_invuomratio) *\n cmitem_unitprice / cmitem_price_invuomratio), 0.0)\n FROM cmitem\n WHERE (cmitem_cmhead_id=<? value("cmhead_id") ?>) ) \n ) AS totaldue,\n formatExtPrice(COALESCE(cmhead_freight,0.0)) AS freight,\n ( SELECT formatExtPrice(COALESCE(SUM(tax * -1.0), 0))\n FROM ( SELECT ROUND(SUM(taxdetail_tax), 2) AS tax\n FROM tax JOIN calculateTaxDetailSummary('CM', cmhead_id, 'T')\n ON (taxdetail_tax_id=tax_id)\n GROUP BY tax_id ) AS data ) AS tax,\n formatExtPrice(COALESCE(cmhead_misc,0.0)) AS misc\n FROM cmhead\n WHERE (cmhead_id=<? value("cmhead_id") ?>);\n\n \n \n logo\n SELECT image_data \nFROM image \nWHERE ((image_name='logo'));\n \n \n \n 451\n \n \n 50\n 370\n 120\n 20\n \n \n helvetica\n 12\n normal\n \n \n \n \n GroupHead\n cmhead_custponumber\n \n \n \n \n \n \n 660\n 130\n 135\n 20\n \n \n Helvetica\n 10\n normal\n \n \n \n \n GroupHead\n docdate\n \n \n \n 50\n 340\n 800\n 340\n 2\n \n \n \n \n \n 660\n 110\n 145\n 20\n \n \n Helvetica\n 10\n normal\n \n \n \n \n GroupHead\n cmhead_number\n \n \n \n \n 100\n 205\n 290\n 20\n \n \n Helvetica\n 12\n normal\n \n \n \n \n GroupHead\n cust_name\n \n \n \n 50\n 445\n 800\n 445\n 2\n \n \n \n \n 390\n 370\n 50\n 20\n \n \n helvetica\n 12\n normal\n \n \n \n \n GroupHead\n curr_symbol\n \n \n \n \n 50\n 80\n 260\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n GroupHead\n remitto_country\n \n \n \n \n 100\n 225\n 315\n 15\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n GroupHead\n f_custaddr\n \n \n \n \n \n \n 185\n 370\n 230\n 20\n \n \n helvetica\n 12\n normal\n \n \n \n \n GroupHead\n docdate\n \n \n \n \n 485\n 205\n 300\n 20\n \n \n Helvetica\n 12\n normal\n \n \n \n \n GroupHead\n cmhead_shipto_name\n \n \n \n \n \n \n 444\n 370\n 110\n 20\n \n \n helvetica\n 12\n normal\n \n \n \n \n GroupHead\n curr_name\n \n \n \n \n 50\n 95\n 200\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n GroupHead\n remitto_phone\n \n \n \n \n \n \n 50\n 50\n 200\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n GroupHead\n remitto_address1\n \n \n \n \n 485\n 225\n 315\n 15\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n GroupHead\n f_shiptoaddr\n \n \n \n \n 270\n 0\n 355\n 111\n \n stretch\n \n logo\n image_data\n \n \n \n \n \n 660\n 150\n 180\n 20\n \n \n Helvetica\n 10\n normal\n \n \n \n \n GroupHead\n cust_number\n \n \n \n \n 50\n 30\n 200\n 20\n \n \n Helvetica\n 10\n bold\n \n \n \n \n GroupHead\n remitto_name\n \n \n \n \n \n \n 50\n 65\n 260\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n GroupHead\n remitto_citystatezip\n \n \n \n \n \n \n \n 660\n 170\n 150\n 20\n \n \n Helvetica\n 10\n normal\n \n \n \n \n GroupHead\n invcnumber\n \n \n \n
\n detail\n \n \n Detail\n \n 82\n \n \n 160\n 55\n 600\n 17\n \n 14\n \n helvetica\n 10\n normal\n \n \n \n \n Detail\n cmitem_comments\n \n \n \n \n \n 670\n 5\n 100\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n Detail\n extprice\n \n \n \n \n 50\n 25\n 120\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n Detail\n qtycredit\n \n \n \n \n 260\n 5\n 300\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n Detail\n item_number\n \n \n \n \n 175\n 5\n 80\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n Detail\n uom_name\n \n \n \n \n 260\n 25\n 300\n 15\n \n \n helvetica\n 8\n normal\n \n \n \n \n Detail\n item_descrip1\n \n \n \n \n 520\n 5\n 100\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n Detail\n unitprice\n \n \n \n \n 260\n 40\n 300\n 15\n \n \n helvetica\n 8\n normal\n \n \n \n \n Detail\n item_descrip2\n \n \n \n \n 50\n 5\n 120\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n Detail\n qtyreturned\n \n \n \n
\n \n \n 144\n \n \n \n 670\n 5\n 100\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n GroupFoot\n extprice\n \n \n \n \n 60\n 55\n 515\n 17\n \n 14\n \n helvetica\n 10\n normal\n \n \n \n \n GroupHead\n cmhead_comments\n \n \n \n \n \n 670\n 65\n 100\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n GroupExtended\n tax\n \n \n \n \n \n 670\n 25\n 100\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n GroupExtended\n misc\n \n \n \n \n \n \n 670\n 45\n 100\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n GroupExtended\n freight\n \n \n \n \n \n 670\n 85\n 100\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n GroupExtended\n totaldue\n \n \n \n \n \n 60\n 25\n 525\n 20\n \n \n helvetica\n 10\n normal\n \n \n \n \n GroupHead\n cmhead_misc_descrip\n \n \n \n
\n Sales Module Return with Logo and CM Currency 0 2015-10-01 17:15:58.47729 264 CreditMemoEditList \N \n\n Return Edit List\n CreditMemoEditList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT orderid,\n itemid,\n documentnumber,\n CASE WHEN(documentnumber='') THEN item\n ELSE cust_number\n END AS name,\n CASE WHEN(documentnumber='') THEN itemdescrip\n ELSE billtoname\n END AS descrip,\n ordernumber,\n linenumber,\n iteminvuom,\n qtytobill,\n price,\n extprice,\n sence,\n account\n FROM creditMemoEditList\nORDER BY ordernumber, linenumber;\n \n \n 136\n \n \n \n \n \n \n \n 5\n 130\n 745\n 130\n 2\n \n \n \n \n \n \n \n \n \n 7\n \n \n 36\n \n \n \n \n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 31\n \n \n 340\n 15\n 240\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n sence\n \n \n \n \n 75\n 15\n 254\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n descrip\n \n \n \n \n 670\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n extprice\n \n \n \n \n 590\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n price\n \n \n \n \n 90\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ordernumber\n \n \n \n \n 285\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n iteminvuom\n \n \n \n \n 180\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n name\n \n \n \n \n 590\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtytobill\n \n \n \n \n 340\n 0\n 240\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n account\n \n \n \n \n 685\n 15\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shiptostate\n \n \n \n \n 5\n 0\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n documentnumber\n \n \n \n
\n \n 16\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 404 CurrencyConversionList \N \n\n Currency Exchange Rates\n CurrencyConversionList\n \n Letter\n \n 100\n 100\n 100\n 100\n \n exchangeRates\n currencyConversions\n detail\n \n \n baseCurrency\n SELECT\n\tcurr_name,\n\tcurrConcat(curr_id) AS currConcat\nFROM curr_symbol\nWHERE curr_base = TRUE;\n \n \n knownCurrencies\n SELECT\n\tcurr_name,\n\tcurrConcat(curr_id) AS currConcat,\n\tcurr_base\nFROM curr_symbol\nWHERE curr_base = FALSE\nORDER BY currConcat;\n \n \n 113\n \n \n \n 0\n 60\n 151\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n baseCurrency\n curr_name\n \n \n \n \n \n \n 150\n 60\n 116\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n baseCurrency\n currConcat\n \n \n \n
\n Known Currencies\n \n Known\n curr_base\n \n 61\n \n \n \n \n \n 0\n 50\n 407\n 50\n 2\n \n \n \n \n \n knownCurrencies\n \n 21\n \n \n 150\n 0\n 126\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n knownCurrencies\n currConcat\n \n \n \n \n 0\n 0\n 150\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n knownCurrencies\n curr_name\n \n \n \n
\n
\n Exchange Rates\n \n By Currency\n currConcat\n \n 21\n \n 409\n 10\n 5\n 10\n 0\n \n \n \n \n \n exchangeRates\n \n 21\n \n \n 0\n 0\n 96\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n exchangeRates\n f_curr\n \n \n \n \n 330\n 0\n 80\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n exchangeRates\n curr_expires\n \n \n \n \n 90\n 0\n 120\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n exchangeRates\n rate\n \n \n \n \n 230\n 0\n 90\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n exchangeRates\n curr_effective\n \n \n \n
\n \n 31\n \n \n 100\n 10\n 120\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 405 CustOrderAcknowledgement \N \n\n Customer Order Acknowledgement\n CustOrderAcknowledgement\n Customer Order Acknowledgement\n \n \n \n 0.05\n 0.05\n \n Letter\n \n 25\n 25\n 25\n 25\n \n head\n <? if not exists("shiphead_id") ?>\n--Run query if no shiphead_id passed - No Shipment Pack List\nSELECT cust_number,\n formatsobarcode(cohead_id) AS order_barcode,\n formataddr(addr_line1, addr_line2, addr_line3, (addr_city || ' ' || addr_state || ' ' || addr_postalcode), addr_country) AS corr_address,\n formataddr(cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, (cohead_billtocity || ' ' || cohead_billtostate || ' ' || cohead_billtozipcode), cohead_billtocountry) AS billing_address, \n\n formataddr(cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3, (cohead_shiptocity || ' ' || cohead_shiptostate || ' ' || cohead_shiptozipcode), cohead_shiptocountry) AS shipping_address, \n\n trim(cntct_first_name || ' ' || cntct_last_name) AS cust_contact,\n cohead_fob,\n cohead_billtoname,\n cohead_billtoaddress1,\n cohead_billtoaddress2,\n cohead_billtoaddress3,\n (cohead_billtocity || ' ' || cohead_billtostate || ' ' || cohead_billtozipcode) AS billtocitystatezip,\n cntct_phone AS cust_phone,\n cohead_shiptoname,\n cohead_shiptoaddress1,\n cohead_shiptoaddress2,\n cohead_shiptoaddress3,\n (cohead_shiptocity || ' ' || cohead_shiptostate || ' ' || cohead_shiptozipcode) AS shiptocitystatezip,\n cohead_number,\n cohead_shipvia,\n cohead_shiptophone,\n cohead_custponumber,\n formatDate(cohead_orderdate) AS orderdate,\n cohead_shipcomments, \n terms_descrip\n FROM cohead JOIN custinfo ON (cohead_cust_id=cust_id)\n JOIN terms ON (cohead_terms_id=terms_id)\n LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n WHERE (cohead_id=<? value("sohead_id") ?>);\n\n-------------------\n<? else ?>\n--Run New Query for Header with shipment number\n-----------------------------------------------\n\nSELECT shiphead_number,\n\n cohead_number,\n formatsobarcode(cohead_id) AS order_barcode,\n cohead_shipvia,\n cohead_shiptophone,\n cohead_custponumber,\n formatDate(cohead_orderdate) AS orderdate,\n cohead_shipcomments, \n cohead_billtoname,\n formataddr(cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3,\n (cohead_billtocity || ' ' || cohead_billtostate || ' ' || cohead_billtozipcode), cohead_billtocountry) AS billing_address,\n cohead_shiptoname,\n formataddr(cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3,\n (cohead_shiptocity || ' ' || cohead_shiptostate || ' ' || cohead_shiptozipcode), cohead_shiptocountry) AS shipping_address, \n\n cust_number,\n trim(cntct_first_name || ' ' || cntct_last_name) AS cust_contact,\n cntct_phone AS cust_phone,\n cohead_shipchrg_id,\n shipchrg_descrip,\n\n terms_descrip\n FROM shiphead\n JOIN cohead ON (cohead_id=shiphead_order_id)\n JOIN custinfo ON (cohead_cust_id=cust_id)\n JOIN terms ON (cohead_terms_id=terms_id)\n JOIN shipchrg ON (cohead_shipchrg_id = shipchrg_id)\n LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n WHERE (shiphead_id=<? value("shiphead_id") ?>);\n\n<? endif ?>\n \n \n scheddate\n <? if not exists("shiphead_id") ?>\n--Query without shipment number\n\nSELECT formatDate(MIN(coitem_scheddate)) AS scheddate\n FROM coitem\n WHERE ((coitem_status <> 'X') AND (coitem_cohead_id=<? value("sohead_id") ?>));\n\n--\n<? else ?>\n--------------------------\n\n\nSELECT formatDate(MIN(coitem_scheddate)) AS scheddate\n FROM coitem, shipitem\n WHERE ((coitem_status <> 'X')\n AND (coitem_id=shipitem_orderitem_id)\n AND (shipitem_shiphead_id=<? value("shiphead_id") ?>));\n\n<? endif ?>\n \n \n detail\n salesOrderItems\n list\n \n \n logo\n SELECT image_data \nFROM image \nWHERE ((image_name='logo'));\n \n \n footer\n SELECT formatMoney(calcSalesOrderAmt(cohead_id, 'S')) AS f_subtotal,\n formatMoney(calcSalesOrderAmt(cohead_id, 'T')) AS f_total,\n formatMoney(calcSalesOrderAmt(cohead_id, 'B')) AS f_balance,\n formatMoney(calcSalesOrderAmt(cohead_id, 'X')) AS f_tax,\n formatMoney(calcSalesOrderAmt(cohead_id, 'C')) AS f_credit,\n formatMoney(cohead_freight) AS f_freight,\n formatMoney(cohead_misc) AS f_misc\nFROM cohead\nWHERE (cohead_id=<? value("sohead_id") ?>)\n;\n \n \n lastupdated\n SELECT formatDate(MAX(lastupdated)) AS f_lastupdated\n FROM (SELECT cohead_lastupdated AS lastupdated\n FROM cohead\n WHERE (cohead_id=<? value("sohead_id") ?>)\n UNION\n SELECT coitem_lastupdated AS lastupdated\n FROM coitem\n WHERE (coitem_cohead_id=<? value("sohead_id") ?>) ) AS data;\n \n \n currency\n SELECT currConcat(curr_id) AS currConcat, curr_symbol\nFROM cohead, curr_symbol\nWHERE (cohead_id = <? value("sohead_id") ?>)\n AND (cohead_curr_id = curr_id);\n \n \n 426\n \n \n 6\n 7\n 426\n 115\n \n stretch\n \n logo\n image_data\n \n \n \n 210\n 330\n 330\n 330\n 0\n \n \n \n \n 40\n 335\n 145\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_custponumber\n \n \n \n \n 539\n 39\n 250\n 25\n \n \n Times New Roman\n 20\n bold\n \n \n \n \n head\n cohead_number\n \n \n \n \n 470\n 330\n 647\n 330\n 0\n \n \n \n 200\n 335\n 165\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n terms_descrip\n \n \n \n 45\n 330\n 177\n 330\n 0\n \n \n \n 355\n 335\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n scheddate\n scheddate\n \n \n \n 15\n 415\n 785\n 415\n 2\n \n \n \n \n \n \n \n 360\n 330\n 440\n 330\n 0\n \n \n \n 622\n 70\n 110\n 20\n \n \n Arial\n 12\n normal\n \n \n \n \n head\n orderdate\n \n \n \n \n 269.976\n 160.037\n 491.976\n 160.037\n 0\n \n \n \n \n 535.987\n 170.037\n 254.338\n 20\n \n \n Arial\n 11\n normal\n \n \n \n \n head\n cohead_shiptoname\n \n \n \n \n 455\n 335\n 195\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_shipvia\n \n \n \n \n \n 655\n 335\n 95\n 16\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_fob\n \n \n \n \n 270.976\n 191.037\n 256\n 22.2821\n \n 10\n \n Arial\n 11\n normal\n \n \n \n \n head\n billing_address\n \n \n \n \n \n 535.987\n 190.037\n 253.562\n 20.2425\n \n 10\n \n Arial\n 11\n normal\n \n \n \n \n head\n shipping_address\n \n \n \n \n 670\n 330\n 750\n 330\n 0\n \n \n \n \n \n \n 271.976\n 170.037\n 256\n 20\n \n \n Arial\n 11\n normal\n \n \n \n \n head\n cohead_billtoname\n \n \n \n 535.987\n 160.037\n 766.987\n 160.037\n 0\n \n \n \n 17.6809\n 192.59\n 222\n 21.011\n \n 10\n \n Arial\n 11\n normal\n \n \n \n \n head\n billing_address\n \n \n \n \n 17.6809\n 171.59\n 213\n 20\n \n \n Arial\n 11\n normal\n \n \n \n \n head\n cohead_billtoname\n \n \n \n 15.8119\n 162.124\n 224.257\n 162.137\n 0\n \n \n \n
\n detail\n \n detail\n groupby\n \n 36\n \n \n 37\n 7\n 707\n 21\n \n 14\n \n Arial\n 12\n normal\n \n \n \n \n head\n cohead_shipcomments\n \n \n \n \n \n lineitem\n coitem_linenumber\n \n 6\n \n \n \n \n detail\n \n 41\n \n \n 15\n 0\n 85\n 20\n \n \n Arial\n 9\n normal\n \n \n \n \n detail\n item_number_cust\n \n \n \n \n 600\n 5\n 27\n 17\n \n \n Arial\n 9\n normal\n \n \n \n \n detail\n qty_uom\n \n \n \n \n 515\n 0\n 65\n 20\n \n \n Arial\n 9\n normal\n \n \n \n \n detail\n f_balance\n \n \n \n \n 640\n 3\n 56\n 16\n \n \n Arial\n 9\n normal\n \n \n \n \n detail\n f_price\n \n \n \n \n 125\n 25\n 435\n 12\n \n 14\n \n Arial\n 8\n normal\n \n \n \n \n detail\n coitem_memo\n \n \n \n \n 705\n 3\n 82\n 17\n \n \n Arial\n 9\n normal\n \n \n \n \n detail\n f_extprice\n \n \n \n \n 435\n 0\n 65\n 20\n \n \n Arial\n 9\n normal\n \n \n \n \n detail\n f_qtyord\n \n \n \n \n 102\n 0\n 325\n 20\n \n \n Arial\n 9\n normal\n \n \n \n \n detail\n item_descrip1_cust\n \n \n \n
\n \n \n 233\n \n \n \n \n 670\n 28\n 97\n 16\n \n \n Arial\n 10\n normal\n \n \n \n \n footer\n f_freight\n \n \n \n \n 670\n 48\n 97\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n footer\n f_misc\n \n \n \n \n \n 605\n 133\n 172\n 32\n \n \n Arial\n 16\n bold\n \n \n \n \n footer\n f_balance\n \n \n \n \n \n 675\n 8\n 92\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n footer\n f_subtotal\n \n \n \n \n \n 670\n 68\n 97\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n footer\n f_tax\n \n \n \n \n 665\n 88\n 102\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n footer\n f_total\n \n \n \n \n \n \n 665\n 108\n 102\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n footer\n f_credit\n \n \n \n \n 635\n 48\n 30\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n currency\n curr_symbol\n \n \n \n \n 635\n 68\n 30\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n currency\n curr_symbol\n \n \n \n \n 635\n 8\n 30\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n currency\n curr_symbol\n \n \n \n \n 565\n 143\n 30\n 17\n \n \n Arial\n 14\n normal\n \n \n \n \n \n currency\n curr_symbol\n \n \n \n \n 635\n 28\n 30\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n currency\n curr_symbol\n \n \n \n \n 635\n 88\n 30\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n currency\n curr_symbol\n \n \n \n \n 635\n 108\n 30\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n currency\n curr_symbol\n \n \n \n \n 28\n \n
\n Customer Order Acknowledgement 0 2015-10-01 17:15:58.47729 330 FinancialReportMonthYear \N \n\n Financial Report Month and Year\n FinancialReportMonthYear\n \n \n Financial Report Column Layout\n SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))\n \n \n Accounting Period Reference\n SELECT period_id, \n CASE\n WHEN period_name <> '' THEN period_name \n ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n END \nFROM period \nORDER BY period_end DESC\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT \n <? value("project") ?> AS project,\n (SELECT prj_name FROM prj WHERE prj_id=<? value("prj_id") ?>) AS prj_name,\n flstmthead_username,\n flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n flstmthead_typedescrip1,\n flstmthead_typedescrip2,\n flstmthead_month,\n flstmthead_qtr,\n flstmthead_year,\n flstmthead_prmonth,\n flstmthead_prqtr,\n flstmthead_pryear\nFROM getflstmthead(<? value("flcol_id") ?>,<? value("period_id") ?>)\n \n \n detail\n SELECT \n flstmtitem_flhead_id,\n flstmtitem_period_id,\n flstmtitem_username,\n flstmtitem_order,\n flstmtitem_level,\n flstmtitem_subgrp,\n flstmtitem_type,\n flstmtitem_type_id,\n flstmtitem_parent_id,\n flstmtitem_accnt_id,\n flstmtitem_name,\n formatMoney(flstmtitem_month) AS flstmtitem_month,\n formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n formatMoney(flstmtitem_year) AS flstmtitem_year,\n formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(<? value("flcol_id") ?>,<? value("period_id") ?>,\n<? if exists("shownumbers") ?>\n true\n<? else ?>\n false\n<? endif ?>\n,True,<? value("prj_id") ?>)\n<? if not exists("showzeros") ?>\n WHERE ((flstmtitem_month <> 0) OR (flstmtitem_year <> 0) OR (flstmtitem_type <> 'I'))\n<? endif ?>\n;\n \n \n notes\n SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (flnotes_period_id=<? value("period_id") ?>)\n AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n\n \n \n 166\n \n \n 380\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n \n 660\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_year\n \n \n \n \n \n 100\n 80\n 460\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_name\n \n \n \n \n \n 2.08287\n 160\n 748\n 160\n 2\n \n \n \n 580\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_year\n \n \n \n \n 460\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n 380\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n \n 100\n 100\n 460\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n flstmthead_typedescrip1\n \n \n \n \n 580\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n \n 99\n 59.6\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n prj_name\n \n \n \n \n 15\n 59.5\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n project\n \n \n \n \n \n 3\n \n \n 36\n \n \n 460\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n \n 580\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 380\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 660\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_year\n \n \n \n \n 380\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_year\n \n \n \n 1.43183\n 30.3326\n 748.17\n 30.3326\n 2\n \n \n \n \n
\n detail\n \n subgrp\n flstmtitem_subgrp\n \n 3\n \n 380\n 1\n 740\n 1\n 0\n \n \n \n \n \n detail\n \n 18\n \n \n 660\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_yearprcnt\n \n \n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_year\n \n \n \n \n 380\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_month\n \n \n \n \n 25\n 0\n 345\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_name\n \n \n \n \n 460\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_monthprcnt\n \n \n \n
\n
\n notes\n \n \n notes\n \n 24\n \n \n 25\n 9\n 700\n 15\n \n 0\n \n Arial\n 9\n normal\n \n \n \n \n notes\n notes\n \n \n \n
\n \n 21\n \n \n 695\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 6\n \n
\n 0 2015-10-01 17:15:58.47729 336 FinancialReportQuarter \N \n\n Financial Report Quarter\n FinancialReportQuarter\n \n \n Financial Report Column Layout\n SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))\n \n \n Accounting Period Reference\n SELECT period_id, \n CASE\n WHEN period_name <> '' THEN period_name \n ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n END \nFROM period \nORDER BY period_end DESC\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT \n <? value("project") ?> AS project,\n (SELECT prj_name FROM prj WHERE prj_id=<? value("prj_id") ?>) AS prj_name,\n flstmthead_username,\n flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n flstmthead_typedescrip1,\n flstmthead_typedescrip2,\n flstmthead_month,\n flstmthead_qtr,\n flstmthead_year,\n flstmthead_prmonth,\n flstmthead_prqtr,\n flstmthead_pryear\nFROM getflstmthead(<? value("flcol_id") ?>,<? value("period_id") ?>)\n \n \n detail\n SELECT \n flstmtitem_flhead_id,\n flstmtitem_period_id,\n flstmtitem_username,\n flstmtitem_order,\n flstmtitem_level,\n flstmtitem_subgrp,\n flstmtitem_type,\n flstmtitem_type_id,\n flstmtitem_parent_id,\n flstmtitem_accnt_id,\n flstmtitem_name,\n formatMoney(flstmtitem_month) AS flstmtitem_month,\n formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n formatMoney(flstmtitem_year) AS flstmtitem_year,\n formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(<? value("flcol_id") ?>,<? value("period_id") ?>,\n<? if exists("shownumbers") ?>\n true\n<? else ?>\n false\n<? endif ?>\n,True,<? value("prj_id") ?>)\n<? if not exists("showzeros") ?>\n WHERE ((flstmtitem_qtr <> 0) OR (flstmtitem_type <> 'I'))\n<? endif ?>\n;\n \n \n notes\n SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (flnotes_period_id=<? value("period_id") ?>)\n AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n\n \n \n 168\n \n 1\n 160\n 750\n 160\n 2\n \n \n \n \n 100\n 80\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_name\n \n \n \n \n \n \n \n 590\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 670\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_qtr\n \n \n \n \n 100\n 100\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n flstmthead_typedescrip1\n \n \n \n \n 590\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_qtr\n \n \n \n \n \n 99\n 59.6\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n prj_name\n \n \n \n \n 15\n 59.5\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n project\n \n \n \n \n \n 5\n \n \n 38\n \n \n 590\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 590\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_qtr\n \n \n \n 1\n 30\n 749\n 30\n 2\n \n \n \n \n 670\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_qtr\n \n \n \n \n
\n detail\n \n subgrp\n flstmtitem_subgrp\n \n 5\n \n 380\n 1\n 740\n 1\n 0\n \n \n \n \n \n detail\n \n 20\n \n \n 25\n 0\n 550\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_name\n \n \n \n \n 590\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_qtr\n \n \n \n \n 670\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_qtrprcnt\n \n \n \n
\n
\n notes\n \n \n notes\n \n 24\n \n \n 25\n 9\n 700\n 15\n \n 0\n \n Arial\n 9\n normal\n \n \n \n \n notes\n notes\n \n \n \n
\n \n 23\n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 695\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 8\n \n
\n 0 2015-10-01 17:15:58.47729 337 FinancialReportQuarterBudget \N \n\n Financial Report Quarter and Budget\n FinancialReportQuarterBudget\n \n \n Financial Report Column Layout\n SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))\n \n \n Accounting Period Reference\n SELECT period_id, \n CASE\n WHEN period_name <> '' THEN period_name \n ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n END \nFROM period \nORDER BY period_end DESC\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT \n <? value("project") ?> AS project,\n (SELECT prj_name FROM prj WHERE prj_id=<? value("prj_id") ?>) AS prj_name,\n flstmthead_username,\n flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n flstmthead_typedescrip1,\n flstmthead_typedescrip2,\n flstmthead_month,\n flstmthead_qtr,\n flstmthead_year,\n flstmthead_prmonth,\n flstmthead_prqtr,\n flstmthead_pryear\nFROM getflstmthead(<? value("flcol_id") ?>,<? value("period_id") ?>)\n \n \n detail\n SELECT \n flstmtitem_flhead_id,\n flstmtitem_period_id,\n flstmtitem_username,\n flstmtitem_order,\n flstmtitem_level,\n flstmtitem_subgrp,\n flstmtitem_type,\n flstmtitem_type_id,\n flstmtitem_parent_id,\n flstmtitem_accnt_id,\n flstmtitem_name,\n formatMoney(flstmtitem_month) AS flstmtitem_month,\n formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n formatMoney(flstmtitem_year) AS flstmtitem_year,\n formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(<? value("flcol_id") ?>,<? value("period_id") ?>,\n<? if exists("shownumbers") ?>\n true\n<? else ?>\n false\n<? endif ?>\n,True,<? value("prj_id") ?>)\n<? if not exists("showzeros") ?>\n WHERE ((flstmtitem_qtr <> 0) OR (flstmtitem_qtrbudget <> 0) OR (flstmtitem_type <> 'I'))\n<? endif ?>\n;\n \n \n notes\n SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (flnotes_period_id=<? value("period_id") ?>)\n AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n\n \n \n 167\n \n \n \n 380\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 380\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_qtr\n \n \n \n \n 580\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_qtr\n \n \n \n 1\n 160\n 749\n 160\n 2\n \n \n \n \n 500\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_qtr\n \n \n \n \n \n 100\n 100\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n flstmthead_typedescrip1\n \n \n \n \n \n 100\n 80\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_name\n \n \n \n \n 660\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_qtr\n \n \n \n \n \n \n 99\n 59.6\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n prj_name\n \n \n \n \n 15\n 59.5\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n project\n \n \n \n \n \n 4\n \n \n 37\n \n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_qtr\n \n \n \n \n \n \n 380\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_qtr\n \n \n \n \n 1.80678\n 30\n 750\n 30\n 2\n \n \n \n 380\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 660\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_qtr\n \n \n \n \n 500\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_qtr\n \n \n \n \n
\n detail\n \n subgrp\n flstmtitem_subgrp\n \n 4\n \n 380\n 1\n 740\n 1\n 0\n \n \n \n \n \n detail\n \n 19\n \n \n 660\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_qtrbudgetdiffprcnt\n \n \n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_qtrbudgetdiff\n \n \n \n \n 500\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_qtrbudget\n \n \n \n \n 25\n 0\n 345\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_name\n \n \n \n \n 380\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_qtr\n \n \n \n
\n
\n notes\n \n \n notes\n \n 24\n \n \n 25\n 9\n 700\n 15\n \n 0\n \n Arial\n 9\n normal\n \n \n \n \n notes\n notes\n \n \n \n
\n \n 22\n \n \n \n 695\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 7\n \n
\n 0 2015-10-01 17:15:58.47729 338 FinancialReportQuarterPriorQuarter \N \n\n Financial Report Quarter and Prior Quarter\n FinancialReportQuarterPriorQuarter\n \n \n Financial Report Column Layout\n SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))\n \n \n Accounting Period Reference\n SELECT period_id, \n CASE\n WHEN period_name <> '' THEN period_name \n ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n END \nFROM period \nORDER BY period_end DESC\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT \n <? value("project") ?> AS project,\n (SELECT prj_name FROM prj WHERE prj_id=<? value("prj_id") ?>) AS prj_name,\n flstmthead_username,\n flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n flstmthead_typedescrip1,\n flstmthead_typedescrip2,\n flstmthead_typedescrip2 || ' Diff.' AS f_diff,\n flstmthead_typedescrip2 || ' % Diff.' AS f_diffprcnt,\n flstmthead_month,\n flstmthead_qtr,\n flstmthead_year,\n flstmthead_prmonth,\n flstmthead_prqtr,\n flstmthead_pryear\nFROM getflstmthead(<? value("flcol_id") ?>,<? value("period_id") ?>)\n \n \n detail\n SELECT \n flstmtitem_flhead_id,\n flstmtitem_period_id,\n flstmtitem_username,\n flstmtitem_order,\n flstmtitem_level,\n flstmtitem_subgrp,\n flstmtitem_type,\n flstmtitem_type_id,\n flstmtitem_parent_id,\n flstmtitem_accnt_id,\n flstmtitem_name,\n formatMoney(flstmtitem_month) AS flstmtitem_month,\n formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n formatMoney(flstmtitem_year) AS flstmtitem_year,\n formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(<? value("flcol_id") ?>,<? value("period_id") ?>,\n<? if exists("shownumbers") ?>\n true\n<? else ?>\n false\n<? endif ?>\n,True,<? value("prj_id") ?>)\n<? if not exists("showzeros") ?>\n WHERE ((flstmtitem_qtr <> 0) OR (flstmtitem_prqtr <> 0) OR (flstmtitem_type <> 'I'))\n<? endif ?>\n;\n \n \n notes\n SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (flnotes_period_id=<? value("period_id") ?>)\n AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n\n \n \n 167\n \n \n 380\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_qtr\n \n \n \n \n 500\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 580\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_diff\n \n \n \n \n 100\n 100\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n flstmthead_typedescrip1\n \n \n \n \n \n 500\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_prqtr\n \n \n \n 0\n 159\n 749\n 159\n 2\n \n \n \n \n 580\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_prqtr\n \n \n \n \n 660\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_diffprcnt\n \n \n \n \n \n \n 100\n 80\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_name\n \n \n \n \n 660\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_prqtr\n \n \n \n \n 380\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 99\n 59.6\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n prj_name\n \n \n \n \n 15\n 59.5\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n project\n \n \n \n \n \n 4\n \n \n 37\n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_prqtr\n \n \n \n \n 500\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 660\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_diffprcnt\n \n \n \n \n 380\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_qtr\n \n \n \n \n 380\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 660\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_prqtr\n \n \n \n \n 580\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_diff\n \n \n \n \n 500\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_prqtr\n \n \n \n 1\n 30\n 748\n 30\n 2\n \n \n \n
\n detail\n \n subgrp\n flstmtitem_subgrp\n \n 4\n \n 380\n 1\n 740\n 1\n 0\n \n \n \n \n \n detail\n \n 19\n \n \n 380\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_qtr\n \n \n \n \n 660\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_prqtrdiffprcnt\n \n \n \n \n 500\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_prqtr\n \n \n \n \n 25\n 0\n 345\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_name\n \n \n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_prqtrdiff\n \n \n \n
\n
\n notes\n \n \n notes\n \n 24\n \n \n 25\n 9\n 700\n 15\n \n 0\n \n Arial\n 9\n normal\n \n \n \n \n notes\n notes\n \n \n \n
\n \n 22\n \n \n 695\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 7\n \n
\n 0 2015-10-01 17:15:58.47729 339 FinancialReportYear \N \n\n Financial Report Year\n FinancialReportYear\n \n \n Financial Report Column Layout\n SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))\n \n \n Accounting Period Reference\n SELECT period_id, \n CASE\n WHEN period_name <> '' THEN period_name \n ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n END \nFROM period \nORDER BY period_end DESC\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT \n <? value("project") ?> AS project,\n (SELECT prj_name FROM prj WHERE prj_id=<? value("prj_id") ?>) AS prj_name,\n flstmthead_username,\n flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n flstmthead_typedescrip1,\n flstmthead_typedescrip2,\n flstmthead_month,\n flstmthead_qtr,\n flstmthead_year,\n flstmthead_prmonth,\n flstmthead_prqtr,\n flstmthead_pryear\nFROM getflstmthead(<? value("flcol_id") ?>,<? value("period_id") ?>)\n \n \n detail\n SELECT \n flstmtitem_flhead_id,\n flstmtitem_period_id,\n flstmtitem_username,\n flstmtitem_order,\n flstmtitem_level,\n flstmtitem_subgrp,\n flstmtitem_type,\n flstmtitem_type_id,\n flstmtitem_parent_id,\n flstmtitem_accnt_id,\n flstmtitem_name,\n formatMoney(flstmtitem_month) AS flstmtitem_month,\n formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n formatMoney(flstmtitem_year) AS flstmtitem_year,\n formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(<? value("flcol_id") ?>,<? value("period_id") ?>,\n<? if exists("shownumbers") ?>\n true\n<? else ?>\n false\n<? endif ?>\n,True,<? value("prj_id") ?>)\n<? if not exists("showzeros") ?>\n WHERE ((flstmtitem_year <> 0) OR (flstmtitem_type <> 'I'))\n<? endif ?>\n;\n \n \n notes\n SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (flnotes_period_id=<? value("period_id") ?>)\n AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n\n \n \n 167\n \n \n \n \n 100\n 80\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_name\n \n \n \n \n 1\n 160\n 749\n 160\n 2\n \n \n \n \n 570\n 130\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_year\n \n \n \n \n \n 665\n 130\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_year\n \n \n \n \n 570\n 145\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 100\n 100\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n flstmthead_typedescrip1\n \n \n \n \n 99\n 59.6\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n prj_name\n \n \n \n \n 15\n 59.5\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n project\n \n \n \n \n \n 4\n \n \n 37\n \n \n 570\n 0\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_year\n \n \n \n \n 660\n 0\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_year\n \n \n \n 0\n 31\n 751\n 31\n 2\n \n \n \n 570\n 15\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n \n
\n detail\n \n subgrp\n flstmtitem_subgrp\n \n 4\n \n 390\n 0\n 750\n 0\n 0\n \n \n \n \n \n detail\n \n 19\n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_yearprcnt\n \n \n \n \n 25\n 0\n 550\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_name\n \n \n \n \n 570\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_year\n \n \n \n
\n
\n notes\n \n \n notes\n \n 24\n \n \n 25\n 9\n 700\n 15\n \n 0\n \n Arial\n 9\n normal\n \n \n \n \n notes\n notes\n \n \n \n
\n \n 22\n \n \n 695\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 7\n \n
\n 0 2015-10-01 17:15:58.47729 340 FinancialReportYearBudget \N \n\n Financial Report Year and Budget\n FinancialReportYearBudget\n \n \n Financial Report Column Layout\n SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))\n \n \n Accounting Period Reference\n SELECT period_id, \n CASE\n WHEN period_name <> '' THEN period_name \n ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n END \nFROM period \nORDER BY period_end DESC\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT \n <? value("project") ?> AS project,\n (SELECT prj_name FROM prj WHERE prj_id=<? value("prj_id") ?>) AS prj_name,\n flstmthead_username,\n flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n flstmthead_typedescrip1,\n flstmthead_typedescrip2,\n flstmthead_month,\n flstmthead_qtr,\n flstmthead_year,\n flstmthead_prmonth,\n flstmthead_prqtr,\n flstmthead_pryear\nFROM getflstmthead(<? value("flcol_id") ?>,<? value("period_id") ?>)\n \n \n detail\n SELECT \n flstmtitem_flhead_id,\n flstmtitem_period_id,\n flstmtitem_username,\n flstmtitem_order,\n flstmtitem_level,\n flstmtitem_subgrp,\n flstmtitem_type,\n flstmtitem_type_id,\n flstmtitem_parent_id,\n flstmtitem_accnt_id,\n flstmtitem_name,\n formatMoney(flstmtitem_month) AS flstmtitem_month,\n formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n formatMoney(flstmtitem_year) AS flstmtitem_year,\n formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(<? value("flcol_id") ?>,<? value("period_id") ?>,\n<? if exists("shownumbers") ?>\n true\n<? else ?>\n false\n<? endif ?>\n,True,<? value("prj_id") ?>)\n<? if not exists("showzeros") ?>\n WHERE ((flstmtitem_year <> 0) OR (flstmtitem_yearbudget <> 0) OR (flstmtitem_type <> 'I'))\n<? endif ?>\n;\n \n \n notes\n SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (flnotes_period_id=<? value("period_id") ?>)\n AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n\n \n \n 167\n \n \n 465\n 130\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_year\n \n \n \n \n 360\n 130\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_year\n \n \n \n \n \n 360\n 145\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 560\n 145\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n Budget Diff.\n \n \n \n \n 100\n 100\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n flstmthead_typedescrip1\n \n \n \n \n \n 560\n 130\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_year\n \n \n \n \n \n 100\n 80\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_name\n \n \n \n \n \n \n 3.53065\n 160\n 749.738\n 160\n 2\n \n \n \n 650\n 130\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_year\n \n \n \n \n 99\n 59.6\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n prj_name\n \n \n \n \n 15\n 59.5\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n project\n \n \n \n \n \n 4\n \n \n 37\n \n \n 555\n 0\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_year\n \n \n \n \n \n 355\n 15\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 650\n 0\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_year\n \n \n \n \n 455\n 0\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_year\n \n \n \n \n 355\n 0\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_year\n \n \n \n \n -0.610015\n 29.5831\n 748.788\n 29.5831\n 2\n \n \n \n 555\n 15\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n Budget Diff.\n \n \n \n \n
\n detail\n \n subgrp\n flstmtitem_subgrp\n \n 4\n \n 355\n 0\n 750\n 0\n 0\n \n \n \n \n \n detail\n \n 19\n \n \n 459\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_yearbudget\n \n \n \n \n 560\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_yearbudgetdiff\n \n \n \n \n 650\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_yearbudgetdiffprcnt\n \n \n \n \n 360\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_year\n \n \n \n \n 25\n 0\n 345\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_name\n \n \n \n
\n
\n notes\n \n \n notes\n \n 24\n \n \n 25\n 9\n 700\n 15\n \n 0\n \n Arial\n 9\n normal\n \n \n \n \n notes\n notes\n \n \n \n
\n \n 22\n \n \n 695\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 7\n \n
\n 0 2015-10-01 17:15:58.47729 341 FinancialReportYearPriorYear \N \n\n Financial Report Year and Prior Year\n FinancialReportYearPriorYear\n \n \n Financial Report Column Layout\n SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))\n \n \n Accounting Period Reference\n SELECT period_id, \n CASE\n WHEN period_name <> '' THEN period_name \n ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n END \nFROM period \nORDER BY period_end DESC\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT \n <? value("project") ?> AS project,\n (SELECT prj_name FROM prj WHERE prj_id=<? value("prj_id") ?>) AS prj_name,\n flstmthead_username,\n flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n flstmthead_typedescrip1,\n flstmthead_typedescrip2,\n flstmthead_typedescrip2 || 'Diff.' AS f_diff,\n flstmthead_typedescrip2 || ' % Diff.' AS f_diffprcnt,\n flstmthead_month,\n flstmthead_qtr,\n flstmthead_year,\n flstmthead_prmonth,\n flstmthead_prqtr,\n flstmthead_pryear\nFROM getflstmthead(<? value("flcol_id") ?>,<? value("period_id") ?>)\n \n \n detail\n SELECT \n flstmtitem_flhead_id,\n flstmtitem_period_id,\n flstmtitem_username,\n flstmtitem_order,\n flstmtitem_level,\n flstmtitem_subgrp,\n flstmtitem_type,\n flstmtitem_type_id,\n flstmtitem_parent_id,\n flstmtitem_accnt_id,\n flstmtitem_name,\n formatMoney(flstmtitem_month) AS flstmtitem_month,\n formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n formatMoney(flstmtitem_year) AS flstmtitem_year,\n formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(<? value("flcol_id") ?>,<? value("period_id") ?>,\n<? if exists("shownumbers") ?>\n true\n<? else ?>\n false\n<? endif ?>\n,True,<? value("prj_id") ?>)\n<? if not exists("showzeros") ?>\n WHERE ((flstmtitem_year <> 0) OR (flstmtitem_pryear <> 0) OR (flstmtitem_type <> 'I'))\n<? endif ?>\n;\n \n \n notes\n SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (flnotes_period_id=<? value("period_id") ?>)\n AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n\n \n \n 167\n \n \n 650\n 130\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_pryear\n \n \n \n \n 555\n 145\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_diff\n \n \n \n \n \n \n 360\n 145\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 459\n 130\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_pryear\n \n \n \n \n 555\n 130\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_pryear\n \n \n \n \n 650\n 145\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_diffprcnt\n \n \n \n \n 100\n 100\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n flstmthead_typedescrip1\n \n \n \n \n 100\n 80\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_name\n \n \n \n \n 459\n 145\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n \n 360\n 130\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_year\n \n \n \n 0\n 160\n 750\n 160\n 2\n \n \n \n \n 99\n 59.6\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n prj_name\n \n \n \n \n 15\n 59.5\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n project\n \n \n \n \n \n 4\n \n \n 37\n \n \n 650\n 0\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_pryear\n \n \n \n \n 1\n 30\n 749\n 30\n 2\n \n \n \n 555\n 15\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_diff\n \n \n \n \n 555\n 0\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_pryear\n \n \n \n \n 360\n 15\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 360\n 0\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_year\n \n \n \n \n 459\n 0\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_pryear\n \n \n \n \n 650\n 15\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_diffprcnt\n \n \n \n \n 459\n 15\n 85\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n
\n detail\n \n subgrp\n flstmtitem_subgrp\n \n 4\n \n 360\n 0\n 750\n 0\n 0\n \n \n \n \n \n detail\n \n 19\n \n \n 25\n 0\n 345\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_name\n \n \n \n \n 459\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_pryear\n \n \n \n \n 555\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_pryeardiff\n \n \n \n \n 360\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_year\n \n \n \n \n 650\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_pryeardiffprcnt\n \n \n \n
\n
\n notes\n \n \n notes\n \n 24\n \n \n 25\n 9\n 700\n 15\n \n 0\n \n Arial\n 9\n normal\n \n \n \n \n notes\n notes\n \n \n \n
\n \n 22\n \n \n \n 695\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 7\n \n
\n 0 2015-10-01 17:15:58.47729 344 FinancialTrend \N \n\n Financial Trend\n FinancialTrend\n Financial Trend Report\n \n Financial Report Layout\n SELECT flhead_id, flhead_name FROM flhead WHERE (flhead_active)\n \n \n Time period buckets\n Month\n Quarter\n Year\n \n \n Accounting Period Reference\n SELECT period_id, \n CASE\n WHEN period_name <> '' THEN period_name \n ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n END \nFROM period \nORDER BY period_end DESC\n \n \n Display account numbers with description\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 25\n 25\n \n head\n SELECT \n <? value("project") ?> AS project,\n (SELECT prj_name FROM prj WHERE prj_id=<? value("prj_id") ?>) AS prj_name,\n fltrendhead_username,\n fltrendhead_flhead_name,\n fltrendhead_typedescrip,\n fltrendhead_fld1,\n fltrendhead_fld2,\n fltrendhead_fld3,\n fltrendhead_fld4,\n fltrendhead_fld5,\n fltrendhead_fld6,\n fltrendhead_fld7,\n fltrendhead_fld8,\n fltrendhead_fld9,\n fltrendhead_fld10,\n fltrendhead_fld11,\n fltrendhead_fld12,\n fltrendhead_grndttl\nFROM getfltrendhead(<? value("flhead_id") ?>,ARRAY[\n <? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n <? endforeach ?>\n],<? value("interval") ?>)\n \n \n detail\n SELECT \n fltrenditem_flhead_id,\n fltrenditem_username,\n fltrenditem_order,\n fltrenditem_level,\n fltrenditem_subgrp,\n fltrenditem_type,\n fltrenditem_type_id,\n fltrenditem_parent_id,\n fltrenditem_accnt_id,\n fltrenditem_name,\n fltrenditem_fld1,\n fltrenditem_fld2,\n fltrenditem_fld3,\n fltrenditem_fld4,\n fltrenditem_fld5,\n fltrenditem_fld6,\n fltrenditem_fld7,\n fltrenditem_fld8,\n fltrenditem_fld9,\n fltrenditem_fld10,\n fltrenditem_fld11,\n fltrenditem_fld12,\n fltrenditem_grndttl\nFROM\n financialReport(<? value("flhead_id") ?>, ARRAY[\n <? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n <? endforeach ?>\n],<? value("interval") ?>,\n<? if exists("shownumbers") ?>\n true\n<? else ?>\n false\n<? endif ?>\n,<? value("prj_id") ?>)\n<? if not exists("showzeros") ?>\n WHERE ((fltrenditem_fld1 <> formatMoney(0) AND fltrenditem_fld1 IS NOT NULL) \n\tOR (fltrenditem_fld1 <> formatMoney(0) AND fltrenditem_fld1 IS NOT NULL)\n\tOR (fltrenditem_fld2 <> formatMoney(0) AND fltrenditem_fld2 IS NOT NULL)\n\tOR (fltrenditem_fld3 <> formatMoney(0) AND fltrenditem_fld3 IS NOT NULL)\n\tOR (fltrenditem_fld4 <> formatMoney(0) AND fltrenditem_fld4 IS NOT NULL)\n\tOR (fltrenditem_fld5 <> formatMoney(0) AND fltrenditem_fld5 IS NOT NULL)\n\tOR (fltrenditem_fld6 <> formatMoney(0) AND fltrenditem_fld6 IS NOT NULL)\n\tOR (fltrenditem_fld7 <> formatMoney(0) AND fltrenditem_fld7 IS NOT NULL)\n\tOR (fltrenditem_fld8 <> formatMoney(0) AND fltrenditem_fld8 IS NOT NULL)\n\tOR (fltrenditem_fld9 <> formatMoney(0) AND fltrenditem_fld9 IS NOT NULL)\n\tOR (fltrenditem_fld10 <> formatMoney(0) AND fltrenditem_fld10 IS NOT NULL)\n\tOR (fltrenditem_fld11 <> formatMoney(0) AND fltrenditem_fld11 IS NOT NULL)\n\tOR (fltrenditem_fld12 <> formatMoney(0) AND fltrenditem_fld12 IS NOT NULL)\n\tOR (fltrenditem_type <> 'I'))\n<? endif ?>\n \n \n notes\n SELECT * FROM (\nSELECT 1 AS seq, text('Notes') AS label, flhead_notes AS notes, \n startOfTime() AS period_end\nFROM flhead\nWHERE ((flhead_id=<? value("flhead_id") ?>)\n AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, period_name AS label, flnotes_notes AS notes, \n period_end\nFROM flnotes\n JOIN period ON (flnotes_period_id=period_id)\nWHERE ((flnotes_flhead_id=<? value("flhead_id") ?>)\n AND (\n <? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n OR \n <? endif ?>\n (flnotes_period_id=<? value("period_id_list") ?>)\n <? endforeach ?>\n )\n AND (length(flnotes_notes) > 0))) data\nORDER BY seq, period_end;\n\n \n \n 149\n \n \n 208\n 120\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld1\n \n \n \n \n 100\n 60\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n fltrendhead_flhead_name\n \n \n \n \n 860\n 120\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld11\n \n \n \n \n 918\n 120\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld12\n \n \n \n \n 469\n 120\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld5\n \n \n \n \n 405\n 120\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld4\n \n \n \n \n 600\n 120\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld7\n \n \n \n \n \n 275\n 120\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld2\n \n \n \n \n 795\n 120\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld10\n \n \n \n 5\n 135\n 1050\n 135\n 2\n \n \n \n 535\n 120\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld6\n \n \n \n \n 665\n 120\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld8\n \n \n \n \n 104\n 80\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n fltrendhead_typedescrip\n \n \n \n \n \n 989\n 120\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_grndttl\n \n \n \n \n \n \n 340\n 120\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld3\n \n \n \n \n 730\n 120\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld9\n \n \n \n \n 100\n 40\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n prj_name\n \n \n \n \n 20\n 40\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n project\n \n \n \n \n \n 10\n \n \n 43\n \n \n 208\n 10\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld1\n \n \n \n \n 340\n 10\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld3\n \n \n \n \n 665\n 10\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld8\n \n \n \n \n 600\n 10\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld7\n \n \n \n \n 535\n 10\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld6\n \n \n \n 5\n 30\n 1050\n 30\n 2\n \n \n \n 405\n 10\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld4\n \n \n \n \n 730\n 10\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld9\n \n \n \n \n 795\n 10\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld10\n \n \n \n \n 918\n 10\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld12\n \n \n \n \n 860\n 10\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld11\n \n \n \n \n 280\n 10\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld2\n \n \n \n \n 469\n 10\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_fld5\n \n \n \n \n 985\n 10\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n fltrendhead_grndttl\n \n \n \n \n
\n detail\n \n subgrp\n fltrenditem_subgrp\n \n 7\n \n 204\n 0\n 1055\n 0\n 1\n \n \n \n \n \n detail\n \n 19\n \n \n 925\n 0\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n fltrenditem_fld12\n \n \n \n \n 665\n 0\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n fltrenditem_fld8\n \n \n \n \n 340\n 0\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n fltrenditem_fld3\n \n \n \n \n 469\n 0\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n fltrenditem_fld5\n \n \n \n \n 860\n 0\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n fltrenditem_fld11\n \n \n \n \n 600\n 0\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n fltrenditem_fld7\n \n \n \n \n 535\n 0\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n fltrenditem_fld6\n \n \n \n \n 405\n 0\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n fltrenditem_fld4\n \n \n \n \n 730\n 0\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n fltrenditem_fld9\n \n \n \n \n 208\n 0\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n fltrenditem_fld1\n \n \n \n \n 795\n 0\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n fltrenditem_fld10\n \n \n \n \n 989\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n fltrenditem_grndttl\n \n \n \n \n 5\n 0\n 195\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n fltrenditem_name\n \n \n \n \n 275\n 0\n 60\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n fltrenditem_fld2\n \n \n \n
\n
\n notes\n \n \n notes\n \n 32\n \n \n 10\n 17\n 1025\n 15\n \n 0\n \n Arial\n 9\n normal\n \n \n \n \n notes\n notes\n \n \n \n \n 5\n 2\n 500\n 15\n \n \n Arial\n 9\n bold\n \n \n \n \n notes\n label\n \n \n \n
\n \n 29\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 930\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n Financial Trend Report 0 2015-10-01 17:15:58.47729 241 CustomerARHistory \N \n\n Customer A/R History\n CustomerARHistory\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT cust_name,\n formatDate(date(<? value("startDate") ?>)) AS startDate,\n formatDate(date(<? value("endDate") ?>)) AS endDate\n FROM custinfo\n WHERE (cust_id=<? value("cust_id") ?>);\n \n \n \n detail\n arHistory\n detail\n \n \n 156\n \n \n \n \n 550\n 85\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n endDate\n \n \n \n \n \n \n \n \n \n 550\n 65\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startDate\n \n \n \n \n \n 135\n 65\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_name\n \n \n \n \n 5\n 150\n 745\n 150\n 2\n \n \n \n \n \n \n 6\n \n \n 21\n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 540\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n amount\n \n extprice\n \n \n \n 645\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n balance\n \n extprice\n \n \n \n 349\n 0\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_docdate\n \n \n \n \n 444\n 0\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_duedate\n \n \n \n \n 5\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_open\n \n \n \n \n 175\n 0\n 170\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n docnumber\n \n \n \n \n 70\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n documenttype\n \n \n \n
\n \n 16\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 104\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 476 CustomerBOL \N \n\n Drop Ship Bill of Lading\n CustomerBOL\n \n \n 850\n 1100\n \n \n 0\n 50\n 0\n 0\n \n head\n SELECT shiphead_shipvia, formatDate(shiphead_shipdate) AS shipdate,\n cust_name, ca.addr_line1 AS cust_address1, ca.addr_line2 AS cust_address2,\n (ca.addr_city || ' ' || ca.addr_state || ' ' || ca.addr_postalcode) AS custcitystatezip,\n cust_number, cohead_number, cohead_fob, cohead_custponumber,\n warehous_descrip, wa.addr_line1 AS warehous_addr1, wa.addr_line2 AS warehous_addr2, wa.addr_line3 AS warehous_addr3, wa.addr_city AS warehous_addr4, warehous_fob,\n cohead_shiptoname, cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3,\n (cohead_shiptocity || ' ' || cohead_shiptostate || ' ' || cohead_shiptozipcode) AS shiptocitystatezip,\n cohead_shiptophone\n FROM shiphead, cohead, whsinfo, custinfo\n LEFT OUTER JOIN addr ca ON (cntct_addr_id=ca.addr_id)\n LEFT OUTER JOIN addr wa ON (warehous_addr_id=wa.addr_id);\n WHERE ((shiphead_order_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n AND (cohead_warehous_id=warehous_id)\n AND (shiphead_id=%1));\n \n \n detail\n SELECT coitem_linenumber, formatQty(SUM(shipitem_qty)) AS invqty, uom_name, roundUp(SUM(shipitem_qty) / itemuomratiobytype(item_id, 'Selling'))::integer AS shipqty,\n itemsellinguom(item_id) AS shipuom, item_number, item_descrip1, item_descrip2,\n formatQty(SUM(shipitem_qty) * item_prodweight) AS netweight,\n formatQty(SUM(shipitem_qty) * (item_prodweight + item_packweight)) AS grossweight\n FROM shipitem, coitem, itemsite, item, uom\n WHERE ((shipitem_orderitem_id=coitem_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (shipitem_shiphead_id=%1))\n GROUP BY coitem_linenumber, item_number, uom_name, shipuom\n item_descrip1, item_descrip2, item_prodweight, item_packweight\n ORDER BY coitem_linenumber;\n \n \n \n foot\n SELECT formatQty(SUM(shipitem_qty * item_prodweight)) AS netweight,\n formatQty(SUM(shipitem_qty * (item_prodweight + item_packweight))) AS grossweight,\n CASE\n WHEN ('%3' = 'C') THEN 'X'\n ELSE ' '\n END AS collectflag,\n CASE\n WHEN ('%3' = 'C') THEN 'Therm-O-Rock East, Inc.'\n ELSE ' '\n END AS section7,\n CASE\n WHEN ('%3' = 'C') THEN cust_name\n ELSE ' '\n END AS collect_name,\n CASE\n WHEN ('%3' = 'C') THEN addr_line1\n ELSE ' '\n END AS collect_address1,\n CASE\n WHEN ('%3' = 'C') THEN addr_line2\n ELSE ' '\n END AS collect_address2,\n CASE\n WHEN ('%3' = 'C') THEN (addr_city || ' ' || addr_state || ' ' || addr_postalcode)\n ELSE ' '\n END AS collect_address3\n FROM shipitem, cohead, custinfo, coitem, itemsite, item\n LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n WHERE ((shipitem_orderitem_id=coitem_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (coitem_cohead_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n AND (shipitem_shiphead_id=%1))\n GROUP BY cust_name, addr_line1, addr_line2, addr_city, addr_state, addr_postalcode;\n \n \n notes\n SELECT shiphead_notes\n FROM shiphead\n WHERE (shiphead_id=%1);\n \n \n \n 318\n \n \n 532\n 224\n 300\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n shiptocitystatezip\n \n \n \n \n 532\n 205\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_shiptoaddress3\n \n \n \n \n 93\n 168\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n warehous_addr2\n \n \n \n \n 93\n 205\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n warehous_addr4\n \n \n \n \n 532\n 168\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_shiptoaddress1\n \n \n \n \n 93\n 149\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cust_name\n \n \n \n \n 532\n 149\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_shiptoname\n \n \n \n \n 532\n 242\n 300\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_shiptophone\n \n \n \n \n 578\n 65\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n shipdate\n \n \n \n \n 93\n 186\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n warehous_addr3\n \n \n \n \n \n 121\n 65\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n shiphead_shipvia\n \n \n \n \n 532\n 186\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_shiptoaddress2\n \n \n \n
\n detail\n \n \n detail\n coitem_linenumber\n \n 54\n \n \n 200\n 40\n 300\n 14\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 94\n 5\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n shipuom\n \n \n \n \n 10\n 30\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n invqty\n \n \n \n \n 200\n 25\n 300\n 14\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 94\n 30\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n uom_name\n \n \n \n \n 10\n 5\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n shipqty\n \n \n \n \n 520\n 5\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n netweight\n \n \n \n \n 200\n 5\n 300\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n item_number\n \n \n \n \n 520\n 25\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n grossweight\n \n \n \n
\n \n \n 346\n \n \n 614\n 80\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cust_number\n \n \n \n \n 230\n 200\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n foot\n collect_address3\n \n \n \n \n \n 20\n 180\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n foot\n collect_name\n \n \n \n \n 520\n 5\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n foot\n netweight\n \n \n \n \n 50\n 10\n 400\n 100\n \n \n Arial\n 10\n normal\n \n \n \n \n notes\n shiphead_notes\n \n \n \n \n 614\n 120\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_custponumber\n \n \n \n \n 20\n 200\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n foot\n collect_address1\n \n \n \n \n 438\n 270\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n foot\n section7\n \n \n \n \n 520\n 25\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n foot\n grossweight\n \n \n \n \n \n 614\n 60\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_fob\n \n \n \n \n 230\n 180\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n foot\n collect_address2\n \n \n \n \n 728\n 270\n 46\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n foot\n collectflag\n \n \n \n \n 614\n 100\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_number\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 59 CustomerInformation \N \n\n Customer Information\n CustomerInformation\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT cust_name, cust_number,\n ba.addr_line1 AS cust_address1, ba.addr_line2 AS cust_address2, ba.addr_line3 AS cust_address3,\n ba.addr_city AS cust_city, ba.addr_state AS cust_state, ba.addr_postalcode AS cust_zipcode,\n (ba.addr_city || ', ' || ba.addr_state || ' ' || ba.addr_postalcode) AS citystatezip,\n trim(bc.cntct_first_name || ' ' || bc.cntct_last_name) AS cust_contact, bc.cntct_phone AS cust_phone, bc.cntct_fax AS cust_fax, bc.cntct_email AS cust_email,\n ca.addr_line1 AS cust_corraddress1, ca.addr_line2 AS cust_corraddress2, ca.addr_line3 AS cust_corraddress3,\n ca.addr_city AS cust_corrcity, ca.addr_state AS cust_corrstate, ca.addr_postalcode AS cust_corrzipcode,\n (ca.addr_city || ', ' || ca.addr_state || ' ' || ca.addr_postalcode) AS corrcitystatezip,\n trim(cc.cntct_first_name || ' ' || cc.cntct_last_name) AS cust_corrcontact, cc.cntct_phone AS cust_corrphone,\n cc.cntct_fax AS cust_corrfax, cc.cntct_email AS cust_corremail,\n CASE WHEN (cust_creditstatus='G') THEN 'In Good Standing'\n WHEN (cust_creditstatus='W') THEN 'On Credit Warning'\n WHEN (cust_creditstatus='H') THEN 'On Credit Hold'\n ELSE ('Unknown Status: ' || cust_creditstatus)\n END AS f_creditstatus,\n cust_comments\n FROM custinfo\n LEFT OUTER JOIN cntct cc ON (cust_corrcntct_id=cc.cntct_id)\n LEFT OUTER JOIN addr ca ON (cc.cntct_addr_id=ca.addr_id)\n LEFT OUTER JOIN cntct bc ON (cust_cntct_id=bc.cntct_id)\n LEFT OUTER JOIN addr ba ON (bc.cntct_addr_id=ba.addr_id)\n WHERE (cust_id=<? value("cust_id") ?>);\n \n \n firstlastorderdate\n SELECT formatDate(MIN(cohist_invcdate)) AS firstdate,\n formatDate(MAX(cohist_invcdate)) AS lastdate\n FROM cohist\nWHERE (cohist_cust_id=<? value("cust_id") ?>);\n \n \n lysales\n SELECT formatMoney(COALESCE(SUM(round(cohist_qtyshipped * cohist_unitprice,2)), 0)) AS lysales FROM cohist WHERE ( (cohist_invcdate BETWEEN (DATE_TRUNC('year', CURRENT_TIMESTAMP) - INTERVAL '1 year') AND (DATE_TRUNC('year', CURRENT_TIMESTAMP) - INTERVAL '1 day')) AND (cohist_cust_id=<? value("cust_id") ?>) );\n \n \n ytdsales\n SELECT formatExtPrice(SUM(round(cohist_qtyshipped * cohist_unitprice,2))) AS ytdsales\n FROM cohist\n WHERE ((cohist_invcdate>=DATE_TRUNC('year', CURRENT_TIMESTAMP))\n AND (cohist_cust_id=<? value("cust_id") ?>) );\n \n \n backlog\n SELECT formatMoney( COALESCE( SUM( (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio) ), 0 ) ) AS backlog FROM cohead, coitem, itemsite, item WHERE ( (coitem_cohead_id=cohead_id) AND (coitem_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (coitem_status='O') AND (cohead_cust_id=<? value("cust_id") ?>) );\n \n \n OpenBalance\n SELECT formatMoney( COALESCE( SUM( CASE WHEN (aropen_doctype IN ('I', 'D')) THEN (aropen_amount - aropen_paid) ELSE ((aropen_amount - aropen_paid) * -1) END ), 0 ) ) AS f_balance FROM aropen WHERE ( (aropen_open) AND (aropen_cust_id=<? value("cust_id") ?>) );\n \n \n LateBalance\n SELECT formatMoney( noNeg( COALESCE( SUM( CASE WHEN (aropen_doctype IN ('I', 'D')) THEN (aropen_amount - aropen_paid) ELSE ((aropen_amount - aropen_paid) * -1) END ), 0 ) ) ) AS f_balance FROM aropen WHERE ( (aropen_open) AND (aropen_duedate < CURRENT_DATE) AND (aropen_cust_id=<? value("cust_id") ?>) );\n\n \n \n Comments\n SELECT comment_source_id AS cust_id,\n comment_id,\n formatDate(comment_date) AS f_date,\n comment_user,\n comment_text\n FROM comment\n WHERE ( (comment_source='C')\n AND (comment_source_id=<? value("cust_id") ?>) )\nORDER BY comment_date;\n \n \n History\n SELECT aropen_cust_id AS cust_id,\n aropen_id AS aropenid, -1 AS applyid,\n aropen_docnumber AS sortnumber,\n aropen_docnumber AS docnumber,\n formatBoolYN(aropen_open) AS f_open,\n CASE WHEN (aropen_doctype='I') THEN text('Invoice')\n WHEN (aropen_doctype='C') THEN text('C/M')\n WHEN (aropen_doctype='D') THEN text('D/M')\n WHEN (aropen_doctype='R') THEN text('C/D')\n ELSE text('Other')\n END AS documenttype,\n formatDate(aropen_docdate) AS f_docdate,\n formatDate(aropen_duedate) AS f_duedate,\n formatMoney(aropen_amount) AS f_amount,\n formatMoney((aropen_amount - aropen_paid)) AS f_balance\nFROM aropen\nWHERE (aropen_cust_id=<? value("cust_id") ?>)\n\nUNION\nSELECT aropen_cust_id AS cust_id,\n -1 AS aropenid, arapply_source_aropen_id AS applyid,\n aropen_docnumber AS sortnumber,\n CASE WHEN (arapply_source_doctype='C') THEN arapply_source_docnumber\n WHEN (arapply_source_doctype='K') THEN arapply_refnumber\n ELSE :error\n END AS docnumber,\n '' AS f_open,\n CASE WHEN (arapply_source_doctype='C') THEN text('C/M')\n WHEN (arapply_fundstype='C') THEN text('Check')\n WHEN (arapply_fundstype='T') THEN text('Certified Check')\n WHEN (arapply_fundstype='M') THEN text('Master Card')\n WHEN (arapply_fundstype='V') THEN text('Visa')\n WHEN (arapply_fundstype='A') THEN text('American Express')\n WHEN (arapply_fundstype='D') THEN text('Discover Card')\n WHEN (arapply_fundstype='R') THEN text('Other Credit Card')\n WHEN (arapply_fundstype='K') THEN text('Cash')\n WHEN (arapply_fundstype='W') THEN text('Wire Transfer')\n WHEN (arapply_fundstype='O') THEN text('Other')\n END AS documenttype,\n formatDate(arapply_postdate) AS f_docdate,\n '' AS f_duedate,\n formatMoney(arapply_applied) AS f_amount,\n '' AS f_balance\nFROM arapply, aropen\nWHERE ( (arapply_target_doctype IN ('I', 'D'))\n AND (arapply_target_doctype=aropen_doctype)\n AND (arapply_target_docnumber=aropen_docnumber)\n AND (arapply_cust_id=<? value("cust_id") ?>)\n AND (aropen_cust_id=<? value("cust_id") ?>) )\n\nUNION\nSELECT aropen_cust_id AS cust_id,\n -1 AS aropenid, arapply_target_aropen_id AS applyid,\n aropen_docnumber AS sortnumber,\n arapply_target_docnumber AS docnumber,\n '' AS f_open,\n CASE WHEN (arapply_target_doctype='I') THEN text('Invoice')\n WHEN (arapply_target_doctype='D') THEN text('D/M')\n ELSE text('Other')\n END AS documenttype,\n formatDate(arapply_postdate) AS f_docdate,\n '' AS f_duedate,\n formatMoney(arapply_applied) AS f_amount,\n '' AS f_balance\nFROM arapply, aropen\nWHERE ( (arapply_source_doctype IN ('K', 'C'))\n AND (arapply_source_doctype=aropen_doctype)\n AND (arapply_source_docnumber=aropen_docnumber)\n AND (arapply_cust_id=<? value("cust_id") ?>)\n AND (aropen_cust_id=<? value("cust_id") ?>) )\n\nORDER BY sortnumber, applyid;\n \n \n 392\n \n \n \n 105\n 365\n 575\n 15\n \n 0\n \n Arial\n 8\n bold\n \n \n \n \n head\n cust_comments\n \n \n \n \n 105\n 305\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n firstlastorderdate\n firstdate\n \n \n \n \n 370\n 160\n 370\n 295\n 0\n \n \n 5\n 155\n 360\n 155\n 0\n \n \n \n \n 100\n 229\n 260\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n cust_corrcontact\n \n \n \n \n 385\n 160\n 350\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n cust_address1\n \n \n \n \n 100\n 260\n 260\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n cust_corrfax\n \n \n \n \n \n 385\n 175\n 350\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n cust_address2\n \n \n \n \n 10\n 204\n 350\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n corrcitystatezip\n \n \n \n \n 475\n 229\n 260\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n cust_contact\n \n \n \n \n \n 385\n 190\n 350\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n cust_address3\n \n \n \n \n \n 600\n 345\n 140\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_creditstatus\n \n \n \n 5\n 295\n 740\n 295\n 2\n \n \n \n \n \n 340\n 305\n 145\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n lysales\n lysales\n \n \n \n \n 600\n 325\n 140\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n LateBalance\n f_balance\n \n \n \n \n 475\n 275\n 260\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n cust_email\n \n \n \n \n 100\n 275\n 260\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n cust_corremail\n \n \n \n \n 475\n 260\n 260\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n cust_fax\n \n \n \n \n \n 100\n 75\n 295\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_name\n \n \n \n \n 10\n 190\n 350\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n cust_corraddress3\n \n \n \n \n \n 340\n 325\n 145\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n ytdsales\n ytdsales\n \n \n \n \n \n \n 475\n 245\n 260\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n cust_phone\n \n \n \n \n 380\n 155\n 735\n 155\n 0\n \n \n \n \n \n \n 10\n 160\n 350\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n cust_corraddress1\n \n \n \n \n 340\n 345\n 145\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n backlog\n backlog\n \n \n \n \n \n 10\n 175\n 350\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n cust_corraddress2\n \n \n \n \n 100\n 245\n 260\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n cust_corrphone\n \n \n \n \n 105\n 325\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n firstlastorderdate\n lastdate\n \n \n \n \n 600\n 305\n 140\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n OpenBalance\n f_balance\n \n \n \n \n \n \n 100\n 95\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_number\n \n \n \n \n 385\n 204\n 350\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n citystatezip\n \n \n \n \n \n \n
\n Comments\n \n Head\n cust_id\n \n 46\n \n 55\n 40\n 745\n 40\n 0\n \n \n \n \n \n \n \n \n \n Comments\n \n 16\n \n \n 260\n 0\n 484\n 15\n \n 5\n \n Arial\n 8\n bold\n \n \n \n \n Comments\n comment_text\n \n \n \n \n 60\n 0\n 95\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Comments\n f_date\n \n \n \n \n 160\n 0\n 95\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Comments\n comment_user\n \n \n \n
\n
\n History\n \n Head\n cust_id\n \n 46\n \n \n \n \n \n \n \n \n \n 55\n 40\n 745\n 40\n 0\n \n \n \n \n \n History\n \n 16\n \n \n 60\n 0\n 65\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n History\n f_open\n \n \n \n \n 290\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n History\n f_docdate\n \n \n \n \n 210\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n History\n docnumber\n \n \n \n \n 380\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n History\n f_duedate\n \n \n \n \n 470\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n History\n f_amount\n \n \n \n \n 130\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n History\n documenttype\n \n \n \n \n 560\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n History\n f_balance\n \n \n \n
\n \n 18\n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 70 CustomerTypesMasterList \N \n\n Customer Types Master List\n CustomerTypesMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n select custtype_code, custtype_descrip\n from custtype\norder by custtype_code;\n \n \n 76\n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n 6\n \n \n 21\n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 175\n 0\n 565\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n custtype_descrip\n \n \n \n \n 10\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n custtype_code\n \n \n \n
\n \n 16\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 453 Customers \N \n\n Customers\n Customers\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n -- Group: customers\n-- Name: detail\n-- Notes: \n\nSELECT DISTINCT ON ( cust_number )\n cust_id, cust_custtype_id, \n formatBoolYN(cust_active) as f_active,\n formatAddr(bill_addr.addr_id) AS f_bill_addr,\n formatAddr(corr_addr.addr_id) AS f_corr_addr,\n bill_cntct.cntct_name AS bill_cntct_name,\n corr_cntct.cntct_name AS corr_cntct_name,\n cust_active, cust_number, cust_name,\n custtype_code,\n bill_cntct.cntct_first_name AS bill_first_name,\n bill_cntct.cntct_last_name AS bill_last_name,\n bill_cntct.cntct_phone AS bill_phone,\n bill_cntct.cntct_fax AS bill_fax,\n bill_cntct.cntct_email AS bill_email,\n bill_addr.addr_line1 AS bill_line1,\n bill_addr.addr_line2 AS bill_line2,\n bill_addr.addr_line3 AS bill_line3,\n bill_addr.addr_city AS bill_city,\n bill_addr.addr_state AS bill_state,\n bill_addr.addr_postalcode AS bill_postalcode,\n bill_addr.addr_country AS bill_country,\n corr_cntct.cntct_first_name AS corr_first_name,\n corr_cntct.cntct_last_name AS corr_last_name,\n corr_cntct.cntct_phone AS corr_phone,\n corr_cntct.cntct_fax AS corr_fax,\n corr_cntct.cntct_email AS corr_email,\n corr_addr.addr_line1 AS corr_line1,\n corr_addr.addr_line2 AS corr_line2,\n corr_addr.addr_line3 AS corr_line3,\n corr_addr.addr_city AS corr_city,\n corr_addr.addr_state AS corr_state,\n corr_addr.addr_postalcode AS corr_postalcode,\n corr_addr.addr_country AS corr_country\n<? foreach("char_id_list") ?>\n , charass_alias<? literal("char_id_list") ?>.charass_value AS char<? literal("char_id_list") ?>\n<? endforeach ?>\nFROM custinfo\n JOIN custtype ON (cust_custtype_id=custtype_id)\n LEFT OUTER JOIN cntct bill_cntct ON (cust_cntct_id=bill_cntct.cntct_id) \n LEFT OUTER JOIN addr bill_addr ON (bill_cntct.cntct_addr_id=bill_addr.addr_id)\n LEFT OUTER JOIN cntct corr_cntct ON (cust_corrcntct_id=corr_cntct.cntct_id) \n LEFT OUTER JOIN addr corr_addr ON (corr_cntct.cntct_addr_id=corr_addr.addr_id) \n<? foreach("char_id_text_list") ?>\n LEFT OUTER JOIN charass charass_alias<? literal("char_id_text_list") ?> ON ((charass_alias<? literal("char_id_text_list") ?>.charass_target_type='C') \n AND (charass_alias<? literal("char_id_text_list") ?>.charass_target_id=cust_id)\n AND (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=<? value("char_id_text_list") ?>))\n LEFT OUTER JOIN char char_alias<? literal("char_id_text_list") ?> ON (charass_alias<? literal("char_id_text_list") ?>.charass_char_id=char_alias<? literal("char_id_text_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_list_list") ?>\n LEFT OUTER JOIN charass charass_alias<? literal("char_id_list_list") ?> ON ((charass_alias<? literal("char_id_list_list") ?>.charass_target_type='C') \n AND (charass_alias<? literal("char_id_list_list") ?>.charass_target_id=cust_id)\n AND (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=<? value("char_id_list_list") ?>))\n LEFT OUTER JOIN char char_alias<? literal("char_id_list_list") ?> ON (charass_alias<? literal("char_id_list_list") ?>.charass_char_id=char_alias<? literal("char_id_list_list") ?>.char_id)\n<? endforeach ?>\n<? foreach("char_id_date_list") ?>\n LEFT OUTER JOIN charass charass_alias<? literal("char_id_date_list") ?> ON ((charass_alias<? literal("char_id_date_list") ?>.charass_target_type='C') \n AND (charass_alias<? literal("char_id_date_list") ?>.charass_target_id=cust_id)\n AND (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=<? value("char_id_date_list") ?>))\n LEFT OUTER JOIN char char_alias<? literal("char_id_date_list") ?> ON (charass_alias<? literal("char_id_date_list") ?>.charass_char_id=char_alias<? literal("char_id_date_list") ?>.char_id)\n<? endforeach ?>\nWHERE true\n<? if not exists("showInactive") ?> \n AND cust_active \n<? endif ?>\n<? if exists("search_pattern") ?>\n AND ((cust_number ~* <? value("search_pattern") ?>)\n OR (cust_name ~* <? value("search_pattern") ?>)\n OR (custtype_code ~* <? value("search_pattern") ?>)\n OR (COALESCE(bill_cntct.cntct_first_name || ' ' || bill_cntct.cntct_last_name,'') ~* <? value("search_pattern") ?>)\n OR (COALESCE(bill_cntct.cntct_phone || ' ' || bill_cntct.cntct_phone2 || ' ' || bill_cntct.cntct_fax, '') ~* <? value("search_pattern") ?>)\n OR (COALESCE(bill_cntct.cntct_email, '') ~* <? value("search_pattern") ?>)\n OR (COALESCE(bill_addr.addr_line1 || ' ' || bill_addr.addr_line2 || ' ' || bill_addr.addr_line3,'') ~* <? value("search_pattern") ?>)\n OR (COALESCE(bill_addr.addr_city,'') ~* <? value("search_pattern") ?>)\n OR (COALESCE(bill_addr.addr_state,'') ~* <? value("search_pattern") ?>)\n OR (COALESCE(bill_addr.addr_postalcode,'') ~* <? value("search_pattern") ?>)\n OR (COALESCE(bill_addr.addr_country,'') ~* <? value("search_pattern") ?>)\n OR (COALESCE(corr_cntct.cntct_first_name || ' ' || corr_cntct.cntct_last_name,'') ~* <? value("search_pattern") ?>)\n OR (COALESCE(corr_cntct.cntct_phone || ' ' || corr_cntct.cntct_phone2 || ' ' || corr_cntct.cntct_fax, '') ~* <? value("search_pattern") ?>)\n OR (COALESCE(corr_cntct.cntct_email, '') ~* <? value("search_pattern") ?>)\n OR (COALESCE(corr_addr.addr_line1 || ' ' || corr_addr.addr_line2 || ' ' || corr_addr.addr_line3,'') ~* <? value("search_pattern") ?>)\n OR (COALESCE(corr_addr.addr_city,'') ~* <? value("search_pattern") ?>)\n OR (COALESCE(corr_addr.addr_state,'') ~* <? value("search_pattern") ?>)\n OR (COALESCE(corr_addr.addr_postalcode,'') ~* <? value("search_pattern") ?>)\n OR (COALESCE(corr_addr.addr_country,'') ~* <? value("search_pattern") ?>))\n<? endif ?>\n<? if exists("cust_number_pattern") ?>\n AND (cust_number ~* <? value("cust_number_pattern") ?>)\n<? endif ?>\n<? if exists("cust_name_pattern") ?>\n AND (cust_name ~* <? value("cust_name_pattern") ?>)\n<? endif ?>\n<? if exists("custtype_code_pattern") ?>\n AND (custtype_code ~* <? value("custtype_code_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_name_pattern") ?>\n AND (COALESCE(bill_cntct.cntct_first_name || ' ' || bill_cntct.cntct_last_name, '') ~* <? value("cntct_name_pattern") ?> \n OR COALESCE(corr_cntct.cntct_first_name || ' ' || corr_cntct.cntct_last_name, '') ~* <? value("cntct_name_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_phone_pattern") ?>\n AND (COALESCE(bill_cntct.cntct_phone || ' ' || bill_cntct.cntct_phone2 || ' ' || bill_cntct.cntct_fax,'') ~* <? value("cntct_phone_pattern") ?>\n OR COALESCE(corr_cntct.cntct_phone || ' ' || corr_cntct.cntct_phone2 || ' ' || corr_cntct.cntct_fax,'') ~* <? value("cntct_phone_pattern") ?>)\n<? endif ?>\n<? if exists("cntct_email_pattern") ?>\n AND (COALESCE(bill_cntct.cntct_email,'') ~* <? value("cntct_email_pattern") ?>\n OR COALESCE(corr_cntct.cntct_email,'') ~* <? value("cntct_email_pattern") ?>)\n<? endif ?>\n<? if exists("addr_street_pattern") ?>\n AND (COALESCE(bill_addr.addr_line1 || ' ' || bill_addr.addr_line2 || ' ' || bill_addr.addr_line3,'') ~* <? value("addr_street_pattern") ?>\n OR COALESCE(corr_addr.addr_line1 || ' ' || corr_addr.addr_line2 || ' ' || corr_addr.addr_line3,'') ~* <? value("addr_street_pattern") ?>)\n<? endif ?>\n<? if exists("addr_city_pattern") ?>\n AND (COALESCE(bill_addr.addr_city,'') ~* <? value("addr_city_pattern") ?>\n OR COALESCE(corr_addr.addr_city,'') ~* <? value("addr_city_pattern") ?>)\n<? endif ?>\n<? if exists("addr_state_pattern") ?>\n AND (COALESCE(bill_addr.addr_state,'') ~* <? value("addr_state_pattern") ?>\n OR COALESCE(corr_addr.addr_state,'') ~* <? value("addr_state_pattern") ?>)\n<? endif ?>\n<? if exists("addr_postalcode_pattern") ?>\n AND (COALESCE(bill_addr.addr_postalcode,'') ~* <? value("addr_postalcode_pattern") ?>\n OR COALESCE(corr_addr.addr_postalcode,'') ~* <? value("addr_postalcode_pattern") ?>)\n<? endif ?>\n<? if exists("addr_country_pattern") ?>\n AND (COALESCE(bill_addr.addr_country,'') ~* <? value("addr_country_pattern") ?>\n OR COALESCE(corr_addr.addr_country,'') ~* <? value("addr_country_pattern") ?>)\n<? endif ?>\n<? literal("charClause") ?>\nORDER BY cust_number; \n \n \n 146\n \n \n 5\n 140\n 745\n 140\n 2\n \n \n \n \n \n \n \n 5\n 33\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 67\n \n \n 50\n 2\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_number\n \n \n \n \n 5\n 2\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_active\n \n \n \n \n 480\n 2\n 250\n 15\n \n 0\n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_bill_addr\n \n \n \n \n 155\n 17\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n bill_cntct_name\n \n \n \n \n 155\n 32\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n bill_phone\n \n \n \n \n 155\n 47\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n bill_email\n \n \n \n \n \n \n \n 365\n 2\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n custtype_code\n \n \n \n \n 155\n 2\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_name\n \n \n \n
\n \n 16\n \n \n 105\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 165 DeliveryDateVariancesByItem \N \n\n Delivery Date Variances By Item\n DeliveryDateVariancesByItem\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number, item_descrip1,\n item_descrip2, uom_name,\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("warehous_id") ?>\n (SELECT warehous_code FROM whsinfo WHERE warehous_id=<? value("warehous_id") ?>)\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("agentUsername") ?>\n TEXT(<? value("agentUsername") ?>)\n <? else ?>\n TEXT('All Agents')\n <? endif ?>\n AS agentUsername\n FROM item JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (item_id=<? value("item_id") ?>);\n \n \n detail\n poDeliveryDateVariances\n detail\n \n \n 185\n \n \n 310\n 47\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n uom_name\n \n \n \n \n \n \n \n \n 95\n 67\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n \n \n \n \n \n 95\n 47\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n 95\n 84\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n \n 95\n 109\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n 5\n 182\n 745\n 182\n 2\n \n \n \n 550\n 47\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n \n 95\n 129\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n agentUsername\n \n \n \n \n 550\n 67\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n \n \n \n 6\n \n \n 39\n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 32\n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_recv_date\n \n \n \n \n 195\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n venditemnumber\n \n \n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n argd_duedate\n \n \n \n 7\n 31\n 747\n 31\n 0\n \n \n \n 60\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_name\n \n \n \n \n 195\n 15\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n venditemdescrip\n \n \n \n \n 5\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n recv_order_number\n \n \n \n \n 492\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n recv_qty\n \n \n \n \n 493\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n real_leadtime\n \n \n \n \n 665\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n orderdate\n \n \n \n \n 581\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n release_duedate\n \n \n \n
\n \n 16\n \n \n \n 102\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 164 DeliveryDateVariancesByVendor \N \n\n Delivery Date Variances By Vendor\n DeliveryDateVariancesByVendor\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT vend_name,\n vend_number,\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("warehous_id") ?>\n (SELECT warehous_code FROM whsinfo WHERE warehous_id=<? value("warehous_id") ?>)\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("agentUsername") ?>\n TEXT(<? value("agentUsername" ?>)\n <? else ?>\n TEXT('All Agents')\n <? endif ?>\n AS purchagent\n FROM vendinfo\n WHERE (vend_id=<? value("vend_id") ?>);\n \n \n detail\n poDeliveryDateVariances\n detail\n \n \n 171\n \n \n 550\n 69\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n 95\n 110\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n purchagent\n \n \n \n \n 95\n 65\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n vend_name\n \n \n \n \n \n \n \n \n \n \n 95\n 90\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n 550\n 49\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n 95\n 45\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n vend_number\n \n \n \n \n \n \n \n \n \n 1\n 168\n 741\n 168\n 2\n \n \n \n \n \n \n 4\n -1\n 744\n -1\n 2\n \n \n \n \n 1\n \n \n 35\n \n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 31\n \n \n 578\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n recv_qty\n \n \n \n \n 62\n 14\n 247\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n venditemdescrip\n \n \n \n \n 495\n 1\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n argd_duedate\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_recv_date\n \n \n \n \n 319\n 0\n 162\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n venditemnumber\n \n \n \n 5\n 30\n 745\n 30\n 0\n \n \n \n 5\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n recv_order_number\n \n \n \n \n 495\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n release_duedate\n \n \n \n \n 578\n 14\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n real_leadtime\n \n \n \n \n 665\n 14\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n orderdate\n \n \n \n \n 62\n 0\n 247\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemnumber\n \n \n \n
\n \n 16\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 103\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 297 DepartmentsMasterList \N \n\n Departments Master List\n DepartmentsMasterList\n \n Letter\n \n 100\n 100\n 100\n 100\n \n deptQuery\n SELECT dept_number, dept_name\nFROM dept\nORDER BY dept_number;\n \n \n \n 103\n \n \n 2\n 100\n 647\n 100\n 0\n \n \n \n 1\n 72\n 646\n 72\n 0\n \n \n \n
\n main\n \n \n deptQuery\n \n 31\n \n \n 180\n 10\n 200\n 20\n \n \n Arial\n 12\n normal\n \n \n \n \n deptQuery\n dept_name\n \n \n \n \n 15\n 10\n 150\n 20\n \n \n Arial\n 12\n normal\n \n \n \n \n deptQuery\n dept_number\n \n \n \n
\n
\n 0 2015-10-01 17:15:58.47729 289 DepositsRegister \N \n\n Deposits Register\n DepositsRegister\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("showUsernames") ?>\n text('Username')\n <? else ?>\n text('')\n <? endif ?>\n AS f_username\n \n \n detail\n SELECT trans_id,\n trans_journalnumber,\n formatDate(trans_date) AS transdate,\n trans_source,\n trans_doctype,\n trans_docnumber,\n firstLine(trans_notes) AS transnotes,\n (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n trans_username,\n formatBoolYN(trans_posted) AS f_posted,\n-- Debits:\n CASE WHEN (trans_amount < 0) THEN formatMoney(ABS(trans_amount))\n ELSE ''\n END AS f_debit, \n CASE WHEN (trans_amount < 0) THEN ABS(trans_amount)\n ELSE 0\n END AS debit_amt, \n--Credits:\n CASE WHEN (trans_amount > 0) THEN formatMoney(trans_amount)\n ELSE ''\n END AS f_credit,\n CASE WHEN (trans_amount > 0) THEN trans_amount\n ELSE 0\n END AS credit_amt,\n--Balance:\n trans_amount * -1 as balance_amt,\n--AROPEN Amount\n formatMoney(currtobase(aropen_curr_id,(aropen_amount - aropen_paid),aropen_docdate)) AS f_aropen_bal,\n currtobase(aropen_curr_id,(aropen_amount - aropen_paid),aropen_docdate) AS aropen_bal\n\nFROM (\nSELECT gltrans_id AS trans_id, gltrans_date AS trans_date, gltrans_created AS trans_created,\n gltrans_source AS trans_source, gltrans_doctype AS trans_doctype, gltrans_sequence AS trans_sequence,\n gltrans_docnumber AS trans_docnumber, gltrans_notes AS trans_notes, gltrans_amount AS trans_amount,\n gltrans_journalnumber AS trans_journalnumber, gltrans_username AS trans_username,\n gltrans_posted AS trans_posted,\n accnt_id, accnt_descrip,\n aropen_amount, aropen_paid, aropen_curr_id, aropen_docdate\nFROM gltrans LEFT OUTER JOIN aropen ON ((text(gltrans_docnumber) = 'I-' || text(aropen_docnumber))\n AND (aropen_doctype='I')), accnt\nWHERE ((gltrans_accnt_id=accnt_id)\n AND (gltrans_doctype = 'CR')\n AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) )\nUNION\nSELECT sltrans_id AS trans_id, sltrans_date AS trans_date, sltrans_created AS trans_created,\n sltrans_source AS trans_source, sltrans_doctype AS trans_doctype, sltrans_sequence AS trans_sequence,\n sltrans_docnumber AS trans_docnumber, sltrans_notes AS trans_notes, sltrans_amount AS trans_amount,\n sltrans_journalnumber AS trans_journalnumber, sltrans_username AS trans_username,\n sltrans_posted AS trans_posted,\n accnt_id, accnt_descrip,\n aropen_amount, aropen_paid, aropen_curr_id, aropen_docdate\nFROM sltrans LEFT OUTER JOIN aropen ON ((text(sltrans_docnumber) = 'I-' || text(aropen_docnumber))\n AND (aropen_doctype='I')), accnt\nWHERE ((sltrans_accnt_id=accnt_id)\n AND (sltrans_doctype = 'CR')\n AND (sltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>) )\n ) AS data\n\nORDER BY trans_created DESC, trans_sequence, trans_amount;\n \n \n 206\n \n \n 0\n 200\n 1000\n 200\n 2\n \n \n \n \n \n \n \n \n \n 175\n 90\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 175\n 70\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n 6\n \n \n 57\n \n \n \n \n \n \n \n \n \n \n 0\n 50\n 1000\n 50\n 2\n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 21\n \n \n 12500\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n trans_doctype\n \n \n \n \n 202\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n trans_docnumber\n \n \n \n \n 892\n 0\n 65\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n trans_username\n \n \n \n \n 55\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n transdate\n \n \n \n \n 160\n 0\n 25\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n trans_doctype\n \n \n \n \n 310\n 0\n 175\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n account\n \n \n \n \n 490\n 0\n 95\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n transnotes\n \n \n \n \n 695\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_credit\n \n \n \n \n 963\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_posted\n \n \n \n \n 600\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_debit\n \n \n \n \n 0\n 0\n 45\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n trans_journalnumber\n \n \n \n \n 790\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_aropen_bal\n \n \n \n \n 120\n 0\n 25\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n trans_source\n \n \n \n
\n \n \n 78\n \n \n \n 695\n 25\n 75\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n credit_amt\n \n money\n \n \n \n \n 600\n 25\n 80\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n debit_amt\n \n money\n \n \n \n \n 960\n 60\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 60\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 605\n 5\n 1015\n 6\n 2\n \n \n \n 790\n 25\n 75\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n aropen_bal\n \n qty\n \n \n \n \n 21\n \n \n 960\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 25 DetailedInventoryHistoryByLocation \N \n\n Detailed Inventory History by Location\n DetailedInventoryHistoryByLocation\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT formatLocationName(location_id) AS locationname,\n firstLine(location_descrip) as f_descrip,\n formatBoolYN(location_netable) AS f_netable,\n formatBoolYN(location_restrict) AS f_restrict,\n warehous_code AS warehouse,\n formatDate(<? value("startDate") ?>) AS startdate,\n formatDate(<? value("endDate") ?>) AS enddate\n FROM location, whsinfo\n WHERE ((location_id=<? value("location_id") ?>)\n AND (location_warehous_id=warehous_id) );\n\n \n \n detail\n SELECT invhist_id,\n formatDateTime(invhist_transdate) AS transdate,\n invhist_transtype,\n (invhist_ordtype || '-' || invhist_ordnumber) AS ordernumber,\n invhist_invuom,\n item_number,\n item_descrip1,\n item_descrip2,\n formatlotserialnumber(invdetail_ls_id) AS invdetail_lotserial,\n formatQty(invdetail_qty) AS transqty,\n formatQty(invdetail_qty_before) AS qohbefore,\n formatQty(invdetail_qty_after) AS qohafter,\n invhist_user AS username,\n (select warehous_code from whsinfo where warehous_id=itemsite_warehous_id) as warehous_code\n FROM invdetail, invhist, itemsite, item\n WHERE ((invdetail_invhist_id=invhist_id)\n AND (invhist_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (invdetail_location_id=<? value("location_id") ?>)\n AND (date(invhist_transdate) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n AND (transType(invhist_transtype, <? value("transType") ?>))\n)\nORDER BY invhist_transdate DESC, invhist_transtype;\n \n \n 251\n \n \n \n \n 140\n 104\n 375\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_descrip\n \n \n \n \n \n \n 140\n 85\n 375\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n locationname\n \n \n \n \n \n \n 508\n 150\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n 140\n 130\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n \n 508\n 130\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n 600\n 104\n 65\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_restrict\n \n \n \n \n \n \n \n \n \n \n 600\n 85\n 65\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_netable\n \n \n \n 5\n 245\n 745\n 245\n 2\n \n \n \n \n \n \n \n \n 6\n \n \n 51\n \n \n \n \n \n \n 5\n 45\n 745\n 45\n 2\n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 51\n \n \n 585\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qohbefore\n \n \n \n \n 508\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n transqty\n \n \n \n \n 60\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n transdate\n \n \n \n \n 433\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n invhist_invuom\n \n \n \n \n 60\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ordernumber\n \n \n \n \n 10\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 660\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qohafter\n \n \n \n \n 170\n 15\n 228\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 10\n 15\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n invhist_transtype\n \n \n \n \n 170\n 0\n 125\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 305\n 0\n 125\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n invdetail_lotserial\n \n \n \n \n 60\n 30\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n username\n \n \n \n \n 170\n 30\n 228\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n
\n \n 16\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 366 EmployeeList \N \n\n Employee List\n EmployeeList\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n employees\n detail\n \n \n head\n SELECT 'Search for "' || <? value("searchString") ?> ||\n '"' ||\n<? if exists("searchCode") ?> ' in Employee Code,' || <? endif ?>\n<? if exists("searchDept") ?> ' in Department, ' || <? endif ?>\n<? if exists("searchMgr") ?> ' in Manager, ' || <? endif ?>\n<? if exists("searchNumber") ?> ' in Employee Number, ' || <? endif ?>\n<? if exists("searchShift") ?> ' in Shift, ' || <? endif ?>\n<? if exists("activeOnly") ?> ' Among Active Employees'\n<? else ?> ' Among All Employees'\n<? endif ?>\nAS filter;\n \n \n 131\n \n \n 390\n 40\n 360\n 31\n \n 0\n \n Arial\n 8\n normal\n \n \n \n \n head\n filter\n \n \n \n \n \n \n 747\n 65\n 42\n 12\n \n 0\n \n Arial\n 8\n normal\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 10\n 130\n 750\n 130\n 2\n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n
\n detail\n \n \n detail\n \n 31\n \n \n 460\n 0\n 130\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cntct_first_name\n \n \n \n \n 605\n 0\n 130\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cntct_last_name\n \n \n \n \n 170\n 15\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n department\n \n \n \n \n 310\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shift\n \n \n \n \n 170\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n emp_number\n \n \n \n \n 375\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n manager_code\n \n \n \n \n 10\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n emp_code\n \n \n \n \n 112\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n emp_active\n \n \n \n
\n \n 16\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 206 ExpenseCategoriesMasterList \N \n\n Expense Categories Master List\n ExpenseCategoriesMasterList\n \n Letter\n \n 50\n 50\n 28\n 28\n \n detail\n SELECT \n expcat_code,\n expcat_descrip,\n formatGLAccountLong(expcat_exp_accnt_id) AS exp_accnt,\n formatGLAccountLong(expcat_purchprice_accnt_id) AS ppv_accnt,\n formatGLAccountLong(expcat_liability_accnt_id) AS poliab_accnt,\n formatGLAccountLong(expcat_freight_accnt_id) AS polinefrgt_accnt\nFROM \n expcat AS A\nORDER BY expcat_code;\n\n \n \n 90\n \n \n 6\n 85\n 1036\n 85\n 2\n \n \n \n \n \n \n \n \n \n \n 7\n \n \n 33\n \n \n 6\n 30\n 1036\n 30\n 2\n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 40\n \n \n 260\n -1\n 490\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n expcat_descrip\n \n \n \n \n 5\n 0\n 130\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n expcat_code\n \n \n \n \n 5\n 14\n 230\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n exp_accnt\n \n \n \n \n 260\n 14\n 240\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ppv_accnt\n \n \n \n \n 520\n 14\n 230\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n poliab_accnt\n \n \n \n \n 780\n 14\n 230\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n polinefrgt_accnt\n \n \n \n 6\n 30\n 1036\n 30\n 1\n \n \n
\n \n 17\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 945\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 215 ExpiredInventoryByClassCode \N \n\n Expired Inventory By Class Code\n ExpiredInventoryByClassCode\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("warehous_id") ?>\n (SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Warehouses')\n <? endif ?>\n AS warehouse,\n <? if exists("classcode_id") ?>\n (SELECT (classcode_code || '-' || classcode_descrip)\n FROM classcode\n WHERE (classcode_id=<? value("classcode_id") ?>) )\n <? elseif exists("classcode_pattern") ?>\n text(<? value("classcode_pattern") ?>)\n <? else ?>\n text('All Class Codes')\n <? endif ?>\n AS classcode,\n <? if exists("perishability") ?> \n 'Perishability'\n <? else ?>\n 'Warranty'\n <? endif ?> AS expiretype,\n <? if exists("showValue") ?>\n <? if exists("useActualCosts") ?>\n text('Show Inventory Value with Actual Costs')\n <? elseif exists("useStandardCosts") ?>\n text('Show Inventory Value with Standard Costs')\n <? else ?>\n text('Show Inventory Value with Posted Costs')\n <? endif ?>\n AS showvalues,\n text('Unit Cost') AS f_unitcost,\n text('Value') AS f_value,\n <? else ?>\n text('') AS showvalues,\n text('') AS f_unitcost,\n text('') AS f_value,\n <? endif ?>\n int4(<? value("thresholdDays") ?>) AS f_thresholddays;\n \n \n detail\n SELECT warehous_code,\n item_number,\n item_descrip1,\n item_descrip2,\n uom_name,\n ls_number AS itemloc_lotserial,\n formatQty(itemloc_qty) AS f_qoh,\n formatDate(itemloc_expiration) AS f_expiration,\n <? if exists("showValue") ?>\n formatCost(cost)\n <? else ?>\n text('')\n <? endif ?>\n AS f_unitcost,\n noNeg(cost * itemloc_qty) AS value,\n <? if exists("showValue") ?>\n formatExtPrice(noNeg(cost * itemloc_qty))\n <? else ?>\n text('')\n <? endif ?>\n AS f_value\n FROM ( SELECT itemsite_id,\n warehous_code,\n item_number,\n item_descrip1,\n item_descrip2,\n uom_name,\n ls_number,\n itemloc_qty,\n<? if exists("perishability") ?>\n itemloc_expiration,\n<? elseif exists("warranty") ?>\n itemloc_warrpurc AS itemloc_expiration,\n<? endif ?>\n <? if exists("useActualCosts") ?>\n actcost(itemsite_item_id)\n <? elseif exists("useStandardCosts") ?>\n stdcost(itemsite_item_id)\n <? else ?>\n (itemsite_value / CASE WHEN(itemsite_qtyonhand=0) THEN 1 ELSE itemsite_qtyonhand END)\n <? endif ?>\n AS cost\n FROM itemloc, itemsite, item, whsinfo, uom, ls\n WHERE ((itemloc_itemsite_id=itemsite_id)\n AND (itemloc_ls_id=ls_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_warehous_id=warehous_id)\n<? if exists("perishability") ?>\n AND (itemsite_perishable)\n AND (itemloc_expiration < (CURRENT_DATE + <? value("thresholdDays") ?>))\n<? elseif exists("warranty") ?>\n AND (itemsite_warrpurc)\n AND (itemloc_warrpurc < (CURRENT_DATE + <? value("thresholdDays") ?>))\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("classcode_id") ?>\n AND (item_classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n AND (item_classcode_id IN (SELECT classcode_id\n FROM classcode\n WHERE classcode_code ~ <? value("classcode_pattern") ?>) )\n<? endif ?>\n )\n ) AS data\nORDER BY warehous_code,\n<? if exists("orderByInventoryValue") ?>\n value DESC\n<? elseif exists("orderByExpirationDate") ?>\n itemloc_expiration\n<? else ?>\n item_number\n<? endif ?>\n \n \n 237\n \n \n \n \n 440\n 140\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n showvalues\n \n \n \n \n 575\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_unitcost\n \n \n \n \n \n \n \n \n \n \n \n 130\n 140\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n 660\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_value\n \n \n \n 5\n 227\n 745\n 227\n 2\n \n \n \n 130\n 120\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n classcode\n \n \n \n \n \n \n 130\n 160\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n expiretype\n \n \n \n \n \n 540\n 120\n 195\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_thresholddays\n \n \n \n \n \n 6\n \n \n 42\n \n 5\n 35\n 745\n 32\n 2\n \n \n \n \n \n \n 660\n 5\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_value\n \n \n \n \n \n \n \n \n 575\n 5\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_unitcost\n \n \n \n
\n detail\n \n \n detail\n \n 52\n \n \n 350\n 15\n 135\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_expiration\n \n \n \n \n 102\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 660\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_value\n \n \n \n \n 25\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 490\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qoh\n \n \n \n \n 265\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 575\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_unitcost\n \n \n \n \n 102\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 102\n 15\n 240\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 350\n 0\n 135\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemloc_lotserial\n \n \n \n
\n \n 17\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 285 FinancialReport \N \n\n Financial Report\n FinancialReport\n Ad Hoc Report\n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT flhead_name,\n CASE WHEN(trim(BOTH FROM COALESCE(flhead_custom_label,''))='') THEN 'Custom'\n ELSE flhead_custom_label\n END AS custom_label,\n CASE WHEN(flhead_usealtbegin) THEN flhead_altbegin\n ELSE text('Begining')\n END AS begining_label,\n CASE WHEN(flhead_usealtend) THEN flhead_altend\n ELSE text('Ending')\n END AS ending_label,\n CASE WHEN(flhead_usealtdebits) THEN flhead_altdebits\n ELSE text('Debits')\n END AS debits_label,\n CASE WHEN(flhead_usealtcredits) THEN flhead_altcredits\n ELSE text('Credits')\n END AS credits_label,\n CASE WHEN(flhead_usealtbudget) THEN flhead_altbudget\n ELSE text('Budget')\n END AS budget_label,\n CASE WHEN(flhead_usealtdiff) THEN flhead_altdiff\n ELSE text('Difference')\n END AS diff_label\n FROM flhead\n WHERE (flhead_id=<? value("flhead_id") ?>)\n \n \n detail\n SELECT financialReport(<? value("flhead_id") ?>, period_id,<? value("interval") ?>,<? value("prj_id") ?>)\n FROM period\n WHERE (period_id IN (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n ));\nSELECT period_id, period_start, formatperiodname(period_id,<? value("interval") ?>) AS f_period, flrpt_order,\n ( repeat(' ', flrpt_level) || flgrp_name ) AS name,\n CASE WHEN(flgrp_summarize AND flgrp_showstart) THEN formatMoney(flrpt_beginning)\n ELSE NULL\n END AS beginning,\n CASE WHEN(flgrp_summarize AND flgrp_showdelta) THEN formatMoney(flrpt_debits)\n ELSE NULL\n END AS debits,\n CASE WHEN(flgrp_summarize AND flgrp_showdelta) THEN formatMoney(flrpt_credits)\n ELSE NULL\n END AS credits,\n CASE WHEN(flgrp_summarize AND flgrp_showend) THEN formatMoney(flrpt_ending)\n ELSE NULL\n END AS ending,\n CASE WHEN(flgrp_summarize AND flgrp_showbudget) THEN formatMoney(flrpt_budget)\n ELSE NULL\n END AS budget,\n CASE WHEN(flgrp_summarize AND flgrp_showdiff) THEN formatMoney(flrpt_diff)\n ELSE NULL\n END AS diff,\n CASE WHEN(flgrp_summarize AND flgrp_showcustom) THEN formatMoney(flrpt_custom)\n ELSE NULL\n END AS custom,\n CASE WHEN(flgrp_summarize AND flgrp_showstartprcnt) THEN formatPrcnt(flrpt_beginningprcnt)\n ELSE NULL\n END AS beginningprcnt,\n CASE WHEN(flgrp_summarize AND flgrp_showdeltaprcnt) THEN formatPrcnt(flrpt_debitsprcnt)\n ELSE NULL\n END AS debitsprcnt,\n CASE WHEN(flgrp_summarize AND flgrp_showdeltaprcnt) THEN formatPrcnt(flrpt_creditsprcnt)\n ELSE NULL\n END AS creditsprcnt,\n CASE WHEN(flgrp_summarize AND flgrp_showendprcnt) THEN formatPrcnt(flrpt_endingprcnt)\n ELSE NULL\n END AS endingprcnt,\n CASE WHEN(flgrp_summarize AND flgrp_showbudgetprcnt) THEN formatPrcnt(flrpt_budgetprcnt)\n ELSE NULL\n END AS budgetprcnt,\n CASE WHEN(flgrp_summarize AND flgrp_showdiffprcnt) THEN formatPrcnt(flrpt_diffprcnt)\n ELSE NULL\n END AS diffprcnt,\n CASE WHEN(flgrp_summarize AND flgrp_showcustomprcnt) THEN formatPrcnt(flrpt_customprcnt)\n ELSE NULL\n END AS customprcnt\n FROM flrpt, flgrp, period\n WHERE ((flrpt_type='G')\n AND (flrpt_type_id=flgrp_id)\n AND (flrpt_flhead_id=<? value("flhead_id") ?>)\n AND (flrpt_period_id=period_id)\n AND (flrpt_username=getEffectiveXtUser())\n AND (flrpt_interval=<? value("interval") ?>)\n AND (period_id IN (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n )))\nUNION\nSELECT period_id, period_start, formatperiodname(period_id,<? value("interval") ?>) AS f_period, flrpt_order,\n ( repeat(' ', flrpt_level) ||\n CASE WHEN(accnt_id IS NULL) THEN ('Unknown Account ID ' || flitem_accnt_id)\n ELSE (formatGLAccount(accnt_id) || '-' || accnt_descrip)\n END\n ) AS name,\n formatMoney(flrpt_beginning) AS beginning,\n formatMoney(flrpt_debits) AS debits,\n formatMoney(flrpt_credits) AS credits,\n formatMoney(flrpt_ending) AS ending,\n formatMoney(flrpt_budget) AS budget,\n formatMoney(flrpt_diff) AS diff,\n formatMoney(flrpt_custom) AS custom,\n formatPrcnt(flrpt_beginningprcnt) AS beginningprcnt,\n formatPrcnt(flrpt_debitsprcnt) AS debitsprcnt,\n formatPrcnt(flrpt_creditsprcnt) AS creditsprcnt,\n formatPrcnt(flrpt_endingprcnt) AS endingprcnt,\n formatPrcnt(flrpt_budgetprcnt) AS budgetprcnt,\n formatPrcnt(flrpt_diffprcnt) AS diffprcnt,\n formatPrcnt(flrpt_customprcnt) AS customprcnt\n FROM flrpt LEFT OUTER JOIN accnt ON (flrpt_accnt_id=accnt_id), flitem, period\n WHERE ((flrpt_type='I')\n AND (flrpt_type_id=flitem_id)\n AND (flrpt_flhead_id=<? value("flhead_id") ?>)\n AND (flrpt_period_id=period_id)\n AND (flrpt_username=getEffectiveXtUser())\n AND (flrpt_interval=<? value("interval") ?>)\n<? if not exists("showzeros") ?>\n AND ((flrpt_beginning <> 0) \n OR (flrpt_debits <> 0)\n OR (flrpt_credits <> 0)\n OR (flrpt_ending <> 0)\n OR (flrpt_budget <> 0)\n OR (flrpt_diff <> 0)\n OR (flrpt_custom <> 0))\n<? endif ?>\n AND (period_id IN (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n )))\nUNION\nSELECT period_id, period_start, formatperiodname(period_id,<? value("interval") ?>) AS f_period, flrpt_order,\n ( repeat(' ', flrpt_level) || flspec_name ) AS name,\n formatMoney(flrpt_beginning) AS beginning,\n formatMoney(flrpt_debits) AS debits,\n formatMoney(flrpt_credits) AS credits,\n formatMoney(flrpt_ending) AS ending,\n formatMoney(flrpt_budget) AS budget,\n formatMoney(flrpt_diff) AS diff,\n formatMoney(flrpt_custom) AS custom,\n formatPrcnt(flrpt_beginningprcnt) AS beginningprcnt,\n formatPrcnt(flrpt_debitsprcnt) AS debitsprcnt,\n formatPrcnt(flrpt_creditsprcnt) AS creditsprcnt,\n formatPrcnt(flrpt_endingprcnt) AS endingprcnt,\n formatPrcnt(flrpt_budgetprcnt) AS budgetprcnt,\n formatPrcnt(flrpt_diffprcnt) AS diffprcnt,\n formatPrcnt(flrpt_customprcnt) AS customprcnt\n FROM flrpt, flspec, period\n WHERE ((flrpt_type='S')\n AND (flrpt_type_id=flspec_id)\n AND (flrpt_flhead_id=<? value("flhead_id") ?>)\n AND (flrpt_period_id=period_id)\n AND (flrpt_username=getEffectiveXtUser())\n AND (flrpt_interval=<? value("interval") ?>)\n AND (period_id IN (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n )))\nUNION\nSELECT period_id, period_start, formatperiodname(period_id,<? value("interval") ?>) AS f_period, flrpt_order,\n ( repeat(' ', flrpt_level) ||\n CASE WHEN(flrpt_type='T' AND flrpt_level=0) THEN COALESCE(flrpt_altname,'Total')\n WHEN(flrpt_type='T') THEN COALESCE(flrpt_altname,'Subtotal')\n ELSE ('Type ' || flrpt_type || ' ' || text(flrpt_type_id))\n END\n ) AS name,\n formatMoney(flrpt_beginning) AS beginning,\n formatMoney(flrpt_debits) AS debits,\n formatMoney(flrpt_credits) AS credits,\n formatMoney(flrpt_ending) AS ending,\n formatMoney(flrpt_budget) AS budget,\n formatMoney(flrpt_diff) AS diff,\n formatMoney(flrpt_custom) AS custom,\n formatPrcnt(flrpt_beginningprcnt) AS beginningprcnt,\n formatPrcnt(flrpt_debitsprcnt) AS debitsprcnt,\n formatPrcnt(flrpt_creditsprcnt) AS creditsprcnt,\n formatPrcnt(flrpt_endingprcnt) AS endingprcnt,\n formatPrcnt(flrpt_budgetprcnt) AS budgetprcnt,\n formatPrcnt(flrpt_diffprcnt) AS diffprcnt,\n formatPrcnt(flrpt_customprcnt) AS customprcnt\n FROM flrpt, period\n WHERE ((NOT (flrpt_type IN ('G','I','S')))\n AND (flrpt_flhead_id=<? value("flhead_id") ?>)\n AND (flrpt_period_id=period_id)\n AND (flrpt_username=getEffectiveXtUser())\n AND (flrpt_interval=<? value("interval") ?>)\n AND (period_id IN (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n )))\n ORDER BY period_start, flrpt_order;\n \n \n notes\n SELECT flhead_notes AS notes\nFROM flhead\nWHERE ((flhead_id=<? value("flhead_id") ?>)\n AND (length(flhead_notes) > 0))\n \n \n 136\n \n \n \n 100\n 104\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n flhead_name\n \n \n \n \n \n \n 5\n \n \n 38\n \n \n 775\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n diff_label\n \n \n \n \n \n \n \n \n 615\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n ending_label\n \n \n \n \n \n \n 375\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n begining_label\n \n \n \n \n 455\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n debits_label\n \n \n \n 5\n 30\n 994\n 30\n 2\n \n \n \n \n 855\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n custom_label\n \n \n \n \n 695\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n budget_label\n \n \n \n \n \n 535\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n credits_label\n \n \n \n
\n detail\n \n byPeriod\n period_id\n \n 112\n \n \n \n \n \n \n 855\n 80\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n custom_label\n \n \n \n \n 535\n 80\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n credits_label\n \n \n \n \n 455\n 80\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n debits_label\n \n \n \n \n \n \n \n 100\n 40\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n f_period\n \n \n \n \n 695\n 80\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n budget_label\n \n \n \n \n \n 615\n 80\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n ending_label\n \n \n \n \n 775\n 80\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n diff_label\n \n \n \n \n 10\n 110\n 1000\n 110\n 2\n \n \n \n 375\n 80\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n begining_label\n \n \n \n \n \n \n detail\n \n 33\n \n \n 455\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n debits\n \n \n \n \n 375\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n beginningprcnt\n \n \n \n \n 5\n 0\n 350\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n name\n \n \n \n \n 855\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n customprcnt\n \n \n \n \n 615\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ending\n \n \n \n \n 775\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n diffprcnt\n \n \n \n \n 695\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n budget\n \n \n \n \n 615\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n endingprcnt\n \n \n \n \n 375\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n beginning\n \n \n \n \n 695\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n budgetprcnt\n \n \n \n \n 855\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n custom\n \n \n \n \n 455\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n debitsprcnt\n \n \n \n \n 535\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n credits\n \n \n \n \n 775\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n diff\n \n \n \n \n 535\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n creditsprcnt\n \n \n \n
\n
\n notes\n \n \n head\n \n 26\n \n \n 10\n 6\n 980\n 15\n \n 0\n \n Arial\n 9\n normal\n \n \n \n \n notes\n notes\n \n \n \n
\n \n 23\n \n \n \n 930\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n Ad Hoc Report 0 2015-10-01 17:15:58.47729 331 FinancialReportMonth \N \n\n Financial Report Month\n FinancialReportMonth\n \n \n Financial Report Column Layout\n SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))\n \n \n Accounting Period Reference\n SELECT period_id, \n CASE\n WHEN period_name <> '' THEN period_name \n ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n END \nFROM period \nORDER BY period_end DESC\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT \n <? value("project") ?> AS project,\n (SELECT prj_name FROM prj WHERE prj_id=<? value("prj_id") ?>) AS prj_name,\n flstmthead_username,\n flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n flstmthead_typedescrip1,\n flstmthead_typedescrip2,\n flstmthead_month,\n flstmthead_qtr,\n flstmthead_year,\n flstmthead_prmonth,\n flstmthead_prqtr,\n flstmthead_pryear\nFROM getflstmthead(<? value("flcol_id") ?>,<? value("period_id") ?>)\n \n \n detail\n -- Group: financialReport\n-- Name: detail\n-- Notes: \nSELECT \n flstmtitem_flhead_id,\n flstmtitem_period_id,\n flstmtitem_username,\n flstmtitem_order,\n flstmtitem_level,\n flstmtitem_subgrp,\n flstmtitem_type,\n flstmtitem_type_id,\n flstmtitem_parent_id,\n flstmtitem_accnt_id,\n flstmtitem_name,\n formatMoney(flstmtitem_month) AS flstmtitem_month,\n formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n formatMoney(flstmtitem_year) AS flstmtitem_year,\n formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(<? value("flcol_id") ?>,<? value("period_id") ?>,\n<? if exists("shownumbers") ?>\n true\n<? else ?>\n false\n<? endif ?>\n,True,<? value("prj_id") ?>)\n<? if not exists("showzeros") ?>\n WHERE ((flstmtitem_month <> 0) OR (flstmtitem_type <> 'I'))\n<? endif ?>\n;\n \n \n notes\n SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (flnotes_period_id=<? value("period_id") ?>)\n AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n\n \n \n 167\n \n \n 100\n 80\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_name\n \n \n \n 3.55207\n 162.602\n 746.627\n 162.602\n 2\n \n \n \n 100\n 100\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n flstmthead_typedescrip1\n \n \n \n \n \n \n 590.695\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n \n 590\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n 670\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n \n 99\n 59.6\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n prj_name\n \n \n \n \n 15\n 59.5\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n project\n \n \n \n \n \n \n 4\n \n \n 37\n \n \n 590\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 670\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n 2.82852\n 30.1086\n 747.989\n 30.1086\n 2\n \n \n \n 590\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n
\n detail\n \n subgrp\n flstmtitem_subgrp\n \n 4\n \n 390\n 0\n 750\n 0\n 0\n \n \n \n \n \n detail\n \n 19\n \n \n 590\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_month\n \n \n \n \n 25\n 0\n 550\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_name\n \n \n \n \n 670\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_monthprcnt\n \n \n \n
\n
\n notes\n \n \n notes\n \n 24\n \n \n 25\n 9\n 700\n 15\n \n 0\n \n Arial\n 9\n normal\n \n \n \n \n notes\n notes\n \n \n \n
\n \n 22\n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 695\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 7\n \n
\n 0 2015-10-01 17:15:58.47729 332 FinancialReportMonthBudget \N \n\n Financial Report Month and Budget\n FinancialReportMonthBudget\n \n \n Financial Report Column Layout\n SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))\n \n \n Accounting Period Reference\n SELECT period_id, \n CASE\n WHEN period_name <> '' THEN period_name \n ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n END \nFROM period \nORDER BY period_end DESC\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT \n <? value("project") ?> AS project,\n (SELECT prj_name FROM prj WHERE prj_id=<? value("prj_id") ?>) AS prj_name,\n flstmthead_username,\n flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n flstmthead_typedescrip1,\n flstmthead_typedescrip2,\n flstmthead_month,\n flstmthead_qtr,\n flstmthead_year,\n flstmthead_prmonth,\n flstmthead_prqtr,\n flstmthead_pryear\nFROM getflstmthead(<? value("flcol_id") ?>,<? value("period_id") ?>)\n \n \n detail\n SELECT \n flstmtitem_flhead_id,\n flstmtitem_period_id,\n flstmtitem_username,\n flstmtitem_order,\n flstmtitem_level,\n flstmtitem_subgrp,\n flstmtitem_type,\n flstmtitem_type_id,\n flstmtitem_parent_id,\n flstmtitem_accnt_id,\n flstmtitem_name,\n formatMoney(flstmtitem_month) AS flstmtitem_month,\n formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n formatMoney(flstmtitem_year) AS flstmtitem_year,\n formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(<? value("flcol_id") ?>,<? value("period_id") ?>,\n<? if exists("shownumbers") ?>\n true\n<? else ?>\n false\n<? endif ?>\n,True,<? value("prj_id") ?>)\n<? if not exists("showzeros") ?>\n WHERE ((flstmtitem_month <> 0) OR (flstmtitem_monthbudget <> 0) OR (flstmtitem_type <> 'I'))\n<? endif ?>\n;\n \n \n notes\n SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (flnotes_period_id=<? value("period_id") ?>)\n AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n\n\n \n \n 167\n \n \n \n \n 380\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n 500\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n 100\n 100\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n flstmthead_typedescrip1\n \n \n \n \n 380\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n \n 580\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n 3.0775\n 165\n 748.368\n 165\n 2\n \n \n \n 100\n 80\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_name\n \n \n \n \n 660\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n \n \n \n 99\n 59.6\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n prj_name\n \n \n \n \n 15\n 59.5\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n project\n \n \n \n \n \n 4\n \n \n 37\n \n \n 500\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n \n 660\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_year\n \n \n \n \n \n \n \n 380\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n 1.53875\n 35\n 749.873\n 35\n 2\n \n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_year\n \n \n \n \n 380\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n
\n detail\n \n subgrp\n flstmtitem_subgrp\n \n 4\n \n 380\n 1\n 740\n 1\n 0\n \n \n \n \n \n detail\n \n 19\n \n \n 500\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_monthbudget\n \n \n \n \n 380\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_month\n \n \n \n \n 660\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_monthbudgetdiffprcnt\n \n \n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_monthbudgetdiff\n \n \n \n \n 25\n 0\n 345\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_name\n \n \n \n
\n
\n notes\n \n \n notes\n \n 24\n \n \n 25\n 9\n 700\n 15\n \n 0\n \n Arial\n 9\n normal\n \n \n \n \n notes\n notes\n \n \n \n
\n \n 22\n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 695\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 7\n \n
\n 0 2015-10-01 17:15:58.47729 343 FinancialReportMonthDbCr \N \n\n Financial Report Month with Debits and Credits\n FinancialReportMonthDbCr\n \n \n Financial Report Column Layout\n SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))\n \n \n Accounting Period Reference\n SELECT period_id, \n CASE\n WHEN period_name <> '' THEN period_name \n ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n END \nFROM period \nORDER BY period_end DESC\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT \n <? value("project") ?> AS project,\n (SELECT prj_name FROM prj WHERE prj_id=<? value("prj_id") ?>) AS prj_name,\n flstmthead_username,\n flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n flstmthead_typedescrip1,\n flstmthead_typedescrip2,\n flstmthead_month,\n flstmthead_qtr,\n flstmthead_year,\n flstmthead_prmonth,\n flstmthead_prqtr,\n flstmthead_pryear\nFROM getflstmthead(<? value("flcol_id") ?>,<? value("period_id") ?>)\n \n \n detail\n SELECT \n flstmtitem_flhead_id,\n flstmtitem_period_id,\n flstmtitem_username,\n flstmtitem_order,\n flstmtitem_level,\n flstmtitem_subgrp,\n flstmtitem_type,\n flstmtitem_type_id,\n flstmtitem_parent_id,\n flstmtitem_accnt_id,\n flstmtitem_name,\n formatMoney(flstmtitem_month) AS flstmtitem_month,\n formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n formatMoney(flstmtitem_year) AS flstmtitem_year,\n formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(<? value("flcol_id") ?>,<? value("period_id") ?>,\n<? if exists("shownumbers") ?>\n true\n<? else ?>\n false\n<? endif ?>\n,True,<? value("prj_id") ?>)\n<? if not exists("showzeros") ?>\n WHERE ((flstmtitem_monthdb <> 0) OR (flstmtitem_monthcr <> 0) OR (flstmtitem_type <> 'I'))\n<? endif ?>\n;\n \n \n notes\n SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (flnotes_period_id=<? value("period_id") ?>)\n AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n\n \n \n 167\n \n \n 590\n 145\n 75\n 16\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 100\n 100\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n flstmthead_typedescrip1\n \n \n \n 2.62279\n 160\n 749\n 160\n 2\n \n \n \n 100\n 80\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_name\n \n \n \n \n \n \n \n 670\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n \n 505\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n \n 425\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n \n 590\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n 100\n 60\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n prj_name\n \n \n \n \n 15\n 60\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n project\n \n \n \n \n \n \n 4\n \n \n 37\n \n 1.94814\n 31\n 748.325\n 31\n 2\n \n \n \n \n 670\n 16\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_typedescrip_prcnt\n \n \n \n \n 505\n 1\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n 670\n 1\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n 425\n 1\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n 590\n 1\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n 590\n 16\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n \n
\n detail\n \n subgrp\n flstmtitem_subgrp\n \n 4\n \n 390\n 0\n 750\n 0\n 0\n \n \n \n \n \n detail\n \n 19\n \n \n 420\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_monthdb\n \n \n \n \n 590\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_month\n \n \n \n \n 505\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_monthcr\n \n \n \n \n 670\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_monthprcnt\n \n \n \n \n 25\n 0\n 390\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_name\n \n \n \n
\n
\n notes\n \n \n notes\n \n 24\n \n \n 25\n 10\n 700\n 15\n \n 0\n \n Arial\n 9\n normal\n \n \n \n \n notes\n notes\n \n \n \n
\n \n 22\n \n \n \n \n 695\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 7\n \n
\n 0 2015-10-01 17:15:58.47729 333 FinancialReportMonthPriorMonth \N \n\n Financial Report Month and Prior Month\n FinancialReportMonthPriorMonth\n \n \n Financial Report Column Layout\n SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))\n \n \n Accounting Period Reference\n SELECT period_id, \n CASE\n WHEN period_name <> '' THEN period_name \n ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n END \nFROM period \nORDER BY period_end DESC\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT \n <? value("project") ?> AS project,\n (SELECT prj_name FROM prj WHERE prj_id=<? value("prj_id") ?>) AS prj_name,\n flstmthead_username,\n flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n flstmthead_typedescrip1,\n flstmthead_typedescrip2,\n flstmthead_typedescrip2 || ' Diff.' AS f_diff,\n flstmthead_typedescrip2 || ' % Diff.' AS f_diffprcnt,\n flstmthead_month,\n flstmthead_qtr,\n flstmthead_year,\n flstmthead_prmonth,\n flstmthead_prqtr,\n flstmthead_pryear\nFROM getflstmthead(<? value("flcol_id") ?>,<? value("period_id") ?>)\n \n \n detail\n SELECT \n flstmtitem_flhead_id,\n flstmtitem_period_id,\n flstmtitem_username,\n flstmtitem_order,\n flstmtitem_level,\n flstmtitem_subgrp,\n flstmtitem_type,\n flstmtitem_type_id,\n flstmtitem_parent_id,\n flstmtitem_accnt_id,\n flstmtitem_name,\n formatMoney(flstmtitem_month) AS flstmtitem_month,\n formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n formatMoney(flstmtitem_year) AS flstmtitem_year,\n formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(<? value("flcol_id") ?>,<? value("period_id") ?>,\n<? if exists("shownumbers") ?>\n true\n<? else ?>\n false\n<? endif ?>\n,True,<? value("prj_id") ?>)\n<? if not exists("showzeros") ?>\n WHERE ((flstmtitem_month <> 0) OR (flstmtitem_prmonth <> 0) OR (flstmtitem_type <> 'I'))\n<? endif ?>\n;\n \n \n notes\n SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (flnotes_period_id=<? value("period_id") ?>)\n AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n\n \n \n 170\n \n 2.82315\n 160.942\n 760\n 160.942\n 2\n \n \n \n 100\n 80\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_name\n \n \n \n \n 500\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_prmonth\n \n \n \n \n 380\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n 580\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_prmonth\n \n \n \n \n \n 100\n 100\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n flstmthead_typedescrip1\n \n \n \n \n 380\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n \n 660\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_diffprcnt\n \n \n \n \n 660\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_prmonth\n \n \n \n \n 500\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n \n \n 580\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_diff\n \n \n \n \n 99\n 59.6\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n prj_name\n \n \n \n \n 15\n 59.5\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n project\n \n \n \n \n \n 7\n \n \n 40\n \n \n 660\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_prmonth\n \n \n \n \n 500\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_prmonth\n \n \n \n \n 500\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_prmonth\n \n \n \n \n \n 380\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n 380\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 660\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_diffprcnt\n \n \n \n \n 580\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_diff\n \n \n \n 0.0790882\n 31.4959\n 747.149\n 31.4959\n 2\n \n \n
\n detail\n \n subgrp\n flstmtitem_subgrp\n \n 7\n \n 380\n 1\n 740\n 1\n 0\n \n \n \n \n \n detail\n \n 22\n \n \n 500\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_prmonth\n \n \n \n \n 25\n 0\n 345\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_name\n \n \n \n \n 380\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_month\n \n \n \n \n 660\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_prmonthdiffprcnt\n \n \n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_prmonthdiff\n \n \n \n
\n
\n notes\n \n \n notes\n \n 24\n \n \n 25\n 9\n 700\n 15\n \n 0\n \n Arial\n 9\n normal\n \n \n \n \n notes\n notes\n \n \n \n
\n \n 25\n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 695\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 10\n \n
\n 0 2015-10-01 17:15:58.47729 342 FinancialReportMonthPriorQuarter \N \n\n Financial Report Month and Prior Quarter\n FinancialReportMonthPriorQuarter\n \n \n Financial Report Column Layout\n SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))\n \n \n Accounting Period Reference\n SELECT period_id, \n CASE\n WHEN period_name <> '' THEN period_name \n ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n END \nFROM period \nORDER BY period_end DESC\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT \n <? value("project") ?> AS project,\n (SELECT prj_name FROM prj WHERE prj_id=<? value("prj_id") ?>) AS prj_name,\n flstmthead_username,\n flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n flstmthead_typedescrip1,\n flstmthead_typedescrip2,\n flstmthead_typedescrip2 || 'Diff.' AS f_diff,\n flstmthead_typedescrip2 || ' % Diff.' AS f_diffprcnt,\n flstmthead_month,\n flstmthead_qtr,\n flstmthead_year,\n flstmthead_prmonth,\n flstmthead_prqtr,\n flstmthead_pryear\nFROM getflstmthead(<? value("flcol_id") ?>,<? value("period_id") ?>)\n \n \n detail\n SELECT \n flstmtitem_flhead_id,\n flstmtitem_period_id,\n flstmtitem_username,\n flstmtitem_order,\n flstmtitem_level,\n flstmtitem_subgrp,\n flstmtitem_type,\n flstmtitem_type_id,\n flstmtitem_parent_id,\n flstmtitem_accnt_id,\n flstmtitem_name,\n formatMoney(flstmtitem_month) AS flstmtitem_month,\n formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n formatMoney(flstmtitem_year) AS flstmtitem_year,\n formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(<? value("flcol_id") ?>,<? value("period_id") ?>,\n<? if exists("shownumbers") ?>\n true\n<? else ?>\n false\n<? endif ?>\n,True,<? value("prj_id") ?>)\n<? if not exists("showzeros") ?>\n WHERE ((flstmtitem_month <> 0) OR (flstmtitem_prqtr <> 0) OR (flstmtitem_type <> 'I'))\n<? endif ?>\n;\n \n \n notes\n SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (flnotes_period_id=<? value("period_id") ?>)\n AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n\n \n \n 169\n \n \n 100\n 80\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_name\n \n \n \n \n 500\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n \n 100\n 100\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n flstmthead_typedescrip1\n \n \n \n \n \n 500\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_prqtr\n \n \n \n \n \n \n 660\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_prqtr\n \n \n \n \n 580\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_prqtr\n \n \n \n \n 380\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n 2.16957\n 162\n 750\n 162\n 2\n \n \n \n 580\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_diff\n \n \n \n \n 660\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_diffprcnt\n \n \n \n \n 380\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n 99\n 59.6\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n prj_name\n \n \n \n \n 15\n 59.5\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n project\n \n \n \n \n \n 6\n \n \n 39\n \n \n 380\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 500\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_prqtr\n \n \n \n \n 380\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n 660\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_prqtr\n \n \n \n \n 660\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_diffprcnt\n \n \n \n 1.79722\n 31\n 749.933\n 31\n 2\n \n \n \n \n 580\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_diff\n \n \n \n \n 500\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_prqtr\n \n \n \n
\n detail\n \n subgrp\n flstmtitem_subgrp\n \n 6\n \n 380\n 1\n 740\n 1\n 0\n \n \n \n \n \n detail\n \n 21\n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_prqtrdiff\n \n \n \n \n 25\n 0\n 345\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_name\n \n \n \n \n 380\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_month\n \n \n \n \n 500\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_prqtr\n \n \n \n \n 660\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_prqtrdiffprcnt\n \n \n \n
\n
\n notes\n \n \n notes\n \n 24\n \n \n 25\n 9\n 700\n 15\n \n 0\n \n Arial\n 9\n normal\n \n \n \n \n notes\n notes\n \n \n \n
\n \n 24\n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 695\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 9\n \n
\n 0 2015-10-01 17:15:58.47729 334 FinancialReportMonthPriorYear \N \n\n Financial Report Month and Prior Year\n FinancialReportMonthPriorYear\n \n \n Financial Report Column Layout\n SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))\n \n \n Accounting Period Reference\n SELECT period_id, \n CASE\n WHEN period_name <> '' THEN period_name \n ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n END \nFROM period \nORDER BY period_end DESC\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT \n <? value("project") ?> AS project,\n (SELECT prj_name FROM prj WHERE prj_id=<? value("prj_id") ?>) AS prj_name,\n flstmthead_username,\n flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n flstmthead_typedescrip1,\n flstmthead_typedescrip2,\n flstmthead_typedescrip2 || ' Diff.' AS f_diff,\n flstmthead_typedescrip2 || ' % Diff.' AS f_diffprcnt,\n flstmthead_month,\n flstmthead_qtr,\n flstmthead_year,\n flstmthead_prmonth,\n flstmthead_prqtr,\n flstmthead_pryear\nFROM getflstmthead(<? value("flcol_id") ?>,<? value("period_id") ?>)\n \n \n detail\n SELECT \n flstmtitem_flhead_id,\n flstmtitem_period_id,\n flstmtitem_username,\n flstmtitem_order,\n flstmtitem_level,\n flstmtitem_subgrp,\n flstmtitem_type,\n flstmtitem_type_id,\n flstmtitem_parent_id,\n flstmtitem_accnt_id,\n flstmtitem_name,\n formatMoney(flstmtitem_month) AS flstmtitem_month,\n formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n formatMoney(flstmtitem_year) AS flstmtitem_year,\n formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(<? value("flcol_id") ?>,<? value("period_id") ?>,\n<? if exists("shownumbers") ?>\n true\n<? else ?>\n false\n<? endif ?>\n,True,<? value("prj_id") ?>)\n<? if not exists("showzeros") ?>\n WHERE ((flstmtitem_month <> 0) OR (flstmtitem_pryear <> 0) OR (flstmtitem_type <> 'I'))\n<? endif ?>\n;\n \n \n notes\n SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (flnotes_period_id=<? value("period_id") ?>)\n AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n\n \n \n 169\n \n \n \n 660\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_pryear\n \n \n \n \n 100\n 100\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n flstmthead_typedescrip1\n \n \n \n \n 380\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n 0.998194\n 160\n 750\n 160\n 2\n \n \n \n \n 100\n 80\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_name\n \n \n \n \n \n 500\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_pryear\n \n \n \n \n 380\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n 580\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_diff\n \n \n \n \n 500\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n \n 580\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_pryear\n \n \n \n \n 660\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_diffprcnt\n \n \n \n \n 99\n 59.6\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n prj_name\n \n \n \n \n 15\n 59.5\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n project\n \n \n \n \n \n 6\n \n \n 39\n \n \n 380\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 660\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_diffprcnt\n \n \n \n \n 500\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_pryear\n \n \n \n \n 500\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_pryear\n \n \n \n 1.55252\n 30\n 751\n 30\n 2\n \n \n \n 580\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_diff\n \n \n \n \n 380\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n 660\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_pryear\n \n \n \n
\n detail\n \n subgrp\n flstmtitem_subgrp\n \n 6\n \n 380\n 1\n 740\n 1\n 0\n \n \n \n \n \n detail\n \n 21\n \n \n 660\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_pryeardiffprcnt\n \n \n \n \n 25\n 0\n 345\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_name\n \n \n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_pryeardiff\n \n \n \n \n 500\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_pryear\n \n \n \n \n 380\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_month\n \n \n \n
\n
\n notes\n \n \n notes\n \n 24\n \n \n 25\n 9\n 700\n 15\n \n 0\n \n Arial\n 9\n normal\n \n \n \n \n notes\n notes\n \n \n \n
\n \n 24\n \n \n 695\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 9\n \n
\n 0 2015-10-01 17:15:58.47729 335 FinancialReportMonthQuarter \N \n\n Financial Report Month and Quarter\n FinancialReportMonthQuarter\n \n \n Financial Report Column Layout\n SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))\n \n \n Accounting Period Reference\n SELECT period_id, \n CASE\n WHEN period_name <> '' THEN period_name \n ELSE (formatdate(period_start) || '-' || formatdate(period_end)) \n END \nFROM period \nORDER BY period_end DESC\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT \n <? value("project") ?> AS project,\n (SELECT prj_name FROM prj WHERE prj_id=<? value("prj_id") ?>) AS prj_name,\n flstmthead_username,\n flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,\n flstmthead_typedescrip1,\n flstmthead_typedescrip2,\n flstmthead_month,\n flstmthead_qtr,\n flstmthead_year,\n flstmthead_prmonth,\n flstmthead_prqtr,\n flstmthead_pryear\nFROM getflstmthead(<? value("flcol_id") ?>,<? value("period_id") ?>)\n \n \n detail\n SELECT \n flstmtitem_flhead_id,\n flstmtitem_period_id,\n flstmtitem_username,\n flstmtitem_order,\n flstmtitem_level,\n flstmtitem_subgrp,\n flstmtitem_type,\n flstmtitem_type_id,\n flstmtitem_parent_id,\n flstmtitem_accnt_id,\n flstmtitem_name,\n formatMoney(flstmtitem_month) AS flstmtitem_month,\n formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,\n formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,\n formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,\n formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,\n formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,\n formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,\n formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,\n formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,\n formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,\n formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,\n formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,\n formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,\n formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,\n formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,\n formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,\n formatMoney(flstmtitem_year) AS flstmtitem_year,\n formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,\n formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,\n formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,\n formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,\n formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,\n formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,\n formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,\n formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,\n formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,\n formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,\n formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,\n formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,\n formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,\n formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,\n formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,\n formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,\n formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,\n formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,\n formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt\nFROM financialreport(<? value("flcol_id") ?>,<? value("period_id") ?>,\n<? if exists("shownumbers") ?>\n true\n<? else ?>\n false\n<? endif ?>\n,True,<? value("prj_id") ?>)\n<? if not exists("showzeros") ?>\n WHERE ((flstmtitem_month <> 0) OR (flstmtitem_qtr <> 0) OR (flstmtitem_type <> 'I'))\n<? endif ?>\n;\n \n \n notes\n SELECT * FROM (\nSELECT 1 AS seq, flhead_notes AS notes\nFROM flhead\n JOIN flcol ON (flhead_id=flcol_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (length(flhead_notes) > 0))\nUNION ALL\nSELECT 2 AS seq, flnotes_notes AS notes\nFROM flnotes\n JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)\nWHERE ((flcol_id=<? value("flcol_id") ?>)\n AND (flnotes_period_id=<? value("period_id") ?>)\n AND (length(flnotes_notes) > 0))) data\nORDER BY seq;\n\n \n \n 167\n \n \n 0.00540306\n 162.686\n 749.477\n 162.686\n 2\n \n \n \n 580\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n \n 380\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n 100\n 80\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_name\n \n \n \n \n 380\n 145\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n 459\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n 100\n 100\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n flstmthead_typedescrip1\n \n \n \n \n \n \n 580\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_qtr\n \n \n \n \n \n 660\n 130\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_qtr\n \n \n \n \n \n 99\n 59.6\n 459\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n prj_name\n \n \n \n \n 15\n 59.5\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n project\n \n \n \n \n \n 4\n \n \n 37\n \n \n 380\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n 0.393337\n 30\n 750\n 30\n 2\n \n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_qtr\n \n \n \n \n 380\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n \n 660\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_qtr\n \n \n \n \n 459\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_month\n \n \n \n \n 580\n 15\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n flstmthead_typedescrip2\n \n \n \n \n \n
\n detail\n \n subgrp\n flstmtitem_subgrp\n \n 4\n \n 380\n 1\n 740\n 1\n 0\n \n \n \n \n \n detail\n \n 19\n \n \n 660\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_qtrprcnt\n \n \n \n \n 459\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_monthprcnt\n \n \n \n \n 25\n 0\n 345\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_name\n \n \n \n \n 580\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_qtr\n \n \n \n \n 380\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n flstmtitem_month\n \n \n \n
\n
\n notes\n \n \n notes\n \n 24\n \n \n 25\n 9\n 700\n 15\n \n 0\n \n Arial\n 9\n normal\n \n \n \n \n notes\n notes\n \n \n \n
\n \n 22\n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 695\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 7\n \n
\n 0 2015-10-01 17:15:58.47729 76 FreightAccountAssignmentsMasterList \N \n\n A/R Account Assignments Master List\n FreightAccountAssignmentsMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT CASE WHEN araccnt_custtype_id=-1 THEN araccnt_custtype\n ELSE (SELECT custtype_code FROM custtype WHERE (custtype_id=araccnt_custtype_id))\n END AS custtypecode,\n formatGLAccount(araccnt_ar_accnt_id) AS f_araccnt,\n formatGLAccount(araccnt_freight_accnt_id) as f_freightaccnt,\n formatGLAccount(araccnt_prepaid_accnt_id) AS f_prepaidaccnt,\n formatGLAccount(araccnt_deferred_accnt_id) AS f_deferredaccnt\nFROM araccnt \nORDER BY custtypecode;\n \n \n 88\n \n 5\n 80\n 745\n 80\n 2\n \n \n \n \n \n \n \n \n \n \n 8\n \n \n 28\n \n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 19\n \n \n 290\n 1\n 125\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_freightaccnt\n \n \n \n \n 5\n 0\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n custtypecode\n \n \n \n \n 130\n 0\n 125\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_araccnt\n \n \n \n \n 610\n 1\n 125\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_deferredaccnt\n \n \n \n \n 450\n 1\n 125\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_prepaidaccnt\n \n \n \n
\n \n 18\n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 406 FreightClassesMasterList \N \n\n Freight Classes Master List\n FreightClassesMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n select freightclass_code, freightclass_descrip\n from freightclass\norder by freightclass_code;\n \n \n 76\n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n 6\n \n \n 21\n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 175\n 0\n 565\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n freightclass_descrip\n \n \n \n \n 10\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n freightclass_code\n \n \n \n
\n \n 16\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 408 FreightPricesByCustomer \N \n\n Freight Prices By Customer\n FreightPricesByCustomer\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT cust_name,\n addr_line1 AS cust_address1,\n addr_line2 AS cust_address2,\n addr_line3 AS cust_address3,\n <? if exists("showExpired") ?>\n text('Yes')\n <? else ?>\n text('No')\n <? endif ?>\n AS f_showexpired,\n <? if exists("showFuture") ?>\n text('Yes')\n <? else ?>\n text('No')\n <? endif ?>\n AS f_showfuture\n FROM custinfo\n LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\nWHERE (cust_id=<? value("cust_id") ?>);\n\n \n \n detail\n SELECT itemid, sourcetype, ipshead_name, source,\n formatQty(ipsfreight_qtybreak) AS f_qtybreak,\n formatSalesPrice(ipsfreight_price) AS f_price,\n CASE WHEN (ipsfreight_type = 'F') THEN 'Flat Rate'\n ELSE 'Per UOM'\n END AS method,\n currConcat(ipshead_curr_id) AS currConcat,\n CASE WHEN (warehous_code IS NULL) THEN 'Any' ELSE warehous_code END AS f_warehous,\n CASE WHEN (shipzone_name IS NULL) THEN 'Any' ELSE shipzone_name END AS f_shipzone,\n CASE WHEN (freightclass_code IS NULL) THEN 'Any' ELSE freightclass_code END AS f_freightclass,\n CASE WHEN (ipsfreight_shipvia IS NULL) THEN 'Any' ELSE ipsfreight_shipvia END AS f_shipvia\n\nFROM ( SELECT ipsfreight_id AS itemid, 1 AS sourcetype,\n ipshead_name, 'Customer' AS source,\n ipsfreight_qtybreak, ipsfreight_price,\n ipsfreight_type, ipshead_curr_id,\n warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\nFROM ipsass JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\nWHERE ( (ipsass_cust_id=<? value("cust_id") ?>)\n AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) = 0)\n\n<? if not exists("showExpired") ?>\n AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n\n)\nUNION SELECT ipsfreight_id AS itemid, 2 AS sourcetype,\n ipshead_name, 'CustType' AS source,\n ipsfreight_qtybreak, ipsfreight_price,\n ipsfreight_type, ipshead_curr_id,\n warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\nFROM ipsass JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n JOIN custinfo ON (cust_custtype_id=ipsass_custtype_id)\n LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\nWHERE ( (cust_id=<? value("cust_id") ?>)\n \n<? if not exists("showExpired") ?>\n AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n\n)\nUNION SELECT ipsfreight_id AS itemid, 3 AS sourcetype,\n ipshead_name, 'CustTypePattern' AS source,\n ipsfreight_qtybreak, ipsfreight_price,\n ipsfreight_type, ipshead_curr_id,\n warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\nFROM custinfo JOIN custtype ON (custtype_id=cust_custtype_id)\n JOIN ipsass ON ((coalesce(length(ipsass_custtype_pattern), 0) > 0) AND\n (custtype_code ~ ipsass_custtype_pattern))\n JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\nWHERE ( (cust_id=<? value("cust_id") ?>)\n \n<? if not exists("showExpired") ?>\n AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n\n)\nUNION SELECT ipsfreight_id AS itemid, 4 AS sourcetype,\n ipshead_name, ('Sale' || '-' || sale_name) AS source,\n ipsfreight_qtybreak, ipsfreight_price,\n ipsfreight_type, ipshead_curr_id,\n warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\nFROM sale JOIN ipshead ON (ipshead_id=sale_ipshead_id)\n JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\nWHERE ((TRUE)\n \n<? if not exists("showExpired") ?>\n AND (sale_enddate > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (sale_startdate <= CURRENT_DATE)\n<? endif ?>\n\n) ) AS data\nORDER BY ipsfreight_qtybreak, ipsfreight_price;\n \n \n 234\n \n \n 100\n 140\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_address3\n \n \n \n \n \n \n \n 565\n 100\n 113\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_showexpired\n \n \n \n \n \n 100\n 120\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_address2\n \n \n \n \n \n \n \n 565\n 120\n 113\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_showfuture\n \n \n \n \n \n \n \n 100\n 80\n 605\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_name\n \n \n \n \n 100\n 100\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_address1\n \n \n \n 5\n 228\n 745\n 228\n 2\n \n \n \n \n \n \n \n \n 6\n \n \n 41\n \n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 56\n \n \n 150\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_price\n \n \n \n 5\n 50\n 745\n 50\n 0\n \n \n \n 480\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_freightclass\n \n \n \n \n 245\n 15\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n currConcat\n \n \n \n \n 10\n 0\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ipshead_name\n \n \n \n \n 10\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n source\n \n \n \n \n 360\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_warehous\n \n \n \n \n 360\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_shipzone\n \n \n \n \n 245\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n method\n \n \n \n \n 480\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_shipvia\n \n \n \n \n 150\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtybreak\n \n \n \n
\n \n 16\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 407 FreightPricesByCustomerType \N \n\n Freight Prices By Customer Type\n FreightPricesByCustomerType\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT (custtype_code || '-' || custtype_descrip) as custtype,\n <? if exists("showExpired") ?>\n text('Yes')\n <? else ?>\n text('No')\n <? endif ?>\n AS f_showexpired,\n <? if exists("showFuture") ?>\n text('Yes')\n <? else ?>\n text('No')\n <? endif ?>\n AS f_showfuture\n FROM custtype\n WHERE (custtype_id=<? value("custtype_id") ?>);\n\n \n \n detail\n SELECT itemid, sourcetype, ipshead_name, source,\n formatQty(ipsfreight_qtybreak) AS f_qtybreak,\n formatSalesPrice(ipsfreight_price) AS f_price,\n CASE WHEN (ipsfreight_type = 'F') THEN 'Flat Rate'\n ELSE 'Per UOM'\n END AS method,\n currConcat(ipshead_curr_id) AS currConcat,\n CASE WHEN (warehous_code IS NULL) THEN 'Any' ELSE warehous_code END AS f_warehous,\n CASE WHEN (shipzone_name IS NULL) THEN 'Any' ELSE shipzone_name END AS f_shipzone,\n CASE WHEN (freightclass_code IS NULL) THEN 'Any' ELSE freightclass_code END AS f_freightclass,\n CASE WHEN (ipsfreight_shipvia IS NULL) THEN 'Any' ELSE ipsfreight_shipvia END AS f_shipvia\n\nFROM ( SELECT ipsfreight_id AS itemid, 1 AS sourcetype,\n ipshead_name, 'CustType' AS source,\n ipsfreight_qtybreak, ipsfreight_price,\n ipsfreight_type, ipshead_curr_id,\n warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\nFROM ipsass JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\nWHERE ( (ipsass_custtype_id=<? value("custtype_id") ?>)\n \n<? if not exists("showExpired") ?>\n AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n\n)\nUNION SELECT ipsfreight_id AS itemid, 2 AS sourcetype,\n ipshead_name, 'CustTypePattern' AS source,\n ipsfreight_qtybreak, ipsfreight_price,\n ipsfreight_type, ipshead_curr_id,\n warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\nFROM custtype JOIN ipsass ON ((coalesce(length(ipsass_custtype_pattern), 0) > 0) AND\n (custtype_code ~ ipsass_custtype_pattern))\n JOIN ipshead ON (ipshead_id=ipsass_ipshead_id)\n JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\nWHERE ( (custtype_id=<? value("custtype_id") ?>)\n \n<? if not exists("showExpired") ?>\n AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n\n)\nUNION SELECT ipsfreight_id AS itemid, 3 AS sourcetype,\n ipshead_name, ('Sale' || '-' || sale_name) AS source,\n ipsfreight_qtybreak, ipsfreight_price,\n ipsfreight_type, ipshead_curr_id,\n warehous_code, shipzone_name, freightclass_code, ipsfreight_shipvia\nFROM sale JOIN ipshead ON (ipshead_id=sale_ipshead_id)\n JOIN ipsfreight ON (ipsfreight_ipshead_id=ipshead_id)\n LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id)\n LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id)\n LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id)\nWHERE ((TRUE)\n\n<? if not exists("showExpired") ?>\n AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n\n) ) AS data\nORDER BY ipsfreight_qtybreak, ipsfreight_price;\n\n \n \n 233\n \n \n \n \n \n \n \n \n \n 565\n 100\n 112\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_showexpired\n \n \n \n \n \n 565\n 120\n 112\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_showfuture\n \n \n \n \n 5\n 227\n 745\n 227\n 2\n \n \n \n \n \n 125\n 80\n 535\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n custtype\n \n \n \n \n \n \n \n \n 6\n \n \n 41\n \n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 56\n \n \n 360\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_shipzone\n \n \n \n \n 245\n 15\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n currConcat\n \n \n \n \n 480\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_shipvia\n \n \n \n \n 150\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_price\n \n \n \n \n 10\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n source\n \n \n \n \n 245\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n method\n \n \n \n \n 360\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_warehous\n \n \n \n \n 10\n 0\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ipshead_name\n \n \n \n 5\n 50\n 745\n 50\n 0\n \n \n \n 150\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtybreak\n \n \n \n \n 480\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_freightclass\n \n \n \n
\n \n 16\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 33 FrozenItemSites \N \n\n Frozen Item Sites\n FrozenItemSites\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse;\n\n \n \n detail\n SELECT warehous_code,\n formatBoolYN(itemsite_active) AS active,\n item_number,\n item_descrip1,\n item_descrip2,\n formatBoolYN(itemsite_wosupply) AS supplied,\n formatBoolYN(itemsite_sold) AS sold,\n itemsite_soldranking,\n formatBoolYN(itemsite_stocked) AS stocked,\n formatBoolYN(itemsite_createpr) AS createpr,\n CASE WHEN (itemsite_controlmethod='N') THEN 'None'\n WHEN (itemsite_controlmethod='R') THEN 'Regular'\n WHEN (itemsite_controlmethod='L') THEN 'Lot #'\n WHEN (itemsite_controlmethod='S') THEN 'Serial #'\n ELSE '?'\n END AS controlmethod,\n formatBoolYN(itemsite_loccntrl) AS locationcontrol,\n CASE WHEN (itemsite_location_id=-1) THEN 'None'\n ELSE formatLocationName(itemsite_location_id)\n END AS defaultlocation,\n formatBoolYN(itemsite_useparams) AS enforceparams,\n formatBoolYN(itemsite_useparamsmanual) AS onmanualorders,\n formatQty(itemsite_reorderlevel) AS reorderlevel,\n formatQty(itemsite_ordertoqty) AS orderupto,\n formatQty(itemsite_multordqty) AS ordermult,\n formatQty(itemsite_safetystock) AS safetystock,\n itemsite_abcclass,\n itemsite_cyclecountfreq,\n itemsite_leadtime,\n itemsite_eventfence,\n formatQty(itemsite_qtyonhand) AS qoh,\n formatDate(itemsite_datelastused, 'Never') AS lastused,\n formatDate(itemsite_datelastcount, 'Never') AS lastcounted,\n COALESCE((SELECT invcnt_tagnumber\n FROM invcnt\n WHERE ((NOT invcnt_posted)\n AND (invcnt_itemsite_id=itemsite_id))), '') AS counttagnum\nFROM itemsite, whsinfo, item\nWHERE ((itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (itemsite_freeze)\n<? if exists("warehous_id") ?>\n AND (warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n)\nORDER BY item_number;\n \n \n 236\n \n \n \n \n \n \n \n \n \n 5\n 229\n 745\n 229\n 2\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 114\n 80\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n \n \n \n \n \n \n \n 7\n \n \n 81\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 5\n 75\n 745\n 75\n 2\n \n \n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 81\n \n \n 50\n 15\n 229\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 50\n 0\n 229\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 280\n 30\n 45\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n stocked\n \n \n \n \n 50\n 30\n 229\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 670\n 45\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemsite_eventfence\n \n \n \n \n 490\n 15\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n onmanualorders\n \n \n \n \n 430\n 60\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n lastcounted\n \n \n \n \n 670\n 0\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemsite_abcclass\n \n \n \n \n 260\n 60\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qoh\n \n \n \n \n 580\n 60\n 145\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n counttagnum\n \n \n \n \n 330\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n createpr\n \n \n \n \n 580\n 30\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ordermult\n \n \n \n \n 670\n 30\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemsite_leadtime\n \n \n \n \n 409\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n locationcontrol\n \n \n \n \n 280\n 0\n 45\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n supplied\n \n \n \n \n 280\n 15\n 45\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n sold\n \n \n \n \n 10\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n reorderlevel\n \n \n \n \n 345\n 60\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n lastused\n \n \n \n \n 409\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n controlmethod\n \n \n \n \n 580\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n orderupto\n \n \n \n \n 409\n 30\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n defaultlocation\n \n \n \n \n 580\n 45\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n safetystock\n \n \n \n \n 490\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n enforceparams\n \n \n \n \n 10\n 15\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n active\n \n \n \n 5\n 75\n 745\n 75\n 0\n \n \n \n 670\n 15\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemsite_cyclecountfreq\n \n \n \n \n 330\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemsite_soldranking\n \n \n \n
\n \n 16\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 242 GLSeries \N \n\n G/L Series\n GLSeries\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? value("title") ?> AS title,\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("sourceLit") ?>\n text(<? value("sourceLit") ?>)\n <? else ?>\n text('All Sources')\n <? endif ?>\n AS sourceLit,\n <? if exists("startJrnlnum") ?>\n text('Start Journal Number:')\n <? else ?>\n text('')\n <? endif ?>\n AS startJrnlnumLit,\n <? if exists("endJrnlnum") ?>\n text('End Journal Number:')\n <? else ?>\n text('')\n <? endif ?>\n AS endJrnlnumLit;\n \n \n detail\n <? if exists("gltrans") ?>\nSELECT gltrans_id,\n gltrans_sequence,\n formatDate(gltrans_date) AS transdate,\n gltrans_journalnumber,\n gltrans_source,\n gltrans_doctype,\n gltrans_docnumber,\n (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n firstLine(gltrans_notes) AS f_notes,\n CASE WHEN (gltrans_amount < 0) THEN formatMoney(gltrans_amount * -1)\n ELSE ''\n END AS f_debit,\n CASE WHEN (gltrans_amount > 0) THEN formatMoney(gltrans_amount)\n ELSE ''\n END AS f_credit,\n CASE WHEN (gltrans_amount < 0) THEN (gltrans_amount * -1)\n ELSE 0.0\n END AS debit,\n CASE WHEN (gltrans_amount > 0) THEN (gltrans_amount)\n ELSE 0.0\n END AS credit,\n formatBoolYN(gltrans_posted) AS f_posted\n FROM gltrans, accnt\n WHERE ((gltrans_accnt_id=accnt_id)\n AND (NOT gltrans_deleted)\n<? if exists("startDate") ?>\n AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("source") ?>\n AND (gltrans_source=<? value("source") ?>)\n<? endif ?>\n<? if exists("startJrnlnum") ?>\n AND (gltrans_journalnumber BETWEEN <? value("startJrnlnum") ?> AND <? value("endJrnlnum") ?>)\n<? endif ?>\n )\nORDER BY gltrans_date, gltrans_sequence, gltrans_amount DESC;\n<? else ?>\nSELECT sltrans_id AS gltrans_id,\n sltrans_sequence AS gltrans_sequence,\n formatDate(sltrans_date) AS transdate,\n sltrans_journalnumber AS gltrans_journalnumber,\n sltrans_source AS gltrans_source,\n sltrans_doctype AS gltrans_doctype,\n sltrans_docnumber AS gltrans_docnumber,\n (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n firstLine(sltrans_notes) AS f_notes,\n CASE WHEN (sltrans_amount < 0) THEN formatMoney(sltrans_amount * -1)\n ELSE ''\n END AS f_debit,\n CASE WHEN (sltrans_amount > 0) THEN formatMoney(sltrans_amount)\n ELSE ''\n END AS f_credit,\n CASE WHEN (sltrans_amount < 0) THEN (sltrans_amount * -1)\n ELSE 0.0\n END AS debit,\n CASE WHEN (sltrans_amount > 0) THEN (sltrans_amount)\n ELSE 0.0\n END AS credit,\n formatBoolYN(sltrans_posted) AS f_posted\n FROM sltrans, accnt\n WHERE ((sltrans_accnt_id=accnt_id)\n<? if exists("startDate") ?>\n AND (sltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("source") ?>\n AND (sltrans_source=<? value("source") ?>)\n<? endif ?>\n<? if exists("startJrnlnum") ?>\n AND (sltrans_journalnumber BETWEEN <? value("startJrnlnum") ?> AND <? value("endJrnlnum") ?>)\n<? endif ?>\n )\nORDER BY sltrans_date, sltrans_sequence, sltrans_amount DESC;\n<? endif ?>\n \n \n summarized\n <? if exists("gltrans") ?>\nSELECT (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n formatMoney(SUM(CASE WHEN (gltrans_amount < 0) THEN (gltrans_amount * -1)\n ELSE 0.0\n END)) AS f_debit,\n formatMoney(SUM(CASE WHEN (gltrans_amount > 0) THEN (gltrans_amount)\n ELSE 0.0\n END)) AS f_credit\n FROM gltrans, accnt\n WHERE ((gltrans_accnt_id=accnt_id)\n AND (NOT gltrans_deleted)\n<? if exists("startDate") ?>\n AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("source") ?>\n AND (gltrans_source=<? value("source") ?>)\n<? endif ?>\n<? if exists("startJrnlnum") ?>\n AND (gltrans_journalnumber BETWEEN <? value("startJrnlnum") ?> AND <? value("endJrnlnum") ?>)\n<? endif ?>\n )\nGROUP BY accnt_id, accnt_descrip\nORDER BY formatGLAccount(accnt_id);\n<? else ?>\nSELECT (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n formatMoney(SUM(CASE WHEN (sltrans_amount < 0) THEN (sltrans_amount * -1)\n ELSE 0.0\n END)) AS f_debit,\n formatMoney(SUM(CASE WHEN (sltrans_amount > 0) THEN (sltrans_amount)\n ELSE 0.0\n END)) AS f_credit\n FROM sltrans, accnt\n WHERE ((sltrans_accnt_id=accnt_id)\n<? if exists("startDate") ?>\n AND (sltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("source") ?>\n AND (sltrans_source=<? value("source") ?>)\n<? endif ?>\n<? if exists("startJrnlnum") ?>\n AND (sltrans_journalnumber BETWEEN <? value("startJrnlnum") ?> AND <? value("endJrnlnum") ?>)\n<? endif ?>\n )\nGROUP BY accnt_id, accnt_descrip\nORDER BY formatGLAccount(accnt_id);\n<? endif ?>\n \n \n 206\n \n \n \n \n \n 545\n 120\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n startJrnlnum\n \n \n \n \n 140\n 70\n 290\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n sourceLit\n \n \n \n \n \n \n \n \n 545\n 90\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n 340\n 140\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n endJrnlnumLit\n \n \n \n 5\n 200\n 745\n 200\n 2\n \n \n \n \n 545\n 70\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n 340\n 120\n 200\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n startJrnlnumLit\n \n \n \n \n 545\n 140\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n endJrnlnum\n \n \n \n \n \n 440\n 7\n 300\n 35\n \n \n Arial\n 18\n bold\n \n \n \n \n head\n title\n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n
\n detail\n \n detail\n gltrans_sequence\n \n 16\n \n \n 95\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_journalnumber\n \n \n \n \n 680\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_posted\n \n \n \n \n 160\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_doctype\n \n \n \n \n 330\n 0\n 175\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_notes\n \n \n \n \n 10\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n transdate\n \n \n \n \n 245\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_docnumber\n \n \n \n \n 95\n 15\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_source\n \n \n \n \n \n \n detail\n \n 56\n \n \n 595\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_credit\n \n \n \n \n 330\n 0\n 175\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n account\n \n \n \n \n 509\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_debit\n \n \n \n
\n
\n summarized\n \n summarized header\n \n \n 35\n \n \n \n \n \n summarized\n \n 35\n \n \n 330\n 5\n 175\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n summarized\n account\n \n \n \n \n 510\n 5\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n summarized\n f_debit\n \n \n \n \n 595\n 5\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n summarized\n f_credit\n \n \n \n
\n \n 21\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 35\n \n \n 510\n 5\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n debit\n \n %0.2f\n \n \n \n \n 595\n 5\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n credit\n \n %0.2f\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 243 GLTransactions \N \n\n G/L Transactions\n GLTransactions\n detail query modified to accomodate "Company", "Profit Center", "Account", "Sub", "Type" & "Sub-Type" filters.\n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("source") ?>\n text(<? value("source") ?>)\n <? else ?>\n text('All Sources')\n <? endif ?>\n AS source,\n <? if exists("accnt_id") ?>\n ( SELECT (accnt_number || '-' || accnt_descrip)\n FROM accnt\n WHERE (accnt_id=<? value("accnt_id") ?>) )\n <? else ?>\n text('All Accounts')\n <? endif ?>\n AS accnt,\n <? if exists("showUsernames") ?>\n text('Username')\n <? else ?>\n text('')\n <? endif ?>\n AS f_username\n \n \n detail\n <? if exists("beginningBalance") ?>\nSELECT -1 AS gltrans_id,\n <? value("startDate") ?> AS gltrans_created, formatDate(<? value("startDate") ?>) AS transdate,\n '' AS gltrans_source, '' AS gltrans_doctype, '' AS gltrans_docnumber, '' AS invhist_docnumber,\n 'Beginning Balance' AS transnotes,\n (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n '' AS f_debit,\n 0.0 AS debit_amt,\n '' AS f_credit,\n 0.0 AS credit_amt,\n <? value("beginningBalance") ?> AS balance_amt,\n <? value("beginningBalance") ?> AS gltrans_amount,\n <? value("beginningBalance") ?> AS running,\n NULL AS f_posted,\n NULL AS f_deleted,\n NULL AS f_username,\n -1 AS gltrans_sequence\n FROM accnt\n WHERE (accnt_id=<? value("accnt_id") ?>)\nUNION\n<? endif ?>\n\nSELECT gltrans_id,\n gltrans_created, formatDate(gltrans_date) AS transdate,\n gltrans_source, gltrans_doctype, gltrans_docnumber, invhist_docnumber,\n firstLine(gltrans_notes) AS transnotes,\n (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n-- Debits:\n CASE WHEN (gltrans_amount < 0 AND NOT gltrans_deleted) THEN formatMoney(ABS(gltrans_amount))\n ELSE ''\n END AS f_debit, \n CASE WHEN (gltrans_amount < 0 AND NOT gltrans_deleted) THEN ABS(gltrans_amount)\n ELSE 0\n END AS debit_amt, \n--Credits:\n CASE WHEN (gltrans_amount > 0 AND NOT gltrans_deleted) THEN formatMoney(gltrans_amount)\n ELSE ''\n END AS f_credit,\n CASE WHEN (gltrans_amount > 0 AND NOT gltrans_deleted) THEN gltrans_amount\n ELSE 0\n END AS credit_amt,\n--Balance:\n CASE WHEN (accnt_type IN ('A','E') AND NOT gltrans_deleted) THEN \n gltrans_amount * -1\n WHEN (NOT gltrans_deleted) THEN \n gltrans_amount \n ELSE 0 END AS balance_amt,\n gltrans_amount,\n CASE WHEN (accnt_type IN ('A','E') AND NOT gltrans_deleted) THEN \n gltrans_amount * -1\n WHEN (NOT gltrans_deleted) THEN \n gltrans_amount \n ELSE 0 END AS running,\n formatBoolYN(gltrans_posted) AS f_posted,\n formatBoolYN(gltrans_deleted) AS f_deleted,\n gltrans_username AS f_username,\n gltrans_sequence\nFROM gltrans JOIN accnt ON (gltrans_accnt_id=accnt_id) \n LEFT OUTER JOIN invhist ON (gltrans_misc_id=invhist_id\n AND gltrans_docnumber='Misc.') \n<? if exists("company_id") ?>\n JOIN company ON (accnt_company=company_number) \n<? endif ?>\n<? if exists("prfcntr_id") ?>\n JOIN prftcntr ON (accnt_profit=prftcntr_number) \n<? endif ?>\n<? if exists("subaccnt_id") ?>\n JOIN subaccnt ON (accnt_sub=subaccnt_number) \n<? endif ?>\n<? if exists("subType") ?>\n JOIN subaccnttype ON (subaccnttype_code=accnt_subaccnttype_code) \n<? endif ?>\nWHERE (\n<? if exists("startDate") ?>\n <? if exists("endDate") ?>\n (gltrans_date BETWEEN <? value("startDate") ?>\n AND <? value("endDate") ?>)\n <? else ?>\n (gltrans_date BETWEEN <? value("startDate") ?>\n AND endoftime())\n <? endif ?>\n<? else ?>\n <? if exists("endDate") ?>\n (gltrans_date BETWEEN startoftime()\n AND <? value("endDate") ?>)\n <? else ?>\n (gltrans_date BETWEEN startoftime()\n AND endoftime())\n <? endif ?>\n<? endif ?>\n<? if not exists("showDeleted") ?>\n AND (NOT gltrans_deleted)\n<? endif ?>\n<? if exists("company_id") ?>\n AND (company_id=<? value("company_id") ?>)\n<? endif ?>\n<? if exists("prfcntr_id") ?>\n AND (prftcntr_id=<? value("prfcntr_id") ?>)\n<? endif ?>\n<? if exists("accnt_number") ?>\n AND (accnt_number=<? value("accnt_number") ?>)\n<? endif ?>\n<? if exists("subaccnt_id") ?>\n AND (subaccnt_id=<? value("subaccnt_id") ?>)\n<? endif ?>\n<? if exists("subType") ?>\n AND (subaccnttype_id=<? value("subType") ?>)\n<? endif ?>\n<? if exists("accntType") ?>\n AND (accnt_type= <? value("accntType") ?>)\n<? endif ?>\n<? if exists("accnt_id") ?>\n AND (gltrans_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n<? if exists("docnum") ?>\n AND (gltrans_docnumber = case when <? value("docnum") ?> = '' then \n gltrans_docnumber else \n<? value("docnum") ?> end ) \n<? endif ?>\n<? if exists("source") ?>\n AND (gltrans_source=<? value("source") ?>)\n<? endif ?>\n )\nORDER BY gltrans_created <? if not exists("beginningBalance") ?> DESC <? endif ?>,\n gltrans_sequence, gltrans_amount\n\n;\n \n \n 205\n \n \n \n \n \n \n \n \n 0\n 200\n 1000\n 200\n 2\n \n \n \n \n \n \n 900\n 185\n 50\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_username\n \n \n \n \n \n \n 10\n 50\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 5\n \n \n 45\n \n \n \n \n 0\n 40\n 1000\n 40\n 2\n \n \n \n \n \n \n \n \n 900\n 25\n 50\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_username\n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 30\n \n \n 900\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_username\n \n \n \n \n 240\n 15\n 265\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n transnotes\n \n \n \n \n 960\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_posted\n \n \n \n \n 12500\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_doctype\n \n \n \n \n 125\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_doctype\n \n \n \n \n 0\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n transdate\n \n \n \n \n 65\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_source\n \n \n \n \n 180\n 15\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n invhist_docnumber\n \n \n \n \n 180\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_docnumber\n \n \n \n \n 240\n 0\n 270\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n account\n \n \n \n \n 960\n 15\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_deleted\n \n \n \n \n 540\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_debit\n \n \n \n \n 780\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n running\n \n qty\n \n \n \n \n 660\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_credit\n \n \n \n
\n \n 41\n \n \n 958\n 7\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 87\n 7\n 100\n 20\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 49\n \n 534\n 6\n 999\n 6\n 2\n \n \n \n \n \n 660\n 25\n 100\n 14\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n credit_amt\n \n money\n \n \n \n \n 540\n 25\n 100\n 14\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n debit_amt\n \n money\n \n \n \n \n 777\n 25\n 100\n 14\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n balance_amt\n \n money\n \n \n \n
\n detail query modified to accomodate "Company", "Profit Center", "Account", "Sub", "Type" & "Sub-Type" filters. 0 2015-10-01 17:15:58.47729 420 Image \N \n\n Image\n Image\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT image_name,\n image_descrip,\n image_data\n FROM image\n WHERE (image_id=<? value("image_id") ?>);\n \n \n 706\n \n \n \n \n 10\n 110\n 730\n 600\n \n stretch\n \n head\n image_data\n \n \n \n \n 130\n 65\n 360\n 15\n \n 0\n \n Arial\n 8\n bold\n \n \n \n \n head\n image_descrip\n \n \n \n \n 130\n 50\n 140\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n image_name\n \n \n \n \n \n 17\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n\n 0 2015-10-01 17:15:58.47729 428 Incident \N \n\n Incident\n Incident\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n select incdt_number, incdt_summary, \n incdt_assigned_username, incdt_status, \n incdt_owner_username, incdtseverity_name,\n incdtpriority_name, incdtcat_name,\n crmacct_name, cntct_first_name || ' ' ||cntct_last_name as f_name, \n cntct_phone, cntct_email,cntct_title\n from incdt left outer join incdtseverity on \n (incdt_incdtseverity_id = incdtseverity_id)\n left outer join incdtpriority on\n (incdt_incdtpriority_id = incdtpriority_id) \n left outer join incdtcat on\n (incdt_incdtcat_id = incdtcat_id)\n left outer join crmacct on \n (incdt_crmacct_id = crmacct_id) \n left outer join cntct on \n (incdt_cntct_id = cntct_id) \n where incdt_id = <? value("incdt_id") ?>;\n \n \n \n detail\n select incdt_descrip \n from incdt\n where incdt_id = <? value("incdt_id") ?>;\n \n \n detail2\n select comment_date, comment_user, comment_text \n from comment\n where comment_source_id = <? value("incdt_id") ?> and comment_source = 'INCDT'\norder by comment_date desc;\n \n \n detail3\n select url_title, url_url \nfrom url \nwhere url_source_id = <? value("incdt_id") ?>\nand url_source = 'INCDT'\n\n\n \n \n 268\n \n \n 136\n 57\n 598\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n incdt_summary\n \n \n \n \n 128\n 123\n 251\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_name\n \n \n \n \n 370\n 10\n 171\n 35\n \n \n Arial\n 18\n bold\n \n \n \n \n head\n incdt_number\n \n \n \n \n 540\n 144\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n incdtseverity_name\n \n \n \n \n \n 128\n 165\n 342\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cntct_title\n \n \n \n \n \n \n \n \n 540\n 187\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n incdt_owner_username\n \n \n \n \n \n \n 540\n 208\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n incdt_assigned_username\n \n \n \n \n 128\n 208\n 279\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cntct_email\n \n \n \n \n \n \n 540\n 105\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n incdtcat_name\n \n \n \n \n \n 540\n 123\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n incdt_status\n \n \n \n \n 128\n 105\n 263\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n crmacct_name\n \n \n \n \n \n 540\n 165\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n incdtpriority_name\n \n \n \n \n \n \n 128\n 144\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cntct_phone\n \n \n \n \n \n 128\n 187\n 170\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cntct_phone\n \n \n \n \n \n \n 6\n \n \n 36\n \n 5\n 30\n 745\n 30\n 2\n \n \n
\n detail\n \n \n detail\n \n 37\n \n \n 10.9\n 8\n 730\n 17\n \n 14\n \n Helvetica\n 9\n normal\n \n \n \n \n detail\n incdt_descrip\n \n \n \n
\n
\n detail2\n \n labour\n \n \n 33.9041\n \n \n 2.90454\n 3.94806\n 744.812\n 3.62203\n 1\n \n \n \n \n \n detail2\n \n 49.0959\n \n \n 10.9\n 0.621\n 150\n 20\n \n \n Helvetica\n 9\n normal\n \n \n \n \n detail2\n comment_date\n \n \n \n \n 196\n 0.621\n 150\n 20\n \n \n Arial\n 9\n normal\n \n \n \n \n detail2\n comment_user\n \n \n \n \n 10.9\n 23.1\n 730\n 17\n \n 14\n \n Helvetica\n 9\n normal\n \n \n \n \n detail2\n comment_text\n \n \n \n
\n
\n jobcost_head\n \n \n head\n \n 47.4021\n \n 4.90454\n 5.44606\n 746.812\n 5.12003\n 1\n \n \n \n \n \n
\n
\n detail3\n \n detail3_footer\n \n \n 39.6984\n \n \n \n \n detail3\n \n 28.8318\n \n \n 289\n 4.08\n 460\n 18\n \n \n Arial\n 9\n normal\n \n \n \n \n detail3\n url_url\n \n \n \n \n 10.9\n 2.9979\n 274.1\n 20\n \n \n Arial\n 9\n normal\n \n \n \n \n detail3\n url_title\n \n \n \n
\n \n 16\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 27.5186\n \n
\n 0 2015-10-01 17:15:58.47729 316 IncidentCategoriesList \N \n\n Incident Categories\n IncidentCategoriesList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT incdtcat_name, incdtcat_order, incdtcat_descrip\n FROM incdtcat\nORDER BY incdtcat_order, incdtcat_name;\n \n \n 76\n \n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n 6\n \n \n 21\n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 250\n 0\n 500\n 15\n \n 0\n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdtcat_descrip\n \n \n \n \n 10\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdtcat_order\n \n \n \n \n 100\n 0\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdtcat_name\n \n \n \n
\n \n 16\n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 317 IncidentPrioritiesList \N \n\n Incident Priorities\n IncidentPrioritiesList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT incdtpriority_name, incdtpriority_order, incdtpriority_descrip\n FROM incdtpriority\nORDER BY incdtpriority_order, incdtpriority_name;\n \n \n 76\n \n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 100\n 0\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdtpriority_name\n \n \n \n \n 10\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdtpriority_order\n \n \n \n \n 250\n 0\n 500\n 15\n \n 0\n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdtpriority_descrip\n \n \n \n
\n \n 16\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 318 IncidentResolutionsList \N \n\n Incident Resolutions\n IncidentResolutionsList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT incdtresolution_name, incdtresolution_order, incdtresolution_descrip\n FROM incdtresolution\nORDER BY incdtresolution_order, incdtresolution_name;\n \n \n 76\n \n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n 6\n \n \n 21\n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 250\n 0\n 500\n 15\n \n 0\n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdtresolution_descrip\n \n \n \n \n 10\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdtresolution_order\n \n \n \n \n 100\n 0\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdtresolution_name\n \n \n \n
\n \n 16\n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 98 MaterialUsageVarianceByWarehouse \N \n\n Material Usage Variance By Site\n MaterialUsageVarianceByWarehouse\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse;\n \n \n detail\n workOrderVariance\n material\n \n \n 234\n \n \n \n \n 490\n 130\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n \n \n 140\n 110\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n 490\n 110\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n \n \n \n \n 5\n 228\n 745\n 228\n 2\n \n \n \n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 51\n \n \n 520\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_projreq\n \n \n \n \n 85\n 15\n 175\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n parentdescrip\n \n \n \n \n 595\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_actqtyper\n \n \n \n \n 444\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ordered\n \n \n \n \n 265\n 15\n 175\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n componentdescrip\n \n \n \n \n 595\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_actiss\n \n \n \n \n 670\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtypervarpercent\n \n \n \n \n 265\n 0\n 175\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n componentitemnumber\n \n \n \n \n 670\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtypervar\n \n \n \n \n 85\n 0\n 175\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n parentitemnumber\n \n \n \n \n 444\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_received\n \n \n \n \n 5\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_posted\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 520\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_projqtyper\n \n \n \n
\n \n 16\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 97 MaterialUsageVarianceByWorkOrder \N \n\n Material Usage Variance By Work Order\n MaterialUsageVarianceByWorkOrder\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT formatWONumber(wo_id) AS wonumber,\n warehous_code, item_number, uom_name,\n item_descrip1, item_descrip2,\n wo_status\n FROM wo, itemsite, item, whsinfo, uom\n WHERE ((wo_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (wo_id=<? value("wo_id") ?>))\n \n \n detail\n workOrderVariance\n material\n \n \n 234\n \n \n 140\n 140\n 350\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n 5\n 228\n 745\n 228\n 2\n \n \n \n 140\n 120\n 350\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n \n \n 140\n 100\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n 360\n 70\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehous_code\n \n \n \n \n \n 140\n 70\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n wonumber\n \n \n \n \n 140\n 165\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n wo_status\n \n \n \n \n \n \n \n \n \n \n 360\n 100\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n uom_name\n \n \n \n \n \n \n \n \n \n \n \n \n 6\n \n \n 36\n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 51\n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_actiss\n \n \n \n \n 85\n 15\n 375\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n componentdescrip\n \n \n \n \n 85\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n componentitemnumber\n \n \n \n \n 400\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_received\n \n \n \n \n 665\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtypervarpercent\n \n \n \n \n 494\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_projreq\n \n \n \n \n 315\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ordered\n \n \n \n \n 580\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_actqtyper\n \n \n \n \n 5\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_posted\n \n \n \n \n 494\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_projqtyper\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtypervar\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n
\n \n 16\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 319 IncidentSeveritiesList \N \n\n Incident Severities\n IncidentSeveritiesList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT incdtseverity_name, incdtseverity_order, incdtseverity_descrip\n FROM incdtseverity\nORDER BY incdtseverity_order, incdtseverity_name;\n \n \n 76\n \n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n 6\n \n \n 21\n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 250\n 0\n 500\n 15\n \n 0\n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdtseverity_descrip\n \n \n \n \n 10\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdtseverity_order\n \n \n \n \n 100\n 0\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdtseverity_name\n \n \n \n
\n \n 16\n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 321 IncidentWorkbenchList \N \n\n Incident List\n IncidentWorkbenchList\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n incidents\n detail\n \n \n 144\n \n 2\n 139\n 742\n 139\n 2\n \n \n \n \n \n \n \n \n \n \n \n \n 10\n 39\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 5\n \n \n 21\n \n \n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n
\n detail\n \n ByUser\n usr_username\n \n \n \n detail\n \n 28\n \n \n 320\n 0\n 230\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdt_summary\n \n \n \n \n 65\n 0\n 110\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n crmacct_name\n \n \n \n \n 240\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdt_assigned_username\n \n \n \n \n 180\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdt_status\n \n \n \n \n 690\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdtpriority_name\n \n \n \n \n 560\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdt_timestamp\n \n \n \n \n 640\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdtseverity_name\n \n \n \n \n 10\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdt_number\n \n \n \n \n 320\n 15\n 430\n 15\n \n 0\n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdt_descrip\n \n \n \n
\n \n 15\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 50 IndentedBOM \N \n\n Indented Bill of Materials\n IndentedBOM\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n uom_name AS item_invuom,\n item_descrip1,\n item_descrip2\n FROM item, uom\n WHERE ((item_id=<? value("item_id") ?>)\n AND (item_inv_uom_id=uom_id));\n \n \n \n detail\n SELECT (REPEAT(' ',(bomdata_bomwork_level-1)*3) || bomdata_bomwork_seqnumber) AS f_seqnumber,\n bomdata_item_number AS item_number,\n bomdata_uom_name AS item_invuom,\n bomdata_item_descrip1 AS item_descrip1,\n bomdata_item_descrip2 AS item_descrip2,\n bomdata_issuemethod AS issuemethod,\n bomdata_createchild AS createchild,\n formatQtyPer(bomdata_qtyreq) AS qtyreq,\n formatScrap(bomdata_scrap) AS scrap,\n CASE WHEN COALESCE(bomdata_effective, startOfTime()) <= startOfTime()\n THEN <? value("always") ?>\n ELSE formatDate(bomdata_effective)\n END AS effective,\n CASE WHEN COALESCE(bomdata_expires, endOfTime()) >= endOfTime()\n THEN <? value("never") ?>\n ELSE formatDate(bomdata_expires)\n END AS expires\nFROM indentedBOM(<? value("item_id") ?>,<? value("revision_id") ?>,<? value("expiredDays") ?>,<? value("futureDays") ?>)\nWHERE (bomdata_item_id>0);\n \n \n bomhead\n SELECT bomhead_docnum, bomhead_revision,\nformatDate(bomhead_revisiondate) AS f_revisiondate\nFROM bomhead\nWHERE ((bomhead_item_id=<? value("item_id") ?>)\nAND (bomhead_rev_id=<? value("revision_id") ?>));\n \n \n 242\n \n \n \n \n \n \n \n 100\n 103\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n 100\n 125\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n 580\n 103\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n bomhead_docnum\n \n \n \n \n \n \n \n 580\n 125\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n f_revisiondate\n \n \n \n \n \n \n 5\n 235\n 745\n 235\n 2\n \n \n \n \n 100\n 145\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n 580\n 145\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n bomhead_revision\n \n \n \n \n 315\n 103\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_invuom\n \n \n \n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n
\n detail\n \n \n detail\n \n 53\n \n \n 505\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n scrap\n \n \n \n \n 665\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n issuemethod\n \n \n \n \n 585\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n effective\n \n \n \n \n 110\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 665\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n expires\n \n \n \n \n 275\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_invuom\n \n \n \n \n 5\n 0\n 103\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_seqnumber\n \n \n \n \n 110\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 425\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyreq\n \n \n \n \n 110\n 15\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 585\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n createchild\n \n \n \n
\n \n 18\n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 208 IndentedWhereUsed \N \n\n Indented Where Used\n IndentedWhereUsed\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n uom_name AS item_invuom,\n item_descrip1,\n item_descrip2\n FROM item, uom\n WHERE ((item_id=<? value("item_id") ?>)\n AND (item_inv_uom_id=uom_id));\n \n \n \n detail\n SELECT (REPEAT(' ',(bomwork_level-1)*3) || bomwork_seqnumber) AS f_seqnumber,\n bomworkitemsequence(bomwork_id) AS seqord,\n item_number, uom_name AS item_invuom,\n item_descrip1, item_descrip2,\n formatQty(bomwork_qtyfxd) AS qtyfxd,\n formatQtyPer(bomwork_qtyper) AS qtyper,\n formatScrap(bomwork_scrap) AS scrap,\n formatDate(bomwork_effective, 'Always') AS effective,\n formatDate(bomwork_expires, 'Never') AS expires\n FROM bomwork, item, uom\n WHERE ((bomwork_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (bomwork_set_id=<? value("bomworkset_id") ?>)\n<? if not exists("showExpired") ?>\n AND (bomwork_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (bomwork_effective <= CURRENT_DATE)\n<? endif ?>\n)\nORDER BY seqord;\n \n \n 242\n \n \n 100\n 145\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n \n 100\n 125\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n \n \n \n \n 315\n 103\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_invuom\n \n \n \n 5\n 235\n 745\n 235\n 2\n \n \n \n \n \n \n \n 100\n 103\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n \n \n 6\n \n \n 36\n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 52\n \n \n 275\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_invuom\n \n \n \n \n 665\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n expires\n \n \n \n \n 5\n 0\n 103\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_seqnumber\n \n \n \n \n 113\n 15\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 585\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n effective\n \n \n \n \n 505\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n scrap\n \n \n \n \n 113\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 425\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyper\n \n \n \n \n 113\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 345\n 1\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyfxd\n \n \n \n
\n \n 17\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 445 InventoryAvailability \N \n\n Inventory Availability\n InventoryAvailability\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("byDays") ?>\n (text('Look ahead ') || text(<? value("byDays") ?>) || text(' days'))\n <? elseif exists("byDate") ?>\n (text('Cutoff date ') || formatDate(<? value("byDate") ?>))\n <? elseif exists("byDates") ?>\n (text('Dates from ') || formatDate(<? value("startDate") ?>) || text(' to ') || formatDate(<? value("endDate") ?>))\n <? else ?>\n text('Item Site Lead Time')\n <? endif ?>\n AS ltcriteria;\n \n \n detail\n SELECT item_number, item_descrip1, item_descrip2,\n warehous_code, itemsite_leadtime,\n formatQty(qtyonhand) AS f_qtyonhand,\n formatQty(noNeg(qtyonhand - allocated)) AS f_unallocated,\n formatQty(noNeg(allocated)) AS f_allocated,\n formatQty(ordered) AS f_ordered,\n formatQty(requests) AS f_requests,\n formatQty(reorderlevel) AS f_reorderlevel,\n (qtyonhand - allocated + ordered) AS available,\n formatQty(qtyonhand - allocated + ordered) AS f_available\n FROM (SELECT \n <? if reExists("[vV]end") ?>\n DISTINCT\n <? endif ?>\n itemsite_id,\n CASE WHEN (item_type IN ('P', 'O')) THEN 1\n WHEN (item_type IN ('M')) THEN 2\n ELSE 0\n END AS altId,\n item_number, item_descrip1, item_descrip2, item_inv_uom_id,\n warehous_id, warehous_code, itemsite_leadtime,\n qtyAvailable(itemsite_id) AS qtyonhand,\n CASE WHEN itemsite_useparams THEN itemsite_reorderlevel\n ELSE 0.0\n END AS reorderlevel,\n CASE WHEN itemsite_useparams THEN itemsite_ordertoqty\n ELSE 0.0\n END AS outlevel,\n <? if exists("byVend") ?>\n vend_number,\n <? else ?>\n NULL AS vend_number,\n <? endif ?>\n <? if exists("byLeadTime") ?>\n qtyAllocated(itemsite_id, itemsite_leadtime) AS allocated,\n qtyOrdered(itemsite_id, itemsite_leadtime) AS ordered, \n qtypr(itemsite_id, itemsite_leadtime) AS requests\n <? elseif exists("byDays") ?>\n qtyAllocated(itemsite_id, CAST(<? value("byDays") ?> AS INTEGER)) AS allocated,\n qtyOrdered(itemsite_id, CAST(<? value("byDays") ?> AS INTEGER)) AS ordered,\n qtypr(itemsite_id, CAST(<? value("byDays") ?> AS INTEGER)) AS requests \n <? elseif exists("byDate") ?>\n qtyAllocated(itemsite_id, (<? value("byDate") ?> - CURRENT_DATE)) AS allocated,\n qtyOrdered(itemsite_id, (<? value("byDate") ?> - CURRENT_DATE)) AS ordered,\n qtypr(itemsite_id, (<? value("byDate") ?> - CURRENT_DATE)) AS requests \n <? elseif exists("byDates") ?>\n qtyAllocated(itemsite_id, <? value("startDate") ?>, <? value("endDate") ?>) AS allocated,\n qtyOrdered(itemsite_id, <? value("startDate") ?>, <? value("endDate") ?>) AS ordered,\n qtypr(itemsite_id, <? value("startDate") ?>, <? value("endDate") ?>) AS requests\n <? endif ?>\n FROM item, itemsite, whsinfo\n <? if reExists("[vV]end") ?>\n , vendinfo JOIN itemsrc ON (itemsrc_vend_id=vend_id)\n <? endif ?>\n WHERE ( (itemsite_active)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n <? if exists("warehous_id") ?>\n AND (warehous_id=<? value("warehous_id") ?>)\n <? endif ?>\n <? if exists("item_id") ?>\n AND (item_id=<? value("item_id") ?>)\n <? elseif exists("classcode_id") ?>\n AND (item_classcode_id=<? value("classcode_id") ?>)\n <? elseif exists("classcode_pattern") ?>\n AND (item_classcode_id IN (SELECT classcode_id\n FROM classcode\n WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n <? elseif exists("plancode_id") ?>\n AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n <? elseif exists("plancode_pattern") ?>\n AND (itemsite_plancode_id IN (SELECT plancode_id\n FROM plancode\n WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n <? elseif exists("itemgrp_id") ?>\n AND (item_id IN (SELECT itemgrpitem_item_id\n FROM itemgrpitem\n WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n <? elseif exists("itemgrp_pattern") ?>\n AND (item_id IN (SELECT itemgrpitem_item_id\n FROM itemgrpitem, itemgrp\n WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n AND (itemgrp_name ~ <? value("itemgrp_pattern") ?>) ) ))\n <? elseif exists("itemgrp") ?>\n AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n <? endif ?>\n <? if reExists("[vV]end") ?>\n AND (itemsrc_item_id=item_id)\n <? endif ?>\n <? if exists("vend_id") ?>\n AND (vend_id=<? value("vend_id") ?>)\n <? elseif exists("vendtype_id") ?>\n AND (vend_vendtype_id=<? value("vendtype_id") ?>)\n <? elseif exists("vendtype_pattern") ?>\n AND (vend_vendtype_id IN (SELECT vendtype_id\n FROM vendtype\n WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n <? endif ?>\n ) ) AS data\n<? if exists("showReorder") ?>\n WHERE ( ((qtyonhand - allocated + ordered) <= reorderlevel)\n <? if exists("ignoreReorderAtZero") ?>\n AND (NOT ( ((qtyonhand - allocated + ordered) = 0) AND (reorderlevel = 0)) )\n <? endif ?>\n )\n<? elseif exists("showShortages") ?>\n WHERE ((qtyonhand - allocated + ordered) < 0)\n<? endif ?>\nORDER BY item_number, warehous_code DESC;\n \n \n 221\n \n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n \n \n \n \n \n \n 140\n 43\n 280\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n ltcriteria\n \n \n \n \n \n 10\n 63\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 56\n \n \n 330\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyonhand\n \n \n \n \n 645\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_available\n \n \n \n \n 65\n 0\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 434\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_allocated\n \n \n \n \n 10\n 15\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemsite_leadtime\n \n \n \n \n 540\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ordered\n \n \n \n 5\n 50\n 745\n 50\n 0\n \n \n \n 65\n 15\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 10\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 65\n 30\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 434\n 30\n 100\n 16\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_unallocated\n \n \n \n \n 540\n 31\n 100\n 12\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_reorderlevel\n \n \n \n \n 540\n 14\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_requests\n \n \n \n
\n \n 16\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 363 InventoryAvailabilityByCustomerType \N \n\n Inventory Availability by Customer Type\n InventoryAvailabilityByCustomerType\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT \n <? if exists("onlyShowShortages") ?>\n text('Only Showing Shortages')\n <? else ?>\n text('')\n <? endif ?>\n AS f_onlyShowShortages,\n <? if exists("showWoSupply") ?>\n text('Show W/O Supply')\n <? else ?>\n text('')\n <? endif ?>\n AS f_showWoSupply,\n<? if exists("custtype_id") ?>\n (SELECT custtype_code from custtype where (custtype_id=<? value("custtype_id") ?>))\n<? elseif exists("custtype_pattern") ?>\n <? value("custtype_pattern") ?>\n<? else ?>\n text('All Customer Types')\n<? endif ?>\n AS f_custtype;\n \n \n detail\n SELECT itemsite_id, coitem_id,\n cohead_id, cohead_number, (cust_number||'-'||cust_name) AS custname,\n item_number, item_description, uom_name, item_picklist,\n qoh, formatQty(qoh) AS f_qoh,sobalance,\n formatQty(sobalance) AS f_sobalance,\n formatQty(allocated) AS f_allocated,\n ordered, formatQty(ordered) AS f_ordered,\n (qoh + ordered - sobalance) AS woavail,\n<? if exists("useReservationNetting") ?>\n formatQty(coitem_qtyreserved) AS f_soavail,\n<? else ?>\n formatQty(qoh + ordered - sobalance) AS f_soavail,\n<? endif ?>\n (qoh + ordered - allocated) AS totalavail,\n formatQty(qoh + ordered - allocated) AS f_totalavail,\n atshipping,formatQty(atshipping) AS f_atshipping,\n reorderlevel \n<? if exists(showWoSupply) ?>, \n wo_id,\n wo_status,\n wo_number,\n wo_ordered,\n CASE WHEN (wo_id = -1) THEN NULL ELSE formatQty(wo_ordered) END AS f_wo_ordered,\n formatdate(wo_startdate) AS f_wo_startdate, \n formatdate(wo_duedate) AS f_wo_duedate,\n COALESCE(wo_latestart,false) AS wo_latestart,\n COALESCE(wo_latedue,false) AS wo_latedue \n<? endif ?>\n FROM ( SELECT itemsite_id, coitem_id,\n cohead_id, cohead_number, cust_number, cust_name,\n item_number, (item_descrip1 || ' ' || item_descrip2) AS item_description,\n uom_name, item_picklist,\n noNeg(qtyAvailable(itemsite_id)) AS qoh,\n noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS sobalance,\n qtyAllocated(itemsite_id, coitem_scheddate) AS allocated,\n qtyOrdered(itemsite_id, coitem_scheddate) AS ordered,\n qtyatshipping(coitem_id) AS atshipping,\n coitem_qtyreserved,\n CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel \n<? if exists(showWoSupply) ?>, \n COALESCE(wo_id,-1) AS wo_id,\n formatwonumber(wo_id) AS wo_number,\n noNeg((wo_qtyord-wo_qtyrcv)) AS wo_ordered,\n wo_status, wo_startdate, wo_duedate,\n ((wo_startdate <= CURRENT_DATE) AND (wo_status IN ('O','E','S','R'))) AS wo_latestart,\n (wo_duedate<=CURRENT_DATE) AS wo_latedue \n<? endif ?> \n FROM cohead, itemsite, item, uom, custinfo, coitem\n<? if exists(showWoSupply) ?> \n LEFT OUTER JOIN wo\n ON ((coitem_itemsite_id=wo_itemsite_id)\n AND (wo_status IN ('E','R','I'))\n AND (wo_qtyord-wo_qtyrcv > 0)\n AND (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned-qtyatshipping(coitem_id)) > \n (SELECT qtyAvailable(itemsite_id) AS availableqoh FROM itemsite WHERE (itemsite_id=coitem_itemsite_id))))\n<? endif ?>\n WHERE((coitem_cohead_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (coitem_status NOT IN ('C', 'X'))\n<? if exists("custtype_id") ?>\n AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n AND (cust_custtype_id IN (SELECT custtype_id\n FROM custtype\n WHERE(custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n )\n ) AS data \n<? if exists(onlyShowShortages) ?>\n WHERE ( ((qoh + ordered - allocated) < 0)\n OR ((qoh + ordered - sobalance) < 0) ) \n<? endif ?>\n ORDER BY cohead_id, cohead_number, item_number\n<? if exists(showWoSupply) ?> ,\n wo_duedate\n<? endif ?>\n;\n \n \n 251\n \n \n \n 360\n 120\n 380\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_showWoSupply\n \n \n \n \n 10\n 245\n 750\n 245\n 2\n \n \n \n \n \n 140\n 100\n 209\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_custtype\n \n \n \n \n \n \n \n 360\n 100\n 380\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_onlyShowShortages\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 6\n \n \n 41\n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n cohead\n cohead_id\n \n 26\n \n \n \n 390\n 0\n 209\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n custname\n \n \n \n \n \n 65\n 0\n 209\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n cohead_number\n \n \n \n \n 6\n \n 5\n 0\n 745\n 0\n 0\n \n \n \n \n \n detail\n \n 46\n \n \n 640\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_totalavail\n \n \n \n \n 25\n 30\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n wo_number\n \n \n \n \n 535\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ordered\n \n \n \n \n 10\n 15\n 400\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n Item_description\n \n \n \n \n 640\n 30\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_wo_duedate\n \n \n \n \n 10\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n Item_number\n \n \n \n \n 430\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_sobalance\n \n \n \n \n 185\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n \n 185\n 30\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n wo_status\n \n \n \n \n 640\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_soavail\n \n \n \n \n 430\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_allocated\n \n \n \n \n 430\n 30\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_wo_ordered\n \n \n \n \n 325\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qoh\n \n \n \n \n 535\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_atshipping\n \n \n \n \n 535\n 30\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_wo_startdate\n \n \n \n
\n \n 18\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 244 InventoryAvailabilityBySalesOrder \N \n\n Inventory Availability by Sales Order\n InventoryAvailabilityBySalesOrder\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT cohead_number,\n formatDate(cohead_orderdate) AS orderdate,\n cohead_custponumber,\n cust_name,\n cntct_phone AS cust_phone,\n <? if exists("onlyShowShortages") ?>\n text('Only Showing Shortages')\n <? else ?>\n text('')\n <? endif ?>\n AS f_onlyShowShortages,\n <? if exists("showWoSupply") ?>\n text('Show W/O Supply')\n <? else ?>\n text('')\n <? endif ?>\n AS f_showWoSupply\n FROM cohead, custinfo\n LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n WHERE ((cohead_cust_id=cust_id)\n AND (cohead_id=<? value("sohead_id") ?>) );\n \n \n detail\n SELECT itemsite_id, coitem_id,\n item_number, item_description, uom_name, item_picklist,\n qoh, formatQty(qoh) AS f_qoh,sobalance,\n formatQty(sobalance) AS f_sobalance,\n formatQty(allocated) AS f_allocated,\n ordered, formatQty(ordered) AS f_ordered,\n (qoh + ordered - sobalance) AS woavail,\n formatQty(qoh + ordered - sobalance) AS f_soavail,\n (qoh + ordered - allocated) AS totalavail,\n formatQty(qoh + ordered - allocated) AS f_totalavail,\n atshipping,formatQty(atshipping) AS f_atshipping,\n reorderlevel \n <? if exists(showWoSupply) ?>, \n wo_id,\n wo_status,\n wo_number,\n wo_ordered,\n CASE WHEN (wo_id = -1) THEN NULL ELSE formatQty(wo_ordered) END AS f_wo_ordered,\n formatdate(wo_startdate) AS f_wo_startdate, \n formatdate(wo_duedate) AS f_wo_duedate,\n COALESCE(wo_latestart,false) AS wo_latestart,\n COALESCE(wo_latedue,false) AS wo_latedue \n <? endif ?>\n FROM ( SELECT itemsite_id, coitem_id,\n item_number, (item_descrip1 || ' ' || item_descrip2) AS item_description,\n uom_name, item_picklist,\n noNeg(qtyAvailable(itemsite_id)) AS qoh,\n noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS sobalance,\n qtyAllocated(itemsite_id, coitem_scheddate) AS allocated,\n qtyOrdered(itemsite_id, coitem_scheddate) AS ordered,\n qtyatshipping(coitem_id) AS atshipping,\n CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel \n <? if exists(showWoSupply) ?>, \n COALESCE(wo_id,-1) AS wo_id,\n formatwonumber(wo_id) AS wo_number,\n noNeg((wo_qtyord-wo_qtyrcv)) AS wo_ordered,\n wo_status, wo_startdate, wo_duedate,\n ((wo_startdate <= CURRENT_DATE) AND (wo_status IN ('O','E','S','R'))) AS wo_latestart,\n (wo_duedate<=CURRENT_DATE) AS wo_latedue \n <? endif ?> \n FROM cohead, itemsite, item, uom, coitem \n <? if exists(showWoSupply) ?> \n LEFT OUTER JOIN wo\n ON ((coitem_itemsite_id=wo_itemsite_id)\n AND (wo_status IN ('E','R','I'))\n AND (wo_qtyord-wo_qtyrcv > 0)\n AND (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned-qtyatshipping(coitem_id)) > \n (SELECT qtyAvailable(itemsite_id) AS availableqoh FROM itemsite WHERE (itemsite_id=coitem_itemsite_id))))\n <? endif ?>\n WHERE ( (coitem_cohead_id=cohead_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (coitem_status NOT IN ('C', 'X'))\n AND (cohead_id=<? value(sohead_id) ?>))\n ) AS data \n\t <? if exists(onlyShowShortages) ?>\n WHERE ( ((qoh + ordered - allocated) < 0)\n OR ((qoh + ordered - sobalance) < 0) ) \n <? endif ?>\n ORDER BY item_number\n <? if exists(showWoSupply) ?> ,\n wo_duedate\n <? endif ?>\n ;\n \n \n 251\n \n \n \n \n \n \n \n \n \n \n 385\n 140\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cohead_custponumber\n \n \n \n \n \n \n \n \n 360\n 175\n 380\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_showWoSupply\n \n \n \n \n \n 10\n 245\n 750\n 245\n 2\n \n \n \n 140\n 100\n 125\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cohead_number\n \n \n \n \n \n 385\n 100\n 350\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_name\n \n \n \n \n \n \n 385\n 120\n 350\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_phone\n \n \n \n \n 360\n 160\n 380\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_onlyShowShortages\n \n \n \n \n 140\n 120\n 125\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n orderdate\n \n \n \n \n \n \n \n \n \n 6\n \n \n 41\n \n \n \n \n \n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n \n
\n detail\n \n coitem\n coitem_id\n \n 31\n \n \n 430\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_allocated\n \n \n \n \n 325\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qoh\n \n \n \n \n 185\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n \n 640\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_soavail\n \n \n \n \n 535\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_atshipping\n \n \n \n \n 640\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_totalavail\n \n \n \n \n 535\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ordered\n \n \n \n \n 10\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n Item_number\n \n \n \n \n 10\n 15\n 400\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n Item_description\n \n \n \n \n 430\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_sobalance\n \n \n \n \n 6\n \n 5\n 0\n 745\n 0\n 0\n \n \n \n \n \n detail\n \n 16\n \n \n 535\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_wo_startdate\n \n \n \n \n 25\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n wo_number\n \n \n \n \n 430\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_wo_ordered\n \n \n \n \n 640\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_wo_duedate\n \n \n \n \n 185\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n wo_status\n \n \n \n
\n \n 17\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 18 InventoryAvailabilityBySourceVendor \N \n\n Inventory Availability by Source Vendor\n InventoryAvailabilityBySourceVendor\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("byDays") ?>\n (text('Look ahead ') || text(<? value("byDays") ?>) || text(' days'))\n <? elseif exists("byDate") ?>\n (text('Cutoff date ') || formatDate(<? value("byDate") ?>))\n <? elseif exists("byDates") ?>\n (text('Dates from ') || formatDate(<? value("startDate") ?>) || text(' to ') || formatDate(<? value("endDate") ?>))\n <? else ?>\n text('Item Site Lead Time')\n <? endif ?>\n AS ltcriteria\n \n \n detail\n SELECT item_number,\n item_descrip1,\n item_descrip2,\n warehous_code,\n vend_number,\n itemsite_leadtime,\n formatQty(qtyonhand) AS f_qtyonhand,\n formatQty(noNeg(qtyonhand - allocated)) AS f_unallocated,\n formatQty(noNeg(allocated)) AS f_allocated,\n formatQty(ordered) AS f_ordered,\n formatQty(reorderlevel) AS f_reorderlevel,\n formatQty(outlevel) AS f_outlevel,\n (qtyonhand - allocated + ordered) AS available,\n formatQty(qtyonhand - allocated + ordered) AS f_available\n FROM (SELECT \n <? if reExists("[vV]end") ?>\n DISTINCT\n <? endif ?>\n itemsite_id,\n CASE WHEN (item_type IN ('P', 'O')) THEN 1\n WHEN (item_type IN ('M')) THEN 2\n ELSE 0\n END AS altId,\n item_number, item_descrip1, item_descrip2, item_inv_uom_id,\n warehous_id, warehous_code, itemsite_leadtime,\n qtyAvailable(itemsite_id) AS qtyonhand,\n CASE WHEN itemsite_useparams THEN itemsite_reorderlevel\n ELSE 0.0\n END AS reorderlevel,\n CASE WHEN itemsite_useparams THEN itemsite_ordertoqty\n ELSE 0.0\n END AS outlevel,\n <? if exists("byVend") ?>\n vend_number,\n <? else ?>\n NULL AS vend_number,\n <? endif ?>\n <? if exists("byLeadTime") ?>\n qtyAllocated(itemsite_id, itemsite_leadtime) AS allocated,\n qtyOrdered(itemsite_id, itemsite_leadtime) AS ordered, \n qtypr(itemsite_id, itemsite_leadtime) AS requests\n <? elseif exists("byDays") ?>\n qtyAllocated(itemsite_id, CAST(<? value("byDays") ?> AS INTEGER)) AS allocated,\n qtyOrdered(itemsite_id, CAST(<? value("byDays") ?> AS INTEGER)) AS ordered,\n qtypr(itemsite_id, CAST(<? value("byDays") ?> AS INTEGER)) AS requests \n <? elseif exists("byDate") ?>\n qtyAllocated(itemsite_id, (<? value("byDate") ?> - CURRENT_DATE)) AS allocated,\n qtyOrdered(itemsite_id, (<? value("byDate") ?> - CURRENT_DATE)) AS ordered,\n qtypr(itemsite_id, (<? value("byDate") ?> - CURRENT_DATE)) AS requests \n <? elseif exists("byDates") ?>\n qtyAllocated(itemsite_id, <? value("startDate") ?>, <? value("endDate") ?>) AS allocated,\n qtyOrdered(itemsite_id, <? value("startDate") ?>, <? value("endDate") ?>) AS ordered,\n qtypr(itemsite_id, <? value("startDate") ?>, <? value("endDate") ?>) AS requests\n <? endif ?>\n FROM item, itemsite, whsinfo\n <? if reExists("[vV]end") ?>\n , vendinfo JOIN itemsrc ON (itemsrc_vend_id=vend_id)\n <? endif ?>\n WHERE ( (itemsite_active)\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n <? if exists("warehous_id") ?>\n AND (warehous_id=<? value("warehous_id") ?>)\n <? endif ?>\n <? if exists("item_id") ?>\n AND (item_id=<? value("item_id") ?>)\n <? elseif exists("classcode_id") ?>\n AND (item_classcode_id=<? value("classcode_id") ?>)\n <? elseif exists("classcode_pattern") ?>\n AND (item_classcode_id IN (SELECT classcode_id\n FROM classcode\n WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n <? elseif exists("plancode_id") ?>\n AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n <? elseif exists("plancode_pattern") ?>\n AND (itemsite_plancode_id IN (SELECT plancode_id\n FROM plancode\n WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n <? elseif exists("itemgrp_id") ?>\n AND (item_id IN (SELECT itemgrpitem_item_id\n FROM itemgrpitem\n WHERE (itemgrpitem_itemgrp_id=<? value("itemgrp_id") ?>)))\n <? elseif exists("itemgrp_pattern") ?>\n AND (item_id IN (SELECT itemgrpitem_item_id\n FROM itemgrpitem, itemgrp\n WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)\n AND (itemgrp_name ~ <? value("itemgrp_pattern") ?>) ) ))\n <? elseif exists("itemgrp") ?>\n AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))\n <? endif ?>\n <? if reExists("[vV]end") ?>\n AND (itemsrc_item_id=item_id)\n <? endif ?>\n <? if exists("vend_id") ?>\n AND (vend_id=<? value("vend_id") ?>)\n <? elseif exists("vendtype_id") ?>\n AND (vend_vendtype_id=<? value("vendtype_id") ?>)\n <? elseif exists("vendtype_pattern") ?>\n AND (vend_vendtype_id IN (SELECT vendtype_id\n FROM vendtype\n WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n <? endif ?>\n ) ) AS data\n<? if exists("showReorder") ?>\n WHERE ( ((qtyonhand - allocated + ordered) <= reorderlevel)\n <? if exists("ignoreReorderAtZero") ?>\n AND (NOT ( ((qtyonhand - allocated + ordered) = 0) AND (reorderlevel = 0)))\n <? endif ?>\n )\n<? elseif exists("showShortages") ?>\n WHERE ((qtyonhand - allocated + ordered) < 0)\n<? endif ?>\nORDER BY vend_number, item_number, warehous_code DESC;\n \n \n 221\n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n \n 135\n 43\n 280\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n ltcriteria\n \n \n \n \n \n \n \n \n \n \n \n \n 10\n 63\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 56\n \n \n 645\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_available\n \n \n \n \n 330\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyonhand\n \n \n \n \n 160\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 55\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_number\n \n \n \n \n 540\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_reorderlevel\n \n \n \n \n 645\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_outlevel\n \n \n \n \n 5\n 15\n 45\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemsite_leadtime\n \n \n \n \n 434\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_allocated\n \n \n \n \n 540\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ordered\n \n \n \n \n 160\n 15\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 160\n 30\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n 5\n 50\n 745\n 50\n 0\n \n \n \n 434\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_unallocated\n \n \n \n \n 5\n 0\n 45\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n
\n \n 16\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 85\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 1 Invoice \N \n\n Invoice\n Invoice\n With Logo - With Invoice Currency\n \n \n SELECT invchead_id, invchead_invcnumber FROM invchead ORDER BY invchead_invcnumber;\n \n \n \n Parameter Query\n watermark\n \n 25\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n GroupHead\n SELECT \n\n--Due Date\nformatDate(determineDueDate(invchead_terms_id, invchead_invcdate)) AS due_date,\n--Discount Date\nformatDate(determineDiscountDate(invchead_terms_id, invchead_invcdate)) AS dis_date,\n\n --remitto.*,\nremitto_name,\nformatAddr(remitto_address1, remitto_address2, remitto_address3, remitto_citystatezip, remitto_country) AS remitto_adr,\n invchead_invcnumber AS invoicenumber,\n formatDate(invchead_invcdate) AS f_invoicedate,\n cust_number,\n invchead_billto_name,\n formatAddr(invchead_billto_address1, invchead_billto_address2, invchead_billto_address3, ( invchead_billto_city || ' ' || invchead_billto_state || ' ' || invchead_billto_zipcode ), invchead_billto_country) AS f_billtoaddress,\n invchead_billto_phone,\n invchead_shipto_name,\n formatAddr(invchead_shipto_address1, invchead_shipto_address2, invchead_shipto_address3, ( invchead_shipto_city || ' ' || invchead_shipto_state || ' ' || invchead_shipto_zipcode ), invchead_shipto_country) AS f_shiptoaddress,\n invchead_ordernumber AS ordernumber,\n invchead_ponumber,\n formatDate(invchead_orderdate) AS f_orderdate,\n formatDate(invchead_shipdate) AS f_shipdate,\n invchead_fob, terms_descrip, invchead_shipvia\nFROM remitto, custinfo, invchead, terms\nWHERE ( (invchead_cust_id=cust_id)\nAND (invchead_terms_id=terms_id)\nAND (invchead_id=<? value("invchead_id") ?>) )\nORDER BY ordernumber;\n \n \n Detail\n SELECT invcitem_linenumber,\n formatQty(invcitem_billed) AS f_billed,\n (select uom_name from uom where uom_id = invcitem_qty_uom_id) AS invuom,\n CASE WHEN (item_number IS NULL) THEN invcitem_number\n WHEN (invcitem_custpn != '') THEN invcitem_custpn\n else item_number\n END AS number,\n CASE WHEN (item_number IS NULL) THEN invcitem_descrip\n WHEN (invcitem_custpn != '' AND itemalias_usedescrip=TRUE) THEN itemalias_descrip1\n ELSE item_descrip1\n END AS descrip1,\n CASE WHEN (invcitem_custpn != '' AND itemalias_usedescrip=TRUE) THEN itemalias_descrip2\n ELSE item_descrip2\n END AS descrip2,\n CASE WHEN (<? value("showcosts") ?>=FALSE) THEN '---'\n ELSE formatPrice(invcitem_qty_invuomratio * invcitem_price / COALESCE(invcitem_price_invuomratio,1))\n END AS f_unitprice,\n CASE WHEN (<? value("showcosts") ?>=FALSE) THEN '---'\n ELSE formatMoney(round((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / COALESCE(invcitem_price_invuomratio,1)),2)) \n END AS f_extprice,\n invcitem_notes,\n getInvcitemLotSerial(invcitem_id) AS lotserial,\n--Sub-select updated for 3.1 to support kitting\n characteristicsToString('SI',invcitem_coitem_id, '=', ', ') \n AS coitem_characteristics\nFROM invcitem LEFT OUTER JOIN (item JOIN uom ON (item_inv_uom_id=uom_id)) ON (invcitem_item_id=item_id) LEFT OUTER JOIN itemalias ON (itemalias_item_id=item_id AND itemalias_number=invcitem_custpn)\nWHERE (invcitem_invchead_id=<? value("invchead_id") ?>)\nORDER BY invcitem_linenumber;\n \n \n foot\n SELECT formatMoney(SUM(round((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / COALESCE(invcitem_price_invuomratio,1)),2))) AS f_extprice \nFROM invcitem LEFT OUTER JOIN item on (invcitem_item_id=item_id) \nWHERE (invcitem_invchead_id=<? value("invchead_id") ?>);\n \n \n GroupExtended\n SELECT *,\n formatMoney(invchead_misc_amount) AS f_misc,\n formatMoney(tax) AS f_tax,\n formatMoney(invchead_freight) AS f_freight,\n formatMoney(invchead_payment) AS f_payment,\n formatMoney(noNeg(invchead_freight + invchead_misc_amount + tax +\n itemtotal - total_allocated)) AS f_totaldue,\n formatMoney(noNeg(invchead_freight + invchead_misc_amount + tax +\n itemtotal - total_allocated)) AS f_netdue,\n formatMoney(total_allocated) AS f_allocated\n FROM (SELECT invchead_misc_amount, invchead_freight,\n invchead_payment, invchead_notes, invchead_misc_descrip,\n (SELECT COALESCE(SUM(tax),0) \n FROM (\n SELECT ROUND(SUM(taxdetail_tax),2) AS tax \n FROM tax \n JOIN calculateTaxDetailSummary('I', <? value("invchead_id") ?>, 'T') ON (taxdetail_tax_id=tax_id)\n\t GROUP BY tax_id) AS data) AS tax,\n SUM(COALESCE(ROUND(invcitem_billed *\n invcitem_qty_invuomratio *\n invcitem_price /\n COALESCE(invcitem_price_invuomratio,1), 2), 0))\n AS itemtotal,\n COALESCE(\n CASE WHEN invchead_posted THEN\n (SELECT SUM(COALESCE(currToCurr(arapply_curr_id, t.aropen_curr_id,\n arapply_applied, t.aropen_docdate), 0))\n FROM arapply, aropen s, aropen t\n WHERE ( (s.aropen_id=arapply_source_aropen_id)\n AND (arapply_target_aropen_id=t.aropen_id)\n AND (arapply_target_doctype='I')\n AND (arapply_target_docnumber=invchead_invcnumber)\n AND (arapply_reftype='S')\n AND (arapply_source_aropen_id=s.aropen_id)))\n ELSE\n (SELECT SUM(COALESCE(CASE WHEN((aropen_amount - aropen_paid) >=\n currToCurr(aropenalloc_curr_id, aropen_curr_id,\n aropenalloc_amount, aropen_docdate))\n THEN currToCurr(aropenalloc_curr_id, invchead_curr_id,\n aropenalloc_amount, aropen_docdate)\n ELSE currToCurr(aropen_curr_id, invchead_curr_id,\n aropen_amount - aropen_paid,\n aropen_docdate)\n END, 0))\n FROM aropenalloc, aropen\n LEFT OUTER JOIN cohead ON (cohead_number=invchead_ordernumber)\n WHERE ( (aropenalloc_aropen_id=aropen_id)\n AND ((aropenalloc_doctype='S' AND aropenalloc_doc_id=cohead_id) OR\n (aropenalloc_doctype='I' AND aropenalloc_doc_id=invchead_id))\n AND ((aropen_amount - aropen_paid) > 0)))\n END, 0) AS total_allocated\n FROM invchead\n LEFT OUTER JOIN invcitem ON (invcitem_invchead_id=invchead_id)\n WHERE (invchead_id=<? value("invchead_id") ?>)\n GROUP BY invchead_freight, invchead_misc_amount, tax,\n invchead_payment, invchead_notes, invchead_misc_descrip,\n total_allocated\n ) AS dummy_outer\n ;\n \n \n allocatedCMs\n SELECT cohead_id,\n aropen_docnumber,\n formatMoney(aropen_amount) AS f_total,\n formatMoney(aropen_paid) AS f_paid,\n formatMoney(aropen_amount - aropen_paid) AS f_balance,\n CASE WHEN((aropen_amount - aropen_paid) >= currToCurr(aropenalloc_curr_id,\n\t\t\t\t\t\t\t aropen_curr_id,\n\t\t\t\t\t\t\t aropenalloc_amount,\n\t\t\t\t\t\t\t aropen_docdate))\n\t THEN currToCurr(aropenalloc_curr_id, aropen_curr_id,\n\t\t\t aropenalloc_amount, aropen_docdate)\n ELSE (aropen_amount - aropen_paid)\n END AS allocated,\n CASE WHEN((aropen_amount - aropen_paid) >= currToCurr(aropenalloc_curr_id,\n\t\t\t\t\t\t\t aropen_curr_id,\n\t\t\t\t\t\t\t aropenalloc_amount,\n\t\t\t\t\t\t\t aropen_docdate))\n\t THEN formatMoney(currToCurr(aropenalloc_curr_id, aropen_curr_id,\n\t\t\t\t\taropenalloc_amount, aropen_docdate))\n ELSE formatMoney(aropen_amount - aropen_paid)\n END AS f_allocated,\n CASE WHEN((aropen_amount - aropen_paid) >= currToCurr(aropenalloc_curr_id,\n\t\t\t\t\t\t\t aropen_curr_id,\n\t\t\t\t\t\t\t aropenalloc_amount,\n\t\t\t\t\t\t\t aropen_docdate))\n\t THEN currToCurr(aropenalloc_curr_id, invchead_curr_id,\n\t\t\t aropenalloc_amount, aropen_docdate)\n ELSE currToCurr(aropen_curr_id, invchead_curr_id,\n aropen_amount - aropen_paid, aropen_docdate)\n END AS allocated_invccurr,\n CASE WHEN((aropen_amount - aropen_paid) >= currToCurr(aropenalloc_curr_id,\n\t\t\t\t\t\t\t aropen_curr_id,\n\t\t\t\t\t\t\t aropenalloc_amount,\n\t\t\t\t\t\t\t aropen_docdate))\n\t THEN formatMoney(currToCurr(aropenalloc_curr_id, invchead_curr_id,\n\t\t\t\t\taropenalloc_amount, aropen_docdate))\n ELSE formatMoney(currToCurr(aropen_curr_id, invchead_curr_id,\n aropen_amount - aropen_paid,\n aropen_docdate))\n END AS f_allocated_invccurr,\n curr_symbol AS aropen_currsymbol\n FROM invchead LEFT OUTER JOIN cohead ON (cohead_number=invchead_ordernumber)\n JOIN aropenalloc ON ((aropenalloc_doctype='S' AND aropenalloc_doc_id=cohead_id) OR\n (aropenalloc_doctype='I' AND aropenalloc_doc_id=invchead_id))\n JOIN aropen ON (aropenalloc_aropen_id=aropen_id)\n JOIN curr_symbol ON (aropen_curr_id=curr_id)\nWHERE ((aropen_amount - aropen_paid) > 0)\n AND (NOT invchead_posted)\n AND (invchead_id=<? value("invchead_id") ?>)\nUNION\nSELECT cohead_id,\n arapply_source_docnumber AS aropen_docnumber,\n formatMoney(s.aropen_amount) AS f_total,\n formatMoney(s.aropen_paid -\n currToCurr(arapply_curr_id, s.aropen_curr_id,\n arapply_applied, arapply_postdate)) AS f_paid,\n formatMoney(s.aropen_amount - s.aropen_paid +\n currToCurr(arapply_curr_id, s.aropen_curr_id,\n arapply_applied, arapply_postdate)) AS f_balance,\n currToCurr(arapply_curr_id, s.aropen_curr_id,\n arapply_applied, arapply_postdate) AS allocated,\n formatMoney(currToCurr(arapply_curr_id, s.aropen_curr_id,\n arapply_applied,\n arapply_postdate)) AS f_allocated,\n currToCurr(arapply_curr_id, invchead_curr_id,\n arapply_applied, t.aropen_docdate) AS allocated_invccurr,\n formatMoney(currToCurr(arapply_curr_id, invchead_curr_id,\n arapply_applied,\n t.aropen_docdate)) AS f_allocated_invccurr,\n curr_symbol AS aropen_currsymbol\n FROM arapply, aropen s, aropen t, cohead, invchead, curr_symbol\nWHERE ( (s.aropen_id=arapply_source_aropen_id)\n AND (arapply_target_aropen_id=t.aropen_id)\n AND (arapply_target_doctype='I')\n AND (arapply_target_docnumber=invchead_invcnumber)\n AND (arapply_source_aropen_id=s.aropen_id)\n AND (arapply_curr_id=curr_id)\n AND (arapply_reftype='S')\n AND (cohead_number=invchead_ordernumber)\n AND (invchead_posted)\n AND (invchead_id=<? value("invchead_id") ?>) )\nORDER BY aropen_docnumber;\n \n \n currency\n SELECT currConcat(curr_id) AS currConcat, curr_symbol\nFROM invchead, curr_symbol\nWHERE (invchead_id = <? value("invchead_id") ?>)\n AND (invchead_curr_id = curr_id);\n \n \n logo\n SELECT image_data \nFROM image \nWHERE ((image_name='logo'));\n \n \n tracknum\n select formatdate(shiphead_shipdate) AS f_shipdate, shiphead_tracknum, shiphead_shipvia from cohead, shiphead, invchead \nwhere \ncohead_id = shiphead_order_id \nand shiphead_order_type = 'SO' \nand cohead_number = invchead_ordernumber \nand invchead_id = <? value("invchead_id") ?> \norder by shiphead_shipdate;\n \n \n \n 360\n \n \n 215\n 5\n 270\n 111\n \n stretch\n \n logo\n image_data\n \n \n \n \n \n 430\n 220\n 300\n 20\n \n 0\n \n Arial\n 12\n normal\n \n \n \n \n GroupHead\n f_shiptoaddress\n \n \n \n \n \n 129\n 140\n 111\n 20\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n GroupHead\n invoicenumber\n \n \n \n \n \n 430\n 200\n 300\n 20\n \n \n Luciduxsans\n 12\n 48\n \n \n \n \n GroupHead\n invchead_shipto_name\n \n \n \n \n \n 55\n 200\n 270\n 20\n \n \n Luciduxsans\n 12\n 48\n \n \n \n \n GroupHead\n invchead_billto_name\n \n \n \n \n \n 5\n 5\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n GroupHead\n remitto_name\n \n \n \n \n 140\n 125\n 100\n 20\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n GroupHead\n ordernumber\n \n \n \n \n 120\n 155\n 120\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n GroupHead\n invchead_ponumber\n \n \n \n \n 650\n 100\n 95\n 20\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n GroupHead\n f_orderdate\n \n \n \n \n 95\n 170\n 145\n 20\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n GroupHead\n cust_number\n \n \n \n \n 5\n 25\n 203\n 16\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n GroupHead\n remitto_adr\n \n \n \n \n 55\n 220\n 300\n 20\n \n 0\n \n Arial\n 12\n normal\n \n \n \n \n GroupHead\n f_billtoaddress\n \n \n \n \n \n \n 5\n 350\n 745\n 350\n 2\n \n \n \n 555\n 115\n 190\n 20\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n GroupHead\n invchead_fob\n \n \n \n \n \n 620\n 40\n 125\n 20\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n GroupHead\n f_invoicedate\n \n \n \n \n \n \n 620\n 55\n 125\n 20\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n GroupHead\n due_date\n \n \n \n \n \n 615\n 70\n 130\n 20\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n GroupHead\n dis_date\n \n \n \n \n \n 545\n 85\n 200\n 20\n \n \n Sans Serif\n 8\n normal\n \n \n \n \n GroupHead\n terms_descrip\n \n \n \n
\n tracknumber\n \n tracknum\n shiphead_shipdate\n \n 41\n \n 40\n 35\n 745\n 35\n 0\n \n \n \n \n \n \n \n 12\n \n 40\n 5\n 745\n 5\n 0\n \n \n \n \n \n tracknum\n \n 21\n \n \n 160\n 0\n 225\n 20\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n tracknum\n shiphead_shipvia\n \n \n \n \n 390\n 0\n 280\n 20\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n tracknum\n shiphead_tracknum\n \n \n \n \n 40\n 0\n 100\n 20\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n tracknum\n f_shipdate\n \n \n \n
\n
\n ColumnHeadings\n \n \n GroupHead\n \n 41\n \n \n \n \n \n 490\n 10\n 71\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n currency\n currConcat\n \n \n \n 40\n 35\n 745\n 35\n 2\n \n \n \n \n \n \n
\n
\n items\n \n \n Detail\n \n 93\n \n \n 25\n 5\n 120\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n f_billed\n \n \n \n \n 260\n 45\n 480\n 14\n \n \n Arial\n 8\n normal\n \n \n \n \n Detail\n coitem_characteristics\n \n \n \n \n 440\n 70\n 365\n 14\n \n 0\n \n Arial\n 8\n normal\n \n \n \n \n Detail\n lotserial\n \n \n \n \n \n 171\n 5\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n invuom\n \n \n \n \n 492\n 5\n 31\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n currency\n curr_symbol\n \n \n \n \n 645\n 5\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n f_extprice\n \n \n \n \n 260\n 35\n 300\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n Detail\n descrip2\n \n \n \n \n \n 540\n 5\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n f_unitprice\n \n \n \n \n 70\n 70\n 365\n 14\n \n 0\n \n Arial\n 8\n normal\n \n \n \n \n Detail\n invcitem_notes\n \n \n \n \n 260\n 5\n 220\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n number\n \n \n \n \n 260\n 25\n 300\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n Detail\n descrip1\n \n \n \n
\n
\n allocatedCMs\n \n unnamed\n cohead_id\n \n 41\n \n \n 45\n 35\n 750\n 35\n 0\n \n \n \n \n 45\n 0\n 750\n 0\n 0\n \n \n \n \n \n \n \n 21\n \n \n 600\n 0\n 31\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n currency\n curr_symbol\n \n \n \n \n \n 640\n 0\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n allocatedCMs\n allocated_invccurr\n \n extprice\n \n \n \n \n \n \n allocatedCMs\n \n 21\n \n \n 140\n 0\n 40\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n allocatedCMs\n aropen_currsymbol\n \n \n \n \n 640\n 0\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n allocatedCMs\n f_allocated_invccurr\n \n \n \n 590\n 0\n 590\n 30\n 0\n \n \n \n 280\n 0\n 90\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n allocatedCMs\n f_paid\n \n \n \n \n 180\n 0\n 90\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n allocatedCMs\n f_total\n \n \n \n \n 480\n 0\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n allocatedCMs\n f_allocated\n \n \n \n \n 600\n 0\n 31\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n currency\n curr_symbol\n \n \n \n \n 40\n 0\n 90\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n allocatedCMs\n aropen_docnumber\n \n \n \n \n 380\n 0\n 90\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n allocatedCMs\n f_balance\n \n \n \n
\n \n \n 167\n \n \n 605\n 5\n 31\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n currency\n curr_symbol\n \n \n \n \n 640\n 25\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n GroupExtended\n f_freight\n \n \n \n \n 20\n 25\n 540\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n GroupExtended\n invchead_notes\n \n \n \n \n \n 605\n 85\n 31\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n currency\n curr_symbol\n \n \n \n \n \n 605\n 25\n 31\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n currency\n curr_symbol\n \n \n \n \n \n \n 640\n 103\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n GroupExtended\n f_totaldue\n \n \n \n \n 640\n 5\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n foot\n f_extprice\n \n \n \n \n 605\n 103\n 31\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n currency\n curr_symbol\n \n \n \n \n 640\n 45\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n GroupExtended\n f_misc\n \n \n \n \n 640\n 85\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n GroupExtended\n f_allocated\n \n \n \n \n \n 640\n 65\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n GroupExtended\n f_tax\n \n \n \n \n 605\n 45\n 31\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n currency\n curr_symbol\n \n \n \n \n 605\n 65\n 31\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n currency\n curr_symbol\n \n \n \n \n 5\n 5\n 745\n 5\n 2\n \n \n \n 325\n 145\n 20\n 20\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 20\n 45\n 540\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n GroupExtended\n invchead_misc_descrip\n \n \n \n \n \n \n 375\n 145\n 20\n 20\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n Context Query\n page_count\n \n \n \n \n 27\n \n \n 330\n 2\n 20\n 20\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 375\n 2\n 20\n 20\n \n \n Sans Serif\n 10\n normal\n \n \n \n \n Context Query\n page_count\n \n \n \n \n
\n With Logo - With Invoice Currency 0 2015-10-01 17:15:58.47729 257 InvoiceInformation \N \n\n Invoice Information\n InvoiceInformation\n \n \n \n Parameter Query\n watermark\n \n 25\n \n Letter\n \n 50\n 50\n 50\n 50\n \n GroupHead\n SELECT invchead_id, invchead_ponumber,\n formatDate(invchead_shipdate) AS f_shipdate,\n formatDate(invchead_invcdate) AS f_invcdate,\n formatMoney(invoiceTotal(invchead_id)) AS f_amount,\n invchead_billto_name, invchead_billto_address1,\n invchead_billto_address2, invchead_billto_address3,\n ( invchead_billto_city || ' ' || invchead_billto_state || ', '\n || invchead_billto_zipcode ) AS billtocitystatezip,\n invchead_shipto_name, invchead_shipto_address1,\n invchead_shipto_address2, invchead_shipto_address3,\n ( invchead_shipto_city || ' ' || invchead_shipto_state || ', '\n || invchead_shipto_zipcode ) AS shiptocitystatezip,\n invchead_notes, invchead_invcnumber\nFROM invchead LEFT OUTER JOIN (invcitem LEFT OUTER JOIN item ON (invcitem_item_id=item_id) ) ON (invcitem_invchead_id=invchead_id)\nWHERE (invchead_id=<? value("invchead_id") ?>)\nGROUP BY invchead_id, invchead_ponumber,\n invchead_shipdate, invchead_invcdate,\n invchead_misc_amount, invchead_freight,\n invchead_billto_name, invchead_billto_address1,\n invchead_billto_address2, invchead_billto_address3,\n invchead_billto_city, invchead_billto_state, invchead_billto_zipcode,\n invchead_shipto_name, invchead_shipto_address1,\n invchead_shipto_address2, invchead_shipto_address3,\n invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode,\n invchead_notes, invchead_invcnumber;\n \n \n CustInfo\n SELECT cust_id,\n cust_number,\n cust_name,\n addr_line1 AS cust_address1,\n addr_line2 AS cust_address2,\n addr_line3 AS cust_address3,\n addr_city || ' ' || addr_state || ', ' || addr_postalcode AS custcitystatezip\nFROM invchead, custinfo\nLEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\nLEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\nWHERE ( (invchead_id=<? value("invchead_id") ?>)\n AND (invchead_cust_id=cust_id) );\n \n \n Details\n SELECT 1 as grpnum,\n arapply_id,\n CASE WHEN (arapply_source_doctype = 'C') THEN text('C/M')\n WHEN (arapply_fundstype='C') THEN text('Check')\n WHEN (arapply_fundstype='T') THEN text('Certified Check')\n WHEN (arapply_fundstype='M') THEN text('Master Card')\n WHEN (arapply_fundstype='V') THEN text('Visa')\n WHEN (arapply_fundstype='A') THEN text('American Express')\n WHEN (arapply_fundstype='D') THEN text('Discover Card')\n WHEN (arapply_fundstype='R') THEN text('Other Credit Card')\n WHEN (arapply_fundstype='K') THEN text('Cash')\n WHEN (arapply_fundstype='W') THEN text('Wire Transfer')\n WHEN (arapply_fundstype='O') THEN text('Other')\n END AS documenttype,\n CASE WHEN (arapply_source_doctype = 'C') THEN arapply_source_docnumber\n WHEN (arapply_source_doctype = 'R') THEN arapply_source_docnumber\n WHEN (arapply_source_doctype = 'K') THEN arapply_refnumber\n ELSE text('Error')\n END AS docnumber,\n formatDate(arapply_postdate) AS f_postdate,\n formatMoney(arapply_applied) AS f_amount\n FROM arapply, invchead\n WHERE ( (arapply_target_doctype='I')\n AND (arapply_target_docnumber=invchead_invcnumber)\n AND (invchead_id=<? value("invchead_id") ?>) )\nORDER BY arapply_postdate;\n \n \n \n 389\n \n \n 590\n 80\n 125\n 20\n \n \n Arial\n 12\n bold\n \n \n \n \n GroupHead\n f_invcdate\n \n \n \n \n 155\n 140\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n CustInfo\n cust_address2\n \n \n \n \n \n 155\n 80\n 125\n 20\n \n \n Arial\n 12\n bold\n \n \n \n \n CustInfo\n cust_number\n \n \n \n \n 25\n 280\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n GroupHead\n invchead_billto_address2\n \n \n \n \n 155\n 120\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n CustInfo\n cust_address1\n \n \n \n \n 590\n 125\n 125\n 20\n \n \n Arial\n 12\n bold\n \n \n \n \n GroupHead\n f_amount\n \n \n \n \n 25\n 240\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n GroupHead\n invchead_billto_name\n \n \n \n \n 155\n 25\n 125\n 20\n \n \n Arial\n 12\n bold\n \n \n \n \n GroupHead\n invchead_invcnumber\n \n \n \n \n 155\n 160\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n CustInfo\n cust_address3\n \n \n \n \n 155\n 100\n 300\n 20\n \n \n Arial\n 12\n bold\n \n \n \n \n CustInfo\n cust_name\n \n \n \n \n \n \n 155\n 180\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n CustInfo\n custcitystatezip\n \n \n \n \n \n 25\n 320\n 325\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n GroupHead\n billtocitystatezip\n \n \n \n \n \n \n 385\n 320\n 325\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n GroupHead\n shiptocitystatezip\n \n \n \n \n \n 385\n 300\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n GroupHead\n invchead_shipto_address3\n \n \n \n \n \n 385\n 280\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n GroupHead\n invchead_shipto_address2\n \n \n \n \n 155\n 50\n 125\n 20\n \n \n Arial\n 12\n bold\n \n \n \n \n GroupHead\n invchead_ponumber\n \n \n \n \n \n 385\n 240\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n GroupHead\n invchead_shipto_name\n \n \n \n \n 20\n 365\n 690\n 20\n \n 0\n \n Arial\n 10\n bold\n \n \n \n \n GroupHead\n invchead_notes\n \n \n \n \n 25\n 300\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n GroupHead\n invchead_billto_address3\n \n \n \n \n 385\n 260\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n GroupHead\n invchead_shipto_address1\n \n \n \n \n \n 25\n 260\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n GroupHead\n invchead_billto_address1\n \n \n \n \n 590\n 100\n 125\n 20\n \n \n Arial\n 12\n bold\n \n \n \n \n GroupHead\n f_shipdate\n \n \n \n
\n details\n \n header\n grpnum\n \n 47\n \n \n \n \n 5\n 40\n 745\n 40\n 2\n \n \n \n \n \n \n \n Details\n \n 17\n \n \n 645\n 0\n 100\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n Details\n f_amount\n \n \n \n \n 110\n 0\n 425\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n Details\n docnumber\n \n \n \n \n 5\n 0\n 100\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n Details\n documenttype\n \n \n \n \n 540\n 0\n 100\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n Details\n f_postdate\n \n \n \n
\n \n 17\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 281 InvoiceRegister \N \n\n Invoice Register\n InvoiceRegister\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("accnt_id") ?>\n ( SELECT (accnt_number || '-' || accnt_descrip)\n FROM accnt\n WHERE (accnt_id=<? value("accnt_id") ?>) )\n <? else ?>\n text('All Accounts')\n <? endif ?>\n AS accnt\n \n \n detail\n SELECT gltrans_id, gltrans_date AS transdate,\n formatDate(gltrans_date) AS f_transdate,\n gltrans_source AS source,\n CASE WHEN(gltrans_doctype='IN') THEN text('Invoice')\n WHEN(gltrans_doctype='CM') THEN text('Credit Memo')\n WHEN(gltrans_doctype='DM') THEN text('Debit Memo')\n WHEN(gltrans_doctype='CD') THEN text('Customer Deposit')\n ELSE gltrans_doctype\n END AS doctype,\n gltrans_docnumber AS docnumber,\n CASE WHEN(gltrans_doctype='IN') THEN\n (SELECT invchead_shipto_name\n FROM aropen LEFT OUTER JOIN\n invchead\n ON (invchead_id=aropen_cobmisc_id\n AND invchead_cust_id=aropen_cust_id)\n WHERE ((aropen_docnumber=gltrans_docnumber)\n AND (aropen_doctype='I')))\n ELSE firstLine(gltrans_notes)\n END AS transnotes,\n (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n CASE WHEN (gltrans_amount < 0) THEN formatMoney(ABS(gltrans_amount))\n ELSE ''\n END AS f_debit,\n CASE WHEN (gltrans_amount < 0) THEN ABS(gltrans_amount)\n ELSE 0\n END AS debit,\n CASE WHEN (gltrans_amount > 0) THEN formatMoney(gltrans_amount)\n ELSE ''\n END AS f_credit,\n CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n ELSE 0\n END AS credit\n FROM gltrans, accnt\n WHERE ((gltrans_accnt_id=accnt_id)\n AND (gltrans_doctype IN ('IN', 'CM', 'DM', 'CD'))\n AND (gltrans_source = 'A/R')\n AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("accnt_id") ?>\n AND (gltrans_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n )\nUNION\nSELECT sltrans_id AS id, sltrans_date AS transdate,\n formatDate(sltrans_date) AS f_transdate,\n sltrans_source AS source,\n CASE WHEN(sltrans_doctype='IN') THEN text('Invoice')\n WHEN(sltrans_doctype='CM') THEN text('Credit Memo')\n WHEN(sltrans_doctype='DM') THEN text('Debit Memo')\n WHEN(sltrans_doctype='CD') THEN text('Customer Deposit')\n ELSE sltrans_doctype\n END AS doctype,\n sltrans_docnumber AS docnumber,\n CASE WHEN(sltrans_doctype='IN') THEN\n (SELECT invchead_shipto_name\n FROM aropen LEFT OUTER JOIN\n invchead\n ON (invchead_id=aropen_cobmisc_id\n AND invchead_cust_id=aropen_cust_id)\n WHERE ((aropen_docnumber=sltrans_docnumber)\n AND (aropen_doctype='I')))\n ELSE firstLine(sltrans_notes)\n END AS transnotes,\n (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n CASE WHEN (sltrans_amount < 0) THEN formatMoney(ABS(sltrans_amount))\n ELSE ''\n END AS f_debit,\n CASE WHEN (sltrans_amount < 0) THEN ABS(sltrans_amount)\n ELSE 0\n END AS debit,\n CASE WHEN (sltrans_amount > 0) THEN formatMoney(sltrans_amount)\n ELSE ''\n END AS f_credit,\n CASE WHEN (sltrans_amount > 0) THEN sltrans_amount\n ELSE 0\n END AS credit\n FROM sltrans, accnt\n WHERE ((sltrans_accnt_id=accnt_id)\n AND (sltrans_doctype IN ('IN', 'CM', 'DM', 'CD'))\n AND (sltrans_source = 'A/R')\n AND (sltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("accnt_id") ?>\n AND (sltrans_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n )\nORDER BY transdate, docnumber;\n \n \n 205\n \n \n \n 545\n 70\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n \n \n \n \n \n 140\n 70\n 290\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n accnt\n \n \n \n \n \n 545\n 90\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n 5\n 200\n 745\n 200\n 2\n \n \n \n \n \n 6\n \n \n 41\n \n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n \n \n \n
\n detail\n \n bydate\n f_transdate\n \n 21\n \n \n 10\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_transdate\n \n \n \n \n 21\n \n \n \n 509\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n debit\n \n money\n \n \n \n 600\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n credit\n \n money\n \n \n 5\n 15\n 745\n 15\n 1\n \n \n \n \n \n detail\n \n 31\n \n \n 95\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n source\n \n \n \n \n 160\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n docnumber\n \n \n \n \n 160\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n doctype\n \n \n \n \n 509\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_debit\n \n \n \n \n 245\n 15\n 260\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n account\n \n \n \n \n 600\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_credit\n \n \n \n \n 245\n 0\n 260\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n transnotes\n \n \n \n
\n \n 18\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 21\n \n \n 600\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n credit\n \n money\n \n \n \n 509\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n debit\n \n money\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 370 ItemCostDetail \N \n\n Item Costs Detail\n ItemCostDetail\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n item_descrip1,\n item_descrip2,\n costelem_type,\n<? if exists("standardCost") ?>\n text('Standard Cost')\n<? else ?>\n text('Actual Cost')\n<? endif ?>\n AS costtype\n FROM item, costelem\n WHERE((item_id=<? value("item_id") ?>)\n AND (costelem_id=<? value("costelem_id") ?>));\n\n \n \n detail\n SELECT seqnumber, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescrip, uom_name,\n formatQtyper(qtyper) AS f_qtyper,\n formatScrap(bomitem_scrap) AS f_scrap,\n formatCost(cost) AS f_cost,\n formatCost(extendedcost) AS f_extendedcost,\n extendedcost\n FROM ( SELECT bomitem_seqnumber AS seqnumber,\n itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyper) AS qtyper, bomitem_scrap,\n item_number, item_descrip1, item_descrip2, uom_name,\n<? if exists("standardCost") ?>\n itemcost_stdcost AS cost,\n (itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyper * (1 + bomitem_scrap)) *\n itemcost_stdcost) AS extendedcost\n<? else ?>\n currToBase(itemcost_curr_id, itemcost_actcost, NULL) AS cost,\n (itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyper * (1 + bomitem_scrap)) *\n currToBase(itemcost_curr_id, itemcost_actcost, NULL)) AS extendedcost\n<? endif ?>\n FROM bomitem, item, itemcost, costelem, uom\n WHERE((bomitem_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires-1))\n AND (itemcost_item_id=item_id)\n AND (itemcost_costelem_id=costelem_id)\n AND (SELECT item_type!='C' FROM item WHERE item_id=<? value("item_id") ?>)\n AND (bomitem_parent_item_id=<? value("item_id") ?>)\n AND (costelem_id=<? value("costelem_id") ?>) ) ) AS data\n\nUNION\n\nSELECT seqnumber, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescrip, uom_name,\n formatQtyPer(bbomitem_qtyper) AS f_qtyper,\n formatScrap(bbomitem_costabsorb) AS f_scrap,\n formatCost(cost) AS f_cost,\n formatCost(extendedcost) AS f_extendedcost,\n extendedcost\n FROM ( SELECT bbomitem_seqnumber AS seqnumber, bbomitem_qtyper, bbomitem_costabsorb,\n item_number, item_descrip1, item_descrip2, uom_name,\n<? if exists("standardCost") ?>\n itemcost_stdcost AS cost,\n (itemcost_stdcost / bbomitem_qtyper * bbomitem_costabsorb) AS extendedcost\n<? else ?>\n currToBase(itemcost_curr_id, itemcost_actcost, NULL) AS cost,\n (currToBase(itemcost_curr_id, itemcost_actcost, NULL) / bbomitem_qtyper * bbomitem_costabsorb) AS extendedcost\n<? endif ?>\n FROM bbomitem, item, itemcost, uom\n WHERE((bbomitem_parent_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (CURRENT_DATE BETWEEN bbomitem_effective AND (bbomitem_expires-1))\n AND (itemcost_item_id=bbomitem_parent_item_id)\n AND (itemcost_costelem_id=<? value("costelem_id") ?>)\n AND (SELECT item_type='C' FROM item WHERE item_id=<? value("item_id") ?>)\n AND (bbomitem_item_id=<? value("item_id") ?>) )\n\n UNION\n\n SELECT source.bbomitem_seqnumber AS seqnumber,\n source.bbomitem_qtyper, target.bbomitem_costabsorb,\n item_number, item_descrip1, item_descrip2, uom_name,\n<? if exists("standardCost") ?>\n itemcost_stdcost AS cost,\n (itemcost_stdcost * source.bbomitem_qtyper / target.bbomitem_qtyper * target.bbomitem_costabsorb) AS extendedcost\n<? else ?>\n currToBase(itemcost_curr_id, itemcost_actcost, NULL) AS cost,\n (currToBase(itemcost_curr_id, itemcost_actcost, NULL) * source.bbomitem_qtyper / target.bbomitem_qtyper * target.bbomitem_costabsorb) AS extendedcost\n<? endif ?>\n FROM item, itemcost, bbomitem AS target, bbomitem AS source, uom\n WHERE ( (source.bbomitem_parent_item_id=target.bbomitem_parent_item_id)\n AND (CURRENT_DATE BETWEEN source.bbomitem_effective AND (source.bbomitem_expires-1))\n AND (CURRENT_DATE BETWEEN target.bbomitem_effective AND (target.bbomitem_expires-1))\n AND (source.bbomitem_item_id=itemcost_item_id)\n AND (source.bbomitem_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (item_type='Y')\n AND (SELECT item_type='C' FROM item WHERE item_id=<? value("item_id") ?>)\n AND (target.bbomitem_item_id=<? value("item_id") ?>)\n AND (itemcost_costelem_id=<? value("costelem_id") ?>) ) ) AS data\n ORDER BY seqnumber;\n \n \n 223\n \n \n \n \n 490\n 80\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n costelem_type\n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n 100\n 80\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n \n \n 100\n 120\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n \n \n \n \n 490\n 100\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n costtype\n \n \n \n \n 100\n 100\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n \n 6\n \n \n 28\n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 18\n \n \n 220\n 0\n 185\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemdescrip\n \n \n \n \n 494\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_scrap\n \n \n \n \n 60\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 165\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n \n 5\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n seqnumber\n \n \n \n \n 410\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyper\n \n \n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_cost\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_extendedcost\n \n \n \n
\n \n 18\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 18\n \n \n \n 660\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n extendedcost\n \n qty\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 170 ItemCostHistory \N \n\n Item Costs History\n ItemCostHistory\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n item_descrip1,\n item_descrip2\n FROM item\n WHERE (item_id=<? value("item_id") ?>);\n\n \n \n detail\n SELECT costhist_id,\n costelem_type as f_element,\n formatBoolYN(costhist_lowlevel) as f_lower,\n CASE WHEN costhist_type='A' THEN 'Actual'\n WHEN costhist_type='S' THEN 'Standard'\n WHEN costhist_type='D' THEN 'Delete'\n WHEN costhist_type='N' THEN 'New'\n END as f_type,\n formatDateTime(costhist_date) as f_time,\n costhist_username as f_user,\n formatCost(costhist_oldcost) as f_oldcost,\n formatCost(costhist_newcost) as f_newcost\n FROM costhist, costelem \n WHERE ((costhist_costelem_id=costelem_id)\n AND (costhist_item_id=<? value("item_id") ?>)\n)\nORDER BY costhist_date, costelem_type;\n \n \n 221\n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n 100\n 100\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n 100\n 120\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n \n \n 100\n 80\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n \n \n \n \n 6\n \n \n 26\n \n \n \n \n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 50\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_element\n \n \n \n \n 470\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_user\n \n \n \n \n 245\n 0\n 45\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_lower\n \n \n \n \n 295\n 0\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_type\n \n \n \n \n 575\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_oldcost\n \n \n \n \n 365\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_time\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_newcost\n \n \n \n
\n \n 16\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 169 ItemCostSummary \N \n\n Item Costs Summary\n ItemCostSummary\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n item_descrip1,\n item_descrip2\n FROM item\n WHERE (item_id=<? value("item_id") ?>);\n\n \n \n detail\n SELECT itemcost_id,\n CASE WHEN (costelem_sys) THEN 1\n ELSE 0\n END,\n costelem_type as f_element,\n formatBoolYN(itemcost_lowlevel) as f_lower,\n formatCost(itemcost_stdcost) as f_stdcost,\n formatDate(itemcost_posted, 'Never') as f_posted,\n formatcost(currToBase(itemcost_curr_id, itemcost_actcost, NULL)) as f_actcost,\n formatDate(itemcost_updated, 'Never') as f_updated,\n itemcost_stdcost AS stdcost, currToBase(itemcost_curr_id, itemcost_actcost, NULL) AS actcost\n FROM itemcost, costelem\n WHERE ((itemcost_costelem_id=costelem_id)\n AND (itemcost_item_id=<? value("item_id") ?>)\n)\nORDER BY itemcost_lowlevel, costelem_type;\n \n \n 221\n \n \n \n 100\n 80\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n \n \n \n \n \n 100\n 120\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n 100\n 100\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n 6\n \n \n 26\n \n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 330\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_stdcost\n \n \n \n \n 50\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_element\n \n \n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_updated\n \n \n \n \n 280\n 0\n 45\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_lower\n \n \n \n \n 409\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_posted\n \n \n \n \n 490\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_actcost\n \n \n \n
\n \n 16\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 16\n \n \n 490\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n actcost\n \n price\n \n \n \n \n \n 330\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n stdcost\n \n price\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 168 ItemCostsByClassCode \N \n\n Item Costs By Class Code\n ItemCostsByClassCode\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("classcode_id") ?>\n ( SELECT (classcode_code || '-' || classcode_descrip)\n FROM classcode\n WHERE (classcode_id=<? value("classcode_id") ?>) )\n <? elseif exists("classcode_pattern") ?>\n text(<? value("classcode_pattern") ?>)\n <? else ?>\n text('All Class Codes')\n <? endif ?>\n AS classcode;\n \n \n detail\n SELECT item_id,\n item_number,\n item_descrip1,\n item_descrip2,\n uom_name as f_uom,\n formatCost(scost) as f_stdcost,\n formatCost(acost) as f_actcost,\n classcode_code\n FROM ( SELECT item_id,\n item_number,\n item_descrip1,\n item_descrip2,\n uom_name,\n stdcost(item_id) AS scost,\n actcost(item_id) AS acost,\n classcode_code\n FROM item, classcode, uom\n WHERE ((item_classcode_id=classcode_id)\n AND (item_inv_uom_id=uom_id)\n <? if exists("onlyShowActive") ?>\n AND (item_active) \n <? endif ?> \n <? if exists("classcode_id") ?>\n AND (classcode_id=<? value("classcode_id") ?>)\n <? elseif exists("classcode_pattern") ?>\n AND (classcode_code ~ <? value("classcode_pattern") ?>)\n <? endif ?>\n )\n ) AS data\n WHERE ( (true)\n<? if exists("onlyShowZeroCosts") ?>\n AND ((scost=0) OR (acost=0))\n<? endif ?>\n<? if exists("onlyShowDiffCosts") ?>\n AND (scost != acost)\n<? endif ?>\n )\nORDER BY item_number\n \n \n 234\n \n \n \n \n \n \n 5\n 228\n 745\n 228\n 2\n \n \n \n \n \n 120\n 120\n 565\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n classcode\n \n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 51\n \n \n 400\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_uom\n \n \n \n \n 500\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_stdcost\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 5\n 0\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n classcode_code\n \n \n \n \n 70\n 0\n 228\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 70\n 30\n 228\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 70\n 15\n 228\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 600\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_actcost\n \n \n \n
\n \n 16\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 455 ItemSources \N \n\n Item Sources\n ItemSources\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT item_number, vend_name,\n item_descrip1, item_descrip2,\n uom_name,\n itemsrc_vend_item_number as f_venditem,\n itemsrc_vend_uom as f_venduom,\n formatQty(itemsrc_invvendoruomratio) as f_uomratio\nFROM itemsrc, vendinfo, item, uom\nWHERE ((itemsrc_vend_id=vend_id)\n AND (itemsrc_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n<? if exists("item_id") ?>\n AND (itemsrc_item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("vend_id") ?>\n AND (itemsrc_vend_id=<? value("vend_id") ?>)\n<? endif ?>\n)\nORDER By item_number, vend_name;\n \n \n 221\n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n \n \n \n \n \n \n 15\n 38\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 56\n \n \n 435\n 2\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n \n 695\n 2\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_uomratio\n \n \n \n \n 230\n 2\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 640\n 2\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_venduom\n \n \n \n \n 230\n 32\n 400\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 230\n 17\n 400\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n 5\n 50\n 745\n 50\n 0\n \n \n \n 485\n 2\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_venditem\n \n \n \n \n 5\n 2\n 215\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_name\n \n \n \n
\n \n 16\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 85\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 364 JobCosting \N \n\n Job Costing\n JobCosting\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT formatwonumber(<? value("wo_id") ?>) AS wonumber;\n \n \n \n detail\n manufacture\n jobcosting\n \n \n 141\n \n \n \n \n 0\n 135\n 740\n 135\n 2\n \n \n \n \n \n \n \n 120\n 70\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n wonumber\n \n \n \n \n \n \n 9\n \n \n 29\n \n \n \n \n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n
\n detail\n \n \n detail\n \n 21\n \n 0\n 20\n 740\n 20\n 0\n \n \n \n 630\n 0\n 29\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom\n \n \n \n \n 80\n 0\n 219\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n code\n \n \n \n \n 305\n 0\n 229\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n descrip\n \n \n \n \n 15\n 0\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n type\n \n \n \n \n 540\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qty\n \n qty\n \n \n \n 666\n 0\n 84\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cost\n \n cost\n \n \n
\n \n 21\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 18\n \n \n 670\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cost\n \n cost\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 79 ListOpenSalesOrders \N \n\n List Open Sales Orders\n ListOpenSalesOrders\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse;\n\n \n \n detail\n opensalesorders\n detail\n \n \n 173\n \n \n \n 4\n 168\n 744\n 168\n 2\n \n \n \n \n \n \n 10\n 43\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 95\n 0\n 325\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cohead_billtoname\n \n \n \n \n 425\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cohead_custponumber\n \n \n \n \n 580\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cohead_orderdate\n \n \n \n \n 5\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cohead_number\n \n \n \n
\n \n 16\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 361 ListTransferOrders \N \n\n List Transfer Orders\n ListTransferOrders\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("src_warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("src_warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?> AS src_warehous_code,\n <? if exists("dest_warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("dest_warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?> AS dest_warehous_code,\n CASE WHEN (<? value ("tohead_status") ?>='C') THEN 'Closed'\n WHEN (<? value ("tohead_status") ?>='O') THEN 'Open'\n ELSE text('All Statuses')\n END AS status;\n\n \n \n detail\n SELECT tohead_number,\n tohead_srcname,\n tohead_trnsname,\n tohead_destname,\n formatDate(tohead_orderdate) AS f_orderdate,\n formatDate(MIN(toitem_schedshipdate)) AS f_scheddate,\n formatDate(DATE(MAX(shipitem_shipdate))) AS f_shipdate,\n CASE WHEN (tohead_status='C') THEN 'Closed'\n WHEN (tohead_status='O') THEN 'Open'\n ELSE tohead_status\n END AS status\n FROM tohead, toitem LEFT OUTER JOIN\n (shipitem JOIN\n shiphead ON (shipitem_shiphead_id=shiphead_id\n AND shiphead_order_type='TO')\n ) ON (shipitem_orderitem_id=toitem_id)\n WHERE ((toitem_tohead_id=tohead_id)\n AND (toitem_status<>'X')\n<? if exists("tohead_status") ?>\n AND (tohead_status=<? value("tohead_status") ?>)\n<? elseif exists("excludeClosed") ?>\n AND (tohead_status <> 'C')\n<? endif ?>\n<? if exists("src_warehous_id") ?>\n AND (tohead_src_warehous_id=<? value("src_warehous_id") ?>)\n<? endif ?>\n<? if exists("dest_warehous_id") ?>\n AND (tohead_dest_warehous_id=<? value("dest_warehous_id") ?>)\n<? endif ?>\n)\nGROUP BY tohead_number, tohead_srcname, tohead_trnsname, tohead_destname,\n tohead_orderdate, tohead_status\nORDER BY tohead_number;\n \n \n 221\n \n \n \n \n \n \n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n 140\n 150\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n status\n \n \n \n \n \n 140\n 105\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n src_warehous_code\n \n \n \n \n 140\n 130\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n dest_warehous_code\n \n \n \n \n \n \n 5\n \n \n 21\n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 15\n \n \n 5\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n tohead_number\n \n \n \n \n 600\n 0\n 100\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_shipdate\n \n \n \n \n 200\n 0\n 95\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n tohead_trnsname\n \n \n \n \n 300\n 0\n 95\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n tohead_destname\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n tohead_srcname\n \n \n \n \n 500\n 0\n 100\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n f_scheddate\n \n \n \n \n 400\n 0\n 100\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_orderdate\n \n \n \n \n 700\n 0\n 50\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n status\n \n \n \n
\n \n 15\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 217 LocationDispatchList \N \n\n Location Dispatch List\n LocationDispatchList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT warehous_code\nFROM whsinfo\nWHERE (warehous_id=%1);\n \n \n detail\n SELECT formatLocationBarcode(location_id) AS barcode,\n formatLocationIssueBarcode(location_id) AS issuebarcode,\n formatLocationContentsBarcode(location_id) AS contentsbarcode,\n location_name, firstLine(location_descrip) AS description\nFROM location\nWHERE (location_id IN (%2))\nORDER BY location_name;\n \n \n 131\n \n \n 5\n 125\n 985\n 125\n 2\n \n \n \n \n \n 510\n 35\n 80\n 20\n \n \n Arial\n 12\n bold\n \n \n \n \n head\n warehous_code\n \n \n \n \n \n \n \n
\n detail\n \n detail\n location_name\n \n \n \n detail\n \n 71\n \n \n 15\n 5\n 125\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n location_name\n \n \n \n \n 335\n 30\n 280\n 25\n \n 128\n 20\n \n \n detail\n contentsbarcode\n \n \n \n \n 5\n 30\n 280\n 25\n \n 128\n 20\n \n \n detail\n barcode\n \n \n \n \n 670\n 30\n 280\n 25\n \n 128\n 20\n \n \n detail\n issuebarcode\n \n \n \n \n 170\n 5\n 275\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n description\n \n \n \n 5\n 65\n 985\n 65\n 0\n \n \n
\n
\n 0 2015-10-01 17:15:58.47729 94 MaterialUsageVarianceByBOMItem \N \n\n Material Usage Variance By BOM Item\n MaterialUsageVarianceByBOMItem\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT parent.item_number AS parent_number,\n parent.item_descrip1 AS parent_descrip1,\n parent.item_descrip2 AS parent_descrip2,\n puom.uom_name AS parent_invuom,\n child.item_number AS comp_number,\n child.item_descrip1 AS comp_descrip1,\n child.item_descrip2 AS comp_descrip2,\n cuom.uom_name AS comp_invuom,\n bomitem_seqnumber as comp_seqnumber,\n <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse\n FROM item as parent, item as child, uom AS puom, uom AS cuom, bomitem\n WHERE ((parent.item_id=<? value("item_id") ?>)\n AND (parent.item_inv_uom_id=puom.uom_id)\n AND (bomitem_item_id=child.item_id)\n AND (child.item_inv_uom_id=cuom.uom_id)\n AND (bomitem_id=<? value("bomitem_id") ?>) );\n\n \n \n detail\n SELECT formatDate(posted) AS f_posted,\n formatQty(ordered) AS f_ordered,\n formatQty(received) AS f_produced,\n formatQty(projreq) AS f_projreq,\n formatQtyPer(projqtyper) AS f_projqtyper,\n formatQty(actiss) AS f_actiss, \n formatQtyPer(actqtyper) AS f_actqtyper,\n formatQtyPer(actqtyper - projqtyper) AS f_qtypervar,\n CASE WHEN (actqtyper=projqtyper) THEN formatPrcnt(0)\n WHEN (projqtyper=0) THEN formatPrcnt(actqtyper)\n ELSE formatPrcnt((1 - (actqtyper / projqtyper)) * -1)\n END AS f_percent\n FROM ( SELECT womatlvar_posted AS posted,\n womatlvar_qtyord AS ordered,\n womatlvar_qtyrcv AS received,\n (womatlvar_qtyrcv * (womatlvar_qtyper * (1 + womatlvar_scrap))) AS projreq,\n womatlvar_qtyper AS projqtyper,\n (womatlvar_qtyiss) AS actiss, (womatlvar_qtyiss / (womatlvar_qtyrcv * (1 + womatlvar_scrap))) AS actqtyper \n FROM womatlvar, itemsite AS component,\n itemsite AS parent\n WHERE ((womatlvar_parent_itemsite_id=parent.itemsite_id)\n AND (womatlvar_component_itemsite_id=component.itemsite_id)\n AND (womatlvar_bomitem_id=<? value("bomitem_id") ?>)\n AND (womatlvar_posted BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("warehous_id") ?>\n AND (component.itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n )\n ) AS data\nORDER BY posted;\n \n \n 237\n \n \n 80\n 140\n 50\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n comp_seqnumber\n \n \n \n 5\n 227\n 745\n 227\n 2\n \n \n \n 140\n 180\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n 360\n 60\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n parent_invuom\n \n \n \n \n \n \n \n \n 140\n 60\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n parent_number\n \n \n \n \n 360\n 120\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n comp_invuom\n \n \n \n \n \n \n \n 140\n 80\n 350\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n parent_descrip1\n \n \n \n \n \n 140\n 120\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n comp_number\n \n \n \n \n 140\n 160\n 350\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n comp_descrip2\n \n \n \n \n \n \n \n \n \n \n 140\n 140\n 350\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n comp_descrip1\n \n \n \n \n 140\n 100\n 350\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n parent_descrip2\n \n \n \n \n \n \n 7\n \n \n 22\n \n \n \n \n \n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 17\n \n \n 250\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_projreq\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_percent\n \n \n \n \n 165\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_produced\n \n \n \n \n 85\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ordered\n \n \n \n \n 415\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_actiss\n \n \n \n \n 5\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_posted\n \n \n \n \n 330\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_projqtyper\n \n \n \n \n 493\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_actqtyper\n \n \n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtypervar\n \n \n \n
\n \n 17\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 96 MaterialUsageVarianceByComponentItem \N \n\n Material Usage Variance By Component Item\n MaterialUsageVarianceByComponentItem\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n item_descrip1,\n item_descrip2,\n uom_name,\n <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate\n FROM item JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (item_id=<? value("component_item_id") ?>);\n\n \n \n detail\n workOrderVariance\n material\n \n \n 234\n \n \n \n \n \n \n 120\n 120\n 350\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n \n \n \n \n 590\n 120\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n 5\n 228\n 745\n 228\n 2\n \n \n \n \n \n 120\n 80\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n 340\n 80\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n uom_name\n \n \n \n \n \n \n 120\n 100\n 350\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n \n \n 120\n 145\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n 590\n 100\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n 6\n \n \n 36\n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 51\n \n \n 580\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_actqtyper\n \n \n \n \n 85\n 15\n 400\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n parentdescrip\n \n \n \n \n 5\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_posted\n \n \n \n \n 494\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_projqtyper\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 494\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_projreq\n \n \n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_actiss\n \n \n \n \n 315\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ordered\n \n \n \n \n 665\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtypervarpercent\n \n \n \n \n 400\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_received\n \n \n \n \n 85\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n parentitemnumber\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtypervar\n \n \n \n
\n \n 16\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 95 MaterialUsageVarianceByItem \N \n\n Material Usage Variance By Item\n MaterialUsageVarianceByItem\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n item_descrip1,\n item_descrip2,\n uom_name,\n <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate\n FROM item JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (item_id=<? value("item_id") ?>);\n\n \n \n detail\n workOrderVariance\n material\n \n \n 234\n \n \n 5\n 228\n 745\n 228\n 2\n \n \n \n \n 605\n 90\n 120\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n 605\n 110\n 120\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n \n 360\n 90\n 120\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n uom_name\n \n \n \n \n \n \n \n 140\n 130\n 350\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n 140\n 110\n 350\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n \n 140\n 155\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n \n \n 140\n 90\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 51\n \n \n 85\n 15\n 395\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n componentdescrip\n \n \n \n \n 580\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_actqtyper\n \n \n \n \n 494\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_projqtyper\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 400\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_received\n \n \n \n \n 665\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtypervarpercent\n \n \n \n \n 85\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n componentitemnumber\n \n \n \n \n 494\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_projreq\n \n \n \n \n 5\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_posted\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtypervar\n \n \n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_actiss\n \n \n \n \n 315\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ordered\n \n \n \n
\n \n 16\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 362 OpportunityList \N \n\n Opportunity List\n OpportunityList\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n opportunities\n detail\n \n \n queryParams\n SELECT\n formatDate(<? value("startDate") ?>,'Earliest') AS f_startDate,\n formatDate(<? value("endDate") ?>,'Latest') AS f_endDate,\n <? if exists("username") ?>\n <? value("username") ?> AS usr_username\n <? elseif exists("usr_pattern") ?>\n <? value("usr_pattern") ?> AS usr_username\n <? else ?>\n text('All') AS usr_username\n <? endif ?>\n;\n \n \n 163\n \n \n \n \n \n \n \n 5.66667\n 158.333\n 745.667\n 158.333\n 2\n \n \n \n \n \n \n \n \n \n 10\n 43\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 6\n \n \n 41\n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n ByUser\n usr\n \n \n \n detail\n \n 36\n \n \n 220\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n opsource_name\n \n \n \n \n 395\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_amount\n \n \n \n \n 50\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n crmacct_number\n \n \n \n \n 480\n 0\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_currency\n \n \n \n \n 10\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ophead_name\n \n \n \n \n 305\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ophead_probability_prcnt\n \n \n \n \n 645\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_actualdate\n \n \n \n \n 220\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n opstage_name\n \n \n \n \n 540\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_targetdate\n \n \n \n \n 135\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ophead_owner_username\n \n \n \n \n 305\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n optype_name\n \n \n \n
\n \n 18\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 294 OrderActivityByProject \N \n\n Order Activity By Project\n OrderActivityByProject\n Order Activity Report\n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT prj_name, prj_number\n FROM prj\n WHERE (prj_id=<? value("prj_id") ?>);\n \n \n detail\n -- Group: orderActivityByProject\n-- Name: detail\n-- Notes: \n\nSELECT *, \n formatQty(qty) AS f_qty,\n formatMoney(value) AS f_value,\n 'curr' AS qty_xtnumericrole,\n 'curr' AS value_xtnumericrole\nFROM (\n<? if exists("showSo") ?>\n----- QUOTES -----\nSELECT quhead_id AS id, \n 15 AS type,\n quhead_number::text AS subtype,\n 1 AS section,\n <? value("quotes") ?> AS section_qtdisplayrole,\n quhead_number::text AS name,\n CASE WHEN (quhead_status = 'C') THEN \n <? value("converted") ?>\n WHEN (quhead_status = 'X') THEN\n <? value("canceled") ?>\n WHEN (COALESCE(quhead_expire, current_date + 1) > current_date) THEN\n <? value("open") ?>\n ELSE\n <? value("expired") ?>\n END AS status,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL AS qty,\n NULL::text AS uom,\n NULL AS value,\n 0.0 AS ordertotal,\n 1 AS xtindentrole\n FROM quhead\n JOIN quitem ON (quitem_quhead_id = quhead_id)\n WHERE (quhead_prj_id = <? value("prj_id") ?>)\nGROUP BY quhead_id, quhead_number, quhead_status, quhead_expire, quhead_freight, quhead_misc\n\nUNION ALL\n\nSELECT quitem_id AS id, \n 17 AS type,\n quhead_number::text AS subtype,\n 1 AS section,\n <? value("quotes") ?> AS section_qtdisplayrole,\n quitem_linenumber::text AS name, \n CASE WHEN (quhead_status = 'C') THEN \n <? value("converted") ?>\n WHEN (quhead_status = 'X') THEN\n <? value("canceled") ?>\n WHEN (COALESCE(quhead_expire, current_date + 1) > current_date) THEN\n <? value("open") ?>\n ELSE\n <? value("Expired") ?>\n END AS status,\n item_number AS item,\n item_descrip1 || ' ' || item_descrip2 AS descrip,\n quitem_qtyord,\n uom_name AS uom,\n (quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio) AS value,\n 0.0 AS ordertotal,\n 2 AS xtindentrole\n FROM quhead\n JOIN quitem ON (quitem_quhead_id = quhead_id)\n JOIN uom ON (quitem_qty_uom_id = uom_id)\n JOIN itemsite ON (quitem_itemsite_id = itemsite_id)\n JOIN item ON (itemsite_item_id = item_id)\n WHERE (quhead_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT quhead_id AS id, \n 18 AS type,\n quhead_number::text AS subtype,\n 1 AS section,\n <? value("quotes") ?> AS section_qtdisplayrole,\n <? value("total") ?> AS name,\n NULL AS status,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL AS qty,\n NULL::text AS uom,\n SUM((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio)) AS value,\n SUM((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio)) AS ordertotal,\n 1 AS xtindentrole\n FROM quhead\n JOIN quitem ON (quitem_quhead_id = quhead_id)\n WHERE (quhead_prj_id = <? value("prj_id") ?>)\nGROUP BY quhead_id, quhead_number\n\nUNION ALL\n\n------ SALES ORDERS ------\nSELECT cohead_id AS id, \n 25 AS type,\n cohead_number::text AS subtype,\n 2 AS section,\n <? value("sos") ?> AS section_qtdisplayrole,\n cohead_number::text AS name,\n COALESCE((SELECT \n CASE WHEN (coitem_status = 'O') THEN\n <? value("open") ?>\n WHEN (coitem_status = 'C') THEN\n <? value("closed" ?>\n ELSE\n <? value("canceled") ?>\n END\n FROM \n (SELECT coitem_status,\n CASE \n WHEN (coitem_status = 'O') THEN 1\n WHEN (coitem_status = 'C') then 2\n ELSE 3\n END AS type\n FROM coitem\n WHERE (coitem_cohead_id=cohead_id)\n ORDER BY type\n LIMIT 1) AS sts) ,'O')\n AS status,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL AS qty,\n NULL::text AS uom,\n NULL AS value,\n 0.0 AS ordertotal,\n 1 AS xtindentrole\n FROM cohead\n JOIN coitem ON (coitem_cohead_id = cohead_id)\n WHERE (cohead_prj_id = <? value("prj_id") ?>)\nGROUP BY cohead_id, cohead_number\n\nUNION ALL\n\nSELECT coitem_id AS id, \n 27 AS type,\n cohead_number::text AS subtype,\n 2 AS section,\n <? value("sos") ?> AS section_qtdisplayrole,\n coitem_linenumber::text AS name, \n CASE WHEN (coitem_status = 'O') THEN\n <? value("open") ?>\n WHEN (coitem_status = 'C') THEN\n <? value("closed") ?>\n WHEN (coitem_status = 'X') THEN\n <? value("canceled") ?>\n END AS status,\n item_number AS item,\n item_descrip1 || ' ' || item_descrip2 AS descrip,\n coitem_qtyord,\n uom_name AS uom,\n (coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio) AS value,\n 0.0 AS ordertotal,\n 2 AS xtindentrole\n FROM cohead\n JOIN coitem ON (coitem_cohead_id = cohead_id)\n JOIN uom ON (coitem_qty_uom_id = uom_id)\n JOIN itemsite ON (coitem_itemsite_id = itemsite_id)\n JOIN item ON (itemsite_item_id = item_id)\n WHERE (cohead_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT cohead_id AS id, \n 28 AS type,\n cohead_number::text AS subtype,\n 2 AS section,\n <? value("sos") ?> AS section_qtdisplayrole,\n <? value("total") ?> AS name,\n NULL AS status,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL AS qty,\n NULL::text AS uom,\n SUM((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio)) AS value,\n SUM((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio)) AS ordertotal,\n 1 AS xtindentrole\n FROM cohead\n JOIN coitem ON (coitem_cohead_id = cohead_id)\n WHERE (cohead_prj_id = <? value("prj_id") ?>)\nGROUP BY cohead_id, cohead_number\n\nUNION ALL\n\n------ INVOICES -------\nSELECT invchead_id AS id,\n 35 AS type,\n invchead_invcnumber::text AS subtype,\n 3 AS section,\n <? value("invoices") ?> AS section_qtdisplayrole,\n invchead_invcnumber::text AS name,\n CASE WHEN (invchead_posted) THEN\n <? value("posted") ?>\n ELSE <? value("unposted") ?>\n END AS status,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL AS qty,\n NULL::text AS uom,\n NULL AS value,\n 0.0 AS ordertotal,\n 1 AS xtindentrole\n FROM invchead\n JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n WHERE (invchead_prj_id = <? value("prj_id") ?>)\nGROUP BY invchead_id, invchead_invcnumber, invchead_freight, invchead_misc_amount, invchead_posted\n\nUNION ALL\n\nSELECT invcitem_id AS id, \n 37 AS type,\n invchead_invcnumber::text AS subtype,\n 3 AS section,\n <? value("invoices") ?> AS section_qtdisplayrole,\n invcitem_linenumber::text AS name, \n CASE WHEN (invchead_posted) THEN\n <? value("posted") ?>\n ELSE <? value("unposted") ?>\n END AS status,\n COALESCE(item_number,invcitem_number) AS item,\n COALESCE(item_descrip1 || ' ' || item_descrip2,invcitem_descrip) AS descrip,\n invcitem_billed AS qty,\n uom_name AS uom,\n (invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio) AS value,\n 0.0 AS ordertotal,\n 2 AS xtindentrole\n FROM invchead\n JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n LEFT OUTER JOIN item ON (invcitem_item_id = item_id)\n LEFT OUTER JOIN uom ON (invcitem_qty_uom_id = uom_id)\n WHERE (invchead_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT invchead_id AS id, \n 38 AS type,\n invchead_invcnumber::text AS subtype,\n 3 AS section,\n <? value("invoices") ?> AS section_qtdisplayrole,\n <? value("total") ?> AS name,\n NULL AS status,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL AS qty,\n NULL::text AS uom,\n SUM((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio)) AS value,\n SUM((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio)) AS ordertotal,\n 1 AS xtindentrole\n FROM invchead\n JOIN invcitem ON (invcitem_invchead_id = invchead_id)\n WHERE (invchead_prj_id = <? value("prj_id") ?>)\nGROUP BY invchead_id, invchead_invcnumber\n\n<? endif ?>\n\n\n<? if exists("showWo") ?>\n\n<? if exists("showSo") ?>\n\nUNION ALL\n\n<? endif ?>\n\n------ WORK ORDERS -------\nSELECT wo_id AS id, \n 45 AS type,\n formatWoNumber(wo_id) AS subtype,\n 4 AS section,\n <? value("wos") ?> AS section_qtdisplayrole,\n formatWoNumber(wo_id) AS name,\n CASE WHEN (wo_status = 'O') THEN\n <? value("open") ?>\n WHEN (wo_status = 'E') THEN\n <? value("exploded") ?>\n WHEN (wo_status = 'R') THEN\n <? value("released") ?>\n WHEN (wo_status = 'I') THEN\n <? value("inprocess") ?>\n WHEN (wo_status = 'C') THEN\n <? value("closed") ?>\n END AS status,\n item_number AS item,\n item_descrip1 || ' ' || item_descrip2 AS descrip,\n wo_qtyord AS qty,\n uom_name AS uom,\n wo_postedvalue AS value,\n wo_postedvalue AS ordertotal,\n 1 AS xtindentrole\n FROM wo\n JOIN itemsite ON (itemsite_id=wo_itemsite_id)\n JOIN item ON (itemsite_item_id=item_id)\n JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (wo_prj_id = <? value("prj_id") ?>)\n\n<? endif ?>\n\n\n<? if exists("showPo") ?>\n<? if exists("showSo") ?>\n UNION ALL\n<? elseif exists("showWo") ?>\n UNION ALL\n\n<? endif ?>\n------ PURCHASE REQUESTS ------\nSELECT pr_id AS id, \n 55 AS type,\n pr_number::text || '-' || pr_subnumber::text AS subtype,\n 5 AS section,\n <? value("prs") ?> AS section_qtdisplayrole,\n pr_number::text || '-' || pr_subnumber::text AS name,\n <? value("open") ?> AS status, \n item_number AS item,\n (item_descrip1 || ' ' || item_descrip2) AS descrip,\n pr_qtyreq AS qty,\n uom_name AS uom,\n stdcost(item_id) * pr_qtyreq AS value,\n stdcost(item_id) * pr_qtyreq AS ordertotal,\n 1 AS xtindentrole\n FROM pr\n JOIN itemsite ON (itemsite_id = pr_itemsite_id)\n JOIN item ON (itemsite_item_id = item_id)\n JOIN uom ON (item_inv_uom_id = uom_id)\n WHERE (pr_prj_id=<? value("prj_id") ?>)\n\nUNION ALL\n\n------ PURCHASE ORDERS ------\nSELECT pohead_id AS id,\n 65 AS type,\n pohead_number::text AS subtype,\n 6 AS section,\n <? value("pos") ?> AS section_qtdisplayrole,\n pohead_number::text AS name,\n CASE WHEN (pohead_status = 'U') THEN\n <? value("unreleased") ?>\n WHEN (pohead_status = 'O') THEN\n <? value("open") ?>\n WHEN (pohead_status = 'C') THEN\n <? value("closed") ?>\n END AS status,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL AS qty,\n NULL AS uom,\n NULL AS value,\n 0.0 AS ordertotal,\n 1 AS xtindentrole\n FROM pohead\n JOIN poitem ON (poitem_pohead_id = pohead_id)\n WHERE (poitem_prj_id = <? value("prj_id") ?>)\nGROUP BY pohead_id, pohead_number, pohead_freight, pohead_status\n\nUNION ALL\n\nSELECT poitem_id AS id, \n 67 AS type,\n pohead_number::text AS subtype,\n 6 AS section,\n <? value("pos") ?> AS section_qtdisplayrole,\n poitem_linenumber::text AS name, \n CASE WHEN (poitem_status = 'U') THEN\n <? value("unreleased") ?>\n WHEN (poitem_status = 'O') THEN\n <? value("open") ?>\n WHEN (poitem_status = 'C') THEN\n <? value("closed") ?>\n END AS status,\n COALESCE(item_number,poitem_vend_item_number) AS item,\n COALESCE((item_descrip1 || ' ' || item_descrip2),poitem_vend_item_descrip) AS descrip,\n poitem_qty_ordered,\n poitem_vend_uom AS uom,\n (poitem_qty_ordered * poitem_unitprice) AS value,\n 0.0 AS ordertotal,\n 2 AS xtindentrole\n FROM pohead\n JOIN poitem ON (poitem_pohead_id = pohead_id)\n LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id = item_id)\n WHERE (poitem_prj_id = <? value("prj_id") ?>)\n\nUNION ALL\n\nSELECT pohead_id AS id, \n 68 AS type,\n pohead_number::text AS subtype,\n 6 AS section,\n <? value("pos") ?> AS section_qtdisplayrole,\n <? value("total") ?> AS name,\n NULL AS status,\n NULL::text AS item,\n NULL::text AS descrip,\n NULL AS qty,\n NULL::text AS uom,\n SUM(poitem_qty_ordered * poitem_unitprice) AS value,\n SUM(poitem_qty_ordered * poitem_unitprice) AS ordertotal,\n 1 AS xtindentrole\n FROM pohead\n JOIN poitem ON (poitem_pohead_id = pohead_id)\n WHERE (poitem_prj_id = <? value("prj_id") ?>)\nGROUP BY pohead_id, pohead_number\n\n<? endif ?>\n\n) data\nORDER BY section, subtype, type, id;\n \n \n 75\n \n \n \n 140\n 25\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n prj_number\n \n \n \n \n \n 140\n 45\n 509\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n prj_name\n \n \n \n \n
\n section\n \n type\n section\n \n 53\n \n \n 0\n 45\n 750\n 45\n 2\n \n \n \n \n 77\n 45\n 77\n 45\n 0\n \n \n \n \n \n 90\n 5\n 610\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n section_qtdisplayrole\n \n \n \n \n \n 33\n \n \n 305\n 5\n 750\n 5\n 0\n \n \n \n 610\n 10\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ordertotal\n \n money\n \n \n \n \n \n \n detail\n \n 18\n \n \n 305\n 0\n 135\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item\n \n \n \n \n 100\n 0\n 95\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n name\n \n \n \n \n 209\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n status\n \n \n \n \n 444\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qty\n \n \n \n \n 544\n 0\n 165\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_value\n \n \n \n
\n \n 41\n \n \n \n 700\n 15\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 0\n 5\n 750\n 5\n 2\n \n \n \n 75\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n Order Activity Report 0 2015-10-01 17:15:58.47729 147 POLineItemsByDate \N \n\n P/O Line Items By Date\n POLineItemsByDate\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("warehous_id") ?>\n (SELECT warehous_code FROM whsinfo WHERE warehous_id=<? value("warehous_id") ?>)\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("agentUsername") ?>\n TEXT(<? value("agentUsername" ?>)\n <? else ?>\n TEXT('All Agents')\n <? endif ?>\n AS agentUsername,\n <? if exists("openItems") ?>\n text('Open Items')\n <? elseif exists("closedItems") ?>\n text('Closed Items')\n <? else ?>\n text('All Items')\n <? endif ?>\n as f_whichitems,\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate\n\n \n \n detail\n SELECT CASE WHEN (itemsite_id IS NULL) THEN ( SELECT warehous_code\n FROM whsinfo\n WHERE (pohead_warehous_id=warehous_id) )\n ELSE ( SELECT warehous_code\n FROM whsinfo\n WHERE (itemsite_warehous_id=warehous_id) )\n END AS warehousecode,\n pohead_number as f_ponumber,\n poitem_linenumber as f_linenumber,\n vend_name,\n formatDate(poitem_duedate) as f_duedate,\n COALESCE(item_number, (text('NonInv - ') || poitem_vend_item_number)) AS itemnumber,\n COALESCE(uom_name, poitem_vend_uom) AS itemuom,\n formatQty(poitem_qty_ordered) as f_ordered,\n formatQty(poitem_qty_received) as f_received,\n formatQty(poitem_qty_returned) as f_returned\n FROM pohead, vendinfo,\n poitem LEFT OUTER JOIN\n (itemsite JOIN item\n ON (itemsite_item_id=item_id) JOIN uom ON (item_inv_uom_id=uom_id))\n ON (poitem_itemsite_id=itemsite_id) \n WHERE ((poitem_pohead_id=pohead_id)\n AND (pohead_vend_id=vend_id)\n AND (poitem_duedate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("warehous_id") ?>\n AND ( ( (itemsite_id IS NULL) AND (pohead_warehous_id=<? value("warehous_id") ?>) ) OR\n ( (itemsite_id IS NOT NULL) AND (itemsite_warehous_id=<? value("warehous_id") ?>) ) )\n<? endif ?>\n<? if exists("agentUsername") ?>\n AND (pohead_agent_username=<? value("agentUsername") ?>)\n<? endif ?>\n<? if exists("openItems") ?>\n AND (poitem_status='O')\n<? elseif exists("closedItems") ?>\n AND (poitem_status='C')\n<? endif ?>\n)\nORDER BY poitem_duedate;\n \n \n 237\n \n \n 135\n 75\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n agentUsername\n \n \n \n \n \n \n 5\n 229\n 745\n 229\n 2\n \n \n \n \n \n \n \n \n \n \n \n 550\n 95\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n 475\n 130\n 165\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_whichitems\n \n \n \n \n \n \n 135\n 95\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n 550\n 75\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n 7\n \n \n 37\n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 37\n \n 5\n 30\n 745\n 30\n 0\n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_returned\n \n \n \n \n 525\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemuom\n \n \n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ordered\n \n \n \n \n 370\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemnumber\n \n \n \n \n 45\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ponumber\n \n \n \n \n 580\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_received\n \n \n \n \n 5\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehousecode\n \n \n \n \n 285\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_duedate\n \n \n \n \n 130\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_name\n \n \n \n \n 5\n 15\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_linenumber\n \n \n \n
\n \n 17\n \n \n \n 103\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 148 POLineItemsByItem \N \n\n P/O Line Items By Item\n POLineItemsByItem\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number, item_descrip1, item_descrip2, uom_name,\n <? if exists("warehous_id") ?>\n ( SELECT warehous_code FROM whsinfo WHERE warehous_id=<? value("warehous_id") ?>)\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("agentUsername") ?>\n TEXT(<? value("agentUsername" ?>)\n <? else ?>\n TEXT('All Agents')\n <? endif ?>\n AS agentUsername,\n <? if exists("openItems") ?>\n text('Open Items')\n <? elseif exists("closedItems") ?>\n text('Closed Items')\n <? else ?>\n text('All Items')\n <? endif ?>\n AS f_whichitems\n FROM item JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (item_id=<? value("item_id") ?>);\n\n \n \n detail\n SELECT warehous_code, pohead_number as f_ponumber, vend_name,\n formatDate(poitem_duedate) as f_duedate,\n poitem_vend_uom as uom_name, \n formatQty(poitem_qty_ordered) as f_ordered,\n formatQty(poitem_qty_received) as f_received,\n formatQty(poitem_qty_returned) as f_returned \n FROM pohead, poitem, vendinfo, itemsite, whsinfo\n WHERE ((poitem_pohead_id=pohead_id)\n AND (pohead_vend_id=vend_id)\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("agentUsername") ?>\n AND (pohead_agent_username=<? value("agentUsername") ?>)\n<? endif ?>\n<? if exists("openItems") ?>\n AND (poitem_status='O')\n<? elseif exists("closedItems") ?>\n AND (poitem_status='C')\n<? endif ?>\n AND (poitem_itemsite_id=itemsite_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (itemsite_item_id=<? value("item_id") ?>)\n) \nORDER BY poitem_duedate;\n \n \n 221\n \n \n \n \n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n 325\n 75\n 80\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n uom_name\n \n \n \n \n \n 475\n 130\n 165\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_whichitems\n \n \n \n \n 110\n 112\n 250\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n 535\n 95\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n 110\n 75\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n 110\n 95\n 250\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n 535\n 75\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n agentUsername\n \n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_received\n \n \n \n \n 440\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n \n 5\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_returned\n \n \n \n \n 355\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_duedate\n \n \n \n \n 493\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ordered\n \n \n \n \n 135\n 0\n 215\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_name\n \n \n \n \n 45\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ponumber\n \n \n \n
\n \n 16\n \n \n 103\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 146 POLineItemsByVendor \N \n\n P/O Line Items By Vendor\n POLineItemsByVendor\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT\n<? if exists("vend_id") ?>\n (SELECT ('Vendor = ' || vend_name) FROM vendinfo WHERE vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n (SELECT ('Vendor Type = ' || vendtype_code) FROM vendtype WHERE vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n ('Vendor Type pattern = ' || <? value("vendtype_pattern") ?>)\n<? else ?>\n 'All Vendors'\n<? endif ?>\n AS selection,\n <? if exists("warehous_id") ?>\n ( SELECT warehous_code FROM whsinfo WHERE warehous_id=<? value("warehous_id") ?>)\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("agentUsername") ?>\n TEXT(<? value("agentUsername" ?>)\n <? else ?>\n TEXT('All Agents')\n <? endif ?>\n AS agentUsername,\n <? if exists("openItems") ?>\n text('Open Items')\n <? elseif exists("closedItems") ?>\n text('Closed Items')\n <? else ?>\n text('All Items')\n <? endif ?>\n AS f_whichitems\n;\n \n \n detail\n poItems\n detail\n \n \n 224\n \n \n \n \n 535\n 75\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n agentUsername\n \n \n \n \n \n 475\n 130\n 165\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_whichitems\n \n \n \n \n \n \n \n \n \n \n 535\n 95\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n 150\n 75\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n selection\n \n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n 9\n \n \n 24\n \n \n \n \n \n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n
\n detail\n \n \n detail\n \n 19\n \n \n 440\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemuom\n \n \n \n \n 225\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemnumber\n \n \n \n \n 45\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n pohead_number\n \n \n \n \n 135\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n poitem_duedate\n \n \n \n \n 5\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 493\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n poitem_qty_ordered\n \n qty\n \n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n poitem_qty_received\n \n qty\n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n poitem_qty_returned\n \n qty\n \n \n
\n \n 19\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 103\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 348 POsByDate \N \n\n P/Os By Date\n POsByDate\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("warehous_id") ?>\n (SELECT warehous_code FROM whsinfo WHERE warehous_id=<? value("warehous_id") ?>)\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("agentUsername") ?>\n TEXT(<? value("agentUsername" ?>)\n <? else ?>\n TEXT('All Agents')\n <? endif ?>\n AS agentUsername,\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate\n\n \n \n detail\n purchaseOrders\n detail\n \n \n 221\n \n \n 550\n 95\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n 135\n 75\n 275\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n agentUsername\n \n \n \n \n \n 135\n 95\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n 550\n 75\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 18\n \n \n 5\n 2\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehousecode\n \n \n \n \n 325\n 2\n 230\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_name\n \n \n \n \n 650\n 2\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_duedate\n \n \n \n \n 80\n 2\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n pohead_number\n \n \n \n \n 200\n 2\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_status\n \n \n \n \n 565\n 2\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_orderdate\n \n \n \n
\n \n 18\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 103\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 349 POsByVendor \N \n\n P/Os By Vendor\n POsByVendor\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("warehous_id") ?>\n (SELECT warehous_code FROM whsinfo WHERE warehous_id=<? value("warehous_id") ?>)\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n<? if exists("vend_id") ?>\n (SELECT ('Vendor = ' || vend_name) FROM vendinfo WHERE vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n (SELECT ('Vendor Type = ' || vendtype_code) FROM vendtype WHERE vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n ('Vendor Type pattern = ' || <? value("vendtype_pattern") ?>)\n<? else ?>\n 'All Vendors'\n<? endif ?>\n AS selection,\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("byReceiptDate") ?>\n TEXT('By Receipt Date')\n <? elseif exists("byDueDate") ?>\n TEXT('By Due Date')\n <? else ?>\n TEXT('By Order Date')\n <? endif ?>\n AS f_byDate,\n <? if exists("descrip_pattern") ?>\n TEXT('Where Item Description contains ' || <? value("descrip_pattern") ?>)\n <? else ?>\n TEXT('')\n <? endif ?>\n AS f_descrip\n\n \n \n detail\n purchaseOrders\n detail\n \n \n 221\n \n \n 135\n 135\n 540\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_descrip\n \n \n \n \n 550\n 115\n 180\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_byDate\n \n \n \n \n \n \n 135\n 95\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n 135\n 75\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n selection\n \n \n \n \n \n 550\n 95\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n 550\n 75\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n 6\n \n \n 21\n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 18\n \n \n 650\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_orderdate\n \n \n \n \n 5\n 0\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehousecode\n \n \n \n \n 200\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_status\n \n \n \n \n 80\n 0\n 110\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n pohead_number\n \n \n \n \n 330\n 0\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_number\n \n \n \n
\n \n 18\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 103\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 421 PackageMasterList \N \n\n Package Master List\n PackageMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT *, formatboolyn(packageIsEnabled(pkghead_name)) AS enabled\nFROM pkghead\nORDER BY pkghead_name, pkghead_version DESC;\n \n \n 76\n \n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n 6\n \n \n 21\n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 265\n 0\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n pkghead_descrip\n \n \n \n \n 10\n 0\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n pkghead_name\n \n \n \n \n 565\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n pkghead_version\n \n \n \n \n 665\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n enabled\n \n \n \n
\n \n 16\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 345 PackingList-Shipment \N \n\n Packing List (Shipment)\n PackingList-Shipment\n Non-Hybrid version - driven only by shiphead_id parameter - Packing List showing the contents of a particular shipment - Shows RA# if SO is a replacement order for and RA\n \n \n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 25\n 25\n 25\n 25\n \n head\n SELECT shiphead_number, 'S/O #:' AS ordertype,\n cohead_number AS ordernumber,\n formatsobarcode(cohead_id) AS order_barcode,\n COALESCE(shiphead_shipvia, cohead_shipvia) AS shipvia,\n cohead_shiptophone AS shiptophone,\n cohead_custponumber,\n formatDate(cohead_orderdate) AS orderdate,\n cohead_shipcomments AS shipcomments, \n cohead_billtoname AS billtoname,\n formataddr(cohead_billtoaddress1, cohead_billtoaddress2,\n cohead_billtoaddress3,\n (cohead_billtocity || ' ' || cohead_billtostate ||\n ' ' || cohead_billtozipcode), cohead_billtocountry) AS billing_address,\n cohead_shiptoname AS shiptoname,\n formataddr(cohead_shiptoaddress1, cohead_shiptoaddress2,\n cohead_shiptoaddress3,\n (cohead_shiptocity || ' ' || cohead_shiptostate ||\n ' ' || cohead_shiptozipcode), cohead_shiptocountry) AS shipping_address, \n\n cust_number,\n trim(cntct_first_name || ' ' || cntct_last_name) AS cust_contact,\n cntct_phone AS cust_phone,\n terms_descrip\n FROM shiphead\n JOIN cohead ON (cohead_id=shiphead_order_id)\n JOIN custinfo ON (cohead_cust_id=cust_id)\n JOIN terms ON (cohead_terms_id=terms_id)\n LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n WHERE (shiphead_id=<? value("shiphead_id") ?>)\n\n<? if exists("MultiWhs") ?>\nUNION\nSELECT shiphead_number, 'T/O #:' AS ordertype,\n tohead_number AS ordernumber,\n formattobarcode(tohead_id) AS order_barcode,\n shiphead_shipvia AS shipvia,\n tohead_destphone AS shiptophone,\n TEXT(' ') AS cohead_custponumber,\n formatDate(tohead_orderdate) AS orderdate,\n tohead_shipcomments AS shipcomments,\n tohead_srcname AS billtoname,\n formataddr(tohead_srcaddress1, tohead_srcaddress2,\n tohead_srcaddress3,\n (tohead_srccity || ' ' || tohead_srcstate ||\n ' ' || tohead_srcpostalcode), tohead_srccountry) AS billing_address,\n tohead_destname AS shiptoname,\n formataddr(tohead_destaddress1, tohead_destaddress2,\n tohead_destaddress3,\n (tohead_destcity || ' ' || tohead_deststate ||\n ' ' || tohead_destpostalcode), tohead_destcountry) AS shipping_address,\n 'Transfer Order' AS cust_number,\n tohead_destcntct_name AS cust_contact,\n tohead_destphone AS cust_phone,\n '' AS terms_descrip\n FROM shiphead, tohead\n WHERE ((tohead_id=shiphead_order_id)\n AND (shiphead_order_type='TO')\n AND (shiphead_id=<? value("shiphead_id") ?>)\n)\n<? endif ?>;\n \n \n scheddate\n SELECT formatDate(MIN(coitem_scheddate)) AS scheddate\n FROM coitem, shipitem\n WHERE ((coitem_status <> 'X')\n AND (coitem_id=shipitem_orderitem_id)\n AND (shipitem_shiphead_id=<? value("shiphead_id") ?>));\n \n \n detail\n SELECT 1 AS groupby,\n coitem_linenumber AS sortline, coitem_subnumber AS sortsubline,\n formatsolinenumber(coitem_id) AS linenumber,\n coitem_memo AS memo,\n CASE WHEN (coitem_custpn != '') THEN coitem_custpn\n ELSE item_number\n END AS item_number,\n formatitemsitebarcode(itemsite_id) AS item_barcode,\n formatsoitembarcode(coitem_id) AS orderitem_barcode,\n-- In 2.3 replaced the next line:\n-- uom_name,\n-- with:\n (select uom_name from uom where uom_id = coitem_qty_uom_id) AS uom_name,\n itemsellinguom(item_id) AS shipuom,\n CASE WHEN (coitem_custpn != '' AND itemalias_usedescrip=TRUE) THEN itemalias_descrip1\n ELSE item_descrip1\n END AS item_descrip1,\n CASE WHEN (coitem_custpn != '' AND itemalias_usedescrip=TRUE) THEN itemalias_descrip2\n ELSE item_descrip2\n END AS item_descrip2,\n\n formatQty(coitem_qtyord) AS ordered,\n (SELECT formatQty(SUM(shipitem_qty)) FROM shipitem WHERE ((shipitem_shiphead_id=<? value("shiphead_id") ?>) AND (shipitem_orderitem_id=coitem_id))) AS shipped,\n\n CASE WHEN (coitem_status='O' AND (SELECT cust_creditstatus\n FROM custinfo,cohead\n WHERE coitem_cohead_id=cohead_id\n AND (cust_id=cohead_cust_id))='H') THEN 'H'\n WHEN (coitem_status='O' AND ((SELECT SUM(invcitem_billed)\n FROM cohead, invchead, invcitem\n WHERE ((invchead_ordernumber=cohead_number)\n AND (invcitem_invchead_id=invchead_id)\n AND (invcitem_item_id=item_id)\n AND (invcitem_warehous_id=itemsite_warehous_id)\n AND (invcitem_linenumber=coitem_linenumber)\n AND (cohead_id=coitem_cohead_id))) >= coitem_qtyord)) THEN 'I'\n WHEN (coitem_status='O' AND ((SELECT SUM(invcitem_billed)\n FROM cohead, invchead, invcitem\n WHERE ((invchead_ordernumber=cohead_number)\n AND (invcitem_invchead_id=invchead_id)\n AND (invcitem_item_id=item_id)\n AND (invcitem_warehous_id=itemsite_warehous_id)\n AND (invcitem_linenumber=coitem_linenumber)\n AND (cohead_id=coitem_cohead_id))) > 0)) THEN 'P'\n WHEN (coitem_status='O' AND (qtyAvailable(itemsite_id) - qtyAllocated(itemsite_id, CURRENT_DATE)\n + qtyOrdered(itemsite_id, CURRENT_DATE))\n >= (coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned)) THEN 'R'\n ELSE coitem_status\n END AS f_status,\n CASE\n WHEN (getPacklistItemLotSerial(shipitem_shiphead_id, coitem_id) = '') THEN\n ''\n ELSE\n 'Serial #/Lot Information:'\n END AS lotserial_title,\n getPacklistItemLotSerial(shipitem_shiphead_id, coitem_id) AS lotserial,\n CASE\n WHEN (getPacklistCharName(shipitem_shiphead_id, coitem_id) = '') THEN\n ''\n ELSE\n 'Characteristics:'\n END AS char_title,\n getPacklistCharName(shipitem_shiphead_id, coitem_id) AS char_name,\n getPacklistCharValue(shipitem_shiphead_id, coitem_id) AS char_value\n FROM shipitem\n JOIN coitem ON (coitem_id=shipitem_orderitem_id)\n JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN uom ON (uom_id=item_inv_uom_id)\n LEFT OUTER JOIN itemalias ON (itemalias_item_id=item_id AND itemalias_number=coitem_custpn) \n WHERE ( (coitem_status <> 'X')\n AND (shipitem_shiphead_id=<? value("shiphead_id") ?>)\n)\n<? if exists("MultiWhs") ?>\nUNION\nSELECT 2 AS groupby,\n toitem_linenumber AS sortline, 0 AS sortsubline,\n CAST(toitem_linenumber AS text) AS linenumber,\n toitem_notes AS memo,\n item_number,\n formatitemsitebarcode(itemsite_id) AS item_barcode,\n formattoitembarcode(toitem_id) AS orderitem_barcode,\n uom_name,\n itemsellinguom(item_id) AS shipuom,\n item_descrip1,\n item_descrip2,\n\n formatQty(toitem_qty_ordered) AS ordered,\n\n (SELECT formatQty(SUM(shipitem_qty))\n FROM shipitem\n WHERE ((shipitem_shiphead_id=<? value("shiphead_id") ?>)\n AND (shipitem_orderitem_id=toitem_id))\n ) AS shipped,\n\n toitem_status AS f_status,\n CASE\n WHEN (getPacklistItemLotSerial(shiphead_id, toitem_id) = '') THEN\n ''\n ELSE\n 'Serial #/Lot Information:'\n END AS lotserial_title,\n getPacklistItemLotSerial(shiphead_id, toitem_id) AS lotserial,\n '' AS char_title,\n '' AS char_name,\n '' AS char_value\n FROM itemsite, item, toitem, tohead, shipitem, shiphead, uom\n WHERE ((toitem_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (item_id=itemsite_item_id)\n AND (toitem_tohead_id=tohead_id)\n AND (toitem_status <> 'X')\n AND (tohead_src_warehous_id=itemsite_warehous_id)\n AND (toitem_id=shipitem_orderitem_id)\n AND (shipitem_shiphead_id=shiphead_id)\n AND (shiphead_order_type='TO')\n AND (shiphead_id=<? value("shiphead_id") ?>)\n)\n<? endif ?>\nORDER BY sortline, sortsubline;\n \n \n logo\n SELECT image_data \nFROM image \nWHERE ((image_name='logo'));\n \n \n so_ra_relation\n --added in 2.3 to show RA link to S/O if the SO\n--was created as the result of a replacement RA\n<? if exists("EnableReturnAuth") ?>\nselect \n'RA #' AS ratext,\nrahead_number\nfrom\nrahead, cohead, shiphead\nwhere \nrahead_new_cohead_id = cohead_id\nand cohead_id = shiphead_order_id\nand shiphead_id = <? value("shiphead_id") ?>;\n<? else ?>\nselect \n'' AS ratext,\n'' AS rahead_number\n<? endif ?>\n \n \n 463\n \n \n 375\n 0\n 425\n 100\n \n stretch\n \n logo\n image_data\n \n \n \n \n 170\n 112\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n ordernumber\n \n \n \n \n \n \n \n \n 170\n 175\n 170\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cust_number\n \n \n \n \n 375\n 202\n 307\n 25\n \n 3of9\n 20\n \n 0.01\n \n head\n cohead_custponumber\n \n \n \n \n \n 480\n 285\n 300\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n shiptoname\n \n \n \n 0\n 425\n 797\n 425\n 0\n \n \n \n \n \n \n \n 375\n 175\n 177\n 25\n \n 3of9\n 10\n \n 0.01\n \n head\n cust_number\n \n \n \n \n 170\n 85\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n shiphead_number\n \n \n \n \n 10\n 145\n 150\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n so_ra_relation\n ratext\n \n \n \n \n 10\n 112\n 150\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n ordertype\n \n \n \n \n \n 480\n 305\n 300\n 15\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n head\n shipping_address\n \n \n \n \n \n 480\n 252\n 300\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n shipvia\n \n \n \n \n 455\n 400\n 320\n 20\n \n \n Arial\n 12\n normal\n \n \n \n \n head\n terms_descrip\n \n \n \n \n 170\n 231\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n orderdate\n \n \n \n \n 170\n 202\n 170\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cohead_custponumber\n \n \n \n 0\n 455\n 797\n 455\n 0\n \n \n \n \n \n \n 375\n 112\n 231\n 25\n \n 128\n 10\n \n 0.01\n \n head\n order_barcode\n \n \n \n \n 90\n 285\n 300\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n billtoname\n \n \n \n \n 170\n 252\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n scheddate\n scheddate\n \n \n \n \n \n \n 170\n 145\n 170\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n so_ra_relation\n rahead_number\n \n \n \n \n \n 112\n 400\n 250\n 20\n \n \n Arial\n 12\n normal\n \n \n \n \n head\n cust_contact\n \n \n \n \n 90\n 305\n 300\n 15\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n head\n billing_address\n \n \n \n \n
\n detail\n \n characteristic\n linenumber\n \n 35\n \n \n 130\n 5\n 195\n 17\n \n 14\n \n Arial\n 10\n normal\n \n \n \n \n detail\n char_name\n \n \n \n \n 10\n 5\n 103\n 17\n \n 14\n \n Arial\n 10\n normal\n \n \n \n \n detail\n char_title\n \n \n \n \n 370\n 5\n 195\n 17\n \n 14\n \n Arial\n 10\n normal\n \n \n \n \n detail\n char_value\n \n \n \n \n \n lotserial\n linenumber\n \n 29\n \n \n 10\n 5\n 185\n 17\n \n 14\n \n Arial\n 10\n normal\n \n \n \n \n detail\n lotserial_title\n \n \n \n \n 228\n 5\n 550\n 17\n \n 14\n \n Arial\n 10\n normal\n \n \n \n \n detail\n lotserial\n \n \n \n \n \n line\n linenumber\n \n 82\n \n \n \n 430\n 0\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n shipped\n \n \n \n \n 70\n 55\n 665\n 17\n \n 14\n \n Arial\n 10\n normal\n \n \n \n \n detail\n memo\n \n \n \n \n 80\n 0\n 200\n 20\n \n \n Arial\n 11\n bold\n \n \n \n \n detail\n item_number\n \n \n \n 545\n 15\n 595\n 15\n 1\n \n \n \n 290\n 0\n 40\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n uom_name\n \n \n \n \n 340\n 0\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n ordered\n \n \n \n \n 80\n 35\n 300\n 15\n \n \n Arial\n 11\n normal\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 670\n 0\n 50\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n f_status\n \n \n \n \n 415\n 20\n 380\n 30\n \n 128\n 15\n \n 0.01\n \n detail\n item_barcode\n \n \n \n \n 80\n 20\n 300\n 15\n \n \n Arial\n 11\n normal\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 5\n 0\n 42\n 20\n \n \n Arial\n 11\n bold\n \n \n \n \n detail\n linenumber\n \n \n \n \n \n \n \n detail\n \n 9\n \n
\n
\n packlist\n \n \n head\n \n 41\n \n \n 5\n 10\n 625\n 17\n \n 14\n \n Arial\n 10\n normal\n \n \n \n \n head\n shipcomments\n \n \n \n 5\n 5\n 842\n 5\n 0\n \n \n
\n \n 57\n \n \n 455\n 7\n 80\n 17\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n ordernumber\n \n \n \n \n \n \n 735\n 5\n 45\n 17\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 5\n 95\n 17\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 365\n 7\n 80\n 17\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n ordertype\n \n \n \n \n 94\n \n \n 540\n 70\n 790\n 70\n 0\n \n \n \n 160\n 70\n 407\n 70\n 0\n \n \n
\n Non-Hybrid version - driven only by shiphead_id parameter - Packing List showing the contents of a particular shipment - Shows RA# if SO is a replacement order for and RA 0 2015-10-01 17:15:58.47729 80 PackingList \N \n\n Packing List\n PackingList\n Hybrid Packing List - use the shiphead_id if it is passed but use the order id and type if they're passed but not shiphead_id - Shows Lot/Serial\n \n \n \n 0.05\n 0.05\n \n Letter\n \n 25\n 25\n 25\n 25\n \n head\n SELECT COALESCE(shiphead_number::TEXT, 'Not Issued To Shipping') AS shiphead_number,\n 'S/O #:' AS ordertype,\n cohead_number AS ordernumber,\n formatsobarcode(cohead_id) AS order_barcode,\n COALESCE(shiphead_shipvia, cohead_shipvia) AS shipvia,\n cohead_shiptophone AS shiptophone,\n cohead_custponumber,\n formatDate(cohead_orderdate) AS orderdate,\n cohead_shipcomments AS shipcomments,\n cohead_billtoname AS billtoname,\n formataddr(cohead_billtoaddress1,\n cohead_billtoaddress2,\n cohead_billtoaddress3,\n (cohead_billtocity || ' ' || cohead_billtostate || ' ' || cohead_billtozipcode),\n cohead_billtocountry) AS billing_address,\n cohead_shiptoname AS shiptoname,\n formataddr(cohead_shiptoaddress1,\n cohead_shiptoaddress2,\n cohead_shiptoaddress3,\n (cohead_shiptocity || ' ' || cohead_shiptostate || ' ' || cohead_shiptozipcode),\n cohead_shiptocountry) AS shipping_address, \n cust_number,\n trim(cntct_first_name || ' ' || cntct_last_name) AS cust_contact,\n cntct_phone AS cust_phone,\n terms_descrip\n FROM cohead\n JOIN custinfo ON (cohead_cust_id=cust_id)\n JOIN terms ON (cohead_terms_id=terms_id)\n LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n<? if exists("shiphead_id") ?>\n JOIN\n<? else ?>\n LEFT OUTER JOIN\n<? endif ?>\n shiphead ON (shiphead_order_type='SO') AND (shiphead_order_id=cohead_id)\nWHERE TRUE\n<? if exists('shiphead_id') ?>\n AND (shiphead_id=<? value("shiphead_id") ?>)\n<? endif ?>\n<? if exists("head_id") ?>\n AND (cohead_id=<? value("head_id") ?>)\n AND (<? value("head_type") ?>='SO')\n<? endif ?>\n\n\n<? if exists("MultiWhs") ?>\nUNION\nSELECT COALESCE(shiphead_number::TEXT, 'Not Issued To Shipping') AS shiphead_number,\n 'T/O #:' AS ordertype,\n tohead_number AS ordernumber,\n formattobarcode(tohead_id) AS order_barcode,\n COALESCE(shiphead_shipvia, tohead_shipvia) AS shipvia,\n tohead_destphone AS shiptophone,\n TEXT(' ') AS cohead_custponumber,\n formatDate(tohead_orderdate) AS orderdate,\n tohead_shipcomments AS shipcomments,\n tohead_srcname AS billtoname,\n formataddr(tohead_srcaddress1,\n tohead_srcaddress2,\n tohead_srcaddress3,\n (tohead_srccity || ' ' || tohead_srcstate || ' ' || tohead_srcpostalcode),\n tohead_srccountry) AS billing_address,\n tohead_destname AS shiptoname,\n formataddr(tohead_destaddress1,\n tohead_destaddress2,\n tohead_destaddress3,\n (tohead_destcity || ' ' || tohead_deststate || ' ' || tohead_destpostalcode),\n tohead_destcountry) AS shipping_address,\n 'Transfer Order' AS cust_number,\n tohead_destcntct_name AS cust_contact,\n tohead_destphone AS cust_phone,\n '' AS terms_descrip\n FROM tohead \n<? if exists("shiphead_id") ?>\n\tJOIN\n<? else ?>\n\tLEFT OUTER JOIN\n<? endif ?>\n shiphead ON (shiphead_order_type='TO') AND (shiphead_order_id=tohead_id)\nWHERE TRUE\n<? if exists('shiphead_id') ?>\n AND (shiphead_id=<? value("shiphead_id")?>)\n<? endif ?>\n<? if exists("head_id") ?>\n AND (tohead_id=<? value("head_id") ?>)\n AND (<? value("head_type") ?>='TO')\n<? endif ?>\n<? endif ?>;\n \n \n scheddate\n SELECT formatDate(MIN(orderitem_scheddate)) AS scheddate\n FROM orderitem\n <? if exists("shiphead_id") ?>\n JOIN shiphead ON ((orderitem_orderhead_type=shiphead_order_type)\n\t\t AND (orderitem_orderhead_id=shiphead_order_id)\n\t\t AND (shiphead_id=<? value("shiphead_id")?>))\n JOIN shipitem ON ((shiphead_id=shipitem_shiphead_id)\n\t\t AND (shipitem_orderitem_id=orderitem_id))\n <? endif ?>\n WHERE ((orderitem_status <> 'X')\n<? if exists("head_id") ?>\n AND (orderitem_orderhead_type=<? value("head_type") ?>)\n AND (orderitem_orderhead_id=<? value("head_id") ?>)\n<? endif ?>\n );\n \n \n detail\n SELECT 1 AS groupby,\n coitem_linenumber AS linenumber,\n coitem_memo AS memo,\n CASE WHEN (coitem_custpn != '') THEN coitem_custpn\n ELSE item_number\n END AS item_number,\n formatitemsitebarcode(itemsite_id) AS item_barcode,\n formatsoitembarcode(coitem_id) AS orderitem_barcode,\n coitemuom.uom_name AS uom_name,\n itemsellinguom(item_id) AS shipuom,\n CASE WHEN (coitem_custpn != '' AND itemalias_usedescrip=TRUE) THEN itemalias_descrip1\n ELSE item_descrip1\n END AS item_descrip1,\n CASE WHEN (coitem_custpn != '' AND itemalias_usedescrip=TRUE) THEN itemalias_descrip2\n ELSE item_descrip2\n END AS item_descrip2,\n formatQty(coitem_qtyord) AS ordered,\n formatQty(qtyAtShipping('SO', coitem_id)) AS atShipping,\n getSoitemStatus(coitem_id) AS f_status\n FROM coitem\n JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN uom invuom ON (invuom.uom_id = item_inv_uom_id)\n JOIN uom coitemuom ON (coitemuom.uom_id = coitem_qty_uom_id) \n LEFT OUTER JOIN itemalias ON (itemalias_item_id=item_id AND itemalias_number=coitem_custpn) \n WHERE ( (coitem_status <> 'X')\n<? if exists("shiphead_id") ?>\n AND (coitem_cohead_id IN (SELECT shiphead_order_id FROM shiphead\n\t\t\t WHERE ((shiphead_id=<? value("shiphead_id") ?>)\n\t\t\t AND (shiphead_order_type='SO'))))\n<? endif ?>\n<? if exists("head_id") ?>\n AND (<? value("head_type") ?>='SO')\n AND (coitem_cohead_id=<? value("head_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n)\n<? if exists("MultiWhs") ?>\nUNION\nSELECT 2 AS groupby,\n toitem_linenumber AS linenumber,\n toitem_notes AS memo,\n item_number,\n formatitemsitebarcode(itemsite_id) AS item_barcode,\n formattoitembarcode(toitem_id) AS orderitem_barcode,\n uom_name,\n itemsellinguom(item_id) AS shipuom,\n item_descrip1,\n item_descrip2,\n formatQty(toitem_qty_ordered) AS ordered,\n formatQty(qtyAtShipping('TO', toitem_id)) AS atShipping,\n toitem_status AS f_status\n FROM itemsite, item, toitem, tohead, uom\n WHERE ((toitem_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (item_id=itemsite_item_id)\n AND (toitem_tohead_id=tohead_id)\n AND (toitem_status <> 'X')\n AND (tohead_src_warehous_id=itemsite_warehous_id)\n<? if exists("shiphead_id") ?>\n AND (toitem_tohead_id IN (SELECT shiphead_order_id FROM shiphead\n\t\t\t WHERE ((shiphead_id=<? value("shiphead_id") ?>)\n\t\t\t AND (shiphead_order_type='TO'))))\n<? endif ?>\n<? if exists("head_id") ?>\n AND (<? value("head_type") ?>='TO')\n AND (toitem_tohead_id=<? value("head_id") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n)\n<? endif ?>\nORDER BY linenumber;\n \n \n logo\n SELECT image_data \nFROM image \nWHERE ((image_name='logo'));\n \n \n lotdetail\n SELECT * FROM \n(\n SELECT\n shiphead_number,\n (cohead_number || '-' || coitem_linenumber) AS ordernumber,\n item_number,\n formatlotserialnumber(invdetail_ls_id) AS invdetail_lotserial,\n SUM(invdetail_qty) * -1 AS lotqty,\n SUM(invhist_invqty) as totalshipmentqty,\n invhist_transtype,\n formatdate(MAX(invhist_transdate)) AS invhistdate,\n formatdate(MAX(shipitem_transdate)) AS shiptransdate\n FROM shiphead\n JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)\n JOIN invhist ON (invhist_id=shipitem_invhist_id)\n JOIN invdetail ON (invdetail_invhist_id=invhist_id)\n JOIN cohead ON (cohead_id=shiphead_order_id)\n JOIN coitem ON (coitem_id=shipitem_orderitem_id)\n JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n WHERE ( (shiphead_id = <? value("shiphead_id") ?> )\n AND ('SO'=shiphead_order_type) )\n GROUP BY shiphead_number,cohead_number,item_number,invdetail_ls_id,\n coitem_linenumber,invhist_transtype\n<? if exists("MultiWhs") ?>\nUNION\n SELECT\n shiphead_number,\n (tohead_number || '-' || toitem_linenumber) AS ordernumber,\n item_number,\n formatlotserialnumber(invdetail_ls_id) AS invdetail_lotserial,\n SUM(invdetail_qty) * -1 AS lotqty,\n SUM(invhist_invqty) as totalshipmentqty,\n invhist_transtype,\n formatdate(MAX(invhist_transdate)) AS invhistdate,\n formatdate(MAX(shipitem_transdate)) AS shiptransdate\n FROM shiphead\n JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)\n JOIN invhist ON (invhist_id=shipitem_invhist_id)\n JOIN invdetail ON (invdetail_invhist_id=invhist_id)\n JOIN tohead ON (tohead_id=shiphead_order_id)\n JOIN toitem ON (toitem_id=shipitem_orderitem_id)\n JOIN item ON (item_id=toitem_item_id)\n WHERE ( (shiphead_id = <? value("shiphead_id") ?> )\n AND ('TO'=shiphead_order_type) )\n GROUP BY shiphead_number,tohead_number,item_number,invdetail_ls_id,\n toitem_linenumber,invhist_transtype\n<? endif ?>\n) data\nORDER BY ordernumber;\n \n \n 451\n \n \n 375\n 0\n 425\n 100\n \n stretch\n \n logo\n image_data\n \n \n \n \n 375\n 180\n 307\n 25\n \n 3of9\n 20\n \n 0.01\n \n head\n cohead_custponumber\n \n \n \n \n 170\n 150\n 170\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cust_number\n \n \n \n \n 375\n 120\n 231\n 25\n \n 128\n 10\n \n 0.01\n \n head\n order_barcode\n \n \n \n \n \n 120\n 360\n 250\n 20\n \n \n Arial\n 12\n normal\n \n \n \n \n head\n cust_contact\n \n \n \n \n \n 170\n 180\n 170\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cohead_custponumber\n \n \n \n \n 480\n 260\n 300\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n shiptoname\n \n \n \n \n 375\n 150\n 177\n 25\n \n 3of9\n 10\n \n 0.01\n \n head\n cust_number\n \n \n \n \n 480\n 280\n 300\n 15\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n head\n shipping_address\n \n \n \n \n \n \n 10\n 120\n 150\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n ordertype\n \n \n \n \n 170\n 207\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n orderdate\n \n \n \n \n \n 170\n 227\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n scheddate\n scheddate\n \n \n \n \n 0\n 390\n 797\n 390\n 0\n \n \n \n \n \n 0\n 430\n 797\n 430\n 0\n \n \n \n \n 480\n 227\n 300\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n shipvia\n \n \n \n \n 90\n 280\n 300\n 15\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n head\n billing_address\n \n \n \n \n \n 90\n 260\n 300\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n billtoname\n \n \n \n \n \n 457\n 360\n 320\n 20\n \n \n Arial\n 12\n normal\n \n \n \n \n head\n terms_descrip\n \n \n \n \n 170\n 90\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n shiphead_number\n \n \n \n \n \n \n 170\n 120\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n ordernumber\n \n \n \n \n \n \n
\n detail\n \n detail\n groupby\n \n 43\n \n \n 50\n 5\n 625\n 17\n \n 14\n \n Arial\n 10\n normal\n \n \n \n \n head\n shipcomments\n \n \n \n \n \n lineitem\n linenumber\n \n 21\n \n 0\n 0\n 837\n 0\n 0\n \n \n \n \n \n detail\n \n 81\n \n \n 227\n 0\n 40\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n uom_name\n \n \n \n \n 610\n 0\n 50\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n f_status\n \n \n \n \n \n \n 280\n 0\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n ordered\n \n \n \n \n 20\n 0\n 200\n 20\n \n \n Arial\n 11\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 90\n 50\n 560\n 17\n \n 14\n \n Arial\n 10\n normal\n \n \n \n \n detail\n memo\n \n \n \n \n 507\n 30\n 280\n 30\n \n 128\n 15\n \n 0.01\n \n detail\n item_barcode\n \n \n \n \n 20\n 35\n 300\n 15\n \n \n Arial\n 11\n normal\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 20\n 20\n 300\n 15\n \n \n Arial\n 11\n normal\n \n \n \n \n detail\n item_descrip1\n \n \n \n 470\n 20\n 520\n 20\n 1\n \n \n \n 370\n 0\n 80\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n atShipping\n \n \n \n
\n
\n lotdetail\n \n lotdetail\n ordernumber\n \n 48\n \n \n \n 0\n 40\n 797\n 40\n 0\n \n \n \n \n \n 13\n \n 0\n 5\n 797\n 5\n 0\n \n \n \n \n \n lotdetail\n \n 23\n \n \n 232\n 5\n 195\n 15\n \n \n Arial\n 11\n normal\n \n \n \n \n lotdetail\n invdetail_lotserial\n \n \n \n \n 30\n 5\n 195\n 15\n \n \n Arial\n 11\n normal\n \n \n \n \n lotdetail\n item_number\n \n \n \n \n 457\n 5\n 60\n 15\n \n \n Arial\n 11\n normal\n \n \n \n \n lotdetail\n lotqty\n \n \n \n
\n \n 57\n \n \n \n 90\n 8\n 95\n 17\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 735\n 8\n 45\n 17\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 455\n 8\n 80\n 17\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n ordernumber\n \n \n \n \n 365\n 8\n 80\n 17\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n ordertype\n \n \n \n \n 57\n \n \n \n 540\n 40\n 790\n 40\n 0\n \n \n 160\n 40\n 407\n 40\n 0\n \n \n
\n Hybrid Packing List - use the shiphead_id if it is passed but use the order id and type if they're passed but not shiphead_id - Shows Lot/Serial 0 2015-10-01 17:15:58.47729 173 PackingListBatchEditList \N \n\n Packing List Batch Edit List\n PackingListBatchEditList\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n packingListBatch\n detail\n \n \n 75\n \n \n \n \n \n \n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n 5\n \n \n 31\n \n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 15\n \n \n 115\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shipment_number\n \n \n \n \n 675\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n pack_printed\n \n \n \n \n 220\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n number\n \n \n \n \n 10\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n order_number\n \n \n \n \n 600\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_holdtype\n \n \n \n \n 320\n 0\n 160\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n name\n \n \n \n \n 490\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shipvia\n \n \n \n
\n \n 15\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 53 PendingBOMChanges \N \n\n Pending Bill of Material Changes\n PendingBOMChanges\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n uom_name,\n item_descrip1,\n item_descrip2,\n CASE WHEN (<? value("cutOffDate") ?> >= date('2099-12-31')) THEN text('Latest')\n ELSE formatDate(<? value("cutOffDate") ?>)\n END AS cutoffdate\n FROM item JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (item_id=<? value("item_id") ?>);\n \n \n \n detail\n SELECT formatDate(bomitem_effective) as actiondate,\n 'Effective' AS action,\n bomitem_seqnumber, item_number, uom_name,\n item_descrip1, item_descrip2, uom_name,\n formatQty(itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyfxd)) AS qtyfxd,\n formatQtyPer(itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyper)) AS qtyper,\n formatScrap(bomitem_scrap) AS scrap,\n formatQtyPer(itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd + bomitem_qtyper) * (1 + bomitem_scrap))) AS qtyreq,\n formatDate(bomitem_effective, 'Always') AS effective,\n formatDate(bomitem_expires, 'Never') AS expires,\n formatBoolYN(bomitem_createwo) AS createchild,\n CASE WHEN (bomitem_issuemethod='S') THEN 'Push'\n WHEN (bomitem_issuemethod='L') THEN 'Pull'\n WHEN (bomitem_issuemethod='M') THEN 'Mixed'\n ELSE 'Special'\n END AS issuemethod\n FROM bomitem(<? value("item_id") ?>,<? value("revision_id") ?>), item, uom\n WHERE ((bomitem_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (bomitem_effective BETWEEN CURRENT_DATE AND <? value("cutOffDate") ?>)\n)\nUNION\nSELECT formatDate(bomitem_expires) as actiondate,\n 'Expires' AS action,\n bomitem_seqnumber, item_number, uom_name,\n item_descrip1, item_descrip2, uom_name,\n formatQty(itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyfxd)) AS qtyfxd,\n formatQtyPer(itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyper)) AS qtyper,\n formatScrap(bomitem_scrap) AS scrap,\n formatQtyPer(itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, bomitem_qtyper + (1 * bomitem_scrap))) AS qtyreq,\n formatDate(bomitem_effective, 'Always') AS effective,\n formatDate(bomitem_expires, 'Never') AS expires,\n formatBoolYN(bomitem_createwo) AS createchild,\n CASE WHEN (bomitem_issuemethod='S') THEN 'Push'\n WHEN (bomitem_issuemethod='L') THEN 'Pull'\n WHEN (bomitem_issuemethod='M') THEN 'Mixed'\n ELSE 'Special'\n END AS issuemethod\nFROM bomitem(<? value("item_id") ?>,<? value("revision_id") ?>), item, uom\nWHERE ((bomitem_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (bomitem_expires BETWEEN CURRENT_DATE AND <? value("cutOffDate") ?>)\n)\nORDER BY action, actiondate, bomitem_seqnumber;\n \n \n \n bomhead\n SELECT bomhead_docnum, bomhead_revision, formatDate(bomhead_revisiondate) AS f_revisiondate\nFROM bomhead\nWHERE ((bomhead_item_id=<? value("item_id") ?>)\n AND (bomhead_rev_id=<? value("revision_id") ?>));\n \n \n 234\n \n \n \n \n 120\n 140\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n 5\n 229\n 745\n 229\n 2\n \n \n \n \n 475\n 140\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n f_revisiondate\n \n \n \n \n \n 430\n 55\n 110\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cutoffdate\n \n \n \n \n \n 120\n 120\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n \n \n \n \n 475\n 160\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n bomhead_revision\n \n \n \n \n \n 120\n 160\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n \n \n \n \n 475\n 120\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n bomhead_docnum\n \n \n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 53\n \n \n 100\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n actiondate\n \n \n \n \n 5\n 0\n 75\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n action\n \n \n \n \n 600\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n scrap\n \n \n \n \n 600\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n createchild\n \n \n \n \n 254\n 30\n 229\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 675\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n issuemethod\n \n \n \n \n 254\n 0\n 229\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 254\n 15\n 229\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 675\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyreq\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 560\n 0\n 38\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n \n 484\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyper\n \n \n \n \n 204\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n bomitem_seqnumber\n \n \n \n \n 485\n 14\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyfxd\n \n \n \n
\n \n 18\n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 91 PendingWOMaterialAvailability \N \n\n Pending W/O Material Availability\n PendingWOMaterialAvailability\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number, item_descrip1, item_descrip2,\n <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse\n FROM item\nWHERE (item_id=<? value("item_id") ?>);\n \n \n detail\n pendingAvailability\n detail\n \n \n 234\n \n \n 140\n 140\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n \n 140\n 160\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n 5\n 229\n 745\n 229\n 2\n \n \n \n \n \n \n \n \n \n 140\n 100\n 198\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n \n 140\n 120\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 41\n \n \n 290\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n \n 405\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n pendalloc\n \n qty\n \n \n 6\n 32\n 745\n 32\n 0\n \n \n \n 110\n -1\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 575\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qoh\n \n qty\n \n \n \n 110\n 15\n 615\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip\n \n \n \n \n 490\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n totalalloc\n \n qty\n \n \n \n 660\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n totalavail\n \n qty\n \n \n \n 60\n -1\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n bomitem_seqnumber\n \n \n \n \n 15\n -1\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n bomdata_bomwork_level\n \n \n \n
\n \n 18\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 81 PickList \N \n\n Pick List\n PickList\n \n Letter\n \n 50\n 28\n 0\n 0\n \n Head\n SELECT formatWoNumber(wo_id) AS wonumber, wo_prodnotes,\n item_number, uom_name, item_descrip1, item_descrip2,\n warehous_code, formatQty(wo_qtyord) AS qtyord,\n formatQty(wo_qtyrcv) AS qtyrcv,\n formatDate(wo_startdate) AS startdate,\n formatDate(wo_duedate) AS duedate\n FROM wo, itemsite, item, whsinfo, uom\n WHERE ((wo_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (wo_id=<? value("wo_id") ?>))\n \n \n \n Detail\n SELECT item_number,\n uom_name,\n item_descrip1,\n item_descrip2,\n formatQty(womatl_qtyreq) AS qtyreq,\n formatQty(womatl_qtyiss) AS qtyiss,\n formatQty(noNeg(womatl_qtyreq - womatl_qtyiss)) AS qtybalance,\n itemsite_location,\n CASE WHEN (womatl_issuemethod='S') THEN text('Push')\n WHEN (womatl_issuemethod='L') THEN text('Pull')\n WHEN (womatl_issuemethod='M') THEN text('Mixed')\n ELSE text(womatl_issuemethod)\n END AS f_issuemethod\n FROM womatl, itemsite, item, uom\n WHERE ((item_picklist)\n AND (womatl_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (womatl_uom_id=uom_id)\n AND (womatl_wo_id=<? value("wo_id") ?>) );\n \n \n \n 246\n \n \n \n 196\n 140\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n Head\n qtyord\n \n \n \n \n 653\n 65\n 150\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n Head\n wonumber\n \n \n \n \n 196\n 102\n 300\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n Head\n item_descrip2\n \n \n \n \n \n 653\n 102\n 130\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n Head\n startdate\n \n \n \n \n 653\n 84\n 130\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 653\n 121\n 130\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n Head\n duedate\n \n \n \n \n \n 196\n 65\n 200\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n Head\n item_number\n \n \n \n \n \n \n \n \n \n \n \n 196\n 158\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n Head\n qtyrcv\n \n \n \n \n 196\n 84\n 300\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n Head\n item_descrip1\n \n \n \n \n 195\n 120\n 120\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n Head\n warehous_code\n \n \n \n \n \n 10\n 240\n 822\n 240\n 2\n \n \n \n \n \n \n \n \n 6\n \n \n 47\n \n \n \n 10\n 40\n 822\n 40\n 2\n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n Detail\n \n 61\n \n \n 215\n 0\n 130\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n itemsite_location\n \n \n \n \n 45\n 0\n 160\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n item_number\n \n \n \n 680\n 30\n 780\n 30\n 1\n \n \n \n 350\n 0\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n qtyreq\n \n \n \n \n 457\n 0\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n qtyiss\n \n \n \n \n 350\n 20\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n uom_name\n \n \n \n \n 46\n 37\n 300\n 14\n \n \n Arial\n 8\n normal\n \n \n \n \n Detail\n item_descrip2\n \n \n \n \n 459\n 20\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n f_issuemethod\n \n \n \n 10\n 55\n 822\n 55\n 0\n \n \n \n 569\n 0\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n qtybalance\n \n \n \n \n 45\n 20\n 300\n 14\n \n \n Arial\n 8\n normal\n \n \n \n \n Detail\n item_descrip1\n \n \n \n
\n \n 57\n \n \n \n 46\n 28\n 746\n 22\n \n 0\n \n Arial\n 12\n 48\n \n \n \n \n Head\n wo_prodnotes\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 368 PickListWOShowLocations \N \n\n Pick List WO Show Locations\n PickListWOShowLocations\n This WO Pick List Shows All Locations and Lots for Each Requirement\n \n \n \n Letter\n \n 50\n 28\n 33\n 33\n \n Head\n SELECT formatWoNumber(wo_id) AS wonumber, wo_prodnotes,\n item_number, uom_name, item_descrip1, item_descrip2,\n warehous_code, formatQty(wo_qtyord) AS qtyord,\n formatQty(wo_qtyrcv) AS qtyrcv,\n formatDate(wo_startdate) AS startdate,\n formatDate(wo_duedate) AS duedate\n FROM wo, itemsite, item, whsinfo, uom\n WHERE ((wo_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (wo_id=%1))\n \n \n \n Detail\n SELECT\n warehous_code, \n wo_number,\n womatl_id,\n item_number,\n item_descrip1,\n item_descrip2, \n uom_name,\n-- itemuomtouomratio(item_id,item_inv_uom_id, womatl_uom_id) * womatl_qtyreq AS required_qty,\n womatl_qtyreq AS required_qty,\n-- formatqty(itemuomtouomratio(item_id,item_inv_uom_id, womatl_uom_id) * womatl_qtyreq) AS required_fmt,\n formatqty(womatl_qtyreq) AS required_fmt,\n-- itemuomtouomratio(item_id,item_inv_uom_id, womatl_uom_id) * womatl_qtyiss AS issued_qty,\n womatl_qtyiss AS issued_qty,\n formatqty(womatl_qtyiss) AS issued_fmt,\n-- (itemuomtouomratio(item_id,item_inv_uom_id, womatl_uom_id) * womatl_qtyreq) - \n (itemuomtouomratio(item_id,item_inv_uom_id, womatl_uom_id) * womatl_qtyiss) AS pick_qty,\n womatl_qtyreq - womatl_qtyiss AS pick_qty, \n formatqty(womatl_qtyreq - womatl_qtyiss) AS pick_fmt,\n CASE WHEN (womatl_issuemethod='S') THEN text('Push')\n WHEN (womatl_issuemethod='L') THEN text('Pull')\n WHEN (womatl_issuemethod='M') THEN text('Mixed')\n ELSE text(womatl_issuemethod)\n END AS f_issuemethod,\n location_aisle || '-' || location_rack || '-' || location_bin || '-' || location_name AS location_name,\n formatlotserialnumber(itemloc_ls_id),\n-- itemloc_lotserial,\n itemsite_location_comments AS location_comment,\n itemloc_qty AS location_qty_qty,\n itemuomtouomratio(item_id,item_inv_uom_id, womatl_uom_id) * itemloc_qty AS loc_issue_uom_qty,\n formatqty(itemuomtouomratio(item_id,item_inv_uom_id, womatl_uom_id) * itemloc_qty) AS loc_issue_uom_fmt,\n CASE WHEN itemloc_expiration = '1970-01-01' THEN text ('N/A')\n WHEN itemloc_expiration = '2100-01-01' THEN text ('N/A')\n ELSE CAST(formatdate(itemloc_expiration) AS text)\n END AS expiration \n\nFROM\n\n item, uom, whsinfo, womatl, wo, itemsite\n LEFT OUTER JOIN itemloc ON (itemloc_itemsite_id = itemsite_id)\n LEFT OUTER JOIN location ON (itemloc_location_id = location_id)\n\n\nWHERE\n itemsite_item_id = item_id\n and \n itemsite_warehous_id = warehous_id\n and\n womatl_uom_id = uom_id\n and\n itemsite_id = womatl_itemsite_id\n and\n womatl_wo_id = wo_id\n and\n wo_id = <? value("wo_id") ?>\nORDER BY wo_number, womatl_id, item_number, itemloc_expiration, location_name;\n \n \n 188\n \n \n 196\n 5\n 150\n 40\n \n \n Arial\n 14\n normal\n \n \n \n \n Head\n wonumber\n \n \n \n \n 196\n 140\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n Head\n qtyord\n \n \n \n \n \n \n 195\n 120\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n Head\n warehous_code\n \n \n \n \n \n 196\n 102\n 300\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n Head\n item_descrip2\n \n \n \n \n 649\n 100\n 130\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n Head\n startdate\n \n \n \n \n 196\n 65\n 200\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n Head\n item_number\n \n \n \n \n 649\n 120\n 130\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n Head\n duedate\n \n \n \n \n 649\n 80\n 130\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 196\n 84\n 300\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n Head\n item_descrip1\n \n \n \n \n \n 196\n 158\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n Head\n qtyrcv\n \n \n \n \n \n \n \n \n \n \n 6\n \n \n 6\n \n
\n detail_group\n \n detail_group\n womatl_id\n \n 133\n \n \n 208\n 40\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n required_fmt\n \n \n \n \n 330\n 55\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n f_issuemethod\n \n \n \n \n \n \n 10\n 35\n 822\n 35\n 2\n \n \n \n \n 575\n 40\n 45\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n uom_name\n \n \n \n \n \n 469\n 75\n 300\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n location_comment\n \n \n \n 80\n 100\n 817\n 100\n 1\n \n \n \n \n \n 469\n 40\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n Detail\n pick_fmt\n \n \n \n \n 37\n 60\n 195\n 14\n \n \n Arial\n 8\n normal\n \n \n \n \n Detail\n item_descrip1\n \n \n \n \n 37\n 40\n 160\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n item_number\n \n \n \n \n \n \n \n 208\n 55\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n uom_name\n \n \n \n \n 37\n 75\n 300\n 14\n \n \n Arial\n 8\n normal\n \n \n \n \n Detail\n item_descrip2\n \n \n \n \n \n 330\n 40\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n issued_fmt\n \n \n \n 680\n 57\n 780\n 57\n 1\n \n \n \n \n \n \n 36\n \n 75\n 25\n 825\n 25\n 1\n \n \n 75\n 5\n 822\n 5\n 1\n \n \n \n 465\n 5\n 50\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n uom_name\n \n \n \n \n 355\n 5\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n loc_issue_uom_qty\n \n qty\n \n \n \n \n \n \n Detail\n \n 21\n \n \n 75\n 0\n 115\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n location_name\n \n \n \n \n 555\n 0\n 75\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n expiration\n \n \n \n \n 465\n 0\n 50\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n uom_name\n \n \n \n 690\n 17\n 790\n 17\n 1\n \n \n \n 215\n 0\n 115\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n formatlotserialnumber\n \n \n \n \n 355\n 0\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n Detail\n loc_issue_uom_fmt\n \n \n \n
\n \n 57\n \n \n 110\n 30\n 480\n 22\n \n 0\n \n Arial\n 12\n 48\n \n \n \n \n Head\n wo_prodnotes\n \n \n \n \n
\n This WO Pick List Shows All Locations and Lots for Each Requirement 0 2015-10-01 17:15:58.47729 346 PickingListSOClosedLines \N \n\n Picking List - SO\n PickingListSOClosedLines\n Shows Closed Lines -- With Barcodes formatitemsitebarcode(itemsite_id) -- SO # barcoded formatsobarcode(cohead_id) -- With Logo, place logo graphic in images DB with name "logo"\n\n \n \n \n 0.05\n 0.05\n \n Letter\n \n 25\n 25\n 25\n 25\n \n head\n SELECT cust_number,\n formatsobarcode(cohead_id) AS order_barcode,\n formataddr(cohead_billtoaddress1,\n cohead_billtoaddress2,\n cohead_billtoaddress3,\n (cohead_billtocity || ' ' || cohead_billtostate || ' ' || cohead_billtozipcode),\n cohead_billtocountry) AS billing_address, \n formataddr(cohead_shiptoaddress1,\n cohead_shiptoaddress2,\n cohead_shiptoaddress3,\n (cohead_shiptocity || ' ' || cohead_shiptostate || ' ' || cohead_shiptozipcode),\n cohead_shiptocountry) AS shipping_address, \n trim(cntct_first_name || ' ' || cntct_last_name) AS cust_contact,\n cohead_billtoname,\n cohead_billtoaddress1,\n cohead_billtoaddress2,\n cohead_billtoaddress3,\n (cohead_billtocity || ' ' || cohead_billtostate || ' ' || cohead_billtozipcode) AS billtocitystatezip,\n cntct_phone AS cust_phone,\n cohead_shiptoname,\n cohead_shiptoaddress1,\n cohead_shiptoaddress2,\n cohead_shiptoaddress3,\n (cohead_shiptocity || ' ' || cohead_shiptostate || ' ' || cohead_shiptozipcode) AS shiptocitystatezip,\n cohead_number,\n cohead_shipvia,\n cohead_shiptophone,\n cohead_custponumber,\n formatDate(cohead_orderdate) AS orderdate,\n formatDate(getSoSchedDate(cohead_id)) AS scheddate,\n cohead_shipcomments, \n terms_descrip\n FROM cohead JOIN custinfo ON (cohead_cust_id=cust_id)\n JOIN terms ON (cohead_terms_id=terms_id)\n LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n WHERE (cohead_id=<? value("sohead_id") ?>);\n \n \n \n detail\n SELECT 1 AS groupby,\n coitem_linenumber AS sortline,\n coitem_subnumber AS sortsubline,\n formatsolinenumber(coitem_id) AS linenumber,\n coitem_memo,\n item_number,\n formatitemsitebarcode(itemsite_id) AS item_barcode,\n coitemuom.uom_name AS uom_name,\n itemsellinguom(item_id) AS shipuom,\n item_descrip1,\n item_descrip2,\n formatQty(coitem_qtyord) AS ordered,\n CASE WHEN (coitem_qtyreserved > 0.0)\n THEN formatQty(coitem_qtyreserved)\n ELSE NULL\n END AS reserved,\n CASE WHEN ((coitem_qtyshipped - coitem_qtyreturned) > 0.0)\n THEN formatQty(coitem_qtyshipped - coitem_qtyreturned)\n ELSE NULL\n END AS shipped,\n CASE WHEN (fetchMetricBool('RequireSOReservations'))\n THEN formatQty(coitem_qtyreserved)\n ELSE formatQty(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping('SO', coitem_id)))\n END AS balance,\n CASE WHEN (qtyAtShipping('SO', coitem_id) > 0.0)\n THEN formatQty(qtyAtShipping('SO', coitem_id))\n ELSE NULL\n END AS atShipping,\n getSoitemStatus(coitem_id) AS f_status\n FROM coitem JOIN itemsite ON (itemsite_id = coitem_itemsite_id)\n JOIN item ON (item_id = itemsite_item_id)\n JOIN whsinfo ON (warehous_id = itemsite_warehous_id)\n JOIN uom invuom ON (invuom.uom_id = item_inv_uom_id)\n JOIN uom coitemuom ON (coitemuom.uom_id = coitem_qty_uom_id) \n WHERE ( (coitem_cohead_id=<? value("sohead_id") ?>)\n AND (coitem_status <> 'X')\n AND (coitem_status <> 'C')\n AND (item_type != 'K')\n AND ( (fetchMetricBool('RequireSOReservations') AND (coitem_qtyreserved > 0.0)) OR\n (NOT fetchMetricBool('RequireSOReservations')) )\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n)\nORDER BY sortline, sortsubline;\n \n \n logo\n SELECT image_data \nFROM image \nWHERE ((image_name='logo'));\n \n \n site\n <? if exists("warehous_id") ?>\n SELECT warehous_code AS f_site\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>);\n<? else ?>\n SELECT text('') AS f_site;\n<? endif ?>\n\n \n \n 477\n \n \n 375\n 0\n 425\n 85\n \n stretch\n \n logo\n image_data\n \n \n \n \n 465\n 280\n 305\n 20\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n head\n shipping_address\n \n \n \n \n 120\n 400\n 252\n 25\n \n \n Arial\n 12\n normal\n \n \n \n \n head\n cust_contact\n \n \n \n 25\n 425\n 822\n 425\n 0\n \n \n \n 170\n 155\n 170\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cohead_custponumber\n \n \n \n \n \n 75\n 280\n 295\n 20\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n head\n billing_address\n \n \n \n \n \n \n 375\n 95\n 232\n 25\n \n 128\n 10\n \n 0.01\n \n head\n order_barcode\n \n \n \n \n \n \n 465\n 260\n 305\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cohead_shiptoname\n \n \n \n \n \n \n 432\n 215\n 331\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cohead_shipvia\n \n \n \n \n 170\n 125\n 170\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cust_number\n \n \n \n \n \n 75\n 260\n 305\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cohead_billtoname\n \n \n \n \n 170\n 95\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cohead_number\n \n \n \n \n 175\n 195\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n orderdate\n \n \n \n \n \n \n \n 25\n 465\n 822\n 465\n 0\n \n \n \n 175\n 215\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n scheddate\n \n \n \n \n 375\n 160\n 307\n 25\n \n 3of9\n 20\n \n 0.01\n \n head\n cohead_custponumber\n \n \n \n \n \n 467\n 400\n 320\n 20\n \n \n Arial\n 12\n normal\n \n \n \n \n head\n terms_descrip\n \n \n \n \n \n \n \n 375\n 130\n 177\n 25\n \n 3of9\n 10\n \n 0.01\n \n head\n cust_number\n \n \n \n \n \n \n \n \n 170\n 65\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n site\n f_site\n \n \n \n
\n detail\n \n detail\n groupby\n \n 73\n \n \n 50\n 5\n 625\n 17\n \n 14\n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_shipcomments\n \n \n \n \n \n lineitem\n linenumber\n \n 28\n \n 5\n 5\n 842\n 5\n 0\n \n \n \n \n \n detail\n \n 156\n \n \n 415\n 80\n 500\n 80\n 0\n \n \n 305\n 110\n 395\n 110\n 0\n \n \n 80\n 80\n 170\n 80\n 0\n \n \n 745\n 15\n 795\n 15\n 1\n \n \n \n 25\n 0\n 200\n 20\n \n \n Arial\n 11\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 100\n 120\n 700\n 17\n \n 14\n \n Arial\n 10\n normal\n \n \n \n \n detail\n coitem_memo\n \n \n \n 415\n 110\n 500\n 110\n 0\n \n \n 305\n 80\n 395\n 80\n 0\n \n \n \n 630\n 103\n 85\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n f_status\n \n \n \n \n 365\n 30\n 467\n 35\n \n 128\n 15\n \n 0.01\n \n detail\n item_barcode\n \n \n \n \n \n 190\n 80\n 280\n 80\n 0\n \n \n \n 530\n 0\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n balance\n \n \n \n 80\n 110\n 170\n 110\n 0\n \n \n 632\n 80\n 720\n 80\n 0\n \n \n \n \n 25\n 40\n 295\n 20\n \n \n Arial\n 11\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 320\n 0\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n reserved\n \n \n \n \n 227\n 0\n 85\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n ordered\n \n \n \n \n 425\n 0\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n shipped\n \n \n \n 190\n 110\n 280\n 110\n 0\n \n \n \n 25\n 20\n 295\n 20\n \n \n Arial\n 11\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 635\n 0\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n atshipping\n \n \n \n \n \n 630\n 88\n 85\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n uom_name\n \n \n \n \n
\n \n 57\n \n \n \n \n 735\n 5\n 45\n 17\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 5\n 95\n 17\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 455\n 5\n 80\n 17\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n cohead_number\n \n \n \n \n 113\n \n \n 186\n 90\n 360\n 90\n 0\n \n \n \n 185\n 25\n 362\n 25\n 0\n \n \n
\n 0 2015-10-01 17:15:58.47729 367 PickingListSOLocsNoClosedLines \N \n\n Picking List SO With Locations\n PickingListSOLocsNoClosedLines\n This report definition shows location / lot / serial information on an SO Pick List. If the item is not Location Controlled it shows the contents of its Location Comment in the corresponding Item Site record.\n \n \n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 25\n 25\n 25\n 25\n \n head\n SELECT cust_number,\n formatsobarcode(cohead_id) AS order_barcode,\n\n formataddr(cohead_billtoaddress1,\n cohead_billtoaddress2,\n cohead_billtoaddress3,\n (cohead_billtocity || ' ' || cohead_billtostate || ' ' || cohead_billtozipcode),\n cohead_billtocountry) AS billing_address, \n formataddr(cohead_shiptoaddress1,\n cohead_shiptoaddress2,\n cohead_shiptoaddress3,\n (cohead_shiptocity || ' ' || cohead_shiptostate || ' ' || cohead_shiptozipcode),\n cohead_shiptocountry) AS shipping_address, \n trim(cntct_first_name || ' ' || cntct_last_name) AS cust_contact,\n cohead_billtoname,\n cohead_billtoaddress1,\n cohead_billtoaddress2,\n cohead_billtoaddress3,\n (cohead_billtocity || ' ' || cohead_billtostate || ' ' || cohead_billtozipcode) AS billtocitystatezip,\n cntct_phone AS cust_phone,\n cohead_shiptoname,\n cohead_shiptoaddress1,\n cohead_shiptoaddress2,\n cohead_shiptoaddress3,\n (cohead_shiptocity || ' ' || cohead_shiptostate || ' ' || cohead_shiptozipcode) AS shiptocitystatezip,\n cohead_number,\n cohead_shipvia,\n cohead_shiptophone,\n cohead_custponumber,\n formatDate(cohead_orderdate) AS orderdate,\n formatDate(getSoSchedDate(cohead_id)) AS scheddate,\n cohead_shipcomments, \n terms_descrip\n FROM cohead JOIN custinfo ON (cohead_cust_id=cust_id)\n LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n LEFT OUTER JOIN terms ON (cohead_terms_id=terms_id)\n WHERE (cohead_id=<? value("sohead_id") ?>)\n;\n \n \n detail\n SELECT \n coitem_linenumber AS sortline,\n coitem_subnumber AS sortsubline,\n formatsolinenumber(coitem_id) AS linenumber,\n coitem_memo,\n item_number,\n formatitemsitebarcode(itemsite_id) AS item_barcode,\n CASE WHEN (formatLocationName(location_id) = 'N/A') THEN itemsite_location_comments || ' ' || '(comment)'\n ELSE formatLocationName(location_id)\n END AS location_name,\n itemsite_location_comments AS location_comment,\n formatlotserialnumber(itemloc_ls_id),\n formatDate(itemloc_expiration, 'N/A') AS expiration,\n itemloc_qty AS location_qty_qty,\n CASE WHEN fetchMetricBool('EnableSOReservationsByLocation')\n THEN formatQty(qtyReservedLocation(itemloc_id, 'SO', coitem_id)) \n ELSE formatQty(0) \n END AS location_reserved_qty,\n itemuomtouomratio(item_id,item_inv_uom_id, coitem_qty_uom_id) * itemloc_qty AS loc_issue_uom_qty,\n formatqty(itemuomtouomratio(item_id,item_inv_uom_id, coitem_qty_uom_id) * itemloc_qty) AS loc_issue_uom_fmt,\n coitemuom.uom_name AS uom_name,\n item_descrip1,\n item_descrip2,\n formatQty(coitem_qtyord) AS ordered,\n CASE WHEN (coitem_qtyreserved > 0.0)\n THEN formatQty(coitem_qtyreserved)\n ELSE NULL\n END AS reserved,\n CASE WHEN ((coitem_qtyshipped - coitem_qtyreturned) > 0.0)\n THEN formatQty(coitem_qtyshipped - coitem_qtyreturned)\n ELSE NULL\n END AS shipped,\n CASE WHEN (fetchMetricBool('RequireSOReservations'))\n THEN formatQty(coitem_qtyreserved)\n ELSE formatQty(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping('SO', coitem_id)))\n END AS balance,\n CASE WHEN (qtyAtShipping('SO', coitem_id) > 0.0)\n THEN formatQty(qtyAtShipping('SO', coitem_id))\n ELSE NULL\n END AS atShipping,\n formatQty(roundUp((coitem_qtyord * coitem_qty_invuomratio))) AS shipordered,\n formatQty(roundUp(((coitem_qtyshipped - coitem_qtyreturned) * coitem_qty_invuomratio))) AS shipshipped,\n formatQty(roundUp((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio))) AS shipbalance,\n getSoitemStatus(coitem_id) AS f_status\n FROM coitem JOIN cohead ON (cohead_id = coitem_cohead_id)\n JOIN custinfo ON (cust_id = cohead_cust_id)\n JOIN itemsite ON (itemsite_id = coitem_itemsite_id)\n JOIN item ON (item_id = itemsite_item_id)\n JOIN whsinfo ON (warehous_id = itemsite_warehous_id)\n JOIN uom invuom ON (invuom.uom_id = item_inv_uom_id)\n JOIN uom coitemuom ON (coitemuom.uom_id = coitem_qty_uom_id) \n LEFT OUTER JOIN itemloc ON (itemloc_itemsite_id = itemsite_id)\n LEFT OUTER JOIN location ON (itemloc_location_id = location_id)\n WHERE ( (coitem_cohead_id=<? value("sohead_id") ?>)\n AND (coitem_status <> 'X')\n AND (coitem_status <> 'C')\n AND (item_type != 'K')\n AND ( (fetchMetricBool('RequireSOReservations') AND (coitem_qtyreserved > 0.0)) OR\n (NOT fetchMetricBool('RequireSOReservations')) )\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n)\nORDER BY sortline, sortsubline, expiration, location_name;\n \n \n logo\n SELECT image_data \nFROM image \nWHERE ((image_name='logo'));\n \n \n site\n <? if exists("warehous_id") ?>\n SELECT warehous_code AS f_site\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>);\n<? else ?>\n SELECT text('') AS f_site;\n<? endif ?>\n\n \n \n 467\n \n \n 375\n 5\n 425\n 85\n \n stretch\n \n logo\n image_data\n \n \n \n \n 170\n 125\n 170\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cust_number\n \n \n \n \n \n \n \n 75\n 280\n 295\n 20\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n head\n billing_address\n \n \n \n \n 5\n 425\n 797\n 425\n 0\n \n \n \n 100\n 400\n 253\n 25\n \n \n Arial\n 12\n normal\n \n \n \n \n head\n cust_contact\n \n \n \n \n 170\n 200\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n scheddate\n \n \n \n \n 475\n 400\n 320\n 20\n \n \n Arial\n 12\n normal\n \n \n \n \n head\n terms_descrip\n \n \n \n \n \n 170\n 220\n 390\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cohead_shipvia\n \n \n \n \n 170\n 155\n 170\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cohead_custponumber\n \n \n \n \n \n 170\n 95\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cohead_number\n \n \n \n \n \n \n \n 375\n 130\n 177\n 25\n \n 3of9\n 10\n \n 0.01\n \n head\n cust_number\n \n \n \n \n 375\n 95\n 233\n 25\n \n 128\n 10\n \n 0.01\n \n head\n order_barcode\n \n \n \n \n 170\n 180\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n orderdate\n \n \n \n \n \n 465\n 260\n 305\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cohead_shiptoname\n \n \n \n \n \n \n \n \n \n \n \n 75\n 260\n 305\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cohead_billtoname\n \n \n \n \n \n \n 465\n 280\n 305\n 20\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n head\n shipping_address\n \n \n \n \n \n 375\n 160\n 307\n 25\n \n 3of9\n 20\n \n 0.01\n \n head\n cohead_custponumber\n \n \n \n \n \n 170\n 70\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n site\n f_site\n \n \n \n
\n detail\n \n lineitems\n linenumber\n \n 132\n \n 5\n 5\n 797\n 5\n 2\n \n \n \n \n \n 30\n 25\n 285\n 20\n \n \n Arial\n 11\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 20\n 10\n 200\n 20\n \n \n Arial\n 11\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n \n 408\n 35\n 380\n 45\n \n 128\n 15\n \n 0.01\n \n detail\n item_barcode\n \n \n \n \n \n \n \n 225\n 10\n 85\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n ordered\n \n \n \n \n \n 620\n 10\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n atshipping\n \n \n \n 135\n 75\n 175\n 75\n 0\n \n \n 75\n 75\n 112\n 75\n 0\n \n \n \n \n 75\n 95\n 112\n 95\n 0\n \n \n 252\n 75\n 295\n 75\n 0\n \n \n \n 515\n 10\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n balance\n \n \n \n 252\n 95\n 295\n 95\n 0\n \n \n 615\n 30\n 535\n 30\n 0\n \n \n 135\n 95\n 175\n 95\n 0\n \n \n \n 415\n 10\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n shipped\n \n \n \n 745\n 25\n 795\n 25\n 1\n \n \n 195\n 95\n 235\n 95\n 0\n \n \n \n 365\n 63\n 25\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n f_status\n \n \n \n \n 30\n 40\n 285\n 20\n \n \n Arial\n 11\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n 195\n 75\n 235\n 75\n 0\n \n \n 70\n 120\n 793\n 120\n 0\n \n \n \n 305\n 10\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n reserved\n \n \n \n \n 365\n 43\n 25\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n uom_name\n \n \n \n \n \n 29\n \n \n 490\n 5\n 50\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n uom_name\n \n \n \n \n 70\n 5\n 793\n 5\n 0\n \n \n \n 415\n 5\n 70\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n loc_issue_uom_qty\n \n qty\n \n \n \n \n 110\n 5\n 135\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n item_number\n \n \n \n \n \n \n \n detail\n \n 29\n \n \n 250\n 0\n 145\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n formatlotserialnumber\n \n \n \n \n 490\n 0\n 70\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n location_reserved_qty\n \n \n \n \n 415\n 0\n 70\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n loc_issue_uom_fmt\n \n \n \n 745\n 15\n 795\n 15\n 1\n \n \n \n 80\n 0\n 155\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n location_name\n \n \n \n \n 565\n 0\n 50\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n uom_name\n \n \n \n \n 635\n 0\n 85\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n expiration\n \n \n \n
\n \n 29\n \n \n \n \n 750\n 5\n 45\n 17\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 430\n 5\n 80\n 17\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n cohead_number\n \n \n \n \n \n 70\n 5\n 95\n 17\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 94\n \n 0\n 0\n 203\n 0\n 2\n \n \n \n \n 215\n 35\n 580\n 17\n \n 14\n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_shipcomments\n \n \n \n 202\n 0\n 203\n 55\n 2\n \n \n 155\n 25\n 195\n 25\n 0\n \n \n \n \n 155\n 50\n 195\n 50\n 0\n \n \n 0\n 55\n 203\n 55\n 2\n \n \n
\n This report definition shows location / lot / serial information on an SO Pick List. If the item is not Location Controlled it shows the contents of its Location Comment in the corresponding Item Site record. 0 2015-10-01 17:15:58.47729 371 PickingListSONoClosedLines \N \n\n Picking List\n PickingListSONoClosedLines\n Omits Closed Lines -- With Barcodes formatitemsitebarcode(itemsite_id) -- SO # barcoded formatsobarcode(cohead_id) -- With Logo, place logo graphic in images DB with name "logo"\n \n \n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 25\n 25\n 25\n 25\n \n head\n SELECT cust_number,\n formatsobarcode(cohead_id) AS order_barcode,\n formataddr(cohead_billtoaddress1,\n cohead_billtoaddress2,\n cohead_billtoaddress3,\n (cohead_billtocity || ' ' || cohead_billtostate || ' ' || cohead_billtozipcode),\n cohead_billtocountry) AS billing_address, \n formataddr(cohead_shiptoaddress1,\n cohead_shiptoaddress2,\n cohead_shiptoaddress3,\n (cohead_shiptocity || ' ' || cohead_shiptostate || ' ' || cohead_shiptozipcode),\n cohead_shiptocountry) AS shipping_address, \n trim(cntct_first_name || ' ' || cntct_last_name) AS cust_contact,\n cohead_billtoname,\n cohead_billtoaddress1,\n cohead_billtoaddress2,\n cohead_billtoaddress3,\n (cohead_billtocity || ' ' || cohead_billtostate || ' ' || cohead_billtozipcode) AS billtocitystatezip,\n cntct_phone AS cust_phone,\n cohead_shiptoname,\n cohead_shiptoaddress1,\n cohead_shiptoaddress2,\n cohead_shiptoaddress3,\n (cohead_shiptocity || ' ' || cohead_shiptostate || ' ' || cohead_shiptozipcode) AS shiptocitystatezip,\n cohead_number,\n cohead_shipvia,\n cohead_shiptophone,\n cohead_custponumber,\n formatDate(cohead_orderdate) AS orderdate,\n formatDate(getSoSchedDate(cohead_id)) AS scheddate,\n cohead_shipcomments, \n terms_descrip\n FROM cohead JOIN custinfo ON (cohead_cust_id=cust_id)\n JOIN terms ON (cohead_terms_id=terms_id)\n LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\n WHERE (cohead_id=<? value("sohead_id") ?>);\n \n \n detail\n SELECT 1 AS groupby,\n coitem_linenumber AS sortline,\n coitem_subnumber AS sortsubline,\n formatsolinenumber(coitem_id) AS linenumber,\n coitem_memo,\n item_number,\n formatitemsitebarcode(itemsite_id) AS item_barcode,\n uom_name AS item_invuom,\n item_descrip1,\n item_descrip2,\n formatQty(coitem_qtyord) AS ordered,\n CASE WHEN (coitem_qtyreserved > 0.0)\n THEN formatQty(coitem_qtyreserved)\n ELSE NULL\n END AS reserved,\n CASE WHEN ((coitem_qtyshipped - coitem_qtyreturned) > 0.0)\n THEN formatQty(coitem_qtyshipped - coitem_qtyreturned)\n ELSE NULL\n END AS shipped,\n CASE WHEN (fetchMetricBool('RequireSOReservations'))\n THEN formatQty(coitem_qtyreserved)\n ELSE formatQty(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping('SO', coitem_id)))\n END AS balance,\n CASE WHEN (qtyAtShipping('SO', coitem_id) > 0.0)\n THEN formatQty(qtyAtShipping('SO', coitem_id))\n ELSE NULL\n END AS atShipping,\n getSoitemStatus(coitem_id) AS f_status\n FROM coitem JOIN uom ON (uom_id=coitem_qty_uom_id)\n JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n WHERE ((coitem_cohead_id=<? value("sohead_id") ?>)\n AND (coitem_status <> 'X')\n AND (coitem_status <> 'C')\n AND (item_type != 'K')\n AND ( (fetchMetricBool('RequireSOReservations') AND (coitem_qtyreserved > 0.0)) OR\n (NOT fetchMetricBool('RequireSOReservations')) )\n-- 1 REMOVE THIS AND CLOSED LINES WILL NOT DISPLAY ON PACKING LIST \n<? if exists("hide closed") ?>\n AND (coitem_status <> 'C')\n-- 2 REMOVE THIS AND CLOSED LINES WILL NOT DISPLAY ON PACKING LIST \n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n)\nORDER BY sortline, sortsubline;\n \n \n logo\n SELECT image_data \nFROM image \nWHERE ((image_name='logo'));\n \n \n site\n <? if exists("warehous_id") ?>\n SELECT warehous_code AS f_site\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>);\n<? else ?>\n SELECT text('') AS f_site;\n<? endif ?>\n\n \n \n 477\n \n \n 375\n 0\n 425\n 85\n \n stretch\n \n logo\n image_data\n \n \n \n \n 120\n 400\n 253\n 25\n \n \n Arial\n 12\n normal\n \n \n \n \n head\n cust_contact\n \n \n \n \n 375\n 160\n 307\n 25\n \n 3of9\n 20\n \n 0.01\n \n head\n cohead_custponumber\n \n \n \n \n \n \n \n \n 175\n 215\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n scheddate\n \n \n \n \n 465\n 280\n 305\n 20\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n head\n shipping_address\n \n \n \n \n \n \n 170\n 125\n 170\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cust_number\n \n \n \n \n \n 433\n 215\n 331\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cohead_shipvia\n \n \n \n \n \n 468\n 400\n 320\n 20\n \n \n Arial\n 12\n normal\n \n \n \n \n head\n terms_descrip\n \n \n \n \n 170\n 155\n 170\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cohead_custponumber\n \n \n \n \n \n 75\n 280\n 295\n 20\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n head\n billing_address\n \n \n \n \n \n 375\n 95\n 233\n 25\n \n 128\n 10\n \n 0.01\n \n head\n order_barcode\n \n \n \n \n 175\n 195\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n orderdate\n \n \n \n \n \n \n 170\n 95\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cohead_number\n \n \n \n 25\n 465\n 823\n 465\n 0\n \n \n \n \n 25\n 425\n 823\n 425\n 0\n \n \n \n 465\n 260\n 305\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cohead_shiptoname\n \n \n \n \n \n 375\n 130\n 177\n 25\n \n 3of9\n 10\n \n 0.01\n \n head\n cust_number\n \n \n \n \n \n \n \n 75\n 260\n 305\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n head\n cohead_billtoname\n \n \n \n \n \n \n 170\n 65\n 100\n 20\n \n \n Arial\n 14\n normal\n \n \n \n \n site\n f_site\n \n \n \n
\n detail\n \n detail\n groupby\n \n 68\n \n \n 50\n 5\n 625\n 17\n \n 14\n \n Arial\n 10\n normal\n \n \n \n \n head\n cohead_shipcomments\n \n \n \n \n \n lineitem\n linenumber\n \n 23\n \n 5\n 5\n 843\n 5\n 0\n \n \n \n \n \n detail\n \n 148\n \n \n \n 630\n 98\n 85\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n f_status\n \n \n \n \n 25\n 40\n 295\n 20\n \n \n Arial\n 11\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n 190\n 110\n 280\n 110\n 0\n \n \n \n 635\n 0\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n atshipping\n \n \n \n \n 25\n 20\n 295\n 20\n \n \n Arial\n 11\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n \n 100\n 120\n 690\n 17\n \n 14\n \n Arial\n 10\n normal\n \n \n \n \n detail\n coitem_memo\n \n \n \n 415\n 110\n 500\n 110\n 0\n \n \n \n \n 415\n 80\n 500\n 80\n 0\n \n \n 80\n 110\n 170\n 110\n 0\n \n \n 190\n 80\n 280\n 80\n 0\n \n \n \n 530\n 0\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n balance\n \n \n \n 305\n 110\n 395\n 110\n 0\n \n \n 305\n 80\n 395\n 80\n 0\n \n \n \n 25\n 0\n 200\n 20\n \n \n Arial\n 11\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n \n 425\n 0\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n shipped\n \n \n \n \n 228\n 0\n 85\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n ordered\n \n \n \n 745\n 15\n 795\n 15\n 1\n \n \n 80\n 80\n 170\n 80\n 0\n \n \n \n 325\n 23\n 468\n 35\n \n 128\n 15\n \n 0.01\n \n detail\n item_barcode\n \n \n \n 632\n 80\n 720\n 80\n 0\n \n \n \n 320\n 0\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n reserved\n \n \n \n \n 630\n 83\n 85\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n item_invuom\n \n \n \n \n
\n \n 56\n \n \n \n 455\n 5\n 80\n 17\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n cohead_number\n \n \n \n \n 90\n 5\n 95\n 17\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 735\n 5\n 45\n 17\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 111\n \n 185\n 25\n 363\n 25\n 0\n \n \n \n 186\n 90\n 360\n 90\n 0\n \n \n \n
\n Omits Closed Lines -- With Barcodes formatitemsitebarcode(itemsite_id) -- SO # barcoded formatsobarcode(cohead_id) -- With Logo, place logo graphic in images DB with name "logo" 0 2015-10-01 17:15:58.47729 141 PlannerCodeMasterList \N \n\n Planner Code Master List\n PlannerCodeMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT plancode_id,\n plancode_code, \n plancode_name\n FROM plancode\nORDER BY plancode_code;\n \n \n 76\n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n 6\n \n \n 21\n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 175\n 0\n 565\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n plancode_name\n \n \n \n \n 10\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n plancode_code\n \n \n \n
\n \n 16\n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 68 PricesByCustomer \N \n\n Prices By Customer\n PricesByCustomer\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT cust_name,\n addr_line1 AS cust_address1,\n addr_line2 AS cust_address2,\n addr_line3 AS cust_address3,\n <? if exists("showExpired") ?>\n text('Yes')\n <? else ?>\n text('No')\n <? endif ?>\n AS f_showexpired,\n <? if exists("showFuture") ?>\n text('Yes')\n <? else ?>\n text('No')\n <? endif ?>\n AS f_showfuture,\n <? if exists("showCosts") ?>\n <? if exists("actualCosts") ?>\n text('Show Costs and Margins using Actual Costs')\n <? else ?>\n text('Show Costs and Margins using Standard Costs')\n <? endif ?>\n AS f_showcosts,\n text('Cost') AS f_costlabel,\n text('Margin') AS f_marginlabel\n <? else ?>\n text('') AS f_showcosts,\n text('') AS f_costlabel,\n text('') AS f_marginlabel\n <? endif ?>\n FROM custinfo\n LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\n LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\nWHERE (cust_id=<? value("cust_id") ?>);\n\n \n \n detail\n SELECT itemid, sourcetype, schedulename, type, itemnumber,\n item_descrip1, item_descrip2,\n CASE WHEN (qtybreak = -1) THEN 'N/A'\n ELSE formatQty(qtybreak)\n END AS f_qtybreak,\n price, formatPrice(price) AS f_price,\n <? if exists("showCosts") ?>\n cost AS cost,\n formatCost(cost) AS f_cost,\n CASE WHEN ((price = 0) OR (cost = 0)) THEN 'N/A'\n ELSE formatScrap((price - cost) / price)\n END AS f_margin\n <? else ?>\n 0 AS cost,\n text('') AS f_cost,\n text('') AS f_margin\n <? endif ?>\nFROM (\n SELECT ipsprice_id AS itemid, 1 AS sourcetype,\n ipshead_name AS schedulename, 'Customer' AS type,\n item_number AS itemnumber, item_descrip1, item_descrip2,\n ipsprice_qtybreak AS qtybreak, ipsprice_price AS price,\n <? if exists("actualCosts") ?>\n (actcost(item_id) * iteminvpricerat(item_id))\n <? else ?>\n (stdcost(item_id) * iteminvpricerat(item_id))\n <? endif ?>\n AS cost\n FROM ipsass, ipshead, ipsprice, item\n WHERE ((ipsass_ipshead_id=ipshead_id)\n AND (ipsprice_ipshead_id=ipshead_id)\n AND (ipsprice_item_id=item_id)\n AND (ipsass_cust_id=<? value("cust_id") ?>)\n<? if not exists("showExpired") ?>\n AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n )\n\n UNION\n SELECT ipsprice_id AS itemid, 2 AS sourcetype,\n ipshead_name AS schedulename, 'Cust. Type' AS type,\n item_number AS itemnumber, item_descrip1, item_descrip2,\n ipsprice_qtybreak AS qtybreak, ipsprice_price AS price,\n <? if exists("actualCosts") ?>\n (actcost(item_id) * iteminvpricerat(item_id))\n <? else ?>\n (stdcost(item_id) * iteminvpricerat(item_id))\n <? endif ?>\n AS cost\n FROM ipsass, ipshead, ipsprice, item, custinfo\n WHERE ((ipsass_ipshead_id=ipshead_id)\n AND (ipsprice_ipshead_id=ipshead_id)\n AND (ipsprice_item_id=item_id)\n AND (ipsass_custtype_id=cust_custtype_id)\n AND (cust_id=<? value("cust_id") ?>)\n<? if not exists("showExpired") ?>\n AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n )\n\n UNION\n SELECT ipsprice_id AS itemid, 3 AS sourcetype,\n ipshead_name AS schedulename, ('Sale' || '-' || sale_name) AS type,\n item_number AS itemnumber, item_descrip1, item_descrip2,\n ipsprice_qtybreak AS qtybreak, ipsprice_price AS price,\n <? if exists("actualCosts") ?>\n (actcost(item_id) * iteminvpricerat(item_id))\n <? else ?>\n (stdcost(item_id) * iteminvpricerat(item_id))\n <? endif ?>\n AS cost\n FROM sale, ipshead, ipsprice, item\n WHERE ((sale_ipshead_id=ipshead_id)\n AND (ipsprice_ipshead_id=ipshead_id)\n AND (ipsprice_item_id=item_id)\n<? if not exists("showExpired") ?>\n AND (sale_enddate > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (sale_startdate <= CURRENT_DATE)\n<? endif ?>\n )\n\n UNION\n SELECT item_id AS itemid, 0 AS sourcetype,\n '' AS schedulename, 'List Price' AS type,\n item_number AS itemnumber, item_descrip1, item_descrip2,\n -1 AS qtybreak, (item_listprice - (item_listprice * cust_discntprcnt)) AS price,\n <? if exists("actualCosts") ?>\n (actcost(item_id) * iteminvpricerat(item_id))\n <? else ?>\n (stdcost(item_id) * iteminvpricerat(item_id))\n <? endif ?>\n AS cost\n FROM item, custinfo\n WHERE ( (item_sold)\n AND (item_active)\n AND (cust_id=<? value("cust_id") ?>)\n AND (NOT item_exclusive) )\n) AS data\nORDER BY itemnumber, price;\n \n \n 236\n \n \n \n \n 565\n 120\n 114\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_showfuture\n \n \n \n \n 100\n 80\n 605\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_name\n \n \n \n \n 665\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_marginlabel\n \n \n \n \n 585\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_costlabel\n \n \n \n 5\n 229\n 745\n 229\n 2\n \n \n \n \n 100\n 140\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_address3\n \n \n \n \n \n 100\n 100\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_address1\n \n \n \n \n 405\n 140\n 335\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_showcosts\n \n \n \n \n \n 565\n 100\n 114\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_showexpired\n \n \n \n \n \n \n \n \n \n 100\n 120\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_address2\n \n \n \n \n \n 6\n \n \n 41\n \n \n 665\n 5\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_marginlabel\n \n \n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n \n 585\n 5\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_costlabel\n \n \n \n \n \n
\n detail\n \n \n detail\n \n 56\n \n \n 10\n 30\n 240\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 10\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemnumber\n \n \n \n \n 425\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtybreak\n \n \n \n 5\n 50\n 745\n 50\n 0\n \n \n \n 585\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_cost\n \n \n \n \n 195\n 0\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n schedulename\n \n \n \n \n 505\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_price\n \n \n \n \n 10\n 15\n 240\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_margin\n \n \n \n \n 320\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n type\n \n \n \n
\n \n 16\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 69 PricesByCustomerType \N \n\n Prices By Customer Type\n PricesByCustomerType\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT (custtype_code || '-' || custtype_descrip) as custtype,\n <? if exists("showExpired") ?>\n text('Yes')\n <? else ?>\n text('No')\n <? endif ?>\n AS f_showexpired,\n <? if exists("showFuture") ?>\n text('Yes')\n <? else ?>\n text('No')\n <? endif ?>\n AS f_showfuture,\n <? if exists("showCosts") ?>\n <? if exists("actualCosts") ?>\n text('Show Costs and Margins using Actual Costs')\n <? else ?>\n text('Show Costs and Margins using Standard Costs')\n <? endif ?>\n AS f_showcosts,\n text('Cost') AS f_costlabel,\n text('Margin') AS f_marginlabel\n <? else ?>\n text('') AS f_showcosts,\n text('') AS f_costlabel,\n text('') AS f_marginlabel\n <? endif ?>\n FROM custtype\n WHERE (custtype_id=<? value("custtype_id") ?>);\n\n \n \n detail\n SELECT itemid, sourcetype, schedulename, type, itemnumber,\n item_descrip1, item_descrip2,\n CASE WHEN (qtybreak = -1) THEN 'N/A'\n ELSE formatQty(qtybreak)\n END AS f_qtybreak,\n price, formatSalesPrice(price) AS f_price,\n <? if exists("showCosts") ?>\n cost AS cost,\n formatCost(cost) AS f_cost,\n CASE WHEN ((price = 0) OR (cost = 0)) THEN 'N/A'\n ELSE formatScrap((price - cost) / price)\n END AS f_margin\n <? else ?>\n 0 AS cost,\n '' AS f_cost,\n '' AS f_margin\n <? endif ?>\nFROM (\n SELECT ipsprice_id AS itemid, 2 AS sourcetype,\n ipshead_name AS schedulename, 'Cust. Type' AS type,\n item_number AS itemnumber, item_descrip1, item_descrip2,\n ipsprice_qtybreak AS qtybreak, ipsprice_price AS price,\n <? if exists("actualCosts") ?>\n (actcost(ipsprice_item_id) * iteminvpricerat(item_id))\n <? else ?>\n (stdcost(ipsprice_item_id) * iteminvpricerat(item_id))\n <? endif ?>\n AS cost\n FROM ipsass, ipshead, ipsprice, item \n WHERE ((ipsass_ipshead_id=ipshead_id)\n AND (ipsprice_ipshead_id=ipshead_id)\n AND (ipsprice_item_id=item_id)\n AND (ipsass_custtype_id=<? value("custtype_id") ?>)\n<? if not exists("showExpired") ?>\n AND (ipshead_expires > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (ipshead_effective <= CURRENT_DATE)\n<? endif ?>\n )\n\n UNION\n SELECT ipsprice_id AS itemid, 3 AS sourcetype,\n ipshead_name AS schedulename, ('Sale' || '-' || sale_name) AS type,\n item_number AS itemnumber,\n item_descrip1, item_descrip2,\n ipsprice_qtybreak AS qtybreak, ipsprice_price AS price,\n <? if exists("actualCosts") ?>\n (actcost(ipsprice_item_id) * iteminvpricerat(item_id))\n <? else ?>\n (stdcost(ipsprice_item_id) * iteminvpricerat(item_id))\n <? endif ?>\n AS cost\n FROM sale, ipshead, ipsprice, item\n WHERE ( (sale_ipshead_id=ipshead_id)\n AND (ipsprice_ipshead_id=ipshead_id)\n AND (ipsprice_item_id=item_id)\n<? if not exists("showExpired") ?>\n AND (sale_enddate > CURRENT_DATE)\n<? endif ?>\n<? if not exists("showFuture") ?>\n AND (sale_startdate <= CURRENT_DATE)\n<? endif ?>\n )\n\n UNION\n SELECT item_id AS itemid, 0 AS sourcetype,\n '' AS schedulename, 'List Price' AS type,\n item_number AS itemnumber, item_descrip1, item_descrip2,\n -1 AS qtybreak, item_listprice AS price,\n <? if exists("actualCosts") ?>\n (actcost(item_id) * iteminvpricerat(item_id))\n <? else ?>\n (stdcost(item_id) * iteminvpricerat(item_id))\n <? endif ?>\n AS cost\n FROM item\n WHERE ( (item_sold)\n AND (item_active)\n AND (NOT item_exclusive) )\n) AS data\nORDER BY itemnumber, price;\n \n \n 236\n \n \n \n \n \n 585\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_costlabel\n \n \n \n \n 665\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_marginlabel\n \n \n \n \n 130\n 80\n 500\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n custtype\n \n \n \n \n \n 565\n 120\n 113\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_showfuture\n \n \n \n \n \n \n 565\n 100\n 113\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_showexpired\n \n \n \n 5\n 229\n 745\n 229\n 2\n \n \n \n \n \n \n 405\n 140\n 335\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_showcosts\n \n \n \n \n \n \n 6\n \n \n 41\n \n \n \n \n \n 665\n 5\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_marginlabel\n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n 585\n 5\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n f_costlabel\n \n \n \n \n \n
\n detail\n \n \n detail\n \n 56\n \n 5\n 50\n 745\n 50\n 0\n \n \n \n 425\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtybreak\n \n \n \n \n 10\n 15\n 240\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 195\n 0\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n schedulename\n \n \n \n \n 10\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemnumber\n \n \n \n \n 505\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_price\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_margin\n \n \n \n \n 10\n 30\n 240\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 585\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_cost\n \n \n \n \n 320\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n type\n \n \n \n
\n \n 16\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 258 PricingScheduleAssignments \N \n\n Pricing Schedule Assignments\n PricingScheduleAssignments\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT ipsass_id,\n CASE WHEN (ipsass_shipto_id != -1) THEN (SELECT shipto_num FROM shiptoinfo WHERE (shipto_id=ipsass_shipto_id))\n WHEN (COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) THEN ipsass_shipto_pattern\n ELSE TEXT('ANY')\n END AS shiptonum,\n CASE WHEN (ipsass_shipto_id != -1) THEN (SELECT cust_number FROM shiptoinfo, custinfo WHERE ((shipto_cust_id=cust_id) AND (shipto_id=ipsass_shipto_id)))\n WHEN (ipsass_cust_id=-1) THEN TEXT('Any')\n ELSE (SELECT cust_number FROM custinfo WHERE (cust_id=ipsass_cust_id))\n END AS custnumber,\n CASE WHEN (ipsass_shipto_id != -1) THEN (SELECT cust_name FROM shiptoinfo, custinfo WHERE ((shipto_cust_id=cust_id) AND (shipto_id=ipsass_shipto_id)))\n WHEN (ipsass_cust_id=-1) THEN ''\n ELSE (SELECT cust_name FROM custinfo WHERE (cust_id=ipsass_cust_id))\n END AS custname,\n CASE WHEN (ipsass_cust_id != -1) THEN TEXT('N/A')\n WHEN (ipsass_shipto_id != -1) THEN TEXT('N/A')\n WHEN (COALESCE(LENGTH(ipsass_shipto_pattern),0) > 0) THEN TEXT('N/A')\n WHEN (ipsass_custtype_id=-1) THEN ipsass_custtype_pattern\n ELSE (SELECT custtype_code FROM custtype WHERE (custtype_id=ipsass_custtype_id))\n END AS custtype,\n ipshead_name\nFROM ipsass, ipshead\nWHERE (ipshead_id=ipsass_ipshead_id)\nORDER BY custname, custtype;\n\n \n \n 78\n \n \n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 18\n \n \n 465\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n custtype\n \n \n \n \n 5\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shiptonum\n \n \n \n \n 240\n 0\n 205\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n custname\n \n \n \n \n 115\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n custnumber\n \n \n \n \n 580\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ipshead_name\n \n \n \n
\n \n 18\n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 44 ProductCategoriesMasterList \N \n\n Product Categories Master List\n ProductCategoriesMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n select prodcat_code, prodcat_descrip\n from prodcat\norder by prodcat_code;\n \n \n 76\n \n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n 6\n \n \n 21\n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 10\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n prodcat_code\n \n \n \n \n 175\n 0\n 565\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n prodcat_descrip\n \n \n \n
\n \n 16\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 298 ProjectTaskList \N \n\n ProjectTaskList\n ProjectTaskList\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT prjtask_number, prjtask_name, prjtask_descrip,\n CASE WHEN (prjtask_status='P') THEN 'Planning'\n\t WHEN (prjtask_status='O') THEN 'In-Process'\n\t ELSE 'Completed' END as status,\n formatDate(prjtask_start_date) as f_start,\n formatDate(prjtask_due_date) as f_due,\n formatDate(prjtask_assigned_date) as f_assigned,\n formatDate(prjtask_completed_date) as f_completed\n FROM prjtask\n WHERE (prjtask_prj_id=<?value("prj_id")?>)\n ORDER BY prjtask_number;\n \n \n head\n SELECT (prj_number||'-'||prj_name) AS project\n FROM prj\n WHERE (prj_id=<? value("prj_id") ?>);\n \n \n 102\n \n \n \n \n 70\n 50\n 450\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n project\n \n \n \n \n \n 5\n 95\n 745\n 95\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 43\n \n \n 10\n 0\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n prjtask_number\n \n \n \n \n 70\n 18\n 70\n 20\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_start\n \n \n \n \n 225\n 18\n 70\n 20\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_assigned\n \n \n \n \n 375\n 18\n 70\n 20\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_due\n \n \n \n \n 525\n 18\n 70\n 20\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_completed\n \n \n \n \n \n \n \n \n 140\n -2\n 200\n 20\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n prjtask_name\n \n \n \n \n 355\n -2\n 385\n 20\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n prjtask_descrip\n \n \n \n \n 660\n 18\n 90\n 20\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n status\n \n \n \n \n
\n \n 18\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 161 PurchasePriceVariancesByItem \N \n\n Purchase Price Variances By Item\n PurchasePriceVariancesByItem\n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number, item_descrip1,\n item_descrip2, uom_name,\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("warehous_id") ?>\n (SELECT warehous_code FROM whsinfo WHERE warehous_id=<? value("warehous_id") ?>)\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("agentUsername") ?>\n TEXT(<? value("agentUsername" ?>)\n <? else ?>\n TEXT('All Agents')\n <? endif ?>\n AS agentUsername\n FROM item JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (item_id=<? value("item_id") ?>);\n \n \n detail\n poPriceVariances\n detail\n \n \n 236\n \n \n 95\n 135\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n \n \n \n \n 550\n 65\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n 95\n 155\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n agentUsername\n \n \n \n \n \n 550\n 85\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n 95\n 65\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n 95\n 85\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n \n \n \n 95\n 103\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n \n 5\n 230\n 745\n 230\n 2\n \n \n \n 310\n 65\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n uom_name\n \n \n \n \n \n \n \n \n 6\n \n \n 41\n \n \n \n \n \n \n \n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 36\n \n \n 5\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n recv_order_number\n \n \n \n \n 665\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_varprcnt\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_variance\n \n \n \n \n 60\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_name\n \n \n \n 5\n 30\n 745\n 30\n 0\n \n \n \n 575\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_recv_value\n \n \n \n \n 215\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_date\n \n \n \n \n 300\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemnumber\n \n \n \n \n 300\n 15\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemdescrip\n \n \n \n \n 490\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qty\n \n \n \n \n 575\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_voucher_value\n \n \n \n
\n \n 17\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 103\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 162 PurchasePriceVariancesByVendor \N \n\n Purchase Price Variances By Vendor\n PurchasePriceVariancesByVendor\n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("warehous_id") ?>\n (SELECT warehous_code FROM whsinfo WHERE warehous_id=<? value("warehous_id") ?>)\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("agentUsername") ?>\n TEXT(<? value("agentUsername" ?>)\n <? else ?>\n TEXT('All Agents')\n <? endif ?>\n AS agentUsername;\n \n \n detail\n poPriceVariances\n detail\n \n \n 236\n \n \n \n 550\n 64.8725\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n 550\n 85\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n 94.254\n 64.8725\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n \n \n \n \n 95.746\n 84.8725\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n agentUsername\n \n \n \n \n \n \n \n 5\n 230\n 745\n 230\n 2\n \n \n \n \n \n \n 6\n \n \n 41\n \n \n \n \n \n \n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n \n
\n detail\n \n \n detail\n \n 36\n \n \n 665\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_varprcnt\n \n \n \n \n 6.49\n -1.88608e-20\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n recv_order_number\n \n \n \n 5\n 30\n 745\n 30\n 0\n \n \n \n 490\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qty\n \n \n \n \n 300\n 15\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemdescrip\n \n \n \n \n 575\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_voucher_value\n \n \n \n \n 215\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_date\n \n \n \n \n 300\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemnumber\n \n \n \n \n 575\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_recv_value\n \n \n \n \n 69.9\n 0\n 143\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_name\n \n \n \n \n 665\n -0.442\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_variance\n \n \n \n
\n \n 17\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 103\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 145 PurchaseRequestsByItem \N \n\n Purchase Requests By Item\n PurchaseRequestsByItem\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n item_descrip1,\n item_descrip2,\n uom_name,\n <? if exists("warehous_id") ?>\n (SELECT warehous_code\n FROM whsinfo\n WHERE warehous_id=<? value("warehous_id") ?>)\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse\n FROM item JOIN uom ON (item_inv_uom_id=uom_id)\n WHERE (item_id=<? value("item_id") ?>);\n \n \n detail\n SELECT pr_status,\n pr_number || '-' || pr_subnumber AS pr_number,\n CASE WHEN (pr_order_type='W') THEN ('W/O ' || ( SELECT formatWoNumber(womatl_wo_id)\n FROM womatl\n WHERE (womatl_id=pr_order_id) ) )\n WHEN (pr_order_type='S') THEN ('S/O ' || (SELECT formatSoNumber(pr_order_id)))\n WHEN (pr_order_type='F') THEN ('Planned Order')\n WHEN (pr_order_type='M') THEN 'Manual'\n ELSE 'Other'\n END as f_type,\n pr_createdate as f_createdate,\n formatDate(pr_duedate) as f_duedate,\n formatQty(pr_qtyreq) as f_qtyreq,\n pr_releasenote as f_notes\n FROM pr, itemsite \n WHERE ((pr_itemsite_id=itemsite_id)\n AND (itemsite_item_id=<? value("item_id") ?>)\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n ) \nORDER BY pr_duedate;\n \n \n 221\n \n \n \n 135\n 85\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n 135\n 105\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n 135\n 135\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n 135\n 65\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n \n 355\n 65\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n uom_name\n \n \n \n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n \n 5\n \n \n 25\n \n \n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 39\n \n \n 655\n 0\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyreq\n \n \n \n \n 190\n 0\n 209\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_type\n \n \n \n \n 560\n 0\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_duedate\n \n \n \n \n 10\n 0\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n pr_number\n \n \n \n \n 105\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n pr_status\n \n \n \n \n \n 52\n 18\n 683\n 15\n \n 14\n \n Helvetica\n 6\n normal\n \n \n \n \n detail\n f_notes\n \n \n \n \n 445\n 0\n 110\n 16\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_createdate\n \n \n \n
\n \n 15\n \n \n 105\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 203 PurchaseReqsByPlannerCode \N \n\n Purchase Requests By Planner Code\n PurchaseReqsByPlannerCode\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("plancode_id") ?>\n ( SELECT (plancode_code||'-'||plancode_name)\n FROM plancode\n WHERE plancode_id=<? value("plancode_id") ?>)\n <? elseif exists("plancode_pattern") ?>\n text(<? value("plancode_pattern") ?>)\n <? else ?>\n text('All Planner Codes')\n <? endif ?>\n AS plancode,\n <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE warehous_id=<? value("warehous_id") ?>)\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n formatDate(<? value("startDate") ?>) AS startdate,\n formatDate(<? value("endDate") ?>) AS enddate;\n \n \n detail\n SELECT item_number,\n (item_descrip1 || ' ' || item_descrip2) as item_descrip,\n pr_status,\n CASE WHEN (pr_order_type='W') THEN ('W/O ' || ( SELECT formatWoNumber(womatl_wo_id)\n FROM womatl\n WHERE (womatl_id=pr_order_id) ) )\n WHEN (pr_order_type='S') THEN ('S/O ' || (SELECT formatSoNumber(pr_order_id)))\n WHEN (pr_order_type='F') THEN ('Planned Order')\n WHEN (pr_order_type='M') THEN 'Manual'\n ELSE 'Other'\n END AS f_type,\n formatDate(pr_duedate) AS f_duedate,\n formatQty(pr_qtyreq) AS f_qtyreq\n FROM pr, itemsite, item\n WHERE ((pr_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (pr_duedate BETWEEN <? value("startDate") ?> and <? value("endDate") ?>)\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("plancode_id") ?>\n AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n AND (itemsite_plancode_id IN (SELECT plancode_id\n FROM plancode\n WHERE (plancode_code ~ <? value("plancode_pattern") ?>) ) )\n<? endif ?>\n)\nORDER BY pr_duedate;\n \n \n 171\n \n \n \n \n 555\n 85\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n 555\n 65\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n 5\n 165\n 745\n 165\n 2\n \n \n \n \n \n \n \n \n 135\n 65\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n plancode\n \n \n \n \n \n 135\n 85\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n \n 6\n \n \n 26\n \n \n \n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyreq\n \n \n \n \n 10\n 0\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 135\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip\n \n \n \n \n 340\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n pr_status\n \n \n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_duedate\n \n \n \n \n 425\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_type\n \n \n \n
\n \n 16\n \n \n \n 105\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 457 QOH \N \n\n Quantities on Hand\n QOH\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("onlyShowPositive") ?>\n text('Only Showing Positive Quantities')\n <? elseif exists("onlyShowNegative") ?>\n text('Only Showing Negative Quantities')\n <? else ?>\n text('Showing All Quantities')\n <? endif ?>\n AS showquantities,\n <? if exists("showValue") ?>\n text('Unit Cost') AS lbl_unitcost,\n text('Value') AS lbl_value,\n text('NN Value') AS lbl_nnvalue,\n text('Cost Method') AS lbl_costmethod,\n <? else ?>\n text('') AS lbl_unitcost,\n text('') AS lbl_value,\n text('') AS lbl_nnvalue,\n text('') AS lbl_costmethod,\n <? endif ?>\n <? if exists("showValue") ?>\n <? if exists("useActualCosts") ?>\n text('Showing Actual Costs')\n <? elseif exists("useStandardCosts") ?>\n text('Showing Standard Costs')\n <? else ?>\n text('Showing Posted Costs')\n <? endif ?>\n <? else ?>\n text('')\n <? endif ?>\n AS showvalues;\n\n \n \n detail\n qoh\n detail\n \n \n 234\n \n \n \n 590\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_value\n \n \n \n \n 509\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_unitcost\n \n \n \n \n \n 185\n 43\n 300\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n showvalues\n \n \n \n 8\n 231.167\n 748\n 231.167\n 2\n \n \n \n \n \n \n 670\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_nnvalue\n \n \n \n \n \n 10\n 43\n 300\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n showquantities\n \n \n \n \n 670\n 215\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_costmethod\n \n \n \n \n \n 10\n 58\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n \n 6\n \n \n 36\n \n \n 590\n 0\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_value\n \n \n \n \n \n 670\n 0\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_nnvalue\n \n \n \n \n 509\n 0\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_unitcost\n \n \n \n \n \n \n \n 670\n 15\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_costmethod\n \n \n \n \n \n \n 10\n 33.3333\n 750\n 33.3333\n 2\n \n \n
\n detail\n \n \n detail\n \n 51\n \n \n 265\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_reorderlevel\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 104\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 104\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 5\n 0\n 95\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 10\n 15\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n defaultlocation\n \n \n \n \n 585\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_value\n \n \n \n \n 345\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qoh\n \n \n \n \n 104\n 15\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_nonnetvalue\n \n \n \n \n 580\n 15\n 170\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_costmethod\n \n \n \n \n 505\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_cost\n \n \n \n \n 425\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_nonnetqoh\n \n \n \n
\n \n 16\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 16\n \n \n 425\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n nonnetqoh\n \n qty\n \n \n \n \n 585\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_value\n \n money\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n nonnetvalue\n \n money\n \n \n \n \n 345\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qoh\n \n qty\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 11 QOHByLocation \N \n\n Quantities on Hand by Location\n QOHByLocation\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT (location_name||'-'||firstLine(location_descrip)) AS f_location,\n formatBoolYN(location_netable) AS f_netable,\n formatBoolYN(location_restrict) AS f_restricted,\n warehous_code,\n formatDate(<? value("asOf") ?>) AS asofdate\n FROM location, whsinfo\n WHERE ((location_warehous_id=warehous_id)\n AND (location_id=<? value("location_id") ?>) );\n \n \n detail\n qoh\n detail\n \n \n 234\n \n \n 130\n 140\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehous_code\n \n \n \n \n \n \n \n 435\n 140\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_restricted\n \n \n \n \n \n \n \n \n 130\n 120\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_location\n \n \n \n 5\n 228\n 745\n 228\n 2\n \n \n \n \n \n 435\n 120\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_netable\n \n \n \n \n \n \n 130\n 160\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n asofdate\n \n \n \n \n \n \n \n 6\n \n \n 41\n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 51\n \n \n 320\n 0\n 230\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_lotserial\n \n \n \n \n 85\n 0\n 220\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 565\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n \n 85\n 15\n 526\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_descrip\n \n \n \n \n 10\n 0\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qoh\n \n qty\n \n \n \n 665\n 14\n 80\n 20\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n reservedqty\n \n qty\n \n \n
\n \n 16\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 172 Quote \N \n\n Quote\n Quote\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT quhead_number,\n quhead_shipvia,\n formatDate(quhead_quotedate) as f_orderdate,\n formatDate(quhead_packdate) as f_packdate,\n salesrep_name,\n formatScrap(quhead_commission) as f_commission,\n (terms_code||' - '||terms_descrip) as f_terms,\n cust_number,\n quhead_billtoname,\n formatAddr(quhead_billtoaddress1,\n quhead_billtoaddress2,\n quhead_billtoaddress3,\n (quhead_billtocity || ', ' || quhead_billtostate || ' ' || quhead_billtozip),\n quhead_billtocountry) AS f_billtoaddress,\n CASE WHEN(quhead_shipto_id=-1) THEN text('')\n ELSE (SELECT text(shipto_num) FROM shiptoinfo WHERE (shipto_id=quhead_shipto_id))\n END AS f_shiptonum,\n quhead_shiptoname,\n formatAddr(quhead_shiptoaddress1,\n quhead_shiptoaddress2,\n quhead_shiptoaddress3,\n (quhead_shiptocity || ', ' || quhead_shiptostate || ' ' || quhead_shiptozipcode),\n quhead_shiptocountry) AS f_shiptoaddress,\n quhead_custponumber,\n quhead_fob, saletype_code\nFROM quhead\n LEFT OUTER JOIN custinfo ON (quhead_cust_id = cust_id)\n LEFT OUTER JOIN terms ON (quhead_terms_id = terms_id)\n LEFT OUTER JOIN salesrep ON (quhead_salesrep_id = salesrep_id)\n LEFT OUTER JOIN saletype ON (quhead_saletype_id = saletype_id)\nWHERE (quhead_id = <? value("quhead_id") ?>)\n\n \n \n notes\n SELECT quhead_ordercomments,\n quhead_shipcomments\n FROM quhead\n WHERE (quhead_id=<? value("quhead_id") ?>);\n \n \n items\n SELECT quitem_id,\n quitem_linenumber,\n quitem_custpn, \n item_number,\n item_descrip1,\n --The following 2 lines are new in 2.3\n (select uom_name from uom where uom_id = quitem_qty_uom_id) AS uom_ordered,\n (select uom_name from uom where uom_id = quitem_price_uom_id) AS uom_pricing,\n warehous_code,\n formatQty(quitem_qtyord) as f_ordered,\n formatPrice(quitem_price) as f_price,\n --The following line was changed in 2.3 from:\n --formatExtprice(quitem_qtyord * (quitem_price / iteminvpricerat(item_id))) as f_extprice\n --To:\n formatExtprice((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio)) as f_extprice,\n quitem_memo,\n char_name, \n charass_value \nFROM quitem\n JOIN item ON (item_id=quitem_item_id)\n LEFT OUTER JOIN (itemsite JOIN whsinfo ON (itemsite_warehous_id=warehous_id)) ON (quitem_itemsite_id=itemsite_id)\n LEFT OUTER JOIN charass ON ((charass_target_id = quitem_id) \n AND (charass_target_type = 'QI'))\n LEFT OUTER JOIN char ON (charass_char_id = char_id)\nWHERE (quitem_quhead_id=<? value("quhead_id") ?>) \nORDER BY quitem_linenumber;\n \n \n totals\n SELECT 1 as one,\n formatExtPrice(subtotal) AS f_subtotal,\n formatExtPrice(tax) AS f_tax,\n formatExtPrice(quhead_freight) AS f_freight,\n formatExtPrice(quhead_misc) AS f_misc,\n formatExtPrice(subtotal + tax + quhead_freight + quhead_misc) AS f_total\n FROM quhead,\n (SELECT SUM(ROUND((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio),2)) AS subtotal\n FROM quitem\n WHERE (quitem_quhead_id=<? value("quhead_id") ?>) ) AS subtot,\n (SELECT COALESCE(SUM(tax),0.0) AS tax \n FROM (\n SELECT ROUND(SUM(taxdetail_tax),2) AS tax \n FROM tax \n JOIN calculateTaxDetailSummary('Q', <? value("quhead_id") ?>, 'T') ON (taxdetail_tax_id=tax_id)\n\tGROUP BY tax_id) AS data) AS taxtot\n \n\n\n WHERE (quhead_id=<? value("quhead_id") ?>);\n\n \n \n logo\n SELECT image_data \nFROM image \nWHERE ((image_name='logo'));\n \n \n currency_info\n --this was added in version 2.3\nSELECT curr_name,\n curr_symbol,\n curr_abbr\nFROM quhead, curr_symbol\nWHERE ( (quhead_curr_id = curr_id)\n AND (quhead_id = <? value("quhead_id") ?>) );\n \n \n address\n SELECT warehous_descrip,\n formatAddr(addr_line1,\n addr_line2,\n addr_line3,\n (addr_city || ' ' || addr_state || ' ' || addr_postalcode),\n addr_country) AS warehouse_address\nFROM whsinfo, \n addr, \n quhead\nWHERE ( (addr_id = warehous_addr_id)\n AND (quhead_warehous_id = warehous_id)\n AND (quhead_id=<? value("quhead_id") ?>) );\n \n \n contact_fax_phone\n SELECT cntct_fax,\n cntct_phone\nFROM cntct, quhead, custinfo\nWHERE ( (cust_id = quhead_cust_id)\n AND (cust_cntct_id = cntct_id)\n AND (quhead_id = <? value("quhead_id") ?>) );\n\n \n \n 427\n \n \n 275\n 5\n 238\n 100\n \n stretch\n \n logo\n image_data\n \n \n \n \n 10\n 25\n 265\n 15\n \n 10\n \n Arial\n 10\n normal\n \n \n \n \n address\n warehouse_address\n \n \n \n \n 100\n 175\n 206\n 21\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_number\n \n \n \n \n 440\n 215\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n quhead_shiptoname\n \n \n \n \n \n 55\n 325\n 121\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n contact_fax_phone\n cntct_phone\n \n \n \n \n \n \n 55\n 215\n 285\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n quhead_billtoname\n \n \n \n \n 208\n 325\n 121\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n contact_fax_phone\n cntct_fax\n \n \n \n \n 440\n 190\n 206\n 21\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_shiptonum\n \n \n \n \n 100\n 130\n 206\n 21\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n quhead_number\n \n \n \n \n \n \n 440\n 145\n 103\n 21\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_packdate\n \n \n \n \n \n \n 100\n 160\n 206\n 21\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n saletype_code\n \n \n \n \n \n \n \n \n \n \n 100\n 145\n 206\n 21\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n salesrep_name\n \n \n \n \n \n \n \n \n \n 440\n 130\n 103\n 21\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_orderdate\n \n \n \n \n \n \n \n \n 505\n 350\n 206\n 21\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n quhead_shipvia\n \n \n \n \n 140\n 370\n 206\n 21\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n quhead_fob\n \n \n \n \n \n 440\n 160\n 262\n 21\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_terms\n \n \n \n \n 55\n 233\n 300\n 15\n \n 0\n \n Arial\n 10\n normal\n \n \n \n \n head\n f_billtoaddress\n \n \n \n \n 140\n 350\n 206\n 21\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n quhead_custponumber\n \n \n \n \n 10\n 5\n 257\n 19\n \n \n Arial\n 10\n bold\n \n \n \n \n address\n warehous_descrip\n \n \n \n \n 440\n 233\n 300\n 15\n \n 0\n \n Arial\n 10\n normal\n \n \n \n \n head\n f_shiptoaddress\n \n \n \n
\n lineitems\n \n lineitems\n quitem_linenumber\n \n 32\n \n \n 155\n 0\n 225\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n items\n item_descrip1\n \n \n \n 5\n 0\n 783\n 0\n 2\n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n items\n f_extprice\n \n \n \n \n \n 5\n 0\n 25\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n items\n quitem_linenumber\n \n \n \n \n 385\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n items\n warehous_code\n \n \n \n \n 640\n 0\n 37\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n items\n uom_pricing\n \n \n \n \n 525\n 0\n 37\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n items\n uom_ordered\n \n \n \n \n \n 45\n 0\n 103\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n items\n item_number\n \n \n \n \n 565\n 0\n 72\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n items\n f_price\n \n \n \n \n 440\n 0\n 77\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n items\n f_ordered\n \n \n \n \n 33.8828\n \n \n \n 290\n 0\n 454.347\n 13.2412\n \n 10\n \n Arial\n 8\n bold\n \n \n \n \n items\n quitem_memo\n \n \n \n \n \n 289.596\n 15.5884\n 199\n 17.1\n \n 0\n \n Sans Serif\n 8\n bold\n \n \n \n \n items\n quitem_custpn\n \n \n \n \n \n \n items\n \n 18\n \n \n 385\n 0\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n items\n charass_value\n \n \n \n \n 208\n 0\n 165\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n items\n char_name\n \n \n \n
\n
\n items\n \n items\n one\n \n 87\n \n \n \n 670\n 65\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n totals\n f_total\n \n \n \n \n \n 670\n 50\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n totals\n f_tax\n \n \n \n \n \n 670\n 35\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n totals\n f_freight\n \n \n \n \n 670\n 20\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n totals\n f_misc\n \n \n \n \n \n \n \n 204\n 10\n 206\n 18\n \n \n Arial\n 10\n bold\n \n \n \n \n currency_info\n curr_name\n \n \n \n \n 670\n 5\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n totals\n f_subtotal\n \n \n \n \n \n \n items\n \n 7\n \n
\n
\n notes\n \n \n notes\n \n 32\n \n \n \n 155\n 5\n 591\n 18\n \n 5\n \n Arial\n 10\n bold\n \n \n \n \n notes\n quhead_ordercomments\n \n \n \n
\n
\n extdescrip\n \n \n notes\n \n 32\n \n \n \n 155\n 5\n 591\n 21\n \n 5\n \n Arial\n 10\n bold\n \n \n \n \n notes\n quhead_shipcomments\n \n \n \n
\n \n 29\n \n \n 705\n 0\n 42\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 85\n 0\n 103\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 278 ReasonCodeMasterList \N \n\n Reason Code Master List\n ReasonCodeMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT rsncode_code, rsncode_descrip\n FROM rsncode\nORDER BY rsncode_code;\n \n \n 77\n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n 7\n \n \n 22\n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 17\n \n \n 10\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n rsncode_code\n \n \n \n \n 175\n 0\n 565\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n rsncode_descrip\n \n \n \n
\n \n 17\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 183 ReceiptsReturnsByVendor \N \n\n Receipts and Returns By Vendor\n ReceiptsReturnsByVendor\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT vend_name,\n vend_number,\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("warehous_id") ?>\n (SELECT warehous_code FROM whsinfo WHERE warehous_id=<? value("warehous_id") ?>)\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("agentUsername") ?>\n TEXT(<? value("agentUsername" ?>)\n <? else ?>\n TEXT('All Agents')\n <? endif ?>\n AS agentUsername,\n <? if exists("showVariances") ?>\n text('Purch. Cost') AS f_purchcost,\n text('Recv. Cost') AS f_recvcost\n <? else ?>\n text('') AS f_purchcost,\n text('') AS f_recvcost\n <? endif ?>\nFROM vendinfo\nWHERE (vend_id=<? value("vend_id") ?>);\n \n \n detail\n receivings\n detail\n \n \n 221\n \n \n 120\n 70\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n vend_number\n \n \n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n \n \n \n 455\n 70\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n \n 645\n 185\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_purchcost\n \n \n \n \n 645\n 200\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_recvcost\n \n \n \n \n 120\n 140\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n agentUsername\n \n \n \n \n 120\n 112\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n 120\n 90\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n vend_name\n \n \n \n \n \n 455\n 90\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n \n 6\n \n \n 41\n \n \n \n 645\n 20\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_recvcost\n \n \n \n \n \n \n \n 645\n 5\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_purchcost\n \n \n \n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n
\n detail\n \n \n detail\n \n 56\n \n \n 530\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qty\n \n \n \n \n 645\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_purchcost\n \n \n \n 5\n 50\n 745\n 50\n 0\n \n \n \n 215\n 15\n 400\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n venditemdescrip\n \n \n \n \n 645\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_recvcost\n \n \n \n \n 215\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n venditemnumber\n \n \n \n \n 5\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ponumber\n \n \n \n \n 418\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n sense\n \n \n \n \n 110\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_recvdate\n \n \n \n \n 110\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_duedate\n \n \n \n
\n \n 16\n \n \n \n 85\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 417 ReceivingLabel \N \n\n Receiving Label\n ReceivingLabel\n \n \n must be a positive number or 0. used to specify how many day back from today the report takes into account when printing recieving labels\n \n \n Item Number - Used to filter the item numbers by the first matching characters from the left of the string\n \n \n used to specify the number of repeated sets of labels required\n \n \n used with the pirnt receiving label form\n \n \n used to filter the report by a PO number\n \n CILS ALP1-9200-1\n Labels\n \n 10\n 0\n 0\n 10\n \n detail\n SELECT formatDate(current_date) AS date, \n COALESCE(item_number,poitem_vend_item_number) AS item_number, \n COALESCE(item_descrip1, poitem_vend_item_descrip) AS item_descrip1,\n <? value("vendorItemLit") ?> AS vendoritemlit,\n poitem_vend_item_number, \n <? value("ordertype") ?> || '#:' AS typenum,\n pohead_number AS head_number \n FROM pohead, poitem \n LEFT OUTER JOIN itemsite ON (itemsite_id = poitem_itemsite_id)\n LEFT OUTER JOIN item ON (item_id = itemsite_item_id) \n WHERE ((pohead_id = poitem_pohead_id)\n AND (poitem_id = <? value("orderitemid") ?>)\n AND ('PO' = <? value("ordertype") ?>))\nUNION\nSELECT formatDate(current_date) AS date, \n item_number AS item_number, \n item_descrip1 AS item_descrip1,\n NULL, NULL, \n <? value("ordertype") ?> || '#:' AS typenum,\n rahead_number AS head_number\n FROM rahead, raitem \n JOIN itemsite ON (itemsite_id = raitem_itemsite_id)\n JOIN item ON (item_id = itemsite_item_id) \n WHERE ((rahead_id = raitem_rahead_id)\n AND (raitem_id = <? value("orderitemid") ?>)\n AND ('RA' = <? value("ordertype") ?>))\nUNION\nSELECT formatDate(current_date) AS date, \n item_number AS item_number, \n item_descrip1 AS item_descrip1,\n NULL, NULL, \n <? value("ordertype") ?> || '#:' AS typenum,\n tohead_number AS head_number\n FROM tohead, toitem \n JOIN item ON (item_id = toitem_item_id) \n WHERE ((tohead_id = toitem_tohead_id)\n AND (toitem_id = <? value("orderitemid") ?>)\n AND ('TO' = <? value("ordertype") ?>))\n \n
\n detail\n \n \n detail\n \n 698\n \n \n 5\n 5\n 190\n 15\n \n \n Arial\n 11\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 5\n 20\n 175\n 10\n \n 0\n \n Arial\n 7\n normal\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 80\n 50\n 100\n 15\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n poitem_vend_item_number\n \n \n \n \n 35\n 65\n 45\n 15\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n head_number\n \n \n \n \n \n 115\n 65\n 65\n 15\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n date\n \n \n \n \n 5\n 65\n 25\n 15\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n typenum\n \n \n \n \n 5\n 50\n 75\n 15\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n vendoritemlit\n \n \n \n
\n
\n 0 2015-10-01 17:15:58.47729 461 ReceivingLabelOrder \N \n\n Receiving Label Order\n ReceivingLabelOrder\n \n \n must be a positive number or 0. used to specify how many day back from today the report takes into account when printing recieving labels\n \n \n Item Number - Used to filter the item numbers by the first matching characters from the left of the string\n \n \n used to specify the number of repeated sets of labels required\n \n \n used with the pirnt receiving label form\n \n \n used to filter the report by a PO number\n \n \n \n \n 0.05\n 0.05\n \n CILS ALP1-9200-1\n Labels\n \n 10\n 0\n 0\n 10\n \n detail\n SELECT formatDate(current_date) AS date, \n COALESCE(item_number,poitem_vend_item_number) AS item_number, \n COALESCE(item_descrip1, poitem_vend_item_descrip) AS item_descrip1,\n <? value("vendorItemLit") ?> AS vendoritemlit,\n poitem_vend_item_number, \n <? value("orderhead_type") ?> || '#:' AS typenum,\n pohead_number AS head_number \n FROM pohead\n JOIN poitem ON (poitem_pohead_id = pohead_id)\n LEFT OUTER JOIN itemsite ON (itemsite_id = poitem_itemsite_id)\n LEFT OUTER JOIN item ON (item_id = itemsite_item_id) \n WHERE ((pohead_id = <? value("orderhead_id") ?>)\n AND ('PO' = <? value("orderhead_type") ?>))\nUNION\nSELECT formatDate(current_date) AS date, \n item_number AS item_number, \n item_descrip1 AS item_descrip1,\n NULL, NULL, \n <? value("orderhead_type") ?> || '#:' AS typenum,\n rahead_number AS head_number\n FROM rahead\n JOIN raitem ON (raitem_rahead_id = rahead_id)\n JOIN itemsite ON (itemsite_id = raitem_itemsite_id)\n JOIN item ON (item_id = itemsite_item_id) \n WHERE ((rahead_id = <? value("orderhead_id") ?>)\n AND ('RA' = <? value("orderhead_type") ?>))\nUNION\nSELECT formatDate(current_date) AS date, \n item_number AS item_number, \n item_descrip1 AS item_descrip1,\n NULL, NULL, \n <? value("orderhead_type") ?> || '#:' AS typenum,\n tohead_number AS head_number\n FROM tohead\n JOIN toitem ON (toitem_tohead_id = tohead_id)\n JOIN item ON (item_id = toitem_item_id) \n WHERE ((tohead_id = <? value("orderhead_id") ?>)\n AND ('TO' = <? value("orderhead_type") ?>))\n \n
\n detail\n \n \n detail\n \n 698\n \n \n 5\n 5\n 190\n 15\n \n \n Arial\n 11\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 5\n 20\n 175\n 10\n \n 0\n \n Arial\n 7\n normal\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 80\n 50\n 100\n 15\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n poitem_vend_item_number\n \n \n \n \n 35\n 65\n 45\n 15\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n head_number\n \n \n \n \n \n 115\n 65\n 65\n 15\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n date\n \n \n \n \n 5\n 65\n 25\n 15\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n typenum\n \n \n \n \n 5\n 50\n 75\n 15\n \n \n Helvetica\n 8\n normal\n \n \n \n \n detail\n vendoritemlit\n \n \n \n
\n
\n 0 2015-10-01 17:15:58.47729 140 RejectCodeMasterList \N \n\n Reject Code Master List\n RejectCodeMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT rjctcode_code, rjctcode_descrip\n FROM rjctcode\nORDER BY rjctcode_code;\n \n \n 77\n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n 7\n \n \n 22\n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 17\n \n \n 10\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n rjctcode_code\n \n \n \n \n 175\n 0\n 565\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n rjctcode_descrip\n \n \n \n
\n \n 17\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 163 RejectedMaterialByVendor \N \n\n Rejected Material By Vendor\n RejectedMaterialByVendor\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT vend_number, vend_name,\n <? if exists("warehous_id") ?>\n (SELECT warehous_code\n FROM whsinfo\n WHERE warehous_id=<? value("warehous_id") ?>)\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("agentUsername") ?>\n TEXT(<? value("agentUsername" ?>)\n <? else ?>\n TEXT('All Agents')\n <? endif ?>\n AS agentUsername,\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate\n FROM vendinfo\n WHERE (vend_id=<? value("vend_id") ?>);\n \n \n detail\n SELECT poreject_id, poreject_ponumber, vend_name,\n formatDate(poreject_date) as f_date,\n poreject_vend_item_number as f_itemnum,\n poreject_vend_item_descrip as f_itemdescrip,\n formatQty(poreject_qty) as f_qty,\n rjctcode_code as f_rejectcode\nFROM poreject, vendinfo, itemsite, rjctcode\nWHERE ( (poreject_posted)\n AND (poreject_vend_id=vend_id)\n AND (poreject_rjctcode_id=rjctcode_id)\n AND (poreject_itemsite_id=itemsite_id)\n AND (vend_id=<? value("vend_id") ?>)\n AND (date(poreject_date) BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("agentUsername") ?>\n AND (poreject_agent_username=<? value("agentUsername") ?>)\n<? endif ?>\n )\nORDER BY poreject_date DESC;\n \n \n 236\n \n \n \n \n 95\n 135\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n \n 95\n 85\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n vend_name\n \n \n \n \n \n \n 95\n 65\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n vend_number\n \n \n \n \n \n \n \n \n 5\n 229\n 745\n 229\n 2\n \n \n \n 550\n 85\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n 95\n 155\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n agentUsername\n \n \n \n \n 550\n 65\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n 6\n \n \n 41\n \n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 36\n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_rejectcode\n \n \n \n \n 492\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qty\n \n \n \n \n 300\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_itemnum\n \n \n \n \n 60\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_name\n \n \n \n \n 5\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n poreject_ponumber\n \n \n \n \n 300\n 15\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_itemdescrip\n \n \n \n \n 215\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_date\n \n \n \n 5\n 30\n 745\n 30\n 0\n \n \n
\n \n 16\n \n \n 102\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 139 ReorderExceptionsByPlannerCode \N \n\n Reorder Exceptions by Planner Code\n ReorderExceptionsByPlannerCode\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("plancode_id") ?>\n ( SELECT (plancode_code || '-' || plancode_name)\n FROM plancode\n WHERE plancode_id=<? value("plancode_id") ?>)\n <? elseif exists("plancode_pattern") ?>\n text(<? value("plancode_pattern") ?>)\n <? else ?>\n text('All Planner Codes')\n <? endif ?>\n AS plannercode,\n <? if exists("includePlannedOrders") ?>\n formatBoolYN(true)\n <? else ?>\n formatBoolYN(false)\n <? endif ?>\n AS includeplnord,\n <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse;\n \n \n detail\n SELECT warehous_code, item_number, item_descrip1, item_descrip2,\n formatDate(reorderdate) AS f_reorderdate,\n formatQty(reorderlevel) AS f_reorderlevel,\n formatQty((qtyNetable(itemsite_id) - qtyAllocated(itemsite_id, reorderdate) + qtyOrdered(itemsite_id, reorderdate))) AS f_projavail,\n reorderdate \n FROM ( SELECT itemsite_id,\n CASE WHEN (item_type IN ('M', 'B', 'T')) THEN 1\n WHEN (item_type IN ('P', 'O')) THEN 2\n ELSE 3\n END AS itemtype,\n warehous_code, item_number, item_descrip1, item_descrip2,\n reorderDate(itemsite_id, <? value("lookAheadDays") ?>, <? if exists("includePlannedOrder") ?>true<? else ?>false<? endif ?>) AS reorderdate,\n reorderlevel \n FROM ( SELECT itemsite_id, itemsite_item_id, itemsite_warehous_id,\n CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel\n FROM itemsite \n WHERE ((true)\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("plancode_id") ?>\n AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n AND (itemsite_plancode_id IN (SELECT plancode_id\n FROM plancode\n WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? endif ?>\n )\n ) AS itemsitedate, item, whsinfo\n WHERE ((itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id))\n ) AS data \n WHERE (reorderdate IS NOT NULL) \nORDER BY reorderdate, item_number;\n \n \n 221\n \n \n \n \n \n \n \n \n 140\n 120\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n lookAheadDays\n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n \n 525\n 80\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n includeplnord\n \n \n \n \n 140\n 100\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n 140\n 80\n 385\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n plannercode\n \n \n \n \n \n \n \n 6\n \n \n 41\n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 51\n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 5\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 50\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 385\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_reorderdate\n \n \n \n \n 490\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_reorderlevel\n \n \n \n \n 595\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_projavail\n \n \n \n \n 50\n 0\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 50\n 15\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n
\n \n 16\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 105 ReportsMasterList \N \n\n Reports Master List\n ReportsMasterList\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n reports\n detail\n \n \n 76\n \n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n 6\n \n \n 21\n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 80\n 2\n 175\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n report_name\n \n \n \n \n 0\n 2\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n pkgname\n \n \n \n \n 265\n 2\n 475\n 15\n \n 1\n \n Arial\n 8\n bold\n \n \n \n \n detail\n report_descrip_qttooltiprole\n \n \n \n
\n \n 16\n \n \n 90\n 1\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 1\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 426 ReturnAuthorizationWorkbenchDueCredit \N \n\n Return Authorization Workbench Due Credit\n ReturnAuthorizationWorkbenchDueCredit\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT \n<? if exists("cust_id") ?>\n cust_number AS f_custtype\n FROM custinfo\n WHERE(cust_id=<? value("cust_id") ?>);\n<? elseif exists("custtype_id") ?>\n custtype_name AS f_custtype\n FROM custtype\n WHERE(custtype_id=<? value("custtype_id") ?>);\n<? elseif exists("custgrp_id") ?>\n custgrp_name AS f_custtype\n FROM custgrp\n WHERE(custgrp_id=<? value("custgrp_id") ?>);\n<? else ?>\n text('All Customer Types') AS f_custtype\n<? endif ?>\n \n \n detail\n SELECT DISTINCT rahead_id,\nCASE\n WHEN rahead_creditmethod = 'M' THEN\n 1\n WHEN rahead_creditmethod = 'K' THEN\n 2\n WHEN rahead_creditmethod = 'C' THEN\n 3\nEND,\nrahead_number, cust_name,\nformatDate(rahead_authdate) AS f_authdate, formatDate(NULL) AS f_eligibledate,\nformatMoney(currtobase(rahead_curr_id,\n calcradueamt(rahead_id), current_date)) AS f_amount,\nCASE\n WHEN rahead_creditmethod = 'M' THEN\n <? value("creditmemo") ?>\n WHEN rahead_creditmethod = 'K' THEN\n <? value("check") ?>\n WHEN rahead_creditmethod = 'C' THEN\n <? value("creditcard") ?>\nEND AS creditmethod, rahead_authdate\nFROM rahead, raitem, custtype, custinfo LEFT OUTER JOIN custgrpitem ON (cust_id=custgrpitem_cust_id)\nWHERE ( (rahead_id=raitem_rahead_id)\n AND (rahead_cust_id=cust_id)\n AND (cust_custtype_id=custtype_id)\n AND ((raitem_disposition = 'R' AND rahead_timing = 'R' AND raitem_qtyreceived > raitem_qtycredited)\n OR (raitem_disposition = 'R' AND rahead_timing = 'I' AND raitem_qtyauthorized > raitem_qtycredited)\n OR (raitem_disposition = 'C' AND raitem_qtyauthorized > raitem_qtycredited))\n AND (raitem_status = 'O')\n AND (rahead_creditmethod != 'N')\n AND (calcradueamt(rahead_id) > 0)\n AND (raitem_disposition IN ('C','R'))\n <? if exists("cust_id") ?>\n AND (cust_id=<? value("cust_id") ?>)\n <? elseif exists("custtype_id") ?>\n AND (custtype_id=<? value("custtype_id") ?>)\n <? elseif exists("custtype_pattern") ?>\n AND (custtype_pattern=<? value("custtype_pattern") ?>)\n <? elseif exists("custgrp_id") ?>\n AND (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n <? endif ?>\n AND (rahead_creditmethod IN ('$'\n <? if exists("doM") ?>, 'M'<? endif ?>\n <? if exists("doK") ?>, 'K'<? endif ?>\n <? if exists("doC") ?>, 'C'<? endif ?>\n ))\n ) \nORDER BY rahead_authdate,rahead_number;\n \n \n 223\n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n \n \n \n 185\n 80\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_custtype\n \n \n \n \n \n \n \n 6\n \n \n 28\n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 18\n \n \n 245\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_eligibledate\n \n \n \n \n 325\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_amount\n \n \n \n \n 410\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n creditmethod\n \n \n \n \n 5\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n rahead_number\n \n \n \n \n 90\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_name\n \n \n \n \n 170\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_authdate\n \n \n \n
\n \n 18\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 427 ReturnAuthorizationWorkbenchReview \N \n\n Return Authorization Workbench Review\n ReturnAuthorizationWorkbenchReview\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT \n<? if exists("cust_id") ?>\n (cust_number || '-' || cust_name) AS f_custtype\n FROM custinfo\n WHERE(cust_id=<? value("cust_id") ?>)\n<? elseif exists("custtype_id") ?>\n (custtype_code || '-' || custtype_descrip) AS f_custtype\n FROM custtype\n WHERE(custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\n (custgrp_name || '-' || custgrp_descrip) AS f_custtype\n FROM custgrp\n WHERE(custgrp_id=<? value("custgrp_id") ?>)\n<? else ?>\n text('All Customer Types') AS f_custtype\n<? endif ?>\n;\n \n \n detail\n SELECT * FROM (\nSELECT rahead_id, rahead_number, COALESCE(cust_name,text('Undefined')) AS custnumber,\nformatDate(rahead_authdate) AS f_authdate, COALESCE(formatDate(rahead_expiredate),text('Never')) AS f_expiredate,\nCASE\n WHEN raitem_disposition = 'C' THEN\n text('Credit')\n WHEN raitem_disposition = 'R' THEN\n text('Return')\n WHEN raitem_disposition = 'P' THEN\n text('Replace')\n WHEN raitem_disposition = 'V' THEN\n text('Service')\n WHEN raitem_disposition = 'S' THEN\n text('Shipment')\n END AS disposition,\nCASE\n WHEN rahead_creditmethod = 'N' THEN\n text('None')\n WHEN rahead_creditmethod = 'M' THEN\n text('Memo')\n WHEN rahead_creditmethod = 'K' THEN\n text('Check')\n WHEN rahead_creditmethod = 'C' THEN\n text('Card')\nEND AS creditmethod,\nCASE\n WHEN raitem_status = 'C' THEN\n text('Closed')\n WHEN raitem_disposition = 'C' THEN\n text('Payment')\n WHEN raitem_disposition = 'R'\n AND SUM(raitem_qtyauthorized-raitem_qtycredited) > 0\n AND SUM(raitem_qtyauthorized-raitem_qtyreceived) > 0 THEN\n text('Receipt') || ',' || text('Payment')\n WHEN raitem_disposition = 'R'\n AND SUM(raitem_qtyreceived-raitem_qtycredited) > 0 THEN\n text('Payment')\n WHEN raitem_disposition = 'R'\n AND SUM(raitem_qtyauthorized-raitem_qtyreceived) > 0 THEN\n text('Receipt')\n WHEN raitem_disposition IN ('P','V')\n AND SUM(raitem_qtyauthorized-COALESCE(coitem_qtyshipped,0)) > 0\n AND SUM(raitem_qtyauthorized-raitem_qtyreceived) > 0 THEN\n text('Receipt') || ',' || text('Shipment')\n WHEN raitem_disposition IN ('P','V')\n AND SUM(raitem_qtyauthorized-COALESCE(coitem_qtyshipped,0)) > 0 THEN\n text('Shipment')\n WHEN raitem_disposition IN ('P','V')\n AND SUM(raitem_qtyauthorized-raitem_qtyreceived) > 0 THEN\n text('Receipt')\n WHEN raitem_disposition = 'S' THEN\n text('Shipment')\n ELSE ''\nEND AS awaiting\nFROM rahead\n LEFT OUTER JOIN custinfo ON (rahead_cust_id=cust_id)\n LEFT OUTER JOIN custtype ON (cust_custtype_id=custtype_id)\n LEFT OUTER JOIN custgrpitem ON (custgrpitem_cust_id=cust_id), \n raitem\n LEFT OUTER JOIN coitem ON (raitem_new_coitem_id=coitem_id)\nWHERE ( (rahead_id=raitem_rahead_id)\n\n<? if exists("cust_id") ?>\n AND (cust_id=<? value("cust_id")?>)\n<? elseif exists("custtype_id") ?>\n AND (custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custgrp_id") ?>\n AND (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n AND (custtype_code ~ <? value("custtype_pattern") ?>)\n<? endif ?>\n\n<? if not exists("showExpired") ?>\n AND (COALESCE(rahead_expiredate,CURRENT_DATE) >= CURRENT_DATE)\n<? endif ?>\n<? if exists("showClosed") ?>\n AND (raitem_status='O' OR rahead_authdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? else ?>\n AND (raitem_status = 'O')\n<? endif ?>\n ) GROUP BY rahead_id,rahead_number,cust_name,rahead_expiredate,\n rahead_authdate,raitem_status,raitem_disposition,rahead_creditmethod,\n rahead_curr_id\n ORDER BY rahead_authdate,rahead_number\n) as data\n\nWHERE (FALSE)\n<? if exists("showReceipts") ?>\n OR ((disposition IN ('Return','Replace','Service'))\n AND (awaiting ~ 'Receipt'))\n<? endif ?>\n<? if exists("showShipments") ?>\n OR ((disposition IN ('Replace','Service','Shipment'))\n AND (awaiting ~ 'Shipment'))\n<? endif ?>\n<? if exists("showPayments") ?>\n OR ((disposition IN ('Credit','Return'))\n AND (awaiting ~ 'Payment'))\n<? endif ?>\n<? if exists("showClosed") ?>\n OR ((awaiting = 'Closed'))\n<? endif ?>\n\n \n \n 223\n \n \n \n \n \n \n 185\n 80\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_custtype\n \n \n \n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n 6\n \n \n 28\n \n \n \n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 18\n \n \n 5\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n rahead_number\n \n \n \n \n 170\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_authdate\n \n \n \n \n 245\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_expiredate\n \n \n \n \n 410\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n creditmethod\n \n \n \n \n 325\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n disposition\n \n \n \n \n 525\n 0\n 195\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n awaiting\n \n \n \n \n 90\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n custnumber\n \n \n \n
\n \n 18\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 137 RunningAvailability \N \n\n Running Availability\n RunningAvailability\n Updated in 2.3 to show order number and item code on higherlevel planned work orders.\n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n item_descrip1,\n item_descrip2,\n uom_name,\n warehous_code AS warehouse,\n <? if exists("showPlanned") ?>\n text('Yes')\n <? else ?>\n text('No')\n <? endif ?>\n AS showplnord\n FROM item, uom, whsinfo\n WHERE ((item_id=<? value("item_id") ?>)\n AND (item_inv_uom_id=uom_id)\n AND (warehous_id=<? value("warehous_id") ?>))\n \n \n detail\n runningAvailability\n detail\n \n \n info\n SELECT\n formatQty(qtyAvailable(itemsite_id)) AS qoh,\n formatQty(CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END) AS reorderlevel,\n formatQty(CASE WHEN(itemsite_useparams) THEN itemsite_ordertoqty ELSE 0.0 END) AS ordertoqty,\n formatQty(CASE WHEN(itemsite_useparams) THEN itemsite_multordqty ELSE 0.0 END) AS multorderqty \nFROM itemsite \nWHERE ((itemsite_item_id=<? value("item_id") ?>)\n AND (itemsite_warehous_id=<? value("warehous_id") ?>));\n \n \n 238\n \n \n \n \n 95\n 125\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n 95\n 75\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n 95\n 95\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n \n \n \n 595\n 145\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n info\n ordertoqty\n \n \n \n \n 365\n 125\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n info\n qoh\n \n \n \n \n \n \n 305\n 55\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n uom_name\n \n \n \n \n \n \n 595\n 125\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n info\n reorderlevel\n \n \n \n \n 595\n 75\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n showplnord\n \n \n \n 5\n 228\n 740\n 228\n 2\n \n \n \n 95\n 55\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n \n 365\n 145\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n info\n multorderqty\n \n \n \n \n \n \n \n \n \n \n 12\n \n \n 28\n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 22\n \n \n 90\n 0\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ordernumber\n \n \n \n \n 285\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_duedate\n \n \n \n \n 5\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ordertype\n \n \n \n \n 555\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_balance\n \n \n \n \n 385\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyordered\n \n \n \n \n 645\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n balance\n \n qty\n \n \n \n \n 467\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyreceived\n \n \n \n \n 150\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n
\n \n 22\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 102\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n Updated in 2.3 to show order number and item code on higherlevel planned work orders. 0 2015-10-01 17:15:58.47729 71 SalesAccountAssignmentsMasterList \N \n\n Sales Account Assignments Master List\n SalesAccountAssignmentsMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT salesaccnt_id,\n CASE WHEN salesaccnt_warehous_id=-1 THEN 'Any'::TEXT\n ELSE (SELECT warehous_code FROM whsinfo WHERE (warehous_id=salesaccnt_warehous_id))\n END AS warehouscode,\n CASE WHEN salesaccnt_custtype_id=-1 THEN salesaccnt_custtype\n ELSE (SELECT custtype_code FROM custtype WHERE (custtype_id=salesaccnt_custtype_id))\n END AS custtypecode,\n CASE WHEN salesaccnt_prodcat_id=-1 THEN salesaccnt_prodcat\n ELSE (SELECT prodcat_code FROM prodcat WHERE (prodcat_id=salesaccnt_prodcat_id))\n END AS prodcatcode,\n formatGLAccount(salesaccnt_sales_accnt_id) AS salesaccnt,\n formatGLAccount(salesaccnt_credit_accnt_id) AS creditaccnt,\n formatGLAccount(salesaccnt_cos_accnt_id) AS costaccnt,\n formatGLAccount(salesaccnt_returns_accnt_id) AS returnsaccnt,\n formatGLAccount(salesaccnt_cor_accnt_id) AS coraccnt,\n formatGLAccount(salesaccnt_cow_accnt_id) AS cowaccnt\n FROM salesaccnt\nORDER BY warehouscode, custtypecode, prodcatcode;\n \n \n 87\n \n 0\n 81\n 740\n 81\n 2\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 7\n \n \n 27\n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 17\n \n \n 230\n -1\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n salesaccnt\n \n \n \n \n 5\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehouscode\n \n \n \n \n 65\n -1\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n custtypecode\n \n \n \n \n 315\n -1\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n creditaccnt\n \n \n \n \n 150\n -1\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n prodcatcode\n \n \n \n \n 400\n -1\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n costaccnt\n \n \n \n \n 485\n -1\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n returnsaccnt\n \n \n \n \n 570\n -1\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n coraccnt\n \n \n \n \n 655\n -1\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cowaccnt\n \n \n \n
\n \n 17\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 422 SalesCategoriesMasterList \N \n\n Sales Categories Master List\n SalesCategoriesMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT salescat_id, salescat_name, salescat_descrip,\n formatGLAccount(salescat_sales_accnt_id) AS salesaccnt,\n formatGLAccount(salescat_prepaid_accnt_id) AS prepaidaccnt,\n formatGLAccount(salescat_ar_accnt_id) AS araccnt\n FROM salescat\nORDER BY salescat_name;\n \n \n 87\n \n 0\n 81\n 740\n 81\n 2\n \n \n \n \n \n \n \n \n \n \n 7\n \n \n 27\n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 17\n \n \n 230\n -1\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n salesaccnt\n \n \n \n \n 5\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n salescat_name\n \n \n \n \n 65\n -1\n 155\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n salescat_descrip\n \n \n \n \n 315\n -1\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n prepaidaccnt\n \n \n \n \n 400\n -1\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n araccnt\n \n \n \n
\n \n 17\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 447 SalesHistory \N \n\n Sales History\n SalesHistory\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n salesHistory\n detail\n \n \n head\n SELECT <? if exists("showPrices") ?>\n text('Unit Price') AS lbl_unitprice,\n text('Total') AS lbl_total\n <? else ?>\n text('') AS lbl_unitprice,\n text('') AS lbl_total\n <? endif ?>;\n \n \n 233\n \n \n \n 665\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_total\n \n \n \n \n \n \n \n \n \n 5\n 230\n 745\n 230\n 2\n \n \n \n 585\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_unitprice\n \n \n \n \n \n 15\n 48\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_total\n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n 585\n 0\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_unitprice\n \n \n \n \n
\n detail\n \n total\n \n \n 39\n \n \n 660\n 9\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n baseextprice\n \n money\n \n \n \n \n \n \n \n detail\n \n 51\n \n \n 355\n 15\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 5\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cohist_ordernumber\n \n \n \n \n 355\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 585\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_baseunitprice\n \n \n \n \n 270\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_orderdate\n \n \n \n \n 505\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyshipped\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 270\n 15\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_invcdate\n \n \n \n \n 355\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemnumber\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_baseextprice\n \n \n \n \n 110\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n invoicenumber\n \n \n \n
\n \n 16\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 103\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 60 SalesOrderStatus \N \n\n Sales Order Status\n SalesOrderStatus\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT \n --the following line was added for version 2.3:\n (select uom_name from uom where uom_id = coitem_qty_uom_id) AS uom_orderuom,\n coitem_linenumber,\n item_number, item_descrip1,\n item_descrip2,\n warehous_code,\n formatQty(coitem_qtyord) AS qtyord,\n formatQty(coitem_qtyshipped) AS qtyship,\n formatQty(coitem_qtyreturned) AS qtyret,\n formatQty(SUM(COALESCE(shipitem_qty, 0))) AS qtyinvcd,\n formatQty(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned)) AS f_balance,\n CASE WHEN (coitem_status='C') THEN\n ( formatDate(coitem_closedate) || ' (' || coitem_close_username || ')' )\n ELSE ''\n END AS f_dateuser,\n CASE WHEN (coitem_order_id=-1) THEN ''\n WHEN (coitem_order_type='W') THEN\n ( SELECT (formatWoNumber(wo_id) || '/' || wo_status)\n FROM wo\n WHERE (wo_id=coitem_order_id) )\n ELSE ''\n END AS f_childord\n FROM itemsite, item, whsinfo, coitem LEFT OUTER JOIN\n shipitem ON (shipitem_orderitem_id=coitem_id\n AND shipitem_invcitem_id IS NOT NULL) \n WHERE ((coitem_itemsite_id=itemsite_id)\n AND (coitem_status<>'X')\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (coitem_cohead_id=<? value("sohead_id") ?>)\n)\nGROUP BY uom_orderuom,\n coitem_id, coitem_linenumber, item_number,\n item_descrip1, item_descrip2, warehous_code,\n coitem_qtyord, coitem_qtyshipped, coitem_status,\n coitem_closedate, coitem_close_username,\n coitem_qtyreturned, coitem_order_id,\n coitem_order_type\nORDER BY coitem_linenumber;\n \n \n head\n SELECT cohead_number,\n formatDate(cohead_orderdate) AS orderdate,\n cohead_custponumber,\n cust_name, cntct_phone AS cust_phone\n FROM cohead, custinfo, cntct\n WHERE ((cohead_cust_id=cust_id)\n AND (cust_cntct_id=cntct_id)\n AND (cohead_id=<? value("sohead_id") ?>)\n);\n \n \n lastupdated\n SELECT formatDate(MAX(lastupdated)) AS f_lastupdated\n FROM (SELECT cohead_lastupdated AS lastupdated\n FROM cohead\n WHERE (cohead_id=:sohead_id)\n UNION\n SELECT coitem_lastupdated AS lastupdated\n FROM coitem\n WHERE (coitem_cohead_id=<? value("sohead_id") ?>) ) AS data;\n \n \n 224\n \n \n \n \n \n \n \n \n \n \n \n \n \n 112\n 95\n 220\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n orderdate\n \n \n \n \n 475\n 75\n 220\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_name\n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n \n 475\n 112\n 220\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cohead_custponumber\n \n \n \n \n \n \n 475\n 95\n 220\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_phone\n \n \n \n \n 475\n 135\n 220\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n lastupdated\n f_lastupdated\n \n \n \n \n 112\n 75\n 220\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cohead_number\n \n \n \n \n \n \n \n \n \n 7\n \n \n 37\n \n \n \n \n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 54\n \n \n 645\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_childord\n \n \n \n \n 550\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_dateuser\n \n \n \n \n 550\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_balance\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 5\n 0\n 25\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n coitem_linenumber\n \n \n \n \n 469\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyinvcd\n \n \n \n \n 35\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 229\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyord\n \n \n \n \n 170\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 390\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyret\n \n \n \n \n 35\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 310\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyship\n \n \n \n \n 35\n 15\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 200\n 0\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_orderuom\n \n \n \n
\n \n 20\n \n \n 715\n 0\n 30\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 80\n 0\n 140\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 72 SalesRepsMasterList \N \n\n Sales Reps Master List\n SalesRepsMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n select salesrep_number, salesrep_name,\n formatBoolYN(salesrep_active) AS f_active,\n formatScrap(salesrep_commission) AS f_commprcnt\n from salesrep\norder by salesrep_name;\n \n \n 76\n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 610\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_active\n \n \n \n \n 10\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n salesrep_number\n \n \n \n \n 115\n 0\n 490\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n salesrep_name\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_commprcnt\n \n \n \n
\n \n 16\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 478 SaleTypesMasterList \N \n\n Sale Types Master List\n SaleTypesMasterList\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n select *\n from saletype\norder by saletype_code;\n \n \n 76\n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n \n \n 6\n \n \n 21\n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 10\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n saletype_code\n \n \n \n \n 240\n 0\n 500\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n saletype_descr\n \n \n \n \n 180\n 2\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n saletype_active\n \n \n \n
\n \n 16\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 246 SelectedPaymentsList \N \n\n Selected Payments List\n SelectedPaymentsList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT apopen_id, apselect_id,\n (bankaccnt_name || '-' || bankaccnt_descrip) AS bankaccnt,\n (vend_number || '-' || vend_name) AS vendor,\n apopen_docnumber,\n apopen_ponumber,\n formatMoney(apselect_amount) AS f_selected\n FROM apselect, apopen, vendinfo, bankaccnt\n WHERE ((apopen_vend_id=vend_id)\n AND (apselect_apopen_id=apopen_id)\n AND (apselect_bankaccnt_id=bankaccnt_id)\n<? if exists("vend_id") ?>\n AND (vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n AND (vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n AND (vend_vendtype_id IN (SELECT vendtype_id\n FROM vendtype\n WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n<? endif ?>\n )\nORDER BY bankaccnt_name, vend_number, apopen_docnumber;\n \n \n 141\n \n \n \n \n \n \n 5\n 135\n 745\n 135\n 2\n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 575\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_selected\n \n \n \n \n 450\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n apopen_ponumber\n \n \n \n \n 10\n 0\n 225\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n bankaccnt\n \n \n \n \n 365\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n apopen_docnumber\n \n \n \n \n 240\n 0\n 120\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vendor\n \n \n \n
\n \n 16\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 75 ShipToMasterList \N \n\n Ship-To Master List\n ShipToMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT cust_number, cust_name\n FROM custinfo\nWHERE (cust_id=<? value("cust_id") ?>);\n \n \n \n detail\n SELECT shipto_num AS num,\n shipto_name AS name,\n addr_line1 AS address,\n (addr_city || ', ' || addr_state || ' ' || addr_postalcode) AS citystatezip\n FROM shiptoinfo\n LEFT OUTER JOIN addr ON (shipto_addr_id=addr_id)\n WHERE (shipto_cust_id=<? value("cust_id") ?>) \nORDER BY shipto_num;\n \n \n 171\n \n 5\n 165\n 745\n 165\n 2\n \n \n \n \n 135\n 70\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_number\n \n \n \n \n 135\n 90\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_name\n \n \n \n \n \n \n \n \n \n \n 6\n \n \n 21\n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 5\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n num\n \n \n \n \n 270\n 0\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n address\n \n \n \n \n 545\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n citystatezip\n \n \n \n \n 65\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n name\n \n \n \n
\n \n 16\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 105\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 218 ShipmentsByDate \N \n\n Shipments By Date\n ShipmentsByDate\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT formatDate(date(<? value("startDate") ?>)) AS startDate,\n formatDate(date(<? value("endDate") ?>)) AS endDate;\n\n \n \n detail\n SELECT shiphead_id, lineitem_id,\n CASE WHEN (level=0) THEN order_number\n ELSE item_number\n END AS order_item,\n CASE WHEN (level=0) THEN customer\n ELSE itemdescription\n END AS cust_desc,\n shiphead_order_type,\n shiphead_number, \n order_number, \n customer,\n shiphead_shipdate AS f_shipdate,\n shiphead_tracknum,\n shiphead_freight,\n freight_curr_abbr,\n linenumber,\n item_number,\n itemdescription,\n warehous_code,\n formatQty(qtyord) AS f_qtyord,\n formatQty(qtyshipped) AS f_qtyshipped\nFROM (\nSELECT shiphead_id, coitem_id AS lineitem_id, cohead_number AS sortkey1, shiphead_number AS sortkey2, 1 AS level,\n shiphead_order_type,\n shiphead_number,\n cohead_number AS order_number, \n (cust_number || '-' || cust_name) AS customer,\n shiphead_shipdate,\n shiphead_tracknum,\n shiphead_freight,\n currConcat(shiphead_freight_curr_id) AS freight_curr_abbr, \n coitem_linenumber AS linenumber, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n warehous_code,\n coitem_qtyord AS qtyord,\n SUM(shipitem_qty) AS qtyshipped\nFROM shipitem, shiphead, coitem, cohead, custinfo, itemsite, item, whsinfo\nWHERE ( (shipitem_shiphead_id=shiphead_id)\n AND (shipitem_orderitem_id=coitem_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (coitem_status <> 'X')\n AND (itemsite_item_id=item_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (shiphead_order_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n AND (shiphead_shipped)\n AND (shiphead_order_type='SO')\n<? if exists("startDate") ?>\n AND (shiphead_shipdate BETWEEN <? value("startDate") ?> and <? value("endDate") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id = <? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("sohead_id") ?>\n AND (cohead_id = <? value("sohead_id") ?>)\n<? endif ?>\n<? if exists("shiphead_id") ?>\n AND (shiphead_id = <? value("shiphead_id") ?>)\n<? endif ?>\n ) \nGROUP BY shiphead_id, coitem_id, shiphead_order_type, shiphead_number,\n cohead_number, cust_number, cust_name, shiphead_shipdate,\n coitem_linenumber, item_number, item_descrip1, item_descrip2,\n warehous_code, shiphead_tracknum, coitem_qtyord, \n shiphead_freight, shiphead_freight_curr_id \n<? if exists("MultiWhs") ?>\nUNION\nSELECT shiphead_id, toitem_id AS lineitem_id, tohead_number AS sortkey1, shiphead_number AS sortkey2, 1 AS level,\n shiphead_order_type,\n shiphead_number,\n tohead_number AS order_number, \n tohead_destname AS customer,\n shiphead_shipdate,\n shiphead_tracknum,\n shiphead_freight,\n currConcat(shiphead_freight_curr_id) AS freight_curr_abbr, \n toitem_linenumber AS linenumber, item_number,\n (item_descrip1 || ' ' || item_descrip2) AS itemdescription,\n tohead_srcname AS warehous_code,\n toitem_qty_ordered AS qtyord,\n SUM(shipitem_qty) AS qtyshipped\nFROM shipitem, shiphead, toitem, tohead, item \nWHERE ( (shipitem_shiphead_id=shiphead_id)\n AND (shipitem_orderitem_id=toitem_id)\n AND (toitem_status <> 'X')\n AND (toitem_item_id=item_id)\n AND (shiphead_order_id=tohead_id)\n AND (shiphead_shipped)\n AND (shiphead_order_type='TO')\n<? if exists("startDate") ?>\n AND (shiphead_shipdate BETWEEN <? value("startDate") ?> and <? value("endDate") ?>)\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (tohead_src_warehous_id = <? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("tohead_id") ?>\n AND (tohead_id = <? value("tohead_id") ?>)\n<? endif ?>\n<? if exists("shiphead_id") ?>\n AND (shiphead_id = <? value("shiphead_id") ?>)\n<? endif ?>\n ) \nGROUP BY shiphead_id, toitem_id, shiphead_order_type, shiphead_number,\n tohead_number, tohead_destname, shiphead_shipdate,\n toitem_linenumber, item_number, item_descrip1, item_descrip2,\n tohead_srcname, shiphead_tracknum, toitem_qty_ordered, \n shiphead_freight, shiphead_freight_curr_id \n<? endif ?>\n ) AS data\nORDER BY sortkey1, sortkey2, level, linenumber DESC;\n\n \n \n 221\n \n \n \n \n \n \n \n \n 140\n 70\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n \n 140\n 90\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n \n 5\n \n \n 41\n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n \n \n \n
\n detail\n \n cohead_number\n order_number\n \n 45\n \n \n 85\n 40\n 745\n 40\n 2\n \n \n \n \n 114\n 5\n 140\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n order_number\n \n \n \n \n 114\n 20\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n customer\n \n \n \n \n \n \n detail\n \n 33\n \n \n 240\n 0\n 140\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 520\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyord\n \n \n \n 5\n 28\n 745\n 28\n 0\n \n \n \n 5\n 0\n 95\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shiphead_number\n \n \n \n \n 600\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyshipped\n \n \n \n \n 185\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n linenumber\n \n \n \n \n 105\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_shipdate\n \n \n \n \n 440\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 240\n 15\n 455\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemdescription\n \n \n \n
\n \n 15\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 219 ShipmentsBySalesOrder \N \n\n Shipments By Sales Order\n ShipmentsBySalesOrder\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT cohead_number AS f_sonumber,\n formatDate(cohead_orderdate) AS f_orderdate,\n cohead_custponumber AS f_ponumber,\n cust_name AS f_custname,\n cntct_phone AS f_custphone\nFROM cohead, custinfo, cntct\nWHERE ((cohead_cust_id=cust_id)\n AND (cust_cntct_id=cntct_id)\n AND (cohead_id=<? value("sohead_id") ?>));\n \n \n detail\n SELECT shiphead_id,\n coitem_id,\n formatShipmentNumber(shiphead_id) AS shiphead_number,\n formatDate(shiphead_shipdate) AS f_shipdate,\n coitem_linenumber,\n item_number,\n item_descrip1,\n item_descrip2,\n uom_name,\n warehous_code,\n formatQty(coitem_qtyord) AS f_qtyord,\n formatQty(SUM(shipitem_qty)) AS f_qtyshipped\n FROM shipitem, shiphead, coitem, itemsite, item, uom, whsinfo\n WHERE ( (shipitem_shiphead_id=shiphead_id)\n AND (shiphead_order_type='SO')\n AND (shipitem_orderitem_id=coitem_id)\n AND (shiphead_shipped)\n AND (coitem_itemsite_id=itemsite_id)\n AND (coitem_status<>'X')\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (coitem_cohead_id=<? value("sohead_id") ?>)\n)\nGROUP BY shiphead_id, coitem_id,\n shiphead_shipdate, coitem_linenumber,\n item_number, item_descrip1, item_descrip2,\n uom_name, warehous_code, coitem_qtyord\nORDER BY shiphead_id DESC, coitem_linenumber DESC;\n \n \n 221\n \n \n \n \n \n 140\n 90\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_orderdate\n \n \n \n \n 140\n 155\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_ponumber\n \n \n \n \n \n \n \n \n 140\n 135\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_custphone\n \n \n \n \n 140\n 114\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_custname\n \n \n \n \n \n \n \n \n 140\n 70\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_sonumber\n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n \n \n \n 5\n \n \n 41\n \n \n \n \n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 51\n \n \n 240\n 15\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 185\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n coitem_linenumber\n \n \n \n \n 520\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyord\n \n \n \n \n 105\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_shipdate\n \n \n \n \n 5\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shiphead_number\n \n \n \n \n 600\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyshipped\n \n \n \n \n 240\n 30\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 385\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n \n 240\n 0\n 140\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 440\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n
\n \n 15\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 423 ShipmentsByShipment \N \n\n Shipments By Shipment\n ShipmentsByShipment\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT shiphead_number AS f_shipnumber,\n shiphead_tracknum AS f_tracknum,\n formatMoney(shiphead_freight) AS freight,\n ordernumber AS f_sonumber,\n formatDate(orderdate) AS f_orderdate,\n custponumber AS f_ponumber,\n cust_name AS f_custname,\n cntct_phone AS f_custphone\n FROM custinfo JOIN cntct ON (cust_cntct_id=cntct_id), (SELECT shiphead_number,\n shiphead_tracknum,\n shiphead_freight,\n cohead_number AS ordernumber,\n cohead_cust_id AS order_cust_id,\n cohead_orderdate AS orderdate,\n cohead_custponumber AS custponumber\n FROM cohead JOIN shiphead ON (shiphead_order_id=cohead_id AND shiphead_order_type='SO')\n WHERE(shiphead_id=<? value("shiphead_id") ?>)\n UNION\n SELECT shiphead_number,\n shiphead_tracknum,\n shiphead_freight,\n tohead_number AS ordernumber,\n NULL AS order_cust_id,\n tohead_orderdate AS orderdate,\n NULL AS custponumber\n FROM tohead JOIN shiphead ON (shiphead_order_id=tohead_id AND shiphead_order_type='TO')\n WHERE(shiphead_id=<? value("shiphead_id") ?>) \n ) AS taborder\n WHERE(order_cust_id=cust_id);\n\n \n \n detail\n shipments\n detail\n \n \n 221\n \n \n \n \n \n 140\n 90\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_orderdate\n \n \n \n \n 140\n 155\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_ponumber\n \n \n \n \n \n \n \n \n 140\n 135\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_custphone\n \n \n \n \n 140\n 114\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_custname\n \n \n \n \n \n \n \n 140\n 70\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_sonumber\n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n \n \n 140\n 49\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_shipnumber\n \n \n \n \n \n 540\n 129\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_tracknum\n \n \n \n \n 540\n 149\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_freight\n \n \n \n \n \n \n \n 5\n \n \n 41\n \n \n \n \n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 38\n \n \n 240\n 15\n 480\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_description\n \n \n \n \n 185\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n linenumber\n \n \n \n \n 520\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyord\n \n \n \n \n 105\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_shipdate\n \n \n \n \n 5\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shiphead_number\n \n \n \n \n 600\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyshipped\n \n \n \n \n 240\n 0\n 140\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 440\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n 5\n 33\n 745\n 33\n 0\n \n \n
\n \n 15\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 416 ShipmentsPending \N \n\n Shipments Pending\n ShipmentsPending\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse;\n\n \n \n detail\n maintainShipping\n detail\n \n \n 221\n \n \n \n \n \n \n \n \n 140\n 70\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n \n \n \n 5\n \n \n 41\n \n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 33\n \n \n 240\n 0\n 140\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n dest\n \n \n \n \n 520\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_shipqty\n \n \n \n 5\n 28\n 745\n 28\n 0\n \n \n \n 5\n 0\n 95\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shiphead_number\n \n \n \n \n 600\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_shipvalue\n \n \n \n \n 160\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n linenumber\n \n \n \n \n 105\n 0\n 45\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ordertype\n \n \n \n \n 390\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shiphead_shipvia\n \n \n \n \n 240\n 13\n 455\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n description\n \n \n \n \n 480\n 0\n 30\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n
\n \n 15\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 100\n \n \n 600\n 10\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shipvalue\n \n cost\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 266 ShippingLabelsByInvoice \N \n\n Shipping Labels By Invoice\n ShippingLabelsByInvoice\n \n Avery 5263\n Labels\n \n 100\n 100\n 100\n 100\n \n detail\n SELECT sequence_value,\n invchead_invcnumber,\n cust_number,\n invchead_ordernumber,\n invchead_ponumber,\n invchead_shipto_name,\n invchead_shipto_address1,\n invchead_shipto_address2,\n invchead_shipto_address3,\n (COALESCE(invchead_shipto_city,'') || ' ' || COALESCE(invchead_shipto_state,'') || ' ' || COALESCE(invchead_shipto_zipcode,'')) AS citystatezip\n FROM invchead, custinfo, sequence\n WHERE ( (invchead_cust_id=cust_id)\n AND (sequence_value BETWEEN <? value("labelFrom") ?> AND <? value("labelTo") ?>)\n AND (invchead_id=<? value("invchead_id") ?>) );\n \n \n
\n detail\n \n \n detail\n \n 201\n \n \n 100\n 125\n 155\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n cust_number\n \n \n \n \n \n \n \n 100\n 140\n 155\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n invchead_invcnumber\n \n \n \n \n 285\n 180\n 36\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n sequence_value\n \n \n \n \n 30\n 85\n 285\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n citystatezip\n \n \n \n \n 30\n 40\n 285\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n invchead_shipto_address1\n \n \n \n \n 340\n 180\n 36\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n Parameter Query\n labelTo\n \n \n \n \n \n 30\n 25\n 285\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n invchead_shipto_name\n \n \n \n \n 30\n 70\n 285\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n invchead_shipto_address3\n \n \n \n \n 30\n 55\n 285\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n invchead_shipto_address2\n \n \n \n \n 100\n 155\n 155\n 17\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n invchead_ponumber\n \n \n \n
\n
\n 0 2015-10-01 17:15:58.47729 267 ShippingLabelsBySo \N \n\n Shippinig Labels By S/O\n ShippingLabelsBySo\n \n Letter\n \n 100\n 100\n 100\n 100\n \n detail\n SELECT sequence_value,\n cust_number,\n cohead_number,\n\nformataddr(cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3, (cohead_shiptocity || ' ' || cohead_shiptostate || ' ' || cohead_shiptozipcode), cohead_shiptocountry) AS shipping_address, \n\n\n cohead_custponumber,\n cohead_shiptoname,\n cohead_shiptoaddress1,\n cohead_shiptoaddress2,\n cohead_shiptoaddress3,\n (COALESCE(cohead_shiptocity,'') || ' ' || COALESCE(cohead_shiptostate,'') || ' ' || COALESCE(cohead_shiptozipcode,'')) AS citystatezip\nFROM cohead\n<? if exists("soitem_id") ?>\n JOIN coitem ON cohead_id = coitem_cohead_id\n<? endif ?>,\n custinfo, sequence\nWHERE ( (cohead_cust_id=cust_id)\n<? if exists("labelFrom") ?>\n AND (sequence_value BETWEEN <? value("labelFrom") ?> AND <? value("labelTo") ?>)\n<? endif ?>\n AND (cohead_id=<? value("sohead_id") ?>)\n<? if exists("soitem_id") ?>\n AND (coitem_id = <? value("soitem_id") ?>)\n<? endif ?>\n)\nLIMIT <? value("labelTo") ?>;\n \n \n
\n detail\n \n \n detail\n \n 494\n \n \n \n 725\n 9\n 155\n 16\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n cust_number\n \n \n \n \n 800\n 445\n 36\n 16\n \n \n Arial\n 10\n normal\n \n \n \n \n Parameter Query\n labelTo\n \n \n \n \n 15\n 119\n 880\n 55\n \n 0\n \n Arial\n 36\n bold\n \n \n \n \n detail\n shipping_address\n \n \n \n \n 9\n 65\n 884\n 50\n \n \n Arial\n 36\n bold\n \n \n \n \n detail\n cohead_shiptoname\n \n \n \n \n 725\n 40\n 155\n 16\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n cohead_custponumber\n \n \n \n \n \n 725\n 25\n 155\n 16\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n cohead_number\n \n \n \n \n 735\n 445\n 36\n 16\n \n \n Arial\n 10\n normal\n \n \n \n \n detail\n sequence_value\n \n \n \n \n \n
\n
\n 0 2015-10-01 17:15:58.47729 73 ShippingZonesMasterList \N \n\n Shipping Zones Master List\n ShippingZonesMasterList\n \n \n 850\n 1100\n \n \n 50\n 50\n 50\n 50\n \n detail\n select shipzone_name, shipzone_descrip\n from shipzone\norder by shipzone_name;\n \n \n 76\n \n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n 6\n \n \n 21\n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 10\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shipzone_name\n \n \n \n \n 175\n 0\n 565\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shipzone_descrip\n \n \n \n
\n \n 16\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 424 SiteTypesMasterList \N \n\n Site Types Master List\n SiteTypesMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n select sitetype_name, sitetype_descrip\n from sitetype\norder by sitetype_name;\n \n \n 76\n \n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n 6\n \n \n 21\n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 10\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n sitetype_name\n \n \n \n \n 175\n 0\n 565\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n sitetype_descrip\n \n \n \n
\n \n 16\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 248 StandardJournalGroupMasterList \N \n\n Standard Journal Group Master List\n StandardJournalGroupMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT stdjrnlgrp_id,\n stdjrnlgrp_name,\n stdjrnlgrp_descrip\n FROM stdjrnlgrp\nORDER BY stdjrnlgrp_name;\n \n \n 77\n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n 7\n \n \n 22\n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n
\n detail\n \n \n detail\n \n 17\n \n \n 220\n 0\n 500\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n stdjrnlgrp_descrip\n \n \n \n \n 10\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n stdjrnlgrp_name\n \n \n \n
\n \n 17\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 282 StandardJournalHistory \N \n\n Standard Journal History\n StandardJournalHistory\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate,\n <? if exists("source") ?>\n text(<? value("source") ?>)\n <? else ?>\n text('All Sources')\n <? endif ?>\n AS source,\n <? if exists("startJrnlnum") ?>\n text('Start Journal Number:')\n <? else ?>\n text('')\n <? endif ?>\n AS startJrnlnumLit,\n <? if exists("endJrnlnum") ?>\n text('End Journal Number:')\n <? else ?>\n text('')\n <? endif ?>\n AS endJrnlnumLit;\n \n \n detail\n SELECT formatDate(gltrans_date) AS transdate,\n gltrans_journalnumber,\n gltrans_docnumber,\n (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n CASE WHEN (gltrans_amount < 0) THEN formatMoney(gltrans_amount * -1)\n ELSE ''\n END AS f_debit,\n CASE WHEN (gltrans_amount > 0) THEN formatMoney(gltrans_amount)\n ELSE ''\n END AS f_credit,\n formatBoolYN(gltrans_posted) AS f_posted\n FROM gltrans, accnt\n WHERE ( (gltrans_accnt_id=accnt_id)\n AND (NOT gltrans_deleted)\n AND (gltrans_date BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n AND (gltrans_doctype='ST') )\nORDER BY gltrans_date, gltrans_sequence, gltrans_docnumber, gltrans_amount;\n \n \n 162\n \n \n \n \n 200\n 65\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n \n 200\n 85\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n \n 5\n 155\n 745\n 155\n 2\n \n \n \n \n \n \n \n 6\n \n \n 21\n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n \n \n \n
\n detail\n \n JournalSeries\n gltrans_journalnumber\n \n 16\n \n \n 680\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_posted\n \n \n \n \n 10\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n transdate\n \n \n \n \n 100\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_journalnumber\n \n \n \n \n \n JournalName\n gltrans_docnumber\n \n 16\n \n \n 190\n 0\n 130\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_docnumber\n \n \n \n \n \n \n detail\n \n 17\n \n \n 595\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_credit\n \n \n \n \n 330\n 0\n 175\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n account\n \n \n \n \n 509\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_debit\n \n \n \n
\n \n 18\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 249 StandardJournalMasterList \N \n\n Standard Journal Master List\n StandardJournalMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT stdjrnl_id,\n stdjrnl_name,\n stdjrnl_descrip\n FROM stdjrnl\nORDER BY stdjrnl_name;\n \n \n 76\n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n 6\n \n \n 21\n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 220\n 0\n 500\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n stdjrnl_descrip\n \n \n \n \n 10\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n stdjrnl_name\n \n \n \n
\n \n 16\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 261 Statement \N \n\n Statement\n Statement\n "As of" date included\n \n \n \n 0.05\n 0.05\n \n Letter\n \n 100\n 100\n 100\n 100\n \n detail\n SELECT CASE WHEN (araging_doctype = 'I') THEN <? value("invoice") ?>\n WHEN (araging_doctype = 'D') THEN <? value("debit") ?>\n WHEN (araging_doctype = 'C') THEN <? value("credit") ?>\n WHEN (araging_doctype = 'R') THEN <? value("deposit") ?>\n ELSE 'Misc.'\n END AS doctype,\n araging_docnumber AS f_docnumber,\n formatDate(CAST(araging_docdate AS DATE)) AS f_docdate,\n CASE WHEN (araging_doctype IN ('I','C','D')) THEN formatDate(araging_duedate)\n ELSE ''\n END AS f_duedate,\n formatMoney(araging_aropen_amount) AS f_amount,\n formatMoney(araging_aropen_amount - araging_total_val) AS f_applied,\n formatMoney(araging_total_val) AS f_balance\nFROM araging(<? value("asofdate") ?>, true, false)\nWHERE ((araging_cust_id = <? value("cust_id") ?>)\n AND (abs(araging_aropen_amount) > 0)\n )\nORDER BY araging_duedate;\n \n \n head\n SELECT cust_name, addr_line1 AS cust_address1, addr_line2 AS cust_address2, addr_line3 AS cust_address3,\n (addr_city || ' ' || addr_state || ' ' || addr_postalcode) AS citystatezip,\n formatDate(COALESCE(<? value("asofdate") ?>, current_date)) AS asofdate\nFROM custinfo\nLEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)\nLEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)\nWHERE (cust_id = <? value("cust_id") ?>);\n \n \n Currency\n SELECT currconcat(cust_curr_id) AS currAbbr\n FROM custinfo\n WHERE (cust_id=<? value("cust_id") ?>)\n\n \n \n foot\n SELECT formatMoney(SUM(araging_cur_val)) AS f_current,\n formatMoney(SUM(araging_thirty_val)) AS f_thirty,\n formatMoney(SUM(araging_sixty_val)) AS f_sixty,\n formatMoney(SUM(araging_ninety_val)) AS f_ninety,\n formatMoney(SUM(araging_plus_val)) AS f_plus,\n formatMoney(SUM(araging_total_val)) AS f_total\nFROM araging(<? value("asofdate") ?>, true, false)\nWHERE ((abs(araging_aropen_amount) > 0)\n AND (araging_cust_id = <? value("cust_id") ?>));\n \n \n 277\n \n 475\n 245\n 475\n 270\n 0\n \n \n \n 25\n 190\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n citystatezip\n \n \n \n \n \n 10\n 245\n 10\n 270\n 0\n \n \n \n \n 445\n 40\n 445\n 75\n 0\n \n \n \n 395\n 245\n 395\n 270\n 0\n \n \n 445\n 75\n 585\n 75\n 0\n \n \n 310\n 245\n 310\n 270\n 0\n \n \n 123.972\n 244.219\n 123.972\n 269.461\n 0\n \n \n \n \n 25\n 150\n 300\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_address1\n \n \n \n \n 25\n 165\n 300\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_address2\n \n \n \n \n 10\n 244.541\n 640\n 244.541\n 0\n \n \n \n 25\n 135\n 300\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_name\n \n \n \n 210\n 245.459\n 210\n 270.459\n 0\n \n \n \n 475\n 60\n 90\n 15\n \n \n Arial\n 12\n normal\n \n \n \n \n Context Query\n report_date\n \n \n \n 640\n 245\n 640\n 270\n 0\n \n \n \n 25\n 180\n 300\n 15\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n cust_address3\n \n \n \n \n 545\n 245\n 545\n 270\n 0\n \n \n \n 585\n 40\n 585\n 75\n 0\n \n \n 445\n 40\n 585\n 40\n 0\n \n \n 10\n 270\n 640\n 270\n 0\n \n \n 445\n 55\n 585\n 55\n 0\n \n \n \n \n 105\n 50\n 100\n 15\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n asofdate\n \n \n \n
\n detail\n \n unnamed\n \n \n \n \n detail\n \n 16\n \n \n 20\n 0\n 100\n 15\n \n \n Arial\n 12\n normal\n \n \n \n \n detail\n doctype\n \n \n \n \n 395\n 0\n 80\n 15\n \n \n Arial\n 11\n normal\n \n \n \n \n detail\n f_amount\n \n \n \n \n 130\n 0\n 75\n 15\n \n \n Arial\n 11\n normal\n \n \n \n \n detail\n f_docnumber\n \n \n \n \n 480\n 0\n 75\n 15\n \n \n Arial\n 11\n normal\n \n \n \n \n detail\n f_applied\n \n \n \n \n 315\n 0\n 75\n 15\n \n \n Arial\n 11\n normal\n \n \n \n \n detail\n f_duedate\n \n \n \n \n 215\n 0\n 90\n 15\n \n \n Arial\n 11\n normal\n \n \n \n \n detail\n f_docdate\n \n \n \n \n 560\n 0\n 80\n 15\n \n \n Arial\n 11\n normal\n \n \n \n \n detail\n f_balance\n \n \n \n
\n \n \n 111\n \n 190\n 5\n 190\n 35\n 0\n \n \n 10\n 5\n 10\n 35\n 0\n \n \n \n 100\n 5\n 100\n 35\n 0\n \n \n 365\n 5\n 365\n 35\n 0\n \n \n \n \n \n 190\n 15\n 85\n 20\n \n \n Arial\n 11\n normal\n \n \n \n \n foot\n f_sixty\n \n \n \n \n 365\n 15\n 85\n 20\n \n \n Arial\n 11\n normal\n \n \n \n \n foot\n f_plus\n \n \n \n \n 100\n 15\n 85\n 20\n \n \n Arial\n 11\n normal\n \n \n \n \n foot\n f_thirty\n \n \n \n 10\n 35\n 640\n 35\n 0\n \n \n \n 10\n 15\n 85\n 20\n \n \n Arial\n 11\n normal\n \n \n \n \n foot\n f_current\n \n \n \n 640\n 5\n 640\n 35\n 0\n \n \n \n \n 280\n 5\n 280\n 35\n 0\n \n \n \n \n \n 280\n 15\n 80\n 20\n \n \n Arial\n 11\n normal\n \n \n \n \n foot\n f_ninety\n \n \n \n 455\n 5\n 455\n 35\n 0\n \n \n \n 100\n 45\n 67\n 15\n \n \n Arial\n 11\n normal\n \n \n \n \n Currency\n currAbbr\n \n \n \n 10\n 5\n 640\n 5\n 0\n \n \n \n 544\n 15\n 85\n 20\n \n \n Arial\n 11\n normal\n \n \n \n \n foot\n f_total\n \n \n \n
\n "As of" date included 0 2015-10-01 17:15:58.47729 274 SubAccountTypeMasterList \N \n\n Subaccount Type Master List\n SubAccountTypeMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT subaccnttype_code, subaccnttype_descrip,\n CASE WHEN(subaccnttype_accnt_type='A') THEN text('Asset')\n WHEN(subaccnttype_accnt_type='L') THEN text('Liability')\n WHEN(subaccnttype_accnt_type='E') THEN text('Expense')\n WHEN(subaccnttype_accnt_type='R') THEN text('Revenue')\n WHEN(subaccnttype_accnt_type='Q') THEN text('Equity')\n ELSE text('ERROR')\n END AS f_type\n FROM subaccnttype\nORDER BY subaccnttype_code;\n \n \n 76\n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n 6\n \n \n 21\n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 240\n 0\n 500\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n subaccnttype_descrip\n \n \n \n \n 120\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_type\n \n \n \n \n 10\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n subaccnttype_code\n \n \n \n
\n \n 16\n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 19 SubstituteAvailabilityByRootItem \N \n\n Substitue Availability By Root Item\n SubstituteAvailabilityByRootItem\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n item_descrip1,\n item_descrip2,\n <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse\n FROM item\n WHERE (item_id=<? value("item_id") ?>);\n \n \n detail\n SELECT warehous_code,\n item_number,\n item_descrip1,\n item_descrip2,\n formatQty(qtyAvailable(sub.itemsite_id)) AS f_qtyonhand,\n formatQty(CASE WHEN(sub.itemsite_useparams) THEN sub.itemsite_reorderlevel ELSE 0.0 END) AS f_reorderlevel,\n sub.itemsite_leadtime as leadtime,\n<? if exists("byDays") ?>\n formatQty(qtyAllocated(sub.itemsite_id, <? value("byDays") ?>)) AS f_allocated,\n formatQty(qtyOrdered(sub.itemsite_id, <? value("byDays") ?>)) AS f_ordered,\n formatQty(qtyAvailable(sub.itemsite_id) + qtyOrdered(sub.itemsite_id, <? value("byDays") ?>) - qtyAllocated(sub.itemsite_id, <? value("byDays") ?>)) as f_avail\n<? elseif exists("byDate") ?>\n formatQty(qtyAllocated(sub.itemsite_id, (<? value("byDate") ?> - CURRENT_DATE))) AS f_allocated,\n formatQty(qtyOrdered(sub.itemsite_id, (<? value("byDate") ?> - CURRENT_DATE))) AS f_ordered,\n formatQty(qtyAvailable(sub.itemsite_id) + qtyOrdered(sub.itemsite_id, (<? value("byDate") ?> - CURRENT_DATE)) - qtyAllocated(sub.itemsite_id, (<? value("byDate") ?> - CURRENT_DATE))) as f_avail\n<? else ?>\n formatQty(qtyAllocated(sub.itemsite_id, sub.itemsite_leadtime)) AS f_allocated,\n formatQty(qtyOrdered(sub.itemsite_id, sub.itemsite_leadtime)) AS f_ordered,\n formatQty(qtyAvailable(sub.itemsite_id) + qtyOrdered(sub.itemsite_id, sub.itemsite_leadtime) - qtyAllocated(sub.itemsite_id, sub.itemsite_leadtime)) as f_avail\n<? endif ?>\n FROM item, itemsite AS sub, itemsite AS root, whsinfo, itemsub\n WHERE ((sub.itemsite_item_id=item_id)\n AND (root.itemsite_item_id=itemsub_parent_item_id)\n AND (sub.itemsite_item_id=itemsub_sub_item_id)\n AND (root.itemsite_warehous_id=sub.itemsite_warehous_id)\n AND (sub.itemsite_warehous_id=warehous_id)\n AND (root.itemsite_item_id=<? value("item_id") ?>)\n<? if exists("warehous_id") ?>\n AND (root.itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n)\nORDER BY itemsub_rank;\n \n \n 221\n \n \n 140\n 140\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n \n 140\n 100\n 385\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n 140\n 120\n 385\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n 140\n 80\n 385\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n \n \n \n \n \n \n \n 6\n \n \n 41\n \n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 56\n \n \n 65\n 30\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 65\n 15\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 10\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 330\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qtyonhand\n \n \n \n \n 10\n 15\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n leadtime\n \n \n \n \n 645\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_avail\n \n \n \n \n 540\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ordered\n \n \n \n \n 540\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_reorderlevel\n \n \n \n \n 434\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_allocated\n \n \n \n \n 65\n 0\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n 5\n 50\n 745\n 50\n 0\n \n \n
\n \n 16\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 220 SummarizedBOM \N \n\n Summarized Bill of Materials\n SummarizedBOM\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n uom_name AS item_invuom,\n item_descrip1,\n item_descrip2\n FROM item, uom\n WHERE ((item_id=<? value("item_id") ?>)\n AND (item_inv_uom_id=uom_id));\n \n \n \n detail\n select bomdata_item_number AS item_number,\n bomdata_uom_name AS item_invuom,\n bomdata_item_descrip1 AS item_descrip1,\n bomdata_item_descrip2 AS item_descrip2,\n formatQtyPer(bomdata_qtyreq) AS qtyreq\n FROM summarizedBOM(<? value("item_id") ?>,<? value("revision_id") ?>,<? value("expiredDays") ?>,<? value("futureDays") ?>)\n\n\n \n \n bomhead\n SELECT bomhead_docnum, bomhead_revision,\nformatDate(bomhead_revisiondate) AS f_revisiondate\nFROM bomhead\nWHERE ((bomhead_item_id=<? value("item_id") ?>)\nAND (bomhead_rev_id=<? value("revision_id") ?>));\n \n \n 242\n \n \n 315\n 103\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_invuom\n \n \n \n \n 585\n 103\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n bomhead_docnum\n \n \n \n \n \n \n 100\n 145\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n 5\n 235\n 745\n 235\n 2\n \n \n \n \n 100\n 103\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n 100\n 125\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n \n \n \n \n \n \n 585\n 145\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n bomhead_revision\n \n \n \n \n \n 585\n 125\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n bomhead\n f_revisiondate\n \n \n \n \n \n 6\n \n \n 36\n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n
\n detail\n \n \n detail\n \n 52\n \n \n 112\n 15\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 112\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 112\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n \n 275\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_invuom\n \n \n \n \n 425\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyreq\n \n \n \n
\n \n 17\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 65 SummarizedBacklogByWarehouse \N \n\n Summarized Backlog By Site\n SummarizedBacklogByWarehouse\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("custtype_id") ?>\n ( SELECT (custtype_code||'-'||custtype_descrip)\n FROM custtype\n WHERE (custtype_id=<? value("custtype_id") ?>) )\n <? elseif exists("custtype_pattern") ?>\n text(<? value("custtype_pattern") ?>)\n <? else ?>\n text('All Customer Types')\n <? endif ?>\n AS custtype,\n <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("showPrices") ?>\n text('Sales') AS lbl_sales,\n text('Cost') AS lbl_cost,\n text('Margin') AS lbl_margin,\n text('Totals:') AS lbl_totals,\n <? else ?>\n text('') AS lbl_sales,\n text('') AS lbl_cost,\n text('') AS lbl_margin,\n text('') AS lbl_totals,\n <? endif ?>\n formatDate(<? value("startDate") ?>, 'Earliest') AS startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS enddate;\n \n \n detail\n SELECT CASE WHEN (cohead_holdtype='P') THEN -1\n ELSE cohead_id\n END AS _coheadid, cohead_id,\n cohead_holdtype, cohead_number, cust_name,\n CASE WHEN (cohead_holdtype='N') THEN <? value("none") ?>\n WHEN (cohead_holdtype='C') THEN <? value("credit") ?>\n WHEN (cohead_holdtype='S') THEN <? value("ship") ?>\n WHEN (cohead_holdtype='P') THEN <? value("pack") ?>\n WHEN (cohead_holdtype='R') THEN <? value("return") ?>\n ELSE <? value("Other") ?>\n END AS f_holdtype,\n formatDate(cohead_orderdate) AS f_orderdate,\n formatDate(MIN(coitem_scheddate)) AS f_scheddate,\n formatDate(cohead_packdate) AS f_packdate,\n <? if exists("showPrices") ?>\n formatMoney( SUM( round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n (coitem_price / coitem_price_invuomratio),2) ) )\n <? else ?>\n text('')\n <? endif ?>\n AS f_sales,\n <? if exists("showPrices") ?>\n formatCost(SUM((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) * stdcost(item_id) ) )\n <? else ?>\n text('')\n <? endif ?>\n AS f_cost,\n <? if exists("showPrices") ?>\n formatMoney( SUM( (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n ((coitem_price / coitem_price_invuomratio) - stdcost(item_id)) ) )\n <? else ?>\n text('')\n <? endif ?>\n AS f_margin,\n SUM( round( (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n (coitem_price / coitem_price_invuomratio),2) ) AS sales,\n SUM((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) * stdcost(item_id) ) AS cost,\n SUM((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n ((coitem_price / coitem_price_invuomratio) - stdcost(item_id)) ) AS margin,\n MIN(coitem_scheddate) AS scheddate,\n formatShipmentNumber(shiphead_id) AS shiphead_number,\n CASE WHEN (shiphead_shipped IS NULL) THEN text('')\n WHEN (shiphead_shipped) THEN text('Yes')\n WHEN (NOT shiphead_shipped) THEN text('No')\n END AS shipstatus,\n COALESCE(shiphead_shipvia, '') AS shipvia,\n CASE WHEN (shiphead_shipdate IS NULL) THEN text('')\n ELSE formatDate(shiphead_shipdate)\n END AS shipdate\n FROM coitem, itemsite, item, custinfo,\n cohead LEFT OUTER JOIN shiphead ON (shiphead_order_id=cohead_id AND shiphead_order_type='SO') \n WHERE ( (coitem_cohead_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (coitem_status NOT IN ('C','X'))\n AND (coitem_scheddate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("custtype_id") ?>\n AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n AND (cust_custtype_id IN (SELECT custtype_id\n FROM custtype\n WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n)\nGROUP BY cohead_id, cohead_number, cust_name, cohead_holdtype,\n cohead_orderdate, cohead_packdate, shiphead_shipped,\n shiphead_shipvia, shiphead_shipdate, shiphead_id\nORDER BY \n<? if exists("orderByShipDate") ?>\n scheddate,\n<? elseif exists("orderByPackDate") ?>\n cohead_packdate,\n<? endif ?>\ncohead_number, shiphead_shipped;\n \n \n totals\n SELECT\n<? if exists("showPrices") ?>\n formatMoney( SUM( sales ) ) AS f_sales,\n formatCost( SUM( cost ) ) AS f_cost,\n formatMoney( SUM( margin ) ) AS f_margin\n FROM (\nSELECT SUM( round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n (coitem_price / coitem_price_invuomratio),2) ) AS sales,\n SUM((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) * stdcost(item_id) ) AS cost,\n SUM((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) *\n ((coitem_price / coitem_price_invuomratio) - stdcost(item_id)) ) AS margin\n FROM coitem, itemsite, item, custinfo,\n cohead\n WHERE ( (coitem_cohead_id=cohead_id)\n AND (cohead_cust_id=cust_id)\n AND (coitem_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (coitem_status NOT IN ('C','X'))\n AND (coitem_scheddate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)\n<? if exists("custtype_id") ?>\n AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? elseif exists("custtype_pattern") ?>\n AND (cust_custtype_id IN (SELECT custtype_id\n FROM custtype\n WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n)\nGROUP BY cohead_id, cohead_number, cust_name, cohead_holdtype,\n cohead_orderdate, cohead_packdate\n) AS data\n<? else ?>\n text('') AS f_sales,\n text('') AS f_cost,\n text('') AS f_margin\n<? endif ?>\n \n \n 206\n \n 5\n 200\n 745\n 200\n 2\n \n \n \n 670\n 170\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_margin\n \n \n \n \n \n \n \n 140\n 104\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n 140\n 85\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n custtype\n \n \n \n \n \n 515\n 85\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n \n 510\n 170\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_sales\n \n \n \n \n \n \n 515\n 104\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n 590\n 170\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_cost\n \n \n \n \n \n \n \n \n \n \n 6\n \n \n 28\n \n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n \n \n 585\n 5\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_cost\n \n \n \n \n 665\n 5\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_margin\n \n \n \n \n \n 505\n 5\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_sales\n \n \n \n
\n detail\n \n unnamed\n cohead_id\n \n 18\n \n \n 70\n 0\n 145\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_name\n \n \n \n \n 370\n 0\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_scheddate\n \n \n \n \n 510\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_sales\n \n \n \n \n 290\n 0\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_orderdate\n \n \n \n \n 670\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_margin\n \n \n \n \n 5\n 0\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cohead_number\n \n \n \n \n 220\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_holdtype\n \n \n \n \n 590\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_cost\n \n \n \n \n 440\n 0\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_packdate\n \n \n \n \n \n \n detail\n \n 18\n \n \n 220\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shiphead_number\n \n \n \n \n 5\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shipstatus\n \n \n \n \n 70\n 0\n 145\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shipvia\n \n \n \n \n 290\n 0\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n shipdate\n \n \n \n
\n \n 18\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 18\n \n \n 590\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n totals\n f_cost\n \n \n \n \n 407\n 0\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_totals\n \n \n \n \n 510\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n totals\n f_sales\n \n \n \n \n 670\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n totals\n f_margin\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 295 SummarizedBankrecHistory \N \n\n Summarized Bank Reconciliation History\n SummarizedBankrecHistory\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT bankrec_id,\n formatBoolYN(bankrec_posted) AS f_posted,\n formatDate(bankrec_created) AS f_created,\n formatDate(bankrec_postdate) AS f_postdate,\n bankrec_username AS f_username,\n formatDate(bankrec_opendate) AS f_opendate,\n formatDate(bankrec_enddate) AS f_enddate,\n formatMoney(bankrec_openbal) AS f_openbal,\n formatMoney(bankrec_endbal) AS f_endbal\n FROM bankrec\n WHERE (bankrec_bankaccnt_id=<? value("bankaccntid") ?>)\n ORDER BY bankrec_created;\n \n \n head\n SELECT (bankaccnt_name || '-' || bankaccnt_descrip) AS f_bankaccnt\n FROM bankaccnt\n WHERE (bankaccnt_id=<? value("bankaccntid") ?>);\n \n \n 121\n \n \n \n \n \n \n 5\n 115\n 745\n 115\n 2\n \n \n \n 145\n 60\n 220\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_bankaccnt\n \n \n \n \n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 10\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_posted\n \n \n \n \n 96\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_postdate\n \n \n \n \n 370\n 0\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_opendate\n \n \n \n \n 655\n 0\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_endbal\n \n \n \n \n 560\n 0\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_openbal\n \n \n \n \n 180\n 0\n 185\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_username\n \n \n \n \n 465\n 0\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_enddate\n \n \n \n
\n \n 18\n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 448 SummarizedSalesHistory \N \n\n Summarized Sales History\n SummarizedSalesHistory\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n summarizedSalesHistory\n detail\n \n \n 163\n \n \n \n \n 3\n 159\n 743\n 159\n 2\n \n \n \n \n \n \n \n 15\n 40\n 725\n 15\n \n 11\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n \n \n 6\n \n \n 21\n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 605\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n totalsales\n \n extprice\n \n \n \n 540\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n qtyshipped\n \n \n \n \n 405\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n firstdate\n \n \n \n \n 475\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n lastdate\n \n \n \n \n 10\n 0\n 80\n 15\n \n 11\n \n Arial\n 8\n bold\n \n \n \n \n detail\n groupsLit\n \n \n \n \n 100\n 0\n 90\n 15\n \n 11\n \n Arial\n 8\n bold\n \n \n \n \n detail\n groups\n \n \n \n \n 200\n 0\n 190\n 15\n \n 11\n \n Arial\n 8\n bold\n \n \n \n \n detail\n groupsDescrip\n \n \n \n \n 695\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n currAbbr\n \n \n \n
\n \n 17\n \n \n \n 105\n 1\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 1\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 351 TaxAuthoritiesMasterList \N \n\n Tax Authorities Master List\n TaxAuthoritiesMasterList\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n taxAuthorities\n detail\n \n \n 128\n \n 5\n 120\n 745\n 120\n 2\n \n \n \n \n \n \n 10\n 38\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 6\n \n \n 21\n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 10\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n taxauth_code\n \n \n \n \n 175\n 0\n 565\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n taxauth_name\n \n \n \n
\n \n 16\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 418 TaxHistoryDetail \N \n\n Tax History Detail\n TaxHistoryDetail\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("showSales") ?>\n 'Yes'\n <? else ?>\n 'No'\n <? endif ?>\n AS showSales,\n <? if exists("showPurchases") ?>\n 'Yes'\n <? else ?>\n 'No'\n <? endif ?>\n AS showPurchases,\n <? if exists("groupProper") ?>\n <? value("groupProper") ?> || '=' || <? value("selection") ?>\n <? else ?>\n 'All' \n <? endif ?>\n AS selection,\n <? if exists("distDate") ?>\n text('Distribution Date')\n <? else ?>\n text('Document Date')\n <? endif ?>\n AS basis,\n formatDate(<? value("startDate") ?>) AS startdate,\n formatDate(<? value("endDate") ?>) AS enddate,\n 'Tax ' || (SELECT curr_symbol \n FROM curr_symbol\n WHERE curr_base) AS taxbaseLit;\n \n \n detail\n <? if exists("showSales") ?>\n------------BEGIN SALES--------------\n-- All sales tax history including memos \nSELECT \n formatDate(taxhist_distdate) AS f_distdate, \n tax_code AS tax, tax_descrip,\n COALESCE(taxtype_name,<? value("none") ?>) AS taxtype, taxtype_descrip,\n COALESCE(taxclass_code,<? value("none") ?>) AS taxclass, taxclass_descrip,\n COALESCE(taxauth_code,<? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n COALESCE(taxzone_code,<? value("none") ?>) AS taxzone, taxzone_descrip, curr_abbr, \n CASE\n WHEN (cohist_doctype != 'C') THEN\n cohist_invcnumber\n ELSE\n cohist_ordernumber\n END AS docnumber, \n <? value("sales") ?> AS source,\n CASE\n WHEN (cohist_doctype='I') THEN\n <? value("invoice") ?>\n WHEN (cohist_doctype='C') THEN\n <? value("creditmemo") ?> \n WHEN (cohist_doctype='D') THEN\n <? value("debitmemo") ?>\n ELSE\n <? value("other") ?>\n END AS doctype,\n item_number, COALESCE(item_descrip1,cohist_misc_descrip) AS description,\n CASE\n WHEN (cohist_doctype != 'C') THEN\n cohist_ordernumber \n END AS ordernumber, cohist_invcdate AS docdate,\n cohist_billtoname AS name, \n formatQty(cohist_qtyshipped) AS f_qty, \n formatSalesPrice(cohist_unitprice) AS f_unitprice, \n formatMoney(cohist_qtyshipped * cohist_unitprice) AS f_amount,\n formatMoney(taxhist_tax) AS f_taxlocal,\n taxhist_tax / taxhist_curr_rate AS taxbase,\n formatMoney(taxhist_tax / taxhist_curr_rate) AS f_taxbase\nFROM cohisttax\n JOIN cohist ON (cohist_id=taxhist_parent_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (cohist_taxzone_id=taxzone_id)\n LEFT OUTER JOIN itemsite ON (cohist_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id=item_id)\n<? if exists("distDate") ?>\nWHERE ((taxhist_distdate BETWEEN <? value("startDate") ?>\n AND <? value("endDate") ?>)\n<? else ?>\nWHERE ((taxhist_docdate BETWEEN <? value("startDate") ?>\n AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("tax_id") ?>\n AND (taxhist_tax_id=<? value("tax_id") ?>)\n<? endif ?>\n<? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=<? value("taxtype_id") ?>)\n<? endif ?>\n<? if exists("taxclass_id") ?>\n AND (taxclass_id=<? value("taxclass_id") ?>)\n<? endif ?>\n<? if exists("taxauth_id") ?>\n AND (taxauth_id=<? value("taxauth_id") ?>)\n<? endif ?>\n<? if exists("taxzone_id") ?>\n AND (taxzone_id=<? value("taxzone_id") ?>)\n<? endif ?>\n)\n<? endif ?>\n--------------END SALES--------------------\n<? if exists("showPurchases") ?>\n<? if exists("showSales") ?>\n-- Union because sales and purchase shown together\nUNION ALL\n<? endif ?>\n<? endif ?>\n------------BEGIN PURCHASE----------------\n<? if exists("showPurchases") ?>\n-- A/P Memo history\nSELECT \n formatDate(taxhist_distdate) AS f_distdate, \n tax_code AS tax, tax_descrip,\n COALESCE(taxtype_name,<? value("none") ?>) AS taxtype, taxtype_descrip,\n COALESCE(taxclass_code,<? value("none") ?>) AS taxclass, taxclass_descrip,\n COALESCE(taxauth_code,<? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n <? value("none") ?> AS taxzone,'' AS taxzone_descrip, curr_abbr, \n apopen_docnumber AS docnumber, \n <? value("purchase") ?> AS source,\n CASE\n WHEN (apopen_doctype='C') THEN\n <? value("creditmemo") ?> \n WHEN (apopen_doctype='D') THEN\n <? value("debitmemo") ?>\n ELSE\n <? value("other") ?>\n END AS doctype,\n '' AS item_number, apopen_notes AS description,\n apopen_ponumber AS ordernumber, apopen_docdate AS docdate,\n vend_name AS name, \n formatQty(1) AS f_qty, \n formatPurchPrice(apopen_amount) AS unitprice, formatMoney(apopen_amount) AS f_amount,\n formatMoney(taxhist_tax) AS f_taxlocal,\n taxhist_tax / taxhist_curr_rate AS taxbase,\n formatMoney(taxhist_tax / taxhist_curr_rate) AS f_taxbase\nFROM apopentax\n JOIN apopen ON (apopen_id=taxhist_parent_id)\n JOIN vendinfo ON (apopen_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n<? if exists("distDate") ?>\nWHERE ((taxhist_distdate BETWEEN <? value("startDate") ?>\n AND <? value("endDate") ?>)\n<? else ?>\nWHERE ((taxhist_docdate BETWEEN <? value("startDate") ?>\n AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("tax_id") ?>\n AND (taxhist_tax_id=<? value("tax_id") ?>)\n<? endif ?>\n<? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=<? value("taxtype_id") ?>)\n<? endif ?>\n<? if exists("taxclass_id") ?>\n AND (taxclass_id=<? value("taxclass_id") ?>)\n<? endif ?>\n<? if exists("taxauth_id") ?>\n AND (taxauth_id=<? value("taxauth_id") ?>)\n<? endif ?>\n<? if exists("taxzone_id") ?>\n AND (false)\n<? endif ?>\n AND (taxhist_distdate IS NOT NULL)\n)\nUNION ALL\n--Voucher Header History\nSELECT \n formatDate(taxhist_distdate) AS f_distdate, \n tax_code AS tax, tax_descrip,\n COALESCE(taxtype_name,<? value("none") ?>) AS taxtype, taxtype_descrip,\n COALESCE(taxclass_code,<? value("none") ?>) AS taxclass, taxclass_descrip,\n COALESCE(taxauth_code,<? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n COALESCE(taxzone_code,<? value("none") ?>) AS taxzone, taxzone_descrip, curr_abbr, \n vohead_number AS docnumber, \n <? value("purchase") ?> AS source,\n <? value("voucher") ?> AS doctype,\n '', vohead_notes AS description,\n pohead_number AS ordernumber, vohead_docdate AS docdate,\n vend_name AS name, \n formatQty(1) AS f_qty, \n formatPurchPrice(0) AS f_unitprice, formatMoney(0) AS f_amount,\n formatMoney(taxhist_tax) AS f_taxlocal,\n taxhist_tax / taxhist_curr_rate AS taxbase,\n formatMoney(taxhist_tax / taxhist_curr_rate) AS f_taxbase\nFROM voheadtax\n JOIN vohead ON (vohead_id=taxhist_parent_id)\n LEFT OUTER JOIN pohead ON (vohead_pohead_id=pohead_id)\n JOIN vendinfo ON (vohead_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (vohead_taxzone_id=taxzone_id)\n<? if exists("distDate") ?>\nWHERE ((taxhist_distdate BETWEEN <? value("startDate") ?>\n AND <? value("endDate") ?>)\n<? else ?>\nWHERE ((taxhist_docdate BETWEEN <? value("startDate") ?>\n AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("tax_id") ?>\n AND (taxhist_tax_id=<? value("tax_id") ?>)\n<? endif ?>\n<? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=<? value("taxtype_id") ?>)\n<? endif ?>\n<? if exists("taxclass_id") ?>\n AND (taxclass_id=<? value("taxclass_id") ?>)\n<? endif ?>\n<? if exists("taxauth_id") ?>\n AND (taxauth_id=<? value("taxauth_id") ?>)\n<? endif ?>\n<? if exists("taxzone_id") ?>\n AND (taxzone_id=<? value("taxzone_id") ?>)\n<? endif ?>\n AND (taxhist_distdate IS NOT NULL)\n)\nUNION ALL\n--Voucher Line Item\nSELECT \n formatDate(taxhist_distdate) AS f_distdate, \n tax_code AS tax, tax_descrip,\n COALESCE(taxtype_name,<? value("none") ?>) AS taxtype, taxtype_descrip,\n COALESCE(taxclass_code,<? value("none") ?>) AS taxclass, taxclass_descrip,\n COALESCE(taxauth_code,<? value("none") ?>) AS taxauth, taxauth_name AS taxauth_descrip,\n COALESCE(taxzone_code,<? value("none") ?>) AS taxzone, taxzone_descrip, curr_abbr, \n vohead_number AS docnumber, \n <? value("purchase") ?> AS source,\n <? value("voucher") ?> AS doctype,\n COALESCE(item_number,expcat_code), COALESCE(item_descrip1,expcat_descrip) AS description,\n pohead_number AS ordernumber, vohead_docdate AS docdate,\n vend_name AS name, \n formatQty(voitem_qty) AS f_qty, \n formatPurchPrice(COALESCE(SUM(vodist_amount),0)/voitem_qty) AS unitprice, \n formatMoney(COALESCE(SUM(vodist_amount),0)) AS f_amount,\n formatMoney(taxhist_tax) AS taxlocal,\n taxhist_tax / taxhist_curr_rate AS taxbase,\n formatMoney(taxhist_tax / taxhist_curr_rate) AS f_taxbase\nFROM voitemtax\n JOIN voitem ON (voitem_id=taxhist_parent_id)\n JOIN vohead ON (vohead_id=voitem_vohead_id)\n JOIN pohead ON (vohead_pohead_id=pohead_id)\n JOIN poitem ON (voitem_poitem_id=poitem_id)\n JOIN vodist ON ((vodist_poitem_id=poitem_id)\n AND (vodist_vohead_id=vohead_id))\n JOIN vendinfo ON (vohead_vend_id=vend_id)\n JOIN taxtype ON (taxtype_id=taxhist_taxtype_id)\n JOIN tax ON (tax_id=taxhist_tax_id)\n JOIN curr_symbol ON (curr_id=taxhist_curr_id)\n LEFT OUTER JOIN taxclass ON (tax_taxclass_id=taxclass_id)\n LEFT OUTER JOIN taxauth ON (tax_taxauth_id=taxauth_id)\n LEFT OUTER JOIN taxzone ON (vohead_taxzone_id=taxzone_id)\n LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id=item_id)\n LEFT OUTER JOIN expcat ON (expcat_id=poitem_expcat_id)\n<? if exists("distDate") ?>\nWHERE ((taxhist_distdate BETWEEN <? value("startDate") ?>\n AND <? value("endDate") ?>)\n<? else ?>\nWHERE ((taxhist_docdate BETWEEN <? value("startDate") ?>\n AND <? value("endDate") ?>)\n<? endif ?>\n<? if exists("tax_id") ?>\n AND (taxhist_tax_id=<? value("tax_id") ?>)\n<? endif ?>\n<? if exists("taxtype_id") ?>\n AND (taxhist_taxtype_id=<? value("taxtype_id") ?>)\n<? endif ?>\n<? if exists("taxclass_id") ?>\n AND (taxclass_id=<? value("taxclass_id") ?>)\n<? endif ?>\n<? if exists("taxauth_id") ?>\n AND (taxauth_id=<? value("taxauth_id") ?>)\n<? endif ?>\n<? if exists("taxzone_id") ?>\n AND (taxzone_id=<? value("taxzone_id") ?>)\n<? endif ?>\n AND (taxhist_distdate IS NOT NULL)\n)\nGROUP BY taxhist_id,taxhist_distdate,tax_code,tax_descrip,\n taxtype_name,taxtype_descrip,taxclass_code,taxclass_descrip,\n taxauth_code,taxauth_descrip,taxzone,taxzone_descrip,curr_abbr,\n vohead_number,pohead_number,item_number,item_descrip1,\n vohead_curr_id,vohead_distdate,vohead_docdate,vend_name,\n expcat_code,expcat_descrip,taxhist_tax,taxhist_curr_rate,\n voitem_qty\n<? endif ?>\n-------------END PURCHASE--------------\nORDER BY docdate DESC, docnumber DESC\n\n\n \n \n 221\n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n 460.577\n 137.571\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n \n 460.577\n 116.571\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n \n \n 461\n 96\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n basis\n \n \n \n \n \n 141\n 137\n 230\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n selection\n \n \n \n \n 141\n 117\n 230\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n showPurchases\n \n \n \n \n \n 141\n 96\n 230\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n showSales\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 650\n 182\n 100\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n taxbaseLit\n \n \n \n \n \n 6\n \n \n 52\n \n \n 6\n 45\n 746\n 45\n 2\n \n \n \n \n \n \n \n \n \n \n \n 650\n 12\n 100\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n taxbaseLit\n \n \n \n
\n detail\n \n \n detail\n \n 37\n \n \n 200\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n tax\n \n \n \n \n 100\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n source\n \n \n \n \n 575\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n curr_abbr\n \n \n \n \n 500\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_taxlocal\n \n \n \n \n 5\n 0\n 95\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n docnumber\n \n \n \n \n 300\n 16.6\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n description\n \n \n \n \n 300\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 650\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_taxbase\n \n \n \n \n 200\n 16.6\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n docdate\n \n \n \n \n 100\n 16.6\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n doctype\n \n \n \n 6\n 33\n 746\n 33\n 1\n \n \n
\n \n 16\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 23\n \n \n 648\n 4\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n taxbase\n \n money\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 352 TaxTypesMasterList \N \n\n Tax Types Master List\n TaxTypesMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n select taxtype_name, taxtype_descrip\n from taxtype\norder by taxtype_name;\n \n \n 76\n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n \n 6\n \n \n 21\n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n
\n detail\n \n \n detail\n \n \n 16\n \n \n 10\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n taxtype_name\n \n \n \n \n 175\n 0\n 565\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n taxtype_descrip\n \n \n \n
\n \n 16\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 74 TermsMasterList \N \n\n Terms Master List\n TermsMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n select terms_code, terms_descrip,\n terms_duedays, terms_discdays,\n formatScrap(terms_discprcnt) AS f_discprcnt\n from terms\norder by terms_code;\n \n \n 76\n \n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 495\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n terms_duedays\n \n \n \n \n 580\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n terms_discdays\n \n \n \n \n 95\n 0\n 395\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n terms_descrip\n \n \n \n \n 10\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n terms_code\n \n \n \n \n 665\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_discprcnt\n \n \n \n
\n \n 16\n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 463 UnpostedVouchers \N \n\n Unposted Vouchers\n UnpostedVouchers\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n openVouchers\n populate\n \n \n 78\n \n \n \n \n \n \n 3.66667\n 74\n 743.667\n 74\n 2\n \n \n \n \n \n \n \n \n 6\n \n \n 41\n \n 5\n 35\n 745\n 35\n 2\n \n \n \n \n \n \n \n \n \n \n
\n detail\n \n detail\n orderid\n \n \n \n detail\n \n 17\n \n \n 650\n 2\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_amount\n \n \n \n \n 400\n 2\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vohead_invcnumber\n \n \n \n \n 90\n 2\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n ponumber\n \n \n \n \n 5\n 2\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vohead_number\n \n \n \n \n 490\n 2\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_distdate\n \n \n \n \n 310\n 2\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vendtype_code\n \n \n \n \n 570\n 2\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_postdate\n \n \n \n \n 150\n 2\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vendor\n \n \n \n
\n \n 16\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 136 TimePhasedAvailability \N \n\n Time Phased Availability\n TimePhasedAvailability\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("plancode_id") ?>\n ( SELECT (plancode_code || '-' || plancode_name)\n FROM plancode\n WHERE (plancode_id=<? value("plancode_id") ?>) )\n <? elseif exists("plancode_pattern") ?>\n text(<? value("plancode_pattern") ?>)\n <? else ?>\n text('All Planner Codes')\n <? endif ?>\n AS plncode;\n \n \n detail\n SELECT findPeriodStart(rcalitem_id) AS pstart,\n findPeriodEnd(rcalitem_id) AS pend,\n (formatDate(findPeriodStart(rcalitem_id)) || '-' || formatDate(findPeriodEnd(rcalitem_id))) AS period,\n item_number,\n uom_name AS f_uom,\n warehous_code,\n formatQty(qtyAvailable(itemsite_id, findPeriodStart(rcalitem_id))) AS f_unit\n FROM rcalitem, itemsite, item, uom, whsinfo\n WHERE ((rcalitem_id in (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n ))\n AND (itemsite_warehous_id=warehous_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("plancode_id") ?>\n AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n AND (itemsite_plancode_id IN ( SELECT plancode_id\n FROM plancode\n WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? endif ?>\n )\n UNION\nSELECT findPeriodStart(acalitem_id) AS pstart,\n findPeriodEnd(acalitem_id) AS pend,\n (formatDate(findPeriodStart(acalitem_id)) || '-' || formatDate(findPeriodEnd(acalitem_id))) AS period,\n item_number,\n uom_name AS f_uom,\n warehous_code,\n formatQty(qtyAvailable(itemsite_id, findPeriodStart(acalitem_id))) AS f_unit\n FROM acalitem, itemsite, item, uom, whsinfo\n WHERE ((acalitem_id IN (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n ))\n AND (itemsite_warehous_id=warehous_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("plancode_id") ?>\n AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n AND (itemsite_plancode_id IN ( SELECT plancode_id\n FROM plancode\n WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? endif ?>\n )\nORDER BY pstart, item_number, warehous_code;\n \n \n 221\n \n \n \n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n 140\n 105\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n 140\n 80\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n plncode\n \n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n
\n detail\n \n detail\n pstart\n \n 6\n \n \n 10\n 5\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n period\n \n \n \n \n \n \n detail\n \n 16\n \n \n 660\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_unit\n \n \n \n \n 530\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_uom\n \n \n \n \n 615\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 320\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n
\n \n 16\n \n \n \n 690\n 0\n 51\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 449 TimePhasedBookings \N \n\n Time Phased Bookings\n TimePhasedBookings\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("byCust") ?>\n text('Customer')\n <? elseif exists("byProdcat") ?>\n text('Product Category')\n <? else ?>\n text('Item')\n <? endif ?>\n AS groupby,\n <? if exists("byCust") ?>\n text('Name')\n <? else ?>\n text('Description')\n <? endif ?>\n AS groupbyDescrip,\n <? if exists("salesDollars") ?>\n text('')\n <? else ?>\n text('UOM')\n <? endif ?>\n AS lbl_uom,\n <? if exists("inventoryUnits") ?>\n text('Qty.')\n <? elseif exists("capacityUnits") ?>\n text('Capacity')\n <? elseif exists("altCapacityUnits") ?>\n text('Alt. Capacity')\n <? elseif exists("salesDollars") ?>\n text('Sales')\n <? else ?>\n text('ERROR')\n <? endif ?>\n AS lbl_unittype; \n \n \n detail\n SELECT *, \n coalesce(unit,0) AS unit, \n<? if exists("salesDollars") ?>\n formatExtPrice(coalesce(unit,0)) AS f_unit\n<? else ?>\n formatQty(coalesce(unit,0)) AS f_unit\n<? endif ?>\nFROM\n-- Outer Table Query\n(SELECT DISTINCT\n calitem_id,\n findPeriodStart(calitem_id) AS pstart,\n findPeriodEnd(calitem_id) AS pend,\n (formatDate(findPeriodStart(calitem_id)) || '-' || formatDate(findPeriodEnd(calitem_id))) AS period,\n<? if exists("byCust") ?>\n cust_id, cust_number AS f_number, cust_name AS f_description\n<? elseif exists("byProdcat") ?>\n prodcat_id, prodcat_code AS f_number, prodcat_descrip AS f_description\n<? elseif exists("byItem") ?>\n item_id, item_number AS f_number, item_descrip1 AS f_description\n<? endif ?>\n , warehous_id, warehous_code\n<? if exists("salesDollars") ?>\n , <? value("baseCurrAbbr") ?>::text AS f_uom\n<? else ?>\n <? if exists("inventoryUnits") ?>\n , uom_name AS f_uom\n <? elseif exists("capacityUnits") ?>\n , itemcapuom(item_id) AS f_uom\n <? elseif exists("altCapacityUnits") ?>\n , itemaltcapuom(item_id) AS f_uom\n <? endif ?>\n<? endif ?>\nFROM coitem\n JOIN cohead ON (coitem_cohead_id=cohead_id)\n JOIN itemsite ON (coitem_itemsite_id=itemsite_id)\n JOIN item ON (itemsite_item_id=item_id)\n<? if exists("inventoryUnits") ?>\n JOIN uom ON (item_inv_uom_id=uom_id)\n<? endif ?>\n JOIN site() ON (itemsite_warehous_id=warehous_id)\n<? if reExists("[cC]ust") ?>\n JOIN custinfo ON (cohead_cust_id=cust_id)\n<? endif ?> \n<? if reExists("[pP]rodcat") ?>\n JOIN prodcat ON (item_prodcat_id=prodcat_id)\n<? endif ?>\n , ( SELECT rcalitem_id AS calitem_id,\n findPeriodStart(rcalitem_id) AS calitem_start,\n findPeriodEnd(rcalitem_id) AS calitem_end\n FROM rcalitem\n WHERE (rcalitem_id IN (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n )\n )\n UNION\n SELECT acalitem_id AS calitem_id,\n findPeriodStart(acalitem_id) AS calitem_start,\n findPeriodEnd(acalitem_id) AS calitem_end\n FROM acalitem\n WHERE (acalitem_id IN (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n )\n )\n ) AS calitem\nWHERE ((cohead_orderdate BETWEEN\n<? foreach("period_id_list") ?>\n <? if isfirst("period_id_list") ?>\n findPeriodStart(<? value("period_id_list") ?>)\n <? endif ?>\n <? if isLast("period_id_list") ?>\n AND findPeriodEnd(<? value("period_id_list") ?>)\n <? endif ?>\n<? endforeach ?>\n)\n AND (coitem_status != 'X')\n<? if exists("item_id") ?> \n AND (item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("cust_id") ?> \n AND (cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?> \n AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n AND (cust_custtype_id IN (SELECT custtype_id \n FROM custtype \n WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("prodcat_id") ?> \n AND (item_prodcat_id=<? value("prodcat_id") ?>) \n<? endif ?>\n<? if exists("prodcat_pattern") ?>\n AND (item_prodcat_id IN (SELECT prodcat_id \n FROM prodcat \n WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n<? endif ?>\n<? if exists("warehous_id") ?> \n AND(itemsite_warehous_id=<? value("warehous_id") ?>) \n<? endif ?>\n )\nORDER BY pstart, f_number, f_description, f_uom, warehous_code) list\nLEFT OUTER JOIN\n-- Bookings calcuations\n-- Loop through each period bucket to find bookings for period\n(<? foreach("period_id_list") ?>\n SELECT \n <? value("period_id_list") ?> AS calitem_id,\n warehous_id,\n<? if exists("byCust") ?>\n cust_id\n<? elseif exists("byProdcat") ?>\n prodcat_id \n<? elseif exists("byItem") ?>\n item_id\n<? endif ?>\n<? if exists("salesDollars") ?>\n , sum(round((coitem_qtyord * coitem_qty_invuomratio) * (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2)) AS unit\n , <? value("baseCurrAbbr") ?>::text AS f_uom\n<? else ?>\n , sum(coitem_qtyord)\n <? if exists("capacityUnits") ?>\n * itemcapinvrat(item_id)\n <? elseif exists("altCapacityUnits") ?>\n * itemaltcapinvrat(item_id)\n <? endif ?>\n AS unit\n <? if exists("inventoryUnits") ?>\n , uom_name AS f_uom\n <? elseif exists("capacityUnits") ?>\n , itemcapuom(item_id) AS f_uom\n <? elseif exists("altCapacityUnits") ?>\n , itemaltcapuom(item_id) AS f_uom\n <? endif ?>\n<? endif ?>\n FROM coitem\n JOIN cohead ON (coitem_cohead_id=cohead_id)\n JOIN itemsite ON (coitem_itemsite_id=itemsite_id)\n JOIN item ON (itemsite_item_id=item_id)\n<? if exists("inventoryUnits") ?>\n JOIN uom ON (item_inv_uom_id=uom_id)\n<? endif ?>\n JOIN site() ON (itemsite_warehous_id=warehous_id)\n<? if reExists("[cC]ust") ?>\n JOIN custinfo ON (cohead_cust_id=cust_id)\n<? endif ?> \n<? if reExists("[pP]rodcat") ?>\n JOIN prodcat ON (item_prodcat_id=prodcat_id)\n<? endif ?>\n WHERE ((cohead_orderdate BETWEEN findPeriodStart(<? value("period_id_list") ?>) AND findPeriodEnd(<? value("period_id_list") ?>))\n AND (coitem_status != 'X')\n<? if exists("item_id") ?> \n AND (item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("cust_id") ?> \n AND (cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?> \n AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n AND (cust_custtype_id IN (SELECT custtype_id \n FROM custtype \n WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("prodcat_id") ?> \n AND (item_prodcat_id=<? value("prodcat_id") ?>) \n<? endif ?>\n<? if exists("prodcat_pattern") ?>\n AND (item_prodcat_id IN (SELECT prodcat_id \n FROM prodcat \n WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n<? endif ?>\n<? if exists("warehous_id") ?> \n AND(itemsite_warehous_id=<? value("warehous_id") ?>) \n<? endif ?>\n )\nGROUP BY\n<? if exists("byCust") ?>\n cust_id, \n <? if exists("capacityUnits") ?>\n item_id,\n <? elseif exists("altCapacityUnits") ?>\n item_id,\n <? endif ?>\n<? elseif exists("byProdcat") ?>\n prodcat_id,\n <? if exists("capacityUnits") ?>\n item_id,\n <? elseif exists("altCapacityUnits") ?>\n item_id,\n <? endif ?>\n<? elseif exists("byItem") ?>\n item_id,\n<? endif ?>\n f_uom, warehous_id\n <? if isLast("period_id_list") ?>\n <? else ?>\nUNION\n <? endif ?>\n<? endforeach ?> \n) bookings ON\n<? if exists("byCust") ?>\n (list.cust_id=bookings.cust_id)\n<? elseif exists("byProdcat") ?>\n (list.prodcat_id=bookings.prodcat_id)\n<? elseif exists("byItem") ?>\n (list.item_id=bookings.item_id)\n<? endif ?>\n AND (list.calitem_id=bookings.calitem_id)\n AND (list.warehous_id=bookings.warehous_id)\n AND (list.f_uom=bookings.f_uom)\n \n \n 221\n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n 660\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_unittype\n \n \n \n \n 530\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_uom\n \n \n \n \n \n 220\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n groupby\n \n \n \n \n 330\n 200\n 200\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n groupbyDescrip\n \n \n \n \n 10\n 33\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 6\n \n \n 21\n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n 530\n -1\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_uom\n \n \n \n \n 660\n -1\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_unittype\n \n \n \n \n 215\n -1\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n groupby\n \n \n \n \n 330\n -1\n 200\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n groupbyDescrip\n \n \n \n
\n detail\n \n detail\n pstart\n \n 6\n \n \n 10\n 5\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n period\n \n \n \n \n 31\n \n \n 660\n 5\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n unit\n \n extprice\n \n \n \n 640\n 0\n 745\n 0\n 0\n \n \n \n \n \n \n detail\n \n 16\n \n \n 660\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_unit\n \n \n \n \n 615\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 530\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_uom\n \n \n \n \n 220\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_number\n \n \n \n \n 330\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_description\n \n \n \n
\n \n 16\n \n \n \n 95\n -1\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 690\n -1\n 51\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 199 TimePhasedDemandByPlannerCode \N \n\n Time Phased Demand By Planner Code\n TimePhasedDemandByPlannerCode\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("plancode_id") ?>\n ( SELECT (plancode_code||'-'||plancode_name)\n FROM plancode\n WHERE plancode_id=<? value("plancode_id") ?>)\n <? elseif exists("plancode_pattern") ?>\n text(<? value("plancode_pattern") ?>)\n <? else ?>\n text('All Planner Codes')\n <? endif ?>\n AS plancode,\n <? if exists("inventoryUnits") ?>\n text('Qty.')\n <? elseif exists("capacityUnits") ?>\n text('Capacity')\n <? elseif exists("altCapacityUnits") ?>\n text('Alt. Capacity')\n <? else ?>\n text('ERROR')\n <? endif ?>\n AS lbl_unittype ;\n \n \n detail\n SELECT findPeriodStart(calitem_id) AS pstart,\n findPeriodEnd(calitem_id) AS pend,\n (formatDate(findPeriodStart(calitem_id)) || '-' || formatDate(findPeriodEnd(calitem_id))) AS period,\n plancode_code,\n <? if exists("inventoryUnits") ?>\n uom_name\n <? elseif exists("capacityUnits") ?>\n itemcapuom(item_id)\n <? elseif exists("altCapacityUnits") ?>\n itemaltcapuom(item_id)\n <? else ?>\n text('')\n <? endif ?>\n AS f_uom,\n warehous_code,\n <? if exists("inventoryUnits") ?>\n formatQty(SUM(summDemand(itemsite_id, calitem_id)))\n <? elseif exists("capacityUnits") ?>\n formatQty(SUM(summDemand(itemsite_id, calitem_id) * itemcapinvrat(item_id)))\n <? elseif exists("altCapacityUnits") ?>\n formatQty(SUM(summDemand(itemsite_id, calitem_id) * itemaltcapinvrat(item_id)))\n <? else ?>\n formatQty(SUM(summDemand(itemsite_id, calitem_id)))\n <? endif ?>\n AS f_unit\n FROM itemsite, item, uom, whsinfo, plancode,\n (SELECT rcalitem_id AS calitem_id\n FROM rcalitem\n WHERE (rcalitem_id in (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n ))\n UNION\n SELECT acalitem_id as calitem_id\n FROM acalitem\n WHERE (acalitem_id in (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n ))\n ) AS calitem\n WHERE ((itemsite_warehous_id=warehous_id)\n AND (itemsite_active)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_plancode_id=plancode_id)\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("plancode_id") ?>\n AND (plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n AND (plancode_code ~ <? value("plancode_pattern") ?>)\n<? endif ?>\n )\nGROUP BY pstart, pend, period, plancode_code, warehous_code, f_uom\nORDER BY pstart, plancode_code, warehous_code, f_uom;\n \n \n 221\n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n 660\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_unittype\n \n \n \n \n 140\n 105\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n 140\n 80\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n plancode\n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n \n 660\n 0\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_unittype\n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n
\n detail\n \n detail\n pstart\n \n 6\n \n \n 10\n 5\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n period\n \n \n \n \n \n \n detail\n \n 16\n \n \n 320\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n plancode_code\n \n \n \n \n 615\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 530\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_uom\n \n \n \n \n 660\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_unit\n \n \n \n
\n \n 16\n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 690\n 0\n 51\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 251 TimePhasedOpenAPItems \N \n\n Time Phased Open A/P Items\n TimePhasedOpenAPItems\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("vend_id") ?>\n ( SELECT vend_name\n FROM vendinfo\n WHERE (vend_id=<? value("vend_id") ?>) )\n <? elseif exists("vendtype_id") ?>\n ( SELECT (vendtype_code || '-' || vendtype_descrip)\n FROM vendtype\n WHERE (vendtype_id=<? value("vendtype_id") ?>) )\n <? elseif exists("vendtype_pattern") ?>\n text(<? value("vendtype_pattern") ?>)\n <? else ?>\n text('All Vendors')\n <? endif ?>\n AS f_value,\n <? if reExists("vendtype_.*") ?>\n text('Vendor Type:')\n <? else ?>\n text('Vendor:')\n <? endif ?>\n AS f_label;\n \n \n \n detail\n SELECT pstart, pend,\n period,\n vend_number, vend_name,\n value,\n formatMoney(value) AS f_value\n FROM (\n SELECT calitem_start AS pstart,\n calitem_end AS pend,\n (formatDate(calitem_start) || '-' || formatDate(calitem_end)) AS period,\n vend_number,\n vend_name,\n openAPItemsValue(vend_id, calitem_id) AS value\n FROM vendinfo,\n ( SELECT rcalitem_id AS calitem_id,\n findPeriodStart(rcalitem_id) AS calitem_start,\n findPeriodEnd(rcalitem_id) AS calitem_end\n FROM rcalitem\n WHERE (rcalitem_id IN (\n <? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n <? endforeach ?>\n )\n )\n UNION\n SELECT acalitem_id AS calitem_id,\n findPeriodStart(acalitem_id) AS calitem_start,\n findPeriodEnd(acalitem_id) AS calitem_end\n FROM acalitem\n WHERE (acalitem_id IN (\n <? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n <? endforeach ?>\n )\n )\n ) AS calitem\n <? if exists("vend_id") ?>\n WHERE (vend_id=<? value("vend_id") ?>)\n <? elseif exists("vendtype_id") ?>\n WHERE (vend_vendtype_id=<? value("vendtype_id") ?>)\n <? elseif exists("vendtype_pattern") ?>\n WHERE (vend_vendtype_id IN (SELECT vendtype_id\n FROM vendtype\n WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>) ))\n <? endif ?>\n ) AS data\n WHERE (value != 0)\nORDER BY pstart, pend, vend_number\n\n \n \n 221\n \n \n \n \n 10\n 100\n 125\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n f_label\n \n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n 140\n 100\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_value\n \n \n \n \n \n 6\n \n \n 21\n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n
\n detail\n \n detail\n pstart\n \n 6\n \n \n 10\n 5\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n period\n \n \n \n \n 31\n \n \n 645\n 10\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n value\n \n money\n \n \n 635\n 5\n 745\n 5\n 0\n \n \n \n \n \n \n detail\n \n 16\n \n \n 320\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_number\n \n \n \n \n 430\n 0\n 210\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_name\n \n \n \n \n 645\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_value\n \n \n \n
\n \n 16\n \n \n 690\n 0\n 51\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 252 TimePhasedOpenARItems \N \n\n Time Phased Open A/R Items\n TimePhasedOpenARItems\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("cust_id") ?>\n ( SELECT cust_name\n FROM custinfo\n WHERE (cust_id=<? value("cust_id") ?>) )\n <? elseif exists("custtype_id") ?>\n ( SELECT (custtype_code || '-' || custtype_descrip)\n FROM custtype\n WHERE (custtype_id=<? value("custtype_id") ?>) )\n <? elseif exists("custgrp_id") ?>\n ( SELECT (custgrp_name || '-' || custgrp_descrip)\n\t FROM custgrp\n WHERE (custgrp_id=<? value("custgrp_id") ?>) )\n <? elseif exists("custtype_pattern") ?>\n text(<? value("custtype_pattern") ?>)\n <? else ?>\n text('All Customers')\n <? endif ?>\n AS f_value,\n <? if reExists("custtype_.*") ?>\n text('Customer Type:')\n <? elseif exists("custgrp_id") ?>\n text('Customer Group:')\n <? else ?>\n text('Customer:')\n <? endif ?>\n AS f_label;\n \n \n \n detail\n SELECT pstart, pend,\n period,\n cust_number, cust_name,\n value,\n formatMoney(value) AS f_value\n FROM (\n SELECT calitem_start AS pstart,\n calitem_end AS pend,\n (formatDate(calitem_start) || '-' || formatDate(calitem_end)) AS period,\n cust_number,\n cust_name,\n openARItemsValue(cust_id, calitem_id) AS value\n FROM custinfo LEFT OUTER JOIN custgrpitem ON (cust_id=custgrpitem_cust_id)\n LEFT OUTER JOIN custgrp ON (custgrpitem_custgrp_id=custgrp_id),\n ( SELECT rcalitem_id AS calitem_id,\n findPeriodStart(rcalitem_id) AS calitem_start,\n findPeriodEnd(rcalitem_id) AS calitem_end\n FROM rcalitem\n WHERE (rcalitem_id IN (\n <? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n <? endforeach ?>\n )\n )\n UNION\n SELECT acalitem_id AS calitem_id,\n findPeriodStart(acalitem_id) AS calitem_start,\n findPeriodEnd(acalitem_id) AS calitem_end\n FROM acalitem\n WHERE (acalitem_id IN (\n <? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n <? endforeach ?>\n )\n )\n ) AS calitem\n <? if exists("cust_id") ?>\n WHERE (cust_id=<? value("cust_id") ?>)\n <? elseif exists("custtype_id") ?>\n WHERE (cust_custtype_id=<? value("custtype_id") ?>)\n <? elseif exists("custgrp_id") ?>\n WHERE (custgrp_id=<? value("custgrp_id") ?>)\n <? elseif exists("custtype_pattern") ?>\n WHERE (cust_custtype_id IN (SELECT custtype_id\n FROM custtype\n WHERE (custtype_code ~ <? value("custtype_pattern") ?>) ))\n <? endif ?>\n ) AS data\n WHERE (value != 0)\nORDER BY pstart, pend, cust_number\n\n \n \n 222\n \n \n \n 10\n 100\n 125\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n f_label\n \n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n 140\n 100\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_value\n \n \n \n \n \n 7\n \n \n 22\n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n
\n detail\n \n detail\n pstart\n \n 7\n \n \n 10\n 5\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n period\n \n \n \n \n 27\n \n 635\n 5\n 745\n 5\n 0\n \n \n \n 645\n 5\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n value\n \n money\n \n \n \n \n \n \n detail\n \n 17\n \n \n 430\n 0\n 210\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_name\n \n \n \n \n 320\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_number\n \n \n \n \n 645\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_value\n \n \n \n
\n \n 17\n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 690\n 0\n 51\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 201 TimePhasedProductionByItem \N \n\n Time Phased Production By Item\n TimePhasedProductionByItem\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse,\n <? if exists("plancode_id") ?>\n ( SELECT (plancode_code||'-'||plancode_name)\n FROM plancode\n WHERE plancode_id=<? value("plancode_id") ?>)\n <? elseif exists("plancode_pattern") ?>\n text(<? value("plancode_pattern") ?>)\n <? else ?>\n text('All Planner Codes')\n <? endif ?>\n AS plancode ;\n \n \n detail\n SELECT findPeriodStart(calitem_id) AS pstart,\n findPeriodEnd(calitem_id) AS pend,\n (formatDate(findPeriodStart(calitem_id)) || '-' || formatDate(findPeriodEnd(calitem_id))) AS period,\n item_number,\n uom_name,\n warehous_code,\n formatQty(SUM(summProd(itemsite_id, calitem_id))) AS f_unit\n FROM itemsite, item, uom, whsinfo,\n (SELECT rcalitem_id AS calitem_id\n FROM rcalitem\n WHERE (rcalitem_id in (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n ))\n UNION\n SELECT acalitem_id as calitem_id\n FROM acalitem\n WHERE (acalitem_id in (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n ))\n ) AS calitem\n WHERE ((itemsite_warehous_id=warehous_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n<? if exists("warehous_id") ?>\n AND (itemsite_warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n<? if exists("plancode_id") ?>\n AND (itemsite_plancode_id=<? value("plancode_id") ?>)\n<? elseif exists("plancode_pattern") ?>\n AND (itemsite_plancode_id IN (SELECT plancode_id FROM plancode WHERE (plancode_code ~ <? value("plancode_pattern") ?>)))\n<? endif ?>\n )\nGROUP BY pstart, pend, period, item_number, warehous_code, uom_name\nORDER BY pstart, item_number, warehous_code;\n \n \n 221\n \n \n 140\n 80\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n plancode\n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n \n \n \n 140\n 105\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n
\n detail\n \n detail\n pstart\n \n 6\n \n \n 10\n 5\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n period\n \n \n \n \n \n \n detail\n \n 16\n \n \n 660\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_unit\n \n \n \n \n 615\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 320\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 530\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n
\n \n 16\n \n \n 690\n 0\n 51\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 450 TimePhasedSalesHistory \N \n\n Time Phased Sales History\n TimePhasedSalesHistory\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("byCust") ?>\n text('Customer')\n <? elseif exists("byProdcat") ?>\n text('Product Category')\n <? else ?>\n text('Item')\n <? endif ?>\n AS groupby,\n <? if exists("byCust") ?>\n text('Name')\n <? else ?>\n text('Description')\n <? endif ?>\n AS groupbyDescrip,\n <? if exists("salesDollars") ?>\n text('')\n <? else ?>\n text('UOM')\n <? endif ?>\n AS lbl_uom,\n <? if exists("inventoryUnits") ?>\n text('Qty.')\n <? elseif exists("capacityUnits") ?>\n text('Capacity')\n <? elseif exists("altCapacityUnits") ?>\n text('Alt. Capacity')\n <? elseif exists("salesDollars") ?>\n text('Sales')\n <? else ?>\n text('ERROR')\n <? endif ?>\n AS lbl_unittype; \n \n \n detail\n SELECT *, \n coalesce(unit,0) AS unit, \n<? if exists("salesDollars") ?>\n formatExtPrice(coalesce(unit,0)) AS f_unit\n<? else ?>\n formatQty(coalesce(unit,0)) AS f_unit\n<? endif ?>\nFROM\n-- Outer Table Query\n(SELECT DISTINCT\n calitem_id,\n findPeriodStart(calitem_id) AS pstart,\n findPeriodEnd(calitem_id) AS pend,\n (formatDate(findPeriodStart(calitem_id)) || '-' || formatDate(findPeriodEnd(calitem_id))) AS period,\n<? if exists("byCust") ?>\n cust_id, cust_number AS f_number, cust_name AS f_description\n<? elseif exists("byProdcat") ?>\n prodcat_id, prodcat_code AS f_number, prodcat_descrip AS f_description\n<? elseif exists("byItem") ?>\n item_id, item_number AS f_number, item_descrip1 AS f_description\n<? endif ?>\n , warehous_id, warehous_code\n<? if exists("salesDollars") ?>\n , <? value("baseCurrAbbr") ?>::text AS f_uom\n<? else ?>\n <? if exists("inventoryUnits") ?>\n , uom_name AS f_uom\n <? elseif exists("capacityUnits") ?>\n , itemcapuom(item_id) AS f_uom\n <? elseif exists("altCapacityUnits") ?>\n , itemaltcapuom(item_id) AS f_uom\n <? endif ?>\n<? endif ?>\nFROM cohist JOIN itemsite ON (itemsite_id=cohist_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n<? if exists("inventoryUnits") ?>\n JOIN uom ON (item_inv_uom_id=uom_id)\n<? endif ?>\n JOIN site() ON (itemsite_warehous_id=warehous_id)\n<? if reExists("[cC]ust") ?>\n JOIN custinfo ON (cohist_cust_id=cust_id)\n<? endif ?> \n<? if reExists("[pP]rodcat") ?>\n JOIN prodcat ON (item_prodcat_id=prodcat_id)\n<? endif ?>\n<? if reExists("custgrp") ?>\n JOIN custgrpitem ON (custgrpitem_cust_id=cohist_cust_id)\n JOIN custgrp ON (custgrpitem_custgrp_id=custgrp_id)\n<? endif ?>\n , ( SELECT rcalitem_id AS calitem_id,\n findPeriodStart(rcalitem_id) AS calitem_start,\n findPeriodEnd(rcalitem_id) AS calitem_end\n FROM rcalitem\n WHERE (rcalitem_id IN (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n )\n )\n UNION\n SELECT acalitem_id AS calitem_id,\n findPeriodStart(acalitem_id) AS calitem_start,\n findPeriodEnd(acalitem_id) AS calitem_end\n FROM acalitem\n WHERE (acalitem_id IN (\n<? foreach("period_id_list") ?>\n <? if not isfirst("period_id_list") ?>\n ,\n <? endif ?>\n <? value("period_id_list") ?>\n<? endforeach ?>\n )\n )\n ) AS calitem\nWHERE ((cohist_invcdate BETWEEN\n<? foreach("period_id_list") ?>\n <? if isfirst("period_id_list") ?>\n findPeriodStart(<? value("period_id_list") ?>)\n <? endif ?>\n <? if isLast("period_id_list") ?>\n AND findPeriodEnd(<? value("period_id_list") ?>)\n <? endif ?>\n<? endforeach ?>\n)\n<? if exists("item_id") ?> \n AND (item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("cust_id") ?> \n AND (cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?> \n AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n AND (cust_custtype_id IN (SELECT custtype_id \n FROM custtype \n WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("custgrp_id") ?> \n AND (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("custgrp_pattern") ?>\n AND (cust_custgrp_name ~ <? value("custgrp_pattern") ?>)))\n<? endif ?>\n<? if exists("prodcat_id") ?> \n AND (item_prodcat_id=<? value("prodcat_id") ?>) \n<? endif ?>\n<? if exists("prodcat_pattern") ?>\n AND (item_prodcat_id IN (SELECT prodcat_id \n FROM prodcat \n WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n<? endif ?>\n<? if exists("warehous_id") ?> \n AND(itemsite_warehous_id=<? value("warehous_id") ?>) \n<? endif ?>\n )\nORDER BY pstart, f_number, f_description, f_uom, warehous_code) list\nLEFT OUTER JOIN\n-- Sales calcuations\n-- Loop through each period bucket to find bookings for period\n(<? foreach("period_id_list") ?>\n SELECT \n <? value("period_id_list") ?> AS calitem_id,\n warehous_id,\n<? if exists("byCust") ?>\n cust_id\n<? elseif exists("byProdcat") ?>\n prodcat_id \n<? elseif exists("byItem") ?>\n item_id\n<? endif ?>\n<? if exists("salesDollars") ?>\n , sum(round(cohist_qtyshipped * currtobase(cohist_curr_id, cohist_unitprice, cohist_invcdate), 2)) AS unit\n , <? value("baseCurrAbbr") ?>::text AS f_uom\n<? else ?>\n , sum(cohist_qtyshipped)\n <? if exists("capacityUnits") ?>\n * itemcapinvrat(item_id)\n <? elseif exists("altCapacityUnits") ?>\n * itemaltcapinvrat(item_id)\n <? endif ?>\n AS unit\n <? if exists("inventoryUnits") ?>\n , uom_name AS f_uom\n <? elseif exists("capacityUnits") ?>\n , itemcapuom(item_id) AS f_uom\n <? elseif exists("altCapacityUnits") ?>\n , itemaltcapuom(item_id) AS f_uom\n <? endif ?>\n<? endif ?>\nFROM cohist JOIN itemsite ON (itemsite_id=cohist_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n<? if exists("inventoryUnits") ?>\n JOIN uom ON (item_inv_uom_id=uom_id)\n<? endif ?>\n JOIN site() ON (itemsite_warehous_id=warehous_id)\n<? if reExists("[cC]ust") ?>\n JOIN custinfo ON (cohist_cust_id=cust_id)\n<? endif ?> \n<? if reExists("[pP]rodcat") ?>\n JOIN prodcat ON (item_prodcat_id=prodcat_id)\n<? endif ?>\n<? if reExists("custgrp") ?>\n JOIN custgrpitem ON (custgrpitem_cust_id=cohist_cust_id)\n JOIN custgrp ON (custgrpitem_custgrp_id=custgrp_id)\n<? endif ?>\n WHERE ((cohist_invcdate BETWEEN findPeriodStart(<? value("period_id_list") ?>) AND findPeriodEnd(<? value("period_id_list") ?>))\n<? if exists("item_id") ?> \n AND (item_id=<? value("item_id") ?>)\n<? endif ?>\n<? if exists("cust_id") ?> \n AND (cust_id=<? value("cust_id") ?>)\n<? endif ?>\n<? if exists("custtype_id") ?> \n AND (cust_custtype_id=<? value("custtype_id") ?>)\n<? endif ?>\n<? if exists("custtype_pattern") ?>\n AND (cust_custtype_id IN (SELECT custtype_id \n FROM custtype \n WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))\n<? endif ?>\n<? if exists("custgrp_id") ?> \n AND (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)\n<? endif ?>\n<? if exists("custgrp_pattern") ?>\n AND (cust_custgrp_name ~ <? value("custgrp_pattern") ?>)))\n<? endif ?>\n<? if exists("prodcat_id") ?> \n AND (item_prodcat_id=<? value("prodcat_id") ?>) \n<? endif ?>\n<? if exists("prodcat_pattern") ?>\n AND (item_prodcat_id IN (SELECT prodcat_id \n FROM prodcat \n WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))\n<? endif ?>\n<? if exists("warehous_id") ?> \n AND(itemsite_warehous_id=<? value("warehous_id") ?>) \n<? endif ?>\n )\nGROUP BY\n<? if exists("byCust") ?>\n cust_id, \n <? if exists("capacityUnits") ?>\n item_id,\n <? elseif exists("altCapacityUnits") ?>\n item_id,\n <? endif ?>\n<? elseif exists("byProdcat") ?>\n prodcat_id,\n <? if exists("capacityUnits") ?>\n item_id,\n <? elseif exists("altCapacityUnits") ?>\n item_id,\n <? endif ?>\n<? elseif exists("byItem") ?>\n item_id,\n<? endif ?>\n f_uom, warehous_id\n <? if isLast("period_id_list") ?>\n <? else ?>\nUNION\n <? endif ?>\n<? endforeach ?> \n) sales ON\n<? if exists("byCust") ?>\n (list.cust_id=sales.cust_id)\n<? elseif exists("byProdcat") ?>\n (list.prodcat_id=sales.prodcat_id)\n<? elseif exists("byItem") ?>\n (list.item_id=sales.item_id)\n<? endif ?>\n AND (list.calitem_id=sales.calitem_id)\n AND (list.warehous_id=sales.warehous_id)\n AND (list.f_uom=sales.f_uom)\n \n \n 221\n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n 660\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_unittype\n \n \n \n \n 530\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_uom\n \n \n \n \n \n 220\n 200\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n groupby\n \n \n \n \n 330\n 200\n 200\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n groupbyDescrip\n \n \n \n \n 10\n 33\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 6\n \n \n 21\n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n 530\n -1\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_uom\n \n \n \n \n 660\n -1\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n lbl_unittype\n \n \n \n \n 215\n -1\n 80\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n groupby\n \n \n \n \n 330\n -1\n 200\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n head\n groupbyDescrip\n \n \n \n
\n detail\n \n detail\n pstart\n \n 6\n \n \n 10\n 5\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n period\n \n \n \n \n 31\n \n \n 660\n 5\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n unit\n \n extprice\n \n \n \n 640\n 0\n 745\n 0\n 0\n \n \n \n \n \n \n detail\n \n 16\n \n \n 660\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_unit\n \n \n \n \n 615\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 530\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_uom\n \n \n \n \n 220\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_number\n \n \n \n \n 330\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_description\n \n \n \n
\n \n 16\n \n \n \n 95\n -1\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 690\n -1\n 51\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 320 TitleList \N \n\n Titles\n TitleList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT hnfc_code\n FROM hnfc\nORDER BY hnfc_code;\n \n \n 76\n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n 6\n \n \n 21\n \n 5\n 15\n 745\n 15\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 10\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n hnfc_code\n \n \n \n
\n \n 16\n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 410 TodoItem \N \n\n To-Do Item\n TodoItem\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT todoitem_id AS id,\n 'T' AS type, todoitem_seq AS seq, \n todoitem_name AS name, \n firstLine(todoitem_description) AS descrip, \n todoitem_status AS status, todoitem_due_date AS due, \n todoitem_username AS usr, incdt_number AS incdt \nFROM todoitem LEFT OUTER JOIN incdt ON (incdt_id=todoitem_incdt_id) \nWHERE (todoitem_id=<? value("todoitem_id") ?>)\nORDER BY seq, usr;\n \n \n 141\n \n \n \n 385\n 30\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n status\n \n \n \n \n 110\n 35\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n type\n \n \n \n \n \n \n \n 385\n 45\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n due\n \n \n \n \n 385\n 60\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n incdt\n \n \n \n \n \n \n 110\n 20\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n usr\n \n \n \n \n 110\n 65\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n name\n \n \n \n \n 110\n 80\n 600\n 15\n \n 0\n \n Arial\n 8\n bold\n \n \n \n \n detail\n descrip\n \n \n \n \n \n 10\n 135\n 750\n 135\n 2\n \n \n \n 110\n 50\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n seq\n \n \n \n \n \n 6\n \n \n 21\n \n 5\n 15\n 745\n 15\n 2\n \n \n \n 16\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n\n 0 2015-10-01 17:15:58.47729 324 TodoList \N \n\n To-Do List\n TodoList\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n todolist\n detail\n \n \n queryParams\n SELECT\n <? if exists("completed") ?> 'Yes' <? else ?> 'No' <? endif ?> AS showClosed,\n <? if exists("projects") ?> 'Yes' <? else ?> 'No' <? endif ?> AS showTasks,\n <? if exists("incidents") ?> 'Yes' <? else ?> 'No' <? endif ?> AS showIncdts;\n \n \n 141\n \n \n 325\n 43\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n queryParams\n showClosed\n \n \n \n \n \n \n \n \n 110\n 43\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n queryParams\n showIncdts\n \n \n \n 10\n 135\n 750\n 135\n 2\n \n \n \n \n \n \n \n \n \n \n 555\n 43\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n queryParams\n showTasks\n \n \n \n \n 10\n 63\n 725\n 15\n \n 12\n \n Arial\n 8\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n \n
\n detail\n \n ByUser\n assigned\n \n \n \n detail\n \n 31\n \n \n 630\n 0\n 115\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_parent\n \n \n \n \n 10\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n assigned\n \n \n \n \n 230\n 15\n 520\n 15\n \n 0\n \n Arial\n 8\n bold\n \n \n \n \n detail\n notes\n \n \n \n \n 435\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n stage\n \n \n \n \n 100\n 0\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n type\n \n \n \n \n 165\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n priority\n \n \n \n \n 540\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n due\n \n \n \n \n 230\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n name\n \n \n \n
\n \n 16\n \n \n \n \n 90\n 1\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 1\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 253 TrialBalances \N \n\n Trial Balances\n TrialBalances\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("accnt_id") ?>\n ( SELECT (accnt_number || '-' || accnt_descrip)\n FROM accnt\n WHERE (accnt_id=<? value("accnt_id") ?>) )\n <? else ?>\n text('All Accounts')\n <? endif ?>\n AS accnt,\n <? if exists("period_id") ?>\n ( SELECT (formatDate(period_start) || '-' || formatDate(period_end))\n FROM period\n WHERE (period_id=<? value("period_id") ?>) )\n <? else ?>\n text('All Periods')\n <? endif ?>\n AS period;\n \n \n \n detail\n SELECT accnt_id,\n period_id,\n formatDate(period_start) AS f_start,\n formatDate(period_end) AS f_end,\n formatGLAccount(accnt_id) AS f_account,\n accnt_descrip,\n formatMoney(abs(trialbal_beginning)) AS f_beginning,\n CASE WHEN(trialbal_beginning>0) THEN text('CR')\n ELSE text('')\n END AS f_beginningcr,\n formatMoney(trialbal_debits) AS f_debits,\n formatMoney(trialbal_credits) AS f_credits,\n formatMoney(abs(trialbal_debits - trialbal_credits)) AS f_diff,\n CASE WHEN((trialbal_debits - trialbal_credits) < 0) THEN text('CR')\n ELSE text('')\n END AS f_diffcr,\n formatMoney(abs(trialbal_ending)) AS f_ending,\n CASE WHEN(trialbal_ending>0) THEN text('CR')\n ELSE text('')\n END AS f_endingcr\n FROM trialbal, accnt, period\n WHERE ((trialbal_accnt_id=accnt_id)\n AND (trialbal_period_id=period_id)\n<? if exists("accnt_id") ?>\n AND (trialbal_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n<? if exists("period_id") ?>\n AND (period_id=<? value("period_id") ?>)\n<? endif ?>\n<? if not exists("showZero") ?>\n AND (abs(trialbal_beginning)+abs(trialbal_ending)+abs(trialbal_debits)+abs(trialbal_credits) > 0) \n<? endif ?>\n )\nORDER BY period_start, formatGLAccount(accnt_id);\n \n \n total\n SELECT formatMoney(abs(beginning)) AS f_beginning,\n CASE WHEN(beginning<0) THEN text('CR')\n ELSE text('')\n END AS f_beginningcr,\n formatMoney(debits) AS f_debits,\n formatMoney(credits) AS f_credits,\n formatMoney(abs(debits - credits)) AS f_diff,\n CASE WHEN((debits - credits) < 0) THEN text('CR')\n ELSE text('')\n END AS f_diffcr,\n formatMoney(abs(ending)) AS f_ending,\n CASE WHEN(ending<0) THEN text('CR')\n ELSE text('')\n END AS f_endingcr\n FROM ( SELECT SUM(trialbal_beginning*-1) AS beginning,\n SUM(trialbal_debits) AS debits,\n SUM(trialbal_credits) AS credits,\n SUM(trialbal_ending*-1) AS ending\n FROM trialbal, accnt, period\n WHERE ((trialbal_accnt_id=accnt_id)\n AND (trialbal_period_id=period_id)\n<? if exists("accnt_id") ?>\n AND (trialbal_accnt_id=<? value("accnt_id") ?>)\n<? endif ?>\n<? if exists("period_id") ?>\n AND (period_id=<? value("period_id") ?>)\n<? endif ?>\n )\n ) AS data;\n \n \n 191\n \n \n \n \n \n \n \n \n \n 5\n 185\n 990\n 185\n 2\n \n \n \n \n \n 10\n 38\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n 5\n 30\n 990\n 30\n 2\n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 31\n \n \n 475\n 0\n 30\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_beginningcr\n \n \n \n \n 105\n 0\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_end\n \n \n \n \n 965\n 0\n 30\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_endingcr\n \n \n \n \n 510\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_debits\n \n \n \n \n 370\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_beginning\n \n \n \n \n 615\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_credits\n \n \n \n \n 200\n 15\n 140\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n accnt_descrip\n \n \n \n \n 10\n 0\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_start\n \n \n \n \n 860\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_ending\n \n \n \n \n 720\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_diff\n \n \n \n \n 825\n 0\n 30\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_diffcr\n \n \n \n \n 200\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_account\n \n \n \n
\n \n 17\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 21\n \n \n 370\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n total\n f_beginning\n \n \n \n \n 720\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n total\n f_diff\n \n \n \n \n 510\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n total\n f_debits\n \n \n \n \n 615\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n total\n f_credits\n \n \n \n \n 860\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n total\n f_ending\n \n \n \n \n \n 965\n 0\n 30\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n total\n f_endingcr\n \n \n \n \n 475\n 0\n 30\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n total\n f_beginningcr\n \n \n \n \n 825\n 0\n 30\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n total\n f_diffcr\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 223 UOMs \N \n\n Units of Measure\n UOMs\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT uom_name,\n uom_descrip\n FROM uom\nORDER BY uom_name;\n \n \n 76\n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n \n 6\n \n \n 21\n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 10\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n \n 175\n 0\n 565\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_descrip\n \n \n \n
\n \n 16\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 268 UnappliedAPCreditMemos \N \n\n Unapplied A/P Credit Memos\n UnappliedAPCreditMemos\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT apopen_id, apopen_docnumber,\n (vend_number || '-' || vend_name) AS vendor,\n formatMoney(apopen_amount) AS f_amount,\n formatMoney(apopen_paid) AS f_paid,\n formatMoney(apopen_amount - apopen_paid) AS f_balance\nFROM apopen, vendinfo\nWHERE ( (apopen_doctype='C')\n AND (apopen_open)\n AND (apopen_vend_id=vend_id)\n<? if exists("vend_id") ?>\n AND (vend_id=<? value("vend_id") ?>)\n<? elseif exists("vendtype_id") ?>\n AND (vend_vendtype_id=<? value("vendtype_id") ?>)\n<? elseif exists("vendtype_pattern") ?>\n AND (vend_vendtype_id IN (SELECT vendtype_id\n FROM vendtype\n WHERE (vendtype_code ~ <? value("vendtype_pattern") ?>)))\n<? endif ?>\n)\nORDER BY apopen_docnumber;\n \n \n 77\n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n \n \n \n 6\n \n \n 26\n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 17\n \n \n 645\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_balance\n \n \n \n \n 10\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n apopen_docnumber\n \n \n \n \n 540\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_paid\n \n \n \n \n 434\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_amount\n \n \n \n \n 100\n 0\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vendor\n \n \n \n
\n \n 17\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 269 UnappliedARCreditMemos \N \n\n Unapplied A/R Credit Memos\n UnappliedARCreditMemos\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n arCreditMemos\n unapplied\n \n \n 77\n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n \n \n \n 6\n \n \n 26\n \n \n 5\n 20\n 745\n 20\n 2\n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 17\n \n \n 645\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_balance\n \n \n \n \n 10\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n aropen_docnumber\n \n \n \n \n 540\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_applied\n \n \n \n \n 434\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_amount\n \n \n \n \n 190\n 1\n 255\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_name\n \n \n \n \n 100\n 1\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_number\n \n \n \n
\n \n 17\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 355 UnpostedGLTransactions \N \n\n Unposted G/L Transactions\n UnpostedGLTransactions\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n <? if exists("period_id") ?>\nSELECT formatDate(period_start, 'Earliest') AS startdate,\n formatDate(period_end, 'Latest') AS enddate,\n period_name\nFROM period\nWHERE (period_id=<? value("period_id") ?>);\n<? else ?>\nSELECT 'Earliest' AS startdate,\n 'Latest' AS enddate,\n 'All Periods' AS period_name;\n<? endif ?>\n \n \n detail\n SELECT gltrans_id,\n formatDate(gltrans_date) AS transdate,\n gltrans_source,\n gltrans_doctype,\n gltrans_docnumber,\n invhist_docnumber,\n firstLine(gltrans_notes) AS transnotes,\n (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,\n-- Debits:\n CASE WHEN (gltrans_amount < 0) THEN formatMoney(ABS(gltrans_amount))\n ELSE ''\n END AS f_debit, \n CASE WHEN (gltrans_amount < 0) THEN ABS(gltrans_amount)\n ELSE 0\n END AS debit_amt, \n--Credits:\n CASE WHEN (gltrans_amount > 0) THEN formatMoney(gltrans_amount)\n ELSE ''\n END AS f_credit,\n CASE WHEN (gltrans_amount > 0) THEN gltrans_amount\n ELSE 0\n END AS credit_amt,\n--Balance:\n gltrans_amount * -1 as balance_amt\n--\n FROM period, gltrans JOIN accnt ON (gltrans_accnt_id=accnt_id)\n LEFT OUTER JOIN invhist ON (gltrans_misc_id=invhist_id AND gltrans_docnumber='Misc.')\nWHERE (NOT gltrans_posted\n AND (NOT gltrans_deleted)\n AND (gltrans_date BETWEEN period_start AND period_end)\n<? if exists("period_id") ?>\n AND (period_id=<? value("period_id") ?>)\n<? endif ?>\n)\nORDER BY gltrans_created, gltrans_sequence, gltrans_amount;\n \n \n 205\n \n \n \n \n \n 545\n 70\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n startdate\n \n \n \n \n \n 140\n 70\n 290\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n period_name\n \n \n \n \n \n \n \n \n \n \n 545\n 90\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n enddate\n \n \n \n 0\n 200\n 1000\n 200\n 2\n \n \n \n \n \n \n 5\n \n \n 45\n \n \n \n 0\n 40\n 1000\n 40\n 2\n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 31\n \n \n 310\n 0\n 270\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n account\n \n \n \n \n 12500\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_doctype\n \n \n \n \n 208\n 15\n 95\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n invhist_docnumber\n \n \n \n \n 0\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n transdate\n \n \n \n \n 125\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_doctype\n \n \n \n \n 204\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_docnumber\n \n \n \n \n 310\n 15\n 265\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n transnotes\n \n \n \n \n 720\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_credit\n \n \n \n \n 65\n 0\n 60\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n gltrans_source\n \n \n \n \n 605\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_debit\n \n \n \n
\n \n \n 75\n \n \n 835\n 25\n 105\n 14\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n balance_amt\n \n money\n \n \n \n \n \n 605\n 5\n 1015\n 5\n 2\n \n \n \n \n 960\n 60\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 60\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 720\n 25\n 105\n 14\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n credit_amt\n \n money\n \n \n \n \n \n 605\n 25\n 105\n 14\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n debit_amt\n \n money\n \n \n \n \n 15\n \n \n \n 960\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 354 UnpostedGlSeries \N \n\n Unposted G/L Series Transactions\n UnpostedGlSeries\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT *, glseries_sequence,\n (formatGLAccount(glseries_accnt_id) || ' - ' ||\n accnt_descrip) AS account,\n CASE WHEN (glseries_amount < 0) THEN\n formatMoney(glseries_amount * -1)\n ELSE '' END AS debit,\n CASE WHEN (glseries_amount >= 0) THEN\n formatMoney(glseries_amount)\n ELSE '' END AS credit\nFROM glseries, accnt\nWHERE (glseries_accnt_id=accnt_id)\nORDER BY glseries_distdate, glseries_sequence, glseries_amount;\n \n \n 75\n \n \n \n \n \n \n \n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n 11\n \n \n 51\n \n \n \n \n \n \n 5\n 40\n 740\n 40\n 2\n \n \n \n \n \n
\n detail\n \n glseries_sequence\n glseries_sequence\n \n 11\n \n 10\n 0\n 40\n 0\n 0\n \n \n \n \n \n detail\n \n 21\n \n \n 610\n 0\n 150\n 11\n \n 0\n \n Arial\n 8\n bold\n \n \n \n \n detail\n glseries_notes\n \n \n \n \n 95\n 0\n 45\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n glseries_source\n \n \n \n \n 310\n 0\n 130\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n account\n \n \n \n \n 0\n 0\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n glseries_distdate\n \n \n \n \n 530\n 0\n 70\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n credit\n \n \n \n \n 450\n 0\n 70\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n debit\n \n \n \n \n 200\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n glseries_docnumber\n \n \n \n \n 145\n 0\n 45\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n glseries_doctype\n \n \n \n
\n \n 15\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 356 UnpostedPoReceipts \N \n\n Unposted Purchase Order Receipts\n UnpostedPoReceipts\n \n \n \n \n \n \n \n \n \n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT recv_id, recv_orderitem_id, recv_order_number, recv_order_type,\n orderhead_from,\n orderitem_linenumber,\n formatDate(recv_duedate) AS recv_duedate,\n warehous_code,\n COALESCE(item_number, <? value("nonInventory") ?>) AS item_number,\n COALESCE(uom_name, <? value("na") ?>) AS uom_name,\n recv_vend_item_number,\n recv_vend_uom,\n formatQty(orderitem_qty_ordered) AS qty_ordered,\n formatQty(orderitem_qty_received) AS qty_received,\n formatQty(recv_qty) AS recv_qty,\n formatDate(recv_date) AS recv_date,\n formatDate(COALESCE(recv_gldistdate, recv_date)) AS recv_gldistdate\nFROM orderhead JOIN\n orderitem ON ((orderitem_orderhead_id=orderhead_id)\n\t AND (orderitem_orderhead_type=orderhead_type)) JOIN \n recv ON ((recv_orderitem_id=orderitem_id)\n\t AND (recv_order_type=orderitem_orderhead_type)) LEFT OUTER JOIN\n (itemsite JOIN item ON (itemsite_item_id=item_id)\n\t JOIN uom ON (item_inv_uom_id=uom_id)\n JOIN site() ON (itemsite_warehous_id=warehous_id)\n )\n ON (recv_itemsite_id=itemsite_id) LEFT OUTER JOIN\n vendinfo ON (orderhead_type='PO' AND orderhead_from_id=vend_id)\nWHERE (NOT recv_posted)\nORDER BY orderhead_from, recv_order_number, orderitem_linenumber;\n\n \n \n 76\n \n 5\n 70\n 745\n 70\n 2\n \n \n \n
\n detail\n \n ponumber\n recv_order_number\n \n 51\n \n \n \n \n \n 100\n 0\n 27\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n recv_order_type\n \n \n \n \n \n 100\n 15\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n orderhead_from\n \n \n \n \n \n \n \n 135\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n recv_order_number\n \n \n \n \n \n \n \n \n \n \n \n detail\n \n 21\n \n \n 685\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n recv_date\n \n \n \n \n 130\n 0\n 100\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n item_number\n \n \n \n \n 395\n 0\n 40\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n recv_vend_uom\n \n \n \n \n 0\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n orderitem_linenumber\n \n \n \n \n 285\n 0\n 100\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n recv_vend_item_number\n \n \n \n \n 520\n 0\n 70\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n qty_received\n \n \n \n \n 40\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n recv_duedate\n \n \n \n \n 240\n 0\n 40\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n uom_name\n \n \n \n \n 600\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n recv_qty\n \n \n \n \n 440\n 0\n 70\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n detail\n qty_ordered\n \n \n \n
\n \n 16\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 357 UnpostedReturnsForPO \N \n\n Unposted Returns For Purchase Order\n UnpostedReturnsForPO\n \n Letter\n \n 100\n 100\n 50\n 50\n \n address\n select formatAddr(<? value("addr_id") ?>) AS f_addr;\n \n \n detail\n SELECT poitem_linenumber,\n COALESCE(item_number, 'Non-Inventory') AS item_number,\n COALESCE(uom_name, 'N/A') AS uom_name,\n poitem_vend_item_number, poitem_vend_uom,\n formatQty(poitem_qty_ordered) AS f_poitem_qty_ordered,\n formatQty(poitem_qty_received) AS f_poitem_qty_received,\n formatQty(poitem_qty_returned) AS f_poitem_qty_returned,\n formatQty(SUM(COALESCE(poreject_qty, 0))) AS f_poreject_qty,\n rjctcode_code\nFROM poreject LEFT OUTER JOIN rjctcode ON (poreject_rjctcode_id=rjctcode_id),\n poitem LEFT OUTER JOIN\n ( itemsite JOIN item\n ON (itemsite_item_id=item_id) JOIN uom ON (item_inv_uom_id=uom_id)\n ) ON (poitem_itemsite_id=itemsite_id)\nWHERE ((poreject_poitem_id=poitem_id)\n AND (NOT poreject_posted)\n AND (poitem_pohead_id=<? value("pohead_id") ?>))\nGROUP BY\n poitem_linenumber,\n item_number,\n uom_name,\n poitem_vend_item_number,\n poitem_vend_uom,\n poitem_qty_ordered,\n poitem_qty_received,\n poitem_qty_returned,\n rjctcode_code\nORDER BY poitem_linenumber;\n \n \n pohead\n SELECT *\nFROM pohead, vendinfo\nWHERE ((pohead_vend_id=vend_id)\n AND (pohead_id=<? value("pohead_id") ?>));\n \n \n logo\n SELECT image_data \nFROM image \nWHERE ((image_name='logo'));\n \n \n 127\n \n \n \n 5\n 5\n 155\n 95\n \n stretch\n \n logo\n image_data\n \n \n \n 0\n 113\n 740\n 113\n 2\n \n \n
\n Address\n \n \n address\n \n 23\n \n \n \n 60\n 0\n 500\n 18\n \n 11\n \n Arial\n 10\n bold\n \n \n \n \n address\n f_addr\n \n \n \n
\n
\n POHead\n \n \n pohead\n \n 107\n \n \n \n \n \n 100\n 41\n 100\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n pohead\n vend_number\n \n \n \n \n \n \n \n 100\n 30\n 100\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n pohead\n pohead_number\n \n \n \n 0\n 95\n 740\n 95\n 0\n \n \n \n \n \n \n
\n
\n detail\n \n \n detail\n \n 42\n \n \n 355\n 0\n 85\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_poitem_qty_received\n \n \n \n \n 200\n 0\n 100\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n poitem_vend_item_number\n \n \n \n \n 570\n 0\n 85\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_poreject_qty\n \n \n \n \n 45\n 15\n 645\n 11\n \n 1\n \n Arial\n 8\n bold\n \n \n \n \n detail\n rjctcode_code\n \n \n \n \n 310\n 0\n 40\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n poitem_vend_uom\n \n \n \n \n 1\n 0\n 35\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n poitem_linenumber\n \n \n \n \n 459\n 0\n 90\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_poitem_qty_returned\n \n \n \n \n \n 150\n 0\n 40\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n \n 40\n 0\n 100\n 11\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n
\n \n 23\n \n \n \n \n 90\n 0\n 100\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 700\n 0\n 40\n 11\n \n \n Arial\n 8\n normal\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 222 UnusedPurchasedItems \N \n\n Unused Purchased Items\n UnusedPurchasedItems\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT <? if exists("classcode_id") ?>\n ( SELECT (classcode_code||'-'||classcode_descrip)\n FROM classcode\n WHERE (classcode_id=<? value("classcode_id") ?>) )\n <? elseif exists("classcode_pattern") ?>\n text(<? value("classcode_pattern") ?>)\n <? else ?>\n text('All Class Codes')\n <? endif ?>\n AS classcode,\n <? if exists("includeUncontrolledItems") ?>\n text('Showing Uncontrolled Items')\n <? else ?>\n text('')\n <? endif ?>\n AS lbl_showuncontrolled\n \n \n detail\n SELECT DISTINCT item_id,\n item_number,\n item_descrip1,\n item_descrip2,\n uom_name,\n formatQty(SUM(itemsite_qtyonhand)) AS f_qoh,\n formatDate(MAX(itemsite_datelastcount), 'Never') AS f_lastcntd,\n formatDate(MAX(itemsite_datelastused), 'Never') AS f_lastused\n FROM item, itemsite, uom\n WHERE ((itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (item_id NOT IN (SELECT DISTINCT bomitem_item_id FROM bomitem))\n AND (NOT item_sold)\n AND (item_type IN ('P', 'O'))\n<? if exists("classcode_id") ?>\n AND (item_classcode_id=<? value("classcode_id") ?>)\n<? elseif exists("classcode_pattern") ?>\n AND (item_classcode_id IN (SELECT classcode_id\n FROM classcode\n WHERE (classcode_code ~ <? value("classcode_pattern") ?>)))\n<? endif ?>\n<? if not exists("includeUncontrolledItems") ?>\n AND (itemsite_controlmethod <> 'N')\n<? endif ?>\n)\nGROUP BY item_id, item_number, uom_name, item_descrip1, item_descrip2\nORDER BY item_number;\n \n \n 236\n \n \n 130\n 120\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n classcode\n \n \n \n \n \n \n 440\n 120\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n lbl_showuncontrolled\n \n \n \n 5\n 229\n 745\n 229\n 2\n \n \n \n \n \n \n \n \n \n \n 6\n \n \n 37\n \n \n 5\n 30\n 745\n 31\n 2\n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 51\n \n \n 509\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_lastused\n \n \n \n 5\n 45\n 745\n 45\n 0\n \n \n \n 425\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_lastcntd\n \n \n \n \n 15\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 15\n 15\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 320\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qoh\n \n \n \n \n 225\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n uom_name\n \n \n \n \n 15\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip2\n \n \n \n
\n \n 16\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 458 UsageStatistics \N \n\n Item Usage Statistics\n UsageStatistics\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n usageStatistics\n detail\n \n \n 221\n \n \n \n \n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n \n \n 10\n 38\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 37\n \n \n 425\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_sold\n \n \n \n \n 10\n 0\n 35\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n 3\n 31\n 743\n 31\n 0\n \n \n \n 665\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_transfer\n \n \n \n \n 505\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_scrap\n \n \n \n \n 585\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_adjust\n \n \n \n \n 345\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_issued\n \n \n \n \n 65\n 15\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemdescrip\n \n \n \n \n 65\n 0\n 185\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 260\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_received\n \n \n \n
\n \n 16\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 106 UsersMasterList \N \n\n User Accounts Master List\n UsersMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n select usr_username,\n usr_propername,\n usr_initials,\n formatBoolYN(usr_active) AS f_active,\n formatBoolYN(usr_agent) AS f_pa,\n locale_code\n FROM usr, locale\n WHERE ((usr_locale_id=locale_id)\n<? if not exists("showInactive") ?>\n AND (usr_active=true)\n<? endif ?>\n)\nORDER BY usr_username;\n \n \n 76\n \n \n \n \n \n \n \n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 434\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_pa\n \n \n \n \n 114\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_active\n \n \n \n \n 375\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n usr_initials\n \n \n \n \n 170\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n usr_propername\n \n \n \n \n 10\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n usr_username\n \n \n \n \n 500\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n locale_code\n \n \n \n
\n \n 16\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 483 UserPrivileges \N \n\n User Privileges Report\n UserPrivileges\n Display of User Roles and Privilege assignments\n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n role\n permissions\n role\n \n \n priv\n permissions\n privileges\n \n \n 60\n \n \n
\n role_detail\n \n roleuser\n role_username\n \n 50\n \n \n 85\n 5\n 165\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n role\n role_username\n \n \n \n \n 5\n 5\n 740\n 5\n 0\n \n \n \n \n \n \n \n role\n \n 16\n \n \n 160\n 0\n 235\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n role\n grp_name\n \n \n \n \n 405\n 0\n 335\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n role\n grp_descrip\n \n \n \n
\n
\n priv_detail\n \n priv_user\n priv_username\n \n 49\n \n \n \n \n \n 85\n 4\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n priv\n priv_username\n \n \n \n \n 5\n 4\n 740\n 4\n 0\n \n \n \n \n \n \n priv\n \n 15\n \n \n 95\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n priv\n priv_module\n \n \n \n \n 185\n 0\n 160\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n priv\n priv_name\n \n \n \n \n 0\n 0\n 85\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n priv\n grp_name\n \n \n \n \n 355\n 0\n 385\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n priv\n priv_descrip\n \n \n \n
\n \n 16\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 105\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 31\n \n
\n Display of User Roles and Privilege assignments 1 2015-10-01 17:15:58.47729 8 ValidLocationsByItem \N \n\n Valid Locations By Item\n ValidLocationsByItem\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT item_number,\n item_descrip1,\n item_descrip2,\n <? if exists("warehous_id") ?>\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) )\n <? else ?>\n text('All Sites')\n <? endif ?>\n AS warehouse\n FROM item\n WHERE (item_id=<? value("item_id") ?>);\n\n \n \n detail\n SELECT warehous_code,\n formatLocationName(location_id) AS locationname,\n firstLine(location_descrip) as f_descrip,\n formatBoolYN(location_restrict) AS restricted,\n formatBoolYN(location_netable) AS netable\n FROM itemsite, location, whsinfo\n WHERE ((validLocation(location_id, itemsite_id))\n AND ((itemsite_loccntrl) OR (itemsite_location_id=location_id))\n AND (itemsite_item_id=<? value("item_id") ?>)\n AND (itemsite_warehous_id=warehous_id)\n<? if exists("warehous_id") ?>\n AND (warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n)\n\nORDER BY warehous_code, locationname;\n \n \n 221\n \n \n 100\n 120\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n 100\n 80\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n \n \n \n 100\n 145\n 200\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n \n 100\n 100\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n 5\n 215\n 745\n 215\n 2\n \n \n \n \n \n 6\n \n \n 21\n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 10\n 0\n 45\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 640\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n netable\n \n \n \n \n 555\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n restricted\n \n \n \n \n 70\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n locationname\n \n \n \n \n 235\n 0\n 310\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_descrip\n \n \n \n
\n \n 16\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 300 VendorAddressList \N \n\n Vendor Address List\n VendorAddressList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT vend_number, vend_name\n FROM vendinfo\n WHERE (vend_id=<? value("vend_id") ?>);\n \n \n \n detail\n SELECT vendaddr_code as num,\n vendaddr_name as name,\n addr_line1 AS address,\n (addr_city || ', ' || addr_state || ' ' || addr_postalcode) AS citystatezip\n FROM vendaddrinfo\n LEFT OUTER JOIN addr ON (vendaddr_addr_id=addr_id)\n WHERE (vendaddr_vend_id=<? value("vend_id") ?>) \nORDER BY vendaddr_code;\n \n \n 171\n \n \n \n \n \n \n 135\n 70\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n vend_number\n \n \n \n \n 5\n 165\n 745\n 165\n 2\n \n \n \n \n 135\n 90\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n vend_name\n \n \n \n \n \n 6\n \n \n 21\n \n \n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n
\n detail\n \n \n detail\n \n 17\n \n \n 5\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n num\n \n \n \n \n 65\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n name\n \n \n \n \n 545\n 0\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n citystatezip\n \n \n \n \n 270\n 0\n 250\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n address\n \n \n \n
\n \n 17\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 105\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 142 VendorMasterList \N \n\n Vendor Master List\n VendorMasterList\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n vendors\n detail\n \n \n 153\n \n \n \n \n \n 8\n 149\n 748\n 149\n 2\n \n \n \n 10\n 43\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 6\n \n \n 36\n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n
\n detail\n \n \n detail\n \n 91\n \n \n 175\n 30\n 565\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n addr_line2\n \n \n \n \n 515\n 60\n 204\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n addr_zip\n \n \n \n \n 175\n 0\n 565\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_name\n \n \n \n \n 175\n 15\n 565\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n addr_line1\n \n \n \n \n 175\n 60\n 204\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n addr_city\n \n \n \n \n 10\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vend_number\n \n \n \n \n 175\n 45\n 565\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n addr_line3\n \n \n \n \n 370\n 60\n 140\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n addr_state\n \n \n \n
\n \n 21\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 186 VendorTypesMasterList \N \n\n Vendor Types Master List\n VendorTypesMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT vendtype_id,\n vendtype_code,\n vendtype_descrip\n FROM vendtype\nORDER BY vendtype_code;\n \n \n 76\n \n \n 5\n 70\n 745\n 70\n 2\n \n \n \n \n \n \n 6\n \n \n 21\n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 16\n \n \n 175\n 0\n 565\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vendtype_descrip\n \n \n \n \n 10\n 0\n 150\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vendtype_code\n \n \n \n
\n \n 16\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 87 WOHistoryByNumber \N \n\n Work Order History by Number\n WOHistoryByNumber\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n Detail\n SELECT formatWoNumber(wo_id) AS number,\n wo_subnumber AS subnumber,\n wo_status, warehous_code,\n item_number, item_descrip1, item_descrip2, uom_name,\n formatQty(wo_qtyord) AS ordered,\n formatQty(wo_qtyrcv) AS received,\n formatDate(wo_startdate) AS startdate,\n formatDate(wo_duedate) AS duedate,\n <? if exists("showCosts") ?>\n text('W/O Cost') AS lbl_value,\n formatCost(wo_postedvalue) AS value\n <? else ?>\n text('') AS lbl_value,\n text('') AS value\n <? endif ?>\n FROM wo, itemsite, whsinfo, item, uom\n WHERE ((wo_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (CAST(wo_number AS TEXT) ~ <? value("woNumber") ?>)\n<? if exists("showOnlyTopLevel") ?>\n AND ((wo_ordtype<>'W') OR (wo_ordtype IS NULL))\n<? endif ?>\n )\nORDER BY wo_subnumber;\n \n \n \n 172\n \n \n \n \n \n \n \n \n \n \n \n 135\n 85\n 170\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n woNumber\n \n \n \n \n 5\n 165\n 740\n 165\n 2\n \n \n \n \n 670\n 151\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n lbl_value\n \n \n \n \n \n 7\n \n \n 32\n \n \n \n \n \n \n \n 5\n 25\n 740\n 25\n 2\n \n \n \n \n \n \n 665\n 13\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n lbl_value\n \n \n \n
\n detail\n \n \n Detail\n \n 52\n \n \n 125\n 15\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n item_descrip1\n \n \n \n \n 5\n 0\n 55\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n number\n \n \n \n \n 125\n 30\n 300\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n item_descrip2\n \n \n \n \n 270\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n ordered\n \n \n \n \n 350\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n received\n \n \n \n \n 670\n 0\n 70\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n value\n \n \n \n \n 65\n 0\n 20\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n wo_status\n \n \n \n \n 85\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n warehous_code\n \n \n \n \n 430\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n startdate\n \n \n \n 5\n 45\n 740\n 45\n 0\n \n \n \n 508\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n duedate\n \n \n \n \n 228\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n uom_name\n \n \n \n \n 125\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n item_number\n \n \n \n
\n \n 17\n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 95\n 0\n 112\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 279 WOLabel \N \n\n WO Order Label\n WOLabel\n Labels generated for use in labeling parts out of a work order\n \n \n \n 0.05\n 0.05\n \n \n 400\n 333\n \n \n 25\n 25\n 25\n 25\n \n detail\n SELECT \n sequence_value,\n formatDate(wo_duedate) AS due_date, \n item_number,\n item_descrip1,\n COALESCE(prodcat_descrip, '') AS prodcat_descrip \n FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN sequence ON (sequence.sequence_value BETWEEN 1 AND <? value("labelTo") ?>)\n LEFT OUTER JOIN prodcat ON (prodcat_id=item_prodcat_id)\nWHERE (wo_id=<? value("wo_id") ?>);\n\n \n
\n detail\n \n \n detail\n \n 218\n \n \n 10\n 150\n 330\n 25\n \n \n Arial\n 12\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 10\n 95\n 330\n 25\n \n \n Arial\n 12\n bold\n \n \n \n \n detail\n prodcat_descrip\n \n \n \n \n 10\n 180\n 330\n 25\n \n 3of9\n 5\n \n 0.01\n \n detail\n item_number\n \n \n \n \n 150\n 35\n 120\n 18\n \n \n Arial\n 12\n bold\n \n \n \n \n detail\n due_date\n \n \n \n \n 75\n 125\n 265\n 18\n \n \n Arial\n 12\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n
\n
\n Labels generated for use in labeling parts out of a work order 0 2015-10-01 17:15:58.47729 280 WOLabelForm \N \n\n WO Order Label\n WOLabelForm\n Labels generated for use in labeling parts out of a work order\n \n 275\n 212\n \n \n 25\n 25\n 25\n 25\n \n detail\n SELECT \n sequence_value,\n formatDate(wo_duedate) AS due_date, \n item_number,\n item_descrip1,\n prodcat_descrip \n FROM \n wo, \n itemsite,\n item,\n prodcat,\n sequence\nWHERE ( (wo_itemsite_id = itemsite_id)\nAND (wo_id=<? value("wo_id") ?>)\nAND (item_prodcat_id = prodcat_id)\nAND (itemsite_item_id = item_id)\nAND (sequence.sequence_value \nBETWEEN 1 AND 1));\n \n
\n detail\n \n \n detail\n \n 214\n \n \n 21\n 91\n 192\n 25\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n prodcat_descrip\n \n \n \n \n 10\n 182\n 212\n 25\n \n 3of9\n 5\n
\n \n detail\n item_number\n \n \n \n \n \n 62\n 122\n 265\n 17\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 145\n 5\n 77\n 17\n \n \n Arial\n 9\n bold\n \n \n \n \n detail\n due_date\n \n \n \n \n 20\n 151\n 185\n 25\n \n \n Arial\n 10\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n
\n
\n Labels generated for use in labeling parts out of a work order 0 2015-10-01 17:15:58.47729 90 WOMaterialAvailabilityByWorkOrder \N \n\n W/O Material Availability By Work Order\n WOMaterialAvailabilityByWorkOrder\n \n Letter\n \n 50\n 50\n 50\n 50\n \n head\n SELECT formatWONumber(wo_id) AS wonumber,\n warehous_code as warehouse,\n item_number, item_descrip1, item_descrip2, uom_name,\n wo_status AS status, \n <? if exists("onlyShowShortages") ?>\n text('Only Show Shortages')\n <? elseif exists("onlyShowInsufficientInventory") ?>\n text('Only Show Insufficient Inventory')\n <? else ?>\n text('All Materials')\n <? endif ?>\n AS itemfiltertext,\n <? if exists("IndentedParentChild") ?>\n text('Indented Works Orders')\n <? elseif exists("summarizedParentChild") ?>\n text('Summarized Parent/Child Orders')\n <? else ?>\n text('Parent Order Only')\n <? endif ?>\n AS wofiltertext\n FROM wo, itemsite, item, uom, whsinfo\n WHERE ((wo_itemsite_id=itemsite_id)\n AND (itemsite_item_id=item_id)\n AND (item_inv_uom_id=uom_id)\n AND (itemsite_warehous_id=warehous_id)\n AND (wo_id=<? value("wo_id") ?>) );\n \n \n detail\n SELECT *, (REPEAT(' ',(woinvav_level-1)*3) || woinvav_item_wo_number) AS itemwonumber FROM woinvavail(<? value("wo_id") ?>,\n<? if exists("IndentedParentChild") ?>\ntrue, \n <? else ?>\nfalse, \n<? endif ?>\n<? if exists("summarizedParentChild") ?>\ntrue, \n <? else ?>\nfalse, \n<? endif ?>\n<? if exists("onlyShowShortages") ?>\ntrue, \n <? else ?>\nfalse, \n<? endif ?>\n<? if exists("onlyShowInsufficientInventory") ?>\ntrue) \n <? else ?>\nfalse) \n<? endif ?>\n \n \n 236\n \n \n \n 325\n 100\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n uom_name\n \n \n \n \n \n \n 100\n 75\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n warehouse\n \n \n \n \n \n 100\n 100\n 150\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_number\n \n \n \n \n \n 100\n 55\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n wonumber\n \n \n \n \n \n \n \n 5\n 229\n 745\n 229\n 2\n \n \n \n 100\n 120\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip1\n \n \n \n \n 100\n 165\n 100\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n status\n \n \n \n \n \n \n \n \n 100\n 140\n 300\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n item_descrip2\n \n \n \n \n \n \n \n 325\n 55\n 365\n 18\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n itemfiltertext\n \n \n \n \n 325\n 75\n 365\n 18\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n wofiltertext\n \n \n \n \n \n \n 6\n \n \n 36\n \n \n \n \n \n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n
\n detail\n \n \n detail\n \n 32\n \n \n 350\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n woinvav_balance\n \n \n \n \n 270\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n woinvav_qoh\n \n \n \n \n 670\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n woinvav_totalavail\n \n \n \n \n 430\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n woinvav_allocated\n \n \n \n \n 509\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n woinvav_ordered\n \n \n \n \n 10\n 0\n 170\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemwonumber\n \n \n \n 0\n 29\n 750\n 29\n 0\n \n \n \n 190\n 15\n 555\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n woinvav_descrip\n \n \n \n \n 590\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n woinvav_woavail\n \n \n \n \n 190\n 0\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n woinvav_uomname\n \n \n \n
\n \n 16\n \n \n \n \n 695\n 0\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 451 WOSchedule \N \n\n Work Order Schedule\n WOSchedule\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n Detail\n workOrderSchedule\n detail\n \n \n Head\n SELECT formatDate(<? value("startDate") ?>, 'Earliest') AS f_startdate,\n formatDate(<? value("endDate") ?>, 'Latest') AS f_enddate,\n<? if exists("warehous_id") ?>\n warehous_code\nFROM whsinfo\nWHERE (warehous_id=<? value("warehous_id") ?>);\n<? else ?>\n TEXT('All Sites') AS warehous_code;\n<? endif ?>\n\n \n \n 191\n \n 5\n 185\n 740\n 185\n 2\n \n \n \n \n \n \n \n \n \n \n \n \n \n 10\n 38\n 725\n 15\n \n 12\n \n Arial\n 10\n bold\n \n \n \n \n Parameter Query\n filter\n \n \n \n \n \n 6\n \n \n 31\n \n \n \n \n \n \n \n \n 5\n 25\n 740\n 25\n 2\n \n \n \n \n
\n detail\n \n \n Detail\n \n 52\n \n \n 405\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n ordered\n \n \n \n \n 190\n 30\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n item_descrip2\n \n \n \n \n 360\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n uom_name\n \n \n \n \n 190\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n item_number\n \n \n \n \n 140\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n warehous_code\n \n \n \n \n 490\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n received\n \n \n \n \n 10\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n wonumber\n \n \n \n 5\n 45\n 740\n 45\n 0\n \n \n \n 190\n 15\n 200\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n item_descrip1\n \n \n \n \n 95\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n wo_status\n \n \n \n \n 575\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n startdate\n \n \n \n \n 660\n 0\n 80\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Detail\n duedate\n \n \n \n
\n \n 17\n \n \n 95\n 0\n 112\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n
\n 0 2015-10-01 17:15:58.47729 413 WarehouseLocationMasterList \N \n\n Warehouse Location Master List\n WarehouseLocationMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT (warehous_code || ' ' || location_name) AS whs_bin,\n warehous_code,\n formatLocationName(location_id) AS locationname,\n location_descrip,\n formatBoolYN(location_netable) AS f_netable,\n formatBoolYN(location_restrict) AS f_restrict,\n item_number,\n (item_descrip1 || ' ' || item_descrip2) AS itemdesc\n FROM location LEFT OUTER JOIN\n (SELECT locitem_location_id,\n item_number,\n item_descrip1,\n item_descrip2\n FROM locitem, item\n WHERE locitem_item_id=item_id) AS itemlocation\n ON (locitem_location_id=location_id and location_restrict=true), whsinfo\n WHERE ((location_warehous_id=warehous_id)\n<? if exists("warehous_id") ?>\n AND (warehous_id=<? value("warehous_id") ?>)\n<? endif ?>\n) ORDER BY warehous_code, location_name;\n \n \n head\n SELECT <? if exists("warehous_id") ?>\n text('Warehouse:') AS f_text,\n ( SELECT warehous_code\n FROM whsinfo\n WHERE (warehous_id=<? value("warehous_id") ?>) ) AS f_value\n <? else ?>\n text('') AS f_text,\n text('') AS f_value\n <? endif ?>\n \n \n 102\n \n \n \n 30\n 50\n 100\n 20\n \n \n Arial\n 10\n normal\n \n \n \n \n head\n f_text\n \n \n \n \n \n \n \n \n \n 140\n 50\n 175\n 20\n \n \n Arial\n 10\n bold\n \n \n \n \n head\n f_value\n \n \n \n 5\n 100\n 745\n 100\n 2\n \n \n \n \n \n 6\n \n \n 21\n \n \n \n 5\n 15\n 745\n 15\n 2\n \n \n \n \n \n \n
\n detail\n \n detail\n locationname\n \n 21\n \n \n 225\n 5\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_restrict\n \n \n \n \n 5\n 5\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 395\n 5\n 350\n 15\n \n 0\n \n Arial\n 8\n bold\n \n \n \n \n detail\n location_descrip\n \n \n \n 5\n 0\n 745\n 0\n 0\n \n \n \n 55\n 5\n 114\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n locationname\n \n \n \n \n 170\n 5\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_netable\n \n \n \n \n \n \n detail\n \n 18\n \n \n 290\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 395\n 0\n 350\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n itemdesc\n \n \n \n
\n \n 18\n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 30 WarehouseMasterList \N \n\n Warehouse Master List\n WarehouseMasterList\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n SELECT warehous_code,\n formatBoolYN(warehous_active) AS f_active,\n warehous_descrip,\n addr_line1 AS warehous_addr1,\n addr_line2 AS warehous_addr2,\n addr_line3 AS warehous_addr3,\n (addr_city || ',' || addr_state || ' ' || addr_postalcode) AS warehous_addr4,\n warehous_fob,\n warehous_bol_prefix,\n warehous_bol_number,\n formatBoolYN(warehous_shipping) AS f_shipping,\n warehous_counttag_prefix,\n warehous_counttag_number,\n formatBoolYN(warehous_useslips) as f_useslips\n FROM site() JOIN addr ON (addr_id=warehous_addr_id)\nLEFT OUTER JOIN sitetype ON (sitetype_id=warehous_sitetype_id) \nWHERE ((TRUE)\n<? if not exists("showInactive") ?>\n AND (warehous_active) \n<? endif ?>\n) ORDER BY warehous_code;\n \n \n head\n SELECT <? if exists("showInactive") ?>\n text('Showing Active and Inactive Warehouses')\n <? else ?>\n text('Showing Active Warehouses')\n <? endif ?>\n AS f_show;\n \n \n 61\n \n 5\n 55\n 745\n 55\n 2\n \n \n \n 10\n 40\n 450\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n head\n f_show\n \n \n \n \n
\n detail\n \n \n detail\n \n 151\n \n \n 615\n 110\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_shipping\n \n \n \n 5\n 145\n 745\n 145\n 0\n \n \n \n 120\n 5\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_code\n \n \n \n \n 295\n 90\n 450\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_fob\n \n \n \n \n 350\n 110\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_bol_number\n \n \n \n \n 120\n 25\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_active\n \n \n \n \n 295\n 5\n 450\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_descrip\n \n \n \n \n 295\n 110\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_bol_prefix\n \n \n \n \n \n \n 295\n 125\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_counttag_prefix\n \n \n \n \n \n 295\n 70\n 450\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_addr4\n \n \n \n \n 350\n 140\n 450\n 140\n 0\n \n \n \n 295\n 125\n 345\n 125\n 0\n \n \n \n \n \n 350\n 125\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_counttag_number\n \n \n \n 350\n 125\n 450\n 125\n 0\n \n \n \n 295\n 25\n 450\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_addr1\n \n \n \n \n \n 615\n 125\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_useslips\n \n \n \n \n 295\n 55\n 450\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_addr3\n \n \n \n \n \n 295\n 40\n 450\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n warehous_addr2\n \n \n \n 295\n 140\n 345\n 140\n 0\n \n \n
\n \n 16\n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 95\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n
\n 0 2015-10-01 17:15:58.47729 \. -- -- Name: report_report_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('report_report_id_seq', 483, true); -- -- Data for Name: rjctcode; Type: TABLE DATA; Schema: public; Owner: admin -- COPY rjctcode (rjctcode_id, rjctcode_code, rjctcode_descrip) FROM stdin; 17 DAMAGED Damaged Material 18 WRONG Wrong Item \. -- -- Name: rjctcode_rjctcode_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('rjctcode_rjctcode_id_seq', 18, true); -- -- Data for Name: rsncode; Type: TABLE DATA; Schema: public; Owner: admin -- COPY rsncode (rsncode_id, rsncode_code, rsncode_descrip, rsncode_doctype) FROM stdin; 1 PREPAY Prepayment \N 2 RETURN Return for Credit \N 3 DAMAGE Damaged \N 4 WRONG Wrong Product \N \. -- -- Name: rsncode_rsncode_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('rsncode_rsncode_id_seq', 4, true); -- -- Data for Name: sale; Type: TABLE DATA; Schema: public; Owner: admin -- COPY sale (sale_id, sale_name, sale_descrip, sale_ipshead_id, sale_startdate, sale_enddate) FROM stdin; \. -- -- Name: sale_sale_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('sale_sale_id_seq', 12, true); -- -- Data for Name: salesaccnt; Type: TABLE DATA; Schema: public; Owner: admin -- COPY salesaccnt (salesaccnt_id, salesaccnt_custtype_id, salesaccnt_prodcat_id, salesaccnt_warehous_id, salesaccnt_sales_accnt_id, salesaccnt_credit_accnt_id, salesaccnt_cos_accnt_id, salesaccnt_custtype, salesaccnt_prodcat, salesaccnt_returns_accnt_id, salesaccnt_cor_accnt_id, salesaccnt_cow_accnt_id, salesaccnt_saletype_id, salesaccnt_shipzone_id) FROM stdin; 32 -1 -1 -1 103 121 108 .* .* \N \N \N -1 -1 \. -- -- Name: salesaccnt_salesaccnt_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('salesaccnt_salesaccnt_id_seq', 32, true); -- -- Data for Name: salescat; Type: TABLE DATA; Schema: public; Owner: admin -- COPY salescat (salescat_id, salescat_active, salescat_name, salescat_descrip, salescat_sales_accnt_id, salescat_prepaid_accnt_id, salescat_ar_accnt_id) FROM stdin; 1 t PRODUCT Product Sales Category 103 121 106 2 t SERVICE Professional Services Sale 129 121 106 \. -- -- Name: salescat_salescat_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('salescat_salescat_id_seq', 2, true); -- -- Data for Name: salesrep; Type: TABLE DATA; Schema: public; Owner: admin -- COPY salesrep (salesrep_id, salesrep_active, salesrep_number, salesrep_name, salesrep_commission, salesrep_method, salesrep_emp_id) FROM stdin; 29 t 10 Inside Sales 0.0000 \N \N \. -- -- Name: salesrep_salesrep_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('salesrep_salesrep_id_seq', 29, true); -- -- Data for Name: saletype; Type: TABLE DATA; Schema: public; Owner: admin -- COPY saletype (saletype_id, saletype_code, saletype_descr, saletype_active, saletype_default) FROM stdin; 1 CUST Customer t f 2 INT Internet t f 3 REP Sales Rep t f \. -- -- Name: saletype_saletype_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('saletype_saletype_id_seq', 3, true); -- -- Data for Name: schemaord; Type: TABLE DATA; Schema: public; Owner: admin -- COPY schemaord (schemaord_id, schemaord_name, schemaord_order) FROM stdin; \. -- -- Name: schemaord_schemaord_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('schemaord_schemaord_id_seq', 1, false); -- -- Data for Name: script; Type: TABLE DATA; Schema: public; Owner: admin -- COPY script (script_id, script_name, script_order, script_enabled, script_source, script_notes) FROM stdin; 1 storedProcErrorLookup 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2009 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\n/* This simplified version of xtuple/common/storedProcErrorLookup.cpp takes\n an error structure, allowing packages to define their own errors.\n*/\nfunction storedProcErrorLookup(procName, returnVal, errorStruct)\n{\n var message;\n\n if (null != errorStruct)\n {\n if (procName in errorStruct &&\n returnVal in errorStruct[procName])\n message = errorStruct[procName][returnVal];\n else\n {\n procName = procName.toLowerCase();\n for (var tmpProcName in errorStruct)\n if (procName == tmpProcName.toLowerCase())\n {\n message = errorStruct[tmpProcName][returnVal];\n break;\n }\n }\n\n if (message != null)\n return "

" + message\n + qsTr("
(%1, %2)
").arg(procName).arg(returnVal);\n }\n\n return toolbox.storedProcErrorLookup(procName, returnVal);\n}\n this scripted version of the error lookup routine allows packages to define their own messages \. -- -- Name: script_script_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('script_script_id_seq', 136, true); -- -- Data for Name: sequence; Type: TABLE DATA; Schema: public; Owner: admin -- COPY sequence (sequence_value) FROM stdin; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 \. -- -- Data for Name: shift; Type: TABLE DATA; Schema: public; Owner: admin -- COPY shift (shift_id, shift_number, shift_name) FROM stdin; 1 1ST First Shift \. -- -- Name: shift_shift_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('shift_shift_id_seq', 1, true); -- -- Data for Name: shipchrg; Type: TABLE DATA; Schema: public; Owner: admin -- COPY shipchrg (shipchrg_id, shipchrg_name, shipchrg_descrip, shipchrg_custfreight, shipchrg_handling) FROM stdin; 3 CUST-PAY Customer Pays Shipping t \N 4 WE-PAY We Pay Shipping f \N 5 CUST-PICKUP Customer Pickup f \N \. -- -- Name: shipchrg_shipchrg_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('shipchrg_shipchrg_id_seq', 5, true); -- -- Data for Name: shipdata; Type: TABLE DATA; Schema: public; Owner: admin -- COPY shipdata (shipdata_cohead_number, shipdata_cosmisc_tracknum, shipdata_cosmisc_packnum_tracknum, shipdata_weight, shipdata_base_freight, shipdata_total_freight, shipdata_shipper, shipdata_billing_option, shipdata_package_type, shipdata_void_ind, shipdata_lastupdated, shipdata_shiphead_number, shipdata_base_freight_curr_id, shipdata_total_freight_curr_id) FROM stdin; \. -- -- Data for Name: shipdatasum; Type: TABLE DATA; Schema: public; Owner: admin -- COPY shipdatasum (shipdatasum_cohead_number, shipdatasum_cosmisc_tracknum, shipdatasum_cosmisc_packnum_tracknum, shipdatasum_weight, shipdatasum_base_freight, shipdatasum_total_freight, shipdatasum_shipper, shipdatasum_billing_option, shipdatasum_package_type, shipdatasum_lastupdated, shipdatasum_shipped, shipdatasum_shiphead_number, shipdatasum_base_freight_curr_id, shipdatasum_total_freight_curr_id) FROM stdin; \. -- -- Data for Name: shipform; Type: TABLE DATA; Schema: public; Owner: admin -- COPY shipform (shipform_id, shipform_name, shipform_report_id, shipform_report_name) FROM stdin; 12 STD-PACKING-LIST 80 PackingList \. -- -- Name: shipform_shipform_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('shipform_shipform_id_seq', 12, true); -- -- Data for Name: shiphead; Type: TABLE DATA; Schema: public; Owner: admin -- COPY shiphead (shiphead_id, shiphead_order_id, shiphead_order_type, shiphead_number, shiphead_shipvia, shiphead_freight, shiphead_freight_curr_id, shiphead_notes, shiphead_shipped, shiphead_shipdate, shiphead_shipchrg_id, shiphead_shipform_id, shiphead_sfstatus, shiphead_tracknum) FROM stdin; \. -- -- Name: shiphead_shiphead_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('shiphead_shiphead_id_seq', 1, false); -- -- Data for Name: shipitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY shipitem (shipitem_id, shipitem_orderitem_id, shipitem_shiphead_id, shipitem_qty, shipitem_shipped, shipitem_shipdate, shipitem_transdate, shipitem_trans_username, shipitem_invoiced, shipitem_invcitem_id, shipitem_value, shipitem_invhist_id) FROM stdin; \. -- -- Name: shipitem_shipitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('shipitem_shipitem_id_seq', 1, false); -- -- Name: shipment_number_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('shipment_number_seq', 80000, true); -- -- Name: shipto_shipto_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('shipto_shipto_id_seq', 30, true); -- -- Data for Name: shiptoinfo; Type: TABLE DATA; Schema: public; Owner: admin -- COPY shiptoinfo (shipto_id, shipto_cust_id, shipto_name, shipto_salesrep_id, shipto_comments, shipto_shipcomments, shipto_shipzone_id, shipto_shipvia, shipto_commission, shipto_shipform_id, shipto_shipchrg_id, shipto_active, shipto_default, shipto_num, shipto_ediprofile_id, shipto_cntct_id, shipto_addr_id, shipto_taxzone_id, shipto_preferred_warehous_id) FROM stdin; \. -- -- Data for Name: shipvia; Type: TABLE DATA; Schema: public; Owner: admin -- COPY shipvia (shipvia_id, shipvia_code, shipvia_descrip) FROM stdin; 13 UPS-Ground UPS Ground 14 UPS-Next Day UPS-Next Day 15 SAIA SAIA 17 AVERITT Averitt 18 DHL DHL 19 FEDEX-Ground FEDEX-Ground 20 FEDEX-Next Day FEDEX-Next Day 21 ROADWAY ROADWAY 22 USF USF 23 WATKINS Watkins 24 YELLOW Yellow \. -- -- Name: shipvia_shipvia_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('shipvia_shipvia_id_seq', 24, true); -- -- Data for Name: shipzone; Type: TABLE DATA; Schema: public; Owner: admin -- COPY shipzone (shipzone_id, shipzone_name, shipzone_descrip) FROM stdin; 35 ZONE1 Zone 1 43 ZONE9 Zone 9 41 ZONE7 Zone 7 40 ZONE6 Zone 6 42 ZONE8 Zone 8 39 ZONE5 Zone 5 38 ZONE4 Zone 4 37 ZONE3 Zone 3 36 ZONE2 Zone 2 45 ZONE0 Zone 0 \. -- -- Name: shipzone_shipzone_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('shipzone_shipzone_id_seq', 45, true); -- -- Data for Name: sitetype; Type: TABLE DATA; Schema: public; Owner: admin -- COPY sitetype (sitetype_id, sitetype_name, sitetype_descrip) FROM stdin; 1 WHSE Warehouse \. -- -- Name: sitetype_sitetype_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('sitetype_sitetype_id_seq', 1, true); -- -- Data for Name: sltrans; Type: TABLE DATA; Schema: public; Owner: admin -- COPY sltrans (sltrans_id, sltrans_created, sltrans_date, sltrans_sequence, sltrans_accnt_id, sltrans_source, sltrans_docnumber, sltrans_misc_id, sltrans_amount, sltrans_notes, sltrans_journalnumber, sltrans_posted, sltrans_doctype, sltrans_username, sltrans_gltrans_journalnumber, sltrans_rec) FROM stdin; \. -- -- Data for Name: sltrans_backup; Type: TABLE DATA; Schema: public; Owner: admin -- COPY sltrans_backup (sltrans_old_id, sltrans_new_id) FROM stdin; \. -- -- Name: sopack_sopack_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('sopack_sopack_id_seq', 60, true); -- -- Data for Name: source; Type: TABLE DATA; Schema: public; Owner: admin -- COPY source (source_id, source_module, source_name, source_descrip, source_docass_num, source_docass, source_charass, source_table, source_key_field, source_number_field, source_name_field, source_desc_field, source_widget, source_joins, source_key_param, source_uiform_name, source_create_priv, source_created, source_last_modified) FROM stdin; 1 CRM ADDR Address 1 ADDR ADDR addr addr_id addr_number addr_line1 addr_line2 addr_id 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 2 Products BBH Breeder BOM Head 2 BBH bbomhead bbomhead_id bbomhead_docnum item_number firstline(item_descrip1) join item on bomhead_item_id = item_id bomhead_id bom 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 3 Products BBI Breeder BOM Item 3 BBI bbomitem bbomitem_id bbomitem_seqnumber::text item_number firstline(item_descrip1) join item on bbomitem_item_id = item_id bbomitem_id bbom 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 4 Products BMH BOM Head 4 BMH bomhead bomhead_id bomhead_docnum item_number firstline(item_descrip1) join item on bomhead_item_id = item_id bomhead_id bom 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 5 Products BMI BOM Item 5 BMI bomitem bomitem_id p.item_number c.item_number firstline(c.item_descrip1) join item p on bomitem_parent_item_id = p.item_id join item c on bomitem_item_id = c.item_id 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 9 CRM T Contact 9 T CNTCT cntct cntct_id cntct_number cntct_name cntct_title core cntct_id contact 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 6 Products BOH Routing Head 6 BOH boohead boohead_id boohead_docnum item_number firstline(item_descrip1) join item on boohead_item_id = item_id 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 7 Products BOI Routing Item 7 BOI booitem booitem_id booitem_seqnumber::text item_number firstline(item_descrip1) join item on booitem_item_id = item_id 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 8 CRM CRMA Account 8 CRMA CRMACCT crmacct crmacct_id crmacct_number crmacct_name firstline(crmacct_notes) core crmacct_id crmaccount 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 39 System CNTR Contract 10 CNTR cntrct cntrct_id cntrct_number vend_name cntrct_descrip join vendinfo on cntrct_vend_id = vendid cntrct_id contrct 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 40 Sales CM Return 11 CM cmhead cmhead_id cmhead_number cust_name firstline(cmhead_comments) join custinfo on cmhead_cust_id = cust_id cmhead_id creditMemo 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 41 Sales CMI Return Item 12 CMI cmitem cmitem_id cmhead_number cust_name item_number join cmhead on cmitem_cmhead_id=cmhead_id join custinfo on cmhead_cust_id=cust_id join itemsite on cmitem_itemsite_id=itemsite_id join item on itemsite_item_id=item_id 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 10 Sales C Customer 13 C C custinfo cust_id cust_number cust_name firstline(cust_comments) core cust_id customer 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 11 System EMP Employee 14 EMP EMP emp emp_id emp_number cntct_name cntct_title core left outer join cntct on emp_cntct_id = cntct_id emp_id employee 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 12 CRM INCDT Incident 15 INCDT INCDT incdt incdt_id incdt_number::text incdt_summary firstline(incdt_descrip) core incdt_id incident MaintainPersonalIncidents MaintainAllIncidents 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 42 Sales INV Invoice 16 INV INV invchead invchead_id invchead_invcnumber cust_name firstline(invchead_notes) core join custinfo on invchead_cust_id = cust_id invchead_id invoice 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 43 Sales INVI Invoice Item 17 INVI INVI invcitem invcitem_id invchead_invcnumber cust_name item_number join invchead on invcitem_invchead_id = invchead_id join custinfo on invchead_cust_id = cust_id join item on invcitem_item_id=item_id 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 13 Products I Item 18 I I item item_id item_number firstline(item_descrip1) firstline(item_descrip2) core item_id item 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 14 Inventory IS Item Site 19 IS itemsite itemsite_id item_number warehous_code firstline(item_descrip1) join item on itemsite_item_id = item_id join whsinfo on itemsite_item_id = warehous_id 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 15 Purchase IR Item Source 20 IR itemsrc itemsrc_id item_number vend_name firstline(item_descrip1) join item on itemsrc_item_id = item_id join vendinfo on itemsrc_vend_id = vend_id itemsrc_id itemSource 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 16 Inventory L Location 21 L location location_id location_formatname warehous_code NULL join whsinfo on location_warehous_id = warehous_id 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 17 Inventory LS Lot/Serial 22 LS LS ls ls_id ls_number item_number firstline(ls_notes) join item on ls_item_id = item_id ls_id lotSerial 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 18 CRM OPP Opportunity 23 OPP OPP ophead ophead_id ophead_id::text ophead_name firstline(ophead_notes) core ophead_id opportunity MaintainPersonalOpportunities MaintainAllOpportunities 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 19 CRM J Project 24 J PROJ prj prj_id prj_number prj_name firstline(prj_descrip) core prj_id project MaintainPersonalProjects MaintainAllProjects 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 20 Purchase P Purchase Order 25 P PO pohead pohead_id pohead_number vend_name firstline(pohead_comments) core join vendinfo on pohead_vend_id = vend_id pohead_id purchaseOrder 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 21 Purchase PI Purchase Order Item 26 PI PI poitem poitem_id pohead_number vend_name item_number join pohead on poitem_pohead_id=pohead_id join vendinfo on pohead_vend_id=vend_id join itemsite on poitem_itemsite_id=itemsite_id join item on itemsite_item_id=item_id 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 22 Sales RA Return Authorization 27 RA rahead rahead_id rahead_number cust_name firstline(rahead_notes) join custinfo on rahead_cust_id = cust_id rahead_id purchaseOrder 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 23 Sales RI Return Authorization Item 28 RI raitem raitem_id rahead_number cust_name item_number join rahead on raitem_rahead_id=rahead_id join custinfo on rahead_cust_id=cust_id join itemsite on raitem_itemsite_id=itemsite_id join item on itemsite_item_id=item_id 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 24 Sales Q Quote 29 Q QU quhead quhead_id quhead_number cust_name firstline(quhead_ordercomments) join custinfo on quhead_cust_id = cust_id quhead_id salesOrder 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 25 Sales QI Quote Item 30 QI QI quitem quitem_id quhead_number cust_name item_number join quhead on quitem_quhead_id=quhead_id join custinfo on quhead_cust_id=cust_id join itemsite on quitem_itemsite_id=itemsite_id join item on itemsite_item_id=item_id 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 26 Sales S Sales Order 31 S SO cohead cohead_id cohead_number cust_name firstline(cohead_ordercomments) core join custinfo on cohead_cust_id = cust_id sohead_id salesOrder 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 27 Sales SI Sales Order Item 32 SI SI coitem coitem_id cohead_number cust_name item_number join cohead on coitem_cohead_id=cohead_id join custinfo on cohead_cust_id=cust_id join itemsite on coitem_itemsite_id=itemsite_id join item on itemsite_item_id=item_id 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 44 Sales SHP Ship To 33 SHP shipto shipto_id shipto_num cust_name shipto_name join custinfo on shipto_cust_id=cust_id shipto_id shipTo 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 45 TE TE Time Expense 34 TE tehead tehead_id tehead_number emp_number formatDate(tehead_weekending) join emp on tehead_emp_id = emp_id tehead_id timeExpenseSheet 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 33 CRM TD To-Do 35 TODO todoitem todoitem_id todoitem_id::text todoitem_name firstline(todoitem_description) todoitem_id todoItem MaintainPersonalToDoItems MaintainAllToDoItems 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 28 Inventory TO Transfer Order 36 TO tohead tohead_id tohead_number s.warehous_code d.warehous_code join whsinfo s on tohead_src_warehous_id = s.warehous_id join whsinfo d on tohead_dest_warehous_id = d.warehous_id tohead_id transferOrder 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 29 Inventory TI Transfer Order Item 37 TI toitem toitem_id tohead_number item_number warehous_code join tohead on toitem_tohead_id=tohead_id join whsinfo on tohead_dest_warehous_id=warehous_id join item on toitem_item_id=item_id 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 30 Purchase V Vendor 38 V V vendinfo vend_id vend_number vend_name firstline(vend_comments) core vend_id vendor 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 46 Purchase VCH Voucher 39 VCH VCH vohead vohead_id vohead_number vend_name firstline(vohead_notes) join vendinfo on vohead_vend_id=vend_id vohead_id 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 31 Inventory WH Site 40 WH whsinfo warehous_id warehous_code warehous_descrip NULL 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 32 Manufacture W Work Order 41 W W wo wo_id formatWonumber(wo_id) item_descrip1 item_descrip2 core join itemsite on wo_itemsite_id=itemsite_id join item on itemsite_item_id=item_id 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 34 CRM TA Project Task 42 TASK TASK prjtask prjtask_id prjtask_number prjtask_name firstline(prjtask_descrip) prjtask_id task 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 35 CRM PSPCT Prospect 43 PSPCT prospect prospect_id prospect_number prospect_name firstline(prospect_comments) 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 36 Sales SR Sales Rep 44 SR salesrep salesrep_id salesrep_number salesrep_name NULL 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 37 Accounting TAXAUTH Tax Authority 45 TAXAUTH taxauth taxauth_id taxauth_code taxauth_name taxauth_extref 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 38 System USR User 46 USR usr usr_id usr_username usr_propername usr_email 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 47 Sales CT Customer Type 47 CT CT custtype custtype_id custtype_code custtype_code custtype_descrip custtype_id customerType 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 48 Sales LSR Lot/Serial Registration 48 LSR lsreg lsreg_id lsreg_number crmacct_number firstline(lsreg_notes) left outer join crmacct on lsreg_crmacct_id=crmacct_id lsreg_id lotSerialRegistration 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 49 Purchase PR Purchase Request 49 PR pr pr_id pr_number::text pr_subnumber::text pr_releasenote pr_id purchaseRequest MaintainPurchaseRequests ViewPurchaseRequests 2015-10-01 17:15:58.47729+00 2015-10-01 17:15:58.47729+00 \. -- -- Name: source_source_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('source_source_id_seq', 49, true); -- -- Data for Name: state; Type: TABLE DATA; Schema: public; Owner: admin -- COPY state (state_id, state_name, state_abbr, state_country_id) FROM stdin; 1 Alabama AL 230 2 Alaska AK 230 3 American Samoa AS 230 4 Arizona AZ 230 5 Arkansas AR 230 6 California CA 230 7 Colorado CO 230 8 Connecticut CT 230 9 Delaware DE 230 10 District Of Columbia DC 230 11 Federated States Of Micronesia FM 230 12 Florida FL 230 13 Georgia GA 230 14 Guam GU 230 15 Hawaii HI 230 16 Idaho ID 230 17 Illinois IL 230 18 Indiana IN 230 19 Iowa IA 230 20 Kansas KS 230 21 Kentucky KY 230 22 Louisiana LA 230 23 Maine ME 230 24 Marshall Islands MH 230 25 Maryland MD 230 26 Massachusetts MA 230 27 Michigan MI 230 28 Minnesota MN 230 29 Mississippi MS 230 30 Missouri MO 230 31 Montana MT 230 32 Nebraska NE 230 33 Nevada NV 230 34 New Hampshire NH 230 35 New Jersey NJ 230 36 New Mexico NM 230 37 New York NY 230 38 North Carolina NC 230 39 North Dakota ND 230 40 Northern Mariana Islands MP 230 41 Ohio OH 230 42 Oklahoma OK 230 43 Oregon OR 230 44 Palau PW 230 45 Pennsylvania PA 230 46 Puerto Rico PR 230 47 Rhode Island RI 230 48 South Carolina SC 230 49 South Dakota SD 230 50 Tennessee TN 230 51 Texas TX 230 52 Utah UT 230 53 Vermont VT 230 54 Virgin Islands VI 230 55 Virginia VA 230 56 Washington WA 230 57 West Virginia WV 230 58 Wisconsin WI 230 59 Wyoming WY 230 60 Armed Forces Africa, Canada, Europe, Middle East AE 230 61 Armed Forces Americas (except Canada) AA 230 62 Armed Forces Pacific AP 230 63 Alberta AB 39 64 British Columbia BC 39 65 Manitoba MB 39 66 New Brunswick NB 39 67 Newfoundland and Labrador NL 39 68 Northwest Territories NT 39 69 Nova Scotia NS 39 70 Nunavut NU 39 71 Ontario ON 39 72 Prince Edward Island PE 39 73 Quebec QC 39 74 Saskatchewan SK 39 75 Yukon YT 39 76 Aguascalientes AGS 140 77 Baja California BC 140 78 Baja California Sur BCS 140 79 Campeche CAM 140 80 Coahuila COAH 140 81 Colima COL 140 82 Chiapas CHIS 140 83 Chihuahua CHIH 140 84 Distrito Federal DF 140 85 Durango DGO 140 86 Guanajuato GTO 140 87 Guerrero GRO 140 88 Hidalgo HGO 140 89 Jalisco JAL 140 90 Mexico MEX 140 91 Michoacan MICH 140 92 Morelos MOR 140 93 Nayarit NAY 140 94 Nuevo Leon NL 140 95 Oaxaca OAX 140 96 Puebla PUE 140 97 Queretaro QRO 140 98 Quintana Roo Q ROO 140 99 San Luis Potosi SLP 140 100 Sinaloa SIN 140 101 Sonora SON 140 102 Tabasco TAB 140 103 Tamaulipas TAMPS 140 104 Tlaxcala TLAX 140 105 Veracruz VER 140 106 Yucatan YUC 140 107 Zacatecas ZAC 140 108 Australian Capital Territory ACT 13 109 New South Wales NSW 13 110 Northern Territory NT 13 111 Queensland QLD 13 112 South Australia SA 13 113 Tasmania TAS 13 114 Victoria VIC 13 115 Western Australia WA 13 116 Schleswig-Holstein SH 81 117 Mecklenburg-Vorpommern MV 81 118 Hamburg HH 81 119 Bremen HB 81 120 Berlin BE 81 121 Brandenburg BB 81 122 Niedersachsen NI 81 123 Nordrhein-Westfalen NW 81 124 Sachsen-Anhalt ST 81 125 Sachsen SN 81 126 Hessen HE 81 127 Thüringen TH 81 128 Bayern BY 81 129 Rheinland-Pfalz RP 81 130 Saarland SL 81 131 Baden-Württemberg BW 81 132 Acre AC 30 133 Alagoas AL 30 134 Amapá AP 30 135 Amazonas AM 30 136 Bahia VA 30 137 Ceará CE 30 138 Distito Federal DF 30 139 Espirito Santo ES 30 140 Goiás GO 30 141 Maranhão MA 30 142 Mato Grosso MT 30 143 Mato Grosso do Sul MS 30 144 Minas Gerais MG 30 145 Pará PA 30 146 Paraiba PB 30 147 Paraná PR 30 148 Pernambuco PE 30 149 Piaui PI 30 150 Rio de Janeiro RJ 30 151 Rio Grande do Norte RN 30 152 Rio Grande do Sul RS 30 153 Rondônia RO 30 154 Roraima RR 30 155 Santa Catarina SC 30 156 São Paulo SP 30 157 Sergipe SE 30 158 Tocantins TO 30 \. -- -- Name: state_state_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('state_state_id_seq', 158, true); -- -- Data for Name: status; Type: TABLE DATA; Schema: public; Owner: admin -- COPY status (status_id, status_type, status_code, status_name, status_seq, status_color) FROM stdin; 1 INCDT N New 0 #00FA9A 2 INCDT F Feedback 1 #F4F776 3 INCDT C Confirmed 2 #F2F2F2 4 INCDT A Assigned 3 #DB7093 5 INCDT R Resolved 4 #EEB4B4 6 INCDT L Closed 5 #FF6EC7 \. -- -- Name: status_status_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('status_status_id_seq', 6, true); -- -- Data for Name: stdjrnl; Type: TABLE DATA; Schema: public; Owner: admin -- COPY stdjrnl (stdjrnl_id, stdjrnl_name, stdjrnl_descrip, stdjrnl_notes) FROM stdin; \. -- -- Name: stdjrnl_stdjrnl_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('stdjrnl_stdjrnl_id_seq', 30, true); -- -- Data for Name: stdjrnlgrp; Type: TABLE DATA; Schema: public; Owner: admin -- COPY stdjrnlgrp (stdjrnlgrp_id, stdjrnlgrp_name, stdjrnlgrp_descrip) FROM stdin; \. -- -- Name: stdjrnlgrp_stdjrnlgrp_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('stdjrnlgrp_stdjrnlgrp_id_seq', 12, true); -- -- Data for Name: stdjrnlgrpitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY stdjrnlgrpitem (stdjrnlgrpitem_id, stdjrnlgrpitem_stdjrnl_id, stdjrnlgrpitem_toapply, stdjrnlgrpitem_applied, stdjrnlgrpitem_effective, stdjrnlgrpitem_expires, stdjrnlgrpitem_stdjrnlgrp_id) FROM stdin; \. -- -- Name: stdjrnlgrpitem_stdjrnlgrpitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('stdjrnlgrpitem_stdjrnlgrpitem_id_seq', 18, true); -- -- Data for Name: stdjrnlitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY stdjrnlitem (stdjrnlitem_id, stdjrnlitem_stdjrnl_id, stdjrnlitem_accnt_id, stdjrnlitem_amount, stdjrnlitem_notes) FROM stdin; \. -- -- Name: stdjrnlitem_stdjrnlitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('stdjrnlitem_stdjrnlitem_id_seq', 28, true); -- -- Data for Name: subaccnt; Type: TABLE DATA; Schema: public; Owner: admin -- COPY subaccnt (subaccnt_id, subaccnt_number, subaccnt_descrip) FROM stdin; 1 01 Subaccount 01 \. -- -- Name: subaccnt_subaccnt_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('subaccnt_subaccnt_id_seq', 1, true); -- -- Data for Name: subaccnttype; Type: TABLE DATA; Schema: public; Owner: admin -- COPY subaccnttype (subaccnttype_id, subaccnttype_accnt_type, subaccnttype_code, subaccnttype_descrip) FROM stdin; 1 A CA Cash Assets 2 A AR Accounts Receivable 3 A IN Inventory 4 A CAS Current Assets 5 A FA Fixed Assets 6 A AD Accumulated Depreciation 7 L CL Current Liabilities 8 L AP Accounts Payable 9 L LTL Long Term Liabilities 10 Q EDC Equity do not close 11 Q ERE Equity Retained Earnings 12 Q EC Equity close 13 R SI Sales Income 14 R II Interest Income 15 R IV Investment Income 16 R RT Returns 17 E COGS Cost of Goods Sold 18 E EXP Expenses 19 E DEP Depreciation Expense \. -- -- Name: subaccnttype_subaccnttype_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('subaccnttype_subaccnttype_id_seq', 19, true); -- -- Data for Name: tax; Type: TABLE DATA; Schema: public; Owner: admin -- COPY tax (tax_id, tax_code, tax_descrip, tax_sales_accnt_id, tax_taxclass_id, tax_taxauth_id, tax_basis_tax_id, tax_dist_accnt_id) FROM stdin; 13 Sales Tax Sales Tax 102 \N \N \N \N \. -- -- Name: tax_tax_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('tax_tax_id_seq', 13, true); -- -- Data for Name: taxass; Type: TABLE DATA; Schema: public; Owner: admin -- COPY taxass (taxass_id, taxass_taxzone_id, taxass_taxtype_id, taxass_tax_id) FROM stdin; 1 1 \N 13 \. -- -- Name: taxass_taxass_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('taxass_taxass_id_seq', 1, false); -- -- Data for Name: taxauth; Type: TABLE DATA; Schema: public; Owner: admin -- COPY taxauth (taxauth_id, taxauth_code, taxauth_name, taxauth_extref, taxauth_addr_id, taxauth_curr_id, taxauth_county, taxauth_accnt_id) FROM stdin; 1 SALES TAX State Sales Tax Authority \N 1 102 \. -- -- Name: taxauth_taxauth_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('taxauth_taxauth_id_seq', 1, true); -- -- Data for Name: taxclass; Type: TABLE DATA; Schema: public; Owner: admin -- COPY taxclass (taxclass_id, taxclass_code, taxclass_descrip, taxclass_sequence) FROM stdin; 1 1 Legacy Class 1 0 2 2 Legacy Class 2 0 3 3 Legacy Class 3 0 \. -- -- Name: taxclass_taxclass_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('taxclass_taxclass_id_seq', 3, true); -- -- Data for Name: taxhist; Type: TABLE DATA; Schema: public; Owner: admin -- COPY taxhist (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; \. -- -- Name: taxhist_taxhist_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('taxhist_taxhist_id_seq', 1, false); -- -- Data for Name: taxpay; Type: TABLE DATA; Schema: public; Owner: admin -- COPY taxpay (taxpay_id, taxpay_taxhist_id, taxpay_apply_id, taxpay_distdate, taxpay_tax) FROM stdin; \. -- -- Name: taxpay_taxpay_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('taxpay_taxpay_id_seq', 1, false); -- -- Data for Name: taxrate; Type: TABLE DATA; Schema: public; Owner: admin -- COPY taxrate (taxrate_id, taxrate_tax_id, taxrate_percent, taxrate_curr_id, taxrate_amount, taxrate_effective, taxrate_expires) FROM stdin; 1 13 0.050000 1 0.00 1970-01-01 2100-12-31 \. -- -- Name: taxrate_taxrate_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('taxrate_taxrate_id_seq', 1, true); -- -- Data for Name: taxreg; Type: TABLE DATA; Schema: public; Owner: admin -- COPY taxreg (taxreg_id, taxreg_rel_id, taxreg_rel_type, taxreg_taxauth_id, taxreg_number, taxreg_taxzone_id, taxreg_effective, taxreg_expires, taxreg_notes) FROM stdin; \. -- -- Name: taxreg_taxreg_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('taxreg_taxreg_id_seq', 1, false); -- -- Data for Name: taxtype; Type: TABLE DATA; Schema: public; Owner: admin -- COPY taxtype (taxtype_id, taxtype_name, taxtype_descrip, taxtype_sys) FROM stdin; 1 Freight System Defined Freight Tax Type. DO NOT CHANGE. t 2 Taxable Taxable Item f 3 Adjustment System Defined Adjustment Tax Type. DO NOT CHANGE. t \. -- -- Name: taxtype_taxtype_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('taxtype_taxtype_id_seq', 3, true); -- -- Data for Name: taxzone; Type: TABLE DATA; Schema: public; Owner: admin -- COPY taxzone (taxzone_id, taxzone_code, taxzone_descrip) FROM stdin; 1 SALES TAX State Sales Tax Authority \. -- -- Name: taxzone_taxzone_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('taxzone_taxzone_id_seq', 2, true); -- -- Data for Name: terms; Type: TABLE DATA; Schema: public; Owner: admin -- COPY terms (terms_id, terms_code, terms_descrip, terms_type, terms_duedays, terms_discdays, terms_discprcnt, terms_cutoffday, terms_ap, terms_ar, terms_fincharg) FROM stdin; 42 2-10-NET-30 2-10-NET-30 D 30 10 0.020000 1 t t t 43 NET30 Net 30 Days D 30 0 0.000000 1 t t t \. -- -- Name: terms_terms_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('terms_terms_id_seq', 43, true); -- -- Data for Name: todoitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY todoitem (todoitem_id, todoitem_name, todoitem_description, todoitem_incdt_id, todoitem_creator_username, todoitem_status, todoitem_active, todoitem_start_date, todoitem_due_date, todoitem_assigned_date, todoitem_completed_date, todoitem_seq, todoitem_notes, todoitem_crmacct_id, todoitem_ophead_id, todoitem_owner_username, todoitem_priority_id, todoitem_username, todoitem_recurring_todoitem_id, todoitem_cntct_id) FROM stdin; \. -- -- Name: todoitem_todoitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('todoitem_todoitem_id_seq', 1, false); -- -- Data for Name: trgthist; Type: TABLE DATA; Schema: public; Owner: admin -- COPY trgthist (trgthist_src_cntct_id, trgthist_trgt_cntct_id, trgthist_col, trgthist_value) FROM stdin; \. -- -- Data for Name: trialbal; Type: TABLE DATA; Schema: public; Owner: admin -- COPY trialbal (trialbal_id, trialbal_period_id, trialbal_accnt_id, trialbal_beginning, trialbal_ending, trialbal_credits, trialbal_debits, trialbal_dirty, trialbal_yearend) FROM stdin; 8159 53 83 0.00 0.00 0.00 0.00 f 0.00 8160 54 83 0.00 0.00 0.00 0.00 f 0.00 8161 55 83 0.00 0.00 0.00 0.00 f 0.00 8162 56 83 0.00 0.00 0.00 0.00 f 0.00 8163 57 83 0.00 0.00 0.00 0.00 f 0.00 8164 58 83 0.00 0.00 0.00 0.00 f 0.00 8165 59 83 0.00 0.00 0.00 0.00 f 0.00 8166 60 83 0.00 0.00 0.00 0.00 f 0.00 8167 61 83 0.00 0.00 0.00 0.00 f 0.00 8168 62 83 0.00 0.00 0.00 0.00 f 0.00 8169 63 83 0.00 0.00 0.00 0.00 f 0.00 8170 64 83 0.00 0.00 0.00 0.00 f 0.00 8171 65 83 0.00 0.00 0.00 0.00 f 0.00 8172 66 83 0.00 0.00 0.00 0.00 f 0.00 8173 67 83 0.00 0.00 0.00 0.00 f 0.00 8174 68 83 0.00 0.00 0.00 0.00 f 0.00 8175 69 83 0.00 0.00 0.00 0.00 f 0.00 8176 70 83 0.00 0.00 0.00 0.00 f 0.00 8177 71 83 0.00 0.00 0.00 0.00 f 0.00 8178 72 83 0.00 0.00 0.00 0.00 f 0.00 8179 73 83 0.00 0.00 0.00 0.00 f 0.00 8158 52 83 0.00 0.00 0.00 0.00 f 0.00 8203 53 89 0.00 0.00 0.00 0.00 f 0.00 8204 54 89 0.00 0.00 0.00 0.00 f 0.00 8205 55 89 0.00 0.00 0.00 0.00 f 0.00 8206 56 89 0.00 0.00 0.00 0.00 f 0.00 8207 57 89 0.00 0.00 0.00 0.00 f 0.00 8208 58 89 0.00 0.00 0.00 0.00 f 0.00 8209 59 89 0.00 0.00 0.00 0.00 f 0.00 8210 60 89 0.00 0.00 0.00 0.00 f 0.00 8211 61 89 0.00 0.00 0.00 0.00 f 0.00 8212 62 89 0.00 0.00 0.00 0.00 f 0.00 8213 63 89 0.00 0.00 0.00 0.00 f 0.00 8214 64 89 0.00 0.00 0.00 0.00 f 0.00 8215 65 89 0.00 0.00 0.00 0.00 f 0.00 8216 66 89 0.00 0.00 0.00 0.00 f 0.00 8217 67 89 0.00 0.00 0.00 0.00 f 0.00 8218 68 89 0.00 0.00 0.00 0.00 f 0.00 8219 69 89 0.00 0.00 0.00 0.00 f 0.00 8220 70 89 0.00 0.00 0.00 0.00 f 0.00 8221 71 89 0.00 0.00 0.00 0.00 f 0.00 8222 72 89 0.00 0.00 0.00 0.00 f 0.00 8223 73 89 0.00 0.00 0.00 0.00 f 0.00 8202 52 89 0.00 0.00 0.00 0.00 f 0.00 8247 53 91 0.00 0.00 0.00 0.00 f 0.00 8248 54 91 0.00 0.00 0.00 0.00 f 0.00 8249 55 91 0.00 0.00 0.00 0.00 f 0.00 8250 56 91 0.00 0.00 0.00 0.00 f 0.00 8251 57 91 0.00 0.00 0.00 0.00 f 0.00 8252 58 91 0.00 0.00 0.00 0.00 f 0.00 8253 59 91 0.00 0.00 0.00 0.00 f 0.00 8254 60 91 0.00 0.00 0.00 0.00 f 0.00 8255 61 91 0.00 0.00 0.00 0.00 f 0.00 8256 62 91 0.00 0.00 0.00 0.00 f 0.00 8257 63 91 0.00 0.00 0.00 0.00 f 0.00 8258 64 91 0.00 0.00 0.00 0.00 f 0.00 8259 65 91 0.00 0.00 0.00 0.00 f 0.00 8260 66 91 0.00 0.00 0.00 0.00 f 0.00 8261 67 91 0.00 0.00 0.00 0.00 f 0.00 8262 68 91 0.00 0.00 0.00 0.00 f 0.00 8263 69 91 0.00 0.00 0.00 0.00 f 0.00 8264 70 91 0.00 0.00 0.00 0.00 f 0.00 8265 71 91 0.00 0.00 0.00 0.00 f 0.00 8266 72 91 0.00 0.00 0.00 0.00 f 0.00 8267 73 91 0.00 0.00 0.00 0.00 f 0.00 8246 52 91 0.00 0.00 0.00 0.00 f 0.00 8269 53 92 0.00 0.00 0.00 0.00 f 0.00 8270 54 92 0.00 0.00 0.00 0.00 f 0.00 8271 55 92 0.00 0.00 0.00 0.00 f 0.00 8272 56 92 0.00 0.00 0.00 0.00 f 0.00 8273 57 92 0.00 0.00 0.00 0.00 f 0.00 8274 58 92 0.00 0.00 0.00 0.00 f 0.00 8275 59 92 0.00 0.00 0.00 0.00 f 0.00 8276 60 92 0.00 0.00 0.00 0.00 f 0.00 8277 61 92 0.00 0.00 0.00 0.00 f 0.00 8278 62 92 0.00 0.00 0.00 0.00 f 0.00 8279 63 92 0.00 0.00 0.00 0.00 f 0.00 8280 64 92 0.00 0.00 0.00 0.00 f 0.00 8281 65 92 0.00 0.00 0.00 0.00 f 0.00 8282 66 92 0.00 0.00 0.00 0.00 f 0.00 8283 67 92 0.00 0.00 0.00 0.00 f 0.00 8284 68 92 0.00 0.00 0.00 0.00 f 0.00 8285 69 92 0.00 0.00 0.00 0.00 f 0.00 8286 70 92 0.00 0.00 0.00 0.00 f 0.00 8287 71 92 0.00 0.00 0.00 0.00 f 0.00 8288 72 92 0.00 0.00 0.00 0.00 f 0.00 8289 73 92 0.00 0.00 0.00 0.00 f 0.00 8268 52 92 0.00 0.00 0.00 0.00 f 0.00 8291 53 93 0.00 0.00 0.00 0.00 f 0.00 8292 54 93 0.00 0.00 0.00 0.00 f 0.00 8293 55 93 0.00 0.00 0.00 0.00 f 0.00 8294 56 93 0.00 0.00 0.00 0.00 f 0.00 8295 57 93 0.00 0.00 0.00 0.00 f 0.00 8296 58 93 0.00 0.00 0.00 0.00 f 0.00 8297 59 93 0.00 0.00 0.00 0.00 f 0.00 8298 60 93 0.00 0.00 0.00 0.00 f 0.00 8299 61 93 0.00 0.00 0.00 0.00 f 0.00 8300 62 93 0.00 0.00 0.00 0.00 f 0.00 8301 63 93 0.00 0.00 0.00 0.00 f 0.00 8302 64 93 0.00 0.00 0.00 0.00 f 0.00 8303 65 93 0.00 0.00 0.00 0.00 f 0.00 8304 66 93 0.00 0.00 0.00 0.00 f 0.00 8305 67 93 0.00 0.00 0.00 0.00 f 0.00 8306 68 93 0.00 0.00 0.00 0.00 f 0.00 8307 69 93 0.00 0.00 0.00 0.00 f 0.00 8308 70 93 0.00 0.00 0.00 0.00 f 0.00 8309 71 93 0.00 0.00 0.00 0.00 f 0.00 8310 72 93 0.00 0.00 0.00 0.00 f 0.00 8311 73 93 0.00 0.00 0.00 0.00 f 0.00 8290 52 93 0.00 0.00 0.00 0.00 f 0.00 8313 53 94 0.00 0.00 0.00 0.00 f 0.00 8314 54 94 0.00 0.00 0.00 0.00 f 0.00 8315 55 94 0.00 0.00 0.00 0.00 f 0.00 8316 56 94 0.00 0.00 0.00 0.00 f 0.00 8317 57 94 0.00 0.00 0.00 0.00 f 0.00 8318 58 94 0.00 0.00 0.00 0.00 f 0.00 8319 59 94 0.00 0.00 0.00 0.00 f 0.00 8320 60 94 0.00 0.00 0.00 0.00 f 0.00 8321 61 94 0.00 0.00 0.00 0.00 f 0.00 8322 62 94 0.00 0.00 0.00 0.00 f 0.00 8323 63 94 0.00 0.00 0.00 0.00 f 0.00 8324 64 94 0.00 0.00 0.00 0.00 f 0.00 8325 65 94 0.00 0.00 0.00 0.00 f 0.00 8326 66 94 0.00 0.00 0.00 0.00 f 0.00 8327 67 94 0.00 0.00 0.00 0.00 f 0.00 8328 68 94 0.00 0.00 0.00 0.00 f 0.00 8329 69 94 0.00 0.00 0.00 0.00 f 0.00 8330 70 94 0.00 0.00 0.00 0.00 f 0.00 8331 71 94 0.00 0.00 0.00 0.00 f 0.00 8332 72 94 0.00 0.00 0.00 0.00 f 0.00 8333 73 94 0.00 0.00 0.00 0.00 f 0.00 8312 52 94 0.00 0.00 0.00 0.00 f 0.00 8335 53 96 0.00 0.00 0.00 0.00 f 0.00 8336 54 96 0.00 0.00 0.00 0.00 f 0.00 8337 55 96 0.00 0.00 0.00 0.00 f 0.00 8338 56 96 0.00 0.00 0.00 0.00 f 0.00 8339 57 96 0.00 0.00 0.00 0.00 f 0.00 8340 58 96 0.00 0.00 0.00 0.00 f 0.00 8341 59 96 0.00 0.00 0.00 0.00 f 0.00 8342 60 96 0.00 0.00 0.00 0.00 f 0.00 8343 61 96 0.00 0.00 0.00 0.00 f 0.00 8344 62 96 0.00 0.00 0.00 0.00 f 0.00 8345 63 96 0.00 0.00 0.00 0.00 f 0.00 8346 64 96 0.00 0.00 0.00 0.00 f 0.00 8347 65 96 0.00 0.00 0.00 0.00 f 0.00 8348 66 96 0.00 0.00 0.00 0.00 f 0.00 8349 67 96 0.00 0.00 0.00 0.00 f 0.00 8350 68 96 0.00 0.00 0.00 0.00 f 0.00 8351 69 96 0.00 0.00 0.00 0.00 f 0.00 8352 70 96 0.00 0.00 0.00 0.00 f 0.00 8353 71 96 0.00 0.00 0.00 0.00 f 0.00 8354 72 96 0.00 0.00 0.00 0.00 f 0.00 8355 73 96 0.00 0.00 0.00 0.00 f 0.00 8334 52 96 0.00 0.00 0.00 0.00 f 0.00 8357 53 98 0.00 0.00 0.00 0.00 f 0.00 8358 54 98 0.00 0.00 0.00 0.00 f 0.00 8359 55 98 0.00 0.00 0.00 0.00 f 0.00 8360 56 98 0.00 0.00 0.00 0.00 f 0.00 8361 57 98 0.00 0.00 0.00 0.00 f 0.00 8362 58 98 0.00 0.00 0.00 0.00 f 0.00 8363 59 98 0.00 0.00 0.00 0.00 f 0.00 8364 60 98 0.00 0.00 0.00 0.00 f 0.00 8365 61 98 0.00 0.00 0.00 0.00 f 0.00 8366 62 98 0.00 0.00 0.00 0.00 f 0.00 8367 63 98 0.00 0.00 0.00 0.00 f 0.00 8368 64 98 0.00 0.00 0.00 0.00 f 0.00 8369 65 98 0.00 0.00 0.00 0.00 f 0.00 8370 66 98 0.00 0.00 0.00 0.00 f 0.00 8371 67 98 0.00 0.00 0.00 0.00 f 0.00 8372 68 98 0.00 0.00 0.00 0.00 f 0.00 8373 69 98 0.00 0.00 0.00 0.00 f 0.00 8374 70 98 0.00 0.00 0.00 0.00 f 0.00 8375 71 98 0.00 0.00 0.00 0.00 f 0.00 8376 72 98 0.00 0.00 0.00 0.00 f 0.00 8377 73 98 0.00 0.00 0.00 0.00 f 0.00 8356 52 98 0.00 0.00 0.00 0.00 f 0.00 8379 53 99 0.00 0.00 0.00 0.00 f 0.00 8380 54 99 0.00 0.00 0.00 0.00 f 0.00 8381 55 99 0.00 0.00 0.00 0.00 f 0.00 8382 56 99 0.00 0.00 0.00 0.00 f 0.00 8383 57 99 0.00 0.00 0.00 0.00 f 0.00 8384 58 99 0.00 0.00 0.00 0.00 f 0.00 8385 59 99 0.00 0.00 0.00 0.00 f 0.00 8386 60 99 0.00 0.00 0.00 0.00 f 0.00 8387 61 99 0.00 0.00 0.00 0.00 f 0.00 8388 62 99 0.00 0.00 0.00 0.00 f 0.00 8389 63 99 0.00 0.00 0.00 0.00 f 0.00 8390 64 99 0.00 0.00 0.00 0.00 f 0.00 8391 65 99 0.00 0.00 0.00 0.00 f 0.00 8392 66 99 0.00 0.00 0.00 0.00 f 0.00 8393 67 99 0.00 0.00 0.00 0.00 f 0.00 8394 68 99 0.00 0.00 0.00 0.00 f 0.00 8395 69 99 0.00 0.00 0.00 0.00 f 0.00 8396 70 99 0.00 0.00 0.00 0.00 f 0.00 8397 71 99 0.00 0.00 0.00 0.00 f 0.00 8398 72 99 0.00 0.00 0.00 0.00 f 0.00 8399 73 99 0.00 0.00 0.00 0.00 f 0.00 8378 52 99 0.00 0.00 0.00 0.00 f 0.00 8423 53 101 0.00 0.00 0.00 0.00 f 0.00 8424 54 101 0.00 0.00 0.00 0.00 f 0.00 8425 55 101 0.00 0.00 0.00 0.00 f 0.00 8426 56 101 0.00 0.00 0.00 0.00 f 0.00 8427 57 101 0.00 0.00 0.00 0.00 f 0.00 8428 58 101 0.00 0.00 0.00 0.00 f 0.00 8429 59 101 0.00 0.00 0.00 0.00 f 0.00 8430 60 101 0.00 0.00 0.00 0.00 f 0.00 8431 61 101 0.00 0.00 0.00 0.00 f 0.00 8432 62 101 0.00 0.00 0.00 0.00 f 0.00 8433 63 101 0.00 0.00 0.00 0.00 f 0.00 8434 64 101 0.00 0.00 0.00 0.00 f 0.00 8435 65 101 0.00 0.00 0.00 0.00 f 0.00 8436 66 101 0.00 0.00 0.00 0.00 f 0.00 8437 67 101 0.00 0.00 0.00 0.00 f 0.00 8438 68 101 0.00 0.00 0.00 0.00 f 0.00 8439 69 101 0.00 0.00 0.00 0.00 f 0.00 8440 70 101 0.00 0.00 0.00 0.00 f 0.00 8441 71 101 0.00 0.00 0.00 0.00 f 0.00 8442 72 101 0.00 0.00 0.00 0.00 f 0.00 8443 73 101 0.00 0.00 0.00 0.00 f 0.00 8422 52 101 0.00 0.00 0.00 0.00 f 0.00 8445 53 103 0.00 0.00 0.00 0.00 f 0.00 8446 54 103 0.00 0.00 0.00 0.00 f 0.00 8447 55 103 0.00 0.00 0.00 0.00 f 0.00 8448 56 103 0.00 0.00 0.00 0.00 f 0.00 8449 57 103 0.00 0.00 0.00 0.00 f 0.00 8450 58 103 0.00 0.00 0.00 0.00 f 0.00 8451 59 103 0.00 0.00 0.00 0.00 f 0.00 8452 60 103 0.00 0.00 0.00 0.00 f 0.00 8453 61 103 0.00 0.00 0.00 0.00 f 0.00 8454 62 103 0.00 0.00 0.00 0.00 f 0.00 8455 63 103 0.00 0.00 0.00 0.00 f 0.00 8456 64 103 0.00 0.00 0.00 0.00 f 0.00 8457 65 103 0.00 0.00 0.00 0.00 f 0.00 8458 66 103 0.00 0.00 0.00 0.00 f 0.00 8459 67 103 0.00 0.00 0.00 0.00 f 0.00 8460 68 103 0.00 0.00 0.00 0.00 f 0.00 8461 69 103 0.00 0.00 0.00 0.00 f 0.00 8462 70 103 0.00 0.00 0.00 0.00 f 0.00 8463 71 103 0.00 0.00 0.00 0.00 f 0.00 8464 72 103 0.00 0.00 0.00 0.00 f 0.00 8465 73 103 0.00 0.00 0.00 0.00 f 0.00 8444 52 103 0.00 0.00 0.00 0.00 f 0.00 8467 53 104 0.00 0.00 0.00 0.00 f 0.00 8468 54 104 0.00 0.00 0.00 0.00 f 0.00 8469 55 104 0.00 0.00 0.00 0.00 f 0.00 8470 56 104 0.00 0.00 0.00 0.00 f 0.00 8471 57 104 0.00 0.00 0.00 0.00 f 0.00 8472 58 104 0.00 0.00 0.00 0.00 f 0.00 8473 59 104 0.00 0.00 0.00 0.00 f 0.00 8474 60 104 0.00 0.00 0.00 0.00 f 0.00 8475 61 104 0.00 0.00 0.00 0.00 f 0.00 8476 62 104 0.00 0.00 0.00 0.00 f 0.00 8477 63 104 0.00 0.00 0.00 0.00 f 0.00 8478 64 104 0.00 0.00 0.00 0.00 f 0.00 8479 65 104 0.00 0.00 0.00 0.00 f 0.00 8480 66 104 0.00 0.00 0.00 0.00 f 0.00 8481 67 104 0.00 0.00 0.00 0.00 f 0.00 8482 68 104 0.00 0.00 0.00 0.00 f 0.00 8483 69 104 0.00 0.00 0.00 0.00 f 0.00 8484 70 104 0.00 0.00 0.00 0.00 f 0.00 8485 71 104 0.00 0.00 0.00 0.00 f 0.00 8486 72 104 0.00 0.00 0.00 0.00 f 0.00 8487 73 104 0.00 0.00 0.00 0.00 f 0.00 8466 52 104 0.00 0.00 0.00 0.00 f 0.00 8489 53 105 0.00 0.00 0.00 0.00 f 0.00 8490 54 105 0.00 0.00 0.00 0.00 f 0.00 8491 55 105 0.00 0.00 0.00 0.00 f 0.00 8492 56 105 0.00 0.00 0.00 0.00 f 0.00 8493 57 105 0.00 0.00 0.00 0.00 f 0.00 8494 58 105 0.00 0.00 0.00 0.00 f 0.00 8495 59 105 0.00 0.00 0.00 0.00 f 0.00 8496 60 105 0.00 0.00 0.00 0.00 f 0.00 8497 61 105 0.00 0.00 0.00 0.00 f 0.00 8498 62 105 0.00 0.00 0.00 0.00 f 0.00 8499 63 105 0.00 0.00 0.00 0.00 f 0.00 8500 64 105 0.00 0.00 0.00 0.00 f 0.00 8501 65 105 0.00 0.00 0.00 0.00 f 0.00 8502 66 105 0.00 0.00 0.00 0.00 f 0.00 8503 67 105 0.00 0.00 0.00 0.00 f 0.00 8504 68 105 0.00 0.00 0.00 0.00 f 0.00 8505 69 105 0.00 0.00 0.00 0.00 f 0.00 8506 70 105 0.00 0.00 0.00 0.00 f 0.00 8507 71 105 0.00 0.00 0.00 0.00 f 0.00 8508 72 105 0.00 0.00 0.00 0.00 f 0.00 8509 73 105 0.00 0.00 0.00 0.00 f 0.00 8488 52 105 0.00 0.00 0.00 0.00 f 0.00 8511 53 107 0.00 0.00 0.00 0.00 f 0.00 8512 54 107 0.00 0.00 0.00 0.00 f 0.00 8513 55 107 0.00 0.00 0.00 0.00 f 0.00 8514 56 107 0.00 0.00 0.00 0.00 f 0.00 8515 57 107 0.00 0.00 0.00 0.00 f 0.00 8516 58 107 0.00 0.00 0.00 0.00 f 0.00 8517 59 107 0.00 0.00 0.00 0.00 f 0.00 8518 60 107 0.00 0.00 0.00 0.00 f 0.00 8519 61 107 0.00 0.00 0.00 0.00 f 0.00 8520 62 107 0.00 0.00 0.00 0.00 f 0.00 8521 63 107 0.00 0.00 0.00 0.00 f 0.00 8522 64 107 0.00 0.00 0.00 0.00 f 0.00 8523 65 107 0.00 0.00 0.00 0.00 f 0.00 8524 66 107 0.00 0.00 0.00 0.00 f 0.00 8525 67 107 0.00 0.00 0.00 0.00 f 0.00 8526 68 107 0.00 0.00 0.00 0.00 f 0.00 8527 69 107 0.00 0.00 0.00 0.00 f 0.00 8528 70 107 0.00 0.00 0.00 0.00 f 0.00 8529 71 107 0.00 0.00 0.00 0.00 f 0.00 8530 72 107 0.00 0.00 0.00 0.00 f 0.00 8531 73 107 0.00 0.00 0.00 0.00 f 0.00 8510 52 107 0.00 0.00 0.00 0.00 f 0.00 8533 53 108 0.00 0.00 0.00 0.00 f 0.00 8534 54 108 0.00 0.00 0.00 0.00 f 0.00 8535 55 108 0.00 0.00 0.00 0.00 f 0.00 8536 56 108 0.00 0.00 0.00 0.00 f 0.00 8537 57 108 0.00 0.00 0.00 0.00 f 0.00 8538 58 108 0.00 0.00 0.00 0.00 f 0.00 8539 59 108 0.00 0.00 0.00 0.00 f 0.00 8540 60 108 0.00 0.00 0.00 0.00 f 0.00 8541 61 108 0.00 0.00 0.00 0.00 f 0.00 8542 62 108 0.00 0.00 0.00 0.00 f 0.00 8543 63 108 0.00 0.00 0.00 0.00 f 0.00 8544 64 108 0.00 0.00 0.00 0.00 f 0.00 8545 65 108 0.00 0.00 0.00 0.00 f 0.00 8546 66 108 0.00 0.00 0.00 0.00 f 0.00 8547 67 108 0.00 0.00 0.00 0.00 f 0.00 8548 68 108 0.00 0.00 0.00 0.00 f 0.00 8549 69 108 0.00 0.00 0.00 0.00 f 0.00 8550 70 108 0.00 0.00 0.00 0.00 f 0.00 8551 71 108 0.00 0.00 0.00 0.00 f 0.00 8552 72 108 0.00 0.00 0.00 0.00 f 0.00 8553 73 108 0.00 0.00 0.00 0.00 f 0.00 8532 52 108 0.00 0.00 0.00 0.00 f 0.00 8555 53 110 0.00 0.00 0.00 0.00 f 0.00 8556 54 110 0.00 0.00 0.00 0.00 f 0.00 8557 55 110 0.00 0.00 0.00 0.00 f 0.00 8558 56 110 0.00 0.00 0.00 0.00 f 0.00 8559 57 110 0.00 0.00 0.00 0.00 f 0.00 8560 58 110 0.00 0.00 0.00 0.00 f 0.00 8561 59 110 0.00 0.00 0.00 0.00 f 0.00 8562 60 110 0.00 0.00 0.00 0.00 f 0.00 8563 61 110 0.00 0.00 0.00 0.00 f 0.00 8564 62 110 0.00 0.00 0.00 0.00 f 0.00 8565 63 110 0.00 0.00 0.00 0.00 f 0.00 8566 64 110 0.00 0.00 0.00 0.00 f 0.00 8567 65 110 0.00 0.00 0.00 0.00 f 0.00 8568 66 110 0.00 0.00 0.00 0.00 f 0.00 8569 67 110 0.00 0.00 0.00 0.00 f 0.00 8570 68 110 0.00 0.00 0.00 0.00 f 0.00 8571 69 110 0.00 0.00 0.00 0.00 f 0.00 8572 70 110 0.00 0.00 0.00 0.00 f 0.00 8573 71 110 0.00 0.00 0.00 0.00 f 0.00 8574 72 110 0.00 0.00 0.00 0.00 f 0.00 8575 73 110 0.00 0.00 0.00 0.00 f 0.00 8554 52 110 0.00 0.00 0.00 0.00 f 0.00 8577 53 111 0.00 0.00 0.00 0.00 f 0.00 8578 54 111 0.00 0.00 0.00 0.00 f 0.00 8579 55 111 0.00 0.00 0.00 0.00 f 0.00 8580 56 111 0.00 0.00 0.00 0.00 f 0.00 8581 57 111 0.00 0.00 0.00 0.00 f 0.00 8582 58 111 0.00 0.00 0.00 0.00 f 0.00 8583 59 111 0.00 0.00 0.00 0.00 f 0.00 8584 60 111 0.00 0.00 0.00 0.00 f 0.00 8585 61 111 0.00 0.00 0.00 0.00 f 0.00 8586 62 111 0.00 0.00 0.00 0.00 f 0.00 8587 63 111 0.00 0.00 0.00 0.00 f 0.00 8588 64 111 0.00 0.00 0.00 0.00 f 0.00 8589 65 111 0.00 0.00 0.00 0.00 f 0.00 8590 66 111 0.00 0.00 0.00 0.00 f 0.00 8591 67 111 0.00 0.00 0.00 0.00 f 0.00 8592 68 111 0.00 0.00 0.00 0.00 f 0.00 8593 69 111 0.00 0.00 0.00 0.00 f 0.00 8594 70 111 0.00 0.00 0.00 0.00 f 0.00 8595 71 111 0.00 0.00 0.00 0.00 f 0.00 8596 72 111 0.00 0.00 0.00 0.00 f 0.00 8597 73 111 0.00 0.00 0.00 0.00 f 0.00 8576 52 111 0.00 0.00 0.00 0.00 f 0.00 8599 53 116 0.00 0.00 0.00 0.00 f 0.00 8600 54 116 0.00 0.00 0.00 0.00 f 0.00 8601 55 116 0.00 0.00 0.00 0.00 f 0.00 8602 56 116 0.00 0.00 0.00 0.00 f 0.00 8603 57 116 0.00 0.00 0.00 0.00 f 0.00 8604 58 116 0.00 0.00 0.00 0.00 f 0.00 8605 59 116 0.00 0.00 0.00 0.00 f 0.00 8606 60 116 0.00 0.00 0.00 0.00 f 0.00 8607 61 116 0.00 0.00 0.00 0.00 f 0.00 8608 62 116 0.00 0.00 0.00 0.00 f 0.00 8609 63 116 0.00 0.00 0.00 0.00 f 0.00 8610 64 116 0.00 0.00 0.00 0.00 f 0.00 8611 65 116 0.00 0.00 0.00 0.00 f 0.00 8612 66 116 0.00 0.00 0.00 0.00 f 0.00 8613 67 116 0.00 0.00 0.00 0.00 f 0.00 8614 68 116 0.00 0.00 0.00 0.00 f 0.00 8615 69 116 0.00 0.00 0.00 0.00 f 0.00 8616 70 116 0.00 0.00 0.00 0.00 f 0.00 8617 71 116 0.00 0.00 0.00 0.00 f 0.00 8618 72 116 0.00 0.00 0.00 0.00 f 0.00 8619 73 116 0.00 0.00 0.00 0.00 f 0.00 8598 52 116 0.00 0.00 0.00 0.00 f 0.00 8621 53 88 0.00 0.00 0.00 0.00 f 0.00 8622 54 88 0.00 0.00 0.00 0.00 f 0.00 8623 55 88 0.00 0.00 0.00 0.00 f 0.00 8624 56 88 0.00 0.00 0.00 0.00 f 0.00 8625 57 88 0.00 0.00 0.00 0.00 f 0.00 8626 58 88 0.00 0.00 0.00 0.00 f 0.00 8627 59 88 0.00 0.00 0.00 0.00 f 0.00 8628 60 88 0.00 0.00 0.00 0.00 f 0.00 8629 61 88 0.00 0.00 0.00 0.00 f 0.00 8630 62 88 0.00 0.00 0.00 0.00 f 0.00 8631 63 88 0.00 0.00 0.00 0.00 f 0.00 8632 64 88 0.00 0.00 0.00 0.00 f 0.00 8633 65 88 0.00 0.00 0.00 0.00 f 0.00 8634 66 88 0.00 0.00 0.00 0.00 f 0.00 8635 67 88 0.00 0.00 0.00 0.00 f 0.00 8636 68 88 0.00 0.00 0.00 0.00 f 0.00 8637 69 88 0.00 0.00 0.00 0.00 f 0.00 8638 70 88 0.00 0.00 0.00 0.00 f 0.00 8639 71 88 0.00 0.00 0.00 0.00 f 0.00 8640 72 88 0.00 0.00 0.00 0.00 f 0.00 8641 73 88 0.00 0.00 0.00 0.00 f 0.00 8620 52 88 0.00 0.00 0.00 0.00 f 0.00 8643 53 117 0.00 0.00 0.00 0.00 f 0.00 8644 54 117 0.00 0.00 0.00 0.00 f 0.00 8645 55 117 0.00 0.00 0.00 0.00 f 0.00 8646 56 117 0.00 0.00 0.00 0.00 f 0.00 8647 57 117 0.00 0.00 0.00 0.00 f 0.00 8648 58 117 0.00 0.00 0.00 0.00 f 0.00 8649 59 117 0.00 0.00 0.00 0.00 f 0.00 8650 60 117 0.00 0.00 0.00 0.00 f 0.00 8651 61 117 0.00 0.00 0.00 0.00 f 0.00 8652 62 117 0.00 0.00 0.00 0.00 f 0.00 8653 63 117 0.00 0.00 0.00 0.00 f 0.00 8654 64 117 0.00 0.00 0.00 0.00 f 0.00 8655 65 117 0.00 0.00 0.00 0.00 f 0.00 8656 66 117 0.00 0.00 0.00 0.00 f 0.00 8657 67 117 0.00 0.00 0.00 0.00 f 0.00 8658 68 117 0.00 0.00 0.00 0.00 f 0.00 8659 69 117 0.00 0.00 0.00 0.00 f 0.00 8660 70 117 0.00 0.00 0.00 0.00 f 0.00 8661 71 117 0.00 0.00 0.00 0.00 f 0.00 8662 72 117 0.00 0.00 0.00 0.00 f 0.00 8663 73 117 0.00 0.00 0.00 0.00 f 0.00 8642 52 117 0.00 0.00 0.00 0.00 f 0.00 8665 53 118 0.00 0.00 0.00 0.00 f 0.00 8666 54 118 0.00 0.00 0.00 0.00 f 0.00 8667 55 118 0.00 0.00 0.00 0.00 f 0.00 8668 56 118 0.00 0.00 0.00 0.00 f 0.00 8669 57 118 0.00 0.00 0.00 0.00 f 0.00 8670 58 118 0.00 0.00 0.00 0.00 f 0.00 8671 59 118 0.00 0.00 0.00 0.00 f 0.00 8672 60 118 0.00 0.00 0.00 0.00 f 0.00 8673 61 118 0.00 0.00 0.00 0.00 f 0.00 8674 62 118 0.00 0.00 0.00 0.00 f 0.00 8675 63 118 0.00 0.00 0.00 0.00 f 0.00 8676 64 118 0.00 0.00 0.00 0.00 f 0.00 8677 65 118 0.00 0.00 0.00 0.00 f 0.00 8678 66 118 0.00 0.00 0.00 0.00 f 0.00 8679 67 118 0.00 0.00 0.00 0.00 f 0.00 8680 68 118 0.00 0.00 0.00 0.00 f 0.00 8681 69 118 0.00 0.00 0.00 0.00 f 0.00 8682 70 118 0.00 0.00 0.00 0.00 f 0.00 8683 71 118 0.00 0.00 0.00 0.00 f 0.00 8684 72 118 0.00 0.00 0.00 0.00 f 0.00 8685 73 118 0.00 0.00 0.00 0.00 f 0.00 8664 52 118 0.00 0.00 0.00 0.00 f 0.00 8687 53 119 0.00 0.00 0.00 0.00 f 0.00 8688 54 119 0.00 0.00 0.00 0.00 f 0.00 8689 55 119 0.00 0.00 0.00 0.00 f 0.00 8690 56 119 0.00 0.00 0.00 0.00 f 0.00 8691 57 119 0.00 0.00 0.00 0.00 f 0.00 8692 58 119 0.00 0.00 0.00 0.00 f 0.00 8693 59 119 0.00 0.00 0.00 0.00 f 0.00 8694 60 119 0.00 0.00 0.00 0.00 f 0.00 8695 61 119 0.00 0.00 0.00 0.00 f 0.00 8696 62 119 0.00 0.00 0.00 0.00 f 0.00 8697 63 119 0.00 0.00 0.00 0.00 f 0.00 8698 64 119 0.00 0.00 0.00 0.00 f 0.00 8699 65 119 0.00 0.00 0.00 0.00 f 0.00 8700 66 119 0.00 0.00 0.00 0.00 f 0.00 8701 67 119 0.00 0.00 0.00 0.00 f 0.00 8702 68 119 0.00 0.00 0.00 0.00 f 0.00 8703 69 119 0.00 0.00 0.00 0.00 f 0.00 8704 70 119 0.00 0.00 0.00 0.00 f 0.00 8705 71 119 0.00 0.00 0.00 0.00 f 0.00 8706 72 119 0.00 0.00 0.00 0.00 f 0.00 8707 73 119 0.00 0.00 0.00 0.00 f 0.00 8686 52 119 0.00 0.00 0.00 0.00 f 0.00 8709 53 121 0.00 0.00 0.00 0.00 f 0.00 8710 54 121 0.00 0.00 0.00 0.00 f 0.00 8711 55 121 0.00 0.00 0.00 0.00 f 0.00 8712 56 121 0.00 0.00 0.00 0.00 f 0.00 8713 57 121 0.00 0.00 0.00 0.00 f 0.00 8714 58 121 0.00 0.00 0.00 0.00 f 0.00 8715 59 121 0.00 0.00 0.00 0.00 f 0.00 8716 60 121 0.00 0.00 0.00 0.00 f 0.00 8717 61 121 0.00 0.00 0.00 0.00 f 0.00 8718 62 121 0.00 0.00 0.00 0.00 f 0.00 8719 63 121 0.00 0.00 0.00 0.00 f 0.00 8720 64 121 0.00 0.00 0.00 0.00 f 0.00 8721 65 121 0.00 0.00 0.00 0.00 f 0.00 8722 66 121 0.00 0.00 0.00 0.00 f 0.00 8723 67 121 0.00 0.00 0.00 0.00 f 0.00 8724 68 121 0.00 0.00 0.00 0.00 f 0.00 8725 69 121 0.00 0.00 0.00 0.00 f 0.00 8726 70 121 0.00 0.00 0.00 0.00 f 0.00 8727 71 121 0.00 0.00 0.00 0.00 f 0.00 8728 72 121 0.00 0.00 0.00 0.00 f 0.00 8729 73 121 0.00 0.00 0.00 0.00 f 0.00 8708 52 121 0.00 0.00 0.00 0.00 f 0.00 8731 53 122 0.00 0.00 0.00 0.00 f 0.00 8732 54 122 0.00 0.00 0.00 0.00 f 0.00 8733 55 122 0.00 0.00 0.00 0.00 f 0.00 8734 56 122 0.00 0.00 0.00 0.00 f 0.00 8735 57 122 0.00 0.00 0.00 0.00 f 0.00 8736 58 122 0.00 0.00 0.00 0.00 f 0.00 8737 59 122 0.00 0.00 0.00 0.00 f 0.00 8738 60 122 0.00 0.00 0.00 0.00 f 0.00 8739 61 122 0.00 0.00 0.00 0.00 f 0.00 8740 62 122 0.00 0.00 0.00 0.00 f 0.00 8741 63 122 0.00 0.00 0.00 0.00 f 0.00 8742 64 122 0.00 0.00 0.00 0.00 f 0.00 8743 65 122 0.00 0.00 0.00 0.00 f 0.00 8744 66 122 0.00 0.00 0.00 0.00 f 0.00 8745 67 122 0.00 0.00 0.00 0.00 f 0.00 8746 68 122 0.00 0.00 0.00 0.00 f 0.00 8747 69 122 0.00 0.00 0.00 0.00 f 0.00 8748 70 122 0.00 0.00 0.00 0.00 f 0.00 8749 71 122 0.00 0.00 0.00 0.00 f 0.00 8750 72 122 0.00 0.00 0.00 0.00 f 0.00 8751 73 122 0.00 0.00 0.00 0.00 f 0.00 8730 52 122 0.00 0.00 0.00 0.00 f 0.00 8753 53 97 0.00 0.00 0.00 0.00 f 0.00 8754 54 97 0.00 0.00 0.00 0.00 f 0.00 8755 55 97 0.00 0.00 0.00 0.00 f 0.00 8756 56 97 0.00 0.00 0.00 0.00 f 0.00 8757 57 97 0.00 0.00 0.00 0.00 f 0.00 8758 58 97 0.00 0.00 0.00 0.00 f 0.00 8759 59 97 0.00 0.00 0.00 0.00 f 0.00 8760 60 97 0.00 0.00 0.00 0.00 f 0.00 8761 61 97 0.00 0.00 0.00 0.00 f 0.00 8762 62 97 0.00 0.00 0.00 0.00 f 0.00 8763 63 97 0.00 0.00 0.00 0.00 f 0.00 8764 64 97 0.00 0.00 0.00 0.00 f 0.00 8765 65 97 0.00 0.00 0.00 0.00 f 0.00 8766 66 97 0.00 0.00 0.00 0.00 f 0.00 8767 67 97 0.00 0.00 0.00 0.00 f 0.00 8768 68 97 0.00 0.00 0.00 0.00 f 0.00 8769 69 97 0.00 0.00 0.00 0.00 f 0.00 8770 70 97 0.00 0.00 0.00 0.00 f 0.00 8771 71 97 0.00 0.00 0.00 0.00 f 0.00 8772 72 97 0.00 0.00 0.00 0.00 f 0.00 8773 73 97 0.00 0.00 0.00 0.00 f 0.00 8752 52 97 0.00 0.00 0.00 0.00 f 0.00 8775 53 123 0.00 0.00 0.00 0.00 f 0.00 8776 54 123 0.00 0.00 0.00 0.00 f 0.00 8777 55 123 0.00 0.00 0.00 0.00 f 0.00 8778 56 123 0.00 0.00 0.00 0.00 f 0.00 8779 57 123 0.00 0.00 0.00 0.00 f 0.00 8780 58 123 0.00 0.00 0.00 0.00 f 0.00 8781 59 123 0.00 0.00 0.00 0.00 f 0.00 8782 60 123 0.00 0.00 0.00 0.00 f 0.00 8783 61 123 0.00 0.00 0.00 0.00 f 0.00 8784 62 123 0.00 0.00 0.00 0.00 f 0.00 8785 63 123 0.00 0.00 0.00 0.00 f 0.00 8786 64 123 0.00 0.00 0.00 0.00 f 0.00 8787 65 123 0.00 0.00 0.00 0.00 f 0.00 8788 66 123 0.00 0.00 0.00 0.00 f 0.00 8789 67 123 0.00 0.00 0.00 0.00 f 0.00 8790 68 123 0.00 0.00 0.00 0.00 f 0.00 8791 69 123 0.00 0.00 0.00 0.00 f 0.00 8792 70 123 0.00 0.00 0.00 0.00 f 0.00 8793 71 123 0.00 0.00 0.00 0.00 f 0.00 8794 72 123 0.00 0.00 0.00 0.00 f 0.00 8795 73 123 0.00 0.00 0.00 0.00 f 0.00 8774 52 123 0.00 0.00 0.00 0.00 f 0.00 8797 53 102 0.00 0.00 0.00 0.00 f 0.00 8798 54 102 0.00 0.00 0.00 0.00 f 0.00 8799 55 102 0.00 0.00 0.00 0.00 f 0.00 8800 56 102 0.00 0.00 0.00 0.00 f 0.00 8801 57 102 0.00 0.00 0.00 0.00 f 0.00 8802 58 102 0.00 0.00 0.00 0.00 f 0.00 8803 59 102 0.00 0.00 0.00 0.00 f 0.00 8804 60 102 0.00 0.00 0.00 0.00 f 0.00 8805 61 102 0.00 0.00 0.00 0.00 f 0.00 8806 62 102 0.00 0.00 0.00 0.00 f 0.00 8807 63 102 0.00 0.00 0.00 0.00 f 0.00 8808 64 102 0.00 0.00 0.00 0.00 f 0.00 8809 65 102 0.00 0.00 0.00 0.00 f 0.00 8810 66 102 0.00 0.00 0.00 0.00 f 0.00 8811 67 102 0.00 0.00 0.00 0.00 f 0.00 8812 68 102 0.00 0.00 0.00 0.00 f 0.00 8813 69 102 0.00 0.00 0.00 0.00 f 0.00 8814 70 102 0.00 0.00 0.00 0.00 f 0.00 8815 71 102 0.00 0.00 0.00 0.00 f 0.00 8816 72 102 0.00 0.00 0.00 0.00 f 0.00 8817 73 102 0.00 0.00 0.00 0.00 f 0.00 8796 52 102 0.00 0.00 0.00 0.00 f 0.00 8819 53 124 0.00 0.00 0.00 0.00 f 0.00 8820 54 124 0.00 0.00 0.00 0.00 f 0.00 8821 55 124 0.00 0.00 0.00 0.00 f 0.00 8822 56 124 0.00 0.00 0.00 0.00 f 0.00 8823 57 124 0.00 0.00 0.00 0.00 f 0.00 8824 58 124 0.00 0.00 0.00 0.00 f 0.00 8825 59 124 0.00 0.00 0.00 0.00 f 0.00 8826 60 124 0.00 0.00 0.00 0.00 f 0.00 8827 61 124 0.00 0.00 0.00 0.00 f 0.00 8828 62 124 0.00 0.00 0.00 0.00 f 0.00 8829 63 124 0.00 0.00 0.00 0.00 f 0.00 8830 64 124 0.00 0.00 0.00 0.00 f 0.00 8831 65 124 0.00 0.00 0.00 0.00 f 0.00 8832 66 124 0.00 0.00 0.00 0.00 f 0.00 8833 67 124 0.00 0.00 0.00 0.00 f 0.00 8834 68 124 0.00 0.00 0.00 0.00 f 0.00 8835 69 124 0.00 0.00 0.00 0.00 f 0.00 8836 70 124 0.00 0.00 0.00 0.00 f 0.00 8837 71 124 0.00 0.00 0.00 0.00 f 0.00 8838 72 124 0.00 0.00 0.00 0.00 f 0.00 8839 73 124 0.00 0.00 0.00 0.00 f 0.00 8818 52 124 0.00 0.00 0.00 0.00 f 0.00 8841 53 95 0.00 0.00 0.00 0.00 f 0.00 8842 54 95 0.00 0.00 0.00 0.00 f 0.00 8843 55 95 0.00 0.00 0.00 0.00 f 0.00 8844 56 95 0.00 0.00 0.00 0.00 f 0.00 8845 57 95 0.00 0.00 0.00 0.00 f 0.00 8846 58 95 0.00 0.00 0.00 0.00 f 0.00 8847 59 95 0.00 0.00 0.00 0.00 f 0.00 8848 60 95 0.00 0.00 0.00 0.00 f 0.00 8849 61 95 0.00 0.00 0.00 0.00 f 0.00 8850 62 95 0.00 0.00 0.00 0.00 f 0.00 8851 63 95 0.00 0.00 0.00 0.00 f 0.00 8852 64 95 0.00 0.00 0.00 0.00 f 0.00 8853 65 95 0.00 0.00 0.00 0.00 f 0.00 8854 66 95 0.00 0.00 0.00 0.00 f 0.00 8855 67 95 0.00 0.00 0.00 0.00 f 0.00 8856 68 95 0.00 0.00 0.00 0.00 f 0.00 8857 69 95 0.00 0.00 0.00 0.00 f 0.00 8858 70 95 0.00 0.00 0.00 0.00 f 0.00 8859 71 95 0.00 0.00 0.00 0.00 f 0.00 8860 72 95 0.00 0.00 0.00 0.00 f 0.00 8861 73 95 0.00 0.00 0.00 0.00 f 0.00 8840 52 95 0.00 0.00 0.00 0.00 f 0.00 8863 53 84 0.00 0.00 0.00 0.00 f 0.00 8864 54 84 0.00 0.00 0.00 0.00 f 0.00 8865 55 84 0.00 0.00 0.00 0.00 f 0.00 8866 56 84 0.00 0.00 0.00 0.00 f 0.00 8867 57 84 0.00 0.00 0.00 0.00 f 0.00 8868 58 84 0.00 0.00 0.00 0.00 f 0.00 8869 59 84 0.00 0.00 0.00 0.00 f 0.00 8870 60 84 0.00 0.00 0.00 0.00 f 0.00 8871 61 84 0.00 0.00 0.00 0.00 f 0.00 8872 62 84 0.00 0.00 0.00 0.00 f 0.00 8873 63 84 0.00 0.00 0.00 0.00 f 0.00 8874 64 84 0.00 0.00 0.00 0.00 f 0.00 8875 65 84 0.00 0.00 0.00 0.00 f 0.00 8876 66 84 0.00 0.00 0.00 0.00 f 0.00 8877 67 84 0.00 0.00 0.00 0.00 f 0.00 8878 68 84 0.00 0.00 0.00 0.00 f 0.00 8879 69 84 0.00 0.00 0.00 0.00 f 0.00 8880 70 84 0.00 0.00 0.00 0.00 f 0.00 8881 71 84 0.00 0.00 0.00 0.00 f 0.00 8882 72 84 0.00 0.00 0.00 0.00 f 0.00 8883 73 84 0.00 0.00 0.00 0.00 f 0.00 8862 52 84 0.00 0.00 0.00 0.00 f 0.00 8885 53 113 0.00 0.00 0.00 0.00 f 0.00 8886 54 113 0.00 0.00 0.00 0.00 f 0.00 8887 55 113 0.00 0.00 0.00 0.00 f 0.00 8888 56 113 0.00 0.00 0.00 0.00 f 0.00 8889 57 113 0.00 0.00 0.00 0.00 f 0.00 8890 58 113 0.00 0.00 0.00 0.00 f 0.00 8891 59 113 0.00 0.00 0.00 0.00 f 0.00 8892 60 113 0.00 0.00 0.00 0.00 f 0.00 8893 61 113 0.00 0.00 0.00 0.00 f 0.00 8894 62 113 0.00 0.00 0.00 0.00 f 0.00 8895 63 113 0.00 0.00 0.00 0.00 f 0.00 8896 64 113 0.00 0.00 0.00 0.00 f 0.00 8897 65 113 0.00 0.00 0.00 0.00 f 0.00 8898 66 113 0.00 0.00 0.00 0.00 f 0.00 8899 67 113 0.00 0.00 0.00 0.00 f 0.00 8900 68 113 0.00 0.00 0.00 0.00 f 0.00 8901 69 113 0.00 0.00 0.00 0.00 f 0.00 8902 70 113 0.00 0.00 0.00 0.00 f 0.00 8903 71 113 0.00 0.00 0.00 0.00 f 0.00 8904 72 113 0.00 0.00 0.00 0.00 f 0.00 8905 73 113 0.00 0.00 0.00 0.00 f 0.00 8884 52 113 0.00 0.00 0.00 0.00 f 0.00 8907 53 86 0.00 0.00 0.00 0.00 f 0.00 8908 54 86 0.00 0.00 0.00 0.00 f 0.00 8909 55 86 0.00 0.00 0.00 0.00 f 0.00 8910 56 86 0.00 0.00 0.00 0.00 f 0.00 8911 57 86 0.00 0.00 0.00 0.00 f 0.00 8912 58 86 0.00 0.00 0.00 0.00 f 0.00 8913 59 86 0.00 0.00 0.00 0.00 f 0.00 8914 60 86 0.00 0.00 0.00 0.00 f 0.00 8915 61 86 0.00 0.00 0.00 0.00 f 0.00 8916 62 86 0.00 0.00 0.00 0.00 f 0.00 8917 63 86 0.00 0.00 0.00 0.00 f 0.00 8918 64 86 0.00 0.00 0.00 0.00 f 0.00 8919 65 86 0.00 0.00 0.00 0.00 f 0.00 8920 66 86 0.00 0.00 0.00 0.00 f 0.00 8921 67 86 0.00 0.00 0.00 0.00 f 0.00 8922 68 86 0.00 0.00 0.00 0.00 f 0.00 8923 69 86 0.00 0.00 0.00 0.00 f 0.00 8924 70 86 0.00 0.00 0.00 0.00 f 0.00 8925 71 86 0.00 0.00 0.00 0.00 f 0.00 8926 72 86 0.00 0.00 0.00 0.00 f 0.00 8927 73 86 0.00 0.00 0.00 0.00 f 0.00 8906 52 86 0.00 0.00 0.00 0.00 f 0.00 8929 53 85 0.00 0.00 0.00 0.00 f 0.00 8930 54 85 0.00 0.00 0.00 0.00 f 0.00 8931 55 85 0.00 0.00 0.00 0.00 f 0.00 8932 56 85 0.00 0.00 0.00 0.00 f 0.00 8933 57 85 0.00 0.00 0.00 0.00 f 0.00 8934 58 85 0.00 0.00 0.00 0.00 f 0.00 8935 59 85 0.00 0.00 0.00 0.00 f 0.00 8936 60 85 0.00 0.00 0.00 0.00 f 0.00 8937 61 85 0.00 0.00 0.00 0.00 f 0.00 8938 62 85 0.00 0.00 0.00 0.00 f 0.00 8939 63 85 0.00 0.00 0.00 0.00 f 0.00 8940 64 85 0.00 0.00 0.00 0.00 f 0.00 8941 65 85 0.00 0.00 0.00 0.00 f 0.00 8942 66 85 0.00 0.00 0.00 0.00 f 0.00 8943 67 85 0.00 0.00 0.00 0.00 f 0.00 8944 68 85 0.00 0.00 0.00 0.00 f 0.00 8945 69 85 0.00 0.00 0.00 0.00 f 0.00 8946 70 85 0.00 0.00 0.00 0.00 f 0.00 8947 71 85 0.00 0.00 0.00 0.00 f 0.00 8948 72 85 0.00 0.00 0.00 0.00 f 0.00 8949 73 85 0.00 0.00 0.00 0.00 f 0.00 8928 52 85 0.00 0.00 0.00 0.00 f 0.00 8951 53 109 0.00 0.00 0.00 0.00 f 0.00 8952 54 109 0.00 0.00 0.00 0.00 f 0.00 8953 55 109 0.00 0.00 0.00 0.00 f 0.00 8954 56 109 0.00 0.00 0.00 0.00 f 0.00 8955 57 109 0.00 0.00 0.00 0.00 f 0.00 8956 58 109 0.00 0.00 0.00 0.00 f 0.00 8957 59 109 0.00 0.00 0.00 0.00 f 0.00 8958 60 109 0.00 0.00 0.00 0.00 f 0.00 8959 61 109 0.00 0.00 0.00 0.00 f 0.00 8960 62 109 0.00 0.00 0.00 0.00 f 0.00 8961 63 109 0.00 0.00 0.00 0.00 f 0.00 8962 64 109 0.00 0.00 0.00 0.00 f 0.00 8963 65 109 0.00 0.00 0.00 0.00 f 0.00 8964 66 109 0.00 0.00 0.00 0.00 f 0.00 8965 67 109 0.00 0.00 0.00 0.00 f 0.00 8966 68 109 0.00 0.00 0.00 0.00 f 0.00 8967 69 109 0.00 0.00 0.00 0.00 f 0.00 8968 70 109 0.00 0.00 0.00 0.00 f 0.00 8969 71 109 0.00 0.00 0.00 0.00 f 0.00 8970 72 109 0.00 0.00 0.00 0.00 f 0.00 8971 73 109 0.00 0.00 0.00 0.00 f 0.00 8950 52 109 0.00 0.00 0.00 0.00 f 0.00 8973 53 125 0.00 0.00 0.00 0.00 f 0.00 8974 54 125 0.00 0.00 0.00 0.00 f 0.00 8975 55 125 0.00 0.00 0.00 0.00 f 0.00 8976 56 125 0.00 0.00 0.00 0.00 f 0.00 8977 57 125 0.00 0.00 0.00 0.00 f 0.00 8978 58 125 0.00 0.00 0.00 0.00 f 0.00 8979 59 125 0.00 0.00 0.00 0.00 f 0.00 8980 60 125 0.00 0.00 0.00 0.00 f 0.00 8981 61 125 0.00 0.00 0.00 0.00 f 0.00 8982 62 125 0.00 0.00 0.00 0.00 f 0.00 8983 63 125 0.00 0.00 0.00 0.00 f 0.00 8984 64 125 0.00 0.00 0.00 0.00 f 0.00 8985 65 125 0.00 0.00 0.00 0.00 f 0.00 8986 66 125 0.00 0.00 0.00 0.00 f 0.00 8987 67 125 0.00 0.00 0.00 0.00 f 0.00 8988 68 125 0.00 0.00 0.00 0.00 f 0.00 8989 69 125 0.00 0.00 0.00 0.00 f 0.00 8990 70 125 0.00 0.00 0.00 0.00 f 0.00 8991 71 125 0.00 0.00 0.00 0.00 f 0.00 8992 72 125 0.00 0.00 0.00 0.00 f 0.00 8993 73 125 0.00 0.00 0.00 0.00 f 0.00 8972 52 125 0.00 0.00 0.00 0.00 f 0.00 8995 53 106 0.00 0.00 0.00 0.00 f 0.00 8996 54 106 0.00 0.00 0.00 0.00 f 0.00 8997 55 106 0.00 0.00 0.00 0.00 f 0.00 8998 56 106 0.00 0.00 0.00 0.00 f 0.00 8999 57 106 0.00 0.00 0.00 0.00 f 0.00 9000 58 106 0.00 0.00 0.00 0.00 f 0.00 9001 59 106 0.00 0.00 0.00 0.00 f 0.00 9002 60 106 0.00 0.00 0.00 0.00 f 0.00 9003 61 106 0.00 0.00 0.00 0.00 f 0.00 9004 62 106 0.00 0.00 0.00 0.00 f 0.00 9005 63 106 0.00 0.00 0.00 0.00 f 0.00 9006 64 106 0.00 0.00 0.00 0.00 f 0.00 9007 65 106 0.00 0.00 0.00 0.00 f 0.00 9008 66 106 0.00 0.00 0.00 0.00 f 0.00 9009 67 106 0.00 0.00 0.00 0.00 f 0.00 9010 68 106 0.00 0.00 0.00 0.00 f 0.00 9011 69 106 0.00 0.00 0.00 0.00 f 0.00 9012 70 106 0.00 0.00 0.00 0.00 f 0.00 9013 71 106 0.00 0.00 0.00 0.00 f 0.00 9014 72 106 0.00 0.00 0.00 0.00 f 0.00 9015 73 106 0.00 0.00 0.00 0.00 f 0.00 8994 52 106 0.00 0.00 0.00 0.00 f 0.00 9017 53 126 0.00 0.00 0.00 0.00 f 0.00 9018 54 126 0.00 0.00 0.00 0.00 f 0.00 9019 55 126 0.00 0.00 0.00 0.00 f 0.00 9020 56 126 0.00 0.00 0.00 0.00 f 0.00 9021 57 126 0.00 0.00 0.00 0.00 f 0.00 9022 58 126 0.00 0.00 0.00 0.00 f 0.00 9023 59 126 0.00 0.00 0.00 0.00 f 0.00 9024 60 126 0.00 0.00 0.00 0.00 f 0.00 9025 61 126 0.00 0.00 0.00 0.00 f 0.00 9026 62 126 0.00 0.00 0.00 0.00 f 0.00 9027 63 126 0.00 0.00 0.00 0.00 f 0.00 9028 64 126 0.00 0.00 0.00 0.00 f 0.00 9029 65 126 0.00 0.00 0.00 0.00 f 0.00 9030 66 126 0.00 0.00 0.00 0.00 f 0.00 9031 67 126 0.00 0.00 0.00 0.00 f 0.00 9032 68 126 0.00 0.00 0.00 0.00 f 0.00 9033 69 126 0.00 0.00 0.00 0.00 f 0.00 9034 70 126 0.00 0.00 0.00 0.00 f 0.00 9035 71 126 0.00 0.00 0.00 0.00 f 0.00 9036 72 126 0.00 0.00 0.00 0.00 f 0.00 9037 73 126 0.00 0.00 0.00 0.00 f 0.00 9016 52 126 0.00 0.00 0.00 0.00 f 0.00 9039 53 127 0.00 0.00 0.00 0.00 f 0.00 9040 54 127 0.00 0.00 0.00 0.00 f 0.00 9041 55 127 0.00 0.00 0.00 0.00 f 0.00 9042 56 127 0.00 0.00 0.00 0.00 f 0.00 9043 57 127 0.00 0.00 0.00 0.00 f 0.00 9044 58 127 0.00 0.00 0.00 0.00 f 0.00 9045 59 127 0.00 0.00 0.00 0.00 f 0.00 9046 60 127 0.00 0.00 0.00 0.00 f 0.00 9047 61 127 0.00 0.00 0.00 0.00 f 0.00 9048 62 127 0.00 0.00 0.00 0.00 f 0.00 9049 63 127 0.00 0.00 0.00 0.00 f 0.00 9050 64 127 0.00 0.00 0.00 0.00 f 0.00 9051 65 127 0.00 0.00 0.00 0.00 f 0.00 9052 66 127 0.00 0.00 0.00 0.00 f 0.00 9053 67 127 0.00 0.00 0.00 0.00 f 0.00 9054 68 127 0.00 0.00 0.00 0.00 f 0.00 9055 69 127 0.00 0.00 0.00 0.00 f 0.00 9056 70 127 0.00 0.00 0.00 0.00 f 0.00 9057 71 127 0.00 0.00 0.00 0.00 f 0.00 9058 72 127 0.00 0.00 0.00 0.00 f 0.00 9059 73 127 0.00 0.00 0.00 0.00 f 0.00 9038 52 127 0.00 0.00 0.00 0.00 f 0.00 9061 53 120 0.00 0.00 0.00 0.00 f 0.00 9062 54 120 0.00 0.00 0.00 0.00 f 0.00 9063 55 120 0.00 0.00 0.00 0.00 f 0.00 9064 56 120 0.00 0.00 0.00 0.00 f 0.00 9065 57 120 0.00 0.00 0.00 0.00 f 0.00 9066 58 120 0.00 0.00 0.00 0.00 f 0.00 9067 59 120 0.00 0.00 0.00 0.00 f 0.00 9068 60 120 0.00 0.00 0.00 0.00 f 0.00 9069 61 120 0.00 0.00 0.00 0.00 f 0.00 9070 62 120 0.00 0.00 0.00 0.00 f 0.00 9071 63 120 0.00 0.00 0.00 0.00 f 0.00 9072 64 120 0.00 0.00 0.00 0.00 f 0.00 9073 65 120 0.00 0.00 0.00 0.00 f 0.00 9074 66 120 0.00 0.00 0.00 0.00 f 0.00 9075 67 120 0.00 0.00 0.00 0.00 f 0.00 9076 68 120 0.00 0.00 0.00 0.00 f 0.00 9077 69 120 0.00 0.00 0.00 0.00 f 0.00 9078 70 120 0.00 0.00 0.00 0.00 f 0.00 9079 71 120 0.00 0.00 0.00 0.00 f 0.00 9080 72 120 0.00 0.00 0.00 0.00 f 0.00 9081 73 120 0.00 0.00 0.00 0.00 f 0.00 9060 52 120 0.00 0.00 0.00 0.00 f 0.00 9083 53 128 0.00 0.00 0.00 0.00 f 0.00 9084 54 128 0.00 0.00 0.00 0.00 f 0.00 9085 55 128 0.00 0.00 0.00 0.00 f 0.00 9086 56 128 0.00 0.00 0.00 0.00 f 0.00 9087 57 128 0.00 0.00 0.00 0.00 f 0.00 9088 58 128 0.00 0.00 0.00 0.00 f 0.00 9089 59 128 0.00 0.00 0.00 0.00 f 0.00 9090 60 128 0.00 0.00 0.00 0.00 f 0.00 9091 61 128 0.00 0.00 0.00 0.00 f 0.00 9092 62 128 0.00 0.00 0.00 0.00 f 0.00 9093 63 128 0.00 0.00 0.00 0.00 f 0.00 9094 64 128 0.00 0.00 0.00 0.00 f 0.00 9095 65 128 0.00 0.00 0.00 0.00 f 0.00 9096 66 128 0.00 0.00 0.00 0.00 f 0.00 9097 67 128 0.00 0.00 0.00 0.00 f 0.00 9098 68 128 0.00 0.00 0.00 0.00 f 0.00 9099 69 128 0.00 0.00 0.00 0.00 f 0.00 9100 70 128 0.00 0.00 0.00 0.00 f 0.00 9101 71 128 0.00 0.00 0.00 0.00 f 0.00 9102 72 128 0.00 0.00 0.00 0.00 f 0.00 9103 73 128 0.00 0.00 0.00 0.00 f 0.00 9082 52 128 0.00 0.00 0.00 0.00 f 0.00 9105 53 112 0.00 0.00 0.00 0.00 f 0.00 9106 54 112 0.00 0.00 0.00 0.00 f 0.00 9107 55 112 0.00 0.00 0.00 0.00 f 0.00 9108 56 112 0.00 0.00 0.00 0.00 f 0.00 9109 57 112 0.00 0.00 0.00 0.00 f 0.00 9110 58 112 0.00 0.00 0.00 0.00 f 0.00 9111 59 112 0.00 0.00 0.00 0.00 f 0.00 9112 60 112 0.00 0.00 0.00 0.00 f 0.00 9113 61 112 0.00 0.00 0.00 0.00 f 0.00 9114 62 112 0.00 0.00 0.00 0.00 f 0.00 9115 63 112 0.00 0.00 0.00 0.00 f 0.00 9116 64 112 0.00 0.00 0.00 0.00 f 0.00 9117 65 112 0.00 0.00 0.00 0.00 f 0.00 9118 66 112 0.00 0.00 0.00 0.00 f 0.00 9119 67 112 0.00 0.00 0.00 0.00 f 0.00 9120 68 112 0.00 0.00 0.00 0.00 f 0.00 9121 69 112 0.00 0.00 0.00 0.00 f 0.00 9122 70 112 0.00 0.00 0.00 0.00 f 0.00 9123 71 112 0.00 0.00 0.00 0.00 f 0.00 9124 72 112 0.00 0.00 0.00 0.00 f 0.00 9125 73 112 0.00 0.00 0.00 0.00 f 0.00 9104 52 112 0.00 0.00 0.00 0.00 f 0.00 9127 53 129 0.00 0.00 0.00 0.00 f 0.00 9128 54 129 0.00 0.00 0.00 0.00 f 0.00 9129 55 129 0.00 0.00 0.00 0.00 f 0.00 9130 56 129 0.00 0.00 0.00 0.00 f 0.00 9131 57 129 0.00 0.00 0.00 0.00 f 0.00 9132 58 129 0.00 0.00 0.00 0.00 f 0.00 9133 59 129 0.00 0.00 0.00 0.00 f 0.00 9134 60 129 0.00 0.00 0.00 0.00 f 0.00 9135 61 129 0.00 0.00 0.00 0.00 f 0.00 9136 62 129 0.00 0.00 0.00 0.00 f 0.00 9137 63 129 0.00 0.00 0.00 0.00 f 0.00 9138 64 129 0.00 0.00 0.00 0.00 f 0.00 9139 65 129 0.00 0.00 0.00 0.00 f 0.00 9140 66 129 0.00 0.00 0.00 0.00 f 0.00 9141 67 129 0.00 0.00 0.00 0.00 f 0.00 9142 68 129 0.00 0.00 0.00 0.00 f 0.00 9143 69 129 0.00 0.00 0.00 0.00 f 0.00 9144 70 129 0.00 0.00 0.00 0.00 f 0.00 9145 71 129 0.00 0.00 0.00 0.00 f 0.00 9146 72 129 0.00 0.00 0.00 0.00 f 0.00 9147 73 129 0.00 0.00 0.00 0.00 f 0.00 9126 52 129 0.00 0.00 0.00 0.00 f 0.00 \. -- -- Name: trialbal_trialbal_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('trialbal_trialbal_id_seq', 9147, true); -- -- Data for Name: uiform; Type: TABLE DATA; Schema: public; Owner: admin -- COPY uiform (uiform_id, uiform_name, uiform_order, uiform_enabled, uiform_source, uiform_notes) FROM stdin; \. -- -- Name: uiform_uiform_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('uiform_uiform_id_seq', 65, true); -- -- Data for Name: uom; Type: TABLE DATA; Schema: public; Owner: admin -- COPY uom (uom_id, uom_name, uom_descrip, uom_item_weight) FROM stdin; 7 LB Pounds t 5 CS Case f 4 EA Each f 6 PL Pallet f 8 KG Kilos f \. -- -- Name: uom_uom_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('uom_uom_id_seq', 8, true); -- -- Data for Name: uomconv; Type: TABLE DATA; Schema: public; Owner: admin -- COPY uomconv (uomconv_id, uomconv_from_uom_id, uomconv_from_value, uomconv_to_uom_id, uomconv_to_value, uomconv_fractional) FROM stdin; 1 7 2.2040000000 8 1.0000000000 t \. -- -- Name: uomconv_uomconv_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('uomconv_uomconv_id_seq', 1, true); -- -- Data for Name: uomtype; Type: TABLE DATA; Schema: public; Owner: admin -- COPY uomtype (uomtype_id, uomtype_name, uomtype_descrip, uomtype_multiple) FROM stdin; 1 Selling Selling a.k.a. Pricing and Shipping UOMs. t 2 Capacity Capacity UOMs. f 3 AltCapacity Alternate Capacity UOMs. f 4 MaterialIssue Material Issuing UOMs. f \. -- -- Name: uomtype_uomtype_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('uomtype_uomtype_id_seq', 4, true); -- -- Data for Name: urlinfo; Type: TABLE DATA; Schema: public; Owner: admin -- COPY urlinfo (url_id, url_title, url_url) FROM stdin; \. -- -- Name: urlinfo_url_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('urlinfo_url_id_seq', 1, false); -- -- Data for Name: usr_bak; Type: TABLE DATA; Schema: public; Owner: admin -- COPY usr_bak (usr_id, usr_username, usr_propername, usr_passwd, usr_locale_id, usr_initials, usr_agent, usr_active, usr_email, usr_window) FROM stdin; 1 mfgadmin OpenMFG Administrator \N 3 ADMIN t t admin@example.com 2 admin Administrator 3 ADMIN t t admin@example.com \N \. -- -- Name: usr_usr_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('usr_usr_id_seq', 9, true); -- -- Data for Name: usrgrp; Type: TABLE DATA; Schema: public; Owner: admin -- COPY usrgrp (usrgrp_id, usrgrp_grp_id, usrgrp_username) FROM stdin; 1 1 admin \. -- -- Name: usrgrp_usrgrp_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('usrgrp_usrgrp_id_seq', 1, true); -- -- Data for Name: usrpref; Type: TABLE DATA; Schema: public; Owner: admin -- COPY usrpref (usrpref_id, usrpref_name, usrpref_value, usrpref_username) FROM stdin; 2 ShowIMMenu t mfgadmin 3 ShowPDMenu t mfgadmin 4 ShowMSMenu t mfgadmin 5 ShowCPMenu t mfgadmin 6 ShowWOMenu t mfgadmin 7 ShowPOMenu t mfgadmin 8 ShowSOMenu t mfgadmin 9 ShowSRMenu t mfgadmin 10 ShowSAMenu t mfgadmin 28 ShowGLMenu t mfgadmin 34 UseCustCache f mfgadmin 29 ShowAPMenu t mfgadmin 27 ShowARMenu t mfgadmin 48 ShowPDToolbar t mfgadmin 51 ShowMSToolbar t mfgadmin 52 ShowCPToolbar t mfgadmin 49 ShowWOToolbar t mfgadmin 30 ShowSOToolbar t mfgadmin 53 ShowSRToolbar t mfgadmin 73 UsedFixedWidthFonts f mfgadmin 47 ShowIMToolbar t mfgadmin 74 ShowSAToolbar t mfgadmin 50 ShowPOToolbar t mfgadmin 76 ShowGLToolbar t mfgadmin 108 ToolbarPositions \n\n\nI/M Tools,P/D Tools,W/O Tools,P/O Tools,S/O Tools,\n[I/M Tools,0,0,-1,-1,1][P/D Tools,0,0,-1,-1,1][W/O Tools,0,0,-1,-1,1][P/O Tools,0,0,-1,-1,1][S/O Tools,0,0,-1,-1,1]\n\n\n\n\n\n\n mfgadmin 11 PreferredWarehouse 35 mfgadmin 112 UseItemCache f mfgadmin 54 ShowRIWorkOrdersByDefault f mfgadmin 113 ListNumericItemNumbersFirst f mfgadmin 114 ShowSOItemAvailability t mfgadmin 116 DefaultEllipsesAction list mfgadmin 117 ShowPMMenu t mfgadmin 118 ShowPMToolbar t mfgadmin 75 ShowAPToolbar t mfgadmin 111 ShowARToolbar t mfgadmin 119 ShowCRMMenu t mfgadmin 120 ShowCRMToolbar t mfgadmin 121 InterfaceWindowOption Workspace mfgadmin 1 BackgroundImageid 14 mfgadmin 122 reports/_report/columnsShown 0,on|1,on|2,on| mfgadmin 123 user/_available/columnsShown 0,on| mfgadmin 124 user/_granted/columnsShown 0,on| mfgadmin 125 users/_usr/columnsShown 0,on|1,on|2,on| mfgadmin 126 UseOldMenu f mfgadmin 127 XCheckBox/forgetful f mfgadmin 115 IdleTimeout 30 mfgadmin 128 userPreferences/_hotkey/columnsShown 0,on|1,on|2,on| mfgadmin 129 userPreferences/_event/columnsShown 0,on|1,on|2,on| mfgadmin 130 userPreferences/_warehouses/columnsShown 0,on|1,on|2,on| mfgadmin 131 configureIM/_shipformWatermarks/columnsShown 0,on|1,on|2,on| mfgadmin 132 configureSO/_invoiceWatermarks/columnsShown 0,on|1,on|2,on| mfgadmin 133 configureSO/_creditMemoWatermarks/columnsShown 0,on|1,on|2,on| mfgadmin 134 salesAccounts/_salesaccnt/columnsShown 0,on|1,on|2,on|3,on|4,on|5,on|6,off|7,off|8,off| mfgadmin 135 /_accnt/columnsShown 0,on|1,on|2,on|3,on|4,on| mfgadmin 136 accountNumbers/_account/columnsShown 0,on|1,on|2,on|3,on|4,on|5,on| mfgadmin 137 arAccountAssignments/_araccnt/columnsShown 0,on|1,on|2,on|3,on|4,on| mfgadmin 138 classCodes/_classcode/columnsShown 0,on|1,on| mfgadmin 139 costCategories/_costcat/columnsShown 0,on|1,on| mfgadmin 140 termses/_terms/columnsShown 0,on|1,on|2,on|3,on|4,on| mfgadmin 141 apAccountAssignments/_apaccnt/columnsShown 0,on|1,on|2,on|3,on| mfgadmin 142 accountingYearPeriods/_period/columnsShown 0,on|1,on|2,on| mfgadmin 143 accountingPeriods/_period/columnsShown 0,on|1,on|2,on|3,on|4,on|5,on|6,on| mfgadmin 144 dspFinancialReport/_periods/columnsShown 0,on|1,on| mfgadmin 145 dspFinancialReport/_showBegBal/checked 0 mfgadmin 146 dspFinancialReport/_showBegBalPrcnt/checked 0 mfgadmin 147 dspFinancialReport/_showDebits/checked 0 mfgadmin 148 dspFinancialReport/_showDebitsPrcnt/checked 0 mfgadmin 149 dspFinancialReport/_showCredits/checked 0 mfgadmin 150 dspFinancialReport/_showCreditsPrcnt/checked 0 mfgadmin 151 dspFinancialReport/_showEndBal/checked 0 mfgadmin 152 dspFinancialReport/_showEndBalPrcnt/checked 0 mfgadmin 153 dspFinancialReport/_showBudget/checked 0 mfgadmin 154 dspFinancialReport/_showBudgetPrcnt/checked 0 mfgadmin 155 dspFinancialReport/_showDiff/checked 0 mfgadmin 156 dspFinancialReport/_showDiffPrcnt/checked 0 mfgadmin 157 dspFinancialReport/_showCustom/checked 0 mfgadmin 158 dspFinancialReport/_showCustomPrcnt/checked 0 mfgadmin 159 dspFinancialReport/_shownumbers/checked 2 mfgadmin 160 dspFinancialReport/_showzeros/checked 2 mfgadmin 161 dspFinancialReport/_layout/columnsShown 0,on|1,on|2,on|3,on|4,on| mfgadmin 162 fixSerial/_serial/columnsShown 0,on|1,on|2,on|3,on|4,on| mfgadmin 163 importXML/_file/columnsShown 0,on|1,on| mfgadmin 164 importXML/_autoUpdate/checked 0 mfgadmin 165 taxCodes/_tax/columnsShown 0,on|1,on| mfgadmin 166 expenseCategories/_expcat/columnsShown 0,on|1,on| mfgadmin 167 incidentCategories/_incidentCategories/columnsShown 0,on|1,on|2,on| mfgadmin 168 opportunitySources/_oplist/columnsShown 0,on|1,on| mfgadmin 169 incidentWorkbench/_statusFeedback/checked 2 mfgadmin 170 incidentWorkbench/_statusConfirmed/checked 2 mfgadmin 171 incidentWorkbench/_statusNew/checked 2 mfgadmin 172 incidentWorkbench/_statusResolved/checked 2 mfgadmin 173 incidentWorkbench/_statusClosed/checked 2 mfgadmin 174 incidentWorkbench/_statusAssigned/checked 2 mfgadmin 175 incidentWorkbench/_incdt/columnsShown 0,on|1,on|2,on|3,on|4,on| mfgadmin 176 incidentWorkbench/_autoUpdate/checked 2 mfgadmin 177 customerFormAssignments/_custform/columnsShown 0,on|1,on|2,on|3,on|4,on|5,on|6,on| mfgadmin 368 agent t mfgadmin 178 taxAuthorities/_taxauth/columnsShown 0,on|1,on| mfgadmin 179 uom/_uomconv/columnsShown 0,on|1,on|2,on| mfgadmin 180 items/_showInactive/checked 0 mfgadmin 181 items/_item/columnsShown 0,on|1,on|2,on|3,on|4,on|5,on| mfgadmin 182 costingElements/_costelem/columnsShown 0,on| mfgadmin 183 uoms/_uoms/columnsShown 0,on|1,on| mfgadmin 184 _commentsTab/_comment/columnsShown 0,on|1,on|2,on|3,on| mfgadmin 185 warehouse/_whsezone/columnsShown 0,on|1,on| mfgadmin 186 taxTypes/_taxtype/columnsShown 0,on|1,on| mfgadmin 187 taxSelections/_taxsel/columnsShown 0,on|1,on|2,on| mfgadmin 188 salesCategories/_salescat/columnsShown 0,on|1,on| mfgadmin 189 bankAccounts/_bankaccnt/columnsShown 0,on|1,on|2,on|3,on|4,on|5,off| mfgadmin 190 vendorTypes/_vendtype/columnsShown 0,on|1,on| mfgadmin 191 shippingForms/_bolformat/columnsShown 0,on| mfgadmin 192 financialLayout/_layouts/columnsShown 0,on|1,on| mfgadmin 193 financialLayout/_layout/columnsShown 0,on|1,on|2,on|3,on|4,on|5,on|6,on|7,on|8,on| mfgadmin 194 financialLayouts/_flhead/columnsShown 0,on|1,on|2,on|3,on| mfgadmin 195 checkFormats/_form/columnsShown 0,on|1,on| mfgadmin 196 subAccntTypes/_subaccnttypes/columnsShown 0,on|1,on|2,on| mfgadmin 197 companies/_company/columnsShown 0,on|1,on| mfgadmin 198 profitCenters/_prftcntr/columnsShown 0,on|1,on| mfgadmin 199 reasonCodes/_rsncode/columnsShown 0,on|1,on| mfgadmin 200 bankAdjustmentTypes/_bankadjtype/columnsShown 0,on|1,on| mfgadmin 109 DisableExportContents f mfgadmin 110 UseEnhancedAuthentication f mfgadmin 201 eventManager/_showAcknowledged/checked 0 mfgadmin 202 eventManager/_event/columnsShown 0,on|1,on|2,on|3,on|4,on|5,on|6,on|7,on| mfgadmin 203 eventManager/_autoUpdate/checked 0 mfgadmin 204 images/_image/columnsShown 0,on|1,on|2,on| mfgadmin 205 forms/_form/columnsShown 0,on|1,on| mfgadmin 206 currencies/_curr/columnsShown 0,on|1,on|2,on|3,on| mfgadmin 207 productCategories/_prodcat/columnsShown 0,on|1,on| mfgadmin 208 /_item/columnsShown 0,on|1,on| mfgadmin 209 shipVias/_shipvia/columnsShown 0,on|1,on| mfgadmin 210 customer/_cc/columnsShown 0,on|1,on|2,on|3,on| mfgadmin 211 tabComments/_comment/columnsShown 0,on|1,on|2,on|3,on| mfgadmin 212 customer/_charass/columnsShown 0,on|1,on| mfgadmin 213 customer/_shipto/columnsShown 0,on|1,on|2,on|3,on|4,on| mfgadmin 214 customer/_taxreg/columnsShown 0,on|1,on| mfgadmin 215 salesReps/_salesrep/columnsShown 0,on|1,on|2,on| mfgadmin 216 shippingZones/_shipzone/columnsShown 0,on|1,on| mfgadmin 217 crmaccounts/_crmaccount/columnsShown 0,on|1,on|2,on|3,on|4,on|5,on|6,on|7,on| mfgadmin 218 customers/_cust/columnsShown 0,on|1,on|2,on|3,on|4,on|5,on| mfgadmin 219 customCommands/_commands/columnsShown 0,on|1,on| mfgadmin 220 departments/_deptList/columnsShown 0,on|1,on| mfgadmin 221 calendars/_calhead/columnsShown 0,on|1,on| mfgadmin 222 ShowIMMenu t admin 223 ShowPDMenu t admin 224 ShowMSMenu t admin 225 ShowCPMenu t admin 226 ShowWOMenu t admin 227 ShowPOMenu t admin 228 ShowSOMenu t admin 229 ShowSRMenu t admin 230 ShowSAMenu t admin 231 ShowGLMenu t admin 232 UseCustCache f admin 233 ShowAPMenu t admin 234 ShowARMenu t admin 235 ShowPDToolbar t admin 236 ShowMSToolbar t admin 237 ShowCPToolbar t admin 238 ShowWOToolbar t admin 239 ShowSOToolbar t admin 240 ShowSRToolbar t admin 241 UsedFixedWidthFonts f admin 242 ShowIMToolbar t admin 243 ShowSAToolbar t admin 244 ShowPOToolbar t admin 245 ShowGLToolbar t admin 246 ToolbarPositions \n\n\nI/M Tools,P/D Tools,W/O Tools,P/O Tools,S/O Tools,\n[I/M Tools,0,0,-1,-1,1][P/D Tools,0,0,-1,-1,1][W/O Tools,0,0,-1,-1,1][P/O Tools,0,0,-1,-1,1][S/O Tools,0,0,-1,-1,1]\n\n\n\n\n\n\n admin 247 PreferredWarehouse 35 admin 248 UseItemCache f admin 249 ShowRIWorkOrdersByDefault f admin 250 ListNumericItemNumbersFirst f admin 251 ShowSOItemAvailability t admin 252 DefaultEllipsesAction list admin 253 ShowPMMenu t admin 254 ShowPMToolbar t admin 255 ShowAPToolbar t admin 256 ShowARToolbar t admin 257 ShowCRMMenu t admin 258 ShowCRMToolbar t admin 260 BackgroundImageid 14 admin 261 reports/_report/columnsShown 0,on|1,on|2,on| admin 262 user/_available/columnsShown 0,on| admin 263 user/_granted/columnsShown 0,on| admin 264 users/_usr/columnsShown 0,on|1,on|2,on| admin 265 UseOldMenu f admin 266 XCheckBox/forgetful f admin 267 IdleTimeout 30 admin 268 userPreferences/_hotkey/columnsShown 0,on|1,on|2,on| admin 269 userPreferences/_event/columnsShown 0,on|1,on|2,on| admin 270 userPreferences/_warehouses/columnsShown 0,on|1,on|2,on| admin 271 configureIM/_shipformWatermarks/columnsShown 0,on|1,on|2,on| admin 272 configureSO/_invoiceWatermarks/columnsShown 0,on|1,on|2,on| admin 273 configureSO/_creditMemoWatermarks/columnsShown 0,on|1,on|2,on| admin 274 salesAccounts/_salesaccnt/columnsShown 0,on|1,on|2,on|3,on|4,on|5,on|6,off|7,off|8,off| admin 278 classCodes/_classcode/columnsShown 0,on|1,on| admin 279 costCategories/_costcat/columnsShown 0,on|1,on| admin 280 termses/_terms/columnsShown 0,on|1,on|2,on|3,on|4,on| admin 281 apAccountAssignments/_apaccnt/columnsShown 0,on|1,on|2,on|3,on| admin 282 accountingYearPeriods/_period/columnsShown 0,on|1,on|2,on| admin 283 accountingPeriods/_period/columnsShown 0,on|1,on|2,on|3,on|4,on|5,on|6,on| admin 284 dspFinancialReport/_periods/columnsShown 0,on|1,on| admin 285 dspFinancialReport/_showBegBal/checked 0 admin 286 dspFinancialReport/_showBegBalPrcnt/checked 0 admin 287 dspFinancialReport/_showDebits/checked 0 admin 288 dspFinancialReport/_showDebitsPrcnt/checked 0 admin 289 dspFinancialReport/_showCredits/checked 0 admin 290 dspFinancialReport/_showCreditsPrcnt/checked 0 admin 291 dspFinancialReport/_showEndBal/checked 0 admin 292 dspFinancialReport/_showEndBalPrcnt/checked 0 admin 293 dspFinancialReport/_showBudget/checked 0 admin 294 dspFinancialReport/_showBudgetPrcnt/checked 0 admin 295 dspFinancialReport/_showDiff/checked 0 admin 296 dspFinancialReport/_showDiffPrcnt/checked 0 admin 297 dspFinancialReport/_showCustom/checked 0 admin 298 dspFinancialReport/_showCustomPrcnt/checked 0 admin 299 dspFinancialReport/_shownumbers/checked 2 admin 300 dspFinancialReport/_showzeros/checked 2 admin 301 dspFinancialReport/_layout/columnsShown 0,on|1,on|2,on|3,on|4,on| admin 302 fixSerial/_serial/columnsShown 0,on|1,on|2,on|3,on|4,on| admin 303 importXML/_file/columnsShown 0,on|1,on| admin 304 importXML/_autoUpdate/checked 0 admin 305 taxCodes/_tax/columnsShown 0,on|1,on| admin 306 expenseCategories/_expcat/columnsShown 0,on|1,on| admin 307 incidentCategories/_incidentCategories/columnsShown 0,on|1,on|2,on| admin 308 opportunitySources/_oplist/columnsShown 0,on|1,on| admin 309 incidentWorkbench/_statusFeedback/checked 2 admin 310 incidentWorkbench/_statusConfirmed/checked 2 admin 311 incidentWorkbench/_statusNew/checked 2 admin 312 incidentWorkbench/_statusResolved/checked 2 admin 313 incidentWorkbench/_statusClosed/checked 2 admin 314 incidentWorkbench/_statusAssigned/checked 2 admin 315 incidentWorkbench/_incdt/columnsShown 0,on|1,on|2,on|3,on|4,on| admin 316 incidentWorkbench/_autoUpdate/checked 2 admin 317 customerFormAssignments/_custform/columnsShown 0,on|1,on|2,on|3,on|4,on|5,on|6,on| admin 318 taxAuthorities/_taxauth/columnsShown 0,on|1,on| admin 319 uom/_uomconv/columnsShown 0,on|1,on|2,on| admin 320 items/_showInactive/checked 0 admin 321 items/_item/columnsShown 0,on|1,on|2,on|3,on|4,on|5,on| admin 322 costingElements/_costelem/columnsShown 0,on| admin 323 uoms/_uoms/columnsShown 0,on|1,on| admin 324 _commentsTab/_comment/columnsShown 0,on|1,on|2,on|3,on| admin 325 warehouse/_whsezone/columnsShown 0,on|1,on| admin 326 taxTypes/_taxtype/columnsShown 0,on|1,on| admin 327 taxSelections/_taxsel/columnsShown 0,on|1,on|2,on| admin 328 salesCategories/_salescat/columnsShown 0,on|1,on| admin 329 bankAccounts/_bankaccnt/columnsShown 0,on|1,on|2,on|3,on|4,on|5,off| admin 330 vendorTypes/_vendtype/columnsShown 0,on|1,on| admin 331 shippingForms/_bolformat/columnsShown 0,on| admin 332 financialLayout/_layouts/columnsShown 0,on|1,on| admin 334 financialLayouts/_flhead/columnsShown 0,on|1,on|2,on|3,on| admin 335 checkFormats/_form/columnsShown 0,on|1,on| admin 336 subAccntTypes/_subaccnttypes/columnsShown 0,on|1,on|2,on| admin 337 companies/_company/columnsShown 0,on|1,on| admin 338 profitCenters/_prftcntr/columnsShown 0,on|1,on| admin 339 reasonCodes/_rsncode/columnsShown 0,on|1,on| admin 340 bankAdjustmentTypes/_bankadjtype/columnsShown 0,on|1,on| admin 343 eventManager/_showAcknowledged/checked 0 admin 344 eventManager/_event/columnsShown 0,on|1,on|2,on|3,on|4,on|5,on|6,on|7,on| admin 345 eventManager/_autoUpdate/checked 0 admin 346 images/_image/columnsShown 0,on|1,on|2,on| admin 347 forms/_form/columnsShown 0,on|1,on| admin 348 currencies/_curr/columnsShown 0,on|1,on|2,on|3,on| admin 349 productCategories/_prodcat/columnsShown 0,on|1,on| admin 350 /_item/columnsShown 0,on|1,on| admin 351 shipVias/_shipvia/columnsShown 0,on|1,on| admin 352 customer/_cc/columnsShown 0,on|1,on|2,on|3,on| admin 353 tabComments/_comment/columnsShown 0,on|1,on|2,on|3,on| admin 354 customer/_charass/columnsShown 0,on|1,on| admin 355 customer/_shipto/columnsShown 0,on|1,on|2,on|3,on|4,on| admin 356 customer/_taxreg/columnsShown 0,on|1,on| admin 357 salesReps/_salesrep/columnsShown 0,on|1,on|2,on| admin 358 shippingZones/_shipzone/columnsShown 0,on|1,on| admin 359 crmaccounts/_crmaccount/columnsShown 0,on|1,on|2,on|3,on|4,on|5,on|6,on|7,on| admin 360 customers/_cust/columnsShown 0,on|1,on|2,on|3,on|4,on|5,on| admin 361 customCommands/_commands/columnsShown 0,on|1,on| admin 362 departments/_deptList/columnsShown 0,on|1,on| admin 275 /_accnt/columnsShown 0,on|1,on|2,on|3,on|4,on|5,on|6,off|7,off| admin 333 financialLayout/_layout/columnsShown 0,on|1,on|2,on| admin 276 accountNumbers/_account/columnsShown 0,on|1,on|2,on|3,on|4,on|5,on|6,on|7,on| admin 363 calendars/_calhead/columnsShown 0,on|1,on| admin 364 propername OpenMFG Administrator mfgadmin 365 initials ADMIN mfgadmin 366 email matherton@openmfg.com mfgadmin 367 locale_id 3 mfgadmin 369 active t mfgadmin 370 window mfgadmin 379 user/_availableSite/columnsShown 0,on| admin 380 user/_grantedSite/columnsShown 0,on| admin 381 user/_availableGroup/columnsShown 0,on| admin 382 user/_grantedGroup/columnsShown 0,on| admin 383 group/_available/columnsShown 0,on| admin 384 group/_granted/columnsShown 0,on| admin 385 groups/_list/columnsShown 0,on|1,on| admin 377 window admin 386 taxCode/_taxitems/columnsShown 0,on|1,on|2,on|3,on|4,on| admin 387 taxClasses/_taxclass/columnsShown 0,on|1,on|2,on| admin 388 taxAssignment/_taxCodeOption/columnsShown 0,on| admin 389 taxAssignment/_taxCodeSelected/columnsShown 0,on| admin 390 taxAssignments/_taxass/columnsShown 0,on|1,on|2,on|3,on| admin 391 accountNumbers/_showExternal/checked 0 admin 392 /_layout/columnsShown 0,on|1,on|2,on| admin 393 locales/_locale/columnsShown 0,on|1,on| admin 277 arAccountAssignments/_araccnt/columnsShown 0,on|1,on|2,on|3,on|4,on|5,on| admin 394 IngoreMissingTranslationFiles f admin 259 InterfaceWindowOption TopLevel admin 396 CopyListsPlainText f admin 397 EmailEvents f admin 398 AlarmEventDefault f admin 399 AlarmEmailDefault f admin 400 AlarmSysmsgDefault f admin 401 EnableScriptDebug f admin 402 unpostedPurchaseOrders/_queryonstart/checked 2 admin 403 unpostedPurchaseOrders/_showOpen/checked 0 admin 404 unpostedPurchaseOrders/_showUnreleased/checked 0 admin 405 unpostedPurchaseOrders/_autoupdate/checked 0 admin 406 accountNumbers/_showInactive/checked 0 admin 407 metasqls/_byPackage/checked 2 admin 408 reports/_byPackage/checked 0 admin 341 DisableExportContents f admin 342 UseEnhancedAuthentication f admin 378 selectedSites f admin 371 propername Administrator admin 373 email admin@example.com admin 372 initials ADMIN admin 374 locale_id 3 admin 375 agent t admin 376 active t admin 409 packages/_autoUpdate/checked 0 admin 410 vendors/_queryonstart/checked 2 admin 411 vendor/_verbose/checked 0 admin 413 crmaccount/_todolist/checked 0 admin 414 crmaccount/_opportunities/checked 0 admin 415 crmaccount/_incidents/checked 0 admin 416 crmaccount/_autoupdate/checked 0 admin 417 crmaccount/_verbose/checked 0 admin 418 crmaccount/_activeOnly/checked 0 admin 419 vendors/_autoupdate/checked 0 admin 420 customers/_queryonstart/checked 2 admin 421 customers/_autoupdate/checked 0 admin \. -- -- Name: usrpref_usrpref_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('usrpref_usrpref_id_seq', 421, true); -- -- Data for Name: usrpriv; Type: TABLE DATA; Schema: public; Owner: admin -- COPY usrpriv (usrpriv_id, usrpriv_priv_id, usrpriv_username) FROM stdin; 1 3 mfgadmin 3 5 mfgadmin 11 45 mfgadmin 12 44 mfgadmin 13 100 mfgadmin 14 48 mfgadmin 15 49 mfgadmin 16 53 mfgadmin 17 54 mfgadmin 18 63 mfgadmin 19 64 mfgadmin 20 65 mfgadmin 21 73 mfgadmin 26 4 mfgadmin 28 17 mfgadmin 29 16 mfgadmin 30 91 mfgadmin 31 27 mfgadmin 33 11 mfgadmin 34 93 mfgadmin 35 12 mfgadmin 36 13 mfgadmin 37 26 mfgadmin 38 75 mfgadmin 39 76 mfgadmin 40 94 mfgadmin 41 121 mfgadmin 42 122 mfgadmin 43 101 mfgadmin 45 87 mfgadmin 46 103 mfgadmin 47 104 mfgadmin 48 105 mfgadmin 50 107 mfgadmin 51 1 mfgadmin 52 2 mfgadmin 60 123 mfgadmin 63 120 mfgadmin 65 124 mfgadmin 66 125 mfgadmin 75 134 mfgadmin 78 137 mfgadmin 80 140 mfgadmin 81 22 mfgadmin 82 23 mfgadmin 83 51 mfgadmin 84 55 mfgadmin 85 56 mfgadmin 86 57 mfgadmin 87 58 mfgadmin 88 61 mfgadmin 89 62 mfgadmin 90 59 mfgadmin 91 60 mfgadmin 92 50 mfgadmin 93 88 mfgadmin 94 89 mfgadmin 96 126 mfgadmin 97 127 mfgadmin 98 141 mfgadmin 99 142 mfgadmin 100 143 mfgadmin 101 144 mfgadmin 118 160 mfgadmin 119 31 mfgadmin 123 161 mfgadmin 124 162 mfgadmin 125 163 mfgadmin 127 68 mfgadmin 129 166 mfgadmin 130 167 mfgadmin 131 168 mfgadmin 132 169 mfgadmin 133 170 mfgadmin 135 173 mfgadmin 138 176 mfgadmin 139 177 mfgadmin 140 178 mfgadmin 142 180 mfgadmin 143 181 mfgadmin 144 182 mfgadmin 147 189 mfgadmin 148 190 mfgadmin 149 191 mfgadmin 150 192 mfgadmin 151 193 mfgadmin 152 194 mfgadmin 153 195 mfgadmin 154 196 mfgadmin 155 197 mfgadmin 156 198 mfgadmin 157 199 mfgadmin 158 200 mfgadmin 159 201 mfgadmin 160 202 mfgadmin 161 232 mfgadmin 162 203 mfgadmin 164 205 mfgadmin 165 233 mfgadmin 166 207 mfgadmin 167 208 mfgadmin 168 209 mfgadmin 170 234 mfgadmin 171 235 mfgadmin 172 211 mfgadmin 173 212 mfgadmin 174 213 mfgadmin 177 236 mfgadmin 188 228 mfgadmin 189 231 mfgadmin 194 239 mfgadmin 195 242 mfgadmin 391 246 mfgadmin 392 244 mfgadmin 393 245 mfgadmin 397 248 mfgadmin 401 249 mfgadmin 402 250 mfgadmin 410 253 mfgadmin 748 258 mfgadmin 749 257 mfgadmin 750 204 mfgadmin 809 187 mfgadmin 810 188 mfgadmin 811 259 mfgadmin 825 262 mfgadmin 827 263 mfgadmin 828 261 mfgadmin 829 269 mfgadmin 839 214 mfgadmin 840 274 mfgadmin 841 47 mfgadmin 842 46 mfgadmin 843 256 mfgadmin 844 255 mfgadmin 846 276 mfgadmin 847 275 mfgadmin 848 277 mfgadmin 849 278 mfgadmin 850 280 mfgadmin 851 215 mfgadmin 852 217 mfgadmin 853 218 mfgadmin 854 219 mfgadmin 855 220 mfgadmin 856 223 mfgadmin 857 224 mfgadmin 858 225 mfgadmin 859 216 mfgadmin 860 222 mfgadmin 861 221 mfgadmin 862 226 mfgadmin 863 227 mfgadmin 872 10 mfgadmin 873 30 mfgadmin 874 29 mfgadmin 875 37 mfgadmin 876 42 mfgadmin 877 84 mfgadmin 878 82 mfgadmin 879 83 mfgadmin 880 85 mfgadmin 881 86 mfgadmin 882 90 mfgadmin 883 116 mfgadmin 884 117 mfgadmin 885 118 mfgadmin 887 14 mfgadmin 888 15 mfgadmin 889 128 mfgadmin 890 129 mfgadmin 891 131 mfgadmin 892 130 mfgadmin 893 132 mfgadmin 894 133 mfgadmin 895 147 mfgadmin 896 81 mfgadmin 897 148 mfgadmin 898 19 mfgadmin 900 150 mfgadmin 901 151 mfgadmin 902 152 mfgadmin 903 154 mfgadmin 904 153 mfgadmin 905 35 mfgadmin 906 36 mfgadmin 907 164 mfgadmin 908 241 mfgadmin 909 238 mfgadmin 910 264 mfgadmin 911 265 mfgadmin 912 179 mfgadmin 913 251 mfgadmin 914 252 mfgadmin 915 254 mfgadmin 916 266 mfgadmin 917 267 mfgadmin 918 268 mfgadmin 919 271 mfgadmin 920 272 mfgadmin 1193 281 mfgadmin 1195 106 mfgadmin 1219 111 mfgadmin 1220 260 mfgadmin 1523 294 mfgadmin 1537 297 mfgadmin 1538 298 mfgadmin 1552 279 mfgadmin 1553 302 mfgadmin 1554 303 mfgadmin 1555 305 mfgadmin 1556 70 mfgadmin 1557 273 mfgadmin 1563 306 mfgadmin 1564 307 mfgadmin 1779 316 mfgadmin 1780 317 mfgadmin 2039 369 mfgadmin 2040 370 mfgadmin 2041 371 mfgadmin 2042 334 mfgadmin 2043 356 mfgadmin 2044 357 mfgadmin 2045 358 mfgadmin 2046 372 mfgadmin 2047 335 mfgadmin 2048 373 mfgadmin 2049 382 mfgadmin 2050 313 mfgadmin 2051 314 mfgadmin 2052 315 mfgadmin 2053 374 mfgadmin 2054 375 mfgadmin 2055 376 mfgadmin 2056 377 mfgadmin 2057 378 mfgadmin 2058 379 mfgadmin 2059 380 mfgadmin 2060 350 mfgadmin 2061 351 mfgadmin 2063 270 mfgadmin 2064 362 mfgadmin 2065 363 mfgadmin 2066 349 mfgadmin 2067 353 mfgadmin 2068 354 mfgadmin 2069 368 mfgadmin 2070 383 mfgadmin 2071 347 mfgadmin 2072 348 mfgadmin 2073 336 mfgadmin 2074 337 mfgadmin 2075 346 mfgadmin 2076 355 mfgadmin 2078 385 mfgadmin 2079 386 mfgadmin 2080 345 mfgadmin 2081 359 mfgadmin 2086 388 mfgadmin 2087 352 mfgadmin 2088 389 mfgadmin 2089 390 mfgadmin 2090 391 mfgadmin 2091 392 mfgadmin 2092 393 mfgadmin 2093 394 mfgadmin 2094 407 mfgadmin 2097 416 mfgadmin 2100 446 mfgadmin 2101 420 mfgadmin 2103 422 mfgadmin 2104 423 mfgadmin 2105 424 mfgadmin 2106 425 mfgadmin 2107 426 mfgadmin 2108 427 mfgadmin 2110 429 mfgadmin 2112 431 mfgadmin 2113 447 mfgadmin 2114 433 mfgadmin 2116 435 mfgadmin 2117 436 mfgadmin 2118 437 mfgadmin 2120 439 mfgadmin 2121 440 mfgadmin 2122 441 mfgadmin 2123 442 mfgadmin 2125 444 mfgadmin 2126 419 mfgadmin 2127 432 mfgadmin 2128 448 mfgadmin 2129 449 mfgadmin 2130 450 mfgadmin 2131 451 mfgadmin 2132 395 mfgadmin 2133 396 mfgadmin 2134 397 mfgadmin 2135 398 mfgadmin 2139 399 mfgadmin 2140 403 mfgadmin 2141 404 mfgadmin 2143 406 mfgadmin 2144 445 mfgadmin 2148 408 mfgadmin 2149 409 mfgadmin 2151 452 mfgadmin 2152 453 mfgadmin 2153 454 mfgadmin 2154 455 mfgadmin 2155 456 mfgadmin 2156 457 mfgadmin 2157 458 mfgadmin 2158 461 mfgadmin 2159 462 mfgadmin 2160 463 mfgadmin 2161 464 mfgadmin 2162 465 mfgadmin 2163 466 mfgadmin 2164 467 mfgadmin 2165 468 mfgadmin 2166 469 mfgadmin 2167 470 mfgadmin 2168 459 mfgadmin 2169 460 mfgadmin 2170 487 mfgadmin 2171 488 mfgadmin 2172 489 mfgadmin 2173 475 mfgadmin 2174 476 mfgadmin 2175 492 mfgadmin 2176 483 mfgadmin 2177 484 mfgadmin 2178 480 mfgadmin 2179 481 mfgadmin 2180 482 mfgadmin 2181 485 mfgadmin 2182 486 mfgadmin 2183 471 mfgadmin 2184 490 mfgadmin 2185 491 mfgadmin 2549 523 admin 2550 485 admin 2551 486 admin 2552 100 admin 2553 63 admin 2554 64 admin 2555 65 admin 2556 73 admin 2557 121 admin 2558 122 admin 2559 101 admin 2560 87 admin 2561 123 admin 2562 124 admin 2563 68 admin 2564 166 admin 2565 167 admin 2566 168 admin 2567 169 admin 2568 170 admin 2569 236 admin 2570 248 admin 2571 253 admin 2572 3 admin 2573 345 admin 2574 359 admin 2575 388 admin 2576 394 admin 2577 399 admin 2578 403 admin 2579 404 admin 2580 406 admin 2581 445 admin 2582 453 admin 2583 471 admin 2584 490 admin 2585 491 admin 2586 493 admin 2587 496 admin 2588 497 admin 2589 498 admin 2590 499 admin 2591 500 admin 2592 494 admin 2593 502 admin 2594 504 admin 2595 517 admin 2596 518 admin 2597 519 admin 2598 520 admin 2599 521 admin 2600 522 admin 2601 524 admin 2626 22 admin 2627 23 admin 2628 51 admin 2629 55 admin 2630 56 admin 2631 57 admin 2632 58 admin 2633 61 admin 2634 59 admin 2635 60 admin 2636 50 admin 2637 88 admin 2638 89 admin 2639 111 admin 2640 126 admin 2641 127 admin 2642 141 admin 2643 142 admin 2644 180 admin 2645 181 admin 2646 190 admin 2647 192 admin 2648 193 admin 2649 194 admin 2650 195 admin 2651 196 admin 2652 197 admin 2653 198 admin 2654 199 admin 2655 200 admin 2656 201 admin 2657 232 admin 2658 203 admin 2659 233 admin 2660 70 admin 2661 234 admin 2662 235 admin 2663 211 admin 2664 212 admin 2665 239 admin 2666 242 admin 2667 257 admin 2668 258 admin 2669 273 admin 2670 274 admin 2671 281 admin 2672 336 admin 2673 337 admin 2674 346 admin 2675 347 admin 2676 348 admin 2677 355 admin 2678 385 admin 2679 386 admin 2680 389 admin 2681 393 admin 2682 459 admin 2683 460 admin 2684 510 admin 2696 575 admin 2697 576 admin 2698 577 admin 2699 578 admin 2700 579 admin 2701 580 admin 2702 581 admin 2703 582 admin 2704 583 admin 2705 584 admin 2706 585 admin 2707 586 admin 2708 587 admin 2709 588 admin 2710 589 admin 2711 590 admin 2712 591 admin 2713 592 admin 2714 593 admin 2715 594 admin 2716 595 admin 2717 596 admin 2718 597 admin 2719 598 admin 2720 635 admin 2721 638 admin 2722 637 admin 2723 636 admin 2724 179 admin 2725 251 admin 2726 252 admin 2727 254 admin 2728 260 admin 2729 261 admin 2730 262 admin 2731 263 admin 2732 266 admin 2733 267 admin 2734 268 admin 2735 271 admin 2736 272 admin 2737 275 admin 2738 276 admin 2739 277 admin 2740 278 admin 2741 279 admin 2742 280 admin 2743 294 admin 2744 297 admin 2745 298 admin 2746 302 admin 2747 303 admin 2748 305 admin 2749 369 admin 2750 370 admin 2751 313 admin 2752 314 admin 2753 315 admin 2754 371 admin 2755 372 admin 2756 334 admin 2757 335 admin 2758 373 admin 2759 374 admin 2760 375 admin 2761 376 admin 2762 377 admin 2763 378 admin 2764 356 admin 2765 357 admin 2766 358 admin 2767 379 admin 2768 380 admin 2769 512 admin 2770 382 admin 2771 395 admin 2772 396 admin 2773 397 admin 2774 398 admin 2775 407 admin 2776 455 admin 2777 456 admin 2778 457 admin 2779 458 admin 2780 461 admin 2781 462 admin 2782 463 admin 2783 464 admin 2784 467 admin 2785 468 admin 2786 469 admin 2787 475 admin 2788 476 admin 2789 487 admin 2790 488 admin 2791 489 admin 2792 187 admin 2793 188 admin 2794 259 admin 2795 492 admin 2796 505 admin 2797 62 admin 2798 191 admin 2799 202 admin 2800 513 admin 2801 514 admin 2802 515 admin 2803 465 admin 2804 466 admin 2805 599 admin 2806 600 admin 2807 601 admin 2808 602 admin 2809 629 admin 2810 630 admin 2811 631 admin 2812 516 admin 2813 632 admin 2814 633 admin 2815 634 admin 2816 446 admin 2817 420 admin 2818 422 admin 2819 426 admin 2820 429 admin 2821 447 admin 2822 433 admin 2823 435 admin 2824 436 admin 2825 441 admin 2826 444 admin 2827 448 admin 2828 449 admin 2829 450 admin 2830 451 admin 2831 480 admin 2832 481 admin 2833 482 admin 2834 511 admin 2835 614 admin 2836 431 admin 2837 416 admin 2838 626 admin 2839 425 admin 2840 423 admin 2841 419 admin 2842 483 admin 2843 424 admin 2844 392 admin 2845 440 admin 2846 437 admin 2847 432 admin 2848 484 admin 2849 439 admin 2850 391 admin 2851 427 admin 2852 618 admin 2853 620 admin 2854 622 admin 2855 624 admin 2856 628 admin 2857 442 admin 2858 617 admin 2859 619 admin 2860 621 admin 2861 623 admin 2862 625 admin 2863 627 admin 2864 639 admin 2865 640 admin 2866 615 admin 2867 616 admin 2868 605 admin 2869 606 admin 2870 607 admin 2871 608 admin 2872 641 admin 2873 642 admin 2874 609 admin 2875 610 admin 2876 611 admin 2877 612 admin 2878 613 admin 2880 649 admin \. -- -- Name: usrpriv_usrpriv_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('usrpriv_usrpriv_id_seq', 2880, true); -- -- Name: vend_vend_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('vend_vend_id_seq', 78, true); -- -- Name: vendaddr_vendaddr_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('vendaddr_vendaddr_id_seq', 33, true); -- -- Data for Name: vendaddrinfo; Type: TABLE DATA; Schema: public; Owner: admin -- COPY vendaddrinfo (vendaddr_id, vendaddr_vend_id, vendaddr_code, vendaddr_name, vendaddr_comments, vendaddr_cntct_id, vendaddr_addr_id, vendaddr_taxzone_id) FROM stdin; \. -- -- Data for Name: vendinfo; Type: TABLE DATA; Schema: public; Owner: admin -- COPY vendinfo (vend_id, vend_name, vend_lastpurchdate, vend_active, vend_po, vend_comments, vend_pocomments, vend_number, vend_1099, vend_exported, vend_fobsource, vend_fob, vend_terms_id, vend_shipvia, vend_vendtype_id, vend_qualified, vend_ediemail, vend_ediemailbody, vend_edisubject, vend_edifilename, vend_accntnum, vend_emailpodelivery, vend_restrictpurch, vend_edicc, vend_curr_id, vend_cntct1_id, vend_cntct2_id, vend_addr_id, vend_match, vend_ach_enabled, vend_ach_accnttype, vend_ach_use_vendinfo, vend_ach_indiv_number, vend_ach_indiv_name, vend_ediemailhtml, vend_ach_routingnumber, vend_ach_accntnumber, vend_taxzone_id, vend_accnt_id, vend_expcat_id, vend_tax_id) FROM stdin; 78 State Sales Tax Authority \N t f SALES TAX f \N W 43 USPS 19 f f f 1 \N \N \N f f \N t f \\x \\x \N \N -1 -1 \. -- -- Data for Name: vendtype; Type: TABLE DATA; Schema: public; Owner: admin -- COPY vendtype (vendtype_id, vendtype_code, vendtype_descrip) FROM stdin; 18 NORMAL Normal Vendor 19 TAX AUTHORITY Tax Authority 20 EMPLOYEE Employee \. -- -- Name: vendtype_vendtype_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('vendtype_vendtype_id_seq', 20, true); -- -- Data for Name: vodist; Type: TABLE DATA; Schema: public; Owner: admin -- COPY vodist (vodist_id, vodist_poitem_id, vodist_vohead_id, vodist_costelem_id, vodist_accnt_id, vodist_amount, vodist_qty, vodist_expcat_id, vodist_tax_id, vodist_discountable, vodist_notes) FROM stdin; \. -- -- Name: vodist_vodist_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('vodist_vodist_id_seq', 117, true); -- -- Data for Name: vohead; Type: TABLE DATA; Schema: public; Owner: admin -- COPY vohead (vohead_id, vohead_number, vohead_pohead_id, vohead_posted, vohead_duedate, vohead_invcnumber, vohead_amount, vohead_docdate, vohead_1099, vohead_distdate, vohead_reference, vohead_terms_id, vohead_vend_id, vohead_curr_id, vohead_adjtaxtype_id, vohead_freighttaxtype_id, vohead_gldistdate, vohead_misc, vohead_taxzone_id, vohead_taxtype_id, vohead_notes, vohead_recurring_vohead_id) FROM stdin; \. -- -- Name: vohead_vohead_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('vohead_vohead_id_seq', 174, true); -- -- Data for Name: voheadtax; Type: TABLE DATA; Schema: public; Owner: admin -- COPY voheadtax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; \. -- -- Data for Name: voitem; Type: TABLE DATA; Schema: public; Owner: admin -- COPY voitem (voitem_id, voitem_vohead_id, voitem_poitem_id, voitem_close, voitem_qty, voitem_freight, voitem_taxtype_id) FROM stdin; \. -- -- Name: voitem_voitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('voitem_voitem_id_seq', 110, true); -- -- Data for Name: voitemtax; Type: TABLE DATA; Schema: public; Owner: admin -- COPY voitemtax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; \. -- -- Name: warehous_warehous_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('warehous_warehous_id_seq', 35, true); -- -- Data for Name: whsezone; Type: TABLE DATA; Schema: public; Owner: admin -- COPY whsezone (whsezone_id, whsezone_warehous_id, whsezone_name, whsezone_descrip) FROM stdin; \. -- -- Name: whsezone_whsezone_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('whsezone_whsezone_id_seq', 6, true); -- -- Data for Name: whsinfo; Type: TABLE DATA; Schema: public; Owner: admin -- COPY whsinfo (warehous_id, warehous_code, warehous_descrip, warehous_fob, warehous_active, warehous_counttag_prefix, warehous_counttag_number, warehous_bol_prefix, warehous_bol_number, warehous_shipping, warehous_useslips, warehous_usezones, warehous_aislesize, warehous_aislealpha, warehous_racksize, warehous_rackalpha, warehous_binsize, warehous_binalpha, warehous_locationsize, warehous_locationalpha, warehous_enforcearbl, warehous_default_accnt_id, warehous_shipping_commission, warehous_cntct_id, warehous_addr_id, warehous_transit, warehous_shipform_id, warehous_shipvia_id, warehous_shipcomments, warehous_costcat_id, warehous_sitetype_id, warehous_taxzone_id, warehous_sequence) FROM stdin; 35 WH1 Main Warehouse t WH1 90000 WH1 10000 t t f 2 t 2 t 2 t 2 t t 83 0.0000 2 2 f \N \N \N \N 1 \N 0 \. -- -- Data for Name: wo; Type: TABLE DATA; Schema: public; Owner: admin -- COPY wo (wo_id, wo_number, wo_subnumber, wo_status, wo_itemsite_id, wo_startdate, wo_duedate, wo_ordtype, wo_ordid, wo_qtyord, wo_qtyrcv, wo_adhoc, wo_itemcfg_series, wo_imported, wo_wipvalue, wo_postedvalue, wo_prodnotes, wo_prj_id, wo_priority, wo_brdvalue, wo_bom_rev_id, wo_boo_rev_id, wo_cosmethod, wo_womatl_id, wo_username) FROM stdin; \. -- -- Name: wo_wo_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('wo_wo_id_seq', 445, true); -- -- Data for Name: womatl; Type: TABLE DATA; Schema: public; Owner: admin -- COPY womatl (womatl_id, womatl_wo_id, womatl_itemsite_id, womatl_qtyper, womatl_scrap, womatl_qtyreq, womatl_qtyiss, womatl_qtywipscrap, womatl_lastissue, womatl_lastreturn, womatl_cost, womatl_picklist, womatl_status, womatl_imported, womatl_createwo, womatl_issuemethod, womatl_wooper_id, womatl_bomitem_id, womatl_duedate, womatl_schedatwooper, womatl_uom_id, womatl_notes, womatl_ref, womatl_scrapvalue, womatl_qtyfxd, womatl_issuewo, womatl_price) FROM stdin; \. -- -- Name: womatl_womatl_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('womatl_womatl_id_seq', 1292, true); -- -- Data for Name: womatlpost; Type: TABLE DATA; Schema: public; Owner: admin -- COPY womatlpost (womatlpost_id, womatlpost_womatl_id, womatlpost_invhist_id) FROM stdin; \. -- -- Name: womatlpost_womatlpost_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('womatlpost_womatlpost_id_seq', 1, false); -- -- Data for Name: womatlvar; Type: TABLE DATA; Schema: public; Owner: admin -- COPY womatlvar (womatlvar_id, womatlvar_number, womatlvar_subnumber, womatlvar_posted, womatlvar_parent_itemsite_id, womatlvar_component_itemsite_id, womatlvar_qtyord, womatlvar_qtyrcv, womatlvar_qtyiss, womatlvar_qtyper, womatlvar_scrap, womatlvar_wipscrap, womatlvar_bomitem_id, womatlvar_ref, womatlvar_notes, womatlvar_qtyfxd) FROM stdin; \. -- -- Name: womatlvar_womatlvar_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('womatlvar_womatlvar_id_seq', 44, true); -- -- Name: xcalitem_xcalitem_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('xcalitem_xcalitem_id_seq', 145, true); -- -- Data for Name: xsltmap; Type: TABLE DATA; Schema: public; Owner: admin -- COPY xsltmap (xsltmap_id, xsltmap_name, xsltmap_doctype, xsltmap_system, xsltmap_import, xsltmap_export) FROM stdin; 1 Yahoo OrderList http://store.yahoo.com/doc/dtd/OrderList2.dtd yahoo_to_xtupleapi.xsl \. -- -- Name: xsltmap_xsltmap_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('xsltmap_xsltmap_id_seq', 1, true); -- -- Data for Name: yearperiod; Type: TABLE DATA; Schema: public; Owner: admin -- COPY yearperiod (yearperiod_id, yearperiod_start, yearperiod_end, yearperiod_closed) FROM stdin; 3 2008-01-01 2008-12-31 f 4 2009-01-01 2009-12-31 f 6 2010-01-01 2010-12-31 f 7 2011-01-01 2011-12-31 f 8 2012-01-01 2012-12-31 f 9 2013-01-01 2013-12-31 f 10 2014-01-01 2014-12-31 f 11 2015-01-01 2015-12-31 f \. -- -- Name: yearperiod_yearperiod_id_seq; Type: SEQUENCE SET; Schema: public; Owner: admin -- SELECT pg_catalog.setval('yearperiod_yearperiod_id_seq', 11, true); SET search_path = te, pg_catalog; -- -- Data for Name: pkgcmd; Type: TABLE DATA; Schema: te; Owner: admin -- COPY pkgcmd (cmd_id, cmd_module, cmd_title, cmd_descrip, cmd_privname, cmd_executable, cmd_name) FROM stdin; \. -- -- Data for Name: pkgcmdarg; Type: TABLE DATA; Schema: te; Owner: admin -- COPY pkgcmdarg (cmdarg_id, cmdarg_cmd_id, cmdarg_order, cmdarg_arg) FROM stdin; \. -- -- Data for Name: pkgimage; Type: TABLE DATA; Schema: te; Owner: admin -- COPY pkgimage (image_id, image_name, image_descrip, image_data) FROM stdin; \. -- -- Data for Name: pkgmetasql; Type: TABLE DATA; Schema: te; Owner: admin -- COPY pkgmetasql (metasql_id, metasql_group, metasql_name, metasql_notes, metasql_query, metasql_lastuser, metasql_lastupdate, metasql_grade) FROM stdin; 416 projects detailte -- Group: projects\n-- Name: detailte\n-- Notes: \nSELECT prj_id, prj_number, prj_name,\n CASE WHEN(prj_status='P') THEN \n WHEN(prj_status='O') THEN \n WHEN(prj_status='C') THEN \n ELSE \n END AS prj_status, \n prj_username, \n COALESCE(SUM(prjtask_hours_budget), 0.0) AS budget_hrs,\n COALESCE(SUM(prjtask_hours_actual), 0.0) AS actual_hrs,\n COALESCE(SUM(prjtask_hours_budget - prjtask_hours_actual), 0.0) AS balance_hrs, \n CASE WHEN COALESCE(SUM(prjtask_hours_budget - prjtask_hours_actual), 0.0) < 0 THEN \n 'error' END AS balance_hrs_qtforegroundrole, \n 'qty' AS budget_hrs_xtnumericrole, \n 'qty' AS actual_hrs_xtnumericrole, \n 'qty' AS balance_hrs_xtnumericrole \nFROM prj\nLEFT OUTER JOIN prjtask ON (prj_id=prjtask_prj_id)\n\nWHERE (prj_status <> 'C')\n\nGROUP BY prj_id, prj_number, prj_name, prj_status, prj_username \n ORDER BY prj_number; \N \N 0 362 customer deltecustrate Delete customer project defaults\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: customer\n-- Name: deltecustrate\n-- Notes: Delete customer project defaults\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM te.tecustrate\nWHERE (tecustrate_cust_id=);\n \N \N 0 363 customer instecustrate Insert customer rate record\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: customer\n-- Name: instecustrate\n-- Notes: Insert customer rate record\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nINSERT INTO te.tecustrate (\n tecustrate_cust_id,\n tecustrate_rate,\n tecustrate_curr_id )\nVALUES (\n ,\n ,\n )\nRETURNING *;\n \N \N 0 364 customer seltecustrate Select Default Customer Project Info\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: customer\n-- Name: seltecustrate\n-- Notes: Select Default Customer Project Info\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *\nFROM te.tecustrate\nWHERE (tecustrate_cust_id=);\n \N \N 0 365 customer updtecustrate Update customer rate record\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: customer\n-- Name: updtecustrate\n-- Notes: Update customer rate record\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.tecustrate SET\n tecustrate_cust_id=,\n tecustrate_rate=,\n tecustrate_curr_id=\nWHERE (tecustrate_id=)\nRETURNING *;\n \N \N 0 366 employee insteemp Insert employee time expense record\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: employee\n-- Name: insteemp\n-- Notes: Insert employee time expense record\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nINSERT INTO te.teemp (\n teemp_emp_id,\n teemp_contractor )\nVALUES (\n ,\n );\n \N \N 0 367 employee selteemp Select Default Employee Time Expense Info\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: employee\n-- Name: selteemp\n-- Notes: Select Default Employee Time Expense Info\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *\nFROM te.teemp\nWHERE (teemp_emp_id=);\n \N \N 0 368 employee updteemp Update employee time expense\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: employee\n-- Name: updteemp\n-- Notes: Update employee time expense\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.teemp SET\n teemp_contractor=\nWHERE (teemp_id=);\n \N \N 0 369 item delteexp Delete Item Expense Settings\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: item\n-- Name: delteexp\n-- Notes: Delete Item Expense Settings\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM te.teexp\nWHERE (teexp_id=);\n \N \N 0 370 item insteexp Insert item expense settings\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: item\n-- Name: insteexp\n-- Notes: Insert item expense settings\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nINSERT INTO te.teexp (\n teexp_id,\n teexp_expcat_id,\n teexp_accnt_id )\nVALUES (\n ,\n ,\n );\n \N \N 0 371 item selteexp Select Item Expense Settings\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: item\n-- Name: selteexp\n-- Notes: Select Item Expense Settings\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n teexp_expcat_id,\n teexp_accnt_id\nFROM te.teexp\nWHERE (teexp_id=);\n \N \N 0 372 item updteexp Update item expense settings\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: item\n-- Name: updteexp\n-- Notes: Update item expense settings\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.teexp SET\n teexp_expcat_id=,\n teexp_accnt_id=\nWHERE (teexp_id=);\n \N \N 0 373 project formatdates Formats Dates for jsGantt\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: project\n-- Name: formatdates\n-- Notes: Formats Dates for jsGantt\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n EXTRACT('day' FROM start_date) || '/' || \n EXTRACT('month' FROM start_date) || '/' || \n EXTRACT('year' FROM start_date) AS start_date,\n EXTRACT('day' FROM due_date) || '/' || \n EXTRACT('month' FROM due_date) || '/' || \n EXTRACT('year' FROM due_date) AS due_date\nFROM (\n SELECT COALESCE(,)::date AS start_date,\n ::date AS due_date\n) data\n \N \N 0 374 project insteprj Insert project time expense record\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: project\n-- Name: insteprj\n-- Notes: Insert project time expense record\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nINSERT INTO te.teprj (\n teprj_prj_id,\n teprj_cust_id,\n teprj_rate,\n teprj_curr_id )\nVALUES (\n ,\n ,\n ,\n );\n \N \N 0 375 project selteprj Select Default Project Time Expense Info\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: project\n-- Name: selteprj\n-- Notes: Select Default Project Time Expense Info\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT COALESCE(teprj_cust_id,-1) AS cust_id,\n COALESCE(teprj_curr_id,-1) AS curr_id,\n *\nFROM te.teprj\nWHERE (teprj_prj_id=);\n \N \N 0 376 project updteprj Update project time expense\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: project\n-- Name: updteprj\n-- Notes: Update project time expense\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.teprj SET\n teprj_cust_id=,\n teprj_rate=,\n teprj_curr_id=\nWHERE (teprj_id=);\n \N \N 0 377 projectGantt getprj Fetch Project Info\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: projectGantt\n-- Name: getprj\n-- Notes: Fetch Project Info\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT prj_id\nFROM prj\nWHERE (prj_number=);\n \N \N 0 378 projectGantt jsgantt Loads jsGantt script file\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: projectGantt\n-- Name: jsgantt\n-- Notes: Loads jsGantt script file\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT script_source FROM script WHERE script_name = 'jsGantt';\n \N \N 0 379 projectGantt jsganttcss Loads jsGantt CSS file\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: projectGantt\n-- Name: jsganttcss\n-- Notes: Loads jsGantt CSS file\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT script_source FROM script WHERE script_name = 'jsGanttCSS';\n \N \N 0 380 projectGantt tasks Load project tasks for jsGantt\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: projectGantt\n-- Name: tasks\n-- Notes: Load project tasks for jsGantt\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n prjtask_id, \n prjtask_name, \n EXTRACT('day' FROM prjtask_start_date) || '/' || \n EXTRACT('month' FROM prjtask_start_date) || '/' || \n EXTRACT('year' FROM prjtask_start_date) AS start_date,\n EXTRACT('day' FROM prjtask_due_date) || '/' || \n EXTRACT('month' FROM prjtask_due_date) || '/' || \n EXTRACT('year' FROM prjtask_due_date) AS due_date \nFROM (\n SELECT \n prjtask_id,\n prjtask_name,\n COALESCE(prjtask_start_date,prjtask_due_date) AS prjtask_start_date,\n prjtask_due_date\n FROM prjtask\n\n\n WHERE (prjtask_prj_id = )\n) data;\n \N \N 0 381 task insteprjtask Insert task time expense record\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: task\n-- Name: insteprjtask\n-- Notes: Insert task time expense record\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nINSERT INTO te.teprjtask (\n teprjtask_prjtask_id,\n teprjtask_cust_id,\n teprjtask_rate,\n teprjtask_curr_id,\n teprjtask_item_id )\nVALUES (\n ,\n ,\n ,\n ,\n );\n \N \N 0 382 task selteprjtask Select Default Task Time Expense Info\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: task\n-- Name: selteprjtask\n-- Notes: Select Default Task Time Expense Info\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n COALESCE(teprjtask_cust_id,-1) AS cust_id,\n COALESCE(teprjtask_curr_id,-1) AS curr_id,\n COALESCE(teprjtask_item_id,-1) AS item_id,\n *\nFROM te.teprjtask\nWHERE (teprjtask_prjtask_id=);\n \N \N 0 383 task updteprjtask Update task time expense\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: task\n-- Name: updteprjtask\n-- Notes: Update task time expense\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.teprjtask SET\n teprjtask_cust_id=,\n teprjtask_rate=,\n teprjtask_curr_id=,\n teprjtask_item_id=\nWHERE (teprjtask_id=);\n \N \N 0 384 timeexpensehistory detail \n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensehistory\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n teitem_id AS id, tehead_emp_id AS altid,\n teitem.*,\n item_number, item_descrip1,\n cust_number, cust_name,\n tehead.*, tehead_number || '-' || teitem_linenumber::text AS f_sheet_number,\n emp_code,\n prj_number, prj_name,\n prjtask_number, prjtask_name,\n CASE WHEN (tehead_status='O') THEN \n \n WHEN (tehead_status='A') THEN\n \n ELSE \n END AS tehead_status_qtdisplayrole,\n CASE WHEN (teitem_type='T') THEN\n \n WHEN (teitem_type='E') THEN\n \n ELSE\n \n END AS teitem_type_qtdisplayrole,\n\n '0' AS teitem_qty_xttotalrole,\n\n\n '0' AS teitem_total_xttotalrole,\n\n\n formatQty(teitem_qty) AS f_qty,\n formatSalesPrice(teitem_rate) AS f_rate,\n formatBoolYN(teitem_billable) AS f_billable,\n formatExtPrice(teitem_total) AS f_total,\n formatDate(teitem_workdate) AS f_workdate,\n\n 'qty' AS teitem_qty_xtnumericrole,\n 'salesprice' AS teitem_rate_xtnumericrole,\n 'extprice' AS teitem_total_xtnumericrole\nFROM te.tehead\n JOIN te.teitem ON (tehead_id = teitem_tehead_id)\n JOIN emp ON (tehead_emp_id= emp_id)\n JOIN item ON (teitem_item_id = item_id)\n JOIN classcode ON (item_classcode_id=classcode_id)\n LEFT OUTER JOIN custinfo ON (teitem_cust_id=cust_id)\n\n JOIN custtype ON (cust_custtype_id=custtype_id)\n\n JOIN prjtask ON (teitem_prjtask_id=prjtask_id)\n JOIN prj ON (prjtask_prj_id=prj_id)\n\n JOIN custgrpitem ON (custgrpitem_cust_id=cust_id)\n\n\n JOIN empgrpitem ON (empgrpitem_emp_id=emp_id)\n\n\n JOIN itemgrpitem ON (itemgrpitem_item_id=item_id)\n\nWHERE (true\n\n AND (teitem_workdate >= )\n\n\n AND (teitem_workdate <= )\n\n\n AND (teitem_type = 'T')\n\n\n AND (teitem_type = 'E')\n\n\n AND (prj_id = )\n\n\n AND (cust_id = )\n\n\n AND (cust_custtype_id = )\n\n\n AND (custtype_code ~* )\n\n\n AND (custgrpitem_custgrp_id=)\n\n\n AND (emp_id = )\n\n\n AND (empgrpitem_empgrp_id=)\n\n\n AND (item_id = )\n\n\n AND (itemgrpitem_itemgrp_id=)\n\n\n AND (classcode_id = )\n\n\n AND (classcode_code ~* )\n\n) \nORDER BY tehead_number, teitem_linenumber;\n \N \N 0 385 timeexpensesheet deltehead Delete Time Expense Sheet\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheet\n-- Name: deltehead\n-- Notes: Delete Time Expense Sheet\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM docass WHERE (docass_source_id= AND docass_source_type='TE');\nDELETE FROM te.tehead WHERE (tehead_id=);\n \N \N 0 386 timeexpensesheet delteitem \n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheet\n-- Name: delteitem\n-- Notes: \n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM te.teitem\nWHERE teitem_id=\n \N \N 0 387 timeexpensesheet detail \n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheet\n-- Name: detail\n-- Notes:\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n teitem.*,\n CASE WHEN (teitem_type = 'T') THEN\n teitem_qty\n END AS hours,\n CASE WHEN (teitem_type = 'E') THEN\n teitem_total\n END AS expense,\n item_number, item_descrip1,\n cust_number, cust_name,\n tehead.*, emp_code,\n prj_number, prj_name,\n prjtask_number, prjtask_name,\n CASE WHEN teitem_type='E' THEN 0\n ELSE COALESCE(teitem_empcost, te.calcRate(emp_wage, emp_wage_period))\n END AS teitem_hrlycost,\n CASE WHEN teitem_type='E' THEN 0\n ELSE COALESCE(teitem_empcost, te.calcRate(emp_wage, emp_wage_period))\n * teitem_qty END AS teitem_totalcost,\n CASE WHEN (teitem_type='T') THEN\n \n WHEN (teitem_type='E') THEN\n \n ELSE\n \n END AS teitem_type_qtdisplayrole,\n 'qty' AS teitem_qty_xtnumericrole,\n 'qty' AS hours_xtnumericrole,\n 'qty' AS teitem_qty_xtnumericrole,\n 'qty' AS hours_xtnumericrole,\n 'extprice' AS expense_xtnumericrole,\n '--' AS hours_xtnullrole,\n '--' AS expense_xtnullrole,\n 'salesprice' AS teitem_rate_xtnumericrole,\n 'extprice' AS teitem_total_xtnumericrole,\n 0 AS hours_xttotalrole,\n 0 AS expense_xttotalrole,\n firstLine(teitem_notes) AS f_notes\nFROM te.tehead\n JOIN te.teitem ON (tehead_id = teitem_tehead_id)\n JOIN emp ON (tehead_emp_id= emp_id)\n JOIN item ON (teitem_item_id = item_id)\n LEFT OUTER JOIN custinfo ON (teitem_cust_id=cust_id)\n JOIN prjtask ON (teitem_prjtask_id=prjtask_id)\n JOIN prj ON (prjtask_prj_id=prj_id)\nWHERE (tehead_id = )\nORDER BY teitem_linenumber;\n \N \N 0 388 timeexpensesheet header \n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheet\n-- Name: header\n-- Notes: \n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n tehead.*, emp_code\nFROM te.tehead\n JOIN emp ON (tehead_emp_id= emp_id)\nWHERE (tehead_id = );\n \N \N 0 389 timeexpensesheet instehead \n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheet\n-- Name: instehead\n-- Notes: \n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nINSERT INTO te.tehead(\n tehead_emp_id,\n tehead_warehous_id,\n tehead_weekending,\n tehead_notes) \nVALUES (\n ,\n ,\n ,\n )\nRETURNING *;\n \N \N 0 390 timeexpensesheet updtehead \n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheet\n-- Name: updtehead\n-- Notes: \n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.tehead SET \n tehead_emp_id = ,\n tehead_warehous_id = ,\n tehead_notes = \nWHERE tehead_id=;\n \N \N 0 391 timeexpensesheetitem detail \n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheetitem\n-- Name: detail\n-- Notes: \n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT *,\n (SELECT (COUNT(teitem_id) = 0)\n FROM te.teitem maxte\n WHERE ((maxte.teitem_tehead_id=tehead_id)\n AND (maxte.teitem_linenumber > curr.teitem_linenumber))) AS ismax,\n COALESCE(curr.teitem_empcost, te.calcRate(emp_wage, emp_wage_period)) AS teitem_hrlycost\nFROM te.tehead\n JOIN te.teitem curr ON (tehead_id = curr.teitem_tehead_id) \n JOIN prjtask ON (prjtask_id=curr.teitem_prjtask_id)\n JOIN prj ON (prj_id=prjtask_prj_id)\t\t\n LEFT JOIN emp ON (tehead_emp_id = emp_id)\nWHERE (curr.teitem_id=);\n \N \N 0 392 timeexpensesheetitem emptotals Employee Hours Totals\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheetitem\n-- Name: emptotals\n-- Notes: Employee Hours Totals\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n formatqty(coalesce(sum(day_hours),0) + coalesce(,0)) as day_hours,\n formatqty(coalesce(sum(sheet_hours),0) + coalesce(,0)) as sheet_hours\nFROM (\n SELECT teitem_qty AS day_hours, 0 AS sheet_hours\n FROM te.teitem\n JOIN te.tehead ON (teitem_tehead_id=tehead_id)\n WHERE ((tehead_emp_id=)\n AND (teitem_id != )\n AND (teitem_workdate = )\n AND (teitem_type = 'T'))\n UNION ALL\n SELECT 0 AS day_hours, teitem_qty AS sheet_hours\n FROM te.teitem\n JOIN te.tehead ON (teitem_tehead_id=tehead_id)\n WHERE ((tehead_emp_id=)\n AND (teitem_id != )\n AND (tehead_id = )\n AND (teitem_type = 'T')) \n) AS data;\n \N \N 0 393 timeexpensesheetitem getcustinfo Get customer currency rate\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheetitem\n-- Name: getcustinfo\n-- Notes: Get customer currency rate\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT cust_curr_id \nFROM custinfo \nWHERE (cust_id=);\n \N \N 0 394 timeexpensesheetitem gettask Get Project task list\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheetitem\n-- Name: gettask\n-- Notes: Get Project task list\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n prjtask_id,\n (prjtask_number || ' - ' || prjtask_name) AS name \nFROM prjtask \nWHERE (prjtask_prj_id = )\n\n AND (prjtask_status IN ('O','P'))\n\nORDER by prjtask_number;\n \N \N 0 395 timeexpensesheetitem getterate Get billing rate for Time Expense Item\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheetitem\n-- Name: getterate\n-- Notes: Get billing rate for Time Expense Item\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT COALESCE(rate,0) AS rate \nFROM (\n\n-- Project Task Rate\nSELECT teprjtask_rate AS rate, \n teprjtask_curr_id AS curr_id,\n 10 AS seq \nFROM te.teprjtask\nWHERE ((teprjtask_prjtask_id = )\n AND (teprjtask_curr_id IS NOT NULL))\nUNION\n\n-- Project Rate\nSELECT teprj_rate AS rate, \n teprj_curr_id AS curr_id,\n 20 AS seq\nFROM te.teprj\nWHERE ((teprj_prj_id = )\n AND (teprj_curr_id IS NOT NULL))\nUNION\n\n-- Employee Rate\nSELECT emp_extrate AS rate, \n baseCurrId() AS curr_id,\n 30 AS seq\nFROM emp\nWHERE ((emp_id = )\n AND (emp_extrate > 0))\nUNION\n\n-- Customer Rate\nSELECT tecustrate_rate as rate, \n tecustrate_curr_id,\n 40 AS seq\nFROM te.tecustrate\nWHERE ((tecustrate_cust_id = )\n AND (tecustrate_curr_id IS NOT NULL))\nUNION\n\n\n-- Item List Price\nSELECT item_listprice as rate, \n baseCurrId(),\n 50 AS seq\nFROM item\nWHERE (item_id = )\n) AS rates\nORDER BY seq\nLIMIT 1;\n \N \N 0 396 timeexpensesheetitem instask Insert a default Project Task\n Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheetitem\n-- Name: instask\n-- Notes: Insert a default Project Task\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nINSERT INTO prjtask\n ( prjtask_id,\n prjtask_number,\n prjtask_name,\n prjtask_descrip,\n prjtask_prj_id,\n prjtask_anyuser,\n prjtask_status,\n prjtask_hours_budget,\n prjtask_hours_actual,\n prjtask_exp_budget,\n prjtask_exp_actual,\n prjtask_owner_username,\n prjtask_start_date,\n prjtask_due_date,\n prjtask_assigned_date,\n prjtask_completed_date,\n prjtask_username )\nSELECT\n nextval('prjtask_prjtask_id_seq'),\n ,\n ,\n ,\n ,\n null,\n 'O',\n 0,\n 0,\n 0,\n 0,\n current_user,\n ,\n null,\n ,\n null,\n current_user\nRETURNING prjtask_id;\n \N \N 0 397 timeexpensesheetitem insteitem \n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheetitem\n-- Name: insteitem\n-- Notes: \n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nINSERT INTO te.teitem (\n teitem_tehead_id,\n teitem_linenumber,\n teitem_type,\n teitem_workdate,\n teitem_cust_id,\n teitem_po,\n teitem_item_id,\n teitem_uom_id,\n teitem_qty,\n teitem_rate,\n teitem_total,\n teitem_prjtask_id,\n teitem_billable,\n teitem_prepaid, \n teitem_notes,\n teitem_curr_id, \n teitem_empcost )\nSELECT\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n item_price_uom_id,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n \nFROM item\nWHERE (item_id=)\nRETURNING *;\n \N \N 0 398 timeexpensesheetitem nextlinenum \n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheetitem\n-- Name: nextlinenum\n-- Notes: \n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT COALESCE(MAX(teitem_linenumber),0) +1 AS linenumber\nFROM te.teitem\nWHERE (teitem_tehead_id=);\n \N \N 0 399 timeexpensesheetitem taskbudg Task Budget\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheetitem\n-- Name: taskbudg\n-- Notes: Task Budget\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n formatqty(prjtask_hours_budget) as budget_hours,\n formatqty(prjtask_hours_actual) as actual_hours,\n formatmoney(prjtask_exp_budget) as budget_cost,\n formatmoney(prjtask_exp_actual) as actual_cost \nFROM prjtask \nWHERE (prjtask_id = )\n \N \N 0 400 timeexpensesheetitem taskdefaults Project Task default values\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheetitem\n-- Name: taskdefaults\n-- Notes: Project Task default values\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n COALESCE(teprj_cust_id,teprjtask_cust_id,-1) AS cust_id,\n COALESCE(teprjtask_item_id,-1) AS item_id\nFROM prjtask\n JOIN prj ON (prj_id=prjtask_prj_id)\n LEFT OUTER JOIN te.teprj ON (teprj_prj_id=prj_id)\n LEFT OUTER JOIN te.teprjtask ON (teprjtask_prjtask_id=prjtask_id)\nWHERE (prjtask_id=)\n \N \N 0 401 timeexpensesheetitem taskrollup Total hours and expenses including unapproved sheets\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheetitem\n-- Name: taskrollup\n-- Notes: Total hours and expenses including unapproved sheets\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n formatQty(SUM(total_hours)) AS total_hours,\n formatMoney(SUM(total_expense)) AS total_expense\nFROM\n (\n SELECT \n prjtask_hours_actual AS total_hours,\n prjtask_exp_actual AS total_expense\n FROM prjtask \n WHERE prjtask_id = \n UNION\n SELECT\n SUM(teitem_qty) as total_hours,\n 0 as total_expense\n FROM te.teitem \n JOIN te.tehead ON (tehead_id=teitem_tehead_id)\n WHERE teitem_prjtask_id = \n AND teitem_type = 'T' \n-- AND teitem_id != \n AND tehead_status = 'O'\n UNION\n SELECT \n 0 as total_hours,\n SUM(teitem_total) AS total_expense\n FROM te.teitem \n JOIN te.tehead ON (tehead_id=teitem_tehead_id)\n WHERE teitem_prjtask_id = \n AND teitem_type = 'E'\n-- AND teitem_id != \n AND tehead_status = 'O'\n) AS rollup;\n \N \N 0 402 timeexpensesheetitem teitemnext Find Next Item\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheetitem\n-- Name: teitemnext\n-- Notes: Find Next Item\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT a.teitem_id\nFROM te.teitem AS a, te.teitem AS b\nWHERE ((a.teitem_tehead_id = b.teitem_tehead_id)\n AND (a.teitem_linenumber > b.teitem_linenumber)\n AND (b.teitem_id=))\nORDER BY a.teitem_linenumber\nLIMIT 1;\n \N \N 0 403 timeexpensesheetitem teitemprev Find previous item\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheetitem\n-- Name: teitemprev\n-- Notes: Find previous item\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n\nSELECT a.teitem_id\nFROM te.teitem AS a, te.teitem AS b\nWHERE ( (a.teitem_tehead_id = b.teitem_tehead_id)\n AND (a.teitem_linenumber < b.teitem_linenumber)\n AND (b.teitem_id=) ) \nORDER BY a.teitem_linenumber DESC\nLIMIT 1;\n\nSELECT teitem_id\nFROM te.teitem\nWHERE (teitem_tehead_id=)\nORDER BY teitem_linenumber DESC\nLIMIT 1;\n\n \N \N 0 404 timeexpensesheetitem updteitem Update Time Expense Item\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheetitem\n-- Name: updteitem\n-- Notes: Update Time Expense Item\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.teitem SET \n teitem_tehead_id=,\n teitem_linenumber=,\n teitem_type=,\n teitem_workdate=,\n teitem_cust_id=,\n teitem_po=,\n teitem_item_id=,\n teitem_uom_id=item_price_uom_id,\n teitem_qty=,\n teitem_rate=,\n teitem_total=,\n teitem_prjtask_id=,\n teitem_billable=,\n teitem_prepaid=, \n teitem_notes=,\n teitem_curr_id=,\n teitem_empcost=\nFROM item\nWHERE ((teitem_id=)\n AND (=item_id))\nRETURNING *;\n \N \N 0 405 timeexpensesheets approve Approve Time Expense Sheet\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheets\n-- Name: approve\n-- Notes: Approve Time Expense Sheet\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.tehead SET \n tehead_status = 'A' \nWHERE (tehead_id=);\n \N \N 0 406 timeexpensesheets close Close Time Expense Sheet\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheets\n-- Name: close\n-- Notes: Close Time Expense Sheet\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.tehead SET \n tehead_status = 'C' \nWHERE (tehead_id=);\n \N \N 0 407 timeexpensesheets detail Time Expense Sheet List\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheets\n-- Name: detail\n-- Notes: Time Expense Sheet List\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n tehead_id,\n tehead_number,\n tehead_weekending,\n tehead_status,\n emp_code,\n invoiced,\n vouchered,\n posted,\n\n SUM(tovoucher) AS total_e,\n SUM(toinvoice) AS total_i,\n \n CASE WHEN (invoiced = 1) THEN \n WHEN (invoiced = 0) THEN \n ELSE \n END AS invoiced_qtdisplayrole,\n CASE WHEN (vouchered = 1) THEN \n WHEN (vouchered = 0) THEN \n ELSE \n END AS vouchered_qtdisplayrole,\n CASE WHEN (posted = 1) THEN \n WHEN (posted = 0) THEN \n ELSE \n END AS posted_qtdisplayrole,\n CASE WHEN (tehead_status='O') THEN\n \n WHEN (tehead_status='A') THEN\n \n ELSE \n END AS tehead_status_qtdisplayrole,\n 'curr' AS total_xtnumericrole,\n CASE WHEN (invoiced = -1) THEN 'LightGray'\n WHEN (invoiced = 0 AND tehead_status = 'A') THEN 'altemphasis'\n END AS invoiced_qtforegroundrole,\n CASE WHEN (vouchered = -1) THEN 'LightGray'\n WHEN (vouchered = 0 AND tehead_status = 'A') THEN 'altemphasis'\n END AS vouchered_qtforegroundrole,\n CASE WHEN (posted = -1) THEN 'LightGray'\n WHEN (posted = 0 AND tehead_status = 'A') THEN 'altemphasis'\n END AS posted_qtforegroundrole,\n CASE WHEN (tehead_status = 'O') THEN 'emphasis'\n WHEN (tehead_status = 'A') THEN 'altemphasis'\n END AS tehead_status_qtforegroundrole\n\n ,\n formatMoney(SUM(toinvoice)) AS f_total,\n formatDate(tehead_weekending) AS f_weekending\n\n\nFROM (\n SELECT\n tehead_id,\n tehead_number,\n tehead_weekending,\n tehead_status,\n emp_code, \n CASE WHEN (teitem_type='E' AND teitem_prepaid = FALSE) \n THEN teitem_total\n WHEN (teitem_type='T' AND teemp_contractor = TRUE) \n THEN COALESCE(teitem_empcost, te.calcRate(emp_wage, emp_wage_period))* teitem_qty\n ELSE 0 \n END as tovoucher,\n \n CASE WHEN (teitem_billable=TRUE) \n THEN teitem_total\n ELSE 0 \n END AS toinvoice,\n\n te.sheetstate(tehead_id, 'I') AS invoiced,\n te.sheetstate(tehead_id, 'V') AS vouchered,\n te.sheetstate(tehead_id, 'P') AS posted\n FROM te.tehead\n LEFT OUTER JOIN te.teitem ON (tehead_id=teitem_tehead_id)\n JOIN emp ON (tehead_emp_id=emp_id)\n LEFT OUTER JOIN te.teemp ON (tehead_emp_id=teemp_emp_id)\n WHERE (\n (tehead_weekending >= )\n AND (tehead_weekending <= )\n AND (tehead_status IN ())\n\n AND \n (tehead_emp_id=)\n\n\n AND \n (emp_mgr_emp_id=)\n\n)) AS data\nGROUP BY\n tehead_id,\n tehead_number,\n tehead_weekending,\n tehead_status,\n emp_code,\n invoiced,\n vouchered,\n posted\nORDER BY tehead_number;\n \N \N 0 408 timeexpensesheets invoice Invoice Time Expense Sheet\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheets\n-- Name: invoice\n-- Notes: Invoice Time Expense Sheet\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT te.invoiceSheets(ARRAY[\n \n \n ,\n \n \n \n],::DATE\n);\n \N \N 0 409 timeexpensesheets post Post Time Expense Sheet\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheets\n-- Name: post\n-- Notes: Post Time Expense Sheet\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT te.postSheet(, , );\n \N \N 0 493 timeexpensesheets reopen Reopen Time Expense Sheet\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheets\n-- Name: reopen\n-- Notes: Reopen Time Expense Sheet\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.tehead SET \n tehead_status = 'O' \nWHERE (tehead_id=);\n \N \N 0 410 timeexpensesheets unapprove Unapprove Time Expense Sheet\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheets\n-- Name: unapprove\n-- Notes: Unapprove Time Expense Sheet\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nUPDATE te.tehead SET \n tehead_status = 'O' \nWHERE (tehead_id=);\n \N \N 0 411 timeexpensesheets voucher Voucher Time Expense Sheet\n Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n See www.xtuple.com/CPAL for the full text of the software license.\n -- Group: timeexpensesheets\n-- Name: voucher\n-- Notes: Voucher Time Expense Sheet\n-- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT te.voucherSheet();\n \N \N 0 \. -- -- Data for Name: pkgpriv; Type: TABLE DATA; Schema: te; Owner: admin -- COPY pkgpriv (priv_id, priv_module, priv_name, priv_descrip, priv_seq) FROM stdin; 605 TE MaintainTimeExpenseOthers Allowed to Maintain Time/Exp Sheets for all users \N 606 TE MaintainTimeExpenseSelf Allowed to Maintain Time/Exp Sheets \N 607 TE MaintainTimeExpense Allowed to Maintain Time/Exp Sheets \N 608 TE CanViewRates Allowed to view rates in the Time Entries \N 641 TE MaintainEmpCostAll Allowed to maintain employee costs for all users \N 642 TE MaintainEmpCostSelf Allowed to maintain own employee costs \N 609 TE CanApprove Allowed to Approve Time/Exp Sheets \N 610 TE allowInvoicing Allowed to Invoice Time/Exp Sheets \N 611 TE allowVouchering Allowed to Voucher Time/Exp Sheets \N 612 TE PostTimeSheets Allowed to Post Time Sheets \N 613 TE ViewTimeExpenseHistory Allowed to view Time Expense Sheet history \N 649 TE ReopenTimeExpense Allowed to Reopen Time/Exp Sheets \N \. -- -- Data for Name: pkgreport; Type: TABLE DATA; Schema: te; Owner: admin -- COPY pkgreport (report_id, report_name, report_sys, report_source, report_descrip, report_grade, report_loaddate) FROM stdin; 439 TimeExpenseHistory \N \n\n Worksheet History\n TimeExpenseHistory\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n timeexpensehistory\n detail\n \n \n 95\n \n \n \n \n 3.33333\n 89.3333\n 743.333\n 89.3333\n 2\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 6\n \n \n 49\n \n \n \n 6.33333\n 41.3333\n 746.333\n 41.3333\n 2\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n

\n detail\n \n \n detail\n \n 40\n \n \n 394\n 19\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_number\n \n \n \n \n 480\n 19\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n item_descrip1\n \n \n \n \n 394\n 3.84333\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n prjtask_number\n \n \n \n \n 479\n 3.84333\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n prjtask_name\n \n \n \n \n 547\n 3.84333\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_qty\n \n \n \n \n 626\n 3.84333\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_billable\n \n \n \n \n 204\n 19\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_number\n \n \n \n \n 294\n 3.84333\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n prj_name\n \n \n \n \n 204\n 3.84333\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n prj_number\n \n \n \n \n 294\n 19\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n cust_name\n \n \n \n \n 10\n 3.84333\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n tehead_number\n \n \n \n \n 669.333\n 3.84333\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_total\n \n \n \n \n 25\n 19\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_workdate\n \n \n \n \n 111.667\n 4.33333\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n teitem_type_qtdisplayrole\n \n \n \n \n 111.667\n 19\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n emp_code\n \n \n \n \n 627\n 19\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n tehead_status_qtdisplayrole\n \n \n \n
\n \n 16\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n \n 35\n \n \n 549\n 4.33\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n teitem_qty\n \n money\n \n \n \n \n \n 668\n 4\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n teitem_total\n \n %0.2f\n \n \n \n\n 0 2015-10-01 17:21:38.526219 440 TimeExpenseSheet \N \n\n Worksheet\n TimeExpenseSheet\n \n \n \n SELECT tehead_id, tehead_number || '-' || tehead_username FROM tehead ORDER By tehead_number DESC;\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n header\n SELECT \n tehead_number,\n formatDate(tehead_weekending) AS f_weekending,\n warehous_code,\n emp_code || ' - ' || COALESCE(cntct_name,'') AS f_employee,\n CASE WHEN (tehead_status='O') THEN \n <? value("open") ?> \n WHEN (tehead_status='A') THEN\n <? value("approved") ?> \n ELSE <? value("closed") ?>\n END AS f_status,\n tehead_notes\nFROM te.tehead\n JOIN emp ON (tehead_emp_id=emp_id)\n JOIN whsinfo ON (warehous_id=tehead_warehous_id)\n LEFT OUTER JOIN cntct ON (emp_cntct_id=cntct_id)\nWHERE (tehead_id=<? value("tehead_id") ?>);\n\n \n \n time\n SELECT\n teitem_tehead_id,\n formatDate(teitem_workdate) AS f_workdate,\n prj_number,\n prj_name,\n prjtask_number,\n prjtask_name,\n cust_number,\n cust_name,\n item_number,\n item_descrip1,\n formatQty(teitem_qty) AS f_hours,\n teitem_qty,\n CASE WHEN (teitem_billable) THEN\n formatMoney(teitem_total)\n ELSE ' -- ' END AS f_billing_total,\n CASE WHEN (teitem_billable) THEN\n teitem_total\n ELSE 0 END AS billing_total,\n formatBoolYN(teitem_billable) AS f_billable,\n teitem_notes\nFROM te.teitem\n JOIN prjtask ON (teitem_prjtask_id=prjtask_id)\n JOIN prj ON (prjtask_prj_id=prj_id)\n JOIN item ON (item_id=teitem_item_id)\n LEFT OUTER JOIN custinfo ON (cust_id=teitem_cust_id)\nWHERE ((teitem_tehead_id=<? value("tehead_id") ?>)\n AND (teitem_type='T'))\nORDER BY teitem_tehead_id, teitem_workdate, teitem_linenumber;\n \n \n expense\n SELECT\n teitem_tehead_id,\n formatDate(teitem_workdate) AS f_workdate,\n prj_number,\n prj_name,\n prjtask_number,\n prjtask_name,\n cust_number,\n cust_name,\n item_number,\n item_descrip1,\n formatQty(teitem_qty) AS f_qty,\n teitem_qty,\n formatMoney(teitem_total) AS f_total,\n teitem_total,\n CASE WHEN (teitem_billable) THEN\n formatMoney(teitem_total)\n ELSE ' -- ' END AS f_billing_total,\n CASE WHEN (teitem_type = 'E') THEN\n teitem_total\n ELSE 0 END AS expense_total,\n CASE WHEN (teitem_billable) THEN\n teitem_total\n ELSE 0 END AS billing_total,\n formatBoolYN(teitem_billable) AS f_billable,\n teitem_notes\nFROM te.teitem\n JOIN prjtask ON (teitem_prjtask_id=prjtask_id)\n JOIN prj ON (prjtask_prj_id=prj_id)\n JOIN item ON (item_id=teitem_item_id)\n LEFT OUTER JOIN custinfo ON (cust_id=teitem_cust_id)\nWHERE ((teitem_tehead_id=<? value("tehead_id") ?>)\n AND (teitem_type='E'))\nORDER BY teitem_workdate, teitem_linenumber;\n \n \n prjsum\n SELECT\n teitem_tehead_id,\n prj_number,\n SUM(teitem_qty) AS total_hours,\n SUM(teitem_total) AS billing_total,\nCASE WHEN (\n (checkprivilege('MaintainEmpCostSelf')) \n AND \n (current_user = (SELECT tehead_username \n FROM te.tehead \n WHERE teitem_tehead_id = tehead_id)\n )\n )\n THEN SUM(teitem_empcost * teitem_qty)\n ELSE 0 END AS cost_total,\nCASE WHEN (\n (checkprivilege('MaintainEmpCostSelf')) \n AND \n (current_user = (SELECT tehead_username \n FROM te.tehead \n WHERE teitem_tehead_id = tehead_id)\n )\n )\n THEN 'Cost'\n ELSE 'No Priv' END AS title\n\nFROM te.teitem\n JOIN prjtask ON (teitem_prjtask_id=prjtask_id)\n JOIN prj ON (prjtask_prj_id=prj_id)\n JOIN item ON (item_id=teitem_item_id)\n LEFT OUTER JOIN custinfo ON (cust_id=teitem_cust_id)\nWHERE ((teitem_tehead_id=<? value("tehead_id") ?>)\n AND (teitem_type='T'))\nGROUP BY teitem_tehead_id, prj_number;\n \n \n prjexpsum\n SELECT\n teitem_tehead_id,\n prj_number,\n SUM(teitem_total) AS total\nFROM te.teitem\n JOIN prjtask ON (teitem_prjtask_id=prjtask_id)\n JOIN prj ON (prjtask_prj_id=prj_id)\n JOIN item ON (item_id=teitem_item_id)\n LEFT OUTER JOIN custinfo ON (cust_id=teitem_cust_id)\nWHERE ((teitem_tehead_id=<? value("tehead_id") ?>)\n AND (teitem_type='E'))\nGROUP BY teitem_tehead_id, prj_number;\n \n \n 110\n \n \n \n \n \n \n \n \n 135\n 35\n 175\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n header\n tehead_number\n \n \n \n \n 135\n 50\n 175\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n header\n f_weekending\n \n \n \n \n 135\n 65\n 175\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n header\n warehous_code\n \n \n \n \n 135\n 80\n 175\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n header\n f_employee\n \n \n \n \n 355\n 80\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n header\n f_status\n \n \n \n \n \n \n 6\n \n \n 14\n \n
\n time\n \n timefoot\n teitem_tehead_id\n \n 70\n \n \n \n \n \n \n \n \n \n \n \n \n \n 3.33333\n 61.333\n 743.333\n 61.333\n 2\n \n \n \n 15\n \n \n \n \n time\n \n 45\n \n \n 625\n 5\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n time\n f_billable\n \n \n \n \n 200\n 5\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n time\n prj_name\n \n \n \n \n 385\n 5\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n time\n prjtask_name\n \n \n \n \n 110\n 5\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n time\n prj_number\n \n \n \n \n 670\n 5\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n time\n f_billing_total\n \n \n \n \n 490\n 5\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n time\n f_hours\n \n \n \n \n 10\n 5\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n time\n f_workdate\n \n \n \n \n 300\n 5\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n time\n prjtask_number\n \n \n \n \n 110\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n time\n cust_number\n \n \n \n \n 200\n 15\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n time\n cust_name\n \n \n \n \n 300\n 15\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n time\n item_number\n \n \n \n \n 385\n 15\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n time\n item_descrip1\n \n \n \n \n 10\n 30\n 370\n 15\n \n 0\n \n Arial\n 8\n normal\n \n \n \n \n time\n teitem_notes\n \n \n \n
\n
\n projsum\n \n \n prj_sum\n teitem_tehead_id\n \n \n 50\n \n \n \n \n \n 3.33333\n 46.333\n 743.333\n 46.333\n 2\n \n \n \n 615\n 30\n 50\n 15\n \n \n Arial\n 8\n normal\n \n \n \n \n prjsum\n title\n \n \n \n \n 30\n \n \n 695\n 5\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n prjsum\n billing_total\n \n money\n \n \n \n \n 505\n 5\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n prjsum\n total_hours\n \n qty\n \n \n \n 360\n 5\n 745\n 5\n 2\n \n \n 420\n 5\n 520\n 5\n 0\n \n \n \n 615\n 5\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n prjsum\n cost_total\n \n money\n \n \n \n \n \n \n prjsum\n \n 25\n \n \n 695\n 5\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n prjsum\n billing_total\n \n money\n \n \n \n 615\n 5\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n prjsum\n cost_total\n \n money\n \n \n \n 380\n 5\n 115\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n prjsum\n prj_number\n \n \n \n \n 505\n 5\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n prjsum\n total_hours\n \n qty\n \n \n
\n
\n expense\n \n expdetail\n teitem_tehead_id\n \n 65\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 35\n \n \n 670\n 5\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n expense\n billing_total\n \n money\n \n \n \n \n \n 550\n 3.33\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n expense\n expense_total\n \n money\n \n \n \n \n \n \n expense\n \n 50\n \n \n 300\n 20\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n expense\n item_number\n \n \n \n \n 385\n 20\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n expense\n item_descrip1\n \n \n \n \n 300\n 5\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n expense\n prjtask_number\n \n \n \n \n 385\n 5\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n expense\n prjtask_name\n \n \n \n \n 490\n 5\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n expense\n f_qty\n \n \n \n \n 625\n 5\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n expense\n f_billable\n \n \n \n \n 670\n 5\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n expense\n f_billing_total\n \n \n \n \n 110\n 20\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n expense\n cust_number\n \n \n \n \n 200\n 5\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n expense\n prj_name\n \n \n \n \n 110\n 5\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n expense\n prj_number\n \n \n \n \n 200\n 20\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n expense\n cust_name\n \n \n \n \n 10\n 5\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n expense\n f_workdate\n \n \n \n \n 550\n 5\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n expense\n f_total\n \n \n \n 4.13052\n -5.20281\n 744.13\n -5.20281\n 2\n \n \n \n 110\n 35\n 600\n 15\n \n 0\n \n Arial\n 8\n normal\n \n \n \n \n expense\n teitem_notes\n \n \n \n
\n
\n prjexpsum\n \n prjexpsum\n teitem_tehead_id\n \n 60\n \n \n \n \n 4.13052\n 53.1454\n 744.13\n 53.1454\n 2\n \n \n \n 40\n \n \n 695\n 5\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n prjexpsum\n total\n \n money\n \n \n \n 655\n 5\n 745\n 5\n 2\n \n \n \n \n \n prjexpsum\n \n 25\n \n \n 370\n 5\n 115\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n prjexpsum\n prj_number\n \n \n \n \n 695\n 5\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n prjexpsum\n total\n \n money\n \n \n
\n \n 25\n \n \n 680\n 5\n 15\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n 90\n 5\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n \n \n 710\n 5\n 20\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_count\n \n \n \n \n 30\n \n \n 110\n 5\n 600\n 15\n \n 0\n \n Arial\n 8\n normal\n \n \n \n \n header\n tehead_notes\n \n \n \n \n
\n 0 2015-10-01 17:21:38.526219 441 TimeExpenseSheets \N \n\n Worksheets\n TimeExpenseSheets\n \n \n \n \n 0.05\n 0.05\n \n Letter\n \n 50\n 50\n 50\n 50\n \n detail\n timeexpensesheets\n detail\n \n \n 131\n \n \n \n \n 10\n 130\n 750\n 130\n 2\n \n \n \n \n \n \n \n \n \n \n 6\n \n \n 36\n \n \n \n 5\n 30\n 745\n 30\n 2\n \n \n \n \n \n \n \n \n
\n detail\n \n \n detail\n \n 22\n \n \n 625\n 1.84\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n vouchered_qtdisplayrole\n \n \n \n \n 225\n 1.84\n 105\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n emp_code\n \n \n \n \n 550\n 1.84\n 75\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n invoiced_qtdisplayrole\n \n \n \n \n 110.599\n 1.84\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_weekending\n \n \n \n \n 700\n 1.84\n 50\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n posted_qtdisplayrole\n \n \n \n \n 450\n 1.84\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n f_total\n \n \n \n \n 8.59883\n 1.84\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n tehead_number\n \n \n \n \n 350\n 1.84\n 90\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n detail\n tehead_status_qtdisplayrole\n \n \n \n
\n \n 16\n \n \n 90\n 0\n 100\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n report_date\n \n \n \n \n \n 705\n 0\n 40\n 15\n \n \n Arial\n 8\n bold\n \n \n \n \n Context Query\n page_number\n \n \n \n \n
\n 0 2015-10-01 17:21:38.526219 \. -- -- Data for Name: pkgscript; Type: TABLE DATA; Schema: te; Owner: admin -- COPY pkgscript (script_id, script_name, script_order, script_enabled, script_source, script_notes) FROM stdin; 109 dspTimeExpenseHistory 0 t /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("xtte");\nxtte.dspTimeExpenseHistory = new Object;\n\nvar _close = mywindow.findChild("_close");\nvar _print = mywindow.findChild("_print");\nvar _query = mywindow.findChild("_query");\nvar _list = mywindow.findChild("_list");\nvar _parameterWidget = mywindow.findChild("_parameterWidget");\n\n_list.addColumn(qsTr("Sheet #"), XTreeWidget.orderColumn, Qt.AlignLeft, true, "f_sheet_number");\n_list.addColumn(qsTr("Employee #"), XTreeWidget.orderColumn, Qt.AlignLeft, true, "emp_code");\n_list.addColumn(qsTr("Work Date"), XTreeWidget.dateColumn, Qt.AlignLeft, true, "teitem_workdate");\n_list.addColumn(qsTr("Type"), XTreeWidget.dateColumn, Qt.AlignLeft, true, "teitem_type");\n_list.addColumn(qsTr("Status"), XTreeWidget.dateColumn, Qt.AlignLeft, true, "tehead_status");\n_list.addColumn(qsTr("Project#"), XTreeWidget.orderColumn, Qt.AlignLeft, true, "prj_number");\n_list.addColumn(qsTr("Project Name"), -1, Qt.AlignLeft, false, "prj_name");\n_list.addColumn(qsTr("Task#"), XTreeWidget.orderColumn, Qt.AlignLeft, false, "prjtask_number");\n_list.addColumn(qsTr("Task Name"), -1, Qt.AlignLeft, false, "prjtask_name");\n_list.addColumn(qsTr("Cust.#"), XTreeWidget.orderColumn, Qt.AlignLeft, false, "cust_number");\n_list.addColumn(qsTr("Cust. Name"), -1, Qt.AlignLeft, false, "cust_name");\n_list.addColumn(qsTr("PO"), XTreeWidget.orderColumn, Qt.AlignLeft, false, "teitem_po");\n_list.addColumn(qsTr("Item"), XTreeWidget.itemColumn, Qt.AlignLeft, true, "item_number");\n_list.addColumn(qsTr("Description"), -1, Qt.AlignLeft, true, "item_descrip1");\n_list.addColumn(qsTr("Qty"), XTreeWidget.qtyColumn, Qt.AlignRight, true, "teitem_qty");\nif (privileges.check("CanViewRates"))\n{\n _list.addColumn(qsTr("Billable"), XTreeWidget.qtyColumn, Qt.AlignRight, false, "teitem_billable");\n _list.addColumn(qsTr("Ext."), XTreeWidget.moneyColumn, Qt.AlignRight, true, "teitem_total");\n}\n\nvar teSql = "SELECT 1,'" + qsTr("Time") + "','T' "\n + "UNION "\n + "SELECT 2,'" + qsTr("Expense") + "','E';";\n\nvar empGrpSql = "SELECT empgrp_id, empgrp_name, empgrp_name "\n + "FROM empgrp "\n + "ORDER BY empgrp_name;";\n\n_parameterWidget.append(qsTr("Start Date"), "startDate", ParameterWidget.Date, mainwindow.dbDate());\n_parameterWidget.append(qsTr("End Date"), "endDate", ParameterWidget.Date, mainwindow.dbDate());\n_parameterWidget.appendComboBox(qsTr("Type"), "typeEnum", teSql);\n_parameterWidget.append(qsTr("Employee"), "emp_id", ParameterWidget.Employee);\n_parameterWidget.appendComboBox(qsTr("Employee Group"), "empgrp_id", empGrpSql);\n_parameterWidget.append(qsTr("Project"), "prj_id", ParameterWidget.Project);\n_parameterWidget.append(qsTr("Customer"), "cust_id", ParameterWidget.Customer);\n_parameterWidget.appendComboBox(qsTr("Customer Type"), "custtype_id", XComboBox.CustomerTypes - 0);\n_parameterWidget.append(qsTr("Customer Type Pattern"), "custtype_pattern", ParameterWidget.Text);\n_parameterWidget.appendComboBox(qsTr("Customer Group"), "custgrp_id", XComboBox.CustomerGroups - 0);\n_parameterWidget.append(qsTr("Item"), "item_id", ParameterWidget.Item);\n_parameterWidget.appendComboBox(qsTr("Item Group"), "itemgrp_id", XComboBox.ItemGroups - 0);\n_parameterWidget.appendComboBox(qsTr("Class Code"), "classcode_id", XComboBox.ClassCodes - 0);\n_parameterWidget.append(qsTr("Class Code Pattern"), "classcode_pattern", ParameterWidget.Text);\n\n_parameterWidget.applyDefaultFilterSet();\n\nxtte.dspTimeExpenseHistory.populateMenu = function(pMenu, pItem, pCol)\n{\n if(pMenu == null)\n pMenu = _booitem.findChild("_menu");\n\n if(pMenu != null)\n {\n var editAct = pMenu.addAction(qsTr("Edit..."));\n editAct.triggered.connect(xtte.dspTimeExpenseHistory.editItem);\n editAct.enabled = (privileges.check("MaintainTimeExpense") &&\n pItem.rawValue("tehead_status") == 'O');\n\n var viewAct = pMenu.addAction(qsTr("View..."));\n viewAct.triggered.connect(xtte.dspTimeExpenseHistory.viewItem);\n }\n}\n\nxtte.dspTimeExpenseHistory.getParams = function()\n{\n var params = _parameterWidget.parameters();\n params.open = qsTr("Open");\n params.approved = qsTr("Approved");\n params.closed = qsTr("Closed");\n params.time = qsTr("Time");\n params.expense = qsTr("Expense");\n\n if("typeEnum" in params)\n {\n if (params.typeEnum == 1)\n params.timeOnly = true;\n else\n params.expenseOnly = true;\n }\n\n return params;\n}\n\nxtte.dspTimeExpenseHistory.print = function()\n{\n var params = xtte.dspTimeExpenseHistory.getParams();\n params.includeFormatted = true;\n\n toolbox.printReport("TimeExpenseHistory", params);\n}\n\nxtte.dspTimeExpenseHistory.fillList = function()\n{\n var qry = toolbox.executeDbQuery("timeexpensehistory", "detail", xtte.dspTimeExpenseHistory.getParams());\n _list.populate(qry, true)\n if(!qry.first())\n xtte.errorCheck(qry);\n}\n\nxtte.dspTimeExpenseHistory.editItem = function()\n{\n xtte.dspTimeExpenseHistory.openItem(xtte.editMode);\n}\n\n\nxtte.dspTimeExpenseHistory.viewItem = function()\n{\n xtte.dspTimeExpenseHistory.openItem(xtte.viewMode);\n}\n\n\nxtte.dspTimeExpenseHistory.openItem = function(mode)\n{ \n var params = new Object;\n params.mode = mode;\n params.teitem_id = _list.id();\n params.emp_id = _list.altId();\n\n var wnd = toolbox.openWindow("timeExpenseSheetItem", mywindow);\n toolbox.lastWindow().set(params);\n if (wnd.exec() > 0)\n xtte.timeExpenseSheet.fillList();\n}\n\n// Connections\n_print.clicked.connect(xtte.dspTimeExpenseHistory.print);\n_query.clicked.connect(xtte.dspTimeExpenseHistory.fillList);\n_list["populateMenu(QMenu *, XTreeWidgetItem *, int)"].connect(xtte.dspTimeExpenseHistory.populateMenu)\n_close.clicked.connect(mywindow, "close");\n\n 113 jsGantt 0 t /* \n _ ___ _ _ _ ____ \n (_)___ / _ \\__ _ _ __ | |_| |_ / | |___ \\ \n | / __| / /_\\/ _` | '_ \\| __| __| | | __) |\n | \\__ \\/ /_\\\\ (_| | | | | |_| |_ | |_ / __/ \n _/ |___/\\____/\\__,_|_| |_|\\__|\\__| |_(_)_____|\n|__/ \n\nCopyright (c) 2009, Shlomy Gantz BlueBrick Inc. All rights reserved.\n \n*\n* Redistribution and use in source and binary forms, with or without\n* modification, are permitted provided that the following conditions are met:\n* * Redistributions of source code must retain the above copyright\n* notice, this list of conditions and the following disclaimer.\n* * Redistributions in binary form must reproduce the above copyright\n* notice, this list of conditions and the following disclaimer in the\n* documentation and/or other materials provided with the distribution.\n* * Neither the name of Shlomy Gantz or BlueBrick Inc. nor the\n* names of its contributors may be used to endorse or promote products\n* derived from this software without specific prior written permission.\n*\n* THIS SOFTWARE IS PROVIDED BY SHLOMY GANTZ/BLUEBRICK INC. ''AS IS'' AND ANY\n* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n* DISCLAIMED. IN NO EVENT SHALL SHLOMY GANTZ/BLUEBRICK INC. BE LIABLE FOR ANY\n* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\nvar JSGantt; if (!JSGantt) JSGantt = {};\n\nvar vTimeout = 0;\nvar vBenchTime = new Date().getTime();\n\nJSGantt.isIE = function () {\n\t\n\tif(typeof document.all != 'undefined')\n\t\treturn true;\n\telse\n\t\treturn false;\n}\n\n\nJSGantt.TaskItem = function(pID, pName, pStart, pEnd, pColor, pLink, pMile, pRes, pComp, pGroup, pParent, pOpen, pDepend, pCaption)\n{\n\n var vID = pID;\n var vName = pName;\n var vStart = new Date();\t\n var vEnd = new Date();\n var vColor = pColor;\n var vLink = pLink;\n var vMile = pMile;\n var vRes = pRes;\n var vComp = pComp;\n var vGroup = pGroup;\n var vParent = pParent;\n var vOpen = pOpen;\n var vDepend = pDepend;\n var vCaption = pCaption;\n var vDuration = '';\n var vLevel = 0;\n var vNumKid = 0;\n var vVisible = 1;\n var x1, y1, x2, y2;\n\n if (vGroup != 1)\n { \n vStart = JSGantt.parseDateStr(pStart,g.getDateInputFormat());\n vEnd = JSGantt.parseDateStr(pEnd,g.getDateInputFormat());\n }\n\n this.getID = function(){ return vID };\n this.getName = function(){ return vName };\n this.getStart = function(){ return vStart};\n this.getEnd = function(){ return vEnd };\n this.getColor = function(){ return vColor};\n this.getLink = function(){ return vLink };\n this.getMile = function(){ return vMile };\n this.getDepend = function(){ if(vDepend) return vDepend; else return null };\n this.getCaption = function(){ if(vCaption) return vCaption; else return ''; };\n this.getResource = function(){ if(vRes) return vRes; else return ' '; };\n this.getCompVal = function(){ if(vComp) return vComp; else return 0; };\n this.getCompStr = function(){ if(vComp) return vComp+'%'; else return ''; };\n\n this.getDuration = function(vFormat){ \n if (vMile) \n vDuration = '-';\n else if (vFormat=='hour')\n {\n tmpPer = Math.ceil((this.getEnd() - this.getStart()) / ( 60 * 60 * 1000) );\n if(tmpPer == 1) \n vDuration = '1 Hour';\n else\n vDuration = tmpPer + ' Hours';\n }\n \n else if (vFormat=='minute')\n {\n tmpPer = Math.ceil((this.getEnd() - this.getStart()) / ( 60 * 1000) );\n if(tmpPer == 1) \n vDuration = '1 Minute';\n else\n vDuration = tmpPer + ' Minutes';\n }\n \n \t\t else { //if(vFormat == 'day') {\n tmpPer = Math.ceil((this.getEnd() - this.getStart()) / (24 * 60 * 60 * 1000) + 1);\n if(tmpPer == 1) vDuration = '1 Day';\n else vDuration = tmpPer + ' Days';\n }\n\n //else if(vFormat == 'week') {\n // tmpPer = ((this.getEnd() - this.getStart()) / (24 * 60 * 60 * 1000) + 1)/7;\n // if(tmpPer == 1) vDuration = '1 Week';\n // else vDuration = tmpPer + ' Weeks'; \n //}\n\n //else if(vFormat == 'month') {\n // tmpPer = ((this.getEnd() - this.getStart()) / (24 * 60 * 60 * 1000) + 1)/30;\n // if(tmpPer == 1) vDuration = '1 Month';\n // else vDuration = tmpPer + ' Months'; \n //}\n\n //else if(vFormat == 'quater') {\n // tmpPer = ((this.getEnd() - this.getStart()) / (24 * 60 * 60 * 1000) + 1)/120;\n // if(tmpPer == 1) vDuration = '1 Qtr';\n // else vDuration = tmpPer + ' Qtrs'; \n //}\n return( vDuration )\n };\n\n this.getParent = function(){ return vParent };\n this.getGroup = function(){ return vGroup };\n this.getOpen = function(){ return vOpen };\n this.getLevel = function(){ return vLevel };\n this.getNumKids = function(){ return vNumKid };\n this.getStartX = function(){ return x1 };\n this.getStartY = function(){ return y1 };\n this.getEndX = function(){ return x2 };\n this.getEndY = function(){ return y2 };\n this.getVisible = function(){ return vVisible };\n\t this.setDepend = function(pDepend){ vDepend = pDepend;};\n this.setStart = function(pStart){ vStart = pStart;};\n this.setEnd = function(pEnd) { vEnd = pEnd; };\n this.setLevel = function(pLevel){ vLevel = pLevel;};\n this.setNumKid = function(pNumKid){ vNumKid = pNumKid;};\n this.setCompVal = function(pCompVal){ vComp = pCompVal;};\n this.setStartX = function(pX) {x1 = pX; };\n this.setStartY = function(pY) {y1 = pY; };\n this.setEndX = function(pX) {x2 = pX; };\n this.setEndY = function(pY) {y2 = pY; };\n this.setOpen = function(pOpen) {vOpen = pOpen; };\n this.setVisible = function(pVisible) {vVisible = pVisible; };\n\n }\n\n\t\n // function that loads the main gantt chart properties and functions\n // pDiv: (required) this is a DIV object created in HTML\n // pStart: UNUSED - future use to force minimum chart date\n // pEnd: UNUSED - future use to force maximum chart date\n // pWidth: UNUSED - future use to force chart width and cause objects to scale to fit within that width\n // pShowRes: UNUSED - future use to turn on/off display of resource names\n // pShowDur: UNUSED - future use to turn on/off display of task durations\n // pFormat: (required) - used to indicate whether chart should be drawn in "day", "week", "month", or "quarter" format\n // pCationType - what type of Caption to show: Caption, Resource, Duration, Complete\nJSGantt.GanttChart = function(pGanttVar, pDiv, pFormat)\n{\n\n var vGanttVar = pGanttVar;\n var vDiv = pDiv;\n var vFormat = pFormat;\n var vShowRes = 1;\n var vShowDur = 1;\n var vShowComp = 1;\n var vShowStartDate = 1;\n var vShowEndDate = 1;\n var vDateInputFormat = "mm/dd/yyyy";\n var vDateDisplayFormat = "mm/dd/yy";\n\t var vNumUnits = 0;\n var vCaptionType;\n var vDepId = 1;\n var vTaskList = new Array();\t\n\t var vFormatArr\t= new Array("day","week","month","quarter");\n var vQuarterArr = new Array(1,1,1,2,2,2,3,3,3,4,4,4);\n var vMonthDaysArr = new Array(31,28,31,30,31,30,31,31,30,31,30,31);\n var vMonthArr = new Array("January","February","March","April","May","June","July","August","September","October","November","December");\n\t this.setFormatArr = function() \t {\n\t\t\t\t\t\t\t\t\t\t vFormatArr = new Array();\n\t\t\t\t\t\t\t\t\t\t for(var i = 0; i < arguments.length; i++) {vFormatArr[i] = arguments[i];}\n\t\t\t\t\t\t\t\t\t\t if(vFormatArr.length>4){vFormatArr.length=4;}\n\t\t\t\t\t\t\t\t\t\t };\n this.setShowRes = function(pShow) { vShowRes = pShow; };\n this.setShowDur = function(pShow) { vShowDur = pShow; };\n this.setShowComp = function(pShow) { vShowComp = pShow; };\n this.setShowStartDate = function(pShow) { vShowStartDate = pShow; };\n this.setShowEndDate = function(pShow) { vShowEndDate = pShow; };\n this.setDateInputFormat = function(pShow) { vDateInputFormat = pShow; };\n this.setDateDisplayFormat = function(pShow) { vDateDisplayFormat = pShow; };\n this.setCaptionType = function(pType) { vCaptionType = pType };\n this.setFormat = function(pFormat){ \n vFormat = pFormat; \n this.Draw(); \n };\n\n this.getShowRes = function(){ return vShowRes };\n this.getShowDur = function(){ return vShowDur };\n this.getShowComp = function(){ return vShowComp };\n\t this.getShowStartDate = function(){ return vShowStartDate };\n\t this.getShowEndDate = function(){ return vShowEndDate };\n this.getDateInputFormat = function() { return vDateInputFormat };\n this.getDateDisplayFormat = function() { return vDateDisplayFormat };\n this.getCaptionType = function() { return vCaptionType };\n this.CalcTaskXY = function () \n {\n var vList = this.getList();\n var vTaskDiv;\n var vParDiv;\n var vLeft, vTop, vHeight, vWidth;\n\n for(i = 0; i < vList.length; i++)\n {\n vID = vList[i].getID();\n vTaskDiv = document.getElementById("taskbar_"+vID);\n vBarDiv = document.getElementById("bardiv_"+vID);\n vParDiv = document.getElementById("childgrid_"+vID);\n\n if(vBarDiv) {\n vList[i].setStartX( vBarDiv.offsetLeft );\n vList[i].setStartY( vParDiv.offsetTop+vBarDiv.offsetTop+6 );\n vList[i].setEndX( vBarDiv.offsetLeft + vBarDiv.offsetWidth );\n vList[i].setEndY( vParDiv.offsetTop+vBarDiv.offsetTop+6 );\n }\n }\n }\n\n this.AddTaskItem = function(value)\n {\n vTaskList.push(value);\n }\n\n this.getList = function() { return vTaskList };\n\n this.clearDependencies = function()\n {\n var parent = document.getElementById('rightside');\n var depLine;\n var vMaxId = vDepId;\n for ( i=1; i 0)\n {\n \n\t\t // Process all tasks preset parent date and completion %\n JSGantt.processRows(vTaskList, 0, -1, 1, 1);\n\n // get overall min/max dates plus padding\n vMinDate = JSGantt.getMinDate(vTaskList, vFormat);\n vMaxDate = JSGantt.getMaxDate(vTaskList, vFormat);\n\n // Calculate chart width variables. vColWidth can be altered manually to change each column width\n // May be smart to make this a parameter of GanttChart or set it based on existing pWidth parameter\n if(vFormat == 'day') {\n vColWidth = 18;\n vColUnit = 1;\n }\n else if(vFormat == 'week') {\n vColWidth = 37;\n vColUnit = 7;\n }\n else if(vFormat == 'month') {\n vColWidth = 37;\n vColUnit = 30;\n }\n else if(vFormat == 'quarter') {\n vColWidth = 60;\n vColUnit = 90;\n }\n \n else if(vFormat=='hour')\n {\n vColWidth = 18;\n vColUnit = 1;\n }\n \n else if(vFormat=='minute')\n {\n vColWidth = 18;\n vColUnit = 1;\n }\n \n vNumDays = (Date.parse(vMaxDate) - Date.parse(vMinDate)) / ( 24 * 60 * 60 * 1000);\n vNumUnits = vNumDays / vColUnit;\n \n \n vChartWidth = vNumUnits * vColWidth + 1;\n vDayWidth = (vColWidth / vColUnit) + (1/vColUnit);\n\n vMainTable =\n '' +\n '';\n\n vMainTable += vLeftTable;\n\n // Draw the Chart Rows\n vRightTable = \n '
';\n\n if(vShowRes !=1) vNameWidth+=vStatusWidth;\n if(vShowDur !=1) vNameWidth+=vStatusWidth;\n if(vShowComp!=1) vNameWidth+=vStatusWidth;\n\t\t if(vShowStartDate!=1) vNameWidth+=vStatusWidth;\n\t\t if(vShowEndDate!=1) vNameWidth+=vStatusWidth;\n \n\t\t // DRAW the Left-side of the chart (names, resources, comp%)\n vLeftTable =\n '
' +\n '' +\n ' ' +\n ' '; \n\n if(vShowRes ==1) vLeftTable += ' ' ;\n if(vShowDur ==1) vLeftTable += ' ' ;\n if(vShowComp==1) vLeftTable += ' ' ;\n\t\t\tif(vShowStartDate==1) vLeftTable += ' ' ;\n\t\t\tif(vShowEndDate==1) vLeftTable += ' ' ;\n\n vLeftTable +=\n '' +\n ' ' +\n ' ' ;\n\n if(vShowRes ==1) vLeftTable += ' ' ;\n if(vShowDur ==1) vLeftTable += ' ' ;\n if(vShowComp==1) vLeftTable += ' ' ;\n if(vShowStartDate==1) vLeftTable += ' ' ;\n if(vShowEndDate==1) vLeftTable += ' ' ;\n \n vLeftTable += '';\n\n for(i = 0; i < vTaskList.length; i++)\n {\n if( vTaskList[i].getGroup()) {\n vBGColor = "f3f3f3";\n vRowType = "group";\n } else {\n vBGColor = "ffffff";\n vRowType = "row";\n }\n \n vID = vTaskList[i].getID();\n\n \t\t if(vTaskList[i].getVisible() == 0) \n vLeftTable += '' ;\n\t\t\t else\n vLeftTable += '' ;\n\n\t\t\t vLeftTable += \n ' ' +\n ' ' ;\n\n if(vShowRes ==1) vLeftTable += ' ' ;\n if(vShowDur ==1) vLeftTable += ' ' ;\n if(vShowComp==1) vLeftTable += ' ' ;\n if(vShowStartDate==1) vLeftTable += ' ' ;\n if(vShowEndDate==1) vLeftTable += ' ' ;\n\n vLeftTable += '';\n\n }\n\n // DRAW the date format selector at bottom left. Another potential GanttChart parameter to hide/show this selector\n vLeftTable += '' +\n '
ResourceDuration% Comp.Start DateEnd Date
 ';\n\n for(j=1; j ' ;\n else\n vLeftTable += '+ ' ;\n\t\t\t\t \n } else {\n\n vLeftTable += '   ';\n }\n\n vLeftTable += \n ' ' + vTaskList[i].getName() + '' + vTaskList[i].getResource() + '' + vTaskList[i].getDuration(vFormat) + '' + vTaskList[i].getCompStr() + '' + JSGantt.formatDateStr( vTaskList[i].getStart(), vDateDisplayFormat) + '' + JSGantt.formatDateStr( vTaskList[i].getEnd(), vDateDisplayFormat) + '
  Powered by jsGantt      Format:';\n\t\t\n\t\t\tif (vFormatArr.join().indexOf("minute")!=-1) { \n if (vFormat=='minute') vLeftTable += 'Minute';\n else vLeftTable += 'Minute';\n\t\t\t}\n\t\t\t\n\t\t\tif (vFormatArr.join().indexOf("hour")!=-1) { \n if (vFormat=='hour') vLeftTable += 'Hour';\n else vLeftTable += 'Hour';\n\t\t\t}\n\t\t\t\n\t\t\tif (vFormatArr.join().indexOf("day")!=-1) { \n if (vFormat=='day') vLeftTable += 'Day';\n else vLeftTable += 'Day';\n\t\t\t}\n\t\t\t\n\t\t\tif (vFormatArr.join().indexOf("week")!=-1) { \n if (vFormat=='week') vLeftTable += 'Week';\n else vLeftTable += 'Week';\n\t\t\t}\n\t\t\t\n\t\t\tif (vFormatArr.join().indexOf("month")!=-1) { \n if (vFormat=='month') vLeftTable += 'Month';\n else vLeftTable += 'Month';\n\t\t\t}\n\t\t\t\n\t\t\tif (vFormatArr.join().indexOf("quarter")!=-1) { \n if (vFormat=='quarter') vLeftTable += 'Quarter';\n else vLeftTable += 'Quarter';\n\t\t\t}\n\t\t\t\n// vLeftTable += ' .';\n\n vLeftTable += '
' +\n '
' +\n '' +\n '';\n\n vTmpDate.setFullYear(vMinDate.getFullYear(), vMinDate.getMonth(), vMinDate.getDate());\n vTmpDate.setHours(0);\n vTmpDate.setMinutes(0);\n\n // Major Date Header\n while(Date.parse(vTmpDate) <= Date.parse(vMaxDate))\n {\t\n vStr = vTmpDate.getFullYear() + '';\n vStr = vStr.substring(2,4);\n \n \n if(vFormat == 'minute')\n {\n vRightTable += '';\n vTmpDate.setHours(vTmpDate.getHours()+1);\n }\n \n if(vFormat == 'hour')\n {\n vRightTable += '';\n vTmpDate.setDate(vTmpDate.getDate()+1);\n }\n \n \t if(vFormat == 'day')\n {\n\t\t\t vRightTable += '';\n vTmpDate.setDate(vTmpDate.getDate()+1);\n }\n else if(vFormat == 'week')\n {\n \t\t vRightTable += '';\n vTmpDate.setDate(vTmpDate.getDate()+7);\n }\n else if(vFormat == 'month')\n {\n\t vRightTable += '';\n vTmpDate.setDate(vTmpDate.getDate() + 1);\n while(vTmpDate.getDate() > 1)\n {\n vTmpDate.setDate(vTmpDate.getDate() + 1);\n }\n }\n else if(vFormat == 'quarter')\n {\n\t vRightTable += '';\n vTmpDate.setDate(vTmpDate.getDate() + 81);\n while(vTmpDate.getDate() > 1)\n {\n vTmpDate.setDate(vTmpDate.getDate() + 1);\n }\n }\n\n }\n\n vRightTable += '';\n\n // Minor Date header and Cell Rows\n vTmpDate.setFullYear(vMinDate.getFullYear(), vMinDate.getMonth(), vMinDate.getDate());\n vNxtDate.setFullYear(vMinDate.getFullYear(), vMinDate.getMonth(), vMinDate.getDate());\n vNumCols = 0;\n \n while(Date.parse(vTmpDate) <= Date.parse(vMaxDate))\n {\t\n if (vFormat == 'minute')\n {\n\t\t\t\n\t\t\t if( vTmpDate.getMinutes() ==0 ) \n vWeekdayColor = "ccccff";\n else\n vWeekdayColor = "ffffff";\n\t\t\t\t \n\t\t\t\t \n vDateRowStr += '';\n vItemRowStr += '';\n vTmpDate.setMinutes(vTmpDate.getMinutes() + 1);\n }\n \n else if (vFormat == 'hour')\n {\n\t\t\t\n\t\t\t if( vTmpDate.getHours() ==0 ) \n vWeekdayColor = "ccccff";\n else\n vWeekdayColor = "ffffff";\n\t\t\t\t \n\t\t\t\t \n vDateRowStr += '';\n vItemRowStr += '';\n vTmpDate.setHours(vTmpDate.getHours() + 1);\n }\n\n\t else if(vFormat == 'day' )\n {\n if( JSGantt.formatDateStr(vCurrDate,'mm/dd/yyyy') == JSGantt.formatDateStr(vTmpDate,'mm/dd/yyyy')) {\n vWeekdayColor = "ccccff";\n vWeekendColor = "9999ff";\n vWeekdayGColor = "bbbbff";\n vWeekendGColor = "8888ff";\n } else {\n vWeekdayColor = "ffffff";\n vWeekendColor = "cfcfcf";\n vWeekdayGColor = "f3f3f3";\n vWeekendGColor = "c3c3c3";\n }\n \n if(vTmpDate.getDay() % 6 == 0) {\n vDateRowStr += '';\n vItemRowStr += '';\n }\n else {\n vDateRowStr += '';\n if( JSGantt.formatDateStr(vCurrDate,'mm/dd/yyyy') == JSGantt.formatDateStr(vTmpDate,'mm/dd/yyyy')) \n vItemRowStr += '';\n else\n vItemRowStr += '';\n }\n\n vTmpDate.setDate(vTmpDate.getDate() + 1);\n\n }\n\n\t else if(vFormat == 'week')\n {\n\n vNxtDate.setDate(vNxtDate.getDate() + 7);\n\n if( vCurrDate >= vTmpDate && vCurrDate < vNxtDate ) \n vWeekdayColor = "ccccff";\n else\n vWeekdayColor = "ffffff";\n\n if(vNxtDate <= vMaxDate) {\n vDateRowStr += '';\n if( vCurrDate >= vTmpDate && vCurrDate < vNxtDate ) \n vItemRowStr += '';\n else\n vItemRowStr += '';\n\n } else {\n vDateRowStr += '';\n if( vCurrDate >= vTmpDate && vCurrDate < vNxtDate ) \n vItemRowStr += '';\n else\n vItemRowStr += '';\n\n }\n\n vTmpDate.setDate(vTmpDate.getDate() + 7);\n\n }\n\n\t else if(vFormat == 'month')\n {\n\n vNxtDate.setFullYear(vTmpDate.getFullYear(), vTmpDate.getMonth(), vMonthDaysArr[vTmpDate.getMonth()]);\n if( vCurrDate >= vTmpDate && vCurrDate < vNxtDate ) \n vWeekdayColor = "ccccff";\n else\n vWeekdayColor = "ffffff";\n\n if(vNxtDate <= vMaxDate) {\n vDateRowStr += '';\n if( vCurrDate >= vTmpDate && vCurrDate < vNxtDate ) \n vItemRowStr += '';\n else\n vItemRowStr += '';\n } else {\n vDateRowStr += '';\n if( vCurrDate >= vTmpDate && vCurrDate < vNxtDate ) \n vItemRowStr += '';\n else\n vItemRowStr += '';\n }\n\n vTmpDate.setDate(vTmpDate.getDate() + 1);\n\n while(vTmpDate.getDate() > 1) \n {\n vTmpDate.setDate(vTmpDate.getDate() + 1);\n }\n\n }\n\n\t else if(vFormat == 'quarter')\n {\n\n vNxtDate.setDate(vNxtDate.getDate() + 122);\n if( vTmpDate.getMonth()==0 || vTmpDate.getMonth()==1 || vTmpDate.getMonth()==2 )\n vNxtDate.setFullYear(vTmpDate.getFullYear(), 2, 31);\n else if( vTmpDate.getMonth()==3 || vTmpDate.getMonth()==4 || vTmpDate.getMonth()==5 )\n vNxtDate.setFullYear(vTmpDate.getFullYear(), 5, 30);\n else if( vTmpDate.getMonth()==6 || vTmpDate.getMonth()==7 || vTmpDate.getMonth()==8 )\n vNxtDate.setFullYear(vTmpDate.getFullYear(), 8, 30);\n else if( vTmpDate.getMonth()==9 || vTmpDate.getMonth()==10 || vTmpDate.getMonth()==11 )\n vNxtDate.setFullYear(vTmpDate.getFullYear(), 11, 31);\n\n if( vCurrDate >= vTmpDate && vCurrDate < vNxtDate ) \n vWeekdayColor = "ccccff";\n else\n vWeekdayColor = "ffffff";\n\n if(vNxtDate <= vMaxDate) {\n vDateRowStr += '';\n if( vCurrDate >= vTmpDate && vCurrDate < vNxtDate ) \n vItemRowStr += '';\n else\n vItemRowStr += '';\n } else {\n vDateRowStr += '';\n if( vCurrDate >= vTmpDate && vCurrDate < vNxtDate ) \n vItemRowStr += '';\n else \n vItemRowStr += '';\n }\n\n vTmpDate.setDate(vTmpDate.getDate() + 81);\n\n while(vTmpDate.getDate() > 1) \n {\n vTmpDate.setDate(vTmpDate.getDate() + 1);\n }\n\n }\n }\n\n vRightTable += vDateRowStr + '';\n vRightTable += '
' ;\n vRightTable += JSGantt.formatDateStr(vTmpDate, vDateDisplayFormat) + ' ' + vTmpDate.getHours() + ':00 -' + vTmpDate.getHours() + ':59 ' ;\n vRightTable += JSGantt.formatDateStr(vTmpDate, vDateDisplayFormat) + '' +\n\t\t\t JSGantt.formatDateStr(vTmpDate,vDateDisplayFormat.substring(0,5)) + ' - ';\n vTmpDate.setDate(vTmpDate.getDate()+6);\n\t\t vRightTable += JSGantt.formatDateStr(vTmpDate, vDateDisplayFormat) + '`'+ vStr + '`'+ vStr + '`'+ vStr + '
' + vTmpDate.getMinutes() + '
  
' + vTmpDate.getHours() + '
  
' + vTmpDate.getDate() + '
 
' + vTmpDate.getDate() + '
  
  
' + (vTmpDate.getMonth()+1) + '/' + vTmpDate.getDate() + '
  
  
' + (vTmpDate.getMonth()+1) + '/' + vTmpDate.getDate() + '
  
  
' + vMonthArr[vTmpDate.getMonth()].substr(0,3) + '
  
  
' + vMonthArr[vTmpDate.getMonth()].substr(0,3) + '
  
  
Qtr. ' + vQuarterArr[vTmpDate.getMonth()] + '
  
  
Qtr. ' + vQuarterArr[vTmpDate.getMonth()] + '
  
  
';\n\n // Draw each row\n\n for(i = 0; i < vTaskList.length; i++)\n\n {\n\n vTmpDate.setFullYear(vMinDate.getFullYear(), vMinDate.getMonth(), vMinDate.getDate());\n vTaskStart = vTaskList[i].getStart();\n vTaskEnd = vTaskList[i].getEnd();\n\n vNumCols = 0;\n vID = vTaskList[i].getID();\n\n // vNumUnits = Math.ceil((vTaskList[i].getEnd() - vTaskList[i].getStart()) / (24 * 60 * 60 * 1000)) + 1;\n vNumUnits = (vTaskList[i].getEnd() - vTaskList[i].getStart()) / (24 * 60 * 60 * 1000) + 1;\n\t if (vFormat=='hour')\n\t {\n vNumUnits = (vTaskList[i].getEnd() - vTaskList[i].getStart()) / ( 60 * 1000) + 1;\n\t }\n\t else if (vFormat=='minute')\n\t {\n vNumUnits = (vTaskList[i].getEnd() - vTaskList[i].getStart()) / ( 60 * 1000) + 1;\n\t }\n\t \n\t if(vTaskList[i].getVisible() == 0) \n vRightTable += '';\n\n }\n\n vMainTable += vRightTable + '
';\n\n\t\t vDiv.innerHTML = vMainTable;\n\n }\n\n } //this.draw\n\n this.mouseOver = function( pObj, pID, pPos, pType ) {\n if( pPos == 'right' ) vID = 'child_' + pID;\n else vID = 'childrow_' + pID;\n \n pObj.bgColor = "#ffffaa";\n vRowObj = JSGantt.findObj(vID);\n if (vRowObj) vRowObj.bgColor = "#ffffaa";\n }\n\n this.mouseOut = function( pObj, pID, pPos, pType ) {\n if( pPos == 'right' ) vID = 'child_' + pID;\n else vID = 'childrow_' + pID;\n \n pObj.bgColor = "#ffffff";\n vRowObj = JSGantt.findObj(vID);\n if (vRowObj) {\n if( pType == "group") {\n pObj.bgColor = "#f3f3f3";\n vRowObj.bgColor = "#f3f3f3";\n } else {\n pObj.bgColor = "#ffffff";\n vRowObj.bgColor = "#ffffff";\n }\n }\n }\n\n} //GanttChart\t\t\n\n// Recursively process task tree ... set min, max dates of parent tasks and identfy task level.\nJSGantt.processRows = function(pList, pID, pRow, pLevel, pOpen)\n{\n\n var vMinDate = new Date();\n var vMaxDate = new Date();\n var vMinSet = 0;\n var vMaxSet = 0;\n var vList = pList;\n var vLevel = pLevel;\n var i = 0;\n var vNumKid = 0;\n var vCompSum = 0;\n var vVisible = pOpen;\n \n for(i = 0; i < pList.length; i++)\n {\n if(pList[i].getParent() == pID) {\n\t\t vVisible = pOpen;\n pList[i].setVisible(vVisible);\n if(vVisible==1 && pList[i].getOpen() == 0) \n vVisible = 0;\n \n pList[i].setLevel(vLevel);\n vNumKid++;\n\n if(pList[i].getGroup() == 1) {\n JSGantt.processRows(vList, pList[i].getID(), i, vLevel+1, vVisible);\n }\n\n if( vMinSet==0 || pList[i].getStart() < vMinDate) {\n vMinDate = pList[i].getStart();\n vMinSet = 1;\n }\n\n if( vMaxSet==0 || pList[i].getEnd() > vMaxDate) {\n vMaxDate = pList[i].getEnd();\n vMaxSet = 1;\n }\n\n vCompSum += pList[i].getCompVal();\n\n }\n }\n\n if(pRow >= 0) {\n pList[pRow].setStart(vMinDate);\n pList[pRow].setEnd(vMaxDate);\n pList[pRow].setNumKid(vNumKid);\n pList[pRow].setCompVal(Math.ceil(vCompSum/vNumKid));\n }\n\n}\n\n\n// Used to determine the minimum date of all tasks and set lower bound based on format\nJSGantt.getMinDate = function getMinDate(pList, pFormat) \n {\n\n var vDate = new Date();\n\n vDate.setFullYear(pList[0].getStart().getFullYear(), pList[0].getStart().getMonth(), pList[0].getStart().getDate());\n\n // Parse all Task End dates to find min\n for(i = 0; i < pList.length; i++)\n {\n if(Date.parse(pList[i].getStart()) < Date.parse(vDate))\n vDate.setFullYear(pList[i].getStart().getFullYear(), pList[i].getStart().getMonth(), pList[i].getStart().getDate());\n }\n\n if ( pFormat== 'minute')\n {\n vDate.setHours(0);\n vDate.setMinutes(0);\n }\n\t\t else if (pFormat == 'hour' )\n {\n vDate.setHours(0);\n vDate.setMinutes(0);\n }\n // Adjust min date to specific format boundaries (first of week or first of month)\n else if (pFormat=='day')\n {\n vDate.setDate(vDate.getDate() - 1);\n while(vDate.getDay() % 7 > 0)\n {\n vDate.setDate(vDate.getDate() - 1);\n }\n\n }\n\n else if (pFormat=='week')\n {\n vDate.setDate(vDate.getDate() - 7);\n while(vDate.getDay() % 7 > 0)\n {\n vDate.setDate(vDate.getDate() - 1);\n }\n\n }\n\n else if (pFormat=='month')\n {\n while(vDate.getDate() > 1)\n {\n vDate.setDate(vDate.getDate() - 1);\n }\n }\n\n else if (pFormat=='quarter')\n {\n if( vDate.getMonth()==0 || vDate.getMonth()==1 || vDate.getMonth()==2 )\n vDate.setFullYear(vDate.getFullYear(), 0, 1);\n else if( vDate.getMonth()==3 || vDate.getMonth()==4 || vDate.getMonth()==5 )\n vDate.setFullYear(vDate.getFullYear(), 3, 1);\n else if( vDate.getMonth()==6 || vDate.getMonth()==7 || vDate.getMonth()==8 )\n vDate.setFullYear(vDate.getFullYear(), 6, 1);\n else if( vDate.getMonth()==9 || vDate.getMonth()==10 || vDate.getMonth()==11 )\n vDate.setFullYear(vDate.getFullYear(), 9, 1);\n\n }\n\n return(vDate);\n\n }\n\n\n\n\n\n\n\n // Used to determine the minimum date of all tasks and set lower bound based on format\n\nJSGantt.getMaxDate = function (pList, pFormat)\n{\n var vDate = new Date();\n\n vDate.setFullYear(pList[0].getEnd().getFullYear(), pList[0].getEnd().getMonth(), pList[0].getEnd().getDate());\n \n \n // Parse all Task End dates to find max\n for(i = 0; i < pList.length; i++)\n {\n if(Date.parse(pList[i].getEnd()) > Date.parse(vDate))\n {\n //vDate.setFullYear(pList[0].getEnd().getFullYear(), pList[0].getEnd().getMonth(), pList[0].getEnd().getDate());\n vDate.setTime(Date.parse(pList[i].getEnd()));\n\t\t\t}\t\n\t }\n\t \n\t if (pFormat == 'minute')\n {\n vDate.setHours(vDate.getHours() + 1);\n vDate.setMinutes(59);\n }\t\n\t \n if (pFormat == 'hour')\n {\n vDate.setHours(vDate.getHours() + 2);\n }\t\t\t\t\n\t\t\t\t\n // Adjust max date to specific format boundaries (end of week or end of month)\n if (pFormat=='day')\n {\n vDate.setDate(vDate.getDate() + 1);\n\n while(vDate.getDay() % 6 > 0)\n {\n vDate.setDate(vDate.getDate() + 1);\n }\n\n }\n\n if (pFormat=='week')\n {\n //For weeks, what is the last logical boundary?\n vDate.setDate(vDate.getDate() + 11);\n\n while(vDate.getDay() % 6 > 0)\n {\n vDate.setDate(vDate.getDate() + 1);\n }\n\n }\n\n // Set to last day of current Month\n if (pFormat=='month')\n {\n while(vDate.getDay() > 1)\n {\n vDate.setDate(vDate.getDate() + 1);\n }\n\n vDate.setDate(vDate.getDate() - 1);\n }\n\n // Set to last day of current Quarter\n if (pFormat=='quarter')\n {\n if( vDate.getMonth()==0 || vDate.getMonth()==1 || vDate.getMonth()==2 )\n vDate.setFullYear(vDate.getFullYear(), 2, 31);\n else if( vDate.getMonth()==3 || vDate.getMonth()==4 || vDate.getMonth()==5 )\n vDate.setFullYear(vDate.getFullYear(), 5, 30);\n else if( vDate.getMonth()==6 || vDate.getMonth()==7 || vDate.getMonth()==8 )\n vDate.setFullYear(vDate.getFullYear(), 8, 30);\n else if( vDate.getMonth()==9 || vDate.getMonth()==10 || vDate.getMonth()==11 )\n vDate.setFullYear(vDate.getFullYear(), 11, 31);\n\n }\n\n return(vDate);\n\n }\n\n\n\n\n\n\n\n // This function finds the document id of the specified object\n\nJSGantt.findObj = function (theObj, theDoc)\n\n {\n\n var p, i, foundObj;\n\n if(!theDoc) theDoc = document;\n\n if( (p = theObj.indexOf("?")) > 0 && parent.frames.length){\n\n theDoc = parent.frames[theObj.substring(p+1)].document;\n\n theObj = theObj.substring(0,p);\n\n }\n\n if(!(foundObj = theDoc[theObj]) && theDoc.all) \n\n foundObj = theDoc.all[theObj];\n\n\n\n for (i=0; !foundObj && i < theDoc.forms.length; i++) \n\n foundObj = theDoc.forms[i][theObj];\n\n\n\n for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)\n\n foundObj = JSGantt.findObj(theObj,theDoc.layers[i].document);\n\n\n\n if(!foundObj && document.getElementById)\n\n foundObj = document.getElementById(theObj);\n\n\n\n return foundObj;\n\n }\n\n\n\n\n\nJSGantt.changeFormat = function(pFormat,ganttObj) {\n\n\n\n if(ganttObj) \n\n\t\t{\n\n\t\tganttObj.setFormat(pFormat);\n\n\t\tganttObj.DrawDependencies();\n\n\t\t}\n\n else\n\n alert('Chart undefined');\n\n\n\n }\n\n\n\n\n\n // Function to open/close and hide/show children of specified task\n\nJSGantt.folder= function (pID,ganttObj) {\n\n var vList = ganttObj.getList();\n\n for(i = 0; i < vList.length; i++)\n {\n if(vList[i].getID() == pID) {\n\n if( vList[i].getOpen() == 1 ) {\n vList[i].setOpen(0);\n JSGantt.hide(pID,ganttObj);\n\n if (JSGantt.isIE()) \n JSGantt.findObj('group_'+pID).innerText = '+';\n else\n JSGantt.findObj('group_'+pID).textContent = '+';\n\t\t\t\t\n } else {\n\n vList[i].setOpen(1);\n\n JSGantt.show(pID, 1, ganttObj);\n\n if (JSGantt.isIE()) \n JSGantt.findObj('group_'+pID).innerText = 'ñ';\n else\n JSGantt.findObj('group_'+pID).textContent = 'ñ';\n\n }\n\n }\n }\n}\n\nJSGantt.hide= function (pID,ganttObj) {\n var vList = ganttObj.getList();\n var vID = 0;\n\n for(var i = 0; i < vList.length; i++)\n {\n if(vList[i].getParent() == pID) {\n vID = vList[i].getID();\n JSGantt.findObj('child_' + vID).style.display = "none";\n JSGantt.findObj('childgrid_' + vID).style.display = "none";\n vList[i].setVisible(0);\n if(vList[i].getGroup() == 1) \n JSGantt.hide(vID,ganttObj);\n }\n\n }\n}\n\n// Function to show children of specified task\nJSGantt.show = function (pID, pTop, ganttObj) {\n var vList = ganttObj.getList();\n var vID = 0;\n\n for(var i = 0; i < vList.length; i++)\n {\n if(vList[i].getParent() == pID) {\n vID = vList[i].getID();\n if(pTop == 1) {\n if (JSGantt.isIE()) { // IE;\n\n if( JSGantt.findObj('group_'+pID).innerText == '+') {\n JSGantt.findObj('child_'+vID).style.display = "";\n JSGantt.findObj('childgrid_'+vID).style.display = "";\n vList[i].setVisible(1);\n }\n\n } else {\n \n if( JSGantt.findObj('group_'+pID).textContent == '+') {\n JSGantt.findObj('child_'+vID).style.display = "";\n JSGantt.findObj('childgrid_'+vID).style.display = "";\n vList[i].setVisible(1);\n }\n\n }\n\n } else {\n\n if (JSGantt.isIE()) { // IE;\n if( JSGantt.findObj('group_'+pID).innerText == 'ñ') {\n JSGantt.findObj('child_'+vID).style.display = "";\n JSGantt.findObj('childgrid_'+vID).style.display = "";\n vList[i].setVisible(1);\n }\n\n } else {\n\n if( JSGantt.findObj('group_'+pID).textContent == 'ñ') {\n JSGantt.findObj('child_'+vID).style.display = "";\n JSGantt.findObj('childgrid_'+vID).style.display = "";\n vList[i].setVisible(1);\n }\n }\n }\n\n if(vList[i].getGroup() == 1) \n JSGantt.show(vID, 0,ganttObj);\n\n }\n }\n}\n\n\n \n\n\n // function to open window to display task link\n\nJSGantt.taskLink = function(pRef,pWidth,pHeight) \n\n {\n\n if(pWidth) vWidth =pWidth; else vWidth =400;\n if(pHeight) vHeight=pHeight; else vHeight=400;\n\n var OpenWindow=window.open(pRef, "newwin", "height="+vHeight+",width="+vWidth); \n\n }\n\nJSGantt.parseDateStr = function(pDateStr,pFormatStr) {\n var vDate =new Date();\t\n vDate.setTime( Date.parse(pDateStr));\n\n switch(pFormatStr) \n {\n\t case 'mm/dd/yyyy':\n\t var vDateParts = pDateStr.split('/');\n vDate.setFullYear(parseInt(vDateParts[2], 10), parseInt(vDateParts[0], 10) - 1, parseInt(vDateParts[1], 10));\n break;\n\t case 'dd/mm/yyyy':\n\t var vDateParts = pDateStr.split('/');\n vDate.setFullYear(parseInt(vDateParts[2], 10), parseInt(vDateParts[1], 10) - 1, parseInt(vDateParts[0], 10));\n break;\n\t case 'yyyy-mm-dd':\n\t var vDateParts = pDateStr.split('-');\n vDate.setFullYear(parseInt(vDateParts[0], 10), parseInt(vDateParts[1], 10) - 1, parseInt(vDateParts[1], 10));\n break;\n }\n\n return(vDate);\n \n}\n\nJSGantt.formatDateStr = function(pDate,pFormatStr) {\n vYear4Str = pDate.getFullYear() + '';\n \t vYear2Str = vYear4Str.substring(2,4);\n vMonthStr = (pDate.getMonth()+1) + '';\n vDayStr = pDate.getDate() + '';\n\n var vDateStr = "";\t\n\n switch(pFormatStr) {\n\t case 'mm/dd/yyyy':\n return( vMonthStr + '/' + vDayStr + '/' + vYear4Str );\n\t case 'dd/mm/yyyy':\n return( vDayStr + '/' + vMonthStr + '/' + vYear4Str );\n\t case 'yyyy-mm-dd':\n return( vYear4Str + '-' + vMonthStr + '-' + vDayStr );\n\t case 'mm/dd/yy':\n return( vMonthStr + '/' + vDayStr + '/' + vYear2Str );\n\t case 'dd/mm/yy':\n return( vDayStr + '/' + vMonthStr + '/' + vYear2Str );\n\t case 'yy-mm-dd':\n return( vYear2Str + '-' + vMonthStr + '-' + vDayStr );\n\t case 'mm/dd':\n return( vMonthStr + '/' + vDayStr );\n\t case 'dd/mm':\n return( vDayStr + '/' + vMonthStr );\n }\t\t \n\t \n}\n\nJSGantt.parseXML = function(ThisFile,pGanttVar){\n\tvar is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1; // Is this Chrome \n\t\n\ttry { //Internet Explorer \n\t\txmlDoc=new ActiveXObject("Microsoft.XMLDOM");\n\t\t}\n\tcatch(e) {\n\t\ttry { //Firefox, Mozilla, Opera, Chrome etc. \n\t\t\tif (is_chrome==false) { xmlDoc=document.implementation.createDocument("","",null); }\n\t\t}\n\t\tcatch(e) {\n\t\t\talert(e.message);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tif (is_chrome==false) { \t// can't use xmlDoc.load in chrome at the moment\n\t\txmlDoc.async=false;\n\t\txmlDoc.load(ThisFile);\t\t// we can use loadxml\n\t\tJSGantt.AddXMLTask(pGanttVar)\n\t\txmlDoc=null;\t\t\t// a little tidying\n\t\tTask = null;\n\t}\n\telse {\n\t\tJSGantt.ChromeLoadXML(ThisFile,pGanttVar);\t\n\t\tta=null;\t// a little tidying\t\n\t}\n}\n\nJSGantt.AddXMLTask = function(pGanttVar){\n\n\tTask=xmlDoc.getElementsByTagName("task");\n\t\n\tvar n = xmlDoc.documentElement.childNodes.length;\t// the number of tasks. IE gets this right, but mozilla add extra ones (Whitespace)\n\t\n\tfor(var i=0;i/gi);\n\n\t\tvar n = ta.length;\t// the number of tasks. \n\t\tfor(var i=1;i/i)\n\t\n\t\t\tif(te.length> 2){var pID=te[1];} else {var pID = 0;}\n\t\t\tpID *= 1;\n\t\n\t\t\tvar te = Task.split(//i)\n\t\t\tif(te.length> 2){var pName=te[1];} else {var pName = "No Task Name";}\n\t\n\t\t\tvar te = Task.split(//i)\n\t\t\tif(te.length> 2){var pStart=te[1];} else {var pStart = "";}\n\t\n\t\t\tvar te = Task.split(//i)\n\t\t\tif(te.length> 2){var pEnd=te[1];} else {var pEnd = "";}\n\t\n\t\t\tvar te = Task.split(//i)\n\t\t\tif(te.length> 2){var pColor=te[1];} else {var pColor = '0000ff';}\n\n\t\t\tvar te = Task.split(//i)\n\t\t\tif(te.length> 2){var pLink=te[1];} else {var pLink = "";}\n\t\n\t\t\tvar te = Task.split(//i)\n\t\t\tif(te.length> 2){var pMile=te[1];} else {var pMile = 0;}\n\t\t\tpMile *= 1;\n\t\n\t\t\tvar te = Task.split(//i)\n\t\t\tif(te.length> 2){var pRes=te[1];} else {var pRes = "";}\t\n\t\n\t\t\tvar te = Task.split(//i)\n\t\t\tif(te.length> 2){var pComp=te[1];} else {var pComp = 0;}\t\n\t\t\tpComp *= 1;\n\t\n\t\t\tvar te = Task.split(//i)\n\t\t\tif(te.length> 2){var pGroup=te[1];} else {var pGroup = 0;}\t\n\t\t\tpGroup *= 1;\n\n\t\t\tvar te = Task.split(//i)\n\t\t\tif(te.length> 2){var pParent=te[1];} else {var pParent = 0;}\t\n\t\t\tpParent *= 1;\n\t\n\t\t\tvar te = Task.split(//i)\n\t\t\tif(te.length> 2){var pOpen=te[1];} else {var pOpen = 1;}\n\t\t\tpOpen *= 1;\n\t\n\t\t\tvar te = Task.split(//i)\n\t\t\tif(te.length> 2){var pDepend=te[1];} else {var pDepend = "";}\t\n\t\t\t//pDepend *= 1;\n\t\t\tif (pDepend.length==0){pDepend=''} // need this to draw the dependency lines\n\t\t\t\n\t\t\tvar te = Task.split(//i)\n\t\t\tif(te.length> 2){var pCaption=te[1];} else {var pCaption = "";}\n\t\t\t\n\t\t\t// Finally add the task\n\t\t\tpGanttVar.AddTaskItem(new JSGantt.TaskItem(pID , pName, pStart, pEnd, pColor, pLink, pMile, pRes, pComp, pGroup, pParent, pOpen, pDepend,pCaption \t));\n\t\t}\n\t}\n}\n\nJSGantt.benchMark = function(pItem){\n var vEndTime=new Date().getTime();\n alert(pItem + ': Elapsed time: '+((vEndTime-vBenchTime)/1000)+' seconds.');\n vBenchTime=new Date().getTime();\n}\n\n\n 114 jsGanttCSS 0 t ..gantt { font-family:tahoma, arial, verdana; font-size:10px;}\n\n..gdatehead { BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; HEIGHT: 18px }\n\n..ghead { BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; WIDTH: 24px; HEIGHT: 20px }\n\n..gname { BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; WIDTH: 18px; HEIGHT: 18px }\n\n..ghead A { FONT-SIZE: 10px; COLOR: #000000; TEXT-DECORATION: none }\n\n..gheadwkend A { FONT-SIZE: 10px; COLOR: #000000; TEXT-DECORATION: none }\n\n..gheadwkend { BORDER-TOP: #efefef 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #efefef 1px solid; WIDTH: 24px; HEIGHT: 20px; background-color: #cfcfcf }\n\n..gfiller { BORDER-TOP: #efefef 1px solid; BORDER-LEFT: #efefef 1px solid; WIDTH: 18px; HEIGHT: 18px }\n\n..gfillerwkend { BORDER-LEFT: #efefef 1px solid; WIDTH: 18px; HEIGHT: 18px; BACKGROUND-COLOR: #cfcfcf }\n\n..gitem { BORDER-TOP: #cccccc 1px solid; WIDTH: 18px; HEIGHT: 18px }\n\n..gitemwkend { BORDER-TOP: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; WIDTH: 18px; HEIGHT: 18px }\n\n..gmilestone {\tBORDER-TOP: #efefef 1px solid; FONT-SIZE: 14px; OVERFLOW: hidden; BORDER-LEFT: #efefef 1px solid; WIDTH: 18px; HEIGHT: 18px}\n\n..gmilestonewkend {\tBORDER-TOP: #efefef 1px solid; BORDER-LEFT: #cccccc 1px solid; WIDTH: 18px; HEIGHT: 18px}\n\n..btn { BORDER-RIGHT: #ffffff; BORDER-TOP: #ffffff; FONT-WEIGHT: bold; FONT-SIZE: 10px; BORDER-LEFT: #ffffff; WIDTH: 12px; COLOR: #cccccc; BORDER-BOTTOM: #ffffff; BACKGROUND-COLOR: #ffffff }\n\n..hrcomplete { BORDER-RIGHT: #000000 2px solid; PADDING-RIGHT: 0px; BORDER-TOP: #000000 2px solid; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; BORDER-LEFT: #000000 2px solid; WIDTH: 20px; COLOR: #000000; PADDING-TOP: 0px; BORDER-BOTTOM: #000000 2px solid; HEIGHT: 4px }\n\n..hrhalfcomplete { BORDER-RIGHT: #000000 2px solid; BORDER-TOP: #000000 2px solid; BORDER-LEFT: #000000 2px solid; WIDTH: 9px; COLOR: #000000; BORDER-BOTTOM: #000000 2px solid; HEIGHT: 4px }\n\n..gweekend { font-family:tahoma, arial, verdana; font-size:11px; background-color:#EEEEEE; text-align:center; }\n\n..gtask { font-family:tahoma, arial, verdana; font-size:11px; background-color:#00FF00; text-align:center; }\n\n..gday { font-family:tahoma, arial, verdana; font-size:11px; text-align:center; }\n\n..gcomplete { background-color:black; height:5px; overflow: auto; margin-top:4px; }\n\nDIV.scroll { BORDER-RIGHT: #efefef 1px solid; PADDING-RIGHT: 0px; BORDER-TOP: #efefef 1px solid; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; OVERFLOW: hidden; BORDER-LEFT: #efefef 1px solid; WIDTH: 420px; PADDING-TOP: 0px; BORDER-BOTTOM: #efefef 1px solid; BACKGROUND-COLOR: #ffffff }\n\nDIV.scroll2 { position:relative; PADDING-RIGHT: 0px; overflow:auto ;overflow-x:scroll;overflow-y:hidden; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; WIDTH: 482px; PADDING-TOP: 0px; BACKGROUND-COLOR: #ffffff }\n\n 116 project 0 t /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("xtte");\nxtte.project = new Object;\n\nvar _tab = mywindow.findChild("_tab"); \nvar _tebilling = toolbox.loadUi("tebilling", mywindow);\n_tab.insertTab(2, _tebilling, qsTr("Billing"));\n_tab.setEnabled(2, privileges.check("CanViewRates"));\n\nvar _buttonBox = mywindow.findChild("_buttonBox");\nvar _gantt = _buttonBox.addButton(qsTr("Gantt..."), QDialogButtonBox.ActionRole);\n\nvar _owner = mywindow.findChild("_owner");\nvar _assignedTo = mywindow.findChild("_assignedTo");\nvar _started = mywindow.findChild("_started");\nvar _due = mywindow.findChild("_due");\nvar _assigned = mywindow.findChild("_assigned");\nvar _completed = mywindow.findChild("_completed");\nvar _prjtask = mywindow.findChild("_prjtask");\nvar _newTask = mywindow.findChild("_newTask");\nvar _editTask = mywindow.findChild("_editTask");\nvar _viewTask = mywindow.findChild("_viewTask");\nvar _number = mywindow.findChild("_number");\nvar _name = mywindow.findChild("_name");\nvar _billingGroup = mywindow.findChild("_billingGroup");\nvar _itemGroup = _tebilling.findChild("_itemGroup");\nvar _useItem = _tebilling.findChild("_useItem");\nvar _cust = _tebilling.findChild("_cust");\nvar _rate = _tebilling.findChild("_rate");\nvar _mode = 'new';\nvar _teprjid = -1; \nvar _prjid = -1;\n\n//set = function(input)\nxtte.project.populated = function(input)\n{\n if (_number.enabled)\n _mode = "edit";\n else\n _mode = "view";\n\n if (input.mode == "view")\n {\n _cust.enabled = false;\n _billingGroup.enabled = false;\n }\n\n sql = "SELECT prj_id FROM prj WHERE prj_number=;";\n var params = new Object;\n params.prj_number = _number.text;\n \n var data = toolbox.executeQuery(sql, params);\n if (data.first())\n {\n _prjid = data.value("prj_id");\n xtte.project.populate();\n }\n}\n\nxtte.project.save = function(prjId)\n{\n if (prjId <= 0)\n return;\n\n var params = new Object();\n params.teprj_id\t= _teprjid;\n params.prj_id\t= prjId;\n if (_cust.isValid())\n params.cust_id \t= _cust.id();\n if (_billingGroup.checked)\n {\n params.rate\t= _rate.localValue;\n params.curr_id\t= _rate.id();\n }\n\n var query = "updteprj";\n if (_teprjid == -1)\n query = "insteprj";\n\n var q = toolbox.executeDbQuery("project", query, params);\n xtte.errorCheck(q);\n}\n\nxtte.project.populate = function()\n{\n var params = new Object();\n params.prj_id = _prjid; \n\n var q = toolbox.executeDbQuery("project", "selteprj", params);\n\n if (q.first())\n {\n _teprjid = q.value("teprj_id");\n _cust.setId(q.value("cust_id"));\n if (q.value("curr_id") == -1)\n _billingGroup.checked = false;\n else\n {\n _billingGroup.checked = true;\n _rate.setId(q.value("curr_id"));\n _rate.localValue = q.value("teprj_rate");\n }\n return;\n }\n else\n xtte.errorCheck(q);\n}\n\nxtte.project.newTask = function()\n{\n if (_prjid == -1)\n {\n if (!mywindow.sSave(true))\n return;\n else\n {\n var params = new Object;\n params.prjNumber = _number.text;\n\n var q = toolbox.executeDbQuery("projectGantt", "getprj", params);\n if (q.first())\n _prjid = q.value("prj_id");\n else\n return;\n }\n }\n\n xtte.project.openTask("new");\n}\n\nxtte.project.editTask = function()\n{\n xtte.project.openTask("edit");\n}\n\nxtte.project.viewTask = function()\n{\n xtte.project.openTask("view");\n}\n\nxtte.project.openTask = function(mode)\n{\n params = new Object;\n params.mode = mode;\n if (mode == "new")\n {\n params.prj_id = _prjid;\n params.prj_owner_username = _owner.username();\n params.prj_username = _assignedTo.username();\n params.prj_start_date = _started.date;\n params.prj_due_date = _due.date;\n params.prj_assigned_date = _assigned.date;\n params.prj_completed_date = _completed.date;\n }\n else\n params.prjtask_id = _prjtask.id();\n if (_cust.isValid())\n params.cust_id = _cust.id();\n\n var win = toolbox.openWindow("task", mywindow, Qt.ApplicationModal);\n toolbox.lastWindow().set(params);\n var result = win.exec();\n if(result != 0)\n mywindow.populate();\n}\n\nxtte.project.gantt = function()\n{\n if (!_due.isValid())\n {\n var msg = qsTr("You must enter a valid Due Date");\n QMessageBox.critical(mywindow, qsTr("Invalid Date"), msg);\n return;\n }\n\n var dparams = new Object;\n dparams.startDate = _started.date;\n dparams.dueDate = _due.date;\n\n var qry = toolbox.executeDbQuery("project","formatdates",dparams);\n if (qry.first())\n {\n var params = new Object;\n params.prjNumber = _number.text;\n params.prjName = _name.text;\n params.startDate = qry.value("start_date");\n params.dueDate = qry.value("due_date");\n\n toolbox.openWindow("projectGantt", mywindow, Qt.ApplicationModal);\n toolbox.lastWindow().set(params);\n }\n}\n\n// Initialize\n_itemGroup.hide();\n_useItem.hide();\n\n// Connections\ntoolbox.coreDisconnect(_newTask, "clicked()", mywindow, "sNewTask()");\ntoolbox.coreDisconnect(_editTask, "clicked()", mywindow, "sEditTask()");\ntoolbox.coreDisconnect(_viewTask, "clicked()", mywindow, "sViewTask()");\n\nmywindow.populated.connect(xtte.project.populated);\n_newTask.clicked.connect(xtte.project.newTask);\n_editTask.clicked.connect(xtte.project.editTask);\n_viewTask.clicked.connect(xtte.project.viewTask);\n_gantt.clicked.connect(xtte.project.gantt);\nmydialog["finished(int)"].connect(xtte.project.save);\n\n 115 projectGantt 0 t /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("xtte");\nxtte.projectGantt = new Object;\n\nvar _webView = new QWebView(mywindow);\nvar _toolBar = mywindow.findChild("_toolBar");\nvar _layout = toolbox.widgetGetLayout(_toolBar);\nvar _prjid;\nvar _prjNumber;\nvar _prjName;\nvar _startDate;\nvar _dueDate;\nvar _jsCode;\nvar _cssCode;\nvar _jsPath;\nvar _cssPath;\nvar _qry;\nvar _page;\nvar _gantt;\n\nset = function (input) \n{ \n if ("startDate" in input)\n _startDate = input.startDate;\n\n if ("dueDate" in input)\n _dueDate = input.dueDate;\n\n if ("prjName" in input)\n _prjName = input.prjName;\n\n if ("prjNumber" in input)\n {\n _prjNumber = input.prjNumber;\n qry = toolbox.executeDbQuery("projectGantt","getprj",input);\n if (qry.first())\n _prjid = qry.value("prj_id");\n\n xtte.projectGantt.populate();\n }\n}\n\nxtte.projectGantt.populate = function()\n{\n\n _page = '';\n _page = _page + '';\n _page = _page + '';\n _page = _page + '';\n _page = _page + '
';\n\n _gantt = "";\n \n var html = _page + _gantt;\n _webView.setHtml(html);\n // This snippet should make the link open in a new browser, but nothing happens. Why?\n //_webView.page().linkDelegationPolicy = QWebPage.DelegateAllLinks;\n}\n\n// Initialize\nmywindow.findChild("_close").triggered.connect(mywindow, "close");\n\n_layout.addWidget(_webView, 1, 0);\n\n// Create jsGantt files on local OS if they don't already exist\nvar tmpdir = QDir.tempPath();\n_jsPath = tmpdir + "/jsgantt.js";\n_cssPath = tmpdir + "/jscantt.css";\n\nif (!QFile.exists(_jsPath))\n{\n // Create jsGantt script\n qry = toolbox.executeDbQuery("projectGantt","jsgantt");\n if (qry.first());\n _jsCode = qry.value("script_source");\n\n toolbox.textStreamWrite(_jsPath, _jsCode);\n\n // Create jsGantt style sheet\n qry = toolbox.executeDbQuery("projectGantt","jsganttcss");\n if (qry.first());\n _cssCode = qry.value("script_source");\n\n toolbox.textStreamWrite(_cssPath, _cssCode);\n}\n 119 timeExpenseSheet 0 t /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\ndebugger;\nvar _debug = false;\ninclude("xtte");\n\ntry\n{\n if (_debug)\n print("xtte.timeExpenseSheet script entered");\n\n // Define Variables\n xtte.timeExpenseSheet = new Object;\n\n var _all = mywindow.findChild("_all");\n var _buttonBox = mywindow.findChild("_buttonBox");\n var _edit = mywindow.findChild("_edit");\n var _new = mywindow.findChild("_new");\n var _delete = mywindow.findChild("_delete");\n var _view = mywindow.findChild("_view");\n var _print = mywindow.findChild("_print");\n var _printSheet = mywindow.findChild("_printSheet");\n var _lines = mywindow.findChild("_lines");\n var _selected = mywindow.findChild("_selected");\n var _weekending = mywindow.findChild("_weekending");\n var _employee = mywindow.findChild("_employee");\n var _sheetNumberExtra = mywindow.findChild("_sheetNumberExtra");\n var _site = mywindow.findChild("_site");\n var _orderComments = mywindow.findChild("_orderComments");\n var _documents = mywindow.findChild("_documents");\n\n var _sheet;\n var _id = -1;\n var _type;\n var _admin;\n\n _lines.addColumn(qsTr("Type"),\t\tXTreeWidget.docTypeColumn,Qt.AlignLeft, false, "teitem_type");\n\n //add logic to determine the next Sunday date and populate both start and end with it\n _lines.addColumn(qsTr("Line #"), XTreeWidget.seqColumn, Qt.AlignLeft, true, "teitem_linenumber");\n _lines.addColumn(qsTr("Sheet Date"), XTreeWidget.dateColumn, Qt.AlignLeft, false, "tehead_weekending");\n _lines.addColumn(qsTr("Work Date"), XTreeWidget.dateColumn, Qt.AlignLeft, true, "teitem_workdate");\n _lines.addColumn(qsTr("Project#"), XTreeWidget.orderColumn, Qt.AlignLeft, true, "prj_number");\n _lines.addColumn(qsTr("Project Name"), -1, Qt.AlignLeft, false, "prj_name");\n _lines.addColumn(qsTr("Task#"), XTreeWidget.orderColumn, Qt.AlignLeft, true, "prjtask_number");\n _lines.addColumn(qsTr("Task Name"), -1, Qt.AlignLeft, false, "prjtask_name");\n _lines.addColumn(qsTr("Cust.#"), XTreeWidget.orderColumn, Qt.AlignLeft, false, "cust_number");\n _lines.addColumn(qsTr("Cust. Name"), -1, Qt.AlignLeft, false, "cust_name");\n _lines.addColumn(qsTr("PO"), XTreeWidget.orderColumn, Qt.AlignLeft, false, "teitem_po");\n _lines.addColumn(qsTr("Item"), XTreeWidget.itemColumn, Qt.AlignLeft, true, "item_number");\n _lines.addColumn(qsTr("Description"), -1, Qt.AlignLeft, true, "item_descrip1");\n _lines.addColumn(qsTr("Hours"), XTreeWidget.qtyColumn, Qt.AlignRight, true, "hours");\n _lines.addColumn(qsTr("Expense"), XTreeWidget.qtyColumn, Qt.AlignRight, true, "expense");\n _lines.addColumn(qsTr("Notes"), -1, Qt.AlignLeft, false, "f_notes");\n\n\n if (privileges.check("CanViewRates"))\n {\n _lines.addColumn(qsTr("Billable"), XTreeWidget.ynColumn, Qt.AlignLeft, true, "teitem_billable");\n _lines.addColumn(qsTr("Rate"), XTreeWidget.priceColumn, Qt.AlignRight, false, "teitem_rate");\n _lines.addColumn(qsTr("Extended"), XTreeWidget.moneyColumn, Qt.AlignRight, false, "teitem_total");\n }\n\n}\n\ncatch (e)\n{\n QMessageBox.critical(mywindow, "timeExpenseSheet",\n qsTr("timeExpenseSheet.js exception: ") + e);\n}\n\nset = function(input)\n{\n try\n {\n if (_debug)\n print("xtte.timeExpenseSheet.set entered");\n\n if("emp_id" in input)\n _employee.setId(input.emp_id); \n \n if("sheet" in input) \n _sheet = input.sheet;\n\n if ("tehead_id" in input)\n {\n _id = input.tehead_id;\n _documents.setId(_id);\n }\n\n if("mode" in input)\n {\n if (input.mode <= xtte.editMode)\n {\n _lines["valid(bool)"].connect(_edit["setEnabled(bool)"]);\n _lines["valid(bool)"].connect(_delete["setEnabled(bool)"]);\n _lines.itemSelected.connect(_edit, "animateClick");\n }\n\n if (input.mode == xtte.newMode)\n {\n _mode = "new";\n _weekending.enabled = true;\n }\n else if (input.mode == xtte.editMode)\n {\n _mode = "edit";\n _weekending.enabled = false;\n _employee.enabled = false;\n _site.enabled = false;\n var shortcut = _buttonBox.button(QDialogButtonBox.Cancel).shortcut;\n _buttonBox.removeButton(_buttonBox.button(QDialogButtonBox.Cancel));\n _buttonBox.addButton(QDialogButtonBox.Close);\n _buttonBox.button(QDialogButtonBox.Close).shortcut = shortcut;\n\n xtte.timeExpenseSheet.populate();\n }\n else if (input.mode == xtte.viewMode)\n {\n _mode = "view";\n _new.enabled = false;\n _orderComments.enabled = false;\n var shortcut = _buttonBox.button(QDialogButtonBox.Cancel).shortcut;\n _buttonBox.clear();\n _buttonBox.addButton(QDialogButtonBox.Close);\n _buttonBox.button(QDialogButtonBox.Close).shortcut = shortcut;\n _lines.itemSelected.connect(_view, "animateClick");\n _printSheet.hide();\n\n xtte.timeExpenseSheet.populate();\n }\n }\n return mainwindow.NoError;\n }\n catch (e)\n {\n QMessageBox.critical(mywindow, "timeExpenseSheet",\n qsTr("set exception: ") + e);\n }\n}\n\nxtte.timeExpenseSheet.populateMenu = function(pMenu, pItem, pCol)\n{\n try\n {\n if (_debug)\n print("xtte.timeExpenseSheet.populateMenu entered");\n\n var tmpact;\n\n if(pMenu == null)\n pMenu = _lines.findChild("_menu");\n\n if(pMenu != null)\n {\n var currentItem = _lines.currentItem();\n if (currentItem != null)\n {\n tmpact = pMenu.addAction(qsTr("Edit..."));\n tmpact.triggered.connect(xtte.timeExpenseSheet.editItem);\n tmpact.enabled = (_mode != "view" && privileges.check("MaintainTimeExpense"));\n\n tmpact = pMenu.addAction(qsTr("View..."));\n tmpact.triggered.connect(xtte.timeExpenseSheet.viewItem);\n\n tmpact = pMenu.addAction(qsTr("Delete..."));\n tmpact.triggered.connect(xtte.timeExpenseSheet.deleteItem);\n tmpact.enabled = (_mode != "view" && privileges.check("MaintainTimeExpense"));\n }\n }\n }\n catch (e)\n {\n QMessageBox.critical(mywindow, "timeExpenseSheet",\n qsTr("populateMenu exception: ") + e);\n }\n}\n\nxtte.timeExpenseSheet.deleteItem = function()\n{\n try\n {\n if (_debug)\n print("xtte.timeExpenseSheet.deleteItem entered");\n\n var msg = qsTr("Are you sure you want to delete this line?");\n if (QMessageBox.question(mywindow, mywindow.windowTitle, msg,\n QMessageBox.Yes | QMessageBox.Escape,\n QMessageBox.No | QMessageBox.Default) == QMessageBox.Yes)\n {\n var params = new Object();\n params.teitem_id = _lines.id();\n\n q = toolbox.executeDbQuery("timeexpensesheet","delteitem", params );\n xtte.errorCheck(q);\n xtte.timeExpenseSheet.fillList();\n }\n }\n catch (e)\n {\n QMessageBox.critical(mywindow, "timeExpenseSheet",\n qsTr("deleteItem exception: ") + e);\n }\n}\n\nxtte.timeExpenseSheet.newItem = function()\n{\n try\n {\n if (_debug)\n print("xtte.timeExpenseSheet.newItem entered");\n\n if (!xtte.timeExpenseSheet.save())\n return;\n\n xtte.timeExpenseSheet.openItem(xtte.newMode);\n }\n catch (e)\n {\n QMessageBox.critical(mywindow, "timeExpenseSheet",\n qsTr("newItem exception: ") + e);\n }\n}\n\nxtte.timeExpenseSheet.editItem = function()\n{\n try\n {\n if (_debug)\n print("xtte.timeExpenseSheet.editItem entered");\n\n xtte.timeExpenseSheet.openItem(xtte.editMode);\n }\n catch (e)\n {\n QMessageBox.critical(mywindow, "timeExpenseSheet",\n qsTr("editItem exception: ") + e);\n }\n}\n\nxtte.timeExpenseSheet.viewItem = function()\n{\n try\n {\n if (_debug)\n print("xtte.timeExpenseSheet.viewItem entered");\n\n xtte.timeExpenseSheet.openItem(xtte.viewMode);\n }\n catch (e)\n {\n QMessageBox.critical(mywindow, "timeExpenseSheet",\n qsTr("viewItem exception: ") + e);\n }\n}\n\nxtte.timeExpenseSheet.openItem = function(mode)\n{\n try\n {\n if (_debug)\n print("xtte.timeExpenseSheet.openItem entered");\n\n var params = new Object;\n params.tehead_id = _id;\n params.site = _site.text;\n params.weekending = _weekending.date;\n params.emp_id = _employee.id();\n params.mode = mode;\n if (mode) // Not new\n params.teitem_id = _lines.id();\n\n var wnd = toolbox.openWindow("timeExpenseSheetItem", mywindow);\n toolbox.lastWindow().set(params);\n wnd.exec();\n\n xtte.timeExpenseSheet.fillList();\n }\n catch (e)\n {\n QMessageBox.critical(mywindow, "timeExpenseSheet",\n qsTr("openItem exception: ") + e);\n }\n}\n\nxtte.timeExpenseSheet.accepted = function()\n{\n try\n {\n if (_debug)\n print("xtte.timeExpenseSheet.accepted entered");\n\n if (!xtte.timeExpenseSheet.save())\n return;\n\n if (_printSheet.checked)\n xtte.timeExpenseSheet.printSheet();\n\n mywindow.close();\n }\n catch (e)\n {\n QMessageBox.critical(mywindow, "timeExpenseSheet",\n qsTr("accepted exception: ") + e);\n }\n}\n\nxtte.timeExpenseSheet.save = function()\n{\n try\n {\n if (_debug)\n print("xtte.timeExpenseSheet.save entered");\n\n if (!_employee.isValid())\n throw new Error(qsTr("Employee Required"));\n\n if (_site.id() == -1)\n throw new Error(qsTr("Site Required"));\n\n if (!_weekending.isValid())\n throw new Error(qsTr("Week Ending Date Required"));\n\n var params = new Object();\n params.tehead_id = _id;\n params.emp_id = _employee.id();\n params.warehous_id = _site.id();\n params.weekending = _weekending.date;\n params.notes = _orderComments.plainText;\n\n var query = "updtehead";\n if (_id == -1)\n query = "instehead";\n\n q = toolbox.executeDbQuery("timeexpensesheet", query, params );\n if (q.first())\n {\n _id = q.value("tehead_id");\n _documents.setId(_id);\n _sheetNumberExtra.text = q.value("tehead_number");\n }\n else if (!xtte.errorCheck(q))\n return false;\n\n _weekending.enabled = false;\n _employee.enabled = false;\n _site.enabled = false;\n\n return true;\n }\n catch (e)\n {\n QMessageBox.critical(mywindow, qsTr("Worksheet"), e.message);\n return false;\n }\n}\n\nxtte.timeExpenseSheet.handleNewButton = function()\n{\n try\n {\n if (_debug)\n print("xtte.timeExpenseSheet.handleNewButton entered");\n\n _new.enabled = (_weekending.isValid() &&\n _employee.isValid() &&\n _mode != "view");\n }\n catch (e)\n {\n QMessageBox.critical(mywindow, "timeExpenseSheet",\n qsTr("handleNewButton exception: ") + e);\n }\n}\n\nxtte.timeExpenseSheet.populate = function()\n{\n try\n {\n if (_debug)\n print("xtte.timeExpenseSheet.populate entered");\n\n var params = new Object;\n params.type = _type;\n params.emp = _employee.id();\n params.tehead_id = _id;\n\n q = toolbox.executeDbQuery("timeexpensesheet", "header", params);\n\n if (q.first())\n {\n _weekending.date = q.value("tehead_weekending");\n _sheetNumberExtra.text = q.value("tehead_number");\n _employee.setId(q.value("tehead_emp_id"));\n _site.setId(q.value("tehead_warehous_id"));\n _orderComments.setPlainText(q.value("tehead_notes"));\n }\n else if (!xtte.errorCheck(q))\n return;\n\n if (_mode == "view")\n {\n _weekending.enabled = false;\n _employee.enabled = false;\n _site.enabled = false;\n }\n\n xtte.timeExpenseSheet.fillList();\n }\n catch (e)\n {\n QMessageBox.critical(mywindow, "timeExpenseSheet",\n qsTr("populate exception: ") + e);\n }\n}\n\nxtte.timeExpenseSheet.testCurrEmpId = function()\n{\n var params = new Object;\n params.emp_id = _employee.id();\n qry = toolbox.executeQuery("SELECT crmacct_emp_id = ::integer AS test "\n + "FROM crmacct "\n + "WHERE crmacct_usr_username = getEffectiveXtUser();", params);\n if (qry.first()) {\n return qry.value("test");\n }\n else\n QMessageBox.information(mywindow, "Database Error", qry.lastError().text);\n return false;\n}\n\nxtte.timeExpenseSheet.fillList = function()\n{\n try\n {\n if (_debug)\n print("xtte.timeExpenseSheet.fillList entered");\n\n if ( ( privileges.check("MaintainEmpCostSelf") && xtte.timeExpenseSheet.testCurrEmpId()) || privileges.check("MaintainEmpCostAll") )\n {\n _lines.addColumn(qsTr("Hourly Cost"), XTreeWidget.priceColumn, Qt.AlignRight, false, "teitem_hrlycost");\n _lines.addColumn(qsTr("Total Cost"), XTreeWidget.priceColumn, Qt.AlignRight, false, "teitem_totalcost");\n }\n\n var params = new Object;\n params.tehead_id = _id;\n params.time = qsTr("Time");\n params.expense = qsTr("Expense");\n params.error = qsTr("Error");\n\n q = toolbox.executeDbQuery("timeexpensesheet", "detail", params);\n\n _lines.populate(q);\n\n xtte.errorCheck(q);\n }\n catch (e)\n {\n QMessageBox.critical(mywindow, "timeExpenseSheet",\n qsTr("fillList exception: ") + e);\n }\n}\n\nxtte.timeExpenseSheet.printSheet = function()\n{\n try\n {\n if (_debug)\n print("xtte.timeExpenseSheet.printSheet entered");\n\n var params = new Object;\n params.tehead_id = _id;\n params.approved = qsTr("Approved");\n params.closed = qsTr("Closed");\n params.open = qsTr("Open");\n\n toolbox.printReport("TimeExpenseSheet", params);\n }\n catch (e)\n {\n QMessageBox.critical(mywindow, "timeExpenseSheet",\n qsTr("printSheet exception: ") + e);\n }\n}\n\nxtte.timeExpenseSheet.close = function()\n{\n try\n {\n if (_debug)\n print("xtte.timeExpenseSheet.close entered");\n\n if (_mode == "new" && _id != -1)\n {\n if (QMessageBox.question(mywindow,\n qsTr("Delete Worksheet"),\n qsTr("

Are you sure you want to cancel this "\n + "Worksheet and discard all your changes?"),\n QMessageBox.Yes, QMessageBox.No) == QMessageBox.Yes)\n {\n var params = new Object;\n params.tehead_id = _id;\n\n toolbox.executeDbQuery("timeexpensesheet", "deltehead", params);\n }\n else\n return;\n }\n\n mywindow.close();\n }\n catch (e)\n {\n QMessageBox.critical(mywindow, "timeExpenseSheet",\n qsTr("close exception: ") + e);\n }\n}\n\n// Initialize\n_employee.enabled = privileges.check("MaintainTimeExpenseOthers");\n_new.enabled = false;\n\n// Make connections\n_employee.newId.connect(xtte.timeExpenseSheet.handleNewButton);\n_weekending.newDate.connect(xtte.timeExpenseSheet.handleNewButton);\n_lines["valid(bool)"].connect(_view["setEnabled(bool)"]);\n\n_buttonBox.accepted.connect(xtte.timeExpenseSheet.accepted);\n_buttonBox.rejected.connect(xtte.timeExpenseSheet.close);\n\n_new.clicked.connect(xtte.timeExpenseSheet.newItem);\n_edit.clicked.connect(xtte.timeExpenseSheet.editItem);\n_delete.clicked.connect(xtte.timeExpenseSheet.deleteItem);\n_view.clicked.connect(xtte.timeExpenseSheet.viewItem);\n\n_lines["populateMenu(QMenu *, XTreeWidgetItem *, int)"].connect(xtte.timeExpenseSheet.populateMenu); 120 timeExpenseSheetItem 0 t /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("xtte");\n\n// Define local variables\nxtte.timeExpenseSheetItem = new Object;\n\nvar _hours = mywindow.findChild("_hours");\nvar _total = mywindow.findChild("_total");\t\nvar _totalLit = mywindow.findChild("_totalLit");\t\nvar _rate = mywindow.findChild("_rate");\nvar _rateLit = mywindow.findChild("_rateLit");\nvar _clients = mywindow.findChild("_clients");\nvar _employee = mywindow.findChild("_employee");\nvar _items = mywindow.findChild("_items");\nvar _po = mywindow.findChild("_po");\nvar _project = mywindow.findChild("_project");\nvar _task = mywindow.findChild("_task");\nvar _linenumber = mywindow.findChild("_linenumber");\nvar _sheet = mywindow.findChild("_sheet");\nvar _buttonBox = mywindow.findChild("_buttonBox");\nvar _weekending = mywindow.findChild("_weekending");\nvar _workdate = mywindow.findChild("_workdate");\nvar _type = mywindow.findChild("_type");\nvar _qtyLabel = mywindow.findChild("_qtyLabel");\nvar _billable = mywindow.findChild("_billable");\nvar _prepaid = mywindow.findChild("_prepaid");\nvar _actual = mywindow.findChild("_actual");\nvar _budget = mywindow.findChild("_budget");\nvar _actualCost = mywindow.findChild("_actualCost");\nvar _budgetCost = mywindow.findChild("_budgetCost");\nvar _notes = mywindow.findChild("_notes");\nvar _sheetLit = mywindow.findChild("_sheetLit");\nvar _dayHrs = mywindow.findChild("_dayHrs");\nvar _weekHrs = mywindow.findChild("_weekHrs");\n\nvar _empcostLit\t\t\t= mywindow.findChild("_empcostLit");\nvar _empcost\t\t\t= mywindow.findChild("_empcost");\nvar _totCostLit = mywindow.findChild("_totCostLit");\nvar _totCost = mywindow.findChild("_totCost");\n\nvar _cancel = _buttonBox.button(QDialogButtonBox.Cancel);\nvar _prev = _buttonBox.addButton(qsTr("Prev"), QDialogButtonBox.ActionRole);\nvar _next = _buttonBox.addButton(qsTr("Next"), QDialogButtonBox.ActionRole);\n\nvar _sheetnum;\nvar _linenum;\nvar _teitemid = -1;\nvar _headid = -1;\nvar _taskid = -1;\nvar _site;\nvar _mode = xtte.newMode;\nvar _modified = false;\nvar _populating = false;\nvar _last = true;\n\n\nset = function(input)\n{\n if("emp_id" in input)\n _employee.setId(input.emp_id);\n \n if("weekending" in input)\n _weekending.date = input.weekending;\n\n if ("tehead_id" in input)\n _headid = input.tehead_id;\n\n if ("site" in input)\n _site = input.site;\n\n if ("teitem_id" in input)\n _teitemid = input.teitem_id;\n\n if ("mode" in input)\n {\n _mode = input.mode;\n\n if (input.mode == xtte.newMode)\n {\n xtte.timeExpenseSheetItem.clear();\n }\n else if (input.mode == xtte.viewMode)\n {\n var shortcut = _buttonBox.button(QDialogButtonBox.Cancel).shortcut;\n _buttonBox.removeButton(_buttonBox.button(QDialogButtonBox.Cancel));\n _buttonBox.removeButton(_buttonBox.button(QDialogButtonBox.Save));\n _buttonBox.addButton(QDialogButtonBox.Close);\n _buttonBox.button(QDialogButtonBox.Close).shortcut = shortcut;\n _weekending.enabled = false;\n _next.enabled = false;\n _prepaid.enabled = false;\n _type.enabled = false;\n _weekending.enabled = false;\n _workdate.enabled = false;\n _hours.enabled = false;\n _rate.enabled = false;\n _items.enabled = false;\n _employee.enabled = false;\n _clients.enabled = false;\n _po.enabled = false;\n _project.enabled = false;\n _task.enabled = false;\n _notes.enabled = false;\n _billable.enabled = false; \n _empcost.enabled = false;\n }\n else if (input.mode == xtte.editMode)\n {\n _project.enabled = false;\n _task.enabled = false;\n }\n\n xtte.timeExpenseSheetItem.populate();\n }\n\n \n return mainwindow.NoError;\n}\n\nxtte.timeExpenseSheetItem.extension = function()\n{\n _total.localValue = (_hours.toDouble() * _rate.localValue);\n _totCost.localValue = (_hours.toDouble() * _empcost.localValue);\n if (_type.code == 'T')\n xtte.timeExpenseSheetItem.empTotals();\n xtte.timeExpenseSheetItem.modified();\n}\n\nxtte.timeExpenseSheetItem.gettask = function()\n{\n if (_project.isValid())\n {\n var params = new Object();\n params.prj_id = _project.id();\n params.name = qsTr("Default");\n if (_mode == xtte.newMode)\n params.active = true;\n if (_workdate.isValid())\n params.startDate = _workdate.date;\n\n var qry = toolbox.executeDbQuery("timeexpensesheetitem", "gettask", params);\n if(!xtte.errorCheck(qry))\n return;\n\n _task.populate(qry);\n\n if(_taskid > 0)\n _task.setId(_taskid);\n\n if (!qry.first())\n {\n var msg = qsTr("No task found. A default task will be added");\n QMessageBox.critical(mywindow, qsTr("task"), msg);\n toolbox.executeDbQuery("timeexpensesheetitem","instask",params);\n\n qry = toolbox.executeDbQuery("timeexpensesheetitem", "gettask", params);\n _task.populate(qry);\n }\n\n xtte.timeExpenseSheetItem.getPrice();\n xtte.timeExpenseSheetItem.budgTotals();\n xtte.timeExpenseSheetItem.actTotals();\n }\n}\n\nxtte.timeExpenseSheetItem.modified = function()\n{\n if (_populating)\n return;\n\n _modified = true;\n}\n\nxtte.timeExpenseSheetItem.getPrice = function()\n{\n if (_populating)\n return;\n var params = new Object();\n params.emp_id = _employee.id();\n if(_type.code == 'T')\n {\n var qry2 = toolbox.executeQuery("SELECT te.calcRate(emp_wage, emp_wage_period) as cost "\n + "FROM emp WHERE emp_id = ", params);\n if (qry2.first())\n {\n _empcost.setBaseValue(qry2.value("cost"));\n _totCost.setBaseValue(qry2.value("cost") * _hours.toDouble());\n }\n else\n xtte.errorCheck(qry2);\n }\n if (!_clients.isValid())\n return;\n if (_type.code == 'T' && !_billable.checked)\n {\n _rate.localValue = 0;\n _rate.enabled = false;\n } \n else if (_mode == xtte.editMode)\n {\n if (QMessageBox.question(mywindow,\n qsTr("Update Rate?"),\n qsTr("

Would you like to update the existing rate?"),\n QMessageBox.Ok, QMessageBox.Cancel) == QMessageBox.Cancel)\n return;\n }\n\n params.item_id = _items.id();\n params.task_id = _task.id();\n params.prj_id = _project.id();\n params.cust_id = _clients.id();\n if (_type.code == "T")\n params.time = true;\n \n if(_billable.checked)\n {\n var qry = toolbox.executeDbQuery("timeexpensesheetitem", "getterate", params);\n if (qry.first())\n {\n _rate.setLocalValue(qry.value("rate"));\n _rate.enabled = true;\n }\n else\n xtte.errorCheck(qry);\n } \n \n xtte.timeExpenseSheetItem.modified();\n}\n\nxtte.timeExpenseSheetItem.populate = function()\n{\n _modified = false;\n \n // Edit or View mode\n var params = new Object();\n params.teitem_id = _teitemid;\n\n var qry = toolbox.executeDbQuery("timeexpensesheetitem","detail", params);\n if (qry.first())\n {\n if (_mode == xtte.newMode)\n _mode = xtte.editMode;\n _populating = true; \n\n _headid = qry.value("teitem_tehead_id");\n _sheet.text = (qry.value("tehead_number"));\n _sheetnum = (qry.value("tehead_number"));\n _employee.setId(qry.value("tehead_emp_id"));\n _weekending.date = (qry.value("tehead_weekending"));\n\n _linenumber.text = (qry.value("teitem_linenumber"));\n _linenum = (qry.value("teitem_linenumber"));\n _workdate.date = (qry.value("teitem_workdate"));\n _type.code = qry.value("teitem_type");\n _clients.setId(qry.value("teitem_cust_id"));\n _po.text = (qry.value("teitem_po"));\n _items.setId(qry.value("teitem_item_id"));\n _hours.text = (qry.value("teitem_qty"));\n _rate.setId(qry.value("teitem_curr_id") - 0);\n _rate.localValue = (qry.value("teitem_rate"));\n _total.localValue = (qry.value("teitem_total"));\n _project.setId(qry.value("prj_id"));\n _task.setId(qry.value("teitem_prjtask_id"));\n _billable.checked = qry.value("teitem_billable");\n _prepaid.checked = qry.value("teitem_prepaid")\n _notes.plainText = qry.value("teitem_notes");\n _empcost.localValue = qry.value("teitem_hrlycost");\n _totCost.localValue = qry.value("teitem_hrlycost")*qry.value("teitem_qty");\n\n _last = qry.value("ismax");\n if (_last && _mode == xtte.editMode)\n _next.text = qsTr("New");\n else\n _next.text = qsTr("Next");\n\n _next.enabled = !(_last && _mode == xtte.viewMode);\n _prev.enabled = (_linenum > 1);\n\n _populating = false;\n _modified = false;\n }\n else if (!xtte.errorCheck)\n return;\n\n xtte.timeExpenseSheetItem.empTotals();\n}\n\nxtte.timeExpenseSheetItem.accepted = function()\n{\n if (xtte.timeExpenseSheetItem.save())\n {\n if (_mode == xtte.newMode)\n xtte.timeExpenseSheetItem.clear();\n else\n mywindow.close();\n }\n}\n\nxtte.timeExpenseSheetItem.save = function()\n{\n try\n {\n if (!_workdate.isValid())\n throw new Error(qsTr("Work Date Required"));\n \n if (!_project.isValid())\n throw new Error(qsTr("Project Required"));\n \n if (!_items.isValid())\n throw new Error(qsTr("Item Required"));\n\n if (_task.id == -1)\n throw new Error(qsTr("Task Required"));\n\n if (_hours.toDouble < 0 && _billable.checked)\n throw new Error(qsTr("Billing of negative amounts is not supported"));\n }\n catch (e)\n {\n QMessageBox.critical(mywindow, qsTr("Processing Error"), e.message);\n return false;\n }\n\n if ((_hours.toDouble() <= 0 || _total.localValue <= 0) && _type.code == 'E' && !_prepaid.checked)\n {\n var msg = qsTr("The system only supports vouchering positive expense quantities and amounts. "\n + "Do you want to save anyway?")\n if (QMessageBox.question( mywindow, mywindow.windowTitle, msg, \n QMessageBox.Yes | QMessageBox.Escape, QMessageBox.No | QMessageBox.Default) == QMessageBox.No)\n return false;\n }\n\n\n var params = new Object();\n params.teitem_tehead_id = _headid;\n params.teitem_linenumber = _linenum;\n params.teitem_type \t = _type.code;\n params.teitem_workdate = _workdate.date;\n params.teitem_cust_id = _clients.id();\n params.teitem_po = _po.text;\n params.teitem_item_id = _items.id();\n params.teitem_qty = _hours.toDouble();\n params.teitem_rate = _rate.localValue;\n params.teitem_total = _total.localValue;\n params.teitem_prjtask_id = _task.id();\n params.teitem_billable = _billable.checked;\n params.teitem_prepaid = _prepaid.checked;\n params.teitem_notes = _notes.plainText;\n params.teitem_id = _teitemid;\n params.teitem_curr_id = _rate.id();\n params.teitem_empcost = _empcost.localValue;\n\n var query = "updteitem";\n if (_teitemid < 0)\n query = "insteitem";\n\n var q = toolbox.executeDbQuery("timeexpensesheetitem", query, params);\n if (q.first())\n _teitemid = q.value("teitem_id");\n else if (!xtte.errorCheck(q))\n return;\n\n _prev.enabled = true;\n\n return true;\n}\n\n\nxtte.timeExpenseSheetItem.typeChanged = function()\n{\n if (_type.code == "T")\n {\n _qtyLabel.text = qsTr("Hours:");\n _rateLit.text = qsTr("Rate:");\n _rate.enabled = _clients.isValid();\n _billable.visible = true;\n _prepaid.visible = false;\n _prepaid.checked = false;\n _empcost.enabled = true;\n } \n else\n {\n _qtyLabel.text = qsTr("Qty:");\n _rateLit.text = qsTr("Unit Cost:");\n _billable.visible = true;\n _prepaid.visible = true;\n _empcost.enabled = false;\n _empcost.localValue = 0;\n _rate.enabled = true;\n _rate.localValue = 0;\n\n var params = new Object();\n params.emp_id = _employee.id();\n\n var qry = toolbox.executeQuery("SELECT COALESCE (crmacct_vend_id,-1) AS crmacct_vend_id FROM crmacct WHERE crmacct_emp_id= ;",params);\n\n if (qry.first())\n {\n var vend_id= qry.value("crmacct_vend_id");\n if(vend_id ==-1)\n {\n var msg = qsTr("The Employee is not a Vendor, this expense cannot be vouchered. "\n + "Do you want to continue?")\n if (QMessageBox.question( mywindow, mywindow.windowTitle, msg,\n QMessageBox.Yes | QMessageBox.Escape, QMessageBox.No | QMessageBox.Default) == QMessageBox.No)\n {\n _type.code= "T";\n return false;\n }\n }\n }\n }\n xtte.timeExpenseSheetItem.getPrice();\n xtte.timeExpenseSheetItem.empTotals();\n xtte.timeExpenseSheetItem.modified();\n}\n\nxtte.timeExpenseSheetItem.customerChanged = function()\n{\n _billable.enabled = _clients.isValid();\n _rate.enabled = (_clients.isValid() || _type.code == 'E');\n\n if (_populating)\n return;\n\n if (!_clients.isValid())\n {\n _po.clear();\n _rate.localValue = 0;\n _billable.checked = false;\n }\n\n var params = new Object;\n params.cust_id = _clients.id();\n\n q = toolbox.executeDbQuery("timeexpensesheetitem", "getcustinfo", params);\n if (q.first())\n _rate.setId(q.value("cust_curr_id") - 0);\n else if (!xtte.errorCheck(q))\n return;\n\n xtte.timeExpenseSheetItem.getPrice();\n}\n\nxtte.timeExpenseSheetItem.projectChanged = function()\n{\n //enable and reset the task fields\n _task.enabled = (_project.isValid() && _mode == xtte.newMode);\n\n xtte.timeExpenseSheetItem.gettask();\n xtte.timeExpenseSheetItem.modified();\n xtte.timeExpenseSheetItem.getPrice();\n}\n\n\nxtte.timeExpenseSheetItem.taskChanged = function()\n{ \n var custid = -1;\n var itemid = -1;\n var params = new Object;\n params.prjtask_id = _task.id();\n\n q = toolbox.executeDbQuery("timeexpensesheetitem", "taskdefaults", params);\n if (q.first())\n {\n custid = q.value("cust_id");\n itemid = q.value("item_id")\n }\n else if (!xtte.errorCheck(q))\n return;\n\n if (_populating)\n {\n // Disable if customer matches default, otherwise default must have changed\n // so allow for editing so user can decide what to do\n _clients.enabled = !(_clients.isValid() && _clients.id() == custid)\n _items.enabled = !(_items.isValid() && _items.id() == itemid)\n }\n else\n {\n if (custid > 0)\n {\n _clients.setId(custid);\n _clients.enabled = false;\n }\n else\n _clients.enabled = true;\n\n if (itemid > 0)\n {\n _items.setId(itemid);\n _items.enabled = false;\n }\n else\n _items.setId(-1);\n _items.enabled = true;\n }\n\n xtte.timeExpenseSheetItem.getPrice();\n xtte.timeExpenseSheetItem.budgTotals();\n xtte.timeExpenseSheetItem.actTotals();\n xtte.timeExpenseSheetItem.modified();\n}\n\nxtte.timeExpenseSheetItem.budgTotals = function()\n{\n var params = new Object;\n params.prj_id = _project.id();\n params.task_id = _task.id();\n \n var q = toolbox.executeDbQuery("timeexpensesheetitem", "taskbudg",params);\n if (q.first())\n {\n _budget.text = q.value("budget_hours"); \n _actual.text = q.value("actual_hours"); \n _budgetCost.text = q.value("budget_cost"); \n _actualCost.text = q.value("actual_cost"); \n \n }\n else \n xtte.errorCheck(q);\n}\n\n\nxtte.timeExpenseSheetItem.actTotals = function()\n{\n var params = new Object;\n params.task_id = _task.id();\n params.teitem_id = _teitemid;\n\n var expense = 0;\n var hours = 0; \n\n // get the task actuals then add the current\n var q = toolbox.executeDbQuery("timeexpensesheetitem","taskrollup",params);\n\n if (q.first())\n {\n _actual.text = q.value("total_hours");\n _actualCost.text = q.value("total_expense");\n } \n else\n xtte.errorCheck(q);\n}\n\nxtte.timeExpenseSheetItem.empTotals = function()\n{\n if (_populating)\n return;\n\n var params = new Object;\n params.teitem_id = _teitemid;\n params.tehead_id = _headid;\n params.emp_id = _employee.id();\n params.workDate = _workdate.date;\n if (_type.code == 'T')\n params.hours = _hours.toDouble() - 0;\n\n var q = toolbox.executeDbQuery("timeexpensesheetitem", "emptotals", params);\n\n if (q.first())\n {\n _dayHrs.setText(q.value("day_hours"));\n _weekHrs.setText(q.value("sheet_hours"));\n } \n else\n xtte.errorCheck(q);\n}\n\nxtte.timeExpenseSheetItem.prev = function()\n{\n if ( (_modified) && (_mode != xtte.viewMode) )\n {\n if (QMessageBox.question(mywindow,\n qsTr("Unsaved Changed"),\n qsTr("

You have made some changes "\n + "which have not yet been saved!

"\n + "Would you like to save them now?"),\n QMessageBox.Save, QMessageBox.No) == QMessageBox.Save)\n {\n if (!xtte.timeExpenseSheetItem.save())\n return;\n }\n }\n\n var params = new Object;\n if (_teitemid > 0)\n params.teitem_id = _teitemid;\n else\n params.tehead_id = _headid;\n\n var q = toolbox.executeDbQuery("timeexpensesheetitem", "teitemprev", params);\n\n if (q.first())\n {\n _teitemid = q.value("teitem_id");\n _modified = false;\n\n if (_mode == xtte.newMode)\n _mode = xtte.editMode;\n\n _next.enabled = true;\n xtte.timeExpenseSheetItem.populate();\n }\n else\n xtte.errorCheck(q);\n}\n\n\nxtte.timeExpenseSheetItem.next = function()\n{\n if ( (_modified) && (_mode != xtte.viewMode) )\n {\n\n if (QMessageBox.question(mywindow,\n qsTr("Unsaved Changed"),\n qsTr("

You have made some changes "\n + "which have not yet been saved!\\n" \n + "Would you like to save them now?"),\n QMessageBox.Save, QMessageBox.Cancel) != QMessageBox.Save)\n return;\n\n if (!xtte.timeExpenseSheetItem.save())\n return;\n }\n\n if (_last)\n xtte.timeExpenseSheetItem.clear();\n else\n {\n var params = new Object;\n params.teitem_id = _teitemid;\n var q = toolbox.executeDbQuery("timeexpensesheetitem","teitemnext",params);\n\n if (q.first())\n {\n _modified = false;\n _teitemid = q.value("teitem_id");\n _prev.enabled = true;\n xtte.timeExpenseSheetItem.populate();\n }\n else if (xtte.errorCheck(q))\n xtte.timeExpenseSheetItem.clear();\n }\n}\n\nxtte.timeExpenseSheetItem.clear = function()\n{\n var params = new Object();\n params.tehead_id = _headid;\n\n var q = toolbox.executeDbQuery("timeexpensesheet","header",params);\n\n if (q.first())\n {\n _weekending.date = (q.value("tehead_weekending")); \n _sheet.text = (q.value("tehead_number"));\n _sheetnum = (q.value("tehead_number"));\n _employee.setId(q.value("tehead_emp_id"));\n }\n else if (!xtte.errorCheck(q))\n return;\n\n q = toolbox.executeDbQuery("timeexpensesheetitem", "nextlinenum", params);\n if (q.first())\n {\n _linenumber.setText(q.value("linenumber"));\n _linenum = (q.value("linenumber"));\n } \n else \n xtte.errorCheck(q);\n\n _mode = xtte.newMode;\n _teitemid = -1;\n _prev.enabled = true;\n _type.enabled = true;\n _workdate.clear();\n _workdate.enabled = true;\n _workdate.setFocus();\n _hours.text = "0.0";\n _hours.enabled = true;\n _rate.localValue = 0;\n _empcost.enabled = true;\n _empcost.localValue = 0;\n _items.enabled = true;\n _items.setId(-1);\n _employee.enabled = false;\n _clients.enabled = true;\n _po.clear();\n _po.enabled = true;\n _project.enabled = true;\n _task.enabled = true;\n _notes.clear();\n _notes.enabled = true;\n _next.text = qsTr("New");\n _next.enabled = false;\n\n xtte.timeExpenseSheetItem.getPrice();\n\n _modified = false;\n}\n\n\nxtte.timeExpenseSheetItem.setSecurity = function()\n{\n if (privileges.check("CanViewRates"))\n {\n _rate.visible = true;\n _total.visible = true;\n _rateLit.visible = true;\n _totalLit.visible = true;\n }\n else\n {\n _rate.visible = false;\n _total.visible = false;\n _rateLit.visible = false;\n _totalLit.visible = false;\n }\n if ( ( privileges.check("MaintainEmpCostSelf") && xtte.timeExpenseSheetItem.testCurrEmpId()) || privileges.check("MaintainEmpCostAll") ) \n {\n _empcostLit.visible = true;\n _empcost.visible = true;\n _totCostLit.visible = true;\n _totCost.visible = true;\n }\n else\n {\n _empcostLit.visible = false;\n _empcost.visible = false;\n _totCostLit.visible = false;\n _totCost.visible = false;\n }\t\n}\n\nxtte.timeExpenseSheetItem.testCurrEmpId = function()\n{\n var params = new Object;\n params.emp_id = _employee.id();\n var qry = toolbox.executeQuery("SELECT crmacct_emp_id = ::integer AS test "\n + "FROM crmacct "\n + "WHERE crmacct_usr_username = getEffectiveXtUser();", params);\n if (qry.first()) {\n return qry.value("test");\n }\n else \n QMessageBox.information(mywindow, "Database Error", qry.lastError().text);\n return false;\n}\n\n// Initialize default states\n_hours.setValidator(mainwindow.transQtyVal());\n\n_prev.enabled = false;\n_next.enabled = false;\n_task.enabled = false;\n_weekending.enabled = false;\n_linenumber.enabled = true;\n_employee.enabled = false;\n_total.enabled = false;\n_total.readonly = true;\n_rate.enabled = false;\n_billable.visible = true;\n_billable.enabled = false;\n_prepaid.visible = false;\n_next.enabled = false;\n\n_type.append(1, qsTr("Time"), "T");\n_type.append(2, qsTr("Expense"), "E");\n\n//_items.setQuery(xtte.itemSql);\n_items.addExtraClause("(item_type='R') AND "\n + "(item_id IN (SELECT teexp_id FROM te.teexp))");\n\n_project.setAllowedStatuses(0x02); // In process\n\n// Define connections\n_buttonBox.accepted.connect(xtte.timeExpenseSheetItem.accepted);\n_buttonBox.rejected.connect(mydialog, "reject");\n_prev.clicked.connect(xtte.timeExpenseSheetItem.prev);\n_next.clicked.connect(xtte.timeExpenseSheetItem.next);\n\n_task.newID.connect(xtte.timeExpenseSheetItem.taskChanged);\n_rate.valueChanged.connect(xtte.timeExpenseSheetItem.extension);\n_workdate.newDate.connect(xtte.timeExpenseSheetItem.empTotals);\n_hours.textChanged.connect(xtte.timeExpenseSheetItem.extension);\n_empcost.valueChanged.connect(xtte.timeExpenseSheetItem.extension);\n_hours.editingFinished.connect(xtte.timeExpenseSheetItem.actTotals);\n_rate.valueChanged.connect(xtte.timeExpenseSheetItem.actTotals);\n_type.newID.connect(xtte.timeExpenseSheetItem.typeChanged);\n_items["newId(int)"].connect(xtte.timeExpenseSheetItem.getPrice);\n_clients["newId(int)"].connect(xtte.timeExpenseSheetItem.customerChanged);\n_project["newId(int)"].connect(xtte.timeExpenseSheetItem.projectChanged);\n_employee.newId.connect(xtte.timeExpenseSheetItem.modified);\n_po.textChanged.connect(xtte.timeExpenseSheetItem.modified);\n_workdate.newDate.connect(xtte.timeExpenseSheetItem.modified);\n_billable.toggled.connect(xtte.timeExpenseSheetItem.getPrice);\n_prepaid.toggled.connect(xtte.timeExpenseSheetItem.modified);\n_notes.textChanged.connect(xtte.timeExpenseSheetItem.modified);\n\nxtte.timeExpenseSheetItem.getPrice();\n_employee["newId(int)"].connect(xtte.timeExpenseSheetItem.setSecurity);\n 118 tebilling 0 t /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _item\t\t= mywindow.findChild("_item");\n\n_item.populate("select item_id,item_number,item_descrip1,item_listprice from item where item_sold = true and item_active = true and item_type = 'R'");\n\n 107 configureCRM 0 t /*\n This file is part of the xtprjaccnt Package for xTuple ERP,\n and is Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. It\n is licensed to you under the xTuple End-User License Agreement ("the\n EULA"), the full text of which is available at www.xtuple.com/EULA.\n While the EULA gives you access to source code and encourages your\n involvement in the development process, this Package is not free\n software. By using this software, you agree to be bound by the\n terms of the EULA.\n*/\n\ninclude("xtte");\n\nxtte.configureCRM = new Object;\n\nvar _telayout = new QBoxLayout(mywindow);\nvar _tespcr = new QSpacerItem(10, 0, 1, 1 | 4);\nvar _laborAndOverheadLit = toolbox.createWidget("QLabel", mywindow, "_laborAndOverheadLit");\nvar _laborAndOverhead = toolbox.createWidget("GLCluster", mywindow, "_laborAndOverhead");\n_laborAndOverheadLit.text = qsTr("Project Labor And Overhead:");\n_laborAndOverheadLit.buddy= _laborAndOverhead;\n_laborAndOverhead.setType(0x02); // Liability\n\n_telayout.addWidget(_laborAndOverheadLit);\n_telayout.addWidget(_laborAndOverhead);\n_telayout.addItem(_tespcr);\n\nvar _useProjects = mywindow.findChild("_useProjects")\nvar _layout = toolbox.widgetGetLayout(_useProjects);\n_layout.insertLayout(1, _telayout);\n\nxtte.configureCRM.save = function()\n{ \n var id = -1;\n if (_useProjects.checked)\n id = _laborAndOverhead.id() \n \n metrics.set("PrjLaborAndOverhead", id);\n}\n// Initialize\n_laborAndOverhead.setEnabled(_useProjects.checked);\n_laborAndOverhead.setId(metrics.value("PrjLaborAndOverhead"));\n\n// Connections\nmywindow.saving.connect(xtte.configureCRM.save);\n_useProjects["toggled(bool)"].connect(_laborAndOverheadLit, "setEnabled(bool)");\n_useProjects["toggled(bool)"].connect(_laborAndOverhead, "setEnabled(bool)");\n\n 108 customer 0 t /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("xtte");\nxtte.customer = new Object;\n\n\nif (privileges.check("CanViewRates"))\n{\n var _custid = -1;\n var _creditGroup = mywindow.findChild("_creditGroup");\n var _layout = toolbox.widgetGetLayout(_creditGroup);\n var _tecustomer = toolbox.loadUi("tecustomer", mywindow);\n var groupBox_3 = mywindow.findChild("groupBox_3");\n var groupBox_4 = mywindow.findChild("groupBox_4");\n var _creditStatusGroup = mywindow.findChild("_creditStatusGroup");\n\n _layout.addWidget(_tecustomer, 0, 0, 1, 3);\n _layout.addWidget(groupBox_4, 1, 0, 1, 1);\n _layout.addWidget(_creditStatusGroup, 1, 1, 1, 1);\n _layout.addWidget(groupBox_3, 1, 2, 1, 1);\n _layout.addWidget(_creditGroup, 2, 0, 1, 3);\n\n var _number = mywindow.findChild("_number");\n var _blanketPos = mywindow.findChild("_blanketPos");\n var _billingGroup = mywindow.findChild("_billingGroup");\n var _rate = _tecustomer.findChild("_rate");\n var _tecustrateid = -1;\n var _basecurrid = _rate.id();\n\n xtte.customer.modeChanged = function(mode)\n {\n _billingGroup.enabled = (mode == mainwindow.cNew || mode == mainwindow.cEdit);\n }\n\n xtte.customer.save = function()\n {\n\n var params = new Object();\n params.tecustrate_id = _tecustrateid;\n params.cust_id = _custid;\n params.curr_id = _rate.id();\n params.rate = _rate.localValue;\n\n var query = "updtecustrate";\n if (!_billingGroup.checked)\n query = "deltecustrate";\n else if (_tecustrateid == -1)\n query = "instecustrate";\n\n var q = toolbox.executeDbQuery("customer", query, params);\n if (q.first())\n _tecustrateid = q.value("tecustrate_id");\n else\n xtte.errorCheck(q);\n }\n\n xtte.customer.populate = function(custId)\n {\n if (_custid == custId)\n return;\n\n _custid = custId;\n\n var params = new Object();\n params.cust_id = _custid;\n\n var q = toolbox.executeDbQuery("customer", "seltecustrate", params);\n\n if (q.first())\n {\n _billingGroup.checked = true;\n _tecustrateid = q.value("tecustrate_id");\n _rate.setId(q.value("tecustrate_curr_id"));\n _rate.localValue = q.value("tecustrate_rate");\n return;\n }\n else\n xtte.errorCheck(q);\n\n _billingGroup.checked = false;\n _tecustrateid = -1;\n _rate.setId(_basecurrid);\n _rate.localValue = 0;\n }\n\n // Initialize\n QWidget.setTabOrder(_blanketPos, _rate);\n\n mywindow["newId(int)"].connect(xtte.customer.populate);\n mywindow["newMode(int)"].connect(xtte.customer.modeChanged);\n mywindow["saved(int)"].connect(xtte.customer.save);\n\n xtte.customer.populate();\n}\n 110 employee 0 t /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("xtte");\nxtte.employee = new Object;\n\nvar _externalRate = mywindow.findChild("_externalRate"); \nvar _layout = toolbox.widgetGetLayout(_externalRate);\nvar _contractor = toolbox.createWidget("QCheckBox", mywindow, "_contractor");\n_contractor.text = qsTr("Contractor");\n\n_layout.addWidget(_contractor, 1, 4);\n\nvar _teempid = -1; \nvar _empid = -1;\n\nset = function(input)\n{\n if("emp_id" in input)\n {\n _empid = input.emp_id;\n xtte.employee.populate();\n }\n\n if("mode" in input)\n {\n if (input.mode == "view")\n _contractor.enabled = false;\n }\n\n return mainwindow.NoError;\n}\n\nxtte.employee.save = function(empId)\n{\n if (empId <= 0)\n return;\n\n var params = new Object();\n params.teemp_id\t= _teempid;\n params.emp_id\t= empId;\n params.contractor\t= _contractor.checked;\n\n var query = "updteemp";\n if (_teempid == -1)\n query = "insteemp";\n\n var q = toolbox.executeDbQuery("employee", query, params);\n xtte.errorCheck(q);\n}\n\nxtte.employee.populate = function()\n{\n var params = new Object();\n params.emp_id = _empid; \n\n var q = toolbox.executeDbQuery("employee", "selteemp", params);\n\n if (q.first())\n {\n _teempid = q.value("teemp_id");\n _contractor.checked = (q.value("teemp_contractor"));\n }\n else\n xtte.errorCheck(q);\n}\n\nmydialog["finished(int)"].connect(xtte.employee.save);\n\n\n 111 initMenu 0 t /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("xtte");\nxtte.initMenu = new Object;\n\n// Define menu and action variables\nvar crmMenu = mainwindow.findChild("menu.crm.projects");\ncrmMenu.addSeparator();\n\nvar tesheetAction = crmMenu.addAction(qsTr("Worksheets..."), mainwindow);\ntesheetAction.objectName = "pm.teSheets";\ntesheetAction.setData("MaintainTimeExpense");\ntesheetAction.enabled = privileges.value("MaintainTimeExpense");\n\nvar crmRptMenu = mainwindow.findChild("menu.crm.reports");\nvar orderActPrj = mainwindow.findChild("pm.dspOrderActivityByProject");\n\nvar historyAction = new QAction(qsTr("Worksheet History"), mainwindow);\nhistoryAction.objectName = "pm.teHistory";\nhistoryAction.setData("ViewTimeExpenseHistory");\nhistoryAction.enabled = privileges.value("ViewTimeExpenseHistory");\ncrmRptMenu.insertAction(orderActPrj, historyAction);\n\n// Define function(s)\nxtte.initMenu.openSheets = function()\n{\n toolbox.openWindow("timeExpenseSheets");\n}\n\nxtte.initMenu.openHistory = function()\n{\n toolbox.openWindow("dspTimeExpenseHistory");\n}\n\n// Connect Actions\ntesheetAction.triggered.connect(xtte.initMenu.openSheets);\nhistoryAction.triggered.connect(xtte.initMenu.openHistory);\n 112 item 0 t /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("xtte");\nxtte.item = new Object;\n\nvar _tab = mywindow.findChild("_tab"); \nvar _expensePage = toolbox.loadUi("teexpense", mywindow);\n_tab.insertTab(2, _expensePage, "Project");\n\nvar _projectExpense = mywindow.findChild("_projectExpense");\nvar _itemtype = mywindow.findChild("_itemtype");\nvar _close = mywindow.findChild("_close");\nvar _description = mywindow.findChild("_description");\nvar _account = mywindow.findChild("_account");\nvar _expcat = mywindow.findChild("_expcat");\nvar _accountSelected = mywindow.findChild("_accountSelected");\nvar _expcatSelected = mywindow.findChild("_expcatSelected");\nvar _allowExpenseGroup = mywindow.findChild("_allowExpenseGroup");\nvar _inventoryUOM = mywindow.findChild("_inventoryUOM");\nvar _save = mywindow.findChild("_save");\n\nvar _saved = false;\nvar _isnew = true;\n\nxtte.item.clickswitch = function()\n{\n if(_accountSelected.checked)\n {\n _account.enabled = true;\n _expcat.enabled = false;\n _expcat.setId(-1);\n }\n else\n {\n _account.enabled = false;\n _expcat.enabled = true;\n _account.setId(-1);\n }\n}\n\nxtte.item.save = function(id)\n{\n var params = new Object;\n params.item_id = id;\n params.expcat_id = _expcat.id();\n params.accnt_id = _account.id();\n\n var query = "updteexp";\n if (!_projectExpense.checked)\n query = "delteexp";\n else if (_isnew)\n query = "insteexp";\n\n var q = toolbox.executeDbQuery("item", query, params);\n xtte.errorCheck(q);\n}\n\nxtte.item.populate = function(itemId)\n{\n var params = new Object;\n params.item_id = itemId;\n\n var q = toolbox.executeDbQuery("item", "selteexp", params);\n\n if (q.first())\n {\n _projectExpense.checked = true;\n _expcat.setId(q.value("teexp_expcat_id"));\n _account.setId(q.value("teexp_accnt_id"));\n\n if(_account.id() > 0)\n _accountSelected.checked = true;\n else\n _expcatSelected.checked = true;\n\n _isnew = false;\n }\n else if (!xtte.errorCheck(q))\n return\n else\n {\n _projectExpense.checked = false;\n _isnew = true;\n }\n\n xtte.item.handleExpense();\n}\n\nxtte.item.handleExpense = function()\n{\n _tab.setTabEnabled(_tab.indexOf(_expensePage), _itemtype.currentIndex == 3);\n}\n\nxtte.item.checkSave = function()\n{\n if (_projectExpense.checked == true &&\n !_expcat.isValid() && \n !_account.isValid())\n {\n QMessageBox.critical(mywindow,\n qsTr("Can not save item"),\n qsTr("You must select a Ledger Account or an expense account for Project Expense Items."));\n }\n else\n mywindow.sSave();\n}\n\n// Initialize\n_expcat.enabled = false;\n_account.setType(0x01 | 0x02 | 0x04); // Asset, Liability, Expense\n\n// Connections\ntoolbox.coreDisconnect(_save, "clicked()", mywindow, "sSave()"); \n_save.clicked.connect(xtte.item.checkSave);\nmywindow["saved(int)"].connect(xtte.item.save);\nmywindow["newId(int)"].connect(xtte.item.populate);\n_accountSelected.toggled.connect(xtte.item.clickswitch);\n_expcatSelected.toggled.connect(xtte.item.clickswitch);\n_itemtype['currentIndexChanged(QString)'].connect(xtte.item.handleExpense);\n_inventoryUOM.newID.connect(xtte.item.handleExpense);\n\n 117 task 0 t /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("xtte");\nxtte.task = new Object;\n\nvar _tab = mywindow.findChild("_tab"); \nvar _tebilling = toolbox.loadUi("tebilling", mywindow);\n_tab.insertTab(2, _tebilling, qsTr("Billing"));\n_tab.setEnabled(2, privileges.check("CanViewRates"));\n\nvar _number = mywindow.findChild("_number");\nvar _actualHours = mywindow.findChild("_actualHours");\nvar _actualExp = mywindow.findChild("_actualExp");\nvar _billingGroup = _tebilling.findChild("_billingGroup");\nvar _itemGroup = _tebilling.findChild("_itemGroup");\nvar _cust = _tebilling.findChild("_cust");\nvar _rate = _tebilling.findChild("_rate");\nvar _item = _tebilling.findChild("_item");\nvar _useItem = _tebilling.findChild("_useItem");\nvar _teprjtaskid = -1; \nvar _prjtaskid = -1;\n\nset = function(input)\n{\n if("prjtask_id" in input)\n {\n _prjtaskid = input.prjtask_id;\n xtte.task.populate();\n }\n\n if("cust_id" in input)\n {\n _cust.setId(input.cust_id);\n _cust.enabled = false;\n }\n\n if("mode" in input)\n {\n if (input.mode == "view")\n {\n _cust.enabled = false;\n _billingGroup.enabled = false;\n _itemGroup.enabled = false;\n }\n }\n\n return mainwindow.NoError;\n}\n\nxtte.task.save = function(prjtaskId)\n{\n if (prjtaskId <= 0)\n return;\n\n var params = new Object();\n params.teprjtask_id\t= _teprjtaskid;\n params.prjtask_id\t= prjtaskId;\n if (_cust.isValid())\n params.cust_id \t= _cust.id();\n if (_billingGroup.checked)\n {\n params.rate\t= _rate.localValue;\n params.curr_id\t= _rate.id();\n }\n if (_useItem.checked && _item.isValid())\n params.item_id\t= _item.id()\n\n var query = "updteprjtask";\n if (_teprjtaskid == -1)\n query = "insteprjtask";\n\n var q = toolbox.executeDbQuery("task", query, params);\n xtte.errorCheck(q);\n}\n\nxtte.task.populate = function()\n{\n var params = new Object();\n params.prjtask_id = _prjtaskid; \n\n var q = toolbox.executeDbQuery("task", "selteprjtask", params);\n\n if (q.first())\n {\n _teprjtaskid = q.value("teprjtask_id");\n\n if (!_cust.isValid())\n _cust.setId(q.value("cust_id"));\n\n if (q.value("curr_id") == -1)\n _billingGroup.checked = false;\n else\n {\n _billingGroup.checked = true;\n _rate.setId(q.value("curr_id"));\n _rate.localValue = q.value("teprjtask_rate");\n }\n\n if (q.value("item_id") == -1)\n _useItem.checked = false;\n else\n {\n _useItem.checked = true;\n _item.setId(q.value("item_id"));\n }\n }\n else\n xtte.errorCheck(q);\n}\n\n// Initialize\n_item.setQuery(xtte.itemSql);\n_useItem.checked = false;\n\n// Connections\nmydialog["finished(int)"].connect(xtte.task.save);\n\n 121 timeExpenseSheets 0 t /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\ndebugger;\n\ninclude("xtte");\n\n// Define Variables\nxtte.timeExpenseSheets = new Object;\n\nvar _all = mywindow.findChild("_all");\nvar _close = mywindow.findChild("_close");\nvar _query = mywindow.findChild("_query");\nvar _new = mywindow.findChild("_new");\nvar _print = mywindow.findChild("_print");\nvar _sheets = mywindow.findChild("_sheets");\nvar _selected = mywindow.findChild("_selected");\nvar _approve = mywindow.findChild("_approve");\nvar _process = mywindow.findChild("_process");\nvar _weekending = mywindow.findChild("_weekending");\nvar _showAllEmployees = mywindow.findChild("_showAllEmployees");\nvar _showDirectReports = mywindow.findChild("_showDirectReports");\nvar _employee = mywindow.findChild("_employee");\nvar _manager = mywindow.findChild("_manager");\nvar _selected = mywindow.findChild("_selected");\nvar _open = mywindow.findChild("_open");\nvar _approved = mywindow.findChild("_approved");\nvar _closed = mywindow.findChild("_closed");\nvar _invoice = mywindow.findChild("_invoice");\nvar _voucher = mywindow.findChild("_voucher");\nvar _post = mywindow.findChild("_post");\n\n// Set up columns\n_sheets.addColumn(qsTr("Sheet#"), XTreeWidget.orderColumn, Qt.AlignLeft, true, "tehead_number");\n_sheets.addColumn(qsTr("Date"), XTreeWidget.dateColumn, Qt.AlignLeft, true, "tehead_weekending");\n_sheets.addColumn(qsTr("Employee"), -1, Qt.AlignLeft, true, "emp_code");\n_sheets.addColumn(qsTr("Status"), XTreeWidget.bigMoneyColumn, Qt.AlignCenter, true, "tehead_status");\nif (privileges.check("CanViewRates")) {\n _sheets.addColumn(qsTr("To Invoice"), XTreeWidget.bigMoneyColumn, Qt.AlignLeft, true, "total_i");\n _sheets.addColumn(qsTr("To Voucher"), XTreeWidget.bigMoneyColumn, Qt.AlignLeft, true, "total_e");\n}\n_sheets.addColumn(qsTr("Invoiced"), XTreeWidget.dateColumn, Qt.AlignLeft, true, "invoiced");\n_sheets.addColumn(qsTr("Vouchered"),XTreeWidget.dateColumn, Qt.AlignLeft, true, "vouchered");\n_sheets.addColumn(qsTr("Posted"), XTreeWidget.dateColumn, Qt.AlignLeft, true, "posted");\n\nxtte.timeExpenseSheets.populateMenu = function(pMenu, pItem, pCol)\n{\n var tmpact;\n\n if(pMenu == null)\n pMenu = _sheets.findChild("_menu");\n\n if(pMenu != null)\n {\n var currentItem = _sheets.currentItem();\n var selected = _sheets.selectedItems();\n\n if (currentItem != null)\n {\n if (selected.length == 1) // Can only handle editing for a single select\n {\n var status = currentItem.rawValue("tehead_status");\n\n tmpact = pMenu.addAction(qsTr("Print"));\n tmpact.triggered.connect(xtte.timeExpenseSheets.printSheet);\n\n pMenu.addSeparator();\n\n tmpact = pMenu.addAction(qsTr("Edit..."));\n tmpact.triggered.connect(xtte.timeExpenseSheets.editSheet);\n tmpact.enabled = (status == 'O' && privileges.check("MaintainTimeExpense"));\n \n tmpact = pMenu.addAction(qsTr("View..."));\n tmpact.triggered.connect(xtte.timeExpenseSheets.viewSheet);\n \n tmpact = pMenu.addAction(qsTr("Delete"));\n tmpact.triggered.connect(xtte.timeExpenseSheets.deleteSheet);\n tmpact.enabled = (status == 'O' && privileges.check("MaintainTimeExpense"));\n }\n\n if (xtte.timeExpenseSheets.canApprove(selected))\n {\n pMenu.addSeparator();\n tmpact = pMenu.addAction(qsTr("Approve"));\n tmpact.enabled = privileges.check("CanApprove");\n tmpact.triggered.connect(xtte.timeExpenseSheets.approveSheets);\n }\n else if (xtte.timeExpenseSheets.canUnapprove(selected))\n {\n pMenu.addSeparator();\n tmpact = pMenu.addAction(qsTr("Unapprove"));\n tmpact.enabled = privileges.check("CanApprove");\n tmpact.triggered.connect(xtte.timeExpenseSheets.unapproveSheets);\n }\n\n if (status == 'A' || status == 'O')\n {\n tmpact = pMenu.addAction(qsTr("Close"));\n tmpact.enabled = privileges.check("MaintainTimeExpense");\n tmpact.triggered.connect(xtte.timeExpenseSheets.closeSheet);\n }\n\n if (status == 'C')\n {\n tmpact = pMenu.addAction(qsTr("Reopen"));\n tmpact.enabled = privileges.check("ReopenTimeExpense");\n tmpact.triggered.connect(xtte.timeExpenseSheets.reopenSheet);\n }\n\n if ((xtte.timeExpenseSheets.canProcess("invoiced", selected)) ||\n (xtte.timeExpenseSheets.canProcess("vouchered", selected)) ||\n (xtte.timeExpenseSheets.canProcess("posted", selected)))\n pMenu.addSeparator();\n\n if (xtte.timeExpenseSheets.canProcess("invoiced", selected))\n {\n tmpact = pMenu.addAction(qsTr("Invoice"));\n tmpact.triggered.connect(xtte.timeExpenseSheets.invoiceSheets);\n tmpact.enabled = privileges.check("allowInvoicing");\n }\n\n if (xtte.timeExpenseSheets.canProcess("vouchered", selected))\n {\n tmpact = pMenu.addAction(qsTr("Voucher"));\n tmpact.triggered.connect(xtte.timeExpenseSheets.voucherSheets);\n tmpact.enabled = privileges.check("allowVouchering");\n }\n\n if (xtte.timeExpenseSheets.canProcess("posted", selected))\n {\n tmpact = pMenu.addAction(qsTr("Post Time"));\n tmpact.triggered.connect(xtte.timeExpenseSheets.postSheets);\n tmpact.enabled = privileges.check("PostTimeSheets");\n }\n }\n }\n}\n\nxtte.timeExpenseSheets.canApprove = function(selected)\n{\n for (var i = 0; i < selected.length; i++)\n {\n if (selected[i].rawValue("tehead_status") != 'O')\n return false;\n }\n return true;\n}\n\nxtte.timeExpenseSheets.canUnapprove = function(selected)\n{\n for (var i = 0; i < selected.length; i++)\n {\n if ((selected[i].rawValue("tehead_status") != 'A') ||\n (selected[i].rawValue("posted") > 0) ||\n (selected[i].rawValue("vouchered") > 0) ||\n (selected[i].rawValue("invoiced") > 0))\n return false;\n }\n return true;\n}\n\nxtte.timeExpenseSheets.canProcess = function(process, selected)\n{\n for (var i = 0; i < selected.length; i++)\n {\n if ((selected[i].rawValue("tehead_status") != 'A') ||\n (selected[i].rawValue(process) != 0))\n return false;\n }\n return true;\n}\n\nxtte.timeExpenseSheets.approve = function()\n{\n toolbox.executeBegin();\n for (var i = 0; i < _sheets.topLevelItemCount; i++)\n {\n var item = _sheets.topLevelItem(i);\n if (item.rawValue("tehead_status") == "O")\n {\n var params = new Object();\n params.tehead_id = item.id(); \n \n q = toolbox.executeDbQuery("timeexpensesheets", "approve", params );\n if (!xtte.errorCheck(q))\n {\n toolbox.executeRollback();\n return;\n }\n } \n }\n toolbox.executeCommit();\n xtte.timeExpenseSheets.fillList();\n}\n\nxtte.timeExpenseSheets.approveSheets = function()\n{\n toolbox.executeBegin();\n var selected = _sheets.selectedItems();\n for (var i = 0; i < selected.length; i++)\n {\n var params = new Object();\n params.tehead_id = selected[i].id(); \n\n q = toolbox.executeDbQuery("timeexpensesheets", "approve", params ); \n if (!xtte.errorCheck(q))\n {\n toolbox.executeRollback();\n return;\n }\n }\n toolbox.executeCommit();\n xtte.timeExpenseSheets.fillList(); \n}\n\nxtte.timeExpenseSheets.unapproveSheets = function()\n{\n toolbox.executeBegin();\n var selected = _sheets.selectedItems();\n for (var i = 0; i < selected.length; i++)\n {\n var params = new Object();\n params.tehead_id = selected[i].id(); \n\n q = toolbox.executeDbQuery("timeexpensesheets", "unapprove", params ); \n if (!xtte.errorCheck(q))\n {\n toolbox.executeRollback();\n return;\n }\n }\n toolbox.executeCommit();\n xtte.timeExpenseSheets.fillList(); \n}\n\n\nxtte.timeExpenseSheets.invoiceSheets = function()\n{\n xtte.timeExpenseSheets.processSheets(_sheets.selectedItems(), true, false, false);\n} \n\nxtte.timeExpenseSheets.voucherSheets = function()\n{\n xtte.timeExpenseSheets.processSheets(_sheets.selectedItems(), false, true, false);\n}\n\nxtte.timeExpenseSheets.postSheets = function()\n{ \n xtte.timeExpenseSheets.processSheets(_sheets.selectedItems(), false, false, true);\n}\n\nxtte.timeExpenseSheets.process = function()\n{\n toolbox.executeBegin();\n\n // First loop through and invoice\n if (_invoice.checked)\n {\n var ids = [];\n for (var i = 0; i < _sheets.topLevelItemCount; i++)\n {\n var item = _sheets.topLevelItem(i);\n if ((item.rawValue("tehead_status") == 'A') &&\n (item.rawValue("invoiced") == 0)) \n ids[i] = item.id();\n }\n\n if (ids.length)\n {\n var params = new Object();\n params.tehead_ids = ids; \n\n q = toolbox.executeDbQuery("timeexpensesheets", "invoice", params ); \n if (!xtte.errorCheck(q))\n {\n toolbox.executeRollback();\n return;\n }\n }\n }\n\n // Now loop through and do the others\n for (var i = 0; i < _sheets.topLevelItemCount; i++)\n {\n var item = _sheets.topLevelItem(i);\n var params = new Object();\n params.tehead_id = item.id(); \n\n if ((_voucher.checked) && \n (item.rawValue("tehead_status") == 'A') &&\n (item.rawValue("vouchered") == 0))\n {\n q = toolbox.executeDbQuery("timeexpensesheets", "voucher", params ); \n if (!xtte.errorCheck(q))\n {\n toolbox.executeRollback();\n return;\n }\n }\n\n if ((_post.checked) && \n (item.rawValue("tehead_status") == 'A') &&\n (item.rawValue("posted") == 0))\n {\n if (metrics.value("PrjLaborAndOverhead") - 0 <= 0)\n {\n QMessageBox.critical(mywindow, qsTr("Setup Error"),\n qsTr("No Labor and Overhead Account defined in CRM Setup."));\n {\n toolbox.executeRollback();\n return;\n }\n }\n\n params.phrase1 = qsTr("Post Time Sheet for ");\n params.phrase2 = qsTr(" to Project");\n\n q = toolbox.executeDbQuery("timeexpensesheets", "post", params ); \n if (!xtte.errorCheck(q))\n {\n toolbox.executeRollback();\n return;\n }\n } \n }\n\n toolbox.executeCommit();\n\n if (_invoice.checked)\n mainwindow.invoicesUpdated(1, true);\n\n if (_voucher.checked)\n mainwindow.vouchersUpdated();\n\n if (_post.checked)\n mainwindow.glSeriesUpdated();\n\n xtte.timeExpenseSheets.fillList();\n}\n\nxtte.timeExpenseSheets.processSheets = function(selected, invoice, voucher, post)\n{\n toolbox.executeBegin();\n if (invoice)\n { \n // Prompt for invoice date\n var invcdate = mainwindow.dbDate();\n var params = new Object();\n params.label = "Invoice Date";\n var newdlg = toolbox.openWindow("XDateInputDialog", mywindow, Qt.ApplicationModal, Qt.Dialog);\n toolbox.lastWindow().set(params);\n var returnval = newdlg.exec();\n if (returnval == 1)\n {\n var invcdate = newdlg.getDate();\n }\n\n // Create an array so invoices can be consolidated\n var ids = [];\n for (var i = 0; i < selected.length; i++)\n ids[i] = selected[i].id();\n \n var params = new Object();\n params.tehead_ids = ids;\n params.invchead_invcdate = invcdate;\n\n q = toolbox.executeDbQuery("timeexpensesheets", "invoice", params ); \n if (!xtte.errorCheck(q))\n {\n toolbox.executeRollback();\n return false;\n }\n }\n\n for (var i = 0; i < selected.length; i++)\n {\n var params = new Object();\n params.tehead_id = selected[i].id(); \n\n if (voucher)\n {\n q = toolbox.executeDbQuery("timeexpensesheets", "voucher", params ); \n if (!xtte.errorCheck(q))\n {\n toolbox.executeRollback();\n return false;\n }\n }\n\n if (post)\n {\n if (metrics.value("PrjLaborAndOverhead") - 0 <= 0)\n {\n QMessageBox.critical(mywindow, qsTr("Setup Error"),\n qsTr("No Labor and Overhead Account defined in CRM Setup."));\n {\n toolbox.executeRollback();\n return false;\n }\n }\n\n params.phrase1 = qsTr("Post Time Sheet for ");\n params.phrase2 = qsTr(" to Project");\n\n q = toolbox.executeDbQuery("timeexpensesheets", "post", params ); \n if (!xtte.errorCheck(q))\n {\n toolbox.executeRollback(); \n return false;\n }\n }\n }\n \n toolbox.executeCommit();\n\n if (invoice)\n mainwindow.invoicesUpdated(1, true);\n\n if (voucher)\n mainwindow.vouchersUpdated();\n\n if (post)\n mainwindow.glSeriesUpdated();\n\n xtte.timeExpenseSheets.fillList(); \n \n return true;\n}\n\nxtte.timeExpenseSheets.deleteSheet = function()\n{\n var msg = qsTr("This action can not be undone. Are you sure you want to delete this Worksheet?");\n if (QMessageBox.question( mywindow, mywindow.windowTitle, msg, \n QMessageBox.Yes | QMessageBox.Escape, QMessageBox.No | QMessageBox.Default) == QMessageBox.Yes)\n {\n var params = new Object();\n params.tehead_id = _sheets.id(); \n\n toolbox.executeDbQuery("timeexpensesheet", "deltehead", params );\n\n xtte.timeExpenseSheets.fillList();\n }\n}\n\nxtte.timeExpenseSheets.closeSheet = function()\n{\n var msg = qsTr("Are you sure you want to close this Worksheet?");\n if (QMessageBox.question( mywindow, mywindow.windowTitle, msg, \n QMessageBox.Yes | QMessageBox.Escape, QMessageBox.No | QMessageBox.Default) == QMessageBox.Yes)\n {\n var params = new Object();\n params.tehead_id = _sheets.id(); \n\n q = toolbox.executeDbQuery("timeexpensesheets", "close", params ); \n if (xtte.errorCheck(q))\n xtte.timeExpenseSheets.fillList(); \n }\n}\n\nxtte.timeExpenseSheets.reopenSheet = function()\n{\n var msg = qsTr("Are you sure you want to reopen this Worksheet?");\n if (QMessageBox.question( mywindow, mywindow.windowTitle, msg, \n QMessageBox.Yes | QMessageBox.Escape, QMessageBox.No | QMessageBox.Default) == QMessageBox.Yes)\n {\n var params = new Object();\n params.tehead_id = _sheets.id(); \n\n q = toolbox.executeDbQuery("timeexpensesheets", "reopen", params ); \n if (xtte.errorCheck(q))\n xtte.timeExpenseSheets.fillList(); \n }\n}\n\nxtte.timeExpenseSheets.editSheet = function()\n{\n if (_sheets.currentItem().rawValue("tehead_status") == 'O')\n xtte.timeExpenseSheets.openSheet(xtte.editMode);\n else\n xtte.timeExpenseSheets.openSheet(xtte.viewMode);\n}\n\nxtte.timeExpenseSheets.newSheet = function()\n{\n xtte.timeExpenseSheets.openSheet(xtte.newMode);\n}\n\nxtte.timeExpenseSheets.viewSheet = function()\n{\n xtte.timeExpenseSheets.openSheet(xtte.viewMode);\n}\n\nxtte.timeExpenseSheets.openSheet = function(mode)\n{\n var params = new Object();\n params.mode = mode;\n if (mode) // Not new\n params.tehead_id = _sheets.id();\n else // New\n {\n if (_selected)\n params.emp_id = _employee.id();\n }\n\n var te = toolbox.openWindow("timeExpenseSheet", mywindow, Qt.ApplicationModal);\n toolbox.lastWindow().set(params);\n te.exec();\n xtte.timeExpenseSheets.fillList();\n}\n\nxtte.timeExpenseSheets.getParams = function()\n{\n params = new Object();\n\n if (!_open.checked &&\n !_approved.checked &&\n !_closed.checked)\n {\n params.statusList = "";\n return params;\n }\n\n params.startDate = _weekending.startDate;\n params.endDate = _weekending.endDate;\n if (_selected.checked)\n params.emp_id = _employee.id();\n if (_showDirectReports.checked)\n params.mgr_emp_id = _manager.id();\n\n var statusList = [];\n var num = 0;\n \n if (_open.checked)\n {\n statusList[num] = "'O'";\n num = num + 1;\n }\n if (_approved.checked)\n {\n statusList[num] = "'A'";\n num = num + 1;\n }\n if (_closed.checked)\n statusList[num] = "'C'";\n \n params.statusList = statusList.toString();\n params.approved = qsTr("Approved");\n params.closed = qsTr("Closed");\n params.open = qsTr("Open");\n params.yes = qsTr("Yes");\n params.no = qsTr("No");\n params.na = qsTr("N/A");\n\n return params;\n}\n\n\nxtte.timeExpenseSheets.fillList = function()\n{ \n var params = xtte.timeExpenseSheets.getParams();\n if (!params.statusList.length)\n return;\n\n q = toolbox.executeDbQuery("timeexpensesheets","detail", params);\n\n _sheets.populate(q);\n if (!xtte.errorCheck(q))\n return;\n}\n\nxtte.timeExpenseSheets.printSheet = function()\n{\n params = xtte.timeExpenseSheets.getParams();\n params.tehead_id = _sheets.id();\n toolbox.printReport("TimeExpenseSheet",params);\n}\n\nxtte.timeExpenseSheets.printReport = function()\n{\n var params = xtte.timeExpenseSheets.getParams();\n params.includeFormatted = true;\n\n toolbox.printReport("TimeExpenseSheets",params);\n}\n\nxtte.timeExpenseSheets.populateEmployees = function()\n{\n // getEffectiveXtUser and crmacct_emp_id were created in the same release\n var q = toolbox.executeQuery("SELECT crmacct_emp_id AS emp_id"\n + " FROM crmacct "\n + " WHERE crmacct_usr_username = getEffectiveXtUser();");\n // if they don't exist, try the older relationship maintained in the emp table\n if (q.lastError().type != QSqlError.NoError)\n q = toolbox.executeQuery("SELECT emp_id "\n + " FROM emp "\n + " WHERE emp_username = CURRENT_USER;");\n\n if (q.first())\n {\n _employee.setId(q.value("emp_id"));\n _manager.setId(q.value("emp_id"));\n }\n\n if (privileges.check("MaintainTimeExpenseOthers"))\n {\n _showAllEmployees.visible = true;\n _showDirectReports.visible = true;\n _manager.visible = true;\n }\n else\n {\n _showAllEmployees.visible = false;\n _showDirectReports.visible = false;\n _manager.visible = false;\n _employee.enabled = false;\n if (privileges.check("MaintainTimeExpenseSelf"))\n {\n if (_employee.id() == -1)\n QMessageBox.critical(mywindow, mywindow.windowTitle, \n qsTr("It appears that your current user isn't an active employee.") ); \n }\n else\n {\n QMessageBox.critical(mywindow, qsTr("Permissions Error"),\n qsTr("You do not have permissions to maintain Worksheet entries"));\n if (mywindow.windowModality)\n mydialog.reject();\n else\n mywindow.close();\n }\n }\n}\n\n// Initialize\n_weekending.setStartNull(qsTr("Earliest"), startOfTime, true);\n_weekending.setEndNull(qsTr("Latest"), endOfTime, true);\n\n_approve.enabled = privileges.check("CanApprove");\n_selected.checked = true;\n_showAllEmployees.visible = false;\n_showDirectReports.visible = false;\n_manager.visible = false;\n//_manager.enabled = false;\n\nif (!privileges.check("allowInvoicing"))\n{\n _invoice.forgetful = true;\n _invoice.checked = false;\n _invoice.enabled = false;\n}\n\nif (!privileges.check("allowVouchering"))\n{\n _voucher.forgetful = true;\n _voucher.checked = false;\n _voucher.enabled = false;\n}\n\nif (!privileges.check("PostTimeSheets"))\n{\n _post.forgetful = true;\n _post.checked = false;\n _post.enabled = false;\n}\n\n// Make connections\n_new.triggered.connect(xtte.timeExpenseSheets.newSheet);\n_close.triggered.connect(mywindow, "close");\n_approve.triggered.connect(xtte.timeExpenseSheets.approve);\n_process.triggered.connect(xtte.timeExpenseSheets.process);\n_print.triggered.connect(xtte.timeExpenseSheets.printReport);\n_query.triggered.connect(xtte.timeExpenseSheets.fillList);\n\n_selected["toggled(bool)"].connect(_employee["setEnabled(bool)"]);\n_employee["newId(int)"].connect(xtte.timeExpenseSheets.fillList);\n\n_showDirectReports["toggled(bool)"].connect(_manager["setEnabled(bool)"]);\n_manager["newId(int)"].connect(xtte.timeExpenseSheets.fillList);\n\nmainwindow.invoicesUpdated.connect(xtte.timeExpenseSheets.fillList);\nmainwindow.vouchersUpdated.connect(xtte.timeExpenseSheets.fillList);\n\n_sheets["populateMenu(QMenu *, XTreeWidgetItem *, int)"].connect(xtte.timeExpenseSheets.populateMenu);\nif (privileges.check("MaintainTimeExpense"))\n _sheets.itemSelected.connect(xtte.timeExpenseSheets.editSheet);\nelse\n{\n _new.enabled = false;\n _sheets.itemSelected.connect(xtte.timeExpenseSheets.viewSheet);\n}\n\nxtte.timeExpenseSheets.populateEmployees();\n 122 xtte 0 t /*\n * This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar xtte;\nif (!xtte)\n xtte = new Object;\n\nxtte.itemSql = "SELECT item_id,item_number,item_descrip1,item_descrip2, "\n + " item_type,item_config,item_upccode, item_active,uom_name "\n + "FROM item JOIN uom ON (uom_id=item_inv_uom_id) "\n + " JOIN te.teexp ON (teexp_id=item_id) "\n + "WHERE item_type='R' "\n\nxtte.newMode \t= 0;\nxtte.editMode\t= 1;\nxtte.viewMode\t= 2;\n\nxtte.errorCheck = function (q)\n{\n if (q.lastError().type != QSqlError.NoError)\n {\n QMessageBox.critical(mywindow,\n qsTr("Database Error"), q.lastError().text);\n return false;\n }\n\n return true;\n}\n \. -- -- Data for Name: pkguiform; Type: TABLE DATA; Schema: te; Owner: admin -- COPY pkguiform (uiform_id, uiform_name, uiform_order, uiform_enabled, uiform_source, uiform_notes) FROM stdin; 50 dspTimeExpenseHistory 0 t \n\n This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL. By using this software, you agree\nto be bound by its terms.\n dspTimeExpenseHistory\n \n \n \n 0\n 0\n 800\n 600\n \n \n \n Worksheet History\n \n \n \n \n \n \n \n \n \n \n Close\n \n \n \n \n \n \n Query\n \n \n \n \n \n \n Print\n \n \n \n \n \n \n Qt::Vertical\n \n \n \n 20\n 0\n \n \n \n \n \n \n \n \n \n \n 0\n 1\n \n \n \n QFrame::NoFrame\n \n \n QFrame::Raised\n \n \n \n 0\n \n \n \n \n Worksheet Items\n \n \n \n \n \n \n false\n \n \n \n \n \n \n \n \n \n \n ParameterWidget\n QWidget\n

parameterwidget.h
\n \n \n XTreeWidget\n QTreeWidget\n
xtreewidget.h
\n 1\n
\n \n \n \n\n 52 tebilling 0 t \n\n This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL. By using this software, you agree\nto be bound by its terms.\n tebilling\n \n \n \n 0\n 0\n 396\n 334\n \n \n \n Billing\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n false\n \n \n Qt::Horizontal\n \n \n \n \n \n \n \n \n \n \n 0\n 1\n \n \n \n Use specified billing rate\n \n \n true\n \n \n false\n \n \n \n \n \n Rate:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 112\n 20\n \n \n \n \n \n \n \n \n \n \n 0\n \n \n \n \n \n \n Qt::Horizontal\n \n \n QSizePolicy::Fixed\n \n \n \n 12\n 10\n \n \n \n \n \n \n \n Qt::StrongFocus\n \n \n Use Specified item\n \n \n true\n \n \n \n \n \n \n \n \n \n 0\n 130\n \n \n \n \n \n \n false\n \n \n false\n \n \n \n \n \n true\n \n \n true\n \n \n \n \n \n \n \n \n \n \n \n \n \n Qt::Vertical\n \n \n \n 20\n 0\n \n \n \n \n \n \n \n \n \n qPixmapFromMimeSource\n \n \n CurrCluster\n CurrDisplay\n
currcluster.h
\n
\n \n CurrDisplay\n QWidget\n
currcluster.h
\n
\n \n CustCluster\n QWidget\n
custcluster.h
\n
\n \n ItemCluster\n QWidget\n
itemcluster.h
\n 1\n
\n
\n \n _rate\n \n \n \n \n _billingGroup\n toggled(bool)\n _rate\n setCurrencyEnabled(bool)\n \n \n 210\n 133\n \n \n 167\n 142\n \n \n \n \n _useItem\n toggled(bool)\n _item\n setEnabled(bool)\n \n \n 200\n 189\n \n \n 196\n 250\n \n \n \n \n
\n 54 teexpense 0 t \n\n This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL. By using this software, you agree\nto be bound by its terms.\n teexpense\n \n \n \n 0\n 0\n 373\n 161\n \n \n \n \n 0\n 0\n \n \n \n \n 0\n 0\n \n \n \n Expense Item Setup\n \n \n \n \n \n 4\n \n \n \n \n \n \n Qt::Horizontal\n \n \n QSizePolicy::Fixed\n \n \n \n 10\n 20\n \n \n \n \n \n \n \n Allow use as Expense Item on Projects\n \n \n false\n \n \n \n \n \n \n \n \n false\n \n \n \n \n \n false\n \n \n \n \n \n \n \n \n \n Account\n \n \n true\n \n \n \n \n \n \n Expense Category\n \n \n \n \n \n \n \n \n \n 0\n 0\n \n \n \n \n \n \n \n \n \n \n 0\n 0\n \n \n \n Qt::StrongFocus\n \n \n \n \n \n false\n \n \n Qt::Horizontal\n \n \n false\n \n \n true\n \n \n \n \n \n \n \n \n Qt::Vertical\n \n \n \n 20\n 0\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n qPixmapFromMimeSource\n \n \n ExpenseCluster\n QWidget\n
expensecluster.h
\n
\n \n GLCluster\n QWidget\n
glcluster.h
\n
\n
\n \n _accountSelected\n _account\n _expcatSelected\n \n \n \n \n _accountSelected\n toggled(bool)\n _account\n setEnabled(bool)\n \n \n 75\n 64\n \n \n 283\n 68\n \n \n \n \n _expcatSelected\n toggled(bool)\n _expcat\n setEnabled(bool)\n \n \n 130\n 126\n \n \n 448\n 140\n \n \n \n \n _projectExpense\n toggled(bool)\n _allowExpenseGroup\n setEnabled(bool)\n \n \n 196\n 25\n \n \n 186\n 96\n \n \n \n \n
\n 55 timeExpenseSheet 0 t \n\n This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL. By using this software, you agree\nto be bound by its terms.\n timeExpenseSheet\n \n \n \n 0\n 0\n 800\n 600\n \n \n \n \n 775\n 400\n \n \n \n Worksheet\n \n \n \n \n \n 12\n \n \n \n \n Sheet #:\n \n \n \n \n \n \n ...\n \n \n \n \n \n \n Qt::Horizontal\n \n \n QSizePolicy::Expanding\n \n \n \n 0\n 20\n \n \n \n \n \n \n \n QDialogButtonBox::Cancel|QDialogButtonBox::Save\n \n \n \n \n \n \n \n \n true\n \n \n 0\n \n \n \n S&heet\n \n \n \n \n \n \n \n Week of Date:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n true\n \n \n \n 0\n 0\n \n \n \n Qt::StrongFocus\n \n \n XDateEdit::None\n \n \n \n \n \n \n Site:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n 3\n \n \n \n \n \n \n \n 0\n 0\n \n \n \n \n 200\n 16777215\n \n \n \n \n \n \n \n Employee:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n 3\n \n \n \n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 0\n 20\n \n \n \n \n \n \n \n \n \n Qt::StrongFocus\n \n \n false\n \n \n true\n \n \n \n \n \n \n \n \n false\n \n \n &New\n \n \n \n \n \n \n false\n \n \n &Edit\n \n \n true\n \n \n \n \n \n \n false\n \n \n &View\n \n \n true\n \n \n \n \n \n \n false\n \n \n &Delete\n \n \n true\n \n \n \n \n \n \n Qt::Vertical\n \n \n QSizePolicy::Expanding\n \n \n \n 20\n 20\n \n \n \n \n \n \n \n \n \n \n Notes\n \n \n \n \n \n Qt::ClickFocus\n \n \n \n \n \n \n \n Documents\n \n \n \n \n \n Documents::TimeExpense\n \n \n \n \n \n \n \n \n \n \n Print on Save\n \n \n \n \n \n \n qPixmapFromMimeSource\n \n \n DLineEdit\n QWidget\n
datecluster.h
\n 1\n
\n \n Documents\n QWidget\n
documents.h
\n
\n \n EmpCluster\n QWidget\n
empcluster.h
\n
\n \n WComboBox\n XComboBox\n
wcombobox.h
\n
\n \n XCheckBox\n QCheckBox\n
xcheckbox.h
\n
\n \n XComboBox\n QComboBox\n
xcombobox.h
\n
\n \n XTreeWidget\n QTreeWidget\n
xtreewidget.h
\n 1\n
\n
\n \n \n
\n 56 timeExpenseSheetItem 0 t \n\n This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2011 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL. By using this software, you agree\nto be bound by its terms.\n timeExpenseSheetItem\n \n \n \n 0\n 0\n 825\n 626\n \n \n \n Worksheet\n \n \n false\n \n \n Worksheet\n \n \n \n \n \n \n \n Worksheet:\n \n \n \n \n \n \n \n 80\n 0\n \n \n \n \n \n \n \n Line #:\n \n \n \n \n \n \n \n 80\n 0\n \n \n \n \n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 19\n 20\n \n \n \n \n \n \n \n \n \n Qt::Vertical\n \n \n QDialogButtonBox::Cancel|QDialogButtonBox::Save\n \n \n \n \n \n \n \n 0\n 0\n \n \n \n \n \n \n \n \n \n \n \n \n \n Week of:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n Qt::NoFocus\n \n \n XDateEdit::Empty\n \n \n \n \n \n \n Work Date:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n Project #:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n Qt::StrongFocus\n \n \n \n \n \n true\n \n \n Qt::Horizontal\n \n \n false\n \n \n false\n \n \n \n \n \n \n \n \n Qt::StrongFocus\n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 0\n 20\n \n \n \n \n \n \n \n \n \n Task:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n \n \n Qt::StrongFocus\n \n \n QComboBox::AdjustToContents\n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 0\n 13\n \n \n \n \n \n \n \n \n \n Type:\n \n \n \n \n \n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 0\n 20\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Qt::StrongFocus\n \n \n CLineEdit::AllCustomers\n \n \n \n \n \n \n \n \n Cust. PO#:\n \n \n \n \n \n \n \n 0\n 0\n \n \n \n Qt::StrongFocus\n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 0\n 20\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 231\n 171\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Hours:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n Rate:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n Total:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n \n \n \n \n \n \n \n Employee:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n \n \n \n \n \n Qt::StrongFocus\n \n \n Billable\n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 40\n 20\n \n \n \n \n \n \n \n \n \n \n \n Qt::StrongFocus\n \n \n timedtl_rate\n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 40\n 20\n \n \n \n \n \n \n \n \n \n \n \n Qt::NoFocus\n \n \n false\n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 40\n 20\n \n \n \n \n \n \n \n \n \n Qt::StrongFocus\n \n \n Prepaid (not reimbursable)\n \n \n \n \n \n \n Hourly Cost:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n \n \n false\n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 40\n 20\n \n \n \n \n \n \n \n \n \n Total Cost:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n \n \n false\n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 40\n 20\n \n \n \n \n \n \n \n \n \n \n \n \n \n Qt::Vertical\n \n \n \n 20\n 0\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\n \n \n \n Summary\n \n \n \n \n \n Task\n \n \n \n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 40\n 20\n \n \n \n \n \n \n \n \n \n Planned Hours:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n \n \n \n Qt::Vertical\n \n \n \n \n \n \n Planned Expense:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n \n \n \n Actual Hours:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n \n \n \n Actual Expense:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 0\n 20\n \n \n \n \n \n \n \n \n \n Qt::Vertical\n \n \n \n 20\n 0\n \n \n \n \n \n \n \n \n \n \n \n \n Employee\n \n \n \n \n \n \n \n \n \n \n \n Day Total:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n \n \n \n Worksheet Total:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n \n \n \n Hours\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n Hours\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 0\n 20\n \n \n \n \n \n \n \n \n \n Qt::Vertical\n \n \n \n 20\n 0\n \n \n \n \n \n \n \n \n \n \n \n \n \n Notes\n \n \n \n \n \n Qt::StrongFocus\n \n \n true\n \n \n \n \n \n \n \n \n \n \n \n CurrCluster\n \n
currcluster.h
\n
\n \n CustCluster\n \n
custcluster.h
\n
\n \n DLineEdit\n \n
datecluster.h
\n 1\n
\n \n EmpCluster\n \n
empcluster.h
\n
\n \n ItemCluster\n \n
itemcluster.h
\n 1\n
\n \n ProjectCluster\n \n
projectcluster.h
\n
\n \n XComboBox\n \n
xcombobox.h
\n
\n \n XLabel\n \n
xlabel.h
\n
\n \n XLineEdit\n \n
xlineedit.h
\n 1\n
\n \n XTextEdit\n \n
xtextedit.h
\n
\n
\n \n _workdate\n _type\n _project\n _task\n _clients\n _po\n _items\n _employee\n _hours\n _billable\n _rate\n _prepaid\n _tab\n _notes\n _buttonBox\n \n \n \n \n _rate\n idChanged(int)\n _total\n setId(int)\n \n \n 598\n 292\n \n \n 598\n 330\n \n \n \n \n
\n 57 timeExpenseSheets 0 t \n\n This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL. By using this software, you agree\nto be bound by its terms.\n timeExpenseSheets\n \n \n \n 0\n 0\n 800\n 600\n \n \n \n \n 0\n 0\n \n \n \n \n 700\n 370\n \n \n \n Worksheets\n \n \n \n 0\n \n \n 0\n \n \n \n \n true\n \n \n Qt::Horizontal\n \n \n Qt::ToolButtonIconOnly\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n QFrame::StyledPanel\n \n \n QFrame::Raised\n \n \n \n \n \n \n 301\n 111\n \n \n \n \n 0\n 0\n \n \n \n Employees\n \n \n \n \n \n \n \n All\n \n \n \n \n \n \n Qt::Horizontal\n \n \n QSizePolicy::Preferred\n \n \n \n 40\n 10\n \n \n \n \n \n \n \n \n \n \n \n Selected:\n \n \n \n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 40\n 10\n \n \n \n \n \n \n \n \n \n \n \n Direct Reports\n \n \n \n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 40\n 20\n \n \n \n \n \n \n \n \n \n \n \n \n \n 253\n 111\n \n \n \n Week of\n \n \n \n 5\n \n \n \n \n \n \n \n \n \n \n Status\n \n \n \n \n \n Open\n \n \n \n \n \n \n Approved\n \n \n \n \n \n \n Closed\n \n \n \n \n \n \n \n \n \n \n \n \n QAbstractItemView::ExtendedSelection\n \n \n false\n \n \n \n \n \n \n 12\n \n \n 6\n \n \n \n \n When Processing:\n \n \n \n \n \n \n Invoice\n \n \n \n \n \n \n Voucher\n \n \n \n \n \n \n Post Time\n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 40\n 0\n \n \n \n \n \n \n \n \n \n New\n \n \n Ctrl+N\n \n \n \n \n Close\n \n \n Ctrl+W\n \n \n \n \n Process\n \n \n Process Approved\n \n \n \n \n Approve\n \n \n Approve All\n \n \n \n \n Query\n \n \n Ctrl+R\n \n \n \n \n Print\n \n \n Ctrl+P\n \n \n \n \n \n DateCluster\n QWidget\n
datecluster.h
\n 1\n
\n \n EmpCluster\n QWidget\n
empcluster.h
\n
\n \n XCheckBox\n QCheckBox\n
xcheckbox.h
\n
\n \n XTreeWidget\n QTreeWidget\n
xtreewidget.h
\n 1\n
\n
\n \n \n
\n 51 projectGantt 0 t \n\n This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL. By using this software, you agree\nto be bound by its terms.\n projectGantt\n \n \n Qt::NonModal\n \n \n \n 0\n 0\n 800\n 600\n \n \n \n Project Gantt\n \n \n \n \n \n \n 0\n \n \n 0\n \n \n \n \n true\n \n \n Qt::Horizontal\n \n \n Qt::ToolButtonIconOnly\n \n \n \n \n \n \n \n \n Close\n \n \n Ctrl+W\n \n \n \n \n \n\n 53 tecustomer 0 t \n\n This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL. By using this software, you agree\nto be bound by its terms.\n tecustomer\n \n \n \n 0\n 0\n 323\n 91\n \n \n \n Billing\n \n \n \n 0\n \n \n 6\n \n \n 0\n \n \n 0\n \n \n \n \n \n 0\n 1\n \n \n \n Use specified billing rate\n \n \n true\n \n \n false\n \n \n \n \n \n Rate:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 41\n 20\n \n \n \n \n \n \n \n \n \n \n qPixmapFromMimeSource\n \n \n CurrCluster\n CurrDisplay\n
currcluster.h
\n
\n \n CurrDisplay\n QWidget\n
currcluster.h
\n
\n
\n \n _rate\n \n \n \n \n _billingGroup\n toggled(bool)\n _rate\n setCurrencyEnabled(bool)\n \n \n 210\n 133\n \n \n 167\n 142\n \n \n \n \n
\n \. -- -- Data for Name: tecustrate; Type: TABLE DATA; Schema: te; Owner: admin -- COPY tecustrate (tecustrate_cust_id, tecustrate_rate, tecustrate_id, tecustrate_curr_id) FROM stdin; \. -- -- Name: tecustrate_tecustrate_id_seq; Type: SEQUENCE SET; Schema: te; Owner: admin -- SELECT pg_catalog.setval('tecustrate_tecustrate_id_seq', 1, false); -- -- Data for Name: teemp; Type: TABLE DATA; Schema: te; Owner: admin -- COPY teemp (teemp_id, teemp_emp_id, teemp_contractor) FROM stdin; \. -- -- Name: teemp_teemp_id_seq; Type: SEQUENCE SET; Schema: te; Owner: admin -- SELECT pg_catalog.setval('teemp_teemp_id_seq', 1, false); -- -- Data for Name: teexp; Type: TABLE DATA; Schema: te; Owner: admin -- COPY teexp (teexp_id, teexp_expcat_id, teexp_accnt_id) FROM stdin; \. -- -- Data for Name: tehead; Type: TABLE DATA; Schema: te; Owner: admin -- COPY tehead (tehead_id, tehead_number, tehead_weekending, tehead_lastupdated, tehead_notes, tehead_status, tehead_emp_id, tehead_warehous_id, tehead_username) FROM stdin; \. -- -- Name: tehead_tehead_id_seq; Type: SEQUENCE SET; Schema: te; Owner: admin -- SELECT pg_catalog.setval('tehead_tehead_id_seq', 1, false); -- -- Data for Name: teitem; Type: TABLE DATA; Schema: te; Owner: admin -- COPY teitem (teitem_id, teitem_tehead_id, teitem_linenumber, teitem_type, teitem_workdate, teitem_cust_id, teitem_vend_id, teitem_po, teitem_item_id, teitem_qty, teitem_rate, teitem_total, teitem_prjtask_id, teitem_lastupdated, teitem_billable, teitem_prepaid, teitem_notes, teitem_posted, teitem_curr_id, teitem_uom_id, teitem_invcitem_id, teitem_vodist_id, teitem_postedvalue, teitem_empcost) FROM stdin; \. -- -- Name: teitem_teitem_id_seq; Type: SEQUENCE SET; Schema: te; Owner: admin -- SELECT pg_catalog.setval('teitem_teitem_id_seq', 1, false); -- -- Data for Name: teprj; Type: TABLE DATA; Schema: te; Owner: admin -- COPY teprj (teprj_id, teprj_prj_id, teprj_cust_id, teprj_rate, teprj_curr_id) FROM stdin; \. -- -- Name: teprj_teprj_id_seq; Type: SEQUENCE SET; Schema: te; Owner: admin -- SELECT pg_catalog.setval('teprj_teprj_id_seq', 1, false); -- -- Data for Name: teprjtask; Type: TABLE DATA; Schema: te; Owner: admin -- COPY teprjtask (teprjtask_id, teprjtask_cust_id, teprjtask_rate, teprjtask_item_id, teprjtask_prjtask_id, teprjtask_curr_id) FROM stdin; \. -- -- Name: teprjtask_teprjtask_id_seq; Type: SEQUENCE SET; Schema: te; Owner: admin -- SELECT pg_catalog.setval('teprjtask_teprjtask_id_seq', 1, false); -- -- Name: timesheet_seq; Type: SEQUENCE SET; Schema: te; Owner: admin -- SELECT pg_catalog.setval('timesheet_seq', 1000, false); SET search_path = xt, pg_catalog; -- -- Data for Name: js; Type: TABLE DATA; Schema: xt; Owner: admin -- COPY js (js_id, js_text, js_namespace, js_type, js_context, js_ext, js_active) FROM stdin; 1 \n\n/**\n * WARNING!!! IMPORTANT!!! README!!!\n * \n * The file was GENERATED! None of this file was written by a human.\n * DO NOT EDIT this file!\n * This file was created by running build_app.js in the process_manifext.js file.\n * If you find a bug or need to extend it with a new feature, you MUST follow this process:\n * \n * 1. Modify the PEG Grammer definition at: ../lib/orm/source/xt/pegs/metasql.peg\n * 2. Use the PEG.js online tool to test the new grammer:\n * - http://pegjs.org/online\n * 3. Run build_app.js with your PEG Grammer change and git commit the modified files.\n */\n\n(function () {\nXT.MetaSQL = {};\nXT.MetaSQL.parser = (function() {\n /*\n * Generated by PEG.js 0.8.0.\n *\n * http://pegjs.majda.cz/\n */\n\n function peg$subclass(child, parent) {\n function ctor() { this.constructor = child; }\n ctor.prototype = parent.prototype;\n child.prototype = new ctor();\n }\n\n function SyntaxError(message, expected, found, offset, line, column) {\n this.message = message;\n this.expected = expected;\n this.found = found;\n this.offset = offset;\n this.line = line;\n this.column = column;\n\n this.name = "SyntaxError";\n }\n\n peg$subclass(SyntaxError, Error);\n\n function parse(input) {\n var options = arguments.length > 1 ? arguments[1] : {},\n\n peg$FAILED = {},\n\n peg$startRuleFunctions = { Start: peg$parseStart },\n peg$startRuleFunction = peg$parseStart,\n\n peg$c0 = peg$FAILED,\n peg$c1 = function(start, metasql, end) {\n return start.join('') + metasql + end.join('');\n },\n peg$c2 = null,\n peg$c3 = function(sql) {\n return sql;\n },\n peg$c4 = [],\n peg$c5 = function(first, rest) {\n return first + rest.join('');\n },\n peg$c6 = function(quoted) {\n //return "quoted: " + quoted;\n return quoted;\n },\n peg$c7 = function(comment) {\n //return "comment: " + comment;\n return comment;\n },\n peg$c8 = function(state) {\n //return "statement: " + state;\n return state;\n },\n peg$c9 = function(sql) {\n //return "sql: " + sql;\n return sql;\n },\n peg$c10 = function(value) {\n //return "MQLValue: " + value;\n return value;\n },\n peg$c11 = function(literal) {\n //return "MQLLiteral: " + literal;\n return literal;\n },\n peg$c12 = function(loopcontrol) {\n //return "MQLLoopControl: " + loopcontrol;\n return loopcontrol;\n },\n peg$c13 = function(rawcond) {\n //return "MQLRawMQLCondition: " + rawcond;\n return rawcond;\n },\n peg$c14 = function(controlstate) {\n //return "MQLControlStatement: " + controlstate;\n return controlstate;\n },\n peg$c15 = function(generic) {\n //return "MQLGeneric: " + generic;\n return generic;\n },\n peg$c16 = "(",\n peg$c17 = { type: "literal", value: "(", description: "\\"(\\"" },\n peg$c18 = ")",\n peg$c19 = { type: "literal", value: ")", description: "\\")\\"" },\n peg$c20 = function(id) {\n var stackidx,\n listidx;\n\n if (Object.prototype.toString.call(params[id]) === '[object Array]') {\n stackidx = stackIdx(id);\n\n if (stackidx < loopstack.length) {\n listidx = loopstack[stackidx].count;\n\n if (listidx >= params[id].length) {\n listidx = params[id].length - 1;\n }\n\n if (typeof params[id][0] == 'string') {\n return ("'" + params[id][listidx] + "'");\n } else {\n return params[id][listidx];\n }\n }\n else {\n // Not in a foreach loop\n if (typeof params[id][0] == 'string') {\n return "'" + params[id][0] + "'";\n } else {\n return params[id][0];\n }\n }\n }\n\n if (typeof params[id] == 'string') {\n return ("'" + (params[id] ? params[id] : 'NULL ') + "'");\n } else {\n return (params[id] ? params[id] : 'NULL ');\n }\n },\n peg$c21 = function(id) {\n var stackidx,\n listidx;\n\n if (Object.prototype.toString.call(params[id]) === '[object Array]') {\n stackidx = stackIdx(id);\n\n if (stackidx < loopstack.length) {\n listidx = loopstack[stackidx].count;\n\n if (listidx >= params[id].length) {\n listidx = params[id].length - 1;\n }\n\n return params[id][listidx];\n }\n else {\n // Not in a foreach loop\n return params[id][0];\n }\n }\n\n return (params[id] ? params[id] : '');\n },\n peg$c22 = function(loop) {\n return loop;\n },\n peg$c23 = function(cond) {\n return cond;\n },\n peg$c24 = void 0,\n peg$c25 = function(ifcond, ifbody) {\n if (ifcond) {\n return (ifbody ? extractList(ifbody, 1).join('') : '');\n } else {\n return '';\n }\n },\n peg$c26 = function(ifcond, ifbody, elsebody) {\n if (ifcond) {\n return (ifbody ? extractList(ifbody, 1).join('') : '');\n } else {\n return (elsebody ? extractList(elsebody, 1).join('') : '');\n }\n },\n peg$c27 = function(ifcond, ifbody, elseifwraper, elsebody) {\n if (ifcond) {\n return (ifbody ? extractList(ifbody, 1).join('') : '');\n }\n\n if (elseifwraper !== null) {\n for (var i = 0; i < elseifwraper.length; i++) {\n // Find a valid elseif if any exists.\n if (elseifwraper[i][0]) {\n return (elseifwraper[i][1] ? extractList(elseifwraper[i][1], 1).join('') : '');\n }\n }\n }\n\n // The ifcond and elseifwraper conditions did not match.\n return (elsebody ? extractList(elsebody, 1).join('') : '');\n },\n peg$c28 = function(wrapper) {\n var body = wrapper.body,\n foreachcond = wrapper.foreachstart.id,\n foreachtext = wrapper.foreachstart.text,\n extractedbody = '',\n result = '',\n stackidx = stackIdx(foreachcond),\n extractForeach = function (foreachbody) {\n var foreachraw = '';\n\n for (var k = 0; k < foreachbody.length; k++) {\n // Index [k][1] is a nested foreach, build it recursively.\n if (foreachbody[k][1]) {\n foreachraw += foreachbody[k][1].foreachstart.text;\n foreachraw += extractForeach(foreachbody[k][1].body);\n foreachraw += foreachbody[k][1].foreachend;\n }\n\n // Index [k][2] is this foreach's body text.\n foreachraw += foreachbody[k][2];\n }\n\n return foreachraw;\n };\n\n extractedbody += extractForeach(body);\n\n if (params[foreachcond]) {\n if (Object.prototype.toString.call(params[foreachcond]) === '[object Array]') {\n for (var i = 0; i < params[foreachcond].length; i++) {\n var recurseOptions = {\n loopstack: loopstack\n };\n\n // Call the parser recursively on the body.\n result += parser.parse(extractedbody, recurseOptions);\n\n loopstack[stackidx].count++;\n }\n\n loopstack.shift().id;\n return result;\n } else {\n return '';\n }\n }\n },\n peg$c29 = function(start, body, end) {\n return start + (body ? extractList(body, 1).join('') : '') + end;\n },\n peg$c30 = function(id) {\n return ! (id in params);\n },\n peg$c31 = function(id) {\n return (id in params);\n },\n peg$c32 = function(re) {\n for (var prop in params) {\n if (prop.match(re)) {\n return true;\n }\n }\n\n return '';\n },\n peg$c33 = function(id) {\n var stackidx = stackIdx(id);\n\n if (Object.prototype.toString.call(params[id]) === '[object Array]') {\n if (stackidx < loopstack.length) {\n listidx = loopstack[stackidx].count;\n\n // Figure out if this is the first item in the array.\n if (listidx === 0) {\n return true;\n } else {\n return false;\n }\n }\n else {\n // Not in a foreach loop\n return (id in params);\n }\n } else {\n // Not a list parameter or does not exist.\n return true;\n }\n },\n peg$c34 = function(id) {\n var stackidx = stackIdx(id);\n\n if (Object.prototype.toString.call(params[id]) === '[object Array]') {\n if (stackidx < loopstack.length) {\n listidx = loopstack[stackidx].count;\n\n // Figure out if this is the last item in the array.\n if (listidx === (params[id].length - 1)) {\n return true;\n } else {\n return false;\n }\n }\n else {\n // Not in a foreach loop\n if ((id in params) && params[id].length === 1) {\n return true;\n } else {\n return false;\n }\n }\n } else {\n // Not a list parameter or does not exist.\n return false;\n }\n },\n peg$c35 = function(id) {\n loopstack.unshift({ id: id, count: 0 });\n\n return {\n text: text(),\n id: id\n };\n },\n peg$c36 = function() {\n return text();\n },\n peg$c37 = function(foreachstart, body, foreachend) {\n var wrapper = {\n foreachstart: foreachstart,\n body: body,\n foreachend: foreachend\n };\n\n return wrapper;\n },\n peg$c38 = function(loop) {\n // TODO: Figure out what the passed loop count is.\n // TODO: Figure out where we are in the loop.\n // TODO: Continue logic.\n loop = loop || 1;\n return '';\n },\n peg$c39 = function(loop) {\n // TODO: Figure out what the passed loop count is.\n // TODO: Figure out where we are in the loop.\n // TODO: Break logic.\n loop = loop || 1;\n return '';\n },\n peg$c40 = "",\n peg$c43 = { type: "literal", value: "?>", description: "\\"?>\\"" },\n peg$c44 = /^[Vv]/,\n peg$c45 = { type: "class", value: "[Vv]", description: "[Vv]" },\n peg$c46 = /^[Aa]/,\n peg$c47 = { type: "class", value: "[Aa]", description: "[Aa]" },\n peg$c48 = /^[Ll]/,\n peg$c49 = { type: "class", value: "[Ll]", description: "[Ll]" },\n peg$c50 = /^[Uu]/,\n peg$c51 = { type: "class", value: "[Uu]", description: "[Uu]" },\n peg$c52 = /^[Ee]/,\n peg$c53 = { type: "class", value: "[Ee]", description: "[Ee]" },\n peg$c54 = /^[Ii]/,\n peg$c55 = { type: "class", value: "[Ii]", description: "[Ii]" },\n peg$c56 = /^[Tt]/,\n peg$c57 = { type: "class", value: "[Tt]", description: "[Tt]" },\n peg$c58 = /^[Rr]/,\n peg$c59 = { type: "class", value: "[Rr]", description: "[Rr]" },\n peg$c60 = /^[Ff]/,\n peg$c61 = { type: "class", value: "[Ff]", description: "[Ff]" },\n peg$c62 = /^[Ss]/,\n peg$c63 = { type: "class", value: "[Ss]", description: "[Ss]" },\n peg$c64 = /^[Nn]/,\n peg$c65 = { type: "class", value: "[Nn]", description: "[Nn]" },\n peg$c66 = /^[Dd]/,\n peg$c67 = { type: "class", value: "[Dd]", description: "[Dd]" },\n peg$c68 = /^[Oo]/,\n peg$c69 = { type: "class", value: "[Oo]", description: "[Oo]" },\n peg$c70 = /^[Xx]/,\n peg$c71 = { type: "class", value: "[Xx]", description: "[Xx]" },\n peg$c72 = /^[Cc]/,\n peg$c73 = { type: "class", value: "[Cc]", description: "[Cc]" },\n peg$c74 = /^[Hh]/,\n peg$c75 = { type: "class", value: "[Hh]", description: "[Hh]" },\n peg$c76 = /^[Bb]/,\n peg$c77 = { type: "class", value: "[Bb]", description: "[Bb]" },\n peg$c78 = /^[Kk]/,\n peg$c79 = { type: "class", value: "[Kk]", description: "[Kk]" },\n peg$c80 = function(text) {\n return (text ? text : '');\n },\n peg$c81 = function(body) {\n return (body ? body : '');\n },\n peg$c82 = { type: "any", description: "any character" },\n peg$c83 = { type: "other", description: "whitespace" },\n peg$c84 = "\\t",\n peg$c85 = { type: "literal", value: "\\t", description: "\\"\\\\t\\"" },\n peg$c86 = "\\x0B",\n peg$c87 = { type: "literal", value: "\\x0B", description: "\\"\\\\x0B\\"" },\n peg$c88 = "\\f",\n peg$c89 = { type: "literal", value: "\\f", description: "\\"\\\\f\\"" },\n peg$c90 = " ",\n peg$c91 = { type: "literal", value: " ", description: "\\" \\"" },\n peg$c92 = "\\xA0",\n peg$c93 = { type: "literal", value: "\\xA0", description: "\\"\\\\xA0\\"" },\n peg$c94 = "\\uFEFF",\n peg$c95 = { type: "literal", value: "\\uFEFF", description: "\\"\\\\uFEFF\\"" },\n peg$c96 = /^[\\n\\r\\u2028\\u2029]/,\n peg$c97 = { type: "class", value: "[\\\\n\\\\r\\\\u2028\\\\u2029]", description: "[\\\\n\\\\r\\\\u2028\\\\u2029]" },\n peg$c98 = function(line) {\n return line + '&';\n },\n peg$c99 = { type: "other", description: "end of line" },\n peg$c100 = "\\n",\n peg$c101 = { type: "literal", value: "\\n", description: "\\"\\\\n\\"" },\n peg$c102 = "\\r\\n",\n peg$c103 = { type: "literal", value: "\\r\\n", description: "\\"\\\\r\\\\n\\"" },\n peg$c104 = "\\r",\n peg$c105 = { type: "literal", value: "\\r", description: "\\"\\\\r\\"" },\n peg$c106 = "\\u2028",\n peg$c107 = { type: "literal", value: "\\u2028", description: "\\"\\\\u2028\\"" },\n peg$c108 = "\\u2029",\n peg$c109 = { type: "literal", value: "\\u2029", description: "\\"\\\\u2029\\"" },\n peg$c110 = /^[0-9]/,\n peg$c111 = { type: "class", value: "[0-9]", description: "[0-9]" },\n peg$c112 = /^[0-9a-f]/i,\n peg$c113 = { type: "class", value: "[0-9a-f]i", description: "[0-9a-f]i" },\n peg$c114 = "'",\n peg$c115 = { type: "literal", value: "'", description: "\\"'\\"" },\n peg$c116 = /^[^']/,\n peg$c117 = { type: "class", value: "[^']", description: "[^']" },\n peg$c118 = function(str) {\n return str.join("");\n },\n peg$c119 = "\\"",\n peg$c120 = { type: "literal", value: "\\"", description: "\\"\\\\\\"\\"" },\n peg$c121 = /^[^"]/,\n peg$c122 = { type: "class", value: "[^\\"]", description: "[^\\"]" },\n peg$c123 = { type: "other", description: "comment" },\n peg$c124 = "/*",\n peg$c125 = { type: "literal", value: "/*", description: "\\"/*\\"" },\n peg$c126 = "*/",\n peg$c127 = { type: "literal", value: "*/", description: "\\"*/\\"" },\n peg$c128 = "--",\n peg$c129 = { type: "literal", value: "--", description: "\\"--\\"" },\n peg$c130 = function(start, body) {\n return start + (body ? extractList(body, 1).join('') : '');\n },\n peg$c131 = { type: "other", description: "quoted identifier" },\n peg$c132 = function(start, body, end) {\n return (body ? body.join('') : '');\n },\n peg$c133 = { type: "other", description: "quoted string" },\n peg$c134 = function(start, body, end) {\n return start + (body ? body.join('') : '') + end;\n },\n peg$c135 = "\\\\",\n peg$c136 = { type: "literal", value: "\\\\", description: "\\"\\\\\\\\\\"" },\n peg$c137 = function(sequence) {\n return sequence;\n },\n peg$c138 = function() {\n return "";\n },\n peg$c139 = "0",\n peg$c140 = { type: "literal", value: "0", description: "\\"0\\"" },\n peg$c141 = function() {\n return "\\0";\n },\n peg$c142 = "b",\n peg$c143 = { type: "literal", value: "b", description: "\\"b\\"" },\n peg$c144 = function() {\n return "\\b";\n },\n peg$c145 = "f",\n peg$c146 = { type: "literal", value: "f", description: "\\"f\\"" },\n peg$c147 = function() {\n return "\\f";\n },\n peg$c148 = "n",\n peg$c149 = { type: "literal", value: "n", description: "\\"n\\"" },\n peg$c150 = function() {\n return "\\n";\n },\n peg$c151 = "r",\n peg$c152 = { type: "literal", value: "r", description: "\\"r\\"" },\n peg$c153 = function() {\n return "\\r";\n },\n peg$c154 = "t",\n peg$c155 = { type: "literal", value: "t", description: "\\"t\\"" },\n peg$c156 = function() {\n return "\\t";\n },\n peg$c157 = "v",\n peg$c158 = { type: "literal", value: "v", description: "\\"v\\"" },\n peg$c159 = function() {\n return "\\x0B"; // IE does not recognize "\\v".\n },\n peg$c160 = "x",\n peg$c161 = { type: "literal", value: "x", description: "\\"x\\"" },\n peg$c162 = "u",\n peg$c163 = { type: "literal", value: "u", description: "\\"u\\"" },\n peg$c164 = function(digits) {\n return String.fromCharCode(parseInt(digits, 16));\n },\n peg$c165 = /^[ \\xA0\\u1680\\u2000-\\u200A\\u202F\\u205F\\u3000]/,\n peg$c166 = { type: "class", value: "[ \\\\xA0\\\\u1680\\\\u2000-\\\\u200A\\\\u202F\\\\u205F\\\\u3000]", description: "[ \\\\xA0\\\\u1680\\\\u2000-\\\\u200A\\\\u202F\\\\u205F\\\\u3000]" },\n\n peg$currPos = 0,\n peg$reportedPos = 0,\n peg$cachedPos = 0,\n peg$cachedPosDetails = { line: 1, column: 1, seenCR: false },\n peg$maxFailPos = 0,\n peg$maxFailExpected = [],\n peg$silentFails = 0,\n\n peg$result;\n\n if ("startRule" in options) {\n if (!(options.startRule in peg$startRuleFunctions)) {\n throw new Error("Can't start parsing from rule \\"" + options.startRule + "\\".");\n }\n\n peg$startRuleFunction = peg$startRuleFunctions[options.startRule];\n }\n\n function text() {\n return input.substring(peg$reportedPos, peg$currPos);\n }\n\n function offset() {\n return peg$reportedPos;\n }\n\n function line() {\n return peg$computePosDetails(peg$reportedPos).line;\n }\n\n function column() {\n return peg$computePosDetails(peg$reportedPos).column;\n }\n\n function expected(description) {\n throw peg$buildException(\n null,\n [{ type: "other", description: description }],\n peg$reportedPos\n );\n }\n\n function error(message) {\n throw peg$buildException(message, null, peg$reportedPos);\n }\n\n function peg$computePosDetails(pos) {\n function advance(details, startPos, endPos) {\n var p, ch;\n\n for (p = startPos; p < endPos; p++) {\n ch = input.charAt(p);\n if (ch === "\\n") {\n if (!details.seenCR) { details.line++; }\n details.column = 1;\n details.seenCR = false;\n } else if (ch === "\\r" || ch === "\\u2028" || ch === "\\u2029") {\n details.line++;\n details.column = 1;\n details.seenCR = true;\n } else {\n details.column++;\n details.seenCR = false;\n }\n }\n }\n\n if (peg$cachedPos !== pos) {\n if (peg$cachedPos > pos) {\n peg$cachedPos = 0;\n peg$cachedPosDetails = { line: 1, column: 1, seenCR: false };\n }\n advance(peg$cachedPosDetails, peg$cachedPos, pos);\n peg$cachedPos = pos;\n }\n\n return peg$cachedPosDetails;\n }\n\n function peg$fail(expected) {\n if (peg$currPos < peg$maxFailPos) { return; }\n\n if (peg$currPos > peg$maxFailPos) {\n peg$maxFailPos = peg$currPos;\n peg$maxFailExpected = [];\n }\n\n peg$maxFailExpected.push(expected);\n }\n\n function peg$buildException(message, expected, pos) {\n function cleanupExpected(expected) {\n var i = 1;\n\n expected.sort(function(a, b) {\n if (a.description < b.description) {\n return -1;\n } else if (a.description > b.description) {\n return 1;\n } else {\n return 0;\n }\n });\n\n while (i < expected.length) {\n if (expected[i - 1] === expected[i]) {\n expected.splice(i, 1);\n } else {\n i++;\n }\n }\n }\n\n function buildMessage(expected, found) {\n function stringEscape(s) {\n function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }\n\n return s\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/"/g, '\\\\"')\n .replace(/\\x08/g, '\\\\b')\n .replace(/\\t/g, '\\\\t')\n .replace(/\\n/g, '\\\\n')\n .replace(/\\f/g, '\\\\f')\n .replace(/\\r/g, '\\\\r')\n .replace(/[\\x00-\\x07\\x0B\\x0E\\x0F]/g, function(ch) { return '\\\\x0' + hex(ch); })\n .replace(/[\\x10-\\x1F\\x80-\\xFF]/g, function(ch) { return '\\\\x' + hex(ch); })\n .replace(/[\\u0180-\\u0FFF]/g, function(ch) { return '\\\\u0' + hex(ch); })\n .replace(/[\\u1080-\\uFFFF]/g, function(ch) { return '\\\\u' + hex(ch); });\n }\n\n var expectedDescs = new Array(expected.length),\n expectedDesc, foundDesc, i;\n\n for (i = 0; i < expected.length; i++) {\n expectedDescs[i] = expected[i].description;\n }\n\n expectedDesc = expected.length > 1\n ? expectedDescs.slice(0, -1).join(", ")\n + " or "\n + expectedDescs[expected.length - 1]\n : expectedDescs[0];\n\n foundDesc = found ? "\\"" + stringEscape(found) + "\\"" : "end of input";\n\n return "Expected " + expectedDesc + " but " + foundDesc + " found.";\n }\n\n var posDetails = peg$computePosDetails(pos),\n found = pos < input.length ? input.charAt(pos) : null;\n\n if (expected !== null) {\n cleanupExpected(expected);\n }\n\n return new SyntaxError(\n message !== null ? message : buildMessage(expected, found),\n expected,\n found,\n pos,\n posDetails.line,\n posDetails.column\n );\n }\n\n function peg$parseStart() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n s1 = peg$parse__();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseMetaSQL();\n if (s2 !== peg$FAILED) {\n s3 = peg$parse__();\n if (s3 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c1(s1, s2, s3);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseMetaSQL() {\n var s0, s1;\n\n s0 = peg$currPos;\n s1 = peg$parseSourceElements();\n if (s1 === peg$FAILED) {\n s1 = peg$c2;\n }\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c3(s1);\n }\n s0 = s1;\n\n return s0;\n }\n\n function peg$parseSourceElements() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n s1 = peg$parseSourceElement();\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parseSourceElement();\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parseSourceElement();\n }\n if (s2 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c5(s1, s2);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseSourceElement() {\n var s0, s1;\n\n s0 = peg$currPos;\n s1 = peg$parseQuotedString();\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c6(s1);\n }\n s0 = s1;\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parseComment();\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c7(s1);\n }\n s0 = s1;\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parseStatement();\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c8(s1);\n }\n s0 = s1;\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parseSQLText();\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c9(s1);\n }\n s0 = s1;\n }\n }\n }\n\n return s0;\n }\n\n function peg$parseStatement() {\n var s0, s1;\n\n s0 = peg$currPos;\n s1 = peg$parseMQLValue();\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c10(s1);\n }\n s0 = s1;\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parseMQLLiteral();\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c11(s1);\n }\n s0 = s1;\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parseMQLLoopControl();\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c12(s1);\n }\n s0 = s1;\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parseMQLRawMQLCondition();\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c13(s1);\n }\n s0 = s1;\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parseMQLControlStatement();\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c14(s1);\n }\n s0 = s1;\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parseMQLGeneric();\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c15(s1);\n }\n s0 = s1;\n }\n }\n }\n }\n }\n\n return s0;\n }\n\n function peg$parseMQLValue() {\n var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11;\n\n s0 = peg$currPos;\n s1 = peg$parseMQLOpen();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseWhiteSpace();\n if (s2 === peg$FAILED) {\n s2 = peg$c2;\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parseValue();\n if (s3 !== peg$FAILED) {\n s4 = peg$parseWhiteSpace();\n if (s4 === peg$FAILED) {\n s4 = peg$c2;\n }\n if (s4 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 40) {\n s5 = peg$c16;\n peg$currPos++;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c17); }\n }\n if (s5 !== peg$FAILED) {\n s6 = peg$parseWhiteSpace();\n if (s6 === peg$FAILED) {\n s6 = peg$c2;\n }\n if (s6 !== peg$FAILED) {\n s7 = peg$parseQuotedIdentifier();\n if (s7 !== peg$FAILED) {\n s8 = peg$parseWhiteSpace();\n if (s8 === peg$FAILED) {\n s8 = peg$c2;\n }\n if (s8 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 41) {\n s9 = peg$c18;\n peg$currPos++;\n } else {\n s9 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c19); }\n }\n if (s9 !== peg$FAILED) {\n s10 = peg$parseWhiteSpace();\n if (s10 === peg$FAILED) {\n s10 = peg$c2;\n }\n if (s10 !== peg$FAILED) {\n s11 = peg$parseMQLClose();\n if (s11 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c20(s7);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseMQLLiteral() {\n var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11;\n\n s0 = peg$currPos;\n s1 = peg$parseMQLOpen();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseWhiteSpace();\n if (s2 === peg$FAILED) {\n s2 = peg$c2;\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parseLiteral();\n if (s3 !== peg$FAILED) {\n s4 = peg$parseWhiteSpace();\n if (s4 === peg$FAILED) {\n s4 = peg$c2;\n }\n if (s4 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 40) {\n s5 = peg$c16;\n peg$currPos++;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c17); }\n }\n if (s5 !== peg$FAILED) {\n s6 = peg$parseWhiteSpace();\n if (s6 === peg$FAILED) {\n s6 = peg$c2;\n }\n if (s6 !== peg$FAILED) {\n s7 = peg$parseQuotedIdentifier();\n if (s7 !== peg$FAILED) {\n s8 = peg$parseWhiteSpace();\n if (s8 === peg$FAILED) {\n s8 = peg$c2;\n }\n if (s8 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 41) {\n s9 = peg$c18;\n peg$currPos++;\n } else {\n s9 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c19); }\n }\n if (s9 !== peg$FAILED) {\n s10 = peg$parseWhiteSpace();\n if (s10 === peg$FAILED) {\n s10 = peg$c2;\n }\n if (s10 !== peg$FAILED) {\n s11 = peg$parseMQLClose();\n if (s11 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c21(s7);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseMQLLoopControl() {\n var s0, s1, s2, s3, s4, s5;\n\n s0 = peg$currPos;\n s1 = peg$parseMQLOpen();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseWhiteSpace();\n if (s2 === peg$FAILED) {\n s2 = peg$c2;\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parseMQLLoopFunction();\n if (s3 !== peg$FAILED) {\n s4 = peg$parseWhiteSpace();\n if (s4 === peg$FAILED) {\n s4 = peg$c2;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseMQLClose();\n if (s5 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c22(s3);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseMQLRawMQLCondition() {\n var s0, s1, s2, s3, s4, s5;\n\n s0 = peg$currPos;\n s1 = peg$parseMQLOpen();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseWhiteSpace();\n if (s2 === peg$FAILED) {\n s2 = peg$c2;\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parseMQLCondition();\n if (s3 !== peg$FAILED) {\n s4 = peg$parseWhiteSpace();\n if (s4 === peg$FAILED) {\n s4 = peg$c2;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseMQLClose();\n if (s5 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c23(s3);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseMQLControlStatement() {\n var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;\n\n s0 = peg$currPos;\n s1 = peg$parseMQLIf();\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$currPos;\n s4 = peg$currPos;\n peg$silentFails++;\n s5 = peg$parseMQLElse();\n if (s5 === peg$FAILED) {\n s5 = peg$parseMQLElseIf();\n if (s5 === peg$FAILED) {\n s5 = peg$parseMQLEndIf();\n }\n }\n peg$silentFails--;\n if (s5 === peg$FAILED) {\n s4 = peg$c24;\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseSourceElement();\n if (s5 !== peg$FAILED) {\n s4 = [s4, s5];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$currPos;\n s4 = peg$currPos;\n peg$silentFails++;\n s5 = peg$parseMQLElse();\n if (s5 === peg$FAILED) {\n s5 = peg$parseMQLElseIf();\n if (s5 === peg$FAILED) {\n s5 = peg$parseMQLEndIf();\n }\n }\n peg$silentFails--;\n if (s5 === peg$FAILED) {\n s4 = peg$c24;\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseSourceElement();\n if (s5 !== peg$FAILED) {\n s4 = [s4, s5];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parseMQLEndIf();\n if (s3 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c25(s1, s2);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parseMQLIf();\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$currPos;\n s4 = peg$currPos;\n peg$silentFails++;\n s5 = peg$parseMQLElse();\n if (s5 === peg$FAILED) {\n s5 = peg$parseMQLElseIf();\n if (s5 === peg$FAILED) {\n s5 = peg$parseMQLEndIf();\n }\n }\n peg$silentFails--;\n if (s5 === peg$FAILED) {\n s4 = peg$c24;\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseSourceElement();\n if (s5 !== peg$FAILED) {\n s4 = [s4, s5];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$currPos;\n s4 = peg$currPos;\n peg$silentFails++;\n s5 = peg$parseMQLElse();\n if (s5 === peg$FAILED) {\n s5 = peg$parseMQLElseIf();\n if (s5 === peg$FAILED) {\n s5 = peg$parseMQLEndIf();\n }\n }\n peg$silentFails--;\n if (s5 === peg$FAILED) {\n s4 = peg$c24;\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseSourceElement();\n if (s5 !== peg$FAILED) {\n s4 = [s4, s5];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parseMQLElse();\n if (s3 !== peg$FAILED) {\n s4 = [];\n s5 = peg$currPos;\n s6 = peg$currPos;\n peg$silentFails++;\n s7 = peg$parseMQLElseIf();\n if (s7 === peg$FAILED) {\n s7 = peg$parseMQLEndIf();\n }\n peg$silentFails--;\n if (s7 === peg$FAILED) {\n s6 = peg$c24;\n } else {\n peg$currPos = s6;\n s6 = peg$c0;\n }\n if (s6 !== peg$FAILED) {\n s7 = peg$parseSourceElement();\n if (s7 !== peg$FAILED) {\n s6 = [s6, s7];\n s5 = s6;\n } else {\n peg$currPos = s5;\n s5 = peg$c0;\n }\n } else {\n peg$currPos = s5;\n s5 = peg$c0;\n }\n while (s5 !== peg$FAILED) {\n s4.push(s5);\n s5 = peg$currPos;\n s6 = peg$currPos;\n peg$silentFails++;\n s7 = peg$parseMQLElseIf();\n if (s7 === peg$FAILED) {\n s7 = peg$parseMQLEndIf();\n }\n peg$silentFails--;\n if (s7 === peg$FAILED) {\n s6 = peg$c24;\n } else {\n peg$currPos = s6;\n s6 = peg$c0;\n }\n if (s6 !== peg$FAILED) {\n s7 = peg$parseSourceElement();\n if (s7 !== peg$FAILED) {\n s6 = [s6, s7];\n s5 = s6;\n } else {\n peg$currPos = s5;\n s5 = peg$c0;\n }\n } else {\n peg$currPos = s5;\n s5 = peg$c0;\n }\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseMQLEndIf();\n if (s5 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c26(s1, s2, s4);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parseMQLIf();\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$currPos;\n s4 = peg$currPos;\n peg$silentFails++;\n s5 = peg$parseMQLElse();\n if (s5 === peg$FAILED) {\n s5 = peg$parseMQLElseIf();\n if (s5 === peg$FAILED) {\n s5 = peg$parseMQLEndIf();\n }\n }\n peg$silentFails--;\n if (s5 === peg$FAILED) {\n s4 = peg$c24;\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseSourceElement();\n if (s5 !== peg$FAILED) {\n s4 = [s4, s5];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$currPos;\n s4 = peg$currPos;\n peg$silentFails++;\n s5 = peg$parseMQLElse();\n if (s5 === peg$FAILED) {\n s5 = peg$parseMQLElseIf();\n if (s5 === peg$FAILED) {\n s5 = peg$parseMQLEndIf();\n }\n }\n peg$silentFails--;\n if (s5 === peg$FAILED) {\n s4 = peg$c24;\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseSourceElement();\n if (s5 !== peg$FAILED) {\n s4 = [s4, s5];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n }\n if (s2 !== peg$FAILED) {\n s3 = [];\n s4 = peg$currPos;\n s5 = peg$parseMQLElseIf();\n if (s5 !== peg$FAILED) {\n s6 = [];\n s7 = peg$currPos;\n s8 = peg$currPos;\n peg$silentFails++;\n s9 = peg$parseMQLElseIf();\n if (s9 === peg$FAILED) {\n s9 = peg$parseMQLElse();\n if (s9 === peg$FAILED) {\n s9 = peg$parseMQLEndIf();\n }\n }\n peg$silentFails--;\n if (s9 === peg$FAILED) {\n s8 = peg$c24;\n } else {\n peg$currPos = s8;\n s8 = peg$c0;\n }\n if (s8 !== peg$FAILED) {\n s9 = peg$parseSourceElement();\n if (s9 !== peg$FAILED) {\n s8 = [s8, s9];\n s7 = s8;\n } else {\n peg$currPos = s7;\n s7 = peg$c0;\n }\n } else {\n peg$currPos = s7;\n s7 = peg$c0;\n }\n while (s7 !== peg$FAILED) {\n s6.push(s7);\n s7 = peg$currPos;\n s8 = peg$currPos;\n peg$silentFails++;\n s9 = peg$parseMQLElseIf();\n if (s9 === peg$FAILED) {\n s9 = peg$parseMQLElse();\n if (s9 === peg$FAILED) {\n s9 = peg$parseMQLEndIf();\n }\n }\n peg$silentFails--;\n if (s9 === peg$FAILED) {\n s8 = peg$c24;\n } else {\n peg$currPos = s8;\n s8 = peg$c0;\n }\n if (s8 !== peg$FAILED) {\n s9 = peg$parseSourceElement();\n if (s9 !== peg$FAILED) {\n s8 = [s8, s9];\n s7 = s8;\n } else {\n peg$currPos = s7;\n s7 = peg$c0;\n }\n } else {\n peg$currPos = s7;\n s7 = peg$c0;\n }\n }\n if (s6 !== peg$FAILED) {\n s5 = [s5, s6];\n s4 = s5;\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n while (s4 !== peg$FAILED) {\n s3.push(s4);\n s4 = peg$currPos;\n s5 = peg$parseMQLElseIf();\n if (s5 !== peg$FAILED) {\n s6 = [];\n s7 = peg$currPos;\n s8 = peg$currPos;\n peg$silentFails++;\n s9 = peg$parseMQLElseIf();\n if (s9 === peg$FAILED) {\n s9 = peg$parseMQLElse();\n if (s9 === peg$FAILED) {\n s9 = peg$parseMQLEndIf();\n }\n }\n peg$silentFails--;\n if (s9 === peg$FAILED) {\n s8 = peg$c24;\n } else {\n peg$currPos = s8;\n s8 = peg$c0;\n }\n if (s8 !== peg$FAILED) {\n s9 = peg$parseSourceElement();\n if (s9 !== peg$FAILED) {\n s8 = [s8, s9];\n s7 = s8;\n } else {\n peg$currPos = s7;\n s7 = peg$c0;\n }\n } else {\n peg$currPos = s7;\n s7 = peg$c0;\n }\n while (s7 !== peg$FAILED) {\n s6.push(s7);\n s7 = peg$currPos;\n s8 = peg$currPos;\n peg$silentFails++;\n s9 = peg$parseMQLElseIf();\n if (s9 === peg$FAILED) {\n s9 = peg$parseMQLElse();\n if (s9 === peg$FAILED) {\n s9 = peg$parseMQLEndIf();\n }\n }\n peg$silentFails--;\n if (s9 === peg$FAILED) {\n s8 = peg$c24;\n } else {\n peg$currPos = s8;\n s8 = peg$c0;\n }\n if (s8 !== peg$FAILED) {\n s9 = peg$parseSourceElement();\n if (s9 !== peg$FAILED) {\n s8 = [s8, s9];\n s7 = s8;\n } else {\n peg$currPos = s7;\n s7 = peg$c0;\n }\n } else {\n peg$currPos = s7;\n s7 = peg$c0;\n }\n }\n if (s6 !== peg$FAILED) {\n s5 = [s5, s6];\n s4 = s5;\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n }\n if (s3 !== peg$FAILED) {\n s4 = peg$parseMQLElse();\n if (s4 !== peg$FAILED) {\n s5 = [];\n s6 = peg$currPos;\n s7 = peg$currPos;\n peg$silentFails++;\n s8 = peg$parseMQLEndIf();\n peg$silentFails--;\n if (s8 === peg$FAILED) {\n s7 = peg$c24;\n } else {\n peg$currPos = s7;\n s7 = peg$c0;\n }\n if (s7 !== peg$FAILED) {\n s8 = peg$parseSourceElement();\n if (s8 !== peg$FAILED) {\n s7 = [s7, s8];\n s6 = s7;\n } else {\n peg$currPos = s6;\n s6 = peg$c0;\n }\n } else {\n peg$currPos = s6;\n s6 = peg$c0;\n }\n while (s6 !== peg$FAILED) {\n s5.push(s6);\n s6 = peg$currPos;\n s7 = peg$currPos;\n peg$silentFails++;\n s8 = peg$parseMQLEndIf();\n peg$silentFails--;\n if (s8 === peg$FAILED) {\n s7 = peg$c24;\n } else {\n peg$currPos = s7;\n s7 = peg$c0;\n }\n if (s7 !== peg$FAILED) {\n s8 = peg$parseSourceElement();\n if (s8 !== peg$FAILED) {\n s7 = [s7, s8];\n s6 = s7;\n } else {\n peg$currPos = s6;\n s6 = peg$c0;\n }\n } else {\n peg$currPos = s6;\n s6 = peg$c0;\n }\n }\n if (s5 !== peg$FAILED) {\n s6 = peg$parseMQLEndIf();\n if (s6 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c27(s1, s2, s3, s5);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parseForEachWrapper();\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c28(s1);\n }\n s0 = s1;\n }\n }\n }\n\n return s0;\n }\n\n function peg$parseMQLGeneric() {\n var s0, s1, s2, s3, s4, s5;\n\n s0 = peg$currPos;\n s1 = peg$parseMQLOpen();\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$currPos;\n s4 = peg$currPos;\n peg$silentFails++;\n s5 = peg$parseMQLClose();\n peg$silentFails--;\n if (s5 === peg$FAILED) {\n s4 = peg$c24;\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseSourceCharacter();\n if (s5 !== peg$FAILED) {\n s4 = [s4, s5];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$currPos;\n s4 = peg$currPos;\n peg$silentFails++;\n s5 = peg$parseMQLClose();\n peg$silentFails--;\n if (s5 === peg$FAILED) {\n s4 = peg$c24;\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseSourceCharacter();\n if (s5 !== peg$FAILED) {\n s4 = [s4, s5];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parseMQLClose();\n if (s3 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c29(s1, s2, s3);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseMQLCondition() {\n var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;\n\n s0 = peg$currPos;\n s1 = peg$parseNot();\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parseWhiteSpace();\n if (s3 !== peg$FAILED) {\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parseWhiteSpace();\n }\n } else {\n s2 = peg$c0;\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parseExists();\n if (s3 !== peg$FAILED) {\n s4 = peg$parseWhiteSpace();\n if (s4 === peg$FAILED) {\n s4 = peg$c2;\n }\n if (s4 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 40) {\n s5 = peg$c16;\n peg$currPos++;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c17); }\n }\n if (s5 !== peg$FAILED) {\n s6 = peg$parseWhiteSpace();\n if (s6 === peg$FAILED) {\n s6 = peg$c2;\n }\n if (s6 !== peg$FAILED) {\n s7 = peg$parseQuotedIdentifier();\n if (s7 !== peg$FAILED) {\n s8 = peg$parseWhiteSpace();\n if (s8 === peg$FAILED) {\n s8 = peg$c2;\n }\n if (s8 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 41) {\n s9 = peg$c18;\n peg$currPos++;\n } else {\n s9 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c19); }\n }\n if (s9 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c30(s7);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parseExists();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseWhiteSpace();\n if (s2 === peg$FAILED) {\n s2 = peg$c2;\n }\n if (s2 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 40) {\n s3 = peg$c16;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c17); }\n }\n if (s3 !== peg$FAILED) {\n s4 = peg$parseWhiteSpace();\n if (s4 === peg$FAILED) {\n s4 = peg$c2;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseQuotedIdentifier();\n if (s5 !== peg$FAILED) {\n s6 = peg$parseWhiteSpace();\n if (s6 === peg$FAILED) {\n s6 = peg$c2;\n }\n if (s6 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 41) {\n s7 = peg$c18;\n peg$currPos++;\n } else {\n s7 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c19); }\n }\n if (s7 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c31(s5);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parseReExists();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseWhiteSpace();\n if (s2 === peg$FAILED) {\n s2 = peg$c2;\n }\n if (s2 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 40) {\n s3 = peg$c16;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c17); }\n }\n if (s3 !== peg$FAILED) {\n s4 = peg$parseWhiteSpace();\n if (s4 === peg$FAILED) {\n s4 = peg$c2;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseRegExp();\n if (s5 !== peg$FAILED) {\n s6 = peg$parseWhiteSpace();\n if (s6 === peg$FAILED) {\n s6 = peg$c2;\n }\n if (s6 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 41) {\n s7 = peg$c18;\n peg$currPos++;\n } else {\n s7 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c19); }\n }\n if (s7 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c32(s5);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parseIsFirst();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseWhiteSpace();\n if (s2 === peg$FAILED) {\n s2 = peg$c2;\n }\n if (s2 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 40) {\n s3 = peg$c16;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c17); }\n }\n if (s3 !== peg$FAILED) {\n s4 = peg$parseWhiteSpace();\n if (s4 === peg$FAILED) {\n s4 = peg$c2;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseQuotedIdentifier();\n if (s5 !== peg$FAILED) {\n s6 = peg$parseWhiteSpace();\n if (s6 === peg$FAILED) {\n s6 = peg$c2;\n }\n if (s6 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 41) {\n s7 = peg$c18;\n peg$currPos++;\n } else {\n s7 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c19); }\n }\n if (s7 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c33(s5);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parseIsLast();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseWhiteSpace();\n if (s2 === peg$FAILED) {\n s2 = peg$c2;\n }\n if (s2 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 40) {\n s3 = peg$c16;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c17); }\n }\n if (s3 !== peg$FAILED) {\n s4 = peg$parseWhiteSpace();\n if (s4 === peg$FAILED) {\n s4 = peg$c2;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseQuotedIdentifier();\n if (s5 !== peg$FAILED) {\n s6 = peg$parseWhiteSpace();\n if (s6 === peg$FAILED) {\n s6 = peg$c2;\n }\n if (s6 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 41) {\n s7 = peg$c18;\n peg$currPos++;\n } else {\n s7 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c19); }\n }\n if (s7 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c34(s5);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n }\n }\n }\n }\n\n return s0;\n }\n\n function peg$parseMQLIf() {\n var s0, s1, s2, s3, s4, s5, s6, s7;\n\n s0 = peg$currPos;\n s1 = peg$parseMQLOpen();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseWhiteSpace();\n if (s2 === peg$FAILED) {\n s2 = peg$c2;\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parseIf();\n if (s3 !== peg$FAILED) {\n s4 = peg$parseWhiteSpace();\n if (s4 === peg$FAILED) {\n s4 = peg$c2;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseMQLCondition();\n if (s5 !== peg$FAILED) {\n s6 = peg$parseWhiteSpace();\n if (s6 === peg$FAILED) {\n s6 = peg$c2;\n }\n if (s6 !== peg$FAILED) {\n s7 = peg$parseMQLClose();\n if (s7 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c23(s5);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseMQLElseIf() {\n var s0, s1, s2, s3, s4, s5, s6, s7;\n\n s0 = peg$currPos;\n s1 = peg$parseMQLOpen();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseWhiteSpace();\n if (s2 === peg$FAILED) {\n s2 = peg$c2;\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parseElseIf();\n if (s3 !== peg$FAILED) {\n s4 = peg$parseWhiteSpace();\n if (s4 === peg$FAILED) {\n s4 = peg$c2;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseMQLCondition();\n if (s5 !== peg$FAILED) {\n s6 = peg$parseWhiteSpace();\n if (s6 === peg$FAILED) {\n s6 = peg$c2;\n }\n if (s6 !== peg$FAILED) {\n s7 = peg$parseMQLClose();\n if (s7 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c23(s5);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseMQLElse() {\n var s0, s1, s2, s3, s4, s5;\n\n s0 = peg$currPos;\n s1 = peg$parseMQLOpen();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseWhiteSpace();\n if (s2 === peg$FAILED) {\n s2 = peg$c2;\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parseElse();\n if (s3 !== peg$FAILED) {\n s4 = peg$parseWhiteSpace();\n if (s4 === peg$FAILED) {\n s4 = peg$c2;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseMQLClose();\n if (s5 !== peg$FAILED) {\n s1 = [s1, s2, s3, s4, s5];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseMQLEndIf() {\n var s0, s1, s2, s3, s4, s5;\n\n s0 = peg$currPos;\n s1 = peg$parseMQLOpen();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseWhiteSpace();\n if (s2 === peg$FAILED) {\n s2 = peg$c2;\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parseEndIf();\n if (s3 !== peg$FAILED) {\n s4 = peg$parseWhiteSpace();\n if (s4 === peg$FAILED) {\n s4 = peg$c2;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseMQLClose();\n if (s5 !== peg$FAILED) {\n s1 = [s1, s2, s3, s4, s5];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseMQLForeach() {\n var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11;\n\n s0 = peg$currPos;\n s1 = peg$parseMQLOpen();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseWhiteSpace();\n if (s2 === peg$FAILED) {\n s2 = peg$c2;\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parseForeach();\n if (s3 !== peg$FAILED) {\n s4 = peg$parseWhiteSpace();\n if (s4 === peg$FAILED) {\n s4 = peg$c2;\n }\n if (s4 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 40) {\n s5 = peg$c16;\n peg$currPos++;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c17); }\n }\n if (s5 !== peg$FAILED) {\n s6 = peg$parseWhiteSpace();\n if (s6 === peg$FAILED) {\n s6 = peg$c2;\n }\n if (s6 !== peg$FAILED) {\n s7 = peg$parseQuotedIdentifier();\n if (s7 !== peg$FAILED) {\n s8 = peg$parseWhiteSpace();\n if (s8 === peg$FAILED) {\n s8 = peg$c2;\n }\n if (s8 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 41) {\n s9 = peg$c18;\n peg$currPos++;\n } else {\n s9 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c19); }\n }\n if (s9 !== peg$FAILED) {\n s10 = peg$parseWhiteSpace();\n if (s10 === peg$FAILED) {\n s10 = peg$c2;\n }\n if (s10 !== peg$FAILED) {\n s11 = peg$parseMQLClose();\n if (s11 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c35(s7);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseMQLEndForeach() {\n var s0, s1, s2, s3, s4, s5;\n\n s0 = peg$currPos;\n s1 = peg$parseMQLOpen();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseWhiteSpace();\n if (s2 === peg$FAILED) {\n s2 = peg$c2;\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parseEndForeach();\n if (s3 !== peg$FAILED) {\n s4 = peg$parseWhiteSpace();\n if (s4 === peg$FAILED) {\n s4 = peg$c2;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseMQLClose();\n if (s5 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c36();\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseForEachWrapper() {\n var s0, s1, s2, s3, s4, s5, s6;\n\n s0 = peg$currPos;\n s1 = peg$parseMQLForeach();\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$currPos;\n s4 = peg$currPos;\n peg$silentFails++;\n s5 = peg$parseMQLEndForeach();\n peg$silentFails--;\n if (s5 === peg$FAILED) {\n s4 = peg$c24;\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseForEachWrapper();\n if (s5 === peg$FAILED) {\n s5 = peg$c2;\n }\n if (s5 !== peg$FAILED) {\n s6 = peg$parseSourceCharacter();\n if (s6 !== peg$FAILED) {\n s4 = [s4, s5, s6];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$currPos;\n s4 = peg$currPos;\n peg$silentFails++;\n s5 = peg$parseMQLEndForeach();\n peg$silentFails--;\n if (s5 === peg$FAILED) {\n s4 = peg$c24;\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseForEachWrapper();\n if (s5 === peg$FAILED) {\n s5 = peg$c2;\n }\n if (s5 !== peg$FAILED) {\n s6 = peg$parseSourceCharacter();\n if (s6 !== peg$FAILED) {\n s4 = [s4, s5, s6];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parseMQLEndForeach();\n if (s3 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c37(s1, s2, s3);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseMQLLoopFunction() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n s1 = peg$parseContinue();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseWhiteSpace();\n if (s2 === peg$FAILED) {\n s2 = peg$c2;\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parseMQLLoopCount();\n if (s3 === peg$FAILED) {\n s3 = peg$c2;\n }\n if (s3 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c38(s3);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parseBreak();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseWhiteSpace();\n if (s2 === peg$FAILED) {\n s2 = peg$c2;\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parseMQLLoopCount();\n if (s3 === peg$FAILED) {\n s3 = peg$c2;\n }\n if (s3 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c39(s3);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n }\n\n return s0;\n }\n\n function peg$parseMQLLoopCount() {\n var s0, s1, s2, s3, s4, s5;\n\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 40) {\n s1 = peg$c16;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c17); }\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$parseWhiteSpace();\n if (s2 === peg$FAILED) {\n s2 = peg$c2;\n }\n if (s2 !== peg$FAILED) {\n s3 = [];\n s4 = peg$parseDecimalDigit();\n while (s4 !== peg$FAILED) {\n s3.push(s4);\n s4 = peg$parseDecimalDigit();\n }\n if (s3 !== peg$FAILED) {\n s4 = peg$parseWhiteSpace();\n if (s4 === peg$FAILED) {\n s4 = peg$c2;\n }\n if (s4 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 41) {\n s5 = peg$c18;\n peg$currPos++;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c19); }\n }\n if (s5 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c22(s3);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseMQLOpen() {\n var s0;\n\n if (input.substr(peg$currPos, 2) === peg$c40) {\n s0 = peg$c40;\n peg$currPos += 2;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c41); }\n }\n\n return s0;\n }\n\n function peg$parseMQLClose() {\n var s0;\n\n if (input.substr(peg$currPos, 2) === peg$c42) {\n s0 = peg$c42;\n peg$currPos += 2;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c43); }\n }\n\n return s0;\n }\n\n function peg$parseValue() {\n var s0, s1, s2, s3, s4, s5;\n\n s0 = peg$currPos;\n if (peg$c44.test(input.charAt(peg$currPos))) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c45); }\n }\n if (s1 !== peg$FAILED) {\n if (peg$c46.test(input.charAt(peg$currPos))) {\n s2 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c47); }\n }\n if (s2 !== peg$FAILED) {\n if (peg$c48.test(input.charAt(peg$currPos))) {\n s3 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c49); }\n }\n if (s3 !== peg$FAILED) {\n if (peg$c50.test(input.charAt(peg$currPos))) {\n s4 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s4 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c51); }\n }\n if (s4 !== peg$FAILED) {\n if (peg$c52.test(input.charAt(peg$currPos))) {\n s5 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c53); }\n }\n if (s5 !== peg$FAILED) {\n s1 = [s1, s2, s3, s4, s5];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseLiteral() {\n var s0, s1, s2, s3, s4, s5, s6, s7;\n\n s0 = peg$currPos;\n if (peg$c48.test(input.charAt(peg$currPos))) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c49); }\n }\n if (s1 !== peg$FAILED) {\n if (peg$c54.test(input.charAt(peg$currPos))) {\n s2 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c55); }\n }\n if (s2 !== peg$FAILED) {\n if (peg$c56.test(input.charAt(peg$currPos))) {\n s3 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c57); }\n }\n if (s3 !== peg$FAILED) {\n if (peg$c52.test(input.charAt(peg$currPos))) {\n s4 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s4 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c53); }\n }\n if (s4 !== peg$FAILED) {\n if (peg$c58.test(input.charAt(peg$currPos))) {\n s5 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c59); }\n }\n if (s5 !== peg$FAILED) {\n if (peg$c46.test(input.charAt(peg$currPos))) {\n s6 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s6 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c47); }\n }\n if (s6 !== peg$FAILED) {\n if (peg$c48.test(input.charAt(peg$currPos))) {\n s7 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s7 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c49); }\n }\n if (s7 !== peg$FAILED) {\n s1 = [s1, s2, s3, s4, s5, s6, s7];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseIf() {\n var s0, s1, s2;\n\n s0 = peg$currPos;\n if (peg$c54.test(input.charAt(peg$currPos))) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c55); }\n }\n if (s1 !== peg$FAILED) {\n if (peg$c60.test(input.charAt(peg$currPos))) {\n s2 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c61); }\n }\n if (s2 !== peg$FAILED) {\n s1 = [s1, s2];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseElseIf() {\n var s0, s1, s2, s3, s4, s5, s6;\n\n s0 = peg$currPos;\n if (peg$c52.test(input.charAt(peg$currPos))) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c53); }\n }\n if (s1 !== peg$FAILED) {\n if (peg$c48.test(input.charAt(peg$currPos))) {\n s2 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c49); }\n }\n if (s2 !== peg$FAILED) {\n if (peg$c62.test(input.charAt(peg$currPos))) {\n s3 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c63); }\n }\n if (s3 !== peg$FAILED) {\n if (peg$c52.test(input.charAt(peg$currPos))) {\n s4 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s4 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c53); }\n }\n if (s4 !== peg$FAILED) {\n if (peg$c54.test(input.charAt(peg$currPos))) {\n s5 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c55); }\n }\n if (s5 !== peg$FAILED) {\n if (peg$c60.test(input.charAt(peg$currPos))) {\n s6 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s6 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c61); }\n }\n if (s6 !== peg$FAILED) {\n s1 = [s1, s2, s3, s4, s5, s6];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseElse() {\n var s0, s1, s2, s3, s4;\n\n s0 = peg$currPos;\n if (peg$c52.test(input.charAt(peg$currPos))) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c53); }\n }\n if (s1 !== peg$FAILED) {\n if (peg$c48.test(input.charAt(peg$currPos))) {\n s2 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c49); }\n }\n if (s2 !== peg$FAILED) {\n if (peg$c62.test(input.charAt(peg$currPos))) {\n s3 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c63); }\n }\n if (s3 !== peg$FAILED) {\n if (peg$c52.test(input.charAt(peg$currPos))) {\n s4 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s4 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c53); }\n }\n if (s4 !== peg$FAILED) {\n s1 = [s1, s2, s3, s4];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseEndIf() {\n var s0, s1, s2, s3, s4, s5;\n\n s0 = peg$currPos;\n if (peg$c52.test(input.charAt(peg$currPos))) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c53); }\n }\n if (s1 !== peg$FAILED) {\n if (peg$c64.test(input.charAt(peg$currPos))) {\n s2 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c65); }\n }\n if (s2 !== peg$FAILED) {\n if (peg$c66.test(input.charAt(peg$currPos))) {\n s3 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c67); }\n }\n if (s3 !== peg$FAILED) {\n if (peg$c54.test(input.charAt(peg$currPos))) {\n s4 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s4 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c55); }\n }\n if (s4 !== peg$FAILED) {\n if (peg$c60.test(input.charAt(peg$currPos))) {\n s5 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c61); }\n }\n if (s5 !== peg$FAILED) {\n s1 = [s1, s2, s3, s4, s5];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseNot() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n if (peg$c64.test(input.charAt(peg$currPos))) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c65); }\n }\n if (s1 !== peg$FAILED) {\n if (peg$c68.test(input.charAt(peg$currPos))) {\n s2 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c69); }\n }\n if (s2 !== peg$FAILED) {\n if (peg$c56.test(input.charAt(peg$currPos))) {\n s3 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c57); }\n }\n if (s3 !== peg$FAILED) {\n s1 = [s1, s2, s3];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseExists() {\n var s0, s1, s2, s3, s4, s5, s6;\n\n s0 = peg$currPos;\n if (peg$c52.test(input.charAt(peg$currPos))) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c53); }\n }\n if (s1 !== peg$FAILED) {\n if (peg$c70.test(input.charAt(peg$currPos))) {\n s2 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c71); }\n }\n if (s2 !== peg$FAILED) {\n if (peg$c54.test(input.charAt(peg$currPos))) {\n s3 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c55); }\n }\n if (s3 !== peg$FAILED) {\n if (peg$c62.test(input.charAt(peg$currPos))) {\n s4 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s4 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c63); }\n }\n if (s4 !== peg$FAILED) {\n if (peg$c56.test(input.charAt(peg$currPos))) {\n s5 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c57); }\n }\n if (s5 !== peg$FAILED) {\n if (peg$c62.test(input.charAt(peg$currPos))) {\n s6 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s6 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c63); }\n }\n if (s6 !== peg$FAILED) {\n s1 = [s1, s2, s3, s4, s5, s6];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseReExists() {\n var s0, s1, s2, s3, s4, s5, s6, s7, s8;\n\n s0 = peg$currPos;\n if (peg$c58.test(input.charAt(peg$currPos))) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c59); }\n }\n if (s1 !== peg$FAILED) {\n if (peg$c52.test(input.charAt(peg$currPos))) {\n s2 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c53); }\n }\n if (s2 !== peg$FAILED) {\n if (peg$c52.test(input.charAt(peg$currPos))) {\n s3 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c53); }\n }\n if (s3 !== peg$FAILED) {\n if (peg$c70.test(input.charAt(peg$currPos))) {\n s4 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s4 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c71); }\n }\n if (s4 !== peg$FAILED) {\n if (peg$c54.test(input.charAt(peg$currPos))) {\n s5 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c55); }\n }\n if (s5 !== peg$FAILED) {\n if (peg$c62.test(input.charAt(peg$currPos))) {\n s6 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s6 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c63); }\n }\n if (s6 !== peg$FAILED) {\n if (peg$c56.test(input.charAt(peg$currPos))) {\n s7 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s7 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c57); }\n }\n if (s7 !== peg$FAILED) {\n if (peg$c62.test(input.charAt(peg$currPos))) {\n s8 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s8 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c63); }\n }\n if (s8 !== peg$FAILED) {\n s1 = [s1, s2, s3, s4, s5, s6, s7, s8];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseIsFirst() {\n var s0, s1, s2, s3, s4, s5, s6, s7;\n\n s0 = peg$currPos;\n if (peg$c54.test(input.charAt(peg$currPos))) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c55); }\n }\n if (s1 !== peg$FAILED) {\n if (peg$c62.test(input.charAt(peg$currPos))) {\n s2 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c63); }\n }\n if (s2 !== peg$FAILED) {\n if (peg$c60.test(input.charAt(peg$currPos))) {\n s3 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c61); }\n }\n if (s3 !== peg$FAILED) {\n if (peg$c54.test(input.charAt(peg$currPos))) {\n s4 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s4 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c55); }\n }\n if (s4 !== peg$FAILED) {\n if (peg$c58.test(input.charAt(peg$currPos))) {\n s5 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c59); }\n }\n if (s5 !== peg$FAILED) {\n if (peg$c62.test(input.charAt(peg$currPos))) {\n s6 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s6 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c63); }\n }\n if (s6 !== peg$FAILED) {\n if (peg$c56.test(input.charAt(peg$currPos))) {\n s7 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s7 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c57); }\n }\n if (s7 !== peg$FAILED) {\n s1 = [s1, s2, s3, s4, s5, s6, s7];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseIsLast() {\n var s0, s1, s2, s3, s4, s5, s6;\n\n s0 = peg$currPos;\n if (peg$c54.test(input.charAt(peg$currPos))) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c55); }\n }\n if (s1 !== peg$FAILED) {\n if (peg$c62.test(input.charAt(peg$currPos))) {\n s2 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c63); }\n }\n if (s2 !== peg$FAILED) {\n if (peg$c48.test(input.charAt(peg$currPos))) {\n s3 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c49); }\n }\n if (s3 !== peg$FAILED) {\n if (peg$c46.test(input.charAt(peg$currPos))) {\n s4 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s4 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c47); }\n }\n if (s4 !== peg$FAILED) {\n if (peg$c62.test(input.charAt(peg$currPos))) {\n s5 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c63); }\n }\n if (s5 !== peg$FAILED) {\n if (peg$c56.test(input.charAt(peg$currPos))) {\n s6 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s6 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c57); }\n }\n if (s6 !== peg$FAILED) {\n s1 = [s1, s2, s3, s4, s5, s6];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseForeach() {\n var s0, s1, s2, s3, s4, s5, s6, s7;\n\n s0 = peg$currPos;\n if (peg$c60.test(input.charAt(peg$currPos))) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c61); }\n }\n if (s1 !== peg$FAILED) {\n if (peg$c68.test(input.charAt(peg$currPos))) {\n s2 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c69); }\n }\n if (s2 !== peg$FAILED) {\n if (peg$c58.test(input.charAt(peg$currPos))) {\n s3 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c59); }\n }\n if (s3 !== peg$FAILED) {\n if (peg$c52.test(input.charAt(peg$currPos))) {\n s4 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s4 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c53); }\n }\n if (s4 !== peg$FAILED) {\n if (peg$c46.test(input.charAt(peg$currPos))) {\n s5 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c47); }\n }\n if (s5 !== peg$FAILED) {\n if (peg$c72.test(input.charAt(peg$currPos))) {\n s6 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s6 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c73); }\n }\n if (s6 !== peg$FAILED) {\n if (peg$c74.test(input.charAt(peg$currPos))) {\n s7 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s7 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c75); }\n }\n if (s7 !== peg$FAILED) {\n s1 = [s1, s2, s3, s4, s5, s6, s7];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseEndForeach() {\n var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;\n\n s0 = peg$currPos;\n if (peg$c52.test(input.charAt(peg$currPos))) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c53); }\n }\n if (s1 !== peg$FAILED) {\n if (peg$c64.test(input.charAt(peg$currPos))) {\n s2 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c65); }\n }\n if (s2 !== peg$FAILED) {\n if (peg$c66.test(input.charAt(peg$currPos))) {\n s3 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c67); }\n }\n if (s3 !== peg$FAILED) {\n if (peg$c60.test(input.charAt(peg$currPos))) {\n s4 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s4 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c61); }\n }\n if (s4 !== peg$FAILED) {\n if (peg$c68.test(input.charAt(peg$currPos))) {\n s5 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c69); }\n }\n if (s5 !== peg$FAILED) {\n if (peg$c58.test(input.charAt(peg$currPos))) {\n s6 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s6 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c59); }\n }\n if (s6 !== peg$FAILED) {\n if (peg$c52.test(input.charAt(peg$currPos))) {\n s7 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s7 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c53); }\n }\n if (s7 !== peg$FAILED) {\n if (peg$c46.test(input.charAt(peg$currPos))) {\n s8 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s8 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c47); }\n }\n if (s8 !== peg$FAILED) {\n if (peg$c72.test(input.charAt(peg$currPos))) {\n s9 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s9 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c73); }\n }\n if (s9 !== peg$FAILED) {\n if (peg$c74.test(input.charAt(peg$currPos))) {\n s10 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s10 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c75); }\n }\n if (s10 !== peg$FAILED) {\n s1 = [s1, s2, s3, s4, s5, s6, s7, s8, s9, s10];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseContinue() {\n var s0, s1, s2, s3, s4, s5, s6, s7, s8;\n\n s0 = peg$currPos;\n if (peg$c72.test(input.charAt(peg$currPos))) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c73); }\n }\n if (s1 !== peg$FAILED) {\n if (peg$c68.test(input.charAt(peg$currPos))) {\n s2 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c69); }\n }\n if (s2 !== peg$FAILED) {\n if (peg$c64.test(input.charAt(peg$currPos))) {\n s3 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c65); }\n }\n if (s3 !== peg$FAILED) {\n if (peg$c56.test(input.charAt(peg$currPos))) {\n s4 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s4 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c57); }\n }\n if (s4 !== peg$FAILED) {\n if (peg$c54.test(input.charAt(peg$currPos))) {\n s5 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c55); }\n }\n if (s5 !== peg$FAILED) {\n if (peg$c64.test(input.charAt(peg$currPos))) {\n s6 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s6 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c65); }\n }\n if (s6 !== peg$FAILED) {\n if (peg$c50.test(input.charAt(peg$currPos))) {\n s7 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s7 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c51); }\n }\n if (s7 !== peg$FAILED) {\n if (peg$c52.test(input.charAt(peg$currPos))) {\n s8 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s8 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c53); }\n }\n if (s8 !== peg$FAILED) {\n s1 = [s1, s2, s3, s4, s5, s6, s7, s8];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseBreak() {\n var s0, s1, s2, s3, s4, s5;\n\n s0 = peg$currPos;\n if (peg$c76.test(input.charAt(peg$currPos))) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c77); }\n }\n if (s1 !== peg$FAILED) {\n if (peg$c58.test(input.charAt(peg$currPos))) {\n s2 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c59); }\n }\n if (s2 !== peg$FAILED) {\n if (peg$c52.test(input.charAt(peg$currPos))) {\n s3 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c53); }\n }\n if (s3 !== peg$FAILED) {\n if (peg$c46.test(input.charAt(peg$currPos))) {\n s4 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s4 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c47); }\n }\n if (s4 !== peg$FAILED) {\n if (peg$c78.test(input.charAt(peg$currPos))) {\n s5 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c79); }\n }\n if (s5 !== peg$FAILED) {\n s1 = [s1, s2, s3, s4, s5];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseSQLText() {\n var s0, s1;\n\n s0 = peg$currPos;\n s1 = peg$parseSQLPattern();\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c80(s1);\n }\n s0 = s1;\n\n return s0;\n }\n\n function peg$parseSQLPattern() {\n var s0, s1;\n\n s0 = peg$currPos;\n s1 = peg$parseSourceCharacter();\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c81(s1);\n }\n s0 = s1;\n\n return s0;\n }\n\n function peg$parseSourceCharacter() {\n var s0;\n\n if (input.length > peg$currPos) {\n s0 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c82); }\n }\n\n return s0;\n }\n\n function peg$parseWhiteSpace() {\n var s0, s1;\n\n peg$silentFails++;\n if (input.charCodeAt(peg$currPos) === 9) {\n s0 = peg$c84;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c85); }\n }\n if (s0 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 11) {\n s0 = peg$c86;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c87); }\n }\n if (s0 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 12) {\n s0 = peg$c88;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c89); }\n }\n if (s0 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 32) {\n s0 = peg$c90;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c91); }\n }\n if (s0 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 160) {\n s0 = peg$c92;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c93); }\n }\n if (s0 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 65279) {\n s0 = peg$c94;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c95); }\n }\n if (s0 === peg$FAILED) {\n s0 = peg$parseZs();\n }\n }\n }\n }\n }\n }\n peg$silentFails--;\n if (s0 === peg$FAILED) {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c83); }\n }\n\n return s0;\n }\n\n function peg$parseLineTerminator() {\n var s0, s1;\n\n s0 = peg$currPos;\n if (peg$c96.test(input.charAt(peg$currPos))) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c97); }\n }\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c98(s1);\n }\n s0 = s1;\n\n return s0;\n }\n\n function peg$parseLineTerminatorSequence() {\n var s0, s1;\n\n peg$silentFails++;\n if (input.charCodeAt(peg$currPos) === 10) {\n s0 = peg$c100;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c101); }\n }\n if (s0 === peg$FAILED) {\n if (input.substr(peg$currPos, 2) === peg$c102) {\n s0 = peg$c102;\n peg$currPos += 2;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c103); }\n }\n if (s0 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 13) {\n s0 = peg$c104;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c105); }\n }\n if (s0 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 8232) {\n s0 = peg$c106;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c107); }\n }\n if (s0 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 8233) {\n s0 = peg$c108;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c109); }\n }\n }\n }\n }\n }\n peg$silentFails--;\n if (s0 === peg$FAILED) {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c99); }\n }\n\n return s0;\n }\n\n function peg$parseDecimalDigit() {\n var s0;\n\n if (peg$c110.test(input.charAt(peg$currPos))) {\n s0 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c111); }\n }\n\n return s0;\n }\n\n function peg$parseHexDigit() {\n var s0;\n\n if (peg$c112.test(input.charAt(peg$currPos))) {\n s0 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c113); }\n }\n\n return s0;\n }\n\n function peg$parseRegExp() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 39) {\n s1 = peg$c114;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c115); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n if (peg$c116.test(input.charAt(peg$currPos))) {\n s3 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c117); }\n }\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n if (peg$c116.test(input.charAt(peg$currPos))) {\n s3 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c117); }\n }\n }\n if (s2 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 39) {\n s3 = peg$c114;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c115); }\n }\n if (s3 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c118(s2);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 34) {\n s1 = peg$c119;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c120); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n if (peg$c121.test(input.charAt(peg$currPos))) {\n s3 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c122); }\n }\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n if (peg$c121.test(input.charAt(peg$currPos))) {\n s3 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c122); }\n }\n }\n if (s2 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 34) {\n s3 = peg$c119;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c120); }\n }\n if (s3 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c118(s2);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n }\n\n return s0;\n }\n\n function peg$parseComment() {\n var s0, s1;\n\n peg$silentFails++;\n s0 = peg$parseMultiLineComment();\n if (s0 === peg$FAILED) {\n s0 = peg$parseSingleLineComment();\n }\n peg$silentFails--;\n if (s0 === peg$FAILED) {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c123); }\n }\n\n return s0;\n }\n\n function peg$parseMultiLineComment() {\n var s0, s1, s2, s3, s4, s5;\n\n s0 = peg$currPos;\n if (input.substr(peg$currPos, 2) === peg$c124) {\n s1 = peg$c124;\n peg$currPos += 2;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c125); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$currPos;\n s4 = peg$currPos;\n peg$silentFails++;\n if (input.substr(peg$currPos, 2) === peg$c126) {\n s5 = peg$c126;\n peg$currPos += 2;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c127); }\n }\n peg$silentFails--;\n if (s5 === peg$FAILED) {\n s4 = peg$c24;\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseSourceCharacter();\n if (s5 !== peg$FAILED) {\n s4 = [s4, s5];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$currPos;\n s4 = peg$currPos;\n peg$silentFails++;\n if (input.substr(peg$currPos, 2) === peg$c126) {\n s5 = peg$c126;\n peg$currPos += 2;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c127); }\n }\n peg$silentFails--;\n if (s5 === peg$FAILED) {\n s4 = peg$c24;\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseSourceCharacter();\n if (s5 !== peg$FAILED) {\n s4 = [s4, s5];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n }\n if (s2 !== peg$FAILED) {\n if (input.substr(peg$currPos, 2) === peg$c126) {\n s3 = peg$c126;\n peg$currPos += 2;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c127); }\n }\n if (s3 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c29(s1, s2, s3);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseMultiLineCommentNoLineTerminator() {\n var s0, s1, s2, s3, s4, s5;\n\n s0 = peg$currPos;\n if (input.substr(peg$currPos, 2) === peg$c124) {\n s1 = peg$c124;\n peg$currPos += 2;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c125); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$currPos;\n s4 = peg$currPos;\n peg$silentFails++;\n if (input.substr(peg$currPos, 2) === peg$c126) {\n s5 = peg$c126;\n peg$currPos += 2;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c127); }\n }\n if (s5 === peg$FAILED) {\n s5 = peg$parseLineTerminator();\n }\n peg$silentFails--;\n if (s5 === peg$FAILED) {\n s4 = peg$c24;\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseSourceCharacter();\n if (s5 !== peg$FAILED) {\n s4 = [s4, s5];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$currPos;\n s4 = peg$currPos;\n peg$silentFails++;\n if (input.substr(peg$currPos, 2) === peg$c126) {\n s5 = peg$c126;\n peg$currPos += 2;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c127); }\n }\n if (s5 === peg$FAILED) {\n s5 = peg$parseLineTerminator();\n }\n peg$silentFails--;\n if (s5 === peg$FAILED) {\n s4 = peg$c24;\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseSourceCharacter();\n if (s5 !== peg$FAILED) {\n s4 = [s4, s5];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n }\n if (s2 !== peg$FAILED) {\n if (input.substr(peg$currPos, 2) === peg$c126) {\n s3 = peg$c126;\n peg$currPos += 2;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c127); }\n }\n if (s3 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c29(s1, s2, s3);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseSingleLineComment() {\n var s0, s1, s2, s3, s4, s5;\n\n s0 = peg$currPos;\n if (input.substr(peg$currPos, 2) === peg$c128) {\n s1 = peg$c128;\n peg$currPos += 2;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c129); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$currPos;\n s4 = peg$currPos;\n peg$silentFails++;\n s5 = peg$parseLineTerminator();\n peg$silentFails--;\n if (s5 === peg$FAILED) {\n s4 = peg$c24;\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseSourceCharacter();\n if (s5 !== peg$FAILED) {\n s4 = [s4, s5];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$currPos;\n s4 = peg$currPos;\n peg$silentFails++;\n s5 = peg$parseLineTerminator();\n peg$silentFails--;\n if (s5 === peg$FAILED) {\n s4 = peg$c24;\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseSourceCharacter();\n if (s5 !== peg$FAILED) {\n s4 = [s4, s5];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n }\n if (s2 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c130(s1, s2);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseQuotedIdentifier() {\n var s0, s1;\n\n peg$silentFails++;\n s0 = peg$parseSingleQuotedIdentifier();\n if (s0 === peg$FAILED) {\n s0 = peg$parseDoubleQuotedIdentifier();\n }\n peg$silentFails--;\n if (s0 === peg$FAILED) {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c131); }\n }\n\n return s0;\n }\n\n function peg$parseSingleQuotedIdentifier() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 39) {\n s1 = peg$c114;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c115); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parseSingleStringCharacter();\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parseSingleStringCharacter();\n }\n if (s2 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 39) {\n s3 = peg$c114;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c115); }\n }\n if (s3 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c132(s1, s2, s3);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseDoubleQuotedIdentifier() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 34) {\n s1 = peg$c119;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c120); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parseDoubleStringCharacter();\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parseDoubleStringCharacter();\n }\n if (s2 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 34) {\n s3 = peg$c119;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c120); }\n }\n if (s3 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c132(s1, s2, s3);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseQuotedString() {\n var s0, s1;\n\n peg$silentFails++;\n s0 = peg$parseSingleQuotedString();\n if (s0 === peg$FAILED) {\n s0 = peg$parseDoubleQuotedString();\n }\n peg$silentFails--;\n if (s0 === peg$FAILED) {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c133); }\n }\n\n return s0;\n }\n\n function peg$parseSingleQuotedString() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 39) {\n s1 = peg$c114;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c115); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parseSingleStringCharacter();\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parseSingleStringCharacter();\n }\n if (s2 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 39) {\n s3 = peg$c114;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c115); }\n }\n if (s3 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c134(s1, s2, s3);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseDoubleQuotedString() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 34) {\n s1 = peg$c119;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c120); }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parseDoubleStringCharacter();\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parseDoubleStringCharacter();\n }\n if (s2 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 34) {\n s3 = peg$c119;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c120); }\n }\n if (s3 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c134(s1, s2, s3);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseDoubleStringCharacter() {\n var s0, s1, s2;\n\n s0 = peg$currPos;\n s1 = peg$currPos;\n peg$silentFails++;\n if (input.charCodeAt(peg$currPos) === 34) {\n s2 = peg$c119;\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c120); }\n }\n if (s2 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 92) {\n s2 = peg$c135;\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c136); }\n }\n if (s2 === peg$FAILED) {\n s2 = peg$parseLineTerminator();\n }\n }\n peg$silentFails--;\n if (s2 === peg$FAILED) {\n s1 = peg$c24;\n } else {\n peg$currPos = s1;\n s1 = peg$c0;\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$parseSourceCharacter();\n if (s2 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c36();\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 92) {\n s1 = peg$c135;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c136); }\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$parseEscapeSequence();\n if (s2 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c137(s2);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$parseLineContinuation();\n }\n }\n\n return s0;\n }\n\n function peg$parseSingleStringCharacter() {\n var s0, s1, s2;\n\n s0 = peg$currPos;\n s1 = peg$currPos;\n peg$silentFails++;\n if (input.charCodeAt(peg$currPos) === 39) {\n s2 = peg$c114;\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c115); }\n }\n if (s2 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 92) {\n s2 = peg$c135;\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c136); }\n }\n if (s2 === peg$FAILED) {\n s2 = peg$parseLineTerminator();\n }\n }\n peg$silentFails--;\n if (s2 === peg$FAILED) {\n s1 = peg$c24;\n } else {\n peg$currPos = s1;\n s1 = peg$c0;\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$parseSourceCharacter();\n if (s2 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c36();\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 92) {\n s1 = peg$c135;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c136); }\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$parseEscapeSequence();\n if (s2 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c137(s2);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$parseLineContinuation();\n }\n }\n\n return s0;\n }\n\n function peg$parseLineContinuation() {\n var s0, s1, s2;\n\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 92) {\n s1 = peg$c135;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c136); }\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$parseLineTerminatorSequence();\n if (s2 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c138();\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseEscapeSequence() {\n var s0, s1, s2, s3;\n\n s0 = peg$parseCharacterEscapeSequence();\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 48) {\n s1 = peg$c139;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c140); }\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$currPos;\n peg$silentFails++;\n s3 = peg$parseDecimalDigit();\n peg$silentFails--;\n if (s3 === peg$FAILED) {\n s2 = peg$c24;\n } else {\n peg$currPos = s2;\n s2 = peg$c0;\n }\n if (s2 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c141();\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$parseHexEscapeSequence();\n if (s0 === peg$FAILED) {\n s0 = peg$parseUnicodeEscapeSequence();\n }\n }\n }\n\n return s0;\n }\n\n function peg$parseCharacterEscapeSequence() {\n var s0;\n\n s0 = peg$parseSingleEscapeCharacter();\n if (s0 === peg$FAILED) {\n s0 = peg$parseNonEscapeCharacter();\n }\n\n return s0;\n }\n\n function peg$parseSingleEscapeCharacter() {\n var s0, s1;\n\n if (input.charCodeAt(peg$currPos) === 39) {\n s0 = peg$c114;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c115); }\n }\n if (s0 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 34) {\n s0 = peg$c119;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c120); }\n }\n if (s0 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 92) {\n s0 = peg$c135;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c136); }\n }\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 98) {\n s1 = peg$c142;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c143); }\n }\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c144();\n }\n s0 = s1;\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 102) {\n s1 = peg$c145;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c146); }\n }\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c147();\n }\n s0 = s1;\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 110) {\n s1 = peg$c148;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c149); }\n }\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c150();\n }\n s0 = s1;\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 114) {\n s1 = peg$c151;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c152); }\n }\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c153();\n }\n s0 = s1;\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 116) {\n s1 = peg$c154;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c155); }\n }\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c156();\n }\n s0 = s1;\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 118) {\n s1 = peg$c157;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c158); }\n }\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c159();\n }\n s0 = s1;\n }\n }\n }\n }\n }\n }\n }\n }\n\n return s0;\n }\n\n function peg$parseNonEscapeCharacter() {\n var s0, s1, s2;\n\n s0 = peg$currPos;\n s1 = peg$currPos;\n peg$silentFails++;\n s2 = peg$parseEscapeCharacter();\n if (s2 === peg$FAILED) {\n s2 = peg$parseLineTerminator();\n }\n peg$silentFails--;\n if (s2 === peg$FAILED) {\n s1 = peg$c24;\n } else {\n peg$currPos = s1;\n s1 = peg$c0;\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$parseSourceCharacter();\n if (s2 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c36();\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseEscapeCharacter() {\n var s0;\n\n s0 = peg$parseSingleEscapeCharacter();\n if (s0 === peg$FAILED) {\n s0 = peg$parseDecimalDigit();\n if (s0 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 120) {\n s0 = peg$c160;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c161); }\n }\n if (s0 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 117) {\n s0 = peg$c162;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c163); }\n }\n }\n }\n }\n\n return s0;\n }\n\n function peg$parseHexEscapeSequence() {\n var s0, s1, s2, s3, s4, s5;\n\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 120) {\n s1 = peg$c160;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c161); }\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$currPos;\n s3 = peg$currPos;\n s4 = peg$parseHexDigit();\n if (s4 !== peg$FAILED) {\n s5 = peg$parseHexDigit();\n if (s5 !== peg$FAILED) {\n s4 = [s4, s5];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n if (s3 !== peg$FAILED) {\n s3 = input.substring(s2, peg$currPos);\n }\n s2 = s3;\n if (s2 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c164(s2);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseUnicodeEscapeSequence() {\n var s0, s1, s2, s3, s4, s5, s6, s7;\n\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 117) {\n s1 = peg$c162;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c163); }\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$currPos;\n s3 = peg$currPos;\n s4 = peg$parseHexDigit();\n if (s4 !== peg$FAILED) {\n s5 = peg$parseHexDigit();\n if (s5 !== peg$FAILED) {\n s6 = peg$parseHexDigit();\n if (s6 !== peg$FAILED) {\n s7 = peg$parseHexDigit();\n if (s7 !== peg$FAILED) {\n s4 = [s4, s5, s6, s7];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n if (s3 !== peg$FAILED) {\n s3 = input.substring(s2, peg$currPos);\n }\n s2 = s3;\n if (s2 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c164(s2);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parse__() {\n var s0, s1;\n\n s0 = [];\n s1 = peg$parseWhiteSpace();\n if (s1 === peg$FAILED) {\n s1 = peg$parseLineTerminatorSequence();\n if (s1 === peg$FAILED) {\n s1 = peg$parseComment();\n }\n }\n while (s1 !== peg$FAILED) {\n s0.push(s1);\n s1 = peg$parseWhiteSpace();\n if (s1 === peg$FAILED) {\n s1 = peg$parseLineTerminatorSequence();\n if (s1 === peg$FAILED) {\n s1 = peg$parseComment();\n }\n }\n }\n\n return s0;\n }\n\n function peg$parse_() {\n var s0, s1;\n\n s0 = [];\n s1 = peg$parseWhiteSpace();\n if (s1 === peg$FAILED) {\n s1 = peg$parseMultiLineCommentNoLineTerminator();\n }\n while (s1 !== peg$FAILED) {\n s0.push(s1);\n s1 = peg$parseWhiteSpace();\n if (s1 === peg$FAILED) {\n s1 = peg$parseMultiLineCommentNoLineTerminator();\n }\n }\n\n return s0;\n }\n\n function peg$parseZs() {\n var s0;\n\n if (peg$c165.test(input.charAt(peg$currPos))) {\n s0 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c166); }\n }\n\n return s0;\n }\n\n\n // The default params below are for the MetaSQL test here: https://github.com/xtuple/openrpt/blob/master/MetaSQL/test.mql\n params = options.params ? options.params : {\n start: true\n ,test_0_1_0: 'test_0_1_0'\n ,test_0_1_2: ['test_0_1_2']\n ,test_0_1_3: ['test_0_1_3', 'test_0_1_3_2', 'test_0_1_3_3']\n ,test_0_1_4: 'true THEN true END AS test_0_1_4) AS tests; SELECT current_user--'\n ,test_0_2_0: 'test_0_2_0'\n ,test_0_2_2: ['test_0_2_2']\n ,test_0_2_3: ['test_0_2_3','test_0_2_3_2', 'test_0_2_3_3']\n ,test_0_2_4: "(SELECT usr_username FROM usr WHERE usr_username = 'admin')"\n ,test_0_3_0: true\n ,test_0_3_2: null\n ,test_0_3_3: ''\n ,test_0_3_4: 'true THEN true END AS test_0_3_4) AS test; SELECT current_user--'\n ,test_0_4_0a: 'test_0_4_0'\n ,test_0_4_2a: null\n ,test_0_4_3a: ''\n ,test_0_4_4a: 'true THEN true END AS test_0_4_4) AS test; SELECT current_user--'\n ,test_0_5_0: ['test_0_5_0']\n ,test_0_5_1: ['test_0_5_1','test_0_5_1_2', 'test_0_5_1_3']\n ,test_0_5_2: 'test_0_5_2'\n ,test_0_5_4: ['true THEN true END AS test_0_5_4) AS test; SELECT current_user--']\n ,test_0_6_0: ['test_0_6_0']\n ,test_0_6_1: ['test_0_6_1','test_0_6_1_2', 'test_0_6_1_3']\n ,test_0_6_2: 'test_0_6_2'\n ,test_0_6_4: ['true THEN true END AS test_0_6_4) AS test; SELECT current_user--']\n ,test_1_3_0: 'test_1_3_0'\n ,test_1_3_1: 'test_1_3_1'\n ,test_1_3_1_2: 'test_1_3_1_2'\n ,test_2_3_0: 'test_2_3_0'\n ,test_2_3_1: 'test_2_3_1'\n ,test_3_3_0: 'test_3_3_0'\n ,test_3_3_1: 'test_3_3_1'\n ,test_3_3_2: 'test_3_3_2'\n ,test_4_0_0: ['test_4_0_0', 'test_4_0_0_2', 'test_4_0_0_3']\n ,test_4_0_1: ['true THEN true END AS test_4_0_1) AS test; SELECT current_user--']\n ,test_41_0_0: ['test_41_0_0', 'test_41_0_0_2', 'test_41_0_0_3']\n ,test_42_0_0: ['test_42_0_0', 'test_42_0_0_2', 'test_42_0_0_3']\n ,test_43_0_0: ['test_43_0_0', 'test_43_0_0_2', 'test_43_0_0_3']\n ,test_4_1_0: 'test_4_1_0'\n ,test_4_1_2: ['test_4_1_2']\n ,test_4_1_3: ['test_4_1_3', 'test_4_1_3_2', 'test_4_1_3_3']\n ,test_4_1_4: ['test_4_1_4', 'test_4_1_4_2', 'test_4_1_4_3']\n ,test_4_1_42: 'test_4_1_42'\n ,test_4_1_5: ['test_4_1_5', 'test_4_1_5_2', 'test_4_1_5_3']\n ,test_4_1_52: ['test_4_1_52']\n ,test_4_1_6: ['test_4_1_6', 'test_4_1_6_2', 'test_4_1_6_3']\n ,test_4_1_62: ['test_4_1_62', 'test_4_1_62_2', 'test_4_1_62_3']\n ,test_4_1_7: [1]\n ,test_4_1_8: [true]\n ,test_4_2_0: 'test_4_2_0'\n ,test_4_2_2: ['test_4_2_2']\n ,test_4_2_3: ['test_4_2_3', 'test_4_2_3_2', 'test_4_2_3_3']\n ,test_4_2_4: ['test_4_2_4', 'test_4_2_4_2', 'test_4_2_4_3']\n ,test_4_2_42: 'test_4_2_42'\n ,test_4_2_5: ['test_4_2_5', 'test_4_2_5_2', 'test_4_2_5_3']\n ,test_4_2_52: ['test_4_2_52']\n ,test_4_2_6: ['test_4_2_6', 'test_4_2_6_2', 'test_4_2_6_3']\n ,test_4_2_62: ['test_4_2_62', 'test_4_2_62_2', 'test_4_2_62_3']\n ,test_4_3_0: ['test_4_3_0']\n ,test_4_3_01: 'test_4_3_01'\n ,test_4_3_1: ['test_4_3_1']\n ,test_4_3_2: ['test_4_3_2']\n ,test_4_3_21: null\n ,test_4_3_3: ['test_4_3_3']\n ,test_4_3_31: ''\n ,test_4_4_0: ['test_4_4_0']\n ,test_4_4_01: 'test_4_4_01'\n ,test_4_4_1: ['test_4_4_1']\n ,test_4_4_2: ['test_4_4_2']\n ,test_4_4_21: null\n ,test_4_4_3: ['test_4_4_3']\n ,test_4_4_31: ''\n ,test_4_5_0: ['test_4_5_0']\n ,test_4_5_1: ['test_4_5_1', 'test_4_5_1_2']\n ,test_4_5_2: ['test_4_5_2', 'test_4_5_2_2']\n ,test_4_5_3: ['test_4_5_3']\n ,test_4_5_32: 'test_4_5_32'\n ,test_4_5_4: ['test_4_5_4']\n ,test_4_6_0: ['test_4_6_0']\n ,test_4_6_1: ['test_4_6_1', 'test_4_6_1_2']\n ,test_4_6_2: ['test_4_6_2', 'test_4_6_2_2']\n ,test_4_6_3: ['test_4_6_3']\n ,test_4_6_32: 'test_4_6_32'\n ,test_4_6_4: ['test_4_6_4']\n ,test_4_7_0: ['test_4_7_0', 'test_4_7_0_2', 'test_4_7_0_3']\n ,test_4_8_0: ['test_4_8_0', 'test_4_8_0_2', 'test_4_8_0_3']\n ,test_44_0_0: ['test_44_0_0', 'test_44_0_0_2']\n ,test_44_0_02: ['test_44_0_02', 'test_44_0_02_2']\n ,test_44_0_1: ['test_44_0_1', 'test_44_0_1_2']\n ,test_441_0_0: ['test_441_0_0', 'test_441_0_0_2']\n ,test_441_0_02: ['test_441_0_02', 'test_441_0_02_2']\n ,test_442_0_0: ['test_442_0_0', 'test_442_0_0_2']\n ,test_442_0_02: ['test_442_0_02', 'test_442_0_02_2']\n ,test_443_0_0: ['test_443_0_0', 'test_443_0_0_2', 'test_443_0_0_3']\n ,test_443_0_02: ['test_443_0_02', 'test_443_0_02_2', 'test_443_0_02_3']\n ,test_444_0_0: ['test_444_0_0', 'test_444_0_0_2']\n ,test_444_0_02: ['test_444_0_02', 'test_444_0_01_2']\n ,test_444_0_03: ['test_444_0_03', 'test_444_0_01_3']\n ,end: true\n }\n ,loopstack = options.loopstack ? options.loopstack : []\n ,stackIdx = function (id) {\n var idx = 1;\n\n if (loopstack.length > 0) {\n for (idx = 0; idx < loopstack.length; idx++) {\n if (loopstack[idx].id === id) {\n break;\n }\n }\n }\n\n return idx;\n }\n ,extractList = function (list, index) {\n var result = new Array(list.length),\n i;\n\n for (i = 0; i < list.length; i++) {\n result[i] = list[i][index];\n }\n\n return result;\n }\n ,buildList = function (first, rest, index) {\n return [first].concat(extractList(rest, index));\n }\n ,optionalList = function (value) {\n return value !== null ? value : [];\n }\n\n\n peg$result = peg$startRuleFunction();\n\n if (peg$result !== peg$FAILED && peg$currPos === input.length) {\n return peg$result;\n } else {\n if (peg$result !== peg$FAILED && peg$currPos < input.length) {\n peg$fail({ type: "end", description: "end of input" });\n }\n\n throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos);\n }\n }\n\n return {\n SyntaxError: SyntaxError,\n parse: parse\n };\n})();\n\n})();\n\n XT MetaSQL xtuple f t 2 \n\n/**\n * WARNING!!! IMPORTANT!!! README!!!\n * \n * The file was GENERATED! None of this file was written by a human.\n * DO NOT EDIT this file!\n * This file was created by running build_app.js in the process_manifext.js file.\n * If you find a bug or need to extend it with a new feature, you MUST follow this process:\n * \n * 1. Modify the PEG Grammer definition at: ../lib/orm/source/xt/pegs/ediprofile.peg\n * 2. Use the PEG.js online tool to test the new grammer:\n * - http://pegjs.org/online\n * 3. Run build_app.js with your PEG Grammer change and git commit the modified files.\n */\n\n(function () {\nXT.EDIProfile = {};\nXT.EDIProfile.parser = (function() {\n /*\n * Generated by PEG.js 0.8.0.\n *\n * http://pegjs.majda.cz/\n */\n\n function peg$subclass(child, parent) {\n function ctor() { this.constructor = child; }\n ctor.prototype = parent.prototype;\n child.prototype = new ctor();\n }\n\n function SyntaxError(message, expected, found, offset, line, column) {\n this.message = message;\n this.expected = expected;\n this.found = found;\n this.offset = offset;\n this.line = line;\n this.column = column;\n\n this.name = "SyntaxError";\n }\n\n peg$subclass(SyntaxError, Error);\n\n function parse(input) {\n var options = arguments.length > 1 ? arguments[1] : {},\n\n peg$FAILED = {},\n\n peg$startRuleFunctions = { Start: peg$parseStart },\n peg$startRuleFunction = peg$parseStart,\n\n peg$c0 = peg$FAILED,\n peg$c1 = function(start, editext, end) {\n return start.join('') + editext + end.join('');\n },\n peg$c2 = null,\n peg$c3 = function(body) {\n return body;\n },\n peg$c4 = [],\n peg$c5 = function(first, rest) {\n return first + rest.join('');\n },\n peg$c6 = function(token) {\n //return "token: " + token;\n return token;\n },\n peg$c7 = function(body) {\n //return "body: " + body;\n return body;\n },\n peg$c8 = function(editoken) {\n //return "EDIToken: " + editoken;\n return editoken;\n },\n peg$c9 = void 0,\n peg$c10 = function(start, body, end) {\n var id = body ? extractList(body, 1).join('') : '';\n\n if (params[id]) {\n return params[id];\n } else if (params.hasOwnProperty(id)) {\n return params[id];\n } else {\n return start + id + end;\n }\n },\n peg$c11 = "",\n peg$c14 = { type: "literal", value: ">", description: "\\">\\"" },\n peg$c15 = function(body) {\n return (body ? body : '');\n },\n peg$c16 = { type: "any", description: "any character" },\n peg$c17 = { type: "other", description: "whitespace" },\n peg$c18 = "\\t",\n peg$c19 = { type: "literal", value: "\\t", description: "\\"\\\\t\\"" },\n peg$c20 = "\\x0B",\n peg$c21 = { type: "literal", value: "\\x0B", description: "\\"\\\\x0B\\"" },\n peg$c22 = "\\f",\n peg$c23 = { type: "literal", value: "\\f", description: "\\"\\\\f\\"" },\n peg$c24 = " ",\n peg$c25 = { type: "literal", value: " ", description: "\\" \\"" },\n peg$c26 = "\\xA0",\n peg$c27 = { type: "literal", value: "\\xA0", description: "\\"\\\\xA0\\"" },\n peg$c28 = "\\uFEFF",\n peg$c29 = { type: "literal", value: "\\uFEFF", description: "\\"\\\\uFEFF\\"" },\n peg$c30 = { type: "other", description: "end of line" },\n peg$c31 = "\\n",\n peg$c32 = { type: "literal", value: "\\n", description: "\\"\\\\n\\"" },\n peg$c33 = "\\r\\n",\n peg$c34 = { type: "literal", value: "\\r\\n", description: "\\"\\\\r\\\\n\\"" },\n peg$c35 = "\\r",\n peg$c36 = { type: "literal", value: "\\r", description: "\\"\\\\r\\"" },\n peg$c37 = "\\u2028",\n peg$c38 = { type: "literal", value: "\\u2028", description: "\\"\\\\u2028\\"" },\n peg$c39 = "\\u2029",\n peg$c40 = { type: "literal", value: "\\u2029", description: "\\"\\\\u2029\\"" },\n peg$c41 = /^[ \\xA0\\u1680\\u2000-\\u200A\\u202F\\u205F\\u3000]/,\n peg$c42 = { type: "class", value: "[ \\\\xA0\\\\u1680\\\\u2000-\\\\u200A\\\\u202F\\\\u205F\\\\u3000]", description: "[ \\\\xA0\\\\u1680\\\\u2000-\\\\u200A\\\\u202F\\\\u205F\\\\u3000]" },\n\n peg$currPos = 0,\n peg$reportedPos = 0,\n peg$cachedPos = 0,\n peg$cachedPosDetails = { line: 1, column: 1, seenCR: false },\n peg$maxFailPos = 0,\n peg$maxFailExpected = [],\n peg$silentFails = 0,\n\n peg$result;\n\n if ("startRule" in options) {\n if (!(options.startRule in peg$startRuleFunctions)) {\n throw new Error("Can't start parsing from rule \\"" + options.startRule + "\\".");\n }\n\n peg$startRuleFunction = peg$startRuleFunctions[options.startRule];\n }\n\n function text() {\n return input.substring(peg$reportedPos, peg$currPos);\n }\n\n function offset() {\n return peg$reportedPos;\n }\n\n function line() {\n return peg$computePosDetails(peg$reportedPos).line;\n }\n\n function column() {\n return peg$computePosDetails(peg$reportedPos).column;\n }\n\n function expected(description) {\n throw peg$buildException(\n null,\n [{ type: "other", description: description }],\n peg$reportedPos\n );\n }\n\n function error(message) {\n throw peg$buildException(message, null, peg$reportedPos);\n }\n\n function peg$computePosDetails(pos) {\n function advance(details, startPos, endPos) {\n var p, ch;\n\n for (p = startPos; p < endPos; p++) {\n ch = input.charAt(p);\n if (ch === "\\n") {\n if (!details.seenCR) { details.line++; }\n details.column = 1;\n details.seenCR = false;\n } else if (ch === "\\r" || ch === "\\u2028" || ch === "\\u2029") {\n details.line++;\n details.column = 1;\n details.seenCR = true;\n } else {\n details.column++;\n details.seenCR = false;\n }\n }\n }\n\n if (peg$cachedPos !== pos) {\n if (peg$cachedPos > pos) {\n peg$cachedPos = 0;\n peg$cachedPosDetails = { line: 1, column: 1, seenCR: false };\n }\n advance(peg$cachedPosDetails, peg$cachedPos, pos);\n peg$cachedPos = pos;\n }\n\n return peg$cachedPosDetails;\n }\n\n function peg$fail(expected) {\n if (peg$currPos < peg$maxFailPos) { return; }\n\n if (peg$currPos > peg$maxFailPos) {\n peg$maxFailPos = peg$currPos;\n peg$maxFailExpected = [];\n }\n\n peg$maxFailExpected.push(expected);\n }\n\n function peg$buildException(message, expected, pos) {\n function cleanupExpected(expected) {\n var i = 1;\n\n expected.sort(function(a, b) {\n if (a.description < b.description) {\n return -1;\n } else if (a.description > b.description) {\n return 1;\n } else {\n return 0;\n }\n });\n\n while (i < expected.length) {\n if (expected[i - 1] === expected[i]) {\n expected.splice(i, 1);\n } else {\n i++;\n }\n }\n }\n\n function buildMessage(expected, found) {\n function stringEscape(s) {\n function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }\n\n return s\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/"/g, '\\\\"')\n .replace(/\\x08/g, '\\\\b')\n .replace(/\\t/g, '\\\\t')\n .replace(/\\n/g, '\\\\n')\n .replace(/\\f/g, '\\\\f')\n .replace(/\\r/g, '\\\\r')\n .replace(/[\\x00-\\x07\\x0B\\x0E\\x0F]/g, function(ch) { return '\\\\x0' + hex(ch); })\n .replace(/[\\x10-\\x1F\\x80-\\xFF]/g, function(ch) { return '\\\\x' + hex(ch); })\n .replace(/[\\u0180-\\u0FFF]/g, function(ch) { return '\\\\u0' + hex(ch); })\n .replace(/[\\u1080-\\uFFFF]/g, function(ch) { return '\\\\u' + hex(ch); });\n }\n\n var expectedDescs = new Array(expected.length),\n expectedDesc, foundDesc, i;\n\n for (i = 0; i < expected.length; i++) {\n expectedDescs[i] = expected[i].description;\n }\n\n expectedDesc = expected.length > 1\n ? expectedDescs.slice(0, -1).join(", ")\n + " or "\n + expectedDescs[expected.length - 1]\n : expectedDescs[0];\n\n foundDesc = found ? "\\"" + stringEscape(found) + "\\"" : "end of input";\n\n return "Expected " + expectedDesc + " but " + foundDesc + " found.";\n }\n\n var posDetails = peg$computePosDetails(pos),\n found = pos < input.length ? input.charAt(pos) : null;\n\n if (expected !== null) {\n cleanupExpected(expected);\n }\n\n return new SyntaxError(\n message !== null ? message : buildMessage(expected, found),\n expected,\n found,\n pos,\n posDetails.line,\n posDetails.column\n );\n }\n\n function peg$parseStart() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n s1 = peg$parse__();\n if (s1 !== peg$FAILED) {\n s2 = peg$parseEDIProfile();\n if (s2 !== peg$FAILED) {\n s3 = peg$parse__();\n if (s3 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c1(s1, s2, s3);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseEDIProfile() {\n var s0, s1;\n\n s0 = peg$currPos;\n s1 = peg$parseSourceElements();\n if (s1 === peg$FAILED) {\n s1 = peg$c2;\n }\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c3(s1);\n }\n s0 = s1;\n\n return s0;\n }\n\n function peg$parseSourceElements() {\n var s0, s1, s2, s3;\n\n s0 = peg$currPos;\n s1 = peg$parseSourceElement();\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$parseSourceElement();\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$parseSourceElement();\n }\n if (s2 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c5(s1, s2);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseSourceElement() {\n var s0, s1;\n\n s0 = peg$currPos;\n s1 = peg$parseToken();\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c6(s1);\n }\n s0 = s1;\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n s1 = peg$parseBodyText();\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c7(s1);\n }\n s0 = s1;\n }\n\n return s0;\n }\n\n function peg$parseToken() {\n var s0, s1;\n\n s0 = peg$currPos;\n s1 = peg$parseEDIToken();\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c8(s1);\n }\n s0 = s1;\n\n return s0;\n }\n\n function peg$parseEDIToken() {\n var s0, s1, s2, s3, s4, s5;\n\n s0 = peg$currPos;\n s1 = peg$parseEDITokenOpen();\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = peg$currPos;\n s4 = peg$currPos;\n peg$silentFails++;\n s5 = peg$parseEDITokenClose();\n peg$silentFails--;\n if (s5 === peg$FAILED) {\n s4 = peg$c9;\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseSourceCharacter();\n if (s5 !== peg$FAILED) {\n s4 = [s4, s5];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$currPos;\n s4 = peg$currPos;\n peg$silentFails++;\n s5 = peg$parseEDITokenClose();\n peg$silentFails--;\n if (s5 === peg$FAILED) {\n s4 = peg$c9;\n } else {\n peg$currPos = s4;\n s4 = peg$c0;\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parseSourceCharacter();\n if (s5 !== peg$FAILED) {\n s4 = [s4, s5];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n } else {\n peg$currPos = s3;\n s3 = peg$c0;\n }\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$parseEDITokenClose();\n if (s3 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c10(s1, s2, s3);\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$c0;\n }\n\n return s0;\n }\n\n function peg$parseEDITokenOpen() {\n var s0;\n\n if (input.substr(peg$currPos, 2) === peg$c11) {\n s0 = peg$c11;\n peg$currPos += 2;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c12); }\n }\n\n return s0;\n }\n\n function peg$parseEDITokenClose() {\n var s0;\n\n if (input.charCodeAt(peg$currPos) === 62) {\n s0 = peg$c13;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c14); }\n }\n\n return s0;\n }\n\n function peg$parseBodyText() {\n var s0, s1;\n\n s0 = peg$currPos;\n s1 = peg$parseBodyPattern();\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c15(s1);\n }\n s0 = s1;\n\n return s0;\n }\n\n function peg$parseBodyPattern() {\n var s0, s1;\n\n s0 = peg$currPos;\n s1 = peg$parseSourceCharacter();\n if (s1 !== peg$FAILED) {\n peg$reportedPos = s0;\n s1 = peg$c15(s1);\n }\n s0 = s1;\n\n return s0;\n }\n\n function peg$parseSourceCharacter() {\n var s0;\n\n if (input.length > peg$currPos) {\n s0 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c16); }\n }\n\n return s0;\n }\n\n function peg$parse__() {\n var s0, s1;\n\n s0 = [];\n s1 = peg$parseWhiteSpace();\n if (s1 === peg$FAILED) {\n s1 = peg$parseLineTerminatorSequence();\n }\n while (s1 !== peg$FAILED) {\n s0.push(s1);\n s1 = peg$parseWhiteSpace();\n if (s1 === peg$FAILED) {\n s1 = peg$parseLineTerminatorSequence();\n }\n }\n\n return s0;\n }\n\n function peg$parseWhiteSpace() {\n var s0, s1;\n\n peg$silentFails++;\n if (input.charCodeAt(peg$currPos) === 9) {\n s0 = peg$c18;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c19); }\n }\n if (s0 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 11) {\n s0 = peg$c20;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c21); }\n }\n if (s0 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 12) {\n s0 = peg$c22;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c23); }\n }\n if (s0 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 32) {\n s0 = peg$c24;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c25); }\n }\n if (s0 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 160) {\n s0 = peg$c26;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c27); }\n }\n if (s0 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 65279) {\n s0 = peg$c28;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c29); }\n }\n if (s0 === peg$FAILED) {\n s0 = peg$parseZs();\n }\n }\n }\n }\n }\n }\n peg$silentFails--;\n if (s0 === peg$FAILED) {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c17); }\n }\n\n return s0;\n }\n\n function peg$parseLineTerminatorSequence() {\n var s0, s1;\n\n peg$silentFails++;\n if (input.charCodeAt(peg$currPos) === 10) {\n s0 = peg$c31;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c32); }\n }\n if (s0 === peg$FAILED) {\n if (input.substr(peg$currPos, 2) === peg$c33) {\n s0 = peg$c33;\n peg$currPos += 2;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c34); }\n }\n if (s0 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 13) {\n s0 = peg$c35;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c36); }\n }\n if (s0 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 8232) {\n s0 = peg$c37;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c38); }\n }\n if (s0 === peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 8233) {\n s0 = peg$c39;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c40); }\n }\n }\n }\n }\n }\n peg$silentFails--;\n if (s0 === peg$FAILED) {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c30); }\n }\n\n return s0;\n }\n\n function peg$parseZs() {\n var s0;\n\n if (peg$c41.test(input.charAt(peg$currPos))) {\n s0 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) { peg$fail(peg$c42); }\n }\n\n return s0;\n }\n\n\n // The default params below are for the test above.\n params = options.params ? options.params : {\n foo: 'bar'\n }\n ,extractList = function (list, index) {\n var result = new Array(list.length),\n i;\n\n for (i = 0; i < list.length; i++) {\n result[i] = list[i][index];\n }\n\n return result;\n }\n ,buildList = function (first, rest, index) {\n return [first].concat(extractList(rest, index));\n }\n ,optionalList = function (value) {\n return value !== null ? value : [];\n }\n\n\n peg$result = peg$startRuleFunction();\n\n if (peg$result !== peg$FAILED && peg$currPos === input.length) {\n return peg$result;\n } else {\n if (peg$result !== peg$FAILED && peg$currPos < input.length) {\n peg$fail({ type: "end", description: "end of input" });\n }\n\n throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos);\n }\n }\n\n return {\n SyntaxError: SyntaxError,\n parse: parse\n };\n})();\n\n})();\n\n XT EDIProfile xtuple f t \. -- -- Name: js_js_id_seq; Type: SEQUENCE SET; Schema: xt; Owner: admin -- SELECT pg_catalog.setval('js_js_id_seq', 2, true); SET search_path = xtdesktop, pg_catalog; -- -- Data for Name: pkgcmd; Type: TABLE DATA; Schema: xtdesktop; Owner: admin -- COPY pkgcmd (cmd_id, cmd_module, cmd_title, cmd_descrip, cmd_privname, cmd_executable, cmd_name) FROM stdin; \. -- -- Data for Name: pkgcmdarg; Type: TABLE DATA; Schema: xtdesktop; Owner: admin -- COPY pkgcmdarg (cmdarg_id, cmdarg_cmd_id, cmdarg_order, cmdarg_arg) FROM stdin; \. -- -- Data for Name: pkgimage; Type: TABLE DATA; Schema: xtdesktop; Owner: admin -- COPY pkgimage (image_id, image_name, image_descrip, image_data) FROM stdin; 6543 ImgUpArrow begin 644 internal\nMB5!.1PT*&@H````-24A$4@```!`````0"`8````?\\_]A````"7!(67,```L3\nM```+$P$`FIP8````&71%6'13;V9T=V%R90!!9&]B92!);6%G95)E861Y<&'$S@*AR[@"(S@9F[`""S0@Z.X`5ZH02B8\nM2#S8A%O_+[U@8HP8F6FH_AP@(DM$]A60P@`@]!`5R.(YO292`44LTT1N@!(?\nM3\\@%-.(%P-I#IE[,S#LS;SU$+O!:+$4#\\3G@4EC%"B)[#@",_`4Y28OS*??,\n8_S_3"0291*&B/"QO`````$E%3D2N0F""\n`\nend\n 6544 ImgRightArrow begin 644 internal\nMB5!.1PT*&@H````-24A$4@```!`````0"`8````?\\_]A````"7!(67,```L3\nM```+$P$`FIP8````&71%6'13;V9T=V%R90!!9&]B92!);6%G95)E861Y</"!\\\nM8/^0XY_)FVPFVY12.*/K\\B"I!5[`T_;G"'`)S#WP`$9)MQ1@H2K('\\#V`'09\nMR"I!%A(^X0<9:B";'=CN:B![)59I$R#I#;2STT2PC29:XFP/N^8P0<:\\`F3-\nB48)[Q@Q!!]G/%):8T1=96DN8J[V">0````!)14Y$KD)@@FP/\n`\nend\n 6545 ImgDownArrow begin 644 internal\nMB5!.1PT*&@H````-24A$4@```!`````0"`8````?\\_]A````"7!(67,```L3\nM```+$P$`FIP8````&71%6'13;V9T=V%R90!!9&]B92!);6%G95)E861Y<6)I"`M"2)7G!UV9ED`@,,P`F@*=XX$"Q)J\\$Q0D8PF\nM\\C`$[\\#,[L!E"QP*`DD5AF`%7Y)ZX%6#5P5;ZO^?Z0TL"DZE0C`+/P````!)\n'14Y$KD)@@L!E\n`\nend\n 6546 ImgLeftArrow begin 644 internal\nMB5!.1PT*&@H````-24A$4@```!`````0"`8````?\\_]A````"7!(67,```L3\nM```+$P$`FIP8````&71%6'13;V9T=V%R90!!9&]B92!);6%G95)E861Y<9`BB4/HY`F20(BJ%($B8AH$>@E('[26=<\nM1_;(DWO*NAV=90\\I):[H%FF2-`$OX&EFG_QL#)H7X`%LDNYA0&:NJ@IPS#O1\nM"%&S"^@QGP"]9G>"7OT!S&P%YJSDKJXYP0%Y1R%#[2E+6H`I*\\77>$PR`VLY\nI2=G7O$0'0AFE&J$P_?["*4((T-(76$U+:;W&_ZD`````245.1*Y"8((R\n`\nend\n 6547 gear_16 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```!`````0"`8````?\\_]A````"7!(67,```L3\nM```+$P$`FIP8```#!$E$050XC:6376A;91C'_V_>]YR3\\Y&F25JSUB5=IE/;\nM364RI]$B.*8P/Y`A0THIZ(5>J'@AXI4?B"!>.5!!1*:XFX+M',P;9>!T.I55\nMF'5C;B.X-6V:[Y-DR3EOUZLQ-N:-_B[_/,^/!Q[^P/^$7!]LGUE`H]4G\nM3SPT,>0,A/GKF7I-`D'AT+X;"B+7!TQ3"YN6D4Y?2F;)5_^%F@RDFE[$ARON&G>ZZ/H.\\UQW5Q^LE)TW%=;W:][778QKT+H(2P[HL+\nM(SW+RJA155]IA5AU2>746O_IBFJ,$,;FI:X:FL)23=?=7FCZ9Q,J+,)HA]VY\nM.8$A@Z4;7"[\\?)%/5;HA]:,2S8`JC=S(K3'*,[*E*$Y?0P*1T`[%ZZA!=R[P+&9;I"[M4E2(#MW!S;\nHD+18]\\ARY_*HQ>3RNW?_V\\I_XQ^8Q6FM@=RAW0````!)14Y$KD)@@H#M\n`\nend\n 6548 reload_16 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```!`````0"`8````?\\_]A````"7!(67,```L3\nM```+$P$`FIP8```#6DE$050XC3W3RT\\<=0#`\\>_,;V9^PS[9I;N475X%FR5!\nM0Z"Q(%!*326E28U73UY[,=&#B1=.MO'6^`_HP4M/7DR,AJ*A"=@6;+NE+=:4\nMU[Z`LLN^V0>[.^.AT>_]>_PH_)<$!H`J;KQ,2:^<=CJ[MI`(P`SP"3B<'AP:^O7KQZ9>3\\B$=*2:Z28^=PAZ<[3TN;B$`$603`!LS.S[+7V/KYVZ=H/MV[>&I^?FI=NCQO=T#$Q\\?O]!+H"\nMTG`8D6*C.%>6Y=W!"X.OG9B;GOO^]LW;?5*1;&UMD;6.J51.\nM6/MYC8=+#S%5$W>WDX*2]V:KNLSU[^Z/'K9\nMW'B\\02%?()5*04<+-=1$[6S2\\UZ(8J+,\\P3]C:$4+$L"TT5&(:&80C4\nM6K,6BQW%P`,^OX_X=H)*Z81,XQ!5LS&DH-WCHK&KD]H]Q-_IPW8VT86&$"(F\nM[+`ML_7LC:R6E4$19'-]$U$T>&=H`(=7XE0]-#9<_+1PG^3>`>.?C-(:/*%6\nM;Q9+E?(=09BCJEV]<%`]B'1&@G1:078V8IR\\:F'NGZ&XIG#_QR?$MQ.\\_]$H\nM@7D'FI0M_T(@HZFJH#T.04$;)PC"GX\nM`P&B\\6?)Y\\D7GTK=6!&<`Q9)<)>8A369MHZ\\U4`)_:R""(#2W<08@K[1,.>[\nMAHDFHLEH,OIEGKT````"7!(67,```L3\nM```+$P$`FIP8```&X$E$0518A>V66XC?Q17'/V=^E_]M=_^;W>QNUI!$=W,S\nM7E.KU&B*%FO!M-0'*6JE0DJQJ%"17D`KI13Z4(JEU5I[`VFAEM(B@;;0!RT5\nM>XL2K#%73#3&O22[F]W_9?^_V\\R-D57ZE5*ROML6/_NG_5JL;XP@)_?I\\`YZW`;Z.(I"@J0QLW?JXVONYAUUE8\nMY9H',.5QU+(S>?W0PY/'CS]7!_^9_R3`4\\"Z]>N9GYR\\L#HV]DA0Z[W3+1PJ\nMC]ZTR.BV2SCZZ]W,O-"'A,MF?&/^N_G4U)-!'#>/YCF?/P^`LX;@CR*$$!B1\nM3U1&1IZDDVP+96\\X?N\\`:^[Y-I5+O\\ZRJT<)PK^RN.MHC4[YAKA27A_D^:NC\nMJU?/WKFPP"\\^B`)_`DIQC+>V/ZCWW2]1^0&?MP;KUR:L^=(-U*_]&I0NQN8I\nM82BX]BY._.51)AY[D>2E&%&S3VSQB"F*'8C8CZB>/\\#S@$01%,5E$L??4H)M\nM03T-A^[J8>3N.ZA>=!>'CRSRS.]WT>X(FS8NYY8;UU(*YVD=?)J9I_[`XN]2\nM:`1-P3\\1H(\\",X4JUYP!X+00O%BM$H9A'-=JMYO"/F&LW5*]I#`KOCK&\\.WW\nM$0_?S(FY>;[WLW]0E*^@,K2>5Z<"1$\\P-N0P?>.4+AV"D:/HF\\U2<((M@;(Y\nM$O;WP^0]P`_/!/`\\\\-"55R(P6EZQXIN29-\\POKVBMBU@Z,O7TK=E.Q*O`=MB\nMSX$C_.2%&D?\\`*^U+<>DPIPU;+U@&BD:$/037K@:W=!$6W,23>AXZ.1F1-J1\nMR-X'1.SW3P$(`88'!K"'#U]6R._<#?5'?F::(['!*XV\nM\\-"$R-S*I;P(`23/0:3I]QV<8+AQ.+J_?E'MNEN-J8R1=^91;U%UJ'<,EAS;\nMM_;RH^.7TRKUT=\\3:OT8>;+:UGNIQB9?Q:;\nM',?9'.]RO+==)8"\\/4V>S>Y;]J)\\>NTOB[=2D63Y*;093:E2!O,YFV\\S7"N0+W%>U!5P*"J2%"1V:OB\nMYLSF//GX@^W3%`A/'>0Y*&!U$3][$#$QZOV2"A;O4ER1XHH$9U.\\*_!>4>WZ\nMH>!\\MU4%58\\JA.68P%1QW@!G`RBZK>8=TLX^%(-J=\\'%U//R&[U`B'>*=R'>\nM@W<6[SW6P5`=+EX-_FT`4!4DCA%J7;AWV6D`6=Y-BB2#)`<1Q8A@C-!<%+2R\nMD:$50Q0>U&6H[\\9<78%K3S(],<7R/D$51`0C!F/`E$L$4L6I/3M`GH-1V#4]\nMCK_\\0<*XW#UEEE*9?QSO,MH;OD"T\\BJRM"#+/5GF23.HO_8#DD./\\W+P608W\nMW82W#N<-,O,RF]RS5$T)K^5S`X0>&F:8(SVWX'V)HIVC[18?TM^`G>6%B9#Y\nM!<%U%#*/9A:;*%=E$=[#1&4S$SV?)&\\FY!W'<&'85-J)U^C\\`$1@,5%V/#>)\nM[P302JF[G,WK^O!NBE?V-W@C/=:-4UI`8B%5QBZ"`6/8>WB1_6^^"XYTZ?M/0H4P%B\\G_N&'\\($,6%8\nM(HY*S,^>(-:`+ZY\\G&2D1B@101`3!24,%2(_QKR"]^`L-*>JM!-#\nM7GC4MM&BC5WR4PS](^,$<1TO\\^<.`="M@$OWV"]5S;P`M*`H%.NZFW?<0;_N*H!(C414UYTC"]&0A.EE$3NEG!1A?8&T70/5T"*]@W9G7\nM<,28H(J>*PG3_)W^Z=5,20N(U6$=N%,4.`G@+!06DDP1WMD<49P7U`2HO/<+\nM>B8%%$4543$AQH28,"+P!F^;%(7#>=!W`SBH]`PRLFH%(K+TS@I&C)3*-6V<\nMF")-VF<'L-U*N4MA.X@8#&I"D`A,2%88VDD7X-3-3ZIGPC+5WD&,`"((`B(R\nF,_WZ0G/_/QNJ9W@,_F__\\_9O.@?:"4TZGOH`````245.1*Y"8(*,\n`\nend\n 6550 clients_32 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```"`````@"`8```!S>GKT````"7!(67,```L3\nM```+$P$`FIP8```(&DE$0518A>V66XQ=51G'?VM?SS[WN9PS,YTI[;2E4\\JT\nMA=IBZPS4MBJ*+45#0+FI(20%0:`&;P31!U`)*(D27\\!$,5ZB@1A,3%!>L-=T\nM:J=VRK2==MI)YWXY9_:Y[/O%AU%2*,68F/#"_W$E>_U_^_]]ZUL+/M2'^H`E\nM_I^;+5Z\\F/GY>67MVK7Y3":3J50J<:52F=$TK>ZZ+B=.G+CD&^7]-KS^^NL9\nM'!S4UJU;5VQJ:FIQ'"%CM.W+$FYZ9^=OT]/3#BJ),]/;V\\L8;;\\B[=^]^?.NV[5]?\nMNF2I-CIZ@=+<'-6Y47#F%KN./6\\V[^WM9>_>O1PX\nM<.#!;=NV_VS3YLUK=2W1>&%T-#$X>$*;&!DRRG/35]5MSTNGTWU1%+F%0J$M\nMF\\W^*!%,%6='CE(:.49[8H:;KH8US26.C8KUJ]==-]/;V[-_W[Y][Y]`K5:C\nML[.SX:.;-MTUA;YW-F59%]?*/VR+__-:]9OF"D4"L^_\nM^.M7O8RTU[[_4SM9WW,3$B&2;^*7S]"9KW/PY'$.CX_7RJ69_UZ"4JF,&\\0<\nM/7Q`ZFE?Q:VWW8:L&B0D#]DOXY=.TZA6V']N4BZ;577-JB7\\\\9G;6ZW10]7N\nMKF6HBH2D&,0$Q,CHBN!SUPI[59C3MUR=U@<^ML&]\\X=][PWPT%;!BMZMC$R:\nMX=S9`T.?V;)N?6-A$4))$`5:H(K&YH_WMS:\nMN5E8$X35+'*RD=B9):I>P+?F6+&TU5A9;+^]__";+V=I\nM5:OW?7)M]MY\\)F7(JH$DR<@2A/5)_-(0;OD<;<>.G4MD\\ZV_M(<#_7JZ\nM83RL3Z\\DJ#?BUPAJDWCF!3QS+!3P*T/7?K#^X8.G2W_^&B\\=O$P)%!G&7GL"\nMS0[ZL\\7VL;@^E@C*6E(*3)`D0O,\\H35+Y%MQ)E,L*?[P/Z2QPZ5)T>*N7M7V\nM4VO\\:-(G>CJRYZ7(M_"J$P1N[;A3F7ZB/CL\\VB(N'3OO2&#_67A@0PU1N7`A\nMT=C^BE^;S.'7-Q*ZA'89OS:%7QG'JTU/!9Y]5[:X_!<=*U8ZJQ[H8\\^6`)5H\nMT+(JW:%37AE'(4ZH5.RZN<=M6W.H]>P(SQZ^Q/_RDW#TQ6LACM9(:NI/LI[I\nMC(D);1/?,;'*X\\^.G:U\\R\\J)<-=/8A*/)XJK5Z[>>&[NW-6/'JI^]H8KDC=@\nMY+$G3?,UU7SYI6NR_5H][JM.5@/C8]73;J@5.ZD=!5\nM0JT!LQ8<+$_-[AEM2)BWS[AJ]Y>[[[AGTSTO;%ZR^<'CYM%/*P.U)8O&`E+3\nM)G(0)5Y?IEX77M&QQ5+:0OJP=VD*;VK";\\/\nM5(RNKD?NW;&SZZLK5Q56O/#[\\\\K(X").]659E;')JPIGZ\\L[1K)M7VHM).-6\nM\\87XZ,NSDG7+22;:3Y`Q=!JS6=2D@:^J&%%,F^,R7Z\\S6YVDJE0(]?`3A&Q!\nM\\.I%`-\\#GJ2EY?D'=NZ\\\\JF/;%RD#XY:#%<#:DMOY0EM*T6YCI`3C&>+5+04\nMF3`02FB(RD">DX,5VAYUR"S7R1M)FM(9THD$,5"U;11)(HPB7-_'=7S-#\\,K\nM48"GWP:0@.\\L7;:L87E='5-D]`T,H9!(9M%$@)5EO&"@)KCDM1T=%TE].)B(I_`\\JW_\nM``A`6^8XKN*<%SQ!?U@-0\\<'Q..S\\NH"6#\nMU9B$0@I2*N1T*"8AI8$;+H"$,=@!U#Q(>_AN"JL64<\\[5&P;69)0%86ZX^"%\nM`:J=(+`B%$6AR6AIGGIH2B7"NP@@+OA!*)=++G)"$&>TA60D`:H,20V:D^`$\nMX`9045$2,:$N$(:"+FA-'"W\\>0D2RJD0.J1#'7$,V6Q)32\nM5/7",*;N.*BR3!!%.+Y/H]J)'T0D24FQ%]=$+'1<4,`'6H#A`O@0>J2E&GX<\nM8=<\\J+A@J"!+8/L+K#4/[(`&)<#RZOB^04YJL,S7=]Y?7_/C([(MRV$4H<@R\nM413A!2&Z8N!%(9Y=9VA^*(C]N"PD@0(!0AR4XSA7!!6PR.H"'Y@KVZ#+(,1"\nM$DEUH21.@*AZ%),RDZZ+;ZL(3U*;9C8ZP8._&1T:NN.2R7J"WUZR%A.C""$`\nM0Q$BK,6Q.P12F#*R1$)`R5[H]CA>J'M"60#P(X3ETYS74)R(G!R#'T2692F:\nM]K[OW$NDQ'&,$)('\\1X(5`@`%=F/%J).J0OW=,S""9`$!!'""9!#G=B3J,XY\nE_/-\\#=^S*D)(_Q/`A_K`]2^6(.KG=#/%80````!)14Y$KD)@@I!#\n`\nend\n 6551 reward_32 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```"`````@"`8```!S>GKT````"7!(67,```L3\nM```+$P$`FIP8```'L$E$0518A<65:VP<5Q7'__)'W!C3\nMI"TD!$$?E)0B-6K*A_(%PJ,%"2%5!?$,2(@66J2&5$)!0JBE@H($%8)0*J02\nMFDHH)"%5:$V>MN/$S\\3V;KRSN_.>O9`\nM_W,0`/CI@1/X]K>^@/L^_("8F9G.U.MADE+**"4*@&4DDN;P;=O=Z8OC^,'C\nMGU]=@$?W/`TI59HS\\F"M5MG9T5[HSV72&==GEN+G-A8C(=T_5T\nM?W]O:VL^WQL$_HY,.KEF9F;Z957WZD?__*=5`>!M68WLN/^C`UUKNUGIBHF3\nMY\\XC4`2;A@:1R690:,W#MAWXKH7QL;'>UPZ^JK6TY+Q540?``>#7['JJ5ZFKI1P"$$@2^AW)Y\nM"2`485W"=7WDGDP8U,6264%=$>EZON4Z[J3KE%_,9M(_>F+?\nM.Q3-PX@E814$H!J[K3A1O1(*4!*B:1AQ.]\\_WOC5-7QAU=>15T2#&P<\nM0&=7IUXL%O.52F4S4>%"1UO^N14Y0`D%`8%2*DHIHU\\H1`P*A!#8CH/#1U]'\nM>WL!`X,;D4ZED$FGP`6''A.8-AQM;>W(M^:1R:212J61,`R42B6,C4]@L5A2-&0"@(*5`E.KJ\\Y4`-!>B-!K'9A)*HB1H",F(9[DT!%>EU/+DKB26BZ74]7T0\nM[51%>8T@)""IA*?74-,``SJ42@%*18<8(:",KRNZ,EO0:O1`$S&XN`+90L!:7:2WA1_3\nM,E;R0G#QZ.Y#NT\\5DH7YL\\4SP?Z[]V-=K.D??CZ9RGX\\D\\TCU]**\nM1"$&O]M$D+,0)B1T?0WRQCO19FQ!-MX#C<T[VM-._,RT^W/'P58/W`+3\\QDNG=\nMR706+;D"*KE%'#=>P;K.0>S<]C1B=!!2ZE"D"EN.(4R,`HE9$%[%E9E%5!71V=&)-1P?B1@(EKX2R:>(\\SN,R+B'A&!AH[T1VNF%5))>(&'@`30XSKZNOK0NW8#`,"L\nMF+#L2-BR+=0L"Z[GXBU?C>"'`0I?*UQ87%A\\+),:*#B!N-T-Y;UV$-YI&,D!\nMSD*=-0%X!-`$X3Q*H7,,W3R$;"+;V'4Y$K8LU*P:+*L6.*YSU/7<\\G\\]/(?V\nMCT+1?L+"O05.?GF[)NC]FA`?Y$+T<,99TPG.(RC&.`07V+!N/0@E*)MEF)4*\nMS$K#_EKUM&5;^VS;^E5,BU56='I_X(6[H0#**.T60KM7$]I#0HBMG/,$9PR4\nM,0@NP#E'-I.%[_LPS7(D7JV4+=OZF>W8SSSXH5T3+_SVYQC]TBC>QN<#^.1K\nMNV'9#ABE:2'$^S2A?4((L:->KZ=]WT:VW!=",/>>^B4IE"0!TP<5V(<1G/<^[;W)Z*F563.1RN8J4]1_;\nMCK,WH>N7YHM%_.7AP]>M\\3\\!-&-O\\?NPJC4`2M=C^AU!$#QZ<>KB&K-:>:):\nMJ_Y.T[3@P`,'_N6[JP+0C.>#9U&MV0!4;O;27.JI[SPU_9&'=JE?[_S-OWWG\n5'XD"KSY"@AH;`````$E%3D2N0F""\n`\nend\n 6552 accounting_32 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```"`````@"`8```!S>GKT````"7!(67,```L3\nM```+$P$`FIP8```%ADE$0518A>V6RZN>5Q6'GWU[O\\M[ON_+N24G'I(F:DPB\nM-J1I;$H(BB`%%04GCG4@*H@*3BP41PKBI"-QU)F(`RD.!#4@5;S6E@I!3*$-\nM";8<3\\[]N[W7O==R<$XB3OP'>A[8L-E[L]=O_?9BL>&88XYYKV,>35Y\\;>OQ\nMXJF%#G6CG,CMB5ZP5_O!/IUG=KF?V=0+=E,-=^_M-'=OWYT\\7,R]^>3%P>GU\nM8;C<)KE4-'*J:,46C6P5C;Q>MGIG8Y(F2WW#=@&J`BC?>'H)`/\\H:-L:5%GQ\nMSGQI7";-,[NN:I[UQGRD:UGH6LA0`DI44Q:-/GCGX?X?=S/O;IY?N&71LUZU\nMFZ&(@62A,6:BJG<&F7EUOTB;;2L2D[YD8/PH[F,!213%7.Z;]-V>D86^L8Q,\nM8LG`T!A\\J[AD\\,EAH'>Z8RXO97JY&X1EU^*JB!/%J])5I2,1CPZ--;?4RHX\\\\8+KVSS\nMO4^L8A]E_^;4.U*ZL9H'5@9]5A>'Y'D/YQUI-L&T-4%:@H'<"$.;L*H8`UGP\nM&&O`@'(X>LZ2:\\O0PTJ><7HA8[7O#"D^^YU[JR9)`C@4$$49N7C2:KPRZGK:\nME##6(JJ'=9H/J4.7PG9HL90X&C7(4;:BBJH>!M>C)W6!TF:T&%(21)1!YK`2\nMG_KFZ=W%)/I?`4D42>EB1CK;SSPJ8(Q%!505:RQ&!:N"B(!U)-\\YLOOP(E4%\nM/7)`%6L=JDJKAN0"CD"*+<$[\nM!$.=E"8IQAHR9^AZ2S*"9[MPK$S3\\SJA$BB9X6>;5EPPB@SY!W'?#9G-J^&2Z?/\nM?O1@;__/_EN?6N_\\;=,_\\^[;F]Q^=8^U\\QP&Q_`SLX1=598:](3,M(K`IZIF9M&%@>Y63!HZEF\\\\$]\nMQKL33IV_>..+UY:<.?/IKRR'XK[2&HI(ZCO$?I#0CZBV\\]U\nMT/,L9&JF&V]S_^]_8O-?]Q$53JX_P;FK-QFL7V+>6IV5#4TQ-4TQ)A83;*SH\nM!O`6QEL;'.SM8C7^H3WX]V?\\>'_?VUEA0V]`6Y>,IP6A/](L'XU#/_NGJKRN\nMDMX2T;$HQ#8.R]GD7#&?/MG6Y7E`R_GL7CF;_J,7VP>BV4Q4C$HZ@:0/J:3K\nM95E>GNR,!VTQ-K&HZ]W[X$P)7G?X'O\nM](W$=H3$#Z-R!?0)%GKT````"7!(67,```L3\nM```+$P$`FIP8```'8DE$0518AF]N/<\\Y^U-M!G7OM))WV.K.@6`7[45]]WU>K5@EW:4__=@]`$KE)\nM223F3$H04R:1B8?C?!B%PW?ZOF/OZMMKA+V;_\nM]Y\\=S2'UYYM*$6(FQ(3UJ8Q3?E^$&#,^99P/=(L%\nME]_\\)U=V%Z]??NW5;U_ZZY]^M'[BE)^]<.&_,Z"5$!*TM>;,%/[U^BZCS;A@\nM^.C#.\\1*,;,)&Q+6YQ)#QH6$\\AFT`;/!]GR3!\\^>.[>]O?WTYO8)_<<+7WWF\nMHV,>&?/^I]>KY!W-__KE?7^2EO_6\\Y?''JQPL>;U:_,KG?5?4"(7G_W&IU%W94`$\nM(X(6(2;#+_[@^/E5PXV/G:'>:&AKH:U5Z8UF4JO2JQ*;2FAJ!=,M?O5&P$AD\nM:\\6$J[*N$G"A8R/X(*4'HMY5R?".W7%VOHZ1LGQ&#!),$IP?F10'B\\5\nMP^"Y/.NP4?!2L9AWC`$<-<-@Z8<1JUH&Z[%]3T>+"HXO/;Q%9:JRL*7[[@K`\nM*"'IX@520GM'(K"J*K)$6BVHJF+J,JD6,(JN$A9:2)5FL)'1"+DV1!=9,64Q\nM6@2MC@%`2T&JE*"`C9R8.4N]6H&&+$)5"TVC0`1=*SK1=&A4HQAK3:$E>'P&SN<4E(6IC/1FP2\nMHB2&860<1[Q.#-8S=!VCBJCH>>*3TR*!<#P3:A&26IH02"FQH:"M%=V*1I2B\nM;FH6=4U"J)L&:X7@->UT%>L\\BX70K!0&MERXS\nM'Q(^)I)Q+&:.,0I1"<,X,@Z6:,!:3]=U6)W1T?&UG0TJ(T<)[@A`SL`EA`V@\nM!3P0X(G7UO*7M_9$RPI"1@2V*F'2:A91@RCJIF%1^^6X>&`<-9/I&MY[^D[3\nMKJX3W,C6BL8L&3UB(+\\$O(+D@2?#NSQJ'3$E2!&^DR3[;FW:KSQV*NW7^'%$\nMQ4S2AB9X9M-'>6OG*RSF'I^$;&2Y"RS4FM%ZQKXG5H)$QYF==;12[Y4@!M`5\nMQ,AG?O\\7_?B-_EY4=C2U(45'92#'Y]`2$%^KX-MAM%XS4Q"[HV\nMC#HRF(B95#@'0UVA)PTY0*4%),WF/(B#;E9+W=A,Y!WX'W0(JX[DW<>)W%[IO,=R^B_=OT@Z4R\nM$ZRUH%J20!4,)U8F?.+\\:3A^9KJZ6]'X;`\\H[\nM"&')0$[T!R_377\\5[P/>@_-E8NM*=+X`"M$0PIVGM-9R<'``P#`,[.[NDE)"\nMB4(M5W^8W(SS9?7>0PJ.^>[+#,,$70O6"4*)50;K*/950DB&&.\\,((3`_OX^\nM(01FLQE55159RJ+@X(![[KF'DR=/,IU.2U:5DF'-[1[0>LE`*M$YH982]1)(I@"0O`20/EP"\nM8PQGSYXEQLC&Q@;3Z?3HF5+O.PN<@\\HL`43P::F[@/,E;5HG!8`ODAP!B.6T\nMO)/Q3IXZ34P1K10Q'>:)/77OS:*LM6\\IELI3+O;$D*X@)YF-41JOYX:8QSI4[GG.PTK;4]19-\nMGF+T)LUZA=$5[09HTQ!C0IE5C`9G!P[>^,TOV\\_Q+5)XSR8LV;!<6./RXAK3\nMLK80T"('AZ!-"*`TQ,CO:AE]O_R]\nAR948XGKT````"7!(67,```L3\nM```+$P$`FIP8```&=TE$0518A>V62XP<1QW&?U7=/3W/GAG/V%Y[_5A[O,D(("7*P"`D(!8E('$"(`Y+-`0DDI!PX<7;,\nM2R`B10D.H!AV;:_7NSLS.SO/?E9W%8=9;-9VA`_FA/_2I^Y2?_KWK[[J*C4\\\nMKO_W$@]CBDX`8&T.L_P[#_;];`H4.$!JP)Q?^^^]Y<,`&`0&<3#3XO-!B-L[\nM^B&@$]\\YI<7IO"/Y8>,1`4PH3$$7BM_2!??"<(Q[>_X!S6P'85E/6(7BI=;8\nM/.M8@N_5'A&`\\3'.J;-%^_0+KPK/OC#T*LG7ZV1*Y;TW',OS-4/S%SJ\nM^!.(U[Q'`$`&HE@VQ9>^X+K/?.(56;&^,0@I_.705IO.,AI[]G'\\^7/S]3U3\nME]KA!.+E\\H/;VO^^>?5'/T>EVFG6O#/=UNW&VW^X,KZ^<.VR[3@!O`,23!0@\nM,T7E4R\\5XB!X)?CS[ZV!G[WQIUG"4PM`EH'1J.&`;;OV,V?=XI%C%RQ7?'.H*+QU`(S68`SI:$C<7:>6SW-T=FZ^6BK^="4V9PH2\nM/EO8NO'N)/"YMWZ`"0-RAPZ+CE7AN-L0BT8)/>J!.P$P<0B]-EE[!=-IX=5K\nM;MCZ>20*M->,;BP2M%I+)$@@))AC"J,N[.S_"]W_W/K;CQY[C%VL#AK[/_%,G:=Y>X2[(THNKL3GOV5PYJP7VFP<%\nM!AJ_ZJ1?J4BQ<_^MUAYM#RG[@_JIZ?"UNL-`&7!S;-=Q6,J0_*T7LF?O?AKU\nM&OU>EUL*CC9WY,+4?"WH#3I&)=S,H+%CBH.5,KX_9E7:S`C!,2GG5):]?C/A\nMQ:)@:&_.NR:-.:\\UTVN=/D79Q[/P7(LO&L0D'+'I5#'>>)DD+I/?O8OB\\H#]\nM)%B6Q?9&,Y]D[#5*(:]?(VSL8_>N*:+5VS3Z&T@A:`K!TX+:;HSC&!#+QX"4\nM63ES\\#>R,35M8["$P9)@";`L@25`&HVR;+)9)45D&I6D\nMQ)$BB17C%-YSR@QS!6KM-7;W^XA4H^*45*57=68^#G3MZ9R`Q,#IY^'D&1AV\nM(1A"-)YH&':)(H94F\nM!1*M`3";FNP"/T^_07UJDDPE2E9+$$5X4,Y,,(>>",0@IZ>^<95WGB*.8\nM,%(41CVJK:6M1YP0B">/D[IEHC`FC!6BW4%^\\/<'G`,"",?0[W`ULOAC?IH;\nMMVZQNIYP9OLVONKT$)O,0DK>K\\[P5[O)XL(B:[T^9_)-/BF7M[Y?6G2>.,;M\nMZ5D6%J[3[O8YXGH<_L<'6WSR#D#@P[!'IE+:W1ZKK0X@L6R'>RM-,UJM#BMK\nM;002V[(G^?\\G`)"FFE9[G=75-B"Q;?N^7O8=C-"'C19*55GIQ.3+E*MU\\G*$N;>S@$0IEGMKN/D"Y5J=O$GN`[V[!,$(;@PP\nMVYY"V$UJ%8]BI4JAF&P!$$"::2S+H5(M4_)JN(FZ;V8"R#*-M')XE4U0?W`?\nMJ`UF@M%K@XJPISY*K;2=6J5,OE0A3P_6S83<:#`")^=2VU:D7O7(5SSXW)9#R/0K_](4L@@'X'W#SSTNW?0G&V0R[DH;2A0)K?W`(0Q(HH184*:*`XX4*M82#-&K0]0JTLD]R9E\nM3@*&G3CV=RA[#6H-0ZT.Y2J4/2AY4*I@BF4RZ9`)"V.[:)DCPR)5"N7[*#]`\nM!0&)'Z#&/LG81P41B1\\0#4:$P]'DVA_))(IOZ,R\\#HR$.;&)8DE)8J!O8`PD\nM@`+T)"&309A.'HV`X:8"(&+RF:A-I4"V*GKT````"7!(67,```L3\nM```+$P$`FIP8```'ETE$0518A>V766P=U1G'_]\\Y,W/GSKW>KQ,`G&NZ^OKSUW[FQGZ4-2IVGL$E#5OO!_')TY_]^<[W\\^?0-\\\nMIO^SZ),M_RJ`47)6?-UI:*TICZ0V^H<+0P2(:.\\-GPK`.-.%BRY_#%&LZJ]9\nMW_"]IL5E%WB!K-WW[L1$WZA_M6'0$`#@_)V`1@*^S]&PJHCGK@`P\\M\\!\\&,@\nM%D@2Y]=,>:)NWY%)O#]0X((;AB8"UN[&Y2L7XMB8=]6%K577C^4*]SWWXBVO\nM)<];)/V#\\Y\\./U.`H/H*1'M[\\^Y9%2N.#'IMAWIG,!/J&1A\\E^;&-%DFCKZ5\nM33>U9K:O7I[9V%A7NJFZK4:_,QYTG=W^C7CZ;[^?<]\\Y,U"_X7?@I-+<3JP:\nMR07[A=1%/UT&BP%"JILTZ$%-C(-S#XP]#]`Q$!T"P5Z("2%3O@'GZ:W7S7'3_(NO&/7NV:N#<_$?X*'">45A?#!<-`[VNTI\nM`+S5\\BDD"L\nM@$AJ"$6HJ7:PQC;Q9J^+D7RT`+9M`0CG=?]W`*T!U)?+5]\\:[2PO=U-3174A\nMN.&AM"\nM_@)M3_*R9:5+.2%PDGQ@\\)&U\\V<`^`IPTT^`_0?3J*W<8B83.WY\\74NJJ:X4\nMAP>+B#4A!ITP)<0*R(<:1\\9"#.=C1+&"5@J0$I#R`Z;DW0WE_*)+FM,;XE#\\\nMX=>W+N^@JUX`GMHP1P8``$\\#CSX-?'E/`;'T%Y^5MFNJDGAWJ`A?'O_:4!,^\nMG);!D*NZ!1C+^KHE[Y,)9@'6"7/&`*)F+?`P,[A159I`J66OHHN?31DU*4^<\nM<&-S%F;SLX!E`8Q]KJ8JR;.>1#Y0\\`7@2Z`O+Z,#'X4_?;\\WN+1G3*S+,^M1\nMV`D@81U_S[+`$R8LVR3-#:,G)_!&OPD@F5$R"+.#L=8&%5$@F3U=77ENX^,E1<.%K0&D357J0Q\nM'2CX@A`3$!(AXH:#\\TK+$:HL[GX3^-F%K:6NGRB8%8AC!8!@!%"\nMW#XV$^GLE"])RC']+]&;!6!$2":,>/7RZDK!IA:/=\\]`$6'2$W`#B0`<,6G$\nM#$A9O)$1>T"U5?P1CUQY!\nM]^#$=#@FI'Z,"-]U0W5T,!?!CQ3ROD+_9(S!:0$M`%7@5!15Z$,M\\H(?O]0:\nM:*KD<`S"I*]\\D#8PE'=P9R]0]LQI`*?T@=IKGX%?C)?$$H[;XW:CO26&##ML\nM)[$]76)S5QL(F3F;=%@68%J`:1R_=DKAG)3"FH7`ZWU%#(S[6)14A46.WCLS\nM$^SJ[IE^BAPSTCO;3R\\!``QU7@D`_;,/5KT&$#TUUI=W%B153O@:^0B%X8*^#8E$`,-H!^=+P-@Z$#E$)`G8RK5\\\nM-#822'IY<$;I*IO61%Z\\3X+<\\?O//\\UJWJFX^>97,)3U4ULNKKMU67U91R'6\nME7NZ\\B__]=#45:BV7927`5K7`WB-<;9X294%(?6N#_<,?ANKJB1^U?8?:GM2\nM\\V:@^Z%U2!%Y.Q\\X?$]7W_1U8[G@>;<0_&;C114NH@@L"H$HU-4)I=L7&;CR\nM7`=?K+?6F^WEC2E3G9$Y\\#%3\\?@3FP#:)A\\?6?F2?OOH&T@8HKL'P)\\V(K'U\nM`(34V8>XQ=5W7&?_MQSKGGWCOCF?'X@<>.'PUV\nMU4XI-0NPF)/$K!+\\RML=%`HD;YH_ZDJ[./\nM[M%>W[?6M_;9^\\!9G,59G,59G,59G,7_7ZB7\\O`#QYIX(0J-&@BM7A%9U1,9\nMI4*K\\\\BJ4]:H82><>JR=IQOCD)61`6"X])1*$2-QZ65A7LI`7DI_YGR0ER)9\nM*9.Y\\X-Y*2-*45QQ3OWE"[AMQRD`K16UP.A6+302&.+(JJ6159M"HZ^)K'IC\nM9-6"R.HPLHK(*A\\:W0Z,&D^='#C6R'?L&FK_Y.[NKD367KNFY8./2^/+%\nMW<&;\\7)N[F1^5OHX*T7E3LA*GV6%C&9.=F:E_T%6RB.YDY'2D34SIW,G-2\\R\nM"\\C-FQ8\\AZ]]O@#O`7B-TGP9R$OO2Z/5:[Q7JT58;+6R5:NI!HK(*`*C"+0R\nM5A,817>A6"7"[R:%W#0U.;4W":U-BGGK!&H&T$JAE&"T(K"0`P&ZJI&5SON5\nM*5SOA1'GY4#N9!2H`(47/JQ@ZOE\\7RA`!($U@=)7!EK5K%:$ND.X;J%*3B4O\nML:5@3*=4:(W7"F4-H;8LC!0K>H+N2/N+*UI8UAW0:P25IKBBP#F'>$%YP7A/\nMX"$6!`5_;&A:C6U:A6M#8(@TB$O"K0V>.^)*Q5":UC2%]/.,O*\\H'2:Z>&VFI3@\nMHO\\>RN[ZBVUC\\IG+%OYJ`IWIHJ!6[\\)8.VWG.3Q$9Z%,%4BI\\$*&M08@P6H-2\nM=-L$"K]QW:*PUWF9_%\\K,-?`YRE?#LRK&!2*LBRQUG:"SZU9.HB0>0M(G,,H\nMC5%@@@B\\HT2ADAF4B^8L(IV,S]E%D`[S,Q#$!!1!C/(>E:>(UMBR0"5-5%RG\nMIV*A5:X2@I5>GBM`GQY\\=,L(2H&'-VM?5'NJ(67I.@]I\\TQ,`5$:'58PQJ"4\nMHIWG9$5)B6*ZA$90)S('IM@N]YXVA%'378K(\\QQB+*'7&LZ?3IY4B\nMSPORH@"E.RN+"-5J3%2)45IWR)UF_^SQ,[GO6$QIPBC"6HNUMM/DVN"5IO2.\nM>AP22J&\\ES79SV/FK/3F4(^ISJF+"BGQLF:LV?B>N\\I2T\\E\nMBJCJ$N?4X01CP[<<\\$%BA+G/.X\nMHL#G*8$Q5+-9>M)I5&OZ#.$SS7OF^KRY4%AKJ&E/M35)968<\\HQ(01R%U*LU\nM5O366!B;52OJ^KSNT/"=O_T.,-?$*__@\\RQ=?@[[]^W;%&E?F5^K(P+..(]!!:EYARM\nM%![-;.G)XVZ$B=,N1U!D68YSGCSOO(V]R)P=-4HK*I68,@A)TI3(!IR*,-=UZZ]]N,_^-H/OF(!HGH?"X/Z0.;-VKY:Q+QZ\nME33+.O9!418Y63LA2]LHH%*)B.,JUAJ4`JTZ7BC+$N]S%.#*,F-3+0FV'Y@\nM.]L/;&?/L;W=R_N6?^I=-[YKCP4(Z[T$77I=6K+(]BXF$4LV.8("BCQ#`7$U\nMIKN[!Q2TTY3QZ5F<]R@%5BLB:XBCB$JU2@7%9#(QEV%!`3V]/7CO::<9[6:;\nMK"QQ7O`"1FLJ44BMNQNK#).M$>[XS]MY_=+7,]`SP/W[[N>!IQY@;'J,WEH/\nM[[WD?>72>4MWS2:S#?NN[PZQY7O?8^V%FR[*LU8XEFJ.S.2<$U6H5F+BN(+W\nMGNEFPN"I468*((BP84@86B*CB;0B0@@RA[2FT=Z3Y.691FUE!4-CDWBE\\28@\nMIT)N%)EX,B?D:4'12#%NAO5+ZWQMQS]0#:N4KN3.;7>RY_@>7.E8MVPM'WW;\nMIUFYX+)_7V;##W7-GS=E>V+#C1]\\7^W)PR?>=&IDFJYLDG[IQJF`H+)-(U-X4\\$&`7&HJ86:6F3H"H4HGR24C-1T,9-[\nM4O$\\<722W0<'F74A6=1/L]0T4T>2"VGN<$5*EW&L>4N%?]O]+200[C]X/Z/)\nM*#K27/?Z=_)'O_-IOKMMF!W'FKSV_#>L7ZQG%_?UQ\\?MKI\\^`+X\\-X\\7]9=I\nMBQ/)%+:[GZ);$;B"]JDIIAJS3,ZD)$ZA@Q@;5;&10ZQ%/#C?V,JRY'6OJ7%H:BO[9P[2\nMREM,NDELU7+=VG?R@3?>RCT[QGADWR_QE?DTAO8O>73_R15*F^/VH2V;$9%Y\nM-JK:H-J%,996TB8X_#2B+`Z#"BISI&.P'L0AWN.]X$3PTKD6:4K>3DB3A,;X\nM*,GL-`A4:G7BKA[RN97,F!@OX$00[XF,XL+ECJ__XAXF_209&28VO&W56WG/\nMZH]RVS=WV;!,DRZE%%:\\0T0"7V2J3#4256G-SF*R$ENI\nM8J(J5CR(1\\3/XOT1\\7Y0Q`^)2,/+W.'*2W>>I4O2)%F>)JUSRCR?KY0V*"C+\nMHDR3UGC:3H[&6?MH&/L3WM,400KGN&1IUX99_=`[=D_OU2YTJ$!Q0?]&;EQW\nM"U^]YR![#QV!(L65)2Y+\\$6N@4!$L)T-OI\\2\\8,B?C'>1XA7B!?Q/L.["1%_\nM0+S;+M[_1+S[I7=EP^=%D;<3'KSE(BZ_;0O)EV]!_\\E?V31I=J5):\\"Y\\GQ@\nM*2!I.QL=$MKZX]G9G8='N[52D(G7HGW(MZG(C($,@U@!8]XOQG8A?H(>9)WS5L\\[T-/\nM-9[Z\\),33RYMNJ;:L&C#Y(5]%]YV[*EC=ZS9N"9WJ7OW5T]\\]9MW[+_#"L)E\nM"R_CLZ_[['WQ1/S>S&93RU"WJ7]'[FOB/W??9@\nMX^"RU0M6JY7S5[)C?$??PXV'/[7BO!7OOCZ^7DWXB=][I/F(U57-HIY%O'_5\nM^T?[7?_G^Y;U37WK[F_]VE@O^*SR?P&E5.=0`JW,9\\7CXX_;1Z<>93@=IJ?>\nMP_BI\\=I`;>"FNX_=??2)\\HE-A]PA@EK`M8NO96.\\\\:Z/O/,C#]]PRPU\\\\I.?\nM?"7H_688/#C(H5V'PO&)\\3^^>]_=8QN_LU'Z_Z5?EMZS5#8^L%&^>."+1:O9\nM>O!+0U]JK_GY&KGRR2OEB<83OV@<;ZP:&1GYC>.\\(A8"6/G:E4PT)O+OW_']\nM?[QFX)H/?NZBSQTY?]'YJ$@QK:?9.KO5'E%'+MGK]E9,S7#5@JMD%:O^:=[`\nMO*?W[]__2M%ZZ=AVWS9$A,9HX_+M(]OW7[WS:CGWP7-EW>/KY#V#[Y%-@YOD\nMZN&K9??L[KWCA\\:7'3UR]-6F_$+<]96[$!&F1Z+U<,'*!W#YSNTPUICXN(MQ[[[VO-MU?C:V;MYX6YL?G4Y2^O'U'1C^L^^/?/M[$?-'S5GQF;>EK22ES7?\nM*_8F?C$<>.H`TI)J_YK^.[76JTXO7OQIT7AY.#I]D\\-#@JJ.#\n@1R\\%N/766U_6//\\#[LK3K##A%88`````245.1*Y"8()T\n`\nend\n 6557 accounting_write_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```,O$E$051H@>V8>ZQE97G&?]]EK;77OIU]SIPY3I9/QPH>H="*%DX72\nMAZ.EDRFEJ&[:VGSE`CZU?Q9`:T4C,KK?B(U$AC2Q:DMBU?6QT>](K+HFL6I]\nM8G6<6$5B58B-'D1&S>5>#IU8*O<_<7)P_W_B*_]20$A`+!):>X&2A>",UIM"D%=),)&JY6M6TT]4B1&$1E%I)6QFL@H\nMVI7B0A%NSBKY\\.+"XI-9;&U6C>P2:!A`*X52@M&*R$()1.BZ1G;X$';D<&L0\nMIGR00Z67,T`-J(+P9PH6?Y+O3PL00>#B2.FW1UHUK%;$>DBX::%.2:UT6"<8\nM,VP56A.T0EE#K"T3B6)[)VHG.MQ0T\\(%[8A1(Z@\\QU<5WGLD""H()@2B`*DH\nM4!9M3*1%;1-1VT(`,5!YF?=!=BBE?KZ`CS]X%@`OZDUQ*!H34F"\\)D'1LH:F\nM:-IQ1*M>(XEC\\L$`[QQ*"?6T1I$7E'E.ZH6==KUB%IUXEJ"\nM,0:40@`1R+*,7K]/4SP]YTF\\D`H42BB#8SK$8YG$5VKDL9\\KP'FA[R1JQ'I/\nM0P9]%$D!L94A3A%B!*T-0@)1FM0BK;-H`I7\nM[=H0C_H@"_]C!U8'^!(5W.1(S:!0..>PU@Z3K^XL'27(R'HR[S%*8Q28*('@\nM<2A4MH+RR:I%9%CQ5;L(,F2^!D%,1!6EJ!!098YHC745*NNATB:=FH6^NU"(\nM=@1YL0!][N9#]TZA%`2X3H>JWJG'..>'A[1Y/J>`*(V.:QAC4$HQ*$N*RN%0\nM+#M8BIJ4)N8R9=M6#C[UU/6)#K5UC2%I[SUF=8#5ZMY6#"L]&!246(Q5*$!K3='/\nM<'&3**HCH52SXM!*20(?1NDL8K?%%Q06'\nM'R9YZL<=M[)P8W?WVQ_>,ZJY;3$,!:@XY9_NO"M]\\TTW7;LN[3/6&J>J*E!J\nM;8!EF)6JJJBJ@B+/D1`@LBBUZFBE"&BZ+E"F;83Y!LAS^&@>1\nM53MJE%;4:BDNBAGD.2A--+Z%N6[&J<>^QN;O?(7+'[N7)3%[_^[PZ;O?>-EU\nM!0_M'PI(FF-,1,W)(IA+QQH)(\\TZ>5$0Q0F"PE4EQ2"CR`5EZ&R\\,Y3U$49-D*`D1Q0F1B\nM3BT?Y\\Z'G^:1F9S=9U=XNVMQX+)W;K^G??7HN`QFU@3$S5&BEMZ5.S;8T8UD\nM8BD6IE!`518H(*VGM-L=4##(<^:6NT/_*[!:D5A#FB34ZG5J*!:R^=4*"PKH\nMC'8((3#("P:]`85S^"`$`:,UM22FV6X#BBP;<&3F`/O3+]*^\\A!;#NQ@?^N7\nMV=>Z@4V3UVS=6)87A=">`;#O^M))[OWRE[GT3=?O*8M^?#;7'%LIV9K4J-=2\nMTK1&"('E7L;1V3.L5$"48..8.+8D1I-H18(0%1[I+Z-#("O=VJ#VBXJ39Q<(\nM2A-,1$F-TB@*"11>*/,*MY2#6Z9M8:R=\\)!\\CN6=3=-2M'S^Y[Q^>/8SNIX4_>_X>-'Q^9OG9V:IE6L<"XM/$JXN1"G_G>\nM/$LE5+:&K;5`&[)!(%L1!$]B`XW8,-8P3#1C&FF#7NZ8&O2HB##*PT\nMB:QF(0N<[3D6^HZL#!1.,$JHQPF-I,Z<$^XY_$V^D7T.%5>,A`W\\0FN4T[.6\nMYM(D*]4,G8MV7O_66V^,3AT[7=D-HS5B*UL[[?HE9XX7//G$8RS-;J2U?C.F\nM5B>.1X@CBZLJ9F>7.+TP8*E0!%/#1A%IK&G$FD9B:,5"4BX02T%N6JR4@5P"\nMCQ]?X(>'C]+U,44R3L]I>KDG*X6\\]/@JQX:"T52Q9:3.PZ>.<3`?,)9XKMCX\nM1AXY->#HXY?"X`QJ4-$YW:*?O$OF]#<#O+=,.XR_M,9XO8]CA5\nM6Q'YBL'L(HM+7196K8Q"/6(@%\\&#[)+O=SEJ9FF#M^B(4STPR\\\nM!0)']A5T)C8SONTB.IL;2%0GG'N,D$`(GD%1T5WJ\\\\3CL_CMM[!K.B4_\\2B'\nMK]Q,O]K+2,M3FD.4Y3J63AS<_,@S,]N5-J?L0_=^'1$9L4G=1O46QECZV8#H\nMR'.(LG@,*JJMDD[!!A"/A$`(@A<_I]9/47+*1RV5L'*/,^U15%^\\E/=Q;F>>^L>K[]\\\nM+P_>?C-ZTS_"]-F6_/&O_XM<-K;GJE/S;"\\7E[^[.'4H=)@,13$65!F+!"4A\nMB(20B\\A)D&4`-7+#NY$0(A/7)DU<>X.)TPTF28V)Z\\XFZ8R)TQ,ZJDV;N)F%\nM*N?@9]_'JX;:7T#^:<-O?N.ON/'B.R:G5Z);JJ7JU#//W+%/3GQFTP43&UPQ\nMV.J+P80O,^.+@?/E8-J7^9'@JRF4\\J\\>F9>-F^$K`C?^VV_QB4,+]8\\^)>_Z\nMP(/R.[=^X0OPNZWUXQ]X25%>UHNM5P\\WP-[;86;J"GY[SQ>)DTM^Z<19+JS.\nM?._^^[[S>ZWVNJ,'#OSM2XJD__HP<.?.(EA_JI]T*O.=K_`$`_2"L_`W<\\M7W<>6V]T>'Y]6U55=\\?_J?[WO@\nM2Y]OMY_$^_]X62'-:T3U9^`&^*./@_G%O;QMUZ=UMQJ[;F:.#7[VG@?W[?_(\nM^O4[N[.SGWG945^W&;"[_Y3&_H/,U\\T1ZYIJ%IV?8YO+YYYY[]O;;;OOS\nM)S_TES<#C[^BV*^+@&:SC3WQ[U%K8M/NF\\IY%CO^]'W?.G''P:>?_?HCCWZ'\nM5TH>7B<+Y45)M]L?[76[VUU5?,OJV7<>?/;NS_W*KYWU9?F5_U/LUV6(9\\].\nM<^+HH=&JK*:5MG?5FYW#WW_H`9X[//UZI'_58'@-"O;?<,`@#IZ3WM$`````\n(245.1*Y"8(*5\n`\nend\n 6558 accounting_zoom_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```-+$E$051H@>V868QD5WG'?V>Y6U5U]3K=TS/M6>RQ9\\`#\nM>,!@&Y(8BQCR@,.2C22*$B4((@@O(!(B$2%")!+Q$!*41#R01$0()7E`H("8\nM$##&#C:#E_$,P1Z;V:>WZ:VJN^K67NX1JNX1JNX1JNX1K^_T+].,%?NM`C"$ELU.[8ZGV)56.)42JVNDJL\nM6K%&S7MAY9%!51S)8O8G!H!Y%W!*D2&9"S)=.=E=.9DJ?8@J)U(Z6:]\\.%LY\nM65"*^NX]K?^Y@(\\\\N`*@M:(9&=UOQD8B0Y98-9=8=4=L]#V)52]/K-J16!TG\nM5I%8%6*C!Y%1JX67IRYTJ@>/7QS<^_6G-QYO)-;<>7#LI4?FLKMVMJ/;"'*@\nM\\C)9NI"53E3EA=*%LJQEN?3R4.G"YTHGQRHO"\\Y3]DJO*R_-(+(%R'OOV/$L\nMOO9[!80`P*S2?`RH7`C.:#4;@KI)A)U6*]NPFD:D2(PB,HI(*V,UD5&T:\\7U\nM(OQ"7LM[-M8W3N:QM7D]>EB@:0"M%$H)1BLB"Q40H1L:V>]#V%_`+P=AP0=Y\nMJO*R#*1`'81W*MCX7K[/%2""P,%(Z==&6C6M5L1Z2+AEH4%%6CFL$XP9E@JM\nM"5JAK"'6ENE$L6\\L:B>R0(*@@F!*(`F2A0%FU,\nMI$7M%5%[0P`Q4'M9\\T'V*Z5^N(`_O?\\R`%[4K7$HF]-28KPF03%B#2W1M..(\nMD49*$L<4@P'>.902&EE*691414'FA0,-RU2F26/%GKA$]7I$(PWB-,$8`THA\nM@`CD>4ZOWZ16)@0M6(4X0H05N#D&"T!J5HVQSJ<.3P3#SN\nM@ZS_P`IL-_`A%=SNT=2@4#CGL-8.)]]>LW24(*,[R+W'*(U18*($@L>A4/DF\nMRB?;%I%AQK?M(LB0^54(8B+J*$.%@*H*1&NLJU%Y#Y6U&$LM]-WU0K0_R+,%\nMZ"LO[SZZ@%(0X#8=ZL98(\\8Y/PS2YKMS"HC2Z#C%&(-2BD%54=8.AZ+KH!.U\nMJ$S,%:[;B2=(^&X%MDL@(HA2#$33P]"W*06&TB04V2B%3AA)#";4XT%XF8CP\nMGB\\N/5=`$.@.?!P"+X^EIMW,**L*8RRBU%7/7DF?5HJJJJGJ&I0>KBPB-!H9\nM29JAM!Z2N\\+^F>_?S?W08DH3)PG66JRUPR;7AJ`T+GA:64PLM0I!;CN]5JOP\nMC'&N"JC*$N^JG=[[PTWMR-*4HBB(XG@XU96FNR)$*1I::$A-2WE2!4HI7%F2\nM]WO;=GE&/&K;3J!0H!0^!*K:X9Q'UQ6^NT;5[U^=-X2`HX`X36F46T3%\nM@&477R5\\M7FW;=/=W&)^<9E+EQ;I=+HX[XF"8RH6]NR:9F)Z)R0)J89@(Y2V\nMC"7@\\_)Z5Y0''*P]2\\#^W_HP^\\QVPVLMM=MQ3#3\nM@T%)A<58A0*TUI3]'!>WB*(&LMJY:B%!0"GJNF9A>95CWSS.HR=/L9&78"Q&\nM@2\\+M"N9G1SC]I>]F)>.3J%[G6&UM&4BBW`+_;'^YN9MXSMFOS'UNG>P>O1O\nMAP)4G/&7'_Z+[,Z[[W[%9-9G8F2*NJY!J:L-+$J!"'5=4]?XQ'SBQQ_>$7.=(TP85`412L+RUR\nM[L1C?/;?OT:G"MQYU\\\\!8$S$1+6*KM?9ZO5N^]1;]YOK?OU#_FH%DM8$TU%K\nM=QG,"R>:":.M!D59$L4)@L+5%>4@IRP&*"!-$[*L@;4&I4"KH36<,OTK?[8C;4\\N7140M\\:)1O3APC%CQW>2\nMBZ5<7T`!=56B@*R1T6Z/@8)!4;#:W1KZ7X'5BL0:LB0A;31(4:SG:\\-SE0A5\nM53._L,!#I^:YYTV_R('9";;*BK5^07=0T4HC6EE,,XO9.=EF)/UY_O,+7^3A\nM8X\\P=]T6<75EFLP:B!!O'Q+$E,9I$*Q*$J/1(OXL.@;QR\nM5YN^JAVG3I]G9/8Z;IR;HE?6.`P=IW%12J$-OH)>5="P,#XYP0TO.,13CQ]G\nM:7&9O5G&@HM8*Q1E'5K-R5TO+S;7OG;/)\\]CQS+#6]_VV\\W_.KWXBI6%+B/E\nM.E/2QJN(B^M]UGIK="JH;8I-1T`;\\D$@WQ0$3V(#S=@PT31,MV*:69->X5@8\nM]*B),,JR7L+\\Y75F]A^F]$+NAL]*#K4H&HFFE5J::40IPGJOPKCQ)'%U34K*QWFUP=T2D4P*3:*R&)-,]8T$\\-(+"35.K&4%&:$\nMS2I02&"M5S,H*ZK2TQG4=`M/OQ96^YZU0<"H$D.@&2DFVRF[)EK$K3'&Q\\$L(GL>*`[32F.\\LK;`Y.$#EH?80:75UAZZ\\(^]7+%Y>1^UNTZJZQ-;2KV)<\nMI5GI.1:6+U,GDW0NGMKUS5-+^Y0VE^P#1S^/B(S:I&&CQ@C&6/KY@.CT&419\nM/`85I=ND,[`!Q",A$(+@10@R_*V+@FJ04^0YG=5E\\JTN(0B/CPIO?,7-'#M^\nMCK,KAYD:;5$XH7!A^WPTW*X5PE0K9B*!I\\BUYG%>_.\nM.(-!]\\\\%C_\nMUB.'MWKYH#>_UMOT0:HXCHVV<:N1)CMNF&JW.Y<78[.ZR#?/KI(SBL_7\\.7P\nM\\N3+G%!7&HA$!#L\\X(<-D7!6).PDA`0)"@DB(90$OR82GI+@[Y,0[I7@GPS>\nM=4)5U]4@Y_[WWR-%WM_MO7L1,*>4DLU>_VQGJ^=N\nM.;3O(YO'3ESW'Y][>KF.DC.^'JPE4O>.G-^\nM88D)@$DDQ")!20@B(10B3G=KMJKK\nM./@@(&5=54_V>MV+49R\\7@_Z7]WU]+%W?/3$J>_<#CST`\\;]B0FX@K?_P7LI\nMBMSLF-FU*_AP$TI/]/LYZ^MKB^OKZT_,WGBHOFO?]-_?F(5?.O7/__CT\\7-+\nM[_Z].V[YMS=^^@M.]Q,7\\*.P\\%?O9V6C^QNS1>>3YT\\\\;KX]?L,3]S]R\nM\\BT[Q]HG/O'0HRQ^3[SYJ;#\\(;CEW".<.?'8^\nM!Q_^T@LFQ_*3O?Q9\\<\\[`9V\\Y@UMU[]8\\<2H\\J^9Z*U.J)U[#MC)&?.IQ[_]\nMU9_)8G]Z^ZX.ST,!YVJP*/[D9A:^OJ96)ZE?.^H&B=ISTTLFHV3AD^6.F6C-NZY59FB0RN^_(Q_[PCQY^W>%#%^X]\nM/T_@>2H`X"M;\\-Z=*ERH.#YJY(4SQ<;!9')FM&Z-'_S\\EQ_X\\HNSN/N$\\\\]?\nM`0"?[<([I]5@H58GV[A7-_OK.\\YY>UT0B?YI;>OH*PVB?_0P/UU\\L0NO'K??\nM.E6H]Y_7C8W](]&9O9&['PA:/0_W@>^'#QYHTQ<=_6Q;OV:/+RZ\\YT3^Q)L3\n>Y!WE3YO9_P'^&ZX+2WXT43Y:`````$E%3D2N0F""\n`\nend\n 6559 availability_write_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```*PTE$051H@>V8;8Q<9W7'?\\]S[YV9G9E]F[4=;^QL["3$\nM&+!#&DN.`(4T2MK05OD"K5"J"*$(":E2D2A%02!0O[2BJBHAD*`2;47:2D`+\nMI)&B"HNF!1+L4MMI8LC:7GL3>]>S.SNS.[L[;_<^K_UP[^RN\\0;B-62_^$A7\nM<^=JYMSS?_[GG.?\\'[AI-^VFW;2;=@,FMOI'?Q*`>X#W$>!Q@`-GP3IP+ONT\nMU]X[!]:"L7CO>1XXM^^#6XLCW"H`YT`('HH3_G;J,F@-HK\\Y7"3,E^@L\nMOL9P90RE>OADA>)@B;C3(A="(&/*I8"<:^),O`[\\K01@#.!!*]BW_^W\\SA_]\nM->=_\\B5&*CLI5-[.I9-?9_RN]]!>;="JGF!DYVTLSD\\3TD$`411BS0K6;#WX\nM7PL`ZP"?$+>KZ*2-BB-$>PZC8SKUEUA=?`W56J#9?8EN)R"?'\\#I.L71.Q!6\nM8C4W4(DW",!GA8F+T9U9C&IC8K!)G:1]A97><;J='H2[D#9&ZP%D('`:K`O!\nM"(QA>U)(:_!!VDV$2U"=*QC5IE/[&:IS`9T,X?(.Z\\`;@12@C4!J@==@;8`W\nM`K/=#%@+^!C5OH3JUA#F$E9WL'888_M`!0)0&F0@\\"9EP-N4@6T!H#6XC`%<\nM0KMV@FYSBK`H,3I=;2,S`%X@Z7>N+(5L@#,B;;]R&P`8D[9VK4'WFK1KBR@5\nMH7,AUH#6`BW3`#T"Z5-0H>G70(`U`KU=-;`QA4S2)NF!UB.8+*\\W,D`?@(8H\nM6B]B8^7V%;$QX&0*P+N,"9,%KD%;@9;I,X1`.E)P1F`U.!=@;UE=>"5E\nMP&T3`(!00&409.`8*R_CD81Y0<[/XA&4!R3>S^"E8#"_C-_YM!#LP./=1H'2%R8>M[K"X4Z'HU<]SWZG%*_.SO#E("`\\\nM>)`_CR(F^G[ZE_?XD5%^-#+,>>N0=H/@V2!^A&J)>O78>VN[YN;'H]K%9_??\nM/_["%Y^K\\M3<)@Q8"T`)^/`K4TS,SD,0@!02*1Q""`(A$#@0DD!Z!!XA`J2P\nM2"FI#(6$4E5'1_G'`PGODC](I'"\nM$PB@,$AC?MCLS0^S<_7ET`J_]ZEGJL?O*6%A$P#]U/`>7CX?<=O!)QG(1[1K\nMI]EY^WTTY\\\\2R82!H5TTJY.4A@:QWA*O+E(J!7B["@%H-8]2"*T!#V>F!/F=\nMCS.V>R]+K_^0L?U':"U=QB=U!LIY@6!\nM7::\\ZR`B7F!H,$"I#C*1#(1=G'!X\\FG/-]E.["$*!`<./<#XQ&%>-]/L._0(\nMC9E3),N3C-UV!*F7*>9CO#?0E=BBY=4#=S)GQN.E]_']XN'DLJ##^R]\nMXVA-DZR^3&^Y3M!;)8Y;\nM:#^.4'5$6"(JE-+=6*_/3'C0O3IQ:S;S-8/J-DA:518O?IO.8A5R74S2I&-O\nMX<>WEI@M1;3;<_SVQ.T\\^(=Q\\^_TP(F[@\\I'N_KU9T/-_*],(8''Q'6\\#+"F\nM1[=^DD[]-(&M@ZZA5043^G2EO4!*D`BL#;)-;0,`/$XMH;MS6)/06SI#N_93\nM;*^&6:EBDB%L('$63NJ8;\\=@STXRXG9Q>&C4_=\\Y-?N-[?_F!,R3FZ5]>`_U5L[T%E%K&Q"N8H(6U1;01D*6(#K.=5P@"\nM!X$46!=D$^GZJ`%@U2*]Y@HJ;F*B5:P-P`I<5BM&P7]4'^;"^.=YU\\P)DIE3\nM+!]J85;NHF"'O[4P>?'9TV,/>EW_S%J\\O[2(\\9YX=8I>\\R):ES`^'=B",%55\nM2@M,E,TX2`(!7DJLRU(HJP'GLGFI/-P1@'6CMZ#0F44F,$8-H\nMGW46D^I:W11V^:`>\\S\nMR9AU$RT%)IO[(YLRT.\\TVH!!H!T(*[`N?:FQK+V\\[\\N1+80$HQTGFD?YSFU_\nM1KZ>\\)ZD3;GY'<:'?XCW$FT$S@=KF^'U,>#7&5`:;)#1GK4[F^E>K5.!8A!H\nM"X%99T";+.@,@"%CP`NL]+R^O)=_&GV2MA[BO?4:M[@7F(C^A5PXO":$G`\\W\nM["77"6!-:2F!C20Z8TAKB569A`S37F^$(+!@7;9JFW0ADTV8!D&]-\\(W"Y]B\nMH?(V]IZ:X4#I"GO\\TPSEE^FH47)2(,D`Z*T`<%`L%BF7=U!P$3[<28X"H2F2\nM+PSB5(62KU#,>T:4PN=VD^-.\\L515+=V51=R#O+Y`@/%G0@1$IG=/#WW""_O\nM^WU*IZH&/PSM(IYW5'\nM^$6+A1_5CI:^?_L303BUQ%&]ZO;GO]N](_>LZRX&."_Q_@+*"9R7)+W5P%@Z\nMWF]>!=?J@;3:%[SG">=,WEKSBP+C*M%A-WF&0'A8QJ&=PSC/GSAKRWG?-5\\Y\nM\\_A#Q][UB2_HAAZX?[G)#M\\X%G1?_"NAFJK3OMI7%HOPT,&SLAF`&SA2NCX3\nM[_X642_>IQZ[[YO!6/'HD8MSW*T67CUYXN2'1RN[SOSD^#>`T]?M=\\N:^'KL\nML0\\]@;MG#^/ZXA/_-W#EZ-*DYW83+TY/7_C,QS[VIV<^^:E'@9>VY/LM`5`N\nM#Q%>_K=H<-?X;SVB%FF.V"O/'[O\\%^9*O!`]S`D=*;MSA1M%J=\nMT7:KM<_HY%@HZQ\\\\=^'+7W_X]Q:L4L_V968QVOMO=W=MC7V>)G!TQYB\nM9F1@HB$;($6#(`D*B$T@0!$2$%Y0%!X0+T@@Q#82`O&`B!`*3X@'(B4*6).0\nM;6;,X(S'LW@9Q_9T3W>[M^KJKJI;=>ML'P_W5G<;>Y+8#M-Y\\">5ZM:I>V]]\nM__O_MO\\I>&`/[($]L`=V'Z;N]4(Y!\\`/`>\\C0@A`@.#!!PBA>/>W'X<`WH/S\nMB`A?!JX<^;E[\\R.^5P`A@%+\\1-;GV:OS8"VHP>.0XECRCTHID/R#0B$B)+&F\nM5A81D5\\'KMRK'_<,P%J(8UA>A^?.'>3DJ0^PM7R%H:$:<;E.VKC!Z,0DQO20\nM_A:UX3I9VJ840Z0SANH1I=`DN&P'^+L)P#E`P!HX8^[7KQ*0H($EBO-O"NWMW_GL"P`=`^F2=\nM)6R_@\\D25.)P`I\nM$I.08=,%G.G@,O#]-?J=1;9Z+])->Q!/HWV&M55TI`@6?(C!*9QC;T+(6I`H\nMKR8J]#'I(LYT2%=>QZ3?PO9'".6`#R!.H158I]!6(1:\\CQ"G<'O-@/>`9)C.\nM'*:[@G)S>)OB_2C.#X`J%&`LZ$@A+F=`?,[`G@"P%D+!`*%/9^4LW>95XIK&\nMV?QI.UT`$(5F4+F*$/(1P:F\\_.H]`.!<7MJM!=MKTEEI8$R"+<5X!]8JK,X=\nM%!1:BQ`:_'#P12@Y,#9WR%EP\nM0>&*$$*!+D"Z(G&]Q-ML[5D.Z#LPX(K$M**PJIB1(D7D;F4HA&@;S)X`&##@\nM?@8M&5@R1^B-@.4QL:1;()ZN,'::]?I,]8]=_E7\\N_]3M?\nM]/_P]\\^Z??NF:336OFL_[CG_G_MS`'X_!/4LT0@Z*A$D0M"(*$1B!(6(1B3*\nMU]"@$^+1D\\C8:58:71J]X6NI+2]Z[U:R+'NQW=KZ_`M?_^JWCAX_+I_[M\\_>\nM/8!"J$R*\\`=*L0]!PFZ!,A`F0FAM<2I->>J6]>(\\8[BX\\#9_&T7$L[-\\.HXY\nMW/?#+/'+S&5/<6ENE69G"Z4L$9[@`)]($E>NGYQY_86/S'[!E"*#V$/(>@#KP2Z]>Y?#",D01:*71*J"4(E(*10"EB;2@$)2*T,JC\nMM69B)";69FE\\G'\\Z<8**!'YSH3%Z>*OR*5Z[>(CGW[C*\\1,'^.$G#U.*+/UL\nM@[358&UY4ZTLM(^_L73T>$5.\\_CD_S`^HBG'YC41_@[H_%]_;P/@BOE9>O@TS>7+)+I/=62:YM(EZB/#>/%DK0;U>H3X%D1@S3+&\nMH*P!'Q0;I5_EJY>)O)MWK>OB>TO2B'H;K-W!!`"5$LQLT_^%.52PLH;ZQP^]0Q+947D-QF:\nMGD5EJXP,1QB3HON::MPEJ(!0SFN^`VV@%3_.6O@@W[P^ST<^^@S'9RKTO:)O\nM4JS=9-_$%$ZM4B\\9(F71CWDN7![F6OLTI^U98K>M2+\\S@+SU#RX0;/A=I]^Z0&]SC:C7(LO:6#F`,FNHN$Y2J>?=V()DT!K[<2[>Z#,Z\nM,\\T//#1)N[6*CF.ZW0:)WT"W%XG[#1+?`=]BNC[.T8,)-Q:/L]A\\G8?*A7"Z\nM&P9$0"&X;`W1$=[UZ*Z=(UU[F.X)S!>X>$+J%WD\\2NH\\(*D8-2U,]#D#HSHX;USAAKFYK]DW:JU823LC`6N:%R1!HW&^R@?%QST/1A7HF\\ZE`GTC<'9\nM#.W7B$**5H*2`$%0O@\\F12>:2J7*^-@H8:.XU[TP`(+OK6+,)B[;PD5MO*]A\nMG8(B1&Q<=%ZEB`)$6N%#A+-@')"!JJ]2KXRQMKY!FJ5X9]#>H'4);Q5.*<0K\nMK(^0$)-4IA`S0:52IEZ)L;8`<(>N==L4X@KJKQ5J/*P8V9]7V\nM\\.8&,X[51>)J?"A"R(*WD*0O<&3_",MS<\\PO+].WGLPX>B;0=Q%]'Y/Y$CU?\nM@>H1*A.SI'X?S=6W&*O)=D%P]FX`.+`VD*Y?(NNVL$YOW\\@.!K:!<+$[0YIS\nM.PPX!RD0MY_GX;$%#E1*O/C2RZRW>VRTNZRWNG1=0M>6Z+HR-IJB-/X$5^8-\nM;R][^C?_B^&RW0%PARV8VP#8(C1RP1(P67?'P<+A[8ESP$#AN'5Y7@P8L!:,\nMAV#;].;^A2<>&44V4KYQ]A4NS=]D,X.N*]'U-5P\\23]ZB%>O95Q]*V/AXAD>\nM+E]`B+?O9>_`P+?M`\\A..#D--N1//7:Y,+=.[;`1*6)1J$3GHW*A"W)-#%GS\nM,I/^,_S8["]R_EJ?MR]M4!V.Z8Y4&4I*!`Y;>OLR3PU]C*.GA?;RM\nM_NYDW[8*2<@KB7-@M<(584/<<%&_IT4#R/IG&?&K'!J\nMZJ=IC,ZPLBFD*YYV4"C)J,H<);-*;>@8#?<>TM:K!(EQ]BX:V38#LL.`L>"C\nM0J07H>3M(!>*V$=A/41NAP%;E-(0>\nM(#M5R.T&4$RK5@":)+TVE2A#^6N(GT0'3:^745Y\\B1.]+A5ON;PQ15M5&)W.\nM\\FW([QI`@%JMQM#0/BHA0>(I2E2(78UR99A@)JC+!+6R,&8,4MI/B>.4:^.8\nM[LJV\\];F]RJ7*U1K4Z`2:FJ*:E0C'BN15";`CE+Q(]0J"<[V\\&Z*N:]]A:G%\nM);+J>WDC^='Z\\V?.#M4KE75H?0<`.4H)0GNX;#K*-T(L"LE6<:*)16$SE6]6\nMR1R]CB:(0N1-LI"O9^EF[`-=ZQ'GD.!)A\\HV5;+A)2A46,L[MVA<]A8BBD@4\nMO5011"-LV>^\\H'%UX;Z1Y[[V__QH\\\\<>DO7SK_F<SP^__Z`T^1%.?=QW[`_Z]]N0V?WJ_"O.&5T4A.\nMSF3-$^7)F5$[-'[B"U_ZQI=.54M;EYS__@4`\\+DM^.2TZBU9]=H([D/U=&/J\nM+1\\?"B+)9QOM_WPZ0NYC2^G=L?_8@@^-QZ]?R=0?S>E:\\^APCD_2/Z)P_[;/Y3KW8O?;R,_&Y_KSW['MC_`M.A.4O;WSF_\n,`````$E%3D2N0F""\n`\nend\n 6561 balance_zoom_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```/84E$051H@>U99W18\\60@D)>0DOP*,^4TQYCT"HICMQMXQM\nMW"2K6+*Z-*,VFEYN/>^'C8V19#O$K.2MQ;?6S)][SC[?=_?>9^]S+O`MOL6W\nM^!;_3)!_-H&O8FC'V7`YS73]SK"WKGY`6?_1@:'R2B\\>?MX_ZGC^9!.X_4+`\nMY0`T`W:>PB8*""432',\\<.>KQY_O'_:B>U"9V]TJ/-W1)O>)6:X?^@>,WK'&\nMGU0!?[S!!,T@U"(:+(9H]D!$\\YCI-RS@UQ=S^/7;.G)R\nM\\XM,/+E!)\\)U,5=%3K?-@Z3<6.ZD@7/S3'%DFQ3%:C+B5K,ZC8[:%F-@,(*X183^XCTF\nMM'<95Y>.ITE90Y>NXNSOWZ\\^M'P184]^R$Y,0/>6)<@OMW`?O#>X]$!GJC0<\nM#+YL$OC.<:8&Q*(JR?%:?:+%OL0LV:XV\\<94IH6XB&P"))'9!)KF=#T9"LD9\nMC.E<));:W3N0>CPPA/T-[>C>WHA@6D$*P`@V/ZHF4%7FF',*?_>T2=QCFW<;\nM05\\.N3<:-9[1#;0O?T0;P774$.KM2Z!O*)37TBP^R/4X)L"2ED_)V_Y,4N,K\nM[3;^`LKI%S(]5IB,A1.*JC6D570ETFB-Q%ES(*@W\\R"BP?@7JJ:Y,ZV25G?O\nMRM2+#]_`LZ??&4G@RRCV4:@J9CH=I'_N,KEG[9,"^H;8'JN5G%Y40-NG^#34\nM=YV`@):V$'C)",X/H7-_%_IV\nM-!H154,:`)[].0^.8^7[>XDA"!P(XP@`\\,?)MJOF`W>LU.GCMW!SW4[RR:>/\nM"FCN9.`H-MLDW+QCCVZ_JIJ+W;GRZ%P8U>SOGJW%%6?HL52:/&/+A,T$O6-S\nM'7Z[YX`^4-?&DAC%_5^``6"'GA)0$$*/S?P0QN50W'$YBIUV*I671TIX/LW+)=2\\_\\OHS_^:N!5^\\/\nM0U&QD>=QVBM_5NGMEQQM;U3K^7D4=U[1-LYF)[GY>=QZ3<=>R4S.G#J1PXWG\nMG@A]@!(`Y,0\\D.4A>'VUDN&TD[(L#ZDI*3HRIZY%1[N?U3'`B\nM`CK382?^:U?(?>J7HF17O8Y3*[BTHI%=@D#G%?IX_&SQ,02X700?K5,ENYW,\nML%G)QL("#LM_+_AU@P5L-CJKV'=B,4T)0`AW7`]SLQ::V\nM9)IAU:\\4I-+8P'$X;<,6C;O]TN.+H!2@)Y`#A>,H;KN:3K#;B*FTA&LPFT>6\nMI@\\VZ_C9G\\0^164!02!5WJPC-H^ROF06<.L3SR'#2>9;+&3SFC<5MOAV!74M\nM!IHZ63T#,PB0%SVMIT^N"UW$@!4\\HH'KCFV@*KA7BL%K)+-0Z^C3^^IN.,\nMF51.R^QSGL/IQ44F@;)<81`4\\\\NPKI=)KWYN7-\nMT'5V83R>J(J)B[W]VAD9K1'[^'1_NN9[/XA\\L'73A@/C2TK8NW]Y^X2,LOEY(C`B:6$'R\\3K7,GL%/D\\SD62(15-]\\Q)T?;-"Q\nM[2/KP*I52I=-(K,<=O+I\\3W`'?9`_AG/068.5WZ![Q=]_8,W-C2WN7H'AI,,\nMC$@2;R-:L(@GPE+!)/[T1]_+JZDN>U>Y_V(S0A&&N&R'SOE`S$4LVVEU];2L\nM#;[Q:N^JO%*B'Q8PI8R#JJ'2;":AZA];.Y^_+W84H>TMP!-/*]!U;+*(;'%X\nMV%C[V`I.6_'8Z&WNP5WH$2_;U%)38S6=A6KX?,$=!P0/4!4YT@*DF(Y8T+5_TP[/T\nM[1O_=M`#URP`;OR#AI?NYN<*)FS^Y,DXKG]0'4%JQSX=H1AKNO1LGMKL7*DS\nM`XU?+>T'V1X40`F%02@#P'D\\GEOV-39?M;:V;>C<1=6I3(>%&PP.LY:.CHY@\nM7W?:;I9M5@O5[*XT"W23S"TMI06?;/(W\\.F>W38)Q,QW@*<[B*'I<265_+2O\nMIQ-/?G@H!R:7_V!B+)ZX=MVN_8F++CC7*,AVFGKZ!N,]@;Y`_?X#K5!3\nM>SBF)IFNRH"AB9R0:[,XES/[[.&:1GY%:\\.6$`ZU_E8>&.^`<7B=BZ8#LV9P\nM<&>0N8)(]A"#)2^_2QE!Z,M>Z.XSMLDJ\\S%%]RQ<,'J;22DY'#YVAWM>>V=O\nMGN#*C)?YO'PH&D_+CKU]54G.A*7)=343V=#&F)1"@1"S<9C&W+RO3,\nMR,_/G;S@O,L8``.`D=!@[!L&]@T?7(?W%1#\\Y7U%FEDI?2<:I^]Z/:G2KM6$\nM>#((HG$@'#WRBR8%Q%,2PG&+$8Y%F:8JLVTV^B$P,MR^R`$0CNJZ4>8?")*<\nMG!PCE98U65%515$459'3U-!EZ$J*J7)"DY,Q755E410%!KW5Y6>')M&JO,ZY=@^``;Z$0H<%L:)!T%6E=`Q-)H@B@:X1A2A@HX0!P1)9E*:TH3#.8GI`5J*JJ:9JN6T2>!IFA\nM,&[V^$R'S4I<&4Y#$$R\\Q2*-&1'\\,Q\\R/+1BNC(X&'I;\nM3FJ7D-P1X358U0]$T0S`)PA=;%2&$$H[C",>;*J9.RY>L\nMF7FB:-(3R61O(ID>6P``[-RV!XQAK=V!Q8$`X??L:T)2!EI[&9HZ`%T'\\C(!\nMCP-PF`&1`Z$&!@E#$"0UNH!#(40)QU+)^-8";U:RIFFWN;UO..P0"9-5G:55\nM'2"<0"@O$),@057U.:=6>,O*)E:$HTIYP._W=W1T-3H=]F,+>',;`"`"8,U8\nMYY7.OC%MC"Z``@0$H!S7M'==3>-\\D]LZ^R='\nM0M%Y^^KJMS>W''BB:MXBUE2[=G^TFWR]GQV:9C\nM=BS?C`<8,V`2+.`%*[X(R4=NJT!5U;PUBI)>4ER0]WA5N2]=XX8\nMTO&#U^*AO;5U?V-#[6V:IBRPF$T79CAL5XH"?U4B'EW8U^<_SYY;\nM<,W"F5/?N_F>3\nM9S+=L`4&L4TWL&SM+J-^8B%A5]XY=I4'`/^C=V,P%+DR-QU^J;-V+]?@*FG<\nMM+/NA[PU(,GN6A]YJMQ*'\nMB:<`07XPA$748.,BPPS?K2#]B^90]9,=H^]VTSMVHJUV=[_8M'-&3CI4PMDS\nMLDAV?N&&K9^OF>3)2-;%DR='P+FYP'V_F@.>%XNBZ>(K*#%^9Y'H3YPV3!<%\nMPQR-,00&#<23##S',AQ6=II98)?8[/QXR9'#JLK0?=YL7EVSX^@V))Q4<9%#\nM2W0K:'02_2QW?,A-O+X)O">'>W5OP_IYDJ"W:D1THS,]`27$FBHNSD>%RFT"E2MXZ:0DQ\nM90PL_VW3#K7E-]A4=\\0;'2K`@^">*?#7!,F0!VJU4TN)Q%=6Z3&)_IG:_\nM\\8W9G3)06`QD\nM90-6`7`(@%,"/%;`;04"@T!S"-B^&X@PBLQB8F@RV&]>&?U4]WPA05B'9[:5\nMO9!O%2\\(E,_%9V%6L_JC=55\\JMX;P)!2,/4"HG]6;0[)_]-\nM*$!#9_\\33W4/WG(:!_T;:R5.%CZ.`&>Z^'W[T^3N3FH)C;>;V@I-VB8`!B7_\nM@M^)1\\-]$QQ(,&J:[Z!G^?1TUR]JDXU+1+#E(^_`_O_A_P`7+.T"(LFS_@``\n*``!)14Y$KD)@@FJ:\n`\nend\n 6562 bank_ok_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```.L$E$051H@>V9:9!=Q77'?Z>[[[UOWKS9I-$,6D;2:$<6\nM%@*,S)8@`S(V14`)D!C;96>Q*\\1+C.,-$L<"8U,&%P456\\$FJ00GA%398`=#\nM0,8+8,PB@T%B)(0D&&VC&69?WG:W[GRX;V8D&8LJ$/:'N*NZ;M_;,Z?/__S/\nM.7VZ'_R^_;[]_V[R5@E^V3D$6AT4-5=V^]+^Z"]MQQ6?>X`'AR+,9:BXB^W:R`"I>0;W7M'\nMECW\\LV[.>L=YF$EUFW-XIS3VHCT,*K\nMI83^'2@1%JO,G]_LO,#<$R7N:J4X:"W.!C,:`E9T-#)<23E43"A%EL0Z4@O6.E*7C5/K\nM:CT;.Z!:<4,#/>9OCU'U"";NM%6Z[L/WX`KBC:PP'K4JX,8R2#Q_J\nM*YG&>I^&0L!@*:$<9\\K:264=1R@\\-7;38VL=493BPHCVF77X.>\\7<6H_IH2M\nM#L4=%\\]^\\P`V;1_%QH`P3\\$M893\\2=]@13FMT%I1CE+2U)):1Y+:J7&:6A)K\nM2=,,C'5RU#,;6R>DUJ&LI:TY1Y`S6Y/4_8UOY(DP<=Q]><<;!_!D9'GL5R/4\nMU7E+;&K_*;7VPM'Q*E$8(FD$<0A)B"01DH38."2.0I*P2A*%)%&5-(Y!>RC/\nM1TP.,0&8`&=\\0GPBR7J(AU,^N?H\\B.Q.K'S\\^U?.^]&&[XWP@\\M^?TK9T^9(%M_I![NS4.JQU"%D1)9(]E4Q;PCF'\nM=;6@M0Y7L[9CTNJ9Z-1E`1XECB@E&Z=9ZK5`DJ0')D:'_V[[@;X?&6.F#)WS\nM#(UU7ME!=.#6*S$`B]L;*87)AO4GS?U<4]YWN$PYYW#.INVV4IE7J51Q2#:!\nM`E&(*%"UITAM7@&U\\932-2#69N_69@%N'39-4=;BN13M4G)B<=;BE.V8.3/W\nMK<5MB_;65$%$&)RHRM[!B>L5\\@,@`U`*$Z(D;>L9*:\\9+4<$GJ$N"`B"'$%=\nM';[O8SP/SWCXGL;3"L\\H/"TH!48+6@FB!"6@E&3JB^#<=$#'Z72/$D><6*J)\nM(XPM86*I1I8X28CBA#B*L$G8DL1ABTLBG(T09TFM!9@YR8@!&"N'@#SQ8L_(\nMM:(4YYZZ]/*JU*WIKSC\\4FET(+;_K$PR)ZX.?"#M>TD7.I;A^0$-.%JA-6B1C#"$U$)G>P.SFNO9/QA!=8(]_46JJ2:V4.KM)L*0\nMFS7_\\4*^\\,"BCH;WCY3B54,C)=*)P<'=`^&WDS@<3Y-0!)[)$G$-P(';W@_P\nMS#.E])E3\\TI^V%-9L75_94WWH0ERQ;'Q5[I^^8WBS!5K7%R]'K8..912*)&LU\\8.T$IH+.0Y-!*1*XVQ<^\\0H0H0\nM48R_V`5^GKPK;-EY[8E?N[^G?-KS^RNK/)?B":P#/D`H^<7WL&'IY1M;C(\nM[.=[FIQO"'R#'P0$@4_@F<-B!U(K--;EO)O^]-S.GEL^LG#TX&B]2""Y_G@\nM^7@U`,Y!6]YCY?)ZZFS/O/[QKGOO>N&Y:'G;BI>6CBR]_;1UI]VW_^7]\\;$!\nM3*E=&P"B#*^U?236H43PC<$S!JVRC4XI08D"`5T#;VN![1F#\\0Q.!,_W$<_#\nMKP%8U!BH678___WD-]G>N]T+3*X]\\PK;<=F:RTZ_9.4EU]SW+_?=?DP`UAWU\nM04"TJ07FKP,0$3RC\\8S&:(6NL:!5!L#H:0:L737HVS;OZUQP8P%_W#%7UVQ[75?+`>,9M#%3RAM="V;)@G92L"-CP/,\\'&`\\GU/GMU`J/Y;?UMM%\nM1TL'=SYU)P>&#@!P_JKSV?C>C=M/;C_Y<]L>W?906V>;;9G;:3K"*,K7F$#C'#0W%CAM\nM@>4_7_@/G'$\\N/M!7BV_B@H4&TZZE(WON>[QSD+GQ^N;ZK?6M=>QY.U+@-=)\nMHT<1`9*ET\nM^"'O^^#[IG0[)H#7RC;*>%/*Z]J&A@,E@E8:O]!`GUF#GK..1[;WT56*^$QA\nMB,ZY[NXZIU?X:=;)XJW\nMW??COL#W.73'7Q^ISS$!')7O!5#:RWRZ%IQ3@@1$:7+Y>N)4^.Z6$1[NAX$3\nMVNFW&FL=VE-3AM$B:$^A`D7GS!ROEAYGV]@+I'Z*U`EK%IS,I\\ZZD9^\\7.#`\nM:)E"8%"O8=%C,J!DF@5'EF64\\6K6G\\XJ`$8)J5;4%1KPW`C8?9RVN`'5KJBS\nM1=(T1;34Y(!2H'R%E],L;T[XWHX?DO@I6C2S@EE<<_9&>HH+Z1X=I""2I?/7\nM\\(C7=2$YXEW0IL:`U-)C#:&NE0S*SW/QLG[>M:"/8B6F7$VI;^J@KOELZILU\nM@PA&U0H]3]'6$.!)%\\]//$=0"%"B^.C*CR0+FLZ)GNTMY8V:K&B/WI!J1GX]\nM!@[_UTD&I@J[27HD8T`IC=4^XV-C%$<&J!8GF+W\\#TC6G,-3$T_Q])[;J#=;\nM6+\\H3V`4>,*2)L.>XE.,FR(JKSAW_KE<-O_RGQXHI4\\=KL-OU/&8#"!,G%.UO<'J@('A(D-C(;-/NX)?M>385>UC2>LR.EL6\\73_(]0W/LVI\nM'05\\3S,W*//4^..HO**]N9T_7_SA5UM=ZU=LOK9U(P?C'G)1CEG)+#I:%G))^R=Y:'P+1;_(\nMXOPBSLE?RI!2MF73*G.:?LY,4$X)"\\0RY$I'9XSP[M(M,I:CHFP,D"+&NF;AYB\nM:YF?>S=?.:.%FW=^B9>35QA38_QH?#,7S7DO+R3/H>L-%\\V\\F+Z#)Y#:@:5+\nM3VA>FJ0)RJ7X@0,_5V@I<.%`,:(4538?GDT-P&`QQ#JXOZN?.D_A&4W.]_"-\nMA^][&.VACX[`4^0\\(3`*WPB>`5^#;Q1&"Y[*#OL.(;6*_6'"W/JU7+?F\nM%F[J_B(OQ;OHDSYNZ+^!O>QE4=-"5LMZ_G5WR+ZB(4D@35*2Q)(F,=8F"(XD\nMJWC=X16R`:AD1TEW8*1LM1)\\XY$++'4!Y`(AYROJ`DU#SJ&T(R"[B*HQI8F;S5?7':C?/70%V4/>]AA=Z#K%.L:SF/B\nMT!SK^Q/,;LI1#F.JD5`)H0I4PI0P3DBM$X[*IV8RBP"_0.1*0-Q4@%J2VH63\nM2BQ>(IA8,-JB8D&4G?0HG&3E=P(D5O#2K#IUSA%;1Y@X^DJA6U6_O/73LS_]\nMV9O';^[L,3VTYF9QIC[[0-=@?$,QM".5V$HUL41)MG9B+?;(0\\FSQTA*;VW[\nM^4]_GOU&,#B^X8'1!P;6]:YSGQW_K.N?Z-]T[3G7JLV;-[^^D-]U>_R1Q_G\\\nM>9^7L=&QO[UK_*[P_N+]Q?'^\\?/+I?(;DO>6_5)_K+;KQ5VXDLNW+F_=I)1:\nMU+N[]^)8XK'5JU?_+M1Y8ZVOIX_N/=V+]G7O^T.`ZZ^__@W)^3]Q%"?97MC*\n-YP````!)14Y$KD)@@M1Y\n`\nend\n 6563 bank_write_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```.#$E$051H@>V9>XQ?1W7'/V=F[KV_?=F[7GO77GMMQTF,\nM8_)R#"0A@`(B(51`&VBJRM`6I#Z@T-*T"*54+2\\)E+9J04`*H:T*+4)M@400\nM6CDT"="01&F>QO$C=N+U]N^M'&B/BT#_@2*,[]\\[N\nMS/F><[YGSLP/?B&_D)]OD9=JXF="0&!Y@-X:C*4A<+Y2YWR=Z^7.+8#=>2`K'+D-%[C`EZ<;^4WC]?:6PO-/\nM,RU__26UW^&!Z?Q<+GGN0NC15@$>`ERJM7QA\\D3G-5_[]YW,-0O>_K9-K%_?\nM?S@K_,VS:?A63RSANN':.5GWG`!XL%'@O4=$KM9*;CLZ/G?Y-[^]A\\T;5S"Z\nMNH__^N^#O'+K"!LW+J\\7-MR2%OZK1HO]E;4]+WKM%PW@OGK&P/*,F1/)=4K)\nMYP^,36_\\WGT'N.:5JWG3%:O0`H\\>G..N[Q_@O/7];-X\\W'`^?"S-_6U:2?[.\nMC7W_?P"VCW?P/H@VIR=''WMB@NNN6<=5%_2C@<('4@=[ZQVV/W"(\nMI7T)FU\\^W`XB?YD7X:]$:/_NQ4M_]@#N.M+&^Z"5EM\\`;MVUJSYT\\$B#-U^S\nMEHM6]A!\\H'"!PD/N`[D+'&X4_/#Q39N'!9N%IY9YV$=LRDCM26EK\nMPZ=?/_32`/C*GED@+%%*?33+[/L/C,TDR_H2-HTN8:KC.-:TM'*/]0'GP?N`\nM"V7?^5"ULA^`=JO`ME-&5O82UZ+MA0M_H(1]W@N?O6'XW`+X\\LX&`98KX=-9\nM;M]];*)EEO3$]/4F3+8L[:)4UL\\K&SA%X85^6.Q['\\AS1\\ARA@>[B&O1CPKG\nMWZ^$)P.*+[]UU8L'<-M3,_@"$-8H^)LLM^^8F.RHH!5:*]JYPSF/\\P'K_$+?\nM.8_U'N=*,#[(:<^R[X/@?$!YSU!_C:1FGK0N_'YLY(',!KY^T^A/#^#!W//#\nMQZ;IZHHN\\,Y_SGE_P\\QL2IYEB,NAR,!FB,T1F^&+C"+/L%F*S3-LGN**`G2$\nMBF+$U!"3@$D()B8C)I>R940$%5/KZ0:1?=;+!^[8MN;N&[\\QS9V_^G]G*`%8\nM_KZO8K1*3LQUN@KKRY$0(+7^^BN&+GS9!>L^$R>UUS@?\\#X@E$642/E4LFB)\nM$`(^5*3U@5!9.S!O]7)J%TJ"YS:0.\\J^*U.O!ZQUA^=FIO[DJ<,3=QMC%@Q=\nMBPQ+NJ)V@/SP9[9A`,X?7D(KLS=>?\\GJ#R_MC@.A5"X$0O!NV'H/SHX&#M\nM2^6XYU`W&K-U`O_=\\K8D2*MO\\M-[-6]HQN)XH2^FN;*C4.T,L'G\nM&9UF@\\D,(JW0&K1(Z3`$Y^&\\X3Y6]/=P:#*'=([]QYND3E-X:(T?(,=06['V\nM_M[NWN]N&.U[YW2KN/C$=`LW-SFYKY[=;HMLUME,!!XI$W$%X/!GWPGPR",M\nM]\\C6;B7?.=K9].2ASI8#Q^:H-1NSS^[\\G\\\\W!S=M"46Z;>[)!W4O?4C2S=+N\nMB-=N7L'$7*`UW6+\\Z%&>/!%02J%$RE;U`Z"5L*2WFV/3.;56@SUC)\\A4@HAB\nM=O=.B+OI#KT/[_G(1;?>=;3]BB<.=2Z.@B-6,K5SY]CGO9CQ([>_]Q02FY-?\nM2@(KO`\\R3\\80((@@4L:_F!A1"A%!%JF+#R`B&"48H]&J3+/S(`(0&57QHK1?\nM'&E$&Q!%G"1(')-$9H$[(9Q$_#)MG)&%S!E?3I(03GD#!-'ZS+^CC'$1P1A%\nM%!F,4J7U50F``%K-`RCG-EHC400B1%$,44P4G:J2#X(N\\MHG&_?\\]C533_3J\nMB^4[YUVUZOY;OWN,6\\;/!F!![:H#B#+/:PGK`TJ$V!@B8Q8]H`0E"@1T!=Y7\nMQ(Z,P42&($(4QT@4+7B@%$4SS5DU^T*@$8O>@!'P*1T1`9$"&N`,21KI;2\nM6)YC;[J7!WJ6ZEW3'=XTXQJ;4_[E#@I]NS:P(.]KV5[\nM]Z79LFM?MV;#SD9\\;%DGYZ'WGL4#9WR1*H1*"/.6G;>J5"$4&XW6"J/T0A@)\nMLL"!0%G(&:W046F0N`(0189M=UX;Q6M7]<5+)YEK-7G]VO.X]J9T^DM%UT,;\nM];+WM(NQ;YN"B;-Z8"'N3_>`@%*J).'"CEMRP$0&;/N,%7==42EOHA+EW2[^_;L>?>[LFWZ73RV%]O\nM^^(')SY\\U6]Q=@#/(Z(,(FJ!I(OH!%^D-)[X)JMZ`TE/+W%7+W%W+Z;6BUJV\nMEL@L/<4H*M:81!,"1$F,Z`2QMIMGKW_WH7Q'_T"4I/#F"!!E*FT=+Z)0A9'*+(,];-/LROOVP9UBREED3H\nM)&;]4,S8T"`'8E/-5>[0.A)TK4RQ42U"Q#!VH''#BK6?6K[LR`](#SW*[LM6\nMTVQ>3;#%OTWM_L0=CPV^*Q3U/UW0[04!/%^V429:4%Y7&QH!E`A::>+>/B;,\nM%O3(Z_G^4Q/L;.5\\J/<$Y]4$;03FJUDEZ%@M>J`KYKFQ#KN2X0V1@TM;6VFJ\nM$=)X$TOS^HE5+WOZ07?1'X9C__![I^CSP@!.R_<"*!V5,5V1GB:)UI@SA_FN)]AG0_H2$'F2NN+H".%J2F"AZ*(V=%6Y+V&UXS7N7"Y\nMQ[]A"],J(>F?Y9XGRT+Q#(.^$``EBUX(E4N4B2KK+V85`*,$I15=O7U$81K\\\nM05YQ?HLKAAMTT\\9[CZK*>A%0"E2L,#6-*RR[ZMW,KASADO$I-A0S,\\.7#HX/\nM;UB.,5#K>?[-\\^P>D%/_3430IO*`5.FQ0JBKDD'%W;QUXW'>L&Z"9L?23BUY\nM(R=?OP%M%)[Y<"L]H(SPU(X&SW3UL/KH#%O=7''TP,&_O?Z/K[I\\Y['\\1K40\nMQZ=O2#\\!`'6R]2L`8J+R*8O*(Y4'E,;KF-E&@TXG8ZZ5T6RG--L9?;9`&ZD`\nM5"!BQ=BN&1Y/(VJ3+:[)YYAMU+4R_-CJMH;O$ZH3S^B3,R$$F3?B"V%0`(,W_P=#'_I/N?K7OF;>\\M'OF;SPXA;N=`)9\nM+L;YH`,0M,$#GK+5Q5>1MJI(^2=YDSJ[L]<\nM2%NY^R*P_<`GW@A4'!CLB+8L'$9LY:7".@KKL3V>R8,ISPP.HO>=X$H[1S*:L.SR4;P$\nM7&0O<+7D`NLL*CCB)$!5=[:?O#\\9@,EFA@]PU\\[C=$6*R&AJ\nM<41L(N(XPN@(;4SY/0HDD:(6"8E1Q$:(#,0:8J,P6HA4>=@O#SI2'N(=:*O8\nML6.:>_.(T.APY6-%=M5JL\nMZ#)2@E%EV5RX0&8#SQYLRKT33II!\\IO6G\\/>NG+5P,%6\nMVZIV[ND494NM)[?EVM9[_*F'DD=/?GG)?B<^6;:]YP-HIF\nMW-%[[S[T\\;V[]_]C'"<^][\\\\/X^D:4:SU5G6G&MN<$5VMU'U=^S=\nM_[F_?^,O'7]1R@.<><7P$DC]^#B'#CP]4.3%N"AS:W=O_[Z'[_\\^S^X;_UDL\n=?\\Y$\\Q(8['\\!(!11!+FE,7X`````245.1*Y"8()S\n`\nend\n 6564 barcode_back_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```)[TE$051H@>V9:VQ+*NG7C&'GOFS)ES/^?=#\\;#)=M0M"3>#_E+,])Y\nMYSW/_']SWN>]/`.7=$F7=$FK*2&E!!@`A@"YJF[^?`E@"CBMO=-P&W`_$*^:\nMI8\\F#7@`^+L5`!TPWGE=$$DI<5T73=,P3?/C"*G#,LG[%$41GN>A*`IQ'#,W\nM-\\?P\\#"^[R.$X,"!`VSWEXT36-\\?!S3--FP80.-1H.AH2$\\S\\,T36JU\nM&I5*A?[^?FJU&D\\]]11=75WLWKV;-$T)PY"77WZ9D9$1.CL[$4*PM+2$XSA(\nM*9FWL9'Q]G>'B8UUY[C9,G3[)U\nMZU;R^3Q34U/8MHWKNAP[=HQ"H<#SSS]/H5#`MFTT36-Z>II2J41W=S?[]^]G\nM>'B8:K6*XSC8MLVN7;L00K3\\*A\\$",.0,`R)XY@T34G3%"DEON\\CI6S=[/L^\nM:9JV[DN2I-4_"(+6+Y:F::NOHB@((9!2MCY;B??![P000I`D";[OX_L^412=\nM,X[.`?A3>B_U^:[?V_[!/A="?S;`_U==`EAM70)8;5T"6&U=`EAMK3J`0""$\nM>'&7^&0Z<.,;NILOJ^I,@%PU@\nMQ<`;TV^P[_O[R.?RW/KY6QG;,D9[OATO\\FBX#6INC3.+9WCKCV]QZ,0A[MES\nM#]H=*HT/`;.*&#\nM&[HD6D)?;Q_M:]HY=>84!X\\=Y-C<,>ZZX:YSGL0%3V(A!'$2\\]R1YZ@J51[]\nM[J/<^>4[J;MU)NXII/7T.I7&+>F<<.;1I1`R=NX"8.OG0)\nMI$>`1XA')'Q?\nMX2>'?@(L#\\L+F@.*4!A_>QS=U/G:35]C>F&:NE>GF31Q$Y<@\\0A2CV*NR*?;\nMKR2GYU`-L)TJ)^MO46F6\\0DQ+$%6F`A%T,#E\\8./<^WEUW*X=/CC!WBG4(80\nM@C`-.5T_S>XO[2:6,=5&E6;2Q$M=@M0GE#X]A1ZNL#:1VA(GVZ2>+C#E'B=0\nM&^3;,I@9C2"(T#0515E.X!/5X_S@^1^P]^#>#P=8,:2J*K!\\>)=2M@[H*X?^\nM]QI7516!H!$T2+2$39_81*5>P0YMFFF30'K$1&SLW,CZN!MGOHFNZ2111#D^\nMC99-*&3SQ$E"&$1XOH:B*"T_C<3G%[__>=&ZY3S3J)22OKX^QL;&,`R#D9$1\nM#,-@^_;MK;J095ELV;(%R[+HZ>FAN[L;3=,8'1TE#$(6F@M860M-UZBY-9S$\nMP4V;2#5A<]=FS&J6,XMGR>5R+"W56-M=9%?W;7AQ$Q#(5)*D*6DB<1*'/1./\nM,Q.?)0P38M^_POTAF?,"9#(9',?AZ-&C^+Y/$`1<=]UU3$U-,3P\\3*E4HE`H\nML&;-&F9G9^GIZ6'?OGT,#P^S?MUZ;-=&UW2\\T"-.8YS40='AJK57X;[M,UN9\nMPC`-YN?GL6V;PX?'45"(PI`PBHBBF#B.2>*8+]^^B_6%=53J%0Q#(\\RHG9G+\nM->L<`,,P,`P#3=/(Y7(((3AUZA2JJJ*J*H[C<.;,&5:&:O#PA5-8C7DM[,OL'G#9K[_\nMP^_QT'T/<^+D"73=X#OWWL.Z,8-F;)/&DB"(\\/V(*(AY6WN#I85Y5$5%5W4$\nMWHSWR]`][RRD*$JKDKPR"ZVTKVAE+[_29ACO%KB'>H1INK@\nM*PZ!TF2B.LY-`SMYX!_OXQ_N_R?^:V*"5(]Y4S^(K%Z,$P5("4&0$$62-($DEF@8Y/5V4E/C[NN_'?_[\nMQ$];.>`!=2#Y.`&$$-QRTRUB[W_LS=?"FDX$<9P21RE1&)-D#"867R<2/M_X\nMWAU\\8NT@Q^T7J(S0C2V`\nM)X$7N`!_,5TU=)4DX4[@&\\2(.$J(HI@PC`F"$%U7.5'_`S^3C_&Y]B\\RO[2(\nMDW@@(8X3/#\\D#B0CEXWA-%UF%V=+(VNN^596SQ[*=F2Y\\.7CSP(1W11X@C8^\nM+]K`S!NTM67(YS/D9Y^?8]=6:CT'45(8AD(F>D3%\\7L7A1UL6$T$58>ZSY\nMOX:[^`#OU3;`1C!,5ND5IF8H"(\\T>CMM9J[6(G=O!)7SA_@?"A+W#7*P^=4`\n+````245.1*Y"8(),\n`\nend\n 6565 barcode_ok_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```'ODE$051H@>V96VP35QK'?V=F/&,[CC-U+K)S<8D)!J5`\nM4F`IL`N(4E5E6P1;MBKJ"P^M5*G[L`]556U?RK9J5BJM^H:V?:F0J"KM`T+;\nM"P4VW5`*1($-VA*@FP"Y8(/'V?APH74U-2@:1H='1T8AD%=71WCX^,$`@$F)RKWLW+D3R[+(9K.<.'&"YN9F*BHJ$$(P-C9&,IE$2LFE2Y?8\nML&%#44LFD\\'C\\=RB=YJ!WMY>0J$0I:6E:)I&6UL;"Q8LX/3ITP0"`5I;6\\ED\nM,HR,C%!?7T][>SL.AX/1T5$&!@:HJ:FAHZ.#8##(F3-GZ.[N9OGRY;A<+JY<\nMN4(BD2"52G'^_'E,T^3(D2.8IDDBD4#3-`8&!NCM[<7G\\]'6UD8P&"02B9!,\nM)DDD$FS=NA4A1%&O8-S#;S!F:;>0.SS9PW<+_9?-K'W%SB\nMQF(+F\\U&J:L439TN=\\Z.@)02L\\S$Z7)2*"O0K_83=4?IB_05C<$<'0'+LE@8\nM6(A1:=#RSQ;.#Y[';K-C28M/3G["KK6[V-&\\H_R%QU\\0<\\Z`E!+#,,B69OGX\nMNX_Q>_R\\_.N7B4Q$.-9]C&/=Q^@*=5'EJOK]Y\\<__]N<,B"EI*JR"J54X<-_\nM?,C2FJ74F#4.\nM?>W[N!JY"L"3CSW)^]O?9V7]REO:S)FWD*[K1+-1]OUK'](F.=1SB'`JC&(H\nM/+_J>?;\\=@^35R=O>0/!#!BXO8,'P;(L'O4_2N=X)]WQ;B[&+Q(M1-&<&CM^\nMM8.6+2U,#$\\P-#(TK>U]4VA*D*JJP$^+=REE<8$^M>B?JB>$0%75.\\Z@-YN;\nMBF=9%@)!6DUSL/<@42M*A@RJ0V5S_6;>W?0NR<$DR8GD'6/>U8"4DMK:6M:M\nM6X>NZS0W-Z/K.JM7KR[N"SD<#I8M6X;#X:"ZNAJ?SX>F::Q8L8),)G-+/-,T\nM<;O=5%55H6D:C8V-*(K"JE6K\\-?Y.=IWE'/QKV$\nMPV%<+A=??/$%@X.#*(I2O.-3VS*!^@!KUZZEM;654"A$(I&@MJ86C\\_#P;Z#\nM%(P"JE/%Z_&R>\\-NXCUQNGNZ492[9_JT$=!U'5W7T32-DI(2A!#T]/2@JBJJ\nMJI),)AD<'&1X>)A3ITXAA,`P#'*Y'*E4BE`HA,OEPNOUHNLZJJIBFB:E[E*"\nM2X)4E%!(A1>?>Q5UE6NH_7?K;C=;MQN\nM-_E\\_H[[0M,,U-?7X_/Y4%65:#1*+I>CKJZ.B8D)"H4"#H<#PS"P+(N5*U<2\nMB41P.!P,#P]35E:&W^^GK*P,C\\?#^M^L9_&2Q43T"-^.?DO"G@`5%@06$(O$\nML"P+7[6/D]&3)+4DBJ:PL7(C+_I?)#00PC`,_'X_?K^?7"Y'-IN=EDK3#-AL\nM-FPV&P!VNYW-FS>CZWKQ8544A=K:6A1%*::)E))"H8"F:>1R.31-0U$4W(^X\nM^?KJUTPF)UE4L8BQW!C?#7_'$]XG>&;M,P@$58]6\\='9CU"<"N5Z.:\\M>8T:\nMLP;+;;$HN*CXL-ML-IQ.Y_U'X&8412GN)$\\%FBJ?0@B!$*)8INO_V^`6"+)6\nMEM/#ISDS=H9P.HSI,KD^=)U%GD4TN!KHF>SA-9,ZV/>S&C\nM,[&JJ.QZ?!?EE\\MY^_3;A/-A[%D[E?E*`L,!7G>]3L=$!TD]2;VCGI>J7T(5\nMZOT#W\\24@4D@#A1^<1-"95O#-DRG:=]];K?SV$ZU$\nM8VO%5MG@:$@\\H`;UAN;B$9,7\\#%S1TQ6-I5=V!YO_\\N>@3V+?\\S]B+W$SK)'\nMEM%''^5Z.2UE+1>6JDO_(.QBC)^.D.Z%`*X!TZ?FF>#3OWZ*E)+X<'SCB>LG\nM_K.M:YML[&J439>;Y(K!%?*#Q`=R+#;V)RDE!PX<^+]H^MD<^>K(E(E-;9&V\nM*\\_V/BN;KS;+IZ-/R_94>V^L+Q8<#`_.MLQ[<_S;XT@I28PF?O=5[*OKFZYM\nMDF\\DWI`CXR-[WUK_EG+X\\.'9EGA_OF_[GCJAX,W^$<@>Z+W8C)Z2S8G'%7D51`M=ZKFW-B5R\\J:EI-N0\\'$/A(7HO\nC]0;Z>_LW`KSSSCL/%>>_SCA<3)0^(-H`````245.1*Y"8()I\n`\nend\n 6566 book_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```+D4E$051H@>V9:XPDUU7'?_=1[^[I><^L[=CKS2Z[7CN)\nMUWDL3D)X*";&4A`0`G*T&,=.D(%`$"`$4HBP<)`2/E@*^4"P`\\:1@TC,(QCY\nM"\\@FQ,0"8[*VX\\!Z7S.SN[/S[NZ9[GI773Y4]T[/[,.[-GS;(QW=*E6IZO^[\nMYYYS;]V"JW;5KMI5NVIOPL3_W:,>`#:`FS4,NTC+PY)#0HF&$(R9THR;TDQ2\nMFAT8CB%X'$C)/OFFWJI?_Q87B(&?U+#'@3$?_#K";6C7&O4"/6&[>L)RY)14\nM<@HA)DICQHK"C!:EJ:=964O3TLNRTJ8T$@,8TT$(P9#_*)V_-+1^\\0T#"/@#\nM(`#:#5"C(!I26J.UFC\\Q/.Q/U.ON9+WN3@6!,^'[UKCK62.VK1O*EC4AA5>`\nME16H)"^)DI).F+.VGK+6SM@(1&'`F&-(<0_&/(^08L+L9L;&2$84$8ET1)0909HJPDSDKBW-#JYIQ:\nMBCFSFM!-2HP0X%H@1>5]`,%F%/H1*&I#"$N6%F*>9[LQWF\nMVQFID.!HWV#V9)-77FDR,N*S:]';!&]O^Z*=`?&V!EN")?>@Y!BV>I9=]R2<^.KE`_`CG_*$)>_S)#NG\nMAVPF&C:OO;;"D2-=]NX;Q?4U:^O9N=YO1P4O'MU@;B7!V`,]W1=W09C^<1]@\nM`,B6%8R6MZ"EPE+/L??>@M<>NTR`#_^6S$OS,TE<[/&,X<;I@")).7:LS>F%\nMC)O?/D8W*>G$!6%F^-Y,E]GE9$!87[R^@*MJ2-D#T1B,0M^U!"TE6KX3+5JX\nM^@7VWV=X]<\\O`R"Y,^>6J8-16A[,NQEU#7NN&V)AOLG,Z9BH$-RPLTXKS#G;\nM3/GON2Z%EINB!L6[`SWMZ@M$Y$)Y(/NY`%I82'$0P4D\\_2HWW0>O?.5U`'[C\nM(?`M'RE_JKN>*A/E3-8LKAMW.7%BE5,K!6Y@46\\X'#T3LMS)-X=!?QP/]JAS\nM`>'N]FBI;8DL>U%0H*6'E`LMY,\nM4%G!C5,^#CDSI]=9[$"M8;/6+6C'Y4`2*G#D^>+MP2&T;3@-WF,/B+<3]\\]\\(0BI__75A/P@I"_D21%&YK+<$WL._Z(5J++19;\nM&>VL>E$W9S/L@R#VMBALR8MM$=E>C:Q>'B@)2E0NQ!2"?1B>Q5)M]MP/KSQR\nM'H#D%R:AX<)4_6GJ]B-,U^C675Y<2CD;&=Y[^_4,RX1V.Z;5R1&2W@S;\\_Z$\nMU7^Q&NC1OE!7@V=5'MA0=S:]9E<>#+AO@:?!T3^*);\\`8I11ZX(1D`#<.P4K\nMW9S`?IAA]]M,UVAY-M^9B\\@]E]MOFT)OK),F!::D6@J<9]N!>KVI>]'J@_@6\nM!-:F\\+I=G0?6IG"W!^MJL-1'4>*SE,;C4]^]"`!4X[.;G26P'F3<7V:ZQI+2\nM/'>\\RXZ=X^R_UH6-C4I\\?T'6=S/@#,`-1DD-@/C6IOA^[_<%NWJS]%8NT?(!\nME/AUXDSQRR]>!.#09/7`FR:>I>Y\\B:F@9#I@+H/_G`TY<.!:IH@AC*$`BK+R\nMLK3XDIHJ4%!6(9VV=I>V!?+`&7$L'(7X/K0[QU/?A$R\\,)/&@\nM_=T?P_M_U>#J5Q'\nM9/H\\@Y`%V]H2\\A+R`DKC4IB#W#CV*IXZQMZ/P\\N/;@,`>.@A.-X)<3=']/#&BBE2:0Y1`IPOK;6BO\nM(=NK6!NKN&$3+^W@EPDN);80B%+4BZQ\\%]WLWU%BGGWW7N23\\HDE^-@$_-G\\\nM;[(2?IZ9EN9$DYUES@=VN?S+MXXSI^LPUMBL[5Y__%I;5Z66`%V"R*`,4?D&\nM;M:DEJTS)'-JML)W71PW0'EU2KM.*GVZI4,W570B"+LE49B3=7.**(.X>)XT\nMOP>ECEW\\F_BQ1;!D@U;\\%RQT?IH33>1LB_=.VEQCI3S][3DZDU-0R,CPKH69G--R"$1=&`DTC<`@"'QT,$3H-5F3`K<'@>=H_]$JO1%YEI.9QLLM\\RO.<:F^>?.\\Z14*,F\nM1E">A7`UI:TH+54M^'2O3,@21($@QQ(YKBBHJY)A1S+F*2;K#M,-CQVC`>/#\nM`2,-GZ&:1^`[.(Z%UJI*)\\F3OL?=94&^;Z*2?NE=B;O'X/$EL9HWL]/GCG.Q@?;V!IU1.GMH@40O1ZLJQ*:,^JZBMZ%?C2XH6`\nMH\\WTAS_TY/SUKA)SYY[QN@``/S<*.VHP[#S)D/U5IFO$(QY)`_;?-L7P*S412/>B'MB-L6)WKD\\YYL@\nM+X,\\S,'.;T\nMS-DK`_C(,'QM!8::VJ%0*R\nMK"0,<\\*HH-7)6&JES#=CYM=3%KLI*U%*.TT)\\S1/\\K1K\\F2-+%DDB\\^(*#IA\nM6JT`K:\\P`@`?&X?'EW(FAQ]F?.CVD__Q\\OM:R^M,7S^&4@JM)5HII!`464$G\nM3$G"G$X[I;4:L[H8L[P?..I>7;?\\&!3\\K47_OGP^`_^^`&2\nM,*';ZM)>W:"UTJ&U%K/>3NET$+A>PDS6'\nMV/\\9L-4$S?#73%;D:'D2+4X)+YEV.`````$E%3D2N0F""\n`\nend\n 6567 cabinet_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```+VDE$051H@=V:28]E1UJ&GX@XPYTR*VNTJVQ06VTW;2/$\nM(`3LD/H7L`"$0$)"]((M"R06O>DU&W:LV+#C%UBLD+"%&B%`W1B0VZZRVV6[\nM,K,JASN=(2*^"!81]]R;Y<7YS'/-^^'D._]M'?R;^7G+/`%('_U_3__\nMJ7(6EP&((0)\nMT?G<:$U1%(PFTPL`XE4!2)!AOG'`$`)OO_TV?_2'?\\"XKO`2D'Q=)(\\A("(X\nM+SCGL-;1]Y:VZ^BZGMY:O//Y';EP]%W+>#I#@A`D;$WT2AH83"AK(004FO%X\nMS%MOOL'^;(IU#N\\$YWT2V'OZWM*T'\\0,2@=8DI%'@A1%"!\nM;#H1I11&:YQSVXCW-2IX/A\\`)`10B@BT;8]6"NL\\W@O.>;J^9[Y8+WER\nMHQ"T-BDTO[P)20:P]0&E-*#H^Z3B^6+-\nMX>,3YHL5UEH.CPZ9S\\^3X)M5ED`(,OB0=Y:#@QO4]3@#VP(HC<)D#0PF=%4`\nMO7KW/[]FWNW+G#[/H^\nMG76TO:6S@>/'1X#BQ@V#\nMXYS#>T=%A2E&B`BSV36,*>AZFTW-XT7PSC&JR^0#,87E%(%>T@="5$S5([YY\nM\\X@WOOW[Z&("@_`I`BH5J/I_X?7/[O/C_AV,5F`TQ`*M0+3&>XW6'JTTWOLA\nM^FPUX(AA])0/A)E1Q>^\\_N?VZXKU/?ATKQ=7S@&03"@"QIQJ_\nMP=[KO\\W>SW\\';2K$-43?$GQ'R.-,&KXI#<%WQ-`20Y>/AN#GB'U"<"?$L$X+\nMD((:2K.MB=3'5/$.[SWX%40T+V%".P"TT9OOL,L<<0UB@MZ'(K]"X(%!@%IMM4I_(R``1C#+;K\nM^.1LQ0]^9+D=UK2GPOK]OV;ZRJ]ARBE16J+T1.D@KSBA0[I'N.8!P9^C\\"A3\nMH/0!VH#2"C8`%*"RD"J9YO%\\QFJ])C##:/U,,WJF!D:C,<='A_S#^X]Y_[_V\nM*-[]&Z+2J.!1^CU,4:&5&BI3/52H"MA#\\-6Z\\BXEX<@$A`)/4!-V[>XGM_^1=,)Q-Z:['68JW#N718YU-!Y]P0\nMTYWW]-;1=AW-NF7=-+1=1]^G^)^A@T#H0@F>U;CF?+UBL5G1=CQ\\M\nM\\_F"QR=GS.<+NMX2`:,-IB@IJQ%&ZQUSVK9>0[.?*U"1!$"AF)_-$>=SR+T"\nM`)%4CVAM6*[6."]8ZW(B$MJVX_C)"4?')ZS6#1$HBI)Z-*8H"HJBR%V7P6BS\nMT\\6I"RL?8B!(!I`KUTTIX>79D>B9I81X(1)16K-:KW&Y_N^MY?#X,5]\\>C[CJ9I*:N*HBB3X$613&^8&XPI4OMH#./QF/V]O:R!W)7M9&CODN.*R)`C\nM7EP#(9F00K%>-UCGF<^7?/J3AYR>S]'&,*I'S.=G+-=K;LVN)3OV`MZC'AQP>'7'XZ)"V60.1Z6Q&#!'G'=XYG"MPSJ"UHRS+!,!+JJNNI($'A,C5'6=(U%B%>IZQ,F3QSQ\\\\.&6D3`%15%F-B+9OZYFO/:-M]"F\nM8&\\VHZIJ`(PS6*5!;?DE8S95Z55-2`)!)R?NNHZ/'WR"4IJR+'%.YV>2K8['\nM8]Y\\\\UN#K1?9_DUA*(J2JJJIZQ%E50WT2E$4G)^=HK4>`H;WVQXZABT3$L(5\nM3"BU@3+\\N%)0UP5%H2F-HC10Z(A1@E8AA4DL^(CXB,\\Q/8:00FE9458U9551\nMEA5%66&*$IT=FR%;I\\-[][(`PI`98XQ45<5T.F4VFS&=3IE.ITPFDW2,QXS'\nM8T:C$>/1B'I4,ZIKJKSB(:20&4),3BX!+V'(WM8Z>FOINS[Q1WV'4HH@,F3H\nM%P:0RFF/4H:R&K%>+3D].2%&,"8Y[89Q2RS<4^<;-LYH3&;BE-:I=LK?2(1!\nMN)#,O$\\1J&G6M&W#]=E-8O!7U8#%&,,KK_X<7=OPV:?WV=^?:X#:<:YM\nML394CG&'*,)S,>/3K&.9()P9!*368U$4:_`4!;%K*5'!E\nMC>0.I.EZE&(H['KK:)J.L_,%)Z?GG"^6M&TWE-=)2U^E$L7+3A;V%`:,,?F;\nMESON\nMDPQ`509C],XF25K`*P)XVH02.QTDL%HW]+WA]&S!EX>/F2^66.M8KI:T;9MK\nMFN03&])V4R9[[QB-)FAM!FI1>`\\)SA=&M!C0BPLGI>:I;+G#^GCNW\nM7^'@VD'JU)SE?-'A3U<#O1[$,YWL498U?:86=ZGW("$5<3P?K?A,`,,64V3H\nMG+36A!BPMK_`]6_X38VB-`4J*K12%*;8>6ZW8?%X;[<^(&'H?9.R*M-G\nM=S+ZU0!<8*>3&6FC46B\\\\XS'8R:3$9/)F,EXG,;)F.EDLKTV'6.TH>\\M7=_O\nMC#U=GXJWKK?YO*=K.S[XT0]QUK)A=5]ZCVSP@1A`H)%`U_7,%TM,WC9-/8#>\nM*>)THF&,`1C"JLOA1J\\;)=>7;B\nM]U>2T5/%'<.="SOEPXI'HB;&0^"9*?D9_RL1`,Z`/PXA5!>$SA]3*HFD\\LY[\nM5`PDP`98&M463-P^%XFHJ!+UOE/V;-X#;);A_^_?_P+8B:=<[GC@@P````!)\n'14Y$KD)@@M46\n`\nend\n 6568 calculation_write_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```*NDE$051H@>V9;9!<59G'_\\]YZWO[=O=DALS$R4QFDB&$\nMR"8!,K#95``AQ)58K*(;M=S=H!0J?K#([I:K"VZA5NV+2PE:!5+"?K!4K+(P\nM[IJE3"J2A1A()3&&#.1ES,1,XC`SFUM=L(0`0$H)*>4Q*66LE%JME,+FS9OGRMM%\nMZ2T!GGKJ*7#.8\\[YLYSS.SGG\\S.9S%QYNRA=L(3.:]VZ=8CCN""$L`#<98P9\nM6K-F36W5JE4X?/CP'%A\\:UVPC;Y1]]]_/Y12Y'G>AB1)[HBBZ&`8A@=KW-==T>UW7GNZ[+?=\\O!4%P+`B"LT1DC#'O'@``;-FR!:=.G<*B\nM18MZHRC:&(;A59[G"<_SC.NZNEZO>_5ZO>2Z;NRZKO1]OR<(@IXHBIZ-X_C[\nM1!1>#HB+!CBO^^Z[#^O7K\\?V[=LMW_=SGN=QS_,BW_\nM(BR=[7EPF0#^&L`F`K[(MV[]=V8@NQ)#=AC3LH%C'^$07V?`O0"V-!WIDMOH\nM!6^T^DD88%7.D1]MR:HVSEB+,<;QPX0CRE]OHDIOQ4LFDW3OODPZ54];O,X9\nM%:?+P6NU:O@,.$WAP&[LS('53^+.6WKPPJ&SF^^]:_D7K^S.H5#V\\;N)\nM&G[YRB1&IEIAI5L025I@6>JNUE8+7?/36-77"M>+H^_M.#DA&/TT?@>A9Z>$\nM"'CVAZ]F>]^36=/_WG:D;8&*'^.EP3S.%#VHK$)+CL!MAD@RC-9#'#A3PO97\nM)K"X)R<[%V;7WO.AJR`_^*-W"0``VNSN[@YG:1`E&!JMX.<'QS%<<,%L"9E1\nMR&0)S&;@C@1/2W!'8M*/<6;:0\\<"I_\\_?C+H,/O2EZ59*2'."$E6+;]BGC5_\nM?-K#SH$)G,J[X&D)DAS247`L@$4<9*G7)UZ2&/RVZ,'.IJ["PEP7L\\70W`/<\nM\\!0ZW^.@6`Y6*4O(%X]/87"\\!F9+L!0'J09`1AGP@($%J"\nM.0K,41".0I4(=8)*9=1*F9;(_=V.-]W^T>XV_-N">?8+?WG[9T]L6/KP\\`JZ\nMR7QF(;[1V1AO.@-,,.@5'3D(NO+86!6N-@V3M@1+"4!QJ$P*F5B#61P\\DP)H\nM9D>J#;0VJ`!@:;DBBA,F!->-P5W(/OH(_G[WBI8'<_L_UR+MK[>/3-H)F>Y_\nM_-GXOFL=)+,"0(*!Y51'-4PZJS4?E&(`"T$F`F(#@H&N5Q#41X$P`&P&X@*0\nM"H8)&,[A&0)9_"IE>`Z$TNIO]2'3_BAX,MTW].=]W_Y>O/0#QW=O51\\HQ>5K\nM?#R]O@U)^;>-^,UG0#(8H),)T^+8"3(9C:P#9&U"QB(X2B,K(V3;%^'#"8,G\nM/+@DX2)&W0BX1J"N)7PANF*P!024EMS0#J]RMG/)LH['E^`7&P>/+\\:^7]^$\nMG>F50=NMMW3W'2VK\\38OQ/[/ST(&)`,9]$(*.U0*M50*?DJB:"F(M(1,2W!+\nM@)1HP#*"88`Q`(R!CA,@3,#\\N(W%NH=0./'3'Q^0&S:M?"!`M+'BGL5M/;VX\nM]6-^\\%V`/K2G'SR<+XYM%Z`2VZ`ZMR\nM\\Y(77OW-\\^G\\A[B?'__F7WUWR\\27_NQ3:!I`*$)P-1Q#$/V@>@!B!=6=30K*%\nM/>T.[!0'10G`"(81P!F(#&(R`",P2X`I#A(,8-0`B#5TR``B&!8O*=QYW3T+\nM>C[XT=;7=L,?^;4^U!,S,3(ED-W[/S;OF'@]`-OLM!B)!Q]ZZ*L#=]]]&X"]V/N+_SM^4P`SZRD9\nM`])_?-Y#P'28H)IH,"X`3F""@2G^>BG!&,`8E`Y74$UET#5>0G]2C4=.#G]S\nMW_Y_V';HY8,`]KZEAZ;V0D0`,?BQ-H$7)J`WO-]%VF"\\'D&;\\XFAQL1EU%B]\nM9\\JI^DH9^9J"/5G'.K^*\\MAK/]ZQ\\_G'VN=_(0G#9][60U,`!@`9E,-(YPO5\nM$)P(F#%<#1*4@QADS,R#-H`VC1_-9,L;JF#B1`A=B]$_-0TRE;%?UG\\H]?E(?F,F"`N.A5HD0?/351@^0S1X<&J`4QPDC#:`.3:)A8-ZY1`ATE\nM"$:J&-L]C2#A6#0X@.WRZ\nM&/E!#$X$HS7BN&$:,]=&OT^@PP1)T&K:\nMM5ZKA-TQ3+H>:6@TVNC5;@%M40FIP0*6P8T&>^R#P?(%_\\1B\\X31QCV]H>^2\nM8\\_:R=QYV?=O!Q*MF"6OE6FY4:;E.F:)7F%QY];R8,=B/Z^FBWILU_[2(_G/\nM??R'Q7O_.=^WY]L8OJ7K'<6;=8#SRGWE.7C3->06MEG&L5MZ\\T>[^]W?/=V6\nML4:\\>O&AQQY_^%<;WM]O=FT_U%2\nB?^1KV968Q=R5G'?W7VN]_;[L5+=\\_8'B\\S=A8<\nM.S.!9(*$2`(H(D!$4)`0$I%X0#R`$`)%D(&R/[;'=[G:W>_/M[=Z^R]EJX>'<>]MM]W@F:,0#Y),^U:FJ4\\N_\nMZMNJ"GY*/Z7_WR2VY=[S]P`5C#F`Z=6)^QN]<6\\66'=QGXS)6"O0.OO^23L7\nMS`)KO/S[VXJ=NS.6)=!*O^\\7GQC_ZCL>V>4JI=$&M#9HD['19E!F3._;@$9@\nMA$#3YUYYOXTR:*702F&41BN=I>:>_G36IC^F,=#JIF)FL?6'MB6^UKT'US8`\nM(EL0]_!DM?K!$[O=)-4H;3)6!J6SO%8&90S*"%1OP@J!PD(!V@B4Z4^$K)W4\nM2*61J42E"IFDR$2B4HF2"MT?1QO,/2#6FC&W[[0]Q[:XE[8!H+>SS7;"2B/"\nM$@+36P6ES5V#D$U<"*2P4,)"(DB-16H$D8)0&KJIH14INK&F$Z9$H20,$](H\nM)@D39!1CH@23Q)A4@C$8P!)@6P+'MG`=BU1II-1H;1X,0&D#`IY^;I;3E^Y0\nM*7KD`P??L_%="R$$!H&V'8SKHFR7Q+*)A4.$36AL0FQ";1$9BU1#J@Q:`E)`\nM"B1`?%<::X@TQ`FD#YX)M9PJK)*0IQ#'$#MA6QJ(W66/(Y*;'/X%R[P"`3!GN[W@'ENILEQ#%;4LT0:I,S8LK_8#!<#1,]$?NY!.R!5MO)AHOB7%V<8*^=Q;&O0:7\\E3,_V\nM#P;L#=8'M"V_K>[NO+FKWYW[4L:0Q#&?.'60G.\\.%N0-`?1)&T/.M?FY\\8#`\nMV5HAW3.E6*+G4#/;OK5ZF9F54B$LT1-Y@U0J&UR(GM/2I%(BA#58&*4T2FF$\nM)0:.+4Q2KJ8^4F^!>TL`(!O$DC'54S.S7([EUB[M`&";:^N'"_UP15@6CN,.V'9<+,O&LFTN7KA`&(59\nMG>>QNK;.V;-GL&P;V[%Q/8^+%R\\P<^L6GN?C>A[=;I?3IT]CV0Z.Z^('.:Y<\nMN<+L["Q^$.#Y/E)KSIXYBU(:QW&W0I4>OPF`GCF^RPIL)X/!8/4"-2E55FJR\nM.,:RK$&=,88XCFEM;F*,02!H-INLU.MHK0<#&`-KJRL#Q4V2A,6E!;IA=YO.\nMF3<`L$V$^C_TY1D8:']&(K-*0O#P_@,4"@72)$$`0>`S,3DY^%\\(P<3$),5B\nM<0!HS]Z]O/\\#3^+8]J#'\\?%QS"#TA6*QR(GWG"1?**#7-@83?R,1V@;`&-"B\nM#T30Z7182L,!&"E3XCBFW6IA@-5ZG3#L8MDVCN/@NQZWYV8)NUU:K19!X).F\nM"?/S9Y'M5K#VVC@\nMUEIT0ZY=GV9A=I%F8Q-]YQD\\SZ%:*9'+EW`];]"V7"DS/#+2\nM$Q>H5"KL'=]'N5+NJ;ZA-K2+R#AAQX:*'$0!!P[=APA!'-SLV`,CNLR/#+,:KU.M]LAE\\LS.C:*,8:9\nMFS=)TA3'=3ERY`AAM\\O*1A/#_D%H\\:8[T&DV,`:GN7I'S+SZ$E?K;8Z^\\R3O\nMWC.*YSHD2M'MM&G<66+ZPGF^^Y\\_XM2)8SSY@<=Q;&<@/K9M4ZY42)($R[*(\nMHPB`()_90\nM*!9P'(OHF5RZ_1I#+XW@^EYH.\\VW%=+WQG:EZX_R9\nM;WUQ&X"!$N^;F.30D<>>N%-?_8T+"YO\\]J]_A,GA,L9H-I:6Z"PNDG>@%-B4\nM/(M:.<>1=SZ&Z^9G3>`Z'G9A7DZG0X8L(1%\nM8V.#I<5%TI[Y3>*8QL8&C<8&QA@F=@^3JU:PBR7L8FEG$?KC/_TTAXX\\RLS4\nM]5^X/KM0G3ATA,F1,JUNMO6Z4J-6*5,(7%S'HEHK8R;V4BB6\\!']CS]!K59%2DDNG^/8\\>/$28(1\nMD*8IQ5*90T>/,C0\\3!BE.)Y#WO?1.\\E/'\\#J:IW?_-B'K,]^_@N'[VQT.'AH\nMC"A52"61,B7U/6P'NIT6KE`(WV.D6@(AJ%1*U(.`S)^QVR>5S\nMV+9-_D,`OA?PR,'#5A+'?B(E"D$L-09!X/M4K`Z!95&NE7`M@RL,<;=+\nM/I]C]]@H*_,+I%*BM&9D9!0I)99MTVZU<#V7D9%1P-#I=.ET.NS9.T88=O&"\nM@+6U-800[!H9)DD24JE87U^C5AU&6R[+@WLIM2,`"Z#5VN3K7_N*M&QG+><(\nMEEXNR9,ZRNK>+[\nM/HV-#9Y]YD=<>/557,_%<3VFIF[PPO//45^IX_D^<11QYL47>.7E04CX_.5)5MVY,L=R,2*0F3B2)\nML#&E2I:7FEAI1L9V4RI7::PWZ+0[C([LPG:P\nM;7NW;3G?_L&9"X][C_P,/_NNP]C"$'(X4DD*A0)1&.)Z'DHI/,]#IA)C#%)*4ID2!#G:[1:>']#NM-%:X[@N\nM<1RCC2%)$OQ\\COGY)2XZCQ(%0TBE/B7@'[[\\JQ/WZP#`]__KN_S!I_]Z>7EN\nM^LM/O.O14\\^<.V<]V]EDU]Z]E/,^'2DIA%V*KDUH&2[.S;,\\=YNPU>#8X7'6\nMU].S88[QVZ1)**28F)AD;&Z,;ALS-SK)[\nM]Q[V[ML'0+%80JG,NM7K=0*15(ET4HQ.SM/%,4TD@W"\nM=NN>P]4]``",L#$&W-H8XR?>3[529'YZAH6%FRPG*<:R<%T'6V@"%QS?Y_7S\nMESB\\=XREI266%A?)Y7+LWW\\`HSO,WII!",'HV"@8<%P'1'9'9%D6EFUG89Y2\nM6+;5*[-PA(T2`MOUR!O-_II'6P@*A3S?>Q"`NX^4=K[$L6-'>.+@./,OGB:4\nM"N?08;Q2@+80P,#X\\P.CH*"`QZ\nM<';6O=08@V:KK'\\&WCVZ!]P\\[JX##*F`ZXOK/'7F#.5BX<$[T/=V_;N:5$K\\\nM74/L_\\B'`8,4@FZWR[Y]>U!*8UT]1^V'WT5T[U`41WGHL6,4AD=H;C:I#@UQ\nM\\O$GL"R;S58+K0UQJI!*H92DU>YD5_0]$0J[7:(H(M60WS5)J$LL:\\526_*#\nM5ZYQ8VD#VVZ^"8"^*!G0PF:)&LL-A39VSYEHE"YB.@:-@]9[.'CY&A,K4R2E\nM&J\\\\721]\\N-H)X_92'I'4X4R;N^`E#E';5RT&V\\]C!X4L]0L(\nM/P=.@'%\\M..3$B",8*9MLY&D3-U>XO*%BT@GAQ,4=HRG'P!@Z_W+MAT*A2+%\nM?![!$,)H+`S":.SWGF)ASQ"'OO$9]L]?X.^R1CCW\\0I?3@U29CB]18\nM)$80*XBD(4P-W533CE/::PV4<+FZO,G,S"T6YFXA;3=;?3^_8T!TW[4*<-W`\nMYPW8_3-Q]FAG8X2=B87(=L@(@Q86^O%/&N_I+Y]Z9&7FPX>JH^+\\^=/RM#?Q\nM;\\5W/WE-IHFEM1F\\F2F3O02E4I&D,F-I:+5C-AIMI.TR?^4RZRLK6/DR3J&$\nM%12P@L*K1M\\/X"=Y1'U#^M8!04/RT(F\\^>9(J?"^N2/OY\\7YS6]_\\T>G?V_4\nM$NO?W^DL^#:1_>:_O#GE!/QR531O)>)&U20?>UO5;Z8[[_'>RW\nM99__%^AOC];XJZ-#^>^=J'WTTO%@OS&?Y#-ORQ[_'Z;_!O"KKK37;16M````\n)`$E%3D2N0F""\n`\nend\n 6570 chat_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```.&$E$051H@=68>[!=57W'/^NQ'^><>^[[@4D(%R24AD<0\nMB4`@9A(!4:`69ZAC"V@KK:B4T3I:6Z?I./:AG:%V4*NE5!1QQCK*C*-8889:\nM)VBM5E0@!`-Y@+G)?3_.:^^SUZM_[`-)K8W8W-AQS:R9LQ^SS_?S^WU_O[7W\nM@E_Q(4[V']2VW6,E.R14GQ;"/$P(3PIA#`/?.2J7P[`T(Y/XWQ0B59;\nMA!1OK23ZRC5CU?&SU@\\PN:;.Z$!*$BN<#QCK*8RGG5L:K8)&Q]#.+,9Z0B``\nMLP@>$HB[@N#;!/P7_WK[R0,8WO$90F!02G%[$LG;SCUS>.QUVT[C9;\\V2AHK\nM\\L+1R1UYX3#645B/L0%K/87U=`O'2MLPM]REDQN\\!^<#WH=9X*/`1Q&LW+MS\nMZ^H##&W_-"$PKJ2X8Z">O/&WKWZINNFU&XB49&8QHY59"NNQSF-=P+J`\\P'G\nM`GGA:.>65F;)NP[C`MX'?"BO.^`=PN8_X?W;5D]@*'MG^GY7=S1\nMWQ>_XWUOOD"\\X\\)]A[O`?C`IW>.%)4\nMDH@T4<21(M(2K21*"A`0PO/B/85Q%,8119*\\*X:,\\3ND9-?.?WS\\Q`&4$HP-\nMU9A>:+VDKZ*II1$S"QF=W.(\\+_AX>C%G;J6+5I)JJJFF$954D\\:*)%$DD2+2\nM"J7$"QDHB]O1+1QYUZ&D10B!DFYB=#AA>BX[<0`I!:VLB]9BSKK`D84.0_6$\nMK.L(`5P(3,UES"WGI(DFB54I.E:DB:*21E0319IHXE@1*8D09?\\\\/DM>E*TR*QP+*UT.SW<0\nM0J!5:1.M)5$DB;0BB21)K*FDFKY*Q$!?PF`]I;\\64ZUH*HDFB^LX/YMU3Q[[QGT=>=<%9(XP.I810WA]"P/M>9SEF6N=+\nMKQN/E!8?`E(*K/48Z^BO*K143,UEY(7_5R'$SEHEZAA;/OA%K0/KUJWC\\LLO\nMY]EGGQT:&AK:,CX^OFU\\?'Q3M5I=V^UVZXN+BW)J:JHX/'5H=T>M^]KPIC^X\nMI%:);I@8J5;'!E-,+P/52M0K8$VU$E%)2NM4>K411PJMRHQ48LEP/<(8S\\'I\nM=F>AT?U\\8?P'M!+/Y87CEFO.>'$`V[=O9W9V5JQ=N_:JR?/%&S=N\nM3&NU&HU&@\\.'#[-OWS[V[-G#GCU[F)V9.6Q$]DM?-:HE\nML::::"H]7S\\_TT0=%:\\EL9;T5321%F2Y:R^WS2-YX3[I77A02)'==.7Z_Z;O\nMN`!;MVZE6JW2[79W;-JTZ;[KKKON)1LV;,`8P_3T-`X6MI=5*-I04^WW@6\\Z'![P/WTD2U3QTN,E[;]SX/S0>%V#SYLWLW;LWVKIU\nMZ^>NN.**&T9&QV@VFRPO+3,S?'2!1_9']J*+\nM7O[HS,S,C4&HI\\]]W<=$K:('TUB?EL1J?:3E+5$DKXNC,O)Q)*>26'TJCM0/\nMI10'!!PLK%N60H3;7G_6<1URW"+.LHR1D9%ZH]'8L&O7(XSJ.3:=7.&/-F:P;34E"B]!\\CBAT^.;>EEZ_?OV%]7K]G"1)GK[_PSL"L/0[.[^Y\nMU,K,D4JB_K1GFQ#'ZI$T5N^/(_7(PG(>=O[N><<5_`L!-!H-0@AF_XB=^\nM/V][ZV8NN_HF1%P'7X`K\\$43TY[#-J8PW3:O/'>$+=]MLG__@6ZM5EW*L@R`\nMJV[_%Y24M-K=-UKK-W<+UTH3?7?JPM\\T6\\61^:6,3[SWTE](_,\\%F)I>P!4O\nM:R;)]QZ]^=(UEVZ^9!LAJB-T!4(,(@-GD+J"U"E")XP.U[EE6\\R?/;![_V+1\nM]V-A.P"T.Y9GVLNG);&Z)8G5@311.YT/7VQVBN(+?[G]>#*..]3_=N']UX\\B\nMIU?$/1^_;D.M.##Y&UO/VKKFC',5@""44P1$<&`S?'<%UYG'MF:I^"5RG_['\nMNW[OVA^>WW]@_ISS+W;_?,]?<.?GGWB;]U1#"&]][/'9ARNUR#WPMS_[4_&$\nM`:Y[Q1CUZDKELE>_\\9]V7+CF38-R(8KZ)H24"B$D4BFD5&!S7/L(=N4Y;.,0\nMKC,/-F/K:V^:'!HYY8JY@X]^92%,+KWEKC#B`T,AA(]T\nMCF.AJNIPQ\\,A>^(3VWY463=YC4]KV-8T4BJD"(`%*0GM&7SS,+Z[3+`YWAFB\nM2C_].D^6CSR\\KY)/S4XF`QCKEXWS7VIGQDT_>.,)"_^Y`+?=,\\=59PWB6^V/\nM^I'ZH%3Q.7;IF8N%;:?D0Y#V(U6$*UJXHH4W&=[F>)NADL$?X+)G5.?PAU[]\nMFNW-!^[^!M,/W>A63?4QX^>NQ$?NO033;FDA_)B,*O?KZN@ENC:*3OL10N%,\nMALV6,*U93/,(W>;L0K>;7W_:16_X]_NNO<]>_O8JY_]]YV1H?W$``#_YY$9D\nM4B?8[N_+N/9QG0Y&,JH``F]S7+Z,:<]C.HODK:5/+:P4MU92:3;_E3]IPI\\?\nM+^IU^M1;G\\07;;PKON"ZK:^9SCRF-8-I'L$T#V-:7B0`P+HM3Z"\\7TETX[U%:^'[ICF#[2P04$03F^@PL+S<6'E/LWK!$Z<,\nM6J[]V,F4?72\\B.^!]P-M+R#0"%`777^>>L__I9;SK_]YC>=?>'01&WLH>\\M\nMI,%/RW4+NYE8-HPO>=8OP>2*PAZJ\\*7L(O&M^.7QT&AU1G8+0Z.*76:#05+HGH)IHE)$;),N(576:@GD!?7)Y3`HR#S()61W=GK2^%Y[8W50WG\nM1Q&BA%M=``!9<\\[W[]Z]R/Z#%CUB#U\nMN+12UY;/>#X3B4;&`A])B"0BED352)G"C00I5PW@F%<)#_@A\\)4>#(1`*E;0\nM(O0V[,,+EPB]WT*468E5":4E*('0DJKJ((0%)1%:,C:6$B5JO%+7H.XZ*0##\nM)8"'X,$8JG*11`8POC=[!5FX,NKM`E9R:)ORG/,00"#HEVV$;8,0!&!LO$)_\nM/1J]Z>WGEN"K"^``-P9.@X/@P.3T11D5*4JQ75O:(S.E\\$8!RSDL9+"2%KINOHJZAAV!;A?7<5\nM`:!48\\?+I%C``!WJE005B3+BB0+=Z_&!LDUFN@1X?C$K'+0-D?>,#290%%!8\nM*!R=AF$PE<-02<&N)H``,B&$F`C!4K:(".C27QLBC10TNV7DC^WQ77MT-9:B\nM]+_QD!EB+3BEOX;H>K2U#-0U0WT*:8H!B&I@5U81($`9^D>%<"H$Z\\H,.**H\nM@I)`NV6P&`B3N*(#OM='JM#0J\\*R&<)_:>B"':;0VS\nICX']$?!OP'G`*T.9Y3]>%8A?Z?%?#^3MDE]TA?8`````245.1*Y"8(+:\n`\nend\n 6571 check_ok_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```)<$E$051H@>V7>VS5Y1G'/^_[^YUSVM.6TD)+H<6V"'0K\nM(!1-E(D7U!$5M&Q#-Y*Y:$:,F]-@ZG\nM&TL+MA,TX`1,A%P@+A"U;2PXZR&M$M9)_F;W$[]ZE/&1YV/H<^;UQ2WZK#@8\nMVJ5$2"O@"\\6)VL(9?X32Z574S*Y`&&XUI8=;3269EOA/):RML]:,T#AGK_.=\nM<[9I#0T>'PW]_H0Q,A4(1!(*!*,610Y-KLO$;<:P+(N4D8<)H,!TF`3C.MUG\nM#,''$G"L]88&P]#)>$CR,*7`8(8"`+E.\\!X_1K\\G@"\\8I3<09<`6A@Q%7"F(\nM6=QSPQSR2RJ(6'+^PT>SME89_80UQ[7&3%"+Q)*4!RRBMN`+QY&DN[K/!/FF\nMN8MV7P1?<2[QBDFH&06H/`?B#^-UFTS*]$[&H>=3R#`U;?N^I/&]S8`@8G/U\nMK3]F\\;);L>V$`5/"I;12J8`V0)D*I;,HU!^,,639A'QA+!+NZO=%:&SJP3$]\nM'U=1$:ZJ0IPU4]#%;NR>`(Y\\%TK&Q_N4@FGZ.1VX"PH0$4!PNER$@P'ZND\\D\nM\\GIJ#4)>82%39U0D#)5.L5D*=/O#6%;"15HG,LUU2RZGNFH*.L>!+G2A)[G0\nM;@?*,J#0H-KA(A"2\\5,FZ1D1FUGSZYA]Q>+T7!#$MJF877..%W52IF$4RE;`\nM4@HQ2*>KJ"48!2643RY-;)3D)Q&!B*"4PA^31/X>KP>&*2@(@A+2V4X;"J6,\nMT977)/B:CH&,(%:&1HF@#)W46-'4^"&'OVQ`:8T";+&8L^A:KKYM#8H1+)])\nME7&FU-&\\EQU#.8;&;4)9KH/\\>)P@-F9F$"M3(TD%$M4O:^-D1=5*(78<3\\\\)\nMK'ATU#0X+*.,%=C)&@)RSAZ%.0[F54[#Y^N@O:^-LM`+8*044("RZ\\4X6WU0_7!D2')XR?2:DO#`&Y\\]G\\?!0@/#0(.[\\?'+S\nM"S*$%TJ<&CW8PFO;UW&H^Q`N1PXB-B(6JQ?_]+[>VOJ6[:__?5.20BI9SA,>\nMT%H1#8>(A`)C"C*6D"/]CX+2A297%E4_=O?;N9C-!))U(B:E[AP*1\nM.+'HT+>FQ(@"I];K)!V58)J:*Y8NHW3F94ROK"8:#A&+A,ES:)R!,_RI\\446\nME%]!^>1RMAW'/Z'7UTN1>S(_7WIOO**P8E]@*.`]2R'A[.5)"3EY^;@+\nM"L:V\\K>Y_V0&-X+24YA>79E.B8:AJ#+#O+IM`[E.-W$KSL8=&VD^U8P5MYA?\nM4[#2:RD*D2CYGA1RMG8\\RJ7U&:\\5E\nMTRDN*TO7C3*7P>Z#K]+J:R48"])O]6.Z359]OYYGZC+Q@&0^.K*^R7Z\\)%]8I*B:W"_'-+A;`OSMR+OT\nM2S\\1(ABY!K=4W<0O;E_/ZZYI^&-QNI)%-E&))S^EES;$-QI9GK;.OYM[O9?P#+::$FN\nMB.RS+;21$-XPE$:I2"J@$FDT<;]^1VGU'V4H45D'8E[XPQRM":&LD"6"V.08\nMF@)#FSHY)R[(`T[?8Z^=^FA-W&EA*(/2G%(>7_)$;XG[\\M_LLN(')AE:ISR/\nM4@KH3"4#$\\#SNQL!>I+M.X-UJ!7M\\:O8O#DU(8E<8XGE*C#R]L5/=>X1PXR?\nM,:#OZ_=X#M3[#AW9K;BR]D=67K=X>[@UONO/1.Z6RNO*\\Y^B+(?R>/7OH[>QU\nM%,TH>N;CCH^?:_6VSIQ;,E=53ZEF5]^NXB^\\7SQ5];VJGZW.7:T\\MN>VKP:_\nM,K5;,VWR-.Z;==_IJ=;4WQ?/+!YX:\\M;8YYU43R@E,(P#(!@Q([$]O;M-;\\>\nM^)K.<">3\\R?3=Z8OKSRO_-$M)[8<;XHW+6FSVG#D.:@OJZ_N*N\nM)^[BR2>?O!CBC0_MK>VT[6MS]GGZ'MAR<$MOW3MU,O6O4Z7BO0JI^Z1.7FAY\nM(18<#.[<<')#J.:;&EE^:+DT>9O^ZSWEG=75U37NL`ZD&/D&:PH62&SF/7GPO+"\nM8T>.'+E88GU[[/AX!R*"][1W66-7XY&5NU?*[)VS9?[>^;*F?8TL:5\\B*SM7\nMRO[`_@-];7TSCW<'2A+.Y:\nM+.O]ZV7`._!;$>']]]^_U.*.C(:M#2DEENWP[#BVHGV%+#JY2);W+Y?=0[O;\nMO1W>N5V=X^?^)<'.3W>MO_=N2CP8\\&_;W^6X:"0Q>TWSB>)-\\]6@ZW($%Q\nM3ZV9NE%K/:N[M?N.F(KY%BY<>"G$N3#T=/;0WM8^ZWC[\\1L`GGWVV0O:YW]7\n3H/,0````!)14Y$KD)@@BG$\n`\nend\n 6572 check_write_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```(($E$051H@>V7?XQ4U17'/^>^-S.[P\\PLNPLKBR"["Q1*\nMJ>"*BD*%18Q@4FFH;:+6IFFJ2=.T)HVU@3:I-FFC:=.F:?^P21.-?UC;V%3:\nM8"M1"E1"51`*N(BNN[JP/]S?N[,[,^_-O'?[QWLS.S,[RRPHFS39D]R\\>^^[\nMY]SS/;_NO3!'%P^:U8BB-$C`$+4*N\nMK_R^/T:IW!HW;UX,A1B"F`HQ5.'0`F;(?J@*(R9!(VTSB.0];(!0H(F`&3B8S*C2FC\nM>#D%R_$;"@Q#^?G@QV$6P'@>`(#*((Q\\U,[08)S1"9N^N,VPJTD80D8$T@X/\nM;EE)9.$2+$=?>O/IK*TD;^Q9"Q9#SC8KF8TE4'[[NKIG^#XZ6XZ\nM1BU&:RK)+(DABZ/(O`!Z+,5(V"26[YV\\32\\%R#`5;:?>X/!?G@$T6KOH7(EM@A`SU@*Q_%7K5!!"Q0`<$;1!\nMKES9CL:(+N3:^76>(#\\^L318&A%A+*V]^CU3#Q0`U&@THLE5.V4((L:E^91`\nM+@?RDE@,A6B-&,I'+)P\\O(]S;QQ`E$(`5SNL7+^)6W;>AU#"\\OFA,L.2.IWW\nM2N:0(6`:$#"]I,]/8C$5V@?@(2UB]D]4)8)V,PSV=N)D[&G+8$%%*9?8_AD"\nM4ZL9:&(UM=14Q:AXZR!;VD[1]YD-_'?MK9B93"$`W"P``33KM]Y#\\[9=A6#P\nM8KBV?BEDO5`FYB]E\\50B3BHQ3C@2H3(2G>H-A`G;IN?H2ZQ_Y46:W]J/W+Z+\nM=]?<2*4UGA]"XA_GG@>4$NQ4$BL9+ZM(.25+_4>@AWURQJQ4TG2=LI+:!&2S@#MH6>Y\nM9LT%EM+$L>CMO%JUB?KPC50FTS@C=E$(:28O3Z*IF!?:SA$XF&*]-X)X=*JQ"\nMY">Q9(]#_XCWVQ0J.5E(.LN?[63G71?M:EQGTA!:P%0&9P<.L>_=WZ-5BBKW\nM&M;%:NA)5A&)-S"R*8:[>CZJ,5KL`0VY,@JN+F_ILA>X8JOGM:&!7B9&AR?O\nM1/XZQ];L.WZ8<\\EQ:H(.Z^I7TC[A,O#A#:AUBW!O6X0RQ;LNE*I"9(]\\)I6<\nMKETJ9+)RIFLUB^JI6;2H`)P"7CG40Y=[+VN[:[`NG&!X:Q.)R$ZV;FZB?T,U\nM_P#_(,L[B?,?%<<^[.'\\X"BHO*1618^/_(='_J.CJ$_QXR5[FF9#-9_/5,1;\nM1SG49I.Q(ZQ.---=LXS^FK4L"%?PWLW5=.$=LE,!>$ELH63L@^&X^\\'8>-[%\nMR=^PY#LU.U8EUOMCLVA<:DU`Z?3%9$77V_'*#$&V#0Y06^ND+NR^*<7RA?0[\nM+A]K[[IA&*(0L;()Y951[W[]1U%R1`S14K0AYB=XF"O_*:FR_PO7J`I3ITYU\nM1R\\>2SQIU2VX]8:+@S3:(T,G^[H>T^NWG!"T$M/`T-JSO(@`7>7+QVR0^@Z`\nMXHLO/\\8OVZUK'SVEO_7(H?3.NY[>"QC!X%?+BC"NMH[3TP[XZ_/0M?9+M*SY\nM17@X%=F>&"75T_G\\OK\\?^,G"!2VI>/R9LE)F4,FO!FV"ECW0V[V.W1M?(!A:\nMO;FSCZ;TQ__YU\\&C]T=CM1VMK3^>D21UE34M38U?@^.GZ[AC_9-4158O/==+\nM0V;XXCMGSO]PX\\:6CM;6G\\]8E'D5U2Q-L9]!QQLA'OCZ7IKJ[HJU<,?:WZAXNN:6W@&N18S]8N'!%\nMO+__=Y^_^?HAVM_OF8WM/S4RN`H&^Q]^&ONPU?-%.`````!)14Y$KD)@@J+,\n`\nend\n 6573 check_zoom_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```(ZTE$051H@>V966Q<5QG'?]^Y]\\Z=Q3/C\\6[':6P*1![8'Q$.A*H(*(1Z0`-%`2Y.6\nM-@E)G3JA=F@6QW;L.%['X_$L=SD\\W#OC\\<2)0X72(/F3CNXY9[YS[O?_EO\\Y\nM5P.;LBF;LBF;LBF;LBF;\\G\\K`I#>_QS%DM\\1CYM;Q%`:)6`(6H1J7X7]<(Q2\nM51V_9EX,A1B"F`HQU-JY=SL.]PKG!"47\\?6E\\P_U8P(\\?-\\M#)U9>.+N#[0]\nMC>`7'8^2IRFY/F5/4_)]2IZF[/F4?$W!]2EXFI+GXP!:@B8U3V&U5>?J=01$\nM)!Q+=8R`%D$4B`J<%/A2$"5*E#RMA1\\"`8#FQB@-""H6S1FBJ`\nM;,&E[&MFEDJT=?8PL+T;S5JOB5KK-0DS+?A-`F^KNC7K-*[8ZUKO66U*P8&Y\nM+`?FEP)GU`+(E0(`^;)'QE+$;).XZ>!Y'A4GKS%`P+1,\\JZJCMG`\\(T,W&B]\nMH<`P5%@/81Y6`"S7``"(16#QPCGFYW)D\\V4NY\\HL^)H50W!%P/'XPD?Z:6CM\nMIN3I:[_\\:MY64C,.O'E=:\\P@M0B65"+@4?8UV:*+#L,U-9/GV-`DY[,ELDTQ\nMW.X4TI5$$A9ZJ8<7S*62+>`3AFL^6.#AX":NS`3N3P>Y)$QEH\nM1C7%\\2_EL!IL1%]?WE<`5M,O8A%/)M%:`YJ(;5/,YYB=&@MXO;(&32*=IJ6K\nM.W!4E6+K`$PM%?&\\($1*!4QS_SU]]/8THZ(6*FVC4C8J;B&>`6F#7LLF5]#7\nMGS)A9+3V>=_M>]B^:V]5MQ*)[NT#5T11A3:M2:%Z`)X(VJ!*5V5/8R1;V=+8\nM%FP4YB9^[0*_3==3<[]W^,2-1&\nMJ9#M:FA4U];`ZG$>1$`IH5PL4"KD-J3%C0X@PD+LL!S>&1KDR$2.AQ]]A.ZV\nM#-/3TQPY]CK1MFZV]N\\@,;"#UBWMG#OT,A<&CY-L:Z5WSQU8D7C@!$.J-+KF\nM*H&I`DJLW#L$M'9QRBO73(GK`81`%(_B]"3_.'V1AS_]"`-=363++F4[06;[\nM3C)-&:*FH/!(-#<2W;>/.TM"UC9V]'>2*#BB3LAFEJZ>'AJA%U#:Q+0/#\nM$'1'*\\[,-..#;^*L%#`,"4E&$*V@)@*JRD*5`JD:I`$?\\)&P4=]DG;GZIGVD\nMO,+DS`(='>VXGH^GP43+,U>7K6I4@-F\\*R+\nM@(8JC8*O-_;TAA>X<(WV7$IE!T,4)=?'TQK'<7#S.8I:HU<,RI;",A1*0=0R\nMH%P@W9C$+17#`RU,<=F`A:@<^:P:>;5VK<*M[(,(OF&2B)A,SRV0+WOX@)@6\nMC9DF'*5HB$>(V2:1B(EA*-*F,)DODK-M(FUMP=GB!WN*JAQDZ[*0\\,;H%*?G\nMLH%RI:C5ZD<%-7VI_YBIZQ/J=VJ'[5WM'!\\ZPZG;!VA)QR@@3+D^>EV8FYWC?&Z9\\=9F#CLN(G`Q/&2O!!`4<0DE2V<76UIYZQ\nMYINTYCNU,E;KZ(>_F4+<$+9T=5N]PV<2!X\\.ZCL_M,?+H_7YLJ=UU-*F9VGE\nMF#H>LU1&1?3;H^.V>?K?O!F++5]J:?&4UA`:;QBB$"D%X:W0:'"_?D&4'!)#\nMM*PQ*##B77^8*\\6R:?I+CK-MSZV]/U@:'.Y[;?S\\J->0&O>57K)-"I8EQ63<\nM)IV,-5XN.[W62F'7A9&1UR]_<.]39B*:%=>52N01$>`BH0@W0+[TE6_R[,]_\nMPL^>?>'CQ5+I1R/OC`Z')J?J?`S%7VOB$1J)6O?N-)\nMBL45H[6]J\\OW_!V(:LKG5YB?GYN:GY\\?[NR_U=G7T_:+_IC_V=._?>Z=$Z.7\nMOO7E>W;_\\3,O_)DQ?>5^-QS`1C+YXZ>86,MS-]PZ\\>/_FY\nMCL;4T+.'WV2J3O^&I-!_([M'CW-N:'#:'CF^I[VXT&._?7]\nMS8TK)Y=7UNC?=``65QP>2[GY\\3+#:?'V-RW/-DG'+=O-YG;CUV^]_S#+2'Y.&=C=W;RQJV[JS9\\]/O_/=8Y^\\_=:QOU^XB,]-"@#@\nMY1P\\V2'^6)D3:4/?UEY<&+";V]-.0V;@3R^]]M*N6"0[['HW+P"`/V3AZVU2\nMF'3D9`KW@41^OG74,[?Z6EN_FLN]>*^!5N^UD1O)7[+P0,8\\=;HH3UU0\\87>\nMI'5NF^6^"L'?$C?=.;">/+,]15XKZ_Z4VG^+5QS[]M#*\\.,V^FNE]]JR_X'\\\n5!QU5?LH<2D+]`````$E%3D2N0F""\n`\nend\n 6574 clients_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```.H4E$051H@>V8>Y!>97W'/\\]S+N]]]]UK$I+L)BQ!""$1\nM<]SWG?#_/]_O\\\nMS@7.U;DZ5^?J7/TVE_C_/'E'1T>P:M6JSG*Y7#'&!$F29&F:UGS?C[36'#QX\nM\\&6/X?^Z)Y=2XIR3W=W=02Z7DX`>'Q]7^7R>)$E>2)(F_=.G2#C84B\\7SM=8]]7K=K]5JK?[^_J>;S>8_E,OEPW-S\nM_^JKKR9-T^ZAH:&[-V_>_/M;MV[MZ^WMI5ZO,S8VQJ%#AYBMD([=BQ@TJE0JO5NJ"_O_\\/UZY=>]/:M6M7]O3T\nM^%IKIJ:F&!T=Y>#!@QPX<(!:K;8GBJ+?DU(>FIRV6JU[A!#:.4<I%6G\nM7I\\G:\\U1\\6-VOT(P]#N=>&G"1[]6\\XZG@^_:NF53^:&''KH3T+\\6P-:M6WGT\nMT4?EKEV[WK-^_?HMU6H7^W[V#//S6:BWU4:YKO']2%G==/'*41I;99G]E]Z[;BJMO>_%:6770EO>==0*EK"7Y8Q#F+U0DF:S)87N#@\nMZ#S[1M.';WW3FQYYXLDGSJCQK`XTFTVLM0P?/RZFQH=YW\\TKN';W&Q"Y#CQA\nM"7R!M`H3SY'53Z#G'3O637#^X\\\\S<7+2Y<)`"R&8F9[BP0_=(+_UR'_LV77E\nMNJNDET.WII%!#N$<4OHX+T!('Q!4"C[7790E)_>>M5`8VD>]<1ECH1/HY<."L`IU@LR:=?H,2\\_S[\nMWN;8Y&SCT]G"B;E;-]3SU[_I[9^]_O*.U_54O+)?Z!92"J202,]'.(V-IM$+\nM(ZCZ&*I9H[>K[&ZY\\Z[-SQPZWKKBZEU/94>^S8]?HB?),TE_R^4P.SO#O]R[\nM*;>NK_7DC5><;PJ5'FPT@XWG<"9!")">WQ;A>2`$#L'FU1ZOZ)S:^X:M7^U^RNY)9Y-A6F=1(;3>/2.40ZCVM-8!MCV'@:IV*[;>C9N?M551Y_[V7_]T;75^4KSP/YR\nM[TII=:1L,C>`2830+5S6P,:SJ&@6'<^BHQET/-?,50>^*VWZ-\\V#/_Y'I^;T\nM'0^JE]1Y1@=*ON;1'Z*"F2?HZPQ7%?.!;UHU;#*'2^N@(X2.<-$DIC&&C6HX\nMU<*9C"!78D5OL;^P\\%1'Q=6B1BMAR25KQGK7K_]CM3!VEXFF)DQS$MVJH1KC\nM9(V3Z&@:$\\]CDCI&I3^:/OR#._J6K_A4U^#RY))[HS/)/+,#C^QM\\.-/]KAT\nM8M](N=J_3@8%ST0S1>FL%#9&Z"8NG_]38]Q]FPP=.\\O9U,ZAXIB:#TA*[]H&AW-H=)&(TN:]P2^\nM]]/CS_Z$2S[4.*/XLSH`H.,%UM_][$]-UGB=JH^_WC1.'%4+P^VH-"90C0E4\nM:QH=SV/2!C9K8E02I8W:>ZV.KD&WOCGZ[0>X[G/MXZU\\UW["0J\\5.OF,2>:^\nMIYJ39/43J/HXUB@H+C&9\\;[8J.E_B^.,S7]^5NW`+WDW.O;YBUEZ[<>9_,][\nM/^J%E0_[A2YD6`(AL"K&)`OHUA19XGFBOO%C[N$%WY#!L6-TL\\!#JL23+*`=98TJL\\TYR9N#P/ON_M&%+<_"-P.3"%X)2MZ\nME_=>4:U4MPPO#%_XQN_8H5L&O35>P?.0`?.MC&I+I4=\\GGW_-G&L3.G9.(H?\nMUTW]!'!3_P?`,S#98Z-7D`YWWJUMOZ#"&\\E#IP0^.7S2(U(YI]_^D_5\nML[6_+*S&7CH/A$!*_[(5R]ZY\\Q4[[[AJ]55#SS2?\\1_8^WEV_9WAMIRDI].2\nMQ]$5"`HQ?&6IY),[/#94+T.OS3J?FIS]O8_C,>,1_]>5V_Y.WTY_!N\nM?LY';JBL"O:,?NHM7_[O5/D+KQ1!G`;@'R'SHN["G)[=S\nM8-65VX^'.9E.,)Z,TEDH$5R:Y_AE`1/")Q`2ZX$6#D]INK.,\nMII[C4&L_C2Q&Y55>YN1=UMJCA'R!#P/WG1'@/J``)$-+EJRX:^?.U6_XW:L'\nMSM-"BH]\\Y@`F,\\P>=@P!73E'23JJOH0ZXNFLH]MTYKO[>BL7KUM9O'YT]`]X\nM_`LMFC>-L'13@XET#"LSRKD\\Y5R>4BY'/@SP/0^!0!M#IC51$-!*$NIQG8B(\nM!@DZU"&:.TEYB(#9,SAP[^*F>./0T-(OO/.=EVW:N&D9J8&O_>L8TYE%+KN*\nM+V8^3Q]YCHN".LM"1S/HXBDQQ*,=KT(5JDQ;2Y(+6#:PE)/'ZGSKXY:+;I^F\nM\\]4G"7Q),0PIY_.4\\WF*84@8!$C1!DB4(O!]I!`XP#J'-A:M+5;9-3@&$6<$\nMD$"\\M+N[ZU.WW[YVT^!@%T='FK04/'VL">4`6UG"D>(M'`D=PC<(*;`R!.N!\nM,A`KDECQS&1*D"B,MF1IF20IAB"]ZSP``SLT$8=A[\nMS9(E%7GB1$2D!:GO,9,Y(B&@N"B^DH-R"'D?`@E"@%X$:/G@>VTS'6`M*`NI\nM)3TZB*IU0D^"$`(I!+Z4Y'R?2CY/JC7*&&+?)_0]0N'C:1_/\\P@\\CTJNXC54\nMLP\\)%ON_`010+#@GED],1%B7)Y4>:>@SYP1*>E#PVQ#E18A2`#D/Y")`K"%8\nM7+<.M&O'*C60&$Q<)ILM86P+8RW:&-3BDFJ-L1;W(CVA"1$+$EEJP_86EV!2\nMVUK)\\+N+Z'*.N!"@"T%;7.BU1[X40$>N\nM#>3+MM"6:KMA[:)P#4G0!LM[N#0D;81DNIWI6"G"-$5*2:84#DB4(M,:936!\nMS>'F);9H,=;27>PB"=,E(W>.(.X7+S6)*0,=2EEJM1@2H,="CX1B")YHBPUD\nM>^0+?ALB[T-F7G`BU9#7B)R'"Q>A0P_/#TD7\\L191B!2/,]#`-I:0K\\M11E#\nME*8DF:(L.A&QA](&90W6.2I>I4]<+WRN:C_HOPC``%3!%=OA;2\\YV<2(`MJZ\nM%S:?;EJR[4HI:,,E?GL]D`C?(^\\G)-+@/(D,)-W=1=)ZGF:2(IV/$`)C+>EB\nMZSP%DRI%,TWHED6D\\TE31:8541I3E,4>5A"B?P'``G2#+8`%9T$;BG*6U.M%\nM:]<>7;TX*96%3$.BVA/6N'8G+GZD&91#64?4S9K(,;#?..#H[`\\JS:_;/\nM1>KKGDB=`)QS*&,(/`\\A!-;:=B?*4O(=163.)U$*'\\=4?4HLS"W,$I*V`W,:\nMX#V+$;+]8&3[/9(!E5+).80GF(ET>S)&JAT3;[$9*]O.>#O`[=]CC:<,W7G)\nML2P"4P5M,4;3-[ON^/C;WOMG,6LR>"MGJT,\\*-:&$_DH1D1D\\I2`:0IAGG%.F#:$I\nMY$N$GH1FUH[*J=&W%M1BCS_E@'6G70CRDJY"`3*)S#0=@<0D2H[.-L;!]\\_R\nMNO/7!<`ZQ[U@/W8Z0GA$D8^0V>+5=%&L)]NF6=J"3\\7J%$"JLV9=Y!D5W7&?^?>%SKWS/1,3]R=W9G=U2K'\nMA96$$382&!,<$!B,R2:XC"EL@RALDD6PP=@$XX+"0`F7C:'*!54V+KN,P"21\nM@PP2FT:S869V9KMW0N=^Z5[_\\7IF)2$;@1S^X5:]>EU=W?W.=\\YWOA,:?G;^\nM?X_\\3_W0TU_P:N(XQO4\\3X0REI*%K(AL/Z./2--:VXR-[8M@/_W1=S[BYSXB\nM`+>^Z#8`)<(4R#76VL/`%<"LB`P!_C8`$4*0!K`LPA&0;PE\\W6+/"(1__Z$_\nM^;\\#,#`\\*R*'K+7/!&Y62NWU/=?+9'PROH?K."!@C,480Q3'1%%,%,9-/?NCM_SL`;GW1;5AK':7486OM*T7D";ELICQ6\nM&69L=)ALQB>.$[J]/KU^0!A%)'&"L19C+5B+M9;$&*(H)HX3DB3!6AM9N!OX\nMH,"G!-F*3][\nMTT\\'X)F_]5JLQ55*7HCE]LK(T/BAJRZA7"YR;.$4)\\^[Z.U!L!:2Q2%A&&(-08_DV%XI,I8=9)\\H;3SF>W+&-L$;@?>\nM!T0??>\\;?S(`O_Z2UV&M=47DE2+RYME=$X4;#EU)N]WE.]\\_2JU>YWSM++5S\nM*P3]+DII2N5A1JN3#(]4R1>*N-X%`%A+DB0$08^MS77JY\\ZRN5'#6JB.3S$U\nMO8=,-H?16GEU;Y[O>/4JNMLK*T2*NYA5**D=%Q=LWNHSH^1:EG6Y_D+PQS<8F2Z?O8V7Y%*[K,3=_D.&1,1#(^!Z]?D`4Q1O6\nM\\A(E\\JG8&C[R%Z]_@*W.0WE>E$*)]WC@S7.S4X6;KK^&^TXM\\ZV[?\\C9E=.L\nM+"T2A0'%4ID]\\Q>S:W:.F:D)YG=/LFNJ2JF8QW52SQMC,,82Q3&]?L#Z9I.5\nMM?.LUC;P/(^1RA@SN_=RY-Z[.7;T!^S;?PG5\\2GBQ#!4*M)HM4>B*'X+<,01\nM=>3!]NH'OW'5HQZ'(-/`!ZNCPP=OONDPJ^?.\\XWOWL/2F466S]R',0D34[NY\nMXIK#7'+)I=QXW65&)#$D28(Q%J44^6R&L:6Y-MWW?G0\nM`)[S\\M<3)XDHK5Z;\\;UG__R-UZ&4XBO?_!Y+IQ=9.K,`6';OW<_5UU[/M5=>\nMRDV'KV3W=!6E%&$4T>WV"8+P@LX;0S(H9G&<$"?)(-$5P^4B^5R63J>/*,U8\nM=9)6N\\G*\\BE&*J,XCDLVZ^,X#F$8[E,BWQ,E)P[=>`O?&H!X`(644KA*K@*>\nM?V!^ELGQ43[_Y6^SMKK*RO))K#',S,YSU36'.7SM95Q^<"^.UH1AC,4B6#8V\nMU@GZ`8DQ6`M(*J&>YZ6RJ5+M3XS!&,-0J<#^N1D63JV@E'#EU8?X^EU?X-3B\nM<2Z]_!JZO3XC0R7Z_:`81O%O6\\L7E*+S(Q%XWN^\\D2B,13OZM85\\[I:;;KB6\nMY=4:]QPYSLG[CM#IM*E4JEQSW8U3X'+KZ"RR[>S\\%]NXD'O$XUVV"M(C&&(`CI]GJ8Q`P^8PC#B%:[\nMP^96DTZGAW(^<<(8*U]O.LY>_;OW<7R:IWSZQO4:V>Q\nMUC(^.<.^??LXN']WZODHWB[_6&.)XX0CQQ8Y5ULG#",2DQ!&$6MK=4Z>6F)]\nMLX$Q%L_W\\7V?;C]B?K]&:8T@>*Z#[[OXGDL4"_L/7,S:EU;8VEK''Y\\""X5\\\nMED:K\\UBMU"2PL@-`!*RUOH@\\J50L2+E4X.C"*;:VUNEVV[BNQ^R>?\\3!5TZG2Z]\nM7L#)TTM\\[HMW<>S$(M:"G\\G@^QZ>EUZ^ERI+',=HI7&T0CL*K=2@X5.XKLO,\nMS"SM=BM]5I*D;;KK9)52EVNMN%\\$!.`2I62B.CK,YE:3;K=+N]5`1!@=JS(V\nM6AF$-]YIO(P%UU%,5,O$X10+]YUF8?$,W[_G*/T@(#.@R[;AWOU`>)Z'`%HK\nMK!7$6*P8Q%A$TLA61L<0@:#?IY`OH!V-ZS@88^8\\U^6VM_QE"D!KA3'V$M?1\nM7JF89ZVV0;_?)PCZ:.TP.CI.J9!+&[+8[%`'($D2OGWW<8X?.\\X]1TYPY,@)\nMHCC>,=+U/#S/'=RWWW/Q/`_'=5(`VT8;008@C#7D3C'OT>J$>US7P75=.MT>8=@G21)PP(D3BQP[L4@<)SBN^P!/>]X@"N[]H^"3S^5PM,:(0:S%B$4,\nM@`4+KNOB^3YQ'*.4H)3"<30BDM=:*Q%)'"5"HQEHQU$CCN,@(H113!+'6&MQ\nM/8],)D.2)$3Q]I"2GGZOP^F3BRPLG.+8B9/$\\:"5=ET\\WWN`UW+$4`,8A1&IWFQ762U4FBE44H2:U/J*U&"TB*B5$8I-6B^3-JG\nM2CI):<IZ'UGK@?5"B&I&)$A'!44JPB!61**6%18G@:`<1\nMM%M99N/QA0R-#M!01AC$4H%O.X\nMGHMV4A'(9K,IE=P'4LB*8JO13A5E8&1*']D!DDR:1R`^!N-7NDLOZ9'-Y"L42B4DX?[X.0!"$Q'%"\nM&$8$880,*%*G'UY0=XSJU/X'G/?"*E8N$A\\R$((OK](/6X'EPJ-;B0\nMSY+QO'3UDL2<75UA?'P"W_,I%'*$00AP4D2.BSRHD(EPCXC4MYJMR9G)*AG?\nM8VQLG/7U.N?65@GZ?3S7H1^&:1LQ^%Z4)-SXZ"LY<&">H:%A\\ODLU9$<]QY?\nM8FEU8T"E"\\5,.PZ]?D0^EQTHC,%:(9OQJ0P76:MMHI6B7J_3;K>YXK(KR&9\\\nMLK[/6FT=@;LV-C?KE9$1=EH)$<'"*:7D>YU.#VLAD_&9F)@DE\\NSM;7)ZNI*\nM*K%AO)/HHH3EM0:;7>C&+B=7&RPN;P#"%9?,I?QW75S7';3)&68F1A@?35MD\nMI11*A%S&9_=4E2B*":,88PQ'CQYE;'2,;2_=-<=_E>IB1H2*W\nM/ODPO_S$0SSV\\*7LFADG3!2=?KKL^\nMP_S<')5*A;'*<"K;K4XD(G>XKK,E]]NE[$QD/_?X7Z*0SS?B)!FRUOZ"XVBR\nM&1]1&JTUYVKGV-C<8*@\\1*52V>E-MDN\\4K)3D&)CZ?9C@@2Z@:75BPGBM`71\nM*O7ZGIEQIJH5FITNBZ=7Z?5#.MTN__[%+Z*UYNJKKF9XJ,34^"@K:W6:[>[G\nM!=XJ(OW??_EO[`#8KAK\\Z>M?01`$B,C'1.2[S58'$<%U'?;,[F7OGCG"(.`;\nMW_@:2TM+;*O`0QUC+!O-/IO-/KT@];CG.)2*.68FQMB[:X)2(<_9VCH+IU;H\nM!2&M=HO/?^$+=+M='G7=(PJE%`NGEI,@"-^1Q.9C2BG[RI<\\\\[\\&\\*4[/\\--MSP5K%U06HUB[:-`Q'4=\nMM.,P,3Y.'$?4ZG66EI?H]7L,E8?(Y;)HK78VSC(H2K[GXOMNV@)82Z?;H[[9\nMX/Q&DVZOS]96@^]\\[S_X\\EU?I3(\\S`V'#S-:&69N=IILQN?HPFE:G>['@3/N??Q@+XUJI#VNMG^*Y+MI1*%%8:U@\\N.G>">(T>PQG+Y99KX<%7,=E>[ZP`-;B^SZCE1'V[-[-S,PTI4*1-_'D)2_8UJIURBM7JJU\nM*KN.@^>Z*>\\'7:0UAB`,:+?;=#H=@C`$TD$DX_N42B7*I=)@3/0H%_,[B^"U\nMVCH+)Y?9V&H=-R9YN[7V$X@$+WK64_X[\\WX\\@.WSK@_\\'=985SOZ%J74J[52\nM-SJ.]CPW74BYCA[,"3+X^TAV"IRH"[-L-N-3+N89&2KAN0X;6RU.KZRQL=FH\nMQW'R#Q;>>^S$VK$#\\^.\\\\%E/?CBF/?P_^=[U@4_BNY!8.ZR4>JI6ZKE*J4=K\nMK8NNZY#Q/3*^EZY/7!?7<7`OH%*3K(`C](*31;+/5;)MNK[^4&///P!W6\nMF+L1B9[_C"<]7)-^,@#;YST?^02^]DE,4E1*KE%*/5$I=;U2LD\\I->9H[3N.\nMQG$$S;K;5[VXE]Y\n>)";\\[/SL/-+SGVP_9I&"BT+8`````$E%3D2N0F""\n`\nend\n 6576 coin_clock_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```46$E$051H@>V::8QDUW7??^?>M]1>7=7[/CMGAK.0,]PI\nMBQ07GJ9GMZ[JFM_V[WY4#U#4F1B.W*4+SG`PT,]/+Q[\nM_N?\\[]ENP?^7_[!U`B#(,!1P!)D6D!_"O`Q`A!-D"KHIP`>2D\nMP*L6.R\\0_N??_V<_/@#;BJ=%Y'9K[2>`AY12.WW/]5(IGY3OX3H."!AC,<80\nMQ3%1%!/%,4EL,-;&8)>`5X&O`<_N&RNO79C?X+_\\_I?_[P!X[#./8ZUUE%)W\nM6FM_641^,I-.%?M[2_3WE4BG?.(XH=7NT.X$A%%$$B<8:S'6@K58:TF,(8IB\nMXC@A21*LM9&%-X&O"#PI2#4V,?_I*W\\QD+\\4@(]]^E=P78TQ=ASXAPB?RF>S\nM?;LF1QD9ZB.*$U;7-EG?K-)J=8CB:%LQY(@C)B^\nMLL#J^B:M5HM6LTZS4:/=;A`&'9(DOK&,U@Z^[Y/.Y,@72N1R!5S/1X2N\\L9B\nMN7&_BN77$/XC$/_1;W_Q_PS`)_[>Y[$65RGY>2Q/])9[!F^_Y2#%8IZIZ5FN\nMS%]C:ZM"96.5ZN8:[7:3)$G06N-Y*3S?1VL-@+66*`H)PQ!K#'XJ1:D\\0/_`\nM,-E8G5MC?75:ZRN+!)T6BBE*11+]`T,4RH/D,WE<;VW`6`M29(0!&VJ\nME0W65JY1V5S%6A@8'&%D=`>I=`9K#$HIDB0A3DP3[#].++^K!//5W_JUOQR`\nMO_G9+V!,+$JYGT7XEWMW3>0^<.K,6ZRN+K&X,$.]5D4I1;EOD/')\nM/0P,CE`H%BCF<^2S:7S?18#$6-J=@$:S3;/5V=Z\\,;6M"@MSEUF\\.HOK>NS:\nMO9]2N1\\$4KY'NQ,01?&FM?R"$GDRMH:O_JM??9>NSOM97I1"B?<@\\,5=DR.Y\nM^^X^QN79JYQ\\\\SS7%N=87)@A"@/RA2([=A]@?'(78R-#[)X89GQD@$(^B^MT\nM+6^,P1A+%,>T.P$;E1J+R^LLK6[B>1[EWG[&)G9RX=R;3+WU`_;L/R#`R-T&HV6)B?(9O-DOO_+L^P/XV5_\\5>(X$:75XRG?^UL?NOJ/&XM59RKU].(Y+.NWC.`YA&.Y1(J=%R:7;[WV8\nMD]L@WD4AI12N)[<`G]ZW>Y+AP3Z>__/765Y:8O'J%:PQC$WNYI9C=W'7\\4,<\nMWK\\31VO",,9B$2R;FQL$G8#$&*P%I!M"/<_KADW5C?V),1ACZ"GDV+MKC.G9\nM1902CMYZ.Z^^\\@*S,Q>Y^?`Q6NT.Y9X"G4Z0#Z/X%ZWE!:5HOL<#G_H'OTX4\nMQJ(=_?E<-O/P??<P?N9M#X@2_+2[\nM&\\O/[)H<)9/VN3@]Q]KJ$K5:%<_SV7?@"(<.[&7_G@GB;5YW8[;!6D5B#$$0\nMTFJW,8G9?L<0AA'U1I-*M4:SV48Y#B-C8Y3+O3B.QO=LV/O\nMSG&N+JVQOK')VNHUK+4,#H^Q9\\\\>]N^=Z%H^BJ^G?ZRQQ''"A:D95E8W",.(\nMQ"2$4<3R\\AI79A?8J&QAC,7S?7S?I]6)V+U7H[1&$#S7P?==?,\\EBH6]^PZP\nM_-(BU>H&_N`(6,AETVS5FQ_42@T#BS<`B("UUA>11POYG!0+.=Z:GJ5:W:#5\nM:N"Z'I,[]K!K?M-;>?!V``E"BT$J/B.[%5YBZ-(.UX*=2^+Z'YW4OW^M&ECB.T4KC\nM:(5V%%JI[8)/X;HN8V.3-!KU[EI)TBW372>ME#JLM>(='A"`@TK)T$!?B4JU\nM1JO5HE'?0D3HZQ^@OZ]WV[WQC<++6'`=Q=!`D3@<8?KR'-,S\\YPY^Q:=(""U\nM39?KBGOO`.%Y'@)HK;!6$&.Q8A!C$>EZMK>O'Q$(.AURV1S:T;B.@S%FE^\nM?_,B%Z4=#T/SW.W[]>?N7B>A^,Z70#7E3:";(,PUI#-\nM9/#]%&'804302N&Z#E$<]P=1I)52B?/9SWV9?-:CW@QWN*Z#Z[HT6VW"L$.2\nM)+BN1Z%01&M%'"<8NQW?M\\N$M;4U+D]/<^G2#%.79HCC!,=UWV5IS]OV@OM.\nM+_AD,QFT4EBQ7:7%@%&`!0.NZ^+Y/G$9>K2%>)XNY1V\nM73S?>Y?5;U#([3[OZ2E0*A?Q7`>GN+B&R[W//P?/^'Z.+ANA[97(:]>W8R/CI,H]'@]9-O,'5IAJ7-\nM&NTH`00MED+*9;B_Q/CX&(#I<149(0!!&>VYTV-)HQ:QM;]/?XY#)I',=]M\\5_\nM2/E"(<_1PP?H+1?Y_IMG>.Z5DUQN**1OG-+$3>1R&>(H(@&6FPWFUA;Y_LQ)\nM=@T4V'_37E+I-*U6:[NJE6EKX8G/_WT%C/S6!M78^,99.$.)['IE,%L_S\nMB**(5K..M8.T.@%*"8@0!&&7IPCY?!;7<]%.-PBDT^GN1G:[$2>;RW+HYGWT\nM%/,\\_?1S?/O4-/'X$1[Y\\#$>.#1.?66!6FV+R"KJ]0;%G<>YLEYG:G:12^=>\nM9_V[KW/TT'YRN1R)H:Z4.GNC`/V=W_@51$!$+@!QO=$BD_9)9[+D\\@42D["^\nMO@9`$(0W-ED01L@VY0KY+*6>`K<>WL?//O:3?.H3CU#(YW`]#]_WV;M[!WWE\nM$L\\__R)?/W6%PFT/\\X6?>Y1/?6`/.5_3BA(J6W6:[39H1L_])Q`1JT0>4TKRO:4B]4:+(`C8\nMV%C#&LODY$Y*#`V%"9HT<.R<'[3G2S>3I-=7Z&E+(D21+^X,RI)V]T9#_QX(?)9;-;<9+T6&L?\nMV_4)M=3O%+=WUHK8F-I=6(:K9#UC2K?\nM>?T,T?!-W'%@'"T0&TN^W$>KU63ZM1>IU.KXY7ZR:8]H:YWY5[X%49M]]SW*\nMR-[]N%H0+*[GTUBYANHTB),D#L/@O]\\`\\/+SW^#>^T^`R!6EU/UQ'`]G,VF,\nMM13R!<(P8&-]C?7U-4JE,J52"27R+@#7[R)"$"8T6VTJFQ7>.#^--W83?4F%\nMVL8*J4(9[?F,WW0S2:;`:T\\_Q:67OLGFI3/,??\\DNXX>X_`#'Z94+N$Z"A.T\nM6)OZ/NE\\@:!>P]8JQ%$<@OQ7Q3M%!,]UKHK(;QIKF[5&"]]S<5V7PX>/,CX^\nM2:U>Y\\677N#BQ2F,M;Q]?O$.L;8[\\S2&,(JPMEO+M)H--A9G:0<=PL00)8;R\nM[L-\\\\.?_$>U.P*O??(IC#YW@SD=^FE(Q2R[MD$^[]!3S>-JBXP[IE(_K.B1)\nM(G&T]$842M5F=J>I:X;Y+Q@1Y\\SR/=-X(5H1D96E%,L=3#\nM_F.WP0+O3P?>Z\nMK:+C.%TJB2((0QK-)O-S\\VRY189V[";7.TADH1[$-*($S]6D/$W?T""3/2GR\nMM6OXNP^1]9PN`"VXOD]Q<`3EI5B=>@L=ARPOKTW5MBI_\\!X```^<^!D"D$XG(`XC\nM:M4J2Y46C<(P]3"A$29$!CRG:^64ITFY&K=8)G_U+/[X'K*%/)F4T^T7`*TT\nMM?5-JES#64MVJ,K^PP,7IRUQX:XKIF1D*^3RY;);%V1F2\\B@Z\nME<%1H%N;I-,I_)2'[SKXKL;/Y?";&Z3B-O[H3I)V$T2A14ABP\\R9<_AAF_GY\nMJ^'2\\O*_V'?P^/GW!0#P_+>>XN%'/XKJ@GA6=5UP2(244@I':[16I#,9!@<'\nMV;5C![MW[6)R8H+1X6$&!P88Z.\\GE\\WB>R[MK2K5RA:IX4F(Y&DA!)0OQ\\$7WA.ZB=AVBTVK0J%?+Y`@MSBU0N3^.*X8W39[Y7K5;^N4FB\nMUO\\2`,"SWWR*9[[Q)"<^\\EC+6ON"4NI-$1D!1@&ME,)UG&X#XKJD_!3%8I'^\nMOGZ&AX<8'1ZFV%.DV6SA.)JM:W-$!K+#$Z2+)1RM<;3@*%@Y]P;$(?F)W3!]\nM&E&:OAW[R*?37%W>8.[-'S#2D^,[KYYLSLTM_)-BL71R763A[\nM@1U]!4Z?/F.^=_+4[]6V*K\\;QV'R@S=>_*L?L_[KK_XQOO9)3))72HXII1Y1\nM2MVME.Q12O4[6ON.HW$I5*J_\nM;*T]%`0AB2B\\8B^9WCZRQ6)W<*4$%8?X)B;O*L*@S;2T3(N2,M21Q'`5!N-9JM:QD1W7&?[7=NG7O[>ZWS/+>C&>QQPO&\nMF,48L1I$6!P,.*QRA&2R*'\\DY(\\D(H1(*$@018I(%(B0B!0I1`I1(@))P!!0\nMG&0,=L#$NSUX83S>9][SF[?V>O>J_-%O!HLQC!7LD5+2E5JEKE9]]YSO?-\\Y\nM#?_/EW@N7_K01S[-QD9?G+=W9R)%Z-5UW6O;UGKO!0$"(4@A"Z5U7VO3;UJ1\nM2TGXXF?_\\(6^_T\\'\\/I?_#`K3Z_(-[[I]1?TNMF;\\GSRFO%X?'%5E0L@>DK)\nM2$HI`$(@A!!*A.@;;99B%S^4)NGW`]R\\M'3RJ31UX8M_^.C@>;_M??/^$\\>/'ZBJ4AXZ=#X777"0F5Z7.+;4=HP''GB(QYXX3EY4Q"YA87&1W8L+\nMS,WOH*IK-C)[-L[HK!***]@Q/T]_,**<#/G6OQ_FOON/DG4R9N?FZ?0BTC2AFR5(*9%2\nMLKAKGO%P@!2P8[9WU>;FYB$1U`L/X)[;ODM9%"[60;WT92]C_[[]W'''G0@A\nMV+5CGLA(7OG*RUG8L\\CY!\\\\CSTL0BL7%W72Z'6P44545/SKV.#.]#A=>L)^[\nM[KQ+'#Y\\6%H;/=_W/Q-`?W,=0-[ZWS>QN;'&)9>^&.\\#]]__`(\\ECFZOQX[Y\nM60X>.D0<6^;F(Z22:*7))Q-65]>8Y`5:"7;MF./FFV_AWGN/$#!4U7,J>C\\?\nM`(`0?"`$CC[X(,>??(I="PLL+.ZAJ7O457F;IQ!*;FUM8ZQB/1G@A7W@`35T#06`A[7000K&VNL[FY@#G$K).1I9E\nM)&F*PV!K0%E4I)T.G4X78PQQ$N-<3&0CE-$@!77;,)[D5$U#\nM7=549840"FL3JG*%S?63B',2`1MO?PJ$T!*[#EI'-%7+>#3!MX&F::CKAJ1I\nM\\6U`(#':$!E#EJ3443U]$7W/9#)$2,7LC@7$"Q"",UY)VS8T31V4-A`$95'@\nM?4MD#4GB<(DC=FX[[RV1-6BCD5+0M"WC/*<_'#$:CZFJFCA.L39F,NZ33P;/\nM.X`S(N"]!X((;8OMQ&AM:7T@GQ2$`"$$$.*T8`DI$5(AE4)K@]$&E4B:LD-;\nMU^3C$64Q1@@)XAR4T)(TP1B+\nMD(JF;BF+$B$D0@@D4Q]$%-!2XFQ,FB94V_7?^X;Q>(!4AKGYQ=,DOOY7?@-C\nM(O;N/V`GD[$MRZHMB[+\\ZR_\\1;-CQR[6UU>?,X`S8KKGP$6$$'XICM.O1#8V\nMQEA^\\[KJ/__MR\\\\]`B[IT#3UI<9$'W0N4P%!T[1X[Q%"HK3"\nM:(TV&J440@J04T4.(2"DQ/M`4S=X[VF:FLWUU>J:=[Q]SWI_^)[#]ST^OOJ=\nM5Y=77'9QYN+(;HUR-2I*$3NG.C,SPV#TH]3-?!R9MTDA']JY:^$!;2S+)QY_\nM;A&(70I3G26$ED[6PT3QU+!)M6VG6YJZQ1N/0*"EPD8169+@$D=5U8RUHFDJ\nMRJK@Q2^YO+-K]\\+;_NGP[>K=UU[3O6CO_,SZ8$SI):V*]NU96$#2!MJF#2$4\nM35%0KZZDW:KZW5%>W/[TD>\\__IY?^QA?^]L_.WL$DJQ+T]0OTB;ZH)!:U4V#\nM`*RU)&E"FJ6D24*2.IR+L;'%1!%:*SS0M"V3?,+&QB9*:7;LV,G!@_O$N"CE\nMINQP[9NN%+4/:&,8URU98IGK).R<[8F=<[,RTXD-\nML]V4Q5T[F.]ES,]TZ=J(IYM*#L?Y2^=FNY\\W1O=#"%\\[:PH)*2&$H+2AKFJT\nMKDBSF"1)L;&;DC;>)G(\\);&U$=9&Z&T_-!P-J:L2@*+(B2)+,1PC@V!2UHPF\nM.?W!$*,4Q)8DL?0Z&3.=!<UD8X">7&#'7KF9^;Z:RMKKYH_X ^=`5180\nM@E#:8&U,"(+)9$+3M"2MGT9):TS;;+>6-5(I@A#X`$(IFKKAGCMN)8[>P)6O\nM>C52*A*C6'KZ)(/\\($H;9N?F<-T.;5-C\\,SW,F921V04<6386-T@C@Q[%G;Q\nMT`/W<_B_#K-S]\\ZS`W@FB=NVIMOI8*U#2HTV!H'`MYZV]00_]3=::9RU4VXX\nM1YF/65M=X89__2J77G8YO4[*WEUSW'''PSQ\\R07L[CF\\]PPG%2&T=)UA4M94\nM98E1@KENQF0\\YLFG3O#D\\>,L+Z_@,6)U]O"P9C$<,1^/I;U45]]U[#S=\\_09&HQ$7\nM]C2WWG8WRYLCEM:W>&)EG9/K?997MSBQNL'&,">*8AY^Y#@K)T[PY/%E?)CR\nML*DG(4GB,P"<$0&M#8#POB6*(ER2`I(BKPA^1%.WU%4S+:5-.R4Q`JDTL56D\nM+J'.2@@!:R.2I$OP\\/U;;^.-5[V.K0\nM?Y3^\\@F6EY:8FY]G/!YR\\H^)PFQCV9BF*@F.//,;++S[`(T\\N$^R[0^;ND*(J8KW^WWRHJ0H2E96\nM3G+@P'XN6[2,QD/*]0T*'R@):*T10N"RE'8X1`NPUE&7*XR&F^'9QC(_A<13\nM%C=-36^F@XT3E-)H;9AR8SIZQ(-\\QFAQ*G`)53'!1):B'*"4)'8.K2.$D(S'\nM.8\\]_A3=;I+"T.?(U_^96Y@!Z>C-[A1:GSF+\nM/H/$=552E7G0Q@""X6#`:#B@;9MM8;,DJ9O.0=W4P"FM"`2*JF0X&C,8C6C;\nM%JTCZKJFR'.\\;U!:$MF(R!J$A-9[D`(=68R-:-J645X0%P,N?N)V7L4&;YB+\nMR'S%>#((`7_V"$@I"4%(W[8BG9FVDMY#65:$,*9M/'7=/H/$GH!`2D4465SL\nMZ*090H!2DC3K(*7&MU#D)0+)U(;+J3E4"J4TQAATK,B[AP^4%>\nMEG0Y8698*PJA1X^>'8`V$80P#(%B.-C*Z$*W-TN:=K!Q?+H?CN-3)(ZG)':.\nM.(X0(E`W-5(JZJJ@R"=DW1YIFA$[MVW)+3;^\\;G31<`80O",=$KW=1=6->77ZOF>8N=GYW800GE9:;REE+O">V;*L\nM9%E6M&W#M&1N]\\1"`()`H/6>IO4@)/EDPOWWW854&J7-=NFM:5M_>BRIM$:J\nM:6N*F-IQOVW'E92,HXPU(@XN_Y#9LQ6U'-$L2E%*41`K/O\\''[_CZI>\\Z,F;GCB!?[84`GCX@=MA6HF>O/+U\nMU_Q]\\/X?$6(66!1"[)5"[!)"9*?:22&$!P8!G@XA+*VL+&_F>?YQI-.N0=2RQL[CD5,K9TU..0*"LJM,SIDF>TWBX=_]KVCV#Y=&KG[J_>\\F+\nM9O=M7G+H3[_Q[9L^]&X7/?$O>?7L`)ZY[OC>MP!:8&W[.7*V,Q=>^DJ`3P@I\nMOB.$O`[$J\\NRV@?CJ#W5$#7MC^VX$"BEB2*!BV.44J&IJHUBG!\\9NNXW'A*=\nM(Q<5QS_;?>3.RU2T[W47[]OYL;]Z:O5W7J=HSPK@_[*./7@G0/[2*W_AAM:W\nMWT*P1PCQZ2072FE5$JAIT^NE%J50CPAA'A(2GF/TNKH#P9Z\nM].GF4?ZG$'_4ZR5_2),.E\nM"8F+Z]BYZIO_\\+GVO1_^.!_]K>M.G_O4A5W&09JKNO(M^]OBR8_>-WGP?9;P\n=D?)9!<1WW'/]WOFG-G=_;P'EII=R6M)$N6\nM)9^R;"1\\88BAL(,+2$BX*N`D90A00`(A4!"@@!1.4:2H%!0$2(!PA3@0;(.-\nMC8U!MK$D2Y:L8W7L:G?VFMFY9]Z;][H[?^Q*%I"UD<"0=%77S-2;U_W]O._O\nMU\\=K^']>Q//=06S[.PE:D;CDNBO2+6/T_O_>4Y-][>C[W_=;:=_ZK;2R3!EZ\nMZQ>9_^:[L'NZ_O#J]?W_U-N1>E5ZS:JI5UR1/3Y[^=^P\\*-__HW[>%X=N/[#\nM_XF49&_>,O2]8JWYDTG?RZA89E6VJ^-6J<*FN>_3U*I5,;KAPMBFBR[VI+28\nM&#^I]NW=W<%7-@UG\nM.^N-QHZ[=QV][6VC?B.12+[0=ISM&+-&6G9&*25\\WP\\"WY]J^OZ>>KW^0'YN\nM=N_`X*KF&U]SZ^\\(X`\\^1L_*;LKU(+MEJ.M-5X_V_?ETTUJU8F6?6=63%'N/\nMS)HA+QS;N<(1*HI&2J6RM5`H4*W549%"2D$\\D2"12("@Y#?]^ZN5RJ<./7W@\nMI^T='>H3'_[%W#EG@(^^#HRAS1+RUH/G>5**"$F(),(FX(0:,3_)OG_3\nM]DT;=G:DD_;NR3HG:Y*A;)P;!P0KXB''CH[Q^.Y]C.4*E"-))!VDE%A&$=,!\nM77&+X<%>5JU:B6U;<]5J]1]FIG.?B<<3C8]\\X%WG#_#QUPNT,K?TC6SY][ZA\nM+5ZM<`SEES!1'5251DMQMW@#]O"MA#+.?&"#$V-MA\\TM*T.LQ@(_^.&#/')X\nMBGK[*E:N74M?-DW2LV@T&D18^,9B-C=%,'&8SJC$Y@UKZ>SJ;#7J]3NG)D]]\nM*!Z/-^_\\V/N!\\QB%;K[<00ASU>J+7_**5FV&)FFR%[^!U.`+2*^ZGF.)&WG4\nMO(`HEL6*M]'7F69]E\\V+>GVHS/&U;WV7AZ=#!J^\\GK^\\[5I>L^-"ND6-9%1E\nM95<;;5&)RR[>Q,!`+U;/$/G(YM333^$);:73ZZUBW[?5T)T$(F'^JP.C!`MFD34=?!.OWS&*%'!JH]/IS`^V[[SQW`%L"PP@3(0E%$9H'&&(VXO1^*(U\nM";;U"8PQ@&&A6*58JO+`([MX;-KGHNM>RLT;NY@OEM&6AS8&+Y4AVV\\1*45+\nMNN3K`:$R1"V?6%AG9.T(QUL-CNY_A`UKG4XIK7><.'YTU^BZ395S!Y!+`$1(\nMH3#R%Z^W)>.T)>,`**4I+E28SLWPR-XC)-9>S[IVQ.+)':[G?4_^\nMJL3G=L"6($R(1"&?91BHU1LLE,HN%F!;DE3"(^E`?>)I2Z.@FC!167Q^E]DY:K19:\nMFZTOO?5/V\\\\]B:5!LI@#$HTYRX'Q\\7'","23R3`[.XMP$E2K-0K5!FUKNG!,\nM2*6JL&-Q1C9?AAU/\\-0#WR78]R2]E^ZDL[N;_-1)"F/[&=YR!1LNO@++<6CY\nM`;I1)Y5,D.[NP^#@X,\\>>`(S4:#(#)X\nMGDONZ#ZD5JS8=!F.YS&X;A-.QP4\\\\!__QMW_^#Z2B3@K-F[AIM>^F;ZAU0@!\nMQAB:D<_T\\:?(#*TGV=9&L&!A6F'<]>+Q\\P+$XQX.$3'7P;@.U6I-^\\VF/G<`(1;CWD1(U.)<+D`I13Z?QQA#N5PF\nM%HLM);C`LZ#1"A"I'K*9#,IRT9&B%BHB(!6/<>L=?TW;UD':,Q:N8^'9%I:4\nM:&-0?HUL=S?QKB[R8\\?P7)>@%51+I87J.0-("<8L.@"+3]<8@^.Z;-RX$8#>\nMWEX`U/@DMFV127@42WD*8C4=,8=&-2#"("Q).NY@24@DDZ2V[B"9.X2]\\5+B\nMGH-M29366)U9XND,Q6(5X3>Q;1N_&4SZC4;AW(=1J;&E-I8(L<2B`\\:`4A'3\nMT],4BT6.'CU*N52B7%S`&,,%75G(G^+X;(DC/S*=>6`;JN,`^C%21>E%$((;-L&((K`0]87(:(6(+P@A%BQ_?!^YXXRO)%\\NKPZ!^9U]/]MK-F]:G\nMYF;GQ7RAA)=Z.6-1R%CM..OUA8QHA64[K%BQ`H#V]G8`,ID,RDC&3TTS/-##\nMT\\?VH+MZ$*[!3G6@I8O6H(V@,C]'5);$^T?Q?_H-1&$;QHVC:A4\\)\\:I(\\=(\nMJ!;56IVIZ>E[:M728U$87WXUNF9T([,S4R^Q;>L]_0/]7D]WES@Y?@K/BS$\\\nMM)+!%?TTHQB5,,7HFF&2CF9BXA1!$#`V-H9E68R-C9%.)`9&?FV=\\?)+>WAXR[6T$K0#?\nM]YF;G:'B&[2^`=MR:6]OQ_,\\;-LFE4HQ,#!`,IGDAA=NQP]"_*:/R$U3?_(A\nMO(NN)+UB@*3KD+"AF4I!O4J/(^B\\ZD9,?HJ90ID31XX3Y><8[&[G.W?=71X?\nMGWC_[I_>\\_C&K2\\`GF4_D.GH1BN]!2%O,4C",*(51H2APB")M&$Z-TVD)5==\nM=05=;1Y""!J-!JE4BGJ]?F9.B,=B=&4SG!B?0"F-].LT9R8(&@V,L/`\\C[9L\nM)^W=/5BVRUQ3VE4"B0\nM3":Q).S1XYV\\*3D'0L;`&')B?9\nMO7?_P5QNYN_JM>)=\\61*'=CST!F=RP(((1$H$`+#XEAOC,%@P!@,+$UBX@Q`\nM3T\\//3T]`'1W=P//S`D`0T-#7+1Y"T-#PSSTDUV,3TS@URI$S3I1R2%P;6S;\nM)5+0;)0H%&9FIW+E?ZTW:I^]<,LU1Y]\\]#[.%O_L`%(@E$!:$LNRD%(BA5S\\\nME!+;DMB61:A!GR98SDU`:4,8&;2PV+QE,RM'5G/\\Q`1C8\\?)34]3J]99J$>T\nMJD?9V/\\$ZS<5Z$S5OWWM;>]Y]YH+OV6^^?F__U_;7A9`:XTQYDSX++JRM*99\nMNAXIA3(VSR;?&(B4H:4T860((TU+&:3M,;1Z+?U#:PA:$4%+\\?/)B/+XIWGE\nMAL_3TPY10%`\\\\"[3L7'Y]I<%D%*B8?'I+X6)-N8,&`BDE`C]3`C]WBV=]#R-#9`0:B38"'8&*!$JQM-I=_A$]JP-::\\(P0FE]YNF?\nM=L`8C8HB0BT79^*SBC$0Z;-$1TM"E\\2>+3Q49NF_AE:D"((0K<"$GPF?)8C3OR-EJ`6:4CT@;+4H\nM+C1HU:OHB&<@SAM`+$(((;#D8B(_D\\P"N>3&Z1%*A1&-9H`1%EI*E!:$2XG;\nM.BU^*?Y/@T3*4*SY:!52#PT5/R*LU!8!EB">B^!9-D[13]J1%&VC82=^*X;AS+B8&TB!"$FE\\)G4:C22@[$FMI.+6EC92"0-8I9V:83Y_BV[FC\nMQ-,9>C,7D4J/,!WO)@SR3)_<15`-B)D^8DX7MIM!.'&,Y1(::#::Y*8+3!:;\nME,I5+MFZE57^XZ@69UP0Y^N`-AJCC3!G`EP0VDWF$N.<=)ZDX=:0:]L9;KN!\nMWO16.A/#.*XDD#GV!=_GU.S/*38GT6A2R6ZHML%<)U8MCNN#5(+0K].LY8E4\nMBXO7KF.MW9DWC`(.Q/%%80X4U5*!18:2,YMASO3Y?/HF%\nMC9'J!UJ9-P=!Z\\8H#->'IK4:24.459ENT\\6%J8V<*D]P@7,!'9DL81!R8N8D,_.S.*KP]:O:GKZ_\nMI2VIE<$HA%$4C>'>Y]"_/,"Q0T\\`5*[<^?(OAV'T%;>12DYVC7W0LJRW57W#\nM3#FD'$`JV881/O5&C1/C)YB>R6$D^"T?ZN`U/1:B(KOD+D9'1KGRTC@J5)3*\nM)1:*16K5*C]LQ!YYL'CYYQ[[B\\>?2^^O#W"Z//KCNP#4@;=X%:74)V.NMT>)\nMS(USU=;5%=^L3*MNU@VS:V;>/8-K;M+"U'%$[*971HE/YL'[[O4R@N\nM4*U6J=:J5&L54V\\T6I9U?@>FO_9KE>#3`<#DM5\\Y^F407RTWQ^]A":6%7/!93A]]]Y'Z[W.\nM=9P7&F/26FM2R11A%%*I5JC6:A.U>NV3M7KM2YX7*T_EQCGVWI/GW?=O]9CU\nMCL?O6-RU:1UW76^'8]NWU^OU%TU.32:%)97C./7)J\\N?U1OU3KNL6#QXYP+ZW[G^^NO[M\nME6^;;\\)6^,3TQ^/OV/MV^VU[_NKW+>G_7OD?%$V@`````245.1*Y"\n"8(*;\n`\nend\n 6579 collection_account_write_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```.%$E$051H@=69>9!HPHY=Q,$I)Q5LXI2K8@J3V"EC%TE!01RG<"K&E.,*\nM)$$*1B1<$4+".CAD';O2GC,[.SLS;V9GYKWNSA\\SNQ*'D%E$G'35JWFSV]/]\nM^_3W]_OUK]^#_^=-O-\\31"[[,M5:*"[<=G&B9HP^\\/@^7_8THY^\\\\YR,;YV3\nM4<[0!K[X?3*/_#%V9_O'+E^SY'O=+?&;$T/+QCY^<>NQJ8O^E)F?_>U[GN-]\nM5>":O_AGI*3UPQ<,/);SYYX9K7@I%4DM:VUO^:A4P=Q?;>]ZSW/(G5O4_^^_8>6_>6UHZR_Z_FS#I,`]FQ=\nMPUT]JJK1<,M-]Z^:J>WY^8LY;U\nM+^TQ`UTQ\\9\\'TV9X1K_6DDK>D9AWOXD@NH557ON@TK[NX=\nM__E:F1[^NY[]YKX'^C&WGEP$P%V?`6-(6D)^(A9/K/4\\3TH1(@F0A-A4.:X&\nMS3.M7UM_V?JU6UH2,7OO:(D17V)%8DC+(1YQB$>L:CN3.U?L_NVC`^YA85D2\nM`Q@#1F,TC*FB^,>;T@]UW=SQ^!VW3$U\\;-W^YX0PZO[;)_G\\30GT)T?`?K<`\nMEA!H;;9U+]]P;\\_`!9Z?/8JJS&+"$J@BY5J4`\\Z-M'4-_2M*>PQB!`;0V&&W,D;5=6R_8`10"XCHV284O/P$:OYD]0LUII^\\`M6$)C\nM"<.>21A-KR$N6FF*1%G>YM+<9)&*6#1Y$L^6N*X@XD@BKH7;_DET*H;E:6K&\nM0HWOP!O[$9-M"3%]Q>H/;8X]P]"Q(XP-]YL?9GZW-K3IZEO;]KUR9&6*V==W\nM?V$1"E@&"4:8`%6=)=J]C=6;?X^.&`@!F8-95KV2I35FTQ(5I"**9,20\\#2N\nM!0B0LGY9@&U!=&@;YPT,<'@:CL]DJ,D?L;._A:*JDA^=YW$*V!880)@02RB,T#C"$+7KX73=4!.;>P3&&#`&0^/3&.J_\nMI.[H"W_7Q!))DA&)+0*$UCPGX+'\\-/)`GC7>!LI>M?#(8U-/RQ,71V?4B3MB\nM2U;/[MWYXT4"R`8`(5(HS)L2<3(6)1F+OMMA&UR&7*6979E/,>N_3H<]0UMO\nM>_''AT9V''OY>C\\^4[@WTWG^(7O7EX#G%@FPH$"`1&'.82*NEJL\\.G411Y=M\nM9].K+S.]_]G24RO8G2]=.6%JY;\\NKA\\X+O]M!T'PW"E[%@.@Q;P"&B-/$50J\nM%;36V+9-K5;#\\SRJU2J>YU&KU;!M&V/,V_=Q/9[<-\\.3;@>=F3(#IHVDC#TF\nMX]<\\VU;<`EC1(ZC$@T6]08&1DA"`(2*523$U-\nMT=?7QXD3)^CKZR.=3I-,)@F"X"U]QD9/`!3!]"-(-9*\nMD9F>)A:+4:E4L&T;(02U6HUH-(KO^R2328K%XD(?Q[9!-/%G.]+L"6W.'\\NR\nMFF$V]OT-*Y9.HD*)L0#T&>U9U$YLI``3(E'U8D2`4HKIZ6F,,>3S>3S/0TI)\nMN5RFI:6%3":#;=NDTVDZ.CHH%`HXEL,_O)3GD9)-^W"637*.A/,T:P<.(!R)\nM%"#.4O"_:P`IZVE]=&YO;U_H\\\\BN*;X]\nM/@*Y#L=5@ZF,+V#-(!A$!8YMP"V%)CC#:6"$`HM*@#*1623F>(1"),\nM3T_3T=%!-ILEF4Q2J5000N"Z+K[OT][6PK-[TWSE99M\\+F3]B0R;UML,;1FB\nM,NTA;+`<0!CD8A6(#U[%U[_\\.<:GIA/9;&:#-GHHZGG)GQ0MTRM>O&1UODJ'\nME<X+9;?HOI7'Y%4"U]NZ>S=>N&]6OBZ:F,R&1G\\>(W\nM`\\Q,#DZ0JE4CO;W=PO,BS,SFB40B#"SM\nM)19KXOAPG+'9&&$84JMIQL;&B4:C3$Y.TMO;R_CX.%U=7>1R.:+1*!AX\\&OF$YG\nM&!D9I;N[DU1SDFJM2J52(3TU2:%BT/I:;,NEN;D9S_.P;9MX/$Y?7Q_1:!3/\nM\\W!=F]T'LMR?=J`\\Q];0YXIU4:Z_80U&6E0#707L;$QNKN[R6:SQ&(Q@C#DM4,'V6#-<<-U?0RN\nM&$1:):9G\\L13;:=NG;%C?\nMF(0^Y4)O;DK7C7NCP?5@#>?OPWD`0Z@T2H%6#>,-B+.(^XX*:*T)@A"E]<+J\nMSRM@C$:%(8&6Z#=-8@R$^C2C&QEFWEWF(>:-#Q=`-=5J@%9@YJ]WMO\\=:J'&\nM+X5HN$L0UJ^P#E3/%@(AY!L4,(8%8^93XYM7>OY[J`Q^53-;JA+4:N1FRM1*\nM173(*8A%`X@ZA!`"JU'/G`IF@6RH,9^A5!!2GJMBA(66$J4%@6ZL^+SQH3[-\nMY^L`.;^"5@&EP%"HA`0%OP[0@#@;P3O&`!@CA'Q#+IMW(R$$MK`)JA7VO[Z7\nMUTZ,,^R?9$E\\D,'D.J).%->-8CD1D!8A@D#S%MA\nM`S"-2R]V(Q.-'";EO`)U%6QI(Z6@*DOD4Y-D$B=Y=/P71!,INE/G$T\\,,A'M\nM(*A.,S'\\`M5BE8CI(>*T8[LIA!/%6"Z!@;GR'.,3649S<\\SFBURX<2/+*B^B\nM:BRHL/@@-AJCC3`+#BX([#G232,,.S^G[/K(EQRX?0\nM-@T(@7ASAOAE`1HVH[5!-?:"`]7=3!0.LWGIS0QU?!K/6H9MN=089=0\\1TI=+Z`FIR@IUPD44RSMM5G24JC\nMJB$F7B,5M5`U@U8@5",8WRV`D!()OF7)JF59GI06(-L^2;'6))6,X.+2D6EER62\\9F>&$/H$\\*HD18]6%JTETQ*EU=A*L\nM&,`5#I,3$PR5#]$?F28,?%3@HZH:%83*:(Z>[;G9F8-8V!BI=FAE/ENMUK:'\nM0;`F,+452%H*U8!L*2!32//2H7_!<0T=;9TLZ5E"2VL+Y;#$S/0,1_4Q\\BI/\nMAVGGO/@Z3N9/T.5TT9)J):@&')\\<9C(SA:.R_W1I\\M4G:]J26AF,0AA%SAB>\nM.(O]9P8X^MI+`(5+MMSX@R`('W;+\\=AH^Y&O6Y9U>[%BF,P'Y*L0CR4QHD*I\nM['-\\Y#@3D^,8"95:!4K@S7G,A#E>D"^P:G`5EVR*H@+%;'Z6F5P.OUAD9SGR\nM[*[<10_L_OR+9[/WEP>8;__]]$\\!U*$_\\`I*J6]%7&^?$JGMZ6+M\\D+%+$TD\nM4I:4'K;M8-LVMFWCV#:V[33*$843=UDUL(HEK3U4*A6RN1F*Q2)%OTC1+YA2\nMN5RSK,6],/VEGTI4OUL%&-WZ\\"]^`.*'^3FQM!SDKVAJBGS0=;RK',=9XMBV\nML.8A+'L!J*VUC:&^(?+Y//E"GJ)?H.`7\\4M^NE*M/E2M5G^Z6(#W]&QY\\_V;\nM,>`XMC7DN=Z'7-?[3==U-SJV';%/`XC'XC2G6I@MS)++S9";S06%8O$)O^3?\nM/3,[\\T(T$E&O_\\GA_WV`^?8[3WR"R8D\\+6W15M?UMGJN]QG7<:XVQB2TUL1C\nM<8(PH%`L4/3]$W[)_Y9?\\O_>\\R+YL?$1CGYE>-%SG]/7K+>]>%O]U*9UU'6]\nMJQS;_ERI5+IN=&PT)BRI',?Y][E*^<\\/OO[*WN7]`V;7IW>]YSG?MS?U=YW\\\nM!D:;J.MZVV=F9SX[.C:ZIU0N?<=UW=PKAP^Q_XL'WJ^ISUU[U#P"&^&>B6]&\nE_^CE+]FW[_O#7[5)__?:_P#II'^^>EO%T@````!)14Y$KD)@@CP"\n`\nend\n 6580 company_write_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```-84E$051H@>69:9!5D"()@3AQ3,I)P)`J5UQV7)6BRA7L4#B`RZI*,(X#%N8'MD.*\nMV&`[-DL??O>>\\[)C]O3&B&0!FNF[SG?\nM^WWO]Y[WZX;_[TM*CZ>?_6'RU,29\\,29Z?_S\\XW+W>"1KW^+8R%4N4#'/';ZKMMONU4<./#X1L3YCNNR`0"@\nM->%PF-FY)3+I148&>\\3<0OKCG_N'+]QTVVU_PN+BXH8<\\W9K8P#4EQV.LIPK\nMT][903@:WURN.E]]ZMM/?VIB?+SCB2>?PBGE-O(X8(,!#`WV885L\\OD".W;N\nM)%VH];WPRJ'[GG_EIT\\90EWSC6\\]PW?^\\YF-/')C`;0T)VF*Q1D_,PM>E=&1\nM$32V>69F\\883XV<^,["I)9;)K&SDD>\\,8/^_/LE#CQSH>?G50[NUUF8FDUG?\nMAJ9!/);DT-&3Y+-INMJ;0W#``UCO]8WHNC=)Z\nMYY'CIQ_)Y@K/*.E]Q2TMCYV=2ZO1;3O>]AGI2X00;.ILPW&J3$[/D8BF230E\nM64Y7XZ-=K_8C:;6U\\V+@=`7V\\OPC`8GYKLRN<+=R/,WSMQ:N*)WDTM\nM7_Z71[\\V]_$[/GK!,QJ-$(*N31UXKHL`ILY,L;*2I2D692F]\\CY#^W^46ES9\nM?^>==[)___[+!O".%`J%0H1MFW`XPN'#A\\EETOVIQ95/'SIRZG[E.8K$F\nM-!'2F2+%4FE7-I?[V-D31\\5O?_C#OT@`J\\%H6EJ:D_\\\nMX*7G]G_EL4]N[X]W`!K`=3VT4FBM4%)A&@;#@_UL&QTFF4Q@6#&65BK,I);^\nMU#'"[UG:`$5ZQQY8"Z"G>S.AD,7DV13#_5WT]0^9LW/S5R_GJ@^DTTO7=?=M\nM'0,(VS9>O9$-0R`,`XVFH[V5T2U#*"E9D!Z5DM?GUBJW-"62A_J&=S`[=?R\\\nM\\P#QPY<.MKSZLZ.%4KDJ[_N[NW]^`*O+,`RBT3A'CD^0C-MT=[:PG"TS,37W\nMN^%(XAI`"R,@E&6:1!)-&(:@5"KC>3[Q>(RAP3Z6TDO8X1@(HW7DBFLIE5\\!\nM8#XU2W=/']_\\C^_VA$+V[3.IQ2MG4LN?2#3%\\A>+:QT`!*I.BYZN30A@+I5B\nM?F&1YJ882LK(S-S"]F1S*THJ-.!Z'I6*A_1]?-]'2HE6&L,P4%(1LD/XTJ.:\nM3V.&;!X_\\`0OO_R*_;E_?.@C)\\>G[U+*VUVJ>*]=NWLWM5KUXHF]-(!`&D'0\nMW)Q@Z\\@`6X8'$4:$Z;DERL4LMA5T;[W\\*%7_J352*GS?)YU9P75=A"&(A&T$\nM@K!M\\3O[;N`CM]_&BR^_<>M*MO!@)KVX^_#A8X1"86P[A&%?^C>Q9\\]UH__T\\/Y[:Y[Z?%]?3U-Z>86JXV,8!EJK2\\:V+@KYOD0JA5(*\nMU_4`&!T9)!JQ02FL4!@@H!I!YH4.?I=2LIS)X7H^@>P:A,-A$$(_\\-"7;U[(\nME.ZO5*O#/?V#HNJXF*$PW5WQ1C4W`(#&M$P,PZAGSR86C:"DI"698'1T&(2%\nM)Q6%0@F%0"L=2*E25*H.A6(IJ*(0""/8HZTEN>/XJ:E?#86;1EI;XF26TP@S\nM0CP66SUV76M=%#+J%-+UUZ9I(I7$]3Q,PZ"_KQM#&-AVB-4+,*``Y`M%/,]'\nM`,(P$$(0B83Q?;FWD"_N<,HYSIR=06J3X:%^+,M"2KF^Z-<'0.#[/DKK@$)>\nMH"R^)_&E#`+T?1`0C48:@4/`_V*Q#&B4UGBNAR$$D7`8*7VK4,B)=*9`<[*-\nM7=M'Z>W:A&$(S#6-*U]]D<]O;HD^__L?_(N3O[;U_LDKQ5Y]1P]?Z%XW`(UI\nMFAA"U-5%HY3&EY)JU6%^?@G7]5CK*)36N)Y'H5C"J=6`@#ZF9085"(=Q/86O\nM+`8'!MBQ;0MA.X360?54/0.V".E/3(ID\\::K[FI.1A_NS"_^;4+HO_[TTRES\nMP`[.6E<32RE16J.50DJ%5#*0QN4LY4KEG'Q*50]"H:2D7*DB9:`D0@@LTZSW\nM0)BF>!/;1K>P97B`IGCL/+D,DB'4<\\YC6WH^],OW?LW?OF_LA6_:OY'S\\SL=\nM#MS8ALR/KQ>``*=6PW7=H`?JS5RI5,EF@QG7,DU`8!@&`@$:0E8(0Q@-<+I.\nMP:!7;-K;6^GH:,/S?9121.U077H%AC#PPJ7.UCVYA_<9WW__\\;$A7GE]+]^+\nM755KN^'ZOI&C>3O55G4Y^)?KH)"&IG@OH(_/V=[7ABM6:6^A/,\\'!C1_?HN3\nMC6Z/'KS";/NHZV7;K*H#O,N96&N%YWE4JPZ%8OEOF=[[4-\nMXUP/**5(+Z^0S>8#4:A;#@.#Y<0,KQH_%O]]XKB8F7:(Y%ODP<-3/XHM[U+.\nMZ=0#?_S/]RR<.78HJ/[Z`M=H'5@$*17E2I5:S6T$9ED6@D!U`JKHU>*]=2>,\nM>@^8IHE&LY3.T-O317-SD$O'\\3A>DTQ.2MI"/KN[MJH7QH[\\^*5GWY]OSJD?\nMJ;''_OV^WSQ"S7]\\_0`,PT"(8&2TPR%,TT1IU?B;[_M`,,4)40N:7:GS;E,I\nM)95*%0CN$:TU:*A4'?*%$IV=G6@IF:KUDQ_FYC[X''M\nMM#]='7OV!X?:;U!>^C.-?===@=6?IF$$.JV#R4M`W>QQ;B)#!Y??FG%-"('G\nM^VBM<%UWS=Z*;+Z`4ZTPGFWB8-][T42XNO)+3)]6_Y5MVSXY9%C3][RQ[WM_\nM,S()4^>"7Q\\``;Z4@<^I4TB]Q:>L]D"E4D6I<[*Y)@6$+(NFICA+2VD@!5)9S/EYC@W+BS3'RK-I4+5SPZ8G#8+BR'UW7F82E\\0WJ4!:`A9\nM5N#EM3[/F0J"J@34@(G)L[1W=`"!4IUGR(1HR*I3JZ'4N40X5S;S\nMGMD,P]XRRDRE/G;/MM-.I9+_U*-_QO]\\_^W#6Y<*K:5076-6L6$8!I&P'5"J\nM_O[59G[K'JL78JU6:Y@[%!PI]W.H:RN]J1Q[=(EB_@2=72ZM+:TDDO9%8[LD\nM`"$$,[/S=4\\#6ND&32`P:-%H!(UF9*B?>"R*E`I#"(SS:%2GFE(X-1?/\\U"^\nM1ZK:Q=C.ZXDL5WF?4Z*R/$;'I@J&*9!2HR^4LG<'``%5QVF,A:SA;H!(X_F!\nM>XS%HEB6V5"@M6(JA,`T`PK5'(>P'<+1G8QMNPE/V5R[M$*K7(30#%*[%X3Q\nM

XZH645"BUV@.!M:!N)58I5"H+CG??0&5S\nM'WUC*7:&BVSJJ2"L&K-S\\V\\1@@EJ;.ZUG\\3U[T,0IQ7\nM`*UU8\\PT#-%0)B%$(_GHX&-'.V0A?9C=M-@$"3];HXO.U&R/GL\nMR>5H8PHC/$\\D;-7MBFI8D0T#8!H&AB'J"J2#9EZ#P#3K/5#7?B&H?_%GT!!7\nMI:AX<6:NN1DOT<9UZ1R#9HJ2.T;(5OA^,.&M)F4#`0@J50?7]5!:X]1<:J[7\nMF)Y\\WR>S$LP%TS,I*E4'I^8R,35#>CD;@-::?*&(M$QV#5H,CYUBQ%DDG7D=\nM.UP#+1JW_;M=E^P!80CFYY>0RF=`:^92"]2<&BW-2<*V12ZG22TLD4PVD\\L7\nML.UP@T;-S0F:DW&<:I5,)DLL*OEU]R@+\\3(_.W22SBZ3:"2)99G,+Z2Q(Q&*\nMI1+E4H7.S3T;`L`!YI16$:TUEFEBQV(T)^+8(0NW5F-^88E0)$KC$SP1-',D\nM',(TP]B6B1,)XWF>Z?FJ=65E.3<^?LR/QB7]?;L8Z.\\C'H]3\\WR4%GB>3]5Q\nM3`2+P"5+9`%@>!+\nM"(M+`J%[I95V-3N[LSMW]W1/=[_\\L4+(+EFL!,JOZE?=-?5^_;Z?^KW?O-_K\nM:H4SM$*A8*U8L2*CJJK5:K5:[79[3M=UN6O7KC-]Y!F96.C`@8$!;KKI)K9M\nMVS8\\.CKZKN7+EV]2%&5X;&S,_O6VIZKU>O.NZ]]QXW?FYKY`N5P^FYI_PY2%\nM#MR\\>3/M=KOOJJNN^N;E5VRZ*I5,LF?/;I[9]@2[=OR:7?N.['*[W%R=FWW"\nMLBPZG<[9U'WXS109]KSW/9/WZTZ/2M\nM&;Y@[9H'J]5JM]5JG4W=QVW!2VCWGMVTO:"QKJ_IO_G2VZQ,WS*4L$W4G,`O\nMJ;SWTH-\\:MU%BY*=*&D;*#)$%28A$'4[C"Z"CUY;Z!E9K8P8'WCW_G7ONNMX_(TWWLC4\nMU%1A_?KUUR]9LN2*9K,U],RSS\\H=.Y[_UNY=.[\\^-#043TY.GCT`4Y/\\VWT[\nMXD>_O/3=YI`RRH!AY^\nMKLK!KVV4_LS1)PU3W1%[E4U*Z"9C=XZ@,4%0.TS@5G]L909NT2=VOAC-'9*?\nM?61^661S.1#V4,;P_VY%MI:WPS)+TW6N7!'2K4^DJW(@=?V[__#!B?&QN-%H\nMG#;`@FN@^/XGF;AG;;5;'_^N9N??0.1_#$4C\\AMT.^URQVW<%>U[Y(5['_.X\nMZ[&7X\\X=S%*MU8,UV=+IJW;=Q).ZR7UKY^E#\nM/[OG[`$`++JU@AS[FW#L2.<;WN[_>8_N3?0'1B_-S.4/[TI^GOW/V+?8:^Y]I;,4''YSE__5*T:2Y`;/CGTF<]YZ[_U\nM;6.D&Q;K87A9!:Z1\\"BWKJ^@M"?F,H[NRL[68N>_O;+_S7JS>O?//!FLERSEMA\nMH_[\\?LSAE93RH]SWF>>8WC--N>Q/'!SS_LGKR'M`">$V*O>>AQHV==\\<^JQF\nM9N\\`B=\\H>W[UT.V1WO/5M#[&P$=/6SL`ZBGI%$&Y_(SYNM<-?W+#AI$;7#>T\nM]D\\''/85,$P*OD*GVF<L$U+7;O[S!5CA9%FOYI'/-*;!U83L_->Y7\\AS:9\nM>XI_NN5H,VX?/'20,6WM]'>=K^U;^>>;K?=\\4P)KSPA@`35PSG`B8;UQ?+S&\nMW&R'DI%C]G#`XF&?7DVCVG1YY$B5H[Z*'POF6CXX>@Y#NR[;G7LXU*Y;=-UU\nM%WRP9R!_[;@87<[YR41ERS'YN\\YP&XY;]UH;:ZX9^\\\nM=@!2&H!>?.JIJHURN<"@LXD\\UB`T-,B8X`@RQ\nMN+9W?_];WK+J/S9?M?*Z(W5)T]!)#Z^GN&^"F=2((A-3`U*S!Z0,WB0L[=RN\nMHO\\MYG]&M/]HP0"G7$)@`E9?K2;M`P=:3$SXX>3N*8*:S[X]+=JU%H=>&*,=\nMF+0;=>K=*"9CQ:1,R%@]J9[,U3V%Y.8#!ZKLV-_@%T&JOR?"6B\nM5(7)V4@/'?U&,F*$I+Y@\\?"*2\\@"Y`!H`D0(>K7=$,7RDW-`DNUVD]W-#,U#\nM+6HS!C*M^]C"PQ)Y++W@AF+M8X\\=-FS;(79LD@F#G>D>!B8G>:%RB,J4@C14\nMR-K@Z'ETM0\\XP&ETXZ<`N//850[._]L*3PAC5JJB6)V,:&^M\\%_%'`=DD7*Y\nM3:Q9D!!=;#$S#R#RD>:L/GRD`T.FXS02V,(W(6\nM.+J-H?41RX6K/S6``;042,X#*'H]67!:OJ+BQ1!T8W[9&"0TD\\2F`%N`*50L\nM4<(2*S&U+%9R'82`,1L$1L_4UJ:Z56KTQ!9C4E">BHC320]'#W!$'D,;();P\nMCI_#@U>\\2@#%!*D;J-H`0@.AS>07IX-9-\\0+)(H5#&ZTV!9?H*Z[*=MVO.9<_0I''T%IC;()T;A\\Z<\\\nM3RP0(&F@0!JA%J2A@5"/9/J=HN9)$!%8&H>E3:P:D#9?!C"T%HX^ISAZCJ$,\nM80DGBF00OEJ`T?6]\nM>)VHN*_D)5J-KHLI2E6IV(&M@ZT26S;C^NL(^E=`UP!+F\\^"H6DDC7'%%I?U\nM+\\U0ZW6F0L>(W$"!G""A-;A"WT,ENY*J98,C="Q1)Z'7\\EFCT)_6TWXD:WM?\nM+<`%ZWHH5;H#ASIS)K%Z5$GHL[.Q8@6V`;H&IDK%ET2Z.E\\O+P,X),VQV!)D\nM$RK64/K(+*KF6CI8*FW1QX["Q;AV`0P-;%U@"H^4,9TMF,.K>HV\\(N7AA0*<\nM="?>]RF%I-5F4-DVN*38(%6@K&2,U@RJ'24-R)BH3LQZ=R=KW`.0L>;K8-Z3\nM3C+:WY]HRX)QA,)@<+"$:GF.`3D;T_08GGD6RXGF-["RR.EG4-G`\nM.8441U2=FFG('N$.?$E^U7*FQH0UON6:39^Z^-';;WYO_,5[[S\\S`%#IQ+&2\nML,3X0*\\82P\\F]ETIPIU;O[+["]V)R;^J"$6K"Y6#N@`%_$@AUE3B_O3CPV],\nM?[MKU#:\\?K6V8]:(PI\\<*>?TV>W?4`Z5-M9#\\JZN<\\#4B.,#:(9&=BC]^,:-\nMW@MKSJUF!T3U\\>]/1#U_?,7T2&\\WZW]QX\\;*;4\\^Z9=6KF1PSYZ3*CWI@6;?\nM/PARJ]^)6]IN)H9&\\W;QO%;?E:5FRU-N`.4!0)?'0!6AE&'0V$33WJD5F=H\nM=5L,_X%#-NKBIJMA^>F\\=_Z`D[KFPC2AZQ>C5KL8N2Y>HT&B5B.LU\\EZ'D&S\nMV1-,3/P+,'[RE7(:AWHI7U*O`OI+7I+$`V/-0X8U4Z/A-VEWVS2#)E6_2MDM\nM4_$JM/P6?M3=)XI@(\nMB./XE.?>TW@K80&2^<[T98!8AH6')Q\\QMB5:=/R`IM^D[M>I>E7:09LHC"!B\nMWB70%AZDIKR]3RZ?/O!#`JD0Q3&AE,>'G>CQ*Z@Z#0#[!`#!?!GHI1A_Q3/E\nM9\\&<@.X)L_[NJX^>*'>E1CN,"4XB.F*^AWTIY"QE0`!&"9V`0`7OMV:-3G(O\nM`27VR-K3W8[`;7(<(.3D(&<'0-%!$S&Z/DTJ[A">`/"[Q+]TKX0N>6,>AQ%2AAYYJ[+'."_^<>+-:L$,#EP0'WY2<1)((8A\\\nMG]#S"+M=)5*41@PSKPV`8X&4\\WV0?0Q`URLDPX[2U4F$#@6S2-;(DA`)',TA\nMCF(\\W\\/S/6KM&M.-:5PE;I,UJD_U;XJ>MJ]2,=3'[[SODEL>`*7!?)YSP`I@\nM%9"%N/N:`&3,EP'F>_\\NAE;%*;CRZ,VT&W4\\<_:7,^FOWZM*%56J$$$<=678\nM7-K7G;OA+V-AYC2MT!:]R6I7$,6VKF,)/G[3%DE?6G+GFN/3/;Y`60L'2)N_\nMG8$`76N0,MO(RY&A3J2*_>XYG[N/9_;`/>OFXZ[Y&4B682@?40T]5RB8[62O\nM6:MTZ394U<(2T`DA;R]8RID#`.@J6`(]H?N&)>I^PFB%8OXW3`WR=T.06\nMQ'SMZRI&VF3ITF1;R9BM-(J_O1FGI"G`C^:[TK,*D/G-&L@6K4XJ(5J>;;2G\nM`TEDBOG^WK$A?8*80NK83`K9HL7J9>GF$RU:%P]9_M1,Q%2LH$:2N)`\\RP!I\nM$Y@'4!W!HD5)MR/I]/?9#;\\>,8EJN)6ZTOB+:UEQ]?4L]!!S9@`G%+&5,E@^DG1_N+_MG=]G-Y4<\nM_&HNF@<8$//9.F:)G_TC81BM*_0-]%J'SZ5D6XOC_WUTX*<]Q>SB)4NX*.&L\nM,A_]?"86U,\\N0-8Y%J&2Z[58NBC9=K]7"?1-@\\U+TCK[S2[E6)'D@9QS/$S7\nM#:0,IAU=^W;6%D8VF]JJ*;3U./QN2JBYGESV12EE%+W"AO6J`;3M7T'ZKM3[\nMSY$]8@E[GM;;//A4M'O=FGI4<.CK0%R9448^>*LR=^V'Y8&7N+-9#AX\\^'/;\nM<7[A^X'2[7;C5:M6X;KN;6$4*:[KQG$<\\Z,?_>B,`!;\\J8&4$L>V/U_L[?W(\nMX*)ADLG$B\\3AYE]MV?K)8E__AX8&!T@Y]G9-$U=+Y,Q##SUT1H).UQ:<`451\nMU%0J5;8L:WLZ86OY?&Y?O5Y7A*8>M0VQ(YU,J+E<;F\\8AE+*TWM!^VILP0`C\nM(R-QK5:[4U&4>\\(HTL(P;/?T]+0T3?MGX(MA&&IA&+:!UO\\GP/\\!23H,Y&L4\n.QEL`````245.1*Y"8((P\n`\nend\n 6582 customers_add_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```2;TE$051H@;6:>91D5UW'/_>]^[:JZJKNZNIUMLXD,PG,\nMEF8FD\\5D)F8&),$3%51B)"!$B"`<.9Z(>E""@"@817##')4@BXA@%)&,(6XA\nM3";)9$AFR4S/]/0LW=75:^VOWOZN?]0D`9?0$\\RM<\\_]X]W[.[_/_?[N?;][\nM7PE>8NGO[[V]]P^U?J5;_F/GY^9?3Y^\\I\nM8J4=]^[=B^NZ0WOV[/G"#;MV[^G)Y9B8.,&A)Q_C^.$G.'YJ^G@GXLY:=?DQ\nMV[;Q??_E]/OYHJ^TXYHU:U"(ZW.V?%^O*LO&[+-(=XKQT8";K^@P>6YV(#.T\nM>>W6+9N_6JO5HG:[_7+Z_7Q9<0B=F#B!ZX7-;4.MX+77_8)=&+H,$;LDK1F"\nMBL9MUYWAT_L7:HORZM`TC[Z8*:VOK\\^P;9M.IQ,*(52]7G]Y`7[[S1N09D9>\nMOFGK5:M[_"3GF`@5HTF+&$@BG_'5\\)Z;^TOK-VECQAT_/;GMI^Y]?OSMM]_.\nMW-Q<_XX=.VY=MV[=KE:KO>K0=[ZC#A\\^\\L43QX]];M6J56FY7'[Y`"Q=\\;&_\nM>";]S\\]<UPZBWM%G$GEW:JA,T9POIYPD[M&W9AY.W&S+%GD^I9\nM]8-,"*UT#I30>8N6]++6J<>T!WBC]$$OP20B<)FD2^.^]WFO&K:_[QWXA_?:'@SPZ$Y2*MPPT/'LU?M'U(3?/*1\nM-G#_\\V/^X%U749F;W[FJ$%^JA572SA+$+G&[0K_M\\:Z?V+P[-/]S@S82/7O1\nMWK.B$-+)Y3Y(&*[)[]SY8S_RI8>==SF;;WY[8=7`AF-/?%.KF>M0.^]9]8E/\nM>CN^^!5S+(H'&G%\\_1*\\1L&_\\HX=2PAWIEK(&!WE5[>+I.,D;H5@^111:_Y8\nMKE#ZB!$M/";=\\_$?_E/EH@&^SXOLG0P-]5*O=RY[_>NO_+U7[[W\\M6<60WO]\nMM1NX8J.#]LB7L-9>3J4XSOV?>)J%B07FYX.9,U/>[WB^N@]$#+_`TE]>@18W\nMC2^HGWUGHI<^F[>F&'G/1?L.@/:B=$(R/W_(>M6KUMZS\nM<^?8CW33L6Q.3/K,S2>K$]WX"!GK)AP#N(S2\nMG1.B>->-UL3`>Q^;;:7NF;-GF-*W+CS@_/6IR^_>:[_Q\\PK8\\I(`5K`&+EF;\nMS=HWGCM7I[KL4S'[6#X?LF9MP*"N4VMU>'BZQFR@$:22:CN`C-&'J=_2&U4?\nMBO77K;[EEJUO*XT4;SXGQS?PREQV:?\\7Z!]_U]JS_\\!7MFS9>62J?-_?PMN_\nM;$BM'<7O_O\\#4,H$C-+!@W.%,V<\\@@"RHQTL&XX.CG%#H\\[\\_!)GXP&"N2:I\nMJ4/!@HP$4ZZNGYP<_M$??<6?[]US^2W3#47+-,BOW<'`J1D6>\\:$RLZ-*-T9\nM42K\\86GKET7"^$VLSR2X;UTQP(N&$%B`/52O*^?TZ38S,T%W0*-[1PFPT:49)2L%-Z+"C8`SVEPJM+_;F]IT_7.#S9Y%NS"?->BJ82\nM#D[5.+*44*E!>3DQXHQQ.P4Y1LY8L?/P?4/(!M0(Z!)D#$;5;K0(YG\nMG!8G6@5:9]O4%TU4W@API(66_[MW\\Z;CI,AS3CDLB;'\\B5&RF6.\nM+IUE:4Z@3`UZ'<@810QM"#C-163C+P+P\\0NM6M7=;:4GI5E5FARLE1/<`TO\\\nMS4`?I]4`\\_,NJ6Y#5D8XIPF]-F0,1P,?1"E5N[]BP.80%M`;A1T$$8CUY]I!T+#2R&,4AYMCA);\nM.5)+@B/!DAJVG,.65V#KO=BY;1`#YG(8FJ6Y`RWM@-(II3932C(_EY#FV]DGG-(#$-<(R(\nMC+&$(XM8&UO84FG,>=%*4XS#=,T[8LQHZ\nM!M@2;"FQ9!5'NCC2I%@0Z)V@9[AGB8RA^5Z*D6ER67&&AAK&M9RN-2W.7%*@_[50'UN6]G(09DQ\nM,TFJPN@'!1C?,8CG)P.G*EZVW8PZ6+)24\\(.'0,\\BG!X(T0FV'I7\nM!5/7R9GGA".O'UY?H#Z8F8LS9M()!?1)LGJ37>8D2_DQ:DD%ZB=,IA[;3K87\nM9+H^G-SW_K13/)*TL\\$OJTS]Q#/CG'\nM^H&BOG;#JFNS3D"<)DZU.'[W].)T6EXN5]V.^S@1][.3;V#0X=LK!#CU(<'?\nMV"ZCXIG1=0,#5+'F7,ML+Z(Y2:[KJ*8%[*@=P^V83*U9]]PN!*:>RV22I_JL\nM(.T/YK3^T?!L)!R>\\#H(3@32>OM+R>H6O?\nML.DZ@MP&\\2N3>[('FJ.:E=$I]5D,%')D7_DS&/E^MF*QA&!9-U"Z&OJR^R>;\nM^U5#F.4G>2IO.._H?,K1PN-H4Q_B-5<,\\H$[O\\@5ZZY@N;7,8FN1*(T(DQ!?\nM^;2B%I[R*`X4N2%W`ZM&5SG[G]W_L[,+LY>KMKJ+<0X1`-,O&D(:?IJ*K"W/\nMC0S*J?QH]M1-,CYVX*]._$DT4_[U)2GTAM0X8T@0$"2"5-=(A_/_L?;&_-]%\nM9GWG]DWZX64SB1^<7NBE_85_5K4O[_K973MRO_/.CR$TP>FYT[2"%D(7C!7&\nM\\-H>M7:-_%">Z=/GYN7^)R-\nM6_@$E*,*I=X2[_^YWR!*(^;K\\[BQ2R?NT(E=,KJ#4@7\\P*=>;Y"2$.L!;MK@\nM7.L,T[5IZNT&'2]`*Y6%.G(5.NL:2_6\nM:08MW,BE%;:H!34JU0J//O@H;]WU5H9+P\\Q69W%C%S=V\\5,//_'04X%"D<0)\nM<1RCM)2E<):3C>/4@AJI$>-D#80.FBX0`B,D_OET5CU`'XL7<2MA`XIN9OH"\nM0*KB_H?*#YM/9MOX04@K:-$(&M2"&NW)-H/>(+O&=U&I56CZ3=S$Q4L[A,HG\nM3'TL);MV!0@A:$3+G/,G4%9(7F8(HYC`CY!21]/$A($H2DB"]/+J9UWSI0$(`W298A@+]*0^\\7EA]^[='#]X$JG+%V8[\nM30B\\@#7;1LAGA*/6"!\\T!(=\nMD8INC43W!16'-+TFN7R.RLD*]WWZ/GS?)TW3KEE-(TT2_,#'LBQZ>WLQ=`,%\nMQ'%,X/N@X/V__ZM8EH%AZ$BI(W5-Z%)Z.UO1H7JC+YQJX<1M=\nMUY&:1&AB.OIFXJ\\<(&_]=P4"#+U!C^6B;D#%!HDF)SN7?/)^#DT@CET)/GIY\nMJ?S:B9D)+;9CVJ*%1XM`:Z'9"=D>D\\%"B223D*8I2BG".*#6KA&$$:[OTPP\\\nMFKZ'%W5(E<*1&5Q"1:*>6OOQTD6$4-[JMD8WZS2R1FC:LAEDS78L+V2BE@[%\nM!O1JJ$"!XMO+]>7I!P\\^N(X\\D%5D>DSR!8>"S)`FBB3IWD)TM\\>$*$IH-CVB\nM.,;W(\\(@)HH2HCC!P,0T>IB-%F=5R*/14OS]+K:^.X3L+D3>AH)-[TC6'UJ=\nM;0^,9EV]U[[PW(:,TVU=X!"3*E4/1$%$%$3$<4*2I"1Q2A0EA&%,%,4H!4F:\nM$(4A49S0:'9HM3Q)Y/'"4TFQWB."&.$SP_)/856XM74V\\UF:U63B=N^NE5-Q:3\\Q]>NA@%\nMK`L*6-A]#AO&Q5OO^CF4#O5ZAT:S0ZW11@MM]J[Y[1U;=Y@THJ83X6B\nM"/1ENF,.@S5L(3WYK=1(O^)EO+VIH7H#(T;70X0&4_-G^-C!#Y+/]&#V2A9/\nMS%'M-+%UAVV#U_":L5LY-G>4!Y[Y7'-YN7I/9RKZXM/O.T_UR^V+`]"?^2M4\nMT,$8OD25Y#HFGC)1P?.#ASP2MYMZ'PXUM.QU`0B2>`E')XY@FV99"R;4FZ`G0,WLF/T&@:<\nM81X\\_G6^\\>S7IIN-U@?"F?3S9K\\>5_[HA>_**_ZK@5**C.-\\:F!P\\#VCJ]>2\nMRV6?)8WW?GO_@7L&AH;O6C4Z0D_&>5K7Y6L4:G'?OGW?:V`G\\`2"US%.CKOU\nMG'Y+H9`O#/<-,-(WQ$"^1#'73S%31"G%^?I9CE6.-.?K<_L2-[W7?30Y:+U2\nM4TN?:7V/V14K((30>GIZYFW;?B:?=?1BL>]4H]$04M=F'5,>SN>R6E]?W\\DX\nMCI7ZWRYHG^C.`X)#+/.V)$FNJD:U6YKMYE7G%V=6VY9IFX8$H8(XC6;B)#Y(\nMQ#=PM2>T#%[K<9?6X__3[(H!QL;&TGJ]_G$AQ'UQDNAQ'+NE4JFMZ_KO`G\\6\nMQ[$>Q[$+M/]7@.?*UP'PV'N2:3N=?L_V;%T7:$KSB435/Q"Y8E`H\n;]?B+WU;_%TCA'_.X-T$X`````$E%3D2N0F""\n`\nend\n 6583 customers_help_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```2V$E$051H@;6:>;`=]77G/]W]Z_5N[[Y]UX(D!%J0B"P6\nMLYG%LK'C)3@&5"9>5`:;F'(R1:CRX(QG[-AQ8L:8#*Z)F7@%`W&`.&9B/!B;\nM,3!(""$A@=#V]/3V];Z[]^W;ZV_^>#+@E`/OV>%4_>K^T;]SZGSJ>T[WZ5]?\nMA=_1VMK:K'7KUN545;7J]7K===VBKNORR)$COVO(W\\G$4C?V]/1PPPTWL'__\nM_L$M6[9\\:.W:M9>26NZW9=<<45/[SXDDNOR*33'#MVE/W/[^;(H;T<.3%^I!&RJU1$.L[77Y]WK&PR-3G4X71L'\nM-V_:^'"I5`KK]?I;F?>KMN02.GKL**X75,_IJOGONO!35JYK#4KD$M?SNF59-!J-0%$462Z7WUJ`+__)6H3AB#,W\nM;'Y;?Z89IVT#14:HPB0"XK#)UGZXY=UM[:LWJ"OU&SX\\=,X?W_&J_\\Z=.YF9\nMF6G;MFW;^U:L6'%)K5;OVW_@@#QTZ*7[CQXY?&]?7U\\R.3GYU@&8FN1O_N%@\nM\\JOOKCJCO<6RP^)QJVV:C>$9]XXN6_?]SC\nMKJ=>\\SNCMX5RI1)N:IDN7GK>>U:E.]4?_Y5K=F^@.C$YJN8L?/Y)ZV[-=\\AAW/54'\nMOO>JS]=O?AO3,[/;^W+1&6I0)&D4('*)ZM.T61XW?W#CI8'QJ[5J3_C*LK-G\nM226DD4[_5X)@(+M]^_MW//B$?;.]\\=V?S/5UK#V\\]^=JR5B!W/Z%OCOO\\K;=\nM_Y"Q,HPZ*E%T40'>*>$7W+BM@.).%'..WI#-XA\\H<<..W6G\\A1.$M=G#Z5S[\nM7^GAW&[ACD7?>'1ZV0!O\\B#[-%U=+93+C35_]$=;OG;5E6>^Z]1\\8*V^8"WK\nMU]FH3SV(.7@FTZU;^=Z=+S)W;([967_BU+#WUUY3W@-*!)^B\\.WUJ%%5]\\W^\nM.S6SY4]!XE=G/;\\\\\\NE8:_]^UARFYY9EYPZ`^H9TBF!V=K]Y[KF#7]B^?>4'\nM&HW(&IH+&/,5,$S:?(5FJV[CBFM\nM-UUF'NOXL]U3M<0]-7**86WSW#_;/SAQYJU76M?>)X%-OQ/`$GI@U6`J95TV\nM.EJFN-!DVLBS,!8P,.C3J6F4:@V>&"\\QY:OXB:!8]\\'1\\QC:U2UA\\?%(>T__\nMU5=O_D1[3^N[1\\76M9R=3A6>_2%M6V\\>'/DQ#VW:M/VEX<>;5XQ5)S=#)#FZCX\\0$\\YF5BDS-]$C-[I$R>(>P\nMM#6AHO\\EYG=CW(\\O&>`-2PA,P.HJEZ5]\\F2=B0D_FCPZ0U#V.7&LCENN,_+R\nM,&Y@XE8K5,(X(6+'%HJ,K34S&S7H(J8_8-EWBI\nM$#-=@LF%6(\\86`41KK#D;QL:K@`P-HZ'U#+2J1WM--HW/,J)5:-12E*,D\nM)F^!H]OH6B=2+CW[-P8P@+H"Z5[00-$KZ3:G[BLJ7@)!F/!,M9?(3).8`FP!\nMIE"QQ`R66(^EM6"ESX$(,!:"P&B?V5-3]TB-]L1B6`IF9V*2;-HCI0?8HA5#\nMZR61<,U3\\/`EOR>`8H+4#52M!Z&!T.9;![/!@AOA!1+%BKBJ\\WF:]EH>"[:"\nMJ8(E-"PQ@RT"#,TFE>X%/S$L>TZUC+9FJ'#T)8]BRQ9F59W8T,'60QR]@"U:\nM,44O00QIXS]``=N$1#H(M0-3`Z%-=PUFDEZ$Z5-:T35&0WKFDO*N?H,SCZ.DRME]NV\nMPM^]X?O$$@'2!@ID$6J;-#00ZGBNVVG7/`DB!DMC3-HDJ@%9\\S4`0ZOCZ$7%\nMT?/TY9#'2_6.U=ER`U5;*(8HZ81T1SM*G`9A@2,$CCZ-K8,ENKEWR"!C!+\\W\nM0-?*#$"K&\\AL/0%T=;PIM`M]2X`F4(V`R]E'P]S(3YSSP5#!%@JZ"$GITUI*\nM/R.]*D?Y1;O8L2+K3=8BD!J^"2?4'+YC@V6!HPM2QCR.[@E'=(J4X<2Q#,+?\nM%V#KMDZ\\9MQQ8MI+U:MA`U-,EZ1B!;8.MDIBV8SJYQ)TKX/0`$M;5,'0--+&\nMJ&*+B[I7YRAW.C.18\\2-0(&\\(*55N<0X3J%E/24E`7].9^SD(+EL)'1E(-K[\nMY'71S,1!!MXS3%B>1[,2)G^Q?(#-Y[0S70A[1II%DT2=4E+ZPD*BV(%M@*Z!\nMJ5+P);&N+O;+:P`.:7,XL00M*16K+SNV@*HU+!TL%=?HX7G.Q#WU`F)NE`XK\nM%GUYYP]334-)&F3J_:W?G+$U=Z%8'0V:SA/(\\#ZE_](748Q8CO]\\:0`GOJCP\nM@.72JQSL7='101%SQC6-^CRJ':<7$U55GVVEP[@-@^&!%;^^"X&AI1TG?B%O\nM^DF;/Z.V]08CT[%S5M,1H$GBT:.,3+S`5>>LY$,W7,WF]2NP3%UQ/9]JO4FI\nMXJJ3L^7,RT,3&_<>'-YX_-3T=4W/^9\\D_O_@C.M+G'S@S0&DHO"1XUM,+]-U\nMP34;+L1/KU7^8NB*U)YJKVHZ&NUYDXY'_4E@HGTWD_CGK;ISF^#UO#``JS2114I88\nM[>D4P]G>U(G+171XSW>.?C.CBAM#1.<+'+L3^'=>\nM:$Y\\69#?\\"$:TP?-5-_65KMC?;WK\\NE:W5,^`,J/`%V>!E6$RD7O[V+KUAQM\nM[?[XFG/:?BYT4UDST.JYOIL\\?^!$[P]^>"KT2\\X'OW_'IXV^KE:*Y3I]77G\\\nMILO8Z`A34U.$88AAZ`P,K*2S;Q5[CU7XZ7,3%"L^I4J3Z=D:PZ-S2=2L?XWR\nM*Y_';(L8NNNW*[#V]@AX$,"'(],`BG++ZW`5D!J@!\\)1]!L^NT&YZ+S55)OU\nM@4;H?<*+FXQ$-9I*DUK*I%S2^.+-'Z"W,\\_H9(%TRJ$P-\\W'/O91AH:&B..8\nM,`SQ/(]L-LN.'>_DOWWIRXR6V_GZCX]0J?J$7H1T,JJB&#=)==,O$>G'WZ"$\nM?DM?R%]GKP+ZK]>T).D9KHT8UGR9JE_##5UJ08V27V36G>>%!U6VK#Z?"[:L\nM871J@6K=1Q4FNA%SWGGG<>NMM]+9T4&>."!![$MBT_]Y[_E\nMKBGWS">#Y5\nMI^D'U/P:%;]"J5G"G0/]R%5\\[I8M%"LNY6J#NB=11<3&+:NX[OJ=//W\nM2^@86,FN6_Z"\\;%QOO/=[_+<UGA]-/3D6-NH4K=BW&;&D77\nM8ZHRRO,'CN.;O1C9'D;*@G,;DL'!`0"<5`H)A(J/:,V`%RT^*>.ZYO0#L>.=53'D1!:%BI&T2,T`1"HJB0"(AT=>G=GQX.0=;\nMKP-0=-!$@J[/D4F:1*\\#2%X'4;>PL@8UMTG=2VCX.FZHX2'Q5(5(A?6#+6Q;\nMW4J?WN3N.[[*T\\\\\\PT=ON(&=']_%EW8?(^QJ1R@6L5!`42"!)$R0<:ICX:__\nM5%DZ@'(:0-7`$&")&,.8)Q-[1`I*$]180TF4TPO"2!!%,96:A^NK-`(5-XYI\nMJ@H-32&?,;EF'L/9C9/XH7$*LA8H@8Q:C-"-35B-ZSL>N*3R=(!O7KZ>]O9T'*AZ39YV-DW6084RD*<@H06W&*(:&,`48&I%01A_ZZLO+\nMZ(&L^6\\5\\-&U"AG315Z,C'1B50PU5MWU/?8?0_G%EY!Q='@A4[WVX-'Q-MWJ\nMH!9F*"4:)46A80L&;9VZ:O&Y+WZ%)(F))-2'I]`S%EK&(/$C5#]&%2J*IJ!H\nM"FE34-&4)L0'XH6Q90(`Z(M3IY[2`\\,253]EU"-Q>A(U-6BM0(L*80-DVG=\\!WH5:?2@9M.(-@?-U!C(6;3;&J'?((EC;-OBG)YN#L02&<3(,$$F\nM"5)"DDBRND;:B%F(HU=DX.Z7L?=F!UNO+R%K$2)K0Y_IH/\\MX=\nM5_&+?WV4+DTE*GN$18^HTB1Q0^)FB)W`AHQ!K1'(*/`?:/GP1^>BL8/+56"Q\nMA%1'T-^?;C2AV=UI5_U*3!%U48$V>[%?F@7PYB'Q?X)E_F\\(KR$)D5%,$B4H\nM44(<1K2W][#SNFOQ/(^SSSJ+?0V?J.2!%R,32>2%I(*8=[3;C$S5*)0;3\\MJ\nMX=[Z3_\\1]U__^W(4,$\\K8&+E;=:N3#=&(\\7KZ;)K9ZU,OWJ-'K&H!B!+1S'B\nM2DTOO_B8".8@\\9%AC`QB"&)>&2WST'$?L>T/R5U^'7M%#X\\/%XDJ/L%"`W^A\nM05\\D^7AOEL0-.3!:'`GKU=N-%6MG&\\\\^`BSG"TV+`R`1*OE.B]7]:;?QXT)@\nM7-I;NR"K,V2&S":*I!7(.XL^U2$<+4\\4-(\\;Z?1]I63@O"3,K)5-`_R8$^-5\nM/O_($;2,CI8VT-(&JJTC+)TV1V?'0(ZK>M+\\GQ-%?G)HZE2]6/[,JB^_[YFA\nMCWX-?\\^/E@>@'?P.TF^@=Z^2[6(%QU[071[>%Q\\Y9V,E:G/H:D)2F%=6[;I1\nM*;[K,W+HM-]6O<3\\5VM/'[HU\\[1J;-^"ZOY-TC2O,`-=H_>"V5_-:\\E\\-I)0X\nMMOUW'9V=M_3V#Y).IUXAB:[\\?\\_N^4)'5_=-?;T]9!S[14T3[Y3(^9_][&>_\nM&:#O_=!V(?B%=NRNCVOI[,>*\nMU36:8Z142X!0O5AC1!+O5J/&KQ@].$*F/:G>=?UOSVNI`"M7KJ1<+NM=75TM\nM?7U]6FMKJVO;=OW11Q_5N[JZ!>I(D\\I%''GGSH&MV0=!4U-8V\nJ2\\UUZ(HI(*A$LC+OH2"C_=]^TQ#_'Q?BMQ+!Y0<59W'OU5U;[WZW3T]/>^93#))S'M@\nM,@DQ(9@'$%3$M^2`>U961!:.KF=UQ5UUW:/NZB**JQYD%T%%5V-`!!8_,VZV$[=L\nMV0)-TQ*;-V_^Q88K-VX.^/WH[>U!U\\%]Z#YZ`-U]H]VZC5MRV>E]LBRC4JE<\nM2MWG3)CMQ,;&1C!PZ_TR^4*8C9/"Q$D0;0#M=2:V+=;1/SP15Q/+FE8L7_9(\nM+I>SR^7RI=1]SF:=0CV]/=`,J[@R43*O77>;'$HL`.=H<$MC,),\\/K9N$/>]\nM-)F;(FLL43Q^H:7X2"1"95F&KNL6QW$LG\\]?6H!O?+P-1%3)HJ4K5C<$*JY?\nM$<$Q!SR1X`!P[0K:&X`[M\\6J6I?R+?3FC_2O_/#=Y_RW;]^.5"H5Z^CHN+ZY\nMN?G*4JE(]_R#\\^97A67%\nMSIYB/+,XCE!X^0$XI0E(A'GK5S0VFBPI\\\\P]Y[MQXT;L>^DEY6,W;K]GW15K\nM;Y(DRO><.((0GP=O32\\-1:+I\\?'Q/RB*`L,PY@PPJQK8]6H6(P^O996I\\9=%\nMB3_J&9F-G*/[/3T+JS@&*S\\"2\\\\]*8=J/TG'3IQTLT/L>[MGTB(,5B<G[W46J,U5AB-4JA#;NZ?:M?2K!>W+NW#."AM+#P]`S@:G'(2,=G`[>]?MM$2GV_C:^V3)K/B12(21S^L+/O"!5?^Y=G++GUBC8L7JB`W_LK2$V+D(RVXZ'OOHK)\nMWDFDT^;8X(#Q[T:%W0]P#G`;,@\\L!N\\4J2DU?%>0PG\\/,)C%M&'FAS[M"E4_\nM#4H#J+USSMH!`/P%Z3B"=+I+NNRRIJ]V=K;02KL-KD"_#E7:!(4"6("J6WJYZ*>NDGKCG]TW4?*TP:%!#`@K\nM)G^K_*QOT3]ND3_Z,`.P_*(`9E$#\\YI\\/OFJX>$\\LM,5),4(ID'4+-A3R2**(`A"1`)8!(&O*G^FO>\\YYW_'C+YD77\nMC1882B)%L*D#\\;XQ3`5:..9+U3)!J67,>A>1A04V1[\\,Z4$7VM_.&N""*01(\nM`.1$/L^4TZ?+&!LSG?&>%*R\\B;[>,K1\\&4/'!Z!9$K1B`07;]1"2/00D("3'\nM`U6AK54Q_Y;3IW,XVE_$"Q,NTH8'GKDX-)##L8R+9`X8GW:IH]+M")$6^.FL\nMQ0-_-85D`*P6$`A`'(!FM2*I3K^#'$:6$GE((I:$R\\E,B6)":4(@!F40A\nMTYCND.5[]HR(BJ+"4Q7X?2).!*M0.SZ.XYDA9%(%)!%`((!$>,DE!)HLA"V'(\nM_I6``T"`SXX%[@D2O?\nM(@`G`8R*X(5:$`$@PE2T*6A-:PX,BX&3'6RM/HB*TH:GK'9`X@&9")!)"@JQ\nM(`H*?/XZP/1$69GD93%6L3GT'#.0#:]"FJ=P10HHU(9*,U!(%!*I@^4"?O%M\nMB(`B`1Y30?@X)`$@0C+1%`@54P:@>V"*@M%`.ZQ``Z!30":`3`@DDH5"-"A$\nM1#3$0=#-0$T@`Y7R%<,#58M8$!U#@=5`DY29R*DT!94NA"34X0OMP/)Z8\nM)8!?!`<$0?@8$P6`\\*.A&K5*,!A`7$`6,,(4>+P(!*77`$2A#)5F.95&4!\\"\nM.Y4KQUN#>1V\\,)VUP?D]^.-5X%P_0&1`)00J34*A@$QJ\\/-^$0'1>LL`B98`\nM`$0UBP7+'@#*CU:(L,Z4"2`0\\**%33@$75J&Q]6U@,@#"N%`B0T?30H^.M\\_\nM+X3\\JTHVWAPTQDL.P`28$M#'AV"J"B!+@$((5)J!2BN"0JJ)3%3799;S5@':\nM.ZIA5-QX7]+PE8NV#HDD#)!V,=#K@^.3(,7=)D",@^-)'`TMA:Z$@-$`5`H@40,!,3)<$QJ>D>U&.$9\nM&SD+<$]#%*;M*6O77WY376&XC:9./SYO;>V+W_J_"7PQ^28[<=^_`J^X?A$(2>!5#QWZ"2S33P,A>:8.9H9?];O]-3[-BXFC\nMB-590TGPLJ&*0$2!)!EHFGH%LNK.;&`1&8C(3`C3$54U_3YGI#J`%(#="-RS\nM#9^[[)90:>OR.T)!Y=YX(?WY`,=N_^)C$T*3>($(,([#3:=6248@<<4'EZZ#\nMZ6_C/M^_V;>_6,=+JH"JB(1XR`_?DAM!@S&L@(0,.$P+%$Q@B1W:#Y?%6($3\nMQP_B<)`JMVKWJ%3F$(](:%!K4,=U8EXL@%&>(B^)K(KHM?>QG\\IJ:H#(PR]=\nMO?'?UCYS]8]3GBUG6T]=W?J]!YT%UYQ\\;J=X3=XI+*G@X4U1N(7^"Z80CXKG\nM<3Z9#-=6DX%@G:]O$W%.[/])SP_ML?&[,H03"H3'("4`!Y@N!T_@X=4$GVNZ\nM*O@;6\\QW7KY4.#HMNLY3H^DPF3[R,#>47%-P$-4IQ6E)@.>=AB`*"-<'GUNS\nMQCB^;'XN7$MRSSX^YE;=MG:ZB><$/[X&@-L!@+(S\nMH!SAL?Y]";2WAQ"K,D<7K(P]3:C$+6B,&IJI>0=?[:^3@S[CU7TC'^H;*TK=\nM^QVD#RNXH2..3]_6B405IFJCG[>1ZCWRV3>.0-L_.P!^!0`FT)T$`(Z[\\[SS\nM&PCQI):-7#UJB`-%<&P\nM^^S1GCUJYGJADIFX>_M]GTE]8>W?7"B%WJ`NV%GU/`!Z=B09O-J!TI`H3^51\nM-$O0;`TEJX2_CTLQL'U/#B,P0/P>/VU.-+Y92P;>QF5D8/>X4;ST.F)S=VL\nM$GO,./G4TUVQJSQ[ZJYSJN8`H)P'0#!3!C3IP5S8E7X%D,8`^XQ0[X)7$]27\nMMID`S?%@G3`*#4W^AZN(`.`H(Q`.EDPAX%3CG\nM`;R9^+/WG*,CJDZY.0K+X.`%@M!H$`\\M^Q1Z.J_$JK$,%FL3J#[P,&+V!-ST\nM>.[S.]^5^[N=;ZQJ]@#<&0!>`$0"R,2%*$XAX!IP.'`5@'<%L7%WI/^:_D8,8>/UJZ17GCW]IKZ\\2PZW))E'G[ZN;I2=\\81\nMA)+G.7_YVB\\*0)4!QF;Z(.4,`*49^)T*9U/X'!4Q*8ZP&(:/^*`**CS7@V$:\nM,$P#>2V/R>(D=,[3$!9SAVHVNH?E33PJILM6-U)E2L<[*R444B,[_GAPY([;\nM,%U\\%N"B@&>_+0`AZ36`F=[?ABCDH,9T-G$+M&(!AC3]XE3PYP_PC`?/>,`%\nM/-=F3JDU86=O^*)'I(@@Q#12[<_:E',]RZ%HKFF%S7#Y5`ZRG=[_[/ZNKS0L\nM65VX[.3O@)F?<^A*Y>X/Z5,WY7\nM/P\\P+(#(WL]`8AO_P."[CROK$\\.#7#G5]:2\\A6P'HEP`@].>[7/PL&C\\%U=\\]:TMP`@A*`&0!>)6AH\\.L5H%)3K13-@HLL^)D(Q)29>CEC\nMW.`38([-D40SZJH;T'>(7X4UK1_@IW6Z.I]'R![?]\\+^?=]J:EIKC8S<,R?Q\nMT;^"99Z!B;0#,WC&3N#^A8/58!_!@9F;/^.0"$50!@(#PBU3):&_R:\nM_EC&$C?6E:X(4O1+-M(>QQ`%$%'/N5$J@C%K4B'\\CL5+EEXA-G#SLR=[T>Q4\nMLNGD@1?B9XN;=%RL=1,@KY=A,]]I;?_OPYL\nMV7HYXS@`N#CQ=TS79B2TL+\\OD\\\nM3202X?KZ>B$:C6J*HI2?>.()FD@D0@T-#4(D$M$`E#W/8X\\^^NCKESC[A^+%\n:)?N;V/\\#IU/(G@5P#>0`````245.1*Y"8((D\n`\nend\n 6585 customers_zoom_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```1YTE$051H@;6:>90V9Z>G:-9M$NC1"2\nM480%DB"L,AC;V`KBV&`P9CG.<6+LQ$[(R;%CQR;&D-@X)&`2;,`L(C;@V)(`\nM(S"2T`*S2*/1K!K-3$_/]/1>55WKRQ\\CA"!&GF&YY]1YW:?JOOI^?>^M>N^>\nM)GB?%HO%Y+:VMA#'<7*I5"IIFI81!('U]O:^WRG?E]&Y7IA()+!]^W8O?6:;4]E,O^&5"KU46I^AY&Y7KAE\nMRQ9HFA;?O'GS+\\[_^,;-`;\\??7W'_I.]NHT;LYF9O;(LHUPN\nM?Y2Z3QL_UPOKZ^O!0#;X97IGF(W3_,114&T('34F+EVD8^#$1*4:7]:P8OFR\nMI[/9K%TJE3Y*W:=MSBETK.\\8-,,JK(P7S4O6WR*'XBT@C@:W.`8SR>&SZX?Q\nMT]>FLM-TG26*/6>;BHM$(H(LR]!UW2*$L%PN]]$"?.?Z5E!1I>U+5YQ;%RB[\nM?D4$80XX*L$!X-IE=-0!=UP:JVA>RC4)VS\\SL/+3=Y_VW[9M&R8G)V-KUJS9\nMVMC8^/%BL51[^(TW6%=7]Z/'>H\\\\4EM;ZXV/CW]T`!+/\\,__V>F]_+,%"RO"\nMLF)GCC..6810`5YN"$YQ`A)EWH85]?4F2\\H<TWY[.>V_7#]\nM>1^[3I($[MB13H2X'#AK9FDH$DV-CX__5E$4&(8Q;X`YU<#.-S,8_?G'6'EZ\nM?+\\H<5V>D=Y('-WOZ1E8A3%8N5%8>O8WE.`_?N>=MO84T8N7S>\nM7AY.9C:NNWR!OZH-K)Q%.7D(5Z\\[`LW))Y>OZ<"FIAP^\\]4'/CH``*B[.0TV\nM]"UGZ&3YY\\:Q7UTK&&/5EEB%8NC\\G;V^O6RC9;XN\nM_<2?/[Y;N559=NE-H=K*UB.O[^*R8B/8VKMJ[[G76//H4V*3[53F'6=#&KB8\nM`2_@YC5I$&TL$U(%G94SYQ!75UPM"7.F'W8Q=<0?JOBV8$_MI=JH\\Z-GD_,&\nM^!,OLB\\C'@\\CE]-;/OG)53^X:$O[)&AXSO&F7V`$`1+>K8?3*+"9.#Z5%D2B:@"A&(_&5A.[/3X2^ON^RR%3=4)**7GJ`=K5CB\nM]Z5?^P5B';D*@7,EV;O_P`!@3`0@5!P].AH:'\nM#9@FX*O1()4PIPLP!-Y("0!*@5$6I<[/E!]Q16+_WW+\nMYO;+3N89BJ*`8,,:5/:/83K01)AO,L%X)<&8=2&5^1:;"'\\'Z6"L\nM*01(`.1X+L>4P<$2QL9,9_S8)*R@C)'@(2\nM$)(K`Q6ABRIB_BV#@UET#13PRH2+E.&!8RX.#F71G7:1S`+C,Z[@J,(VA&@3\nM_,*M(C2$\\2,)$#P@J@"E$(7!S`\nM(.:Q&C\\+P/=/C:QV]FE+#4K%#.-H57;`X"<$,**"J"$'E*9&Y?%F1RD25JGA%\nM5#V/6A84P6C[%;V)PU?J6#KD&@RRXAL*0*@$U;"JVP!;!&1^\nM-@HBS\\,OGB`*W5#='$*N2IUT5-'5+0*$*8)"$9^.]&.FK1:*F`.Q2A+G&)=-\nM$+^0Y4,)-3W>_LPWK]__B1>WXU=//?+^`5:LK$`R;2=&RAD)'C=!?,+,C$<4\nM2Q$!@0_L^7R:ZW=S_]R?@",$%QW?)5D!.+G7;-T/4Q_*_G:\nMP&;?OD(-)ZD\\*B(2*D-^^)9\\#D(PAA60D`;!#"^`\\2S^A/;C93&6)^+X`1P,\nM",J7C'O4+ZX$JO5N[!K*X?*M6Q%-))`R/70571B"X%XDGW1C51HF=&_P<+<&U8NNN`(-%1%,3&8Q,I+%:&KF1'4@-U9;9[E5=K:<9W:)XUF7\nMK,C;@\\'@[9V=;^P*^(/OV7?YHQN:_N]01)9^"GJR4_+5=D25RD6E^*9DL620\nMJP#R!`"!G0(EE,.&3\\31T1%"K,(\\V;(RMHL*$FFICQJ:J7FOOW&\\9EGC&N[H\nMON36_:DR=]/5%V,B60+G.C!L"R(S]`K)2X=%S@SPL'2]+`'@WAP9K^\\9'"EW\nM=W=?QG'\\JR_]]HFY1Z#UFPZ`QP'`!'J3`$#('6?@$H#Q``2+JD38_I6E9,.Z\nM9A3*I7K=-FXPW#)&G"(,9B"X+(RR86,BG45]_6](C#G33UC;ZGG``AO'4D&+S%4\nM'!'EZ1P*9A&:K:%H%9$ULTCI*:3U-"Y1KD;9!@D&@8:%B#2W$T$4J:HJ[ZEK'ET)&0##[,KT;0"/.;&=\nMX[O%`[X2RJ:%HEE$WLPC:V2A61IW(2^>869CG4*1=*HCDX\nM"/?$,#Q+AV64(!@EP"S#U]P,.QB&((FFH>OCAO'>C>)Y`"AG`%#,EH&0]&"V\nM'4Z]`4AC@`W`!>"=,3I`3Z83JZK/PZN'CF)@*LW"3LPQ;`\\ERP$#!\\)1N(($\nMWO,@5R?@M2U"D5'<$*``Q"0$6+`XP9L6^`^#4T6.^\nMB:F&,2SQ![!O?[=[3OMZRR[IL`HZ)%Z`RUP(@@?5[T=@Z6+TESV,R0RE7;]C\nMFT9[`2K@O5I>[P^`"`!//0C"%`)>&*/_79<'4\\,?((OM!Z&XJ'4V3?\nMP4.D5I#0[G$(^D(`#2&H"/"B(726=$Q),C*O[$%S[YL@`%S'?D]5JQ4\\YV@S1K3+1;)/W++UD6U:OIA7&9+__RN3J=446X/[UOIZ^L?5D]K?[\nM8``AZ6V`V;6_#9'/0HWI;.)&:(4\\#&GFU>G@(P]RC`/'.,`%/-=F3K$Y;F>N\nM^H9'I4B*CPW=K[<]+"KNE2&?+5<$"K\\_1]]W?R:3F^PU&_PC$W`&"TKLC8$+@\\PA(&MCY8(X`EZ,#\nM^H)['\\;A/N"!E;-^%[\\,,+1`)'=PHA")Q23-7R7ETC;L$8Z71^3ZX8.EAJ>P\nM+`A\\HQD3]WX+T]F^'8E4[BI%<5K%]>N^_Y-#W:/7KUO=]>"^PWAW]W1^```@\nMS*XZ!9]@B3(MF#ZQY-!3*U&)!Z)Y('Q&NRE&9\\,O1E0E=GQ-$``J`@`,3_"\nM-0$L:PD7\\XI<6MT2,N-U02#F`U?I`V)^`,!#HQH60I\\:,/&W>=,:3`P?1JOD\nM7KIA_=JO[TQ.BQ!_AV$9@XB@1&8Z5YM:+A;,\\XEW>QW:?GH=`.`E'7AT\nM!OB+%AP13YXZ=\\?C;#T'(4.*3AR5NJR/+6[,2="S)#OD)KTUU?7-AX\nM_,8-ZU[YQI[]L.<5@;`*1'P,8161A!_-=7Y-[S$L,:@4SVL.(I[P`V&5(0H@\nMHIYV$P01/,]/J0+_9%BA3U:&`_MX`DWPG&<"E'NR(A+>Z0\\&79_/]X[;?7,"\nMN"),[!X#=T]8[/G(V%&TLT+]\\O:%W_O-GOV-5YY*I3E'@.]\\",S4(50O8!6T\nM$7V'!`U/'W1[5R[+.S$5\\3+@I:?)@AMO)IE+;F<#;W&'PQ@>'MZCJ.HKIFD1\nMV[:]Q8L70]?U6QS7);JN>Y[GX?GGG_]_][SA!,.O6\\C,@$G^5N7,A<'!0TMX\nML7Y]6WWEU^X_.?V5]3S<.0,XN_\\%JJ)LKJRJ$I6)!A3]OH5;MCCQ/WSOON69\nM>#5J:Q+H4)55_-I+*Z*9@>FW`(:'AP$`75U=#.]\\';W[^Q^UW^:!K]?1GKTY\nMYUNAD/K@@H"0U03G%0`>1^81`4((%P@$4K(L=P9]"A^-1OKS^3RA/#>AB+0K\nMZ/=QD4CDN.,XC,VS07LV^\\DT0SRD0..XY\\XWS6T-XWVC/QK2>W\\B@=UJSN//\nM'DU-3#Q45U?'1R(1#4#)\\SRV8\\>.\n:#PWB;/9_KC?X%D$"^&0`````245.1*Y"8(+Q\n`\nend\n 6586 dispatch_order_ok_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```11TE$051H@>V8:9!<5W7'?_?>]WJ=F>X>:199JT>2L78C\nM"YO88`,V)JRV*38;0\\`!AY!*$2`&XY``AB(5.S9A*82\\B2/)K1-OM,3_?T\\MZ[6S[T+!(2_F!4^<2MZKJW[WW]^OSO^?_/\nMN??`']H?VN_5Q&]/_-./Q@'.]=Y?:CW">7#>XSSXD\\;._8[Y4Y[Q-!MU*C/3\nMS%;*8K8\\.=UL-G?]ZE_?,]ZVXWIJ3WSM[`/X[,/C`-=YSU>%0)YFG#N#H=XO\nM@G"GKFEC:-1FJ59GJ$R,Z%CK_O'Q\\2\\>'3CPC5Q'87;\\@7_XO0`$OSTA!7B/\nMR*6DN&A-3F13`F/!.H]QOM5;AW7,?1;G%S]@'%CGL"Z-L5GBN$"YW)YZ^NCX\nMCO9BU]UX__*QD>.WK+KVXT-'#^Z'??]UM@`('!`JP8IBB+"&9F2P`IP4J$`B\nM@P!M/8F=,]YZ]-S86+\\`REBYV&<5;6G%3*7">1O6I]K:VMY\\8/_>4GER[,;U\nM6[:?.'2V`"@)PH-2@F8SX2M?>@RM'>,3EH,#AE=>O9ZW7;^.X[%AM&F)M2?6\nMCLC,]=H3&T>D';'VK>]SZXU&@[#:Y,:+4RSMV$A'1_M51XX<^<#HZ,B'7G;K\nMM^S#G[[V;'A@L=?:X5U`1Z'(=Q\\YSNYAS38C"`.)$X)8""(\\D1F[!^_['SX;'I!"\nM+`"04K%OP//(;XXQ+$/8OI1@39&T$F12DISU2$#@$$(B1"LJ2`$"OS"6`H1H\nMO;M.%[MFRERQ(LV*]I"1@-?_'.Q_=@_(0#*DL@SW!K"V!*N+R)4=\nMA$J0#@294`+@`7!X+_&^]=WC\\`@\\<(H;B$TM(L/1TAN4E!97;VG"!(\nM/Q?[SZ0!@?`>*03IM.3MUZ_E,BV0G5E<(<-+>P*4@IYL0%8Y$N-)S&(?&X\\V\nMGMC.SRVNQR>-5[<'*`GY?!L$:8(@/#L`YCT@!*1#R=LNSF.LQ7L'-'#>,U7V\nM@"#G/2D+QMK%T(G#"(\\1#AL(C/18Y3&!PWKF0K(CG1;438!2@E08(D[+2+\\7\nM`($48(UA:&H2D^]`F\\4=+4].$N0+:"=(+-0K%302JS*MG8YBHD8=D^IH>45[\nMS.PT4=A!;$$GFE>?FV9Y3^^`G>X[W#`D(J'!+G\nM/=J#$1(G`HSP:#2)$U@4B1=H'(F#V"MB#XFS@"=4`B7%@M#/"H"31>R]I\\U:\nM4LTZC4:#8K&$"SP364]G!T@E`$DY5(2I%)EL"F,]C::E6DW17LQ@K$,;Q]14\nMAGQ'%H<@B@)2PIUB_%D$,!=&I4`(T3JU&*F):I;3,T0:T^B';IJB%*ZI8%8\nMT]46TA4L&B_DV0)P4B(#CW<>9RT]RE/*"GQ:,=Y0="X)D+*5QLK9%&$J33:7\nMQWM/'"EJ=2B6"ACKT<8Q.1'35BSBO""*8U+"HV1+/6<3N.8AKU)I.FCG$MKU3*,6G=G*-0\nMS/.Z,K0%$$4QFWLS=`1RP0-G3P-2X+PX\nMG4*!I6(5`LBD`X+0XFQ+@)@J264OIG&<9C2.;@3$9I9T?BFQ$.P\\9CC12$C"\nM9HM"2<*R0HKEP4EYX`P4.KSK,(V9AEBS;4TQ"(,E>%S4C,8*RPOUKW_VZUSW\nM5]>=V0/S(H:Y.["U]$I'IX/C#DQS&.T\\IGX$'>VF/KD/82?0K@M$E20I$'B'\nM3"N"T//V+>U4;)'.SB((29(DM(6MS6I%H5-%?-?M=_'^F]]/9;QR;KXO_XY=\nM8[M>=:1\\9%D@`W]^]_E/KR^O_^*.E^ZX_^C`47UC\\`H7/X;\nM+KIZX]4?N?]+]W_QC%'(>['@@<4H9$D[A?>@:T-8/8&-&VCM<%*`AM@)/)!H\nM00BDC,+@^,DQS5B<$)]$H=Z.-,OG!#P[.?+"XXN_NB;WO6F_C/F`<]\\./6G4*A=\nMP*B%QN23"*>1*DV2@)<"KT'[UH^31)!"8&R`4HZW;^F@QND4=F&+K[\\R\\^QZ9S-+"\\NYX&]#_#0_H<8KXQ3RI>XX44WF!6%\nM%7MF&[,SIP$0\\YF8TRDD8HNS$"5EI,RA`EH`%'@-B1?@(-:0`HQ1&"<8F&PR\nMR^D4*LPEL$!)GTZGL3[+&U^U@0>'OD`NS&.LX>Y'[J;_>#_66#:OW,Q'7O&1\nMB:O.N^JN(`K^I=A5+)\\&8!$)IU'(.X6S8$W+2Z$7)!J\\D_@$M)!@6AY(/!@;\nM8(S@)\\A1^D_TLZ*TDGM^<0_'IHX!\\/+-5_#Q\nM5W]BW[:N"S[4_Y/^'W2?V^U*RTNG1Z&3F^^I)/VY_72W=\\LVF^__?=DNS6=:T-?C8`IU`H,:22%H6,!NW`>4$<\nM"X23N!@2)?`)Q+$@9<':`.-;%&JHTRE4%(M:.W]='_WUQSE8.40]J3-MIPER\nM`==NO(8_O>CCW+D_4?OD]`N*KSW_*]_^::^?MW$!P!O?\\3Z"(%C]\\0_^Q`C5/(8,R$H$@G2\\1TD80Y@A260@Z\\3J+#;I1-H>R17)A3+:P\nMC/'A,KN.:.XLU-,>LL*W2B]*2KI7=_A_?NI^IMTT,3$JJ[CBW"OX\nMRQ?F?__*]]#_5S]JU:V\\?/'SX74N[\nMECZ]S0E9GRN`AL@[5/(@M/XE06820\\Y6?>^R927AW1^-\nM'CO*R$E1J=560&Y5J\\C#?#UH43'S$QX6GJ%=X"L&Y\\JM%2%04C$S.86?\\\\#&\nMRR[HO*?\\,"9E4$+1G>GBYAVW<.#18PP-'B4C!6$0$/;7E+;NC6%U]AL#2M86\nM*&2,00CAG+5Q-IO%.X\\Q&ITD)#K&Z`2M=:LW&C,W-D;CG)NSU9_4^[EBEL,[\nM3U_?6IZ__0*"5,C3>_?SZSV[%]9ZNKMI=JQAS]@>TFUII)#PHM35_+@X9^R9$D);2Q::Y+$8*P#O/,>?8J(DR3!\nM&(LQYG`+@%\\@2+-1IUXMSQ6VSM!\\*]PN_$8H>5\nMSJ.LR_17^GG!NHMHG^KB9[_8S:8=FWF\\\\3@R)UF:7LI;>V_@^__Y(_8?>@;O\nM!0B%5,'\\.0B\\GP&F3@%PVRU_SE__W9T`@]ZCO?)KU&DFCC(ZJ"[3`^U.J\nM4'ZN&"JDP'N/E(KI1HU,6R?EZ0HU66?W]*_8-;V+$]$)BFU%)B?W6-[/J\nMR#+B);,\\,_4,83[DFF77$#\\5LV?WS]`Z(9]O(TCGJ58-*LRT+ECX2;RH+B3:\nM>4/B*`(XYJ'FO2\\9K:E,C7#X8#])'!&&(;.SLXR.CE*I5!:,[^CH8.W:M2BE\nMJ%0JE,MESCM_$STKUG/?MW_(BR_=P8NV7,9=!_^1X_HXF21#E^EB56$5UU[S\nM!GZ0^@ZUL,:ZXCJV5[?SN<]_CNF9:9(DH5*I4.KL9-UYFYFI55`JA?=^%.\\;\nM\\UE4HDXCLED,GCO.3QPB&PN3W?OUW_N_W..D>)'">#4$0E((@9+9:04E'[[)EC(Z-LW[#5LY=\nM?SZ=2Y:0R60`V+QY,_E\\GNERA0U;MK.Z;SVE4@DI)<>/#)!*A704"OSFT"!#\nM.V?XX/);V-:U%9F2C(I1/C7^*?;Y??05^SA_XGR&!H<8&1VEK=#)AJT7'!@[M\nM7+YL2:B39&5'J8N-VRY$&X?",7AX(-'&_,>."R^4]7J]IWO92L[;M)4XT6`U\nM0X.#M7J]_F4OT]^W.AYLR\\B-4Y/C05N)TM\nM["X^]MACCW8VHSB]8>N%%)=TX8QE>G*,D9&1IX1,?VFVUGAT;'3L!]5J]=<3\nM$Q/NZ;U/+&K@A_=_%>``\\(D[[KB#)Y^4I-/IR2B*+@F5X.#^?:UKGW-$4326\nMQ/$G"X7"NZ(HVHHS'/C-7L)`8G1"',<#<1Q_[.)M?1.77W[Y.N?L-N_I=LYY\nM]XSC_1O>7[RC?D?[B>`$2S-+N51>>F3&SGS,&//Y;":S:6)LA,18KV.\nM,>9[0\\\\\\]=&]3_X"G22G!,$S5F-NOOEFG'/$/7@X.!E0T-#ES_\\XX=?O#'9^)[WEMX[40I*;`NVT6?Z'NR_MW]G',??+)>G\nM7:T\\CC0-?OW$+H:'AX]Y[^^KU^NG&7]*%/KM%D410T-#AWMZ>OYL=G;VPP<.\nM'+AP9F8FJE:KWP'N*)5*?L>.';]Z\\,$';QH?'__`OGW[-I7+Y)7[^6T_\nM_VRM5@N&AX=?7ZU6V\\OE\\M/6VKN,,4\\$P9E-?=9JS+9MVQ!"H)3*-!J-WEJM\nMEM1JM3&EE)VK5:G0B"P$U/3__.]Q[N75OK[^^G5JL]\nMFZG__VWTQ"B#SPSV'1D\\\\W\\TSD=FB_U)#P````!)14Y$KD)@\n!@JG_\n`\nend\n 6587 dispatch_order_zoom_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```0=DE$051H@>V9:9!=1W7'?]U][]OGS7M/,QH):[$\\DFW)\nMEH1MV2:8X+`X*2HF!@K*V`F4<1FR%Q6(`T42`R&5*N**"RHI$DQ,52"+X[`$\nMXA"6X++!&`S>)$N697NDD30:S?[F[7?I[I,/;Q;)LDUB]"$?Z*JN[MOWW7?/\nMO\\__?TYW7_AY^7GYF8IZ_L"GOCL#L$5$KG*"\\@)>!"\\@I_2]?Y'QTWXC]+H=\nM&HL+M!IUU:K/+?1ZO1\\_>N=OS93VW$C[D7\\^^P`^?=\\,P`TB?%$I]!G&^1]-:/C1][YB`<^->S!4#A@=`H-E1"E+/T(HM3X+7"\nM!!H=!*1.2-R2\\4Y(E_K6R0HHZ_1JFS>4LH;%1H/SMV_+E$JEZP\\=W%^MSTW?\nMO&WGI2>>/5L`C`8E8(RBUTOXPM__@#3US,PZGAFSO.FZ;;SKQJU,Q):IGB-.\nMA3CU1':I3878>J+4$Z?2OUZZW^UV"9L];KXRPU!Y!^7RP"\\?/7KT`U-3)__H\nM]1_YJKOO+]YZ-CRPVJ:I1WQ`>;#"O?=/\\-ADRFZK"`.-5XI8*2*$2!0]+_0\\\nM])P06:%GH9<*O<03)9Y>ZNG:`,T@7WUH+T6MJ64'T9LWW;#IW//^`9%]]YT-\nM#VBE5@!H;3@P)MS_U'$F=0B7#A&<6R%K%+F,IN`$#2@\\2FF4ZD<%K4`A*WVM\nM0*G^?W<8YL>+==ZP(F/>4*HK*$ZE&>D'%*84S1:K5<$\nM0?;EV/]"&E`H$;129+.:=]\\XRFM3A:[E\\8,Y7C<28`R,Y`/RQI-8(;&K;6R%\nMU`JQ6QY;O1^?TM\\\\$&`T%(LE"+($07AV`"Q[0"G(AIIW75G$.H>(![IX$>;K\nM`B@*(F0<6.=60R<>JP2K/"Y06"TX(]C`XX2ED.S)9A4=&V",(A.&J#,RTL\\$\nM0*$5.&L9GY_#%LND=G5&ZW-S!,5!4J](''0:#5(TSN3Z,QW%1-T.-E/N>R45\nM;&N!*"P3.TB3E%_=DN6(#838OU,J@C0(T]=`09C+D\\AFL$[H]1[.98:"2PSI/:CWS\\SF*\nMY3P>110%9)0_S?BS"&`IC&J%4JJ_:K,IK2C&1PG.>^I12MI)0&N\\0+.=H(R0\nMB36I$WJ]F$X[)BL1J?6DUM%LQ&1LA/40QPE;:QD*1J^`,&<-@`9D=4:"H#^[\nM'1/2(21VCGEK"&.SI`&AW8)4!!_VHU#<Q0R*]FT3R'G/C'..>J]"-ON@>I3J-&*T($CC/O+[3B*Z79ZS-D.UO>]TJC'9-/>$H5B+AC.\nM40KT$O_56=3`BU"H;;+DDONI=?^=G.TA]2S6*ZP3JG&"]0I'@#@A2#V%),4M\nM9(A=CA_86YAKYHDS,8F#)$YX[T"&=2M1J.^-LP-`J?X"8&ECL$HAV"P'.;+O\nM'@X>KY#/*(SR?;'C"`R(]X2!H*VG&'KR64.U4F#GKIN9CZM4JQ4\\FEX4D]6>\nM8%G`6IW=1"8L+\\!6*=1)+.W`,;L(Y^WY4ZH%CX^G,;DU=&:?H%#=3'WB$4KE\nM`>9/'J942#$Z(K(QQ^:ZS$5=\\G$&)XHHBKAX),^`@0"/]FGPD6LW*1&1H:&U\nMS,_/OGP`1BN\\J#,I%#@:SJ"`7#8@"!W>]06(;9(T]F.[$_2B&=)N0&Q;9(M#\nMQ$KQP''+B6Y"&D;$#O+:D4UFF#AV'#VH>)CS8WB2I%VSG*>&)VY`R@W\nM2^J'035)DD$"\\>BL(0B%=^\\4WE?^Y7/_5P`*058HY)>C4&HI)`[Q\nMX*)I$B=TIGY`VIM!=`6LD/H^_^)$$0"!,SAQ3,SUB.BR12L.[=_/`P=/L&/W\nM3EX[>AYM9Z@OS'=FCX]-1HW%:F=^>K,1;M]T[GF[+KG\\BL??].:W&!%YR!CS\nM>+?;X?=O?OM/`:!!1*UX8#4*.;+>(`)I>QR7SN+B+FGJ\\5I!"K%7")"DBA#(\nM6(/%\\[T3EG-J(<H3[GEO@FFO?S,Z--40I#DY'6%&5XL#`VFJM2K)V1,V-\nM'>96"P@HC\\6XKYC="8Y*=ZP"R+6`,BIU%H0,&4@^[<7I1/T29+\nMDH!HA:202O_A)%%D4%@7$!C/.R\\L<&*QP]UC)[G^+==RX88A.G%*,_$L1A;Q\nMOI4EK=8;H0FRZQDXMXP[\\00G9QH\\/+N>!IG7S%MSOH;]9TSX\\P?44@+3G$FA\nM=NSP#J).G3CV)`G]FBY719I`G/;'K35$J:(3I8P=.49V>`/;SAEFH1WC14B\\\nMD`T#.4AG(<+S=X[#-KF\\7?3BAWU\nMR%/-:P*CR00&IY4/EG)!HY/2:L1,)076U0;)-E(R0P6"0OAK^KSJY_"R^+\\#\nM``BG4,AX0@73#FP*?FG;GB0@`9!`HA5B(;6*!'#>$&`XIZBPUC*8"\\D:H9;7\nMA$;A1!-HC]%(8#0J#'AJND,C=0SGEL)9[R_![+E&CWQL_\nMTP/ON.G]!$&P^6,?_-V-[__C3Q37K1T2!`*S3"&+L1J%(ENL$E(B"`L$F3P$\nM-23-XX*U&%?`N`J%,"8_N)[IR3HGZ[!AW5I^\\NAA]E]P`;5BEF&$#&;I^-$K\nMT0:5SS"2R[%U?0$FIS@VO\\@U&S<1S1Y@[XDICO_*M=ZN5@'@HE];SJCV[,,K3B5(2)^BTURT8GTL&\nMAO6:6H76S!3)V`&>ZZ;4]ER!MPFVVZ8U5'.5X=K[YHK%SU_TG0?YT'O?V@=P\nMQV?O1BF5$^'KC<;B-4K\\D@;Z-#J%5/V=A\\C*_5,5LSP@L/(;E`+QY')9JN42\nM/WSB*=JE=12'UY$--:6,IA#V:R4?TENLTYF;Y>B1(Y0J-4KE`42$,`CH==JD\nMSG^SW6R]PQC=OO-3'^]3R%J+4LI[Y^)\\/H]XP=J4-$E(TAB;)J1IVF]MBEWJ\nM6YOBO5^R54YI3^_WL0GE@1+G;]W&B=DY)IZ>1!<':>JL\nM&KML_.J8G>/'QIDMYMC^^'/\\@K38E2LS(65^/)]BBF7$^RE$NLM;\nMN!4`N7P.K;5+DM2)>+KM!L\\^O9]+=EV$"0(.'SY,+I?#&(-SCE:KQ>#@(#?=\nM=!/-9I-CQXZ1R^706K-_W^-X%7+ASLO(9'*K^A!9B5#"LK@A[G58G)NG49_G\nMS==>RY,'#O"56<=(\\P`;CSS*U1=>3;T>4:]L()O/]W;NW.F;S1;?_OH73LW$\nM"B]L#X*@&@0AK68#HSWKUJ]G:GJ&;=MWL67;A=36K"&7RP%P\\<474RP66:@W\nMV+[S4C:?MXUJM8K6FHFC8V3"D,'!0N[GWQ/&C7QL>6K.]VXLRVW==1G7-6DY*0&-QGAWU<4JYD*8W\nM//;$DU_^;&W/O:6Q)^2Y`X^L4NC;7_\\BP"'@X[???CM[]VJRV>Q<%$6O#HWB\nMF8,'^FL7[XFB:#J)XT\\,#@[>$D71+KSET%/["0.-31/B.!Z+X_BC5^X^;_;J\nMJZ_>ZKW;+<+:E=!V>C'&Z"\\IU[DKBJ*K\\[G2!S']W:[W?NOO_[N.&[>IA0ZE\\_S^+ZG.'1\\\\M@WC/[X\nM:XOQ'Y3''MVI,QNO.G_C\\*U_>WSV_:\\VN!==3D=1Q/CX^.&1D9'?;+5:'SIT\nMZ-!EBXN+4;/9_`_@]FJU*GOV['GT6]_ZUOMF9F8^<.#`@8OJ]7JCU6K=+2*?\nM>>"!!XCZD_=N5#_9Y+K=[KIVNYVTV^UI8XR;\nMFYOCTDLOI=OM4B@4BIU.9Z33Z72:S>9L$`1^86'AI]E\\1KGRRBLQQIA.IS/<\nM;K<+[79[9G1TM/WZZ?TDZ/`7R_H-FUQT[(/[N@??ED5^)_X_O^+_7_D?]SLI\n1ESO!"%``````245.1*Y"8((7\n`\nend\n 6588 execute_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```+?TE$051H@>V9:XQ=UU7'?_L\\[OLU8X\\]'L.78GOL\\3RN[WON/>]S]MY\\\\-3-$+_F03[E+]TOY]R]U_JM\nMO?9>ZYP#G^@3K4ABM2M6_=;HZ.COS0^\nM/CZT:=,F(Y?+$88AK5:+:K7Z,T=''<>Y+TF2?;5:[?.&89Q>D?&Z+K5:C;FY.7J]'HU&@VJU2JU6Q_,\\\nMPC#<&8;AE^;GYW\\OE4H11=&R`9:50@\\]]!"V;1-%T8.;-V]^Y=EGGQT<'Q_'\nM,`P\\SZ/9;%*M5IF9F>'BQ8M,7KC(W.PLKC-/X'OT7)\\@",^:IOFU,`Q?%4(T\nMI93+`EC6"@1!P!MOO,'$Q,2OC8R,##J.PUN'W\\;U/+KS71K-!O5:C6:]1NBV\nM6)=UN?\\NQ6B_@9DHOG/(YS]/ZRV[=NWZMFF:WSQTZ-!+0/*Q`81AR,C(2#:*\nMHJU34U.<.7.:LJY22"4D4F.@&,N:[-V187S3;6P>JE!("U3803N7F*RZ_.BD\nMCVW;QCWWW#-QZ-"A/B%$76O]\\0!XG@>@&HU&TN[,,USR^/TOWL66'0\\C[#R&\nM(;`L&],TT2HA";HD;AV%0$4.$]O*C+WATOV;L0OK,5)%,&PT&I0$%8$,49%'.150L3J\\\nM>5;CA_+'ERY=^@-;MVX0Z_9L,7?OV/E01=A9$`(!"*$1+$1')6@9H",7%7:1?@OI-S'B\nM>8(HKN_8L?W?O_K9.X/N6V=:7W@BPW^=6EHV+7D/5(H%=NW4`YONW/OW]^_9\nMNRTX]3U+1BY&U$,8)EHL`%@IA!`(])74"=M(KXKR&^C80RG)@?O'^V][Y,M_\nM/7?NZ-&''^7)?"7;AN#_%R!GQ?B1[QG-(]U<>7/.[AM"NC6L3`EM&&A#@&$@\nM3`.A%=JOH[I3**>*#GMH&8&2**496#]DY<(+5LXYWK$2@E)ZZ05MZ7N@T^:K\nMO]+G1!_\\\\S>]"S]NI?N&T6%'2Z^!\\ILHOX%RJZCN%'+^/-*MHB('+2.TBM$R\nM1LD(8:5U8>TP>5>\nM$B!#AR281X9=9.@21?&/>H%^W5ZQ]54`0$N$97M:1G^A(O:@U:"*`Q`&:(E*\nM`E3DD@1=M#`)I;CLAE)'[GJV)W%;(0\nM8JVQA3#.A^HQ63^W^Z=_]23KF*'2MQ8=M9@[^:^FWCQ=U[\\\nMW%^>T#K<)E8>OY4`V,`H\\.F<;=_UP)X]=W8N77AP<./(@+GUESGQPS]'34X2\nMRTF4@KZ=SS!TQZYLNU/_(ZM3G=@FQ%'@!'`4N`#$'Q=`!MA;+I<_OV/'CHE=\nMNW8-M=MMLU`J(2P;5VJ*O_B[8`DRI[]'B@@Q_B3V[C\\@E2T1-;K%>[;?_7AG\nM;OKQP0T;Y.SL[&R]7G\\]CN/O`(=88B^QU&9NQ+;MER?+\nM8V-CQK%CQ]B]>S?E3:-X(D4S!&_-3@K&1M8/WHO]Z%AZG)\nM239NW&B,CHZ6<[G<]B`(G@Z"8!@X!LS?JD-+68$MF4SF;Y][[KE]+[SP`DHI\nM+E^^S)DS9PB"@$JEPKSC@EW$%@9WAI#K!P\\>W/?$$T\\P-S>'\nM[_M(*3E]^C1KUZY%QC%NMT>^;Y#1M7ER9AG_TGG\\ZBQQ$%(V#:36]+KS>$Z/\nM@8$!WG[[;1S'(4D2E%*8IHEMV_NB*/HZ\\.M`;[4`/C,\\//S4GCU[F)F9(0@"\nMHB@BBB*JU2K#P\\.XGHNJ7V;-\\#!&NDBW;Y#\\]GLIAPGM\\3NI^C%^SZ$],X73\nMZY%.IU%*!SP#_N!H`%O#,EBU;TK[OT^ETKCKO^SY!$&!9\nM%KV>@^KVF%]3H=#?A^KVJ"0)*$U\\N8H_L(F+ITXP<_Q_,`5(*>GKZZ/1:%PU\nM]*&GL@SP#/!];O*\\?"L`_;9M;R^52M1JM471]SP/K3522CJ=#NE4"J?1P/$"\nMTITV(O!)?)]X;@9W;`?=ZBQ");A!"$"E4KF1W;N!?J"V4H"2E+)\\_OQYI)1H\nMK:\\"N*Y+.IT&KKRIL$P3K].AU^F2Z;002A'Y(,NUCL=E(8H")#5.7JSL_3JE[DT?8DHBBF52HO2YQK*`^6;.7=+*01DE%)T\nM.ATZG>85MV[9Q^^VWHY2D/36)E4I06A,%(<'<++USI[`%9+,Y\nMFLUICAPY0JUVP^!F%FS?4+?2C:X%4O_WHF59&,:5X?W]_=QWWWT4"@5\\/Z`U\nM>1;1:9`DDBB,<"]=P/W@.%(FY'(YMF_?SLC(R!4'#`/+6AS'5"I%-IM-+=A>\nM,<#`M?Z7S69)I:YP34U-QT\\ST-*\nMR?3T-,>/'[\\:B'P^OVCN=#K-P,"`L6#[AKJ5%%I_K8NY7(X@"`B"`*TU[[SS\nM#DHI!@<'"<*0]TS)@RH@"D(:F0RN8:!=EW:[S>'#APF"*RU/*I4BG\\\\S/__S\nM[D$(P88-&YB>GEYO&`9)1[O9Y+WWWENTC]+I-,5B<='<29(P.#A(-IL=Q'%=O`T;.*%\\#`27+9O6A0N<.7,&UUW\\ZB27RWT$\nM((YCTNDTA4)A0`AA<8-B=C.`#+#F6C<*A<+5/?!A)4G"ACV'OC5ERIB<\nMG9UE=G;VFE]B\\OD\\Y7+Y(W/$<4P^GU^SX(.S7(`LUSG*BL4BU_NJHI2B7JOQ\nM6J]+VC!H^3Y*7?OU2:E4^DA!TUH3AB&%0J%_P8=E`Q2Y4@T_HD*A\\)'C;[$T\nM/=^_:3O9U]=W=05,TR27RY'+YK[/P(5P!TRLV\\HD^T?7UOZUP[0I:UH+3`````$E%\n&3D2N0F""\n`\nend\n 6589 export_database_write_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```-]4E$051H@>V969!=Q7G'?]UGN\\OL^R)IM(V0$$)FD4`0\nM@W$%VYC8D-@$.PMV'!PG92>5%U/&54DEL5/V@U-^<.&XC$-<)*9B;%[4.>?_Z_[.\nM]^_^+OQ__!\\+:RW66L]:^P%K[SZ>3>^/';2]DK\nM?P[T6FO.:C;>,0!C#*TL)$\\7K@VZ]T5/?O%HLO<.$)M"73ECB'<,0!M#,VM0\nM4V6T,?@4G)=:SU^_*WSL!ZX(/@0X9P+AGNV#O[5S+].52%P\\T>?W%OR\\*\\A)\nM@8=`8&'QD4((K;5)HB2)CAPOQ9^^Y9OZ8Q^_^K4`:8CC>A@,`)[-<3C:M[FB\nM2M_=7-S^M3Y_^#9K;5T(<5H]I_\\/T#26G2\\Z[OB$U6Z[5:\nMJY%,90-:ZXY,ZYPQ1AIK,=J@C2;+M%)*M72FJX'OS^;SP?3H4->!D='.LB>]\nMSCV-ISY_N+5WLL?KQV"P6+`6"S1UC9PLJ"U=.WZXNK#QSU*3'/)EP%(@2P(\\\nMO/LH0@*606O,M4;%UPN=;L?HH22*'94IM#$+HRT14F)IETAM#"I56&WH+`;D\nM>@U.;T+LU$A$TZ8VLMIFHI%51-[IH,/M>AU`^ZZ)B0'8TG7),YN[MWW!D_Y/\nM`?-ZB%,`#ARK<:Q21DIY@3'FZ[/3O[C\\^+&CKB,E^7P>S_=!2`P"X;BXGH_G\nM^[B>CY"23"GRGDOG0$HI>(E$-!!"H(U&6XVQ&H-%6$"($Z(MBX:V>`;:9I23\nM639W7SQ[Q?"U7^GQ^V\\'FB=#G/(.3)K5,FLF)FA&\nM$?6Y,M)UR>4+Y`M%"HZ'+QT\\/\\!Q'`9[NPCS^]B3/L>@&$,:CX:JHHPZ1:@Y\nM:=3MB=%?/#?45)6CX4OL+^\\:F@Z/?/7:E;^U=:)C_:W6VIE%B%,`YNL18:2<\nML?Y";\\YWF=Q\\/OMWO\\CQ^1)1DI)I0Z%81#HNCN,@I<`:0Y(D#/7U4/)W\\V+U\nM,<8+$QQK'"7*6FB3H6V&Q2(0"[DL$'`B]T,-.*41IS:H"[IZ0@8&!JAMZ^?:K5"O5JA4:\\3QS'6&.(X\nM1BE%RVG242BB5T8\\.GLO?<$@!\\I[J"8E0M4@T3':9@LY*Y!"(H6+(^1B\\8*%\nME,F,0AF%L;K]I84+AG:8CZ[_Q+V;^RZ\\I:7"/06OX_0I!%#,^20JHQ):C+%T\nM%GS&1D<9'QM#:TVJ,I1*42I#:XTQFH$>GP=K=]",6\\R'>YF+9DAU`H#1%IUJ\nMC#$GGB%=B>LY"+E$'1'M6?4(N'KUAZ+K-_SVMU=UKOVRQ\\!TX.;2Q\nMA/%"VN0\\BH%'(?#HS/E`?F%$P7,]II)GV'WH.5*=4D^K[3S6H"*%+P)6]*YA\nMO',5>5G$",V!^3U,U0[C%5\\G00BTRNCQ^[GAW)MF/SCYD;_L#?KO`&(I3O7=\nM,S(R;2V)RC`+GP)#IA1:*72F&.[MY(G*0QROSY*9#`3H1&,BR]95%[&][SVD\nM4Y)7]LQ1:T:L6K&"R\\X=X\\[9O\\5Z)\\^`126:M=V3W'319W:]=\\T'/N_+X'[`\nMGL[,SLJ)%V]AC$5EFB1)2>*80E?&\\Z\\^31BUD$*211ENYG/=^361^]Z\nMCK#5HJN[BT(^3YQJ"AFDL8*@?6=K##HR7++JW>93E_S1?1>/[;BEGE9W^_[2\nM!K8L@*7"]SR:ILQ4>8HLTV21PDU];MAV$V)?#P\\__PQ!/L]@=P\\]71UXKD-W\nM=S>I34@2#4JB$XV3>ERW]3?CF[;??/O:WLDO6>QO;&"W_G2_WY@>]PFGP_(X`T36G%,;W=7=J5X@U'P`*>ZS!;\nM/TXKC-$MR]7GO9^QQB;VSDS3.S!($L=8P&B-RA1%D0,@RS3A;(O-Z\\_CL^_[\nMT]W7;K[NEL`)[F.)Y<(;Q2F8#_[H3K[RAQ^Q+S[^B$E:33IR`<7`PW==I!1M\nM]^?$UA#I"*J-"N%\\Q&CG.%<.?Y"IHU4*75T88S#&8DW;8]-4$2<)]4:(P7#%\nMUJNX<>TGUK;!%5K=\\Y-J/4<@&&5U1Q!J-R11&:[`&\nM8PPJ3:G5:]3#!E>MNA3Q2L#=W[['E*K5BNLZ;YKO9P20Z^KCZ+%7>->[KZ9\\\nM[#"_V+^+P_M>H*>OG]'QE8R,CM#=U47@>;A2D`]\\TE2Q9?U6MG=N8^3(47K*\nM1SDR,LFA8B_U:HURM49IOD2I7*):J2*%):Q6V+5[-\\+WZ>CN/FV9/&L`:RTJ\nM:N`(R?#J#4RLVT#2J%`K':.K5G'PY<,D2;JLT5\\2\nMH!WM96ZF#:F0Y'N'Z!\\9)^])7#0JB8A;+9(HHKNC2*DYP0^G^_@GO\\&.N08?\nMSHW0?\\W'N7)P@DPIE,IH1BU:K0B=98"ENZN3^?D2!PX>6I;P-P%X;6AC2)3"\nM6@?/=1!N'I%W\\-P\\\\^YQU(9#;%CQP^$&.\\G`S*LTFR&-L$$8\nMAA1R/JO&Q\\@%`85\\CDJY`F`0(OT?!7A-6-M^(3--/:GQ,WT7F3I"U&KQX8WG\nM,G]CQ"./KN/P`8GMJ6%L3*H4UEKRN7Q["2X$4IPHT18X$]-YFP`60@K)L\\V?\nM\\4!Z'[)L&1-K(9]CZHBALS'(V/@T7@!)W,YMQW$H%/(GA`OQQAZS;`#/D4@I\nMR;+LM!<)(6@V4Q[V<]Y02/]`2IPL7&`MN<`G\nM%[37-5)*'*==-ATI\\?+YMP^@7JU2J]=9N6*%]EV'4P9)@%&&'[^049*?XMS#\nMH^CR7HZ=C_Q")=?>P.;ME[$R/`PGKN8L^`(P2.[6GP_Z:$0:39&.Y!R\nM%.-,,EZLLWHD(HK;*];%8S%=<F6$,2)S0:#4JE,HUZ0T91%"Q/_A(`EU_S\nM&_S^%_^:^^^ZPWGFYS]E=-4:UJZ?9&AP@.YBGD-'(NZ8R9%IRV6U*AM76;9L\nMWT10<-&I1,HB2=)>O!F38;3&&HW.-*U6BVJURGRYS,S,#+5J!5[6[YM\nM,V`=CQ>>W\\6Z\\[>Q8O5:I@_MY?X\nM3$ST8(W!FAS6:.(X(6PVJ3<:U,,FY4J%4JE$M5*AV0S12N&Z#L/#PX2-D$JU\nMBI3+ZW(N684<-)F&7/<`6W=H[#V/`0KCN&Q9(+`IK-)H\\_\\>3"OMHL)65Y`"PT\nM/(RU))DF<'V>F.GGF97KZ)ZN<:EN,+["2T>Q0"&7(Y<+"/Q@H3.$\nM08CDS70L"T`*>'4FY1^F`\\I6LN'0+.>,)VRY9(#NGAQ1U';9)$E(XH0DCMM'\nM$I,L`$DAR`4!ON?@NBY"MF6+USKQ\\O*')38T[52P""EHA1G?WP>'@@[ZGG^5\nM;9TQFR[J9GRBA]>G;%L4"+D@;O$!4BYLA!8;6G+!R.0O>T+6+CN53ID!WW/H\nM'0B8G6IR_^Z,_RH,D7OQ.#O<)INVY-APWA#V+`9,RI.$.VWAQAJ.O3K#GGW[\nM<5V7?"ZW3/E+`#SWGR]STT;%=YX=T3_I&$9.U;@LJ7/NI&3SMI&V`'TV,RZP\nM6%*E:$418:/MP'/S\\^T&5E>7"IMA(I9I!*<`?.U?+;?]*#H_?G_O!6YDN;Q1\nMYUVK#)>\\9YS>GGR[TIC%J?_EWM@L'BE\nM4FG.S]?^KERN[/)\\[ZT#?.9/;N5;CUPG?N^Z?_R#9[UC:],]&>,R>65TLN_E\nMGL'B!L]Q^O.^XTA\\LKR'2@.4*J!4BLX6^J191I*F**5.\\H64.(K;RX=R.9HO\nME:?+Y?*CM7KM[E;8?"A?R,>/__2^MPY@D7SNO7_1V:>.;?TU.<^QCNBEG0],\nM?^&CG_OL_-B\nMDL0RBJ(3I31.XB2.6F$<1,K5_^[XSCA]_[^&V_K`_\\WPN6=_`7_+.._`;1\\W/;1=!W6`````$E%\n&3D2N0F""\n`\nend\n 6590 group_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```-7TE$051H@>V7>8Q=U7W'/^?N;YTWNV?&.WAL`@P&CV.;\nMS28V`0/!A*`D8)(T`:5-E*9IJS2*4-14*C1*VH16+`UJ0IN$+"IEST:_;UO7???7F=\nM!_.:U[SF-:]YS6M>\\_I_*_&'7JQ8L8)RN6RO6[=NR<*%"U.7+4":-?,'CDA>DPC#Z,,!Y^`\\8,0)\\<+ZM4\nM*K%QXT9&1T>;5ZU:M6G)DB4;B\\7BRFJUVG;LV#'KX,&#)W;OWGW[T-#0CSH[\nM.QD?'W_C`&O6K.&!!Q[@(Q^YX6/+EB[YA*$C!@\\GNFWG;9JUXX=.VAI:6%F9D;T]_=W+%JTZ.SV]O8^UW67U6JUXL3$A!P=\nM'=T]-S?W/T$=GC\\W%IRZE*`H,'PB9\nM_>:)/J.E;=WBA5V[SCWW7&JU6F;3IDT?7KUZ]4?[^OI6EDHES_=]AH:&V+-G\nM+^/C$Q^,HGC#U-3D#=ELSM^W;Y_8OGW[7RQ;MGQKM5IAY\\[#'#LZR-CQ08SZ\nM,!1\\]FR]2IC[,`3_3=<\nMM?:\\_O/?2=?"4R@4BX@T(J.F$+47P^>'@KOO?^2)_1_^T+6$47SCIDT7?>62\nM2R[MZ>[NL2I5G\\'!H^S;NX<7#N_#GQUA9JZR)(QE.55J7VMKJS!,ZZ^JXX>6\nM+K%>H"AF6=F>L.6<3JY8W\\U%ISE4ID?$L7K'\\F7+3MG=U]?W[)-//OG&*G!J\nM3Q-1?/SL+WSRXJL6M#DDY5&L7"M"U='U251]FO-6Y=P++KGX^C08>_2HU0K)I-5EQ-VDL8^LG$"&95TLY/<7\\^%/FV?O][LZEN3W\nM'SCHZ;E#?.JZ]70N[,6Q!1G'P!$QRA\\EGMK/Y6>/\\^V]RBH4FPJ/??.S'9_:\nMMGCFX@VKT$HAHRJ&:2$,"T,8:*WH;!)N/JY)I_>.[U\nM(_2])V?Y[ET?#69^O?,'AI,FR/"=.@F$K$T0S9T@J8Z.A]7)ZQ;?^/1]8L&Y\nM//382&*JB?Z/O6MY_Y;+KJ%IP4IRI4YL-PM:HY,Z*JJR.#?#WJ.3_J.[9__Q\nMVO-;SKOPG*6?R]G2-.TH>&4Q>HL*YK>@4&4?--&X;W[RR<<_HB+<.*,(6%86#8XN6UQ(W6*;,3-1K9HC$Y6)]9DUQRKJR%J8\nM=9.)RRY:?\\9V'4XC_7$,(1`&&(:!"J=)_6%T.$VJ(M:=_G\nMH['W!4GU6IWX=PD5N*F31R4!TI]"!C/(N+[+GQ[Z0'O/Z6/?^??S=,^?O$X3\nM?_9RZ%NW@HGAL26;/[CUSWN6]U\\Y.G#?PKV[G_&L\\1G1[$S1C&BNM5I?:6Y?\nMZK=VMP[<<]."KW6K\\OWI61O7&Z9]NIP]O,!0-432BC9,TMI8XS1EA$[3R'&]\nM$WIZ]S?4GH-'9EMZI>W$#Q)6WQMK?;DP'=*XA@S+)''=CZ+H=D^,#C_]^!$N\nMO>TUO3?2\\M+DJ@MM)D8FNU;V;_UZ[]G;KG=LT5H^OL,N=`AA->7)M>0\nMBS*&99N>96<7R2BX9+1:&6G+.']M*_\\(LGZ9(+5%FJ`B'QE,(_U)$G\\<&NWU]_\\-E&>V0P?256L4`R+""K$TA(S^02?A577YQ\nMJ-<=('J63.G,]ZRR#+:V\nMI?\\1IX45I8NVGK?UB]M7;[]).?+]XTP>(V-''Y#^\\3/2^@D,7<7+\nM>F1R67*%//FF`EXVBQ`"I21)(E%)0JIB(TGT3Z_^PH\\/?_G!A>;;.[^_Q#4K\nMYQB62VBV,'1DW>]Y;O9'HX^(VH5+2E:8H?2-R<`)V^?(\\4PL"R+4S+Q+(L0N7@AQZ[7U@N!J:N^.3Z3?Y'\nM!YX/%^U_7K4VVS.,#\\^@U#Z:(]7L3ZS[-[M[?+QMS]^T^ME"Z[.,4EMPB$HZ\nM0ZF]0+`DPV\\\nMNOK>'2,\\,U3DJ;%3:?_%$99G$CI=DTG5*AX6&YID:[YI07,W8_LDS_U\\%'M#\nM@K71I)AQ*65R%#P/U[9I^)'X=LB<64-J22T&/&V0:7,@Y8!N-!JLGX%EH4Z`UD*00*L+9-FJ#\nM;8A5$PC`,DTRMDTB)8YI8ILF3N1@86);-B7/S<_&Y29-VO#\\$L"7_@N`%*@U\nMN(Z='`#5DP/@\\T!BN6[:_*M?35)JET19ARG#0-DF9&W(.U#RH,D#SVH`U&*P\nM3-#ZI'D)08+V76K36<(D(8AC*O4ZB91$4I(HA0;L:H94:P2P(-.92>JJ.4XC\nM0L+?`KQQI8"1BR+5M'?O-&8N@8X;MXP24@238=5)"PG)*Y$B]3,DNUHR;:\\50`)Z&:P,I""4F1$A=0H\nM4DM22!3$*42-B%")P!00JT:4@+Q1IZH")!;%)ALO:?5GRO41I;1^"0"MB97$\nM2!T*7A-A(LEY1=S4,^?",KEB#FX";GYK`"T@/9`@8W)&%26@%B102\\"/P#,;\nM)Y^D#8!(@1]#J"B9"4%<0\\HBIJ/IG#U[]R]_VGG]BLM'PC1-L3\nMC)LC5C'5H$ZE^AO":A@4&'5)US*'@Y'"C!6.\nMK;$,W0Q67HAD5O_O-^?7U)L`$`@!6C,HA/R&UG$*BDPFC^L84#T9'5,TFCE1\nM)P%._A;$"A$KVK(N1@*VE'BV(4Z\\6)X3*/E6S#=V9::Q=5W7'?VOO?W[OW?F"JH`DT(:HR-.7/$+YB:KSW>4B$]7[XR&]#KP>#(6^:W\\"-\nMG3FCNR(80G-J'N>S4X"=-YP_';@]K0&QIY?)[)D:2#;1@*$)8E%2#`>8\\`>F\nM?`>1'MA/1N#H<;C_0?SE+^:ZLH2%#1`RB)7C);]P*UM>?`.F%3!91DX34PP%\nM2_5\\(EA"53%53"?S=/([8W7Q81Z]^]^P,BX@;`!Z9U[_,Q`8%L+TK$POG;!+\nM8JQ7(7C0<:2_?(CF]`*FZ30"Z13(4R0F<].$69I<%4VQGJNBFM"4T*1,;=Q.\nMHS-3I6KYPYT-_N!@-3T?_O4)&((XRBK)1WH#YIH]B[,9-P&WK#SY$.5@!9\\W\nMB=4(P4BI!!01,(V4XR%9(Z,J1GCO)]HQ8E4B&*9*K$I2C`BU&?57G@*+3XIP\nM]V`MS2.L?>H6TN_>_A,0^-BW%&`(?![@$^\\0J-@OPLW#U2>GAFN+9)V-C/HG\nM`"-D'N\\=Y7B`#YYBU$=3#AA./%4Y9CSLXYR08H7W@10KLBRG*H:,>LMTC^Y%\nMQ&9\\X'U$Z9CQI\\#*F?S`K<_MN3K!["%$=L6B1^_X8V19H-EJTVRU:+7;..\\0\nM`4T5(H8/CKP1,(M`(LL#(?,X!\\6X3U7TZ*\\\\R6#E(*/N,5JS6YC=^I(%<>Z#\nMXGBS"`O/B6(_.0$(#5EVCMO,TKB_].C$22-ET2=6(ZIQ'Q\\$[R'+/5@DED,L\nMC?`N8K&'EBL03T!U%"V.H.4)L#&-IB<$1]Z:(F0Y(FQ`V"K/@W!=$WKV>._G\nMX!_>">+XB@B_VE]^_,VQ'`"&I)0(IQ2T2V/Q^NL];`IWX'G!-$>(?S_&+WZ%X6\nM]WP=U9*0>;(@:+F,%4]1]A[#I24"79P,P$8TFR!4.$F(*+$J@%2+382$]H3F_&B3'N':6WM)]Q]Q#%<`6S"DT5*564\nM18&FJHY,Q9@4*XQ$2A58I(Y.)T-O`C%"WJH3HO"BT!3^\\=;U<9VU"?D`8"`L\nM(H)IA5G%<.4`H^YA(.(\\^"`XT7KN!55!O:O](@54%4U*NY--$MK))&?U_QN$\nMO(F(@'#>N*?>!]9-"&=-X-;;X#/O!N"8",FT\\MVCNYG9?`EYYA$GB#.<4T0,\nM<8II9-`?X#WDN6<\\+HE5I"PJ6JT&J4JH&J9&52FI4LS`A;S^/[6-WDLNPFB]\nM4'K6!("3)G1"A!*T%<==L(01DU*,LSAK`J.?6@-P:F?9%:$0H97B"+-$BB4Q%I@EQ-59\nM.029F!&$$"B*B*E2E16Q2F198#2LT*1D(3`<%,1**8M$[@UQ'I%J2D0:]=M?\nM(`U@#!!*!#2.,8WXX'`^(,X1`B`![PV1>G,7@A""!QRI(9@:JE9'KE2;3[N=\nM80JQH51%B7,>I-Z^GVF$N&3\nM"-$T@D4$Q0ULV(9S]?[G9.PW\nME&(T1C76&BI+1)2JC)1E12Q+RG'%<&24E3`>1V)5$:N*87>5\\>K!%8WE7YK*\nMQS5:<GYM@)O-PL@8)@A,S5><#7-AXR(\\NE]A%GQ`I2\nM](ST(JK.99SHS;#65ZHTQEN?*8[0#@\\0LJ6&J=R08O5Y1+IGPG-.&OCL^\\"4\nM+.1RI?,46;/SQO;LULP%(03!ASKJE$6!640U,1Z-$91B5#`NL;A:C!5H^N<;Z)6)S!%R7-W*IE!(`1%&C,4K5_GKEUM[MV_\nMCXM>O)T;KKV,W"?*\\1J#[@F6CRZS>*AB97@%%\\H:V_7.6Z;GT^V&[%\\/T3D1\nMT+H:D8O(R\\3)6ZOQ6CGN'4'"-H;]/JUV0)RA%A%)Y`V'`_@0(Q&[E!+)+^5I?)EW+G[/G[E\nMK:_GLO/GZ?5/L+9ZA-7E@S2EH.4CGDBKE;CJ8MAS8(I#RZ^*_6Y9^9`##[\\`\nM!.K1QL@P:^?MC>WF]););E,HRP)Q1@A&"%"5"E38W,7L/;#&U.9-7'[!%OK]\nM%5(UIM<]1L,5-"AH4"*QP)O2:`OGS^<<3!=/W?-4?[-S?N\\+0F!2SYHQ:!C@\nMLC9Y9R-(?3)KM0*@B%/RADR>\\3"[C<.[5]AZ_GG$6)%2!"J\\E#B)-'VDH06.\nM$:(ESN4L=`KZ<6LGSUL[FJW.=]?#=.X:,-8P^A@=D8"FA+C$8#`BQ8J\\X?#!\nM2-$A3HDQDE5"45;D0%&6Q%AA*9%[3Q4C6`560AQAY8BL,T^[V6"#FY$LST.[\nMW5H7SCGZ@*'*;N?EFX:\\75PX51MJMS)$/"$#Y^L]D(C0R!Q1NW0:FSFVM,R@\nM*#"MZT)9ED'N".)PZ@CF,0NTIL[#,4]NC6(X'#XU'(Y?&`).P652F=D]X-\\N\nM$E!-B"FCT0A06BU/THB(4A05(HDFN[APRV4\\],.]'#QV,9LZ#JTJ^L.(1"%S\nM`N9)FM%JSQ-F+J;H>PXO'CUTX,#!/;,ST^MC.EOPG_HM*"IDY8@Y,V;`@W@T\nMU96W5C/0Z62$`*VFI]7RS,WES,TU:.E^+MAP@FV=-O?<]P`KHS%KPR&KPR'C\nMY!C%P"AEI&R>]L8K>?QH9'%9V;]GYW\\]LNO.@X/!^LGXK#/Q6ZX!H)4WY6;G\nMV.&<>U7>FA8?LDG&+8@QDE*B*B.J2E4E8DQH+-#1$6:W7,?CCQ[GP+%C],H1\nMJA'O!!%'EK5QV0('%BN>.`*+^[ZG6\\??^-@KK]JT\\\\O??'!=7&=M0E;W!F9P\nM?$!5]FE*>P>KAZ_P^87XX&CD'N?K4Y@:.*DKUE"7X\\-X/UOE"[SZRC?RHT?Z\nM'-YWA.FYC.&4IYTY7(+1<$2OIQP^]!B7N^\\=NGKCXL[QF;+8.1&HD]A6,:XT\nMX\\:L/9^R9A--"><`-SF@4^_]1V4$4T*`E.JS+Z/[V>0.<^V6ZU@VH[1T:O/G[7/?=7'_WA/KE*L%WK5!?/-8Q>;,8L)A*R\nM3LB:4\\084:UJ&VJ)$$`U@2A9)J@F\nM8DI@AO?@77U\\/-E?$I04E5@9F@PO4)61A?Q2O;9QK7MBYTYV;[ADSQWW/?BV\nM+7,S.V_[_@]9?!;.=9WXQDNAU>`-*?%W6S9S8XS=N%W[KKWOZ]8F!L^V!\\^/X$/OZ-6^_04M[2:O#8+T._!TF$A)2%K\nM3I$UV]25`N-D`792>L1[CXC@O,-,<%(?Z)T(PJ38E4X6LFK1I*\\O+&A?/\\YQ[8_>T;6WEZ-#Y=Y_JQ/C`S`V6%;-[$12_:"BNK\nML'2LSO9U8R\\#`EFC1=[JD+?:Y*T.6?-I"8T.66.*T)A"1(A%74ZOBAYQW*4:\nM]2A'7'%KWSO.U]Q\nMS9X/W_.CVZ[RPFX]`X$-<_":Z^'^O51/'H8CQZ`)S$PJ-./^"\nM>0T>YQW.^UIK+5@[_\nMT8X3CW6ZEUWTH7=?G$[#)QS,:W>GI7G&J":RHVGX12>_YK/'E2X65R$NO;MF_-J9G\nMK_Q&?@&[GSCZ\\;\\_=/SW;_"D=?/`U>\\$(`+[GK%\\_VNC?M_7U^"/MX6'[EJ-\nM?S$[V[YMQW2V,LCB'8`Z>9Y._?^7\\=>7SC`PE]TTXUZW/8T/_N'.X9Z;&]C[\nAPA13@````!)14Y$KD)@@MTT\n`\nend\n 6592 industry_add_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```.Q$E$051H@>V9>9`<5WW'/Z^[9[I[9G9F3^U*UF7)M@[;\nMDK",9,`R"190X<:IHB`NCL(A0)(J4I2!).8P<8P3RJD*(2G`JAP02!544BY<\nM`9N82BCC&&QL#/B0)5GG[L[>,SO3T]/'N_+'[-J65P)A!?_E[]1O>OIX7;]/\nM_W[OO5^_@9?TDE[22WI)YR'Q0ANFNT$('&/88BPG@*3\\Z+FU/3`&P!A0$$*,\nM*VWYT.P+\\\\-Y8)#8CX%.5%PO``2Q8\nMF5'<^]M4KO_C4/0/WB24_7AJ"9[<]LLAK)*$Y0J[W_8.QC9?O-]8OIP8-ED/\nM/GZ.$.<'X"YMLQ0;M_%W[J7ZN^\\/1:W_)JOM38DA?'3+62`$6*U1G8@P#+GB\nMM6]@U8:-S_0)Z\\"?G`.$]_P#-]W^CV2Y+`S5JN\\H^84-)X\\=,8_]XE%G\\M2)\nM^\\)RY?Y'?O0_*P'R%.((F^<$VW?1_^9W^3/?_K>/V<662(6X]<&+1;+WB%T)\nM8#0Z[H`VA(4"5UQU-7F:[Q^?JA_(C?A#5W#HPV7+E^*S`ZR(@$%@$`4#'[1P\nMJX7;1H:';NT?'+CVHLV;5C@!8&6*[;9[%K<)+[Z4H==?Y[NU_ANML7^>&,(?\nM7K0R$E;W`%0NRZ_*=K!H:>8VQ'.AJMH#@AO#L`"LB\\,H??YTLS1@<\nM&:)2J[)F>H&)KF6X-<<%0V6^>2;\\/,-V>Q$PN41WVA1+)6I;+_.SGS[T,9OE\nMA:X1M]R[B?BUQY;8!:`U*NZ`TJANEVRA@=MLLJU_@&X[VC>59@=RPP<<`\\*9C_PUM0(Z@BADD.U&F-8B\nMJGX".3^+3G-\\K1E8N\\[/3XU_E"QW,RMN_LY&XGK*4@H93+>#27/BD\\?IUNNH\nM3.(JS;9"@5RJ?5-2'\\@M'W"%./2.@N5;\\E<`X`AP+#@N=LEDU$;%,>GT].G7\nMBB5'9`;-6?3)(Y#EN-M?SF)IB'BQB3[R!%5E"_G$Q$>R+$=9<;,KB#7+G;A#\nM6I\\`;1A\\TW5$Q8!H?`+QDQ^S749TQ7[^:D+SOF_&TM`ZO7\nM%+QB\\2/&VL]671LBL-9H\\OE9'"%(WOI.;I]8X-,//,)=83^_V'L-4:G,Y84"\nM0XZSS\\"!5+/%",'ON,^Z<'8``4((A!"D,S.D\\_.T#QT\\`P"]_.]&F+$-W-4P\nM//'T,3I11*W6CR[7N-\\=8,XK,;H$D5D^YPBJ5BFK&O.P:P_?GVTQ,3F)48:^\nM:C_)R!B_&%F-`^PL>(P(L<_`@<2P!2NX=LD%#^!;FP06JBZ\\[JXF8<6AN&6Q\nMN\\J=FB&+),6DR05A9^?&XN+U4SN%4Q2@+#@&!&RV,D=82U0HR,&`M\nMY7*%U2.C?CXS?96P!L<8U-P,B]K'&MBT>1.^']!HS%.,VGC68H$*\\#(A<+#K\nMCF#]$)$^$X%E!RP(:Y?WED\\\\LSW3L>>0.)069UBO+.,.K+Y@#0B':M%C333#\nM^E+QF2;5`S19<:[E[&>"*D@4#PB_B!B5(Y=)<-`H8#5AMQ:?J#:W%EL6@>F/;VL#A^G[)7&U`EO1J'2E`*^BT(%[L07CN,QUH\nM6=9:2JY@;;F(E@:E-$9;'E,)GTHF6+5G']]X_V?8NF$K"]$"<]$WXN6-?HN;H2P*'G5-R")(;C3Z*L\nMP6B#M09K+2;K8I.((._BNH)GIV+`6O`*T#^*EAJE-%)JC#(<7YSCYL8DV_=?\nMQ^<_=!O"$1R=/DJ410A7L+&VD:23T.PTJ8Y6&3]ZDEC'=&R7OOX*5V[?S4]\\\nMP;\\ZDUS_B+6[F["P`D`L`T30C:A+P7<*&U&.(4XRNDE*-Y/42A=R@W>85>G\\\nMZ9W86LS`,/>.[F4ATR1)2C=)B;HQWY\\^RLCNJ[GM#_Z23&7,17-T99>.[%`4\nM1:;KTSS^Z./<=]]]O/?C[T:2(46&%"D=TZ)M%JGVESB^T>-?BK+TPW'"K$B+\nM1\\X$T.U`TB'*).U2">&XG)PYR@X\nMX\\UQ%CLMNDF&"&%BC=@R7K-O$4/<0?\\*``7=")((QUJR-"-.$B;KTQAMJ)0K\nME$NEI5)RI00":PR+BRU.G:HSTYBCGI_@@Z^[@;&A,>J-.K&*B55,:A)2G>`:\nM@<6BE48IA74,\\WF=PZV#-+,FIJ`(RP6$"XXK$()";M7OF[J]DP'F3@?0L@>0\nM=A#6)>K$C->G484\nM[;1-K&,2TR6W*;E)\\:U';P;JE2XMN<#)]!#6SZEZ)7*IR%*)Y[DXCEC.UAU2\nMJ5>(HKAK90HE'6C.XGC]M/*8),TH52J$0=@#"$)$?I8("$$N%7,+3?P@I)4V\nMV+3A0GS?IQ$WD$ARFZ-16&$0KL7Q``V>Z^%Y'KB&_EH%:\\IH;67^;?M7(4BEIPZC!B[0[R7.'[(4&X9$%(&(8(>4;_$0*DTE@<\nM@K)/W.APV=!%1&F$'_A<.GHI6FL0EN5/P?.8.%S'8AD8[.>RZFXN6;4-:VUO\nMY+,6JV&RCK\nMZ^/5KWXU!Q\\^C.=ZSSYMH\\F2C'4[5U,M5UCH-"CF'EE!#196N_[I$)Z+\nMYSK"]<1S1B&7WAS@.N`(^AS+ODVC",?M/77'06J#4`K/FEZ^B*57,F'!<1!8\nM=JP=8?7P(,5BD?\\]5J79:=)*6C@MAYU[=O)G&_\\4X?0>F+(YA4*!R<>F^:][\nM[F5RD$`]EN,MU6"NZW1TT\\KG=>(8IVMTVL^DL3S4.(@H&Y:1T;(..:+!I=!-OV?U>@D+(/?=\\CZ'+BQQ:=2]I\nMEA.U$]I+MG"R1:PZN*Z+YW@(1XS+>W7ZW'?B!O!%K*VBE:4UCT@CW""$9?.#\nMG@4E\\$/P?1`NU@B,!6-!:XNQ@H+C&29/7#*=S%QW:.*0JP)%1T0D1&1.A!-H\nMRGU%5M6&T26-,;UR)5<9S4Z3+)?$:4H[2VBG"8GL8JPE]$K$Y!9M'UG_^>%>\nM"HE'`)@'!5V%0?`7-(118:9%2D><]RS))EBD`\\ER2\nM)"E*:MKM+JU6#R+J),C4L&-P+T)[U!M31W5LOGS!;PWJN3O:9U@7^O]4!.SA\nM*9[FL^1\\"4E-9IJL*"D4/!Q7T(F[](_4N/*J*Q@:'<2ZEL7%+MIHN)MP[XGO1TF4WK+CT^L>>^B&X\\!I!?UO0#-`$6CP%&5:.+S2N@0XRTLV\nMD,@N1SH'.9C_C'KY&`].W\\]\\-(]0'CN']O+.+3?S)]VOI%4`+EPMY%V5N<2K.QDHMI%(N$08%"H%+X!+L5?3J?,%]W^X2:^N+B,[=^<0``]@`/\nM(7@C+Z/"C6[%?4.M5JV-#8RP>F"4D>HP@Y4A!DN#6&LYM7B")Z8>:\\\\L3M^C\nM8W-[?+]^V-_NV/E_CDZ[[8L'L*PW`2D!_;R<$F_P`O?E0>"O#?QB4"QX(&RF\nMC)Q06CV,Y+O$SD-.B63^;SMGO-V+#["L'<`L@MV4"!ER`Q&XKL"Q3HH4C?3'\nA,A:KA+4//G\\!ZG3]'R,#]?7;5S!:`````$E%3D2N0F""\n`\nend\n 6593 industry_back_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```.V4E$051H@>V9>[!=57G`?VN_SM[GG'ON.[GWYD%,"`D)\nM>1@J@4!D-*&=JA2Q4UM`JJ-5:VV'CHI.I474B<*4/JQVJHVO%FVG3CN,S*@X\nM,#JEEJ((Q!0(22#AON\\Y]W5>^[T>_>/:Z]UYOOM[_O6\nM^O;>\\*J\\*J_*J_*JO`P1+W5BO?S=#FK?M5QQ,;$/`7Y5<*P`(,F#S%\nMV_T&RC?\\<2!Z^FX1TGPT,?A/7OCS(8S,"4IE+G[KVQG:L'&_-GPQUJPW#GST\nM'"%>'H"]U*8))FQ2V+&;RF^_.Q#=/;<896Z)-<%CF\\X"(<`HA6RW"(*`75>]\nMB17GK3N=$\\:"/ST'".>%';?<^172+'?[NRMO+Q;<\\T9/'-?_>_@Q:W+LV0>"\nM4OE'C_S/#Y<#9`F$+4R6X6_92<_5UQ6JW_Z7FTV](1(A#OQXHXAW'S?+`;1"\nMA6U0FL!UV77I%61)MG]\\>NI@IL4?V8*C'R@9_B$\\.\\`R#V@$&N%J>+^!`P8^\nM.SC0?Z"GKW??^1O6+S,"P.0))FIV-&P2;-Q*_V^\\K6!W]WS$://Q6!/\\U_G+\nM/6%4!T"&+62K26#;[-RV@Q7]@V_4AH.18A,(WA.<'6"9!_8\\]`W2)*5OL)]R\nM=X61F7DF(L-`8Y95_27^[<7PLQ03=3R@LQS5;N(5BW1OOJB0/OJ3FTV:N9$6\nMG[YO/>%5)Y;8!:`4,FR#5,@H(IU?P%Y7J)F:^]TDA[,-.^U$$=_WS?\\\nMSL?^X^[G!I\\10B9JH1MUY-2S\nMY',U5))14(K>U6L*V=CXAT@S.S7BMN^L(YQ*6`HAC8[:Z"0C'#U)-#6%3'-L\nMJ;C0=.09MA;7D>]V$]87T0=?X**-&XV,7%3FF9((VZS!:'B5!*W2:8F\nM0&GZWO(V6IY/:WP"\\?!#;)%S9#K=.YVK@ZGFO9801Z^U#7>KY4%P=A&0S$R3\nMSM9H''GB^=?L4P,BS,P8(DMI[=K/[1.*=WWS>QPX-,Z_=VW@\\>[5]`Z/N([G\nMW:2-^63%-@$"8[0BFZMA"4%\\S>]QY\\0\\MS[X"/<$/1S>_7I:Q1+;7)=^R]JK\nMX6"BV*2%X#?MYTPX.X``(01""))JE61NCN;1(R\\"0"?^HQ9ZZ#SN6=`\\\\?0)\nMVJT6W=T]J%(W/[)[F76*K%R"2`V?L005(Z61"W.P\\Q+NKS68F)Q$2TU7I8=X\nM<(C#@\\-8P`[785"(O1H.QII-&,&^)1,<@&^M%QBHV/#K]RP2E"V\\3?5HA3U=\nM)6WE>/$BJX+VCG5>_8;I'<+R!$@#E@8!&TR>(8RAY98X-EEEZT7;N'@*_\nM0)YEM(Q@*I&!7>:@QO?6$!+D"8I0/9F,>2/3Q][!BK5Z_&*7>Q,#^/';J>G\nM=)5*K!E8R6BSS@DRGCKV8\\8&ALF`(`]`@JQ763M7I6)9H#0&Z`(N%K#!@&T,\nMWSL%L*MH0(,H>-A^$=NQL2P+VSZE-K9M8YTZ=NRE/@NA#71UHXS!1[,_&2>.\nM!5,/?)]`P-IPEIU%3:_KHI7"`JHFYUXOY@=].6$?5`:[*'79N);@T.Q/F6\\N\nMT*Y6V3@<4FBXG-\\0"`0&<('!,^Z;`["Q0&?MWWTQO/E&D#GD:4=EUCE72ZIE\nMYSR+0::8-$&D&V/8]1BG*7A8N'EIH=2F)P?U`N<_\nMMP\\HP"]"_W#'\\"2"I`UIW*EU<@%*0KL!8;T#X=BG$^B4&&,HVH+5)0^5:Z14\nM2*G)C>&K28U[NAS>=_UMW'#5==BV3:U1H]:JT4I:M+,V41:A',6JD1&NZMG'\nMTVO.X[^//,A8SR3O."P86>R8NAS`HF-4V(`XA)-/(HU&*XTQ&F,,.HTP<0L_\nMB[!MP7-;,6`,."[TK$3E"BD5>:Z0N2+/QT_#6R^88]QW:/&[*S#PC(`<0J@\nM!5&+J5SP'7<=TM*$<4H4)T1I3G?Q-;S'.<:*9.[Y26P,NG>`^U;N9CY5Q''2\nMF1.G/-MXAH<"BSO_Y$XNV?(Z3E9/TDI;IXV.942L(A*3D)J8E)B,F%PD1*9%\nM1(O>_@K'-Q3XFI<4+YC$3SP://)B`%$;XC:M-*=9+"(LF]'J**/CDZ19SIH5\nM`ZBS/(`K`W.IQ.[N9[$]R3/C,TS/SW"H^2`WO?.#[-EV&2>K)VEG;4+9,3Y5\nM,;&**`4EM@]LY\\'1!Y`J(1,1T]$8HPNCS#;G:4,KQ*;QGK--=9*_I%@\nM&8"$J`5Q"\\L8TB0EC&,FIV;02E,NE2D5BTNEY'(1"(S6U.L-QL8FJ3>:U/))\nMUJ]?R[577LO8W!B-N$&X%":IBDEU3%^ICRV5BRBY)6P/FNUYCC6.4`NK)&1X\nM@:`H"@A+(`1NBGR?'C/?9ICJ\\P%4W@%(V@ACTVJ'C$_-(*6F6"I3\\`/\\H(@X\nM"P!"D$O%V,PD"XL-G(++7&N&]UQZ(])(YEOSA"HDUA&I3LA,PDC/"!N#S>BF\nMH5T,:>@Y3D1/DMHMRET^!=\\A37,+1+01!U'R$@EPJ#1:EE2GK=I$.L38BJU#6RG,%YE:F*94*K&X6&=PN(^KAZ\\GEB$@,-J@M$8K\nM0UNUN>OP5YB0TV290GIJ\\_2!!?\\%(22A-@[S5<1:&];&JUG9LX):HX;G.62^/>"?[P3/]T":P,PX\nM:(5E6?A^F0)0+I?Q_0#'*^#[SEES0`!>P:=4[J+2W4,0EU!U13-N(AU)V[18\nMV[660C/@RW=]%==S$4(0QS'-9I-JM4JCT2#+,I12:*T10N"Y'E>\\Z3*\\HH/C\nM.KBNQ'%MX12<,U8AF\\X>8%M@";HLP][U*Q&6W;GKED6N-$)*'*,[\\2*6'LF$\nM`I#A@3[*Q3)&C/-X+68Q7,04#*$(.3QQ"+'"<.6^*SGPR0-,3$Z<\nMOB&[=NUBU\\Y=&&.62L=.O^>XK%PYA`@%CF-A60++6&TUH_,7)'$&M@]^B=Z)\nM(UR;-="%`.,7.VTAP'@%O*$1\\-:!7T38+I9EXP@;V_&YHKN`MERP70K9,-_X\nM:4:U7B/H]HE$B+0S?CAY'UO7;.73?_4I;K_U#HX>.XKK>MS\\\\0^Q8H]'*)MH\nM:4C3G"3)R5/),\\YC+,[-8ELVKNUBD4S$]V31F<_$"\\#G,::"DH;&'")I8?L!\nMG-*"WU&_"(4`"@40-D8+M`%M0"F#-J)37B_,%I)VXW=_=N)GJWI7]!#:;1*K\nM36J%')[_"6]8MX]/_O6MW/F)O^%GAP^C77?>90>T`B$<`F`/]V6[0"I0T\nM.'AT>=U,YW-5DYL?)E/YF=78_Z_(.4/[<@6*AG'-;QG7%(UCL%P+UW5P'1O/\nM\\^5U<\\)I-/!H^0#VJDZ:2.,Z(XXPH2LE3S;KR)FKU>:KSM6_5\nM#X5?LX6E?V4``/0#,TS1RP`.>W`!!QS7PG%L;+NS[#;T(E/J!*5*D2,+AVDE\nM(6F2DR098922IX8=?9>A,L%CHX^=C!OIA\\MK_:GJWS5^=1X`8`;8B2'C<3RV\nMX;`!QX`EL&T+R[(ZBQF"MFSRQ,(APC0BRR1)DA-&";XILW_--;C:Y]XCWVTM\nM+C0^=M7M6[[_^!>G2)[,?L4`T"D7U](FX6%L+L)BG;%,9]\\1G=)`&X-6AEPJ\nMLCPG37-L[7'QBLNY;O,?4&W,\\J^/W-6LS=5NC9_-OW+R_CD]]T\\MX&5\\Y/NE\nMI!MX/9#P&LK<+LKB6K]2<"N5,N5B0#'P*/H^13]@H#S`AOZ-;%OQ6HI.%_7G>H\nM=P6#W0/T%GNH!-U(+9EJ3')B[OC<8KO^79V8OVW?*P_YNRRS>-?SW[6_L@``\nM5P`_`JYFB#*OQ^=*MV!O\\GRWQW5MA"`WRDP8HQ\\14MQO&N*P<$56__*+?R1X\nMY0'.E(N!)H(+*%JK1,'Q+$2,SI_1H?]:)X^^F<,O^'[\\?Y'4R4PV9:9!<5W7'?_>M_5YW3\\^^:4:2-=I&DB4A\nM@>5-++8`@TUA[(I9#(1`B"&A0HH`J6"2D,60%%1224@%HDH^0)8R10K'E"%>\nM,#8X>),E6=8VDBQI-)I][]?]]GMO/LR,;5F6,5;B3_Y7G7[KO75^[YQSWWVW\nMX76]KM?UNE[714B\\VH;Q=A`"0RG6*V5M=W<"T`G80HBA7&H^-?'J\nM_#!>7;,%.19:(WY'(SX;2>S9K:^TI0!$OT+\\0RQUGQ+PS997Y\\-%`5!"`T6E\nM^8K0?"'6PIW8_,J#JF&7TGP[DJS*#/BKQE_=A8L#&`8,`W/+%2[-;5_6F?Y\\\nM7>.>V?3+(52F*7=VZY:U_=+B`")`2>P=U^#]^N<\\T=1\\\nMN\\CUYR.->V+#RT,H"85*$V_\\T,?I7+]QEUR(1!\\"_JCT6@$8@`:=)3@[WD;I\nMUL]XHK'Y=I'K+\\::PN'^EX?0>897++']QEOH[%NS2VF^%2E6:0N^^`HA+@[`\nM7-PF,;I>Q=VR@X:;/^Z)2N/M6NK;(X6W;]T%(`1H*WM[Z9]Q\\7@R>/JF0/[C.$SIW_F%4N///7H\nM3\\\\'2&.H!^@TI;!A*XWO^:`[_E___@4]-R]B(>YX?(V(=AS7YP,HB:S70"H\\\nMVV;;Y5>3QNFNH=&1W:D2OVT*!CY=U/QC_<(`YT5`(5`(6\\%M&N[0\\+6VUI8[\nM&IN;KEW=M^H\\)P!T%J/#ZH+5JWAK-M+RSIM:WTER*%]_/5YT="RP6`\nMO!Z0!U4\\TV3KI5MH;VF[1FEVAY)U(/B$=V&`\\R)PY6/_2A(G-+>U4*HTT#TV\nMS=E0TSH_R;*6(G>^%'Z:H,.%"*@T0]:J.+Y/9?TF-]G[Q!=TDMJA$G]^_RKJ\nM;S^YR"X`*1B23,]@SL[2W]A$6`UVCL;)[E3Q20,Q\\-&"YCOQ*P"X\nMX>2#4`6R-G)G-6UQ1/_*;8QDBN4[K^(/_O,'S]_\\@A3288":GR,?.4TV-8&,\nM4UPI:>KI==,S0Y\\C2)QX;._=>L>A(EL#L\nM!'+P."0IYH8W,>>W4)^;11X_1$.N[?3LV<\\F24JNQ5=,05VR5,0UXI&S(!7-\nM-]Q$X!0(ALXBGGR,#?D4J4IVCF9R=Z+XI"'$P/M,S0_D^4EP80F(QT9))B>8\nM/W+HW&OFT@TA>NP,(DT(MNWB+\\]*/O9O/^:._4-\\O]S'P4H/35W=MN4XGU5:\nM_VF#J3T$6BM).C6!(031>S_`-\\Y.\\\\>_>(J[O48.['@S@5_D4MNFQ3!V*M@=\nM2]8I(7B7^;P+%P80((1`"$$\\/DX\\-45UX,A+`+"0_V&`ZES!W3.*0R=.4@L"\nM*I5&9+'"(V83DY9/QR)$HOFJ(6C0>:[SF2G8>AD/3,QS=G@8E2O*#8U$;9T<\nM:.O"`+;8%FU"[%2P.U*L0PNN773!`OC>*H&&!A/>960X@8K1<`],)/)X*_%8+N'*&/3P7"G0EP!%0,\nMG!*I69F9[&C&H4A0*M*19+=+5U\nMN.GXV.5:2G26D8Z/,",+:`VK5JW"LFUF9Z:P@WDLK=%`"7B#$!CHWN-HUT/$\nMST5@R0$-0NNEHZ4+SVU?ZMP+2`S\\N7&6YYHA`[J6=8,P:'`LNH-QEOL.&@%H\nM2EZ!91U=3#M%6+\\5?^5ZKFQ;1IQF='9V4:W.XQQ):0OKE`2@-!I!&=@NH$^#\nMJ34_7@+8YFM0(%P'L^!C6B:&86":2V9BFB;&TKYE+IXS$$I#N8+4F@**7?$0\nM4208^=F]>`*6UR?9ZBN:;!N5YR`,U)K-^)==B[6JG]PKH^.$SCA&YA*E-2UM\nM11H;FLD[>A"//HQZ[!&8F44#-M#V@N=F`:QQ61C[=VR'ZS\\">099LF!YNG`L\nM%TWE"\\=I!'F"3F)$DD*^,+;U%`QN;/HH.,E/D\nMN23/S?SSG=OXYI-O03C0U2K\\V3:(`AJ5"[9SJFI@('3PQP_M(>I_WF<+9LW4'[O\nM+;@(O+U/(!T7TN0%`&()((`P8"03W&.O)#<4]2@AC&+")*/B7\\(GK&.TQU/G\nM%K'6J*96[N_8P70BB:*8,(J)XH0MV[;3M7H=#S[P$/?L/47+&]_.;==M8WUG\nMF;DH9SR3S,X'"-L!TZ!@&ZQI+]/>T,>Q]E9.[7V_F;\nM>QS+GN?OOO:"%]D20%B#J$:09%1MG\\BK,%B-V'/R+/M.G>79R3GDBT>@I2S4\nM,)7D&)5F9J7FX)D1)F))9=D*#APXR+U[!BAOVANM=P=.`XD6$NSQN;/O/HP&'K`Q_]U(LC\nMD$,80!1@:$T2)]2CB.&1,914E(HEBKZ_.)4\\7P*!5HJYN7G.G!DF".J\\Y2UO\nM(T\\S'GSD"<*N#=RZ;L&C4/`0Z04B(`1IEC,Y/8OK\nM%NCN7H9AF`PN)OK;OU-W*X^)NHIKF/B.C:&\nMR@E.'F3VZ-/T7_%6.OJW(I7`6K&2X,A>TC1%*77EPS^]SS]_%`KFX1+%<(IT;9WC/P_A%GTNONXE22SMYGI.D.5:E\nM@5)K.[(ZB51JA>.ZK>=&0.8P,033XXCE)K;CXAL6GN=3\\!8CX'D07&BU06":\nM%I[O4_1]"H4"]3`DS"3%HL_DJ0%FA*)C53^FZW'Y];_&P,%]//3][Y#<=Q?M\nM7=UDN>0-U[R#_BO>BNNZ**T)@Y")XP=H6+Z&E$1IV`6H%"DZ>P1WI?.HUP/7?`7MJZ'=ER3863(>"DFLR%LR1^)?0V-I-+96D<4ZJP7M_1]J:ZKXPU,C'!E?\nM3<5W\\%P+S[$I>1:&(3`-@8E&KMR,\\_2/<)(`O]2*8QMDN4(#0AA4IT>Q94:J\nM%6$8/O/HP_?,60#B*0"F0'UM8<$SND"1OG)]^<^^CJ[KIO9RLJ&KJ^/*@>%#\nM)-598J<-RY38T2S":4,(9^'3%1#E)E1+-];P`&9'!UE8`\\NA8!G(3#(].$BC\nM7^#(X.DTC,+[KKW^5GUQ2XLOHR.'#[*V_]+9>KW^'[Y?5+U-1=2I9T`I5'T.\nM`X4V;;1>F`>F<4045$F7K2<]OI^T7J=:CY@='<41@LF1,>3,%)8I&!H>V1.&\nM]8=JP=P+IY/_QP`'GV;]QLV$87C*M*S+2J72ROGA03(%Q:[E>)4F+-/$,@66\nM`>.'GH(\\I;R\\#T[L0Q@FK2O74O8\\SHY-,[C_&;H;2_SBL2?K@X-#MUA50G\nMQ[&5HGGSE337)B&3G#@SSNG]!UG5T<3!0T?4X2,#NX/JW%VS,Y,C'5EJ85A4.#;P+/6A(;HJ'D_LV2L??.B1[\\[/S]U>\\+S:_L?O!R[B3[Y?\nM1>__R&]QYW?_B=M^]TOO,BW[ZUJIC4F2(H6!4VG!;VFE6*E0V9>91<59W'/_>M]:JJNZIZ23KI#MD@(20D\nM,=&$`7L001&0X\\DH\nM4=##%A,P,<1LG?2^5G=MK^JM]\\X?UW5_"V\nMWM;;>EMOZTU(O-&&WFH0`DU*%DO%4:"6>N[UM=WJ-8<>7(&[-#\nM>V/-ZK(,E$+\\DT)<4XLQ)U:^WI8"$$LDXMM>K!9*`7E=A\nM]RQ[;0@9*AK:9JOF14O.E(I-7LP"=/BW/Q/BS0'4`!ECKGT?SJ>NMK"OO0*7\\:0L:0R.1XY\\WDI6?%]4@L1,"7TV\\5@`8H4*&/M?:]I-=?\nM[8ALTXTB4C=XBL0+2_XTA(I"G%2:U>==1-O"D\\Z2BKMKD@7*@!M>)\\2;`]`G\nM:]]#N27L%6MI_,@ECLAD;U2QNK$F<9Y;/`V$`!7'1)4RCN.PZOT?9,;<>2_V\nM":7!M:\\#PCCVPHVW?1\\_",WF3.-%2=N5_NW.IWYU\nM/$#@@5M&!0&)4U:2_=`_V,,/W;=1%8K"$^*69TX2M;4'U?$`,B9V*Q!+'--D\nMU6GO)O""LWH'!S8'4GQ&%^R_*J6XRYT>X+@(2`0284KX1P6W*/B/UI;F6[)-\nMN3-/7+C@.",`5.BAJJ5Z<4LX)RVE^>P+;#V3O5Y)]:6:Q/G-B<='0L5U@,@M\nM$Y5+.+K.RE-7,*.Y]7U2L;D:LQ@$ESK3`QP7@=.?_B]\\SZ>IM9ETII'90WGZ\nMJHJ6XBCMS2GN?S7\\P$=5ZQ&004A<*6$EDV1.7F;[NY[=J/S`K$KQ[[]8@/O^\nMKDEV`<0QD5N!*":J5O'SX^@3$RS)YJB6RIV#GK\\YD%RN(?9?G%#C66S%O%0"@YH?,,OO#C!U]Z^&4II*IE9+%`-'"4<&R$V`NP\nMXYAH#@P0^2%Z%+/$-`G"\nMJ',PC#<'BLMU(?9?9"JVAJ\\!@"9`4Z#IJ,D2EDM$KHLW-/3*9\\6D(:$/$R/$\nMW0?!#]!/>1>%9#-N88+XX%X:(V4&?7W7^'Y`I,17=($;,]6)*W@#?1!+FM9=\nM0-E*4.[M0^QXFE.B,0+I=PZ&\\69?$.#^*,C%/?M\nM?>4]?>J!*FJH!Q'XE%>=Q=?Z8C;\\]\\^YY?E>'FA8R!\\R'>1FS38-R[I&*O6O\nMC;IR$"@E8X*Q$30AJ'WX[[FM+\\_-3^[D82?+[K5_33F9XE33I%G3.B5L]F(6\nM2R$X1W_)A.D!!`@A$$+@#0_CC8U1VK_O50"HYW^UC&R;R\\/CDKV'NJB4RV0R\nM6>)4AM_J.4:-)#,G(7S%5S5!HXHB%8V/P8<1-D.PGLQ\nM`E,&*!!*39U-W7BQ?K5K+R/12!:&.2%2]&HPJWTV"(U&RV!V>9@3DM:+31I2\nM*=I;9]"7+S!8]NA_\\BG,;!N!5%B6B31,K-$1YN:'2>L:1!(%-`"K!2Q4H"O%\nMSZ<`5B452!"VA9Y(HALZFJ:AZU-%1]=UM*EC0Y^\\IB&D@H8,L5(DD)SE]5*K\nM"0:>V(8CX`1WE)5)2P@\\@JH]M'0F-]=F0T4H>%<>D&S1,+&0D\\6/%SNXQ=N=]VD_OY(*/\nM?I2YRY=CV#:^ZU(KE7`G)ICH[:5_[UX./_,,NP\\=I"V.:->U%[-7'0L`0`PD\nMDM`\\JVZX5P6O`GZMOM8)!<015(K@%NH0AOYB!YJ24HJD+NA(6<2A)(IBXEA2\nM#6-^N6^`T<997'CG32P_^VR"6HW2\\##%P4'\\Y<4FO6<'3'#D;'\\[0@E`G(XP#$%$`9JF4&0L&C\nMYCPB3>+6?*HUCZH?DDG.YU+C`#.\\L5=V8J60N19^,7,M>3^F5O/J;6H^P8'?\nM8:;;N.+..TDT-+!]TR9D$%`Z?)@Y2YK>+V]6+[/S#ES&-VQ\nM`Z>UA=FY'".%`L4X-A+U$7P:@&H%:A7*?D@IF41H.MW#W73W]N,'(7-FM!!/\nMLP&/%8SY$7JFF8E*/X?ZABAV=3'CA=U<\\SER^G_?33\\?;L86#;\nM-EKFST?(&.&Z!'T]F`I:K[H*9]8L,M^^D_V;OPN>3T8J:K!P'-:D8=M4XKP,\nM(()J/0*:4OB>3SZ?IW]@"!E+TJDTJ61RGGX*$T6D\\G\\U>O9ML==S!CT2*>&1[FWBU;$(L6L>`#'Z#\\^^>1^3&"GB.80M)RZ64<\nMJE38LG4KW@?/Y<0/K\\-6DI2F:!!D,G#%84A<=QQ`'-8!:A6$DI0K+MV]`T21\nM))E*DTRE23A)Q#0`"$$8Q?3T]I.?*.'(F(9*F>7G_"WNQ`0)QZ$T-(1CVVR]\nM_WY^^,,?XB]>S+P+/TIUWVY,(?>01=N[:A5XI$?0=)6E!P@!'\nMAP:-SH6PI/U54ZA6@8D1-"-+,7"I>3[)=!HGX6`G'!()!Q%,$P$A",*(T7S=\nM6*N0ISF7)=,VB\\K8&`M6K^;P8X\\Q3PBNNO)*;K_C#J(XYO+++F/1QB]2T@T.\nM5*K\\]"<_H7]PD"]>\\BGBNV_'?WX'C@5Z7%\\L$].:@C4-@N=>BL#4*%0N0L\\!\nM1.`1!!&V[9!,IG!2*9*I%([C3)=!"`%A%*/02*4;,*LNF99FXC"D5B@052K,\nM7[*$^/GG65HJ\\L_77LM##SW$EBU;>$$8[!H:X6F^\nM-@ATW/L[+SW7S^LU?SS6]_\nM!UW7:6UMI5`LL4A0+!*6\nM2L2E$M)U2=LFQH%]G-G92<><.=QSSSV,CX]S[>>OX^1&AW3/?E(6."_SO%7W\nM/*8&EHZ^3"!>BH!.?0[0-=`$#9JB<\\%,A*;7O:YIA+%$1!&&DG5WB,DMF5"@\nM:0@4RSM:F=721#*5XH][6BD>V$^U4$"O5C&K5337Q>_K)I5MI.6*JSD\\EN>4\nM)4OH.GR8!Q_\\*99MT_JQC]%VTS>HW+H1?WR\\[GD%L59?$!@:1#'%SWT">4PG\nM#D!/0")%KF\\?YP=%I.V@$LEZ;3LHR\\9JFPW6/$@D$;J)IND80DDSG^-0M<9O'G^<@<%![MUT%WL/\nM'&3SC^Y!QC'KUZ^G_5^^0?G6C\nMM:LQ:QC8$Q.T=70P\\[/7TE6M\\>OMV]FW?S]?^-1ZVA_8Q-Q%R^#3&[AK\\_<(\nMHX@-&S8P^X9O$'SM!L1H'DT3&,E&*)1K(?%SO?)-_#_P6CI7$\\20S"H><(0X\nM)R#V;]W)\nMNG7KN.[SUY+^WJV,_.`N@DP30:*1T2/=._L"=8ZN,:J_MBEO3&4%*Q&A#])0\nMZMP$&);O8PE!XXH5//'LLUSSL0O)W?\\#2K_:AF&"I2+XPPZ6K5A.]K2_872B\nMP!E)#>^^381!@'G**BH]/;)NJIO&?U*OS;OD0X-H9S\nMYCKT[P4&?OZS(V.U\\!.S3)Z\\N0#;X[]@\nM!`#*U#?C[X2Q-P)0^")P.],**%OAZ3H@S<[:E)QV+\nMA*61,#5LV\\1.)DBVS:1AV0H:WK&&.)8,;;U7C3WS]-.E2-[PD09^>UL1-E9>\nM>O=;`@!P-O`N8!Q:6N'362$V9!Q[44,N8Z1GM)!LRI'(9;#2:62M2JV[*W:/\nM'#Y2K7CWE36^.U^C_Q$?OG[,!]ZW#&!*%P)_!/$AF-T$?YT4G&'KG&@:(F5J\nMH*%J2([$BJ=J&K_>+>AI4<@OUU[]?6\\YP,MU,>"!:(9$B\\`T-"A!-""I&:"V\n;'/OMZ57T?YC*+/`N5^DI`````$E%3D2N0F""\n`\nend\n 6596 industry_next_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```.PTE$051H@>V9>]!=577`?_L\\[CGGWOO=^SV3+R$ODT`>\nM!!)"(20QVD)H:T4KMH,"HM9'U59'JV+'4BW50=N.[=3:AS8M8]'6QX".=!BJ\nM,MHQHB`JR#LD$/*]W]^]W[WG??9>_>-^"8&/:(3*7ZR9=<]S[5F_O?;:>^US\nMX45Y45Z4%^5%>1ZBGJMA>\nMFQ_6FP_/"X`J`E2,\nM<+T2KDU$>5/GGGY0!?8;X7.Q9GUNP5]W__(N/#^`4<"RL+?O]N@=^'/)Y8.A\nMX`UM^\\40)A>Z!E=*WUE;+C'"YQ+->FSXV"\\)\\?P`8L!HW%T7$[SI_8'JZ;U.\nM%?+!6/".;/WY$$:#7^_AUZYZ"X.;S]ZO.Y'8@(*/5%\\H``L0D#REM.LWJ%[]\nM[D!U]UZG"OE0(O@/;_GY$%+D!)4JY[_F"@8WG+G?")^-#>O%@0^=)L3S`[`7\nMCVF"A`MXVW=1^[VW!*K>?9UHN2XV!/=N.@6$`M&:HMTB"`)V7OH[+%N[[D1.\nMB`7O.PT(YYDWKOO4OY-FN=M7KUU1]MRUQYXX;!ZX_UYK=.C)[P65ZO=_\\L/O\nM+@7($@A;2);A;]U!]ZNN]":_\\5_72J.I$J5NN/M,%>\\Z+$L!C$:';="&P'79\nM>=%+R9)L__#XV(',J#^R%8?>51'^)3PUP)((&!0&Y1IXA\\`-`I\\39]O_5:SZYW?U",_%EL"`YN7!H)T1V`(FQ1\nMM!8(;)L=YVQG6=_`Q48X$&DV@>*MP:D!ED1@SUU?)$U2>@?ZJ-9KK)R89202\nM^IO3G-%7X2O/AI^E2-2)@,ER='N!4KE,??,V+_WICZZ5-',CHS[^[?6$ESZQ\nMR*X`K2G"-A2:(HI(9^>PY^?9TMU#M-#:-YZD!S+#VRW4H3?ZPDW):0!<]L1W\nM8`'(!RA*&QE(8K:LV\\E8;EBS;R]_>LO7GWKYI"$D40O3;%",/4D^,X5.,CRM\nMZ5FUVLN&AM]/FMFIJ.MO6T?Z0":\\W5;JT!6N\\-7\\%P!@*;`$+!M9U+RU0!&&)!,33W]7+3J2IS`_A3YV\nM&-(,>^L%-,I]A(UY].&'J!7B9B,C[TW3C$+4];8BU!Q/XC;)V`AH0^]EKZ55\nM\\FD-CZ#NN8NMQ0R92?>-Y_I`:GB[I=2ARVWAZWKI(#BU*$@FQDFGIV@^\\M#3\nMG]G'7XB0B2%4EM+:N9^_&M&\\^3]OYX;[AKFY:P,/UE?1LV*EZY1*[S4B?UFS\nM)4`A8C39S!264L2_^WH^-3++1W_P$VX-NKE_U\\MHE2N\nMC:[4^;[=P[139ODB1"I\\PE+4I"BDF)N!'1=RQU23D=%13&'HJG43#PQR_\\`*\nM+&"[ZS"@U#X#!V+#)D1QR:(+#L!7URL$:C;\\YJWS!%6+TJ9&M,P>GR1MY93B\nM>S-FTF\\#WR+*,E\nMBK&D8&V]B^7+!YWA\\8EWV3J[2/+\\\\P"7(&2Q9.B.8M5='/DL<=8M6H53K6+N=E9[+A-11D0H5*ILF)@N9=-\nM3ER$&"QCT-.3-+6/"'15*GB>S]S<-&YK`4<$`:K`>4IA(:L/(UZ`2DY$X+@#\nM`DKD^-7Q!R>.SW;O)!*+G;E_U_GPRFN@R"%/.UIDG6N]J*;H7&LY-*>2SBR\nM9BUW/OP#1NJCO.$!Q$14@H(;7>&A>>GGV\\MW,9MJXCCI\nMV,0I1XLCW!4H_O8]G^+"K1=P=.(HK;1%6'2DDI"8D(R87,7D*B&2\nM%B$M>GIK'-[@<6,IJ:P?)TA+-+GGV0"B-L1M6FG.0KF,LFR.31[CV/`H:9:S\nM>ED_^A0;<"TPDQ;8]3[FVZ,\\/CS!V.P$]RW]&[VG+.;HY-':6?M3H_K\nMCN.)2=`JY[PU.WE\\[C"'IA\\F)60\\'N+8[#%F%F9IQ1'&TXREY'9*:A&Q1Q1+Z2GWT]?23F#9?>^1+3+0G2%6.\nM&R@JEH=E*92%DU*\\31Z7KS'(Q-,!=-X!2-HHL6FU0X;')B@*0[E2Q?,#_*",\nM.@4`2I$7FJ&)4>;FFSB>PTQKG+=>]$8**9AMSQ+J3L^G$I-+2B$9.2G*@BB)\nMB\\E;EDZA.(VS$]A.=TT\nMLY`X22E7JP1^T`'P`U1VB@@H19873,_.X_ME(MHH3]BT=C-3S2D6L@5"'9*2\nM4)!2D%%8&5KE.+;"2$&:"59A<;'_:OK/'N#6HU^FV5[`LJS%5!.T-JX4V;Z!\nMJ^JW+)V%6DT8>@RUZERRK,#S`OQ@4?V`(`A0^;/ZCU*0%QK!HE*MT`AGJ58J\nM.*Y#(VH0F8B-*S92PJ60`D$C2D!I+-N"T.+HDT?I[>TE2S->XF_CFK/>PW\nMEV:S21`$:*T)YKJX>O,[N=GZ/(\\71\\ES!R]UR+VB3V]P_:='($U@8AB,QK(L\nM?+^*!U2K57P_P"EY^+YSRAQ00,GSJ52[J-6[*<=E=$.S$"^0.SE2$EKM%@IUPN8]LV[5:;-USS!G:M>1E#P]S\\?,=<.NNX4HK9N1D.\nM'CQ(412("%U=-?[D`^\\C7#7)#\\;OP'4=;#OOU&=BM?2XR9^1Q!G8/O@5>D8>\nMX?*LB?$"Q"]WCEZ`E#Q*@RNAM`[\\,LIVL2P;1]G8CL]+ZQ[&\nME,G&%$'-)\\D3[F_>QP57[B3,%S!VCN>[>+Y#K5IE>;2>JU[U)L8GQNGO'^"Z\nMO_@PRR_VN6/F%C(WPE(*R[)P;0=+J9'X:UET\\IYX#O@,(C5T(31G4$D+VP_@\nMN'I^1_TR>`%X'B@;,0HC8`2T%HRH3GD]-UU*VPNO^]GC/UO5L[R;T&YSS]@/\nM254;2CG5FD>]7J9>#UCN]O/;UIM1RF+UJM5<_\\F/XNUJ/G*5[)W[QX>[?L^#R9WDQ6:.,Z(HI0LU:RK;F:J,&`[5@X)VV:U.)DT-_5SX_"[_!H>"]Y;DCBC#!*R3-A\nM1^]N=`;W#MUW)&ZD'ZBN"<8G_K[QJXL``)/`^0@Y#^"P%9NSL`5LL&T+R[).\nME%7::`[-/\\!4,M%Q/LD(XP1?JNQ?_6H?_+]4G(>L`)(64V-CZNJ>KU7\\[SN\nM6I5J)2#P2Y0#GXH?T%?M9V/?66Q;MH.*W<6W#_\\/WSGTK:?F$`CLLK@)0*W?P^%=[I5_WS^KM[O,&>90S4^^FI=%,/ZA2F8*PY\nM*D_,')F<;\\U_P\\3R#U-_UWJX^W5E&E^)GM;D"PL`L`5X&+B,/KK8K0)>YGKV\nMEE+)[>XDMLH%,V*TN<;9C^YMV9>W!?=V[*ZUD/2W++_F%7\\@V\nM%`/!,`[&3(J)33+VA)(^"(&0I!TR"8:I33J4CI/2H9UFVKI0EZ$P@0X9`I3B\nM>K`[B8U-ZQ:#0;8!2\\*R+.MI2?M^W+WWGE__6,D&9(%CM^4?OC._O<^S^_W<\nMW^_L.6<7OM`7^D)?Z`M=@M3%-BQ>`4IA:,T"+9P$"M'#%]9V1R,`C4!0*=7C\nM^<*]0Q?GP[BX9F6%`HB@OB^H^PH^P<2R"VVI`+50H_ZNZ,L!O:R[.PR4!\nM$$.`J!8>5L+FHJCPT.47GE2!-5IXHN#3XAKP:-5O;N'2`'H!P\\!LO2;,E+J'\nMQ)7[*/BV8\\,AO"'%I``5`^P17?AGK]W]H\nMJ>HI6Y4G]Q>$<.>B3X?0/D3BU5SY.]^B\\;+%:_QR)N:@X,>Q_R\\``Q`0UR&T\nM"Y6-,85&S;1.&?>&BT\\7M"T2``>N$"(\nM2P,PQ[9.$NI/+KW[)4O&JK^+*UH+$.+Y@$0H'X/EXV@V59K+CIMZF?\nM.>MLGQ`#?G`!$(%/GMCZV),X)3=8$Z_<9(>#,[M/=.@C;8>-WE,G7[>BL0-O\nM_>>O)P*4BI#+(*42D47+J+KU]O#@OSRW69(I551JVW_-4X65'3(10/OXN2SX\nM&BL89,75UU$JEM;T]/?M*&GU/5-Q_+M1X>]SDP-,R(!&H5%!#=\\1V";PT[K:\nMFFU54ZIOG#NG98()`'&+2#Y=CEP::]YB:F[^6MB,5]TO6K84--;^N1,S(7X9\nMP,ME\\#)I+--DV=)6ZFOJOJR%'7F?!:"XRYH<8$(&KCWX0!MPZO-!\nMPB^6"/L^U$Y+J;G\nMLS`8I.1ZJ_I=?T=)N-M4ZOBFH/`+]S,`,!08`H:)C(6;2>/E22"?R.8U1Z$BR=/GV?XY3P1#UL*G(^XYTX2['O\nM-/B:*>N^1B84(=-S&O7F019YPY2TLZK?]7'87V][IX86*.1R--U,]M2D8\nM"(7NTR)_6FF*A4)$^Y2&AS"4HK#^&SQV>H0_^8^W>,6JHFWE]63L*$N#06H,\nM8Y6&'46?!5HIOF*>LS`Y@`*E%$HIBH.#%(>'21]__SP`E.L_GT$WSN254)][H,"R[BG\\?2G&ZMQ?M:2HJ\nMJRC4-=)6-Q4#:`T&J%-JE88=!+ZP;$%9WM[30W-Q.(53`Z,H)9R!)5&D2(\nM1F-,K6L(EP8'KA;1B-:4S@R2\\,.(%F:WM!`,A4@D1@AFT@1$$!&B6E@F@D*F\nM=RH5MJ!X-@/C!@24R/C1^(6SV_.=^PB)@9T<9(8G]!@P=5H3*(/*4("FS"`S\nM[-#9)K%HE&FU]9Q)I/P(E,V%/-@(EA&)CF>)B8IHDQOA\\P\nMQ\\X9:"WX%7'\\B(WO^G1G7?XUJ>@G@J5@1NX,RTR7VF``[?MXGL9S?7Q/4W`<\nME%9XGL]Q0KP3G8)G18GD<]1V=;)T6C-S-FYB='$SO48.$\\5LLW9PWJ)K?Y#6\nMX1<"VO$"`//"E+_[5UX!M_PN>"ZX3CF\\4OG8'POME8]+!?`^V\nMYHC!'54N9[(CB.\\3JS`($L+W](2DA?6+]H_917_O&UQ\\^-`SX0L:%F:MEX,0_%\nM+#B%\\ES'5>![D$U!+EF&")AG.]"X1`3;5#1'0_BNQO-\\/,^?6'+GJ<8*0V$9\nM4+7R&M1]=_%HQ_/,C#=SUS5W,I(;85_[/O:U[^-(=UOES"DS']KT[4UMYP`,\nMRJ9R*2CDH.L]/-%H7R.B$1&TDT<*&2*E/*:I.#<4`R(0"$)5`[Y;-NVZ/IY;\nMWI))H;+IB11C;54P2*1A&F9E%;'OW<-?GGR%I8V+F%8UC5U'=['G_3T,I8:H\nMCE;SS>N^Z37'F]_)Y#/)HV5]56)B8"Y+-0\nMR))Q7-*VC3),N@>[Z>[IQ2FY3*^OQ9]D`>X+##L>9KR&1+:7SIY^$HD4P8C%\nM%7'_4W\\"\\05BC4VT^1_2UM?&].KI/'WP:7I&>@!8<_E-_'C!G:@=N]M?V[UE\nMN]78D/CZX;?X!(`'^0P4,A@B.$6'7*%`;]\\`VM?$HC&BMCTVE9PHA4*T)IE,\nM<>I4+\\EDFDC$PHI58)KI\\W6#LPH%0\\Q9.HLGWOPI$A!V=>QB,#^($3;8)[&CL8(1RPBEHV:\nM!`"E<#V?4P.]C"126':4B&5A1:.8>O)5B8BFHF4N^].'Z$QWD"OE&/5'"=@!\nM-BR^C2WUW^#D_0\\Q?.P8RE#*T.<>Q;FYT'@)%;(P.H3A%$AETO["9Y_`.4:4YH:WQLSW,ADX)3[:A2D5+)(QRVL.TH\nMUI@9R[(FJR"4`M?S$0SL:*P<=@S;CI8!SO?T?4WE94LX/,WE2+(-/^2C+,7R\nM6I8_.5\nM#]+S;H*AT23-P>"D_>?CXX!3A($>T#Z&81")Q`@#L5BY=`*A,)%(8-(^H(!0\nM.$(T5D%E106V;1,.1YC:V$#S[#CQV8TX'W:0.O)V>>06P6J8QF!K$X?[GB(<\nM"V,H@^\\LOI>JT2;>&VRCHC*.&0A.8O^C`";E,<`TP%!4&,*JE@:489:?NF'@\nM^AKE>01$E^M%C2W)E(!AH!`N;ZYC:NT4K(A%*!JC?M8LLO8(!]*GR#1;7+EF\nM(_-?;V7P^7]"W!R5*Z[B0.4@F8$TAFUP0_T-?-5>0_NQ#EJB(3SM0ZF(_YD`\nMBO*\\QXQ`)$KUZ?>YK91"ARTD8I>W80L)A0DU-D%H%D1LE!G$,$P"RL0,1+@N\nM'D8;07PC@#3/X.7,(4H9EWDU,1CI0C8D/8@G`8E(EHA1;0`KXO:%%(("3FS&_/+/C.^K>'WXJ]F7B3\nMWF(O5;$JAM4(,Z[<6*CL&_CUR2:YXY\\[^MS0\\G]>+K7/U$KS\nM+YME^9[E\\FC'7Y1RN?R^O^[Y67[!H06R]MA:.9P\\_%ZB)]'2W]=_P9]S:3\\M\nM?HIFSYO-2'*D]/)?O?P/MTZ[]9YM5V\\[N;1A*2JL2!DI]J1W!T_2=?U1_XAE\nM1DUNJ;M%6FAYLJJYZL0'QS_XO[+UFVOOO^U%1$@.)E?OZ]MW?-W!=3)W_UQ9\nM\\O82N;WK=KFFZQI9U[M.WLV\\>V2X=L]OW;OW#T.L7KOR-X3\nMMW3=(LMZELG:T;5R,'^P*WDR.;^OM^_SMOGIVO^K_8@(Z>'T;3N3.\\^L[E\\M\nMF].;92@SM'W+JBW&:Z^]]GE;_&P=V'N`!V]\\4*62J?N>33_KO)I]-9L>2J_)\nMY_(7]7X7_3?KI:C]_78D)W;M@MKMAF&T]'?TW^HJ-]7:VOIYV+DX#?0.T-79\nCU=+=U7T#P".//')1[_,_R&BQ_!/ME<$`````245.1*Y"8()Y\n`\nend\n 6598 inventory_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```+S4E$051H@>V96XA=UWG'?VOMO<\\Y<\\Z9ZN*$)DXL&B>UE,JZVI)GU!E=1C-S[F>M]7U]6/O,S2-Y/)X&`EVPV7N?\nMV7NM[[_^__^WOK4'?L:;^6D-].D_>YE6NU][Y.#V7VSW_:_T?SZ%S;=[T\\%P*'/?8TK?_$W]D_^Y2^_M*M>?GYJKMU[Z[:_G>^.R;?^GGWOBOL\\]-%[8?N;J5=*?WKH^G>^^9=2E*H4ADI4BDF>>#Y44B&*V-/_4*W\\6N$\nM6W]+*3-(/OMJ%1$098]!7\\?061G+I@"D"02HC.V^OUP:JC!U\\1P['GN!K%3#\nM&L48Y3\\NEYCK'Z73KU"IEKB_4J!62JB5$LH%2R$U%#)#(;.4,DNI6($G/D_W\nMRD.4:F5$+#+S;;*I?R2U($I=,1G0B=Q\\6``):DW`]Q9("V5V/GR*^_>-DUGH\nM!^55G6;B=I>=U8S1@N$BE#(%$P]K#=9"FO;1>HUMC_P*A_;OY^+-\nMP-7%%B/Z$D,%0Y`8]EK-;PI`8B,(2\\#@26R\\KA8@LU&WGWVT2KM70E50#8""\nM!L`#BM$XBP:-]UY1">S.LNQB>.,U_=^X#$DG_$T@4)*9$#?^]SF`-@!@+`:0#[`^5OG^?(K\nM7^;(Z!'&"Q.8ED599_1U6KE<9F1D))K8@,T@3<%N)8!DP``"N"@A8_GQK1_S\nMH\\9IIKO3//7H4SRSYQG._?AKO_:KW1>0]?0X`C(^/,SX^'CW`,@,,&%C3\nM/B0#.8"[%"2E4HG)RWWCK&[SX\\1?95]M'M]O=<-])DI!E662&A'`"1];7M\nM0S%@<@:,20DB/+;C,49'RW1,E\\/%P_1Z/0X<.'#7K+,>@%JM1A#P06/MDT09\nMJ8+9*A,;8C&)"BH>2`G1%!PI+>O=.<_MN7F\\#]CU1E_3@@A!#;71';B09Z%T\nM&<"&3*S_"<`H\\"20:5X%BL0T)@(8D5LWF)R;;Q6R+.#HHNU_Q\\YR1E03!)!&&'=>OJ]`&+?]ZGR=WW'2+N+\nMJBSO3P='6H+M.Q<2E86X]9M^D=M3JY\\1450$LCW4#_\\#%/<"0I9EF+PN5M4H\nM&5&\\%PJE,CTORPQ8L`E(DD_*^P'(%TUC#%OI!@`T'@MFLMU&<2&:J%!V6)-3)>E\\BCED4-DI5'2T*-8W4-6\nM&L$F!0K%$8)W&&-0W\\"[)N);^%Z+T)\\CRT>WV2-,NJ-!L=_`A!NJ#\nM+%V[H!B;8;,2/BAA:=>6-[-Q"6%-?%%#@WY["M]?Q&@'U[Z.[]XA^`[-&Z_1\nMN'4>UVW3FKV(ZS?I=T;IIPF^.T^A.H1H0J?3XLR9,_CT-B)"$%T^#*`1@.O,X%T+$VYRY\\K76?R?"YAT+T)`-`_:QW?=BG,:+"()WH'K.8+T\nM(X!!X,+2S`]`:>HI^/Q^P((0];\\A#^0,6.+#&EJX]@S!-9'658),(<%BK"%`\nM#"X8O#=YX`8?(J`@EJ`)S@G-A45\\.D^00,B#%8&@`_G$A4QM@:&@]/J.;J>+\nM^+B`Z0#(^V8AOT9"H45O\\3*=^0N4TIC:@C>H-60:`7N_XNQ9`A."1<2B)(SM\nMV(,4)_!!2+(B@L7E!O:YC.ZT'(V@M&;G6+C3I==J+`,(&UR)!Q(R`PFY!HV9\nMU^@V9DAKVR%$>6`-WAJBV:2TL(IYX?!``*U-5KSE-6SHXG^&]@3PXDOBU+,Z^\nM(2Q)*()P.0-!+$E2Y,'CCV,JDS@?\\&KHN;`J??J@M%LMO-W&FU=O\\L[4+`]N\nMWXUZLP0"OQ$)Y1X8['%=MX'+P/O"$@#GP20&;W(`8E9(:;4'1!.Z#J[.*[XW\nM,*?@))K4"_2=I]5J<>WZ/%/SL\\S/SW/RL8]RP)TG.$6=0?TF)*0:J5N21_YE\nMT'LPJ<&S`L`*&0TD)&)13>AT^UR^=)9N=@>1$'._QGVO\\T*KV63ASFWF;LVB\nM6(X_;CW5^CT32N+>U@%4411)!,B'4`WZOPR89:9)BKROJ.M2V&4(?Q)L5\nM6>@>`)88R)\\3C:G2A[A`#0#8E0!8K?^!'Z*$+-:6>>"A7Z:R;0*;53!&4&FB\nMTHCGT`1I(J&)^@;!-Q#71)S']XJ$?A\\16HCZ#9<2AKS^UQ42\\F9)0C8LFSB8\nMY5GW(8)U;B"AE%ZWW9M_YUMGW9URUZ9)+,R,Q]B!,W-MJD[B\nME`[VPJOVQFOVR8._KWIV.?!9$3IK#?A_`B#_`G)!E5]5Q0QJ\\D'`2_V82XQEUU6&O[W/X]ZZ5=5=_8K=CCO&I+N5\nMQ"9"&,0`)D%(O(8)$X9,,LL,B)@P9,Z,S)@@F,``B2C`A*$'*(IL$B-C8EMN\nM=[>[JJOK5IW'WGL]&)Q3#[<+)?2``M%;.JI5J\\Z^M?[U_VNMO2\\\\7\\_7\\_5_\nM>H5GV>3_`L`6O__5CJ9P+@`/PJSG=$J(M\\\nM.D@W,#_?=_:G.\\&=WIW?`]Y\\EEB>"8`*`$M5;O[U/X3ZX&A!VP1P6+00@A&)\nMM(T!1@P5;3W9(=2TM1"#\\\\*-+;;:=6_F;7@F+3PC`!$(`5+&U]T&O_&-/V6Q\nMO,2]M_Z26Z_]%JG?9_>]?^*%G_UEQOX)3S[^`==NOLK8KUGOW6/GRB9E>,!J\nMEG8)\nM/F+#8[P,F-]$9OE="``1B,&0X0'!.E1'2G^?W.^BI6/]T?U0*Z>A]#A]\\G]Q_PE'^F#1F-+R,S>\\7#S2`\nM>T`O%`#'##B:=G%9(OF0)S_^&P[W/\\#\\);R:@A.FIP@4"PASE_(:43"](``J\nM$#!DW`,3).V3]1ZFAGA`90[:`^(@9;9#P$X8"!<$((#H)*'2WV/8?X>2%(WA\nM1"HEA"EH`F7>)TP,.!,#*E,S^!\\%H'H&"$ZW^Q;CX7V*WIJ"/\\YZF.SCH$]L\nM!R-@5IW4P+.N9V8`YH%FPKB^CX@A.F5?RAQHF&43P_1[86+%3QFX4`"BX.Z(\nM^)3U8P`RR>:$@3@%?=;V$#Y5Q!<&`.GVXL!L-J\\Q-;V\nM%<0JEO$%-NL-FLN*U)]G%:^QD0UK7F(9/L^EXEC[$AOA-E6SI%E>IA2_.`;,\nM86>5B1S0A$AM!UB*U!Z):8_BD4@DE`=D#T`DC!\\Q>,")['UP2,EZ?$%ZIG4R\nM__S;OPW0$,*W"+Q&B#9UZW.W61_7KQ[$_5]S)[H[[IP\\YD[OX_??UG__"V,1\nMFU?^^/=#>_-U-S`SS!Q5FVYJ1`F7?N5[WO[,?=42)K^AJO-[>OQ4[OZFBOYY\nMK*+_X1_ZY_]W>_^1^W"UP[73U[_\\,,?3B"-^>P0<*<._='OP-NG\nM?@^8.X&`,_W/MMG"G%61\\IW:ZY/,QL\\F-_#>XR/>89OJ%[Y&?_4+E!?O$+[T\nM2QRMKE.NW2*^\\A6.VDODRY\\CO'"+P[@D;^[`UB5\\LB//EGW^#-[[Y1^Q_]Z_86"Q8OO8&C__Q;]G8VF3C\nMU;OLO?G/;"Y;EE>OLO?.O[*YL6`9%,V%=+!&4Z$9E9(ST0U1XZM?_3+?^/HO\nM\\O??W65G9X.?>WV3&'>Y>G7)W;M;F#YB9V?%R[[$/?&U5E/'@`7:?4M2!:\nM$,F("J44BBB-5S\\!0#P%X&G`@\\&33[#N`/;OP0>'^$&/;6]CZ8@T%$)HT#YA\nMC2+%D"3D49%<"*ZH&6:1<0011]49!DC9.5@[\\3[T@['<<(;!R+F04H5J10B"\nMR"0=-86?AH%*,JSWIJSG#O;>Q^^_CV]O0TD4,7)2&#)#$D(L:)=@I6A19!1R\nM$K((T63N.I$Q30#&!/?OP^'::!I'!'3.\\C!D4DJD5)%SI*D+*M/?Q)3ZS/'U\nMLP!\\EI!F.'R,CST=,RC60R2F14DO)IW;.@1AU8B<73`6KZ\\\\"<)];LSON3L@#O/XQES3B6\nM.>@IZW5=L#XQID@;"K'+C%;1A(+WB9B52B<&T@A2"EA!U#CJG+V],LDC-Z@E\nM4DKDU.*>R"F1TY)<(BEE4EOH.V=K,Z`BY%QP'#M/0CE-7S4$!\\E*D<+`@F$T\nMJKI@?68:3-=I^1B[6\nM$FCK63;>L`B3G%(5211*GUAD!4X9*"4351&=NE;?9W+*TU356>LY,P[57`^%\nMK@_DE$F+0M\\KN3`#$!2;9M'3`,H,P-W1/'6/P9PQ!]I&J/K$J#6+6@A=(E6!\nM%&224U.QH*%TF5*,P,1`DZ:A%;0@HJ2D='TBY43*QU*:P/1]G)DI]+U32F:1\nM"GT/)5>H*CD+9H*?5\\0Y%68"D"*4L3`4892:15,(76;$638%[S-C6[,,!>DR\nM::,E4QC[1"Y&#$8>A68`R0*SA%)6^FZ224Z9OJLFV/W*8`\\?UME,P-C80!&/PYZ9(R0&D&[D=$:$C6Y&QG#DM$+PZB(\nM.!+F+B202YD9,-(H$P.S[KNN(HV)-&:Z(Y_KH-!U2HR9IBGTO2&BV`D`Q>Q<\nM!LX`*(IZI!"PV*"QP<(";Y98L\\2:%2PW\\>4&OMPF;EVB6:VPG37ME2O(WL.I\nM!F":Q#(-(C5#2B&@@&)6J"JGJIP0C+8)U`W4M;-81%:KBNWMBDN76KK.R'F:\nM)TUS'@.I3//`H"%P]<;GJ.N&ET)%53?8Z@X;L::J&NS:%7;JEEA5^"NW>+%I\nMJ>L&_])=JM6*AV__@%*4/+=G+YD86]K6@%TVMQK,![:V1[:V5S1UX>9-(<1M\nMZLK9WH*ZODI=1ZY?#[3M$8\\>'2(BJ#IG+UJG19R%$(*9^8^"^67M/]8L-@V@\nM^9F&D4W'`M79[[-_ND%)452M=O-W"U"*."+_YL:+GSSLU&R-VK1_NIW-GVWS\nM9YE^RF=FB!AF5KO[N^[N$XBG`*@H(82DQK=-K58U3)X*_M@^SW\\6K#EF7@3<\nMS<3$_L3,ZJ<#.PG_8#Y08\\;.#[/EZOOZ_K_\\$6F)X%ST5*7@`````\n(245.1*Y"8((#\n`\nend\n 6600 inventory_write_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```-E4E$051H@>V9:VPYN[R+DDB1NLNZ6!=+\nM5F*YK@+;B5/+3M`T:)TV;>JZ@('6<%$@18`6_I&B11($<'ZD"!JX1I`&A1O$\nM:>"FB8VFO@:-U<9W2U:L^\\VD1$HDM=S[SKE\\_3&S)"5;LDJK`0+T`(.9(6?.\nM?.]YW_<[WSD+O^)-_;(^]*FO/4F]'G=M7KGH-QJQ[3DX-O7,CG7+3SSRQ--4\nM'W]HP?W^4@"L_O/O_QHO?#90D:=?_Y/\nM-R^X[_`:QGG9E@U#-GS^@>ZF\\7>^?'SJ&R?CPMX5RY8]=ELANT%$SC__`?H.\nMKEF4[]FVD/_C+W/V['1^H*_PR9HN_G;GX/*E']DZM&F@P+87WS@RO??@U,%X\nMXB>5ZQ]ZF?&??.-=/70">V_;P,J6R7UVI*=P9X[I#>:IL@0\\@H2_^<3^,]6..-?)VF6]'#@]\nMPY&)EB\\4B_N["[FOKC[STW^]Z]#GC!G1&)-\\(PQ@SQW>?_?/-@VMW7+=5Y:=\nM>7.C/G?RVX/[Y.\\?'4'N?V>!$OKRO0I!0BW\\?L=PUYY\\H3,;*(<2@\\*@,2AI\nM\\8]NM[IM]>#66S:N6-6PBB89CHTW.#*ER&1S#"XNZGQ6;RMDPT=R`]QWXFQG\nM=42J*A,I1$`=0^+.A?SU)$&)1,29(H4>K(4L@'Y\nMK*;0/C)!9Z'_]CN:E=_%37Z+7*0049Q>W,-+BS["J]/;>?;P"^RV9R=6N]*C\nM.P8"_[E#$RP80!B`@T+_TK7Y7$>!T2-O,[#C`:)<%UH)2@G_>2S'=+R!1ER@\nM4,RQMI"A*Q?0E0O(9S294)&)%)E(DXLTN6P!;OD\\S>/7T]%5Y*P_Q+%5;[(V\nM=X">XU.,GAJ1Q\\[_0;SNQEOO[W_]%T?7=5,Z]-(#'P!`@&CEL*T9PDR>Q9OO\nM8>W($)&&V`G/RQC#4TT6%R-Z\\P$]'8KN''1F(1<)J.306J$UA&&,='?1O^73\nM]"WMY'M'O\\!D:X;R9(O=W1]F_:[JV7=.]KVXK&('ITLS>!\\NG(%`)R`T#H4E\nMT,EU,0.1!N_A_NU%ZJT<(AX1!Z2BQ@*"$@%`(Y\\RV^^TS,]-EU#&1F&!KNX>3HZTR?NK'NIJ>_Q,I%\nM!U[Y]X>!O1\\`@+X,@&10.31YB(>?>9CUO>L9R@RC:AII__,*39SBJ\\_5>9G;\nMV'FAB_*!%YBXL<10L)P_V?S$F1VWGCPX'0?L^)&;BV4A`((V`SC`)!)2FCX??OMW#5X%V__XFV.CA]]_TZ]YY]_5N%;F8T,E)LLET&*PUF&\nM^V!(CK)AX"1EKXDR%P_$@CW09D#/,B"LZEK%6_(Z*_M7"?E183G9BF%W?8;!1;!A9Q\\[W-Q:)VH\nMISO;S;U+[\\6)(R!`:TVQ6,0Y=X6^%,=.5?GKUPUG\\\\+M4R76=<6LNV4-JE)`\nMS0A!%KP%KAF```A`S?.``A#0:+1*3!'',6-C8UAK+WK?>P^`4E"K.KYY:(#C\nM/4O8?&*"S;DZ'__8"H*1`0Z_+.@(@B@9,/R[8_F`#*0`+E-1Y7(Y5JU:-1MP\nM$K2BN[N;3";"&<^7GACE/Z(>/>L)`HT7$@"AH".5`'!<&PEI#:)!I0QH)8C,!1G;F"?W/\\F^L7U\\9N=G\nMV+!TP[OZ>/7`!1YZHTIIVK+Y]"0[-P=\\ZK]>V[2\\).U@B:^-#J);BMMMC9LW1NS:5:1<\nMOH`(..]QHNCJ'<"XQ`,JG`-P52:65P#H!78#D?A$W]XG:8Y5TZ5:\nM)HHO$SW@OB/42#Y%=_A_/CXVQFFD]^?#F;-FY@:+`;[WTB&2]8Z\\GD\\K2L\nMGV-`@P[`!Z"O!D`Z:2JM")Y]"?WFH2R]W3FL,60S(6$HB+<$.B03.10>D8!<\nMQJ.4PSE-+JO1M,AF.QA>$B+6\nM8SVQ];,>0"<@E.+JTFB[;!$%I1G8M?L>/G3;_9QX[3$BF69@W=U,CKY&;?PU\nMEJS["*UZB?%C>UDZL@9!,W[Z('T]>8068J8)(X\\`VZ[?PKK-BUF[9B5A&.+E\nMDL!=&X`DUUY2NXV55;VM352PBMDA?%58CKH]BXC)(&IGX&V[R`LPVJY_92F3R$:=:I\nM31S!Q%7B1B]Q&&";)3+%#KP$-!HU]N_;CPVG4LW+W)%ZI7W?U;>8H97K$P_X\nM64^FLK@TVBM(R++&.P%@*G<2Y`T/3W+\\)EE^"<2T;7"S8-VCK2LR>;[TP\\X`679K[9Q/`>&*[(\nM`)(`,(UQK*FAW'DN''^<\\MG#J'`9'H>7-&B;O&OFG4.G\\3[`&C`M@_-Q`J`=\nMN&=VY-N@)+1D;'K?9L&3U!57Y8&4`4WRL+@:ICZ.,U5\\[13.C^*=1FF%@R0X\nMI[!6I8$KK$L`.:]Q$F",ISI3QH8EG'>X-%COP4E;/LE$)CI#AQ-:L:'9:.)M\nM,H%)&\\C[9B%[B81V3(+QCF-]QHAH']@\nM$)\\=QCI/$&7Q:$QJ8)O*Z$+-4'%";6*:F0M-6K7*'`!WE3-Q6T*J+2%3H3*^\nMEV9EG+!K$;A$'FB%U0ICTE&?%[Q+P3BO\\#ZDV32,GSR!"9J@%*LW;"-?[)[-\nM]TDV`A^76=P=<&;&,M.L4YLIXVVRG/3_&P#S4U6K.D;=-S`VPEH%:7`$*IE!\nM+:EDU#P/*$S*@/.:(,BR:=M-J,(JC'584;2,NRA]6B?4:S6L[F/?J?.<')U@\nMTZ*EB%6S(+!7(Z'4`^TUKFE6,!%8FYD%8"RH0&%5"L"K>5*ZV`->`IH&3I4$\nMVVJ;TV-\\8E+K(3:66JW&Z3,E1DL3E$HE;MRQDQ7F$,X(8A1B%R`AD82Z67FD\nM.X/6@@H5EGD`YLFH+2'O-2(!C6;,L:-OT8PNX+U+;"%-.3\nM$PB:;5NVL:GW'.'X.,ZD$C(@OAV]7![`13L@,A>,24=7M0$XA944@"2Z=_,8\nML+,2"@G-%!]J_`6!#Y.UK0:T(`@^\\/C(X[H==IE!!Q%A$*+/"&(:=/4I7`S>\nMJGE9Z`H`9AE(G_.2I$KKD@FJ#4#/!\\#%^F_[(9&01NL\\UUW_FQ3ZAM%1`:4\\\nMXJN(KR1G5P5?Q;LJ8BLX6\\&;*MY8;"N+BV.\\IX87>]6EA"*M_V6>A*R:E9!V\nM(LXA\nMSN&=0RRQ>+ZI=5#WEVR275%",B_/&Y,`$)-HW_?N'R*OHEU^9_MR\\X`2@9YB2*:C"Z5#ACL#E*I#H9]"\nM=X#H*HI^BJ(195"JFV)/#[U$!#I$.E>CB9D>.X!SR0IS(:&_7WM/"2E%683_\nM4KY5;)9'I;T6OFAM?,DZN?W_BYZ="WS">QJ7&O#_!$"Z`W)8A$^+H-HU>3O@\nMV?OY?V^7NI=:V8:XP=Y7G'?^\\[EW/=L_?UKB]X;?`%`[:Q\nM`Z9)0`E5U0(I1(T$ZB4E1>)#*Z2T0NF'IFJD1FT_)'Q(52E*JUXB@E"(:$15\nM4-50("%`($""#<'WRWK7WK77NV?WW.;,>WGZ8>09^Q8?ZJ![TV8>>I-E,*]>.#_UF*[5]^Z?./;UKTQ7'OO7]'U!_\nM[,LKON]'`K#QB]_FZ#>^I?_NB;__ZJK>XA].SC73_>?LT8.MGM\\K1^KL7']:-^C:YC_R_C0C]]*G/@T-7,S\nMTZ=/[]BY._GNH]_A^6>>O*Q[?\\@`UU&\\[XLTYQ>+5V\\<^>SZ*]8_M&'MZN-[\nM^NI39N'<;\\]/'4_FY^;%&NM!ZB*RM]5J/3H[>_8_2J5R[5^^^;4/#^!+MP,!\nMI%6T%G0^!X42%(J0+T!O$;8+L^XS,XM)8;PHG#ZPE[W'\nMSM#.]1`6R_A6[6S[].%J0?E5?>5R3BF^G]1F_N*?]_S;Q%-36HF(#P/M[_H;\nM]\\$`_.V]"D%"+?Q^H52YK5CJR07*H<2@,&@,6MJ\\YFY69S9^:?O'KQ[?T!.'\nM]-L%?O##DT^'K;G&T$*]1Y=4=>^G!AX[\nM6@KKRGM5%?@V\\!S`G5_U2[&$*P'0@$U97UFU^J\\W7_^9*Y+Z-$GM%&(:B&V`\nMJS'5'N-HY6Z&>D9X^DB+WU@7L'_O:YS-C_+YVV]!:2PK`@@#<%`:'+VJF"^4\nMF#ST-L.[_H0H7T$K02GA^2-YYM*M--LE-@W&]+2/\\8MSAOO^X&;*A8A:V]$P\nMGBC6#!1CRH68L'(+\\=P(5V^(,3\\]RM3D3C;9_51R3;Q7O8**@!;(!P`0(%HY\nM;'N!,"XRQB1EWE@\\1S7M9[C4Q/HL[(LUOR*`0&<0&H?"\nM$NCLN!Q#I,%[N/_Z,LUV'A%/L[[(&]4Z(YNOQ#M'@">OA8'($X>>2@@EY<@%\nM,-1;H5(.&1X9HF]@A'2VAS@4M%=X`741P8HS(`%HY5&2`2P?6BMTM,B)V3?9\nMOG8'!55"O,.+X%%$84@0:L9R,7$4TE^,ZAW`>A(\\\\#L`;[^]-?9TK^%-?$Z,#GZRP6.GYQB?ML&(@U*@W$.\nMK02?1"2Y@%JH*17R]);+B&DCIDXYGB>,%,J!R"5B60E`T,T`#C"9A)3FY[,_\nMYV>U5YA*IKCU^ENY?>QVWO[%VXAJL7GC.EY[^J>\\>?Q*KAKMQWM+K=5"B:,6\nM:PJA(E0P-C2`]S`[Y9KB*CE16^BX!H-]YZC(`=`:AE4?)M`5RF7'#HBV\\)LOWRLV,1TC(M8M,XFIS?7R[VC]^+$$1"@\nMM:94+I-WCH'!0?*%$K7__B$O/?,,HUNN8=7(('&DB"4@9H3!P\\Q.W4*\nMRF-LV[8#U?X>.@8LX'F'"58L(0)0RSR@``0T&JVRQ*9IRM34%-9:`)J-)C?L\nMW,K`\\5,<>^L5FL=ZF"X5*<8AVAH:U7EJ"_.(3#1T]0K2Y@ZI9"(<]UNZYA\nM8*"79W_T$]R1UVG.',)="4$,RH)\\8`!*@1:4\\H!!O8N3%AN+'#UV%/'GW1<$\nM`3MW[F3S5>.TDH0T-8@77+?D^R=VLL]'[N'K:-;+WF?8J%`L5"XX)P"1GH+\nM+/S7PUR;S')X?@\\G#_^(\\:WSJ(L7G!4#*)9,K,2@LY.(%'M__\nM.`_<^`#K*NM(DN2R[QT$(?F-6SFZ?@<]/WN!L:#`B6`78?R"7/MK"0NS'P1`\nMQP,*#V)1"@3%H>IAOCOS,#JG^>9\\W$/EK;/K7U9''/\nM@]]XYOD__W0^;C^;I"L'Z,0/XA%O@1"7F8(M^?-Z-\\9R;JZ*M0ZMWA_">8\\3\nM1:5_&&,\\=C2D=0=4GEC@BI-OJ/JZW?=_8??VM[[VZAO_^/%`\\Y*7=P+(JP#T\nM`S<#D71>HKS/RICW@/)^]@P;YJJ-.(HYHEPCM2%G\nM6N-8'R_-]*6&]V"=T#8>ZP0O0N\\G(&TJ\\D].<%6YOS`]W/=7GZL4#NTHC%Z\nM-WT'HP3O&1K0-^=,#OA2=\\ZA/2,K]DP\nM5/G\\0\\?.//^)$/L.@,ZBJ;0B^)]7T&\\_T1(IEC>-,=S$Z^3F/Z=59MNH5VL\\KTD1<977N(X<`D3=S*`5EFYS!?[*?9M),KW$[HVN?(84;X/'<3$N3Z<-2BE$%O#\nMFCK>-K#M!BZ=(XB*.!_AK"%)VH1A`N*I-UM8EP5JG5\\Z-DY0.D)'>:P37$?/\nMW:)QS9_:*?5G-(=WG8_W/0$4(*Y&VIS$IHLH:6&:I[#)/,ZVJ)]YD=KL`4S2\nMI#%S")/625O]I&&`3:K$Y0)>`EJM!OOV[<.&Y_#>X[RZ?ZN#(RP>GQ+\nMY@%_41-S.0U-5T*^"V`;V,8,+JT3J#9I_23)P@'2UAD6)UZCW4[Q;FU6`AU8\nMJW!.82T$3N-<@*`9'!S"Y5;AG,MFUPNV$[1U=/:>7+$G\\X#/S'U!`;D$PWMF\nM`,D`3&L::QHH=Y;YHX^Q>/H@*ER#Q^&E$[3-_MY6^G'[`=C*@R2X6U\\`TIW&FCF^

<4UJI.X`KK,B#G-4X"C/'4%Q:Q817G':X3K/?@I"N?;"$3'5-P0CLU)*T$\nM;T%<)Q.7`^#L11)R#=J+1VA5#Y(/L]+FK$*T(I(,V-IE>\\L2C',:[S5"P.#P\nM&#ZW%NL\\093#HS$=`]N.C.8;AIH3&C-S+,PGM!NU\\P"=[?TST`%070F9&K7I\nM%TEJTX25(7"9/-`*JQ7&=&9]6?"N`^.\\PON0)#%,'S^&"1)0BHU;=U`L]R[5\nM^ZP:@4\\7&>D-.+5@64B:-!86\\99L^[\\`+&\\:VO4IFKZ%L1'6*N@$1Z"R%=32\nMD8Q:Y@&%Z63`>4T0Y-BV8P^JM`%C'584;>,N*)_6"J@FUW\nMS>DQ/C.I]9`:2Z/18.)4E;QW6>T7\\"(8ZVG4ZRS,GV-N=@9!\nML^.Z'6SK/T,X/8TS'0D9$-^-_CT^[G8ST+VN&XSIS*[J`CB%E0Z`9+IWRS)@\nMER04$IISW-!ZD,"'T&E'T8(@^,#C(X_K==@U!AU$A$&(/B6(:5$94+@4O%7+\nMJM![`"QEH'.=EZQ46IE@;7HJ(12'O%U\nMQ->RO:N#K^-=';$UG*WA31UO++:=PZ4IWM/`BWW?IGXY0+<76%YA6`;0-;%3\nMYV?=N@S6F*Z$0MI)LUT]_M2;9KZ8Z##(OF(HB])=9W:T*181AWB+.(65I>.;;\\[H4O$^^:`0"E\nM`L)@F"8O(H(2X/D_!@^#GCTAWC6A2YJ;>PKFLPUQ)Z.\\W+BDAI5@4X27E\nMV^5D<5*ZO?`%O?%%?7+W[Q=<>S[P&>]I76S`#P6@\\P7DH`B_(X+JOI-W`U[Z\nJO?Q\\]U7WHN.EO2!`\\BZ]_/^/7^GQOPN5OBO*VNH*`````$E%3D2N0F""\n`\nend\n 6602 lamp_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```)G$E$051H@=V9:XQ=517'?VN?<^Z=QYUVIM.9:4N'M-0"\nM0I`4&D1Y1!2U)!@$!0E1H])(B,8/)"08_:`FQL08_6",Q1B#8/BB)J*!0)00\nM&@*T(91''[0\\6Q[M/#IS[]P[]Y['WGOYX9P[,T4T)^C\\5#)RQ/EA]9F!ZAL$8U%LTK>);\nMDZK)S(RZ9(^(W(L)'@1MK/G2O@^>P.2N<00%9`QO[Y12Y1O1QBN&REL_3S1Z\nM$=*S!O!@FV@VCT]J^-8D;NX5[/3SN.KA6+/&@R+F!U[]?B.&H2_N_6`(3.P:\nMQZ``6U#_RV#HG!U]%W]'2IL^BX2]BP]ZB]IY-&N@MH%F\\\\6U@:\\?(SN^&]A#X-LACJ#)T_9/O/X&I7>.`;L#[WT8;+KVF_XH?$ZXY%W)2^5?Z!)]4T606\nMM0WP*>HS\\%E^58^F5;+CC^-J1PZC?`WA:5%8_;G'.\\(3=@Y>>O'VA^'HA==4\nMKOP)P=#9IP)OGL"W)E`[#SA0+Q6U6PC#[00=B:(#`@#>?=)4UF\\K;=X!/LL+\nM-:UAJX=RK8N"^-QI@P<1"L"FJ\nM4G-RK9I@V026G2]55F.B"X.AK:`67()/:_AX"E`419`BZK(`+O?B/H`*HGE:\nMBO]`59'R$!+U;,+&FT"FEXNK@QKPPQ*41TWO&M2U4!?C6Y.YE'"@GE,SH(5,\nM9(GN#1((!&;)_9RD!"$2A!5,L+&3.EC^DZH53-2/"="L!>IRZ:@K"KP=C[9V\nM6(B^&%G\\C$%\\D2\\MNJP!M`5")"849<$U4+00!20N@#4P)C0`4*PG@%,C0]@;HY$.,0,]=!4#O)@)Q4GTUI\nM:WI]G@$+FH&7O&UJ@+<--#D&6H/0(*42IM0+#(`90H)^D!#Q&:H)ZNIH,H7/\nM9MM!FA>1M]^'#"BX;!9C#KC&VQ\\)[?FHE@";I]T;L%5<8S_01$H]2-`#&J!J\nM$=\\$9U%3`P1LBF8)FL6H3U@L?'D3X?7E!W697H_L9.OV!]D_?Y=F23#A[`/4_18*D?]L]RP8/';X/`!"5:JB_R\\V]>:;T\nM'MHNI1[4)HB4(;!@#8AA00=:2&IA,`)44760U\\9QO+]33'!0;=HQG([?R*;O\nM.Q3^TX'2X?M`8<-?.8`:D^']W>K^7Z+_X.U6;\nMW:U9>E*M/2WP<#HUT#9UJ/I]HOJP"E\\M;B*JJ&JN?>>*<2*?/A?J0@QXOP_\\\nM(XBPZO('/G@"+HTQ8=FJVC]A]2:@)^=0@/<.3``NR&>@=@%+@(3]:%9_`.1D\nM!X/G>]II20A@=.<;[5:YERQ[^139I.F[VF:\\'S<.^^;,8[%V<9=-D_?8O%I(N!H)!]%6]86AF_;73J?OO]M.OXA/M9=`&SA74>_!!*@S\nMB,D+6(V`*N'8.*C@6]4#,_=O0^3TNT_;ND7@.%`%*JCFTO*"BEWR>AD0K#X;\nMWYS,?&ON#4R)D5M?6?'"*ZL!H)B?J\\#LDL^+;=3F0UMIP^64-GX"C6LM;=6G\nMZ(+^H2L9$(`Z<$Q,>`$FRN\\9@Y@RIK*.:.,5])Y["[Y^%#?UW*2B[T@G0_]_\nML!43$+',)JN2GB"]Q_O2E96^\\D#0,XCI&\\'TC1)4-B!AB>9SO^+MEYZD/O/.\nM/=N_6STV?7>E&_B[\\Q/3SMMN)[8R>M9:\\]B'1YKG#>H)RKZ&J"7-'!,UQUMS\nM98Y4A[+]QYI?,*)_V_O4[FXLW9TBGDG[R6RF[V0C*FZ8^>H$U>D3..=P:JBL\nM&F3\\G#,YH][@N:,/+QZ]=,&Z0D!$B[-:)0Q@5:67LADA=9YF,V5H<)`-8R,<\nM36)4\\T.Y;EE70J%>4>_ST\\_V^WPQNGGO:;9:>.^[L=2_V(HS<,?W?P90&AX>\nMVGEB$!&"\nM("`,`XPQ1%%$7U].((HB1D9'>P<'RERVXY85@P=8_D'\\O[%F[+CZNIN2YY]]\nM]MF1D=$=@ZOZUXA/\\Q,+P*LP,#"`B)!8@N&1==OZ5@W/G[5I\\[ZSS[^(YY]Y\nM8D7KKUA"QU[9Q\\L'7V3MV/KI(`@28PR9]Z1IBG7Y&:B(X+URZ-`A/SC;'#]Q\nM@HF)B4/U1N/FP37K#DZ>.,Q#?_[=BM?N2D,;&]_"YBWGDB3QF;V]_3]:O7KP\nMAKZ^_@&O2AS'U.?FLOI<=4^:QM\\K1?V[DZS.2\\\\]W8VENT.@;1^_ZGH:C7KO\nME@]MO71L_;K+*I6!456?S,[,///66V\\]NF7+UND]>Y_BV2=6]A;V?V7_!*^9\n2MUB`]2>Z`````$E%3D2N0F""\n`\nend\n 6603 money_bag_write_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```.($E$051H@>V9>92>57W'/W=YGN?=9T\\FF2R3R48R0$(V\nM4I9`1`H&@XCB`E21:IH>+*)"%7HJ%3U:1#G'RK%6K59!:ZM44((2-`H$$B`D\nM@4#V9)),DEDRD]G>[5GNO?TC@>/2:#)$_:-^S[GG_>-9[O?S_G[WWN?^+OQ9\nM?];_;XG3]:*??K;`91__`3_[PG7*"SRIE+)]@YVFD&_BDK\\[#GTK=&J12;4$Z)8)4@)\\*\\(/`>9XWH#R]36OU)/`+:^Q+\nM45@]HI2VTY:O_],!W/\\1,(9L.J4^4=/4>K.244JIA%0Z32J=XE4(+_#Q/$V4\nM@,"5I7![DBA^.@JCG\\51]%202?>6AT>8>]TKH_(A1_/05V^"H1(^\\+%\\TZP/\nM-[:>GY)*H91$:X72&NU[>(%/D`KH'70\\\\D0_#_^R+_/RGO)9!KE2*O$=A+CY\nM:%>W%&+TB:!/Y>8[W@KE$M[1HIB3#=P-?K;IO6/:+O1,M0=G0J3G(:1$*HE2\nM"JTUQ0KLZ@R9-+&&,?7^2"[E=GG:;C(N>4I*\\;/F*:UVN*_O#PMPPT70VXM,\nMO,+\\<6V%E80]RQUQDTU"AKI?0HD(G`-`"($0`HZW:F19>'9#<7QS_ON^=O<[\nM$[UH;#2H58T5,QX:M?&3!KA^*3RY#G'9I=F5DV8N_J?&AH:F_OWKL.4#1-5A\nM^@\\\\2R:?)TAII+`(#-9";`3*0%.-+N<+\\N-^-O75I%R)O9D/OF[3IP2`@_;9\nM2&-LW]#1[F^81C$+_>-R.'@(,6Z<=X)0&,<"G?@R`8R.5[]TF\nM]WST_G?M.7/BX:T-TY8_TME5;DS%SS'9'F1,SR$RY.CVK^J,*ZT=B1'L.NWV\nM3\\-*'`0K",-L,/N,^.ZT>>KFR8W;Q+BZB+$U4)>%=%J6\\QGQ0\\]7]WJ>WF02\nMXZZZ*SP=WH'3`'#3,I"2?*DB/U_(NA4M#8Y<5F*5`BD8D[)HK9!*'51:_8M2\nMZNO.N0%P++MC^$\\+<.>[P`G2SG)7/AO<4IN)=:`=+U2R/!Y*M(`538ZI>8M4\nM"B%5(I5Z7"IYITA[S]MJPAL_W/.Z`-1H'[SWKP4I7WB^Y+:Q8\\?>-F[<>-^%\nM_00:A)2LBR2[O0HF2B.%QT"B2=`RT&IZRE=_J84:]'Q_ZXU7%,PW5@V-&F!4\nM$;CG1BC%B+QF14U#\\^>GM%^2Z^]X@LK(00Z:%,]6?9Y/'-VY$IZ6!%(CE2`O\nM%!.MSWE>BBM:@E+6E_=))3_K'$.+;AS=$#_E;Z'/W0!*0$;RYFQ-TUTS%KP]\nM)S'T#_?R:#''?2.*]9%EBJ>8G>1)LI:TT4R.4\\2>8T--DMQ44L`4B"$=%**'T@I;W;.=9_Y\nMCLVG!'"*$1"$"6.U[_]SVYQE,\\=./H?RP#[Z!PZRTTAB+!>F?,YO,.12@KGU\nMDL4FQW!-S`8BIM?ZO&=&EHLGI5&^QO-]/-\\3VM/72*WN\\0*_;L?#B_XP`)^Z\nM#L+(>5)P:\\O4,1#/NU9I=8?V/'_/JO-.&N"D5N([WWW\\*Q-W\nM9:%APHJ9"ZX62BHJQ4%*_;OQE>.*^@AO),W/;DJIW[AB@F=TXLL#/>\nM!]]W)Y5"@MNO<;.$%.^==,:%!*D\\4;F/)"I3'CJ$`(04O[*1D4@I"7R![TL\\\nM7]%4T$P[D+`M(VBN\\?C0U";Z0L?3_14VUPO^)X[)]U0Y=U*>.#%88][Q\\"\\N\nM6CWKO-3-;:Q^\\[:MK:S;<`&/9,J'MY2'_<'TE8OW*WSV(;WTKY-(2\nM:WEG.E?7.JYU'B8),4E($HT0E?LYEKZO`LC70%[=E3DA2/F*=M\\CL)I#6417OQ:*^/+A][Y5A]Z7>FD$.`HQWA9M0V\nMM2*$P,2O1J"(-3'J-];"_45!.A"TUAV#$0B<@_$YCYJC$<46C[U],7'LV-I3\nM9%5OB?RBL>A7!BAD?,)8\\KTMC;Q/2PCHJ4K^K3\\FU#%7\nM5W(L;-(TYAW:0AX@M>+%>Y=V,WW6,"&LA34U:\\N_K9K(^\nM7LZ976NI'MA@7Y@4/K_GT"7;7+7AH%B&Q^Y_;5^?R>``)RC\\3@(\nM21(>:W&(LQ8GY/%JA`/GZ*Y`GS#LJRNSFPHSNK-,ZTM3ZWL(I>B4#N5!94Z:\nM'15)MNK(;>QG>4L="R9G>6)K(Y_NNY*BJ>?\\\\GRZ.LP3O?6S=K1*?>!#+US^\nMV"UM>Z'C]E_S>$*`FY8=(W!0L!9*0T=(HBHF#DF2*@Z'E#XN*>.XWA\nM[S,!SY4"-NN8WG1,CV])>3YI[9$-?`IQ@AF$>0<$ETRJ8=;L/#4YS:[.@'_8\nM]69Z=!-OZ.WG[)H#7/6V%W_^Q=WSOU0WW.G;1[N@X[>+Q"<$$!+N>?`L;GG+\nMECH%]':^PN3I"\\%%F#C$68<.\\L3Q`,XYG'-(9VG+6*;7>%SM4@P8Q8B3X!0I\nM-+M[#6OR(2H2G%-?PSGCTUAAZ.^7?&KS&W@^=29S#_8S(^GBC.9'N&3!(=ZX\nMZ*[AJ6]Z@J=7_]\\^3S@+.0DL0UI].:G3\\Z]T0V3QP!:P'(6D>S)HPK2R^)0V./&K;588['68(S%)`:3))@DP<-0\nMGP9K8HHC@VSNJ.5SP^]FJ))F_I$!ZDH;:$P]BN^%:.$P<3P_B9,/EDO%8.,#\nMLT\\^`MI-;WFF;4E-=L-A\nM%JJ!J,%\\MV-2X?DM2=D]5TW,Y*B2F1($06SGW'C8FG+7O]IH_=W:A'V9\nM&N+]'8B#^T=T3_^(F=C49S_XC?TGLOGZZD+WO1^21)#+.\\_7^+Y&:*U16L52\nMBLB!N^J3U>-WGP_O_QJ\\N&DIR^<]("MV_.)]W;3$W:O6_/S)]V5SA2,'.N\\Y\nM90^G[93R]TG/>X`@++>5EBWZGFK(+URPIYL94>_6#>LWO*NN?LR69]9]"SCU\nM`\\!3+NZ.1E>^_:^P_?NOOT#'[AYRT=NO1S8\nM-*IW_U$`OZ%IQFM>1CE(=^I\nMJAI&C(R4ZHHC(ZU)'*[6\\LC;=NS^TM??N*S71-'K.V8:=6WT5'2DMXL#'3OK\nMXBCN$E+?GQU$DQZ.LN@````!)14Y$\n$KD)@@E+?\n`\nend\n 6604 notepad_zoom_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```+H4E$051H@=69:8Q=UUW`?^?!V[GMB.8^S$\nM%"=-TK2)"!"$FIB`:''5@@1\\X`N;J@JJ2*B!1*)&0J0;17PH$:6`*"TI"+<)\nMP@EI4H?8\\=B9)I/8$X^7\\>A0_WOIGQ]L8KJ$X92?O_G.8/B+I&7(H+RBLM9SYZDV_YN8#//04G_^=G^/8R>FM]XX,\nM_:XR9OC8Y.P+WQN=_%(AX]?&]N^[J=?==(!M?_`<8Z=F,\\_LN_^Y[JR_\\\\1T\nMY4@I\\#XRV?(_6UU8^.O[FJ]R^`CQ<\\+[6F4JD4@S",PC`JGY\\Z=V[G\nMKMVM;W[C.5YZ\\;O_/P`[/O-W.%(,/7K7QH-G%\\+G7BFE]S^X?>A[?5VIT>KY\nM\\[]YGSNQRO6\\7ZU6ZWM+I?+(0J6:CI0R8*O6F*/-9O,;I=+,=W*Y?/5OOOQG\nM_X<`CSQ-[\\AM5.9J/<.#Q5\\97C_\\U(;A#3/;-Q1^V)N5C[T^-ODC2E-?>GBU\nMV#+[_X\nM_!6O=6Z&[/E?^PJA0!8S_D,/;%OSEY_XT.V_%2F5-Y+^P:*W\\^14)35Q9F'-\nM@T/R%UX[='C36S.-Z>UW[9P>V;JYTMO?5S*N-]&$L85F<[11K45IWWO$<[TM\nM4U-GOY_)Y!KOOGWTBG=WM,#3GQ(`>6'MXY[G;O-3ONLZ`D<89#)=J=&X]IOF\nMMWOZ1Q[]V,-WKAU45O+FF2JCYP.4F\\7WTSPQK#ES^"`3]/#$S]X?BN9,LU(Z\nMV3IW]JU*JUZJ^"*,/*&5P,CI&6_;7*78/3,S^[EO_?U?_>E/WOLP__/JBY>5\nMT>T$(`488_<6^]=^;?V6!WRC&D2-:718Q48UC*IAHRJ'HWO(K;V?M8/]'!BO\nM,=401#*-W]5-UG>YO5M0:+[#?Y0B?GW?`^0SOE^EQZ\\VWBCFQ/E5JWI"TB+$\nM$Q$"&,H''#]5)(R*^W[J@9__VVR^.'DE&3L"N*Y$*SVR8>N#?K[8S\\G1[Y+N\nMWXI,#2`Q>,)0"ER.U/;BI=?STCF!]+K(=OETIURROB3M2[;TA)QZXS1#PQL9\nM*&:8;X8(/TLS-TQ6E4EG+6D9X=LZ3NT=KED^#E6?O37Z2OIQ='@",%+TU44*_/T=6586W>IR_GT9MUZ,DX%#,.\nM.5^2:\\WR_'R-@=LWHXW!D0($%`NI:^_%X1#JW(6Y_B3Y+V`@8*A'!92\nMF71J=;ZK>&4E=P)PI`%KP88(H7$_[;!S(XR?_<[X5\\YB\nMP3J.$UAKKA<@7H752,SBY^5CQ^H\\6_M]K+58+-8"R_=`::Y*;U>&B9D90KT5\nMSW%P)+A=7632/MH8E!%H"WA9TMT?P)3[49K:;'GNI)25ZP<0`%8AK,)Q+DU;\nMKNOBNAV/03H>6S:M9_2_CO#>U)V,K.X%!$9*-()6I`DB0:`,/7UW$'H#S+5R\nMO'=B8FS\\W7?'AFY;=>6S.UWL.FT(';M0(KWM*.ZE(Y=-LWW;"%L&1KA^!M)K&#T1<>)D"3G[GS^\\[Y>>G6W4KVR!C@".\nM)-&Z0J`7@^]:AQ""S1O7\\=`#>^A7\\[Q\\X`!OO7N*N7J+:BNBVE(TFP&EJ6E>\nM>;/"X;$Z?OD[_/*.5Z+',I]@_/BA*YY]E3&@XCCHB-MYI%,^>W;O`.#@RZ\\Q\nM\\>H+S'1U4R@62'LN0;U&8[Y,?6&.>W4`:$!?-HBO\nM9>2R&3Y\\[VZ&UPUQ]/C;G#CQ/G/S"T0UA>NDZ.[-LRE]@/[N>R@ULASYP?<'\nMG_K:VZ#IN&US&\\?BVMH$481F`M)^8$\nMA\\?'6#?Q!1[.#-+C/,KK7__1$X_O&1S[_&M'GOEP-J4/-H)+9>QTF2,$CA0(\nM%)(;1=":-L8"C*80OX_[KL]P9S:3NVK;Y]S]SS^['\nMO_W%_8Q<1GL=19(R[H>P.H:X=2^@6$M/]=RQ:=U3\nMO_'8"Q%N%8W"SD?D92V2ATW]EQ\nM^X&@M.7N'7<\\<^CXVZL^.31P]0".B$TMDD(F17S)K7B5MMC8A21(%U*]%OL0\nM!Q#$`$)"\nMSP[>.-$43T;U2G7#Z:-B^]I5O_'IW3_QJ1>;`?Q]Y3]QU.A>-:;/F4VSYW(;!KH?O(7"YF/[AHH\\$&YD@6(\nM+=`N9`*PUMYT`F,MD;9)$"<62``._X4PQYKL/Q>:Y\\/)=[#U\\IJ-_85/?OG\\\nM@NNO!"!$/.,LI&'1A6[.L!8B;0F516F#,78)P(GG;7M@5<:;'6W)SYW/]A[:\nMF=7_M%Y7]]N/#2LI5BAD0H+4Q#&06,#<)`.TM:ZT11M+I%D,8N&`-&"(]Z/D\nMF4L[QWJFIA[/-]3\\_5GJXML3P$H`+%D`JP'0]L;$MX`VL>"1MBAE$@`3GRT2\nM[1L0-DXD3X^7`>Q7X,S%YZT($*M=`0H$W(C\\QEJ4`:7,HO9CWX]78\\"Z20LC\nMDP2R0O7O#"!B+6`5UD9`K+WK8;A`ZSK6N-*6R-C%9[I]L"2V1#L&KQ<@I@"C\nM0Z1I`8F?7@.!!70B>"R\\60(QADB3N)!=C*]V^K:"%6MF9P`12V!4`TNT6.ZO\nM=AAK49HE;2<`L?!+S[2)/VN3O$=?0Z'O#)#D?*,"K-L6ZNH.;FM574;S2P!)\nM#)BE&#"&V`S)/3?L0G;9Q@)FA1BPEF7"&2+5%K8=N/'SY5#:D,1`$L@V2186\nM.GRCLC)`VUO:Q3V/BH%P>K$N"Q[E>&7/A<[,,P(#1L=#M>4,6,,N$\nM;VOECG$Q978\nMV,3?U86I</C9$O%-F^]7:<\nM>8E1+$+<4"MQJ?8%U4!RX.TF)%:(K12G/VV33)*LVMBE?9(B(Z5IU&LLS)68\nMKU29*4_0/S#(GKMWL3XUB2P+3)2XCV;%'\\&N#L"`D2##$KFS7Z=E,LFWSW%-\nM,+37>-_.7NT@$A9DVYQ!B*W7<&LUO/DY-N<+;.K=3/_-YW#3>=Q4GD1GD2Z\nM$NDZB44DTI'QRXDP($V\\"AU;@CC1VR0[6&.P.IY&6V$-$QC^8:7&;L6^[U_^\nMR,$8ZSL.:=>QN-+B.?%O!ZX$+_D*7CI+[[++WVE%\\DPX<8LLEO7Z%]R^F.D$\nHU@K0!#(E@FC>LO73*S1$/\\[C?P'5WY."ZM%]GP````!)14Y$KD)@@MR^\n`\nend\n 6605 order_add_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```0Y$E$051H@=6:>ZQG577'/WN?U^]YW_-B9F#$\\%*!`D*1\nM%K%6;,4&J\\8^-6IIHFW3I&E]1FNU5A-:K8U-&H--J);:VE";4E"*%$@NW.^UW>XYT'Y\\%[3RE['.`=Z^?>OX`,>%<^(R(,\nMAWT&_56&_1ZCP6IOV.\\?;,UNRN^[\\5TOJD_X)=2ZG/.>^Q9Y[\\V^"2W[RW.3%3]._YZ],#\nM0&O`$R6!:NR:28@"$`?B/FX07^U\nMUCI\\=/%7DT;[%ZTU7U]>7+AQ\\UL^/K]TSU=AO'R*`)3"`[50\nMZSPBY;$P@A6/N%+Q$W)UGV/]7!S5-8^X&"L-LGR"AUW&CM;VR7J]\\?N'XN3\\\nME>-'?V?[FW[OT/QM?PZDIP*@-+W6"JW@H0>?Y/#A51P:*R&HF*M^]@R:$Q%=\nMXTFMQTBY6W$8\\13B,=9CY<18(1O."Z%GA$NWUMBZZ0J:K?:U3Q[<]Y>][LK[\nM+WCWGW7VWO)'IP&`*MWC[O_>SOC>O2L<&P=\\\\VNSG#N3<-0*G=.$K8@H4"21)A%`.;S7\nM9:#[4@9PWH'7>*IQ#R6'1:236_CJ`\\\\R80>M>Y\nMZ^5:(-`E#6JE4$JQT(VX];Y%.O4$+IY`G3=#V(J)M*(6:FJQ1Z$!!TI7;]D@\nMJS6Y.JIRW#=;C'3,IKKET@MF^=^GEEE:Z)X=9=E.H+.FS\\MR(0"E2D;J33;H\nM[)B"LZ=AQP25,0AG%F'39$N\nM@]26NZD"V=@JF-=EA[%^0Y`["O$T0TT<:J(PH-5JXUP#3@W`6A`KE((W7U#C\nMC6*K62OPOD!23\\][0A0-[Q$!ZUQ%IR7WBR[S@\\4C"B3P2%@RT5K>$.=1.B`,\nM0@*M"+0F"/1)^KST3*P`2@IUXGAB99&BUL0*U>PY"B/T.UVB]G1%DS#J][`$\nMN+"V/OMY?Q43)%BBTCI6L*-5\\FB"PD)N'1>T+6^^:!=!Y;+/W5YZ$"N%5Z4%\nMP$,0$K4G0$"L1UF'SRTF2E&U%L9"+IXTR+&$N+!![ATYGI0QA@:%BLEQ&"\\8\nM.R;5#0KQC*UCIQT1:D6@5?6;IPA`:_">]1C0Z9BPLTP^&##9;.,`:X58ADSZ\nM&EZ#TS"H901!0*VA,;9TD0X&H@R"*LE985PWU"<,UBF,==2=)PP40:#6">34\nM`%1Y0*FR`FV$$1.-.FXT9%.[@5(*:X7$I&R::0&@4'2U)8I"FJTVXAS.PY+.\nM2>H-PB@IL["UK"0%$],3B%.(\\PQZKO1_50%X#HA3*B5`X;W'>T_7.I:&!NL@\nM+RS=3D$BZ7JI,%P=854`D:.PCD(@7>UC0X-5<7G-"&;0IX@#"BFS\\R53!;^R\nM0Q/H$\\1QZ@!4R>9*@3A'411@+:$8M`.ET0Z(PI-UNX[U'*\\72\\9!VJT52JV&=QQC+XE+$S.QFQ(.(\nM9VEYF4!368#3Z$+55.1YSF`P8+$_9"5(HS1#G*:PPI0WG\nMAWH]!DY?$"M5N5!"J]W&#<>LQ`V,*#)KZ+^*&_0"C0EQ:QL4@S5AX\nM^B#SBT^PTITG3?N(=&7!MI`FT/ETNI$\\$L5(88QD.\nMQT1YP8SD@,*$0C<6IANV:E*@KSTZ`*?'_/O]MW/K/;E9\nMAQ9'YPE=@?8X*^S9]C&.3K\\7<9X#^Q[AEF]^C'-V[.#O_OCKG'_6^:P,5C@^\nM.(YQAD(*,I\\Q,`-2/V9FTRQ7MZ[AC#-V_G]S+.UY_(Z_#0>)32A(%"J57P/<)`H;5#`8$.TR-**PX=.\\0@'Z`"Q:[)7:3#E.ZP\nMR\\26"0X?>H:1C!CZ,>WI-I=?>#F[#_R0?[KO#\\+SME[3BFM->"VPNP(@MDPV\nM6L-H#/N>KG'M6VX@KD]Q=-^=;#WKU01QF\\6G'F)Z9I:H,47GV$&2P-*8F&'8\nM7\\$5*:UVA,T[U%O3V/P`NR8;!%MKW/2UO^+LV2D^_\\'/D]N/C[P'0XY1.49E#%V/OENE/=OFJ?DG&@M['_\\@71YF\nM*_UU"]@-`$2@W8PY]Y)WDK2W(]T][#K_&L+F3NQHGDU;SJ(^>RZ()90.K;F=\nMX`W%T%"/RT8E"&/L&`YU,[[UT,T\\XS1'-4"AKO?*_QJSW,3/KUE`2@#>\nME[)6GB)=0BFPMJ!(EQ&O$9-ATN/(8I>T>X"(`7:PF]$P1X5;&15'$*>I3>Q$\nMG.9XO\\MM]]W%.][P=K;.;66AL\\#(CAC9$9E+R20E<`J/1ZQ@K<5KQW*QP('>\nM7KIY%Q=9ZLT(%8`.%$H1%=C?=@O^7YGF^`M:0"N'Y"L8!4X*)%_%28[->PP7\nM]R'Y/.D@0#>GP0VP5H-2:%2YWNE"O`M8?/81BO$2K[_D&HYVC]+/^HQD1.K&\nM%#ZCDMRV[D+65O>75B`@HS]I?%(8<.;"`QS,],\\5K)B[C\nMW,T7K#=*SGN\\P/SP6;[PP.>P=@EC!,G=>9VOC>*37,AKL%(N--FL0S$Z@LFZ\nM.)V72HO"6H78\\AEK%8&4L@K*@"J7T2.R`OH%G!''],8]YI(Y%IY<8/[P?/6A\nMPY??&I3"BJ7=;G/--=>P=_DK-Y%E&0_%>!DCVTMEJQFW%1!C06P)P%K05F$]B%VD/W-!=?<3$?W_6Q;GY_GHIS]$\nM;7/9U3EQ6'$H`L)9A=U3$`8!0:`)`CV4KC:E&=.^_\\#V8OC-F_^;MD><&@G]*O]I5G>HSLD"`("'6(TNJP^:YD)0"I\nMZ+.B43Q84WT]V3#CUBJLG!P#OAH+1&%E[6->B'>:GWK%J_CAWB7V']F/K5F&\nM:D#*@%P/T#6AV8[9/#F'-`3G'-Y["IO3'7;)"\\,HR^CG*?TL)35CG/?4PP8C\nM"H_X_SGSS^=.9.+RN]::"U6@UMWFQ*Q+Y4ZF`K/F0E26<5[A"3'6<]6%/\\,W\nMGKR;.QZ^`SVEH>EIM&,F)NM,A@V=PE;*HW?<*V:V>?)&P)ZXY@()0#C.'O[.;SMZK&/+<`%(4A33.L$?K],;U>"6(P3#&9XZ*9GP8;LM!9."0C\nM_Y7M;YB1XS?U2P!RTJR6`(P%8S;XOZGB@=$29M1#3+"_N_'P[]PU=>>+VZ=/>M\nML_?LO^T=+O;3>60)@@*EX9:+2)IT*.[SM&9]RG%M2Y>/.5O'G7\nM]3QV[%&^]9._[\\TEYWWCAJL_.<0'Z&#!+S#$:*".AI!Z0CG+$<>^P[6F#]4BB_=\\&.@\nM1\\`K^'6:?%:W]*[69)U6LT&]%A'5`FI)3".I,=?:Q+ESY_/:,ZYD4WTKW]EW\nM.]]^_+;#_=[@4_YH=`M-L?-?7CFY(Q-9![#B/0>U[\\BXV\\&M]<8;^^.J[%Z3\nMGWN^=K\\'[3U=`!X$KD"X@W_@K3SNE/O02&77A2J>G$JFV5;;PJ:).69:L\\PT\nM9O#BN6//'3QV=$]_\nM1%X[7Y>K58BJ4ABN_]+#)5NB^!$K_):(7-XQW>OZP_[ESQX_LJ.6Q+4X"D'Y\nMW#ISQ(K=C>';C/3#ND$Z>&C$X"&>M[WD_U8Y;=M%P!**RVA09S:HJ5H0*+37\nE&49ULA^8D=JLO'_(O^AK_@\\/0I2A$8X6F0````!)14Y$KD)@@C:H\n`\nend\n 6606 order_clock_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```1*TE$051H@=6:::P=9WG'?^\\[V]G//7?S=J_MV+$=)XXA\nMH10(M*R!A%")$E':)K2BM**HHJI`E4I5555;*M%6I8(O5=-6*O`%":D1%0V)\nMLI"DD,T8QXX3.W9LQ[%]?9=SSKUGF3DS[]8/,W,\nM,0P&/?J]90:]%8;]Y95!KW>Z-C&5/OG53_Y"??PW@UC`)X407['.60>`PP%N\nM]0[G"IEB]75DMRX+*8FB,JJD4)DB2X;#X]^X\nM-@"D!!Q!Y(G*SO&(P`-CP3B'M0[CP%HVR`[C',86WG%@"LO;*YX+R"9"DKA"\nM;[E4>VUN_E-1I7Z'UNJ;2_.7OCI]YY(^R]JYL137',:&:%-AE#9XUHZ8J6UKELN5+[P2\nM1C>T%^<^O^U#?_3*Q>_]/9!<#8#<]5(*I(!GGCK#:Z\\M8Y%HXX,(N>T]6ZDV\nM`KK*D6B',OE7&XLRCLPXE'9HL[Z6F0WGF6%%&6[=7&+SU"]3K=5O/W/ZQ#^M\nM=-N?V7_OWW9>^O:7K@$`D8?'HP^?9&*RSJOG1CSR1)O+L<=W_G."O>,1<]K0\nM&5E2[1AEEI&VC)1CI"RILB3*D:KU:Z-5.5/8GN#VLF(J='!@#[5Z_:Z%^Z"Z7`:RSX"2.8MU!SF$!27,3]_WX/`W=9^^F">K2]_PM6WX[+->^O=G9\nMSD-OU@.>S&E0"H$0@DO=@.\\^.4^G',%;&HA]X_BUD$`*2KZD%#H$$K`@9/&6\nM#;)8E8NCR-==M<90ADR5-;?NG^#(V246+G5W!:/1+-!9U>=-A1"`$#DCK30K\nM=&;&8%<+9AJPJXE?7?6`H&1SY1PR+PYL`%%X0K#JE6*]X%?K0LJU"J4HH#'6\nMHCP0D\nMI#K_JB*1E2Z2>4VV*.TV)+DE,XZJ+PE]2>![U&IUK*W`U0%836*!$/#A_24^\nM8'1AM0SG,DSB6'$.'T'%.8P!;6U!ISGW&YG7!XW#"#">P_@Y$ZW6#6,=0GKX\nMGH\\G!9Z4>)Z\\0I\\W7HD%0$ZAUEA.M>?)2E6TH;">)5.&7J=+4&\\5-`G#W@H:\nM#^N7UJR?]I917H0FR+VC#7JX3!HTR#2DVK*_KOGPP9UX1-)[$0.)%[\nM`!QX/D&]`0:,=@AM<:E&!0FB5$-I2(TC\\5(T/M:OD#I+BB,A1E$A$R$I%N4,\nM2L94`I`3G6,L!F<3XG272?I]FM8X%M#:$9D#3\nME7`2K(1^:83G>90J$J7S$.F@(!B!5Q0Y;8C+BG)#H:U`:4O9.GQ/X'EBC4"N\nM#D!1!X3(.]"*']"HE+'#`5/U"D((M#9$*F%JO`:`0-"5FB#PJ=;J&&NQ#A9D\nM2E2NX`=17H6UIAUE-%H-C!48Z^BOV#S^10'@9T!<52L!`N<AWG'%((%A9]ZK4:4:F$M@ZE-/,+`>,3TQ@'\nMQC@6EI;P)(4'N(8A5)@B35/Z_3[SO0%M+\\(Z4,K0;2]S-O,+/H?^RC)('R^*\nM,<9B'/2[;634!R]"&TNF#?%R!UE5*`.9MFPO*SZR96O.0J^3Q5?5C0H@#$-J\nMU2JR-"0.RF@#J5'T1$CJ`C(+J1$,=(!V'L[Y9"JOLLG0PZ82)00C)?-:T!.D\nMB2#3D&0"?QK":QI"&UB((@?2+*/J-+.!1482$TDZF9(Q&*T6B%)U1\nM!H#2AN4XQ0Q&^1`/K`Q3G-"$RBMH5-#K)I0R#S_0^7AI#)U.PH5LF(>BMK0\\\nMQ0V^7,N!:Y?$0A0A%%&KU[&#F'9801G!2&NZ9LA"&JXU<8.>AQ(^-O'(M$0;\nMD'%()3%$,D%:@]::4:QI=P?,CWSF$LG[-EL^%.1]T#4*(;F>Q$*@E&8PB`G2\nMC'&3`@+E&[JAH571Q9`"/>E`6**R9;D_9!!GU*H>0L7AAMB*(.S7(3(ZN`P%<1I2@D\\"/$*$:E?8X>.9Z_1(\nME`$$GG`T2@%;IEILG]W&R+9X],EG&=5VX'F5GS-H[@%7S!J"3^/X4_*.EK6O\nMI1@'821QNY?N;FDQAIH'+TE9T19I+)U3L@#ML-IP;,N?,=?Z790QJ'[*C%BA\nM&G@<.7*41W]TB%<&$C$Y2VO[/FJU"EHI#'!Y..#5Q8L\\?^80NZ8;[-M[/:7:\nM$J)U/:*Q-;?F1@#6Y)86@E:FV/$__PN#85$\\I(?G620.(22^)Q!B&=P*OB>0\nMTB(`3_I(H1$"6F-5FJ4A%=>G)3693HDJ/J44'GSP$1XZ?!H]>Y"/?/16/G!@\nMEO[\\:_1Z*R@GZ?<'-*][&V>7^IP\\=Y%3QP^Q]/1/>,N!?523N#0Z?_2ZF3T'\nMG_[4I_^`[WSKOAR`T7FQD1*&,9PX5^+V.S]+6!YC[L0/V+SC)KRPSOS99VB-\nM3Q!4QNA&GN?]^9''_NOPS.S.DVL>T!L`&`/U:LC>6^XFJF_#=(^Q\\X;W\nMXE=GT<.+3&W:07EB+QB-;SK4)F?!*;*!HASF@XKGA^@83K43TM-SE-,^1X^^\nMP(.'3E)_R_OY[/MO9*KJ*G#8S]ZCGC+\nMC=SS*P8[39\\\\S-KT%XZ`ZL8G2^#3M..-R;T2R-``A,,-E;+_#W+E7F+Q^\nM/PO=!187%FDT&W?OW+WW/X(@?.YU/2"%Q:1ME`!K,DRZC#4I.EUA,'\\"DUXD\nMZ7O(:@ML'ZTE"(%$Y`7)^F@CV!))%E7"4R=>YI4^''CG`;:/5]#6(8*8;J=#\nMM36.M8Y+_1$75Q(0$`0>GA3T%_N\\].0/\\.LMMK]]&G'P;70./4ZE4ID2POOH\nM]AV[-P!P(&TN2^'0HS8XC=&*TU=D;\nM&*OX))G&"`$UZF)EFBMM!%H+\nMC,Z?T5K@F5P67LX(^39Z@#:2)!/$64RL#-5JA<6S)^D(RZ9=^_&B,N^\\ZY.<\nM?.&G_/"[WR1]Z'ZFMVQ%:<,M'_@P^]_U/J(HPCI'W(]9.'64QO8]U,?'48,V\nMSKIZJ52MRU4`NE#$&/`$9,,+]"\\]@4ICC%E7VAB!UJ"T*`#ELC9R[7GG_-RK\nMVI(I50Q`DG@XH'WQ'$DZRC>RC&5\\]\\W\\ZF>^2#)*>?J!^[GU0W?PCH]\\C%:S\nM2JWL4R\\'C#7KA)[#TR/*I8@@\\#'&"*V-N)*%1"Z#8;ATC"Q>0IEMN;*%Q74!\nM1&DP6N"*6O\nM(!_[%GMOVDLY]`@]\\&1>V7776%=7K2:O-E3FPMK8!F'4^1D.C7B<(?*9:3":B4`DI10*U2Q@P'!$;A\nMG"6.XV-//?[]Y;4<,!MR8`V46E5R73E3A),JP*Q=7Y,%CIR%FHT&C5J539NF\nM*??G2'M=1CK?P-(K"PBC$,4&F0!$O86=V(I_\\22>[Z'B(5A#R9?X`MJOOLI8\nMI42[W$W!P@-K82(V>&B#?(72ZVO&L`8@"D-V[9RA7J\\S\nMVZIBSQX#:['#9206YP5K'6\\V2DCZ/;)M-Y"=.D(V'-(;)G3GY@B%8/'294QG\nM"=\\3O';QTJ$X'OYPT%_F"@^8#2%DBI!21F#TZUEZ0]@4N;%ZGR-`F[PJ[[M^\nM)ULV3S$[NXWF\\#+9V1?PRG6\\L4UY@AJ+TIKS1P^Q=/XL:7,S<69(3AYALC7!\nMYNE-7)I;9.[X2\\Q.M3AZ[,5AM]/]>JLUN=1?Z>8`S!56S0$H#4IMB']5A(T6\nM16BMKRE5`"N.%"PTWU-<'$AF]AR@/M9B]XX92G,G&)X^ADDS(E\\2^1["&'02\nMTUN<)["6\\8.W,3Y8!&4X?7Z>8->F%L=?.LG)4V?^O=->N+_;6>3%YW^\\\nMWHT6\\T#.*#)`>"$2\\&P5Z1MD:`AHX(4A7M0C,`V"\\CA"](GP"6N3E*(5A`SP\nMHSK&2)8NG7S,&[AGP^:TF-@\\4VTO+'Q\\9O/4MO;\\:9:3%<3>FPEF9Q@;K[/C\nMA@-4/,=X*41MV<?%[M[SG@_\\LA$B_\\5>?\nM!XI]KD?_L1AR!']A+7^CQ#B5:@OG/#0E_&*0UT3X7H"S%N,"I!>!LUA\\A%=&\nM8A`RP%K-A>,/H)7ZHA!\\[7'UQSSW[,/\\ZGL_?J?G!__@K+TI33.,D(3-"2H3\nMDU2;S7SDE`*I,R*KJ0>2+$UX[M!/AR\\.T=!T3=SO8U=EXXWQK][O0#I'%^";]WV=C]U]+]NV[7W@U*DC\nM9SS/_Q*(3PCLA%U9(DM6$(L1)@H)PQ#?D_32C*.7Y]6Y\\Z\\=;K<[7QO%@_O]\nM,$PW*K_F@0?_+E=""*K64OTYI=ZD#`R`^'/_NOZ#'__4[Y&FH[!2J=\\"XM><\nM<^]RCNU"4+/.8;16:9HMQG%\\-(Z3!],T>:0UL6GQ\\J5SG#[^S,\\-]6_XWRK7\nMZG/@;>]FT.^*V9GKJT%8F@JB4DUK31+':C#HM?N];B>,2N;DT:=^X7O^#^3F\n21IIHX^#)`````$E%3D2N0F""\n`\nend\n 6607 order_help_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```1.DE$051H@=6::[`E577'?WOWZ[SO>^[+>4J??[>ZN34REMW_YW;^U/_[S02S@W4*(+UKGK`/`X0"W?(=S\nMA4W1^BRV6[&%E$11&552J$R1)7%<+I=N>6K?X]_RSOC`;=7&>-:]]1^/#P`I\nM`4<0>:*R:3PB\\,!8,,YAK<,XL)95ML,XA[&%=QR88N3M4<\\%9!,AR:!"=ZE4\nMVW]H_KU1I?X6K=5W%N?GOKSFK9\\]N'#K-V&P>(P`A,`!)5_P\\DT51BH^QCJT\nM=1B3'S-ET,9A;-[Q%;NXSW+DW%B*:PYC0[2I,$P;[+1#-M36CY3+E4_L":,M\nMS<.'/K;^S1_?<_!'EP/)L0#(72^E0`K8<=?C[-^_A$6BC0\\BY-6O74>U$=!6\nMCD0[E,EW;2S*.#+C4-JAS4I;9E:=9X:.,IRYML3:J5=0K=7/?7SW(U_MM)N7\nM;/W@W[8>_NZ?'0<`(J?'+W[^*!.3=?;M'7+S;4V>&GA\\_^H)-H]''-*&UM"2\nM:L7J"NO0]?V;FHK!<^^Y:9ULW\nM/5\\/>#(/@U((A!#,M0.NNWV>5CF"TQN(%X[CUT("*2CYDE+H$$C`@I#%6U;9\nM8MDNCB)O=]4:L0R9*FO.W#K!O4\\LLC#7/BD8#F>!UG)_GA>%`(3((U)GI$)K\nMPRB<-`8;&G#2"'YUV0."DLT[YY!YUQ#E&\nM%Z.6X5R&21P=Y_`15)S#&-#6%N$TC_U&YOE!XS`"C.>B05`'D*ML>QJSI.5JFA#,7J63!FZK39!?:P(DQ!W.V@\\\nMK%\\Z,OII=PGE16B"W#O:H.,ETJ!!IB'5EJUUS7FG;<(K*/OT[;F+6`B"W%DE[/4:J=2R@M2$T?49<\nM"2?!2NB5AGB>1ZDB43JG2`L%P1"\\(LEIPZ"L*#<4V@J4MI2MP_<$GB>.!)!C\nM`U#D`2'R"K3B!S0J96S<9ZI>00B!UH9()4R-UP`0"-I2$P0^U5H=8RW6P8),\nMB!N*82@D0..=PSM'6EH6^0EM(\nM,TV[E1&9Y$BIT%^*T<*#P))I2V8@6>JB?84687Y-&52O2Q9Z9";/SF>,9KQG\nM@\\23*X'CV`&(/)H+`<9:LBP#K?&-0EK`&B*GJ:#0`HP$/)-'>=^@A4-[$(<6\nM%UBL+$)KX$B4PY5ST*ERC$3@>P*_J+V.'8`4N0:*B!`&`=5JE>G:@.G)$804\nM&&-8##1KUTX`((2DU?8)?)]ZO8YS#BD$"X=]ZK4:4:F$M@ZE-/,+`>,3:S`.\nMC'$L+"[B20H/CWFNWV:7H1UH)2AW5SBB99/8PZ82)01#)?-TI"*]O&#/*QJ8VBWAQS2`XQU9,HR\nMZBFV^/*(!HZ?B(4H*!11J]>Q_0'-L((R@J'6M$W,0AH>*>+Z70\\E?&SBH8U'\nMJAVM0XJ%Y@&:K1Z#.$$;B[09_N0&PI$)\\$/.6^]XLY_70<>)0G)%Q$*@E*;?\nM'Q"D&>,F!03*-[1#PUA%%Y,4Z$J'D(Y2!7[SZ'[^]?J[>."1`X3",35:I5(*\nM\\:RE/T@Y<,^]Q%:R<<,DM0O.0(@M!-YOH9"[F^4:O`&,.+MJ7:=6`?#B,#-4_8:-/P6DT%>7AAMB*(6(^41C*P"@D"7<`Y^>MM]7'7M\nM+9RP;H(O?.Q\\7KIU$Z4H($Y2NOTA[4[,P?DV#^XZR([[]G#Y-W["8C/A]%>^\nM,J]$G3L*@`!P_U/,-00?Q_%I',:N!F#SYPK;:4;'M!@=]R4D28K6%FORR8@M\nMEE*L-AR:^7,.C5V,MH;%0_/\\X'LWT#[U)V8'-MFC/GE)\\^>6O&`-7GG\nMA&`L4YSPXSN@'Q?)0WIXGD7B$$+B>P(AEL!U\\#V!E!8!>-)'"HT0,#9:9:04\nM4W$]QJ6FF\\1<_U^WHP895W_YHYRP?I*G%CLH;2F5(C94JGG$R2P+K80]![JT\nM6S&Q@NGIC;Q,CK#S_GU<=]WMXJRSMOC6/HU"1N?)1DJ(!_#(WA+GOO52PO(H\nMAQ[Y"6M/>!%>6&?^B1V,C4\\05$9I/;6;R--4&N/TNTULEE"K!^BT1;DVADX?\nMXX21,J>=.,F55^_D\\-[]?.NR/V3MU"B'%I98/SU&.HQYYN;F4$H1A@&S\nMLYLX[>P3V?EHAQ_O.$`K,\\24&5^SCD=V+=8?>OC6=YB#O_XE)W]2L_O*'(!>\nM!<`8J%=#-I]Q(5%]/:9]/YNVO`&_.HN.#S(U?0+EB\\B]/[^7JZZ]A;_^XW>Q?GJ,?0<7J54K+"X=<8I[)MKTNVG2#\\B"`UGG746G_K4IU@S-86Q\nMANW;MW/%%5_CFFO^C7*IQ!_]Q>5OBAAPF]43L0'W7-1V[CM,\\-\nMY;('EO<<@,6D352R@#49)EU"Q?O1:8?^_)VT]UQ#TMF%T2DZ[:&U1AF!UJ*@\nMHX^QDF`0<_"QO;SMC2^EU8E9Z@[HQII.7S.[\\43>]_Z+>/Q@D^T/SO-PO\\:E\nMG_@TOW?AA0#LV+&3DNDRL\\;#'ROG^V@)?R3"JU=>)Z=.VBK'UJVBD`-IF(Y[/HX*WAH]U,@-K)N\nMS1@+S2[]Q!`//5IQPEQG'[^ZYS'2:!UA8X:]2SYG#AP;-\\X"4*E6<8`2*?YX\nM'1*-"21X`F`**J\\0I?H]1RBD;;%<6%#(I$VP*48/Z7+Z`%:P?QBER@*Z,5#^HEED`;$RB/!D4B!\nMEK!EXR@O.VF<]<&0KW_E2]Q^QQU<_*$/<=$EE_*%NQY%34_BBQ+&+^H("U99\nMG*E.-?_NX^(9%#(F]U(6'R!I/8!*`TRTTFEC!%J#T@)E!*ZPI2_11[[6^&@#\nM6CNTI^GT$N)4,L@DL3$,I6#@"<;J$1>>-L&-__$]/G/U=ZA4*GSSJJLX]56O\nMXN\\ABED4ELG.4EA'4X9?!2'W3H^2]XJ3@Z"HG#_98!%EUN>=\nM+49\\6>Q*@]$Y`*U!:H%V8)S`XF.-H%XMLZLSI-,;,E`!@\\QGX#3#0)+XDL!8\nM>KT>7__Z/[%K]VYNO/%&6M.S?/(W3[!_10(R,/$ZO.\nMI3__B#TZ#RP#L)HT;F),/KK&Y,E.&=!F!80VX"T#,`*]7#>Y`&,%&]=-LOW`\nM@&8GQE`CSC2Q$/0S.*0M-4#Z:SG[[#>R9F!0@.F")]%(L.!5L77DU4CKK5`FZ,UX(HVSPBT\nM6?Z8YZ,4O.24C=@=CGL?WD]8GJ*GZK2M1UL(!F6?C>6`OBSQV<]?AK4&[:#_\nM^!Q!O817#[&I1J8&Z4N$)Q">H!;Y=#PQ!'./:3ZY(N+EHBVG4`'J"&U61MT4\nM=%(%F&4*47C&.H'#1RG'YA-G>/$I$3?>>C^RW,6%,\\A^B@A=YS(Z4F"Q[\nMJ'2`-89RN<3I,VNYQSA<9G#*XJPM"DE'(_"HA8:FT0^Y++[;F81G)C)=>.`(\nM340AR*?9JP2]NLT8,_J>BQ?TD_>M\nM>,"Y8IVGH)`I.*Z,P*SVP-,Z+8O[,`)?BUP#!(56'+]SSIF\\_9S3N>YG>\\`J\nMG#98;1':8I1FY!\\Q1HYH#4!J46L5_5=!&"[0Z6AM*%<"*(_@8`_-=\nMQ7SBRS%?]G;&3GG?>ST9[CI\\1:ZDY(U\nM!Z3-`>NUXY)U#6RLV+LP&&X9K5QQ]AM>/S^X\\PM';OV_5O7W1TKPP]_>>TJ`":O:1#YS&QZJDZE.H9S\nM'@U\\?#F![Y]??O>\nM;U]QZ?5OAZES(5GZ#E'IU_\\JK;?G3IU^A^^T^?-J%9`=!TCMW2M>IPWT@<%'KUKUB[._#PN[!%O>LD[61UXO:^77^)7P9*\\25F7)!U\\F\nMQF.OP]PE]>!6]MVWE_JDC?_]LSS;]IS_K7)MH\nAUSF<('#Z[G_^/U_QOQ0U-?Z(8@E_`````$E%3D2N0F""\n`\nend\n 6608 order_next_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```0Z$E$051H@=69>ZQE=77'/[_?;^^SS_O5BK-I6&6E]I4V.K1MM:;-54FX94FZBQ`BF2%%M%BH".\nM@`C*2V%@!N8]=^Z=>\\ZYY[7/WOOWZA][W\\<(L9&9I.E)?MEKO\\Y9W_7XKK5^\nM!_Z??\\2O^L+GO[>`@%.=]UN\\QSL/SH/WGESV.,`[5LZ]?PX9\\"Y_QUK+<-AG\nMT%]BV.\\Q&BSUAOW^GOKT;+KSNK?]4GV"YX-8P-N$$'_CO'<>`(\\'_/(3WA]_\\>0`D!+P\nMA)$2U2U3$:$"Z\\!ZCW,>Z\\$YUL@>ZSW6%=[Q8`O+N^/>"\\FF2XSC*OVE.66*JUJ@'4>XSS6\nMYL=,6XSU6)UC\nM]E`(IX/[[GN'@P24<$F,#$"5V7'@*M69(5WO&\nMQJ-MOHQU:.O)K$<;C[&K]S*[YCRS]+3EW`UE-LR>1ZW>N.29/;L^U^NVW[7]\nMZK_N//'U#Y\\$`"(/CSOO>)+IF0;[]R5\\[P=MCL:*F[XZS;:IB#ECZ22.U'B2\nMS)$81Z(]B7:DVC'6GE2O7DN6Y4SC^H)+*IK9DH>S7T2]T7CCPOS1J\\OEZ`N;\nM/_9?W/[)-SY?`&(%@``\\5>;F`[YS7\\SCPQ*3+YXDJ(>$2A"%DL@"PN&]S!/=\nMYS*`\\PZ\\Q%/<]Y!S6,BXM9XOW7N`IAFP;?TT#1FH8./&*TN5^M->Y_?EZ\nM0,F><\\G4H$+VLB7CQ%4"\\12D$YD)1+'H$$'`A9?,L:62S+\nMQ5'D]WVMSDB6F*T8SMT^S<-[%UDXTMT:)LEFH+.LS_,*(0`AI1R%-"KV!\\)$%2]QUHPSA5TFG._E7E],'BL`*L\\-LB9:+EN6.<14A&H`"4%\nM2DJ4DL?I\\ZM78@&04ZBSCMWM>;)R#6,IK.?(M*7?Z1(V)@N:A%&_AT'A@O**\nM]=/^$EI%&,+<.\\9B1DND89/,0&HY!X`#RH@\nM;#3!@C4>81P^->APC"C7T092ZQFK%$.`"ZJDWI'B&1.CJ9*)$BD.[2W:Q(QE\nME0<_E\\2\\*`+\\`XH1:"1!X[_'>TS6.A:'&.$@S0[>3\nM$=GQ2JLP7!IAA(+0D1E'9F&\\U,<$&B-*^35MT8,^64F1V;PZGS.1\\;N;)$JN\nM$L>)`Q`YFPL!UCFR+`-C"*Q&.L!9(F^HHC$"K`24S5D^L!CA,0I&)8ET`\\(@H-%HX+U'"L'"L8!&O4Y4+F.<1VO#_$+(U/0ZK`=K/0N+\nMBRA)X0%.8@@5IDC3E,%@P'Q_2%M%.`]:6[KM)?9F0<'G,.@M@0Q048RU#NMA\nMT&TCHP&H"&,=F;'$2QUD3:,M9,9Q6D7SAHVGY"ST'%E\\0MVH`$JE$O5:#5D>\nM$8<5C(74:OJB1.I#,@>I%0Q-B/$*[P,RG5?9\\4CA4HD6@D3+O!;T!>E8D!D8\nM9X)@'91.:@BM82&*'$BSC)HW;`X=,I+82-+)%#,SI7Q6!I;*(4H%U.KEO`M%\nMT&V/:30:E*(HK]3&T6EKIJ8GL3X?A))AOZC"XB0GX1ICZ78SYDR2DX.V3"C-F8%<\nMR8&3E\\1"%"$446\\T<,.8=JF*MH+$&+IVQ$):6FGBAGV%%@%NK-!&H1UT%Q(6\nM^P=8[!YA,.Q@C`6M41,O(FIL@6":2S?!Z\\*\\#SI)(217DU@(M#8,AS%AFC%E\nM4T"@`TNW9)FLFF)(@;[T".FIU"1[C^SEAKMNXM['[D:X$3/-)HUJ#85GG(V9\nMW]^CKP53S:W8ZEMP;BMA\\$M"R/^4Y1Z\\";2\\6[.O4QR]S8_AH;I]9-WW)KPX\nM!9*(T,]344V:08>9,&\\OK+%$48=6I865-4`0FC)*21[?O>&S1&'$AW_G\nM][G@[`MHU)HD.J$_[K,4+W&DP-$Y-&3$P%$L;C%&,4J&40^(10A(H@1!+X'L$2B"E0P!*!DAA$`(F)VJTRB.J?L"D-&0V\nMY=OWW\\BNW7?RQ0]]@1TOW<%<9X[.J,,H&Q'KF)$>$9L1L8T9V9B1&3'R(UK3\nM+;WWL_DU#1A=8+.T3U$RE!M3C'LMW'9F'HCQ*0=*O5)3/H4\nMIS6>>Q]^A>!NF`D_-DCU]#C`3;36P%@U@"P%AJU$MO.N9RH<2JV\nM^QA;SKR(H+89,SK,[/K3J4QO`VL(;(?ZS&;PFFRHJ93R044%)4P,>[H)^W_Z\nM&'_WE4]SQ>NO9,=+=[!W?B_#;)A;W.:*)R[!"LTYIYW+TYW=/'GL<5)&S(T/\nML+^]G\\5^F\\$XQI^'O9#/_S-*R!VP.P/M9#1,$<$&1MDAK).4FYNQ5F"\\Y/8';R-4DLM?>SD'\nMCAV@E_1RR]L1J4O(BN6E9[HTS?3D#(D;)14:,**H"8CI!0(29!B\nM_M`_[6]A`T>?TP-2.&S:1@MP-L.F2SB;8M(>P_E=V/0PXX%"UB;!#3!&@A!(\nM1+[?Z0*,%:P+-,\\\\\\7U>=]YO8KRA/6PSLKGE4S]&^Q3C,S0I0D*FW+#XXS&N;Q1\\Q:TR>E3B67:#7!.R5K6^NA)!QQ79A$4(V;8-+L29A<.1.3-+!V6F<5UB7*VV,0%HP>BT`@?,!\nMWDGV''H&(01A&+(4+Q&[F!=N?"$E0HPW>"Q>>!`6J22,)'OW[65J:HHLS3BC\nM?#;OV/9>;M[W-8YVY_-=[&+3P*1NV^%/MLO'A9"78&R^T622#MGH$#KIXF2:\nM*VT%Q@BLR=\\Q1J!L+@N5)U2^C1YBC&"ANTB@%&,]1CN-#2PJ5GSU^J^191EA\nM&*ZL4JF$QS,U-46OUZ-2J6"MI=)I<-69UW"S_`I/F[UH'1"E`3HRT_8%8?E9\nM(60M*`'9Z!#CSL_0:8B-5I6V5F`,:"/05N`+6082L_)O35`\\YS`.^N,^.M#X\nMDFK[-APP9:K1;5:A6E%,/!D*O?<37GG_8:\nM#G0.$(8!0:!0H91!18GC64CD,EA&BX^1Q8MH>VJN;&%Q4P#1!JS)`1@#T@B,\nM!^L%C@!CH5%IDNDVW5$75W)XYZENJ++C@AUTNEV6=V;R]ES0[BRR<^=.C#%X\nM[VDTFGSPPQ]@M&F>>^?N(`P#E-(H)5%>#NRST#(`9TA';:S-K6MM7NRT\nM!6-701@+:AF`%9CEOLF'&`.GS&S"N'GFE^:I-"LD.N'1WL.\\\\HIS&>D^3FFB\nMC'/\\+ZB\\OBSH%$\\&%W\\>[+&XL8(C#T^!WQQ3UF!LC.BU:K2:E58'\\YPJ?P#A)!LWK293WSZ8T3G\nM#[EG<"LFR/+FTGDJJDJ,P3O_X);/S+H5#RPW;7D(%:!6PF;5ZK8()UV`60XA\nM"L\\X+_`$:`/K)M=ST,QPG'62\\Y\nMBW>][QW$+]G/CY-[T%ZC,XO6EH"01C3!G%X\\ZK2_.YW3^5[W2DB87&G\\FFN%\nM99\\EKTGHM?>L!4^`-2"%XHI+KF"V-8O+',XXK/$8X]#:HK4A30U)JHE'";,S\nMZ_GH=7_.X3,>YH'!W<1I1AQGC,<91CO.:)Y)G"0DX^0_!T^,']=MNPK`VM6%\nM+ZQO<^JT:SWPBTH7SYDUSWE"C!5H8SEO^Z_S[DO?C3`"-!AMR3)#EAF21),D\nMFG&S&WBH>Q_#8*_#G(`]CBKY@"T`:W7Q+\\NPL8(C#X^-[0N@!5'"+`6%@:&9]J>-U_T)UQX\nMUF60@4L=::I7E(_CE-$H9:D_X*;'O\\(CQW[*8)#2ZXWH]H8$NL*EFR]G,EC'\nM0P6,Z!O'D#*4.$*B$!Y6K(P")+EI`FJE1"17U"\nMVR2L3"'$@(B`4GV&I@?NQ"F?E%1>_GX?VW7/!,.F]\nM2H=6C(,LGZ^+Z4D;0Y(&*"614E`+Z[QBPX5G2^\\?'5B>S.?\\A[&@1_Z1R?TF**:FT2[Q6&,D$QR!LB`A7BG^X"-0,IFFGQ*U,7O1QMGK7DY--?COW;=QYY.W[^[U!G^5[G8W!]/"\nMSE_?.WXFMG8%0-M[]DC?L7&WDX^2;G4N?H[Q\\EGGR\\][D-[3!>"A8EW&07I<\nMZX6_*R&Y9LEQ3D`8392FF`IFF(PF:`4M%KM+?&/?O_EG%O?,=P?=_W!C_X6%\nMSPT>GWA[E?;U\\7%#O0#X[M_F2@A!S3EJSU+J>^?+SBQP'X/_O\\!K`$\nI-(G$))$(!2+%N:X?H['^_O_]*_X'!HIY!5TY']L`````245.1*Y"8(+\\\n`\nend\n 6609 order_search_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```0C4E$051H@>V9:8PEUU7'?_=6U:NWK]T]O4S/]&SVC)UX\nML"4GD`1%(;%C)R`%L@F2*"#$$D4("80$?$!*!)&"!)'"MX0/@)`04@((R&9C\nM0SP0X\\0Q\\M:U?^TKO_8T^5JLVD_^V_N#,`I`0<\nM0>B)XE(S)/#`6##.8:W#.+"6/;;#.(>Q670"TA:.2;C(OUNOOSR\nMZMI'PV+E$:W5WVRNK7Q^YM$_N+G^[2_#>/,V`0B!`_*^X,&E(K6BC[$.;1W&\nMI/M$&;1Q&)LZOFMG]UEVCHTE.^LKPP&R>V>FW4"I7'KIRZ?R?]SI;OW+B\nMXW_W($FM'\nME%@B;8F4(U*66%DFRA&KW7/1MITH;%_P4$$QG7/PIF.4*Y7WKZ_=^G@^'WYQ\nM\\8^^QF.???\\;!2!V``C`461US><;3X\\Y-\\S1N+N!7PX(/$$82$(#"(MS,DUT\nME]H`UEEP$D=VW4&J80&3VCZ^_)WK5/6`N_:UJ$C?\\^?F?BE7*/_MK+/MQ]YH\nM!#R9RJ`4`B$$*YV`KYQ:HUT(X605<7<3OYPCD(*\\+\\GG'`()6!`R>\\L>6VS;\nMV5ZDUUVIS$CFF"YH'CC1X@=7-UE?Z1P.HF@1:&_[\\X8H!"!$JDB]6I'V_CH<\nM;L#^*ARNX9>V(R#(V]0YATR+`WM`9)$0;$Y7,':(MP>@.TD%@@!#Y_(\\S-&9[.6\nMX%R"F3AZSN$C*#J',:"MS>0TU7XCT_J@<1@!QG,8/U6B[;IAK$-(#]_S\\:3`\nMDQ+/DZ_PY\\>OQ`(@E5!K+!>WUDCR);0AFSU+H@S]=H>@TLAD$D;]'AH/Z^=W\nM9C_N=U%>B"9(HZ,->M0E#JHD&F)M.5'1/'S?$EY&V5>/'S^)A<")-`+@P/,)\nM*E4P8+1#:(N+-2J8(/)EE(;8."9>C,;'^D5B9XEQ3!BC*)*('#$6Y0Q*CYG(\nM(HEQC+5E48_PI<"3(OO-VP0@)3C'3@[(R1B_O4D\\&%`K5;"`UH:<&5)S>9P$\nM*V&0C_`\\CWQ1HG1*D38*@@B\\K,AIP[B@*%05V@J4MA2LP_<$GB=V!.3V`&1U\nM0(BT`RWZ`=5B`3L:,ETI(H1`:T.H)DPWRP`(!!VI"0*?4KF"L1;K8%W&A(4B\nM?A"F55AKML*$:J.*L0)C'8.>3?DO,@"O`G%;K00(G',XY^AHR_I0H2W$B:;3\nM3@C-9*=5&'9':.%!8$FT)3$PZ?;1OD*+7'I.&=2@3Y+S2$Q:G>^O)WQDO\\23\nMN\\)Q^P!$JN9"@+&6)$E`:WRCD!:PAM!IBBBT`",!SZ0J[QNT<&@/1CF+"RQ6\nM9M(:.";*X0HIZ%@Y:B'XGL#/>J_;!R!%F@.9(N2"@%*IQ+[RF'U3-804&&/8\nM##2SLRT`A)"T.SZ![U.I5'#.(85@?<.G4BX3YO-HZU!*L[8>T&S-8!P8XUC?\nMW,239!'@#E(HFXHXCAD,!JSUAVQY(=:!4H;.5I>KB9_I.0QZ79`^7CC&&(MQ\nM,.AL(<,!>"':6!)M&'?;R))"&4BTY4!!\\=ZY^52%7B>+;ZL;%4`NEZ-<*B'S\nM(\\9!`6T@-HJ^R!&[@,1";`1#':"=AW,^B4JK[&3D86.)$H)(R;06]`7Q1)!H\nMF"0"?P9R=Y1">U2(+`?B)*'D-(N!1882$TK:B*<4*34UXFHX)!=T(A\\?`"G:W<#-WVA!4UPEA0VE+W%,=]\nMN9,#=RZ)A<@H%%*N5+##,5NY(LH((JWIF!'K<6ZGB1OV/93PL1./1(F46CT/\nM+2'&4I`6904;ZX8H3&5V%&G>/6=XCY_V07>(0G(WB85`*]Z2).8GK9(8VE?E!EHA]6&,W._SVKCDRAC\nM&'8CE(D8W#C-:&69%R]=Y]CA)4Z_<(ZGG_X.LW-SU!M-5E=NP*5+A$&.TR]=\nM1'SS%%O],:9Q5Q8!]UH`UJ0S+02-1''PZ_\\)PU%6/*2'YUDD#B$DOB<0H@NN\nMA^\\)I+0(P),^4FB$@$:]1"T_HN@&-*3".$,@%1HLWK^F\\P>O!5*@([;%,H-='R!@]4";UZ:PI..*U?'G%];1CB7RJ\\Q-%I3+,PO4"B4\nMN')]!7/E.M+S.;ATB&O7EM,6A92Z[>LOTJKNI]RC5B^?IV#2X>8F9FF7J\\SBA3-1IU;JRMT-FYQ^-!!]C7+Q(FBO;4)PP11\nM;+P6P*LC((7%Q%LH`=8DF+B+-3$Z[C%<.X^);S(9>,A2`^P`K24(@42D_W=:\nM'Z7A:*W(U-$I7KJPR>/7+V.,IEJI4*O7.7)T"L\\+6%Z^ROSL#"MK&]0;#?J]\nM-ICQ_^BR]\nM48S,E8BC27&PN?+.A]]^/P^\\_5V[`,P>YVU&(1-OH2?K&!TQ6'F2J/,BUABL\nM$UF9SYS6H-4>6XL,`#@GB!/#J5/_1:TUR\\*!0Q1+%02",V?.L+:^QN*!`R0:\nM*N4BI4(>9>#@TB$VUC<)P^?8:-]0VJM1J>YR$]CVJMSM;F)J?/G$$X0ZE8($EBK#442V5:\nM^^9':S>OZT&_^_H4,@8\\`3W-JYM![/O"+LR??^M.OHT(BM<$PVCQ#,MY$F874V;V4\nMT2F%C!:X[;S1`NW`.($ES0$0_.#,"UR]=HUZK88)),XH>KV8>JW*!W[N4=[W\nMZ",,^SV,L4PF$Z:;-3[]:Y_D7_[U:\\31A%ZOG[8UR00UF:"2Y)CO!^^M5&M?\nMNN>!G]P3`;T;`:PF'FWMS*[)Z*$,:+.'0GMHLWW>:'`NP!C!<#3A\\2>>)!\\(\nMYO;-,EV?8G9V'N'GN+&RRMO>^B`GW_PFK+5[)GQ\nM5&GV\\#Z+@-+@&9$I4*I"SDK.G#G'C94&,FKQW%>[V-$(5QS0O,=2;NYC?;.-\nMYWF4RV7.GS_/S,P,@\\&`^?EYE'&46S-T;RDN/WD#.:[A%2VM>^LTFZVWOGSU\nMPH.^M/^^F\\1[BD,C"[D=M5(4=:!YYY[BS]+[^/D2`(U&@_ONNX]ZO<[,S`RU6@T_7Z:]UN?L8]>)K]0I\nM=4]@K\\UR_EN;V*A0G9G?__X7?O#L;B'+FCF,SB*0T4%G,ZM?;6=.;^<`1N!E\nMB>OPB6+HC/.L7%Y!,LW"T1K50IGBJ$9[V7'YS"76-S8`.'+D"$HIQN,QM5H-\nM@(W-32Z=O4!H]C-_I,Y,N7R*K6#]7N$$/D=`,YE`#(*F8SCR@B,\nM?KV93@')[#Z,P-APX-,V1MW@4\\A&-48X5*]A83;\\);X\\@\nM"*C5:NEZ&Q@.^HRC+K/[%SGZ8)YZ)2+1@@U/<*77`YJ)[_MV1X5V(I`!4/I5\nM_%<9;;3(J)5N0H-2($QZW@F1BIN#Z7J.*#.Q8M=HMP6M>D2\nMNN4F@'19/S]G_WH\nM+R>OH9#6(&6`\\')(P+,EI&^0.4-`%2^7PPO[!*9*4&@BQ(`0GUQYBGS80\\@`\nM/ZR@C6"N&7Q'>.P/:^&!YZ^>Y>;@%IL;FQ1;>;9&^GQS[M#7-P;::&-VOB%;\nM!T)8*C-+TCG[2+%9O/?BZF7Z=D2GVR77##"WU+5AI_]/PT%_5X6<26/G+.R;\nMKE`L-7#.HXJ/+ULXUZ)&B.\\%N$:%I@N07@BNSC0^PBL@J2%D0'_C`O$DHJB>\nM_,JUJ_=>C::K?]:HE0\\[IQA/NN["BV=/KZ^M_O9O?N3=WZXUI[EU8YF](Q?F\nM"?,%M%;_.![VOEBKEN^WM(318VY>O[+<;K?_%(^+(2;'HW&-^)H\nM\\DU@64B)LY8?-M*/6>Y`+LP_4BJ5%AUL&>,>SX7!.:.-Z[8W4P#?^MQ.$I>L\nHI?0:I]Z@#0R!\\6]\\Z8?Z^/_C?P$6V;R).I+A9`````!)14Y$KD)@@MQ.\n`\nend\n 6610 order_write_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```.Z$E$051H@=69::Q=5W7'?VOO,]SY^;[!0VS'CA.,(P(D\nMII`RB1(2:$I5BA"@ME2H:C^T0OT`J!65`*ET4*E*D>!#I4*A!3X442I`A:0A\nM`P14(!!*%-+82?L<^Y=_[W^\nM:]H'_I\\/^45?^/A=:PCL]2$<#('@`_@`(00*.>"!X-F\\#N$\\,A!\\\\8YSCM%H\nMP'#09S388#SL;XP&@\\<:2RO9=S[Z]N?4)[H8Q`)O%Y&_\\B'X`$`@`&'^1`BE\nM3#E['CELR:(4:5K%5`PF-^33\\;A:K7SKS%./?UK?\\#OWUEN+^>#;G[P\\`)0"\nM`G&JI79P,276X#RX$/`^X`)XSS8YX$+`^=(Z`5RY\\OX9[\\7D2PG328U!O](X\nM<7KUG6FM^:O6FL^MKY[ZZ,Y;_^SDVK<_!9/U2P0@0@`JD?#R@S46:A'.!ZP/\nM.%><<^.P+N!\\H?B67#[GV;QVGO)>P/D$ZVK,LA;W^1G[&GL7JM7:'_\\L28]T\nMSI[^H[TWO^=G)[_VM\\#T4@`4IE=*4`(_^-[CG#C1QZ.P+@))>-5KKJ#>BNF9\nMP-0&C"L.ZSS&!7(7,#9@W=9<[K9=YXX-XSBZN\\+NE5=0;S1O>?RQ8W^_T>O\\\nMWK7O^LONPU]X_V4`(`4][K[S.$O+39YZ,C;[Y8`+()0(!`C=.K$;=];\\+_C!+:+VP3-6)B+:2Q(G6`>$)0\nMA:.'0@;PP4-0!,KY`$4,BYDN[.)3__5S6G;(X5U+-%6DHSU[?CNI-KZP._CN\nM'1=K`:V*,*A$$!%.]6+^[3NK=*LIO+2%O'"1J)$0*Z$2*2I)0%"`!U'EKVR3\nM92Z79RGF0[W!6"6L5"U'KUWB)T^LLW:J=RB>S?8#W;D^%T4A`)$B(FTLU.CN\nMVP&'VK"O!8<6B.IS"P@57R@74$5R8!N(TA+"W"KE?!E??4BH-FI4TIC6CC;5\nMD:0FGU5E6_JZ*`H)H:"0".]ZZT&.OMZB%E)",Z76B-E;%Y((KJS"2JP*)[7%\nM84I'-K9TYDW98VS8YN2>W`7JD2*)%'&D:32:>%^#2P,P=V)!!-YX;86;G"U7\nM+2>$'#<-;(1`A%`+`>?`>E^&TR+V.U7D!TO`"3@=<%$1B>9YP_F`*$VD([02\nMM%)HK9ZASR^>B06@"*'>>1[MK))7ZEA'N7J>W#@&W1YQLUV&21@/-K!H?%39\nM7/ULT,?H%$M<6,\nMP;`R0VM-I:8PMJ!(%P/Q#'29Y*QC4C546P;K!6,]51^(M*"U;`:02P-0Y@&1\nMH@*M13&M6A4_'K'2K"$B6.M(S925Q08`@M!3ECB.J#>:.._Q`=941EJM$<5I\nMD86MI9/FM-HMG!><#PPW?,%_*0&<`^*22@D00@B$$.A9S]K(8#UDN:77S4G=\nM=+-4&/7'6-$0>W+KR1U,^P-L9+"2%/>,PPP'Y(DF=T5VOF%'SCOV*;3:"AR7\nM#D"*:"X"SGOR/`=KB9Q!><`[TF"I8;`"3@':%5$^DWT75#<9!;CU75@UOVG-%$87.X\\675(T*D"0)C7H=51DSB:M8\nM!YDS#"0A"S&YA\\P)(QMC@R:$B-P4678ZUOA,8428&57D@H&0387U2J<*FBFVN6EY.B5P;ZE1BM(^J-2E&%(O0Z4YK-\nM)DF:%IG:>KH=P^)2&Q>*1F@V&I196"ZS$Y<_Y)S%&L/4&+JS'`!C'?U)AAO-\nMBB8>V!AG!+$D1I=A5!CVIU1SC8XM/A3YH]>=S0AB.1VO2!R^?$\nM(B6%4AK-)GXTH9/4,$Z864O/C5G+DLTB;C30&(GP4TUNI&AR^F"TPX@CLY[<\nM>.S`,DEL0;'<<_,5CIMCA8YT@4!'12:]>`NH+2<6P1C+:#0ASG(6708()G+T\nM$D>[9LLF!08J(,I3J8'W0D#H-S5I-29*$GP(..?9Z*8TVQ5"*!)9-4P)LRGM\nMGWR35SQP?UH_\\>"AREO>]WW9`Q\\X70((/V9>@[>`A>"W[>N4Y^"*<_QTPSVP\nM\\ZX=0:Z`64H<5JGJ%JVHRW)FW'?/5UBXY]\\Y?/_MJ\\\nM=3RXYP.<;K\\;XQRCW@PKAA!31B&8]H?8R&YE8NLP@QYY"L8)CE6>RDZSFDVY\nM877(K;-*?KB^ZRMO>/FR&][VHRT*>5>LM`CMW'#@&]^%T;A,'DJCM4<1$%%$\nM6A#I0]@@TH)2'@&TBE!B$8'VCCH+E3&U,*2M#"XXDL@2)*`3B]%%,3?*'))X\nM@BYZ!>M@2D#7A*[KTMOW59JMQXD>NHKO-5_+O:T;V?/J7[DR^?+#\\?`5?V#X\nM_A\\6`)PMDHU2,)[`L2'P#6\\C;>[%]1[DX)'7$=7W8\\+0[9>.)=8*W#/M]@HK0Z;A8;0^C7@<7UP@J@1"P\nMSI$-^JQ5OL4W_3_A=,8.OXOK%Q9Y_&R=I'^ET6L;GWCW/[QW];VO>O<6A9PK\nM`(10R$H"^70-$;`V)Y^NXX+"F1EF>A:WVF/:>X28(7;X(\\:C#(EV,\\Z?QGE%\nMI;4?YP3C8>8%XQ0S(G*O";F0;W9OFB!@"9N=VW0$7W_X"7X6C5E,'-?O>0&=\nM::#WU%&NV;C(O-7V$9O:U/%.#3\nMMVM<[2U<]^0"V8G[,3<=8MJ\\E1M?M(?V[BJBA.3XC91H=*,^"MP?NB4`L.C"W"IY9YV(UP3HBCF'HU`9+GE6.^\\^,.\nM'SL1,BV#4HMPM+"KFL`S[#\nMV1G#4W=C9UV\\6\\('7:9YL%90#JS9#D!*``68YSN>/#'F3[_;Y[01;EKO\\;*]\nMPMO>>I0#AU:(5$4E:1PFY^K8FP\nMS],"X]&$#WW^(?[5[&3OJ3XOUXM@5*'W`.\\)9LW,&Y0J$Y0./`NBT0\nMUH$N9>4$.Z^;0HRS97GR'..!8WT^^,"$P=CSRK4N!U9&O/T=+R9)9C0:#9:6\nMEI"2],*\\@'RF$0H`K@R?91@E@#7EUY-M*VZM8-TS?2"4<]I)09M01"'KY#DI\nMM+8VY0-W=3B6*_8=.\\E+5Z:\\]C5+:#UF:6D7[79[4_GM%C@_`#O_KC6G4`EJ\nMDQI;JSZGC2G!A/(^I65\\$`)E%+H`A;*IY:__GS#:Y=.CM`+0KJU5?ZQ`]$C'6ZT0][T^F5NNNEJO#>T6JWS@IY3Z()1*(020$DA5W+<.,%M\nMM\\`S?$!0Y7,X(;*%XP;B"U+HGA]W^,CQC-G:C!O[?=[PTAIO^T`MJ)+*9N2-E:P9FM.+!@#XHK[001*"JT-+7K=$7Q19I\\Z\nM/>']W]W@=";\\TGJ/&_?##:^[BJZ/.'MZ1F#K0_B\\_RC.@=[$H2^TK;*=0M:"\nM4C&B$Q2@?1T5.53BB&FADP2=#HA=B[BZB,B0E(BDL4PEW4!43)0V<4ZQ?NKX\nM/7K,?<%:I96$'_[TX9OU='STT''/52[K[%AN?VGABO;@S(:1^3=D7S91\\^NY\nM7&XHSP*<.M%V*43B%X\nM/!&BJR@7Z]*9>\\+1UX!'#O7?\\!D%QS^+J/'3ST@MN65W9V,'"IRO]?#UT>\n8EW7\\+Y^L^Y,,G%8,`````$E%3D2N0F""\n`\nend\n 6611 order_zoom_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```/,DE$051H@=69:XPDUU7'?_=655>_>WIF9W>\\N[->>[T;\nM;^*LX\\1V(I.0$)P0)S$(HA#))""43[R$$$2`!'P(("5\\(`&D\\"$AB,@"@@(2\nM!F++X$#B$">VXZSCU^YZO6OO>V9GNJ>?U57W64;!#B^R6P3Q`EY`1,AMP0/BF9Z+7,8&Q.>_\nM<9+*TMG/KWUGM\\]O?SUS\\-XY2H!*(4`Y5!QQ^XJK6J(\nM\\X+U@G/Y9V8<;QYHM\nMHS/QI%:89)Z)]4R,,#&>U'@2(Z1FX[O)NIT9?%_QGHIAOB1PRU[JC<8'EI?.\nM?;13!Q\\8\\/RS1?EV;L!X1!8HXTL0.\nM4!X1G0>ZY#:`%P^B$8KK`KF&122M;7S^6R=HV@'[MLW1T&$07G?=?:5*_?X%\nM\\9V'7ZL'`IW+H%8*I11GNA%?>72)3B6&6YNHU\\T2UDM$6E$.->62H-"`!Z6+\nMIVRRU;I=?*K\\NM3JC'2)^8KES?OG.'A\\A>4SW1NCR601Z*S/YS51"$"I7)%Z\nMK2J=G3-P8QMV-N'&%F%MW0.*LL\\G)^@\\.;`)1.$)Q;I7BNN%OGHI4:E7*<<1\nMS9DVE:&*33:IJ$WIZS512"$YA93BHS^]FS?_F$6W8J014ZU'[*@I2B'LJL!\\\nMI/,@M?EABD`VM@CFJ>TQ5C8%N2=S0BW4E$)-%`;4ZPV\\K\\+5`5@/8H52\\-[]\nM9=[M;+%J&2(9+A%Z(H0HJB(X!];[0DYS[7#"7(G6\\X;S@M(!\nM81`2:$6@-4&@+YC/#Y^)%4`NH=YY7EQ=(BO7L(YB]3R96JQMB<(AT,1!,(BB1G'>.*H=(T6*\\PUE/Q0A@H@D!-!>3J\nM`!1Y0*F\\`JV&$87SPJ#G<_ZK`L!%(*ZJE`"%B"`B=*UG>6BP'M+,\nMTNUDQ"Z9E@K#M1%6!1!Y,NO)'"1K?6QHL*J4?V<<9M`G*P5D+L_.M\\UD_.Q.\nM3:`WA./J`:A`=L5BJ&*P"IX'`Y2H?.JP2;`"CDD%M$9"8@2IY*!3([1B"`-%6-1>5P]`JSP&"D4H11&U6HUM]3';MK106N&<\nM8R6R+"S,`:"4IM,-B<*01J.!B*"58OE\\2*->)RZ7L5XPQK*T'#$[MQ4GX)RP\nMO+)"H"D\\P#6D4+$4:9HR&`Q8Z@]9#6*\\@#&.[NH:Q[.PT',8]-9`AP3Q&.<\\\nM3F#0747'`PABK/-DUC%>ZZ!K!N,@LYY=%<-/7+<]5Z'+1/%55:,**)5*U&LU\nM='G$.*I@':3.T%40IM4B"(&TBRC)I;%R*-CC8LUG2Q@RY92WBL#:^6((`BIU(\\4UM/9]4P.]?&2=X(38;](@NK:QS$Q8.Q`.]48HH2V0"G,^;^^':F&H*091B16$]=%<3SI@1SH.QGIG`\nM<'.HIS%P[8)8J8)",?5&`S\\"6"F,L0R'8Z(T\nM8]:E@,*$CF[)T:[:HDF!OA:,S>B-SW'VQ"L<.7*4SB!!1Q&A5O@T04Q*K=)D\nMWTW[N./V`T1AF;(;H[4B#*Z0!^0IUFOP)M`2O^F]3O$I+O^,3M7=TUL?F1&U\nM'28QD2Q1"9HTPPY;HKR\\<-81QQU:E19.UP!%V5?I]88\\^?WO\\\\1+Y]C[Q@/L\nMW;%`K5K!BC`>)RR?/,&QI[_+J6>?9/_6,K??>0?)R.:]AU)H?8F*%AZ0HM=0\nM?`SA$^05+=/#4[2#,-'(GI4/M:V:P2Q!D*3TK$<[3^=%78`6O'4\\<]WO<+;]\nM"QAK:9N$8T\\=Y)LO][CG@_>R?7Z&WGC"R;YA)?%X*:.VWDSC]EGZ+SS%@__^\nM*'_W_(2[;KV)F_<4#=2K486K^?6&[:19(96)6)0#EAH5YEK5*C'$7&H\nM&`T'-)LS_+?MHI[\\+CO#(13]]ZMZP&X"X!PT:B7VW?8AXL8.7/<9=M_\\3L+:\nM(G9TFOEMUU.9VP?.$KH.]2V+((9L:*B4\\D8E"$O8,;S82>@=6Z5N1YQ>[M+:\nMM9]1:AE,#*D33JQ-D(&CW'.4BD[+C`=$5<](-:C6&[QT:JD0CRMYP.4`1');\nM*R%+EE$*K,W(DA6<:)R98)+SN*4N2?<($0/LX$E&PQ05+C#*3N&\\IMQ4S4.NR\nM&^*<(@HC:I6(N7:3&W8N\\/"SQSF[=@L+K0H*A6B%#@)T&*+#"!4&Q*$&YQGT\nM!B3C,;MW[=P$X%(*Z74*69L?OJ"02U>QR3+.3AB<^1J3[@MXY_"BBC2?N]M:\nML&:3;54!(`<#T*Q7>I_FDG<):A;-,\nM)QL4X%60/RQ_C1YA;5YR``1!P/Y]-_#.M[Z)A[[Q!(_B6=S[.MK-*DIK`FW1\nM6F'2"=\\_>HP7GGZ&[ODEWO$S]TP3E[I2(MM,(><@4)"-3I%TGL6D$2[>F+1S\nM^4H;JS!.(86M0XV=[M:$V$T>`&BW&KSSKMLQQO"M)Y[FN5/'F5^\\GG:[22B.\nMLA(Z9T]S_O1I3IUXF8_=]R'>]*8#!$7GI%7^1N2R#`7C\nM=N23W4P9FU/(V1R`M:"MP@HX47CR&/!RX9\\M;-O"!]_W+A:W+_#=@\\]P\\M2+\nMG#HZP3I'7(JHQ!&-:D1S9H;G#C[#GOD6M[SU;81A.`WBRP*8JM`Z`&])1ZLX\nMEZ^N#N<>B'"V*$\\N&C/-!C_Z([=SVZW[65GMTNFL\nM\\=SSS[']N@6ZG?/<<<>=//?XD[163_/*%_Z,JK.\\_MUW3S,Q%SDA!^`*^2QD\nM%`%KBMV332MNK<*Z"V-`BFN!4SEM)%S#&,!Z/:;5:`&S]C4^Q_%L?X;KC3S&IMCBJ9JC]^'V$Y0KBW<8"\nMK`-P;N-`UB>?2Z?;[($+8D!-8\\%NND^(KDBARXTHBFBU6M/MVM8;WT+]5S^)\nM*D4LGGB:]O''Z3[V(-8:W.2B3;[UI*/4!@!C+^*_*6AC59&X"OVW8`PHEW\\O\nM2D%!H>6!)5AQB+>7G;04^\\G3OH.-C7!!X0[XX=SS#`E+W_O:\nM`PM[;]I'!)C+48E0@=Q"`SS!.B@@J:%DI'],\\?(4M3QM_[XK]T#W[Q,Q__W`].\nMI0O&'WZ5!_[Z_1P1?4NY[+_%0#@<^>%\nM;:T*(ZW_]1UI>M^NTX=/?/;8^(7/Q<@OIU?[]/\\#XW\\`L./*LPG&87H`````\n(245.1*Y"8()I\n`\nend\n 6612 payment_ok_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```0*DE$051H@=69>71=Q7W'/W/GOOT][9(E2[(MV<@KV"(V\nM9C'4!@(EA)@8)TU[2!MH%@XD-(04,$Y3A^`LM)#UL"4Y@1P**3@M`8H3(`DF\nMF(`=P)8M&TNV),N2M3X]O?V^>^_,]`^14!*P16I.TSEGSOWK_K[?S_W-_&:Y\nM\\/^\\B7(P$Q2H`+Y[XF3>'8"-@`\\(-J#8C&($GTX4OT'Q\nM`H8#:`:0N-S]OY.R3X3?/VH""!'"Y\\R*2(60VJK/Y?/U;LD]SRCCH!G!8R=%\nM?LU'>`F?;CQ26!C^\\\\\\!P`*@2=KRY(:*!@(J0#Z4)^_DR>?SX5*Q--M3WFR#\nMN0S(``<1[,#G7M:RBY_^.0`8ED6"D9E1.\\+$:`I?^41C$61<(B*"F(SAE3R1\nMR6;*)R%C+`4PY[CRUDG',`"$I0A65F3J"$4\nM"F,';*24V'+J*2S!:':4B<($",@6LQ#$0K(>P^,(OH3++/X!N/38I6NI:I>`&6$.3O\nM,<3?;BB=>`"?&5;`>D]#>0,!.?7%M3:,C(XP-CY&:C)%J53"MFWR;HYD/DDP\nM%,0(D)8D74RSLVLG=35U!,/!&C1?0W`Y`KCDW080@&!1/!R?,Z-L!I:46)9%\nM)IM!&TU9HHQX+`X"I+1Q5`E7NX3"02S+(AP(\\]S^YQ!"L/;TM21B"8!]P+-O\nM)WGBUH$[F=H^6)Q1':^.ED?+<5T/I11**1*Q.-H8?-]'*876&H-!2$$@%"0<\nM"'-T\\BB'1@YQ[L)SZ1SH)#F9',-B`T%>PP$>?SHKZHGK_*\\U/62B^#K\nM./R<*/#H6\\O^20#&&'B]XD_V_+9V=-?6QO'.[7.V3KZ\\^)OSLRMF51LR(/&T2S@41DI))I?!]5UB%3%>Z7T%I=5#P#V4\nM87CP[;V\\8X#LP%YV?>\\J9JZ\\;-U$U_8;)GIWS4P.'*P8&QZ.]I2GO42B.E!?\nM5H^E+2QAD1Y/@Y["U;ZFH;F!1'F"5#Z%AT]YN`*`HELD$`@PD!J@Z!5?Q&(3\nMDASW']O/.P;(#.ZG<>6E\\P=>>N1+/=NW+/)>WOUR$"#*[_2P2=7.H.[R/2;\\C6!3U!.T`\nMKNT1"H:8OZB-UK964LD)?%^A4?3T]U)0!<+!,,(29)TLTI:XGNL8S*W\\@&U\\\nM`OCA\\3U-^T#SQ.U7XKLE`N'X%6.'7KXS+@KADY:=3:QV-EIKT(K\\4!='A_1D<5MY,MB).)EF-=['.H]1-_`8?8,["%NQU&>8BP]AM`"Y:F[4'P.\nM@<-=T_,U[0P,#HWB^BR)F<,WS:PI#\\]=^G[L2!G&:$+12M*'=]'3M9O#_4-$\nM#@QRRF"*_K9FW/9%!&IJ\\5R7_L$C9'-9/./A&0];VHQGQM%H,#R+X%8".'QG\nMNJZFN9!]=5T#AW<]&RO7(SN^'S5_%7KRNOGHMP":!]I!XF4U]/[PA9RON#T?(%P[[^JFTSZXL;)Y<4C[#I8%EK2PI(67'2&33C*CH9%(.$0D&B-0\nM4TMO0Q5#98KM;@==]0'L0!#;ME$H,FX&5[DHHPP6]V!XB#SPC3?K]^SH8>]3\nM>T5N)%?I3#CSG*33.CDP&3/&\\-`W'SI^!H24N*DCR"L:J`L8K8`D!PD(8\nM`(.?&\\&R;:)2XDX>04:J:&B>3<>I\\QBL*R/O%%&E$K)81$J;O%^@X!=^)_$S\nMX.L$-_AU.$&V[+-@KH%KYV4.NGN\nMY6N6/]9_J-\\[)L"JS?MX^;8:T/XNY:2=8+PRK$O>%``"C`;C$R\\K(Y=.X66.\nMXN63U(9#E.<=)D-U2%]A>SZVE-A2,N%,X!L?H`N+FY&,H=[0W/+(%BY;?QG9\nM5/;L[ESWMWZTXT?MG4.=A.P0QABTT4WKV]>?MG;1V@V/??^QNX\\[!V0@@%?(\nM'E1.>M2JK)]EO#R6):8*L)F"**NH))_+8-P,ONL2*+E435B,JQG84A((!/!\\\nM'R,=;SWYK87-E,U>>\nM>27)?))M7=O8UK6-COZ.LME5L[_PX8]_N./X`,$@SMCHL'8S/9:T9QEI85D"\nM(::.7FA%-!8G%`XC@T&,`7P?-=S'0SMW4!Z?P2]'"DGI;'X-GG^\nM`P%\\^0VMZS][/>F1=%-_J?^.>[??NW#QS,4T5C2R=>]6GM[_-*/I42ICE5R^\nMZG*_J;QI5[:0G3PN@&V'6+EY(-^[Y3,=8%9/[?&GJ@E&8;1/,"B)1*/(H,1H\nMC5&*!E%%(;F;O1,'D5H2EW'"A"BHPB$"?)\\&?#[WALY++[Y$7T>?W71JT_7W\nMO73?V=%@%%_YW/GLG70,=*!\\Q9+F)6RX<,/8!6T7W&$[]CT5M16IXP(L_-2C\nM]%9^"I3:C2H9RPX("XUE6PAMT,8B$(D2BT6Q`P:C?+3G4A.MH[&0H,?D44J1\nM=M.D-2#8@>3H']:_%:>MH)`NK-FR?\\O?[1W:2U-E$_>_>#]'DD<`.'_)^6QZ\nMWZ;.93.6W="QK>-G=2UUNK*QG]3*@)[*C-^A7KV?S^S;]L\nMC;=>&:N,[?[Q`S^F_?3VWWN;5@8L8>$>,`PBQ&&,0&-!%A)JJ2L*R\nM0$Q-;B%M1#C!A6+63GQN!"X"'L5GC-";8S_\\\\,.D=J>"J:;4WS[>^W@BJ9.4\nM*"$CDO-;SN>+:[[X_*SPK*LB99'NE:>M9,?.'6]Z?UH``JA?\\WG/S8[L-MI?\nMAS%HKP@J"]I'*XW1&HS!&(,5B&`%(GBE;*8S_.&!Q9]X^'MO%WO!@@5$1?24\nM)_N??.^>]!Y44"$"@O;J=C:>L[%S=G#VM9&J2/?O_R#Q,Z\nM4<7,+N4676,,?B&-5\\SBE8HHKX3R/;12&.43B->AE9?W80J@!!HWT=Y[N\\A(I6S*::.]'B9X=A>`A+6'Q\\T_K:_I`_@^;FKPJ%=(]5J!A@;E*XQ;`J.G[CP]%^65\nM$,$$")O"\\/Z?QM<^G)N5'+OAU?2^:SJ3G4TYE1/+9BR;6-ZT_%_Z]_??,;]]\nMOJL<=7;'4,>"M$QC12U6UZUF_:SU/W=&G;L_V++>U[/';-\nMMJR72QY02J%\\']_S\\9P"OE/$+SGXKHL=KRWDR_\\6TW+S$U/]OW7K=V3\nMW^,&?!G(^LCZP729V\\:$=NAVU%+694S."*UBM&\nM:E3-5ZN:JU(///C`<7U-.P/%S"3G?:4]H929K9P"7C$/6J-*SM3BY?L8*XB3\nM.MKO3/3=X%[PY$%TLEC2)>^5\\5?LG:F=##J#5,0K&!\\;CS7&&J]_L/_!PZ_Z\nMKYYQ4!TD$`NPMGXM[9'V'UYWZ74O?.BF#[%QX\\;C^IK6]?K>[UV`40&L0.0O\nM([7S/NOE1@/*R:&5CW*+*-=!>9Y17FFGEY_XS.Y[MS[3=M$:7B>W+[V-0#9(D22P3G$RZC][QZ+V7-%[RR<;)B)`@;:5Y*ON4\nMW2?Z5NU1>\\(R)KFX]F+32NL/RAO+>PX<.#`M\\],&T!K"M2>M1`3/*X[WXQ9R\nM4[V8Q7,*>*4"GE-\\KIC3A[QLDO=LG/K-M7+U2N:=-4_'*^*/GAD]\\\\I-)V_J\nM6EJS%"MH,2R&N77T5CI-)ZUEK:R.K.[TQKV'^P_WLV;-FA,'\\,RU30SN>,7&\nM"EWNYB=YH=(LNW[;F]Y?_;[5W'?/?937E?]J\nMF5SVR0US-W0MKER,#FKVZ7V40B56)U8S2\\UZL'IN]9&77WEYVN:G!:!\\EWA3\nMU1S/*9[G.7E\\U\\'-IRGET[CY#&XAB^<4CGJEXBM>R7G+&%=<=05//_DT975E\nMVY;H)5==UW!=;TNL!1$4U(1K6&6OZA.3XB=#1X=8MV[=B068VB:H03X3@'/*7;XKG/$=]\\:`.""BR_@^5\\]3UE=V:].-:=>\nM?W7EU>.5=B5+[:6TJM:MMWWTMH-[]D[CM^0?M&G=PCQVN<3-*A&M+5\\4J6Y>\nM'Z]O.T]85DLI,Q)W)@8L[;NW&&-N-WA<^-VQ8\\9Z_MGG>?S+CXN;?W+SM4]8\nM3]Q6;I5[YQ3.N=2.V<]$8]%W!^!W[3N-,#X("R\\D$:^/U-F16$((2P"'@8D+\nM[QJ=5IRN_5V8O(G6S*^YT[*LUJ'NH4L\\X:67+EWZC@'^S]KPX#"]!WM;#_<>\n?_@N`6VZYY4^*\\]_7<\\-],"VQK0````!)14Y$KD)@@@'^\n`\nend\n 6613 printer_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```(ODE$051H@>V96XQ=51G'?VOMR[G,G+E/AY9IF=:V8(#2\nM0@I*3!.()AHR1L4H^FXD/)CX8GB`-Q,?Y,'X8#2:&$P,/NB#&`5?K(`$,%PL\nM4(&2H+;#,--VF)[9Y[+W7C'1/(&'BII:0MI19Z\nMAW6;P&P&MFUS8.D99PH@2Q00"#?@E?]3`IWNM\\YU`QT`::\\6`0%HRQ8"@V9[$+%V3F3(\\R+PL1)P';.V\nMA0!]8G^`!W);/FX]_&H0R%IC0=EN$%?D`;$90E?-`Y"%D-E:=?I5H>T2&39#\nMR%X-`NTDSG*@"S"7#Z&^!/+)V3G^CQ!";I/`Y2K.=F$DLLFX:@3R6=/]/'`%\nM>2!$AR>N9@YT>F"HA8O^GA&=2;QS_%<60D+@^N;`=A[H1RHCD$V*\\^4V+QX@\nM._J)$(+)DMCURU_\\_(C25N9AI+.2JK=190;=*XBB:.+!![]]YU?ON[>TN+CX\nM\\1$(PP!@\\>D__OX'J58%*P0&@,3X^-[BX5P1P2V\nM;KYO_3I$#6]L]Z[[*J/E&\\#9?-/F$#9>.7-B84P_L/CEKZ%EZV4.T=[K@^AI\nML^M]6@`A)5Y]E9=?.Q4M-4L_BK1<$1VXTE2SOE%_1DKYIFY>@K>>[(*[)0?$\nMR!S.-:__W(D['CMQ]."A.-4DJ2).-8G2K%P\\RIF7_LRN0H(?&)32:*W01J.U\nM06N-5@JE5>N:4FBM45IAM,&83*W!&(NUAHU:DV3\\YLJ1PPY`EP*-=4U0:G@\nM4PI]0M_#]R1B9(3)W?+NY`MSL^5B_@WWW'P]?W]WY<[1T5)X\nM/HII)(IFHJDGBF:J68\\VB"XL\\]33JT11C4:C09(D:*TQQN"<0PB!E!(I)9[G\nMM?O];$((BH60Z3)\\&'C$%M+4X&E'X$E"7S(W.[$P.35V"-B>P/S<.,^^NQHN\nM[!J[93U6)%'<"AUM2)7!.(%)(SXX]Q[OZW0+(-_W\\3ROB\\`P.C(RPLQTR,SU\nM4PCI`>`VDPHAQ)@4XA9C[?.GMB.P,#_%POSDF#%NP3E'&'B$Y;"540*$]+#+\nM,;YPR$(!Z7GXGD<8A@1A2!B&A$%`$`0$04@0MOJYS6]?"Y!28K1&*47@^U`.\nMD;M'\\8NC]%O2A."F:BWA^W]XA4<6[^A/X."^:8`I:]W,EB>T9@)]=IKX]N/M\nM6?<\\GR#PV\\!R]?V`(/`[6I_`#_"SOI2RE=Q9GL2I9F[/!(6QB?[[:L'>()"^\nMM4X/],#!?3,(P:QU;JP?`><'%9`(37%9'K*22F^V:C)-548NL7D)[?!M(&V`&N#;*/YM[LLA7*O'G1XVP(\nMSFXN=`Z8*8"R!*NQ\\$H]A;]K^-SKRUAKP[OW3WIG-B3KB>M:JIW5+)W?('KC\nM1?PPI%`H4"@4LS;7D&+6EU)F"UVNJMTWV:)GK44(\\((R_UA*D(TFN$T/6`='\nM9B2U1EQX]NVS_E31&TS@;T\\\\!M;(E0.'J=HRL>XYZ'`.'36QX_/MLND'`;[G\nMX^/C:P\\/']]X^"D(X3`&C!%8ZV5]B34>QMKVN@%``_0S?\\(6*^!:&Q&7;567\nM1@+JZ^][9TZ_*LO%XF`";O8`0HCDR*%]]N3I<_)BM=Y>*7,I3._'F]J'!E+R\nM<.AT>#;.CR]$[UOZBQ,2%2>$C74\\9VB*$F.F3B2*'-M[F&9EH?GZBDE'=HT!\nMO^Y/H'8AQN'BI=78U"/K)Y&C$[]PECW1:4:3\\TC/:]7Z(.BH]R%^X!-F=@0H\nMI5"I(DU34I62I@J5INVQ2A5:*Y179GGF+HX>7*4RW^34R0H/SUJ>7(75M0,T\nMDS1A+39-OS#8`\\G%%:QCY=1K]>KZ1GV72KLJ%L)9-JKG.'KD!KYX_S>004#+\nMV:(UU6*S[X1H?;A8AW4.D[76MM0XA[6@FQ&_^]5/>.>]_Y"RGU?%,B634/O0\nMX]E_+[%6H]4?6F/OHN>TSUGC1@I^\nMY5L/?>>>VXY_JJ1,*\\F,ZVZM[3Y2Z:NT/N8]";['^J/?^^Y?=;2FJO$T&V?!\nM"<<3X1XP`GGN7QHI?^9[)E7K&]V3NB48"_-@C:`T*I#=&>_6W[+-U#Q0U_+Q\nM6!/V@C*7`]VKMO6;\\2)K>TIJ,(XJ,9,3Q;"+]W[N'YA??D-\nM.UD:_D^.H3_JK07M.-!4[M.Q;H'<;L9[KQN[>:S2&V*I@6KB/OO4-_V9FN+B\nMT.AW0B`V(`7'FYK=>>P/,[M#W6>AFG#H4L(GG>.YG1`8ZJ.^J1R/G%0DAN.Q\nM1JKL9.&R:H94"QL)E5K*':MUQVK4=S-WY02L@Q]_/AA-M;M-F2SYAM"^9T/T\nM#[=80U-Q[+;KA-S)"=W0(908@H(O7IXNL9R5]_9BVSYBI\\=&C[W3UG,?($L!\nM[T8)/J*UZQY&ADKWNFZ](A3(*SD]&T8<<"F&AL8&'LR5=_P/\\#6Y)M?D_U'^\n5"V]#6$Q^&,Z+`````$E%3D2N0F""\n`\nend\n 6614 reward_clock_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```4L4E$051H@>V9:9"E5WG??V=[E[OVWK./>C2C6=&"A+"%\nM(@%"R"!AHX2*';.8&`BQ@T-BNT(<$\\?(5*!2AB2*30H;4F4[K[W]EW>]9R3#]T:+0@*EV/S)4_56_>YY\\,Y\nM__]Y_L]SGO>\\\\/_M)VOBE0._]>__&!769&=IKMKM=NI)DE2L==+C`6&-T?U*\nMI=8=&5\\WR+/,WWG'K_X$8+]H`F#+SC=R]M@#_-/?_-3Z:B6ZI=5>OK$LBLOB\nM.)J(X[BBM1;.>VOO#E;_#$M__DK[7X\nM;WSLX_2Z77'9[CW1OM=<$4JI.'OFM#UT\\,ED=F:V_."'/\\PM;[KN1Q-XWT<^\nMP9?^X-_QT=_^S#L;M>AW3YT^M7=B?%3_]+57LV%RG%ZOS_FY!1:7VPAE"**8\nME6Z/5JM%4>39\\-#P(U*JW_*N?&S+9;OXQS]WXX]<\\#-W_E>6EY?%55=?LZ5:\nMJ;U1&W,=WF^72C>MM2)-TRQ+TYDD30_T^_WO+B[,']RX>6ORR^^^_57G4SOW\nM7??=]_Q%F73=XX\\\\\\*H+O>>7/L"7_N?7`29W\nM[][[T69SZ/>EUN_O=GNOFY^;GSIW;F;#_-S\\^G:[O;FT=D\\0!#<%8?@/HKAR\nMY4JG]FZ=1-;MVYBR\\9U##7KV**@R'/JM0H'G]P_\\_6O_-F?YVEBYV;/_`#X\nMW_OT9_A/O_\\I]A\\X_/KAD='/*Z7>?^+X\\V/W?NV_W,_#SYSEP.E%GIY>\nMXLCI.8X^=Y*SITZ1)8.H5JOM"9;B^\\]<.^+$MJ\\;3?>\nMN=H5\\[,S9&>/,5JVN7SW#D;'1O-!O__9\nMF7/3=\\1QG'SVT[^S&H%J;0AK;5-*]?X\\+X>7%I=HMU?H]P;TNGTZG17:[17:\nMG2Z=;H]>/R4O'$M+;:9G9FDMM^BTEIY?.#_S9UIK>V'N[$7P-]U\\"^]Y_P>9\nM/G-ZW]#PR!?;[<[>KWSM6SQTOF#SZV_B5]_U)MY]PQ[&18]JV67+6(-&V>::\nM*_:Q<>,ZU,0E+)::Z:-/$PJGZO7ZZY12@^\\]>-^C-]WR#O_4DX^AC0GPWJ.D\nM0@@PQB`09&E*M]O%.8]W``*E-&$H`(''XYVE+`NT"6D,CQ%&\\<\nM/G6RL67K)7<,!LGE_^N;=_-7G9#K?^86WG_#94@!T\\M]%OH%B^T5RJ46E<8(\nMJ7740\\UKMHPPW+B68XT&1_;?#_BPT6S^J]=?=^/!>KUYSW4WWHPNRASO'$)*\nMA)"494E1Y%@7(81`2H&0X+VG=):B*-#&X#UH;3#:4!09_6X'K>1%\\&^\\Z:WL\nMN_PJSIP^^4XIY:V///(8CY]/>,V;;^/6O6-<:'5P*L1Y3UAK,K)!45I++@,6\nM^QF%]91Y2E3TV;9C&R?S`<__YE._>M:*T->.^54CAG\nM45H1!`%&&X00JP\\2I11&:8+`H+4"H"@*BK(D#&/]EK?_W%:ES?@5UUZWWEI;\nM=PYYY^>^J&Z_[>8/S<\\M!`\\?/$9EQQMXQ]536&%9NK#$T,0ZK(>@6L='58TQ.&(58Y[#.4MJ2HBPIBA)M'%)*PB`D#`*,T==DV>#;(Y6A\nML.'N>YYT\\S,3&!M9:39V=08UO9-M$D+1P.P?SY6;[[E?_&C;?>3G//\nM3]&SBGHE)#"*O'V!UC./0U[PAI__92K#XQ2E1:U?3WMHE#S/<_^RVR0T^Q\nM[NH;&1T?9W'F-$LG#C-UY;7LON):E#'D:88;]*E5*]3')_`7SF&=7:^,&=,(\nM`4@OE<9:"\\(3!(8P"C'&H)1":8U6:NW1X#U%69)E&2#HK/3XSH/?8].F352B\nMF+??>@LCPT,H)5E>:I.5GC`,F#U^".DLF_9=@PE#-N_Y+M?_^_\\G__X\nM<:J5F$U[K^26]_T3UE]R*4*L%H^D3#E_\\FF:E^RBVFB0+2M\\7L1!&,<:`.^%\nM]PX3!"BE*8J2-$G1VA`$P<5D+&;K?GTB1Q&N\\!/`C*O"`('&$84JU5J51CHB@B\nM#,,7]:\\4UEGR/"?-4ISS)$G*L6>?I=%HTF@VJ=?K5&M5IB[92K->(50PR#-$\nM;8*19A.K`EQIZ166$JC%$;=_Y&,TKMK,4%,1&$6HU5JN>6S:8V1\\G'ALC,43\nMSQ,&`5F>==OMY:Z64N+7(B"D!`19EB%[?820**G19BV1@P!K'9%4!&MC?O64\nM(PQ#@B!`*;56?B59EB$:59J5D%9[D25Q*<.18=#-*/$():G'!B6A4JU2N^H&\nMJK//HO=>31P:M))8YU"C(\\3U)JU6%Y$F:*U)D^Q<.A@L26M+K"V]$`+G+-:6\nM**4(HY`H"@F"5:!::Y24"`&%+.^14J*UQCE/GN6D:4J6Y11Y05F66+>Z\nMV\\%:2=5:8VV)$!#%:[*K5(BBB"B*$$+23U(F)B=HYFUL:PZ/Q!49Y?(Y<.6+\nM7:4`$54H)K#N$\\\\>1A9%\nM1I&G?E5*JZ>K$!ZS5HG",,`$!J454@J<L7%B@-7N.8L-EI&>/D2Q=\nMP.N(LM<#ZYA^[GDJ-J??ZS-S_OS=O6[[\\5ZO@PQ,2!!$PGM06A'%,5)I;&G)\nMLX(\\SRF+`F?=6O^CB<)5>1FML+;`(]!&$5V47;!V^&D\\@KRT3$Y.L"%R%$>_\nMCUIS$\\QG//GB29/<=HL\\H3\nM^P^>75E9^6RC.9+N?^2>U0CD18KW#EM:LC3%68L)]!J@B"`,4%HCA,!:2Y9G\nM9%E.:1U2*KRS6.M(L^QELBO*$N<<01"CC6'3Q@V,%FT&3SW$8'$>)035P%`S\nMBEJM!OTN$T:P]:=OIM$<96ZIPU,'GF$P?9;-XT/<]YV'.F?.G/V=)Q^Y^XE.\nM:PD`;8(0[_UJG<:CM4$(25&L'E2K%2@@"$I8RY/`K.H?/$61(^1JY0F#D"B,\nM",,`%:X>?%)(/!!6:I@D97QLE&!EA>3@@\\PO7DJY=1L3D^.,3>VF$D@Z_8S%\nM7+*2U$@?>9R&]$3"\\I6O?7/YZ2//_G9G:>'+^UY[(\\\\<_,M5`D6>X;PC"BN`\nMH"ARM`D0K$I*:X54$H3`>4]9KE:@LK2(M7;"6XG9[A\nMR8.'GYF=G?NW_5[K&W&U9H\\<>.AB\\FMC0CQX(14>OUHRS6HK[:Q;T[Y?)20E\nMQAA"$Y`JA7,EJ1@@MUC4IAP[D9-5,G1D:,:3K!_:S=3HM6RN[T/E`C*Z\\_\nM_M1C]_%2\\*L1*#*R:>AJUM5W40_'4,H`'JL=U5U0V=@FW="FLW!F)2HJ\nMA\\5,I.R\\%/8"99G;/,_S/,NSZ3S/GDS3])&5]N)I$T3VJU_\\O5?>%;PD`MH+\nM[\\$Y1ZU2(8ZKQ'&,T0:M--HHH54*1^]%.7_X?.O?XO>*O\\^Z\\*_.+YL6'+=IQSFX,P?J!6']H6A#%1\nM7*'>:-)L-+$C*8,M%["-A#+(00IB,\\%PO)O1RI4,QSN)S1IH#PB'$WUR-4-?\nM/DM?G:"02[3.7^#L@6G".$(KA2TLZW:L9W)J@K(L2;.,(B^\\MZXEA3P1ZO")\nM2EAYM!;7#HS7Q\\_\\\\_4?[=]3WLTMYFTO)[!Y:C?@-VD3/AA&\\;9JK4&E6J=:\nMK5&KUCD5'^%@^!#U2HVIC7MYPYY_2:SVHN0(4ABD6.T%2]_#!_.4X0DRF*=*"T0TC;-JY":TU)C#T6WV44GCGLRY=N6T:4M<-8*$X07;Q7RM5?*\nM,K)X[[&%I=WJT(XS+IN\\#N]KK"0%O;1DJ7\\2IY]EQ1YBD)PEJ#BJU2K5N$9D\nM*KC89(S)E52S,XLS1S[0_,"=GWSJD_?H,(S!^QQ$M\\AS\nMXDJ%:FTU`G$T"`\\YY!7F*411M!8`L>.?(INOD!-FW8S/C8!&$>DY<%\nM26<1;32!"IBZ:HJQ\\3&TU$@AF2OGN&ON+D9G1I@4DXR,CM!K]QG?.\\[4GBFR\nM,N-\\ZSQ)D1"9B,LV7$:H0_J#?C!_8>&2\\_/G+^GUND_,+R[Z16!JO=Q4MXZSR]U**THR@=@]S2Z;4Y>WZ:F=GSU*HU\nM)L8GV;1A$^LGUU$U-1R.I$@X,7T":21+EU208#LB)'Y1GZ]/'#`'[]YIT/\nM.&S:Y4`=#.'*BVY]:2Y0TI#%`=H%6"=8VYA\nMCL6E"QP[46%L9(R1X6'2(F.F-"-1RCPPM/R+;YO'^.94T>IB`K;\nMUVUGT\\0FRO%QW)!CD"2T.VWZ_3Z#9$">9:NM3)XAI4*_D,U//_D@0`(DO+M6C+-MEB1G!%P/#(,)V5#DF2\nMD*;)6O^5K?9;64J6YR@I7R3P4KOO6W\\*@#EB\\-KO#V1POU14+R&RYBLED5(Q,2HHRH(D3TC+%.LLSCOB,&;7U$[V\nM[MA'K5)ED`SH#_IK@#.R+"7-T]7?M2BHET;@U:Q6C6G]PO?:O'0C>6F%T@&5*$9*LPI6J370\\B*AB_[:N%(UI!P%+5!5Q>CD\nM*)>.7\\I0U"3)$OK]/DGZPGO%"Z#3M0B\\,)9[I>0/?B/[8?:ZSS_'Y5L;G%M.\nM*Z7UN[/2OSDMDIO3P>^^5O@C(U(9\\3+@+_BO)/1*7RGV[MG#^,@$O7Z7P6#`\nM($D8)(,U_R7/ZO\\B3=.'\\B+_-U**QW]L`B^U7?_E60+Q)4K>5='N8[N,6GJ+\nMUOI6I=152JJZ?!42:DU.+P)_T=^V=8I&O7$Q45\\!^**?I,ES:9[=F679_PB,\nM::WTNS]^!'Z8W?@G;Z2;=ZBH2D,I]5JM].U:Z;_>[9SXUR>`5_G,^C>Q6[_Z=CQ>"B$W\nM:ZW?;K3^>:74ZY14%?F2""CU\\B2OUQH(`?V7[OKJKTW3]-$LSSZ59LF]2JGB\nMP$<.OFS-_Z<$7K#WWO]>LD&",J:AE+K1:/T^I?1;E))#WD.>92BMJ56JJ[>!\nM4I)F*9U.AZS(R;*409+,9UGVN:S(/A^%X?QB:YE#O_;4#ZSUMT+@!?O(_E\\C\nM3S.`2"OU4UKK#VJEWV:='5E:7F9Y>8E&O4$4Q5Q87""*8X3`IFGV0)YGGUCI\nM=Q\\.@]`]^$L/_M`U_E8)O-1^\\]!O``1*J=<;;3ZLE+ZUU^L./7GP`'/SY]FY\nMS-(^][[[_A\\Y[]\\9@1?L$Z<^`=Z'6NF_9TSP$?!O\nM/77F5-SIKAS(\\^SC@\\'@V\\88^XW;O_ECS?=W3@#@<^T[R8H2[ZD:K6^;GIF^\nM^N294W]4K51.=`=]OG[;UW[LN7XB!%ZP+Z9?H-?OL=Q:EI]XYQV.I__Z<_Q?\n4SY"4-VVJBH4`````245.1*Y"8((B\n`\nend\n 6615 reward_write_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```2*DE$051H@>V9:;!=5W7G?WLZPYW>/$AZ3[;D9S\\-QI.P\nM;-P8XYC$;0,!3"BZDX8.94(2XL0,3@>'5(@INNFDR^EJ)5!-2)."!%+I="=M\nM<*IM`\\9RRJ,L2TC69,N6-?D->M-]=SKG['/V[@_W299M('9,X$NOJE-WW?UA\nMG_]_K__::^U]X/_;3]?$RP=N_T]?1H4569^?+C<:]6JGTRD5A9,>#XC"&-TJ\nME2J-_J'1=I:F?MMG/_I3@/VB"8"UDV_EV*$'^+7;/K^J7(JN7UQ:N":W]H(X\nMCH;C."YIK85SGCS/79)F36OSZ2`(]I?+Y>\\"]T].G+/XYU^_BQWW?O4G3^"#\nMM]S!U_[T,]SZZ3O?7:M$?W#D^2.;AX<&])NV;F'UR!#-9HNIZ5GF%I80RA!$\nM,J,P\nM;=8;#MPMQQ,`U.2%6Q@]=W/_Y/GKO[RX,']IH[$L/_B+_X:U8ZN9F9[F;_[V\nMFSRQ>R\\+BPVT-HRN&F%P<(!5H\\-T.AT=!F9=K5KIN>>>^_X^[S3V+9.[EQ\nM$_7E.H_OW,W:M6,4-N.\\B75L'>A'2$E/3R^K1H=16K.PL$1_;XTP,#RQ8T?/\nM`]_^![4X>R+_L2$?^'68/RI^:>*]6]X_=.^G5L],W;1ZZIAPWN]\\7S^B)/$`\nMJE+K0T#O[.S,A^I+];Z>GEZ:S1;S"XMTDHS>_GY*Y3+E7J=1ZZ>\\?H+>W\nMETJU0KE<)HYCHC@BBB+",&*YOLP+4R_0:G4H\\HSZPBD$`Z\\;_/A-@TS>L)HG\nM[O_*%>LG1OYDA(?.77_D.4X^/^Z_<>K?91-;WOHK`[OV'SZ_AZ5#CW\\4;4R`\nM]QXE%4*`,0:!($T2&HT&SGF\\`Q`HI0E#`0@\\'N\\*\\MRB34BM;Y`PBE\\W@?RZ\nMG&_>_43?YDO&/QLMF_.6&@E7U[9R_I7)\\T>.]#VRII&O6EBJXYP&0-H\\P]J4\nMPA4((5'@/6AM,-I@;4JK4<=FZ>M#OZK,\nMXN@RS2Q]YX&I$]<^^-0!LNDJ[:ET^7_>/;-='CM?+1P\\=GMY]>32,P=V`:"U\nM-N"]5TKA7('2BB`(,-H@A.@^2)12&*4)`H/6"@!K+3;/"<-8O^W&=YVCM!FZ\nM>.M5JXJBJ'J/%$+@P2HI%Z(H.EDNEX\\7N5\\00K@O_.%MK\\#?._A'^%OE2'S3\nM\\9M;[>^8`;W`P)K!QO_:=_2^YW;?V*PL+&\\[-?R&??J!CP,/=PD4N<4Y)Y0V\nM&!/@':19AC$98112.$?A"O(BQ^8YUN9HXY!2$@8A81!@C'YCFK;O[2_U#HZO\nM61M7*V6%$&2I)+UU]93/VO^U<>&Y1^3_O0]K\nM'SY#6DNED=*#$.2Y)2J5*,4QI5),&(88;3"F*Y4P"`@"@Y(2YQV936_0>>X9GGCM))4GKZ!L3Y$^<%:6;[E^I+_4N+"Q=52K7W\nM77[IYEN4Y/]L^\\K?\\5L?^1XT?A^NO^N7N>2-K1GAJ\nMWWYJMZ>G#\nMGY][[!-S;YJ]68Y\\^A\\@_^^OD)U&"$!ZJ31%48#P!($AC$*,,2BE4%JCE5IY\nM-'B/S7/2-`4$]>4FW]W^CXR-C5&*8FY\\^_7T]_6"]U2J%2J5$EEFF3DUSZKA\nM0>;GY]C^P(,:8/O4]?#4/>?Q_C?_H8Z"U5=.SU%JS.[_QQU[/C4Q,3DW]]@6\nM'N%)]\\B)'YSWW;W(>^&]PP0!2FFLS4DZ"5H;@B`XDZPVSRE6(A4$`7$4HY0D\nM3=H0[?_ZD=NW7O;;_]K8->/W+@TW@-X$.29)0@<\nM81A2KI0IE>.5PA6^J'^E*%Q!EF4D:8)SGDXGX=#!@]1J/=1Z>JA6JY2K%$>16P]K##?]S,?8M.87AHXL_3PXG=SW\\3X+O)K&4^)4(""D!09JFR&8+(21*:K192>0@H"@L'W1JBI$2H;M+;W)+9#(3$&.UYRQ^_AZWK/ZY/+.LK.LLTETY\\\nM_=[[[OWBP,"ON?GY5^K]!YDLBIRBR+T0`N<*BB)'*448A4112!!T@6JMNV`$\nMV"(GS3*LM4BI`$&669(D)4W3%R5GN[)SA4-)11B&Q%&$DK#8Z7\\#;]G\\'VD7\nMO9M/S%%MGWKHT4=W?69R\\M+FJP4/()4.4#H0WGNDE&BM<$*TBPE31,Z2=>./J9G;M^[R$A;@`.O38"@0E7<@"45D1QC%2:(B_(\nM4DMF,D)K<85;Z7\\T41ABHQ"C%45A\\0BTD41G9!>HMHN7YSZPO>V_]DWRN4G@'M>$W@`:6U*9A.\\=Q1Y09HDN*+`!'H%\nM4$00!BBM$4)0%*>ED)$7#BD5WA44A2-)TY?(SN8Y;D5V86!HV!Z>6K>5L%%P\nM7=ZBE)SZUH,//O1?QL=NL.WV7[UF\\`#:!"'>>X00@$=K@Q`2:[N%JBN%@"#(\nM825/`M/5/WBLS1"RN\\IA$!*%$6$8H,)NX9-"GB%7+66\\M;F7%YX5V*7DX-XC\nM1WYW4<4E@"!M1G:!`BZDM):(94$(7#>D^?='2C/\nMN^VW,0&^<$AC2'R;(NI0'\\PH>A+*HH?5>AWK*Q=2"BK,S9YBLT]9-;3,CF-/\nM[]Q_8,_!R8O._6>#[T;`A'CP0BH\\OJM=TVVE7>%6M.^[A*3$&$-H`A*E<"XG\nM$6WDV@(UEE$,9Z2E%!T9>N(15O5N9-W`5M96WT`ZOTSZ[+.4>X9HS"Y@HJ:#\nM_5[KOM='P-H45Q24JST$)J`H"FR64811]]9(=.^^O(>B<&0V(U%M7I#/IFQGJW,%K=0#4<1"D#0I`&.4-ON@@_V('QW=0N]E>^\nM]V,W_784Q(^^.=I\\<*1G=+Z5MHH[M][YF@B(M>LWX;T?UR9XH%RIK:_U]A''\nM9>)2]QQ<+E>HU,J(LB.M-FF4YUC2L[1%':$4Y6"$@=)&1FN7,53>2#D81$D#\nM>,"1BP8MCK+$?I;RIVED,V2V0]K)<+E#"MF4J.<#%3P9!]'#I;"\\L[?4>6@]%?T)[[2F*\nM6H<\\R$`*8C-,7[R1@=(E],63Q&8%M`>$PXD6F3I)2QZDI0YCY3R+4ZG/#2PF,K]L(^#%MPNUA%*\\O5VJ4RM7NRI>K'(GWL3M\\D&JIPKHU\nMF_E7FSY.K#:C9#]2&*0`\\.2^B0]FR,/#I.8PN9P%:6G,-&@MM`FCD&-[CF,3\nMR\\#J?L8FQ]!:8P)#:[&%4@KO/(4K&!@?(/K@(T:;\nM/;VEWA<^_."OI`OO6$#GA<45A3!!>.96(5LY4N91@?>>PA8L+=99BE,N&+D*\nM[RLL=RS-)&>^]1Q.'V2YV$.[$."\\\nMIYWE&%6@C2`H+`_O^SR-;!=CJ\\<9&APFS&*RW-*ISZ&-)E`!ZRY=Q^#0(%IJ\nMI)!,Y]/7:F.UDTBXA(4#,];!K9R.8++R0>BCFQ?!(I);6XRG#?,!))\nML]7DZ/11YN;G6&XVZ+3;I#9#92GZ^6?V`OA5XY,/.%<\\)H2<\\)XW%GEQH9:DYAM<4;CU#@A6?1+_)H\\1C[CQR@)$I,C$XP-CQ&/C2$ZW6T.QV6\nMZDNT6BW:G399FG9;F2Q%2K5RI`2>>G([0`?8^[9W?F#O=[[UE_`%T-\\WGQ!"\nMW(GT""EII@52=@FDMD`90QS%:!4@E41)A902*02+]47JC7JW31>*435"L]6B\nMU6IA,XO+'3@H?,&B6V1)+I'.I007!_3U]U%?KM/I=$B2SDK_E7;[K30AS3*4\nME"\\2.-N^\\ZV_!,#L,WCM=P8RN%\\J+M8F[&^F3B`*;.%)K4.IH)LKTB!EM^V0\nM\\BPB*[Y2$BD5PP,"FULZ68=?2*54IMUITVJW5@!W\nMSQ%)EG1_5Z*@SH[`#[)*.6;Q3Y>W1[\\>_;S`;@B#_FL[5OQ[ZL[P0\nM2@>4HA@I31>L4BN@Y1E"9_R5<:4J2#D`6J#*BH&1`J(=.VJ'5:M%)\nM.BN=[6G0R4H$3H]E7BGYRF]D/\\PN_]+37'1.C1,+22DO_,8T]S^3V,[/)NT_\nMN$SX??U2&?$2X*?]EQ-ZN:\\4FS=M8JA_F&:K0;O=IMWIT.ZT5_RSGNY_FR3)\nM@YG-?E=*\\?BK)G"V;?B3@P3B:^3\\0DF[W]E@U/S;M-9O5TI=JJ2JRA]`0JW(\nMZ47@+_KKSUE'K5H[DZ@O`WS&[R2=IY,LW9:FZ3<"8Q:76XU7'X$?9M=\\]:TT\nMLCHE5:HII2[32K]'*WV#4FJ]5$J]F+3!(<_U?V0\\KH)G&UO_]L;\\7@IA!S76M]HM'Z_4NIR)55)GA4!\nMI5Z:Y-5*#2&@=?:J=W^+)$D>2;/T\\TG:^;92RNZZ9?=+WOEC)7#:/G#_!TC;\nM'90Q-:74-4;K#RJEWZ:4[/4>LC1%:4VE5.[>!DI)DB;4ZW52FY&F">U.9R9-\nMTR^F-OU2%(8S97E=)O;S8;O4_NWL7TS!23DQN(PG`A29,OI%FV32D]ER8M\nMOOU+]__(>7]B!$[;'4?N`.]#K?35Q@2W@/^Y(T>/Q/7&\\JXL2W^OW6[?:XPI\nM[GK/-U_5?#]Q`@!?7-I&:G.\\IVRT?L?QD\\>W/'?TR)^52Z7#C7:+OWO'_W[5\nM<_U4")RV_Y'\\..JUS_'_`,'I$&U=>3H$`````$E%3D2N\n#0F""\n`\nend\n 6616 script_write_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```,(TE$051H@>V9:XQ=UU7'?VN?Q[TSXYFQ[]B.[7$>N&D;\nMTJ"D35*%QJU*$A[E(P6DMH``M2B(0E#$AQ0A/M"*A@`55OQ8=]SID[<3W.)(9/W=+6.?>>\nMU_JOYW^O#3\\8/QAO:\\AZ%__AD?WLV+5##KU\\J'7L\\-&FJEYTCXMBHCC!Q3%1\nM'..B"!=%B',XY\\`Y!$$``\\P44PM'[U'O\\=ZC18XO"M07N:H_+XA^^?._\\_8`\nM//0W_X2JW3`Z.OZW9T]/[VQ?:)N(8&;A87%!\\"0ABMX((,(YAXB`#`(HA5=%\nM2P#J?26\\:%%TU/O?%9%'5)4_?W!]$/&E+GSBT_>S,-]F>6GI(_FV;.^FT6$6\nMYA<`8V1XF,@Y)(J"T'%,%,6X*`"0R.%?:2=0,1$KA@J:M$E8JC8?WF1EJ!.'-`@`?0'CO,57.S5[@^9>.D)O=ZHQW\nM`<]?#D!TJ0O;=DZ2INEXUNO>YXMBTCE'%"44A=+:/,8[WW$U:9*0)BE)DI`F\nM<3BF,4D\\,).8.(Z)XRC,*"*.7'GNB%Q$%#DB%^;KLQ?HY_D0<%"]WA<6YMN;AT=&BHFM0Q\\2<;\\X/3-'M]G0$-G*RKH6N"2`9[_]'P`=X*L`\nMO_'`'P.<1OCYA>5.8W&YP\\26\\>!&QEH0I?M0"5_^KZR>#_Y?>&.EF['2[=%L\nM-G!1A)G=V%M9'A;G.NL!<.O"NWA,BC!L/-)E$4(\\[MB:)XJY/U1=P@`)MUSLV8P=S"$EZM=H%*\nMHUIK5FJM>S4*A=P;O<*SDA4L=OLL=C(Z68Y7ZF20I@EQ$N/$38B327'KBWA)\nM%WKC$.=0U241=U:AGV8B8F[R<7!NP@'#\\\\(L]<>Z,U4ZO3[MY1[S\nM*QE+O9PL5W(U?.5*$@06"94:YX+FZPG..=(T19R+Q+E)%UTR46X,0!3%O.>V\nMO;@HFA(7D>4%O2S'J[+2[3.WV&&AD]$O%#,IB]CWGT'P-PHOI46$-(T1<8#L\nMCJ*$^__@+]\\^@"]^]K<(&5->%^?PJBPN=YE?ZC*_W"4OE*J8(1*$=`YQ@58@\nM#ES0O)3"AZ-;6PP1DB0)-,3)9'=ER:U6\\XO'FXX!"'&`V7GGQ*L1G9]?0J(8\nMB:)2!GG#++6-A.MFF`2UB3E0K86WTH4`XCC"10[QM82OO,$K-!W"K-22\\P[FHY%(R)B(-@2L#()B=)1')\nM1*19>"V#.+!-UEC!#;B1JZN7`)B"#EBJ=I]PFZNH.+))Q#76X\\P;J@-!H[*,\nM2%]$*+QB@4R$`!P@=96/U\\%;4FSJ&%C5OE6SK!TB4E'Q480Q60?!ABT`Y")2\nM(%)67W`5XX1:D%40T8`;*6(VD(%*$`P\\7[[+10Z$IB!#ZUE@8S$`8*(@*I0`\nMM+)`904NL/*E^!ZU+A$@L5PQ`X/LJ@E:R#K+-2@`J\nM,`-`Q+GPB*[Z_:KPU;G5)BB34B20K"?3QKA0G>I6_=W,T#(.E%5.-/A,703=WYZ/!WZW+:I;/<#7SM[\nMX.81_(8!B!J&Q9C%%9Q*D#<*)6:(:LCY7A&QL(!71]\\+PQ_8VK[YNZ]>EQ?2LZUNGZ?NW5@,E)EB&$BMK*K51^M.P\\#TJGBO%(6GJ!I87O'J\\26(\nM`$0'K*`4VN?4CB=9WGJ2Q>5I?NP:XU=_KM<>NF'HJ7=%K5_IY^U6W.T!&PSB\nM\\$$;,[,&&%63J^KSF`Z"\\![1W].R??/RO[GO]Y"NAX[*Q2AS\\=*>I-LT,)Z"J(!J8I09_\nM)]0ZC$#V4%<^;L$"%8CZ6`(QI9]YGGUMAB-)1BLMN/FJZW7?H9?V/_'U#RZ,\nMS^NW]-#?_^L??N0ELN(K&P-P_V?_H@K4'686888,`!"O(#[0!O7@RW:B$0!5\nM-4,]WA?XPM>-K.0G3P[_`35.[Z4T]J\\]=DSWSZIF[OVN]B:]U#WW]\nMF\\]/?%CSV<_4>U#/D:F"1]UN+$^YL7,KIX_;$W.M=Q^^SL53]SWW4X_]]I[C<.(S:^1Z\nM\\P`*S^Y;;N;DB_^]W;2LI0:^U'RHLKY>^X8"9?4*K"I0ICH@?%&V%3TSLWT>\nM7MK*RN@0=YV;X^K&/,.WI(^>Q/UU<_%HX]19LL\nM.J?7W9">O59/+7[A[^[ER6]\\?[G>/`!5Q&Q<5:]UJL%]+`2DX<*2L%Z5!=<1\nM9Z$[735]!YJZ(2L5%%G.OF/"?\\N=N5L_>!?+BPL3M]QVQZ]__)?O\nMG1@9'?,'GSSPOM.G3L68K@4@JWQ>#5QDB`TL':6B^255,,_"A3[_-CO&S.@F\nMKG[N-->/+=#8LL3(J"/K]3'35Y)F(\\O[_;<&8&AXA.;0T-[Y^?;OS\nM4^0Y0?N"F>(+OZKYDD!*R4!=W/`YDGBHW/<42PQL;W-Q*3#?`AL\nM55TPU4,&?/%S]VT>HB@X\\-(BCS\nMU>&Z&T>0J&!EN4,_\\*CC9OHJETM!EP+0VKJ-NW[ZH[SP]'_E4R>.<>;T%",C\nMF]G2V@D8G6Z77M8G3A*2-"5.4N(DM,6C."&*H[!K66_V!29[H:U\\Y?Q.%M.4\nMVV>G^>&Q)1JM);IY3+Z2D_?[^*+`5)]9.K]X8:0U^M8`C(UOYM7#+]J6+:V'\nM1>3N1G-XO+/2KQ>)@4(7>%4*KT2%)^KGN(%M5E?W08.+.83ECA]JQ2Z10]/L\nM(ZPV,1O6Y6%K9"U/OSIOK5T8E1R_+U`QC6L=$_?_,91"06>,?,N=G6\nM]PX=-N_7!E2]3QQ7F]U!\\Q*5>\\3.!7<307V1].:F'TP<'VA?\\&>^LW_F3^_Y\nMV9N^DR8FI?`!0%&TM?!'1<1_Z?/WOW4`5W+\\S,<^A<&V;=NV?V/SV*:9[DK[\nM][_TY8<.WO/CM]KCCS[WMMZ]_N[!%1JS,]-,G3C2ROOYM+CXCX8W;3YZGKT````"7!(67,```L3\nM```+$P$`FIP8````&71%6'13;V9T=V%R90!!9&]B92!);6%G95)E861Y<>,@+\\.8$>$$*4AXB(`B"HUC@Q,9V#GL=\nMASCQFMAKK[WKG=V=JX^JCX?JGIE=-B(2E/1U57=7?]^__O4=U6KQTCL>H``-\nMZ/H;SWU1B;I5E%((@(`(^<7=6R,(`E:PQ@DBB(`U%K&6++/]]R8Q$K=3:6QZ\nMMGW[-]X";"ZB<@#:]T,_.O#T>;5A1P.MD"QS<\\2`$<"XL;4.B\\U`<+W-Y]E<\nMQ*X1&7RS=/[D\\CV/W5R`T/GJ5;3OYP?5EMT-09`L<9--"EGFE(L=&+!9KG"-\nM0024[883943^'YD*6%\nM7H52'FTS1O7J6_#\\(#=:[([EU?)'>7!ZC%YF"3SWW'HEK#%\\864?7]\\ZQV@H\nMJ%)EBKSI,!KSM?8\\)`WH+>-+RJ:I7.';[]&C/+Y>LR2R]\nM%L1M2+IH&S.Y:Q>S\\U>!E/"\\$)$R5DIDMD0]B%D^_1IB4@3%R]S,GOTA*XLM\nMHBQU_J,]4(K[+OV1![?-4F&PK6)2^@P@8JUD0M*!I`5I&^(NVB9LVKZ#06>Z>^S/?N>X]RBH!\nMFX+)P,1@4ND#D"*\\D@[$'=>;&&R&IX5-4]MY;P;\\($)[-9`(L67$5J`T#J=?\nMX\\F/S'"G.4FKE6%[*;;=XZZYO_#0C>]2"U+GS"8%DSBGLF:8`>L`V!1E,I3-\nM7&]2E#4$OF;3U#;.O-,B"&OHH`Y4$4+PZYCZ-7@7S_"+6\\^R<^44\\4K*IUJ'\nM>6C'66I>YJ+(&K?ZW+BR61^`;PLT)G4K1R':N%`2"_@$98^K=M[`S/%3;-WU\nM(?`KB*?!\\_&J8^!O)WSW$'MOBWGRR$6^>],*H^4,C'%Z;0Y"C&.YLRBKPA!!\nM85(7_TJ!>*"UBUNQX/F$4<#FW=OHM#O4M^_`>"&Z<07B!VAK4:9-\\%$$Y@J`"I0H2CI.^\nM?1YYYQG,^=.8F9-(NT5EI,I\\NT+]OGM1C0:/'-C*OJ/S'*M.,6HO<\\^6YH!1\nMAGKZ#/0!J'[5,PDD>1_T$#^B^_E5B*%3\\Y\\3$\\\\S?NWCRWIBC908T`I?MW8@9%IQ@'->+7+Y$>GH92\nM`X)1\\.J4;$"G+20[MG+E!GCJC3K/'[I,+2ICC,$D,R0OO8[RJA`#72'H"MVNHK-MG,T[&I"EW#/R#VX.\nM7L.*A\\U2,`:5I5Q.(AX]?CL'YD9SW86PB@'7ABDJC]![.Z"W[QB4:I""]!1^\nMSSGU\\O4C3&ZO0)I`%G-C/>7QW=-<:Z:Q$N*+P5."3\\I"6N,')S[)X?E&7I+S\nMTMS/A*L`&*0\\3G=FE/BYHW@J0G6`MN"W+;TN')PE/\\X?9C8.M^(\\HR#/BPBF/I1>.\nMH*ZH(IXFLPZG,C![59V)+4)Y\\1R^!^-5((6H9#D;9TR$=>Z:.,:+%U?PM";4\nM!FL5)65HI15^<_IJ/GOEZ2$?',XR>>H=W;A$[4+;J&.=P%D`$"4$(3*\nMEQ;^-77,14&,004:M#/HBR)M"T:!U^=.^M=F+T!4R/71,HA%;$9F%5WC,599\nM86MYR=4'4:L`N)NT.X=?VD@T!D&(=\\,$TLOR\\_+`54H"HH%`KV+`BB*J>M2*\nM50FL>3.'H_41DA[?`+G]OWS.UI[YZR)M[ZV>D\\5C_9*NT\nM&M;;/S\\,T0_#6/JC$>+638Q-NJS:6A@D^#E1:V1MD_<9K\\8!\nMC/[T$[_$"[[&V*1CH;7@&-!>L_GHT2O)=U.&I`A2\\P$D^V_/F@\\??("D^ROF\nMST`X`N7:X/\\BMUEXUUH`'P3(VKGK?6.;CQ[90])ZFH4SKM+Z)7O/ZTOS1B?M)\nM>WOI+1>+9ST&AMMZBO^GUOSQ/^_'9'O)DG49>#^C_T^A^<2I^Q'[K<+@OP'#\n33-I\\2K+<&`````!)14Y$KD)@@N_'\n`\nend\n 6617 spreadsheet_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```*CTE$051H@>V938QLQU7'?Z>J[KT]/=WS]>:]%]LACO-A\nM64C@2-A\\2HA5!!&+*)N(B$6D[+)((B&Q88642)%@8;$`-@@I(*$LB(C$R@L0\nM6:``!MD+DB`3(^S$>>]-S^MYT]W3W?=6G9-%W;[=/6_F&2,+&<5'*G7=^NIS\nMZISSKU.GX#UZCWZR2?[ZW\\8(8%"IX=4,55!`K2T*AK5U0RW7S2"I8:S'Y3F6\nMYZ?5/".MYK9C33?6-\\MK&5Q,)YR=C9B,[S.;GJ?E9+3TH>3;?_KY*P4((B!"\nMP/A],7Z)O`X8F4/+`ZW]D\\VBMC',,K-&^VN`@&E;;]?!0+IEUXWM<,JJQ^[N\nM'JF)$F-S(=QX<30:?0-XH_?L;[-XY2^W-?`W+Y\\A(H6J?K,(\\AO[/9^9ZQBS\nM#4;7.W]YS&J'4ZO!I+0[WVK4++=I7J,;9VO-IE:+==-P,9MR?G;*Z>FICN?I\nMW__[M?_XPS=>>_7K_<%P>?;W?[36@!,0#!/AJ!]X_H.[.'G[MI@9-&*"J$I,\nM1DQMF^9Z5$BI_=;M_I3HVI.6Q-1G61_RRG?-38L;/U-5U9\\41?7,O1^^_N7'\nM?_/W+M[\\VZ]D`;P#$;`$3M;E[9(3(3@A.",F1W262S*\\6MMN1`&ON02!J.!5\nMB&)=>TS@!8(O.3X8\\I&C`1]X[!?[WQ[L_\nMX$00`>_^=XQ?)N_R>I($$4-$D79S9%42B`@.:\\?81CL(@HCB#'K]`8<]8]\\U\nM+)]YLCS8W__"DT]]]$41>?D5.A,"D[R+[P0Y$0J_TJ;#2=Y]$4-:IEVKC8[I\nMEH\\LJ"')D=38&_3YP?TIS?(,FR^HS)XXVA]^\\GP\\>OEWO_X:(>^88$F[1=X)\nM$H'@LS:<"$X4MS+3Q!;S3@67%"<057#)6J'AB:-=;A_T26HLFL3I=^[RH]/S\nMCSE?A1_>N1O#2F+O!">"`4T=J>NTP8QT)01'43A@`\\,O,6^7&A1#$516]78N\nMN20S$M*ME\\Q(JB158LK%N4`1/,/]`R:I*.<74RG+JO4!P,1P`IJ4%U[X!U25\nMJBJ8S93Q6+E[DK@W5C[S6T_SV<]\\&(`[\\\\3WSFJBTJ*,7?%+]]U$HTF72T:L\nM)I&_HU+7-?7%.J\nM\\=KW'_#\\\\Q^DCH%_?OF$?_WNA!],$O.BX.=GVNUL8\\;Y!E-UVF:T7C&TR7#<\nMKF_VU5V?4#=]ZIA8U$OB_():A3)(!AL'F'1FRLIWLSD)\\W3`U[YYCU=/:NXL\nMP0X'\\%0?CG:0)_<[`8(3^I7KF"I6S+C,6$A&XX0BZ9IIM\\&T-XH-@0J_$E`H\nMO:,I"LJ=7>+>(;W!D,()W@E>!)PA0)"6>[="(1%F1WM\\Z]7[\\,0AW.S#C;8<\nM[6#OWUL+X(6=TA%<9M9'PSO#.\\4G"!&"@Y#<1I_ADQ%B/AM6WSXJWK7C8X9U\nM[QS.]]"JI.KU"7[CG&I-/VQ#1U;/IS[Y%$__ROMQNP7T<[%^@?8"OW:X'KY?\nM.)X9EEUXL`H9NH!N\\[L+(=;UU9BF]9=F98+)B*W6\\FD-'SKPA%8#V81:I+L,\nM?TZ$7_]9^(7%I(64?+"4OD!,L!I>'X&8Y*CL"@HY..GF;^^18&)KO/9@(4>U\nMFB2'(6JDC3##3!CVCDE6$%QK*:WO/B2`"'SM>W_!5^]\\E4``!5'!FT[4TFDV#1F(=Y#K.3$5/$S)`DI#HQ\nM88+IM@"F1JH3R:4L@$),$4T*"5*3F,N\\JW?7FE"BO&)\nM&Y_@XT]\\',,X/1TQ'`XIBJ(3T,PXOW_.S>.;B!/,C"8U@*&JG)T^X/#&`2N`\nMV#S8SL?G'.P?4)9%WJS4H):A^>STC,%P0"@"VIXM28WYQ8+W[;\\OF\\\\*1J_5\nM`-"3'GW7QWN/\\R5.AG@INGN!FF$IL*@/0-S&!<=(25G4@=GRN+OTU&JMXPK3\nMB6.JN_BBZFYBJW&3*"VT>>,CB"M":$Y=\nMM,:8&A"W8_L'2V,\\5]16,7Q[ZB9E=MY0VH)D0M+LH$GSB;QXL"2=!]1E85=S\nMDT*:SK%22%*T_Y7G%&G!+W_8*()T(4^.6*_1@/>>LBSQSK%753PVZ%&696<*\nM9LJ)S3B^.<0YMRDWFI3[HX9;MV_F('%C71'AY)ZC/QA25A67@>K^J.3@\\("R\nM*+?F3*=3=HI`X5UG0M<[L4!*B<5B@0N!^O57V7GI15(1P'L(`7,>30[='T+P\nM&))-1)48E=EDQID73!5-BJ;E+U+*HJF0>HF.W!,I"81=P?$\nM^0(OK&'T6@$V5"<8[J//XK_\\5X2RW)01?_;64TOL_AT0W*HLB-EB=-9S-ZPSW,VE#BK4Q(-8>T\nMWCFF,7'6@+.,)"NG'%\\8;U;9QKN00;,3GX\\3?5VV>:/-T`%F#VI\\%9#@UIF*\nM-MR8/ZCQ=R:8"SGL:.=1S_GT=54C";`F3>4Z3K#(1J4VA+&:*U8IZ[7"^0YQI(ETDDLA&]@**E*BC\nM=I;Q:!AM!WGO<WO[E.7#*#2H"HR5";4WQ$>9T'*Y;%'H/VF^\\2)<0J&F\nM,>)N#Q="/O4U(T9,RO2BIBC#U2BTC)P!@37*K.:>Q43/N`*%`L]]\\4O(\\8W6\nMA%;"O84)N5#@KT,AUR/T7(="*=\\KD:C0@&J#MLBSA4+JL*;!-7$+@5),3'S)\nM?+&X&H46"V"5('@4C&Z9D!">_MC5*'1R0G%\\C/.^,ZN5"=6C4V[=/+X2A4Y&\nM(P:#(555;ML/<#(Z97]_[VH4VMOK[@#_HX-LN5SBG6/21,97H=`T\\6:(F*1+\nM*)0X'R_IQ^M0:(FO/!+B.A^Z0J&S*7Y'KD:AGQMT*-3ECKC&B[;,#E/!!V")<0:/UQC%V3\nM/C-;_]=Z6H;+@T$?U=8'WBJ+90TYU`?'0N]RVDS>_[_5`#!N4>%\nM$N]RNEX#`G4T[D[B.Y:A?GMDW7L;K)_G;"-YG!3J9'B7!VS&0B;PTD6M_K]&\nMR_30VO\\'M/G^MDZ.;23(R.>)&=X[>V96XQ>UU7'?VOO?/42>WX-K=O9K[[.7OOQ<,YWV4FXU1MG;S0)6V=??;M\nMK+77VO^U]CKP4_HI_?\\F^=9_UQ%`(8V*C:K$"!&(6I8(BI9U)6I15X40%64X\nMKIBCQ?S0GZ>$_MQRK,:1]56+M13:S0:KJTLTZBNTFNNQUUCN69?P])\\]N*4`\nM3@1$<"@/B7*,8AU0"@ZU&*CE1T9+U)%A6C"KE$\\%!#26]7(=%&2P[+"Q'$Y:\nM&6-B8ALA]^)]WA9FCR\\M+3T*G!^[]5?HGGQDHP8>.[&*B"0QQL<3)[\\P-68+\nMY@:,Z0BCPYW?/*:_PZ'48(B4.U]J5+5HB\\4:@W$ZU&PHM9CE.>U6D_7599:7\nMEV.]$UXX=_;TE\\^=/?/-ZF2MM_K4'P\\U8`0$1468K3J.'IS`R(]NBP6#B@_@\nM8\\0'Q8>R+19U'R&$\\CUN[`^!07N(*3Y4Z64SG'Q)33/9?G.E4OFJ2RHW+ESX\nMP1?W?OQWVQ>__?N%`-:`"&@`(\\/RHY(1P1G!&<4'@S=:E*#8J&6[X@5L+(H3\nM\\!%L%+SHH-T'L`+.ILQ-US@\\.\\F!/7=6GY[<]MOG9^=6GW[J^!\\=^=Q7],1?\nM/H@S(HB`-3\\>XYO)FF(]"8*((A*11,&$B!'P43!!2Z%AW^P$NZ:KA*AT\\\\#RBU>X\nMM+Q^FS$5=^'R%>_Z$ELC&!$4R#-/EH419F10G#,DB0%&,'P3\\[JI(:)$A"C]\nM>CF7H@15`C)8+Z@28B3$B`]%,<:1.$MM:II&2-).NREI6BG/`*"B&($8(@\\_\nM_!UBC%0J":U6I%Z/7%D,+-0CG_W,#?SZ9]\\)P.5.X-1JAH^4**-;/!F\\YU[)\nMP^92(%8>*-Y]),LRLO8ZO6:=K%''M]=XX&>/)/..9T\\L\\E\\O-7B]$>@D">]KQ<'.YJJLCS"5A8V,9GV&\nM1AGV&^NC?=F@3\\CR*ID/=+,>OM,FBT+JI``;`Z@,S)3^V2W,2>B$:;[Q^`)G\nM%C,N]T!G)N%0%6;'D?FI@0#."-6*&3"5])DQ!6,N*+D1DA"'3)L1IJV2C`B4\nMV+Z`0FH->9*0CD_@M\\TP-EDC,8(U@A4!HPC@I.3>]%%(A-;L-O[MS`KLFX$=\nM5=A>EMEQ=/^VH0!6&$\\-SA3,6J]8HU@3L0&'Y.7YR7OFV!0?*FUPEO#==,65VJ@\nM,*$2Z3;#GQ'A[EO@_=U&"2F%8TEM@JB@&9Q;`E$IHK(MR!7!R6#^QCT25'2(\nMUQ;4%5%M#%*$(5$)(V&&JE`;FR-H@C.EI91G]PT"B,`W3OTM7[K\\)1P.(D@4\nMK%JDP$$D"K5VC4;:0'4$#_M]W1H-]\\8^(DSFDW3IXO$02@'[?;Y&1]OX(@Y'\nM(VA0INPT#W_JZ\\SOO0EC9.C5MQ(`!1\\]'D]&1HRQV.U1)H.@7NFX3A%F!\\4'\nMCZHB00A9H$$#C1L%T*B$+!!,*`2(X(,GA@@!0A[H2`/[/L(BK*\\O$2M5B-)DH&`JLKZRCH[YG8@1E!5\\I`#2HR1\nMU>4U9K9/TP>(4<>V7E]G>FJ:-$V*S0HY40MH7EU>9;(VB4L"J(H&1S>;!C$C%QPEA$@W<[1Z\nM01'R'OMMDU:TF=P4EI\nM0F@1&6QE0@!BBD.:H305\\!MC^[6>4N]$HO9C^-+KADAK/2?5+D&%$(L#&F+A\nMD;MK/<*Z(YI"V/[<$"$T.V@J!$G*;Q5SDM#C`X>%)+$89S'BRXCU*AJPUI*F\nM*=88ME4J[)D<(TW3@2FH1A:UQ=R.&L:84;F)(;*RE+-SUXXB2!Q95T187#!4\nM)VNDE0J;@6IE*65Z9IHT23?,:2XOT7W^2?S*!::J-W-Q]^VH&(S&+000""'0\nM[78QSI&=.\\/X\\\\<)B0-KP3G46&(PQ*D:.(LBA8G$B/>15J/%JA4T1F*(Q%#T\nMQ:C4L\\!XI8)#B#&BHWW='I=[&2;&(ED0E/5DG&PJ$V.UB\\IS@(SZ4?3ZR[BHD>8YD.3$H2S3XA]OOYO3>\nM&SFZ\\#WNDVDF[G@`D@J5K(6YF@GU52?LZW1O"J=/O8O%,QWV5\\?9>3S3[S.:^?;S%8"M^ZY@`&.V\\@.E"?5ZO1*%\nM7B%_]#AL0J$\\5_S$&,:YPNM')9;7OV8[(TG=UBC4\\ZP"#BW:0QS,7?.1_TB.\nM\\C^[[^4]E\\;IOO8L%^=:K%?V\\KE[#W+?1_?SQ(OK@^S)UGY@Q(2,2[!70R$S\nMAALS`Q0*Q;T2\\1%RB#$GELBS`86B0?,CVL,31R3WTK%&H&+CJ/2MB$0H'U>H^JOQH*];`5\nMBS@_R&SGK9S'_C?GN]49CIQ?8CXTN3!A>'+%H\\N7T:S#IV[?PPS#&UF18]KJ\nM#`!IF@Y0R"0)7>/8C$(=<81HB"H;4"@$H1,6/3XJ(RA!+%ECHDRG+Y*+"0(.W?N),]S\nM``[MW4/_^K0A`[1K8I`-V)P'0F=@$P(-7^;0G//#+-U.M)H.4O8@P/5DEQC))]L/"Z4JEL@'FWBKZ[NDUOGS6T&I[CBVL\nM\\)Z#D?M_\\=WLWS.SY?@0BQSJZ(7&;#GR;:"%A0Z_\\^02IWK"_A=[[WGT_=&YA\nM0C(PH;=?`U'YZZ>N\\!?+X%Y>YD[?X.Z?VPNZ;T&#WV:P!@+SS;/'(I6CFZ5.>F6N?\\X=NN\nM_]ZZI-2O=`?_WX;)L9$$&84_4<5:(\\^KBHZBD`<>XMK]'G@#O?]@-7S];Q[]\nMO5IEYVW7G5(.^N[RRZ^]\\IM?^_./??N9'W2,,8*4S-+_\\4M9-Z4ZR@P(BD;!\nMRUO)\\"A]^M<>Q+DDV;E[[]]7TN3^U95PX5^.G_O"Z9=>^:LTK80L>^S'7OMM\nM.<19EM-JM6>:C<;!D/>..[/XR=.O_,G7[KIGX2=B'L!>(Q[?E!87+G'NU9=G\nM\\BR_),;]875R^LRS__ZOG#USZ>WX_#4CRUNP8?\\'6#O1AQRH-!8`````245.\n%1*Y"8(+]\n`\nend\n 6619 spreadsheet_zoom_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```-/DE$051H@>V9?XQ^^][,SN[L[.^UO?;:3AS'\nM"4FN_?PQWLS.^O:28-<)1(]TM6\\\nM=W_-.?><\\[W?>Q]\\7[XO_[]%OGJXB@`*D5<"KXKWX`&O>?&@:/ZL>,V>5<%Y\nM1=GHEXW1;+SKCE-<=VS>5WW?_*K97`K->HW5U65JU2LTZNN^4UOI!#;DU3][\nM\\IH&6!$0P:+\\GB@_1#8/*)F&FG74_$_ZB]>^;IHIJ^2_"@BHSY_S>5"0WK0;\nME7EWHD*1P<%A7))*FB9-8>R%Y>7EYX#SQ?V_0/OHWVWVP#\\=645$0N_]\\Z&5\nMGZ@4@TRYGF+:I^C&RE_=I[O"+O>@\\^0KGWM4-:OSV1R]?KKA69=[,4X2FHTZ\nMZZLKK*RL^&K+_<^YLZ?^\\-S9T\\^6ALJ=U9?^>,,#1D!05(2QDN6^78,8^>"Q\nMF"FHI`Y2[TF=DKJ\\SF?/J0?G\\G>_N=TY>O7.1Z2N1"<>Y>@)-?5P_,Y"H?`E\nM&Q;V7;HX_\\5MG_[-YL*__'YF0&!`!-2!D8WR0<6(8(U@C9(Z0VHT*TX)O.;U\nM2BH0^*Q8@=1#X(54M%>?.@@$;!`Q,5)FS]@0LUL?*+TZ-/R%\\V,3JZ^^],(?\nMW/W+?ZI'_O))K!%!!`+S?U/\\:@E,-I\\X0401\\4B^.-(M#D0$@^9]M*\\>!$'$\nM8Q2*I2%&BTK%)'3V[8Q&*I7/[]Q]RPLB8-(X(1C^F&J6.3\\L8+QGF,0.H%XS0W&F;&!ID>*>&\\\nMTDX<*\\>7>'=E_1YC"O;BXE)JNQ8'1C`B*)#$*7'L^I217K'6$(8&Z,/PJY37\nMJRH\\BD?PTGW.QY(5IXI#>O,Y59SW..])75:,L80VH%P9H>;"J-6L2Q05\\AP`\nM5!0CX)WGF6?^`^\\]A4)(H^&I5CU+EQV7JIXG?GXOGWOB9@`66XZ3JS&I)T<9\nMO<8OO?I6X5B5MKO'X)^YCS^P.PB!@8&"0\nM@6(I\\[(Q>0[XS-W>*V??7N.^^W81IY;7CESF]1,U+M0TU23V0F0E`QL#J/3"E&[N9N$D\nMM-P(7W[^$J'8'<)Q@:0G96>`=8(I8+I*15VE3&98M8IB1%"YS>4\nM-GU*!TK89U`8=`T4HL"0A"'1P"#I\\"C%H3*A$0(C!")@%`&LY-J;+@J)T!@;\nMYC]/7X&949@LP7A>Q@;0[<,;!@3"0&2P)E,V2)7`*('Q!`YL"M:`=::O30F<\nM8M-L;^B^!ZDG,'G_-(/UP!A,4,07(@K%$C;HVZ?RT+>;H2-SS^./[6;O0]LQ\nM@R&4LJ*E$%^T/#RZT;T2&O:5HQX]Z%*&'J'K?^]1B(WG;I\\DSY>D&X).27.O\nM9;LUW#028',/9"&4(]W5\\&=$^/&[X`?;M1Q2LHTE"D)$!8WAW#*(2L;*KB$V\nM(R>]\\9O72%#1#;P.0&W&:KV3C(9XQ?71#%6A7)S`:8@U>:3DN?L=!HC`ET_^\nM#4\\O/HW%@@?Q0J`!DN$@XH5RLTPMJJ':AX?=MG:9FOW.-CP,)4.T:9.2@LL-\nM[+:E95K:),UX..I!G5()1GCF,W_%SFVW8XQL[.K7,@"%U*>DI,3$>.^SU>Y7\nMT@F:*BW;RFBV4U*7HJJ($USLJ%%#_68#U"LN=CCC,@,\\I"[%.P\\.7.)H28O4\nMIQMCG&*L(#@BF_&M(,_;:X:01WET_%$>F7D$15E96:9<+A.&8<]`567]RCJ3\nM$Y.($525Q"6`XKUG=66-T?$1N@#1O[&M5]<9J8P012$H)"Y%-8/FU94J0^4A\nM;&CQ^=[BO-)JMME2V9*%3Q=&K^L!H"A%2J9$$`28(,)(F4#"WKG`JZ+.THY'\nM0$S?`4=QSM..+8W.1._0$WO-$U>HUPQU/T@0%A#O($]RAV%]78G<,,984J^T\nM$D_J(6DWF1X+B*S!2AY":,8,KA5"`&*R)(U1Z@JDF[G]6D>IMCQ>NQP^WW6=\nMI[&>$&D;IX+S68(ZGR%0:RV&=R]I@8K*,,:;?\nM;KSS7%E.F)J>S$ABW\\KXU'%ZKL&;)TYQ^LP[5)L=)+`$!ERGA<8=1BO#?/R!\nMC_'@_?=@HP@1H5ZO,Q!:PL#T0NCZ22S@G*/=;F.L)3YWFH%#+^!""T$`UJ(F\nMP#N#KY3!!BB2A8CWI*FG46NP&@CJ/=YEQ0V4:>__)`>/GN*UHV^Q\\]9]W'_W\nM#@JBQ(TZM2M76'AGCN5WYOFW6HVE8T>Y>6D>[72(;<2]O_H4X>3$^R/XB-+-@(HA"U$58BP@A,&.(1TM2C&7.#-,#C\\*G#.8]+4I([\nM'N+;Q][BU1,7^,E''V'[Q#"MM766+RX0+RY12MKL'BZRHSC#7+/-X3/G67_C\nM%;;'=9+!,FFK32!LP.AU#>@Z0@1!,;?L)_CB5[!1M"E-@J4ES-@HQAA,GRN=\nM\\W2J5::FIWLHU(E3#I^Y?6V=%[_V31K;M_')S_X,Q@B%H3*J.95XOQ#R/J.T@3'44\\=J`D8S).DF\nM9;6I+!2R&.]1!I\\E\\7K54?*=_-X(1JSGY-GS%"9GV#TSP7(]IIUZSJQT2%49\nMB"!L*;[C"9H=5$J$6W;3F#_!GW]KCJ'Q*7[NP!!C9`8$N?;7W+SXU^]&1-&-D.AU-'>LH?!R/+NV3EJLV.0\nM=)"X3;.Z@ENKTA;'FD])T@Y5[QC=/DNU#1'*Q;_]:X*O5SCP^:>0B?$\\A+H+\nM_3XA9&Q(<#T4,D5LT?10R&7G2B3UD(#W"3[U^"2%9H==6^[F^"O'.;=W)],#\nM!M^L45])/ET)*VVT#W@N"]8'13\nM"`EV[]W71J'+EPDG)C!!T`NK;@C%RRM,34YL<"&$]ML7.')JCD-G+_#P0_<1\nMC6_!;-U-I6`I%RV#48!/.DQ6RLR?6V#QT&%F;MK)8__Z-1K-)L7AX=X9X+O:\nMR#J=#H$QU)*4ZK50J.Y8L"DJ[BH4[:\nMO''L%.??/8^=W$ZI,L)`:(F2!EQ9(*TNL;!PD>B.3[%BQUE8BBFB.`GR.Z8<\nM1J_'A01A:FJ*)$D`V+UM*]WCTZ8;H.G!WFW`U?=`Z"ALXD%YW,DD:3++;7MV\nMQ\nMCTX7"@4*A<*UFFZ(?.+!4>ZYZS:65ZK4Z@V<_P[Y?>I+;?^130!:ZTO/`^U")[Z6(",/E(8;+0]=L/[!CC/:W#E%8>HLS\nM7W^>RLQV9F[=!VR^/<^/QA\\]";?.4GUW@:F%DXR>>9VC__CWK"\\OY[NP9(0N\nMR'\\_;&6O)87Q2:9_[6F2;;O8.G<8>_P@KS_W#\\3M=G8>R%?>;`HA@3A5EFKI\nM#;NA_F"BO>]M`#I[-XW/_C8#S_P*L^>.C[5%O<6]8W'KIE[*Z5,W^Q?;#P4^_N\nM?9"#]>"UEPX=>R)=7'K[-U0_/(6_6_GG/4(UY8Z[!O390KER^XO1#H[/+_[)\nME\\XO/_5@@/M()G&_?&,-'AZU;YYJRV_-FU)U=SD\\NS-T_P7X[M'R(R^_NV>8\nMAIKPAX?-C\\ZZ]KDO_'?SQ.,%],G.AZW9#9#_!>AA7-`:7_3'`````$E%3D2N\n#0F""\n`\nend\n 6620 stamp_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```-K$E$051H@>V8:9`=U77'?[>[7[_7;W^S+]I7T&HA9,`L\nML6,$40H,9@F8@*4D.%!QQ66[C$F,DU`IBKAB*A5C2"`$%\\0XF!B,PV)6_>O*77>V\\^O!DM-A!KI,CYX%-UJKMO=]_[_Y]S\nM[[GG'OB-_'I%G)!>/KL5E#:PK'8,!V4LK"LT[&L:[&LCV(8<]`RB0I-4"!,A17WP1Q"1EN0\\CM$:C,"\nME[M6_AH)?.95T#J'97T.T_I3+*,=?P+*>V"B'R:'H#X*L22T+H*NE="R"`R[\nM3A0]3"1OQ1`'<'VX?]U))O"'+X/6:2SK#BSK>F*6B5N$R?V@?#!$LV<50A1"\nMZ(&2D.Z!CI5@.A"&SQ#)/T:(_=RSYB02N.Y%L&.@]29,\\U[B<1OI@CL"0H,I\nMI@AH0$$40>1#X$'@0[(#6D^!2$,4?IVQTLT4D;89T:@)6V1\nM2UEKDS%QYJ%&,P968DKCAZ]F',P$Q`Z_$[$$AF$"&@.]T#98G[0%;'KI)!#X\nMY&:6]3ATI,U5I\\U)IH36H"">S.*DT@C3!A$#+-`F:&/J:H&(D4AFR/!E#,B8!W3UZ9D;FNMZ2#&.N9L=H1"3C=!5R%%+@\nM!B%5/R14"A.%B44FYM":BA,92?K&-;+JXYB:SK3!T)AL8?T#%DI%__<$A.;=\nM_57JC;`1-^"Z,UKX[NL5WBZ&'!S71,KAE.XL"]MB]&1-VI(&;JC9-1[QQH&`\nM'4,NGAO2%H<%^1BE"8^&&WI86J'43/`?(X'O7<"NZ_Z32*K=Q;(7+9N;M3:=\nM66#K09^?#+@,3KC\\>,+GQ9A)W#8Q#4$H-;XO$5K1GA2<,<\\F;VOV%1L,EUQD\nM$/51!((`)-5'^5&6_>.U(?FM#NS0PTK.FU6]R8H>9H#E8BQAB+2`LL4\nMV";D$@:MC@%*T3_BLO-`C?VC#>HUST6JEY#`HQ><'`(JDO#3`WO>G9?>O*0G\nMN3'IQ)BHAT1:$+=-%K=8K.VU2<0,8J;`#32#)9^^D1H#18^1LL?8A$>C$8"4\nM/T.K5XXG(3AF`CQU,(%DHA92G/"H-4)4&(&4$J7^!2'&D3/?"(Z=`.#6?.BOO/BSC/E(2SIV8SX3\nM)XB:P$.IF_>1)HP4GB\\Y4/(9G?")(ME,*:2"2/P893\\""I[=,&,",_:=\\=O?\nM105RR;)%AN\nMFO/#%R+X(8JR%K#A+XX=ASE3`KKS8KJZD^,'AVLCIN#"=,)(^$&$[T4$042M\nMYK/G0)7RA#N5#T401IA1@T\\O>=*XX>R154[+O$NE7SS3$%'9LMFW<3W1@\\\\=\nM&X[C.P^L_6?8.VEF5[7?NFQ!X2N9E&WXD<(-%/W#=<8J_A1;W50%EY\\)=VRT\nMZ)RU`JU@?.`9BML?J#5*.Y[42M^)P:L"Y'E?.!D$`$Z[%_RHNWM6]HGYO=G3\nMI=8,C;D,%AMH?7AQ&@)Z6RT>_:OYK)P+@5]MMELIHJ!*:??CE/J?*@;UT8>`\nM>R3T&:#/_?P'#S_C*71(6JXDWV76)BLR%[>-"Z)(,3A<(PKE("#BNHL(+TBFC9(-EZ"JGV52F4>U;D%3<(%<6`/==OH/[IWX$'\nM?O3>PQ^W!]ZX!TZ[<90/7WS;A4/AZL="%4L-CS<.?Z`TRQ>U\\*$E!=8O>)E+\nMUM6(U-2P&C2@%2BMP4B`B..6=S(Q^+QT)_>_IB)UIU(\\@:`F))QWTPDB\\-)=\nMH#2F9;+$,KFRY!>N^K/GOW1J7VF6J-2\\PQ]JS9EB"O%6M/D]PW3O-A*9&9UM\\X5G7G)]N+125GYZ_9/\\O..3M3U]_R*\nM!)[]&B1L"".R4<1'39/K#$-\\W(S9!3N1PHX[F&*,K#5,$,XZPOH0BQGT'ZQ2\nM+AT@9P]@$:(T2-UT_Z$`I4!(0(*.0$;3T5>@I0#(`Y_)Y=BP\\0^XM?<3W*]?\nM^U\\(//W7X'D@([H]S>^:)M<*P1F&@6.8`M.0"%5!!V50&EM,(.41'A"@E&;;\nMKA)Y627E:&RK:6D1-:_3!`P#E`%"@1!,E92:5M!:DW!BM'^`EIAA"&+;)O+@:N%8)EA8!E&-\\>'9(+-8,ITH="7`*ICY:IS?N6-RA\nM^,X706OL,.1#EL4U:"X%Y@B!F+;*>VISMI!A&-/?C8QU-L_"@(PD(R,5:BV*\nM(!0(@U^8\\TU5ZK!*"68L2;YG$>T]O:3BHXB@#Z+*U$B\\"6AQ^A2!'_PEI#.D\nM#N[G/"&X3FO6`VV(7[;4>XJ`4E40+ZSA4^?W\\O:[@QPL"WR5P(@Y1")+J!SJ\nMKHF(A41'`(^BH^^U2)+M64U+SRJ<^`2BL059'6QZW;!`1PW0;TT/;;UZ/Y@F\nM"1GQ=<]G4Z6,<^3B^B`]TFI[AS1];SU#T4F1[UU!OM=BLBXI37J(8(#+E_\\'\nMEO+Q_,-6/@0\\!"T)V@)IX#G]R!Z:=QW3.1<>RJ'"?-OSMKQD$\nM[TSO\\9;G`1I;&&*-D\\&I^AJ_`'"KD&8F]Q)C[Z#T9$Y3$9=\nMY(7!+'.1\nM7X<2T"AMF]3>P+\\+6;E;1+R&@>R]])>7GW7U;4!R)8V*-]09F"0S[21;3V?9\nMZE:2SDMLV3;*COVP;C$LZ#X,WC2;ENP?AIH+\\=C1X*>E/0M:@B\\%L50OV=D;\nM2'6=2U`?9."E+^)7WL)V6DD6SD78&1J5O9YR!S83E;XI%,\\+`W_15>\\?/TR`\nMLQ?7WP;%">@N-,%J!<4*[!]KAGW3\nM;'K)-)KU7=-H>J6G!5*9%IRNCY&9009U$?CEV9A&A5X[<\nM\\EM;@FK_5R.O<7LDV>Y6D2LVO3_X0P3.6AA2JZB^R=*^-VJ5TES3SLRVG8+`\nM<##L`BESDJ[,)(-C\\-9`:FY4A()U.,FO^"C*]'T,96<;V\nM;F9T]Y,$?IE$;BF)_%)D&.AZ><<[_N3NVT.W=HO4>DO0(%AW`_S3TQ\\,'H[(\nM1C_2#E=>)MC;KSO:>CIN[)ZW^D\\ZYYS:&;-,W.HPQ;TO4RL/,#:I&1R#I`V]\nMK9",@S":'0G1[#$6BY%O[:*C=S&)9!*WTH]7V8-I&J3R?GV[IB@3?!\nM&B%"Z&1K3#K2D(99H5J`-`[3TL&(VJ6P'B70;`HE?'ZZ'\nM[LC32.^;0O,R$%UYV\\R`3\\M['BGW^O!J/_3$\\#:_ZF_)F`=?J$Z4"L)(+,JU\nMS;>T2%`I3Q`&(::82@$`T]1$H8_6X&2Z2>9F(_[Q7&[LY]*._\nMBR1[*B.HC7<>'WCX%4]D5ZP$KT&JO2?Y>QT]\\[[\nM6,C5:W8O+G2TW=3>,_]3F7Q;.O1=)LLC!-5=M.0BLJT]Q.R$]ANC?2JHW8?6\nM#XDX0\\J%+SUPXH`?,X%IN6(EN'7BK9WV187VKC]OZ9AU6N![HC&^C71:8MOQ\nM(4'T;92\\+Z;8'0GT+0^?>.#3,J-#_=D]<-Y9)KO[Y.Q<:^YS=CS^1S$Q*IRX\nM_KXAN%MKMB)0MW__1,/]93FNLLIER\\'WL%K;.3>7A:3#3Z0DN..I$P7O-_+_\n77_X'437:/$%6J)X`````245.1*Y"8(+W\n`\nend\n 6621 stamp_zoom_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```/O4E$051H@>V:>;!D57W'/^?>V[?[]MYO?_/>S#`[LS,P\nM!I!`&65QE%'<2D-`2$JB%2N6&B-QBUNLBDM908U"*5%11`(8`^((&`8%81!F\nMWV?>F_?>O+W?ZWZ]]UW./2=_].`,<41G0/PGOZI3I^_IT_?W_9S?V:OA_^U/\nM:^(E>@:TSF!9[\\.T_A[+Z,0KP=PQ*`U!91+J,Q")0_M2Z%D+;4O!L.M(>1VO>)D!_F8;:)W$LKZ$9;V+B&72S$-E#)0'AFB]604@`PA<4"$DYT'7\nM6C`="((MR/!O$6*,6S>\\C`#7/P%V!+2^$=.\\C6C4)FQ"N"[X'L0[X+V3"ZC^>;91<$XXU]H#:Z70>OK$,(&#;()I@VV\nM`W88AM<&;<%W/C4RP#PID=9/<^A\nM*VFN.W]!/"&T!@71>!HGD428-H@(8($V01LG<@M$A%@\\1;9O&2*:@C`D90OB\nM$9;K8;+]L>8K9IN;0C$2&47IR&7():/H!52\\@\nM4`H3A8E%*N+0GH@BC3@#!4U8]7!,37?28'(V;..*GUDH)?_X`$)S9*Q*O1$T\nMH@99G\\^8**@D@_0X![KN3H]?^##-5`ON3*50O2UHT7Y=@UX?&K\nMX2:CI2:_*'D\\$3&)VB:F(0A"C>>%"*WHC`LN/,9?I.9?9DDNCX4,8[D&K7[^8\nM#<$9`_"3S3AOO%\\.CE:^NZ\\C^H;U2W,Y+P0OA+DJ#$]K_!`\\J4\\DA>N'E&H!\nM^9)+K1&@`@EA&*+4'0A1(#S[A>#,`8!FS8.A\\A-[4^;=;[*I*+YL"0]"\nMW?HL-8%4N%[(>-%CIN0A9=C:4H0*I/@%RKX;%#R\\Z:P!SCIVQJM_B/+#Y:N6\nMYN[;L+QMC1)&J\\7#5LO[4E%KA@SG&\\S5`K12K54\\5#BB[EZWX*[OOWW!3Q^3\nM\\%,4N.%B:G:M"FX*ADS8IXO\\5R)[TMJ-8]CXU7F\nM2LT3^R$)@<24#=ZY_`'CW9=,KW/:SKDF]/(7&4+.63;';[@"^=U'SDS'BSL/\nM7/`M&*F8Z76=GUJU./?15,(V/*EH^HJAJ3JS9>\\$K6XE!6^Y"+YT@T5W_QJT\nM@L+P%O('OE-K%`\\]H)7^BC!X!@@O^\\#+`0"PX3;P96]O?_K^17WIC:'63,XV\nM&G[7]C]67>AWUC[V\\CVF+5*.-**16C4S5D$/ZFY2.F8$E?FBO6-GCK\nMQBE"=QH=E%%!F=#-HU6=>-M*$IWK$JCFQ=+-;Q)*1H!C[]I$_9VOA>_\\[/3N\nM7W0$=MP*Y[]GAC_;_"]730;K[PM4)#%5:)RLH#2KE[9QWO(<5RS>QC6OJ"%5\nM*S*AM@B5@=8*H16F9:-%E$;Q"*71K6&S,O:LDNHK2G$_@II0<-F'7B*`I[X&\nM2F-:)LLMD[<5O=S;_VGKAU8.%/M%N>:>K*@U'[YA`X1EKEYT%VOF>U3D//*-\nM?B;G8I2J$AGXV(9+>Z)$?V:63%P2RI#:[$%JA<-NX-8?"4-N"4,>%P+_\\IM/\nMOOZ,UH&??0&245"*J%)<8)K\\E6&:FZU8JK^W?:'HSH8S1B6K%9\nMN8U+0=_C>7SM=C=W;T$JA0P,@"]R4R;#IQK_F4WUOX';][.\\!>/`S\nMX+H02GI=S>M,D^N$X$+#P#%,@6F$"%5&^W.@-+8H$8:G1$"`4IH#QPJL7[*6\nM[<.3[!PYPNO?\\&KF=R3QO2+ETB"N/TT\\T:1[&2SJ#=FUSV/W[,6DK6F6M0VB\nMM2+F1.CLCM';[?<[,>]:O9V[T#1."W#?1T$KC"!@J6WS%N`=0K#*,+`,HW6<\nM-81"H!"TGDT#M`I!B>>=\\UPOI%AI,0CQ8@;()F%$T3_D\\$[OP@\nM:(T=!)QG65R+YAI@@1`((>!WIE9O(<44IC=(&.ENG84!)24].9/"S!CIK@Y6\nMS.^ET2B@E8O;G")F>,0MGYAPB6@?K22]*<&2>6T,CIU+;%Z=1Q_XCHTS,\nM"3P5`SO&TGD1I@L%NOLZD=(G5`$Z]#&41T1(;'QL7"Q5QS0L8FTK6!Y;S&Q=\nM42Q-H6N[T(!A6*!E`_3>YUQ;S]P.IDDLE'S1];BQ/(;"9-J-.$SB5H,XL*CFO#._"L@7_PN37>L,)AOYIFG-S$>7<3TS"P-UT-+\nMB1&&@$6H(EB9U:1[SB<5CQ!6GL#W?%RW@U@T0CJW&$F1L'KXF"&/WV[BW^$J\nM:](Q6G<`5KD"Y9TYM-=*Y#&(,>&IY@I*KI3D$F<%!R&+='/W8!HW7H>\nMF8:Y2FNJC0N/7/PH@J,@P#)@H9/#RIS'@1T'.#Y3H#MI@%0$9@^)>1<2S?7B\nM-G;@3F_%L01.Q^7,-2UJQ?VD#_H$@)3/SRLU&!AK"8U:8%L0,2%B\nMM)\\6V9_90;`KJ9A_-V!KJ;H/)@;N9'GT,5W=BMK^.0Z,6\nM`T,5)D9V/Y!4!S?3J'VH4>=0YG7HW%7/'W[FO;^$E='[J);G-F9[SGM5Q.G$\nMM'/D2U`^B!""6&HQV.=P:*#&_OTE]NX]]*NG=XS<=._3J_>_\nM__-']9=_>/KYPP2X9%F-9J.9,^WLE?',?$<8,;1PB"=RM#MSN,T:6W=#O@2]\nM.8A&6A')EV%LMC7MFZ>(-D4KMPR8UP:)5!NISC6T=\\TG8F>9&LDS-GB8>JV*\nM#!-X09;\\M.;@_EF.'"IP8/\\!?W#@Z,?3ZW$*D^2E=')_%8'UY54"D$%"8;:G:J6B\\6JKN*A=FG\nMHXZSHB,1SRX9V_OTMHG)XFH!,R\\$\\-A^"`JH]6O5X.#!R0K['A'\nM,F)G,>UV0K].NU/&L>'P>$N\\8T,LM2-T=/4Q?_%Z['@[I>E]%$9^\nMB=^<(Y%JIROCTQ4=H,,Z,&J;?'W.Z_QJI5*Z;79VYI;VO>U_(_<!4VW7)/08Z/8>-3HQ7'BP4AK+-YO>REBB/9O(\nM]N.Z(=52D:BIB%G0\\$!I<")@V1'L6)Q0NC0JTT@9$$OVXF07(8PH]?)XO58<\nM_+%7+WY0>N$W/9^I"_\\1_8TM)_V?-[R=8WMV3D&@-3JJ7>*8?8<9H5*;]:F%HJUN;O3GPY)=ER+'R\nM%.J&K_RV[U(CX(UI61_U.9@1X6O::K-MHF?!4JN]V[QS]X''_MRQPT%Y\\BK^\nM!<_$@V5H`"O:F)H>KVQIU*:&?==;DL%GE&9WM8Q\\S[_#@[M.[W,X``O!)U8S\\61!S+83\nM7)F1S:A8L'Q]>R0Z<;M;G\nM8E8DMB+3WF]'XVTM$'>.J*V(I;I0"ETIC@XTRODO!*[_D=#@<;^!^[[;X*'?\nM(?Q4V]4$VX6'RAQ:YHADMZR^THE%H[KWG`U?_?#-SUZUYMSC6T?&49S%F?BM\nM:Z%9)]K>;5^=Z^SY2%M7__F^YXI&83?)9(AM1R<%\\GNH\\)L1Q:`4Z(_==:9>\nM6O8?"P6ED/8+$_K;_8GHYLD5E["MI)]\\8,O6:S../?*CIG_FURH'\\M#E$*Y=\nMQ<'C0Z4MOE=1@=]8:8BZ9PI^$,KP`X&O[PQ""I^\\!Q[==W;B`?Z[#._M$LV)\nM0.Q-(U^5J!<[AT-KOM(Z\\KU"]:%7FNBSNA<:K<(3!S4K.JB4"MY6TZAOLR/<\nM;5E\\(Y",??Y^].,'SU[XJ98S!==U6_E=-3WIIG)79C*927^N^.V?S[G[%IHO\nMU7\\E_LCVZ:5IZMJ(7)HV7K,@=(__PY[&P3='T7_G_:F5O03VOX8VZ?-H&J1K\n,`````$E%3D2N0F""\n`\nend\n 6622 store_house_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```-@DE$051H@>V82Z]EQU6`OU55>^]SS[G/ONU^V$FZ;<=.\nMK$@.MB&1$"."I41"_``&,.4'\\".8(3&!(:.($1)B&JP,("C8V&#\\C-LFMKO;\nMW?>Z[SWWG'OVHUZ+P=[G<6\\[8AS))=59JU;5J:KU7KO@Z_9U^[K]5C>Y]>WO\nMH%E?,-:^;*U5$0$1!$$$0!C`!KZFB4DFO.;JOJ^V]N_0MM&=L41@R!V>S,S,_G?YEB?-_=NO4TIZ.VM3:,%[\nM)I,QH]&(:`5W='1,US9\\^*L[[!V<,AJ-UA??N.B:F^HB^96OK*_[?^\nM*_?<8*IM&AX=/R3&2--VN+.S4X+WA!CP74=959?4>'%3-C9=2_@RU=-&<\nM'C>7B_:^@7_%N.M:SDY/B#'BVQ87/_^$X`/7GK[-?BXQ30N:0;6'65>XJB++\nMN;Q<>VW[RXC4XP;(*>,Z#UE)*>%N\nM:V`>:EY]\\7OX'\\`KS!*Y`&16.3]]\\@^;C#RE%>ILU@PH'\nMB"J:$RF$7C+&8JQ!C$6J$46U17%XM1_;OF/[D$Q.V)R0G#!#MSEA'22M,1";FG9Z2C<]\nMQ<_/2%V+:,:(8`8'-2(8LW966=%[<[`"!NVEN(2B:YH\\/N>6X\\TYZ4W(>K!9\nM,5EPBF*OIUJ[@9F?HV5C46A`A\nM;4A^+?T-J>>$&22]DKZNH1NTH9K(,2)MPN3<,]!X3QTBN2Q9-"WQT1$:0B\\U\nM$:P!NY2R#/B*]A5S0\\2P&UJP:._(@R8,CT-!!\\]6%$@;,`Q[&.`\\*5.O=$L?\nM^&1R2$R)+\\\\#(U4%05.X=7:=J6\nMJG"XLD*5X8#EYH_WQ^?LXV/;X_8K:,OUU@[_&X1GK<6W+4)F=_^0DR^/V-W;\nMI;EWGQ`\\_;;S].V#;M[!Q16^.X+W^/^PX?LC`JJ[7U"C(-SF@M1:44S\nMZ^1D+JU9:NLB33:T2;C?VS!1%299^/)Y,4-55&8(([M'1\nM0]JN)83`>&N+C^_$_3+'"?O?X+8DJ,BH(M9WE0\nM%'W-LRR-AZ^@Z]=N\\(UGGNWY2(F<$BE%0DSD&$AAV3W)>Z+OH>:T_B#9L,7-\nM6FC-'%@$,="9Y5)%5#&FCTA1X:SK*%&.?,(]<7I,I\\K$&K8+B[.6;"T`14X4\nM.2&^X^7??9E7__@GW'WC=7S;$MN6V+7$IB6D2$PMH:O[FNA\\3G-Z0FB:OOA;\nM)L,E7-=T*QP!IU!F."_`CBU!+,%8O+%D$2I-D!*SD'`Y>NJ`%[__"J.J&JK+C"5C)&-(&!*:.N:=\\.35;4@MUDB?;363\nM4B"GA.9,RID8$^7.`5MW&^Q[=W&:,.=G=/4"?_R0SCHRPD@C&B/!1R1%0M/A\nM#G9W*$/DZF3,S8-])GM[V-V]WOK.9S"?$DX>8363VH;*";>_=8,__;._0),G\nMA984.W+HR+$EQQ:-'>?3AWSRZ3V>_N8UBJ)`4R"TY_CVG-"UQ!B)*1-3POM$\nM.9ZP-5*2P*BP'![LDK?WR=M[I.U]U#EU=AY@S$/L"+8(:(MLO*@RXC`\nM%_4"]\\5S+Z-`N[5%/#QD>_BP+XH"5_20G`EG7Y*;,PIGL`92Z-`<(/>7WKS\\\nMB@%;4!@E+$XH!,K*H6I)64DI$P9AB,!H-**J(DG@P#2;X5YXY0TU$WU#\nM3@')`2'U#)`PDK`D)+>H6*JJP'J+-7:(R$I*2DP9.Q2`H%35B+**=,#ADT]Q\nMY0]_TB`U+5H\nM5U,X@Q$(OD4&\\U%)"`F1A.1(:$])S0G*/J/1B.0+K.V3?LY*RID04^_8(JAF\nMRJJD+$NL@<(YW&0'39&4$BEGTI![T)Z9G!*JBDNIOVR,B1`BS@527E^^[3S=\nM\\7N4\\\\_1ML-9P:#$KL8:,$24!)*!@*^/D3#'&7G/0(J1F%+_4=]SV&?5E"(Q1G+.O0;"\nME-F]=WET=`+')X3%.<40#D-7(Z6#0?*JD79QA,0Y6U6!B!"SI2A+3.5P18$`\nM.6="S(/DE9PST=F5K5N!_:V.V[<^YK77W^4X?H_1Y("<4[\\VIN'R<\nM17&#L^G)(\\;^;5Y]L>;N]!G>_L\\WZ6;'N)MC(-/5,R176.FE[YM'2)BQ514X\nM:T"4J-)?K'*4I1LB6J8+$5#R$$:M%:QS?="P\\-'G!>;T:5ZX]C.:=]_EP?0/\nMV+GZ+*I*C(-9Q5[(+N6E!E+/78R$X+E]^)!WWI[SSU\\*K_Z^4[1$X:[!&:+QP4BOS-G$R]YPM(E82E56<\nM*`YAQ_51SQJXLJO^J7P5/DIHKNTV]_$6"'&,#`1-TPHY:'W)M2VGALW\nM/"__./*//U?>^%"9GT-AP!E!K&5G9X?)]AY%65)6(\\JJHC*1RD;&14)B3>E`\nMR$PF6^Q4.UREY'JTU!ZB;TE^@6\\7=(LIQCJ<*S#`M0/E]O<#;_]'QT]?$YYY\nM+O&=FY&<(<3$VNP3+@_>G5-O6S8F0O#\\R^OP_%7+CUX.W#^'MS*]TQI(JFB.\nM=/49]>D<0V14%4RV*G1<44PJ"FLHK9)3!-_T63LKN0ODUA/#4N.)'#QB',X-\nM)O29X#^%'_]>))TI[Y]F8HB(L&%"`P/>>T((=-[3M2T@-'7-LT]V?/2)X'Z`9CC_HVG4V5^WE!L[6"K)Y%B&V\\=P4;24#'N2(>33`B!IA$6J>#<\nM.\\Y:PZ(#)X%*.IPVV)1!+-856.DU\\.#4\\(N?.YXY$)@DFJ;!F/YMU/L.'P(A\nM>%Q=+VB;%CMDO:[KF,UF['^KX<]_DGCMK6W>O",L9N#,\\#0B,*X,-D_9HF7L\nMYHQ'!55AJ0I#51A4$U9Z;98F,*F$Z]L)52%FI?.!KNMHVX[%(J)B<46?8PYV\nME9=>4CYXR_`/KPE/W.QXJCQ#@*:NJ1<+8DRTS0)7+Q9T;3N\\!CC*LF(^F_&S\nM7R:F)XX?O"#<.X6W&$Q((*5$?3ZCL(IH0%*'AH)4%6A50"Z&CY1$UW5(V^)#\nM0!"R9E+,^)CP(='YB`\\!Q6"=H7#PT6>&^M>6/WI%26?*O]WIF)^=(0)-TU`O\nM%J@J=5WCFKHF!)^-,2K&)%<4+.8S7GI1N'LD?/)%X`??/>.)W:QFVC]`Q1CI\nMN@Y3%<2A+(@I$V/&V[3^S,R1KFW1-F)L_TJ=E54)[4/"AT@($<7@7(D%;EZ)\nMW'\\PY=__-?'M?7CNAN?^;(81Z+J6IJF-B,E=V^``C+'_E'/^WZYM-'C/8E%S\nMZYKEX!G#7__T$7<^^)`?MEVRTI='>4A`?==U%!L28$QY>!#.?6*,"9-U50OE\nMI(15V.[7J_:O$`+DGAL/#2!?:OH0)`4",,?]CC.7K]G7[\n:NOV6M_\\#@*=@>"+)(0D`````245.1*Y"8(+#\n`\nend\n 6623 taxes_add_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```/\\DE$051H@>V9>[!D1UW'/]U]^LQ[YN[4""\nMD!!"LED@V6P>N\\EFG_?N?<^=YWGTRS]F[F:#A+TA:_F/OZFNT]W3^#_[?_6Q*D&_-U="X`0'K_!$PH^@/<0`O@`/@2\\!\\^H/OK>$PA^U#ZI\nMI$E"9W6%3GN%[NJ*S]*T5:Z4\\F__]?4_$X#HE`BE0$`<@OB8"%Q!P`$$`N'D\nMUQ"`((;(&+5/O)\\3(XFTIEBND.<963)PWN8/+2PLW*POON&>:G,J;WWK;T\\O\nM`"E`@/1PYG1-;]_G`^X$'`>_$EUYT_N&[9/KCNO,5:33A;I=BL<.7KL\nM)97&^#7&Y%^DWO._XW-&G8>\\MIP>`D*.KATV-B%=NKV)<#U@6L'Y9AFV']6?T:ZXH86Z=$PIEZHE&KUW]_7Z%X]M+"\\7>=M>/\\\nM(X?WKFO^IP:@1BP(0J`CQ?XGYOC.W0<(*-IML!3XC>MWH&N:F=23VD!N/;D-\nM9">N)_694=T%,N-8:%NN/C_BW+,NH5ZK7_/44_L_N+*T\\.[+W_V/R8.?>OL+\nM!R"%&`$)*`E'CJR2IX&E%<\\MM\\^158J\\Z;IS:$C!DH.>":0FD!A/DGO2/)#D\nM?M@>]26Y'X[)/6E:9,?R"M6XR]:)$K%^Z76]9/N_!N=NN^%8X`_/_.DZP@\\`@A$$(B!$A&\nM183AF+$)OO;T$IO5,J\\Z:P-S2:^J1?%UG_O`']S6;'[A5--;7Q"O786`7,?\\\nMUWP@/:L)V\\;@_'&BLJ80"8K:XX(`Y%"4PC/%!T\\8]7O`X_%!$`H:UYQBHC[-\nMN6?76+!+')YKG77=^_\\J6EQNV=,$0`S?6(#)+36N?,LY^*D*86.%J4T5ZN6(\nMD@QL+"F22)(93V8$:3RJVT!J/)D9QD5FAK&2C?H2XYDN*[025"I5&DT5)G*^0.C`.3],B#P@1-:CW;:X&=YVY%R9'7\nME5A'GK`N&5U3H2$8XQRB5H>XA#<>8P.)5_1=ABJ,D4K/P`SH>0^R3B8\\&9Y!\nM-L#(*IF%S`7R)",E)J7`(/=450^MAJ(A1PIP>CPP6L@"HQLZ2W$P(,T6:12+\nM2!51LWTR";A\\&J4HPM4YC02\\2U,,R34&KT4(V\nM=,%IHI`<`?`G*!1K?1*%`MV^9Y`&E/?/4J&3*92T!MB\\2[YX#)7UB+PAC@L(\nM%;$RL&QN5IEHC!')`CH*Z+B,.&DK^C,#6*,0ST6AZ"0*U7A."CW1[7'@P#[.\nM'!^G-C7%H<,'65PX0&5>)QO_>!F*AM?C!.5C=^]^],7]1=6'N5J\nM$K[]@CS`R`/#H))2HI0BCA3%2*$BA5&2H,1)%-+#A6Q$(><\\R?(\\C7*!9K/*\nM_N./<,N#7V:E-\\>636>P9>,6+KSX'*PSM'H/\nMV$,K.\\ZU5U[+FZY\\$UNGMV*]I3/HT$[:M`=M%MH+\\JF9IR;NWW?_&_<\\O>,-N4]J\nM'58X4NO(G">V'A^&_=W,PL#@`RPL'>)[AV[C#5>_EIO>?1-""@[,':";=1%*\nML*VQC:27T.JUJ&^L<_3`8?JN3R\\,J(Y5N?2"2^%)+IN9F_D4`WZ;2]G/1F#W\nM.@#\\N$DI*99*K.:&6:_P1M#+!(,$%,,=5S)P]/L@3*#;[_$OMWR$+5,;^<@[\nM/T)F,Q:[B\\.4V_2(1^ZYA[?^\\6]AR#`BPXB4GF_3\\:M4FQ5T\nMJE]N(O-A6KR-:3KK\\L"S+5"MU>AVNXQ7*VQ0PY][7<:'$D(J?)`$'V%L$63,\nM%^_X3Y+EQ_FSW_L\\QAOF5^?IVSX#.V!@^Y15B1`:I%G*ZFH;C\\.JC+YO<[A[\nMD*.MHZSVV@R2#%D"$<2U081?9YS/\\@O/$T`(4"J5*)5*ZQJ_TEGA[A_\\!]==\nM_6:F)Z:979FE;_OT;9_4)Z0N07E!(."LPUI+D)ZE?);][<=I92V\\MI0J&J%`\nM*H$0Z!S[#C\\;_IT-+#YO"CT?>^#1!YA=G.6J2Z[B>.LXG;1#W_5)_(`\\I.0^\nMI1`B((QR+4';+',XW4A;THJ;AP^A*F*E,G\\AB`>_?L4:5X"LXY\\ES2YKF=/O):/(!YWR!/+RR.4+_?@Y`5Q_Y_5\\^>8O\\Z>[?JE4](T++IJX&4;L=8LNWF>6KB5^60/2]TG*5C%CV9_R!7;KZ0]:#-1F&#VZ5EF\nMCLX,)Q7"<'\\A!-99:K4:5UUU%8_OWD\\T$H<0`LX[LB1CRT6;J%>J+/=6B/.(\nM3-NFWJ0*SPG@*U_]"K(AZP\\]O.<3TU.;WN!#;7RL?`F;&[_"6.E%1"HFZ&5F\nM_2X&Y@DZV4%6YF:9WS]'O=F@-E[#2D=F,CI)AVJ]RO']Q_GL9SY+FJ9X[X'A\nM!LD[1YJE%`H%QL;&T$H3`&LM69I"@/=_[+T4"AJM%5&DB)04*A+/K4)9G@$4\nM%Y<6=R9],W'-R_Z&#;7+6>JL>:SS"!31N,`^DA,IA5(2I63/M8)95Q`[Y\\EL1!""3G*06^_[(VIU\nMR>9-9S(Y.8FO!\\K-"L4SBH128)?9Q6)KD5ZQSWQKGLZ@PT*ZP!,KCR.TQ\\J4\nM7EBA)U8X>^/97'OI6RGJ$G?<\\0W&7Q:S;^I.TBRGVTGHC,KRX39]VT,I120C\nMA!1'S9TN71<`#[0&%A$;6HDE-X:YA0ZM5H=ZK<[DQ"3%2I'YWAP+?I&.[!#D\nM4!K5LF+?L7W8HJ4GNB1TR6076714:C%3C0E&])X1`;C-:O199;NBG*9TL\nMH9,F)&:`#X%25*9/'G#A!UMOFGAN"DDA"81<2O%$K`M;VZDON:ZADP6JE1H!\nM011II)2LMENH?H16,9O")L;2!H,LP10,;=/F]@=OAP90"91K,?5&B494QKOA\nMN2FLR:/#&$>GDV"L)4T->68QQF&L0Q,3ZQJS9G$VY-QKENQS`]!:DW6S55U7\nM;ZN6FY?94+UFJ6>N[*3^O$JU5I)"$JD(%44G-#Q2BBB*4"I"1()JL\\K,AAEV\nM?W2YQ1A+"."\\P^0YQCK:R0#GAM\\G24Z:YG@#VVKG\\N3Q\nM`V19]M6E![O[FB^I_I0@_D0&0(I=V?(/MWYSKL>=<:0G$M.^M%34K]>Z]CH=\nMZ1U1%,61&D[^&3`*I13-2I/MK]_.P2<.LMQ;)IB`,98\\'Y8LDV39\\"^`/#[PO^6)<\\3+JY1IQ\nM'+&8S#$_F*&H2EPT=3FOWW8MC\\[MY8N[;^XL+BU]H/^4^:1N2#/WZ?8+`W"R\nMO>O[[\\0Y)^,XWA''\\0T@;FBU5K8=GYL36D>4RJ5C29+>=/N7;N];;?]<5N6V\nM:J-$M5*F5-3HHJ)8B"D7BDQ4)]DQ<1Z7;7X%DZ5I;G_BZ]SVV->.=MK=&_-C\nM_DNJ)NSQOU\\]\\>S3`F#-;GSR1K(L$]5J98>.]#OF%Q9NF%N<>]Q:^_ZCJX<>\nMN/^&!P-OY!*JO$=5U36-1KTQO6&231LV,EF?H%D=IUEN$D+@R.HA'CW^2&=^\nM=>X.U_*L/2Y[K/>N9I!;!FGVQ_DFJEHN87YL\\[?/3P4KU>GW_D\nML;U\\_2U?AU\\&4HJ,<3EEKHF*ZO)BL7!FL1`78QV!")GUYIAU=C>&V^C+7;),\nMLO3QWD]\\UO\\*@'79A<`"@DLI4V)<%451*8$,,L6(E?1^TQ=3(H0'?OKAUG\\#\n4>6TU;$`D4RP`````245.1*Y"8()<\n`\nend\n 6624 taxes_clock_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```0I$E$051H@>V8>:Q=1WW'/S-SYIQ[[OKV9SM^MA/;+X[C\nM."1AR0:$52'04D@0$*,ND(JEA:(B5;11H46B*JTHJBH*$FIH&T0A;1$"`DF(\nML[!DL[,XMN,E7N+EV6^_[]WEG'N6F>D?]]HX@/$CN.H__4E'9V;NW'/F>W[?\nMW_:\\(_W3P-"6&R_Q076@;7@'%@'UCFL!4NOW?O=XG"VUS_C\nMZL0QC85Y&HOS-!?F;=+IU(NE,'WP[V]]20"\\3&DO<6\nMG.66W#B,=>3&D=ONU>W3;;]H7).;`EE>)21FI1ZJ5:K5/]X7%"Z:G3[YX=7C\nMEQX]LFM)ZS\\W`-5C@1,"[2GV[YWDH8S'G=I1[K5U])M5*]Z<"!_7\\]/SO]D5=\\Y%_B;?_\\\nM@=\\<@!2B!\\2A)!P]ND#:<>$LK7ON?SICO;SGN^/C*7ZTS\nMY_:`[#[`T8T':PO<_TB;[4=3IHLE5EXQ@BYI?$\\0^A+;FR>ZL8/`(H1`"(D0\nM(.E=PG7G]`WQG4.SK%!S7+^ZG\\FX5=:B\\*:O?OICWQ\\8^+=S+6]I07SJ+@2D\nMVN>!*4=G]0"LZ8-+!_&*FL`3%+3%.`'(KBBYGUW665QOW`(6BW4"%VC,P`A#\nMU66LOZC"=#[+DS)%DW+I*L&RM);RS.+,N*"JT$I5*9VH#R\nMXC@26OOG6MX2`$@`AT)@'5P]7N:NU<$I?B"P!*1@'*LDY-J12]>]]Y2GJT"B\nMJUI&=MO&D5MY6IT<$H/`4Y)"H4#@AXASIMDE!K$`G'!(`?7%!8ZWVJ!T3TX=\nM41R3ICDR*':5)DF)HQB"$FE/@9)6`Z-+I`8R`UG<(G6*S&DZN65MQ?'*]:M0\nMLN=U)9:P3UB2C)Y2H2Z8S!A$I0I^B,TL6>Z(K:)M$E301T=:HBRB92W(*HFP\nM)%BB)"*399(<$N-(XX0./AT"HM125BVTZHJ&["G`^?%`+Y$Y>@\\T.84HHI/,\nM4"L4D,JCDK=)2"DKC16.CDMHF0Z5O@Z9Z2:Z>9<35E.,ZU*I6&5`QEK+Q2GJ4KO@_WF'I!=N5'8;B(SAC3+$%G*:)#A*4'+-R3.42YWM]8=\nM7]#R!-4^B;$"8R7U4%.N^:[%%*B1]GSX8%36PG7\nM4R,A)5)*M)*$GD)KA=,*[2RUP.M2"(.7>_05?9SK[D9EK*F5?1`28QU!IO'\\\nM`*4#TMQ@.BG:$UT5D@+GSE<0G^+BJ>V!$.@S*62@V79$L47E.8FQIRE$CT)I\nM9HGJ$;;@DQA!DD/::I.XC$3X1(GANI&<#1?)TT$LY'D"H$ZK4%?>C#%D9U!(\nM:T$4.!(!E:H@,X+XEU"H4?2I#818)TB-H[%0P/,#I"Z09):BC5#J9Q3J?K-S\nM(UCR7LB="N:?IY#G83T%)B?P)`5/$N#]`H6(%"5?H:1$.DO0<00%@0X$N=.8\nM1!-HU4MD71><)PK)'@![FD*^UF=0R-%L6Z*.0UG[(A4ZDT)Q/2)/FZ0SQU%)\nM"V4SM-8@)/.QX8+!"@/5*E+X"'D>`9RB$&>CD'<&A2J??0Y57L:(<\\O=[//7U&=.[@`6W_.^/^`;\nM7_OJ2_4`/0]T@TI*B5(*WU,4/(7R%)F2."7.H)#N)K(>A8RQQ'-35`L^RT8&\nM&1H<8'2XGR#0>%J3=!)&1X;)L@Q7/TI5J:M^\nM[1TSW_S:O_*#[WWK)0*0+TXLD75,=`PNS6FV#'''H$Q&DEGB*"9J1HBZWSM&\nM&G;N/,2(SEFW[B+*I2(FS]BS9Q_[]A_BY'R#.#.`0`E'M:#%\\N'^ZMC8RNMJ\nMM>K5M;[^=YV8F/C+K??=\\Y,/??3/W)?_Z>^6#N#4B0SKD(#KE4T*`M:&'EIK\nM6GAT?$NEUMU*)!U'5,D9&*S@7+<`('8.,K9R)DV#K8D8FB,\nM_E474RX7R;,,`TRV6QR9F6#'H6U<-%)5&RX>?VT8%K]^^V?^]N.?_N3'_OL/\nM_^@3?.6+GP>6D.P>/=@&"*USWUG1Y[\\QS.9(DH3%=AM=KN)IGW:K19)F5*I]\nM6&?I=!(6&TTJ?8,8:Y'.$LW-@A!LW?HP]SUU@'QL,V^X[DI>OVF,YM0Q&HU%\nM,B=I-EO4+KR4P[--]KTPP=SN[?2W)[E\\TP;"L##16%R\\;I)04PI"%-..$5=A,T$H$40R*[HDKC@SM-I!V*Q$KO815RF/KUH>X\nM^ZG##+[\\37SPQBO9L*S"0IPSE1GJBTV$]D%)"EJR?J3"2'4M^T>&./S4XSSU\nM[&XV;QR_P-/^W^_:M>/PRK$U^Y9$H1>;HURIT&PV&2R7Z%?=OUM=Q+H0(176\nM29SUR/("3BB:[9BXV6'GCIWMY'ADL?AV7:W5H1$^CYYFA'4\nM!FFG.:FQ6&<9JRK\\JZ_CP",I>_W_U0_FL!<`["\nM,"0,PR7.=^P_=(S)>IT'?KJ-:/E&MKQZ,P7E.'#X*'TCRS$.2H.C%`9&F(M2\nM)AL=XMD6"(%I+V";\\YQ\\X2!#ZRYANC[-S/0,U5KUYC5KQ^_0VM\\FS[V,EVY1\nMG#`[O\\C>O?LYV(1-EVUBU4`1XX4('5"?G\\?0K>Z=:'0X--5@2^PD1-\nMGOOQ/3079AD8'6%T\\U7,+S3)LWQ8"'73JM5K?_T8.&69S3C9.,&NZ5THJ=B\\\nM[$I&2B.G]S$`C5:;1K/%_@.',?TKV3@V1&H,!LG^YW;RY/W?X<8MMQ$L7\\MT\nM.R7P%8&OD3:G>6@7];T[N.2:&QB]Y&48*_!6KZ&YYRG2-,5:>^W##]Y7/"<`\nM3_H(A,ML1F93#M>/\\\\SD,VP[L8W#"\\=QHLJ:P9=3=Q%CM922UT&Y:4;""@N-\nMB&:CR=1\\@]+8!OJ*'G&:XX3DPDU7,C=]DL>^^TVJZU]&W\\974*J421>FF-C^\nM,,52D6$8ON@05A%S]UG>Q;]?3//1?_TYRW[<96;Z"\nM+#=<\\?HW<\\DU-Q`$`=8YHF;$]///4EVUGLK``%EK#F==I5`H5=39`.RO[SDA/LA1Z)[.73\\)QQXZAE<\nM:O$*'LOT&&K>9^?^PZCEZQB4$:V9"UCED]EN@3?*#$/+5_#>/_\\L\\L$[&;]TG-!7^`J4E%@'\nM>=2D$/B4RR7FG27P?=(LC1<6YN,E!;$QEB3W<$+0B`]S]R-_2J4J6;%\\)8*H^Q1N3MW&]6$DY4$PV%TB*%](WM()6:D@[.:F#\nM8N#A25BQ=CV#XBT4I_;B77PIH2=12F*M10T-4'C5M;0[.20Q6FN23CK=B:/Y\nM)0&P0#W*$7Y&/H-JIB9TDC3H=?QA/&71<1_C#\nM".%WRS6`J/1C!U?@3>Q#C8Z212WP?`J>Q&2&N2-'Z"L6V'/DA32*H_O>\\-8M\nM[JP`M-8DS61!5]7[R\\6!E^>N?--L*WM-HV,WE,J54`J)ISR4Y^$I#\\_S\\)3"\nM\\SR4\\A">H#18(O`$Q=U%QOI+'#F\\$P9NP+:;2!^U1U'[(Y!EG52'SA($=D#]AXXV_\nM]_C!9E*Z-[?AM^)T_X\\]^?A,&.I*&!;[PC!482$D+!0HA"%A(20,"Q0+(4.5\nM04;&!LFGH$2%A1-'R"R4EJ\\BK/5W`2N!)V%J]Y.0IU16K84#3R.D8FC-.)4P\nMY/CD'$>>V3(L=MKM?YM\\[.32\\O$3]RV#KJUIIGKOWK]/0CO\nM7JP>];7_VL#W;]':OT%K;TBI%WNAX!=HFQ;QR@6"F2'6K1GC\\/&]M#U!:>,5\nM!*6`P%,(8\\CCB,;,%-I:!C9?2VGQ)&2&`T>G.+%G'Q>-]O/XX]OM8BXEB0#!Q49K1;8]^;1YX,&?W+FP4/]$$`3S3S]V'["TZMTY[<./?@ACC/1]\nM?]SW_2T@MM3K\\VM.3DX*K3W",#S>23N?&WETPX2?%3_CG-V4)"E&2/S:(,7!\nM(4JU&H7`1TN!S%,"FU/1DC2)V;;]Z?:NW7N_W&PN?E;KH/[LMOM/O_N\\`#AE\nMGWK^4R1)(LKETKCV]&U3T]-;)FH[L??TOZ`7=RY[&+E?(^`>*=\nMP*!2"M_7!$%`$/CXOH^G)&F21#+WKG\nM>05PRKZX^$7*I9*:FI[:<.38D=EJM3JU\\[E=?._F[_$[[WX_2=+QB\\7*%2!^\nMRSEWC7.L$H*R=0Z3YUF2I#-1%#T;1?&]21)O[1\\$T=1UFHUYIJ-^KP?%,R^9Q_]E<_Y'T*`\n2VI(Q1&%\\`````$E%3D2N0F""\n`\nend\n 6625 taxes_ok_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```/=$E$051H@>V8>Y"=19G&?]W]?=^YGS/WD,DDDTPN!G(C\nM&..%2Z!$7''9**;<$K#61:U5RK*VW%HUXK)L7*E=4-%R`=U%`9?U6KJUB+(*\nMHE@L+@FK(28D3$)"DDDR<^9R9LXY<\\YWZ^[]XSLS"2K.`+'VGWVKNKJ_/CT]\nM[]/]O$^_W?#_]G]K8JX!7WBD#`AA,.T&FS(6C`%KP5@PUF(,&%KMUN\\&BS6M\nM[S.*WVQ2G9R@.C5!;7+"!+Y?R>8RX4]ON^9E`7#F1"@%`CQKQ6>%Y6(L&L!B\nML6_ZFZ\\]N?YCIZP\\I/;\nMSRX`*4"`--!W3L%=WEMRT`:TL6AKT0;,&6UMSNQ+OL]L:^,2Q2Y^=YI:+<>Q\nMXT/GYDJ=5T91^*\\C)X[=C:5'A@KG_I@\nM_ZHUQX[NG9?_"!87[VV'-8%%-3$)/B7=>LPBVXG/`-?FP)\nM8T,86X+9^HR^J-76EB#2E*=B+EOCL++_`HJ%XI6'#@W^W<18^8;7W/"5YJX[\nMW_O*`4@A6D`L2L*Q8Y.$OF5LPO#MAX8)C25=&3SWO&WUYO+O6*U_>.V0Y2_[?K_.\nMS+T#,IG`DL2#,6D>>6*:IXZ%E+,Y^C;VX.90\\22F-4XDL8/`((1`"(D0\nM(&D589,Q;5T\\<'B,7C7.1?WM##?K>5>DWW3/WW[XAQT=]\\WEWOR">*86`D+7\nMX]$1B]_?`4O;8$TG3M8EY0C2KD%;`A;F*&8=\nM,M*R(*-H.I(@,@21P/=:[=CB1X8@2N(BB))8"5I]S-VJ/-_N3\\WP`X$A10C:LD1"[%IB:9.ZI3R)`HE$\nMM;1,VMH2&SFK3A:)1N`H23J=)N5E$',>L_,,8@%889$"*E.3#-6G0;DM.;4T\nMFDW",$:FLHG2!"'-1A-2.<*6`@7U*MK-$6J(-$3-.J%51-;%CPW+"Y;-*Y>@\nM9&O7E9A'GC`O&9U1H01,I#6B4`0O@XD,46QI&L6T#E"I-GQI:$0-ZL:`+!((\nM0X"A$32(9)X@AD!;PF:`CX=/BD9HR*LZKDI$0[84X.SL0.L@L[0FU#'I1@,_\nM&*643B.50R&>)B`DKUR,L/@VH*Y]"FT^D4X.N@D;DRF&:)M0J9:+02EP#%&L\nM21EPE&@!2/[G//R?WT&64$@@!"@A*2B%-4TR2N)Z#G@*%X=2VL582UIHG-BE\nM+9=":T.D+31=\\CD/@T`;\\"(7Y::0KD<4&W0SPE4R`2!/R_`K!C`S42*C`B$$\nMCN,02H?A6&*,H#8-#=^@M":(-+(6F*A["22&<%&%LR!B+(Q,**=&B[-G8@9E4\nMPK;42$B)E!)723*.PG45UE6XUE!*.0F%T#BQ0UO6P]HD&Y5-EU+>`R'1QI**\nM7!POA7)3A+%&^R&N(Q(5D@)KSU80SW!Q)CT0`O=,"FFH35L:38.*8P)M9BE$\nMBT)A9&A4&IBT1Z`%00QA?9K`1@3"HQ%H+NR)63T@9X-8R+,$0,VJ4")O6FNB\nM,RCDNH)&RA((*!0%D18T?P>%JEF/4D<&8P6AME0GTSA>"NFF"2)#UC10ZC2%\nMDC6;&\\&\\YX%4C$]'+.HLT%$J(H5W6D;G`4#.-4#)F7*:0GX0)!0B8HFC\nM69:RK,C`^@*<7Q2('DLH6*R_L<5CIUO..[&<@9SNWK(B\\-\\629\nMM8M*_-D5KR:JG.3?OO7OC)9'<91$`IW*L/?'>T5]I-[N3_@K_'%_8')H,F>M\nMY1N?_\\9\\=X#6#B0K(J5$*87G*-*.0CF*2$FL$F=0R$T.LA:%M#8TQTH9P_3MZ:;$Z.3_,6EG4M]V?WG.T=V\nM7GFT+VQ5S_\nMANL9GQ[GL<''>&SP,?8J!H-$$1>)HLZ&9G@;"UNTKTIQL6')*SN93M&HA$G&02I%*I5BW\nM-,NWGOHGLEZ.6,?<^;,[V3.T!QUKUBY>R_8W;Q^]8M45GW-\\Y\\MMW6V5EPC`\nMDB\\4J-5J=.9SM*ODSXV;Q=@,0BJ,E5CC$,5I#`J+16N'1D%1;IZ61C%36B",\nM-KQ^\\R:F"R=Y^M>[6=R^F/O^^SZ.CQ\\'X/*UEW/SE3?O.W_!^1_=\\]B>_^Q9\nMUF/:%[7/K4(O<-]")I,AD\\F\\)-C&&$JY-*>TF7UY;'D_.V\\VFV'+FU_+_8?O\nMP3J6APX^Q$AC!)F2O'W=V[GY+3<_OBR_[$.Y4N[IS((,*]:O`.9Q#IPM$ZV\\\nMO*4DL[%@C"&*(S:N7\\O)W#&>G7R6_5/[F=`3.%F';:_9QJ?_^-./#N0'KL^U\nMYY[^YOW?9./K-L[.^Y)C8,8B$W&J>I*]Y;THJ5A_S@7TY'IF\\YC?`D!RJDLA\nMDEJ>+KELCDT7K^,KQ[_(A)D@($!E%)S<\nMM?,%\\\\X)P)$>`F$C$Q&9D".5(78/[V;7R5T3K3G;C2!9*5MW;F1=O.OF(;8UBQK)^ISC)/']Z#]C3"%6SLW,B-E]RX\nMK]_K_W"F(W/PQNTW_I;SOQ?`-0]?P]>_^G4^L?./,FE36KNAZY+N2G"<;UOIS.W%,]U&="8CU%ZSB1U/?)?9BE%#TI'OXV.L_-GIN[MR/YCORO[KKSKNXY1]N\nM^9U^JA<#,%@:Q'JV6*W6[HJ);FX*EJ%6BP6%/Z&_?2OMV?7@&B;%KSEI'^9H\nMXT<<'GJ<0[__EO%>M)-^9I69K!,V09JU)(9-A\nMY9:%?'WX?B(5X:9<;EA[@[ZZ[^I;[OOD??>Z"URVOFWKBS/DQ7X(P@`@/3HV\nMNKDY'75=N>YSM!=>PUAUDJ.57Q`X3V.R)TCG-1DG37VD@FQ*NCM[R'?GZ5C0\nM065PDC<.O)&^["(.-@\\RD2FS;NEZNER/9R:?I3'HLS)X%4>]YZBJ*C(KN;3G\nM4K8MO>Y_FE/J[JW;WV7[^[I?U/G?"^!,T]H0Q`Y6"*K-(_S@B8]0*$IZ%_;1\nMW=V-*5JR'3G2B]+8C.7)\\$FFIJK\\_?I/$38BGI\\XRLK.553""D^./,FFWDWT\nM9GO8*9_@XO,V\\\\WI!Y%929?7R7N7?Y#Q2OO(]YX>F]S0EYW3MWD!,$"E$2.\\\nMB$HS)HPBALM5*I4JQ4*1[JYNTKDT(_5ARF:4JJCB*(<#JY^E)]7#GLH>=E5V\nM<<(_05N^C;%38VQ=N)5EF678MIB#)P[BYERVGO,VNN/U')STV;`HBRM?P8U,\nM"HG%AE**`YZ;6C+EFXRN150#2SY7P")P'!O>S>/1H]2=^LL;UO.Z\\(+\nMV?G,`;J6K@9L0Z\\@2]8>D.U+LN'`'M^^_G4/1(:;D%`_7'N:J\nM15>Q;W0?*J=X:^=;^=5]^^SQFGSDJE7K'PS"T,SG664^8]A\\]R&,07A.OJOA\nM__S5-O[L%:ZKW^0Z[BK'<3Q'):F?%P`JJ]2J]]+*\\L(([CM_!\nM@>@`Z5R:=>WK>)[GZ4QU\\C&]??SS'[G[.S]_XO%;BL7"\\>?V_W(^KLT/P)EV\nMT3T7@;`"(Q9XKK[U'6=+J5>N`NY3);V]G:JM1H3DQ,L32VU%RZ[\nM,+ZK545Q3N(;W!._YFZZNKD]???6[[/>^]XUY^_.2`WYZ\nM'5-3TPA)RG7<#9[G_:GG>>]PE+,DUK&04E'(%]!QS%1UBMIT/:S6I_[C(^O^\nMZL?9WNSV6Z=N'3CAG*`GU\\..]([G5Y=7O[GA-@9[%_6^)#]>=BYT[V7WSS2#\nM#_[B`SNUUD]YGO^^]9#6SZYY27[\\;)WX'?930=O(@@"D<_G\nM5KF.^[Z163UT>-'QXK%XLBOG]G+@^]X\nM$(#!_8/8:9OM>E77G5+*@5,'3UT5B6AJPX8-?PAW_C`V?&*8(X>.#!P]V8::Q=5WF&GS7LO<\\^XYWMZSB^GN/$(1,A\nMH29``@TBH551B4J;H`K:/R&BI2H21>V/BE84%41II4(KT22MJJ8*2$4*0PH-\nMA(800F,;VW$2Q_-P[3O?<\\^XQ[56?YSCFYN"\\;5CB3_]CK;6L-=9>[WK>]?[\nM?7O#_]LOU\\3%!OS=4[.`$!8[:'&!=6`M.`?6@74.:\\'2K_?O6QS.]MLKKCB*\nM:"XMTFPLTEI:M$DB?8\\"L42:9J01%UC\\W3?[.SL(][-#SQ3'AI+Z]_[XI4%(`4(\nMD!;6KZUX6];5-,:"L0[C',:"75$W=F5?K[VR;JQ'EGO$HP5:K1*GSTQ>6ZH-\nMWYMEZ;_.G#W]5VOO^=34])GC_JM>G57]?OD9L"65XE)&*]-U*K5*L?>S4H;)Z?G?KHQ/:=IT\\=\nM7-7Z+PY`]5G@A,#3BL.'IOG!?Q_#H6@T("?@=^[?CE?Q.!M;XMR1YI8T=R3+\nMY8J^K%\\WCB0SS#9R[MJIV39Q"]5*]=ZC1P]_>G%^]J&W//1P],*7?_^-`Y!"\nM]($XE(33IY=(8\\?\\HN6K3TZ3E`K\\QGU;J4G!O(%VYH@S1Y19HM02IXXHM;UV\nMOR]*;6],:HGC`ML7%BG[+3:,A/C>=?>UHRU?<\\9\\^X%)QQ^M_\\4Z6M[A"?+X6`U//Y_HPC\nMGAB"C0.P^VRSN+Z_1:P6*P3N,###(TQ4EW+MLT5\nM9O-Y3DW7)^[[L[_6F$I0:E4IC:D=!1UA>?Y\nM%UO>*@!(`(="8!V\\=7N9KTX$Y_F!P!*0@G%LD)![CERZ7ME7GIX"B9YJ&=FK\nM&T=NY;(Z.20&@5:20J%`X(>(BX;951YB`3CAD`+JC24FVQU07E].'=TH(DUS\nM9%#L*4V2$G4C"$JD?05*VDV,5R(UD!G(HC:I4V3.(\\XM6RJ.V[9M0,F^UY58\nM19ZP*AD]KT(],)DQB$H5_!";6;+<$5E%QR2H8(!86KI9E[:U(*LDPI)@Z29=\nM,EDFR2$QCC1*B/&)">BFEK)JXZF>:,B^`EP9#_0#F:,_HC4JN4@U*@+5EN""QH)?H`\nM>L]:AW[@K865`)[">0K/66J![E$(@\\XU`T4?YWK9J(P\\:F4?A,181Y!Y:#]`>0%I;C!Q\nMBJ=%3X6DP+DK=8C/<_%\\>B`$WDH*&6AU'-W(HO*I8NK%#6?LZ%5I)H:C>)4];I'.3J*2#MBF>YY,[\nMQV(W9\\.:089K5:0(^C+J$*M`L&H*<2$*Z144JG!!"AUJM3EZ]%6N&AZBMG84\nM80U:":)NQ$*]3OWL<;[^1!>U_F9T>1RABV"S-P[@=102/0HII?"UHJ`52BLR\nM)7%*K*"0UPMD?0H98XD6IAFNAFR>6,?"_"('#AUEKMG%.+#6($W&[/PBM>D%\nMBF,3Y879Z5`ZU$QP]=I(?OWJ6J[9NXTTWK05G65QJ,#,SP\\+9,[1GIJDNSNQ*\nMXO@31XX<_LROON^#Z5/?>OSR`9Q_(\\,Z).#ZGTT*`K:$&L_S:*.)?4NEUDLE\nMDMC1K>0,#5=PSI'GEB/J=HX>/.'QP8'/[:+;??Q=Z?//WS-_AB`$3_)_MI1"^?RS'6\nM$N>&*#?$N2$QMIQFS'?2>FD.07/X]F73G'O>]_%CJM'R+*4F<4&\nMY^86,&F,S!-D'C$P,,"&F]XZ'12+>;5:_8/]^W\\Z$):JE^^!GT$L)84P9"G-\nM.&<5-A.T$T$W`D7OC2OJ&CH=(+7$F67<-RP=.D8X,LYU$VMI="-R:ZDW.RAL\nM[YL-AMQD>,)1'1R<2O7L%0+@*%%P1)V,?Y]98&S-)C)C,,9BC,$YBQ:]>7-C<%F"QE+0\nMVH(]-C@X]*YB6-Q2"(M7!H!S$(8A81A>$NSCI\\X1)RD:B-*QFL0R"E0@A!K:#"T>'AM87`,YUN]VRG&U]Y`)G-F&J>X^#L0914W+#V\nM%L9*8\\MYS$JKEHMLFUC'ON<.<6JNP9I:V(O0QO52!J60VD-Z`<5`4PLPY7+U\nMFJDSI\\^=/'GZE5JUX$32Y,X467C\\*W4\nM79>K:RDE':/<+*-AF>'",)[TJ)2*;-JPGHT'7N4G>UYDUVTW$4_@2Z_\\[=&7GCN]XX9?N>#Z+IALW/]?]_/8(X]Q\nM]_O?'19L[?H;1][QE7IRYL;9:(K<51@MW\\#Z@5L9+FW$]SP2,4,]?X69Z`#S\nMS2,49<"6P2WL&-C!UNI6GOG67K(V['OE%-'@583#8TAKD":&-,)S&15?,%@;\nM)F\\L3N9[]]Z0""CP5D>58='AK^^[5CX_=L&+MY>*!X\nMBQ@IWL)`N`FM?)RW0**/TI6':"8G6)P^Q\\SA::I#-0;'!ZFMJ9&E&2(3$"L&\nMLE%&9]=SXL`<4QV#*-?P?8TG+)Y)\\4T*:>_^%WR=+H\nMP@RYT(TD30`*<_-SMT6=;.3>-_T-@Y6W,-]_X!2<1TS2Z_PQ',/,E=_$?(,[33"28)20&U-C?*F,OLK^]G=V(.*%,.%(3;M\nMW(0J*A!0K(9D@Q'SA;/4@QEDTR=:2#@W=8[)R5/<>N?[N//F&[A[7;!9'W_I\nMO1N$./&7][S]\\),'C]"X%`^L-`O4NSG"SZA'.6F6,3W;I%YO4JU4&1T9I5`J\nM,-.>9M;.T91-G'#,9#.,\nM5*)2+-/NM&FU6K3:33J=-IU.AXHQ"*&77[R5$"R5UNP]]HW'HW%E[]Q^=[Z=O:,9VQVE\nMWF:ZD&5=KM%O6E.NU.NP>DTR+I\nM9`BS4D>__CQVQPL&B:_S9^8N^6[K7OO.>.7;?]R1>_^X,_?4_H\nMI]^-TN5_K.;3"[?]TU&L1?BZ/-*-GWFSR[_P'L\\S=WO:VZZU]K7J+?XU,`JE\nM%(.U0;9NWDJKW6:I4:?1;%!O+-%L-IU>"MWH_";T?,DMSBW&]86%R59K\\?MQ\nMU/VLASMS:/U^OGZ"^Z\\+W#^ZD:LJAS:_M?.CEXY]_//_\\].'=RK!R_82`*RT\nM.QZ]`X036+'&]_QW!KY_G^?Y=WJ>'E'J]5XHA44&!P=IMEHL->HL-1HT6XTS\nM:2?_RHV-=QU6-1U)F64IF#>Y[F,^M@3P?OP3'Q%]L*\nM?+*QZ2:YOSQQYIGG]SYPW?KQ'W[JF9^070Z`\\_;AIS]$H]%!2`)/>S?ZOO]!\nMW_<_H)7>D)M<2*FHE"N8/*?1;-#JM--VI_W-;K?SF9/G3OYT=&C,[7UH[R]\\\nMQB,3@B7#\\.TE]^CZ4O#K4]>\\C>>7W'/?>/+I^VNA?^H_HO3R`:RTC_[X08PQ\nMTO?][;[O/P#B@7I]<>/4]+3P/$T8AI-Q$G^NW>W^LZ=UZSN__9U5S_W$5D$]\nMY_H;0O=X4*E=]SW_:EX^-?.E?S@S]_%="G/A.'`)MOOAW>QY9*][[R?OF7>.\nM']2JU?\\<&QU+PK"X*0ES3VH!!]:HV?WM=U4\nM7!E\\3ZU6FTKKBX\\^58\\/3J@W0*%?9%]J?(ERJ:1F9F=VG#IS:KY:K6J7CI/?VJGSW!A.?_L2![BN_&>`>2J[PPG\\9]K_M-C2="WSR\n-)`````!)14Y$KD)@@O?V\n`\nend\n 6627 time_sheet_write_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```0#$E$051H@=V9:9"=59G'?^==[WY[O;VDEW0G9.UL)"1@\nM9D`,:]!!5'#&`41Q1-%AF&$L9Z9&+;4L=G\\^-/_N[(SF0L6CG\\O8]=_LNJ'_K;?)S0>NX\nM^P'^^5GC!8_QC@*,9DN(\nMUH][>X[G6U^;0C0OWR3[5BW6ZWN2]>'L\\9;-O7%Z[ON?"QKC;0NA;<`3P-]U\nMU,>:$X[]K][ZXOXMMZS?U-M\\3RR6N-%K;$]O7MXRLZC.B3V_YYC]])[)5Z/)\nMQG],))(/*:WF?O6)WG<>X!NW@X&HD62$P'=ME'J8OWO7##?5==O[:S:[8L>63/&-%4'=KR&,XI7"]"U'>#1-3Y27ONJ6^O\nM>?FVJ?9V2V"J8QG`&-`&8PQY;K9)58YD6U[\\5&6)O1O?LS#F)$`-(H_A.\\+H?S)"F/=]]22$?P\nMWB(5X^'Y<6()ESK/)NI9Q'R+F">J[YXMHO[*!F'^BN*NSY!P\\QA3%<)HA=$:\nM786X'<1_`S.G^G7.`(X-6N+7-W\nMZ.7!@B@LRM%7RZ:RF)[Z+2\nM/D;82*D1!^['GWX&(RRTP3<&^PR_SA7`ML"U0:#080$;0ZEY$4_7/46EF&4V\nM)[FZ^=UD+J^@_"Z6AB&+&RT:4I"*0-(7)#R#8X/!@`!A*2P+;%M@6V!Z+F%M\nM;R\\5;?/;H2+Y_3\\D(FJ35PNG\\P9P;#`66$(!$L;O&9NWYXFEM8870)JHZM:,P8Q_QL:@<%H33(:H2ENDP_`&(G!X-I@\nM.Z#U!0+8%A@;+#26"9DLU//"@>7D["R=L9!,=RL3IIL,6_C,78OIZ4Z<:]=G\nMF$&AM<$2!M=YNP$L3;'H\\$-Q-]F.&]GX\\J^IC.UAIFX#[8U;N.>V1;0T^N?M\nM?(T`90`!MET+(?$VA)`P8,*0AP;7L6/QE?2,Y.EU._C]]Z_"6=K-LI1UX^B_J9"ELKLVQ>G^#V6]=1+LWQZN[=\nM//'$`J.<2_?&$(U&V;AQ(^"A="WG7+"\\Y[J5Q.,>CI.@KV\\U9J%1SM%LV\\9S7?MO#&&6"S&)9LV`5XU\nMB4]7X+P`ZKX"!W=$N?6C7Z"G:5OG@4G66F-TZ']C/A.UG=^+'HPRQ:5I]O_\nM):L:=B%.Z6U\\?)R]>_>^I9-O%F+S"FS>O!F$]X8D/D\\%/@B?_33L6'87-R_9AS1K$*;.1R62(1J-G==[SO+.J)(3`<6S*18W2X)R:\nM`Z*Z%YP[P"4?@9\\^NHR;+_L&QF[I/3#"JOC>N;[ZAV)U\\;@].ZLQQLQ7OTQ,\nM3+!OW[ZSSG![>SM]?7T(KF>3[SW:S2G\nM-V1>&F*M5QQ.!+_XS[86S^W0NA*M.+4(4-#&(0P#GD0%=/+T/C'%D\nM8#?CD].4RA6,,7BN0SH9)Y-IIJFID<,#QVBL3V&;`,>"<]D93FYD%Z.-6U6`\nM&H!=I7I+@&W7WD2KNM\\IK;KTEH/EG:GQ0YI,2YQU&]NLUU]_S7_V^9T^1UFES%\\B7=M+>WX[DVFR]>3>>B%O0"\\I]NEF4C\nM;)>@;)`U!81=#2-AJB%U5@#7BY*U$_7>[/B*S?4)XI>GJ6OP>>[YIWCVM4%*\nM+2M8?^U:MJ[J))P>(1:+,3HV!GX^W](Y?)Q5JU;PTJO]\nM'!T<)!X[>XVDC<'W(ZQ;OY%0>B<4$'95`:/!>BN`@2,'""I!9O6:M;'%O3TT\nM-C;ROX_^DJ>/Y&C>=`U_>O4&-G8U4`P5.R<.(0-!(NJA5)E,OIRD9X=#$'($V\nM%`.)+$Z3FQREI78T(*P:@%I8N3<`_,L##X*A!=C4W[^79W8?\nM(+;ZW=QV^4KR4Z,4RW78GH_2AJ;NB]!:$VOK(1MHQJ<+U0-7J8`=Y*EW/<(-\nMES'ZW&,D1\\<0P+8K?H_E%_6@:DY+90A5]2F51FK`LJH*F&I!)ZR3;:%2XL1T\nM//'+KGQ([1T]9!92$-%&4)9S8%35RXAJLZ>G@8G0DA*\nM!8).`3W#QX:9M>.L;\\_@6!:56H?Y8H'7'WJ`K=L_@.I8C>UZQ#T;UX*9HP<8\nM^]T+^'6-7''KI_#B*4(I\\=P4Z46=A&-'F9S*,C(Z1??B.('4U1#2\\R%4#2>E\nM3SY/77D-"^\\GIP"$@&@SF.3DY#0FFJ8^YC$U.88;3V&['N^ZX6;:>Y?QRJ\\>\nMH6+OH/OBK:3228[U[Z8T/DS?>ZZG<^5:$!9!I4(PDR,22U*7:65V?(ARN8-N:"TJ8:0.>T@7[O$>%,%PE`B!`FMC5,LE;$C=91G)A@8\nM.DJZO8OFQ][E(HEI*XZ'ZC35B%]\\ADJ0Z@TH=08S8G&V4H)\nM*25`UD`EXGF.-5LD,`Z-+9W$F]H(I$*9ZFIC.Q9U#8W<^=5_H.'%ATBY(:[O\nMX-D"6XCJ+5I8)IE,$&EJ8V3_(2*^3[%0P/4BU226^C3GJ2J@#950DI_-$90K\nM&,4))A:.9:&TP;+2^.LVD"\\%',V_0C3B8Q#$DVDJ877%.3'K"J8+\nM`6/9`CHLDRV4T4&%4KZ`4;P!XG0[L8Q**5%2C01!V)^N2Y-0>:;&Q]D[-LO`\nM5(')0HA4&DL(+$M@"8&-P70LQ],A?BE'U'-)1%VBGH/G6$0<"UDL8`IY;$L0\nMC26(I^NI2$4H34V):L@4RQ5:4C:M+;R]&]9"FN'R6LA<^)I@W%0I%C.K\\:T-QD!^>IKB3)9R\nM:R_!X3V49V:H*,B/3V`;P_CQ,I[-S"8E0QF%4=SDJ&<9"@;\nM.9]EU:(+G?O,2Z70]F]:L(.6[)P!.;0OF`$`H)?FYXI%H+')_)!K]\nMSI*.5N_@_I>0B01V>SLX'LIHI#84"WFF?K>#SI5]))8N0Q@;L?=E6BZYDC`:\nMX\\CH),?W]-/3UL3C3SY-I+6+H:)AX-!(K1:J;IZ%_!PSN6EFLY/,Y?-T=/=R\nM\\8I6EJ0*S!*B0S`N&`E&S^\\";_*%YO-_]@F^_,WO(Z7\\+RGE)8U-C1^K!`$3\nMKSU'D4N)]?02L6TBC@WE`L88"A.C)%>NI'']5IR)0?*E@"-#(TSN/\\C2UD9>\nM?'$GUNPO>=^R*9S<]ZOWG@(,HJHX"IF05-P`,A;Q1!I_V$:/0"(8PA:@0]!*\nM+'@F7O"$_==?_GN$$*U2RN]**6^>RH2F=\nMI*N[BS"43&5SS(R-(V9G:*V/L_/EW12R!_GX]C(M#;)V.J]@*(.I@"EC3/7=\nMZ`I&E]&RA)9EM*J@90`R0"N-D>PRVER%(+OT`V_QC6QR+$?B^7WMZ.+9%I5+A^.B8\nM'A@\\]KJOQQ[\\FQM^,YQ)%82B.OG"KC6K=E"WJE7F&5Z8^8U+8+001E$PAF>`\nMB66WO'$S>,M+FML^>1_I^C2ST[/M4LGM4LKM2ND^C&X"7&T,6BE9"8*I8K&T\nMIUP.'M-:/VR[]I!6FI>>^>E;#7%!=L[?B:^_Z0YBL3A:*T]KU2Q#F0FEC$HI\nMD5)5E))C2ID)WW$CQ0````!)14Y$KD)@\n!@E)5\n`\nend\n 6628 trash_ok_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8```3F$E$051H@=69:9!^^Y9>IKMGG\\$,!OLZ`$B(\nM`$12(BESDV31H2B++$K1!\\?%,$NEY"2TG(1E)PZ+6<3$JDI))=N18A>]I!Q5\nM4=3BD)3ILDQS!260(`&(Q([9>Y:>Z?WM]^9#-T`"`DE9Y4HJI^KT>_U>OW?_\nM_WNV>T_#_^).L;83Q>;<>]?A!G@R#V?#]RXC"6:1A;(DD028J(.T?B\nM!*6U<8Q.;6/2K"W"G)+A2"G;&"IE%H;ZLG,C`SWG1X<+I_MZ6)?VM9503Y1;2>]"*W8KC9!J\nM*Z+5#@G:`:D?01A#&$$00A!USL/X\\O,P>D>C&*(8.TW("BBZ%D.%#!/#/>GV\nMC0/-73M'YB?/PB[V]^1>!GP#-*\\D(`/'`8YAO_@8W/O[LNFO7C_QB\nM7[%P=TLZ!Z93-7C6N-:,S%`+-$D00=`%$G5!A%$79`<007@YX)_ZWM7H*H3]\nMCHHT(9L13*POL'__>G/3S;NK'_W(Y.O;MX]_VW'L[[YQY*79/=<>0BD;,?;;\nM_YWR:M6]Z]"^^[>/#OV+EK#WO-;2ULG8IN;DT+D"Y'H@->\\`:/F(M@^-)J+9\nM1K0"\\$.$'W:!)I"D$%^A751\\&;FT@JQ4$?46HN$CXA02`ZE`:`'F8OA:';WR.Q:F&]X8\nMB3%@=(I.8DSDH_T:VJ]BPAHF;H+V@1!C0I1*^.QG/\\:7O_QKC<'!TD/U>O,;\nMXL!__A_]M^S<]+2VW8./GRQ35Q["O,JOB@1/8SB+E"`6DA\nM50:9[8/>+%KW8H(UXK4RCE\\EFW'QXS@TTDKD][_R#UJO/7EFUIM=X^#*')GC\nM;\\#B`L01"-D!+"Z"_;\\IAHY_&9`6)INEN&TC#W[I5U@WN8W_^MSK;_7WY.KJ\nM[.E5\\R\\?>F)F-,CAKMM#\\?HL;YXY0WFE2IQH!)*_15WYNX-O0*<&(0V%'H=K\nM=JWC4[?OPQL?Y%^]<(PCYZ9G?O_H:=0?/OX*!F:V;ADFBH;IRPXST;N=V'GE&"\nMOAQ/+5=Y^<6W:*ZM&B7$3"L(42^_=)Y6*YIM-:-H:+C@"-%/3[Z'_MPHF_KV\nM4/?;-*,Z:WZ5M6:-:K-)LQ40A"E1;$BU0*>@C<&8#L'+U'05T77%#DA+@%(2\nMVU9D,R[%8H;!H1S#XQD&-N5Q)TK4"BX7XH1G5NLLG%TAKJUBQ0E2$!@AY@R@\nM3M8CXB@M/_',R=8OWK+5*?7F\\#R+GAZG$\\#:Q:*(9XTS5#"D0I/*A)2$6,>D\nM)B75,6$4H[4AU9HT-1@D0EH(82&$1-D*Y3C8KH.7\\W#R'DXQ`UD7T>,1YERJ\nMGL,9I7A>*):!=J.%:;80[0BI#;)K\\KYLOC%8ZELT@!JX:Q_"DLL_6:A7SSU]\nMJG>R-\\^.B7YR.0\\A!4H)1&2(DY1&H&F&FE9B:*<6@;$($:1*8I3$SBJY;F!X=:S06XG2%*5L"P.UW'AQ68[V;'JMW.3H\\06*H<6`Z]'C>=B.(A&=\nMR.J\\T)"FAC`V-)*.MHW`V!)FV3\\6ES"P`J34J,&3"B"(Q\nM@TG`:-1DQ(3T*T/6M5&V`D`;,V?9GJ^C-@IAX0D_"5,UTYMSN&O?,-.5-L=F\nM:YQ::K)4"VCY,5&8DH2:)#`DH4%&!CL1N"ED4T%D!`F06@9C&[`-V"G8W1HH\nM#9;06#K%CCNWO+;!,08[-3AA@ANF%*R$8B8EYQDR.8F=42AE8>AL%JQ.[II.\nMVA5M63G4D8=OXL"C/T1K/;W2#%&69,-`EOZ\\PS43)=::$"_([$F',S$7_NT0`PWS-C_TX-?F\\*[$MV;W<*3+Z8E47`MN2"`I"LVZ3D)0+O9U#7MK"$9,O&F&G[!:)V2#-NLA(L,]N>8:8Y33-NH8T&\nM*9#"8BZ<8L/P07:K3S`^Y/#\\X8!F_,'6,.\\L6)>`*N^V@`"D$,T@UN5J.]IK\nM6Q)769H)F\nMT@1C.&8_R34[I\\FM?)8@++SO&`!YUZ'0DT7:BE"S4//CMJLNLX"@X14"&:S-\nMKC0CE)1XMD')]_$A`ZZRV+]=<3SW%OTZ@T%04`4.-![@S.L;.XL_`X.]%K?M\nMTQR-GP($J6F1*I^UN5Y2'5]UH6X,#!8R7+>CA+'G66R;H18$ES5#>2K^9`!2UCD78N@#;\\P],^87/<*\nMI_0+#,1[F3JZGJKO8W4SF6,K-I6V496#)&F*%(*=[9LYL6PA94*JS4^!WS%>\nMXMK)B">/_PXGYH[AVA[::+36V^[]T'U_O2O\nMT,9,5YH1!G`=ZU*0OANY9UL,]:4LQ&_C.V4BITRMD"5S[@[6MP_0:DL6*C&R\nMFYWR&9N]6SS2=(`/6Y]#9^M83H*S="T[KJE16_8X<>*=]*D-;!TKLF=7DZ^_\nM^!@3O1OXU8\\\\0*55X;E3S_']\\!];ZHKJ,]66E$0QMKS\nM[*L1@%0;4I-R.OT;GE]^DH%B#QO<0?;W;N#P2V.THNB22P@!=3_BN\\]7<>48\nM&7N"G"O9O=4FWG"$8X7_Q4CQ(_3-?H+E2M1QFU*&&_8+_N3(U]BS;B]CI3&>\nM/OXTS[[U+$NU)7ISO7SAHU](QHOC1QOM1O4R`D*(H]4Z^04&L8_$"SVJK3#F+ZU#!ZY`T&!S7[MO;2\nM<%[FS?EC1#KF\\5<>Y_7IUTEURNU[;N=W/_\\'Y4_M_/0#YWYX[+%*I;(FG(M[\nMP^[L2BGJ09PNENL!<6JZKO!N!@+/B7ECZ2D:]0;-=DC=]]FL/X+_^J?1S0%*\nM><5[50\\AH+P<$[]]`U[2CZUS;,GN9"#KLFG7`C<>E'S[[?^)48:G3S_-7'L.\nMZ4H^<^`S_/9=7V.^.G[TT1^>_\\&+O1-ZZ[ZMG4E_]\\NE$'Z\\YM(@QF!+DZ;:3)=K`4&#09A^MO9>PZ[\\3H;$,`O5\nM)2XD1Q@NN>0]]=,I$;`MR6AOYI)%!X<3IL.WZ:%$UF1)PI2!GGZ^<_8[K.I5\nMZM2Q,A8?WW,G7[SA$5X]G;!4;R,1T_7)2<+V50B\\^INWHCL#3B\\W(OPH)=7F\nMBK:V(8@EZXLW,)Z=X+:1V\\CI`L\\L_S%>WP(#/1EL2Y+J3CKL/"+8N]WFQOTN\nM.A7TYEV2L5/`21V*=HFY<)XW:V^2.BDB(]B_\\5H>^O`CO'X*%FMM\nMI!#&8*:--ORG^SYT"='E:;0C,VNM*&F$L;*EO,(9!,:DZ&20T=PD;FKCN`XO\nM-9_G#?TM/KSY'S(P8!-$FF9=<6X^9'S08?BZPX3^(+MW3%#HJ_!D\\T_PVS&%\nM4A$=PH:Q;?RWTX^1.`F6L!AT!_GU@[_%V;-YII?7<#,*`P'&S%X)]J<(",%"\nM/8C;U59<*.66X>NH/S/T9NS.XDY<3+G0"A5%M1F_?097%MGB7$.N-(CC&OK,!.65%#]*>*WR*C^J\nMOLI<,$9F_/_8KM"[D"8LSG%D^@YVS^?3H/?CG-_'VU"R9K$`*2#"<\nM;]8YLE*>._M7_]O/[+_^O0FD40K\\49@L?&FF?WJ-LS,MS@SUT+NA0-]@AMZ\\\nM0R%KD[,M'"FQA*#I%W#5A]#&8*4PD@J2Q'`J3#@:SG+#CMNX:;R7KYQXE)EX\nM%B_R&$P&F2AMY)<./L@/Y%_2M)ML*6[F9GDW3QY>(<'04(HI:;C@MYBN+1,V\nM&]/VQSZIDY6E]R8`%CMW?MDL+M:F[KUG#]E,EN>>G^/X"Q7>TA)1=,@,.^3Z\nM'#(YA>=)'-M"66!)>:DGA1'0;04^]>,%KMNRAW^[_[_PU:G_P.GX+#59XR\\:\nMSW#7SD]R?/DH5D[QJ8%?XM73X_S%0(UVOI>:"&GY-70CQ$H3)&::T"?\\G7]^\nM!>++Y#!1=(@H2C9X7^??U=9SISU-3FC`*$&$;&?B(T(]$$G\\#.)4^]_WW(P!);3?/1;-9=5RQF4$J1RSD,#F49&\\LQOB['4'^64L[%4S8"1119-'Q)I6VQ\nMV+*8;RL68INR]B@+E]?J4`E&>'#R`&7K!"O6*JMJ%>VEW-WS:4Y6/LZ?UP!2\nM1-!&!FU$Z","'Q&'+XLD^BI"-#Z0@#&'D'*X.CL[_^+1HVOYJ:G6^B`@*X2%\nM$9+40-+MYV`)I"VQ'(G5;>8:2Y)*22P%VK)`2;`ML"W.MU)6@R%^=?M>IN0;\nM-.PF0]E!/FG]8[XZ-<2*`4S2`1VVC0C]91&%?R:2^%]3[+]@_!;Z"@+OL^E]\nM&(@<*.YSW>(G!P9+MPRMZ]E9&LP,>@7'L;,V6@DB(?$-M#0T-32UH&F@)22I\nM:X%G=QJ\\GMUI[+H6G]E5Y/Z#1_B]Z%$.Y@\\PLO8(#YVST)X*B8,ET5A[2S;7\nM?BB:M1_0K!]'J3CYIW=>%>7/\\!_+KP,O`_=D(3=.SMMI%=T];L'9;OZC&NE=6.E8V5I6(EK4A90KNJ`SJCP%,&3Z5X*I:>W7[X0$^X:_OWAPNR\nME#YU_H[O_>ZR_C&>=8(T/"D:M7GSB5&?[YR&>[:_+[J?[T\\B[W&(0L%PP:/@\nMY,G;>;)VGJS=2T;ER:@,GI)X70(=U7BJC:>:.&KUYA$G>N)V]5M*LG'Z]-+?\nM$U9XP=UUW'/^YYP??\\S=74.<-&LG!48ZTNSL\nMG9GOY_P>YW=^`__/#_5R/#1-4_(\\5_OV[;/#P\\,I8$(($D+(G7.Y4DH>>^RQ\nME^1=+PG`;;?=AHAH:^V4UOI@',>O3I)D-HJBO2&$J;(LHUZO)^UVN]7K]8Z5\nM9?G7699]QUH;3IPX\\;\\'7FQ*(I/S,W-_=G.G3ME<7'QDC78RQ$?0AB)\nMHNB7=^[<^:%#APY-'3Y\\F-V[=Z.4HMUN<_[\\>187%^ET.H@((02\\]SCG=I9E\nM^5OCX^,/.^<>OF3UEPKPAC>\\@3S/DX&!@=^YV_-LNS[@/^1`H00""$<\nMV;5KUWN/'#EBAH:&6%A8H*JJS9E?6EIB8>$L9^;G65A8H+/Z+%%HLW^]C4S/3T]/3\\_SS,G3Q'G<[QVNB0U\nM"9-:D^XR3,RF3$]-,[-KG+&1810>EZWBNDO$VK-O8IVYE0J`ZZ^_?O_1HT<'\nM?R0`69:AE)*UM;7\\^X\\\\0D.7?.PG$^Y\\QSV8H1FT35`(2BE$/+[*\\?D:(5M!\nM.8>*NC1'QGG7Z\\[QGR<[S,\\O,#DYN084V]5R20!YGE,41:B<>P(1[KXY<,<;\nMWXF=O![3&$69&/$EXC*DZJ&"H&T#;`,=-="V@;W[]F\\-ZM?VVVU[)X/2KD2HCE&VD;$,H4`A:\nM:[2Q:&U1)D)IB](&I0PV2GC;31%Q<:X\\]KWC_[QKU^YMB]\\VP'4[0.3/^>S/\nM38V\\ZY:!Y3<=5,>OW'KA>N!+%!ZE%$IIE-;U.0I$0`(2/#N'%8?V\nMY">.7*U.?_[NYAC`+QW:'L"V;/8;;Y^DN[XR=N=[?_W^/9/-UW2__Z?-G?L/\nM3293!S&-473O"^=T>-H<5?^-+2B]:TK1AH1(*+T*GJ7#4Y<>6^YMZK"?EY\nM0M%&:P-*(5JAE489BP*\\RY#>$KY]!M]=1*HVA!*1`"A>^:K9L1VCZ5AQ>L6/\nMI"&VR?;6M&VY4)2O\\.D'/W&^>_S+7UW[W@,T1G:C0D7(6X2R3:@Z2-5%7`?*\nM-21;(G3F"=DRXC(0CX3:?20X3#Q(?^]>^^]5?%_)AN;0O`;.?'\nMWWA">'/^37RG\\\\10TU[1&-V[-Y3=-5]V4D50A`)<#\\HN4K61HDTH._BR@R_J\nM$C@BS9F8.QL<]?!4+7/_F.Y\\O0G?_R.B;6;/K6V+8!MI]$?^XPP]X5K\nM%GW>^4"Q>NI5/E^[`KC?A6*$:@S5&(%D"'$)B!"JC%!T"%6O/J]R@L_QOFK[\nM;NL776?IE,O73XR^XM;SSWS];[4'5R^CL]6<5D+UUNAR-H/=K/JG<;H[HV_'2Y9PR67TP`Z%$@\\\nMW!,)7PPN/^++:!A`^1*E#"*>X`I"V<,7;7S1)I1=7)5W2N>_F#9,=WG]D@O1\nM6L/EW#SSX:<07R&N."JN^(HOVKA\\O:YYLA:NU\\)G+5R^BL];A.`))J$HJ[]L\nM]\\+7.WG@ML]>EOZ79DLY=]^U('*%TOK+2D>O5]J"HLXVKB"X')U.H0=WT3KQ\nM;]]NKRR]RUIUXO#OR&6_^[(LL'%,#"F"S^B-VZ@;./OWPF:7EI8\\ZKT^W1QF,$[4V'?_1?9DVY&P(Z@?.A8>=XUL^\\%@CHK>T!A]_X&4`^*.?!Q$&%;PI\nM;:9W3^RY]M9=^V^92(G]A]XR>_-=`U-7'L)&"0N/?I50K=)($]QHQ9/?R0E/:G8V\nM84<,PQ9&K!!5@=4L<'+NL?L,%\nM^=1;#O"0_J#B(_>]<*R\\8"GQ>_>`T5`)MR1)XX%K;OZ9-[[V31^/AD:GJ?(6\nM>?LL\\X_\\!57O'(.#":-7)+2;EJ[1.*40I1"KZ34L\\V,Q9ZY.*:X;I-&T:&V0\nM4&+C04!AC"5.!HWWY=6^S&__P0J/-ZQ^^B=N%!Y\\Z!(MH)2B\\K(OMN9SK[SQ\nMK==???AG*7OG*5P/"!3M!8KV::(XP481>W=;KMACJ(+&>84$:&F%M0IC%4TM\nMT.\\->>?PSN.R1=`IKLB0*F=@(,67O5=DO=[G"A?>:;1Z!)[?"L\\+\\)E[%-T<\nMG<;(SA&H%?J3P?^,*'5/FA+UPR>0VN%M1'66FP482*+L09C#-J830!$""(U\nM@/,XXU!:H:J2C>QOI"'EG$2TE\nMFA*E`EH)OEC%6(VU!A-9;-R'L!9KMP#J#H7T+1#PQJ$OW&;V_R\\B2.C_+GA\\\nM8$J$URG%L3^Y%][_QR\\2X--W@U808#:*!XPKNXA;1TN)40ZM`UI#\\+UZIJW!\nM6(NQ$3:*L%'M2L::33<2J6(_;<*U-]Q*D[O;5%O`!8P+&"R(<:#8-Z^ON\nMQ5M`:YB>2CAS+M^==9YE^A`\\#E:&XRN7<;8>EAKL7'M\nM5AM6V&SNNMIU4'5HUCNT6KSI`QIO,%YCC"<(.UNKSD16^8L%\\\\5=2!1/S>6F\nMD:A)7^6_[L:.-P>B`5[(CLB1:2>]%6T!$,)H$85SUW^:*#H7O0&*@\nMD:!)P"2;/JZTV@31?9`-2QAC0,`YAT+U.RMU0`>_(5K7PK5&:[7Y'*W\\F-9J\nM0"EZ%[/`1:M1J?US0&!\\ZY8-GU44SB!*;SWOPH)DHQ>D:D'66J(X)DKB?JK=\nMR%`;L`9E#)6W*%4+WYB(N#&$UF9$(4WU/&O!Q0%$$*$IPK#0]]7^\\$%8Z<9`\nMM)4Y+AALG'/!-47?0OVA+AR@=$2K%Q&$S>L`27,*&P\\T$8;5\\Y1M%P4(02'"\nMN(\nMU6Y$Y?JP]302#XP2#XP.2&#LHNIYGA@(M;7&@C"P(3[T08I":!<-M+&$JO/?\nMQ`;G\\<:CC<<;MQFPP0>44OTL5*_$H9]])`24CN@4BCP.#"8U&"*8J$'2W)G(\nMXNGQBSO0"P"(L$,IDM`7[^MK=',(JH&Q$67NMTH#[_'>H9U&&TVU(3X(VO3S\nMODB=B:IZ-=X`5U&,Q]++/6F\\Y8;!E23-28MB\\ODL<%$7\\@%\\8"((-DC]=ZBO\nMTU^$!7[U[1!J*TSI`-Z#UYM0=`MH3J28\nM.-T4KC8+-UV7!1L!'`+>FYV73O/*\nM$F4&&1PT!.]PSJ)L2A)/H!L3*-L`W9@8FUJ/O#SW,]1%+:#JZUT1GO(!OP$B\nMKLYR:9KJ>'`*Y_!:.R[\\-"2A+ILE",'X>J'26[E](X4&W__H757H:%BGJ5)*\nM?*A*1&D%5@B5X]R)?S=EWEV+FT0NJ.)_KL87R4(*H`)^#8@VTF<(@$#ET8UT\nM3*>C>_&"VZCA@PD$YPG]A<@#B"%H06L%:B-?R.;:4:=>1SRXVR2=7%7.!^\\E\nMN"PCS];(LM,4)>B&V9VV\\<5QG`?]\\YL[ZL77N]\\07'CF^Q@Q,G\nM<9(VA(8V32IP(H*`"IX0CWWC?R@(!(B'/L$+0D(5*A(\\@`0\\M`*A-,VEI8DI\nMB92D:9M-[SOH:'OBDLW/FNYWO.F?G#/P?GBX(\nMO`K,B]_?.]39V;Y=:Z7R1&,*L\\*\\&J[(;TKFRW&E]WFTB!"+)4@F;2#/JW+S\nM_+V5&P(8%S(AR,Q``Y;?'\\!QV@Z<.K7GS5V[NH<\\+R]DRHPP%'6:/"V'-Z::\nMDV:9$Y5X$2$:33`]?8_.S@"B&XC-+S$;B3(XT(GV-;$03Q%Y^)#]0RYMC89X\nMPG`YU'1A;D&^#RILM;3VX;EFW.?;MOM16(OK>'C&X'E"T1DIIDQ`E*`D:X#D\nMK]0')N>0ZQI2*9=0"`(=?>P]/,+]QF=(1)<8OW>/8R\\,TKJCFTL?S=%Y\\1*O\nM?C7*<'<+]\\Y?(+)PZ/#<@MZ.$+82`SLQQCCOQ9J,$S5BI\\')&!QW>8GD02E!\nM:T$KP;($RU)8.H<3H5B$17`]<%U#QO5(9SQLVR.5,J0S`29Z?'SXP(,309*C\nM772X'A<_S;`8$%KW]:'OWL7Y]%UV['P1OQ/%/[P#5%!H=+"6IG8!<#=;&Y4!\nM7SF4E?`DN4H9R?ZD+)<^SZ%U>PLS2A.9V$Y[)$%33RN)@)_DL\\-\\%NIE^E_3\nM.*-?)NS?#XNMH%VL43F/B.`X3J%6)?\\K5=;+(ZL8*X9LC57U*Z>OBD[+"%$-\nMT:O@FFSI9EH%YV-P$&S'\\->>O;PE'ADT.OT?&5-I):*Q3LQ<1$1P73<7HEP]\nMY^J[>$\\YK>*:OQ2ZH0H-!)&2,%3P9.FY9TT)7U8F2Q`1E`B93$:TUEB]??VX\nMKDM/3P][]NPI+$!!L#:L1*^D5>-=::U:--NV"85")I5*N4HI+!'!&$,P&&1T\nM=)14*E53>#7SC5[1`2F=(,U'1@+8JKT>HU>K4.YZ&LA*KM`YL9R?7@EF4@;WRMZ/^O\nMX4HS4+8/U&J2IQ'Q4EI=/:!RKU"URJA>`S;58:6R0\\IMK;D//.TLY.=**;R4\nM3>+2.5KNWT3;($W;"GW[Q/]"FQ7Q>OB4:.:6;&Z__Q9=?_\\;@92:X2?3(&]9X[Q[_87^5;'/G:[$92JLPL#%A-+'!\\8XN3W#->OC7'GMI^Q,0NML_VQXE^)>HW:2)Q6FHN1\nM<_SVYALXVB;@]3#9'B29:*%E<9@O=H;P639@(>(M?R-;CP'KS8Q20CKM\\H?S\nMU[CV*$&PP>5`[QCA>(;YVP>9VM]-H"'*G;OS!3UE/?`T(EZ&0_CCQ2COSW^=\nMO0^:L.]-DWIID$7_25XY.LC4D6V<.?-1SME->HRN5=;2B@M78OS\\%BRF6WE^\nMZ1"]P1UT!"<8:&YDZDL=B-3Y;W3+(IZO>ZWX[/X2KUVV>60:>/GQ8P[V&+[[\nMG>?H'PSB9KS.,#PE34R-8EEY6+J5E7LB@2/&%IE+@2=%=\nM:_F)")967/UDD1]?=XG%'0Z&9]D=S'#Z]`CM[4TU;:G,@*KG5&X]F:DFJY00\nMCMC\\\\$*"3UR+_NLS/-MF,S75S\\!@1UG)5.HH=:!F#]2*6B6]7K[*>3KE\\OJ9\nM.?[I-=%RY7.>;TYRXM@7F)SLQ?/,$W6797(E`S:J6WVE5)9#UX)W'YH\\]JTS4Q:\\UQDCJ-]\nM#J=.CM#>[L.V[9KK%0*@-9E,INQ\\M."`;=M(51#T]^>)X'\nM&&)N`&5O9_B&RZA9(I6\\P=EWKW+FG>HRU70]?OR8R[7P4B?ZLJ;'A9F]7\\V_V3_0O:-T@QE!V\nM*E)-9R7>\\SS'&!/*AF4+(-C9`]`W-K[O^/#(KK<[N[JCOWK]1UNQ](:"SHT-\n7A?\\">74FVT/(N,,`````245.1*Y"8(+O\n`\nend\n 6632 xtuple-dashboard_48 begin 644 internal\nMB5!.1PT*&@H````-24A$4@```#`````P"`8```!7`OF'````"7!(67,```L3\nM```+$P$`FIP8````&71%6'13;V9T=V%R90!!9&]B92!);6%G95)E861Y<^J:JZJWH>W+8[5M*>VG$&)S%8220B\nM+`@;%@@D=B!V+%B`DBW9LV'!BG\\@"HH@0BA*&$2(%"5!0$CBM&/WX)ZJNZM>\nMO>&^.YSAQ^+<]ZJJJQTCI"PXI:H.O^_O]_V-1XG(F\\!/^?^Y"@O.C6/'R?.<&",;QS;(LIPHPG`XQ%H+@-8:\nMI=0O&X"V0+84^L[MVUQ_YQT0H74MB[+$.P=*$6.\\H(T9!N_WWKMY1VN;M[]R[__H,?XMN:HM=#1(XYYS[9.O?:?+YXLS\\8\nMO)CGJA\\CI8@\\4A+>`WX6??BYT?&1P*.JJNX8;;9#\\-MMVP:)D1`\\H(D2"=ZC\nME4(`[SQK&^N("!)C$E@$`?(\\7[$@SS)Z@P$2(KU^CZQ\\^Z[W'\nMMYX8(U$B=;T[!>XHI6XII1]IK1X8H^]F-KNAM7[+6GM7*;5KC*7(5L;^90B!\nM**"T!B`$C\\2(L9:!,:`4(49B"$GPD#3MO,=[O^Y]6`_>7W'>X4,@AH"(`(A2\nM/-!*W1/AO0L![CT+1Z_42\nM>A'61D-&HW4>31R#'W^5%V]]G4?%>2:C2]2;SR!G/\\;HV$F4`M>VU$V#:UM"\nM#"B62O&T;4L(8<7A&",^>((/A!`R[WT"Z!S3^?SC82\\08L0YQXFMS;=/;6V^\nML*@6+H2P#T"AT(DNT1A#GN^S*5K_X!NX%1V#?:`\nMOX,?O/$GZ-_[(]8UA!6U`CX$0O?QWJ?GMBW>N71-C/@0:)N&UCFR+"/&R#(R\nMQA@)(>"B0T9%G&L,CV`70O#]T^+OL::[0\\'D=7/M!Q4!T4VGS)`);+>T_3-*N'\nMV,S2'PP8#`8@`Z1^"(U'Z0!;$3D'+,!93UW5U#:%01'!6$MF+=9:,I5!%^=%\nMA!`"S7S*K)P0O2//(YH>$2&&`Q8,(=T7`_/9]"@`$<&U+0*V;=M5(C'&\nM4-4U"D!`!)CO0>F1X"!4J%,*9D(^RN@5/8JBP%J;>.L]554E9^L2E?=)J_5T\nME^\\\\@F\\T%QB$FO.ZY"-%Q=5-QZFMXQAC.XLD[2M4TK[(40!**;(\\!_#&F`3(\nM.83DP$HKE%:@%,S&,"TA!,35L*4@%R@22$AUD#%FZ5>KM=3\\[L-M_GI[G:_Y\nM#]':'"R(@O+A#E^\\]4/^_/6";&,3.5!&:*W9V2V65']_"JTN4`F84@KODB95\nMV\\)\\"C.;-.$<##7$"%8=>8Z(T`;/K%W0NI8LR\\B-9:^NR<]>XW=IG?OL.#D<*YAH%2JY!KK*57%*LRY!<"6%I$H6CKE,P$P=H,CR#5`EFH\nM!*!UT`J)`B>)N\nM*7RCT;!Y'ELXC(:B*`X%!&,,QI@CLCZ>B45$NJCC0+%*9D618]H"Z@JJSB%:\nM#_VD^>`]3=M0-PK7MDSKDG!MS$O?"FS.[YZ57CD8``45K&V\nM<8Q9T.CX$.)L)?@AI3ZA*CV4B46D\\-Z391G66IQSU'7=4:+SGZ:!A0<%N.XW\nMJ8+L]_KT>P5%GK-;3NA-A8TOO@#'-'SW/GSM77A[2G\\0F+:PWC3JI3-$J!-AK51KB_`!7A80T]`Z?[Z+ZGBJ`=V`@[K6)D!1$P1K.VML;&\nMQL:J2HU=T[,L<8X"Z`06$=6V;809Q,=BXX'R&J441BFR551Z`H`H\nMDL*E2*ZU9C`8I!A^H/1UKL6Y]C"`/'G`(B_X>?9OW"B_2=$V#,=/,R^/\\=KX\nM\\Z`NP,RESS+,`G6$Z!*VQP$\\:3T>E0X!T%IWS36U]_X0>DA.[KW'.]\\];?\\!\nMRD7N/'N>]=8AR,IGF@"UAPT-D54P\nM(XH0#EA@Z8_OMXY4HX_'7A&A:5MVQV.LJU"=JZZN\\E#T`A^^>)E-GN'XN6]P\nM^]UKC$8P;#3<:Z$TL'`KOU&`"U`%\\++_+*4@^,!X/$;W1^1Y068M*$61YX3W\nM]8''EE**$`)U4],TS6K6T[8N<7#U1B`H7"G<=M^FRM89EP_8/)51*,>@ED2=\nMNG-^S\\2I0W(>YQV9S=`#O?*%\nM&`)'C.D$7REV=^:8S2FSB2+/UF#-D64"+B:2*]590/9_]LNNE4YBC.E]/M%5\nME,)H0]$OL%GVY%HHQLABL4`IE2\\S<5[D>.]73ES7-=(T^TXL)*%:(=0P'VM&\nM5EA,4QVT`GK06EKM_RT<$4:I)$M=-_ME?)?,K+$$[X\\H<.7$O5X/P"WG+4NO\nMUUHCP'Q>8EVS+U07/FDA-E!.8-&#MA*T/2#X\\%'``]X'FHZZ2P=6\nM"HRV..^/E!E/+.:6?VN=Z-/4-8O:DX?IX3"J@$8(#=0+\\'6JK,VA=QP0521)\nM&N*J05IB\\P*-0.T\\D\\4$W=_%9AG6F%5_X3M:/1'`P;6LA;H"C\\%@0-7.D8/W\nM"V`$:F`_Q*,4A^ES$"Q`&T"%(TQ<`FA#Q#O'HJH(LQE::[(\\3S*US:I?_X46\nM6%:@R_:PKFL694D1#U`(4A/3`5AJ5'4>*B6X[Z9F2BGF\\SE1U_NJ5*`*4HAT\nM!XBB(`;!-1`]^SRAVU>=!3HV+4&["%6$QGL6BP596:X4J[5"H3'F2`Q<#K;2\nMA=9:&0P&JP2VU/ZMFS%H/*X6)I)=$8.$0\nM'5:3:`$,*3///50N4-<5=K%8R978H1CT"S)KC@)`J66[%I<5GS&&!]O;W+A^\nM`R%R[-@&@\\)#T[TU`PJ5NC,GJX9':P@A4I<0O.S3J,L!+#R8?2I$24[O8@)1\nM-H[)9(+TUS#:K(*)`-8H/Z/=[#`9]@ECZ:I$T\nM%X"!2I.(!2L*B8`VB3K5/%6;JRRU-/_<@_7[/@#D)H5/6HMO$X683--GK$V?!\\`7/T5N6L2HC"U-$%"P$=3[-@Y(%DJ`2\nMP680`E0S\\.T!"EF=K%`Z*`X7$3T#XEMH/+%-_;AS;I7(HD1B57%L?>W)>4!B\nM)'B'2,RK0!$C\nM+&9=Q[GDR<"FJ%4ZU"AU;TL+C+(E@("K2^;SDEC,5_Q76J=!L?=/[LB,,;BF\nMQEB[?>;,Z>^%$%X1D6+9REECR(N<7N\\2;[_V9VRLO4/Q@VV*.]N,7UWG1T]K\nMI/DFVL#Y"V>X_M_W*:?@ZHX_;83+0]BNH'3H:C^6:P6G"HB^A;HB(\\U+)Y,)\nM402=@LNJ/U$\\P0(;&QN<.GV&>W?OOC4<#3\\EPG-*V8>%I&HA*?Z$-H6R@D73Y_@=U[];1HR]O;V>._.7>[>N\\=T.DWM\nMK3H,H1NO:S[R_/-LW[_?Q67UME;J;9W9OU6H+R'QC/?^0\\ZYWY#9^`L-XV?G\nM<$P;2YY9!OTAZ_EOH:Y#5!5OG%6$UUK?-\\9\\1VO])90ZC&4UFDPD.36TL24?1=5Q60ZH74.H_5?]0>#KSCG[IP^\nMAZ!I32&&LP1A/C@=FEUN@T\nMW=Y">"[&\\$K;MK_IO7]>1,YIK0O;G1GT>WV*/"/74!@-VE"E$HD0`GO3"659\nMHK7^?I;G?VJT_F>E--X[WOC`.#QM3S;"B$PG4PHRSGE;,YT-B5T\nM1T)-W1!CZMBTUJBN_#5:8XQEL2@+$2X)\\MG@_1=CC"]&D8L*S/),;M#KD^=Y\nMXOO>&!&96FN_8HS]BQ""5PIZ_3X7+E[DI9=?699D'PS@@]828-LT+,JRBQ9-\nM.M!K6YSSC'=W4BVO%$9I1-%'>":$\\(40_"><`EY12%A&T,5]7J"_E1?Y6\nMEN<GFUHF_.7/V3#J;WCJQ/'QYTLJ5B+P*_-CJ_<_I[CL0FBBTOT`````245.1*Y"8(('\n`\nend\n \. -- -- Data for Name: pkgmetasql; Type: TABLE DATA; Schema: xtdesktop; Owner: admin -- COPY pkgmetasql (metasql_id, metasql_group, metasql_name, metasql_notes, metasql_query, metasql_lastuser, metasql_lastupdate, metasql_grade) FROM stdin; 470 desktop cmmntPrefUser Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group:desktop\r\n-- Name:cmmntPrefUser\r\n-- Notes: \r\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\r\n-- See www.xtuple.com/CPAL for the full text of the software license.\r\n\r\nSELECT usr_id, usr_username\r\nFROM usr \r\nWHERE (usr_username=current_user)\r\nUNION\r\nSELECT usr_id, usr_username AS usr_username\r\nFROM usr\r\nWHERE ((usr_active = true)\r\n AND(usr_username <> current_user))\r\nORDER BY usr_username; \r\n\r\n\r\n\r\n \N \N 0 207 desktop bankBal Forward update balances if applicable Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: bankBal\n-- Notes: \n-- Forward update balances if applicable\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT forwardUpdateAccount(bankaccnt_accnt_id) AS result \nFROM bankaccnt \nWHERE (NOT fetchmetricbool('ManualForwardUpdate'));\n\n-- Return results\nSELECT bankaccnt_id, bankaccnt_name, SUM(balance) AS balance,\n 'curr' AS balance_xtnumericrole\nFROM (\nSELECT bankaccnt_id, bankaccnt_name, COALESCE(trialbal_ending * -1, 0.0) AS balance\nFROM accnt\n JOIN bankaccnt ON (bankaccnt_accnt_id=accnt_id)\n JOIN trialbal ON (accnt_id=trialbal_accnt_id)\n JOIN (SELECT period_id\n FROM period\n JOIN yearperiod ON (period_yearperiod_id=yearperiod_id)\n JOIN trialbal ON (trialbal_period_id=period_id)\n WHERE (period_start <= current_date)\n ORDER BY yearperiod_end desc, period_number desc\n LIMIT 1) data\n ON (trialbal_period_id=period_id)\n\nUNION ALL\nSELECT bankaccnt_id, bankaccnt_name, COALESCE(trialbal_ending * -1, 0.0) AS balance\nFROM xtprjaccnt.prjaccnt p\n JOIN ONLY accnt a ON (a.accnt_id=p.prjaccnt_accnt_id)\n JOIN bankaccnt ON (bankaccnt_accnt_id=a.accnt_id)\n JOIN trialbal ON (p.accnt_id=trialbal_accnt_id)\n JOIN (SELECT period_id\n FROM period\n JOIN yearperiod ON (period_yearperiod_id=yearperiod_id)\n JOIN trialbal ON (trialbal_period_id=period_id)\n WHERE (period_start <= current_date)\n ORDER BY yearperiod_end desc, period_number desc\n LIMIT 1) data\n ON (trialbal_period_id=period_id)\n\n) AS accntdata\nGROUP BY bankaccnt_id, bankaccnt_name\nORDER BY bankaccnt_name;\n \N \N 0 468 desktop cmmntPrefSrc Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group:desktop\r\n-- Name:cmmntPrefSrc\r\n-- Notes: \r\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\r\n-- See www.xtuple.com/CPAL for the full text of the software license.\r\n\r\nSELECT A.id AS id, A.cmntsource_name AS cmntsource_name, A.cmntsource_fullname AS cmntsource_fullname\r\nFROM (SELECT 1 AS id, '' AS cmntsource_name, 'All Sources' AS cmntsource_fullname\r\n UNION\r\n SELECT 2, 'ADDR', 'Address'\r\n \r\n UNION\r\n SELECT 3, 'BBH', 'BBOMHead'\r\n UNION\r\n SELECT 4, 'BBI', 'BBOMItem'\r\n \r\n UNION\r\n SELECT 5, 'BMH', 'BOMHead'\r\n UNION\r\n SELECT 6, 'BMI', 'BOMItem'\r\n \r\n UNION\r\n SELECT 7, 'BOH', 'BOOHead'\r\n UNION\r\n SELECT 8, 'BOI', 'BOOItem'\r\n UNION\r\n SELECT 9, 'CRMA', 'CRMAccount'\r\n \r\n UNION\r\n SELECT 10, 'T', 'Contact'\r\n UNION\r\n SELECT 11, 'C', 'Customer'\r\n UNION\r\n SELECT 12, 'EMP', 'Employee'\r\n UNION\r\n SELECT 13, 'INCDT', 'Incident'\r\n UNION\r\n SELECT 14, 'I', 'Item'\r\n UNION\r\n SELECT 15, 'IS', 'ItemSite'\r\n UNION\r\n SELECT 16, 'IR', 'ItemSource'\r\n UNION\r\n SELECT 17, 'L', 'Location'\r\n \r\n UNION\r\n SELECT 18, 'LS', 'LotSerial'\r\n \r\n UNION\r\n SELECT 19, 'OPP', 'Opportunity'\r\n UNION\r\n SELECT 20, 'J', 'Project'\r\n UNION\r\n SELECT 21, 'P', 'PurchaseOrder'\r\n UNION\r\n SELECT 22, 'PI', 'PurchaseOrderItem'\r\n \r\n UNION\r\n SELECT 23, 'RA', 'ReturnAuth'\r\n \r\n UNION\r\n SELECT 24, 'RI', 'ReturnAuthItem'\r\n UNION\r\n SELECT 25, 'Q', 'Quote'\r\n UNION\r\n SELECT 26, 'QI', 'QuoteItem'\r\n UNION\r\n SELECT 27, 'S', 'SalesOrder'\r\n UNION\r\n SELECT 28, 'SI', 'SalesOrderItem'\r\n UNION\r\n SELECT 29, 'TA', 'Task'\r\n UNION\r\n SELECT 30, 'TD', 'TodoItem'\r\n \r\n UNION\r\n SELECT 31, 'TO', 'TransferOrder'\r\n UNION\r\n SELECT 32, 'TI', 'TransferOrderItem'\r\n \r\n UNION\r\n SELECT 33, 'V', 'Vendor'\r\n UNION\r\n SELECT 34, 'WH', 'Warehouse'\r\n UNION\r\n SELECT 35, 'W', 'WorkOrder') AS A\r\nWHERE ((true)\r\n\r\n AND (A.id IN ())\r\n\r\n )\r\nORDER BY A.id;\r\n \N \N 0 469 desktop cmmntPrefType Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group:desktop\r\n-- Name:cmmntPrefType\r\n-- Notes: \r\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\r\n-- See www.xtuple.com/CPAL for the full text of the software license.\r\n\r\nSELECT 0 AS id, 'All Types' AS commenttype_name\r\nUNION\r\nSELECT cmnttype_id AS id, cmnttype_name AS commenttype_name\r\nFROM cmnttype \r\nORDER BY commenttype_name;\r\n\r\n\r\n \N \N 0 471 desktop commentConsole Comment Console Query - update for OPP in 3.8 Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: commentConsole\n-- Notes: Comment Console Query - update for OPP in 3.8\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT\n comment_source_id,\n comment_date,\n cmnttype_name,\n firstLine(comment_text) AS comment_text,\n comment_text AS comment_text_qttooltiprole,\n comment_user,\n CASE WHEN comment_source = 'OPP' THEN 'OPP-Opportunity'\n WHEN comment_source = 'T' THEN 'T-Contact'\n ELSE comment_source END AS comment_source,\n CASE WHEN cmnttype_name = 'Email Received' THEN 6.5\n WHEN cmnttype_name = 'Email Sent' THEN 3.5\n WHEN cmnttype_name = 'Internal Information' THEN 1\n WHEN cmnttype_name = 'Left Message' THEN 1\n WHEN cmnttype_name = 'Meeting' THEN 25\n WHEN cmnttype_name = 'Outside Meeting' THEN 35\n WHEN cmnttype_name = 'Phone Call' THEN 7\n WHEN cmnttype_name = 'Sample Confirmation' THEN 1\n WHEN cmnttype_name = 'Sample Request' THEN 10\n WHEN cmnttype_name = 'Sent Postcard' THEN 1\n WHEN cmnttype_name = 'Trade Show' THEN 15\n ELSE 0 END AS points,\n 'qty' AS points_xttotalrole,\n CASE\n-- Address\n WHEN comment_source = 'ADDR' THEN\n (SELECT addr_line1 || addr_line2 || addr_line3\n FROM addr\n WHERE ((addr_id = comment_source_id)\n AND (comment_source = 'ADDR')))\n\n-- BBOMHead\n \n WHEN (comment_source = 'BBH')THEN\n (SELECT item_descrip1 || ' - ' || item_number\n FROM xtmfg.bbomitem, item\n WHERE ((comment_source_id = bbomitem_id)\n AND (item_id = bbomitem_parent_item_id)\n AND (comment_source = 'BBH')))\n \n\n-- BBOMItem\n \n WHEN (comment_source = 'BBI') THEN\n (\n (SELECT 'Parent - ' || item.item_descrip1 || ' - ' || item.item_number\n FROM xtmfg.bbomitem, item\n WHERE ((comment_source_id = bbomitem_id)\n AND (item_id = bbomitem_parent_item_id)\n AND (comment_source = 'BBI')))\n || ' - ' ||\n (SELECT 'BBOM Item - ' || item.item_descrip1 || ' - ' || item.item_number\n FROM xtmfg.bbomitem, item\n WHERE ((comment_source_id = bbomitem_id)\n AND (item_id = bbomitem_item_id)\n AND (comment_source = 'BBI')))\n )\n \n\n-- BOMHead\n WHEN comment_source = 'BMH' THEN\n (SELECT item_descrip1 || ' - ' || item_number\n FROM item\n JOIN bomhead ON (bomhead_item_id = item_id)\n\n LEFT JOIN rev ON (rev_id = bomhead_rev_id)\n\n WHERE (comment_source_id = bomhead_item_id)\n AND (comment_source = 'BMH')\n\n AND (rev_status = 'A' OR coalesce(bomhead_rev_id, -1) < 0)\n\n )\n\n-- BOM Item\n WHEN comment_source = 'BMI' THEN\n (\n (SELECT 'Parent - ' || item.item_descrip1 || ' - ' || item.item_number FROM\n public.bomitem,\n public.item\n WHERE bomitem.bomitem_parent_item_id = item.item_id AND\n bomitem_id = comment_source_id\n AND comment_source = 'BMI')\n || ' - ' ||\n (SELECT 'BOM Item - ' || item.item_descrip1 || ' - ' || item.item_number FROM\n public.bomitem,\n public.item\n WHERE bomitem.bomitem_item_id = item.item_id AND\n bomitem_id = comment_source_id\n AND comment_source = 'BMI')\n )\n\n-- BOOHead\n \n WHEN (comment_source = 'BOH') THEN\n (SELECT item_descrip1 || ' - ' || item_number\n FROM xtmfg.boohead, item\n WHERE ((comment_source_id = boohead_item_id)\n AND (item_id = boohead_item_id)\n AND (comment_source = 'BOH')))\n \n\n-- BOOItem\n \n WHEN (comment_source = 'BOI') THEN\n (SELECT 'Item - ' || item.item_descrip1 || ' - ' ||item.item_number\n || ' - ' ||\n 'Operation - ' || booitem_descrip1\n FROM xtmfg.booitem, item\n WHERE ((xtmfg.booitem.booitem_item_id = item_id)\n AND (booitem_id = comment_source_id)\n AND (comment_source = 'BOI')))\n \n\n-- T Contact\n WHEN comment_source = 'T' THEN\n (SELECT cntct_first_name || ' ' || cntct_last_name FROM cntct\n WHERE cntct_id = comment_source_id\n AND comment_source = 'T'\n )\n-- Opportunity\n-- Put this back in after 3.8.0\n/*\n\tWHEN comment_source = 'OPP' THEN\n (\n SELECT ophead_name || ' Account: ' || crmacct_number || ' - ' || crmacct_name || ' Priority: ' || incdtpriority_name || ' - ' || ' Assigned To: ' || ophead_username\n FROM ophead\n LEFT OUTER JOIN crmacct ON (ophead_crmacct_id = crmacct_id)\n LEFT OUTER JOIN incdtpriority ON (ophead_priority_id = incdtpriority_id)\n WHERE\n comment_source = 'OPP'\n AND comment_source_id = ophead_id\n\t )\n*/\n-- Customer\n WHEN comment_source = 'C' THEN\n (SELECT cust_number || ' - ' || cust_name FROM custinfo WHERE (cust_id = comment_source_id) AND (comment_source = 'C'))\n\n-- Credit Memo - Return Auth\n \n WHEN comment_source = 'CRMA' THEN\n (SELECT 'Credit Memo: ' || cmhead_number || ' Return Auth: ' || rahead_number || ' Customer ' || cust_number || ' - ' || cust_name\n FROM rahead, cmhead, custinfo\n WHERE\n ((cmhead_rahead_id = rahead_id)\n AND (cmhead_cust_id = cust_id)\n AND (cmhead_id = comment_source_id)\n AND (comment_source = 'CRMA')))\n \n\n-- Employee\n WHEN comment_source = 'EMP' THEN\n (SELECT emp_code || '-' || emp_name\n FROM emp\n WHERE((comment_source_id = emp_id)\n AND (comment_source = 'EMP')))\n\n-- Incident\n WHEN comment_source = 'INCDT' THEN\n (\n SELECT incdt_number || ' - ' ||\n crmacct_number || ' - ' ||\n crmacct_name || ' - ' ||\n incdt_summary\n FROM incdt, crmacct\n WHERE\n incdt_id = comment_source_id\n AND crmacct_id = incdt_crmacct_id\n AND (comment_source = 'INCDT')\n )\n\n-- Item\n WHEN comment_source = 'I' THEN\n (SELECT item_number || ' - ' || item_descrip1\n FROM item WHERE item_id = comment_source_id\n AND (comment_source = 'I'))\n\n-- Item Site\n WHEN comment_source = 'IS' THEN\n (\n SELECT item_number || ' - ' || item_descrip1\n FROM item, itemsite\n WHERE itemsite_item_id = item_id\n AND itemsite_id = comment_source_id\n AND (comment_source = 'IS')\n )\n\n-- ItemSource\n WHEN comment_source = 'IR' THEN\n (\n SELECT item_number || ' - ' || item_descrip1\n FROM item, itemsrc\n WHERE itemsrc_item_id = item_id\n AND itemsrc_id = comment_source_id\n AND (comment_source = 'IR')\n )\n\n-- Location\n WHEN comment_source = 'L' THEN\n (SELECT location_name || ' - ' || location_descrip\n FROM location\n WHERE location_id = comment_source_id\n AND (comment_source = 'L'))\n\n-- LotSerial\n \n WHEN comment_source = 'LS' THEN\n (SELECT ls_number || '-' || item_number || '-' || item_descrip1 || item_descrip2\n FROM ls, item\n WHERE(ls_id = comment_source_id)\n AND(ls_item_id = item_id)\n AND (comment_source = 'LS'))\n \n-- Project\n WHEN comment_source = 'J' THEN\n (\n SELECT 'Project#: ' || prj_number || ' - Descrip: ' || prj_descrip ||\n ' - Status: ' || prj_status || ' - Owner: ' || prj_owner_username || '- Due: ' || prj_due_date\n FROM prj\n WHERE\n prj_id = comment_source_id\n AND (comment_source = 'J')\n )\n-- PO Head\n WHEN comment_source = 'P' THEN\n (\n SELECT pohead_number || ' - ' || vend_number || ' - ' || vend_name\n FROM pohead, vendinfo\n WHERE pohead_vend_id = vend_id\n AND comment_source_id = pohead_id\n AND (comment_source = 'P')\n )\n-- PO Item\n WHEN comment_source = 'PI' THEN\n (\n SELECT pohead_number || ' - ' || vend_number || ' - ' || vend_name || ' - ' ||\n (\n SELECT item_number || ' - ' || item_descrip1\n FROM poitem, itemsite, item\n WHERE poitem_itemsite_id = itemsite_id\n AND itemsite_item_id = item_id\n AND comment_source_id = poitem_id\n AND comment_source = 'PI'\n )\n || ' - ' || poitem_vend_item_number\n || ' - ' || poitem_vend_item_descrip\n FROM pohead, vendinfo, poitem\n WHERE pohead_vend_id = vend_id\n AND poitem_pohead_id = pohead_id\n AND comment_source_id = poitem_id\n AND comment_source = 'PI'\n )\n-- Quote Head\n WHEN comment_source = 'Q' THEN\n (\n SELECT 'Quote#: ' || quhead_number || ' - Customer: ' || cust_number || ' - ' || cust_name\n FROM quhead, custinfo\n WHERE quhead_cust_id = cust_id\n AND quhead_id = comment_source_id\n AND comment_source = 'Q'\n )\n-- Quote Item\n WHEN comment_source = 'QI' THEN\n (\n SELECT 'Quote#: ' || quhead_number || ' Customer ' || cust_number || ' - ' ||\n cust_name || ' Line #: ' || quitem_linenumber || ' - ' || ' Item#: ' || item_number || ' - ' || item_descrip1 || ' - Order Qty: ' || formatQty(quitem_qtyord)\n FROM quhead, quitem, item, itemsite, custinfo\n\n WHERE\n quitem_quhead_id = quhead_id\n AND quhead_cust_id = cust_id\n AND quitem_itemsite_id = itemsite_id\n AND itemsite_item_id = item_id\n AND quitem_id = comment_source_id\n AND comment_source = 'QI'\n )\n-- Return Auth Head\n \n WHEN comment_source = 'RA' THEN\n (\n SELECT rahead_number || ' - ' || cust_number || ' - ' || cust_name\n FROM rahead, custinfo\n WHERE rahead_cust_id = cust_id\n AND rahead_id = comment_source_id\n AND comment_source = 'RA'\n )\n \n-- SO Head\n WHEN comment_source = 'S' THEN\n (\n SELECT cohead_number || ' - ' || cust_number || ' - ' || cust_name\n FROM cohead, custinfo\n WHERE cohead_cust_id = cust_id\n AND cohead_id = comment_source_id\n AND comment_source = 'S'\n )\n-- SO Item\n WHEN comment_source = 'SI' THEN\n (\n SELECT 'Sales Order: ' || cohead_number || ' Customer ' || cust_number || ' - ' ||\n cust_name || ' Line #: ' || coitem_linenumber || ' - ' || ' Item#: ' || item_number || ' - ' || item_descrip1 || ' - Order Qty: ' || formatQty(coitem_qtyord)\n FROM cohead, coitem, item, itemsite, custinfo\n\n WHERE\n coitem_cohead_id = cohead_id\n AND cohead_cust_id = cust_id\n AND coitem_itemsite_id = itemsite_id\n AND itemsite_item_id = item_id\n AND coitem_id = comment_source_id\n AND comment_source = 'SI'\n )\n\n-- Task\n WHEN comment_source = 'TA' THEN\n (\n SELECT prj_number || '-' || prjtask_number || '-' || prjtask_name || '-' || prjtask_descrip\n FROM prjtask, prj\n WHERE((prjtask_prj_id = prj_id)\n AND(prjtask_id = comment_source_id)\n AND(comment_source = 'TA'))\n )\n\n--TodoItem\n WHEN comment_source = 'TD' THEN\n (\n SELECT todoitem_name || '-' || todoitem_description\n FROM todoitem\n WHERE((todoitem_id = comment_source_id)\n AND(comment_source = 'TD'))\n )\n\n--Transfer Order Header\n \n WHEN comment_source = 'TO' THEN\n (\n SELECT 'Transfer#: ' || tohead_number || ' - Status: ' || tohead_status || ' - Source / Dest: ' ||\n (SELECT warehous_code FROM whsinfo WHERE warehous_id = tohead_src_warehous_id) || ' / ' ||\n (SELECT warehous_code FROM whsinfo WHERE warehous_id = tohead_dest_warehous_id)\n FROM tohead\n WHERE tohead_id = comment_source_id\n AND comment_source = 'TO'\n )\n \n--Transfer Order item\n \n WHEN comment_source = 'TI' THEN\n (\n SELECT 'Transfer#: ' || tohead_number || ' - Status: ' || tohead_status || ' - Source / Dest: ' ||\n (SELECT warehous_code FROM whsinfo WHERE warehous_id = tohead_src_warehous_id) || ' / ' ||\n (SELECT warehous_code FROM whsinfo WHERE warehous_id = tohead_dest_warehous_id) ||\n ' - Item: ' || item_number || ' - ' || item_descrip1 || ' - Qty: ' || formatQty(toitem_qty_ordered)\n FROM tohead, toitem, item\n WHERE\n toitem_item_id = item_id\n AND toitem_tohead_id = tohead_id\n AND toitem_id = comment_source_id\n AND comment_source = 'TI'\n )\n \n-- Vendor\n WHEN comment_source = 'V' THEN\n (\n SELECT 'Vendor Name: ' || vend_name || ' - Vendor Number: ' || vend_number\n FROM vendinfo\n WHERE vend_id = comment_source_id\n AND comment_source = 'V'\n )\n\n-- Warehouse\n WHEN comment_source = 'WH' THEN\n (SELECT warehous_code || ' - ' || warehous_descrip\n FROM whsinfo WHERE warehous_id = comment_source_id\n AND comment_source = 'WH')\n\n-- Work Order\n WHEN comment_source = 'W' THEN\n (\n SELECT\n 'WO#: ' || wo_number || ' - ' ||\n wo_subnumber || ' - ' ||\n 'Status: ' || wo_status || ' - ' ||\n 'Ordered: ' || formatQty(wo_qtyord) || ' - ' ||\n 'Received: ' || formatQty(wo_qtyrcv) || ' - ' ||\n 'Item: ' || item_number || ' - ' ||\n item_descrip1\n FROM wo, itemsite, item\n WHERE wo_itemsite_id = itemsite_id\n AND itemsite_item_id = item_id\n AND wo_id = comment_source_id\n AND comment_source = 'W'\n )\n-- Unknown\n ELSE 'Unknown Comment Type'\n END AS info\nFROM\n comment, cmnttype\nWHERE\n comment_cmnttype_id = cmnttype_id\n \n AND cmnttype_id IN ()\n \n --Example: these are the names given to the various comment types like 'General' or "ChangeLog' or those defined by the user.\n --This query will give you a list of them:\n --SELECT DISTINCT cmnttype_name, cmnttype_name FROM cmnttype ORDER BY cmnttype_name;\n-- AND comment_text LIKE '%'\n --Example: 'Created%' for all comments that start with the work 'Created'\n --Example: '%question% for all comments that contain the word 'question' anywhere in the comment\n\n \n AND comment_user IN (SELECT usr_username FROM usr WHERE usr_id IN ())\n -- \n \n \n \n AND comment_user = current_user\n -- \n \n \n --This list will show you users who have at least one comment\n --SELECT DISTINCT comment_user FROM comment ORDER BY comment_user;\n \n AND comment_source IN (\n \n \n \n \n ,\n \n \n )\n \n --This query will show all comment sources for which there is a comment\n --SELECT DISTINCT comment_source FROM comment ORDER BY comment_source;\n --Example: Incidents = 'INCDT'\n AND CAST(comment_date AS DATE) BETWEEN AND \nORDER BY\n comment_date, comment_user, comment_source;\n \N \N 0 208 desktop contacts Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: contacts\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n cntct_id AS id, crmacct_number, crmacct_name,\n cntct.*, addr.*\nFROM cntct \n LEFT OUTER JOIN crmacct ON (crmacct_cntct_id_1=cntct_id) \n LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) \nWHERE (cntct_owner_username=getEffectiveXtUser())\nORDER BY cntct_name;\n \N \N 0 209 desktop crmaccounts Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: crmaccounts\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT \n crmacct_id AS id, crmacct_number, crmacct_name,\n cntct.*, addr.*\nFROM crmacct \n LEFT OUTER JOIN cntct ON (crmacct_cntct_id_1=cntct_id) \n LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) \nWHERE (crmacct_owner_username=getEffectiveXtUser())\nORDER BY crmacct_number;\n \N \N 0 210 desktop getDates Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: getDates\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT date_trunc(, current_date) AS startDate,\n date_trunc(, current_date) + + '-1 day' AS endDate\n \N \N 0 211 desktop glaccountBal tweak Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: glaccountBal\n-- Notes: tweak\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT accnt_id, formatGlAccount(accnt_id) AS accnt_id_qtdisplayrole, \n accnt_descrip, accnt_type,\n CASE WHEN(accnt_type='A') THEN \n WHEN(accnt_type='E') THEN \n WHEN(accnt_type='L') THEN \n WHEN(accnt_type='Q') THEN \n WHEN(accnt_type='R') THEN \n ELSE accnt_type\n END AS accnt_type_qtdisplayrole,\n CASE WHEN(accnt_type IN ('A','E')) THEN trialbal_ending * -1 \n ELSE trialbal_ending\n END AS balance,\n period_id,\n 'curr' AS balance_xtnumericrole\nFROM accnt \nJOIN trialbal ON (accnt_id=trialbal_accnt_id)\nJOIN (SELECT period_id\n FROM period\n JOIN yearperiod ON (period_yearperiod_id=yearperiod_id)\n WHERE (period_end >= current_date)\n ORDER BY yearperiod_end asc, period_number asc\n LIMIT 1) data\n ON (trialbal_period_id=period_id)\nWHERE (accnt_id IN ())\nORDER BY accnt_company, accnt_profit, accnt_number, accnt_sub\n \N \N 0 212 desktop glaccounts Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: glaccounts\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT accnt_id, formatGlAccount(accnt_id) AS accnt_id_qtdisplayrole, \n accnt_descrip, accnt_type,\n CASE WHEN(accnt_type='A') THEN \n WHEN(accnt_type='E') THEN \n WHEN(accnt_type='L') THEN \n WHEN(accnt_type='Q') THEN \n WHEN(accnt_type='R') THEN \n ELSE accnt_type\nEND AS accnt_type_qtdisplayrole \nFROM accnt;\t\n \N \N 0 228 desktop glforwardupdate Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: glforwardupdate\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT MIN(forwardUpdateAccount(accnt_id)) AS result \nFROM accnt \nWHERE (accnt_id IN ())\n \N \N 0 472 desktop messageHistory Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\r\n-- Name: messageHistory\r\n-- Notes:\r\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\r\n-- See www.xtuple.com/CPAL for the full text of the software license.\r\n\r\nSELECT \r\n msg_id, \r\n msg_posted AS sent,\r\n CASE WHEN (msg_username = geteffectivextuser()) THEN 'me'\r\n ELSE msg_username END AS from,\r\n msg_text AS message,\r\n CASE WHEN msguser_username = geteffectivextuser() THEN 'me'\r\n ELSE msguser_username END AS to\r\nFROM msg a\r\nLEFT OUTER JOIN msguser ab ON a.msg_id = ab.msguser_msg_id\r\nWHERE (a.msg_username = geteffectivextuser())\r\n\r\nUNION\r\n\r\nSELECT \r\n msg_id, \r\n msg_posted AS sent,\r\n CASE WHEN (msg_username = geteffectivextuser()) THEN 'me'\r\n ELSE msg_username END AS from,\r\n msg_text AS message,\r\n CASE WHEN msguser_username = geteffectivextuser() THEN 'me'\r\n ELSE msguser_username END AS to\r\nFROM msg c\r\nLEFT OUTER JOIN msguser cd ON c.msg_id = cd.msguser_msg_id\r\nWHERE (cd.msguser_username = geteffectivextuser())\r\n\r\nORDER BY msg_id DESC\r\nLIMIT \n \N \N 0 213 desktop mfgAct Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: mfgAct\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n \nSELECT 'L' AS activity, AS activity_qtdisplayrole, 0 AS seq,\n COUNT(planord_id) AS count, COALESCE(sum(stdcost(item_id) * planord_qty),0) AS amount, \n sum(planord_qty) AS qty,\n 'curr' AS amount_xtnumericrole, 'qty' AS qty_xtnumericrole\nFROM planord\n JOIN itemsite ON (planord_itemsite_id = itemsite_id)\n JOIN item ON (itemsite_item_id = item_id)\nWHERE (planord_type = 'W')\nHAVING (COUNT(planord_id) > 0)\nUNION\n\nSELECT 'O' AS activity, AS activity_qtdisplayrole, 4 AS seq, \n COUNT(wo_id) AS count, \n SUM(round((wo_qtyord - wo_qtyrcv) * stdcost(itemsite_item_id),2)) AS amount, \n SUM(wo_qtyord - wo_qtyrcv) AS qty,\n 'curr' AS amount_xtnumericrole, 'qty' AS qty_xtnumericrole\nFROM wo\n JOIN itemsite ON (wo_itemsite_id=itemsite_id)\nWHERE (wo_status = 'O')\nHAVING (COUNT(wo_id) > 0)\nUNION ALL\nSELECT 'E' AS activity, AS activity_qtdisplayrole, 4 AS seq, \n COUNT(wo_id) AS count, \n SUM(round((wo_qtyord - wo_qtyrcv) * stdcost(itemsite_item_id),2)) AS amount, \n SUM(wo_qtyord - wo_qtyrcv) AS qty,\n 'curr' AS amount_xtnumericrole, 'qty' AS qty_xtnumericrole\nFROM wo\n JOIN itemsite ON (wo_itemsite_id=itemsite_id)\nWHERE (wo_status = 'E')\nHAVING (COUNT(wo_id) > 0)\nUNION ALL\nSELECT 'R' AS activity, AS activity_qtdisplayrole, 4 AS seq, \n COUNT(wo_id) AS count, \n SUM(round((wo_qtyord - wo_qtyrcv) * stdcost(itemsite_item_id),2)) AS amount, \n SUM(wo_qtyord - wo_qtyrcv) AS qty,\n 'curr' AS amount_xtnumericrole, 'qty' AS qty_xtnumericrole\nFROM wo\n JOIN itemsite ON (wo_itemsite_id=itemsite_id)\nWHERE (wo_status = 'R')\nHAVING (COUNT(wo_id) > 0)\nUNION ALL\nSELECT 'I' AS activity, AS activity_qtdisplayrole, 4 AS seq, \n COUNT(wo_id) AS count, \n SUM(round((wo_qtyord - wo_qtyrcv) * stdcost(itemsite_item_id),2)) AS amount, \n SUM(wo_qtyord - wo_qtyrcv) AS qty,\n 'curr' AS amount_xtnumericrole, 'qty' AS qty_xtnumericrole\nFROM wo\n JOIN itemsite ON (wo_itemsite_id=itemsite_id)\nWHERE (wo_status = 'I')\nHAVING (COUNT(wo_id) > 0)\nORDER BY seq;\n \N \N 0 214 desktop mfgHist Summarized Manufacture History for Desktop Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: mfgHist\n-- Notes: Summarized Manufacture History for Desktop\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT , , ,\n sum(invhist_value_after-invhist_value_before) as amount, sum(invhist_qoh_after-invhist_qoh_before) AS qty,\n 'curr' AS amount_xtnumericrole,\n 'qty' AS qty_xtnumericrole,\n 0 AS amount_xttotalrole,\n 0 AS qty_xttotalrole\nFROM invhist\n JOIN itemsite ON (itemsite_id=invhist_itemsite_id)\n JOIN plancode ON (plancode_id=itemsite_plancode_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN classcode ON (classcode_id=item_classcode_id)\nWHERE ((invhist_transtype = 'RM')\n AND (invhist_ordtype = 'WO')\n AND ((invhist_transdate > DATE - 1 AND\n invhist_transdate < DATE + 1) )\n)\nGROUP BY , , \nORDER BY \n;\n \N \N 0 215 desktop mfgOpen Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: mfgOpen\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT wo_id,\n CASE WHEN (wo_ordid IS NULL) THEN -1\n ELSE wo_ordid\n END AS orderid, wo_status,\n CASE WHEN (wo_status = 'E') THEN \n WHEN (wo_status = 'I') THEN \n WHEN (wo_status = 'R') THEN \n WHEN (wo_status = 'O') THEN \n END AS wo_status_qtdisplayrole, \n warehous_code, uom_name,\n item_number, (item_descrip1 || ' ' || item_descrip2) AS itemdescrip,\n wo_qtyord, wo_qtyrcv, wo_startdate, wo_duedate,\n wo_number::TEXT || '-' || wo_subnumber::TEXT AS wonumber,\n wo_postedvalue, wo_wipvalue,\n 'qty' AS wo_qtyord_xtnumericrole,\n 'qty' AS wo_qtyrcv_xtnumericrole,\n 'curr' AS wo_postedvalue_xtnumericrole,\n 'curr' AS wo_wipvalue_xtnumericrole,\n CASE WHEN ((wo_startdate<=CURRENT_DATE) AND (wo_status IN ('O','E','S','R'))) THEN 'error'\n END AS wo_startdate_qtforegroundrole,\n CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'error'\n END AS wo_duedate_qtforegroundrole,\n CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'Overdue'\n ELSE 'On Time'\n END AS condition,\n CASE WHEN (wo_duedate<=CURRENT_DATE) THEN 'error' END AS condition_qtforegroundrole\nFROM wo\n JOIN itemsite ON (wo_itemsite_id=itemsite_id)\n JOIN whsinfo ON (itemsite_warehous_id=warehous_id)\n JOIN item ON (itemsite_item_id=item_id)\n JOIN uom ON (item_inv_uom_id=uom_id)\nWHERE (wo_status != 'C')\nORDER BY wo_number, wo_subnumber;\n \N \N 0 216 desktop payables Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: payables\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT formatMoney(sum(apaging_cur_val)) AS cur_val,\n formatMoney(sum(apaging_thirty_val)) AS thirty_val,\n formatMoney(sum(apaging_sixty_val)) AS sixty_val,\n formatMoney(sum(apaging_ninety_val)) AS ninety_val,\n formatMoney(sum(apaging_plus_val)) AS plus_val,\n formatMoney(sum(apaging_total_val)) AS total_val \nFROM apaging(current_date, false);\n \N \N 0 217 desktop pkgItems Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: pkgItems\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\nSELECT *,\n CASE WHEN pkgitem_type='P' THEN \n WHEN pkgitem_type='C' THEN \n WHEN pkgitem_type='D' THEN \n WHEN pkgitem_type='F' THEN \n WHEN pkgitem_type='G' THEN \n WHEN pkgitem_type='I' THEN \n WHEN pkgitem_type='M' THEN \n WHEN pkgitem_type='P' THEN \n WHEN pkgitem_type='R' THEN \n WHEN pkgitem_type='S' THEN \n WHEN pkgitem_type='T' THEN \n WHEN pkgitem_type='U' THEN \n WHEN pkgitem_type='V' THEN \n WHEN pkgitem_type='L' THEN \n WHEN pkgitem_type='B' THEN \n WHEN pkgitem_type='C' THEN \n ELSE pkgitem_type END AS pkgitem_type_qtdisplayrole\nFROM (\n------ PACKAGE ------\nSELECT pkghead_id AS pkgitem_id, 0 AS seq,\n 0 AS xtindentrole,\n pkghead_name AS pkgname,\n 'P'::text AS pkgitem_type,\n pkghead_name AS pkgitem_name,\n pkghead_descrip AS pkgitem_descrip\n FROM pkghead\nUNION\n\n------ CLIENT ------\nSELECT pkghead_id AS pkgitem_id, 1 AS seq,\n 1 AS xtindentrole,\n pkghead_name AS pkgname,\n 'L'::text AS pkgitem_type,\n AS pkgitem_name,\n '' AS pkgitem_descrip\n FROM pkghead\nUNION\n------ COMMANDS ------\nSELECT pkghead_id AS pkgitem_id, 2 AS seq,\n 2 AS xtindentrole,\n pkghead_name AS pkgname,\n 'L'::text AS pkgitem_type,\n AS pkgitem_name,\n '' AS pkgitem_descrip\n FROM pkghead\nUNION \nSELECT cmd_id AS pkgitem_id, 3 AS seq,\n 3 AS xtindentrole,\n nspname AS pkgname,\n 'D' AS pkgitem_type,\n cmd_name AS pkgitem_name,\n cmd_descrip AS pkgitem_descrip \n FROM cmd\n JOIN pg_class ON (cmd.tableoid=pg_class.oid)\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nUNION\n------ IMAGES ------\nSELECT pkghead_id AS pkgitem_id, 4 AS seq,\n 2 AS xtindentrole,\n pkghead_name AS pkgname,\n 'L'::text AS pkgitem_type,\n AS pkgitem_name,\n '' AS pkgitem_descrip\n FROM pkghead\nUNION \nSELECT image_id AS pkgitem_id, 5 AS seq,\n 3 AS xtindentrole,\n nspname AS pkgname,\n 'I'::text AS pkgitem_type,\n image_name AS pkgitem_name,\n image_descrip AS pkgitem_descrip \n FROM image\n JOIN pg_class ON (image.tableoid=pg_class.oid)\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nUNION \n------ METASQL ------\nSELECT pkghead_id AS pkgitem_id, 6 AS seq,\n 2 AS xtindentrole,\n pkghead_name AS pkgname,\n 'L'::text AS pkgitem_type,\n AS pkgitem_name,\n '' AS pkgitem_descrip\n FROM pkghead\nUNION\nSELECT metasql_id AS pkgitem_id, 7 AS seq,\n 3 AS xtindentrole,\n nspname AS pkgname,\n 'M' AS pkgitem_type,\n metasql_group || '-' || metasql_name AS pkgitem_name,\n metasql_notes AS pkgitem_descrip \n FROM metasql\n JOIN pg_class ON (metasql.tableoid=pg_class.oid)\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nUNION\n------ PRIVILEGES ------\nSELECT pkghead_id AS pkgitem_id, 8 AS seq,\n 2 AS xtindentrole,\n pkghead_name AS pkgname,\n 'L'::text AS pkgitem_type,\n AS pkgitem_name,\n '' AS pkgitem_descrip\n FROM pkghead\nUNION\nSELECT pkghead_id AS pkgitem_id, 9 AS seq,\n 3 AS xtindentrole,\n nspname AS pkgname,\n 'P' AS pkgitem_type,\n priv_module || '.' || priv_name AS pkgitem_name,\n priv_descrip AS pkgitem_descrip \n FROM priv\n JOIN pg_class ON (priv.tableoid=pg_class.oid)\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n JOIN pkghead ON (nspname=pkghead_name)\nUNION \n------ REPORTS ------\nSELECT pkghead_id AS pkgitem_id, 10 AS seq,\n 2 AS xtindentrole,\n pkghead_name AS pkgname,\n 'L'::text AS pkgitem_type,\n AS pkgitem_name,\n '' AS pkgitem_descrip\n FROM pkghead\nUNION\nSELECT report_id AS pkgitem_id, 11 AS seq,\n 3 AS xtindentrole,\n nspname AS pkgname,\n 'R' AS pkgitem_type,\n report_name AS pkgitem_name,\n report_descrip AS pkgitem_descrip \n FROM report\n JOIN pg_class ON (report.tableoid=pg_class.oid)\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid) \nUNION\n------ SCRIPTS ------\nSELECT pkghead_id AS pkgitem_id, 12 AS seq,\n 2 AS xtindentrole,\n pkghead_name AS pkgname,\n 'L'::text AS pkgitem_type,\n AS pkgitem_name,\n '' AS pkgitem_descrip\n FROM pkghead\nUNION\nSELECT script_id AS pkgitem_id, 13 AS seq,\n 3 AS xtindentrole,\n nspname AS pkgname,\n 'C'::text AS pkgitem_type,\n script_name AS pkgitem_name,\n script_notes AS pkgitem_descrip\n FROM script\n JOIN pg_class ON (script.tableoid=pg_class.oid)\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nUNION\n------ SCREENS ------\nSELECT pkghead_id AS pkgitem_id, 14 AS seq,\n 2 AS xtindentrole,\n pkghead_name AS pkgname,\n 'L'::text AS pkgitem_type,\n AS pkgitem_name,\n '' AS pkgitem_descrip\n FROM pkghead\nUNION\nSELECT uiform_id AS pkgitem_id, 15 AS seq,\n 3 AS xtindentrole,\n nspname AS pkgname,\n 'U'::text AS pkgitem_type,\n uiform_name AS pkgitem_name,\n uiform_notes AS pkgitem_descrip\n FROM uiform\n JOIN pg_class ON (uiform.tableoid=pg_class.oid)\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\nUNION\n------ DATABASE ------\nSELECT pkghead_id AS pkgitem_id, 20 AS seq, \n 1 AS xtindentrole,\n pkghead_name AS pkgname,\n 'B'::text AS pkgitem_type,\n AS pkgitem_name,\n '' AS pkgitem_descrip\n FROM pkghead\nUNION\n------ FUNCTIONS ------\nSELECT pkghead_id AS pkgitem_id, 21 AS seq,\n 2 AS xtindentrole,\n pkghead_name AS pkgname,\n 'L'::text AS pkgitem_type,\n AS pkgitem_name,\n '' AS pkgitem_descrip\n FROM pkghead\nUNION\nSELECT pg_proc.oid AS pkgitem_id, 22 AS seq,\n 3 AS xtindentrole,\n nspname AS pkgname,\n 'F' AS pkgitem_type,\n proname || '(' || oidvectortypes(proargtypes)\n || ')' AS pkgitem_name,\n pg_catalog.obj_description(pg_proc.oid, 'pg_proc') AS pkgitem_descrip \n FROM pg_proc\n JOIN pg_namespace ON (pronamespace=pg_namespace.oid)\nUNION\n------ SCHEMA ------\nSELECT pkghead_id AS pkgitem_id, 27 AS seq,\n 2 AS xtindentrole,\n pkghead_name AS pkgname,\n 'L'::text AS pkgitem_type,\n AS pkgitem_name,\n '' AS pkgitem_descrip\n FROM pkghead\nUNION\nSELECT n.oid AS pkgitem_id, 28 AS seq,\n 3 AS xtindentrole,\n nspname AS pkgname,\n 'S' AS pkgitem_type,\n nspname AS pkgitem_name,\n pg_catalog.obj_description(n.oid, 'pg_namespace') AS pkgitem_descrip \n FROM pg_namespace n\nUNION\n------ TABLES ------\nSELECT pkghead_id AS pkgitem_id, 29 AS seq,\n 2 AS xtindentrole,\n pkghead_name AS pkgname,\n 'L'::text AS pkgitem_type,\n AS pkgitem_name,\n '' AS pkgitem_descrip\n FROM pkghead\nUNION\nSELECT c.oid AS pkgitem_id, 30 AS seq,\n 3 AS xtindentrole,\n nspname AS pkgname,\n 'T' AS pkgitem_type,\n relname AS pkgitem_name,\n pg_catalog.obj_description(c.oid, 'pg_class') AS pkgitem_descrip \n FROM pg_class c\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n WHERE ((relkind='r')\n AND (relname !~ '^pkg(cmd(arg)?|image|metasql|priv|report|script|uiform)$'))\nUNION\n------ TRIGGERS ------\nSELECT pkghead_id AS pkgitem_id, 31 AS seq,\n 2 AS xtindentrole,\n pkghead_name AS pkgname,\n 'L'::text AS pkgitem_type,\n AS pkgitem_name,\n '' AS pkgitem_descrip\n FROM pkghead\nUNION\nSELECT 0 AS pkgitem_id, 32 AS seq,\n 3 AS xtindentrole,\n trigger_schema AS pkgname,\n 'G' AS pkgitem_type,\n trigger_name AS pkgitem_name,\n event_object_table AS pkgitem_descrip \n FROM information_schema.triggers\n WHERE (trigger_name !~ '^pkg(cmd(arg)?|image|metasql|priv|report|script|uiform)')\nUNION\n------ VIEWS ------\nSELECT pkghead_id AS pkgitem_id, 33 AS seq,\n 2 AS xtindentrole,\n pkghead_name AS pkgname,\n 'L'::text AS pkgitem_type,\n AS pkgitem_name,\n '' AS pkgitem_descrip\n FROM pkghead\nUNION\nSELECT c.oid AS pkgitem_id, 34 AS seq,\n 3 AS xtindentrole,\n nspname AS pkgname,\n 'V' AS pkgitem_type,\n relname AS pkgitem_name,\n pg_catalog.obj_description(c.oid, 'pg_class') AS pkgitem_descrip \n FROM pg_class c\n JOIN pg_namespace ON (relnamespace=pg_namespace.oid)\n WHERE ((relkind='v'))\n) AS pkgitem \nWHERE (pkgname NOT IN ('api','public','pg_catalog'))\nORDER BY pkgname, seq, pkgitem_type_qtdisplayrole, pkgitem_name;\n \N \N 0 218 desktop purchAct Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: purchAct\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n \nSELECT 'L' AS activity, AS activity_qtdisplayrole, 0 AS seq,\n COUNT(planord_id) AS count, COALESCE(sum(stdcost(item_id) * planord_qty),0) AS amount, \n 'curr' AS amount_xtnumericrole\nFROM planord\n JOIN itemsite ON (planord_itemsite_id = itemsite_id)\n JOIN item ON (itemsite_item_id = item_id)\nWHERE (planord_type = 'P')\nHAVING (COUNT(planord_id) > 0)\nUNION\n\nSELECT 'Q' AS activity, AS activity_qtdisplayrole, 2 AS seq,\n COUNT(pr_id) AS count, COALESCE(sum(stdcost(item_id) * pr_qtyreq),0) AS amount, \n 'curr' AS amount_xtnumericrole\nFROM pr\n JOIN itemsite ON (pr_itemsite_id = itemsite_id)\n JOIN item ON (itemsite_item_id = item_id)\nHAVING (COUNT(pr_id) > 0)\nUNION\nSELECT 'U' AS activity, AS activity_qtdisplayrole, 3 AS seq, \n COUNT(pohead_id) AS count, COALESCE(sum(amount),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM\n (SELECT pohead_id,\n SUM(round((noNeg(poitem_qty_ordered - poitem_qty_received + poitem_qty_returned)) * \n currToBase(pohead_curr_id, poitem_unitprice, pohead_orderdate), 2) ) AS amount\n FROM poitem\n JOIN pohead ON (poitem_pohead_id=pohead_id)\n WHERE (pohead_status = 'U')\n GROUP BY pohead_id) data\nHAVING (COUNT(pohead_id) > 0)\nUNION\nSELECT 'O' AS activity, AS activity_qtdisplayrole, 4 AS seq, \n COUNT(pohead_id) AS count, COALESCE(sum(amount),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM\n (SELECT pohead_id,\n SUM(round((noNeg(poitem_qty_ordered - poitem_qty_received + poitem_qty_returned)) * \n currToBase(pohead_curr_id, poitem_unitprice, pohead_orderdate), 2) ) AS amount\n FROM poitem\n JOIN pohead ON (poitem_pohead_id=pohead_id)\n WHERE (pohead_status = 'O')\n GROUP BY pohead_id) data\nHAVING (COUNT(pohead_id) > 0)\nUNION\nSELECT 'A' AS activity, AS activity_qtdisplayrole, 5 AS seq, \n COUNT(recv_id) AS count, COALESCE(sum(recv_value),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM recv\nWHERE (NOT recv_posted)\nHAVING (COUNT(recv_id) > 0)\nUNION\nSELECT 'V' AS activity, AS activity_qtdisplayrole, 6 AS seq, \n COUNT(recv_id) AS count, COALESCE(sum(recv_value),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM recv\nWHERE ((recv_posted)\n AND (NOT recv_invoiced)\n AND (recv_vohead_id IS NULL)\n AND (recv_order_type = 'PO'))\nHAVING (COUNT(recv_id) > 0)\nUNION\nSELECT 'I' AS activity, AS activity_qtdisplayrole, 7 AS seq, \n COUNT(vohead_id) AS count, COALESCE(sum(amount),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM\n (SELECT vohead_id,\n SUM(round(currToBase(vohead_curr_id, vodist_amount, vohead_docdate), 2) ) AS amount\n FROM vohead\n JOIN vodist ON (vodist_vohead_id=vohead_id)\n WHERE ((vohead_pohead_id != -1)\n AND (NOT vohead_posted))\n GROUP BY vohead_id) data\nHAVING (COUNT(vohead_id) > 0)\nORDER BY seq;\n \N \N 0 219 desktop purchHist Summarized Purchase History for Desktop Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: purchHist\n-- Notes: Summarized Purchase History for Desktop\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n--------- VARIANCES -----------\n \nSELECT , , ,\n sum(qty) AS qty, sum(amount) AS amount,\n 'curr' AS amount_xtnumericrole,\n 'qty' AS qty_xtnumericrole,\n 0 AS amount_xttotalrole,\n 0 AS qty_xttotalrole\nFROM (\nSELECT vend_id, vend_number, vend_name,\n pohead_agent_username, usr_propername,\n COALESCE(item_id,-2) AS item_id,\n COALESCE(item_number,) AS item_number,\n item_descrip1,\n recv_qty AS qty, \n currToBase(vohead_curr_id, sum(vodist_amount) / sum(vodist_qty), vohead_distdate) * recv_qty - recv_value AS amount\nFROM recv\n JOIN vendinfo ON (recv_vend_id=vend_id)\n LEFT OUTER JOIN itemsite ON (recv_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id=item_id)\n JOIN vodist ON ((vodist_poitem_id=recv_orderitem_id) \n AND (vodist_vohead_id=recv_vohead_id))\n JOIN vohead ON ((vodist_vohead_id=vohead_id) \n AND (vohead_posted))\n JOIN poitem ON (recv_orderitem_id=poitem_id)\n JOIN pohead ON (poitem_pohead_id=pohead_id)\n LEFT OUTER JOIN usr ON (pohead_agent_username=usr_username)\nWHERE (vohead_distdate BETWEEN AND \n AND (recv_order_type='PO'))\nGROUP BY recv_qty, recv_value, vohead_curr_id, vohead_distdate,\n vend_id, vend_number, vend_name,\n pohead_agent_username, usr_propername,\n item_id, item_number, item_descrip1\n) data\nWHERE (amount > 0)\nGROUP BY , , \n\n--------- RECEIPTS -------\n \nSELECT , , ,\n sum(amount) as amount, sum(qty) AS qty,\n 'curr' AS amount_xtnumericrole,\n 'qty' AS qty_xtnumericrole,\n 0 AS amount_xttotalrole,\n 0 AS qty_xttotalrole\nFROM (\n SELECT vend_id, vend_number, vend_name,\n pohead_agent_username, usr_propername,\n COALESCE(item_id,-2) AS item_id, COALESCE(item_number,) AS item_number,\n item_descrip1,\n coalesce(recv_value,0) AS amount,\n recv_qty AS qty\n FROM recv\n JOIN vendinfo ON (vend_id=recv_vend_id)\n LEFT OUTER JOIN itemsite ON (recv_itemsite_id=itemsite_id)\n LEFT OUTER JOIN item ON (itemsite_item_id=item_id)\n JOIN poitem ON (recv_orderitem_id=poitem_id)\n JOIN pohead ON (poitem_pohead_id=pohead_id)\n LEFT OUTER JOIN usr ON (pohead_agent_username=usr_username)\n WHERE ((recv_date::date BETWEEN AND )\n AND (recv_posted)\n AND (recv_order_type = 'PO'))\n UNION ALL\n SELECT vend_id, vend_number, vend_name,\n pohead_agent_username, usr_propername,\n COALESCE(item_id,-1) AS item_id, COALESCE(item_number,) AS item_number,\n item_descrip1,\n coalesce(poreject_value,0) * -1 AS amount,\n poreject_qty * -1 AS qty\n FROM poreject\n JOIN vendinfo ON (vend_id=poreject_vend_id)\n JOIN itemsite ON (itemsite_id=poreject_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN poitem ON (poreject_poitem_id=poitem_id)\n JOIN pohead ON (poitem_pohead_id=pohead_id)\n LEFT OUTER JOIN usr ON (pohead_agent_username=usr_username)\n WHERE ((poreject_date::date BETWEEN AND )\n AND (poreject_posted))\n) data\nGROUP BY , , \nORDER BY \n;\n\n \N \N 0 220 desktop purchOpen Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: purchOpen\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT pohead_id, pohead_number, vend_number, vend_name, pohead_shipvia, \n formatCntctName(pohead_vend_cntct_honorific, \n pohead_vend_cntct_first_name, \n pohead_vend_cntct_middle, \n pohead_vend_cntct_last_name, \n pohead_vend_cntct_suffix) AS vend_cntct, \n pohead_vend_cntct_phone,\n formatCntctName(pohead_shipto_cntct_honorific, \n pohead_shipto_cntct_first_name, \n pohead_shipto_cntct_middle, \n pohead_shipto_cntct_last_name, \n pohead_shipto_cntct_suffix) AS shipto_cntct, \n pohead_shipto_cntct_phone,\n min(poitem_duedate) AS duedate, pohead_status AS status,\n CASE WHEN (pohead_status = 'O') THEN \n ELSE END AS status_qtdisplayrole,\n SUM(round(noNeg(poitem_qty_ordered - poitem_qty_received + poitem_qty_returned) * \n currToBase(pohead_curr_id, poitem_unitprice, pohead_orderdate), 2) ) AS amount,\n CASE WHEN (min(poitem_duedate) <= current_date) THEN 'error' \n ELSE 'emphasis' END AS duedate_qtforegroundrole,\n 'curr' AS amount_xtnumericrole\nFROM pohead \n JOIN vendinfo ON (pohead_vend_id=vend_id) \n JOIN poitem ON (poitem_pohead_id=pohead_id) \nWHERE (poitem_status IN ('U','O'))\nGROUP BY pohead_id, pohead_number, pohead_status, vend_number, vend_name, pohead_shipvia, pohead_vend_cntct_id, \n pohead_shipto_cntct_id, pohead_vend_cntct_phone, pohead_shipto_cntct_phone, pohead_vend_cntct_honorific, \n pohead_vend_cntct_first_name, pohead_vend_cntct_middle, pohead_vend_cntct_last_name, pohead_vend_cntct_suffix,\n pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name, pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name, \n pohead_shipto_cntct_suffix\nORDER BY pohead_number;\t\n \N \N 0 221 desktop receivables Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: receivables\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT formatMoney(sum(araging_cur_val)) AS cur_val,\n formatMoney(sum(araging_thirty_val)) AS thirty_val,\n formatMoney(sum(araging_sixty_val)) AS sixty_val,\n formatMoney(sum(araging_ninety_val)) AS ninety_val,\n formatMoney(sum(araging_plus_val)) AS plus_val,\n formatMoney(sum(araging_total_val)) AS total_val \nFROM araging(current_date, false);\n \N \N 0 222 desktop salesAct Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: salesAct\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT 'Q' AS activity, AS activity_qtdisplayrole, 0 AS seq,\n COUNT(quhead_id) AS count, COALESCE(sum(amount),0) AS amount, 'curr' AS amount_xtnumericrole \nFROM \n (SELECT quhead_id,\n SUM(round((noNeg(quitem_qtyord) * quitem_qty_invuomratio) * \n (currToBase(quhead_curr_id, quitem_price, quhead_quotedate) / quitem_price_invuomratio), 2) ) AS amount\n FROM quitem\n JOIN quhead ON (quitem_quhead_id=quhead_id)\n WHERE ( COALESCE(quhead_expire,current_date + 1) > current_date\n AND quhead_status != 'C' )\n GROUP BY quhead_id) data\nHAVING (COUNT(quhead_id) > 0)\nUNION \nSELECT 'O' AS activity, AS activity_qtdisplayrole, 1 AS seq, \n COUNT(cohead_id) AS count, COALESCE(sum(amount),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM\n (SELECT cohead_id,\n SUM(round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) * \n (currToBase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) ) AS amount\n FROM coitem\n JOIN cohead ON (coitem_cohead_id=cohead_id)\n WHERE ( coitem_status = 'O' )\n GROUP BY cohead_id) data\nHAVING (COUNT(cohead_id) > 0)\nUNION\nSELECT 'P' AS activity, AS activity_qtdisplayrole, 2 AS seq, \n COUNT(cohead_id) AS count, COALESCE(sum(amount),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM\n (SELECT cohead_id,\n SUM(round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) * \n (currToBase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) ) AS amount\n FROM coitem\n JOIN cohead ON (coitem_cohead_id=cohead_id)\n JOIN pack ON ((pack_head_type='SO')\n AND (pack_head_id=cohead_id))\n WHERE ( (coitem_status = 'O')\n AND (NOT pack_printed) )\n GROUP BY cohead_id) data\nHAVING (COUNT(cohead_id) > 0)\nUNION\nSELECT 'S' AS activity, AS activity_qtdisplayrole, 3 AS seq, \n COUNT(cohead_id) AS count, COALESCE(sum(amount),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM\n (SELECT cohead_id,\n SUM(round((shipitem_qty * coitem_qty_invuomratio) * \n (currToBase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) ) AS amount\n FROM coitem\n JOIN cohead ON (coitem_cohead_id=cohead_id)\n JOIN shipitem ON (shipitem_orderitem_id=coitem_id)\n JOIN shiphead ON ((shiphead_order_type='SO')\n AND (shipitem_shiphead_id=shiphead_id))\n WHERE ( (coitem_status = 'O')\n AND (NOT shiphead_shipped) )\n GROUP BY cohead_id) data\nHAVING (COUNT(cohead_id) > 0)\nUNION\nSELECT 'B' AS activity, AS activity_qtdisplayrole, 4 AS seq, \n COUNT(cohead_id) AS count, COALESCE(sum(amount),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM\n (SELECT cohead_id,\n CASE WHEN ( \n -- For kits only when entire kit has shipped\n item_type != 'K' OR NOT coitem_id IN (\n SELECT sub.coitem_id\n FROM coitem sub\n WHERE((sub.coitem_cohead_id=coitem_cohead_id)\n AND (sub.coitem_linenumber=coitem_linenumber)\n AND (sub.coitem_subnumber > 0)\n AND ((sub.coitem_qtyord - sub.coitem_qtyshipped + sub.coitem_qtyreturned) > 0))\n )) THEN\n -- Total shipped not invoiced minus any already selected for billing not invoiced\n SUM(round(((shipitem_qty -\n COALESCE((SELECT sum(cobill_qty) \n FROM cobill \n WHERE ((cobill_coitem_id=coitem_id \n AND (cobill_invcitem_id IS NULL)\n ))),0) \n * coitem_qty_invuomratio) * \n (currToBase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio)),2))\n ELSE 0\n END AS amount\n FROM coitem\n JOIN itemsite ON (coitem_itemsite_id=itemsite_id)\n JOIN item ON (itemsite_item_id=item_id)\n JOIN cohead ON (coitem_cohead_id=cohead_id)\n JOIN custinfo ON (cust_id=cohead_cust_id)\n JOIN shipitem ON (shipitem_orderitem_id=coitem_id)\n JOIN shiphead ON ((shiphead_order_type='SO')\n AND (shiphead_id=shipitem_shiphead_id))\n WHERE ( (coitem_cohead_id=cohead_id)\n AND (coitem_status = 'O')\n AND (shiphead_shipped)\n AND (NOT shipitem_invoiced)\n AND (shipitem_qty > COALESCE((SELECT sum(cobill_qty)\n FROM cobill\n WHERE cobill_coitem_id=coitem_id AND cobill_invcitem_id IS NULL), 0)) )\n GROUP BY cohead_id, coitem_id, coitem_qtyord, coitem_qtyshipped, coitem_qtyreturned, \n cust_partialship, item_type) data\nHAVING (COUNT(cohead_id) > 0)\nUNION\nSELECT 'I' AS activity, AS activity_qtdisplayrole, 5 AS seq, \n COUNT(cohead_id) AS count, COALESCE(sum(amount),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM\n (SELECT cohead_id,\n SUM(round((cobill_qty * coitem_qty_invuomratio) * \n (currToBase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) ) AS amount\n FROM coitem\n JOIN cohead ON (coitem_cohead_id=cohead_id)\n JOIN cobill ON (cobill_coitem_id=coitem_id)\n WHERE ( (coitem_status = 'O')\n AND (cobill_invcitem_id IS NULL) )\n GROUP BY cohead_id) data\nHAVING (COUNT(cohead_id) > 0)\nUNION\nSELECT 'T' AS activity, AS activity_qtdisplayrole, 5 AS seq, \n COUNT(invchead_id) AS count, COALESCE(sum(amount),0) AS amount, 'curr' AS amount_xtnumericrole\nFROM\n (SELECT invchead_id,\n SUM(round((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / COALESCE(invcitem_price_invuomratio,1)),2)\n ) AS amount\n FROM invcitem\n JOIN invchead ON (invcitem_invchead_id=invchead_id)\n WHERE ( NOT invchead_posted )\n GROUP BY invchead_id) data\nHAVING (COUNT(invchead_id) > 0)\nORDER BY seq;\n \N \N 0 223 desktop salesHist Summarized Sales History for Desktop Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: salesHist\n-- Notes: Summarized Sales History for Desktop\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n--------- BOOKINGS -----------\n\nSELECT , , ,\n sum(round((coitem_qtyord * coitem_qty_invuomratio) *\n (currtobase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2)) AS amount,\n sum(coitem_qtyord) AS qty,\n 'curr' AS amount_xtnumericrole,\n 'qty' AS qty_xtnumericrole,\n 0 AS amount_xttotalrole,\n 0 AS qty_xttotalrole\nFROM coitem\n JOIN cohead ON (coitem_cohead_id=cohead_id)\n JOIN custinfo ON (cust_id=cohead_cust_id)\n JOIN salesrep ON (salesrep_id=cohead_salesrep_id)\n JOIN itemsite ON (itemsite_id=coitem_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN prodcat ON (item_prodcat_id=prodcat_id)\nWHERE (cohead_orderdate BETWEEN AND )\nAND (coitem_status != 'X')\nGROUP BY , , \nORDER BY ;\n\n--------- SALES HISTORY -------\n \nSELECT , , ,\n sum(round((cohist_qtyshipped * currtobase(cohist_curr_id, cohist_unitprice, cohist_invcdate)), 2)) AS amount,\n sum(cohist_qtyshipped) AS qty,\n 'curr' AS amount_xtnumericrole,\n 'qty' AS qty_xtnumericrole,\n 0 AS amount_xttotalrole,\n 0 AS qty_xttotalrole\nFROM cohist \n JOIN custinfo ON (cust_id=cohist_cust_id)\n JOIN salesrep ON (salesrep_id=cohist_salesrep_id)\n JOIN itemsite ON (itemsite_id=cohist_itemsite_id)\n JOIN item ON (item_id=itemsite_item_id)\n JOIN prodcat ON (item_prodcat_id=prodcat_id)\nWHERE (cohist_invcdate BETWEEN AND )\nGROUP BY , , \nORDER BY ;\n\n \N \N 0 224 desktop salesOpen Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. Change from showing open amount to total amount -- Group: desktop\n-- Name: salesOpen\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n-- Change from showing open amount to total amount\n\nSELECT cohead_id, cohead_number, cust_number, cohead_shipvia, \n cohead_billtoname, \n formatCntctName(cohead_billto_cntct_honorific, \n cohead_billto_cntct_first_name, \n cohead_billto_cntct_middle, \n cohead_billto_cntct_last_name, \n cohead_billto_cntct_suffix) AS billto_cntct, \n cohead_billto_cntct_phone,\n cohead_shiptoname, \n formatCntctName(cohead_shipto_cntct_honorific, \n cohead_shipto_cntct_first_name, \n cohead_shipto_cntct_middle, \n cohead_shipto_cntct_last_name, \n cohead_shipto_cntct_suffix) AS shipto_cntct, \n cohead_shipto_cntct_phone,\n getSoSchedDate(cohead_id) AS scheddate, \n calcSalesOrderAmt(cohead_id) AS amount,\n CASE WHEN (getSoSchedDate(cohead_id) <= current_date) THEN 'error' \n ELSE 'emphasis' END AS scheddate_qtforegroundrole,\n 'curr' AS amount_xtnumericrole\nFROM cohead \n JOIN custinfo ON (cohead_cust_id=cust_id) \nWHERE (cohead_status='O')\nORDER BY cohead_number;\n\n-- min(coitem_scheddate) AS scheddate, \n-- sum(round((noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) * \n-- (currToBase(cohead_curr_id, coitem_price, cohead_orderdate) / coitem_price_invuomratio), 2) ) AS amount,\n-- CASE WHEN (min(coitem_scheddate) <= current_date) THEN 'error' \n-- ELSE 'emphasis' END AS scheddate_qtforegroundrole,\n-- 'curr' AS amount_xtnumericrole\n--FROM cohead \n-- JOIN custinfo ON (cohead_cust_id=cust_id) \n-- JOIN coitem ON (coitem_cohead_id=cohead_id) \n-- JOIN itemsite ON (coitem_itemsite_id=itemsite_id) \n-- JOIN whsinfo ON (itemsite_warehous_id=warehous_id) \n--WHERE (coitem_status='O')\n--GROUP BY cohead_shipvia, cohead_billtoname, cohead_billto_cntct_id, cohead_billto_cntct_phone, \n-- cohead_shiptoname, cohead_shipto_cntct_id, cohead_shipto_cntct_phone, cohead_id, cohead_number, \n-- cust_number, cohead_billtoname, cohead_shiptoname, \n-- cohead_billto_cntct_honorific, cohead_billto_cntct_first_name, \n-- cohead_billto_cntct_middle, cohead_billto_cntct_last_name, cohead_billto_cntct_suffix,\n-- cohead_shipto_cntct_honorific, cohead_shipto_cntct_first_name, cohead_shipto_cntct_middle, \n-- cohead_shipto_cntct_last_name, cohead_shipto_cntct_suffix\n--ORDER BY cohead_number;\n \N \N 0 473 desktop sendMessageToUser User Message query. Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\r\n-- Name: sendMessageToUser\r\n-- Notes: User Message query.\r\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\r\n-- See www.xtuple.com/CPAL for the full text of the software license.\r\n\r\nSELECT \r\npostmessage(\r\n( SELECT usr_username FROM usr WHERE usr_id = ),\r\n \r\n );\n \N \N 0 225 desktop todoDelete Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: todoDelete\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nDELETE FROM todoitem WHERE (todoitem_id=);\n \N \N 0 226 desktop todoList Select the list of activities that need attention including to-do items, incidents, tasks, and projects. Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: todoList\n-- Notes: Select the list of activities that need attention\n-- including to-do items, incidents, tasks, and projects.\n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\n------ TO DO ITEMS-------\n SELECT todoitem_id AS id, 1 AS altId, todoitem_owner_username AS owner, \n AS type, incdtpriority_order AS seq,\n incdtpriority_name AS priority, \n todoitem_name AS name, \n firstLine(todoitem_description) AS descrip, \n todoitem_status AS status, todoitem_start_date as start, \n todoitem_due_date AS due, \n todoitem_username AS usr, CAST(incdt_number AS text) AS number,\n crmacct_number, crmacct_name, \n cust_number AS cust,\n CASE WHEN (todoitem_status != 'C'AND \n todoitem_due_date < CURRENT_DATE) THEN 'expired'\n WHEN (todoitem_status != 'C'AND \n todoitem_due_date > CURRENT_DATE) THEN 'future'\n END AS due_qtforegroundrole \n FROM todoitem LEFT OUTER JOIN incdt ON (incdt_id=todoitem_incdt_id) \n LEFT OUTER JOIN crmacct ON (crmacct_id=todoitem_crmacct_id) \n LEFT OUTER JOIN custinfo ON (cust_id=crmacct_cust_id) \n LEFT OUTER JOIN incdtpriority ON (incdtpriority_id=todoitem_priority_id) \n WHERE ((todoitem_active)\n AND (todoitem_status != 'C')\n AND ((todoitem_owner_username=) \n OR (todoitem_username=))) \n UNION \n------ INCIDENTS ------\n SELECT incdt_id AS id, 2 AS altId, incdt_owner_username AS owner, \n AS type, incdtpriority_order AS seq,\n incdtpriority_name AS priority, \n incdt_summary AS name, \n firstLine(incdt_descrip) AS descrip, \n incdt_status AS status, CAST(incdt_timestamp AS date) AS start, \n null AS due, \n incdt_assigned_username AS usr, CAST(incdt_number AS text) AS number,\n crmacct_number, crmacct_name,\n cust_number AS cust, \n NULL AS due_qtforegroundrole \n FROM incdt LEFT OUTER JOIN crmacct ON (crmacct_id=incdt_crmacct_id) \n LEFT OUTER JOIN custinfo ON (cust_id=crmacct_cust_id) \n LEFT OUTER JOIN incdtpriority ON (incdtpriority_id=incdt_incdtpriority_id) \n WHERE ((incdt_status != 'L')\n AND ((incdt_owner_username=) \t \n OR (incdt_assigned_username=)))\n------ TASKS ------\n UNION \n SELECT prjtask_id AS id, 3 AS altId, prjtask_owner_username AS owner, \n AS type, NULL AS seq, NULL AS priority, \n prjtask_number || '-' || prjtask_name AS name, \n firstLine(prjtask_descrip) AS descrip, \n prjtask_status AS status, prjtask_start_date AS start, \n prjtask_due_date AS due, \n prjtask_username AS usr, prj_number,\n '' AS crmacct_number, '' AS crmacct_name, '' AS cust, \n CASE WHEN (prjtask_status != 'C'AND \n prjtask_due_date < CURRENT_DATE) THEN 'expired'\n WHEN (prjtask_status != 'C'AND \n prjtask_due_date > CURRENT_DATE) THEN 'future'\n END AS due_qtforegroundrole \n FROM prj, prjtask \n WHERE((prj_id=prjtask_prj_id) \n AND (prjtask_status != 'C')\n AND ((prjtask_owner_username=) \n OR (prjtask_username=))) \n------ PROJECTS ------\n UNION \n SELECT prj_id AS id, 4 AS altId, prj_owner_username AS owner, \n AS type, NULL AS seq, NULL AS priority, \n prj_number || '-' || prj_name AS name, \n firstLine(prj_descrip) AS descrip, \n prj_status AS status, prj_start_date AS start, \n prj_due_date AS due, \n prj_username AS usr, NULL AS number,\n '' AS crmacct_number, '' AS crmacct_name,'' AS cust, \n CASE WHEN (prj_status != 'C'AND \n prj_due_date < CURRENT_DATE) THEN 'expired'\n WHEN (prj_status != 'C'AND \n prj_due_date > CURRENT_DATE) THEN 'future'\n END AS due_qtforegroundrole \n FROM prj \n WHERE ((prj_status != 'C')\n AND ((prj_owner_username=) \n OR (prj_username=)))\nORDER BY due, seq, usr; \n \N \N 0 227 desktop userOnline Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. -- Group: desktop\n-- Name: userOnline\n-- Notes: \n-- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n-- See www.xtuple.com/CPAL for the full text of the software license.\n\nSELECT usersonline.*,\n 0 AS cnt_internal_xttotalrole,\n 0 AS cnt_external_xttotalrole\nFROM xtdesktop.usersonline();\n \N \N 0 494 desktop userShortcuts Return list of User defined hotkey preferences for use in xtDesktop Shortcuts. Shortcuts names derive programatically from the action -- Group: desktop\n-- Name: userShortcuts\n-- Notes: Return list of User defined hotkey preferences for use in xtDesktop Shortcuts. Shortcuts names derive programatically from the action\nSELECT usrpref_id, \n usrpref_value AS menuAction,\n TRIM(initcap(regexp_replace(split_part(regexp_replace(usrpref_value, E'dsp|_', E' '), '.', 2), E'([A-Z])', E'\\ \\\\1','g'))) AS menuAction_qtdisplayrole,\n CASE WHEN LEFT(usrpref_name,1) = 'F' THEN 1\n WHEN SUBSTRING(usrpref_name,2,1) ~ '[0-9]' THEN 3 \n ELSE 2 END AS sort\nFROM usrpref\nWHERE usrpref_username = getEffectiveXtUser()\nAND length(usrpref_name) = 2\nORDER BY sort, usrpref_name;\n \N \N 0 \. -- -- Data for Name: pkgpriv; Type: TABLE DATA; Schema: xtdesktop; Owner: admin -- COPY pkgpriv (priv_id, priv_module, priv_name, priv_descrip, priv_seq) FROM stdin; 635 Desktop AccessAdditionalUser Controls access to additional Users \N 575 Desktop ViewBankAccountsDock Allows the user to view the Bank Accounts dock widget on the Desktop \N 576 Desktop ViewExtensionsDock Allows the user to view the Extensions dock widget on the Desktop \N 577 Desktop ViewGLAccountsDock Allows the user to view Monitored General Ledger Accounts dock widget on the Desktop \N 578 Desktop ViewManufactureActivitiesDock Allows the user to view the Manufacture Activities dock widget on the Desktop \N 579 Desktop ViewManufactureHistoryDock Allows the user to view the Manufacture History dock widget on the Desktop \N 580 Desktop ViewMyAccountsDock Allows the user to view the My (CRM) Accounts dock widget on the Desktop \N 581 Desktop ViewMyContactsDock Allows the user to view the My Contact dock widget on the Desktop \N 582 Desktop ViewTodoDock Allows the user to view the To Do dock widget on the Desktop \N 583 Desktop ViewPayablesDock Allows the user to view the Payables dock widget on the Desktop \N 584 Desktop ViewPurchaseActivitiesDock Allows the user to view the Purchase Activities dock widget on the Desktop \N 585 Desktop ViewPurchaseHistoryDock Allows the user to view the Purchase History dock widget on the Desktop \N 586 Desktop ViewPurchaseOrdersDock Allows the user to view the open purchase orders dock widget on the Desktop \N 587 Desktop ViewReceivablesDock Allows the user to view the Purchase History dock widget on the Desktop \N 588 Desktop ViewSalesActivitiesDock Allows the user to view the Sales Activities dock widget on the Desktop \N 589 Desktop ViewSalesHistoryDock Allows the user to view the Sales History dock widget on the Desktop \N 590 Desktop ViewSalesOrdersDock Allows the user to view the Sales Orders dock widget on the Desktop \N 591 Desktop ViewWorkOrdersDock Allows the user to view the Work Orders dock widget on the Desktop \N 592 Desktop ViewUsersOnlineDock Allows the user to view the Users Online doc \N 593 Desktop ViewCRMDesktop Allows the user to view the CRM Desktop page \N 594 Desktop ViewSalesDesktop Allows the user to view the Sales Desktop page \N 595 Desktop ViewPurchaseDesktop Allows the user to view the Purchase Desktop page \N 596 Desktop ViewManufactureDesktop Allows the user to view the Manufacture Desktop page \N 597 Desktop ViewAccountingDesktop Allows the user to view the Accounting Desktop page \N 598 Desktop ViewMaintenanceDesktop Allows the user to view the Maintenance Desktop page \N 636 Desktop viewSocialDesktop Allows the user to view the Social Desktop page \N 637 Desktop viewMsgHistoryDock Allows the user to view the Message History dock widget on the Desktop \N 638 Desktop viewSendMsgDock Allows the user to view the Sed Message dock widget on the Desktop \N \. -- -- Data for Name: pkgreport; Type: TABLE DATA; Schema: xtdesktop; Owner: admin -- COPY pkgreport (report_id, report_name, report_sys, report_source, report_descrip, report_grade, report_loaddate) FROM stdin; \. -- -- Data for Name: pkgscript; Type: TABLE DATA; Schema: xtdesktop; Owner: admin -- COPY pkgscript (script_id, script_name, script_order, script_enabled, script_source, script_notes) FROM stdin; 70 dockExtensions 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockExtensions;\nvar _extensions;\nvar _extensionsIsDirty = true;\n\n/*!\n Initializes Extensions dock widget and places it in the main window.\n*/\nfunction initDockExtensions()\n{\n _dockExtensions = mainwindow.findChild("_dockExtensions");\n _extensions = mainwindow.findChild("_extensions");\n\n // Set columns on list\n _extensions.addColumn(qsTr("Name"), -1, Qt.AlignLeft, true, "pkgitem_name");\n _extensions.addColumn(qsTr("Description"), -1, Qt.AlignLeft, false, "pkgitem_descrip");\n _extensions.addColumn(qsTr("Type"), -1, Qt.AlignLeft, false, "pkgitem_type");\n\n // Connect Signals and Slots\n _dtTimer.timeout.connect(refreshExtensions);\n\n _extensions.itemSelected.connect(openWindowExtensions);\n _extensions["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n .connect(populateMenuExtensions);\n\n _dockExtensions.visibilityChanged.connect(fillListExtensions);\n\n // Handle privilge control\n var act = _dockExtensions.toggleViewAction();\n\n // Don't show if no privs\n if (!privileges.check("ViewExtensionsDock"))\n {\n _dockExtensions.hide();\n act.enabled = false;\n }\n\n // Allow rescan to let them show if privs granted\n act.setData("ViewExtensionsDock");\n _menuDesktop.appendAction(act);\n\n fillListExtensions();\n}\n\n/*!\n Fills the list with active sales data.\n*/\nfunction fillListExtensions()\n{\n _dockExtensions = mainwindow.findChild("_dockExtensions");\n _extensions = mainwindow.findChild("_extensions");\n\n if (_dockExtensions.visible && _extensionsIsDirty)\n {\n var params = new Object;\n params.script = qsTr("Scripts");\n params.cmd = qsTr("Custom Commands");\n params.procedure = qsTr("Stored Procedures");\n params.trigger = qsTr("Triggers");\n params.image = qsTr("Images");\n params.metasql = qsTr("MetaSQL");\n params.priv = qsTr("Privileges");\n params.report = qsTr("Reports");\n params.schema = qsTr("Schema");\n params.table = qsTr("Tables");\n params.uiform = qsTr("Screens");\n params.view = qsTr("Views");\n params.folder = qsTr("Folder");\n params.client = qsTr("Client");\n params.database = qsTr("Database");\n\n _extensions.populate(toolbox.executeDbQuery("desktop","pkgItems", params))\n \n _extensionsIsDirty = false;\n }\n}\n\n/*! \n Opens the window associated with the selected item.\n*/\nfunction openWindowExtensions()\n{\n var ui;\n var run = false;\n var type = _extensions.currentItem().rawValue("pkgitem_type");\n var params = new Object;\n params.mode = "view";\n \n // Make sure we can open the window for this activity\n if (!privilegeCheckExtensions(type))\n return;\n\n // Determine which window to open\n if (type == "P")\n {\n ui = "package";\n params.pkghead_id = _extensions.id();\n }\n else if (type == "C")\n {\n ui = "scriptEditor";\n params.script_id = _extensions.id();\n }\n else if (type == "D")\n {\n ui = "customCommand";\n params.cmd_id = _extensions.id();\n }\n else if (type == "I")\n {\n ui = "image";\n params.image_id = _extensions.id();\n }\n else if (type == "M")\n ui = "metasqls";\n else if (type == "R")\n ui = "reports";\n else if (type == "U")\n {\n ui = "uiform";\n params.uiform_id = _extensions.id();\n }\n\n // Open the window and perform any handling required\n win = toolbox.openWindow(ui);\n if (type == "M")\n {\n win.hide();\n win.findChild("_list").setId(_extensions.id());\n win.sEdit();\n win.close();\n }\n else if (type == "R")\n {\n win.hide();\n win.findChild("_report").setId(_extensions.id());\n win.sEdit();\n win.close();\n }\n else if (type == "U")\n {\n win.hide();\n toolbox.lastWindow().set(params);\n win.sEdit();\n }\n else\n {\n toolbox.lastWindow().set(params);\n if (toolbox.lastWindow().exec())\n fillListExtensions();\n }\n}\n\n/*!\n Adds actions to @a pMenu, typically from a right click on an Extension item.\n*/\nfunction populateMenuExtensions(pMenu, pItem)\n{\n var menuItem;\n var type = pItem.rawValue("pkgitem_type");\n var enable = privilegeCheckExtensions(type);\n\n // If not a type we have an editor for get out\n if ((type != "P") &&\n (type != "C") &&\n (type != "D") &&\n (type != "I") &&\n (type != "M") &&\n (type != "R") &&\n (type != "U"))\n return;\n\n menuItem = pMenu.addAction(_open);\n menuItem.enabled = enable;\n menuItem.triggered.connect(openWindowExtensions);\n}\n\n/*!\n Returns whether user has privileges to view detail on the selected extension type.\n*/\nfunction privilegeCheckExtensions(type)\n{\n if (type == "P")\n return privileges.check("ViewPackages+#superuser")\n else if (type == "C")\n return privileges.check("MaintainScripts");\n else if (type == "D") \n return privileges.check("MaintainCustomCommands");\n else if (type == "I") \n return privileges.check("MaintainImages");\n else if (type == "M")\n return privileges.check("MaintainMetaSQL") ||\n privileges.check("ViewMetaSQL");\n else if (type == "R") \n return privileges.check("MaintainReports");\n else if (type == "U")\n return privileges.check("MaintainScreens");\n\n return false;\n}\n\n/*!\n Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshExtensions()\n{\n _extensionsIsDirty = true;\n fillListExtensions();\n}\n 67 contact 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("dockMyContacts");\n\n// Connect this window so that the My Contacts dock list gets updated\nvar _contactList = mainwindow.findChild("_contactList");\n\n// Connect this window so that the My Contacts dock list gets updated\n//new method for buttonbox, added for 3.8\n var _buttonBox = mywindow.findChild("_buttonBox");\n toolbox.coreDisconnect(_buttonBox, "accepted()", mywindow, "sSave()");\n _buttonBox.accepted.connect(save);\n\n//method prior to 3.8 core release\n//var _save = mywindow.findChild("_save");\n//toolbox.coreDisconnect(_save, "clicked()", mydialog, "sSave()");\n//_save.clicked.connect(save);\n\nfunction save()\n{\n mydialog.sSave();\n fillListMyCntcts();\n}\n\n 133 desktopMenuBar 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nfunction setupDesktopMenu() {\n\n _mainMenu = mainwindow.findChild("_mainMenu");\n _shortcutMenu = mainwindow.findChild("_shortcutMenu");\n _employee = mainwindow.findChild("_employee");\n\n _mainMenu.addColumn(qsTr("MAIN MENU"), -1, Qt.AlignLeft, true, "menuItem");\n\n _mainMenu.setStyleSheet(desktopStyle);\n _shortcutMenu.setStyleSheet(desktopStyle);\n _mainMenu.alternatingRowColors = false;\n _shortcutMenu.alternatingRowColors = false;\n _shortcutMenu.maximumHeight = 400;\n _shortcutMenu.addColumn(qsTr("SHORTCUTS"), -1, Qt.AlignLeft, true, "menuAction");\n\n shortcutsMenuPopulateList();\n\n var _employeeSql = "SELECT 0 as sort, crmacct_name, crmacct_usr_username "\n + "FROM emp JOIN crmacct ON (emp_id=crmacct_emp_id) "\n + "WHERE crmacct_usr_username = geteffectivextuser() "\n + "UNION SELECT 1 as sort, geteffectivextuser(), usr_propername "\n + "FROM usr WHERE usr_username = geteffectivextuser() "\n + "ORDER BY 1 ASC LIMIT 1; ";\n var _employeeData = toolbox.executeQuery(_employeeSql);\n if (_employeeData.first()){\n _employee.text = _employeeData.value("crmacct_name");\n _employee.wordWrap = true;\n }\n\n_employee.setStyleSheet(imageStyle);\n\n\n _mainMenu["itemClicked(XTreeWidgetItem*, int)"].connect(mainMenuClicked);\n _shortcutMenu["itemClicked(XTreeWidgetItem*, int)"].connect(shortcutMenuClicked);\n mainwindow["emitSignal(QString, QString)"].connect(refreshShortcuts);\n\n // Populate Shortcuts Right Click menu\n _shortcutMenu["populateMenu(QMenu *,XTreeWidgetItem *, int)"].connect(shortcutsPopulateMenu);\n\n}\n\nfunction refreshShortcuts(source, type) {\n if (source == "xtdesktop")\n shortcutsMenuPopulateList();\n}\n\nfunction shortcutsMenuPopulateList() {\n\n var menu = [ "menu.prod", "menu.im", "menu.sched",\n "menu.purch", "menu.manu", "menu.crm",\n "menu.sales", "menu.accnt", "menu.sys" ],\n scMaxLength = 25,\n sep = qsTr(" > "),\n scq, column, idx, item, i, j, path, longText;\n\n function getPath(objName, menu) {\n var actions, item, i, submenu;\n if (! menu) {\n return; // menu.sched is only defined if xtmfg is installed\n } else if (menu.objectName === objName) {\n return [ menu ];\n } else if (menu.menu || menu.actions) {\n if (menu.menu) {\n submenu = menu.menu();\n actions = (submenu && submenu.actions) ? submenu.actions() : [];\n } else\n actions = menu.actions();\n for (i = 0; i < actions.length; i++) {\n item = getPath(objName, actions[i]);\n if (item) {\n item.unshift(menu);\n return item;\n }\n }\n }\n }\n \n _shortcutMenu.clear();\n scq = toolbox.executeDbQuery("desktop", "userShortcuts", new Object);\n\n _shortcutMenu.populate(scq);\n \n column = _shortcutMenu.column('menuAction');\n for (idx = _shortcutMenu.topLevelItemCount - 1; idx >= 0; idx--) {\n item = _shortcutMenu.topLevelItem(idx);\n for (i = 0; i < menu.length; i++) {\n path = getPath(item.rawValue('menuAction'), mainwindow.findChild(menu[i]));\n if (path && path.length) {\n longText = path.map(function (elem) { return elem.text ? elem.text : "" })\n .filter(function (elem) { return elem; })\n .join(sep);\n longText = longText.replace(/(\\.\\.\\.|&)/g, "");\n break;\n }\n }\n if (longText) {\n if (longText.length < scMaxLength)\n item.setData(column, Qt.DisplayRole, longText);\n else {\n // shorten the shortcut to a '>' boundary if it looks too long\n for (j = i = longText.indexOf(sep);\n longText.length - j > scMaxLength && j > 0;\n j = longText.indexOf(sep, j + 1)) {\n i = j;\n }\n item.setData(column, Qt.DisplayRole, "..." + longText.substring(i));\n }\n item.setData(column, Qt.ToolTipRole, longText);\n }\n }\n}\n\nfunction shortcutsPopulateMenu(pMenu, pItem, pCol){\n var mCode;\n var currentItem = _shortcutMenu.currentItem();\n if(currentItem != null) {\n mCode = pMenu.addAction(qsTr("Edit Shortcuts..."));\n mCode.enabled = privileges.check("MaintainPreferencesSelf");\n mCode.triggered.connect(shortcutsMenuOpenPrefs);\n }\n}\n\nfunction shortcutsMenuOpenPrefs() {\n var hotkeys = toolbox.openWindow("hotkeys", mainwindow, 0, 1);\n var params = new Object;\n params.currentUser = true;\n toolbox.lastWindow().set(params);\n if (hotkeys.exec() > 0)\n shortcutsMenuPopulateList();\n}\n \nfunction mainMenuClicked(wdgt, item) {\n _shortcutMenu.setCurrentItem(-1);\n _desktopStack.currentIndex = (wdgt.id() - 1);\n}\n\nfunction shortcutMenuClicked(wdgt, item) {\n _mainMenu.setCurrentItem(-1);\n var param = new Object;\n param.action = wdgt.id();\n\n var _actionSQL = "SELECT usrpref_value FROM usrpref "\n\t\t+ " WHERE (usrpref_username = geteffectivextuser() "\n + " and usrpref_id = );";\n var _scAction = toolbox.executeQuery(_actionSQL, param);\n if (_scAction.first()){\n var priv = mainwindow.findChild(_scAction.value("usrpref_value"));\n if (priv && priv.enabled)\n mainwindow.findChild(_scAction.value("usrpref_value")).trigger();\n else\n QMessageBox.information(mainwindow, qsTr("Insufficient Privileges"), qsTr("You have insufficient permissions for this action"));\n } else {\n QMessageBox.critical(mainwindow, qsTr("Error"), qsTr("Could not find the shortcut action"));\n return false;\n }\n}\n 68 desktopNotice 0 t /*\n * This file is part of the xtdesktop package for xTuple ERP: PostBooks edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nmydialog.accepted.connect(save)\n\nfunction save()\n{\n preferences.set("NoDesktopNotice",!mydialog.findChild("_remind").checked)\n}\n 69 dockBankBal 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockBankBal;\nvar _bankBal;\nvar _bankBalIsDirty = true;\n\n/*!\n Initializes Bank Balance dock widget and places it in the main window.\n*/\nfunction initDockBankBal()\n{\n _dockBankBal = mainwindow.findChild("_dockBankBal");\n _bankBal = mainwindow.findChild("_bankBal");\n\n // Set columns on list\n _bankBal.addColumn(qsTr("Name"), -1, Qt.AlignLeft, true, "bankaccnt_name");\n _bankBal.addColumn(qsTr("Balance"), -1, Qt.AlignRight, true, "balance");\n\n // Connect Signals and Slots\n _dtTimer.timeout.connect(refreshBankBal);\n mainwindow.bankAccountsUpdated.connect(refreshBankBal);\n mainwindow.bankAdjustmentsUpdated.connect(refreshBankBal);\n mainwindow.cashReceiptsUpdated.connect(refreshBankBal);\n mainwindow.checksUpdated.connect(refreshBankBal);\n mainwindow.glSeriesUpdated.connect(refreshBankBal);\n\n _bankBal.itemSelected.connect(openWindowBankBal);\n _bankBal["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n .connect(populateMenuBankBal);\n\n _dockBankBal.visibilityChanged.connect(fillListBankBal);\n\n // Handle privilge control\n var act = _dockBankBal.toggleViewAction();\n\n // Don't show if no privs\n if (!privileges.check("ViewBankAccountsDock"))\n {\n _dockBankBal.hide();\n act.enabled = false;\n }\n\n // Allow rescan to let them show if privs granted\n act.setData("ViewBankAccountsDock");\n _menuDesktop.appendAction(act);\n\n fillListBankBal();\n}\n\n/*!\n Fills the list with bank account data.\n*/\nfunction fillListBankBal()\n{\n _dockBankBal = mainwindow.findChild("_dockBankBal");\n _bankBal = mainwindow.findChild("_bankBal");\n\n if (_dockBankBal.visible && _bankBalIsDirty)\n {\n var params = new Object;\n if (metrics.boolean("EnableProjectAccounting"))\n params.projectAccounting = true;\n var qry = toolbox.executeDbQuery("desktop","bankBal", params);\n _bankBal.populate(qry);\n _bankBalIsDirty = false;\n }\n}\n\n/*! \n Opens the window associated with the selected item.\n*/\nfunction openWindowBankBal()\n{\n // Make sure we can open the window\n if (!privilegeCheckBankBal())\n return;\n\n // Open the window and perform any handling required\n toolbox.openWindow("reconcileBankaccount");\n var w = toolbox.lastWindow().findChild("_bankaccnt").setId(_bankBal.id());\n}\n\n/*!\n Adds actions to @a pMenu, typically from a right click on a bank account item.\n*/\nfunction populateMenuBankBal(pMenu, pItem)\n{\n var menuItem;\n var enable = privilegeCheckBankBal();\n\n menuItem = pMenu.addAction(qsTr("Reconcile..."));\n menuItem.enabled = enable;\n menuItem.triggered.connect(openWindowBankBal);\n}\n\n/*!\n Returns whether user has privileges to view detail.\n*/\nfunction privilegeCheckBankBal(act)\n{\n return privileges.check("MaintainBankRec");\n}\n\n/*!\n Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshBankBal()\n{\n _bankBalIsDirty = true;\n fillListBankBal();\n}\n 71 dockGLAccounts 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _b1GLAccounts;\nvar _b2GLAccounts;\nvar _dockGLAccounts;\nvar _glAccounts;\nvar _glAccountsIsDirty = true;\nvar _periodId = -1;\n\n/*!\n Initializes Monitored Accounts dock widget and places it in the main window.\n*/\nfunction initDockGLAccounts()\n{\n // Set up objects\n _dockGLAccounts = mainwindow.findChild("_dockGLAccounts");\n _glAccounts = mainwindow.findChild("_glAccounts");\n\n _b1GLAccounts = _dockGLAccounts.findChild("_button1");\n _b2GLAccounts = _dockGLAccounts.findChild("_button2");\n _labelGLAccounts = _dockGLAccounts.findChild("_label");\n\n // Set icons\n var iReload = new QIcon;\n iReload.addDbImage("reload_16");\n _b1GLAccounts.icon = iReload;\n _b1GLAccounts.text = "";\n _b1GLAccounts.toolTip = qsTr("Reload");\n\n var iGear = new QIcon();\n iGear.addDbImage("gear_16");\n _b2GLAccounts.icon = iGear;\n _b2GLAccounts.text = "";\n _b2GLAccounts.toolTip = qsTr("Preferences...");\n\n // Set columns on list\n _glAccounts.addColumn(qsTr("Number"), -1, Qt.AlignLeft, true, "accnt_id");\n _glAccounts.addColumn(qsTr("Description"), -1, Qt.AlignLeft, true, "accnt_descrip");\n _glAccounts.addColumn(qsTr("Type"), -1, Qt.AlignLeft, true, "accnt_type");\n _glAccounts.addColumn(qsTr("Balance"), -1, Qt.AlignRight, true, "balance");\n\n // Connect Signals and Slots\n _b1GLAccounts.clicked.connect(refreshGLAccounts);\n _b2GLAccounts.clicked.connect(preferencesGLAccounts);\n\n _dtTimer.timeout.connect(refreshGLAccounts);\n mainwindow.bankAdjustmentsUpdated.connect(refreshGLAccounts);\n mainwindow.checksUpdated.connect(refreshGLAccounts);\n mainwindow.creditMemosUpdated.connect(refreshGLAccounts);\n mainwindow.cashReceiptsUpdated.connect(refreshGLAccounts);\n mainwindow.glSeriesUpdated.connect(refreshGLAccounts);\n mainwindow.invoicesUpdated.connect(refreshGLAccounts);\n mainwindow.paymentsUpdated.connect(refreshGLAccounts);\n mainwindow.standardPeriodsUpdated.connect(refreshGLAccounts);\n mainwindow.vouchersUpdated.connect(refreshGLAccounts);\n mainwindow.workOrderMaterialsUpdated.connect(refreshGLAccounts);\n mainwindow.workOrderOperationsUpdated.connect(refreshGLAccounts);\n mainwindow.workOrdersUpdated.connect(refreshGLAccounts);\n\n _glAccounts.itemSelected.connect(openWindowGLAccounts);\n _glAccounts["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n .connect(populateMenuGLAccounts);\n\n _dockGLAccounts.visibilityChanged.connect(fillListGLAccounts);\n\n // Handle privilge control\n var act = _dockGLAccounts.toggleViewAction();\n\n // Don't show if no privs\n if (!privileges.check("ViewGLAccountsDock"))\n {\n _dockGLAccounts.hide();\n act.enabled = false;\n }\n\n // Allow rescan to let them show if privs granted\n act.setData("ViewGLAccountsDock");\n _menuDesktop.appendAction(act);\n fillListGLAccounts();\n}\n\n/*!\n Fills the list with sales history data based on parameters determined by\n sales history preferences.\n\n @sa preferencesGLAccounts()\n*/\nfunction fillListGLAccounts()\n{\n _dockGLAccounts = mainwindow.findChild("_dockGLAccounts");\n _glAccounts = mainwindow.findChild("_glAccounts");\n\n if (!_dockGLAccounts.visible || !_glAccountsIsDirty)\n return;\n\n _glAccounts.clear();\n var accntIdList = preferences.value("MonitoredAccounts");\n if(!accntIdList.length)\n return;\n\n var params = new Object;\n params.asset = qsTr("Asset");\n params.liability = qsTr("Liability");\n params.revenue = qsTr("Revenue");\n params.expense = qsTr("Expense");\n params.equity = qsTr("Equity");\n params.accnt_id_list = accntIdList;\n\n // Forward update if applicable\n if (!metrics.boolean("ManualForwardUpdate"))\n toolbox.executeDbQuery("desktop","glforwardupdate", params);\n\n var qry = toolbox.executeDbQuery("desktop","glaccountBal", params);\n if (qry.first())\n {\n _periodId = qry.value("period_id");\n _glAccounts.populate(qry);\n }\n\n _glAccountsIsDirty = false;\n}\n\n/*! \n Opens the window associated with the selected item.\n*/\nfunction openWindowGLAccounts()\n{\n var ui;\n var params = new Object;\n params.period_id = _periodId;\n params.accnt_id = _glAccounts.id();\n params.run = true;\n\n // Make sure we can open the window\n if (!privilegeCheckGLAccounts())\n return;\n\n // Open the window and perform any special handling required\n toolbox.openWindow("dspGLTransactions");\n toolbox.lastWindow().set(params);\n}\n\n/*!\n Adds actions to @a pMenu, typically from a right click on sales history.\n*/\nfunction populateMenuGLAccounts(pMenu)\n{\n var menuItem;\n var enable = privilegeCheckGLAccounts();\n\n menuItem = pMenu.addAction(_open);\n menuItem.enabled = enable;\n menuItem.triggered.connect(openWindowGLAccounts);\n}\n\n/*!\n Returns whether user has privileges to view Sales History detail.\n*/\nfunction privilegeCheckGLAccounts()\n{\n var returnval = privileges.check("ViewGLTransactions");\n print("privilegeCheckGLAccounts returning " + returnval);\n return returnval;\n}\n\n/*! \n Launches the preferences window where the user can set sales data output preferences.\n*/\nfunction preferencesGLAccounts()\n{\n params = new Object;\n\n var newdlg = toolbox.openWindow("preferencesSelections", mainwindow,\n Qt.ApplicationModal, Qt.Dialog);\n toolbox.lastWindow().set(params);\n if (newdlg.exec())\n refreshGLAccounts();\n}\n\n/*!\n Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshGLAccounts()\n{\n _glAccountsIsDirty = true;\n fillListGLAccounts();\n}\n 127 dockMessageHistory 0 t var _b1MessageHistory;\nvar _b2MessageHistory;\nvar _dockMessageHistory;\nvar _messageHistory;\nvar _limitmessageHistory;\nvar _messageHistoryIsDirty = true;\nvar _periodId = -1;\n\nfunction initDockMessageHistory()\n{ \n // Set up objects\n _dockMessageHistory = mainwindow.findChild("_dockMessageHistory");\n _messageHistory = mainwindow.findChild("_messageHistory");\n\n _b1MessageHistory = _dockMessageHistory.findChild("_button3");\n _b2MessageHistory = _dockMessageHistory.findChild("_button4");\n\n // Set icons\n var iReload = new QIcon;\n iReload.addDbImage("reload_16");\n _b1MessageHistory.icon = iReload;\n _b1MessageHistory.text = "";\n _b1MessageHistory.toolTip = qsTr("Reload");\n\n var iGear = new QIcon();\n iGear.addDbImage("gear_16");\n _b2MessageHistory.icon = iGear;\n _b2MessageHistory.text = "";\n _b2MessageHistory.toolTip = qsTr("Preferences...");\n\n // Set columns on list\n _messageHistory.addColumn("Date", 75, 1, true, "sent");\n _messageHistory.addColumn("From", 75, 1, true, "from");\n _messageHistory.addColumn("To", 75, 1, true, "to")\n _messageHistory.addColumn("Message", -1, 1, true, "message");\n\n // Connect Signals and Slots\n _b1MessageHistory.clicked.connect(refreshMessageHistory);\n _b2MessageHistory.clicked.connect(preferencesMessageHistory);\n\n _messageHistory["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n .connect(populateMenuMessageHistory);\n _messageHistory["itemDoubleClicked(QTreeWidgetItem*, int)"].connect(myOpen);\n\n mainwindow["tick()"].connect(refreshMessageHistory);\n mainwindow.setUpListener("messagePosted");\n mainwindow["messageNotify()"].connect(refreshMessageHistory);\n\n // Don't show if no privs\n var act = _dockMessageHistory.toggleViewAction();\n if (!privileges.check("viewMsgHistoryDock"))\n { \n _dockMessageHistory.hide();\n act.enabled = false;\n }\n else\n {\n _dockMessageHistory.show();\n act.enabled = true;\n }\n\n // Allow rescan to let them show if privs granted\n act.setData("viewMsgHistoryDock");\n _menuDesktop.appendAction(act);\n\n fillListMessageHistory();\n}\n\nfunction fillListMessageHistory()\n{\n _dockMessageHistory = mainwindow.findChild("_dockMessageHistory");\n _messageHistory = mainwindow.findChild("_messageHistory");\n\n _messageHistory.clear();\n\n var params = new Object;\n params.limit = _limitmessageHistory;\n\n _messageHistory.populate(toolbox.executeDbQuery("desktop","messageHistory", params));\n _messageHistoryIsDirty = false;\n}\n\nfunction populateMenuMessageHistory(pMenu)\n{\n try\n {\n var menuItem = pMenu.addAction(qsTr("Open..."));\n menuItem.triggered.connect(myOpen);\n }\n catch (e)\n {\n QMessageBox.critical(mainwindow, "dockMessageHistory",\n "populateMenuMessageHistory exception: " + e);\n }\n}\n\nfunction preferencesMessageHistory()\n{\n try\n {\n params = new Object;\n params.path = "desktop/messageHistory";\n params.limit = _limitmessageHistory;\n var newdlg = toolbox.openWindow("preferencesNumber", mainwindow,\n Qt.ApplicationModal, Qt.Dialog);\n toolbox.lastWindow().set(params);\n if (newdlg.exec())\n {\n loadPreferencesMessageHistory();\n refreshMessageHistory();\n }\n }\n catch (e)\n {\n QMessageBox.critical(mainwindow, "dockMessageHistory",\n "preferencesMessageHistory exception: " + e);\n }\n}\n\nfunction loadPreferencesMessageHistory()\n{\n // Load preferences\n _limitmessageHistory = preferences.value("desktop/messageHistory/limit");\n}\n\n/*!\n Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshMessageHistory()\n{\n try\n {\n mainwindow.sSystemMessageAdded();\n messageHistoryIsDirty = true;\n fillListMessageHistory();\n }\n catch (e)\n {\n QMessageBox.critical(mainwindow, "dockMessageHistory",\n "refreshMessageHistory exception: " + e);\n }\n}\n\nfunction myOpen()\n{\n try\n {\n var params = new Object;\n params.msg_id = _messageHistory.id();\n var q = "SELECT msguser_id "\n + "FROM msguser "\n + "WHERE (msguser_msg_id = );";\n var data = toolbox.executeQuery(q, params);\n if (data.first())\n params.msguser_id = data.value("msguser_id");\n else if (data.lastError().type != QSqlError.NoError)\n {\n QMessageBox.critical(mainwindow, qsTr("Database Error"),\n data.lastError().text);\n return;\n }\n\n params.mode = "acknowledge";\n var newwnd = toolbox.openWindow("systemMessage", mainwindow, Qt.ApplicationModal, Qt.Dialog);\n toolbox.lastWindow().set(params);\n newwnd.exec();\n refreshMessageHistory();\n }\n catch (e)\n {\n QMessageBox.critical(mainwindow, "dockMessageHistory",\n "myOpen exception: " + e);\n }\n}\n 72 dockMfgActive 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockMfgAct;\nvar _MfgAct;\nvar _mfgActIsDirty = true;\n\n/*!\n Initializes Mfg. Activity dock widget and places it in the main window.\n*/\nfunction initDockMfgAct()\n{\n _dockMfgAct = mainwindow.findChild("_dockMfgAct");\n _mfgAct = mainwindow.findChild("_mfgAct");\n\n // Set columns on list\n _mfgAct.addColumn(qsTr("Type"), -1, Qt.AlignLeft, true, "activity");\n _mfgAct.addColumn(qsTr("#"), 40, Qt.AlignRight, true, "count");\n _mfgAct.addColumn(qsTr("Amount"), -1, Qt.AlignRight, true, "amount");\n _mfgAct.addColumn(qsTr("Qty"), -1, Qt.AlignRight, false, "qty");\n\n // Connect Signals and Slots\n _dtTimer.timeout.connect(refreshMfgAct);\n mainwindow.workOrdersUpdated.connect(refreshMfgAct);\n mainwindow.workOrderMaterialsUpdated.connect(refreshMfgAct);\n mainwindow.workOrderOperationsUpdated.connect(refreshMfgAct);\n\n _mfgAct.itemSelected.connect(openWindowMfgAct);\n _mfgAct["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n .connect(populateMenuMfgAct);\n\n _dockMfgAct.visibilityChanged.connect(fillListMfgAct);\n\n // Handle privilge control\n var act = _dockMfgAct.toggleViewAction();\n\n // Don't show if no privs\n if (!privileges.check("ViewManufactureActivitiesDock"))\n {\n _dockMfgAct.hide();\n act.enabled = false;\n }\n\n // Allow rescan to let them show if privs granted\n act.setData("ViewManufactureActivitiesDock");\n _menuDesktop.appendAction(act);\n\n fillListMfgAct();\n}\n\n/*!\n Fills the list with active Purch data.\n*/\nfunction fillListMfgAct()\n{\n _dockMfgAct = mainwindow.findChild("_dockMfgAct");\n _mfgAct = mainwindow.findChild("_mfgAct");\n\n if (_dockMfgAct.visible && _mfgActIsDirty)\n {\n var params = new Object;\n if (metrics.value("Application") != "PostBooks")\n params.planned = qsTr("Planned");\n params.open = qsTr("Open");\n params.exploded = qsTr("Exploded");\n params.released = qsTr("Released");\n params.inprocess = qsTr("In Process");\n\n _mfgAct.populate(toolbox.executeDbQuery("desktop","mfgAct", params));\n }\n}\n\n/*! \n Opens the window associated with the selected item.\n*/\nfunction openWindowMfgAct()\n{\n var ui;\n var run = false;\n var act = _mfgAct.currentItem().rawValue("activity");\n \n // Make sure we can open the window for this activity\n if (!privilegeCheckMfgAct(act))\n return;\n\n // Determine which window to open\n if (act == "L")\n ui = "dspPlannedOrders";\n else\n ui = "dspWoSchedule";\n\n // Open the window and perform any handling required\n var win = toolbox.openWindow(ui);\n if (act == "L")\n {\n// win.findChild("_purchase").forgetful = true;\n// win.findChild("_manufacture").forgetful = true;\n// win.findChild("_transfer").forgetful = true;\n// win.findChild("_purchase").checked = false;\n// win.findChild("_manufacture").checked = true;\n// win.findChild("_transfer").checked = false;\n// if (act == 'O')\n// win.findChild("_open").checked = true;\n// else if (act == 'E')\n// win.findChild("_exploded").checked = true;\n// else if (act == 'R')\n// win.findChild("_released").checked = true;\n// else if (act == 'I')\n// win.findChild("_inprocess").checked = true;\n// win.findChild("_warehouse").setAll();\n var params = new Object();\n params.type = "W";\n toolbox.lastWindow().set(params);\n }\n else\n {\n var params = new Object();\n params.status = act;\n toolbox.lastWindow().set(params);\n }\n\n\n win.sFillList();\n}\n\n/*!\n Adds actions to @a pMenu, typically from a right click on a Purch Activity item.\n*/\nfunction populateMenuMfgAct(pMenu, pItem)\n{\n var menuItem;\n var act = pItem.rawValue("activity");\n var enable = privilegeCheckMfgAct(act);\n\n menuItem = pMenu.addAction(_open);\n menuItem.enabled = enable;\n menuItem.triggered.connect(openWindowMfgAct);\n}\n\n/*!\n Returns whether user has privileges to view detail on the selected Manufacture Activity.\n*/\nfunction privilegeCheckMfgAct(act)\n{\n if (act == "L") // Planned Orders\n return privileges.check("ViewPlannedOrders");\n else // Work Orders\n return (privileges.check("ViewWorkOrders") || \n privileges.check("EditWorkOrders"));\n}\n\n/*!\n Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshMfgAct()\n{\n _mfgActIsDirty = true;\n fillListMfgAct();\n}\n 73 dockMfgHist 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _b1MfgHist;\nvar _b2MfgHist;\nvar _dockMfgHist;\nvar _groupByMfgHist;\nvar _timeFrameMfgHist;\nvar _typeMfgHist;\nvar _labelMfgHist;\nvar _mfgHist;\nvar _mfgHistIsDirty = true;\n\n/*!\n Initializes Sales History dock widget and places it in the main window.\n*/\nfunction initDockMfgHist()\n{\n // Set up objects\n _dockMfgHist = mainwindow.findChild("_dockMfgHist");\n _mfgHist = mainwindow.findChild("_mfgHist");\n\n _b1MfgHist = _dockMfgHist.findChild("_button1");\n _b2MfgHist = _dockMfgHist.findChild("_button2");\n _labelMfgHist = _dockMfgHist.findChild("_label");\n\n // Set icons\n var iReload = new QIcon;\n iReload.addDbImage("reload_16");\n _b1MfgHist.icon = iReload;\n _b1MfgHist.text = "";\n _b1MfgHist.toolTip = qsTr("Reload");\n\n var iGear = new QIcon();\n iGear.addDbImage("gear_16");\n _b2MfgHist.icon = iGear;\n _b2MfgHist.text = "";\n _b2MfgHist.toolTip = qsTr("Preferences...");\n\n // Load local preferences\n loadPreferencesMfgHist();\n\n // Set columns on list\n setColumnsMfgHist();\n\n // Connect Signals and Slots\n _b1MfgHist.clicked.connect(refreshMfgHist);\n _b2MfgHist.clicked.connect(preferencesMfgHist);\n\n _dtTimer.timeout.connect(refreshMfgHist);\n mainwindow.purchaseOrderReceiptsUpdated.connect(refreshMfgHist);\n mainwindow.vouchersUpdated.connect(refreshMfgHist);\n\n _mfgHist.itemSelected.connect(openWindowMfgHist);\n _mfgHist["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n .connect(populateMenuMfgHist);\n\n _dockMfgHist.visibilityChanged.connect(fillListMfgHist);\n\n // Handle privilge control\n var act = _dockMfgHist.toggleViewAction();\n\n // Don't show if no privs\n if (!privileges.check("ViewManufactureHistoryDock"))\n {\n _dockMfgHist.hide();\n act.enabled = false;\n }\n\n // Allow rescan to let them show if privs granted\n act.setData("ViewManufactureHistoryDock");\n _menuDesktop.appendAction(act);\n\n fillListMfgHist();\n}\n\n/*!\n Fills the list with sales history data based on parameters determined by\n sales history preferences.\n\n @sa preferencesMfgHist()\n*/\nfunction fillListMfgHist()\n{\n _dockMfgHist = mainwindow.findChild("_dockMfgHist");\n _mfgHist = mainwindow.findChild("_mfgHist");\n\n if (!_dockMfgHist.visible || !_mfgHistIsDirty) \n return;\n\n var timeFrame;\n var type;\n var params = getDatesMfgHist();\n \n if (_groupByMfgHist == "classcode")\n {\n params.group_id = "classcode_id";\n params.group_number = "classcode_code";\n params.group_name = "classcode_descrip";\n }\n else if (_groupByMfgHist == "item")\n {\n params.group_id = "item_id";\n params.group_number = "item_number";\n params.group_name = "item_descrip1";\n }\n else if (_groupByMfgHist == "plancode")\n {\n params.group_id = "plancode_id";\n params.group_number = "plancode_code";\n params.group_name = "plancode_name";\n }\n\n _mfgHist.populate(toolbox.executeDbQuery("desktop","mfgHist", params));\n\n type = qsTr("Receipts");\n\n if (_timeFrameMfgHist == "day")\n timeFrame = qsTr("Today");\n else if (_timeFrameMfgHist == "week")\n timeFrame = qsTr("this Week");\n else if (_timeFrameMfgHist == "month")\n timeFrame = qsTr("this Month");\n else if (_timeFrameMfgHist == "year")\n timeFrame = qsTr("this Year");\n\n _labelMfgHist.text = type + " " + timeFrame;\n\n _mfgHistIsDirty = false;\n}\n\n/*!\n Returns an object with a list containing @a startDate and @a endDate\n that is used for fetching data and opening windows using the date range\n stored in local preferences.\n \n @sa preferencesMfgHist()\n @sa openWindowMfgHist()\n @sa fillListMfgHist()\n*/\nfunction getDatesMfgHist()\n{\n var params = new Object;\n\n params.timeFrame = _timeFrameMfgHist;\n params.interval = "1 " + _timeFrameMfgHist;\n\n var q = toolbox.executeDbQuery("desktop", "getDates", params);\n\n if (q.first())\n {\n params.startDate = q.value("startDate");\n params.endDate = q.value("endDate");\n }\n\n return params;\n}\n\n/*! \n Loads local Sales History preferences into memory.\n\n @sa preferencesMfgHist()\n*/\nfunction loadPreferencesMfgHist()\n{\n // Load preferences\n _groupByMfgHist = preferences.value("desktop/mfgHist/groupBy");\n _timeFrameMfgHist = preferences.value("desktop/mfgHist/timeFrame");\n _typeMfgHist = preferences.value("desktop/mfgHist/type")\n \n // Set to defaults if no values\n _groupByMfgHist = (_groupByMfgHist.length ? _groupByMfgHist : "plancode");\n _timeFrameMfgHist = (_timeFrameMfgHist.length ? _timeFrameMfgHist : "year");\n _typeMfgHist = (_typeMfgHist.length ? _typeMfgHist : "receipts");\n}\n\n/*! \n Opens the window associated with the selected item.\n*/\nfunction openWindowMfgHist()\n{\n var ui;\n var params = getDatesMfgHist();\n params.run = true;\n\n // TO DO: Work it out so totals launch a window too\n if (_mfgHist.id() == -1)\n return;\n \n // Make sure we can open the window\n if (!privilegeCheckMfgHist())\n return;\n\n // Determine which window to open\n if (_groupByMfgHist == "classcode")\n {\n ui = "dspInventoryHistory";\n params.classcode_id = _mfgHist.id();\n }\n else if (_groupByMfgHist == "item")\n {\n ui = "dspInventoryHistory";\n params.item_id = _mfgHist.id();\n }\n else if (_groupByMfgHist == "plancode")\n {\n ui = "dspInventoryHistory";\n params.plancode_id = _mfgHist.id();\n }\n params.transtype = "R";\n params.ordertype = "WO";\n params.run = true;\n\n // Open the window and perform any special handling required\n toolbox.openWindow(ui);\n toolbox.lastWindow().set(params);\n}\n\n/*!\n Adds actions to @a pMenu, typically from a right click on sales history.\n*/\nfunction populateMenuMfgHist(pMenu)\n{\n var menuItem;\n var enable = privilegeCheckMfgHist();\n\n menuItem = pMenu.addAction(_open);\n menuItem.enabled = enable;\n menuItem.triggered.connect(openWindowMfgHist);\n}\n\n/*!\n Returns whether user has privileges to view Sales History detail.\n*/\nfunction privilegeCheckMfgHist()\n{\n return privileges.check("ViewInventoryHistory");\n}\n\n/*! \n Set up columns depending on local preferences.\n\n @sa preferencesMfgHist()\n*/\nfunction setColumnsMfgHist()\n{\n _mfgHist.columnCount = 0;\n\n if (_groupByMfgHist == "classcode")\n {\n _mfgHist.addColumn(qsTr("Class Code"), -1, Qt.AlignLeft, true, "classcode_code");\n _mfgHist.addColumn(qsTr("Description"), -1, Qt.AlignLeft, false, "classcode_descrip");\n }\n else if (_groupByMfgHist == "item")\n {\n _mfgHist.addColumn(qsTr("Item Number"), -1, Qt.AlignLeft, true, "item_number");\n _mfgHist.addColumn(qsTr("Description"), -1, Qt.AlignLeft, false, "item_descrip1");\n }\n else if (_groupByMfgHist == "plancode")\n {\n _mfgHist.addColumn(qsTr("Planner Code"), -1, Qt.AlignLeft, true, "plancode_code");\n _mfgHist.addColumn(qsTr("Description"), -1, Qt.AlignLeft, false, "plancode_descrip");\n }\n\n _mfgHist.addColumn(qsTr("Amount"), -1, Qt.AlignRight, true, "amount");\n _mfgHist.addColumn(qsTr("Qty."), -1, Qt.AlignRight, false, "qty");\n}\n\n/*! \n Launches the preferences window where the user can set sales data output preferences.\n*/\nfunction preferencesMfgHist()\n{\n params = new Object;\n params.path = "desktop/mfgHist";\n params.groupBy = _groupByMfgHist;\n params.timeFrame = _timeFrameMfgHist;\n params.type = _typeMfgHist;\n\n var newdlg = toolbox.openWindow("preferencesHistory", mainwindow,\n Qt.ApplicationModal, Qt.Dialog);\n toolbox.lastWindow().set(params);\n if (newdlg.exec())\n {\n loadPreferencesMfgHist();\n setColumnsMfgHist();\n refreshMfgHist();\n }\n}\n\n/*!\n Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshMfgHist()\n{\n _mfgHistIsDirty = true;\n fillListMfgHist();\n}\n 74 dockMfgOpen 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockMfgOpen;\nvar _mfgOpen;\nvar _mfgOpenIsDirty = true;\n\n/*!\n Initializes Work Order dock widget and places it in the main window.\n*/\nfunction initDockMfgOpen()\n{\n _dockMfgOpen = mainwindow.findChild("_dockMfgOpen");\n _mfgOpen = mainwindow.findChild("_mfgOpen");\n\n // Set columns on list\n _mfgOpen.addColumn(qsTr("Order#"), XTreeWidget.orderColumn, Qt.AlignLeft, true, "wonumber");\n _mfgOpen.addColumn(qsTr("Item#"), XTreeWidget.itemColumn, Qt.AlignLeft, true, "item_number");\n _mfgOpen.addColumn(qsTr("Description"), -1, Qt.AlignLeft, true, "itemdescrip");\n if (metrics.boolean("MultiWhs"))\n _mfgOpen.addColumn(qsTr("Whs."), XTreeWidget.whsColumn, Qt.AlignLeft, true, "warehous_code");\n _mfgOpen.addColumn(qsTr("Status"), XTreeWidget.moneyColumn, Qt.AlignLeft, true, "wo_status");\n _mfgOpen.addColumn(qsTr("Ordered"), XTreeWidget.qtyColumn, Qt.AlignRight, true, "wo_qtyord"); \n _mfgOpen.addColumn(qsTr("Received"), XTreeWidget.qtyColumn, Qt.AlignRight, true, "wo_qtyrcv"); \n _mfgOpen.addColumn(qsTr("UOM"), XTreeWidget.uomColumn, Qt.AlignLeft, true, "uom_name"); \n _mfgOpen.addColumn(qsTr("Start Date"), XTreeWidget.dateColumn, Qt.AlignLeft, false, "wo_startdate"); \n _mfgOpen.addColumn(qsTr("Due Date"), XTreeWidget.dateColumn, Qt.AlignLeft, true, "wo_duedate"); \n _mfgOpen.addColumn(qsTr("Condition"), XTreeWidget.statusColumn, Qt.AlignLeft, false, "condition"); \n if (privileges.check("ViewCosts"))\n {\n _mfgOpen.addColumn(qsTr("Posted Value"), XTreeWidget.moneyColumn, Qt.AlignRight, false, "wo_postedvalue");\n _mfgOpen.addColumn(qsTr("WIP Value"), XTreeWidget.moneyColumn, Qt.AlignRight, true, "wo_wipvalue");\n }\n\n // Connect Signals and Slots\n _dtTimer.timeout.connect(refreshMfgOpen);\n mainwindow.workOrdersUpdated.connect(refreshMfgOpen);\n mainwindow.workOrderMaterialsUpdated.connect(refreshMfgOpen);\n mainwindow.workOrderOperationsUpdated.connect(refreshMfgOpen);\n\n _mfgOpen.itemSelected.connect(openWindowMfgOpen);\n _mfgOpen["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n .connect(populateMenuMfgOpen);\n\n _dockMfgOpen.visibilityChanged.connect(fillListMfgOpen);\n\n // Handle privilge control\n var act = _dockMfgOpen.toggleViewAction();\n\n // Don't show if no privs\n if (!privileges.check("ViewWorkOrdersDock"))\n {\n _dockMfgOpen.hide();\n act.enabled = false;\n }\n\n // Allow rescan to let them show if privs granted\n act.setData("ViewWorkOrdersDock");\n _menuDesktop.appendAction(act);\n\n fillListMfgOpen();\n}\n\n/*!\n Fills the list with open sales data.\n*/\nfunction fillListMfgOpen()\n{\n _dockMfgOpen = mainwindow.findChild("_dockMfgOpen");\n _mfgOpen = mainwindow.findChild("_mfgOpen");\n\n if (!_dockMfgOpen.visible || !_mfgOpenIsDirty)\n return;\n\n params = new Object;\n params.open = qsTr("Open");\n params.exploded = qsTr("Exploded");\n params.released = qsTr("Released");\n params.inprocess = qsTr("In Process");\n\n _mfgOpen.populate(toolbox.executeDbQuery("desktop","mfgOpen",params), true);\n\n _mfgOpenIsDirty = false;\n}\n\n/*! \n Opens the window associated with the selected item.\n*/\nfunction openWindowMfgOpen()\n{ \n // Make sure we can open the window for this activity\n if (!privilegeCheckMfgOpen)\n return;\n\n params = new Object;\n params.wo_id = _mfgOpen.id();\n if (privileges.check("MaintainWorkOrders"))\n params.mode = "edit";\n else\n params.mode = "view";\n\n // Open the window and perform any handling required\n var wo = toolbox.openWindow("workOrder");\n wo.set(params);\n\n}\n\n/*!\n Adds actions to @a pMenu, typically from a right click on a Sales Order item.\n*/\nfunction populateMenuMfgOpen(pMenu, pItem)\n{\n var menuItem;\n var enable = privilegeCheckMfgOpen();\n\n menuItem = pMenu.addAction(_open);\n menuItem.enabled = enable;\n menuItem.triggered.connect(openWindowMfgOpen);\n}\n\n/*!\n Returns whether user has privileges to view detail on the selected Sales Order.\n*/\nfunction privilegeCheckMfgOpen()\n{\n return privileges.check("ViewWorkOrders") || \n privileges.check("MaintainWorkOrders");\n\n return false;\n}\n\n/*!\n Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshMfgOpen()\n{\n _mfgOpenIsDirty = true;\n fillListMfgOpen();\n}\n 75 dockMyAccounts 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockMyaccounts;\nvar _accountList;\n\n/*!\n Initializes the My Accounts dock widget and places it in the main window.\n*/\nfunction initDockAccounts()\n{\n var _accountListIsDirty = true;\n _dockMyaccounts = mainwindow.findChild("_dockMyaccounts");\n _accountList = mainwindow.findChild("_accountList");\n\n _accountList.addColumn(qsTr("Number"), XTreeWidget.itemColumn, Qt.AlignLeft, false, "crmacct_number");\n _accountList.addColumn(qsTr("Name"), -1, Qt.AlignLeft, true, "crmacct_name");\n _accountList.addColumn(qsTr("Contact"), -1, Qt.AlignLeft , false, "cntct_name" );\n _accountList.addColumn(qsTr("Phone"), -1, Qt.AlignLeft, false, "cntct_phone" );\n _accountList.addColumn(qsTr("Email"), -1, Qt.AlignLeft, false, "cntct_email" );\n _accountList.addColumn(qsTr("Address"), -1, Qt.AlignLeft , false, "addr_line1" );\n _accountList.addColumn(qsTr("City"), XTreeWidget.docTypeColumn, Qt.AlignLeft , false, "addr_city" );\n _accountList.addColumn(qsTr("State"), XTreeWidget.orderColumn, Qt.AlignLeft , false, "addr_state" );\n _accountList.addColumn(qsTr("Country"), XTreeWidget.orderColumn, Qt.AlignLeft , false, "addr_country" );\n _accountList.addColumn(qsTr("Postal Code"), XTreeWidget.docTypeColumn, Qt.AlignLeft , false, "addr_postalcode" );\n\n mainwindow.crmAccountsUpdated.connect(refreshMyAccts);\n mainwindow.customersUpdated.connect(refreshMyAccts);\n mainwindow.vendorsUpdated.connect(refreshMyAccts);\n\n _accountList.itemSelected.connect(openWindowMyAccts);\n _accountList["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n .connect(populateMenuMyAccts);\n\n _dockMyaccounts.visibilityChanged.connect(fillListMyAccts);\n\n // Handle privilege control\n var act = _dockMyaccounts.toggleViewAction();\n\n // Don't show if no privs\n if (!privileges.check("ViewMyAccountsDock"))\n {\n _dockMyaccounts.hide();\n act.enabled = false;\n }\n\n // Allow rescan to let them show if privs granted\n act.setData("ViewMyAccountsDock");\n _menuDesktop.appendAction(act);\n\n fillListMyAccts();\n\n function fillListMyAccts()\n {\n if (! _dockMyaccounts || ! _accountList || !_dockMyaccounts.visible || !_accountListIsDirty)\n return;\n\n _accountList.populate(toolbox.executeDbQuery("desktop", "crmaccounts",\n { owner_username: mainwindow.username()} ));\n\n _accountListIsDirty = false;\n }\n\n function openWindowMyAccts()\n {\n if (!privilegeCheckMyAccts())\n return;\n\n params = { crmacct_id: _accountList.id() };\n if (privileges.check("MaintainAllCRMAccounts") || privileges.check("MaintainPersonalCRMAccounts"))\n params.mode = "edit"\n else\n params.mode = "view"\n\n // Open the window and perform any special handling required\n var win = toolbox.openWindow("crmaccount");\n win.set(params);\n }\n\n function populateMenuMyAccts(pMenu)\n {\n var menuItem;\n\n menuItem = pMenu.addAction(_open);\n menuItem.enabled = privilegeCheckMyAccts();\n menuItem.triggered.connect(openWindowMyAccts);\n }\n\n function privilegeCheckMyAccts()\n {\n return privileges.check("MaintainAllCRMAccounts") || privileges.check("MaintainPersonalAccounts") ||\n privileges.check("ViewAllCRMAccounts") || privileges.check("ViewPersonalCRMAccounts");\n }\n\n function refreshMyAccts()\n {\n _accountListIsDirty = true;\n fillListMyAccts();\n }\n}\n 76 dockMyContacts 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockMycontacts;\nvar _contactList;\n\n/*!\n Initializes the My Contacts dock widget and places it in the main window.\n*/\nfunction initDockMyCntcts()\n{\n _dockMycontacts = mainwindow.findChild("_dockMycontacts");\n _contactList = mainwindow.findChild("_contactList");\n\n // Set columns on list\n _contactList.addColumn(qsTr("Name"), -1, Qt.AlignLeft , true, "cntct_name" );\n _contactList.addColumn(qsTr("Account#"), XTreeWidget.itemColumn, Qt.AlignLeft, false, "crmacct_number");\n _contactList.addColumn(qsTr("Account Name"), -1, Qt.AlignLeft, false, "crmacct_name");\n _contactList.addColumn(qsTr("Phone"), -1, Qt.AlignLeft, true, "cntct_phone" );\n _contactList.addColumn(qsTr("Email"), -1, Qt.AlignLeft, false, "cntct_email" );\n _contactList.addColumn(qsTr("Address"), -1, Qt.AlignLeft , false, "addr_line1" );\n _contactList.addColumn(qsTr("City"), XTreeWidget.docTypeColumn, Qt.AlignLeft , false, "addr_city" );\n _contactList.addColumn(qsTr("State"), XTreeWidget.orderColumn, Qt.AlignLeft , false, "addr_state" );\n _contactList.addColumn(qsTr("Country"), XTreeWidget.orderColumn, Qt.AlignLeft , false, "addr_country" );\n _contactList.addColumn(qsTr("Postal Code"), XTreeWidget.docTypeColumn, Qt.AlignLeft , false, "addr_postalcode" );\n\n _dtTimer.timeout.connect(fillListMyCntcts);\n\n _contactList.itemSelected.connect(openWindowMyCntcts);\n _contactList["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n .connect(populateMenuMyCntcts);\n\n _dockMycontacts.visibilityChanged.connect(fillListMyCntcts);\n\n // Handle privilge control\n var act = _dockMycontacts.toggleViewAction();\n\n // Don't show if no privs\n if (!privileges.check("ViewMyContactsDock"))\n {\n _dockMycontacts.hide();\n act.enabled = false;\n }\n\n // Allow rescan to let them show if privs granted\n act.setData("ViewMyContactsDock");\n _menuDesktop.appendAction(act);\n\n fillListMyCntcts();\n}\n\n/*!\n Fills the My Contacts list with Contacts owned by the current user.\n*/\nfunction fillListMyCntcts()\n{\n _dockMycontacts = mainwindow.findChild("_dockMycontacts");\n _contactList = mainwindow.findChild("_contactList");\n\n if (!_dockMycontacts.visible)\n return;\n\n _contactList = mainwindow.findChild("_contactList");\n _contactList.populate(toolbox.executeDbQuery("desktop", "contacts"));\n}\n\n/*! \n Opens the window associated with the selected item.\n*/\nfunction openWindowMyCntcts()\n{\n // Make sure we can open the window\n if (!privilegeCheckMyCntcts())\n return;\n\n // Determine which contact to open\n params = new Object;\n if (privileges.check("MaintainAllContacts") || privileges.check("MaintainPersonalContacts"))\n params.mode = "edit";\n else\n params.mode = "view";\n params.cntct_id = _contactList.id();\n\n // Open the window and perform any special handling required\n var newdlg = toolbox.openWindow("contact");\n newdlg.set(params);\n newdlg.exec();\n}\n\n/*!\n Adds actions to \\a pMenu, typically from a right click on My Contacts.\n*/\nfunction populateMenuMyCntcts(pMenu)\n{\n var menuItem;\n\n menuItem = pMenu.addAction(_open);\n menuItem.enabled = privilegeCheckMyCntcts();\n menuItem.triggered.connect(openWindowMyCntcts);\n}\n\n/*!\n Returns whether user has privileges to view My Contact detail.\n*/\nfunction privilegeCheckMyCntcts()\n{\n return privileges.check("MaintainAllContacts") || privileges.check("MaintainPersonalContacts") ||\n privileges.check("ViewAllContacts") || privileges.check("ViewPersonalContacts");\n}\n 77 dockMyTodo 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockMytodo;\nvar _todoList;\n\n/*!\n Initializes To Do dock widget and places it in the main window.\n*/\nfunction initDockTodo()\n{\n _dockMytodo = mainwindow.findChild("_dockMytodo");\n _todoList = mainwindow.findChild("_todoList");\n\n if (_todoList)\n {\n _todoList.addColumn(qsTr("Type"), XTreeWidget.userColumn, Qt.AlignCenter, true, "type");\n _todoList.addColumn(qsTr("Priority"), XTreeWidget.userColumn, Qt.AlignLeft, false, "priority");\n _todoList.addColumn(qsTr("Assigned To"), XTreeWidget.userColumn, Qt.AlignLeft, false, "usr");\n _todoList.addColumn(qsTr("Name"), -1, Qt.AlignLeft, true, "name");\n _todoList.addColumn(qsTr("Description"), -1, Qt.AlignLeft, true, "descrip");\n _todoList.addColumn(qsTr("Status"), XTreeWidget.statusColumn, Qt.AlignLeft, false, "status");\n _todoList.addColumn(qsTr("Start Date"), XTreeWidget.dateColumn, Qt.AlignLeft, true, "start");\n _todoList.addColumn(qsTr("Due Date"), XTreeWidget.dateColumn, Qt.AlignLeft, true, "due");\n _todoList.addColumn(qsTr("Parent#"), XTreeWidget.orderColumn, Qt.AlignLeft, false, "number");\n _todoList.addColumn(qsTr("Customer#"), XTreeWidget.orderColumn, Qt.AlignLeft, false, "cust");\n _todoList.addColumn(qsTr("Account#"), XTreeWidget.orderColumn, Qt.AlignLeft, true, "crmacct_number");\n _todoList.addColumn(qsTr("Account Name"), 100, Qt.AlignLeft, false, "crmacct_name");\n _todoList.addColumn(qsTr("Owner"), XTreeWidget.userColumn, Qt.AlignLeft, false,"owner");\n\n _todoList.itemSelected.connect(openWindowToDo);\n _todoList["populateMenu(QMenu*,XTreeWidgetItem*,int)"].connect(populateMenuToDo);\n\n if (_dockMytodo)\n {\n _dtTimer.timeout.connect(fillListToDo);\n _dockMytodo.visibilityChanged.connect(fillListToDo);\n\n // Handle privilege control\n var act = _dockMytodo.toggleViewAction();\n\n if (!privileges.check("ViewTodoDock"))\n {\n _dockMytodo.hide();\n act.enabled = false;\n }\n\n // Allow rescan to let them show if privs granted\n act.setData("ViewTodoDock");\n _menuDesktop.appendAction(act);\n }\n\n fillListToDo();\n }\n\n function deleteToDo()\n {\n var answer = QMessageBox.question(mainwindow,\n qsTr("Delete To Do?"),\n qsTr("This will permenantly delete the To Do item. Are you sure?"),\n QMessageBox.Yes | QMessageBox.No,\n QMessageBox.Yes);\n if(answer == QMessageBox.No)\n return;\n\n toolbox.executeDbQuery("desktop","todoDelete", { todoitem_id: _todoList.id() } );\n fillListToDo();\n }\n\n function openWindowToDo()\n {\n params = new Object;\n actId = _todoList.altId();\n act = toDoAct(actId);\n\n // Make sure we can open the window\n if (!privilegeCheckToDo(act))\n return;\n\n // Determine which window to open\n if (act == "D") // To Do\n {\n ui = "todoItem";\n if (privileges.check("MaintainAllToDoItems") || privileges.check("MaintainPersonalToDoItems"))\n params.mode = "edit";\n else\n params.mode = "view";\n params.todoitem_id = _todoList.id();\n }\n else if (act == "I")\n {\n ui = "incident";\n if (privileges.check("MaintainAllIncidents") || privileges.check("MaintainPersonalIncidents"))\n params.mode = "edit";\n else\n params.mode = "view";\n params.incdt_id = _todoList.id();\n }\n else if (act == "T")\n {\n ui = "task";\n if (privileges.check("MaintainAllProjects") || privileges.check("MaintainPersonalProjects"))\n params.mode = "edit";\n else\n params.mode = "view"\n params.prjtask_id = _todoList.id();\n }\n else if (act == "P")\n {\n ui = "project";\n if (privileges.check("MaintainAllProjects") || privileges.check("MaintainPersonalProjects"))\n params.mode = "edit";\n else\n params.mode = "view";\n params.prj_id = _todoList.id();\n }\n\n // Open the window and perform any special handling required\n var newdlg = toolbox.openWindow(ui);\n newdlg.set(params);\n newdlg.exec()\n }\n\n function toDoAct(actId)\n {\n if (actId == 1)\n return "D";\n else if (actId == 2)\n return "I";\n else if (actId == 3)\n return "T";\n else if (actId == 4)\n return "P"\n\n return "";\n }\n\n function populateMenuToDo(pMenu)\n {\n var act = toDoAct(_todoList.altId());\n var menuItem;\n\n menuItem = pMenu.addAction(_open);\n menuItem.enabled = privilegeCheckToDo(act);\n \n menuItem.triggered.connect(openWindowToDo);\n\n if (act == "D")\n {\n menuItem = pMenu.addAction(qsTr("Delete"));\n menuItem.enabled = privileges.check("MaintainAllToDoItems") || \n privileges.check("MaintainPersonalToDoItems");\n menuItem.triggered.connect(deleteToDo);\n }\n }\n\n function privilegeCheckToDo(act)\n {\n if (act == "D") // To Do list\n return privileges.check("MaintainAllToDoItems") || privileges.check("MaintainPersonalToDoItems") ||\n privileges.check("ViewAllToDoItems") || privileges.check("ViewPersonalToDoItems");\n else if (act == "I") // Incidents\n return privileges.check("MaintainAllIncidents") || privileges.check("MaintainPersonalIncidents") ||\n privileges.check("ViewAllIncidents") || privileges.check("ViewPersonalIncidents");\n else if (act == "P" || act == "T") // Projects and Tasks\n return privileges.check("MaintainAllProjects") || privileges.check("MaintainPersonalProjects") ||\n privileges.check("ViewAllProjects") || privileges.check("ViewPersonalProjects");\n\n return false;\n }\n\n}\n\n function fillListToDo()\n {\n if (!_dockMytodo || !_dockMytodo.visible || !_todoList)\n return;\n\n var params = {\n todo: qsTr("To-do"),\n incident: qsTr("Incident"),\n task: qsTr("Task"),\n project: qsTr("Project"),\n todoList: true,\n incidents: true,\n projects: true,\n assigned_username: mainwindow.username(),\n owner_username: mainwindow.username(),\n };\n _todoList.populate(toolbox.executeDbQuery("desktop", "todoList", params), true);\n }\n 78 dockPayables 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockPayables;\nvar _payables;\nvar _payablesIsDirty = true;\n\n/*!\n Initializes Bank Balance dock widget and places it in the main window.\n*/\nfunction initDockPayables()\n{\n _dockPayables = mainwindow.findChild("_dockPayables");\n _ap = mainwindow.findChild("_ap");\n _ap.rootIsDecorated = false;\n\n // Set columns on list\n _ap.addColumn(qsTr("Status"), -1, Qt.AlignLeft, true);\n _ap.addColumn(qsTr("Balance"), -1, Qt.AlignRight, true);\n\n // Connect Signals and Slots\n _dtTimer.timeout.connect(refreshPayables);\n mainwindow.checksUpdated.connect(refreshPayables);\n mainwindow.paymentsUpdated.connect(refreshPayables);\n mainwindow.vouchersUpdated.connect(refreshPayables);\n\n _ap.itemSelected.connect(openWindowPayables);\n _ap["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n .connect(populateMenuPayables);\n\n _dockPayables.visibilityChanged.connect(fillListPayables);\n\n // Handle privilge control\n var act = _dockPayables.toggleViewAction();\n\n // Don't show if no privs\n if (!privileges.check("ViewPayablesDock"))\n {\n _dockPayables.hide();\n act.enabled = false;\n }\n\n // Allow rescan to let them show if privs granted\n act.setData("ViewPayablesDock");\n _menuDesktop.appendAction(act);\n\n fillListPayables();\n}\n\n/*!\n Fills the list with bank account data.\n*/\nfunction fillListPayables()\n{\n _dockPayables = mainwindow.findChild("_dockPayables");\n _ap = mainwindow.findChild("_ap");\n\n if (!_dockPayables.visible || !_payablesIsDirty)\n return;\n\n var q = toolbox.executeDbQuery("desktop","payables");\n q.first();\n \n _ap.clear();\n var item1 = new XTreeWidgetItem(_ap, 0, qsTr("0+ Days"), q.value("cur_val"));\n var item2 = new XTreeWidgetItem(_ap, 1, qsTr("0-30 Days"), q.value("thirty_val"));\n var item3 = new XTreeWidgetItem(_ap, 2, qsTr("31-60 Days"), q.value("sixty_val"));\n var item4 = new XTreeWidgetItem(_ap, 3, qsTr("61-90 Days"), q.value("ninety_val"));\n var item5 = new XTreeWidgetItem(_ap, 4, qsTr("90+ days"), q.value("plus_val"));\n var item6 = new XTreeWidgetItem(_ap, 5, qsTr("Total Open"), q.value("total_val"));\n\n _payablesIsDirty = false;\n}\n\n/*! \n Opens the window associated with the selected item.\n*/\nfunction openWindowPayables()\n{\n // Make sure we can open the window\n if (!privilegeCheckPayables())\n return;\n\n var params = new Object;\n params.run = true;\n\n var asOfDate = mainwindow.dbDate();\n var startDate = new Date();\n var endDate = new Date();\n\n // Open the window and perform any handling required\n toolbox.openWindow("dspAPOpenItemsByVendor");\n\n if (_ap.id() == 0)\n {\n startDate.setDate(asOfDate.getDate());\n toolbox.lastWindow().findChild("_dates").setStartDate(startDate);\n }\n else if (_ap.id() == 1)\n {\n startDate.setDate(asOfDate.getDate() -30);\n endDate.setDate(asOfDate.getDate() -1);\n toolbox.lastWindow().findChild("_dates").setStartDate(startDate);\n toolbox.lastWindow().findChild("_dates").setEndDate(endDate);\n }\n else if (_ap.id() == 2)\n {\n startDate.setDate(asOfDate.getDate() -60);\n endDate.setDate(asOfDate.getDate() -31);\n toolbox.lastWindow().findChild("_dates").setStartDate(startDate);\n toolbox.lastWindow().findChild("_dates").setEndDate(endDate);\n }\n else if (_ap.id() == 3)\n {\n startDate.setDate(asOfDate.getDate() -90);\n endDate.setDate(asOfDate.getDate() -61);\n toolbox.lastWindow().findChild("_dates").setStartDate(startDate);\n toolbox.lastWindow().findChild("_dates").setEndDate(endDate);\n }\n else if (_ap.id() == 4)\n {\n endDate.setDate(asOfDate.getDate() -91);\n toolbox.lastWindow().findChild("_dates").setEndDate(endDate);\n }\n\n toolbox.lastWindow().set(params);\n}\n\n/*!\n Adds actions to @a pMenu, typically from a right click on a bank account item.\n*/\nfunction populateMenuPayables(pMenu, pItem)\n{\n var menuItem;\n var enable = privilegeCheckPayables();\n\n menuItem = pMenu.addAction(_open);\n menuItem.enabled = enable;\n menuItem.triggered.connect(openWindowPayables);\n}\n\n/*!\n Returns whether user has privileges to view detail.\n*/\nfunction privilegeCheckPayables(act)\n{\n return privileges.check("ViewAPOpenItems");\n}\n\n/*!\n Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshPayables()\n{\n _payablesIsDirty = true;\n fillListPayables();\n}\n 79 dockPurchActive 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockPurchAct;\nvar _purchAct;\nvar _purchActIsDirty = true;\n\n/*!\n Initializes Purch Activity dock widget and places it in the main window.\n*/\nfunction initDockPurchAct()\n{\n _dockPurchAct = mainwindow.findChild("_dockPurchAct");\n _purchAct = mainwindow.findChild("_purchAct");\n\n // Set columns on list\n _purchAct.addColumn(qsTr("Type"), -1, Qt.AlignLeft, true, "activity");\n _purchAct.addColumn(qsTr("#"), 40, Qt.AlignRight, true, "count");\n _purchAct.addColumn(qsTr("Amount"), -1, Qt.AlignRight, true, "amount");\n\n // Connect Signals and Slots\n _dtTimer.timeout.connect(refreshPurchAct);\n mainwindow.purchaseOrdersUpdated.connect(refreshPurchAct);\n mainwindow.purchaseOrderReceiptsUpdated.connect(refreshPurchAct);\n mainwindow.purchaseRequestsUpdated.connect(refreshPurchAct);\n mainwindow.vouchersUpdated.connect(refreshPurchAct);\n\n _purchAct.itemSelected.connect(openWindowPurchAct);\n _purchAct["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n .connect(populateMenuPurchAct);\n\n _dockPurchAct.visibilityChanged.connect(fillListPurchAct);\n\n // Handle privilge control\n var act = _dockPurchAct.toggleViewAction();\n\n // Don't show if no privs\n if (!privileges.check("ViewPurchaseActivitiesDock"))\n {\n _dockPurchAct.hide();\n act.enabled = false;\n }\n\n // Allow rescan to let them show if privs granted\n act.setData("ViewPurchaseActivitiesDock");\n _menuDesktop.appendAction(act);\n\n fillListPurchAct();\n}\n\n/*!\n Fills the list with active Purch data.\n*/\nfunction fillListPurchAct()\n{\n _dockPurchAct = mainwindow.findChild("_dockPurchAct");\n _purchAct = mainwindow.findChild("_purchAct");\n\n if (!_dockPurchAct.visible || !_purchActIsDirty)\n return;\n\n var params = new Object;\n if (metrics.value("Application") != "PostBooks")\n {\n params.planned = qsTr("Planned");\n params.firmed = qsTr("Firmed");\n }\n params.request = qsTr("Requests");\n params.unreleased = qsTr("Unreleased");\n params.open = qsTr("Open");\n params.receiving = qsTr("At Receiving");\n params.received = qsTr("Received");\n params.vouchered = qsTr("Vouchered");\n\n _purchAct.populate(toolbox.executeDbQuery("desktop","purchAct", params));\n\n _purchActIsDirty = false;\n}\n\n/*! \n Opens the window associated with the selected item.\n*/\nfunction openWindowPurchAct()\n{\n var ui;\n var run = false;\n var act = _purchAct.currentItem().rawValue("activity");\n \n // Make sure we can open the window for this activity\n if (!privilegeCheckPurchAct(act))\n return;\n\n // Determine which window to open\n if (act == "L")\n ui = "dspPlannedOrders";\n else if (act == "Q")\n ui = "dspPurchaseReqsByPlannerCode";\n else if (act == "U" || act == "O")\n ui = "unpostedPurchaseOrders";\n else if (act == "A")\n ui = "unpostedPoReceipts";\n else if (act == "V")\n ui = "dspUninvoicedReceivings";\n else if (act == "I")\n ui = "openVouchers";\n\n // Open the window and perform any handling required\n toolbox.openWindow(ui);\n if (act == "L")\n {\n// toolbox.lastWindow().findChild("_purchase").forgetful = true;\n// toolbox.lastWindow().findChild("_manufacture").forgetful = true;\n// toolbox.lastWindow().findChild("_transfer").forgetful = true;\n// toolbox.lastWindow().findChild("_purchase").checked = true;\n// toolbox.lastWindow().findChild("_manufacture").checked = false;\n// toolbox.lastWindow().findChild("_transfer").checked = false;\n var params = new Object();\n params.type = "P";\n toolbox.lastWindow().set(params);\n toolbox.lastWindow().sFillList();\n }\n if (act == "U" || act == "O") // Set options for open P/O list\n {\n var showUnreleased = toolbox.lastWindow().findChild("_showUnreleased");\n var showOpen = toolbox.lastWindow().findChild("_showOpen");\n showUnreleased.forgetful = true;\n showOpen.forgetful = true;\n if (act == "U")\n {\n showUnreleased.checked = true;\n showOpen.checked = false;\n }\n else\n {\n showUnreleased.checked = false;\n showOpen.checked = true;\n }\n toolbox.lastWindow().sFillList();\n }\n else if (act == "Q" || act == "V") \n {\n toolbox.lastWindow().findChild("_warehouse").setAll();\n toolbox.lastWindow().sFillList();\n }\n}\n\n/*!\n Adds actions to @a pMenu, typically from a right click on a Purch Activity item.\n*/\nfunction populateMenuPurchAct(pMenu, pItem)\n{\n var menuItem;\n var act = pItem.rawValue("activity");\n var enable = privilegeCheckPurchAct(act);\n\n menuItem = pMenu.addAction(_open);\n menuItem.enabled = enable;\n menuItem.triggered.connect(openWindowPurchAct);\n}\n\n/*!\n Returns whether user has privileges to view detail on the selected Purch Activity.\n*/\nfunction privilegeCheckPurchAct(act)\n{\n if (act == "L") // Planned Orders\n return privileges.check("ViewPlannedOrders");\n else if (act == "Q") // Purchase Requests\n return privileges.check("ViewPurchaseRequests");\n else if (act == "U" || act == "O") // Purchase Orders\n return privileges.check("ViewPurchaseOrders") || \n privileges.check("MaintainPurchaseOrders");\n else if (act == "A") // At Receiving\n return privileges.check("EnterReceipts");\n else if (act == "V") // Unvouchered Receipts\n return privileges.check("ViewUninvoicedReceipts") || \n privileges.check("MaintainUninvoicedReceipts");\n else if (act == "I") // Unposted Vouchers\n return privileges.check("ViewVouchers") || \n privileges.check("MaintainVouchers");\n\n return false;\n}\n\n/*!\n Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshPurchAct()\n{\n _purchActIsDirty = true;\n fillListPurchAct();\n}\n 80 dockPurchHist 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _b1PurchHist;\nvar _b2PurchHist;\nvar _dockPurchHist;\nvar _groupByPurchHist;\nvar _timeFramePurchHist;\nvar _typePurchHist;\nvar _labelPurchHist;\nvar _purchHist;\nvar _purchHistIsDirty = true;\n\n/*!\n Initializes Sales History dock widget and places it in the main window.\n*/\nfunction initDockPurchHist()\n{\n // Set up objects\n _dockPurchHist = mainwindow.findChild("_dockPurchHist");\n _purchHist = mainwindow.findChild("_purchHist");\n\n _b1PurchHist = _dockPurchHist.findChild("_button1");\n _b2PurchHist = _dockPurchHist.findChild("_button2");\n _labelPurchHist = _dockPurchHist.findChild("_label");\n\n // Set icons\n var iReload = new QIcon;\n iReload.addDbImage("reload_16");\n _b1PurchHist.icon = iReload;\n _b1PurchHist.text = "";\n _b1PurchHist.toolTip = qsTr("Reload");\n\n var iGear = new QIcon();\n iGear.addDbImage("gear_16");\n _b2PurchHist.icon = iGear;\n _b2PurchHist.text = "";\n _b2PurchHist.toolTip = qsTr("Preferences...");\n\n // Load local preferences\n loadPreferencesPurchHist();\n\n // Set columns on list\n setColumnsPurchHist();\n\n // Connect Signals and Slots\n _b1PurchHist.clicked.connect(refreshPurchHist);\n _b2PurchHist.clicked.connect(preferencesPurchHist);\n\n _dtTimer.timeout.connect(refreshPurchHist);\n mainwindow.purchaseOrderReceiptsUpdated.connect(refreshPurchHist);\n mainwindow.vouchersUpdated.connect(refreshPurchHist);\n\n _purchHist.itemSelected.connect(openWindowPurchHist);\n _purchHist["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n .connect(populateMenuPurchHist);\n\n _dockPurchHist.visibilityChanged.connect(fillListPurchHist);\n\n // Handle privilge control\n var act = _dockPurchHist.toggleViewAction();\n\n // Don't show if no privs\n if (!privileges.check("ViewPurchaseHistoryDock"))\n {\n _dockPurchHist.hide();\n act.enabled = false;\n }\n\n // Allow rescan to let them show if privs granted\n act.setData("ViewPurchaseHistoryDock");\n _menuDesktop.appendAction(act);\n\n fillListPurchHist();\n}\n\n/*!\n Fills the list with sales history data based on parameters determined by\n sales history preferences.\n\n @sa preferencesPurchHist()\n*/\nfunction fillListPurchHist()\n{\n _dockPurchHist = mainwindow.findChild("_dockPurchHist");\n _purchHist = mainwindow.findChild("_purchHist");\n\n if (!_dockPurchHist.visible || !_purchHistIsDirty) \n return;\n\n var timeFrame;\n var type;\n var params = getDatesPurchHist();\n params.nonInv = qsTr("Non-Inventory");\n\n if (_typePurchHist == "variances")\n params.variances = true;\n else\n params.receipts = true;\n \n if (_groupByPurchHist == "vend")\n {\n params.group_id = "vend_id";\n params.group_number = "vend_number";\n params.group_name = "vend_name";\n }\n else if (_groupByPurchHist == "item")\n {\n params.group_id = "item_id";\n params.group_number = "item_number";\n params.group_name = "item_descrip1";\n }\n else if (_groupByPurchHist == "agent")\n {\n params.group_id = "1";\n params.group_number = "pohead_agent_username";\n params.group_name = "usr_propername";\n }\n\n _purchHist.populate(toolbox.executeDbQuery("desktop","purchHist", params));\n\n if ("variances" in params)\n type = qsTr("Variances");\n else\n type = qsTr("Receipts");\n\n if (_timeFramePurchHist == "day")\n timeFrame = qsTr("Today");\n else if (_timeFramePurchHist == "week")\n timeFrame = qsTr("this Week");\n else if (_timeFramePurchHist == "month")\n timeFrame = qsTr("this Month");\n else if (_timeFramePurchHist == "year")\n timeFrame = qsTr("this Year");\n\n _labelPurchHist.text = type + " " + timeFrame;\n\n _purchHistIsDirty = false;\n}\n\n/*!\n Returns an object with a list containing @a startDate and @a endDate\n that is used for fetching data and opening windows using the date range\n stored in local preferences.\n \n @sa preferencesPurchHist()\n @sa openWindowPurchHist()\n @sa fillListPurchHist()\n*/\nfunction getDatesPurchHist()\n{\n var params = new Object;\n\n params.timeFrame = _timeFramePurchHist;\n params.interval = "1 " + _timeFramePurchHist;\n\n var q = toolbox.executeDbQuery("desktop", "getDates", params);\n\n if (q.first())\n {\n params.startDate = q.value("startDate");\n params.endDate = q.value("endDate");\n }\n\n return params;\n}\n\n/*! \n Loads local Sales History preferences into memory.\n\n @sa preferencesPurchHist()\n*/\nfunction loadPreferencesPurchHist()\n{\n // Load preferences\n _groupByPurchHist = preferences.value("desktop/purchHist/groupBy");\n _timeFramePurchHist = preferences.value("desktop/purchHist/timeFrame");\n _typePurchHist = preferences.value("desktop/purchHist/type")\n \n // Set to defaults if no values\n _groupByPurchHist = (_groupByPurchHist.length ? _groupByPurchHist : "vend");\n _timeFramePurchHist = (_timeFramePurchHist.length ? _timeFramePurchHist : "year");\n _typePurchHist = (_typePurchHist.length ? _typePurchHist : "receipts");\n}\n\n/*! \n Opens the window associated with the selected item.\n*/\nfunction openWindowPurchHist()\n{\n var ui;\n var params = getDatesPurchHist();\n params.run = true;\n\n // TO DO: Work it out so totals launch a window too\n if (_purchHist.id() == -1)\n return;\n \n // Make sure we can open the window\n if (!privilegeCheckPurchHist())\n return;\n\n // Determine which window to open\n if (_groupByPurchHist == "vend")\n {\n if (_typePurchHist == "variances")\n ui = "dspPoPriceVariancesByVendor";\n else\n ui = "dspPoItemReceivingsByVendor";\n params.cust_id = _purchHist.id();\n }\n else if (_groupByPurchHist == "item")\n {\n if (_purchHist.id() == -2)\n {\n QMessageBox.warning(mainwindow, qsTr("Unsupported Action"),\n qsTr("Drill down on Non-Inventory Items is not yet supported"));\n return;\n }\n if (_typePurchHist == "variances")\n ui = "dspPoPriceVariancesByItem";\n else\n ui = "dspPoItemReceivingsByItem";\n params.prodcat_id = _purchHist.id();\n }\n else if (_groupByPurchHist == "agent")\n {\n if (_typePurchHist == "variances")\n ui = "dspPoPriceVariancesByVendor";\n else\n ui = "dspPoItemReceivingsByDate";\n params.salesrep_id = _purchHist.id();\n }\n\n // Open the window and perform any special handling required\n toolbox.openWindow(ui);\n var warehouse = toolbox.lastWindow().findChild("_warehouse");\n warehouse.setAll();\n if (_typePurchHist == "receipts")\n {\n toolbox.lastWindow().findChild("_showUnvouchered").forgetful = true;\n toolbox.lastWindow().findChild("_showUnvouchered").checked = true; \n }\n if (_groupByPurchHist == "vend")\n {\n if (_typePurchHist == "variances")\n toolbox.lastWindow().findChild("_vendorGroup").setVendId(_purchHist.id());\n else\n toolbox.lastWindow().findChild("_vendor").setId(_purchHist.id());\n }\n else if (_groupByPurchHist == "item")\n toolbox.lastWindow().findChild("_item").setId(_purchHist.id()); \n else if (_groupByPurchHist == "agent")\n {\n toolbox.lastWindow().findChild("_selectedPurchasingAgent").checked = true;\n toolbox.lastWindow().findChild("_agent").code = \n _purchHist.currentItem().rawValue("pohead_agent_username")\n }\n\n var dates = toolbox.lastWindow().findChild("_dates");\n dates.setStartDate(params.startDate);\n dates.setEndDate(params.endDate);\n toolbox.lastWindow().sFillList();\n}\n\n/*!\n Adds actions to @a pMenu, typically from a right click on sales history.\n*/\nfunction populateMenuPurchHist(pMenu)\n{\n var menuItem;\n var enable = privilegeCheckPurchHist();\n\n menuItem = pMenu.addAction(_open);\n menuItem.enabled = enable;\n menuItem.triggered.connect(openWindowPurchHist);\n}\n\n/*!\n Returns whether user has privileges to view Sales History detail.\n*/\nfunction privilegeCheckPurchHist()\n{\n if (_typePurchHist == "variances")\n return privileges.check("ViewVendorPerformance");\n else if (_typePurchHist == "receipts")\n return privileges.check("ViewReceiptsReturns");\n \n return false;\n}\n\n/*! \n Set up columns depending on local preferences.\n\n @sa preferencesPurchHist()\n*/\nfunction setColumnsPurchHist()\n{\n _purchHist.columnCount = 0;\n\n if (_groupByPurchHist == "vend")\n {\n _purchHist.addColumn(qsTr("Vendor"), -1, Qt.AlignLeft, true, "vend_number");\n _purchHist.addColumn(qsTr("Name"), -1, Qt.AlignLeft, false, "vend_name");\n }\n else if (_groupByPurchHist == "item")\n {\n _purchHist.addColumn(qsTr("Item Number"), -1, Qt.AlignLeft, true, "item_number");\n _purchHist.addColumn(qsTr("Description"), -1, Qt.AlignLeft, false, "item_descrip1");\n }\n else if (_groupByPurchHist == "agent")\n {\n _purchHist.addColumn(qsTr("Purch. Agent"), -1, Qt.AlignLeft, true, "pohead_agent_username");\n _purchHist.addColumn(qsTr("Name"), -1, Qt.AlignLeft, false, "usr_propername");\n }\n\n _purchHist.addColumn(qsTr("Amount"), -1, Qt.AlignRight, true, "amount");\n _purchHist.addColumn(qsTr("Qty."), -1, Qt.AlignRight, false, "qty");\n}\n\n/*! \n Launches the preferences window where the user can set sales data output preferences.\n*/\nfunction preferencesPurchHist()\n{\n params = new Object;\n params.path = "desktop/purchHist";\n params.groupBy = _groupByPurchHist;\n params.timeFrame = _timeFramePurchHist;\n params.type = _typePurchHist;\n\n var newdlg = toolbox.openWindow("preferencesHistory", mainwindow,\n Qt.ApplicationModal, Qt.Dialog);\n toolbox.lastWindow().set(params);\n if (newdlg.exec())\n {\n loadPreferencesPurchHist();\n setColumnsPurchHist();\n refreshPurchHist();\n }\n}\n\n/*!\n Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshPurchHist()\n{\n _purchHistIsDirty = true;\n fillListPurchHist();\n}\n 81 dockPurchOpen 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockPurchOpen;\nvar _purchOpen;\nvar _purchOpenIsDirty = true;\n\n/*!\n Initializes Open Purchase Order dock widget and places it in the main window.\n*/\nfunction initDockPurchOpen()\n{\n _dockPurchOpen = mainwindow.findChild("_dockPurchOpen");\n _purchOpen = mainwindow.findChild("_purchOpen");\n\n // Set columns on list\n _purchOpen.addColumn(qsTr("Order#"), XTreeWidget.orderColumn, Qt.AlignLeft, true, "pohead_number");\n _purchOpen.addColumn(qsTr("Vendor#"), XTreeWidget.orderColumn, Qt.AlignLeft, true, "vend_number");\n _purchOpen.addColumn(qsTr("Name"), -1, Qt.AlignLeft, true, "vend_name");\n _purchOpen.addColumn(qsTr("Contact"), -1, Qt.AlignLeft, true, "vend_cntct");\n _purchOpen.addColumn(qsTr("Phone"), -1, Qt.AlignLeft, true, "pohead_vend_cntct_phone"); \n _purchOpen.addColumn(qsTr("Status"), -1, Qt.AlignLeft, true, "status");\n _purchOpen.addColumn(qsTr("Ship Contact"), -1, Qt.AlignLeft, false, "shipto_cntct");\n _purchOpen.addColumn(qsTr("Ship Phone"), -1, Qt.AlignLeft, false, "pohead_shipto_cntct_phone"); \n _purchOpen.addColumn(qsTr("Ship Via"), -1, Qt.AlignLeft, true, "pohead_shipvia"); \n _purchOpen.addColumn(qsTr("Due Date"), XTreeWidget.dateColumn, Qt.AlignLeft, true, "duedate");\n _purchOpen.addColumn(qsTr("Amount"), XTreeWidget.moneyColumn, Qt.AlignRight, true, "amount");\n\n // Connect Signals and Slots\n _dtTimer.timeout.connect(refreshPurchOpen);\n mainwindow.purchaseOrderReceiptsUpdated.connect(refreshPurchOpen);\n mainwindow.purchaseOrdersUpdated.connect(refreshPurchOpen);\n\n _purchOpen.itemSelected.connect(openWindowPurchOpen);\n _purchOpen["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n .connect(populateMenuPurchOpen);\n\n _dockPurchOpen.visibilityChanged.connect(fillListPurchOpen);\n\n // Handle privilge control\n var act = _dockPurchOpen.toggleViewAction();\n\n // Don't show if no privs\n if (!privileges.check("ViewPurchaseOrdersDock"))\n {\n _dockPurchOpen.hide();\n act.enabled = false;\n }\n\n // Allow rescan to let them show if privs granted\n act.setData("ViewPurchaseOrdersDock");\n _menuDesktop.appendAction(act);\n\n fillListPurchOpen();\n}\n\n/*!\n Fills the list with open purchase data.\n*/\nfunction fillListPurchOpen()\n{\n _dockPurchOpen = mainwindow.findChild("_dockPurchOpen");\n _purchOpen = mainwindow.findChild("_purchOpen");\n\n if (!_dockPurchOpen.visible || !_purchOpenIsDirty)\n return;\n\n var params = new Object;\n params.open = qsTr("Open");\n params.unreleased = qsTr("Unreleased");\n\n _purchOpen.populate(toolbox.executeDbQuery("desktop","purchOpen",params));\n _purchOpenIsDirty = false;\n}\n\n/*! \n Opens the window associated with the selected item.\n*/\nfunction openWindowPurchOpen()\n{ \n // Make sure we can open the window for this activity\n if (!privilegeCheckPurchOpen)\n return;\n\n params = new Object;\n params.pohead_id = _purchOpen.id();\n if (privileges.check("MaintainPurchaseOrders"))\n params.mode = "edit";\n else\n params.mode = "view";\n\n // Open the window and perform any handling required\n var po = toolbox.openWindow("purchaseOrder");\n po.set(params);\n}\n\n/*!\n Adds actions to @a pMenu, typically from a right click on a Purchase Order item.\n*/\nfunction populateMenuPurchOpen(pMenu, pItem)\n{\n var menuItem;\n var enable = privilegeCheckPurchOpen();\n\n menuItem = pMenu.addAction(_open);\n menuItem.enabled = enable;\n menuItem.triggered.connect(openWindowPurchOpen);\n}\n\n/*!\n Returns whether user has privileges to view detail on the selected Purchase Order.\n*/\nfunction privilegeCheckPurchOpen()\n{\n return privileges.check("ViewPurchaseOrders") || \n privileges.check("MaintainPurchaseOrders");\n\n return false;\n}\n\n/*!\n Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshPurchOpen()\n{\n _purchOpenIsDirty = true;\n fillListPurchOpen();\n}\n 82 dockReceivables 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockReceivables;\nvar _receivables;\nvar _receivablesIsDirty = true;\n\n/*!\n Initializes Bank Balance dock widget and places it in the main window.\n*/\nfunction initDockReceivables()\n{\n _dockReceivables = mainwindow.findChild("_dockReceivables");\n _ar = mainwindow.findChild("_ar");\n _ar.rootIsDecorated = false;\n\n // Set columns on list\n _ar.addColumn(qsTr("Status"), -1, Qt.AlignLeft, true);\n _ar.addColumn(qsTr("Balance"), -1, Qt.AlignRight, true);\n\n // Connect Signals and Slots\n _dtTimer.timeout.connect(refreshReceivables);\n mainwindow.checksUpdated.connect(refreshReceivables);\n mainwindow.paymentsUpdated.connect(refreshReceivables);\n mainwindow.vouchersUpdated.connect(refreshReceivables);\n\n _ar.itemSelected.connect(openWindowReceivables);\n _ar["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n .connect(populateMenuReceivables);\n\n _dockReceivables.visibilityChanged.connect(fillListReceivables);\n\n // Handle privilge control\n var act = _dockReceivables.toggleViewAction();\n\n // Don't show if no privs\n if (!privileges.check("ViewReceivablesDock"))\n {\n _dockReceivables.hide();\n act.enabled = false;\n }\n\n // Allow rescan to let them show if privs granted\n act.setData("ViewReceivablesDock");\n _menuDesktop.appendAction(act);\n\n fillListReceivables();\n}\n\n/*!\n Fills the list with bank account data.\n*/\nfunction fillListReceivables()\n{\n _dockReceivables = mainwindow.findChild("_dockReceivables");\n _ar = mainwindow.findChild("_ar");\n\n if (!_dockReceivables.visible || !_receivablesIsDirty)\n return;\n\n var q = toolbox.executeDbQuery("desktop","receivables");\n q.first();\n \n _ar.clear();\n var item1 = new XTreeWidgetItem(_ar, 0, qsTr("0+ Days"), q.value("cur_val"));\n var item2 = new XTreeWidgetItem(_ar, 1, qsTr("0-30 Days"), q.value("thirty_val"));\n var item3 = new XTreeWidgetItem(_ar, 2, qsTr("31-60 Days"), q.value("sixty_val"));\n var item4 = new XTreeWidgetItem(_ar, 3, qsTr("61-90 Days"), q.value("ninety_val"));\n var item5 = new XTreeWidgetItem(_ar, 4, qsTr("90+ days"), q.value("plus_val"));\n var item6 = new XTreeWidgetItem(_ar, 5, qsTr("Total Open"), q.value("total_val"));\n\n _receivablesIsDirty = false;\n}\n\n/*! \n Opens the window associated with the selected item.\n*/\nfunction openWindowReceivables()\n{\n // Make sure we can open the window\n if (!privilegeCheckReceivables())\n return;\n\n var params = new Object;\n params.run = true;\n params.byDueDate = true;\n\n var asOfDate = mainwindow.dbDate();\n var startDate = new Date();\n var endDate = new Date();\n\n // Open the window and perform any handling required\n toolbox.openWindow("dspAROpenItems");\n\n if (_ar.id() == 0)\n {\n startDate.setDate(asOfDate.getDate());\n toolbox.lastWindow().findChild("_dates").setStartDate(startDate);\n }\n else if (_ar.id() == 1)\n {\n startDate.setDate(asOfDate.getDate() -30);\n endDate.setDate(asOfDate.getDate() -1);\n toolbox.lastWindow().findChild("_dates").setStartDate(startDate);\n toolbox.lastWindow().findChild("_dates").setEndDate(endDate);\n }\n else if (_ar.id() == 2)\n {\n startDate.setDate(asOfDate.getDate() -60);\n endDate.setDate(asOfDate.getDate() -31);\n toolbox.lastWindow().findChild("_dates").setStartDate(startDate);\n toolbox.lastWindow().findChild("_dates").setEndDate(endDate);\n }\n else if (_ar.id() == 3)\n {\n startDate.setDate(asOfDate.getDate() -90);\n endDate.setDate(asOfDate.getDate() -61);\n toolbox.lastWindow().findChild("_dates").setStartDate(startDate);\n toolbox.lastWindow().findChild("_dates").setEndDate(endDate);\n }\n else if (_ar.id() == 4)\n {\n endDate.setDate(asOfDate.getDate() -91);\n toolbox.lastWindow().findChild("_dates").setEndDate(endDate);\n }\n\n toolbox.lastWindow().set(params);\n}\n\n/*!\n Adds actions to @a pMenu, typically from a right click on a bank account item.\n*/\nfunction populateMenuReceivables(pMenu, pItem)\n{\n var menuItem;\n var enable = privilegeCheckReceivables();\n\n menuItem = pMenu.addAction(_open);\n menuItem.enabled = enable;\n menuItem.triggered.connect(openWindowReceivables);\n}\n\n/*!\n Returns whether user has privileges to view detail.\n*/\nfunction privilegeCheckReceivables(act)\n{\n return privileges.check("ViewAROpenItems");\n}\n\n/*!\n Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshReceivables()\n{\n _receivablesIsDirty = true;\n fillListReceivables();\n}\n 83 dockSalesActive 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockSalesAct;\nvar _salesAct;\n\n/*!\n Initializes Sales Activity dock widget and places it in the main window.\n*/\nfunction initDockSalesAct()\n{\n var _salesActIsDirty = true;\n\n _dockSalesAct = mainwindow.findChild("_dockSalesAct");\n _salesAct = mainwindow.findChild("_salesAct");\n\n _salesAct.addColumn(qsTr("Type"), -1, Qt.AlignLeft, true, "activity");\n _salesAct.addColumn(qsTr("#"), 40, Qt.AlignRight, true, "count");\n _salesAct.addColumn(qsTr("Amount"), -1, Qt.AlignRight, true, "amount");\n\n _dtTimer.timeout.connect(refreshSalesAct);\n mainwindow.billingSelectionUpdated.connect(refreshSalesAct);\n mainwindow.invoicesUpdated.connect(refreshSalesAct);\n mainwindow.quotesUpdated.connect(refreshSalesAct)\n mainwindow.salesOrdersUpdated.connect(refreshSalesAct);\n\n _salesAct.itemSelected.connect(openWindowSalesAct);\n _salesAct["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n .connect(populateMenuSalesAct);\n\n _dockSalesAct.visibilityChanged.connect(fillListSalesAct);\n\n // Handle privilege control\n var act = _dockSalesAct.toggleViewAction();\n\n if (!privileges.check("ViewSalesActivitiesDock"))\n {\n _dockSalesAct.hide();\n act.enabled = false;\n }\n\n // Allow rescan to let them show if privs granted\n act.setData("ViewSalesActivitiesDock");\n _menuDesktop.appendAction(act);\n fillListSalesAct();\n\n function fillListSalesAct()\n {\n if (! _dockSalesAct || !_dockSalesAct.visible || !_salesActIsDirty)\n return;\n\n var params = {\n quotes: qsTr("Quotes"),\n open: qsTr("Orders"),\n print: qsTr("To Print"),\n pick: qsTr("Pick"),\n ship: qsTr("At Shipping"),\n bill: qsTr("Shipped"),\n invoice: qsTr("To Bill"),\n post: qsTr("Invoiced"),\n };\n\n _salesAct.populate(toolbox.executeDbQuery("desktop", "salesAct", params));\n _salesActIsDirty = false;\n }\n\n function openWindowSalesAct()\n {\n var ui;\n var run = false;\n var act = _salesAct.currentItem().rawValue("activity");\n \n // Make sure we can open the window for this activity\n if (!privilegeCheckSalesAct(act))\n return;\n\n // Determine which window to open\n if (act == "Q")\n {\n ui = "quotes";\n run = true;\n }\n else if (act == "O")\n {\n ui = "openSalesOrders";\n run = true;\n }\n else if (act == "P")\n ui = "packingListBatch";\n else if (act == "S")\n {\n ui = "maintainShipping";\n run = true;\n }\n else if (act == "B")\n ui = "uninvoicedShipments";\n else if (act == "I")\n ui = "dspBillingSelections";\n else if (act == "T")\n ui = "unpostedInvoices";\n\n // Open the window and perform any handling required\n toolbox.openWindow(ui);\n if (run)\n toolbox.lastWindow().sFillList();\n }\n\n function populateMenuSalesAct(pMenu, pItem)\n {\n var menuItem;\n var act = pItem.rawValue("activity");\n var enable = privilegeCheckSalesAct(act);\n\n menuItem = pMenu.addAction(_open);\n menuItem.enabled = enable;\n menuItem.triggered.connect(openWindowSalesAct);\n }\n\n function privilegeCheckSalesAct(act)\n {\n if (act == "Q") // Quote\n return privileges.check("ViewQuotes") || \n privileges.check("MaintainQuotes")\n else if (act == "O") // Open Sales Orders\n return privileges.check("ViewSalesOrders") || \n privileges.check("MaintainSalesOrders");\n else if (act == "P") // Packlist Batch\n return privileges.check("ViewPackingListBatch") || \n privileges.check("MaintainPackingListBatch");\n else if (act == "S") // Shipping\n return privileges.check("ViewShipping");\n else if (act == "B" || \n act == "I" || \n act == "T") // Billing, Invoicing\n return privileges.check("SelectBilling");\n\n return false;\n }\n\n function refreshSalesAct()\n {\n _salesActIsDirty = true;\n fillListSalesAct();\n }\n}\n 84 dockSalesHistory 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _b1SalesHist;\nvar _b2SalesHist;\nvar _dockSalesHist;\nvar _groupBySalesHist;\nvar _timeFrameSalesHist;\nvar _typeSalesHist;\nvar _labelSalesHist;\nvar _salesHist;\nvar _salesHistIsDirty = true;\n\n/*!\n Initializes Sales History dock widget and places it in the main window.\n*/\nfunction initDockSalesHist()\n{\n // Set up objects\n _dockSalesHist = mainwindow.findChild("_dockSalesHist");\n _salesHist = mainwindow.findChild("_salesHist");\n\n _b1SalesHist = _dockSalesHist.findChild("_button1");\n _b2SalesHist = _dockSalesHist.findChild("_button2");\n _labelSalesHist = _dockSalesHist.findChild("_label");\n\n // Set icons\n var iReload = new QIcon;\n iReload.addDbImage("reload_16");\n _b1SalesHist.icon = iReload;\n _b1SalesHist.text = "";\n _b1SalesHist.toolTip = qsTr("Reload");\n\n var iGear = new QIcon();\n iGear.addDbImage("gear_16");\n _b2SalesHist.icon = iGear;\n _b2SalesHist.text = "";\n _b2SalesHist.toolTip = qsTr("Preferences...");\n\n // Load local preferences\n loadPreferencesSalesHist();\n\n // Set columns on list\n setColumnsSalesHist();\n\n // Populate the data\n fillListSalesHist();\n\n // Connect Signals and Slots\n _b1SalesHist.clicked.connect(refreshSalesHist);\n _b2SalesHist.clicked.connect(preferencesSalesHist);\n\n _dtTimer.timeout.connect(refreshSalesHist);\n mainwindow.salesOrdersUpdated.connect(refreshSalesHist);\n\n _salesHist.itemSelected.connect(openWindowSalesHist);\n _salesHist["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n .connect(populateMenuSalesHist);\n\n _dockSalesHist.visibilityChanged.connect(fillListSalesHist);\n\n // Handle privilge control\n var act = _dockSalesHist.toggleViewAction();\n\n // Don't show if no privs\n if (!privileges.check("ViewSalesHistoryDock"))\n {\n _dockSalesHist.hide();\n act.enabled = false;\n }\n\n // Allow rescan to let them show if privs granted\n act.setData("ViewSalesHistoryDock");\n _menuDesktop.appendAction(act);\n\n fillListSalesHist();\n}\n\n/*!\n Fills the list with sales history data based on parameters determined by\n sales history preferences.\n\n @sa preferencesSalesHist()\n*/\nfunction fillListSalesHist()\n{\n _dockSalesHist = mainwindow.findChild("_dockSalesHist");\n _salesHist = mainwindow.findChild("_salesHist");\n\n if (!_dockSalesHist.visible || !_salesHistIsDirty)\n return;\n\n var timeFrame;\n var type;\n var params = getDatesSalesHist();\n\n if (_typeSalesHist == "bookings")\n params.bookings = true;\n else\n params.sales = true;\n \n if (_groupBySalesHist == "cust")\n {\n params.group_id = "cust_id";\n params.group_number = "cust_number";\n params.group_name = "cust_name";\n }\n else if (_groupBySalesHist == "prodcat")\n {\n params.group_id = "prodcat_id";\n params.group_number = "prodcat_code";\n params.group_name = "prodcat_descrip";\n }\n else if (_groupBySalesHist == "salesrep")\n {\n params.group_id = "salesrep_id";\n params.group_number = "salesrep_number";\n params.group_name = "salesrep_name";\n }\n\n _salesHist.populate(toolbox.executeDbQuery("desktop","salesHist", params));\n\n if ("bookings" in params)\n type = qsTr("Bookings");\n else\n type = qsTr("Sales");\n\n if (_timeFrameSalesHist == "day")\n timeFrame = qsTr("Today");\n else if (_timeFrameSalesHist == "week")\n timeFrame = qsTr("this Week");\n else if (_timeFrameSalesHist == "month")\n timeFrame = qsTr("this Month");\n else if (_timeFrameSalesHist == "year")\n timeFrame = qsTr("this Year");\n\n _labelSalesHist.text = type + " " + timeFrame;\n\n _salesHistIsDirty = false;\n}\n\n/*!\n Returns an object with a list containing @a startDate and @a endDate\n that is used for fetching data and opening windows using the date range\n stored in local preferences.\n \n @sa preferencesSalesHist()\n @sa openWindowSalesHist()\n @sa fillListSalesHist()\n*/\nfunction getDatesSalesHist()\n{\n var params = new Object;\n\n params.timeFrame = _timeFrameSalesHist;\n params.interval = "1 " + _timeFrameSalesHist;\n\n var q = toolbox.executeDbQuery("desktop", "getDates", params);\n\n if (q.first())\n {\n params.startDate = q.value("startDate");\n params.endDate = q.value("endDate");\n }\n\n return params;\n}\n\n/*! \n Loads local Sales History preferences into memory.\n\n @sa preferencesSalesHist()\n*/\nfunction loadPreferencesSalesHist()\n{\n // Load preferences\n _groupBySalesHist = preferences.value("desktop/salesHist/groupBy");\n _timeFrameSalesHist = preferences.value("desktop/salesHist/timeFrame");\n _typeSalesHist = preferences.value("desktop/salesHist/type")\n \n // Set to defaults if no values\n _groupBySalesHist = (_groupBySalesHist.length ? _groupBySalesHist : "cust");\n _timeFrameSalesHist = (_timeFrameSalesHist.length ? _timeFrameSalesHist : "year");\n _typeSalesHist = (_typeSalesHist.length ? _typeSalesHist : "bookings");\n}\n\n/*! \n Opens the window associated with the selected item.\n*/\nfunction openWindowSalesHist()\n{\n var ui;\n var params = getDatesSalesHist();\n params.run = true;\n\n // TO DO: Work it out so totals launch a window too\n if (_salesHist.id() == -1)\n return;\n \n // Make sure we can open the window\n if (!privilegeCheckSalesHist())\n return;\n\n // Determine which window to open\n if (_typeSalesHist == "bookings")\n ui = "dspBookings";\n else\n ui = "dspSalesHistory";\n if (_groupBySalesHist == "cust")\n params.cust_id = _salesHist.id();\n else if (_groupBySalesHist == "prodcat")\n params.prodcat_id = _salesHist.id();\n else if (_groupBySalesHist == "salesrep")\n params.salesrep_id = _salesHist.id();\n\n // Open the window and perform any special handling required\n toolbox.openWindow(ui);\n toolbox.lastWindow().set(params);\n}\n\n/*!\n Adds actions to @a pMenu, typically from a right click on sales history.\n*/\nfunction populateMenuSalesHist(pMenu)\n{\n var menuItem;\n var enable = privilegeCheckSalesHist();\n\n menuItem = pMenu.addAction(_open);\n menuItem.enabled = enable;\n menuItem.triggered.connect(openWindowSalesHist);\n}\n\n/*!\n Returns whether user has privileges to view Sales History detail.\n*/\nfunction privilegeCheckSalesHist()\n{\n return privileges.check("ViewSalesHistory");\n}\n\n/*! \n Set up columns depending on local preferences.\n\n @sa preferencesSalesHist()\n*/\nfunction setColumnsSalesHist()\n{\n _salesHist.columnCount = 0;\n\n if (_groupBySalesHist == "cust")\n {\n _salesHist.addColumn(qsTr("Customer"), -1, Qt.AlignLeft, true, "cust_number");\n _salesHist.addColumn(qsTr("Name"), -1, Qt.AlignLeft, false, "cust_name");\n }\n else if (_groupBySalesHist == "prodcat")\n {\n _salesHist.addColumn(qsTr("Product Category"), -1, Qt.AlignLeft, true, "prodcat_code");\n _salesHist.addColumn(qsTr("Description"), -1, Qt.AlignLeft, false, "prodcat_descrip");\n }\n else if (_groupBySalesHist == "salesrep")\n {\n _salesHist.addColumn(qsTr("Sales Rep."), -1, Qt.AlignLeft, true, "salesrep_number");\n _salesHist.addColumn(qsTr("Name"), -1, Qt.AlignLeft, false, "salesrep_name");\n }\n\n _salesHist.addColumn(qsTr("Amount"), -1, Qt.AlignRight, true, "amount");\n _salesHist.addColumn(qsTr("Qty."), -1, Qt.AlignRight, false, "qty");\n}\n\n/*! \n Launches the preferences window where the user can set sales data output preferences.\n*/\nfunction preferencesSalesHist()\n{\n params = new Object;\n params.path = "desktop/salesHist";\n params.groupBy = _groupBySalesHist;\n params.timeFrame = _timeFrameSalesHist;\n params.type = _typeSalesHist;\n\n var newdlg = toolbox.openWindow("preferencesHistory", mainwindow,\n Qt.ApplicationModal, Qt.Dialog);\n toolbox.lastWindow().set(params);\n if (newdlg.exec())\n {\n loadPreferencesSalesHist();\n setColumnsSalesHist();\n refreshSalesHist();\n }\n}\n\n/*!\n Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshSalesHist()\n{\n _salesHistIsDirty = true;\n fillListSalesHist();\n}\n 85 dockSalesOpen 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockSalesOpen;\nvar _salesOpen;\nvar _salesOpenIsDirty = true;\n\n/*!\n Initializes Open Sales Order dock widget and places it in the main window.\n*/\nfunction initDockSalesOpen()\n{\n _dockSalesOpen = mainwindow.findChild("_dockSalesOpen");\n _salesOpen = mainwindow.findChild("_salesOpen");\n\n // Set columns on list\n _salesOpen.addColumn(qsTr("Order#"), XTreeWidget.orderColumn, Qt.AlignLeft, true, "cohead_number");\n _salesOpen.addColumn(qsTr("Customer#"), XTreeWidget.orderColumn, Qt.AlignLeft, true, "cust_number");\n _salesOpen.addColumn(qsTr("Bill To"), -1, Qt.AlignLeft, true, "cohead_billtoname");\n _salesOpen.addColumn(qsTr("Bill Contact"), -1, Qt.AlignLeft, false, "billto_cntct");\n _salesOpen.addColumn(qsTr("Bill Phone"), -1, Qt.AlignLeft, false, "cohead_billto_cntct_phone"); \n _salesOpen.addColumn(qsTr("Ship To"), -1, Qt.AlignLeft, true, "cohead_shiptoname");\n _salesOpen.addColumn(qsTr("Ship Contact"), -1, Qt.AlignLeft, false, "shipto_cntct");\n _salesOpen.addColumn(qsTr("Ship Phone"), -1, Qt.AlignLeft, false, "cohead_shipto_cntct_phone");\n _salesOpen.addColumn(qsTr("Ship Via"), -1, Qt.AlignLeft, true, "cohead_shipvia"); \n _salesOpen.addColumn(qsTr("Sched. Date"), XTreeWidget.dateColumn, Qt.AlignLeft, true, "scheddate");\n _salesOpen.addColumn(qsTr("Amount"), XTreeWidget.moneyColumn, Qt.AlignRight, true, "amount");\n\n // Connect Signals and Slots\n _dtTimer.timeout.connect(refreshSalesOpen);\n mainwindow.invoicesUpdated.connect(refreshSalesOpen);\n mainwindow.salesOrdersUpdated.connect(refreshSalesOpen);\n\n _salesOpen.itemSelected.connect(openWindowSalesOpen);\n _salesOpen["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n .connect(populateMenuSalesOpen);\n\n _dockSalesOpen.visibilityChanged.connect(fillListSalesOpen);\n\n // Handle privilge control\n var act = _dockSalesOpen.toggleViewAction();\n\n // Don't show if no privs\n if (!privileges.check("ViewSalesOrdersDock"))\n {\n _dockSalesOpen.hide();\n act.enabled = false;\n }\n\n // Allow rescan to let them show if privs granted\n act.setData("ViewSalesOrdersDock");\n _menuDesktop.appendAction(act);\n\n fillListSalesOpen();\n}\n\n/*!\n Fills the list with open sales data.\n*/\nfunction fillListSalesOpen()\n{\n _dockSalesOpen = mainwindow.findChild("_dockSalesOpen");\n _salesOpen = mainwindow.findChild("_salesOpen");\n\n if (!_dockSalesOpen.visible || !_salesOpenIsDirty)\n return;\n\n _salesOpen.populate(toolbox.executeDbQuery("desktop","salesOpen"));\n\n _salesOpenIsDirty = false;\n}\n\n/*! \n Opens the window associated with the selected item.\n*/\nfunction openWindowSalesOpen()\n{ \n // Make sure we can open the window for this activity\n if (!privilegeCheckSalesOpen)\n return;\n\n params = new Object;\n params.sohead_id = _salesOpen.id();\n if (privileges.check("MaintainSalesOrders"))\n params.mode = "edit";\n else\n params.mode = "view";\n\n // Open the window and perform any handling required\n var so = toolbox.openWindow("salesOrder");\n so.set(params);\n\n}\n\n/*!\n Adds actions to @a pMenu, typically from a right click on a Sales Order item.\n*/\nfunction populateMenuSalesOpen(pMenu, pItem)\n{\n var menuItem;\n var enable = privilegeCheckSalesOpen();\n\n menuItem = pMenu.addAction(_open);\n menuItem.enabled = enable;\n menuItem.triggered.connect(openWindowSalesOpen);\n}\n\n/*!\n Returns whether user has privileges to view detail on the selected Sales Order.\n*/\nfunction privilegeCheckSalesOpen()\n{\n return privileges.check("ViewSalesOrders") || \n privileges.check("MaintainSalesOrders");\n\n return false;\n}\n\n/*!\n Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshSalesOpen()\n{\n _salesOpenIsDirty = true;\n fillListSalesOpen();\n}\n 128 dockSendMessage 0 t var _dockSendMessage;\nvar _usr;\nvar _message;\nvar _send;\nvar _sendMessageIsDirty = true;\nvar _periodId = -1;\nvar _b1CommentConsole;\nvar _b2CommentConsole;\nvar _commentConsole;\nvar _commentConsoleIsDirty = true;\nvar _periodId = -1;\n\nfunction initDockSendMessage()\n{\n // Set up objects\n _dockSendMessage = mainwindow.findChild("_dockSendMessage");\n _usr = mainwindow.findChild("_usr");\n _message = mainwindow.findChild("_message");\n _send = mainwindow.findChild("_send");\n\n _commentConsole = mainwindow.findChild("_commentConsole");\n\n _b1CommentConsole = mainwindow.findChild("_button1");\n _b2CommentConsole = mainwindow.findChild("_button2");\n\n // Set icons\n var iReload = new QIcon;\n iReload.addDbImage("reload_16");\n _b1CommentConsole.icon = iReload;\n _b1CommentConsole.text = "";\n _b1CommentConsole.toolTip = qsTr("Reload");\n\n var iGear = new QIcon();\n iGear.addDbImage("gear_16");\n _b2CommentConsole.icon = iGear;\n _b2CommentConsole.text = "";\n _b2CommentConsole.toolTip = qsTr("Preferences...");\n\n // Set columns on list\n _commentConsole.addColumn("Date", 75, 1, true, "comment_date");\n _commentConsole.addColumn("Comment Type", 115, 1, true, "cmnttype_name");\n _commentConsole.addColumn("Text", 90, 1, true, "comment_text");\n _commentConsole.addColumn("Source", 115, 1, true, "comment_source")\n _commentConsole.addColumn("User", 65, 1, true, "comment_user")\n _commentConsole.addColumn("Detail", -1, 1, true, "info");\n _commentConsole.addColumn("Points", 40, 3, true, "points");\n\n mainwindow.itemsitesUpdated.connect(refreshCommentConsole);\n mainwindow.warehousesUpdated.connect(refreshCommentConsole);\n mainwindow.customersUpdated.connect(refreshCommentConsole)\n mainwindow.employeeUpdated.connect(refreshCommentConsole);\n mainwindow.vendorsUpdated.connect(refreshCommentConsole);\n mainwindow.returnAuthorizationsUpdated.connect(refreshCommentConsole);\n mainwindow.salesOrdersUpdated.connect(refreshCommentConsole)\n mainwindow.quotesUpdated.connect(refreshCommentConsole);\n mainwindow.workOrdersUpdated.connect(refreshCommentConsole);\n mainwindow.purchaseOrdersUpdated.connect(refreshCommentConsole);\n mainwindow.bomsUpdated.connect(refreshCommentConsole)\n mainwindow.bbomsUpdated.connect(refreshCommentConsole);\n mainwindow.boosUpdated.connect(refreshCommentConsole);\n mainwindow.projectsUpdated.connect(refreshCommentConsole);\n mainwindow.crmAccountsUpdated.connect(refreshCommentConsole)\n mainwindow.transferOrdersUpdated.connect(refreshCommentConsole);\n\n _b1CommentConsole.clicked.connect(refreshCommentConsole);\n _b2CommentConsole.clicked.connect(preferencesCommentConsole);\n\n _commentConsole["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n .connect(populateMenuCommentConsole);\n\n mainwindow["tick()"].connect(refreshCommentConsole);\n\n var act = _dockSendMessage.toggleViewAction();\n if (!privileges.check("viewSendMsgDock"))\n {\n _dockSendMessage.hide();\n act.enabled = false;\n }\n else\n {\n _dockSendMessage.show();\n act.enabled = true;\n }\n\n // Allow rescan to let them show if privs granted\n act.setData("viewSendMsgDock");\n _menuDesktop.appendAction(act);\n\n _usr["newId(int)"].connect(sHandleButtons);\n _send.clicked.connect(send);\n\n fillListCommentConsole();\n}\n\nfunction getParams()\n{\n var params = new Object;\n\n params.message = _message.plainText;\n if (_usr.id() > 0)\n params.usr_id = _usr.id();\n\n return params;\n}\n\nfunction sHandleButtons()\n{\n var qry = "SELECT usr_id FROM usr WHERE usr_username = current_user;";\n var data = toolbox.executeQuery(qry, -1);\n if (data.first())\n var currenttUsr_id = data.value("usr_id");\n\n if (currenttUsr_id == _usr.id())\n {\n if (QMessageBox.information(mainwindow, qsTr("Send Message?"),\n qsTr("You are trying to Send Message to Yourself."\n +" Are you sure that you really want to Continue?."),\n QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) == QMessageBox.No)\n {\n _usr.clear();\n return;\n }\n }\n\n _send.enabled = (_usr.id() >= 0);\n}\n\nfunction send()\n{\n var params = getParams();\n var qry = toolbox.executeDbQuery("desktop", "sendMessageToUser", params);\n QMessageBox.information(mainwindow,'Sent','Message Sent');\n clear();\n}\n\nfunction set(input)\n{\n if ("user" in input)\n _usr.setUsername(input.user);\n else\n QMessageBox.warning(mywindow, "Message", "Could not set username");\n}\n\nfunction clear()\n{\n _usr.clear();\n _message.clear();\n}\n\nfunction fillListCommentConsole()\n{\n _commentConsole = mainwindow.findChild("_commentConsole");\n\n var cmmntTypeList = preferences.value("MonitoredCommentTypes");\n var cmmntSrcList = preferences.value("MonitoredCommentSrcs");\n var cmmntUsrList = preferences.value("MonitoredCommentUsrs");\n\n var params = new Object;\n\n var getDate = "SELECT CURRENT_DATE + CAST( AS INTEGER) AS start,"\n + " CURRENT_DATE + CAST( AS INTEGER) AS end,"\n + " EXISTS(SELECT 1"\n + " FROM pg_class JOIN pg_namespace n ON relnamespace = n.oid"\n + " WHERE relname = 'rev') AS hasRev,"\n + " EXISTS(SELECT 1 FROM pkghead WHERE pkghead_name = 'xtmfg') AS hasMFG"\n + ";";\n\n params.startOffSet = ((preferences.value("MonitoredCommentStrtDate") != '')?preferences.value("MonitoredCommentStrtDate"):-1);\n params.endOffSet = ((preferences.value("MonitoredCommentEndDate") != '')?preferences.value("MonitoredCommentEndDate"):0);\n var data = toolbox.executeQuery(getDate, params);\n if (data.first())\n {\n params.startDate = data.value("start");\n params.endDate = data.value("end");\n if (data.value("hasRev"))\n params.hasRev = 'hasRev'; // mql uses \n if (data.value("hasMFG"))\n params.xtmfg_exist = 'hasMFG';\n }\n else if (data.lastError().type != QSqlError.NoError)\n {\n QMessageBox.critical(mainwindow, qsTr("Database Error"),\n data.lastError().text);\n return;\n }\n\n _commentConsole.clear();\n\n if (cmmntTypeList.length)\n params.commenttype_id = cmmntTypeList;\n\n if (cmmntSrcList.length)\n {\n params.sourceidlist = cmmntSrcList;\n var sourceList = new Array();\n var data = toolbox.executeDbQuery("desktop","cmmntPrefSrc", params);\n var i = 0;\n while (data.next())\n sourceList.push(data.value("cmntsource_name"));\n params.source = sourceList;\n }\n\n if(cmmntUsrList.length)\n params.usr_id = cmmntUsrList;\n\n _commentConsole.populate(toolbox.executeDbQuery("desktop","commentConsole", params));\n _commentConsoleIsDirty = false;\n}\n\nfunction populateMenuCommentConsole(pMenu, pItem, pCol)\n{\n try\n {\n var doctype = pItem.text("comment_source");\n\n // undo oddities in the desktop-commentConsole mql\n if (doctype == 'T-Contact')\n doctype = 'T';\n else if (doctype == 'OPP-Opportunity')\n doctype = 'OPP';\n\n var lookup = {},\n editAct,\n viewAct\n ;\n\n // TODO: put more detail in the source table then use that instead\n lookup['ADDR'] = { editPriv: "MaintainAddresses", viewPriv: "ViewAddresses",\n id: "addr_id", uiform: "address", wflags: Qt.Dialog };\n lookup['BBH'] = { editPriv: "MaintainBBOMs", viewPriv: "ViewBBOMs",\n id: "bbomhead_id", uiform: "bbom", wflags: Qt.Window };\n lookup['BBI'] = { editPriv: "MaintainBBOMs", viewPriv: "ViewBBOMs",\n id: "bbomitem_id", uiform: "bbomItem", wflags: Qt.Dialog };\n lookup['BMH'] = { editPriv: "MaintainBOMs", viewPriv: "ViewBOMs",\n id: "bomhead_id", uiform: "BOM", wflags: Qt.Window };\n lookup['BIM'] = { editPriv: "MaintainBOMs", viewPriv: "ViewBOMs",\n id: "bomitem_id", uiform: "bomItem", wflags: Qt.Dialog };\n lookup['BOH'] = { editPriv: "MaintainBOOs", viewPriv: "ViewBOOs",\n id: "boohead_id", uiform: "boo", wflags: Qt.Dialog };\n lookup['BOI'] = { editPriv: "MaintainBOOs", viewPriv: "ViewBOOs",\n id: "booitem_id", uiform: "booItem", wflags: Qt.Dialog };\n lookup['CRMA'] = { editPriv: "MaintainPersonalCRMAccounts MaintainAllCRMAccounts",\n viewPriv: "ViewPersonalCRMAccounts ViewAllCRMAccounts",\n id: "crmacct_id", uiform: "crmaccount", wflags: Qt.Window };\n lookup['T'] = { editPriv: "MaintainPersonalContacts MaintainAllContacts",\n viewPriv: "ViewPersonalContacts ViewAllContacts",\n id: "cntct_id", uiform: "contact", wflags: Qt.Dialog };\n lookup['C'] = { editPriv: "MaintainCustomerMasters", viewPriv: "ViewCustomerMasters",\n id: "cust_id", uiform: "customer", wflags: Qt.Window };\n lookup['EMP'] = { editPriv: "MaintainEmployees", viewPriv: "ViewEmployees",\n id: "emp_id", uiform: "employee", wflags: Qt.Dialog };\n lookup['INCDT'] = { editPriv: "MaintainPersonalIncidents MaintainAllIncidents",\n viewPriv: "ViewPersonalIncidents ViewAllIncidents",\n id: "incdt_id", uiform: "incident", wflags: Qt.Window };\n lookup['I'] = { editPriv: "MaintainItemMasters", viewPriv: "ViewItemMasters",\n id: "item_id", uiform: "item", wflags: Qt.Window };\n lookup['IS'] = { editPriv: "MaintainItemSites", viewPriv: "ViewItemSites",\n id: "itemsite_id", uiform: "itemSite", wflags: Qt.Dialog };\n lookup['IR'] = { editPriv: "MaintainItemSources", viewPriv: "ViewItemSources",\n id: "itemsrc_id", uiform: "itemSource", wflags: Qt.Dialog };\n lookup['L'] = { editPriv: "MaintainLocations", viewPriv: "ViewLocations",\n id: "location_id", uiform: "location", wflags: Qt.Dialog };\n lookup['LS'] = { editPriv: "", viewPriv: "",\n id: "ls_id", uiform: "lotSerial", wflags: Qt.Dialog };\n lookup['OPP'] = { editPriv: "MaintainPersonalOpportunities MaintainAllOpportunities",\n viewPriv: "ViewPersonalOpportunities ViewAllOpportunities",\n id: "ophead_id", uiform: "opportunity", wflags: Qt.Dialog };\n lookup['J'] = { editPriv: "MaintainPersonalProjects MaintainAllProjects",\n viewPriv: "ViewPersonalProjects ViewAllProjects",\n id: "prj_id", uiform: "project", wflags: Qt.Dialog };\n lookup['P'] = { editPriv: "MaintainPurchaseOrders", viewPriv: "ViewPurchaseOrders",\n id: "pohead_id", uiform: "purchaseOrder", wflags: Qt.Window };\n lookup['PI'] = { editPriv: "MaintainPurchaseOrders", viewPriv: "ViewPurchaseOrders",\n id: "poitem_id", uiform: "purchaseOrderItem", wflags: Qt.Dialog };\n lookup['RA'] = { editPriv: "MaintainReturns", viewPriv: "ViewReturns",\n id: "rahead_id", uiform: "returnAuthorization", wflags: Qt.Window };\n lookup['RI'] = { editPriv: "MaintainReturns", viewPriv: "ViewReturns",\n id: "raitem_id", uiform: "returnAuthorizationItem",wflags: Qt.Dialog };\n lookup['Q'] = { editPriv: "MaintainQuotes", viewPriv: "ViewQuotes",\n id: "quhead_id", uiform: "salesOrder", wflags: Qt.Window };\n lookup['QI'] = { editPriv: "MaintainQuotes", viewPriv: "ViewQuotes",\n id: "soitem_id", uiform: "salesOrderItem", wflags: Qt.Dialog };\n lookup['S'] = { editPriv: "MaintainSalesOrders", viewPriv: "ViewSalesOrders",\n id: "sohead_id", uiform: "salesOrder", wflags: Qt.Window };\n lookup['SI'] = { editPriv: "MaintainSalesOrders", viewPriv: "ViewSalesOrders",\n id: "soitem_id", uiform: "salesOrderItem", wflags: Qt.Dialog };\n lookup['TA'] = { editPriv: "MaintainPersonalProjects MaintainAllProjects",\n viewPriv: "ViewPersonalProjects ViewAllProjects",\n id: "prjtask_id", uiform: "task", wflags: Qt.Dialog };\n lookup['TD'] = { editPriv: "MaintainPersonalToDoItems MaintainAllToDoItems",\n viewPriv: "ViewPersonalToDoItems ViewAllToDoItems",\n id: "todoitem_id", uiform: "todoItem", wflags: Qt.Dialog };\n lookup['TO'] = { editPriv: "MaintainTransferOrders", viewPriv: "ViewTransferOrders",\n id: "tohead_id", uiform: "transferOrder", wflags: Qt.Window };\n lookup['TI'] = { editPriv: "MaintainTransferOrders", viewPriv: "ViewTransferOrders",\n id: "toitem_id", uiform: "transferOrderItem", wflags: Qt.Dialog };\n lookup['V'] = { editPriv: "MaintainVendors", viewPriv: "ViewVendors",\n id: "vend_id", uiform: "vendor", wflags: Qt.Window };\n lookup['WH'] = { editPriv: "MaintainWarehouses", viewPriv: "ViewWarehouses",\n id: "warehous_id", uiform: "warehouse", wflags: Qt.Dialog };\n lookup['W'] = { editPriv: "MaintainWorkOrders", viewPriv: "MaintainWorkOrders",\n id: "wo_id", uiform: "workOrder", wflags: Qt.Window };\n\n _commentConsole = mainwindow.findChild("_commentConsole");\n\n if(pMenu == null)\n pMenu = _commentConsole.findChild("_menu");\n if(pMenu != null)\n {\n editAct = pMenu.addAction(qsTr("Edit"));\n editAct.enabled = privileges.check(lookup[doctype].editPriv);\n editAct.triggered.connect(editDoctype);\n\n viewAct = pMenu.addAction(qsTr("View"));\n viewAct.enabled = privileges.check(lookup[doctype].editPriv + " " + lookup[doctype].viewPriv);\n viewAct.triggered.connect(viewDoctype);\n }\n\n function editDoctype() {\n var mode = "edit";\n if (doctype == "Q" || doctype == "QI")\n mode = "editQuote";\n\n openDoctype(mode);\n }\n\n function viewDoctype() {\n var mode = "view";\n if (doctype == "Q" || doctype == "QI")\n mode = "viewQuote";\n openDoctype(mode);\n }\n\n function openDoctype(mode) {\n try {\n var params = { mode: mode },\n docdesc = lookup[doctype],\n q;\n params[docdesc.id] = _commentConsole.id();\n\n // BOM window takes an item_id, not a bomhead_id!\n if (doctype == "BMH") {\n q = toolbox.executeQuery("SELECT bomhead_item_id, bomhead_rev_id"\n + " FROM bomhead"\n + " WHERE bomhead_id = ;",\n params);\n if (q.first()) {\n params.item_id = q.value("bomhead_item_id");\n params.revision_id = q.value("bomhead_rev_id");\n } else if (q.lastError() != QSqlError.NoError) {\n throw q.lastError().text;\n }\n }\n\n var newdlg = toolbox.openWindow(docdesc.uiform, mainwindow,\n (docdesc.wflags == Qt.Dialog) ? Qt.ApplicationModal : Qt.NonModal,\n docdesc.wflags);\n newdlg.set(params);\n if (newdlg.exec) {\n newdlg.exec();\n }\n } catch (e) {\n QMessageBox.critical(mainwindow, "dockSendMessage",\n "Could not open a window for source " + doctype + ": " + e);\n\n }\n }\n }\n catch (e)\n {\n QMessageBox.critical(mainwindow, "dockSendMessage",\n "populateMenuCommentConsole exception: " + e);\n }\n}\n\nfunction preferencesCommentConsole()\n{\n try\n {\n \tparams = new Object;\n var newdlg = toolbox.openWindow("preferencesComment", mainwindow,\n Qt.ApplicationModal, Qt.Dialog);\n toolbox.lastWindow().set(params);\n if (newdlg.exec())\n refreshCommentConsole();\n }\n catch (e)\n {\n QMessageBox.critical(mainwindow, "dockSendMessage",\n "preferencesCommentConsole exception: " + e);\n }\n}\n\n/*!\n Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshCommentConsole()\n{\n try\n {\n \t_commentConsoleIsDirty = true;\n fillListCommentConsole();\n }\n catch (e)\n {\n QMessageBox.critical(mainwindow, "dockSendMessage",\n "refreshCommentConsole exception: " + e);\n }\n}\n 86 dockUserOnline 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _dockUserOnline;\nvar _userOnline;\nvar _userOnlineIsDirty = true;\n\n/*!\n Initializes Open Sales Order dock widget and places it in the main window.\n*/\nfunction initDockUserOnline()\n{\n _dockUserOnline = mainwindow.findChild("_dockUserOnline");\n _userOnline = mainwindow.findChild("_userOnline");\n\n // Set columns on list\n _userOnline.addColumn(qsTr("Username"), -1, Qt.AlignLeft, true, "usr_username");\n _userOnline.addColumn(qsTr("Proper Name"), -1, Qt.AlignLeft, true, "usr_propername");\n _userOnline.addColumn(qsTr("Email"), -1, Qt.AlignLeft, true, "usr_email");\n _userOnline.addColumn(qsTr("# Internal"), -1, Qt.AlignLeft, true, "cnt_internal");\n _userOnline.addColumn(qsTr("# External"), -1, Qt.AlignLeft, true, "cnt_external");\n _userOnline.addColumn(qsTr("Client Start"), XTreeWidget.timeDateColumn, Qt.AlignLeft, true, "client_start"); \n _userOnline.addColumn(qsTr("Query Start"), XTreeWidget.timeDateColumn, Qt.AlignLeft, true, "query_start");\n _userOnline.addColumn(qsTr("Client Address"), -1, Qt.AlignLeft, true, "client_addr");\n\n // Connect Signals and Slots\n _dtTimer.timeout.connect(refreshUserOnline);\n\n _userOnline.itemSelected.connect(openWindowUserOnline);\n _userOnline["populateMenu(QMenu*,XTreeWidgetItem*,int)"]\n .connect(populateMenuUserOnline);\n\n _dockUserOnline.visibilityChanged.connect(refreshUserOnline);\n\n // Handle privilge control\n var act = _dockUserOnline.toggleViewAction();\n\n // Don't show if no privs\n if (!privileges.check("ViewUsersOnlineDock"))\n {\n _dockUserOnline.hide();\n act.enabled = false;\n }\n\n // Allow rescan to let them show if privs granted\n act.setData("ViewUsersOnlineDock");\n _menuDesktop.appendAction(act);\n\n fillListUserOnline();\n}\n\n/*!\n Fills the list with open sales data.\n*/\nfunction fillListUserOnline()\n{\n _dockUserOnline = mainwindow.findChild("_dockUserOnline");\n _userOnline = mainwindow.findChild("_userOnline");\n\n if (!_dockUserOnline.visible || !_userOnlineIsDirty)\n return;\n\n _userOnline.populate(toolbox.executeDbQuery("desktop","userOnline"));\n _userOnlineIsDirty = false;\n}\n\n/*! \n Opens the window associated with the selected item.\n*/\nfunction openWindowUserOnline()\n{ \n // Make sure we can open the window for this activity\n if (!privilegeCheckUserOnline() ||\n !_userOnline.currentItem().rawValue("usr_username").length)\n return;\n\n params = new Object;\n params.username = _userOnline.currentItem().rawValue("usr_username");\n if (privilegeCheckUserOnline())\n params.mode="edit";\n\n // Open the window and perform any handling required\n var user = toolbox.openWindow("user");\n user.set(params);\n if (user.exec())\n refreshUserOnline();\n}\n\n/*!\n Adds actions to @a pMenu, typically from a right click on a user record.\n*/\nfunction populateMenuUserOnline(pMenu, pItem)\n{\n if (!_userOnline.currentItem().rawValue("usr_username").length)\n return;\n\n var menuItem;\n var enable = privilegeCheckUserOnline();\n\n menuItem = pMenu.addAction(_open);\n menuItem.enabled = enable;\n menuItem.triggered.connect(openWindowUserOnline);\n}\n\n/*!\n Returns whether user has privileges to view detail on the selected User.\n*/\nfunction privilegeCheckUserOnline()\n{\n return privileges.check("MaintainUsers");\n\n return false;\n}\n\n/*!\n Refreshes data if the window is visible, or the next time it becomes visible\n*/\nfunction refreshUserOnline()\n{\n _userOnlineIsDirty = true;\n fillListUserOnline();\n}\n 134 hotkey 0 t var _save = mywindow.findChild("_save");\n\nfunction refreshShortcuts() {\n mainwindow.sEmitSignal("xtdesktop", "refreshShortcuts");\n}\n\n_save.clicked.connect(refreshShortcuts); 87 incident 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("dockMyTodo");\n\n// Connect this window so that the To Do dock list gets updated\nmydialog.finished.connect(fillListToDo);\n 135 initMenu 10 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\n\n// Import code from related scripts\ninclude("stylesheets");\ninclude("dockBankBal");\ninclude("dockExtensions");\ninclude("dockGLAccounts");\ninclude("dockMessageHistory");\ninclude("dockMfgActive");\ninclude("dockMfgHist");\ninclude("dockMfgOpen");\ninclude("dockMyAccounts");\ninclude("dockMyContacts");\ninclude("dockMyTodo");\ninclude("dockPayables");\ninclude("dockPurchActive");\ninclude("dockPurchHist");\ninclude("dockPurchOpen");\ninclude("dockReceivables");\ninclude("dockSalesActive");\ninclude("dockSalesHistory");\ninclude("dockSalesOpen");\ninclude("dockSendMessage");\ninclude("dockUserOnline");\ninclude("desktopMenuBar");\n\nvar _desktopStack = toolbox.createWidget("QStackedWidget", mainwindow, "_desktopStack");\nvar _open = qsTr("Open...");\nvar _dtTimer = new QTimer(mainwindow);\nvar _windows = new Array();\nvar _vToolBarActions = []; // used only in addToolBarAction()\nvar showDashboardAnything = false;\n\nvar _mainMenu;\nvar _employee;\n\nvar _menuDesktop = new QMenu(qsTr("Desktop"),mainwindow);\nvar _menuToolBar = new QMenu(mainwindow);\nvar _menuWindow = mainwindow.findChild("menu.window");\n\n// Create Menu items for setup windows\nvar _menuSetup = new QMenu(qsTr("Setup"),mainwindow);\n\n// Add desktop to main window\naddAction("sys.currencies","currencies","CreateNewCurrency","CreateNewCurrency");\naddAction("sys.exchangeRates","currencyConversions","MaintainCurrencyRates","ViewCurrencyRates");\n\n// Set up refresh timer\n_dtTimer.setInterval(metrics.value("desktop/timer"));\n_dtTimer.start();\n\n// Setup the desktop layout\nvar _desktopWidget = toolbox.createWidget("QWidget", mainwindow, "_desktopWidget");\n_desktopWidget.setStyleSheet(desktopStyle);\n_desktopLayout = toolbox.createLayout("QHBoxLayout", mainwindow, "_desktopLayout");\n_desktopMenu = toolbox.loadUi("desktopMenuBar", mainwindow);\n_desktopMenu.maximumWidth = 250;\n_desktopLayout.addWidget(_desktopMenu);\n_desktopLayout.addWidget(_desktopStack);\n_desktopWidget.setLayout(_desktopLayout);\n\nvar _desktopParent = mainwindow.showTopLevel() ? mainwindow : null;\nif (_desktopParent)\n{\n _desktopParent.setCentralWidget(_desktopWidget);\n\n setupDesktopMenu();\n\n // Set up browser for Welcome Page\n var _welcome = new QWebView(mainwindow);\n var welcomeUrl = (function () {\n var databaseURL = mainwindow.databaseURL(),\n string = databaseURL.split("/"),\n hostName = string[2].substring(0, string[2].indexOf(":")),\n databaseName = string[3],\n urlString = metrics.value("desktop/welcome")\n + "?client=desktop" + "&hostname=" + hostName\n + "&organization=" + databaseName\n + "&edition=" + metrics.value("Application")\n + "&version=" + metrics.value("ServerVersion")\n ;\n return new QUrl(urlString);\n })();\n _welcome.objectName = "_welcome";\n _welcome["loadFinished(bool)"].connect(loadLocalHtml);\n _welcome["linkClicked(const QUrl &)"].connect(openUrl);\n _welcome.load(welcomeUrl);\n _welcome.page().linkDelegationPolicy = QWebPage.DelegateAllLinks;\n _desktopStack.addWidget(_welcome);\n addToolBarAction(qsTr("Welcome"), "home_32");\n\n if (showDashboardAnything) {\n var _home = new QWebView(mainwindow);\n _home["loadFinished(bool)"].connect(missingxTupleServer);\n _home["linkClicked(const QUrl &)"].connect(openUrl);\n var homeURL = "https://" + metrics.value("WebappHostname")\n + ":" + metrics.value("WebappPort")\n + "/" + mainwindow.databaseURL().split("/")[3];\n + "/npm/xtuple-dashboard-anything/public/index.html";\n _home.load(new QUrl(homeURL));\n _home.page().linkDelegationPolicy = QWebPage.DelegateAllLinks;\n _desktopStack.addWidget(_home);\n addToolBarAction(qsTr("Dashboard"), "home_32");\n }\n\n // Initialize additional desktop UIs and Dock Widgets\n // (Init functions come from the code pulled in by the include statements)\n addDesktop("desktopCRM", "clients_32", "ViewCRMDesktop");\n initDockTodo();\n initDockAccounts();\n initDockMyCntcts();\n\n addDesktop("desktopSales", "reward_32", "ViewSalesDesktop");\n initDockSalesAct();\n initDockSalesHist();\n initDockSalesOpen();\n\n addDesktop("desktopAccounting", "accounting_32", "ViewAccountingDesktop");\n initDockPayables();\n initDockReceivables();\n initDockBankBal();\n initDockGLAccounts();\n\n addDesktop("desktopPurchase", "order_32", "ViewPurchaseDesktop");\n initDockPurchAct();\n initDockPurchHist();\n initDockPurchOpen();\n\n addDesktop("desktopManufacture", "industry_32", "ViewManufactureDesktop");\n initDockMfgAct();\n initDockMfgHist();\n initDockMfgOpen();\n\n addDesktop("desktopSocial", "social", "viewSocialDesktop");\n initDockUserOnline();\n initDockMessageHistory();\n initDockSendMessage();\n\n var maintWin = addDesktop("desktopMaintenance", "gear_32", "ViewMaintenanceDesktop");\n initDockExtensions();\n\n // Handle window actions\n _menuWindow.aboutToShow.connect(prepareWindowMenu);\n\n if (metrics.boolean("MultiWhs"))\n {\n var button = mainwindow.findChild("_sites");\n button.label = qsTr("Sites");\n button.actionName = "im.warehouses";\n }\n}\nelse\n{\n if (!preferences.boolean("NoDesktopNotice"))\n toolbox.openWindow("desktopNotice",mainwindow, Qt.WindowModal, Qt.Dialog);\n}\n\n/*!\n Adds screen with name of @a uiName to the desktop stack so long as the user has\n been granted the privilege @a privName. The @a windowTitle of the UI object is \n added to the Desktop Dock so that when it is clicked, the associated window is \n selected on the Desktop.\n*/\nfunction addDesktop(uiName, imageName, privilege)\n{\n // Get the UI and add to desktop stack\n var desktop = toolbox.loadUi(uiName);\n _desktopStack.addWidget(desktop);\n _windows.push(desktop);\n addToolBarAction(desktop.windowTitle, imageName, privilege);\n desktop.restoreState();\n \n return desktop;\n}\n\n/*!\n Add a button with @a label and @a imageName to the left desktop toolbar\n*/\nfunction addToolBarAction(label, imageName, privilege)\n{\n var act,\n icn = new QIcon(),\n menuItem;\n icn.addDbImage(imageName);\n\n // create an action in an invisible menu to ensure priv rescans work\n act = _menuToolBar.addAction(icn, label);\n if (act) {\n act.checkable = true;\n if (privilege)\n {\n act.setEnabled(privileges.check(privilege));\n act.setData(privilege);\n }\n\n _vToolBarActions.push(act);\n\n if (!privilege || privileges.check(privilege))\n menuItem = new XTreeWidgetItem(_mainMenu, _vToolBarActions.length,\n _vToolBarActions.length, label);\n }\n else {\n print('addToolbarAction() could not add ' + label);\n }\n}\n\n/*!\n Loads a local HTML page from the database if the xTuple welcome page\n fails to load.\n*/\nfunction loadLocalHtml(ok)\n{\n if (!ok)\n {\n // Page didn't load, so load internal HTML saying we aren't connected\n var q = toolbox.executeQuery("SELECT xtdesktop.fetchWelcomeHtml() AS html");\n q.first();\n _welcome.setHtml(q.value("html"));\n }\n // We don't want to deal with loading any more web pages. Let OS do it\n _welcome.page().linkDelegationPolicy = QWebPage.DelegateAllLinks;;\n}\n\nfunction missingxTupleServer(ok)\n{\n if (!ok)\n {\n // xTuple Server is not available or didn't load, so load internal HTML saying we aren't connected\n var q = toolbox.executeQuery("SELECT xtdesktop.fetchxTupleServerHtml() AS html");\n q.first();\n _home.setHtml(q.value("html"));\n }\n // We don't want to deal with loading any more web pages. Let OS do it\n _home.page().linkDelegationPolicy = QWebPage.DelegateAllLinks;;\n}\n\n/*!\n Launches links clicked on home page into new local browser window\n*/\nfunction openUrl(url)\n{\n toolbox.openUrl(new QUrl(url).toString());\n}\n\n/*!\n Adds desktop to the window menu\n*/\nfunction prepareWindowMenu()\n{\n // TO DO: Make this more modular\n var idx = _desktopStack.currentIndex;\n _dockMycontacts.toggleViewAction().visible = (idx == 1);\n _dockMyaccounts.toggleViewAction().visible = (idx == 1);\n _dockMytodo.toggleViewAction().visible = (idx == 1);\n _dockSalesAct.toggleViewAction().visible = (idx == 2);\n _dockSalesHist.toggleViewAction().visible = (idx == 2);\n _dockSalesOpen.toggleViewAction().visible = (idx == 2);\n _dockBankBal.toggleViewAction().visible = (idx == 3);\n _dockPayables.toggleViewAction().visible = (idx == 3);\n _dockReceivables.toggleViewAction().visible = (idx == 3);\n _dockGLAccounts.toggleViewAction().visible = (idx == 3);\n _dockPurchAct.toggleViewAction().visible = (idx == 4);\n _dockPurchHist.toggleViewAction().visible = (idx == 4);\n _dockPurchOpen.toggleViewAction().visible = (idx == 4);\n _dockMfgAct.toggleViewAction().visible = (idx == 5);\n _dockMfgHist.toggleViewAction().visible = (idx == 5);\n _dockMfgOpen.toggleViewAction().visible = (idx == 5);\n _dockSendMessage.toggleViewAction().visible = (idx == 6);\n _dockMessageHistory.toggleViewAction().visible = (idx == 6);\n _dockUserOnline.toggleViewAction().visible = (idx == 6);\n _dockExtensions.toggleViewAction().visible = (idx == 7);\n// _dockUserOnline.toggleViewAction().visible = (idx == 7);\n _menuWindow.addSeparator();\n _menuWindow.addMenu(_menuDesktop);\n}\n\nfunction addAction(actionName, slotName, editPriv, viewPriv)\n{\n var tempaction;\n tmpaction = new QAction(mainwindow);\n tmpaction.enabled = privileges.value(editPriv) || privileges.value(viewPriv);\n tmpaction.setData(editPriv + " " + viewPriv);\n tmpaction.objectName = actionName;\n tmpaction.triggered.connect(this, slotName);\n _menuSetup.appendAction(tmpaction);\n}\n\nfunction openSetup(uiName)\n{\n var params = new Object;\n params.uiName = uiName;\n var wnd = toolbox.openWindow("setup", mainwindow);\n toolbox.lastWindow().set(params);\n wnd.exec();\n}\n\nfunction currencies()\n{\n openSetup("currencies");\n}\n\nfunction currencyConversions()\n{\n openSetup("currencyConversions");\n}\n 129 preferencesComment 0 t try\r\n{\r\n var _usr = mywindow.findChild("_usr");\r\n var _type = mywindow.findChild("_type");\r\n var _source = mywindow.findChild("_source");\r\n var _dates = mywindow.findChild("_dates");\r\n var startdate;\r\n var enddate;\r\n\r\n if (!privileges.check("AccessAdditionalUser"))\r\n _usr.hide();\r\n else if(privileges.check("AccessAdditionalUser"))\r\n _usr.show();\r\n\r\n _type.addColumn("Comment Type", -1, 1, true, "commenttype_name");\r\n _source.addColumn("Comment Source", -1, 1, false, "cmntsource_name");\r\n _source.addColumn("Comment Source", -1, 1, true, "cmntsource_fullname");\r\n _usr.addColumn("User Name", -1, 1, true, "usr_username");\r\n\r\n populate();\r\n mydialog.accepted.connect(save);\r\n}\r\ncatch (e)\r\n{\r\n QMessageBox.critical(mywindow, "preferencesComment",\r\n "preferencesComment.js exception: " + e);\r\n}\r\n\r\nfunction set(params)\r\n{\r\n var prefusr = preferences.value("MonitoredCommentUsrs");\r\n var preftyp = preferences.value("MonitoredCommentTypes");\r\n var prefsrc = preferences.value("MonitoredCommentSrcs");\r\n\r\n var getDate = "SELECT CURRENT_DATE + CAST( AS INTEGER) AS datevalue;";\r\n\r\n params.offSet = ((preferences.value("MonitoredCommentStrtDate") != '')?preferences.value("MonitoredCommentStrtDate"):-1);\r\n var data = toolbox.executeQuery(getDate, params);\r\n if (data.first())\r\n _dates.setStartDate(data.value("datevalue"));\r\n else if (data.lastError().type != QSqlError.NoError)\r\n {\r\n QMessageBox.critical(mainwindow, qsTr("Database Error"),\r\n data.lastError().text);\r\n return;\r\n }\r\n\r\n params.offSet = ((preferences.value("MonitoredCommentEndDate") != '')?preferences.value("MonitoredCommentEndDate"):0);\r\n var data = toolbox.executeQuery(getDate, params);\r\n if (data.first())\r\n _dates.setEndDate(data.value("datevalue"));\r\n else if (data.lastError().type != QSqlError.NoError)\r\n {\r\n QMessageBox.critical(mainwindow, qsTr("Database Error"),\r\n data.lastError().text);\r\n return;\r\n }\r\n\r\n if (prefusr == '')\r\n {\r\n var qry = "SELECT usr_id FROM usr WHERE (usr_username = current_user);";\r\n var data = toolbox.executeQuery(qry, -1);\r\n if (data.first())\r\n _usr.setId(data.value("usr_id"));\r\n else if (data.lastError().type != QSqlError.NoError)\r\n {\r\n QMessageBox.critical(mainwindow, qsTr("Database Error"),\r\n data.lastError().text);\r\n return;\r\n }\r\n }\r\n else\r\n {\r\n var usrList = new Array();\r\n usrList = prefusr.split(",");\r\n for (var i in usrList)\r\n _usr.setId(usrList[i], false);\r\n }\r\n\r\n var typList = new Array();\r\n if (preftyp == '')\r\n _type.setId(0);\r\n else\r\n {\r\n typList = preftyp.split(",");\r\n for (var j in typList)\r\n _type.setId(typList[j], false);\r\n }\r\n\r\n var srcList = new Array();\r\n if (prefsrc == '')\r\n _source.setId(1);\r\n else\r\n {\r\n srcList = prefsrc.split(",");\r\n for (var k in srcList)\r\n _source.setId(srcList[k], false);\r\n }\r\n}\r\n\r\nfunction populate()\r\n{\r\n try\r\n {\r\n _type.clear();\r\n _type.populate(toolbox.executeDbQuery("desktop","cmmntPrefType"));\r\n _source.clear();\r\n _source.populate(toolbox.executeDbQuery("desktop","cmmntPrefSrc"));\r\n if (privileges.check("AccessAdditionalUser"))\r\n {\r\n _usr.clear();\r\n _usr.populate(toolbox.executeDbQuery("desktop","cmmntPrefUser"));\r\n }\r\n }\r\n catch (e)\r\n {\r\n QMessageBox.critical(mywindow, "preferencesComment",\r\n "populateType exception: " + e);\r\n }\r\n}\r\n\r\nfunction save()\r\n{\r\n var typList = new Array();\r\n var emptyList = new Array();\r\n var selectedTyp = _type.selectedItems();\r\n for (var i = 0; i < selectedTyp.length; i++)\r\n {\r\n if (selectedTyp[i].id() != 0)\n {\r\n typList[i] = selectedTyp[i].id();\n preferences.set("MonitoredCommentTypes", typList.join(","));\n }\r\n else\n {\n preferences.set("MonitoredCommentTypes", emptyList.join(","));\r\n break;\n }\r\n }\r\n\r\n var srcList = new Array();\r\n var selectedSrc = _source.selectedItems();\r\n for (var i = 0; i < selectedSrc.length; i++)\r\n {\r\n if (selectedSrc[i].id() != 1)\n {\r\n srcList[i] = selectedSrc[i].id();\n preferences.set("MonitoredCommentSrcs", srcList.join(","));\n }\r\n else\n {\n preferences.set("MonitoredCommentSrcs", emptyList.join(","));\r\n break;\n }\r\n }\r\n\r\n if (privileges.check("AccessAdditionalUser"))\r\n {\r\n var usrList = new Array();\r\n var selectedUsr = _usr.selectedItems();\r\n for (var i = 0; i < selectedUsr.length; i++)\r\n usrList[i] = selectedUsr[i].id();\r\n preferences.set("MonitoredCommentUsrs", usrList.join(","));\r\n }\r\n\r\n var params = new Object();\r\n params.startdate1 = _dates.startDate;\r\n var qryStdate = "SELECT (::DATE - (current_date)) AS difference1;";\r\n var data1 = toolbox.executeQuery(qryStdate,params);\r\n if (data1.first())\r\n var strtDateoffSet = data1.value("difference1");\r\n else if (data1.lastError().type != QSqlError.NoError)\r\n {\r\n QMessageBox.critical(mywindow, qsTr("Database Error"),\r\n data1.lastError().text);\r\n mywindow.reject();\r\n }\r\n\r\n params.enddate1 = _dates.endDate;\r\n var qryEnddate = "SELECT (::DATE - (current_date)) AS difference2;";\r\n var data2 = toolbox.executeQuery(qryEnddate,params);\r\n if (data2.first())\r\n var endDateoffSet = data2.value("difference2");\r\n else if (data2.lastError().type != QSqlError.NoError)\r\n {\r\n QMessageBox.critical(mywindow, qsTr("Database Error"),\r\n data2.lastError().text);\r\n mywindow.reject();\r\n }\r\n\r\n if (endDateoffSet - strtDateoffSet > 7)\n {\n strtDateoffSet = endDateoffSet - 7;\n QMessageBox.critical(mywindow, qsTr("Comment Date Limit"),\r\n qsTr("Comment Start Date changed to honor 7 day limit"));\r\n }\r\n\r\n preferences.set("MonitoredCommentStrtDate", strtDateoffSet);\r\n preferences.set("MonitoredCommentEndDate", endDateoffSet);\r\n}\r\n 89 preferencesHistory 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar _groupBy = mywindow.findChild("_groupBy");\nvar _timeFrame = mywindow.findChild("_timeFrame");\nvar _type = mywindow.findChild("_type");\n\nvar _path;\n\n// Populate timeFrame combo\n_timeFrame.append(0, qsTr("Today"), "day");\n_timeFrame.append(1, qsTr("This Week"), "week");\n_timeFrame.append(2, qsTr("This Month"), "month");\n_timeFrame.append(3, qsTr("This Year"), "year");\n\nmydialog.accepted.connect(save);\n\n/*!\n Parameters @a params are passed to set up selection criteria for the window\n*/\nfunction set(params)\n{\n if ("path" in params)\n {\n _path = params.path;\n if (_path == "desktop/salesHist")\n {\n _type.append(0, qsTr("Bookings"), "bookings");\n _type.append(1, qsTr("Sales"), "sales");\n\n _groupBy.append(0, qsTr("Customer"), "cust");\n _groupBy.append(1, qsTr("Product Category"), "prodcat");\n _groupBy.append(2, qsTr("Sales Rep"), "salesrep");\n\n mywindow.windowTitle = qsTr("Sales History Preferences");\n }\n else if (_path == "desktop/purchHist")\n {\n _type.append(0, qsTr("Receipts"), "receipts");\n _type.append(1, qsTr("Variances"), "variances");\n\n _groupBy.append(0, qsTr("Vendor"), "vend");\n _groupBy.append(1, qsTr("Item"), "item");\n _groupBy.append(2, qsTr("Purchase Agent"), "agent");\n\n mywindow.windowTitle = qsTr("Purchase History Preferences");\n }\n else if (_path == "desktop/mfgHist")\n {\n _type.append(0, qsTr("Receipts"), "receipts");\n _type.enabled = false;\n\n _groupBy.append(0, qsTr("Class Code"), "classcode");\n _groupBy.append(1, qsTr("Item"), "item");\n _groupBy.append(2, qsTr("Planner Code"), "plancode");\n\n mywindow.windowTitle = qsTr("Manufacture History Preferences");\n }\n }\n\n if ("type" in params)\n _type.code = params.type;\n\n if ("groupBy" in params)\n _groupBy.code = params.groupBy;\n\n if ("timeFrame" in params)\n _timeFrame.code = params.timeFrame;\n\n}\n\n/*!\n Saves selection preferences to the local machine.\n*/\nfunction save()\n{\n // Save preferences to local machine\n preferences.set(_path + "/type", _type.code);\n preferences.set(_path + "/groupBy", _groupBy.code);\n preferences.set(_path + "/timeFrame", _timeFrame.code);\n}\n\n 130 preferencesNumber 0 t try\r\n{\r\n var _limit = mywindow.findChild("_limit");\r\n var _path;\r\n\r\n mydialog.accepted.connect(mysave);\r\n}\r\ncatch (e)\r\n{\r\n QMessageBox.critical(mainwindow, "preferencesNumber",\r\n "preferencesNumber.js exception: " + e);\r\n}\r\n\r\nfunction set(params)\r\n{\r\n if ("path" in params)\r\n _path = params.path;\r\n\r\n if ("limit" in params)\r\n _limit.value = params.limit;\r\n else\r\n _limit.value = 10;\r\n}\r\n\r\nfunction mysave()\r\n{\r\n try\r\n {\r\n preferences.set(_path + "/limit", _limit.value);\r\n }\r\n catch (e)\r\n {\r\n QMessageBox.critical(mainwindow, "preferencesNumber",\r\n "mysave exception: " + e);\r\n }\r\n}\n 90 preferencesSelections 0 t /*\n * This file is part of the xtdesktop package for xTuple ERP: PostBooks edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\nvar _gl = mywindow.findChild("_gl");\n\n// Set columns on list\n_gl.addColumn(qsTr("Account#"), -1, Qt.AlignLeft, true, "accnt_id");\n_gl.addColumn(qsTr("Description"), -1, Qt.AlignLeft, true, "accnt_descrip");\n_gl.addColumn(qsTr("Type"), -1, Qt.AlignLeft, true, "accnt_type" );\n\nparams = new Object;\nparams.asset = qsTr("Asset");\nparams.liability = qsTr("Liability");\nparams.revenue = qsTr("Revenue");\nparams.expense = qsTr("Expense");\nparams.equity = qsTr("Equity");\n\n_gl.populate(toolbox.executeDbQuery("desktop", "glaccounts", params));\n\nfunction set(params)\n{\n // Select accounts previously selected\n var pref = preferences.value("MonitoredAccounts");\n var accntList = new Array();\n accntList = pref.split(",");\n for (i in accntList) \n {\n _gl.setId(accntList[i], false);\n }\n}\n\nfunction save()\n{\n var accntList = new Array();\n var selected = _gl.selectedItems();\n for (var i = 0; i < selected.length; i++)\n accntList[i] = selected[i].id();\n\n preferences.set("MonitoredAccounts", accntList.join(","));\n}\n\n// Connect save on Ok\nmydialog.accepted.connect(save);\n 91 project 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("dockMyTodo");\n\n// Connect this window so that the To Do dock list gets updated\nmydialog.finished.connect(fillListToDo);\n 131 sendMessageToUser 0 t //debugger;\n\nvar _usr = mywindow.findChild("_usr");\nvar _message = mywindow.findChild("_message");\nvar _send = mywindow.findChild("_send");\n\nfunction getParams() \n{\n var params = new Object;\n\n params.message = _message.plainText;\n if (_usr.id() > 0)\n params.usr_id = _usr.id();\n\n return params;\n}\n\nfunction sHandleButtons()\n{\n var qry = "SELECT usr_id FROM usr WHERE usr_username = current_user;";\n var data = toolbox.executeQuery(qry, -1);\n if (data.first())\n var currenttUsr_id = data.value("usr_id");\n\n if (currenttUsr_id == _usr.id())\n {\n if (QMessageBox.information(mainwindow, qsTr("Send Message?"),\n qsTr("You are trying to Send Reply Message to Yourself."\n +"\\nAre you sure that you really want to Continue?."),\n QMessageBox.Yes | QMessageBox.Default, QMessageBox.No | QMessageBox.Escape) == QMessageBox.No)\n {\n _usr.clear();\n return;\n }\n else\n _send.enabled = (_usr.id() >= 0);\n }\n else\n _send.enabled = (_usr.id() >= 0);\n}\n\nfunction send()\n{\n var params = getParams(); \n var qry = toolbox.executeDbQuery("desktop", "sendMessageToUser", params);\n QMessageBox.information(mywindow,'Sent','Message Sent');\n mywindow.close();\n}\n\nfunction set(input)\n{\n if ("user" in input)\n _usr.setUsername(input.user);\n else\n QMessageBox.warning(mywindow, "Message", "Could not set username");\n}\n\n_usr["newId(int)"].connect(sHandleButtons);\n_send.clicked.connect(send);\nmywindow.findChild("_close").clicked.connect(mywindow, "close");\n 136 stylesheets 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\nvar selectedFg = "#0177FF",\n selectedBg = "#FFF",\n uncheckedFg = "#99bbff",\n bigBoxBorderColor = "#AAA",\n smallBoxBorderColor = "#E8E8E8",\n smallBoxBg = "#E8E8E8",\n generalFontSize = "10pt",\n borderRadius = "4px",\n groupBoxPadding = "1ex",\n groupBoxTitleFontSize=generalFontSize,\n tableHeadingFontSize= "10pt",\n multiButtonMargin = "0.5ex",\n windowBg = "#FAAFAAFAA",\n toolbarBg = "#DFFDFFDFF",\n layeredWindowBg = windowBg,\n ;\n\nswitch (mainwindow.getWindowSystem()) {\n case mainwindow.MAC: generalFontSize = "12pt";\n groupBoxTitleFontSize = "10pt";\n layerdWindowBg = "transparent";\n break;\n case mainwindow.X11: tableHeadingFontSize = "9pt";\n break;\n case mainwindow.WIN: groupBoxPadding = "3ex;";\n break;\n}\n\nvar imageStyle = [ "* {",\n "border: none;",\n "font: 14px;",\n"}"\n].join(" ");\n\nvar generalStyle = [ "* {",\n "font-family: Open Sans, Helvetica, Verdana, sans-serif;", \n "font-size: " + generalFontSize + ";",\n "font-weight: regular;",\n "color: rgb(68, 68, 68);",\n "background-color: " + selectedBg + ";",\n "selection-color: " + selectedFg + ";",\n "selection-background-color: " + selectedBg + ";",\n"}",\n"*:focus {",\n "border-color: " + selectedFg + ";",\n"}",\n"*:disabled {",\n "color: " + bigBoxBorderColor + ";",\n"}",\n"QScrollBar:horizontal {",\n "border: 1px solid " + smallBoxBorderColor + ";",\n "border-radius: " + borderRadius + ";",\n "background: " + smallBoxBg + ";",\n "height: 10px;",\n "margin: 0px 0px 0px 0px;",\n"}",\n"QScrollBar:vertical {",\n "border: 1px solid " + smallBoxBorderColor + ";",\n "border-radius: " + borderRadius + ";",\n "background: " + smallBoxBg + ";",\n "width: 10px;",\n "margin: 0px 0 0px 0;",\n "}",\n "QScrollBar::add-line:vertical {",\n "background: " + bigBoxBorderColor + ";",\n "height: 0px;",\n "subcontrol-position: bottom;",\n "subcontrol-origin: margin;",\n "}",\n "QScrollBar::add-line:horizontal {",\n "background: " + bigBoxBorderColor + ";",\n "width: 0px;",\n "subcontrol-position: bottom;",\n "subcontrol-origin: margin;",\n "}",\n "QScrollBar::sub-line:vertical {",\n "background: " + bigBoxBorderColor + ";",\n "height: 0px;",\n "subcontrol-position: top;",\n "subcontrol-origin: margin;",\n "}",\n "QScrollBar::sub-line:horizontal {",\n "background: " + bigBoxBorderColor + ";",\n "width: 0px;",\n "subcontrol-position: top;",\n "subcontrol-origin: margin;",\n "}",\n"QScrollBar::down-arrow:vertical {",\n "width: 20px;",\n "height: 20px;",\n"}",\n"QScrollBar::up-arrow:vertical {",\n "width: 10px;",\n "height: 20px;",\n"}", \n"QScrollBar::down-arrow:horizontal {",\n "width: 20px;",\n "height: 20px;",\n "background: " + selectedBg + ";",\n"}",\n"QScrollBar::up-arrow:horizontal {",\n "width: 10px;",\n "height: 20px;",\n "background: " + selectedBg + ";",\n"}",\n"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {",\n "background: none;",\n "}",\n"QScrollBar::handle {",\n "background-color: " + bigBoxBorderColor + ";",\n "border: 1px solid " + bigBoxBorderColor + ";",\n "border-radius: " + borderRadius + ";",\n"}",\n"QStatusBar {",\n //"background-color: rgb(1, 119, 255);",\n"}",\n"#desktopCollaborateLit, #desktopAccountingLit, #desktopManufactureLit, #_notice, #desktopPurchaseLit, #desktopSalesLit, #desktopSociallit {",\n "text-transform: lowercase;",\n "font-size: 18px;",\n "color: " + selectedFg + ";",\n "font-weight: 200;",\n"}",\n"QMenu {",\n "border: 1px solid " + bigBoxBorderColor + ";",\n"}",\n"QCheckBox {",\n "margin: " + multiButtonMargin + ";",\n "background-color: transparent;",\n"}",\n/* this checkbox styling is really ugly but will do if we cannot find a better solution\n"QCheckBox::indicator:checked:focus {",\n "background-color: " + selectedFg + ";",\n"}",\n"QCheckBox::indicator:unchecked:focus {",\n "background-color: " + uncheckedFg + ";",\n"}",\n*/\n"QGroupBox {",\n "text-transform: uppercase;",\n "font-size: " + groupBoxTitleFontSize + ";",\n "border-top: 1px solid " + smallBoxBorderColor + ";",\n "border-left: 1px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #e8e8e8, stop: 0.05 #e8e8e8, stop: 0.06 #FFFFFF, stop: 1 #FFFFFF);",\n "border-right: 1px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #e8e8e8, stop: 0.05 #e8e8e8, stop: 0.06 #FFFFFF, stop: 1 #FFFFFF);",\n "margin-top: 1ex;",\n "padding: " + groupBoxPadding + ";",\n"}",\n"QGroupBox::title {",\n "color: rgb(138, 138, 138);",\n "subcontrol-origin: margin;",\n "subcontrol-position: top center;",\n "padding: 0 3px;",\n"}",\n"QTabBar::tab:selected {",\n"background-color: " + selectedBg + ";",\n"color: " + selectedFg + ";",\n "border-bottom-color: " + selectedBg + ";",\n"}",\n"QTabBar::tab:!selected {",\n"background-color: " + selectedBg + ";",\n"color: #666;",\n"}",\n "QTabBar::tab:disabled {",\n"background-color: " + selectedBg + ";",\n"color: " + bigBoxBorderColor + ";",\n "border-bottom-color: " + bigBoxBorderColor + ";",\n"}",\n"QTabBar::tab {", \n "border: 1px solid " + bigBoxBorderColor + ";",\n "border-top-left-radius: " + borderRadius + ";",\n "border-top-right-radius: " + borderRadius + ";",\n "min-width: 8ex;",\n "padding-top: 2px;",\n"padding-bottom: 2px;",\n"padding-left: 4px;",\n"padding-right: 4px;",\n"}", \n"MenuButton::label {",\n "max-width: 90%;",\n"}",\n"VirtualClusterLineEdit QLabel {",\n "background-color: none;",\n"}",\n"QComboBox {",\n "padding-left: 4px;",\n "padding-right: 4px;",\n "padding-top: 2px;",\n "padding-bottom: 2px;",\n "margin: 2px;",\n "border-radius: " + borderRadius + ";",\n "border: 1px solid " + bigBoxBorderColor + ";",\n"}",\n"QComboBox:selected {",\n "border: 2px solid " + selectedFg + ";",\n"}",\n"QComboBox::editable:selected {",\n "border: 2px solid " + selectedFg + ";",\n"}",\n"QHeaderView::section {",\n "color: black;", // font-size doesn't work without this. why not?\n "font-size: " + tableHeadingFontSize + ";",\n "background-color: " + smallBoxBg + ";",\n"}",\n"QLabel {",\n "background: transparent;",\n"}",\n"QMainWindow, XDialog, XWidget {",\n "background: " + windowBg + ";",\n"}",\n"QMainWindow QMainWindow, QMainWindow XWidget {",\n "background: " + layeredWindowBg + ";",\n"}",\n"QMenuBar::item:selected {",\n "background: " + selectedBg + ";",\n "selection-background-color:" + smallBoxBg + ";",\n"}",\n"QMenuBar::item:pressed {",\n "background: " + selectedBg + ";", \n "color: " + selectedFg + ";",\n "border-left: 1px solid " + bigBoxBorderColor + ";",\n "border-right: 1px solid " + bigBoxBorderColor + ";",\n"}",\n"QMenuBar::item:hover {",\n "color: " + selectedFg + ";",\n"}",\n"QPushButton {",\n "border-radius: " + borderRadius + ";",\n "border: 1px solid " + bigBoxBorderColor + ";",\n "margin: 0.75ex;",\n "padding: 0.50ex;",\n"}",\n"QPushButton:default {",\n "color:" + selectedFg + ";",\n "border: 1px solid " + bigBoxBorderColor + ";",\n"}",\n"QPushButton:hover {",\n "color: " + selectedFg + ";",\n "background-color: " + selectedBg + ";",\n "border-color: " + selectedFg + ";",\n "border-width: 2px;",\n"}",\n"QPushButton:pressed {",\n "color: " + selectedBg + ";",\n "background-color: " + selectedFg + ";",\n"}",\n"QRadioButton {",\n "margin: " + multiButtonMargin + ";",\n"}",\n"QRadioButton::indicator {",\n "background-color: " + bigBoxBorderColor + ";",\n "width: 10px;",\n "height: 10px;",\n"}",\n"QRadioButton::indicator::unchecked {",\n "background-color: " + selectedBg + ";",\n "border: 2px solid " + bigBoxBorderColor + ";",\n "border-radius: 7px;",\n"}",\n"QRadioButton::indicator:unchecked:hover {",\n "background-color: " + selectedFg + ";",\n "border: 2px solid " + selectedBg + ";", \n "border-radius: 7px;",\n"}",\n"QRadioButton::indicator:unchecked:pressed {",\n "background-color: " + selectedFg + ";",\n "border: 2px solid " + smallBoxBg + ";",\n "border-radius: 7px;",\n"}",\n"QRadioButton::indicator::checked {",\n "background-color: " + selectedFg + ";",\n "border: 2px solid " + selectedBg + ";",\n "border-radius: 7px;",\n"}",\n"QRadioButton::indicator:checked:hover {",\n "background-color: " + selectedFg + ";",\n "border: 2px solid " + selectedBg + ";",\n "border-radius: 7px;",\n"}",\n"QRadioButton::indicator:checked:pressed {",\n "background-color: " + selectedFg + ";",\n "border: 2px solid " + selectedBg + ";",\n "border-radius: 7px;",\n"}",\n"QTextEdit, QPlainTextEdit {",\n "font-family: courier new, courier, monospace;",\n"}",\n"QTextEdit:focus, QPlainTextEdit:focus {",\n "border: 2px solid " + selectedFg + ";",\n"}",\n"QToolBar {",\n "background: " + toolbarBg + ";",\n "color: " + selectedFg + ";",\n "border: 1px solid " + smallBoxBorderColor + ";",\n"}",\n"QToolBar::separator {",\n "color: " + selectedFg + ";",\n "background-color: " + selectedBg + ";",\n "image: none;",\n "border: 1px solid " + bigBoxBorderColor + ";",\n "width: 0px;",\n"}",\n"QToolBar::handle {",\n "background-color: " + bigBoxBorderColor + ";",\n "border: 1px solid " + bigBoxBorderColor + ";",\n "image: none;",\n "width: 2px;",\n "height: 2px;",\n"}",\n"QToolButton {",\n "background-color: transparent;",\n "selection-color: " + selectedFg + ";",\n"}",\n"QToolButton:hover {",\n "border-top: none;",\n "border-left: none;",\n "border-right: none;",\n "border-bottom: 1px solid " + selectedFg + ";",\n"}",\n"QToolButton:on {",\n "border: 1px solid " + selectedFg + ";",\n "selection-color: " + selectedFg + ";",\n "color: " + selectedFg + ";",\n"}",\n\n"ParameterWidget QToolButton {",\n "border-radius: " + borderRadius + ";",\n "border: 1px solid " + bigBoxBorderColor + ";",\n "margin: 0.75ex;",\n "padding: 0.50ex;",\n"}",\n"ParameterWidget QToolButton:default {",\n "color:" + selectedFg + ";",\n "border: 1px solid " + smallBoxBorderColor + ";",\n"}",\n"ParameterWidget QToolButton:hover {",\n "border: 1px solid " + selectedFg + ";",\n "background-color: " + selectedBg + ";",\n"}",\n"ParameterWidget QToolButton:pressed {",\n "color: " + selectedBg + ";",\n "background-color: " + selectedFg + ";",\n"}",\n\n"QTreeView::item:selected QWidget {",\n "min-height: 16px;",\n"}",\n"QTreeView QScrollBar:horizontal {",\n "min-height: 10px;",\n "height: 10px;",\n"}",\n\n"QTreeView::item:selected QComboBox {",\n "color: " + selectedFg + ";",\n "font-size: " + generalFontSize + ";",\n "min-height: 15pt;", // generalFontSize + a bit\n "padding: 1px;",\n "margin: 0px;",\n"}",\n\n"QTreeWidget {",\n "selection-background-color: transparent;",\n"}"\n].join(" ");\n\nvar desktopStyle = generalStyle +\n[ "QTreeView {",\n "border-style: none;",\n "}",\n "QPushButton {",\n "border: none;",\n "}",\n "QWidget#dockWidgetContents QPushButton#_send {",\n "border-radius: " + borderRadius + ";",\n "border: 1px solid " + bigBoxBorderColor + ";",\n "margin: 0.75ex;",\n "padding: 0.50ex;",\n "}",\n "QHeaderView::section {",\n "background-color: transparent;",\n "}",\n].join(" ");\n\ntry {\n if (! preferences.boolean("xtdesktop/useNativeStyle")) {\n QApplication.setStyleSheet(generalStyle);\n }\n} catch(e) {\n QMessageBox.critical(mainwindow, "QApplication Error", e.message);\n}\n 132 systemMessage 0 t //debugger;\n\nvar _save = mywindow.findChild("_save");\nvar layout = toolbox.widgetGetLayout(_save);\nvar _user = mywindow.findChild("_user");\n\nvar _reply = toolbox.createWidget("QPushButton", mywindow, "_reply");\n_reply.text = qsTr("Reply");\nlayout.insertWidget(0, _reply);\n\n_reply.clicked.connect(sendReply);\n\nfunction sendReply() \n{\n var params = new Object;\n params.user = _user.text;\n\n var newwnd = toolbox.openWindow("sendMessageToUser", mywindow, Qt.ApplicationModal, Qt.Dialog);\n toolbox.lastWindow().set(params);\n newwnd.exec();\n mydialog.sClose();\n}\n 92 task 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("dockMyTodo");\n\n// Connect this window so that the To Do dock list gets updated\nmydialog.finished.connect(fillListToDo);\n 93 todoItem 0 t /*\n * This file is part of the xTuple ERP: PostBooks Edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\ninclude("dockMyTodo");\n\n// Connect this window so that the To Do dock list gets updated\nmydialog.finished.connect(fillListToDo);\n 94 userPreferences 0 t /*\n * This file is part of the xtdesktop package for xTuple ERP: PostBooks edition, a free and\n * open source Enterprise Resource Planning software suite,\n * Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\n * It is licensed to you under the Common Public Attribution License\n * version 1.0, the full text of which (including xTuple-specific Exhibits)\n * is available at www.xtuple.com/CPAL. By using this software, you agree\n * to be bound by its terms.\n */\n\n(function () {\n var _buttonBox = mywindow.findChild("_buttonBox"),\n _interfaceWorkspace = mywindow.findChild("_interfaceWorkspace"),\n _layout = toolbox.widgetGetLayout(_interfaceWorkspace),\n _useNativeStyle = toolbox.createWidget("QCheckBox", mywindow, "_useNativeStyle"),\n _prefs = preferences,\n _selectedUser = mywindow.findChild("_selectedUser"),\n _user = mywindow.findChild("_user")\n ;\n\n _buttonBox.accepted.connect(save);\n _interfaceWorkspace.toggled.connect(desktopNotice);\n _user["newID(int)"].connect(sUserChanged);\n\n if (_prefs.value("xtdesktop/useNativeStyle").length) {\n _useNativeStyle.checked = _prefs.boolean("xtdesktop/useNativeStyle");\n }\n \n _layout.addWidget(_useNativeStyle, 2, 1);\n _useNativeStyle.text = qsTr("Use Native Application Styling");\n\n function desktopNotice()\n {\n if (_interfaceWorkspace.checked &&\n !preferences.boolean("NoDesktopNotice"))\n toolbox.openWindow("desktopNotice", mywindow, Qt.WindowModal, Qt.Dialog);\n }\n\n function save()\n {\n if (_selectedUser.checked) {\n toolbox.executeQuery("select setUserPreference(,"\n + " 'xtdesktop/useNativeStyle',"\n + " );",\n { user: _user.text,\n bool: (_useNativeStyle.checked ? 't' : 'f') });\n } else\n _prefs.set("xtdesktop/useNativeStyle", _useNativeStyle.checked);\n }\n\n function sUserChanged(id)\n {\n var q;\n if (_selectedUser.checked && _user.isValid()) {\n q = toolbox.executeQuery("select usrpref_value from usrpref"\n + " where usrpref_name = 'xtdesktop/useNativeStyle'"\n + " and usrpref_username = ;",\n { user: _user.text });\n if (q.first()) {\n _useNativeStyle.checked = (q.value("usrpref_value") == 't');\n } else if (q.lastError().type != QSqlError.NoError) {\n QMessageBox.critical(mywindow, qsTr("Error"), q.lastError().text);\n } else {\n _useNativeStyle.checked = false;\n }\n }\n }\n\n})();\n \. -- -- Data for Name: pkguiform; Type: TABLE DATA; Schema: xtdesktop; Owner: admin -- COPY pkguiform (uiform_id, uiform_name, uiform_order, uiform_enabled, uiform_source, uiform_notes) FROM stdin; 35 desktopAccounting 0 t \n\n This file is part of the xtdesktop package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL. By using this software, you agree\nto be bound by its terms.\n desktopAccounting\n \n \n \n 0\n 0\n 876\n 554\n \n \n \n Accounting\n \n \n true\n \n \n QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks\n \n \n \n \n \n \n \n 14\n 75\n true\n \n \n \n Accounting\n \n \n \n \n \n \n Payables\n \n \n \n 6\n \n \n 0\n \n \n \n \n taxes_clock_48\n \n \n Aging\n \n \n ap.dspAPAging\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n check_write_48\n \n \n Workbench\n \n \n ap.workbench\n \n \n dspBillingSelections\n \n \n \n \n \n \n \n \n \n customers_zoom_48\n \n \n Vendor\n \n \n po.vendorWorkBench\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Receivables\n \n \n \n 6\n \n \n 0\n \n \n \n \n collection_account_clock_48\n \n \n Aging\n \n \n ar.dspARAging\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n collection_account_write_48\n \n \n Workbench\n \n \n ar.arWorkBench\n \n \n dspBillingSelections\n \n \n \n \n \n \n \n \n \n customers_zoom_48\n \n \n Customer\n \n \n so.customerWorkbench\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n General Ledger\n \n \n \n 6\n \n \n 0\n \n \n \n \n company_write_48\n \n \n Chart of Accounts\n \n \n gl.accountNumbers\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n reward_write_48\n \n \n Budget\n \n \n gl.maintainBudgets\n \n \n \n \n \n \n \n \n \n accounting_write_48\n \n \n Standard Journal\n \n \n gl.listStandardJournals\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n accounting_ok_48\n \n \n Journal Series\n \n \n gl.unpostedEntries\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Bank Accounts\n \n \n \n 6\n \n \n 0\n \n \n \n \n bank_write_48\n \n \n Adjustment\n \n \n gl.adjustmentEditList\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n bank_ok_48\n \n \n Reconcile\n \n \n gl.reconcileBankaccnt\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Reporting\n \n \n \n 6\n \n \n 0\n \n \n \n \n spreadsheet_48\n \n \n Financial Statements\n \n \n gl.viewFinancialReport\n \n \n \n \n \n \n \n \n \n \n \n \n balance_zoom_48\n \n \n Trial Balance\n \n \n gl.dspTrialBalances\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n accounting_zoom_48\n \n \n Transactions\n \n \n gl.dspGLTransactions\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Bank Accounts\n \n \n 1\n \n \n \n \n 0\n \n \n \n \n false\n \n \n \n \n \n \n \n \n Payables\n \n \n 1\n \n \n \n \n 0\n \n \n \n \n false\n \n \n \n \n \n \n \n \n Receivables\n \n \n 1\n \n \n \n \n 0\n \n \n \n \n false\n \n \n \n \n \n \n \n \n Monitored Accounts\n \n \n 8\n \n \n \n \n 0\n \n \n 0\n \n \n 0\n \n \n 3\n \n \n 3\n \n \n \n \n false\n \n \n \n \n \n \n \n 16\n 16\n \n \n \n b\n \n \n true\n \n \n \n \n \n \n \n 16\n 16\n \n \n \n b\n \n \n true\n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 40\n 20\n \n \n \n \n \n \n \n \n \n \n MenuButton\n QWidget\n

menubutton.h
\n \n \n XTreeWidget\n QTreeWidget\n
xtreewidget.h
\n
\n \n \n \n
\n 36 desktopCRM 0 t \n\n This file is part of the xtdesktop package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL. By using this software, you agree\nto be bound by its terms.\n desktopCRM\n \n \n \n 0\n 0\n 893\n 554\n \n \n \n CRM\n \n \n true\n \n \n true\n \n \n \n \n \n \n \n 14\n 75\n true\n \n \n \n Corporate Relationship Management\n \n \n \n \n \n \n Personal\n \n \n \n 6\n \n \n 0\n \n \n \n \n lamp_48\n \n \n Event Manager\n \n \n sys.eventManager\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n calendar_month_zoom_48\n \n \n To Do Calendar\n \n \n crm.todoListCalendar\n \n \n \n \n \n \n \n \n \n \n \n \n notepad_zoom_48\n \n \n To Do List\n \n \n crm.todoList\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Corporate\n \n \n \n 6\n \n \n 0\n \n \n \n \n clients_48\n \n \n Accounts\n \n \n crm.crmaccounts\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n execute_48\n \n \n Contacts\n \n \n crm.contacts\n \n \n \n \n \n \n \n \n \n \n \n \n book_48\n \n \n Address Book\n \n \n crm.addresses\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Pre-Sales\n \n \n \n 6\n \n \n 0\n \n \n \n \n customers_help_48\n \n \n Prospects\n \n \n so.prospects\n \n \n \n \n \n \n \n \n \n \n \n \n order_help_48\n \n \n Quotes\n \n \n so.listQuotes\n \n \n \n \n \n \n \n \n \n order_search_48\n \n \n Quotes by Item\n \n \n so.dspQuoteOrderLookupByItem\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n money_bag_write_48\n \n \n Opportunities\n \n \n crm.listOpportunity\n \n \n dspBillingSelections\n \n \n \n \n \n \n \n \n \n \n \n \n Project\n \n \n \n 6\n \n \n 0\n \n \n \n \n spreadsheet_48\n \n \n Projects\n \n \n pm.projects\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n time_sheet_write_48\n \n \n Time & Expense\n \n \n pm.teSheets\n \n \n \n \n \n \n \n \n \n \n \n \n spreadsheet_zoom_48\n \n \n Project Orders\n \n \n pm.dspOrderActivityByProject\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Account Management\n \n \n \n 6\n \n \n 0\n \n \n \n \n customers_48\n \n \n Customer Workbench\n \n \n so.customerWorkbench\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n chat_48\n \n \n Incidents\n \n \n crm.incidentList\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n To Do\n \n \n 8\n \n \n \n \n 0\n \n \n \n \n false\n \n \n \n \n \n \n \n \n My Contacts\n \n \n 1\n \n \n \n \n 0\n \n \n \n \n false\n \n \n \n \n \n \n \n \n My Accounts\n \n \n 1\n \n \n \n \n 0\n \n \n \n \n false\n \n \n \n \n \n \n \n \n \n MenuButton\n QWidget\n
menubutton.h
\n
\n \n XTreeWidget\n QTreeWidget\n
xtreewidget.h
\n
\n
\n \n \n
\n 37 desktopMaintenance 0 t \n\n This file is part of the xtdesktop package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL. By using this software, you agree\nto be bound by its terms.\n desktopMaintenance\n \n \n \n 0\n 0\n 905\n 563\n \n \n \n Maintenance\n \n \n true\n \n \n QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks\n \n \n \n \n \n \n \n Open Sans,Helvetica,Verdana,sans-serif\n -1\n 25\n false\n \n \n \n Maintenance\n \n \n \n \n \n \n Products\n \n \n \n 6\n \n \n 0\n \n \n \n \n inventory_categories_48\n \n \n Items\n \n \n pd.listItems\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n inventory_write_48\n \n \n Bill of Materials\n \n \n pd.listBOMs\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 0\n 20\n \n \n \n \n \n \n \n ImgDownArrow\n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 0\n 20\n \n \n \n \n \n \n \n \n \n \n \n \n Inventory\n \n \n \n 6\n \n \n 0\n \n \n \n \n store_house_48\n \n \n Site\n \n \n im.warehouse\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n cabinet_48\n \n \n Locations\n \n \n im.warehousesLocations\n \n \n dspBillingSelections\n \n \n \n \n \n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 0\n 20\n \n \n \n \n \n \n \n ImgDownArrow\n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 0\n 20\n \n \n \n \n \n \n \n \n \n \n \n \n Pricing\n \n \n \n 6\n \n \n 0\n \n \n \n \n reward_clock_48\n \n \n Schedules\n \n \n so.pricingSchedules\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n customers_write_48\n \n \n Assignments\n \n \n so.pricingScheduleAssignments\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 0\n 20\n \n \n \n \n \n \n \n ImgDownArrow\n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 0\n 20\n \n \n \n \n \n \n \n \n \n \n \n \n Security\n \n \n \n 6\n \n \n 0\n \n \n \n \n user_48\n \n \n Users\n \n \n sys.maintainUsers\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n group_48\n \n \n Roles\n \n \n sys.maintainGroups\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 0\n 20\n \n \n \n \n \n \n \n ImgDownArrow\n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 0\n 20\n \n \n \n \n \n \n \n \n \n \n \n \n Currency\n \n \n \n 6\n \n \n 0\n \n \n \n \n coin_48\n \n \n Currencies\n \n \n sys.currencies\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n coin_clock_48\n \n \n Exchange Rates\n \n \n sys.exchangeRates\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 0\n 20\n \n \n \n \n \n \n \n ImgDownArrow\n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 0\n 20\n \n \n \n \n \n \n \n \n \n \n \n \n Design\n \n \n \n 6\n \n \n 0\n \n \n \n \n calculation_write_48\n \n \n Commands\n \n \n sys.customCommands\n \n \n \n \n \n \n \n \n \n \n \n \n script_write_48\n \n \n Scripts\n \n \n sys.scripts\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n window_write_48\n \n \n Screens\n \n \n sys.uiforms\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n spreadsheet_write_48\n \n \n Reports\n \n \n sys.reports\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n export_database_write_48\n \n \n MetaSQL\n \n \n sys.metasqls\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Extensions\n \n \n 1\n \n \n \n \n 0\n \n \n \n \n false\n \n \n \n \n \n \n \n \n \n MenuButton\n QWidget\n
menubutton.h
\n
\n \n XLabel\n QLabel\n
xlabel.h
\n
\n \n XTreeWidget\n QTreeWidget\n
xtreewidget.h
\n
\n
\n \n \n
\n 38 desktopManufacture 0 t \n\n This file is part of the xtdesktop package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL. By using this software, you agree\nto be bound by its terms.\n desktopManufacture\n \n \n \n 0\n 0\n 882\n 554\n \n \n \n Manufacture\n \n \n true\n \n \n true\n \n \n \n \n \n \n \n 14\n 75\n true\n \n \n \n Manufacture\n \n \n \n \n \n \n Plan\n \n \n \n 6\n \n \n 0\n \n \n \n \n inventory_zoom_48\n \n \n Inventory Availability\n \n \n im.dspInventoryAvailability\n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n industry_add_48\n \n \n Create Work Order\n \n \n wo.newWorkOrder\n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n availability_write_48\n \n \n Material Requirements\n \n \n wo.maintainWoMaterialRequirements\n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n industry_next_48\n \n \n Release\n \n \n wo.releaseWorkOrdersByPlannerCode\n \n \n \n \n \n \n \n \n \n \n \n \n printer_48\n \n \n Print\n \n \n wo.printTraveler\n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n \n \n \n Process\n \n \n \n 6\n \n \n 0\n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n barcode_ok_48\n \n \n Issue Material\n \n \n wo.issueWoMaterialItem\n \n \n \n \n \n \n \n \n \n industry_close_48\n \n \n Close Work Order\n \n \n wo.closeWorkOrder\n \n \n \n \n \n \n \n \n \n \n \n \n barcode_back_48\n \n \n Return Material\n \n \n wo.returnWoMaterialItem\n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n coin_stack_zoom_48\n \n \n Costing\n \n \n wo.dspJobCosting\n \n \n \n \n \n \n \n \n \n \n \n \n history_zoom_48\n \n \n History\n \n \n wo.dspWoHistoryByClassCode\n \n \n \n \n \n \n \n \n \n \n \n \n industry_ok_48\n \n \n Post Production\n \n \n wo.postProduction\n \n \n \n \n \n \n \n \n \n \n \n \n trash_ok_48\n \n \n Post Scrap\n \n \n wo.scrapWoMaterialFromWo\n \n \n \n \n \n \n \n \n \n \n \n \n industry_clock_48\n \n \n Order Schedule\n \n \n wo.dspWoSchedule\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n availability_zoom_48\n \n \n Material Availability\n \n \n wo.dspInventoryAvailabilityByWorkOrder\n \n \n \n \n \n \n \n \n \n \n \n \n industry_back_48\n \n \n Correct Production\n \n \n wo.correctProductionPosting\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Qt::AllDockWidgetAreas\n \n \n Manufacture Activities\n \n \n 1\n \n \n \n \n 0\n \n \n \n \n false\n \n \n \n \n \n \n \n \n Manufacture History\n \n \n 1\n \n \n \n \n 0\n \n \n 0\n \n \n 0\n \n \n 3\n \n \n 3\n \n \n \n \n false\n \n \n \n \n \n \n \n 0\n 0\n \n \n \n label\n \n \n Qt::AlignCenter\n \n \n \n \n \n \n \n 16\n 16\n \n \n \n b\n \n \n true\n \n \n \n \n \n \n \n 16\n 16\n \n \n \n b\n \n \n true\n \n \n \n \n \n \n \n \n Qt::AllDockWidgetAreas\n \n \n Work Orders\n \n \n 8\n \n \n \n \n 0\n \n \n \n \n false\n \n \n \n \n \n \n \n \n \n MenuButton\n QWidget\n
menubutton.h
\n
\n \n XLabel\n QLabel\n
xlabel.h
\n
\n \n XTreeWidget\n QTreeWidget\n
xtreewidget.h
\n
\n
\n \n \n
\n 40 desktopPurchase 0 t \n\n This file is part of the xtdesktop package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL. By using this software, you agree\nto be bound by its terms.\n desktopPurchase\n \n \n \n 0\n 0\n 886\n 554\n \n \n \n Purchase\n \n \n true\n \n \n true\n \n \n \n \n \n \n \n 14\n 75\n true\n \n \n \n Purchase\n \n \n \n \n \n \n Order\n \n \n \n 6\n \n \n 0\n \n \n \n \n order_help_48\n \n \n Purchase Requests\n \n \n po.dspPurchaseRequestsByPlannerCode\n \n \n \n \n \n \n \n \n \n \n \n \n order_add_48\n \n \n Create Purchase Order\n \n \n po.newPurchaseOrder\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n printer_48\n \n \n Print\n \n \n po.printPurchaseOrder\n \n \n \n \n \n \n \n \n \n \n \n \n inventory_zoom_48\n \n \n Inventory Availability\n \n \n im.dspInventoryAvailability\n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n order_next_48\n \n \n Release\n \n \n po.listUnpostedPurchaseOrders\n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n \n \n \n Receive\n \n \n \n 6\n \n \n 0\n \n \n \n \n barcode_ok_48\n \n \n Enter Receipts\n \n \n sr.enterReceipt\n \n \n \n \n \n \n \n \n \n \n \n \n inventory_48\n \n \n Unposted Receipts\n \n \n sr.postReceipts\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Payment\n \n \n \n 6\n \n \n 0\n \n \n \n \n taxes_ok_48\n \n \n Vouchers\n \n \n po.listUnpostedVouchers\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n stamp_48\n \n \n Select for Payment\n \n \n ap.selectPayments\n \n \n \n \n \n \n \n \n \n \n \n \n stamp_zoom_48\n \n \n Selected Payments\n \n \n ap.listSelectPayments\n \n \n \n \n \n \n \n \n \n \n \n \n check_zoom_48\n \n \n Check Register\n \n \n ap.dspCheckRegister\n \n \n \n \n \n \n \n \n \n \n \n \n check_ok_48\n \n \n Check Run\n \n \n ap.viewCheckRun\n \n \n \n \n \n \n \n \n \n \n \n \n taxes_clock_48\n \n \n Aging\n \n \n ap.dspAPAging\n \n \n dspTimePhasedOpenAPItems\n \n \n ViewAPOpenItems\n \n \n \n \n \n \n inventory_zoom_48\n \n \n Uninvoiced Receipts\n \n \n ap.uninvoicedReceipts\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n taxes_zoom_48\n \n \n Open Items\n \n \n ap.dspOpenAPItemsByVendor\n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n \n \n \n \n Qt::AllDockWidgetAreas\n \n \n Purchase Activities\n \n \n 1\n \n \n \n \n 0\n \n \n \n \n false\n \n \n \n \n \n \n \n \n Purchase History\n \n \n 1\n \n \n \n \n 0\n \n \n 0\n \n \n 0\n \n \n 3\n \n \n 3\n \n \n \n \n false\n \n \n \n \n \n \n \n 0\n 0\n \n \n \n label\n \n \n Qt::AlignCenter\n \n \n \n \n \n \n \n 16\n 16\n \n \n \n b\n \n \n true\n \n \n \n \n \n \n \n 16\n 16\n \n \n \n b\n \n \n true\n \n \n \n \n \n \n \n \n Qt::AllDockWidgetAreas\n \n \n Purchase Orders\n \n \n 8\n \n \n \n \n 0\n \n \n \n \n false\n \n \n \n \n \n \n \n \n \n MenuButton\n QWidget\n
menubutton.h
\n
\n \n XLabel\n QLabel\n
xlabel.h
\n
\n \n XTreeWidget\n QTreeWidget\n
xtreewidget.h
\n
\n
\n \n \n
\n 41 desktopSales 0 t \n\n This file is part of the xtdesktop package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL. By using this software, you agree\nto be bound by its terms.\n desktopSales\n \n \n \n 0\n 0\n 873\n 554\n \n \n \n Sales\n \n \n true\n \n \n QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks\n \n \n \n \n \n \n \n 14\n 75\n true\n \n \n \n Sales\n \n \n \n \n \n \n Order\n \n \n \n 6\n \n \n 0\n \n \n \n \n customers_write_48\n \n \n Prospects\n \n \n so.prospects\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n customers_add_48\n \n \n New Customer\n \n \n so.enterNewCustomer\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n order_write_48\n \n \n Quotes\n \n \n so.listQuotes\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n order_add_48\n \n \n New Sales Order\n \n \n so.newSalesOrder\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Ship\n \n \n \n 6\n \n \n 0\n \n \n \n \n printer_48\n \n \n Print Packing Lists\n \n \n sr.packingListBatch\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n barcode_ok_48\n \n \n Issue To Shipping\n \n \n sr.issueToShipping\n \n \n \n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n dispatch_order_ok_48\n \n \n Ship\n \n \n sr.shipOrder\n \n \n \n \n \n \n \n \n \n \n \n \n dispatch_order_zoom_48\n \n \n Maintain Shipping\n \n \n sr.maintainShippingContents\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n order_zoom_48\n \n \n Inventory Availability\n \n \n so.dspInventoryAvailabilityByCustomerType\n \n \n \n \n \n \n \n \n \n \n \n \n order_clock_48\n \n \n Backlog\n \n \n so.dspSummarizedBacklogByWarehouse\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Bill\n \n \n \n 6\n \n \n 0\n \n \n \n \n stamp_48\n \n \n Select for Billing\n \n \n so.uninvoicedShipments\n \n \n \n \n \n \n \n \n \n \n \n \n taxes_add_48\n \n \n Create Invoices\n \n \n so.dspBillingSelections\n \n \n dspBillingSelections\n \n \n \n \n \n \n \n \n \n taxes_ok_48\n \n \n Post Invoices\n \n \n so.listUnpostedInvoices\n \n \n \n \n \n \n \n \n \n \n \n \n taxes_clock_48\n \n \n Aging\n \n \n ar.dspARAging\n \n \n \n \n \n \n \n \n \n \n \n \n payment_ok_48\n \n \n Cash Receipts\n \n \n ar.cashReceiptEditList\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n \n 0\n 0\n \n \n \n ImgRightArrow\n \n \n \n \n \n \n \n \n \n \n Sales Activities\n \n \n 1\n \n \n \n \n 0\n \n \n \n \n false\n \n \n \n \n \n \n \n \n Sales History\n \n \n 1\n \n \n \n \n 0\n \n \n 0\n \n \n 0\n \n \n 3\n \n \n 3\n \n \n \n \n false\n \n \n \n \n \n \n \n 0\n 0\n \n \n \n label\n \n \n Qt::AlignCenter\n \n \n \n \n \n \n \n 16\n 16\n \n \n \n b\n \n \n true\n \n \n \n \n \n \n \n 16\n 16\n \n \n \n b\n \n \n true\n \n \n \n \n \n \n \n \n Sales Orders\n \n \n 8\n \n \n \n \n 0\n \n \n \n \n false\n \n \n \n \n \n \n \n \n \n MenuButton\n QWidget\n
menubutton.h
\n
\n \n XLabel\n QLabel\n
xlabel.h
\n
\n \n XTreeWidget\n QTreeWidget\n
xtreewidget.h
\n
\n
\n \n \n
\n 64 desktop 0 t \n\n This file is part of the xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL. By using this software, you agree\nto be bound by its terms.\n desktop\n \n \n \n 0\n 0\n 24\n 24\n \n \n \n Desktop\n \n \n \n \n \n\n container ui for the desktop webview 65 desktopMenuBar 0 t \n\n This file is part of the xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL. By using this software, you agree\nto be bound by its terms.\n desktopMenuBar\n \n \n \n 0\n 0\n 226\n 680\n \n \n \n \n \n \n background-color: rgb(255, 255, 255);\n \n \n \n \n \n \n 16777215\n 16777215\n \n \n \n Qt::ScrollBarAsNeeded\n \n \n false\n \n \n \n \n \n \n \n 16777215\n 16777215\n \n \n \n Qt::ScrollBarAsNeeded\n \n \n false\n \n \n \n \n \n \n \n \n \n 100\n 100\n \n \n \n font: 75 12pt "Verdana";\n \n \n <html><head/><body><p>Employee</p><p>Name</p></body></html>\n \n \n \n \n \n \n \n \n \n ImageCluster\n QWidget\n
imagecluster.h
\n
\n \n XLabel\n QLabel\n
xlabel.h
\n
\n \n XTreeWidget\n QTreeWidget\n
xtreewidget.h
\n
\n
\n \n \n
\n 39 desktopNotice 0 t \n\n This file is part of the xtdesktop package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL. By using this software, you agree\nto be bound by its terms.\n desktopNotice\n \n \n \n 0\n 0\n 211\n 109\n \n \n \n Notice\n \n \n \n \n \n \n 0\n 0\n \n \n \n Note: The xTuple Desktop is only available when user preferences are set to show windows as free-floating.\n \n \n true\n \n \n \n \n \n \n Remind me about this again.\n \n \n true\n \n \n \n \n \n \n Qt::Horizontal\n \n \n QDialogButtonBox::Ok\n \n \n true\n \n \n \n \n \n \n \n \n _buttonBox\n accepted()\n desktopNotice\n accept()\n \n \n 248\n 254\n \n \n 157\n 274\n \n \n \n \n _buttonBox\n rejected()\n desktopNotice\n reject()\n \n \n 316\n 260\n \n \n 286\n 274\n \n \n \n \n\n 42 preferencesHistory 0 t \n\n This file is part of the xtdesktop package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL. By using this software, you agree\nto be bound by its terms.\n preferencesHistory\n \n \n \n 0\n 0\n 350\n 104\n \n \n \n \n 350\n 0\n \n \n \n History Settings\n \n \n \n \n \n Type:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n \n 0\n 0\n \n \n \n \n \n \n \n Qt::Vertical\n \n \n QDialogButtonBox::Cancel|QDialogButtonBox::Ok\n \n \n \n \n \n \n Group By:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n \n 0\n 0\n \n \n \n \n \n \n \n Time Frame:\n \n \n Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter\n \n \n \n \n \n \n \n 0\n 0\n \n \n \n \n \n \n \n \n XComboBox\n QComboBox\n
xcombobox.h
\n
\n
\n \n \n \n buttonBox\n accepted()\n preferencesHistory\n accept()\n \n \n 248\n 254\n \n \n 157\n 274\n \n \n \n \n buttonBox\n rejected()\n preferencesHistory\n reject()\n \n \n 316\n 260\n \n \n 286\n 274\n \n \n \n \n
\n 60 desktopSocial 0 t \n\n desktopSocial\n \n \n \n 0\n 0\n 996\n 666\n \n \n \n Social\n \n \n \n \n \n \n \n \n \n \n \n Open Sans,Helvetica,Verdana,sans-serif\n -1\n 25\n false\n \n \n \n Social\n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 40\n 20\n \n \n \n \n \n \n \n \n \n Comment Console\n \n \n \n \n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 40\n 20\n \n \n \n \n \n \n \n \n 16\n 16\n \n \n \n b\n \n \n true\n \n \n \n \n \n \n \n 16\n 16\n \n \n \n b\n \n \n true\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Qt::BottomDockWidgetArea|Qt::RightDockWidgetArea|Qt::TopDockWidgetArea\n \n \n Send Message\n \n \n 2\n \n \n \n \n \n \n false\n \n \n Send\n \n \n \n \n \n \n User:\n \n \n \n \n \n \n false\n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 54\n 20\n \n \n \n \n \n \n \n Message:\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n Qt::BottomDockWidgetArea|Qt::RightDockWidgetArea|Qt::TopDockWidgetArea\n \n \n Message History\n \n \n 2\n \n \n \n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 282\n 20\n \n \n \n \n \n \n \n \n 16\n 16\n \n \n \n b\n \n \n true\n \n \n \n \n \n \n \n 16\n 16\n \n \n \n b\n \n \n true\n \n \n \n \n \n \n \n \n Qt::BottomDockWidgetArea|Qt::RightDockWidgetArea|Qt::TopDockWidgetArea\n \n \n Users Online\n \n \n 2\n \n \n \n \n \n \n false\n \n \n \n \n \n \n \n \n \n UsernameCluster\n QWidget\n
usernamecluster.h
\n
\n \n XTreeWidget\n QTreeWidget\n
xtreewidget.h
\n 1\n
\n
\n \n \n
\n 61 preferencesComment 0 t \r\n\r\n preferencesComment\r\n \r\n \r\n \r\n 0\r\n 0\r\n 626\r\n 342\r\n \r\n \r\n \r\n Comment Preference\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Qt::Horizontal\r\n \r\n \r\n \r\n 40\r\n 20\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n QAbstractItemView::ExtendedSelection\r\n \r\n \r\n \r\n \r\n \r\n \r\n QAbstractItemView::ExtendedSelection\r\n \r\n \r\n \r\n \r\n \r\n \r\n QAbstractItemView::ExtendedSelection\r\n \r\n \r\n \r\n \r\n \r\n \r\n Qt::Horizontal\r\n \r\n \r\n \r\n 40\r\n 20\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Qt::Horizontal\r\n \r\n \r\n \r\n 40\r\n 20\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Qt::Horizontal\r\n \r\n \r\n QDialogButtonBox::Cancel|QDialogButtonBox::Ok\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n DateCluster\r\n QWidget\r\n
datecluster.h
\r\n
\r\n \r\n XTreeWidget\r\n QTreeWidget\r\n
xtreewidget.h
\r\n 1\r\n
\r\n
\r\n \r\n \r\n \r\n _buttonBox\r\n accepted()\r\n preferencesComment\r\n accept()\r\n \r\n \r\n 248\r\n 254\r\n \r\n \r\n 157\r\n 274\r\n \r\n \r\n \r\n \r\n _buttonBox\r\n rejected()\r\n preferencesComment\r\n reject()\r\n \r\n \r\n 316\r\n 260\r\n \r\n \r\n 286\r\n 274\r\n \r\n \r\n \r\n \r\n
\r\n 62 preferencesNumber 0 t \r\n\r\n preferencesNumber\r\n \r\n \r\n \r\n 0\r\n 0\r\n 257\r\n 72\r\n \r\n \r\n \r\n Number Preferences\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Messages to display:\r\n \r\n \r\n \r\n \r\n \r\n \r\n 10\r\n \r\n \r\n \r\n \r\n \r\n \r\n Qt::Horizontal\r\n \r\n \r\n \r\n 40\r\n 20\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Qt::Vertical\r\n \r\n \r\n QDialogButtonBox::Cancel|QDialogButtonBox::Ok\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n buttonBox\r\n accepted()\r\n preferencesNumber\r\n accept()\r\n \r\n \r\n 209\r\n 35\r\n \r\n \r\n 128\r\n 35\r\n \r\n \r\n \r\n \r\n buttonBox\r\n rejected()\r\n preferencesNumber\r\n reject()\r\n \r\n \r\n 209\r\n 35\r\n \r\n \r\n 128\r\n 35\r\n \r\n \r\n \r\n \r\n\r\n 43 preferencesSelections 0 t \n\n This file is part of the xtdesktop package for xTuple ERP: PostBooks Edition, a free and\nopen source Enterprise Resource Planning software suite,\nCopyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple.\nIt is licensed to you under the Common Public Attribution License\nversion 1.0, the full text of which (including xTuple-specific Exhibits)\nis available at www.xtuple.com/CPAL. By using this software, you agree\nto be bound by its terms.\n preferencesSelections\n \n \n \n 0\n 0\n 280\n 259\n \n \n \n Selection Preferences\n \n \n \n \n \n QAbstractItemView::ExtendedSelection\n \n \n \n \n \n \n Qt::Horizontal\n \n \n QDialogButtonBox::Cancel|QDialogButtonBox::Ok\n \n \n \n \n \n \n Select Accounts to monitor:\n \n \n \n \n \n \n \n XTreeWidget\n QTreeWidget\n
xtreewidget.h
\n
\n
\n \n \n \n _buttonBox\n accepted()\n preferencesSelections\n accept()\n \n \n 248\n 254\n \n \n 157\n 274\n \n \n \n \n _buttonBox\n rejected()\n preferencesSelections\n reject()\n \n \n 316\n 260\n \n \n 286\n 274\n \n \n \n \n
\n 63 sendMessageToUser 0 t \n\n sendMessageToUser\n \n \n \n 0\n 0\n 406\n 300\n \n \n \n Send Message to User\n \n \n \n \n \n User:\n \n \n \n \n \n \n Qt::Horizontal\n \n \n \n 158\n 56\n \n \n \n \n \n \n \n \n \n Close\n \n \n \n \n \n \n false\n \n \n Send\n \n \n \n \n \n \n Qt::Vertical\n \n \n \n 38\n 25\n \n \n \n \n \n \n \n \n \n false\n \n \n \n \n \n \n Message:\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n UsernameCluster\n QWidget\n
usernamecluster.h
\n
\n
\n \n \n
\n \. SET search_path = fixcountry, pg_catalog; -- -- Name: pkgcmd_pkey; Type: CONSTRAINT; Schema: fixcountry; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgcmd ADD CONSTRAINT pkgcmd_pkey PRIMARY KEY (cmd_id); -- -- Name: pkgcmdarg_pkey; Type: CONSTRAINT; Schema: fixcountry; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgcmdarg ADD CONSTRAINT pkgcmdarg_pkey PRIMARY KEY (cmdarg_id); -- -- Name: pkgimage_pkey; Type: CONSTRAINT; Schema: fixcountry; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgimage ADD CONSTRAINT pkgimage_pkey PRIMARY KEY (image_id); -- -- Name: pkgmetasql_pkey; Type: CONSTRAINT; Schema: fixcountry; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgmetasql ADD CONSTRAINT pkgmetasql_pkey PRIMARY KEY (metasql_id); -- -- Name: pkgpriv_pkey; Type: CONSTRAINT; Schema: fixcountry; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgpriv ADD CONSTRAINT pkgpriv_pkey PRIMARY KEY (priv_id); -- -- Name: pkgreport_pkey; Type: CONSTRAINT; Schema: fixcountry; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgreport ADD CONSTRAINT pkgreport_pkey PRIMARY KEY (report_id); -- -- Name: pkgscript_pkey; Type: CONSTRAINT; Schema: fixcountry; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgscript ADD CONSTRAINT pkgscript_pkey PRIMARY KEY (script_id); -- -- Name: pkguiform_pkey; Type: CONSTRAINT; Schema: fixcountry; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkguiform ADD CONSTRAINT pkguiform_pkey PRIMARY KEY (uiform_id); SET search_path = public, pg_catalog; -- -- Name: acalitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY acalitem ADD CONSTRAINT acalitem_pkey PRIMARY KEY (acalitem_id); -- -- Name: accnt_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY accnt ADD CONSTRAINT accnt_pkey PRIMARY KEY (accnt_id); -- -- Name: addr_addr_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY addr ADD CONSTRAINT addr_addr_number_key UNIQUE (addr_number); -- -- Name: addr_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY addr ADD CONSTRAINT addr_pkey PRIMARY KEY (addr_id); -- -- Name: alarm_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY alarm ADD CONSTRAINT alarm_pkey PRIMARY KEY (alarm_id); -- -- Name: apaccnt_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY apaccnt ADD CONSTRAINT apaccnt_pkey PRIMARY KEY (apaccnt_id); -- -- Name: apapply_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY apapply ADD CONSTRAINT apapply_pkey PRIMARY KEY (apapply_id); -- -- Name: apcreditapply_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY apcreditapply ADD CONSTRAINT apcreditapply_pkey PRIMARY KEY (apcreditapply_id); -- -- Name: apopen_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY apopen ADD CONSTRAINT apopen_pkey PRIMARY KEY (apopen_id); -- -- Name: apopentax_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY apopentax ADD CONSTRAINT apopentax_pkey PRIMARY KEY (taxhist_id); -- -- Name: apselect_apselect_apopen_id_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY apselect ADD CONSTRAINT apselect_apselect_apopen_id_key UNIQUE (apselect_apopen_id); -- -- Name: apselect_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY apselect ADD CONSTRAINT apselect_pkey PRIMARY KEY (apselect_id); -- -- Name: araccnt_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY araccnt ADD CONSTRAINT araccnt_pkey PRIMARY KEY (araccnt_id); -- -- Name: arapply_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY arapply ADD CONSTRAINT arapply_pkey PRIMARY KEY (arapply_id); -- -- Name: arcreditapply_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY arcreditapply ADD CONSTRAINT arcreditapply_pkey PRIMARY KEY (arcreditapply_id); -- -- Name: aropen_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY aropen ADD CONSTRAINT aropen_pkey PRIMARY KEY (aropen_id); -- -- Name: aropenalloc_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY aropenalloc ADD CONSTRAINT aropenalloc_pkey PRIMARY KEY (aropenalloc_aropen_id, aropenalloc_doctype, aropenalloc_doc_id); -- -- Name: aropentax_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY aropentax ADD CONSTRAINT aropentax_pkey PRIMARY KEY (taxhist_id); -- -- Name: asohist_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY asohist ADD CONSTRAINT asohist_pkey PRIMARY KEY (asohist_id); -- -- Name: asohisttax_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY asohisttax ADD CONSTRAINT asohisttax_pkey PRIMARY KEY (taxhist_id); -- -- Name: atlasmap_atlasmap_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY atlasmap ADD CONSTRAINT atlasmap_atlasmap_name_key UNIQUE (atlasmap_name); -- -- Name: atlasmap_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY atlasmap ADD CONSTRAINT atlasmap_pkey PRIMARY KEY (atlasmap_id); -- -- Name: bankaccnt_bankaccnt_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY bankaccnt ADD CONSTRAINT bankaccnt_bankaccnt_name_key UNIQUE (bankaccnt_name); -- -- Name: bankaccnt_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY bankaccnt ADD CONSTRAINT bankaccnt_pkey PRIMARY KEY (bankaccnt_id); -- -- Name: bankadj_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY bankadj ADD CONSTRAINT bankadj_pkey PRIMARY KEY (bankadj_id); -- -- Name: bankadjtype_bankadjtype_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY bankadjtype ADD CONSTRAINT bankadjtype_bankadjtype_name_key UNIQUE (bankadjtype_name); -- -- Name: bankadjtype_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY bankadjtype ADD CONSTRAINT bankadjtype_pkey PRIMARY KEY (bankadjtype_id); -- -- Name: bankrec_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY bankrec ADD CONSTRAINT bankrec_pkey PRIMARY KEY (bankrec_id); -- -- Name: bankrecimport_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY bankrecimport ADD CONSTRAINT bankrecimport_pkey PRIMARY KEY (bankrecimport_id); -- -- Name: bankrecitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY bankrecitem ADD CONSTRAINT bankrecitem_pkey PRIMARY KEY (bankrecitem_id); -- -- Name: bomhead_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY bomhead ADD CONSTRAINT bomhead_pkey PRIMARY KEY (bomhead_id); -- -- Name: bomitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY bomitem ADD CONSTRAINT bomitem_pkey PRIMARY KEY (bomitem_id); -- -- Name: bomitemcost_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY bomitemcost ADD CONSTRAINT bomitemcost_pkey PRIMARY KEY (bomitemcost_id); -- -- Name: bomitemsub_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY bomitemsub ADD CONSTRAINT bomitemsub_pkey PRIMARY KEY (bomitemsub_id); -- -- Name: bomwork_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY bomwork ADD CONSTRAINT bomwork_pkey PRIMARY KEY (bomwork_id); -- -- Name: budghead_budghead_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY budghead ADD CONSTRAINT budghead_budghead_name_key UNIQUE (budghead_name); -- -- Name: budghead_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY budghead ADD CONSTRAINT budghead_pkey PRIMARY KEY (budghead_id); -- -- Name: budgitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY budgitem ADD CONSTRAINT budgitem_pkey PRIMARY KEY (budgitem_id); -- -- Name: calhead_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY calhead ADD CONSTRAINT calhead_pkey PRIMARY KEY (calhead_id); -- -- Name: cashrcpt_cashrcpt_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cashrcpt ADD CONSTRAINT cashrcpt_cashrcpt_number_key UNIQUE (cashrcpt_number); -- -- Name: cashrcpt_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cashrcpt ADD CONSTRAINT cashrcpt_pkey PRIMARY KEY (cashrcpt_id); -- -- Name: cashrcptitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cashrcptitem ADD CONSTRAINT cashrcptitem_pkey PRIMARY KEY (cashrcptitem_id); -- -- Name: cashrcptmisc_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cashrcptmisc ADD CONSTRAINT cashrcptmisc_pkey PRIMARY KEY (cashrcptmisc_id); -- -- Name: ccard_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY ccard ADD CONSTRAINT ccard_pkey PRIMARY KEY (ccard_id); -- -- Name: ccardaud_ccard_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY ccardaud ADD CONSTRAINT ccardaud_ccard_pkey PRIMARY KEY (ccardaud_id); -- -- Name: ccbank_ccbank_ccard_type_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY ccbank ADD CONSTRAINT ccbank_ccbank_ccard_type_key UNIQUE (ccbank_ccard_type); -- -- Name: ccbank_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY ccbank ADD CONSTRAINT ccbank_pkey PRIMARY KEY (ccbank_id); -- -- Name: ccpay_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY ccpay ADD CONSTRAINT ccpay_pkey PRIMARY KEY (ccpay_id); -- -- Name: char_char_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY "char" ADD CONSTRAINT char_char_name_key UNIQUE (char_name); -- -- Name: char_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY "char" ADD CONSTRAINT char_pkey PRIMARY KEY (char_id); -- -- Name: charass_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY charass ADD CONSTRAINT charass_pkey PRIMARY KEY (charass_id); -- -- Name: charopt_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY charopt ADD CONSTRAINT charopt_pkey PRIMARY KEY (charopt_id); -- -- Name: charuse_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY charuse ADD CONSTRAINT charuse_pkey PRIMARY KEY (charuse_id); -- -- Name: checkhead_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY checkhead ADD CONSTRAINT checkhead_pkey PRIMARY KEY (checkhead_id); -- -- Name: checkitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY checkitem ADD CONSTRAINT checkitem_pkey PRIMARY KEY (checkitem_id); -- -- Name: classcode_classcode_code_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY classcode ADD CONSTRAINT classcode_classcode_code_key UNIQUE (classcode_code); -- -- Name: classcode_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY classcode ADD CONSTRAINT classcode_pkey PRIMARY KEY (classcode_id); -- -- Name: cmd_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cmd ADD CONSTRAINT cmd_pkey PRIMARY KEY (cmd_id); -- -- Name: cmdarg_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cmdarg ADD CONSTRAINT cmdarg_pkey PRIMARY KEY (cmdarg_id); -- -- Name: cmhead_cmhead_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cmhead ADD CONSTRAINT cmhead_cmhead_number_key UNIQUE (cmhead_number); -- -- Name: cmhead_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cmhead ADD CONSTRAINT cmhead_pkey PRIMARY KEY (cmhead_id); -- -- Name: cmheadtax_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cmheadtax ADD CONSTRAINT cmheadtax_pkey PRIMARY KEY (taxhist_id); -- -- Name: cmitem_cmhead_id_linenumber_unique; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cmitem ADD CONSTRAINT cmitem_cmhead_id_linenumber_unique UNIQUE (cmitem_cmhead_id, cmitem_linenumber); -- -- Name: cmitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cmitem ADD CONSTRAINT cmitem_pkey PRIMARY KEY (cmitem_id); -- -- Name: cmitemtax_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cmitemtax ADD CONSTRAINT cmitemtax_pkey PRIMARY KEY (taxhist_id); -- -- Name: cmnttype_cmnttype_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cmnttype ADD CONSTRAINT cmnttype_cmnttype_name_key UNIQUE (cmnttype_name); -- -- Name: cmnttype_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cmnttype ADD CONSTRAINT cmnttype_pkey PRIMARY KEY (cmnttype_id); -- -- Name: cmnttypesource_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cmnttypesource ADD CONSTRAINT cmnttypesource_pkey PRIMARY KEY (cmnttypesource_id); -- -- Name: cntct_cntct_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cntct ADD CONSTRAINT cntct_cntct_number_key UNIQUE (cntct_number); -- -- Name: cntct_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cntct ADD CONSTRAINT cntct_pkey PRIMARY KEY (cntct_id); -- -- Name: cntctaddr_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cntctaddr ADD CONSTRAINT cntctaddr_pkey PRIMARY KEY (cntctaddr_id); -- -- Name: cntctdata_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cntctdata ADD CONSTRAINT cntctdata_pkey PRIMARY KEY (cntctdata_id); -- -- Name: cntcteml_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cntcteml ADD CONSTRAINT cntcteml_pkey PRIMARY KEY (cntcteml_id); -- -- Name: cntctmrgd_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cntctmrgd ADD CONSTRAINT cntctmrgd_pkey PRIMARY KEY (cntctmrgd_cntct_id); -- -- Name: cntctsel_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cntctsel ADD CONSTRAINT cntctsel_pkey PRIMARY KEY (cntctsel_cntct_id); -- -- Name: cntslip_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cntslip ADD CONSTRAINT cntslip_pkey PRIMARY KEY (cntslip_id); -- -- Name: cobill_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cobill ADD CONSTRAINT cobill_pkey PRIMARY KEY (cobill_id); -- -- Name: cobilltax_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cobilltax ADD CONSTRAINT cobilltax_pkey PRIMARY KEY (taxhist_id); -- -- Name: cobmisc_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cobmisc ADD CONSTRAINT cobmisc_pkey PRIMARY KEY (cobmisc_id); -- -- Name: cobmisctax_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cobmisctax ADD CONSTRAINT cobmisctax_pkey PRIMARY KEY (taxhist_id); -- -- Name: cohead_cohead_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_number_key UNIQUE (cohead_number); -- -- Name: cohead_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cohead ADD CONSTRAINT cohead_pkey PRIMARY KEY (cohead_id); -- -- Name: cohist_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cohist ADD CONSTRAINT cohist_pkey PRIMARY KEY (cohist_id); -- -- Name: cohisttax_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY cohisttax ADD CONSTRAINT cohisttax_pkey PRIMARY KEY (taxhist_id); -- -- Name: coitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY coitem ADD CONSTRAINT coitem_pkey PRIMARY KEY (coitem_id); -- -- Name: comment_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY comment ADD CONSTRAINT comment_pkey PRIMARY KEY (comment_id); -- -- Name: company_company_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY company ADD CONSTRAINT company_company_number_key UNIQUE (company_number); -- -- Name: company_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY company ADD CONSTRAINT company_pkey PRIMARY KEY (company_id); -- -- Name: contrct_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY contrct ADD CONSTRAINT contrct_pkey PRIMARY KEY (contrct_id); -- -- Name: costcat_costcat_code_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY costcat ADD CONSTRAINT costcat_costcat_code_key UNIQUE (costcat_code); -- -- Name: costcat_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY costcat ADD CONSTRAINT costcat_pkey PRIMARY KEY (costcat_id); -- -- Name: costelem_costelem_type_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY costelem ADD CONSTRAINT costelem_costelem_type_key UNIQUE (costelem_type); -- -- Name: costelem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY costelem ADD CONSTRAINT costelem_pkey PRIMARY KEY (costelem_id); -- -- Name: costhist_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY costhist ADD CONSTRAINT costhist_pkey PRIMARY KEY (costhist_id); -- -- Name: costupdate_costupdate_item_id_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY costupdate ADD CONSTRAINT costupdate_costupdate_item_id_key UNIQUE (costupdate_item_id); -- -- Name: country_country_abbr_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY country ADD CONSTRAINT country_country_abbr_key UNIQUE (country_abbr); -- -- Name: country_country_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY country ADD CONSTRAINT country_country_name_key UNIQUE (country_name); -- -- Name: country_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY country ADD CONSTRAINT country_pkey PRIMARY KEY (country_id); -- -- Name: crmacct_crmacct_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_crmacct_number_key UNIQUE (crmacct_number); -- -- Name: crmacct_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_pkey PRIMARY KEY (crmacct_id); -- -- Name: crmacctsel_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY crmacctsel ADD CONSTRAINT crmacctsel_pkey PRIMARY KEY (crmacctsel_src_crmacct_id); -- -- Name: curr_rate_curr_id_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY curr_rate ADD CONSTRAINT curr_rate_curr_id_key UNIQUE (curr_id, curr_effective); -- -- Name: curr_rate_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY curr_rate ADD CONSTRAINT curr_rate_pkey PRIMARY KEY (curr_rate_id); -- -- Name: curr_symbol_curr_abbr_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY curr_symbol ADD CONSTRAINT curr_symbol_curr_abbr_key UNIQUE (curr_abbr); -- -- Name: curr_symbol_curr_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY curr_symbol ADD CONSTRAINT curr_symbol_curr_name_key UNIQUE (curr_name); -- -- Name: curr_symbol_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY curr_symbol ADD CONSTRAINT curr_symbol_pkey PRIMARY KEY (curr_id); -- -- Name: cust_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY custinfo ADD CONSTRAINT cust_pkey PRIMARY KEY (cust_id); -- -- Name: custform_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY custform ADD CONSTRAINT custform_pkey PRIMARY KEY (custform_id); -- -- Name: custgrp_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY custgrp ADD CONSTRAINT custgrp_pkey PRIMARY KEY (custgrp_id); -- -- Name: custgrpitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY custgrpitem ADD CONSTRAINT custgrpitem_pkey PRIMARY KEY (custgrpitem_id); -- -- Name: custinfo_cust_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY custinfo ADD CONSTRAINT custinfo_cust_number_key UNIQUE (cust_number); -- -- Name: custtype_custtype_code_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY custtype ADD CONSTRAINT custtype_custtype_code_key UNIQUE (custtype_code); -- -- Name: custtype_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY custtype ADD CONSTRAINT custtype_pkey PRIMARY KEY (custtype_id); -- -- Name: dept_dept_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY dept ADD CONSTRAINT dept_dept_number_key UNIQUE (dept_number); -- -- Name: dept_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY dept ADD CONSTRAINT dept_pkey PRIMARY KEY (dept_id); -- -- Name: destination_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY destination ADD CONSTRAINT destination_pkey PRIMARY KEY (destination_id); -- -- Name: docass_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY docass ADD CONSTRAINT docass_pkey PRIMARY KEY (docass_id); -- -- Name: emp_emp_code_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY emp ADD CONSTRAINT emp_emp_code_key UNIQUE (emp_code); -- -- Name: emp_emp_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY emp ADD CONSTRAINT emp_emp_number_key UNIQUE (emp_number); -- -- Name: emp_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY emp ADD CONSTRAINT emp_pkey PRIMARY KEY (emp_id); -- -- Name: empgrp_empgrp_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY empgrp ADD CONSTRAINT empgrp_empgrp_name_key UNIQUE (empgrp_name); -- -- Name: empgrp_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY empgrp ADD CONSTRAINT empgrp_pkey PRIMARY KEY (empgrp_id); -- -- Name: empgrpitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY empgrpitem ADD CONSTRAINT empgrpitem_pkey PRIMARY KEY (empgrpitem_id); -- -- Name: evntlog_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY evntlog ADD CONSTRAINT evntlog_pkey PRIMARY KEY (evntlog_id); -- -- Name: evntnot_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY evntnot ADD CONSTRAINT evntnot_pkey PRIMARY KEY (evntnot_id); -- -- Name: evnttype_evnttype_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY evnttype ADD CONSTRAINT evnttype_evnttype_name_key UNIQUE (evnttype_name); -- -- Name: evnttype_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY evnttype ADD CONSTRAINT evnttype_pkey PRIMARY KEY (evnttype_id); -- -- Name: expcat_expcat_code_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY expcat ADD CONSTRAINT expcat_expcat_code_key UNIQUE (expcat_code); -- -- Name: expcat_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY expcat ADD CONSTRAINT expcat_pkey PRIMARY KEY (expcat_id); -- -- Name: file_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY file ADD CONSTRAINT file_pkey PRIMARY KEY (file_id); -- -- Name: filter_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY filter ADD CONSTRAINT filter_pkey PRIMARY KEY (filter_id); -- -- Name: fincharg_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY fincharg ADD CONSTRAINT fincharg_pkey PRIMARY KEY (fincharg_id); -- -- Name: fkey_flcol_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY flcol ADD CONSTRAINT fkey_flcol_key PRIMARY KEY (flcol_id); -- -- Name: flgrp_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY flgrp ADD CONSTRAINT flgrp_pkey PRIMARY KEY (flgrp_id); -- -- Name: flhead_flhead_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY flhead ADD CONSTRAINT flhead_flhead_name_key UNIQUE (flhead_name); -- -- Name: flhead_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY flhead ADD CONSTRAINT flhead_pkey PRIMARY KEY (flhead_id); -- -- Name: flitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY flitem ADD CONSTRAINT flitem_pkey PRIMARY KEY (flitem_id); -- -- Name: flnotes_flnotes_flhead_id_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY flnotes ADD CONSTRAINT flnotes_flnotes_flhead_id_key UNIQUE (flnotes_flhead_id, flnotes_period_id); -- -- Name: flrpt_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY flrpt ADD CONSTRAINT flrpt_pkey PRIMARY KEY (flrpt_id); -- -- Name: flspec_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY flspec ADD CONSTRAINT flspec_pkey PRIMARY KEY (flspec_id); -- -- Name: form_form_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY form ADD CONSTRAINT form_form_name_key UNIQUE (form_name); -- -- Name: form_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY form ADD CONSTRAINT form_pkey PRIMARY KEY (form_id); -- -- Name: freightclass_freightclass_code_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY freightclass ADD CONSTRAINT freightclass_freightclass_code_key UNIQUE (freightclass_code); -- -- Name: freightclass_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY freightclass ADD CONSTRAINT freightclass_pkey PRIMARY KEY (freightclass_id); -- -- Name: glseries_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY glseries ADD CONSTRAINT glseries_pkey PRIMARY KEY (glseries_id); -- -- Name: gltrans_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY gltrans ADD CONSTRAINT gltrans_pkey PRIMARY KEY (gltrans_id); -- -- Name: grp_grp_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY grp ADD CONSTRAINT grp_grp_name_key UNIQUE (grp_name); -- -- Name: grp_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY grp ADD CONSTRAINT grp_pkey PRIMARY KEY (grp_id); -- -- Name: grppriv_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY grppriv ADD CONSTRAINT grppriv_pkey PRIMARY KEY (grppriv_id); -- -- Name: hnfc_hnfc_code_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY hnfc ADD CONSTRAINT hnfc_hnfc_code_key UNIQUE (hnfc_code); -- -- Name: hnfc_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY hnfc ADD CONSTRAINT hnfc_pkey PRIMARY KEY (hnfc_id); -- -- Name: image_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY image ADD CONSTRAINT image_pkey PRIMARY KEY (image_id); -- -- Name: imageass_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY imageass ADD CONSTRAINT imageass_pkey PRIMARY KEY (imageass_id); -- -- Name: incdt_incdt_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_number_key UNIQUE (incdt_number); -- -- Name: incdt_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY incdt ADD CONSTRAINT incdt_pkey PRIMARY KEY (incdt_id); -- -- Name: incdtcat_incdtcat_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY incdtcat ADD CONSTRAINT incdtcat_incdtcat_name_key UNIQUE (incdtcat_name); -- -- Name: incdtcat_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY incdtcat ADD CONSTRAINT incdtcat_pkey PRIMARY KEY (incdtcat_id); -- -- Name: incdthist_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY incdthist ADD CONSTRAINT incdthist_pkey PRIMARY KEY (incdthist_id); -- -- Name: incdtpriority_incdtpriority_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY incdtpriority ADD CONSTRAINT incdtpriority_incdtpriority_name_key UNIQUE (incdtpriority_name); -- -- Name: incdtpriority_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY incdtpriority ADD CONSTRAINT incdtpriority_pkey PRIMARY KEY (incdtpriority_id); -- -- Name: incdtresolution_incdtresolution_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY incdtresolution ADD CONSTRAINT incdtresolution_incdtresolution_name_key UNIQUE (incdtresolution_name); -- -- Name: incdtresolution_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY incdtresolution ADD CONSTRAINT incdtresolution_pkey PRIMARY KEY (incdtresolution_id); -- -- Name: incdtseverity_incdtseverity_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY incdtseverity ADD CONSTRAINT incdtseverity_incdtseverity_name_key UNIQUE (incdtseverity_name); -- -- Name: incdtseverity_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY incdtseverity ADD CONSTRAINT incdtseverity_pkey PRIMARY KEY (incdtseverity_id); -- -- Name: invbal_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY invbal ADD CONSTRAINT invbal_pkey PRIMARY KEY (invbal_id); -- -- Name: invchead_invcnumber_unique; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY invchead ADD CONSTRAINT invchead_invcnumber_unique UNIQUE (invchead_invcnumber); -- -- Name: invchead_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY invchead ADD CONSTRAINT invchead_pkey PRIMARY KEY (invchead_id); -- -- Name: invcheadtax_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY invcheadtax ADD CONSTRAINT invcheadtax_pkey PRIMARY KEY (taxhist_id); -- -- Name: invcitem_invchead_id_linenumber_unique; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY invcitem ADD CONSTRAINT invcitem_invchead_id_linenumber_unique UNIQUE (invcitem_invchead_id, invcitem_linenumber); -- -- Name: invcitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY invcitem ADD CONSTRAINT invcitem_pkey PRIMARY KEY (invcitem_id); -- -- Name: invcitemtax_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY invcitemtax ADD CONSTRAINT invcitemtax_pkey PRIMARY KEY (taxhist_id); -- -- Name: invcnt_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY invcnt ADD CONSTRAINT invcnt_pkey PRIMARY KEY (invcnt_id); -- -- Name: invdetail_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY invdetail ADD CONSTRAINT invdetail_pkey PRIMARY KEY (invdetail_id); -- -- Name: invhist_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY invhist ADD CONSTRAINT invhist_pkey PRIMARY KEY (invhist_id); -- -- Name: invhistexpcat_invhist_id_expcat_id; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY invhistexpcat ADD CONSTRAINT invhistexpcat_invhist_id_expcat_id UNIQUE (invhistexpcat_invhist_id, invhistexpcat_expcat_id); -- -- Name: invhistexpcat_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY invhistexpcat ADD CONSTRAINT invhistexpcat_pkey PRIMARY KEY (invhistexpcat_id); -- -- Name: ipsass_ipsass_ipshead_id_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY ipsass ADD CONSTRAINT ipsass_ipsass_ipshead_id_key UNIQUE (ipsass_ipshead_id, ipsass_cust_id, ipsass_custtype_id, ipsass_custtype_pattern, ipsass_shipto_id, ipsass_shipto_pattern); -- -- Name: ipsass_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY ipsass ADD CONSTRAINT ipsass_pkey PRIMARY KEY (ipsass_id); -- -- Name: ipsfreight_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY ipsfreight ADD CONSTRAINT ipsfreight_pkey PRIMARY KEY (ipsfreight_id); -- -- Name: ipshead_ipshead_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY ipshead ADD CONSTRAINT ipshead_ipshead_name_key UNIQUE (ipshead_name); -- -- Name: ipshead_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY ipshead ADD CONSTRAINT ipshead_pkey PRIMARY KEY (ipshead_id); -- -- Name: ipsitem_ipsitem_ipshead_id_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY ipsiteminfo ADD CONSTRAINT ipsitem_ipsitem_ipshead_id_key UNIQUE (ipsitem_ipshead_id, ipsitem_item_id, ipsitem_prodcat_id, ipsitem_qtybreak, ipsitem_qty_uom_id, ipsitem_price_uom_id); -- -- Name: ipsitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY ipsiteminfo ADD CONSTRAINT ipsitem_pkey PRIMARY KEY (ipsitem_id); -- -- Name: ipsitemchar_ipsitemchar_ipsitem_id_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY ipsitemchar ADD CONSTRAINT ipsitemchar_ipsitemchar_ipsitem_id_key UNIQUE (ipsitemchar_ipsitem_id, ipsitemchar_char_id, ipsitemchar_value); -- -- Name: ipsitemchar_ipsitemchar_ipsitem_id_key1; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY ipsitemchar ADD CONSTRAINT ipsitemchar_ipsitemchar_ipsitem_id_key1 UNIQUE (ipsitemchar_ipsitem_id, ipsitemchar_char_id, ipsitemchar_value); -- -- Name: ipsitemchar_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY ipsitemchar ADD CONSTRAINT ipsitemchar_pkey PRIMARY KEY (ipsitemchar_id); -- -- Name: ipsprodcat_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY ipsprodcat_bak ADD CONSTRAINT ipsprodcat_pkey PRIMARY KEY (ipsprodcat_id); -- -- Name: item_item_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY item ADD CONSTRAINT item_item_number_key UNIQUE (item_number); -- -- Name: item_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY item ADD CONSTRAINT item_pkey PRIMARY KEY (item_id); -- -- Name: itemalias_itemalias_item_id_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemalias ADD CONSTRAINT itemalias_itemalias_item_id_key UNIQUE (itemalias_item_id, itemalias_number); -- -- Name: itemalias_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemalias ADD CONSTRAINT itemalias_pkey PRIMARY KEY (itemalias_id); -- -- Name: itemcost_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemcost ADD CONSTRAINT itemcost_pkey PRIMARY KEY (itemcost_id); -- -- Name: itemgrp_itemgrp_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemgrp ADD CONSTRAINT itemgrp_itemgrp_name_key UNIQUE (itemgrp_name); -- -- Name: itemgrp_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemgrp ADD CONSTRAINT itemgrp_pkey PRIMARY KEY (itemgrp_id); -- -- Name: itemgrpitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemgrpitem ADD CONSTRAINT itemgrpitem_pkey PRIMARY KEY (itemgrpitem_id); -- -- Name: itemgrpitem_unique_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemgrpitem ADD CONSTRAINT itemgrpitem_unique_key UNIQUE (itemgrpitem_itemgrp_id, itemgrpitem_item_id, itemgrpitem_item_type); -- -- Name: itemloc_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemloc ADD CONSTRAINT itemloc_pkey PRIMARY KEY (itemloc_id); -- -- Name: itemlocdist_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemlocdist ADD CONSTRAINT itemlocdist_pkey PRIMARY KEY (itemlocdist_id); -- -- Name: itemlocpost_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemlocpost ADD CONSTRAINT itemlocpost_pkey PRIMARY KEY (itemlocpost_id); -- -- Name: itemsite_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemsite ADD CONSTRAINT itemsite_pkey PRIMARY KEY (itemsite_id); -- -- Name: itemsrc_itemsrc_vend_id_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemsrc ADD CONSTRAINT itemsrc_itemsrc_vend_id_key UNIQUE (itemsrc_vend_id, itemsrc_item_id, itemsrc_effective, itemsrc_expires, itemsrc_vend_item_number, itemsrc_manuf_name, itemsrc_manuf_item_number, itemsrc_contrct_id); -- -- Name: itemsrc_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemsrc ADD CONSTRAINT itemsrc_pkey PRIMARY KEY (itemsrc_id); -- -- Name: itemsrcp_itemsrcp_itemsrc_id_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemsrcp ADD CONSTRAINT itemsrcp_itemsrcp_itemsrc_id_key UNIQUE (itemsrcp_itemsrc_id, itemsrcp_warehous_id, itemsrcp_dropship, itemsrcp_qtybreak); -- -- Name: itemsrcp_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemsrcp ADD CONSTRAINT itemsrcp_pkey PRIMARY KEY (itemsrcp_id); -- -- Name: itemsub_itemsub_parent_item_id_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemsub ADD CONSTRAINT itemsub_itemsub_parent_item_id_key UNIQUE (itemsub_parent_item_id, itemsub_sub_item_id); -- -- Name: itemsub_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemsub ADD CONSTRAINT itemsub_pkey PRIMARY KEY (itemsub_id); -- -- Name: itemtax_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemtax ADD CONSTRAINT itemtax_pkey PRIMARY KEY (itemtax_id); -- -- Name: itemtrans_itemtrans_source_item_id_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemtrans ADD CONSTRAINT itemtrans_itemtrans_source_item_id_key UNIQUE (itemtrans_source_item_id, itemtrans_target_item_id); -- -- Name: itemtrans_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemtrans ADD CONSTRAINT itemtrans_pkey PRIMARY KEY (itemtrans_id); -- -- Name: itemuom_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemuom ADD CONSTRAINT itemuom_pkey PRIMARY KEY (itemuom_id); -- -- Name: itemuomconv_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY itemuomconv ADD CONSTRAINT itemuomconv_pkey PRIMARY KEY (itemuomconv_id); -- -- Name: jrnluse_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY jrnluse ADD CONSTRAINT jrnluse_pkey PRIMARY KEY (jrnluse_id); -- -- Name: labeldef_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY labeldef ADD CONSTRAINT labeldef_pkey PRIMARY KEY (labeldef_id); -- -- Name: labelform_labelform_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY labelform ADD CONSTRAINT labelform_labelform_name_key UNIQUE (labelform_name); -- -- Name: labelform_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY labelform ADD CONSTRAINT labelform_pkey PRIMARY KEY (labelform_id); -- -- Name: lang_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY lang ADD CONSTRAINT lang_pkey PRIMARY KEY (lang_id); -- -- Name: locale_locale_code_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY locale ADD CONSTRAINT locale_locale_code_key UNIQUE (locale_code); -- -- Name: locale_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY locale ADD CONSTRAINT locale_pkey PRIMARY KEY (locale_id); -- -- Name: location_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY location ADD CONSTRAINT location_pkey PRIMARY KEY (location_id); -- -- Name: locitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY locitem ADD CONSTRAINT locitem_pkey PRIMARY KEY (locitem_id); -- -- Name: metasql_metasql_group_name_grade_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY metasql ADD CONSTRAINT metasql_metasql_group_name_grade_key UNIQUE (metasql_group, metasql_name, metasql_grade); -- -- Name: metasql_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY metasql ADD CONSTRAINT metasql_pkey PRIMARY KEY (metasql_id); -- -- Name: metric_metric_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY metric ADD CONSTRAINT metric_metric_name_key UNIQUE (metric_name); -- -- Name: metric_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY metric ADD CONSTRAINT metric_pkey PRIMARY KEY (metric_id); -- -- Name: metricenc_metricenc_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY metricenc ADD CONSTRAINT metricenc_metricenc_name_key UNIQUE (metricenc_name); -- -- Name: metricenc_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY metricenc ADD CONSTRAINT metricenc_pkey PRIMARY KEY (metricenc_id); -- -- Name: mrghist_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY mrghist ADD CONSTRAINT mrghist_pkey PRIMARY KEY (mrghist_cntct_id, mrghist_table, mrghist_pkey_col, mrghist_pkey_id, mrghist_cntct_col); -- -- Name: mrgundo_mrgundo_schema_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY mrgundo ADD CONSTRAINT mrgundo_mrgundo_schema_key UNIQUE (mrgundo_schema, mrgundo_table, mrgundo_pkey_col, mrgundo_pkey_id, mrgundo_col); -- -- Name: msg_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY msg ADD CONSTRAINT msg_pkey PRIMARY KEY (msg_id); -- -- Name: msguser_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY msguser ADD CONSTRAINT msguser_pkey PRIMARY KEY (msguser_id); -- -- Name: obsolete_tax_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY obsolete_tax ADD CONSTRAINT obsolete_tax_pkey PRIMARY KEY (tax_id); -- -- Name: ophead_ophead_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY ophead ADD CONSTRAINT ophead_ophead_number_key UNIQUE (ophead_number); -- -- Name: ophead_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY ophead ADD CONSTRAINT ophead_pkey PRIMARY KEY (ophead_id); -- -- Name: opsource_opsource_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY opsource ADD CONSTRAINT opsource_opsource_name_key UNIQUE (opsource_name); -- -- Name: opsource_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY opsource ADD CONSTRAINT opsource_pkey PRIMARY KEY (opsource_id); -- -- Name: opstage_opstage_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY opstage ADD CONSTRAINT opstage_opstage_name_key UNIQUE (opstage_name); -- -- Name: opstage_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY opstage ADD CONSTRAINT opstage_pkey PRIMARY KEY (opstage_id); -- -- Name: optype_optype_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY optype ADD CONSTRAINT optype_optype_name_key UNIQUE (optype_name); -- -- Name: optype_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY optype ADD CONSTRAINT optype_pkey PRIMARY KEY (optype_id); -- -- Name: orderseq_orderseq_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY orderseq ADD CONSTRAINT orderseq_orderseq_name_key UNIQUE (orderseq_name); -- -- Name: orderseq_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY orderseq ADD CONSTRAINT orderseq_pkey PRIMARY KEY (orderseq_id); -- -- Name: pack_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY pack ADD CONSTRAINT pack_pkey PRIMARY KEY (pack_id); -- -- Name: payaropen_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY payaropen ADD CONSTRAINT payaropen_pkey PRIMARY KEY (payaropen_ccpay_id, payaropen_aropen_id); -- -- Name: payco_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY payco ADD CONSTRAINT payco_pkey PRIMARY KEY (payco_id); -- -- Name: payco_unique_ccpay_id_cohead_id; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY payco ADD CONSTRAINT payco_unique_ccpay_id_cohead_id UNIQUE (payco_ccpay_id, payco_cohead_id); -- -- Name: period_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY period ADD CONSTRAINT period_pkey PRIMARY KEY (period_id); -- -- Name: pk_prjtype; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY prjtype ADD CONSTRAINT pk_prjtype PRIMARY KEY (prjtype_id); -- -- Name: pkgdep_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgdep ADD CONSTRAINT pkgdep_pkey PRIMARY KEY (pkgdep_id); -- -- Name: pkghead_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkghead ADD CONSTRAINT pkghead_pkey PRIMARY KEY (pkghead_id); -- -- Name: pkgitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgitem ADD CONSTRAINT pkgitem_pkey PRIMARY KEY (pkgitem_id); -- -- Name: pkgitem_pkgitem_pkghead_id_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgitem ADD CONSTRAINT pkgitem_pkgitem_pkghead_id_key UNIQUE (pkgitem_pkghead_id, pkgitem_type, pkgitem_name); -- -- Name: pkgitem_pkgitem_pkghead_id_key1; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgitem ADD CONSTRAINT pkgitem_pkgitem_pkghead_id_key1 UNIQUE (pkgitem_pkghead_id, pkgitem_type, pkgitem_item_id); -- -- Name: plancode_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY plancode ADD CONSTRAINT plancode_pkey PRIMARY KEY (plancode_id); -- -- Name: plancode_plancode_code_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY plancode ADD CONSTRAINT plancode_plancode_code_key UNIQUE (plancode_code); -- -- Name: pohead_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pkey PRIMARY KEY (pohead_id); -- -- Name: pohead_pohead_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_number_key UNIQUE (pohead_number); -- -- Name: poitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY poitem ADD CONSTRAINT poitem_pkey PRIMARY KEY (poitem_id); -- -- Name: poitem_poitem_pohead_id_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY poitem ADD CONSTRAINT poitem_poitem_pohead_id_key UNIQUE (poitem_pohead_id, poitem_linenumber); -- -- Name: poreject_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY poreject ADD CONSTRAINT poreject_pkey PRIMARY KEY (poreject_id); -- -- Name: pr_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY pr ADD CONSTRAINT pr_pkey PRIMARY KEY (pr_id); -- -- Name: prftcntr_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY prftcntr ADD CONSTRAINT prftcntr_pkey PRIMARY KEY (prftcntr_id); -- -- Name: prftcntr_prftcntr_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY prftcntr ADD CONSTRAINT prftcntr_prftcntr_number_key UNIQUE (prftcntr_number); -- -- Name: priv_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY priv ADD CONSTRAINT priv_pkey PRIMARY KEY (priv_id); -- -- Name: prj_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY prj ADD CONSTRAINT prj_pkey PRIMARY KEY (prj_id); -- -- Name: prj_prj_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY prj ADD CONSTRAINT prj_prj_number_key UNIQUE (prj_number); -- -- Name: prjtask_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY prjtask ADD CONSTRAINT prjtask_pkey PRIMARY KEY (prjtask_id); -- -- Name: prjtask_prjtask_prj_id_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY prjtask ADD CONSTRAINT prjtask_prjtask_prj_id_key UNIQUE (prjtask_prj_id, prjtask_number); -- -- Name: prjtaskuser_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY prjtaskuser ADD CONSTRAINT prjtaskuser_pkey PRIMARY KEY (prjtaskuser_id); -- -- Name: prodcat_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY prodcat ADD CONSTRAINT prodcat_pkey PRIMARY KEY (prodcat_id); -- -- Name: prodcat_prodcat_code_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY prodcat ADD CONSTRAINT prodcat_prodcat_code_key UNIQUE (prodcat_code); -- -- Name: prospect_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY prospect ADD CONSTRAINT prospect_pkey PRIMARY KEY (prospect_id); -- -- Name: prospect_prospect_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY prospect ADD CONSTRAINT prospect_prospect_number_key UNIQUE (prospect_number); -- -- Name: qryhead_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY qryhead ADD CONSTRAINT qryhead_pkey PRIMARY KEY (qryhead_id); -- -- Name: qryhead_qryhead_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY qryhead ADD CONSTRAINT qryhead_qryhead_name_key UNIQUE (qryhead_name); -- -- Name: qryitem_qryitem_qryhead_id_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY qryitem ADD CONSTRAINT qryitem_qryitem_qryhead_id_key UNIQUE (qryitem_qryhead_id, qryitem_name); -- -- Name: qryitem_qryitem_qryhead_id_key1; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY qryitem ADD CONSTRAINT qryitem_qryitem_qryhead_id_key1 UNIQUE (qryitem_qryhead_id, qryitem_order); -- -- Name: quhead_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY quhead ADD CONSTRAINT quhead_pkey PRIMARY KEY (quhead_id); -- -- Name: quhead_quhead_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_number_key UNIQUE (quhead_number); -- -- Name: quitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY quitem ADD CONSTRAINT quitem_pkey PRIMARY KEY (quitem_id); -- -- Name: rcalitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY rcalitem ADD CONSTRAINT rcalitem_pkey PRIMARY KEY (rcalitem_id); -- -- Name: recur_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY recur ADD CONSTRAINT recur_pkey PRIMARY KEY (recur_id); -- -- Name: recur_recur_parent_id_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY recur ADD CONSTRAINT recur_recur_parent_id_key UNIQUE (recur_parent_id, recur_parent_type); -- -- Name: recurtype_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY recurtype ADD CONSTRAINT recurtype_pkey PRIMARY KEY (recurtype_id); -- -- Name: recurtype_recurtype_type_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY recurtype ADD CONSTRAINT recurtype_recurtype_type_key UNIQUE (recurtype_type); -- -- Name: recv_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY recv ADD CONSTRAINT recv_pkey PRIMARY KEY (recv_id); -- -- Name: report_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY report ADD CONSTRAINT report_pkey PRIMARY KEY (report_id); -- -- Name: rjctcode_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY rjctcode ADD CONSTRAINT rjctcode_pkey PRIMARY KEY (rjctcode_id); -- -- Name: rjctcode_rjctcode_code_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY rjctcode ADD CONSTRAINT rjctcode_rjctcode_code_key UNIQUE (rjctcode_code); -- -- Name: rsncode_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY rsncode ADD CONSTRAINT rsncode_pkey PRIMARY KEY (rsncode_id); -- -- Name: rsncode_rsncode_code_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY rsncode ADD CONSTRAINT rsncode_rsncode_code_key UNIQUE (rsncode_code); -- -- Name: sale_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY sale ADD CONSTRAINT sale_pkey PRIMARY KEY (sale_id); -- -- Name: sale_sale_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY sale ADD CONSTRAINT sale_sale_name_key UNIQUE (sale_name); -- -- Name: salesaccnt_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY salesaccnt ADD CONSTRAINT salesaccnt_pkey PRIMARY KEY (salesaccnt_id); -- -- Name: salescat_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY salescat ADD CONSTRAINT salescat_pkey PRIMARY KEY (salescat_id); -- -- Name: salescat_salescat_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY salescat ADD CONSTRAINT salescat_salescat_name_key UNIQUE (salescat_name); -- -- Name: salesrep_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY salesrep ADD CONSTRAINT salesrep_pkey PRIMARY KEY (salesrep_id); -- -- Name: salesrep_salesrep_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY salesrep ADD CONSTRAINT salesrep_salesrep_number_key UNIQUE (salesrep_number); -- -- Name: saletype_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY saletype ADD CONSTRAINT saletype_pkey PRIMARY KEY (saletype_id); -- -- Name: schemaord_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY schemaord ADD CONSTRAINT schemaord_pkey PRIMARY KEY (schemaord_id); -- -- Name: schemaord_schemaord_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY schemaord ADD CONSTRAINT schemaord_schemaord_name_key UNIQUE (schemaord_name); -- -- Name: schemaord_schemaord_order_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY schemaord ADD CONSTRAINT schemaord_schemaord_order_key UNIQUE (schemaord_order); -- -- Name: script_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY script ADD CONSTRAINT script_pkey PRIMARY KEY (script_id); -- -- Name: shift_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY shift ADD CONSTRAINT shift_pkey PRIMARY KEY (shift_id); -- -- Name: shipchrg_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY shipchrg ADD CONSTRAINT shipchrg_pkey PRIMARY KEY (shipchrg_id); -- -- Name: shipdata_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY shipdata ADD CONSTRAINT shipdata_pkey PRIMARY KEY (shipdata_cohead_number, shipdata_cosmisc_tracknum, shipdata_cosmisc_packnum_tracknum, shipdata_void_ind); -- -- Name: shipdatasum_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY shipdatasum ADD CONSTRAINT shipdatasum_pkey PRIMARY KEY (shipdatasum_cohead_number, shipdatasum_cosmisc_tracknum, shipdatasum_cosmisc_packnum_tracknum); -- -- Name: shipform_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY shipform ADD CONSTRAINT shipform_pkey PRIMARY KEY (shipform_id); -- -- Name: shipform_shipform_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY shipform ADD CONSTRAINT shipform_shipform_name_key UNIQUE (shipform_name); -- -- Name: shiphead_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY shiphead ADD CONSTRAINT shiphead_pkey PRIMARY KEY (shiphead_id); -- -- Name: shiphead_shiphead_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY shiphead ADD CONSTRAINT shiphead_shiphead_number_key UNIQUE (shiphead_number); -- -- Name: shipitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY shipitem ADD CONSTRAINT shipitem_pkey PRIMARY KEY (shipitem_id); -- -- Name: shipto_num_cust_unique; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shipto_num_cust_unique UNIQUE (shipto_cust_id, shipto_num); -- -- Name: shipto_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shipto_pkey PRIMARY KEY (shipto_id); -- -- Name: shipvia_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY shipvia ADD CONSTRAINT shipvia_pkey PRIMARY KEY (shipvia_id); -- -- Name: shipvia_shipvia_code_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY shipvia ADD CONSTRAINT shipvia_shipvia_code_key UNIQUE (shipvia_code); -- -- Name: shipzone_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY shipzone ADD CONSTRAINT shipzone_pkey PRIMARY KEY (shipzone_id); -- -- Name: shipzone_shipzone_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY shipzone ADD CONSTRAINT shipzone_shipzone_name_key UNIQUE (shipzone_name); -- -- Name: sitetype_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY sitetype ADD CONSTRAINT sitetype_pkey PRIMARY KEY (sitetype_id); -- -- Name: sitetype_sitetype_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY sitetype ADD CONSTRAINT sitetype_sitetype_name_key UNIQUE (sitetype_name); -- -- Name: sltrans_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY sltrans ADD CONSTRAINT sltrans_pkey PRIMARY KEY (sltrans_id); -- -- Name: source_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY source ADD CONSTRAINT source_pkey PRIMARY KEY (source_id); -- -- Name: source_source_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY source ADD CONSTRAINT source_source_name_key UNIQUE (source_name); -- -- Name: state_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY state ADD CONSTRAINT state_pkey PRIMARY KEY (state_id); -- -- Name: state_state_country_id_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY state ADD CONSTRAINT state_state_country_id_key UNIQUE (state_country_id, state_name); -- -- Name: status_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY status ADD CONSTRAINT status_pkey PRIMARY KEY (status_id); -- -- Name: status_status_type_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY status ADD CONSTRAINT status_status_type_key UNIQUE (status_type, status_code); -- -- Name: stdjrnl_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY stdjrnl ADD CONSTRAINT stdjrnl_pkey PRIMARY KEY (stdjrnl_id); -- -- Name: stdjrnl_stdjrnl_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY stdjrnl ADD CONSTRAINT stdjrnl_stdjrnl_name_key UNIQUE (stdjrnl_name); -- -- Name: stdjrnlgrp_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY stdjrnlgrp ADD CONSTRAINT stdjrnlgrp_pkey PRIMARY KEY (stdjrnlgrp_id); -- -- Name: stdjrnlgrp_stdjrnlgrp_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY stdjrnlgrp ADD CONSTRAINT stdjrnlgrp_stdjrnlgrp_name_key UNIQUE (stdjrnlgrp_name); -- -- Name: stdjrnlgrpitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY stdjrnlgrpitem ADD CONSTRAINT stdjrnlgrpitem_pkey PRIMARY KEY (stdjrnlgrpitem_id); -- -- Name: stdjrnlitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY stdjrnlitem ADD CONSTRAINT stdjrnlitem_pkey PRIMARY KEY (stdjrnlitem_id); -- -- Name: subaccnt_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY subaccnt ADD CONSTRAINT subaccnt_pkey PRIMARY KEY (subaccnt_id); -- -- Name: subaccnt_subaccnt_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY subaccnt ADD CONSTRAINT subaccnt_subaccnt_number_key UNIQUE (subaccnt_number); -- -- Name: subaccnttype_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY subaccnttype ADD CONSTRAINT subaccnttype_pkey PRIMARY KEY (subaccnttype_id); -- -- Name: tax_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY tax ADD CONSTRAINT tax_pkey PRIMARY KEY (tax_id); -- -- Name: taxass_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY taxass ADD CONSTRAINT taxass_pkey PRIMARY KEY (taxass_id); -- -- Name: taxass_taxass_taxzone_id_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY taxass ADD CONSTRAINT taxass_taxass_taxzone_id_key UNIQUE (taxass_taxzone_id, taxass_taxtype_id, taxass_tax_id); -- -- Name: taxauth_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY taxauth ADD CONSTRAINT taxauth_pkey PRIMARY KEY (taxauth_id); -- -- Name: taxauth_taxauth_code_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY taxauth ADD CONSTRAINT taxauth_taxauth_code_key UNIQUE (taxauth_code); -- -- Name: taxclass_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY taxclass ADD CONSTRAINT taxclass_pkey PRIMARY KEY (taxclass_id); -- -- Name: taxclass_taxclass_code_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY taxclass ADD CONSTRAINT taxclass_taxclass_code_key UNIQUE (taxclass_code); -- -- Name: taxhist_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY taxhist ADD CONSTRAINT taxhist_pkey PRIMARY KEY (taxhist_id); -- -- Name: taxpay_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY taxpay ADD CONSTRAINT taxpay_pkey PRIMARY KEY (taxpay_id); -- -- Name: taxrate_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY taxrate ADD CONSTRAINT taxrate_pkey PRIMARY KEY (taxrate_id); -- -- Name: taxreg_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY taxreg ADD CONSTRAINT taxreg_pkey PRIMARY KEY (taxreg_id); -- -- Name: taxtype_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY taxtype ADD CONSTRAINT taxtype_pkey PRIMARY KEY (taxtype_id); -- -- Name: taxtype_taxtype_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY taxtype ADD CONSTRAINT taxtype_taxtype_name_key UNIQUE (taxtype_name); -- -- Name: taxzone_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY taxzone ADD CONSTRAINT taxzone_pkey PRIMARY KEY (taxzone_id); -- -- Name: taxzone_taxzone_code_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY taxzone ADD CONSTRAINT taxzone_taxzone_code_key UNIQUE (taxzone_code); -- -- Name: terms_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY terms ADD CONSTRAINT terms_pkey PRIMARY KEY (terms_id); -- -- Name: terms_terms_code_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY terms ADD CONSTRAINT terms_terms_code_key UNIQUE (terms_code); -- -- Name: todoitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY todoitem ADD CONSTRAINT todoitem_pkey PRIMARY KEY (todoitem_id); -- -- Name: trialbal_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY trialbal ADD CONSTRAINT trialbal_pkey PRIMARY KEY (trialbal_id); -- -- Name: uiform_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY uiform ADD CONSTRAINT uiform_pkey PRIMARY KEY (uiform_id); -- -- Name: unq_prjtype_code; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY prjtype ADD CONSTRAINT unq_prjtype_code UNIQUE (prjtype_code); -- -- Name: uom_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY uom ADD CONSTRAINT uom_pkey PRIMARY KEY (uom_id); -- -- Name: uom_uom_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY uom ADD CONSTRAINT uom_uom_name_key UNIQUE (uom_name); -- -- Name: uomconv_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY uomconv ADD CONSTRAINT uomconv_pkey PRIMARY KEY (uomconv_id); -- -- Name: uomtype_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY uomtype ADD CONSTRAINT uomtype_pkey PRIMARY KEY (uomtype_id); -- -- Name: uomtype_uomtype_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY uomtype ADD CONSTRAINT uomtype_uomtype_name_key UNIQUE (uomtype_name); -- -- Name: urlinfo_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY urlinfo ADD CONSTRAINT urlinfo_pkey PRIMARY KEY (url_id); -- -- Name: usr_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY usr_bak ADD CONSTRAINT usr_pkey PRIMARY KEY (usr_id); -- -- Name: usr_usr_username_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY usr_bak ADD CONSTRAINT usr_usr_username_key UNIQUE (usr_username); -- -- Name: usrgrp_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY usrgrp ADD CONSTRAINT usrgrp_pkey PRIMARY KEY (usrgrp_id); -- -- Name: usrpref_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY usrpref ADD CONSTRAINT usrpref_pkey PRIMARY KEY (usrpref_id); -- -- Name: usrpriv_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY usrpriv ADD CONSTRAINT usrpriv_pkey PRIMARY KEY (usrpriv_id); -- -- Name: vend_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY vendinfo ADD CONSTRAINT vend_pkey PRIMARY KEY (vend_id); -- -- Name: vendaddr_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY vendaddrinfo ADD CONSTRAINT vendaddr_pkey PRIMARY KEY (vendaddr_id); -- -- Name: vendinfo_vend_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY vendinfo ADD CONSTRAINT vendinfo_vend_number_key UNIQUE (vend_number); -- -- Name: vendtype_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY vendtype ADD CONSTRAINT vendtype_pkey PRIMARY KEY (vendtype_id); -- -- Name: vendtype_vendtype_code_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY vendtype ADD CONSTRAINT vendtype_vendtype_code_key UNIQUE (vendtype_code); -- -- Name: vodist_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY vodist ADD CONSTRAINT vodist_pkey PRIMARY KEY (vodist_id); -- -- Name: vohead_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY vohead ADD CONSTRAINT vohead_pkey PRIMARY KEY (vohead_id); -- -- Name: vohead_vohead_number_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY vohead ADD CONSTRAINT vohead_vohead_number_key UNIQUE (vohead_number); -- -- Name: voheadtax_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY voheadtax ADD CONSTRAINT voheadtax_pkey PRIMARY KEY (taxhist_id); -- -- Name: voitem_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY voitem ADD CONSTRAINT voitem_pkey PRIMARY KEY (voitem_id); -- -- Name: voitemtax_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY voitemtax ADD CONSTRAINT voitemtax_pkey PRIMARY KEY (taxhist_id); -- -- Name: warehous_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY whsinfo ADD CONSTRAINT warehous_pkey PRIMARY KEY (warehous_id); -- -- Name: whsezone_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY whsezone ADD CONSTRAINT whsezone_pkey PRIMARY KEY (whsezone_id); -- -- Name: whsinfo_warehous_code_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY whsinfo ADD CONSTRAINT whsinfo_warehous_code_key UNIQUE (warehous_code); -- -- Name: wo_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY wo ADD CONSTRAINT wo_pkey PRIMARY KEY (wo_id); -- -- Name: womatl_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY womatl ADD CONSTRAINT womatl_pkey PRIMARY KEY (womatl_id); -- -- Name: womatlpost_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY womatlpost ADD CONSTRAINT womatlpost_pkey PRIMARY KEY (womatlpost_id); -- -- Name: womatlvar_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY womatlvar ADD CONSTRAINT womatlvar_pkey PRIMARY KEY (womatlvar_id); -- -- Name: xsltmap_name_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY xsltmap ADD CONSTRAINT xsltmap_name_key UNIQUE (xsltmap_name); -- -- Name: xsltmap_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY xsltmap ADD CONSTRAINT xsltmap_pkey PRIMARY KEY (xsltmap_id); -- -- Name: yearperiod_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: -- ALTER TABLE ONLY yearperiod ADD CONSTRAINT yearperiod_pkey PRIMARY KEY (yearperiod_id); SET search_path = te, pg_catalog; -- -- Name: pkgcmd_pkey; Type: CONSTRAINT; Schema: te; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgcmd ADD CONSTRAINT pkgcmd_pkey PRIMARY KEY (cmd_id); -- -- Name: pkgcmdarg_pkey; Type: CONSTRAINT; Schema: te; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgcmdarg ADD CONSTRAINT pkgcmdarg_pkey PRIMARY KEY (cmdarg_id); -- -- Name: pkgimage_pkey; Type: CONSTRAINT; Schema: te; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgimage ADD CONSTRAINT pkgimage_pkey PRIMARY KEY (image_id); -- -- Name: pkgmetasql_pkey; Type: CONSTRAINT; Schema: te; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgmetasql ADD CONSTRAINT pkgmetasql_pkey PRIMARY KEY (metasql_id); -- -- Name: pkgpriv_pkey; Type: CONSTRAINT; Schema: te; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgpriv ADD CONSTRAINT pkgpriv_pkey PRIMARY KEY (priv_id); -- -- Name: pkgreport_pkey; Type: CONSTRAINT; Schema: te; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgreport ADD CONSTRAINT pkgreport_pkey PRIMARY KEY (report_id); -- -- Name: pkgscript_pkey; Type: CONSTRAINT; Schema: te; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgscript ADD CONSTRAINT pkgscript_pkey PRIMARY KEY (script_id); -- -- Name: pkguiform_pkey; Type: CONSTRAINT; Schema: te; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkguiform ADD CONSTRAINT pkguiform_pkey PRIMARY KEY (uiform_id); -- -- Name: tecustrate_pkey; Type: CONSTRAINT; Schema: te; Owner: admin; Tablespace: -- ALTER TABLE ONLY tecustrate ADD CONSTRAINT tecustrate_pkey PRIMARY KEY (tecustrate_cust_id); -- -- Name: teexp_pkey; Type: CONSTRAINT; Schema: te; Owner: admin; Tablespace: -- ALTER TABLE ONLY teexp ADD CONSTRAINT teexp_pkey PRIMARY KEY (teexp_id); -- -- Name: tehead_pkey; Type: CONSTRAINT; Schema: te; Owner: admin; Tablespace: -- ALTER TABLE ONLY tehead ADD CONSTRAINT tehead_pkey PRIMARY KEY (tehead_id); -- -- Name: teitem_pkey; Type: CONSTRAINT; Schema: te; Owner: admin; Tablespace: -- ALTER TABLE ONLY teitem ADD CONSTRAINT teitem_pkey PRIMARY KEY (teitem_id); -- -- Name: teprj_pkey; Type: CONSTRAINT; Schema: te; Owner: admin; Tablespace: -- ALTER TABLE ONLY teprj ADD CONSTRAINT teprj_pkey PRIMARY KEY (teprj_id); -- -- Name: teprj_teprj_prj_id; Type: CONSTRAINT; Schema: te; Owner: admin; Tablespace: -- ALTER TABLE ONLY teprj ADD CONSTRAINT teprj_teprj_prj_id UNIQUE (teprj_prj_id); -- -- Name: teprjtask_pkey; Type: CONSTRAINT; Schema: te; Owner: admin; Tablespace: -- ALTER TABLE ONLY teprjtask ADD CONSTRAINT teprjtask_pkey PRIMARY KEY (teprjtask_id); -- -- Name: teprjtask_teprjtask_prjtask_id_key; Type: CONSTRAINT; Schema: te; Owner: admin; Tablespace: -- ALTER TABLE ONLY teprjtask ADD CONSTRAINT teprjtask_teprjtask_prjtask_id_key UNIQUE (teprjtask_prjtask_id); SET search_path = xt, pg_catalog; -- -- Name: js_js_namespace_js_type_js_context; Type: CONSTRAINT; Schema: xt; Owner: admin; Tablespace: -- ALTER TABLE ONLY js ADD CONSTRAINT js_js_namespace_js_type_js_context UNIQUE (js_namespace, js_type, js_context); -- -- Name: js_pkey; Type: CONSTRAINT; Schema: xt; Owner: admin; Tablespace: -- ALTER TABLE ONLY js ADD CONSTRAINT js_pkey PRIMARY KEY (js_id); SET search_path = xtdesktop, pg_catalog; -- -- Name: pkgcmd_pkey; Type: CONSTRAINT; Schema: xtdesktop; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgcmd ADD CONSTRAINT pkgcmd_pkey PRIMARY KEY (cmd_id); -- -- Name: pkgcmdarg_pkey; Type: CONSTRAINT; Schema: xtdesktop; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgcmdarg ADD CONSTRAINT pkgcmdarg_pkey PRIMARY KEY (cmdarg_id); -- -- Name: pkgimage_pkey; Type: CONSTRAINT; Schema: xtdesktop; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgimage ADD CONSTRAINT pkgimage_pkey PRIMARY KEY (image_id); -- -- Name: pkgmetasql_pkey; Type: CONSTRAINT; Schema: xtdesktop; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgmetasql ADD CONSTRAINT pkgmetasql_pkey PRIMARY KEY (metasql_id); -- -- Name: pkgpriv_pkey; Type: CONSTRAINT; Schema: xtdesktop; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgpriv ADD CONSTRAINT pkgpriv_pkey PRIMARY KEY (priv_id); -- -- Name: pkgreport_pkey; Type: CONSTRAINT; Schema: xtdesktop; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgreport ADD CONSTRAINT pkgreport_pkey PRIMARY KEY (report_id); -- -- Name: pkgscript_pkey; Type: CONSTRAINT; Schema: xtdesktop; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkgscript ADD CONSTRAINT pkgscript_pkey PRIMARY KEY (script_id); -- -- Name: pkguiform_pkey; Type: CONSTRAINT; Schema: xtdesktop; Owner: admin; Tablespace: -- ALTER TABLE ONLY pkguiform ADD CONSTRAINT pkguiform_pkey PRIMARY KEY (uiform_id); SET search_path = public, pg_catalog; -- -- Name: accnt_unique_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE UNIQUE INDEX accnt_unique_idx ON accnt USING btree (accnt_number, accnt_profit, accnt_sub, accnt_company); -- -- Name: apopen_apopen_open_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX apopen_apopen_open_idx ON apopen USING btree (apopen_open); -- -- Name: apopen_apopen_vend_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX apopen_apopen_vend_id_idx ON apopen USING btree (apopen_vend_id); -- -- Name: apopentax_taxhist_parent_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX apopentax_taxhist_parent_id_idx ON apopentax USING btree (taxhist_parent_id); -- -- Name: apopentax_taxhist_parent_type_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX apopentax_taxhist_parent_type_idx ON apopentax USING btree (taxhist_parent_id, taxhist_taxtype_id); -- -- Name: apopentax_taxhist_taxtype_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX apopentax_taxhist_taxtype_id_idx ON apopentax USING btree (taxhist_taxtype_id); -- -- Name: apselect_apselect_apopen_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX apselect_apselect_apopen_id_idx ON apselect USING btree (apselect_apopen_id); -- -- Name: arapply_arapply_target_docnumber_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX arapply_arapply_target_docnumber_idx ON arapply USING btree (arapply_target_docnumber); -- -- Name: aropen_aropen_cust_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX aropen_aropen_cust_id_idx ON aropen USING btree (aropen_cust_id); -- -- Name: aropen_aropen_docnumber_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX aropen_aropen_docnumber_idx ON aropen USING btree (aropen_docnumber); -- -- Name: aropen_aropen_doctype_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX aropen_aropen_doctype_idx ON aropen USING btree (aropen_doctype); -- -- Name: aropen_aropen_open_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX aropen_aropen_open_idx ON aropen USING btree (aropen_open); -- -- Name: aropen_posted_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX aropen_posted_idx ON aropen USING btree (aropen_posted); -- -- Name: aropenalloc_aropen_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX aropenalloc_aropen_id_idx ON aropenalloc USING btree (aropenalloc_aropen_id); -- -- Name: aropenalloc_doc_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX aropenalloc_doc_id_idx ON aropenalloc USING btree (aropenalloc_doc_id); -- -- Name: aropentax_taxhist_parent_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX aropentax_taxhist_parent_id_idx ON aropentax USING btree (taxhist_parent_id); -- -- Name: aropentax_taxhist_parent_type_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX aropentax_taxhist_parent_type_idx ON aropentax USING btree (taxhist_parent_id, taxhist_taxtype_id); -- -- Name: aropentax_taxhist_taxtype_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX aropentax_taxhist_taxtype_id_idx ON aropentax USING btree (taxhist_taxtype_id); -- -- Name: asohisttax_taxhist_parent_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX asohisttax_taxhist_parent_id_idx ON asohisttax USING btree (taxhist_parent_id); -- -- Name: asohisttax_taxhist_parent_type_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX asohisttax_taxhist_parent_type_idx ON asohisttax USING btree (taxhist_parent_id, taxhist_taxtype_id); -- -- Name: asohisttax_taxhist_taxtype_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX asohisttax_taxhist_taxtype_id_idx ON asohisttax USING btree (taxhist_taxtype_id); -- -- Name: bomitem_bomitem_item_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX bomitem_bomitem_item_id_idx ON bomitem USING btree (bomitem_item_id); -- -- Name: bomitem_effective_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX bomitem_effective_key ON bomitem USING btree (bomitem_effective); -- -- Name: bomitem_expires_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX bomitem_expires_key ON bomitem USING btree (bomitem_expires); -- -- Name: bomitem_parent_item_id; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX bomitem_parent_item_id ON bomitem USING btree (bomitem_parent_item_id); -- -- Name: bomitemcost_bomitem_id_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX bomitemcost_bomitem_id_key ON bomitemcost USING btree (bomitemcost_bomitem_id); -- -- Name: bomitemcost_master_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE UNIQUE INDEX bomitemcost_master_idx ON bomitemcost USING btree (bomitemcost_bomitem_id, bomitemcost_costelem_id, bomitemcost_lowlevel); -- -- Name: cashrcptitem_aropen_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cashrcptitem_aropen_idx ON cashrcptitem USING btree (cashrcptitem_aropen_id); -- -- Name: cashrcptitem_cashrcpt_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cashrcptitem_cashrcpt_idx ON cashrcptitem USING btree (cashrcptitem_cashrcpt_id); -- -- Name: ccard_cust_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX ccard_cust_id_idx ON ccard USING btree (ccard_cust_id); -- -- Name: ccardaud_ccard_cust_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX ccardaud_ccard_cust_id_idx ON ccardaud USING btree (ccardaud_ccard_cust_id_new); -- -- Name: ccardaud_ccard_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX ccardaud_ccard_id_idx ON ccardaud USING btree (ccardaud_ccard_id); -- -- Name: ccpay_ccard_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX ccpay_ccard_id_idx ON ccpay USING btree (ccpay_ccard_id); -- -- Name: ccpay_cust_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX ccpay_cust_id_idx ON ccpay USING btree (ccpay_cust_id); -- -- Name: ccpay_order_number_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX ccpay_order_number_idx ON ccpay USING btree (ccpay_order_number); -- -- Name: charass_char_id_target_type_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX charass_char_id_target_type_idx ON charass USING btree (charass_char_id, charass_target_type); -- -- Name: charass_target_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX charass_target_idx ON charass USING btree (charass_target_type, charass_target_id); -- -- Name: checkhead_posted_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX checkhead_posted_idx ON checkhead USING btree (checkhead_posted); -- -- Name: checkhead_replaced_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX checkhead_replaced_idx ON checkhead USING btree (checkhead_replaced); -- -- Name: checkitem_apopenitem_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX checkitem_apopenitem_id_idx ON checkitem USING btree (checkitem_apopen_id); -- -- Name: cmhead_invcnumber_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cmhead_invcnumber_idx ON cmhead USING btree (cmhead_invcnumber); -- -- Name: cmheadtax_taxhist_parent_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cmheadtax_taxhist_parent_id_idx ON cmheadtax USING btree (taxhist_parent_id); -- -- Name: cmheadtax_taxhist_parent_type_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cmheadtax_taxhist_parent_type_idx ON cmheadtax USING btree (taxhist_parent_id, taxhist_taxtype_id); -- -- Name: cmheadtax_taxhist_taxtype_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cmheadtax_taxhist_taxtype_id_idx ON cmheadtax USING btree (taxhist_taxtype_id); -- -- Name: cmitemtax_taxhist_parent_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cmitemtax_taxhist_parent_id_idx ON cmitemtax USING btree (taxhist_parent_id); -- -- Name: cmitemtax_taxhist_parent_type_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cmitemtax_taxhist_parent_type_idx ON cmitemtax USING btree (taxhist_parent_id, taxhist_taxtype_id); -- -- Name: cmitemtax_taxhist_taxtype_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cmitemtax_taxhist_taxtype_id_idx ON cmitemtax USING btree (taxhist_taxtype_id); -- -- Name: cntct_email_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cntct_email_idx ON cntct USING btree (cntct_email); -- -- Name: cntct_name_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cntct_name_idx ON cntct USING btree (cntct_name); -- -- Name: cobill_cobmisc_id; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cobill_cobmisc_id ON cobill USING btree (cobill_cobmisc_id); -- -- Name: cobill_coitem_id; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cobill_coitem_id ON cobill USING btree (cobill_coitem_id); -- -- Name: cobilltax_taxhist_parent_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cobilltax_taxhist_parent_id_idx ON cobilltax USING btree (taxhist_parent_id); -- -- Name: cobilltax_taxhist_parent_type_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cobilltax_taxhist_parent_type_idx ON cobilltax USING btree (taxhist_parent_id, taxhist_taxtype_id); -- -- Name: cobilltax_taxhist_taxtype_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cobilltax_taxhist_taxtype_id_idx ON cobilltax USING btree (taxhist_taxtype_id); -- -- Name: cobmisc_cohead_id; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cobmisc_cohead_id ON cobmisc USING btree (cobmisc_cohead_id); -- -- Name: cobmisc_posted; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cobmisc_posted ON cobmisc USING btree (cobmisc_posted); -- -- Name: cobmisctax_taxhist_parent_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cobmisctax_taxhist_parent_id_idx ON cobmisctax USING btree (taxhist_parent_id); -- -- Name: cobmisctax_taxhist_parent_type_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cobmisctax_taxhist_parent_type_idx ON cobmisctax USING btree (taxhist_parent_id, taxhist_taxtype_id); -- -- Name: cobmisctax_taxhist_taxtype_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cobmisctax_taxhist_taxtype_id_idx ON cobmisctax USING btree (taxhist_taxtype_id); -- -- Name: cohead_cohead_status_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cohead_cohead_status_idx ON cohead USING btree (cohead_status); -- -- Name: cohead_cust_id_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cohead_cust_id_key ON cohead USING btree (cohead_cust_id); -- -- Name: cohead_custponumber_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cohead_custponumber_idx ON cohead USING btree (cohead_custponumber); -- -- Name: cohead_number_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE UNIQUE INDEX cohead_number_idx ON cohead USING btree (cohead_number); -- -- Name: cohead_shipto_id; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cohead_shipto_id ON cohead USING btree (cohead_shipto_id); -- -- Name: cohist_cust_id; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cohist_cust_id ON cohist USING btree (cohist_cust_id); -- -- Name: cohist_invcnumber; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cohist_invcnumber ON cohist USING btree (cohist_invcnumber); -- -- Name: cohist_itemsite_id; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cohist_itemsite_id ON cohist USING btree (cohist_itemsite_id); -- -- Name: cohist_shipdate; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cohist_shipdate ON cohist USING btree (cohist_shipdate); -- -- Name: cohist_shipto_id; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cohist_shipto_id ON cohist USING btree (cohist_shipto_id); -- -- Name: cohisttax_taxhist_parent_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cohisttax_taxhist_parent_id_idx ON cohisttax USING btree (taxhist_parent_id); -- -- Name: cohisttax_taxhist_parent_type_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cohisttax_taxhist_parent_type_idx ON cohisttax USING btree (taxhist_parent_id, taxhist_taxtype_id); -- -- Name: cohisttax_taxhist_taxtype_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX cohisttax_taxhist_taxtype_id_idx ON cohisttax USING btree (taxhist_taxtype_id); -- -- Name: coitem_cohead_id_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX coitem_cohead_id_key ON coitem USING btree (coitem_cohead_id); -- -- Name: coitem_coitem_cohead_id_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE UNIQUE INDEX coitem_coitem_cohead_id_key ON coitem USING btree (coitem_cohead_id, coitem_linenumber, coitem_subnumber); -- -- Name: coitem_itemsite_id; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX coitem_itemsite_id ON coitem USING btree (coitem_itemsite_id); -- -- Name: coitem_linenumber_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX coitem_linenumber_key ON coitem USING btree (coitem_linenumber); -- -- Name: coitem_status_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX coitem_status_key ON coitem USING btree (coitem_status); -- -- Name: comment_comment_source_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX comment_comment_source_idx ON comment USING btree (comment_source, comment_source_id); -- -- Name: contrct_master_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE UNIQUE INDEX contrct_master_idx ON contrct USING btree (contrct_number, contrct_vend_id); -- -- Name: cust_number_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE UNIQUE INDEX cust_number_idx ON custinfo USING btree (cust_number); -- -- Name: docass_source_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX docass_source_id_idx ON docass USING btree (docass_source_id); -- -- Name: docass_source_type_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX docass_source_type_idx ON docass USING btree (docass_source_type); -- -- Name: docass_target_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX docass_target_id_idx ON docass USING btree (docass_target_id); -- -- Name: docass_target_type_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX docass_target_type_idx ON docass USING btree (docass_target_type); -- -- Name: evntlog_dispatched_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX evntlog_dispatched_idx ON evntlog USING btree (evntlog_dispatched); -- -- Name: evntlog_evntlog_username_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX evntlog_evntlog_username_idx ON evntlog USING btree (evntlog_username); -- -- Name: evntnot_evnttype_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX evntnot_evnttype_id_idx ON evntnot USING btree (evntnot_evnttype_id); -- -- Name: evntnot_warehous_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX evntnot_warehous_id_idx ON evntnot USING btree (evntnot_warehous_id); -- -- Name: filter_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX filter_idx ON filter USING btree (filter_screen, filter_username, filter_name); -- -- Name: gltrans_gltrans_accnt_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX gltrans_gltrans_accnt_id_idx ON gltrans USING btree (gltrans_accnt_id); -- -- Name: gltrans_gltrans_date_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX gltrans_gltrans_date_idx ON gltrans USING btree (gltrans_date); -- -- Name: gltrans_gltrans_journalnumber_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX gltrans_gltrans_journalnumber_idx ON gltrans USING btree (gltrans_journalnumber); -- -- Name: gltrans_sequence_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX gltrans_sequence_idx ON gltrans USING btree (gltrans_sequence); -- -- Name: invchead_invchead_cust_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX invchead_invchead_cust_id_idx ON invchead USING btree (invchead_cust_id); -- -- Name: invchead_invchead_ordernumber_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX invchead_invchead_ordernumber_idx ON invchead USING btree (invchead_ordernumber); -- -- Name: invcheadtax_taxhist_parent_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX invcheadtax_taxhist_parent_id_idx ON invcheadtax USING btree (taxhist_parent_id); -- -- Name: invcheadtax_taxhist_parent_type_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX invcheadtax_taxhist_parent_type_idx ON invcheadtax USING btree (taxhist_parent_id, taxhist_taxtype_id); -- -- Name: invcheadtax_taxhist_taxtype_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX invcheadtax_taxhist_taxtype_id_idx ON invcheadtax USING btree (taxhist_taxtype_id); -- -- Name: invcitem_invcitem_invchead_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX invcitem_invcitem_invchead_id_idx ON invcitem USING btree (invcitem_invchead_id); -- -- Name: invcitem_invcitem_itemsite_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX invcitem_invcitem_itemsite_id_idx ON invcitem USING btree (invcitem_item_id, invcitem_warehous_id); -- -- Name: invcitemtax_taxhist_parent_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX invcitemtax_taxhist_parent_id_idx ON invcitemtax USING btree (taxhist_parent_id); -- -- Name: invcitemtax_taxhist_parent_type_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX invcitemtax_taxhist_parent_type_idx ON invcitemtax USING btree (taxhist_parent_id, taxhist_taxtype_id); -- -- Name: invcitemtax_taxhist_taxtype_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX invcitemtax_taxhist_taxtype_id_idx ON invcitemtax USING btree (taxhist_taxtype_id); -- -- Name: invdetail_invdetail_invcitem_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX invdetail_invdetail_invcitem_id_idx ON invdetail USING btree (invdetail_invcitem_id); -- -- Name: invdetail_invdetail_invhist_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX invdetail_invdetail_invhist_id_idx ON invdetail USING btree (invdetail_invhist_id); -- -- Name: invhist_hasdetail; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX invhist_hasdetail ON invhist USING btree (invhist_hasdetail); -- -- Name: invhist_invhist_ordnumber_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX invhist_invhist_ordnumber_idx ON invhist USING btree (invhist_ordnumber); -- -- Name: invhist_itemsite_id; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX invhist_itemsite_id ON invhist USING btree (invhist_itemsite_id); -- -- Name: invhist_series; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX invhist_series ON invhist USING btree (invhist_series); -- -- Name: invhist_transdate; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX invhist_transdate ON invhist USING btree (invhist_transdate); -- -- Name: invhist_transtype; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX invhist_transtype ON invhist USING btree (invhist_transtype); -- -- Name: ipsitem_ipshead_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX ipsitem_ipshead_id_idx ON ipsiteminfo USING btree (ipsitem_ipshead_id); -- -- Name: item_classcode_id; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX item_classcode_id ON item USING btree (item_classcode_id); -- -- Name: item_number_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE UNIQUE INDEX item_number_idx ON item USING btree (item_number); -- -- Name: item_prodcat_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX item_prodcat_id_idx ON item USING btree (item_prodcat_id); -- -- Name: item_upccode_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX item_upccode_idx ON item USING btree (item_upccode); -- -- Name: itemcost_item_id_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX itemcost_item_id_key ON itemcost USING btree (itemcost_item_id); -- -- Name: itemcost_master_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE UNIQUE INDEX itemcost_master_idx ON itemcost USING btree (itemcost_item_id, itemcost_costelem_id, itemcost_lowlevel); -- -- Name: itemloc_itemsite_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX itemloc_itemsite_idx ON itemloc USING btree (itemloc_itemsite_id); -- -- Name: itemloc_location_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX itemloc_location_idx ON itemloc USING btree (itemloc_location_id); -- -- Name: itemsite_active_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX itemsite_active_key ON itemsite USING btree (itemsite_active); -- -- Name: itemsite_item_id_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX itemsite_item_id_key ON itemsite USING btree (itemsite_item_id); -- -- Name: itemsite_item_warehous_id_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE UNIQUE INDEX itemsite_item_warehous_id_key ON itemsite USING btree (itemsite_item_id, itemsite_warehous_id); -- -- Name: itemsite_plancode_id_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX itemsite_plancode_id_key ON itemsite USING btree (itemsite_plancode_id); -- -- Name: itemsite_warehous_id_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX itemsite_warehous_id_key ON itemsite USING btree (itemsite_warehous_id); -- -- Name: itemsrc_vend_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX itemsrc_vend_id_idx ON itemsrc USING btree (itemsrc_vend_id); -- -- Name: itemsrcp_itemsrc_id_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX itemsrcp_itemsrc_id_key ON itemsrcp USING btree (itemsrcp_itemsrc_id); -- -- Name: itemsub_parent_item_id_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX itemsub_parent_item_id_key ON itemsub USING btree (itemsub_parent_item_id); -- -- Name: itemsub_sub_item_id_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX itemsub_sub_item_id_key ON itemsub USING btree (itemsub_sub_item_id); -- -- Name: location_location_formatname_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX location_location_formatname_idx ON location USING btree (location_formatname); -- -- Name: location_warehous_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX location_warehous_idx ON location USING btree (location_warehous_id); -- -- Name: payaropen_aropen_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX payaropen_aropen_id_idx ON payaropen USING btree (payaropen_aropen_id); -- -- Name: payaropen_ccpay_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX payaropen_ccpay_id_idx ON payaropen USING btree (payaropen_ccpay_id); -- -- Name: payco_ccpay_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX payco_ccpay_id_idx ON payco USING btree (payco_ccpay_id); -- -- Name: payco_cohead_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX payco_cohead_id_idx ON payco USING btree (payco_cohead_id); -- -- Name: pohead_pohead_status_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX pohead_pohead_status_idx ON pohead USING btree (pohead_status); -- -- Name: poitem_itemsite_id_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX poitem_itemsite_id_key ON poitem USING btree (poitem_itemsite_id); -- -- Name: poitem_itemsite_status_duedate_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX poitem_itemsite_status_duedate_key ON poitem USING btree (poitem_itemsite_id, poitem_status, poitem_duedate); -- -- Name: poitem_pohead_id_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX poitem_pohead_id_key ON poitem USING btree (poitem_pohead_id); -- -- Name: poitem_status_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX poitem_status_key ON poitem USING btree (poitem_status); -- -- Name: priv_name_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE UNIQUE INDEX priv_name_idx ON priv USING btree (priv_name); -- -- Name: quitem_quhead_id_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX quitem_quhead_id_key ON quitem USING btree (quitem_quhead_id); -- -- Name: recv_ordertypeid_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX recv_ordertypeid_idx ON recv USING btree (recv_order_type, recv_orderitem_id); -- -- Name: report_name_grade_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE UNIQUE INDEX report_name_grade_idx ON report USING btree (report_name, report_grade); -- -- Name: salesaccnt_prodcat_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX salesaccnt_prodcat_id_idx ON salesaccnt USING btree (salesaccnt_prodcat_id); -- -- Name: salesaccnt_warehous_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX salesaccnt_warehous_id_idx ON salesaccnt USING btree (salesaccnt_warehous_id); -- -- Name: shipdata_cohead_number_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX shipdata_cohead_number_idx ON shipdata USING btree (shipdata_cohead_number); -- -- Name: shipdatasum_cohead_number_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX shipdatasum_cohead_number_idx ON shipdatasum USING btree (shipdatasum_cohead_number); -- -- Name: shipdatasum_cosmisc_tracknum_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX shipdatasum_cosmisc_tracknum_idx ON shipdatasum USING btree (shipdatasum_cosmisc_tracknum); -- -- Name: shiphead_order_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX shiphead_order_id_idx ON shiphead USING btree (shiphead_order_id); -- -- Name: shiphead_shipped_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX shiphead_shipped_idx ON shiphead USING btree (shiphead_shipped); -- -- Name: shipitem_invcitem_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX shipitem_invcitem_id_idx ON shipitem USING btree (shipitem_invcitem_id); -- -- Name: shipitem_orderitem_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX shipitem_orderitem_id_idx ON shipitem USING btree (shipitem_orderitem_id); -- -- Name: shipitem_shiphead_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX shipitem_shiphead_id_idx ON shipitem USING btree (shipitem_shiphead_id); -- -- Name: sltrans_sequence_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX sltrans_sequence_idx ON sltrans USING btree (sltrans_sequence); -- -- Name: sltrans_sltrans_accnt_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX sltrans_sltrans_accnt_id_idx ON sltrans USING btree (sltrans_accnt_id); -- -- Name: sltrans_sltrans_date_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX sltrans_sltrans_date_idx ON sltrans USING btree (sltrans_date); -- -- Name: sltrans_sltrans_journalnumber_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX sltrans_sltrans_journalnumber_idx ON sltrans USING btree (sltrans_journalnumber); -- -- Name: subaccnttype_code_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE UNIQUE INDEX subaccnttype_code_idx ON subaccnttype USING btree (subaccnttype_code); -- -- Name: taxhist_taxhist_parent_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX taxhist_taxhist_parent_id_idx ON taxhist USING btree (taxhist_parent_id); -- -- Name: taxhist_taxhist_parent_type_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX taxhist_taxhist_parent_type_idx ON taxhist USING btree (taxhist_parent_id, taxhist_taxtype_id); -- -- Name: taxhist_taxhist_taxtype_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX taxhist_taxhist_taxtype_id_idx ON taxhist USING btree (taxhist_taxtype_id); -- -- Name: todoitem_todoitem_username_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX todoitem_todoitem_username_idx ON todoitem USING btree (todoitem_username); -- -- Name: trialbal_accnt_period_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE UNIQUE INDEX trialbal_accnt_period_idx ON trialbal USING btree (trialbal_accnt_id, trialbal_period_id); -- -- Name: usrpref_userpref_name_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX usrpref_userpref_name_idx ON usrpref USING btree (usrpref_name); -- -- Name: vend_number_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE UNIQUE INDEX vend_number_idx ON vendinfo USING btree (vend_number); -- -- Name: voheadtax_taxhist_parent_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX voheadtax_taxhist_parent_id_idx ON voheadtax USING btree (taxhist_parent_id); -- -- Name: voheadtax_taxhist_parent_type_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX voheadtax_taxhist_parent_type_idx ON voheadtax USING btree (taxhist_parent_id, taxhist_taxtype_id); -- -- Name: voheadtax_taxhist_taxtype_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX voheadtax_taxhist_taxtype_id_idx ON voheadtax USING btree (taxhist_taxtype_id); -- -- Name: voitemtax_taxhist_parent_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX voitemtax_taxhist_parent_id_idx ON voitemtax USING btree (taxhist_parent_id); -- -- Name: voitemtax_taxhist_parent_type_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX voitemtax_taxhist_parent_type_idx ON voitemtax USING btree (taxhist_parent_id, taxhist_taxtype_id); -- -- Name: voitemtax_taxhist_taxtype_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX voitemtax_taxhist_taxtype_id_idx ON voitemtax USING btree (taxhist_taxtype_id); -- -- Name: warehous_code_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX warehous_code_key ON whsinfo USING btree (warehous_code bpchar_ops); -- -- Name: wo_duedate; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX wo_duedate ON wo USING btree (wo_duedate); -- -- Name: wo_itemsite_id; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX wo_itemsite_id ON wo USING btree (wo_itemsite_id); -- -- Name: wo_ordtype; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX wo_ordtype ON wo USING btree (wo_ordtype); -- -- Name: wo_startdate; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX wo_startdate ON wo USING btree (wo_startdate); -- -- Name: wo_status; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX wo_status ON wo USING btree (wo_status); -- -- Name: womatl_itemsite_id_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX womatl_itemsite_id_key ON womatl USING btree (womatl_itemsite_id); -- -- Name: womatl_wo_id_key; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX womatl_wo_id_key ON womatl USING btree (womatl_wo_id); -- -- Name: womatlpost_womatl_id_idx; Type: INDEX; Schema: public; Owner: admin; Tablespace: -- CREATE INDEX womatlpost_womatl_id_idx ON womatlpost USING btree (womatlpost_womatl_id); SET search_path = te, pg_catalog; -- -- Name: teitem_teitem_tehead_id_idx; Type: INDEX; Schema: te; Owner: admin; Tablespace: -- CREATE INDEX teitem_teitem_tehead_id_idx ON teitem USING btree (teitem_tehead_id); SET search_path = api, pg_catalog; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO salesline DO INSTEAD DELETE FROM public.coitem WHERE (((coitem.coitem_cohead_id = public.getcoheadid((old.order_number)::text)) AND (((coitem.coitem_linenumber)::character varying)::text = (old.line_number)::text)) AND (coitem.coitem_subnumber = 0)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO apmemo DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO armemo DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO physinvcount DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO account DO INSTEAD DELETE FROM public.crmacct WHERE (crmacct.crmacct_number = (old.account_number)::text); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO accountchar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'CRMACCT'::text) AND (charass.charass_target_id = public.getcrmacctid((old.account_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'CRMACCT'::text))); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO accountcomment DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO accountfile DO INSTEAD DELETE FROM public.url WHERE ((((url.url_source_id = public.getcrmacctid(old.account_number)) AND (url.url_source = 'CRMA'::text)) AND (url.url_title = old.title)) AND (url.url_url = old.url)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO accountimage DO INSTEAD DELETE FROM public.imageass WHERE (((imageass.imageass_source_id = public.getcrmacctid(old.account_number)) AND (imageass.imageass_source = 'CRMA'::text)) AND (imageass.imageass_image_id = public.getimageid(old.image_name))); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO address DO INSTEAD SELECT public.deleteaddress(public.getaddrid((old.address_number)::text)) AS deleteaddress; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO addresschar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'ADDR'::text) AND (charass.charass_target_id = public.getaddrid((old.address_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'ADDR'::text))); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO addresscomment DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO bom DO INSTEAD SELECT public.deletebom(public.getitemid((old.item_number)::text)) AS deletebom; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO bomitem DO INSTEAD DELETE FROM public.bomitem WHERE ((bomitem.bomitem_id = old.id) AND public.fetchmetricbool('AllowBOMItemDelete'::text)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO bomitemcomment DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO bomitemsubstitute DO INSTEAD DELETE FROM public.bomitemsub WHERE ((bomitemsub.bomitemsub_bomitem_id = old.bomitem_id) AND (bomitemsub.bomitemsub_item_id = public.getitemid((old.substitute_item_number)::text))); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO budget DO INSTEAD DELETE FROM public.budghead WHERE (budghead.budghead_name = old.name); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO budgetentry DO INSTEAD DELETE FROM public.budgitem WHERE (((budgitem.budgitem_budghead_id = public.getbudgheadid(old.name)) AND (budgitem.budgitem_period_id = public.getperiodid(old.period_start))) AND (budgitem.budgitem_accnt_id = public.getglaccntid(old.account))); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO cashreceipt DO INSTEAD SELECT public.deletecashrcpt(cashrcpt.cashrcpt_id) AS deletecashrcpt FROM public.cashrcpt WHERE (cashrcpt.cashrcpt_id = public.getcashrcptid((old.customer_number)::text, CASE WHEN ((old.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((old.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((old.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((old.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((old.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((old.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((old.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((old.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((old.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (old.check_document_number)::text)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO cashreceiptapply DO INSTEAD DELETE FROM public.cashrcptitem WHERE ((cashrcptitem.cashrcptitem_cashrcpt_id = public.getcashrcptid((old.customer_number)::text, CASE WHEN ((old.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((old.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((old.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((old.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((old.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((old.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((old.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((old.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((old.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (old.check_document_number)::text)) AND (cashrcptitem.cashrcptitem_aropen_id = public.getaropenid((old.customer_number)::text, (old.doc_type)::bpchar, (old.doc_number)::text))); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO cashreceiptapplymisc DO INSTEAD DELETE FROM public.cashrcptmisc WHERE ((cashrcptmisc.cashrcptmisc_cashrcpt_id = public.getcashrcptid((old.customer_number)::text, CASE WHEN ((old.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((old.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((old.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((old.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((old.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((old.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((old.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((old.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((old.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (old.check_document_number)::text)) AND (cashrcptmisc.cashrcptmisc_accnt_id = public.getglaccntid((old.account)::text))); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO contact DO INSTEAD DELETE FROM public.cntct WHERE (cntct.cntct_number = (old.contact_number)::text); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO contactchar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'CNTCT'::text) AND (charass.charass_target_id = public.getcntctid(old.contact_number))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'CNTCT'::text))); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO contactcomment DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO creditmemo DO INSTEAD SELECT public.deletecreditmemo(cmhead.cmhead_id) AS deletecreditmemo FROM public.cmhead WHERE ((cmhead.cmhead_number = old.memo_number) AND (cmhead.cmhead_posted = false)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO creditmemoline DO INSTEAD DELETE FROM public.cmitem WHERE ((cmitem.cmitem_cmhead_id = public.getcmheadid(old.memo_number, false)) AND (cmitem.cmitem_linenumber = old.line_number)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO custchar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'C'::text) AND (charass.charass_target_id = public.getcustid((old.customer_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'C'::text))); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO custcomment DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO custcreditcard DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO customer DO INSTEAD DELETE FROM public.custinfo WHERE (custinfo.cust_number = (old.customer_number)::text); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO customertype DO INSTEAD DELETE FROM public.custtype WHERE (custtype.custtype_code = (old.code)::text); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO customertypechar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'CT'::text) AND (charass.charass_target_id = public.getcusttypeid((old.customer_type)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'CT'::text))); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO custshipto DO INSTEAD SELECT public.deleteshipto(public.getshiptoid((old.customer_number)::text, (old.shipto_number)::text)) AS deleteshipto; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO custtax DO INSTEAD DELETE FROM public.taxreg WHERE (((taxreg.taxreg_rel_type = 'C'::bpchar) AND (taxreg.taxreg_rel_id = public.getcustid((old.customer_number)::text))) AND (taxreg.taxreg_taxauth_id = public.gettaxauthid((old.tax_authority)::text))); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO employee DO INSTEAD DELETE FROM public.emp WHERE (emp.emp_code = (old.code)::text); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO employeechar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'EMP'::text) AND (charass.charass_target_id = public.getempid((old.employee_code)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'EMP'::text))); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO employeecomment DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO extshipmaint DO INSTEAD DELETE FROM public.shipdata WHERE ((((shipdata.shipdata_cohead_number = (old.so_number)::text) AND (shipdata.shipdata_shiphead_number = (old.shipment_number)::text)) AND (shipdata.shipdata_shipper = (old.shipper)::text)) AND (shipdata.shipdata_cosmisc_packnum_tracknum = (old.package_tracking_number)::text)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO freightpricingscheduleitem DO INSTEAD DELETE FROM public.ipsfreight WHERE (((((((((ipsfreight.ipsfreight_ipshead_id = public.getipsheadid((old.pricing_schedule)::text)) AND (ipsfreight.ipsfreight_qtybreak = old.qty_break)) AND (ipsfreight.ipsfreight_price = old.price)) AND ((ipsfreight.ipsfreight_type)::text = CASE WHEN (old.price_type = 'Flat Rate'::text) THEN 'F'::text WHEN (old.price_type = 'Price Per UOM'::text) THEN 'P'::text ELSE NULL::text END)) AND ((ipsfreight.ipsfreight_warehous_id IS NULL) AND (old.from_site = 'Any'::text))) OR ((ipsfreight.ipsfreight_warehous_id = CASE WHEN (old.from_site = 'Any'::text) THEN 0 ELSE public.getwarehousid(old.from_site, 'All'::text) END) AND ((ipsfreight.ipsfreight_shipzone_id IS NULL) AND (old.to_shipzone = 'Any'::text)))) OR ((ipsfreight.ipsfreight_shipzone_id = CASE WHEN (old.to_shipzone = 'Any'::text) THEN 0 ELSE public.getshipzoneid(old.to_shipzone) END) AND ((ipsfreight.ipsfreight_freightclass_id IS NULL) AND (old.freight_class = 'Any'::text)))) OR ((ipsfreight.ipsfreight_freightclass_id = CASE WHEN (old.freight_class = 'Any'::text) THEN 0 ELSE public.getfreightclassid(old.freight_class) END) AND ((ipsfreight.ipsfreight_shipvia IS NULL) AND (old.ship_via = 'Any'::text)))) OR (ipsfreight.ipsfreight_shipvia = old.ship_via)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO incident DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO incidentchar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'INCDT'::text) AND (charass.charass_target_id = public.getincidentid(old.incident_number))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'INCDT'::text))); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO incidentcomment DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO incidentfile DO INSTEAD DELETE FROM public.url WHERE ((((url.url_source_id = public.getincidentid(old.incident_number)) AND (url.url_source = 'INCDT'::text)) AND (url.url_title = old.title)) AND (url.url_url = old.url)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO incidentimage DO INSTEAD DELETE FROM public.imageass WHERE (((imageass.imageass_source_id = public.getincidentid(old.incident_number)) AND (imageass.imageass_source = 'INCDT'::text)) AND (imageass.imageass_image_id = public.getimageid(old.image_name))); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO invoice DO INSTEAD SELECT public.deleteinvoice(invchead.invchead_id) AS deleteinvoice FROM public.invchead WHERE ((invchead.invchead_invcnumber = old.invoice_number) AND (invchead.invchead_posted = false)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO invoiceline DO INSTEAD DELETE FROM public.invcitem WHERE (invcitem.invcitem_invchead_id = (SELECT invchead.invchead_id FROM public.invchead WHERE ((invchead.invchead_invcnumber = old.invoice_number) AND (invchead.invchead_posted = false)))); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO item DO INSTEAD SELECT public.deleteitem(public.getitemid((old.item_number)::text)) AS deleteitem; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO itemalias DO INSTEAD DELETE FROM public.itemalias WHERE ((itemalias.itemalias_item_id = public.getitemid((old.item_number)::text)) AND (itemalias.itemalias_number = old.alias_number)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO itemchar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'I'::text) AND (charass.charass_target_id = public.getitemid((old.item_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'I'::text))); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO itemcomment DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO itemcost DO INSTEAD SELECT public.deleteitemcost(public.getitemid((old.item_number)::text), public.getcostelemid((old.costing_element)::text)) AS deleteitemcost; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO itemfile DO INSTEAD DELETE FROM public.url WHERE ((((url.url_source_id = public.getitemid((old.item_number)::text)) AND (url.url_source = 'I'::text)) AND (url.url_title = old.title)) AND (url.url_url = old.url)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO itemimage DO INSTEAD DELETE FROM public.imageass WHERE (((imageass.imageass_source_id = public.getitemid((old.item_number)::text)) AND (imageass.imageass_source = 'I'::text)) AND (imageass.imageass_image_id = public.getimageid(old.image_name))); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO itemsite DO INSTEAD SELECT public.deleteitemsite(public.getitemsiteid((old.site)::text, (old.item_number)::text)) AS deleteitemsite; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO itemsitecomment DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO itemsource DO INSTEAD DELETE FROM public.itemsrc WHERE (((((itemsrc.itemsrc_item_id = public.getitemid((old.item_number)::text)) AND (itemsrc.itemsrc_vend_id = public.getvendid((old.vendor)::text))) AND (itemsrc.itemsrc_vend_item_number = old.vendor_item_number)) AND (itemsrc.itemsrc_manuf_name = old.manufacturer_name)) AND (itemsrc.itemsrc_manuf_item_number = old.manufacturer_item_number)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO itemsourceprice DO INSTEAD DELETE FROM public.itemsrcp WHERE ((itemsrcp.itemsrcp_itemsrc_id = public.getitemsrcid((old.item_number)::text, (old.vendor)::text)) AND (itemsrcp.itemsrcp_qtybreak = old.qty_break)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO itemsubstitute DO INSTEAD DELETE FROM public.itemsub WHERE ((itemsub.itemsub_parent_item_id = public.getitemid((old.root_item_number)::text)) AND (itemsub.itemsub_sub_item_id = public.getitemid((old.substitute_item_number)::text))); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO itemtaxtype DO INSTEAD DELETE FROM public.itemtax WHERE (((itemtax.itemtax_item_id = public.getitemid((old.item_number)::text)) AND CASE WHEN ((old.tax_zone)::text = 'Any'::text) THEN (itemtax.itemtax_taxzone_id IS NULL) ELSE (itemtax.itemtax_taxzone_id = public.gettaxzoneid((old.tax_zone)::text)) END) AND (itemtax.itemtax_taxtype_id = public.gettaxtypeid(old.tax_type))); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO itemuomconversion DO INSTEAD SELECT public.deleteitemuomconv(itemuomconv.itemuomconv_id) AS deleteitemuomconv FROM public.itemuomconv WHERE ((itemuomconv.itemuomconv_item_id = public.getitemid((old.item_number)::text)) AND (((itemuomconv.itemuomconv_from_uom_id = public.getuomid((old.uom)::text)) AND (itemuomconv.itemuomconv_to_uom_id = public.getuomid(old.per_uom))) OR ((itemuomconv.itemuomconv_from_uom_id = public.getuomid(old.per_uom)) AND (itemuomconv.itemuomconv_to_uom_id = public.getuomid((old.uom)::text))))); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO journalentry DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO location DO INSTEAD DELETE FROM public.location WHERE ((location.location_warehous_id = public.getwarehousid((old.site)::text, 'ACTIVE'::text)) AND (location.location_name = (old.location)::text)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO misccounttag DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO pricingschedule DO INSTEAD DELETE FROM public.ipshead WHERE ((old.name)::text = ipshead.ipshead_name); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO pricingscheduleassign DO INSTEAD DELETE FROM public.ipsass WHERE ((((((ipsass.ipsass_ipshead_id = public.getipsheadid((old.pricing_schedule)::text)) AND (ipsass.ipsass_cust_id = CASE WHEN ((old.customer_number)::text = 'Any'::text) THEN (-1) ELSE public.getcustid((old.customer_number)::text) END)) AND (ipsass.ipsass_custtype_id = CASE WHEN ((old.customer_type)::text = 'N/A'::text) THEN (-1) ELSE public.getcusttypeid((old.customer_type)::text) END)) AND (ipsass.ipsass_custtype_pattern = (old.customer_type_pattern)::text)) AND (ipsass.ipsass_shipto_id = CASE WHEN ((old.customer_shipto)::text = 'Any'::text) THEN (-1) ELSE public.getshiptoid((old.customer_number)::text, (old.customer_shipto)::text) END)) AND (ipsass.ipsass_shipto_pattern = (old.customer_shipto_pattern)::text)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO pricingscheduleitem DO INSTEAD SELECT CASE WHEN ((old.type)::text = 'Item'::text) THEN public.deleteipsitem(public.getipsitemid((old.pricing_schedule)::text, (old.item_number)::text, old.qty_break, (old.qty_uom)::text, (old.price_uom)::text)) WHEN ((old.type)::text = 'Product Category'::text) THEN public.deleteipsprodcat(public.getipsprodcatid((old.pricing_schedule)::text, (old.product_category)::text, old.qty_break)) ELSE NULL::integer END AS result; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO pricingscheduleitemchar DO INSTEAD DELETE FROM public.ipsitemchar WHERE (((ipsitemchar.ipsitemchar_ipsitem_id = public.getipsitemid((old.pricing_schedule)::text, (old.item_number)::text, old.qty_break, (old.qty_uom)::text, (old.price_uom)::text)) AND (ipsitemchar.ipsitemchar_char_id = public.getcharid((old.characteristic)::text, 'I'::text))) AND (ipsitemchar.ipsitemchar_value = (old.value)::text)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO project DO INSTEAD SELECT public.deleteproject(public.getprjid(old.number)) AS deleteproject; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO projectcomment DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO prospect DO INSTEAD DELETE FROM public.prospect WHERE (prospect.prospect_number = (old.prospect_number)::text); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO purchaseline DO INSTEAD DELETE FROM public.poitem WHERE (poitem.poitem_id = public.getpoitemid((old.order_number)::text, old.line_number)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO purchaselinechar DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO purchaselinecomment DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO purchaseorder DO INSTEAD SELECT public.deletepo(pohead.pohead_id) AS deletepo FROM public.pohead WHERE (pohead.pohead_number = (old.order_number)::text); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO purchaseordercomment DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO quote DO INSTEAD SELECT public.deletequote(quhead.quhead_id, (old.quote_number)::text) AS deletequote FROM public.quhead WHERE (quhead.quhead_number = (old.quote_number)::text); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO quotecomment DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO quoteline DO INSTEAD DELETE FROM public.quitem WHERE ((quitem.quitem_quhead_id = public.getquoteid(old.quote_number)) AND (quitem.quitem_linenumber = old.line_number)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO quotelinechar DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO quotelinecomment DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO saleshistory DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO saleslinechar DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO saleslinecomment DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO salesorder DO INSTEAD SELECT public.deleteso(cohead.cohead_id, (old.order_number)::text) AS deleteso FROM public.cohead WHERE (cohead.cohead_number = (old.order_number)::text); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO salesordercomment DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO salesrep DO INSTEAD DELETE FROM public.salesrep WHERE (salesrep.salesrep_number = (old.number)::text); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO site DO NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO sitezone DO INSTEAD DELETE FROM public.whsezone WHERE ((whsezone.whsezone_warehous_id = public.getwarehousid((old.site)::text, 'ACTIVE'::text)) AND (whsezone.whsezone_name = (old.name)::text)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO task DO INSTEAD DELETE FROM public.prjtask WHERE ((prjtask.prjtask_prj_id = public.getprjid(old.project_number)) AND (prjtask.prjtask_number = old.number)); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO taskcomment DO INSTEAD NOTHING; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO todo DO INSTEAD SELECT public.deletetodoitem(old.task_number) AS deletetodoitem; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO vendor DO INSTEAD DELETE FROM public.vendinfo WHERE (vendinfo.vend_number = (old.vendor_number)::text); -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO vendoraddress DO INSTEAD SELECT public.deletevendoraddress(public.getvendaddrid((old.vendor_number)::text, (old.vendor_address_number)::text)) AS deletevendoraddress; -- -- Name: _DELETE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO vendortype DO INSTEAD SELECT public.deletevendortype(public.getvendtypeid((old.code)::text)) AS deletevendortype; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO salesline DO INSTEAD SELECT public.insertsalesline(new.*) AS insertsalesline; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO apmemo DO INSTEAD SELECT public.insertapmemo(new.*) AS insertapmemo; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO armemo DO INSTEAD SELECT public.insertarmemo(new.*) AS insertarmemo; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO physinvcount DO INSTEAD SELECT insertphysinvcount(new.*) AS insertphysinvcount; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO account DO INSTEAD INSERT INTO public.crmacct (crmacct_number, crmacct_parent_id, crmacct_name, crmacct_active, crmacct_type, crmacct_cntct_id_1, crmacct_cntct_id_2, crmacct_notes) VALUES (COALESCE(new.account_number, ((public.fetchcrmaccountnumber())::text)::character varying), public.getcrmacctid(new.parent_account), new.account_name, COALESCE(new.active, true), CASE WHEN (new.type = 'Individual'::text) THEN 'I'::text ELSE 'O'::text END, public.savecntct(public.getcntctid(new.primary_contact_number), new.primary_contact_number, public.saveaddr(public.getaddrid(new.primary_contact_address_number), new.primary_contact_address_number, new.primary_contact_address1, new.primary_contact_address2, new.primary_contact_address3, new.primary_contact_city, new.primary_contact_state, new.primary_contact_postalcode, new.primary_contact_country, new.primary_contact_address_change), new.primary_contact_honorific, new.primary_contact_first, new.primary_contact_middle, new.primary_contact_last, new.primary_contact_suffix, new.primary_contact_voice, NULL::text, new.primary_contact_fax, new.primary_contact_email, NULL::text, new.primary_contact_job_title, new.primary_contact_change), public.savecntct(public.getcntctid(new.secondary_contact_number), new.secondary_contact_number, public.saveaddr(public.getaddrid(new.secondary_contact_address_number), new.secondary_contact_address_number, new.secondary_contact_address1, new.secondary_contact_address2, new.secondary_contact_address3, new.secondary_contact_city, new.secondary_contact_state, new.secondary_contact_postalcode, new.secondary_contact_country, new.secondary_contact_address_change), new.secondary_contact_honorific, new.secondary_contact_first, new.secondary_contact_middle, new.secondary_contact_last, new.secondary_contact_suffix, new.secondary_contact_voice, NULL::text, new.secondary_contact_fax, new.secondary_contact_email, NULL::text, new.secondary_contact_job_title, new.secondary_contact_change), new.notes); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO accountchar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('CRMACCT'::text, public.getcrmacctid((new.account_number)::text), public.getcharid((new.characteristic)::text, 'CRMACCT'::text), new.value, false); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO accountcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'CRMA'::text, public.getcrmacctid((new.account_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO accountfile DO INSTEAD INSERT INTO public.url (url_source_id, url_source, url_title, url_url) VALUES (public.getcrmacctid(new.account_number), 'CRMA'::text, new.title, new.url); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO accountimage DO INSTEAD SELECT public.saveimageass('CRMA'::text, public.getcrmacctid(new.account_number), 'M'::bpchar, public.getimageid(new.image_name)) AS saveimageass; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO address DO INSTEAD SELECT public.saveaddr(NULL::integer, (new.address_number)::text, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, COALESCE(new.active, true), new.notes, NULL::text) AS saveaddr; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO addresschar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('ADDR'::text, public.getaddrid((new.address_number)::text), public.getcharid((new.characteristic)::text, 'ADDR'::text), new.value, false); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO addresscomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'ADDR'::text, public.getaddrid((new.address_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO bom DO INSTEAD SELECT public.savebomhead(public.getitemid((new.item_number)::text), (new.revision)::text, new.revision_date, new.document_number, COALESCE(new.batch_size, (0)::numeric), new.total_qty_per) AS savebomhead; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO bomitem DO INSTEAD SELECT public.createbomitem(COALESCE(new.id, (nextval('public.bomitem_bomitem_id_seq'::regclass))::integer), public.getitemid((new.bom_item_number)::text), public.getitemid(new.item_number), COALESCE(new.sequence_number, (SELECT (max(bomitem.bomitem_seqnumber) + 10) FROM public.bomitem(public.getitemid((new.bom_item_number)::text), COALESCE(public.getrevid('BOM'::text, (new.bom_item_number)::text, (new.bom_revision)::text))) bomitem(bomitem_id, bomitem_parent_item_id, bomitem_seqnumber, bomitem_item_id, bomitem_qtyper, bomitem_scrap, bomitem_status, bomitem_effective, bomitem_expires, bomitem_createwo, bomitem_issuemethod, bomitem_schedatwooper, bomitem_ecn, bomitem_moddate, bomitem_subtype, bomitem_uom_id, bomitem_rev_id, bomitem_booitem_seq_id, bomitem_char_id, bomitem_value, bomitem_notes, bomitem_ref, bomitem_qtyfxd, bomitem_issuewo)), 10), (CASE WHEN (new.issue_method = 'Mixed'::text) THEN 'M'::text WHEN (new.issue_method = 'Push'::text) THEN 'S'::text WHEN (new.issue_method = 'Pull'::text) THEN 'L'::text ELSE public.fetchmetrictext('DefaultWomatlIssueMethod'::text) END)::bpchar, COALESCE(public.getuomid(new.issue_uom), (SELECT item.item_inv_uom_id FROM public.item WHERE (item.item_id = public.getitemid(new.item_number)))), new.qty_per, new.scrap, CASE WHEN (new.effective = 'Always'::text) THEN public.startoftime() ELSE COALESCE((new.effective)::date, public.startoftime()) END, CASE WHEN (new.expires = 'Never'::text) THEN public.endoftime() ELSE COALESCE((new.expires)::date, public.endoftime()) END, COALESCE(new.create_child_wo, false), COALESCE(public.getbooitemseqid((new.bom_item_number)::text, new.used_at), (-1)), COALESCE(new.schedule_at_wo_operation, false), new.ecn_number, (CASE WHEN (new.substitutions = 'No'::text) THEN 'N'::text WHEN (new.substitutions = 'BOM-Defined'::text) THEN 'B'::text ELSE 'I'::text END)::bpchar, COALESCE(public.getrevid('BOM'::text, (new.bom_item_number)::text, (new.bom_revision)::text)), public.getcharid(new.characteristic, 'I'::text), new.value, new.notes, new.reference) AS createbomitem; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO bomitemcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'BMI'::text, new.bomitem_id, COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO bomitemsubstitute DO INSTEAD INSERT INTO public.bomitemsub (bomitemsub_bomitem_id, bomitemsub_item_id, bomitemsub_uomratio, bomitemsub_rank) VALUES (new.bomitem_id, public.getitemid((new.substitute_item_number)::text), COALESCE(new.sub_parent_uom_ratio, (1)::numeric), COALESCE(new.ranking, 1)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO budget DO INSTEAD INSERT INTO public.budghead (budghead_name, budghead_descrip) VALUES (new.name, new.description); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO budgetentry DO INSTEAD INSERT INTO public.budgitem (budgitem_budghead_id, budgitem_period_id, budgitem_accnt_id, budgitem_amount) VALUES (public.getbudgheadid(new.name), public.getperiodid(new.period_start), public.getglaccntid(new.account), new.amount); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO cashreceipt DO INSTEAD INSERT INTO public.cashrcpt (cashrcpt_cust_id, cashrcpt_number, cashrcpt_amount, cashrcpt_fundstype, cashrcpt_docnumber, cashrcpt_bankaccnt_id, cashrcpt_notes, cashrcpt_distdate, cashrcpt_salescat_id, cashrcpt_curr_id, cashrcpt_usecustdeposit) VALUES (public.getcustid((new.customer_number)::text), (SELECT public.fetchcashrcptnumber() AS fetchcashrcptnumber), COALESCE(new.amount_received, (0)::numeric), CASE WHEN ((new.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((new.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((new.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((new.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((new.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((new.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((new.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((new.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((new.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, COALESCE(new.check_document_number, ''::character varying), public.getbankaccntid(new.post_to), COALESCE(new.notes, ''::text), CASE WHEN (new.distribution_date > ''::text) THEN ((new.distribution_date)::date)::timestamp with time zone ELSE now() END, COALESCE(public.getsalescatid(new.sales_category), (-1)), public.getcurrid((new.currency)::text), CASE WHEN (new.apply_balance_as = 'Customer Deposit'::text) THEN true ELSE false END); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO cashreceiptapply DO INSTEAD INSERT INTO public.cashrcptitem (cashrcptitem_cashrcpt_id, cashrcptitem_aropen_id, cashrcptitem_amount, cashrcptitem_discount) VALUES (public.getcashrcptid((new.customer_number)::text, CASE WHEN ((new.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((new.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((new.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((new.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((new.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((new.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((new.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((new.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((new.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (new.check_document_number)::text), public.getaropenid((new.customer_number)::text, (new.doc_type)::bpchar, (new.doc_number)::text), COALESCE(new.amount_to_apply, (0)::numeric), COALESCE(new.cashrcptitem_discount, (0)::numeric)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO cashreceiptapplymisc DO INSTEAD INSERT INTO public.cashrcptmisc (cashrcptmisc_cashrcpt_id, cashrcptmisc_accnt_id, cashrcptmisc_amount, cashrcptmisc_notes) VALUES (public.getcashrcptid((new.customer_number)::text, CASE WHEN ((new.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((new.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((new.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((new.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((new.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((new.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((new.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((new.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((new.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (new.check_document_number)::text), public.getglaccntid((new.account)::text), COALESCE(new.amount_to_distribute, (0)::numeric), COALESCE(new.notes, ''::text)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO contact DO INSTEAD SELECT public.savecntct(NULL::integer, (new.contact_number)::text, public.getcrmacctid(new.crm_account), public.saveaddr(CASE WHEN (NOT (EXISTS (SELECT addr.addr_id FROM public.addr WHERE (addr.addr_number = new.address_number)))) THEN NULL::integer ELSE public.getaddrid(new.address_number) END, new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.address_change), new.honorific, new.first, new.middle, new.last, new.suffix, new.initials, COALESCE(new.active, true), new.voice, new.alternate, new.fax, new.email, new.web, new.notes, new.job_title, new.contact_change) AS savecntct; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO contactchar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('CNTCT'::text, public.getcntctid(new.contact_number), public.getcharid((new.characteristic)::text, 'CNTCT'::text), new.value, false); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO contactcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'T'::text, public.getcntctid(new.contact_number), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO creditmemo DO INSTEAD SELECT public.insertcreditmemo(new.*) AS insertcreditmemo; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO creditmemoline DO INSTEAD SELECT public.insertcreditmemoline(new.*) AS insertcreditmemoline; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO custchar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('C'::text, public.getcustid((new.customer_number)::text), public.getcharid((new.characteristic)::text, 'C'::text), new.value, false); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO custcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'C'::text, public.getcustid((new.customer_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO custcreditcard DO INSTEAD SELECT public.insertccard((new.customer_number)::text, new.active, new.credit_card_type, new.credit_card_number, new.name, new.street_address1, new.street_address2, new.city, new.state, new.postal_code, new.country, new.expiration_month, new.expiration_year, new.key) AS insertccard; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO customer DO INSTEAD INSERT INTO public.custinfo (cust_active, cust_custtype_id, cust_salesrep_id, cust_commprcnt, cust_name, cust_creditlmt, cust_creditrating, cust_backorder, cust_partialship, cust_terms_id, cust_discntprcnt, cust_balmethod, cust_ffshipto, cust_shipform_id, cust_shipvia, cust_blanketpos, cust_shipchrg_id, cust_creditstatus, cust_comments, cust_ffbillto, cust_usespos, cust_number, cust_autoupdatestatus, cust_autoholdorders, cust_preferred_warehous_id, cust_curr_id, cust_creditlmt_curr_id, cust_cntct_id, cust_corrcntct_id, cust_taxzone_id, cust_gracedays) VALUES (COALESCE(new.active, true), COALESCE((public.getcusttypeid(new.customer_type))::numeric, public.fetchmetricvalue('DefaultCustType'::text)), COALESCE((public.getsalesrepid(new.sales_rep))::numeric, public.fetchmetricvalue('DefaultSalesRep'::text)), COALESCE((new.commission * 0.01), (SELECT salesrep.salesrep_commission FROM public.salesrep WHERE (salesrep.salesrep_id = public.getsalesrepid(new.sales_rep)))), COALESCE(new.customer_name, ''::text), COALESCE((new.credit_limit)::numeric, public.fetchmetricvalue('SOCreditLimit'::text)), COALESCE(new.credit_rating, public.fetchmetrictext('SOCreditRate'::text)), COALESCE(new.accepts_backorders, public.fetchmetricbool('DefaultBackOrders'::text), false), COALESCE(new.accepts_partial_shipments, public.fetchmetricbool('DefaultPartialShipments'::text), false), COALESCE((public.gettermsid(new.default_terms))::numeric, public.fetchmetricvalue('DefaultTerms'::text)), COALESCE(new.default_discount, (0)::numeric), CASE WHEN (new.balance_method = 'Balance Forward'::text) THEN 'B'::text WHEN (new.balance_method = 'Open Items'::text) THEN 'O'::text ELSE COALESCE(public.fetchmetrictext('DefaultBalanceMethod'::text), 'B'::text) END, COALESCE(new.allow_free_form_shipto, public.fetchmetricbool('DefaultFreeFormShiptos'::text), false), COALESCE((public.getshipformid(new.ship_form))::numeric, public.fetchmetricvalue('DefaultShipFormId'::text)), COALESCE(new.ship_via, public.fetchdefaultshipvia()), COALESCE(new.uses_blanket_pos, false), COALESCE(public.getshipchrgid(new.shipping_charges), (-1)), CASE WHEN (new.credit_status = 'On Credit Warning'::text) THEN 'W'::text WHEN (new.credit_status = 'On Credit Hold'::text) THEN 'H'::text ELSE 'G'::text END, COALESCE(new.notes, ''::text), COALESCE(new.allow_free_form_billto, false), COALESCE(new.uses_purchase_orders, false), COALESCE(upper((new.customer_number)::text), (public.fetchcrmaccountnumber())::text), COALESCE(new.credit_status_exceed_warn, false), COALESCE(new.credit_status_exceed_hold, false), COALESCE(public.getwarehousid(new.preferred_selling_site, 'ACTIVE'::text), (-1)), COALESCE(public.getcurrid((new.default_currency)::text), public.basecurrid()), COALESCE(public.getcurrid((new.credit_limit_currency)::text), public.basecurrid()), public.savecntct(public.getcntctid(new.billing_contact_number, false), new.billing_contact_number, public.saveaddr(public.getaddrid(new.billing_contact_address_number), new.billing_contact_address_number, new.billing_contact_address1, new.billing_contact_address2, new.billing_contact_address3, new.billing_contact_city, new.billing_contact_state, new.billing_contact_postalcode, new.billing_contact_country, new.billing_contact_address_change), new.billing_contact_honorific, new.billing_contact_first, new.billing_contact_middle, new.billing_contact_last, new.billing_contact_suffix, new.billing_contact_voice, new.billing_contact_alternate, new.billing_contact_fax, new.billing_contact_email, new.billing_contact_web, new.billing_contact_job_title, new.billing_contact_change), public.savecntct(public.getcntctid(new.correspond_contact_number, false), new.correspond_contact_number, public.saveaddr(public.getaddrid(new.correspond_contact_address_number), new.correspond_contact_address_number, new.correspond_contact_address1, new.correspond_contact_address2, new.correspond_contact_address3, new.correspond_contact_city, new.correspond_contact_state, new.correspond_contact_postalcode, new.correspond_contact_country, new.correspond_contact_address_change), new.correspond_contact_honorific, new.correspond_contact_first, new.correspond_contact_middle, new.correspond_contact_last, new.correspond_contact_suffix, new.correspond_contact_voice, new.correspond_contact_alternate, new.correspond_contact_fax, new.correspond_contact_email, new.correspond_contact_web, new.correspond_contact_job_title, new.correspond_contact_change), public.gettaxzoneid(new.default_tax_zone), CASE WHEN (COALESCE(new.alternate_grace_days, 0) > 0) THEN new.alternate_grace_days ELSE NULL::integer END); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO customertaxreg DO INSTEAD INSERT INTO public.taxreg (taxreg_rel_id, taxreg_rel_type, taxreg_taxauth_id, taxreg_taxzone_id, taxreg_number, taxreg_effective, taxreg_expires, taxreg_notes) VALUES (public.getcustid((new.customer_number)::text), 'C'::bpchar, public.gettaxauthid((new.tax_authority)::text), (SELECT custinfo.cust_taxzone_id FROM public.custinfo WHERE (custinfo.cust_id = public.getcustid((new.customer_number)::text))), COALESCE(new.registration_number, ''::text), CASE WHEN (new.start_date = 'Always'::text) THEN public.startoftime() ELSE COALESCE((new.start_date)::date, public.startoftime()) END, CASE WHEN (new.end_date = 'Never'::text) THEN public.endoftime() ELSE COALESCE((new.end_date)::date, public.endoftime()) END, new.notes); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO customertype DO INSTEAD INSERT INTO public.custtype (custtype_code, custtype_descrip, custtype_char) VALUES (new.code, COALESCE(new.description, ''::text), COALESCE(new.enable_characteristics_profile, false)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO customertypechar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('CT'::text, public.getcusttypeid((new.customer_type)::text), public.getcharid((new.characteristic)::text, 'CT'::text), new.value, COALESCE(new.is_default, false)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO custshipto DO INSTEAD INSERT INTO public.shiptoinfo (shipto_cust_id, shipto_name, shipto_salesrep_id, shipto_comments, shipto_shipcomments, shipto_shipzone_id, shipto_shipvia, shipto_commission, shipto_shipform_id, shipto_shipchrg_id, shipto_active, shipto_default, shipto_num, shipto_ediprofile_id, shipto_cntct_id, shipto_addr_id, shipto_taxzone_id) VALUES (public.getcustid((new.customer_number)::text), COALESCE(new.name, ''::text), COALESCE(public.getsalesrepid(new.sales_rep), (SELECT custinfo.cust_salesrep_id FROM public.custinfo WHERE (custinfo.cust_id = public.getcustid((new.customer_number)::text)))), COALESCE(new.general_notes, ''::text), COALESCE(new.shipping_notes, ''::text), public.getshipzoneid(new.zone), COALESCE(new.ship_via, (SELECT custinfo.cust_shipvia FROM public.custinfo WHERE (custinfo.cust_id = public.getcustid((new.customer_number)::text)))), COALESCE((new.commission / 100.0), (0)::numeric), COALESCE(public.getshipformid(new.ship_form), (SELECT custinfo.cust_shipform_id FROM public.custinfo WHERE (custinfo.cust_id = public.getcustid((new.customer_number)::text)))), COALESCE(public.getshipchrgid(new.shipping_charges), (SELECT custinfo.cust_shipchrg_id FROM public.custinfo WHERE (custinfo.cust_id = public.getcustid((new.customer_number)::text)))), COALESCE(new.active, true), COALESCE(new.default_flag, false), COALESCE(new.shipto_number, (((SELECT (COALESCE(max((shiptoinfo.shipto_num)::integer), 0) + 1) FROM public.shiptoinfo WHERE ((shiptoinfo.shipto_cust_id = public.getcustid((new.customer_number)::text)) AND (shiptoinfo.shipto_num ~ '^[0-9]*$'::text))))::text)::character varying), CASE WHEN (new.edi_profile = 'No EDI'::text) THEN (-1) WHEN (new.edi_profile = 'Use Customer Master'::text) THEN (-2) ELSE public.getediprofileid(new.edi_profile) END, public.savecntct(public.getcntctid(new.contact_number), new.contact_number, NULL::integer, new.honorific, new.first, new.middle, new.last, new.suffix, new.phone, NULL::text, new.fax, new.email, NULL::text, new.job_title, new.contact_change), public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.address_change), COALESCE(public.gettaxzoneid(new.tax_zone), (SELECT custinfo.cust_taxzone_id FROM public.custinfo WHERE (custinfo.cust_id = public.getcustid((new.customer_number)::text))))); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO custtax DO INSTEAD INSERT INTO public.taxreg (taxreg_rel_type, taxreg_rel_id, taxreg_taxauth_id, taxreg_number) VALUES ('C'::bpchar, public.getcustid((new.customer_number)::text), public.gettaxauthid((new.tax_authority)::text), new.registration_number); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO employee DO INSTEAD INSERT INTO public.emp (emp_code, emp_number, emp_active, emp_cntct_id, emp_warehous_id, emp_mgr_emp_id, emp_wage_type, emp_wage, emp_wage_curr_id, emp_wage_period, emp_dept_id, emp_shift_id, emp_image_id, emp_extrate, emp_extrate_period, emp_startdate, emp_notes) VALUES (new.code, new.number, COALESCE(new.active, true), public.savecntct(public.getcntctid(new.contact_number), new.contact_number, public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change), new.honorific, new.first, new.middle, new.last, new.suffix, new.voice, new.alternate, new.fax, new.email, new.web, new.job_title, new.contact_change), public.getwarehousid(new.site, 'ALL'::text), (SELECT emp.emp_id FROM public.emp WHERE (emp.emp_code = new.manager_code)), CASE WHEN (new.wage_type = 'Hourly'::text) THEN 'H'::text WHEN (new.wage_type = 'Salaried'::text) THEN 'S'::text ELSE NULL::text END, new.wage, COALESCE(public.getcurrid((new.wage_currency)::text), public.basecurrid()), CASE WHEN (new.wage_period = 'Hour'::text) THEN 'H'::text WHEN (new.wage_period = 'Day'::text) THEN 'D'::text WHEN (new.wage_period = 'Week'::text) THEN 'W'::text WHEN (new.wage_period = 'Biweek'::text) THEN 'BW'::text WHEN (new.wage_period = 'Month'::text) THEN 'M'::text WHEN (new.wage_period = 'Year'::text) THEN 'Y'::text ELSE NULL::text END, public.getdeptid(new.department), public.getshiftid(new.shift), public.getimageid(new.image), new.rate, CASE WHEN (new.billing_period = 'Hour'::text) THEN 'H'::text WHEN (new.billing_period = 'Day'::text) THEN 'D'::text WHEN (new.billing_period = 'Week'::text) THEN 'W'::text WHEN (new.billing_period = 'Biweek'::text) THEN 'BW'::text WHEN (new.billing_period = 'Month'::text) THEN 'M'::text WHEN (new.billing_period = 'Year'::text) THEN 'Y'::text ELSE NULL::text END, new.start_date, COALESCE(new.notes, ''::text)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO employeechar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('EMP'::text, public.getempid((new.employee_code)::text), public.getcharid((new.characteristic)::text, 'EMP'::text), new.value, false); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO employeecomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'EMP'::text, public.getempid((new.code)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid((new.type)::text), new.text); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO extshipmaint DO INSTEAD INSERT INTO public.shipdata (shipdata_cohead_number, shipdata_shiphead_number, shipdata_void_ind, shipdata_shipper, shipdata_billing_option, shipdata_weight, shipdata_base_freight, shipdata_base_freight_curr_id, shipdata_total_freight, shipdata_total_freight_curr_id, shipdata_package_type, shipdata_cosmisc_tracknum, shipdata_cosmisc_packnum_tracknum, shipdata_lastupdated) VALUES (new.so_number, new.shipment_number, new.void, new.shipper, new.billing_option, new.weight, new.base_freight, public.getcurrid((new.base_freight_currency)::text), new.total_freight, public.getcurrid((new.total_freight_currency)::text), new.package_type, new.tracking_number, new.package_tracking_number, new.last_updated); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO freightpricingscheduleitem DO INSTEAD INSERT INTO public.ipsfreight (ipsfreight_ipshead_id, ipsfreight_qtybreak, ipsfreight_price, ipsfreight_type, ipsfreight_warehous_id, ipsfreight_shipzone_id, ipsfreight_freightclass_id, ipsfreight_shipvia) VALUES (public.getipsheadid((new.pricing_schedule)::text), new.qty_break, new.price, CASE WHEN (new.price_type = 'Flat Rate'::text) THEN 'F'::text ELSE 'P'::text END, CASE WHEN (new.from_site = 'Any'::text) THEN NULL::integer ELSE public.getwarehousid(new.from_site, 'All'::text) END, CASE WHEN (new.to_shipzone = 'Any'::text) THEN NULL::integer ELSE public.getshipzoneid(new.to_shipzone) END, CASE WHEN (new.freight_class = 'Any'::text) THEN NULL::integer ELSE public.getfreightclassid(new.freight_class) END, CASE WHEN (new.ship_via = 'Any'::text) THEN NULL::text ELSE new.ship_via END); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO glaccount DO INSTEAD INSERT INTO public.accnt (accnt_number, accnt_descrip, accnt_comments, accnt_profit, accnt_sub, accnt_type, accnt_extref, accnt_company, accnt_forwardupdate, accnt_subaccnttype_code) VALUES (COALESCE(new.account_number, ''::character varying), COALESCE(new.description, ''::text), COALESCE(new.notes, ''::text), new.profit_center, new.sub_account, CASE WHEN (new.type = 'Asset'::text) THEN 'A'::text WHEN (new.type = 'Liability'::text) THEN 'L'::text WHEN (new.type = 'Expense'::text) THEN 'E'::text WHEN (new.type = 'Revenue'::text) THEN 'R'::text WHEN (new.type = 'Equity'::text) THEN 'Q'::text ELSE NULL::text END, COALESCE(new.ext_reference, ''::text), new.company, COALESCE(new.forward_update_trial_balances, false), COALESCE(new.sub_type, ''::text)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO incident DO INSTEAD INSERT INTO public.incdt (incdt_number, incdt_crmacct_id, incdt_cntct_id, incdt_summary, incdt_descrip, incdt_item_id, incdt_status, incdt_assigned_username, incdt_incdtcat_id, incdt_incdtseverity_id, incdt_incdtpriority_id, incdt_incdtresolution_id, incdt_lotserial, incdt_ls_id) VALUES (new.incident_number, public.getcrmacctid(new.crm_account), public.savecntct(public.getcntctid(new.contact_number), new.contact_number, NULL::integer, new.honorific, new.first, new.middle, new.last, new.suffix, new.phone, NULL::text, new.fax, new.email, NULL::text, new.job_title, new.contact_change), COALESCE(new.description, ''::text), COALESCE(new.notes, ''::text), public.getitemid(new.item_number), CASE WHEN (new.status = 'New'::text) THEN 'N'::text WHEN (new.status = 'Feedback'::text) THEN 'F'::text WHEN (new.status = 'Confirmed'::text) THEN 'C'::text WHEN (new.status = 'Assigned'::text) THEN 'A'::text WHEN (new.status = 'Resolved'::text) THEN 'R'::text WHEN (new.status = 'Closed'::text) THEN 'L'::text ELSE ''::text END, COALESCE(new.assigned_to, ''::text), public.getincdtcatid(new.category), public.getincdtseverityid(new.severity), public.getincdtpriorityid(new.priority), public.getincdtresolutionid(new.resolution), COALESCE(new.lot_serial_number, ''::text), public.getlotserialid(new.item_number, new.lot_serial_number)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO incidentchar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('INCDT'::text, public.getincidentid(new.incident_number), public.getcharid((new.characteristic)::text, 'INCDT'::text), new.value, false); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO incidentcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text, comment_public) VALUES (COALESCE(new.date, now()), 'INCDT'::text, public.getincidentid(new.incident_number), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text, COALESCE(new.public, true)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO incidentfile DO INSTEAD INSERT INTO public.url (url_source_id, url_source, url_title, url_url) VALUES (public.getincidentid(new.incident_number), 'INCDT'::text, new.title, new.url); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO incidentimage DO INSTEAD SELECT public.saveimageass('INCDT'::text, public.getincidentid(new.incident_number), 'M'::bpchar, public.getimageid(new.image_name)) AS saveimageass; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO invoice DO INSTEAD SELECT public.insertinvoice(new.*) AS insertinvoice; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO invoiceline DO INSTEAD SELECT public.insertinvoicelineitem(new.*) AS insertinvoicelineitem; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO item DO INSTEAD INSERT INTO public.item (item_number, item_active, item_descrip1, item_descrip2, item_type, item_maxcost, item_classcode_id, item_inv_uom_id, item_picklist, item_fractional, item_config, item_sold, item_prodcat_id, item_exclusive, item_listprice, item_listcost, item_price_uom_id, item_upccode, item_prodweight, item_packweight, item_comments, item_extdescrip) VALUES (upper((new.item_number)::text), COALESCE(new.active, true), COALESCE(new.description1, ''::text), COALESCE(new.description2, ''::text), CASE WHEN (new.item_type = 'Purchased'::text) THEN 'P'::text WHEN (new.item_type = 'Manufactured'::text) THEN 'M'::text WHEN (new.item_type = 'Job'::text) THEN 'J'::text WHEN (new.item_type = 'Kit'::text) THEN 'K'::text WHEN (new.item_type = 'Phantom'::text) THEN 'F'::text WHEN (new.item_type = 'Reference'::text) THEN 'R'::text WHEN (new.item_type = 'Costing'::text) THEN 'S'::text WHEN (new.item_type = 'Tooling'::text) THEN 'T'::text WHEN (new.item_type = 'Outside Process'::text) THEN 'O'::text WHEN (new.item_type = 'Planning'::text) THEN 'L'::text WHEN (new.item_type = 'Breeder'::text) THEN 'B'::text WHEN (new.item_type = 'Co-Product'::text) THEN 'C'::text WHEN (new.item_type = 'By-Product'::text) THEN 'Y'::text ELSE NULL::text END, COALESCE(new.maximum_desired_cost, (0)::numeric), public.getclasscodeid(new.class_code), public.getuomid(new.inventory_uom), COALESCE(new.pick_list_item, true), COALESCE(new.fractional, false), COALESCE(new.configured, false), COALESCE(new.item_is_sold, true), COALESCE(public.getprodcatid(new.product_category), (-1)), COALESCE(new.exclusive, false), COALESCE(new.list_price, (0)::numeric), COALESCE(new.list_cost, (0)::numeric), COALESCE(public.getuomid(new.list_price_uom), public.getuomid(new.inventory_uom)), new.upc_code, COALESCE(new.product_weight, (0)::numeric), COALESCE(new.packaging_weight, (0)::numeric), new.notes, new.ext_description); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO itemalias DO INSTEAD INSERT INTO public.itemalias (itemalias_item_id, itemalias_number, itemalias_usedescrip, itemalias_descrip1, itemalias_descrip2, itemalias_comments, itemalias_crmacct_id) VALUES (public.getitemid((new.item_number)::text), new.alias_number, COALESCE(new.use_description, false), COALESCE(new.description1, ''::text), COALESCE(new.description2, ''::text), new.comments, public.getcrmacctid(new.crmacct_number)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO itemchar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('I'::text, public.getitemid((new.item_number)::text), public.getcharid((new.characteristic)::text, 'I'::text), new.value, COALESCE(new.is_default, false)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO itemcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'IS'::text, public.getitemid((new.item_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO itemcost DO INSTEAD SELECT public.insertitemcost(public.getitemid((new.item_number)::text), public.getcostelemid((new.costing_element)::text), public.getcurrid((new.currency)::text), new.actual_cost, new.post_to_standard) AS insertitemcost; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO itemfile DO INSTEAD INSERT INTO public.url (url_source_id, url_source, url_title, url_url) VALUES (public.getitemid((new.item_number)::text), 'I'::text, new.title, new.url); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO itemimage DO INSTEAD SELECT public.saveimageass('I'::text, public.getitemid((new.item_number)::text), (CASE WHEN (new.purpose = 'Product Description'::text) THEN 'P'::text WHEN (new.purpose = 'Inventory Description'::text) THEN 'I'::text WHEN (new.purpose = 'Engineering Reference'::text) THEN 'E'::text WHEN (new.purpose = 'Miscellaneous'::text) THEN 'M'::text ELSE 'X'::text END)::bpchar, public.getimageid(new.image_name)) AS saveimageass; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO itemsite DO INSTEAD INSERT INTO public.itemsite (itemsite_item_id, itemsite_warehous_id, itemsite_active, itemsite_dropship, itemsite_posupply, itemsite_createpr, itemsite_wosupply, itemsite_createwo, itemsite_createsopr, itemsite_createsopo, itemsite_sold, itemsite_soldranking, itemsite_costmethod, itemsite_controlmethod, itemsite_perishable, itemsite_plancode_id, itemsite_costcat_id, itemsite_loccntrl, itemsite_location_id, itemsite_recvlocation_id, itemsite_issuelocation_id, itemsite_location_dist, itemsite_recvlocation_dist, itemsite_issuelocation_dist, itemsite_location, itemsite_location_comments, itemsite_disallowblankwip, itemsite_stocked, itemsite_abcclass, itemsite_autoabcclass, itemsite_cyclecountfreq, itemsite_eventfence, itemsite_useparams, itemsite_reorderlevel, itemsite_ordertoqty, itemsite_minordqty, itemsite_maxordqty, itemsite_multordqty, itemsite_useparamsmanual, itemsite_ordergroup, itemsite_ordergroup_first, itemsite_mps_timefence, itemsite_leadtime, itemsite_safetystock, itemsite_supply_itemsite_id, itemsite_notes, itemsite_qtyonhand, itemsite_warrpurc, itemsite_autoreg, itemsite_freeze, itemsite_value, itemsite_planning_type) VALUES (public.getitemid((new.item_number)::text), public.getwarehousid((new.site)::text, 'ACTIVE'::text), COALESCE(new.active, true), COALESCE(new.dropship, false), COALESCE(new.po_supplied_at_site, false), COALESCE(new.create_prs, false), COALESCE(new.wo_supplied_at_site, false), COALESCE(new.create_wos, false), COALESCE(new.create_soprs, false), COALESCE(new.create_sopos, false), COALESCE(new.sold_from_site, true), COALESCE(new.ranking, 1), CASE WHEN (new.cost_method = 'None'::text) THEN 'N'::text WHEN (new.cost_method = 'Average'::text) THEN 'A'::text WHEN (new.cost_method = 'Standard'::text) THEN 'S'::text WHEN (new.cost_method = 'Job'::text) THEN 'J'::text ELSE NULL::text END, CASE WHEN (new.control_method = 'None'::text) THEN 'N'::text WHEN (new.control_method = 'Regular'::text) THEN 'R'::text WHEN (new.control_method = 'Serial #'::text) THEN 'S'::text WHEN (new.control_method = 'Lot #'::text) THEN 'L'::text ELSE NULL::text END, COALESCE(new.perishable, false), public.getplancodeid(new.planner_code), public.getcostcatid(new.cost_category), COALESCE(new.multiple_location_control, false), COALESCE(public.getlocationid((new.site)::text, new.location), (-1)), COALESCE(public.getlocationid((new.site)::text, new.receive_location), (-1)), COALESCE(public.getlocationid((new.site)::text, new.issue_location), (-1)), COALESCE(new.auto_distr_location, false), COALESCE(new.auto_distr_receive_location, false), COALESCE(new.auto_distr_issue_location, false), COALESCE(new.user_defined_location, ''::text), COALESCE(new.location_comment, ''::text), COALESCE(new.disallow_blank_wip_locations, false), COALESCE(new.stocked, false), COALESCE(new.abc_class, 'A'::bpchar), COALESCE(new.allow_automatic_updates, false), COALESCE(new.cycl_cnt_freq, 0), COALESCE((new.event_fence)::numeric, public.fetchmetricvalue('DefaultEventFence'::text)), COALESCE(new.enforce_order_parameters, false), COALESCE(new.reorder_level, (0)::numeric), COALESCE(new.order_up_to, (0)::numeric), COALESCE(new.minimum_order, (0)::numeric), COALESCE(new.maximum_order, (0)::numeric), COALESCE(new.order_multiple, (0)::numeric), COALESCE(new.enforce_on_manual_orders, false), COALESCE(new.group_mps_mrp_orders, 0), COALESCE(new.first_group, false), COALESCE(new.mps_time_fence, 0), COALESCE(new.lead_time, 0), COALESCE(new.safety_stock, (0)::numeric), CASE WHEN (new.supplied_from_site = 'None'::text) THEN NULL::integer WHEN (new.supplied_from_site = ''::text) THEN NULL::integer ELSE public.getitemsiteid(new.supplied_from_site, (new.item_number)::text) END, COALESCE(new.notes, ''::text), 0, COALESCE(new.require_warranty, false), COALESCE(new.auto_register, false), false, 0, CASE WHEN (new.planning_system = 'None'::text) THEN 'N'::text WHEN (new.planning_system = 'MPS'::text) THEN 'S'::text ELSE 'M'::text END); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO itemsitecomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'IS'::text, public.getitemsiteid((new.site)::text, (new.item_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO itemsource DO INSTEAD INSERT INTO public.itemsrc (itemsrc_item_id, itemsrc_vend_id, itemsrc_vend_item_number, itemsrc_vend_item_descrip, itemsrc_comments, itemsrc_vend_uom, itemsrc_invvendoruomratio, itemsrc_minordqty, itemsrc_multordqty, itemsrc_leadtime, itemsrc_ranking, itemsrc_active, itemsrc_default, itemsrc_manuf_name, itemsrc_manuf_item_number, itemsrc_manuf_item_descrip, itemsrc_upccode, itemsrc_contrct_id, itemsrc_effective, itemsrc_expires) VALUES (public.getitemid((new.item_number)::text), public.getvendid((new.vendor)::text), new.vendor_item_number, COALESCE(new.vendor_description, ''::text), COALESCE(new.notes, ''::text), new.vendor_uom, new.inventory_vendor_uom_ratio, new.minimum_order, new.order_multiple, new.lead_time, new.vendor_ranking, COALESCE(new.active, true), COALESCE(new.itemsrc_default, true), COALESCE(new.manufacturer_name, ''::text), COALESCE(new.manufacturer_item_number, ''::text), new.manufacturer_description, new.bar_code, public.getcontrctid(new.contract_number), COALESCE(public.getcontrcteffective(new.contract_number), new.effective_date), COALESCE(public.getcontrctexpires(new.contract_number), new.expires_date)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO itemsourceprice DO INSTEAD INSERT INTO public.itemsrcp (itemsrcp_itemsrc_id, itemsrcp_qtybreak, itemsrcp_price, itemsrcp_curr_id, itemsrcp_updated, itemsrcp_dropship, itemsrcp_warehous_id, itemsrcp_type, itemsrcp_discntprcnt, itemsrcp_fixedamtdiscount) VALUES (public.getitemsrcid((new.item_number)::text, (new.vendor)::text), new.qty_break, new.price_per_unit, public.getcurrid((new.currency)::text), now(), COALESCE(new.dropship_only, false), CASE WHEN (new.pricing_site = 'All'::text) THEN (-1) ELSE COALESCE(public.getwarehousid(new.pricing_site, 'ALL'::text), (-1)) END, CASE WHEN (new.pricing_type = 'Discount'::text) THEN 'D'::text ELSE 'N'::text END, (COALESCE(new.discount_percent, 0.0) / 100.0), new.discount_fixed_amount); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO itemsubstitute DO INSTEAD INSERT INTO public.itemsub (itemsub_parent_item_id, itemsub_sub_item_id, itemsub_uomratio, itemsub_rank) VALUES (public.getitemid((new.root_item_number)::text), public.getitemid((new.substitute_item_number)::text), COALESCE(new.sub_parent_uom_ratio, (1)::numeric), COALESCE(new.ranking, 1)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO itemtaxtype DO INSTEAD INSERT INTO public.itemtax (itemtax_item_id, itemtax_taxzone_id, itemtax_taxtype_id) VALUES (public.getitemid((new.item_number)::text), CASE WHEN ((new.tax_zone)::text = 'Any'::text) THEN NULL::integer ELSE public.gettaxzoneid((new.tax_zone)::text) END, public.gettaxtypeid(new.tax_type)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO itemuomconversion DO INSTEAD SELECT public.saveitemuomconv(public.getitemid((new.item_number)::text), COALESCE(public.getuomid((new.uom)::text), (SELECT item.item_inv_uom_id FROM public.item WHERE (item.item_id = public.getitemid((new.item_number)::text)))), COALESCE(new.uom_value, (1)::numeric), COALESCE(public.getuomid(new.per_uom), (SELECT item.item_inv_uom_id FROM public.item WHERE (item.item_id = public.getitemid((new.item_number)::text)))), COALESCE(new.per_uom_value, (1)::numeric), COALESCE(new.fractional, false), public.getuomtypeid(new.selected_types)) AS saveitemuomconv; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO journalentry DO INSTEAD SELECT public.insertgltransaction('G/L'::text, 'JE'::text, new.doc_number, new.notes, public.getglaccntid(new.credit), public.getglaccntid(new.debit), (-1), public.currtobase(public.getcurrid((new.currency)::text), new.amount, new.dist_date), new.dist_date) AS insertgltransaction; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO location DO INSTEAD INSERT INTO public.location (location_warehous_id, location_name, location_descrip, location_restrict, location_netable, location_usable, location_whsezone_id, location_aisle, location_rack, location_bin) VALUES (public.getwarehousid((new.site)::text, 'ACTIVE'::text), COALESCE(new.location, ''::character varying), COALESCE(new.description, ''::text), COALESCE(new.restricted, false), COALESCE(new.netable, true), COALESCE(new.usable, true), public.getwhsezoneid((new.site)::text, new.zone), COALESCE(new.aisle, ''::character varying), COALESCE(new.rack, ''::character varying), COALESCE(new.bin, ''::character varying)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO misccounttag DO INSTEAD SELECT public.postmisccount(public.getitemsiteid(COALESCE(new.site, (SELECT whsinfo.warehous_code FROM public.usrpref, public.whsinfo WHERE (((usrpref.usrpref_username = public.geteffectivextuser()) AND (usrpref.usrpref_name = 'PreferredWarehouse'::text)) AND (whsinfo.warehous_id = (usrpref.usrpref_value)::integer)))), new.item_number), new.quantity, new.comment) AS postmisccount; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO pricingschedule DO INSTEAD INSERT INTO public.ipshead (ipshead_id, ipshead_name, ipshead_descrip, ipshead_effective, ipshead_expires, ipshead_curr_id, ipshead_updated) VALUES (nextval('public.ipshead_ipshead_id_seq'::regclass), new.name, new.description, CASE WHEN (new.effective = 'Always'::text) THEN '1970-01-01'::date ELSE (COALESCE(new.effective, '1970-01-01'::text))::date END, CASE WHEN (new.expires = 'Never'::text) THEN '2100-01-01'::date ELSE (COALESCE(new.expires, '2100-01-01'::text))::date END, COALESCE(public.getcurrid((new.currency)::text), public.basecurrid()), now()); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO pricingscheduleassign DO INSTEAD INSERT INTO public.ipsass (ipsass_ipshead_id, ipsass_cust_id, ipsass_custtype_id, ipsass_custtype_pattern, ipsass_shipto_id, ipsass_shipto_pattern) VALUES (public.getipsheadid((new.pricing_schedule)::text), CASE WHEN ((new.customer_number)::text = 'Any'::text) THEN (-1) ELSE public.getcustid((new.customer_number)::text) END, CASE WHEN ((new.customer_type)::text = 'N/A'::text) THEN (-1) ELSE public.getcusttypeid((new.customer_type)::text) END, new.customer_type_pattern, CASE WHEN (((new.customer_number)::text = 'Any'::text) OR ((new.customer_shipto)::text = 'Any'::text)) THEN (-1) ELSE public.getshiptoid((new.customer_number)::text, (new.customer_shipto)::text) END, new.customer_shipto_pattern); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO pricingscheduleitem DO INSTEAD SELECT CASE WHEN ((new.type)::text = 'Item'::text) THEN public.saveipsitem(NULL::integer, public.getipsheadid((new.pricing_schedule)::text), public.getitemid((new.item_number)::text), COALESCE(new.qty_break, (0)::numeric), COALESCE(new.price, (0)::numeric), public.getuomid((new.qty_uom)::text), public.getuomid((new.price_uom)::text), new.percent, new.fixedamt, CASE new.pricing_type WHEN 'Nominal'::text THEN 'N'::text WHEN 'Discount'::text THEN 'D'::text WHEN 'Markup'::text THEN 'M'::text ELSE '?'::text END) WHEN ((new.type)::text = 'Product Category'::text) THEN public.saveipsprodcat(NULL::integer, public.getipsheadid((new.pricing_schedule)::text), public.getprodcatid((new.product_category)::text), new.qty_break, new.percent, new.fixedamt, CASE new.pricing_type WHEN 'Nominal'::text THEN 'N'::text WHEN 'Discount'::text THEN 'D'::text WHEN 'Markup'::text THEN 'M'::text ELSE '?'::text END) ELSE NULL::integer END AS "case"; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO pricingscheduleitemchar DO INSTEAD INSERT INTO public.ipsitemchar (ipsitemchar_ipsitem_id, ipsitemchar_char_id, ipsitemchar_value, ipsitemchar_price) VALUES (public.getipsitemid((new.pricing_schedule)::text, (new.item_number)::text, new.qty_break, (new.qty_uom)::text, (new.price_uom)::text), public.getcharid((new.characteristic)::text, 'I'::text), new.value, COALESCE(new.price, (0)::numeric)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO project DO INSTEAD INSERT INTO public.prj (prj_number, prj_name, prj_descrip, prj_owner_username, prj_username, prj_so, prj_wo, prj_po, prj_status, prj_due_date, prj_assigned_date, prj_start_date, prj_completed_date) VALUES (new.number, COALESCE(new.name, ''::text), COALESCE(new.description, ''::text), COALESCE(new.owner, public.geteffectivextuser()), COALESCE(new.assigned_to, public.geteffectivextuser()), COALESCE(new.sales_orders, true), COALESCE(new.work_orders, true), COALESCE(new.purchase_orders, true), CASE WHEN (new.status = 'In-Process'::text) THEN 'O'::text WHEN (new.status = 'Completed'::text) THEN 'C'::text ELSE 'P'::text END, new.due, new.assigned, new.started, new.completed); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO projectcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'J'::text, public.getprjid((new.project_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO prospect DO INSTEAD INSERT INTO public.prospect (prospect_number, prospect_name, prospect_active, prospect_cntct_id, prospect_taxzone_id, prospect_salesrep_id, prospect_warehous_id, prospect_comments) VALUES (upper((new.prospect_number)::text), COALESCE(new.prospect_name, ''::text), COALESCE(new.active, true), public.savecntct(public.getcntctid(new.contact_number), new.contact_number, public.saveaddr(public.getaddrid(new.contact_address_number), new.contact_address_number, new.contact_address1, new.contact_address2, new.contact_address3, new.contact_city, new.contact_state, new.contact_postalcode, new.contact_country, new.contact_address_change), new.contact_honorific, new.contact_first, new.contact_middle, new.contact_last, new.contact_suffix, new.contact_voice, new.contact_alternate, new.contact_fax, new.contact_email, new.contact_web, new.contact_job_title, new.contact_change), public.gettaxzoneid(new.default_tax_zone), public.getsalesrepid(new.sales_rep), public.getwarehousid(new.site_code, 'ACTIVE'::text), COALESCE(new.notes, ''::text)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO purchaseline DO INSTEAD INSERT INTO public.poitem (poitem_pohead_id, poitem_linenumber, poitem_duedate, poitem_itemsite_id, poitem_vend_item_descrip, poitem_qty_ordered, poitem_unitprice, poitem_vend_item_number, poitem_manuf_name, poitem_manuf_item_number, poitem_manuf_item_descrip, poitem_comments, poitem_expcat_id, poitem_freight, poitem_prj_id, poitem_bom_rev_id, poitem_boo_rev_id) VALUES (public.getpoheadid((new.order_number)::text), new.line_number, new.due_date, public.getitemsiteid(COALESCE(new.site, (SELECT whsinfo.warehous_code FROM (public.pohead JOIN public.whsinfo ON ((whsinfo.warehous_id = pohead.pohead_warehous_id))) WHERE (pohead.pohead_id = public.getpoheadid((new.order_number)::text))), (SELECT whsinfo.warehous_code FROM public.whsinfo WHERE (whsinfo.warehous_id = public.fetchprefwarehousid()))), new.item_number), new.vendor_description, new.qty_ordered, new.unit_price, new.vend_item_number, new.manufacturer_name, new.manufacturer_item_number, new.manufacturer_description, new.notes, public.getexpcatid(new.expense_category), new.freight, public.getprjid(new.project_number), public.getrevid('BOM'::text, new.item_number, new.bill_of_materials_revision), public.getrevid('BOO'::text, new.item_number, new.bill_of_operations_revision)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO purchaselinechar DO INSTEAD SELECT DISTINCT public.updatecharassignment('PI'::text, poitem.poitem_id, charass.charass_char_id, new.value) AS updatecharassignment FROM public.pohead, public.poitem, public.itemsite, public.item, public.charass, public."char" WHERE (((((((((pohead.pohead_number = (new.order_number)::text) AND (pohead.pohead_id = poitem.poitem_pohead_id)) AND (poitem.poitem_linenumber = new.line_number)) AND (poitem.poitem_itemsite_id = itemsite.itemsite_id)) AND (item.item_id = itemsite.itemsite_item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND ("char".char_id = charass.charass_char_id)) AND ("char".char_name = new.characteristic)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO purchaselinecomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) SELECT COALESCE(new.date, (('now'::text)::date)::timestamp with time zone) AS "coalesce", 'PI', poitem.poitem_id, COALESCE(new.username, public.geteffectivextuser()) AS "coalesce", public.getcmnttypeid(new.type) AS getcmnttypeid, new.text FROM public.poitem, public.pohead WHERE (((pohead.pohead_number = (new.order_number)::text) AND (poitem.poitem_pohead_id = pohead.pohead_id)) AND (poitem.poitem_linenumber = new.line_number)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO purchaseorder DO INSTEAD INSERT INTO public.pohead (pohead_number, pohead_orderdate, pohead_status, pohead_terms_id, pohead_taxzone_id, pohead_warehous_id, pohead_agent_username, pohead_vend_id, pohead_vendaddr_id, pohead_fob, pohead_shipvia, pohead_curr_id, pohead_freight, pohead_comments, pohead_dropship, pohead_vend_cntct_id, pohead_vend_cntct_honorific, pohead_vend_cntct_first_name, pohead_vend_cntct_middle, pohead_vend_cntct_last_name, pohead_vend_cntct_suffix, pohead_vend_cntct_phone, pohead_vend_cntct_title, pohead_vend_cntct_fax, pohead_vend_cntct_email, pohead_vendaddress1, pohead_vendaddress2, pohead_vendaddress3, pohead_vendcity, pohead_vendstate, pohead_vendzipcode, pohead_vendcountry, pohead_shipto_cntct_id, pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name, pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name, pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone, pohead_shipto_cntct_title, pohead_shipto_cntct_fax, pohead_shipto_cntct_email, pohead_shiptoaddress_id, pohead_shiptoaddress1, pohead_shiptoaddress2, pohead_shiptoaddress3, pohead_shiptocity, pohead_shiptostate, pohead_shiptozipcode, pohead_shiptocountry, pohead_cohead_id) SELECT new.order_number, COALESCE(new.order_date, ('now'::text)::date) AS "coalesce", 'U', COALESCE(public.gettermsid(new.terms), vendinfo.vend_terms_id) AS "coalesce", COALESCE(public.gettaxzoneid(new.tax_zone), vendinfo.vend_taxzone_id) AS "coalesce", COALESCE(public.getwarehousid(new.receiving_site, 'ALL'::text), public.fetchprefwarehousid()) AS "coalesce", COALESCE(new.purchasing_agent, public.geteffectivextuser()) AS "coalesce", public.getvendid(new.vendor_number) AS getvendid, CASE WHEN (new.alt_address = 'MAIN'::text) THEN NULL::integer ELSE public.getvendaddrid(new.vendor_number, new.alt_address) END AS getvendaddrid, COALESCE(new.fob, CASE WHEN (vendinfo.vend_fobsource = 'W'::bpchar) THEN (SELECT whsinfo.warehous_fob FROM public.whsinfo WHERE (whsinfo.warehous_id = COALESCE(public.getwarehousid(new.receiving_site, 'ALL'::text), public.fetchprefwarehousid()))) ELSE vendinfo.vend_fob END) AS "coalesce", COALESCE(new.ship_via, vendinfo.vend_shipvia) AS "coalesce", COALESCE(public.getcurrid((new.currency)::text), vendinfo.vend_curr_id) AS "coalesce", COALESCE(new.freight, (0)::numeric) AS "coalesce", new.notes, COALESCE(new.dropship, false) AS "coalesce", public.getcntctid(new.vend_contact_number) AS getcntctid, COALESCE(new.vend_cntct_honorific, ''::text) AS "coalesce", COALESCE(new.vend_cntct_first_name, ''::text) AS "coalesce", COALESCE(new.vend_cntct_middle, ''::text) AS "coalesce", COALESCE(new.vend_cntct_last_name, ''::text) AS "coalesce", COALESCE(new.vend_cntct_suffix, ''::text) AS "coalesce", COALESCE(new.vend_cntct_phone, ''::text) AS "coalesce", COALESCE(new.vend_cntct_title, ''::text) AS "coalesce", COALESCE(new.vend_cntct_fax, ''::text) AS "coalesce", COALESCE(new.vend_cntct_email, ''::text) AS "coalesce", COALESCE(new.vendaddress1, ''::text) AS "coalesce", COALESCE(new.vendaddress2, ''::text) AS "coalesce", COALESCE(new.vendaddress3, ''::text) AS "coalesce", COALESCE(new.vendcity, ''::text) AS "coalesce", COALESCE(new.vendstate, ''::text) AS "coalesce", COALESCE(new.vendzipcode, ''::text) AS "coalesce", COALESCE(new.vendcountry, ''::text) AS "coalesce", public.getcntctid(new.shipto_contact_number) AS getcntctid, COALESCE(new.shipto_cntct_honorific, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_first_name, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_middle, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_last_name, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_suffix, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_phone, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_title, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_fax, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_email, ''::text) AS "coalesce", public.getaddrid(new.shiptoaddress_number) AS getaddrid, COALESCE(new.shiptoaddress1, ''::text) AS "coalesce", COALESCE(new.shiptoaddress2, ''::text) AS "coalesce", COALESCE(new.shiptoaddress3, ''::text) AS "coalesce", COALESCE(new.shiptocity, ''::text) AS "coalesce", COALESCE(new.shiptostate, ''::text) AS "coalesce", COALESCE(new.shiptozipcode, ''::text) AS "coalesce", COALESCE(new.shiptocountry, ''::text) AS "coalesce", public.getcoheadid(new.sales_order_number) AS getcoheadid FROM public.vendinfo WHERE (vendinfo.vend_id = public.getvendid(new.vendor_number)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO purchaseordercomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, (('now'::text)::date)::timestamp with time zone), 'P'::text, public.getpoheadid((new.order_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO quote DO INSTEAD INSERT INTO public.quhead (quhead_number, quhead_cust_id, quhead_custponumber, quhead_quotedate, quhead_warehous_id, quhead_shipto_id, quhead_shiptoname, quhead_shiptoaddress1, quhead_shiptoaddress2, quhead_shiptoaddress3, quhead_salesrep_id, quhead_terms_id, quhead_fob, quhead_shipvia, quhead_shiptocity, quhead_shiptostate, quhead_shiptozipcode, quhead_freight, quhead_misc, quhead_ordercomments, quhead_shipcomments, quhead_shiptophone, quhead_billtoname, quhead_billtoaddress1, quhead_billtoaddress2, quhead_billtoaddress3, quhead_billtocity, quhead_billtostate, quhead_billtozip, quhead_misc_accnt_id, quhead_misc_descrip, quhead_commission, quhead_packdate, quhead_prj_id, quhead_billtocountry, quhead_shiptocountry, quhead_curr_id, quhead_taxzone_id, quhead_taxtype_id, quhead_imported, quhead_expire, quhead_status, quhead_saletype_id, quhead_shipzone_id) VALUES (new.quote_number, public.getcustid(new.customer_number, true), new.cust_po_number, new.quote_date, public.getwarehousid(new.site, 'SHIPPING'::text), public.getshiptoid(new.customer_number, new.shipto_number), new.shipto_name, new.shipto_address1, new.shipto_address2, new.shipto_address3, public.getsalesrepid(new.sales_rep), public.gettermsid(new.terms), new.fob, new.ship_via, new.shipto_city, new.shipto_state, new.shipto_postal_code, new.freight, new.misc_charge, new.order_notes, new.shipping_notes, new.shipto_phone, new.billto_name, new.billto_address1, new.billto_address2, new.billto_address3, new.billto_city, new.billto_state, new.billto_postal_code, public.getglaccntid(new.misc_account_number), new.misc_charge_description, new.commission, new.pack_date, public.getprjid(new.project_number), new.billto_country, new.shipto_country, public.getcurrid((new.currency)::text), public.gettaxzoneid(new.tax_zone), public.gettaxtypeid(new.tax_type), true, new.expire_date, CASE WHEN (new.status = 'Converted'::text) THEN 'C'::text ELSE 'O'::text END, public.getsaletypeid(new.sale_type), public.getshipzoneid(new.shipto_shipzone)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO quotecomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, (('now'::text)::date)::timestamp with time zone), 'Q'::text, public.getquoteid(new.quote_number), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO quoteline DO INSTEAD INSERT INTO public.quitem (quitem_quhead_id, quitem_linenumber, quitem_itemsite_id, quitem_scheddate, quitem_qtyord, quitem_unitcost, quitem_price, quitem_custprice, quitem_memo, quitem_imported, quitem_custpn, quitem_createorder, quitem_order_warehous_id, quitem_item_id, quitem_prcost, quitem_taxtype_id, quitem_qty_uom_id, quitem_qty_invuomratio, quitem_price_uom_id, quitem_price_invuomratio) SELECT public.getquoteid(new.quote_number) AS getquoteid, COALESCE(new.line_number, (SELECT (COALESCE(max(quitem.quitem_linenumber), 0) + 1) FROM public.quitem WHERE (quitem.quitem_quhead_id = public.getquoteid(new.quote_number)))) AS "coalesce", itemsite.itemsite_id, COALESCE(new.scheduled_date, (SELECT min(quitem.quitem_scheddate) AS min FROM public.quitem WHERE (quitem.quitem_quhead_id = public.getquoteid(new.quote_number)))) AS "coalesce", new.qty_ordered, public.stdcost(item.item_id) AS stdcost, COALESCE(new.net_unit_price, public.itemprice(public.getitemid(new.item_number), quhead.quhead_cust_id, quhead.quhead_shipto_id, new.qty_ordered, quhead.quhead_curr_id, quhead.quhead_quotedate)) AS "coalesce", public.itemprice(public.getitemid(new.item_number), quhead.quhead_cust_id, quhead.quhead_shipto_id, new.qty_ordered, quhead.quhead_curr_id, quhead.quhead_quotedate) AS itemprice, COALESCE(new.notes, ''::text) AS "coalesce", true AS bool, new.customer_pn, COALESCE(new.create_order, false) AS "coalesce", COALESCE(public.getwarehousid(new.supplying_site, 'SHIPPING'::text), itemsite.itemsite_warehous_id) AS "coalesce", public.getitemid(new.item_number) AS getitemid, COALESCE(new.overwrite_po_price, (0)::numeric) AS "coalesce", COALESCE(public.gettaxtypeid(new.tax_type), public.getitemtaxtype(itemsite.itemsite_item_id, quhead.quhead_taxzone_id)) AS "coalesce", COALESCE(public.getuomid(new.qty_uom), item.item_inv_uom_id) AS "coalesce", public.itemuomtouomratio(item.item_id, COALESCE(public.getuomid(new.qty_uom), item.item_inv_uom_id), item.item_inv_uom_id) AS itemuomtouomratio, COALESCE(public.getuomid(new.price_uom), item.item_price_uom_id) AS "coalesce", public.itemuomtouomratio(item.item_id, COALESCE(public.getuomid(new.price_uom), item.item_price_uom_id), item.item_price_uom_id) AS itemuomtouomratio FROM public.quhead, public.itemsite, public.item, public.whsinfo WHERE ((quhead.quhead_number = new.quote_number) AND (((((((itemsite.itemsite_warehous_id = whsinfo.warehous_id) AND (itemsite.itemsite_item_id = item.item_id)) AND itemsite.itemsite_active) AND (item.item_number = new.item_number)) AND whsinfo.warehous_active) AND whsinfo.warehous_shipping) AND (whsinfo.warehous_code = COALESCE(new.sold_from_site, (SELECT whsinfo.warehous_code FROM public.usrpref, public.whsinfo WHERE (((usrpref.usrpref_username = public.geteffectivextuser()) AND (usrpref.usrpref_name = 'PreferredWarehouse'::text)) AND (whsinfo.warehous_id = (usrpref.usrpref_value)::integer))))))); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO quotelinechar DO INSTEAD SELECT DISTINCT public.updatecharassignment('QI'::text, quitem.quitem_id, charass.charass_char_id, new.value) AS updatecharassignment FROM public.quhead, public.quitem, public.itemsite, public.item, public.charass, public."char" WHERE (((((((((quhead.quhead_number = new.quote_number) AND (quhead.quhead_id = quitem.quitem_quhead_id)) AND (quitem.quitem_linenumber = new.line_number)) AND (quitem.quitem_itemsite_id = itemsite.itemsite_id)) AND (item.item_id = itemsite.itemsite_item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND ("char".char_id = charass.charass_char_id)) AND ("char".char_name = new.characteristic)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO quotelinecomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, (('now'::text)::date)::timestamp with time zone), 'QI'::text, public.getquotelineitemid(new.quote_number, new.line_number), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO salescredit DO INSTEAD INSERT INTO public.aropenalloc (aropenalloc_aropen_id, aropenalloc_doctype, aropenalloc_doc_id, aropenalloc_amount, aropenalloc_curr_id) VALUES (public.getaropenid(new.customer_number, 'C'::bpchar, new.cm_number), 'S'::bpchar, public.getcoheadid(new.so_number), new.amount, public.getcurrid((new.currency)::text)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO saleshistory DO INSTEAD INSERT INTO public.cohist (cohist_cust_id, cohist_itemsite_id, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_orderdate, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_shipto_id, cohist_salesrep_id, cohist_duedate, cohist_imported, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_commission, cohist_commissionpaid, cohist_unitcost, cohist_misc_type, cohist_misc_descrip, cohist_misc_id, cohist_doctype, cohist_promisedate, cohist_ponumber, cohist_curr_id, cohist_sequence, cohist_taxzone_id, cohist_taxtype_id) VALUES (public.getcustid(new.customer_number), public.getitemsiteid(new.site_code, new.item_number), new.ship_date, new.ship_via, new.order_number, new.order_date, new.invoice_number, new.invoice_date, new.quantity_shipped, COALESCE(new.unit_price, (0)::numeric), public.getshiptoid(new.customer_number, new.shipto_number), public.getsalesrepid(new.sales_rep), new.due_date, true, new.billto_name, new.billto_address1, new.billto_address2, new.billto_address3, new.billto_city, new.billto_state, new.billto_zip, new.shipto_name, new.shipto_address1, new.shipto_address2, new.shipto_address3, new.shipto_city, new.shipto_state, new.shipto_zip, COALESCE(new.commission, (0)::numeric), COALESCE(new.commission_paid, false), COALESCE(new.unit_cost, (0)::numeric), CASE WHEN (new.misc_type = 'Misc. Charge'::text) THEN 'M'::text WHEN (new.misc_type = 'Freight'::text) THEN 'F'::text ELSE NULL::text END, new.misc_description, CASE WHEN (new.misc_type = 'Misc. Charge'::text) THEN public.getglaccntid(new.misc_info) ELSE NULL::integer END, CASE WHEN (new.document_type = 'Invoice'::text) THEN 'I'::text WHEN (new.document_type = 'Credit Memo'::text) THEN 'C'::text ELSE NULL::text END, new.promise_date, new.purchase_order_number, COALESCE(public.getcurrid((new.currency)::text), public.basecurrid()), new.gl_sequence, public.gettaxzoneid(new.tax_zone), public.gettaxtypeid(new.tax_type)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO saleslinechar DO INSTEAD SELECT DISTINCT public.updatecharassignment('SI'::text, coitem.coitem_id, charass.charass_char_id, new.value, public.itemcharprice(item.item_id, "char".char_id, new.value, cohead.cohead_cust_id, cohead.cohead_shipto_id, coitem.coitem_qtyord, cohead.cohead_curr_id, cohead.cohead_orderdate)) AS updatecharassignment FROM public.cohead, public.coitem, public.itemsite, public.item, public.charass, public."char" WHERE (((((((((cohead.cohead_number = (new.order_number)::text) AND (cohead.cohead_id = coitem.coitem_cohead_id)) AND (coitem.coitem_id = public.getcoitemid((new.order_number)::text, new.line_number))) AND (coitem.coitem_itemsite_id = itemsite.itemsite_id)) AND (item.item_id = itemsite.itemsite_item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND ("char".char_id = charass.charass_char_id)) AND ("char".char_name = new.characteristic)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO saleslinecomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, (('now'::text)::date)::timestamp with time zone), 'SI'::text, public.getcoitemid((new.order_number)::text, new.line_number), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO salesorder DO INSTEAD INSERT INTO public.cohead (cohead_number, cohead_cust_id, cohead_custponumber, cohead_orderdate, cohead_warehous_id, cohead_shipto_id, cohead_shiptoname, cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3, cohead_salesrep_id, cohead_terms_id, cohead_fob, cohead_shipvia, cohead_shiptocity, cohead_shiptostate, cohead_shiptozipcode, cohead_freight, cohead_calcfreight, cohead_misc, cohead_imported, cohead_ordercomments, cohead_shipcomments, cohead_shiptophone, cohead_shipchrg_id, cohead_shipform_id, cohead_billtoname, cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, cohead_billtocity, cohead_billtostate, cohead_billtozipcode, cohead_misc_accnt_id, cohead_misc_descrip, cohead_commission, cohead_holdtype, cohead_packdate, cohead_prj_id, cohead_shipcomplete, cohead_billtocountry, cohead_shiptocountry, cohead_curr_id, cohead_taxzone_id, cohead_shipto_cntct_id, cohead_shipto_cntct_honorific, cohead_shipto_cntct_first_name, cohead_shipto_cntct_middle, cohead_shipto_cntct_last_name, cohead_shipto_cntct_suffix, cohead_shipto_cntct_phone, cohead_shipto_cntct_title, cohead_shipto_cntct_fax, cohead_shipto_cntct_email, cohead_billto_cntct_id, cohead_billto_cntct_honorific, cohead_billto_cntct_first_name, cohead_billto_cntct_middle, cohead_billto_cntct_last_name, cohead_billto_cntct_suffix, cohead_billto_cntct_phone, cohead_billto_cntct_title, cohead_billto_cntct_fax, cohead_billto_cntct_email, cohead_saletype_id, cohead_shipzone_id) SELECT new.order_number, public.getcustid(new.customer_number) AS getcustid, new.cust_po_number, new.order_date, public.getwarehousid(new.site, 'SHIPPING'::text) AS getwarehousid, public.getshiptoid(new.customer_number, new.shipto_number) AS getshiptoid, new.shipto_name, new.shipto_address1, new.shipto_address2, new.shipto_address3, public.getsalesrepid(new.sales_rep) AS getsalesrepid, public.gettermsid(new.terms) AS gettermsid, new.fob, new.ship_via, new.shipto_city, new.shipto_state, new.shipto_postal_code, CASE WHEN COALESCE(new.calculate_freight, public.fetchmetricbool('CalculateFreight'::text)) THEN (0)::numeric ELSE new.freight END AS freight, COALESCE(new.calculate_freight, public.fetchmetricbool('CalculateFreight'::text)) AS "coalesce", new.misc_charge, true AS bool, new.order_notes, new.shipping_notes, new.shipto_phone, public.getshipchrgid(new.shipping_chgs) AS getshipchrgid, public.getshipformid(new.shipping_form) AS getshipformid, new.billto_name, new.billto_address1, new.billto_address2, new.billto_address3, new.billto_city, new.billto_state, new.billto_postal_code, public.getglaccntid(new.misc_account_number) AS getglaccntid, new.misc_charge_description, new.commission, CASE WHEN (new.hold_type = 'Credit'::text) THEN 'C'::text WHEN (new.hold_type = 'Shipping'::text) THEN 'S'::text WHEN (new.hold_type = 'Packing'::text) THEN 'P'::text ELSE 'N'::text END AS "case", new.pack_date, public.getprjid(new.project_number) AS getprjid, new.ship_complete, new.billto_country, new.shipto_country, public.getcurrid((new.currency)::text) AS getcurrid, CASE WHEN (new.tax_zone = 'None'::text) THEN (-1) ELSE public.gettaxzoneid(new.tax_zone) END AS gettaxzoneid, public.getcntctid(new.shipto_contact_number) AS getcntctid, new.shipto_contact_honorific, new.shipto_contact_first, new.shipto_contact_middle, new.shipto_contact_last, new.shipto_contact_suffix, new.shipto_contact_phone, new.shipto_contact_title, new.shipto_contact_fax, new.shipto_contact_email, public.getcntctid(new.billto_contact_number) AS getcntctid, new.billto_contact_name, new.billto_contact_first, new.billto_contact_middle, new.billto_contact_last, new.billto_contact_suffix, new.billto_contact_phone, new.billto_contact_title, new.billto_contct_fax, new.billto_contact_email, public.getsaletypeid(new.sale_type) AS getsaletypeid, public.getshipzoneid(new.shipto_shipzone) AS getshipzoneid FROM public.custinfo WHERE (custinfo.cust_number = new.customer_number); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO salesordercomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, (('now'::text)::date)::timestamp with time zone), 'S'::text, public.getsalesorderid((new.order_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO salesrep DO INSTEAD INSERT INTO public.salesrep (salesrep_active, salesrep_number, salesrep_name, salesrep_commission, salesrep_method, salesrep_emp_id) VALUES (COALESCE(new.active, true), COALESCE(new.number, ''::character varying), COALESCE(new.name, ''::text), COALESCE((new.commission_percent * 0.01), (0)::numeric), ''::bpchar, public.getempid(new.employee)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO site DO INSTEAD INSERT INTO public.whsinfo (warehous_code, warehous_descrip, warehous_fob, warehous_active, warehous_counttag_prefix, warehous_counttag_number, warehous_bol_prefix, warehous_bol_number, warehous_shipping, warehous_useslips, warehous_usezones, warehous_aislesize, warehous_aislealpha, warehous_racksize, warehous_rackalpha, warehous_binsize, warehous_binalpha, warehous_locationsize, warehous_locationalpha, warehous_enforcearbl, warehous_default_accnt_id, warehous_shipping_commission, warehous_cntct_id, warehous_addr_id, warehous_taxzone_id, warehous_transit, warehous_shipform_id, warehous_shipvia_id, warehous_shipcomments, warehous_costcat_id, warehous_sitetype_id, warehous_sequence) VALUES (COALESCE(new.code, ''::character varying), COALESCE(new.description, ''::text), CASE WHEN new.inventory_type THEN COALESCE(new.default_fob, ''::text) ELSE ''::text END, COALESCE(new.active, true), CASE WHEN new.inventory_type THEN COALESCE(new.next_count_tag_prefix, ''::text) ELSE ''::text END, CASE WHEN new.inventory_type THEN COALESCE(new.next_count_tag_number, 0) ELSE 0 END, CASE WHEN new.inventory_type THEN COALESCE(new.next_bill_of_lading_prefix, ''::text) ELSE ''::text END, CASE WHEN new.inventory_type THEN COALESCE(new.next_bill_of_lading_number, 0) ELSE 0 END, CASE WHEN new.inventory_type THEN COALESCE(new.shipping_site, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.force_the_use_of_count_slips, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.force_the_use_of_zones, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.aisle_size, 0) ELSE 0 END, CASE WHEN new.inventory_type THEN COALESCE(new.aisle_allow_alpha_characters, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.rack_size, 0) ELSE 0 END, CASE WHEN new.inventory_type THEN COALESCE(new.rack_allow_alpha_characters, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.bin_size, 0) ELSE 0 END, CASE WHEN new.inventory_type THEN COALESCE(new.bin_allow_alpha_characters, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.location_size, 0) ELSE 0 END, CASE WHEN new.inventory_type THEN COALESCE(new.location_allow_alpha_characters, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.enforce_arbl_naming_convention, false) ELSE false END, COALESCE(public.getglaccntid(new.post_unassigned_transactions_to), (-1)), CASE WHEN new.inventory_type THEN COALESCE((new.shipping_commission * 0.01), (0)::numeric) ELSE (0)::numeric END, public.savecntct(public.getcntctid(new.contact_number), new.contact_number, NULL::integer, new.honorific, new.first, new.middle, new.last, new.suffix, new.phone, NULL::text, new.fax, new.email, NULL::text, new.job_title, new.contact_change), public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.address_change), CASE WHEN new.inventory_type THEN COALESCE(public.gettaxzoneid(new.tax_zone), (-1)) ELSE NULL::integer END, CASE WHEN new.inventory_type THEN false WHEN new.transit_type THEN true ELSE false END, CASE WHEN new.transit_type THEN COALESCE((public.getshipformid(new.default_shipping_form))::numeric, public.fetchmetricvalue('DefaultShipFormId'::text)) ELSE NULL::numeric END, CASE WHEN new.transit_type THEN COALESCE((public.getshipviaid(new.default_ship_via))::numeric, public.fetchmetricvalue('DefaultShipViaId'::text)) ELSE NULL::numeric END, CASE WHEN new.transit_type THEN COALESCE(new.shipping_comments, ''::text) ELSE ''::text END, CASE WHEN new.transit_type THEN COALESCE(public.getcostcatid(new.default_cost_category), (-1)) ELSE NULL::integer END, COALESCE(public.getsitetypeid(new.type), (-1)), COALESCE(new.scheduling_sequence, 0)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO sitezone DO INSTEAD INSERT INTO public.whsezone (whsezone_warehous_id, whsezone_name, whsezone_descrip) VALUES (public.getwarehousid((new.site)::text, 'ACTIVE'::text), COALESCE(new.name, ''::character varying), COALESCE(new.description, ''::text)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO task DO INSTEAD INSERT INTO public.prjtask (prjtask_prj_id, prjtask_number, prjtask_name, prjtask_descrip, prjtask_owner_username, prjtask_username, prjtask_hours_budget, prjtask_hours_actual, prjtask_exp_budget, prjtask_exp_actual, prjtask_status, prjtask_due_date, prjtask_assigned_date, prjtask_start_date, prjtask_completed_date) VALUES (public.getprjid(new.project_number), new.number, COALESCE(new.name, ''::text), COALESCE(new.description, ''::text), COALESCE(new.owner, public.geteffectivextuser()), COALESCE(new.assigned_to, public.geteffectivextuser()), COALESCE(new.hours_budgeted, (0)::numeric), COALESCE(new.hours_actual, (0)::numeric), COALESCE(new.expenses_budgeted, (0)::numeric), COALESCE(new.expenses_actual, (0)::numeric), CASE WHEN (new.status = 'In-Process'::text) THEN 'O'::text WHEN (new.status = 'Completed'::text) THEN 'C'::text ELSE 'P'::text END, new.due, new.assigned, new.started, new.completed); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO taskcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'TA'::text, public.getprjtaskid((new.project_number)::text, (new.task_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO todo DO INSTEAD SELECT public.createtodoitem(NULL::integer, new.assigned_to, COALESCE(new.task_name, ''::text), COALESCE(new.description, ''::text), public.getincidentid(new.incident), COALESCE(public.getincdtcrmacctid(new.incident), public.getcrmacctid(new.account)), public.getopheadid(new.opportunity), CASE WHEN (new.date_started > ''::text) THEN (new.date_started)::date ELSE NULL::date END, CASE WHEN (new.date_due > ''::text) THEN (new.date_due)::date ELSE NULL::date END, (CASE WHEN (new.status = 'Pending Input'::text) THEN 'P'::text WHEN (new.status = 'Deferred'::text) THEN 'D'::text ELSE 'N'::text END)::bpchar, CASE WHEN (new.date_assigned > ''::text) THEN (new.date_assigned)::date ELSE NULL::date END, CASE WHEN (new.date_completed > ''::text) THEN (new.date_completed)::date ELSE NULL::date END, public.getincdtpriorityid(new.priority), COALESCE(new.notes, ''::text), new.owner) AS createtodoitem; -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO vendor DO INSTEAD INSERT INTO public.vendinfo (vend_name, vend_lastpurchdate, vend_active, vend_po, vend_comments, vend_pocomments, vend_number, vend_1099, vend_exported, vend_fobsource, vend_fob, vend_terms_id, vend_shipvia, vend_vendtype_id, vend_qualified, vend_ediemail, vend_ediemailbody, vend_edisubject, vend_edifilename, vend_accntnum, vend_emailpodelivery, vend_restrictpurch, vend_edicc, vend_curr_id, vend_cntct1_id, vend_cntct2_id, vend_addr_id, vend_match, vend_taxzone_id, vend_ach_routingnumber, vend_ach_accntnumber, vend_accnt_id, vend_expcat_id, vend_tax_id) VALUES (COALESCE(new.vendor_name, ''::text), NULL::date, COALESCE(new.active, true), COALESCE(new.sells_purchase_order_items, false), COALESCE(new.notes, ''::text), COALESCE(new.po_comments, ''::text), COALESCE(new.vendor_number, ''::character varying), COALESCE(new.receives_1099, false), false, CASE WHEN (new.default_fob = 'Receiving Site'::text) THEN 'W'::text ELSE 'V'::text END, CASE WHEN (new.default_fob = 'Receiving Site'::text) THEN ''::text ELSE new.default_fob END, COALESCE((public.gettermsid(new.default_terms))::numeric, public.fetchmetricvalue('DefaultTerms'::text)), COALESCE(new.ship_via, public.fetchdefaultshipvia()), public.getvendtypeid(new.vendor_type), COALESCE(new.qualified, false), COALESCE(new.po_edi_email, ''::text), COALESCE(new.po_edi_emailbody, ''::text), COALESCE(new.po_edi_subject, ''::text), COALESCE(new.po_edi_filename, ''::text), COALESCE(new.account_number, ''::text), COALESCE(new.allow_email_po_delivery, false), COALESCE(new.may_only_sell_item_source, false), COALESCE(new.po_edi_cc, ''::text), COALESCE(public.getcurrid((new.default_currency)::text), public.basecurrid()), public.savecntct(public.getcntctid(new.contact1_number), new.contact1_number, NULL::integer, new.contact1_honorific, new.contact1_first, new.contact1_middle, new.contact1_last, new.contact1_suffix, new.contact1_voice, new.contact1_alternate, new.contact1_fax, new.contact1_email, new.contact1_web, new.contact1_job_title, new.contact1_change), public.savecntct(public.getcntctid(new.contact2_number), new.contact2_number, NULL::integer, new.contact2_honorific, new.contact2_first, new.contact2_middle, new.contact2_last, new.contact2_suffix, new.contact2_voice, new.contact2_alternate, new.contact2_fax, new.contact2_email, new.contact2_web, new.contact2_job_title, new.contact2_change), public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change), COALESCE(new.matching_vo_po_amounts, false), public.gettaxzoneid(new.default_tax_zone), '\x'::bytea, '\x'::bytea, COALESCE(public.getglaccntid(new.default_dist_gl_account), (-1)), COALESCE(public.getexpcatid(new.default_dist_expense_category), (-1)), COALESCE(public.gettaxid(new.default_dist_tax_code), (-1))); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO vendoraddress DO INSTEAD INSERT INTO public.vendaddrinfo (vendaddr_vend_id, vendaddr_code, vendaddr_name, vendaddr_comments, vendaddr_cntct_id, vendaddr_addr_id) VALUES (public.getvendid((new.vendor_number)::text), COALESCE(new.vendor_address_number, ''::character varying), COALESCE(new.vendor_address_name, ''::text), COALESCE(new.notes, ''::text), public.savecntct(public.getcntctid(new.contact_number), new.contact_number, public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change), new.contact_honorific, new.contact_first, new.contact_middle, new.contact_last, new.contact_suffix, new.contact_voice, new.contact_alternate, new.contact_fax, new.contact_email, new.contact_web, new.contact_job_title, new.contact_change), public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change)); -- -- Name: _INSERT; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO vendortype DO INSTEAD INSERT INTO public.vendtype (vendtype_code, vendtype_descrip) VALUES (new.code, COALESCE(new.description, ''::text)); -- -- Name: _INSERT_CHAR; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_INSERT_CHAR" AS ON INSERT TO purchaseline DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value) SELECT 'PI', poitem.poitem_id, "char".char_id, charass.charass_value FROM public.pohead, public.poitem, public.charass, public."char", public.itemsite, public.item WHERE (((((((((pohead.pohead_number = (new.order_number)::text) AND (poitem.poitem_pohead_id = pohead.pohead_id)) AND (poitem.poitem_linenumber = new.line_number)) AND (itemsite.itemsite_id = poitem.poitem_itemsite_id)) AND (itemsite.itemsite_item_id = item.item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND charass.charass_default) AND ("char".char_id = charass.charass_char_id)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO salesline DO INSTEAD UPDATE public.coitem SET coitem_status = new.status, coitem_scheddate = new.scheduled_date, coitem_promdate = new.promise_date, coitem_qtyord = new.qty_ordered, coitem_qty_uom_id = public.getuomid(new.qty_uom), coitem_qty_invuomratio = public.itemuomtouomratio(item.item_id, public.getuomid(new.qty_uom), item.item_inv_uom_id), coitem_price = new.net_unit_price, coitem_price_uom_id = public.getuomid(new.price_uom), coitem_price_invuomratio = public.itemuomtouomratio(item.item_id, public.getuomid(new.price_uom), item.item_price_uom_id), coitem_memo = new.notes, coitem_order_type = CASE WHEN (((NOT old.create_order) AND new.create_order) AND (item.item_type = 'M'::bpchar)) THEN 'W'::text WHEN ((((NOT old.create_order) AND new.create_order) AND (item.item_type = 'P'::bpchar)) AND itemsite.itemsite_createsopo) THEN 'P'::text WHEN (((NOT old.create_order) AND new.create_order) AND (item.item_type = 'P'::bpchar)) THEN 'R'::text ELSE NULL::text END, coitem_substitute_item_id = public.getitemid(new.substitute_for), coitem_prcost = new.overwrite_po_price, coitem_taxtype_id = CASE WHEN (new.tax_type = 'None'::text) THEN NULL::integer ELSE public.gettaxtypeid(new.tax_type) END, coitem_warranty = new.warranty, coitem_cos_accnt_id = public.getglaccntid(new.alternate_cos_account), coitem_rev_accnt_id = public.getglaccntid(new.alternate_rev_account) FROM (public.item JOIN public.itemsite ON ((item.item_id = itemsite.itemsite_item_id))) WHERE ((((item.item_number = old.item_number) AND (coitem.coitem_cohead_id = public.getcoheadid((old.order_number)::text))) AND (coitem.coitem_id = public.getcoitemid((old.order_number)::text, (old.line_number)::text))) AND (coitem.coitem_subnumber = 0)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO apmemo DO INSTEAD UPDATE public.apopen SET apopen_duedate = new.due_date, apopen_terms_id = public.gettermsid(new.terms), apopen_amount = new.amount, apopen_notes = new.notes WHERE ((apopen.apopen_docnumber = old.document_number) AND ((apopen.apopen_doctype)::text = CASE WHEN (old.document_type = 'Credit Memo'::text) THEN 'C'::text WHEN (old.document_type = 'Debit Memo'::text) THEN 'D'::text ELSE ''::text END)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO armemo DO INSTEAD UPDATE public.aropen SET aropen_duedate = new.due_date, aropen_terms_id = public.gettermsid(new.terms), aropen_salesrep_id = public.getsalesrepid(new.sales_rep), aropen_amount = new.amount, aropen_commission_due = new.commission_due, aropen_notes = new.notes, aropen_rsncode_id = public.getrsnid(new.reason_code) WHERE ((aropen.aropen_docnumber = old.document_number) AND ((aropen.aropen_doctype)::text = CASE WHEN (old.document_type = 'Credit Memo'::text) THEN 'C'::text WHEN (old.document_type = 'Debit Memo'::text) THEN 'D'::text ELSE ''::text END)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO physinvcount DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO account DO INSTEAD UPDATE public.crmacct SET crmacct_number = new.account_number, crmacct_parent_id = public.getcrmacctid(new.parent_account), crmacct_name = new.account_name, crmacct_active = new.active, crmacct_type = CASE WHEN (new.type = 'Individual'::text) THEN 'I'::text ELSE 'O'::text END, crmacct_cntct_id_1 = public.getcntctid(new.primary_contact_number), crmacct_cntct_id_2 = public.getcntctid(new.secondary_contact_number), crmacct_notes = new.notes WHERE (crmacct.crmacct_number = (old.account_number)::text); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO accountchar DO INSTEAD UPDATE public.charass SET charass_value = new.value WHERE (((charass.charass_target_type = 'CRMACCT'::text) AND (charass.charass_target_id = public.getcrmacctid((old.account_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'CRMACCT'::text))); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO accountcomment DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO accountfile DO INSTEAD UPDATE public.url SET url_title = new.title, url_url = new.url WHERE ((((url.url_source_id = public.getcrmacctid(old.account_number)) AND (url.url_source = 'CRMA'::text)) AND (url.url_title = old.title)) AND (url.url_url = old.url)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO accountimage DO INSTEAD UPDATE public.imageass SET imageass_image_id = public.getimageid(new.image_name) WHERE (((imageass.imageass_source_id = public.getcrmacctid(old.account_number)) AND (imageass.imageass_source = 'CRMA'::text)) AND (imageass.imageass_image_id = public.getimageid(old.image_name))); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO address DO INSTEAD SELECT public.saveaddr(public.getaddrid((new.address_number)::text), (new.address_number)::text, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.active, new.notes, new.change) AS saveaddr; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO addresschar DO INSTEAD UPDATE public.charass SET charass_value = new.value WHERE (((charass.charass_target_type = 'ADDR'::text) AND (charass.charass_target_id = public.getaddrid((old.address_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'ADDR'::text))); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO addresscomment DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO bom DO INSTEAD SELECT public.savebomhead(public.getitemid((new.item_number)::text), (new.revision)::text, new.revision_date, new.document_number, COALESCE(new.batch_size, (0)::numeric), new.total_qty_per) AS savebomhead; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO bomitem DO INSTEAD UPDATE public.bomitem SET bomitem_issuemethod = CASE WHEN (new.issue_method = 'Mixed'::text) THEN 'M'::text WHEN (new.issue_method = 'Push'::text) THEN 'S'::text WHEN (new.issue_method = 'Pull'::text) THEN 'L'::text ELSE NULL::text END, bomitem_uom_id = public.getuomid(new.issue_uom), bomitem_qtyper = new.qty_per, bomitem_scrap = new.scrap, bomitem_effective = CASE WHEN (new.effective = 'Always'::text) THEN public.startoftime() ELSE (new.effective)::date END, bomitem_expires = CASE WHEN (new.expires = 'Never'::text) THEN public.endoftime() ELSE (new.expires)::date END, bomitem_createwo = new.create_child_wo, bomitem_booitem_seq_id = COALESCE(public.getbooitemseqid((new.bom_item_number)::text, new.used_at), (-1)), bomitem_schedatwooper = new.schedule_at_wo_operation, bomitem_ecn = new.ecn_number, bomitem_subtype = CASE WHEN (new.substitutions = 'No'::text) THEN 'N'::text WHEN (new.substitutions = 'Item-Defined'::text) THEN 'I'::text WHEN (new.substitutions = 'BOM-Defined'::text) THEN 'B'::text ELSE NULL::text END, bomitem_rev_id = public.getrevid('BOM'::text, (new.bom_item_number)::text, (new.bom_revision)::text), bomitem_char_id = public.getcharid(new.characteristic, 'I'::text), bomitem_value = new.value, bomitem_notes = new.notes, bomitem_ref = new.reference WHERE (bomitem.bomitem_id = old.id); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO bomitemcomment DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO bomitemsubstitute DO INSTEAD UPDATE public.bomitemsub SET bomitemsub_uomratio = new.sub_parent_uom_ratio, bomitemsub_rank = new.ranking WHERE ((bomitemsub.bomitemsub_bomitem_id = old.bomitem_id) AND (bomitemsub.bomitemsub_item_id = public.getitemid((old.substitute_item_number)::text))); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO budget DO INSTEAD UPDATE public.budghead SET budghead_name = new.name, budghead_descrip = new.description WHERE (budghead.budghead_name = old.name); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO budgetentry DO INSTEAD UPDATE public.budgitem SET budgitem_amount = new.amount WHERE (((budgitem.budgitem_budghead_id = public.getbudgheadid(old.name)) AND (budgitem.budgitem_period_id = public.getperiodid(old.period_start))) AND (budgitem.budgitem_accnt_id = public.getglaccntid(old.account))); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO cashreceipt DO INSTEAD UPDATE public.cashrcpt SET cashrcpt_amount = new.amount_received, cashrcpt_number = new.cashreceipt_number, cashrcpt_fundstype = CASE WHEN ((new.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((new.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((new.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((new.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((new.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((new.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((new.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((new.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((new.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, cashrcpt_docnumber = new.check_document_number, cashrcpt_bankaccnt_id = public.getbankaccntid(new.post_to), cashrcpt_notes = new.notes, cashrcpt_distdate = CASE WHEN (new.distribution_date > ''::text) THEN (new.distribution_date)::date ELSE NULL::date END, cashrcpt_salescat_id = public.getsalescatid(new.sales_category), cashrcpt_curr_id = public.getcurrid((new.currency)::text), cashrcpt_usecustdeposit = CASE WHEN (new.apply_balance_as = 'Customer Deposit'::text) THEN true ELSE false END WHERE (cashrcpt.cashrcpt_id = public.getcashrcptid((old.customer_number)::text, CASE WHEN ((old.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((old.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((old.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((old.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((old.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((old.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((old.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((old.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((old.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (old.check_document_number)::text)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO cashreceiptapply DO INSTEAD UPDATE public.cashrcptitem SET cashrcptitem_amount = new.amount_to_apply, cashrcptitem_discount = new.cashrcptitem_discount WHERE ((cashrcptitem.cashrcptitem_cashrcpt_id = public.getcashrcptid((old.customer_number)::text, CASE WHEN ((old.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((old.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((old.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((old.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((old.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((old.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((old.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((old.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((old.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (old.check_document_number)::text)) AND (cashrcptitem.cashrcptitem_aropen_id = public.getaropenid((old.customer_number)::text, (old.doc_type)::bpchar, (old.doc_number)::text))); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO cashreceiptapplymisc DO INSTEAD UPDATE public.cashrcptmisc SET cashrcptmisc_accnt_id = public.getglaccntid((new.account)::text), cashrcptmisc_amount = new.amount_to_distribute, cashrcptmisc_notes = new.notes WHERE ((cashrcptmisc.cashrcptmisc_cashrcpt_id = public.getcashrcptid((old.customer_number)::text, CASE WHEN ((old.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((old.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((old.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((old.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((old.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((old.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((old.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((old.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((old.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (old.check_document_number)::text)) AND (cashrcptmisc.cashrcptmisc_accnt_id = public.getglaccntid((old.account)::text))); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO contact DO INSTEAD SELECT public.savecntct(public.getcntctid((new.contact_number)::text), (new.contact_number)::text, public.getcrmacctid(new.crm_account), public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.address_change), new.honorific, new.first, new.middle, new.last, new.suffix, new.initials, new.active, new.voice, new.alternate, new.fax, new.email, new.web, new.notes, new.job_title, new.contact_change) AS savecntct; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO contactchar DO INSTEAD UPDATE public.charass SET charass_value = new.value WHERE (((charass.charass_target_type = 'CNTCT'::text) AND (charass.charass_target_id = public.getcntctid(old.contact_number))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'CNTCT'::text))); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO contactcomment DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO creditmemo DO INSTEAD UPDATE public.cmhead SET cmhead_custponumber = new.customer_po_number, cmhead_docdate = new.memo_date, cmhead_shipto_id = COALESCE(public.getshiptoid(new.customer_number, new.shipto_number), (-1)), cmhead_shipto_name = new.shipto_name, cmhead_shipto_address1 = new.shipto_address1, cmhead_shipto_address2 = new.shipto_address2, cmhead_shipto_address3 = new.shipto_address3, cmhead_shipto_city = new.shipto_city, cmhead_shipto_state = new.shipto_state, cmhead_shipto_zipcode = new.shipto_postal_code, cmhead_shipto_country = new.shipto_country, cmhead_salesrep_id = public.getsalesrepid(new.sales_rep), cmhead_freight = COALESCE(new.freight, (0)::numeric), cmhead_misc = COALESCE(new.misc_charge_amount, (0)::numeric), cmhead_comments = new.notes, cmhead_billtoname = new.billto_name, cmhead_billtoaddress1 = new.billto_address1, cmhead_billtoaddress2 = new.billto_address2, cmhead_billtoaddress3 = new.billto_address3, cmhead_billtocity = new.billto_city, cmhead_billtostate = new.billto_state, cmhead_billtozip = new.billto_postal_code, cmhead_billtocountry = new.billto_country, cmhead_hold = COALESCE(new.on_hold, false), cmhead_commission = COALESCE(new.commission, (0)::numeric), cmhead_misc_accnt_id = COALESCE(public.getglaccntid(new.misc_charge_credit_account), (-1)), cmhead_misc_descrip = new.misc_charge_description, cmhead_rsncode_id = (SELECT rsncode.rsncode_id FROM public.rsncode WHERE (rsncode.rsncode_code = new.reason_code)), cmhead_curr_id = COALESCE(public.getcurrid((new.currency)::text), (-1)), cmhead_taxzone_id = public.gettaxzoneid(NULLIF(new.tax_zone, 'None'::text)) WHERE ((cmhead.cmhead_number = old.memo_number) AND (cmhead.cmhead_posted = false)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO creditmemoline DO INSTEAD SELECT public.updatecreditmemoline(new.*, old.*) AS updatecreditmemoline; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO custchar DO INSTEAD UPDATE public.charass SET charass_value = new.value WHERE (((charass.charass_target_type = 'C'::text) AND (charass.charass_target_id = public.getcustid((old.customer_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'C'::text))); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO custcomment DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO custcreditcard DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO customer DO INSTEAD UPDATE public.custinfo SET cust_active = new.active, cust_custtype_id = public.getcusttypeid(new.customer_type), cust_salesrep_id = public.getsalesrepid(new.sales_rep), cust_commprcnt = (new.commission * 0.01), cust_name = new.customer_name, cust_creditlmt = new.credit_limit, cust_creditrating = new.credit_rating, cust_backorder = new.accepts_backorders, cust_partialship = new.accepts_partial_shipments, cust_terms_id = public.gettermsid(new.default_terms), cust_discntprcnt = new.default_discount, cust_balmethod = CASE WHEN (new.balance_method = 'Balance Forward'::text) THEN 'B'::text WHEN (new.balance_method = 'Open Items'::text) THEN 'O'::text ELSE NULL::text END, cust_ffshipto = new.allow_free_form_shipto, cust_shipform_id = public.getshipformid(new.ship_form), cust_shipvia = new.ship_via, cust_blanketpos = new.uses_blanket_pos, cust_shipchrg_id = COALESCE(public.getshipchrgid(new.shipping_charges), (-1)), cust_creditstatus = CASE WHEN (new.credit_status = 'On Credit Warning'::text) THEN 'W'::text WHEN (new.credit_status = 'On Credit Hold'::text) THEN 'H'::text ELSE 'G'::text END, cust_comments = new.notes, cust_ffbillto = new.allow_free_form_billto, cust_usespos = new.uses_purchase_orders, cust_number = new.customer_number, cust_autoupdatestatus = new.credit_status_exceed_warn, cust_autoholdorders = new.credit_status_exceed_hold, cust_preferred_warehous_id = COALESCE(public.getwarehousid(new.preferred_selling_site, 'ACTIVE'::text), (-1)), cust_curr_id = public.getcurrid((new.default_currency)::text), cust_creditlmt_curr_id = public.getcurrid((new.credit_limit_currency)::text), cust_cntct_id = public.savecntct(public.getcntctid(new.billing_contact_number, false), new.billing_contact_number, public.saveaddr(public.getaddrid(new.billing_contact_address_number), new.billing_contact_address_number, new.billing_contact_address1, new.billing_contact_address2, new.billing_contact_address3, new.billing_contact_city, new.billing_contact_state, new.billing_contact_postalcode, new.billing_contact_country, new.billing_contact_address_change), new.billing_contact_honorific, new.billing_contact_first, new.billing_contact_middle, new.billing_contact_last, new.billing_contact_suffix, new.billing_contact_voice, new.billing_contact_alternate, new.billing_contact_fax, new.billing_contact_email, new.billing_contact_web, new.billing_contact_job_title, new.billing_contact_change), cust_corrcntct_id = public.savecntct(public.getcntctid(new.correspond_contact_number, false), new.correspond_contact_number, public.saveaddr(public.getaddrid(new.correspond_contact_address_number), new.correspond_contact_address_number, new.correspond_contact_address1, new.correspond_contact_address2, new.correspond_contact_address3, new.correspond_contact_city, new.correspond_contact_state, new.correspond_contact_postalcode, new.correspond_contact_country, new.correspond_contact_address_change), new.correspond_contact_honorific, new.correspond_contact_first, new.correspond_contact_middle, new.correspond_contact_last, new.correspond_contact_suffix, new.correspond_contact_voice, new.correspond_contact_alternate, new.correspond_contact_fax, new.correspond_contact_email, new.correspond_contact_web, new.correspond_contact_job_title, new.correspond_contact_change), cust_taxzone_id = public.gettaxzoneid(new.default_tax_zone), cust_gracedays = CASE WHEN (COALESCE(new.alternate_grace_days, 0) > 0) THEN new.alternate_grace_days ELSE NULL::integer END WHERE (custinfo.cust_id = public.getcustid((old.customer_number)::text)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO customertype DO INSTEAD UPDATE public.custtype SET custtype_code = new.code, custtype_descrip = new.description, custtype_char = new.enable_characteristics_profile WHERE (custtype.custtype_code = (old.code)::text); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO customertypechar DO INSTEAD UPDATE public.charass SET charass_value = new.value, charass_default = new.is_default WHERE (((charass.charass_target_type = 'CT'::text) AND (charass.charass_target_id = public.getcusttypeid((old.customer_type)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'CT'::text))); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO custshipto DO INSTEAD UPDATE public.shiptoinfo SET shipto_cust_id = public.getcustid((new.customer_number)::text), shipto_name = new.name, shipto_salesrep_id = public.getsalesrepid(new.sales_rep), shipto_comments = new.general_notes, shipto_shipcomments = new.shipping_notes, shipto_shipzone_id = public.getshipzoneid(new.zone), shipto_shipvia = new.ship_via, shipto_commission = (new.commission / (100)::numeric), shipto_shipform_id = public.getshipformid(new.ship_form), shipto_shipchrg_id = public.getshipchrgid(new.shipping_charges), shipto_active = new.active, shipto_default = new.default_flag, shipto_num = old.shipto_number, shipto_ediprofile_id = CASE WHEN (new.edi_profile = 'No EDI'::text) THEN (-1) WHEN (new.edi_profile = 'Use Customer Master'::text) THEN (-2) ELSE public.getediprofileid(new.edi_profile) END, shipto_cntct_id = public.savecntct(public.getcntctid(new.contact_number), new.contact_number, NULL::integer, new.honorific, new.first, new.middle, new.last, new.suffix, new.phone, NULL::text, new.fax, new.email, NULL::text, new.job_title, new.contact_change), shipto_addr_id = public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.address_change), shipto_taxzone_id = public.gettaxzoneid(new.tax_zone) WHERE (shiptoinfo.shipto_id = public.getshiptoid((old.customer_number)::text, (old.shipto_number)::text)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO custtax DO INSTEAD UPDATE public.taxreg SET taxreg_number = new.registration_number WHERE (((taxreg.taxreg_rel_type = 'C'::bpchar) AND (taxreg.taxreg_rel_id = public.getcustid((old.customer_number)::text))) AND (taxreg.taxreg_taxauth_id = public.gettaxauthid((old.tax_authority)::text))); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO employee DO INSTEAD UPDATE public.emp SET emp_code = new.code, emp_number = new.number, emp_active = new.active, emp_startdate = new.start_date, emp_cntct_id = public.savecntct(public.getcntctid(new.contact_number), new.contact_number, public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change), new.honorific, new.first, new.middle, new.last, new.suffix, new.voice, new.alternate, new.fax, new.email, new.web, new.job_title, new.contact_change), emp_warehous_id = public.getwarehousid(new.site, 'ALL'::text), emp_mgr_emp_id = (SELECT emp.emp_id FROM public.emp WHERE (emp.emp_code = new.manager_code)), emp_wage_type = CASE WHEN (new.wage_type = 'Hourly'::text) THEN 'H'::text WHEN (new.wage_type = 'Salaried'::text) THEN 'S'::text ELSE NULL::text END, emp_wage = new.wage, emp_wage_curr_id = COALESCE(public.getcurrid((new.wage_currency)::text), public.basecurrid()), emp_wage_period = CASE WHEN (new.wage_period = 'Hour'::text) THEN 'H'::text WHEN (new.wage_period = 'Day'::text) THEN 'D'::text WHEN (new.wage_period = 'Week'::text) THEN 'W'::text WHEN (new.wage_period = 'Biweek'::text) THEN 'BW'::text WHEN (new.wage_period = 'Month'::text) THEN 'M'::text WHEN (new.wage_period = 'Year'::text) THEN 'Y'::text ELSE NULL::text END, emp_dept_id = public.getdeptid(new.department), emp_shift_id = public.getshiftid(new.shift), emp_image_id = public.getimageid(new.image), emp_extrate = new.rate, emp_extrate_period = CASE WHEN (new.billing_period = 'Hour'::text) THEN 'H'::text WHEN (new.billing_period = 'Day'::text) THEN 'D'::text WHEN (new.billing_period = 'Week'::text) THEN 'W'::text WHEN (new.billing_period = 'Biweek'::text) THEN 'BW'::text WHEN (new.billing_period = 'Month'::text) THEN 'M'::text WHEN (new.billing_period = 'Year'::text) THEN 'Y'::text ELSE NULL::text END, emp_notes = COALESCE(new.notes, ''::text) WHERE (emp.emp_code = (old.code)::text); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO employeechar DO INSTEAD UPDATE public.charass SET charass_value = new.value WHERE (((charass.charass_target_type = 'EMP'::text) AND (charass.charass_target_id = public.getempid((old.employee_code)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'EMP'::text))); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO employeecomment DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO extshipmaint DO INSTEAD UPDATE public.shipdata SET shipdata_cohead_number = new.so_number, shipdata_shiphead_number = new.shipment_number, shipdata_void_ind = new.void, shipdata_shipper = new.shipper, shipdata_billing_option = new.billing_option, shipdata_weight = new.weight, shipdata_base_freight = new.base_freight, shipdata_base_freight_curr_id = public.getcurrid((new.base_freight_currency)::text), shipdata_total_freight = new.total_freight, shipdata_total_freight_curr_id = public.getcurrid((new.total_freight_currency)::text), shipdata_package_type = new.package_type, shipdata_cosmisc_tracknum = new.tracking_number, shipdata_cosmisc_packnum_tracknum = new.package_tracking_number, shipdata_lastupdated = new.last_updated WHERE ((((shipdata.shipdata_cohead_number = (old.so_number)::text) AND (shipdata.shipdata_shiphead_number = (old.shipment_number)::text)) AND (shipdata.shipdata_shipper = (old.shipper)::text)) AND (shipdata.shipdata_cosmisc_packnum_tracknum = (old.package_tracking_number)::text)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO freightpricingscheduleitem DO INSTEAD UPDATE public.ipsfreight SET ipsfreight_ipshead_id = public.getipsheadid((old.pricing_schedule)::text), ipsfreight_qtybreak = new.qty_break, ipsfreight_price = new.price, ipsfreight_type = CASE WHEN (new.price_type = 'Flat Rate'::text) THEN 'F'::text WHEN (new.price_type = 'Price Per UOM'::text) THEN 'P'::text ELSE NULL::text END, ipsfreight_warehous_id = CASE WHEN (new.from_site = 'Any'::text) THEN NULL::integer ELSE public.getwarehousid(new.from_site, 'All'::text) END, ipsfreight_shipzone_id = CASE WHEN (new.to_shipzone = 'Any'::text) THEN NULL::integer ELSE public.getshipzoneid(new.to_shipzone) END, ipsfreight_freightclass_id = CASE WHEN (new.freight_class = 'Any'::text) THEN NULL::integer ELSE public.getfreightclassid(new.freight_class) END, ipsfreight_shipvia = CASE WHEN (new.ship_via = 'Any'::text) THEN NULL::text ELSE new.ship_via END WHERE (((((((((ipsfreight.ipsfreight_ipshead_id = public.getipsheadid((old.pricing_schedule)::text)) AND (ipsfreight.ipsfreight_qtybreak = old.qty_break)) AND (ipsfreight.ipsfreight_price = old.price)) AND ((ipsfreight.ipsfreight_type)::text = CASE WHEN (old.price_type = 'Flat Rate'::text) THEN 'F'::text WHEN (old.price_type = 'Price Per UOM'::text) THEN 'P'::text ELSE NULL::text END)) AND ((ipsfreight.ipsfreight_warehous_id IS NULL) AND (old.from_site = 'Any'::text))) OR ((ipsfreight.ipsfreight_warehous_id = CASE WHEN (old.from_site = 'Any'::text) THEN 0 ELSE public.getwarehousid(old.from_site, 'All'::text) END) AND ((ipsfreight.ipsfreight_shipzone_id IS NULL) AND (old.to_shipzone = 'Any'::text)))) OR ((ipsfreight.ipsfreight_shipzone_id = CASE WHEN (old.to_shipzone = 'Any'::text) THEN 0 ELSE public.getshipzoneid(old.to_shipzone) END) AND ((ipsfreight.ipsfreight_freightclass_id IS NULL) AND (old.freight_class = 'Any'::text)))) OR ((ipsfreight.ipsfreight_freightclass_id = CASE WHEN (old.freight_class = 'Any'::text) THEN 0 ELSE public.getfreightclassid(old.freight_class) END) AND ((ipsfreight.ipsfreight_shipvia IS NULL) AND (old.ship_via = 'Any'::text)))) OR (ipsfreight.ipsfreight_shipvia = old.ship_via)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO glaccount DO INSTEAD UPDATE public.accnt SET accnt_number = new.account_number, accnt_descrip = new.description, accnt_comments = new.notes, accnt_profit = new.profit_center, accnt_sub = new.sub_account, accnt_type = CASE WHEN (new.type = 'Asset'::text) THEN 'A'::text WHEN (new.type = 'Liability'::text) THEN 'L'::text WHEN (new.type = 'Expense'::text) THEN 'E'::text WHEN (new.type = 'Revenue'::text) THEN 'R'::text WHEN (new.type = 'Equity'::text) THEN 'Q'::text ELSE NULL::text END, accnt_extref = new.ext_reference, accnt_company = new.company, accnt_forwardupdate = new.forward_update_trial_balances, accnt_subaccnttype_code = new.sub_type WHERE (accnt.accnt_id = public.getglaccntid((old.company)::text, (old.profit_center)::text, (old.account_number)::text, (old.sub_account)::text)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO incident DO INSTEAD UPDATE public.incdt SET incdt_crmacct_id = public.getcrmacctid(new.crm_account), incdt_cntct_id = public.savecntct(public.getcntctid(new.contact_number), new.contact_number, NULL::integer, new.honorific, new.first, new.middle, new.last, new.suffix, new.phone, NULL::text, new.fax, new.email, NULL::text, new.job_title, new.contact_change), incdt_descrip = new.notes, incdt_summary = new.description, incdt_item_id = public.getitemid(new.item_number), incdt_status = CASE WHEN (new.status = 'New'::text) THEN 'N'::text WHEN (new.status = 'Feedback'::text) THEN 'F'::text WHEN (new.status = 'Confirmed'::text) THEN 'C'::text WHEN (new.status = 'Assigned'::text) THEN 'A'::text WHEN (new.status = 'Resolved'::text) THEN 'R'::text WHEN (new.status = 'Closed'::text) THEN 'L'::text ELSE NULL::text END, incdt_assigned_username = new.assigned_to, incdt_incdtcat_id = public.getincdtcatid(new.category), incdt_incdtseverity_id = public.getincdtseverityid(new.severity), incdt_incdtpriority_id = public.getincdtpriorityid(new.priority), incdt_incdtresolution_id = public.getincdtresolutionid(new.resolution), incdt_lotserial = new.lot_serial_number, incdt_ls_id = public.getlotserialid(new.item_number, new.lot_serial_number) WHERE (incdt.incdt_id = public.getincidentid(old.incident_number)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO incidentchar DO INSTEAD UPDATE public.charass SET charass_value = new.value WHERE (((charass.charass_target_type = 'INCDT'::text) AND (charass.charass_target_id = public.getincidentid(old.incident_number))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'INCDT'::text))); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO incidentcomment DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO incidentfile DO INSTEAD UPDATE public.url SET url_title = new.title, url_url = new.url WHERE ((((url.url_source_id = public.getincidentid(old.incident_number)) AND (url.url_source = 'INCDT'::text)) AND (url.url_title = old.title)) AND (url.url_url = old.url)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO incidentimage DO INSTEAD UPDATE public.imageass SET imageass_image_id = public.getimageid(new.image_name) WHERE (((imageass.imageass_source_id = public.getincidentid(old.incident_number)) AND (imageass.imageass_source = 'INCDT'::text)) AND (imageass.imageass_image_id = public.getimageid(old.image_name))); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO invoice DO INSTEAD UPDATE public.invchead SET invchead_invcnumber = old.invoice_number, invchead_ordernumber = new.order_number, invchead_invcdate = new.invoice_date, invchead_shipdate = new.ship_date, invchead_orderdate = new.order_date, invchead_salesrep_id = public.getsalesrepid(new.sales_rep), invchead_commission = new.commission, invchead_taxzone_id = public.gettaxzoneid(NULLIF(new.tax_zone, 'None'::text)), invchead_terms_id = public.gettermsid(new.terms), invchead_cust_id = (SELECT public.getcustid(new.customer_number) AS getcustid), invchead_billto_name = new.billto_name, invchead_billto_address1 = new.billto_address1, invchead_billto_address2 = new.billto_address2, invchead_billto_address3 = new.billto_address3, invchead_billto_city = new.billto_city, invchead_billto_state = new.billto_state, invchead_billto_zipcode = new.billto_postal_code, invchead_billto_country = new.billto_country, invchead_billto_phone = new.billto_phone, invchead_shipto_id = COALESCE(public.getshiptoid(new.customer_number, new.shipto_number), (-1)), invchead_shipto_name = new.shipto_name, invchead_shipto_address1 = new.shipto_address1, invchead_shipto_address2 = new.shipto_address2, invchead_shipto_address3 = new.shipto_address3, invchead_shipto_city = new.shipto_city, invchead_shipto_state = new.shipto_state, invchead_shipto_zipcode = new.shipto_postal_code, invchead_shipto_country = new.shipto_country, invchead_shipto_phone = new.shipto_phone, invchead_ponumber = new.po_number, invchead_shipvia = new.ship_via, invchead_prj_id = COALESCE(public.getprjid(new.project_number), (-1)), invchead_fob = new.fob, invchead_misc_descrip = new.misc_charge_description, invchead_misc_amount = new.misc_charge, invchead_misc_accnt_id = COALESCE(public.getglaccntid(new.misc_charge_account_number), (-1)), invchead_freight = new.freight, invchead_curr_id = COALESCE(public.getcurrid((new.currency)::text), (-1)), invchead_payment = new.payment, invchead_notes = new.notes, invchead_saletype_id = public.getsaletypeid(new.sale_type), invchead_shipzone_id = public.getshipzoneid(new.shipto_shipzone) WHERE ((invchead.invchead_invcnumber = old.invoice_number) AND (invchead.invchead_posted = false)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO invoiceline DO INSTEAD SELECT public.updateinvoicelineitem(new.*, old.*) AS updateinvoicelineitem; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO item DO INSTEAD UPDATE public.item SET item_active = new.active, item_descrip1 = new.description1, item_descrip2 = new.description2, item_type = CASE WHEN (new.item_type = 'Purchased'::text) THEN 'P'::text WHEN (new.item_type = 'Manufactured'::text) THEN 'M'::text WHEN (new.item_type = 'Job'::text) THEN 'J'::text WHEN (new.item_type = 'Kit'::text) THEN 'K'::text WHEN (new.item_type = 'Phantom'::text) THEN 'F'::text WHEN (new.item_type = 'Reference'::text) THEN 'R'::text WHEN (new.item_type = 'Costing'::text) THEN 'S'::text WHEN (new.item_type = 'Tooling'::text) THEN 'T'::text WHEN (new.item_type = 'Outside Process'::text) THEN 'O'::text WHEN (new.item_type = 'Planning'::text) THEN 'L'::text WHEN (new.item_type = 'Breeder'::text) THEN 'B'::text WHEN (new.item_type = 'Co-Product'::text) THEN 'C'::text WHEN (new.item_type = 'By-Product'::text) THEN 'Y'::text ELSE NULL::text END, item_maxcost = new.maximum_desired_cost, item_classcode_id = public.getclasscodeid(new.class_code), item_inv_uom_id = public.getuomid(new.inventory_uom), item_picklist = new.pick_list_item, item_fractional = new.fractional, item_config = new.configured, item_sold = new.item_is_sold, item_prodcat_id = COALESCE(public.getprodcatid(new.product_category), (-1)), item_exclusive = new.exclusive, item_listprice = new.list_price, item_listcost = new.list_cost, item_price_uom_id = public.getuomid(new.list_price_uom), item_upccode = new.upc_code, item_prodweight = new.product_weight, item_packweight = new.packaging_weight, item_comments = new.notes, item_extdescrip = new.ext_description WHERE (item.item_id = public.getitemid((old.item_number)::text)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO itemalias DO INSTEAD UPDATE public.itemalias SET itemalias_number = new.alias_number, itemalias_usedescrip = new.use_description, itemalias_descrip1 = new.description1, itemalias_descrip2 = new.description2, itemalias_comments = new.comments, itemalias_crmacct_id = public.getcrmacctid(new.crmacct_number) WHERE ((itemalias.itemalias_item_id = public.getitemid((old.item_number)::text)) AND (itemalias.itemalias_number = old.alias_number)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO itemchar DO INSTEAD UPDATE public.charass SET charass_value = new.value, charass_default = new.is_default WHERE (((charass.charass_target_type = 'I'::text) AND (charass.charass_target_id = public.getitemid((old.item_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'I'::text))); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO itemcomment DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO itemcost DO INSTEAD SELECT public.updateitemcost(public.getitemid((new.item_number)::text), public.getcostelemid((new.costing_element)::text), public.getcurrid((new.currency)::text), new.actual_cost, new.post_to_standard) AS updateitemcost; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO itemfile DO INSTEAD UPDATE public.url SET url_title = new.title, url_url = new.url WHERE ((((url.url_source_id = public.getitemid((old.item_number)::text)) AND (url.url_source = 'I'::text)) AND (url.url_title = old.title)) AND (url.url_url = old.url)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO itemimage DO INSTEAD SELECT public.saveimageass('I'::text, public.getitemid((new.item_number)::text), (CASE WHEN (new.purpose = 'Product Description'::text) THEN 'P'::text WHEN (new.purpose = 'Inventory Description'::text) THEN 'I'::text WHEN (new.purpose = 'Engineering Reference'::text) THEN 'E'::text WHEN (new.purpose = 'Miscellaneous'::text) THEN 'M'::text ELSE 'X'::text END)::bpchar, public.getimageid(new.image_name)) AS saveimageass; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO itemsite DO INSTEAD UPDATE public.itemsite SET itemsite_active = new.active, itemsite_dropship = new.dropship, itemsite_posupply = new.po_supplied_at_site, itemsite_createpr = new.create_prs, itemsite_wosupply = new.wo_supplied_at_site, itemsite_createwo = new.create_wos, itemsite_createsopr = new.create_soprs, itemsite_createsopo = new.create_sopos, itemsite_sold = new.sold_from_site, itemsite_soldranking = new.ranking, itemsite_costmethod = CASE WHEN (new.cost_method = 'None'::text) THEN 'N'::text WHEN (new.cost_method = 'Average'::text) THEN 'A'::text WHEN (new.cost_method = 'Standard'::text) THEN 'S'::text WHEN (new.cost_method = 'Job'::text) THEN 'J'::text ELSE NULL::text END, itemsite_controlmethod = CASE WHEN (new.control_method = 'None'::text) THEN 'N'::text WHEN (new.control_method = 'Regular'::text) THEN 'R'::text WHEN (new.control_method = 'Serial #'::text) THEN 'S'::text WHEN (new.control_method = 'Lot #'::text) THEN 'L'::text ELSE NULL::text END, itemsite_perishable = new.perishable, itemsite_plancode_id = public.getplancodeid(new.planner_code), itemsite_costcat_id = public.getcostcatid(new.cost_category), itemsite_loccntrl = new.multiple_location_control, itemsite_location_id = CASE WHEN (new.location = 'N/A'::text) THEN (-1) ELSE public.getlocationid((new.site)::text, new.location) END, itemsite_recvlocation_id = CASE WHEN (new.receive_location = 'N/A'::text) THEN (-1) ELSE public.getlocationid((new.site)::text, new.receive_location) END, itemsite_issuelocation_id = CASE WHEN (new.issue_location = 'N/A'::text) THEN (-1) ELSE public.getlocationid((new.site)::text, new.issue_location) END, itemsite_location_dist = new.auto_distr_location, itemsite_recvlocation_dist = new.auto_distr_receive_location, itemsite_issuelocation_dist = new.auto_distr_issue_location, itemsite_location = new.user_defined_location, itemsite_location_comments = new.user_defined_location, itemsite_disallowblankwip = new.disallow_blank_wip_locations, itemsite_stocked = new.stocked, itemsite_abcclass = new.abc_class, itemsite_autoabcclass = new.allow_automatic_updates, itemsite_cyclecountfreq = new.cycl_cnt_freq, itemsite_eventfence = new.event_fence, itemsite_useparams = new.enforce_order_parameters, itemsite_reorderlevel = new.reorder_level, itemsite_ordertoqty = new.order_up_to, itemsite_minordqty = new.minimum_order, itemsite_maxordqty = new.maximum_order, itemsite_multordqty = new.order_multiple, itemsite_useparamsmanual = new.enforce_on_manual_orders, itemsite_ordergroup = new.group_mps_mrp_orders, itemsite_ordergroup_first = new.first_group, itemsite_mps_timefence = new.mps_time_fence, itemsite_leadtime = new.lead_time, itemsite_safetystock = new.safety_stock, itemsite_supply_itemsite_id = CASE WHEN (new.supplied_from_site = 'None'::text) THEN NULL::integer WHEN (new.supplied_from_site = ''::text) THEN NULL::integer ELSE public.getitemsiteid(new.supplied_from_site, (new.item_number)::text) END, itemsite_notes = new.notes, itemsite_warrpurc = new.require_warranty, itemsite_autoreg = new.auto_register, itemsite_planning_type = CASE WHEN (new.planning_system = 'None'::text) THEN 'N'::text WHEN (new.planning_system = 'MPS'::text) THEN 'S'::text ELSE 'M'::text END WHERE (itemsite.itemsite_id = public.getitemsiteid((old.site)::text, (old.item_number)::text)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO itemsitecomment DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO itemsource DO INSTEAD UPDATE public.itemsrc SET itemsrc_vend_item_number = new.vendor_item_number, itemsrc_vend_item_descrip = new.vendor_description, itemsrc_comments = new.notes, itemsrc_vend_uom = new.vendor_uom, itemsrc_invvendoruomratio = new.inventory_vendor_uom_ratio, itemsrc_minordqty = new.minimum_order, itemsrc_multordqty = new.order_multiple, itemsrc_leadtime = new.lead_time, itemsrc_ranking = new.vendor_ranking, itemsrc_active = new.active, itemsrc_default = new.itemsrc_default, itemsrc_manuf_name = new.manufacturer_name, itemsrc_manuf_item_number = new.manufacturer_item_number, itemsrc_manuf_item_descrip = new.manufacturer_description, itemsrc_upccode = new.bar_code, itemsrc_contrct_id = public.getcontrctid(new.contract_number), itemsrc_effective = COALESCE(public.getcontrcteffective(new.contract_number), new.effective_date), itemsrc_expires = COALESCE(public.getcontrctexpires(new.contract_number), new.expires_date) WHERE (((((itemsrc.itemsrc_item_id = public.getitemid((old.item_number)::text)) AND (itemsrc.itemsrc_vend_id = public.getvendid((old.vendor)::text))) AND (itemsrc.itemsrc_vend_item_number = old.vendor_item_number)) AND (itemsrc.itemsrc_manuf_name = old.manufacturer_name)) AND (itemsrc.itemsrc_manuf_item_number = old.manufacturer_item_number)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO itemsourceprice DO INSTEAD UPDATE public.itemsrcp SET itemsrcp_qtybreak = new.qty_break, itemsrcp_price = new.price_per_unit, itemsrcp_updated = now(), itemsrcp_curr_id = public.getcurrid((new.currency)::text), itemsrcp_dropship = COALESCE(new.dropship_only, false), itemsrcp_warehous_id = CASE WHEN (new.pricing_site = 'All'::text) THEN (-1) ELSE COALESCE(public.getwarehousid(new.pricing_site, 'ALL'::text), (-1)) END, itemsrcp_type = CASE WHEN (new.pricing_type = 'Discount'::text) THEN 'D'::text ELSE 'N'::text END, itemsrcp_discntprcnt = (COALESCE(new.discount_percent, 0.0) / 100.0), itemsrcp_fixedamtdiscount = new.discount_fixed_amount WHERE ((itemsrcp.itemsrcp_itemsrc_id = public.getitemsrcid((old.item_number)::text, (new.vendor)::text)) AND (itemsrcp.itemsrcp_qtybreak = old.qty_break)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO itemsubstitute DO INSTEAD UPDATE public.itemsub SET itemsub_uomratio = new.sub_parent_uom_ratio, itemsub_rank = new.ranking WHERE ((itemsub.itemsub_parent_item_id = public.getitemid((old.root_item_number)::text)) AND (itemsub.itemsub_sub_item_id = public.getitemid((old.substitute_item_number)::text))); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO itemtaxtype DO INSTEAD UPDATE public.itemtax SET itemtax_taxzone_id = CASE WHEN ((new.tax_zone)::text = 'Any'::text) THEN NULL::integer ELSE public.gettaxzoneid((new.tax_zone)::text) END, itemtax_taxtype_id = public.gettaxtypeid(new.tax_type) WHERE (((itemtax.itemtax_item_id = public.getitemid((old.item_number)::text)) AND CASE WHEN ((old.tax_zone)::text = 'Any'::text) THEN (itemtax.itemtax_taxzone_id IS NULL) ELSE (itemtax.itemtax_taxzone_id = public.gettaxzoneid((old.tax_zone)::text)) END) AND (itemtax.itemtax_taxtype_id = public.gettaxtypeid(old.tax_type))); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO itemuomconversion DO INSTEAD SELECT public.saveitemuomconv(public.getitemid((new.item_number)::text), COALESCE(public.getuomid((new.uom)::text), (SELECT item.item_inv_uom_id FROM public.item WHERE (item.item_id = public.getitemid((new.item_number)::text)))), COALESCE(new.uom_value, (1)::numeric), COALESCE(public.getuomid(new.per_uom), (SELECT item.item_inv_uom_id FROM public.item WHERE (item.item_id = public.getitemid((new.item_number)::text)))), COALESCE(new.per_uom_value, (1)::numeric), COALESCE(new.fractional, false), public.getuomtypeid(new.selected_types)) AS saveitemuomconv; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO journalentry DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO location DO INSTEAD UPDATE public.location SET location_name = new.location, location_descrip = new.description, location_restrict = new.restricted, location_netable = new.netable, location_usable = new.usable, location_whsezone_id = public.getwhsezoneid((new.site)::text, new.zone), location_aisle = new.aisle, location_rack = new.rack, location_bin = new.bin WHERE ((location.location_warehous_id = public.getwarehousid((old.site)::text, 'ACTIVE'::text)) AND (location.location_name = (old.location)::text)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO misccounttag DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO pricingschedule DO INSTEAD UPDATE public.ipshead SET ipshead_descrip = new.description, ipshead_effective = CASE WHEN (new.effective = 'Always'::text) THEN '1970-01-01'::date ELSE (new.effective)::date END, ipshead_expires = CASE WHEN (new.expires = 'Never'::text) THEN '2100-01-01'::date ELSE (new.expires)::date END, ipshead_updated = now(), ipshead_curr_id = CASE WHEN (SELECT (count(ipsiteminfo.ipsitem_id) = 0) FROM public.ipsiteminfo WHERE (ipsiteminfo.ipsitem_ipshead_id = public.getipsheadid((old.name)::text))) THEN COALESCE(public.getcurrid((new.currency)::text), public.basecurrid()) ELSE public.getcurrid((old.currency)::text) END WHERE (ipshead.ipshead_name = (old.name)::text); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO pricingscheduleassign DO INSTEAD UPDATE public.ipsass SET ipsass_ipshead_id = public.getipsheadid((new.pricing_schedule)::text), ipsass_cust_id = CASE WHEN ((new.customer_number)::text = 'Any'::text) THEN (-1) ELSE public.getcustid((new.customer_number)::text) END, ipsass_custtype_id = CASE WHEN ((new.customer_type)::text = 'N/A'::text) THEN (-1) ELSE public.getcusttypeid((new.customer_type)::text) END, ipsass_custtype_pattern = new.customer_type_pattern, ipsass_shipto_id = CASE WHEN (((new.customer_number)::text = 'Any'::text) OR ((new.customer_shipto)::text = 'Any'::text)) THEN (-1) ELSE public.getshiptoid((new.customer_number)::text, (new.customer_shipto)::text) END, ipsass_shipto_pattern = new.customer_shipto_pattern WHERE ((((((ipsass.ipsass_ipshead_id = public.getipsheadid((old.pricing_schedule)::text)) AND (ipsass.ipsass_cust_id = CASE WHEN ((old.customer_number)::text = 'Any'::text) THEN (-1) ELSE public.getcustid((old.customer_number)::text) END)) AND (ipsass.ipsass_custtype_id = CASE WHEN ((old.customer_type)::text = 'N/A'::text) THEN (-1) ELSE public.getcusttypeid((old.customer_type)::text) END)) AND (ipsass.ipsass_custtype_pattern = (old.customer_type_pattern)::text)) AND (ipsass.ipsass_shipto_id = CASE WHEN ((old.customer_shipto)::text = 'Any'::text) THEN (-1) ELSE public.getshiptoid((old.customer_number)::text, (old.customer_shipto)::text) END)) AND (ipsass.ipsass_shipto_pattern = (old.customer_shipto_pattern)::text)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO pricingscheduleitem DO INSTEAD SELECT CASE WHEN ((old.type)::text = 'Item'::text) THEN public.saveipsitem(public.getipsitemid((old.pricing_schedule)::text, (old.item_number)::text, old.qty_break, (old.qty_uom)::text, (old.price_uom)::text), public.getipsheadid((new.pricing_schedule)::text), public.getitemid((new.item_number)::text), new.qty_break, new.price, public.getuomid((new.qty_uom)::text), public.getuomid((new.price_uom)::text), new.percent, new.fixedamt, CASE new.pricing_type WHEN 'Nominal'::text THEN 'N'::text WHEN 'Discount'::text THEN 'D'::text WHEN 'Markup'::text THEN 'M'::text ELSE '?'::text END) WHEN ((old.type)::text = 'Product Category'::text) THEN public.saveipsprodcat(public.getipsprodcatid((old.pricing_schedule)::text, (old.product_category)::text, old.qty_break), public.getipsheadid((new.pricing_schedule)::text), public.getprodcatid((new.product_category)::text), new.qty_break, new.percent, new.fixedamt, CASE new.pricing_type WHEN 'Nominal'::text THEN 'N'::text WHEN 'Discount'::text THEN 'D'::text WHEN 'Markup'::text THEN 'M'::text ELSE '?'::text END) ELSE NULL::integer END AS result; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO pricingscheduleitemchar DO INSTEAD UPDATE public.ipsitemchar SET ipsitemchar_price = new.price WHERE (((ipsitemchar.ipsitemchar_ipsitem_id = public.getipsitemid((old.pricing_schedule)::text, (old.item_number)::text, old.qty_break, (old.qty_uom)::text, (old.price_uom)::text)) AND (ipsitemchar.ipsitemchar_char_id = public.getcharid((old.characteristic)::text, 'I'::text))) AND (ipsitemchar.ipsitemchar_value = (old.value)::text)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO project DO INSTEAD UPDATE public.prj SET prj_name = new.name, prj_descrip = new.description, prj_owner_username = new.owner, prj_username = new.assigned_to, prj_so = new.sales_orders, prj_wo = new.work_orders, prj_po = new.purchase_orders, prj_status = CASE WHEN (new.status = 'In-Process'::text) THEN 'O'::text WHEN (new.status = 'Completed'::text) THEN 'C'::text ELSE 'P'::text END, prj_due_date = new.due, prj_assigned_date = new.assigned, prj_start_date = new.started, prj_completed_date = new.completed WHERE (prj.prj_number = old.number); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO projectcomment DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO prospect DO INSTEAD UPDATE public.prospect SET prospect_number = upper((new.prospect_number)::text), prospect_name = new.prospect_name, prospect_active = new.active, prospect_cntct_id = public.getcntctid(new.contact_number), prospect_taxzone_id = public.gettaxzoneid(new.default_tax_zone), prospect_salesrep_id = public.getsalesrepid(new.sales_rep), prospect_warehous_id = public.getwarehousid(new.site_code, 'ACTIVE'::text), prospect_comments = new.notes WHERE (prospect.prospect_id = public.getprospectid((old.prospect_number)::text)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO purchaseline DO INSTEAD UPDATE public.poitem SET poitem_duedate = new.due_date, poitem_qty_ordered = new.qty_ordered, poitem_unitprice = new.unit_price, poitem_vend_item_number = new.vend_item_number, poitem_vend_item_descrip = new.vendor_description, poitem_manuf_name = new.manufacturer_name, poitem_manuf_item_number = new.manufacturer_item_number, poitem_manuf_item_descrip = new.manufacturer_description, poitem_comments = new.notes, poitem_freight = new.freight, poitem_prj_id = public.getprjid(new.project_number), poitem_bom_rev_id = public.getrevid('BOM'::text, old.item_number, new.bill_of_materials_revision), poitem_boo_rev_id = public.getrevid('BOO'::text, old.item_number, new.bill_of_operations_revision) WHERE (poitem.poitem_id = public.getpoitemid((old.order_number)::text, old.line_number)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO purchaselinechar DO INSTEAD SELECT DISTINCT public.updatecharassignment('PI'::text, poitem.poitem_id, charass.charass_char_id, new.value) AS updatecharassignment FROM public.pohead, public.poitem, public.itemsite, public.item, public.charass, public."char" WHERE (((((((((pohead.pohead_number = (old.order_number)::text) AND (pohead.pohead_id = poitem.poitem_pohead_id)) AND (poitem.poitem_linenumber = old.line_number)) AND (poitem.poitem_itemsite_id = itemsite.itemsite_id)) AND (item.item_id = itemsite.itemsite_item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND ("char".char_id = charass.charass_char_id)) AND ("char".char_name = old.characteristic)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO purchaselinecomment DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO purchaseorder DO INSTEAD UPDATE public.pohead SET pohead_terms_id = public.gettermsid(new.terms), pohead_taxzone_id = public.gettaxzoneid(new.tax_zone), pohead_warehous_id = public.getwarehousid(new.receiving_site, 'ALL'::text), pohead_agent_username = new.purchasing_agent, pohead_vendaddr_id = CASE WHEN (new.alt_address = 'MAIN'::text) THEN NULL::integer ELSE public.getvendaddrid(old.vendor_number, new.alt_address) END, pohead_fob = new.fob, pohead_shipvia = new.ship_via, pohead_curr_id = public.getcurrid((new.currency)::text), pohead_freight = new.freight, pohead_comments = new.notes, pohead_dropship = new.dropship, pohead_vend_cntct_id = public.getcntctid(new.vend_contact_number), pohead_vend_cntct_honorific = new.vend_cntct_honorific, pohead_vend_cntct_first_name = new.vend_cntct_first_name, pohead_vend_cntct_middle = new.vend_cntct_middle, pohead_vend_cntct_last_name = new.vend_cntct_last_name, pohead_vend_cntct_suffix = new.vend_cntct_suffix, pohead_vend_cntct_phone = new.vend_cntct_phone, pohead_vend_cntct_title = new.vend_cntct_title, pohead_vend_cntct_fax = new.vend_cntct_fax, pohead_vend_cntct_email = new.vend_cntct_email, pohead_vendaddress1 = new.vendaddress1, pohead_vendaddress2 = new.vendaddress2, pohead_vendaddress3 = new.vendaddress3, pohead_vendcity = new.vendcity, pohead_vendstate = new.vendstate, pohead_vendzipcode = new.vendzipcode, pohead_vendcountry = new.vendcountry, pohead_shipto_cntct_id = public.getcntctid(new.shipto_contact_number), pohead_shipto_cntct_honorific = new.shipto_cntct_honorific, pohead_shipto_cntct_first_name = new.shipto_cntct_first_name, pohead_shipto_cntct_middle = new.shipto_cntct_middle, pohead_shipto_cntct_last_name = new.shipto_cntct_last_name, pohead_shipto_cntct_suffix = new.shipto_cntct_suffix, pohead_shipto_cntct_phone = new.shipto_cntct_phone, pohead_shipto_cntct_title = new.shipto_cntct_title, pohead_shipto_cntct_fax = new.shipto_cntct_fax, pohead_shipto_cntct_email = new.shipto_cntct_email, pohead_shiptoaddress_id = public.getaddrid(new.shiptoaddress_number), pohead_shiptoaddress1 = new.shiptoaddress1, pohead_shiptoaddress2 = new.shiptoaddress2, pohead_shiptoaddress3 = new.shiptoaddress3, pohead_shiptocity = new.shiptocity, pohead_shiptostate = new.shiptostate, pohead_shiptozipcode = new.shiptozipcode, pohead_shiptocountry = new.shiptocountry, pohead_cohead_id = public.getcoheadid(new.sales_order_number) WHERE (pohead.pohead_number = (old.order_number)::text); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO purchaseordercomment DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO quote DO INSTEAD UPDATE public.quhead SET quhead_number = old.quote_number, quhead_cust_id = public.getcustid(new.customer_number, true), quhead_custponumber = new.cust_po_number, quhead_quotedate = new.quote_date, quhead_warehous_id = public.getwarehousid(new.site, 'SHIPPING'::text), quhead_shipto_id = public.getshiptoid(new.customer_number, new.shipto_number), quhead_shiptoname = new.shipto_name, quhead_shiptoaddress1 = new.shipto_address1, quhead_shiptoaddress2 = new.shipto_address2, quhead_shiptoaddress3 = new.shipto_address3, quhead_salesrep_id = public.getsalesrepid(new.sales_rep), quhead_terms_id = public.gettermsid(new.terms), quhead_fob = new.fob, quhead_shipvia = new.ship_via, quhead_shiptocity = new.shipto_city, quhead_shiptostate = new.shipto_state, quhead_shiptozipcode = new.shipto_postal_code, quhead_freight = new.freight, quhead_misc = new.misc_charge, quhead_ordercomments = new.order_notes, quhead_shipcomments = new.shipping_notes, quhead_shiptophone = new.shipto_phone, quhead_billtoname = new.billto_name, quhead_billtoaddress1 = new.billto_address1, quhead_billtoaddress2 = new.billto_address2, quhead_billtoaddress3 = new.billto_address3, quhead_billtocity = new.billto_city, quhead_billtostate = new.billto_state, quhead_billtozip = new.billto_postal_code, quhead_misc_accnt_id = public.getglaccntid(new.misc_account_number), quhead_misc_descrip = new.misc_charge_description, quhead_commission = new.commission, quhead_packdate = new.pack_date, quhead_prj_id = public.getprjid(new.project_number), quhead_billtocountry = new.billto_country, quhead_shiptocountry = new.shipto_country, quhead_curr_id = public.getcurrid((new.currency)::text), quhead_taxzone_id = public.gettaxzoneid(new.tax_zone), quhead_taxtype_id = public.gettaxtypeid(new.tax_type), quhead_expire = new.expire_date, quhead_saletype_id = public.getsaletypeid(new.sale_type), quhead_shipzone_id = public.getshipzoneid(new.shipto_shipzone) WHERE (quhead.quhead_number = (old.quote_number)::text); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO quotecomment DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO quoteline DO INSTEAD UPDATE public.quitem SET quitem_scheddate = new.scheduled_date, quitem_qtyord = new.qty_ordered, quitem_qty_uom_id = public.getuomid(new.qty_uom), quitem_qty_invuomratio = public.itemuomtouomratio(item.item_id, COALESCE(public.getuomid(new.qty_uom), item.item_inv_uom_id), item.item_inv_uom_id), quitem_price = new.net_unit_price, quitem_price_uom_id = public.getuomid(new.price_uom), quitem_price_invuomratio = public.itemuomtouomratio(item.item_id, COALESCE(public.getuomid(new.price_uom), item.item_inv_uom_id), item.item_inv_uom_id), quitem_memo = new.notes, quitem_createorder = new.create_order, quitem_order_warehous_id = public.getwarehousid(new.supplying_site, 'SHIPPING'::text), quitem_prcost = new.overwrite_po_price, quitem_taxtype_id = public.gettaxtypeid(new.tax_type) FROM public.item WHERE ((quitem.quitem_quhead_id = public.getquoteid(old.quote_number)) AND (quitem.quitem_linenumber = old.line_number)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO quotelinechar DO INSTEAD SELECT DISTINCT public.updatecharassignment('QI'::text, quitem.quitem_id, charass.charass_char_id, new.value) AS updatecharassignment FROM public.quhead, public.quitem, public.itemsite, public.item, public.charass, public."char" WHERE (((((((((quhead.quhead_number = old.quote_number) AND (quhead.quhead_id = quitem.quitem_quhead_id)) AND (quitem.quitem_linenumber = old.line_number)) AND (quitem.quitem_itemsite_id = itemsite.itemsite_id)) AND (item.item_id = itemsite.itemsite_item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND ("char".char_id = charass.charass_char_id)) AND ("char".char_name = old.characteristic)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO quotelinecomment DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO saleshistory DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO saleslinechar DO INSTEAD SELECT DISTINCT public.updatecharassignment('SI'::text, coitem.coitem_id, charass.charass_char_id, new.value, public.itemcharprice(item.item_id, "char".char_id, new.value, cohead.cohead_cust_id, cohead.cohead_shipto_id, coitem.coitem_qtyord, cohead.cohead_curr_id, cohead.cohead_orderdate)) AS updatecharassignment FROM public.cohead, public.coitem, public.itemsite, public.item, public.charass, public."char" WHERE (((((((((cohead.cohead_number = (old.order_number)::text) AND (cohead.cohead_id = coitem.coitem_cohead_id)) AND (coitem.coitem_id = public.getcoitemid((old.order_number)::text, old.line_number))) AND (coitem.coitem_itemsite_id = itemsite.itemsite_id)) AND (item.item_id = itemsite.itemsite_item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND ("char".char_id = charass.charass_char_id)) AND ("char".char_name = old.characteristic)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO saleslinecomment DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO salesorder DO INSTEAD UPDATE public.cohead SET cohead_number = old.order_number, cohead_cust_id = public.getcustid(new.customer_number), cohead_custponumber = new.cust_po_number, cohead_orderdate = new.order_date, cohead_warehous_id = public.getwarehousid(new.site, 'SHIPPING'::text), cohead_shipto_id = public.getshiptoid(new.customer_number, new.shipto_number), cohead_shiptoname = new.shipto_name, cohead_shiptoaddress1 = new.shipto_address1, cohead_shiptoaddress2 = new.shipto_address2, cohead_shiptoaddress3 = new.shipto_address3, cohead_salesrep_id = public.getsalesrepid(new.sales_rep), cohead_terms_id = public.gettermsid(new.terms), cohead_fob = new.fob, cohead_shipvia = new.ship_via, cohead_shiptocity = new.shipto_city, cohead_shiptostate = new.shipto_state, cohead_shiptozipcode = new.shipto_postal_code, cohead_freight = CASE WHEN new.calculate_freight THEN COALESCE((SELECT sum(freightdetail.freightdata_total) AS sum FROM public.freightdetail('SO'::text, public.getcoheadid((old.order_number)::text), public.getcustid(new.customer_number), public.getshiptoid(new.customer_number, new.shipto_number), new.order_date, new.ship_via, public.getcurrid((new.currency)::text)) freightdetail(freightdata_schedule, freightdata_from, freightdata_to, freightdata_shipvia, freightdata_freightclass, freightdata_weight, freightdata_uom, freightdata_price, freightdata_type, freightdata_total, freightdata_currency)), (0)::numeric) ELSE new.freight END, cohead_calcfreight = new.calculate_freight, cohead_misc = new.misc_charge, cohead_ordercomments = new.order_notes, cohead_shipcomments = new.shipping_notes, cohead_shiptophone = new.shipto_phone, cohead_shipchrg_id = public.getshipchrgid(new.shipping_chgs), cohead_shipform_id = public.getshipformid(new.shipping_form), cohead_billtoname = new.billto_name, cohead_billtoaddress1 = new.billto_address1, cohead_billtoaddress2 = new.billto_address2, cohead_billtoaddress3 = new.billto_address3, cohead_billtocity = new.billto_city, cohead_billtostate = new.billto_state, cohead_billtozipcode = new.billto_postal_code, cohead_misc_accnt_id = public.getglaccntid(new.misc_account_number), cohead_misc_descrip = new.misc_charge_description, cohead_commission = new.commission, cohead_holdtype = CASE WHEN (new.hold_type = 'Credit'::text) THEN 'C'::text WHEN (new.hold_type = 'Shipping'::text) THEN 'S'::text WHEN (new.hold_type = 'Packing'::text) THEN 'P'::text ELSE 'N'::text END, cohead_packdate = new.pack_date, cohead_prj_id = public.getprjid(new.project_number), cohead_shipcomplete = new.ship_complete, cohead_billtocountry = new.billto_country, cohead_shiptocountry = new.shipto_country, cohead_curr_id = public.getcurrid((new.currency)::text), cohead_taxzone_id = public.gettaxzoneid(new.tax_zone), cohead_lastupdated = ('now'::text)::timestamp(6) with time zone, cohead_shipto_cntct_id = public.getcntctid(new.shipto_contact_number), cohead_shipto_cntct_honorific = new.shipto_contact_honorific, cohead_shipto_cntct_first_name = new.shipto_contact_first, cohead_shipto_cntct_middle = new.shipto_contact_middle, cohead_shipto_cntct_last_name = new.shipto_contact_last, cohead_shipto_cntct_suffix = new.shipto_contact_suffix, cohead_shipto_cntct_phone = new.shipto_contact_phone, cohead_shipto_cntct_title = new.shipto_contact_title, cohead_shipto_cntct_fax = new.shipto_contact_fax, cohead_shipto_cntct_email = new.shipto_contact_email, cohead_billto_cntct_id = public.getcntctid(new.billto_contact_number), cohead_billto_cntct_honorific = new.billto_contact_name, cohead_billto_cntct_first_name = new.billto_contact_first, cohead_billto_cntct_middle = new.billto_contact_middle, cohead_billto_cntct_last_name = new.billto_contact_last, cohead_billto_cntct_suffix = new.billto_contact_suffix, cohead_billto_cntct_phone = new.billto_contact_phone, cohead_billto_cntct_title = new.billto_contact_title, cohead_billto_cntct_fax = new.billto_contct_fax, cohead_billto_cntct_email = new.billto_contact_email, cohead_saletype_id = public.getsaletypeid(new.sale_type), cohead_shipzone_id = public.getshipzoneid(new.shipto_shipzone) WHERE (cohead.cohead_number = (old.order_number)::text); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO salesordercomment DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO salesrep DO INSTEAD UPDATE public.salesrep SET salesrep_active = new.active, salesrep_number = new.number, salesrep_name = new.name, salesrep_commission = (new.commission_percent * 0.01), salesrep_emp_id = public.getempid(new.employee) WHERE (salesrep.salesrep_number = (old.number)::text); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO site DO INSTEAD UPDATE public.whsinfo SET warehous_descrip = new.description, warehous_fob = CASE WHEN new.inventory_type THEN new.default_fob ELSE NULL::text END, warehous_active = new.active, warehous_counttag_prefix = CASE WHEN new.inventory_type THEN new.next_count_tag_prefix ELSE NULL::text END, warehous_counttag_number = CASE WHEN new.inventory_type THEN new.next_count_tag_number ELSE NULL::integer END, warehous_bol_prefix = CASE WHEN new.inventory_type THEN new.next_bill_of_lading_prefix ELSE NULL::text END, warehous_bol_number = CASE WHEN new.inventory_type THEN new.next_bill_of_lading_number ELSE NULL::integer END, warehous_shipping = CASE WHEN new.inventory_type THEN new.shipping_site ELSE NULL::boolean END, warehous_useslips = CASE WHEN new.inventory_type THEN new.force_the_use_of_count_slips ELSE NULL::boolean END, warehous_usezones = CASE WHEN new.inventory_type THEN new.force_the_use_of_zones ELSE NULL::boolean END, warehous_aislesize = CASE WHEN new.inventory_type THEN new.aisle_size ELSE NULL::integer END, warehous_aislealpha = CASE WHEN new.inventory_type THEN new.aisle_allow_alpha_characters ELSE NULL::boolean END, warehous_racksize = CASE WHEN new.inventory_type THEN new.rack_size ELSE NULL::integer END, warehous_rackalpha = CASE WHEN new.inventory_type THEN new.rack_allow_alpha_characters ELSE NULL::boolean END, warehous_binsize = CASE WHEN new.inventory_type THEN new.bin_size ELSE NULL::integer END, warehous_binalpha = CASE WHEN new.inventory_type THEN new.bin_allow_alpha_characters ELSE NULL::boolean END, warehous_locationsize = CASE WHEN new.inventory_type THEN new.location_size ELSE NULL::integer END, warehous_locationalpha = CASE WHEN new.inventory_type THEN new.location_allow_alpha_characters ELSE NULL::boolean END, warehous_enforcearbl = CASE WHEN new.inventory_type THEN new.enforce_arbl_naming_convention ELSE NULL::boolean END, warehous_default_accnt_id = public.getglaccntid(new.post_unassigned_transactions_to), warehous_shipping_commission = CASE WHEN new.inventory_type THEN (new.shipping_commission * 0.01) ELSE NULL::numeric END, warehous_cntct_id = public.savecntct(public.getcntctid(new.contact_number), new.contact_number, NULL::integer, new.honorific, new.first, new.middle, new.last, new.suffix, new.phone, NULL::text, new.fax, new.email, NULL::text, new.job_title, new.contact_change), warehous_addr_id = public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.address_change), warehous_taxzone_id = CASE WHEN new.inventory_type THEN public.gettaxzoneid(new.tax_zone) ELSE NULL::integer END, warehous_transit = CASE WHEN new.inventory_type THEN false WHEN new.transit_type THEN true ELSE NULL::boolean END, warehous_shipform_id = CASE WHEN new.transit_type THEN public.getshipformid(new.default_shipping_form) ELSE NULL::integer END, warehous_shipvia_id = CASE WHEN new.transit_type THEN public.getshipviaid(new.default_ship_via) ELSE NULL::integer END, warehous_shipcomments = CASE WHEN new.transit_type THEN new.shipping_comments ELSE NULL::text END, warehous_costcat_id = CASE WHEN new.transit_type THEN public.getcostcatid(new.default_cost_category) ELSE NULL::integer END, warehous_sitetype_id = public.getsitetypeid(new.type), warehous_sequence = new.scheduling_sequence WHERE (whsinfo.warehous_id = public.getwarehousid((old.code)::text, 'ALL'::text)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO sitezone DO INSTEAD UPDATE public.whsezone SET whsezone_descrip = new.description WHERE ((whsezone.whsezone_warehous_id = public.getwarehousid((old.site)::text, 'ACTIVE'::text)) AND (whsezone.whsezone_name = (old.name)::text)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO task DO INSTEAD UPDATE public.prjtask SET prjtask_name = new.name, prjtask_descrip = new.description, prjtask_owner_username = new.owner, prjtask_username = new.assigned_to, prjtask_hours_budget = new.hours_budgeted, prjtask_hours_actual = new.hours_actual, prjtask_exp_budget = new.expenses_budgeted, prjtask_exp_actual = new.expenses_actual, prjtask_status = CASE WHEN (new.status = 'In-Process'::text) THEN 'O'::text WHEN (new.status = 'Completed'::text) THEN 'C'::text ELSE 'P'::text END, prjtask_due_date = new.due, prjtask_assigned_date = new.assigned, prjtask_start_date = new.started, prjtask_completed_date = new.completed WHERE ((prjtask.prjtask_prj_id = public.getprjid(old.project_number)) AND (prjtask.prjtask_number = old.number)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO taskcomment DO INSTEAD NOTHING; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO todo DO INSTEAD SELECT public.updatetodoitem(old.task_number, old.assigned_to, new.task_name, new.description, public.getincidentid(new.incident), COALESCE(public.getincdtcrmacctid(new.incident), public.getcrmacctid(new.account)), public.getopheadid(new.opportunity), CASE WHEN (new.date_started > ''::text) THEN (new.date_started)::date ELSE NULL::date END, CASE WHEN (new.date_due > ''::text) THEN (new.date_due)::date ELSE NULL::date END, (CASE WHEN (new.status = 'Pending Input'::text) THEN 'P'::text WHEN (new.status = 'Deferred'::text) THEN 'D'::text WHEN (new.status = 'Neither'::text) THEN 'N'::text ELSE NULL::text END)::bpchar, CASE WHEN (new.date_assigned > ''::text) THEN (new.date_assigned)::date ELSE NULL::date END, CASE WHEN (new.date_completed > ''::text) THEN (new.date_completed)::date ELSE NULL::date END, public.getincdtpriorityid(new.priority), new.notes, new.active, new.owner) AS updatetodoitem; -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO vendor DO INSTEAD UPDATE public.vendinfo SET vend_name = new.vendor_name, vend_active = new.active, vend_po = new.sells_purchase_order_items, vend_comments = new.notes, vend_pocomments = new.po_comments, vend_1099 = new.receives_1099, vend_fobsource = CASE WHEN (new.default_fob IS NULL) THEN NULL::text WHEN (new.default_fob = 'Receiving Site'::text) THEN 'W'::text ELSE 'V'::text END, vend_fob = CASE WHEN (new.default_fob IS NULL) THEN NULL::text WHEN (new.default_fob = 'Receiving Site'::text) THEN ''::text ELSE new.default_fob END, vend_terms_id = public.gettermsid(new.default_terms), vend_shipvia = new.ship_via, vend_vendtype_id = public.getvendtypeid(new.vendor_type), vend_qualified = new.qualified, vend_ediemail = new.po_edi_email, vend_ediemailbody = new.po_edi_emailbody, vend_edisubject = new.po_edi_subject, vend_edifilename = new.po_edi_filename, vend_accntnum = new.account_number, vend_emailpodelivery = new.allow_email_po_delivery, vend_restrictpurch = new.may_only_sell_item_source, vend_edicc = new.po_edi_cc, vend_curr_id = public.getcurrid((new.default_currency)::text), vend_cntct1_id = public.savecntct(public.getcntctid(new.contact1_number), new.contact1_number, NULL::integer, new.contact1_honorific, new.contact1_first, new.contact1_middle, new.contact1_last, new.contact1_suffix, new.contact1_voice, new.contact1_alternate, new.contact1_fax, new.contact1_email, new.contact1_web, new.contact1_job_title, new.contact1_change), vend_cntct2_id = public.savecntct(public.getcntctid(new.contact2_number), new.contact2_number, NULL::integer, new.contact2_honorific, new.contact2_first, new.contact2_middle, new.contact2_last, new.contact2_suffix, new.contact2_voice, new.contact2_alternate, new.contact2_fax, new.contact2_email, new.contact2_web, new.contact2_job_title, new.contact2_change), vend_addr_id = public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change), vend_match = new.matching_vo_po_amounts, vend_taxzone_id = public.gettaxzoneid(new.default_tax_zone), vend_accnt_id = COALESCE(public.getglaccntid(NULLIF(new.default_dist_gl_account, 'N/A'::text)), (-1)), vend_expcat_id = COALESCE(public.getexpcatid(NULLIF(new.default_dist_expense_category, 'N/A'::text)), (-1)), vend_tax_id = COALESCE(public.gettaxid(NULLIF(new.default_dist_tax_code, 'N/A'::text)), (-1)) WHERE (vendinfo.vend_id = public.getvendid((old.vendor_number)::text)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO vendoraddress DO INSTEAD UPDATE public.vendaddrinfo SET vendaddr_vend_id = public.getvendid((new.vendor_number)::text), vendaddr_code = new.vendor_address_number, vendaddr_name = new.vendor_address_name, vendaddr_comments = new.notes, vendaddr_cntct_id = public.savecntct(public.getcntctid(new.contact_number), new.contact_number, public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change), new.contact_honorific, new.contact_first, new.contact_middle, new.contact_last, new.contact_suffix, new.contact_voice, new.contact_alternate, new.contact_fax, new.contact_email, new.contact_web, new.contact_job_title, new.contact_change), vendaddr_addr_id = public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change) WHERE (vendaddrinfo.vendaddr_id = public.getvendaddrid((old.vendor_number)::text, (old.vendor_address_number)::text)); -- -- Name: _UPDATE; Type: RULE; Schema: api; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO vendortype DO INSTEAD UPDATE public.vendtype SET vendtype_code = new.code, vendtype_descrip = new.description WHERE (vendtype.vendtype_code = (old.code)::text); SET search_path = public, pg_catalog; -- -- Name: _DELETE; Type: RULE; Schema: public; Owner: admin -- CREATE RULE "_DELETE" AS ON DELETE TO url DO INSTEAD NOTHING; -- -- Name: _DELETE_FILE; Type: RULE; Schema: public; Owner: admin -- CREATE RULE "_DELETE_FILE" AS ON DELETE TO url WHERE (old.url_stream IS NOT NULL) DO INSTEAD SELECT deletefile(old.url_id) AS deletefile; -- -- Name: _DELETE_URL; Type: RULE; Schema: public; Owner: admin -- CREATE RULE "_DELETE_URL" AS ON DELETE TO url WHERE (old.url_stream IS NULL) DO INSTEAD SELECT deleteurl(old.url_id) AS deleteurl; -- -- Name: _INSERT; Type: RULE; Schema: public; Owner: admin -- CREATE RULE "_INSERT" AS ON INSERT TO url DO INSTEAD NOTHING; -- -- Name: _INSERT_FILE; Type: RULE; Schema: public; Owner: admin -- CREATE RULE "_INSERT_FILE" AS ON INSERT TO url WHERE (new.url_stream IS NOT NULL) DO INSTEAD INSERT INTO docass (docass_id, docass_source_id, docass_source_type, docass_target_id, docass_target_type, docass_purpose) VALUES (COALESCE((new.url_id)::bigint, nextval('docass_docass_id_seq'::regclass)), new.url_source_id, new.url_source, createfile(new.url_title, new.url_url, new.url_stream), 'FILE'::text, 'S'::bpchar); -- -- Name: _INSERT_URL; Type: RULE; Schema: public; Owner: admin -- CREATE RULE "_INSERT_URL" AS ON INSERT TO url WHERE (new.url_stream IS NULL) DO INSTEAD INSERT INTO docass (docass_id, docass_source_id, docass_source_type, docass_target_id, docass_target_type, docass_purpose) VALUES (COALESCE((new.url_id)::bigint, nextval('docass_docass_id_seq'::regclass)), new.url_source_id, new.url_source, createurl(new.url_title, new.url_url), 'URL'::text, 'S'::bpchar); -- -- Name: _UPDATE; Type: RULE; Schema: public; Owner: admin -- CREATE RULE "_UPDATE" AS ON UPDATE TO url DO INSTEAD NOTHING; -- -- Name: _UPDATE_FILE; Type: RULE; Schema: public; Owner: admin -- CREATE RULE "_UPDATE_FILE" AS ON UPDATE TO url WHERE (new.url_stream IS NOT NULL) DO INSTEAD UPDATE file SET file_title = new.url_title, file_stream = new.url_stream FROM docass WHERE (((docass.docass_id = old.url_id) AND (docass.docass_target_id = file.file_id)) AND (docass.docass_target_type = 'FILE'::text)); -- -- Name: _UPDATE_URL; Type: RULE; Schema: public; Owner: admin -- CREATE RULE "_UPDATE_URL" AS ON UPDATE TO url WHERE (new.url_stream IS NULL) DO INSTEAD UPDATE urlinfo SET url_title = new.url_title, url_url = new.url_url FROM docass WHERE (((docass.docass_id = old.url_id) AND (docass.docass_target_id = urlinfo.url_id)) AND (docass.docass_target_type = 'URL'::text)); SET search_path = fixcountry, pg_catalog; -- -- Name: pkgcmdaftertrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgcmdaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdaftertrigger(); -- -- Name: pkgcmdaltertrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgcmdaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdaltertrigger(); -- -- Name: pkgcmdargaftertrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgcmdargaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargaftertrigger(); -- -- Name: pkgcmdargaltertrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgcmdargaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargaltertrigger(); -- -- Name: pkgcmdargbeforetrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgcmdargbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargbeforetrigger(); -- -- Name: pkgcmdbeforetrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgcmdbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdbeforetrigger(); -- -- Name: pkgimageaftertrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgimageaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimageaftertrigger(); -- -- Name: pkgimagealtertrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgimagealtertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimagealtertrigger(); -- -- Name: pkgimagebeforetrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgimagebeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimagebeforetrigger(); -- -- Name: pkgmetasqlaftertrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgmetasqlaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlaftertrigger(); -- -- Name: pkgmetasqlaltertrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgmetasqlaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlaltertrigger(); -- -- Name: pkgmetasqlbeforetrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgmetasqlbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlbeforetrigger(); -- -- Name: pkgprivaftertrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgprivaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivaftertrigger(); -- -- Name: pkgprivaltertrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgprivaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivaltertrigger(); -- -- Name: pkgprivbeforetrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgprivbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivbeforetrigger(); -- -- Name: pkgreportaftertrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgreportaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportaftertrigger(); -- -- Name: pkgreportaltertrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgreportaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportaltertrigger(); -- -- Name: pkgreportbeforetrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgreportbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportbeforetrigger(); -- -- Name: pkgscriptaftertrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgscriptaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptaftertrigger(); -- -- Name: pkgscriptaltertrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgscriptaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptaltertrigger(); -- -- Name: pkgscriptbeforetrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkgscriptbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptbeforetrigger(); -- -- Name: pkguiformaftertrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkguiformaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformaftertrigger(); -- -- Name: pkguiformaltertrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkguiformaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformaltertrigger(); -- -- Name: pkguiformbeforetrigger; Type: TRIGGER; Schema: fixcountry; Owner: admin -- CREATE TRIGGER pkguiformbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformbeforetrigger(); SET search_path = public, pg_catalog; -- -- Name: accntdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER accntdeletetrigger BEFORE DELETE ON accnt FOR EACH ROW EXECUTE PROCEDURE _accntdeletetrigger(); -- -- Name: accnttrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER accnttrigger BEFORE INSERT OR UPDATE ON accnt FOR EACH ROW EXECUTE PROCEDURE _accnttrigger(); -- -- Name: accntuniquetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER accntuniquetrigger BEFORE INSERT ON accnt FOR EACH ROW EXECUTE PROCEDURE _accntuniquetrigger(); -- -- Name: addrafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER addrafterdeletetrigger AFTER DELETE ON addr FOR EACH ROW EXECUTE PROCEDURE _addrafterdeletetrigger(); -- -- Name: addrtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER addrtrigger BEFORE INSERT OR DELETE OR UPDATE ON addr FOR EACH ROW EXECUTE PROCEDURE _addrtrigger(); -- -- Name: alarmbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER alarmbeforetrigger BEFORE INSERT ON alarm FOR EACH ROW EXECUTE PROCEDURE _alarmbeforetrigger(); -- -- Name: apapplytrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER apapplytrigger BEFORE INSERT OR UPDATE ON apapply FOR EACH ROW EXECUTE PROCEDURE _apapplytrigger(); -- -- Name: apopentrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER apopentrigger BEFORE INSERT OR UPDATE ON apopen FOR EACH ROW EXECUTE PROCEDURE _apopentrigger(); -- -- Name: arapplytrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER arapplytrigger BEFORE INSERT OR UPDATE ON arapply FOR EACH ROW EXECUTE PROCEDURE _arapplytrigger(); -- -- Name: aropenaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER aropenaftertrigger AFTER INSERT OR UPDATE ON aropen FOR EACH ROW EXECUTE PROCEDURE _aropenaftertrigger(); -- -- Name: aropentrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER aropentrigger BEFORE INSERT OR UPDATE ON aropen FOR EACH ROW EXECUTE PROCEDURE _aropentrigger(); -- -- Name: bomheadtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER bomheadtrigger AFTER INSERT OR DELETE OR UPDATE ON bomhead FOR EACH ROW EXECUTE PROCEDURE _bomheadtrigger(); -- -- Name: bomitemaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER bomitemaftertrigger AFTER INSERT OR UPDATE ON bomitem FOR EACH ROW EXECUTE PROCEDURE _bomitemaftertrigger(); -- -- Name: bomitembeforedeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER bomitembeforedeletetrigger BEFORE DELETE ON bomitem FOR EACH ROW EXECUTE PROCEDURE _bomitembeforedeletetrigger(); -- -- Name: bomitembeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER bomitembeforetrigger BEFORE INSERT OR UPDATE ON bomitem FOR EACH ROW EXECUTE PROCEDURE _bomitembeforetrigger(); -- -- Name: bomitemsubtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER bomitemsubtrigger BEFORE INSERT OR DELETE OR UPDATE ON bomitemsub FOR EACH ROW EXECUTE PROCEDURE _bomitemsubtrigger(); -- -- Name: cashrcptitemaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER cashrcptitemaftertrigger AFTER INSERT OR UPDATE ON cashrcptitem FOR EACH ROW EXECUTE PROCEDURE _cashrcptitemaftertrigger(); -- -- Name: cashrcptitemtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER cashrcptitemtrigger BEFORE INSERT OR UPDATE ON cashrcptitem FOR EACH ROW EXECUTE PROCEDURE _cashrcptitemtrigger(); -- -- Name: cashrcptmisctrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER cashrcptmisctrigger BEFORE INSERT OR UPDATE ON cashrcptmisc FOR EACH ROW EXECUTE PROCEDURE _cashrcptmisctrigger(); -- -- Name: cashrcpttrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER cashrcpttrigger BEFORE INSERT OR UPDATE ON cashrcpt FOR EACH ROW EXECUTE PROCEDURE _cashrcpttrigger(); -- -- Name: ccardtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER ccardtrigger BEFORE INSERT OR UPDATE ON ccard FOR EACH ROW EXECUTE PROCEDURE _ccardtrigger(); -- -- Name: ccpaybeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER ccpaybeforetrigger BEFORE INSERT OR UPDATE ON ccpay FOR EACH ROW EXECUTE PROCEDURE _ccpaybeforetrigger(); -- -- Name: charasshistorytrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER charasshistorytrigger BEFORE INSERT OR DELETE OR UPDATE ON charass FOR EACH ROW EXECUTE PROCEDURE _charasshistorytrigger(); -- -- Name: charasstrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER charasstrigger AFTER INSERT OR UPDATE ON charass FOR EACH ROW EXECUTE PROCEDURE _charasstrigger(); -- -- Name: charbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER charbeforetrigger BEFORE INSERT OR UPDATE ON "char" FOR EACH ROW EXECUTE PROCEDURE _charbeforetrigger(); -- -- Name: charopttrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER charopttrigger AFTER DELETE OR UPDATE ON charopt FOR EACH ROW EXECUTE PROCEDURE _charopttrigger(); -- -- Name: charusebeforeupserttrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER charusebeforeupserttrigger BEFORE INSERT OR UPDATE ON charuse FOR EACH ROW EXECUTE PROCEDURE _charusebeforeupserttrigger(); -- -- Name: checkheadbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER checkheadbeforetrigger BEFORE INSERT OR UPDATE ON checkhead FOR EACH ROW EXECUTE PROCEDURE _checkheadbeforetrigger(); -- -- Name: cmheadbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER cmheadbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON cmhead FOR EACH ROW EXECUTE PROCEDURE _cmheadbeforetrigger(); -- -- Name: cmheadtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER cmheadtrigger AFTER INSERT OR DELETE OR UPDATE ON cmhead FOR EACH ROW EXECUTE PROCEDURE _cmheadtrigger(); -- -- Name: cmitembeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER cmitembeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON cmitem FOR EACH ROW EXECUTE PROCEDURE _cmitembeforetrigger(); -- -- Name: cmitemtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER cmitemtrigger AFTER INSERT OR DELETE OR UPDATE ON cmitem FOR EACH ROW EXECUTE PROCEDURE _cmitemtrigger(); -- -- Name: cntctafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER cntctafterdeletetrigger AFTER DELETE ON cntct FOR EACH ROW EXECUTE PROCEDURE _cntctafterdeletetrigger(); -- -- Name: cntcttrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER cntcttrigger BEFORE INSERT OR UPDATE ON cntct FOR EACH ROW EXECUTE PROCEDURE _cntcttrigger(); -- -- Name: cntcttriggerafter; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER cntcttriggerafter AFTER INSERT OR DELETE OR UPDATE ON cntct FOR EACH ROW EXECUTE PROCEDURE _cntcttriggerafter(); -- -- Name: cntcttriggerbeforedelete; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER cntcttriggerbeforedelete BEFORE DELETE ON cntct FOR EACH ROW EXECUTE PROCEDURE _cntcttriggerbeforedelete(); -- -- Name: cntsliptrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER cntsliptrigger BEFORE INSERT OR DELETE OR UPDATE ON cntslip FOR EACH ROW EXECUTE PROCEDURE _cntsliptrigger(); -- -- Name: cobillbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER cobillbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON cobill FOR EACH ROW EXECUTE PROCEDURE _cobillbeforetrigger(); -- -- Name: cobilltrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER cobilltrigger AFTER INSERT OR DELETE OR UPDATE ON cobill FOR EACH ROW EXECUTE PROCEDURE _cobilltrigger(); -- -- Name: cobmiscbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER cobmiscbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON cobmisc FOR EACH ROW EXECUTE PROCEDURE _cobmiscbeforetrigger(); -- -- Name: cobmisctrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER cobmisctrigger AFTER INSERT OR DELETE OR UPDATE ON cobmisc FOR EACH ROW EXECUTE PROCEDURE _cobmisctrigger(); -- -- Name: coheadafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER coheadafterdeletetrigger AFTER DELETE ON cohead FOR EACH ROW EXECUTE PROCEDURE _coheadafterdeletetrigger(); -- -- Name: coitembeforeimptaxtypedef; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER coitembeforeimptaxtypedef BEFORE INSERT ON coitem FOR EACH ROW EXECUTE PROCEDURE _coitembeforeimptaxtypedeftrigger(); -- -- Name: commenttrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER commenttrigger AFTER INSERT OR UPDATE ON comment FOR EACH ROW EXECUTE PROCEDURE _commenttrigger(); -- -- Name: companytrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER companytrigger BEFORE UPDATE ON company FOR EACH ROW EXECUTE PROCEDURE _companytrigger(); -- -- Name: contrctaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER contrctaftertrigger AFTER UPDATE ON contrct FOR EACH ROW EXECUTE PROCEDURE _contrctaftertrigger(); -- -- Name: crmacctafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER crmacctafterdeletetrigger AFTER DELETE ON crmacct FOR EACH ROW EXECUTE PROCEDURE _crmacctafterdeletetrigger(); -- -- Name: crmacctaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER crmacctaftertrigger AFTER INSERT OR DELETE OR UPDATE ON crmacct FOR EACH ROW EXECUTE PROCEDURE _crmacctaftertrigger(); -- -- Name: crmacctbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER crmacctbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON crmacct FOR EACH ROW EXECUTE PROCEDURE _crmacctbeforetrigger(); -- -- Name: currexchangecheckoverlap; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER currexchangecheckoverlap BEFORE INSERT OR UPDATE ON curr_rate FOR EACH ROW EXECUTE PROCEDURE currexchangecheckoverlap(); -- -- Name: curronebase; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER curronebase AFTER INSERT OR UPDATE ON curr_symbol FOR EACH ROW EXECUTE PROCEDURE curronebase(); -- -- Name: custaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER custaftertrigger AFTER INSERT OR UPDATE ON custinfo FOR EACH ROW EXECUTE PROCEDURE _custaftertrigger(); -- -- Name: custinfoafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER custinfoafterdeletetrigger AFTER DELETE ON custinfo FOR EACH ROW EXECUTE PROCEDURE _custinfoafterdeletetrigger(); -- -- Name: custinfobeforedeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER custinfobeforedeletetrigger BEFORE DELETE ON custinfo FOR EACH ROW EXECUTE PROCEDURE _custinfobeforedeletetrigger(); -- -- Name: custtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER custtrigger BEFORE INSERT OR UPDATE ON custinfo FOR EACH ROW EXECUTE PROCEDURE _custtrigger(); -- -- Name: custtypeafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER custtypeafterdeletetrigger AFTER DELETE ON custtype FOR EACH ROW EXECUTE PROCEDURE _custtypeafterdeletetrigger(); -- -- Name: custtypetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER custtypetrigger BEFORE INSERT OR UPDATE ON custtype FOR EACH ROW EXECUTE PROCEDURE _custtypetrigger(); -- -- Name: docasstrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER docasstrigger AFTER INSERT OR UPDATE ON docass FOR EACH ROW EXECUTE PROCEDURE _docasstrigger(); -- -- Name: empafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER empafterdeletetrigger AFTER DELETE ON emp FOR EACH ROW EXECUTE PROCEDURE _empafterdeletetrigger(); -- -- Name: empaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER empaftertrigger AFTER INSERT OR UPDATE ON emp FOR EACH ROW EXECUTE PROCEDURE _empaftertrigger(); -- -- Name: empbeforedeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER empbeforedeletetrigger BEFORE DELETE ON emp FOR EACH ROW EXECUTE PROCEDURE _empbeforedeletetrigger(); -- -- Name: empbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER empbeforetrigger BEFORE INSERT OR UPDATE ON emp FOR EACH ROW EXECUTE PROCEDURE _empbeforetrigger(); -- -- Name: evntlogafterinserttrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER evntlogafterinserttrigger AFTER INSERT ON evntlog FOR EACH ROW EXECUTE PROCEDURE _evntlogafterinserttrigger(); -- -- Name: gltransaltertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER gltransaltertrigger BEFORE DELETE OR UPDATE ON gltrans FOR EACH ROW EXECUTE PROCEDURE _gltransaltertrigger(); -- -- Name: gltransinserttrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER gltransinserttrigger BEFORE INSERT ON gltrans FOR EACH ROW EXECUTE PROCEDURE _gltransinserttrigger(); -- -- Name: grpprivtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER grpprivtrigger BEFORE INSERT OR UPDATE ON grppriv FOR EACH ROW EXECUTE PROCEDURE _grpprivtrigger(); -- -- Name: imageasstrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER imageasstrigger AFTER INSERT OR UPDATE ON imageass FOR EACH ROW EXECUTE PROCEDURE _imageasstrigger(); -- -- Name: incdtafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER incdtafterdeletetrigger AFTER DELETE ON incdt FOR EACH ROW EXECUTE PROCEDURE _incdtafterdeletetrigger(); -- -- Name: incdtbeforedeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER incdtbeforedeletetrigger BEFORE DELETE ON incdt FOR EACH ROW EXECUTE PROCEDURE _incdtbeforedeletetrigger(); -- -- Name: incdtbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER incdtbeforetrigger BEFORE INSERT OR UPDATE ON incdt FOR EACH ROW EXECUTE PROCEDURE _incdtbeforetrigger(); -- -- Name: incdttrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER incdttrigger AFTER INSERT OR DELETE OR UPDATE ON incdt FOR EACH ROW EXECUTE PROCEDURE _incdttrigger(); -- -- Name: invcheadafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER invcheadafterdeletetrigger AFTER DELETE ON invchead FOR EACH ROW EXECUTE PROCEDURE _invcheadafterdeletetrigger(); -- -- Name: invcheadaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER invcheadaftertrigger AFTER UPDATE ON invchead FOR EACH ROW EXECUTE PROCEDURE _invcheadaftertrigger(); -- -- Name: invcheadbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER invcheadbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON invchead FOR EACH ROW EXECUTE PROCEDURE _invcheadbeforetrigger(); -- -- Name: invcheadtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER invcheadtrigger AFTER INSERT OR DELETE OR UPDATE ON invchead FOR EACH ROW EXECUTE PROCEDURE _invcheadtrigger(); -- -- Name: invcitembeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER invcitembeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON invcitem FOR EACH ROW EXECUTE PROCEDURE _invcitembeforetrigger(); -- -- Name: invcitemtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER invcitemtrigger AFTER INSERT OR DELETE OR UPDATE ON invcitem FOR EACH ROW EXECUTE PROCEDURE _invcitemtrigger(); -- -- Name: invhisttrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER invhisttrigger BEFORE INSERT OR UPDATE ON invhist FOR EACH ROW EXECUTE PROCEDURE invhisttrig(); -- -- Name: ipsassbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER ipsassbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON ipsass FOR EACH ROW EXECUTE PROCEDURE _ipsassbeforetrigger(); -- -- Name: ipsheadbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER ipsheadbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON ipshead FOR EACH ROW EXECUTE PROCEDURE _ipsheadbeforetrigger(); -- -- Name: ipsitemcharbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER ipsitemcharbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON ipsitemchar FOR EACH ROW EXECUTE PROCEDURE _ipsitemcharbeforetrigger(); -- -- Name: ipsiteminfobeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER ipsiteminfobeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON ipsiteminfo FOR EACH ROW EXECUTE PROCEDURE _ipsiteminfobeforetrigger(); -- -- Name: item_uom_check; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER item_uom_check BEFORE INSERT OR UPDATE ON item FOR EACH ROW EXECUTE PROCEDURE _item_uom_check(); -- -- Name: itemafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER itemafterdeletetrigger AFTER DELETE ON item FOR EACH ROW EXECUTE PROCEDURE _itemafterdeletetrigger(); -- -- Name: itemaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER itemaftertrigger AFTER INSERT OR DELETE OR UPDATE ON item FOR EACH ROW EXECUTE PROCEDURE _itemaftertrigger(); -- -- Name: itemcostaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER itemcostaftertrigger AFTER INSERT OR UPDATE ON itemcost FOR EACH ROW EXECUTE PROCEDURE _itemcostaftertrigger(); -- -- Name: itemcosttrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER itemcosttrigger BEFORE INSERT OR DELETE OR UPDATE ON itemcost FOR EACH ROW EXECUTE PROCEDURE _itemcosttrigger(); -- -- Name: itemsiteaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER itemsiteaftertrigger AFTER INSERT OR UPDATE ON itemsite FOR EACH ROW EXECUTE PROCEDURE _itemsiteaftertrigger(); -- -- Name: itemsitetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER itemsitetrigger BEFORE INSERT OR UPDATE ON itemsite FOR EACH ROW EXECUTE PROCEDURE _itemsitetrigger(); -- -- Name: itemsrcaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER itemsrcaftertrigger AFTER INSERT OR UPDATE ON itemsrc FOR EACH ROW EXECUTE PROCEDURE _itemsrcaftertrigger(); -- -- Name: itemsrcptrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER itemsrcptrigger BEFORE INSERT OR UPDATE ON itemsrcp FOR EACH ROW EXECUTE PROCEDURE _itemsrcptrigger(); -- -- Name: itemsrctrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER itemsrctrigger BEFORE INSERT OR UPDATE ON itemsrc FOR EACH ROW EXECUTE PROCEDURE _itemsrctrigger(); -- -- Name: itemsubtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER itemsubtrigger AFTER INSERT OR UPDATE ON itemsub FOR EACH ROW EXECUTE PROCEDURE _itemsubtrigger(); -- -- Name: itemtaxtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER itemtaxtrigger AFTER INSERT OR UPDATE ON itemtax FOR EACH ROW EXECUTE PROCEDURE _itemtaxtrigger(); -- -- Name: itemtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER itemtrigger BEFORE INSERT OR UPDATE ON item FOR EACH ROW EXECUTE PROCEDURE _itemtrigger(); -- -- Name: itemuomconvtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER itemuomconvtrigger AFTER INSERT OR UPDATE ON itemuomconv FOR EACH ROW EXECUTE PROCEDURE _itemuomconvtrigger(); -- -- Name: locationaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER locationaftertrigger AFTER INSERT OR UPDATE ON location FOR EACH ROW EXECUTE PROCEDURE _locationaftertrigger(); -- -- Name: locationtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER locationtrigger BEFORE INSERT OR UPDATE ON location FOR EACH ROW EXECUTE PROCEDURE _locationtrigger(); -- -- Name: metasqlaltertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER metasqlaltertrigger BEFORE INSERT OR UPDATE ON metasql FOR EACH ROW EXECUTE PROCEDURE _metasqlaltertrigger(); -- -- Name: metasqltrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER metasqltrigger BEFORE INSERT OR UPDATE ON metasql FOR EACH ROW EXECUTE PROCEDURE _metasqltrigger(); -- -- Name: opheadafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER opheadafterdeletetrigger AFTER DELETE ON ophead FOR EACH ROW EXECUTE PROCEDURE _opheadafterdeletetrigger(); -- -- Name: opheadaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER opheadaftertrigger AFTER INSERT OR DELETE OR UPDATE ON ophead FOR EACH ROW EXECUTE PROCEDURE _opheadaftertrigger(); -- -- Name: opheadbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER opheadbeforetrigger BEFORE INSERT OR UPDATE ON ophead FOR EACH ROW EXECUTE PROCEDURE _opheadbeforetrigger(); -- -- Name: packbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER packbeforetrigger BEFORE INSERT OR UPDATE ON pack FOR EACH ROW EXECUTE PROCEDURE _packbeforetrigger(); -- -- Name: periodaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER periodaftertrigger AFTER INSERT OR DELETE OR UPDATE ON period FOR EACH STATEMENT EXECUTE PROCEDURE _periodaftertrigger(); -- -- Name: pkgheadbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER pkgheadbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkghead FOR EACH ROW EXECUTE PROCEDURE _pkgheadbeforetrigger(); -- -- Name: pkgitembeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER pkgitembeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgitem FOR EACH ROW EXECUTE PROCEDURE _pkgitembeforetrigger(); -- -- Name: poheadafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER poheadafterdeletetrigger AFTER DELETE ON pohead FOR EACH ROW EXECUTE PROCEDURE _poheadafterdeletetrigger(); -- -- Name: poheadtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER poheadtrigger BEFORE INSERT OR DELETE OR UPDATE ON pohead FOR EACH ROW EXECUTE PROCEDURE _poheadtrigger(); -- -- Name: poheadtriggerafter; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER poheadtriggerafter AFTER UPDATE ON pohead FOR EACH ROW EXECUTE PROCEDURE _poheadtriggerafter(); -- -- Name: poitemafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER poitemafterdeletetrigger AFTER DELETE ON poitem FOR EACH ROW EXECUTE PROCEDURE _poitemafterdeletetrigger(); -- -- Name: poitemaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER poitemaftertrigger AFTER INSERT OR UPDATE ON poitem FOR EACH ROW EXECUTE PROCEDURE _poitemaftertrigger(); -- -- Name: poitemdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER poitemdeletetrigger BEFORE DELETE ON poitem FOR EACH ROW EXECUTE PROCEDURE _poitemdeletetrigger(); -- -- Name: poitemtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER poitemtrigger BEFORE INSERT OR UPDATE ON poitem FOR EACH ROW EXECUTE PROCEDURE _poitemtrigger(); -- -- Name: prjafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER prjafterdeletetrigger AFTER DELETE ON prj FOR EACH ROW EXECUTE PROCEDURE _prjafterdeletetrigger(); -- -- Name: prjaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER prjaftertrigger AFTER INSERT OR UPDATE ON prj FOR EACH ROW EXECUTE PROCEDURE _prjaftertrigger(); -- -- Name: prjbeforedeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER prjbeforedeletetrigger BEFORE DELETE ON prj FOR EACH ROW EXECUTE PROCEDURE _prjbeforedeletetrigger(); -- -- Name: prjtaskafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER prjtaskafterdeletetrigger AFTER DELETE ON prjtask FOR EACH ROW EXECUTE PROCEDURE _prjtaskafterdeletetrigger(); -- -- Name: prjtaskaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER prjtaskaftertrigger AFTER INSERT OR UPDATE ON prjtask FOR EACH ROW EXECUTE PROCEDURE _prjtaskaftertrigger(); -- -- Name: prjtasktrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER prjtasktrigger BEFORE INSERT OR UPDATE ON prjtask FOR EACH ROW EXECUTE PROCEDURE _prjtasktrigger(); -- -- Name: prospectafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER prospectafterdeletetrigger AFTER DELETE ON prospect FOR EACH ROW EXECUTE PROCEDURE _prospectafterdeletetrigger(); -- -- Name: prospectaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER prospectaftertrigger AFTER INSERT OR UPDATE ON prospect FOR EACH ROW EXECUTE PROCEDURE _prospectaftertrigger(); -- -- Name: prospectbeforedeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER prospectbeforedeletetrigger BEFORE DELETE ON prospect FOR EACH ROW EXECUTE PROCEDURE _prospectbeforedeletetrigger(); -- -- Name: prospecttrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER prospecttrigger BEFORE INSERT OR UPDATE ON prospect FOR EACH ROW EXECUTE PROCEDURE _prospecttrigger(); -- -- Name: prtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER prtrigger AFTER INSERT ON pr FOR EACH ROW EXECUTE PROCEDURE _prtrigger(); -- -- Name: quheadafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER quheadafterdeletetrigger AFTER DELETE ON quhead FOR EACH ROW EXECUTE PROCEDURE _quheadafterdeletetrigger(); -- -- Name: quheadtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER quheadtrigger BEFORE INSERT OR DELETE OR UPDATE ON quhead FOR EACH ROW EXECUTE PROCEDURE _quheadtrigger(); -- -- Name: quitemafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER quitemafterdeletetrigger AFTER DELETE ON quitem FOR EACH ROW EXECUTE PROCEDURE _quitemafterdeletetrigger(); -- -- Name: quitemaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER quitemaftertrigger AFTER INSERT OR UPDATE ON quitem FOR EACH ROW EXECUTE PROCEDURE _quitemaftertrigger(); -- -- Name: quitembeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER quitembeforetrigger BEFORE INSERT OR UPDATE ON quitem FOR EACH ROW EXECUTE PROCEDURE _quitembeforetrigger(); -- -- Name: quitemtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER quitemtrigger BEFORE INSERT OR DELETE OR UPDATE ON quitem FOR EACH ROW EXECUTE PROCEDURE _quitemtrigger(); -- -- Name: recuraftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER recuraftertrigger AFTER DELETE ON recur FOR EACH ROW EXECUTE PROCEDURE _recuraftertrigger(); -- -- Name: reporttrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER reporttrigger BEFORE INSERT OR UPDATE ON report FOR EACH ROW EXECUTE PROCEDURE _reporttrigger(); -- -- Name: salesrepafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER salesrepafterdeletetrigger AFTER DELETE ON salesrep FOR EACH ROW EXECUTE PROCEDURE _salesrepafterdeletetrigger(); -- -- Name: salesrepaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER salesrepaftertrigger AFTER INSERT OR UPDATE ON salesrep FOR EACH ROW EXECUTE PROCEDURE _salesrepaftertrigger(); -- -- Name: salesrepbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER salesrepbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON salesrep FOR EACH ROW EXECUTE PROCEDURE _salesrepbeforetrigger(); -- -- Name: saletype_after_change; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER saletype_after_change AFTER INSERT OR UPDATE ON saletype FOR EACH ROW EXECUTE PROCEDURE _saletypeaftertrigger(); -- -- Name: saletypebeforedeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER saletypebeforedeletetrigger BEFORE DELETE ON saletype FOR EACH ROW EXECUTE PROCEDURE _saletypebeforedeletetrigger(); -- -- Name: shipdatasumtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER shipdatasumtrigger BEFORE INSERT OR UPDATE ON shipdatasum FOR EACH ROW EXECUTE PROCEDURE _shipdatasumtrigger(); -- -- Name: shipdatatrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER shipdatatrigger BEFORE INSERT OR UPDATE ON shipdata FOR EACH ROW EXECUTE PROCEDURE _shipdatatrigger(); -- -- Name: shipformafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER shipformafterdeletetrigger AFTER DELETE ON shipform FOR EACH ROW EXECUTE PROCEDURE _shipformafterdeletetrigger(); -- -- Name: shipheadbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER shipheadbeforetrigger BEFORE INSERT OR UPDATE ON shiphead FOR EACH ROW EXECUTE PROCEDURE _shipheadbeforetrigger(); -- -- Name: shiptoinfoaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER shiptoinfoaftertrigger AFTER INSERT OR UPDATE ON shiptoinfo FOR EACH ROW EXECUTE PROCEDURE _shiptoinfoaftertrigger(); -- -- Name: shipviaafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER shipviaafterdeletetrigger AFTER DELETE ON shipvia FOR EACH ROW EXECUTE PROCEDURE _shipviaafterdeletetrigger(); -- -- Name: sltransaltertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER sltransaltertrigger BEFORE DELETE OR UPDATE ON sltrans FOR EACH ROW EXECUTE PROCEDURE _sltransaltertrigger(); -- -- Name: sltransinserttrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER sltransinserttrigger BEFORE INSERT ON sltrans FOR EACH ROW EXECUTE PROCEDURE _sltransinserttrigger(); -- -- Name: soheadtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER soheadtrigger BEFORE INSERT OR DELETE OR UPDATE ON cohead FOR EACH ROW EXECUTE PROCEDURE _soheadtrigger(); -- -- Name: soheadtriggerafter; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER soheadtriggerafter AFTER UPDATE ON cohead FOR EACH ROW EXECUTE PROCEDURE _soheadtriggerafter(); -- -- Name: soitemafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER soitemafterdeletetrigger AFTER DELETE ON coitem FOR EACH ROW EXECUTE PROCEDURE _soitemafterdeletetrigger(); -- -- Name: soitemaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER soitemaftertrigger AFTER INSERT OR UPDATE ON coitem FOR EACH ROW EXECUTE PROCEDURE _soitemaftertrigger(); -- -- Name: soitembeforedeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER soitembeforedeletetrigger BEFORE DELETE ON coitem FOR EACH ROW EXECUTE PROCEDURE _soitembeforedeletetrigger(); -- -- Name: soitembeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER soitembeforetrigger BEFORE INSERT OR UPDATE ON coitem FOR EACH ROW EXECUTE PROCEDURE _soitembeforetrigger(); -- -- Name: soitemtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER soitemtrigger BEFORE INSERT OR UPDATE ON coitem FOR EACH ROW EXECUTE PROCEDURE _soitemtrigger(); -- -- Name: sourcebeforeupserttrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER sourcebeforeupserttrigger BEFORE INSERT OR UPDATE ON source FOR EACH ROW EXECUTE PROCEDURE _sourcebeforeupserttrigger(); -- -- Name: taxauthafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER taxauthafterdeletetrigger AFTER DELETE ON taxauth FOR EACH ROW EXECUTE PROCEDURE _taxauthafterdeletetrigger(); -- -- Name: taxauthaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER taxauthaftertrigger AFTER INSERT OR UPDATE ON taxauth FOR EACH ROW EXECUTE PROCEDURE _taxauthaftertrigger(); -- -- Name: taxauthbeforedeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER taxauthbeforedeletetrigger BEFORE DELETE ON taxauth FOR EACH ROW EXECUTE PROCEDURE _taxauthbeforedeletetrigger(); -- -- Name: taxauthbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER taxauthbeforetrigger BEFORE INSERT OR UPDATE ON taxauth FOR EACH ROW EXECUTE PROCEDURE _taxauthbeforetrigger(); -- -- Name: termsafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER termsafterdeletetrigger AFTER DELETE ON terms FOR EACH ROW EXECUTE PROCEDURE _termsafterdeletetrigger(); -- -- Name: todoitemtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER todoitemtrigger AFTER DELETE ON todoitem FOR EACH ROW EXECUTE PROCEDURE _todoitemtrigger(); -- -- Name: trialbalaltertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER trialbalaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON trialbal FOR EACH ROW EXECUTE PROCEDURE _trialbalaltertrigger(); -- -- Name: uomconvupdate; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER uomconvupdate BEFORE UPDATE ON uomconv FOR EACH ROW EXECUTE PROCEDURE _uomconvupdate(); -- -- Name: usrprefaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER usrprefaftertrigger AFTER INSERT OR DELETE OR UPDATE ON usrpref FOR EACH ROW EXECUTE PROCEDURE _usrprefaftertrigger(); -- -- Name: usrprefbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER usrprefbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON usrpref FOR EACH ROW EXECUTE PROCEDURE _usrprefbeforetrigger(); -- -- Name: usrprivtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER usrprivtrigger BEFORE INSERT OR UPDATE ON usrpriv FOR EACH ROW EXECUTE PROCEDURE _usrprivtrigger(); -- -- Name: vendaddrtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER vendaddrtrigger BEFORE INSERT OR DELETE OR UPDATE ON vendaddrinfo FOR EACH ROW EXECUTE PROCEDURE _vendaddrtrigger(); -- -- Name: vendaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER vendaftertrigger AFTER INSERT OR UPDATE ON vendinfo FOR EACH ROW EXECUTE PROCEDURE _vendaftertrigger(); -- -- Name: vendinfoafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER vendinfoafterdeletetrigger AFTER DELETE ON vendinfo FOR EACH ROW EXECUTE PROCEDURE _vendinfoafterdeletetrigger(); -- -- Name: vendinfobeforedeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER vendinfobeforedeletetrigger BEFORE DELETE ON vendinfo FOR EACH ROW EXECUTE PROCEDURE _vendinfobeforedeletetrigger(); -- -- Name: vendtrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER vendtrigger BEFORE INSERT OR UPDATE ON vendinfo FOR EACH ROW EXECUTE PROCEDURE _vendtrigger(); -- -- Name: vodistaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER vodistaftertrigger AFTER INSERT OR DELETE OR UPDATE ON vodist FOR EACH ROW EXECUTE PROCEDURE _vodistaftertrigger(); -- -- Name: vodistbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER vodistbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON vodist FOR EACH ROW EXECUTE PROCEDURE _vodistbeforetrigger(); -- -- Name: voheadafterdeletetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER voheadafterdeletetrigger AFTER DELETE ON vohead FOR EACH ROW EXECUTE PROCEDURE _voheadafterdeletetrigger(); -- -- Name: voheadaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER voheadaftertrigger AFTER INSERT OR DELETE OR UPDATE ON vohead FOR EACH ROW EXECUTE PROCEDURE _voheadaftertrigger(); -- -- Name: voheadbeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER voheadbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON vohead FOR EACH ROW EXECUTE PROCEDURE _voheadbeforetrigger(); -- -- Name: voitemaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER voitemaftertrigger AFTER INSERT OR DELETE OR UPDATE ON voitem FOR EACH ROW EXECUTE PROCEDURE _voitemaftertrigger(); -- -- Name: voitembeforetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER voitembeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON voitem FOR EACH ROW EXECUTE PROCEDURE _voitembeforetrigger(); -- -- Name: warehoustrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER warehoustrigger BEFORE INSERT OR UPDATE ON whsinfo FOR EACH ROW EXECUTE PROCEDURE _warehoustrigger(); -- -- Name: whsezonetrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER whsezonetrigger BEFORE INSERT OR UPDATE ON whsezone FOR EACH ROW EXECUTE PROCEDURE _whsezonetrigger(); -- -- Name: womatlaftertrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER womatlaftertrigger AFTER INSERT OR DELETE OR UPDATE ON womatl FOR EACH ROW EXECUTE PROCEDURE _womatlaftertrigger(); -- -- Name: wotrigger; Type: TRIGGER; Schema: public; Owner: admin -- CREATE TRIGGER wotrigger BEFORE INSERT OR DELETE OR UPDATE ON wo FOR EACH ROW EXECUTE PROCEDURE _wotrigger(); SET search_path = te, pg_catalog; -- -- Name: pkgcmdaftertrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgcmdaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdaftertrigger(); -- -- Name: pkgcmdaltertrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgcmdaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdaltertrigger(); -- -- Name: pkgcmdargaftertrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgcmdargaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargaftertrigger(); -- -- Name: pkgcmdargaltertrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgcmdargaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargaltertrigger(); -- -- Name: pkgcmdargbeforetrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgcmdargbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargbeforetrigger(); -- -- Name: pkgcmdbeforetrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgcmdbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdbeforetrigger(); -- -- Name: pkgimageaftertrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgimageaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimageaftertrigger(); -- -- Name: pkgimagealtertrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgimagealtertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimagealtertrigger(); -- -- Name: pkgimagebeforetrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgimagebeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimagebeforetrigger(); -- -- Name: pkgmetasqlaftertrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgmetasqlaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlaftertrigger(); -- -- Name: pkgmetasqlaltertrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgmetasqlaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlaltertrigger(); -- -- Name: pkgmetasqlbeforetrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgmetasqlbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlbeforetrigger(); -- -- Name: pkgprivaftertrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgprivaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivaftertrigger(); -- -- Name: pkgprivaltertrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgprivaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivaltertrigger(); -- -- Name: pkgprivbeforetrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgprivbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivbeforetrigger(); -- -- Name: pkgreportaftertrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgreportaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportaftertrigger(); -- -- Name: pkgreportaltertrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgreportaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportaltertrigger(); -- -- Name: pkgreportbeforetrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgreportbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportbeforetrigger(); -- -- Name: pkgscriptaftertrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgscriptaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptaftertrigger(); -- -- Name: pkgscriptaltertrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgscriptaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptaltertrigger(); -- -- Name: pkgscriptbeforetrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkgscriptbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptbeforetrigger(); -- -- Name: pkguiformaftertrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkguiformaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformaftertrigger(); -- -- Name: pkguiformaltertrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkguiformaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformaltertrigger(); -- -- Name: pkguiformbeforetrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER pkguiformbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformbeforetrigger(); -- -- Name: teheadtrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER teheadtrigger AFTER INSERT OR UPDATE ON tehead FOR EACH ROW EXECUTE PROCEDURE triggertehead(); -- -- Name: teitemtrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER teitemtrigger AFTER INSERT OR UPDATE ON teitem FOR EACH ROW EXECUTE PROCEDURE triggerteitem(); -- -- Name: teprjtrigger; Type: TRIGGER; Schema: te; Owner: admin -- CREATE TRIGGER teprjtrigger AFTER INSERT OR UPDATE ON teprj FOR EACH ROW EXECUTE PROCEDURE triggerteprj(); SET search_path = xtdesktop, pg_catalog; -- -- Name: pkgcmdaftertrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgcmdaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdaftertrigger(); -- -- Name: pkgcmdaltertrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgcmdaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdaltertrigger(); -- -- Name: pkgcmdargaftertrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgcmdargaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargaftertrigger(); -- -- Name: pkgcmdargaltertrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgcmdargaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargaltertrigger(); -- -- Name: pkgcmdargbeforetrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgcmdargbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargbeforetrigger(); -- -- Name: pkgcmdbeforetrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgcmdbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdbeforetrigger(); -- -- Name: pkgimageaftertrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgimageaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimageaftertrigger(); -- -- Name: pkgimagealtertrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgimagealtertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimagealtertrigger(); -- -- Name: pkgimagebeforetrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgimagebeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimagebeforetrigger(); -- -- Name: pkgmetasqlaftertrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgmetasqlaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlaftertrigger(); -- -- Name: pkgmetasqlaltertrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgmetasqlaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlaltertrigger(); -- -- Name: pkgmetasqlbeforetrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgmetasqlbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlbeforetrigger(); -- -- Name: pkgprivaftertrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgprivaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivaftertrigger(); -- -- Name: pkgprivaltertrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgprivaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivaltertrigger(); -- -- Name: pkgprivbeforetrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgprivbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivbeforetrigger(); -- -- Name: pkgreportaftertrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgreportaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportaftertrigger(); -- -- Name: pkgreportaltertrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgreportaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportaltertrigger(); -- -- Name: pkgreportbeforetrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgreportbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportbeforetrigger(); -- -- Name: pkgscriptaftertrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgscriptaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptaftertrigger(); -- -- Name: pkgscriptaltertrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgscriptaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptaltertrigger(); -- -- Name: pkgscriptbeforetrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkgscriptbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptbeforetrigger(); -- -- Name: pkguiformaftertrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkguiformaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformaftertrigger(); -- -- Name: pkguiformaltertrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkguiformaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformaltertrigger(); -- -- Name: pkguiformbeforetrigger; Type: TRIGGER; Schema: xtdesktop; Owner: admin -- CREATE TRIGGER pkguiformbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformbeforetrigger(); SET search_path = fixcountry, pg_catalog; -- -- Name: pkgcmdarg_cmdarg_cmd_id_fkey; Type: FK CONSTRAINT; Schema: fixcountry; Owner: admin -- ALTER TABLE ONLY pkgcmdarg ADD CONSTRAINT pkgcmdarg_cmdarg_cmd_id_fkey FOREIGN KEY (cmdarg_cmd_id) REFERENCES pkgcmd(cmd_id); SET search_path = public, pg_catalog; -- -- Name: accnt_accnt_company_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY accnt ADD CONSTRAINT accnt_accnt_company_fkey FOREIGN KEY (accnt_company) REFERENCES company(company_number) ON UPDATE CASCADE; -- -- Name: accnt_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY accnt ADD CONSTRAINT accnt_to_curr_symbol FOREIGN KEY (accnt_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: apapply_apapply_checkhead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY apapply ADD CONSTRAINT apapply_apapply_checkhead_id_fkey FOREIGN KEY (apapply_checkhead_id) REFERENCES checkhead(checkhead_id); -- -- Name: apapply_apapply_vend_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY apapply ADD CONSTRAINT apapply_apapply_vend_id_fkey FOREIGN KEY (apapply_vend_id) REFERENCES vendinfo(vend_id); -- -- Name: apapply_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY apapply ADD CONSTRAINT apapply_to_curr_symbol FOREIGN KEY (apapply_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: apcreditapply_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY apcreditapply ADD CONSTRAINT apcreditapply_curr_symbol FOREIGN KEY (apcreditapply_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: apopen_apopen_vend_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY apopen ADD CONSTRAINT apopen_apopen_vend_id_fkey FOREIGN KEY (apopen_vend_id) REFERENCES vendinfo(vend_id); -- -- Name: apopen_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY apopen ADD CONSTRAINT apopen_to_curr_symbol FOREIGN KEY (apopen_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: apopentax_taxhist_basis_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY apopentax ADD CONSTRAINT apopentax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); -- -- Name: apopentax_taxhist_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY apopentax ADD CONSTRAINT apopentax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES apopen(apopen_id) ON DELETE CASCADE; -- -- Name: apopentax_taxhist_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY apopentax ADD CONSTRAINT apopentax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); -- -- Name: apopentax_taxhist_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY apopentax ADD CONSTRAINT apopentax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: apselect_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY apselect ADD CONSTRAINT apselect_to_curr_symbol FOREIGN KEY (apselect_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: arapply_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY arapply ADD CONSTRAINT arapply_to_curr_symbol FOREIGN KEY (arapply_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: arcreditapply_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY arcreditapply ADD CONSTRAINT arcreditapply_curr_symbol FOREIGN KEY (arcreditapply_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: aropen_aropen_cust_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY aropen ADD CONSTRAINT aropen_aropen_cust_id_fkey FOREIGN KEY (aropen_cust_id) REFERENCES custinfo(cust_id); -- -- Name: aropen_aropen_salesrep_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY aropen ADD CONSTRAINT aropen_aropen_salesrep_id_fkey FOREIGN KEY (aropen_salesrep_id) REFERENCES salesrep(salesrep_id); -- -- Name: aropen_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY aropen ADD CONSTRAINT aropen_to_curr_symbol FOREIGN KEY (aropen_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: aropentax_taxhist_basis_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY aropentax ADD CONSTRAINT aropentax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); -- -- Name: aropentax_taxhist_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY aropentax ADD CONSTRAINT aropentax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES aropen(aropen_id) ON DELETE CASCADE; -- -- Name: aropentax_taxhist_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY aropentax ADD CONSTRAINT aropentax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); -- -- Name: aropentax_taxhist_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY aropentax ADD CONSTRAINT aropentax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: asohist_asohist_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY asohist ADD CONSTRAINT asohist_asohist_taxtype_id_fkey FOREIGN KEY (asohist_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: asohist_asohist_taxzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY asohist ADD CONSTRAINT asohist_asohist_taxzone_id_fkey FOREIGN KEY (asohist_taxzone_id) REFERENCES taxzone(taxzone_id); -- -- Name: asohist_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY asohist ADD CONSTRAINT asohist_to_curr_symbol FOREIGN KEY (asohist_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: asohisttax_taxhist_basis_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY asohisttax ADD CONSTRAINT asohisttax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); -- -- Name: asohisttax_taxhist_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY asohisttax ADD CONSTRAINT asohisttax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES asohist(asohist_id) ON DELETE CASCADE; -- -- Name: asohisttax_taxhist_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY asohisttax ADD CONSTRAINT asohisttax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); -- -- Name: asohisttax_taxhist_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY asohisttax ADD CONSTRAINT asohisttax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: bankaccnt_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY bankaccnt ADD CONSTRAINT bankaccnt_to_curr_symbol FOREIGN KEY (bankaccnt_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: bankadj_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY bankadj ADD CONSTRAINT bankadj_to_curr_symbol FOREIGN KEY (bankadj_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: bomhead_bomhead_item_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY bomhead ADD CONSTRAINT bomhead_bomhead_item_id_fkey FOREIGN KEY (bomhead_item_id) REFERENCES item(item_id) ON UPDATE RESTRICT ON DELETE CASCADE; -- -- Name: bomitem_bomitem_char_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY bomitem ADD CONSTRAINT bomitem_bomitem_char_id_fkey FOREIGN KEY (bomitem_char_id) REFERENCES "char"(char_id); -- -- Name: bomitem_bomitem_item_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY bomitem ADD CONSTRAINT bomitem_bomitem_item_id_fkey FOREIGN KEY (bomitem_item_id) REFERENCES item(item_id); -- -- Name: bomitem_bomitem_parent_item_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY bomitem ADD CONSTRAINT bomitem_bomitem_parent_item_id_fkey FOREIGN KEY (bomitem_parent_item_id) REFERENCES item(item_id) ON UPDATE RESTRICT ON DELETE CASCADE; -- -- Name: bomitem_bomitem_uom_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY bomitem ADD CONSTRAINT bomitem_bomitem_uom_id_fkey FOREIGN KEY (bomitem_uom_id) REFERENCES uom(uom_id); -- -- Name: bomitemcost_bomitemcost_bomitem_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY bomitemcost ADD CONSTRAINT bomitemcost_bomitemcost_bomitem_id_fkey FOREIGN KEY (bomitemcost_bomitem_id) REFERENCES bomitem(bomitem_id); -- -- Name: bomitemcost_bomitemcost_costelem_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY bomitemcost ADD CONSTRAINT bomitemcost_bomitemcost_costelem_id_fkey FOREIGN KEY (bomitemcost_costelem_id) REFERENCES costelem(costelem_id); -- -- Name: bomitemcost_bomitemcost_curr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY bomitemcost ADD CONSTRAINT bomitemcost_bomitemcost_curr_id_fkey FOREIGN KEY (bomitemcost_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: bomitemsub_bomitemsub_bomitem_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY bomitemsub ADD CONSTRAINT bomitemsub_bomitemsub_bomitem_id_fkey FOREIGN KEY (bomitemsub_bomitem_id) REFERENCES bomitem(bomitem_id) ON UPDATE RESTRICT ON DELETE CASCADE; -- -- Name: bomitemsub_bomitemsub_item_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY bomitemsub ADD CONSTRAINT bomitemsub_bomitemsub_item_id_fkey FOREIGN KEY (bomitemsub_item_id) REFERENCES item(item_id) ON UPDATE RESTRICT ON DELETE CASCADE; -- -- Name: bomwork_bomwork_char_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY bomwork ADD CONSTRAINT bomwork_bomwork_char_id_fkey FOREIGN KEY (bomwork_char_id) REFERENCES "char"(char_id); -- -- Name: budgitem_budgitem_budghead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY budgitem ADD CONSTRAINT budgitem_budgitem_budghead_id_fkey FOREIGN KEY (budgitem_budghead_id) REFERENCES budghead(budghead_id); -- -- Name: budgitem_budgitem_period_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY budgitem ADD CONSTRAINT budgitem_budgitem_period_id_fkey FOREIGN KEY (budgitem_period_id) REFERENCES period(period_id); -- -- Name: cashrcpt_bankaccnt_bankaccnt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cashrcpt ADD CONSTRAINT cashrcpt_bankaccnt_bankaccnt_id_fkey FOREIGN KEY (cashrcpt_bankaccnt_id) REFERENCES bankaccnt(bankaccnt_id); -- -- Name: cashrcpt_cust_cust_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cashrcpt ADD CONSTRAINT cashrcpt_cust_cust_id_fkey FOREIGN KEY (cashrcpt_cust_id) REFERENCES custinfo(cust_id); -- -- Name: cashrcpt_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cashrcpt ADD CONSTRAINT cashrcpt_to_curr_symbol FOREIGN KEY (cashrcpt_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: cashrcptitem_aropen_aropen_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cashrcptitem ADD CONSTRAINT cashrcptitem_aropen_aropen_id_fkey FOREIGN KEY (cashrcptitem_aropen_id) REFERENCES aropen(aropen_id); -- -- Name: cashrcptitem_cashrcpt_cashrcpt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cashrcptitem ADD CONSTRAINT cashrcptitem_cashrcpt_cashrcpt_id_fkey FOREIGN KEY (cashrcptitem_cashrcpt_id) REFERENCES cashrcpt(cashrcpt_id); -- -- Name: cashrcptmisc_accnt_accnt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cashrcptmisc ADD CONSTRAINT cashrcptmisc_accnt_accnt_id_fkey FOREIGN KEY (cashrcptmisc_accnt_id) REFERENCES accnt(accnt_id); -- -- Name: cashrcptmisc_cashrcpt_cashrcpt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cashrcptmisc ADD CONSTRAINT cashrcptmisc_cashrcpt_cashrcpt_id_fkey FOREIGN KEY (cashrcptmisc_cashrcpt_id) REFERENCES cashrcpt(cashrcpt_id); -- -- Name: ccard_ccard_cust_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ccard ADD CONSTRAINT ccard_ccard_cust_id_fkey FOREIGN KEY (ccard_cust_id) REFERENCES custinfo(cust_id); -- -- Name: ccbank_ccbank_bankaccnt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ccbank ADD CONSTRAINT ccbank_ccbank_bankaccnt_id_fkey FOREIGN KEY (ccbank_bankaccnt_id) REFERENCES bankaccnt(bankaccnt_id); -- -- Name: charopt_charopt_char_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY charopt ADD CONSTRAINT charopt_charopt_char_id_fkey FOREIGN KEY (charopt_char_id) REFERENCES "char"(char_id) ON DELETE CASCADE; -- -- Name: charuse_charuse_char_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY charuse ADD CONSTRAINT charuse_charuse_char_id_fkey FOREIGN KEY (charuse_char_id) REFERENCES "char"(char_id) ON DELETE CASCADE; -- -- Name: checkhead_checkhead_bankaccnt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY checkhead ADD CONSTRAINT checkhead_checkhead_bankaccnt_id_fkey FOREIGN KEY (checkhead_bankaccnt_id) REFERENCES bankaccnt(bankaccnt_id); -- -- Name: checkhead_checkhead_curr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY checkhead ADD CONSTRAINT checkhead_checkhead_curr_id_fkey FOREIGN KEY (checkhead_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: checkhead_checkhead_expcat_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY checkhead ADD CONSTRAINT checkhead_checkhead_expcat_id_fkey FOREIGN KEY (checkhead_expcat_id) REFERENCES expcat(expcat_id); -- -- Name: checkitem_checkitem_apopen_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY checkitem ADD CONSTRAINT checkitem_checkitem_apopen_id_fkey FOREIGN KEY (checkitem_apopen_id) REFERENCES apopen(apopen_id); -- -- Name: checkitem_checkitem_aropen_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY checkitem ADD CONSTRAINT checkitem_checkitem_aropen_id_fkey FOREIGN KEY (checkitem_aropen_id) REFERENCES aropen(aropen_id); -- -- Name: checkitem_checkitem_checkhead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY checkitem ADD CONSTRAINT checkitem_checkitem_checkhead_id_fkey FOREIGN KEY (checkitem_checkhead_id) REFERENCES checkhead(checkhead_id); -- -- Name: checkitem_checkitem_curr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY checkitem ADD CONSTRAINT checkitem_checkitem_curr_id_fkey FOREIGN KEY (checkitem_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: cmdarg_cmdarg_cmd_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmdarg ADD CONSTRAINT cmdarg_cmdarg_cmd_id_fkey FOREIGN KEY (cmdarg_cmd_id) REFERENCES cmd(cmd_id) ON DELETE CASCADE; -- -- Name: cmhead_cmhead_cust_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmhead ADD CONSTRAINT cmhead_cmhead_cust_id_fkey FOREIGN KEY (cmhead_cust_id) REFERENCES custinfo(cust_id); -- -- Name: cmhead_cmhead_freighttaxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmhead ADD CONSTRAINT cmhead_cmhead_freighttaxtype_id_fkey FOREIGN KEY (cmhead_freighttaxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: cmhead_cmhead_prj_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmhead ADD CONSTRAINT cmhead_cmhead_prj_id_fkey FOREIGN KEY (cmhead_prj_id) REFERENCES prj(prj_id); -- -- Name: cmhead_cmhead_salesrep_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmhead ADD CONSTRAINT cmhead_cmhead_salesrep_id_fkey FOREIGN KEY (cmhead_salesrep_id) REFERENCES salesrep(salesrep_id); -- -- Name: cmhead_cmhead_saletype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmhead ADD CONSTRAINT cmhead_cmhead_saletype_id_fkey FOREIGN KEY (cmhead_saletype_id) REFERENCES saletype(saletype_id); -- -- Name: cmhead_cmhead_shipzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmhead ADD CONSTRAINT cmhead_cmhead_shipzone_id_fkey FOREIGN KEY (cmhead_shipzone_id) REFERENCES shipzone(shipzone_id); -- -- Name: cmhead_cmhead_taxzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmhead ADD CONSTRAINT cmhead_cmhead_taxzone_id_fkey FOREIGN KEY (cmhead_taxzone_id) REFERENCES taxzone(taxzone_id); -- -- Name: cmhead_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmhead ADD CONSTRAINT cmhead_to_curr_symbol FOREIGN KEY (cmhead_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: cmheadtax_taxhist_basis_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmheadtax ADD CONSTRAINT cmheadtax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); -- -- Name: cmheadtax_taxhist_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmheadtax ADD CONSTRAINT cmheadtax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES cmhead(cmhead_id) ON DELETE CASCADE; -- -- Name: cmheadtax_taxhist_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmheadtax ADD CONSTRAINT cmheadtax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); -- -- Name: cmheadtax_taxhist_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmheadtax ADD CONSTRAINT cmheadtax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: cmitem_cmhead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmitem ADD CONSTRAINT cmitem_cmhead_id_fkey FOREIGN KEY (cmitem_cmhead_id) REFERENCES cmhead(cmhead_id) ON UPDATE CASCADE ON DELETE CASCADE; -- -- Name: cmitem_cmitem_price_uom_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmitem ADD CONSTRAINT cmitem_cmitem_price_uom_id_fkey FOREIGN KEY (cmitem_price_uom_id) REFERENCES uom(uom_id); -- -- Name: cmitem_cmitem_qty_uom_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmitem ADD CONSTRAINT cmitem_cmitem_qty_uom_id_fkey FOREIGN KEY (cmitem_qty_uom_id) REFERENCES uom(uom_id); -- -- Name: cmitem_cmitem_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmitem ADD CONSTRAINT cmitem_cmitem_taxtype_id_fkey FOREIGN KEY (cmitem_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: cmitemtax_taxhist_basis_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmitemtax ADD CONSTRAINT cmitemtax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); -- -- Name: cmitemtax_taxhist_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmitemtax ADD CONSTRAINT cmitemtax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES cmitem(cmitem_id) ON DELETE CASCADE; -- -- Name: cmitemtax_taxhist_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmitemtax ADD CONSTRAINT cmitemtax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); -- -- Name: cmitemtax_taxhist_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmitemtax ADD CONSTRAINT cmitemtax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: cmnttypesource_cmnttypesource_cmnttype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmnttypesource ADD CONSTRAINT cmnttypesource_cmnttypesource_cmnttype_id_fkey FOREIGN KEY (cmnttypesource_cmnttype_id) REFERENCES cmnttype(cmnttype_id); -- -- Name: cmnttypesource_cmnttypesource_source_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cmnttypesource ADD CONSTRAINT cmnttypesource_cmnttypesource_source_id_fkey FOREIGN KEY (cmnttypesource_source_id) REFERENCES source(source_id); -- -- Name: cntct_cntct_addr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cntct ADD CONSTRAINT cntct_cntct_addr_id_fkey FOREIGN KEY (cntct_addr_id) REFERENCES addr(addr_id); -- -- Name: cntct_cntct_crmacct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cntct ADD CONSTRAINT cntct_cntct_crmacct_id_fkey FOREIGN KEY (cntct_crmacct_id) REFERENCES crmacct(crmacct_id); -- -- Name: cntctaddr_cntctaddr_addr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cntctaddr ADD CONSTRAINT cntctaddr_cntctaddr_addr_id_fkey FOREIGN KEY (cntctaddr_addr_id) REFERENCES addr(addr_id); -- -- Name: cntctaddr_cntctaddr_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cntctaddr ADD CONSTRAINT cntctaddr_cntctaddr_cntct_id_fkey FOREIGN KEY (cntctaddr_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE; -- -- Name: cntctdata_cntctdata_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cntctdata ADD CONSTRAINT cntctdata_cntctdata_cntct_id_fkey FOREIGN KEY (cntctdata_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE; -- -- Name: cntcteml_cntcteml_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cntcteml ADD CONSTRAINT cntcteml_cntcteml_cntct_id_fkey FOREIGN KEY (cntcteml_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE; -- -- Name: cntctmrgd_cntctmrgd_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cntctmrgd ADD CONSTRAINT cntctmrgd_cntctmrgd_cntct_id_fkey FOREIGN KEY (cntctmrgd_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE; -- -- Name: cntctsel_cntctsel_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cntctsel ADD CONSTRAINT cntctsel_cntctsel_cntct_id_fkey FOREIGN KEY (cntctsel_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE; -- -- Name: cobill_cobill_invcitem_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cobill ADD CONSTRAINT cobill_cobill_invcitem_id_fkey FOREIGN KEY (cobill_invcitem_id) REFERENCES invcitem(invcitem_id); -- -- Name: cobill_cobill_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cobill ADD CONSTRAINT cobill_cobill_taxtype_id_fkey FOREIGN KEY (cobill_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: cobilltax_taxhist_basis_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cobilltax ADD CONSTRAINT cobilltax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); -- -- Name: cobilltax_taxhist_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cobilltax ADD CONSTRAINT cobilltax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES cobill(cobill_id) ON DELETE CASCADE; -- -- Name: cobilltax_taxhist_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cobilltax ADD CONSTRAINT cobilltax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); -- -- Name: cobilltax_taxhist_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cobilltax ADD CONSTRAINT cobilltax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: cobmisc_cobmisc_invchead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cobmisc ADD CONSTRAINT cobmisc_cobmisc_invchead_id_fkey FOREIGN KEY (cobmisc_invchead_id) REFERENCES invchead(invchead_id); -- -- Name: cobmisc_cobmisc_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cobmisc ADD CONSTRAINT cobmisc_cobmisc_taxtype_id_fkey FOREIGN KEY (cobmisc_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: cobmisc_cobmisc_taxzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cobmisc ADD CONSTRAINT cobmisc_cobmisc_taxzone_id_fkey FOREIGN KEY (cobmisc_taxzone_id) REFERENCES taxzone(taxzone_id); -- -- Name: cobmisc_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cobmisc ADD CONSTRAINT cobmisc_to_curr_symbol FOREIGN KEY (cobmisc_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: cobmisctax_taxhist_basis_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cobmisctax ADD CONSTRAINT cobmisctax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); -- -- Name: cobmisctax_taxhist_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cobmisctax ADD CONSTRAINT cobmisctax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES cobmisc(cobmisc_id) ON DELETE CASCADE; -- -- Name: cobmisctax_taxhist_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cobmisctax ADD CONSTRAINT cobmisctax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); -- -- Name: cobmisctax_taxhist_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cobmisctax ADD CONSTRAINT cobmisctax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: cohead_cohead_billto_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_billto_cntct_id_fkey FOREIGN KEY (cohead_billto_cntct_id) REFERENCES cntct(cntct_id); -- -- Name: cohead_cohead_cust_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_cust_id_fkey FOREIGN KEY (cohead_cust_id) REFERENCES custinfo(cust_id); -- -- Name: cohead_cohead_misc_accnt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_misc_accnt_id_fkey FOREIGN KEY (cohead_misc_accnt_id) REFERENCES accnt(accnt_id); -- -- Name: cohead_cohead_ophead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_ophead_id_fkey FOREIGN KEY (cohead_ophead_id) REFERENCES ophead(ophead_id); -- -- Name: cohead_cohead_prj_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_prj_id_fkey FOREIGN KEY (cohead_prj_id) REFERENCES prj(prj_id); -- -- Name: cohead_cohead_salesrep_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_salesrep_id_fkey FOREIGN KEY (cohead_salesrep_id) REFERENCES salesrep(salesrep_id); -- -- Name: cohead_cohead_saletype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_saletype_id_fkey FOREIGN KEY (cohead_saletype_id) REFERENCES saletype(saletype_id); -- -- Name: cohead_cohead_shipform_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_shipform_id_fkey FOREIGN KEY (cohead_shipform_id) REFERENCES shipform(shipform_id); -- -- Name: cohead_cohead_shipto_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_shipto_cntct_id_fkey FOREIGN KEY (cohead_shipto_cntct_id) REFERENCES cntct(cntct_id); -- -- Name: cohead_cohead_shipto_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_shipto_id_fkey FOREIGN KEY (cohead_shipto_id) REFERENCES shiptoinfo(shipto_id); -- -- Name: cohead_cohead_shipzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_shipzone_id_fkey FOREIGN KEY (cohead_shipzone_id) REFERENCES shipzone(shipzone_id); -- -- Name: cohead_cohead_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_taxtype_id_fkey FOREIGN KEY (cohead_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: cohead_cohead_taxzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_taxzone_id_fkey FOREIGN KEY (cohead_taxzone_id) REFERENCES taxzone(taxzone_id); -- -- Name: cohead_cohead_terms_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_terms_id_fkey FOREIGN KEY (cohead_terms_id) REFERENCES terms(terms_id); -- -- Name: cohead_cohead_warehous_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_warehous_id_fkey FOREIGN KEY (cohead_warehous_id) REFERENCES whsinfo(warehous_id); -- -- Name: cohead_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohead ADD CONSTRAINT cohead_to_curr_symbol FOREIGN KEY (cohead_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: cohist_cohist_cohead_ccpay_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohist ADD CONSTRAINT cohist_cohist_cohead_ccpay_id_fkey FOREIGN KEY (cohist_cohead_ccpay_id) REFERENCES ccpay(ccpay_id); -- -- Name: cohist_cohist_cust_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohist ADD CONSTRAINT cohist_cohist_cust_id_fkey FOREIGN KEY (cohist_cust_id) REFERENCES custinfo(cust_id); -- -- Name: cohist_cohist_salesrep_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohist ADD CONSTRAINT cohist_cohist_salesrep_id_fkey FOREIGN KEY (cohist_salesrep_id) REFERENCES salesrep(salesrep_id); -- -- Name: cohist_cohist_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohist ADD CONSTRAINT cohist_cohist_taxtype_id_fkey FOREIGN KEY (cohist_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: cohist_cohist_taxzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohist ADD CONSTRAINT cohist_cohist_taxzone_id_fkey FOREIGN KEY (cohist_taxzone_id) REFERENCES taxzone(taxzone_id); -- -- Name: cohist_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohist ADD CONSTRAINT cohist_to_curr_symbol FOREIGN KEY (cohist_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: cohisttax_taxhist_basis_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohisttax ADD CONSTRAINT cohisttax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); -- -- Name: cohisttax_taxhist_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohisttax ADD CONSTRAINT cohisttax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES cohist(cohist_id) ON DELETE CASCADE; -- -- Name: cohisttax_taxhist_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohisttax ADD CONSTRAINT cohisttax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); -- -- Name: cohisttax_taxhist_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY cohisttax ADD CONSTRAINT cohisttax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: coitem_coitem_cohead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY coitem ADD CONSTRAINT coitem_coitem_cohead_id_fkey FOREIGN KEY (coitem_cohead_id) REFERENCES cohead(cohead_id) ON DELETE CASCADE; -- -- Name: coitem_coitem_cos_accnt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY coitem ADD CONSTRAINT coitem_coitem_cos_accnt_id_fkey FOREIGN KEY (coitem_cos_accnt_id) REFERENCES accnt(accnt_id); -- -- Name: coitem_coitem_itemsite_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY coitem ADD CONSTRAINT coitem_coitem_itemsite_id_fkey FOREIGN KEY (coitem_itemsite_id) REFERENCES itemsite(itemsite_id); -- -- Name: coitem_coitem_price_uom_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY coitem ADD CONSTRAINT coitem_coitem_price_uom_id_fkey FOREIGN KEY (coitem_price_uom_id) REFERENCES uom(uom_id); -- -- Name: coitem_coitem_qty_uom_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY coitem ADD CONSTRAINT coitem_coitem_qty_uom_id_fkey FOREIGN KEY (coitem_qty_uom_id) REFERENCES uom(uom_id); -- -- Name: coitem_coitem_rev_accnt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY coitem ADD CONSTRAINT coitem_coitem_rev_accnt_id_fkey FOREIGN KEY (coitem_rev_accnt_id) REFERENCES accnt(accnt_id); -- -- Name: coitem_coitem_substitute_item_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY coitem ADD CONSTRAINT coitem_coitem_substitute_item_id_fkey FOREIGN KEY (coitem_substitute_item_id) REFERENCES item(item_id); -- -- Name: coitem_coitem_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY coitem ADD CONSTRAINT coitem_coitem_taxtype_id_fkey FOREIGN KEY (coitem_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: comment_comment_cmnttype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY comment ADD CONSTRAINT comment_comment_cmnttype_id_fkey FOREIGN KEY (comment_cmnttype_id) REFERENCES cmnttype(cmnttype_id); -- -- Name: company_company_curr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY company ADD CONSTRAINT company_company_curr_id_fkey FOREIGN KEY (company_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: company_company_dscrp_accnt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY company ADD CONSTRAINT company_company_dscrp_accnt_id_fkey FOREIGN KEY (company_dscrp_accnt_id) REFERENCES accnt(accnt_id); -- -- Name: company_company_gainloss_accnt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY company ADD CONSTRAINT company_company_gainloss_accnt_id_fkey FOREIGN KEY (company_gainloss_accnt_id) REFERENCES accnt(accnt_id); -- -- Name: company_company_unrlzgainloss_accnt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY company ADD CONSTRAINT company_company_unrlzgainloss_accnt_id_fkey FOREIGN KEY (company_unrlzgainloss_accnt_id) REFERENCES accnt(accnt_id); -- -- Name: company_company_yearend_accnt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY company ADD CONSTRAINT company_company_yearend_accnt_id_fkey FOREIGN KEY (company_yearend_accnt_id) REFERENCES accnt(accnt_id); -- -- Name: contrct_contrct_vend_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY contrct ADD CONSTRAINT contrct_contrct_vend_id_fkey FOREIGN KEY (contrct_vend_id) REFERENCES vendinfo(vend_id); -- -- Name: costhist_new_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY costhist ADD CONSTRAINT costhist_new_to_curr_symbol FOREIGN KEY (costhist_newcurr_id) REFERENCES curr_symbol(curr_id); -- -- Name: costhist_old_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY costhist ADD CONSTRAINT costhist_old_to_curr_symbol FOREIGN KEY (costhist_oldcurr_id) REFERENCES curr_symbol(curr_id); -- -- Name: crmacct_crmacct_cntct_id_1_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_crmacct_cntct_id_1_fkey FOREIGN KEY (crmacct_cntct_id_1) REFERENCES cntct(cntct_id); -- -- Name: crmacct_crmacct_cntct_id_2_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_crmacct_cntct_id_2_fkey FOREIGN KEY (crmacct_cntct_id_2) REFERENCES cntct(cntct_id); -- -- Name: crmacct_crmacct_cust_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_crmacct_cust_id_fkey FOREIGN KEY (crmacct_cust_id) REFERENCES custinfo(cust_id); -- -- Name: crmacct_crmacct_emp_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_crmacct_emp_id_fkey FOREIGN KEY (crmacct_emp_id) REFERENCES emp(emp_id); -- -- Name: crmacct_crmacct_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_crmacct_parent_id_fkey FOREIGN KEY (crmacct_parent_id) REFERENCES crmacct(crmacct_id); -- -- Name: crmacct_crmacct_prospect_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_crmacct_prospect_id_fkey FOREIGN KEY (crmacct_prospect_id) REFERENCES prospect(prospect_id); -- -- Name: crmacct_crmacct_salesrep_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_crmacct_salesrep_id_fkey FOREIGN KEY (crmacct_salesrep_id) REFERENCES salesrep(salesrep_id); -- -- Name: crmacct_crmacct_taxauth_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_crmacct_taxauth_id_fkey FOREIGN KEY (crmacct_taxauth_id) REFERENCES taxauth(taxauth_id); -- -- Name: crmacct_crmacct_vend_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_crmacct_vend_id_fkey FOREIGN KEY (crmacct_vend_id) REFERENCES vendinfo(vend_id); -- -- Name: crmacctsel_crmacctsel_dest_crmacct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY crmacctsel ADD CONSTRAINT crmacctsel_crmacctsel_dest_crmacct_id_fkey FOREIGN KEY (crmacctsel_dest_crmacct_id) REFERENCES crmacct(crmacct_id) ON DELETE CASCADE; -- -- Name: crmacctsel_crmacctsel_src_crmacct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY crmacctsel ADD CONSTRAINT crmacctsel_crmacctsel_src_crmacct_id_fkey FOREIGN KEY (crmacctsel_src_crmacct_id) REFERENCES crmacct(crmacct_id) ON DELETE CASCADE; -- -- Name: curr_rate_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY curr_rate ADD CONSTRAINT curr_rate_to_curr_symbol FOREIGN KEY (curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: cust_creditlmt_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY custinfo ADD CONSTRAINT cust_creditlmt_to_curr_symbol FOREIGN KEY (cust_creditlmt_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: cust_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY custinfo ADD CONSTRAINT cust_to_curr_symbol FOREIGN KEY (cust_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: custinfo_cust_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY custinfo ADD CONSTRAINT custinfo_cust_cntct_id_fkey FOREIGN KEY (cust_cntct_id) REFERENCES cntct(cntct_id); -- -- Name: custinfo_cust_corrcntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY custinfo ADD CONSTRAINT custinfo_cust_corrcntct_id_fkey FOREIGN KEY (cust_corrcntct_id) REFERENCES cntct(cntct_id); -- -- Name: custinfo_cust_custtype_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY custinfo ADD CONSTRAINT custinfo_cust_custtype_fkey FOREIGN KEY (cust_custtype_id) REFERENCES custtype(custtype_id) ON UPDATE RESTRICT ON DELETE RESTRICT; -- -- Name: custinfo_cust_salesrep_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY custinfo ADD CONSTRAINT custinfo_cust_salesrep_fkey FOREIGN KEY (cust_salesrep_id) REFERENCES salesrep(salesrep_id) ON UPDATE RESTRICT ON DELETE RESTRICT; -- -- Name: custinfo_cust_shipform_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY custinfo ADD CONSTRAINT custinfo_cust_shipform_fkey FOREIGN KEY (cust_shipform_id) REFERENCES shipform(shipform_id) ON UPDATE RESTRICT ON DELETE RESTRICT; -- -- Name: custinfo_cust_taxzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY custinfo ADD CONSTRAINT custinfo_cust_taxzone_id_fkey FOREIGN KEY (cust_taxzone_id) REFERENCES taxzone(taxzone_id); -- -- Name: custinfo_cust_terms_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY custinfo ADD CONSTRAINT custinfo_cust_terms_fkey FOREIGN KEY (cust_terms_id) REFERENCES terms(terms_id) ON UPDATE RESTRICT ON DELETE RESTRICT; -- -- Name: emp_emp_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY emp ADD CONSTRAINT emp_emp_cntct_id_fkey FOREIGN KEY (emp_cntct_id) REFERENCES cntct(cntct_id); -- -- Name: emp_emp_dept_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY emp ADD CONSTRAINT emp_emp_dept_id_fkey FOREIGN KEY (emp_dept_id) REFERENCES dept(dept_id); -- -- Name: emp_emp_image_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY emp ADD CONSTRAINT emp_emp_image_id_fkey FOREIGN KEY (emp_image_id) REFERENCES image(image_id); -- -- Name: emp_emp_mgr_emp_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY emp ADD CONSTRAINT emp_emp_mgr_emp_id_fkey FOREIGN KEY (emp_mgr_emp_id) REFERENCES emp(emp_id); -- -- Name: emp_emp_shift_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY emp ADD CONSTRAINT emp_emp_shift_id_fkey FOREIGN KEY (emp_shift_id) REFERENCES shift(shift_id); -- -- Name: emp_emp_wage_curr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY emp ADD CONSTRAINT emp_emp_wage_curr_id_fkey FOREIGN KEY (emp_wage_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: emp_emp_warehous_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY emp ADD CONSTRAINT emp_emp_warehous_id_fkey FOREIGN KEY (emp_warehous_id) REFERENCES whsinfo(warehous_id); -- -- Name: empgrpitem_empgrpitem_emp_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY empgrpitem ADD CONSTRAINT empgrpitem_empgrpitem_emp_id_fkey FOREIGN KEY (empgrpitem_emp_id) REFERENCES emp(emp_id); -- -- Name: empgrpitem_empgrpitem_empgrp_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY empgrpitem ADD CONSTRAINT empgrpitem_empgrpitem_empgrp_id_fkey FOREIGN KEY (empgrpitem_empgrp_id) REFERENCES empgrp(empgrp_id); -- -- Name: flnotes_flnotes_flhead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY flnotes ADD CONSTRAINT flnotes_flnotes_flhead_id_fkey FOREIGN KEY (flnotes_flhead_id) REFERENCES flhead(flhead_id) ON DELETE CASCADE; -- -- Name: flnotes_flnotes_period_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY flnotes ADD CONSTRAINT flnotes_flnotes_period_id_fkey FOREIGN KEY (flnotes_period_id) REFERENCES period(period_id) ON DELETE CASCADE; -- -- Name: grppriv_grppriv_grp_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY grppriv ADD CONSTRAINT grppriv_grppriv_grp_id_fkey FOREIGN KEY (grppriv_grp_id) REFERENCES grp(grp_id); -- -- Name: incdt_incdt_aropen_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_aropen_id_fkey FOREIGN KEY (incdt_aropen_id) REFERENCES aropen(aropen_id); -- -- Name: incdt_incdt_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_cntct_id_fkey FOREIGN KEY (incdt_cntct_id) REFERENCES cntct(cntct_id); -- -- Name: incdt_incdt_crmacct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_crmacct_id_fkey FOREIGN KEY (incdt_crmacct_id) REFERENCES crmacct(crmacct_id); -- -- Name: incdt_incdt_incdtcat_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_incdtcat_id_fkey FOREIGN KEY (incdt_incdtcat_id) REFERENCES incdtcat(incdtcat_id); -- -- Name: incdt_incdt_incdtpriority_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_incdtpriority_id_fkey FOREIGN KEY (incdt_incdtpriority_id) REFERENCES incdtpriority(incdtpriority_id); -- -- Name: incdt_incdt_incdtresolution_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_incdtresolution_id_fkey FOREIGN KEY (incdt_incdtresolution_id) REFERENCES incdtresolution(incdtresolution_id); -- -- Name: incdt_incdt_incdtseverity_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_incdtseverity_id_fkey FOREIGN KEY (incdt_incdtseverity_id) REFERENCES incdtseverity(incdtseverity_id); -- -- Name: incdt_incdt_item_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_item_id_fkey FOREIGN KEY (incdt_item_id) REFERENCES item(item_id); -- -- Name: incdt_incdt_prj_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_prj_id_fkey FOREIGN KEY (incdt_prj_id) REFERENCES prj(prj_id); -- -- Name: incdt_incdt_recurring_incdt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_recurring_incdt_id_fkey FOREIGN KEY (incdt_recurring_incdt_id) REFERENCES incdt(incdt_id); -- -- Name: incdthist_incdthist_incdt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY incdthist ADD CONSTRAINT incdthist_incdthist_incdt_id_fkey FOREIGN KEY (incdthist_incdt_id) REFERENCES incdt(incdt_id); -- -- Name: invbal_invbal_itemsite_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invbal ADD CONSTRAINT invbal_invbal_itemsite_id_fkey FOREIGN KEY (invbal_itemsite_id) REFERENCES itemsite(itemsite_id) ON DELETE CASCADE; -- -- Name: invbal_invbal_period_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invbal ADD CONSTRAINT invbal_invbal_period_id_fkey FOREIGN KEY (invbal_period_id) REFERENCES period(period_id) ON DELETE CASCADE; -- -- Name: invchead_invchead_saletype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invchead ADD CONSTRAINT invchead_invchead_saletype_id_fkey FOREIGN KEY (invchead_saletype_id) REFERENCES saletype(saletype_id); -- -- Name: invchead_invchead_shipzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invchead ADD CONSTRAINT invchead_invchead_shipzone_id_fkey FOREIGN KEY (invchead_shipzone_id) REFERENCES shipzone(shipzone_id); -- -- Name: invchead_invchead_taxzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invchead ADD CONSTRAINT invchead_invchead_taxzone_id_fkey FOREIGN KEY (invchead_taxzone_id) REFERENCES taxzone(taxzone_id); -- -- Name: invchead_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invchead ADD CONSTRAINT invchead_to_curr_symbol FOREIGN KEY (invchead_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: invcheadtax_taxhist_basis_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invcheadtax ADD CONSTRAINT invcheadtax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); -- -- Name: invcheadtax_taxhist_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invcheadtax ADD CONSTRAINT invcheadtax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES invchead(invchead_id) ON DELETE CASCADE; -- -- Name: invcheadtax_taxhist_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invcheadtax ADD CONSTRAINT invcheadtax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); -- -- Name: invcheadtax_taxhist_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invcheadtax ADD CONSTRAINT invcheadtax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: invcitem_invchead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invcitem ADD CONSTRAINT invcitem_invchead_id_fkey FOREIGN KEY (invcitem_invchead_id) REFERENCES invchead(invchead_id) ON UPDATE CASCADE ON DELETE CASCADE; -- -- Name: invcitem_invcitem_price_uom_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invcitem ADD CONSTRAINT invcitem_invcitem_price_uom_id_fkey FOREIGN KEY (invcitem_price_uom_id) REFERENCES uom(uom_id); -- -- Name: invcitem_invcitem_qty_uom_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invcitem ADD CONSTRAINT invcitem_invcitem_qty_uom_id_fkey FOREIGN KEY (invcitem_qty_uom_id) REFERENCES uom(uom_id); -- -- Name: invcitem_invcitem_rev_accnt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invcitem ADD CONSTRAINT invcitem_invcitem_rev_accnt_id_fkey FOREIGN KEY (invcitem_rev_accnt_id) REFERENCES accnt(accnt_id); -- -- Name: invcitem_invcitem_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invcitem ADD CONSTRAINT invcitem_invcitem_taxtype_id_fkey FOREIGN KEY (invcitem_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: invcitemtax_taxhist_basis_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invcitemtax ADD CONSTRAINT invcitemtax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); -- -- Name: invcitemtax_taxhist_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invcitemtax ADD CONSTRAINT invcitemtax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES invcitem(invcitem_id) ON DELETE CASCADE; -- -- Name: invcitemtax_taxhist_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invcitemtax ADD CONSTRAINT invcitemtax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); -- -- Name: invcitemtax_taxhist_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invcitemtax ADD CONSTRAINT invcitemtax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: invhistexpcat_invhistexpcat_expcat_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invhistexpcat ADD CONSTRAINT invhistexpcat_invhistexpcat_expcat_id_fkey FOREIGN KEY (invhistexpcat_expcat_id) REFERENCES expcat(expcat_id) ON UPDATE CASCADE ON DELETE CASCADE; -- -- Name: invhistexpcat_invhistexpcat_invhist_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY invhistexpcat ADD CONSTRAINT invhistexpcat_invhistexpcat_invhist_id_fkey FOREIGN KEY (invhistexpcat_invhist_id) REFERENCES invhist(invhist_id) ON UPDATE CASCADE ON DELETE CASCADE; -- -- Name: ipsass_ipsass_ipshead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ipsass ADD CONSTRAINT ipsass_ipsass_ipshead_id_fkey FOREIGN KEY (ipsass_ipshead_id) REFERENCES ipshead(ipshead_id); -- -- Name: ipsfreight_ipsfreight_freightclass_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ipsfreight ADD CONSTRAINT ipsfreight_ipsfreight_freightclass_id_fkey FOREIGN KEY (ipsfreight_freightclass_id) REFERENCES freightclass(freightclass_id); -- -- Name: ipsfreight_ipsfreight_ipshead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ipsfreight ADD CONSTRAINT ipsfreight_ipsfreight_ipshead_id_fkey FOREIGN KEY (ipsfreight_ipshead_id) REFERENCES ipshead(ipshead_id); -- -- Name: ipsfreight_ipsfreight_shipzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ipsfreight ADD CONSTRAINT ipsfreight_ipsfreight_shipzone_id_fkey FOREIGN KEY (ipsfreight_shipzone_id) REFERENCES shipzone(shipzone_id); -- -- Name: ipsfreight_ipsfreight_warehous_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ipsfreight ADD CONSTRAINT ipsfreight_ipsfreight_warehous_id_fkey FOREIGN KEY (ipsfreight_warehous_id) REFERENCES whsinfo(warehous_id); -- -- Name: ipshead_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ipshead ADD CONSTRAINT ipshead_to_curr_symbol FOREIGN KEY (ipshead_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: ipsitem_ipshead_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ipsiteminfo ADD CONSTRAINT ipsitem_ipshead_id_fk FOREIGN KEY (ipsitem_ipshead_id) REFERENCES ipshead(ipshead_id) ON DELETE CASCADE; -- -- Name: ipsitem_ipsitem_price_uom_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ipsiteminfo ADD CONSTRAINT ipsitem_ipsitem_price_uom_id_fkey FOREIGN KEY (ipsitem_price_uom_id) REFERENCES uom(uom_id); -- -- Name: ipsitem_ipsitem_qty_uom_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ipsiteminfo ADD CONSTRAINT ipsitem_ipsitem_qty_uom_id_fkey FOREIGN KEY (ipsitem_qty_uom_id) REFERENCES uom(uom_id); -- -- Name: ipsitem_ipsitem_warehous_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ipsiteminfo ADD CONSTRAINT ipsitem_ipsitem_warehous_id_fkey FOREIGN KEY (ipsitem_warehous_id) REFERENCES whsinfo(warehous_id); -- -- Name: ipsitem_item_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ipsiteminfo ADD CONSTRAINT ipsitem_item_id_fk FOREIGN KEY (ipsitem_item_id) REFERENCES item(item_id); -- -- Name: ipsitemchar_ipsitemchar_char_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ipsitemchar ADD CONSTRAINT ipsitemchar_ipsitemchar_char_id_fkey FOREIGN KEY (ipsitemchar_char_id) REFERENCES "char"(char_id); -- -- Name: ipsitemchar_ipsitemchar_ipsitem_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ipsitemchar ADD CONSTRAINT ipsitemchar_ipsitemchar_ipsitem_id_fkey FOREIGN KEY (ipsitemchar_ipsitem_id) REFERENCES ipsiteminfo(ipsitem_id) ON DELETE CASCADE; -- -- Name: item_item_classcode_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY item ADD CONSTRAINT item_item_classcode_id_fkey FOREIGN KEY (item_classcode_id) REFERENCES classcode(classcode_id); -- -- Name: item_item_freightclass_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY item ADD CONSTRAINT item_item_freightclass_id_fkey FOREIGN KEY (item_freightclass_id) REFERENCES freightclass(freightclass_id); -- -- Name: item_item_inv_uom_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY item ADD CONSTRAINT item_item_inv_uom_id_fkey FOREIGN KEY (item_inv_uom_id) REFERENCES uom(uom_id); -- -- Name: item_item_price_uom_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY item ADD CONSTRAINT item_item_price_uom_id_fkey FOREIGN KEY (item_price_uom_id) REFERENCES uom(uom_id); -- -- Name: itemalias_itemalias_crmacct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemalias ADD CONSTRAINT itemalias_itemalias_crmacct_id_fkey FOREIGN KEY (itemalias_crmacct_id) REFERENCES crmacct(crmacct_id); -- -- Name: itemalias_itemalias_item_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemalias ADD CONSTRAINT itemalias_itemalias_item_id_fkey FOREIGN KEY (itemalias_item_id) REFERENCES item(item_id); -- -- Name: itemcost_itemcost_costelem_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemcost ADD CONSTRAINT itemcost_itemcost_costelem_id_fkey FOREIGN KEY (itemcost_costelem_id) REFERENCES costelem(costelem_id); -- -- Name: itemcost_itemcost_curr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemcost ADD CONSTRAINT itemcost_itemcost_curr_id_fkey FOREIGN KEY (itemcost_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: itemcost_itemcost_item_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemcost ADD CONSTRAINT itemcost_itemcost_item_id_fkey FOREIGN KEY (itemcost_item_id) REFERENCES item(item_id); -- -- Name: itemcost_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemcost ADD CONSTRAINT itemcost_to_curr_symbol FOREIGN KEY (itemcost_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: itemsite_itemsite_costcat_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemsite ADD CONSTRAINT itemsite_itemsite_costcat_id_fkey FOREIGN KEY (itemsite_costcat_id) REFERENCES costcat(costcat_id); -- -- Name: itemsite_itemsite_item_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemsite ADD CONSTRAINT itemsite_itemsite_item_id_fkey FOREIGN KEY (itemsite_item_id) REFERENCES item(item_id); -- -- Name: itemsite_itemsite_plancode_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemsite ADD CONSTRAINT itemsite_itemsite_plancode_id_fkey FOREIGN KEY (itemsite_plancode_id) REFERENCES plancode(plancode_id); -- -- Name: itemsite_itemsite_warehous_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemsite ADD CONSTRAINT itemsite_itemsite_warehous_id_fkey FOREIGN KEY (itemsite_warehous_id) REFERENCES whsinfo(warehous_id); -- -- Name: itemsrc_itemsrc_contrct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemsrc ADD CONSTRAINT itemsrc_itemsrc_contrct_id_fkey FOREIGN KEY (itemsrc_contrct_id) REFERENCES contrct(contrct_id); -- -- Name: itemsrc_itemsrc_item_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemsrc ADD CONSTRAINT itemsrc_itemsrc_item_id_fkey FOREIGN KEY (itemsrc_item_id) REFERENCES item(item_id) ON DELETE CASCADE; -- -- Name: itemsrc_itemsrc_vend_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemsrc ADD CONSTRAINT itemsrc_itemsrc_vend_id_fkey FOREIGN KEY (itemsrc_vend_id) REFERENCES vendinfo(vend_id) ON DELETE CASCADE; -- -- Name: itemsrcp_itemsrcp_itemsrc_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemsrcp ADD CONSTRAINT itemsrcp_itemsrcp_itemsrc_id_fkey FOREIGN KEY (itemsrcp_itemsrc_id) REFERENCES itemsrc(itemsrc_id) ON DELETE CASCADE; -- -- Name: itemsrcp_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemsrcp ADD CONSTRAINT itemsrcp_to_curr_symbol FOREIGN KEY (itemsrcp_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: itemsub_itemsub_parent_item_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemsub ADD CONSTRAINT itemsub_itemsub_parent_item_id_fkey FOREIGN KEY (itemsub_parent_item_id) REFERENCES item(item_id); -- -- Name: itemsub_itemsub_sub_item_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemsub ADD CONSTRAINT itemsub_itemsub_sub_item_id_fkey FOREIGN KEY (itemsub_sub_item_id) REFERENCES item(item_id); -- -- Name: itemtax_itemtax_item_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemtax ADD CONSTRAINT itemtax_itemtax_item_id_fkey FOREIGN KEY (itemtax_item_id) REFERENCES item(item_id); -- -- Name: itemtax_itemtax_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemtax ADD CONSTRAINT itemtax_itemtax_taxtype_id_fkey FOREIGN KEY (itemtax_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: itemtax_itemtax_taxzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemtax ADD CONSTRAINT itemtax_itemtax_taxzone_id_fkey FOREIGN KEY (itemtax_taxzone_id) REFERENCES taxzone(taxzone_id); -- -- Name: itemtrans_itemtrans_source_item_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemtrans ADD CONSTRAINT itemtrans_itemtrans_source_item_id_fkey FOREIGN KEY (itemtrans_source_item_id) REFERENCES item(item_id); -- -- Name: itemtrans_itemtrans_target_item_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemtrans ADD CONSTRAINT itemtrans_itemtrans_target_item_id_fkey FOREIGN KEY (itemtrans_target_item_id) REFERENCES item(item_id); -- -- Name: itemuom_itemuom_itemuomconv_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemuom ADD CONSTRAINT itemuom_itemuom_itemuomconv_id_fkey FOREIGN KEY (itemuom_itemuomconv_id) REFERENCES itemuomconv(itemuomconv_id); -- -- Name: itemuom_itemuom_uomtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemuom ADD CONSTRAINT itemuom_itemuom_uomtype_id_fkey FOREIGN KEY (itemuom_uomtype_id) REFERENCES uomtype(uomtype_id); -- -- Name: itemuomconv_itemuomconv_from_uom_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemuomconv ADD CONSTRAINT itemuomconv_itemuomconv_from_uom_id_fkey FOREIGN KEY (itemuomconv_from_uom_id) REFERENCES uom(uom_id); -- -- Name: itemuomconv_itemuomconv_item_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemuomconv ADD CONSTRAINT itemuomconv_itemuomconv_item_id_fkey FOREIGN KEY (itemuomconv_item_id) REFERENCES item(item_id); -- -- Name: itemuomconv_itemuomconv_to_uom_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY itemuomconv ADD CONSTRAINT itemuomconv_itemuomconv_to_uom_id_fkey FOREIGN KEY (itemuomconv_to_uom_id) REFERENCES uom(uom_id); -- -- Name: mrghist_mrghist_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY mrghist ADD CONSTRAINT mrghist_mrghist_cntct_id_fkey FOREIGN KEY (mrghist_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE; -- -- Name: ophead_ophead_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ophead ADD CONSTRAINT ophead_ophead_cntct_id_fkey FOREIGN KEY (ophead_cntct_id) REFERENCES cntct(cntct_id); -- -- Name: ophead_ophead_crmacct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ophead ADD CONSTRAINT ophead_ophead_crmacct_id_fkey FOREIGN KEY (ophead_crmacct_id) REFERENCES crmacct(crmacct_id); -- -- Name: ophead_ophead_opsource_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ophead ADD CONSTRAINT ophead_ophead_opsource_id_fkey FOREIGN KEY (ophead_opsource_id) REFERENCES opsource(opsource_id); -- -- Name: ophead_ophead_opstage_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ophead ADD CONSTRAINT ophead_ophead_opstage_id_fkey FOREIGN KEY (ophead_opstage_id) REFERENCES opstage(opstage_id); -- -- Name: ophead_ophead_optype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ophead ADD CONSTRAINT ophead_ophead_optype_id_fkey FOREIGN KEY (ophead_optype_id) REFERENCES optype(optype_id); -- -- Name: ophead_ophead_priority_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY ophead ADD CONSTRAINT ophead_ophead_priority_id_fkey FOREIGN KEY (ophead_priority_id) REFERENCES incdtpriority(incdtpriority_id); -- -- Name: pack_pack_shiphead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY pack ADD CONSTRAINT pack_pack_shiphead_id_fkey FOREIGN KEY (pack_shiphead_id) REFERENCES shiphead(shiphead_id); -- -- Name: payco_payco_ccpay_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY payco ADD CONSTRAINT payco_payco_ccpay_id_fkey FOREIGN KEY (payco_ccpay_id) REFERENCES ccpay(ccpay_id); -- -- Name: payco_payco_cohead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY payco ADD CONSTRAINT payco_payco_cohead_id_fkey FOREIGN KEY (payco_cohead_id) REFERENCES cohead(cohead_id); -- -- Name: pkgdep_pkgdep_parent_pkghead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY pkgdep ADD CONSTRAINT pkgdep_pkgdep_parent_pkghead_id_fkey FOREIGN KEY (pkgdep_parent_pkghead_id) REFERENCES pkghead(pkghead_id); -- -- Name: pkgdep_pkgdep_pkghead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY pkgdep ADD CONSTRAINT pkgdep_pkgdep_pkghead_id_fkey FOREIGN KEY (pkgdep_pkghead_id) REFERENCES pkghead(pkghead_id); -- -- Name: pkgitem_pkgitem_pkghead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY pkgitem ADD CONSTRAINT pkgitem_pkgitem_pkghead_id_fkey FOREIGN KEY (pkgitem_pkghead_id) REFERENCES pkghead(pkghead_id) ON DELETE CASCADE; -- -- Name: pohead_pohead_cohead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_cohead_id_fkey FOREIGN KEY (pohead_cohead_id) REFERENCES cohead(cohead_id) ON DELETE SET NULL; -- -- Name: pohead_pohead_shipto_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_shipto_cntct_id_fkey FOREIGN KEY (pohead_shipto_cntct_id) REFERENCES cntct(cntct_id); -- -- Name: pohead_pohead_shiptoddress_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_shiptoddress_id_fkey FOREIGN KEY (pohead_shiptoaddress_id) REFERENCES addr(addr_id); -- -- Name: pohead_pohead_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_taxtype_id_fkey FOREIGN KEY (pohead_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: pohead_pohead_taxzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_taxzone_id_fkey FOREIGN KEY (pohead_taxzone_id) REFERENCES taxzone(taxzone_id); -- -- Name: pohead_pohead_terms_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_terms_id_fkey FOREIGN KEY (pohead_terms_id) REFERENCES terms(terms_id); -- -- Name: pohead_pohead_vend_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_vend_cntct_id_fkey FOREIGN KEY (pohead_vend_cntct_id) REFERENCES cntct(cntct_id); -- -- Name: pohead_pohead_vend_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_vend_id_fkey FOREIGN KEY (pohead_vend_id) REFERENCES vendinfo(vend_id); -- -- Name: pohead_pohead_vendaddr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_vendaddr_id_fkey FOREIGN KEY (pohead_vendaddr_id) REFERENCES vendaddrinfo(vendaddr_id); -- -- Name: pohead_pohead_warehous_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_warehous_id_fkey FOREIGN KEY (pohead_warehous_id) REFERENCES whsinfo(warehous_id); -- -- Name: pohead_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY pohead ADD CONSTRAINT pohead_to_curr_symbol FOREIGN KEY (pohead_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: poitem_poitem_expcat_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY poitem ADD CONSTRAINT poitem_poitem_expcat_id_fkey FOREIGN KEY (poitem_expcat_id) REFERENCES expcat(expcat_id); -- -- Name: poitem_poitem_itemsite_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY poitem ADD CONSTRAINT poitem_poitem_itemsite_id_fkey FOREIGN KEY (poitem_itemsite_id) REFERENCES itemsite(itemsite_id); -- -- Name: poitem_poitem_itemsrc_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY poitem ADD CONSTRAINT poitem_poitem_itemsrc_id_fkey FOREIGN KEY (poitem_itemsrc_id) REFERENCES itemsrc(itemsrc_id); -- -- Name: poitem_poitem_prj_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY poitem ADD CONSTRAINT poitem_poitem_prj_id_fkey FOREIGN KEY (poitem_prj_id) REFERENCES prj(prj_id); -- -- Name: poitem_poitem_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY poitem ADD CONSTRAINT poitem_poitem_taxtype_id_fkey FOREIGN KEY (poitem_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: poreject_poreject_recv_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY poreject ADD CONSTRAINT poreject_poreject_recv_id_fkey FOREIGN KEY (poreject_recv_id) REFERENCES recv(recv_id); -- -- Name: poreject_poreject_vend_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY poreject ADD CONSTRAINT poreject_poreject_vend_id_fkey FOREIGN KEY (poreject_vend_id) REFERENCES vendinfo(vend_id); -- -- Name: prj_prj_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY prj ADD CONSTRAINT prj_prj_cntct_id_fkey FOREIGN KEY (prj_cntct_id) REFERENCES cntct(cntct_id); -- -- Name: prj_prj_crmacct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY prj ADD CONSTRAINT prj_prj_crmacct_id_fkey FOREIGN KEY (prj_crmacct_id) REFERENCES crmacct(crmacct_id); -- -- Name: prj_prj_prjtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY prj ADD CONSTRAINT prj_prj_prjtype_id_fkey FOREIGN KEY (prj_prjtype_id) REFERENCES prjtype(prjtype_id); -- -- Name: prj_prj_recurring_prj_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY prj ADD CONSTRAINT prj_prj_recurring_prj_id_fkey FOREIGN KEY (prj_recurring_prj_id) REFERENCES prj(prj_id); -- -- Name: prjtask_prjtask_prj_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY prjtask ADD CONSTRAINT prjtask_prjtask_prj_id_fkey FOREIGN KEY (prjtask_prj_id) REFERENCES prj(prj_id); -- -- Name: prospect_prospect_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY prospect ADD CONSTRAINT prospect_prospect_cntct_id_fkey FOREIGN KEY (prospect_cntct_id) REFERENCES cntct(cntct_id); -- -- Name: prospect_prospect_salesrep_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY prospect ADD CONSTRAINT prospect_prospect_salesrep_id_fkey FOREIGN KEY (prospect_salesrep_id) REFERENCES salesrep(salesrep_id); -- -- Name: prospect_prospect_taxzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY prospect ADD CONSTRAINT prospect_prospect_taxzone_id_fkey FOREIGN KEY (prospect_taxzone_id) REFERENCES taxzone(taxzone_id); -- -- Name: prospect_prospect_warehous_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY prospect ADD CONSTRAINT prospect_prospect_warehous_id_fkey FOREIGN KEY (prospect_warehous_id) REFERENCES whsinfo(warehous_id); -- -- Name: qryitem_qryitem_qryhead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY qryitem ADD CONSTRAINT qryitem_qryitem_qryhead_id_fkey FOREIGN KEY (qryitem_qryhead_id) REFERENCES qryhead(qryhead_id); -- -- Name: quhead_quhead_billto_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_billto_cntct_id_fkey FOREIGN KEY (quhead_billto_cntct_id) REFERENCES cntct(cntct_id); -- -- Name: quhead_quhead_misc_accnt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_misc_accnt_id_fkey FOREIGN KEY (quhead_misc_accnt_id) REFERENCES accnt(accnt_id); -- -- Name: quhead_quhead_ophead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_ophead_id_fkey FOREIGN KEY (quhead_ophead_id) REFERENCES ophead(ophead_id); -- -- Name: quhead_quhead_prj_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_prj_id_fkey FOREIGN KEY (quhead_prj_id) REFERENCES prj(prj_id); -- -- Name: quhead_quhead_salesrep_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_salesrep_id_fkey FOREIGN KEY (quhead_salesrep_id) REFERENCES salesrep(salesrep_id); -- -- Name: quhead_quhead_saletype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_saletype_id_fkey FOREIGN KEY (quhead_saletype_id) REFERENCES saletype(saletype_id); -- -- Name: quhead_quhead_shipto_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_shipto_cntct_id_fkey FOREIGN KEY (quhead_shipto_cntct_id) REFERENCES cntct(cntct_id); -- -- Name: quhead_quhead_shipto_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_shipto_id_fkey FOREIGN KEY (quhead_shipto_id) REFERENCES shiptoinfo(shipto_id); -- -- Name: quhead_quhead_shipzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_shipzone_id_fkey FOREIGN KEY (quhead_shipzone_id) REFERENCES shipzone(shipzone_id); -- -- Name: quhead_quhead_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_taxtype_id_fkey FOREIGN KEY (quhead_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: quhead_quhead_taxzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_taxzone_id_fkey FOREIGN KEY (quhead_taxzone_id) REFERENCES taxzone(taxzone_id); -- -- Name: quhead_quhead_terms_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_terms_id_fkey FOREIGN KEY (quhead_terms_id) REFERENCES terms(terms_id); -- -- Name: quhead_quhead_warehous_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_warehous_id_fkey FOREIGN KEY (quhead_warehous_id) REFERENCES whsinfo(warehous_id); -- -- Name: quhead_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY quhead ADD CONSTRAINT quhead_to_curr_symbol FOREIGN KEY (quhead_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: quitem_quitem_itemsrc_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY quitem ADD CONSTRAINT quitem_quitem_itemsrc_id_fkey FOREIGN KEY (quitem_itemsrc_id) REFERENCES itemsrc(itemsrc_id); -- -- Name: quitem_quitem_price_uom_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY quitem ADD CONSTRAINT quitem_quitem_price_uom_id_fkey FOREIGN KEY (quitem_price_uom_id) REFERENCES uom(uom_id); -- -- Name: quitem_quitem_qty_uom_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY quitem ADD CONSTRAINT quitem_quitem_qty_uom_id_fkey FOREIGN KEY (quitem_qty_uom_id) REFERENCES uom(uom_id); -- -- Name: quitem_quitem_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY quitem ADD CONSTRAINT quitem_quitem_taxtype_id_fkey FOREIGN KEY (quitem_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: recv_recv_freight_curr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY recv ADD CONSTRAINT recv_recv_freight_curr_id_fkey FOREIGN KEY (recv_freight_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: recv_recv_itemsite_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY recv ADD CONSTRAINT recv_recv_itemsite_id_fkey FOREIGN KEY (recv_itemsite_id) REFERENCES itemsite(itemsite_id); -- -- Name: recv_recv_purchcost_curr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY recv ADD CONSTRAINT recv_recv_purchcost_curr_id_fkey FOREIGN KEY (recv_purchcost_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: recv_recv_recvcost_curr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY recv ADD CONSTRAINT recv_recv_recvcost_curr_id_fkey FOREIGN KEY (recv_recvcost_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: recv_recv_splitfrom_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY recv ADD CONSTRAINT recv_recv_splitfrom_id_fkey FOREIGN KEY (recv_splitfrom_id) REFERENCES recv(recv_id); -- -- Name: recv_recv_vend_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY recv ADD CONSTRAINT recv_recv_vend_id_fkey FOREIGN KEY (recv_vend_id) REFERENCES vendinfo(vend_id); -- -- Name: recv_recv_vohead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY recv ADD CONSTRAINT recv_recv_vohead_id_fkey FOREIGN KEY (recv_vohead_id) REFERENCES vohead(vohead_id); -- -- Name: recv_recv_voitem_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY recv ADD CONSTRAINT recv_recv_voitem_id_fkey FOREIGN KEY (recv_voitem_id) REFERENCES voitem(voitem_id); -- -- Name: salesrep_salesrep_emp_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY salesrep ADD CONSTRAINT salesrep_salesrep_emp_id_fkey FOREIGN KEY (salesrep_emp_id) REFERENCES emp(emp_id); -- -- Name: shipdata_shipdata_base_freight_curr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shipdata ADD CONSTRAINT shipdata_shipdata_base_freight_curr_id_fkey FOREIGN KEY (shipdata_base_freight_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: shipdata_shipdata_shiphead_number_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shipdata ADD CONSTRAINT shipdata_shipdata_shiphead_number_fkey FOREIGN KEY (shipdata_shiphead_number) REFERENCES shiphead(shiphead_number); -- -- Name: shipdata_shipdata_total_freight_curr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shipdata ADD CONSTRAINT shipdata_shipdata_total_freight_curr_id_fkey FOREIGN KEY (shipdata_total_freight_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: shipdatasum_shipdatasum_base_freight_curr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shipdatasum ADD CONSTRAINT shipdatasum_shipdatasum_base_freight_curr_id_fkey FOREIGN KEY (shipdatasum_base_freight_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: shipdatasum_shipdatasum_shiphead_number_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shipdatasum ADD CONSTRAINT shipdatasum_shipdatasum_shiphead_number_fkey FOREIGN KEY (shipdatasum_shiphead_number) REFERENCES shiphead(shiphead_number); -- -- Name: shipdatasum_shipdatasum_total_freight_curr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shipdatasum ADD CONSTRAINT shipdatasum_shipdatasum_total_freight_curr_id_fkey FOREIGN KEY (shipdatasum_total_freight_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: shiphead_shiphead_freight_curr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shiphead ADD CONSTRAINT shiphead_shiphead_freight_curr_id_fkey FOREIGN KEY (shiphead_freight_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: shiphead_shiphead_shipchrg_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shiphead ADD CONSTRAINT shiphead_shiphead_shipchrg_id_fkey FOREIGN KEY (shiphead_shipchrg_id) REFERENCES shipchrg(shipchrg_id); -- -- Name: shiphead_shiphead_shipform_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shiphead ADD CONSTRAINT shiphead_shiphead_shipform_id_fkey FOREIGN KEY (shiphead_shipform_id) REFERENCES shipform(shipform_id); -- -- Name: shipitem_shipitem_invcitem_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shipitem ADD CONSTRAINT shipitem_shipitem_invcitem_id_fkey FOREIGN KEY (shipitem_invcitem_id) REFERENCES invcitem(invcitem_id); -- -- Name: shipitem_shipitem_invhist_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shipitem ADD CONSTRAINT shipitem_shipitem_invhist_id_fkey FOREIGN KEY (shipitem_invhist_id) REFERENCES invhist(invhist_id); -- -- Name: shipitem_shipitem_shiphead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shipitem ADD CONSTRAINT shipitem_shipitem_shiphead_id_fkey FOREIGN KEY (shipitem_shiphead_id) REFERENCES shiphead(shiphead_id); -- -- Name: shiptoinfo_shipto_addr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shiptoinfo_shipto_addr_id_fkey FOREIGN KEY (shipto_addr_id) REFERENCES addr(addr_id); -- -- Name: shiptoinfo_shipto_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shiptoinfo_shipto_cntct_id_fkey FOREIGN KEY (shipto_cntct_id) REFERENCES cntct(cntct_id); -- -- Name: shiptoinfo_shipto_cust_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shiptoinfo_shipto_cust_id_fkey FOREIGN KEY (shipto_cust_id) REFERENCES custinfo(cust_id); -- -- Name: shiptoinfo_shipto_salesrep_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shiptoinfo_shipto_salesrep_fkey FOREIGN KEY (shipto_salesrep_id) REFERENCES salesrep(salesrep_id) ON UPDATE RESTRICT ON DELETE RESTRICT; -- -- Name: shiptoinfo_shipto_salesrep_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shiptoinfo_shipto_salesrep_id_fkey FOREIGN KEY (shipto_salesrep_id) REFERENCES salesrep(salesrep_id); -- -- Name: shiptoinfo_shipto_shipform_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shiptoinfo_shipto_shipform_fkey FOREIGN KEY (shipto_shipform_id) REFERENCES shipform(shipform_id) ON UPDATE RESTRICT ON DELETE RESTRICT; -- -- Name: shiptoinfo_shipto_shipform_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shiptoinfo_shipto_shipform_id_fkey FOREIGN KEY (shipto_shipform_id) REFERENCES shipform(shipform_id); -- -- Name: shiptoinfo_shipto_shipzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shiptoinfo_shipto_shipzone_id_fkey FOREIGN KEY (shipto_shipzone_id) REFERENCES shipzone(shipzone_id); -- -- Name: shiptoinfo_shipto_taxzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shiptoinfo_shipto_taxzone_id_fkey FOREIGN KEY (shipto_taxzone_id) REFERENCES taxzone(taxzone_id); -- -- Name: state_state_country_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY state ADD CONSTRAINT state_state_country_id_fkey FOREIGN KEY (state_country_id) REFERENCES country(country_id); -- -- Name: tax_tax_basis_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY tax ADD CONSTRAINT tax_tax_basis_tax_id_fkey FOREIGN KEY (tax_basis_tax_id) REFERENCES tax(tax_id) ON DELETE CASCADE; -- -- Name: tax_tax_sales_accnt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY tax ADD CONSTRAINT tax_tax_sales_accnt_id_fkey FOREIGN KEY (tax_sales_accnt_id) REFERENCES accnt(accnt_id); -- -- Name: tax_tax_taxauth_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY tax ADD CONSTRAINT tax_tax_taxauth_id_fkey FOREIGN KEY (tax_taxauth_id) REFERENCES taxauth(taxauth_id); -- -- Name: tax_tax_taxclass_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY tax ADD CONSTRAINT tax_tax_taxclass_id_fkey FOREIGN KEY (tax_taxclass_id) REFERENCES taxclass(taxclass_id); -- -- Name: taxass_taxass_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxass ADD CONSTRAINT taxass_taxass_tax_id_fkey FOREIGN KEY (taxass_tax_id) REFERENCES tax(tax_id); -- -- Name: taxass_taxass_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxass ADD CONSTRAINT taxass_taxass_taxtype_id_fkey FOREIGN KEY (taxass_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: taxass_taxass_taxzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxass ADD CONSTRAINT taxass_taxass_taxzone_id_fkey FOREIGN KEY (taxass_taxzone_id) REFERENCES taxzone(taxzone_id); -- -- Name: taxauth_taxauth_accnt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxauth ADD CONSTRAINT taxauth_taxauth_accnt_id_fkey FOREIGN KEY (taxauth_accnt_id) REFERENCES accnt(accnt_id); -- -- Name: taxauth_taxauth_addr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxauth ADD CONSTRAINT taxauth_taxauth_addr_id_fkey FOREIGN KEY (taxauth_addr_id) REFERENCES addr(addr_id); -- -- Name: taxauth_taxauth_curr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxauth ADD CONSTRAINT taxauth_taxauth_curr_id_fkey FOREIGN KEY (taxauth_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: taxhist_taxhist_curr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxhist ADD CONSTRAINT taxhist_taxhist_curr_id_fkey FOREIGN KEY (taxhist_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: taxhist_taxhist_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxhist ADD CONSTRAINT taxhist_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); -- -- Name: taxhist_taxhist_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxhist ADD CONSTRAINT taxhist_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: taxrate_taxrate_curr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxrate ADD CONSTRAINT taxrate_taxrate_curr_id_fkey FOREIGN KEY (taxrate_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: taxrate_taxrate_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxrate ADD CONSTRAINT taxrate_taxrate_tax_id_fkey FOREIGN KEY (taxrate_tax_id) REFERENCES tax(tax_id); -- -- Name: taxreg_taxreg_taxauth_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxreg ADD CONSTRAINT taxreg_taxreg_taxauth_id_fkey FOREIGN KEY (taxreg_taxauth_id) REFERENCES taxauth(taxauth_id); -- -- Name: taxreg_taxreg_taxzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY taxreg ADD CONSTRAINT taxreg_taxreg_taxzone_id_fkey FOREIGN KEY (taxreg_taxzone_id) REFERENCES taxzone(taxzone_id); -- -- Name: todoitem_todoitem_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY todoitem ADD CONSTRAINT todoitem_todoitem_cntct_id_fkey FOREIGN KEY (todoitem_cntct_id) REFERENCES cntct(cntct_id); -- -- Name: todoitem_todoitem_crmacct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY todoitem ADD CONSTRAINT todoitem_todoitem_crmacct_id_fkey FOREIGN KEY (todoitem_crmacct_id) REFERENCES crmacct(crmacct_id); -- -- Name: todoitem_todoitem_incdt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY todoitem ADD CONSTRAINT todoitem_todoitem_incdt_id_fkey FOREIGN KEY (todoitem_incdt_id) REFERENCES incdt(incdt_id); -- -- Name: todoitem_todoitem_ophead_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY todoitem ADD CONSTRAINT todoitem_todoitem_ophead_id_fkey FOREIGN KEY (todoitem_ophead_id) REFERENCES ophead(ophead_id) ON UPDATE RESTRICT ON DELETE RESTRICT; -- -- Name: todoitem_todoitem_recurring_todoitem_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY todoitem ADD CONSTRAINT todoitem_todoitem_recurring_todoitem_id_fkey FOREIGN KEY (todoitem_recurring_todoitem_id) REFERENCES todoitem(todoitem_id); -- -- Name: trgthist_trgthist_src_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY trgthist ADD CONSTRAINT trgthist_trgthist_src_cntct_id_fkey FOREIGN KEY (trgthist_src_cntct_id) REFERENCES cntctmrgd(cntctmrgd_cntct_id) ON DELETE CASCADE; -- -- Name: trgthist_trgthist_trgt_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY trgthist ADD CONSTRAINT trgthist_trgthist_trgt_cntct_id_fkey FOREIGN KEY (trgthist_trgt_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE; -- -- Name: uomconv_uomconv_from_uom_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY uomconv ADD CONSTRAINT uomconv_uomconv_from_uom_id_fkey FOREIGN KEY (uomconv_from_uom_id) REFERENCES uom(uom_id); -- -- Name: uomconv_uomconv_to_uom_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY uomconv ADD CONSTRAINT uomconv_uomconv_to_uom_id_fkey FOREIGN KEY (uomconv_to_uom_id) REFERENCES uom(uom_id); -- -- Name: usrgrp_usrgrp_grp_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY usrgrp ADD CONSTRAINT usrgrp_usrgrp_grp_id_fkey FOREIGN KEY (usrgrp_grp_id) REFERENCES grp(grp_id); -- -- Name: vend_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY vendinfo ADD CONSTRAINT vend_to_curr_symbol FOREIGN KEY (vend_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: vend_vend_cntct1_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY vendinfo ADD CONSTRAINT vend_vend_cntct1_id_fkey FOREIGN KEY (vend_cntct1_id) REFERENCES cntct(cntct_id); -- -- Name: vend_vend_cntct2_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY vendinfo ADD CONSTRAINT vend_vend_cntct2_id_fkey FOREIGN KEY (vend_cntct2_id) REFERENCES cntct(cntct_id); -- -- Name: vendaddrinfo_vendaddr_addr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY vendaddrinfo ADD CONSTRAINT vendaddrinfo_vendaddr_addr_id_fkey FOREIGN KEY (vendaddr_addr_id) REFERENCES addr(addr_id); -- -- Name: vendaddrinfo_vendaddr_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY vendaddrinfo ADD CONSTRAINT vendaddrinfo_vendaddr_cntct_id_fkey FOREIGN KEY (vendaddr_cntct_id) REFERENCES cntct(cntct_id); -- -- Name: vendaddrinfo_vendaddr_taxzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY vendaddrinfo ADD CONSTRAINT vendaddrinfo_vendaddr_taxzone_id_fkey FOREIGN KEY (vendaddr_taxzone_id) REFERENCES taxzone(taxzone_id); -- -- Name: vendinfo_vend_addr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY vendinfo ADD CONSTRAINT vendinfo_vend_addr_id_fkey FOREIGN KEY (vend_addr_id) REFERENCES addr(addr_id); -- -- Name: vendinfo_vend_taxzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY vendinfo ADD CONSTRAINT vendinfo_vend_taxzone_id_fkey FOREIGN KEY (vend_taxzone_id) REFERENCES taxzone(taxzone_id); -- -- Name: vendinfo_vend_vendtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY vendinfo ADD CONSTRAINT vendinfo_vend_vendtype_id_fkey FOREIGN KEY (vend_vendtype_id) REFERENCES vendtype(vendtype_id); -- -- Name: vohead_to_curr_symbol; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY vohead ADD CONSTRAINT vohead_to_curr_symbol FOREIGN KEY (vohead_curr_id) REFERENCES curr_symbol(curr_id); -- -- Name: vohead_vohead_adjtaxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY vohead ADD CONSTRAINT vohead_vohead_adjtaxtype_id_fkey FOREIGN KEY (vohead_adjtaxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: vohead_vohead_freighttaxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY vohead ADD CONSTRAINT vohead_vohead_freighttaxtype_id_fkey FOREIGN KEY (vohead_freighttaxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: vohead_vohead_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY vohead ADD CONSTRAINT vohead_vohead_taxtype_id_fkey FOREIGN KEY (vohead_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: vohead_vohead_taxzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY vohead ADD CONSTRAINT vohead_vohead_taxzone_id_fkey FOREIGN KEY (vohead_taxzone_id) REFERENCES taxzone(taxzone_id); -- -- Name: vohead_vohead_vend_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY vohead ADD CONSTRAINT vohead_vohead_vend_id_fkey FOREIGN KEY (vohead_vend_id) REFERENCES vendinfo(vend_id); -- -- Name: voheadtax_taxhist_basis_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY voheadtax ADD CONSTRAINT voheadtax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); -- -- Name: voheadtax_taxhist_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY voheadtax ADD CONSTRAINT voheadtax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES vohead(vohead_id) ON DELETE CASCADE; -- -- Name: voheadtax_taxhist_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY voheadtax ADD CONSTRAINT voheadtax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); -- -- Name: voheadtax_taxhist_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY voheadtax ADD CONSTRAINT voheadtax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: voitem_voitem_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY voitem ADD CONSTRAINT voitem_voitem_taxtype_id_fkey FOREIGN KEY (voitem_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: voitemtax_taxhist_basis_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY voitemtax ADD CONSTRAINT voitemtax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); -- -- Name: voitemtax_taxhist_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY voitemtax ADD CONSTRAINT voitemtax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES voitem(voitem_id) ON DELETE CASCADE; -- -- Name: voitemtax_taxhist_tax_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY voitemtax ADD CONSTRAINT voitemtax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); -- -- Name: voitemtax_taxhist_taxtype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY voitemtax ADD CONSTRAINT voitemtax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); -- -- Name: whsinfo_warehous_accnt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY whsinfo ADD CONSTRAINT whsinfo_warehous_accnt_id_fkey FOREIGN KEY (warehous_default_accnt_id) REFERENCES accnt(accnt_id); -- -- Name: whsinfo_warehous_addr_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY whsinfo ADD CONSTRAINT whsinfo_warehous_addr_id_fkey FOREIGN KEY (warehous_addr_id) REFERENCES addr(addr_id); -- -- Name: whsinfo_warehous_cntct_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY whsinfo ADD CONSTRAINT whsinfo_warehous_cntct_id_fkey FOREIGN KEY (warehous_cntct_id) REFERENCES cntct(cntct_id); -- -- Name: whsinfo_warehous_costcat_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY whsinfo ADD CONSTRAINT whsinfo_warehous_costcat_id_fkey FOREIGN KEY (warehous_costcat_id) REFERENCES costcat(costcat_id); -- -- Name: whsinfo_warehous_shipform_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY whsinfo ADD CONSTRAINT whsinfo_warehous_shipform_id_fkey FOREIGN KEY (warehous_shipform_id) REFERENCES shipform(shipform_id); -- -- Name: whsinfo_warehous_shipvia_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY whsinfo ADD CONSTRAINT whsinfo_warehous_shipvia_id_fkey FOREIGN KEY (warehous_shipvia_id) REFERENCES shipvia(shipvia_id); -- -- Name: whsinfo_warehous_sitetype_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY whsinfo ADD CONSTRAINT whsinfo_warehous_sitetype_id_fkey FOREIGN KEY (warehous_sitetype_id) REFERENCES sitetype(sitetype_id); -- -- Name: whsinfo_warehous_taxzone_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY whsinfo ADD CONSTRAINT whsinfo_warehous_taxzone_id_fkey FOREIGN KEY (warehous_taxzone_id) REFERENCES taxzone(taxzone_id); -- -- Name: wo_wo_womatl_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY wo ADD CONSTRAINT wo_wo_womatl_id_fkey FOREIGN KEY (wo_womatl_id) REFERENCES womatl(womatl_id) ON DELETE SET NULL; -- -- Name: womatl_womatl_uom_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY womatl ADD CONSTRAINT womatl_womatl_uom_id_fkey FOREIGN KEY (womatl_uom_id) REFERENCES uom(uom_id); -- -- Name: womatlpost_womatlpost_invhist_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY womatlpost ADD CONSTRAINT womatlpost_womatlpost_invhist_id_fkey FOREIGN KEY (womatlpost_invhist_id) REFERENCES invhist(invhist_id); -- -- Name: womatlpost_womatlpost_womatl_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin -- ALTER TABLE ONLY womatlpost ADD CONSTRAINT womatlpost_womatlpost_womatl_id_fkey FOREIGN KEY (womatlpost_womatl_id) REFERENCES womatl(womatl_id) ON DELETE CASCADE; SET search_path = te, pg_catalog; -- -- Name: pkgcmdarg_cmdarg_cmd_id_fkey; Type: FK CONSTRAINT; Schema: te; Owner: admin -- ALTER TABLE ONLY pkgcmdarg ADD CONSTRAINT pkgcmdarg_cmdarg_cmd_id_fkey FOREIGN KEY (cmdarg_cmd_id) REFERENCES pkgcmd(cmd_id); -- -- Name: tecustrate_tecustrate_curr_id_fkey; Type: FK CONSTRAINT; Schema: te; Owner: admin -- ALTER TABLE ONLY tecustrate ADD CONSTRAINT tecustrate_tecustrate_curr_id_fkey FOREIGN KEY (tecustrate_curr_id) REFERENCES public.curr_symbol(curr_id) ON DELETE SET DEFAULT; -- -- Name: tecustrate_tecustrate_cust_id_fkey; Type: FK CONSTRAINT; Schema: te; Owner: admin -- ALTER TABLE ONLY tecustrate ADD CONSTRAINT tecustrate_tecustrate_cust_id_fkey FOREIGN KEY (tecustrate_cust_id) REFERENCES public.custinfo(cust_id) ON DELETE CASCADE; -- -- Name: teemp_teemp_emp_id_fkey; Type: FK CONSTRAINT; Schema: te; Owner: admin -- ALTER TABLE ONLY teemp ADD CONSTRAINT teemp_teemp_emp_id_fkey FOREIGN KEY (teemp_emp_id) REFERENCES public.emp(emp_id) ON DELETE CASCADE; -- -- Name: teitem_teitem_curr_id_fkey; Type: FK CONSTRAINT; Schema: te; Owner: admin -- ALTER TABLE ONLY teitem ADD CONSTRAINT teitem_teitem_curr_id_fkey FOREIGN KEY (teitem_curr_id) REFERENCES public.curr_symbol(curr_id) ON DELETE SET DEFAULT; -- -- Name: teitem_teitem_invcitem_id_fkey; Type: FK CONSTRAINT; Schema: te; Owner: admin -- ALTER TABLE ONLY teitem ADD CONSTRAINT teitem_teitem_invcitem_id_fkey FOREIGN KEY (teitem_invcitem_id) REFERENCES public.invcitem(invcitem_id) ON DELETE SET NULL; -- -- Name: teitem_teitem_prjtask_id_fkey; Type: FK CONSTRAINT; Schema: te; Owner: admin -- ALTER TABLE ONLY teitem ADD CONSTRAINT teitem_teitem_prjtask_id_fkey FOREIGN KEY (teitem_prjtask_id) REFERENCES public.prjtask(prjtask_id); -- -- Name: teitem_teitem_tehead_id_fkey; Type: FK CONSTRAINT; Schema: te; Owner: admin -- ALTER TABLE ONLY teitem ADD CONSTRAINT teitem_teitem_tehead_id_fkey FOREIGN KEY (teitem_tehead_id) REFERENCES tehead(tehead_id) ON DELETE CASCADE; -- -- Name: teitem_teitem_vodist_id_fkey; Type: FK CONSTRAINT; Schema: te; Owner: admin -- ALTER TABLE ONLY teitem ADD CONSTRAINT teitem_teitem_vodist_id_fkey FOREIGN KEY (teitem_vodist_id) REFERENCES public.vodist(vodist_id) ON DELETE SET NULL; -- -- Name: teprj_teprj_curr_id_fkey; Type: FK CONSTRAINT; Schema: te; Owner: admin -- ALTER TABLE ONLY teprj ADD CONSTRAINT teprj_teprj_curr_id_fkey FOREIGN KEY (teprj_curr_id) REFERENCES public.curr_symbol(curr_id) ON DELETE SET NULL; -- -- Name: teprj_teprj_cust_id_fkey; Type: FK CONSTRAINT; Schema: te; Owner: admin -- ALTER TABLE ONLY teprj ADD CONSTRAINT teprj_teprj_cust_id_fkey FOREIGN KEY (teprj_cust_id) REFERENCES public.custinfo(cust_id) ON DELETE SET NULL; -- -- Name: teprjtask_teprjtask_curr_id_fkey; Type: FK CONSTRAINT; Schema: te; Owner: admin -- ALTER TABLE ONLY teprjtask ADD CONSTRAINT teprjtask_teprjtask_curr_id_fkey FOREIGN KEY (teprjtask_curr_id) REFERENCES public.curr_symbol(curr_id) ON DELETE SET DEFAULT; -- -- Name: teprjtask_teprjtask_item_id_fkey; Type: FK CONSTRAINT; Schema: te; Owner: admin -- ALTER TABLE ONLY teprjtask ADD CONSTRAINT teprjtask_teprjtask_item_id_fkey FOREIGN KEY (teprjtask_item_id) REFERENCES public.item(item_id) ON DELETE SET NULL; SET search_path = xtdesktop, pg_catalog; -- -- Name: pkgcmdarg_cmdarg_cmd_id_fkey; Type: FK CONSTRAINT; Schema: xtdesktop; Owner: admin -- ALTER TABLE ONLY pkgcmdarg ADD CONSTRAINT pkgcmdarg_cmdarg_cmd_id_fkey FOREIGN KEY (cmdarg_cmd_id) REFERENCES pkgcmd(cmd_id); -- -- Name: api; Type: ACL; Schema: -; Owner: admin -- REVOKE ALL ON SCHEMA api FROM PUBLIC; REVOKE ALL ON SCHEMA api FROM admin; GRANT ALL ON SCHEMA api TO admin; GRANT ALL ON SCHEMA api TO xtrole; -- -- Name: fixcountry; Type: ACL; Schema: -; Owner: admin -- REVOKE ALL ON SCHEMA fixcountry FROM PUBLIC; REVOKE ALL ON SCHEMA fixcountry FROM admin; GRANT ALL ON SCHEMA fixcountry TO admin; GRANT ALL ON SCHEMA fixcountry TO xtrole; -- -- Name: public; Type: ACL; Schema: -; Owner: postgres -- REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; -- -- Name: te; Type: ACL; Schema: -; Owner: admin -- REVOKE ALL ON SCHEMA te FROM PUBLIC; REVOKE ALL ON SCHEMA te FROM admin; GRANT ALL ON SCHEMA te TO admin; GRANT ALL ON SCHEMA te TO xtrole; -- -- Name: xt; Type: ACL; Schema: -; Owner: admin -- REVOKE ALL ON SCHEMA xt FROM PUBLIC; REVOKE ALL ON SCHEMA xt FROM admin; GRANT ALL ON SCHEMA xt TO admin; GRANT ALL ON SCHEMA xt TO xtrole; -- -- Name: xtdesktop; Type: ACL; Schema: -; Owner: admin -- REVOKE ALL ON SCHEMA xtdesktop FROM PUBLIC; REVOKE ALL ON SCHEMA xtdesktop FROM admin; GRANT ALL ON SCHEMA xtdesktop TO admin; GRANT ALL ON SCHEMA xtdesktop TO xtrole; SET search_path = public, pg_catalog; -- -- Name: cntslip; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cntslip FROM PUBLIC; REVOKE ALL ON TABLE cntslip FROM admin; GRANT ALL ON TABLE cntslip TO admin; GRANT ALL ON TABLE cntslip TO xtrole; -- -- Name: invcnt; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE invcnt FROM PUBLIC; REVOKE ALL ON TABLE invcnt FROM admin; GRANT ALL ON TABLE invcnt TO admin; GRANT ALL ON TABLE invcnt TO xtrole; -- -- Name: item; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE item FROM PUBLIC; REVOKE ALL ON TABLE item FROM admin; GRANT ALL ON TABLE item TO admin; GRANT ALL ON TABLE item TO xtrole; -- -- Name: itemsite; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE itemsite FROM PUBLIC; REVOKE ALL ON TABLE itemsite FROM admin; GRANT ALL ON TABLE itemsite TO admin; GRANT ALL ON TABLE itemsite TO xtrole; -- -- Name: whsinfo; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE whsinfo FROM PUBLIC; REVOKE ALL ON TABLE whsinfo FROM admin; GRANT ALL ON TABLE whsinfo TO admin; GRANT ALL ON TABLE whsinfo TO xtrole; SET search_path = api, pg_catalog; -- -- Name: physinvcount; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE physinvcount FROM PUBLIC; REVOKE ALL ON TABLE physinvcount FROM admin; GRANT ALL ON TABLE physinvcount TO admin; GRANT ALL ON TABLE physinvcount TO xtrole; SET search_path = public, pg_catalog; -- -- Name: cohead; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cohead FROM PUBLIC; REVOKE ALL ON TABLE cohead FROM admin; GRANT ALL ON TABLE cohead TO admin; GRANT ALL ON TABLE cohead TO xtrole; -- -- Name: coitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE coitem FROM PUBLIC; REVOKE ALL ON TABLE coitem FROM admin; GRANT ALL ON TABLE coitem TO admin; GRANT ALL ON TABLE coitem TO xtrole; -- -- Name: pohead; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE pohead FROM PUBLIC; REVOKE ALL ON TABLE pohead FROM admin; GRANT ALL ON TABLE pohead TO admin; GRANT ALL ON TABLE pohead TO xtrole; -- -- Name: poitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE poitem FROM PUBLIC; REVOKE ALL ON TABLE poitem FROM admin; GRANT ALL ON TABLE poitem TO admin; GRANT ALL ON TABLE poitem TO xtrole; -- -- Name: taxtype; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE taxtype FROM PUBLIC; REVOKE ALL ON TABLE taxtype FROM admin; GRANT ALL ON TABLE taxtype TO admin; GRANT ALL ON TABLE taxtype TO xtrole; -- -- Name: uom; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE uom FROM PUBLIC; REVOKE ALL ON TABLE uom FROM admin; GRANT ALL ON TABLE uom TO admin; GRANT ALL ON TABLE uom TO xtrole; SET search_path = api, pg_catalog; -- -- Name: salesline; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE salesline FROM PUBLIC; REVOKE ALL ON TABLE salesline FROM admin; GRANT ALL ON TABLE salesline TO admin; GRANT ALL ON TABLE salesline TO xtrole; SET search_path = public, pg_catalog; -- -- Name: invbal; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE invbal FROM PUBLIC; REVOKE ALL ON TABLE invbal FROM admin; GRANT ALL ON TABLE invbal TO admin; GRANT ALL ON TABLE invbal TO xtrole; -- -- Name: bomitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE bomitem FROM PUBLIC; REVOKE ALL ON TABLE bomitem FROM admin; GRANT ALL ON TABLE bomitem TO admin; GRANT ALL ON TABLE bomitem TO xtrole; -- -- Name: cntct; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cntct FROM PUBLIC; REVOKE ALL ON TABLE cntct FROM admin; GRANT ALL ON TABLE cntct TO admin; GRANT ALL ON TABLE cntct TO xtrole; -- -- Name: crmacct; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE crmacct FROM PUBLIC; REVOKE ALL ON TABLE crmacct FROM admin; GRANT ALL ON TABLE crmacct TO admin; GRANT ALL ON TABLE crmacct TO xtrole; -- -- Name: incdt; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE incdt FROM PUBLIC; REVOKE ALL ON TABLE incdt FROM admin; GRANT ALL ON TABLE incdt TO admin; GRANT ALL ON TABLE incdt TO xtrole; -- -- Name: apopen; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE apopen FROM PUBLIC; REVOKE ALL ON TABLE apopen FROM admin; GRANT ALL ON TABLE apopen TO admin; GRANT ALL ON TABLE apopen TO xtrole; -- -- Name: curr_symbol; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE curr_symbol FROM PUBLIC; REVOKE ALL ON TABLE curr_symbol FROM admin; GRANT ALL ON TABLE curr_symbol TO admin; GRANT ALL ON TABLE curr_symbol TO xtrole; -- -- Name: terms; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE terms FROM PUBLIC; REVOKE ALL ON TABLE terms FROM admin; GRANT ALL ON TABLE terms TO admin; GRANT ALL ON TABLE terms TO xtrole; -- -- Name: vendinfo; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE vendinfo FROM PUBLIC; REVOKE ALL ON TABLE vendinfo FROM admin; GRANT ALL ON TABLE vendinfo TO admin; GRANT ALL ON TABLE vendinfo TO xtrole; SET search_path = api, pg_catalog; -- -- Name: apmemo; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE apmemo FROM PUBLIC; REVOKE ALL ON TABLE apmemo FROM admin; GRANT ALL ON TABLE apmemo TO admin; GRANT ALL ON TABLE apmemo TO xtrole; SET search_path = public, pg_catalog; -- -- Name: aropen; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE aropen FROM PUBLIC; REVOKE ALL ON TABLE aropen FROM admin; GRANT ALL ON TABLE aropen TO admin; GRANT ALL ON TABLE aropen TO xtrole; -- -- Name: custinfo; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE custinfo FROM PUBLIC; REVOKE ALL ON TABLE custinfo FROM admin; GRANT ALL ON TABLE custinfo TO admin; GRANT ALL ON TABLE custinfo TO xtrole; -- -- Name: rsncode; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE rsncode FROM PUBLIC; REVOKE ALL ON TABLE rsncode FROM admin; GRANT ALL ON TABLE rsncode TO admin; GRANT ALL ON TABLE rsncode TO xtrole; -- -- Name: salescat; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE salescat FROM PUBLIC; REVOKE ALL ON TABLE salescat FROM admin; GRANT ALL ON TABLE salescat TO admin; GRANT ALL ON TABLE salescat TO xtrole; -- -- Name: salesrep; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE salesrep FROM PUBLIC; REVOKE ALL ON TABLE salesrep FROM admin; GRANT ALL ON TABLE salesrep TO admin; GRANT ALL ON TABLE salesrep TO xtrole; SET search_path = api, pg_catalog; -- -- Name: armemo; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE armemo FROM PUBLIC; REVOKE ALL ON TABLE armemo FROM admin; GRANT ALL ON TABLE armemo TO admin; GRANT ALL ON TABLE armemo TO xtrole; SET search_path = public, pg_catalog; -- -- Name: cmhead; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cmhead FROM PUBLIC; REVOKE ALL ON TABLE cmhead FROM admin; GRANT ALL ON TABLE cmhead TO admin; GRANT ALL ON TABLE cmhead TO xtrole; -- -- Name: shiptoinfo; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE shiptoinfo FROM PUBLIC; REVOKE ALL ON TABLE shiptoinfo FROM admin; GRANT ALL ON TABLE shiptoinfo TO admin; GRANT ALL ON TABLE shiptoinfo TO xtrole; -- -- Name: taxzone; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE taxzone FROM PUBLIC; REVOKE ALL ON TABLE taxzone FROM admin; GRANT ALL ON TABLE taxzone TO admin; GRANT ALL ON TABLE taxzone TO xtrole; SET search_path = api, pg_catalog; -- -- Name: creditmemo; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE creditmemo FROM PUBLIC; REVOKE ALL ON TABLE creditmemo FROM admin; GRANT ALL ON TABLE creditmemo TO admin; GRANT ALL ON TABLE creditmemo TO xtrole; SET search_path = public, pg_catalog; -- -- Name: cmitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cmitem FROM PUBLIC; REVOKE ALL ON TABLE cmitem FROM admin; GRANT ALL ON TABLE cmitem TO admin; GRANT ALL ON TABLE cmitem TO xtrole; SET search_path = api, pg_catalog; -- -- Name: creditmemoline; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE creditmemoline FROM PUBLIC; REVOKE ALL ON TABLE creditmemoline FROM admin; GRANT ALL ON TABLE creditmemoline TO admin; GRANT ALL ON TABLE creditmemoline TO xtrole; SET search_path = public, pg_catalog; -- -- Name: invchead; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE invchead FROM PUBLIC; REVOKE ALL ON TABLE invchead FROM admin; GRANT ALL ON TABLE invchead TO admin; GRANT ALL ON TABLE invchead TO xtrole; -- -- Name: prj; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE prj FROM PUBLIC; REVOKE ALL ON TABLE prj FROM admin; GRANT ALL ON TABLE prj TO admin; GRANT ALL ON TABLE prj TO xtrole; -- -- Name: saletype; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE saletype FROM PUBLIC; REVOKE ALL ON TABLE saletype FROM admin; GRANT ALL ON TABLE saletype TO admin; GRANT ALL ON TABLE saletype TO xtrole; -- -- Name: shipzone; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE shipzone FROM PUBLIC; REVOKE ALL ON TABLE shipzone FROM admin; GRANT ALL ON TABLE shipzone TO admin; GRANT ALL ON TABLE shipzone TO xtrole; SET search_path = api, pg_catalog; -- -- Name: invoice; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE invoice FROM PUBLIC; REVOKE ALL ON TABLE invoice FROM admin; GRANT ALL ON TABLE invoice TO admin; GRANT ALL ON TABLE invoice TO xtrole; SET search_path = public, pg_catalog; -- -- Name: invcitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE invcitem FROM PUBLIC; REVOKE ALL ON TABLE invcitem FROM admin; GRANT ALL ON TABLE invcitem TO admin; GRANT ALL ON TABLE invcitem TO xtrole; SET search_path = api, pg_catalog; -- -- Name: invoiceline; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE invoiceline FROM PUBLIC; REVOKE ALL ON TABLE invoiceline FROM admin; GRANT ALL ON TABLE invoiceline TO admin; GRANT ALL ON TABLE invoiceline TO xtrole; SET search_path = public, pg_catalog; -- -- Name: ophead; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE ophead FROM PUBLIC; REVOKE ALL ON TABLE ophead FROM admin; GRANT ALL ON TABLE ophead TO admin; GRANT ALL ON TABLE ophead TO xtrole; -- -- Name: prjtask; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE prjtask FROM PUBLIC; REVOKE ALL ON TABLE prjtask FROM admin; GRANT ALL ON TABLE prjtask TO admin; GRANT ALL ON TABLE prjtask TO xtrole; -- -- Name: todoitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE todoitem FROM PUBLIC; REVOKE ALL ON TABLE todoitem FROM admin; GRANT ALL ON TABLE todoitem TO admin; GRANT ALL ON TABLE todoitem TO xtrole; -- -- Name: addr; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE addr FROM PUBLIC; REVOKE ALL ON TABLE addr FROM admin; GRANT ALL ON TABLE addr TO admin; GRANT ALL ON TABLE addr TO xtrole; SET search_path = api, pg_catalog; -- -- Name: account; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE account FROM PUBLIC; REVOKE ALL ON TABLE account FROM admin; GRANT ALL ON TABLE account TO admin; GRANT ALL ON TABLE account TO xtrole; SET search_path = public, pg_catalog; -- -- Name: char; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE "char" FROM PUBLIC; REVOKE ALL ON TABLE "char" FROM admin; GRANT ALL ON TABLE "char" TO admin; GRANT ALL ON TABLE "char" TO xtrole; -- -- Name: charass; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE charass FROM PUBLIC; REVOKE ALL ON TABLE charass FROM admin; GRANT ALL ON TABLE charass TO admin; GRANT ALL ON TABLE charass TO xtrole; SET search_path = api, pg_catalog; -- -- Name: accountchar; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE accountchar FROM PUBLIC; REVOKE ALL ON TABLE accountchar FROM admin; GRANT ALL ON TABLE accountchar TO admin; GRANT ALL ON TABLE accountchar TO xtrole; SET search_path = public, pg_catalog; -- -- Name: cmnttype; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cmnttype FROM PUBLIC; REVOKE ALL ON TABLE cmnttype FROM admin; GRANT ALL ON TABLE cmnttype TO admin; GRANT ALL ON TABLE cmnttype TO xtrole; -- -- Name: comment; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE comment FROM PUBLIC; REVOKE ALL ON TABLE comment FROM admin; GRANT ALL ON TABLE comment TO admin; GRANT ALL ON TABLE comment TO xtrole; SET search_path = api, pg_catalog; -- -- Name: accountcomment; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE accountcomment FROM PUBLIC; REVOKE ALL ON TABLE accountcomment FROM admin; GRANT ALL ON TABLE accountcomment TO admin; GRANT ALL ON TABLE accountcomment TO xtrole; SET search_path = public, pg_catalog; -- -- Name: docass; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE docass FROM PUBLIC; REVOKE ALL ON TABLE docass FROM admin; GRANT ALL ON TABLE docass TO admin; GRANT ALL ON TABLE docass TO xtrole; -- -- Name: file; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE file FROM PUBLIC; REVOKE ALL ON TABLE file FROM admin; GRANT ALL ON TABLE file TO admin; GRANT ALL ON TABLE file TO xtrole; -- -- Name: urlinfo; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE urlinfo FROM PUBLIC; REVOKE ALL ON TABLE urlinfo FROM admin; GRANT ALL ON TABLE urlinfo TO admin; GRANT ALL ON TABLE urlinfo TO xtrole; -- -- Name: url; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE url FROM PUBLIC; REVOKE ALL ON TABLE url FROM admin; GRANT ALL ON TABLE url TO admin; GRANT ALL ON TABLE url TO xtrole; SET search_path = api, pg_catalog; -- -- Name: accountfile; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE accountfile FROM PUBLIC; REVOKE ALL ON TABLE accountfile FROM admin; GRANT ALL ON TABLE accountfile TO admin; GRANT ALL ON TABLE accountfile TO xtrole; SET search_path = public, pg_catalog; -- -- Name: docass_docass_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE docass_docass_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE docass_docass_id_seq FROM admin; GRANT ALL ON SEQUENCE docass_docass_id_seq TO admin; GRANT ALL ON SEQUENCE docass_docass_id_seq TO xtrole; -- -- Name: image; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE image FROM PUBLIC; REVOKE ALL ON TABLE image FROM admin; GRANT ALL ON TABLE image TO admin; GRANT ALL ON TABLE image TO xtrole; -- -- Name: imageass; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE imageass FROM PUBLIC; REVOKE ALL ON TABLE imageass FROM admin; GRANT ALL ON TABLE imageass TO admin; GRANT ALL ON TABLE imageass TO xtrole; SET search_path = api, pg_catalog; -- -- Name: accountimage; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE accountimage FROM PUBLIC; REVOKE ALL ON TABLE accountimage FROM admin; GRANT ALL ON TABLE accountimage TO admin; GRANT ALL ON TABLE accountimage TO xtrole; -- -- Name: address; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE address FROM PUBLIC; REVOKE ALL ON TABLE address FROM admin; GRANT ALL ON TABLE address TO admin; GRANT ALL ON TABLE address TO xtrole; -- -- Name: addresschar; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE addresschar FROM PUBLIC; REVOKE ALL ON TABLE addresschar FROM admin; GRANT ALL ON TABLE addresschar TO admin; GRANT ALL ON TABLE addresschar TO xtrole; -- -- Name: addresscomment; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE addresscomment FROM PUBLIC; REVOKE ALL ON TABLE addresscomment FROM admin; GRANT ALL ON TABLE addresscomment TO admin; GRANT ALL ON TABLE addresscomment TO xtrole; SET search_path = public, pg_catalog; -- -- Name: bomhead; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE bomhead FROM PUBLIC; REVOKE ALL ON TABLE bomhead FROM admin; GRANT ALL ON TABLE bomhead TO admin; GRANT ALL ON TABLE bomhead TO xtrole; SET search_path = api, pg_catalog; -- -- Name: bom; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE bom FROM PUBLIC; REVOKE ALL ON TABLE bom FROM admin; GRANT ALL ON TABLE bom TO admin; GRANT ALL ON TABLE bom TO xtrole; -- -- Name: bomitem; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE bomitem FROM PUBLIC; REVOKE ALL ON TABLE bomitem FROM admin; GRANT ALL ON TABLE bomitem TO admin; GRANT ALL ON TABLE bomitem TO xtrole; -- -- Name: bomitemcomment; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE bomitemcomment FROM PUBLIC; REVOKE ALL ON TABLE bomitemcomment FROM admin; GRANT ALL ON TABLE bomitemcomment TO admin; GRANT ALL ON TABLE bomitemcomment TO xtrole; SET search_path = public, pg_catalog; -- -- Name: bomitemsub; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE bomitemsub FROM PUBLIC; REVOKE ALL ON TABLE bomitemsub FROM admin; GRANT ALL ON TABLE bomitemsub TO admin; GRANT ALL ON TABLE bomitemsub TO xtrole; SET search_path = api, pg_catalog; -- -- Name: bomitemsubstitute; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE bomitemsubstitute FROM PUBLIC; REVOKE ALL ON TABLE bomitemsubstitute FROM admin; GRANT ALL ON TABLE bomitemsubstitute TO admin; GRANT ALL ON TABLE bomitemsubstitute TO xtrole; SET search_path = public, pg_catalog; -- -- Name: budghead; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE budghead FROM PUBLIC; REVOKE ALL ON TABLE budghead FROM admin; GRANT ALL ON TABLE budghead TO admin; GRANT ALL ON TABLE budghead TO xtrole; SET search_path = api, pg_catalog; -- -- Name: budget; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE budget FROM PUBLIC; REVOKE ALL ON TABLE budget FROM admin; GRANT ALL ON TABLE budget TO admin; GRANT ALL ON TABLE budget TO xtrole; SET search_path = public, pg_catalog; -- -- Name: accnt; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE accnt FROM PUBLIC; REVOKE ALL ON TABLE accnt FROM admin; GRANT ALL ON TABLE accnt TO admin; GRANT ALL ON TABLE accnt TO xtrole; -- -- Name: budgitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE budgitem FROM PUBLIC; REVOKE ALL ON TABLE budgitem FROM admin; GRANT ALL ON TABLE budgitem TO admin; GRANT ALL ON TABLE budgitem TO xtrole; -- -- Name: period; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE period FROM PUBLIC; REVOKE ALL ON TABLE period FROM admin; GRANT ALL ON TABLE period TO admin; GRANT ALL ON TABLE period TO xtrole; SET search_path = api, pg_catalog; -- -- Name: budgetentry; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE budgetentry FROM PUBLIC; REVOKE ALL ON TABLE budgetentry FROM admin; GRANT ALL ON TABLE budgetentry TO admin; GRANT ALL ON TABLE budgetentry TO xtrole; SET search_path = public, pg_catalog; -- -- Name: bankaccnt; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE bankaccnt FROM PUBLIC; REVOKE ALL ON TABLE bankaccnt FROM admin; GRANT ALL ON TABLE bankaccnt TO admin; GRANT ALL ON TABLE bankaccnt TO xtrole; -- -- Name: cashrcpt; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cashrcpt FROM PUBLIC; REVOKE ALL ON TABLE cashrcpt FROM admin; GRANT ALL ON TABLE cashrcpt TO admin; GRANT ALL ON TABLE cashrcpt TO xtrole; SET search_path = api, pg_catalog; -- -- Name: cashreceipt; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE cashreceipt FROM PUBLIC; REVOKE ALL ON TABLE cashreceipt FROM admin; GRANT ALL ON TABLE cashreceipt TO admin; GRANT ALL ON TABLE cashreceipt TO xtrole; SET search_path = public, pg_catalog; -- -- Name: cashrcptitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cashrcptitem FROM PUBLIC; REVOKE ALL ON TABLE cashrcptitem FROM admin; GRANT ALL ON TABLE cashrcptitem TO admin; GRANT ALL ON TABLE cashrcptitem TO xtrole; SET search_path = api, pg_catalog; -- -- Name: cashreceiptapply; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE cashreceiptapply FROM PUBLIC; REVOKE ALL ON TABLE cashreceiptapply FROM admin; GRANT ALL ON TABLE cashreceiptapply TO admin; GRANT ALL ON TABLE cashreceiptapply TO xtrole; SET search_path = public, pg_catalog; -- -- Name: cashrcptmisc; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cashrcptmisc FROM PUBLIC; REVOKE ALL ON TABLE cashrcptmisc FROM admin; GRANT ALL ON TABLE cashrcptmisc TO admin; GRANT ALL ON TABLE cashrcptmisc TO xtrole; SET search_path = api, pg_catalog; -- -- Name: cashreceiptapplymisc; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE cashreceiptapplymisc FROM PUBLIC; REVOKE ALL ON TABLE cashreceiptapplymisc FROM admin; GRANT ALL ON TABLE cashreceiptapplymisc TO admin; GRANT ALL ON TABLE cashreceiptapplymisc TO xtrole; -- -- Name: contact; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE contact FROM PUBLIC; REVOKE ALL ON TABLE contact FROM admin; GRANT ALL ON TABLE contact TO admin; GRANT ALL ON TABLE contact TO xtrole; -- -- Name: contactchar; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE contactchar FROM PUBLIC; REVOKE ALL ON TABLE contactchar FROM admin; GRANT ALL ON TABLE contactchar TO admin; GRANT ALL ON TABLE contactchar TO xtrole; -- -- Name: contactcomment; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE contactcomment FROM PUBLIC; REVOKE ALL ON TABLE contactcomment FROM admin; GRANT ALL ON TABLE contactcomment TO admin; GRANT ALL ON TABLE contactcomment TO xtrole; -- -- Name: custchar; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE custchar FROM PUBLIC; REVOKE ALL ON TABLE custchar FROM admin; GRANT ALL ON TABLE custchar TO admin; GRANT ALL ON TABLE custchar TO xtrole; -- -- Name: custcomment; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE custcomment FROM PUBLIC; REVOKE ALL ON TABLE custcomment FROM admin; GRANT ALL ON TABLE custcomment TO admin; GRANT ALL ON TABLE custcomment TO xtrole; SET search_path = public, pg_catalog; -- -- Name: ccard; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE ccard FROM PUBLIC; REVOKE ALL ON TABLE ccard FROM admin; GRANT ALL ON TABLE ccard TO admin; GRANT ALL ON TABLE ccard TO xtrole; SET search_path = api, pg_catalog; -- -- Name: custcreditcard; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE custcreditcard FROM PUBLIC; REVOKE ALL ON TABLE custcreditcard FROM admin; GRANT ALL ON TABLE custcreditcard TO admin; GRANT ALL ON TABLE custcreditcard TO xtrole; SET search_path = public, pg_catalog; -- -- Name: custtype; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE custtype FROM PUBLIC; REVOKE ALL ON TABLE custtype FROM admin; GRANT ALL ON TABLE custtype TO admin; GRANT ALL ON TABLE custtype TO xtrole; -- -- Name: shipchrg; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE shipchrg FROM PUBLIC; REVOKE ALL ON TABLE shipchrg FROM admin; GRANT ALL ON TABLE shipchrg TO admin; GRANT ALL ON TABLE shipchrg TO xtrole; -- -- Name: shipform; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE shipform FROM PUBLIC; REVOKE ALL ON TABLE shipform FROM admin; GRANT ALL ON TABLE shipform TO admin; GRANT ALL ON TABLE shipform TO xtrole; SET search_path = api, pg_catalog; -- -- Name: customer; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE customer FROM PUBLIC; REVOKE ALL ON TABLE customer FROM admin; GRANT ALL ON TABLE customer TO admin; GRANT ALL ON TABLE customer TO xtrole; SET search_path = public, pg_catalog; -- -- Name: taxauth; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE taxauth FROM PUBLIC; REVOKE ALL ON TABLE taxauth FROM admin; GRANT ALL ON TABLE taxauth TO admin; GRANT ALL ON TABLE taxauth TO xtrole; -- -- Name: taxreg; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE taxreg FROM PUBLIC; REVOKE ALL ON TABLE taxreg FROM admin; GRANT ALL ON TABLE taxreg TO admin; GRANT ALL ON TABLE taxreg TO xtrole; SET search_path = api, pg_catalog; -- -- Name: customertaxreg; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE customertaxreg FROM PUBLIC; REVOKE ALL ON TABLE customertaxreg FROM admin; GRANT ALL ON TABLE customertaxreg TO admin; GRANT ALL ON TABLE customertaxreg TO xtrole; -- -- Name: customertype; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE customertype FROM PUBLIC; REVOKE ALL ON TABLE customertype FROM admin; GRANT ALL ON TABLE customertype TO admin; GRANT ALL ON TABLE customertype TO xtrole; -- -- Name: customertypechar; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE customertypechar FROM PUBLIC; REVOKE ALL ON TABLE customertypechar FROM admin; GRANT ALL ON TABLE customertypechar TO admin; GRANT ALL ON TABLE customertypechar TO xtrole; -- -- Name: custshipto; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE custshipto FROM PUBLIC; REVOKE ALL ON TABLE custshipto FROM admin; GRANT ALL ON TABLE custshipto TO admin; GRANT ALL ON TABLE custshipto TO xtrole; -- -- Name: custtax; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE custtax FROM PUBLIC; REVOKE ALL ON TABLE custtax FROM admin; GRANT ALL ON TABLE custtax TO admin; GRANT ALL ON TABLE custtax TO xtrole; SET search_path = public, pg_catalog; -- -- Name: dept; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE dept FROM PUBLIC; REVOKE ALL ON TABLE dept FROM admin; GRANT ALL ON TABLE dept TO admin; GRANT ALL ON TABLE dept TO xtrole; -- -- Name: emp; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE emp FROM PUBLIC; REVOKE ALL ON TABLE emp FROM admin; GRANT ALL ON TABLE emp TO admin; GRANT ALL ON TABLE emp TO xtrole; -- -- Name: shift; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE shift FROM PUBLIC; REVOKE ALL ON TABLE shift FROM admin; GRANT ALL ON TABLE shift TO admin; GRANT ALL ON TABLE shift TO xtrole; SET search_path = api, pg_catalog; -- -- Name: employee; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE employee FROM PUBLIC; REVOKE ALL ON TABLE employee FROM admin; GRANT ALL ON TABLE employee TO admin; GRANT ALL ON TABLE employee TO xtrole; -- -- Name: employeechar; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE employeechar FROM PUBLIC; REVOKE ALL ON TABLE employeechar FROM admin; GRANT ALL ON TABLE employeechar TO admin; GRANT ALL ON TABLE employeechar TO xtrole; -- -- Name: employeecomment; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE employeecomment FROM PUBLIC; REVOKE ALL ON TABLE employeecomment FROM admin; GRANT ALL ON TABLE employeecomment TO admin; GRANT ALL ON TABLE employeecomment TO xtrole; SET search_path = public, pg_catalog; -- -- Name: shipdata; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE shipdata FROM PUBLIC; REVOKE ALL ON TABLE shipdata FROM admin; GRANT ALL ON TABLE shipdata TO admin; GRANT ALL ON TABLE shipdata TO xtrole; SET search_path = api, pg_catalog; -- -- Name: extshipmaint; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE extshipmaint FROM PUBLIC; REVOKE ALL ON TABLE extshipmaint FROM admin; GRANT ALL ON TABLE extshipmaint TO admin; GRANT ALL ON TABLE extshipmaint TO xtrole; SET search_path = public, pg_catalog; -- -- Name: freightclass; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE freightclass FROM PUBLIC; REVOKE ALL ON TABLE freightclass FROM admin; GRANT ALL ON TABLE freightclass TO admin; GRANT ALL ON TABLE freightclass TO xtrole; -- -- Name: ipsfreight; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE ipsfreight FROM PUBLIC; REVOKE ALL ON TABLE ipsfreight FROM admin; GRANT ALL ON TABLE ipsfreight TO admin; GRANT ALL ON TABLE ipsfreight TO xtrole; -- -- Name: ipshead; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE ipshead FROM PUBLIC; REVOKE ALL ON TABLE ipshead FROM admin; GRANT ALL ON TABLE ipshead TO admin; GRANT ALL ON TABLE ipshead TO xtrole; SET search_path = api, pg_catalog; -- -- Name: freightpricingscheduleitem; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE freightpricingscheduleitem FROM PUBLIC; REVOKE ALL ON TABLE freightpricingscheduleitem FROM admin; GRANT ALL ON TABLE freightpricingscheduleitem TO admin; GRANT ALL ON TABLE freightpricingscheduleitem TO xtrole; -- -- Name: glaccount; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE glaccount FROM PUBLIC; REVOKE ALL ON TABLE glaccount FROM admin; GRANT ALL ON TABLE glaccount TO admin; GRANT ALL ON TABLE glaccount TO xtrole; SET search_path = public, pg_catalog; -- -- Name: incdtcat; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE incdtcat FROM PUBLIC; REVOKE ALL ON TABLE incdtcat FROM admin; GRANT ALL ON TABLE incdtcat TO admin; GRANT ALL ON TABLE incdtcat TO xtrole; -- -- Name: incdtpriority; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE incdtpriority FROM PUBLIC; REVOKE ALL ON TABLE incdtpriority FROM admin; GRANT ALL ON TABLE incdtpriority TO admin; GRANT ALL ON TABLE incdtpriority TO xtrole; -- -- Name: incdtresolution; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE incdtresolution FROM PUBLIC; REVOKE ALL ON TABLE incdtresolution FROM admin; GRANT ALL ON TABLE incdtresolution TO admin; GRANT ALL ON TABLE incdtresolution TO xtrole; -- -- Name: incdtseverity; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE incdtseverity FROM PUBLIC; REVOKE ALL ON TABLE incdtseverity FROM admin; GRANT ALL ON TABLE incdtseverity TO admin; GRANT ALL ON TABLE incdtseverity TO xtrole; SET search_path = api, pg_catalog; -- -- Name: incident; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE incident FROM PUBLIC; REVOKE ALL ON TABLE incident FROM admin; GRANT ALL ON TABLE incident TO admin; GRANT ALL ON TABLE incident TO xtrole; -- -- Name: incidentchar; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE incidentchar FROM PUBLIC; REVOKE ALL ON TABLE incidentchar FROM admin; GRANT ALL ON TABLE incidentchar TO admin; GRANT ALL ON TABLE incidentchar TO xtrole; -- -- Name: incidentcomment; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE incidentcomment FROM PUBLIC; REVOKE ALL ON TABLE incidentcomment FROM admin; GRANT ALL ON TABLE incidentcomment TO admin; GRANT ALL ON TABLE incidentcomment TO xtrole; -- -- Name: incidentfile; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE incidentfile FROM PUBLIC; REVOKE ALL ON TABLE incidentfile FROM admin; GRANT ALL ON TABLE incidentfile TO admin; GRANT ALL ON TABLE incidentfile TO xtrole; -- -- Name: incidentimage; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE incidentimage FROM PUBLIC; REVOKE ALL ON TABLE incidentimage FROM admin; GRANT ALL ON TABLE incidentimage TO admin; GRANT ALL ON TABLE incidentimage TO xtrole; SET search_path = public, pg_catalog; -- -- Name: classcode; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE classcode FROM PUBLIC; REVOKE ALL ON TABLE classcode FROM admin; GRANT ALL ON TABLE classcode TO admin; GRANT ALL ON TABLE classcode TO xtrole; -- -- Name: prodcat; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE prodcat FROM PUBLIC; REVOKE ALL ON TABLE prodcat FROM admin; GRANT ALL ON TABLE prodcat TO admin; GRANT ALL ON TABLE prodcat TO xtrole; SET search_path = api, pg_catalog; -- -- Name: item; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE item FROM PUBLIC; REVOKE ALL ON TABLE item FROM admin; GRANT ALL ON TABLE item TO admin; GRANT ALL ON TABLE item TO xtrole; SET search_path = public, pg_catalog; -- -- Name: itemalias; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE itemalias FROM PUBLIC; REVOKE ALL ON TABLE itemalias FROM admin; GRANT ALL ON TABLE itemalias TO admin; GRANT ALL ON TABLE itemalias TO xtrole; SET search_path = api, pg_catalog; -- -- Name: itemalias; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE itemalias FROM PUBLIC; REVOKE ALL ON TABLE itemalias FROM admin; GRANT ALL ON TABLE itemalias TO admin; GRANT ALL ON TABLE itemalias TO xtrole; -- -- Name: itemchar; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE itemchar FROM PUBLIC; REVOKE ALL ON TABLE itemchar FROM admin; GRANT ALL ON TABLE itemchar TO admin; GRANT ALL ON TABLE itemchar TO xtrole; -- -- Name: itemcomment; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE itemcomment FROM PUBLIC; REVOKE ALL ON TABLE itemcomment FROM admin; GRANT ALL ON TABLE itemcomment TO admin; GRANT ALL ON TABLE itemcomment TO xtrole; SET search_path = public, pg_catalog; -- -- Name: costelem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE costelem FROM PUBLIC; REVOKE ALL ON TABLE costelem FROM admin; GRANT ALL ON TABLE costelem TO admin; GRANT ALL ON TABLE costelem TO xtrole; -- -- Name: itemcost; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE itemcost FROM PUBLIC; REVOKE ALL ON TABLE itemcost FROM admin; GRANT ALL ON TABLE itemcost TO admin; GRANT ALL ON TABLE itemcost TO xtrole; SET search_path = api, pg_catalog; -- -- Name: itemcost; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE itemcost FROM PUBLIC; REVOKE ALL ON TABLE itemcost FROM admin; GRANT ALL ON TABLE itemcost TO admin; GRANT ALL ON TABLE itemcost TO xtrole; -- -- Name: itemfile; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE itemfile FROM PUBLIC; REVOKE ALL ON TABLE itemfile FROM admin; GRANT ALL ON TABLE itemfile TO admin; GRANT ALL ON TABLE itemfile TO xtrole; -- -- Name: itemimage; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE itemimage FROM PUBLIC; REVOKE ALL ON TABLE itemimage FROM admin; GRANT ALL ON TABLE itemimage TO admin; GRANT ALL ON TABLE itemimage TO xtrole; SET search_path = public, pg_catalog; -- -- Name: costcat; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE costcat FROM PUBLIC; REVOKE ALL ON TABLE costcat FROM admin; GRANT ALL ON TABLE costcat TO admin; GRANT ALL ON TABLE costcat TO xtrole; -- -- Name: plancode; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE plancode FROM PUBLIC; REVOKE ALL ON TABLE plancode FROM admin; GRANT ALL ON TABLE plancode TO admin; GRANT ALL ON TABLE plancode TO xtrole; SET search_path = api, pg_catalog; -- -- Name: itemsite; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE itemsite FROM PUBLIC; REVOKE ALL ON TABLE itemsite FROM admin; GRANT ALL ON TABLE itemsite TO admin; GRANT ALL ON TABLE itemsite TO xtrole; -- -- Name: itemsitecomment; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE itemsitecomment FROM PUBLIC; REVOKE ALL ON TABLE itemsitecomment FROM admin; GRANT ALL ON TABLE itemsitecomment TO admin; GRANT ALL ON TABLE itemsitecomment TO xtrole; SET search_path = public, pg_catalog; -- -- Name: contrct; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE contrct FROM PUBLIC; REVOKE ALL ON TABLE contrct FROM admin; GRANT ALL ON TABLE contrct TO admin; GRANT ALL ON TABLE contrct TO xtrole; -- -- Name: itemsrc; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE itemsrc FROM PUBLIC; REVOKE ALL ON TABLE itemsrc FROM admin; GRANT ALL ON TABLE itemsrc TO admin; GRANT ALL ON TABLE itemsrc TO xtrole; SET search_path = api, pg_catalog; -- -- Name: itemsource; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE itemsource FROM PUBLIC; REVOKE ALL ON TABLE itemsource FROM admin; GRANT ALL ON TABLE itemsource TO admin; GRANT ALL ON TABLE itemsource TO xtrole; SET search_path = public, pg_catalog; -- -- Name: itemsrcp; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE itemsrcp FROM PUBLIC; REVOKE ALL ON TABLE itemsrcp FROM admin; GRANT ALL ON TABLE itemsrcp TO admin; GRANT ALL ON TABLE itemsrcp TO xtrole; SET search_path = api, pg_catalog; -- -- Name: itemsourceprice; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE itemsourceprice FROM PUBLIC; REVOKE ALL ON TABLE itemsourceprice FROM admin; GRANT ALL ON TABLE itemsourceprice TO admin; GRANT ALL ON TABLE itemsourceprice TO xtrole; SET search_path = public, pg_catalog; -- -- Name: itemsub; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE itemsub FROM PUBLIC; REVOKE ALL ON TABLE itemsub FROM admin; GRANT ALL ON TABLE itemsub TO admin; GRANT ALL ON TABLE itemsub TO xtrole; SET search_path = api, pg_catalog; -- -- Name: itemsubstitute; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE itemsubstitute FROM PUBLIC; REVOKE ALL ON TABLE itemsubstitute FROM admin; GRANT ALL ON TABLE itemsubstitute TO admin; GRANT ALL ON TABLE itemsubstitute TO xtrole; SET search_path = public, pg_catalog; -- -- Name: itemtax; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE itemtax FROM PUBLIC; REVOKE ALL ON TABLE itemtax FROM admin; GRANT ALL ON TABLE itemtax TO admin; GRANT ALL ON TABLE itemtax TO xtrole; SET search_path = api, pg_catalog; -- -- Name: itemtaxtype; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE itemtaxtype FROM PUBLIC; REVOKE ALL ON TABLE itemtaxtype FROM admin; GRANT ALL ON TABLE itemtaxtype TO admin; GRANT ALL ON TABLE itemtaxtype TO xtrole; SET search_path = public, pg_catalog; -- -- Name: itemuomconv; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE itemuomconv FROM PUBLIC; REVOKE ALL ON TABLE itemuomconv FROM admin; GRANT ALL ON TABLE itemuomconv TO admin; GRANT ALL ON TABLE itemuomconv TO xtrole; SET search_path = api, pg_catalog; -- -- Name: itemuomconversion; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE itemuomconversion FROM PUBLIC; REVOKE ALL ON TABLE itemuomconversion FROM admin; GRANT ALL ON TABLE itemuomconversion TO admin; GRANT ALL ON TABLE itemuomconversion TO xtrole; SET search_path = public, pg_catalog; -- -- Name: gltrans; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE gltrans FROM PUBLIC; REVOKE ALL ON TABLE gltrans FROM admin; GRANT ALL ON TABLE gltrans TO admin; GRANT ALL ON TABLE gltrans TO xtrole; SET search_path = api, pg_catalog; -- -- Name: journalentry; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE journalentry FROM PUBLIC; REVOKE ALL ON TABLE journalentry FROM admin; GRANT ALL ON TABLE journalentry TO admin; GRANT ALL ON TABLE journalentry TO xtrole; SET search_path = public, pg_catalog; -- -- Name: location; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE location FROM PUBLIC; REVOKE ALL ON TABLE location FROM admin; GRANT ALL ON TABLE location TO admin; GRANT ALL ON TABLE location TO xtrole; -- -- Name: whsezone; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE whsezone FROM PUBLIC; REVOKE ALL ON TABLE whsezone FROM admin; GRANT ALL ON TABLE whsezone TO admin; GRANT ALL ON TABLE whsezone TO xtrole; SET search_path = api, pg_catalog; -- -- Name: location; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE location FROM PUBLIC; REVOKE ALL ON TABLE location FROM admin; GRANT ALL ON TABLE location TO admin; GRANT ALL ON TABLE location TO xtrole; -- -- Name: misccounttag; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE misccounttag FROM PUBLIC; REVOKE ALL ON TABLE misccounttag FROM admin; GRANT ALL ON TABLE misccounttag TO admin; GRANT ALL ON TABLE misccounttag TO xtrole; -- -- Name: pricingschedule; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE pricingschedule FROM PUBLIC; REVOKE ALL ON TABLE pricingschedule FROM admin; GRANT ALL ON TABLE pricingschedule TO admin; GRANT ALL ON TABLE pricingschedule TO xtrole; SET search_path = public, pg_catalog; -- -- Name: ipsass; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE ipsass FROM PUBLIC; REVOKE ALL ON TABLE ipsass FROM admin; GRANT ALL ON TABLE ipsass TO admin; GRANT ALL ON TABLE ipsass TO xtrole; SET search_path = api, pg_catalog; -- -- Name: pricingscheduleassign; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE pricingscheduleassign FROM PUBLIC; REVOKE ALL ON TABLE pricingscheduleassign FROM admin; GRANT ALL ON TABLE pricingscheduleassign TO admin; GRANT ALL ON TABLE pricingscheduleassign TO xtrole; SET search_path = public, pg_catalog; -- -- Name: ipsiteminfo; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE ipsiteminfo FROM PUBLIC; REVOKE ALL ON TABLE ipsiteminfo FROM admin; GRANT ALL ON TABLE ipsiteminfo TO admin; GRANT ALL ON TABLE ipsiteminfo TO xtrole; SET search_path = api, pg_catalog; -- -- Name: pricingscheduleitem; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE pricingscheduleitem FROM PUBLIC; REVOKE ALL ON TABLE pricingscheduleitem FROM admin; GRANT ALL ON TABLE pricingscheduleitem TO admin; GRANT ALL ON TABLE pricingscheduleitem TO xtrole; SET search_path = public, pg_catalog; -- -- Name: ipsitemchar; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE ipsitemchar FROM PUBLIC; REVOKE ALL ON TABLE ipsitemchar FROM admin; GRANT ALL ON TABLE ipsitemchar TO admin; GRANT ALL ON TABLE ipsitemchar TO xtrole; SET search_path = api, pg_catalog; -- -- Name: pricingscheduleitemchar; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE pricingscheduleitemchar FROM PUBLIC; REVOKE ALL ON TABLE pricingscheduleitemchar FROM admin; GRANT ALL ON TABLE pricingscheduleitemchar TO admin; GRANT ALL ON TABLE pricingscheduleitemchar TO xtrole; -- -- Name: project; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE project FROM PUBLIC; REVOKE ALL ON TABLE project FROM admin; GRANT ALL ON TABLE project TO admin; GRANT ALL ON TABLE project TO xtrole; -- -- Name: projectcomment; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE projectcomment FROM PUBLIC; REVOKE ALL ON TABLE projectcomment FROM admin; GRANT ALL ON TABLE projectcomment TO admin; GRANT ALL ON TABLE projectcomment TO xtrole; SET search_path = public, pg_catalog; -- -- Name: cust_cust_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cust_cust_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cust_cust_id_seq FROM admin; GRANT ALL ON SEQUENCE cust_cust_id_seq TO admin; GRANT ALL ON SEQUENCE cust_cust_id_seq TO xtrole; -- -- Name: prospect; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE prospect FROM PUBLIC; REVOKE ALL ON TABLE prospect FROM admin; GRANT ALL ON TABLE prospect TO admin; GRANT ALL ON TABLE prospect TO xtrole; SET search_path = api, pg_catalog; -- -- Name: prospect; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE prospect FROM PUBLIC; REVOKE ALL ON TABLE prospect FROM admin; GRANT ALL ON TABLE prospect TO admin; GRANT ALL ON TABLE prospect TO xtrole; SET search_path = public, pg_catalog; -- -- Name: expcat; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE expcat FROM PUBLIC; REVOKE ALL ON TABLE expcat FROM admin; GRANT ALL ON TABLE expcat TO admin; GRANT ALL ON TABLE expcat TO xtrole; -- -- Name: womatl; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE womatl FROM PUBLIC; REVOKE ALL ON TABLE womatl FROM admin; GRANT ALL ON TABLE womatl TO admin; GRANT ALL ON TABLE womatl TO xtrole; SET search_path = api, pg_catalog; -- -- Name: purchaseline; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE purchaseline FROM PUBLIC; REVOKE ALL ON TABLE purchaseline FROM admin; GRANT ALL ON TABLE purchaseline TO admin; GRANT ALL ON TABLE purchaseline TO xtrole; -- -- Name: purchaselinechar; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE purchaselinechar FROM PUBLIC; REVOKE ALL ON TABLE purchaselinechar FROM admin; GRANT ALL ON TABLE purchaselinechar TO admin; GRANT ALL ON TABLE purchaselinechar TO xtrole; -- -- Name: purchaselinecomment; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE purchaselinecomment FROM PUBLIC; REVOKE ALL ON TABLE purchaselinecomment FROM admin; GRANT ALL ON TABLE purchaselinecomment TO admin; GRANT ALL ON TABLE purchaselinecomment TO xtrole; SET search_path = public, pg_catalog; -- -- Name: tax; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE tax FROM PUBLIC; REVOKE ALL ON TABLE tax FROM admin; GRANT ALL ON TABLE tax TO admin; GRANT ALL ON TABLE tax TO xtrole; -- -- Name: vendaddrinfo; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE vendaddrinfo FROM PUBLIC; REVOKE ALL ON TABLE vendaddrinfo FROM admin; GRANT ALL ON TABLE vendaddrinfo TO admin; GRANT ALL ON TABLE vendaddrinfo TO xtrole; SET search_path = api, pg_catalog; -- -- Name: purchaseorder; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE purchaseorder FROM PUBLIC; REVOKE ALL ON TABLE purchaseorder FROM admin; GRANT ALL ON TABLE purchaseorder TO admin; GRANT ALL ON TABLE purchaseorder TO xtrole; -- -- Name: purchaseordercomment; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE purchaseordercomment FROM PUBLIC; REVOKE ALL ON TABLE purchaseordercomment FROM admin; GRANT ALL ON TABLE purchaseordercomment TO admin; GRANT ALL ON TABLE purchaseordercomment TO xtrole; SET search_path = public, pg_catalog; -- -- Name: quhead; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE quhead FROM PUBLIC; REVOKE ALL ON TABLE quhead FROM admin; GRANT ALL ON TABLE quhead TO admin; GRANT ALL ON TABLE quhead TO xtrole; SET search_path = api, pg_catalog; -- -- Name: quote; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE quote FROM PUBLIC; REVOKE ALL ON TABLE quote FROM admin; GRANT ALL ON TABLE quote TO admin; GRANT ALL ON TABLE quote TO xtrole; -- -- Name: quotecomment; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE quotecomment FROM PUBLIC; REVOKE ALL ON TABLE quotecomment FROM admin; GRANT ALL ON TABLE quotecomment TO admin; GRANT ALL ON TABLE quotecomment TO xtrole; SET search_path = public, pg_catalog; -- -- Name: quitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE quitem FROM PUBLIC; REVOKE ALL ON TABLE quitem FROM admin; GRANT ALL ON TABLE quitem TO admin; GRANT ALL ON TABLE quitem TO xtrole; SET search_path = api, pg_catalog; -- -- Name: quoteline; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE quoteline FROM PUBLIC; REVOKE ALL ON TABLE quoteline FROM admin; GRANT ALL ON TABLE quoteline TO admin; GRANT ALL ON TABLE quoteline TO xtrole; -- -- Name: quotelinechar; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE quotelinechar FROM PUBLIC; REVOKE ALL ON TABLE quotelinechar FROM admin; GRANT ALL ON TABLE quotelinechar TO admin; GRANT ALL ON TABLE quotelinechar TO xtrole; -- -- Name: quotelinecomment; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE quotelinecomment FROM PUBLIC; REVOKE ALL ON TABLE quotelinecomment FROM admin; GRANT ALL ON TABLE quotelinecomment TO admin; GRANT ALL ON TABLE quotelinecomment TO xtrole; SET search_path = public, pg_catalog; -- -- Name: aropenalloc; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE aropenalloc FROM PUBLIC; REVOKE ALL ON TABLE aropenalloc FROM admin; GRANT ALL ON TABLE aropenalloc TO admin; GRANT ALL ON TABLE aropenalloc TO xtrole; SET search_path = api, pg_catalog; -- -- Name: salescredit; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE salescredit FROM PUBLIC; REVOKE ALL ON TABLE salescredit FROM admin; GRANT ALL ON TABLE salescredit TO admin; GRANT ALL ON TABLE salescredit TO xtrole; SET search_path = public, pg_catalog; -- -- Name: cohist; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cohist FROM PUBLIC; REVOKE ALL ON TABLE cohist FROM admin; GRANT ALL ON TABLE cohist TO admin; GRANT ALL ON TABLE cohist TO xtrole; -- -- Name: taxhist; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE taxhist FROM PUBLIC; REVOKE ALL ON TABLE taxhist FROM admin; GRANT ALL ON TABLE taxhist TO admin; GRANT ALL ON TABLE taxhist TO xtrole; -- -- Name: cohisttax; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cohisttax FROM PUBLIC; REVOKE ALL ON TABLE cohisttax FROM admin; GRANT ALL ON TABLE cohisttax TO admin; GRANT ALL ON TABLE cohisttax TO xtrole; SET search_path = api, pg_catalog; -- -- Name: saleshistory; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE saleshistory FROM PUBLIC; REVOKE ALL ON TABLE saleshistory FROM admin; GRANT ALL ON TABLE saleshistory TO admin; GRANT ALL ON TABLE saleshistory TO xtrole; -- -- Name: saleslinechar; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE saleslinechar FROM PUBLIC; REVOKE ALL ON TABLE saleslinechar FROM admin; GRANT ALL ON TABLE saleslinechar TO admin; GRANT ALL ON TABLE saleslinechar TO xtrole; -- -- Name: saleslinecomment; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE saleslinecomment FROM PUBLIC; REVOKE ALL ON TABLE saleslinecomment FROM admin; GRANT ALL ON TABLE saleslinecomment TO admin; GRANT ALL ON TABLE saleslinecomment TO xtrole; -- -- Name: salesorder; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE salesorder FROM PUBLIC; REVOKE ALL ON TABLE salesorder FROM admin; GRANT ALL ON TABLE salesorder TO admin; GRANT ALL ON TABLE salesorder TO xtrole; -- -- Name: salesordercomment; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE salesordercomment FROM PUBLIC; REVOKE ALL ON TABLE salesordercomment FROM admin; GRANT ALL ON TABLE salesordercomment TO admin; GRANT ALL ON TABLE salesordercomment TO xtrole; -- -- Name: salesrep; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE salesrep FROM PUBLIC; REVOKE ALL ON TABLE salesrep FROM admin; GRANT ALL ON TABLE salesrep TO admin; GRANT ALL ON TABLE salesrep TO xtrole; SET search_path = public, pg_catalog; -- -- Name: shipvia; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE shipvia FROM PUBLIC; REVOKE ALL ON TABLE shipvia FROM admin; GRANT ALL ON TABLE shipvia TO admin; GRANT ALL ON TABLE shipvia TO xtrole; -- -- Name: sitetype; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE sitetype FROM PUBLIC; REVOKE ALL ON TABLE sitetype FROM admin; GRANT ALL ON TABLE sitetype TO admin; GRANT ALL ON TABLE sitetype TO xtrole; SET search_path = api, pg_catalog; -- -- Name: site; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE site FROM PUBLIC; REVOKE ALL ON TABLE site FROM admin; GRANT ALL ON TABLE site TO admin; GRANT ALL ON TABLE site TO xtrole; -- -- Name: sitezone; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE sitezone FROM PUBLIC; REVOKE ALL ON TABLE sitezone FROM admin; GRANT ALL ON TABLE sitezone TO admin; GRANT ALL ON TABLE sitezone TO xtrole; -- -- Name: task; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE task FROM PUBLIC; REVOKE ALL ON TABLE task FROM admin; GRANT ALL ON TABLE task TO admin; GRANT ALL ON TABLE task TO xtrole; -- -- Name: taskcomment; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE taskcomment FROM PUBLIC; REVOKE ALL ON TABLE taskcomment FROM admin; GRANT ALL ON TABLE taskcomment TO admin; GRANT ALL ON TABLE taskcomment TO xtrole; -- -- Name: todo; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE todo FROM PUBLIC; REVOKE ALL ON TABLE todo FROM admin; GRANT ALL ON TABLE todo TO admin; GRANT ALL ON TABLE todo TO xtrole; SET search_path = public, pg_catalog; -- -- Name: vendtype; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE vendtype FROM PUBLIC; REVOKE ALL ON TABLE vendtype FROM admin; GRANT ALL ON TABLE vendtype TO admin; GRANT ALL ON TABLE vendtype TO xtrole; SET search_path = api, pg_catalog; -- -- Name: vendor; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE vendor FROM PUBLIC; REVOKE ALL ON TABLE vendor FROM admin; GRANT ALL ON TABLE vendor TO admin; GRANT ALL ON TABLE vendor TO xtrole; -- -- Name: vendoraddress; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE vendoraddress FROM PUBLIC; REVOKE ALL ON TABLE vendoraddress FROM admin; GRANT ALL ON TABLE vendoraddress TO admin; GRANT ALL ON TABLE vendoraddress TO xtrole; -- -- Name: vendortype; Type: ACL; Schema: api; Owner: admin -- REVOKE ALL ON TABLE vendortype FROM PUBLIC; REVOKE ALL ON TABLE vendortype FROM admin; GRANT ALL ON TABLE vendortype TO admin; GRANT ALL ON TABLE vendortype TO xtrole; SET search_path = public, pg_catalog; -- -- Name: cmd; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cmd FROM PUBLIC; REVOKE ALL ON TABLE cmd FROM admin; GRANT ALL ON TABLE cmd TO admin; GRANT ALL ON TABLE cmd TO xtrole; -- -- Name: cmd_cmd_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cmd_cmd_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cmd_cmd_id_seq FROM admin; GRANT ALL ON SEQUENCE cmd_cmd_id_seq TO admin; GRANT ALL ON SEQUENCE cmd_cmd_id_seq TO xtrole; SET search_path = fixcountry, pg_catalog; -- -- Name: pkgcmd; Type: ACL; Schema: fixcountry; Owner: admin -- REVOKE ALL ON TABLE pkgcmd FROM PUBLIC; REVOKE ALL ON TABLE pkgcmd FROM admin; GRANT ALL ON TABLE pkgcmd TO admin; GRANT ALL ON TABLE pkgcmd TO xtrole; SET search_path = public, pg_catalog; -- -- Name: cmdarg; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cmdarg FROM PUBLIC; REVOKE ALL ON TABLE cmdarg FROM admin; GRANT ALL ON TABLE cmdarg TO admin; GRANT ALL ON TABLE cmdarg TO xtrole; -- -- Name: cmdarg_cmdarg_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cmdarg_cmdarg_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cmdarg_cmdarg_id_seq FROM admin; GRANT ALL ON SEQUENCE cmdarg_cmdarg_id_seq TO admin; GRANT ALL ON SEQUENCE cmdarg_cmdarg_id_seq TO xtrole; SET search_path = fixcountry, pg_catalog; -- -- Name: pkgcmdarg; Type: ACL; Schema: fixcountry; Owner: admin -- REVOKE ALL ON TABLE pkgcmdarg FROM PUBLIC; REVOKE ALL ON TABLE pkgcmdarg FROM admin; GRANT ALL ON TABLE pkgcmdarg TO admin; GRANT ALL ON TABLE pkgcmdarg TO xtrole; SET search_path = public, pg_catalog; -- -- Name: image_image_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE image_image_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE image_image_id_seq FROM admin; GRANT ALL ON SEQUENCE image_image_id_seq TO admin; GRANT ALL ON SEQUENCE image_image_id_seq TO xtrole; SET search_path = fixcountry, pg_catalog; -- -- Name: pkgimage; Type: ACL; Schema: fixcountry; Owner: admin -- REVOKE ALL ON TABLE pkgimage FROM PUBLIC; REVOKE ALL ON TABLE pkgimage FROM admin; GRANT ALL ON TABLE pkgimage TO admin; GRANT ALL ON TABLE pkgimage TO xtrole; SET search_path = public, pg_catalog; -- -- Name: metasql; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE metasql FROM PUBLIC; REVOKE ALL ON TABLE metasql FROM admin; GRANT ALL ON TABLE metasql TO admin; GRANT ALL ON TABLE metasql TO xtrole; -- -- Name: metasql_metasql_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE metasql_metasql_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE metasql_metasql_id_seq FROM admin; GRANT ALL ON SEQUENCE metasql_metasql_id_seq TO admin; GRANT ALL ON SEQUENCE metasql_metasql_id_seq TO xtrole; SET search_path = fixcountry, pg_catalog; -- -- Name: pkgmetasql; Type: ACL; Schema: fixcountry; Owner: admin -- REVOKE ALL ON TABLE pkgmetasql FROM PUBLIC; REVOKE ALL ON TABLE pkgmetasql FROM admin; GRANT ALL ON TABLE pkgmetasql TO admin; GRANT ALL ON TABLE pkgmetasql TO xtrole; SET search_path = public, pg_catalog; -- -- Name: priv; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE priv FROM PUBLIC; REVOKE ALL ON TABLE priv FROM admin; GRANT ALL ON TABLE priv TO admin; GRANT ALL ON TABLE priv TO xtrole; -- -- Name: priv_priv_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE priv_priv_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE priv_priv_id_seq FROM admin; GRANT ALL ON SEQUENCE priv_priv_id_seq TO admin; GRANT ALL ON SEQUENCE priv_priv_id_seq TO xtrole; SET search_path = fixcountry, pg_catalog; -- -- Name: pkgpriv; Type: ACL; Schema: fixcountry; Owner: admin -- REVOKE ALL ON TABLE pkgpriv FROM PUBLIC; REVOKE ALL ON TABLE pkgpriv FROM admin; GRANT ALL ON TABLE pkgpriv TO admin; GRANT ALL ON TABLE pkgpriv TO xtrole; SET search_path = public, pg_catalog; -- -- Name: report; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE report FROM PUBLIC; REVOKE ALL ON TABLE report FROM admin; GRANT ALL ON TABLE report TO admin; GRANT ALL ON TABLE report TO xtrole; -- -- Name: report_report_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE report_report_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE report_report_id_seq FROM admin; GRANT ALL ON SEQUENCE report_report_id_seq TO admin; GRANT ALL ON SEQUENCE report_report_id_seq TO xtrole; SET search_path = fixcountry, pg_catalog; -- -- Name: pkgreport; Type: ACL; Schema: fixcountry; Owner: admin -- REVOKE ALL ON TABLE pkgreport FROM PUBLIC; REVOKE ALL ON TABLE pkgreport FROM admin; GRANT ALL ON TABLE pkgreport TO admin; GRANT ALL ON TABLE pkgreport TO xtrole; SET search_path = public, pg_catalog; -- -- Name: script; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE script FROM PUBLIC; REVOKE ALL ON TABLE script FROM admin; GRANT ALL ON TABLE script TO admin; GRANT ALL ON TABLE script TO xtrole; -- -- Name: script_script_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE script_script_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE script_script_id_seq FROM admin; GRANT ALL ON SEQUENCE script_script_id_seq TO admin; GRANT ALL ON SEQUENCE script_script_id_seq TO xtrole; SET search_path = fixcountry, pg_catalog; -- -- Name: pkgscript; Type: ACL; Schema: fixcountry; Owner: admin -- REVOKE ALL ON TABLE pkgscript FROM PUBLIC; REVOKE ALL ON TABLE pkgscript FROM admin; GRANT ALL ON TABLE pkgscript TO admin; GRANT ALL ON TABLE pkgscript TO xtrole; SET search_path = public, pg_catalog; -- -- Name: uiform; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE uiform FROM PUBLIC; REVOKE ALL ON TABLE uiform FROM admin; GRANT ALL ON TABLE uiform TO admin; GRANT ALL ON TABLE uiform TO xtrole; -- -- Name: uiform_uiform_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE uiform_uiform_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE uiform_uiform_id_seq FROM admin; GRANT ALL ON SEQUENCE uiform_uiform_id_seq TO admin; GRANT ALL ON SEQUENCE uiform_uiform_id_seq TO xtrole; SET search_path = fixcountry, pg_catalog; -- -- Name: pkguiform; Type: ACL; Schema: fixcountry; Owner: admin -- REVOKE ALL ON TABLE pkguiform FROM PUBLIC; REVOKE ALL ON TABLE pkguiform FROM admin; GRANT ALL ON TABLE pkguiform TO admin; GRANT ALL ON TABLE pkguiform TO xtrole; SET search_path = public, pg_catalog; -- -- Name: acalitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE acalitem FROM PUBLIC; REVOKE ALL ON TABLE acalitem FROM admin; GRANT ALL ON TABLE acalitem TO admin; GRANT ALL ON TABLE acalitem TO xtrole; -- -- Name: accnt_accnt_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE accnt_accnt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE accnt_accnt_id_seq FROM admin; GRANT ALL ON SEQUENCE accnt_accnt_id_seq TO admin; GRANT ALL ON SEQUENCE accnt_accnt_id_seq TO xtrole; -- -- Name: addr_addr_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE addr_addr_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE addr_addr_id_seq FROM admin; GRANT ALL ON SEQUENCE addr_addr_id_seq TO admin; GRANT ALL ON SEQUENCE addr_addr_id_seq TO xtrole; -- -- Name: address; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE address FROM PUBLIC; REVOKE ALL ON TABLE address FROM admin; GRANT ALL ON TABLE address TO admin; GRANT ALL ON TABLE address TO xtrole; -- -- Name: alarm; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE alarm FROM PUBLIC; REVOKE ALL ON TABLE alarm FROM admin; GRANT ALL ON TABLE alarm TO admin; GRANT ALL ON TABLE alarm TO xtrole; -- -- Name: alarm_alarm_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE alarm_alarm_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE alarm_alarm_id_seq FROM admin; GRANT ALL ON SEQUENCE alarm_alarm_id_seq TO admin; GRANT ALL ON SEQUENCE alarm_alarm_id_seq TO xtrole; -- -- Name: apaccnt; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE apaccnt FROM PUBLIC; REVOKE ALL ON TABLE apaccnt FROM admin; GRANT ALL ON TABLE apaccnt TO admin; GRANT ALL ON TABLE apaccnt TO xtrole; -- -- Name: apaccnt_apaccnt_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE apaccnt_apaccnt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE apaccnt_apaccnt_id_seq FROM admin; GRANT ALL ON SEQUENCE apaccnt_apaccnt_id_seq TO admin; GRANT ALL ON SEQUENCE apaccnt_apaccnt_id_seq TO xtrole; -- -- Name: apapply; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE apapply FROM PUBLIC; REVOKE ALL ON TABLE apapply FROM admin; GRANT ALL ON TABLE apapply TO admin; GRANT ALL ON TABLE apapply TO xtrole; -- -- Name: apapply_apapply_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE apapply_apapply_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE apapply_apapply_id_seq FROM admin; GRANT ALL ON SEQUENCE apapply_apapply_id_seq TO admin; GRANT ALL ON SEQUENCE apapply_apapply_id_seq TO xtrole; -- -- Name: checkhead; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE checkhead FROM PUBLIC; REVOKE ALL ON TABLE checkhead FROM admin; GRANT ALL ON TABLE checkhead TO admin; GRANT ALL ON TABLE checkhead TO xtrole; -- -- Name: apchk; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE apchk FROM PUBLIC; REVOKE ALL ON TABLE apchk FROM admin; GRANT ALL ON TABLE apchk TO admin; GRANT ALL ON TABLE apchk TO xtrole; -- -- Name: checkitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE checkitem FROM PUBLIC; REVOKE ALL ON TABLE checkitem FROM admin; GRANT ALL ON TABLE checkitem TO admin; GRANT ALL ON TABLE checkitem TO xtrole; -- -- Name: apchkitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE apchkitem FROM PUBLIC; REVOKE ALL ON TABLE apchkitem FROM admin; GRANT ALL ON TABLE apchkitem TO admin; GRANT ALL ON TABLE apchkitem TO xtrole; -- -- Name: apcreditapply; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE apcreditapply FROM PUBLIC; REVOKE ALL ON TABLE apcreditapply FROM admin; GRANT ALL ON TABLE apcreditapply TO admin; GRANT ALL ON TABLE apcreditapply TO xtrole; -- -- Name: apcreditapply_apcreditapply_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE apcreditapply_apcreditapply_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE apcreditapply_apcreditapply_id_seq FROM admin; GRANT ALL ON SEQUENCE apcreditapply_apcreditapply_id_seq TO admin; GRANT ALL ON SEQUENCE apcreditapply_apcreditapply_id_seq TO xtrole; -- -- Name: apmemo; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE apmemo FROM PUBLIC; REVOKE ALL ON TABLE apmemo FROM admin; GRANT ALL ON TABLE apmemo TO admin; GRANT ALL ON TABLE apmemo TO xtrole; -- -- Name: apopen_apopen_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE apopen_apopen_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE apopen_apopen_id_seq FROM admin; GRANT ALL ON SEQUENCE apopen_apopen_id_seq TO admin; GRANT ALL ON SEQUENCE apopen_apopen_id_seq TO xtrole; -- -- Name: apopentax; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE apopentax FROM PUBLIC; REVOKE ALL ON TABLE apopentax FROM admin; GRANT ALL ON TABLE apopentax TO admin; GRANT ALL ON TABLE apopentax TO xtrole; -- -- Name: apselect; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE apselect FROM PUBLIC; REVOKE ALL ON TABLE apselect FROM admin; GRANT ALL ON TABLE apselect TO admin; GRANT ALL ON TABLE apselect TO xtrole; -- -- Name: apselect_apselect_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE apselect_apselect_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE apselect_apselect_id_seq FROM admin; GRANT ALL ON SEQUENCE apselect_apselect_id_seq TO admin; GRANT ALL ON SEQUENCE apselect_apselect_id_seq TO xtrole; -- -- Name: araccnt; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE araccnt FROM PUBLIC; REVOKE ALL ON TABLE araccnt FROM admin; GRANT ALL ON TABLE araccnt TO admin; GRANT ALL ON TABLE araccnt TO xtrole; -- -- Name: araccnt_araccnt_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE araccnt_araccnt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE araccnt_araccnt_id_seq FROM admin; GRANT ALL ON SEQUENCE araccnt_araccnt_id_seq TO admin; GRANT ALL ON SEQUENCE araccnt_araccnt_id_seq TO xtrole; -- -- Name: arapply; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE arapply FROM PUBLIC; REVOKE ALL ON TABLE arapply FROM admin; GRANT ALL ON TABLE arapply TO admin; GRANT ALL ON TABLE arapply TO xtrole; -- -- Name: arapply_arapply_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE arapply_arapply_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE arapply_arapply_id_seq FROM admin; GRANT ALL ON SEQUENCE arapply_arapply_id_seq TO admin; GRANT ALL ON SEQUENCE arapply_arapply_id_seq TO xtrole; -- -- Name: cashrcptitem_cashrcptitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cashrcptitem_cashrcptitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cashrcptitem_cashrcptitem_id_seq FROM admin; GRANT ALL ON SEQUENCE cashrcptitem_cashrcptitem_id_seq TO admin; GRANT ALL ON SEQUENCE cashrcptitem_cashrcptitem_id_seq TO xtrole; -- -- Name: arcreditapply; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE arcreditapply FROM PUBLIC; REVOKE ALL ON TABLE arcreditapply FROM admin; GRANT ALL ON TABLE arcreditapply TO admin; GRANT ALL ON TABLE arcreditapply TO xtrole; -- -- Name: arcreditapply_arcreditapply_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE arcreditapply_arcreditapply_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE arcreditapply_arcreditapply_id_seq FROM admin; GRANT ALL ON SEQUENCE arcreditapply_arcreditapply_id_seq TO admin; GRANT ALL ON SEQUENCE arcreditapply_arcreditapply_id_seq TO xtrole; -- -- Name: armemo; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE armemo FROM PUBLIC; REVOKE ALL ON TABLE armemo FROM admin; GRANT ALL ON TABLE armemo TO admin; GRANT ALL ON TABLE armemo TO xtrole; -- -- Name: aropen_aropen_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE aropen_aropen_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE aropen_aropen_id_seq FROM admin; GRANT ALL ON SEQUENCE aropen_aropen_id_seq TO admin; GRANT ALL ON SEQUENCE aropen_aropen_id_seq TO xtrole; -- -- Name: aropentax; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE aropentax FROM PUBLIC; REVOKE ALL ON TABLE aropentax FROM admin; GRANT ALL ON TABLE aropentax TO admin; GRANT ALL ON TABLE aropentax TO xtrole; -- -- Name: asohist; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE asohist FROM PUBLIC; REVOKE ALL ON TABLE asohist FROM admin; GRANT ALL ON TABLE asohist TO admin; GRANT ALL ON TABLE asohist TO xtrole; -- -- Name: asohist_asohist_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE asohist_asohist_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE asohist_asohist_id_seq FROM admin; GRANT ALL ON SEQUENCE asohist_asohist_id_seq TO admin; GRANT ALL ON SEQUENCE asohist_asohist_id_seq TO xtrole; -- -- Name: asohisttax; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE asohisttax FROM PUBLIC; REVOKE ALL ON TABLE asohisttax FROM admin; GRANT ALL ON TABLE asohisttax TO admin; GRANT ALL ON TABLE asohisttax TO xtrole; -- -- Name: atlasmap; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE atlasmap FROM PUBLIC; REVOKE ALL ON TABLE atlasmap FROM admin; GRANT ALL ON TABLE atlasmap TO admin; GRANT ALL ON TABLE atlasmap TO xtrole; -- -- Name: atlasmap_atlasmap_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE atlasmap_atlasmap_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE atlasmap_atlasmap_id_seq FROM admin; GRANT ALL ON SEQUENCE atlasmap_atlasmap_id_seq TO admin; GRANT ALL ON SEQUENCE atlasmap_atlasmap_id_seq TO xtrole; -- -- Name: backup_usr; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE backup_usr FROM PUBLIC; REVOKE ALL ON TABLE backup_usr FROM admin; GRANT ALL ON TABLE backup_usr TO admin; GRANT ALL ON TABLE backup_usr TO xtrole; -- -- Name: bankaccnt_bankaccnt_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE bankaccnt_bankaccnt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bankaccnt_bankaccnt_id_seq FROM admin; GRANT ALL ON SEQUENCE bankaccnt_bankaccnt_id_seq TO admin; GRANT ALL ON SEQUENCE bankaccnt_bankaccnt_id_seq TO xtrole; -- -- Name: bankadj; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE bankadj FROM PUBLIC; REVOKE ALL ON TABLE bankadj FROM admin; GRANT ALL ON TABLE bankadj TO admin; GRANT ALL ON TABLE bankadj TO xtrole; -- -- Name: bankadj_bankadj_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE bankadj_bankadj_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bankadj_bankadj_id_seq FROM admin; GRANT ALL ON SEQUENCE bankadj_bankadj_id_seq TO admin; GRANT ALL ON SEQUENCE bankadj_bankadj_id_seq TO xtrole; -- -- Name: bankadjtype; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE bankadjtype FROM PUBLIC; REVOKE ALL ON TABLE bankadjtype FROM admin; GRANT ALL ON TABLE bankadjtype TO admin; GRANT ALL ON TABLE bankadjtype TO xtrole; -- -- Name: bankadjtype_bankadjtype_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE bankadjtype_bankadjtype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bankadjtype_bankadjtype_id_seq FROM admin; GRANT ALL ON SEQUENCE bankadjtype_bankadjtype_id_seq TO admin; GRANT ALL ON SEQUENCE bankadjtype_bankadjtype_id_seq TO xtrole; -- -- Name: bankrec; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE bankrec FROM PUBLIC; REVOKE ALL ON TABLE bankrec FROM admin; GRANT ALL ON TABLE bankrec TO admin; GRANT ALL ON TABLE bankrec TO xtrole; -- -- Name: bankrec_bankrec_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE bankrec_bankrec_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bankrec_bankrec_id_seq FROM admin; GRANT ALL ON SEQUENCE bankrec_bankrec_id_seq TO admin; GRANT ALL ON SEQUENCE bankrec_bankrec_id_seq TO xtrole; -- -- Name: bankrecimport; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE bankrecimport FROM PUBLIC; REVOKE ALL ON TABLE bankrecimport FROM admin; GRANT ALL ON TABLE bankrecimport TO admin; GRANT ALL ON TABLE bankrecimport TO xtrole; -- -- Name: bankrecimport_bankrecimport_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE bankrecimport_bankrecimport_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bankrecimport_bankrecimport_id_seq FROM admin; GRANT ALL ON SEQUENCE bankrecimport_bankrecimport_id_seq TO admin; GRANT ALL ON SEQUENCE bankrecimport_bankrecimport_id_seq TO xtrole; -- -- Name: bankrecitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE bankrecitem FROM PUBLIC; REVOKE ALL ON TABLE bankrecitem FROM admin; GRANT ALL ON TABLE bankrecitem TO admin; GRANT ALL ON TABLE bankrecitem TO xtrole; -- -- Name: bankrecitem_bankrecitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE bankrecitem_bankrecitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bankrecitem_bankrecitem_id_seq FROM admin; GRANT ALL ON SEQUENCE bankrecitem_bankrecitem_id_seq TO admin; GRANT ALL ON SEQUENCE bankrecitem_bankrecitem_id_seq TO xtrole; -- -- Name: bomhead_bomhead_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE bomhead_bomhead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bomhead_bomhead_id_seq FROM admin; GRANT ALL ON SEQUENCE bomhead_bomhead_id_seq TO admin; GRANT ALL ON SEQUENCE bomhead_bomhead_id_seq TO xtrole; -- -- Name: bomitem_bomitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE bomitem_bomitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bomitem_bomitem_id_seq FROM admin; GRANT ALL ON SEQUENCE bomitem_bomitem_id_seq TO admin; GRANT ALL ON SEQUENCE bomitem_bomitem_id_seq TO xtrole; -- -- Name: bomitemcost; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE bomitemcost FROM PUBLIC; REVOKE ALL ON TABLE bomitemcost FROM admin; GRANT ALL ON TABLE bomitemcost TO admin; GRANT ALL ON TABLE bomitemcost TO xtrole; -- -- Name: bomitemcost_bomitemcost_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE bomitemcost_bomitemcost_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bomitemcost_bomitemcost_id_seq FROM admin; GRANT ALL ON SEQUENCE bomitemcost_bomitemcost_id_seq TO admin; GRANT ALL ON SEQUENCE bomitemcost_bomitemcost_id_seq TO xtrole; -- -- Name: bomitemsub_bomitemsub_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE bomitemsub_bomitemsub_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bomitemsub_bomitemsub_id_seq FROM admin; GRANT ALL ON SEQUENCE bomitemsub_bomitemsub_id_seq TO admin; GRANT ALL ON SEQUENCE bomitemsub_bomitemsub_id_seq TO xtrole; -- -- Name: bomwork; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE bomwork FROM PUBLIC; REVOKE ALL ON TABLE bomwork FROM admin; GRANT ALL ON TABLE bomwork TO admin; GRANT ALL ON TABLE bomwork TO xtrole; -- -- Name: bomwork_bomwork_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE bomwork_bomwork_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bomwork_bomwork_id_seq FROM admin; GRANT ALL ON SEQUENCE bomwork_bomwork_id_seq TO admin; GRANT ALL ON SEQUENCE bomwork_bomwork_id_seq TO xtrole; -- -- Name: budget; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE budget FROM PUBLIC; REVOKE ALL ON TABLE budget FROM admin; GRANT ALL ON TABLE budget TO admin; GRANT ALL ON TABLE budget TO xtrole; -- -- Name: budghead_budghead_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE budghead_budghead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE budghead_budghead_id_seq FROM admin; GRANT ALL ON SEQUENCE budghead_budghead_id_seq TO admin; GRANT ALL ON SEQUENCE budghead_budghead_id_seq TO xtrole; -- -- Name: budgitem_budgitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE budgitem_budgitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE budgitem_budgitem_id_seq FROM admin; GRANT ALL ON SEQUENCE budgitem_budgitem_id_seq TO admin; GRANT ALL ON SEQUENCE budgitem_budgitem_id_seq TO xtrole; -- -- Name: calhead; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE calhead FROM PUBLIC; REVOKE ALL ON TABLE calhead FROM admin; GRANT ALL ON TABLE calhead TO admin; GRANT ALL ON TABLE calhead TO xtrole; -- -- Name: calhead_calhead_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE calhead_calhead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE calhead_calhead_id_seq FROM admin; GRANT ALL ON SEQUENCE calhead_calhead_id_seq TO admin; GRANT ALL ON SEQUENCE calhead_calhead_id_seq TO xtrole; -- -- Name: carrier_carrier_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE carrier_carrier_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE carrier_carrier_id_seq FROM admin; GRANT ALL ON SEQUENCE carrier_carrier_id_seq TO admin; GRANT ALL ON SEQUENCE carrier_carrier_id_seq TO xtrole; -- -- Name: cashrcpt_cashrcpt_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cashrcpt_cashrcpt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cashrcpt_cashrcpt_id_seq FROM admin; GRANT ALL ON SEQUENCE cashrcpt_cashrcpt_id_seq TO admin; GRANT ALL ON SEQUENCE cashrcpt_cashrcpt_id_seq TO xtrole; -- -- Name: cashrcptmisc_cashrcptmisc_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cashrcptmisc_cashrcptmisc_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cashrcptmisc_cashrcptmisc_id_seq FROM admin; GRANT ALL ON SEQUENCE cashrcptmisc_cashrcptmisc_id_seq TO admin; GRANT ALL ON SEQUENCE cashrcptmisc_cashrcptmisc_id_seq TO xtrole; -- -- Name: ccard_ccard_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE ccard_ccard_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ccard_ccard_id_seq FROM admin; GRANT ALL ON SEQUENCE ccard_ccard_id_seq TO admin; GRANT ALL ON SEQUENCE ccard_ccard_id_seq TO xtrole; -- -- Name: ccardaud; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE ccardaud FROM PUBLIC; REVOKE ALL ON TABLE ccardaud FROM admin; GRANT ALL ON TABLE ccardaud TO admin; GRANT ALL ON TABLE ccardaud TO xtrole; -- -- Name: ccardaud_ccardaud_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE ccardaud_ccardaud_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ccardaud_ccardaud_id_seq FROM admin; GRANT ALL ON SEQUENCE ccardaud_ccardaud_id_seq TO admin; GRANT ALL ON SEQUENCE ccardaud_ccardaud_id_seq TO xtrole; -- -- Name: ccbank; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE ccbank FROM PUBLIC; REVOKE ALL ON TABLE ccbank FROM admin; GRANT ALL ON TABLE ccbank TO admin; GRANT ALL ON TABLE ccbank TO xtrole; -- -- Name: ccbank_ccbank_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE ccbank_ccbank_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ccbank_ccbank_id_seq FROM admin; GRANT ALL ON SEQUENCE ccbank_ccbank_id_seq TO admin; GRANT ALL ON SEQUENCE ccbank_ccbank_id_seq TO xtrole; -- -- Name: ccpay; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE ccpay FROM PUBLIC; REVOKE ALL ON TABLE ccpay FROM admin; GRANT ALL ON TABLE ccpay TO admin; GRANT ALL ON TABLE ccpay TO xtrole; -- -- Name: ccpay_ccpay_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE ccpay_ccpay_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ccpay_ccpay_id_seq FROM admin; GRANT ALL ON SEQUENCE ccpay_ccpay_id_seq TO admin; GRANT ALL ON SEQUENCE ccpay_ccpay_id_seq TO xtrole; -- -- Name: char_char_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE char_char_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE char_char_id_seq FROM admin; GRANT ALL ON SEQUENCE char_char_id_seq TO admin; GRANT ALL ON SEQUENCE char_char_id_seq TO xtrole; -- -- Name: charass_charass_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE charass_charass_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE charass_charass_id_seq FROM admin; GRANT ALL ON SEQUENCE charass_charass_id_seq TO admin; GRANT ALL ON SEQUENCE charass_charass_id_seq TO xtrole; -- -- Name: charopt; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE charopt FROM PUBLIC; REVOKE ALL ON TABLE charopt FROM admin; GRANT ALL ON TABLE charopt TO admin; GRANT ALL ON TABLE charopt TO xtrole; -- -- Name: charopt_charopt_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE charopt_charopt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE charopt_charopt_id_seq FROM admin; GRANT ALL ON SEQUENCE charopt_charopt_id_seq TO admin; GRANT ALL ON SEQUENCE charopt_charopt_id_seq TO xtrole; -- -- Name: charuse; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE charuse FROM PUBLIC; REVOKE ALL ON TABLE charuse FROM admin; GRANT ALL ON TABLE charuse TO admin; GRANT ALL ON TABLE charuse TO xtrole; -- -- Name: charuse_charuse_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE charuse_charuse_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE charuse_charuse_id_seq FROM admin; GRANT ALL ON SEQUENCE charuse_charuse_id_seq TO admin; GRANT ALL ON SEQUENCE charuse_charuse_id_seq TO xtrole; -- -- Name: checkhead_checkhead_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE checkhead_checkhead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE checkhead_checkhead_id_seq FROM admin; GRANT ALL ON SEQUENCE checkhead_checkhead_id_seq TO admin; GRANT ALL ON SEQUENCE checkhead_checkhead_id_seq TO xtrole; -- -- Name: checkitem_checkitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE checkitem_checkitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE checkitem_checkitem_id_seq FROM admin; GRANT ALL ON SEQUENCE checkitem_checkitem_id_seq TO admin; GRANT ALL ON SEQUENCE checkitem_checkitem_id_seq TO xtrole; -- -- Name: checkrecip; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE checkrecip FROM PUBLIC; REVOKE ALL ON TABLE checkrecip FROM admin; GRANT ALL ON TABLE checkrecip TO admin; GRANT ALL ON TABLE checkrecip TO xtrole; -- -- Name: classcode_classcode_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE classcode_classcode_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE classcode_classcode_id_seq FROM admin; GRANT ALL ON SEQUENCE classcode_classcode_id_seq TO admin; GRANT ALL ON SEQUENCE classcode_classcode_id_seq TO xtrole; -- -- Name: cmhead_cmhead_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cmhead_cmhead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cmhead_cmhead_id_seq FROM admin; GRANT ALL ON SEQUENCE cmhead_cmhead_id_seq TO admin; GRANT ALL ON SEQUENCE cmhead_cmhead_id_seq TO xtrole; -- -- Name: cmheadtax; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cmheadtax FROM PUBLIC; REVOKE ALL ON TABLE cmheadtax FROM admin; GRANT ALL ON TABLE cmheadtax TO admin; GRANT ALL ON TABLE cmheadtax TO xtrole; -- -- Name: cmitem_cmitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cmitem_cmitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cmitem_cmitem_id_seq FROM admin; GRANT ALL ON SEQUENCE cmitem_cmitem_id_seq TO admin; GRANT ALL ON SEQUENCE cmitem_cmitem_id_seq TO xtrole; -- -- Name: cmitemtax; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cmitemtax FROM PUBLIC; REVOKE ALL ON TABLE cmitemtax FROM admin; GRANT ALL ON TABLE cmitemtax TO admin; GRANT ALL ON TABLE cmitemtax TO xtrole; -- -- Name: cmnttype_cmnttype_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cmnttype_cmnttype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cmnttype_cmnttype_id_seq FROM admin; GRANT ALL ON SEQUENCE cmnttype_cmnttype_id_seq TO admin; GRANT ALL ON SEQUENCE cmnttype_cmnttype_id_seq TO xtrole; -- -- Name: cmnttypesource; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cmnttypesource FROM PUBLIC; REVOKE ALL ON TABLE cmnttypesource FROM admin; GRANT ALL ON TABLE cmnttypesource TO admin; GRANT ALL ON TABLE cmnttypesource TO xtrole; -- -- Name: cmnttypesource_cmnttypesource_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cmnttypesource_cmnttypesource_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cmnttypesource_cmnttypesource_id_seq FROM admin; GRANT ALL ON SEQUENCE cmnttypesource_cmnttypesource_id_seq TO admin; GRANT ALL ON SEQUENCE cmnttypesource_cmnttypesource_id_seq TO xtrole; -- -- Name: cntct_cntct_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cntct_cntct_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cntct_cntct_id_seq FROM admin; GRANT ALL ON SEQUENCE cntct_cntct_id_seq TO admin; GRANT ALL ON SEQUENCE cntct_cntct_id_seq TO xtrole; -- -- Name: cntctaddr; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cntctaddr FROM PUBLIC; REVOKE ALL ON TABLE cntctaddr FROM admin; GRANT ALL ON TABLE cntctaddr TO admin; GRANT ALL ON TABLE cntctaddr TO xtrole; -- -- Name: cntctaddr_cntctaddr_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cntctaddr_cntctaddr_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cntctaddr_cntctaddr_id_seq FROM admin; GRANT ALL ON SEQUENCE cntctaddr_cntctaddr_id_seq TO admin; GRANT ALL ON SEQUENCE cntctaddr_cntctaddr_id_seq TO xtrole; -- -- Name: cntctdata; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cntctdata FROM PUBLIC; REVOKE ALL ON TABLE cntctdata FROM admin; GRANT ALL ON TABLE cntctdata TO admin; GRANT ALL ON TABLE cntctdata TO xtrole; -- -- Name: cntctdata_cntctdata_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cntctdata_cntctdata_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cntctdata_cntctdata_id_seq FROM admin; GRANT ALL ON SEQUENCE cntctdata_cntctdata_id_seq TO admin; GRANT ALL ON SEQUENCE cntctdata_cntctdata_id_seq TO xtrole; -- -- Name: cntcteml; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cntcteml FROM PUBLIC; REVOKE ALL ON TABLE cntcteml FROM admin; GRANT ALL ON TABLE cntcteml TO admin; GRANT ALL ON TABLE cntcteml TO xtrole; -- -- Name: cntcteml_cntcteml_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cntcteml_cntcteml_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cntcteml_cntcteml_id_seq FROM admin; GRANT ALL ON SEQUENCE cntcteml_cntcteml_id_seq TO admin; GRANT ALL ON SEQUENCE cntcteml_cntcteml_id_seq TO xtrole; -- -- Name: cntctmrgd; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cntctmrgd FROM PUBLIC; REVOKE ALL ON TABLE cntctmrgd FROM admin; GRANT ALL ON TABLE cntctmrgd TO admin; GRANT ALL ON TABLE cntctmrgd TO xtrole; -- -- Name: cntctsel; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cntctsel FROM PUBLIC; REVOKE ALL ON TABLE cntctsel FROM admin; GRANT ALL ON TABLE cntctsel TO admin; GRANT ALL ON TABLE cntctsel TO xtrole; -- -- Name: cntslip_cntslip_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cntslip_cntslip_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cntslip_cntslip_id_seq FROM admin; GRANT ALL ON SEQUENCE cntslip_cntslip_id_seq TO admin; GRANT ALL ON SEQUENCE cntslip_cntslip_id_seq TO xtrole; -- -- Name: cobill; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cobill FROM PUBLIC; REVOKE ALL ON TABLE cobill FROM admin; GRANT ALL ON TABLE cobill TO admin; GRANT ALL ON TABLE cobill TO xtrole; -- -- Name: cobill_cobill_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cobill_cobill_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cobill_cobill_id_seq FROM admin; GRANT ALL ON SEQUENCE cobill_cobill_id_seq TO admin; GRANT ALL ON SEQUENCE cobill_cobill_id_seq TO xtrole; -- -- Name: cobilltax; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cobilltax FROM PUBLIC; REVOKE ALL ON TABLE cobilltax FROM admin; GRANT ALL ON TABLE cobilltax TO admin; GRANT ALL ON TABLE cobilltax TO xtrole; -- -- Name: cobmisc; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cobmisc FROM PUBLIC; REVOKE ALL ON TABLE cobmisc FROM admin; GRANT ALL ON TABLE cobmisc TO admin; GRANT ALL ON TABLE cobmisc TO xtrole; -- -- Name: cobmisc_cobmisc_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cobmisc_cobmisc_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cobmisc_cobmisc_id_seq FROM admin; GRANT ALL ON SEQUENCE cobmisc_cobmisc_id_seq TO admin; GRANT ALL ON SEQUENCE cobmisc_cobmisc_id_seq TO xtrole; -- -- Name: cobmisctax; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cobmisctax FROM PUBLIC; REVOKE ALL ON TABLE cobmisctax FROM admin; GRANT ALL ON TABLE cobmisctax TO admin; GRANT ALL ON TABLE cobmisctax TO xtrole; -- -- Name: cohead_cohead_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cohead_cohead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cohead_cohead_id_seq FROM admin; GRANT ALL ON SEQUENCE cohead_cohead_id_seq TO admin; GRANT ALL ON SEQUENCE cohead_cohead_id_seq TO xtrole; -- -- Name: cohist_cohist_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cohist_cohist_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cohist_cohist_id_seq FROM admin; GRANT ALL ON SEQUENCE cohist_cohist_id_seq TO admin; GRANT ALL ON SEQUENCE cohist_cohist_id_seq TO xtrole; -- -- Name: coitem_coitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE coitem_coitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE coitem_coitem_id_seq FROM admin; GRANT ALL ON SEQUENCE coitem_coitem_id_seq TO admin; GRANT ALL ON SEQUENCE coitem_coitem_id_seq TO xtrole; -- -- Name: comment_comment_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE comment_comment_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE comment_comment_id_seq FROM admin; GRANT ALL ON SEQUENCE comment_comment_id_seq TO admin; GRANT ALL ON SEQUENCE comment_comment_id_seq TO xtrole; -- -- Name: company; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE company FROM PUBLIC; REVOKE ALL ON TABLE company FROM admin; GRANT ALL ON TABLE company TO admin; GRANT ALL ON TABLE company TO xtrole; -- -- Name: company_company_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE company_company_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE company_company_id_seq FROM admin; GRANT ALL ON SEQUENCE company_company_id_seq TO admin; GRANT ALL ON SEQUENCE company_company_id_seq TO xtrole; -- -- Name: contrct_contrct_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE contrct_contrct_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE contrct_contrct_id_seq FROM admin; GRANT ALL ON SEQUENCE contrct_contrct_id_seq TO admin; GRANT ALL ON SEQUENCE contrct_contrct_id_seq TO xtrole; -- -- Name: shiphead; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE shiphead FROM PUBLIC; REVOKE ALL ON TABLE shiphead FROM admin; GRANT ALL ON TABLE shiphead TO admin; GRANT ALL ON TABLE shiphead TO xtrole; -- -- Name: shipitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE shipitem FROM PUBLIC; REVOKE ALL ON TABLE shipitem FROM admin; GRANT ALL ON TABLE shipitem TO admin; GRANT ALL ON TABLE shipitem TO xtrole; -- -- Name: coship; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE coship FROM PUBLIC; REVOKE ALL ON TABLE coship FROM admin; GRANT ALL ON TABLE coship TO admin; GRANT ALL ON TABLE coship TO xtrole; -- -- Name: coship_coship_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE coship_coship_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE coship_coship_id_seq FROM admin; GRANT ALL ON SEQUENCE coship_coship_id_seq TO admin; GRANT ALL ON SEQUENCE coship_coship_id_seq TO xtrole; -- -- Name: cosmisc; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cosmisc FROM PUBLIC; REVOKE ALL ON TABLE cosmisc FROM admin; GRANT ALL ON TABLE cosmisc TO admin; GRANT ALL ON TABLE cosmisc TO xtrole; -- -- Name: cosmisc_cosmisc_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cosmisc_cosmisc_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cosmisc_cosmisc_id_seq FROM admin; GRANT ALL ON SEQUENCE cosmisc_cosmisc_id_seq TO admin; GRANT ALL ON SEQUENCE cosmisc_cosmisc_id_seq TO xtrole; -- -- Name: cosrc_cosrc_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cosrc_cosrc_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cosrc_cosrc_id_seq FROM admin; GRANT ALL ON SEQUENCE cosrc_cosrc_id_seq TO admin; GRANT ALL ON SEQUENCE cosrc_cosrc_id_seq TO xtrole; -- -- Name: costcat_costcat_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE costcat_costcat_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE costcat_costcat_id_seq FROM admin; GRANT ALL ON SEQUENCE costcat_costcat_id_seq TO admin; GRANT ALL ON SEQUENCE costcat_costcat_id_seq TO xtrole; -- -- Name: costelem_costelem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE costelem_costelem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE costelem_costelem_id_seq FROM admin; GRANT ALL ON SEQUENCE costelem_costelem_id_seq TO admin; GRANT ALL ON SEQUENCE costelem_costelem_id_seq TO xtrole; -- -- Name: costhist; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE costhist FROM PUBLIC; REVOKE ALL ON TABLE costhist FROM admin; GRANT ALL ON TABLE costhist TO admin; GRANT ALL ON TABLE costhist TO xtrole; -- -- Name: costhist_costhist_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE costhist_costhist_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE costhist_costhist_id_seq FROM admin; GRANT ALL ON SEQUENCE costhist_costhist_id_seq TO admin; GRANT ALL ON SEQUENCE costhist_costhist_id_seq TO xtrole; -- -- Name: costupdate; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE costupdate FROM PUBLIC; REVOKE ALL ON TABLE costupdate FROM admin; GRANT ALL ON TABLE costupdate TO admin; GRANT ALL ON TABLE costupdate TO xtrole; -- -- Name: country; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE country FROM PUBLIC; REVOKE ALL ON TABLE country FROM admin; GRANT ALL ON TABLE country TO admin; GRANT ALL ON TABLE country TO xtrole; -- -- Name: country_country_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE country_country_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE country_country_id_seq FROM admin; GRANT ALL ON SEQUENCE country_country_id_seq TO admin; GRANT ALL ON SEQUENCE country_country_id_seq TO xtrole; -- -- Name: salesaccnt; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE salesaccnt FROM PUBLIC; REVOKE ALL ON TABLE salesaccnt FROM admin; GRANT ALL ON TABLE salesaccnt TO admin; GRANT ALL ON TABLE salesaccnt TO xtrole; -- -- Name: creditmemoeditlist; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE creditmemoeditlist FROM PUBLIC; REVOKE ALL ON TABLE creditmemoeditlist FROM admin; GRANT ALL ON TABLE creditmemoeditlist TO admin; GRANT ALL ON TABLE creditmemoeditlist TO xtrole; -- -- Name: creditmemoitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE creditmemoitem FROM PUBLIC; REVOKE ALL ON TABLE creditmemoitem FROM admin; GRANT ALL ON TABLE creditmemoitem TO admin; GRANT ALL ON TABLE creditmemoitem TO xtrole; -- -- Name: crmacct_crmacct_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE crmacct_crmacct_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE crmacct_crmacct_id_seq FROM admin; GRANT ALL ON SEQUENCE crmacct_crmacct_id_seq TO admin; GRANT ALL ON SEQUENCE crmacct_crmacct_id_seq TO xtrole; -- -- Name: crmacctsel; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE crmacctsel FROM PUBLIC; REVOKE ALL ON TABLE crmacctsel FROM admin; GRANT ALL ON TABLE crmacctsel TO admin; GRANT ALL ON TABLE crmacctsel TO xtrole; -- -- Name: curr_rate; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE curr_rate FROM PUBLIC; REVOKE ALL ON TABLE curr_rate FROM admin; GRANT ALL ON TABLE curr_rate TO admin; GRANT ALL ON TABLE curr_rate TO xtrole; -- -- Name: curr_rate_curr_rate_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE curr_rate_curr_rate_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE curr_rate_curr_rate_id_seq FROM admin; GRANT ALL ON SEQUENCE curr_rate_curr_rate_id_seq TO admin; GRANT ALL ON SEQUENCE curr_rate_curr_rate_id_seq TO xtrole; -- -- Name: curr_symbol_curr_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE curr_symbol_curr_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE curr_symbol_curr_id_seq FROM admin; GRANT ALL ON SEQUENCE curr_symbol_curr_id_seq TO admin; GRANT ALL ON SEQUENCE curr_symbol_curr_id_seq TO xtrole; -- -- Name: cust; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE cust FROM PUBLIC; REVOKE ALL ON TABLE cust FROM admin; GRANT ALL ON TABLE cust TO admin; GRANT ALL ON TABLE cust TO xtrole; -- -- Name: cust_serial_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE cust_serial_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cust_serial_seq FROM admin; GRANT ALL ON SEQUENCE cust_serial_seq TO admin; GRANT ALL ON SEQUENCE cust_serial_seq TO xtrole; -- -- Name: custform; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE custform FROM PUBLIC; REVOKE ALL ON TABLE custform FROM admin; GRANT ALL ON TABLE custform TO admin; GRANT ALL ON TABLE custform TO xtrole; -- -- Name: custform_custform_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE custform_custform_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE custform_custform_id_seq FROM admin; GRANT ALL ON SEQUENCE custform_custform_id_seq TO admin; GRANT ALL ON SEQUENCE custform_custform_id_seq TO xtrole; -- -- Name: custgrp; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE custgrp FROM PUBLIC; REVOKE ALL ON TABLE custgrp FROM admin; GRANT ALL ON TABLE custgrp TO admin; GRANT ALL ON TABLE custgrp TO xtrole; -- -- Name: custgrp_custgrp_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE custgrp_custgrp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE custgrp_custgrp_id_seq FROM admin; GRANT ALL ON SEQUENCE custgrp_custgrp_id_seq TO admin; GRANT ALL ON SEQUENCE custgrp_custgrp_id_seq TO xtrole; -- -- Name: custgrpitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE custgrpitem FROM PUBLIC; REVOKE ALL ON TABLE custgrpitem FROM admin; GRANT ALL ON TABLE custgrpitem TO admin; GRANT ALL ON TABLE custgrpitem TO xtrole; -- -- Name: custgrpitem_custgrpitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE custgrpitem_custgrpitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE custgrpitem_custgrpitem_id_seq FROM admin; GRANT ALL ON SEQUENCE custgrpitem_custgrpitem_id_seq TO admin; GRANT ALL ON SEQUENCE custgrpitem_custgrpitem_id_seq TO xtrole; -- -- Name: custtype_custtype_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE custtype_custtype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE custtype_custtype_id_seq FROM admin; GRANT ALL ON SEQUENCE custtype_custtype_id_seq TO admin; GRANT ALL ON SEQUENCE custtype_custtype_id_seq TO xtrole; -- -- Name: dept_dept_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE dept_dept_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE dept_dept_id_seq FROM admin; GRANT ALL ON SEQUENCE dept_dept_id_seq TO admin; GRANT ALL ON SEQUENCE dept_dept_id_seq TO xtrole; -- -- Name: destination; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE destination FROM PUBLIC; REVOKE ALL ON TABLE destination FROM admin; GRANT ALL ON TABLE destination TO admin; GRANT ALL ON TABLE destination TO xtrole; -- -- Name: destination_destination_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE destination_destination_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE destination_destination_id_seq FROM admin; GRANT ALL ON SEQUENCE destination_destination_id_seq TO admin; GRANT ALL ON SEQUENCE destination_destination_id_seq TO xtrole; -- -- Name: docinfo; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE docinfo FROM PUBLIC; REVOKE ALL ON TABLE docinfo FROM admin; GRANT ALL ON TABLE docinfo TO admin; GRANT ALL ON TABLE docinfo TO xtrole; -- -- Name: emp_emp_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE emp_emp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE emp_emp_id_seq FROM admin; GRANT ALL ON SEQUENCE emp_emp_id_seq TO admin; GRANT ALL ON SEQUENCE emp_emp_id_seq TO xtrole; -- -- Name: empgrp; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE empgrp FROM PUBLIC; REVOKE ALL ON TABLE empgrp FROM admin; GRANT ALL ON TABLE empgrp TO admin; GRANT ALL ON TABLE empgrp TO xtrole; -- -- Name: empgrp_empgrp_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE empgrp_empgrp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE empgrp_empgrp_id_seq FROM admin; GRANT ALL ON SEQUENCE empgrp_empgrp_id_seq TO admin; GRANT ALL ON SEQUENCE empgrp_empgrp_id_seq TO xtrole; -- -- Name: empgrpitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE empgrpitem FROM PUBLIC; REVOKE ALL ON TABLE empgrpitem FROM admin; GRANT ALL ON TABLE empgrpitem TO admin; GRANT ALL ON TABLE empgrpitem TO xtrole; -- -- Name: empgrpitem_empgrpitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE empgrpitem_empgrpitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE empgrpitem_empgrpitem_id_seq FROM admin; GRANT ALL ON SEQUENCE empgrpitem_empgrpitem_id_seq TO admin; GRANT ALL ON SEQUENCE empgrpitem_empgrpitem_id_seq TO xtrole; -- -- Name: evntlog; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE evntlog FROM PUBLIC; REVOKE ALL ON TABLE evntlog FROM admin; GRANT ALL ON TABLE evntlog TO admin; GRANT ALL ON TABLE evntlog TO xtrole; -- -- Name: evntlog_evntlog_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE evntlog_evntlog_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE evntlog_evntlog_id_seq FROM admin; GRANT ALL ON SEQUENCE evntlog_evntlog_id_seq TO admin; GRANT ALL ON SEQUENCE evntlog_evntlog_id_seq TO xtrole; -- -- Name: evntnot; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE evntnot FROM PUBLIC; REVOKE ALL ON TABLE evntnot FROM admin; GRANT ALL ON TABLE evntnot TO admin; GRANT ALL ON TABLE evntnot TO xtrole; -- -- Name: evntnot_evntnot_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE evntnot_evntnot_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE evntnot_evntnot_id_seq FROM admin; GRANT ALL ON SEQUENCE evntnot_evntnot_id_seq TO admin; GRANT ALL ON SEQUENCE evntnot_evntnot_id_seq TO xtrole; -- -- Name: evnttype; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE evnttype FROM PUBLIC; REVOKE ALL ON TABLE evnttype FROM admin; GRANT ALL ON TABLE evnttype TO admin; GRANT ALL ON TABLE evnttype TO xtrole; -- -- Name: evnttype_evnttype_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE evnttype_evnttype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE evnttype_evnttype_id_seq FROM admin; GRANT ALL ON SEQUENCE evnttype_evnttype_id_seq TO admin; GRANT ALL ON SEQUENCE evnttype_evnttype_id_seq TO xtrole; -- -- Name: expcat_expcat_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE expcat_expcat_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE expcat_expcat_id_seq FROM admin; GRANT ALL ON SEQUENCE expcat_expcat_id_seq TO admin; GRANT ALL ON SEQUENCE expcat_expcat_id_seq TO xtrole; -- -- Name: file_file_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE file_file_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE file_file_id_seq FROM admin; GRANT ALL ON SEQUENCE file_file_id_seq TO admin; GRANT ALL ON SEQUENCE file_file_id_seq TO xtrole; -- -- Name: filter; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE filter FROM PUBLIC; REVOKE ALL ON TABLE filter FROM admin; GRANT ALL ON TABLE filter TO admin; GRANT ALL ON TABLE filter TO xtrole; -- -- Name: filter_filter_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE filter_filter_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE filter_filter_id_seq FROM admin; GRANT ALL ON SEQUENCE filter_filter_id_seq TO admin; GRANT ALL ON SEQUENCE filter_filter_id_seq TO xtrole; -- -- Name: fincharg; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE fincharg FROM PUBLIC; REVOKE ALL ON TABLE fincharg FROM admin; GRANT ALL ON TABLE fincharg TO admin; GRANT ALL ON TABLE fincharg TO xtrole; -- -- Name: fincharg_fincharg_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE fincharg_fincharg_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE fincharg_fincharg_id_seq FROM admin; GRANT ALL ON SEQUENCE fincharg_fincharg_id_seq TO admin; GRANT ALL ON SEQUENCE fincharg_fincharg_id_seq TO xtrole; -- -- Name: flhead; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE flhead FROM PUBLIC; REVOKE ALL ON TABLE flhead FROM admin; GRANT ALL ON TABLE flhead TO admin; GRANT ALL ON TABLE flhead TO xtrole; -- -- Name: flitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE flitem FROM PUBLIC; REVOKE ALL ON TABLE flitem FROM admin; GRANT ALL ON TABLE flitem TO admin; GRANT ALL ON TABLE flitem TO xtrole; -- -- Name: flaccnt; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE flaccnt FROM PUBLIC; REVOKE ALL ON TABLE flaccnt FROM admin; GRANT ALL ON TABLE flaccnt TO admin; GRANT ALL ON TABLE flaccnt TO xtrole; -- -- Name: flcol; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE flcol FROM PUBLIC; REVOKE ALL ON TABLE flcol FROM admin; GRANT ALL ON TABLE flcol TO admin; GRANT ALL ON TABLE flcol TO xtrole; -- -- Name: flcol_flcol_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE flcol_flcol_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE flcol_flcol_id_seq FROM admin; GRANT ALL ON SEQUENCE flcol_flcol_id_seq TO admin; GRANT ALL ON SEQUENCE flcol_flcol_id_seq TO xtrole; -- -- Name: flgrp; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE flgrp FROM PUBLIC; REVOKE ALL ON TABLE flgrp FROM admin; GRANT ALL ON TABLE flgrp TO admin; GRANT ALL ON TABLE flgrp TO xtrole; -- -- Name: flgrp_flgrp_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE flgrp_flgrp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE flgrp_flgrp_id_seq FROM admin; GRANT ALL ON SEQUENCE flgrp_flgrp_id_seq TO admin; GRANT ALL ON SEQUENCE flgrp_flgrp_id_seq TO xtrole; -- -- Name: flhead_flhead_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE flhead_flhead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE flhead_flhead_id_seq FROM admin; GRANT ALL ON SEQUENCE flhead_flhead_id_seq TO admin; GRANT ALL ON SEQUENCE flhead_flhead_id_seq TO xtrole; -- -- Name: flitem_flitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE flitem_flitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE flitem_flitem_id_seq FROM admin; GRANT ALL ON SEQUENCE flitem_flitem_id_seq TO admin; GRANT ALL ON SEQUENCE flitem_flitem_id_seq TO xtrole; -- -- Name: flnotes; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE flnotes FROM PUBLIC; REVOKE ALL ON TABLE flnotes FROM admin; GRANT ALL ON TABLE flnotes TO admin; GRANT ALL ON TABLE flnotes TO xtrole; -- -- Name: flnotes_flnotes_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE flnotes_flnotes_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE flnotes_flnotes_id_seq FROM admin; GRANT ALL ON SEQUENCE flnotes_flnotes_id_seq TO admin; GRANT ALL ON SEQUENCE flnotes_flnotes_id_seq TO xtrole; -- -- Name: flrpt; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE flrpt FROM PUBLIC; REVOKE ALL ON TABLE flrpt FROM admin; GRANT ALL ON TABLE flrpt TO admin; GRANT ALL ON TABLE flrpt TO xtrole; -- -- Name: flrpt_flrpt_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE flrpt_flrpt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE flrpt_flrpt_id_seq FROM admin; GRANT ALL ON SEQUENCE flrpt_flrpt_id_seq TO admin; GRANT ALL ON SEQUENCE flrpt_flrpt_id_seq TO xtrole; -- -- Name: flspec; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE flspec FROM PUBLIC; REVOKE ALL ON TABLE flspec FROM admin; GRANT ALL ON TABLE flspec TO admin; GRANT ALL ON TABLE flspec TO xtrole; -- -- Name: flspec_flspec_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE flspec_flspec_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE flspec_flspec_id_seq FROM admin; GRANT ALL ON SEQUENCE flspec_flspec_id_seq TO admin; GRANT ALL ON SEQUENCE flspec_flspec_id_seq TO xtrole; -- -- Name: form; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE form FROM PUBLIC; REVOKE ALL ON TABLE form FROM admin; GRANT ALL ON TABLE form TO admin; GRANT ALL ON TABLE form TO xtrole; -- -- Name: form_form_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE form_form_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE form_form_id_seq FROM admin; GRANT ALL ON SEQUENCE form_form_id_seq TO admin; GRANT ALL ON SEQUENCE form_form_id_seq TO xtrole; -- -- Name: freightclass_freightclass_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE freightclass_freightclass_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE freightclass_freightclass_id_seq FROM admin; GRANT ALL ON SEQUENCE freightclass_freightclass_id_seq TO admin; GRANT ALL ON SEQUENCE freightclass_freightclass_id_seq TO xtrole; -- -- Name: glseries; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE glseries FROM PUBLIC; REVOKE ALL ON TABLE glseries FROM admin; GRANT ALL ON TABLE glseries TO admin; GRANT ALL ON TABLE glseries TO xtrole; -- -- Name: glseries_glseries_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE glseries_glseries_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE glseries_glseries_id_seq FROM admin; GRANT ALL ON SEQUENCE glseries_glseries_id_seq TO admin; GRANT ALL ON SEQUENCE glseries_glseries_id_seq TO xtrole; -- -- Name: gltrans_gltrans_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE gltrans_gltrans_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE gltrans_gltrans_id_seq FROM admin; GRANT ALL ON SEQUENCE gltrans_gltrans_id_seq TO admin; GRANT ALL ON SEQUENCE gltrans_gltrans_id_seq TO xtrole; -- -- Name: gltrans_sequence_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE gltrans_sequence_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE gltrans_sequence_seq FROM admin; GRANT ALL ON SEQUENCE gltrans_sequence_seq TO admin; GRANT ALL ON SEQUENCE gltrans_sequence_seq TO xtrole; -- -- Name: grp; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE grp FROM PUBLIC; REVOKE ALL ON TABLE grp FROM admin; GRANT ALL ON TABLE grp TO admin; GRANT ALL ON TABLE grp TO xtrole; -- -- Name: grp_grp_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE grp_grp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE grp_grp_id_seq FROM admin; GRANT ALL ON SEQUENCE grp_grp_id_seq TO admin; GRANT ALL ON SEQUENCE grp_grp_id_seq TO xtrole; -- -- Name: grppriv; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE grppriv FROM PUBLIC; REVOKE ALL ON TABLE grppriv FROM admin; GRANT ALL ON TABLE grppriv TO admin; GRANT ALL ON TABLE grppriv TO xtrole; -- -- Name: grppriv_grppriv_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE grppriv_grppriv_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE grppriv_grppriv_id_seq FROM admin; GRANT ALL ON SEQUENCE grppriv_grppriv_id_seq TO admin; GRANT ALL ON SEQUENCE grppriv_grppriv_id_seq TO xtrole; -- -- Name: hnfc; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE hnfc FROM PUBLIC; REVOKE ALL ON TABLE hnfc FROM admin; GRANT ALL ON TABLE hnfc TO admin; GRANT ALL ON TABLE hnfc TO xtrole; -- -- Name: hnfc_hnfc_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE hnfc_hnfc_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE hnfc_hnfc_id_seq FROM admin; GRANT ALL ON SEQUENCE hnfc_hnfc_id_seq TO admin; GRANT ALL ON SEQUENCE hnfc_hnfc_id_seq TO xtrole; -- -- Name: incdt_incdt_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE incdt_incdt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE incdt_incdt_id_seq FROM admin; GRANT ALL ON SEQUENCE incdt_incdt_id_seq TO admin; GRANT ALL ON SEQUENCE incdt_incdt_id_seq TO xtrole; -- -- Name: incdtcat_incdtcat_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE incdtcat_incdtcat_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE incdtcat_incdtcat_id_seq FROM admin; GRANT ALL ON SEQUENCE incdtcat_incdtcat_id_seq TO admin; GRANT ALL ON SEQUENCE incdtcat_incdtcat_id_seq TO xtrole; -- -- Name: incdthist; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE incdthist FROM PUBLIC; REVOKE ALL ON TABLE incdthist FROM admin; GRANT ALL ON TABLE incdthist TO admin; GRANT ALL ON TABLE incdthist TO xtrole; -- -- Name: incdthist_incdthist_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE incdthist_incdthist_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE incdthist_incdthist_id_seq FROM admin; GRANT ALL ON SEQUENCE incdthist_incdthist_id_seq TO admin; GRANT ALL ON SEQUENCE incdthist_incdthist_id_seq TO xtrole; -- -- Name: incdtpriority_incdtpriority_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE incdtpriority_incdtpriority_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE incdtpriority_incdtpriority_id_seq FROM admin; GRANT ALL ON SEQUENCE incdtpriority_incdtpriority_id_seq TO admin; GRANT ALL ON SEQUENCE incdtpriority_incdtpriority_id_seq TO xtrole; -- -- Name: incdtresolution_incdtresolution_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE incdtresolution_incdtresolution_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE incdtresolution_incdtresolution_id_seq FROM admin; GRANT ALL ON SEQUENCE incdtresolution_incdtresolution_id_seq TO admin; GRANT ALL ON SEQUENCE incdtresolution_incdtresolution_id_seq TO xtrole; -- -- Name: incdtseverity_incdtseverity_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE incdtseverity_incdtseverity_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE incdtseverity_incdtseverity_id_seq FROM admin; GRANT ALL ON SEQUENCE incdtseverity_incdtseverity_id_seq TO admin; GRANT ALL ON SEQUENCE incdtseverity_incdtseverity_id_seq TO xtrole; -- -- Name: invbal_invbal_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE invbal_invbal_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE invbal_invbal_id_seq FROM admin; GRANT ALL ON SEQUENCE invbal_invbal_id_seq TO admin; GRANT ALL ON SEQUENCE invbal_invbal_id_seq TO xtrole; -- -- Name: invc_invc_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE invc_invc_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE invc_invc_id_seq FROM admin; GRANT ALL ON SEQUENCE invc_invc_id_seq TO admin; GRANT ALL ON SEQUENCE invc_invc_id_seq TO xtrole; -- -- Name: invchead_invchead_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE invchead_invchead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE invchead_invchead_id_seq FROM admin; GRANT ALL ON SEQUENCE invchead_invchead_id_seq TO admin; GRANT ALL ON SEQUENCE invchead_invchead_id_seq TO xtrole; -- -- Name: invcheadtax; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE invcheadtax FROM PUBLIC; REVOKE ALL ON TABLE invcheadtax FROM admin; GRANT ALL ON TABLE invcheadtax TO admin; GRANT ALL ON TABLE invcheadtax TO xtrole; -- -- Name: invcitem_invcitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE invcitem_invcitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE invcitem_invcitem_id_seq FROM admin; GRANT ALL ON SEQUENCE invcitem_invcitem_id_seq TO admin; GRANT ALL ON SEQUENCE invcitem_invcitem_id_seq TO xtrole; -- -- Name: invcitemtax; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE invcitemtax FROM PUBLIC; REVOKE ALL ON TABLE invcitemtax FROM admin; GRANT ALL ON TABLE invcitemtax TO admin; GRANT ALL ON TABLE invcitemtax TO xtrole; -- -- Name: invcnt_invcnt_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE invcnt_invcnt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE invcnt_invcnt_id_seq FROM admin; GRANT ALL ON SEQUENCE invcnt_invcnt_id_seq TO admin; GRANT ALL ON SEQUENCE invcnt_invcnt_id_seq TO xtrole; -- -- Name: invdetail; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE invdetail FROM PUBLIC; REVOKE ALL ON TABLE invdetail FROM admin; GRANT ALL ON TABLE invdetail TO admin; GRANT ALL ON TABLE invdetail TO xtrole; -- -- Name: invdetail_invdetail_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE invdetail_invdetail_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE invdetail_invdetail_id_seq FROM admin; GRANT ALL ON SEQUENCE invdetail_invdetail_id_seq TO admin; GRANT ALL ON SEQUENCE invdetail_invdetail_id_seq TO xtrole; -- -- Name: invhist; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE invhist FROM PUBLIC; REVOKE ALL ON TABLE invhist FROM admin; GRANT ALL ON TABLE invhist TO admin; GRANT ALL ON TABLE invhist TO xtrole; -- -- Name: invhist_invhist_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE invhist_invhist_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE invhist_invhist_id_seq FROM admin; GRANT ALL ON SEQUENCE invhist_invhist_id_seq TO admin; GRANT ALL ON SEQUENCE invhist_invhist_id_seq TO xtrole; -- -- Name: invhistexpcat; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE invhistexpcat FROM PUBLIC; REVOKE ALL ON TABLE invhistexpcat FROM admin; GRANT ALL ON TABLE invhistexpcat TO admin; GRANT ALL ON TABLE invhistexpcat TO xtrole; -- -- Name: invhistexpcat_invhistexpcat_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE invhistexpcat_invhistexpcat_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE invhistexpcat_invhistexpcat_id_seq FROM admin; GRANT ALL ON SEQUENCE invhistexpcat_invhistexpcat_id_seq TO admin; GRANT ALL ON SEQUENCE invhistexpcat_invhistexpcat_id_seq TO xtrole; -- -- Name: invoiceitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE invoiceitem FROM PUBLIC; REVOKE ALL ON TABLE invoiceitem FROM admin; GRANT ALL ON TABLE invoiceitem TO admin; GRANT ALL ON TABLE invoiceitem TO xtrole; -- -- Name: ipsass_ipsass_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE ipsass_ipsass_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ipsass_ipsass_id_seq FROM admin; GRANT ALL ON SEQUENCE ipsass_ipsass_id_seq TO admin; GRANT ALL ON SEQUENCE ipsass_ipsass_id_seq TO xtrole; -- -- Name: ipsctyp_ipsctyp_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE ipsctyp_ipsctyp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ipsctyp_ipsctyp_id_seq FROM admin; GRANT ALL ON SEQUENCE ipsctyp_ipsctyp_id_seq TO admin; GRANT ALL ON SEQUENCE ipsctyp_ipsctyp_id_seq TO xtrole; -- -- Name: ipscust_ipscust_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE ipscust_ipscust_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ipscust_ipscust_id_seq FROM admin; GRANT ALL ON SEQUENCE ipscust_ipscust_id_seq TO admin; GRANT ALL ON SEQUENCE ipscust_ipscust_id_seq TO xtrole; -- -- Name: ipsfreight_ipsfreight_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE ipsfreight_ipsfreight_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ipsfreight_ipsfreight_id_seq FROM admin; GRANT ALL ON SEQUENCE ipsfreight_ipsfreight_id_seq TO admin; GRANT ALL ON SEQUENCE ipsfreight_ipsfreight_id_seq TO xtrole; -- -- Name: ipshead_ipshead_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE ipshead_ipshead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ipshead_ipshead_id_seq FROM admin; GRANT ALL ON SEQUENCE ipshead_ipshead_id_seq TO admin; GRANT ALL ON SEQUENCE ipshead_ipshead_id_seq TO xtrole; -- -- Name: ipsitem_ipsitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE ipsitem_ipsitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ipsitem_ipsitem_id_seq FROM admin; GRANT ALL ON SEQUENCE ipsitem_ipsitem_id_seq TO admin; GRANT ALL ON SEQUENCE ipsitem_ipsitem_id_seq TO xtrole; -- -- Name: ipsitemchar_ipsitemchar_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE ipsitemchar_ipsitemchar_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ipsitemchar_ipsitemchar_id_seq FROM admin; GRANT ALL ON SEQUENCE ipsitemchar_ipsitemchar_id_seq TO admin; GRANT ALL ON SEQUENCE ipsitemchar_ipsitemchar_id_seq TO xtrole; -- -- Name: ipsprice; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE ipsprice FROM PUBLIC; REVOKE ALL ON TABLE ipsprice FROM admin; GRANT ALL ON TABLE ipsprice TO admin; GRANT ALL ON TABLE ipsprice TO xtrole; -- -- Name: ipsprodcat_bak; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE ipsprodcat_bak FROM PUBLIC; REVOKE ALL ON TABLE ipsprodcat_bak FROM admin; GRANT ALL ON TABLE ipsprodcat_bak TO admin; GRANT ALL ON TABLE ipsprodcat_bak TO xtrole; -- -- Name: ipsprodcat_ipsprodcat_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE ipsprodcat_ipsprodcat_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ipsprodcat_ipsprodcat_id_seq FROM admin; GRANT ALL ON SEQUENCE ipsprodcat_ipsprodcat_id_seq TO admin; GRANT ALL ON SEQUENCE ipsprodcat_ipsprodcat_id_seq TO xtrole; -- -- Name: item_item_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE item_item_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE item_item_id_seq FROM admin; GRANT ALL ON SEQUENCE item_item_id_seq TO admin; GRANT ALL ON SEQUENCE item_item_id_seq TO xtrole; -- -- Name: itemalias_itemalias_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE itemalias_itemalias_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemalias_itemalias_id_seq FROM admin; GRANT ALL ON SEQUENCE itemalias_itemalias_id_seq TO admin; GRANT ALL ON SEQUENCE itemalias_itemalias_id_seq TO xtrole; -- -- Name: itematr_itematr_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE itematr_itematr_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itematr_itematr_id_seq FROM admin; GRANT ALL ON SEQUENCE itematr_itematr_id_seq TO admin; GRANT ALL ON SEQUENCE itematr_itematr_id_seq TO xtrole; -- -- Name: itemcost_itemcost_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE itemcost_itemcost_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemcost_itemcost_id_seq FROM admin; GRANT ALL ON SEQUENCE itemcost_itemcost_id_seq TO admin; GRANT ALL ON SEQUENCE itemcost_itemcost_id_seq TO xtrole; -- -- Name: itemfrez_itemfrez_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE itemfrez_itemfrez_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemfrez_itemfrez_seq FROM admin; GRANT ALL ON SEQUENCE itemfrez_itemfrez_seq TO admin; GRANT ALL ON SEQUENCE itemfrez_itemfrez_seq TO xtrole; -- -- Name: itemgrp; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE itemgrp FROM PUBLIC; REVOKE ALL ON TABLE itemgrp FROM admin; GRANT ALL ON TABLE itemgrp TO admin; GRANT ALL ON TABLE itemgrp TO xtrole; -- -- Name: itemgrp_itemgrp_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE itemgrp_itemgrp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemgrp_itemgrp_id_seq FROM admin; GRANT ALL ON SEQUENCE itemgrp_itemgrp_id_seq TO admin; GRANT ALL ON SEQUENCE itemgrp_itemgrp_id_seq TO xtrole; -- -- Name: itemgrpitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE itemgrpitem FROM PUBLIC; REVOKE ALL ON TABLE itemgrpitem FROM admin; GRANT ALL ON TABLE itemgrpitem TO admin; GRANT ALL ON TABLE itemgrpitem TO xtrole; -- -- Name: itemgrpitem_itemgrpitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE itemgrpitem_itemgrpitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemgrpitem_itemgrpitem_id_seq FROM admin; GRANT ALL ON SEQUENCE itemgrpitem_itemgrpitem_id_seq TO admin; GRANT ALL ON SEQUENCE itemgrpitem_itemgrpitem_id_seq TO xtrole; -- -- Name: itemimage; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE itemimage FROM PUBLIC; REVOKE ALL ON TABLE itemimage FROM admin; GRANT ALL ON TABLE itemimage TO admin; GRANT ALL ON TABLE itemimage TO xtrole; -- -- Name: itemimage_itemimage_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE itemimage_itemimage_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemimage_itemimage_id_seq FROM admin; GRANT ALL ON SEQUENCE itemimage_itemimage_id_seq TO admin; GRANT ALL ON SEQUENCE itemimage_itemimage_id_seq TO xtrole; -- -- Name: itemloc; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE itemloc FROM PUBLIC; REVOKE ALL ON TABLE itemloc FROM admin; GRANT ALL ON TABLE itemloc TO admin; GRANT ALL ON TABLE itemloc TO xtrole; -- -- Name: itemloc_itemloc_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE itemloc_itemloc_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemloc_itemloc_id_seq FROM admin; GRANT ALL ON SEQUENCE itemloc_itemloc_id_seq TO admin; GRANT ALL ON SEQUENCE itemloc_itemloc_id_seq TO xtrole; -- -- Name: itemloc_series_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE itemloc_series_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemloc_series_seq FROM admin; GRANT ALL ON SEQUENCE itemloc_series_seq TO admin; GRANT ALL ON SEQUENCE itemloc_series_seq TO xtrole; -- -- Name: itemlocdist; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE itemlocdist FROM PUBLIC; REVOKE ALL ON TABLE itemlocdist FROM admin; GRANT ALL ON TABLE itemlocdist TO admin; GRANT ALL ON TABLE itemlocdist TO xtrole; -- -- Name: itemlocdist_itemlocdist_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE itemlocdist_itemlocdist_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemlocdist_itemlocdist_id_seq FROM admin; GRANT ALL ON SEQUENCE itemlocdist_itemlocdist_id_seq TO admin; GRANT ALL ON SEQUENCE itemlocdist_itemlocdist_id_seq TO xtrole; -- -- Name: itemlocpost; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE itemlocpost FROM PUBLIC; REVOKE ALL ON TABLE itemlocpost FROM admin; GRANT ALL ON TABLE itemlocpost TO admin; GRANT ALL ON TABLE itemlocpost TO xtrole; -- -- Name: itemlocpost_itemlocpost_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE itemlocpost_itemlocpost_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemlocpost_itemlocpost_id_seq FROM admin; GRANT ALL ON SEQUENCE itemlocpost_itemlocpost_id_seq TO admin; GRANT ALL ON SEQUENCE itemlocpost_itemlocpost_id_seq TO xtrole; -- -- Name: itemopn_itemopn_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE itemopn_itemopn_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemopn_itemopn_id_seq FROM admin; GRANT ALL ON SEQUENCE itemopn_itemopn_id_seq TO admin; GRANT ALL ON SEQUENCE itemopn_itemopn_id_seq TO xtrole; -- -- Name: itemsite_itemsite_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE itemsite_itemsite_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemsite_itemsite_id_seq FROM admin; GRANT ALL ON SEQUENCE itemsite_itemsite_id_seq TO admin; GRANT ALL ON SEQUENCE itemsite_itemsite_id_seq TO xtrole; -- -- Name: itemsrc_itemsrc_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE itemsrc_itemsrc_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemsrc_itemsrc_id_seq FROM admin; GRANT ALL ON SEQUENCE itemsrc_itemsrc_id_seq TO admin; GRANT ALL ON SEQUENCE itemsrc_itemsrc_id_seq TO xtrole; -- -- Name: itemsrcp_itemsrcp_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE itemsrcp_itemsrcp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemsrcp_itemsrcp_id_seq FROM admin; GRANT ALL ON SEQUENCE itemsrcp_itemsrcp_id_seq TO admin; GRANT ALL ON SEQUENCE itemsrcp_itemsrcp_id_seq TO xtrole; -- -- Name: itemsub_itemsub_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE itemsub_itemsub_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemsub_itemsub_id_seq FROM admin; GRANT ALL ON SEQUENCE itemsub_itemsub_id_seq TO admin; GRANT ALL ON SEQUENCE itemsub_itemsub_id_seq TO xtrole; -- -- Name: itemtax_itemtax_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE itemtax_itemtax_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemtax_itemtax_id_seq FROM admin; GRANT ALL ON SEQUENCE itemtax_itemtax_id_seq TO admin; GRANT ALL ON SEQUENCE itemtax_itemtax_id_seq TO xtrole; -- -- Name: itemtrans; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE itemtrans FROM PUBLIC; REVOKE ALL ON TABLE itemtrans FROM admin; GRANT ALL ON TABLE itemtrans TO admin; GRANT ALL ON TABLE itemtrans TO xtrole; -- -- Name: itemtrans_itemtrans_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE itemtrans_itemtrans_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemtrans_itemtrans_id_seq FROM admin; GRANT ALL ON SEQUENCE itemtrans_itemtrans_id_seq TO admin; GRANT ALL ON SEQUENCE itemtrans_itemtrans_id_seq TO xtrole; -- -- Name: itemuom; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE itemuom FROM PUBLIC; REVOKE ALL ON TABLE itemuom FROM admin; GRANT ALL ON TABLE itemuom TO admin; GRANT ALL ON TABLE itemuom TO xtrole; -- -- Name: itemuom_itemuom_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE itemuom_itemuom_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemuom_itemuom_id_seq FROM admin; GRANT ALL ON SEQUENCE itemuom_itemuom_id_seq TO admin; GRANT ALL ON SEQUENCE itemuom_itemuom_id_seq TO xtrole; -- -- Name: itemuomconv_itemuomconv_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE itemuomconv_itemuomconv_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemuomconv_itemuomconv_id_seq FROM admin; GRANT ALL ON SEQUENCE itemuomconv_itemuomconv_id_seq TO admin; GRANT ALL ON SEQUENCE itemuomconv_itemuomconv_id_seq TO xtrole; -- -- Name: journal_number_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE journal_number_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE journal_number_seq FROM admin; GRANT ALL ON SEQUENCE journal_number_seq TO admin; GRANT ALL ON SEQUENCE journal_number_seq TO xtrole; -- -- Name: jrnluse; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE jrnluse FROM PUBLIC; REVOKE ALL ON TABLE jrnluse FROM admin; GRANT ALL ON TABLE jrnluse TO admin; GRANT ALL ON TABLE jrnluse TO xtrole; -- -- Name: jrnluse_jrnluse_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE jrnluse_jrnluse_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE jrnluse_jrnluse_id_seq FROM admin; GRANT ALL ON SEQUENCE jrnluse_jrnluse_id_seq TO admin; GRANT ALL ON SEQUENCE jrnluse_jrnluse_id_seq TO xtrole; -- -- Name: labeldef; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE labeldef FROM PUBLIC; REVOKE ALL ON TABLE labeldef FROM admin; GRANT ALL ON TABLE labeldef TO admin; GRANT ALL ON TABLE labeldef TO xtrole; -- -- Name: labeldef_labeldef_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE labeldef_labeldef_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE labeldef_labeldef_id_seq FROM admin; GRANT ALL ON SEQUENCE labeldef_labeldef_id_seq TO admin; GRANT ALL ON SEQUENCE labeldef_labeldef_id_seq TO xtrole; -- -- Name: labelform; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE labelform FROM PUBLIC; REVOKE ALL ON TABLE labelform FROM admin; GRANT ALL ON TABLE labelform TO admin; GRANT ALL ON TABLE labelform TO xtrole; -- -- Name: labelform_labelform_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE labelform_labelform_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE labelform_labelform_id_seq FROM admin; GRANT ALL ON SEQUENCE labelform_labelform_id_seq TO admin; GRANT ALL ON SEQUENCE labelform_labelform_id_seq TO xtrole; -- -- Name: lang; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE lang FROM PUBLIC; REVOKE ALL ON TABLE lang FROM admin; GRANT ALL ON TABLE lang TO admin; GRANT ALL ON TABLE lang TO xtrole; -- -- Name: lang_lang_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE lang_lang_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE lang_lang_id_seq FROM admin; GRANT ALL ON SEQUENCE lang_lang_id_seq TO admin; GRANT ALL ON SEQUENCE lang_lang_id_seq TO xtrole; -- -- Name: locale; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE locale FROM PUBLIC; REVOKE ALL ON TABLE locale FROM admin; GRANT ALL ON TABLE locale TO admin; GRANT ALL ON TABLE locale TO xtrole; -- -- Name: locale_locale_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE locale_locale_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE locale_locale_id_seq FROM admin; GRANT ALL ON SEQUENCE locale_locale_id_seq TO admin; GRANT ALL ON SEQUENCE locale_locale_id_seq TO xtrole; -- -- Name: location_location_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE location_location_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE location_location_id_seq FROM admin; GRANT ALL ON SEQUENCE location_location_id_seq TO admin; GRANT ALL ON SEQUENCE location_location_id_seq TO xtrole; -- -- Name: locitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE locitem FROM PUBLIC; REVOKE ALL ON TABLE locitem FROM admin; GRANT ALL ON TABLE locitem TO admin; GRANT ALL ON TABLE locitem TO xtrole; -- -- Name: locitem_locitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE locitem_locitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE locitem_locitem_id_seq FROM admin; GRANT ALL ON SEQUENCE locitem_locitem_id_seq TO admin; GRANT ALL ON SEQUENCE locitem_locitem_id_seq TO xtrole; -- -- Name: log_log_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE log_log_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE log_log_id_seq FROM admin; GRANT ALL ON SEQUENCE log_log_id_seq TO admin; GRANT ALL ON SEQUENCE log_log_id_seq TO xtrole; -- -- Name: metric; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE metric FROM PUBLIC; REVOKE ALL ON TABLE metric FROM admin; GRANT ALL ON TABLE metric TO admin; GRANT ALL ON TABLE metric TO xtrole; -- -- Name: metric_metric_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE metric_metric_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE metric_metric_id_seq FROM admin; GRANT ALL ON SEQUENCE metric_metric_id_seq TO admin; GRANT ALL ON SEQUENCE metric_metric_id_seq TO xtrole; -- -- Name: metricenc; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE metricenc FROM PUBLIC; REVOKE ALL ON TABLE metricenc FROM admin; GRANT ALL ON TABLE metricenc TO admin; GRANT ALL ON TABLE metricenc TO xtrole; -- -- Name: metricenc_metricenc_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE metricenc_metricenc_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE metricenc_metricenc_id_seq FROM admin; GRANT ALL ON SEQUENCE metricenc_metricenc_id_seq TO admin; GRANT ALL ON SEQUENCE metricenc_metricenc_id_seq TO xtrole; -- -- Name: misc_index_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE misc_index_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE misc_index_seq FROM admin; GRANT ALL ON SEQUENCE misc_index_seq TO admin; GRANT ALL ON SEQUENCE misc_index_seq TO xtrole; -- -- Name: mrghist; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE mrghist FROM PUBLIC; REVOKE ALL ON TABLE mrghist FROM admin; GRANT ALL ON TABLE mrghist TO admin; GRANT ALL ON TABLE mrghist TO xtrole; -- -- Name: mrgundo; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE mrgundo FROM PUBLIC; REVOKE ALL ON TABLE mrgundo FROM admin; GRANT ALL ON TABLE mrgundo TO admin; GRANT ALL ON TABLE mrgundo TO xtrole; -- -- Name: msg; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE msg FROM PUBLIC; REVOKE ALL ON TABLE msg FROM admin; GRANT ALL ON TABLE msg TO admin; GRANT ALL ON TABLE msg TO xtrole; -- -- Name: msg_msg_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE msg_msg_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE msg_msg_id_seq FROM admin; GRANT ALL ON SEQUENCE msg_msg_id_seq TO admin; GRANT ALL ON SEQUENCE msg_msg_id_seq TO xtrole; -- -- Name: msguser; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE msguser FROM PUBLIC; REVOKE ALL ON TABLE msguser FROM admin; GRANT ALL ON TABLE msguser TO admin; GRANT ALL ON TABLE msguser TO xtrole; -- -- Name: msguser_msguser_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE msguser_msguser_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE msguser_msguser_id_seq FROM admin; GRANT ALL ON SEQUENCE msguser_msguser_id_seq TO admin; GRANT ALL ON SEQUENCE msguser_msguser_id_seq TO xtrole; -- -- Name: nvend_nvend_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE nvend_nvend_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE nvend_nvend_id_seq FROM admin; GRANT ALL ON SEQUENCE nvend_nvend_id_seq TO admin; GRANT ALL ON SEQUENCE nvend_nvend_id_seq TO xtrole; -- -- Name: obsolete_tax; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE obsolete_tax FROM PUBLIC; REVOKE ALL ON TABLE obsolete_tax FROM admin; GRANT ALL ON TABLE obsolete_tax TO admin; GRANT ALL ON TABLE obsolete_tax TO xtrole; -- -- Name: ophead_ophead_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE ophead_ophead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ophead_ophead_id_seq FROM admin; GRANT ALL ON SEQUENCE ophead_ophead_id_seq TO admin; GRANT ALL ON SEQUENCE ophead_ophead_id_seq TO xtrole; -- -- Name: opsource; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE opsource FROM PUBLIC; REVOKE ALL ON TABLE opsource FROM admin; GRANT ALL ON TABLE opsource TO admin; GRANT ALL ON TABLE opsource TO xtrole; -- -- Name: opsource_opsource_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE opsource_opsource_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE opsource_opsource_id_seq FROM admin; GRANT ALL ON SEQUENCE opsource_opsource_id_seq TO admin; GRANT ALL ON SEQUENCE opsource_opsource_id_seq TO xtrole; -- -- Name: opstage; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE opstage FROM PUBLIC; REVOKE ALL ON TABLE opstage FROM admin; GRANT ALL ON TABLE opstage TO admin; GRANT ALL ON TABLE opstage TO xtrole; -- -- Name: opstage_opstage_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE opstage_opstage_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE opstage_opstage_id_seq FROM admin; GRANT ALL ON SEQUENCE opstage_opstage_id_seq TO admin; GRANT ALL ON SEQUENCE opstage_opstage_id_seq TO xtrole; -- -- Name: optype; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE optype FROM PUBLIC; REVOKE ALL ON TABLE optype FROM admin; GRANT ALL ON TABLE optype TO admin; GRANT ALL ON TABLE optype TO xtrole; -- -- Name: optype_optype_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE optype_optype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE optype_optype_id_seq FROM admin; GRANT ALL ON SEQUENCE optype_optype_id_seq TO admin; GRANT ALL ON SEQUENCE optype_optype_id_seq TO xtrole; -- -- Name: orderhead; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE orderhead FROM PUBLIC; REVOKE ALL ON TABLE orderhead FROM admin; GRANT ALL ON TABLE orderhead TO admin; GRANT ALL ON TABLE orderhead TO xtrole; -- -- Name: orderitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE orderitem FROM PUBLIC; REVOKE ALL ON TABLE orderitem FROM admin; GRANT ALL ON TABLE orderitem TO admin; GRANT ALL ON TABLE orderitem TO xtrole; -- -- Name: orderseq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE orderseq FROM PUBLIC; REVOKE ALL ON TABLE orderseq FROM admin; GRANT ALL ON TABLE orderseq TO admin; GRANT ALL ON TABLE orderseq TO xtrole; -- -- Name: orderseq_orderseq_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE orderseq_orderseq_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE orderseq_orderseq_id_seq FROM admin; GRANT ALL ON SEQUENCE orderseq_orderseq_id_seq TO admin; GRANT ALL ON SEQUENCE orderseq_orderseq_id_seq TO xtrole; -- -- Name: pack; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE pack FROM PUBLIC; REVOKE ALL ON TABLE pack FROM admin; GRANT ALL ON TABLE pack TO admin; GRANT ALL ON TABLE pack TO xtrole; -- -- Name: pack_pack_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE pack_pack_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE pack_pack_id_seq FROM admin; GRANT ALL ON SEQUENCE pack_pack_id_seq TO admin; GRANT ALL ON SEQUENCE pack_pack_id_seq TO xtrole; -- -- Name: payaropen; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE payaropen FROM PUBLIC; REVOKE ALL ON TABLE payaropen FROM admin; GRANT ALL ON TABLE payaropen TO admin; GRANT ALL ON TABLE payaropen TO xtrole; -- -- Name: payco; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE payco FROM PUBLIC; REVOKE ALL ON TABLE payco FROM admin; GRANT ALL ON TABLE payco TO admin; GRANT ALL ON TABLE payco TO xtrole; -- -- Name: payco_payco_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE payco_payco_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE payco_payco_id_seq FROM admin; GRANT ALL ON SEQUENCE payco_payco_id_seq TO admin; GRANT ALL ON SEQUENCE payco_payco_id_seq TO xtrole; -- -- Name: period_period_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE period_period_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE period_period_id_seq FROM admin; GRANT ALL ON SEQUENCE period_period_id_seq TO admin; GRANT ALL ON SEQUENCE period_period_id_seq TO xtrole; -- -- Name: pkgdep; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE pkgdep FROM PUBLIC; REVOKE ALL ON TABLE pkgdep FROM admin; GRANT ALL ON TABLE pkgdep TO admin; GRANT ALL ON TABLE pkgdep TO xtrole; -- -- Name: pkgdep_pkgdep_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE pkgdep_pkgdep_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE pkgdep_pkgdep_id_seq FROM admin; GRANT ALL ON SEQUENCE pkgdep_pkgdep_id_seq TO admin; GRANT ALL ON SEQUENCE pkgdep_pkgdep_id_seq TO xtrole; -- -- Name: pkghead; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE pkghead FROM PUBLIC; REVOKE ALL ON TABLE pkghead FROM admin; GRANT ALL ON TABLE pkghead TO admin; GRANT ALL ON TABLE pkghead TO xtrole; -- -- Name: pkghead_pkghead_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE pkghead_pkghead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE pkghead_pkghead_id_seq FROM admin; GRANT ALL ON SEQUENCE pkghead_pkghead_id_seq TO admin; GRANT ALL ON SEQUENCE pkghead_pkghead_id_seq TO xtrole; -- -- Name: pkgitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE pkgitem FROM PUBLIC; REVOKE ALL ON TABLE pkgitem FROM admin; GRANT ALL ON TABLE pkgitem TO admin; GRANT ALL ON TABLE pkgitem TO xtrole; -- -- Name: pkgitem_pkgitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE pkgitem_pkgitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE pkgitem_pkgitem_id_seq FROM admin; GRANT ALL ON SEQUENCE pkgitem_pkgitem_id_seq TO admin; GRANT ALL ON SEQUENCE pkgitem_pkgitem_id_seq TO xtrole; -- -- Name: plancode_plancode_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE plancode_plancode_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE plancode_plancode_id_seq FROM admin; GRANT ALL ON SEQUENCE plancode_plancode_id_seq TO admin; GRANT ALL ON SEQUENCE plancode_plancode_id_seq TO xtrole; -- -- Name: planord_planord_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE planord_planord_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE planord_planord_id_seq FROM admin; GRANT ALL ON SEQUENCE planord_planord_id_seq TO admin; GRANT ALL ON SEQUENCE planord_planord_id_seq TO xtrole; -- -- Name: pohead_pohead_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE pohead_pohead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE pohead_pohead_id_seq FROM admin; GRANT ALL ON SEQUENCE pohead_pohead_id_seq TO admin; GRANT ALL ON SEQUENCE pohead_pohead_id_seq TO xtrole; -- -- Name: poitem_poitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE poitem_poitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE poitem_poitem_id_seq FROM admin; GRANT ALL ON SEQUENCE poitem_poitem_id_seq TO admin; GRANT ALL ON SEQUENCE poitem_poitem_id_seq TO xtrole; -- -- Name: recv; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE recv FROM PUBLIC; REVOKE ALL ON TABLE recv FROM admin; GRANT ALL ON TABLE recv TO admin; GRANT ALL ON TABLE recv TO xtrole; -- -- Name: porecv; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE porecv FROM PUBLIC; REVOKE ALL ON TABLE porecv FROM admin; GRANT ALL ON TABLE porecv TO admin; GRANT ALL ON TABLE porecv TO xtrole; -- -- Name: porecv_porecv_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE porecv_porecv_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE porecv_porecv_id_seq FROM admin; GRANT ALL ON SEQUENCE porecv_porecv_id_seq TO admin; GRANT ALL ON SEQUENCE porecv_porecv_id_seq TO xtrole; -- -- Name: poreject; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE poreject FROM PUBLIC; REVOKE ALL ON TABLE poreject FROM admin; GRANT ALL ON TABLE poreject TO admin; GRANT ALL ON TABLE poreject TO xtrole; -- -- Name: poreject_poreject_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE poreject_poreject_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE poreject_poreject_id_seq FROM admin; GRANT ALL ON SEQUENCE poreject_poreject_id_seq TO admin; GRANT ALL ON SEQUENCE poreject_poreject_id_seq TO xtrole; -- -- Name: pr; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE pr FROM PUBLIC; REVOKE ALL ON TABLE pr FROM admin; GRANT ALL ON TABLE pr TO admin; GRANT ALL ON TABLE pr TO xtrole; -- -- Name: pr_pr_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE pr_pr_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE pr_pr_id_seq FROM admin; GRANT ALL ON SEQUENCE pr_pr_id_seq TO admin; GRANT ALL ON SEQUENCE pr_pr_id_seq TO xtrole; -- -- Name: prftcntr; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE prftcntr FROM PUBLIC; REVOKE ALL ON TABLE prftcntr FROM admin; GRANT ALL ON TABLE prftcntr TO admin; GRANT ALL ON TABLE prftcntr TO xtrole; -- -- Name: prftcntr_prftcntr_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE prftcntr_prftcntr_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE prftcntr_prftcntr_id_seq FROM admin; GRANT ALL ON SEQUENCE prftcntr_prftcntr_id_seq TO admin; GRANT ALL ON SEQUENCE prftcntr_prftcntr_id_seq TO xtrole; -- -- Name: usrgrp; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE usrgrp FROM PUBLIC; REVOKE ALL ON TABLE usrgrp FROM admin; GRANT ALL ON TABLE usrgrp TO admin; GRANT ALL ON TABLE usrgrp TO xtrole; -- -- Name: usrpriv; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE usrpriv FROM PUBLIC; REVOKE ALL ON TABLE usrpriv FROM admin; GRANT ALL ON TABLE usrpriv TO admin; GRANT ALL ON TABLE usrpriv TO xtrole; -- -- Name: privgranted; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE privgranted FROM PUBLIC; REVOKE ALL ON TABLE privgranted FROM admin; GRANT ALL ON TABLE privgranted TO admin; GRANT ALL ON TABLE privgranted TO xtrole; -- -- Name: prj_prj_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE prj_prj_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE prj_prj_id_seq FROM admin; GRANT ALL ON SEQUENCE prj_prj_id_seq TO admin; GRANT ALL ON SEQUENCE prj_prj_id_seq TO xtrole; -- -- Name: prjtask_prjtask_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE prjtask_prjtask_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE prjtask_prjtask_id_seq FROM admin; GRANT ALL ON SEQUENCE prjtask_prjtask_id_seq TO admin; GRANT ALL ON SEQUENCE prjtask_prjtask_id_seq TO xtrole; -- -- Name: prjtaskuser; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE prjtaskuser FROM PUBLIC; REVOKE ALL ON TABLE prjtaskuser FROM admin; GRANT ALL ON TABLE prjtaskuser TO admin; GRANT ALL ON TABLE prjtaskuser TO xtrole; -- -- Name: prjtaskuser_prjtaskuser_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE prjtaskuser_prjtaskuser_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE prjtaskuser_prjtaskuser_id_seq FROM admin; GRANT ALL ON SEQUENCE prjtaskuser_prjtaskuser_id_seq TO admin; GRANT ALL ON SEQUENCE prjtaskuser_prjtaskuser_id_seq TO xtrole; -- -- Name: prjtype; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE prjtype FROM PUBLIC; REVOKE ALL ON TABLE prjtype FROM admin; GRANT ALL ON TABLE prjtype TO admin; GRANT ALL ON TABLE prjtype TO xtrole; -- -- Name: prjtype_prjtype_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE prjtype_prjtype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE prjtype_prjtype_id_seq FROM admin; GRANT ALL ON SEQUENCE prjtype_prjtype_id_seq TO admin; GRANT ALL ON SEQUENCE prjtype_prjtype_id_seq TO xtrole; -- -- Name: prodcat_prodcat_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE prodcat_prodcat_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE prodcat_prodcat_id_seq FROM admin; GRANT ALL ON SEQUENCE prodcat_prodcat_id_seq TO admin; GRANT ALL ON SEQUENCE prodcat_prodcat_id_seq TO xtrole; -- -- Name: qryhead; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE qryhead FROM PUBLIC; REVOKE ALL ON TABLE qryhead FROM admin; GRANT ALL ON TABLE qryhead TO admin; GRANT ALL ON TABLE qryhead TO xtrole; -- -- Name: qryhead_qryhead_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE qryhead_qryhead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE qryhead_qryhead_id_seq FROM admin; GRANT ALL ON SEQUENCE qryhead_qryhead_id_seq TO admin; GRANT ALL ON SEQUENCE qryhead_qryhead_id_seq TO xtrole; -- -- Name: qryitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE qryitem FROM PUBLIC; REVOKE ALL ON TABLE qryitem FROM admin; GRANT ALL ON TABLE qryitem TO admin; GRANT ALL ON TABLE qryitem TO xtrole; -- -- Name: qryitem_qryitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE qryitem_qryitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE qryitem_qryitem_id_seq FROM admin; GRANT ALL ON SEQUENCE qryitem_qryitem_id_seq TO admin; GRANT ALL ON SEQUENCE qryitem_qryitem_id_seq TO xtrole; -- -- Name: quhead_quhead_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE quhead_quhead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE quhead_quhead_id_seq FROM admin; GRANT ALL ON SEQUENCE quhead_quhead_id_seq TO admin; GRANT ALL ON SEQUENCE quhead_quhead_id_seq TO xtrole; -- -- Name: quitem_quitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE quitem_quitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE quitem_quitem_id_seq FROM admin; GRANT ALL ON SEQUENCE quitem_quitem_id_seq TO admin; GRANT ALL ON SEQUENCE quitem_quitem_id_seq TO xtrole; -- -- Name: rcalitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE rcalitem FROM PUBLIC; REVOKE ALL ON TABLE rcalitem FROM admin; GRANT ALL ON TABLE rcalitem TO admin; GRANT ALL ON TABLE rcalitem TO xtrole; -- -- Name: recur; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE recur FROM PUBLIC; REVOKE ALL ON TABLE recur FROM admin; GRANT ALL ON TABLE recur TO admin; GRANT ALL ON TABLE recur TO xtrole; -- -- Name: recur_recur_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE recur_recur_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE recur_recur_id_seq FROM admin; GRANT ALL ON SEQUENCE recur_recur_id_seq TO admin; GRANT ALL ON SEQUENCE recur_recur_id_seq TO xtrole; -- -- Name: recurtype; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE recurtype FROM PUBLIC; REVOKE ALL ON TABLE recurtype FROM admin; GRANT ALL ON TABLE recurtype TO admin; GRANT ALL ON TABLE recurtype TO xtrole; -- -- Name: recurtype_recurtype_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE recurtype_recurtype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE recurtype_recurtype_id_seq FROM admin; GRANT ALL ON SEQUENCE recurtype_recurtype_id_seq TO admin; GRANT ALL ON SEQUENCE recurtype_recurtype_id_seq TO xtrole; -- -- Name: recv_recv_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE recv_recv_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE recv_recv_id_seq FROM admin; GRANT ALL ON SEQUENCE recv_recv_id_seq TO admin; GRANT ALL ON SEQUENCE recv_recv_id_seq TO xtrole; -- -- Name: remitto; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE remitto FROM PUBLIC; REVOKE ALL ON TABLE remitto FROM admin; GRANT ALL ON TABLE remitto TO admin; GRANT ALL ON TABLE remitto TO xtrole; -- -- Name: rjctcode; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE rjctcode FROM PUBLIC; REVOKE ALL ON TABLE rjctcode FROM admin; GRANT ALL ON TABLE rjctcode TO admin; GRANT ALL ON TABLE rjctcode TO xtrole; -- -- Name: rjctcode_rjctcode_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE rjctcode_rjctcode_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE rjctcode_rjctcode_id_seq FROM admin; GRANT ALL ON SEQUENCE rjctcode_rjctcode_id_seq TO admin; GRANT ALL ON SEQUENCE rjctcode_rjctcode_id_seq TO xtrole; -- -- Name: rsncode_rsncode_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE rsncode_rsncode_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE rsncode_rsncode_id_seq FROM admin; GRANT ALL ON SEQUENCE rsncode_rsncode_id_seq TO admin; GRANT ALL ON SEQUENCE rsncode_rsncode_id_seq TO xtrole; -- -- Name: sale; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE sale FROM PUBLIC; REVOKE ALL ON TABLE sale FROM admin; GRANT ALL ON TABLE sale TO admin; GRANT ALL ON TABLE sale TO xtrole; -- -- Name: sale_sale_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE sale_sale_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE sale_sale_id_seq FROM admin; GRANT ALL ON SEQUENCE sale_sale_id_seq TO admin; GRANT ALL ON SEQUENCE sale_sale_id_seq TO xtrole; -- -- Name: salesaccnt_salesaccnt_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE salesaccnt_salesaccnt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE salesaccnt_salesaccnt_id_seq FROM admin; GRANT ALL ON SEQUENCE salesaccnt_salesaccnt_id_seq TO admin; GRANT ALL ON SEQUENCE salesaccnt_salesaccnt_id_seq TO xtrole; -- -- Name: salescat_salescat_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE salescat_salescat_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE salescat_salescat_id_seq FROM admin; GRANT ALL ON SEQUENCE salescat_salescat_id_seq TO admin; GRANT ALL ON SEQUENCE salescat_salescat_id_seq TO xtrole; -- -- Name: saleshistory; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE saleshistory FROM PUBLIC; REVOKE ALL ON TABLE saleshistory FROM admin; GRANT ALL ON TABLE saleshistory TO admin; GRANT ALL ON TABLE saleshistory TO xtrole; -- -- Name: saleshistorymisc; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE saleshistorymisc FROM PUBLIC; REVOKE ALL ON TABLE saleshistorymisc FROM admin; GRANT ALL ON TABLE saleshistorymisc TO admin; GRANT ALL ON TABLE saleshistorymisc TO xtrole; -- -- Name: salesrep_salesrep_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE salesrep_salesrep_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE salesrep_salesrep_id_seq FROM admin; GRANT ALL ON SEQUENCE salesrep_salesrep_id_seq TO admin; GRANT ALL ON SEQUENCE salesrep_salesrep_id_seq TO xtrole; -- -- Name: saletype_saletype_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE saletype_saletype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE saletype_saletype_id_seq FROM admin; GRANT ALL ON SEQUENCE saletype_saletype_id_seq TO admin; GRANT ALL ON SEQUENCE saletype_saletype_id_seq TO xtrole; -- -- Name: schemaord; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE schemaord FROM PUBLIC; REVOKE ALL ON TABLE schemaord FROM admin; GRANT ALL ON TABLE schemaord TO admin; GRANT ALL ON TABLE schemaord TO xtrole; -- -- Name: schemaord_schemaord_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE schemaord_schemaord_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE schemaord_schemaord_id_seq FROM admin; GRANT ALL ON SEQUENCE schemaord_schemaord_id_seq TO admin; GRANT ALL ON SEQUENCE schemaord_schemaord_id_seq TO xtrole; -- -- Name: sequence; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE sequence FROM PUBLIC; REVOKE ALL ON TABLE sequence FROM admin; GRANT ALL ON TABLE sequence TO admin; GRANT ALL ON TABLE sequence TO xtrole; -- -- Name: shift_shift_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE shift_shift_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE shift_shift_id_seq FROM admin; GRANT ALL ON SEQUENCE shift_shift_id_seq TO admin; GRANT ALL ON SEQUENCE shift_shift_id_seq TO xtrole; -- -- Name: shipchrg_shipchrg_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE shipchrg_shipchrg_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE shipchrg_shipchrg_id_seq FROM admin; GRANT ALL ON SEQUENCE shipchrg_shipchrg_id_seq TO admin; GRANT ALL ON SEQUENCE shipchrg_shipchrg_id_seq TO xtrole; -- -- Name: shipdatasum; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE shipdatasum FROM PUBLIC; REVOKE ALL ON TABLE shipdatasum FROM admin; GRANT ALL ON TABLE shipdatasum TO admin; GRANT ALL ON TABLE shipdatasum TO xtrole; -- -- Name: shipform_shipform_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE shipform_shipform_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE shipform_shipform_id_seq FROM admin; GRANT ALL ON SEQUENCE shipform_shipform_id_seq TO admin; GRANT ALL ON SEQUENCE shipform_shipform_id_seq TO xtrole; -- -- Name: shiphead_shiphead_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE shiphead_shiphead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE shiphead_shiphead_id_seq FROM admin; GRANT ALL ON SEQUENCE shiphead_shiphead_id_seq TO admin; GRANT ALL ON SEQUENCE shiphead_shiphead_id_seq TO xtrole; -- -- Name: shipitem_shipitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE shipitem_shipitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE shipitem_shipitem_id_seq FROM admin; GRANT ALL ON SEQUENCE shipitem_shipitem_id_seq TO admin; GRANT ALL ON SEQUENCE shipitem_shipitem_id_seq TO xtrole; -- -- Name: shipment_number_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE shipment_number_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE shipment_number_seq FROM admin; GRANT ALL ON SEQUENCE shipment_number_seq TO admin; GRANT ALL ON SEQUENCE shipment_number_seq TO xtrole; -- -- Name: shipto; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE shipto FROM PUBLIC; REVOKE ALL ON TABLE shipto FROM admin; GRANT ALL ON TABLE shipto TO admin; GRANT ALL ON TABLE shipto TO xtrole; -- -- Name: shipto_shipto_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE shipto_shipto_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE shipto_shipto_id_seq FROM admin; GRANT ALL ON SEQUENCE shipto_shipto_id_seq TO admin; GRANT ALL ON SEQUENCE shipto_shipto_id_seq TO xtrole; -- -- Name: shipvia_shipvia_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE shipvia_shipvia_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE shipvia_shipvia_id_seq FROM admin; GRANT ALL ON SEQUENCE shipvia_shipvia_id_seq TO admin; GRANT ALL ON SEQUENCE shipvia_shipvia_id_seq TO xtrole; -- -- Name: shipzone_shipzone_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE shipzone_shipzone_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE shipzone_shipzone_id_seq FROM admin; GRANT ALL ON SEQUENCE shipzone_shipzone_id_seq TO admin; GRANT ALL ON SEQUENCE shipzone_shipzone_id_seq TO xtrole; -- -- Name: sitetype_sitetype_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE sitetype_sitetype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE sitetype_sitetype_id_seq FROM admin; GRANT ALL ON SEQUENCE sitetype_sitetype_id_seq TO admin; GRANT ALL ON SEQUENCE sitetype_sitetype_id_seq TO xtrole; -- -- Name: sltrans; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE sltrans FROM PUBLIC; REVOKE ALL ON TABLE sltrans FROM admin; GRANT ALL ON TABLE sltrans TO admin; GRANT ALL ON TABLE sltrans TO xtrole; -- -- Name: sltrans_backup; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE sltrans_backup FROM PUBLIC; REVOKE ALL ON TABLE sltrans_backup FROM admin; GRANT ALL ON TABLE sltrans_backup TO admin; GRANT ALL ON TABLE sltrans_backup TO xtrole; -- -- Name: sopack; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE sopack FROM PUBLIC; REVOKE ALL ON TABLE sopack FROM admin; GRANT ALL ON TABLE sopack TO admin; GRANT ALL ON TABLE sopack TO xtrole; -- -- Name: sopack_sopack_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE sopack_sopack_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE sopack_sopack_id_seq FROM admin; GRANT ALL ON SEQUENCE sopack_sopack_id_seq TO admin; GRANT ALL ON SEQUENCE sopack_sopack_id_seq TO xtrole; -- -- Name: source; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE source FROM PUBLIC; REVOKE ALL ON TABLE source FROM admin; GRANT ALL ON TABLE source TO admin; GRANT ALL ON TABLE source TO xtrole; -- -- Name: source_source_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE source_source_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE source_source_id_seq FROM admin; GRANT ALL ON SEQUENCE source_source_id_seq TO admin; GRANT ALL ON SEQUENCE source_source_id_seq TO xtrole; -- -- Name: state; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE state FROM PUBLIC; REVOKE ALL ON TABLE state FROM admin; GRANT ALL ON TABLE state TO admin; GRANT ALL ON TABLE state TO xtrole; -- -- Name: state_state_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE state_state_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE state_state_id_seq FROM admin; GRANT ALL ON SEQUENCE state_state_id_seq TO admin; GRANT ALL ON SEQUENCE state_state_id_seq TO xtrole; -- -- Name: status; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE status FROM PUBLIC; REVOKE ALL ON TABLE status FROM admin; GRANT ALL ON TABLE status TO admin; GRANT ALL ON TABLE status TO xtrole; -- -- Name: status_status_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE status_status_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE status_status_id_seq FROM admin; GRANT ALL ON SEQUENCE status_status_id_seq TO admin; GRANT ALL ON SEQUENCE status_status_id_seq TO xtrole; -- -- Name: stdjrnl; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE stdjrnl FROM PUBLIC; REVOKE ALL ON TABLE stdjrnl FROM admin; GRANT ALL ON TABLE stdjrnl TO admin; GRANT ALL ON TABLE stdjrnl TO xtrole; -- -- Name: stdjrnl_stdjrnl_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE stdjrnl_stdjrnl_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE stdjrnl_stdjrnl_id_seq FROM admin; GRANT ALL ON SEQUENCE stdjrnl_stdjrnl_id_seq TO admin; GRANT ALL ON SEQUENCE stdjrnl_stdjrnl_id_seq TO xtrole; -- -- Name: stdjrnlgrp; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE stdjrnlgrp FROM PUBLIC; REVOKE ALL ON TABLE stdjrnlgrp FROM admin; GRANT ALL ON TABLE stdjrnlgrp TO admin; GRANT ALL ON TABLE stdjrnlgrp TO xtrole; -- -- Name: stdjrnlgrp_stdjrnlgrp_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE stdjrnlgrp_stdjrnlgrp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE stdjrnlgrp_stdjrnlgrp_id_seq FROM admin; GRANT ALL ON SEQUENCE stdjrnlgrp_stdjrnlgrp_id_seq TO admin; GRANT ALL ON SEQUENCE stdjrnlgrp_stdjrnlgrp_id_seq TO xtrole; -- -- Name: stdjrnlgrpitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE stdjrnlgrpitem FROM PUBLIC; REVOKE ALL ON TABLE stdjrnlgrpitem FROM admin; GRANT ALL ON TABLE stdjrnlgrpitem TO admin; GRANT ALL ON TABLE stdjrnlgrpitem TO xtrole; -- -- Name: stdjrnlgrpitem_stdjrnlgrpitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE stdjrnlgrpitem_stdjrnlgrpitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE stdjrnlgrpitem_stdjrnlgrpitem_id_seq FROM admin; GRANT ALL ON SEQUENCE stdjrnlgrpitem_stdjrnlgrpitem_id_seq TO admin; GRANT ALL ON SEQUENCE stdjrnlgrpitem_stdjrnlgrpitem_id_seq TO xtrole; -- -- Name: stdjrnlitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE stdjrnlitem FROM PUBLIC; REVOKE ALL ON TABLE stdjrnlitem FROM admin; GRANT ALL ON TABLE stdjrnlitem TO admin; GRANT ALL ON TABLE stdjrnlitem TO xtrole; -- -- Name: stdjrnlitem_stdjrnlitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE stdjrnlitem_stdjrnlitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE stdjrnlitem_stdjrnlitem_id_seq FROM admin; GRANT ALL ON SEQUENCE stdjrnlitem_stdjrnlitem_id_seq TO admin; GRANT ALL ON SEQUENCE stdjrnlitem_stdjrnlitem_id_seq TO xtrole; -- -- Name: subaccnt; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE subaccnt FROM PUBLIC; REVOKE ALL ON TABLE subaccnt FROM admin; GRANT ALL ON TABLE subaccnt TO admin; GRANT ALL ON TABLE subaccnt TO xtrole; -- -- Name: subaccnt_subaccnt_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE subaccnt_subaccnt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE subaccnt_subaccnt_id_seq FROM admin; GRANT ALL ON SEQUENCE subaccnt_subaccnt_id_seq TO admin; GRANT ALL ON SEQUENCE subaccnt_subaccnt_id_seq TO xtrole; -- -- Name: subaccnttype; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE subaccnttype FROM PUBLIC; REVOKE ALL ON TABLE subaccnttype FROM admin; GRANT ALL ON TABLE subaccnttype TO admin; GRANT ALL ON TABLE subaccnttype TO xtrole; -- -- Name: subaccnttype_subaccnttype_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE subaccnttype_subaccnttype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE subaccnttype_subaccnttype_id_seq FROM admin; GRANT ALL ON SEQUENCE subaccnttype_subaccnttype_id_seq TO admin; GRANT ALL ON SEQUENCE subaccnttype_subaccnttype_id_seq TO xtrole; -- -- Name: tax_tax_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE tax_tax_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE tax_tax_id_seq FROM admin; GRANT ALL ON SEQUENCE tax_tax_id_seq TO admin; GRANT ALL ON SEQUENCE tax_tax_id_seq TO xtrole; -- -- Name: taxass; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE taxass FROM PUBLIC; REVOKE ALL ON TABLE taxass FROM admin; GRANT ALL ON TABLE taxass TO admin; GRANT ALL ON TABLE taxass TO xtrole; -- -- Name: taxass_taxass_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE taxass_taxass_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE taxass_taxass_id_seq FROM admin; GRANT ALL ON SEQUENCE taxass_taxass_id_seq TO admin; GRANT ALL ON SEQUENCE taxass_taxass_id_seq TO xtrole; -- -- Name: taxauth_taxauth_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE taxauth_taxauth_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE taxauth_taxauth_id_seq FROM admin; GRANT ALL ON SEQUENCE taxauth_taxauth_id_seq TO admin; GRANT ALL ON SEQUENCE taxauth_taxauth_id_seq TO xtrole; -- -- Name: taxclass; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE taxclass FROM PUBLIC; REVOKE ALL ON TABLE taxclass FROM admin; GRANT ALL ON TABLE taxclass TO admin; GRANT ALL ON TABLE taxclass TO xtrole; -- -- Name: taxclass_taxclass_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE taxclass_taxclass_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE taxclass_taxclass_id_seq FROM admin; GRANT ALL ON SEQUENCE taxclass_taxclass_id_seq TO admin; GRANT ALL ON SEQUENCE taxclass_taxclass_id_seq TO xtrole; -- -- Name: taxhist_taxhist_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE taxhist_taxhist_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE taxhist_taxhist_id_seq FROM admin; GRANT ALL ON SEQUENCE taxhist_taxhist_id_seq TO admin; GRANT ALL ON SEQUENCE taxhist_taxhist_id_seq TO xtrole; -- -- Name: taxpay; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE taxpay FROM PUBLIC; REVOKE ALL ON TABLE taxpay FROM admin; GRANT ALL ON TABLE taxpay TO admin; GRANT ALL ON TABLE taxpay TO xtrole; -- -- Name: taxpay_taxpay_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE taxpay_taxpay_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE taxpay_taxpay_id_seq FROM admin; GRANT ALL ON SEQUENCE taxpay_taxpay_id_seq TO admin; GRANT ALL ON SEQUENCE taxpay_taxpay_id_seq TO xtrole; -- -- Name: taxrate; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE taxrate FROM PUBLIC; REVOKE ALL ON TABLE taxrate FROM admin; GRANT ALL ON TABLE taxrate TO admin; GRANT ALL ON TABLE taxrate TO xtrole; -- -- Name: taxrate_taxrate_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE taxrate_taxrate_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE taxrate_taxrate_id_seq FROM admin; GRANT ALL ON SEQUENCE taxrate_taxrate_id_seq TO admin; GRANT ALL ON SEQUENCE taxrate_taxrate_id_seq TO xtrole; -- -- Name: taxreg_taxreg_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE taxreg_taxreg_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE taxreg_taxreg_id_seq FROM admin; GRANT ALL ON SEQUENCE taxreg_taxreg_id_seq TO admin; GRANT ALL ON SEQUENCE taxreg_taxreg_id_seq TO xtrole; -- -- Name: taxtype_taxtype_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE taxtype_taxtype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE taxtype_taxtype_id_seq FROM admin; GRANT ALL ON SEQUENCE taxtype_taxtype_id_seq TO admin; GRANT ALL ON SEQUENCE taxtype_taxtype_id_seq TO xtrole; -- -- Name: taxzone_taxzone_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE taxzone_taxzone_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE taxzone_taxzone_id_seq FROM admin; GRANT ALL ON SEQUENCE taxzone_taxzone_id_seq TO admin; GRANT ALL ON SEQUENCE taxzone_taxzone_id_seq TO xtrole; -- -- Name: terms_terms_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE terms_terms_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE terms_terms_id_seq FROM admin; GRANT ALL ON SEQUENCE terms_terms_id_seq TO admin; GRANT ALL ON SEQUENCE terms_terms_id_seq TO xtrole; -- -- Name: todoitem_todoitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE todoitem_todoitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE todoitem_todoitem_id_seq FROM admin; GRANT ALL ON SEQUENCE todoitem_todoitem_id_seq TO admin; GRANT ALL ON SEQUENCE todoitem_todoitem_id_seq TO xtrole; -- -- Name: trgthist; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE trgthist FROM PUBLIC; REVOKE ALL ON TABLE trgthist FROM admin; GRANT ALL ON TABLE trgthist TO admin; GRANT ALL ON TABLE trgthist TO xtrole; -- -- Name: trialbal; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE trialbal FROM PUBLIC; REVOKE ALL ON TABLE trialbal FROM admin; GRANT ALL ON TABLE trialbal TO admin; GRANT ALL ON TABLE trialbal TO xtrole; -- -- Name: trialbal_trialbal_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE trialbal_trialbal_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE trialbal_trialbal_id_seq FROM admin; GRANT ALL ON SEQUENCE trialbal_trialbal_id_seq TO admin; GRANT ALL ON SEQUENCE trialbal_trialbal_id_seq TO xtrole; -- -- Name: uom_uom_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE uom_uom_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE uom_uom_id_seq FROM admin; GRANT ALL ON SEQUENCE uom_uom_id_seq TO admin; GRANT ALL ON SEQUENCE uom_uom_id_seq TO xtrole; -- -- Name: uomconv; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE uomconv FROM PUBLIC; REVOKE ALL ON TABLE uomconv FROM admin; GRANT ALL ON TABLE uomconv TO admin; GRANT ALL ON TABLE uomconv TO xtrole; -- -- Name: uomconv_uomconv_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE uomconv_uomconv_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE uomconv_uomconv_id_seq FROM admin; GRANT ALL ON SEQUENCE uomconv_uomconv_id_seq TO admin; GRANT ALL ON SEQUENCE uomconv_uomconv_id_seq TO xtrole; -- -- Name: uomtype; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE uomtype FROM PUBLIC; REVOKE ALL ON TABLE uomtype FROM admin; GRANT ALL ON TABLE uomtype TO admin; GRANT ALL ON TABLE uomtype TO xtrole; -- -- Name: uomtype_uomtype_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE uomtype_uomtype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE uomtype_uomtype_id_seq FROM admin; GRANT ALL ON SEQUENCE uomtype_uomtype_id_seq TO admin; GRANT ALL ON SEQUENCE uomtype_uomtype_id_seq TO xtrole; -- -- Name: urlinfo_url_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE urlinfo_url_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE urlinfo_url_id_seq FROM admin; GRANT ALL ON SEQUENCE urlinfo_url_id_seq TO admin; GRANT ALL ON SEQUENCE urlinfo_url_id_seq TO xtrole; -- -- Name: usrpref; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE usrpref FROM PUBLIC; REVOKE ALL ON TABLE usrpref FROM admin; GRANT ALL ON TABLE usrpref TO admin; GRANT ALL ON TABLE usrpref TO xtrole; -- -- Name: usr; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE usr FROM PUBLIC; REVOKE ALL ON TABLE usr FROM admin; GRANT ALL ON TABLE usr TO admin; GRANT ALL ON TABLE usr TO xtrole; -- -- Name: usr_bak; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE usr_bak FROM PUBLIC; REVOKE ALL ON TABLE usr_bak FROM admin; GRANT ALL ON TABLE usr_bak TO admin; GRANT ALL ON TABLE usr_bak TO xtrole; -- -- Name: usr_usr_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE usr_usr_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE usr_usr_id_seq FROM admin; GRANT ALL ON SEQUENCE usr_usr_id_seq TO admin; GRANT ALL ON SEQUENCE usr_usr_id_seq TO xtrole; -- -- Name: usrgrp_usrgrp_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE usrgrp_usrgrp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE usrgrp_usrgrp_id_seq FROM admin; GRANT ALL ON SEQUENCE usrgrp_usrgrp_id_seq TO admin; GRANT ALL ON SEQUENCE usrgrp_usrgrp_id_seq TO xtrole; -- -- Name: usrpref_usrpref_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE usrpref_usrpref_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE usrpref_usrpref_id_seq FROM admin; GRANT ALL ON SEQUENCE usrpref_usrpref_id_seq TO admin; GRANT ALL ON SEQUENCE usrpref_usrpref_id_seq TO xtrole; -- -- Name: usrpriv_usrpriv_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE usrpriv_usrpriv_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE usrpriv_usrpriv_id_seq FROM admin; GRANT ALL ON SEQUENCE usrpriv_usrpriv_id_seq TO admin; GRANT ALL ON SEQUENCE usrpriv_usrpriv_id_seq TO xtrole; -- -- Name: vend; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE vend FROM PUBLIC; REVOKE ALL ON TABLE vend FROM admin; GRANT ALL ON TABLE vend TO admin; GRANT ALL ON TABLE vend TO xtrole; -- -- Name: vend_vend_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE vend_vend_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE vend_vend_id_seq FROM admin; GRANT ALL ON SEQUENCE vend_vend_id_seq TO admin; GRANT ALL ON SEQUENCE vend_vend_id_seq TO xtrole; -- -- Name: vendaddr; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE vendaddr FROM PUBLIC; REVOKE ALL ON TABLE vendaddr FROM admin; GRANT ALL ON TABLE vendaddr TO admin; GRANT ALL ON TABLE vendaddr TO xtrole; -- -- Name: vendaddr_vendaddr_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE vendaddr_vendaddr_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE vendaddr_vendaddr_id_seq FROM admin; GRANT ALL ON SEQUENCE vendaddr_vendaddr_id_seq TO admin; GRANT ALL ON SEQUENCE vendaddr_vendaddr_id_seq TO xtrole; -- -- Name: vendtype_vendtype_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE vendtype_vendtype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE vendtype_vendtype_id_seq FROM admin; GRANT ALL ON SEQUENCE vendtype_vendtype_id_seq TO admin; GRANT ALL ON SEQUENCE vendtype_vendtype_id_seq TO xtrole; -- -- Name: vodist; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE vodist FROM PUBLIC; REVOKE ALL ON TABLE vodist FROM admin; GRANT ALL ON TABLE vodist TO admin; GRANT ALL ON TABLE vodist TO xtrole; -- -- Name: vodist_vodist_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE vodist_vodist_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE vodist_vodist_id_seq FROM admin; GRANT ALL ON SEQUENCE vodist_vodist_id_seq TO admin; GRANT ALL ON SEQUENCE vodist_vodist_id_seq TO xtrole; -- -- Name: vohead; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE vohead FROM PUBLIC; REVOKE ALL ON TABLE vohead FROM admin; GRANT ALL ON TABLE vohead TO admin; GRANT ALL ON TABLE vohead TO xtrole; -- -- Name: vohead_vohead_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE vohead_vohead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE vohead_vohead_id_seq FROM admin; GRANT ALL ON SEQUENCE vohead_vohead_id_seq TO admin; GRANT ALL ON SEQUENCE vohead_vohead_id_seq TO xtrole; -- -- Name: voheadtax; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE voheadtax FROM PUBLIC; REVOKE ALL ON TABLE voheadtax FROM admin; GRANT ALL ON TABLE voheadtax TO admin; GRANT ALL ON TABLE voheadtax TO xtrole; -- -- Name: voitem; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE voitem FROM PUBLIC; REVOKE ALL ON TABLE voitem FROM admin; GRANT ALL ON TABLE voitem TO admin; GRANT ALL ON TABLE voitem TO xtrole; -- -- Name: voitem_voitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE voitem_voitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE voitem_voitem_id_seq FROM admin; GRANT ALL ON SEQUENCE voitem_voitem_id_seq TO admin; GRANT ALL ON SEQUENCE voitem_voitem_id_seq TO xtrole; -- -- Name: voitemtax; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE voitemtax FROM PUBLIC; REVOKE ALL ON TABLE voitemtax FROM admin; GRANT ALL ON TABLE voitemtax TO admin; GRANT ALL ON TABLE voitemtax TO xtrole; -- -- Name: warehous; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE warehous FROM PUBLIC; REVOKE ALL ON TABLE warehous FROM admin; GRANT ALL ON TABLE warehous TO admin; GRANT ALL ON TABLE warehous TO xtrole; -- -- Name: warehous_warehous_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE warehous_warehous_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE warehous_warehous_id_seq FROM admin; GRANT ALL ON SEQUENCE warehous_warehous_id_seq TO admin; GRANT ALL ON SEQUENCE warehous_warehous_id_seq TO xtrole; -- -- Name: whsezone_whsezone_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE whsezone_whsezone_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE whsezone_whsezone_id_seq FROM admin; GRANT ALL ON SEQUENCE whsezone_whsezone_id_seq TO admin; GRANT ALL ON SEQUENCE whsezone_whsezone_id_seq TO xtrole; -- -- Name: wo; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE wo FROM PUBLIC; REVOKE ALL ON TABLE wo FROM admin; GRANT ALL ON TABLE wo TO admin; GRANT ALL ON TABLE wo TO xtrole; -- -- Name: wo_wo_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE wo_wo_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE wo_wo_id_seq FROM admin; GRANT ALL ON SEQUENCE wo_wo_id_seq TO admin; GRANT ALL ON SEQUENCE wo_wo_id_seq TO xtrole; -- -- Name: womatl_womatl_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE womatl_womatl_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE womatl_womatl_id_seq FROM admin; GRANT ALL ON SEQUENCE womatl_womatl_id_seq TO admin; GRANT ALL ON SEQUENCE womatl_womatl_id_seq TO xtrole; -- -- Name: womatlpost; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE womatlpost FROM PUBLIC; REVOKE ALL ON TABLE womatlpost FROM admin; GRANT ALL ON TABLE womatlpost TO admin; GRANT ALL ON TABLE womatlpost TO xtrole; -- -- Name: womatlpost_womatlpost_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE womatlpost_womatlpost_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE womatlpost_womatlpost_id_seq FROM admin; GRANT ALL ON SEQUENCE womatlpost_womatlpost_id_seq TO admin; GRANT ALL ON SEQUENCE womatlpost_womatlpost_id_seq TO xtrole; -- -- Name: womatlvar; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE womatlvar FROM PUBLIC; REVOKE ALL ON TABLE womatlvar FROM admin; GRANT ALL ON TABLE womatlvar TO admin; GRANT ALL ON TABLE womatlvar TO xtrole; -- -- Name: womatlvar_womatlvar_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE womatlvar_womatlvar_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE womatlvar_womatlvar_id_seq FROM admin; GRANT ALL ON SEQUENCE womatlvar_womatlvar_id_seq TO admin; GRANT ALL ON SEQUENCE womatlvar_womatlvar_id_seq TO xtrole; -- -- Name: xcalitem_xcalitem_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE xcalitem_xcalitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE xcalitem_xcalitem_id_seq FROM admin; GRANT ALL ON SEQUENCE xcalitem_xcalitem_id_seq TO admin; GRANT ALL ON SEQUENCE xcalitem_xcalitem_id_seq TO xtrole; -- -- Name: xsltmap; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE xsltmap FROM PUBLIC; REVOKE ALL ON TABLE xsltmap FROM admin; GRANT ALL ON TABLE xsltmap TO admin; GRANT ALL ON TABLE xsltmap TO xtrole; -- -- Name: xsltmap_xsltmap_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE xsltmap_xsltmap_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE xsltmap_xsltmap_id_seq FROM admin; GRANT ALL ON SEQUENCE xsltmap_xsltmap_id_seq TO admin; GRANT ALL ON SEQUENCE xsltmap_xsltmap_id_seq TO xtrole; -- -- Name: yearperiod; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON TABLE yearperiod FROM PUBLIC; REVOKE ALL ON TABLE yearperiod FROM admin; GRANT ALL ON TABLE yearperiod TO admin; GRANT ALL ON TABLE yearperiod TO xtrole; -- -- Name: yearperiod_yearperiod_id_seq; Type: ACL; Schema: public; Owner: admin -- REVOKE ALL ON SEQUENCE yearperiod_yearperiod_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE yearperiod_yearperiod_id_seq FROM admin; GRANT ALL ON SEQUENCE yearperiod_yearperiod_id_seq TO admin; GRANT ALL ON SEQUENCE yearperiod_yearperiod_id_seq TO xtrole; SET search_path = te, pg_catalog; -- -- Name: pkgcmd; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON TABLE pkgcmd FROM PUBLIC; REVOKE ALL ON TABLE pkgcmd FROM admin; GRANT ALL ON TABLE pkgcmd TO admin; GRANT ALL ON TABLE pkgcmd TO xtrole; -- -- Name: pkgcmdarg; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON TABLE pkgcmdarg FROM PUBLIC; REVOKE ALL ON TABLE pkgcmdarg FROM admin; GRANT ALL ON TABLE pkgcmdarg TO admin; GRANT ALL ON TABLE pkgcmdarg TO xtrole; -- -- Name: pkgimage; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON TABLE pkgimage FROM PUBLIC; REVOKE ALL ON TABLE pkgimage FROM admin; GRANT ALL ON TABLE pkgimage TO admin; GRANT ALL ON TABLE pkgimage TO xtrole; -- -- Name: pkgmetasql; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON TABLE pkgmetasql FROM PUBLIC; REVOKE ALL ON TABLE pkgmetasql FROM admin; GRANT ALL ON TABLE pkgmetasql TO admin; GRANT ALL ON TABLE pkgmetasql TO xtrole; -- -- Name: pkgpriv; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON TABLE pkgpriv FROM PUBLIC; REVOKE ALL ON TABLE pkgpriv FROM admin; GRANT ALL ON TABLE pkgpriv TO admin; GRANT ALL ON TABLE pkgpriv TO xtrole; -- -- Name: pkgreport; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON TABLE pkgreport FROM PUBLIC; REVOKE ALL ON TABLE pkgreport FROM admin; GRANT ALL ON TABLE pkgreport TO admin; GRANT ALL ON TABLE pkgreport TO xtrole; -- -- Name: pkgscript; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON TABLE pkgscript FROM PUBLIC; REVOKE ALL ON TABLE pkgscript FROM admin; GRANT ALL ON TABLE pkgscript TO admin; GRANT ALL ON TABLE pkgscript TO xtrole; -- -- Name: pkguiform; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON TABLE pkguiform FROM PUBLIC; REVOKE ALL ON TABLE pkguiform FROM admin; GRANT ALL ON TABLE pkguiform TO admin; GRANT ALL ON TABLE pkguiform TO xtrole; -- -- Name: tecustrate; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON TABLE tecustrate FROM PUBLIC; REVOKE ALL ON TABLE tecustrate FROM admin; GRANT ALL ON TABLE tecustrate TO admin; GRANT ALL ON TABLE tecustrate TO xtrole; -- -- Name: tecustrate_tecustrate_id_seq; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON SEQUENCE tecustrate_tecustrate_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE tecustrate_tecustrate_id_seq FROM admin; GRANT ALL ON SEQUENCE tecustrate_tecustrate_id_seq TO admin; GRANT ALL ON SEQUENCE tecustrate_tecustrate_id_seq TO xtrole; -- -- Name: teemp; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON TABLE teemp FROM PUBLIC; REVOKE ALL ON TABLE teemp FROM admin; GRANT ALL ON TABLE teemp TO admin; GRANT ALL ON TABLE teemp TO xtrole; -- -- Name: teemp_teemp_id_seq; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON SEQUENCE teemp_teemp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE teemp_teemp_id_seq FROM admin; GRANT ALL ON SEQUENCE teemp_teemp_id_seq TO admin; GRANT ALL ON SEQUENCE teemp_teemp_id_seq TO xtrole; -- -- Name: teexp; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON TABLE teexp FROM PUBLIC; REVOKE ALL ON TABLE teexp FROM admin; GRANT ALL ON TABLE teexp TO admin; GRANT ALL ON TABLE teexp TO xtrole; -- -- Name: timesheet_seq; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON SEQUENCE timesheet_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE timesheet_seq FROM admin; GRANT ALL ON SEQUENCE timesheet_seq TO admin; GRANT ALL ON SEQUENCE timesheet_seq TO xtrole; -- -- Name: tehead; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON TABLE tehead FROM PUBLIC; REVOKE ALL ON TABLE tehead FROM admin; GRANT ALL ON TABLE tehead TO admin; GRANT ALL ON TABLE tehead TO xtrole; -- -- Name: tehead_tehead_id_seq; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON SEQUENCE tehead_tehead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE tehead_tehead_id_seq FROM admin; GRANT ALL ON SEQUENCE tehead_tehead_id_seq TO admin; GRANT ALL ON SEQUENCE tehead_tehead_id_seq TO xtrole; -- -- Name: teitem; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON TABLE teitem FROM PUBLIC; REVOKE ALL ON TABLE teitem FROM admin; GRANT ALL ON TABLE teitem TO admin; GRANT ALL ON TABLE teitem TO xtrole; -- -- Name: teitem_teitem_id_seq; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON SEQUENCE teitem_teitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE teitem_teitem_id_seq FROM admin; GRANT ALL ON SEQUENCE teitem_teitem_id_seq TO admin; GRANT ALL ON SEQUENCE teitem_teitem_id_seq TO xtrole; -- -- Name: teprj; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON TABLE teprj FROM PUBLIC; REVOKE ALL ON TABLE teprj FROM admin; GRANT ALL ON TABLE teprj TO admin; GRANT ALL ON TABLE teprj TO xtrole; -- -- Name: teprj_teprj_id_seq; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON SEQUENCE teprj_teprj_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE teprj_teprj_id_seq FROM admin; GRANT ALL ON SEQUENCE teprj_teprj_id_seq TO admin; GRANT ALL ON SEQUENCE teprj_teprj_id_seq TO xtrole; -- -- Name: teprjtask; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON TABLE teprjtask FROM PUBLIC; REVOKE ALL ON TABLE teprjtask FROM admin; GRANT ALL ON TABLE teprjtask TO admin; GRANT ALL ON TABLE teprjtask TO xtrole; -- -- Name: teprjtask_teprjtask_id_seq; Type: ACL; Schema: te; Owner: admin -- REVOKE ALL ON SEQUENCE teprjtask_teprjtask_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE teprjtask_teprjtask_id_seq FROM admin; GRANT ALL ON SEQUENCE teprjtask_teprjtask_id_seq TO admin; GRANT ALL ON SEQUENCE teprjtask_teprjtask_id_seq TO xtrole; SET search_path = xt, pg_catalog; -- -- Name: js; Type: ACL; Schema: xt; Owner: admin -- REVOKE ALL ON TABLE js FROM PUBLIC; REVOKE ALL ON TABLE js FROM admin; GRANT ALL ON TABLE js TO admin; GRANT ALL ON TABLE js TO xtrole; SET search_path = xtdesktop, pg_catalog; -- -- Name: pkgcmd; Type: ACL; Schema: xtdesktop; Owner: admin -- REVOKE ALL ON TABLE pkgcmd FROM PUBLIC; REVOKE ALL ON TABLE pkgcmd FROM admin; GRANT ALL ON TABLE pkgcmd TO admin; GRANT ALL ON TABLE pkgcmd TO xtrole; -- -- Name: pkgcmdarg; Type: ACL; Schema: xtdesktop; Owner: admin -- REVOKE ALL ON TABLE pkgcmdarg FROM PUBLIC; REVOKE ALL ON TABLE pkgcmdarg FROM admin; GRANT ALL ON TABLE pkgcmdarg TO admin; GRANT ALL ON TABLE pkgcmdarg TO xtrole; -- -- Name: pkgimage; Type: ACL; Schema: xtdesktop; Owner: admin -- REVOKE ALL ON TABLE pkgimage FROM PUBLIC; REVOKE ALL ON TABLE pkgimage FROM admin; GRANT ALL ON TABLE pkgimage TO admin; GRANT ALL ON TABLE pkgimage TO xtrole; -- -- Name: pkgmetasql; Type: ACL; Schema: xtdesktop; Owner: admin -- REVOKE ALL ON TABLE pkgmetasql FROM PUBLIC; REVOKE ALL ON TABLE pkgmetasql FROM admin; GRANT ALL ON TABLE pkgmetasql TO admin; GRANT ALL ON TABLE pkgmetasql TO xtrole; -- -- Name: pkgpriv; Type: ACL; Schema: xtdesktop; Owner: admin -- REVOKE ALL ON TABLE pkgpriv FROM PUBLIC; REVOKE ALL ON TABLE pkgpriv FROM admin; GRANT ALL ON TABLE pkgpriv TO admin; GRANT ALL ON TABLE pkgpriv TO xtrole; -- -- Name: pkgreport; Type: ACL; Schema: xtdesktop; Owner: admin -- REVOKE ALL ON TABLE pkgreport FROM PUBLIC; REVOKE ALL ON TABLE pkgreport FROM admin; GRANT ALL ON TABLE pkgreport TO admin; GRANT ALL ON TABLE pkgreport TO xtrole; -- -- Name: pkgscript; Type: ACL; Schema: xtdesktop; Owner: admin -- REVOKE ALL ON TABLE pkgscript FROM PUBLIC; REVOKE ALL ON TABLE pkgscript FROM admin; GRANT ALL ON TABLE pkgscript TO admin; GRANT ALL ON TABLE pkgscript TO xtrole; -- -- Name: pkguiform; Type: ACL; Schema: xtdesktop; Owner: admin -- REVOKE ALL ON TABLE pkguiform FROM PUBLIC; REVOKE ALL ON TABLE pkguiform FROM admin; GRANT ALL ON TABLE pkguiform TO admin; GRANT ALL ON TABLE pkguiform TO xtrole; -- -- PostgreSQL database dump complete -- postbooks-schema-quickstart-4.9.2/postbooks_quickstart-4.9.2.backup0000644000175000017500002607554112603675632024643 0ustar danieldanielPGDMP ,/ s quickstart9.1.189.1.18%00ENCODINGENCODINGSET client_encoding = 'UTF8'; false%00 STDSTRINGS STDSTRINGS(SET standard_conforming_strings = 'on'; false%126277485 quickstartDATABASEzCREATE DATABASE quickstart WITH TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'en_US.utf8' LC_CTYPE = 'en_US.utf8'; DROP DATABASE quickstart; adminfalse261577489apiSCHEMACREATE SCHEMA api; DROP SCHEMA api; adminfalse%00apiACLREVOKE ALL ON SCHEMA api FROM PUBLIC; REVOKE ALL ON SCHEMA api FROM admin; GRANT ALL ON SCHEMA api TO admin; GRANT ALL ON SCHEMA api TO xtrole; adminfalse6261577490 fixcountrySCHEMACREATE SCHEMA fixcountry; DROP SCHEMA fixcountry; adminfalse%00SCHEMA fixcountryCOMMENTICOMMENT ON SCHEMA fixcountry IS 'Schema to hold contents of fixcountry'; adminfalse7%00 fixcountryACLREVOKE ALL ON SCHEMA fixcountry FROM PUBLIC; REVOKE ALL ON SCHEMA fixcountry FROM admin; GRANT ALL ON SCHEMA fixcountry TO admin; GRANT ALL ON SCHEMA fixcountry TO xtrole; adminfalse726152200publicSCHEMACREATE SCHEMA public; DROP SCHEMA public; postgresfalse%00 SCHEMA publicCOMMENT6COMMENT ON SCHEMA public IS 'standard public schema'; postgresfalse8%00publicACLREVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC; postgresfalse8 261577491teSCHEMACREATE SCHEMA te; DROP SCHEMA te; adminfalse%00 SCHEMA teCOMMENTCOMMENT ON SCHEMA te IS 'Time and Expense system add-on package for xTuple ERP. This file is part of the xtte package for xTuple ERP: PostBooks Edition, a free and open source Enterprise Resource Planning software suite, Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. It is licensed to you under the Common Public Attribution License version 1.0, the full text of which (including xTuple-specific Exhibits) is available at www.xtuple.com/CPAL. By using this software, you agree to be bound by its terms.'; adminfalse9%00teACLREVOKE ALL ON SCHEMA te FROM PUBLIC; REVOKE ALL ON SCHEMA te FROM admin; GRANT ALL ON SCHEMA te TO admin; GRANT ALL ON SCHEMA te TO xtrole; adminfalse9 261586811xtSCHEMACREATE SCHEMA xt; DROP SCHEMA xt; adminfalse%00xtACLREVOKE ALL ON SCHEMA xt FROM PUBLIC; REVOKE ALL ON SCHEMA xt FROM admin; GRANT ALL ON SCHEMA xt TO admin; GRANT ALL ON SCHEMA xt TO xtrole; adminfalse11 261577492 xtdesktopSCHEMACREATE SCHEMA xtdesktop; DROP SCHEMA xtdesktop; adminfalse%00SCHEMA xtdesktopCOMMENTGCOMMENT ON SCHEMA xtdesktop IS 'Schema to hold contents of xtdesktop'; adminfalse10%00 xtdesktopACLREVOKE ALL ON SCHEMA xtdesktop FROM PUBLIC; REVOKE ALL ON SCHEMA xtdesktop FROM admin; GRANT ALL ON SCHEMA xtdesktop TO admin; GRANT ALL ON SCHEMA xtdesktop TO xtrole; adminfalse10307911645plpgsql EXTENSION?CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; DROP EXTENSION plpgsql; false%00EXTENSION plpgsqlCOMMENT@COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; false899307986852plv8 EXTENSION<CREATE EXTENSION IF NOT EXISTS plv8 WITH SCHEMA pg_catalog; DROP EXTENSION plv8; false%00EXTENSION plv8COMMENTOCOMMENT ON EXTENSION plv8 IS 'PL/JavaScript (v8) trusted procedural language'; false898124786914_docinfoTYPECREATE TYPE _docinfo AS ( id integer, target_number text, target_type text, target_id integer, source_type text, source_id integer, name text, description text, purpose text ); DROP TYPE public._docinfo; publicadminfalse8765124786917achlineTYPExCREATE TYPE achline AS ( achline_checkhead_id integer, achline_batch text, achline_type text, achline_value text ); DROP TYPE public.achline; publicadminfalse8766124786920apagingTYPECREATE TYPE apaging AS ( apaging_docdate text, apaging_duedate date, apaging_ponumber text, apaging_reference text, apaging_invcnumber text, apaging_docnumber text, apaging_doctype text, apaging_vend_id integer, apaging_vend_number text, apaging_vend_name text, apaging_vend_vendtype_id integer, apaging_vendtype_code text, apaging_terms_descrip text, apaging_apopen_amount numeric, apaging_cur_val numeric, apaging_thirty_val numeric, apaging_sixty_val numeric, apaging_ninety_val numeric, apaging_plus_val numeric, apaging_total_val numeric, apaging_discdate date, apaging_disc_val numeric, apaging_discdays numeric, apaging_discprcnt numeric ); DROP TYPE public.apaging; publicadminfalse8767124786923aragingTYPECREATE TYPE araging AS ( araging_docdate date, araging_duedate date, araging_ponumber text, araging_docnumber text, araging_doctype text, araging_cust_id integer, araging_cust_number text, araging_cust_name text, araging_cust_custtype_id integer, araging_custtype_code text, araging_terms_descrip text, araging_aropen_amount numeric, araging_cur_val numeric, araging_thirty_val numeric, araging_sixty_val numeric, araging_ninety_val numeric, araging_plus_val numeric, araging_total_val numeric ); DROP TYPE public.araging; publicadminfalse8768124786926bomdataTYPEhCREATE TYPE bomdata AS ( bomdata_bomwork_id integer, bomdata_bomwork_parent_id integer, bomdata_bomwork_level integer, bomdata_bomwork_seqnumber integer, bomdata_bomitem_id integer, bomdata_item_id integer, bomdata_item_number text, bomdata_uom_name text, bomdata_item_descrip1 text, bomdata_item_descrip2 text, bomdata_itemdescription text, bomdata_batchsize numeric, bomdata_qtyfxd numeric, bomdata_qtyper numeric, bomdata_qtyreq numeric, bomdata_scrap numeric, bomdata_createchild boolean, bomdata_issuemethod text, bomdata_effective date, bomdata_expires date, bomdata_expired boolean, bomdata_future boolean, bomdata_actunitcost numeric, bomdata_stdunitcost numeric, bomdata_actextendedcost numeric, bomdata_stdextendedcost numeric, bomdata_ecn text, bomdata_char_id integer, bomdata_value text, bomdata_notes text, bomdata_ref text ); DROP TYPE public.bomdata; publicadminfalse8769 124777507 checkdataTYPECREATE TYPE checkdata AS ( checkdata_page integer, checkdata_checknumber text, checkdata_checkwords text, checkdata_checkdate text, checkdata_checkamount text, checkdata_checkcurrsymbol text, checkdata_checkcurrabbr text, checkdata_checkcurrname text, checkdata_checkpayto text, checkdata_checkaddress text, checkdata_checkmemo text, checkdata_docnumber text, checkdata_docreference text, checkdata_docdate text, checkdata_docamount text, checkdata_docdiscount text, checkdata_docnetamount text ); DROP TYPE public.checkdata; publicadminfalse8166124786929cntctdupTYPECREATE TYPE cntctdup AS ( cntct_id integer, cntct_crmacct_id integer, cntct_addr_id integer, cntct_first_name text, cntct_last_name text, cntct_honorific text, cntct_initials text, cntct_active boolean, cntct_phone text, cntct_phone2 text, cntct_fax text, cntct_email text, cntct_webaddr text, cntct_notes text, cntct_title text, cntct_number text, cntct_middle text, cntct_suffix text, cntct_owner_username text, cntct_name text, crmacct_number text, crmacct_name text, addr_id integer, addr_active boolean, addr_line1 text, addr_line2 text, addr_line3 text, addr_city text, addr_state text, addr_postalcode text, addr_country text, addr_notes text, addr_number text, cntctdup_level integer ); DROP TYPE public.cntctdup; publicadminfalse8770124786932 flcoldataTYPEdCREATE TYPE flcoldata AS ( flcoldata_column integer, flcoldata_start date, flcoldata_end date ); DROP TYPE public.flcoldata; publicadminfalse8771 124777516 flstmtheadTYPECREATE TYPE flstmthead AS ( flstmthead_flhead_id integer, flstmthead_flcol_id integer, flstmthead_period_id integer, flstmthead_username text, flstmthead_typedescrip1 text, flstmthead_typedescrip2 text, flstmthead_flhead_name text, flstmthead_flcol_name text, flstmthead_month text, flstmthead_qtr text, flstmthead_year text, flstmthead_prmonth text, flstmthead_prqtr text, flstmthead_pryear text ); DROP TYPE public.flstmthead; publicadminfalse8167124786935 flstmtitemTYPECREATE TYPE flstmtitem AS ( flstmtitem_flhead_id integer, flstmtitem_period_id integer, flstmtitem_username text, flstmtitem_order integer, flstmtitem_level integer, flstmtitem_subgrp integer, flstmtitem_type text, flstmtitem_type_id integer, flstmtitem_parent_id integer, flstmtitem_accnt_id integer, flstmtitem_name text, flstmtitem_month numeric, flstmtitem_monthdb numeric, flstmtitem_monthcr numeric, flstmtitem_monthprcnt numeric, flstmtitem_monthbudget numeric, flstmtitem_monthbudgetprcnt numeric, flstmtitem_monthbudgetdiff numeric, flstmtitem_monthbudgetdiffprcnt numeric, flstmtitem_qtr numeric, flstmtitem_qtrdb numeric, flstmtitem_qtrcr numeric, flstmtitem_qtrprcnt numeric, flstmtitem_qtrbudget numeric, flstmtitem_qtrbudgetprcnt numeric, flstmtitem_qtrbudgetdiff numeric, flstmtitem_qtrbudgetdiffprcnt numeric, flstmtitem_year numeric, flstmtitem_yeardb numeric, flstmtitem_yearcr numeric, flstmtitem_yearprcnt numeric, flstmtitem_yearbudget numeric, flstmtitem_yearbudgetprcnt numeric, flstmtitem_yearbudgetdiff numeric, flstmtitem_yearbudgetdiffprcnt numeric, flstmtitem_prmonth numeric, flstmtitem_prmonthprcnt numeric, flstmtitem_prmonthdiff numeric, flstmtitem_prmonthdiffprcnt numeric, flstmtitem_prqtr numeric, flstmtitem_prqtrprcnt numeric, flstmtitem_prqtrdiff numeric, flstmtitem_prqtrdiffprcnt numeric, flstmtitem_pryear numeric, flstmtitem_pryearprcnt numeric, flstmtitem_pryeardiff numeric, flstmtitem_pryeardiffprcnt numeric ); DROP TYPE public.flstmtitem; publicadminfalse8772 124777522 fltrendheadTYPECREATE TYPE fltrendhead AS ( fltrendhead_flhead_id integer, fltrendhead_username text, fltrendhead_typedescrip text, fltrendhead_flhead_name text, fltrendhead_fld1 text, fltrendhead_fld2 text, fltrendhead_fld3 text, fltrendhead_fld4 text, fltrendhead_fld5 text, fltrendhead_fld6 text, fltrendhead_fld7 text, fltrendhead_fld8 text, fltrendhead_fld9 text, fltrendhead_fld10 text, fltrendhead_fld11 text, fltrendhead_fld12 text, fltrendhead_grndttl text ); DROP TYPE public.fltrendhead; publicadminfalse8168 124777525 fltrenditemTYPE{CREATE TYPE fltrenditem AS ( fltrenditem_flhead_id integer, fltrenditem_username text, fltrenditem_order integer, fltrenditem_level integer, fltrenditem_subgrp integer, fltrenditem_type text, fltrenditem_type_id integer, fltrenditem_parent_id integer, fltrenditem_accnt_id integer, fltrenditem_name text, fltrenditem_fld1 text, fltrenditem_fld2 text, fltrenditem_fld3 text, fltrenditem_fld4 text, fltrenditem_fld5 text, fltrenditem_fld6 text, fltrenditem_fld7 text, fltrenditem_fld8 text, fltrenditem_fld9 text, fltrenditem_fld10 text, fltrenditem_fld11 text, fltrenditem_fld12 text, fltrenditem_grndttl text ); DROP TYPE public.fltrenditem; publicadminfalse8169124786938 freightdataTYPEDCREATE TYPE freightdata AS ( freightdata_schedule text, freightdata_from text, freightdata_to text, freightdata_shipvia text, freightdata_freightclass text, freightdata_weight numeric, freightdata_uom text, freightdata_price numeric, freightdata_type text, freightdata_total numeric, freightdata_currency text ); DROP TYPE public.freightdata; publicadminfalse8773124786941 itempriceTYPEUCREATE TYPE itemprice AS ( itemprice_price numeric, itemprice_type character(1) ); DROP TYPE public.itemprice; publicadminfalse8774 124777534 orderitemtypeTYPE6CREATE TYPE orderitemtype AS ( orderitem_id integer, orderitem_orderhead_type text, orderitem_orderhead_id integer, orderitem_linenumber integer, orderitem_status text, orderitem_itemsite_id integer, orderitem_scheddate date, orderitem_qty_ordered numeric, orderitem_qty_shipped numeric, orderitem_qty_received numeric, orderitem_qty_uom_id integer, orderitem_qty_invuomratio numeric, orderitem_unitcost numeric, orderitem_unitcost_curr_id integer, orderitem_freight numeric, orderitem_freight_received numeric, orderitem_freight_curr_id integer ); DROP TYPE public.orderitemtype; publicadminfalse8170124786944ordheadTYPEfCREATE TYPE ordhead AS ( orderhead_id integer, orderhead_type text, orderhead_number text, orderhead_status text, orderhead_orderdate date, orderhead_linecount integer, orderhead_from_id integer, orderhead_from text, orderhead_to_id integer, orderhead_to text, orderhead_curr_id integer, orderhead_agent_username text, orderhead_shipvia text ); DROP TYPE public.ordhead; publicadminfalse8775124786947orditemTYPE0CREATE TYPE orditem AS ( orderitem_id integer, orderitem_orderhead_type text, orderitem_orderhead_id integer, orderitem_linenumber integer, orderitem_status text, orderitem_itemsite_id integer, orderitem_scheddate date, orderitem_qty_ordered numeric, orderitem_qty_shipped numeric, orderitem_qty_received numeric, orderitem_qty_uom_id integer, orderitem_qty_invuomratio numeric, orderitem_unitcost numeric, orderitem_unitcost_curr_id integer, orderitem_freight numeric, orderitem_freight_received numeric, orderitem_freight_curr_id integer ); DROP TYPE public.orditem; publicadminfalse8776124786950reordlvlTYPEaCREATE TYPE reordlvl AS ( reordlvl_itemsite_id integer, reordlvl_item_id integer, reordlvl_warehous_code text, reordlvl_item_number text, reordlvl_item_descrip text, reordlvl_leadtime integer, reordlvl_daysofstock integer, reordlvl_curr_level numeric, reordlvl_total_days numeric, reordlvl_total_usage numeric, reordlvl_calc_level integer ); DROP TYPE public.reordlvl; publicadminfalse8777 124777546seqissTYPEYCREATE TYPE seqiss AS ( seqiss_number integer, seqiss_time timestamp with time zone ); DROP TYPE public.seqiss; publicadminfalse8171124786954subtaxTYPECREATE TYPE subtax AS ( subtax_taxcode_id integer, subtax_taxcode_code text, subtax_taxcode_descrip text, subtax_taxcode_level integer ); DROP TYPE public.subtax; publicadminfalse8778124786957 taxassignTYPECREATE TYPE taxassign AS ( taxassign_taxzone_id integer, taxassign_taxtype_id integer, taxassign_level integer, taxassign_zone_code text, taxassign_type_descrip text, taxassign_taxclass_code text, taxassign_taxclass_sequence integer ); DROP TYPE public.taxassign; publicadminfalse8779124786960 taxdetailTYPECREATE TYPE taxdetail AS ( taxdetail_tax_id integer, taxdetail_tax_code text, taxdetail_tax_descrip text, taxdetail_tax_basis_tax_id integer, taxdetail_taxrate_percent numeric(10,6), taxdetail_taxrate_amount numeric(16,2), taxdetail_level integer, taxdetail_taxclass_id integer, taxdetail_taxclass_code text, taxdetail_taxclass_sequence integer, taxdetail_tax numeric(16,6), taxdetail_curr_id integer, taxdetail_curr_abbr text ); DROP TYPE public.taxdetail; publicadminfalse8780124786963wodataTYPECREATE TYPE wodata AS ( wodata_id integer, wodata_id_type integer, wodata_number integer, wodata_subnumber integer, wodata_itemnumber text, wodata_descrip text, wodata_status character(1), wodata_startdate date, wodata_duedate date, wodata_adhoc boolean, wodata_itemsite_id integer, wodata_listprice numeric, wodata_custprice numeric, wodata_qoh numeric, wodata_short numeric, wodata_qtyper numeric, wodata_qtyiss numeric, wodata_qtyrcv numeric, wodata_qtyordreq numeric, wodata_qtyuom text, wodata_scrap numeric, wodata_setup numeric, wodata_run numeric, wodata_notes text, wodata_ref text, wodata_level integer ); DROP TYPE public.wodata; publicadminfalse8781124786966woinvavTYPECREATE TYPE woinvav AS ( woinvav_itemsite_id integer, woinvav_womatl_id integer, woinvav_type character(1), woinvav_item_wo_number text, woinvav_descrip text, woinvav_uomname text, woinvav_qoh numeric, woinvav_balance numeric, woinvav_allocated numeric, woinvav_ordered numeric, woinvav_woavail numeric, woinvav_totalavail numeric, woinvav_reorderlevel numeric, woinvav_level integer ); DROP TYPE public.woinvav; publicadminfalse8782 1247154475 usersonlineTYPECREATE TYPE usersonline AS ( usr_id integer, usr_username text, usr_propername text, usr_email text, client_start timestamp with time zone, query_start timestamp with time zone, cnt_internal bigint, cnt_external bigint, client_addr inet ); !DROP TYPE xtdesktop.usersonline;  xtdesktopadminfalse10897T 125577565<getcustnumberfrominfo(text, text, text, text, text, boolean)FUNCTIONCREATE FUNCTION getcustnumberfrominfo(text, text, text, text, text, boolean) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _email TEXT := COALESCE(UPPER($1), ''); _company TEXT := COALESCE(UPPER($2), ''); _first TEXT := COALESCE(UPPER($3), ''); _last TEXT := COALESCE(UPPER($4), ''); _fullname TEXT := COALESCE(UPPER($5), TRIM(_first || ' ' || _last)); _generate BOOLEAN := COALESCE($6, FALSE); _counter INTEGER; _custcount INTEGER := 0; _custnumber TEXT; _candidate TEXT := ''; _loopmax INTEGER := 0; _minlength INTEGER := 5; _maxlength INTEGER := 8; _numformat TEXT := ''; _testme TEXT; BEGIN IF (_email != '') THEN SELECT count(*), cust_number INTO _custcount, _custnumber FROM custinfo LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) WHERE (UPPER(cntct_email)=_email) GROUP BY cust_number; IF (NOT FOUND) THEN _custcount := 0; ELSIF(_custcount = 1) THEN RETURN _custnumber; END IF; END IF; IF (_company != '') THEN SELECT count(*), cust_number INTO _custcount, _custnumber FROM custinfo WHERE (UPPER(cust_name)=_company) GROUP BY cust_number; IF (NOT FOUND) THEN _custcount := 0; ELSIF(_custcount = 1) THEN RETURN _custnumber; END IF; END IF; IF (_fullname = '' AND (_first != '' OR _last != '')) THEN _fullname := TRIM(_first || ' ' || _last); END IF; IF (_custcount <= 0 AND _fullname != '') THEN SELECT count(*), cust_number INTO _custcount, _custnumber FROM custinfo WHERE (UPPER(cust_name)=_fullname) GROUP BY cust_number; IF (NOT FOUND) THEN _custcount := 0; ELSIF(_custcount = 1) THEN RETURN _custnumber; END IF; END IF; IF (_custcount > 1) THEN RAISE EXCEPTION 'Found % possible Customers for % and % and %', _custcount, _email, _company, _fullname; END IF; IF (_custcount <= 0 AND _generate) THEN IF (_maxlength < _minlength) THEN RAISE EXCEPTION 'Fix getCustNumberFromInfo: max length < min length'; END IF; IF (_company != '') THEN _candidate := _company; ELSIF (_email != '') THEN _candidate := SUBSTRING(_email FOR POSITION('@' IN _email) - 1); ELSIF (_last != '') THEN _candidate := _last; IF (_first != '') THEN _candidate := _candidate || _first; END IF; ELSIF (_fullname != '' AND (POSITION(' ' IN _fullname) > 0)) THEN _candidate := SUBSTRING(_fullname FROM POSITION(' ' IN _fullname) + 1) || SUBSTRING(_fullname FOR POSITION(' ' IN _fullname) - 1); END IF; WHILE (POSITION(' ' IN _candidate) > 0) LOOP _candidate := SUBSTRING(_candidate FOR POSITION(' ' IN _candidate) - 1) || SUBSTRING(_candidate FROM POSITION(' ' IN _candidate) + 1); END LOOP; FOR _counter IN _minlength.._maxlength LOOP _testme := SUBSTRING(_candidate FOR _counter); IF (NOT EXISTS(SELECT cust_number FROM custinfo WHERE (cust_number=_testme))) THEN _custnumber := _testme; EXIT; END IF; END LOOP; IF (_custnumber IS NULL OR _custnumber = '') THEN IF (LENGTH(_candidate) < _minlength) THEN _minlength := LENGTH(_candidate); END IF; FOR _counter IN _minlength.._maxlength LOOP _loopmax := _loopmax * 10 + 9; _numformat := _numformat || '0'; END LOOP; FOR _counter IN 1.._loopmax LOOP _testme := SUBSTRING(_candidate FOR _minlength) || TRIM(TO_CHAR(_counter, _numformat)); IF (NOT EXISTS(SELECT cust_number FROM custinfo WHERE (cust_number=_testme))) THEN _custnumber := _testme; EXIT; END IF; END LOOP; END IF; IF (_custnumber IS NULL OR _custnumber = '') THEN RAISE EXCEPTION 'Could not generate a new Customer Number'; END IF; END IF; IF (_custnumber IS NULL OR _custnumber = '') THEN RAISE EXCEPTION 'Could not find Customer Number for % and % and %', _email, _company, _fullname; END IF; RETURN _custnumber; END; $_$; PDROP FUNCTION api.getcustnumberfrominfo(text, text, text, text, text, boolean); apiadminfalse64623125577566formatlocationname(integer)FUNCTIONCREATE FUNCTION formatlocationname(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLocationid ALIAS FOR $1; _name TEXT; _r RECORD; BEGIN SELECT location_aisle, location_rack, location_bin, location_name INTO _r FROM location WHERE (location_id=pLocationid); IF (FOUND) THEN IF (_r.location_aisle IS NOT NULL) THEN _name := _r.location_aisle; ELSE _name := ''; END IF; IF (_r.location_rack IS NOT NULL) THEN _name := (_name || _r.location_rack); END IF; IF (_r.location_bin IS NOT NULL) THEN _name := (_name || _r.location_bin); END IF; IF (_r.location_name IS NOT NULL) THEN _name := (_name || _r.location_name); END IF; RETURN _name; ELSE RETURN 'N/A'; END IF; END; $_$; 2DROP FUNCTION public.formatlocationname(integer); publicadminfalse84623125977567cntslipTABLECREATE TABLE cntslip ( cntslip_id integer DEFAULT nextval(('"cntslip_cntslip_id_seq"'::text)::regclass) NOT NULL, cntslip_cnttag_id integer, cntslip_entered timestamp with time zone, cntslip_posted boolean, cntslip_number text, cntslip_qty numeric(18,6), cntslip_comments text, cntslip_location_id integer, cntslip_lotserial text, cntslip_lotserial_expiration date, cntslip_lotserial_warrpurc date, cntslip_username text ); DROP TABLE public.cntslip; publicadminfalse58908%00 TABLE cntslipCOMMENT6COMMENT ON TABLE cntslip IS 'Count Slip information'; publicadminfalse172%00cntslipACLREVOKE ALL ON TABLE cntslip FROM PUBLIC; REVOKE ALL ON TABLE cntslip FROM admin; GRANT ALL ON TABLE cntslip TO admin; GRANT ALL ON TABLE cntslip TO xtrole; publicadminfalse172125977574invcntTABLECREATE TABLE invcnt ( invcnt_id integer DEFAULT nextval(('invcnt_invcnt_id_seq'::text)::regclass) NOT NULL, invcnt_itemsite_id integer, invcnt_tagdate timestamp with time zone, invcnt_cntdate timestamp with time zone, invcnt_qoh_before numeric(18,6), invcnt_qoh_after numeric(18,6), invcnt_matcost numeric(16,6), invcnt_posted boolean, invcnt_postdate timestamp with time zone, invcnt_comments text, invcnt_priority boolean, invcnt_tagnumber text, invcnt_invhist_id integer, invcnt_location_id integer, invcnt_cnt_username text, invcnt_post_username text, invcnt_tag_username text ); DROP TABLE public.invcnt; publicadminfalse58918%00 TABLE invcntCOMMENT4COMMENT ON TABLE invcnt IS 'Count Tag information'; publicadminfalse173%00invcntACLREVOKE ALL ON TABLE invcnt FROM PUBLIC; REVOKE ALL ON TABLE invcnt FROM admin; GRANT ALL ON TABLE invcnt TO admin; GRANT ALL ON TABLE invcnt TO xtrole; publicadminfalse173125977581itemTABLECREATE TABLE item ( item_id integer DEFAULT nextval(('item_item_id_seq'::text)::regclass) NOT NULL, item_number text NOT NULL, item_descrip1 text NOT NULL, item_descrip2 text NOT NULL, item_classcode_id integer NOT NULL, item_picklist boolean DEFAULT true NOT NULL, item_comments text, item_sold boolean NOT NULL, item_fractional boolean NOT NULL, item_active boolean NOT NULL, item_type character(1) DEFAULT 'R'::bpchar NOT NULL, item_prodweight numeric(16,2) DEFAULT 0 NOT NULL, item_packweight numeric(16,2) DEFAULT 0 NOT NULL, item_prodcat_id integer NOT NULL, item_exclusive boolean DEFAULT false NOT NULL, item_listprice numeric(16,4) NOT NULL, item_config boolean DEFAULT false, item_extdescrip text, item_upccode text, item_maxcost numeric(16,6) DEFAULT 0 NOT NULL, item_inv_uom_id integer NOT NULL, item_price_uom_id integer NOT NULL, item_warrdays integer DEFAULT 0, item_freightclass_id integer, item_tax_recoverable boolean DEFAULT false NOT NULL, item_listcost numeric(16,6) DEFAULT 0.0 NOT NULL, CONSTRAINT item_item_number_check CHECK ((item_number <> ''::text)), CONSTRAINT item_item_type_check CHECK (((((((((((((item_type = 'P'::bpchar) OR (item_type = 'M'::bpchar)) OR (item_type = 'F'::bpchar)) OR (item_type = 'O'::bpchar)) OR (item_type = 'R'::bpchar)) OR (item_type = 'S'::bpchar)) OR (item_type = 'T'::bpchar)) OR (item_type = 'B'::bpchar)) OR (item_type = 'L'::bpchar)) OR (item_type = 'Y'::bpchar)) OR (item_type = 'C'::bpchar)) OR (item_type = 'K'::bpchar))), CONSTRAINT item_sold_check CHECK ((NOT (item_sold AND (item_prodcat_id = (-1))))) ); DROP TABLE public.item; publicadminfalse589258935894589558965897589858995900590159025903590459058%00 TABLE itemCOMMENT-COMMENT ON TABLE item IS 'Item information'; publicadminfalse174%00COLUMN item.item_maxcostCOMMENTjCOMMENT ON COLUMN item.item_maxcost IS 'Maximum cost for item. Used to constrain purchase order price.'; publicadminfalse174%00COLUMN item.item_listcostCOMMENTZCOMMENT ON COLUMN item.item_listcost IS 'List cost for item. Basis for markup pricing.'; publicadminfalse174%00itemACLREVOKE ALL ON TABLE item FROM PUBLIC; REVOKE ALL ON TABLE item FROM admin; GRANT ALL ON TABLE item TO admin; GRANT ALL ON TABLE item TO xtrole; publicadminfalse174125977601itemsiteTABLE CREATE TABLE itemsite ( itemsite_id integer DEFAULT nextval(('itemsite_itemsite_id_seq'::text)::regclass) NOT NULL, itemsite_item_id integer NOT NULL, itemsite_warehous_id integer, itemsite_qtyonhand numeric(18,6) NOT NULL, itemsite_reorderlevel numeric(18,6) NOT NULL, itemsite_ordertoqty numeric(18,6) NOT NULL, itemsite_cyclecountfreq integer NOT NULL, itemsite_datelastcount date, itemsite_datelastused date, itemsite_loccntrl boolean NOT NULL, itemsite_safetystock numeric(18,6) NOT NULL, itemsite_minordqty numeric(18,6) NOT NULL, itemsite_multordqty numeric(18,6) NOT NULL, itemsite_leadtime integer NOT NULL, itemsite_abcclass character(1), itemsite_issuemethod character(1), itemsite_controlmethod character(1), itemsite_active boolean NOT NULL, itemsite_plancode_id integer NOT NULL, itemsite_costcat_id integer NOT NULL, itemsite_eventfence integer NOT NULL, itemsite_sold boolean NOT NULL, itemsite_stocked boolean NOT NULL, itemsite_freeze boolean DEFAULT false NOT NULL, itemsite_location_id integer NOT NULL, itemsite_useparams boolean NOT NULL, itemsite_useparamsmanual boolean NOT NULL, itemsite_soldranking integer DEFAULT 1, itemsite_createpr boolean, itemsite_location text, itemsite_location_comments text, itemsite_notes text, itemsite_perishable boolean NOT NULL, itemsite_autoabcclass boolean NOT NULL, itemsite_ordergroup integer DEFAULT 1 NOT NULL, itemsite_disallowblankwip boolean DEFAULT false NOT NULL, itemsite_maxordqty numeric(18,6) DEFAULT 0.0 NOT NULL, itemsite_mps_timefence integer DEFAULT 0 NOT NULL, itemsite_createwo boolean DEFAULT false NOT NULL, itemsite_warrpurc boolean DEFAULT false NOT NULL, itemsite_autoreg boolean DEFAULT false, itemsite_costmethod character(1) NOT NULL, itemsite_value numeric(12,2) NOT NULL, itemsite_ordergroup_first boolean DEFAULT false NOT NULL, itemsite_supply_itemsite_id integer, itemsite_planning_type character(1) DEFAULT 'M'::bpchar NOT NULL, itemsite_wosupply boolean DEFAULT false NOT NULL, itemsite_posupply boolean DEFAULT false NOT NULL, itemsite_lsseq_id integer, itemsite_cosdefault character(1), itemsite_createsopr boolean DEFAULT false, itemsite_createsopo boolean DEFAULT false, itemsite_dropship boolean DEFAULT false, itemsite_recvlocation_id integer DEFAULT (-1) NOT NULL, itemsite_issuelocation_id integer DEFAULT (-1) NOT NULL, itemsite_location_dist boolean DEFAULT false NOT NULL, itemsite_recvlocation_dist boolean DEFAULT false NOT NULL, itemsite_issuelocation_dist boolean DEFAULT false NOT NULL, CONSTRAINT itemsite_itemsite_abcclass_check CHECK (((((itemsite_abcclass = 'A'::bpchar) OR (itemsite_abcclass = 'B'::bpchar)) OR (itemsite_abcclass = 'C'::bpchar)) OR (itemsite_abcclass = 'T'::bpchar))), CONSTRAINT itemsite_itemsite_controlmethod_check CHECK (((((itemsite_controlmethod = 'N'::bpchar) OR (itemsite_controlmethod = 'R'::bpchar)) OR (itemsite_controlmethod = 'S'::bpchar)) OR (itemsite_controlmethod = 'L'::bpchar))), CONSTRAINT itemsite_itemsite_costmethod_check CHECK (((((itemsite_costmethod = 'N'::bpchar) OR (itemsite_costmethod = 'A'::bpchar)) OR (itemsite_costmethod = 'S'::bpchar)) OR (itemsite_costmethod = 'J'::bpchar))), CONSTRAINT itemsite_itemsite_ordergroup_check CHECK ((itemsite_ordergroup > 0)) ); DROP TABLE public.itemsite; publicadminfalse590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059318%00TABLE itemsiteCOMMENT6COMMENT ON TABLE itemsite IS 'Item Site information'; publicadminfalse175%00!COLUMN itemsite.itemsite_lsseq_idCOMMENTlCOMMENT ON COLUMN itemsite.itemsite_lsseq_id IS 'Foreign key reference for automatic lot/serial numbering'; publicadminfalse175%00#COLUMN itemsite.itemsite_createsoprCOMMENT_COMMENT ON COLUMN itemsite.itemsite_createsopr IS 'Used to flag Sales items that create P/Rs'; publicadminfalse175%00#COLUMN itemsite.itemsite_createsopoCOMMENT_COMMENT ON COLUMN itemsite.itemsite_createsopo IS 'Used to flag Sales items that create P/Os'; publicadminfalse175%00!COLUMN itemsite.itemsite_dropshipCOMMENTYCOMMENT ON COLUMN itemsite.itemsite_dropship IS 'Used to flag Sales items to drop ship'; publicadminfalse175%00itemsiteACLREVOKE ALL ON TABLE itemsite FROM PUBLIC; REVOKE ALL ON TABLE itemsite FROM admin; GRANT ALL ON TABLE itemsite TO admin; GRANT ALL ON TABLE itemsite TO xtrole; publicadminfalse175125977634whsinfoTABLECREATE TABLE whsinfo ( warehous_id integer DEFAULT nextval(('warehous_warehous_id_seq'::text)::regclass) NOT NULL, warehous_code text NOT NULL, warehous_descrip text, warehous_fob text, warehous_active boolean, warehous_counttag_prefix text, warehous_counttag_number integer, warehous_bol_prefix text, warehous_bol_number integer, warehous_shipping boolean, warehous_useslips boolean, warehous_usezones boolean, warehous_aislesize integer, warehous_aislealpha boolean, warehous_racksize integer, warehous_rackalpha boolean, warehous_binsize integer, warehous_binalpha boolean, warehous_locationsize integer, warehous_locationalpha boolean, warehous_enforcearbl boolean, warehous_default_accnt_id integer, warehous_shipping_commission numeric(8,4) DEFAULT 0.00, warehous_cntct_id integer, warehous_addr_id integer, warehous_transit boolean DEFAULT false NOT NULL, warehous_shipform_id integer, warehous_shipvia_id integer, warehous_shipcomments text, warehous_costcat_id integer, warehous_sitetype_id integer, warehous_taxzone_id integer, warehous_sequence integer DEFAULT 0 NOT NULL, CONSTRAINT whsinfo_check CHECK (((warehous_transit AND (warehous_costcat_id IS NOT NULL)) OR (NOT warehous_transit))), CONSTRAINT whsinfo_warehous_code_check CHECK ((warehous_code <> ''::text)) ); DROP TABLE public.whsinfo; publicadminfalse5932593359345935593659378%00 TABLE whsinfoCOMMENT5COMMENT ON TABLE whsinfo IS 'Warehouse information'; publicadminfalse176%00whsinfoACLREVOKE ALL ON TABLE whsinfo FROM PUBLIC; REVOKE ALL ON TABLE whsinfo FROM admin; GRANT ALL ON TABLE whsinfo TO admin; GRANT ALL ON TABLE whsinfo TO xtrole; publicadminfalse176125977646 physinvcountVIEWvCREATE VIEW physinvcount AS SELECT whsinfo.warehous_code AS site, item.item_number, invcnt.invcnt_tagnumber AS tag_number, cntslip.cntslip_qty AS quantity, public.formatlocationname(cntslip.cntslip_location_id) AS location, cntslip.cntslip_lotserial AS lotserial, cntslip.cntslip_comments AS comment FROM ((((public.invcnt JOIN public.itemsite ON ((itemsite.itemsite_id = invcnt.invcnt_itemsite_id))) JOIN public.whsinfo ON ((whsinfo.warehous_id = itemsite.itemsite_warehous_id))) JOIN public.item ON ((item.item_id = itemsite.itemsite_item_id))) LEFT JOIN public.cntslip ON ((cntslip.cntslip_cnttag_id = invcnt.invcnt_id))); DROP VIEW api.physinvcount; apiadminfalse86316%00VIEW physinvcountCOMMENTICOMMENT ON VIEW physinvcount IS 'Physical Inventory Count Tag and Slip'; apiadminfalse177%00 physinvcountACLREVOKE ALL ON TABLE physinvcount FROM PUBLIC; REVOKE ALL ON TABLE physinvcount FROM admin; GRANT ALL ON TABLE physinvcount TO admin; GRANT ALL ON TABLE physinvcount TO xtrole; apiadminfalse177^ 125577651 insertphysinvcount(physinvcount)FUNCTIONCREATE FUNCTION insertphysinvcount(physinvcount) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNEW ALIAS FOR $1; _itemid INTEGER; _type TEXT; _siteid INTEGER; _itemsiteid INTEGER; _controlmethod TEXT; _loccntrl BOOLEAN; _locationid INTEGER; _lsid INTEGER; _invcntid INTEGER; _cntslipid INTEGER; _result INTEGER; BEGIN -- Check Item SELECT item_id, item_type INTO _itemid, _type FROM item WHERE (item_number=UPPER(pNEW.item_number)); IF (NOT FOUND OR _type IN ('F', 'R', 'L','J', 'K')) THEN SELECT item_id, item_type INTO _itemid, _type FROM item WHERE (item_upccode=pNEW.item_number); IF (NOT FOUND OR _type IN ('F', 'R', 'L','J', 'K')) THEN RAISE EXCEPTION 'Function insertPhysInvCount failed because Item % not found or invalid type', pNEW.item_number; END IF; END IF; -- Check Site SELECT warehous_id INTO _siteid FROM whsinfo WHERE (warehous_code=COALESCE(pNEW.site, (SELECT warehous_code FROM usrpref,whsinfo WHERE (usrpref_username=getEffectiveXtUser()) AND (usrpref_name='PreferredWarehouse') AND (warehous_id=CAST(usrpref_value AS INTEGER))))); IF (NOT FOUND) THEN RAISE EXCEPTION 'Function insertPhysInvCount failed because Site % not found', pNEW.site; END IF; -- Check Itemsite SELECT itemsite_id, itemsite_controlmethod, itemsite_loccntrl INTO _itemsiteid, _controlmethod, _loccntrl FROM itemsite WHERE (itemsite_item_id=_itemid) AND (itemsite_warehous_id=_siteid); IF (NOT FOUND) THEN RAISE EXCEPTION 'Function insertPhysInvCount failed because Itemsite %, % not found', pNEW.site, pNEW.item_number; END IF; IF (_controlmethod = 'N') THEN RAISE EXCEPTION 'Function insertPhysInvCount failed because Itemsite %, % not inventory control method', pNEW.site, pNEW.item_number; END IF; IF (_controlmethod IN ('L', 'S') AND COALESCE(pNEW.lotserial, '') = '') THEN RAISE EXCEPTION 'Function insertPhysInvCount failed because Itemsite %, % lot/serial controlled and lotserial not provided', pNEW.site, pNEW.item_number; END IF; IF (_controlmethod = 'S') THEN -- Check for unique serial id SELECT ls_id INTO _lsid FROM ls WHERE (ls_number=pNEW.lotserial); IF (FOUND) THEN RAISE EXCEPTION 'Function insertPhysInvCount failed because Serial %, %, % not unique', pNEW.site, pNEW.item_number, pNEW.lotserial; END IF; END IF; IF (_loccntrl) THEN IF (pNEW.location IS NULL) THEN RAISE EXCEPTION 'Function insertPhysInvCount failed because Itemsite %, % multi location and location not provided', pNEW.site, pNEW.item_number; ELSE -- Check Location SELECT location_id INTO _locationid FROM location WHERE (location_id=getLocationId(pNEW.site, pNEW.location)); IF (NOT FOUND) THEN RAISE EXCEPTION 'Function insertPhysInvCount failed because Location %, % not found', pNEW.site, pNEW.location; END IF; END IF; END IF; -- Create Count Tag SELECT CreateCountTag(_itemsiteid, pNEW.comment, FALSE, FALSE) INTO _invcntid; IF (_invcntid <= 0) THEN RAISE EXCEPTION 'Function insertPhysInvCount failed because CreateCountTag failed for Itemsite %, %', pNEW.site, pNEW.item_number; END IF; -- Create Count Slip INSERT INTO cntslip ( cntslip_cnttag_id, cntslip_username, cntslip_entered, cntslip_posted, cntslip_number, cntslip_qty, cntslip_location_id, cntslip_lotserial, cntslip_lotserial_expiration, cntslip_lotserial_warrpurc, cntslip_comments ) VALUES ( _invcntid, getEffectiveXtUser(), CURRENT_TIMESTAMP, FALSE, 'N/A', pNEW.quantity, COALESCE(_locationid, -1), pNEW.lotserial, NULL, NULL, pNEW.comment ) RETURNING cntslip_id INTO _cntslipid; -- Post Count Slip SELECT postCountSlip(_cntslipid) INTO _result; IF (_result < 0) THEN RAISE EXCEPTION 'Function insertPhysInvCount failed because postCountSlip failed for Itemsite %, %, %', pNEW.site, pNEW.item_number, _result; END IF; RETURN TRUE; END; $_$; 4DROP FUNCTION api.insertphysinvcount(physinvcount); apiadminfalse462362750?125577652 basecurrid()FUNCTIONCREATE FUNCTION basecurrid() RETURNS integer LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE returnVal INTEGER; BEGIN SELECT curr_id INTO returnVal FROM curr_symbol WHERE curr_base = TRUE; IF NOT FOUND THEN RAISE EXCEPTION 'No base currency found'; END IF; RETURN returnVal; END; $$; #DROP FUNCTION public.basecurrid(); publicadminfalse84623125577653formatglaccount(integer)FUNCTIONrCREATE FUNCTION formatglaccount(paccntid integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN formatGlAccount(accnt_company, accnt_profit, accnt_number, accnt_sub) FROM accnt WHERE (accnt_id=pAccntid); END; $$; 8DROP FUNCTION public.formatglaccount(paccntid integer); publicadminfalse46238 125577654formatsolinenumber(integer)FUNCTIONNCREATE FUNCTION formatsolinenumber(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoitemid ALIAS FOR $1; _r RECORD; BEGIN SELECT coitem_linenumber, coitem_subnumber INTO _r FROM coitem WHERE(coitem_id=pSoitemid); IF(NOT FOUND) THEN RETURN NULL; END IF; IF(COALESCE(_r.coitem_subnumber, 0) > 0) THEN RETURN _r.coitem_linenumber || '.' || _r.coitem_subnumber; END IF; RETURN _r.coitem_linenumber; END; $_$; 2DROP FUNCTION public.formatsolinenumber(integer); publicadminfalse46238>125577655geteffectivextuser()FUNCTIONCREATE FUNCTION geteffectivextuser() RETURNS text LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN /* The default return value of this function is simply the user currently connected. Overload this function from another schema to implement specific user handling from an external application that uses connection pooling. Use setEffectiveXtUser(text) to create a temporary table that inserts user data that can in turn be used as a lookup reference for an over loaded version of this function like so: SELECT effective_value FROM effective_user WHERE effective_key = 'username' */ RETURN CURRENT_USER; END; $$; +DROP FUNCTION public.geteffectivextuser(); publicadminfalse46238^125577656 getitemtaxtype(integer, integer)FUNCTIONCREATE FUNCTION getitemtaxtype(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pTaxzoneid ALIAS FOR $2; _taxtypeid INTEGER; BEGIN SELECT itemtax_taxtype_id INTO _taxtypeid FROM itemtax WHERE ((itemtax_item_id=pItemid) AND (itemtax_taxzone_id=pTaxzoneid)); IF (NOT FOUND) THEN SELECT itemtax_taxtype_id INTO _taxtypeid FROM itemtax WHERE ((itemtax_item_id=pItemid) AND (itemtax_taxzone_id IS NULL)); IF (NOT FOUND) THEN RETURN NULL; END IF; END IF; RETURN _taxtypeid; END; $_$; 7DROP FUNCTION public.getitemtaxtype(integer, integer); publicadminfalse84623125977657coheadTABLE CREATE TABLE cohead ( cohead_id integer DEFAULT nextval(('cohead_cohead_id_seq'::text)::regclass) NOT NULL, cohead_number text NOT NULL, cohead_cust_id integer NOT NULL, cohead_custponumber text, cohead_type character(1), cohead_orderdate date, cohead_warehous_id integer, cohead_shipto_id integer, cohead_shiptoname text, cohead_shiptoaddress1 text, cohead_shiptoaddress2 text, cohead_shiptoaddress3 text, cohead_shiptoaddress4 text, cohead_shiptoaddress5 text, cohead_salesrep_id integer NOT NULL, cohead_terms_id integer NOT NULL, cohead_fob text, cohead_shipvia text, cohead_shiptocity text, cohead_shiptostate text, cohead_shiptozipcode text, cohead_freight numeric(16,4) NOT NULL, cohead_misc numeric(16,4) DEFAULT 0 NOT NULL, cohead_imported boolean DEFAULT false, cohead_ordercomments text, cohead_shipcomments text, cohead_shiptophone text, cohead_shipchrg_id integer, cohead_shipform_id integer, cohead_billtoname text, cohead_billtoaddress1 text, cohead_billtoaddress2 text, cohead_billtoaddress3 text, cohead_billtocity text, cohead_billtostate text, cohead_billtozipcode text, cohead_misc_accnt_id integer, cohead_misc_descrip text, cohead_commission numeric(16,4), cohead_miscdate date, cohead_holdtype character(1), cohead_packdate date, cohead_prj_id integer, cohead_wasquote boolean DEFAULT false NOT NULL, cohead_lastupdated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL, cohead_shipcomplete boolean DEFAULT false NOT NULL, cohead_created timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone, cohead_creator text DEFAULT geteffectivextuser(), cohead_quote_number text, cohead_billtocountry text, cohead_shiptocountry text, cohead_curr_id integer DEFAULT basecurrid(), cohead_calcfreight boolean DEFAULT false NOT NULL, cohead_shipto_cntct_id integer, cohead_shipto_cntct_honorific text, cohead_shipto_cntct_first_name text, cohead_shipto_cntct_middle text, cohead_shipto_cntct_last_name text, cohead_shipto_cntct_suffix text, cohead_shipto_cntct_phone text, cohead_shipto_cntct_title text, cohead_shipto_cntct_fax text, cohead_shipto_cntct_email text, cohead_billto_cntct_id integer, cohead_billto_cntct_honorific text, cohead_billto_cntct_first_name text, cohead_billto_cntct_middle text, cohead_billto_cntct_last_name text, cohead_billto_cntct_suffix text, cohead_billto_cntct_phone text, cohead_billto_cntct_title text, cohead_billto_cntct_fax text, cohead_billto_cntct_email text, cohead_taxzone_id integer, cohead_taxtype_id integer, cohead_ophead_id integer, cohead_status character(1) DEFAULT 'O'::bpchar NOT NULL, cohead_saletype_id integer, cohead_shipzone_id integer, CONSTRAINT cohead_check CHECK (((cohead_misc = (0)::numeric) OR ((cohead_misc <> (0)::numeric) AND (cohead_misc_accnt_id IS NOT NULL)))), CONSTRAINT cohead_cohead_number_check CHECK ((cohead_number <> ''::text)) ); DROP TABLE public.cohead; publicadminfalse59385939594059415942594359445945594659475948594959508%00 TABLE coheadCOMMENT=COMMENT ON TABLE cohead IS 'Sales Order header information'; publicadminfalse178%00 COLUMN cohead.cohead_saletype_idCOMMENTXCOMMENT ON COLUMN cohead.cohead_saletype_id IS 'Associated sale type for sales order.'; publicadminfalse178%00 COLUMN cohead.cohead_shipzone_idCOMMENT\COMMENT ON COLUMN cohead.cohead_shipzone_id IS 'Associated shipping zone for sales order.'; publicadminfalse178%00coheadACLREVOKE ALL ON TABLE cohead FROM PUBLIC; REVOKE ALL ON TABLE cohead FROM admin; GRANT ALL ON TABLE cohead TO admin; GRANT ALL ON TABLE cohead TO xtrole; publicadminfalse178125977676coitemTABLECREATE TABLE coitem ( coitem_id integer DEFAULT nextval(('coitem_coitem_id_seq'::text)::regclass) NOT NULL, coitem_cohead_id integer, coitem_linenumber integer NOT NULL, coitem_itemsite_id integer, coitem_status character(1), coitem_scheddate date, coitem_promdate date, coitem_qtyord numeric(18,6) NOT NULL, coitem_unitcost numeric(16,6) NOT NULL, coitem_price numeric(16,4) NOT NULL, coitem_custprice numeric(16,4) NOT NULL, coitem_qtyshipped numeric(18,6) NOT NULL, coitem_order_id integer, coitem_memo text, coitem_imported boolean DEFAULT false, coitem_qtyreturned numeric(18,6), coitem_closedate timestamp with time zone, coitem_custpn text, coitem_order_type character(1), coitem_close_username text, coitem_lastupdated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL, coitem_substitute_item_id integer, coitem_created timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone, coitem_creator text DEFAULT geteffectivextuser(), coitem_prcost numeric(16,6), coitem_qty_uom_id integer NOT NULL, coitem_qty_invuomratio numeric(20,10) NOT NULL, coitem_price_uom_id integer NOT NULL, coitem_price_invuomratio numeric(20,10) NOT NULL, coitem_warranty boolean DEFAULT false NOT NULL, coitem_cos_accnt_id integer, coitem_qtyreserved numeric(18,6) DEFAULT 0.0 NOT NULL, coitem_subnumber integer DEFAULT 0 NOT NULL, coitem_firm boolean DEFAULT false NOT NULL, coitem_taxtype_id integer, coitem_rev_accnt_id integer, coitem_pricemode character(1) DEFAULT 'D'::bpchar NOT NULL, CONSTRAINT coitem_coitem_status_check CHECK ((((coitem_status = 'O'::bpchar) OR (coitem_status = 'C'::bpchar)) OR (coitem_status = 'X'::bpchar))), CONSTRAINT valid_coitem_pricemode CHECK ((coitem_pricemode = ANY (ARRAY['D'::bpchar, 'M'::bpchar]))) ); DROP TABLE public.coitem; publicadminfalse5951595259535954595559565957595859595960596159628%00 TABLE coitemCOMMENT@COMMENT ON TABLE coitem IS 'Sales Order Line Item information'; publicadminfalse179%00COLUMN coitem.coitem_pricemodeCOMMENT~COMMENT ON COLUMN coitem.coitem_pricemode IS 'Pricing mode for sales order item. Valid values are D-discount, and M-markup'; publicadminfalse179%00coitemACLREVOKE ALL ON TABLE coitem FROM PUBLIC; REVOKE ALL ON TABLE coitem FROM admin; GRANT ALL ON TABLE coitem TO admin; GRANT ALL ON TABLE coitem TO xtrole; publicadminfalse179125977694poheadTABLECREATE TABLE pohead ( pohead_id integer DEFAULT nextval(('pohead_pohead_id_seq'::text)::regclass) NOT NULL, pohead_status character(1), pohead_number text NOT NULL, pohead_orderdate date, pohead_vend_id integer, pohead_fob text, pohead_shipvia text, pohead_comments text, pohead_freight numeric(16,2) DEFAULT 0, pohead_printed boolean DEFAULT false, pohead_terms_id integer, pohead_warehous_id integer, pohead_vendaddr_id integer, pohead_agent_username text, pohead_curr_id integer DEFAULT basecurrid(), pohead_saved boolean DEFAULT true NOT NULL, pohead_taxzone_id integer, pohead_taxtype_id integer, pohead_dropship boolean DEFAULT false, pohead_vend_cntct_id integer, pohead_vend_cntct_honorific text, pohead_vend_cntct_first_name text, pohead_vend_cntct_middle text, pohead_vend_cntct_last_name text, pohead_vend_cntct_suffix text, pohead_vend_cntct_phone text, pohead_vend_cntct_title text, pohead_vend_cntct_fax text, pohead_vend_cntct_email text, pohead_vendaddress1 text, pohead_vendaddress2 text, pohead_vendaddress3 text, pohead_vendcity text, pohead_vendstate text, pohead_vendzipcode text, pohead_vendcountry text, pohead_shipto_cntct_id integer, pohead_shipto_cntct_honorific text, pohead_shipto_cntct_first_name text, pohead_shipto_cntct_middle text, pohead_shipto_cntct_last_name text, pohead_shipto_cntct_suffix text, pohead_shipto_cntct_phone text, pohead_shipto_cntct_title text, pohead_shipto_cntct_fax text, pohead_shipto_cntct_email text, pohead_shiptoaddress_id integer, pohead_shiptoaddress1 text, pohead_shiptoaddress2 text, pohead_shiptoaddress3 text, pohead_shiptocity text, pohead_shiptostate text, pohead_shiptozipcode text, pohead_shiptocountry text, pohead_cohead_id integer, pohead_released date, pohead_shiptoname text, CONSTRAINT pohead_pohead_number_check CHECK ((pohead_number <> ''::text)), CONSTRAINT pohead_pohead_status_check CHECK ((((pohead_status = 'U'::bpchar) OR (pohead_status = 'O'::bpchar)) OR (pohead_status = 'C'::bpchar))) ); DROP TABLE public.pohead; publicadminfalse596359645965596659675968596959708%00 TABLE poheadCOMMENT@COMMENT ON TABLE pohead IS 'Purchase Order header information'; publicadminfalse180%00poheadACLREVOKE ALL ON TABLE pohead FROM PUBLIC; REVOKE ALL ON TABLE pohead FROM admin; GRANT ALL ON TABLE pohead TO admin; GRANT ALL ON TABLE pohead TO xtrole; publicadminfalse180125977708poitemTABLECREATE TABLE poitem ( poitem_id integer DEFAULT nextval(('poitem_poitem_id_seq'::text)::regclass) NOT NULL, poitem_status character(1), poitem_pohead_id integer, poitem_linenumber integer, poitem_duedate date, poitem_itemsite_id integer, poitem_vend_item_descrip text, poitem_vend_uom text, poitem_invvenduomratio numeric(20,10), poitem_qty_ordered numeric(18,6) NOT NULL, poitem_qty_received numeric(18,6) DEFAULT 0.0 NOT NULL, poitem_qty_returned numeric(18,6) DEFAULT 0.0 NOT NULL, poitem_qty_vouchered numeric(18,6) DEFAULT 0.0 NOT NULL, poitem_unitprice numeric(16,6), poitem_vend_item_number text, poitem_comments text, poitem_qty_toreceive numeric(18,6), poitem_expcat_id integer, poitem_itemsrc_id integer, poitem_freight numeric(16,4) DEFAULT 0.0 NOT NULL, poitem_freight_received numeric(16,4) DEFAULT 0.0 NOT NULL, poitem_freight_vouchered numeric(16,4) DEFAULT 0.0 NOT NULL, poitem_prj_id integer, poitem_stdcost numeric(16,6), poitem_bom_rev_id integer, poitem_boo_rev_id integer, poitem_manuf_name text, poitem_manuf_item_number text, poitem_manuf_item_descrip text, poitem_taxtype_id integer, poitem_tax_recoverable boolean DEFAULT true NOT NULL, poitem_rlsd_duedate date, poitem_order_id integer, poitem_order_type character(1), CONSTRAINT poitem_poitem_status_check CHECK ((((poitem_status = 'U'::bpchar) OR (poitem_status = 'O'::bpchar)) OR (poitem_status = 'C'::bpchar))) ); DROP TABLE public.poitem; publicadminfalse5971597259735974597559765977597859798%00 TABLE poitemCOMMENTCCOMMENT ON TABLE poitem IS 'Purchase Order Line Item information'; publicadminfalse181%00poitemACLREVOKE ALL ON TABLE poitem FROM PUBLIC; REVOKE ALL ON TABLE poitem FROM admin; GRANT ALL ON TABLE poitem TO admin; GRANT ALL ON TABLE poitem TO xtrole; publicadminfalse181125977723taxtypeTABLECREATE TABLE taxtype ( taxtype_id integer NOT NULL, taxtype_name text NOT NULL, taxtype_descrip text, taxtype_sys boolean DEFAULT false NOT NULL, CONSTRAINT taxtype_taxtype_name_check CHECK ((taxtype_name <> ''::text)) ); DROP TABLE public.taxtype; publicadminfalse598159828%00 TABLE taxtypeCOMMENT5COMMENT ON TABLE taxtype IS 'The list of Tax Types'; publicadminfalse182%00taxtypeACLREVOKE ALL ON TABLE taxtype FROM PUBLIC; REVOKE ALL ON TABLE taxtype FROM admin; GRANT ALL ON TABLE taxtype TO admin; GRANT ALL ON TABLE taxtype TO xtrole; publicadminfalse182125977731uomTABLECREATE TABLE uom ( uom_id integer NOT NULL, uom_name text NOT NULL, uom_descrip text, uom_item_weight boolean DEFAULT false NOT NULL, CONSTRAINT uom_uom_name_check CHECK ((uom_name <> ''::text)) ); DROP TABLE public.uom; publicadminfalse598459858%00 TABLE uomCOMMENT7COMMENT ON TABLE uom IS 'Unit of Measure information'; publicadminfalse183%00uomACLREVOKE ALL ON TABLE uom FROM PUBLIC; REVOKE ALL ON TABLE uom FROM admin; GRANT ALL ON TABLE uom TO admin; GRANT ALL ON TABLE uom TO xtrole; publicadminfalse183125977739 saleslineVIEWg CREATE VIEW salesline AS SELECT (cohead.cohead_number)::character varying AS order_number, (public.formatsolinenumber(coitem.coitem_id))::character varying AS line_number, l.item_number, coitem.coitem_custpn AS customer_pn, s.item_number AS substitute_for, whsinfo.warehous_code AS sold_from_site, coitem.coitem_status AS status, coitem.coitem_qtyord AS qty_ordered, q.uom_name AS qty_uom, coitem.coitem_price AS net_unit_price, p.uom_name AS price_uom, coitem.coitem_scheddate AS scheduled_date, coitem.coitem_promdate AS promise_date, coitem.coitem_warranty AS warranty, COALESCE((SELECT taxtype.taxtype_name FROM public.taxtype WHERE (taxtype.taxtype_id = public.getitemtaxtype(l.item_id, cohead.cohead_taxzone_id))), 'None'::text) AS tax_type, CASE WHEN (coitem.coitem_price = (0)::numeric) THEN '100'::text WHEN (coitem.coitem_custprice = (0)::numeric) THEN 'N/A'::text ELSE (round((((1)::numeric - (coitem.coitem_price / coitem.coitem_custprice)) * (100)::numeric), 4))::text END AS discount_pct_from_list, CASE WHEN (coitem.coitem_order_id = (-1)) THEN false ELSE true END AS create_order, CASE WHEN (coitem.coitem_order_id = (-1)) THEN ''::text ELSE ((pohead.pohead_number || '-'::text) || poitem.poitem_linenumber) END AS create_po, coitem.coitem_prcost AS overwrite_po_price, coitem.coitem_memo AS notes, CASE WHEN (coitem.coitem_cos_accnt_id IS NOT NULL) THEN public.formatglaccount(coitem.coitem_cos_accnt_id) ELSE NULL::text END AS alternate_cos_account, CASE WHEN (coitem.coitem_rev_accnt_id IS NOT NULL) THEN public.formatglaccount(coitem.coitem_rev_accnt_id) ELSE NULL::text END AS alternate_rev_account FROM public.cohead, (((public.coitem LEFT JOIN public.itemsite isb ON ((coitem.coitem_substitute_item_id = isb.itemsite_id))) LEFT JOIN public.item s ON ((isb.itemsite_item_id = s.item_id))) LEFT JOIN (public.poitem JOIN public.pohead ON ((poitem.poitem_pohead_id = pohead.pohead_id))) ON ((poitem.poitem_id = coitem.coitem_order_id))), public.itemsite il, public.item l, public.whsinfo, public.uom q, public.uom p WHERE ((((((cohead.cohead_id = coitem.coitem_cohead_id) AND (coitem.coitem_itemsite_id = il.itemsite_id)) AND (il.itemsite_item_id = l.item_id)) AND (il.itemsite_warehous_id = whsinfo.warehous_id)) AND (coitem.coitem_qty_uom_id = q.uom_id)) AND (coitem.coitem_price_uom_id = p.uom_id)) ORDER BY cohead.cohead_number, coitem.coitem_linenumber, coitem.coitem_subnumber; DROP VIEW api.salesline; apiadminfalse86326%00VIEW saleslineCOMMENT6COMMENT ON VIEW salesline IS 'Sales Order Line Item'; apiadminfalse184%00 saleslineACLREVOKE ALL ON TABLE salesline FROM PUBLIC; REVOKE ALL ON TABLE salesline FROM admin; GRANT ALL ON TABLE salesline TO admin; GRANT ALL ON TABLE salesline TO xtrole; apiadminfalse184V 125577744insertsalesline(salesline)FUNCTIONTCREATE FUNCTION insertsalesline(salesline) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNEW ALIAS FOR $1; _r RECORD; BEGIN IF (NOT EXISTS (SELECT cohead_id FROM cohead WHERE cohead_number=pNEW.order_number)) THEN RAISE EXCEPTION 'Function insertSalesLine failed because Sales Order % not found', pNEW.order_number; END IF; IF (NOT EXISTS (SELECT item_id FROM item WHERE item_number=pNEW.item_number)) THEN RAISE EXCEPTION 'Function insertSalesLine failed because Item Number % not found', pNEW.item_number; END IF; SELECT * INTO _r FROM cohead, itemsite, item, whsinfo WHERE ((cohead_number=pNEW.order_number) AND (itemsite_warehous_id=warehous_id AND (itemsite_item_id=item_id) AND (itemsite_active) AND (item_number=pNEW.item_number) AND (warehous_active) AND (warehous_id=COALESCE(getWarehousId(pNEW.sold_from_site,'ALL'),cohead_warehous_id,fetchprefwarehousid())))); IF (NOT FOUND) THEN RAISE EXCEPTION 'Function insertSalesLine failed with unknown failure to retrieve Sales Order'; END IF; INSERT INTO coitem ( coitem_cohead_id, coitem_linenumber, coitem_itemsite_id, coitem_status, coitem_scheddate, coitem_promdate, coitem_qtyord, coitem_qty_uom_id, coitem_qty_invuomratio, coitem_qtyshipped, coitem_unitcost, coitem_price, coitem_price_uom_id, coitem_price_invuomratio, coitem_custprice, coitem_order_id, coitem_memo, coitem_imported, coitem_qtyreturned, coitem_custpn, coitem_order_type, coitem_substitute_item_id, coitem_prcost, coitem_taxtype_id, coitem_warranty, coitem_cos_accnt_id, coitem_rev_accnt_id) VALUES ( _r.cohead_id, pNEW.line_number::INTEGER, _r.itemsite_id, pNEW.status, pNEW.scheduled_date, pNEW.promise_date, pNEW.qty_ordered, COALESCE(getUomId(pNEW.qty_uom),_r.item_inv_uom_id), itemuomtouomratio(_r.item_id,COALESCE(getUomId(pNEW.qty_uom),_r.item_inv_uom_id),_r.item_inv_uom_id), 0, stdCost(_r.item_id), COALESCE(pNEW.net_unit_price,itemPrice(_r.item_id,_r.cohead_cust_id, _r.cohead_shipto_id,pNEW.qty_ordered,_r.cohead_curr_id,_r.cohead_orderdate)), COALESCE(getUomId(pNEW.price_uom),_r.item_price_uom_id), itemuomtouomratio(_r.item_id,COALESCE(getUomId(pNEW.price_uom),_r.item_price_uom_id),_r.item_price_uom_id), itemPrice(_r.item_id, _r.cohead_cust_id, _r.cohead_shipto_id, pNEW.qty_ordered, _r.item_inv_uom_id, _r.item_price_uom_id, _r.cohead_curr_id,_r.cohead_orderdate, CASE WHEN (fetchMetricText('soPriceEffective') = 'ScheduleDate') THEN pNEW.scheduled_date WHEN (fetchMetricText('soPriceEffective') = 'OrderDate') THEN _r.cohead_orderdate ELSE CURRENT_DATE END, NULL) -1, pNEW.notes, true, 0, pNEW.customer_pn, CASE WHEN ((pNEW.create_order AND (_r.item_type = 'M')) OR ((pNEW.create_order IS NULL) AND _r.itemsite_createwo) AND (NOT _r.itemsite_stocked)) THEN 'W' WHEN ((pNEW.create_order AND (_r.item_type = 'P')) OR ((pNEW.create_order IS NULL) AND _r.itemsite_createsopr) AND (NOT _r.itemsite_stocked)) THEN 'R' WHEN ((pNEW.create_order AND (_r.item_type = 'P') AND (_r.itemsite_createsopo)) OR ((pNEW.create_order IS NULL) AND _r.itemsite_createsopo) AND (NOT _r.itemsite_stocked)) THEN 'P' END, getitemid(pNEW.substitute_for), pNEW.overwrite_po_price, COALESCE(getTaxTypeId(pNEW.tax_type), getItemTaxType(_r.itemsite_item_id, _r.cohead_taxzone_id)), pNEW.warranty, getGlAccntId(pNEW.alternate_cos_account), getGlAccntId(pNEW.alternate_rev_account) ); RETURN TRUE; END; $_$; .DROP FUNCTION api.insertsalesline(salesline); apiadminfalse277746236125577745_accntdeletetrigger()FUNCTION CREATE FUNCTION _accntdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _accntnum TEXT := formatGLAccount(OLD.accnt_id); _check INTEGER; BEGIN -- This trigger is to protect against accounts that are in use -- Check to see if the passed accnt is used in a Cost Category SELECT costcat_id INTO _check FROM costcat WHERE ( (costcat_asset_accnt_id=OLD.accnt_id) OR (costcat_liability_accnt_id=OLD.accnt_id) OR (costcat_adjustment_accnt_id=OLD.accnt_id) OR (costcat_purchprice_accnt_id=OLD.accnt_id) OR (costcat_laboroverhead_accnt_id=OLD.accnt_id) OR (costcat_scrap_accnt_id=OLD.accnt_id) OR (costcat_invcost_accnt_id=OLD.accnt_id) OR (costcat_wip_accnt_id=OLD.accnt_id) OR (costcat_shipasset_accnt_id=OLD.accnt_id) OR (costcat_mfgscrap_accnt_id=OLD.accnt_id) OR (costcat_transform_accnt_id=OLD.accnt_id) OR (costcat_freight_accnt_id=OLD.accnt_id) ) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in Cost Category'; END IF; -- Check to see if the passed accnt is used in a Sales Account Assignment SELECT salesaccnt_id INTO _check FROM salesaccnt WHERE ( (salesaccnt_sales_accnt_id=OLD.accnt_id) OR (salesaccnt_credit_accnt_id=OLD.accnt_id) OR (salesaccnt_cos_accnt_id=OLD.accnt_id) ) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in Sales Account Assignment'; END IF; -- Check to see if the passed accnt is used in a A/R Account Assignment SELECT araccnt_id INTO _check FROM araccnt WHERE ( (araccnt_freight_accnt_id=OLD.accnt_id) OR (araccnt_ar_accnt_id=OLD.accnt_id) OR (araccnt_prepaid_accnt_id=OLD.accnt_id) ) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in A/R Account Assignment'; END IF; -- Check to see if the passed accnt is used in a Warehouse SELECT warehous_id INTO _check FROM whsinfo WHERE (warehous_default_accnt_id=OLD.accnt_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in Site'; END IF; -- Check to see if the passed accnt is used in a Bank Account SELECT bankaccnt_id INTO _check FROM bankaccnt WHERE (bankaccnt_accnt_id=OLD.accnt_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in Bank Account'; END IF; -- Check to see if the passed accnt is used in an Expense Category SELECT expcat_id INTO _check FROM expcat WHERE ( (expcat_exp_accnt_id=OLD.accnt_id) OR (expcat_liability_accnt_id=OLD.accnt_id) OR (expcat_purchprice_accnt_id=OLD.accnt_id) OR (expcat_freight_accnt_id=OLD.accnt_id) ) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in Expense Category'; END IF; -- Check to see if the passed accnt is used in a Tax Code SELECT tax_id INTO _check FROM tax WHERE (tax_sales_accnt_id=OLD.accnt_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in Tax Code'; END IF; -- Check to see if the passed accnt is used in a Standard Journal Item SELECT stdjrnlitem_id INTO _check FROM stdjrnlitem WHERE (stdjrnlitem_accnt_id=OLD.accnt_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in Standard Journal Item'; END IF; -- Check to see if the passed accnt is used in a A/P Account Assignment SELECT apaccnt_ap_accnt_id INTO _check FROM apaccnt WHERE ( (apaccnt_ap_accnt_id=OLD.accnt_id) OR (apaccnt_prepaid_accnt_id=OLD.accnt_id) OR (apaccnt_discount_accnt_id=OLD.accnt_id) ) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in A/P Account Assignment'; END IF; -- Check to see if the passed accnt is used in an A/R Open Item record SELECT aropen_accnt_id INTO _check FROM aropen WHERE (aropen_accnt_id=OLD.accnt_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in A/R Open Item'; END IF; -- Check to see if the passed accnt has been used in the G/L SELECT gltrans_accnt_id INTO _check FROM gltrans WHERE (gltrans_accnt_id=OLD.accnt_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in G/L Transaction'; END IF; SELECT sltrans_accnt_id INTO _check FROM sltrans WHERE (sltrans_accnt_id=OLD.accnt_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in G/L Journal Transaction'; END IF; SELECT glseries_accnt_id INTO _check FROM glseries WHERE (glseries_accnt_id=OLD.accnt_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in G/L Series'; END IF; SELECT trialbal_accnt_id INTO _check FROM trialbal WHERE (trialbal_accnt_id=OLD.accnt_id) AND (trialbal_beginning != 0 OR trialbal_ending != 0) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in Trial Balance'; END IF; SELECT cashrcptmisc_accnt_id INTO _check FROM cashrcptmisc WHERE (cashrcptmisc_accnt_id=OLD.accnt_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Can not delete, used in Cash Receipt Misc. Application'; END IF; -- TODO: everything above here should be replaced by fkeys IF (OLD.accnt_id = fetchMetricValue('DefaultAPAccount')) THEN RAISE EXCEPTION 'Cannot delete the default A/P Account [xtuple: accnt, -1, %]', _accntnum; ELSIF (OLD.accnt_id = fetchMetricValue('DefaultARAccount')) THEN RAISE EXCEPTION 'Cannot delete the default A/R Account [xtuple: accnt, -2, %]', _accntnum; END IF; RETURN OLD; END; $$; ,DROP FUNCTION public._accntdeletetrigger(); publicadminfalse46238125577746_accnttrigger()FUNCTION9CREATE FUNCTION _accnttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ffSub BOOLEAN; ffProfit BOOLEAN; result INTEGER; BEGIN SELECT (metric_value='t') INTO ffSub FROM metric WHERE(metric_name='GLFFSubaccounts') LIMIT 1; ffSub := COALESCE(ffSub, false); SELECT (metric_value='t') INTO ffProfit FROM metric WHERE(metric_name='GLFFProfitCenters') LIMIT 1; ffProfit := COALESCE(ffProfit, false); IF (NEW.accnt_sub IS NOT NULL AND ffSub = false) THEN SELECT subaccnt_id INTO result FROM subaccnt WHERE(subaccnt_number=NEW.accnt_sub) LIMIT 1; IF (NOT FOUND) THEN RAISE EXCEPTION 'You must supply a valid Sub Account Number.'; END IF; END IF; IF (NEW.accnt_profit IS NOT NULL AND ffProfit = false) THEN SELECT prftcntr_id INTO result FROM prftcntr WHERE(prftcntr_number=NEW.accnt_profit) LIMIT 1; IF (NOT FOUND) THEN RAISE EXCEPTION 'You must supply a valid Profit Center Number.'; END IF; END IF; IF (TG_OP = 'UPDATE') THEN IF ((NEW.accnt_type != OLD.accnt_type) AND (SELECT (count(*) > 0) FROM gltrans WHERE (gltrans_accnt_id=NEW.accnt_id))) THEN RAISE EXCEPTION 'You may not change the account type of an account that has transaction history'; END IF; END IF; NEW.accnt_name := formatGlAccount(NEW.accnt_company, NEW.accnt_profit, NEW.accnt_number, NEW.accnt_sub); RETURN NEW; END; $$; &DROP FUNCTION public._accnttrigger(); publicadminfalse46238125577747_accntuniquetrigger()FUNCTIONCREATE FUNCTION _accntuniquetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN -- This trigger is to protect against id collision on inherited tables since there is no way -- to enforce that with regular constraints. It should be applied to accnt and any table that -- inherits accnt. IF (SELECT (count(accnt_id) > 0) FROM accnt WHERE (accnt_id = NEW.accnt_id)) THEN RAISE EXCEPTION 'Can not create record on account with duplicate key %.', NEW.accnt_id; END IF; RETURN NEW; END; $$; ,DROP FUNCTION public._accntuniquetrigger(); publicadminfalse46238125587114_addrafterdeletetrigger()FUNCTIONfCREATE FUNCTION _addrafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'ADDR' AND charass_target_id = OLD.addr_id; RETURN OLD; END; $$; 0DROP FUNCTION public._addrafterdeletetrigger(); publicadminfalse46238125577748_addrtrigger()FUNCTIONCREATE FUNCTION _addrtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _uses INTEGER := 0; BEGIN IF (TG_OP = 'INSERT') THEN --- clear the number from the issue cache PERFORM clearNumberIssue('AddressNumber', NEW.addr_number); ELSE SELECT count(*) INTO _uses FROM cntct WHERE ((cntct_addr_id=OLD.addr_id) AND cntct_active); END IF; IF (TG_OP = 'UPDATE') THEN IF (OLD.addr_active AND NOT NEW.addr_active AND _uses > 0) THEN RAISE EXCEPTION 'Cannot inactivate Address with Active Contacts (%)', _uses; END IF; ELSIF (TG_OP = 'DELETE') THEN IF (_uses > 0) THEN RAISE EXCEPTION 'Cannot Delete Address with Active Contacts (%)', _uses; END IF; UPDATE cntct SET cntct_addr_id = NULL WHERE ((cntct_addr_id=OLD.addr_id) AND (NOT cntct_active)); RETURN OLD; END IF; RETURN NEW; END; $$; %DROP FUNCTION public._addrtrigger(); publicadminfalse46238125577749_alarmbeforetrigger()FUNCTION7CREATE FUNCTION _alarmbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN PERFORM clearNumberIssue('AlarmNumber', NEW.alarm_number); RETURN NEW; END; $$; ,DROP FUNCTION public._alarmbeforetrigger(); publicadminfalse46238125577750_apapplytrigger()FUNCTIONCREATE FUNCTION _apapplytrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _tpaid NUMERIC; BEGIN -- get the exchange rate for the doc date IF (TG_OP = 'INSERT') THEN SELECT currtocurr(NEW.apapply_curr_id,apopen_curr_id,NEW.apapply_amount,NEW.apapply_postdate) INTO _tpaid FROM apopen WHERE ( apopen_id=NEW.apapply_target_apopen_id ); IF (FOUND) THEN NEW.apapply_target_paid := _tpaid; ELSE RAISE EXCEPTION 'Error calculating paid amount on application'; END IF; END IF; RETURN NEW; END; $$; (DROP FUNCTION public._apapplytrigger(); publicadminfalse46238125577751_apopentrigger()FUNCTIONCREATE FUNCTION _apopentrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _currrate NUMERIC; BEGIN -- get the base exchange rate for the doc date IF (TG_OP = 'INSERT' AND NEW.apopen_curr_rate IS NULL) THEN SELECT curr_rate INTO _currrate FROM curr_rate WHERE ( (NEW.apopen_curr_id=curr_id) AND ( NEW.apopen_docdate BETWEEN curr_effective AND curr_expires) ); IF (FOUND) THEN NEW.apopen_curr_rate := _currrate; ELSE RAISE EXCEPTION 'Currency exchange rate not found'; END IF; END IF; NEW.apopen_open := NEW.apopen_amount > NEW.apopen_paid; IF (TG_OP = 'INSERT') THEN IF (NEW.apopen_open=FALSE) THEN NEW.apopen_status='C'; ELSE NEW.apopen_status='O'; END IF; --- clear the number from the issue cache PERFORM clearNumberIssue('APMemoNumber', NEW.apopen_docnumber); END IF; IF (TG_OP = 'UPDATE') THEN IF ((OLD.apopen_open=TRUE) AND (NEW.apopen_open=FALSE)) THEN NEW.apopen_status='C'; IF (NEW.apopen_closedate IS NULL) THEN NEW.apopen_closedate=CURRENT_DATE; END IF; END IF; IF ((OLD.apopen_open=FALSE) AND (NEW.apopen_open=TRUE)) THEN NEW.apopen_status='O'; NEW.apopen_closedate=NULL; END IF; END IF; RETURN NEW; END; $$; 'DROP FUNCTION public._apopentrigger(); publicadminfalse84623125577752_arapplytrigger()FUNCTIONCREATE FUNCTION _arapplytrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _tpaid NUMERIC; BEGIN -- get the exchange rate for the doc date IF (TG_OP = 'INSERT') THEN IF (NEW.arapply_target_doctype != 'K') THEN SELECT round(currtocurr(NEW.arapply_curr_id,aropen_curr_id,NEW.arapply_applied,NEW.arapply_postdate),2) INTO NEW.arapply_target_paid FROM aropen WHERE ( aropen_id=NEW.arapply_target_aropen_id ); ELSE SELECT round(currtocurr(NEW.arapply_curr_id,aropen_curr_id,NEW.arapply_applied,NEW.arapply_postdate),2) INTO NEW.arapply_target_paid FROM aropen WHERE ( aropen_id=NEW.arapply_source_aropen_id ); END IF; IF NOT FOUND THEN NEW.arapply_target_paid := NEW.arapply_applied; END IF; END IF; RETURN NEW; END; $$; (DROP FUNCTION public._arapplytrigger(); publicadminfalse84623125577753_aropenaftertrigger()FUNCTIONCREATE FUNCTION _aropenaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _openAmount NUMERIC; _lateCount INTEGER := 0; _graceDays INTEGER; _checkLate BOOLEAN := false; _checkLimit BOOLEAN := false; _id INTEGER; BEGIN IF (TG_OP = 'INSERT') THEN _id := NEW.aropen_id; ELSE _id := OLD.aropen_id; END IF; -- If metric is set then auto close any associated incidents when AR is closed IF (fetchMetricBool('AutoCloseARIncident')) THEN IF (NEW.aropen_open = FALSE) THEN UPDATE incdt SET incdt_status='L' WHERE (incdt_aropen_id=_id); END IF; END IF; RETURN NEW; END; $$; ,DROP FUNCTION public._aropenaftertrigger(); publicadminfalse84623125577754_aropentrigger()FUNCTION2CREATE FUNCTION _aropentrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _openAmount NUMERIC; _p RECORD; _lateCount INTEGER := 0; _graceDays INTEGER; _checkLate BOOLEAN := false; _checkLimit BOOLEAN := false; _id INTEGER; _currRate NUMERIC; BEGIN -- Checks -- Start with privileges IF ( (NOT checkPrivilege('MaintainARMemos')) AND (NOT checkPrivilege('PostMiscInvoices')) AND (NOT checkPrivilege('MaintainSalesOrders')) AND -- #24608 Required to post payments on SOs (NOT checkPrivilege('PostARDocuments')) ) THEN RAISE EXCEPTION 'You do not have privileges to maintain A/R Memos.'; END IF; IF ( (NEW.aropen_docnumber IS NULL) OR (LENGTH(NEW.aropen_docnumber) = 0) ) THEN RAISE EXCEPTION 'You must enter a valid Document # for this A/R Memo.'; END IF; IF (TG_OP IN ('INSERT', 'UPDATE') AND NEW.aropen_cust_id < 0) THEN RAISE WARNING 'Fixing deprecated use of negative aropen_cust_id'; NEW.aropen_cust_id := NULL; END IF; IF (TG_OP IN ('INSERT', 'UPDATE') AND NEW.aropen_salesrep_id < 0) THEN RAISE WARNING 'Fixing deprecated use of negative aropen_salesrep_id'; NEW.aropen_salesrep_id := NULL; END IF; IF (TG_OP = 'INSERT') THEN SELECT aropen_id INTO _id FROM aropen WHERE ( (aropen_doctype=NEW.aropen_doctype) AND (aropen_docnumber=NEW.aropen_docnumber) ) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'This Document Type/Number already exists. You may not enter a duplicate A/R Memo.'; END IF; --- clear the number from the issue cache if applicable PERFORM clearNumberIssue('ARMemoNumber', NEW.aropen_docnumber); END IF; -- Determine the number of late invoices IF ( SELECT (metric_value='t') FROM metric WHERE(metric_name='AutoCreditWarnLateCustomers')) THEN _checkLate := true; SELECT COALESCE(metric_value::integer, _graceDays) INTO _graceDays FROM metric WHERE(metric_name='DefaultAutoCreditWarnGraceDays'); IF (NOT FOUND) THEN _graceDays := 30; END IF; SELECT COALESCE(cust_gracedays, _graceDays) INTO _graceDays FROM custinfo WHERE(cust_id=NEW.aropen_cust_id); IF (NOT FOUND) THEN _graceDays := 30; END IF; SELECT count(aropen_id) INTO _lateCount FROM aropen WHERE((NEW.aropen_cust_id = aropen_cust_id) AND (aropen_open) AND (aropen_amount > aropen_paid) AND (aropen_doctype IN ('I', 'D')) AND (aropen_duedate < (CURRENT_DATE - _graceDays))); -- Adjust _lateCount if late invoice being paid IF ( (NEW.aropen_paid = NEW.aropen_amount) AND (NEW.aropen_doctype IN ('I', 'D')) AND (NEW.aropen_duedate < (CURRENT_DATE - _graceDays))) THEN _lateCount := _lateCount - 1; END IF; END IF; -- get the base exchange rate for the doc date IF (TG_OP = 'INSERT' AND NEW.aropen_curr_rate IS NULL) THEN SELECT curr_rate INTO _currrate FROM curr_rate WHERE ( (NEW.aropen_curr_id=curr_id) AND ( NEW.aropen_docdate BETWEEN curr_effective AND curr_expires) ); IF (FOUND) THEN NEW.aropen_curr_rate := _currrate; ELSE RAISE EXCEPTION 'Currency exchange rate not found'; END IF; END IF; -- Close this aropen if it is paid IF (NEW.aropen_paid = NEW.aropen_amount) THEN NEW.aropen_open=FALSE; -- Remove any aropenalloc regards that reference this aropen item DELETE FROM aropenalloc WHERE (aropenalloc_aropen_id=NEW.aropen_id); END IF; IF (TG_OP = 'INSERT') THEN IF (NEW.aropen_open=FALSE) AND (NEW.aropen_closedate IS NULL) THEN NEW.aropen_closedate=current_date; END IF; END IF; IF (TG_OP = 'UPDATE') THEN IF ((OLD.aropen_open=TRUE) AND (NEW.aropen_open=FALSE) AND (NEW.aropen_closedate IS NULL)) THEN NEW.aropen_closedate=current_date; END IF; END IF; -- Only check if the customer in question has a non-zero Credit Limit SELECT cust_id, cust_creditlmt, cust_creditstatus, cust_autoupdatestatus, cust_autoholdorders INTO _p FROM custinfo WHERE (cust_id=NEW.aropen_cust_id); IF (_p.cust_creditlmt > 0) THEN _checkLimit := true; SELECT COALESCE(SUM( CASE WHEN (aropen_doctype IN ('I', 'D')) THEN (aropen_amount - aropen_paid) ELSE ((aropen_amount - aropen_paid) * -1) END ), 0.0) INTO _openAmount FROM aropen AS current WHERE ( (current.aropen_cust_id=NEW.aropen_cust_id) AND (current.aropen_open) AND (current.aropen_id <> NEW.aropen_id) ); -- Add in the value of the current aropen item IF (NEW.aropen_doctype IN ('I', 'D')) THEN _openAmount := (_openAmount + (NEW.aropen_amount - NEW.aropen_paid)); ELSE _openAmount := (_openAmount - (NEW.aropen_amount - NEW.aropen_paid)); END IF; ELSE _openAmount := 0; END IF; IF (_checkLimit OR _checkLate) THEN -- Handle a Customer that is going under its credit limit IF ((_p.cust_creditlmt >= _openAmount) AND (_lateCount <= 0)) THEN -- Handle the Customer Status IF ( (_p.cust_autoupdatestatus) AND (_p.cust_creditstatus='W') ) THEN UPDATE custinfo SET cust_creditstatus='G' WHERE (cust_id=NEW.aropen_cust_id); END IF; -- Handle the open Sales Orders IF (_p.cust_autoholdorders) THEN UPDATE cohead SET cohead_holdtype='N' FROM coitem WHERE ( (coitem_cohead_id=cohead_id) AND (cohead_holdtype='C') AND (coitem_status='O') AND (cohead_cust_id=_p.cust_id) ); END IF; -- Handle a Customer that is going over its credit limit ELSIF ((_p.cust_creditlmt < _openAmount) OR (_lateCount > 0)) THEN -- Handle the Customer Status IF ( (_p.cust_autoupdatestatus) AND (_p.cust_creditstatus = 'G') ) THEN UPDATE custinfo SET cust_creditstatus='W' WHERE (cust_id=NEW.aropen_cust_id); END IF; -- Handle the open Sales Orders IF (_p.cust_autoholdorders) THEN UPDATE cohead SET cohead_holdtype='C' FROM coitem WHERE ( (coitem_cohead_id=cohead_id) AND (cohead_holdtype='N') AND (coitem_status='O') AND (cohead_cust_id=_p.cust_id) ); END IF; END IF; END IF; RETURN NEW; END; $$; 'DROP FUNCTION public._aropentrigger(); publicadminfalse84623125577756_bomheadtrigger()FUNCTIONCREATE FUNCTION _bomheadtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _revid INTEGER; _check TEXT; _cmnttypeid INTEGER; BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainBOMs')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Bills of Material.'; END IF; -- Cache the cmnttype_id for ChangeLog SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (FOUND) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'BMH', NEW.bomhead_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.bomhead_revision <> NEW.bomhead_revision) THEN PERFORM postComment(_cmnttypeid, 'BMH', NEW.bomhead_id, 'Revision Updated from '|| OLD.bomhead_revision||' to '||NEW.bomhead_revision); ELSE PERFORM postComment(_cmnttypeid, 'BMH', NEW.bomhead_id, 'Updated'); END IF; END IF; END IF; RETURN NEW; END; $$; (DROP FUNCTION public._bomheadtrigger(); publicadminfalse84623125577757_bomitemaftertrigger()FUNCTIONrCREATE FUNCTION _bomitemaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF ( SELECT fetchMetricBool('ItemChangeLog') ) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment('ChangeLog', 'BMI', NEW.bomitem_id, ('Created BOM Item Sequence ' || NEW.bomitem_seqnumber::TEXT)); ELSIF (TG_OP = 'UPDATE') THEN IF (NEW.bomitem_effective <> OLD.bomitem_effective) THEN PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id, ( 'Effective Date Changed from ' || formatDate(OLD.bomitem_effective, 'Always') || ' to ' || formatDate(NEW.bomitem_effective, 'Always' ) ) ); END IF; IF (NEW.bomitem_expires <> OLD.bomitem_expires) THEN PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id, ( 'Expiration Date Changed from ' || formatDate(OLD.bomitem_expires, 'Never') || ' to ' || formatDate(NEW.bomitem_expires, 'Never' ) ) ); END IF; IF (NEW.bomitem_qtyfxd <> OLD.bomitem_qtyfxd) THEN PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id, ( 'Fixed Qty. Changed from ' || formatQtyPer(OLD.bomitem_qtyfxd) || ' to ' || formatQtyPer(NEW.bomitem_qtyfxd ) ) ); END IF; IF (NEW.bomitem_qtyper <> OLD.bomitem_qtyper) THEN PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id, ( 'Qty. Per Changed from ' || formatQtyPer(OLD.bomitem_qtyper) || ' to ' || formatQtyPer(NEW.bomitem_qtyper ) ) ); END IF; IF (NEW.bomitem_scrap <> OLD.bomitem_scrap) THEN PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id, ( 'Scrap % Changed from ' || formatPrcnt(OLD.bomitem_scrap) || ' to ' || formatPrcnt(NEW.bomitem_scrap ) ) ); END IF; IF (NEW.bomitem_issuemethod <> OLD.bomitem_issuemethod) THEN PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id, ( 'Issue Method Changed from ' || (CASE WHEN(OLD.bomitem_issuemethod='S') THEN 'Push' WHEN(OLD.bomitem_issuemethod='L') THEN 'Pull' WHEN(OLD.bomitem_issuemethod='M') THEN 'Mixed' ELSE OLD.bomitem_issuemethod END) || ' to ' || (CASE WHEN(NEW.bomitem_issuemethod='S') THEN 'Push' WHEN(NEW.bomitem_issuemethod='L') THEN 'Pull' WHEN(NEW.bomitem_issuemethod='M') THEN 'Mixed' ELSE NEW.bomitem_issuemethod END) ) ); END IF; IF (NEW.bomitem_ecn <> OLD.bomitem_ecn) THEN PERFORM postComment( 'ChangeLog', 'BMI', NEW.bomitem_id, ( 'ECN Changed from ' || OLD.bomitem_ecn || ' to ' || NEW.bomitem_ecn ) ); END IF; IF (OLD.bomitem_createwo <> NEW.bomitem_createwo) THEN IF (NEW.bomitem_createwo) THEN PERFORM postComment('ChangeLog', 'BMI', NEW.bomitem_id, 'Create Child W/O activated'); ELSE PERFORM postComment('ChangeLog', 'BMI', NEW.bomitem_id, 'Create Child W/O deactivated'); END IF; END IF; IF (OLD.bomitem_issuewo <> NEW.bomitem_issuewo) THEN IF (NEW.bomitem_issuewo) THEN PERFORM postComment('ChangeLog', 'BMI', NEW.bomitem_id, 'Issue Child W/O activated'); ELSE PERFORM postComment('ChangeLog', 'BMI', NEW.bomitem_id, 'Issue Child W/O deactivated'); END IF; END IF; END IF; END IF; IF (TG_OP = 'DELETE') THEN DELETE FROM comment WHERE ( (comment_source='BMI') AND (comment_source_id=OLD.bomitem_id) ); RETURN OLD; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._bomitemaftertrigger(); publicadminfalse84623125577758_bomitembeforedeletetrigger()FUNCTIONmCREATE FUNCTION _bomitembeforedeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM comment WHERE ( (comment_source='BMI') AND (comment_source_id=OLD.bomitem_id) ); RETURN OLD; END; $$; 4DROP FUNCTION public._bomitembeforedeletetrigger(); publicadminfalse84623125577759_bomitembeforetrigger()FUNCTIONCREATE FUNCTION _bomitembeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _bomworksetid INTEGER; _bomworkid INTEGER; _seqNumber INTEGER; _parentItem RECORD; _bomheadid INTEGER; BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainBOMs')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Bills of Material.'; END IF; -- Cache Parent Item SELECT * INTO _parentItem FROM item WHERE (item_id=NEW.bomitem_parent_item_id); IF (TG_OP = 'INSERT') THEN -- Make sure that the parent and component are not the same IF (NEW.bomitem_parent_item_id = NEW.bomitem_item_id) THEN RAISE EXCEPTION 'BOM Item Parent and Component Item cannot be the same. [xtuple: createBOMItem, -1]'; END IF; -- Make sure that the parent is not used in the component at some level SELECT indentedWhereUsed(NEW.bomitem_parent_item_id) INTO _bomworksetid; SELECT bomwork_id INTO _bomworkid FROM bomwork WHERE ((bomwork_set_id=_bomworksetid) AND (bomwork_item_id=NEW.bomitem_item_id)) LIMIT 1; IF (FOUND) THEN PERFORM deleteBOMWorkset(_bomworksetid); RAISE EXCEPTION 'BOM Item Parent is used by Component, BOM is recursive. [xtuple: createBOMItem, -2]'; END IF; PERFORM deleteBOMWorkset(_bomworksetid); -- Create bomhead record if one does not exist SELECT bomhead_id INTO _bomheadid FROM bomhead WHERE (bomhead_item_id=NEW.bomitem_parent_item_id); IF (NOT FOUND) THEN INSERT INTO bomhead (bomhead_item_id, bomhead_batchsize, bomhead_rev_id) VALUES (NEW.bomitem_parent_item_id, 1, -1); END IF; -- Set defaults NEW.bomitem_rev_id := COALESCE(NEW.bomitem_rev_id, -1); NEW.bomitem_booitem_seq_id := COALESCE(NEW.bomitem_booitem_seq_id, -1); NEW.bomitem_schedatwooper := COALESCE(NEW.bomitem_schedatwooper, FALSE); IF (NEW.bomitem_seqnumber IS NULL) THEN -- Grab the next Sequence Number, if any SELECT MAX(bomitem_seqnumber) INTO _seqNumber FROM bomitem(NEW.bomitem_parent_item_id,NEW.bomitem_rev_id); IF (_seqNumber IS NOT NULL) THEN NEW.bomitem_seqnumber := (_seqNumber + 10); ELSE NEW.bomitem_seqnumber := 10; END IF; END IF; END IF; -- end Insert specific IF (TG_OP = 'UPDATE') THEN -- Disallow changes that would compromise revision control integrity IF (NEW.bomitem_parent_item_id != OLD.bomitem_parent_item_id) THEN RAISE EXCEPTION 'Parent Item ID may not be changed.'; END IF; IF (NEW.bomitem_item_id != OLD.bomitem_item_id) THEN RAISE EXCEPTION 'Item ID may not be changed.'; END IF; IF ((fetchMetricBool('RevControl')) AND (OLD.bomitem_rev_id > -1)) THEN IF (SELECT (rev_status = 'I') FROM rev WHERE (rev_id=OLD.bomitem_rev_id)) THEN RAISE EXCEPTION 'Bill of material is Inactive and may not be modified'; END IF; END IF; END IF; -- end Update specific -- Check for valid UOM IF (SELECT (count(*) != 1) FROM (SELECT uom_id FROM item JOIN uom ON (item_inv_uom_id=uom_id) WHERE(item_id=NEW.bomitem_item_id) UNION SELECT uom_id FROM item JOIN itemuomconv ON (itemuomconv_item_id=item_id) JOIN uom ON (itemuomconv_to_uom_id=uom_id), itemuom, uomtype WHERE((itemuomconv_from_uom_id=item_inv_uom_id) AND (item_id=NEW.bomitem_item_id) AND (itemuom_itemuomconv_id=itemuomconv_id) AND (uomtype_id=itemuom_uomtype_id) AND (uomtype_name='MaterialIssue')) UNION SELECT uom_id FROM item JOIN itemuomconv ON (itemuomconv_item_id=item_id) JOIN uom ON (itemuomconv_from_uom_id=uom_id), itemuom, uomtype WHERE((itemuomconv_to_uom_id=item_inv_uom_id) AND (item_id=NEW.bomitem_item_id) AND (itemuom_itemuomconv_id=itemuomconv_id) AND (uomtype_id=itemuom_uomtype_id) AND (uomtype_name='MaterialIssue'))) AS data WHERE (uom_id=NEW.bomitem_uom_id)) THEN RAISE EXCEPTION 'Unit of Measure Invalid for Material Issue.'; END IF; -- Disallow configuration parameters if parent is not a job item IF (NEW.bomitem_char_id IS NOT NULL) THEN IF (NOT _parentItem.item_config) THEN RAISE EXCEPTION 'Configuration characteristics may only be defined for Configured Items'; END IF; END IF; -- Kit items must be sold and not kits themselves IF (_parentItem.item_type = 'K') THEN IF (SELECT (COUNT(item_id) = 0) FROM item WHERE ((item_id=NEW.bomitem_item_id) AND (item_sold) AND (item_type != 'K'))) THEN RAISE EXCEPTION 'Bill of Material Items for kits must be sold and not kits themselves'; END IF; END IF; -- Over ride logic to disallow invalid data IF (NEW.bomitem_createwo) THEN IF (SELECT (item_type != 'M') FROM item WHERE (item_id=NEW.bomitem_item_id)) THEN NEW.bomitem_createwo := FALSE; END IF; IF (NEW.bomitem_booitem_seq_id = -1) THEN NEW.bomitem_schedatwooper := FALSE; END IF; END IF; NEW.bomitem_moddate := COALESCE(NEW.bomitem_moddate, CURRENT_DATE); RETURN NEW; END; $$; .DROP FUNCTION public._bomitembeforetrigger(); publicadminfalse46238125577761_bomitemsubtrigger()FUNCTIONCREATE FUNCTION _bomitemsubtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainBOMs')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Bills of Material.'; END IF; IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END; $$; +DROP FUNCTION public._bomitemsubtrigger(); publicadminfalse84623125577762_cashrcptitemaftertrigger()FUNCTIONCREATE FUNCTION _cashrcptitemaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _total NUMERIC; BEGIN -- Checks -- Total Over Application Warning SELECT (cashrcpt_amount - SUM(COALESCE(cashrcptitem_amount, 0))) INTO _total FROM cashrcptitem JOIN cashrcpt ON (cashrcpt_id=cashrcptitem_cashrcpt_id) WHERE (cashrcptitem_cashrcpt_id=NEW.cashrcptitem_cashrcpt_id) GROUP BY cashrcpt_amount; IF (_total < 0.0) THEN RAISE WARNING 'Warning -- the Cash Receipt has been over applied.'; END IF; RETURN NEW; END; $$; 2DROP FUNCTION public._cashrcptitemaftertrigger(); publicadminfalse46238125577763_cashrcptitemtrigger()FUNCTIONCREATE FUNCTION _cashrcptitemtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check BOOLEAN; _openAmount NUMERIC; BEGIN -- Checks -- Start with Privileges IF (TG_OP = 'INSERT') THEN SELECT checkPrivilege('MaintainCashReceipts') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to add a new Cash Receipt Application.'; END IF; ELSE SELECT checkPrivilege('MaintainCashReceipts') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to alter a Cash Receipt Application.'; END IF; END IF; -- Over Application SELECT round(currToCurr(aropen_curr_id, cashrcpt_curr_id, aropen_amount - aropen_paid, cashrcpt_distdate) - COALESCE((SELECT SUM(cashrcptitem_amount) FROM cashrcptitem, cashrcpt WHERE ((cashrcpt_id=cashrcptitem_cashrcpt_id) AND (NOT cashrcpt_void) AND (NOT cashrcpt_posted) AND (cashrcpt_id != NEW.cashrcptitem_cashrcpt_id) AND (cashrcptitem_aropen_id=NEW.cashrcptitem_aropen_id))), 0),2) INTO _openAmount FROM aropen, cashrcpt WHERE ( (aropen_id=NEW.cashrcptitem_aropen_id) AND (cashrcpt_id=NEW.cashrcptitem_cashrcpt_id) ); IF (NEW.cashrcptitem_amount > _openAmount) THEN RAISE EXCEPTION 'You may not apply more than the balance of this item.'; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._cashrcptitemtrigger(); publicadminfalse84623125577764_cashrcptmisctrigger()FUNCTIONCREATE FUNCTION _cashrcptmisctrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check BOOLEAN; BEGIN -- Checks -- Start with Privileges IF (TG_OP = 'INSERT') THEN SELECT checkPrivilege('MaintainCashReceipts') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to add a new Cash Receipt Misc. Application.'; END IF; ELSE SELECT checkPrivilege('MaintainCashReceipts') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to alter a Cash Receipt Misc. Application.'; END IF; END IF; -- Account is required IF (NEW.cashrcptmisc_accnt_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid GL Account.'; END IF; -- Amount is required IF (COALESCE(NEW.cashrcptmisc_amount, 0) = 0) THEN RAISE EXCEPTION 'You must supply a valid Amount.'; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._cashrcptmisctrigger(); publicadminfalse46238125577765_cashrcpttrigger()FUNCTIONjCREATE FUNCTION _cashrcpttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check BOOLEAN; _checkId INTEGER; _currId INTEGER; _bankCurrId INTEGER; _currrate NUMERIC; BEGIN -- Checks -- Start with privileges IF (TG_OP = 'INSERT') THEN SELECT checkPrivilege('MaintainCashReceipts') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to add new Cash Receipts.'; END IF; ELSE SELECT checkPrivilege('MaintainCashReceipts') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to alter a Cash Receipt.'; END IF; END IF; -- Currency must be same as Bank Currency IF (TG_OP = 'INSERT') THEN _currId = COALESCE(NEW.cashrcpt_curr_id, basecurrid()); --- clear the number from the issue cache PERFORM clearNumberIssue('CashRcptNumber', NEW.cashrcpt_number); ELSE _currId = NEW.cashrcpt_curr_id; END IF; -- get the base exchange rate for the dist date IF (NEW.cashrcpt_curr_rate IS NULL) THEN SELECT curr_rate INTO _currrate FROM curr_rate WHERE ( (NEW.cashrcpt_curr_id=curr_id) AND ( NEW.cashrcpt_distdate BETWEEN curr_effective AND curr_expires) ); IF (FOUND) THEN NEW.cashrcpt_curr_rate := _currrate; ELSE RAISE EXCEPTION 'Currency exchange rate not found'; END IF; END IF; -- Create CashReceiptPosted Event IF (TG_OP = 'UPDATE') THEN IF (OLD.cashrcpt_posted=FALSE AND NEW.cashrcpt_posted=TRUE) THEN PERFORM postEvent('CashReceiptPosted', NULL, NEW.cashrcpt_id, NULL, (cust_number || '-' || NEW.cashrcpt_docnumber || ' ' || currConcat(NEW.cashrcpt_curr_id) || formatMoney(NEW.cashrcpt_amount)), NULL, NULL, NULL, NULL) FROM custinfo WHERE (cust_id=NEW.cashrcpt_cust_id); END IF; END IF; RETURN NEW; END; $$; )DROP FUNCTION public._cashrcpttrigger(); publicadminfalse46238125577766_ccardtrigger()FUNCTION'CREATE FUNCTION _ccardtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN New.ccard_lastupdated := current_timestamp; New.ccard_last_updated_by_username := getEffectiveXtUser(); IF (TG_OP = 'UPDATE') THEN INSERT INTO ccardaud VALUES (nextval('ccardaud_ccardaud_id_seq'), NEW.ccard_id, OLD.ccard_seq, NEW.ccard_seq, OLD.ccard_cust_id, NEW.ccard_cust_id, OLD.ccard_active, NEW.ccard_active, OLD.ccard_name, NEW.ccard_name, OLD.ccard_address1, NEW.ccard_address1, OLD.ccard_address2, NEW.ccard_address2, OLD.ccard_city, NEW.ccard_city, OLD.ccard_state, NEW.ccard_state, OLD.ccard_zip, NEW.ccard_zip, OLD.ccard_country, NEW.ccard_country, OLD.ccard_number, NEW.ccard_number, OLD.ccard_debit, NEW.ccard_debit, OLD.ccard_month_expired, NEW.ccard_month_expired, OLD.ccard_year_expired, NEW.ccard_year_expired, OLD.ccard_type, NEW.ccard_type); ELSE -- We are inserting a record, therefore no old values INSERT INTO ccardaud VALUES (nextval('ccardaud_ccardaud_id_seq'), NEW.ccard_id, NULL, NEW.ccard_seq, NULL, NEW.ccard_cust_id, NULL, NEW.ccard_active, NULL, NEW.ccard_name, NULL, NEW.ccard_address1, NULL, NEW.ccard_address2, NULL, NEW.ccard_city, NULL, NEW.ccard_state, NULL, NEW.ccard_zip, NULL, NEW.ccard_country, NULL, NEW.ccard_number, NULL, NEW.ccard_debit, NULL, NEW.ccard_month_expired, NULL, NEW.ccard_year_expired, NULL, NEW.ccard_type); END IF; RETURN NEW; END; $$; &DROP FUNCTION public._ccardtrigger(); publicadminfalse46238125587134_ccpaybeforetrigger()FUNCTIONCREATE FUNCTION _ccpaybeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cardType TEXT; BEGIN IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN -- If ccpay_ccard_id is set, we don't care if ccpay_card_type is set, -- we want to get the Card Type from ccard. IF (NEW.ccpay_ccard_id IS NOT NULL) THEN SELECT ccard_type INTO _cardType FROM ccard WHERE ccard_id = NEW.ccpay_ccard_id; IF (_cardType IS NOT NULL) THEN NEW.ccpay_card_type = _cardType; END IF; END IF; END IF; RETURN NEW; END; $$; ,DROP FUNCTION public._ccpaybeforetrigger(); publicadminfalse46238125577767_charasshistorytrigger()FUNCTIONcCREATE FUNCTION _charasshistorytrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF(TG_OP = 'DELETE') THEN IF (OLD.charass_target_type = 'INCDT') THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_descrip) VALUES(OLD.charass_target_id, ('Characteristic ' || COALESCE((SELECT char_name FROM char WHERE (char_id=OLD.charass_char_id)), '') || ' Deleted: "' || COALESCE(OLD.charass_value,'') || '"') ); END IF; RETURN OLD; ELSIF (NEW.charass_target_type = 'INCDT') THEN IF (TG_OP = 'INSERT') THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_descrip) VALUES(NEW.charass_target_id, ('Characteristic ' || COALESCE((SELECT char_name FROM char WHERE (char_id=NEW.charass_char_id)), '') || ' Added: "' || COALESCE(NEW.charass_value,'') || '"') ); ELSIF (TG_OP = 'UPDATE') THEN IF (COALESCE(NEW.charass_value,'') <> COALESCE(OLD.charass_value,'')) THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_descrip) VALUES(NEW.charass_target_id, ('Characteristic ' || COALESCE((SELECT char_name FROM char WHERE (char_id=NEW.charass_char_id)), '') || ' Changed: "' || COALESCE(OLD.charass_value,'') || '" -> "' || COALESCE(NEW.charass_value,'') || '"') ); END IF; END IF; END IF; RETURN NEW; END; $$; /DROP FUNCTION public._charasshistorytrigger(); publicadminfalse46238125577768_charasstrigger()FUNCTIONCREATE FUNCTION _charasstrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Privilege Checks IF (NEW.charass_target_type = 'I' AND NOT checkPrivilege('MaintainItemMasters')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Items.'; END IF; IF (NEW.charass_target_type = 'C' AND NOT checkPrivilege('MaintainCustomerMasters')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Customers.'; END IF; -- Data check IF (NEW.charass_char_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Characteristic ID.'; END IF; -- Default Logic IF (NEW.charass_default) THEN UPDATE charass SET charass_default = false WHERE ((charass_target_id=NEW.charass_target_id) AND (charass_target_type=NEW.charass_target_type) AND (charass_char_id=NEW.charass_char_id) AND (charass_id <> NEW.charass_ID)); END IF; -- Incident update IF (NEW.charass_target_type = 'INCDT') THEN UPDATE incdt SET incdt_updated = now() WHERE incdt_id = NEW.charass_target_id; END IF; RETURN NEW; END; $$; (DROP FUNCTION public._charasstrigger(); publicadminfalse84623125577769_charbeforetrigger()FUNCTIONCREATE FUNCTION _charbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (NOT checkPrivilege('MaintainCharacteristics')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Characteristics.'; END IF; RETURN NEW; END; $$; +DROP FUNCTION public._charbeforetrigger(); publicadminfalse46238125577770_charopttrigger()FUNCTIONCREATE FUNCTION _charopttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (NOT checkPrivilege('MaintainCharacteristics')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Characteristic options.'; END IF; IF (TG_OP = 'UPDATE') THEN UPDATE charass SET charass_value = NEW.charopt_value WHERE ((charass_char_id=NEW.charopt_char_id) AND (charass_value=OLD.charopt_value)); END IF; IF (TG_OP = 'DELETE') THEN IF (SELECT (count(charass_id) > 0) FROM charass WHERE ((charass_char_id=OLD.charopt_char_id) AND (charass_value=OLD.charopt_value))) THEN RAISE EXCEPTION 'This characteristic option value is in use and can not be deleted.'; END IF; END IF; RETURN NEW; END; $$; (DROP FUNCTION public._charopttrigger(); publicadminfalse46238_ 125588617_charusebeforeupserttrigger()FUNCTION>CREATE FUNCTION _charusebeforeupserttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF NEW.charuse_target_type != 'LSR' AND NOT EXISTS (SELECT 1 FROM source WHERE source_charass = NEW.charuse_target_type) THEN RAISE EXCEPTION 'Cannot use Characteristic % with undefined target type % [ xtuple: charuse, -1, %, % ]', NEW.charuse_char_id, NEW.charuse_target_type, NEW.charuse_char_id, NEW.charuse_target_type; END IF; IF (TG_OP = 'INSERT') THEN NEW.charuse_created = CURRENT_TIMESTAMP; ELSE NEW.charuse_created = OLD.charuse_created; END IF; NEW.charuse_last_modified = CURRENT_TIMESTAMP; RETURN NEW; END $$; 4DROP FUNCTION public._charusebeforeupserttrigger(); publicadminfalse84623125577771_checkheadbeforetrigger()FUNCTIONCREATE FUNCTION _checkheadbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _amount NUMERIC; _currrate NUMERIC; BEGIN -- get the base exchange rate for the check date IF (TG_OP = 'INSERT' AND NEW.checkhead_curr_rate IS NULL) THEN SELECT curr_rate INTO _currrate FROM curr_rate WHERE ( (NEW.checkhead_curr_id=curr_id) AND ( NEW.checkhead_checkdate BETWEEN curr_effective AND curr_expires) ); IF (FOUND) THEN NEW.checkhead_curr_rate := _currrate; ELSE RAISE EXCEPTION 'Currency exchange rate not found'; END IF; END IF; IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN IF (NOT EXISTS (SELECT checkrecip_id FROM checkrecip WHERE ((checkrecip_type=NEW.checkhead_recip_type) AND (checkrecip_id=NEW.checkhead_recip_id)) )) THEN RAISE EXCEPTION 'Cannot verify recipient for check % (type % id %)', NEW.checkhead_number, NEW.checkhead_recip_type, NEW.checkhead_recip_id; END IF; IF (NEW.checkhead_journalnumber IS NOT NULL AND NOT EXISTS (SELECT jrnluse_number FROM jrnluse WHERE (jrnluse_number=NEW.checkhead_journalnumber)) ) THEN RAISE EXCEPTION 'Journal Number % does not exist and cannot be used for check %.', NEW.checkhead_journalnumber, NEW.checkhead_number; END IF; END IF; RETURN NEW; END; $$; 0DROP FUNCTION public._checkheadbeforetrigger(); publicadminfalse46238125577772_cmheadbeforetrigger()FUNCTIONCREATE FUNCTION _cmheadbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check BOOLEAN; _id INTEGER; BEGIN -- Checks -- Start with privileges SELECT checkPrivilege('MaintainCreditMemos') INTO _check; IF ( (TG_OP = 'INSERT') OR (TG_OP = 'DELETE') ) THEN IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to maintain Credit Memos.'; END IF; END IF; IF (TG_OP = 'UPDATE') THEN IF ((OLD.cmhead_printed = NEW.cmhead_printed) AND NOT (_check) ) THEN RAISE EXCEPTION 'You do not have privileges to maintain Credit Memos.'; END IF; END IF; IF (TG_OP = 'DELETE') THEN DELETE FROM cmheadtax WHERE (taxhist_parent_id=OLD.cmhead_id); RETURN OLD; END IF; IF ( (NEW.cmhead_number IS NULL) OR (LENGTH(NEW.cmhead_number) = 0) ) THEN RAISE EXCEPTION 'You must enter a valid Memo # for this Credit Memo.'; END IF; IF (TG_OP = 'INSERT') THEN SELECT cmhead_id INTO _id FROM cmhead WHERE (cmhead_number=NEW.cmhead_number); IF (FOUND) THEN RAISE EXCEPTION 'The Memo # is already in use.'; END IF; IF (fetchMetricText('CMNumberGeneration') IN ('A','O')) THEN --- clear the number from the issue cache PERFORM clearNumberIssue('CmNumber', NEW.cmhead_number); ELSIF (fetchMetricText('CMNumberGeneration') = 'S') THEN --- clear the number from the issue cache PERFORM clearNumberIssue('SoNumber', NEW.cmhead_number); END IF; END IF; IF (NEW.cmhead_cust_id IS NOT NULL) THEN SELECT cust_id INTO _id FROM custinfo WHERE (cust_id=NEW.cmhead_cust_id); IF (NOT FOUND) THEN RAISE EXCEPTION 'You must enter a valid Customer # for this Credit Memo.'; END IF; END IF; IF ( (NEW.cmhead_misc > 0) AND (NEW.cmhead_misc_accnt_id = -1) ) THEN RAISE EXCEPTION 'You may not enter a Misc. Charge without indicating the G/L Sales Account.'; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._cmheadbeforetrigger(); publicadminfalse46238125577773_cmheadtrigger()FUNCTION CREATE FUNCTION _cmheadtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN -- If this was created by a return, then reset the return IF (OLD.cmhead_rahead_id IS NOT NULL) THEN UPDATE rahead SET rahead_headcredited=false WHERE (rahead_id=OLD.cmhead_rahead_id); DELETE FROM rahist WHERE ((rahist_rahead_id=OLD.cmhead_rahead_id) AND (rahist_source='CM') AND (rahist_source_id=OLD.cmhead_id)); END IF; RETURN OLD; END IF; -- Insert new row IF (TG_OP = 'INSERT') THEN -- Calculate Freight Tax IF (NEW.cmhead_freight <> 0) THEN PERFORM calculateTaxHist( 'cmheadtax', NEW.cmhead_id, NEW.cmhead_taxzone_id, getFreightTaxtypeId(), NEW.cmhead_docdate, NEW.cmhead_curr_id, NEW.cmhead_freight * -1 ); END IF; END IF; -- Update row IF (TG_OP = 'UPDATE') THEN IF ( (NEW.cmhead_freight <> OLD.cmhead_freight) OR (COALESCE(NEW.cmhead_taxzone_id,-1) <> COALESCE(OLD.cmhead_taxzone_id,-1)) OR (NEW.cmhead_docdate <> OLD.cmhead_docdate) OR (NEW.cmhead_curr_id <> OLD.cmhead_curr_id) ) THEN -- Calculate cmhead Tax PERFORM calculateTaxHist( 'cmheadtax', NEW.cmhead_id, NEW.cmhead_taxzone_id, getFreightTaxtypeId(), NEW.cmhead_docdate, NEW.cmhead_curr_id, NEW.cmhead_freight * -1 ); END IF; IF ( (COALESCE(NEW.cmhead_taxzone_id,-1) <> COALESCE(OLD.cmhead_taxzone_id,-1)) OR (NEW.cmhead_docdate <> OLD.cmhead_docdate) OR (NEW.cmhead_curr_id <> OLD.cmhead_curr_id) ) THEN -- Calculate cmitem Tax IF (COALESCE(NEW.cmhead_taxzone_id,-1) <> COALESCE(OLD.cmhead_taxzone_id,-1)) THEN -- Cmitem trigger will calculate tax UPDATE cmitem SET cmitem_taxtype_id=getItemTaxType(itemsite_item_id,NEW.cmhead_taxzone_id) FROM itemsite WHERE ((itemsite_id=cmitem_itemsite_id) AND (cmitem_cmhead_id=NEW.cmhead_id)); ELSE PERFORM calculateTaxHist( 'cmitemtax', cmitem_id, NEW.cmhead_taxzone_id, cmitem_taxtype_id, NEW.cmhead_docdate, NEW.cmhead_curr_id, (cmitem_qtycredit * cmitem_qty_invuomratio) * (cmitem_unitprice / cmitem_price_invuomratio) * -1) FROM cmitem WHERE (cmitem_cmhead_id = NEW.cmhead_id); END IF; END IF; END IF; RETURN NEW; END; $$; 'DROP FUNCTION public._cmheadtrigger(); publicadminfalse46238125577774_cmitembeforetrigger()FUNCTION)CREATE FUNCTION _cmitembeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check BOOLEAN; _id INTEGER; BEGIN -- Checks -- Start with privileges SELECT checkPrivilege('MaintainCreditMemos') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to maintain Credit Memos.'; END IF; IF (TG_OP = 'DELETE') THEN DELETE FROM cmitemtax WHERE (taxhist_parent_id=OLD.cmitem_id); RETURN OLD; END IF; IF (TG_OP = 'INSERT') THEN IF ( (NEW.cmitem_qtycredit IS NULL) OR (NEW.cmitem_qtycredit = 0) ) THEN RAISE EXCEPTION 'Quantity to Credit must be greater than zero.'; END IF; SELECT cmitem_id INTO _id FROM cmitem WHERE ( (cmitem_cmhead_id=NEW.cmitem_cmhead_id) AND (cmitem_linenumber=NEW.cmitem_linenumber) ); IF (FOUND) THEN RAISE EXCEPTION 'The Memo Line Number is already in use.'; END IF; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._cmitembeforetrigger(); publicadminfalse46238125577775_cmitemtrigger()FUNCTION CREATE FUNCTION _cmitemtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _ext NUMERIC; _r RECORD; BEGIN IF (TG_OP = 'DELETE') THEN -- If this was created by a return, reset return values IF (OLD.cmitem_raitem_id) IS NOT NULL THEN _ext := ROUND((OLD.cmitem_qtycredit * OLD.cmitem_qty_invuomratio) * (OLD.cmitem_unitprice / OLD.cmitem_price_invuomratio),2); UPDATE raitem SET raitem_status = 'O', raitem_qtycredited = raitem_qtycredited-OLD.cmitem_qtycredit, raitem_amtcredited = raitem_amtcredited-_ext WHERE (raitem_id=OLD.cmitem_raitem_id); END IF; RETURN OLD; END IF; -- Cache Credit Memo Head SELECT * INTO _r FROM cmhead WHERE (cmhead_id=NEW.cmitem_cmhead_id); IF (NOT FOUND) THEN RAISE EXCEPTION 'Credit Memo head not found'; END IF; -- Insert new row IF (TG_OP = 'INSERT') THEN -- Calculate Tax PERFORM calculateTaxHist( 'cmitemtax', NEW.cmitem_id, COALESCE(_r.cmhead_taxzone_id, -1), NEW.cmitem_taxtype_id, COALESCE(_r.cmhead_docdate, CURRENT_DATE), COALESCE(_r.cmhead_curr_id, -1), (NEW.cmitem_qtycredit * NEW.cmitem_qty_invuomratio) * (NEW.cmitem_unitprice / NEW.cmitem_price_invuomratio) * -1); END IF; -- Update row IF (TG_OP = 'UPDATE') THEN -- Calculate Tax IF ( (NEW.cmitem_qtycredit <> OLD.cmitem_qtycredit) OR (NEW.cmitem_qty_invuomratio <> OLD.cmitem_qty_invuomratio) OR (NEW.cmitem_unitprice <> OLD.cmitem_unitprice) OR (NEW.cmitem_price_invuomratio <> OLD.cmitem_price_invuomratio) OR (COALESCE(NEW.cmitem_taxtype_id, -1) <> COALESCE(OLD.cmitem_taxtype_id, -1)) ) THEN PERFORM calculateTaxHist( 'cmitemtax', NEW.cmitem_id, COALESCE(_r.cmhead_taxzone_id, -1), NEW.cmitem_taxtype_id, COALESCE(_r.cmhead_docdate, CURRENT_DATE), COALESCE(_r.cmhead_curr_id, -1), (NEW.cmitem_qtycredit * NEW.cmitem_qty_invuomratio) * (NEW.cmitem_unitprice / NEW.cmitem_price_invuomratio) * -1); END IF; END IF; RETURN NEW; END; $$; 'DROP FUNCTION public._cmitemtrigger(); publicadminfalse46238125587147_cntctafterdeletetrigger()FUNCTIONiCREATE FUNCTION _cntctafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'CNTCT' AND charass_target_id = OLD.cntct_id; RETURN OLD; END; $$; 1DROP FUNCTION public._cntctafterdeletetrigger(); publicadminfalse46238125577776_cntcttrigger()FUNCTION+CREATE FUNCTION _cntcttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN NEW.cntct_name := formatCntctName(NULL, NEW.cntct_first_name, NEW.cntct_middle, NEW.cntct_last_name, NEW.cntct_suffix); NEW.cntct_email := lower(NEW.cntct_email); IF (TG_OP = 'INSERT') THEN --- clear the number from the issue cache PERFORM clearNumberIssue('ContactNumber', NEW.cntct_number); END IF; RETURN NEW; END; $$; &DROP FUNCTION public._cntcttrigger(); publicadminfalse84623125577777_cntcttriggerafter()FUNCTIONeCREATE FUNCTION _cntcttriggerafter() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cntctemlid INTEGER; _rows INTEGER; BEGIN IF (TG_OP = 'INSERT') THEN IF(length(coalesce(NEW.cntct_email,'')) > 0) THEN INSERT INTO cntcteml ( cntcteml_cntct_id, cntcteml_primary, cntcteml_email ) VALUES ( NEW.cntct_id, true, NEW.cntct_email ); END IF; PERFORM postComment('ChangeLog', 'T', NEW.cntct_id, ('Created by ' || getEffectiveXtUser())); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.cntct_email != NEW.cntct_email) THEN SELECT cntcteml_id INTO _cntctemlid FROM cntcteml WHERE ((cntcteml_cntct_id=NEW.cntct_id) AND (cntcteml_email=NEW.cntct_email)); GET DIAGNOSTICS _rows = ROW_COUNT; IF (_rows = 0) THEN UPDATE cntcteml SET cntcteml_primary=false WHERE ((cntcteml_cntct_id=NEW.cntct_id) AND (cntcteml_primary=true)); INSERT INTO cntcteml ( cntcteml_cntct_id, cntcteml_primary, cntcteml_email ) VALUES ( NEW.cntct_id, true, NEW.cntct_email ); ELSE UPDATE cntcteml SET cntcteml_primary=false WHERE ((cntcteml_cntct_id=NEW.cntct_id) AND (cntcteml_primary=true)); UPDATE cntcteml SET cntcteml_primary=true WHERE (cntcteml_id=_cntctemlid); END IF; END IF; ELSIF (TG_OP = 'DELETE') THEN DELETE FROM comment WHERE (comment_source_id=OLD.cntct_id AND comment_source = 'T'); DELETE FROM docass WHERE (docass_source_id=OLD.cntct_id AND docass_source_type = 'T') OR (docass_target_id=OLD.cntct_id AND docass_target_type = 'T'); RETURN OLD; END IF; RETURN NEW; END; $$; +DROP FUNCTION public._cntcttriggerafter(); publicadminfalse46238125577778_cntcttriggerbeforedelete()FUNCTION#CREATE FUNCTION _cntcttriggerbeforedelete() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN DELETE FROM cntctaddr WHERE cntctaddr_cntct_id=OLD.cntct_id; DELETE FROM cntctdata WHERE cntctdata_cntct_id=OLD.cntct_id; DELETE FROM cntcteml WHERE cntcteml_cntct_id=OLD.cntct_id; DELETE FROM docass WHERE docass_source_id = OLD.cntct_id AND docass_source_type = 'T'; DELETE FROM docass WHERE docass_target_id = OLD.cntct_id AND docass_target_type = 'T'; -- these have denormalized cntct info so it should be ok to update them UPDATE cohead SET cohead_billto_cntct_id=NULL WHERE cohead_billto_cntct_id=OLD.cntct_id; UPDATE cohead SET cohead_shipto_cntct_id=NULL WHERE cohead_shipto_cntct_id=OLD.cntct_id; UPDATE pohead SET pohead_vend_cntct_id=NULL WHERE pohead_vend_cntct_id=OLD.cntct_id; UPDATE pohead SET pohead_shipto_cntct_id=NULL WHERE pohead_shipto_cntct_id=OLD.cntct_id; UPDATE quhead SET quhead_billto_cntct_id=NULL WHERE quhead_billto_cntct_id=OLD.cntct_id; UPDATE quhead SET quhead_shipto_cntct_id=NULL WHERE quhead_shipto_cntct_id=OLD.cntct_id; IF (fetchMetricBool('MultiWhs')) THEN UPDATE tohead SET tohead_destcntct_id=NULL WHERE tohead_destcntct_id=OLD.cntct_id; UPDATE tohead SET tohead_srccntct_id=NULL WHERE tohead_srccntct_id=OLD.cntct_id; END IF; END IF; RETURN OLD; END; $$; 2DROP FUNCTION public._cntcttriggerbeforedelete(); publicadminfalse46238125577779_cntsliptrigger()FUNCTIONlCREATE FUNCTION _cntsliptrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _p RECORD; _comments TEXT; _temp TEXT; BEGIN IF (TG_OP = 'DELETE') THEN SELECT itemsite_loccntrl, itemsite_controlmethod, cntslip_posted, cntslip_lotserial, cntslip_comments, cntslip_number, cntslip_qty INTO _p FROM cntslip, invcnt, itemsite WHERE ( (cntslip_cnttag_id=invcnt_id) AND (invcnt_itemsite_id=itemsite_id) AND (cntslip_id=OLD.cntslip_id) ); IF(_p.cntslip_posted) THEN SELECT ( ' Count Slip #' || _p.cntslip_number || ' deleted ' || formatQty(_p.cntslip_qty) ) INTO _comments; -- Add the Location name if the itemsite is MLC IF (_p.itemsite_loccntrl) THEN SELECT ( ', Location:' || location_name ) INTO _temp FROM location, cntslip WHERE ( (cntslip_location_id=location_id) AND (cntslip_id=OLD.cntslip_id) ); _comments := (_comments || _temp); END IF; -- Add the Lot/Serial if the itemsite is Lot or Serial controlled IF (_p.itemsite_controlmethod = 'L') THEN _comments := (_comments || ( ', Lot #:' || _p.cntslip_lotserial)); ELSIF (_p.itemsite_controlmethod = 'S') THEN _comments := (_comments || ( ', Serial #:' || _p.cntslip_lotserial)); END IF; _comments := (_comments || ' ' || _p.cntslip_comments); UPDATE invcnt SET invcnt_qoh_after = ( COALESCE(invcnt_qoh_after, 0) - cntslip_qty), invcnt_comments = (invcnt_comments || _comments) FROM cntslip WHERE ( (cntslip_cnttag_id=invcnt_id) AND (NOT invcnt_posted) AND (cntslip_id=OLD.cntslip_id) ); END IF; RETURN OLD; END IF; RETURN NEW; END; $$; (DROP FUNCTION public._cntsliptrigger(); publicadminfalse46238125577780_cobillbeforetrigger()FUNCTION|CREATE FUNCTION _cobillbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF (TG_OP = 'DELETE') THEN DELETE FROM cobilltax WHERE (taxhist_parent_id=OLD.cobill_id); RETURN OLD; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._cobillbeforetrigger(); publicadminfalse46238125577781_cobilltrigger()FUNCTIONCREATE FUNCTION _cobilltrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; -- Cache Billing Head SELECT * INTO _r FROM cobmisc WHERE (cobmisc_id=NEW.cobill_cobmisc_id); IF (NOT FOUND) THEN RAISE EXCEPTION 'Billing head not found'; END IF; -- Insert new row IF (TG_OP = 'INSERT') THEN -- Calculate Tax PERFORM calculateTaxHist( 'cobilltax', NEW.cobill_id, COALESCE(_r.cobmisc_taxzone_id, -1), NEW.cobill_taxtype_id, COALESCE(_r.cobmisc_shipdate, CURRENT_DATE), COALESCE(_r.cobmisc_curr_id, -1), (NEW.cobill_qty * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio) ) FROM coitem WHERE (coitem_id=NEW.cobill_coitem_id); END IF; -- Update row IF (TG_OP = 'UPDATE') THEN -- Calculate Tax IF ( (NEW.cobill_qty <> OLD.cobill_qty) OR (NEW.cobill_taxtype_id <> OLD.cobill_taxtype_id) ) THEN PERFORM calculateTaxHist( 'cobilltax', NEW.cobill_id, COALESCE(_r.cobmisc_taxzone_id, -1), NEW.cobill_taxtype_id, COALESCE(_r.cobmisc_shipdate, CURRENT_DATE), COALESCE(_r.cobmisc_curr_id, -1), (NEW.cobill_qty * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio) ) FROM coitem WHERE (coitem_id=NEW.cobill_coitem_id); END IF; END IF; RETURN NEW; END; $$; 'DROP FUNCTION public._cobilltrigger(); publicadminfalse84623125577782_cobmiscbeforetrigger()FUNCTIONCREATE FUNCTION _cobmiscbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF (TG_OP = 'DELETE') THEN DELETE FROM cobmisctax WHERE (taxhist_parent_id=OLD.cobmisc_id); RETURN OLD; END IF; RETURN NEW; END; $$; .DROP FUNCTION public._cobmiscbeforetrigger(); publicadminfalse46238125577783_cobmisctrigger()FUNCTION CREATE FUNCTION _cobmisctrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN -- Something can go here RETURN OLD; END IF; -- Insert new row IF (TG_OP = 'INSERT') THEN -- Calculate Freight Tax IF (NEW.cobmisc_freight <> 0) THEN PERFORM calculateTaxHist( 'cobmisctax', NEW.cobmisc_id, NEW.cobmisc_taxzone_id, getFreightTaxtypeId(), NEW.cobmisc_invcdate, NEW.cobmisc_curr_id, NEW.cobmisc_freight ); END IF; END IF; -- Update row IF (TG_OP = 'UPDATE') THEN -- Calculate Tax IF (COALESCE(NEW.cobmisc_taxzone_id,-1) <> COALESCE(OLD.cobmisc_taxzone_id,-1)) THEN UPDATE cobill SET cobill_taxtype_id=getItemTaxType(itemsite_item_id,NEW.cobmisc_taxzone_id) FROM coitem JOIN itemsite ON (coitem_itemsite_id=itemsite_id) WHERE ((coitem_id=cobill_coitem_id) AND (cobill_cobmisc_id=NEW.cobmisc_id)); END IF; IF ( (NEW.cobmisc_freight <> OLD.cobmisc_freight) OR (COALESCE(NEW.cobmisc_taxzone_id,-1) <> COALESCE(OLD.cobmisc_taxzone_id,-1)) OR (NEW.cobmisc_invcdate <> OLD.cobmisc_invcdate) OR (NEW.cobmisc_curr_id <> OLD.cobmisc_curr_id) ) THEN PERFORM calculateTaxHist( 'cobmisctax', NEW.cobmisc_id, NEW.cobmisc_taxzone_id, getFreightTaxtypeId(), NEW.cobmisc_invcdate, NEW.cobmisc_curr_id, NEW.cobmisc_freight ); PERFORM calculateTaxHist( 'cobilltax', cobill_id, NEW.cobmisc_taxzone_id, cobill_taxtype_id, NEW.cobmisc_invcdate, NEW.cobmisc_curr_id, (cobill_qty * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio) ) FROM cobill JOIN coitem ON (coitem_id = cobill_coitem_id) WHERE (cobill_cobmisc_id = NEW.cobmisc_id); END IF; END IF; RETURN NEW; END; $$; (DROP FUNCTION public._cobmisctrigger(); publicadminfalse46238125587158_coheadafterdeletetrigger()FUNCTIONhCREATE FUNCTION _coheadafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'SO' AND charass_target_id = OLD.cohead_id; RETURN OLD; END; $$; 2DROP FUNCTION public._coheadafterdeletetrigger(); publicadminfalse46238125587168#_coitembeforeimptaxtypedeftrigger()FUNCTIONCREATE FUNCTION _coitembeforeimptaxtypedeftrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _itemid INTEGER := 0; _cohead RECORD; BEGIN IF (NEW.coitem_taxtype_id IS NULL) THEN -- Get the cohead_taxzone_id and cohead_imported SELECT cohead_taxzone_id, cohead_imported INTO _cohead FROM cohead WHERE (cohead_id = NEW.coitem_cohead_id); IF (_cohead.cohead_imported) THEN -- Get the item_id SELECT item_id INTO _itemid FROM item LEFT JOIN itemsite ON item.item_id = itemsite.itemsite_item_id WHERE (itemsite_id = NEW.coitem_itemsite_id); -- Set coitem_taxtype_id default NEW.coitem_taxtype_id = getItemTaxType(_itemid, _cohead.cohead_taxzone_id); END IF; END IF; RETURN NEW; END; $$; :DROP FUNCTION public._coitembeforeimptaxtypedeftrigger(); publicadminfalse84623125577784_commenttrigger()FUNCTIONCREATE FUNCTION _commenttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (NEW.comment_cmnttype_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Comment Type ID.'; ELSIF (NEW.comment_source = 'INCDT') THEN UPDATE incdt SET incdt_updated = now() WHERE incdt_id = NEW.comment_source_id; END IF; RETURN NEW; END; $$; (DROP FUNCTION public._commenttrigger(); publicadminfalse84623125577785_companytrigger()FUNCTIONCREATE FUNCTION _companytrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _used BOOLEAN := false; BEGIN IF (NEW.company_external AND NOT OLD.company_external) THEN IF EXISTS(SELECT accnt_id FROM accnt, company, ( SELECT DISTINCT apaccnt_ap_accnt_id AS test_accnt_id FROM apaccnt UNION SELECT DISTINCT apaccnt_discount_accnt_id FROM apaccnt UNION SELECT DISTINCT apaccnt_prepaid_accnt_id FROM apaccnt UNION SELECT DISTINCT apopen_accnt_id FROM apopen UNION SELECT DISTINCT araccnt_ar_accnt_id FROM araccnt UNION SELECT DISTINCT araccnt_deferred_accnt_id FROM araccnt UNION SELECT DISTINCT araccnt_freight_accnt_id FROM araccnt UNION SELECT DISTINCT araccnt_prepaid_accnt_id FROM araccnt UNION SELECT DISTINCT aropen_accnt_id FROM aropen UNION SELECT DISTINCT bankaccnt_accnt_id FROM bankaccnt UNION SELECT DISTINCT bankaccnt_rec_accnt_id FROM bankaccnt UNION SELECT DISTINCT budgitem_accnt_id FROM budgitem UNION SELECT DISTINCT cashrcptmisc_accnt_id FROM cashrcptmisc UNION SELECT DISTINCT cmhead_misc_accnt_id FROM cmhead UNION SELECT DISTINCT cobmisc_misc_accnt_id FROM cobmisc UNION SELECT DISTINCT cohead_misc_accnt_id FROM cohead UNION SELECT DISTINCT coitem_cos_accnt_id FROM coitem UNION SELECT DISTINCT costcat_adjustment_accnt_id FROM costcat UNION SELECT DISTINCT costcat_asset_accnt_id FROM costcat UNION SELECT DISTINCT costcat_freight_accnt_id FROM costcat UNION SELECT DISTINCT costcat_invcost_accnt_id FROM costcat UNION SELECT DISTINCT costcat_laboroverhead_accnt_id FROM costcat UNION SELECT DISTINCT costcat_liability_accnt_id FROM costcat UNION SELECT DISTINCT costcat_matusage_accnt_id FROM costcat UNION SELECT DISTINCT costcat_mfgscrap_accnt_id FROM costcat UNION SELECT DISTINCT costcat_purchprice_accnt_id FROM costcat UNION SELECT DISTINCT costcat_scrap_accnt_id FROM costcat UNION SELECT DISTINCT costcat_shipasset_accnt_id FROM costcat UNION SELECT DISTINCT costcat_toliability_accnt_id FROM costcat UNION SELECT DISTINCT costcat_transform_accnt_id FROM costcat UNION SELECT DISTINCT costcat_wip_accnt_id FROM costcat UNION SELECT DISTINCT costelem_exp_accnt_id FROM costelem UNION SELECT DISTINCT expcat_exp_accnt_id FROM expcat UNION SELECT DISTINCT expcat_freight_accnt_id FROM expcat UNION SELECT DISTINCT expcat_liability_accnt_id FROM expcat UNION SELECT DISTINCT expcat_purchprice_accnt_id FROM expcat UNION SELECT DISTINCT glseries_accnt_id FROM glseries UNION SELECT DISTINCT gltrans_accnt_id FROM gltrans UNION SELECT DISTINCT invchead_misc_accnt_id FROM invchead UNION SELECT DISTINCT quhead_misc_accnt_id FROM quhead UNION SELECT DISTINCT salesaccnt_cor_accnt_id FROM salesaccnt UNION SELECT DISTINCT salesaccnt_cos_accnt_id FROM salesaccnt UNION SELECT DISTINCT salesaccnt_cow_accnt_id FROM salesaccnt UNION SELECT DISTINCT salesaccnt_credit_accnt_id FROM salesaccnt UNION SELECT DISTINCT salesaccnt_returns_accnt_id FROM salesaccnt UNION SELECT DISTINCT salesaccnt_sales_accnt_id FROM salesaccnt UNION SELECT DISTINCT salescat_ar_accnt_id FROM salescat UNION SELECT DISTINCT salescat_prepaid_accnt_id FROM salescat UNION SELECT DISTINCT salescat_sales_accnt_id FROM salescat UNION SELECT DISTINCT stdjrnlitem_accnt_id FROM stdjrnlitem UNION SELECT DISTINCT tax_sales_accnt_id FROM tax UNION SELECT DISTINCT taxauth_accnt_id FROM taxauth UNION SELECT DISTINCT vodist_accnt_id FROM vodist UNION SELECT DISTINCT warehous_default_accnt_id FROM whsinfo ) AS dummy WHERE ((accnt_id=test_accnt_id) AND (accnt_company=company_number) AND (accnt_company=NEW.company_number)) ) THEN RAISE EXCEPTION 'Cannot make Company % External because it is used in the local database.', NEW.company_number; ELSIF (fetchMetricBool('EnableReturnAuth')) THEN IF EXISTS(SELECT accnt_id FROM accnt, company, ( SELECT DISTINCT rahead_misc_accnt_id AS test_accnt_id FROM rahead UNION SELECT DISTINCT raitem_cos_accnt_id FROM raitem ) AS dummy WHERE ((accnt_id=test_accnt_id) AND (accnt_company=company_number) AND (accnt_company=NEW.company_number)) ) THEN RAISE EXCEPTION 'Cannot make Company % External because it is used in the local database.', NEW.company_number; END IF; END IF; END IF; RETURN NEW; END; $$; (DROP FUNCTION public._companytrigger(); publicadminfalse84623125577786_contrctaftertrigger()FUNCTIONCREATE FUNCTION _contrctaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN -- synchronize contract effectivity with item source effectivity IF (NEW.contrct_effective <> OLD.contrct_effective) THEN UPDATE itemsrc SET itemsrc_effective=NEW.contrct_effective WHERE itemsrc_contrct_id=NEW.contrct_id; END IF; IF (NEW.contrct_expires <> OLD.contrct_expires) THEN UPDATE itemsrc SET itemsrc_expires=NEW.contrct_expires WHERE itemsrc_contrct_id=NEW.contrct_id; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._contrctaftertrigger(); publicadminfalse46238125587175_crmacctafterdeletetrigger()FUNCTIONoCREATE FUNCTION _crmacctafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'CRMACCT' AND charass_target_id = OLD.crmacct_id; RETURN OLD; END; $$; 3DROP FUNCTION public._crmacctafterdeletetrigger(); publicadminfalse46238125577787_crmacctaftertrigger()FUNCTIONpCREATE FUNCTION _crmacctaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; _gotpriv BOOLEAN; BEGIN /* update _number and _name separately to propagate just what changed. the priv manipulation allows targeted updates of crmaccount-maintained data */ IF TG_OP = 'UPDATE' AND (OLD.crmacct_number != NEW.crmacct_number OR OLD.crmacct_name != NEW.crmacct_name) THEN IF NEW.crmacct_cust_id IS NOT NULL THEN UPDATE custinfo SET cust_number = NEW.crmacct_number WHERE ((cust_id=NEW.crmacct_cust_id) AND (cust_number!=NEW.crmacct_number)); UPDATE custinfo SET cust_name = NEW.crmacct_name WHERE ((cust_id=NEW.crmacct_cust_id) AND (cust_name!=NEW.crmacct_name)); END IF; IF NEW.crmacct_emp_id IS NOT NULL THEN UPDATE emp SET emp_code = NEW.crmacct_number WHERE ((emp_id=NEW.crmacct_emp_id) AND (emp_code!=NEW.crmacct_number)); UPDATE emp SET emp_name = NEW.crmacct_name WHERE ((emp_id=NEW.crmacct_emp_id) AND (emp_name!=NEW.crmacct_name)); END IF; IF (NEW.crmacct_prospect_id IS NOT NULL) THEN UPDATE prospect SET prospect_number = NEW.crmacct_number WHERE ((prospect_id=NEW.crmacct_prospect_id) AND (prospect_number!=NEW.crmacct_number)); UPDATE prospect SET prospect_name = NEW.crmacct_name WHERE ((prospect_id=NEW.crmacct_prospect_id) AND (prospect_name!=NEW.crmacct_name)); END IF; IF (NEW.crmacct_salesrep_id IS NOT NULL) THEN UPDATE salesrep SET salesrep_number = NEW.crmacct_number WHERE ((salesrep_id=NEW.crmacct_salesrep_id) AND (salesrep_number!=NEW.crmacct_number)); UPDATE salesrep SET salesrep_name = NEW.crmacct_name WHERE ((salesrep_id=NEW.crmacct_salesrep_id) AND (salesrep_name!=NEW.crmacct_name)); END IF; IF (NEW.crmacct_taxauth_id IS NOT NULL) THEN UPDATE taxauth SET taxauth_code = NEW.crmacct_number WHERE ((taxauth_id=NEW.crmacct_taxauth_id) AND (taxauth_code!=NEW.crmacct_number)); UPDATE taxauth SET taxauth_name = NEW.crmacct_name WHERE ((taxauth_id=NEW.crmacct_taxauth_id) AND (taxauth_name!=NEW.crmacct_name)); END IF; IF (NEW.crmacct_vend_id IS NOT NULL) THEN UPDATE vendinfo SET vend_number = NEW.crmacct_number WHERE ((vend_id=NEW.crmacct_vend_id) AND (vend_number!=NEW.crmacct_number)); UPDATE vendinfo SET vend_name = NEW.crmacct_name WHERE ((vend_id=NEW.crmacct_vend_id) AND (vend_name!=NEW.crmacct_name)); END IF; END IF; IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN -- Link Primary and Secondary Contacts to this Account if they are not already IF (NEW.crmacct_cntct_id_1 IS NOT NULL) THEN UPDATE cntct SET cntct_crmacct_id = NEW.crmacct_id WHERE cntct_id=NEW.crmacct_cntct_id_1 AND COALESCE(cntct_crmacct_id, -1) != NEW.crmacct_id; END IF; IF (NEW.crmacct_cntct_id_2 IS NOT NULL) THEN UPDATE cntct SET cntct_crmacct_id = NEW.crmacct_id WHERE cntct_id=NEW.crmacct_cntct_id_2 AND COALESCE(cntct_crmacct_id, -1) != NEW.crmacct_id; END IF; -- cannot have fkey references to system catalogs so enforce them here IF (NEW.crmacct_usr_username IS NOT NULL) THEN IF (NOT EXISTS(SELECT usr_username FROM usr WHERE usr_username=NEW.crmacct_usr_username)) THEN RAISE EXCEPTION 'User % does not exist so this CRM Account Number is invalid.', NEW.crmacct_usr_username; END IF; IF (TG_OP = 'UPDATE') THEN -- reminder: this evaluates to false if either is NULL IF (NEW.crmacct_usr_username != OLD.crmacct_usr_username) THEN RAISE EXCEPTION 'Cannot change the user name for %', OLD.crmacct_usr_username; END IF; END IF; UPDATE usrpref SET usrpref_value = NEW.crmacct_name WHERE ((usrpref_username=NEW.crmacct_usr_username) AND (usrpref_name='propername') AND (usrpref_value!=NEW.crmacct_name)); END IF; ELSIF (TG_OP = 'DELETE') THEN IF (OLD.crmacct_cust_id IS NOT NULL) THEN RAISE EXCEPTION 'Cannot delete CRM Account because it is a Customer [xtuple: deleteCrmAccount, -1]'; END IF; IF (OLD.crmacct_emp_id IS NOT NULL) THEN RAISE EXCEPTION 'Cannot delete CRM Account because it is an Employee [xtuple: deleteCrmAccount, -7]'; END IF; IF (OLD.crmacct_prospect_id IS NOT NULL) THEN RAISE EXCEPTION 'Cannot delete CRM Account because it is a Prospect [xtuple: deleteCrmAccount, -3]'; END IF; DELETE FROM salesrep WHERE salesrep_id = OLD.crmacct_salesrep_id; IF (OLD.crmacct_salesrep_id IS NOT NULL) THEN RAISE EXCEPTION 'Cannot delete CRM Account because it is a Sales Rep [xtuple: deleteCrmAccount, -6]'; END IF; IF (OLD.crmacct_taxauth_id IS NOT NULL) THEN RAISE EXCEPTION 'Cannot delete CRM Account because it is a Tax Authority [xtuple: deleteCrmAccount, -5]'; END IF; IF (EXISTS(SELECT usename FROM pg_user WHERE usename=OLD.crmacct_usr_username)) THEN RAISE EXCEPTION 'Cannot delete CRM Account because it is a User [xtuple: deleteCrmAccount, -8]'; END IF; IF (OLD.crmacct_vend_id IS NOT NULL) THEN RAISE EXCEPTION 'Cannot delete CRM Account because it is a Vendor [xtuple: deleteCrmAccount, -2]'; END IF; DELETE FROM imageass WHERE (imageass_source_id=OLD.crmacct_id) AND (imageass_source='CRMA'); DELETE FROM url WHERE (url_source_id=OLD.crmacct_id) AND (url_source='CRMA'); END IF; SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (_cmnttypeid IS NOT NULL) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'CRMA', NEW.crmacct_id, ('Created by ' || getEffectiveXtUser())); ELSIF (TG_OP = 'DELETE') THEN PERFORM postComment(_cmnttypeid, 'CRMA', OLD.crmacct_id, 'Deleted "' || OLD.crmacct_number || '"'); END IF; END IF; IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._crmacctaftertrigger(); publicadminfalse46238125577789_crmacctbeforetrigger()FUNCTION CREATE FUNCTION _crmacctbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _count INTEGER; BEGIN -- disallow reusing crmacct_numbers IF (TG_OP IN ('INSERT', 'UPDATE')) THEN IF (TG_OP = 'INSERT' AND fetchMetricText('CRMAccountNumberGeneration') IN ('A','O')) THEN PERFORM clearNumberIssue('CRMAccountNumber', NEW.crmacct_number); END IF; NEW.crmacct_usr_username := LOWER(TRIM(NEW.crmacct_usr_username)); IF (NEW.crmacct_usr_username = '') THEN NEW.crmacct_usr_username = NULL; END IF; NEW.crmacct_owner_username := LOWER(TRIM(NEW.crmacct_owner_username)); IF (COALESCE(NEW.crmacct_owner_username, '') = '') THEN NEW.crmacct_owner_username = getEffectiveXtUser(); END IF; IF (NEW.crmacct_competitor_id < 0) THEN NEW.crmacct_competitor_id := NULL; END IF; IF (NEW.crmacct_partner_id < 0) THEN NEW.crmacct_partner_id := NULL; END IF; NEW.crmacct_number = UPPER(NEW.crmacct_number); IF (TG_OP = 'UPDATE') THEN -- TODO: why not ALTER USER OLD.crmacct_number RENAME TO LOWER(NEW.crmacct_number)? IF (NEW.crmacct_number != UPPER(OLD.crmacct_number) AND NEW.crmacct_usr_username IS NOT NULL AND UPPER(NEW.crmacct_usr_username) != NEW.crmacct_number) THEN RAISE EXCEPTION 'The CRM Account % is associated with a system User so the number cannot be changed.', NEW.crmacct_number; END IF; -- It appears possible to remove a user account without cleaning up the CRM account (#25291) -- Tidy up CRM Account in this scenario to prevent errors IF (NEW.crmacct_usr_username IS NOT NULL) THEN IF (NOT EXISTS(SELECT usr_username FROM usr WHERE usr_username=NEW.crmacct_usr_username)) THEN NEW.crmacct_usr_username = NULL; END IF; END IF; END IF; ELSIF (TG_OP = 'DELETE') THEN UPDATE cntct SET cntct_crmacct_id = NULL WHERE cntct_crmacct_id = OLD.crmacct_id; DELETE FROM docass WHERE docass_source_id = OLD.crmacct_id AND docass_source_type = 'CRMA'; DELETE FROM docass WHERE docass_target_id = OLD.crmacct_id AND docass_target_type = 'CRMA'; GET DIAGNOSTICS _count = ROW_COUNT; RAISE DEBUG 'updated % contacts', _count; RETURN OLD; END IF; RETURN NEW; END; $$; .DROP FUNCTION public._crmacctbeforetrigger(); publicadminfalse84623125577790_custaftertrigger()FUNCTIONCREATE FUNCTION _custaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; _whsId INTEGER := -1; BEGIN IF (TG_OP = 'INSERT') THEN -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE LOOP UPDATE crmacct SET crmacct_cust_id=NEW.cust_id, crmacct_name=NEW.cust_name, crmacct_prospect_id=NULL WHERE crmacct_number=NEW.cust_number; IF (FOUND) THEN DELETE FROM prospect WHERE prospect_id=NEW.cust_id; EXIT; END IF; BEGIN INSERT INTO crmacct(crmacct_number, crmacct_name, crmacct_active, crmacct_type, crmacct_cust_id, crmacct_cntct_id_1, crmacct_cntct_id_2 ) VALUES (NEW.cust_number, NEW.cust_name, NEW.cust_active, 'O', NEW.cust_id, NEW.cust_cntct_id, NEW.cust_corrcntct_id); EXIT; EXCEPTION WHEN unique_violation THEN -- do nothing, and loop to try the UPDATE again END; END LOOP; PERFORM updateCharAssignment('C', NEW.cust_id, char_id, charass_value) FROM custtype JOIN charass ON (custtype_id=charass_target_id AND charass_target_type='CT') JOIN char ON (charass_char_id=char_id) WHERE ((custtype_id=NEW.cust_custtype_id) AND (custtype_char) AND (charass_default)); ELSIF (TG_OP = 'UPDATE') THEN UPDATE crmacct SET crmacct_number = NEW.cust_number WHERE ((crmacct_cust_id=NEW.cust_id) AND (crmacct_number!=NEW.cust_number)); UPDATE crmacct SET crmacct_name = NEW.cust_name WHERE ((crmacct_cust_id=NEW.cust_id) AND (crmacct_name!=NEW.cust_name)); END IF; IF (TG_OP = 'INSERT') THEN PERFORM postEvent('NewCustomer', 'C', NEW.cust_id, NULL, NEW.cust_number, NULL, NULL, NULL, NULL); END IF; IF (fetchMetricBool('CustomerChangeLog')) THEN SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (_cmnttypeid IS NOT NULL) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.cust_number <> NEW.cust_number) THEN PERFORM postComment( _cmnttypeid, 'C', NEW.cust_id, ('Number changed from "' || OLD.cust_number || '" to "' || NEW.cust_number || '"') ); END IF; IF (OLD.cust_name <> NEW.cust_name) THEN PERFORM postComment( _cmnttypeid, 'C', NEW.cust_id, ('Name changed from "' || OLD.cust_name || '" to "' || NEW.cust_name || '"') ); END IF; IF (OLD.cust_active <> NEW.cust_active) THEN PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id, CASE WHEN NEW.cust_active THEN 'Activated' ELSE 'Deactivated' END); END IF; IF (OLD.cust_discntprcnt <> NEW.cust_discntprcnt) THEN PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id, ('Discount changed from "' || formatprcnt(OLD.cust_discntprcnt) || '%" to "' || formatprcnt(NEW.cust_discntprcnt) || '%"') ); END IF; IF (OLD.cust_creditlmt <> NEW.cust_creditlmt) THEN PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id, ('Credit Limit changed from ' || formatMoney(OLD.cust_creditlmt) || ' to ' || formatMoney(NEW.cust_creditlmt))); END IF; IF (OLD.cust_creditstatus <> NEW.cust_creditstatus) THEN PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id, ('Credit Status Changed from "' || CASE OLD.cust_creditstatus WHEN 'G' THEN 'In Good Standing' WHEN 'W' THEN 'Credit Warning' WHEN 'H' THEN 'Credit Hold' ELSE 'Unknown/Error' END || '" to "' || CASE NEW.cust_creditstatus WHEN 'G' THEN 'In Good Standing' WHEN 'W' THEN 'Credit Warning' WHEN 'H' THEN 'Credit Hold' ELSE 'Unknown/Error' END || '"') ); END IF; IF (OLD.cust_custtype_id <> NEW.cust_custtype_id) THEN PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id, ('Customer type changed from "' || (SELECT custtype_code FROM custtype WHERE custtype_id = OLD.cust_custtype_id) || '" to "' || (SELECT custtype_code FROM custtype WHERE custtype_id = NEW.cust_custtype_id) || '"') ); END IF; IF (COALESCE(OLD.cust_gracedays,-1) <> COALESCE(NEW.cust_gracedays,-1)) THEN PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id, ('Grace Days changed from "' || COALESCE(TEXT(OLD.cust_gracedays), 'Default') || '" to "' || COALESCE(TEXT(NEW.cust_gracedays), 'Default') || '"')); END IF; IF (OLD.cust_terms_id <> NEW.cust_terms_id) THEN PERFORM postComment(_cmnttypeid, 'C', NEW.cust_id, ('Terms changed from "' || (SELECT terms_code FROM terms WHERE terms_id = OLD.cust_terms_id) || '" to "' || (SELECT terms_code FROM terms WHERE terms_id = NEW.cust_terms_id) || '"')); END IF; END IF; END IF; END IF; RETURN NEW; END; $$; *DROP FUNCTION public._custaftertrigger(); publicadminfalse46238125577791_custinfoafterdeletetrigger()FUNCTIONCREATE FUNCTION _custinfoafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- handle transitory state when converting customer to prospect IF EXISTS(SELECT quhead_id FROM quhead WHERE (quhead_cust_id=OLD.cust_id) AND NOT EXISTS(SELECT prospect_id FROM prospect WHERE prospect_id=OLD.cust_id)) THEN RAISE EXCEPTION '[xtuple: deleteCustomer, -8]'; END IF; IF EXISTS(SELECT invchead_id FROM invchead WHERE (invchead_cust_id=OLD.cust_id)) THEN RAISE EXCEPTION '[xtuple: deleteCustomer, -7]'; END IF; -- end TODO IF EXISTS(SELECT checkhead_recip_id FROM checkhead WHERE ((checkhead_recip_id=OLD.cust_id) AND (checkhead_recip_type='C'))) THEN RAISE EXCEPTION '[xtuple: deleteCustomer, -6]'; END IF; DELETE FROM taxreg WHERE ((taxreg_rel_type='C') AND (taxreg_rel_id=OLD.cust_id)); DELETE FROM ipsass WHERE (ipsass_cust_id=OLD.cust_id); DELETE FROM docass WHERE docass_source_id = OLD.cust_id AND docass_source_type = 'C'; DELETE FROM docass WHERE docass_target_id = OLD.cust_id AND docass_target_type = 'C'; DELETE FROM charass WHERE charass_target_type = 'C' AND charass_target_id = OLD.cust_id; IF (fetchMetricBool('CustomerChangeLog')) THEN PERFORM postComment(cmnttype_id, 'C', OLD.cust_id, ('Deleted "' || OLD.cust_number || '"')) FROM cmnttype WHERE (cmnttype_name='ChangeLog'); END IF; RETURN OLD; END; $$; 4DROP FUNCTION public._custinfoafterdeletetrigger(); publicadminfalse46238125577792_custinfobeforedeletetrigger()FUNCTIONCREATE FUNCTION _custinfobeforedeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF NOT (checkPrivilege('MaintainCustomerMasters')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Customers.'; END IF; UPDATE crmacct SET crmacct_cust_id = NULL WHERE crmacct_cust_id = OLD.cust_id; RETURN OLD; END; $$; 5DROP FUNCTION public._custinfobeforedeletetrigger(); publicadminfalse84623125577793_custtrigger()FUNCTIONCREATE FUNCTION _custtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF NOT (checkPrivilege('MaintainCustomerMasters') OR checkPrivilege('PostMiscInvoices')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Customers.'; END IF; IF (NEW.cust_number IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Customer Number.'; END IF; IF (LENGTH(COALESCE(NEW.cust_name,''))=0) THEN RAISE EXCEPTION 'You must supply a valid Customer Name.'; END IF; IF (NEW.cust_custtype_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Customer Type ID.'; END IF; IF (NEW.cust_salesrep_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Sales Rep ID.'; END IF; IF (NEW.cust_terms_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Terms Code ID.'; END IF; IF (TG_OP = 'INSERT' AND fetchMetricText('CRMAccountNumberGeneration') IN ('A','O')) THEN PERFORM clearNumberIssue('CRMAccountNumber', NEW.cust_number); END IF; NEW.cust_number := UPPER(NEW.cust_number); RETURN NEW; END; $$; %DROP FUNCTION public._custtrigger(); publicadminfalse84623125577794_custtypeafterdeletetrigger()FUNCTION6CREATE FUNCTION _custtypeafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (SELECT fetchMetricValue('DefaultCustType') = OLD.custtype_id) THEN RAISE EXCEPTION 'Cannot delete the default Customer Type [xtuple: custtype, -1, %]', OLD.custtype_code; END IF; DELETE FROM charass WHERE charass_target_type = 'CT' AND charass_target_id = OLD.custtype_id; RETURN OLD; END; $$; 4DROP FUNCTION public._custtypeafterdeletetrigger(); publicadminfalse84623125577795_custtypetrigger()FUNCTIONCREATE FUNCTION _custtypetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check BOOLEAN; _code TEXT; BEGIN -- Checks IF (TG_OP IN ('INSERT','UPDATE')) THEN IF (LENGTH(COALESCE(NEW.custtype_code, ''))=0) THEN RAISE EXCEPTION 'You must supply a valid Customer Type Code.'; END IF; SELECT custtype_code INTO _code FROM custtype WHERE ( (UPPER(custtype_code)=UPPER(NEW.custtype_code)) AND (custtype_id<>NEW.custtype_id) ); IF (FOUND) THEN RAISE EXCEPTION 'The Customer Type Code entered cannot be used as it is in use.'; END IF; END IF; RETURN NEW; END; $$; )DROP FUNCTION public._custtypetrigger(); publicadminfalse84623125577796_docasstrigger()FUNCTIONwCREATE FUNCTION _docasstrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (NEW.docass_source_type = 'INCDT') THEN UPDATE incdt SET incdt_updated = now() WHERE incdt_id = NEW.docass_source_id; END IF; RETURN NEW; END; $$; 'DROP FUNCTION public._docasstrigger(); publicadminfalse84623 125586967_docinfo(integer, text)FUNCTION#CREATE FUNCTION _docinfo(req_id integer, req_type text) RETURNS SETOF _docinfo LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- Return all document associations, optionally limited to the given document type DECLARE _current TEXT := ''; _row _docinfo%rowtype; _desc record; _crm record; _rev TEXT := $$SELECT '' AS revnumber, '' AS revname, '' AS revdesc, -1 AS revid, '' AS revtype$$; _reverseQ TEXT := $$SELECT %s AS revnumber, %s AS revname, %s AS revdesc, %s AS revid, '%s' AS revtype FROM %s %s$$; _docassQ TEXT := $$SELECT docass_id AS id, %s AS target_number, %s AS target_type, %s AS target_id, %s AS source_type, %s AS source_id, %s AS name, %s AS description, docass_purpose AS purpose FROM docass JOIN %s ON docass_target_id = %s %s %s WHERE docass_target_type = '%s' AND docass_source_id = %s AND docass_source_type = '%s' UNION ALL SELECT docass_id AS id, revnumber AS target_number, %s AS target_type, %s AS target_id, %s AS source_type, %s AS source_id, revname AS name, revdesc AS description, CASE WHEN docass_purpose = 'A' THEN 'C' WHEN docass_purpose = 'C' THEN 'A' ELSE docass_purpose END AS purpose FROM docass JOIN %s ON docass_target_id = %s JOIN rev ON revid = docass_source_id AND revtype = docass_source_type %s WHERE docass_target_type = '%s' AND docass_source_id = %s AND docass_source_type = '%s' $$; _imgQ TEXT := $$SELECT imageass_id AS id, image_id::text AS target_number, 'IMG' AS target_type, imageass_image_id AS target_id, imageass_source AS source_type, imageass_source_id AS source_id, image_name AS name, image_descrip AS description, imageass_purpose AS purpose FROM imageass JOIN image ON imageass_image_id=image_id WHERE true AND imageass_source_id = %s AND imageass_source = '%s' $$; _urlQ TEXT := $$SELECT url_id AS id, url_id::text AS target_number, 'URL' AS target_type, url_id AS target_id, url_source AS source_type, url_source_id AS source_id, url_title AS name, url_url AS description, 'S' AS doc_purpose FROM url WHERE (url_stream IS NULL) AND url_source_id = %s AND url_source = '%s' $$; _fileQ TEXT := $$SELECT url_id AS id, url_id::text AS target_number, 'FILE' AS target_type, url_id AS target_id, url_source AS source_type, url_source_id AS source_id, url_title AS name, url_url AS description, 'S' AS doc_purpose FROM url WHERE (url_stream IS NOT NULL) AND url_source_id = %s AND url_source = '%s' $$; _crmIdField TEXT := ''; _crmChildIdField TEXT := ''; BEGIN -- TODO: normalize image, url, and file into docass _current := _current || format(_imgQ, req_id, req_type); _current := _current || ' UNION ALL ' || format(_urlQ, req_id, req_type); _current := _current || ' UNION ALL ' || format(_fileQ, req_id, req_type); SELECT source.* INTO _crm FROM source WHERE source_docass = 'CRMA'; -- must match populate_source.sql FOR _desc IN SELECT source.* FROM source JOIN pg_class c on source_table = relname JOIN pg_namespace n on relnamespace = n.oid JOIN regexp_split_to_table(buildSearchPath(), E',\\s*') sp on nspname = sp WHERE relkind = 'r' LOOP _rev := _rev || ' UNION ALL ' || format(_reverseQ, _desc.source_number_field, _desc.source_name_field, _desc.source_desc_field, _desc.source_key_field, _desc.source_docass, _desc.source_table, _desc.source_joins); _current := _current || ' UNION ALL ' || format(_docassQ, _desc.source_number_field, 'docass_target_type', 'docass_target_id', 'docass_source_type', 'docass_source_id', _desc.source_name_field, _desc.source_desc_field, _desc.source_table, _desc.source_key_field, _desc.source_joins, '', _desc.source_docass, req_id, req_type, 'docass_source_type', 'docass_source_id', 'docass_target_type', 'docass_target_id', _desc.source_table, _desc.source_key_field, _desc.source_joins, _desc.source_docass, req_id, req_type); -- must match populate_source.sql IF _desc.source_docass IN ('C', 'V', 'EMP', 'PSPCT', 'SR', 'USR', 'TAXAUTH') THEN /* for each type of CRM Account child (e.g. customer, vendor), - return all CRM Account child doc associations as belonging to the CRM Account - return all CRM Account document associations as belonging to the child */ CASE _desc.source_docass WHEN 'C' THEN _crmIdField := 'crmacct_cust_id'; _crmChildIdField := 'cust_id'; WHEN 'V' THEN _crmIdField := 'crmacct_vend_id'; _crmChildIdField := 'vend_id'; WHEN 'EMP' THEN _crmIdField := 'crmacct_emp_id'; _crmChildIdField := 'emp_id'; WHEN 'PSPCT' THEN _crmIdField := 'crmacct_prospect_id'; _crmChildIdField := 'prospect_id'; WHEN 'SR' THEN _crmIdField := 'crmacct_salesrep_id'; _crmChildIdField := 'salesrep_id'; WHEN 'USR' THEN _crmIdField := 'crmacct_usr_username'; _crmChildIdField := 'usr_username'; WHEN 'TAXAUTH' THEN _crmIdField := 'crmacct_taxauth_id'; _crmChildIdField := 'taxauth_id'; END CASE; _current := _current || ' UNION ALL ' || format(_docassQ, _crm.source_number_field, '$$' || _crm.source_docass || '$$', _crm.source_key_field, 'docass_source_type', 'docass_source_id', _desc.source_name_field, _desc.source_desc_field, _desc.source_table, _desc.source_key_field, _desc.source_joins, format('JOIN crmacct ON %s = %s', _crmIdField, _crmChildIdField), _desc.source_docass, req_id, req_type, 'docass_source_type', 'docass_source_id', '$$' || _crm.source_docass || '$$', _crm.source_key_field, _desc.source_table, _desc.source_key_field, format('JOIN crmacct ON %s = %s', _crmIdField, _crmChildIdField), _desc.source_docass, req_id, req_type); END IF; END LOOP; _current := 'WITH rev AS (' || _rev || ') ' || _current; FOR _row IN EXECUTE(_current) LOOP RETURN NEXT _row; END LOOP; RETURN; END; $_$; >DROP FUNCTION public._docinfo(req_id integer, req_type text); publicadminfalse462342258125577797_empafterdeletetrigger()FUNCTIONGCREATE FUNCTION _empafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (fetchMetricBool('EmployeeChangeLog')) THEN PERFORM postComment(cmnttype_id, 'EMP', OLD.emp_id, ('Deleted "' || OLD.emp_code || '"')) FROM cmnttype WHERE (cmnttype_name='ChangeLog'); END IF; DELETE FROM charass WHERE charass_target_type = 'EMP' AND charass_target_id = OLD.emp_id; RETURN OLD; END; $$; /DROP FUNCTION public._empafterdeletetrigger(); publicadminfalse84623125577798_empaftertrigger()FUNCTIONCREATE FUNCTION _empaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; _newcrmacctname TEXT; BEGIN IF (TG_OP = 'INSERT') THEN -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE LOOP UPDATE crmacct SET crmacct_emp_id=NEW.emp_id, crmacct_name=NEW.emp_name WHERE crmacct_number=NEW.emp_code; IF (FOUND) THEN EXIT; END IF; BEGIN INSERT INTO crmacct(crmacct_number, crmacct_name, crmacct_active, crmacct_type, crmacct_emp_id, crmacct_cntct_id_1 ) VALUES (NEW.emp_code, NEW.emp_name, NEW.emp_active, 'I', NEW.emp_id, NEW.emp_cntct_id); EXIT; EXCEPTION WHEN unique_violation THEN -- do nothing, and loop to try the UPDATE again END; END LOOP; /* TODO: default characteristic assignments based on empgrp? */ ELSIF (TG_OP = 'UPDATE') THEN UPDATE crmacct SET crmacct_number = NEW.emp_code WHERE ((crmacct_emp_id=NEW.emp_id) AND (crmacct_number!=NEW.emp_code)); UPDATE crmacct SET crmacct_name = NEW.emp_name WHERE ((crmacct_emp_id=NEW.emp_id) AND (crmacct_name!=NEW.emp_name)); END IF; IF (fetchMetricBool('EmployeeChangeLog')) THEN SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (_cmnttypeid IS NOT NULL) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'EMP', NEW.emp_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.emp_number <> NEW.emp_number) THEN PERFORM postComment(_cmnttypeid, 'EMP', NEW.emp_id, ('Number Changed from "' || OLD.emp_number || '" to "' || NEW.emp_number || '"')); END IF; IF (OLD.emp_code <> NEW.emp_code) THEN PERFORM postComment(_cmnttypeid, 'EMP', NEW.emp_id, ('Code Changed from "' || OLD.emp_code || '" to "' || NEW.emp_code || '"')); END IF; IF (OLD.emp_active <> NEW.emp_active) THEN PERFORM postComment(_cmnttypeid, 'EMP', NEW.emp_id, CASE WHEN NEW.emp_active THEN 'Activated' ELSE 'Deactivated' END); END IF; IF (COALESCE(OLD.emp_dept_id, -1) <> COALESCE(NEW.emp_dept_id, -1)) THEN PERFORM postComment(_cmnttypeid, 'EMP', NEW.emp_id, ('Department Changed from "' || COALESCE((SELECT dept_number FROM dept WHERE dept_id=OLD.emp_dept_id), '') || '" to "' || COALESCE((SELECT dept_number FROM dept WHERE dept_id=NEW.emp_dept_id), '') || '"')); END IF; IF (COALESCE(OLD.emp_shift_id, -1) <> COALESCE(NEW.emp_shift_id, -1)) THEN PERFORM postComment(_cmnttypeid, 'EMP', NEW.emp_id, ('Shift Changed from "' || COALESCE((SELECT shift_number FROM shift WHERE shift_id=OLD.emp_shift_id), '') || '" to "' || COALESCE((SELECT shift_number FROM shift WHERE shift_id=NEW.emp_shift_id), '') || '"')); END IF; END IF; END IF; END IF; RETURN NEW; END; $$; )DROP FUNCTION public._empaftertrigger(); publicadminfalse46238125577799_empbeforedeletetrigger()FUNCTIONCREATE FUNCTION _empbeforedeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF NOT (checkPrivilege('MaintainEmployees')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Employees.'; END IF; UPDATE crmacct SET crmacct_emp_id = NULL WHERE crmacct_emp_id = OLD.emp_id; UPDATE salesrep SET salesrep_emp_id = NULL WHERE salesrep_emp_id = OLD.emp_id; DELETE FROM docass WHERE docass_source_id = OLD.emp_id AND docass_source_type = 'EMP'; DELETE FROM docass WHERE docass_target_id = OLD.emp_id AND docass_target_type = 'EMP'; RETURN OLD; END; $$; 0DROP FUNCTION public._empbeforedeletetrigger(); publicadminfalse84623125577800_empbeforetrigger()FUNCTIONCREATE FUNCTION _empbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF NOT (checkPrivilege('MaintainEmployees')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Employees.'; END IF; IF (NEW.emp_code IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Employee Code.'; END IF; IF (NEW.emp_number IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Employee Number.'; END IF; IF (NEW.emp_id = NEW.emp_mgr_emp_id) THEN RAISE EXCEPTION 'An Employee may not be his or her own Manager.'; END IF; -- ERROR: cannot use column references in default expression IF (NEW.emp_name IS NULL) THEN NEW.emp_name = COALESCE(formatCntctName(NEW.emp_cntct_id), NEW.emp_number); END IF; IF (TG_OP = 'INSERT' AND fetchMetricText('CRMAccountNumberGeneration') IN ('A','O')) THEN PERFORM clearNumberIssue('CRMAccountNumber', NEW.emp_number); END IF; NEW.emp_code := UPPER(NEW.emp_code); -- deprecated column emp_username IF (TG_OP = 'UPDATE' AND LOWER(NEW.emp_username) != LOWER(NEW.emp_code) AND EXISTS(SELECT 1 FROM crmacct WHERE crmacct_emp_id = NEW.emp_id AND crmacct_usr_username IS NOT NULL)) THEN NEW.emp_username = LOWER(NEW.emp_code); END IF; RETURN NEW; END; $$; *DROP FUNCTION public._empbeforetrigger(); publicadminfalse84623125577801_evntlogafterinserttrigger()FUNCTIONCREATE FUNCTION _evntlogafterinserttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; BEGIN IF (NEW.evntlog_username = 'autopilot') THEN SELECT * INTO _r FROM evnttype WHERE (evnttype_id=NEW.evntlog_evnttype_id); IF (_r.evnttype_name = 'SoCreated') THEN PERFORM createPrjToSale(NEW.evntlog_ord_id); END IF; END IF; RETURN NEW; END; $$; 3DROP FUNCTION public._evntlogafterinserttrigger(); publicadminfalse84623125577802_gltransaltertrigger()FUNCTION CREATE FUNCTION _gltransaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _externalCompany BOOLEAN := false; _updated BOOLEAN := false; BEGIN IF(TG_OP='DELETE') THEN RAISE EXCEPTION 'You may not delete G/L Transactions once they have been created.'; ELSIF (TG_OP = 'UPDATE') THEN SELECT company_external INTO _externalCompany FROM company JOIN accnt ON (company_number=accnt_company) WHERE (accnt_id=NEW.gltrans_accnt_id); IF (_externalCompany) THEN RAISE EXCEPTION 'Transactions are not allowed for G/L Accounts with External Company segments.'; END IF; IF(OLD.gltrans_id != NEW.gltrans_id) THEN _updated := true; ELSIF(OLD.gltrans_date != NEW.gltrans_date) THEN _updated := true; ELSIF(OLD.gltrans_accnt_id != NEW.gltrans_accnt_id) THEN _updated := true; ELSIF(OLD.gltrans_amount != NEW.gltrans_amount) THEN _updated := true; ELSIF(OLD.gltrans_username != NEW.gltrans_username) THEN _updated := true; ELSIF( (OLD.gltrans_sequence IS NULL AND NEW.gltrans_sequence IS NOT NULL) OR (OLD.gltrans_sequence IS NOT NULL AND NEW.gltrans_sequence IS NULL) OR (COALESCE(OLD.gltrans_sequence,0) != COALESCE(NEW.gltrans_sequence,0)) ) THEN _updated := true; ELSIF( (OLD.gltrans_created IS NULL AND NEW.gltrans_created IS NOT NULL) OR (OLD.gltrans_created IS NOT NULL AND NEW.gltrans_created IS NULL) OR (COALESCE(OLD.gltrans_created,now()) != COALESCE(NEW.gltrans_created,now())) ) THEN _updated := true; ELSIF( (OLD.gltrans_source IS NULL AND NEW.gltrans_source IS NOT NULL) OR (OLD.gltrans_source IS NOT NULL AND NEW.gltrans_source IS NULL) OR (COALESCE(OLD.gltrans_source,'') != COALESCE(NEW.gltrans_source,'')) ) THEN _updated := true; ELSIF( (OLD.gltrans_docnumber IS NULL AND NEW.gltrans_docnumber IS NOT NULL) OR (OLD.gltrans_docnumber IS NOT NULL AND NEW.gltrans_docnumber IS NULL) OR (COALESCE(OLD.gltrans_docnumber,'') != COALESCE(NEW.gltrans_docnumber,'')) ) THEN _updated := true; ELSIF( (OLD.gltrans_doctype IS NULL AND NEW.gltrans_doctype IS NOT NULL) OR (OLD.gltrans_doctype IS NOT NULL AND NEW.gltrans_doctype IS NULL) OR (COALESCE(OLD.gltrans_doctype,'') != COALESCE(NEW.gltrans_doctype,'')) ) THEN _updated := true; END IF; IF(_updated) THEN RAISE EXCEPTION 'You may not alter some G/L Transaction fields once they have been created.'; END IF; ELSE RAISE EXCEPTION 'trigger for gltrans table called in unexpected state.'; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._gltransaltertrigger(); publicadminfalse84623125577803_gltransinserttrigger()FUNCTIONCREATE FUNCTION _gltransinserttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _reqNotes BOOLEAN; _externalCompany BOOLEAN := false; BEGIN -- Checks -- Start with privileges IF ((NEW.gltrans_doctype='JE') AND (NOT checkPrivilege('PostJournalEntries'))) THEN RAISE EXCEPTION 'You do not have privileges to create a Journal Entry.'; END IF; SELECT company_external INTO _externalCompany FROM company JOIN accnt ON (company_number=accnt_company) WHERE (accnt_id=NEW.gltrans_accnt_id); IF (_externalCompany) THEN RAISE EXCEPTION 'Transactions are not allowed for G/L Accounts with External Company segments.'; END IF; -- RAISE NOTICE '_gltransInsertTrigger(): company_external = %', _externalCompany; SELECT metric_value='t' INTO _reqNotes FROM metric WHERE(metric_name='MandatoryGLEntryNotes'); IF (_reqNotes IS NULL) THEN _reqNotes := false; END IF; IF ((NEW.gltrans_doctype='JE') AND _reqNotes AND (TRIM(BOTH FROM COALESCE(NEW.gltrans_notes,''))='')) THEN RAISE EXCEPTION 'Notes are required for Journal Entries.'; END IF; RETURN NEW; END; $$; .DROP FUNCTION public._gltransinserttrigger(); publicadminfalse46238125577804_grpprivtrigger()FUNCTION?CREATE FUNCTION _grpprivtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check BOOLEAN; _returnVal INTEGER; BEGIN -- This looks like a candidate for a foreign key but isn't. -- fkeys don't work if the foreign key value resides in a child of the -- table and not the table itself. IF ((TG_OP = 'UPDATE' OR TG_OP = 'INSERT') AND (NOT EXISTS(SELECT priv_id FROM priv WHERE (priv_id=NEW.grppriv_priv_id)))) THEN RAISE EXCEPTION 'Privilege id % does not exist or is part of a disabled package.', NEW.grppriv_priv_id; RETURN OLD; ELSIF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; (DROP FUNCTION public._grpprivtrigger(); publicadminfalse46238125577805_imageasstrigger()FUNCTIONxCREATE FUNCTION _imageasstrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (NEW.imageass_source = 'INCDT') THEN UPDATE incdt SET incdt_updated = now() WHERE incdt_id = NEW.imageass_source_id; END IF; RETURN NEW; END; $$; )DROP FUNCTION public._imageasstrigger(); publicadminfalse46238125587197_incdtafterdeletetrigger()FUNCTIONiCREATE FUNCTION _incdtafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'INCDT' AND charass_target_id = OLD.incdt_id; RETURN OLD; END; $$; 1DROP FUNCTION public._incdtafterdeletetrigger(); publicadminfalse46238125577806_incdtbeforedeletetrigger()FUNCTIONCREATE FUNCTION _incdtbeforedeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _recurid INTEGER; _newparentid INTEGER; BEGIN IF (TG_OP = 'DELETE') THEN SELECT recur_id INTO _recurid FROM recur WHERE ((recur_parent_id=OLD.incdt_id) AND (recur_parent_type='INCDT')); IF (_recurid IS NOT NULL) THEN SELECT MIN(incdt_id) INTO _newparentid FROM incdt WHERE ((incdt_recurring_incdt_id=OLD.inctd_id) AND (incdt_id!=OLD.incdt_id)); -- client is responsible for warning about deleting a recurring incdt IF (_newparentid IS NULL) THEN DELETE FROM recur WHERE recur_id=_recurid; ELSE UPDATE recur SET recur_parent_id=_newparentid WHERE recur_id=_recurid; END IF; END IF; RETURN OLD; END IF; RETURN NEW; END; $$; 2DROP FUNCTION public._incdtbeforedeletetrigger(); publicadminfalse46238125577807_incdtbeforetrigger()FUNCTIONCREATE FUNCTION _incdtbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _rec RECORD; _check BOOLEAN; _crmacct INTEGER; BEGIN IF(TG_OP = 'DELETE') THEN _rec := OLD; ELSE _rec := NEW; END IF; -- Set the incident number if blank IF (TG_OP = 'INSERT') THEN IF (NEW.incdt_number IS NULL) THEN SELECT fetchIncidentNumber() INTO NEW.incdt_number; END IF; --- clear the number from the issue cache PERFORM clearNumberIssue('IncidentNumber', NEW.incdt_number); END IF; -- Description is required IF (LENGTH(COALESCE(NEW.incdt_summary,''))=0) THEN RAISE EXCEPTION 'You must supply a valid Incident Description.'; END IF; -- CRM Account is required IF (NEW.incdt_crmacct_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid CRM Account.'; END IF; -- Contact is required IF (NEW.incdt_cntct_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Contact.'; END IF; NEW.incdt_updated := now(); RETURN NEW; END; $$; ,DROP FUNCTION public._incdtbeforetrigger(); publicadminfalse84623125577808_incdttrigger()FUNCTIONCREATE FUNCTION _incdttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; _counter INTEGER := 0; _whsId INTEGER := -1; _evntType TEXT; _cmnttypeid INTEGER := -1; _cmntid INTEGER := -1; BEGIN SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='Notes to Comment'); IF NOT FOUND OR _cmnttypeid IS NULL THEN _cmnttypeid := -1; END IF; IF (TG_OP = 'DELETE') THEN -- This should never happen RETURN OLD; ELSIF (TG_OP = 'INSERT') THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_change, incdthist_target_id, incdthist_descrip) VALUES(NEW.incdt_id, 'N', NULL, 'Incident Added'); _evntType = 'NewIncident'; IF (_cmnttypeid <> -1 AND COALESCE(NEW.incdt_descrip, '') <> '') THEN PERFORM postComment(_cmnttypeid, 'INCDT', NEW.incdt_id, NEW.incdt_descrip); END IF; ELSIF (TG_OP = 'UPDATE') THEN _evntType = 'UpdatedIncident'; IF (COALESCE(NEW.incdt_cntct_id,-1) <> COALESCE(OLD.incdt_cntct_id,-1)) THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_change, incdthist_target_id, incdthist_descrip) VALUES(NEW.incdt_id, 'C', NEW.incdt_cntct_id, ('Contact Changed: "' || COALESCE((SELECT cntct_first_name || ' ' || cntct_last_name FROM cntct WHERE (cntct_id=OLD.incdt_cntct_id)), '') || '" -> "' || COALESCE((SELECT cntct_first_name || ' ' || cntct_last_name FROM cntct WHERE (cntct_id=NEW.incdt_cntct_id)), '') || '"') ); END IF; IF (COALESCE(NEW.incdt_summary,'') <> COALESCE(OLD.incdt_summary,'')) THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_descrip) VALUES(NEW.incdt_id, ('Description Updated: "' || COALESCE(OLD.incdt_summary, '') || '" -> "' || COALESCE(NEW.incdt_summary, '') || '"') ); END IF; IF (COALESCE(NEW.incdt_descrip,'') <> COALESCE(OLD.incdt_descrip,'')) THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_descrip) VALUES(NEW.incdt_id, ('Notes Updated: "' || substr(COALESCE(OLD.incdt_descrip, ''), 1, 20) || '..." -> "' || substr(COALESCE(NEW.incdt_descrip, ''), 1, 20) || '..."') ); IF (_cmnttypeid <> -1) THEN -- find an existing comment SELECT comment_id INTO _cmntid FROM comment WHERE comment_source = 'INCDT' AND comment_source_id = NEW.incdt_id -- back out change for 21068 -- AND comment_user = getEffectiveXtUser() AND comment_cmnttype_id = _cmnttypeid; IF FOUND THEN UPDATE comment SET comment_text = NEW.incdt_descrip WHERE comment_id = _cmntid; ELSE PERFORM postComment(_cmnttypeid, 'INCDT', NEW.incdt_id, NEW.incdt_descrip); END IF; END IF; END IF; IF (NEW.incdt_status <> OLD.incdt_status) THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_change, incdthist_target_id, incdthist_descrip) VALUES(NEW.incdt_id, 'S', NULL, ('Status Changed: ' || CASE WHEN(OLD.incdt_status='N') THEN 'New' WHEN(OLD.incdt_status='F') THEN 'Feedback' WHEN(OLD.incdt_status='C') THEN 'Confirmed' WHEN(OLD.incdt_status='A') THEN 'Assigned' WHEN(OLD.incdt_status='R') THEN 'Resolved' WHEN(OLD.incdt_status='L') THEN 'Closed' ELSE OLD.incdt_status END || ' -> ' || CASE WHEN(NEW.incdt_status='N') THEN 'New' WHEN(NEW.incdt_status='F') THEN 'Feedback' WHEN(NEW.incdt_status='C') THEN 'Confirmed' WHEN(NEW.incdt_status='A') THEN 'Assigned' WHEN(NEW.incdt_status='R') THEN 'Resolved' WHEN(NEW.incdt_status='L') THEN 'Closed' ELSE NEW.incdt_status END ) ); IF (NEW.incdt_status = 'L') THEN _evntType = 'ClosedIncident'; ELSIF (OLD.incdt_status = 'L') THEN _evntType = 'ReopenedIncident'; END IF; END IF; IF (COALESCE(NEW.incdt_assigned_username,'') <> COALESCE(OLD.incdt_assigned_username,'')) THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_change, incdthist_target_id, incdthist_descrip) VALUES(NEW.incdt_id, 'A', NULL, ('Assigned to: "' || COALESCE(OLD.incdt_assigned_username, '') || '" -> "' || COALESCE(NEW.incdt_assigned_username, '') || '"') ); END IF; IF (COALESCE(NEW.incdt_incdtcat_id,-1) <> COALESCE(OLD.incdt_incdtcat_id,-1)) THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_change, incdthist_target_id, incdthist_descrip) VALUES(NEW.incdt_id, 'T', NEW.incdt_incdtcat_id, ('Category Changed: ' || COALESCE((SELECT incdtcat_name FROM incdtcat WHERE (incdtcat_id=OLD.incdt_incdtcat_id)), '') || ' -> ' || COALESCE((SELECT incdtcat_name FROM incdtcat WHERE (incdtcat_id=NEW.incdt_incdtcat_id)), '') || '') ); END IF; IF (COALESCE(NEW.incdt_incdtseverity_id,-1) <> COALESCE(OLD.incdt_incdtseverity_id,-1)) THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_change, incdthist_target_id, incdthist_descrip) VALUES(NEW.incdt_id, 'V', NEW.incdt_incdtseverity_id, ('Severity Changed: ' || COALESCE((SELECT incdtseverity_name FROM incdtseverity WHERE (incdtseverity_id=OLD.incdt_incdtseverity_id)), '') || ' -> ' || COALESCE((SELECT incdtseverity_name FROM incdtseverity WHERE (incdtseverity_id=NEW.incdt_incdtseverity_id)), '') || '') ); END IF; IF (COALESCE(NEW.incdt_incdtpriority_id,-1) <> COALESCE(OLD.incdt_incdtpriority_id,-1)) THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_change, incdthist_target_id, incdthist_descrip) VALUES(NEW.incdt_id, 'P', NEW.incdt_incdtpriority_id, ('Priority Changed: ' || COALESCE((SELECT incdtpriority_name FROM incdtpriority WHERE (incdtpriority_id=OLD.incdt_incdtpriority_id)), '') || ' -> ' || COALESCE((SELECT incdtpriority_name FROM incdtpriority WHERE (incdtpriority_id=NEW.incdt_incdtpriority_id)), '') || '') ); END IF; IF (COALESCE(NEW.incdt_incdtresolution_id,-1) <> COALESCE(OLD.incdt_incdtresolution_id,-1)) THEN INSERT INTO incdthist (incdthist_incdt_id, incdthist_change, incdthist_target_id, incdthist_descrip) VALUES(NEW.incdt_id, 'E', NEW.incdt_incdtresolution_id, ('Resolution Changed: ' || COALESCE((SELECT incdtresolution_name FROM incdtresolution WHERE (incdtresolution_id=OLD.incdt_incdtresolution_id)), '') || ' -> ' || COALESCE((SELECT incdtresolution_name FROM incdtresolution WHERE (incdtresolution_id=NEW.incdt_incdtresolution_id)), '') || '') ); END IF; END IF; PERFORM postEvent(_evntType, 'IC', NEW.incdt_id, NULL, NEW.incdt_number::TEXT, NULL, NULL, NULL, NULL); RETURN NEW; END; $$; &DROP FUNCTION public._incdttrigger(); publicadminfalse84623125587202_invcheadafterdeletetrigger()FUNCTIONmCREATE FUNCTION _invcheadafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'INV' AND charass_target_id = OLD.invchead_id; RETURN OLD; END; $$; 4DROP FUNCTION public._invcheadafterdeletetrigger(); publicadminfalse46238125577809_invcheadaftertrigger()FUNCTIONCREATE FUNCTION _invcheadaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; _cohead_id INTEGER; BEGIN -- Create a comment entry when on a Sales Order when an Invoice is Posted for that order -- Cache the cmnttype_id for ChangeLog SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (FOUND) THEN IF (TG_OP = 'UPDATE') THEN IF ((OLD.invchead_posted != NEW.invchead_posted) AND NEW.invchead_posted) THEN SELECT cohead_id INTO _cohead_id FROM cohead WHERE (cohead_number = OLD.invchead_ordernumber); IF (FOUND) THEN PERFORM postComment( _cmnttypeid, 'S', _cohead_id, ('Invoice, ' || NEW.invchead_invcnumber || ', posted for this order') ); END IF; END IF; END IF; END IF; RETURN NEW; END; $$; .DROP FUNCTION public._invcheadaftertrigger(); publicadminfalse84623125577810_invcheadbeforetrigger()FUNCTION CREATE FUNCTION _invcheadbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _recurid INTEGER; _newparentid INTEGER; BEGIN IF (TG_OP = 'UPDATE') THEN IF (OLD.invchead_posted AND ((OLD.invchead_invcnumber != NEW.invchead_invcnumber) OR (OLD.invchead_invcdate != NEW.invchead_invcdate) OR (OLD.invchead_terms_id != NEW.invchead_terms_id) OR (OLD.invchead_salesrep_id != NEW.invchead_salesrep_id) OR (OLD.invchead_commission != NEW.invchead_commission) OR (OLD.invchead_taxzone_id != NEW.invchead_taxzone_id) OR (OLD.invchead_shipchrg_id != NEW.invchead_shipchrg_id) OR (OLD.invchead_prj_id != NEW.invchead_prj_id) OR (OLD.invchead_misc_accnt_id != NEW.invchead_misc_accnt_id) OR (OLD.invchead_misc_amount != NEW.invchead_misc_amount) OR (OLD.invchead_freight != NEW.invchead_freight))) THEN RAISE EXCEPTION 'Edit not allow on Posted Invoice.'; END IF; END IF; IF (TG_OP = 'DELETE') THEN DELETE FROM invcheadtax WHERE (taxhist_parent_id=OLD.invchead_id); SELECT recur_id INTO _recurid FROM recur WHERE ((recur_parent_id=OLD.invchead_id) AND (recur_parent_type='I')); IF (_recurid IS NOT NULL) THEN SELECT invchead_id INTO _newparentid FROM invchead WHERE ((invchead_recurring_invchead_id=OLD.invchead_id) AND (invchead_id!=OLD.invchead_id)) ORDER BY invchead_invcdate LIMIT 1; IF (_newparentid IS NULL) THEN DELETE FROM recur WHERE recur_id=_recurid; ELSE UPDATE recur SET recur_parent_id=_newparentid WHERE recur_id=_recurid; UPDATE invchead SET invchead_recurring_invchead_id=_newparentid WHERE invchead_recurring_invchead_id=OLD.invchead_id AND invchead_id!=OLD.invchead_id; END IF; END IF; RETURN OLD; END IF; RETURN NEW; END; $$; /DROP FUNCTION public._invcheadbeforetrigger(); publicadminfalse46238125577811_invcheadtrigger()FUNCTION CREATE FUNCTION _invcheadtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN -- Something can go here RETURN OLD; END IF; -- Insert new row IF (TG_OP = 'INSERT') THEN -- Calculate Freight Tax IF (NEW.invchead_freight <> 0) THEN PERFORM calculateTaxHist( 'invcheadtax', NEW.invchead_id, NEW.invchead_taxzone_id, getFreightTaxtypeId(), NEW.invchead_invcdate, NEW.invchead_curr_id, NEW.invchead_freight ); END IF; --- clear the number from the issue cache PERFORM clearNumberIssue('InvcNumber', NEW.invchead_invcnumber); END IF; -- Update row IF (TG_OP = 'UPDATE') THEN IF ( (NEW.invchead_freight <> OLD.invchead_freight) OR (COALESCE(NEW.invchead_taxzone_id,-1) <> COALESCE(OLD.invchead_taxzone_id,-1)) OR (NEW.invchead_invcdate <> OLD.invchead_invcdate) OR (NEW.invchead_curr_id <> OLD.invchead_curr_id) ) THEN -- Calculate invchead Tax PERFORM calculateTaxHist( 'invcheadtax', NEW.invchead_id, NEW.invchead_taxzone_id, getFreightTaxtypeId(), NEW.invchead_invcdate, NEW.invchead_curr_id, NEW.invchead_freight ); END IF; IF ( (COALESCE(NEW.invchead_taxzone_id,-1) <> COALESCE(OLD.invchead_taxzone_id,-1)) OR (NEW.invchead_invcdate <> OLD.invchead_invcdate) OR (NEW.invchead_curr_id <> OLD.invchead_curr_id) ) THEN -- Calculate invcitem Tax IF (COALESCE(NEW.invchead_taxzone_id,-1) <> COALESCE(OLD.invchead_taxzone_id,-1)) THEN UPDATE invcitem SET invcitem_taxtype_id=getItemTaxType(invcitem_item_id,NEW.invchead_taxzone_id) WHERE (invcitem_invchead_id=NEW.invchead_id); PERFORM calculateTaxHist( 'invcitemtax', invcitem_id, NEW.invchead_taxzone_id, invcitem_taxtype_id, NEW.invchead_invcdate, NEW.invchead_curr_id, (invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / invcitem_price_invuomratio) ) FROM invcitem WHERE (invcitem_invchead_id = NEW.invchead_id); END IF; END IF; END IF; RETURN NEW; END; $$; )DROP FUNCTION public._invcheadtrigger(); publicadminfalse46238125577812_invcitembeforetrigger()FUNCTIONCREATE FUNCTION _invcitembeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _itemfractional BOOLEAN; BEGIN IF (TG_OP = 'DELETE') THEN DELETE FROM invcitemtax WHERE (taxhist_parent_id=OLD.invcitem_id); RETURN OLD; END IF; IF (TG_OP IN ('UPDATE','DELETE')) THEN IF (SELECT COUNT(invchead_id) > 0 FROM invchead WHERE ((invchead_id=OLD.invcitem_invchead_id) AND (invchead_posted))) THEN RAISE EXCEPTION 'Edit not allowed on Posted Invoices.'; END IF; END IF; -- If regular Item then enforce item_fractional IF (COALESCE(NEW.invcitem_item_id, -1) <> -1) THEN SELECT itemuomfractionalbyuom(NEW.invcitem_item_id, NEW.invcitem_qty_uom_id) INTO _itemfractional; IF (NOT _itemfractional) THEN IF (TRUNC(NEW.invcitem_ordered) <> NEW.invcitem_ordered) THEN RAISE EXCEPTION 'Item does not support fractional quantities'; END IF; IF (TRUNC(NEW.invcitem_billed) <> NEW.invcitem_billed) THEN RAISE EXCEPTION 'Item does not support fractional quantities'; END IF; END IF; END IF; RETURN NEW; END; $$; /DROP FUNCTION public._invcitembeforetrigger(); publicadminfalse84623125577813_invcitemtrigger()FUNCTIONDCREATE FUNCTION _invcitemtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; -- Cache Invoice Head SELECT * INTO _r FROM invchead WHERE (invchead_id=NEW.invcitem_invchead_id); IF (NOT FOUND) THEN RAISE EXCEPTION 'Invoice head not found'; END IF; -- Insert new row IF (TG_OP = 'INSERT') THEN -- Calculate Tax PERFORM calculateTaxHist( 'invcitemtax', NEW.invcitem_id, COALESCE(_r.invchead_taxzone_id, -1), NEW.invcitem_taxtype_id, COALESCE(_r.invchead_invcdate, CURRENT_DATE), COALESCE(_r.invchead_curr_id, -1), (NEW.invcitem_billed * NEW.invcitem_qty_invuomratio) * (NEW.invcitem_price / NEW.invcitem_price_invuomratio) ); END IF; -- Update row IF (TG_OP = 'UPDATE') THEN -- Calculate Tax IF ( (NEW.invcitem_billed <> OLD.invcitem_billed) OR (NEW.invcitem_qty_invuomratio <> OLD.invcitem_qty_invuomratio) OR (NEW.invcitem_price <> OLD.invcitem_price) OR (NEW.invcitem_price_invuomratio <> OLD.invcitem_price_invuomratio) OR (COALESCE(NEW.invcitem_taxtype_id, -1) <> COALESCE(OLD.invcitem_taxtype_id, -1)) ) THEN PERFORM calculateTaxHist( 'invcitemtax', NEW.invcitem_id, COALESCE(_r.invchead_taxzone_id, -1), NEW.invcitem_taxtype_id, COALESCE(_r.invchead_invcdate, CURRENT_DATE), COALESCE(_r.invchead_curr_id, -1), (NEW.invcitem_billed * NEW.invcitem_qty_invuomratio) * (NEW.invcitem_price / NEW.invcitem_price_invuomratio) ); END IF; END IF; RETURN NEW; END; $$; )DROP FUNCTION public._invcitemtrigger(); publicadminfalse84623125577814_ipsassbeforetrigger()FUNCTION<CREATE FUNCTION _ipsassbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Checks IF NOT (checkPrivilege('MaintainPricingSchedules')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Price Schedules.'; END IF; -- Business logic, disallow invalid combinations IF (TG_OP IN ('INSERT','UPDATE')) THEN IF (LENGTH(COALESCE(NEW.ipsass_custtype_pattern,'')) != 0) THEN new.ipsass_cust_id = -1; new.ipsass_custtype_id = -1; new.ipsass_shipto_id = -1; new.ipsass_shipto_pattern = ''; ELSIF (COALESCE(NEW.ipsass_custtype_id,-1) > -1) THEN new.ipsass_cust_id = -1; new.ipsass_shipto_id = -1; new.ipsass_shipto_pattern = ''; new.ipsass_custtype_pattern = ''; ELSIF (LENGTH(COALESCE(NEW.ipsass_shipto_pattern,'')) != 0) THEN new.ipsass_custtype_id = -1; new.ipsass_shipto_id = -1; new.ipsass_custtype_pattern = ''; ELSE new.ipsass_shipto_id = COALESCE(NEW.ipsass_shipto_id,-1); new.ipsass_custtype_id = -1; new.ipsass_shipto_pattern = ''; new.ipsass_custtype_pattern = ''; END IF; RETURN NEW; ELSE RETURN OLD; END IF; END; $$; -DROP FUNCTION public._ipsassbeforetrigger(); publicadminfalse46238125577815_ipsheadbeforetrigger()FUNCTIONCREATE FUNCTION _ipsheadbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Checks IF NOT (checkPrivilege('MaintainPricingSchedules')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Price Schedules.'; END IF; IF (TG_OP IN ('INSERT','UPDATE')) THEN RETURN NEW; ELSE RETURN OLD; END IF; END; $$; .DROP FUNCTION public._ipsheadbeforetrigger(); publicadminfalse46238125577816_ipsitemcharbeforetrigger()FUNCTIONCREATE FUNCTION _ipsitemcharbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Checks IF NOT (checkPrivilege('MaintainPricingSchedules')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Price Schedules.'; END IF; IF (TG_OP IN ('INSERT','UPDATE')) THEN IF (SELECT (COUNT(item_id)=0) FROM ipsiteminfo JOIN item ON (item_id=ipsitem_item_id) WHERE ((ipsitem_id=NEW.ipsitemchar_ipsitem_id) AND (item_config))) THEN RAISE EXCEPTION 'Characteristic prices may only be set on configured items.'; ELSIF (SELECT (COUNT(item_id)=0) FROM ipsiteminfo JOIN item ON (item_id=ipsitem_item_id) JOIN charass ON (charass_target_id=item_id AND charass_target_type='I') WHERE ((ipsitem_id=NEW.ipsitemchar_ipsitem_id) AND (charass_char_id=NEW.ipsitemchar_char_id) AND (charass_value=NEW.ipsitemchar_value))) THEN RAISE EXCEPTION 'No characteristic with matching value exists for this item.'; END IF; RETURN NEW; ELSE RETURN OLD; END IF; END; $$; 2DROP FUNCTION public._ipsitemcharbeforetrigger(); publicadminfalse84623125577817_ipsiteminfobeforetrigger()FUNCTIONiCREATE FUNCTION _ipsiteminfobeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN -- Checks IF NOT (checkPrivilege('MaintainPricingSchedules')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Price Schedules.'; END IF; IF (TG_OP IN ('INSERT','UPDATE')) THEN RETURN NEW; ELSE RETURN OLD; END IF; END; $$; 2DROP FUNCTION public._ipsiteminfobeforetrigger(); publicadminfalse46238125587216_item_uom_check()FUNCTION@CREATE FUNCTION _item_uom_check() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- This trigger checks the all item uom_id columns have valid conversion ratios. BEGIN IF (NEW.item_active AND NEW.item_sold) THEN IF (NEW.item_inv_uom_id <> NEW.item_price_uom_id) THEN BEGIN PERFORM itemuomtouomratio(NEW.item_id, NEW.item_inv_uom_id, NEW.item_price_uom_id) FROM item WHERE TRUE AND item_id = NEW.item_id; EXCEPTION WHEN SQLSTATE 'P0001' THEN RAISE EXCEPTION 'An invalid UOM was set on this item. Please verify that the Unit Price UOM has a conversion to the Inventory UOM.'; END; END IF; END IF; RETURN NEW; END; $$; (DROP FUNCTION public._item_uom_check(); publicadminfalse46238125587214_itemafterdeletetrigger()FUNCTIONcCREATE FUNCTION _itemafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'I' AND charass_target_id = OLD.item_id; RETURN OLD; END; $$; 0DROP FUNCTION public._itemafterdeletetrigger(); publicadminfalse46238125577818_itemaftertrigger()FUNCTION*CREATE FUNCTION _itemaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainItemMasters')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Items.'; END IF; -- Integrity checks IF (TG_OP = 'UPDATE') THEN IF ((OLD.item_type <> NEW.item_type) AND (NEW.item_type = 'L')) THEN IF (SELECT COUNT(*) != 0 FROM bomitem WHERE (bomitem_item_id = OLD.item_id)) THEN RAISE EXCEPTION 'This item is part of one or more Bills of Materials and cannot be a Planning Item.'; END IF; END IF; IF ((OLD.item_type <> NEW.item_type) AND (NEW.item_type IN ('R','S','T'))) THEN IF (SELECT COUNT(*) != 0 FROM itemsite WHERE ((itemsite_item_id=OLD.item_id) AND (itemsite_qtyonhand + qtyallocated(itemsite_id,startoftime(),endoftime()) + qtyordered(itemsite_id,startoftime(),endoftime()) > 0 ))) THEN RAISE EXCEPTION 'Item type not allowed when there are itemsites with quantities with on hand quantities or pending inventory activity for this item.'; END IF; END IF; -- If type changed remove costs and deactivate item sites IF (NEW.item_type <> OLD.item_type) THEN PERFORM updateCost(itemcost_id, 0) FROM itemcost WHERE (itemcost_item_id=OLD.item_id); UPDATE itemsite SET itemsite_active=false WHERE (itemsite_item_id=OLD.item_id); IF (NEW.item_type = 'R') THEN UPDATE itemsite SET itemsite_controlmethod='N' WHERE (itemsite_item_id=OLD.item_id); END IF; END IF; END IF; IF ( SELECT (metric_value='t') FROM metric WHERE (metric_name='ItemChangeLog') ) THEN -- Cache the cmnttype_id for ChangeLog SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (FOUND) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'I', NEW.item_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.item_active <> NEW.item_active) THEN IF (NEW.item_active) THEN PERFORM postComment(_cmnttypeid, 'I', NEW.item_id, 'Activated'); ELSE PERFORM postComment(_cmnttypeid, 'I', NEW.item_id, 'Deactivated'); END IF; END IF; IF (OLD.item_descrip1 <> NEW.item_descrip1) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Description 1 Changed from "' || OLD.item_descrip1 || '" to "' || NEW.item_descrip1 || '"' ) ); END IF; IF (OLD.item_descrip2 <> NEW.item_descrip2) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Description 2 Changed from "' || OLD.item_descrip2 || '" to "' || NEW.item_descrip2 || '"' ) ); END IF; IF (OLD.item_inv_uom_id <> NEW.item_inv_uom_id) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Inventory UOM Changed from "' || (SELECT uom_name FROM uom WHERE uom_id=OLD.item_inv_uom_id) || '" (' || CAST(OLD.item_inv_uom_id AS TEXT) || ') to "' || (SELECT uom_name FROM uom WHERE uom_id=NEW.item_inv_uom_id) || '" (' || CAST(NEW.item_inv_uom_id AS TEXT) || ')' ) ); END IF; IF (OLD.item_sold <> NEW.item_sold) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, CASE WHEN (NEW.item_sold) THEN 'Sold Changed from FALSE to TRUE' ELSE 'Sold Changed from TRUE to FALSE' END ); END IF; IF (OLD.item_picklist <> NEW.item_picklist) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, CASE WHEN (NEW.item_picklist) THEN 'Pick List Changed from FALSE to TRUE' ELSE 'Pick List Changed from TRUE to FALSE' END ); END IF; IF (OLD.item_fractional <> NEW.item_fractional) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, CASE WHEN (NEW.item_fractional) THEN 'Fractional Changed from FALSE to TRUE' ELSE 'Fractional Changed from TRUE to FALSE' END ); END IF; IF (OLD.item_exclusive <> NEW.item_exclusive) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, CASE WHEN (NEW.item_exclusive) THEN 'Exclusive Changed from FALSE to TRUE' ELSE 'Exclusive Changed from TRUE to FALSE' END ); END IF; IF (OLD.item_config <> NEW.item_config) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, CASE WHEN (NEW.item_config) THEN 'Configured Changed from FALSE to TRUE' ELSE 'Configured Changed from TRUE to FALSE' END ); END IF; IF (OLD.item_listprice <> NEW.item_listprice) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'List Price Changed from "' || formatSalesPrice(OLD.item_listprice) || '" to "' || formatSalesPrice(NEW.item_listprice) || '"' ) ); END IF; -- Add New stuff IF (OLD.item_type <> NEW.item_type) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Type Changed from "' || OLD.item_type || '" to "' || NEW.item_type || '"' ) ); END IF; IF (OLD.item_price_uom_id <> NEW.item_price_uom_id) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Price UOM Changed from "' || (SELECT uom_name FROM uom WHERE uom_id=OLD.item_price_uom_id) || '" (' || CAST(OLD.item_price_uom_id AS TEXT) || ') to "' || (SELECT uom_name FROM uom WHERE uom_id=NEW.item_price_uom_id) || '" (' || CAST(NEW.item_price_uom_id AS TEXT) || ')' ) ); END IF; IF (OLD.item_classcode_id <> NEW.item_classcode_id) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Class Code Changed from "' || (SELECT classcode_code || '-' || classcode_descrip FROM classcode WHERE classcode_id=OLD.item_classcode_id) || '" (' || CAST(OLD.item_classcode_id AS TEXT) || ') to "' || (SELECT classcode_code || '-' || classcode_descrip FROM classcode WHERE classcode_id=NEW.item_classcode_id) || '" (' || CAST(NEW.item_classcode_id AS TEXT) || ')' ) ); END IF; IF (OLD.item_freightclass_id <> NEW.item_freightclass_id) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Freight Class Changed from "' || (SELECT freightclass_code || '-' || freightclass_descrip FROM freightclass WHERE freightclass_id=OLD.item_freightclass_id) || '" (' || CAST(OLD.item_freightclass_id AS TEXT) || ') to "' || (SELECT freightclass_code || '-' || freightclass_descrip FROM freightclass WHERE freightclass_id=NEW.item_freightclass_id) || '" (' || CAST(NEW.item_freightclass_id AS TEXT) || ')' ) ); END IF; IF (OLD.item_prodcat_id <> NEW.item_prodcat_id) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Product Category Changed from "' || (SELECT prodcat_code || '-' || prodcat_descrip FROM prodcat WHERE prodcat_id=OLD.item_prodcat_id) || '" (' || CAST(OLD.item_prodcat_id AS TEXT) || ') to "' || (SELECT prodcat_code || '-' || prodcat_descrip FROM prodcat WHERE prodcat_id=NEW.item_prodcat_id) || '" (' || CAST(NEW.item_prodcat_id AS TEXT) || ')' ) ); END IF; IF (OLD.item_upccode <> NEW.item_upccode) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'UPC Code Changed from "' || OLD.item_upccode || '" to "' || NEW.item_upccode || '"' ) ); END IF; IF (OLD.item_prodweight <> NEW.item_prodweight) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Product Weight Changed from "' || formatWeight(OLD.item_prodweight) || '" to "' || formatWeight(NEW.item_prodweight) || '"' ) ); END IF; IF (OLD.item_packweight <> NEW.item_packweight) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Packaging Weight Changed from "' || formatWeight(OLD.item_packweight) || '" to "' || formatWeight(NEW.item_packweight) || '"' ) ); END IF; IF (OLD.item_maxcost <> NEW.item_maxcost) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'Maximum Desired Cost Changed from "' || formatCost(OLD.item_maxcost) || '" to "' || formatCost(NEW.item_maxcost) || '"' ) ); END IF; IF (OLD.item_listcost <> NEW.item_listcost) THEN PERFORM postComment( _cmnttypeid, 'I', NEW.item_id, ( 'List Cost Changed from "' || formatCost(OLD.item_listcost) || '" to "' || formatCost(NEW.item_listcost) || '"' ) ); END IF; -- End changes END IF; END IF; END IF; IF (TG_OP = 'DELETE') THEN DELETE FROM imageass WHERE ((imageass_source_id=OLD.item_id) AND (imageass_source='I')); DELETE FROM url WHERE ((url_source_id=OLD.item_id) AND (url_source='I')); DELETE FROM docass WHERE docass_source_id = OLD.item_id AND docass_source_type = 'I'; DELETE FROM docass WHERE docass_target_id = OLD.item_id AND docass_target_type = 'I'; RETURN OLD; END IF; RETURN NEW; END; $$; *DROP FUNCTION public._itemaftertrigger(); publicadminfalse84623125577820_itemaliastrigger()FUNCTIONCREATE FUNCTION _itemaliastrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainItemMasters')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Item Aliases.'; END IF; RETURN NEW; END; $$; *DROP FUNCTION public._itemaliastrigger(); publicadminfalse84623125577821_itemcostaftertrigger()FUNCTION CREATE FUNCTION _itemcostaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _itemNumber TEXT; _maxCost NUMERIC; _oldStdCost NUMERIC; _oldActCost NUMERIC; _actualCost NUMERIC; _standardCost NUMERIC; BEGIN -- Create Event if Standard or Actual Cost is greater than Max Cost IF NOT EXISTS(SELECT 1 FROM evntnot JOIN evnttype ON (evnttype_id = evntnot_evnttype_id) JOIN usrpref ON (evntnot_username = usrpref_username) WHERE evnttype_name = 'CostExceedsMaxDesired' AND usrpref_name = 'active' AND usrpref_value = 't') THEN RETURN NEW; END IF; SELECT item_number, item_maxcost, actcost(item_id), stdcost(item_id) INTO _itemNumber, _maxCost, _actualCost, _standardCost FROM item WHERE (item_id=NEW.itemcost_item_id); IF (_maxCost > 0.0) THEN -- IF (_standardCost > _maxCost) IF NOT EXISTS(SELECT 1 --COUNT(evntlog_id) FROM evntlog, evnttype WHERE evntlog_evnttype_id = evnttype_id AND evntlog_number LIKE (_itemNumber || ' -Standard- New:' || '%') AND (evntlog_dispatched IS NULL) AND CAST(evntlog_evnttime AS DATE) = current_date ) AND (_standardCost > _maxCost) THEN IF (TG_OP = 'INSERT') THEN _oldStdCost := 0; _oldActCost := 0; ELSE _oldStdCost := OLD.itemcost_stdcost; _oldActCost := OLD.itemcost_stdcost; END IF; PERFORM postEvent('CostExceedsMaxDesired', NULL, NEW.itemcost_item_id, itemsite_warehous_id, (_itemNumber || ' -Standard- ' || 'New: ' || formatCost(_standardCost) || ' Max: '|| formatCost(_MaxCost)), NEW.itemcost_stdcost, _oldStdCost, NULL, NULL) FROM itemsite WHERE (itemsite_item_id=NEW.itemcost_item_id); END IF; IF NOT EXISTS( SELECT 1 FROM evntlog, evnttype WHERE evntlog_evnttype_id = evnttype_id AND evntlog_number LIKE (_itemNumber || ' -Actual- New:' || '%') AND (evntlog_dispatched IS NULL) AND CAST(evntlog_evnttime AS DATE) = current_date ) AND (_actualCost > _maxCost) THEN PERFORM postEvent('CostExceedsMaxDesired', NULL, NEW.itemcost_item_id, itemsite_warehous_id, (_itemNumber || ' -Actual- ' || 'New: ' || formatCost(_actualCost) || ' Max: '|| formatCost(_MaxCost)), NEW.itemcost_actcost, _oldActCost, NULL, NULL) FROM itemsite WHERE (itemsite_item_id=NEW.itemcost_item_id); END IF; END IF; RETURN NEW; END; $$; .DROP FUNCTION public._itemcostaftertrigger(); publicadminfalse84623125577822_itemcosttrigger()FUNCTIONf CREATE FUNCTION _itemcosttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN --Privilege Checks IF ( (TG_OP = 'INSERT') AND (NOT checkPrivilege('CreateCosts')) AND (NOT checkPrivilege('PostVouchers')) ) THEN RAISE EXCEPTION 'You do not have privileges to enter Item Costs.'; END IF; IF ( (TG_OP = 'UPDATE') AND (NOT checkPrivilege('EnterActualCosts')) AND (NOT checkPrivilege('PostVouchers')) AND (NOT checkPrivilege('UpdateActualCosts')) AND (NOT checkPrivilege('PostActualCosts')) AND (NOT checkPrivilege('PostStandardCosts')) ) THEN RAISE EXCEPTION 'You do not have privileges to update Item Costs.'; END IF; IF ( (TG_OP = 'DELETE') AND (NOT checkPrivilege('DeleteCosts')) ) THEN RAISE EXCEPTION 'You do not have privileges to delete Item Costs.'; END IF; IF (TG_OP = 'UPDATE') THEN IF (NEW.itemcost_actcost <> OLD.itemcost_actcost OR NEW.itemcost_curr_id <> OLD.itemcost_curr_id) THEN INSERT INTO costhist ( costhist_item_id, costhist_costelem_id, costhist_type, costhist_lowlevel, costhist_username, costhist_date, costhist_oldcost, costhist_newcost, costhist_oldcurr_id, costhist_newcurr_id ) VALUES ( NEW.itemcost_item_id, NEW.itemcost_costelem_id, 'A', NEW.itemcost_lowlevel, getEffectiveXtUser(), CURRENT_TIMESTAMP, OLD.itemcost_actcost, NEW.itemcost_actcost, OLD.itemcost_curr_id, NEW.itemcost_curr_id ); END IF; IF (NEW.itemcost_stdcost <> OLD.itemcost_stdcost) THEN INSERT INTO costhist ( costhist_item_id, costhist_costelem_id, costhist_type, costhist_lowlevel, costhist_username, costhist_date, costhist_oldcost, costhist_newcost, costhist_oldcurr_id, costhist_newcurr_id ) VALUES ( NEW.itemcost_item_id, NEW.itemcost_costelem_id, 'S', NEW.itemcost_lowlevel, getEffectiveXtUser(), CURRENT_TIMESTAMP, OLD.itemcost_stdcost, NEW.itemcost_stdcost, baseCurrId(), baseCurrId() ); END IF; RETURN NEW; ELSIF (TG_OP = 'INSERT') THEN INSERT INTO costhist ( costhist_item_id, costhist_costelem_id, costhist_type, costhist_lowlevel, costhist_username, costhist_date, costhist_oldcost, costhist_newcost, costhist_oldcurr_id, costhist_newcurr_id ) VALUES ( NEW.itemcost_item_id, NEW.itemcost_costelem_id, 'N', NEW.itemcost_lowlevel, getEffectiveXtUser(), CURRENT_TIMESTAMP, 0, NEW.itemcost_actcost, baseCurrId(), NEW.itemcost_curr_id ); RETURN NEW; ELSIF (TG_OP = 'DELETE') THEN INSERT INTO costhist ( costhist_item_id, costhist_costelem_id, costhist_type, costhist_lowlevel, costhist_username, costhist_date, costhist_oldcost, costhist_newcost, costhist_oldcurr_id, costhist_newcurr_id ) VALUES ( OLD.itemcost_item_id, OLD.itemcost_costelem_id, 'D', OLD.itemcost_lowlevel, getEffectiveXtUser(), CURRENT_TIMESTAMP, OLD.itemcost_stdcost, 0, OLD.itemcost_curr_id, baseCurrId() ); RETURN OLD; END IF; END; $$; )DROP FUNCTION public._itemcosttrigger(); publicadminfalse46238125577823_itemsiteaftertrigger()FUNCTION/CREATE FUNCTION _itemsiteaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _state INTEGER; _wasLocationControl BOOLEAN; _isLocationControl BOOLEAN; _wasLotSerial BOOLEAN; _isLotSerial BOOLEAN; _wasPerishable BOOLEAN; _isPerishable BOOLEAN; _qty NUMERIC; _maint BOOLEAN; _cost NUMERIC; _variance NUMERIC; _application TEXT; BEGIN -- Cache Application SELECT fetchMetricText('Application') INTO _application; -- Check if we are doing maintenance IF (TG_OP = 'INSERT') THEN _maint := TRUE; ELSIF (TG_OP = 'UPDATE') THEN IF ((OLD.itemsite_item_id != NEW.itemsite_item_id) OR (OLD.itemsite_warehous_id != NEW.itemsite_warehous_id) OR (OLD.itemsite_reorderlevel != NEW.itemsite_reorderlevel) OR (OLD.itemsite_ordertoqty != NEW.itemsite_ordertoqty) OR (OLD.itemsite_cyclecountfreq != NEW.itemsite_cyclecountfreq) OR (OLD.itemsite_planning_type != NEW.itemsite_planning_type) OR (OLD.itemsite_posupply != NEW.itemsite_posupply) OR (OLD.itemsite_wosupply != NEW.itemsite_wosupply) OR (OLD.itemsite_loccntrl != NEW.itemsite_loccntrl) OR (OLD.itemsite_safetystock != NEW.itemsite_safetystock) OR (OLD.itemsite_minordqty != NEW.itemsite_minordqty) OR (OLD.itemsite_multordqty != NEW.itemsite_multordqty) OR (OLD.itemsite_leadtime != NEW.itemsite_leadtime) OR (OLD.itemsite_abcclass != NEW.itemsite_abcclass) OR (OLD.itemsite_controlmethod != NEW.itemsite_controlmethod) OR (OLD.itemsite_active != NEW.itemsite_active) OR (OLD.itemsite_plancode_id != NEW.itemsite_plancode_id) OR (OLD.itemsite_costcat_id != NEW.itemsite_costcat_id) OR (OLD.itemsite_eventfence != NEW.itemsite_eventfence) OR (OLD.itemsite_sold != NEW.itemsite_sold) OR (OLD.itemsite_stocked != NEW.itemsite_stocked) OR (OLD.itemsite_location_id != NEW.itemsite_location_id) OR (OLD.itemsite_recvlocation_id != NEW.itemsite_recvlocation_id) OR (OLD.itemsite_issuelocation_id != NEW.itemsite_issuelocation_id) OR (OLD.itemsite_location_dist != NEW.itemsite_location_dist) OR (OLD.itemsite_recvlocation_dist != NEW.itemsite_recvlocation_dist) OR (OLD.itemsite_issuelocation_dist != NEW.itemsite_issuelocation_dist) OR (OLD.itemsite_useparams != NEW.itemsite_useparams) OR (OLD.itemsite_useparamsmanual != NEW.itemsite_useparamsmanual) OR (OLD.itemsite_soldranking != NEW.itemsite_soldranking) OR (OLD.itemsite_createpr != NEW.itemsite_createpr) OR (OLD.itemsite_location != NEW.itemsite_location) OR (OLD.itemsite_location_comments != NEW.itemsite_location_comments) OR (OLD.itemsite_notes != NEW.itemsite_notes) OR (OLD.itemsite_perishable != NEW.itemsite_perishable) OR (OLD.itemsite_autoabcclass != NEW.itemsite_autoabcclass) OR (OLD.itemsite_ordergroup != NEW.itemsite_ordergroup) OR (OLD.itemsite_disallowblankwip != NEW.itemsite_disallowblankwip) OR (OLD.itemsite_maxordqty != NEW.itemsite_maxordqty) OR (OLD.itemsite_mps_timefence != NEW.itemsite_mps_timefence) OR (OLD.itemsite_createwo != NEW.itemsite_createwo) OR (OLD.itemsite_warrpurc != NEW.itemsite_warrpurc) OR (OLD.itemsite_costmethod != NEW.itemsite_costmethod) OR (OLD.itemsite_autoreg != NEW.itemsite_autoreg) OR (OLD.itemsite_lsseq_id != NEW.itemsite_lsseq_id) ) THEN IF (OLD.itemsite_item_id != NEW.itemsite_item_id) THEN RAISE EXCEPTION 'The item number on an itemsite may not be changed.'; ELSIF (OLD.itemsite_warehous_id != NEW.itemsite_warehous_id) THEN RAISE EXCEPTION 'The warehouse code on an itemsite may not be changed.'; END IF; _maint := TRUE; END IF; ELSE _maint := FALSE; END IF; IF (_maint) THEN -- Begin Maintenance -- Privilege Checks IF ( NOT checkPrivilege('MaintainItemSites') ) THEN RAISE EXCEPTION 'You do not have privileges to maintain Item Sites.'; END IF; -- Override values to avoid invalid data combinations IF (NOT NEW.itemsite_posupply) THEN UPDATE itemsite SET itemsite_createpr = FALSE WHERE (itemsite_id=NEW.itemsite_id); END IF; IF (NOT NEW.itemsite_wosupply) THEN UPDATE itemsite SET itemsite_createwo = FALSE WHERE (itemsite_id=NEW.itemsite_id); END IF; IF (NEW.itemsite_controlmethod NOT IN ('S','L')) THEN UPDATE itemsite SET itemsite_perishable = FALSE, itemsite_warrpurc = FALSE, itemsite_autoreg = FALSE, itemsite_lsseq_id = NULL WHERE (itemsite_id=NEW.itemsite_id); END IF; IF (NOT NEW.itemsite_loccntrl) THEN UPDATE itemsite SET itemsite_disallowblankwip = FALSE WHERE (itemsite_id=NEW.itemsite_id); END IF; IF (NOT NEW.itemsite_useparams) THEN UPDATE itemsite SET itemsite_reorderlevel = 0, itemsite_ordertoqty = 0, itemsite_minordqty = 0, itemsite_maxordqty = 0, itemsite_multordqty = 0, itemsite_useparamsmanual = FALSE WHERE (itemsite_id = NEW.itemsite_id); END IF; -- Integrity check -- Both insert and update IF ( (NEW.itemsite_controlmethod IN ('S', 'L')) AND (NEW.itemsite_location_dist OR NEW.itemsite_recvlocation_dist OR NEW.itemsite_issuelocation_dist) ) THEN RAISE EXCEPTION 'You cannot auto-distribute Lot/Serial controlled Item Sites.'; END IF; IF (TG_OP = 'INSERT') THEN -- Handle MLC logic IF ( (NEW.itemsite_loccntrl) AND (NEW.itemsite_warehous_id IS NOT NULL) ) THEN IF (SELECT count(*)=0 FROM location WHERE ((location_warehous_id=NEW.itemsite_warehous_id) AND ( (NOT location_restrict) OR ( (location_restrict) AND (location_id IN ( SELECT locitem_location_id FROM locitem WHERE (locitem_item_id=NEW.itemsite_item_id) ) ) ) ))) THEN RAISE EXCEPTION 'You must first create at least one valid Location for this Item Site before it may be multiply located.'; END IF; END IF; END IF; IF (TG_OP = 'UPDATE') THEN -- Integrity check IF (NOT OLD.itemsite_loccntrl AND NEW.itemsite_loccntrl) THEN IF (SELECT count(*)=0 FROM location WHERE ((location_warehous_id=NEW.itemsite_warehous_id) AND ( (NOT location_restrict) OR ( (location_restrict) AND (location_id IN ( SELECT locitem_location_id FROM locitem WHERE (locitem_item_id=NEW.itemsite_item_id) ) ) ) ))) THEN RAISE EXCEPTION 'You must first create at least one valid Location for this Item Site before it may be multiply located.'; END IF; END IF; -- Update detail records based on control method changes _wasLocationControl := OLD.itemsite_loccntrl; _isLocationControl := NEW.itemsite_loccntrl; _wasLotSerial := OLD.itemsite_controlmethod IN ('S','L'); _isLotSerial := NEW.itemsite_controlmethod IN ('S','L'); _wasPerishable := OLD.itemsite_perishable; _isPerishable := NEW.itemsite_perishable; _state := 0; IF ( (_wasLocationControl) AND (_isLocationControl) ) THEN _state := 10; ELSIF ( (NOT _wasLocationControl) AND (NOT _isLocationControl) ) THEN _state := 20; ELSIF ( (NOT _wasLocationControl) AND (_isLocationControl) ) THEN _state := 30; ELSIF ( (_wasLocationControl) AND (NOT _isLocationControl) ) THEN _state := 40; END IF; IF ( (_wasLotSerial) AND (_isLotSerial) ) THEN _state := _state + 1; ELSIF ( (NOT _wasLotSerial) AND (NOT _isLotSerial) ) THEN _state := _state + 2; ELSIF ( (NOT _wasLotSerial) AND (_isLotSerial) ) THEN _state := _state + 3; ELSIF ( (_wasLotSerial) AND (NOT _isLotSerial) ) THEN _state := _state + 4; END IF; IF ( (_application = 'Standard') AND (_state IN (41, 43, 14, 34, 24, 42, 44)) ) THEN -- Check for Reservations IF (SELECT COUNT(*) > 0 FROM itemloc JOIN reserve ON (reserve_supply_id=itemloc_id AND reserve_supply_type='I') WHERE (itemloc_itemsite_id=OLD.itemsite_id)) THEN RAISE EXCEPTION 'Sales Order Reservations by Location exist for this Item Site'; END IF; END IF; IF (_state IN (41, 43)) THEN PERFORM consolidateLotSerial(OLD.itemsite_id); ELSIF (_state IN (14, 34)) THEN PERFORM consolidateLocations(OLD.itemsite_id); ELSIF (_state IN (24, 42, 44)) THEN DELETE FROM itemloc WHERE (itemloc_itemsite_id=OLD.itemsite_id); END IF; IF (NEW.itemsite_qtyonhand != 0) THEN -- Handle detail creation -- Create itemloc records if they do not exist IF (_state IN (23, 32, 33)) THEN INSERT INTO itemloc ( itemloc_itemsite_id, itemloc_location_id, itemloc_expiration, itemloc_qty ) VALUES ( NEW.itemsite_id, -1, endOfTime(), NEW.itemsite_qtyonhand ); END IF; -- Handle Location distribution IF (_state IN (31, 32, 33, 34)) THEN IF (SELECT (COUNT(*)=1) FROM location WHERE ((location_id=NEW.itemsite_location_id) AND (location_warehous_id=NEW.itemsite_warehous_id) AND ( (NOT location_restrict) OR ( (location_restrict) AND (location_id IN ( SELECT locitem_location_id FROM locitem WHERE (locitem_item_id=NEW.itemsite_item_id) ) ) ) ))) THEN PERFORM initialDistribution(NEW.itemsite_id, NEW.itemsite_location_id); ELSE RAISE EXCEPTION 'A valid default location must be selected to distribute existing inventory to.'; END IF; END IF; -- Handle Lot/Serial distribution IF ( (_state = 13) OR (_state = 23) OR (_state = 33) OR (_state = 43) ) THEN RAISE WARNING 'You should now use the Reassign Lot/Serial # window to assign Lot/Serial #s.'; END IF; END IF; IF (OLD.itemsite_costmethod='A' AND NEW.itemsite_costmethod='S') THEN -- TODO: Average costing cost method change SELECT stdcost(NEW.itemsite_item_id) * NEW.itemsite_qtyonhand INTO _cost; _variance := _cost - NEW.itemsite_value; NEW.itemsite_value := _cost; IF(_variance <> 0.0) THEN PERFORM insertGLTransaction( 'P/D', '', '', 'Itemsite converted from Average to Standard cost.', costcat_invcost_accnt_id, costcat_asset_accnt_id, NEW.itemsite_id, _variance, CURRENT_DATE ) FROM costcat WHERE(costcat_id=NEW.itemsite_costcat_id); UPDATE itemsite SET itemsite_value = _cost WHERE (itemsite_id = NEW.itemsite_id); END IF; END IF; END IF; -- Handle Perishable IF ( (_application = 'Standard') AND (_wasPerishable) AND (NOT _isPerishable) ) THEN UPDATE itemloc SET itemloc_expiration = endOfTime() WHERE (itemloc_itemsite_id = OLD.itemsite_id); PERFORM consolidateLotSerial(OLD.itemsite_id); END IF; -- If Planning Type changed to None then delete all Planned Orders IF ( (_application = 'Standard') AND (TG_OP = 'UPDATE') ) THEN IF (NEW.itemsite_planning_type = 'N' AND OLD.itemsite_planning_type <> 'N') THEN PERFORM deletePlannedOrder(planord_id, TRUE) FROM planord WHERE (planord_itemsite_id=NEW.itemsite_id); END IF; END IF; END IF; -- End Maintenance RETURN NEW; END; $$; .DROP FUNCTION public._itemsiteaftertrigger(); publicadminfalse84623125577825_itemsitetrigger()FUNCTIONCREATE FUNCTION _itemsitetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; _r RECORD; BEGIN -- Cache some information -- Added item_number as part of feature request 21645 SELECT item_type, item_number INTO _r FROM item WHERE (item_id=NEW.itemsite_item_id); -- Override values to avoid invalid data combinations IF (_r.item_type IN ('J','R','S')) THEN NEW.itemsite_planning_type := 'N'; END IF; IF (_r.item_type = 'L') THEN NEW.itemsite_planning_type := 'S'; END IF; IF (TG_OP = 'UPDATE') THEN IF ( (NEW.itemsite_qtyonhand <> OLD.itemsite_qtyonhand) ) THEN IF (OLD.itemsite_freeze) THEN NEW.itemsite_qtyonhand := OLD.itemsite_qtyonhand; ELSE NEW.itemsite_datelastused := CURRENT_DATE; END IF; IF ( (NEW.itemsite_qtyonhand < 0) AND (OLD.itemsite_qtyonhand >= 0) AND (NEW.itemsite_eventfence > 0) ) THEN PERFORM postEvent('QOHBelowZero', 'I', NEW.itemsite_id, warehous_id, (item_number || '/' || warehous_code), NULL, NULL, NULL, NULL) FROM item, whsinfo WHERE (item_id=NEW.itemsite_item_id) AND (warehous_id=NEW.itemsite_warehous_id); END IF; END IF; IF ( (NEW.itemsite_value <> OLD.itemsite_value) AND (OLD.itemsite_freeze) ) THEN NEW.itemsite_value := OLD.itemsite_value; END IF; END IF; -- Added item_number to error messages displayed to fulfill Feature Request 21645 IF (NEW.itemsite_qtyonhand < 0 AND NEW.itemsite_costmethod = 'A') THEN RAISE EXCEPTION 'Itemsite (%) is set to use average costing and is not allowed to have a negative quantity on hand.', 'ID: ' || NEW.itemsite_id || ', Item: ' || _r.item_number; ELSIF (NEW.itemsite_value < 0 AND NEW.itemsite_costmethod = 'A') THEN RAISE EXCEPTION 'This transaction results in a negative itemsite value. Itemsite (%) is set to use average costing and is not allowed to have a negative value.', 'ID: ' || NEW.itemsite_id || ', Item: ' || _r.item_number; END IF; -- Handle the ChangeLog IF ( SELECT (metric_value='t') FROM metric WHERE (metric_name='ItemSiteChangeLog') ) THEN -- Cache the cmnttype_id for ChangeLog SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (FOUND) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'IS', NEW.itemsite_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.itemsite_plancode_id <> NEW.itemsite_plancode_id) THEN PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id, ( 'Planner Code Changed from "' || oldplancode.plancode_code || '" to "' || newplancode.plancode_code || '"' ) ) FROM plancode AS oldplancode, plancode AS newplancode WHERE ( (oldplancode.plancode_id=OLD.itemsite_plancode_id) AND (newplancode.plancode_id=NEW.itemsite_plancode_id) ); END IF; IF (NEW.itemsite_reorderlevel <> OLD.itemsite_reorderlevel) THEN PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id, ( 'Reorder Level Changed from ' || formatQty(OLD.itemsite_reorderlevel) || ' to ' || formatQty(NEW.itemsite_reorderlevel ) ) ); END IF; IF (NEW.itemsite_ordertoqty <> OLD.itemsite_ordertoqty) THEN PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id, ( 'Order Up To Changed from ' || formatQty(OLD.itemsite_ordertoqty) || ' to ' || formatQty(NEW.itemsite_ordertoqty ) ) ); END IF; IF (NEW.itemsite_leadtime <> OLD.itemsite_leadtime) THEN PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id, ( 'Itemsite Leadtime Changed from ' || formatQty(OLD.itemsite_leadtime) || ' to ' || formatQty(NEW.itemsite_leadtime ) ) ); END IF; IF (NEW.itemsite_abcclass <> OLD.itemsite_abcclass) THEN PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id, ( 'Itemsite ABC Class Changed from ' || COALESCE(OLD.itemsite_abcclass, 'None') || ' to ' || COALESCE(NEW.itemsite_abcclass,'None') ) ); END IF; IF (NEW.itemsite_controlmethod <> OLD.itemsite_controlmethod) THEN PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id, ( 'Itemsite Control Method Changed from ' || COALESCE(OLD.itemsite_controlmethod,'None') || ' to ' || COALESCE(NEW.itemsite_controlmethod,'None') ) ); END IF; IF (OLD.itemsite_sold <> NEW.itemsite_sold) THEN PERFORM postComment( _cmnttypeid, 'IS', NEW.itemsite_id, CASE WHEN (NEW.itemsite_sold) THEN 'Sold Changed from FALSE to TRUE' ELSE 'Sold Changed from TRUE to FALSE' END ); END IF; IF (OLD.itemsite_active <> NEW.itemsite_active) THEN IF (NEW.itemsite_active) THEN PERFORM postComment(_cmnttypeid, 'IS', NEW.itemsite_id, 'Activated'); ELSE PERFORM postComment(_cmnttypeid, 'IS', NEW.itemsite_id, 'Deactivated'); END IF; END IF; END IF; END IF; END IF; RETURN NEW; END; $$; )DROP FUNCTION public._itemsitetrigger(); publicadminfalse46238125577826_itemsrcaftertrigger()FUNCTIONCREATE FUNCTION _itemsrcaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainItemSources')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Item Sources.'; END IF; -- Set default to false for other item sources of this item IF (COALESCE(NEW.itemsrc_default, FALSE) = TRUE) THEN UPDATE itemsrc SET itemsrc_default = FALSE WHERE ( (itemsrc_item_id = NEW.itemsrc_item_id) AND (itemsrc_id <> NEW.itemsrc_id) ); END IF; RETURN NEW; END; $$; -DROP FUNCTION public._itemsrcaftertrigger(); publicadminfalse84623125577827_itemsrcptrigger()FUNCTIONCREATE FUNCTION _itemsrcptrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainItemSources')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Item Sources.'; END IF; -- Set defaults NEW.itemsrcp_curr_id := COALESCE(NEW.itemsrcp_curr_id,basecurrid()); RETURN NEW; END; $$; )DROP FUNCTION public._itemsrcptrigger(); publicadminfalse46238125577828_itemsrctrigger()FUNCTION1CREATE FUNCTION _itemsrctrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainItemSources')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Item Sources.'; END IF; -- Set defaults NEW.itemsrc_invvendoruomratio := COALESCE(NEW.itemsrc_invvendoruomratio,1); NEW.itemsrc_minordqty := COALESCE(NEW.itemsrc_minordqty,0); NEW.itemsrc_multordqty := COALESCE(NEW.itemsrc_multordqty,0); NEW.itemsrc_active := COALESCE(NEW.itemsrc_active,true); NEW.itemsrc_leadtime := COALESCE(NEW.itemsrc_leadtime,0); NEW.itemsrc_ranking := COALESCE(NEW.itemsrc_ranking,1); RETURN NEW; END; $$; (DROP FUNCTION public._itemsrctrigger(); publicadminfalse46238125577829_itemsubtrigger()FUNCTIONCREATE FUNCTION _itemsubtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainItemMasters')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Item Substitutes.'; END IF; RETURN NEW; END; $$; (DROP FUNCTION public._itemsubtrigger(); publicadminfalse84623125577830_itemtaxtrigger()FUNCTIONCREATE FUNCTION _itemtaxtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainItemMasters')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Items.'; END IF; RETURN NEW; END; $$; (DROP FUNCTION public._itemtaxtrigger(); publicadminfalse46238125577831_itemtrigger()FUNCTIONCREATE FUNCTION _itemtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Override values to avoid invalid data combinations IF (NEW.item_type IN ('R','S','O','L','B')) THEN NEW.item_picklist := FALSE; END IF; IF (NEW.item_type IN ('F','S','O','L','B')) THEN NEW.item_picklist := FALSE; NEW.item_sold := FALSE; NEW.item_prodcat_id := -1; NEW.item_exclusive := false; NEW.item_listprice := 0; NEW.item_upccode := ''; NEW.item_prodweight := 0; NEW.item_packweight := 0; END IF; IF (NEW.item_type NOT IN ('M','R')) THEN NEW.item_config := false; END IF; RETURN NEW; END; $$; %DROP FUNCTION public._itemtrigger(); publicadminfalse46238125577832_itemuomconvtrigger()FUNCTIONCREATE FUNCTION _itemuomconvtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Privilege Checks IF (NOT checkPrivilege('MaintainItemMasters')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Items.'; END IF; RETURN NEW; END; $$; ,DROP FUNCTION public._itemuomconvtrigger(); publicadminfalse46238125577833_locationaftertrigger()FUNCTIONCREATE FUNCTION _locationaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _itemloc RECORD; BEGIN RETURN NEW; END; $$; .DROP FUNCTION public._locationaftertrigger(); publicadminfalse84623125577834_locationtrigger()FUNCTIONCREATE FUNCTION _locationtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check BOOLEAN; _checkId INTEGER; BEGIN -- Checks -- Start with privileges IF (TG_OP = 'INSERT') THEN SELECT checkPrivilege('MaintainLocations') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to add new Locations.'; END IF; ELSE SELECT checkPrivilege('MaintainLocations') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to alter a Location.'; END IF; END IF; -- Code is required IF ( (LENGTH(COALESCE(NEW.location_name,''))=0) AND (LENGTH(COALESCE(NEW.location_aisle,''))=0) AND (LENGTH(COALESCE(NEW.location_rack,''))=0) AND (LENGTH(COALESCE(NEW.location_bin,''))=0) ) THEN RAISE EXCEPTION 'You must supply a valid Location Identifier.'; END IF; -- Site is required IF (NEW.location_warehous_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Site.'; END IF; -- Location Identifier must be unique SELECT location_id INTO _checkId FROM location WHERE ( (UPPER(location_name)=UPPER(NEW.location_name)) AND (UPPER(location_aisle)=UPPER(NEW.location_aisle)) AND (UPPER(location_rack)=UPPER(NEW.location_rack)) AND (UPPER(location_bin)=UPPER(NEW.location_bin)) AND (location_warehous_id=NEW.location_warehous_id) AND (location_id<>NEW.location_id) ); IF (FOUND) THEN RAISE EXCEPTION 'You must supply a unique Location Identifier for this Site.'; END IF; -- Populate formatted name IF (NEW.location_aisle IS NOT NULL) THEN NEW.location_formatname := NEW.location_aisle; ELSE NEW.location_formatname := ''; END IF; IF (NEW.location_rack IS NOT NULL) THEN NEW.location_formatname := (NEW.location_formatname || NEW.location_rack); END IF; IF (NEW.location_bin IS NOT NULL) THEN NEW.location_formatname := (NEW.location_formatname || NEW.location_bin); END IF; IF (NEW.location_name IS NOT NULL) THEN NEW.location_formatname := (NEW.location_formatname || NEW.location_name); END IF; RETURN NEW; END; $$; )DROP FUNCTION public._locationtrigger(); publicadminfalse84623125577835_metasqlaltertrigger()FUNCTIONCREATE FUNCTION _metasqlaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (NOT (isDBA() OR checkPrivilege('MaintainMetaSQL'))) THEN RAISE EXCEPTION '% does not have privileges to maintain MetaSQL statements in %.%', getEffectiveXtUser(), TG_TABLE_SCHEMA, TG_TABLE_NAME; END IF; IF ((TG_OP = 'UPDATE' OR TG_OP = 'DELETE') AND NEW.metasql_grade <= 0 AND NOT isDBA()) THEN RAISE EXCEPTION 'You may not alter grade 0 metasql queries except using the xTuple Updater utility'; END IF; IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._metasqlaltertrigger(); publicadminfalse84623125577836_metasqltrigger()FUNCTIONMCREATE FUNCTION _metasqltrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN NEW.metasql_lastuser := getEffectiveXtUser(); NEW.metasql_lastupdate := current_date; RETURN NEW; END; $$; (DROP FUNCTION public._metasqltrigger(); publicadminfalse84623 125586969_normalizeversion(text)FUNCTIONCREATE FUNCTION _normalizeversion(pversion text) RETURNS smallint[] LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- Convert an arbitrary version number string to an array of integers. -- Supports the following styles: -- xTuple 4.5.6Beta2A -- semver 4.5.6-beta.2.a+buildId -- postgres 9.3 DECLARE _result SMALLINT[]; -- 4.5.6 _part TEXT[]; _debug BOOLEAN := false; BEGIN -- extract 4.5.6 _part := regexp_matches(pVersion, -- v----------- 6 -----------v -- capture v-3-v v---- 8 ----v -- 1 2 4 5 7 9 10 -- 4 . 5 . 6 - beta 2 a E'^([0-9]+)\\.([0-9]+)((\\.)([0-9]+))?-?(([a-z]+)\\.?(([0-9]*)\\.?([a-z]?)?)?)?', 'i'); IF _debug THEN RAISE NOTICE 'M: % N: % dP: % d: % P: % rest: % alpha: % sub: % num: % let: %', _part[1], _part[2], _part[3], _part[4], _part[5], _part[6], _part[7], _part[8], _part[9], _part[10]; END IF; _result := ARRAY [ _part[1]::SMALLINT, _part[2]::SMALLINT, COALESCE(_part[5]::SMALLINT, 0), CASE lower(COALESCE(_part[7], '')) WHEN '' THEN 50 WHEN 'rc' THEN 40 WHEN 'beta' THEN 30 WHEN 'alpha' THEN 20 ELSE 10 END, CASE WHEN _part[9] IS NULL THEN 0 WHEN _part[9] = '' THEN 0 ELSE _part[9]::SMALLINT -- beta < beta2 END, ascii(CASE WHEN _part[10] IS NULL THEN '_' WHEN _part[10] = '' THEN '_' ELSE lower(COALESCE(_part[10], '_')) END) -- 2 < 2a ]; IF _debug THEN RAISE NOTICE '_part: % -> _result: %', _part, _result; END IF; IF _part[1] IS NULL OR _part[2] IS NULL THEN RAISE EXCEPTION '% is not recognized as a valid version number', pVersion; END IF; RETURN _result; END; $$; 7DROP FUNCTION public._normalizeversion(pversion text); publicadminfalse46238125587233_opheadafterdeletetrigger()FUNCTIONiCREATE FUNCTION _opheadafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'OPP' AND charass_target_id = OLD.ophead_id; RETURN OLD; END; $$; 2DROP FUNCTION public._opheadafterdeletetrigger(); publicadminfalse84623125577837_opheadaftertrigger()FUNCTIONCREATE FUNCTION _opheadaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; BEGIN IF (TG_OP = 'DELETE') THEN DELETE FROM docass WHERE docass_source_id = OLD.ophead_id AND docass_source_type = 'OPP'; DELETE FROM docass WHERE docass_target_id = OLD.ophead_id AND docass_target_type = 'OPP'; END IF; -- Comments IF ( SELECT (metric_value='t') FROM metric WHERE (metric_name='OpportunityChangeLog') ) THEN -- Cache the cmnttype_id for ChangeLog SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (FOUND) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'OPP', NEW.ophead_id, 'Created'); --- clear the number from the issue cache PERFORM clearNumberIssue('OpportunityNumber', NEW.ophead_number); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.ophead_active <> NEW.ophead_active) THEN IF (NEW.ophead_active) THEN PERFORM postComment(_cmnttypeid, 'OPP', NEW.ophead_id, 'Activated'); ELSE PERFORM postComment(_cmnttypeid, 'OPP', NEW.ophead_id, 'Deactivated'); END IF; END IF; IF (OLD.ophead_name <> NEW.ophead_name) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'Name Changed from "' || OLD.ophead_name || '" to "' || NEW.ophead_name || '"' ) ); END IF; IF (OLD.ophead_owner_username <> NEW.ophead_owner_username) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'Owner Name Changed from "' || OLD.ophead_owner_username || '" to "' || NEW.ophead_owner_username || '"' ) ); END IF; IF (OLD.ophead_probability_prcnt <> NEW.ophead_probability_prcnt) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'Probability % Changed from "' || OLD.ophead_probability_prcnt || '" to "' || NEW.ophead_probability_prcnt || '"' ) ); END IF; IF (OLD.ophead_amount <> NEW.ophead_amount) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'Amount Changed from "' || OLD.ophead_amount || '" to "' || NEW.ophead_amount || '"' ) ); END IF; IF (OLD.ophead_target_date <> NEW.ophead_target_date) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'Target Date Changed from "' || OLD.ophead_target_date || '" to "' || NEW.ophead_target_date || '"' ) ); END IF; IF (OLD.ophead_actual_date <> NEW.ophead_actual_date) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'Actual Date Changed from "' || OLD.ophead_actual_date || '" to "' || NEW.ophead_actual_date || '"' ) ); END IF; IF (OLD.ophead_crmacct_id <> NEW.ophead_crmacct_id) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'CRM Account Changed from "' || (SELECT crmacct_name FROM crmacct WHERE crmacct_id=OLD.ophead_crmacct_id) || '" (' || OLD.ophead_crmacct_id || ') to "' || (SELECT crmacct_name FROM crmacct WHERE crmacct_id=NEW.ophead_crmacct_id) || '" (' || NEW.ophead_crmacct_id || ')' ) ); END IF; IF (OLD.ophead_curr_id <> NEW.ophead_curr_id) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'Currency Changed from "' || (SELECT curr_name FROM curr_symbol WHERE curr_id=OLD.ophead_curr_id) || '" (' || OLD.ophead_curr_id || ') to "' || (SELECT curr_name FROM curr_symbol WHERE curr_id=NEW.ophead_curr_id) || '" (' || NEW.ophead_curr_id || ')' ) ); END IF; IF (OLD.ophead_opstage_id <> NEW.ophead_opstage_id) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'Stage Changed from "' || (SELECT opstage_name FROM opstage WHERE opstage_id=OLD.ophead_opstage_id) || '" (' || OLD.ophead_opstage_id || ') to "' || (SELECT opstage_name FROM opstage WHERE opstage_id=NEW.ophead_opstage_id) || '" (' || NEW.ophead_opstage_id || ')' ) ); END IF; IF (OLD.ophead_opsource_id <> NEW.ophead_opsource_id) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'Source Changed from "' || (SELECT opsource_name FROM opsource WHERE opsource_id=OLD.ophead_opsource_id) || '" (' || OLD.ophead_opsource_id || ') to "' || (SELECT opsource_name FROM opsource WHERE opsource_id=NEW.ophead_opsource_id) || '" (' || NEW.ophead_opsource_id || ')' ) ); END IF; IF (OLD.ophead_optype_id <> NEW.ophead_optype_id) THEN PERFORM postComment( _cmnttypeid, 'OPP', NEW.ophead_id, ( 'Type Changed from "' || (SELECT optype_name FROM optype WHERE optype_id=OLD.ophead_optype_id) || '" (' || OLD.ophead_optype_id || ') to "' || (SELECT optype_name FROM optype WHERE optype_id=NEW.ophead_optype_id) || '" (' || NEW.ophead_optype_id || ')' ) ); END IF; END IF; END IF; END IF; RETURN NEW; END; $$; ,DROP FUNCTION public._opheadaftertrigger(); publicadminfalse46238125577838_opheadbeforetrigger()FUNCTION6CREATE FUNCTION _opheadbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _rec record; _check boolean; _test text; BEGIN IF(TG_OP = 'DELETE') THEN _rec := OLD; ELSE _rec := NEW; END IF; -- Auto inactivate IF (TG_OP = 'UPDATE') THEN IF ( (NEW.ophead_opstage_id != OLD.ophead_opstage_id) AND (SELECT opstage_opinactive FROM opstage WHERE opstage_id=NEW.ophead_opstage_id) ) THEN NEW.ophead_active := FALSE; END IF; END IF; IF (TG_OP = 'INSERT') THEN IF (SELECT opstage_opinactive FROM opstage WHERE opstage_id=NEW.ophead_opstage_id) THEN NEW.ophead_active := FALSE; END IF; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._opheadbeforetrigger(); publicadminfalse46238125577839_packbeforetrigger()FUNCTIONCREATE FUNCTION _packbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; BEGIN SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (FOUND) THEN IF ((TG_OP = 'INSERT') AND (NEW.pack_head_id) IS NOT NULL)THEN PERFORM postComment(_cmnttypeid, 'S', NEW.pack_head_id, 'Added to Packing List Batch'); END IF; END IF; IF ((TG_OP = 'INSERT') OR (TG_OP = 'UPDATE')) THEN IF (NEW.pack_shiphead_id IS NOT NULL AND NEW.pack_shiphead_id NOT IN (SELECT shiphead_id FROM shiphead WHERE (shiphead_order_id=NEW.pack_head_id) AND (shiphead_order_type=NEW.pack_head_type))) THEN RAISE EXCEPTION 'Shipment does not exist for % id %', NEW.pack_head_type, NEW.pack_head_id; RETURN OLD; END IF; IF (NEW.pack_head_type = 'SO' AND NEW.pack_head_id IN (SELECT cohead_id FROM cohead)) THEN RETURN NEW; ELSEIF (NEW.pack_head_type = 'TO') THEN IF (NOT fetchMetricBool('MultiWhs')) THEN RAISE EXCEPTION 'Transfer Orders are not supported by this version of the application'; ELSEIF (NEW.pack_head_id IN (SELECT tohead_id FROM tohead)) THEN RETURN NEW; END IF; END IF; RAISE EXCEPTION '% with id % does not exist', NEW.pack_head_type, NEW.pack_head_id; RETURN OLD; END IF; RETURN NEW; END; $$; +DROP FUNCTION public._packbeforetrigger(); publicadminfalse46238125577840_periodaftertrigger()FUNCTIONoCREATE FUNCTION _periodaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _idoffirst INTEGER; _test INTEGER; BEGIN -- This trigger can easily cause an infinite loop -- because of this we have to be very careful to not -- do an update on the period table if no updates -- are absolutely needed so we don't just keep -- trigger ourselves again and again -- Figure out which period is the first one SELECT period_id INTO _idoffirst FROM period ORDER BY period_start LIMIT 1; -- If we didn't find anything there is nothing to do IF( NOT FOUND ) THEN RETURN NEW; END IF; -- do a select to see if there is at least one record that needs to be -- updated. If we do not find any then we can just leave without -- causing a retrigger of ourselves SELECT period_id INTO _test FROM period WHERE((COALESCE(period_initial, true) AND (NOT period_id=_idoffirst)) OR ((NOT COALESCE(period_initial, false)) AND (period_id=_idoffirst))) LIMIT 1; -- Nothing to update - get out of here IF( NOT FOUND ) THEN RETURN NEW; END IF; -- Update all the period records that already have the initial flag -- set and the one that we know should be the first. -- We don't have to be as careful here since we have already ruled -- out if don't need to update already. UPDATE period SET period_initial = (_idoffirst=period_id) WHERE((COALESCE(period_initial, true)) OR (period_id=_idoffirst)); RETURN NEW; END; $$; ,DROP FUNCTION public._periodaftertrigger(); publicadminfalse46238125577841_pkgcmdaftertrigger()FUNCTION*CREATE FUNCTION _pkgcmdaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; ,DROP FUNCTION public._pkgcmdaftertrigger(); publicadminfalse84623125577842_pkgcmdaltertrigger()FUNCTIONECREATE FUNCTION _pkgcmdaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END IF; IF (TG_OP = 'INSERT') THEN RAISE EXCEPTION 'You may not create custom commands in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'UPDATE') THEN RAISE EXCEPTION 'You may not alter custom commands in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'DELETE') THEN RAISE EXCEPTION 'You may not delete custom commands from packages. Try deleting or disabling the package.'; END IF; RETURN NEW; END; $$; ,DROP FUNCTION public._pkgcmdaltertrigger(); publicadminfalse46238 125577843_pkgcmdargaftertrigger()FUNCTION,CREATE FUNCTION _pkgcmdargaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; /DROP FUNCTION public._pkgcmdargaftertrigger(); publicadminfalse84623 125577844_pkgcmdargaltertrigger()FUNCTIONNCREATE FUNCTION _pkgcmdargaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END IF; IF (TG_OP = 'INSERT') THEN RAISE EXCEPTION 'You may not create command arguments in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'UPDATE') THEN RAISE EXCEPTION 'You may not alter command arguments in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'DELETE') THEN RAISE EXCEPTION 'You may not delete command arguments from packages. Try deleting or disabling the package.'; END IF; RETURN NEW; END; $$; /DROP FUNCTION public._pkgcmdargaltertrigger(); publicadminfalse84623 125577845_pkgcmdargbeforetrigger()FUNCTIONCREATE FUNCTION _pkgcmdargbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmdargid INTEGER; _debug BOOL := false; BEGIN IF (TG_OP = 'UPDATE') THEN RETURN NEW; ELSIF (TG_OP = 'INSERT') THEN RETURN NEW; ELSIF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; 0DROP FUNCTION public._pkgcmdargbeforetrigger(); publicadminfalse84623125577846_pkgcmdbeforetrigger()FUNCTIONCREATE FUNCTION _pkgcmdbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmdid INTEGER; _debug BOOL := false; BEGIN IF (TG_OP = 'UPDATE') THEN IF (_debug) THEN RAISE NOTICE 'OLD.cmd_name %, NEW.cmd_name %', OLD.cmd_name, NEW.cmd_name; END IF; IF (NEW.cmd_name != OLD.cmd_name) THEN SELECT cmd_id INTO _cmdid FROM cmd WHERE cmd_name=NEW.cmd_name; IF (FOUND) THEN RAISE EXCEPTION 'Cannot change command name % because another command with that name already exists.', NEW.cmd_name; END IF; END IF; ELSIF (TG_OP = 'INSERT') THEN IF (_debug) THEN RAISE NOTICE 'inserting NEW.cmd_name %', NEW.cmd_name; END IF; SELECT cmd_id INTO _cmdid FROM cmd WHERE cmd_name=NEW.cmd_name; IF (FOUND) THEN RAISE EXCEPTION 'Cannot create new command % because another command with that name already exists.', NEW.cmd_name; END IF; ELSIF (TG_OP = 'DELETE') THEN DELETE FROM cmdarg WHERE cmdarg_cmd_id=OLD.cmd_id; RETURN OLD; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._pkgcmdbeforetrigger(); publicadminfalse84623125577847_pkgheadbeforetrigger()FUNCTIONCREATE FUNCTION _pkgheadbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; BEGIN IF (TG_OP = 'UPDATE') THEN NEW.pkghead_created := OLD.pkghead_created; NEW.pkghead_updated := CURRENT_TIMESTAMP; IF (NEW.pkghead_indev AND NOT userCanCreateUsers(getEffectiveXtUser())) THEN NEW.pkghead_indev = FALSE; END IF; ELSIF (TG_OP = 'INSERT') THEN NEW.pkghead_created := CURRENT_TIMESTAMP; NEW.pkghead_updated := NEW.pkghead_created; IF (NEW.pkghead_indev AND NOT userCanCreateUsers(getEffectiveXtUser())) THEN NEW.pkghead_indev = FALSE; END IF; ELSIF (TG_OP = 'DELETE') THEN DELETE FROM pkgdep WHERE pkgdep_pkghead_id=OLD.pkghead_id; EXECUTE 'DROP SCHEMA ' || OLD.pkghead_name || ' CASCADE'; RETURN OLD; END IF; RETURN NEW; END; $$; .DROP FUNCTION public._pkgheadbeforetrigger(); publicadminfalse84623 125577848_pkgimageaftertrigger()FUNCTION,CREATE FUNCTION _pkgimageaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; .DROP FUNCTION public._pkgimageaftertrigger(); publicadminfalse84623 125577849_pkgimagealtertrigger()FUNCTION+CREATE FUNCTION _pkgimagealtertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END IF; IF (TG_OP = 'INSERT') THEN RAISE EXCEPTION 'You may not create images in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'UPDATE') THEN RAISE EXCEPTION 'You may not alter images in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'DELETE') THEN RAISE EXCEPTION 'You may not delete images from packages. Try deleting or disabling the package.'; END IF; RETURN NEW; END; $$; .DROP FUNCTION public._pkgimagealtertrigger(); publicadminfalse84623 125577850_pkgimagebeforetrigger()FUNCTIONCREATE FUNCTION _pkgimagebeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _imageid INTEGER; _debug BOOL := false; BEGIN IF (TG_OP = 'UPDATE') THEN IF (_debug) THEN RAISE NOTICE 'OLD.image_name %, NEW.image_name %', OLD.image_name, NEW.image_name; END IF; IF (NEW.image_name != OLD.image_name) THEN SELECT image_id INTO _imageid FROM image WHERE image_name=NEW.image_name; IF (FOUND) THEN RAISE EXCEPTION 'Cannot change image named % because another image with that name already exists.', NEW.image_name; END IF; END IF; ELSIF (TG_OP = 'INSERT') THEN IF (_debug) THEN RAISE NOTICE 'inserting NEW.image_name %', NEW.image_name; END IF; SELECT image_id INTO _imageid FROM image WHERE image_name=NEW.image_name; IF (FOUND) THEN RAISE EXCEPTION 'Cannot create new image % because another image with that name already exists.', NEW.image_name; END IF; ELSIF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; /DROP FUNCTION public._pkgimagebeforetrigger(); publicadminfalse46238125577851_pkgitembeforetrigger()FUNCTION$CREATE FUNCTION _pkgitembeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _functionargs TEXT; _group TEXT; _object TEXT; _schema TEXT; _debug BOOL := false; BEGIN IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN _object = NEW.pkgitem_name; SELECT LOWER(pkghead_name) INTO _schema FROM pkghead WHERE (pkghead_id=NEW.pkgitem_pkghead_id); IF (NOT FOUND) THEN _schema := 'public'; END IF; IF (NEW.pkgitem_type = 'F') THEN _object := SPLIT_PART(_object, '(', 1); ELSIF (NEW.pkgitem_type = 'M') THEN _group := SPLIT_PART(_object, '-', 1); _object := SPLIT_PART(_object, '-', 2); END IF; IF _debug THEN RAISE NOTICE '_schema % and _object %', _schema, _object; END IF; IF (NEW.pkgitem_type = 'C') THEN IF (NOT EXISTS(SELECT script_id FROM script WHERE ((script_id=NEW.pkgitem_item_id) AND (script_name=NEW.pkgitem_name)))) THEN RAISE EXCEPTION 'Cannot create Script % as a Package Item without a corresponding script record.', NEW.pkgitem_name; END IF; ELSIF (NEW.pkgitem_type = 'D') THEN IF (NOT EXISTS(SELECT cmd_id FROM cmd WHERE ((cmd_id=NEW.pkgitem_item_id) AND (cmd_name=NEW.pkgitem_name)))) THEN RAISE EXCEPTION 'Cannot create Custom Command % as a Package Item without a corresponding cmd record.', NEW.pkgitem_name; END IF; ELSIF (NEW.pkgitem_type = 'F') THEN IF (NOT EXISTS(SELECT pg_proc.oid FROM pg_proc, pg_namespace WHERE ((pg_proc.oid=NEW.pkgitem_item_id) AND (proname = (_object)) AND (pronamespace=pg_namespace.oid) AND (nspname=_schema)) )) THEN RAISE EXCEPTION 'Cannot create Function % (oid %) as a Package Item without a corresponding function in the database.', NEW.pkgitem_name, NEW.pkgitem_item_id; END IF; ELSIF (NEW.pkgitem_type = 'G') THEN IF (NOT EXISTS(SELECT pg_class.oid FROM pg_trigger, pg_class, pg_namespace WHERE ((tgname=_object) AND (tgrelid=pg_class.oid) AND (relnamespace=pg_namespace.oid) AND (nspname=_schema)))) THEN RAISE EXCEPTION 'Cannot create Trigger % as a Package Item without a corresponding trigger in the database.', NEW.pkgitem_name; END IF; ELSIF (NEW.pkgitem_type = 'I') THEN IF (NOT EXISTS(SELECT image_id FROM image WHERE ((image_id=NEW.pkgitem_item_id) AND (image_name=NEW.pkgitem_name)))) THEN RAISE EXCEPTION 'Cannot create Image % as a Package Item without a corresponding image record.', NEW.pkgitem_name; END IF; ELSIF (NEW.pkgitem_type = 'M') THEN IF (NOT EXISTS(SELECT metasql_id FROM metasql WHERE ((metasql_id=NEW.pkgitem_item_id) AND (metasql_group=_group) AND (metasql_name=_object)))) THEN RAISE EXCEPTION 'Cannot create MetaSQL statement % as a Package Item without a corresponding metasql record.', NEW.pkgitem_name; END IF; ELSIF (NEW.pkgitem_type = 'P') THEN IF (NOT EXISTS(SELECT priv_id FROM priv WHERE ((priv_id=NEW.pkgitem_item_id) AND (priv_name=NEW.pkgitem_name)))) THEN RAISE EXCEPTION 'Cannot create Privilege % as a Package Item without a corresponding priv record.', NEW.pkgitem_name; END IF; ELSIF (NEW.pkgitem_type = 'R') THEN IF (NOT EXISTS(SELECT report_id FROM report WHERE ((report_id=NEW.pkgitem_item_id) AND (report_name=NEW.pkgitem_name)))) THEN RAISE EXCEPTION 'Cannot create Report % as a Package Item without a corresponding report record.', NEW.pkgitem_name; END IF; ELSIF (NEW.pkgitem_type = 'S') THEN IF (NOT EXISTS(SELECT oid FROM pg_namespace WHERE (LOWER(nspname)=LOWER(NEW.pkgitem_name)))) THEN RAISE EXCEPTION 'Cannot create Schema % as a Package Item without a corresponding schema in the database.', NEW.pkgitem_name; END IF; ELSIF (NEW.pkgitem_type = 'T') THEN IF (NOT EXISTS(SELECT pg_class.oid FROM pg_class, pg_namespace WHERE ((relname=_object) AND (relnamespace=pg_namespace.oid) AND (relkind='r') AND (nspname=_schema)))) THEN RAISE EXCEPTION 'Cannot create Table % as a Package Item without a corresponding table in the database.', NEW.pkgitem_name; END IF; ELSIF (NEW.pkgitem_type = 'U') THEN IF (NOT EXISTS(SELECT uiform_id FROM uiform WHERE ((uiform_id=NEW.pkgitem_item_id) AND (uiform_name=NEW.pkgitem_name)))) THEN RAISE EXCEPTION 'Cannot create User Interface Form % as a Package Item without a corresponding uiform record.', NEW.pkgitem_name; END IF; ELSIF (NEW.pkgitem_type = 'V') THEN IF (NOT EXISTS(SELECT pg_class.oid FROM pg_class, pg_namespace WHERE ((relname=_object) AND (relnamespace=pg_namespace.oid) AND (relkind='v') AND (nspname=_schema)))) THEN RAISE EXCEPTION 'Cannot create View % as a Package Item without a corresponding view in the database.', NEW.pkgitem_name; END IF; ELSE RAISE EXCEPTION '"%" is not a valid type of package item.', NEW.pkgitem_type; END IF; ELSIF (TG_OP = 'DELETE') THEN IF _debug THEN RAISE NOTICE 'Deleting % % %', OLD.pkgitem_item_id, OLD.pkgitem_name, OLD.pkgitem_type; END IF; _object = OLD.pkgitem_name; SELECT pkghead_name INTO _schema FROM pkghead WHERE (pkghead_id=OLD.pkgitem_pkghead_id); IF (NOT FOUND) THEN _schema := 'public'; END IF; IF (OLD.pkgitem_type = 'F') THEN _object := SPLIT_PART(_object, '(', 1); ELSIF (OLD.pkgitem_type = 'M') THEN _group := SPLIT_PART(_object, '-', 1); _object := SPLIT_PART(_object, '-', 2); END IF; IF _debug THEN RAISE NOTICE '_schema % and _object %', _schema, _object; END IF; IF (OLD.pkgitem_type = 'C') THEN DELETE FROM script WHERE ((script_id=OLD.pkgitem_item_id) AND (script_name=OLD.pkgitem_name)); ELSIF (OLD.pkgitem_type = 'D') THEN DELETE FROM cmd WHERE ((cmd_id=OLD.pkgitem_item_id) AND (cmd_name=OLD.pkgitem_name)); ELSIF (OLD.pkgitem_type = 'F') THEN -- SELECT dropIfExists('FUNCTION', CAST (oid::regprocedure AS TEXT), _schema) PERFORM dropIfExists('FUNCTION', proname || '(' || oidvectortypes(proargtypes) || ')', _schema) FROM pg_proc WHERE (oid=OLD.pkgitem_item_id); ELSIF (OLD.pkgitem_type = 'G') THEN PERFORM dropIfExists('TRIGGER', _object, _schema); ELSIF (OLD.pkgitem_type = 'I') THEN DELETE FROM image WHERE ((image_id=OLD.pkgitem_item_id) AND (image_name=OLD.pkgitem_name)); ELSIF (OLD.pkgitem_type = 'M') THEN DELETE FROM metasql WHERE ((metasql_id=OLD.pkgitem_item_id) AND (metasql_group=_group) AND (metasql_name=_object)); ELSIF (OLD.pkgitem_type = 'P') THEN DELETE FROM priv WHERE ((priv_id=OLD.pkgitem_item_id) AND (priv_name=OLD.pkgitem_name)); ELSIF (OLD.pkgitem_type = 'R') THEN DELETE FROM report WHERE ((report_id=OLD.pkgitem_item_id) AND (report_name=OLD.pkgitem_name)); ELSIF (OLD.pkgitem_type = 'S') THEN PERFORM dropIfExists('SCHEMA', OLD.pkgitem_name, OLD.pkgitem_name); ELSIF (OLD.pkgitem_type = 'T') THEN PERFORM dropIfExists('TABLE', _object, _schema, true); ELSIF (OLD.pkgitem_type = 'U') THEN DELETE FROM uiform WHERE ((uiform_id=OLD.pkgitem_item_id) AND (uiform_name=OLD.pkgitem_name)); ELSIF (OLD.pkgitem_type = 'V') THEN PERFORM dropIfExists('VIEW', _object, _schema, true); ELSE RAISE EXCEPTION '"%" is not a valid type of package item.', OLD.pkgitem_type; END IF; RETURN OLD; END IF; RETURN NEW; END; $$; .DROP FUNCTION public._pkgitembeforetrigger(); publicadminfalse46238 125577853_pkgmetasqlaftertrigger()FUNCTION.CREATE FUNCTION _pkgmetasqlaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; 0DROP FUNCTION public._pkgmetasqlaftertrigger(); publicadminfalse46238 125577854_pkgmetasqlaltertrigger()FUNCTIONCREATE FUNCTION _pkgmetasqlaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END IF; -- cannot combine IF's because plpgsql does not always evaluate left-to-right IF (TG_OP = 'INSERT') THEN IF (NEW.metasql_grade <= 0 AND NOT _isdba) THEN RAISE EXCEPTION 'You may not create grade 0 MetaSQL statements in packages except using the xTuple Updater utility'; END IF; ELSIF (TG_OP = 'UPDATE') THEN IF (NEW.metasql_grade <= 0 AND NOT _isdba) THEN RAISE EXCEPTION 'You may not alter grade 0 MetaSQL statements in packages except using the xTuple Updater utility'; END IF; ELSIF (TG_OP = 'DELETE') THEN IF (OLD.metasql_grade <= 0 AND NOT _isdba) THEN RAISE EXCEPTION 'You may not delete grade 0 MetaSQL statements from packages. Try deleting or disabling the package.'; ELSE RETURN OLD; END IF; END IF; RETURN NEW; END; $$; 0DROP FUNCTION public._pkgmetasqlaltertrigger(); publicadminfalse46238 125577855_pkgmetasqlbeforetrigger()FUNCTIONCREATE FUNCTION _pkgmetasqlbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _metasqlid INTEGER; _isdba BOOLEAN := false; BEGIN SELECT rolsuper INTO _isdba FROM pg_roles WHERE (rolname=getEffectiveXtUser()); IF (NOT (_isdba OR checkPrivilege('MaintainMetaSQL'))) THEN RAISE EXCEPTION '% does not have privileges to maintain MetaSQL statements in %.% (DBA=%)', getEffectiveXtUser(), TG_TABLE_SCHEMA, TG_TABLE_NAME, _isdba; END IF; IF (TG_OP = 'UPDATE') THEN RAISE DEBUG 'update OLD %-%-%, NEW %-%-%', OLD.metasql_group, OLD.metasql_name, OLD.metasql_grade, NEW.metasql_group, NEW.metasql_name, NEW.metasql_grade; IF (NEW.metasql_name != OLD.metasql_name OR NEW.metasql_group != OLD.metasql_group OR NEW.metasql_grade != OLD.metasql_grade) THEN SELECT metasql_id INTO _metasqlid FROM metasql WHERE metasql_name=NEW.metasql_name AND metasql_group=NEW.metasql_group AND metasql_grade=NEW.metasql_grade; IF (FOUND) THEN RAISE EXCEPTION 'Cannot change the MetaSQL statement named %-%-% because another MetaSQL statement with that group, name and grade already exists.', NEW.metasql_group, NEW.metasql_name, NEW.metasql_grade; END IF; END IF; ELSIF (TG_OP = 'INSERT') THEN RAISE DEBUG 'insert NEW %-% %', NEW.metasql_group, NEW.metasql_name, NEW.metasql_grade; SELECT metasql_id INTO _metasqlid FROM metasql WHERE metasql_name=NEW.metasql_name AND metasql_group=NEW.metasql_group AND metasql_grade=NEW.metasql_grade; IF (FOUND) THEN RAISE EXCEPTION 'The new MetaSQL statement %-% % conflicts with an existing statement.', NEW.metasql_group, NEW.metasql_name, NEW.metasql_grade; END IF; ELSIF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; 1DROP FUNCTION public._pkgmetasqlbeforetrigger(); publicadminfalse84623 125577856_pkgprivaftertrigger()FUNCTION+CREATE FUNCTION _pkgprivaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._pkgprivaftertrigger(); publicadminfalse46238 125577857_pkgprivaltertrigger()FUNCTION7CREATE FUNCTION _pkgprivaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END IF; IF (TG_OP = 'INSERT') THEN RAISE EXCEPTION 'You may not create privileges in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'UPDATE') THEN RAISE EXCEPTION 'You may not alter privileges in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'DELETE') THEN RAISE EXCEPTION 'You may not delete privileges from packages. Try deleting or disabling the package.'; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._pkgprivaltertrigger(); publicadminfalse84623 125577858_pkgprivbeforetrigger()FUNCTIONrCREATE FUNCTION _pkgprivbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _privid INTEGER; _debug BOOL := false; BEGIN IF (TG_OP = 'UPDATE') THEN IF (_debug) THEN RAISE NOTICE 'OLD.priv_name %, NEW.priv_name %', OLD.priv_name, NEW.priv_name; END IF; IF (NEW.priv_name != OLD.priv_name) THEN SELECT priv_id INTO _privid FROM priv WHERE priv_name=NEW.priv_name; IF (FOUND) THEN RAISE EXCEPTION 'Cannot change privilege name % because another privilege with that name already exists.', NEW.priv_name; END IF; END IF; ELSIF (TG_OP = 'INSERT') THEN IF (_debug) THEN RAISE NOTICE 'inserting NEW.priv_name %', NEW.priv_name; END IF; SELECT priv_id INTO _privid FROM priv WHERE priv_name=NEW.priv_name; IF (FOUND) THEN RAISE EXCEPTION 'Cannot create new privilege % because another privilege with that name already exists.', NEW.priv_name; END IF; ELSIF (TG_OP = 'DELETE') THEN IF (_debug) THEN RAISE NOTICE 'deleting pkgpriv_id %', OLD.priv_id; END IF; DELETE FROM usrpriv WHERE usrpriv_priv_id=OLD.priv_id; DELETE FROM grppriv WHERE grppriv_priv_id=OLD.priv_id; RETURN OLD; END IF; RETURN NEW; END; $$; .DROP FUNCTION public._pkgprivbeforetrigger(); publicadminfalse46238125577859_pkgreportaftertrigger()FUNCTION-CREATE FUNCTION _pkgreportaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; /DROP FUNCTION public._pkgreportaftertrigger(); publicadminfalse84623 125577860_pkgreportaltertrigger()FUNCTIONPCREATE FUNCTION _pkgreportaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END IF; IF (TG_OP = 'INSERT') THEN RAISE EXCEPTION 'You may not create report definitions in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'UPDATE') THEN RAISE EXCEPTION 'You may not alter report definitions in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'DELETE') THEN RAISE EXCEPTION 'You may not delete report definitions from packages. Try deleting or disabling the package.'; END IF; RETURN NEW; END; $$; /DROP FUNCTION public._pkgreportaltertrigger(); publicadminfalse46238 125577861_pkgreportbeforetrigger()FUNCTIONCREATE FUNCTION _pkgreportbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _reportid INTEGER; _debug BOOL := false; BEGIN IF (TG_OP = 'UPDATE') THEN IF (_debug) THEN RAISE NOTICE 'update OLD % %, NEW % %', OLD.report_name, OLD.report_grade, NEW.report_name, NEW.report_grade; END IF; IF (NEW.report_name != OLD.report_name) THEN SELECT report_id INTO _reportid FROM report WHERE ((report_name=NEW.report_name) AND (report_grade=NEW.report_grade)); IF (FOUND) THEN RAISE EXCEPTION 'Cannot change report % % because another report with that name and grade already exists.', NEW.report_name, NEW.report_grade; END IF; END IF; ELSIF (TG_OP = 'INSERT') THEN IF (_debug) THEN RAISE NOTICE 'insert NEW % %', NEW.report_name, NEW.report_grade; END IF; SELECT report_id INTO _reportid FROM report WHERE ((report_name=NEW.report_name) AND (report_grade=NEW.report_grade)); IF (FOUND) THEN RAISE EXCEPTION 'Cannot create new report % % because another report with that name and grade already exists.', NEW.report_name, NEW.report_grade; END IF; ELSIF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; 0DROP FUNCTION public._pkgreportbeforetrigger(); publicadminfalse84623 125577862_pkgscriptaftertrigger()FUNCTION-CREATE FUNCTION _pkgscriptaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; /DROP FUNCTION public._pkgscriptaftertrigger(); publicadminfalse46238 125577863_pkgscriptaltertrigger()FUNCTION/CREATE FUNCTION _pkgscriptaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END IF; IF (TG_OP = 'INSERT') THEN RAISE EXCEPTION 'You may not create scripts in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'UPDATE') THEN RAISE EXCEPTION 'You may not alter scripts in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'DELETE') THEN RAISE EXCEPTION 'You may not delete scripts from packages. Try deleting or disabling the package.'; END IF; RETURN NEW; END; $$; /DROP FUNCTION public._pkgscriptaltertrigger(); publicadminfalse46238)125577864_pkgscriptbeforetrigger()FUNCTIONCREATE FUNCTION _pkgscriptbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _scriptid INTEGER; _debug BOOL := false; BEGIN IF (TG_OP = 'UPDATE') THEN RETURN NEW; ELSIF (TG_OP = 'INSERT') THEN RETURN NEW; ELSIF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; 0DROP FUNCTION public._pkgscriptbeforetrigger(); publicadminfalse84623 125577865_pkguiformaftertrigger()FUNCTION-CREATE FUNCTION _pkguiformaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; /DROP FUNCTION public._pkguiformaftertrigger(); publicadminfalse46238 125577866_pkguiformaltertrigger()FUNCTION*CREATE FUNCTION _pkguiformaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pkgMayBeModified(TG_TABLE_SCHEMA) OR isDba()) THEN IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END IF; IF (TG_OP = 'INSERT') THEN RAISE EXCEPTION 'You may not create forms in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'UPDATE') THEN RAISE EXCEPTION 'You may not alter forms in packages except using the xTuple Updater utility'; ELSIF (TG_OP = 'DELETE') THEN RAISE EXCEPTION 'You may not delete forms from packages. Try deleting or disabling the package.'; END IF; RETURN NEW; END; $$; /DROP FUNCTION public._pkguiformaltertrigger(); publicadminfalse84623 125577867_pkguiformbeforetrigger()FUNCTIONCREATE FUNCTION _pkguiformbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _uiformid INTEGER; _debug BOOL := false; BEGIN IF (TG_OP = 'UPDATE') THEN RETURN NEW; ELSIF (TG_OP = 'INSERT') THEN RETURN NEW; ELSIF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; 0DROP FUNCTION public._pkguiformbeforetrigger(); publicadminfalse46238 125587242_poheadafterdeletetrigger()FUNCTIONhCREATE FUNCTION _poheadafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'PO' AND charass_target_id = OLD.pohead_id; RETURN OLD; END; $$; 2DROP FUNCTION public._poheadafterdeletetrigger(); publicadminfalse46238 125577868_poheadtrigger()FUNCTIONS CREATE FUNCTION _poheadtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; _check BOOLEAN; _maint BOOLEAN := TRUE; BEGIN -- Check if we are doing maintenance IF (TG_OP = 'UPDATE') THEN IF ( (OLD.pohead_status != NEW.pohead_status) OR (OLD.pohead_printed != NEW.pohead_printed) ) THEN _maint := FALSE; END IF; END IF; -- Check IF ( (NOT _maint) AND (NOT checkPrivilege('MaintainPurchaseOrders')) AND (NOT checkPrivilege('PostPurchaseOrders')) AND (NOT checkPrivilege('PrintPurchaseOrders')) AND (NOT checkPrivilege('PostVouchers')) ) THEN RAISE EXCEPTION 'You do not have privileges to alter a Purchase Order.'; END IF; IF ( _maint AND (NOT checkPrivilege('MaintainPurchaseOrders')) ) THEN RAISE EXCEPTION 'You do not have privileges to alter a Purchase Order.'; END IF; IF (TG_OP = 'INSERT') THEN --- clear the number from the issue cache PERFORM clearNumberIssue('PoNumber', NEW.pohead_number); END IF; IF ( (TG_OP = 'INSERT') OR (TG_op = 'UPDATE') ) THEN IF (NOT ISNUMERIC(NEW.pohead_number) AND NEW.pohead_saved) THEN RAISE EXCEPTION 'Purchase Order Number must be numeric.'; END IF; END IF; IF (TG_OP = 'UPDATE') THEN IF (NEW.pohead_status = 'O' AND OLD.pohead_released IS NULL) THEN NEW.pohead_released := CURRENT_DATE; END IF; END IF; IF ( SELECT (metric_value='t') FROM metric WHERE (metric_name='POChangeLog') ) THEN -- Cache the cmnttype_id for ChangeLog SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (FOUND) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'P', NEW.pohead_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.pohead_terms_id <> NEW.pohead_terms_id) THEN PERFORM postComment( _cmnttypeid, 'P', NEW.pohead_id, ('Terms Changed from "' || oldterms.terms_code || '" to "' || newterms.terms_code || '"') ) FROM terms AS oldterms, terms AS newterms WHERE ( (oldterms.terms_id=OLD.pohead_terms_id) AND (newterms.terms_id=NEW.pohead_terms_id) ); END IF; ELSIF (TG_OP = 'DELETE') THEN DELETE FROM docass WHERE docass_source_id = OLD.pohead_id AND docass_source_type = 'P'; DELETE FROM docass WHERE docass_target_id = OLD.pohead_id AND docass_target_type = 'P'; DELETE FROM comment WHERE ( (comment_source='P') AND (comment_source_id=OLD.pohead_id) ); END IF; END IF; END IF; IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END; $$; 'DROP FUNCTION public._poheadtrigger(); publicadminfalse46238 125577869_poheadtriggerafter()FUNCTION:CREATE FUNCTION _poheadtriggerafter() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (COALESCE(NEW.pohead_taxzone_id,-1) <> COALESCE(OLD.pohead_taxzone_id,-1)) THEN UPDATE poitem SET poitem_taxtype_id=getItemTaxType(itemsite_item_id,NEW.pohead_taxzone_id) FROM itemsite WHERE ((itemsite_id=poitem_itemsite_id) AND (poitem_pohead_id=NEW.pohead_id)); END IF; -- Do not update closed poitems IF (TG_OP = 'UPDATE') THEN IF (OLD.pohead_status != NEW.pohead_status) THEN UPDATE poitem SET poitem_status=NEW.pohead_status WHERE ( (poitem_pohead_id=NEW.pohead_id) AND (poitem_status <> 'C') ); END IF; END IF; RETURN NEW; END; $$; ,DROP FUNCTION public._poheadtriggerafter(); publicadminfalse46238 125577870_poitemafterdeletetrigger()FUNCTIONCREATE FUNCTION _poitemafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _changelog BOOLEAN := FALSE; BEGIN IF (OLD.poitem_status = 'O') THEN IF ( (SELECT (count(*) < 1) FROM poitem WHERE ((poitem_pohead_id=OLD.poitem_pohead_id) AND (poitem_id != OLD.poitem_id) AND (poitem_status <> 'C')) ) ) THEN UPDATE pohead SET pohead_status = 'C' WHERE ((pohead_id=OLD.poitem_pohead_id) AND (pohead_status='O')); END IF; END IF; IF ( SELECT fetchMetricBool('POChangeLog') ) THEN _changelog := TRUE; END IF; IF ( _changelog ) THEN PERFORM postComment('ChangeLog', 'P', OLD.poitem_pohead_id, ('Deleted Line #' || OLD.poitem_linenumber::TEXT)); END IF; DELETE FROM charass WHERE charass_target_type = 'PI' AND charass_target_id = OLD.poitem_id; RETURN OLD; END; $$; 2DROP FUNCTION public._poitemafterdeletetrigger(); publicadminfalse84623 125577871_poitemaftertrigger()FUNCTIONCREATE FUNCTION _poitemaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _changelog BOOLEAN := FALSE; BEGIN IF (TG_OP = 'UPDATE') THEN IF (OLD.poitem_status <> NEW.poitem_status) THEN IF ( (SELECT (count(*) < 1) FROM poitem WHERE ((poitem_pohead_id=NEW.poitem_pohead_id) AND (poitem_id != NEW.poitem_id) AND (poitem_status<>'C')) ) AND (NEW.poitem_status='C') ) THEN UPDATE pohead SET pohead_status = 'C' WHERE ((pohead_id=NEW.poitem_pohead_id) AND (pohead_status='O')); ELSE UPDATE pohead SET pohead_status = 'O' WHERE ((pohead_id=NEW.poitem_pohead_id) AND (pohead_status='C')); END IF; END IF; END IF; IF (TG_OP = 'INSERT') THEN PERFORM postEvent('POitemCreate', 'P', NEW.poitem_id, itemsite_warehous_id, (pohead_number || '-' || NEW.poitem_linenumber || ': ' || item_number), NULL, NULL, NULL, NULL) FROM pohead JOIN itemsite ON (itemsite_id=NEW.poitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (pohead_id=NEW.poitem_pohead_id) AND (NEW.poitem_duedate <= (CURRENT_DATE + itemsite_eventfence)); END IF; IF ( SELECT fetchMetricBool('POChangeLog') ) THEN _changelog := TRUE; END IF; IF ( _changelog ) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment('ChangeLog', 'P', NEW.poitem_pohead_id, ('Created Line #' || NEW.poitem_linenumber::TEXT)); PERFORM postComment('ChangeLog', 'PI', NEW.poitem_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (NEW.poitem_qty_ordered <> OLD.poitem_qty_ordered) THEN PERFORM postComment( 'ChangeLog', 'PI', NEW.poitem_id, ( 'Qty. Ordered Changed from ' || formatQty(OLD.poitem_qty_ordered) || ' to ' || formatQty(NEW.poitem_qty_ordered ) ) ); END IF; IF (NEW.poitem_unitprice <> OLD.poitem_unitprice) THEN PERFORM postComment( 'ChangeLog', 'PI', NEW.poitem_id, ( 'Unit Price Changed from ' || formatPurchPrice(OLD.poitem_unitprice) || ' to ' || formatPurchPrice(NEW.poitem_unitprice ) ) ); END IF; IF (NEW.poitem_duedate <> OLD.poitem_duedate) THEN PERFORM postComment( 'ChangeLog', 'PI', NEW.poitem_id, ( 'Due Date Changed from ' || formatDate(OLD.poitem_duedate) || ' to ' || formatDate(NEW.poitem_duedate ) ) ); END IF; IF (COALESCE(OLD.poitem_taxtype_id, -1) <> COALESCE(NEW.poitem_taxtype_id, -1)) THEN PERFORM postComment( 'ChangeLog', 'PI', NEW.poitem_id, ( 'Tax Type Changed from "' || COALESCE((SELECT taxtype_name FROM taxtype WHERE taxtype_id=OLD.poitem_taxtype_id), 'None') || '" (' || COALESCE(OLD.poitem_taxtype_id, 0) || ') to "' || COALESCE((SELECT taxtype_name FROM taxtype WHERE taxtype_id=NEW.poitem_taxtype_id), 'None') || '" (' || COALESCE(NEW.poitem_taxtype_id, 0) || ')' ) ); END IF; IF (NEW.poitem_status <> OLD.poitem_status) THEN IF (NEW.poitem_status = 'C') THEN PERFORM postComment('ChangeLog', 'PI', NEW.poitem_id, 'Closed'); ELSIF (NEW.poitem_status = 'O') THEN PERFORM postComment('ChangeLog', 'PI', NEW.poitem_id, 'Opened'); END IF; END IF; END IF; END IF; RETURN NEW; END; $$; ,DROP FUNCTION public._poitemaftertrigger(); publicadminfalse46238 125577872_poitemdeletetrigger()FUNCTIONpCREATE FUNCTION _poitemdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF (NOT checkPrivilege('MaintainPurchaseOrders')) THEN RAISE EXCEPTION 'You do not have privileges to alter a Purchase Order.'; END IF; IF (EXISTS(SELECT recv_id FROM recv WHERE ((recv_order_type='PO') AND (recv_orderitem_id=OLD.poitem_id) AND (recv_qty>0)))) THEN RAISE EXCEPTION 'Cannot delete an P/O Item which has been received'; END IF; DELETE FROM comment WHERE ( (comment_source='PI') AND (comment_source_id=OLD.poitem_id) ); DELETE FROM charass WHERE ((charass_target_type='PI') AND (charass_target_id=OLD.poitem_id)); RETURN OLD; END; $$; -DROP FUNCTION public._poitemdeletetrigger(); publicadminfalse46238 125577873_poitemtrigger()FUNCTIONCREATE FUNCTION _poitemtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; _status CHAR(1); _check BOOLEAN; _cnt INTEGER; _s RECORD; BEGIN -- Check IF ( (TG_OP = 'UPDATE') AND (NOT checkPrivilege('MaintainPurchaseOrders')) AND (NOT checkPrivilege('ChangePurchaseOrderQty')) AND (NOT checkPrivilege('EnterReceipts')) AND (NOT checkPrivilege('PostVouchers')) ) THEN RAISE EXCEPTION 'You do not have privileges to alter a Purchase Order.'; END IF; IF ( (TG_OP = 'INSERT') AND (NOT checkPrivilege('MaintainPurchaseOrders')) ) THEN RAISE EXCEPTION 'You do not have privileges to alter a Purchase Order.'; END IF; IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN SELECT pohead_status INTO _status FROM pohead WHERE (pohead_id=NEW.poitem_pohead_id); IF (NEW.poitem_itemsite_id=-1) THEN NEW.poitem_itemsite_id := NULL; END IF; IF (NEW.poitem_expcat_id=-1) THEN NEW.poitem_expcat_id := NULL; END IF; IF (NEW.poitem_itemsite_id IS NOT NULL AND NEW.poitem_expcat_id IS NOT NULL) THEN RAISE EXCEPTION 'A purchase order line may not include both an inventory and non-inventory item'; ELSIF (NEW.poitem_itemsite_id IS NULL AND NEW.poitem_expcat_id IS NULL) THEN RAISE EXCEPTION 'A purchase order line must specify either an inventory item or a non-inventory expense category'; ELSIF (NEW.poitem_qty_ordered IS NULL) THEN RAISE EXCEPTION 'A purchase order line must specify a quantity'; ELSIF (COALESCE(NEW.poitem_itemsite_id,-1) != -1) THEN SELECT (COUNT(item_id)=1) INTO _check FROM itemsite, item WHERE ((itemsite_id=NEW.poitem_itemsite_id) AND (itemsite_item_id=item_id) AND (item_type IN ('P','O','M','T'))); IF NOT (_check) THEN RAISE EXCEPTION 'The item is not a purchasable item type'; END IF; END IF; END IF; IF (TG_OP = 'INSERT') THEN IF (_status='C') THEN RAISE EXCEPTION 'New lines may not be inserted into a closed purchase order'; END IF; --Fetch and apply default item source data if applicable IF ((NEW.poitem_itemsrc_id IS NULL) AND (NEW.poitem_itemsite_id IS NOT NULL)) THEN IF (NEW.poitem_itemsrc_id IS NULL) THEN SELECT COUNT(itemsrc_id) INTO _cnt FROM pohead,itemsrc,itemsite WHERE ((pohead_id=NEW.poitem_pohead_id) AND (pohead_vend_id=itemsrc_vend_id) AND (itemsite_id=NEW.poitem_itemsite_id) AND (itemsite_item_id=itemsrc_item_id)); IF (_cnt = 1) THEN -- We found the one and only item source, so populate data for it SELECT itemsrc.* INTO _s FROM pohead,itemsrc,itemsite WHERE ((pohead_id=NEW.poitem_pohead_id) AND (pohead_vend_id=itemsrc_vend_id) AND (itemsite_id=NEW.poitem_itemsite_id) AND (itemsite_item_id=itemsrc_item_id)); IF (FOUND) THEN NEW.poitem_itemsrc_id := _s.itemsrc_id; NEW.poitem_vend_uom := _s.itemsrc_vend_uom; NEW.poitem_invvenduomratio := _s.itemsrc_invvendoruomratio; NEW.poitem_duedate := COALESCE(NEW.poitem_duedate, CURRENT_DATE + _s.itemsrc_leadtime); NEW.poitem_vend_item_number := COALESCE(NEW.poitem_vend_item_number,_s.itemsrc_vend_item_number); NEW.poitem_vend_item_descrip := COALESCE(NEW.poitem_vend_item_descrip,_s.itemsrc_vend_item_descrip); NEW.poitem_manuf_name := COALESCE(NEW.poitem_manuf_name,_s.itemsrc_manuf_name); NEW.poitem_manuf_item_number := COALESCE(NEW.poitem_manuf_item_number, _s.itemsrc_manuf_item_number); NEW.poitem_manuf_item_descrip := COALESCE(NEW.poitem_manuf_item_descrip, _s.itemsrc_manuf_item_descrip); END IF; ELSIF (_cnt > 1) THEN -- There are multiple sources, see if there is an exact match with provided vendor info. SELECT itemsrc.* INTO _s FROM pohead,itemsrc,itemsite WHERE ((pohead_id=NEW.poitem_pohead_id) AND (pohead_vend_id=itemsrc_vend_id) AND (itemsite_id=NEW.poitem_itemsite_id) AND (itemsite_item_id=itemsrc_item_id) AND (NEW.poitem_vend_item_number=itemsrc_vend_item_number) AND (COALESCE(NEW.poitem_manuf_name,'')=COALESCE(itemsrc_manuf_name,'')) AND (COALESCE(NEW.poitem_manuf_item_number,'')=COALESCE(itemsrc_manuf_item_number,''))); IF (FOUND) THEN NEW.poitem_itemsrc_id := _s.itemsrc_id; NEW.poitem_vend_uom := _s.itemsrc_vend_uom; NEW.poitem_invvenduomratio := _s.itemsrc_invvendoruomratio; NEW.poitem_duedate := COALESCE(NEW.poitem_duedate, CURRENT_DATE + _s.itemsrc_leadtime); NEW.poitem_vend_item_descrip := COALESCE(NEW.poitem_vend_item_descrip,_s.itemsrc_vend_item_descrip); NEW.poitem_manuf_item_descrip := COALESCE(NEW.poitem_manuf_item_descrip, _s.itemsrc_manuf_item_descrip); END IF; END IF; END IF; END IF; IF (NEW.poitem_duedate IS NULL) THEN RAISE EXCEPTION 'A due date is required'; END IF; --Set defaults NEW.poitem_linenumber := COALESCE(NEW.poitem_linenumber,( SELECT COALESCE(MAX(poitem_linenumber),0) + 1 FROM poitem WHERE (poitem_pohead_id=NEW.poitem_pohead_id))); NEW.poitem_status := _status; NEW.poitem_invvenduomratio := COALESCE(NEW.poitem_invvenduomratio,1); IF (NEW.poitem_invvenduomratio = 0.0) THEN NEW.poitem_invvenduomratio = 1.0; END IF; NEW.poitem_vend_item_number := COALESCE(NEW.poitem_vend_item_number,''); NEW.poitem_vend_item_descrip := COALESCE(NEW.poitem_vend_item_descrip,''); NEW.poitem_unitprice := COALESCE(NEW.poitem_unitprice,( SELECT itemsrcPrice(NEW.poitem_itemsrc_id, COALESCE(itemsite_warehous_id, -1), pohead_dropship, NEW.poitem_qty_ordered, pohead_curr_id, CURRENT_DATE) FROM itemsite, pohead WHERE ( (itemsite_id=NEW.poitem_itemsite_id) AND (pohead_id=NEW.poitem_pohead_id) )), 0.0); NEW.poitem_stdcost := COALESCE(NEW.poitem_stdcost,( SELECT stdcost(itemsite_item_id) FROM itemsite WHERE (itemsite_id=NEW.poitem_itemsite_id))); NEW.poitem_bom_rev_id := COALESCE(NEW.poitem_bom_rev_id,( SELECT getActiveRevId('BOM',itemsite_item_id) FROM itemsite WHERE (itemsite_id=NEW.poitem_itemsite_id))); NEW.poitem_boo_rev_id := COALESCE(NEW.poitem_boo_rev_id,( SELECT getActiveRevId('BOO',itemsite_item_id) FROM itemsite WHERE (itemsite_id=NEW.poitem_itemsite_id))); NEW.poitem_comments := COALESCE(NEW.poitem_comments,''); NEW.poitem_freight := COALESCE(NEW.poitem_freight,0); NEW.poitem_qty_received := 0; NEW.poitem_qty_returned := 0; NEW.poitem_qty_vouchered := 0; END IF; IF (TG_OP = 'UPDATE') THEN IF (NEW.poitem_itemsite_id != OLD.poitem_itemsite_id) THEN RAISE EXCEPTION 'You may not change the item site for a line item.'; ELSIF (NEW.poitem_expcat_id != OLD.poitem_expcat_id) THEN RAISE EXCEPTION 'You may not change the expense category for a line item.'; END IF; END IF; RETURN NEW; END; $$; 'DROP FUNCTION public._poitemtrigger(); publicadminfalse46238 125587251_prjafterdeletetrigger()FUNCTIONdCREATE FUNCTION _prjafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'PROJ' AND charass_target_id = OLD.prj_id; RETURN OLD; END; $$; /DROP FUNCTION public._prjafterdeletetrigger(); publicadminfalse46238 125577875_prjaftertrigger()FUNCTIONCREATE FUNCTION _prjaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; BEGIN -- Cache the cmnttype_id for ChangeLog SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (NOT FOUND) THEN RAISE EXCEPTION 'Comment type ChangeLog not found'; END IF; IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'J', NEW.prj_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.prj_start_date <> NEW.prj_start_date) THEN PERFORM postComment( _cmnttypeid, 'J', NEW.prj_id, ('Start Date Changed from ' || formatDate(OLD.prj_start_date) || ' to ' || formatDate(NEW.prj_start_date)) ); END IF; IF (OLD.prj_due_date <> NEW.prj_due_date) THEN PERFORM postComment( _cmnttypeid, 'J', NEW.prj_id, ('Due Date Changed from ' || formatDate(OLD.prj_due_date) || ' to ' || formatDate(NEW.prj_due_date)) ); END IF; IF (OLD.prj_assigned_date <> NEW.prj_assigned_date) THEN PERFORM postComment( _cmnttypeid, 'J', NEW.prj_id, ('Assigned Date Changed from ' || formatDate(OLD.prj_assigned_date) || ' to ' || formatDate(NEW.prj_assigned_date)) ); END IF; IF (OLD.prj_completed_date <> NEW.prj_completed_date) THEN PERFORM postComment( _cmnttypeid, 'J', NEW.prj_id, ('Completed Date Changed from ' || formatDate(OLD.prj_completed_date) || ' to ' || formatDate(NEW.prj_completed_date)) ); END IF; END IF; RETURN NEW; END; $$; )DROP FUNCTION public._prjaftertrigger(); publicadminfalse84623 125577876_prjbeforedeletetrigger()FUNCTIONrCREATE FUNCTION _prjbeforedeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _recurid INTEGER; _newparentid INTEGER; BEGIN IF (TG_OP = 'DELETE') THEN DELETE FROM docass WHERE docass_source_id = OLD.prj_id AND docass_source_type = 'J'; DELETE FROM docass WHERE docass_target_id = OLD.prj_id AND docass_target_type = 'J'; SELECT recur_id INTO _recurid FROM recur WHERE ((recur_parent_id=OLD.prj_id) AND (recur_parent_type='J')); IF (_recurid IS NOT NULL) THEN SELECT MIN(prj_id) INTO _newparentid FROM prj WHERE ((prj_recurring_prj_id=OLD.prj_id) AND (prj_id!=OLD.prj_id)); -- client is responsible for warning about deleting a recurring prj IF (_newparentid IS NULL) THEN DELETE FROM recur WHERE recur_id=_recurid; ELSE UPDATE recur SET recur_parent_id=_newparentid WHERE recur_id=_recurid; END IF; END IF; RETURN OLD; END IF; RETURN NEW; END; $$; 0DROP FUNCTION public._prjbeforedeletetrigger(); publicadminfalse46238w125587256_prjtaskafterdeletetrigger()FUNCTIONlCREATE FUNCTION _prjtaskafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'TASK' AND charass_target_id = OLD.prjtask_id; RETURN OLD; END; $$; 3DROP FUNCTION public._prjtaskafterdeletetrigger(); publicadminfalse84623 125577877_prjtaskaftertrigger()FUNCTIONCREATE FUNCTION _prjtaskaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; BEGIN SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (NOT FOUND) THEN RAISE EXCEPTION 'Comment type ChangeLog not found'; END IF; IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'TA', NEW.prjtask_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.prjtask_start_date <> NEW.prjtask_start_date) THEN PERFORM postComment( _cmnttypeid, 'TA', NEW.prjtask_id, ('Start Date Changed from ' || formatDate(OLD.prjtask_start_date) || ' to ' || formatDate(NEW.prjtask_start_date)) ); END IF; IF (OLD.prjtask_due_date <> NEW.prjtask_due_date) THEN PERFORM postComment( _cmnttypeid, 'TA', NEW.prjtask_id, ('Due Date Changed from ' || formatDate(OLD.prjtask_due_date) || ' to ' || formatDate(NEW.prjtask_due_date)) ); END IF; IF (OLD.prjtask_assigned_date <> NEW.prjtask_assigned_date) THEN PERFORM postComment( _cmnttypeid, 'TA', NEW.prjtask_id, ('Assigned Date Changed from ' || formatDate(OLD.prjtask_assigned_date) || ' to ' || formatDate(NEW.prjtask_assigned_date)) ); END IF; IF (OLD.prjtask_completed_date <> NEW.prjtask_completed_date) THEN PERFORM postComment( _cmnttypeid, 'TA', NEW.prjtask_id, ('Completed Date Changed from ' || formatDate(OLD.prjtask_completed_date) || ' to ' || formatDate(NEW.prjtask_completed_date)) ); END IF; IF (OLD.prjtask_hours_actual != NEW.prjtask_hours_actual) THEN PERFORM postComment(_cmnttypeid, 'TA', NEW.prjtask_id, 'Actual Hours changed from ' || formatQty(OLD.prjtask_hours_actual) || ' to ' || formatQty(NEW.prjtask_hours_actual)); END IF; IF (OLD.prjtask_exp_actual != NEW.prjtask_exp_actual) THEN PERFORM postComment(_cmnttypeid, 'TA', NEW.prjtask_id, 'Actual Expense changed from ' || formatQty(OLD.prjtask_exp_actual) || ' to ' || formatQty(NEW.prjtask_exp_actual)); END IF; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._prjtaskaftertrigger(); publicadminfalse46238 125577878_prjtasktrigger()FUNCTIONbCREATE FUNCTION _prjtasktrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Checks IF (NEW.prjtask_owner_username=getEffectiveXtUser()) THEN IF (NOT checkPrivilege('MaintainAllProjects') AND NOT checkPrivilege('MaintainPersonalProjects')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Projects.'; END IF; ELSIF (NOT checkPrivilege('MaintainAllProjects')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Projects.'; ELSIF (LENGTH(COALESCE(NEW.prjtask_number,'')) = 0) THEN RAISE EXCEPTION 'You must ender a valid number.'; ELSIF (LENGTH(COALESCE(NEW.prjtask_name,'')) = 0) THEN RAISE EXCEPTION 'You must ender a valid name.'; END IF; RETURN NEW; END; $$; (DROP FUNCTION public._prjtasktrigger(); publicadminfalse84623# 125577879_prospectafterdeletetrigger()FUNCTIONCREATE FUNCTION _prospectafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF EXISTS(SELECT 1 FROM quhead WHERE quhead_cust_id = OLD.prospect_id) AND NOT EXISTS (SELECT 1 FROM custinfo WHERE cust_id = OLD.prospect_id) THEN RAISE EXCEPTION '[xtuple: deleteProspect, -1]'; END IF; IF (fetchMetricBool('ProspectChangeLog')) THEN PERFORM postComment(cmnttype_id, 'PSPCT', OLD.prospect_id, 'Deleted "' || OLD.prospect_number || '"') FROM cmnttype WHERE (cmnttype_name='ChangeLog'); END IF; RETURN OLD; END; $$; 4DROP FUNCTION public._prospectafterdeletetrigger(); publicadminfalse84623! 125577880_prospectaftertrigger()FUNCTIONCREATE FUNCTION _prospectaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; _custid INTEGER; _prospectid INTEGER; BEGIN IF (TG_OP = 'INSERT') THEN SELECT crmacct_cust_id, crmacct_prospect_id INTO _custid, _prospectid FROM crmacct WHERE crmacct_number=NEW.prospect_number; IF (_custid > 0 AND _custid != _prospectid) THEN RAISE EXCEPTION '[xtuple: createProspect, -2]'; END IF; IF (_prospectid > 0) THEN RAISE EXCEPTION '[xtuple: createProspect, -3]'; END IF; -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE LOOP UPDATE crmacct SET crmacct_prospect_id=NEW.prospect_id, crmacct_cust_id=NULL, crmacct_name=NEW.prospect_name WHERE crmacct_number=NEW.prospect_number; IF (FOUND) THEN EXIT; END IF; BEGIN INSERT INTO crmacct(crmacct_number, crmacct_name, crmacct_active, crmacct_type, crmacct_prospect_id, crmacct_cntct_id_1 ) VALUES (NEW.prospect_number, NEW.prospect_name, NEW.prospect_active, 'O', NEW.prospect_id, NEW.prospect_cntct_id); EXIT; EXCEPTION WHEN unique_violation THEN -- do nothing, and loop to try the UPDATE again END; END LOOP; /* TODO: default characteristic assignments based on what? */ ELSIF (TG_OP = 'UPDATE') THEN UPDATE crmacct SET crmacct_number = NEW.prospect_number WHERE ((crmacct_prospect_id=NEW.prospect_id) AND (crmacct_number!=NEW.prospect_number)); UPDATE crmacct SET crmacct_name = NEW.prospect_name WHERE ((crmacct_prospect_id=NEW.prospect_id) AND (crmacct_name!=NEW.prospect_name)); END IF; IF (fetchMetricBool('ProspectChangeLog')) THEN SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (_cmnttypeid IS NOT NULL) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.prospect_active <> NEW.prospect_active) THEN PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id, CASE WHEN NEW.prospect_active THEN 'Activated' ELSE 'Deactivated' END); END IF; IF (OLD.prospect_number <> NEW.prospect_number) THEN PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id, 'Number changed from "' || OLD.prospect_number || '" to "' || NEW.prospect_number || '"'); END IF; IF (OLD.prospect_name <> NEW.prospect_name) THEN PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id, 'Name changed from "' || OLD.prospect_name || '" to "' || NEW.prospect_name || '"'); END IF; IF (OLD.prospect_cntct_id <> NEW.prospect_cntct_id) THEN PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id, 'Contact changed from "' || formatCntctName(OLD.prospect_cntct_id) || '" to "' || formatCntctName(NEW.prospect_cntct_id) || '"'); END IF; IF (OLD.prospect_taxauth_id <> NEW.prospect_taxauth_id) THEN PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id, 'Tax Authority changed from "' || (SELECT taxauth_code FROM taxauth WHERE taxauth_id=OLD.prospect_taxauth_id) || '" to "' || (SELECT taxauth_code FROM taxauth WHERE taxauth_id=NEW.prospect_taxauth_id) || '"'); END IF; IF (OLD.prospect_salesrep_id <> NEW.prospect_salesrep_id) THEN PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id, 'Sales Rep changed from "' || (SELECT salesrep_number FROM salesrep WHERE salesrep_id=OLD.prospect_salesrep_id) || '" to "' || (SELECT salesrep_number FROM salesrep WHERE salesrep_id=NEW.prospect_salesrep_id) || '"'); END IF; IF (OLD.prospect_warehous_id <> NEW.prospect_warehous_id) THEN PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id, 'Warehouse changed from "' || (SELECT warehous_code FROM whsinfo WHERE warehous_id=OLD.prospect_warehous_id) || '" to "' || (SELECT warehous_code FROM whsinfo WHERE warehous_id=NEW.prospect_warehous_id) || '"'); END IF; IF (OLD.prospect_taxzone_id <> NEW.prospect_taxzone_id) THEN PERFORM postComment(_cmnttypeid, 'PSPCT', NEW.prospect_id, 'Tax Zone changed from "' || (SELECT taxzone_code FROM taxzone WHERE taxzone_id=OLD.prospect_taxzone_id) || '" to "' || (SELECT taxzone_code FROM taxzone WHERE taxzone_id=NEW.prospect_taxzone_id) || '"'); END IF; END IF; END IF; END IF; RETURN NEW; END; $$; .DROP FUNCTION public._prospectaftertrigger(); publicadminfalse84623" 125577881_prospectbeforedeletetrigger()FUNCTIONCREATE FUNCTION _prospectbeforedeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (NOT checkPrivilege('MaintainProspectMasters')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Prospects.'; END IF; UPDATE crmacct SET crmacct_prospect_id = NULL WHERE crmacct_prospect_id = OLD.prospect_id; RETURN OLD; END; $$; 5DROP FUNCTION public._prospectbeforedeletetrigger(); publicadminfalse84623125577882_prospecttrigger()FUNCTION%CREATE FUNCTION _prospecttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (NOT checkPrivilege('MaintainProspectMasters')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Prospects.'; END IF; IF (NEW.prospect_number IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Prospect Number.'; END IF; NEW.prospect_number := UPPER(NEW.prospect_number); RETURN NEW; END; $$; )DROP FUNCTION public._prospecttrigger(); publicadminfalse46238 125577883 _prtrigger()FUNCTIONMCREATE FUNCTION _prtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/EULA for the full text of the software license. BEGIN --- clear the number from the issue cache PERFORM clearNumberIssue('PrNumber', NEW.pr_number); RETURN NEW; END; $$; #DROP FUNCTION public._prtrigger(); publicadminfalse46238% 125587264_quheadafterdeletetrigger()FUNCTIONhCREATE FUNCTION _quheadafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'QU' AND charass_target_id = OLD.quhead_id; RETURN OLD; END; $$; 2DROP FUNCTION public._quheadafterdeletetrigger(); publicadminfalse46238$ 125577884_quheadtrigger()FUNCTION7CREATE FUNCTION _quheadtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; _oldHoldType TEXT; _newHoldType TEXT; _p RECORD; _a RECORD; _w RECORD; _shiptoId INTEGER; _addrId INTEGER; _prjId INTEGER; _check BOOLEAN; _numGen CHAR(1); BEGIN -- Checks SELECT checkPrivilege('MaintainQuotes') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to maintain Quotes.'; END IF; -- If this is imported, check the quote number IF (TG_OP = 'INSERT') THEN IF (NEW.quhead_imported) THEN SELECT fetchMetricText('QUNumberGeneration') INTO _numGen; IF ((NEW.quhead_number IS NULL) AND (_numGen='M')) THEN RAISE EXCEPTION 'You must supply a Quote Number.'; ELSE IF ((NEW.quhead_number IS NOT NULL) AND (_numGen='A')) THEN RAISE EXCEPTION 'You may not supply a new Quote Number xTuple will generate the number.'; ELSE IF ((NEW.quhead_number IS NULL) AND (_numGen='S')) THEN SELECT fetchsonumber() INTO NEW.quhead_number; ELSE IF (NEW.quhead_number IS NULL) THEN SELECT fetchqunumber() INTO NEW.quhead_number; END IF; END IF; END IF; END IF; END IF; IF (fetchMetricText('QUNumberGeneration') IN ('A','O')) THEN --- clear the number from the issue cache PERFORM clearNumberIssue('QuNumber', NEW.quhead_number); ELSIF (fetchMetricText('QUNumberGeneration') = 'S') THEN --- clear the number from the issue cache PERFORM clearNumberIssue('SoNumber', NEW.quhead_number); END IF; ELSE IF (TG_OP = 'UPDATE') THEN IF (NEW.quhead_number <> OLD.quhead_number) THEN RAISE EXCEPTION 'The order number may not be changed.'; END IF; END IF; END IF; IF (TG_OP IN ('INSERT','UPDATE')) THEN -- Get Customer data IF (NEW.quhead_shipto_id IS NULL) THEN SELECT * INTO _p FROM ( SELECT cust_number,cust_usespos,cust_blanketpos,cust_ffbillto, cust_ffshipto,cust_name,cust_salesrep_id,cust_terms_id,cust_shipvia, cust_commprcnt,cust_curr_id,cust_taxzone_id, addr_line1,addr_line2,addr_line3,addr_city,addr_state,addr_postalcode,addr_country, shipto_id,shipto_addr_id,shipto_name,shipto_salesrep_id,shipto_shipvia, shipto_shipchrg_id,shipto_shipform_id,shipto_commission,shipto_taxzone_id FROM custinfo LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) LEFT OUTER JOIN shiptoinfo ON ((cust_id=shipto_cust_id) AND shipto_default) WHERE (cust_id=NEW.quhead_cust_id) UNION SELECT prospect_number,false,false,true, true,prospect_name,prospect_salesrep_id,null,null, null,null,prospect_taxzone_id, addr_line1,addr_line2,addr_line3,addr_city,addr_state,addr_postalcode,addr_country, null,null,null,null,null, null,null,null,null FROM prospect LEFT OUTER JOIN cntct ON (prospect_cntct_id=cntct_id) LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) WHERE (prospect_id=NEW.quhead_cust_id)) AS data; ELSE SELECT cust_creditstatus,cust_number,cust_usespos,cust_blanketpos,cust_ffbillto, cust_ffshipto,cust_name,cust_salesrep_id,cust_terms_id,cust_shipvia, cust_shipchrg_id,cust_shipform_id,cust_commprcnt,cust_curr_id,cust_taxzone_id, addr_line1,addr_line2,addr_line3,addr_city,addr_state,addr_postalcode,addr_country, shipto_id,shipto_addr_id,shipto_name,shipto_salesrep_id,shipto_shipvia, shipto_shipchrg_id,shipto_shipform_id,shipto_commission,shipto_taxzone_id INTO _p FROM shiptoinfo,custinfo LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) WHERE ((cust_id=NEW.quhead_cust_id) AND (shipto_id=shipto_id)); END IF; -- If there is customer data, then we can get to work IF (FOUND) THEN -- Only check PO number for imports because UI checks when whole quote is saved IF (TG_OP = 'INSERT') THEN -- Set to defaults if values not provided NEW.quhead_shipto_id := COALESCE(NEW.quhead_shipto_id,_p.shipto_id); NEW.quhead_salesrep_id := COALESCE(NEW.quhead_salesrep_id,_p.shipto_salesrep_id,_p.cust_salesrep_id); NEW.quhead_terms_id := COALESCE(NEW.quhead_terms_id,_p.cust_terms_id); NEW.quhead_shipvia := COALESCE(NEW.quhead_shipvia,_p.shipto_shipvia,_p.cust_shipvia); NEW.quhead_commission := COALESCE(NEW.quhead_commission,_p.shipto_commission,_p.cust_commprcnt); NEW.quhead_quotedate := COALESCE(NEW.quhead_quotedate,current_date); NEW.quhead_packdate := COALESCE(NEW.quhead_packdate,NEW.quhead_quotedate); NEW.quhead_curr_id := COALESCE(NEW.quhead_curr_id,_p.cust_curr_id,basecurrid()); NEW.quhead_taxzone_id := COALESCE(NEW.quhead_taxzone_id,_p.shipto_taxzone_id,_p.cust_taxzone_id); NEW.quhead_freight := COALESCE(NEW.quhead_freight,0); NEW.quhead_custponumber := COALESCE(NEW.quhead_custponumber,''); NEW.quhead_ordercomments := COALESCE(NEW.quhead_ordercomments,''); NEW.quhead_shipcomments := COALESCE(NEW.quhead_shipcomments,''); NEW.quhead_shiptophone := COALESCE(NEW.quhead_shiptophone,''); NEW.quhead_misc := COALESCE(NEW.quhead_misc,0); NEW.quhead_misc_descrip := COALESCE(NEW.quhead_misc_descrip,''); IF ((NEW.quhead_warehous_id IS NULL) OR (NEW.quhead_fob IS NULL)) THEN IF (NEW.quhead_warehous_id IS NULL) THEN SELECT warehous_id,warehous_fob INTO _w FROM usrpref, whsinfo WHERE ((warehous_id=CAST(usrpref_value AS INTEGER)) AND (warehous_shipping) AND (warehous_active) AND (usrpref_username=getEffectiveXtUser()) AND (usrpref_name='PreferredWarehouse')); ELSE SELECT warehous_id,warehous_fob INTO _w FROM whsinfo WHERE (warehous_id=NEW.quhead_warehous_id); END IF; IF (FOUND) THEN NEW.quhead_warehous_id := COALESCE(NEW.quhead_warehous_id,_w.warehous_id); NEW.quhead_fob := COALESCE(NEW.quhead_fob,_w.warehous_fob); END IF; END IF; END IF; --Auto create project if applicable IF ((TG_OP = 'INSERT') AND (COALESCE(NEW.quhead_prj_id,-1)=-1)) THEN SELECT fetchMetricBool('AutoCreateProjectsForOrders') INTO _check; IF (_check) THEN SELECT NEXTVAL('prj_prj_id_seq') INTO _prjId; NEW.quhead_prj_id := _prjId; INSERT INTO prj (prj_id, prj_number, prj_name, prj_descrip, prj_status, prj_so, prj_wo, prj_po, prj_owner_username, prj_start_date, prj_due_date, prj_assigned_date, prj_completed_date, prj_username, prj_recurring_prj_id, prj_crmacct_id, prj_cntct_id, prj_prjtype_id) SELECT _prjId, NEW.quhead_number, NEW.quhead_number, 'Auto Generated Project from Quote.', 'O', TRUE, TRUE, TRUE, getEffectiveXTUser(), NEW.quhead_quotedate, NEW.quhead_packdate, NEW.quhead_quotedate, NULL, getEffectiveXTUser(), NULL, crmacct_id, NEW.quhead_billto_cntct_id, NULL FROM crmacct WHERE (crmacct_cust_id=NEW.quhead_cust_id) OR (crmacct_prospect_id=NEW.quhead_cust_id) LIMIT 1; END IF; END IF; -- Deal with Billing Address IF (TG_OP = 'INSERT') THEN IF (_p.cust_ffbillto) THEN -- If they didn't supply data, we'll put in the bill to address NEW.quhead_billtoname=COALESCE(NEW.quhead_billtoname,_p.cust_name,''); NEW.quhead_billtoaddress1=COALESCE(NEW.quhead_billtoaddress1,_p.addr_line1,''); NEW.quhead_billtoaddress2=COALESCE(NEW.quhead_billtoaddress2,_p.addr_line2,''); NEW.quhead_billtoaddress3=COALESCE(NEW.quhead_billtoaddress3,_p.addr_line3,''); NEW.quhead_billtocity=COALESCE(NEW.quhead_billtocity,_p.addr_city,''); NEW.quhead_billtostate=COALESCE(NEW.quhead_billtostate,_p.addr_state,''); NEW.quhead_billtozip=COALESCE(NEW.quhead_billtozip,_p.addr_postalcode,''); NEW.quhead_billtocountry=COALESCE(NEW.quhead_billtocountry,_p.addr_country,''); ELSE -- Free form not allowed, we're going to put in the address regardless NEW.quhead_billtoname=COALESCE(_p.cust_name,''); NEW.quhead_billtoaddress1=COALESCE(_p.addr_line1,''); NEW.quhead_billtoaddress2=COALESCE(_p.addr_line2,''); NEW.quhead_billtoaddress3=COALESCE(_p.addr_line3,''); NEW.quhead_billtocity=COALESCE(_p.addr_city,''); NEW.quhead_billtostate=COALESCE(_p.addr_state,''); NEW.quhead_billtozip=COALESCE(_p.addr_postalcode,''); NEW.quhead_billtocountry=COALESCE(_p.addr_country,''); END IF; END IF; -- Now let's look at Shipto Address -- If there's nothing in the address fields and there is a shipto id -- or there is a default address available, let's put in some shipto address data IF ((TG_OP = 'INSERT') AND NOT ((NEW.quhead_shipto_id IS NULL) AND NOT _p.cust_ffshipto) AND (NEW.quhead_shiptoname IS NULL) AND (NEW.quhead_shiptoaddress1 IS NULL) AND (NEW.quhead_shiptoaddress2 IS NULL) AND (NEW.quhead_shiptoaddress3 IS NULL) AND (NEW.quhead_shiptocity IS NULL) AND (NEW.quhead_shiptostate IS NULL) AND (NEW.quhead_shiptocountry IS NULL)) THEN IF ((NEW.quhead_shipto_id IS NULL) AND (_p.shipto_id IS NOT NULL)) THEN _shiptoId := _p.shipto_addr_id; ELSE _shiptoId := NEW.quhead_shipto_id; END IF; SELECT * INTO _a FROM shiptoinfo, addr WHERE ((shipto_id=_shiptoId) AND (addr_id=shipto_addr_id)); NEW.quhead_shiptoname := COALESCE(_p.shipto_name,''); NEW.quhead_shiptoaddress1 := COALESCE(_a.addr_line1,''); NEW.quhead_shiptoaddress2 := COALESCE(_a.addr_line2,''); NEW.quhead_shiptoaddress3 := COALESCE(_a.addr_line3,''); NEW.quhead_shiptocity := COALESCE(_a.addr_city,''); NEW.quhead_shiptostate := COALESCE(_a.addr_state,''); NEW.quhead_shiptozipcode := COALESCE(_a.addr_postalcode,''); NEW.quhead_shiptocountry := COALESCE(_a.addr_country,''); ELSE IF (_p.cust_ffshipto) THEN -- Use Address Save function to see if the new address entered matches -- data for the shipto number. If not that will insert new address for CRM SELECT SaveAddr( NULL, NULL, NEW.quhead_shiptoaddress1, NEW.quhead_shiptoaddress2, NEW.quhead_shiptoaddress3, NEW.quhead_shiptocity, NEW.quhead_shiptostate, NEW.quhead_shiptozipcode, NEW.quhead_shiptocountry, 'CHANGEONE') INTO _addrId; SELECT shipto_addr_id INTO _shiptoid FROM shiptoinfo WHERE (shipto_id=NEW.quhead_shipto_id); -- If the address passed doesn't match shipto address, then it's something else IF (_shiptoid <> _addrId) THEN NEW.quhead_shipto_id := NULL; END IF; ELSE SELECT quhead_shipto_id INTO _shiptoid FROM quhead WHERE (quhead_id=NEW.quhead_id); -- Get the shipto address IF (COALESCE(NEW.quhead_shipto_id,-1) <> COALESCE(_shiptoid,-1)) THEN SELECT * INTO _a FROM shiptoinfo LEFT OUTER JOIN cntct ON (shipto_cntct_id=cntct_id) LEFT OUTER JOIN addr ON (shipto_addr_id=addr_id) WHERE (shipto_id=NEW.quhead_shipto_id); IF (FOUND) THEN -- Free form not allowed so we're going to make sure address matches Shipto data NEW.quhead_shiptoname := COALESCE(_a.shipto_name,''); NEW.quhead_shiptophone := COALESCE(_a.cntct_phone,''); NEW.quhead_shiptoaddress1 := COALESCE(_a.addr_line1,''); NEW.quhead_shiptoaddress2 := COALESCE(_a.addr_line2,''); NEW.quhead_shiptoaddress3 := COALESCE(_a.addr_line3,''); NEW.quhead_shiptocity := COALESCE(_a.addr_city,''); NEW.quhead_shiptostate := COALESCE(_a.addr_state,''); NEW.quhead_shiptozipcode := COALESCE(_a.addr_postalcode,''); NEW.quhead_shiptocountry := COALESCE(_a.addr_country,''); ELSE -- If no shipto data and free form not allowed, this won't work RAISE EXCEPTION 'Free form Shipto is not allowed on this Customer. You must supply a valid Shipto ID.'; END IF; END IF; END IF; END IF; END IF; END IF; IF ( SELECT (metric_value='t') FROM metric WHERE (metric_name='SalesOrderChangeLog') ) THEN -- Cache the cmnttype_id for ChangeLog SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (FOUND) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'Q', NEW.quhead_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.quhead_terms_id <> NEW.quhead_terms_id) THEN PERFORM postComment( _cmnttypeid, 'Q', NEW.quhead_id, ('Terms Changed from "' || oldterms.terms_code || '" to "' || newterms.terms_code || '"') ) FROM terms AS oldterms, terms AS newterms WHERE ( (oldterms.terms_id=OLD.quhead_terms_id) AND (newterms.terms_id=NEW.quhead_terms_id) ); END IF; ELSIF (TG_OP = 'DELETE') THEN DELETE FROM comment WHERE ( (comment_source='Q') AND (comment_source_id=OLD.quhead_id) ); END IF; END IF; END IF; IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE RETURN NEW; END IF; END; $$; 'DROP FUNCTION public._quheadtrigger(); publicadminfalse46238) 125587269_quitemafterdeletetrigger()FUNCTIONhCREATE FUNCTION _quitemafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'QI' AND charass_target_id = OLD.quitem_id; RETURN OLD; END; $$; 2DROP FUNCTION public._quitemafterdeletetrigger(); publicadminfalse84623( 125577886_quitemaftertrigger()FUNCTIONCREATE FUNCTION _quitemaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check NUMERIC; BEGIN --If auto calculate freight, recalculate quhead_freight IF (SELECT quhead_calcfreight FROM quhead WHERE (quhead_id=NEW.quitem_quhead_id)) THEN UPDATE quhead SET quhead_freight = (SELECT SUM(freightdata_total) FROM freightDetail('QU', quhead_id, quhead_cust_id, quhead_shipto_id, quhead_quotedate, quhead_shipvia, quhead_curr_id)) WHERE quhead_id=NEW.quitem_quhead_id; END IF; RETURN NEW; END; $$; ,DROP FUNCTION public._quitemaftertrigger(); publicadminfalse46238' 125577887_quitembeforetrigger()FUNCTIONCREATE FUNCTION _quitembeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check NUMERIC; _itemNumber TEXT; BEGIN -- Check IF (NEW.quitem_scheddate IS NULL) THEN RAISE EXCEPTION 'A schedule date is required.'; END IF; -- If this is imported, go ahead and insert default characteristics IF ((TG_OP = 'INSERT') AND NEW.quitem_imported) THEN PERFORM updateCharAssignment('SI', NEW.quitem_id, char_id, charass_value) FROM ( SELECT DISTINCT char_id, char_name, charass_value FROM charass, char, itemsite, item WHERE ((itemsite_id=NEW.quitem_itemsite_id) AND (itemsite_item_id=item_id) AND (charass_target_type='I') AND (charass_target_id=item_id) AND (charass_default) AND (char_id=charass_char_id)) ORDER BY char_name) AS data; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._quitembeforetrigger(); publicadminfalse46238& 125577888_quitemtrigger()FUNCTIONCREATE FUNCTION _quitemtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _changelog BOOLEAN := FALSE; _check BOOLEAN; BEGIN -- Checks SELECT checkPrivilege('MaintainQuotes') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to maintain Quotes.'; END IF; IF ( SELECT fetchMetricBool('SalesOrderChangeLog') ) THEN _changelog := TRUE; END IF; IF (TG_OP = 'INSERT') THEN IF (_changelog) THEN PERFORM postComment('ChangeLog', 'QI', NEW.quitem_id, 'Created'); END IF; RETURN NEW; END IF; IF (TG_OP = 'DELETE') THEN DELETE FROM comment WHERE ( (comment_source='QI') AND (comment_source_id=OLD.quitem_id) ); DELETE FROM charass WHERE ((charass_target_type='QI') AND (charass_target_id=OLD.quitem_id)); RETURN OLD; END IF; IF (TG_OP = 'UPDATE') THEN IF (_changelog) THEN IF (NEW.quitem_qtyord <> OLD.quitem_qtyord) THEN PERFORM postComment( 'ChangeLog', 'QI', NEW.quitem_id, ( 'Changed Qty. Ordered from ' || formatQty(OLD.quitem_qtyord) || ' to ' || formatQty(NEW.quitem_qtyord) ) ); END IF; IF (NEW.quitem_price <> OLD.quitem_price) THEN PERFORM postComment( 'ChangeLog', 'QI', NEW.quitem_id, ( 'Changed Unit Price from ' || formatPrice(OLD.quitem_price) || ' to ' || formatPrice(NEW.quitem_price) ) ); END IF; IF (NEW.quitem_scheddate <> OLD.quitem_scheddate) THEN PERFORM postComment( 'ChangeLog', 'QI', NEW.quitem_id, ( 'Changed Sched. Date from ' || formatDate(OLD.quitem_scheddate) || ' to ' || formatDate(NEW.quitem_scheddate)) ); END IF; END IF; END IF; -- NEW.quitem_lastupdated = CURRENT_TIMESTAMP; RETURN NEW; END; $$; 'DROP FUNCTION public._quitemtrigger(); publicadminfalse84623* 125577889_recuraftertrigger()FUNCTIONCREATE FUNCTION _recuraftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _parentid INTEGER; _parenttype TEXT; BEGIN IF (TG_OP = 'DELETE') THEN IF (UPPER(OLD.recur_parent_type) = 'TODO') THEN UPDATE todoitem SET todoitem_recurring_todoitem_id=NULL WHERE (todoitem_recurring_todoitem_id=OLD.recur_parent_id); END IF; RETURN OLD; END IF; RETURN NEW; END; $$; +DROP FUNCTION public._recuraftertrigger(); publicadminfalse46238 125577890_reporttrigger()FUNCTIONCREATE FUNCTION _reporttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN NEW.report_loaddate = CURRENT_TIMESTAMP; RETURN NEW; END; $$; 'DROP FUNCTION public._reporttrigger(); publicadminfalse46238- 125577891_salesrepafterdeletetrigger()FUNCTIONCREATE FUNCTION _salesrepafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN IF (SELECT fetchMetricValue('DefaultSalesRep') = OLD.salesrep_id) THEN RAISE EXCEPTION 'Cannot delete the default Sales Rep [xtuple: salesrep, -1, %]', OLD.salesrep_number; END IF; PERFORM postComment('ChangeLog', 'SR', OLD.salesrep_id, 'Deleted "' || OLD.salesrep_number || '"'); RETURN OLD; END; $$; 4DROP FUNCTION public._salesrepafterdeletetrigger(); publicadminfalse46238, 125577892_salesrepaftertrigger()FUNCTIONg CREATE FUNCTION _salesrepaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF (TG_OP = 'INSERT') THEN -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE LOOP UPDATE crmacct SET crmacct_salesrep_id=NEW.salesrep_id, crmacct_name=NEW.salesrep_name WHERE crmacct_number=NEW.salesrep_number; IF (FOUND) THEN EXIT; END IF; BEGIN INSERT INTO crmacct(crmacct_number, crmacct_name, crmacct_active, crmacct_type, crmacct_salesrep_id ) VALUES (NEW.salesrep_number, NEW.salesrep_name, NEW.salesrep_active, 'I', NEW.salesrep_id); EXIT; EXCEPTION WHEN unique_violation THEN -- do nothing, and loop to try the UPDATE again END; END LOOP; -- TODO: default characteristic assignments? ELSIF (TG_OP = 'UPDATE') THEN UPDATE crmacct SET crmacct_number = NEW.salesrep_number WHERE ((crmacct_salesrep_id=NEW.salesrep_id) AND (crmacct_number!=NEW.salesrep_number)); UPDATE crmacct SET crmacct_name = NEW.salesrep_name WHERE ((crmacct_salesrep_id=NEW.salesrep_id) AND (crmacct_name!=NEW.salesrep_name)); END IF; IF (fetchMetricBool('SalesRepChangeLog')) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment('ChangeLog', 'SR', NEW.salesrep_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.salesrep_active <> NEW.salesrep_active) THEN PERFORM postComment('ChangeLog', 'SR', NEW.salesrep_id, CASE WHEN NEW.salesrep_active THEN 'Activated' ELSE 'Deactivated' END); END IF; IF (OLD.salesrep_number <> NEW.salesrep_number) THEN PERFORM postComment('ChangeLog', 'SR', NEW.salesrep_id, 'Number changed from "' || OLD.salesrep_number || '" to "' || NEW.salesrep_number || '"'); END IF; IF (OLD.salesrep_name <> NEW.salesrep_name) THEN PERFORM postComment('ChangeLog', 'SR', NEW.salesrep_id, 'Name changed from "' || OLD.salesrep_name || '" to "' || NEW.salesrep_name || '"'); END IF; IF (OLD.salesrep_commission <> NEW.salesrep_commission) THEN PERFORM postComment('ChangeLog', 'SR', NEW.salesrep_id, 'Commission changed from "' || OLD.salesrep_commission || '" to "' || NEW.salesrep_commission || '"'); END IF; IF (OLD.salesrep_method <> NEW.salesrep_method) THEN PERFORM postComment('ChangeLog', 'SR', NEW.salesrep_id, 'Method changed from "' || OLD.salesrep_method || '" to "' || NEW.salesrep_method || '"'); END IF; END IF; END IF; RETURN NEW; END; $$; .DROP FUNCTION public._salesrepaftertrigger(); publicadminfalse46238+ 125577893_salesrepbeforetrigger()FUNCTIONCREATE FUNCTION _salesrepbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF NOT (checkPrivilege('MaintainSalesReps')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Sales Reps.'; END IF; IF (TG_OP IN ('INSERT', 'UPDATE')) THEN IF (NEW.salesrep_number IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Sales Rep Number.'; END IF; IF (NEW.salesrep_commission IS NULL) THEN RAISE EXCEPTION 'You must supply a Commission Rate for this Sales Rep.'; END IF; IF (TG_OP = 'INSERT' AND fetchMetricText('CRMAccountNumberGeneration') IN ('A','O') AND isNumeric(NEW.salesrep_number)) THEN --- clear the number from the issue cache PERFORM clearNumberIssue('CRMAccountNumber', NEW.salesrep_number); END IF; NEW.salesrep_number = UPPER(NEW.salesrep_number); -- deprecated column salesrep_emp_id -- TODO: will this prevent breaking the crmacct-emp relationship? IF (TG_OP = 'UPDATE') THEN SELECT crmacct_emp_id INTO NEW.salesrep_emp_id FROM crmacct WHERE crmacct_salesrep_id = NEW.salesrep_id; END IF; ELSIF (TG_OP = 'DELETE') THEN UPDATE crmacct SET crmacct_salesrep_id = NULL WHERE crmacct_salesrep_id = OLD.salesrep_id; RETURN OLD; END IF; RETURN NEW; END; $$; /DROP FUNCTION public._salesrepbeforetrigger(); publicadminfalse84623/ 125587277_saletypeaftertrigger()FUNCTIONCREATE FUNCTION _saletypeaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- If this Sale Type is marked "default" set all others to not default IF (NEW.saletype_default) THEN UPDATE saletype SET saletype_default = false WHERE saletype_id <> NEW.saletype_id; END IF; RETURN NEW; END; $$; .DROP FUNCTION public._saletypeaftertrigger(); publicadminfalse84623. 125577894_saletypebeforedeletetrigger()FUNCTIONCREATE FUNCTION _saletypebeforedeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check TEXT; BEGIN -- Check to see if any sales orders are assigned to the passed saletype SELECT cohead_number INTO _check FROM cohead WHERE (cohead_saletype_id=OLD.saletype_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Assigned to Sales Order % and possibly more. [xtuple: deletesaletype, -1]', _check; END IF; -- Check to see if any quotes are assigned to the passed saletype SELECT quhead_number INTO _check FROM quhead WHERE (quhead_saletype_id=OLD.saletype_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Assigned to Quote % and possibly more. [xtuple: deletesaletype, -2]', _check; END IF; -- Check to see if any invoice are assigned to the passed saletype SELECT invchead_invcnumber INTO _check FROM invchead WHERE (invchead_saletype_id=OLD.saletype_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Assigned to Invoice % and possibly more. [xtuple: deletesaletype, -3]', _check; END IF; -- Check to see if any credit memos are assigned to the passed saletype SELECT cmhead_number INTO _check FROM cmhead WHERE (cmhead_saletype_id=OLD.saletype_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Assigned to Credit Memo % and possibly more. [xtuple: deletesaletype, -4]', _check; END IF; -- Check to see if any return ruthorizations are assigned to the passed saletype IF (fetchMetricBool('EnableReturnAuth')) THEN SELECT rahead_number INTO _check FROM rahead WHERE (rahead_saletype_id=OLD.saletype_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Assigned to Return Authorization % and possibly more returns. [xtuple: deleteSaleType, -5]', _check; END IF; END IF; RETURN OLD; END; $$; 5DROP FUNCTION public._saletypebeforedeletetrigger(); publicadminfalse846231 125577895_shipdatasumtrigger()FUNCTIONiCREATE FUNCTION _shipdatasumtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (LENGTH(TRIM(NEW.shipdatasum_shiphead_number)) = 0) THEN NEW.shipdatasum_shiphead_number = NULL; END IF; RETURN NEW; END; $$; ,DROP FUNCTION public._shipdatasumtrigger(); publicadminfalse846230 125577896_shipdatatrigger()FUNCTIONCREATE FUNCTION _shipdatatrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _newShipdata_cohead_number INTEGER; _shipdatasum_shipper TEXT; _rows INTEGER; _cohead_id INTEGER; _shiphead_number TEXT; _headcount INTEGER; BEGIN -- This is where the shipper is identified and may need to be changed NEW.shipdata_cohead_number := TRIM(NEW.shipdata_cohead_number); IF (substring(NEW.shipdata_cosmisc_tracknum from 1 for 2) = '1Z') THEN _shipdatasum_shipper := 'UPS'; ELSE _shipdatasum_shipper := 'UNKNOWN'; END IF; IF (LENGTH(TRIM(NEW.shipdata_shiphead_number)) = 0) THEN NEW.shipdata_shiphead_number := NULL; END IF; IF (NEW.shipdata_cosmisc_tracknum = NEW.shipdata_cosmisc_packnum_tracknum) THEN IF (NEW.shipdata_void_ind = 'Y') THEN -- Delete the current shipdatasum DELETE FROM shipdatasum WHERE ((shipdatasum_cohead_number = NEW.shipdata_cohead_number) AND (shipdatasum_cosmisc_tracknum = NEW.shipdata_cosmisc_tracknum)); ELSIF (TG_OP = 'INSERT') THEN -- RAISE NOTICE 'Getting cohead_id (%)', NEW.shipdata_cohead_number; IF (NEW.shipdata_shiphead_number IS NULL) THEN SELECT cohead_id INTO _cohead_id FROM cohead WHERE cohead_number = NEW.shipdata_cohead_number; IF (FOUND) THEN -- RAISE NOTICE 'Getting shiphead number (%)', _cohead_id; SELECT count(shiphead_order_id), MAX(shiphead_number) INTO _headcount, _shiphead_number FROM shiphead WHERE ((shiphead_tracknum IS NULL OR shiphead_tracknum = '') AND ( shiphead_order_type = 'SO' and shiphead_order_id = _cohead_id) ); IF (_headcount = 1) THEN -- RAISE NOTICE 'Updating Shiphead Number (%)', _shiphead_number; NEW.shipdata_shiphead_number = _shiphead_number; ELSIF (_headcount > 1) THEN -- Trap for potential workflow problem. Can only infer shiphead from sales order number -- if shipping one at a time RAISE EXCEPTION 'Multiple shipments exist for this order. Please provide a specific a shipment number.'; END IF; END IF; END IF; INSERT INTO shipdatasum (shipdatasum_cohead_number, shipdatasum_cosmisc_tracknum, shipdatasum_cosmisc_packnum_tracknum, shipdatasum_weight, shipdatasum_base_freight, shipdatasum_total_freight, shipdatasum_base_freight_curr_id, shipdatasum_total_freight_curr_id, shipdatasum_shipper, shipdatasum_billing_option, shipdatasum_package_type, shipdatasum_shiphead_number) VALUES (NEW.shipdata_cohead_number, NEW.shipdata_cosmisc_tracknum, NEW.shipdata_cosmisc_packnum_tracknum, NEW.shipdata_weight, NEW.shipdata_base_freight, NEW.shipdata_total_freight, NEW.shipdata_base_freight_curr_id, NEW.shipdata_total_freight_curr_id, _shipdatasum_shipper, NEW.shipdata_billing_option, NEW.shipdata_package_type, NEW.shipdata_shiphead_number); ELSIF (TG_OP = 'UPDATE') THEN UPDATE shipdatasum SET shipdatasum_cohead_number=NEW.shipdata_cohead_number, shipdatasum_cosmisc_tracknum=NEW.shipdata_cosmisc_tracknum, shipdatasum_cosmisc_packnum_tracknum=NEW.shipdata_cosmisc_packnum_tracknum, shipdatasum_weight=NEW.shipdata_weight, shipdatasum_base_freight=NEW.shipdata_base_freight, shipdatasum_total_freight=NEW.shipdata_total_freight, shipdatasum_base_freight_curr_id=NEW.shipdata_base_freight_curr_id, shipdatasum_total_freight_curr_id=NEW.shipdata_total_freight_curr_id, shipdatasum_shipper=_shipdatasum_shipper, shipdatasum_billing_option=NEW.shipdata_billing_option, shipdatasum_package_type=NEW.shipdata_package_type, shipdatasum_shiphead_number=NEW.shipdata_shiphead_number WHERE ((TRIM(shipdatasum_cohead_number)=TRIM(OLD.shipdata_cohead_number)) AND (TRIM(shipdatasum_cosmisc_tracknum)=TRIM(OLD.shipdata_cosmisc_tracknum)) AND (TRIM(shipdatasum_cosmisc_packnum_tracknum)=TRIM(OLD.shipdata_cosmisc_packnum_tracknum))); GET DIAGNOSTICS _rows = ROW_COUNT; IF (_rows <= 0) THEN INSERT INTO shipdatasum (shipdatasum_cohead_number, shipdatasum_cosmisc_tracknum, shipdatasum_cosmisc_packnum_tracknum, shipdatasum_weight, shipdatasum_base_freight, shipdatasum_total_freight, shipdatasum_base_freight_curr_id, shipdatasum_total_freight_curr_id, shipdatasum_shipper, shipdatasum_billing_option, shipdatasum_package_type, shipdatasum_shiphead_number) VALUES (NEW.shipdata_cohead_number, NEW.shipdata_cosmisc_tracknum, NEW.shipdata_cosmisc_packnum_tracknum, NEW.shipdata_weight, NEW.shipdata_base_freight, NEW.shipdata_total_freight, NEW.shipdata_base_freight_curr_id, NEW.shipdata_total_freight_curr_id, _shipdatasum_shipper, NEW.shipdata_billing_option, NEW.shipdata_package_type, NEW.shipdata_shiphead_number); END IF; END IF; END IF; RETURN NEW; END; $$; )DROP FUNCTION public._shipdatatrigger(); publicadminfalse462382 125577897_shipformafterdeletetrigger()FUNCTIONCREATE FUNCTION _shipformafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (fetchMetricValue('DefaultShipFormId') = OLD.shipform_id) THEN RAISE EXCEPTION 'Cannot delete the default Shipping Form [xtuple: shipform, -1, %, %]', OLD.shipform_name, OLD.shipform_report_name; END IF; RETURN OLD; END; $$; 4DROP FUNCTION public._shipformafterdeletetrigger(); publicadminfalse462383 125577898_shipheadbeforetrigger()FUNCTIONCREATE FUNCTION _shipheadbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF ((TG_OP = 'INSERT') OR (TG_OP = 'UPDATE')) THEN IF (NEW.shiphead_order_type = 'SO' AND NEW.shiphead_order_id IN (SELECT cohead_id FROM cohead)) THEN RETURN NEW; ELSEIF (NEW.shiphead_order_type = 'TO' AND NEW.shiphead_order_id IN (SELECT tohead_id FROM tohead)) THEN RETURN NEW; END IF; RAISE EXCEPTION '% with id % does not exist', NEW.shiphead_order_type, NEW.shiphead_order_id; RETURN OLD; END IF; RETURN NEW; END; $$; /DROP FUNCTION public._shipheadbeforetrigger(); publicadminfalse462384 125577899_shiptoinfoaftertrigger()FUNCTIONvCREATE FUNCTION _shiptoinfoaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; BEGIN IF (NEW.shipto_default) THEN UPDATE shiptoinfo SET shipto_default = false WHERE ((shipto_cust_id=NEW.shipto_cust_id) AND (shipto_id <> NEW.shipto_id)); END IF; IF (SELECT fetchMetricBool('CustomerChangeLog')) THEN -- Cache the cmnttype_id for ChangeLog SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (FOUND) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'C', NEW.shipto_cust_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.shipto_name <> NEW.shipto_name) THEN PERFORM postComment( _cmnttypeid, 'C', NEW.shipto_cust_id, ( NEW.shipto_name || ': Ship To Name Changed from "' || COALESCE(OLD.shipto_name, '') || '" to "' || COALESCE(NEW.shipto_name, '') || '"' ) ); END IF; IF (OLD.shipto_shipvia <> NEW.shipto_shipvia) THEN PERFORM postComment( _cmnttypeid, 'C', NEW.shipto_cust_id, ( NEW.shipto_name || ': Ship To ShipVia Changed from "' || COALESCE(OLD.shipto_shipvia, '') || '" to "' || COALESCE(NEW.shipto_shipvia, '') || '"' ) ); END IF; IF (COALESCE(OLD.shipto_taxzone_id, -1) <> COALESCE(NEW.shipto_taxzone_id, -1)) THEN PERFORM postComment( _cmnttypeid, 'C', NEW.shipto_cust_id, ( NEW.shipto_name || ': Ship To Tax Zone Changed from "' || COALESCE((SELECT taxzone_code FROM taxzone WHERE taxzone_id=OLD.shipto_taxzone_id), 'None') || '" to "' || COALESCE((SELECT taxzone_code FROM taxzone WHERE taxzone_id=NEW.shipto_taxzone_id), 'None') || '"' ) ); END IF; IF (OLD.shipto_shipzone_id <> NEW.shipto_shipzone_id) THEN PERFORM postComment( _cmnttypeid, 'C', NEW.shipto_cust_id, ( NEW.shipto_name || ': Ship To Shipping Zone Changed from "' || (SELECT shipzone_name FROM shipzone WHERE shipzone_id=OLD.shipto_shipzone_id) || '" to "' || (SELECT shipzone_name FROM shipzone WHERE shipzone_id=NEW.shipto_shipzone_id) || '"' ) ); END IF; IF (OLD.shipto_salesrep_id <> NEW.shipto_salesrep_id) THEN PERFORM postComment( _cmnttypeid, 'C', NEW.shipto_cust_id, ( NEW.shipto_name || ': Ship To Sales Rep Changed from "' || (SELECT salesrep_name FROM salesrep WHERE salesrep_id=OLD.shipto_salesrep_id) || '" to "' || (SELECT salesrep_name FROM salesrep WHERE salesrep_id=NEW.shipto_salesrep_id) || '"' ) ); END IF; IF (OLD.shipto_active <> NEW.shipto_active) THEN IF (NEW.shipto_active) THEN PERFORM postComment(_cmnttypeid, 'C', NEW.shipto_cust_id, (NEW.shipto_name || ': Ship To Activated')); ELSE PERFORM postComment(_cmnttypeid, 'C', NEW.shipto_cust_id, (NEW.shipto_name || ': Ship To Deactivated')); END IF; END IF; END IF; END IF; END IF; RETURN NEW; END; $$; 0DROP FUNCTION public._shiptoinfoaftertrigger(); publicadminfalse462385 125577900_shipviaafterdeletetrigger()FUNCTIONCREATE FUNCTION _shipviaafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (SELECT fetchMetricValue('DefaultShipViaId') = OLD.shipvia_id) THEN RAISE EXCEPTION 'Cannot delete the default Ship-Via [xtuple: shipvia, -1, %]', OLD.shipvia_code; END IF; RETURN OLD; END; $$; 3DROP FUNCTION public._shipviaafterdeletetrigger(); publicadminfalse846238 125577901_sltransaltertrigger()FUNCTION CREATE FUNCTION _sltransaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _externalCompany BOOLEAN := false; _updated BOOLEAN := false; BEGIN IF(TG_OP='DELETE') THEN RAISE EXCEPTION 'You may not delete Journal Transactions once they have been created.'; ELSIF (TG_OP = 'UPDATE') THEN IF(OLD.sltrans_id != NEW.sltrans_id) THEN _updated := true; ELSIF(OLD.sltrans_date != NEW.sltrans_date) THEN _updated := true; ELSIF(OLD.sltrans_accnt_id != NEW.sltrans_accnt_id) THEN _updated := true; ELSIF(OLD.sltrans_amount != NEW.sltrans_amount) THEN _updated := true; ELSIF(OLD.sltrans_username != NEW.sltrans_username) THEN _updated := true; ELSIF( (OLD.sltrans_sequence IS NULL AND NEW.sltrans_sequence IS NOT NULL) OR (OLD.sltrans_sequence IS NOT NULL AND NEW.sltrans_sequence IS NULL) OR (COALESCE(OLD.sltrans_sequence,0) != COALESCE(NEW.sltrans_sequence,0)) ) THEN _updated := true; ELSIF( (OLD.sltrans_created IS NULL AND NEW.sltrans_created IS NOT NULL) OR (OLD.sltrans_created IS NOT NULL AND NEW.sltrans_created IS NULL) OR (COALESCE(OLD.sltrans_created,now()) != COALESCE(NEW.sltrans_created,now())) ) THEN _updated := true; ELSIF( (OLD.sltrans_source IS NULL AND NEW.sltrans_source IS NOT NULL) OR (OLD.sltrans_source IS NOT NULL AND NEW.sltrans_source IS NULL) OR (COALESCE(OLD.sltrans_source,'') != COALESCE(NEW.sltrans_source,'')) ) THEN _updated := true; ELSIF( (OLD.sltrans_docnumber IS NULL AND NEW.sltrans_docnumber IS NOT NULL) OR (OLD.sltrans_docnumber IS NOT NULL AND NEW.sltrans_docnumber IS NULL) OR (COALESCE(OLD.sltrans_docnumber,'') != COALESCE(NEW.sltrans_docnumber,'')) ) THEN _updated := true; ELSIF( (OLD.sltrans_doctype IS NULL AND NEW.sltrans_doctype IS NOT NULL) OR (OLD.sltrans_doctype IS NOT NULL AND NEW.sltrans_doctype IS NULL) OR (COALESCE(OLD.sltrans_doctype,'') != COALESCE(NEW.sltrans_doctype,'')) ) THEN _updated := true; END IF; IF(_updated) THEN RAISE EXCEPTION 'You may not alter some Journal Transaction fields once they have been created.'; END IF; ELSE RAISE EXCEPTION 'trigger for sltrans table called in unexpected state.'; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._sltransaltertrigger(); publicadminfalse846237 125577902_sltransinserttrigger()FUNCTIONkCREATE FUNCTION _sltransinserttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _reqNotes BOOLEAN; _externalCompany BOOLEAN := false; BEGIN -- Checks SELECT company_external INTO _externalCompany FROM company JOIN accnt ON (company_number=accnt_company) WHERE (accnt_id=NEW.sltrans_accnt_id); IF (_externalCompany) THEN RAISE EXCEPTION 'Transactions are not allowed for G/L Accounts with External Company segments.'; END IF; RETURN NEW; END; $$; .DROP FUNCTION public._sltransinserttrigger(); publicadminfalse84623125577903_soheadtrigger()FUNCTION;`CREATE FUNCTION _soheadtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _p RECORD; _a RECORD; _w RECORD; _shiptoId INTEGER; _addrId INTEGER; _prjId INTEGER; _check BOOLEAN; _numGen CHAR(1); BEGIN -- Checks -- Start with privileges IF (TG_OP = 'INSERT') THEN IF ( (NOT checkPrivilege('MaintainSalesOrders')) AND (NOT checkPrivilege('EnterReceipts')) ) THEN RAISE EXCEPTION 'You do not have privileges to create a Sales Order.'; END IF; ELSIF (TG_OP = 'UPDATE') THEN IF ( (NOT checkPrivilege('MaintainSalesOrders')) AND (NOT checkPrivilege('IssueStockToShipping')) AND (NEW.cohead_holdtype = OLD.cohead_holdtype) ) THEN RAISE EXCEPTION 'You do not have privileges to alter a Sales Order.'; END IF; ELSE IF ( (NOT checkPrivilege('MaintainSalesOrders')) AND (NOT checkPrivilege('IssueStockToShipping')) ) THEN RAISE EXCEPTION 'You do not have privileges to alter a Sales Order.'; END IF; END IF; -- If this is imported, check the order number IF (TG_OP = 'INSERT') THEN IF (NEW.cohead_imported) THEN SELECT fetchMetricText('CONumberGeneration') INTO _numGen; IF ((NEW.cohead_number IS NULL) AND (_numGen='M')) THEN RAISE EXCEPTION 'You must supply an Order Number.'; ELSE IF (NEW.cohead_number IS NULL) THEN SELECT fetchsonumber() INTO NEW.cohead_number; END IF; END IF; END IF; IF (fetchMetricText('CONumberGeneration') IN ('A','O')) THEN --- clear the number from the issue cache PERFORM clearNumberIssue('SoNumber', NEW.cohead_number); END IF; ELSE IF (TG_OP = 'UPDATE') THEN IF (NEW.cohead_number <> OLD.cohead_number) THEN RAISE EXCEPTION 'The order number may not be changed.'; END IF; END IF; END IF; IF (TG_OP IN ('INSERT','UPDATE')) THEN -- Get Customer data IF (NEW.cohead_shipto_id IS NULL) THEN SELECT cust_creditstatus,cust_number,cust_usespos,cust_blanketpos,cust_ffbillto, cust_ffshipto,cust_name,cust_salesrep_id,cust_terms_id,cust_shipvia, cust_shipchrg_id,cust_shipform_id,cust_commprcnt,cust_curr_id,cust_taxzone_id, cntct.*,addr.*, shipto_id,shipto_addr_id,shipto_name,shipto_salesrep_id,shipto_shipvia, shipto_shipchrg_id,shipto_shipform_id,shipto_commission,shipto_taxzone_id INTO _p FROM custinfo LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) LEFT OUTER JOIN shiptoinfo ON ((cust_id=shipto_cust_id) AND shipto_default) WHERE (cust_id=NEW.cohead_cust_id); ELSE SELECT cust_creditstatus,cust_number,cust_usespos,cust_blanketpos,cust_ffbillto, cust_ffshipto,cust_name,cust_salesrep_id,cust_terms_id,cust_shipvia, cust_shipchrg_id,cust_shipform_id,cust_commprcnt,cust_curr_id,cust_taxzone_id, cntct.*,addr.*, shipto_id,shipto_addr_id,shipto_name,shipto_salesrep_id,shipto_shipvia, shipto_shipchrg_id,shipto_shipform_id,shipto_commission,shipto_taxzone_id INTO _p FROM shiptoinfo,custinfo LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) WHERE ((cust_id=NEW.cohead_cust_id) AND (shipto_id=NEW.cohead_shipto_id)); END IF; -- If there is customer data, then we can get to work IF (FOUND) THEN -- Check Credit IF (TG_OP = 'INSERT') THEN IF (_p.cust_creditstatus = 'H') THEN SELECT checkPrivilege('CreateSOForHoldCustomer') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'Customer % has been placed on a Credit Hold and you do not have privilege to create Sales Orders for Customers on Credit Hold. The selected Customer must be taken off of Credit Hold before you may create a new Sales Order for the Customer.',_p.cust_number; ELSE NEW.cohead_holdtype='C'; END IF; END IF; IF (_p.cust_creditstatus = 'W') THEN SELECT checkPrivilege('CreateSOForWarnCustomer') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'Customer % has been placed on a Credit Warning and you do not have privilege to create Sales Orders for Customers on Credit Warning. The selected Customer must be taken off of Credit Warning before you may create a new Sales Order for the Customer.',_p.cust_number; ELSE NEW.cohead_holdtype='C'; END IF; END IF; -- Set to defaults if values not provided NEW.cohead_shipto_id := COALESCE(NEW.cohead_shipto_id,_p.shipto_id); NEW.cohead_terms_id := COALESCE(NEW.cohead_terms_id,_p.cust_terms_id); NEW.cohead_orderdate := COALESCE(NEW.cohead_orderdate,current_date); NEW.cohead_packdate := COALESCE(NEW.cohead_packdate,NEW.cohead_orderdate); NEW.cohead_curr_id := COALESCE(NEW.cohead_curr_id,_p.cust_curr_id,basecurrid()); NEW.cohead_freight := COALESCE(NEW.cohead_freight,0); NEW.cohead_custponumber := COALESCE(NEW.cohead_custponumber,''); NEW.cohead_ordercomments := COALESCE(NEW.cohead_ordercomments,''); NEW.cohead_shipcomments := COALESCE(NEW.cohead_shipcomments,''); NEW.cohead_shiptophone := COALESCE(NEW.cohead_shiptophone,''); NEW.cohead_misc := COALESCE(NEW.cohead_misc,0); NEW.cohead_misc_descrip := COALESCE(NEW.cohead_misc_descrip,''); NEW.cohead_shipcomplete := COALESCE(NEW.cohead_shipcomplete,false); IF (_p.shipto_id IS NOT NULL) THEN -- Pull in over ride values NEW.cohead_salesrep_id := COALESCE(NEW.cohead_salesrep_id,_p.shipto_salesrep_id); NEW.cohead_shipvia := COALESCE(NEW.cohead_shipvia,_p.shipto_shipvia); NEW.cohead_shipchrg_id := COALESCE(NEW.cohead_shipchrg_id,_p.shipto_shipchrg_id); NEW.cohead_shipform_id := COALESCE(NEW.cohead_shipform_id,_p.shipto_shipform_id); NEW.cohead_commission := COALESCE(NEW.cohead_commission,_p.shipto_commission); IF (NEW.cohead_taxzone_id=-1) THEN NEW.cohead_taxzone_id := NULL; ELSE NEW.cohead_taxzone_id := COALESCE(NEW.cohead_taxzone_id,_p.shipto_taxzone_id); END IF; ELSE NEW.cohead_salesrep_id := COALESCE(NEW.cohead_salesrep_id,_p.cust_salesrep_id); NEW.cohead_shipvia := COALESCE(NEW.cohead_shipvia,_p.cust_shipvia); NEW.cohead_shipchrg_id := COALESCE(NEW.cohead_shipchrg_id,_p.cust_shipchrg_id); NEW.cohead_shipform_id := COALESCE(NEW.cohead_shipform_id,_p.cust_shipform_id); NEW.cohead_commission := COALESCE(NEW.cohead_commission,_p.cust_commprcnt); IF (NEW.cohead_taxzone_id=-1) THEN NEW.cohead_taxzone_id := NULL; ELSE NEW.cohead_taxzone_id := COALESCE(NEW.cohead_taxzone_id,_p.cust_taxzone_id); END IF; END IF; IF ((NEW.cohead_warehous_id IS NULL) OR (NEW.cohead_fob IS NULL)) THEN IF (NEW.cohead_warehous_id IS NULL) THEN SELECT warehous_id,warehous_fob INTO _w FROM usrpref, whsinfo WHERE ((warehous_id=CAST(usrpref_value AS INTEGER)) AND (warehous_shipping) AND (warehous_active) AND (usrpref_username=getEffectiveXtUser()) AND (usrpref_name='PreferredWarehouse')); ELSE SELECT warehous_id,warehous_fob INTO _w FROM whsinfo WHERE (warehous_id=NEW.cohead_warehous_id); END IF; IF (FOUND) THEN NEW.cohead_warehous_id := COALESCE(NEW.cohead_warehous_id,_w.warehous_id); NEW.cohead_fob := COALESCE(NEW.cohead_fob,_w.warehous_fob); END IF; END IF; END IF; -- Only Check P/O logic for imports, because UI checks when entire order is saved IF (NEW.cohead_imported) THEN -- Check for required Purchase Order IF (_p.cust_usespos AND ((NEW.cohead_custponumber IS NULL) OR (TRIM(BOTH FROM NEW.cohead_custponumber)=''))) THEN RAISE EXCEPTION 'You must enter a Customer P/O for this Sales Order.'; END IF; -- Check for duplicate Purchase Orders if not allowed IF (_p.cust_usespos AND NOT (_p.cust_blanketpos)) THEN SELECT cohead_id INTO _a FROM cohead WHERE ((cohead_cust_id=NEW.cohead_cust_id) AND (cohead_id<>NEW.cohead_id) AND (UPPER(cohead_custponumber) = UPPER(NEW.cohead_custponumber)) ) UNION SELECT quhead_id FROM quhead WHERE ((quhead_cust_id=NEW.cohead_cust_id) AND (quhead_id<>NEW.cohead_id) AND (UPPER(quhead_custponumber) = UPPER(NEW.cohead_custponumber)) ); IF (FOUND) THEN RAISE EXCEPTION 'This Customer does not use Blanket P/O Numbers and the P/O Number you entered has already been used for another Sales Order. Please verify the P/O Number and either enter a new P/O Number or add to the existing Sales Order.'; END IF; END IF; END IF; --Auto create project if applicable IF ((TG_OP = 'INSERT') AND (COALESCE(NEW.cohead_prj_id,-1)=-1)) THEN SELECT fetchMetricBool('AutoCreateProjectsForOrders') INTO _check; IF (_check) THEN SELECT NEXTVAL('prj_prj_id_seq') INTO _prjId; NEW.cohead_prj_id := _prjId; INSERT INTO prj (prj_id, prj_number, prj_name, prj_descrip, prj_status, prj_so, prj_wo, prj_po, prj_owner_username, prj_start_date, prj_due_date, prj_assigned_date, prj_completed_date, prj_username, prj_recurring_prj_id, prj_crmacct_id, prj_cntct_id, prj_prjtype_id) SELECT _prjId, NEW.cohead_number, NEW.cohead_number, 'Auto Generated Project from Sales Order.', 'O', TRUE, TRUE, TRUE, getEffectiveXTUser(), NEW.cohead_orderdate, NEW.cohead_packdate, NEW.cohead_orderdate, NULL, getEffectiveXTUser(), NULL, crmacct_id, NEW.cohead_billto_cntct_id, NULL FROM crmacct WHERE (crmacct_cust_id=NEW.cohead_cust_id); END IF; END IF; IF (TG_OP = 'UPDATE') THEN SELECT true INTO _check FROM coitem WHERE ( (coitem_status='C') AND (coitem_cohead_id=NEW.cohead_id) ) LIMIT 1; IF (NOT FOUND) THEN --Update project references on supply UPDATE pr SET pr_prj_id=NEW.cohead_prj_id FROM coitem WHERE ((coitem_cohead_id=NEW.cohead_id) AND (coitem_order_type='R') AND (coitem_order_id=pr_id)); PERFORM changeWoProject(coitem_order_id, NEW.cohead_prj_id, TRUE) FROM coitem WHERE ((coitem_cohead_id=NEW.cohead_id) AND (coitem_order_type='W')); ELSE IF NEW.cohead_prj_id <> COALESCE(OLD.cohead_prj_id,-1) THEN RAISE EXCEPTION 'You can not change the project ID on orders with closed lines.'; END IF; END IF; END IF; -- Deal with Billing Address IF (TG_OP = 'INSERT') THEN IF (_p.cust_ffbillto) THEN -- If they didn't supply data, we'll put in the bill to contact and address NEW.cohead_billto_cntct_id=COALESCE(NEW.cohead_billto_cntct_id,_p.cntct_id); NEW.cohead_billto_cntct_honorific=COALESCE(NEW.cohead_billto_cntct_honorific,_p.cntct_honorific,''); NEW.cohead_billto_cntct_first_name=COALESCE(NEW.cohead_billto_cntct_first_name,_p.cntct_first_name,''); NEW.cohead_billto_cntct_middle=COALESCE(NEW.cohead_billto_cntct_middle,_p.cntct_middle,''); NEW.cohead_billto_cntct_last_name=COALESCE(NEW.cohead_billto_cntct_last_name,_p.cntct_last_name,''); NEW.cohead_billto_cntct_phone=COALESCE(NEW.cohead_billto_cntct_phone,_p.cntct_phone,''); NEW.cohead_billto_cntct_title=COALESCE(NEW.cohead_billto_cntct_title,_p.cntct_title,''); NEW.cohead_billto_cntct_fax=COALESCE(NEW.cohead_billto_cntct_fax,_p.cntct_fax,''); NEW.cohead_billto_cntct_email=COALESCE(NEW.cohead_billto_cntct_email,_p.cntct_email,''); NEW.cohead_billtoname=COALESCE(NEW.cohead_billtoname,_p.cust_name,''); NEW.cohead_billtoaddress1=COALESCE(NEW.cohead_billtoaddress1,_p.addr_line1,''); NEW.cohead_billtoaddress2=COALESCE(NEW.cohead_billtoaddress2,_p.addr_line2,''); NEW.cohead_billtoaddress3=COALESCE(NEW.cohead_billtoaddress3,_p.addr_line3,''); NEW.cohead_billtocity=COALESCE(NEW.cohead_billtocity,_p.addr_city,''); NEW.cohead_billtostate=COALESCE(NEW.cohead_billtostate,_p.addr_state,''); NEW.cohead_billtozipcode=COALESCE(NEW.cohead_billtozipcode,_p.addr_postalcode,''); NEW.cohead_billtocountry=COALESCE(NEW.cohead_billtocountry,_p.addr_country,''); ELSE -- Free form not allowed, we're going to put in the address regardless NEW.cohead_billto_cntct_id=_p.cntct_id; NEW.cohead_billto_cntct_honorific=COALESCE(_p.cntct_honorific,''); NEW.cohead_billto_cntct_first_name=COALESCE(_p.cntct_first_name,''); NEW.cohead_billto_cntct_middle=COALESCE(_p.cntct_middle,''); NEW.cohead_billto_cntct_last_name=COALESCE(_p.cntct_last_name,''); NEW.cohead_billto_cntct_phone=COALESCE(_p.cntct_phone,''); NEW.cohead_billto_cntct_title=COALESCE(_p.cntct_title,''); NEW.cohead_billto_cntct_fax=COALESCE(_p.cntct_fax,''); NEW.cohead_billto_cntct_email=COALESCE(_p.cntct_email,''); NEW.cohead_billtoname=COALESCE(_p.cust_name,''); NEW.cohead_billtoaddress1=COALESCE(_p.addr_line1,''); NEW.cohead_billtoaddress2=COALESCE(_p.addr_line2,''); NEW.cohead_billtoaddress3=COALESCE(_p.addr_line3,''); NEW.cohead_billtocity=COALESCE(_p.addr_city,''); NEW.cohead_billtostate=COALESCE(_p.addr_state,''); NEW.cohead_billtozipcode=COALESCE(_p.addr_postalcode,''); NEW.cohead_billtocountry=COALESCE(_p.addr_country,''); END IF; END IF; -- Now let's look at Shipto Address -- If there's nothing in the address fields and there is a shipto id -- or there is a default address available, let's put in some shipto address data IF ((TG_OP = 'INSERT') AND NOT ((NEW.cohead_shipto_id IS NULL) AND NOT _p.cust_ffshipto) AND (NEW.cohead_shipto_cntct_id IS NULL) AND (NEW.cohead_shipto_cntct_honorific IS NULL) AND (NEW.cohead_shipto_cntct_first_name IS NULL) AND (NEW.cohead_shipto_cntct_middle IS NULL) AND (NEW.cohead_shipto_cntct_last_name IS NULL) AND (NEW.cohead_shipto_cntct_suffix IS NULL) AND (NEW.cohead_shipto_cntct_phone IS NULL) AND (NEW.cohead_shipto_cntct_title IS NULL) AND (NEW.cohead_shipto_cntct_fax IS NULL) AND (NEW.cohead_shipto_cntct_email IS NULL) AND (NEW.cohead_shiptoname IS NULL) AND (NEW.cohead_shiptoaddress1 IS NULL) AND (NEW.cohead_shiptoaddress2 IS NULL) AND (NEW.cohead_shiptoaddress3 IS NULL) AND (NEW.cohead_shiptocity IS NULL) AND (NEW.cohead_shiptostate IS NULL) AND (NEW.cohead_shiptocountry IS NULL)) THEN IF ((NEW.cohead_shipto_id IS NULL) AND (_p.shipto_id IS NOT NULL)) THEN _shiptoId := _p.shipto_addr_id; ELSE _shiptoId := NEW.cohead_shipto_id; END IF; SELECT * INTO _a FROM shiptoinfo LEFT OUTER JOIN addr ON (addr_id=shipto_addr_id) LEFT OUTER JOIN cntct ON (cntct_id=shipto_cntct_id) WHERE (shipto_id=_shiptoId); NEW.cohead_shipto_cntct_id := _a.cntct_id; NEW.cohead_shipto_cntct_honorific := COALESCE(_a.cntct_honorific,''); NEW.cohead_shipto_cntct_first_name := COALESCE(_a.cntct_first_name,''); NEW.cohead_shipto_cntct_middle := COALESCE(_a.cntct_middle,''); NEW.cohead_shipto_cntct_last_name := COALESCE(_a.cntct_last_name,''); NEW.cohead_shipto_cntct_suffix := COALESCE(_a.cntct_suffix,''); NEW.cohead_shipto_cntct_phone := COALESCE(_a.cntct_phone,''); NEW.cohead_shipto_cntct_title := COALESCE(_a.cntct_title,''); NEW.cohead_shipto_cntct_fax := COALESCE(_a.cntct_fax,''); NEW.cohead_shipto_cntct_email := COALESCE(_a.cntct_email,''); NEW.cohead_shiptoname := COALESCE(_p.shipto_name,''); NEW.cohead_shiptoaddress1 := COALESCE(_a.addr_line1,''); NEW.cohead_shiptoaddress2 := COALESCE(_a.addr_line2,''); NEW.cohead_shiptoaddress3 := COALESCE(_a.addr_line3,''); NEW.cohead_shiptocity := COALESCE(_a.addr_city,''); NEW.cohead_shiptostate := COALESCE(_a.addr_state,''); NEW.cohead_shiptozipcode := COALESCE(_a.addr_postalcode,''); NEW.cohead_shiptocountry := COALESCE(_a.addr_country,''); ELSE IF (_p.cust_ffshipto) THEN -- Use Address Save function to see if the new address entered matches -- data for the shipto number. If not that will insert new address for CRM SELECT SaveAddr( NULL, NULL, NEW.cohead_shiptoaddress1, NEW.cohead_shiptoaddress2, NEW.cohead_shiptoaddress3, NEW.cohead_shiptocity, NEW.cohead_shiptostate, NEW.cohead_shiptozipcode, NEW.cohead_shiptocountry, 'CHANGEONE') INTO _addrId; SELECT shipto_addr_id INTO _shiptoid FROM shiptoinfo WHERE (shipto_id=NEW.cohead_shipto_id); -- If the address passed doesn't match shipto address, then it's something else IF (_shiptoid <> _addrId) THEN NEW.cohead_shipto_id := NULL; END IF; ELSE SELECT cohead_shipto_id INTO _shiptoid FROM cohead WHERE (cohead_id=NEW.cohead_id); -- Get the shipto address IF (COALESCE(NEW.cohead_shipto_id,-1) <> COALESCE(_shiptoid,-1)) THEN SELECT * INTO _a FROM shiptoinfo LEFT OUTER JOIN cntct ON (shipto_cntct_id=cntct_id) LEFT OUTER JOIN addr ON (shipto_addr_id=addr_id) WHERE (shipto_id=NEW.cohead_shipto_id); IF (FOUND) THEN -- Free form not allowed so we're going to make sure address matches Shipto data NEW.cohead_shipto_cntct_id=_a.cntct_id; NEW.cohead_shipto_cntct_honorific=COALESCE(_a.cntct_honorific,''); NEW.cohead_shipto_cntct_first_name=COALESCE(_a.cntct_first_name,''); NEW.cohead_shipto_cntct_middle=COALESCE(_a.cntct_middle,''); NEW.cohead_shipto_cntct_last_name=COALESCE(_a.cntct_last_name,''); NEW.cohead_shipto_cntct_phone=COALESCE(_a.cntct_phone,''); NEW.cohead_shipto_cntct_title=COALESCE(_a.cntct_title,''); NEW.cohead_shipto_cntct_fax=COALESCE(_a.cntct_fax,''); NEW.cohead_shipto_cntct_email=COALESCE(_a.cntct_email,''); NEW.cohead_shiptoname := COALESCE(_a.shipto_name,''); NEW.cohead_shiptophone := COALESCE(_a.cntct_phone,''); NEW.cohead_shiptoaddress1 := COALESCE(_a.addr_line1,''); NEW.cohead_shiptoaddress2 := COALESCE(_a.addr_line2,''); NEW.cohead_shiptoaddress3 := COALESCE(_a.addr_line3,''); NEW.cohead_shiptocity := COALESCE(_a.addr_city,''); NEW.cohead_shiptostate := COALESCE(_a.addr_state,''); NEW.cohead_shiptozipcode := COALESCE(_a.addr_postalcode,''); NEW.cohead_shiptocountry := COALESCE(_a.addr_country,''); ELSE -- If no shipto data and free form not allowed, this won't work RAISE EXCEPTION 'Free form Shipto is not allowed on this Customer. You must supply a valid Shipto ID.'; END IF; END IF; END IF; END IF; END IF; END IF; IF ( SELECT (metric_value='t') FROM metric WHERE (metric_name='SalesOrderChangeLog') ) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment('ChangeLog', 'S', NEW.cohead_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF ( (OLD.cohead_terms_id <> NEW.cohead_terms_id) AND (OLD.cohead_cust_id = NEW.cohead_cust_id) ) THEN PERFORM postComment( 'ChangeLog', 'S', NEW.cohead_id, ('Terms Changed from "' || oldterms.terms_code || '" to "' || newterms.terms_code || '"') ) FROM terms AS oldterms, terms AS newterms WHERE ( (oldterms.terms_id=OLD.cohead_terms_id) AND (newterms.terms_id=NEW.cohead_terms_id) ); END IF; IF ( (OLD.cohead_shipvia <> NEW.cohead_shipvia) AND (OLD.cohead_cust_id = NEW.cohead_cust_id) ) THEN PERFORM postComment ('ChangeLog', 'S', New.cohead_id, ('Shipvia Changed from "' || OLD.cohead_shipvia || '" to "' || NEW.cohead_shipvia || '"')); END IF; IF (OLD.cohead_holdtype <> NEW.cohead_holdtype) THEN PERFORM postComment( 'ChangeLog', 'S', NEW.cohead_id, ( 'Hold Type Changed from ' || (CASE OLD.cohead_holdtype WHEN('N') THEN 'No Hold' WHEN('C') THEN 'Credit Hold' WHEN('P') THEN 'Packing Hold' WHEN('S') THEN 'Shipping Hold' ELSE 'Unknown/Error' END) || ' to ' || (CASE NEW.cohead_holdtype WHEN('N') THEN 'No Hold' WHEN('C') THEN 'Credit Hold' WHEN('P') THEN 'Packing Hold' WHEN('S') THEN 'Shipping Hold' ELSE 'Unknown/Error' END) ) ); END IF; ELSIF (TG_OP = 'DELETE') THEN DELETE FROM docass WHERE docass_source_id = OLD.cohead_id AND docass_source_type = 'S'; DELETE FROM docass WHERE docass_target_id = OLD.cohead_id AND docass_target_type = 'S'; DELETE FROM comment WHERE ( (comment_source='S') AND (comment_source_id=OLD.cohead_id) ); END IF; END IF; IF (TG_OP = 'UPDATE') THEN IF ( (NOT (OLD.cohead_holdtype = 'N')) AND (NEW.cohead_holdtype='N') ) THEN PERFORM postEvent('SoReleased', 'S', NEW.cohead_id, NEW.cohead_warehous_id, NEW.cohead_number, NULL, NULL, NULL, NULL); END IF; IF (OLD.cohead_ordercomments <> NEW.cohead_ordercomments) THEN PERFORM postEvent('SoNotesChanged', 'S', NEW.cohead_id, NEW.cohead_warehous_id, NEW.cohead_number, NULL, NULL, NULL, NULL); END IF; IF ((OLD.cohead_shipchrg_id != NEW.cohead_shipchrg_id) OR (OLD.cohead_freight != NEW.cohead_freight) OR (OLD.cohead_shipvia != NEW.cohead_shipvia)) THEN UPDATE shiphead SET shiphead_shipchrg_id= CASE WHEN (NEW.cohead_shipchrg_id <= 0) THEN NULL ELSE NEW.cohead_shipchrg_id END, shiphead_freight=NEW.cohead_freight, shiphead_shipvia=NEW.cohead_shipvia WHERE ((shiphead_order_type='SO') AND (shiphead_order_id=NEW.cohead_id) AND (NOT shiphead_shipped)); END IF; END IF; IF (TG_OP = 'DELETE') THEN RETURN OLD; ELSE NEW.cohead_lastupdated = CURRENT_TIMESTAMP; RETURN NEW; END IF; END; $$; 'DROP FUNCTION public._soheadtrigger(); publicadminfalse46238125577905_soheadtriggerafter()FUNCTIONCREATE FUNCTION _soheadtriggerafter() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (COALESCE(NEW.cohead_taxzone_id,-1) <> COALESCE(OLD.cohead_taxzone_id,-1)) THEN UPDATE coitem SET coitem_taxtype_id=getItemTaxType(itemsite_item_id,NEW.cohead_taxzone_id) FROM itemsite WHERE ((itemsite_id=coitem_itemsite_id) AND (coitem_cohead_id=NEW.cohead_id)); END IF; -- update comments on any associated drop ship POs IF (COALESCE(NEW.cohead_shipcomments, TEXT('')) <> COALESCE(OLD.cohead_shipcomments, TEXT(''))) THEN UPDATE pohead SET pohead_comments=NEW.cohead_shipcomments FROM poitem JOIN coitem ON (coitem_cohead_id=NEW.cohead_id AND coitem_order_type='P' AND coitem_order_id=poitem_id) WHERE (pohead_id=poitem_pohead_id); END IF; RETURN NEW; END; $$; ,DROP FUNCTION public._soheadtriggerafter(); publicadminfalse84623125577906_soitemafterdeletetrigger()FUNCTIONCREATE FUNCTION _soitemafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF (OLD.coitem_status = 'O') THEN IF ( (SELECT (count(*) < 1) FROM coitem WHERE ((coitem_cohead_id=OLD.coitem_cohead_id) AND (coitem_id != OLD.coitem_id) AND (coitem_status = 'O')) ) ) THEN UPDATE cohead SET cohead_status = 'C' WHERE ((cohead_id=OLD.coitem_cohead_id) AND (cohead_status='O')); END IF; END IF; DELETE FROM charass WHERE charass_target_type = 'SI' AND charass_target_id = OLD.coitem_id; RETURN OLD; END; $$; 2DROP FUNCTION public._soitemafterdeletetrigger(); publicadminfalse84623125577907_soitemaftertrigger()FUNCTIONf(CREATE FUNCTION _soitemaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check NUMERIC; _r RECORD; _kit BOOLEAN; _fractional BOOLEAN; _rec RECORD; _kstat TEXT; _pstat TEXT; _result INTEGER; _coheadnumber TEXT; _coitemid INTEGER; _itemsrcid INTEGER; _orderid INTEGER; BEGIN _rec := NEW; --Cache some information SELECT * INTO _r FROM cohead WHERE (cohead_id=_rec.coitem_cohead_id); --Determine if this is a kit for later processing SELECT COALESCE(item_type,'')='K', item_fractional INTO _kit, _fractional FROM itemsite, item WHERE((itemsite_item_id=item_id) AND (itemsite_id=_rec.coitem_itemsite_id)); _kit := COALESCE(_kit, false); _fractional := COALESCE(_fractional, false); IF (_kit) THEN -- Kit Processing IF (TG_OP = 'INSERT') THEN -- Create Sub Lines for Kit Components PERFORM explodeKit(NEW.coitem_cohead_id, NEW.coitem_linenumber, 0, NEW.coitem_itemsite_id, NEW.coitem_qtyord, NEW.coitem_scheddate, NEW.coitem_promdate, NEW.coitem_memo); IF (fetchMetricBool('KitComponentInheritCOS')) THEN -- Update kit line item COS UPDATE coitem SET coitem_cos_accnt_id = CASE WHEN (COALESCE(NEW.coitem_cos_accnt_id, -1) != -1) THEN NEW.coitem_cos_accnt_id WHEN (NEW.coitem_warranty) THEN resolveCOWAccount(NEW.coitem_itemsite_id, _r.cohead_cust_id, _r.cohead_saletype_id, _r.cohead_shipzone_id) ELSE resolveCOSAccount(NEW.coitem_itemsite_id, _r.cohead_cust_id, _r.cohead_saletype_id, _r.cohead_shipzone_id) END WHERE((coitem_cohead_id=NEW.coitem_cohead_id) AND (coitem_linenumber = NEW.coitem_linenumber) AND (coitem_subnumber > 0)); END IF; END IF; IF (TG_OP = 'UPDATE') THEN IF (NEW.coitem_qtyord <> OLD.coitem_qtyord) THEN -- Recreate Sub Lines for Kit Components FOR _coitemid IN SELECT coitem_id FROM coitem WHERE ( (coitem_cohead_id=OLD.coitem_cohead_id) AND (coitem_linenumber=OLD.coitem_linenumber) AND (coitem_subnumber > 0) ) LOOP SELECT deleteSoItem(_coitemid) INTO _result; IF (_result < 0) THEN RAISE EXCEPTION 'Error deleting kit components: deleteSoItem(integer) Error:%', _result; END IF; END LOOP; PERFORM explodeKit(NEW.coitem_cohead_id, NEW.coitem_linenumber, 0, NEW.coitem_itemsite_id, NEW.coitem_qtyord, NEW.coitem_scheddate, NEW.coitem_promdate); END IF; IF ( (NEW.coitem_qtyord <> OLD.coitem_qtyord) OR (NEW.coitem_cos_accnt_id <> OLD.coitem_cos_accnt_id) ) THEN IF (fetchMetricBool('KitComponentInheritCOS')) THEN -- Update kit line item COS UPDATE coitem SET coitem_cos_accnt_id = CASE WHEN (COALESCE(NEW.coitem_cos_accnt_id, -1) != -1) THEN NEW.coitem_cos_accnt_id WHEN (NEW.coitem_warranty) THEN resolveCOWAccount(NEW.coitem_itemsite_id, _r.cohead_cust_id, _r.cohead_saletype_id, _r.cohead_shipzone_id) ELSE resolveCOSAccount(NEW.coitem_itemsite_id, _r.cohead_cust_id, _r.cohead_saletype_id, _r.cohead_shipzone_id) END WHERE((coitem_cohead_id=NEW.coitem_cohead_id) AND (coitem_linenumber = NEW.coitem_linenumber) AND (coitem_subnumber > 0)); END IF; END IF; IF (NEW.coitem_scheddate <> OLD.coitem_scheddate) THEN -- Update kit line item Schedule Date UPDATE coitem SET coitem_scheddate = NEW.coitem_scheddate WHERE((coitem_cohead_id=NEW.coitem_cohead_id) AND (coitem_linenumber = NEW.coitem_linenumber) AND (coitem_subnumber > 0)); END IF; END IF; END IF; IF (TG_OP = 'INSERT') THEN -- Create Purchase Request if flagged to do so IF ((NEW.coitem_order_type='R') AND (NEW.coitem_order_id=-1)) THEN SELECT cohead_number INTO _coheadnumber FROM cohead, itemsite WHERE (cohead_id=NEW.coitem_cohead_id) AND (itemsite_id=NEW.coitem_itemsite_id) AND (NOT itemsite_stocked); IF (FOUND) THEN SELECT createPR(CAST(_coheadnumber AS INTEGER), 'S', NEW.coitem_id) INTO _orderid; IF (_orderid > 0) THEN UPDATE coitem SET coitem_order_id=_orderid WHERE (coitem_id=NEW.coitem_id); ELSE RAISE EXCEPTION 'CreatePR failed, result=%', _orderid; END IF; END IF; END IF; -- Create Purchase Order if flagged to do so IF ((NEW.coitem_order_type='P') AND (NEW.coitem_order_id=-1)) THEN SELECT itemsrc_id INTO _itemsrcid FROM itemsite JOIN itemsrc ON (itemsrc_item_id=itemsite_item_id AND itemsrc_default) WHERE (itemsite_id=NEW.coitem_itemsite_id) AND (NOT itemsite_stocked); IF (FOUND) THEN SELECT createPurchaseToSale(NEW.coitem_id, _itemsrcid, itemsite_dropship, CASE WHEN (NEW.coitem_prcost=0.0) THEN NULL ELSE NEW.coitem_prcost END) INTO _orderid FROM itemsite WHERE (itemsite_id=NEW.coitem_itemsite_id); IF (_orderid > 0) THEN UPDATE coitem SET coitem_order_id=_orderid WHERE (coitem_id=NEW.coitem_id); ELSE RAISE EXCEPTION 'CreatePurchaseToSale failed, result=%', _orderid; END IF; END IF; END IF; -- Update Purchase Order comments IF (NEW.coitem_order_type='P') THEN UPDATE poitem SET poitem_comments=NEW.coitem_memo WHERE ((poitem_order_id=NEW.coitem_id) AND (poitem_order_type='S')); END IF; END IF; IF (TG_OP = 'UPDATE') THEN IF (NEW.coitem_order_type = 'P') THEN --If soitem is cancelled IF ((NEW.coitem_status = 'X') AND (OLD.coitem_status <> 'X')) THEN PERFORM postEvent('PoItemSoCancelled', 'P', poitem_id, itemsite_warehous_id, (pohead_number || '-' || poitem_linenumber || ':' || item_number), NULL, NULL, NULL, NULL) FROM poitem JOIN itemsite ON (itemsite_id=poitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) JOIN pohead ON (pohead_id=poitem_pohead_id) WHERE ( (poitem_id=OLD.coitem_order_id) AND (poitem_duedate <= (CURRENT_DATE + itemsite_eventfence)) ); --If soitem notes changed ELSIF (NEW.coitem_memo <> OLD.coitem_memo) THEN UPDATE poitem SET poitem_comments=NEW.coitem_memo WHERE ((poitem_order_id=NEW.coitem_id) AND (poitem_order_type='S')); END IF; END IF; END IF; IF (_rec.coitem_subnumber > 0) THEN SELECT coitem_status INTO _kstat FROM coitem WHERE((coitem_cohead_id=_rec.coitem_cohead_id) AND (coitem_linenumber=_rec.coitem_linenumber) AND (coitem_subnumber = 0)); IF ((SELECT count(*) FROM coitem WHERE((coitem_cohead_id=_rec.coitem_cohead_id) AND (coitem_linenumber=_rec.coitem_linenumber) AND (coitem_subnumber <> _rec.coitem_subnumber) AND (coitem_subnumber > 0) AND (coitem_status = 'O'))) > 0) THEN _pstat := 'O'; ELSE _pstat := _rec.coitem_status; END IF; END IF; IF(TG_OP = 'INSERT') THEN IF (_rec.coitem_subnumber > 0 AND _rec.coitem_status = 'O') THEN _pstat := 'O'; END IF; ELSIF (TG_OP = 'UPDATE') THEN IF (_rec.coitem_subnumber > 0 AND _rec.coitem_status = 'O') THEN _pstat := 'O'; END IF; IF ((NEW.coitem_status = 'C') AND (OLD.coitem_status <> 'C')) THEN IF(_kit) THEN UPDATE coitem SET coitem_status='C' WHERE((coitem_cohead_id=OLD.coitem_cohead_id) AND (coitem_linenumber=OLD.coitem_linenumber) AND (coitem_status='O') AND (coitem_subnumber > 0)); END IF; END IF; IF ((NEW.coitem_status = 'X') AND (OLD.coitem_status <> 'X')) THEN IF(_kit) THEN UPDATE coitem SET coitem_status='X' WHERE((coitem_cohead_id=OLD.coitem_cohead_id) AND (coitem_linenumber=OLD.coitem_linenumber) AND (coitem_status='O') AND (coitem_subnumber > 0)); END IF; END IF; IF(NEW.coitem_status = 'O' AND OLD.coitem_status <> 'O') THEN IF(_kit) THEN UPDATE coitem SET coitem_status='O' WHERE((coitem_cohead_id=OLD.coitem_cohead_id) AND (coitem_linenumber=OLD.coitem_linenumber) AND ((coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) > 0) AND (coitem_subnumber > 0)); END IF; END IF; END IF; IF ((_kstat IS NOT NULL) AND (_pstat IS NOT NULL) AND (_rec.coitem_subnumber > 0) AND (_kstat <> _pstat)) THEN UPDATE coitem SET coitem_status = _pstat WHERE((coitem_cohead_id=_rec.coitem_cohead_id) AND (coitem_linenumber=_rec.coitem_linenumber) AND (coitem_subnumber = 0)); END IF; --If auto calculate freight, recalculate cohead_freight IF (SELECT cohead_calcfreight FROM cohead WHERE (cohead_id=NEW.coitem_cohead_id)) THEN UPDATE cohead SET cohead_freight = COALESCE( (SELECT SUM(freightdata_total) FROM freightDetail('SO', cohead_id, cohead_cust_id, cohead_shipto_id, cohead_orderdate, cohead_shipvia, cohead_curr_id)), 0) WHERE cohead_id=NEW.coitem_cohead_id; END IF; RETURN NEW; END; $$; ,DROP FUNCTION public._soitemaftertrigger(); publicadminfalse46238125577909_soitembeforedeletetrigger()FUNCTION CREATE FUNCTION _soitembeforedeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; _kit BOOLEAN := FALSE; _shipped BOOLEAN := FALSE; _coitemid INTEGER := 0; _result INTEGER := 0; BEGIN -- Check Priv IF NOT (checkPrivilege('MaintainSalesOrders')) THEN RAISE EXCEPTION 'You do not have privileges to alter a Sales Order.'; END IF; -- Cache some information SELECT * INTO _r FROM cohead, itemsite, item WHERE ( (cohead_id=OLD.coitem_cohead_id) AND (itemsite_id=OLD.coitem_itemsite_id) AND (item_id=itemsite_item_id) ); _kit := (COALESCE(_r.item_type,'')='K'); -- Check for shipped kit components IF(_kit AND OLD.coitem_status <> 'C' AND OLD.coitem_status <> 'X') THEN IF (EXISTS (SELECT coitem_id FROM coitem JOIN shipitem ON (shipitem_orderitem_id=coitem_id) JOIN shiphead ON (shiphead_id=shipitem_shiphead_id AND shiphead_order_type='SO') WHERE ((coitem_cohead_id=OLD.coitem_cohead_id) AND (coitem_linenumber=OLD.coitem_linenumber) AND (coitem_subnumber > 0)) GROUP BY coitem_id HAVING (SUM(shipitem_qty) > 0) LIMIT 1) ) THEN _shipped := TRUE; END IF; END IF; IF(_kit AND _shipped) THEN RAISE EXCEPTION 'You can not delete this Sales Order Line as it has several sub components that have already been shipped.'; END IF; DELETE FROM comment WHERE ( (comment_source='SI') AND (comment_source_id=OLD.coitem_id) ); DELETE FROM charass WHERE ((charass_target_type='SI') AND (charass_target_id=OLD.coitem_id)); -- Delete Sub Lines for Kit Components IF (OLD.coitem_subnumber = 0) THEN FOR _coitemid IN SELECT coitem_id FROM coitem WHERE ( (coitem_cohead_id=OLD.coitem_cohead_id) AND (coitem_linenumber=OLD.coitem_linenumber) AND (coitem_subnumber > 0) ) LOOP SELECT deleteSoItem(_coitemid) INTO _result; IF (_result < 0) THEN IF NOT (_r.itemsite_createsopo AND (_result = -10 OR _result = -20)) THEN RAISE EXCEPTION 'Error deleting kit components: deleteSoItem(integer) Error:%', _result; END IF; END IF; END LOOP; END IF; IF (OLD.coitem_scheddate <= (CURRENT_DATE + _r.itemsite_eventfence)) THEN PERFORM postEvent('SoitemCancelled', 'S', OLD.coitem_id, _r.itemsite_warehous_id, (_r.cohead_number || '-' || OLD.coitem_linenumber), NULL, NULL, NULL, NULL); END IF; RETURN OLD; END; $$; 3DROP FUNCTION public._soitembeforedeletetrigger(); publicadminfalse46238125577910_soitembeforetrigger()FUNCTIONCREATE FUNCTION _soitembeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check NUMERIC; _itemNumber TEXT; _r RECORD; _kit BOOLEAN; BEGIN --Determine if this is a kit for later processing SELECT COALESCE(item_type,'')='K' INTO _kit FROM itemsite, item WHERE((itemsite_item_id=item_id) AND (itemsite_id=NEW.coitem_itemsite_id)); _kit := COALESCE(_kit, false); IF (TG_OP = 'INSERT') THEN -- If this is imported, go ahead and insert default characteristics IF (NEW.coitem_imported) THEN INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_price) SELECT 'SI', NEW.coitem_id, char_id, charass_value, itemcharprice(item_id,char_id,charass_value,cohead_cust_id,cohead_shipto_id,NEW.coitem_qtyord,cohead_curr_id,cohead_orderdate) FROM ( SELECT DISTINCT char_id, char_name, charass_value, item_id, cohead_cust_id, cohead_shipto_id, cohead_curr_id, cohead_orderdate FROM cohead, charass, char, itemsite, item WHERE((itemsite_id=NEW.coitem_itemsite_id) AND (itemsite_item_id=item_id) AND (charass_target_type='I') AND (charass_target_id=item_id) AND (charass_default) AND (char_id=charass_char_id) AND (cohead_id=NEW.coitem_cohead_id)) ORDER BY char_name) AS data; END IF; END IF; -- Create work order and process if flagged to do so IF ((NEW.coitem_order_type='W') AND (NEW.coitem_order_id=-1)) THEN SELECT createwo(CAST(cohead_number AS INTEGER), NEW.coitem_itemsite_id, 1, -- priority validateOrderQty(NEW.coitem_itemsite_id, NEW.coitem_qtyord, TRUE), itemsite_leadtime, NEW.coitem_scheddate, NEW.coitem_memo, 'S', NEW.coitem_id, cohead_prj_id) INTO NEW.coitem_order_id FROM cohead, itemsite WHERE ((cohead_id=NEW.coitem_cohead_id) AND (itemsite_id=NEW.coitem_itemsite_id)); INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value) SELECT 'W', NEW.coitem_order_id, charass_char_id, charass_value FROM charass WHERE ((charass_target_type='SI') AND (charass_target_id=NEW.coitem_id)); END IF; IF (TG_OP = 'UPDATE') THEN -- Update P/R date if applicable IF (NEW.coitem_scheddate <> OLD.coitem_scheddate AND NEW.coitem_order_type='R' AND NEW.coitem_order_id > 1) THEN UPDATE pr SET pr_duedate = NEW.coitem_scheddate WHERE (pr_order_id=NEW.coitem_id AND pr_order_type='S'); END IF; -- If closing or cancelling and there is a job item work order, then close job and distribute remaining costs IF ((NEW.coitem_status = 'C' AND OLD.coitem_status <> 'C') OR (NEW.coitem_status = 'X' AND OLD.coitem_status <> 'X')) AND (OLD.coitem_order_id > -1) THEN SELECT wo_id, wo_wipvalue INTO _r FROM wo,itemsite,item WHERE ((wo_ordtype='S') AND (wo_ordid=OLD.coitem_id) AND (itemsite_id=wo_itemsite_id) AND (item_id=itemsite_item_id) AND (itemsite_costmethod = 'J')); IF (FOUND) THEN IF (_r.wo_wipvalue > 0) THEN -- Distribute to G/L, debit Cost of Sales, credit WIP PERFORM MIN(insertGLTransaction( 'W/O', 'WO', formatWoNumber(NEW.coitem_order_id), 'Job Closed Incomplete', costcat_wip_accnt_id, CASE WHEN (COALESCE(NEW.coitem_cos_accnt_id, -1) != -1) THEN NEW.coitem_cos_accnt_id WHEN (NEW.coitem_warranty=TRUE) THEN resolveCOWAccount(itemsite_id, cohead_cust_id, cohead_saletype_id, cohead_shipzone_id) ELSE resolveCOSAccount(itemsite_id, cohead_cust_id, cohead_saletype_id, cohead_shipzone_id) END, -1, _r.wo_wipvalue, current_date )) FROM itemsite, costcat, cohead WHERE ((itemsite_id=NEW.coitem_itemsite_id) AND (itemsite_costcat_id=costcat_id) AND (cohead_id=NEW.coitem_cohead_id)); END IF; UPDATE wo SET wo_status = 'C', wo_wipvalue = 0 WHERE (wo_id = _r.wo_id); END IF; END IF; -- Likewise, reopen the job if line reopened IF ((NEW.coitem_status != 'C' AND OLD.coitem_status = 'C') OR (NEW.coitem_status != 'X' AND OLD.coitem_status = 'X')) AND (OLD.coitem_order_id > -1) THEN UPDATE wo SET wo_status = 'I' FROM itemsite, item WHERE ((wo_ordtype = 'S') AND (wo_ordid=NEW.coitem_id) AND (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (itemsite_costmethod='J')); END IF; -- Handle links to Return Authorization IF (fetchMetricBool('EnableReturnAuth')) THEN SELECT * INTO _r FROM raitem,rahead WHERE ((raitem_new_coitem_id=NEW.coitem_id) AND (rahead_id=raitem_rahead_id)); IF (FOUND) THEN IF ((_r.raitem_qtyauthorized <> NEW.coitem_qtyord OR _r.raitem_qty_uom_id <> NEW.coitem_qty_uom_id OR _r.raitem_qty_invuomratio <> NEW.coitem_qty_invuomratio OR _r.raitem_price_uom_id <> NEW.coitem_price_uom_id OR _r.raitem_price_invuomratio <> NEW.coitem_price_invuomratio) AND NOT (NEW.coitem_status = 'X' AND _r.raitem_qtyauthorized = 0)) THEN RAISE EXCEPTION 'Quantities for line item % may only be changed on the Return Authorization that created it.',NEW.coitem_linenumber; END IF; IF (OLD.coitem_warranty <> NEW.coitem_warranty) THEN UPDATE raitem SET raitem_warranty = NEW.coitem_warranty WHERE((raitem_new_coitem_id=NEW.coitem_id) AND (raitem_warranty != NEW.coitem_warranty)); END IF; IF (OLD.coitem_cos_accnt_id <> NEW.coitem_cos_accnt_id) THEN UPDATE raitem SET raitem_cos_accnt_id = NEW.coitem_cos_accnt_id WHERE((raitem_new_coitem_id=NEW.coitem_id) AND (COALESCE(raitem_cos_accnt_id,-1) != COALESCE(NEW.coitem_cos_accnt_id,-1))); END IF; IF (OLD.coitem_taxtype_id <> NEW.coitem_taxtype_id) THEN UPDATE raitem SET raitem_taxtype_id = NEW.coitem_taxtype_id WHERE((raitem_new_coitem_id=NEW.coitem_id) AND (COALESCE(raitem_taxtype_id,-1) != COALESCE(NEW.coitem_taxtype_id,-1))); END IF; IF (OLD.coitem_scheddate <> NEW.coitem_scheddate) THEN UPDATE raitem SET raitem_scheddate = NEW.coitem_scheddate WHERE((raitem_new_coitem_id=NEW.coitem_id) AND (raitem_scheddate != NEW.coitem_scheddate)); END IF; IF (OLD.coitem_memo <> NEW.coitem_memo) THEN UPDATE raitem SET raitem_notes = NEW.coitem_memo WHERE((raitem_new_coitem_id=NEW.coitem_id) AND (raitem_notes != NEW.coitem_memo)); END IF; IF ((OLD.coitem_qtyshipped <> NEW.coitem_qtyshipped) AND (NEW.coitem_qtyshipped >= _r.raitem_qtyauthorized) AND ((_r.raitem_disposition = 'S') OR (_r.raitem_status = 'O') AND (_r.raitem_disposition IN ('P','V')) AND (_r.raitem_qtyreceived >= _r.raitem_qtyauthorized))) THEN UPDATE raitem SET raitem_status = 'C' WHERE (raitem_new_coitem_id=NEW.coitem_id); END IF; END IF; END IF; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._soitembeforetrigger(); publicadminfalse46238125577912_soitemtrigger()FUNCTIOND!CREATE FUNCTION _soitemtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _changelog BOOLEAN := FALSE; _check BOOLEAN; _kit BOOLEAN; _shipped BOOLEAN; _atShipping NUMERIC; _tmp INTEGER; _rec RECORD; BEGIN -- Check SELECT checkPrivilege('MaintainSalesOrders') OR checkPrivilege('ShipOrders') OR checkPrivilege('IssueStockToShipping') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to alter a Sales Order.'; END IF; IF ( SELECT fetchMetricBool('SalesOrderChangeLog') ) THEN _changelog := TRUE; END IF; IF (TG_OP IN ('INSERT','UPDATE')) THEN IF (NEW.coitem_scheddate IS NULL) THEN IF (fetchmetricbool('AllowASAPShipSchedules')) THEN NEW.coitem_scheddate := current_date; ELSE RAISE EXCEPTION 'A schedule date is required.'; END IF; END IF; END IF; _rec := NEW; SELECT COALESCE(item_type,'')='K' INTO _kit FROM itemsite, item WHERE((itemsite_item_id=item_id) AND (itemsite_id=_rec.coitem_itemsite_id)); _kit := COALESCE(_kit, false); _shipped := false; IF(_kit AND _rec.coitem_status <> 'C' AND _rec.coitem_status <> 'X') THEN SELECT coitem_id INTO _tmp FROM coitem JOIN shipitem ON (shipitem_orderitem_id=coitem_id) JOIN shiphead ON (shiphead_id=shipitem_shiphead_id AND shiphead_order_type='SO') WHERE((coitem_cohead_id=_rec.coitem_cohead_id) AND (coitem_linenumber=_rec.coitem_linenumber) AND (coitem_subnumber > 0)) GROUP BY coitem_id HAVING (SUM(shipitem_qty) > 0) LIMIT 1; IF (FOUND) THEN _shipped := true; END IF; END IF; IF (TG_OP ='UPDATE') THEN IF ((OLD.coitem_status <> 'C') AND (NEW.coitem_status = 'C')) THEN SELECT qtyAtShipping(NEW.coitem_id) INTO _atShipping; IF (_atShipping > 0) THEN RAISE EXCEPTION 'Line % cannot be Closed at this time as there is inventory at shipping.',NEW.coitem_linenumber; END IF; END IF; END IF; IF (TG_OP = 'INSERT') THEN PERFORM postEvent('SoitemCreated', 'S', NEW.coitem_id, itemsite_warehous_id, (cohead_number || '-' || NEW.coitem_linenumber), NULL, NULL, NULL, NULL) FROM cohead, itemsite WHERE ( (cohead_id=NEW.coitem_cohead_id) AND (itemsite_id=NEW.coitem_itemsite_id) AND (NEW.coitem_scheddate <= (CURRENT_DATE + itemsite_eventfence)) ); IF (_changelog) THEN PERFORM postComment('ChangeLog', 'SI', NEW.coitem_id, 'Created'); END IF; --Set defaults if no values passed NEW.coitem_linenumber := COALESCE(NEW.coitem_linenumber, (SELECT (COALESCE(MAX(coitem_linenumber), 0) + 1) FROM coitem WHERE (coitem_cohead_id=NEW.coitem_cohead_id))); NEW.coitem_status := COALESCE(NEW.coitem_status,'O'); NEW.coitem_scheddate := COALESCE(NEW.coitem_scheddate, (SELECT MIN(coitem_scheddate) FROM coitem WHERE (coitem_cohead_id=NEW.coitem_cohead_id))); NEW.coitem_memo := COALESCE(NEW.coitem_memo,''); NEW.coitem_prcost := COALESCE(NEW.coitem_prcost,0); NEW.coitem_warranty := COALESCE(NEW.coitem_warranty,false); IF (NEW.coitem_status='O') THEN UPDATE cohead SET cohead_status = 'O' WHERE ((cohead_id=NEW.coitem_cohead_id) AND (cohead_status='C')); END IF; RETURN NEW; ELSIF (TG_OP = 'UPDATE') THEN IF (NEW.coitem_qtyord <> OLD.coitem_qtyord) THEN IF(_kit) THEN IF(_shipped) THEN RAISE EXCEPTION 'You can not change the qty ordered for a Kit item when one or more of its components have shipped inventory.'; END IF; END IF; PERFORM postEvent('SoitemQtyChanged', 'S', NEW.coitem_id, itemsite_warehous_id, (cohead_number || '-' || NEW.coitem_linenumber), NEW.coitem_qtyord, OLD.coitem_qtyord, NULL, NULL) FROM cohead, itemsite WHERE ( (cohead_id=NEW.coitem_cohead_id) AND (itemsite_id=NEW.coitem_itemsite_id) AND ( (NEW.coitem_scheddate <= (CURRENT_DATE + itemsite_eventfence)) OR (OLD.coitem_scheddate <= (CURRENT_DATE + itemsite_eventfence)) ) ); IF (_changelog) THEN PERFORM postComment( 'ChangeLog', 'SI', NEW.coitem_id, ( 'Changed Qty. Ordered from ' || formatQty(OLD.coitem_qtyord) || ' to ' || formatQty(NEW.coitem_qtyord) ) ); END IF; END IF; IF (NEW.coitem_price <> OLD.coitem_price) THEN IF (_changelog) THEN PERFORM postComment( 'ChangeLog', 'SI', NEW.coitem_id, ( 'Changed Unit Price from ' || formatPrice(OLD.coitem_price) || ' to ' || formatPrice(NEW.coitem_price) ) ); END IF; END IF; IF (NEW.coitem_scheddate <> OLD.coitem_scheddate) THEN PERFORM postEvent('SoitemSchedDateChanged', 'S', NEW.coitem_id, itemsite_warehous_id, (cohead_number || '-' || NEW.coitem_linenumber), NULL, NULL, NEW.coitem_scheddate, OLD.coitem_scheddate) FROM cohead, itemsite WHERE ( (cohead_id=NEW.coitem_cohead_id) AND (itemsite_id=NEW.coitem_itemsite_id) AND ( (NEW.coitem_scheddate <= (CURRENT_DATE + itemsite_eventfence)) OR (OLD.coitem_scheddate <= (CURRENT_DATE + itemsite_eventfence)) ) ); IF (_changelog) THEN PERFORM postComment( 'ChangeLog', 'SI', NEW.coitem_id, ( 'Changed Sched. Date from ' || formatDate(OLD.coitem_scheddate) || ' to ' || formatDate(NEW.coitem_scheddate)) ); END IF; END IF; IF ((NEW.coitem_status = 'C') AND (OLD.coitem_status <> 'C')) THEN NEW.coitem_closedate = CURRENT_TIMESTAMP; NEW.coitem_close_username = getEffectiveXtUser(); NEW.coitem_qtyreserved := 0; IF (_changelog) THEN PERFORM postComment('ChangeLog', 'SI', NEW.coitem_id, 'Closed'); END IF; END IF; IF ((NEW.coitem_status <> 'C') AND (OLD.coitem_status = 'C')) THEN NEW.coitem_closedate = NULL; NEW.coitem_close_username = NULL; IF (_changelog) THEN PERFORM postComment('ChangeLog', 'SI', NEW.coitem_id, 'Reopened'); END IF; END IF; IF ((NEW.coitem_status = 'X') AND (OLD.coitem_status <> 'X')) THEN IF ((OLD.coitem_order_type = 'W') AND (SELECT wo_status IN ('O', 'E', 'R') FROM wo WHERE (wo_id=OLD.coitem_order_id))) THEN -- Close any associated W/O PERFORM closeWo(OLD.coitem_order_id, FALSE, CURRENT_DATE); ELSIF (OLD.coitem_order_type = 'R') THEN -- Delete any associated P/R PERFORM deletePr(OLD.coitem_order_id); END IF; NEW.coitem_qtyreserved := 0; IF (_changelog) THEN PERFORM postComment('ChangeLog', 'SI', NEW.coitem_id, 'Canceled'); PERFORM postComment('ChangeLog', 'S', NEW.coitem_cohead_id, 'Line # '|| NEW.coitem_linenumber ||' Canceled'); END IF; PERFORM postEvent('SoitemCancelled', 'S', OLD.coitem_id, itemsite_warehous_id, (cohead_number || '-' || OLD.coitem_linenumber), NULL, NULL, NULL, NULL) FROM cohead, itemsite WHERE ( (cohead_id=OLD.coitem_cohead_id) AND (itemsite_id=OLD.coitem_itemsite_id) AND (OLD.coitem_scheddate <= (CURRENT_DATE + itemsite_eventfence)) ); END IF; IF ((NEW.coitem_qtyreserved <> OLD.coitem_qtyreserved) AND (_changelog)) THEN PERFORM postComment('ChangeLog', 'SI', NEW.coitem_id, 'Changed Qty Reserved to '|| NEW.coitem_qtyreserved); END IF; END IF; NEW.coitem_lastupdated = CURRENT_TIMESTAMP; -- Handle status for header IF (TG_OP = 'UPDATE') THEN IF (OLD.coitem_status <> NEW.coitem_status) THEN IF ( (SELECT (count(*) < 1) FROM coitem WHERE ((coitem_cohead_id=NEW.coitem_cohead_id) AND (coitem_id != NEW.coitem_id) AND (coitem_status='O')) ) AND (NEW.coitem_status<>'O') ) THEN UPDATE cohead SET cohead_status = 'C' WHERE ((cohead_id=NEW.coitem_cohead_id) AND (cohead_status='O')); ELSE UPDATE cohead SET cohead_status = 'O' WHERE ((cohead_id=NEW.coitem_cohead_id) AND (cohead_status='C')); END IF; END IF; END IF; RETURN NEW; END; $$; 'DROP FUNCTION public._soitemtrigger(); publicadminfalse462386 125587285_sourcebeforeupserttrigger()FUNCTIONCREATE FUNCTION _sourcebeforeupserttrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF TG_OP = 'INSERT' THEN NEW.source_created := CURRENT_TIMESTAMP; ELSE NEW.source_created := OLD.source_created; NEW.source_docass_num := COALESCE(NEW.source_docass_num, OLD.source_docass_num); END IF; IF COALESCE(NEW.source_module, '') = '' THEN NEW.source_module = 'System'; END IF; IF COALESCE(NEW.source_docass_num, 0) = 0 THEN /* 0 == Documents::Uninitialized */ SELECT max(source_docass_num) + 1 FROM source INTO NEW.source_docass_num; END IF; NEW.source_last_modified := CURRENT_TIMESTAMP; RETURN NEW; END; $$; 3DROP FUNCTION public._sourcebeforeupserttrigger(); publicadminfalse84623< 125577914_taxauthafterdeletetrigger()FUNCTION6CREATE FUNCTION _taxauthafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (EXISTS(SELECT 1 FROM checkhead WHERE checkhead_recip_id = OLD.taxauth_id AND checkhead_recip_type='T')) THEN RAISE EXCEPTION 'Cannot delete the tax authority % because checks have been written to it [xtuple: deleteTaxAuthority, -7, %]', OLD.taxauth_number, OLD.taxauth_number; END IF; IF (fetchMetricValue('DefaultTaxAuthority') = OLD.taxauth_id) THEN RAISE EXCEPTION 'Cannot delete the default Tax Authority [xtuple: deleteTaxAuthority, -8, %]', OLD.taxauth_code; END IF; IF (fetchMetricBool('TaxAuthChangeLog')) THEN PERFORM postComment(cmnttype_id, 'TAXAUTH', OLD.taxauth_id, 'Deleted "' || OLD.taxauth_number || '"') FROM cmnttype WHERE (cmnttype_name='ChangeLog'); END IF; RETURN OLD; END; $$; 3DROP FUNCTION public._taxauthafterdeletetrigger(); publicadminfalse46238: 125577915_taxauthaftertrigger()FUNCTIONCREATE FUNCTION _taxauthaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; BEGIN IF (TG_OP = 'INSERT') THEN -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE LOOP UPDATE crmacct SET crmacct_taxauth_id=NEW.taxauth_id, crmacct_name=NEW.taxauth_name WHERE crmacct_number=NEW.taxauth_code; IF (FOUND) THEN EXIT; END IF; BEGIN INSERT INTO crmacct(crmacct_number, crmacct_name, crmacct_active, crmacct_type, crmacct_taxauth_id ) VALUES (NEW.taxauth_code, NEW.taxauth_name, TRUE, 'O', NEW.taxauth_id); EXIT; EXCEPTION WHEN unique_violation THEN -- do nothing, and loop to try the UPDATE again END; END LOOP; /* TODO: default characteristic assignments based on what? */ ELSIF (TG_OP = 'UPDATE') THEN UPDATE crmacct SET crmacct_number = NEW.taxauth_code WHERE ((crmacct_taxauth_id=NEW.taxauth_id) AND (crmacct_number!=NEW.taxauth_code)); UPDATE crmacct SET crmacct_name = NEW.taxauth_name WHERE ((crmacct_taxauth_id=NEW.taxauth_id) AND (crmacct_name!=NEW.taxauth_name)); END IF; IF (fetchMetricBool('TaxAuthChangeLog')) THEN SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (_cmnttypeid IS NOT NULL) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.taxauth_code <> NEW.taxauth_code) THEN PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id, 'Code changed from "' || OLD.taxauth_code || '" to "' || NEW.taxauth_code || '"'); END IF; IF (OLD.taxauth_name <> NEW.taxauth_name) THEN PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id, 'Name changed from "' || OLD.taxauth_name || '" to "' || NEW.taxauth_name || '"'); END IF; IF (OLD.taxauth_extref <> NEW.taxauth_extref) THEN PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id, 'External Ref. changed from "' || OLD.taxauth_extref || '" to "' || NEW.taxauth_extref || '"'); END IF; IF (OLD.taxauth_addr_id <> NEW.taxauth_addr_id) THEN PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id, 'Address changed from ' || formatAddr(OLD.taxauth_addr_id) || ' to ' || formatAddr(NEW.taxauth_addr_id)); END IF; IF (OLD.taxauth_curr_id <> NEW.taxauth_curr_id) THEN PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id, 'Currency changed from "' || currConcat(OLD.taxauth_curr_id) || '" to "' || currConcat(NEW.taxauth_curr_id) || '"'); END IF; IF (OLD.taxauth_county <> NEW.taxauth_county) THEN PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id, 'County changed from "' || OLD.taxauth_county || '" to "' || NEW.taxauth_county || '"'); END IF; IF (OLD.taxauth_accnt_id <> NEW.taxauth_accnt_id) THEN PERFORM postComment(_cmnttypeid, 'TAXAUTH', NEW.taxauth_id, 'Account changed from "' || formatGLAccount(OLD.taxauth_accnt_id) || '" to "' || formatGLAccount(NEW.taxauth_accnt_id) || '"'); END IF; END IF; END IF; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._taxauthaftertrigger(); publicadminfalse46238; 125577916_taxauthbeforedeletetrigger()FUNCTIONCREATE FUNCTION _taxauthbeforedeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (NOT checkPrivilege('MaintainTaxAuthorities')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Tax Authorities.'; END IF; UPDATE crmacct SET crmacct_taxauth_id = NULL WHERE crmacct_taxauth_id = OLD.taxauth_id; RETURN OLD; END; $$; 4DROP FUNCTION public._taxauthbeforedeletetrigger(); publicadminfalse462389 125577917_taxauthbeforetrigger()FUNCTIONCREATE FUNCTION _taxauthbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (NOT checkPrivilege('MaintainTaxAuthorities')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Tax Authorities.'; END IF; IF (NEW.taxauth_code IS NULL) THEN RAISE EXCEPTION 'You must supply a Tax Authority Code.'; END IF; IF (TG_OP = 'INSERT' AND fetchMetricText('CRMAccountNumberGeneration') IN ('A','O')) THEN PERFORM clearNumberIssue('CRMAccountNumber', NEW.taxauth_code); END IF; NEW.taxauth_code := UPPER(NEW.taxauth_code); RETURN NEW; END; $$; .DROP FUNCTION public._taxauthbeforetrigger(); publicadminfalse84623= 125577918_termsafterdeletetrigger()FUNCTIONCREATE FUNCTION _termsafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (fetchMetricValue('DefaultTerms') = OLD.terms_id) THEN RAISE EXCEPTION 'Cannot delete the default Terms [xtuple: terms, -1, %]', OLD.terms_code; END IF; RETURN OLD; END; $$; 1DROP FUNCTION public._termsafterdeletetrigger(); publicadminfalse46238> 125577919_todoitemtrigger()FUNCTIONCREATE FUNCTION _todoitemtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _recurid INTEGER; _newparentid INTEGER; BEGIN IF (TG_OP = 'DELETE') THEN SELECT recur_id INTO _recurid FROM recur WHERE ((recur_parent_id=OLD.todoitem_id) AND (recur_parent_type='TODO')); IF (_recurid IS NOT NULL) THEN RAISE DEBUG 'recur_id for deleted todoitem = %', _recurid; SELECT todoitem_id INTO _newparentid FROM todoitem WHERE ((todoitem_recurring_todoitem_id=OLD.todoitem_id) AND (todoitem_id!=OLD.todoitem_id)) ORDER BY todoitem_due_date LIMIT 1; RAISE DEBUG '_newparentid for deleted todoitem = %', COALESCE(_newparentid, NULL); -- client is responsible for warning about deleting a recurring todoitem IF (_newparentid IS NULL) THEN DELETE FROM recur WHERE recur_id=_recurid; ELSE UPDATE recur SET recur_parent_id=_newparentid WHERE recur_id=_recurid; UPDATE todoitem SET todoitem_recurring_todoitem_id=_newparentid WHERE todoitem_recurring_todoitem_id=OLD.todoitem_id AND todoitem_id != OLD.todoitem_id; RAISE DEBUG 'reparented recurrence'; END IF; END IF; DELETE FROM alarm WHERE ((alarm_source='TODO') AND (alarm_source_id=OLD.todoitem_id)); DELETE FROM docass WHERE docass_source_id = OLD.todoitem_id AND docass_source_type = 'TODO'; DELETE FROM docass WHERE docass_target_id = OLD.todoitem_id AND docass_target_type = 'TODO'; RETURN OLD; END IF; RETURN NEW; END; $$; )DROP FUNCTION public._todoitemtrigger(); publicadminfalse46238? 125587295_trialbalaltertrigger()FUNCTIONCREATE FUNCTION _trialbalaltertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _accntid INTEGER[]; BEGIN IF (TG_OP='DELETE') THEN IF (SELECT period_closed FROM period WHERE period_id=OLD.trialbal_period_id) THEN RAISE EXCEPTION 'You may not delete Trial Balance Transactions in closed periods.'; END IF; RETURN OLD; END IF; IF (TG_OP='INSERT' OR TG_OP='UPDATE') THEN IF (coalesce(fetchMetricValue('GLCompanySize'),0) = 0) THEN -- Get the default account number for year end closing _accntid := fetchmetricvalue('YearEndEquityAccount'); ELSE -- Multi-company setup _accntid := (SELECT array_agg(company_yearend_accnt_id) FROM company); END IF; If (NEW.trialbal_accnt_id = ANY(_accntid) OR (NEW.trialbal_beginning = 0.00 AND NEW.trialbal_ending = 0.00)) THEN -- Dont check new accounts or Retained Earnings account ELSE IF (SELECT period_closed FROM period WHERE period_id=NEW.trialbal_period_id) THEN RAISE EXCEPTION 'You may not alter Trial Balance records in a closed Period.'; END IF; END IF; RETURN NEW; END IF; END; $$; .DROP FUNCTION public._trialbalaltertrigger(); publicadminfalse46238@ 125577920_uomconvupdate()FUNCTIONCREATE FUNCTION _uomconvupdate() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN UPDATE itemuomconv SET itemuomconv_to_value = NEW.uomconv_to_value, itemuomconv_from_value = NEW.uomconv_from_value, itemuomconv_fractional = NEW.uomconv_fractional WHERE((itemuomconv_from_uom_id = NEW.uomconv_from_uom_id) AND (itemuomconv_to_uom_id = NEW.uomconv_to_uom_id)); RETURN NEW; END; $$; 'DROP FUNCTION public._uomconvupdate(); publicadminfalse46238B 125577921_usrprefaftertrigger()FUNCTIONCREATE FUNCTION _usrprefaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE IF (NEW.usrpref_name='active') THEN LOOP UPDATE crmacct SET crmacct_usr_username=NEW.usrpref_username WHERE crmacct_number=UPPER(NEW.usrpref_username); IF (FOUND) THEN EXIT; END IF; BEGIN INSERT INTO crmacct(crmacct_number, crmacct_active, crmacct_type, crmacct_usr_username ) VALUES (NEW.usrpref_username, NEW.usrpref_value::BOOL, 'I', NEW.usrpref_username); EXIT; EXCEPTION WHEN unique_violation THEN -- do nothing, and loop to try the UPDATE again END; END LOOP; ELSIF (NEW.usrpref_name='propername') THEN LOOP UPDATE crmacct SET crmacct_name=NEW.usrpref_value WHERE crmacct_number=UPPER(NEW.usrpref_username); IF (FOUND) THEN EXIT; END IF; BEGIN INSERT INTO crmacct(crmacct_number, crmacct_active, crmacct_name, crmacct_type, crmacct_usr_username ) VALUES (UPPER(NEW.usrpref_username), TRUE, NEW.usrpref_value, 'I', NEW.usrpref_username); EXIT; EXCEPTION WHEN unique_violation THEN -- do nothing, and loop to try the UPDATE again END; END LOOP; END IF; ELSIF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._usrprefaftertrigger(); publicadminfalse46238A 125577922_usrprefbeforetrigger()FUNCTIONCREATE FUNCTION _usrprefbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF NOT (checkPrivilege('MaintainUsers') OR checkPrivilege('MaintainPreferencesOthers') OR (checkPrivilege('MaintainPreferencesSelf'))) THEN -- 2 IFs because plpgsql doesn't always evaluate boolean exprs left-to-right IF (TG_OP = 'DELETE') THEN IF NOT (OLD.usrpref_name LIKE '%/checked' OR OLD.usrpref_name LIKE '%/columnsShown') THEN RAISE EXCEPTION 'You do not have privileges to change this User Preference.'; END IF; ELSIF (NEW.usrpref_username = getEffectiveXtUser()) THEN IF NOT (NEW.usrpref_name LIKE '%/checked' OR NEW.usrpref_name LIKE '%/columnsShown') THEN RAISE EXCEPTION 'You do not have privileges to change this User Preference.'; END IF; END IF; END IF; IF (TG_OP IN ('INSERT', 'UPDATE')) THEN IF (NEW.usrpref_name = 'locale') THEN IF NOT EXISTS(SELECT locale_id FROM locale WHERE locale_id = NEW.usrpref_value::INTEGER) THEN RAISE EXCEPTION 'You must supply a valid Locale.'; END IF; ELSIF (NEW.usrpref_name IN ('agent', 'active')) THEN IF (NEW.usrpref_value NOT IN ('t', 'f')) THEN RAISE EXCEPTION '% must be either "t" or "f"', NEW.usrpref_name; END IF; END IF; ELSIF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; .DROP FUNCTION public._usrprefbeforetrigger(); publicadminfalse46238C 125577923_usrprivtrigger()FUNCTIONCREATE FUNCTION _usrprivtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF NOT checkPrivilege('MaintainUsers') THEN RAISE EXCEPTION '% does not have privileges to modify user privileges.', getEffectiveXtUser(); END IF; -- This looks like a candidate for a foreign key but isn't. -- fkeys don't work if the foreign key value resides in a child of the -- table and not the table itself. IF ((TG_OP = 'UPDATE' OR TG_OP = 'INSERT') AND (NOT EXISTS(SELECT priv_id FROM priv WHERE (priv_id=NEW.usrpriv_priv_id)))) THEN RAISE EXCEPTION 'Privilege id % does not exist or is part of a disabled package.', NEW.usrpriv_priv_id; RETURN OLD; ELSIF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; (DROP FUNCTION public._usrprivtrigger(); publicadminfalse46238H 125577924_vendaddrtrigger()FUNCTIONCREATE FUNCTION _vendaddrtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check BOOLEAN; _vendname TEXT; BEGIN -- Checks SELECT checkPrivilege('MaintainVendors') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to maintain Vendors.'; END IF; IF (TG_OP IN ('INSERT','UPDATE')) THEN IF (LENGTH(COALESCE(NEW.vendaddr_code, ''))=0) THEN RAISE EXCEPTION 'You must supply a valid Vendor Address Number.'; END IF; IF (LENGTH(COALESCE(NEW.vendaddr_name, ''))=0) THEN RAISE EXCEPTION 'You must supply a valid Vendor Address Name.'; END IF; IF (NEW.vendaddr_vend_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Vendor ID.'; END IF; SELECT vendaddr_code INTO _vendname FROM vendaddrinfo WHERE ( (vendaddr_vend_id=NEW.vendaddr_vend_id) AND (UPPER(vendaddr_code)=UPPER(NEW.vendaddr_code)) AND (vendaddr_id<>NEW.vendaddr_id) ); IF (FOUND) THEN RAISE EXCEPTION 'The Vendor Address Number entered cannot be used as it is in use.'; END IF; END IF; IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; RETURN NEW; END; $$; )DROP FUNCTION public._vendaddrtrigger(); publicadminfalse84623E 125577925_vendaftertrigger()FUNCTION CREATE FUNCTION _vendaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; BEGIN IF (TG_OP = 'INSERT') THEN -- http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-UPSERT-EXAMPLE LOOP UPDATE crmacct SET crmacct_vend_id=NEW.vend_id, crmacct_name=NEW.vend_name WHERE crmacct_number=NEW.vend_number; IF (FOUND) THEN EXIT; END IF; BEGIN INSERT INTO crmacct(crmacct_number, crmacct_name, crmacct_active, crmacct_type, crmacct_vend_id, crmacct_cntct_id_1, crmacct_cntct_id_2 ) VALUES (NEW.vend_number, NEW.vend_name, NEW.vend_active, 'O', NEW.vend_id, NEW.vend_cntct1_id, NEW.vend_cntct2_id); EXIT; EXCEPTION WHEN unique_violation THEN -- do nothing, and loop to try the UPDATE again END; END LOOP; /* TODO: default characteristic assignments based on vendgrp? */ ELSIF (TG_OP = 'UPDATE') THEN UPDATE crmacct SET crmacct_number = NEW.vend_number WHERE ((crmacct_vend_id=NEW.vend_id) AND (crmacct_number!=NEW.vend_number)); UPDATE crmacct SET crmacct_name = NEW.vend_name WHERE ((crmacct_vend_id=NEW.vend_id) AND (crmacct_name!=NEW.vend_name)); END IF; IF (fetchMetricBool('VendorChangeLog')) THEN SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (_cmnttypeid IS NOT NULL) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'V', NEW.vend_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.vend_number <> NEW.vend_number) THEN PERFORM postComment(_cmnttypeid, 'V', NEW.vend_id, ('Number Changed from "' || OLD.vend_number || '" to "' || NEW.vend_number || '"') ); END IF; IF (OLD.vend_name <> NEW.vend_name) THEN PERFORM postComment( _cmnttypeid, 'V', NEW.vend_id, ('Name Changed from "' || OLD.vend_name || '" to "' || NEW.vend_name || '"') ); END IF; IF (OLD.vend_active <> NEW.vend_active) THEN PERFORM postComment(_cmnttypeid, 'V', NEW.vend_id, CASE WHEN NEW.vend_active THEN 'Activated' ELSE 'Deactivated' END); END IF; END IF; END IF; END IF; RETURN NEW; END; $$; *DROP FUNCTION public._vendaftertrigger(); publicadminfalse46238G 125577926_vendinfoafterdeletetrigger()FUNCTIONCREATE FUNCTION _vendinfoafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF EXISTS(SELECT 1 FROM checkhead WHERE ((checkhead_recip_id=OLD.vend_id) AND (checkhead_recip_type='V'))) THEN RAISE EXCEPTION '[xtuple: deleteVendor, -7]'; END IF; DELETE FROM taxreg WHERE ((taxreg_rel_type='V') AND (taxreg_rel_id=OLD.vend_id)); IF (fetchMetricBool('VendorChangeLog')) THEN PERFORM postComment(cmnttype_id, 'V', OLD.vend_id, ('Deleted "' || OLD.vend_number || '"')) FROM cmnttype WHERE (cmnttype_name='ChangeLog'); END IF; DELETE FROM charass WHERE charass_target_type = 'V' AND charass_target_id = OLD.vend_id; RETURN OLD; END; $$; 4DROP FUNCTION public._vendinfoafterdeletetrigger(); publicadminfalse46238F 125577927_vendinfobeforedeletetrigger()FUNCTIONCREATE FUNCTION _vendinfobeforedeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF NOT (checkPrivilege('MaintainVendors')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Vendors.'; END IF; DELETE FROM itemsrcp WHERE itemsrcp_itemsrc_id IN (SELECT itemsrc_id FROM itemsrc WHERE itemsrc_vend_id=OLD.vend_id); DELETE FROM itemsrc WHERE (itemsrc_vend_id=OLD.vend_id); DELETE FROM vendaddrinfo WHERE (vendaddr_vend_id=OLD.vend_id); DELETE FROM docass WHERE docass_source_id = OLD.vend_id AND docass_source_type = 'V'; DELETE FROM docass WHERE docass_target_id = OLD.vend_id AND docass_target_type = 'V'; UPDATE crmacct SET crmacct_vend_id = NULL WHERE crmacct_vend_id = OLD.vend_id; RETURN OLD; END; $$; 5DROP FUNCTION public._vendinfobeforedeletetrigger(); publicadminfalse46238D 125577928_vendtrigger()FUNCTIONCREATE FUNCTION _vendtrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF NOT (checkPrivilege('MaintainVendors')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Vendors.'; END IF; IF (LENGTH(COALESCE(NEW.vend_number, ''))=0) THEN RAISE EXCEPTION 'You must supply a valid Vendor Number.'; END IF; IF (LENGTH(COALESCE(NEW.vend_name, ''))=0) THEN RAISE EXCEPTION 'You must supply a valid Vendor Name.'; END IF; IF (NEW.vend_vendtype_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Vendor Type ID.'; END IF; IF (NEW.vend_terms_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Terms Code ID.'; END IF; IF (TG_OP = 'INSERT' AND fetchMetricText('CRMAccountNumberGeneration') IN ('A','O')) THEN PERFORM clearNumberIssue('CRMAccountNumber', NEW.vend_number); END IF; NEW.vend_number := UPPER(NEW.vend_number); RETURN NEW; END; $$; %DROP FUNCTION public._vendtrigger(); publicadminfalse84623J 125577929_vodistaftertrigger()FUNCTIONCREATE FUNCTION _vodistaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; BEGIN IF ( (TG_OP = 'UPDATE') OR (TG_OP = 'DELETE') ) THEN IF (OLD.vodist_tax_id <> -1) THEN -- Delete any existing voheadtax adjustment records DELETE FROM voheadtax WHERE ( (taxhist_parent_id=OLD.vodist_vohead_id) AND (taxhist_tax_id=OLD.vodist_tax_id) AND (taxhist_taxtype_id=getAdjustmentTaxTypeId()) ); END IF; END IF; IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; -- Cache Voucher Head SELECT * INTO _r FROM vohead WHERE (vohead_id=NEW.vodist_vohead_id); IF (NOT FOUND) THEN RAISE EXCEPTION 'Voucher head not found'; END IF; IF (NEW.vodist_tax_id <> -1) THEN -- Insert adjustment voheadtax INSERT INTO voheadtax ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate ) VALUES ( NEW.vodist_vohead_id, getAdjustmentTaxTypeId(), NEW.vodist_tax_id, 0, NULL, 1, 0, 0, (NEW.vodist_amount * -1), _r.vohead_docdate ); END IF; RETURN NEW; END; $$; ,DROP FUNCTION public._vodistaftertrigger(); publicadminfalse46238I 125577930_vodistbeforetrigger()FUNCTIONbCREATE FUNCTION _vodistbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF (TG_OP = 'DELETE') THEN IF (OLD.vodist_tax_id <> -1) THEN -- Delete any existing voheadtax adjustment records DELETE FROM voheadtax WHERE ( (taxhist_parent_id=OLD.vodist_vohead_id) AND (taxhist_tax_id=OLD.vodist_tax_id) AND (taxhist_taxtype_id=getAdjustmentTaxTypeId()) ); END IF; RETURN OLD; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._vodistbeforetrigger(); publicadminfalse46238M 125587310_voheadafterdeletetrigger()FUNCTIONiCREATE FUNCTION _voheadafterdeletetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM charass WHERE charass_target_type = 'VCH' AND charass_target_id = OLD.vohead_id; RETURN OLD; END; $$; 2DROP FUNCTION public._voheadafterdeletetrigger(); publicadminfalse46238L 125577931_voheadaftertrigger()FUNCTIONCREATE FUNCTION _voheadaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (TG_OP = 'DELETE') THEN PERFORM releaseVoNumber(CAST(OLD.vohead_number AS INTEGER)); RETURN OLD; END IF; IF (TG_OP = 'INSERT') THEN PERFORM clearNumberIssue('VcNumber', NEW.vohead_number); RETURN NEW; END IF; IF (TG_OP = 'UPDATE') THEN IF ( (COALESCE(NEW.vohead_taxzone_id,-1) <> COALESCE(OLD.vohead_taxzone_id,-1)) OR (NEW.vohead_docdate <> OLD.vohead_docdate) OR (NEW.vohead_curr_id <> OLD.vohead_curr_id) ) THEN PERFORM calculateTaxHist( 'voitemtax', voitem_id, NEW.vohead_taxzone_id, voitem_taxtype_id, NEW.vohead_docdate, NEW.vohead_curr_id, (vodist_amount * -1) ) FROM voitem JOIN vodist ON ( (vodist_vohead_id=voitem_vohead_id) AND (vodist_poitem_id=voitem_poitem_id) ) WHERE (voitem_vohead_id = NEW.vohead_id); END IF; -- Touch any Misc Tax Distributions so voheadtax is recalculated IF (NEW.vohead_docdate <> OLD.vohead_docdate) THEN UPDATE vodist SET vodist_vohead_id=NEW.vohead_id WHERE ( (vodist_vohead_id=OLD.vohead_id) AND (vodist_tax_id <> -1) ); END IF; END IF; RETURN NEW; END; $$; ,DROP FUNCTION public._voheadaftertrigger(); publicadminfalse46238K 125577932_voheadbeforetrigger()FUNCTIONCREATE FUNCTION _voheadbeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _recurid INTEGER; _newparentid INTEGER; BEGIN IF (TG_OP = 'DELETE') THEN IF (OLD.vohead_posted) THEN -- Cannot delete a posted voucher RAISE EXCEPTION 'Cannot delete a posted voucher'; END IF; /* TODO: is setting recv_invoiced and poreject_invoiced to FALSE correct? this behavior is inherited from the now-defunct deleteVoucher. */ UPDATE recv SET recv_vohead_id = NULL, recv_voitem_id = NULL, recv_invoiced = FALSE WHERE recv_vohead_id = OLD.vohead_id; UPDATE poreject SET poreject_vohead_id = NULL, poreject_voitem_id = NULL, poreject_invoiced = FALSE WHERE poreject_vohead_id = OLD.vohead_id; DELETE FROM vodist WHERE vodist_vohead_id = OLD.vohead_id; DELETE FROM voheadtax WHERE taxhist_parent_id = OLD.vohead_id; DELETE FROM voitem WHERE voitem_vohead_id = OLD.vohead_id; SELECT recur_id INTO _recurid FROM recur WHERE ((recur_parent_id=OLD.vohead_id) AND (recur_parent_type='V')); IF (_recurid IS NOT NULL) THEN SELECT vohead_id INTO _newparentid FROM vohead WHERE ((vohead_recurring_vohead_id=OLD.vohead_id) AND (vohead_id!=OLD.vohead_id)) ORDER BY vohead_docdate LIMIT 1; IF (_newparentid IS NULL) THEN DELETE FROM recur WHERE recur_id=_recurid; ELSE UPDATE recur SET recur_parent_id=_newparentid WHERE recur_id=_recurid; UPDATE vohead SET vohead_recurring_vohead_id=_newparentid WHERE vohead_recurring_vohead_id=OLD.vohead_id AND vohead_id!=OLD.vohead_id; END IF; END IF; RETURN OLD; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._voheadbeforetrigger(); publicadminfalse46238O 125577933_voitemaftertrigger()FUNCTIONCREATE FUNCTION _voitemaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; BEGIN IF (TG_OP = 'DELETE') THEN RETURN OLD; END IF; -- Cache Voucher Head SELECT * INTO _r FROM vohead WHERE (vohead_id=NEW.voitem_vohead_id); IF (NOT FOUND) THEN RAISE EXCEPTION 'Voucher head not found'; END IF; -- Calculate Tax PERFORM calculateTaxHist( 'voitemtax', NEW.voitem_id, COALESCE(_r.vohead_taxzone_id, -1), NEW.voitem_taxtype_id, COALESCE(_r.vohead_docdate, CURRENT_DATE), COALESCE(_r.vohead_curr_id, -1), COALESCE(SUM(vodist_amount * -1), 0) ) FROM vodist WHERE ( (vodist_vohead_id=_r.vohead_id) AND (vodist_poitem_id=NEW.voitem_poitem_id) ); RETURN NEW; END; $$; ,DROP FUNCTION public._voitemaftertrigger(); publicadminfalse46238N 125577934_voitembeforetrigger()FUNCTION|CREATE FUNCTION _voitembeforetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF (TG_OP = 'DELETE') THEN DELETE FROM voitemtax WHERE (taxhist_parent_id=OLD.voitem_id); RETURN OLD; END IF; RETURN NEW; END; $$; -DROP FUNCTION public._voitembeforetrigger(); publicadminfalse84623Q 125577935_warehoustrigger()FUNCTION3 CREATE FUNCTION _warehoustrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; _check BOOLEAN; _checkId INTEGER; BEGIN -- Checks -- Start with privileges IF (TG_OP = 'INSERT') THEN SELECT checkPrivilege('MaintainWarehouses') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to add new Sites.'; END IF; ELSE SELECT checkPrivilege('MaintainWarehouses') OR checkPrivilege('IssueCountTags') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to alter a Site.'; END IF; END IF; -- Code is required IF (LENGTH(COALESCE(NEW.warehous_code,''))=0) THEN RAISE EXCEPTION 'You must supply a valid Site Code.'; END IF; -- Sitetype is required IF (NEW.warehous_sitetype_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Site Type.'; END IF; -- Cost Category is required for Transit types IF ((NEW.warehous_transit) AND (NEW.warehous_costcat_id IS NULL)) THEN RAISE EXCEPTION 'You must supply a valid Cost Category for Transit Sites.'; END IF; -- Code must be unique SELECT warehous_id INTO _checkId FROM whsinfo WHERE ( (UPPER(warehous_code)=UPPER(NEW.warehous_code)) AND (warehous_id<>NEW.warehous_id) ); IF (FOUND) THEN RAISE EXCEPTION 'You must supply a unique Site Code.'; END IF; -- Count Tag Prefix must be unique IF (TG_OP = 'INSERT') THEN SELECT warehous_id INTO _checkId FROM whsinfo WHERE (warehous_counttag_prefix=NEW.warehous_counttag_prefix); ELSE SELECT warehous_id INTO _checkId FROM whsinfo WHERE ( (warehous_counttag_prefix=NEW.warehous_counttag_prefix) AND (warehous_id<>NEW.warehous_id) ); END IF; IF (FOUND) THEN RAISE EXCEPTION 'You must supply a unique Count Tag Prefix.'; END IF; -- Check Complete -- Change Log IF ( SELECT (metric_value='t') FROM metric WHERE (metric_name='WarehouseChangeLog') ) THEN -- Cache the cmnttype_id for ChangeLog SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name='ChangeLog'); IF (FOUND) THEN IF (TG_OP = 'INSERT') THEN PERFORM postComment(_cmnttypeid, 'WH', NEW.warehous_id, 'Created'); ELSIF (TG_OP = 'UPDATE') THEN IF (OLD.warehous_code <> NEW.warehous_code) THEN PERFORM postComment( _cmnttypeid, 'WH', NEW.warehous_id, ('Code Changed from "' || OLD.warehous_code || '" to "' || NEW.warehous_code || '"') ); END IF; IF (OLD.warehous_descrip <> NEW.warehous_descrip) THEN PERFORM postComment( _cmnttypeid, 'WH', NEW.warehous_id, ( 'Description Changed from "' || OLD.warehous_descrip || '" to "' || NEW.warehous_descrip || '"' ) ); END IF; IF (OLD.warehous_active <> NEW.warehous_active) THEN IF (NEW.warehous_active) THEN PERFORM postComment(_cmnttypeid, 'WH', NEW.warehous_id, 'Activated'); ELSE PERFORM postComment(_cmnttypeid, 'WH', NEW.warehous_id, 'Deactivated'); END IF; END IF; END IF; END IF; END IF; RETURN NEW; END; $$; )DROP FUNCTION public._warehoustrigger(); publicadminfalse84623P 125577936_whsezonetrigger()FUNCTIONCREATE FUNCTION _whsezonetrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _check BOOLEAN; _checkId INTEGER; BEGIN -- Checks -- Start with privileges IF (TG_OP = 'INSERT') THEN SELECT checkPrivilege('MaintainWarehouses') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to add new Site Zones.'; END IF; ELSE SELECT checkPrivilege('MaintainWarehouses') INTO _check; IF NOT (_check) THEN RAISE EXCEPTION 'You do not have privileges to alter a Site Zone.'; END IF; END IF; -- Name is required IF (LENGTH(COALESCE(NEW.whsezone_name,''))=0) THEN RAISE EXCEPTION 'You must supply a valid Site Zone Name.'; END IF; -- Site is required IF (NEW.whsezone_warehous_id IS NULL) THEN RAISE EXCEPTION 'You must supply a valid Site.'; END IF; RETURN NEW; END; $$; )DROP FUNCTION public._whsezonetrigger(); publicadminfalse46238S 125577937_womatlaftertrigger()FUNCTIONCREATE FUNCTION _womatlaftertrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF (TG_OP = 'INSERT') THEN -- Create any required P/R's PERFORM createPr('W', NEW.womatl_id) FROM itemsite WHERE ((itemsite_id=NEW.womatl_itemsite_id) AND (itemsite_createpr)); END IF; RETURN NEW; END; $$; ,DROP FUNCTION public._womatlaftertrigger(); publicadminfalse84623R 125577938 _wotrigger()FUNCTIONCREATE FUNCTION _wotrigger() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF (TG_OP = 'INSERT') THEN PERFORM postEvent('WoCreated', 'W', NEW.wo_id, itemsite_warehous_id, (NEW.wo_number || '-' || NEW.wo_subnumber), NULL, NULL, NULL, NULL) FROM itemsite WHERE (itemsite_id=NEW.wo_itemsite_id) AND (NEW.wo_duedate <= (CURRENT_DATE + itemsite_eventfence)); PERFORM postComment('ChangeLog', 'W', NEW.wo_id, 'Created'); IF (fetchMetricText('WONumberGeneration') IN ('A','O')) THEN --- clear the number from the issue cache PERFORM clearNumberIssue('WoNumber', NEW.wo_number); END IF; RETURN NEW; ELSE IF (TG_OP = 'DELETE') THEN PERFORM postEvent('WoCancelled', 'W', OLD.wo_id, itemsite_warehous_id, (OLD.wo_number || '-' || OLD.wo_subnumber), NULL, NULL, NULL, NULL) FROM itemsite WHERE (itemsite_id=OLD.wo_itemsite_id) AND (OLD.wo_duedate <= (CURRENT_DATE + itemsite_eventfence)); DELETE FROM docass WHERE docass_source_id = OLD.wo_id AND docass_source_type = 'W'; DELETE FROM docass WHERE docass_target_id = OLD.wo_id AND docass_target_type = 'W'; DELETE FROM comment WHERE ( (comment_source='W') AND (comment_source_id=OLD.wo_id) ); DELETE FROM charass WHERE ((charass_target_type='W') AND (charass_target_id=OLD.wo_id)); RETURN OLD; ELSE IF (TG_OP = 'UPDATE') THEN IF (NEW.wo_qtyord <> OLD.wo_qtyord) THEN PERFORM postEvent('WoQtyChanged', 'W', NEW.wo_id, itemsite_warehous_id, (NEW.wo_number || '-' || NEW.wo_subnumber), NEW.wo_qtyord, OLD.wo_qtyord, NULL, NULL) FROM itemsite WHERE (itemsite_id=NEW.wo_itemsite_id) AND ( (NEW.wo_duedate <= (CURRENT_DATE + itemsite_eventfence)) OR (OLD.wo_duedate <= (CURRENT_DATE + itemsite_eventfence)) ); PERFORM postComment( 'ChangeLog', 'W', NEW.wo_id, ( 'Qty. Ordered Changed from ' || formatQty(OLD.wo_qtyord) || ' to ' || formatQty(NEW.wo_qtyord ) ) ); END IF; IF (NEW.wo_duedate <> OLD.wo_duedate) THEN PERFORM postEvent('WoDueDateChanged', 'W', NEW.wo_id, itemsite_warehous_id, (NEW.wo_number || '-' || NEW.wo_subnumber), NULL, NULL, NEW.wo_duedate, OLD.wo_duedate) FROM itemsite WHERE (itemsite_id=NEW.wo_itemsite_id) AND ( (NEW.wo_duedate <= (CURRENT_DATE + itemsite_eventfence)) OR (OLD.wo_duedate <= (CURRENT_DATE + itemsite_eventfence)) ); PERFORM postComment( 'ChangeLog', 'W', NEW.wo_id, ( 'Due Date Changed from ' || formatDate(OLD.wo_duedate) || ' to ' || formatDate(NEW.wo_duedate ) ) ); END IF; IF (NEW.wo_status <> OLD.wo_status) THEN PERFORM postComment( 'ChangeLog', 'W', NEW.wo_id, ('Status Changed from ' || OLD.wo_status || ' to ' || NEW.wo_status) ); END IF; END IF; END IF; END IF; IF (TG_OP = 'UPDATE') THEN IF (NEW.wo_prj_id <> OLD.wo_prj_id) THEN UPDATE wo SET wo_prj_id=NEW.wo_prj_id WHERE (wo_ordtype='W') AND (wo_ordid=NEW.wo_id); END IF; END IF; RETURN NEW; END; $$; #DROP FUNCTION public._wotrigger(); publicadminfalse46238125577939acknowledgemessage(integer)FUNCTIONCREATE FUNCTION acknowledgemessage(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pMsgid ALIAS FOR $1; BEGIN UPDATE msguser SET msguser_viewed=CURRENT_TIMESTAMP WHERE ( (msguser_msg_id=pMsgid) AND (msguser_username=getEffectiveXtUser()) ); RETURN TRUE; END; $_$; 2DROP FUNCTION public.acknowledgemessage(integer); publicadminfalse46238125577940actcost(integer)FUNCTION CREATE FUNCTION actcost(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN actCost($1, NULL, baseCurrId()); END; $_$; 'DROP FUNCTION public.actcost(integer); publicadminfalse84623125577941actcost(integer, integer)FUNCTIONCREATE FUNCTION actcost(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN actCost($1, $2, baseCurrId()); END; $_$; 0DROP FUNCTION public.actcost(integer, integer); publicadminfalse84623125577942"actcost(integer, integer, integer)FUNCTIONCREATE FUNCTION actcost(integer, integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pBomitemid ALIAS FOR $2; pCurrid ALIAS FOR $3; _cost NUMERIC; BEGIN -- Return actual cost in the given currency at the current conversion rate SELECT SUM(CASE WHEN (bomitemcost_id IS NOT NULL) THEN ROUND(currToCurr(bomitemcost_curr_id, pCurrid, bomitemcost_actcost, CURRENT_DATE), 6) ELSE ROUND(currToCurr(itemcost_curr_id, pCurrid, itemcost_actcost, CURRENT_DATE), 6) END) INTO _cost FROM itemcost LEFT OUTER JOIN bomitemcost ON (bomitemcost_bomitem_id=pBomitemid AND bomitemcost_costelem_id=itemcost_costelem_id) WHERE (itemcost_item_id=pItemid); IF (_cost IS NULL) THEN RETURN 0; ELSE RETURN _cost; END IF; END; $_$; 9DROP FUNCTION public.actcost(integer, integer, integer); publicadminfalse84623125577943addrusecount(integer)FUNCTIONCREATE FUNCTION addrusecount(integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAddrId ALIAS FOR $1; _fk RECORD; _r RECORD; _seq INTEGER; _col TEXT; _qry TEXT; _count INTEGER = 0; BEGIN -- Determine where this address is used by analyzing foreign key linkages -- TO DO: Can this be rationalized with cntctused(int)? FOR _fk IN SELECT pg_namespace.nspname AS schemaname, con.relname AS tablename, conkey AS seq, conrelid AS class_id FROM pg_constraint, pg_class f, pg_class con, pg_namespace WHERE confrelid=f.oid AND conrelid=con.oid AND f.relname = 'addr' AND con.relnamespace=pg_namespace.oid AND con.relname NOT IN ('pohead') -- exception(s) where address key doesn't actually drive document information LOOP -- Validate IF (ARRAY_UPPER(_fk.seq,1) > 1) THEN RAISE EXCEPTION 'Checks to tables where the address is one of multiple foreign key columns is not supported. Error on Table: %', pg_namespace.nspname || '.' || con.relname; END IF; _seq := _fk.seq[1]; -- Get the specific column name SELECT attname INTO _col FROM pg_attribute, pg_class WHERE ((attrelid=pg_class.oid) AND (pg_class.oid=_fk.class_id) AND (attnum=_seq)); -- See if there are dependencies _qry := 'SELECT * FROM ' || _fk.schemaname || '.' || _fk.tablename || ' WHERE ('|| _col || '=' || pAddrId || ');'; FOR _r IN EXECUTE _qry LOOP _count := _count + 1; END LOOP; END LOOP; RETURN _count; END; $_$; ,DROP FUNCTION public.addrusecount(integer); publicadminfalse84623125577944Uaddtaxtoglseries(integer, text, text, text, integer, date, date, text, integer, text)FUNCTIONCREATE FUNCTION addtaxtoglseries(integer, text, text, text, integer, date, date, text, integer, text) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; pSource ALIAS FOR $2; pDocType ALIAS FOR $3; pDocNumber ALIAS FOR $4; pCurrId ALIAS FOR $5; pExchDate ALIAS FOR $6; pDistDate ALIAS FOR $7; pTableName ALIAS FOR $8; pParentId ALIAS FOR $9; pNotes ALIAS FOR $10; _count INTEGER := 0; _baseTax NUMERIC := 0; _returnVal NUMERIC := 0; _t RECORD; _test INTEGER := 0; BEGIN -- This is just a fancy select statement on taxhist. -- Because all tax records tables inherit from taxhist, -- we can use the same select statement for all. -- https://www.postgresql.org/docs/8.1/static/ddl-inherit.html -- pTableName in the where clause narrows down the selection -- to the correct sub table. FOR _t IN SELECT * FROM taxhist JOIN tax ON (tax_id = taxhist_tax_id) JOIN pg_class ON (pg_class.oid = taxhist.tableoid) WHERE ( (taxhist_parent_id = pParentId) AND (relname = pTableName) ) LOOP _count := _count + 1; _baseTax := currToBase(pCurrId, _t.taxhist_tax, pExchDate); _returnVal := _returnVal + _baseTax; PERFORM insertIntoGLSeries( pSequence, pSource, pDocType, pDocNumber, _t.tax_sales_accnt_id, _baseTax, pDistDate, pNotes ); UPDATE taxhist SET taxhist_docdate=pExchDate, taxhist_distdate=pDistDate, taxhist_curr_id=pCurrId, taxhist_curr_rate=curr_rate FROM curr_rate WHERE ((taxhist_id=_t.taxhist_id) AND (pCurrId=curr_id) AND ( pExchDate BETWEEN curr_effective AND curr_expires) ); END LOOP; RETURN _returnVal; END; $_$; lDROP FUNCTION public.addtaxtoglseries(integer, text, text, text, integer, date, date, text, integer, text); publicadminfalse46238125577945addtopackinglistbatch(integer)FUNCTIONCREATE FUNCTION addtopackinglistbatch(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; returnVal INTEGER; BEGIN -- MIN because error codes are negative SELECT MIN(addToPackingListBatch('SO', pSoheadid, shiphead_id)) INTO returnVal FROM shiphead WHERE ((shiphead_order_id=pSoheadid) AND (NOT shiphead_shipped) AND (shiphead_order_type='SO')); IF (NOT FOUND OR returnVal IS NULL) THEN returnVal := addToPackingListBatch('SO', pSoheadid, NULL); END IF; RETURN returnVal; END; $_$; 5DROP FUNCTION public.addtopackinglistbatch(integer); publicadminfalse84623125577946'addtopackinglistbatch(integer, integer)FUNCTION&CREATE FUNCTION addtopackinglistbatch(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN addToPackingListBatch('SO', $1, $2); END; $_$; >DROP FUNCTION public.addtopackinglistbatch(integer, integer); publicadminfalse46238125577947$addtopackinglistbatch(text, integer)FUNCTIONCREATE FUNCTION addtopackinglistbatch(text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pheadtype ALIAS FOR $1; pheadid ALIAS FOR $2; returnVal INTEGER; BEGIN -- MIN because error codes are negative SELECT MIN(addToPackingListBatch(pheadtype, pheadid, shiphead_id)) INTO returnVal FROM shiphead WHERE ((shiphead_order_id=pheadid) AND (NOT shiphead_shipped) AND (shiphead_order_type=pheadtype)); IF (NOT FOUND OR returnVal IS NULL) THEN returnVal := addToPackingListBatch(pheadtype, pheadid, NULL); END IF; RETURN returnVal; END; $_$; ;DROP FUNCTION public.addtopackinglistbatch(text, integer); publicadminfalse46238125577948-addtopackinglistbatch(text, integer, integer)FUNCTIONCREATE FUNCTION addtopackinglistbatch(text, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pheadtype ALIAS FOR $1; pheadid ALIAS FOR $2; pshipheadid ALIAS FOR $3; _check INTEGER; BEGIN SELECT pack_id INTO _check FROM pack WHERE ((pack_head_id=pheadid) AND ((pack_shiphead_id=pshipheadid) OR (pshipheadid IS NULL AND pack_shiphead_id IS NULL)) AND (pack_head_type=pheadtype) ); IF (NOT FOUND) THEN INSERT INTO pack ( pack_head_type, pack_head_id, pack_shiphead_id, pack_printed ) VALUES ( pheadtype, pheadid, pshipheadid, FALSE ); -- Auto Firm Sales Orders conditionally based on metric IF ( (pheadtype = 'SO') AND (fetchMetricBool('FirmSalesOrderPackingList')) ) THEN UPDATE coitem SET coitem_firm=TRUE WHERE (coitem_cohead_id=pheadid); END IF; END IF; RETURN pheadid; END; $_$; DDROP FUNCTION public.addtopackinglistbatch(text, integer, integer); publicadminfalse46238125577949-addtopackinglistbatch(integer, text, integer)FUNCTIONCREATE FUNCTION addtopackinglistbatch(integer, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pwarehousid ALIAS FOR $1; pheadtype ALIAS FOR $2; pheadid ALIAS FOR $3; returnVal INTEGER; BEGIN -- MIN because error codes are negative SELECT MIN(addToPackingListBatch(pheadtype, pheadid, getOpenShipmentId(pheadtype, pheadid, pwarehousid))) INTO returnVal; IF (NOT FOUND OR returnVal IS NULL) THEN returnVal := addToPackingListBatch(pheadtype, pheadid, NULL); END IF; RETURN returnVal; END; $_$; DDROP FUNCTION public.addtopackinglistbatch(integer, text, integer); publicadminfalse84623125577950)adjustinvvalue(integer, numeric, integer)FUNCTION\CREATE FUNCTION adjustinvvalue(integer, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pNewValue ALIAS FOR $2; pAccountid ALIAS FOR $3; _delta NUMERIC; _glreturn INTEGER; _invhistid INTEGER; _itemlocSeries INTEGER; BEGIN SELECT pNewValue - itemsite_value INTO _delta FROM itemsite WHERE (itemsite_id=pItemsiteid) FOR UPDATE; IF (NOT FOUND) THEN RETURN -1; END IF; SELECT insertGLTransaction('I/M', '', 'Post Value', 'Inventory Value Adjustment for ' || item_number, COALESCE (pAccountid, costcat_adjustment_accnt_id), costcat_asset_accnt_id, -1, _delta, CURRENT_DATE) INTO _glreturn FROM itemsite JOIN costcat ON (itemsite_costcat_id=costcat_id) JOIN item ON (itemsite_item_id=item_id) WHERE (itemsite_id=pItemsiteid); -- Create the AD transaction INSERT INTO invhist ( invhist_itemsite_id, invhist_transdate, invhist_transtype, invhist_invqty, invhist_qoh_before, invhist_qoh_after, invhist_docnumber, invhist_comments, invhist_invuom, invhist_unitcost, invhist_hasdetail, invhist_costmethod, invhist_value_before, invhist_value_after, invhist_series ) SELECT itemsite_id, CURRENT_TIMESTAMP, 'AD', 0.0, itemsite_qtyonhand, itemsite_qtyonhand, '', 'Inventory Value Adjustment', uom_name, _delta, FALSE, itemsite_costmethod, itemsite_value, pNewValue, 0 FROM itemsite, item, uom WHERE ( (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (itemsite_id=pItemsiteid) ); UPDATE itemsite SET itemsite_value=pNewValue WHERE (itemsite_id=pItemsiteid); RETURN 0; END; $_$; @DROP FUNCTION public.adjustinvvalue(integer, numeric, integer); publicadminfalse46238125577951adjustments(text)FUNCTIONbCREATE FUNCTION adjustments(text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTransType ALIAS FOR $1; BEGIN IF (pTransType IN ('CC', 'AD')) THEN RETURN TRUE; ELSE RETURN FALSE; END IF; END; $_$; (DROP FUNCTION public.adjustments(text); publicadminfalse84623125577952allocatedforso(integer, date)FUNCTIONnCREATE FUNCTION allocatedforso(integer, date) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pDate ALIAS FOR $2; BEGIN RETURN allocatedForSo(pItemsiteid, startOfTime(), pDate); END; $_$; 4DROP FUNCTION public.allocatedforso(integer, date); publicadminfalse84623125577953 allocatedforso(integer, integer)FUNCTIONCREATE FUNCTION allocatedforso(integer, integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pDate ALIAS FOR $2; BEGIN RETURN allocatedForSo(pItemsiteid, startOfTime(), (CURRENT_DATE + pDate)); END; $_$; 7DROP FUNCTION public.allocatedforso(integer, integer); publicadminfalse84623125577954#allocatedforso(integer, date, date)FUNCTION CREATE FUNCTION allocatedforso(integer, date, date) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _qty NUMERIC; BEGIN SELECT COALESCE(SUM(noNeg(itemuomtouom(itemsite_item_id, coitem_qty_uom_id, NULL, coitem_qtyord - (coitem_qtyshipped + qtyAtShipping(coitem_id)) + coitem_qtyreturned))), 0.0) INTO _qty FROM coitem, itemsite, item WHERE ( (coitem_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (coitem_status='O') AND (coitem_itemsite_id=pItemsiteid) AND (coitem_scheddate BETWEEN pStartDate AND pEndDate) ); RETURN _qty; END; $_$; :DROP FUNCTION public.allocatedforso(integer, date, date); publicadminfalse84623125577955allocatedforwo(integer, date)FUNCTIONnCREATE FUNCTION allocatedforwo(integer, date) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pDate ALIAS FOR $2; BEGIN RETURN allocatedForWo(pItemsiteid, startOfTime(), pDate); END; $_$; 4DROP FUNCTION public.allocatedforwo(integer, date); publicadminfalse84623125577956 allocatedforwo(integer, integer)FUNCTIONCREATE FUNCTION allocatedforwo(integer, integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pLookAheadDays ALIAS FOR $2; BEGIN RETURN allocatedForWo(pItemsiteid, startOfTime(), (CURRENT_DATE + pLookaheadDays)); END; $_$; 7DROP FUNCTION public.allocatedforwo(integer, integer); publicadminfalse84623125577957#allocatedforwo(integer, date, date)FUNCTION,CREATE FUNCTION allocatedforwo(integer, date, date) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _itemtype TEXT; _qty NUMERIC; BEGIN SELECT item_type INTO _itemtype FROM itemsite JOIN item ON (item_id=itemsite_item_id) WHERE (itemsite_id=pItemsiteid); IF (_itemtype != 'T') THEN SELECT COALESCE(SUM(noNeg(itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq - womatl_qtyiss))), 0.0) INTO _qty FROM womatl JOIN wo ON (wo_id=womatl_wo_id AND wo_status IN ('E','I','R')) JOIN itemsite ON (itemsite_id=womatl_itemsite_id) WHERE (womatl_itemsite_id=pItemsiteid) AND (womatl_duedate BETWEEN pStartDate AND pEndDate); ELSE SELECT COALESCE(SUM(noNeg(itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq))), 0.0) - ( SELECT COALESCE(SUM(invhist_invqty),0) FROM itemsite, item, wo, womatl LEFT OUTER JOIN womatlpost ON (womatl_id=womatlpost_womatl_id) LEFT OUTER JOIN invhist ON ((womatlpost_invhist_id=invhist_id) AND (invhist_invqty > 0)) WHERE ( (womatl_itemsite_id=pItemsiteid) AND (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (womatl_duedate BETWEEN pStartDate AND pEndDate) AND (wo_id=womatl_wo_id) AND (wo_status IN ('E','I','R')) ) ) INTO _qty FROM womatl JOIN wo ON (wo_id=womatl_wo_id AND wo_status IN ('E','I','R')) JOIN itemsite ON (itemsite_id=womatl_itemsite_id) WHERE (womatl_itemsite_id=pItemsiteid) AND (womatl_duedate BETWEEN pStartDate AND pEndDate); END IF; RETURN COALESCE(_qty,0); END; $_$; :DROP FUNCTION public.allocatedforwo(integer, date, date); publicadminfalse84623 125577958alterencrypt(text, text)FUNCTIONCREATE FUNCTION alterencrypt(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOldKey ALIAS FOR $1; pNewKey ALIAS FOR $2; _cc RECORD; _ccaud RECORD; _metricenc RECORD; num_updated INTEGER; BEGIN num_updated := 0; -- Update ccard FOR _cc IN SELECT ccard_id, decrypt(setbytea(ccard_name), setbytea(pOldKey), 'bf') AS ccard_name, decrypt(setbytea(ccard_address1), setbytea(pOldKey), 'bf') AS ccard_address1, decrypt(setbytea(ccard_address2), setbytea(pOldKey), 'bf') AS ccard_address2, decrypt(setbytea(ccard_city), setbytea(pOldKey), 'bf') AS ccard_city, decrypt(setbytea(ccard_state), setbytea(pOldKey), 'bf') AS ccard_state, decrypt(setbytea(ccard_zip), setbytea(pOldKey), 'bf') AS ccard_zip, decrypt(setbytea(ccard_country), setbytea(pOldKey), 'bf') AS ccard_country, decrypt(setbytea(ccard_number), setbytea(pOldKey), 'bf') AS ccard_number, decrypt(setbytea(ccard_month_expired), setbytea(pOldKey), 'bf') AS ccard_month_expired, decrypt(setbytea(ccard_year_expired), setbytea(pOldKey), 'bf') AS ccard_year_expired FROM ccard LOOP UPDATE ccard set ccard_name = encrypt(setbytea(_cc.ccard_name), setbytea(pNewKey), 'bf'), ccard_address1 = encrypt(setbytea(_cc.ccard_address1), setbytea(pNewKey), 'bf'), ccard_address2 = encrypt(setbytea(_cc.ccard_address2), setbytea(pNewKey), 'bf'), ccard_city = encrypt(setbytea(_cc.ccard_city), setbytea(pNewKey), 'bf'), ccard_state = encrypt(setbytea(_cc.ccard_state), setbytea(pNewKey), 'bf'), ccard_zip = encrypt(setbytea(_cc.ccard_zip), setbytea(pNewKey), 'bf'), ccard_country = encrypt(setbytea(_cc.ccard_country), setbytea(pNewKey), 'bf'), ccard_number = encrypt(setbytea(_cc.ccard_number), setbytea(pNewKey), 'bf'), ccard_month_expired = encrypt(setbytea(_cc.ccard_month_expired), setbytea(pNewKey), 'bf'), ccard_year_expired = encrypt(setbytea(_cc.ccard_year_expired), setbytea(pNewKey), 'bf') WHERE ccard_id = _cc.ccard_id; num_updated := num_updated + 1; END LOOP; -- Update ccardaud FOR _ccaud IN SELECT ccardaud_id, decrypt(setbytea(ccardaud_ccard_name_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_name_old, decrypt(setbytea(ccardaud_ccard_name_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_name_new, decrypt(setbytea(ccardaud_ccard_address1_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_address1_old, decrypt(setbytea(ccardaud_ccard_address1_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_address1_new, decrypt(setbytea(ccardaud_ccard_address2_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_address2_old, decrypt(setbytea(ccardaud_ccard_address2_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_address2_new, decrypt(setbytea(ccardaud_ccard_city_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_city_old, decrypt(setbytea(ccardaud_ccard_city_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_city_new, decrypt(setbytea(ccardaud_ccard_state_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_state_old, decrypt(setbytea(ccardaud_ccard_state_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_state_new, decrypt(setbytea(ccardaud_ccard_zip_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_zip_old, decrypt(setbytea(ccardaud_ccard_zip_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_zip_new, decrypt(setbytea(ccardaud_ccard_country_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_country_old, decrypt(setbytea(ccardaud_ccard_country_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_country_new, decrypt(setbytea(ccardaud_ccard_number_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_number_old, decrypt(setbytea(ccardaud_ccard_number_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_number_new, decrypt(setbytea(ccardaud_ccard_month_expired_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_month_expired_old, decrypt(setbytea(ccardaud_ccard_month_expired_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_month_expired_new, decrypt(setbytea(ccardaud_ccard_year_expired_old), setbytea(pOldKey), 'bf') AS ccardaud_ccard_year_expired_old, decrypt(setbytea(ccardaud_ccard_year_expired_new), setbytea(pOldKey), 'bf') AS ccardaud_ccard_year_expired_new FROM ccardaud LOOP UPDATE ccardaud set ccardaud_ccard_name_old = encrypt(setbytea(_ccaud.ccardaud_ccard_name_old), setbytea(pNewKey), 'bf'), ccardaud_ccard_name_new = encrypt(setbytea(_ccaud.ccardaud_ccard_name_new), setbytea(pNewKey), 'bf'), ccardaud_ccard_address1_old = encrypt(setbytea(_ccaud.ccardaud_ccard_address1_old), setbytea(pNewKey), 'bf'), ccardaud_ccard_address1_new = encrypt(setbytea(_ccaud.ccardaud_ccard_address1_new), setbytea(pNewKey), 'bf'), ccardaud_ccard_address2_old = encrypt(setbytea(_ccaud.ccardaud_ccard_address2_old), setbytea(pNewKey), 'bf'), ccardaud_ccard_address2_new = encrypt(setbytea(_ccaud.ccardaud_ccard_address2_new), setbytea(pNewKey), 'bf'), ccardaud_ccard_city_old = encrypt(setbytea(_ccaud.ccardaud_ccard_city_old), setbytea(pNewKey), 'bf'), ccardaud_ccard_city_new = encrypt(setbytea(_ccaud.ccardaud_ccard_city_new), setbytea(pNewKey), 'bf'), ccardaud_ccard_state_old = encrypt(setbytea(_ccaud.ccardaud_ccard_state_old), setbytea(pNewKey), 'bf'), ccardaud_ccard_state_new = encrypt(setbytea(_ccaud.ccardaud_ccard_state_new), setbytea(pNewKey), 'bf'), ccardaud_ccard_zip_old = encrypt(setbytea(_ccaud.ccardaud_ccard_zip_old), setbytea(pNewKey), 'bf'), ccardaud_ccard_zip_new = encrypt(setbytea(_ccaud.ccardaud_ccard_zip_new), setbytea(pNewKey), 'bf'), ccardaud_ccard_country_old = encrypt(setbytea(_ccaud.ccardaud_ccard_country_old), setbytea(pNewKey), 'bf'), ccardaud_ccard_country_new = encrypt(setbytea(_ccaud.ccardaud_ccard_country_new), setbytea(pNewKey), 'bf'), ccardaud_ccard_number_old = encrypt(setbytea(_ccaud.ccardaud_ccard_number_old), setbytea(pNewKey), 'bf'), ccardaud_ccard_number_new = encrypt(setbytea(_ccaud.ccardaud_ccard_number_new), setbytea(pNewKey), 'bf'), ccardaud_ccard_month_expired_old = encrypt(setbytea(_ccaud.ccardaud_ccard_month_expired_old), setbytea(pNewKey), 'bf'), ccardaud_ccard_month_expired_new = encrypt(setbytea(_ccaud.ccardaud_ccard_month_expired_new), setbytea(pNewKey), 'bf'), ccardaud_ccard_year_expired_old = encrypt(setbytea(_ccaud.ccardaud_ccard_year_expired_old), setbytea(pNewKey), 'bf'), ccardaud_ccard_year_expired_new = encrypt(setbytea(_ccaud.ccardaud_ccard_year_expired_new), setbytea(pNewKey), 'bf') WHERE ccardaud_id = _ccaud.ccardaud_id; num_updated := num_updated + 1; END LOOP; -- Update metricenc FOR _metricenc IN SELECT metricenc_id, decrypt(setbytea(metricenc_value), setbytea(pOldKey), 'bf') AS metricenc_value FROM metricenc LOOP UPDATE metricenc set metricenc_value = encrypt(setbytea(_metricenc.metricenc_value), setbytea(pNewKey), 'bf') WHERE metricenc_id = _metricenc.metricenc_id; num_updated := num_updated + 1; END LOOP; RETURN num_updated; END; $_$; /DROP FUNCTION public.alterencrypt(text, text); publicadminfalse46238!125586970apaging(date, boolean)FUNCTIONCREATE FUNCTION apaging(date, boolean) RETURNS SETOF apaging LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAsOfDate ALIAS FOR $1; pUseDocDate ALIAS FOR $2; _row apaging%ROWTYPE; _x RECORD; _returnVal INTEGER; _asOfDate DATE; BEGIN _asOfDate := COALESCE(pAsOfDate,current_date); FOR _x IN SELECT --report uses currency rate snapshot to convert all amounts to base based on apopen_docdate to ensure the same exchange rate --today and greater base: CASE WHEN((apopen.apopen_duedate >= DATE(_asOfDate))) THEN (((apopen.apopen_amount - apopen.apopen_paid + COALESCE(SUM(apapply_target_paid * apopen.apopen_curr_rate / target.apopen_curr_rate),0))) / apopen.apopen_curr_rate * CASE WHEN (apopen.apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END) ELSE 0 END AS cur_val, --0 to 30 base CASE WHEN((apopen.apopen_duedate >= DATE(_asOfDate)-30) AND (apopen.apopen_duedate < DATE(_asOfDate))) THEN (((apopen.apopen_amount - apopen.apopen_paid + COALESCE(SUM(apapply_target_paid * apopen.apopen_curr_rate / target.apopen_curr_rate),0))) / apopen.apopen_curr_rate * CASE WHEN (apopen.apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END) ELSE 0 END AS thirty_val, --30-60 base CASE WHEN((apopen.apopen_duedate >= DATE(_asOfDate)-60) AND (apopen.apopen_duedate < DATE(_asOfDate) - 30 )) THEN (((apopen.apopen_amount - apopen.apopen_paid + COALESCE(SUM(apapply_target_paid * apopen.apopen_curr_rate / target.apopen_curr_rate),0))) / apopen.apopen_curr_rate * CASE WHEN (apopen.apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END) ELSE 0 END AS sixty_val, --60-90 base CASE WHEN((apopen.apopen_duedate >= DATE(_asOfDate)-90) AND (apopen.apopen_duedate < DATE(_asOfDate) - 60)) THEN (((apopen.apopen_amount - apopen.apopen_paid + COALESCE(SUM(apapply_target_paid * apopen.apopen_curr_rate / target.apopen_curr_rate),0))) / apopen.apopen_curr_rate * CASE WHEN (apopen.apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END) ELSE 0 END AS ninety_val, --greater than 90 base: CASE WHEN((apopen.apopen_duedate > DATE(_asOfDate)-10000) AND (apopen.apopen_duedate < DATE(_asOfDate) - 90)) THEN (((apopen.apopen_amount - apopen.apopen_paid + COALESCE(SUM(apapply_target_paid * apopen.apopen_curr_rate / target.apopen_curr_rate),0))) / apopen.apopen_curr_rate * CASE WHEN (apopen.apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END) ELSE 0 END AS plus_val, --total amount base: CASE WHEN((apopen.apopen_duedate > DATE(_asOfDate)-10000)) THEN (((apopen.apopen_amount - apopen.apopen_paid + COALESCE(SUM(apapply_target_paid * apopen.apopen_curr_rate / target.apopen_curr_rate),0))) / apopen.apopen_curr_rate * CASE WHEN (apopen.apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END) ELSE 0 END AS total_val, --AP Open Amount base CASE WHEN apopen.apopen_doctype IN ('C', 'R') THEN (apopen.apopen_amount / apopen.apopen_curr_rate * -1.0) ELSE (apopen.apopen_amount / apopen.apopen_curr_rate) END AS apopen_amount, apopen.apopen_docdate, apopen.apopen_duedate, apopen.apopen_ponumber, apopen.apopen_invcnumber, apopen.apopen_docnumber, apopen.apopen_doctype, vend_id, vend_name, vend_number, vend_vendtype_id, vendtype_code, terms_descrip, determineDiscountDate(terms_id, apopen.apopen_docdate) AS discdate, noNeg(apopen.apopen_discountable_amount * CASE WHEN (CURRENT_DATE <= determineDiscountDate(terms_id, apopen.apopen_docdate)) THEN terms_discprcnt ELSE 0.0 END) AS disc_val, terms_discdays AS discdays, (terms_discprcnt * 100.0) AS discprcnt FROM vendinfo, vendtype, apopen LEFT OUTER JOIN terms ON (apopen_terms_id=terms_id) LEFT OUTER JOIN apapply ON (((apopen_id=apapply_target_apopen_id) OR (apopen_id=apapply_source_apopen_id)) AND (apapply_postdate >_asOfDate)) LEFT OUTER JOIN apopen target ON (target.apopen_id=apapply_target_apopen_id) WHERE ( (apopen.apopen_vend_id = vend_id) AND (vend_vendtype_id=vendtype_id) AND (CASE WHEN (pUseDocDate) THEN apopen.apopen_docdate ELSE apopen.apopen_distdate END <= _asOfDate) AND (COALESCE(apopen.apopen_closedate,_asOfDate+1)>_asOfDate) ) GROUP BY apopen.apopen_id,apopen.apopen_docdate,apopen.apopen_duedate,apopen.apopen_ponumber, apopen.apopen_invcnumber,apopen.apopen_docnumber,apopen.apopen_doctype,apopen.apopen_paid, apopen.apopen_curr_id,apopen.apopen_amount,vend_id,vend_name,vend_number,vend_vendtype_id,vendtype_code,terms_descrip, apopen.apopen_curr_rate, terms_id, terms_discdays, terms_discprcnt, apopen.apopen_discountable_amount ORDER BY vend_number, apopen.apopen_duedate LOOP _row.apaging_docdate := _x.apopen_docdate; _row.apaging_duedate := _x.apopen_duedate; _row.apaging_ponumber := _x.apopen_ponumber; _row.apaging_invcnumber := _x.apopen_invcnumber; _row.apaging_docnumber := _x.apopen_docnumber; _row.apaging_doctype := _x.apopen_doctype; _row.apaging_vend_id := _x.vend_id; _row.apaging_vend_number := _x.vend_number; _row.apaging_vend_name := _x.vend_name; _row.apaging_vend_vendtype_id := _x.vend_vendtype_id; _row.apaging_vendtype_code := _x.vendtype_code; _row.apaging_terms_descrip := _x.terms_descrip; _row.apaging_apopen_amount := _x.apopen_amount; _row.apaging_cur_val := _x.cur_val; _row.apaging_thirty_val := _x.thirty_val; _row.apaging_sixty_val := _x.sixty_val; _row.apaging_ninety_val := _x.ninety_val; _row.apaging_plus_val := _x.plus_val; _row.apaging_total_val := _x.total_val; _row.apaging_discdate := _x.discdate; _row.apaging_disc_val := _x.disc_val; _row.apaging_discdays := _x.discdays; _row.apaging_discprcnt := _x.discprcnt; RETURN NEXT _row; END LOOP; RETURN; END; $_$; -DROP FUNCTION public.apaging(date, boolean); publicadminfalse423184623"125577960apapplied(integer, date)FUNCTION}CREATE FUNCTION apapplied(integer, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pApopenid ALIAS FOR $1; pDate ALIAS FOR $2; _amount NUMERIC; BEGIN -- Return amount applied to an apopen in base currency as of apapply_postdate SELECT SUM(currtobase(apapply_curr_id,apapply_amount,apapply_postdate)) INTO _amount FROM apapply WHERE (((apapply_target_apopen_id = pApopenid) OR (apapply_source_apopen_id = pApopenid)) AND (((apapply_journalnumber=0) AND (apapply_postdate <= pDate)) OR EXISTS(SELECT * FROM gltrans WHERE ((gltrans_journalnumber=apapply_journalnumber) AND (gltrans_date <= pDate))))); IF (_amount IS NULL) THEN RETURN 0; ELSE RETURN _amount; END IF; END; $_$; /DROP FUNCTION public.apapplied(integer, date); publicadminfalse46238#125577961apcheckpending(integer)FUNCTIONCREATE FUNCTION apcheckpending(integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pApopenid ALIAS FOR $1; _qty NUMERIC := 0.0; BEGIN SELECT SUM(checkitem_amount + checkitem_discount) INTO _qty FROM checkitem JOIN checkhead ON (checkitem_checkhead_id=checkhead_id) WHERE ((checkitem_apopen_id=pApopenid) AND (NOT checkhead_deleted) AND (NOT checkhead_replaced) AND (NOT checkhead_void) AND (NOT checkhead_posted)); RETURN COALESCE(_qty, 0.0); END; $_$; .DROP FUNCTION public.apcheckpending(integer); publicadminfalse46238$125577962+apcurrgain(integer, integer, numeric, date)FUNCTIONCREATE FUNCTION apcurrgain(integer, integer, numeric, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pApopenId ALIAS FOR $1; pCurrId ALIAS FOR $2; pValue ALIAS FOR $3; pDate ALIAS FOR $4; _start DATE; _end DATE; _gain NUMERIC; _r RECORD; BEGIN IF (pApopenId IS NULL OR pValue = 0) THEN RETURN 0; END IF; SELECT apopen_docdate, apopen_curr_rate INTO _r FROM apopen WHERE (apopen_id=pApopenId); IF (_r.apopen_docdate > pDate) THEN _gain := (currToBase(pCurrId, pValue, pDate) - (pValue / _r.apopen_curr_rate)) * -1; ELSE _gain := (pValue / _r.apopen_curr_rate) - currToBase(pCurrId, pValue, pDate); END IF; IF (_gain IS NULL) THEN RAISE EXCEPTION 'Error processing currency gain/loss.'; END IF; RETURN _gain; END; $_$; BDROP FUNCTION public.apcurrgain(integer, integer, numeric, date); publicadminfalse84623%125577963#applyapcreditmemotobalance(integer)FUNCTIONCREATE FUNCTION applyapcreditmemotobalance(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pApopenid ALIAS FOR $1; _amount NUMERIC; _curr_id INTEGER; _curr_rate NUMERIC; _docdate DATE; _applyAmount NUMERIC; _r RECORD; _p RECORD; BEGIN -- Find the balance to apply SELECT (apopen_amount - apopen_paid - COALESCE(prepared,0.0) - COALESCE(selected,0.0) - COALESCE(SUM(currToCurr(apcreditapply_curr_id, apopen_curr_id, apcreditapply_amount, apopen_docdate)), 0)), apopen_curr_id, apopen_curr_rate, apopen_docdate INTO _amount, _curr_id, _curr_rate, _docdate FROM apopen LEFT OUTER JOIN apcreditapply ON (apcreditapply_source_apopen_id=apopen_id) LEFT OUTER JOIN (SELECT apopen_id AS selected_apopen_id, SUM(currToCurr(apselect_curr_id, apopen_curr_id, apselect_amount + apselect_discount, apselect_date)) AS selected FROM apselect JOIN apopen ON (apselect_apopen_id=apopen_id) GROUP BY apopen_id) AS sub1 ON (apopen_id=selected_apopen_id) LEFT OUTER JOIN (SELECT apopen_id AS prepared_apopen_id, SUM(checkitem_amount + checkitem_discount) AS prepared FROM checkhead JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN apopen ON (checkitem_apopen_id=apopen_id) WHERE ((NOT checkhead_posted) AND (NOT checkhead_void)) GROUP BY apopen_id) AS sub2 ON (prepared_apopen_id=apopen_id) WHERE (apopen_id=pApopenid) GROUP BY apopen_amount, apopen_paid, apopen_curr_id, apopen_curr_rate, apopen_docdate, prepared, selected; IF (_amount < 0) THEN RETURN -1; END IF; -- Loop through the apopen items in order of due date FOR _r IN SELECT target.apopen_id AS apopenid, currToCurr(target.apopen_curr_id,source.apopen_curr_id, target.apopen_amount - target.apopen_paid - COALESCE(prepared,0.0) - COALESCE(selected,0.0) - COALESCE(applied,0.0), current_date) AS balance FROM apopen AS source, apopen AS target LEFT OUTER JOIN (SELECT apcreditapply_target_apopen_id AS applied_apopen_id, SUM(currToCurr(apcreditapply_curr_id, apopen_curr_id, apcreditapply_amount, apopen_docdate)) AS applied FROM apcreditapply JOIN apopen ON (apopen_id=apcreditapply_source_apopen_id) GROUP BY apcreditapply_target_apopen_id) AS sub3 ON (target.apopen_id=applied_apopen_id) LEFT OUTER JOIN (SELECT apopen_id AS selected_apopen_id, SUM(currToCurr(apselect_curr_id, apopen_curr_id, apselect_amount + apselect_discount, apselect_date)) AS selected FROM apselect JOIN apopen ON (apselect_apopen_id=apopen_id) GROUP BY apopen_id) AS sub1 ON (target.apopen_id=selected_apopen_id) LEFT OUTER JOIN (SELECT apopen_id AS prepared_apopen_id, SUM(checkitem_amount + checkitem_discount) AS prepared FROM checkhead JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN apopen ON (checkitem_apopen_id=apopen_id) WHERE ((NOT checkhead_posted) AND (NOT checkhead_void)) GROUP BY apopen_id) AS sub2 ON (prepared_apopen_id=target.apopen_id) WHERE ( (source.apopen_vend_id=target.apopen_vend_id) AND (target.apopen_doctype IN ('V', 'D')) AND (target.apopen_open) AND (source.apopen_id=pApopenid) ) ORDER BY target.apopen_duedate, (target.apopen_amount - target.apopen_paid) LOOP -- Determine the amount to apply IF (_r.balance <= 0.0) THEN CONTINUE; ELSEIF (_r.balance > _amount) THEN _applyAmount := _amount; ELSE _applyAmount := _r.balance; END IF; -- Does an apcreditapply record already exist? SELECT apcreditapply_id, apcreditapply_amount * _curr_rate / currRate(apcreditapply_curr_id,_docdate) AS apcreditapply_amount INTO _p FROM apcreditapply WHERE ( (apcreditapply_target_apopen_id=_r.apopenid) AND (apcreditapply_source_apopen_id=pApopenid) ); IF (FOUND) THEN -- The following is depreciated, just skip the record -- Recalculate the amount to apply -- IF ((_r.balance - _p.apcreditapply_amount) > _amount) THEN -- _applyAmount := _amount; -- ELSE -- _applyAmount := (_r.balance - _p.apcreditapply_amount); -- END IF; -- Update the apcreditapply with the new amount to apply -- UPDATE apcreditapply -- SET apcreditapply_amount = (apcreditapply_amount + -- _applyAmount * currRate(apcreditapply_curr_id,_docdate) / _curr_rate) -- WHERE (apcreditapply_id=_p.apcreditapply_id); CONTINUE; ELSE -- Create a new apcreditapply record INSERT INTO apcreditapply ( apcreditapply_source_apopen_id, apcreditapply_target_apopen_id, apcreditapply_amount, apcreditapply_curr_id ) VALUES ( pApopenid, _r.apopenid, _applyAmount, _curr_id ); END IF; _amount := (_amount - _applyAmount); IF (_amount = 0) THEN EXIT; END IF; END LOOP; RETURN 1; END; $_$; :DROP FUNCTION public.applyapcreditmemotobalance(integer); publicadminfalse84623&125577964applyapcredits(integer)FUNCTIONCREATE FUNCTION applyapcredits(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendId ALIAS FOR $1; _result INTEGER; _apopenid INTEGER; _r RECORD; BEGIN -- Fetch credit memo(s) for the vendor FOR _r IN SELECT apopen_id, apopen_duedate FROM apopen JOIN vendinfo ON (apopen_vend_id = vend_id) WHERE ((apopen_doctype = 'C') AND (apopen_status = 'O') AND (vend_id = pVendId)) ORDER BY apopen_duedate LOOP -- Apply credit memo(s) according to due date SELECT applyapcreditmemotobalance(_r.apopen_id) INTO _result; -- Post the credit memo if applied IF (_result = 1) THEN SELECT postapcreditmemoapplication(_r.apopen_id) INTO _apopenid; IF (_apopenid < 0) THEN RETURN -1; END IF; ELSE RETURN -1; END IF; END LOOP; RETURN 1; END; $_$; .DROP FUNCTION public.applyapcredits(integer); publicadminfalse84623'125577965#applyarcreditmemotobalance(integer)FUNCTIONOCREATE FUNCTION applyarcreditmemotobalance(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAropenid ALIAS FOR $1; BEGIN RETURN applyARCreditMemoToBalance(pAropenid, NULL); END; $_$; :DROP FUNCTION public.applyarcreditmemotobalance(integer); publicadminfalse84623(125577966,applyarcreditmemotobalance(integer, integer)FUNCTIONCREATE FUNCTION applyarcreditmemotobalance(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSourceAropenid ALIAS FOR $1; pTargetAropenid ALIAS FOR $2; _amount NUMERIC; _amountcurrid INTEGER; _applyAmount NUMERIC; _applycurrid INTEGER; _curr_rate NUMERIC; _r RECORD; _p RECORD; BEGIN -- Find the balance to apply SELECT (aropen_amount - COALESCE(SUM(currToCurr(arcreditapply_curr_id, aropen_curr_id, arcreditapply_amount, aropen_docdate)), 0) - aropen_paid - COALESCE(prepared,0.0) - COALESCE(cashapplied,0.0)), aropen_curr_id, aropen_curr_rate INTO _amount, _amountcurrid, _curr_rate FROM aropen LEFT OUTER JOIN arcreditapply ON (arcreditapply_source_aropen_id=aropen_id) LEFT OUTER JOIN (SELECT aropen_id AS prepared_aropen_id, SUM(checkitem_amount + checkitem_discount) AS prepared FROM checkhead JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN aropen ON (checkitem_aropen_id=aropen_id) WHERE ((NOT checkhead_posted) AND (NOT checkhead_void)) GROUP BY aropen_id) AS sub1 ON (prepared_aropen_id=aropen_id) LEFT OUTER JOIN (SELECT aropen_id AS cash_aropen_id, SUM(cashrcptitem_amount + cashrcptitem_discount) * -1.0 AS cashapplied FROM cashrcpt JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id) JOIN aropen ON (cashrcptitem_aropen_id=aropen_id) WHERE (NOT cashrcpt_posted) AND (NOT cashrcpt_void) GROUP BY aropen_id ) AS sub2 ON (cash_aropen_id=aropen_id) WHERE (aropen_id=pSourceAropenid) GROUP BY aropen_amount, aropen_paid, aropen_curr_id, aropen_curr_rate, prepared, cashapplied; IF (_amount < 0) THEN RETURN -1; END IF; -- Loop through the aropen items in order of due date FOR _r IN SELECT target.aropen_id AS aropenid, currToCurr(target.aropen_curr_id,source.aropen_curr_id, (target.aropen_amount - target.aropen_paid - calcpendingarapplications(target.aropen_id)), current_date) AS balance, target.aropen_curr_id AS curr_id, target.aropen_docdate AS docdate FROM aropen AS target, aropen AS source WHERE ( (source.aropen_cust_id=target.aropen_cust_id) AND (target.aropen_doctype IN ('D', 'I')) AND (target.aropen_open) AND (source.aropen_id=pSourceAropenid) AND ((pTargetAropenid IS NULL) OR (target.aropen_id=pTargetAropenid)) ) ORDER BY target.aropen_duedate, target.aropen_docnumber LOOP -- Determine the amount to apply IF (_r.balance > _amount) THEN _applyAmount := _amount; ELSE _applyAmount := _r.balance; END IF; _applycurrid := _amountcurrid; -- Does an arcreditapply record already exist? SELECT arcreditapply_id, arcreditapply_amount, arcreditapply_amount * _curr_rate / currRate(arcreditapply_curr_id,_r.docdate) AS arcreditapply_amount_applycurr INTO _p FROM arcreditapply WHERE ( (arcreditapply_target_aropen_id=_r.aropenid) AND (arcreditapply_source_aropen_id=pSourceAropenid) ); IF (FOUND) THEN -- Offset the amount to apply by the amount already applied _applyAmount := (_applyAmount - _p.arcreditapply_amount_applycurr); IF (_applyAmount < 0) THEN _applyAmount := 0; END IF; -- Update the arcreditapply with the new amount to apply UPDATE arcreditapply SET arcreditapply_amount = (arcreditapply_amount + _applyAmount * currRate(arcreditapply_curr_id,_r.docdate) / _curr_rate) WHERE (arcreditapply_id=_p.arcreditapply_id); ELSE -- Create a new arcreditapply record INSERT INTO arcreditapply ( arcreditapply_source_aropen_id, arcreditapply_target_aropen_id, arcreditapply_amount, arcreditapply_curr_id ) VALUES ( pSourceAropenid, _r.aropenid, _applyAmount, _applycurrid ); END IF; _amount := _amount - currToCurr(_applycurrid, _amountcurrid, _applyAmount, _r.docdate); IF (_amount = 0) THEN EXIT; END IF; END LOOP; RETURN 1; END; $_$; CDROP FUNCTION public.applyarcreditmemotobalance(integer, integer); publicadminfalse46238)125577967?applycashreceiptlinebalance(integer, integer, numeric, integer)FUNCTIONCREATE FUNCTION applycashreceiptlinebalance(integer, integer, numeric, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCashrcptId ALIAS FOR $1; pAropenid ALIAS FOR $2; pAmount ALIAS FOR $3; pCurrId ALIAS FOR $4; _balance NUMERIC; _amount NUMERIC; _applyAmount NUMERIC := 0; _discount NUMERIC := 0; _discprct NUMERIC; _docDate DATE; _r RECORD; _doctype CHAR(1); BEGIN -- All calculations performed in currency of Cash Receipt -- Clear previously applied DELETE FROM cashrcptitem WHERE ((cashrcptitem_cashrcpt_id=pCashrcptId) AND (cashrcptitem_aropen_id=pAropenId)); -- Find the balance to apply SELECT (pAmount - (COALESCE(SUM(cashrcptitem_amount), 0) ) ), COALESCE(cashrcpt_docdate, current_date) INTO _amount, _docDate FROM cashrcpt LEFT OUTER JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id = cashrcpt_id) WHERE (cashrcpt_id=pCashrcptid) GROUP BY cashrcpt_curr_id, cashrcpt_distdate, cashrcpt_docdate; SELECT (_amount - COALESCE(SUM(cashrcptmisc_amount), 0)) INTO _amount FROM cashrcptmisc WHERE (cashrcptmisc_cashrcpt_id=pCashrcptid); SELECT aropen_doctype INTO _doctype FROM aropen WHERE (aropen_id=pAropenId); RAISE DEBUG 'Amount (%) DocType (%)', _amount, _doctype; IF (_amount <= 0 AND _doctype IN ('I','D')) THEN RETURN 0; END IF; -- Determine Line balance SELECT currToCurr(aropen_curr_id, cashrcpt_curr_id, aropen_amount - aropen_paid, cashrcpt_distdate) - COALESCE((SELECT (SUM(cashrcptitem_amount) + SUM(cashrcptitem_discount)) FROM cashrcptitem, cashrcpt WHERE ((cashrcpt_id=cashrcptitem_cashrcpt_id) AND (NOT cashrcpt_void) AND (NOT cashrcpt_posted) AND (cashrcpt_id != pCashrcptId) AND (cashrcptitem_aropen_id=pAropenId))), 0) INTO _balance FROM aropen, cashrcpt WHERE ((aropen_id=pAropenId) AND (cashrcpt_id=pCashrcptId)); RAISE DEBUG 'Balance (%)', _balance; -- If Invoice or Debit Memo, determine Max Discount as per Terms IF (_doctype IN ('I','D')) THEN SELECT round(noNeg(_balance * CASE WHEN (_docDate <= determineDiscountDate(terms_id, aropen_docdate)) THEN COALESCE(terms_discprcnt, 0.0) ELSE 0.00 END - applied),2), CASE WHEN (_docDate <= determineDiscountDate(terms_id, aropen_docdate)) THEN COALESCE(terms_discprcnt, 0.0) ELSE 0.00 END INTO _discount, _discprct FROM aropen LEFT OUTER JOIN terms ON (terms_id=aropen_terms_id), (SELECT COALESCE(SUM(arapply_applied), 0.00) AS applied FROM arapply, aropen WHERE ((arapply_target_aropen_id=pAropenId) AND (arapply_source_aropen_id=pAropenId) AND (aropen_discount) ) ) AS data WHERE (aropen_id=pAropenId); -- Determine the amount to apply IF (_balance <= _amount + _discount) THEN _applyAmount := _balance - _discount; ELSE _discount := round((_amount / (1 - _discprct)) - _amount, 2); _applyAmount := _amount; END IF; ELSIF (_doctype IN ('C', 'R')) THEN -- Handle Credits, discounts don't apply here _applyAmount := _balance * -1; ELSE _applyAmount := _amount; END IF; IF (_applyAmount != 0) THEN -- Create a new cashrcptitem INSERT INTO cashrcptitem ( cashrcptitem_aropen_id, cashrcptitem_cashrcpt_id, cashrcptitem_amount,cashrcptitem_discount ) VALUES ( pAropenid, pCashrcptid, round(_applyAmount, 2), round(_discount, 2) ); END IF; RETURN abs(_applyAmount); END; $_$; VDROP FUNCTION public.applycashreceiptlinebalance(integer, integer, numeric, integer); publicadminfalse46238*125577968+applycashreceipttobalance(integer, numeric)FUNCTIONCREATE FUNCTION applycashreceipttobalance(integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCashrcptid ALIAS FOR $1; pAmount ALIAS FOR $2; BEGIN RETURN applyCashReceiptToBalance(pCashrcptid, pAmount, baseCurrId() ); END; $_$; BDROP FUNCTION public.applycashreceipttobalance(integer, numeric); publicadminfalse84623+1255779694applycashreceipttobalance(integer, numeric, integer)FUNCTIONCREATE FUNCTION applycashreceipttobalance(integer, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCashrcptid ALIAS FOR $1; pAmount ALIAS FOR $2; pCurrId ALIAS FOR $3; BEGIN RETURN applyCashReceiptToBalance(pCashrcptid, pAmount, pCurrId, false); END; $_$; KDROP FUNCTION public.applycashreceipttobalance(integer, numeric, integer); publicadminfalse84623125577970=applycashreceipttobalance(integer, numeric, integer, boolean)FUNCTIONCREATE FUNCTION applycashreceipttobalance(integer, numeric, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCashrcptid ALIAS FOR $1; pAmount ALIAS FOR $2; pCurrId ALIAS FOR $3; pInclCredits ALIAS FOR $4; _amount NUMERIC; _applied NUMERIC := 0; _applyAmount NUMERIC; _discount NUMERIC; _discprct NUMERIC; _docDate DATE; _r RECORD; _toApply NUMERIC; BEGIN -- Apply open credits first if applicable IF (pInclCredits) THEN -- First find total debits unaccounted for by this receipt so we can apply as much credit -- as possible to clear, but no more SELECT coalesce(noNeg(sum(currToCurr(aropen_curr_id, cashrcpt_curr_id, aropen_amount - aropen_paid, cashrcpt_distdate) - COALESCE((SELECT (SUM(cashrcptitem_amount) + SUM(cashrcptitem_discount)) FROM cashrcptitem, cashrcpt WHERE ((cashrcpt_id=cashrcptitem_cashrcpt_id) AND (NOT cashrcpt_void) AND (NOT cashrcpt_posted) AND (cashrcpt_id != pCashrcptid) AND (cashrcptitem_aropen_id=aropen_id))), 0)) - pAmount),0) INTO _toApply FROM cashrcpt JOIN custinfo ON (cashrcpt_cust_id=cust_id) JOIN aropen ON (cust_id=aropen_cust_id) WHERE ((cashrcpt_id=pCashrcptid) AND (aropen_open) AND (aropen_doctype IN ('I','D'))); -- Loop through and apply credits until we account for all remaining debits we can FOR _r IN SELECT aropen_id FROM cashrcpt JOIN custinfo ON (cashrcpt_cust_id=cust_id) JOIN aropen ON (cust_id=aropen_cust_id) WHERE ((cashrcpt_id=pCashrcptid) AND (aropen_open) AND (aropen_doctype IN ('C','R'))) ORDER BY aropen_duedate, aropen_docnumber LOOP EXIT WHEN _toApply <= 0; _toApply := _toApply - applyCashReceiptLineBalance(pCashrcptid, _r.aropen_id, _toApply, pCurrId); END LOOP; END IF; -- Find the balance to apply SELECT (currToCurr(pCurrId, cashrcpt_curr_id, pAmount, cashrcpt_distdate) - (COALESCE(SUM(cashrcptitem_amount), 0) ) ), COALESCE(cashrcpt_docdate, current_date) INTO _amount, _docDate FROM cashrcpt LEFT OUTER JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id = cashrcpt_id) WHERE (cashrcpt_id=pCashrcptid) GROUP BY cashrcpt_curr_id, cashrcpt_distdate, cashrcpt_docdate; SELECT (_amount - COALESCE(SUM(cashrcptmisc_amount), 0)) INTO _amount FROM cashrcptmisc WHERE (cashrcptmisc_cashrcpt_id=pCashrcptid); IF (_amount = 0) THEN RETURN 1; END IF; -- Loop through the aropen item in order of due date, searching only for -- aropen items that are open, for the current customer and have an outstanding balance FOR _r IN SELECT aropen_id, currToCurr(aropen_curr_id, cashrcpt_curr_id, aropen_amount - aropen_paid, cashrcpt_distdate) - COALESCE((SELECT SUM(cashrcptitem_amount) + SUM(cashrcptitem_discount) FROM cashrcptitem, cashrcpt WHERE ((cashrcpt_id=cashrcptitem_cashrcpt_id) AND (NOT cashrcpt_void) AND (NOT cashrcpt_posted) AND (cashrcpt_id != pCashrcptId) AND (cashrcptitem_aropen_id=aropen_id))), 0) AS balance, s.cashrcptitem_id AS cashrcptitem_id FROM cashrcpt, aropen LEFT OUTER JOIN cashrcptitem s ON (s.cashrcptitem_aropen_id=aropen_id AND s.cashrcptitem_cashrcpt_id=pCashrcptId) LEFT OUTER JOIN terms ON (aropen_terms_id=terms_id), (SELECT COALESCE(SUM(arapply_applied), 0.00) AS applied FROM arapply, aropen WHERE ((arapply_target_aropen_id=aropen_id) AND (arapply_source_aropen_id=aropen_id) AND (aropen_discount) ) ) AS data WHERE ( (aropen_cust_id=cashrcpt_cust_id) AND (aropen_doctype IN ('I', 'D')) AND (aropen_open) AND (cashrcpt_id=pCashrcptid) ) ORDER BY aropen_duedate, aropen_amount, balance LOOP -- Determine Max Discount as per Terms SELECT COALESCE(round(noNeg(_r.balance * CASE WHEN (_docDate <= determineDiscountDate(terms_id, aropen_docdate)) THEN terms_discprcnt ELSE 0.00 END - applied),2), 0), COALESCE(CASE WHEN (_docDate <= determineDiscountDate(terms_id, aropen_docdate)) THEN terms_discprcnt ELSE 0.00 END, 0) INTO _discount, _discprct FROM aropen LEFT OUTER JOIN terms ON (terms_id=aropen_terms_id), (SELECT COALESCE(SUM(arapply_applied), 0.00) AS applied FROM arapply, aropen WHERE ((arapply_target_aropen_id=_r.aropen_id) AND (arapply_source_aropen_id=_r.aropen_id) AND (aropen_discount) ) ) AS data WHERE (aropen_id=_r.aropen_id); -- Determine the amount to apply IF (_r.balance <= _amount + _discount) THEN _applyAmount := _r.balance - _discount; ELSE _discount := round((_amount / (1 - _discprct)) - _amount, 2); _applyAmount := _amount; END IF; IF (_applyAmount > 0) THEN -- Does an cashrcptitem already exist? IF (_r.cashrcptitem_id IS NOT NULL) THEN -- Update the cashrcptitem with the new amount to apply UPDATE cashrcptitem SET cashrcptitem_amount = round(cashrcptitem_amount + _applyAmount, 2), cashrcptitem_discount = round(_discount, 2) WHERE (cashrcptitem_id=_r.cashrcptitem_id); ELSE -- Create a new cashrcptitem INSERT INTO cashrcptitem ( cashrcptitem_aropen_id, cashrcptitem_cashrcpt_id, cashrcptitem_amount, cashrcptitem_discount ) VALUES ( _r.aropen_id, pCashrcptid, round(_applyAmount, 2), round(_discount, 2) ); END IF; _amount := (_amount - _applyAmount); IF (round(_amount, 2) = 0) THEN EXIT; END IF; END IF; END LOOP; RETURN 1; END; $_$; TDROP FUNCTION public.applycashreceipttobalance(integer, numeric, integer, boolean); publicadminfalse84623,125586972araging(date, boolean)FUNCTIONCREATE FUNCTION araging(date, boolean) RETURNS SETOF araging LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAsOfDate ALIAS FOR $1; pUseDocDate ALIAS FOR $2; _row araging%ROWTYPE; BEGIN FOR _row IN SELECT * FROM araging(pAsOfDate, pUseDocDate, true) LOOP RETURN NEXT _row; END LOOP; RETURN; END; $_$; -DROP FUNCTION public.araging(date, boolean); publicadminfalse842344623/125586973araging(date, boolean, boolean)FUNCTION5CREATE FUNCTION araging(date, boolean, boolean) RETURNS SETOF araging LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAsOfDate ALIAS FOR $1; pUseDocDate ALIAS FOR $2; pConvBaseCurr ALIAS FOR $3; _row araging%ROWTYPE; _x RECORD; _returnVal INTEGER; _asOfDate DATE; BEGIN _asOfDate := COALESCE(pAsOfDate,current_date); FOR _x IN SELECT aropen_docdate, aropen_duedate, aropen_ponumber, aropen_docnumber, aropen_doctype, cust_id, cust_name, cust_number, cust_custtype_id, custtype_code, terms_descrip, --if pConvBaseCurr is true then use currtobase to convert all amounts to base based on aropen_docdate to ensure the same exchange rate --otherwise use currtocurr to convert all amounts to customer's currency based on aropen_docdate to ensure the same exchange rate --today and greater: CASE WHEN((aropen_duedate >= DATE(_asOfDate))) THEN balance ELSE 0.0 END AS cur_val, --0 to 30 CASE WHEN((aropen_duedate >= DATE(_asOfDate)-30) AND (aropen_duedate < DATE(_asOfDate))) THEN balance ELSE 0.0 END AS thirty_val, --30-60 CASE WHEN((aropen_duedate >= DATE(_asOfDate)-60) AND (aropen_duedate < DATE(_asOfDate) - 30 )) THEN balance ELSE 0.0 END AS sixty_val, --60-90 CASE WHEN((aropen_duedate >= DATE(_asOfDate)-90) AND (aropen_duedate < DATE(_asOfDate) - 60)) THEN balance ELSE 0.0 END AS ninety_val, --greater than 90: CASE WHEN((aropen_duedate > DATE(_asOfDate)-10000) AND (aropen_duedate < DATE(_asOfDate) - 90)) THEN balance ELSE 0.0 END AS plus_val, --total amount: CASE WHEN((aropen_duedate > DATE(_asOfDate)-10000)) THEN balance ELSE 0.0 END AS total_val, --AR Open Amount base aropen_amount FROM ( SELECT (((aropen_amount - aropen_paid + COALESCE(SUM(arapply_target_paid),0))) / CASE WHEN (pConvBaseCurr) THEN aropen_curr_rate ELSE currRate(aropen_curr_id, cust_curr_id, aropen_docdate) END * CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1.0 ELSE 1.0 END) AS balance, ((aropen_amount) / CASE WHEN (pConvBaseCurr) THEN aropen_curr_rate ELSE currRate(aropen_curr_id, cust_curr_id, aropen_docdate) END * CASE WHEN (aropen_doctype IN ('C', 'R')) THEN -1.0 ELSE 1.0 END) AS aropen_amount, aropen_docdate, aropen_duedate, aropen_ponumber, aropen_docnumber, aropen_doctype, cust_id, cust_name, cust_number, cust_custtype_id, custtype_code, COALESCE(arterms.terms_descrip, custterms.terms_descrip, '') AS terms_descrip FROM aropen JOIN custinfo ON (cust_id=aropen_cust_id) JOIN custtype ON (custtype_id=cust_custtype_id) LEFT OUTER JOIN terms arterms ON (arterms.terms_id=aropen_terms_id) LEFT OUTER JOIN terms custterms ON (custterms.terms_id=cust_terms_id) LEFT OUTER JOIN arapply ON (((aropen_id=arapply_target_aropen_id) OR (aropen_id=arapply_source_aropen_id)) AND (arapply_distdate>_asOfDate)) WHERE ( (CASE WHEN (pUseDocDate) THEN aropen_docdate ELSE aropen_distdate END <= _asOfDate) AND (COALESCE(aropen_closedate,_asOfDate+1)>_asOfDate) ) GROUP BY aropen_id,aropen_docdate,aropen_duedate,aropen_ponumber,aropen_docnumber,aropen_doctype,aropen_paid, aropen_curr_id,aropen_amount,cust_id,cust_name,cust_number,cust_custtype_id,custtype_code, arterms.terms_descrip,custterms.terms_descrip, aropen_curr_rate, aropen_curr_id, cust_curr_id ORDER BY cust_number, aropen_duedate ) AS data LOOP _row.araging_docdate := _x.aropen_docdate; _row.araging_duedate := _x.aropen_duedate; _row.araging_ponumber := _x.aropen_ponumber; _row.araging_docnumber := _x.aropen_docnumber; _row.araging_doctype := _x.aropen_doctype; _row.araging_cust_id := _x.cust_id; _row.araging_cust_number := _x.cust_number; _row.araging_cust_name := _x.cust_name; _row.araging_cust_custtype_id := _x.cust_custtype_id; _row.araging_custtype_code := _x.custtype_code; _row.araging_terms_descrip := _x.terms_descrip; _row.araging_aropen_amount := _x.aropen_amount; _row.araging_cur_val := _x.cur_val; _row.araging_thirty_val := _x.thirty_val; _row.araging_sixty_val := _x.sixty_val; _row.araging_ninety_val := _x.ninety_val; _row.araging_plus_val := _x.plus_val; _row.araging_total_val := _x.total_val; RETURN NEXT _row; END LOOP; RETURN; END; $_$; 6DROP FUNCTION public.araging(date, boolean, boolean); publicadminfalse4234846230125577974arapplied(integer, date)FUNCTIONzCREATE FUNCTION arapplied(integer, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAropenid ALIAS FOR $1; pDate ALIAS FOR $2; _amount NUMERIC; BEGIN -- Return amount applied to an aropen in base currency item as of the parameter date SELECT SUM(currtobase(arapply_curr_id,arapply_applied,pDate)) INTO _amount FROM arapply WHERE (((arapply_target_aropen_id = pAropenid) OR (arapply_source_aropen_id = pAropenid)) AND (((arapply_journalnumber=0) AND (arapply_postdate <= pDate)) OR EXISTS(SELECT * FROM gltrans WHERE ((gltrans_journalnumber=arapply_journalnumber) AND (gltrans_date <= pDate))))); IF (_amount IS NULL) THEN RETURN 0; ELSE RETURN _amount; END IF; END; $_$; /DROP FUNCTION public.arapplied(integer, date); publicadminfalse462381125577975archivesaleshistory(integer)FUNCTIONCREATE FUNCTION archivesaleshistory(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSohistid ALIAS FOR $1; BEGIN INSERT INTO asohist ( asohist_id, asohist_cust_id, asohist_itemsite_id, asohist_shipdate, asohist_invcdate, asohist_duedate, asohist_promisedate, asohist_ordernumber, asohist_invcnumber, asohist_qtyshipped, asohist_unitprice, asohist_unitcost, asohist_billtoname, asohist_billtoaddress1, asohist_billtoaddress2, asohist_billtoaddress3, asohist_billtocity, asohist_billtostate, asohist_billtozip, asohist_shiptoname, asohist_shiptoaddress1, asohist_shiptoaddress2, asohist_shiptoaddress3, asohist_shiptocity, asohist_shiptostate, asohist_shiptozip, asohist_shipto_id, asohist_shipvia, asohist_salesrep_id, asohist_misc_type, asohist_misc_descrip, asohist_misc_id, asohist_commission, asohist_commissionpaid, asohist_doctype, asohist_orderdate, asohist_imported, asohist_ponumber, asohist_curr_id, asohist_taxtype_id, asohist_taxzone_id ) SELECT cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipdate, cohist_invcdate, cohist_duedate, cohist_promisedate, cohist_ordernumber, cohist_invcnumber, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_shipto_id, cohist_shipvia, cohist_salesrep_id, cohist_misc_type, cohist_misc_descrip, cohist_misc_id, cohist_commission, cohist_commissionpaid, cohist_doctype, cohist_orderdate, cohist_imported, cohist_ponumber, cohist_curr_id, cohist_taxtype_id, cohist_taxzone_id FROM cohist WHERE (cohist_id=pSohistid); INSERT INTO asohisttax ( taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM cohisttax WHERE (taxhist_parent_id=pSohistid); DELETE FROM cohisttax WHERE (taxhist_parent_id=pSohistid); DELETE FROM cohist WHERE (cohist_id=pSohistid); RETURN pSohistid; END; $_$; 3DROP FUNCTION public.archivesaleshistory(integer); publicadminfalse846232125577976+arcurrgain(integer, integer, numeric, date)FUNCTIONCREATE FUNCTION arcurrgain(integer, integer, numeric, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAropenId ALIAS FOR $1; pCurrId ALIAS FOR $2; pValue ALIAS FOR $3; pDate ALIAS FOR $4; _start DATE; _end DATE; _gain NUMERIC; _r RECORD; BEGIN IF (pAropenId IS NULL OR pValue = 0) THEN RETURN 0; END IF; SELECT aropen_docdate, aropen_curr_id, aropen_curr_rate INTO _r FROM aropen WHERE (aropen_id=pAropenId); IF (_r.aropen_docdate > pDate) THEN _gain := (currToBase(pCurrId, pValue, pDate) - currToCurr(pCurrId,_r.aropen_curr_id, pValue, pDate) / _r.aropen_curr_rate) * -1; ELSE _gain := currToCurr(pCurrId,_r.aropen_curr_id, pValue, pDate) / _r.aropen_curr_rate - currToBase(pCurrId, pValue, pDate); END IF; IF (_gain IS NULL) THEN RAISE EXCEPTION 'Error processing currency gain/loss.'; END IF; RETURN _gain; END; $_$; BDROP FUNCTION public.arcurrgain(integer, integer, numeric, date); publicadminfalse46238125577977 armor(bytea)FUNCTIONqCREATE FUNCTION armor(bytea) RETURNS text LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_armor'; #DROP FUNCTION public.armor(bytea); publicadminfalse8125977978invbalTABLECREATE TABLE invbal ( invbal_id integer NOT NULL, invbal_period_id integer, invbal_itemsite_id integer, invbal_qoh_beginning numeric(18,6) NOT NULL, invbal_qoh_ending numeric(18,6) NOT NULL, invbal_qty_in numeric(18,6) NOT NULL, invbal_qty_out numeric(18,6) NOT NULL, invbal_value_beginning numeric(12,2) NOT NULL, invbal_value_ending numeric(12,2) NOT NULL, invbal_value_in numeric(12,2) NOT NULL, invbal_value_out numeric(12,2) NOT NULL, invbal_nn_beginning numeric(18,6) NOT NULL, invbal_nn_ending numeric(18,6) NOT NULL, invbal_nn_in numeric(18,6) NOT NULL, invbal_nn_out numeric(18,6) NOT NULL, invbal_nnval_beginning numeric(12,2) NOT NULL, invbal_nnval_ending numeric(12,2) NOT NULL, invbal_nnval_in numeric(12,2) NOT NULL, invbal_nnval_out numeric(12,2) NOT NULL, invbal_dirty boolean DEFAULT true NOT NULL ); DROP TABLE public.invbal; publicadminfalse59878%00invbalACLREVOKE ALL ON TABLE invbal FROM PUBLIC; REVOKE ALL ON TABLE invbal FROM admin; GRANT ALL ON TABLE invbal TO admin; GRANT ALL ON TABLE invbal TO xtrole; publicadminfalse1853125577982asofinvbal(integer, date)FUNCTIONWCREATE FUNCTION asofinvbal(integer, date) RETURNS SETOF invbal LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteId ALIAS FOR $1; pAsofDate ALIAS FOR $2; _result invbal%ROWTYPE; _i RECORD; _h RECORD; _r RECORD; _prevCostmethod TEXT := 'A'; _prevDate TIMESTAMP WITH TIME ZONE; _runningQty NUMERIC := 0; _runningNn NUMERIC := 0; _runningValue NUMERIC := 0; _runningNnval NUMERIC := 0; BEGIN /* This is a base function to gather data. Because it is STABLE it should only need to be calculated once, even though it is likely to be called several times by other functions in parent query to present the various data. */ -- First make sure inventory balance is forward updated PERFORM forwardUpdateItemsite(pItemsiteId); -- Next find the previous period balace to use as a starting point SELECT invbal.*, period_start, itemsite_costmethod INTO _i FROM invbal JOIN itemsite ON (invbal_itemsite_id=itemsite_id) JOIN period ON (invbal_period_id=period_id) WHERE ((invbal_itemsite_id=pItemsiteId) AND (pAsofDate >= period_start)) ORDER BY period_start DESC LIMIT 1; _runningQty := _i.invbal_qoh_beginning; _runningNn := _i.invbal_nn_beginning; _runningValue := _i.invbal_value_beginning; _runningNnval := _i.invbal_nnval_beginning; _prevDate := _i.period_start; _prevCostmethod := _i.itemsite_costmethod; FOR _r IN SELECT invhist_id, invhist_created, invhist_invqty, invhist_transtype, invhist_unitcost, invhist_costmethod, itemsite_item_id, invhistSense(invhist_id) AS sense FROM invhist JOIN itemsite ON (itemsite_id=invhist_itemsite_id) WHERE ((invhist_itemsite_id=pItemsiteId) AND (invhist_transdate::date BETWEEN _i.period_start AND pAsofdate)) ORDER BY invhist_created, invhist_id LOOP -- Update balances changed by any standard cost update between transactions IF (_prevCostmethod = 'S' AND _runningQty != 0) THEN FOR _h IN SELECT costhist_oldcost, costhist_newcost FROM costhist JOIN item ON (costhist_item_id=item_id) JOIN itemsite ON (itemsite_item_id=item_id) WHERE ((itemsite_id=pItemsiteId) AND (costhist_date BETWEEN _prevDate AND _r.invhist_created) AND (costhist_type IN ('S','D'))) LOOP _runningValue := _runningValue + round((_h.costhist_newcost-_h.costhist_oldcost) * _runningQty,2); _runningNnval := _runningNnval + round((_h.costhist_newcost-_h.costhist_oldcost) * _runningNn,2); END LOOP; END IF; _prevDate := _r.invhist_created; _prevCostmethod := _r.invhist_costmethod; _runningQty := _runningQty + _r.invhist_invqty * _r.sense; _runningValue := _runningValue + round( _r.invhist_invqty * _r.sense * _r.invhist_unitcost,2); IF (_r.invhist_transtype = 'NN') THEN _runningNn := _runningNn + _r.invhist_invqty * -1; _runningNnval := _runningNnval + round( _r.invhist_invqty * -1 * _r.invhist_unitcost,2); END IF; END LOOP; _prevDate := COALESCE(_prevDate, _i.period_start); _prevCostmethod := COALESCE(_r.invhist_costmethod, _i.itemsite_costmethod); IF (_prevCostmethod = 'S' AND _runningQty != 0) THEN FOR _h IN SELECT costhist_oldcost, costhist_newcost FROM costhist JOIN item ON (costhist_item_id=item_id) JOIN itemsite ON (itemsite_item_id=item_id) WHERE ((itemsite_id=pItemsiteId) AND (costhist_date BETWEEN _prevDate AND CAST(pAsofDate + 1 AS TIMESTAMP WITH TIME ZONE)) AND (costhist_type IN ('S','D'))) LOOP _runningValue := _runningValue + round((_h.costhist_newcost-_h.costhist_oldcost) * _runningQty,2); _runningNnval := _runningNnval + round((_h.costhist_newcost-_h.costhist_oldcost) * _runningNn,2); END LOOP; END IF; _result := _i; _result.invbal_qoh_ending := _runningQty; _result.invbal_value_ending := _runningValue; _result.invbal_nn_ending := _runningNn; _result.invbal_nnval_ending := _runningNnval; RETURN NEXT _result; RETURN; END; $_$; 0DROP FUNCTION public.asofinvbal(integer, date); publicadminfalse4623278084125577983asofinvnn(integer, date)FUNCTIONCREATE FUNCTION asofinvnn(integer, date) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteId ALIAS FOR $1; pAsofDate ALIAS FOR $2; _result NUMERIC; BEGIN SELECT invbal_nn_ending INTO _result FROM asofinvbal(pItemsiteId, pAsofDate); RETURN COALESCE(_result, 0); END; $_$; /DROP FUNCTION public.asofinvnn(integer, date); publicadminfalse846235125577984asofinvqty(integer, date)FUNCTIONCREATE FUNCTION asofinvqty(integer, date) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteId ALIAS FOR $1; pAsofDate ALIAS FOR $2; _result NUMERIC; BEGIN SELECT invbal_qoh_ending INTO _result FROM asofinvbal(pItemsiteId, pAsofDate); RETURN COALESCE(_result, 0); END; $_$; 0DROP FUNCTION public.asofinvqty(integer, date); publicadminfalse846237125577985+assessfinancecharge(integer, date, numeric)FUNCTIONCREATE FUNCTION assessfinancecharge(paropenid integer, passessdate date, passessamount numeric) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _fc RECORD; _ar RECORD; _invcheadid INTEGER; BEGIN -- cache some information SELECT * INTO _fc FROM fincharg; IF (NOT FOUND) THEN RAISE EXCEPTION 'assessFinanceCharge, configuration not set.'; END IF; SELECT * INTO _ar FROM aropen WHERE (aropen_id=pAropenid); IF (NOT FOUND) THEN RAISE EXCEPTION 'assessFinanceCharge, aropen not found.'; END IF; -- create invoice head INSERT INTO invchead ( invchead_cust_id, invchead_shipto_id, invchead_ordernumber, invchead_orderdate, invchead_posted, invchead_printed, invchead_invcnumber, invchead_invcdate, invchead_shipdate, invchead_ponumber, invchead_shipvia, invchead_fob, invchead_billto_name, invchead_billto_address1, invchead_billto_address2, invchead_billto_address3, invchead_billto_city, invchead_billto_state, invchead_billto_zipcode, invchead_billto_phone, invchead_shipto_name, invchead_shipto_address1, invchead_shipto_address2, invchead_shipto_address3, invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode, invchead_shipto_phone, invchead_salesrep_id, invchead_commission, invchead_terms_id, invchead_freight, invchead_misc_amount, invchead_misc_descrip, invchead_misc_accnt_id, invchead_payment, invchead_paymentref, invchead_notes, invchead_billto_country, invchead_shipto_country, invchead_prj_id, invchead_curr_id, invchead_gldistdate, invchead_recurring, invchead_recurring_interval, invchead_recurring_type, invchead_recurring_until, invchead_recurring_invchead_id, invchead_shipchrg_id, invchead_taxzone_id, invchead_void, invchead_saletype_id, invchead_shipzone_id ) SELECT invchead_cust_id, invchead_shipto_id, invchead_ordernumber, invchead_orderdate, FALSE, FALSE, fetchInvcNumber(), pAssessDate, invchead_shipdate, invchead_ponumber, invchead_shipvia, invchead_fob, invchead_billto_name, invchead_billto_address1, invchead_billto_address2, invchead_billto_address3, invchead_billto_city, invchead_billto_state, invchead_billto_zipcode, invchead_billto_phone, invchead_shipto_name, invchead_shipto_address1, invchead_shipto_address2, invchead_shipto_address3, invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode, invchead_shipto_phone, invchead_salesrep_id, 0.0, invchead_terms_id, 0.0, 0.0, NULL, NULL, 0.0, NULL, '', invchead_billto_country, invchead_shipto_country, invchead_prj_id, invchead_curr_id, NULL, FALSE, NULL, NULL, NULL, NULL, invchead_shipchrg_id, invchead_taxzone_id, invchead_void, invchead_saletype_id, invchead_shipzone_id FROM invchead WHERE (invchead_invcnumber=_ar.aropen_docnumber) RETURNING invchead_id INTO _invcheadid; -- create invoice item INSERT INTO invcitem ( invcitem_invchead_id, invcitem_linenumber, invcitem_item_id, invcitem_warehous_id, invcitem_custpn, invcitem_number, invcitem_descrip, invcitem_ordered, invcitem_billed, invcitem_custprice, invcitem_price, invcitem_notes, invcitem_salescat_id, invcitem_taxtype_id, invcitem_qty_uom_id, invcitem_qty_invuomratio, invcitem_price_uom_id, invcitem_price_invuomratio, invcitem_coitem_id, invcitem_updateinv, invcitem_rev_accnt_id ) VALUES ( _invcheadid, 1, -1, -1, NULL, _fc.fincharg_markoninvoice, -- - enhance data shown in the item description for the invoice line to indicate which invoice is affected -- - Feature Request 23344 -- 'Finance Charge Assessment', 'Finance Charge Assessment - Invoice Number ' || _ar.aropen_docnumber || ' - Past Due Balance ' || (_ar.aropen_amount - _ar.aropen_paid) || ' Due Date - ' || _ar.aropen_duedate, 1.0, 1.0, pAssessAmount, pAssessAmount, '', _fc.fincharg_salescat_id, NULL, NULL, 1.0, NULL, 1.0, NULL, FALSE, _fc.fincharg_accnt_id ); -- update aropen UPDATE aropen SET aropen_fincharg_date = pAssessDate, aropen_fincharg_amount = COALESCE(aropen_fincharg_amount, 0.0) + pAssessAmount WHERE (aropen_id=pAropenid); RETURN 0; END; $$; fDROP FUNCTION public.assessfinancecharge(paropenid integer, passessdate date, passessamount numeric); publicadminfalse462388125577986attachcontact(integer, integer)FUNCTIONCREATE FUNCTION attachcontact(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pcntctId ALIAS FOR $1; pcrmacctId ALIAS FOR $2; BEGIN UPDATE cntct SET cntct_crmacct_id = pcrmacctId WHERE cntct_id = pcntctId; RETURN 0; END; $_$; 6DROP FUNCTION public.attachcontact(integer, integer); publicadminfalse462389125577987*attachquotetoopportunity(integer, integer)FUNCTIONCREATE FUNCTION attachquotetoopportunity(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuheadid ALIAS FOR $1; pOpheadid ALIAS FOR $2; BEGIN -- Check Quote IF (NOT EXISTS(SELECT quhead_id FROM quhead WHERE (quhead_id=pQuheadid))) THEN RETURN -1; END IF; -- Check Opportunity IF (NOT EXISTS(SELECT ophead_id FROM ophead WHERE (ophead_id=pOpheadid))) THEN RETURN -2; END IF; -- Cannot attach if already attached IF (EXISTS(SELECT quhead_id FROM quhead WHERE ((quhead_id=pQuheadid) AND (quhead_ophead_id IS NOT NULL)))) THEN RETURN -3; END IF; UPDATE quhead SET quhead_ophead_id=pOpheadid WHERE (quhead_id=pQuheadid); RETURN 0; END; $_$; ADROP FUNCTION public.attachquotetoopportunity(integer, integer); publicadminfalse46238:125577988/attachsalesordertoopportunity(integer, integer)FUNCTIONCREATE FUNCTION attachsalesordertoopportunity(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; pOpheadid ALIAS FOR $2; BEGIN -- Check Sales Order IF (NOT EXISTS(SELECT cohead_id FROM cohead WHERE (cohead_id=pSoheadid))) THEN RETURN -1; END IF; -- Check Opportunity IF (NOT EXISTS(SELECT ophead_id FROM ophead WHERE (ophead_id=pOpheadid))) THEN RETURN -2; END IF; -- Cannot attach if already attached IF (EXISTS(SELECT cohead_id FROM cohead WHERE ((cohead_id=pSoheadid) AND (cohead_ophead_id IS NOT NULL)))) THEN RETURN -3; END IF; UPDATE cohead SET cohead_ophead_id=pOpheadid WHERE (cohead_id=pSoheadid); RETURN 0; END; $_$; FDROP FUNCTION public.attachsalesordertoopportunity(integer, integer); publicadminfalse84623;125577989&averagesalesprice(integer, date, date)FUNCTIONCREATE FUNCTION averagesalesprice(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _p RECORD; BEGIN -- Returns value in base currency -- ToDo: is cohist_shipdate the right DATE to use? SELECT SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitprice, cohist_shipdate)) AS totalsales, SUM(cohist_qtyshipped) AS totalship INTO _p FROM cohist WHERE ( (cohist_itemsite_id=pItemsiteid) AND (cohist_invcdate BETWEEN pStartDate AND pEndDate) ); IF ( (_p.totalship IS NULL) OR (_p.totalship = 0) ) THEN RETURN 0; ELSE RETURN (_p.totalsales / _p.totalship); END IF; END; $_$; =DROP FUNCTION public.averagesalesprice(integer, date, date); publicadminfalse84623<125577990avgcost(integer)FUNCTIONCREATE FUNCTION avgcost(pitemsiteid integer) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _value NUMERIC; _qoh NUMERIC; BEGIN SELECT itemsite_value, itemsite_qtyonhand INTO _value, _qoh FROM itemsite WHERE(itemsite_id=pItemsiteid); IF (_qoh = 0.0) THEN RETURN 0.0; END IF; RETURN _value / _qoh; END; $$; 3DROP FUNCTION public.avgcost(pitemsiteid integer); publicadminfalse46238=125577991balanceitemsite(integer)FUNCTION(CREATE FUNCTION balanceitemsite(pitemsiteid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _itemlocseries INTEGER; _balanced NUMERIC; _qoh NUMERIC; BEGIN -- Make sure that that passed Itemsite is MLC or Lot/Serial controlled IF ( ( SELECT (NOT ( (itemsite_loccntrl) OR (itemsite_controlmethod IN ('L', 'S')) )) FROM itemsite WHERE (itemsite_id=pItemsiteid) ) ) THEN RETURN 0; END IF; IF ( ( SELECT itemsite_freeze FROM itemsite WHERE(itemsite_id=pItemsiteid) ) ) THEN RETURN -1; END IF; -- Calculate the qoh SELECT COALESCE(SUM(itemloc_qty), 0) INTO _balanced FROM itemloc WHERE (itemloc_itemsite_id=pItemsiteid); -- Post an AD Transaction SELECT invAdjustment( itemsite_id, (_balanced - itemsite_qtyonhand), 'Balance', 'Inventory Balance' ) INTO _itemlocseries FROM itemsite WHERE (itemsite_id=pItemsiteid); -- Post the itemloc series which will postIntoTrialBalance and postInvHist PERFORM postItemlocSeries(_itemlocseries); -- Kill the resultant distribution records DELETE FROM itemlocdist WHERE (itemlocdist_series=_itemlocseries); RETURN 1; END; $$; ;DROP FUNCTION public.balanceitemsite(pitemsiteid integer); publicadminfalse84623>125586974!bankreconciliation(integer, text)FUNCTIONeSCREATE FUNCTION bankreconciliation(pbankrecid integer, ptask text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- posting and reopening bank reconciliations are nearly identical. -- the main differences revolve around what cleanup is done before starting. -- other than that, posting and reopening touch the same g/l accounts but with -- debits and credits reversed. DECLARE _accntid INTEGER; _bankrecid INTEGER; _gltransid INTEGER; _post BOOLEAN; _r RECORD; _result INTEGER; _sequence INTEGER; _sign INTEGER := 1; _tax RECORD; BEGIN CASE lower(pTask) WHEN 'post' THEN _post = TRUE; WHEN 'reopen' THEN _post = FALSE; ELSE RAISE EXCEPTION 'bankReconciliation got an invalid task %1 [xtuple: bankReconciliation, -2, %2]', pTask, pTask; END CASE; -- Check the accnt information to make sure it is valid SELECT accnt_id INTO _accntid FROM bankrec JOIN bankaccnt ON (bankrec_bankaccnt_id=bankaccnt_id) JOIN accnt ON (bankaccnt_accnt_id=accnt_id) WHERE (bankrec_id=pBankrecid); IF ( NOT FOUND ) THEN RAISE EXCEPTION 'bankReconciliation %1 %2 did not find the bank''s G/L account [xtuple: bankReconciliation, -1, %3, %4]', pTask, pBankrecid, pTask, pBankrecid; END IF; IF _post THEN DELETE FROM bankrecitem WHERE ( (NOT bankrecitem_cleared) AND (bankrecitem_bankrec_id=pBankrecid) ); -- Post any cleared bankadj items and convert the bankrecitem FOR _r IN SELECT bankrecitem_id, bankrecitem_source_id FROM bankrecitem, bankadj WHERE ( (bankrecitem_source = 'AD') AND (bankrecitem_source_id=bankadj_id) AND (bankrecitem_cleared) AND (NOT bankadj_posted) AND (bankrecitem_bankrec_id=pBankrecid) ) LOOP _sequence := postBankAdjustment(_r.bankrecitem_source_id); IF (_sequence < 0) THEN RAISE EXCEPTION 'postBankAdjustment %1 %2 failed during bankReconciliation [xtuple: postBankAdjustment, -10, %3, %4, %5]', pTask, pBankrecid, pTask, pBankrecid, _sequence; END IF; SELECT gltrans_id INTO _gltransid FROM gltrans WHERE ( (gltrans_sequence=_sequence) AND (gltrans_accnt_id=_accntid) ); IF ( NOT FOUND ) THEN RAISE EXCEPTION 'bankReconciliation %1 %2 did not find exactly one gltrans record for %3 [xtuple: bankReconciliation, -11, %4, %5, %6]', pTask, pBankrecid, _sequence, pTask, pBankrecid, _sequence; END IF; UPDATE bankrecitem SET bankrecitem_source = 'GL', bankrecitem_source_id=_gltransid WHERE (bankrecitem_id=_r.bankrecitem_id); END LOOP; ELSE -- NOT _post, therefore must be reopen _sign := -1; SELECT bankrec_id INTO _bankrecid FROM bankrec WHERE (NOT bankrec_posted); IF (FOUND) THEN -- Delete any bankrecitem records for unposted periods DELETE FROM bankrecitem WHERE (bankrecitem_bankrec_id=_bankrecid); -- Delete any bankrec records for unposted period DELETE FROM bankrec WHERE (bankrec_id=_bankrecid); END IF; END IF; IF (fetchMetricBool('CashBasedTax')) THEN -- Cash based tax distributions -- GL Transactions SELECT fetchGLSequence() INTO _sequence; FOR _r IN SELECT * FROM bankrecitem WHERE ( (bankrecitem_cleared) AND (bankrecitem_bankrec_id=pBankrecid) ) LOOP -- first, debit the tax liability clearing account -- and credit the tax liability distribution account -- for each tax code FOR _tax IN SELECT docnumber, custname, distdate, source, doctype, tax_sales_accnt_id, tax_dist_accnt_id, ROUND(currToBase(currid, ROUND(SUM(taxhist_tax),2), taxhist_docdate) * percentpaid, 2) AS taxbasevalue FROM ( -- Cash receipt, gltrans SELECT aropen_docnumber AS docnumber, cust_name AS custname, aropen_curr_id AS currid, gltrans_date AS distdate, (cashrcptitem_amount / aropen_amount) AS percentpaid, gltrans_source AS source, gltrans_doctype AS doctype, tax_sales_accnt_id, tax_dist_accnt_id, taxhist_tax, taxhist_docdate FROM gltrans JOIN cashrcpt ON ((gltrans_source='A/R') AND (gltrans_doctype='CR') AND (gltrans_misc_id=cashrcpt_id)) JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id) JOIN aropen ON (aropen_id=cashrcptitem_aropen_id) JOIN custinfo ON (cust_id=aropen_cust_id) JOIN cohist ON (cohist_invcnumber=aropen_docnumber AND cohist_doctype=aropen_doctype) JOIN cohisttax ON (taxhist_parent_id=cohist_id) JOIN tax ON (tax_id=taxhist_tax_id) WHERE (gltrans_id=_r.bankrecitem_source_id) -- Cash receipt, sltrans UNION SELECT aropen_docnumber AS docnumber, cust_name AS custname, aropen_curr_id AS currid, sltrans_date AS distdate, (cashrcptitem_amount / aropen_amount) AS percentpaid, sltrans_source AS source, sltrans_doctype AS doctype, tax_sales_accnt_id, tax_dist_accnt_id, taxhist_tax, taxhist_docdate FROM sltrans JOIN cashrcpt ON ((sltrans_source='A/R') AND (sltrans_doctype='CR') AND (sltrans_misc_id=cashrcpt_id)) JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id) JOIN aropen ON (aropen_id=cashrcptitem_aropen_id) JOIN custinfo ON (cust_id=aropen_cust_id) JOIN cohist ON (cohist_invcnumber=aropen_docnumber AND cohist_doctype=aropen_doctype) JOIN cohisttax ON (taxhist_parent_id=cohist_id) JOIN tax ON (tax_id=taxhist_tax_id) WHERE (sltrans_id=_r.bankrecitem_source_id) -- Cash payment, gltrans UNION SELECT apopen_docnumber AS docnumber, vend_name AS vendname, apopen_curr_id AS currid, gltrans_date AS distdate, (checkitem_amount / apopen_amount) AS percentpaid, gltrans_source AS source, gltrans_doctype AS doctype, tax_sales_accnt_id, tax_dist_accnt_id, taxhist_tax, taxhist_docdate FROM gltrans JOIN checkhead ON ((gltrans_source='A/P') AND (gltrans_doctype='CK') AND (gltrans_misc_id=checkhead_id)) JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN apopen ON (apopen_id=checkitem_apopen_id) JOIN vohead ON (vohead_number=apopen_docnumber) JOIN vendinfo ON (vend_id=apopen_vend_id) JOIN voheadtax ON (taxhist_parent_id=vohead_id) JOIN tax ON (tax_id=taxhist_tax_id) WHERE (gltrans_id=_r.bankrecitem_source_id) UNION SELECT apopen_docnumber AS docnumber, vend_name AS vendname, apopen_curr_id AS currid, gltrans_date AS distdate, (checkitem_amount / apopen_amount) AS percentpaid, gltrans_source AS source, gltrans_doctype AS doctype, tax_sales_accnt_id, tax_dist_accnt_id, taxhist_tax, taxhist_docdate FROM gltrans JOIN checkhead ON ((gltrans_source='A/P') AND (gltrans_doctype='CK') AND (gltrans_misc_id=checkhead_id)) JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN apopen ON (apopen_id=checkitem_apopen_id) JOIN vohead ON (vohead_number=apopen_docnumber) JOIN vendinfo ON (vend_id=apopen_vend_id) JOIN voitem ON (voitem_vohead_id=vohead_id) JOIN voitemtax ON (taxhist_parent_id=voitem_id) JOIN tax ON (tax_id=taxhist_tax_id) WHERE (gltrans_id=_r.bankrecitem_source_id) -- Cash payment, sltrans UNION SELECT apopen_docnumber AS docnumber, vend_name AS vendname, apopen_curr_id AS currid, sltrans_date AS distdate, (checkitem_amount / apopen_amount) AS percentpaid, sltrans_source AS source, sltrans_doctype AS doctype, tax_sales_accnt_id, tax_dist_accnt_id, taxhist_tax, taxhist_docdate FROM sltrans JOIN checkhead ON ((sltrans_source='A/P') AND (sltrans_doctype='CK') AND (sltrans_misc_id=checkhead_id)) JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN apopen ON (apopen_id=checkitem_apopen_id) JOIN vohead ON (vohead_number=apopen_docnumber) JOIN vendinfo ON (vend_id=apopen_vend_id) JOIN voheadtax ON (taxhist_parent_id=vohead_id) JOIN tax ON (tax_id=taxhist_tax_id) WHERE (sltrans_id=_r.bankrecitem_source_id) UNION SELECT apopen_docnumber AS docnumber, vend_name AS vendname, apopen_curr_id AS currid, sltrans_date AS distdate, (checkitem_amount / apopen_amount) AS percentpaid, sltrans_source AS source, sltrans_doctype AS doctype, tax_sales_accnt_id, tax_dist_accnt_id, taxhist_tax, taxhist_docdate FROM sltrans JOIN checkhead ON ((sltrans_source='A/P') AND (sltrans_doctype='CK') AND (sltrans_misc_id=checkhead_id)) JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN apopen ON (apopen_id=checkitem_apopen_id) JOIN vohead ON (vohead_number=apopen_docnumber) JOIN vendinfo ON (vend_id=apopen_vend_id) JOIN voitem ON (voitem_vohead_id=vohead_id) JOIN voitemtax ON (taxhist_parent_id=voitem_id) JOIN tax ON (tax_id=taxhist_tax_id) WHERE (sltrans_id=_r.bankrecitem_source_id) ) AS data GROUP BY docnumber, custname, currid, distdate, percentpaid, source, doctype, tax_sales_accnt_id, tax_dist_accnt_id, taxhist_docdate LOOP SELECT insertIntoGLSeries( _sequence, _tax.source, _tax.doctype, _tax.docnumber, _tax.tax_dist_accnt_id, _tax.taxbasevalue * _sign, COALESCE(_r.bankrecitem_effdate, _tax.distdate), _tax.custname ) INTO _result; IF (_result < 0) THEN RAISE EXCEPTION 'insertIntoGLSeries failed, result=%', _result; END IF; SELECT insertIntoGLSeries( _sequence, _tax.source, _tax.doctype, _tax.docnumber, _tax.tax_sales_accnt_id, (_tax.taxbasevalue * -1.0 * _sign), COALESCE(_r.bankrecitem_effdate, _tax.distdate), _tax.custname ) INTO _result; IF (_result < 0) THEN RAISE EXCEPTION 'insertIntoGLSeries failed, result=%', _result; END IF; END LOOP; -- second, create a taxpay row for each taxhist FOR _tax IN SELECT taxhist_id, applyid, distdate, ROUND(taxhist_tax * percentpaid, 2) AS taxpaid FROM ( -- Cash receipt, gltrans SELECT taxhist_id, aropen_id AS applyid, gltrans_date AS distdate, taxhist_tax, (cashrcptitem_amount / aropen_amount) AS percentpaid FROM gltrans JOIN cashrcpt ON ((gltrans_source='A/R') AND (gltrans_doctype='CR') AND (gltrans_misc_id=cashrcpt_id)) JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id) JOIN aropen ON (aropen_id=cashrcptitem_aropen_id) JOIN cohist ON (cohist_invcnumber=aropen_docnumber AND cohist_doctype=aropen_doctype) JOIN cohisttax ON (taxhist_parent_id=cohist_id) WHERE (gltrans_id=_r.bankrecitem_source_id) -- Cash receipt, sltrans UNION SELECT taxhist_id, aropen_id AS applyid, sltrans_date AS distdate, taxhist_tax, (cashrcptitem_amount / aropen_amount) AS percentpaid FROM sltrans JOIN cashrcpt ON ((sltrans_source='A/R') AND (sltrans_doctype='CR') AND (sltrans_misc_id=cashrcpt_id)) JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id) JOIN aropen ON (aropen_id=cashrcptitem_aropen_id) JOIN cohist ON (cohist_invcnumber=aropen_docnumber AND cohist_doctype=aropen_doctype) JOIN cohisttax ON (taxhist_parent_id=cohist_id) WHERE (sltrans_id=_r.bankrecitem_source_id) -- Cash payment, gltrans UNION SELECT taxhist_id, apopen_id AS applyid, gltrans_date AS distdate, taxhist_tax, (checkitem_amount / apopen_amount) AS percentpaid FROM gltrans JOIN checkhead ON ((gltrans_source='A/P') AND (gltrans_doctype='CK') AND (gltrans_misc_id=checkhead_id)) JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN apopen ON (apopen_id=checkitem_apopen_id) JOIN vohead ON (vohead_number=apopen_docnumber) JOIN voheadtax ON (taxhist_parent_id=vohead_id) WHERE (gltrans_id=_r.bankrecitem_source_id) UNION SELECT taxhist_id, apopen_id AS applyid, gltrans_date AS distdate, taxhist_tax, (checkitem_amount / apopen_amount) AS percentpaid FROM gltrans JOIN checkhead ON ((gltrans_source='A/P') AND (gltrans_doctype='CK') AND (gltrans_misc_id=checkhead_id)) JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN apopen ON (apopen_id=checkitem_apopen_id) JOIN vohead ON (vohead_number=apopen_docnumber) JOIN voitem ON (voitem_vohead_id=vohead_id) JOIN voitemtax ON (taxhist_parent_id=voitem_id) WHERE (gltrans_id=_r.bankrecitem_source_id) -- Cash payment, sltrans UNION SELECT taxhist_id, apopen_id AS applyid, sltrans_date AS distdate, taxhist_tax, (checkitem_amount / apopen_amount) AS percentpaid FROM sltrans JOIN checkhead ON ((sltrans_source='A/P') AND (sltrans_doctype='CK') AND (sltrans_misc_id=checkhead_id)) JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN apopen ON (apopen_id=checkitem_apopen_id) JOIN vohead ON (vohead_number=apopen_docnumber) JOIN voheadtax ON (taxhist_parent_id=vohead_id) WHERE (sltrans_id=_r.bankrecitem_source_id) UNION SELECT taxhist_id, apopen_id AS applyid, sltrans_date AS distdate, taxhist_tax, (checkitem_amount / apopen_amount) AS percentpaid FROM sltrans JOIN checkhead ON ((sltrans_source='A/P') AND (sltrans_doctype='CK') AND (sltrans_misc_id=checkhead_id)) JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) JOIN apopen ON (apopen_id=checkitem_apopen_id) JOIN vohead ON (vohead_number=apopen_docnumber) JOIN voitem ON (voitem_vohead_id=vohead_id) JOIN voitemtax ON (taxhist_parent_id=voitem_id) WHERE (sltrans_id=_r.bankrecitem_source_id) ) AS data LOOP IF _post THEN INSERT INTO taxpay ( taxpay_taxhist_id, taxpay_apply_id, taxpay_distdate, taxpay_tax ) VALUES ( _tax.taxhist_id, _tax.applyid, COALESCE(_r.bankrecitem_effdate, _tax.distdate), _tax.taxpaid ); ELSE DELETE FROM taxpay WHERE ((taxpay_taxhist_id=_tax.taxhist_id) AND (taxpay_apply_id=_tax.applyid) AND (taxpay_distdate=COALESCE(_r.bankrecitem_effdate, _tax.distdate)) AND (taxpay_tax=_tax.taxpaid)); END IF; END LOOP; END LOOP; SELECT postGLSeries(_sequence, fetchJournalNumber('GL-MISC')) INTO _result; IF (_result < 0) THEN RAISE EXCEPTION 'postGLSeries failed, result=%', _result; END IF; END IF; UPDATE gltrans SET gltrans_rec = _post WHERE ( (gltrans_id IN (SELECT bankrecitem_source_id FROM bankrecitem WHERE ((bankrecitem_source = 'GL') AND (bankrecitem_cleared) AND (bankrecitem_bankrec_id=pBankrecid) ) ) ) AND (gltrans_accnt_id=_accntid) ) ; UPDATE sltrans SET sltrans_rec = _post WHERE ( (sltrans_id IN (SELECT bankrecitem_source_id FROM bankrecitem WHERE ((bankrecitem_source = 'SL') AND (bankrecitem_cleared) AND (bankrecitem_bankrec_id=pBankrecid) ) ) ) AND (sltrans_accnt_id=_accntid) ) ; UPDATE bankrec SET bankrec_posted = _post, bankrec_postdate = CASE _post WHEN TRUE THEN now() ELSE NULL END WHERE (bankrec_id=pBankrecid); RETURN pBankrecid; END; $$; IDROP FUNCTION public.bankreconciliation(pbankrecid integer, ptask text); publicadminfalse84623-125577992bomcontains(integer, integer)FUNCTIONgCREATE FUNCTION bomcontains(integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pparentitemid ALIAS FOR $1; pchilditemid ALIAS FOR $2; _bomworksetid INTEGER; _result BOOLEAN; BEGIN _bomworksetid := indentedWhereUsed(pchilditemid); _result := EXISTS(SELECT bomwork_id FROM bomwork WHERE ((bomwork_set_id=_bomworksetid) AND (bomwork_item_id=pparentitemid) )); PERFORM deleteBOMWorkset(_bomworksetid); RETURN _result; END; $_$; 4DROP FUNCTION public.bomcontains(integer, integer); publicadminfalse84623@125577993bomhistsequence(integer)FUNCTIONCREATE FUNCTION bomhistsequence(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pHistid ALIAS FOR $1; _wid INTEGER; _seqnum TEXT; _bomhist RECORD; BEGIN _wid := pHistid; SELECT bomhist_parent_id AS parent, to_char(bomhist_seqnumber, '00009') AS seq INTO _bomhist FROM bomhist WHERE bomhist_seq_id=_wid; IF (FOUND) THEN _seqnum := _bomhist.seq; _wid := _bomhist.parent; WHILE (_wid != -1) LOOP SELECT bomhist_parent_id AS parent, to_char(bomhist_seqnumber, '00009') AS seq INTO _bomhist FROM bomhist WHERE bomhist_seq_id=_wid; IF (FOUND) THEN _seqnum := _bomhist.seq || '-' || _seqnum; _wid := _bomhist.parent; ELSE _wid := -1; END IF; END LOOP; ELSE _seqnum := ''::TEXT; END IF; RETURN _seqnum; END; $_$; /DROP FUNCTION public.bomhistsequence(integer); publicadminfalse84623125977994bomitemTABLECREATE TABLE bomitem ( bomitem_id integer DEFAULT nextval(('bomitem_bomitem_id_seq'::text)::regclass) NOT NULL, bomitem_parent_item_id integer NOT NULL, bomitem_seqnumber integer, bomitem_item_id integer NOT NULL, bomitem_qtyper numeric(20,8) NOT NULL, bomitem_scrap numeric(8,4) NOT NULL, bomitem_status character(1), bomitem_effective date NOT NULL, bomitem_expires date NOT NULL, bomitem_createwo boolean NOT NULL, bomitem_issuemethod character(1) NOT NULL, bomitem_schedatwooper boolean NOT NULL, bomitem_ecn text, bomitem_moddate date, bomitem_subtype character(1) NOT NULL, bomitem_uom_id integer NOT NULL, bomitem_rev_id integer DEFAULT (-1), bomitem_booitem_seq_id integer DEFAULT (-1), bomitem_char_id integer, bomitem_value text, bomitem_notes text, bomitem_ref text, bomitem_qtyfxd numeric(20,8) DEFAULT 0 NOT NULL, bomitem_issuewo boolean DEFAULT false NOT NULL, CONSTRAINT bomitem_bomitem_issuemethod_check CHECK ((((bomitem_issuemethod = 'M'::bpchar) OR (bomitem_issuemethod = 'S'::bpchar)) OR (bomitem_issuemethod = 'L'::bpchar))), CONSTRAINT bomitem_bomitem_subtype_check CHECK ((((bomitem_subtype = 'N'::bpchar) OR (bomitem_subtype = 'I'::bpchar)) OR (bomitem_subtype = 'B'::bpchar))) ); DROP TABLE public.bomitem; publicadminfalse59885989599059915992599359948%00 TABLE bomitemCOMMENTSCOMMENT ON TABLE bomitem IS 'Bill of Materials (BOM) component Items information'; publicadminfalse186%00COLUMN bomitem.bomitem_qtyfxdCOMMENTKCOMMENT ON COLUMN bomitem.bomitem_qtyfxd IS 'The fixed quantity required'; publicadminfalse186%00bomitemACLREVOKE ALL ON TABLE bomitem FROM PUBLIC; REVOKE ALL ON TABLE bomitem FROM admin; GRANT ALL ON TABLE bomitem TO admin; GRANT ALL ON TABLE bomitem TO xtrole; publicadminfalse186A125578007bomitem(integer)FUNCTIONCCREATE FUNCTION bomitem(integer) RETURNS SETOF bomitem LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT * FROM bomitem WHERE ((bomitem_parent_item_id=$1) AND (bomitem_rev_id=getActiveRevId('BOM',$1))); $_$; 'DROP FUNCTION public.bomitem(integer); publicadminfalse27838B125578008bomitem(integer, integer)FUNCTION6CREATE FUNCTION bomitem(integer, integer) RETURNS SETOF bomitem LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT * FROM bomitem WHERE ((bomitem_parent_item_id=$1) AND (bomitem_rev_id=$2)); $_$; 0DROP FUNCTION public.bomitem(integer, integer); publicadminfalse27838C125578009bomlevelbyitem(integer)FUNCTIONCREATE FUNCTION bomlevelbyitem(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; _cnt INTEGER; _result INTEGER; _bomitem RECORD; BEGIN _cnt := 0; BEGIN FOR _bomitem IN SELECT bomitem_parent_item_id FROM bomitem WHERE ((bomitem_item_id=pItemid) AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id)) AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1))) LOOP SELECT bomLevelByItem(_bomitem.bomitem_parent_item_id) + 1 INTO _result; IF (_result > _cnt) THEN _cnt := _result; END IF; END LOOP; EXCEPTION WHEN statement_too_complex THEN RAISE EXCEPTION 'potential recursive BOM found for item_id %', pItemid; END; return _cnt; END; $_$; .DROP FUNCTION public.bomlevelbyitem(integer); publicadminfalse46238D125578010 bomlevelbyitem(integer, integer)FUNCTIONCREATE FUNCTION bomlevelbyitem(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pBomrevid ALIAS FOR $2; _cnt INTEGER; _result INTEGER; _bomitem RECORD; BEGIN _cnt := 0; BEGIN FOR _bomitem IN SELECT bomitem_parent_item_id FROM bomitem WHERE ((bomitem_item_id=pItemid) AND (bomitem_rev_id=pBomrevid) AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1))) LOOP SELECT bomLevelByItem(_bomitem.bomitem_parent_item_id, pBomrevid) + 1 INTO _result; IF (_result > _cnt) THEN _cnt := _result; END IF; END LOOP; EXCEPTION WHEN statement_too_complex THEN RAISE EXCEPTION 'potential recursive BOM found for item_id %', pItemid; END; return _cnt; END; $_$; 7DROP FUNCTION public.bomlevelbyitem(integer, integer); publicadminfalse84623E125578011bomworkeffective(integer, date)FUNCTION*CREATE FUNCTION bomworkeffective(integer, date) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE workid ALIAS FOR $1; effdate ALIAS FOR $2; _wid INTEGER; _bomwork RECORD; BEGIN _wid := workid; WHILE (_wid != -1) LOOP SELECT bomwork_parent_id AS parent, bomwork_effective AS effective INTO _bomwork FROM bomwork WHERE bomwork_id=_wid; IF (FOUND) THEN _wid := _bomwork.parent; IF (_bomwork.effective > effdate) THEN RETURN FALSE; END IF; ELSE _wid := -1; END IF; END LOOP; RETURN TRUE; END; $_$; 6DROP FUNCTION public.bomworkeffective(integer, date); publicadminfalse84623F125578012bomworkexpired(integer, date)FUNCTION#CREATE FUNCTION bomworkexpired(integer, date) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE workid ALIAS FOR $1; expdate ALIAS FOR $2; _wid INTEGER; _bomwork RECORD; BEGIN _wid := workid; WHILE (_wid != -1) LOOP SELECT bomwork_parent_id AS parent, bomwork_expires AS expires INTO _bomwork FROM bomwork WHERE bomwork_id=_wid; IF (FOUND) THEN _wid := _bomwork.parent; IF (_bomwork.expires <= expdate) THEN RETURN TRUE; END IF; ELSE _wid := -1; END IF; END LOOP; RETURN FALSE; END; $_$; 4DROP FUNCTION public.bomworkexpired(integer, date); publicadminfalse46238G125578013bomworkitemsequence(integer)FUNCTIONCREATE FUNCTION bomworkitemsequence(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWorkid ALIAS FOR $1; _wid INTEGER; _seqnum TEXT; _bomwork RECORD; BEGIN _wid := pWorkid; SELECT bomwork_parent_id AS parent, item_number AS seq INTO _bomwork FROM bomwork, item WHERE ((bomwork_id=_wid) AND (bomwork_item_id=item_id)); IF (FOUND) THEN _seqnum := _bomwork.seq; _wid := _bomwork.parent; WHILE (_wid != -1) LOOP SELECT bomwork_parent_id AS parent, item_number AS seq INTO _bomwork FROM bomwork, item WHERE ((bomwork_id=_wid) AND (bomwork_item_id=item_id)); IF (FOUND) THEN _seqnum := _bomwork.seq || '-' || _seqnum; _wid := _bomwork.parent; ELSE _wid := -1; END IF; END LOOP; ELSE _seqnum := ''::TEXT; END IF; RETURN _seqnum; END; $_$; 3DROP FUNCTION public.bomworkitemsequence(integer); publicadminfalse46238H125578014bomworksequence(integer)FUNCTIONCREATE FUNCTION bomworksequence(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWorkid ALIAS FOR $1; _wid INTEGER; _seqnum TEXT; _bomwork RECORD; BEGIN _wid := pWorkid; SELECT bomwork_parent_id AS parent, to_char(bomwork_seqnumber, '00009') AS seq INTO _bomwork FROM bomwork WHERE bomwork_id=_wid; IF (FOUND) THEN _seqnum := _bomwork.seq; _wid := _bomwork.parent; WHILE (_wid != -1) LOOP SELECT bomwork_parent_id AS parent, to_char(bomwork_seqnumber, '00009') AS seq INTO _bomwork FROM bomwork WHERE bomwork_id=_wid; IF (FOUND) THEN _seqnum := _bomwork.seq || '-' || _seqnum; _wid := _bomwork.parent; ELSE _wid := -1; END IF; END LOOP; ELSE _seqnum := ''::TEXT; END IF; RETURN _seqnum; END; $_$; /DROP FUNCTION public.bomworksequence(integer); publicadminfalse46238I125578015buildinvbal(integer)FUNCTION CREATE FUNCTION buildinvbal(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteId ALIAS FOR $1; _r RECORD; _prevCostmethod TEXT := 'A'; _prevDate TIMESTAMP WITH TIME ZONE; _runningQty NUMERIC := 0; _runningNn NUMERIC := 0; BEGIN -- Validate IF (SELECT (count(invhist_id) > 0) FROM invhist WHERE ((invhist_itemsite_id=pItemsiteId) AND (NOT invhist_posted))) THEN SELECT item_number, warehous_code INTO _r FROM itemsite JOIN item ON (item_id=itemsite_item_id) JOIN whsinfo ON (itemsite_warehous_id=warehous_id) WHERE (itemsite_id=pItemsiteId); RAISE EXCEPTION 'Unposted inventory transactions exist for % at % [xtuple: buildInvBal, -1, %, %]', _r.item_number, _r.warehous_code, _r.item_number, _r.warehous_code; END IF; -- Remove any old records DELETE FROM invbal WHERE invbal_itemsite_id=pItemsiteId; FOR _r IN SELECT invhist.*, itemsite_item_id, invhistSense(invhist_id) AS sense, item_number, warehous_code FROM invhist JOIN itemsite ON (itemsite_id=invhist_itemsite_id) JOIN item ON (itemsite_item_id=item_id) JOIN whsinfo ON (itemsite_warehous_id=warehous_id) WHERE (invhist_itemsite_id=pItemsiteId) ORDER BY invhist_created, invhist_id LOOP --RAISE NOTICE 'Calculating balances for Item % at Site % against transaction %, transtype %, sense %, qty %, %', _r.item_number, _r.warehous_code, _r.invhist_id, _r.invhist_transtype, _r.sense, _r.invhist_invqty, _r.invhist_comments; -- Update balances changed by any standard cost update between transactions IF (_prevCostmethod = 'S' AND _runningQty != 0) THEN PERFORM postValueintoInvBalance(pItemsiteid, costhist_date::date, _runningQty, _runningNn, costhist_oldcost, costhist_newcost ) FROM costhist WHERE ((costhist_item_id=_r.itemsite_item_id) AND (costhist_date BETWEEN _prevDate AND _r.invhist_created) AND (costhist_type IN ('S','D'))); END IF; -- Post transaction into inventory balance table PERFORM postIntoInvBalance(_r.invhist_id); _prevDate := _r.invhist_created; _prevCostmethod := _r.invhist_costmethod; _runningQty := _runningQty + _r.invhist_invqty * _r.sense; IF (_r.invhist_transtype = 'NN') THEN _runningNn := _runningNn + _r.invhist_invqty * -1; END IF; END LOOP; -- Update balances changed by any standard cost since last transaction IF (_prevCostmethod = 'S' AND _runningQty != 0) THEN PERFORM postValueintoInvBalance(pItemsiteid, costhist_date::date, _runningQty, _runningNn, costhist_oldcost, costhist_newcost ) FROM costhist WHERE ((costhist_item_id=_r.itemsite_item_id) AND (costhist_date > _prevDate) AND (costhist_type IN ('S','D'))); END IF; -- Forward update changes through all the balances PERFORM forwardupdateitemsite(pItemsiteId); RETURN 1; END; $_$; +DROP FUNCTION public.buildinvbal(integer); publicadminfalse46238J125578016buildsearchpath()FUNCTIONCREATE FUNCTION buildsearchpath() RETURNS text LANGUAGE plpgsql AS $_$ DECLARE _path TEXT := ''; _schema TEXT; _seq INTEGER; BEGIN -- get the schemas as ordered by the administrator SELECT concatagg(quote_ident(schemaord_name) || ',') INTO _path FROM (SELECT schemaord_name FROM schemaord LEFT OUTER JOIN pkghead ON (schemaord_name=pkghead_name) WHERE (pkghead_id IS NULL OR (pkghead_id IS NOT NULL AND packageisenabled(pkghead_id))) ORDER BY schemaord_order ) AS xtspq; -- add others that we think/know we need -- TODO: is there a reason not to include public, api, or packages? FOR _schema, _seq IN SELECT pkghead_name AS schema, 0 AS seq FROM pkghead WHERE packageisenabled(pkghead_id) UNION ALL SELECT 'public', 1 UNION ALL SELECT 'api', 2 ORDER BY seq, schema LOOP IF (_path !~* (E'(^|\\W)' || _schema || E'(\\W|$)')) THEN _path := _path || ',' || quote_ident(_schema); END IF; END LOOP; -- remove extraneous spaces and commas _path = BTRIM(REGEXP_REPLACE(_path, '( ?, ?)+', ',', 'g'), ', '); RAISE DEBUG 'buildSearchPath() returning %', _path; RETURN _path; END; $_$; (DROP FUNCTION public.buildsearchpath(); publicadminfalse84623%00FUNCTION buildsearchpath()COMMENT:COMMENT ON FUNCTION buildsearchpath() IS 'buildSearchPath() examines the schemaord and pkghead tables to build a search path string. It ensures that public, api, and all enabled packages are included even if they are not listed in the schemaord table. It returns the constructed search_path but does not set it.'; publicadminfalse1098O125578017+calccashbudget(integer, integer, character)FUNCTION CREATE FUNCTION calccashbudget(integer, integer, character) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAccntId ALIAS FOR $1; pPeriodId ALIAS FOR $2; pInterval ALIAS FOR $3; _accntType CHAR; _currentBudget NUMERIC; _priorBudget NUMERIC; _result NUMERIC; BEGIN SELECT accnt_type INTO _accntType FROM accnt WHERE (accnt_id=pAccntId); SELECT COALESCE(SUM(budget_amount),0) INTO _currentBudget FROM budget WHERE ((budget_accnt_id=pAccntId) AND (budget_period_id=pPeriodId)); IF (pInterval='M') THEN SELECT (COALESCE(SUM(budget_amount),0)) INTO _priorBudget FROM budget, (SELECT COALESCE(pp.period_id,-1) AS prior_period_id FROM period cp, period pp WHERE ((cp.period_id=pPeriodId) AND (cp.period_start > pp.period_start)) ORDER BY pp.period_start DESC LIMIT 1) AS data WHERE ((budget_accnt_id=pAccntId) AND (budget_period_id=prior_period_id)); ELSE IF (pInterval='Q') THEN SELECT (COALESCE(SUM(budget_amount),0)) INTO _priorBudget FROM budget, (SELECT COALESCE(pp.period_id,-1) AS prior_period_id FROM period cp, period pp WHERE ((cp.period_id=pPeriodId) AND (cp.period_start > pp.period_start) AND (pp.period_quarter= CASE WHEN cp.period_quarter > 1 THEN cp.period_quarter - 1 ELSE 4 END) AND (pp.period_start >= cp.period_start - interval '1 year')) ORDER BY pp.period_start DESC LIMIT 1) AS data WHERE ((budget_accnt_id=pAccntId) AND (budget_period_id=prior_period_id)); ELSE SELECT (COALESCE(SUM(budget_amount),0)) INTO _priorBudget FROM budget, (SELECT pp.period_id AS prior_period_id FROM period cp, period pp, yearperiod cy, yearperiod py WHERE ((cp.period_id=pPeriodId) AND (cp.period_yearperiod_id=cy.yearperiod_id) AND (pp.period_yearperiod_id=py.yearperiod_id) AND (cy.yearperiod_start > py.yearperiod_start)) ORDER BY pp.period_start DESC LIMIT 1) AS data WHERE ((budget_accnt_id=pAccntId) AND (budget_period_id=prior_period_id)); END IF; END IF; IF _accntType='A' THEN _result := ((_priorBudget-_currentBudget) * -1 ); ELSE IF (_accntType IN ('L','Q')) THEN _result := ((_priorBudget-_currentBudget) *-1); ELSE RETURN -1; END IF; END IF; RETURN _result; END; $_$; BDROP FUNCTION public.calccashbudget(integer, integer, character); publicadminfalse46238P125578018calccmheadamt(integer)FUNCTIONCREATE FUNCTION calccmheadamt(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmheadid ALIAS FOR $1; _amount NUMERIC := 0; BEGIN SELECT SUM(COALESCE(extprice, 0)) INTO _amount FROM cmhead JOIN creditmemoitem ON (cmhead_id=cmitem_cmhead_id) WHERE (cmhead_id=pCmheadid); RETURN _amount; END; $_$; -DROP FUNCTION public.calccmheadamt(integer); publicadminfalse46238.125578019calccmheadtax(integer)FUNCTIONCREATE FUNCTION calccmheadtax(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmheadid ALIAS FOR $1; _headamount NUMERIC := 0; _itemamount NUMERIC := 0; _amount NUMERIC := 0; BEGIN SELECT COALESCE(SUM(taxhist_tax), 0) INTO _headamount FROM cmhead JOIN cmheadtax ON (taxhist_parent_id=cmhead_id) WHERE (cmhead_id=pCmheadid); SELECT SUM(COALESCE(tax, 0)) INTO _itemamount FROM cmhead JOIN creditmemoitem ON (cmhead_id=cmitem_cmhead_id) WHERE (cmhead_id=pCmheadid); _amount := _headamount + _itemamount; RETURN (_amount * -1.0); END; $_$; -DROP FUNCTION public.calccmheadtax(integer); publicadminfalse84623K125578020calccobillamt(integer)FUNCTION'CREATE FUNCTION calccobillamt(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCobillid ALIAS FOR $1; _amount NUMERIC := 0; BEGIN SELECT COALESCE(round((cobill_qty * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio), 2), 0) INTO _amount FROM cobill JOIN coitem ON (coitem_id=cobill_coitem_id) WHERE (cobill_id=pCobillid); RETURN _amount; END; $_$; -DROP FUNCTION public.calccobillamt(integer); publicadminfalse46238L125578021calccobilltax(integer)FUNCTIONCREATE FUNCTION calccobilltax(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCobillid ALIAS FOR $1; _amount NUMERIC := 0; BEGIN SELECT COALESCE(calculateTax(cobmisc_taxzone_id, cobill_taxtype_id, cobmisc_shipdate, cobmisc_curr_id, calcCobillAmt(cobill_id)), 0) INTO _amount FROM cobill JOIN coitem ON (coitem_id=cobill_coitem_id) JOIN cobmisc ON (cobmisc_id=cobill_cobmisc_id) WHERE (cobill_id=pCobillid); RETURN _amount; END; $_$; -DROP FUNCTION public.calccobilltax(integer); publicadminfalse84623M125578022calccobmiscamt(integer)FUNCTIONCREATE FUNCTION calccobmiscamt(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCobmiscid ALIAS FOR $1; _amount NUMERIC := 0; BEGIN SELECT SUM(COALESCE(calcCobillAmt(cobill_id), 0)) INTO _amount FROM cobmisc JOIN cobill ON (cobmisc_id=cobill_cobmisc_id) WHERE (cobmisc_id=pCobmiscid); RETURN _amount; END; $_$; .DROP FUNCTION public.calccobmiscamt(integer); publicadminfalse46238N125578023calccobmisctax(integer)FUNCTION`CREATE FUNCTION calccobmisctax(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCobmiscid ALIAS FOR $1; _amount NUMERIC := 0; BEGIN SELECT SUM( COALESCE(calculateTax(cobmisc_taxzone_id, cobill_taxtype_id, cobmisc_shipdate, cobmisc_curr_id, COALESCE(round((cobill_qty * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio), 2), 0)) , 0) ) INTO _amount FROM cobmisc JOIN cobill ON (cobmisc_id=cobill_cobmisc_id) JOIN coitem ON (coitem_id=cobill_coitem_id) WHERE (cobmisc_id=pCobmiscid); RETURN _amount; END; $_$; .DROP FUNCTION public.calccobmisctax(integer); publicadminfalse46238Q125578024calcinvoiceamt(integer)FUNCTION&CREATE FUNCTION calcinvoiceamt(pinvcheadid integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN calcInvoiceAmt(pInvcheadid, 'T'); END; $$; :DROP FUNCTION public.calcinvoiceamt(pinvcheadid integer); publicadminfalse46238R125578025calcinvoiceamt(integer, text)FUNCTIONlCREATE FUNCTION calcinvoiceamt(pinvcheadid integer, ptype text) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _subtotal NUMERIC := 0.0; _cost NUMERIC := 0.0; _tax NUMERIC := 0.0; _freight NUMERIC := 0.0; _misc NUMERIC := 0.0; _amount NUMERIC := 0.0; BEGIN -- pType: S = line item subtotal -- T = total -- X = tax -- M = margin SELECT COALESCE(SUM(ROUND((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / COALESCE(invcitem_price_invuomratio, 1.0)), 2)), 0.0), COALESCE(SUM(ROUND((invcitem_billed * invcitem_qty_invuomratio) * (currtolocal(invchead_curr_id, COALESCE(coitem_unitcost, itemCost(itemsite_id), 0.0), invchead_invcdate) / COALESCE(coitem_price_invuomratio, 1.0)), 2)), 0.0) INTO _subtotal, _cost FROM invcitem JOIN invchead ON (invchead_id = invcitem_invchead_id) LEFT OUTER JOIN coitem ON (coitem_id=invcitem_coitem_id) LEFT OUTER JOIN itemsite ON (itemsite_item_id=invcitem_item_id AND itemsite_warehous_id=invcitem_warehous_id) WHERE (invcitem_invchead_id=pInvcheadid); IF (pType IN ('T', 'X')) THEN SELECT COALESCE(SUM(tax), 0.0) INTO _tax FROM (SELECT COALESCE(ROUND(SUM(taxdetail_tax), 2), 0.0) AS tax FROM tax JOIN calculateTaxDetailSummary('I', pInvcheadid, 'T')ON (taxdetail_tax_id=tax_id) GROUP BY tax_id) AS data; END IF; IF (pType = 'T') THEN SELECT COALESCE(invchead_freight, 0), COALESCE(invchead_misc_amount, 0) INTO _freight, _misc FROM invchead WHERE (invchead_id=pinvcheadid); END IF; _amount := CASE pType WHEN 'S' THEN (_subtotal) WHEN 'T' THEN (_subtotal + _tax + _freight + _misc) WHEN 'X' THEN (_tax) WHEN 'M' THEN (_subtotal - _cost) ELSE 0.0 END; RETURN _amount; END; $$; FDROP FUNCTION public.calcinvoiceamt(pinvcheadid integer, ptype text); publicadminfalse46238S125578026"calcpendingarapplications(integer)FUNCTIONCREATE FUNCTION calcpendingarapplications(integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE paropenid ALIAS FOR $1; _arcreditsum NUMERIC; _aropencurrid INTEGER; _cashrcptsum NUMERIC; _sense INTEGER; BEGIN SELECT aropen_curr_id, (CASE WHEN aropen_doctype IN ('I','D') THEN 1 ELSE -1 END) INTO _aropencurrid, _sense FROM aropen WHERE (aropen_id=paropenid); SELECT SUM(currToCurr(cashrcpt_curr_id, _aropencurrid, cashrcptitem_amount + cashrcptitem_discount, coalesce(cashrcpt_applydate, cashrcpt_distdate))) * _sense INTO _cashrcptsum FROM cashrcptitem, cashrcpt WHERE ((cashrcptitem_cashrcpt_id=cashrcpt_id) AND (NOT cashrcpt_posted) AND (NOT cashrcpt_void) AND (cashrcptitem_aropen_id=paropenid) ); SELECT SUM(currToCurr(arcreditapply_curr_id, _aropencurrid, arcreditapply_amount, CURRENT_DATE)) INTO _arcreditsum FROM arcreditapply WHERE ((arcreditapply_target_aropen_id=paropenid) ); RETURN round(COALESCE(_cashrcptsum, 0) + COALESCE(_arcreditsum, 0),2); END; $_$; 9DROP FUNCTION public.calcpendingarapplications(integer); publicadminfalse84623125578027calcpurchaseorderamt(integer)FUNCTION&CREATE FUNCTION calcpurchaseorderamt(ppoheadid integer) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN calcPurchaseOrderAmt(pPoheadid, 'T'); END; $$; >DROP FUNCTION public.calcpurchaseorderamt(ppoheadid integer); publicadminfalse84623125578028#calcpurchaseorderamt(integer, text)FUNCTIONCREATE FUNCTION calcpurchaseorderamt(ppoheadid integer, ptype text) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _subtotal NUMERIC := 0; _freightsub NUMERIC := 0; _tax NUMERIC := 0; _freight NUMERIC := 0; _currid INTEGER := 0; _effdate DATE := CURRENT_DATE; _amount NUMERIC := 0; BEGIN -- pType: S = line item subtotal -- T = total -- X = tax SELECT COALESCE(SUM(ROUND(poitem_qty_ordered * poitem_unitprice, 2)), 0), COALESCE(SUM(ROUND(poitem_freight, 2)), 0) INTO _subtotal, _freightsub FROM poitem WHERE (poitem_pohead_id=pPoheadid); SELECT COALESCE(SUM(tax), 0) INTO _tax FROM ( SELECT COALESCE(ROUND(SUM(taxdetail_tax), 2), 0.0) AS tax FROM tax JOIN calculateTaxDetailSummary('PO', pPoheadid, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id ) AS data; SELECT COALESCE(pohead_freight, 0), pohead_curr_id, pohead_orderdate INTO _freight, _currid, _effdate FROM pohead WHERE (pohead_id=pPoheadid); _amount := currToBase(_currid, CASE pType WHEN 'S' THEN (_subtotal) WHEN 'T' THEN (_subtotal + _tax + _freight + _freightsub) WHEN 'X' THEN (_tax) ELSE 0.0 END, _effdate); RETURN _amount; END; $$; JDROP FUNCTION public.calcpurchaseorderamt(ppoheadid integer, ptype text); publicadminfalse84623125578029!calcpurchaseorderduedate(integer)FUNCTIONCREATE FUNCTION calcpurchaseorderduedate(ppoheadid integer) RETURNS date LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _result DATE; BEGIN SELECT MIN(poitem_duedate) INTO _result FROM poitem WHERE (poitem_pohead_id=pPoheadid); RETURN _result; END; $$; BDROP FUNCTION public.calcpurchaseorderduedate(ppoheadid integer); publicadminfalse84623T125578030calcquoteamt(integer)FUNCTIONCREATE FUNCTION calcquoteamt(pquheadid integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN calcQuoteAmt(pQuheadid, 'T'); END; $$; 6DROP FUNCTION public.calcquoteamt(pquheadid integer); publicadminfalse84623U125578031calcquoteamt(integer, text)FUNCTIONCREATE FUNCTION calcquoteamt(pquheadid integer, ptype text) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _subtotal NUMERIC := 0.0; _cost NUMERIC := 0.0; _tax NUMERIC := 0.0; _freight NUMERIC := 0.0; _misc NUMERIC := 0.0; _amount NUMERIC := 0.0; BEGIN -- pType: S = line item subtotal -- T = total -- X = tax -- M = margin SELECT COALESCE(SUM(ROUND((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio), 2)), 0.0), COALESCE(SUM(ROUND((quitem_qtyord * quitem_qty_invuomratio) * (quitem_unitcost / quitem_price_invuomratio), 2)), 0.0) INTO _subtotal, _cost FROM quitem WHERE (quitem_quhead_id=pQuheadid); IF (pType IN ('T', 'X')) THEN SELECT COALESCE(SUM(tax), 0.0) INTO _tax FROM (SELECT COALESCE(ROUND(SUM(taxdetail_tax), 2), 0.0) AS tax FROM tax JOIN calculateTaxDetailSummary('Q', pQuheadid, 'T')ON (taxdetail_tax_id=tax_id) GROUP BY tax_id) AS data; END IF; IF (pType = 'T') THEN SELECT COALESCE(quhead_freight, 0), COALESCE(quhead_misc, 0) INTO _freight, _misc FROM quhead WHERE (quhead_id=pQuheadid); END IF; _amount := CASE pType WHEN 'S' THEN (_subtotal) WHEN 'T' THEN (_subtotal + _tax + _freight + _misc) WHEN 'X' THEN (_tax) WHEN 'M' THEN (_subtotal - _cost) ELSE 0.0 END; RETURN _amount; END; $$; BDROP FUNCTION public.calcquoteamt(pquheadid integer, ptype text); publicadminfalse84623V125578032calcsalesorderamt(integer)FUNCTION(CREATE FUNCTION calcsalesorderamt(pcoheadid integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN calcSalesOrderAmt(pCoheadid, 'T'); END; $$; ;DROP FUNCTION public.calcsalesorderamt(pcoheadid integer); publicadminfalse46238W125578033 calcsalesorderamt(integer, text)FUNCTION> CREATE FUNCTION calcsalesorderamt(pcoheadid integer, ptype text) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _subtotal NUMERIC := 0.0; _cost NUMERIC := 0.0; _tax NUMERIC := 0.0; _freight NUMERIC := 0.0; _misc NUMERIC := 0.0; _credit NUMERIC := 0.0; _amount NUMERIC := 0.0; BEGIN -- pType: S = line item subtotal -- T = total -- B = balance due -- C = allocated credits -- X = tax -- M = margin SELECT COALESCE(SUM(ROUND((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio), 2)), 0.0), COALESCE(SUM(ROUND((coitem_qtyord * coitem_qty_invuomratio) * (CASE WHEN (coitem_subnumber > 0) THEN 0.0 ELSE coitem_unitcost END / coitem_price_invuomratio), 2)), 0.0) INTO _subtotal, _cost FROM coitem WHERE (coitem_cohead_id=pCoheadid) AND (coitem_status != 'X'); IF (pType IN ('T', 'B', 'X')) THEN SELECT COALESCE(SUM(tax), 0.0) INTO _tax FROM (SELECT COALESCE(ROUND(SUM(taxdetail_tax), 2), 0.0) AS tax FROM tax JOIN calculateTaxDetailSummary('S', pCoheadid, 'T')ON (taxdetail_tax_id=tax_id) GROUP BY tax_id) AS data; END IF; IF (pType IN ('T', 'B', 'C')) THEN SELECT COALESCE(cohead_freight, 0), COALESCE(cohead_misc, 0), COALESCE(SUM(currToCurr(aropenalloc_curr_id, cohead_curr_id, aropenalloc_amount, CURRENT_DATE)),0) INTO _freight, _misc, _credit FROM cohead LEFT OUTER JOIN aropenalloc ON (aropenalloc_doctype='S' AND aropenalloc_doc_id=cohead_id) WHERE (cohead_id=pCoheadid) GROUP BY cohead_freight, cohead_misc, cohead_curr_id; END IF; _amount := CASE pType WHEN 'S' THEN (_subtotal) WHEN 'T' THEN (_subtotal + _tax + _freight + _misc) WHEN 'B' THEN (_subtotal + _tax + _freight + _misc - _credit) WHEN 'C' THEN (_credit) WHEN 'X' THEN (_tax) WHEN 'M' THEN (_subtotal - _cost) ELSE 0.0 END; RETURN _amount; END; $$; GDROP FUNCTION public.calcsalesorderamt(pcoheadid integer, ptype text); publicadminfalse84623125578034calcshipfreight(integer)FUNCTION7CREATE FUNCTION calcshipfreight(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipheadId ALIAS FOR $1; _result NUMERIC := 0; _order RECORD; _shipment RECORD; _weights RECORD; _price RECORD; _sales RECORD; _freightid INTEGER; _totalprice NUMERIC; _includepkgweight BOOLEAN := FALSE; _freight RECORD; _debug BOOLEAN := false; BEGIN --Get shipment SELECT shiphead_order_id, shiphead_order_type, shiphead_freight INTO _shipment FROM shiphead WHERE (shiphead_id=pShipheadId); IF (NOT FOUND) THEN RAISE EXCEPTION 'Shipment not found'; END IF; IF (_shipment.shiphead_order_type = 'SO') THEN --Sales Orders --Get the order header information SELECT cust_id AS cust_id, custtype_id, custtype_code, shipto_id, shipto_num, cohead_orderdate AS orderdate, cohead_shipvia AS shipvia, shipto_shipzone_id AS shipzone_id, cohead_curr_id AS curr_id, currConcat(cohead_curr_id) AS currAbbr, cohead_calcfreight, cohead_freight INTO _order FROM cohead JOIN custinfo ON (cust_id=cohead_cust_id) JOIN custtype ON (custtype_id=cust_custtype_id) LEFT OUTER JOIN shiptoinfo ON (shipto_id=cohead_shipto_id) WHERE (cohead_id=_shipment.shiphead_order_id); IF (NOT FOUND) THEN RAISE EXCEPTION 'Order not found'; END IF; IF (_debug) THEN RAISE NOTICE 'cust_id = %', _order.cust_id; RAISE NOTICE 'custtype_id = %', _order.custtype_id; RAISE NOTICE 'shipto_id = %', _order.shipto_id; RAISE NOTICE 'shipto_num = %', _order.shipto_num; RAISE NOTICE 'orderdate = %', _order.orderdate; RAISE NOTICE 'shipvia = %', _order.shipvia; RAISE NOTICE 'shipzone_id = %', _order.shipzone_id; RAISE NOTICE 'curr_id = %', _order.curr_id; RAISE NOTICE 'currAbbr = %', _order.currAbbr; RAISE NOTICE 'calcfreight = %', _order.cohead_calcfreight; RAISE NOTICE 'freight = %', _order.cohead_freight; END IF; IF (NOT _order.cohead_calcfreight) THEN SELECT noNeg( _order.cohead_freight - COALESCE((SELECT SUM(shiphead_freight) FROM shiphead WHERE (shiphead_order_id = _shipment.shiphead_order_id) AND (shiphead_shipped='true')), 0) ) INTO _result; RETURN _result; END IF; SELECT fetchMetricBool('IncludePackageWeight') INTO _includepkgweight; --Calculate Sales Order freight --Get a list of aggregated weights from sites and --freight classes used on order lines FOR _weights IN SELECT CASE WHEN (_includePkgWeight) THEN SUM(shipitem_qty * (item_prodweight + item_packweight)) ELSE SUM(shipitem_qty * item_prodweight) END AS weight, itemsite_warehous_id, item_freightclass_id FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id) JOIN coitem ON (shipitem_orderitem_id=coitem_id) JOIN itemsite ON (itemsite_id=coitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE ( (shiphead_id=pShipheadId) AND (item_freightclass_id IS NOT NULL) ) GROUP BY itemsite_warehous_id, item_freightclass_id LOOP IF (_debug) THEN RAISE NOTICE '_weights.weight - %', _weights.weight; RAISE NOTICE '_weights.itemsite_warehous_id = %', _weights.itemsite_warehous_id; RAISE NOTICE '_weights.item_freightclass_id = %', _weights.item_freightclass_id; END IF; -- First get a sales price if any so we when we find other prices -- we can determine if we want that price or this price. -- Check for a Sale Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, _order.curr_id, ipsfreight_price, _order.orderdate) ELSE currToCurr(ipshead_curr_id, _order.curr_id, (_weights.weight * ipsfreight_price), _order.orderdate) END AS price INTO _sales FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN sale ON (sale_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= _weights.weight) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=_weights.itemsite_warehous_id)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=_weights.item_freightclass_id)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=_order.shipzone_id)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=_order.shipvia)) AND (CURRENT_DATE BETWEEN sale_startdate AND sale_enddate) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_sales.price IS NOT NULL) THEN RAISE NOTICE 'Sales Price found, %', _sales.price; END IF; END IF; -- Check for a Customer Shipto Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, _order.curr_id, ipsfreight_price, _order.orderdate) ELSE currToCurr(ipshead_curr_id, _order.curr_id, (_weights.weight * ipsfreight_price), _order.orderdate) END AS price INTO _price FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= _weights.weight) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=_weights.itemsite_warehous_id)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=_weights.item_freightclass_id)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=_order.shipzone_id)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=_order.shipvia)) AND (CURRENT_DATE BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsass_shipto_id != -1) AND (ipsass_shipto_id=_order.shipto_id) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_price.price IS NOT NULL) THEN RAISE NOTICE 'Customer Shipto Price found, %', _price.price; END IF; END IF; IF (_price.price IS NULL) THEN -- Check for a Customer Shipto Pattern Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, _order.curr_id, ipsfreight_price, _order.orderdate) ELSE currToCurr(ipshead_curr_id, _order.curr_id, (_weights.weight * ipsfreight_price), _order.orderdate) END AS price INTO _price FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= _weights.weight) AND (CURRENT_DATE BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsass_cust_id=_order.cust_id) AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) AND (_order.shipto_num ~ ipsass_shipto_pattern) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=_weights.itemsite_warehous_id)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=_weights.item_freightclass_id)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=_order.shipzone_id)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=_order.shipvia)) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_price.price IS NOT NULL) THEN RAISE NOTICE 'Customer Shipto Pattern Price found, %', _price.price; END IF; END IF; END IF; IF (_price.price IS NULL) THEN -- Check for a Customer Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, _order.curr_id, ipsfreight_price, _order.orderdate) ELSE currToCurr(ipshead_curr_id, _order.curr_id, (_weights.weight * ipsfreight_price), _order.orderdate) END AS price INTO _price FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= _weights.weight) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=_weights.itemsite_warehous_id)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=_weights.item_freightclass_id)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=_order.shipzone_id)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=_order.shipvia)) AND (CURRENT_DATE BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsass_cust_id=_order.cust_id) AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) = 0) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_price.price IS NOT NULL) THEN RAISE NOTICE 'Customer Price found, %', _price.price; END IF; END IF; END IF; IF (_price.price IS NULL) THEN -- Check for a Customer Type Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, _order.curr_id, ipsfreight_price, _order.orderdate) ELSE currToCurr(ipshead_curr_id, _order.curr_id, (_weights.weight * ipsfreight_price), _order.orderdate) END AS price INTO _price FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= _weights.weight) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=_weights.itemsite_warehous_id)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=_weights.item_freightclass_id)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=_order.shipzone_id)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=_order.shipvia)) AND (CURRENT_DATE BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsass_custtype_id=_order.custtype_id) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_price.price IS NOT NULL) THEN RAISE NOTICE 'Customer Type Price found, %', _price.price; END IF; END IF; END IF; IF (_price.price IS NULL) THEN -- Check for a Customer Type Pattern Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, _order.curr_id, ipsfreight_price, _order.orderdate) ELSE currToCurr(ipshead_curr_id, _order.curr_id, (_weights.weight * ipsfreight_price), _order.orderdate) END AS price INTO _price FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= _weights.weight) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=_weights.itemsite_warehous_id)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=_weights.item_freightclass_id)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=_order.shipzone_id)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=_order.shipvia)) AND (CURRENT_DATE BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) AND (_order.custtype_code ~ ipsass_custtype_pattern) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_price.price IS NOT NULL) THEN RAISE NOTICE 'Customer Type Pattern Price found, %', _price.price; END IF; END IF; END IF; -- Select the lowest price IF ( (_price.price IS NOT NULL) AND ((_sales.price IS NULL) OR (_price.price < _sales.price)) ) THEN _freightid := _price.ipsfreight_id; _totalprice := _price.price; ELSE IF ( (_sales.price IS NOT NULL) AND ((_price.price IS NULL) OR (_sales.price <= _price.price)) ) THEN _freightid := _sales.ipsfreight_id; _totalprice := _sales.price; END IF; END IF; -- Total IF (_freightid IS NOT NULL) THEN _result := _result + _totalprice; END IF; END LOOP; RETURN ROUND(_result,2); END IF; IF (_shipment.shiphead_order_type = 'TO') THEN --Transfer Orders SELECT noNeg( (SELECT SUM(toitem_freight) + tohead_freight FROM tohead, toitem WHERE (toitem_tohead_id=tohead_id) AND (tohead_id = _shipment.shiphead_order_id) GROUP BY tohead_freight) - COALESCE((SELECT SUM(shiphead_freight) FROM shiphead WHERE (shiphead_order_id = _shipment.shiphead_order_id) AND (shiphead_shipped='true')), 0) ) INTO _result; RETURN _result; END IF; RETURN _result; END; $_$; /DROP FUNCTION public.calcshipfreight(integer); publicadminfalse84623X125578036calctotalslipqty(integer)FUNCTIONCREATE FUNCTION calctotalslipqty(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTagid ALIAS FOR $1; _qty NUMERIC := 0; BEGIN SELECT SUM(COALESCE(cntslip_qty, 0.0)) INTO _qty FROM cntslip WHERE (cntslip_cnttag_id=pTagid); RETURN _qty; END; $_$; 0DROP FUNCTION public.calctotalslipqty(integer); publicadminfalse46238Y125586977calculatefreightdetail(integer, integer, text, integer, integer, text, date, text, integer, character varying, integer, integer, numeric)FUNCTION)CREATE FUNCTION calculatefreightdetail(integer, integer, text, integer, integer, text, date, text, integer, character varying, integer, integer, numeric) RETURNS SETOF freightdata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustId ALIAS FOR $1; pCustTypeId ALIAS FOR $2; pCustTypeCode ALIAS FOR $3; pShiptoId ALIAS FOR $4; pShipZoneId ALIAS FOR $5; pShiptoNum ALIAS FOR $6; pOrderDate ALIAS FOR $7; pShipVia ALIAS FOR $8; pCurrId ALIAS FOR $9; pCurrAbbr ALIAS FOR $10; pItemSiteWhsId ALIAS FOR $11; pItemFreightclassId ALIAS FOR $12; pWeight ALIAS FOR $13; _row freightData%ROWTYPE; _price RECORD; _sales RECORD; _freightid INTEGER; _totalprice NUMERIC; _asof DATE; _debug BOOLEAN := FALSE; BEGIN --Get pricing effectivity metric IF (SELECT fetchMetricText('soPriceEffective') = 'OrderDate') THEN _asof := pOrderDate; ELSE _asof := CURRENT_DATE; END IF; _freightid := NULL; _totalprice := 0.0; IF (_debug) THEN RAISE NOTICE 'pWeight - %', pWeight; RAISE NOTICE 'pItemSiteWhsId = %', pItemSiteWhsId; RAISE NOTICE 'pItemFreightclassId = %', pItemFreightclassId; END IF; -- First get a sales price if any so when we find other prices -- we can determine if we want that price or this sales price. -- Check for a Sale Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, pCurrId, ipsfreight_price, pOrderDate) ELSE currToCurr(ipshead_curr_id, pCurrId, (pWeight * ipsfreight_price), pOrderDate) END AS price INTO _sales FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN sale ON (sale_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= pWeight) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=pItemSiteWhsId)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=pItemFreightclassId)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=pShipZoneId)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=pShipVia)) AND (_asof BETWEEN sale_startdate AND sale_enddate) AND (pCustId IS NOT NULL) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_sales.price IS NOT NULL) THEN RAISE NOTICE 'Sales Price found, %', _sales.price; END IF; END IF; -- Check for a Customer Shipto Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, pCurrId, ipsfreight_price, pOrderDate) ELSE currToCurr(ipshead_curr_id, pCurrId, (pWeight * ipsfreight_price), pOrderDate) END AS price INTO _price FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= pWeight) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=pItemSiteWhsId)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=pItemFreightclassId)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=pShipZoneId)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=pShipVia)) AND (_asof BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsass_shipto_id != -1) AND (ipsass_shipto_id=pShiptoId) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_price.price IS NOT NULL) THEN RAISE NOTICE 'Customer Shipto Price found, %', _price.price; END IF; END IF; IF (_price.price IS NULL) THEN -- Check for a Customer Shipto Pattern Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, pCurrId, ipsfreight_price, pOrderDate) ELSE currToCurr(ipshead_curr_id, pCurrId, (pWeight * ipsfreight_price), pOrderDate) END AS price INTO _price FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= pWeight) AND (_asof BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsass_cust_id=pCustId) AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) AND (pShiptoNum ~ ipsass_shipto_pattern) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=pItemSiteWhsId)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=pItemFreightclassId)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=pShipZoneId)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=pShipVia)) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_price.price IS NOT NULL) THEN RAISE NOTICE 'Customer Shipto Pattern Price found, %', _price.price; END IF; END IF; END IF; IF (_price.price IS NULL) THEN -- Check for a Customer Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, pCurrId, ipsfreight_price, pOrderDate) ELSE currToCurr(ipshead_curr_id, pCurrId, (pWeight * ipsfreight_price), pOrderDate) END AS price INTO _price FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= pWeight) AND((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=pItemSiteWhsId)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=pItemFreightclassId)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=pShipZoneId)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=pShipVia)) AND (_asof BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsass_cust_id=pCustId) AND (COALESCE(LENGTH(ipsass_shipto_pattern), 0) = 0) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_price.price IS NOT NULL) THEN RAISE NOTICE 'Customer Price found, %', _price.price; END IF; END IF; END IF; IF (_price.price IS NULL) THEN -- Check for a Customer Type Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, pCurrId, ipsfreight_price, pOrderDate) ELSE currToCurr(ipshead_curr_id, pCurrId, (pWeight * ipsfreight_price), pOrderDate) END AS price INTO _price FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= pWeight) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=pItemSiteWhsId)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=pItemFreightclassId)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=pShipZoneId)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=pShipVia)) AND (_asof BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsass_custtype_id=pCustTypeId) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_price.price IS NOT NULL) THEN RAISE NOTICE 'Customer Type Price found, %', _price.price; END IF; END IF; END IF; IF (_price.price IS NULL) THEN -- Check for a Customer Type Pattern Price SELECT ipsfreight_id, CASE WHEN (ipsfreight_type='F') THEN currToCurr(ipshead_curr_id, pCurrId, ipsfreight_price, pOrderDate) ELSE currToCurr(ipshead_curr_id, pCurrId, (pWeight * ipsfreight_price), pOrderDate) END AS price INTO _price FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE ( (ipsfreight_qtybreak <= pWeight) AND ((ipsfreight_warehous_id IS NULL) OR (ipsfreight_warehous_id=pItemSiteWhsId)) AND ((ipsfreight_freightclass_id IS NULL) OR (ipsfreight_freightclass_id=pItemFreightclassId)) AND ((ipsfreight_shipzone_id IS NULL) OR (ipsfreight_shipzone_id=pShipZoneId)) AND ((ipsfreight_shipvia IS NULL) OR (ipsfreight_shipvia=pShipVia)) AND (_asof BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) AND (pCustTypeCode ~ ipsass_custtype_pattern) ) ORDER BY ipsfreight_qtybreak DESC, price ASC LIMIT 1; IF (_debug) THEN IF (_price.price IS NOT NULL) THEN RAISE NOTICE 'Customer Type Pattern Price found, %', _price.price; END IF; END IF; END IF; -- Select the lowest price IF ( (_price.price IS NOT NULL) AND ((_sales.price IS NULL) OR (_price.price < _sales.price)) ) THEN _freightid := _price.ipsfreight_id; _totalprice := _price.price; ELSE IF ( (_sales.price IS NOT NULL) AND ((_price.price IS NULL) OR (_sales.price <= _price.price)) ) THEN _freightid := _sales.ipsfreight_id; _totalprice := _sales.price; END IF; END IF; IF (_debug) THEN RAISE NOTICE '_freightid = %', _freightid; RAISE NOTICE '_totalprice = %', _totalprice; END IF; -- Get information for the selected ipsfreight -- and return IF (_freightid IS NULL) THEN _row.freightdata_schedule := 'N/A'; _row.freightdata_from := ''; _row.freightdata_to := ''; _row.freightdata_shipvia := ''; _row.freightdata_freightclass := ''; _row.freightdata_weight := 0; _row.freightdata_uom := ''; _row.freightdata_price := 0; _row.freightdata_type := ''; _row.freightdata_total := 0; _row.freightdata_currency := ''; RETURN NEXT _row; ELSE SELECT ipshead_name AS freightdata_schedule, COALESCE(warehous_code, 'Any') AS freightdata_from, COALESCE(shipzone_name, 'Any') AS freightdata_to, COALESCE(ipsfreight_shipvia, 'Any') AS freightdata_shipvia, COALESCE(freightclass_code, 'Any') AS freightdata_freightclass, pWeight AS freightdata_weight, uom_name AS freightdata_uom, currToCurr(ipshead_curr_id, pCurrId, ipsfreight_price, pOrderDate) AS freightdata_price, CASE WHEN (ipsfreight_type='F') THEN 'Flat Rate' ELSE 'Per UOM' END AS freightdata_type, _totalprice AS freightdata_total, pCurrAbbr AS freightdata_currency INTO _row FROM ipsfreight JOIN ipshead ON (ipshead_id=ipsfreight_ipshead_id) LEFT OUTER JOIN uom ON (uom_item_weight) LEFT OUTER JOIN whsinfo ON (warehous_id=ipsfreight_warehous_id) LEFT OUTER JOIN shipzone ON (shipzone_id=ipsfreight_shipzone_id) LEFT OUTER JOIN freightclass ON (freightclass_id=ipsfreight_freightclass_id) WHERE (ipsfreight_id=_freightid); RETURN NEXT _row; END IF; RETURN; END; $_$; DROP FUNCTION public.calculatefreightdetail(integer, integer, text, integer, integer, text, date, text, integer, character varying, integer, integer, numeric); publicadminfalse424946238\1255869799calculatesubtax(integer, date, integer, numeric, integer)FUNCTION6 CREATE FUNCTION calculatesubtax(integer, date, integer, numeric, integer) RETURNS SETOF taxdetail LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxCodeId ALIAS FOR $1; pDate ALIAS FOR $2; pCurrId ALIAS FOR $3; pAmount ALIAS FOR $4; pLevel ALIAS FOR $5; _row taxdetail%ROWTYPE; _rownumber INTEGER := 1; _calc_tax Numeric :=0; _x RECORD; _y RECORD; BEGIN FOR _x IN SELECT tax_id, tax_code, tax_descrip, tax_basis_tax_id, taxrate_id, taxrate_percent, taxrate_curr_id, taxrate_amount, taxclass_id, taxclass_code, COALESCE(taxclass_sequence,0) AS taxclass_sequence, curr_id, curr_abbr FROM tax, taxrate, taxclass, curr_symbol WHERE ((tax_id = taxrate_tax_id) AND (tax_taxclass_id = taxclass_id) AND (taxrate_curr_id = curr_id) AND (tax_basis_tax_id = pTaxCodeId) AND (pDate BETWEEN taxrate_effective AND taxrate_expires) AND (taxrate_curr_id = pCurrId)) LOOP SELECT ROUND((_x.taxrate_percent * pAmount + currToCurr(_x.curr_id, pCurrId, _x.taxrate_amount, pDate)), 6) INTO _calc_tax; _row.taxdetail_tax_id = _x.tax_id; _row.taxdetail_tax_code = _x.tax_code; _row.taxdetail_tax_descrip = _x.tax_descrip; _row.taxdetail_tax_basis_tax_id = _x.tax_basis_tax_id ; _row.taxdetail_taxrate_percent = _x.taxrate_percent; _row.taxdetail_taxrate_amount = _x.taxrate_amount; _row.taxdetail_level = pLevel + 1; _row.taxdetail_taxclass_id = _x.taxclass_id ; _row.taxdetail_taxclass_code = _x.taxclass_code; _row.taxdetail_taxclass_sequence = _x.taxclass_sequence; _row.taxdetail_tax = _calc_tax; _row.taxdetail_curr_id = _x.curr_id; _row.taxdetail_curr_abbr = _x.curr_abbr; RETURN NEXT _row; _rownumber := _rownumber + 1; FOR _y IN SELECT * FROM calculateSubTax( _x.tax_id, pDate, pCurrId, _calc_tax, pLevel + 1) LOOP _row.taxdetail_tax_id = _y.taxdetail_tax_id; _row.taxdetail_tax_code = _y.taxdetail_tax_code; _row.taxdetail_tax_descrip = _y.taxdetail_tax_descrip; _row.taxdetail_tax_basis_tax_id = _y.taxdetail_tax_basis_tax_id ; _row.taxdetail_taxrate_percent = _y.taxdetail_taxrate_percent; _row.taxdetail_taxrate_amount = _y.taxdetail_taxrate_amount; _row.taxdetail_level = _y.taxdetail_level + 1; _row.taxdetail_taxclass_id = _y.taxdetail_taxclass_id ; _row.taxdetail_taxclass_code = _y.taxdetail_taxclass_code; _row.taxdetail_taxclass_sequence = _y.taxdetail_taxclass_sequence; _row.taxdetail_tax = _y.taxdetail_tax; _row.taxdetail_curr_id = _y.taxdetail_curr_id; _row.taxdetail_curr_abbr = _y.taxdetail_curr_abbr; RETURN NEXT _row; _rownumber := _rownumber + 1; END LOOP; END LOOP; END; $_$; PDROP FUNCTION public.calculatesubtax(integer, date, integer, numeric, integer); publicadminfalse462342708]1255780406calculatetax(integer, integer, date, integer, numeric)FUNCTION]CREATE FUNCTION calculatetax(integer, integer, date, integer, numeric) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxZoneId ALIAS FOR $1; pTaxTypeId ALIAS FOR $2; pDate ALIAS FOR $3; pCurrId ALIAS FOR $4; pAmount ALIAS FOR $5; _tottax numeric := 0; -- total tax BEGIN SELECT COALESCE(ROUND(SUM(taxdetail_tax),6),0) INTO _tottax FROM calculateTaxDetail(pTaxZoneId, pTaxTypeId, pDate, pCurrId, pAmount); RETURN _tottax; END; $_$; MDROP FUNCTION public.calculatetax(integer, integer, date, integer, numeric); publicadminfalse46238^125586980<calculatetaxdetail(integer, integer, date, integer, numeric)FUNCTIONCREATE FUNCTION calculatetaxdetail(integer, integer, date, integer, numeric) RETURNS SETOF taxdetail LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxZoneId ALIAS FOR $1; pTaxTypeId ALIAS FOR $2; pDate ALIAS FOR $3; pCurrId ALIAS FOR $4; pAmount ALIAS FOR $5; _row taxdetail%ROWTYPE; _x RECORD; _y RECORD; _z RECORD; _currcum numeric := 0; -- Current cumulative tax _currseq numeric := 0; -- Current group sequence _prevcum numeric := 0; -- Previous cumulative tax _tax numeric := 0; -- Calculated tax amount _taxbasis numeric := 0; -- Used for calculating sub taxes BEGIN IF ((COALESCE(pTaxTypeId,-1) = -1) OR (COALESCE(pTaxZoneId,-1) = -1)) THEN RETURN; END IF; SELECT DISTINCT COALESCE(taxass_taxzone_id, -1) AS taxzone_id, COALESCE(taxass_taxtype_id, -1) AS taxtype_id, taxass_tax_id, CASE WHEN ((taxass_taxzone_id IS NOT NULL) AND (taxass_taxtype_id IS NOT NULL)) THEN 0 WHEN ((taxass_taxzone_id IS NOT NULL) AND (taxass_taxtype_id IS NULL)) THEN 1 WHEN ((taxass_taxzone_id IS NULL) AND (taxass_taxtype_id IS NOT NULL)) THEN 2 ELSE 3 END AS sequence INTO _x FROM taxass WHERE ((COALESCE(taxass_taxzone_id, pTaxZoneId, -1) = COALESCE(pTaxZoneId,-1)) AND (COALESCE(taxass_taxtype_id, pTaxTypeId, -1) = COALESCE(pTaxTypeId,-1))) ORDER BY sequence LIMIT 1; --Now loop through each tax detail record and return calculated result FOR _y IN SELECT --the data required by taxdetail type. Coalesce group sequence to 0 if no class. tax_id ,tax_code ,tax_descrip ,tax_basis_tax_id ,taxrate_percent ,taxrate_amount ,0 as taxdetail_level ,taxclass_id ,taxclass_code ,COALESCE(taxclass_sequence, 0) AS taxclass_sequence ,0 as taxdetail_tax ,curr_id ,curr_abbr FROM taxass, taxclass RIGHT OUTER JOIN tax LEFT OUTER JOIN taxrate ON (taxrate_tax_id=tax_id) ON (tax_taxclass_id=taxclass_id), curr_symbol WHERE taxass_tax_id=tax_id AND taxrate_curr_id=curr_id AND COALESCE(taxass_taxzone_id, -1) = _x.taxzone_id AND COALESCE(taxass_taxtype_id, -1) = _x.taxtype_id AND pDate BETWEEN COALESCE(taxrate_effective, startoftime()) AND COALESCE(taxrate_expires, endoftime()) ORDER BY COALESCE(taxclass_sequence, 0) LOOP -- If sequence has changed, cache the previous cumulative tax IF (_currseq != _x.sequence) THEN _prevcum := _currcum; END IF; -- Calculate the tax amount. Convert currency for flat rate amounts SELECT ROUND((_y.taxrate_percent * (pAmount + _prevcum) + currToCurr(_y.curr_id, pCurrId, _y.taxrate_amount, pDate)), 6) INTO _tax FROM tax JOIN taxrate ON (tax_id = taxrate_tax_id) WHERE (tax_id=_x.taxass_tax_id) AND (pDate BETWEEN COALESCE(taxrate_effective, startoftime()) AND COALESCE(taxrate_expires, endoftime())); --Map fields to _row _row.taxdetail_tax_id := _y.tax_id; _row.taxdetail_tax_code := _y.tax_code; _row.taxdetail_tax_descrip := _y.tax_descrip; _row.taxdetail_tax_basis_tax_id := _y.tax_basis_tax_id; _row.taxdetail_taxrate_percent := _y.taxrate_percent; _row.taxdetail_taxrate_amount := _y.taxrate_amount; _row.taxdetail_level := _y.taxdetail_level; _row.taxdetail_taxclass_id := _y.taxclass_id; _row.taxdetail_taxclass_code := _y.taxclass_code; _row.taxdetail_taxclass_sequence := _y.taxclass_sequence; _row.taxdetail_tax := _tax; _row.taxdetail_curr_id := _y.curr_id; _row.taxdetail_curr_abbr := _y.curr_abbr; RETURN NEXT _row; -- Increment cumulative balance and sequence number IF(_y.taxclass_sequence <> 0) THEN _currcum := _currcum + _tax; END IF; _currseq := _y.taxclass_sequence; -- Loop to Calculate sub taxes FOR _z IN SELECT * FROM calculateSubTax(_y.tax_id,pDate, pCurrId, _tax, 0) LOOP --Mapping of data _row.taxdetail_tax_id := _z.taxdetail_tax_id; _row.taxdetail_tax_code := _z.taxdetail_tax_code; _row.taxdetail_tax_descrip := _z.taxdetail_tax_descrip; _row.taxdetail_tax_basis_tax_id := _z.taxdetail_tax_basis_tax_id; _row.taxdetail_taxrate_percent := _z.taxdetail_taxrate_percent; _row.taxdetail_taxrate_amount := _z.taxdetail_taxrate_amount; _row.taxdetail_level := _z.taxdetail_level; _row.taxdetail_taxclass_id := _z.taxdetail_taxclass_id; _row.taxdetail_taxclass_code := _z.taxdetail_taxclass_code; _row.taxdetail_taxclass_sequence := _z.taxdetail_taxclass_sequence; _row.taxdetail_tax := _z.taxdetail_tax; _row.taxdetail_curr_id := _z.taxdetail_curr_id; _row.taxdetail_curr_abbr := _z.taxdetail_curr_abbr; RETURN NEXT _row; --Add to cumulative counter (_curcum) _currcum := _currcum + _z.taxdetail_tax ; END LOOP; END LOOP; END; $_$; SDROP FUNCTION public.calculatetaxdetail(integer, integer, date, integer, numeric); publicadminfalse427084623_125586981%calculatetaxdetailline(text, integer)FUNCTIONCREATE FUNCTION calculatetaxdetailline(text, integer) RETURNS SETOF taxdetail LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOrderType ALIAS FOR $1; pOrderId ALIAS FOR $2; _row taxdetail%ROWTYPE; _qry text; _totaltax numeric; _y RECORD; _table text; BEGIN _totaltax=0.0; IF pOrderType = 'II' THEN _table := 'invcitemtax'; ELSIF pOrderType = 'BI' THEN _table := 'cobilltax'; ELSIF pOrderType = 'CI' THEN _table := 'cmitemtax'; ELSIF pOrderType = 'VI' THEN _table := 'voitemtax'; ELSIF pOrderType = 'TI' THEN _table := 'toitemtax'; ELSIF pOrderType = 'AR' THEN _table := 'aropentax'; ELSIF pOrderType = 'AP' THEN _table := 'apopentax'; END IF; _qry := 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, COALESCE(taxhist_sequence,0) AS taxhist_sequence FROM ' || _table || ' JOIN tax ON (taxhist_tax_id=tax_id) WHERE ( (taxhist_parent_id = ' || pOrderId || ') );'; FOR _y IN EXECUTE _qry LOOP _row.taxdetail_tax_id=_y.tax_id; _row.taxdetail_tax_code = _y.tax_code; _row.taxdetail_tax_descrip = _y.tax_descrip; _row.taxdetail_tax = _y.taxhist_tax; _row.taxdetail_level= 0 ; _row.taxdetail_taxclass_sequence= _y.taxhist_sequence; _totaltax = _totaltax + _y.taxhist_tax; RETURN NEXT _row; END LOOP; END; $_$; <DROP FUNCTION public.calculatetaxdetailline(text, integer); publicadminfalse842704623`125586982.calculatetaxdetailsummary(text, integer, text)FUNCTION!CREATE FUNCTION calculatetaxdetailsummary(text, integer, text) RETURNS SETOF taxdetail LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOrderType ALIAS FOR $1; pOrderId ALIAS FOR $2; pDisplayType ALIAS FOR $3; _row taxdetail%ROWTYPE; _qry text := ''; _qry1 text; _totaltax numeric; _x RECORD; _y RECORD; _table text; BEGIN _totaltax=0.0; IF pOrderType IN ('S','Q','RA','PO') THEN IF pOrderType = 'S' THEN _qry := 'SELECT ' || 'COALESCE(cohead_taxzone_id, -1) AS taxzone_id, cohead_orderdate AS order_date, cohead_curr_id AS curr_id, COALESCE(coitem_taxtype_id, -1) AS taxtype_id, ROUND((coitem_qtyord * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio),2) AS amount FROM cohead, coitem WHERE ( (coitem_cohead_id = ' || pOrderId || ') AND (' || 'cohead_id = coitem_cohead_id) AND ( coitem_status != ''X'') )'; ELSEIF pOrderType = 'Q' THEN _qry := 'SELECT ' || 'COALESCE(quhead_taxzone_id, -1) AS taxzone_id, quhead_quotedate AS order_date, quhead_curr_id AS curr_id, COALESCE(quitem_taxtype_id, -1) AS taxtype_id, ROUND((quitem_qtyord * quitem_qty_invuomratio) * (quitem_price / quitem_price_invuomratio),2) AS amount FROM quhead, quitem WHERE ( (quitem_quhead_id = ' || pOrderId || ') AND (quhead_id = quitem_quhead_id) )'; ELSEIF pOrderType = 'RA' THEN _qry := 'SELECT ' || 'COALESCE(rahead_taxzone_id, -1) AS taxzone_id, rahead_authdate AS order_date, rahead_curr_id AS curr_id, COALESCE(raitem_taxtype_id, -1) AS taxtype_id, ROUND((raitem_qtyauthorized * raitem_qty_invuomratio) * (raitem_unitprice / raitem_price_invuomratio),2) AS amount FROM rahead, raitem WHERE ( (raitem_rahead_id = ' || pOrderId || ') AND (rahead_id = raitem_rahead_id) )'; ELSEIF pOrderType = 'PO' THEN _qry := 'SELECT ' || 'COALESCE(pohead_taxzone_id, -1) AS taxzone_id, pohead_orderdate AS order_date, pohead_curr_id AS curr_id, COALESCE(poitem_taxtype_id, -1) AS taxtype_id, ROUND(poitem_qty_ordered * poitem_unitprice, 2) AS amount FROM pohead, poitem WHERE ( (poitem_pohead_id = ' || pOrderId || ') AND (pohead_id = poitem_pohead_id) )'; END IF; FOR _x IN EXECUTE _qry LOOP _qry1 := 'SELECT * from calculatetaxdetail(' || _x.taxzone_id || ',' || _x.taxtype_id || ',''' || _x.order_date || ''',' || _x.curr_id || ',' || _x.amount || ')'; FOR _y IN EXECUTE _qry1 LOOP _row.taxdetail_tax_id=_y.taxdetail_tax_id; _row.taxdetail_tax_code = _y.taxdetail_tax_code; _row.taxdetail_tax_descrip = _y.taxdetail_tax_descrip; _row.taxdetail_tax = _y.taxdetail_tax; _row.taxdetail_level=_y.taxdetail_level; _row.taxdetail_taxclass_sequence= _y.taxdetail_taxclass_sequence; _totaltax = _totaltax + _y.taxdetail_tax; RETURN NEXT _row; END LOOP; END LOOP; IF pDisplayType = 'T' AND pOrderType <> 'PO' THEN IF pOrderType = 'S' THEN _qry := 'SELECT COALESCE(cohead_taxzone_id, -1) AS taxzone_id, cohead_orderdate AS order_date, cohead_curr_id AS curr_id, cohead_freight AS freight FROM cohead WHERE cohead_id = ' || pOrderId ; ELSEIF pOrderType = 'Q' THEN _qry := 'SELECT COALESCE(quhead_taxzone_id, -1) AS taxzone_id, quhead_quotedate AS order_date, quhead_curr_id AS curr_id, COALESCE(quhead_freight,0) AS freight FROM quhead WHERE quhead_id = ' || pOrderId; ELSEIF pOrderType = 'RA' THEN _qry := 'SELECT COALESCE(rahead_taxzone_id, -1) AS taxzone_id, COALESCE(rahead_authdate,CURRENT_DATE) AS order_date, rahead_curr_id AS curr_id, COALESCE(rahead_freight,0) AS freight FROM rahead WHERE rahead_id = ' || pOrderId; END IF; FOR _x IN EXECUTE _qry LOOP _qry1 := 'SELECT * from calculatetaxdetail(' || _x.taxzone_id || ', getfreighttaxtypeid(),''' || _x.order_date || ''',' || _x.curr_id || ',' || _x.freight || ')'; FOR _y IN EXECUTE _qry1 LOOP _row.taxdetail_tax_id=_y.taxdetail_tax_id; _row.taxdetail_tax_code = _y.taxdetail_tax_code; _row.taxdetail_tax_descrip = _y.taxdetail_tax_descrip; _row.taxdetail_tax = _y.taxdetail_tax; _row.taxdetail_level=_y.taxdetail_level; _row.taxdetail_taxclass_sequence= _y.taxdetail_taxclass_sequence; _totaltax = _totaltax + _y.taxdetail_tax; RETURN NEXT _row; END LOOP; END LOOP; END IF; ELSEIF pOrderType IN ('I','B','CM', 'VO','TO') THEN IF (pOrderType='I') THEN _table := 'invcheadtax'; ELSIF (pOrderType='B') THEN _table := 'cobmisctax'; ELSIF (pOrderType='CM') THEN _table := 'cmheadtax'; ELSIF (pOrderType='VO') THEN _table := 'voheadtax'; ELSIF (pOrderType='TO') THEN _table := 'toheadtax'; END IF; IF pOrderType = 'I' AND (pDisplayType IN ('L','T')) THEN _qry := 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence FROM invchead, invcitemtax LEFT OUTER JOIN tax ON (taxhist_tax_id=tax_id) LEFT OUTER JOIN invcitem ON (invcitem_id=taxhist_parent_id) WHERE invcitem_invchead_id = ' || pOrderId || ' AND invchead_id = invcitem_invchead_id '; ELSIF pOrderType = 'B' AND (pDisplayType IN ('L','T')) THEN _qry := 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence FROM cobmisc, cobilltax LEFT OUTER JOIN tax ON (taxhist_tax_id=tax_id) LEFT OUTER JOIN cobill ON (cobill_id=taxhist_parent_id) WHERE cobill_cobmisc_id = ' || pOrderId || ' AND cobmisc_id = cobill_cobmisc_id '; ELSIF pOrderType = 'CM' AND (pDisplayType IN ('L','T')) THEN _qry := 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence FROM cmhead, cmitemtax LEFT OUTER JOIN tax ON (taxhist_tax_id=tax_id) LEFT OUTER JOIN cmitem ON (cmitem_id=taxhist_parent_id) WHERE cmitem_cmhead_id = ' || pOrderId || ' AND cmhead_id = cmitem_cmhead_id '; ELSIF pOrderType = 'VO' AND (pDisplayType IN ('L','T')) THEN _qry := 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence FROM vohead, voitemtax LEFT OUTER JOIN tax ON (taxhist_tax_id=tax_id) LEFT OUTER JOIN voitem ON (voitem_id=taxhist_parent_id) WHERE voitem_vohead_id = ' || pOrderId || ' AND vohead_id = voitem_vohead_id '; ELSIF pOrderType = 'TO' AND (pDisplayType IN ('L','T')) THEN _qry := 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence FROM tohead, toitemtax LEFT OUTER JOIN tax ON (taxhist_tax_id=tax_id) LEFT OUTER JOIN toitem ON (toitem_id=taxhist_parent_id) WHERE toitem_tohead_id = ' || pOrderId || ' AND tohead_id = toitem_tohead_id '; END IF; IF pDisplayType IN ('F','T') AND pOrderType <> 'VO' THEN IF (length(_qry) > 0) THEN _qry := _qry || ' UNION ALL '; END IF; _qry := _qry || 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence FROM ' || _table || ' JOIN tax ON (taxhist_tax_id=tax_id) WHERE ( (taxhist_parent_id = ' || pOrderId || ') AND (taxhist_taxtype_id=getfreighttaxtypeid()) )'; END IF; IF pDisplayType IN ('A','T') THEN IF (length(_qry) > 0) THEN _qry := _qry || ' UNION ALL '; END IF; _qry := _qry || 'SELECT taxhist_tax_id as tax_id, tax_code, tax_descrip, taxhist_tax, taxhist_sequence FROM ' || _table || ' JOIN tax ON (taxhist_tax_id=tax_id) WHERE ( (taxhist_parent_id = ' || pOrderId || ') AND (taxhist_taxtype_id=getadjustmenttaxtypeid()) )'; END IF; FOR _y IN EXECUTE _qry LOOP _row.taxdetail_tax_id=_y.tax_id; _row.taxdetail_tax_code = _y.tax_code; _row.taxdetail_tax_descrip = _y.tax_descrip; _row.taxdetail_tax = _y.taxhist_tax; _row.taxdetail_level= 0 ; _row.taxdetail_taxclass_sequence= COALESCE(_y.taxhist_sequence,0); _totaltax = _totaltax + _y.taxhist_tax; RETURN NEXT _row; END LOOP; END IF; END; $_$; EDROP FUNCTION public.calculatetaxdetailsummary(text, integer, text); publicadminfalse462384270a125578045Icalculatetaxhist(text, integer, integer, integer, date, integer, numeric)FUNCTIONCREATE FUNCTION calculatetaxhist(text, integer, integer, integer, date, integer, numeric) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTableName ALIAS FOR $1; pParentId ALIAS FOR $2; pTaxZoneId ALIAS FOR $3; pTaxTypeId ALIAS FOR $4; pDate ALIAS FOR $5; pCurrId ALIAS FOR $6; pAmount ALIAS FOR $7; _qry TEXT; BEGIN IF (pTableName IS NULL) THEN RAISE EXCEPTION 'A table name is required to calculate tax history'; ELSEIF (pParentId IS NULL) THEN RAISE EXCEPTION 'A parent ID is required to calculate tax history'; ELSEIF (pDate IS NULL) THEN RAISE EXCEPTION 'A date is required to calculate tax history'; ELSEIF (pAmount IS NULL) THEN RAISE EXCEPTION 'An amount is required to calculate tax history'; END IF; -- Build a query that deletes any previous tax history for this document record _qry := 'DELETE FROM ' || pTableName || ' WHERE taxhist_parent_id = ' || pParentId || ' AND taxhist_taxtype_id <> getadjustmenttaxtypeid();'; EXECUTE _qry; -- Next, build and execute query that inserts new rows. _qry := 'INSERT INTO ' || pTableName || ' ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate) SELECT ' || pParentId || ','; IF (pTaxTypeId IS NULL) THEN _qry := _qry || 'NULL'; ELSE _qry := _qry || pTaxTypeId; END If; _qry := _qry || ', taxdetail_tax_id,' || pAmount || ', taxdetail_tax_basis_tax_id, taxdetail_taxclass_sequence, taxdetail_taxrate_percent, taxdetail_taxrate_amount, taxdetail_tax, ''' || pDate || ''' FROM calculatetaxdetail(' || COALESCE(pTaxZoneId,-1) || ',' || COALESCE(pTaxTypeId,-1) ||',''' || pDate || ''',' || pCurrId || ',' || pAmount || ');'; EXECUTE _qry; RETURN true; END; $_$; `DROP FUNCTION public.calculatetaxhist(text, integer, integer, integer, date, integer, numeric); publicadminfalse46238Z125578046calcvoucheramt(integer)FUNCTIONCREATE FUNCTION calcvoucheramt(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVoucherid ALIAS FOR $1; _amount NUMERIC := 0; BEGIN SELECT SUM(COALESCE(vodist_amount, 0)) INTO _amount FROM vodist WHERE (vodist_vohead_id=pVoucherid); RETURN _amount; END; $_$; .DROP FUNCTION public.calcvoucheramt(integer); publicadminfalse46238b125578047calcvoucherfreight(integer)FUNCTIONCREATE FUNCTION calcvoucherfreight(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVoucherid ALIAS FOR $1; _amount NUMERIC := 0; BEGIN SELECT SUM(COALESCE(voitem_freight, 0)) INTO _amount FROM voitem WHERE (voitem_vohead_id=pVoucherid); RETURN _amount; END; $_$; 2DROP FUNCTION public.calcvoucherfreight(integer); publicadminfalse84623c125578048calcvouchertax(integer)FUNCTIONtCREATE FUNCTION calcvouchertax(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVoucherid ALIAS FOR $1; _amount NUMERIC := 0; BEGIN SELECT COALESCE(calculateTax(vohead_taxzone_id, vohead_taxtype_id, vohead_docdate, vohead_curr_id, calcVoucherAmt(vohead_id)), 0) INTO _amount FROM vohead WHERE (vohead_id=pVoucherid); RETURN _amount; END; $_$; .DROP FUNCTION public.calcvouchertax(integer); publicadminfalse84623d125578049%calcwooperstartstub(integer, integer)FUNCTION"CREATE FUNCTION calcwooperstartstub(integer, integer) RETURNS date LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoId ALIAS FOR $1; pBooitemSeqId ALIAS FOR $2; _result DATE; BEGIN IF ( SELECT ((metric_value='t') AND packageIsEnabled('xtmfg')) FROM metric WHERE(metric_name='Routings') ) THEN RETURN xtmfg.calcWooperStart(pWoId, pBooitemSeqId); END IF; RETURN null; END; $_$; <DROP FUNCTION public.calcwooperstartstub(integer, integer); publicadminfalse46238e125578050cancelbillingselection(integer)FUNCTIONCREATE FUNCTION cancelbillingselection(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCobmiscid ALIAS FOR $1; BEGIN IF ( ( SELECT cobmisc_posted FROM cobmisc WHERE (cobmisc_id=pCobmiscid) ) ) THEN RETURN -1; END IF; DELETE FROM cobill WHERE (cobill_cobmisc_id=pCobmiscid); DELETE FROM cobmisc WHERE (cobmisc_id=pCobmiscid); RETURN 1; END; $_$; 6DROP FUNCTION public.cancelbillingselection(integer); publicadminfalse84623f1255780510changeaccountingperioddates(integer, date, date)FUNCTIONCREATE FUNCTION changeaccountingperioddates(integer, date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _check INTEGER; _r RECORD; BEGIN -- Check to make sure that the passed period is not closed IF ( ( SELECT period_closed FROM period WHERE (period_id=pPeriodid) ) ) THEN RETURN -1; END IF; -- Check to make sure that the passed start date does not fall -- into another period SELECT period_id INTO _check FROM period WHERE ( (pStartDate BETWEEN period_start AND period_end) AND (period_id <> pPeriodid) ) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; -- Check to make sure that the passed end date does not fall -- into another period SELECT period_id INTO _check FROM period WHERE ( (pEndDate BETWEEN period_start AND period_end) AND (period_id <> pPeriodid) ) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; -- Check to make sure that the new passed start and end dates do not -- orphan a posted G/L Transaction SELECT gltrans_id INTO _check FROM gltrans, period WHERE ( (gltrans_date BETWEEN period_start AND period_end) AND (gltrans_posted) AND (NOT (gltrans_date BETWEEN pStartDate AND pEndDate)) AND (period_id=pPeriodid) ) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; -- Alter the start and end dates of the pass period UPDATE period SET period_start=pStartDate, period_end=pEndDate WHERE (period_id=pPeriodid); -- Post any unposted G/L Transactions into the period FOR _r IN SELECT DISTINCT gltrans_sequence FROM gltrans WHERE ( (NOT gltrans_posted) AND (gltrans_date BETWEEN pStartDate AND pEndDate) ) LOOP PERFORM postIntoTrialBalance(_r.gltrans_sequence); END LOOP; -- All done RETURN 1; END; $_$; GDROP FUNCTION public.changeaccountingperioddates(integer, date, date); publicadminfalse46238g1255780524changeaccountingyearperioddates(integer, date, date)FUNCTION0CREATE FUNCTION changeaccountingyearperioddates(integer, date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _check INTEGER; _checkBool BOOLEAN; _r RECORD; BEGIN -- Check to make sure that the passed yearperiod is not closed IF ( ( SELECT yearperiod_closed FROM yearperiod WHERE (yearperiod_id=pPeriodid) ) ) THEN RETURN -1; END IF; -- Check to make sure that the passed start date does not fall -- into another yearperiod SELECT yearperiod_id INTO _check FROM yearperiod WHERE ( (pStartDate BETWEEN yearperiod_start AND yearperiod_end) AND (yearperiod_id <> pPeriodid) ) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; -- Check to make sure that the passed end date does not fall -- into another yearperiod SELECT yearperiod_id INTO _check FROM yearperiod WHERE ( (pEndDate BETWEEN yearperiod_start AND yearperiod_end) AND (yearperiod_id <> pPeriodid) ) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; -- Check to make sure that the passed yearperiod is not closed IF ( ( SELECT (count(period_id) > 0) FROM period WHERE ((period_yearperiod_id=pPeriodid) AND (period_start < pStartDate OR period_end > pEndDate)) ) ) THEN RETURN -4; END IF; -- Make sure that the passed start is prior to the end date SELECT (pStartDate > pEndDate) INTO _checkBool; IF (_checkBool) THEN RETURN -5; END IF; -- Alter the start and end dates of the pass period UPDATE yearperiod SET yearperiod_start=pStartDate, yearperiod_end=pEndDate WHERE (yearperiod_id=pPeriodid); -- All done RETURN 1; END; $_$; KDROP FUNCTION public.changeaccountingyearperioddates(integer, date, date); publicadminfalse84623h125578053Achangefkeypointers(text, text, integer, integer, text[], boolean)FUNCTIONECREATE FUNCTION changefkeypointers(text, text, integer, integer, text[], boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSchema ALIAS FOR $1; pTable ALIAS FOR $2; pSourceId ALIAS FOR $3; pTargetId ALIAS FOR $4; pIgnore ALIAS FOR $5; _purge BOOLEAN := COALESCE($6, FALSE); _counter INTEGER := 0; _count1 INTEGER := 0; _fk RECORD; _pk TEXT[]; BEGIN -- for all foreign keys that point to pSchema.pTable FOR _fk IN EXECUTE 'SELECT fkeyns.nspname AS schemaname, fkeytab.relname AS tablename, conkey, attname, typname FROM pg_constraint JOIN pg_class basetab ON (confrelid=basetab.oid) JOIN pg_namespace basens ON (basetab.relnamespace=basens.oid) JOIN pg_class fkeytab ON (conrelid=fkeytab.oid) JOIN pg_namespace fkeyns ON (fkeytab.relnamespace=fkeyns.oid) JOIN pg_attribute ON (attrelid=conrelid AND attnum=conkey[1]) JOIN pg_type ON (atttypid=pg_type.oid) WHERE basetab.relname = ' || quote_literal(pTable) || ' AND basens.nspname = ' || quote_literal(pSchema) || ' AND fkeytab.relname NOT IN (''' || ARRAY_TO_STRING(pIgnore, ''', ''') || ''')' LOOP IF (ARRAY_UPPER(_fk.conkey, 1) > 1) THEN RAISE EXCEPTION 'Cannot change the foreign key in %.% that refers to %.% because the foreign key constraint has multiple columns. [xtuple: changefkeypointers, -1, %.%, %.%]', _fk.schemaname, _fk.tablename, pSchema, pTable, _fk.schemaname, _fk.tablename, pSchema, pTable; END IF; -- optionally make a backup copy of the data IF (NOT _purge) THEN -- determine the primary key column of the fkey table _pk := primaryKeyFields(_fk.schemaname, _fk.tablename); IF (ARRAY_UPPER(_pk, 1) > 1) THEN RAISE EXCEPTION 'Cannot change foreign key references in %.% because it has a composite primary key. Try setting the purge option. [xtuple: changefkeypointers, -4, %.%]', _fk.schemaname, _fk.tablename, _fk.schemaname, _fk.tablename; END IF; -- make the backup copy EXECUTE 'INSERT INTO mrgundo ( mrgundo_schema, mrgundo_table, mrgundo_pkey_col, mrgundo_pkey_id, mrgundo_col, mrgundo_value, mrgundo_type, mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id ) SELECT ' || quote_literal(_fk.schemaname) || ', ' || quote_literal(_fk.tablename) || ', ' || quote_literal(_pk[1]) || ', ' || _pk[1] || ', ' || quote_literal(_fk.attname) || ', ' || _fk.attname || ', ' || quote_literal(_fk.typname) || ', ' || quote_literal(pSchema) || ', ' || quote_literal(pTable) || ', ' || pTargetId || ' FROM ' || _fk.schemaname || '.' || _fk.tablename || ' WHERE ('|| _fk.attname || '=' || pSourceId || ');'; END IF; -- actually change the foreign keys to point to the desired base table record EXECUTE 'UPDATE ' || _fk.schemaname || '.' || _fk.tablename || ' SET ' || _fk.attname || '=' || pTargetId || ' WHERE (' || _fk.attname || '=' || pSourceId || ');'; GET DIAGNOSTICS _count1 = ROW_COUNT; _counter := _counter + _count1; END LOOP; RETURN _counter; END; $_$; XDROP FUNCTION public.changefkeypointers(text, text, integer, integer, text[], boolean); publicadminfalse46238%00JFUNCTION changefkeypointers(text, text, integer, integer, text[], boolean)COMMENTCOMMENT ON FUNCTION changefkeypointers(text, text, integer, integer, text[], boolean) IS 'Change the data in all tables with foreign key relationships so they point to the pSchema.pTable record with primary key pTargetId instead of the record with primary key pSourceId. Ignore any tables listed in pIgnore. If the final arg is TRUE, make a backup copy of the original data in the mrgundo table.'; publicadminfalse1128i125578054"changepoitemduedate(integer, date)FUNCTION:CREATE FUNCTION changepoitemduedate(ppoitemid integer, pdate date) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN changePoitemDueDate(pPoitemid, pDate, false); END; $$; IDROP FUNCTION public.changepoitemduedate(ppoitemid integer, pdate date); publicadminfalse46238j125578055+changepoitemduedate(integer, date, boolean)FUNCTIONGCREATE FUNCTION changepoitemduedate(ppoitemid integer, pdate date, pbyso boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF ( ( SELECT (poitem_status IN ('C')) FROM poitem WHERE (poitem_id=pPoitemid) ) ) THEN RETURN -1; END IF; UPDATE poitem SET poitem_duedate=pDate WHERE (poitem_id=pPoitemid); IF (pBySO) THEN --Generate the PoItemUpdatedBySo event PERFORM postEvent('PoItemUpdatedBySo', 'P', poitem_id, itemsite_warehous_id, (pohead_number || '-'|| poitem_linenumber || ': ' || item_number), NULL, NULL, NULL, NULL) FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id) JOIN itemsite ON (itemsite_id=poitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (poitem_id=pPoitemid) AND (poitem_duedate <= (CURRENT_DATE + itemsite_eventfence)); END IF; RETURN pPoitemid; END; $$; XDROP FUNCTION public.changepoitemduedate(ppoitemid integer, pdate date, pbyso boolean); publicadminfalse84623k125578056!changepoitemqty(integer, numeric)FUNCTION3CREATE FUNCTION changepoitemqty(ppoitemid integer, pqty numeric) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN changePoitemQty(pPoitemid, pQty, false); END; $$; GDROP FUNCTION public.changepoitemqty(ppoitemid integer, pqty numeric); publicadminfalse46238l125578057*changepoitemqty(integer, numeric, boolean)FUNCTIONQCREATE FUNCTION changepoitemqty(ppoitemid integer, pqty numeric, pbyso boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN IF ( ( SELECT (poitem_status IN ('C')) FROM poitem WHERE (poitem_id=pPoitemid) ) ) THEN RETURN -1; END IF; UPDATE poitem SET poitem_qty_ordered=pQty WHERE (poitem_id=pPoitemid); IF (pBySO) THEN --Generate the PoItemUpdatedBySo event PERFORM postEvent('PoItemUpdatedBySo', 'P', poitem_id, itemsite_warehous_id, (pohead_number || '-'|| poitem_linenumber || ': ' || item_number), NULL, NULL, NULL, NULL) FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id) JOIN itemsite ON (itemsite_id=poitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (poitem_id=pPoitemid) AND (poitem_duedate <= (CURRENT_DATE + itemsite_eventfence)); END IF; RETURN pPoitemid; END; $$; VDROP FUNCTION public.changepoitemqty(ppoitemid integer, pqty numeric, pbyso boolean); publicadminfalse84623m125586984changeprdate(integer, date)FUNCTIONoCREATE FUNCTION changeprdate(integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrid ALIAS FOR $1; pDueDate ALIAS FOR $2; BEGIN UPDATE pr SET pr_duedate=pDueDate WHERE (pr_id=pPrid); RETURN 0; END; $_$; 2DROP FUNCTION public.changeprdate(integer, date); publicadminfalse46238n125578059changeprqty(integer, numeric)FUNCTIONlCREATE FUNCTION changeprqty(integer, numeric) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrid ALIAS FOR $1; pQty ALIAS FOR $2; BEGIN UPDATE pr SET pr_qtyreq=pQty WHERE (pr_id=pPrid); RETURN TRUE; END; $_$; 4DROP FUNCTION public.changeprqty(integer, numeric); publicadminfalse46238125578060changeprqty(integer, date)FUNCTIONCREATE FUNCTION changeprqty(integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pPrid ALIAS FOR $1; pDueDate ALIAS FOR $2; BEGIN UPDATE pr SET pr_duedate=pDueDate WHERE (pr_id=pPrid); RETURN 0; END; $_$; 1DROP FUNCTION public.changeprqty(integer, date); publicadminfalse84623o125578061]changepseudofkeypointers(text, text, text, integer, text, text, integer, text, text, boolean)FUNCTIONC CREATE FUNCTION changepseudofkeypointers(text, text, text, integer, text, text, integer, text, text, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSchema ALIAS FOR $1; pTable ALIAS FOR $2; pFkeyCol ALIAS FOR $3; pSourceId ALIAS FOR $4; pBaseSchema ALIAS FOR $5; pBaseTable ALIAS FOR $6; pTargetId ALIAS FOR $7; pTypeCol ALIAS FOR $8; pType ALIAS FOR $9; _purge BOOLEAN := COALESCE($10, FALSE); _counter INTEGER := 0; _coltype TEXT; _pk TEXT[]; BEGIN IF (NOT _purge) THEN EXECUTE 'SELECT typname FROM pg_type JOIN pg_attribute ON (pg_type.oid=atttypid) JOIN pg_class ON (attrelid=pg_class.oid) JOIN pg_namespace ON (relnamespace=pg_namespace.oid) WHERE (relname=' || quote_literal(pTable) || ') AND (nspname=' || quote_literal(pSchema) || ') AND (attname=' || quote_literal(pFkeyCol) || ')' INTO _coltype; _pk := primaryKeyFields(pSchema, pTable); IF (ARRAY_UPPER(_pk, 1) > 1) THEN RAISE EXCEPTION 'Cannot change pseudo-foreign key references in %.% because it has a composite primary key. Try setting the purge option. [xtuple: changepseudofkeypointers, -1, %.%', pSchema, pTable, pSchema, pTable; END IF; EXECUTE 'INSERT INTO mrgundo ( mrgundo_schema, mrgundo_table, mrgundo_pkey_col, mrgundo_pkey_id, mrgundo_col, mrgundo_value, mrgundo_type, mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id ) SELECT ' || quote_literal(pSchema) || ', ' || quote_literal(pTable) || ', ' || quote_literal(_pk[1]) || ', ' || quote_ident(_pk[1]) || ', ' || quote_literal(pFkeyCol) || ', ' || quote_ident(pFkeyCol) || ', ' || quote_literal(_coltype) || ', ' || quote_literal(pBaseSchema) || ', ' || quote_literal(pBaseTable) || ', ' || pTargetId || ' FROM ' || quote_ident(pSchema) || '.' || quote_ident(pTable) || ' WHERE (('|| quote_ident(pFkeyCol) || '=' || pSourceId || ') AND ('|| quote_ident(pTypeCol) || '=' || quote_literal(pType) || '));'; END IF; -- actually change the foreign keys to point to the desired base table record EXECUTE 'UPDATE ' || quote_ident(pSchema) || '.' || quote_ident(pTable) || ' SET ' || quote_ident(pFkeyCol) || '=' || pTargetId || ' WHERE ((' || quote_ident(pFkeyCol) || '=' || pSourceId || ') AND (' || quote_ident(pTypeCol) || '=' || quote_literal(pType) || '));'; GET DIAGNOSTICS _counter = ROW_COUNT; RETURN _counter; END; $_$; tDROP FUNCTION public.changepseudofkeypointers(text, text, text, integer, text, text, integer, text, text, boolean); publicadminfalse46238%00fFUNCTION changepseudofkeypointers(text, text, text, integer, text, text, integer, text, text, boolean)COMMENTCOMMENT ON FUNCTION changepseudofkeypointers(text, text, text, integer, text, text, integer, text, text, boolean) IS 'Change the data in pSchema.pTable with a pseudo-foreign key relationship to another (unnamed) table. Make pSchema.pTable point to the record with primary key pTargetId instead of the record with primary key pSourceId. pSchema.pTable cannot have a true foreign key relationship because it holds data that can point to any of several tables. The pType value in the pTypeCol column describes which table the data refer to (e.g. "T" may indicate that the current record refers to a "cntct"). If the final arg is TRUE, make a backup copy of the data in the mrgundo table.'; publicadminfalse1135p1255780621changepurchasedropship(integer, integer, boolean)FUNCTIONCREATE FUNCTION changepurchasedropship(pcoitemid integer, ppoitemid integer, pdropship boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _s RECORD; _w RECORD; _p RECORD; _result INTEGER; _poitemid INTEGER; BEGIN -- Check for existing poitem for this coitem SELECT * INTO _p FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id) WHERE (poitem_id=pPoitemId) AND (poitem_order_id=pCoitemId) AND (poitem_order_type='S'); IF (NOT FOUND) THEN RAISE EXCEPTION 'Change Purchase Drop Ship PO not found'; END IF; SELECT * INTO _s FROM coitem JOIN cohead ON (cohead_id = coitem_cohead_id) LEFT OUTER JOIN shiptoinfo ON (cohead_shipto_id = shipto_id) LEFT OUTER JOIN cntct ON (shipto_cntct_id = cntct_id) LEFT OUTER JOIN addr ON (shipto_addr_id = addr_id) WHERE (coitem_id = pCoitemId); IF (NOT FOUND) THEN RETURN -1; END IF; IF (_p.pohead_status != 'U') THEN RETURN -3; END IF; SELECT deletePoitem(_p.poitem_id) INTO _result; IF (_result < 0) THEN RETURN _result; END IF; SELECT createPurchaseToSale(_s.coitem_id, _p.poitem_itemsrc_id, pDropShip, _s.coitem_qtyord, _s.coitem_scheddate, NULL) INTO _poitemid; RETURN _poitemid; END; $$; fDROP FUNCTION public.changepurchasedropship(pcoitemid integer, ppoitemid integer, pdropship boolean); publicadminfalse84623q125578063+changewodates(integer, date, date, boolean)FUNCTION CREATE FUNCTION changewodates(integer, date, date, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pStartDate ALIAS FOR $2; pDueDate ALIAS FOR $3; changeChildren ALIAS FOR $4; _p RECORD; returnCode INTEGER; _vtemp NUMERIC; BEGIN SELECT wo_status, wo_startdate, itemsite_warehous_id INTO _p FROM wo Inner Join itemsite on wo_itemsite_id=itemsite_id WHERE (wo_id=pWoid); IF (_p.wo_status = 'C') THEN returnCode := 0; ELSIF (_p.wo_status IN ('R','I')) THEN PERFORM postEvent('RWoDueDateRequestChange', 'W', wo_id, itemsite_warehous_id, formatWoNumber(wo_id), NULL, NULL, pDueDate, wo_duedate) FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (wo_id=pWoid); returnCode := 0; END IF; -- Reschedule operations if routings enabled IF (fetchMetricBool('Routings')) THEN -- Reschedule wooper IF (fetchMetricBool('UseSiteCalendar')) THEN UPDATE xtmfg.wooper SET wooper_scheduled = calculatenextworkingdate(itemsite_warehous_id,DATE(pStartDate), CAST(calculateworkdays(itemsite_warehous_id, DATE(wo_startdate), DATE(wooper_scheduled)) as INTEGER)) FROM wo JOIN itemsite ON (wo_itemsite_id=itemsite_id) WHERE ( (wooper_wo_id=wo_id) AND (wo_id=pWoid) ); ELSE UPDATE xtmfg.wooper SET wooper_scheduled = (wooper_scheduled::DATE + (pStartDate - wo_startdate)) FROM wo WHERE ( (wooper_wo_id=wo_id) AND (wo_id=pWoid) ); END IF; -- Reschedule any womatl that is linked to wooper items -- and is set to be scheduled with the wooper in question UPDATE womatl SET womatl_duedate=wooper_scheduled FROM xtmfg.wooper WHERE ( (womatl_schedatwooper) AND (womatl_wooper_id=wooper_id) AND (womatl_wo_id=pWoid) ); END IF; -- Reschedule any womatl that is not linked to wooper items UPDATE womatl SET womatl_duedate=pStartDate WHERE ( (NOT womatl_schedatwooper) AND (womatl_wo_id=pWoid) ); -- Reschedule the W/O UPDATE wo SET wo_startdate=pStartDate, wo_duedate=pDueDate WHERE (wo_id=pWoid); -- Do the same for the children IF (changeChildren) THEN SELECT MAX(changeWoDates(wo_id, (pStartDate - itemsite_leadtime), pStartDate, TRUE)) INTO returnCode FROM wo, itemsite WHERE ( (wo_itemsite_id=itemsite_id) AND (wo_ordtype='W') AND (wo_ordid=pWoid) ); END IF; IF (returnCode IS NULL) THEN returnCode := 0; END IF; RETURN returnCode; END; $_$; BDROP FUNCTION public.changewodates(integer, date, date, boolean); publicadminfalse46238r125578064*changewoproject(integer, integer, boolean)FUNCTIONCREATE FUNCTION changewoproject(integer, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pPrjid ALIAS FOR $2; changeChildren ALIAS FOR $3; woStatus CHAR(1); _result INTEGER; BEGIN SELECT wo_status INTO woStatus FROM wo WHERE (wo_id=pWoid); UPDATE wo SET wo_prj_id=pPrjid WHERE (wo_id=pWoid); IF (woStatus = 'E' AND changeChildren) THEN _result := ( SELECT MIN(changeWoProject(wo_id, pPrjid, TRUE)) FROM womatl, wo WHERE ((womatl_itemsite_id=wo_itemsite_id) AND (wo_ordtype='W') AND (womatl_wo_id=pWoid) AND (wo_ordid=pWoid)) ); UPDATE pr SET pr_prj_id=pPrjid FROM womatl WHERE ((womatl_wo_id=pWoid) AND (pr_order_type='W') AND (pr_order_id=womatl_id)); ELSE _result = 1; END IF; RETURN _result; END; $_$; ADROP FUNCTION public.changewoproject(integer, integer, boolean); publicadminfalse84623t125578065&changewoqty(integer, numeric, boolean)FUNCTION# CREATE FUNCTION changewoqty(integer, numeric, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pQty ALIAS FOR $2; changeChildren ALIAS FOR $3; _r RECORD; _result INTEGER := 1; BEGIN SELECT wo_qtyord, wo_status, item_fractional INTO _r FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (wo_id=pWoid); IF (_r.wo_qtyord = pQty) THEN RETURN 0; END IF; IF (NOT _r.wo_status IN ('O','E','R','I')) THEN RETURN 1; END IF; IF (_r.wo_status IN ('R','I')) THEN PERFORM postEvent('RWoQtyRequestChange', 'W', wo_id, itemsite_warehous_id, formatWoNumber(wo_id), pQty, wo_qtyord, NULL, NULL) FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (wo_id=pWoid); _result = 0; END IF; UPDATE wo SET wo_qtyord=roundQty(_r.item_fractional, pQty) WHERE (wo_id=pWoid); UPDATE womatl SET womatl_qtyreq=(womatl_qtyfxd + wo_qtyord * womatl_qtyper) * (1 + womatl_scrap) FROM wo, itemsite WHERE ((womatl_wo_id=wo_id) AND (womatl_itemsite_id=itemsite_id) AND (wo_id=pWoid)); IF (fetchMetricBool('Routings')) THEN UPDATE xtmfg.wooper SET wooper_rntime = CASE WHEN ((booitem_rnqtyper = 0) OR (booitem_invproduomratio = 0)) THEN 0 WHEN (NOT booitem_rnrpt) THEN 0 ELSE ( ( booitem_rntime / booitem_rnqtyper / booitem_invproduomratio ) * wo_qtyord ) END FROM xtmfg.booitem, wo WHERE ((wooper_wo_id=wo_id) AND (wooper_booitem_id=booitem_id) AND (wo_id=pWoid)); END IF; IF (changeChildren) THEN _result := ( SELECT MIN(changeWoQty(wo_id, womatl_qtyreq, TRUE)) FROM womatl, wo WHERE ((womatl_itemsite_id=wo_itemsite_id) AND (wo_ordtype='W') AND (womatl_wo_id=pWoid) AND (wo_ordid=pWoid)) ); END IF; RETURN _result; END; $_$; =DROP FUNCTION public.changewoqty(integer, numeric, boolean); publicadminfalse84623u1255780662characteristicstostring(text, integer, text, text)FUNCTION]CREATE FUNCTION characteristicstostring(text, integer, text, text) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTargetType ALIAS FOR $1; pTargetId ALIAS FOR $2; pValKeySep ALIAS FOR $3; pPairSep ALIAS FOR $4; _string TEXT := ''; _extra BOOLEAN := false; _r RECORD; BEGIN FOR _r IN SELECT char_name, charass_value FROM charass, char WHERE ((charass_char_id=char_id) AND (charass_target_type=pTargetType) AND (charass_target_id=pTargetId)) LOOP IF(_extra) THEN _string := _string || pPairSep; END IF; _extra := true; _string := _string || _r.char_name || pValKeySep || _r.charass_value; END LOOP; RETURN _string; END; $_$; IDROP FUNCTION public.characteristicstostring(text, integer, text, text); publicadminfalse46238v125578067!checkcreditmemositeprivs(integer)FUNCTIONCREATE FUNCTION checkcreditmemositeprivs(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmheadid ALIAS FOR $1; _check BOOLEAN; _result INTEGER; BEGIN IF (NOT fetchMetricBool('MultiWhs')) THEN RETURN true; END IF; IF (NOT fetchUsrPrefBool('selectedSites')) THEN RETURN true; END IF; SELECT COALESCE(COUNT(*), 0) INTO _result FROM ( SELECT cmitem_id FROM cmitem JOIN itemsite ON (itemsite_id=cmitem_itemsite_id) WHERE ( (cmitem_cmhead_id=pCmheadid) AND (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) ) AS data; IF (_result > 0) THEN RETURN false; END IF; RETURN true; END; $_$; 8DROP FUNCTION public.checkcreditmemositeprivs(integer); publicadminfalse46238125578068&checkdetailformatted(integer, integer)FUNCTIONS(CREATE FUNCTION checkdetailformatted(integer, integer) RETURNS SETOF checkdata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCheckheadid ALIAS FOR $1; pMaxLines ALIAS FOR $2; _row checkdata%ROWTYPE; _checkhead RECORD; _checkdetail RECORD; _rowcount INTEGER := 0; _page INTEGER := 1; _docnumber TEXT := ''; _docreference TEXT := ''; _docdate TEXT := ''; _docamount TEXT := ''; _docdiscount TEXT := ''; _docnetamount TEXT := ''; BEGIN -- Check header information SELECT checkhead_number AS checknumber, INITCAP(spellAmount(checkhead_amount, curr_id)) AS checkwords, formatDate(checkhead_checkdate) AS checkdate, formatMoney(checkhead_amount) AS checkamount, curr_symbol AS checkcurrsymbol, curr_abbr AS checkcurrabbr, curr_name AS checkcurrname, CASE WHEN checkhead_recip_type = 'C' THEN (SELECT cust_name FROM custinfo WHERE cust_id=checkhead_recip_id) WHEN checkhead_recip_type = 'T' THEN (SELECT taxauth_name FROM taxauth WHERE taxauth_id=checkhead_recip_id) WHEN checkhead_recip_type = 'V' THEN COALESCE((SELECT vendaddr_name FROM vendaddrinfo WHERE((UPPER(vendaddr_code)='REMIT') AND (vendaddr_vend_id=checkhead_recip_id))), (SELECT vend_name FROM vendinfo WHERE(vend_id=checkhead_recip_id))) END AS checkpayto, formatAddr(CASE WHEN checkhead_recip_type = 'C' THEN (SELECT cntct_addr_id FROM cntct, custinfo WHERE((cust_cntct_id=cntct_id) AND (cust_id=checkhead_recip_id))) WHEN checkhead_recip_type = 'T' THEN (SELECT taxauth_addr_id FROM taxauth WHERE(taxauth_id=checkhead_recip_id)) WHEN checkhead_recip_type = 'V' THEN COALESCE((SELECT vendaddr_addr_id FROM vendaddrinfo WHERE((UPPER(vendaddr_code)='REMIT') AND (vendaddr_vend_id=checkhead_recip_id))), (SELECT vend_addr_id FROM vendinfo WHERE(vend_id=checkhead_recip_id))) END) AS checkaddress, checkhead_for AS checkmemo INTO _checkhead FROM checkhead, curr_symbol WHERE((checkhead_curr_id = curr_id) AND (checkhead_id=pCheckheadid) ); IF (NOT FOUND) THEN RETURN; END IF; _row.checkdata_page := _page; _row.checkdata_checknumber := _checkhead.checknumber; _row.checkdata_checkwords := _checkhead.checkwords; _row.checkdata_checkdate := _checkhead.checkdate; _row.checkdata_checkamount := _checkhead.checkamount; _row.checkdata_checkcurrsymbol := _checkhead.checkcurrsymbol; _row.checkdata_checkcurrabbr := _checkhead.checkcurrabbr; _row.checkdata_checkcurrname := _checkhead.checkcurrname; _row.checkdata_checkpayto := _checkhead.checkpayto; _row.checkdata_checkaddress := _checkhead.checkaddress; _row.checkdata_checkmemo := _checkhead.checkmemo; -- Check item details FOR _checkdetail IN SELECT --VOUCHER------------- 1 AS ord, 1 AS sequence_value, checkitem_invcnumber, checkitem_ponumber, formatMoney(checkitem_amount) AS docnetamount, 'Invoice#: ' || vohead_invcnumber AS docnumber, formatDate(vohead_docdate) AS docdate, vohead_reference AS docreference, 'Voucher: ' || checkitem_vouchernumber AS vouchernumber, formatMoney(apopen_amount) AS docamount, formatMoney(checkitem_discount) AS docdiscount FROM checkitem, vohead, apopen WHERE ((checkitem_checkhead_id=pCheckheadid) AND (checkitem_vouchernumber = vohead_number) AND (checkitem_apopen_id = apopen_id) AND (apopen_doctype = 'V')) UNION SELECT --DEBIT MEMO ------------------------- 2 AS ord, 1 AS sequence_value, checkitem_invcnumber, checkitem_ponumber, formatMoney(checkitem_amount) AS f_amount, 'Debit Memo PO#: ' || checkitem_ponumber AS doc_number, '' AS f_docdate, 'Debit Memo: ' || checkitem_vouchernumber AS doc_reference, checkitem_vouchernumber AS vouchernumber, formatMoney(apopen_amount) AS amount, formatMoney(checkitem_discount) AS disc_cred FROM checkitem, apopen WHERE ((checkitem_checkhead_id=pCheckheadid) AND (checkitem_apopen_id = apopen_id) AND (apopen_doctype = 'D')) UNION SELECT --CREDIT MEMO ------------------------- 2 AS ord, 1 AS sequence_value, checkitem_invcnumber, checkitem_ponumber, formatMoney(checkitem_amount * -1.0) AS f_amount, 'Credit Memo PO#: ' || checkitem_ponumber AS doc_number, '' AS f_docdate, 'Credit Memo: ' || checkitem_vouchernumber AS doc_reference, checkitem_vouchernumber AS vouchernumber, '' AS amount, formatMoney(checkitem_amount) AS disc_cred FROM checkitem, apopen WHERE ((checkitem_checkhead_id=pCheckheadid) AND (checkitem_apopen_id = apopen_id) AND (apopen_doctype = 'C')) UNION SELECT --CREDITs FOR VOUCHERS----------------- 3 AS ord, 1 AS sequence_value, checkitem_invcnumber, checkitem_ponumber, formatMoney(checkitem_amount) AS f_amount, 'Invoice#: ' || vohead_invcnumber AS doc_number, formatDate(vohead_docdate) AS f_docdate, 'Credit Applied: ' || apapply_source_doctype || ' ' || apapply_source_docnumber AS doc_reference, 'Voucher: ' || checkitem_vouchernumber AS vouchernumber, '' AS amount, formatMoney((apapply_amount)) AS disc_cred FROM checkitem, vohead, apapply WHERE ((checkitem_checkhead_id=pCheckheadid) AND (checkitem_vouchernumber = vohead_number) AND (apapply_target_docnumber = checkitem_vouchernumber) AND (apapply_target_doctype = 'V') AND (apapply_source_doctype = 'C')) UNION SELECT --CREDITs FOR DEBIT MEMOS----------- 3 AS ord, 1 AS sequence_value, checkitem_invcnumber, checkitem_ponumber, formatMoney(checkitem_amount) AS f_amount, 'Debit Memo PO#: ' || checkitem_ponumber AS doc_number, '' AS f_docdate, 'Credit Applied: ' || apapply_source_doctype || ' ' || apapply_source_docnumber AS doc_reference, 'Debit Memo: ' || checkitem_vouchernumber AS vouchernumber, '' AS amount, formatMoney((apapply_amount)) AS disc_cred FROM checkitem, apopen, apapply WHERE ((checkitem_checkhead_id=pCheckheadid) AND (checkitem_apopen_id = apopen_id) AND (apopen_doctype = 'D') AND (apapply_target_apopen_id = apopen_id) AND (apapply_target_doctype = 'D') AND (apapply_source_doctype = 'C')) UNION SELECT --NON-VENDOR----------------------- 4 AS ord, 1 AS sequence_value, checkitem_invcnumber, checkitem_ponumber, formatMoney(checkitem_amount) AS f_amount, checkitem_invcnumber AS doc_number, formatDate(checkitem_docdate) AS f_docdate, '' AS doc_reference, '' AS vouchernumber, '' AS amount, '' AS disc_cred FROM checkhead LEFT OUTER JOIN checkitem ON (checkitem_checkhead_id=checkhead_id) WHERE ((checkhead_id=pCheckheadid) AND (checkhead_recip_type != 'V')) LOOP IF (_rowcount = pMaxLines) THEN _row.checkdata_docnumber := _docnumber; _row.checkdata_docreference := _docreference; _row.checkdata_docdate := _docdate; _row.checkdata_docamount := _docamount; _row.checkdata_docdiscount := _docdiscount; _row.checkdata_docnetamount := _docnetamount; RETURN NEXT _row; -- update/reset some variables _rowcount = 0; _page := _page + 1; _docnumber := ''; _docreference := ''; _docdate := ''; _docamount := ''; _docdiscount := ''; _docnetamount := ''; _row.checkdata_page := _page; _row.checkdata_checknumber := _checkhead.checknumber; _row.checkdata_checkwords := 'VOID VOID PAGE '||_page||' OF CHECK #'||_checkhead.checknumber||' VOID VOID'; _row.checkdata_checkdate := 'VOID VOID VOID'; _row.checkdata_checkamount := 'VOID VOID VOID'; --_row.checkdata_checkcurrsymbol := _checkhead.checkcurrsymbol; --_row.checkdata_checkcurrabbr := _checkhead.checkcurrabbr; --_row.checkdata_checkcurrname := _checkhead.checkcurrname; _row.checkdata_checkpayto := 'VOID VOID VOID'; --_row.checkdata_checkaddress := _checkhead.checkaddress; _row.checkdata_checkmemo := 'VOID VOID PAGE '||_page||' OF CHECK #'||_checkhead.checknumber||' VOID VOID'; END IF; _rowcount := _rowcount + 1; _docnumber := _docnumber || _checkdetail.docnumber || E'\n'; _docreference := _docreference || _checkdetail.docreference || E'\n'; _docdate := _docdate || _checkdetail.docdate || E'\n'; _docamount := _docamount || _checkdetail.docamount || E'\n'; _docdiscount := _docdiscount || _checkdetail.docdiscount || E'\n'; _docnetamount := _docnetamount || _checkdetail.docnetamount || E'\n'; END LOOP; _row.checkdata_docnumber := _docnumber; _row.checkdata_docreference := _docreference; _row.checkdata_docdate := _docdate; _row.checkdata_docamount := _docamount; _row.checkdata_docdiscount := _docdiscount; _row.checkdata_docnetamount := _docnetamount; RETURN NEXT _row; RETURN; END; $_$; =DROP FUNCTION public.checkdetailformatted(integer, integer); publicadminfalse462327128w125578070checkinvoicesiteprivs(integer)FUNCTIONCREATE FUNCTION checkinvoicesiteprivs(integer) RETURNS boolean LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvcheadid ALIAS FOR $1; _check BOOLEAN; _result INTEGER; BEGIN IF (NOT fetchMetricBool('MultiWhs')) THEN RETURN true; END IF; IF (NOT fetchUsrPrefBool('selectedSites')) THEN RETURN true; END IF; SELECT COALESCE(COUNT(*), 0) INTO _result FROM ( SELECT invcitem_id FROM invcitem WHERE ( (invcitem_invchead_id=pInvcheadid) AND (invcitem_warehous_id <> -1) AND (invcitem_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) ) AS data; IF (_result > 0) THEN RETURN false; END IF; RETURN true; END; $_$; 5DROP FUNCTION public.checkinvoicesiteprivs(integer); publicadminfalse46238x125578071checkpositeprivs(integer)FUNCTIONWCREATE FUNCTION checkpositeprivs(integer) RETURNS boolean LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPoheadid ALIAS FOR $1; _check BOOLEAN; _result INTEGER; BEGIN IF (NOT fetchMetricBool('MultiWhs')) THEN RETURN true; END IF; IF (NOT fetchUsrPrefBool('selectedSites')) THEN RETURN true; END IF; SELECT COALESCE(COUNT(*), 0) INTO _result FROM ( SELECT poitem_id FROM poitem, itemsite WHERE ( (poitem_pohead_id=pPoheadid) AND (poitem_itemsite_id=itemsite_id) AND (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) UNION SELECT pohead_warehous_id FROM pohead WHERE ( (pohead_id=pPoheadid) AND (pohead_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) ) AS data; IF (_result > 0) THEN RETURN false; END IF; RETURN true; END; $_$; 0DROP FUNCTION public.checkpositeprivs(integer); publicadminfalse84623y125578072checkprivilege(text)FUNCTIONCREATE FUNCTION checkprivilege(text) RETURNS boolean LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrivilege ALIAS FOR $1; _result TEXT; BEGIN SELECT priv_id INTO _result FROM priv, grppriv, usrgrp WHERE((usrgrp_grp_id=grppriv_grp_id) AND (grppriv_priv_id=priv_id) AND (priv_name=pPrivilege) AND (usrgrp_username=getEffectiveXtUser())); IF (FOUND) THEN RETURN true; END IF; SELECT priv_id INTO _result FROM priv, usrpriv WHERE ((priv_id=usrpriv_priv_id) AND (priv_name=pPrivilege) AND (usrpriv_username=getEffectiveXtUser())); IF (FOUND) THEN RETURN true; ELSE RETURN false; END IF; END; $_$; +DROP FUNCTION public.checkprivilege(text); publicadminfalse84623z125578073checkquotesiteprivs(integer)FUNCTIONHCREATE FUNCTION checkquotesiteprivs(integer) RETURNS boolean LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuheadid ALIAS FOR $1; BEGIN RETURN checkQuoteSitePrivs(pQuheadid, NULL); END; $_$; 3DROP FUNCTION public.checkquotesiteprivs(integer); publicadminfalse84623|125578074%checkquotesiteprivs(integer, integer)FUNCTIONCREATE FUNCTION checkquotesiteprivs(integer, integer) RETURNS boolean LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuheadid ALIAS FOR $1; pWarehousid ALIAS FOR $2; _result INTEGER := 0; BEGIN -- RAISE NOTICE 'checkQuoteSitePrivs, pQuheadid = %', pQuheadid; -- RAISE NOTICE 'checkQuoteSitePrivs, pWarehousid = %', pWarehousid; IF (NOT fetchMetricBool('MultiWhs')) THEN RETURN true; END IF; IF ( (NOT fetchUsrPrefBool('selectedSites')) AND (pWarehousid IS NULL) ) THEN RETURN true; END IF; IF (pWarehousid IS NULL) THEN SELECT COALESCE(COUNT(*), 0) INTO _result FROM quitem JOIN itemsite ON (itemsite_id=quitem_itemsite_id) JOIN site() ON (warehous_id=itemsite_warehous_id) WHERE (quitem_quhead_id=pQuheadid); ELSE SELECT COALESCE(COUNT(*), 0) INTO _result FROM quitem JOIN itemsite ON (itemsite_id=quitem_itemsite_id) JOIN site() ON (warehous_id=itemsite_warehous_id) WHERE ( (quitem_quhead_id=pQuheadid) AND (itemsite_warehous_id=pWarehousid) ); END IF; IF (_result > 0) THEN RETURN true; END IF; RETURN false; END; $_$; <DROP FUNCTION public.checkquotesiteprivs(integer, integer); publicadminfalse84623}125578075checkrasiteprivs(integer)FUNCTIONCREATE FUNCTION checkrasiteprivs(integer) RETURNS boolean LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pRaheadid ALIAS FOR $1; _check BOOLEAN; _result INTEGER; BEGIN IF (NOT fetchMetricBool('MultiWhs')) THEN RETURN true; END IF; IF (NOT fetchUsrPrefBool('selectedSites')) THEN RETURN true; END IF; SELECT COALESCE(COUNT(*), 0) INTO _result FROM ( SELECT raitem_id FROM raitem, itemsite WHERE ( (raitem_rahead_id=pRaheadid) AND (raitem_itemsite_id=itemsite_id) AND (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) UNION SELECT raitem_id FROM raitem, itemsite WHERE ( (raitem_rahead_id=pRaheadid) AND (raitem_coitem_itemsite_id=itemsite_id) AND (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) ) AS data; IF (_result > 0) THEN RETURN false; END IF; RETURN true; END; $_$; 0DROP FUNCTION public.checkrasiteprivs(integer); publicadminfalse46238~125578076checkshipmentsiteprivs(integer)FUNCTION$CREATE FUNCTION checkshipmentsiteprivs(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipheadid ALIAS FOR $1; _check BOOLEAN; _result INTEGER; BEGIN IF (NOT fetchMetricBool('MultiWhs')) THEN RETURN true; END IF; IF (NOT fetchUsrPrefBool('selectedSites')) THEN RETURN true; END IF; SELECT COALESCE(COUNT(*), 0) INTO _result FROM ( SELECT coitem_id FROM shipitem, coitem, itemsite WHERE ( (shipitem_shiphead_id=pShipheadid) AND (coitem_id=shipitem_orderitem_id) AND (coitem_itemsite_id=itemsite_id) AND (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) UNION SELECT cohead_warehous_id FROM shipitem, coitem, cohead WHERE ( (shipitem_shiphead_id=pShipheadid) AND (coitem_id=shipitem_orderitem_id) AND (cohead_id=coitem_cohead_id) AND (cohead_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) ) AS data; IF (_result > 0) THEN RETURN false; END IF; RETURN true; END; $_$; 6DROP FUNCTION public.checkshipmentsiteprivs(integer); publicadminfalse84623125578077checksositeprivs(integer)FUNCTIONWCREATE FUNCTION checksositeprivs(integer) RETURNS boolean LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; _check BOOLEAN; _result INTEGER; BEGIN IF (NOT fetchMetricBool('MultiWhs')) THEN RETURN true; END IF; IF (NOT fetchUsrPrefBool('selectedSites')) THEN RETURN true; END IF; SELECT COALESCE(COUNT(*), 0) INTO _result FROM ( SELECT coitem_id FROM coitem, itemsite WHERE ( (coitem_cohead_id=pSoheadid) AND (coitem_itemsite_id=itemsite_id) AND (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) UNION SELECT cohead_warehous_id FROM cohead WHERE ( (cohead_id=pSoheadid) AND (cohead_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) ) AS data; IF (_result > 0) THEN RETURN false; END IF; RETURN true; END; $_$; 0DROP FUNCTION public.checksositeprivs(integer); publicadminfalse84623125578078checkvouchersiteprivs(integer)FUNCTIONCREATE FUNCTION checkvouchersiteprivs(integer) RETURNS boolean LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVoheadid ALIAS FOR $1; _check BOOLEAN; _result INTEGER; BEGIN IF (NOT fetchMetricBool('MultiWhs')) THEN RETURN true; END IF; IF (NOT fetchUsrPrefBool('selectedSites')) THEN RETURN true; END IF; SELECT COALESCE(COUNT(*), 0) INTO _result FROM ( SELECT voitem_id FROM voitem, poitem, itemsite WHERE ( (voitem_vohead_id=pVoheadid) AND (poitem_id=voitem_poitem_id) AND (poitem_itemsite_id=itemsite_id) AND (itemsite_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) UNION SELECT pohead_warehous_id FROM vohead, pohead WHERE ( (vohead_id=pVoheadid) AND (pohead_id=vohead_pohead_id) AND (pohead_warehous_id NOT IN (SELECT usrsite_warehous_id FROM usrsite WHERE (usrsite_username=getEffectiveXtUser()))) ) ) AS data; IF (_result > 0) THEN RETURN false; END IF; RETURN true; END; $_$; 5DROP FUNCTION public.checkvouchersiteprivs(integer); publicadminfalse46238125578079clearnumberissue(text, integer)FUNCTIONqCREATE FUNCTION clearnumberissue(psequence text, pnumber integer) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE __seqiss seqiss[]; __newiss seqiss[] := ARRAY[]::seqiss[]; _i INTEGER; _result BOOLEAN := FALSE; _interval TEXT := fetchMetricText('NumberIssueResetIntervalDays') || ' day'; _number INTEGER; BEGIN -- get the sequence to update SELECT orderseq_seqiss INTO __seqiss FROM orderseq WHERE (orderseq_name=psequence); IF (NOT FOUND) THEN RAISE EXCEPTION 'Invalid orderseq_name %', psequence; END IF; IF(ARRAY_LENGTH(COALESCE(__seqiss,__newiss),1) IS NULL) THEN RETURN FALSE; END IF; -- build a new array sans the number we are releasing FOR _i IN 1..ARRAY_LENGTH(__seqiss,1) LOOP IF((__seqiss[_i]).seqiss_number = pnumber) THEN _result = TRUE; -- don't bother re-adding stale numbers ELSIF (now() - _interval::INTERVAL > (__seqiss[_i]).seqiss_time) THEN IF (_number IS NULL) THEN _number := (__seqiss[_i]).seqiss_number; ELSE _number := LEAST((__seqiss[_i]).seqiss_number, _number); END IF; ELSE __newiss := __newiss || __seqiss[_i]; END IF; END LOOP; -- update the order sequence with the result UPDATE orderseq SET orderseq_seqiss = __newiss WHERE (orderseq_name=psequence); -- reset to any cleared stale number IF(_number IS NOT NULL) THEN UPDATE orderseq SET orderseq_number = _number WHERE (orderseq_name=psequence); END IF; RETURN _result; END; $$; HDROP FUNCTION public.clearnumberissue(psequence text, pnumber integer); publicadminfalse46238125578080clearnumberissue(text, text)FUNCTION'CREATE FUNCTION clearnumberissue(psequence text, pnumber text) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _castpnumber INTEGER; BEGIN -- for now, order numbers in the database are text but usually -- string representations of integers. allow for the occasional non-integer. BEGIN _castpnumber := CAST(pnumber AS INTEGER); EXCEPTION WHEN cannot_coerce OR invalid_text_representation OR numeric_value_out_of_range THEN RAISE DEBUG 'clearNumberIssue(%, %) received an unexpected pnumber', psequence, pnumber; RETURN FALSE; END; RETURN clearNumberIssue(psequence, _castpnumber); END; $$; EDROP FUNCTION public.clearnumberissue(psequence text, pnumber text); publicadminfalse46238125578081clearpayment(integer)FUNCTIONTCREATE FUNCTION clearpayment(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pApselectid ALIAS FOR $1; BEGIN DELETE FROM apselect WHERE (apselect_id=pApselectid); RETURN 1; END; $_$; ,DROP FUNCTION public.clearpayment(integer); publicadminfalse46238125578082closeaccountingperiod(integer)FUNCTION?CREATE FUNCTION closeaccountingperiod(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodid ALIAS FOR $1; _r RECORD; _nextPeriodid INTEGER; _trialbalid INTEGER; _ending NUMERIC; _currYear INTEGER; _nextYear INTEGER; BEGIN -- Bypass error checking is this the the initial period IF ( NOT ( SELECT period_initial FROM period WHERE (period_id=pPeriodid) ) ) THEN -- Check to make use that the period is not already closed IF ( ( SELECT period_closed FROM period WHERE (period_id=pPeriodid) ) ) THEN RETURN -1; END IF; -- Make sure that the day before this period belongs to another period SELECT prev.period_id AS periodid, prev.period_closed AS closed INTO _r FROM period AS prev, period AS curr WHERE ( (prev.period_end = (curr.period_start - 1)) AND (curr.period_id=pPeriodid) ); IF (NOT FOUND) THEN RETURN -2; END IF; -- Make sure that the previous period is closed IF (NOT _r.closed) THEN RETURN -3; END IF; END IF; -- Make sure that there the next period is defined SELECT next.period_id INTO _nextPeriodid FROM period AS next, period AS curr WHERE ( (next.period_start = (curr.period_end + 1)) AND (curr.period_id=pPeriodid) ); IF (NOT FOUND) THEN RETURN -4; END IF; -- Make sure that the user is not trying to prematurely close the Period IF ( ( SELECT (period_end >= CURRENT_DATE) FROM period WHERE (period_id=pPeriodid) ) ) THEN RETURN -5; END IF; SELECT yearperiod_id INTO _currYear FROM yearperiod, period WHERE ((period_end BETWEEN yearperiod_start and yearperiod_end) AND (period_id=pPeriodid)); IF (NOT FOUND) THEN _currYear := -1; END IF; SELECT yearperiod_id INTO _nextYear FROM yearperiod, period WHERE ((period_end BETWEEN yearperiod_start and yearperiod_end) AND (period_id=_nextPeriodid)); IF (NOT FOUND) THEN RETURN -6; END IF; -- Walk through the entire COA, calculating the ending balance and pushing -- it to the beginning balance for the next period FOR _r IN SELECT accnt_id, accnt_type IN ('E', 'R') AS revexp, trialbal_id, trialbal_beginning, trialbal_credits, trialbal_debits FROM accnt LEFT OUTER JOIN trialbal ON ( (trialbal_accnt_id=accnt_id) AND (trialbal_period_id=pPeriodid) ) ORDER BY accnt_id LOOP IF (_r.trialbal_id IS NULL) THEN _ending = 0; INSERT INTO trialbal ( trialbal_period_id, trialbal_accnt_id, trialbal_beginning, trialbal_ending, trialbal_dirty, trialbal_credits, trialbal_debits ) VALUES ( pPeriodid, _r.accnt_id, 0, 0, FALSE, 0, 0 ); ELSE _ending = (_r.trialbal_beginning - _r.trialbal_debits + _r.trialbal_credits); UPDATE trialbal SET trialbal_ending=_ending, trialbal_dirty = FALSE WHERE (trialbal_id=_r.trialbal_id); PERFORM forwardUpdateTrialBalance(_r.trialbal_id); END IF; IF (_r.revexp AND _currYear != _nextYear) THEN _ending := 0; END IF; -- Find the trialbal record for the next period SELECT trialbal_id INTO _trialbalid FROM trialbal WHERE ( (trialbal_period_id=_nextPeriodid) AND (trialbal_accnt_id=_r.accnt_id) ); IF (FOUND) THEN UPDATE trialbal SET trialbal_beginning = (_ending + trialbal_yearend), trialbal_ending = (_ending + trialbal_yearend - trialbal_debits + trialbal_credits) WHERE (trialbal_id=_trialbalid); ELSE INSERT INTO trialbal ( trialbal_period_id, trialbal_accnt_id, trialbal_beginning, trialbal_ending, trialbal_dirty, trialbal_credits, trialbal_debits ) VALUES(_nextPeriodid, _r.accnt_id, _ending, _ending, TRUE, 0, 0 ); END IF; END LOOP; -- Set the period_closed flag UPDATE period SET period_closed=TRUE WHERE (period_id=pPeriodid); RETURN pPeriodid; END; $_$; 5DROP FUNCTION public.closeaccountingperiod(integer); publicadminfalse84623125578083"closeaccountingyearperiod(integer)FUNCTIONCREATE FUNCTION closeaccountingyearperiod(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pYearPeriodid ALIAS FOR $1; _result INTEGER; BEGIN -- Check to make sure that the yearperiod is not already closed IF ( ( SELECT yearperiod_closed FROM yearperiod WHERE (yearperiod_id=pYearPeriodid) ) ) THEN RETURN -1; END IF; IF ( ( SELECT (count(period_id) > 0) FROM period WHERE ((period_yearperiod_id=pYearPeriodid) AND (NOT period_closed)) ) ) THEN RETURN -10; END IF; IF ( ( SELECT (count(yearperiod_id) > 0) FROM yearperiod WHERE ((yearperiod_end< ( SELECT yearperiod_end FROM yearperiod WHERE (yearperiod_id=pYearPeriodId)) ) AND (NOT yearperiod_closed)) ) ) THEN RETURN -11; END IF; -- Should we check for a previous yearperiod existing already ? -- If so then we should return -2 if one does not. -- If we did the previous yearperiod we should check to make sure that -- it is also closed. Returning -3 if it is not. -- Make sure that the user is not trying to prematurely close the YearPeriod IF ( ( SELECT (yearperiod_end >= CURRENT_DATE) FROM yearperiod WHERE (yearperiod_id=pYearPeriodid) ) ) THEN RETURN -5; END IF; -- Update the year end Retained Earnings SELECT updateRetainedEarnings(pYearPeriodid) INTO _result; IF (_result < 0) THEN RETURN _result; END IF; UPDATE yearperiod SET yearperiod_closed = TRUE WHERE yearperiod_id = pYearPeriodid; RETURN 0; END; $_$; 9DROP FUNCTION public.closeaccountingyearperiod(integer); publicadminfalse84623125578084closepo(integer)FUNCTIONCREATE FUNCTION closepo(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPoheadid ALIAS FOR $1; BEGIN UPDATE poitem SET poitem_status='C' WHERE (poitem_pohead_id=pPoheadid); -- _poitemTrigger will close pohead when the last poitem is closed -- UPDATE pohead -- SET pohead_status='C' -- WHERE (pohead_id=pPoheadid); RETURN 1; END; $_$; 'DROP FUNCTION public.closepo(integer); publicadminfalse46238125578085closewo(integer, boolean)FUNCTIONrCREATE FUNCTION closewo(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pPostMaterialVariances ALIAS FOR $2; BEGIN RETURN closeWo(pWoid, pPostMaterialVariances, CURRENT_DATE); END; $_$; 0DROP FUNCTION public.closewo(integer, boolean); publicadminfalse84623125578086closewo(integer, boolean, date)FUNCTION8CREATE FUNCTION closewo(integer, boolean, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pPostMaterialVariances ALIAS FOR $2; pTransDate ALIAS FOR $3; _woNumber TEXT; _check CHAR; _itemlocSeries INTEGER := 0; BEGIN --Comment this out --In addition to IssueToShipping driving PostProduction, --not PostProduction can drive IssueToShipping. --Must allow closing of Job items --If this is item type Job then we cannot close here --SELECT itemsite_costmethod INTO _check --FROM wo,itemsite --WHERE ((wo_id=pWoid) --AND (wo_itemsite_id=itemsite_id) --AND (itemsite_costmethod = 'J')); --IF (FOUND) THEN -- RAISE EXCEPTION 'Work orders for Job items are closed when all quantities are shipped'; --END IF; SELECT formatWoNumber(pWoid) INTO _woNumber; -- If there are any tools issued on this job then we cannot close here IF ( SELECT (count(*) > 0) FROM womatl JOIN itemsite ON (womatl_itemsite_id=itemsite_id) JOIN item ON ((itemsite_item_id=item_id) AND (item_type='T')) WHERE ((womatl_wo_id=pWoid) AND (womatl_qtyiss > 0)) ) THEN RAISE EXCEPTION 'All Tools must be returned before the W/O can be closed'; END IF; -- Distribute any remaining wo_wipvalue to G/L - debit Inventory Cost, credit WIP PERFORM insertGLTransaction( 'W/O', 'WO', _woNumber, ('Manufacturing Inventory Cost Variance for ' || item_number), getPrjAccntId(wo_prj_id, costcat_wip_accnt_id), getPrjAccntId(wo_prj_id, costcat_invcost_accnt_id), -1, COALESCE(wo_wipvalue, 0), pTransDate ) FROM wo, itemsite, item, costcat WHERE ( (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (itemsite_costcat_id=costcat_id) AND (wo_id=pWoid) ); -- Distribute any remaining wo_brdvalue to G/L - debit Inventory Cost, credit WIP PERFORM insertGLTransaction( 'W/O', 'WO', _woNumber, ('Breeder Inventory Cost Variance for ' || item_number), getPrjAccntId(wo_prj_id, costcat_wip_accnt_id), CASE WHEN(itemsite_costmethod='A') THEN costcat_asset_accnt_id ELSE getPrjAccntId(wo_prj_id, costcat_invcost_accnt_id) END, -1, COALESCE(wo_brdvalue, 0), pTransDate ) FROM wo, itemsite, item, costcat WHERE ( (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (itemsite_costcat_id=costcat_id) AND (wo_id=pWoid) ); -- Don't bother with posting variances if the qtyrcv is 0 as -- they are meaningless. IF ( ( SELECT wo_qtyrcv FROM wo WHERE (wo_id=pWoid) ) > 0 ) THEN IF (pPostMaterialVariances) THEN -- Post womatl variances INSERT INTO womatlvar ( womatlvar_number, womatlvar_subnumber, womatlvar_posted, womatlvar_parent_itemsite_id, womatlvar_component_itemsite_id, womatlvar_qtyord, womatlvar_qtyrcv, womatlvar_qtyiss, womatlvar_qtyfxd, womatlvar_qtyper, womatlvar_scrap, womatlvar_wipscrap, womatlvar_bomitem_id, womatlvar_notes, womatlvar_ref ) SELECT wo_number, wo_subnumber, pTransDate, wo_itemsite_id, womatl_itemsite_id, wo_qtyord, wo_qtyrcv, itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyiss), itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyfxd), itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyper), womatl_scrap, itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtywipscrap), womatl_bomitem_id, womatl_notes, womatl_ref FROM wo, womatl, itemsite, item WHERE ((womatl_wo_id=wo_id) AND (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_type <> 'T') AND (wo_id=pWoid)); END IF; END IF; -- Delete any P/R's created for this W/O PERFORM deletePr('W', womatl_id) FROM womatl WHERE (womatl_wo_id=pWoid); UPDATE wo SET wo_wipvalue = 0, wo_brdvalue=0, wo_status='C' WHERE (wo_id=pWoid); RETURN 1; END; $_$; 6DROP FUNCTION public.closewo(integer, boolean, date); publicadminfalse84623125978087cntctTABLECREATE TABLE cntct ( cntct_id integer NOT NULL, cntct_crmacct_id integer, cntct_addr_id integer, cntct_first_name text, cntct_last_name text, cntct_honorific text, cntct_initials text, cntct_active boolean DEFAULT true, cntct_phone text, cntct_phone2 text, cntct_fax text, cntct_email text, cntct_webaddr text, cntct_notes text, cntct_title text, cntct_number text NOT NULL, cntct_middle text, cntct_suffix text, cntct_owner_username text, cntct_name text ); DROP TABLE public.cntct; publicadminfalse59968%00 TABLE cntctCOMMENTSCOMMENT ON TABLE cntct IS 'Contact - information on how to reach a living person'; publicadminfalse187%00cntctACLREVOKE ALL ON TABLE cntct FROM PUBLIC; REVOKE ALL ON TABLE cntct FROM admin; GRANT ALL ON TABLE cntct TO admin; GRANT ALL ON TABLE cntct TO xtrole; publicadminfalse187125578094cntct()FUNCTIONCREATE FUNCTION cntct() RETURNS SETOF cntct LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row cntct%ROWTYPE; _priv TEXT; _grant BOOLEAN; BEGIN -- This query will give us the most permissive privilege the user has been granted SELECT privilege, granted INTO _priv, _grant FROM privgranted WHERE privilege IN ('MaintainAllContacts','ViewAllContacts','MaintainPersonalContacts','ViewPersonalContacts') ORDER BY granted DESC, sequence LIMIT 1; -- If have an 'All' privilege return all results IF (_priv ~ 'All' AND _grant) THEN FOR _row IN SELECT * FROM cntct LOOP RETURN NEXT _row; END LOOP; -- Otherwise if have any other grant, must be personal privilege. ELSIF (_grant) THEN FOR _row IN SELECT * FROM cntct WHERE cntct_owner_username = getEffectiveXtUser() LOOP RETURN NEXT _row; END LOOP; END IF; RETURN; END; $$; DROP FUNCTION public.cntct(); publicadminfalse846232787%00FUNCTION cntct()COMMENTqCOMMENT ON FUNCTION cntct() IS 'A table function that returns Contact results according to privilege settings.'; publicadminfalse1163125586986cntctdups(text, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean)FUNCTION$CREATE FUNCTION cntctdups(text, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS SETOF cntctdup LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSearchText ALIAS FOR $1; pSearchContactName ALIAS FOR $2; pSearchPhone ALIAS FOR $3; pSearchEmail ALIAS FOR $4; pSearchNumber ALIAS FOR $5; pSearchName ALIAS FOR $6; pShowInactive ALIAS FOR $7; pIgnoreBlanks ALIAS FOR $8; pIndentedDups ALIAS FOR $9; pCheckHnfc ALIAS FOR $10; pCheckFirst ALIAS FOR $11; pCheckMiddle ALIAS FOR $12; pCheckLast ALIAS FOR $13; pCheckSuffix ALIAS FOR $14; pCheckPhone ALIAS FOR $15; pCheckEmail ALIAS FOR $16; _cntct cntctdup%ROWTYPE; _cntctdup cntctdup%ROWTYPE; _rec RECORD; _operator TEXT := ''; _clause TEXT; _qry TEXT := ''; _return BOOLEAN := true; _text TEXT; _first BOOLEAN := true; BEGIN -- Validate IF (pIndentedDups AND NOT pCheckHnfc AND NOT pCheckFirst AND NOT pCheckMiddle AND NOT pCheckLast AND NOT pCheckSuffix AND NOT pCheckEmail AND NOT pCheckPhone) THEN RETURN; END IF; _text = quote_literal(pSearchText); IF (pIndentedDups) THEN _qry := 'SELECT -1 AS cntct_id, -1 AS cntct_crmacct_id, -1 AS cntct_addr_id,'; IF (NOT pCheckFirst) THEN _qry := _qry || ''''' AS '; END IF; _qry := _qry || ' cntct_first_name,'; IF (NOT pCheckLast) THEN _qry := _qry || ''''' AS '; END IF; _qry := _qry || ' cntct_last_name,'; IF (NOT pCheckHnfc) THEN _qry := _qry || ''''' AS '; END IF; _qry := _qry || ' cntct_honorific,'; _qry := _qry || ' '''' AS cntct_initials,'; _qry := _qry || ' NULL AS cntct_active,'; IF (NOT pCheckPhone) THEN _qry := _qry || ''''' AS '; END IF; _qry := _qry || ' cntct_phone,'; IF (NOT pCheckPhone) THEN _qry := _qry || ''''' AS '; END IF; _qry := _qry || ' cntct_phone2,'; _qry := _qry || ' '''' AS cntct_fax,'; IF (NOT pCheckEmail) THEN _qry := _qry || ''''' AS '; END IF; _qry := _qry || ' cntct_email,'; _qry := _qry || ' '''' AS cntct_webaddr,'; _qry := _qry || ' '''' AS cntct_notes,'; _qry := _qry || ' '''' AS cntct_title,'; _qry := _qry || ' '''' AS cntct_number,'; IF (NOT pCheckMiddle) THEN _qry := _qry || ''''' AS '; END IF; _qry := _qry || ' cntct_middle,'; IF (NOT pCheckSuffix) THEN _qry := _qry || ''''' AS '; END IF; _qry := _qry || ' cntct_suffix,'; _qry := _qry || ' '''' AS cntct_owner_username,'; _qry := _qry || ' '''' AS cntct_name,'; _qry := _qry || ' '''' AS crmacct_number, '; _qry := _qry || ' '''' AS crmacct_name, '; _qry := _qry || ' NULL AS addr_id, NULL AS addr_active, '''' AS addr_line1, '''' AS addr_line2, '''' AS addr_line3, '''' AS addr_city, '''' AS addr_state, '''' AS addr_postalcode, '''' AS addr_country, '''' AS addr_notes, '''' AS addr_number, cntctdup_level FROM ('; END IF; _clause := 'SELECT cntct_id, cntct_crmacct_id, cntct_addr_id, UPPER(cntct_first_name) AS cntct_first_name, UPPER(cntct_last_name) AS cntct_last_name, UPPER(cntct_honorific) AS cntct_honorific, cntct_initials, cntct_active, cntct_phone, cntct_phone2, cntct_fax, UPPER(cntct_email) AS cntct_email, cntct_webaddr, cntct_notes, cntct_title, cntct_number, UPPER(cntct_middle) AS cntct_middle, UPPER(cntct_suffix) AS cntct_suffix, cntct_owner_username, cntct_name, crmacct_number, crmacct_name, addr_id, addr_active, addr_line1, addr_line2, addr_line3, addr_city, addr_state, addr_postalcode, addr_country, addr_notes, addr_number, 0 AS cntctdup_level FROM cntct() LEFT OUTER JOIN crmacct ON (cntct_crmacct_id=crmacct_id) LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) WHERE '; IF (NOT pIndentedDups) THEN WHILE position('UPPER' in _clause) > 0 LOOP _clause := regexp_replace(_clause, 'UPPER', ''); END LOOP; END IF; _qry := _qry || _clause; IF (NOT pShowInactive) THEN _qry := _qry || ' cntct_active AND '; END IF; IF (pIgnoreBlanks) THEN _qry := _qry || ' (COALESCE(LENGTH(cntct_first_name || cntct_last_name),0) > 0) AND '; END IF; _qry := _qry || '(false '; IF (pSearchNumber) THEN _qry := _qry || ' OR (crmacct_number ~* ' || quote_literal(pSearchText) || ') '; END IF; IF (pSearchName) THEN _qry := _qry || ' OR (crmacct_name ~* ' || quote_literal(pSearchText) || ') '; END IF; IF (pSearchContactName) THEN _qry := _qry || ' OR (cntct_first_name || '' '' || cntct_last_name ~* ' || quote_literal(pSearchText) || ') '; END IF; IF (pSearchPhone) THEN _qry := _qry || ' OR (cntct_phone || '' '' || cntct_phone2 || '' '' || cntct_fax ~* ' || quote_literal(pSearchText) || ') '; END IF; IF (pSearchEmail) THEN _qry := _qry || ' OR (cntct_email ~* ' || quote_literal(pSearchText) || ') '; END IF; _qry := _qry || ' ) '; IF (pIndentedDups) THEN _qry := _qry || ') data'; _clause := ' GROUP BY cntctdup_level'; IF (pCheckHnfc) THEN _clause := _clause || ',cntct_honorific'; END IF; IF (pCheckFirst) THEN _clause := _clause || ',cntct_first_name'; END IF; IF (pCheckMiddle) THEN _clause := _clause || ',cntct_middle'; END IF; IF (pCheckLast) THEN _clause := _clause || ',cntct_last_name'; END IF; IF (pCheckSuffix) THEN _clause := _clause || ',cntct_suffix'; END IF; IF (pCheckEmail) THEN _clause := _clause || ',cntct_email'; END IF; IF (pCheckPhone) THEN _clause := _clause || ',cntct_phone'; _clause := _clause || ',cntct_phone2'; END IF; _qry := _qry || _clause; _clause := ' HAVING('; IF (pCheckHnfc) THEN _clause := _clause || 'OR COUNT(cntct_honorific) > 1 '; END IF; IF (pCheckFirst) THEN _clause := _clause || 'OR COUNT(cntct_first_name) > 1 '; END IF; IF (pCheckMiddle) THEN _clause := _clause || 'OR COUNT(cntct_middle) > 1 '; END IF; IF (pCheckLast) THEN _clause := _clause || 'OR COUNT(cntct_last_name) > 1 '; END IF; IF (pCheckSuffix) THEN _clause := _clause || 'OR COUNT(cntct_suffix) > 1 '; END IF; IF (pCheckEmail) THEN _clause := _clause || 'OR COUNT(cntct_email) > 1 '; END IF; IF (pCheckPhone) THEN _clause := _clause || 'OR (COUNT(cntct_phone) > 1 AND LENGTH(cntct_phone) > 0) '; _clause := _clause || 'OR (COUNT(cntct_phone2) > 1 AND LENGTH(cntct_phone2) > 0) '; END IF; _clause := _clause || ') '; _clause := overlay(_clause placing '' from 9 for 2); IF (pCheckHnfc) THEN _clause := _clause || 'AND LENGTH(cntct_honorific) > 0 '; END IF; IF (pCheckFirst) THEN _clause := _clause || 'AND LENGTH(cntct_first_name) > 0 '; END IF; IF (pCheckMiddle) THEN _clause := _clause || 'AND LENGTH(cntct_middle) > 0 '; END IF; IF (pCheckLast) THEN _clause := _clause || 'AND LENGTH(cntct_last_name) > 0 '; END IF; IF (pCheckSuffix) THEN _clause := _clause || 'AND LENGTH(cntct_suffix) > 0 '; END IF; IF (pCheckEmail) THEN _clause := _clause || 'AND LENGTH(cntct_email) > 0 '; END IF; _qry := _qry || _clause; END IF; _qry := _qry || ' ORDER BY cntct_last_name, cntct_first_name;'; -- raise exception '%',_qry; FOR _cntct IN EXECUTE _qry LOOP RETURN NEXT _cntct; -- If duplicates, get duplicates IF (pIndentedDups) THEN _qry := 'SELECT cntct.*, crmacct_number, crmacct_name, addr.*, 1 AS cntctdup_level FROM cntct() LEFT OUTER JOIN crmacct ON (cntct_crmacct_id=crmacct_id) LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) WHERE (true) '; IF (pCheckHnfc) THEN _qry := _qry || ' AND (UPPER(cntct_honorific)=' || quote_literal(_cntct.cntct_honorific) || ')'; END IF; IF (pCheckFirst) THEN _qry := _qry || ' AND (UPPER(cntct_first_name)=' || quote_literal(_cntct.cntct_first_name) || ')'; END IF; IF (pCheckMiddle) THEN _qry := _qry || ' AND (UPPER(cntct_middle)=' || quote_literal(_cntct.cntct_middle) || ')'; END IF; IF (pCheckLast) THEN _qry := _qry || ' AND (UPPER(cntct_last_name)=' || quote_literal(_cntct.cntct_last_name) || ')'; END IF; IF (pCheckSuffix) THEN _qry := _qry || ' AND (UPPER(cntct_suffix)=' || quote_literal(_cntct.cntct_suffix) || ')'; END IF; IF (pCheckPhone) THEN _qry := _qry || ' AND (cntct_phone=' || quote_literal(_cntct.cntct_phone) || ')'; END IF; IF (pCheckEmail) THEN _qry := _qry || ' AND (UPPER(cntct_email)=' || quote_literal(_cntct.cntct_email) || ')'; END IF; -- raise exception '%',_qry; FOR _cntctdup IN EXECUTE _qry LOOP RETURN NEXT _cntctdup; END LOOP; END IF; END LOOP; RETURN; END; $_$; DROP FUNCTION public.cntctdups(text, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean); publicadminfalse846234240125578097%cntctmerge(integer, integer, boolean)FUNCTIONG2CREATE FUNCTION cntctmerge(integer, integer, boolean) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSourceCntctId ALIAS FOR $1; pTargetCntctId ALIAS FOR $2; pPurge ALIAS FOR $3; _fk RECORD; _pk RECORD; _sel RECORD; _seq INTEGER; _col TEXT; _pkcol TEXT; _qry TEXT; _multi BOOLEAN; BEGIN -- Validate IF (pSourceCntctId IS NULL) THEN RAISE EXCEPTION 'Source contact id can not be null'; ELSIF (pTargetCntctId IS NULL) THEN RAISE EXCEPTION 'Target contact id can not be null'; ELSIF (pPurge IS NULL) THEN RAISE EXCEPTION 'Purge flag can not be null'; END IF; -- Determine where this contact is used by analyzing foreign key linkages and update each FOR _fk IN SELECT pg_namespace.nspname AS schemaname, con.relname AS tablename, conkey AS seq, conrelid AS class_id FROM pg_constraint, pg_class f, pg_class con, pg_namespace WHERE confrelid=f.oid AND conrelid=con.oid AND f.relname = 'cntct' AND con.relnamespace=pg_namespace.oid AND con.relname NOT IN ('cntctsel', 'cntctmrgd', 'mrghist','trgthist') LOOP -- Validate IF (ARRAY_UPPER(_fk.seq,1) > 1) THEN RAISE EXCEPTION 'Updates to tables where the contact is one of multiple foreign key columns is not supported. Error on Table: %', pg_namespace.nspname || '.' || con.relname; END IF; _seq := _fk.seq[1]; -- Get the specific column name SELECT attname INTO _col FROM pg_attribute, pg_class WHERE ((attrelid=pg_class.oid) AND (pg_class.oid=_fk.class_id) AND (attnum=_seq)); IF (NOT pPurge) THEN -- Cache what we're going to do so we can restore if need be. -- Start by determining the primary key column for this table. _multi := false; _qry := 'SELECT pg_attribute.attname AS key FROM pg_attribute, pg_class WHERE pg_class.relnamespace = ( SELECT oid FROM pg_namespace WHERE pg_namespace.nspname = ''' || _fk.schemaname || ''') AND pg_class.oid IN ( SELECT indexrelid FROM pg_index WHERE indisprimary = true AND indrelid IN ( SELECT oid FROM pg_class WHERE lower(relname) = ''' || _fk.tablename || ''')) AND pg_attribute.attrelid = pg_class.oid AND pg_attribute.attisdropped = false ORDER BY pg_attribute.attnum;'; FOR _pk IN EXECUTE _qry LOOP IF (_multi) THEN RAISE EXCEPTION 'Reference tables with composite primary keys not supported. Try the merge and purge option.'; END IF; _pkcol := _pk.key; _multi := true; END LOOP; -- Gather and store the history _qry := 'INSERT INTO mrghist SELECT ' || pSourceCntctId || ', ''' || _fk.schemaname || '.' || _fk.tablename || ''', ''' || _pkcol || ''', ' || _pkcol || ', ''' || _col || ''' FROM ' || _fk.schemaname || '.' || _fk.tablename || ' WHERE (' || _col || '=' || pSourceCntctId || ');'; -- raise exception '%',_qry; EXECUTE _qry; END IF; -- Merge references _qry := 'UPDATE ' || _fk.schemaname || '.' || _fk.tablename || ' SET ' || _col || '=' || pTargetCntctId || ' WHERE (' || _col || '=' || pSourceCntctId || ');'; EXECUTE _qry; END LOOP; -- Merge cases with no foreign key IF (NOT pPurge) THEN INSERT INTO mrghist SELECT pSourceCntctId, 'comment', 'comment_id', comment_id, 'comment_source_id' FROM comment WHERE ((comment_source_id= pSourceCntctId) AND (comment_source='T')); INSERT INTO mrghist SELECT pSourceCntctId, 'docass', 'docass_id', docass_id, 'docass_source_id' FROM docass WHERE ((docass_source_id= pSourceCntctId) AND (docass_source_type='T')); INSERT INTO mrghist SELECT pSourceCntctId, 'docass', 'docass_id', docass_id, 'docass_target_id' FROM docass WHERE ((docass_target_id= pSourceCntctId) AND (docass_target_type='T')); INSERT INTO mrghist SELECT pSourceCntctId, 'vendinfo', 'vend_id', vend_id, 'vend_cntct1_id' FROM vendinfo WHERE (vend_cntct1_id=pSourceCntctId); INSERT INTO mrghist SELECT pSourceCntctId, 'vendinfo', 'vend_id', vend_id, 'vend_cntct2_id' FROM vendinfo WHERE (vend_cntct2_id=pSourceCntctId); IF (fetchMetricBool('EnableBatchManager') AND packageIsEnabled('xtbatch')) THEN INSERT INTO mrghist SELECT pSourceCntctId, 'xtbatch.emlassc', 'emlassc_id', emlassc_id, 'emlassc_assc_id' FROM xtbatch.emlassc WHERE ((emlassc_assc_id= pSourceCntctId) AND (emlassc_type='T')); END IF; END IF; UPDATE comment SET comment_source_id = pTargetCntctId WHERE ((comment_source = 'T') AND (comment_source_id = pSourceCntctId)); UPDATE docass SET docass_source_id = pTargetCntctId WHERE ((docass_source_type = 'T') AND (docass_source_id = pSourceCntctId)); UPDATE docass SET docass_target_id = pTargetCntctId WHERE ((docass_target_type = 'T') AND (docass_target_id = pSourceCntctId)); UPDATE vendinfo SET vend_cntct1_id = pTargetCntctId WHERE (vend_cntct1_id = pSourceCntctId); UPDATE vendinfo SET vend_cntct2_id = pTargetCntctId WHERE (vend_cntct2_id = pSourceCntctId); IF (fetchMetricBool('EnableBatchManager') AND packageIsEnabled('xtbatch')) THEN UPDATE xtbatch.emlassc SET emlassc_assc_id = pTargetCntctId WHERE ((emlassc_type = 'T') AND (emlassc_assc_id = pSourceCntctId)); END IF; IF (NOT pPurge) THEN -- Record that this has been merged if not already IF (SELECT (COUNT(cntctmrgd_cntct_id) = 0) FROM cntctmrgd WHERE (cntctmrgd_cntct_id=pSourceCntctId)) THEN INSERT INTO cntctmrgd (cntctmrgd_cntct_id, cntctmrgd_error) VALUES (pSourceCntctId,false); END IF; END IF; -- Merge field detail to target SELECT * INTO _sel FROM cntctsel JOIN cntct ON (cntctsel_cntct_id=cntct_id) WHERE (cntctsel_cntct_id=pSourceCntctId); IF (FOUND) THEN IF (_sel.cntctsel_mrg_crmacct_id) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_crmacct_id', cntct_crmacct_id::text || '::integer' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_crmacct_id=_sel.cntct_crmacct_id WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_addr_id) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_addr_id', cntct_addr_id::text || '::integer' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_addr_id=_sel.cntct_addr_id WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_first_name) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_first_name', '''' || cntct_first_name || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_first_name=_sel.cntct_first_name WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_last_name) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_last_name', '''' || cntct_last_name || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_last_name=_sel.cntct_last_name WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_honorific) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_honorific', '''' || cntct_honorific || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_honorific=_sel.cntct_honorific WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_initials) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_initials', '''' || cntct_initials || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_initials=_sel.cntct_initials WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_phone) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_phone', '''' || cntct_phone || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_phone=_sel.cntct_phone WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_phone2) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_phone2', '''' || cntct_phone2 || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_phone2=_sel.cntct_phone2 WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_fax) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_fax', '''' || cntct_fax || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_fax=_sel.cntct_fax WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_email) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_email', '''' || cntct_email || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_email=_sel.cntct_email WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_webaddr) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_webaddr', '''' || cntct_webaddr || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_webaddr=_sel.cntct_webaddr WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_notes) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_notes', '''' || cntct_notes || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_notes=cntct_notes || ' ' || _sel.cntct_notes WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_title) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_title', '''' || cntct_title || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_title=_sel.cntct_title WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_middle) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_middle', '''' || cntct_middle || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_middle=_sel.cntct_middle WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_suffix) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_suffix', '''' || cntct_suffix || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_suffix=_sel.cntct_suffix WHERE (cntct_id=pTargetCntctId); END IF; IF (_sel.cntctsel_mrg_owner_username) THEN IF (NOT pPurge) THEN INSERT INTO trgthist SELECT pSourceCntctId,pTargetCntctId,'cntct_owner_username', '''' || cntct_owner_username || '''' FROM cntct WHERE (cntct_id=pTargetCntctId); END IF; UPDATE cntct SET cntct_owner_username=_sel.cntct_owner_username WHERE (cntct_id=pTargetCntctId); END IF; ELSE RAISE EXCEPTION 'Source Contact not Found'; END IF; -- Disposition source contact IF (pPurge) THEN DELETE FROM cntct WHERE cntct_id = pSourceCntctId; END IF; -- Deactivate contact UPDATE cntct SET cntct_active = false WHERE (cntct_id=pSourceCntctId); -- Clean up DELETE FROM cntctsel WHERE (cntctsel_cntct_id=pSourceCntctId); RETURN true; END; $_$; <DROP FUNCTION public.cntctmerge(integer, integer, boolean); publicadminfalse46238125578099cntctrestore(integer)FUNCTIONCREATE FUNCTION cntctrestore(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCntctId ALIAS FOR $1; _r RECORD; _qry TEXT; BEGIN -- Validate SELECT * INTO _r FROM cntctmrgd WHERE (cntctmrgd_cntct_id=pCntctId); IF (NOT FOUND) THEN RETURN false; END IF; -- Gather the list of affected records FOR _r IN SELECT * FROM mrghist WHERE (mrghist_cntct_id=pCntctId) LOOP -- Restore the old references _qry := 'UPDATE ' || _r.mrghist_table || ' SET ' || _r.mrghist_cntct_col || '=' || pCntctId || ' WHERE (' || _r.mrghist_pkey_col || '=' || _r.mrghist_pkey_id || ');'; EXECUTE _qry; END LOOP; -- Gather the list of affected fields FOR _r IN SELECT * FROM trgthist WHERE (trgthist_src_cntct_id=pCntctId) LOOP -- Restore the old values _qry := 'UPDATE cntct SET ' || _r.trgthist_col || '=' || _r.trgthist_value || ' WHERE (cntct_id=' || _r.trgthist_trgt_cntct_id || ');'; EXECUTE _qry; END LOOP; -- Clean up UPDATE cntct SET cntct_active=true WHERE (cntct_id=pCntctId); DELETE FROM mrghist WHERE (mrghist_cntct_id=pCntctId); DELETE FROM trgthist WHERE (trgthist_src_cntct_id=pCntctId); DELETE FROM cntctmrgd WHERE (cntctmrgd_cntct_id=pCntctId); RETURN true; END; $_$; ,DROP FUNCTION public.cntctrestore(integer); publicadminfalse84623125578100cntctselect(integer, boolean)FUNCTIONCREATE FUNCTION cntctselect(integer, boolean) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCntctId ALIAS FOR $1; pTarget ALIAS FOR $2; BEGIN -- If target, delete any other targets IF (pTarget) THEN DELETE FROM cntctsel WHERE cntctsel_target; END IF; -- Delete any previous selection of this contact DELETE FROM cntctsel WHERE cntctsel_cntct_id=pCntctId; -- Add this contact in appropriate selection state INSERT INTO cntctsel (cntctsel_cntct_id, cntctsel_target) VALUES (pCntctId,pTarget); RETURN true; END; $_$; 4DROP FUNCTION public.cntctselect(integer, boolean); publicadminfalse46238125578101 cntctselectcol(integer, integer)FUNCTION CREATE FUNCTION cntctselectcol(integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCntctId ALIAS FOR $1; pColNumber ALIAS FOR $2; BEGIN IF (pColNumber = 2 OR pColNumber = 3) THEN UPDATE cntctsel SET cntctsel_mrg_crmacct_id=false WHERE (cntctsel_mrg_crmacct_id AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_crmacct_id=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 4) THEN UPDATE cntctsel SET cntctsel_mrg_honorific=false WHERE (cntctsel_mrg_honorific AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_honorific=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 5) THEN UPDATE cntctsel SET cntctsel_mrg_first_name=false WHERE (cntctsel_mrg_first_name AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_first_name=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 6) THEN UPDATE cntctsel SET cntctsel_mrg_middle=false WHERE (cntctsel_mrg_middle AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_middle=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 7) THEN UPDATE cntctsel SET cntctsel_mrg_last_name=false WHERE (cntctsel_mrg_last_name AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_last_name=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 8) THEN UPDATE cntctsel SET cntctsel_mrg_suffix=false WHERE (cntctsel_mrg_suffix AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_suffix=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 9) THEN UPDATE cntctsel SET cntctsel_mrg_initials=false WHERE (cntctsel_mrg_initials AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_initials=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 10) THEN UPDATE cntctsel SET cntctsel_mrg_phone=false WHERE (cntctsel_mrg_phone AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_phone=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 11) THEN UPDATE cntctsel SET cntctsel_mrg_phone2=false WHERE (cntctsel_mrg_phone2 AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_phone2=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 12) THEN UPDATE cntctsel SET cntctsel_mrg_fax=false WHERE (cntctsel_mrg_fax AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_fax=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 13) THEN UPDATE cntctsel SET cntctsel_mrg_email=false WHERE (cntctsel_mrg_email AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_email=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 14) THEN UPDATE cntctsel SET cntctsel_mrg_webaddr=false WHERE (cntctsel_mrg_webaddr AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_webaddr=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 15) THEN UPDATE cntctsel SET cntctsel_mrg_title=false WHERE (cntctsel_mrg_title AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_title=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 16) THEN UPDATE cntctsel SET cntctsel_mrg_owner_username=false WHERE (cntctsel_mrg_owner_username AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_owner_username=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber = 17) THEN UPDATE cntctsel SET cntctsel_mrg_notes=false WHERE (cntctsel_mrg_notes AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_notes=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; ELSIF (pColNumber >= 18) THEN UPDATE cntctsel SET cntctsel_mrg_addr_id=false WHERE (cntctsel_mrg_addr_id AND cntctsel_cntct_id != pCntctId); UPDATE cntctsel SET cntctsel_mrg_addr_id=true WHERE (cntctsel_cntct_id = pCntctId); RETURN true; END IF; RETURN false; END; $_$; 7DROP FUNCTION public.cntctselectcol(integer, integer); publicadminfalse46238125578102cntctused(integer)FUNCTION CREATE FUNCTION cntctused(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCntctId ALIAS FOR $1; _fk RECORD; _r RECORD; _seq INTEGER; _col TEXT; _qry TEXT; BEGIN -- Determine where this contact is used by analyzing foreign key linkages -- but ignore child tables and those with impermanent relationships FOR _fk IN SELECT pg_namespace.nspname AS schemaname, con.relname AS tablename, conkey AS seq, conrelid AS class_id FROM pg_constraint, pg_class f, pg_class con, pg_namespace WHERE confrelid=f.oid AND conrelid=con.oid AND f.relname = 'cntct' AND con.relnamespace=pg_namespace.oid AND con.relname NOT IN ('cntctaddr', 'cntctdata', 'cntcteml', 'cohead', 'pohead', 'quhead', 'tohead', 'cntctsel', 'cntctmrgd', 'mrghist', 'trgthist') LOOP -- Validate IF (ARRAY_UPPER(_fk.seq,1) > 1) THEN RAISE EXCEPTION 'Cannot check dependencies when the contact is one of multiple foreign key columns (%.%) [xtuple: fkeycheck, -1, %, %]', _fk.nspname, _fk.relname, _fk.nspname, _fk.relname; END IF; _seq := _fk.seq[1]; -- Get the specific column name SELECT attname INTO _col FROM pg_attribute, pg_class WHERE ((attrelid=pg_class.oid) AND (pg_class.oid=_fk.class_id) AND (attnum=_seq)); -- See if there are dependencies _qry := 'SELECT * FROM ' || _fk.schemaname || '.' || _fk.tablename || ' WHERE ('|| _col || '=' || pCntctId || ');'; FOR _r IN EXECUTE _qry LOOP RETURN true; END LOOP; END LOOP; RETURN false; END; $_$; )DROP FUNCTION public.cntctused(integer); publicadminfalse46238125578103coheadstatecolor(integer)FUNCTIONCREATE FUNCTION coheadstatecolor(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCoheadId ALIAS FOR $1; _shipheadid INTEGER; _result TEXT := ''; BEGIN IF (pCoheadid IS NULL) THEN RAISE EXCEPTION 'Customer Id is required.'; END IF; SELECT shiphead_id INTO _shipheadid FROM cohead JOIN shiphead ON ((shiphead_order_id=cohead_id) AND (shiphead_order_type='SO')) JOIN shipitem ON (shiphead_id=shipitem_shiphead_id) WHERE ((cohead_id=pCoheadId) AND (NOT shipitem_invoiced)) ORDER BY shiphead_id DESC LIMIT 1; IF (FOUND) THEN SELECT CASE WHEN ((shiphead_shipped) AND (COALESCE(shiphead_order_id,0) > 0) AND (SUM(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned)) <= 0)) THEN 'altemphasis' WHEN ((COALESCE(cobmisc_cohead_id,0) > 0) AND (SUM(noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned)) > 0)) THEN 'error' WHEN (NOT shiphead_shipped) THEN 'emphasis' END INTO _result FROM cohead JOIN coitem ON (cohead_id=coitem_cohead_id) JOIN shiphead ON ((shiphead_order_id=cohead_id) AND (shiphead_order_type='SO')) JOIN shipitem ON (shiphead_id=shipitem_shiphead_id) LEFT OUTER JOIN (SELECT DISTINCT cobmisc_cohead_id FROM cobmisc) AS cobmisc ON (cobmisc_cohead_id=cohead_id) WHERE (shiphead_id=_shipheadid) GROUP BY shiphead_id,shiphead_shipped,shiphead_order_id,cobmisc_cohead_id ORDER BY shiphead_id DESC; ELSE _result := ''; END IF; RETURN _result; END; $_$; 0DROP FUNCTION public.coheadstatecolor(integer); publicadminfalse46238125578104compareversion(text, text)FUNCTIONCREATE FUNCTION compareversion(pleft text, pright text DEFAULT split_part(version(), ' '::text, 2)) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- Returns 1 if the left version is greater than the right version -- -1 if the right is greater than the left -- 0 if the versions are equal. -- parameter two defaults to current server version DECLARE _left SMALLINT[] := _normalizeVersion(pLeft); _right SMALLINT[] := _normalizeVersion(pRight); _result SMALLINT := 0; _major SMALLINT := 1; -- 4 _minor SMALLINT := 2; -- .5 _point SMALLINT := 3; -- .6 _qual SMALLINT := 4; -- beta _qualn SMALLINT := 5; -- 2 _subq SMALLINT := 6; -- A BEGIN CASE WHEN _left[_major] > _right[_major] THEN _result := 1; WHEN _left[_major] < _right[_major] THEN _result := -1; WHEN _left[_minor] > _right[_minor] THEN _result := 1; WHEN _left[_minor] < _right[_minor] THEN _result := -1; WHEN _left[_point] > _right[_point] THEN _result := 1; WHEN _left[_point] < _right[_point] THEN _result := -1; WHEN _left[_qual] > _right[_qual] THEN _result := 1; WHEN _left[_qual] < _right[_qual] THEN _result := -1; WHEN _left[_qualn] > _right[_qualn] THEN _result := 1; WHEN _left[_qualn] < _right[_qualn] THEN _result := -1; WHEN _left[_subq] > _right[_subq] THEN _result := 1; WHEN _left[_subq] < _right[_subq] THEN _result := -1; WHEN _left[_subq] = _right[_subq] THEN _result := 0; END CASE; RETURN _result; END; $$; >DROP FUNCTION public.compareversion(pleft text, pright text); publicadminfalse46238125578105concataggsfunc(text, text)FUNCTIONJCREATE FUNCTION concataggsfunc(text, text) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE prevstate ALIAS FOR $1; newval ALIAS FOR $2; BEGIN RETURN prevstate || newval; END; $_$; 1DROP FUNCTION public.concataggsfunc(text, text); publicadminfalse84623125578106consolidatelocations(integer)FUNCTIONCREATE FUNCTION consolidatelocations(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; _r RECORD; BEGIN UPDATE itemloc SET itemloc_consolflag = TRUE WHERE (itemloc_itemsite_id=pItemsiteid); FOR _r IN SELECT itemloc_location_id, SUM(itemloc_qty) AS qty FROM itemloc WHERE (itemloc_itemsite_id=pItemsiteid) GROUP BY itemloc_location_id LOOP INSERT INTO itemloc ( itemloc_itemsite_id, itemloc_location_id, itemloc_expiration, itemloc_qty, itemloc_consolflag ) VALUES ( pItemsiteid, _r.itemloc_location_id, endOfTime(), _r.qty, FALSE ); END LOOP; DELETE FROM itemloc WHERE ( (itemloc_itemsite_id=pItemsiteid) AND (itemloc_consolflag) ); RETURN 1; END; $_$; 4DROP FUNCTION public.consolidatelocations(integer); publicadminfalse46238125578107"convertcustomertoprospect(integer)FUNCTIONCREATE FUNCTION convertcustomertoprospect(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustId ALIAS FOR $1; _c RECORD; BEGIN SELECT * INTO _c FROM custinfo WHERE (cust_id=pCustId); INSERT INTO prospect ( prospect_id, prospect_active, prospect_number, prospect_name, prospect_cntct_id, prospect_taxzone_id, prospect_salesrep_id, prospect_warehous_id, prospect_comments ) VALUES ( _c.cust_id, _c.cust_active, _c.cust_number, _c.cust_name, _c.cust_cntct_id, _c.cust_taxzone_id, CASE WHEN(_c.cust_salesrep_id > 0) THEN _c.cust_salesrep_id ELSE NULL END, CASE WHEN(_c.cust_preferred_warehous_id > 0) THEN _c.cust_preferred_warehous_id ELSE NULL END, _c.cust_comments); DELETE FROM custinfo WHERE (cust_id=pCustId); RETURN pCustId; END; $_$; 9DROP FUNCTION public.convertcustomertoprospect(integer); publicadminfalse84623s125578108"convertprospecttocustomer(integer)FUNCTION!CREATE FUNCTION convertprospecttocustomer(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN convertProspectToCustomer($1, FALSE); END; $_$; 9DROP FUNCTION public.convertprospecttocustomer(integer); publicadminfalse84623125578109+convertprospecttocustomer(integer, boolean)FUNCTIONW CREATE FUNCTION convertprospecttocustomer(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pProspectId ALIAS FOR $1; pdoquotes ALIAS FOR $2; _p RECORD; _q RECORD; BEGIN SELECT * INTO _p FROM prospect WHERE (prospect_id=pProspectId); IF (EXISTS(SELECT cust_id FROM custinfo WHERE cust_id=pProspectId)) THEN RAISE EXCEPTION '[xtuple: convertProspectToCustomer, -10]'; END IF; INSERT INTO custinfo ( cust_id, cust_active, cust_number, cust_name, cust_cntct_id, cust_taxzone_id, cust_comments, cust_creditstatus, cust_salesrep_id, cust_preferred_warehous_id, cust_terms_id, cust_custtype_id, cust_shipform_id, cust_shipvia, cust_balmethod, cust_ffshipto, cust_backorder, cust_partialship, cust_creditlmt, cust_creditrating, cust_commprcnt, cust_discntprcnt, cust_blanketpos, cust_shipchrg_id, cust_ffbillto, cust_usespos, cust_emaildelivery, cust_autoupdatestatus, cust_autoholdorders, cust_soemaildelivery ) SELECT _p.prospect_id, _p.prospect_active, _p.prospect_number, _p.prospect_name, _p.prospect_cntct_id, _p.prospect_taxzone_id, _p.prospect_comments, 'G', salesrep_id, COALESCE(_p.prospect_warehous_id, -1), FetchMetricValue('DefaultTerms'), FetchMetricValue('DefaultCustType'), FetchMetricValue('DefaultShipFormId'), COALESCE(FetchMetricValue('DefaultShipViaId'),-1), FetchMetricText('DefaultBalanceMethod'), FetchMetricBool('DefaultFreeFormShiptos'), FetchMetricBool('DefaultBackOrders'), FetchMetricBool('DefaultPartialShipments'), FetchMetricValue('SOCreditLimit'), FetchMetricText('SOCreditRate'), salesrep_commission, 0, false, COALESCE(FetchMetricValue('DefaultShipChrgId'), -1), false, false, false, false, false, false FROM salesrep WHERE (salesrep_id=COALESCE(_p.prospect_salesrep_id, FetchMetricValue('DefaultSalesRep'))); DELETE FROM prospect WHERE (prospect_id=pprospectId); IF (pdoquotes) THEN BEGIN FOR _q IN SELECT quhead_number, convertQuote(quhead_id) AS err FROM quhead WHERE ((COALESCE(quhead_expire, endOfTime()) >= CURRENT_DATE) AND (quhead_cust_id=pProspectId)) LOOP IF (_q.err < 0) THEN RAISE WARNING 'Quote % for % didn''t convert to a Sales Order [xtuple: convertQuote, %]', _q.quhead_number, _p.prospect_number, _q.err; END IF; END LOOP; EXCEPTION WHEN OTHERS THEN RAISE WARNING 'Ignored errors convering quotes: % %', SQLSTATE, SQLERRM; END; END IF; RETURN pProspectId; END; $_$; BDROP FUNCTION public.convertprospecttocustomer(integer, boolean); publicadminfalse84623125578110convertquote(integer)FUNCTIONA3CREATE FUNCTION convertquote(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuheadid ALIAS FOR $1; _qunumber TEXT; _ponumber TEXT; _soheadid INTEGER; _soitemid INTEGER; _orderid INTEGER; _ordertype CHARACTER(1); _creditstatus TEXT; _usespos BOOLEAN := false; _blanketpos BOOLEAN := true; _showConvertedQuote BOOLEAN := false; _prospectid INTEGER; _r RECORD; _soNum TEXT; BEGIN -- Check to make sure the quote has not expired IF (SELECT COALESCE(quhead_expire, endOfTime()) < CURRENT_DATE FROM quhead WHERE(quhead_id=pQuheadid)) THEN RETURN -6; END IF; -- Check to make sure that all of the quote items have a valid itemsite SELECT quitem_id INTO _r FROM quitem LEFT OUTER JOIN itemsite ON (quitem_itemsite_id=itemsite_id) WHERE ((itemsite_id IS NULL) AND (quitem_quhead_id=pQuheadid)); IF (FOUND) THEN PERFORM postEvent('CannotConvertQuote', 'Q', quhead_id, quhead_warehous_id, quhead_number, NULL, NULL, NULL, NULL) FROM quhead WHERE (quhead_id=pQuheadid); RETURN -1; END IF; SELECT cust_creditstatus, cust_usespos, cust_blanketpos INTO _creditstatus, _usespos, _blanketpos FROM quhead, custinfo WHERE ((quhead_cust_id=cust_id) AND (quhead_id=pQuheadid)); IF (NOT FOUND) THEN SELECT prospect_id INTO _prospectid FROM quhead, prospect WHERE ((quhead_cust_id=prospect_id) AND (quhead_id=pQuheadid)); IF (NOT FOUND) THEN RETURN -2; ELSE RETURN -3; END IF; ELSIF (_creditstatus = 'H' AND NOT checkPrivilege('CreateSOForHoldCustomer')) THEN RETURN -4; ELSIF (_creditstatus = 'W' AND NOT checkPrivilege('CreateSOForWarnCustomer')) THEN RETURN -5; END IF; IF (_usespos) THEN SELECT quhead_number, COALESCE(quhead_custponumber, ''), cohead_id INTO _qunumber, _ponumber, _soheadid FROM quhead LEFT OUTER JOIN cohead ON ( (cohead_cust_id=quhead_cust_id) AND (UPPER(cohead_custponumber)=UPPER(quhead_custponumber)) ) WHERE (quhead_id=pQuheadid); IF (_ponumber = '') THEN RAISE EXCEPTION 'Customer PO required for Quote % [xtuple: convertQuote, -7, %]', _qunumber, _qunumber; END IF; IF ( (NOT _blanketpos) AND (_soheadid IS NOT NULL) ) THEN RAISE EXCEPTION 'Duplicate Customer PO % for Quote % [xtuple: convertQuote, -8, %, %]', _ponumber, _qunumber, _ponumber, _qunumber; END IF; END IF; PERFORM quhead_number, cohead_id FROM quhead, cohead WHERE quhead_id = pQuheadid AND cohead_number = quhead_number; IF (FOUND) THEN SELECT fetchSoNumber() INTO _soNum; ELSE SELECT quhead_number INTO _soNum FROM quhead WHERE quhead_id = pQuheadid; END IF; SELECT NEXTVAL('cohead_cohead_id_seq') INTO _soheadid; INSERT INTO cohead ( cohead_id, cohead_number, cohead_cust_id, cohead_orderdate, cohead_packdate, cohead_custponumber, cohead_warehous_id, cohead_billtoname, cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, cohead_billtocity, cohead_billtostate, cohead_billtozipcode, cohead_billtocountry, cohead_shipto_id, cohead_shiptoname, cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3, cohead_shiptocity, cohead_shiptostate, cohead_shiptozipcode, cohead_shiptocountry, cohead_salesrep_id, cohead_commission, cohead_terms_id, cohead_shipchrg_id, cohead_shipform_id, cohead_fob, cohead_shipvia, cohead_ordercomments, cohead_shipcomments, cohead_freight, cohead_misc, cohead_misc_accnt_id, cohead_misc_descrip, cohead_holdtype, cohead_quote_number, cohead_prj_id, cohead_curr_id, cohead_taxzone_id, cohead_taxtype_id, cohead_shipto_cntct_id, cohead_shipto_cntct_honorific, cohead_shipto_cntct_first_name, cohead_shipto_cntct_middle, cohead_shipto_cntct_last_name, cohead_shipto_cntct_suffix, cohead_shipto_cntct_phone, cohead_shipto_cntct_title, cohead_shipto_cntct_fax, cohead_shipto_cntct_email, cohead_billto_cntct_id, cohead_billto_cntct_honorific, cohead_billto_cntct_first_name, cohead_billto_cntct_middle, cohead_billto_cntct_last_name, cohead_billto_cntct_suffix, cohead_billto_cntct_phone, cohead_billto_cntct_title, cohead_billto_cntct_fax, cohead_billto_cntct_email, cohead_ophead_id, cohead_calcfreight, cohead_saletype_id, cohead_shipzone_id ) SELECT _soheadid, _soNum, quhead_cust_id, CURRENT_DATE, quhead_packdate, quhead_custponumber, quhead_warehous_id, quhead_billtoname, quhead_billtoaddress1, quhead_billtoaddress2, quhead_billtoaddress3, quhead_billtocity, quhead_billtostate, quhead_billtozip, quhead_billtocountry, quhead_shipto_id, quhead_shiptoname, quhead_shiptoaddress1, quhead_shiptoaddress2, quhead_shiptoaddress3, quhead_shiptocity, quhead_shiptostate, quhead_shiptozipcode, quhead_shiptocountry, quhead_salesrep_id, quhead_commission, quhead_terms_id, cust_shipchrg_id, cust_shipform_id, quhead_fob, quhead_shipvia, quhead_ordercomments, quhead_shipcomments, quhead_freight, quhead_misc, quhead_misc_accnt_id, quhead_misc_descrip, 'N', quhead_number, quhead_prj_id, quhead_curr_id, quhead_taxzone_id, quhead_taxtype_id, quhead_shipto_cntct_id, quhead_shipto_cntct_honorific, quhead_shipto_cntct_first_name, quhead_shipto_cntct_middle, quhead_shipto_cntct_last_name, quhead_shipto_cntct_suffix, quhead_shipto_cntct_phone, quhead_shipto_cntct_title, quhead_shipto_cntct_fax, quhead_shipto_cntct_email, quhead_billto_cntct_id, quhead_billto_cntct_honorific, quhead_billto_cntct_first_name, quhead_billto_cntct_middle, quhead_billto_cntct_last_name, quhead_billto_cntct_suffix, quhead_billto_cntct_phone, quhead_billto_cntct_title, quhead_billto_cntct_fax, quhead_billto_cntct_email, quhead_ophead_id, quhead_calcfreight, quhead_saletype_id, quhead_shipzone_id FROM quhead JOIN custinfo ON (cust_id=quhead_cust_id) WHERE (quhead_id=pQuheadid); -- Move Documents UPDATE url SET url_source_id = _soheadid, url_source = 'S' WHERE ((url_source='Q') AND (url_source_id = pQuheadid)); UPDATE imageass SET imageass_source_id = _soheadid, imageass_source = 'S' WHERE ((imageass_source='Q') AND (imageass_source_id = pQuheadid)); UPDATE docass SET docass_source_id = _soheadid, docass_source_type = 'S' WHERE ((docass_source_type='Q') AND (docass_source_id = pQuheadid)); -- Move Email IF (fetchMetricBool('EnableBatchManager')) THEN UPDATE xtbatch.emlassc SET emlassc_type='S', emlassc_assc_id=_soheadid WHERE ((emlassc_type='Q') AND (emlassc_assc_id=pQuheadid)); END IF; -- Copy Characteristics INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price) SELECT 'SO', _soheadid, charass_char_id, charass_value, charass_default, charass_price FROM charass WHERE ((charass_target_type='QU') AND (charass_target_id=pQuheadid)); -- Copy Comments INSERT INTO comment ( comment_cmnttype_id, comment_source, comment_source_id, comment_date, comment_user, comment_text, comment_public ) SELECT comment_cmnttype_id, 'S', _soheadid, comment_date, comment_user, ('Quote-' || comment_text), comment_public FROM comment WHERE ( (comment_source='Q') AND (comment_source_id=pQuheadid) ); FOR _r IN SELECT quitem.*, quhead_number, quhead_prj_id, quhead_saletype_id, itemsite_item_id, itemsite_leadtime, itemsite_createsopo, itemsite_createsopr, item_type, COALESCE(quitem_itemsrc_id, itemsrc_id, -1) AS itemsrcid FROM quhead JOIN quitem ON (quitem_quhead_id=quhead_id) JOIN itemsite ON (itemsite_id=quitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) LEFT OUTER JOIN itemsrc ON ( (itemsrc_item_id=item_id) AND (itemsrc_default) ) WHERE (quhead_id=pQuheadid) ORDER BY quitem_linenumber LOOP SELECT NEXTVAL('coitem_coitem_id_seq') INTO _soitemid; INSERT INTO coitem ( coitem_id, coitem_cohead_id, coitem_linenumber, coitem_itemsite_id, coitem_status, coitem_scheddate, coitem_promdate, coitem_price, coitem_custprice, coitem_qtyord, coitem_qtyshipped, coitem_qtyreturned, coitem_qty_uom_id, coitem_qty_invuomratio, coitem_price_uom_id, coitem_price_invuomratio, coitem_unitcost, coitem_prcost, coitem_custpn, coitem_memo, coitem_taxtype_id, coitem_order_id ) VALUES ( _soitemid, _soheadid, _r.quitem_linenumber, _r.quitem_itemsite_id, 'O', _r.quitem_scheddate, _r.quitem_promdate, _r.quitem_price, _r.quitem_custprice, _r.quitem_qtyord, 0, 0, _r.quitem_qty_uom_id, _r.quitem_qty_invuomratio, _r.quitem_price_uom_id, _r.quitem_price_invuomratio, _r.quitem_unitcost, _r.quitem_prcost, _r.quitem_custpn, _r.quitem_memo, _r.quitem_taxtype_id, -1 ); IF (fetchMetricBool('enablextcommissionission')) THEN PERFORM xtcommission.getSalesReps(quhead_cust_id, quhead_shipto_id, _r.itemsite_item_id, _r.quhead_saletype_id, _r.quitem_price, _r.quitem_custprice, _soitemid, 'SalesItem') FROM quhead WHERE (quhead_id=pQuheadid); END IF; -- Copy Characteristics INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price) SELECT 'SI', _soitemid, charass_char_id, charass_value, charass_default, charass_price FROM charass WHERE ((charass_target_type='QI') AND (charass_target_id=_r.quitem_id)); -- Copy Comments INSERT INTO comment ( comment_cmnttype_id, comment_source, comment_source_id, comment_date, comment_user, comment_text ) SELECT comment_cmnttype_id, 'SI', _soitemid, comment_date, comment_user, ('Quote-' || comment_text) FROM comment WHERE ( (comment_source='QI') AND (comment_source_id=_r.quitem_id) ); _orderid := -1; _ordertype := ''; IF (_r.quitem_createorder) THEN IF (_r.item_type IN ('M')) THEN SELECT createWo( CAST(_soNum AS INTEGER), supply.itemsite_id, 1, (_r.quitem_qtyord * _r.quitem_qty_invuomratio), _r.itemsite_leadtime, _r.quitem_scheddate, _r.quitem_memo, 'S', _soitemid, _r.quhead_prj_id ) INTO _orderId FROM itemsite sold, itemsite supply WHERE ((sold.itemsite_item_id=supply.itemsite_item_id) AND (supply.itemsite_warehous_id=_r.quitem_order_warehous_id) AND (sold.itemsite_id=_r.quitem_itemsite_id) ); _orderType := 'W'; INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value) SELECT 'W', _orderId, charass_char_id, charass_value FROM charass WHERE ((charass_target_type='QI') AND (charass_target_id=_r.quitem_id)); ELSIF ( (_r.item_type IN ('P', 'O')) AND (_r.itemsite_createsopr) ) THEN SELECT createPr( CAST(_soNum AS INTEGER), _r.quitem_itemsite_id, (_r.quitem_qtyord * _r.quitem_qty_invuomratio), _r.quitem_scheddate, '', 'S', _soitemid ) INTO _orderId; _orderType := 'R'; UPDATE pr SET pr_prj_id=_r.quhead_prj_id WHERE pr_id=_orderId; ELSIF ( (_r.item_type IN ('P', 'O')) AND (_r.itemsite_createsopo) ) THEN IF (_r.quitem_prcost=0) THEN SELECT createPurchaseToSale(_soitemid, _r.itemsrcid, _r.quitem_dropship) INTO _orderId; ELSE SELECT createPurchaseToSale(_soitemid, _r.itemsrcid, _r.quitem_dropship, _r.quitem_prcost) INTO _orderId; END IF; _orderType := 'P'; END IF; UPDATE coitem SET coitem_order_type=_ordertype, coitem_order_id=_orderid WHERE (coitem_id=_soitemid); END IF; END LOOP; SELECT metric_value INTO _showConvertedQuote FROM metric WHERE metric_name = 'ShowQuotesAfterSO'; -- bug 26513 - mobilized databases delete the quote in a cohead trigger when cohead_wasquote -- on INSERT. set the flag late, otherwise quitems may be removed before they can be copied UPDATE cohead SET cohead_wasquote = TRUE WHERE cohead_id = _soheadid; IF (_showConvertedQuote) THEN UPDATE quhead SET quhead_status= 'C' WHERE (quhead_id = pQuheadid); ELSE PERFORM deleteQuote(pQuheadid); END IF; RETURN _soheadid; END; $_$; ,DROP FUNCTION public.convertquote(integer); publicadminfalse84623125578112convertquotetoinvoice(integer)FUNCTION8CREATE FUNCTION convertquotetoinvoice(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuheadid ALIAS FOR $1; _qunumber TEXT; _ponumber TEXT; _iheadid INTEGER; _iitemid INTEGER; _orderid INTEGER; _ordertype CHARACTER(1); _creditstatus TEXT; _usespos BOOLEAN := false; _blanketpos BOOLEAN := true; _showConvertedQuote BOOLEAN := false; _prospectid INTEGER; _r RECORD; _inNum TEXT; BEGIN -- Check to make sure the quote has not expired IF (SELECT COALESCE(quhead_expire, endOfTime()) < CURRENT_DATE FROM quhead WHERE(quhead_id=pQuheadid)) THEN RETURN -6; END IF; -- Check to make sure that all of the quote items have a valid itemsite SELECT quitem_id INTO _r FROM quitem LEFT OUTER JOIN itemsite ON (quitem_itemsite_id=itemsite_id) WHERE ((itemsite_id IS NULL) AND (quitem_quhead_id=pQuheadid)); IF (FOUND) THEN PERFORM postEvent('CannotConvertQuote', 'Q', quhead_id, quhead_warehous_id, quhead_number, NULL, NULL, NULL, NULL) FROM quhead WHERE (quhead_id=pQuheadid); RETURN -1; END IF; -- Get Credit Stat, Uses POs and Blanket POs SELECT cust_creditstatus, cust_usespos, cust_blanketpos INTO _creditstatus, _usespos, _blanketpos FROM quhead, custinfo WHERE ((quhead_cust_id=cust_id) AND (quhead_id=pQuheadid)); -- Check to see if customer or prospect IF (NOT FOUND) THEN SELECT prospect_id INTO _prospectid FROM quhead, prospect WHERE ((quhead_cust_id=prospect_id) AND (quhead_id=pQuheadid)); IF (NOT FOUND) THEN RETURN -2; ELSE RETURN -3; END IF; ELSIF (_creditstatus = 'H' AND NOT hasPriv('CreateSOForHoldCustomer')) THEN RETURN -4; ELSIF (_creditstatus = 'W' AND NOT hasPriv('CreateSOForWarnCustomer')) THEN RETURN -5; END IF; -- PO/blanket PO checks IF (_usespos) THEN SELECT quhead_number, COALESCE(quhead_custponumber, ''), invchead_id INTO _qunumber, _ponumber, _iheadid FROM quhead LEFT OUTER JOIN invchead ON ( (invchead_cust_id=quhead_cust_id) AND (UPPER(invchead_ponumber)=UPPER(quhead_custponumber)) ) WHERE (quhead_id=pQuheadid); IF (_ponumber = '') THEN RAISE EXCEPTION 'Customer PO required for Quote % [xtuple: convertQuote, -7, %]', _qunumber, _qunumber; END IF; IF ( (NOT _blanketpos) AND (_iheadid IS NOT NULL) ) THEN RAISE EXCEPTION 'Duplicate Customer PO % for Quote % [xtuple: convertQuote, -8, %, %]', _ponumber, _qunumber, _ponumber, _qunumber; END IF; END IF; IF (_usespos) THEN SELECT quhead_number INTO _qunumber FROM quhead WHERE (quhead_id=pQuheadid) AND (COALESCE(quhead_custponumber, '') = ''); IF (FOUND) THEN RAISE EXCEPTION 'Customer PO required for Quote % [xtuple: convertQuote, -7, %]', _qunumber, _qunumber; END IF; END IF; IF ( (_usespos) AND (NOT _blanketpos) ) THEN SELECT quhead_number, quhead_custponumber INTO _qunumber, _ponumber FROM quhead JOIN invchead ON ( (invchead_cust_id=quhead_cust_id) AND (UPPER(invchead_ponumber)=UPPER(quhead_custponumber)) ) WHERE (quhead_id=pQuheadid); IF (FOUND) THEN RAISE EXCEPTION 'Duplicate Customer PO % for Quote % [xtuple: convertQuote, -8, %, %]', _ponumber, _qunumber, _ponumber, _qunumber; END IF; END IF; --Check to see if an invoice exists with the quote number PERFORM quhead_number, invchead_id FROM quhead, invchead WHERE quhead_id = pQuheadid AND invchead_invcnumber = quhead_number; -- If it does then get a new Invoice number otherwise use the quote number as the invoice number IF (FOUND) THEN SELECT fetchinvcnumber() INTO _inNum; ELSE SELECT quhead_number INTO _inNum FROM quhead WHERE quhead_id = pQuheadid; END IF; --Insert quote info into invoice tables SELECT NEXTVAL('invchead_invchead_id_seq') INTO _iheadid; INSERT INTO invchead ( invchead_ordernumber, invchead_shipdate, invchead_recurring, invchead_id, invchead_invcnumber, invchead_cust_id, invchead_orderdate, invchead_ponumber, invchead_billto_name, invchead_billto_address1, invchead_billto_address2, invchead_billto_address3, invchead_billto_city, invchead_billto_state, invchead_billto_zipcode, invchead_billto_country, invchead_shipto_id, invchead_shipto_name, invchead_shipto_address1, invchead_shipto_address2, invchead_shipto_address3, invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode, invchead_shipto_country, invchead_salesrep_id, invchead_commission, invchead_terms_id, invchead_shipchrg_id, invchead_fob, invchead_shipvia, invchead_notes, invchead_freight, invchead_misc_amount, invchead_misc_accnt_id, invchead_misc_descrip, invchead_prj_id, invchead_curr_id, invchead_taxzone_id, invchead_posted, invchead_printed, invchead_invcdate, invchead_saletype_id, invchead_shipzone_id --invchead_taxtype_id, --invchead_shipto_cntct_id, invchead_shipto_cntct_honorific, invchead_shipto_cntct_first_name, --invchead_shipto_cntct_middle, invchead_shipto_cntct_last_name, invchead_shipto_cntct_suffix, --invchead_shipto_cntct_phone, invchead_shipto_cntct_title, invchead_shipto_cntct_fax, --invchead_shipto_cntct_email, --invchead_billto_cntct_id, invchead_billto_cntct_honorific, --invchead_billto_cntct_first_name, invchead_billto_cntct_middle, invchead_billto_cntct_last_name, --invchead_billto_cntct_suffix, invchead_billto_cntct_phone, invchead_billto_cntct_title, --invchead_billto_cntct_fax, invchead_billto_cntct_email, --invchead_ophead_id, --invchead_calcfreight ) SELECT quhead_number, quhead_packdate, 'f', _iheadid, _inNum, quhead_cust_id, CURRENT_DATE, quhead_custponumber, quhead_billtoname, quhead_billtoaddress1, quhead_billtoaddress2, quhead_billtoaddress3, quhead_billtocity, quhead_billtostate, quhead_billtozip, quhead_billtocountry, quhead_shipto_id, quhead_shiptoname, quhead_shiptoaddress1, quhead_shiptoaddress2, quhead_shiptoaddress3, quhead_shiptocity, quhead_shiptostate, quhead_shiptozipcode, quhead_shiptocountry, quhead_salesrep_id, quhead_commission, quhead_terms_id, cust_shipchrg_id, quhead_fob, quhead_shipvia, quhead_ordercomments, quhead_freight, quhead_misc, quhead_misc_accnt_id, quhead_misc_descrip, quhead_prj_id, quhead_curr_id, quhead_taxzone_id, 'f','f',current_date, quhead_saletype_id, quhead_shipzone_id --quhead_shipto_cntct_id, quhead_shipto_cntct_honorific, --quhead_shipto_cntct_first_name, quhead_shipto_cntct_middle, quhead_shipto_cntct_last_name, --quhead_shipto_cntct_suffix, quhead_shipto_cntct_phone, quhead_shipto_cntct_title, --quhead_shipto_cntct_fax, quhead_shipto_cntct_email, quhead_billto_cntct_id, --quhead_billto_cntct_honorific, quhead_billto_cntct_first_name, quhead_billto_cntct_middle, --quhead_billto_cntct_last_name, quhead_billto_cntct_suffix, quhead_billto_cntct_phone, --quhead_billto_cntct_title, quhead_billto_cntct_fax, quhead_billto_cntct_email, quhead_ophead_id, --quhead_calcfreight FROM quhead JOIN custinfo ON (cust_id=quhead_cust_id) WHERE (quhead_id=pQuheadid); -- Copy characteristics from the quhead to the invoice head INSERT INTO charass ( charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price ) SELECT 'INV', _iheadid, charass_char_id, charass_value, charass_default, charass_price FROM charass JOIN char ON char_id = charass_char_id JOIN charuse ON char_id = charuse_char_id AND charuse_target_type = 'INV' WHERE charass_target_type = 'QU' AND charass_target_id = pQuheadid; -- Attachments on Invoice not supported but leaving this in for future use: /* UPDATE url SET url_source_id = _iheadid, url_source = 'I' WHERE ((url_source='Q') AND (url_source_id = pQuheadid)); UPDATE imageass SET imageass_source_id = _iheadid, imageass_source = 'I' WHERE ((imageass_source='Q') AND (imageass_source_id = pQuheadid)); UPDATE docass SET docass_source_id = _iheadid, docass_source_type = 'I' WHERE ((docass_source_type='Q') AND (docass_source_id = pQuheadid)); */ -- Comments not supported on Invoice but leaving this in for future use: /* INSERT INTO comment ( comment_cmnttype_id, comment_source, comment_source_id, comment_date, comment_user, comment_text, comment_public ) SELECT comment_cmnttype_id, 'I', _iheadid, comment_date, comment_user, ('Quote-' || comment_text), comment_public FROM comment WHERE ( (comment_source='Q') AND (comment_source_id=pQuheadid) ); */ FOR _r IN SELECT quitem.*, quhead_number, quhead_prj_id, quhead_saletype_id, itemsite_item_id, itemsite_leadtime, itemsite_createsopo, itemsite_createsopr, item_type, COALESCE(quitem_itemsrc_id, itemsrc_id, -1) AS itemsrcid FROM quhead JOIN quitem ON (quitem_quhead_id=quhead_id) JOIN itemsite ON (itemsite_id=quitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) LEFT OUTER JOIN itemsrc ON ( (itemsrc_item_id=item_id) AND (itemsrc_default) ) WHERE (quhead_id=pQuheadid) LOOP SELECT NEXTVAL('invcitem_invcitem_id_seq') INTO _iitemid; INSERT INTO invcitem ( invcitem_id, invcitem_invchead_id, invcitem_linenumber, invcitem_item_id, invcitem_warehous_id, --invcitem_status, --invcitem_scheddate, invcitem_promdate, invcitem_price, invcitem_custprice, invcitem_ordered, invcitem_billed, invcitem_qty_uom_id, invcitem_qty_invuomratio, invcitem_price_uom_id, invcitem_price_invuomratio, invcitem_custpn, invcitem_notes, invcitem_taxtype_id ) VALUES ( _iitemid, _iheadid, _r.quitem_linenumber, (SELECT itemsite_item_id FROM itemsite WHERE itemsite_id = _r.quitem_itemsite_id), (SELECT itemsite_warehous_id FROM itemsite WHERE itemsite_id = _r.quitem_itemsite_id), --'O', --_r.quitem_scheddate, _r.quitem_promdate, _r.quitem_price, _r.quitem_custprice, _r.quitem_qtyord, _r.quitem_qtyord, _r.quitem_qty_uom_id, _r.quitem_qty_invuomratio, _r.quitem_price_uom_id, _r.quitem_price_invuomratio, _r.quitem_custpn, _r.quitem_memo, _r.quitem_taxtype_id ); IF (fetchMetricBool('enablextcommissionission')) THEN PERFORM xtcommission.getSalesReps(quhead_cust_id, quhead_shipto_id, _r.itemsite_item_id, _r.quhead_saletype_id, _r.quitem_price, _r.quitem_custprice, _iitemid, 'InvoiceItem') FROM quhead WHERE (quhead_id=pQuheadid); END IF; /* INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price) SELECT 'SI', _iitemid, charass_char_id, charass_value, charass_default, charass_price FROM charass WHERE ((charass_target_type='QI') AND (charass_target_id=_r.quitem_id)); */ -- Comments not supported but leaving in for future use /* INSERT INTO comment ( comment_cmnttype_id, comment_source, comment_source_id, comment_date, comment_user, comment_text ) SELECT comment_cmnttype_id, 'SI', _iitemid, comment_date, comment_user, ('Quote-' || comment_text) FROM comment WHERE ( (comment_source='QI') AND (comment_source_id=_r.quitem_id) ); */ _orderid := -1; _ordertype := ''; IF (_r.quitem_createorder) THEN IF (_r.item_type IN ('M')) THEN SELECT createWo( CAST(_r.quhead_number AS INTEGER), supply.itemsite_id, 1, (_r.quitem_qtyord * _r.quitem_qty_invuomratio), _r.itemsite_leadtime, _r.quitem_scheddate, _r.quitem_memo, 'Q', _iitemid, _r.quhead_prj_id ) INTO _orderId FROM itemsite sold, itemsite supply WHERE ((sold.itemsite_item_id=supply.itemsite_item_id) AND (supply.itemsite_warehous_id=_r.quitem_order_warehous_id) AND (sold.itemsite_id=_r.quitem_itemsite_id) ); _orderType := 'W'; INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value) SELECT 'W', _orderId, charass_char_id, charass_value FROM charass WHERE ((charass_target_type='QI') AND (charass_target_id=_r.quitem_id)); ELSIF ( (_r.item_type IN ('P', 'O')) AND (_r.itemsite_createsopr) ) THEN SELECT createPr( CAST(_r.quhead_number AS INTEGER), _r.quitem_itemsite_id, (_r.quitem_qtyord * _r.quitem_qty_invuomratio), _r.quitem_scheddate, '', 'S', _iitemid ) INTO _orderId; _orderType := 'R'; UPDATE pr SET pr_prj_id=_r.quhead_prj_id WHERE pr_id=_orderId; ELSIF ( (_r.item_type IN ('P', 'O')) AND (_r.itemsite_createsopo) ) THEN IF (_r.quitem_prcost=0) THEN SELECT createpurchasetoquote(_r.quitem_id, _r.itemsrcid, _r.quitem_dropship) INTO _orderId; ELSE SELECT createpurchasetoquote(_r.quitem_id, _r.itemsrcid, _r.quitem_dropship, _r.quitem_prcost) INTO _orderId; END IF; _orderType := 'P'; END IF; -- UPDATE invcitem SET invcitem_order_type=_ordertype, invcitem_order_id=_orderid -- WHERE (invcitem_id=_iitemid); END IF; END LOOP; SELECT metric_value INTO _showConvertedQuote FROM metric WHERE metric_name = 'ShowQuotesAfterSO'; IF (_showConvertedQuote) THEN UPDATE quhead SET quhead_status= 'C' WHERE (quhead_id = pQuheadid); ELSE PERFORM deleteQuote(pQuheadid); END IF; RETURN _iheadid; END; $_$; 5DROP FUNCTION public.convertquotetoinvoice(integer); publicadminfalse84623125586992!copyaccountingyearperiod(integer)FUNCTIONCREATE FUNCTION copyaccountingyearperiod(pyearperiodid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _newYear INTEGER; BEGIN -- First create new fiscal year INSERT INTO yearperiod (yearperiod_start, yearperiod_end, yearperiod_closed) SELECT yearperiod_start + INTERVAL ' 1 year', yearperiod_end + INTERVAL ' 1 year', FALSE FROM yearperiod WHERE yearperiod_id = pYearPeriodid RETURNING yearperiod_id INTO _newYear; IF (NOT COALESCE(_newYear, -1) > 0) THEN RAISE EXCEPTION 'An error occurred creating the Fiscal Year [xtuple: copyaccountingyearperiod, -1]'; END IF; -- Copy corresponding fiscal periods across to the new fiscal year INSERT INTO period (period_start, period_end, period_closed, period_freeze, period_initial, period_name, period_yearperiod_id, period_quarter, period_number) SELECT (period_start + INTERVAL '1 year')::date, (period_end + INTERVAL '1 year')::date, FALSE, FALSE, FALSE, EXTRACT(year FROM period_start + INTERVAL '1 year') || '-' || to_char((period_start + INTERVAL '1 year'), 'Mon'), _newYear, period_quarter, period_number FROM period WHERE period_yearperiod_id = pYearPeriodid; -- Forward Update Accounting Periods for all G/L Accounts PERFORM forwardupdatetrialbalance(max(trialbal_id)) FROM accnt LEFT OUTER JOIN trialbal ON ( (trialbal_accnt_id=accnt_id) ) GROUP BY accnt_id HAVING max(trialbal_id) IS NOT NULL ORDER BY accnt_id; RETURN _newYear; END; $$; FDROP FUNCTION public.copyaccountingyearperiod(pyearperiodid integer); publicadminfalse84623125578114copybom(integer, integer)FUNCTIONfCREATE FUNCTION copybom(psitemid integer, ptitemid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _result INTEGER; BEGIN SELECT copyBOM (pSItemid, PTItemid, FALSE) into _result; RETURN _result; END; $$; BDROP FUNCTION public.copybom(psitemid integer, ptitemid integer); publicadminfalse84623125578115"copybom(integer, integer, boolean)FUNCTIONCREATE FUNCTION copybom(psitemid integer, ptitemid integer, pcopyusedat boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _bh RECORD; _bi RECORD; _bomheadfound BOOLEAN := FALSE; _bomheadid INTEGER; _bomitemid INTEGER; _bomworksetid INTEGER; _temp INTEGER; _schedatwooper BOOLEAN; _booitemseqid INTEGER; BEGIN -- Cache source bomhead SELECT * INTO _bh FROM bomhead WHERE ((bomhead_item_id=pSItemid) AND (bomhead_rev_id=getActiveRevID('BOM', pSItemid))); -- bomhead may not exist -- IF (NOT FOUND) THEN -- RETURN -1; -- END IF; IF (FOUND) THEN _bomheadfound := TRUE; END IF; -- Make sure that source bomitems exist SELECT bomitem_id INTO _bomitemid FROM bomitem WHERE ((bomitem_parent_item_id=pSItemid) AND (bomitem_rev_id=getActiveRevID('BOM', pSItemid))) LIMIT 1; IF (NOT FOUND) THEN RETURN -2; END IF; -- Make sure that target bomitems do not exist SELECT bomitem_id INTO _bomitemid FROM bomitem WHERE ((bomitem_parent_item_id=pTItemid) AND (bomitem_rev_id= -1)) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; -- Make sure that the parent is not used in the component at some level IF ( SELECT (item_type IN ('M', 'F')) FROM item WHERE (item_id=pSItemid) ) THEN SELECT indentedWhereUsed(pTItemid) INTO _bomworksetid; SELECT bomwork_id INTO _temp FROM bomwork WHERE ( (bomwork_set_id=_bomworksetid) AND (bomwork_item_id=pSItemid) ) LIMIT 1; IF (FOUND) THEN PERFORM deleteBOMWorkset(_bomworksetid); RETURN -4; END IF; PERFORM deleteBOMWorkset(_bomworksetid); END IF; -- Check for existing target bomhead SELECT bomhead_id INTO _bomheadid FROM bomhead WHERE ((bomhead_item_id=pTItemid) AND (bomhead_rev_id= -1)); IF (NOT FOUND) THEN IF (_bomheadfound) THEN INSERT INTO bomhead ( bomhead_item_id, bomhead_serial, bomhead_docnum, bomhead_batchsize, bomhead_requiredqtyper ) VALUES ( pTItemid, _bh.bomhead_serial, _bh.bomhead_docnum, _bh.bomhead_batchsize, _bh.bomhead_requiredqtyper ); END IF; END IF; FOR _bi IN SELECT bomitem.* FROM bomitem(pSItemid) WHERE (bomitem_expires>CURRENT_DATE) LOOP SELECT NEXTVAL('bomitem_bomitem_id_seq') INTO _bomitemid; IF (pCopyUsedAt) THEN _schedatwooper := _bi.bomitem_schedatwooper; _booitemseqid := _bi.bomitem_booitem_seq_id; ELSE _schedatwooper := FALSE; _booitemseqid := -1; END IF; INSERT INTO bomitem ( bomitem_id, bomitem_parent_item_id, bomitem_seqnumber, bomitem_item_id, bomitem_uom_id, bomitem_qtyfxd, bomitem_qtyper, bomitem_scrap, bomitem_schedatwooper, bomitem_booitem_seq_id, bomitem_effective, bomitem_expires, bomitem_ecn, bomitem_createwo, bomitem_issuemethod, bomitem_moddate, bomitem_subtype, bomitem_notes, bomitem_ref, bomitem_char_id, bomitem_value ) VALUES ( _bomitemid, pTItemid, _bi.bomitem_seqnumber, _bi.bomitem_item_id, _bi.bomitem_uom_id, _bi.bomitem_qtyfxd, _bi.bomitem_qtyper, _bi.bomitem_scrap, _schedatwooper, _booitemseqid, CURRENT_DATE, _bi.bomitem_expires, _bi.bomitem_ecn, _bi.bomitem_createwo, _bi.bomitem_issuemethod, CURRENT_DATE, _bi.bomitem_subtype, _bi.bomitem_notes, _bi.bomitem_ref, _bi.bomitem_char_id, _bi.bomitem_value ); INSERT INTO bomitemsub ( bomitemsub_bomitem_id, bomitemsub_item_id, bomitemsub_uomratio, bomitemsub_rank ) SELECT _bomitemid, bomitemsub_item_id, bomitemsub_uomratio, bomitemsub_rank FROM bomitemsub WHERE (bomitemsub_bomitem_id=_bi.bomitem_id); END LOOP; RETURN pTItemid; END; $$; WDROP FUNCTION public.copybom(psitemid integer, ptitemid integer, pcopyusedat boolean); publicadminfalse46238125578116(copybudget(integer, text, text, integer)FUNCTIONyCREATE FUNCTION copybudget(integer, text, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBudgheadid ALIAS FOR $1; pName ALIAS FOR $2; pDescrip ALIAS FOR $3; pInterval ALIAS FOR $4; _budgheadid INTEGER; _periodid INTEGER; _result INTEGER; BEGIN SELECT 1 INTO _result FROM budgitem WHERE ((budgitem_budghead_id=pBudgheadid) AND (nextPeriodByInterval(budgitem_period_id, pInterval)=-1)) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; SELECT nextval('budghead_budghead_id_seq') INTO _budgheadid; INSERT INTO budghead (budghead_id, budghead_name, budghead_descrip) VALUES(_budgheadid, pName, pDescrip); INSERT INTO budgitem (budgitem_budghead_id, budgitem_period_id, budgitem_accnt_id, budgitem_amount) SELECT _budgheadid, nextPeriodByInterval(budgitem_period_id, pInterval), budgitem_accnt_id, budgitem_amount FROM budgitem WHERE (budgitem_budghead_id=pBudgheadid); RETURN _budgheadid; END; $_$; ?DROP FUNCTION public.copybudget(integer, text, text, integer); publicadminfalse46238125578117copycmd(integer, text, text)FUNCTIONCREATE FUNCTION copycmd(integer, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmdId ALIAS FOR $1; pModule ALIAS FOR $2; pTitle ALIAS FOR $3; _cmdId INTEGER; BEGIN SELECT nextval('cmd_cmd_id_seq') INTO _cmdId; INSERT INTO cmd SELECT _cmdId, pModule, pTitle, cmd_descrip, cmd_privname, cmd_executable FROM cmd WHERE (cmd_id=pCmdId); INSERT INTO cmdarg (cmdarg_cmd_id, cmdarg_order, cmdarg_arg) SELECT _cmdId, cmdarg_order, cmdarg_arg FROM cmdarg WHERE (cmdarg_cmd_id=pCmdId); RETURN 1; END; $_$; 3DROP FUNCTION public.copycmd(integer, text, text); publicadminfalse84623{125578118'copycontract(integer, text, date, date)FUNCTION CREATE FUNCTION copycontract(pcontrctid integer, pnumber text, peffective date, pexpires date) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _contrctid INTEGER; _itemsrcid INTEGER; _r RECORD; BEGIN INSERT INTO contrct ( contrct_number, contrct_vend_id, contrct_descrip, contrct_effective, contrct_expires, contrct_note ) SELECT pNumber, contrct_vend_id, contrct_descrip, pEffective, pExpires, contrct_note FROM contrct WHERE (contrct_id=pContrctid) RETURNING contrct_id INTO _contrctid; FOR _r IN SELECT * FROM itemsrc WHERE (itemsrc_contrct_id=pContrctid) LOOP INSERT INTO itemsrc ( itemsrc_item_id, itemsrc_vend_id, itemsrc_vend_item_number, itemsrc_vend_item_descrip, itemsrc_comments, itemsrc_vend_uom, itemsrc_invvendoruomratio, itemsrc_minordqty, itemsrc_multordqty, itemsrc_leadtime, itemsrc_ranking, itemsrc_active, itemsrc_manuf_name, itemsrc_manuf_item_number, itemsrc_manuf_item_descrip, itemsrc_default, itemsrc_upccode, itemsrc_effective, itemsrc_expires, itemsrc_contrct_id ) VALUES ( _r.itemsrc_item_id, _r.itemsrc_vend_id, _r.itemsrc_vend_item_number, _r.itemsrc_vend_item_descrip, _r.itemsrc_comments, _r.itemsrc_vend_uom, _r.itemsrc_invvendoruomratio, _r.itemsrc_minordqty, _r.itemsrc_multordqty, _r.itemsrc_leadtime, _r.itemsrc_ranking, _r.itemsrc_active, _r.itemsrc_manuf_name, _r.itemsrc_manuf_item_number, _r.itemsrc_manuf_item_descrip, _r.itemsrc_default, _r.itemsrc_upccode, pEffective, pExpires, _contrctid ) RETURNING itemsrc_id INTO _itemsrcid; INSERT INTO itemsrcp ( itemsrcp_itemsrc_id, itemsrcp_qtybreak, itemsrcp_price, itemsrcp_updated, itemsrcp_curr_id, itemsrcp_dropship, itemsrcp_warehous_id, itemsrcp_type, itemsrcp_discntprcnt, itemsrcp_fixedamtdiscount ) SELECT _itemsrcid, itemsrcp_qtybreak, itemsrcp_price, CURRENT_DATE, itemsrcp_curr_id, itemsrcp_dropship, itemsrcp_warehous_id, itemsrcp_type, itemsrcp_discntprcnt, itemsrcp_fixedamtdiscount FROM itemsrcp WHERE (itemsrcp_itemsrc_id=_r.itemsrc_id); END LOOP; RETURN _contrctid; END; $$; eDROP FUNCTION public.copycontract(pcontrctid integer, pnumber text, peffective date, pexpires date); publicadminfalse84623125578119-copyfinancialgroup(integer, integer, integer)FUNCTIONCREATE FUNCTION copyfinancialgroup(integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSourceGroup ALIAS FOR $1; pFlheadid ALIAS FOR $2; pParentFlgrpid ALIAS FOR $3; _flgrpid INTEGER; BEGIN SELECT nextval('flgrp_flgrp_id_seq') INTO _flgrpid; -- Copy the group item INSERT INTO flgrp (flgrp_id, flgrp_flhead_id, flgrp_flgrp_id, flgrp_order, flgrp_name, flgrp_descrip, flgrp_subtotal, flgrp_summarize, flgrp_subtract, flgrp_showstart, flgrp_showend, flgrp_showdelta, flgrp_showbudget, flgrp_showdiff, flgrp_showcustom, flgrp_showstartprcnt, flgrp_showendprcnt, flgrp_showdeltaprcnt, flgrp_showbudgetprcnt, flgrp_showdiffprcnt, flgrp_showcustomprcnt, flgrp_usealtsubtotal, flgrp_altsubtotal,flgrp_prcnt_flgrp_id) SELECT _flgrpid, pFlheadid, pParentFlgrpid, flgrp_order, flgrp_name, flgrp_descrip, flgrp_subtotal, flgrp_summarize, flgrp_subtract, flgrp_showstart, flgrp_showend, flgrp_showdelta, flgrp_showbudget, flgrp_showdiff, flgrp_showcustom, flgrp_showstartprcnt, flgrp_showendprcnt, flgrp_showdeltaprcnt, flgrp_showbudgetprcnt, flgrp_showdiffprcnt, flgrp_showcustomprcnt, flgrp_usealtsubtotal, flgrp_altsubtotal,flgrp_prcnt_flgrp_id FROM flgrp WHERE (flgrp_id=pSourceGroup); -- Store temporary cross ref info EXECUTE ' INSERT INTO tmp_flgrpxref' || getEffectiveXtUser() || ' (flgrpxref_oldid,flgrpxref_newid) VALUES (' || pSourceGroup || ',' || _flgrpid || ');'; -- Copy any children flitems INSERT INTO flitem (flitem_flhead_id, flitem_flgrp_id, flitem_order, flitem_accnt_id, flitem_showstart, flitem_showend, flitem_showdelta, flitem_showbudget, flitem_showdiff, flitem_showcustom, flitem_subtract, flitem_showstartprcnt, flitem_showendprcnt, flitem_showdeltaprcnt, flitem_showbudgetprcnt, flitem_showdiffprcnt, flitem_showcustomprcnt, flitem_custom_source, flitem_company, flitem_profit, flitem_number, flitem_sub, flitem_type, flitem_subaccnttype_code, flitem_prcnt_flgrp_id) SELECT pFlheadid, _flgrpid, flitem_order, flitem_accnt_id, flitem_showstart, flitem_showend, flitem_showdelta, flitem_showbudget, flitem_showdiff, flitem_showcustom, flitem_subtract, flitem_showstartprcnt, flitem_showendprcnt, flitem_showdeltaprcnt, flitem_showbudgetprcnt, flitem_showdiffprcnt, flitem_showcustomprcnt, flitem_custom_source, flitem_company, flitem_profit, flitem_number, flitem_sub, flitem_type, flitem_subaccnttype_code, flitem_prcnt_flgrp_id FROM flitem WHERE (flitem_flgrp_id=pSourceGroup); -- Copy any children flspecs INSERT INTO flspec (flspec_flhead_id, flspec_flgrp_id, flspec_order, flspec_name, flspec_type, flspec_showstart, flspec_showend, flspec_showdelta, flspec_showbudget, flspec_showdiff, flspec_showcustom, flspec_subtract, flspec_showstartprcnt, flspec_showendprcnt, flspec_showdeltaprcnt, flspec_showbudgetprcnt, flspec_showdiffprcnt, flspec_showcustomprcnt, flspec_custom_source, flspec_prcnt_flgrp_id) SELECT pFlheadid, _flgrpid, flspec_order, flspec_name, flspec_type, flspec_showstart, flspec_showend, flspec_showdelta, flspec_showbudget, flspec_showdiff, flspec_showcustom, flspec_subtract, flspec_showstartprcnt, flspec_showendprcnt, flspec_showdeltaprcnt, flspec_showbudgetprcnt, flspec_showdiffprcnt, flspec_showcustomprcnt, flspec_custom_source, flspec_prcnt_flgrp_id FROM flspec WHERE (flspec_flgrp_id=pSourceGroup); -- Copy the groups PERFORM copyFinancialGroup(flgrp_id, pFlheadid, _flgrpid) FROM flgrp WHERE (flgrp_flgrp_id=pSourceGroup); RETURN _flgrpid; END; $_$; DDROP FUNCTION public.copyfinancialgroup(integer, integer, integer); publicadminfalse84623125578120"copyfinanciallayout(integer, text)FUNCTIONCREATE FUNCTION copyfinanciallayout(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSourceFlheadid ALIAS FOR $1; pDestName ALIAS FOR $2; _flheadid INTEGER; _tblName TEXT; BEGIN -- Check for the flhead to be copy that it exists PERFORM flhead_id FROM flhead WHERE (flhead_id=pSourceFlheadid); IF (NOT FOUND) THEN RETURN -1; END IF; -- Check that the name is valid IF (pDestName IS NULL OR pDestName = '') THEN RETURN -2; END IF; -- Check for the name to copy to does not exist PERFORM flhead_id FROM flhead WHERE (flhead_name=pDestName); IF (FOUND) THEN RETURN -3; END IF; -- Copy the flhead record SELECT nextval('flhead_flhead_id_seq') INTO _flheadid; INSERT INTO flhead (flhead_id, flhead_name, flhead_descrip, flhead_showtotal, flhead_showstart, flhead_showend, flhead_showdelta, flhead_showbudget, flhead_showdiff, flhead_showcustom, flhead_custom_label, flhead_usealttotal, flhead_alttotal, flhead_usealtbegin, flhead_altbegin, flhead_usealtend, flhead_altend, flhead_usealtdebits, flhead_altdebits, flhead_usealtcredits, flhead_altcredits, flhead_usealtbudget, flhead_altbudget, flhead_usealtdiff, flhead_altdiff, flhead_type, flhead_active, flhead_sys ) SELECT _flheadid, pDestName, flhead_descrip, flhead_showtotal, flhead_showstart, flhead_showend, flhead_showdelta, flhead_showbudget, flhead_showdiff, flhead_showcustom, flhead_custom_label, flhead_usealttotal, flhead_alttotal, flhead_usealtbegin, flhead_altbegin, flhead_usealtend, flhead_altend, flhead_usealtdebits, flhead_altdebits, flhead_usealtcredits, flhead_altcredits, flhead_usealtbudget, flhead_altbudget, flhead_usealtdiff, flhead_altdiff, flhead_type, flhead_active, false FROM flhead WHERE (flhead_id=pSourceFlheadid); -- Create temporary table so old and new group ids can be stored SELECT relname FROM pg_class INTO _tblName WHERE relname = 'tmp_flgrpxref'; IF (_tblName IS NULL) THEN EXECUTE 'CREATE TEMPORARY TABLE tmp_flgrpxref' || getEffectiveXtUser() || ' ( flgrpxref_oldid int4, flgrpxref_newid int4 ) ON COMMIT DROP;'; END IF; -- Copy the top level groups PERFORM copyFinancialGroup(flgrp_id, _flheadid, -1) FROM flgrp WHERE ((flgrp_flhead_id=pSourceFlheadid) AND (flgrp_flgrp_id=-1)); -- Update Group Percent settings EXECUTE 'UPDATE flgrp SET flgrp_prcnt_flgrp_id=flgrpxref_newid FROM tmp_flgrpxref' || getEffectiveXtUser() || ' WHERE ((flgrp_flhead_id=' || _flheadid || ') AND (flgrp_prcnt_flgrp_id=flgrpxref_oldid));'; EXECUTE 'UPDATE flitem SET flitem_prcnt_flgrp_id=flgrpxref_newid FROM tmp_flgrpxref' || getEffectiveXtUser() || ' WHERE ((flitem_flhead_id=' || _flheadid || ') AND (flitem_prcnt_flgrp_id=flgrpxref_oldid));'; EXECUTE 'UPDATE flspec SET flspec_prcnt_flgrp_id=flgrpxref_newid FROM tmp_flgrpxref' || getEffectiveXtUser() || ' WHERE ((flspec_flhead_id=' || _flheadid || ') AND (flspec_prcnt_flgrp_id=flgrpxref_oldid));'; -- Copy Column Layounts INSERT INTO flcol (flcol_flhead_id, flcol_name, flcol_descrip, flcol_report_id, flcol_month, flcol_quarter, flcol_year, flcol_showdb, flcol_prcnt, flcol_priortype, flcol_priormonth, flcol_priorquarter, flcol_prioryear, flcol_priorprcnt, flcol_priordiff, flcol_priordiffprcnt, flcol_budget, flcol_budgetprcnt, flcol_budgetdiff, flcol_budgetdiffprcnt ) SELECT _flheadid,flcol_name,flcol_descrip, flcol_report_id,flcol_month,flcol_quarter, flcol_year,flcol_showdb,flcol_prcnt, flcol_priortype,flcol_priormonth,flcol_priorquarter, flcol_prioryear,flcol_priorprcnt,flcol_priordiff, flcol_priordiffprcnt,flcol_budget,flcol_budgetprcnt, flcol_budgetdiff,flcol_budgetdiffprcnt FROM flcol WHERE (flcol_flhead_id=pSourceFlheadid); RETURN _flheadid; END; $_$; 9DROP FUNCTION public.copyfinanciallayout(integer, text); publicadminfalse46238125578121copyglseries(integer)FUNCTIONCREATE FUNCTION copyglseries(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; _sequence INTEGER := fetchGLSequence(); _journal INTEGER; BEGIN SELECT gltrans_journalnumber INTO _journal FROM gltrans WHERE ( gltrans_sequence=pSequence ) LIMIT 1; IF (FOUND) THEN INSERT INTO glseries ( glseries_sequence, glseries_source, glseries_doctype, glseries_docnumber, glseries_notes, glseries_accnt_id, glseries_amount, glseries_distdate ) SELECT _sequence, gltrans_source, gltrans_doctype, gltrans_docnumber, gltrans_notes, gltrans_accnt_id, gltrans_amount, gltrans_date FROM gltrans WHERE ( gltrans_sequence=pSequence ); ELSE RAISE EXCEPTION 'g/l transaction sequence not found'; END IF; RETURN _sequence; END; $_$; ,DROP FUNCTION public.copyglseries(integer); publicadminfalse46238125578122,copyincdt(integer, timestamp with time zone)FUNCTION^ CREATE FUNCTION copyincdt(integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pparentid ALIAS FOR $1; ptimestamp TIMESTAMP WITH TIME ZONE := COALESCE($2, CURRENT_TIMESTAMP); _alarmid INTEGER; _incdtid INTEGER; _todoitemid INTEGER; BEGIN INSERT INTO incdt(incdt_number, incdt_crmacct_id, incdt_cntct_id, incdt_summary, incdt_descrip, incdt_item_id, incdt_timestamp, incdt_incdtcat_id, incdt_incdtseverity_id,incdt_incdtpriority_id, incdt_owner_username, incdt_recurring_incdt_id ) SELECT fetchIncidentNumber(), incdt_crmacct_id, incdt_cntct_id, incdt_summary, incdt_descrip, incdt_item_id, ptimestamp, incdt_incdtcat_id, incdt_incdtseverity_id,incdt_incdtpriority_id, incdt_owner_username, incdt_recurring_incdt_id FROM incdt WHERE (incdt_id=pparentid) RETURNING incdt_id INTO _incdtid; IF (_incdtid IS NULL) THEN RETURN -10; END IF; SELECT MIN(copyTodoitem(todoitem_id, CAST(ptimestamp AS DATE), _incdtid)) INTO _todoitemid FROM todoitem WHERE (todoitem_incdt_id=pparentid); IF (_todoitemid < 0) THEN RETURN _todoitemid; END IF; SELECT saveAlarm(NULL, NULL, CAST(ptimestamp AS DATE), CAST(alarm_time - DATE_TRUNC('day',alarm_time) AS TIME), alarm_time_offset, alarm_time_qualifier, alarm_event_recipient IS NOT NULL, alarm_event_recipient, alarm_email_recipient IS NOT NULL, alarm_email_recipient, alarm_sysmsg_recipient IS NOT NULL, alarm_sysmsg_recipient, 'INCDT', _incdtid, 'CHANGEONE') INTO _alarmid FROM alarm WHERE ((alarm_source='INCDT') AND (alarm_source_id=pparentid)); IF (_alarmid < 0) THEN RETURN _alarmid; END IF; INSERT INTO docass (docass_source_id, docass_source_type, docass_target_id, docass_target_type, docass_purpose ) SELECT _incdtid, 'INCDT', docass_target_id, docass_target_type, docass_purpose FROM docass WHERE ((docass_source_id=pparentid) AND (docass_source_type='INCDT')); RETURN _incdtid; END; $_$; CDROP FUNCTION public.copyincdt(integer, timestamp with time zone); publicadminfalse84623125578123copyinvoice(integer, date)FUNCTIONCREATE FUNCTION copyinvoice(integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvcheadid ALIAS FOR $1; _invcheadid INTEGER; _invcnumber TEXT; _invcdate DATE := COALESCE($2, CURRENT_DATE); _i RECORD; _l RECORD; _invcitemid INTEGER; BEGIN SELECT * INTO _i FROM invchead WHERE(invchead_id=pInvcheadid); IF(NOT FOUND) THEN RETURN -1; END IF; _invcnumber := fetchInvcNumber(); _invcheadid := nextval('invchead_invchead_id_seq'); INSERT INTO invchead (invchead_id, invchead_cust_id, invchead_shipto_id, invchead_ordernumber, invchead_orderdate, invchead_posted, invchead_printed, invchead_invcnumber, invchead_invcdate, invchead_shipdate, invchead_ponumber, invchead_shipvia, invchead_fob, invchead_billto_name, invchead_billto_address1, invchead_billto_address2, invchead_billto_address3, invchead_billto_city, invchead_billto_state, invchead_billto_zipcode, invchead_billto_phone, invchead_shipto_name, invchead_shipto_address1, invchead_shipto_address2, invchead_shipto_address3, invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode, invchead_shipto_phone, invchead_salesrep_id, invchead_commission, invchead_terms_id, invchead_freight, invchead_misc_amount, invchead_misc_descrip, invchead_misc_accnt_id, invchead_payment, invchead_paymentref, invchead_notes, invchead_billto_country, invchead_shipto_country, invchead_prj_id, invchead_curr_id, invchead_taxzone_id, invchead_recurring_invchead_id, invchead_saletype_id, invchead_shipzone_id) VALUES(_invcheadid, _i.invchead_cust_id, _i.invchead_shipto_id, _i.invchead_ordernumber, _i.invchead_orderdate, false, false, _invcnumber, _invcdate, _i.invchead_shipdate, _i.invchead_ponumber, _i.invchead_shipvia, _i.invchead_fob, _i.invchead_billto_name, _i.invchead_billto_address1, _i.invchead_billto_address2, _i.invchead_billto_address3, _i.invchead_billto_city, _i.invchead_billto_state, _i.invchead_billto_zipcode, _i.invchead_billto_phone, _i.invchead_shipto_name, _i.invchead_shipto_address1, _i.invchead_shipto_address2, _i.invchead_shipto_address3, _i.invchead_shipto_city, _i.invchead_shipto_state, _i.invchead_shipto_zipcode, _i.invchead_shipto_phone, _i.invchead_salesrep_id, _i.invchead_commission, _i.invchead_terms_id, _i.invchead_freight, _i.invchead_misc_amount, _i.invchead_misc_descrip, _i.invchead_misc_accnt_id, _i.invchead_payment, _i.invchead_paymentref, _i.invchead_notes, _i.invchead_billto_country, _i.invchead_shipto_country, _i.invchead_prj_id, _i.invchead_curr_id, _i.invchead_taxzone_id, _i.invchead_recurring_invchead_id, _i.invchead_saletype_id, _i.invchead_shipzone_id); FOR _l IN SELECT * FROM invcitem WHERE (invcitem_invchead_id=pInvcheadid) LOOP SELECT NEXTVAL('invcitem_invcitem_id_seq') INTO _invcitemid; INSERT INTO invcitem (invcitem_id, invcitem_invchead_id, invcitem_linenumber, invcitem_item_id, invcitem_warehous_id, invcitem_custpn, invcitem_number, invcitem_descrip, invcitem_ordered, invcitem_billed, invcitem_custprice, invcitem_price, invcitem_notes, invcitem_salescat_id, invcitem_taxtype_id, invcitem_qty_uom_id, invcitem_qty_invuomratio, invcitem_price_uom_id, invcitem_price_invuomratio, invcitem_coitem_id) VALUES (_invcitemid, _invcheadid, _l.invcitem_linenumber, _l.invcitem_item_id, _l.invcitem_warehous_id, _l.invcitem_custpn, _l.invcitem_number, _l.invcitem_descrip, _l.invcitem_ordered, _l.invcitem_billed, _l.invcitem_custprice, _l.invcitem_price, _l.invcitem_notes, _l.invcitem_salescat_id, _l.invcitem_taxtype_id, _l.invcitem_qty_uom_id, _l.invcitem_qty_invuomratio, _l.invcitem_price_uom_id, _l.invcitem_price_invuomratio, _l.invcitem_coitem_id); END LOOP; RETURN _invcheadid; END; $_$; 1DROP FUNCTION public.copyinvoice(integer, date); publicadminfalse84623125578124copyitem(integer, text)FUNCTIONE CREATE FUNCTION copyitem(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSItemid ALIAS FOR $1; pTItemNumber ALIAS FOR $2; _itemid INTEGER; _r RECORD; _id INTEGER; BEGIN SELECT NEXTVAL('item_item_id_seq') INTO _itemid; INSERT INTO item ( item_id, item_number, item_descrip1, item_descrip2, item_classcode_id, item_type, item_active, item_picklist, item_sold, item_fractional, item_maxcost, item_prodweight, item_packweight, item_prodcat_id,item_exclusive, item_listprice, item_listcost, item_config, item_comments, item_extdescrip, item_upccode, item_inv_uom_id, item_price_uom_id ) SELECT _itemid, pTItemNumber, item_descrip1, item_descrip2, item_classcode_id, item_type, item_active, item_picklist, item_sold, item_fractional, item_maxcost, item_prodweight, item_packweight, item_prodcat_id, item_exclusive, item_listprice, item_listcost, item_config, item_comments, item_extdescrip, item_upccode, item_inv_uom_id, item_price_uom_id FROM item WHERE (item_id=pSItemid); INSERT INTO imageass (imageass_source_id, imageass_source, imageass_image_id, imageass_purpose) SELECT _itemid, 'I', imageass_image_id, imageass_purpose FROM imageass WHERE ((imageass_source_id=pSItemid) AND (imageass_source='I')); INSERT INTO url (url_source_id, url_source, url_title, url_url) SELECT _itemid, 'I', url_title, url_url FROM url WHERE ((url_source_id=pSItemid) AND (url_source='I')); INSERT INTO itemtax (itemtax_item_id, itemtax_taxzone_id, itemtax_taxtype_id) SELECT _itemid, itemtax_taxzone_id, itemtax_taxtype_id FROM itemtax WHERE(itemtax_item_id=pSItemid); INSERT INTO charass ( charass_target_type, charass_target_id, charass_char_id, charass_value ) SELECT 'I', _itemid, charass_char_id, charass_value FROM charass WHERE ( (charass_target_type='I') AND (charass_target_id=pSItemid) ); FOR _r IN SELECT itemuomconv_id, itemuomconv_from_uom_id, itemuomconv_from_value, itemuomconv_to_uom_id, itemuomconv_to_value, itemuomconv_fractional FROM itemuomconv WHERE(itemuomconv_item_id=pSItemid) LOOP SELECT nextval('itemuomconv_itemuomconv_id_seq') INTO _id; INSERT INTO itemuomconv (itemuomconv_id, itemuomconv_item_id, itemuomconv_from_uom_id, itemuomconv_from_value, itemuomconv_to_uom_id, itemuomconv_to_value, itemuomconv_fractional) VALUES(_id, _itemid, _r.itemuomconv_from_uom_id, _r.itemuomconv_from_value, _r.itemuomconv_to_uom_id, _r.itemuomconv_to_value, _r.itemuomconv_fractional); INSERT INTO itemuom (itemuom_itemuomconv_id, itemuom_uomtype_id) SELECT _id, itemuom_uomtype_id FROM itemuom WHERE(itemuom_itemuomconv_id=_r.itemuomconv_id); END LOOP; RETURN _itemid; END; $_$; .DROP FUNCTION public.copyitem(integer, text); publicadminfalse46238125578125)copyitem(integer, text, boolean, boolean)FUNCTIONCREATE FUNCTION copyitem(integer, text, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSItemid ALIAS FOR $1; pTItemNumber ALIAS FOR $2; pCopyBOM ALIAS FOR $3; pCopyCosts ALIAS FOR $4; _itemid INTEGER; BEGIN _itemid := copyItem(pSItemid, pTItemNumber); IF (pCopyBOM) THEN PERFORM copyBOM(pSItemid, _itemid, FALSE); END IF; IF (pCopyCosts) THEN INSERT INTO itemcost ( itemcost_item_id, itemcost_costelem_id, itemcost_lowlevel, itemcost_stdcost, itemcost_posted, itemcost_actcost, itemcost_curr_id, itemcost_updated ) SELECT _itemid, itemcost_costelem_id, itemcost_lowlevel, itemcost_stdcost, CURRENT_DATE, itemcost_actcost, itemcost_curr_id, CURRENT_DATE FROM itemcost WHERE (itemcost_item_id=pSItemid); END IF; RETURN _itemid; END; $_$; @DROP FUNCTION public.copyitem(integer, text, boolean, boolean); publicadminfalse846231255781262copyitem(integer, text, boolean, boolean, boolean)FUNCTIONCREATE FUNCTION copyitem(integer, text, boolean, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSItemid ALIAS FOR $1; pTItemNumber ALIAS FOR $2; pCopyBOM ALIAS FOR $3; pCopyBOO ALIAS FOR $4; -- deprecated - xtmfg-specific pCopyCosts ALIAS FOR $5; BEGIN RAISE WARNING 'copyItem(INTEGER, TEXT, BOOLEAN, BOOLEAN, BOOLEAN) has been deprecated. Use copyItem(INTEGER, TEXT) or copyItem(INTEGER, TEXT, BOOLEAN, BOOLEAN) or a package-specific version instead.'; RETURN copyItem(pSItemid, pTItemNumber, pCopyBOM, pCopyCosts); END; $_$; IDROP FUNCTION public.copyitem(integer, text, boolean, boolean, boolean); publicadminfalse84623125578127;copyitem(integer, text, boolean, boolean, boolean, boolean)FUNCTION<CREATE FUNCTION copyitem(integer, text, boolean, boolean, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSItemid ALIAS FOR $1; pTItemNumber ALIAS FOR $2; pCopyBOM ALIAS FOR $3; pCopyBOO ALIAS FOR $4; -- deprecated - xtmfg-specific pCopyCosts ALIAS FOR $5; pCopyUsedAt ALIAS FOR $6; -- deprecated - xtmfg-specific BEGIN RETURN copyItem(pSItemid, pTItemNumber, pCopyBOM, pCopyCosts); END; $_$; RDROP FUNCTION public.copyitem(integer, text, boolean, boolean, boolean, boolean); publicadminfalse46238125578128copyitemsite(integer, integer)FUNCTION<CREATE FUNCTION copyitemsite(pitemsiteid integer, pdestwhsid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN copyItemSite(pItemsiteid, pDestWhsid, NULL); END; $$; LDROP FUNCTION public.copyitemsite(pitemsiteid integer, pdestwhsid integer); publicadminfalse46238125578129'copyitemsite(integer, integer, integer)FUNCTIONCREATE FUNCTION copyitemsite(pitemsiteid integer, pdestwhsid integer, pdestitemid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _destwhs whsinfo%ROWTYPE; _new itemsite%ROWTYPE; _supplywarehousid INTEGER := NULL; BEGIN -- make a copy of the old itemsite SELECT * INTO _new FROM itemsite WHERE (itemsite_id=pItemsiteid); IF (NOT FOUND) THEN RETURN -1; END IF; -- if there is no dest warehouse then perhaps the user is manually copying it IF (pDestWhsid IS NOT NULL) THEN SELECT * INTO _destwhs FROM whsinfo WHERE (warehous_id=pDestWhsid); IF (NOT FOUND) THEN RETURN -2; END IF; END IF; IF (NOT checkPrivilege('MaintainItemSites')) THEN RETURN -3; END IF; SELECT itemsite_id INTO _new.itemsite_id FROM itemsite WHERE ((itemsite_item_id=COALESCE(pDestItemid, _new.itemsite_item_id)) AND (itemsite_warehous_id=pDestWhsid OR (itemsite_warehous_id IS NULL AND pDestWhsid IS NULL))); IF (FOUND) THEN RETURN _new.itemsite_id; END IF; -- find supply itemsite IF (_new.itemsite_supply_itemsite_id IS NOT NULL) THEN SELECT itemsite_warehous_id INTO _supplywarehousid FROM itemsite WHERE (itemsite_id=_new.itemsite_supply_itemsite_id); IF (FOUND) THEN SELECT itemsite_id INTO _new.itemsite_supply_itemsite_id FROM itemsite WHERE (itemsite_warehous_id=_supplywarehousid) AND (itemsite_item_id=pDestItemid); END IF; END IF; -- now override the things we know have to change _new.itemsite_id := NEXTVAL('itemsite_itemsite_id_seq'); _new.itemsite_warehous_id := pDestWhsid; _new.itemsite_qtyonhand := 0; _new.itemsite_value := 0; _new.itemsite_datelastcount := NULL; _new.itemsite_datelastused := NULL; _new.itemsite_location_id := -1; _new.itemsite_recvlocation_id := -1; _new.itemsite_issuelocation_id := -1; _new.itemsite_location_dist := FALSE; _new.itemsite_recvlocation_dist := FALSE; _new.itemsite_issuelocation_dist := FALSE; IF (_destwhs.warehous_transit) THEN _new.itemsite_reorderlevel := 0; _new.itemsite_ordertoqty := 0; _new.itemsite_soldranking := NULL; _new.itemsite_posupply := FALSE; _new.itemsite_wosupply := FALSE; _new.itemsite_loccntrl := FALSE; _new.itemsite_safetystock := 0; _new.itemsite_minordqty := 0; _new.itemsite_multordqty := 0; _new.itemsite_leadtime := 0; _new.itemsite_controlmethod := 'R'; IF(_new.itemsite_costmethod='N') THEN _new.itemsite_costmethod := 'S'; END IF; _new.itemsite_active := TRUE; -- ? _new.itemsite_plancode_id := -1; -- ? _new.itemsite_costcat_id := -1; _new.itemsite_eventfence := 1; _new.itemsite_sold := FALSE; _new.itemsite_stocked := FALSE; _new.itemsite_location_id := -1; _new.itemsite_useparams := FALSE; _new.itemsite_useparamsmanual := FALSE; _new.itemsite_createpr := FALSE; _new.itemsite_location := NULL; _new.itemsite_location_comments := NULL; _new.itemsite_notes := 'Transit Warehouse'; _new.itemsite_createwo := FALSE; _new.itemsite_costcat_id := _destwhs.warehous_costcat_id; _new.itemsite_supply_itemsite_id := NULL; END IF; INSERT INTO itemsite ( itemsite_id, itemsite_item_id, itemsite_warehous_id, itemsite_qtyonhand, itemsite_costmethod, itemsite_value, itemsite_reorderlevel, itemsite_ordertoqty, itemsite_cyclecountfreq, itemsite_datelastcount, itemsite_datelastused, itemsite_posupply, itemsite_wosupply, itemsite_loccntrl, itemsite_safetystock, itemsite_minordqty, itemsite_multordqty, itemsite_leadtime, itemsite_abcclass, itemsite_issuemethod, itemsite_controlmethod, itemsite_active, itemsite_plancode_id, itemsite_costcat_id, itemsite_eventfence, itemsite_sold, itemsite_stocked, itemsite_freeze, itemsite_location_id, itemsite_useparams, itemsite_useparamsmanual, itemsite_soldranking, itemsite_createpr, itemsite_location, itemsite_location_comments, itemsite_notes, itemsite_perishable, itemsite_autoabcclass, itemsite_ordergroup, itemsite_disallowblankwip, itemsite_maxordqty, itemsite_mps_timefence, itemsite_createwo, itemsite_warrpurc, itemsite_autoreg, itemsite_planning_type, itemsite_supply_itemsite_id, itemsite_createsopr, itemsite_createsopo, itemsite_dropship, itemsite_recvlocation_id, itemsite_issuelocation_id, itemsite_location_dist, itemsite_recvlocation_dist, itemsite_issuelocation_dist ) VALUES ( _new.itemsite_id, COALESCE(pDestItemid, _new.itemsite_item_id), _new.itemsite_warehous_id, _new.itemsite_qtyonhand, _new.itemsite_costmethod, _new.itemsite_value, _new.itemsite_reorderlevel, _new.itemsite_ordertoqty, _new.itemsite_cyclecountfreq, _new.itemsite_datelastcount, _new.itemsite_datelastused, _new.itemsite_posupply, _new.itemsite_wosupply, _new.itemsite_loccntrl, _new.itemsite_safetystock, _new.itemsite_minordqty, _new.itemsite_multordqty, _new.itemsite_leadtime, _new.itemsite_abcclass, _new.itemsite_issuemethod, _new.itemsite_controlmethod, _new.itemsite_active, _new.itemsite_plancode_id, _new.itemsite_costcat_id, _new.itemsite_eventfence, _new.itemsite_sold, _new.itemsite_stocked, _new.itemsite_freeze, _new.itemsite_location_id, _new.itemsite_useparams, _new.itemsite_useparamsmanual, _new.itemsite_soldranking, _new.itemsite_createpr, _new.itemsite_location, _new.itemsite_location_comments, _new.itemsite_notes, _new.itemsite_perishable, _new.itemsite_autoabcclass, _new.itemsite_ordergroup, _new.itemsite_disallowblankwip, _new.itemsite_maxordqty, _new.itemsite_mps_timefence, _new.itemsite_createwo, _new.itemsite_warrpurc, _new.itemsite_autoreg, _new.itemsite_planning_type, _new.itemsite_supply_itemsite_id, _new.itemsite_createsopr, _new.itemsite_createsopo, _new.itemsite_dropship, _new.itemsite_recvlocation_id, _new.itemsite_issuelocation_id, _new.itemsite_location_dist, _new.itemsite_recvlocation_dist, _new.itemsite_issuelocation_dist ); RETURN _new.itemsite_id; END; $$; aDROP FUNCTION public.copyitemsite(pitemsiteid integer, pdestwhsid integer, pdestitemid integer); publicadminfalse84623125578130copylocale(integer)FUNCTION CREATE FUNCTION copylocale(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLocaleid ALIAS FOR $1; _localecode TEXT; _localeid INTEGER; BEGIN SELECT locale_code INTO _localecode FROM locale WHERE (locale_id=pLocaleid); IF (NOT FOUND) THEN RAISE EXCEPTION 'Attempt to copy a non-existent locale-id.'; END IF; IF (EXISTS(SELECT locale_id FROM locale WHERE (locale_code = (_localecode || '-COPY')))) THEN RAISE EXCEPTION 'Attempt to copy a Locale Code that already exists.'; END IF; SELECT NEXTVAL('locale_locale_id_seq') INTO _localeid; INSERT INTO locale (locale_id, locale_code, locale_descrip, locale_lang_file, locale_dateformat, locale_currformat, locale_qtyformat, locale_comments, locale_qtyperformat, locale_salespriceformat, locale_extpriceformat, locale_timeformat, locale_timestampformat, local_costformat, locale_costformat, locale_purchpriceformat, locale_uomratioformat, locale_intervalformat, locale_lang_id, locale_country_id, locale_error_color, locale_warning_color, locale_emphasis_color, locale_altemphasis_color, locale_expired_color, locale_future_color, locale_curr_scale, locale_salesprice_scale, locale_purchprice_scale, locale_extprice_scale, locale_cost_scale, locale_qty_scale, locale_qtyper_scale, locale_uomratio_scale) SELECT _localeid, locale_code || '-COPY', '', locale_lang_file, locale_dateformat, locale_currformat, locale_qtyformat, locale_comments, locale_qtyperformat, locale_salespriceformat, locale_extpriceformat, locale_timeformat, locale_timestampformat, local_costformat, locale_costformat, locale_purchpriceformat, locale_uomratioformat, locale_intervalformat, locale_lang_id, locale_country_id, locale_error_color, locale_warning_color, locale_emphasis_color, locale_altemphasis_color, locale_expired_color, locale_future_color, locale_curr_scale, locale_salesprice_scale, locale_purchprice_scale, locale_extprice_scale, locale_cost_scale, locale_qty_scale, locale_qtyper_scale, locale_uomratio_scale FROM locale WHERE(locale_id=pLocaleid); RETURN _localeid; END; $_$; *DROP FUNCTION public.copylocale(integer); publicadminfalse46238125578131'copypo(integer, integer, date, boolean)FUNCTION(#CREATE FUNCTION copypo(integer, integer, date, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSrcid ALIAS FOR $1; pVendid ALIAS FOR $2; pOrderdate ALIAS FOR $3; pRecheckVendinfo ALIAS FOR $4; _tgtid INTEGER; _orderdate DATE; _head RECORD; _itemsrc RECORD; _lineitem RECORD; _qty NUMERIC; _unitprice NUMERIC; _uomratio NUMERIC; _vend_restrictpurch BOOLEAN; BEGIN SELECT * INTO _head FROM pohead WHERE pohead_id = pSrcid; IF (NOT FOUND) THEN RETURN -1; END IF; IF (_head.pohead_vend_id != pVendid) THEN RETURN -2; -- not supported now but should be in the future END IF; -- when enabled, set pRecheckVendinfo if vendors don't match IF (pOrderdate IS NULL) THEN _orderdate := CURRENT_DATE; ELSE _orderdate := pOrderdate; END IF; INSERT INTO pohead (pohead_status, pohead_number, pohead_orderdate, pohead_vend_id, pohead_fob, pohead_shipvia, pohead_freight, pohead_printed, pohead_terms_id, pohead_warehous_id, pohead_vendaddr_id, pohead_agent_username, pohead_curr_id, pohead_saved, pohead_taxtype_id, pohead_taxzone_id, pohead_dropship, pohead_vend_cntct_id, pohead_vend_cntct_honorific, pohead_vend_cntct_first_name, pohead_vend_cntct_middle, pohead_vend_cntct_last_name, pohead_vend_cntct_suffix, pohead_vend_cntct_phone, pohead_vend_cntct_title, pohead_vend_cntct_fax, pohead_vend_cntct_email, pohead_vendaddress1, pohead_vendaddress2, pohead_vendaddress3, pohead_vendcity, pohead_vendstate, pohead_vendzipcode, pohead_vendcountry, pohead_shipto_cntct_id, pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name, pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name, pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone, pohead_shipto_cntct_title, pohead_shipto_cntct_fax, pohead_shipto_cntct_email, pohead_shiptoaddress_id, pohead_shiptoaddress1, pohead_shiptoaddress2, pohead_shiptoaddress3, pohead_shiptocity, pohead_shiptostate, pohead_shiptozipcode, pohead_shiptocountry ) VALUES ( 'U', fetchPoNumber(), _orderdate, _head.pohead_vend_id, _head.pohead_fob, _head.pohead_shipvia, _head.pohead_freight, false, _head.pohead_terms_id, _head.pohead_warehous_id, _head.pohead_vendaddr_id, _head.pohead_agent_username, _head.pohead_curr_id, true, _head.pohead_taxtype_id, _head.pohead_taxzone_id, false, _head.pohead_vend_cntct_id, _head.pohead_vend_cntct_honorific, _head.pohead_vend_cntct_first_name, _head.pohead_vend_cntct_middle, _head.pohead_vend_cntct_last_name, _head.pohead_vend_cntct_suffix, _head.pohead_vend_cntct_phone, _head.pohead_vend_cntct_title, _head.pohead_vend_cntct_fax, _head.pohead_vend_cntct_email, _head.pohead_vendaddress1, _head.pohead_vendaddress2, _head.pohead_vendaddress3, _head.pohead_vendcity, _head.pohead_vendstate, _head.pohead_vendzipcode, _head.pohead_vendcountry, _head.pohead_shipto_cntct_id, _head.pohead_shipto_cntct_honorific, _head.pohead_shipto_cntct_first_name, _head.pohead_shipto_cntct_middle, _head.pohead_shipto_cntct_last_name, _head.pohead_shipto_cntct_suffix, _head.pohead_shipto_cntct_phone, _head.pohead_shipto_cntct_title, _head.pohead_shipto_cntct_fax, _head.pohead_shipto_cntct_email, _head.pohead_shiptoaddress_id, _head.pohead_shiptoaddress1, _head.pohead_shiptoaddress2, _head.pohead_shiptoaddress3, _head.pohead_shiptocity, _head.pohead_shiptostate, _head.pohead_shiptozipcode, _head.pohead_shiptocountry); _tgtid := CURRVAL('pohead_pohead_id_seq'); IF (pRecheckVendinfo) THEN SELECT vend_restrictpurch INTO _vend_restrictpurch FROM vendinfo WHERE (vend_id = pVendid); FOR _lineitem IN SELECT * FROM poitem WHERE (poitem_pohead_id = pSrcid) LOOP SELECT * INTO _itemsrc FROM itemsrc, itemsite WHERE (itemsrc_active AND (itemsrc_id = _lineitem.poitem_itemsrc_id) AND (itemsite_id = _lineitem.poitem_itemsite_id)); IF (NOT FOUND AND _vend_restrictpurch) THEN RETURN -3; END IF; -- handle changes to the uom ratio and consequent qty changes _uomratio := COALESCE(_itemsrc.itemsrc_invvendoruomratio, _lineitem.poitem_invvenduomratio); IF (_itemsrc.itemsrc_invvendoruomratio IS NULL OR _itemsrc.itemsrc_invvendoruomratio != _lineitem.poitem_invvenduomratio) THEN _qty := _lineitem.poitem_qty_ordered; ELSE _qty := _lineitem.poitem_qty_ordered * _lineitem.poitem_invvenduomratio / _itemsrc.itemsrc_invvendoruomratio; IF (_itemsrc.itemsrc_minordqty IS NOT NULL) THEN IF (_qty < _itemsrc.itemsrc_minordqty) THEN _qty := _itemsrc.itemsrc_minordqty; ELSIF (_itemsrc.itemsrc_multordqty > 0 AND _qty % _itemsrc.itemsrc_multordqty > 0) THEN _qty = _qty % _itemsrc.itemsrc_multordqty + _itemsrc.itemsrc_multordqty; END IF; END IF; END IF; IF (_itemsrc.itemsrc_id IS NULL) THEN _unitprice = _lineitem.poitem_unitprice; ELSE SELECT itemsrcPrice(_itemsrc.itemsrc_id, _head.pohead_warehous_id, _head.pohead_dropship, _lineitem.poitem_qty_ordered, _head.pohead_curr_id, CURRENT_DATE) INTO _unitprice; IF (_unitprice IS NULL) THEN RETURN -4; END IF; END IF; INSERT INTO poitem (poitem_status, poitem_pohead_id, poitem_linenumber, poitem_duedate, poitem_itemsite_id, poitem_vend_item_descrip, poitem_vend_uom, poitem_invvenduomratio, poitem_qty_ordered, poitem_unitprice, poitem_vend_item_number, poitem_comments, poitem_expcat_id, poitem_itemsrc_id, poitem_freight, poitem_stdcost, poitem_manuf_name, poitem_manuf_item_number, poitem_manuf_item_descrip, poitem_taxtype_id ) VALUES ( 'U', _tgtid, _lineitem.poitem_linenumber, _orderdate + COALESCE(_itemsrc.itemsrc_leadtime, 0), _lineitem.poitem_itemsite_id, COALESCE(_itemsrc.itemsrc_vend_item_descrip, _lineitem.poitem_vend_item_descrip), COALESCE(_itemsrc.itemsrc_vend_uom, _lineitem.poitem_vend_uom), COALESCE(_itemsrc.itemsrc_invvendoruomratio, _lineitem.poitem_invvenduomratio), _qty, _unitprice, COALESCE(_itemsrc.itemsrc_vend_item_number, _lineitem.poitem_vend_item_number), _lineitem.poitem_comments, _lineitem.poitem_expcat_id, COALESCE(_itemsrc.itemsrc_id, -1), _lineitem.poitem_freight, stdcost(_itemsrc.itemsite_item_id), COALESCE(_itemsrc.itemsrc_manuf_name, _lineitem.poitem_manuf_name), COALESCE(_itemsrc.itemsrc_manuf_item_number, _lineitem.poitem_manuf_item_number), COALESCE(_itemsrc.itemsrc_manuf_item_descrip, _lineitem.poitem_manuf_item_descrip), _lineitem.poitem_taxtype_id); END LOOP; ELSE INSERT INTO poitem (poitem_status, poitem_pohead_id, poitem_linenumber, poitem_duedate, poitem_itemsite_id, poitem_vend_item_descrip, poitem_vend_uom, poitem_invvenduomratio, poitem_qty_ordered, poitem_unitprice, poitem_vend_item_number, poitem_comments, poitem_expcat_id, poitem_itemsrc_id, poitem_freight, poitem_stdcost, poitem_manuf_name, poitem_manuf_item_number, poitem_manuf_item_descrip, poitem_taxtype_id ) SELECT 'U', _tgtid, poitem_linenumber, _orderdate + COALESCE(itemsrc_leadtime, 0), poitem_itemsite_id, poitem_vend_item_descrip, poitem_vend_uom, poitem_invvenduomratio, poitem_qty_ordered, poitem_unitprice, poitem_vend_item_number, poitem_comments, poitem_expcat_id, poitem_itemsrc_id, poitem_freight, stdcost(itemsite_item_id), poitem_manuf_name, poitem_manuf_item_number, poitem_manuf_item_descrip, poitem_taxtype_id FROM poitem LEFT OUTER JOIN itemsrc ON (itemsrc_id=poitem_itemsrc_id) LEFT OUTER JOIN itemsite ON (itemsite_id=poitem_itemsite_id) WHERE (poitem_pohead_id = pSrcid); END IF; -- Todo: recalculate tax? RETURN _tgtid; END; $_$; >DROP FUNCTION public.copypo(integer, integer, date, boolean); publicadminfalse46238125578133copypricingschedule(integer)FUNCTION CREATE FUNCTION copypricingschedule(pipsheadid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _ipsheadid INTEGER; _ipsitemid INTEGER; _ipsfreightid INTEGER; _x RECORD; BEGIN _ipsheadid := nextval('ipshead_ipshead_id_seq'); INSERT INTO ipshead ( ipshead_id, ipshead_name, ipshead_descrip, ipshead_effective, ipshead_expires, ipshead_curr_id, ipshead_updated ) SELECT _ipsheadid, orig.ipshead_name || (SELECT CAST((COUNT(cnt.ipshead_id)+1) AS text) FROM ipshead cnt WHERE (SUBSTRING(cnt.ipshead_name FROM 0 FOR char_length(orig.ipshead_name)+1) = orig.ipshead_name)), orig.ipshead_descrip, orig.ipshead_effective, orig.ipshead_expires, orig.ipshead_curr_id, CURRENT_DATE FROM ipshead orig WHERE (orig.ipshead_id=pIpsheadId); FOR _x IN SELECT ipsitem_id FROM ipsiteminfo WHERE (ipsitem_ipshead_id=pIpsheadid) LOOP INSERT INTO ipsiteminfo (ipsitem_ipshead_id, ipsitem_item_id, ipsitem_prodcat_id, ipsitem_qtybreak, ipsitem_price, ipsitem_qty_uom_id, ipsitem_price_uom_id, ipsitem_discntprcnt, ipsitem_fixedamtdiscount, ipsitem_type, ipsitem_warehous_id) SELECT _ipsheadid, ipsitem_item_id, ipsitem_prodcat_id, ipsitem_qtybreak, ipsitem_price, ipsitem_qty_uom_id, ipsitem_price_uom_id, ipsitem_discntprcnt, ipsitem_fixedamtdiscount, ipsitem_type, ipsitem_warehous_id FROM ipsiteminfo WHERE (ipsitem_id=_x.ipsitem_id) RETURNING ipsitem_id INTO _ipsitemid; INSERT INTO ipsitemchar ( ipsitemchar_ipsitem_id, ipsitemchar_char_id, ipsitemchar_value, ipsitemchar_price) SELECT _ipsitemid, ipsitemchar_char_id, ipsitemchar_value, ipsitemchar_price FROM ipsitemchar WHERE (ipsitemchar_ipsitem_id=_x.ipsitem_id); END LOOP; FOR _x IN SELECT ipsfreight_id FROM ipsfreight WHERE (ipsfreight_ipshead_id=pIpsheadid) LOOP _ipsfreightid := nextval('ipsfreight_ipsfreight_id_seq'); INSERT INTO ipsfreight (ipsfreight_id, ipsfreight_ipshead_id, ipsfreight_qtybreak, ipsfreight_price, ipsfreight_type, ipsfreight_warehous_id, ipsfreight_shipzone_id,ipsfreight_freightclass_id, ipsfreight_shipvia) SELECT _ipsfreightid, _ipsheadid, ipsfreight_qtybreak, ipsfreight_price,ipsfreight_type, ipsfreight_warehous_id,ipsfreight_shipzone_id, ipsfreight_freightclass_id,ipsfreight_shipvia FROM ipsfreight WHERE (ipsfreight_id=_x.ipsfreight_id); END LOOP; RETURN _ipsheadid; END; $$; >DROP FUNCTION public.copypricingschedule(pipsheadid integer); publicadminfalse84623125578134copyprj(integer, date)FUNCTIONy CREATE FUNCTION copyprj(integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pparentid ALIAS FOR $1; _counter INTEGER; _duedate DATE := COALESCE($2, CURRENT_DATE); _alarmid INTEGER; _i INTEGER; _newnumber TEXT; _p RECORD; _prjid INTEGER; _testnumber TEXT; BEGIN RAISE DEBUG 'copyPrj(%, %) entered', pparentid, _duedate; SELECT * INTO _p FROM prj WHERE (prj_id=pparentid); -- new number = old number up to but not including -, followed by _duedate -- e.g. REPAIR-FRIDGE becomes REPAIR-2010-05-15 -- but REPAIR_FRIDGE becomes REPAIR_FRIDGE-2010-05-15 IF (_p.prj_recurring_prj_id IS NULL) THEN _newnumber := _p.prj_number; ELSE _newnumber := SUBSTRING(_p.prj_number FROM '[^-]*'); IF (_newnumber IS NULL) THEN _newnumber := _p.prj_number; END IF; END IF; _newnumber := _newnumber || '-' || to_char(_duedate, 'YYYY-MM-DD'); RAISE DEBUG 'copyPrj checking if _newnumber % exists', _newnumber; SELECT MAX(prj_number) INTO _testnumber FROM prj WHERE (prj_number ~ ('^' || _newnumber)); IF (_testnumber = _newnumber) THEN _newnumber := _newnumber || '-001'; ELSIF (_testnumber IS NOT NULL) THEN _counter := CAST(SUBSTRING(_testnumber FROM '...$') AS INTEGER); _counter := _counter + 1; _newnumber := REGEXP_REPLACE(_testnumber, '...$', to_char(_counter, 'FM009')); END IF; RAISE DEBUG 'copyPrj _newnumber is now %', _newnumber; INSERT INTO prj( prj_number, prj_name, prj_descrip, prj_status, prj_so, prj_wo, prj_po, prj_owner_username, prj_prjtype_id, prj_due_date, prj_username, prj_recurring_prj_id ) SELECT _newnumber, _p.prj_name, _p.prj_descrip, 'P', _p.prj_so, _p.prj_wo, _p.prj_po, _p.prj_owner_username, _p.prj_prjtype_id, _duedate, _p.prj_username, _p. prj_recurring_prj_id FROM prj WHERE (prj_id=pparentid) RETURNING prj_id INTO _prjid; IF (_prjid IS NULL) THEN RETURN -1; END IF; SELECT saveAlarm(NULL, NULL, _duedate, CAST(alarm_time - DATE_TRUNC('day',alarm_time) AS TIME), alarm_time_offset, alarm_time_qualifier, alarm_event_recipient IS NOT NULL, alarm_event_recipient, alarm_email_recipient IS NOT NULL, alarm_email_recipient, alarm_sysmsg_recipient IS NOT NULL, alarm_sysmsg_recipient, 'J', _prjid, 'CHANGEONE') INTO _alarmid FROM alarm WHERE ((alarm_source='J') AND (alarm_source_id=pparentid)); IF (_alarmid < 0) THEN RETURN _alarmid; END IF; RETURN _prjid; END; $_$; -DROP FUNCTION public.copyprj(integer, date); publicadminfalse84623125578135&copyproject(integer, text, text, date)FUNCTION CREATE FUNCTION copyproject(integer, text, text, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrjId ALIAS FOR $1; pPrjNumber ALIAS FOR $2; pPrjName ALIAS FOR $3; pDueDate ALIAS FOR $4; _prjid INTEGER; _offset INTEGER; BEGIN IF (COALESCE(pPrjNumber, '') = '') THEN RETURN -1; END IF; IF (COALESCE(pPrjName, '') = '') THEN RETURN -1; END IF; IF (EXISTS(SELECT prj_id FROM prj WHERE UPPER(prj_number)=UPPER(pPrjNumber))) THEN RETURN -2; END IF; IF (NOT EXISTS(SELECT prj_id FROM prj WHERE prj_id=pPrjId)) THEN RETURN -3; END IF; IF (pDueDate IS NULL) THEN RETURN -4; END IF; SELECT (pDueDate - prj_due_date) INTO _offset FROM prj WHERE (prj_id=pPrjId); SELECT NEXTVAL('prj_prj_id_seq') INTO _prjid; INSERT INTO prj ( prj_id, prj_number, prj_name, prj_descrip, prj_status, prj_prjtype_id, prj_so, prj_wo, prj_po, prj_owner_username, prj_start_date, prj_due_date, prj_assigned_date, prj_completed_date, prj_username, prj_recurring_prj_id, prj_crmacct_id, prj_cntct_id ) SELECT _prjid, UPPER(pPrjNumber), pPrjName, prj_descrip, 'P', prj_prjtype_id, prj_so, prj_wo, prj_po, prj_owner_username, NULL, (prj_due_date + COALESCE(_offset, 0)), CASE WHEN (prj_username IS NULL) THEN NULL ELSE CURRENT_DATE END, NULL, prj_username, prj_recurring_prj_id, prj_crmacct_id, prj_cntct_id FROM prj WHERE (prj_id=pPrjId); INSERT INTO prjtask ( prjtask_number, prjtask_name, prjtask_descrip, prjtask_prj_id, prjtask_anyuser, prjtask_status, prjtask_hours_budget, prjtask_hours_actual, prjtask_exp_budget, prjtask_exp_actual, prjtask_owner_username, prjtask_start_date, prjtask_due_date, prjtask_assigned_date, prjtask_completed_date, prjtask_username ) SELECT prjtask_number, prjtask_name, prjtask_descrip, _prjid, prjtask_anyuser, 'P', prjtask_hours_budget, 0.0, prjtask_exp_budget, 0.0, prjtask_owner_username, NULL, (prjtask_due_date + COALESCE(_offset, 0)), CASE WHEN (prjtask_username IS NULL) THEN NULL ELSE CURRENT_DATE END, NULL, prjtask_username FROM prjtask WHERE (prjtask_prj_id=pPrjId); INSERT INTO docass ( docass_source_id, docass_source_type, docass_target_id, docass_target_type, docass_purpose ) SELECT _prjid, docass_source_type, docass_target_id, docass_target_type, docass_purpose FROM docass WHERE ((docass_source_id=pPrjId) AND (docass_source_type='J')); RETURN _prjid; END; $_$; =DROP FUNCTION public.copyproject(integer, text, text, date); publicadminfalse46238125578136copyquote(integer, date)FUNCTIONCREATE FUNCTION copyquote(integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuheadid ALIAS FOR $1; pSchedDate ALIAS FOR $2; _quheadid INTEGER; _qunumber TEXT; BEGIN SELECT NEXTVAL('quhead_quhead_id_seq') INTO _quheadid; IF (fetchMetricText('QUNumberGeneration') = 'S') THEN SELECT fetchSoNumber() INTO _qunumber; ELSE SELECT fetchQuNumber() INTO _qunumber; END IF; INSERT INTO quhead ( quhead_id, quhead_number, quhead_cust_id, quhead_prj_id, quhead_quotedate, quhead_packdate, quhead_fob, quhead_warehous_id, quhead_terms_id, quhead_salesrep_id, quhead_custponumber, quhead_shipvia, quhead_shipto_id, quhead_shiptoname, quhead_shiptoaddress1, quhead_shiptoaddress2, quhead_shiptoaddress3, quhead_shiptocity, quhead_shiptostate, quhead_shiptozipcode, quhead_shiptophone, quhead_shiptocountry, quhead_billtoname, quhead_billtoaddress1, quhead_billtoaddress2, quhead_billtoaddress3, quhead_billtocity, quhead_billtostate, quhead_billtozip, quhead_misc_accnt_id, quhead_misc_descrip, quhead_misc, quhead_freight, quhead_commission, quhead_ordercomments, quhead_shipcomments, quhead_imported, quhead_curr_id, quhead_taxzone_id, quhead_taxtype_id, quhead_ophead_id, quhead_status, quhead_shipto_cntct_id, quhead_shipto_cntct_honorific, quhead_shipto_cntct_first_name, quhead_shipto_cntct_middle, quhead_shipto_cntct_last_name, quhead_shipto_cntct_suffix, quhead_shipto_cntct_phone, quhead_shipto_cntct_title, quhead_shipto_cntct_fax, quhead_shipto_cntct_email, quhead_billto_cntct_id, quhead_billto_cntct_honorific, quhead_billto_cntct_first_name, quhead_billto_cntct_middle, quhead_billto_cntct_last_name, quhead_billto_cntct_suffix, quhead_billto_cntct_phone, quhead_billto_cntct_title, quhead_billto_cntct_fax, quhead_billto_cntct_email ) SELECT _quheadid, _qunumber, quhead_cust_id, quhead_prj_id, CURRENT_DATE, COALESCE(pSchedDate, quhead_packdate), quhead_fob, quhead_warehous_id, quhead_terms_id, quhead_salesrep_id, quhead_custponumber, quhead_shipvia, quhead_shipto_id, quhead_shiptoname, quhead_shiptoaddress1, quhead_shiptoaddress2, quhead_shiptoaddress3, quhead_shiptocity, quhead_shiptostate, quhead_shiptozipcode, quhead_shiptophone, quhead_shiptocountry, quhead_billtoname, quhead_billtoaddress1, quhead_billtoaddress2, quhead_billtoaddress3, quhead_billtocity, quhead_billtostate, quhead_billtozip, quhead_misc_accnt_id, quhead_misc_descrip, quhead_misc, quhead_freight, quhead_commission, quhead_ordercomments, quhead_shipcomments, FALSE, quhead_curr_id, quhead_taxzone_id, quhead_taxtype_id, quhead_ophead_id, 'O', quhead_shipto_cntct_id, quhead_shipto_cntct_honorific, quhead_shipto_cntct_first_name, quhead_shipto_cntct_middle, quhead_shipto_cntct_last_name, quhead_shipto_cntct_suffix, quhead_shipto_cntct_phone, quhead_shipto_cntct_title, quhead_shipto_cntct_fax, quhead_shipto_cntct_email, quhead_billto_cntct_id, quhead_billto_cntct_honorific, quhead_billto_cntct_first_name, quhead_billto_cntct_middle, quhead_billto_cntct_last_name, quhead_billto_cntct_suffix, quhead_billto_cntct_phone, quhead_billto_cntct_title, quhead_billto_cntct_fax, quhead_billto_cntct_email FROM quhead WHERE (quhead_id=pQuheadid); INSERT INTO quitem ( quitem_quhead_id, quitem_linenumber, quitem_itemsite_id, quitem_scheddate, quitem_promdate, quitem_qtyord, quitem_price, quitem_custprice, quitem_unitcost, quitem_qty_uom_id, quitem_price_uom_id, quitem_qty_invuomratio, quitem_price_invuomratio, quitem_memo, quitem_custpn, quitem_imported, quitem_taxtype_id, quitem_createorder, quitem_order_warehous_id, quitem_item_id, quitem_prcost, quitem_dropship, quitem_itemsrc_id, quitem_pricemode ) SELECT _quheadid, quitem_linenumber, quitem_itemsite_id, COALESCE(pSchedDate, quitem_scheddate), quitem_promdate, quitem_qtyord, quitem_price, quitem_custprice, stdCost(itemsite_item_id), quitem_qty_uom_id, quitem_price_uom_id, quitem_qty_invuomratio, quitem_price_invuomratio, quitem_memo, quitem_custpn, FALSE, quitem_taxtype_id, quitem_createorder, quitem_order_warehous_id, quitem_item_id, quitem_prcost, quitem_dropship, quitem_itemsrc_id, quitem_pricemode FROM quitem, itemsite WHERE ( (quitem_itemsite_id=itemsite_id) AND (quitem_quhead_id=pQuheadid)); INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value) SELECT charass_target_type, b.quitem_id, charass_char_id, charass_value FROM quitem a, charass, quitem b WHERE ((charass_target_type='QI') AND (charass_target_id=a.quitem_id) AND (a.quitem_quhead_id=pQuheadid) AND (b.quitem_quhead_id=_quheadid) AND (a.quitem_linenumber=b.quitem_linenumber) ); RETURN _quheadid; END; $_$; /DROP FUNCTION public.copyquote(integer, date); publicadminfalse46238125586995+copyquotetocustomer(integer, integer, date)FUNCTIONCREATE FUNCTION copyquotetocustomer(pquheadid integer, pcustomerid integer, pscheddate date) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _isCustomer BOOLEAN; _quotecustomer INTEGER; _quheadid INTEGER; _qunumber TEXT; _b RECORD; BEGIN SELECT NEXTVAL('quhead_quhead_id_seq') INTO _quheadid; IF (fetchMetricText('QUNumberGeneration') = 'S') THEN SELECT fetchSoNumber() INTO _qunumber; ELSE SELECT fetchQuNumber() INTO _qunumber; END IF; SELECT * INTO _b FROM ( SELECT cust_name as name, addr_line1, addr_line2, addr_line3, addr_city, addr_state, addr_postalcode, addr_country, cntct_id, cntct_honorific, cntct_first_name, cntct_middle, cntct_last_name, cntct_suffix, cntct_phone, cntct_title, cntct_fax, cntct_email FROM custinfo LEFT JOIN cntct ON (cust_cntct_id = cntct_id) LEFT JOIN addr ON (cntct_addr_id = addr_id) WHERE cust_id = pCustomerid UNION SELECT prospect_name AS name, addr_line1, addr_line2, addr_line3, addr_city, addr_state, addr_postalcode, addr_country, cntct_id, cntct_honorific, cntct_first_name, cntct_middle, cntct_last_name, cntct_suffix, cntct_phone, cntct_title, cntct_fax, cntct_email FROM prospect LEFT JOIN cntct ON (prospect_cntct_id = cntct_id) LEFT JOIN addr ON (cntct_addr_id = addr_id) WHERE prospect_id = pCustomerid ) data; IF (NOT FOUND) THEN RAISE EXCEPTION 'Invalid Customer supplied: %', pCustomerid; END IF; INSERT INTO quhead ( quhead_id, quhead_number, quhead_cust_id, quhead_prj_id, quhead_quotedate, quhead_packdate, quhead_fob, quhead_warehous_id, quhead_terms_id, quhead_salesrep_id, quhead_custponumber, quhead_shipvia, quhead_shipto_id, quhead_shiptoname, quhead_shiptoaddress1, quhead_shiptoaddress2, quhead_shiptoaddress3, quhead_shiptocity, quhead_shiptostate, quhead_shiptozipcode, quhead_shiptophone, quhead_shiptocountry, quhead_billtoname, quhead_billtoaddress1, quhead_billtoaddress2, quhead_billtoaddress3, quhead_billtocity, quhead_billtostate, quhead_billtozip, quhead_misc_accnt_id, quhead_misc_descrip, quhead_misc, quhead_freight, quhead_commission, quhead_ordercomments, quhead_shipcomments, quhead_imported, quhead_curr_id, quhead_taxzone_id, quhead_taxtype_id, quhead_ophead_id, quhead_status, quhead_shipto_cntct_id, quhead_shipto_cntct_honorific, quhead_shipto_cntct_first_name, quhead_shipto_cntct_middle, quhead_shipto_cntct_last_name, quhead_shipto_cntct_suffix, quhead_shipto_cntct_phone, quhead_shipto_cntct_title, quhead_shipto_cntct_fax, quhead_shipto_cntct_email, quhead_billto_cntct_id, quhead_billto_cntct_honorific, quhead_billto_cntct_first_name, quhead_billto_cntct_middle, quhead_billto_cntct_last_name, quhead_billto_cntct_suffix, quhead_billto_cntct_phone, quhead_billto_cntct_title, quhead_billto_cntct_fax, quhead_billto_cntct_email ) SELECT _quheadid, _qunumber, pCustomerid, -- use new customer or prospect quhead_prj_id, CURRENT_DATE, COALESCE(pSchedDate, quhead_packdate), quhead_fob, quhead_warehous_id, quhead_terms_id, quhead_salesrep_id, quhead_custponumber, quhead_shipvia, NULL, -- shipto_id '', -- shipto_name '', -- addr_line1 '', -- addr_line2 '', -- addr_line3 '', -- addr_city '', -- addr_state '', -- addr_postalcode NULL, '', -- new billto info _b.name, -- quhead_billtoname, _b.addr_line1, -- quhead_billtoaddress1, _b.addr_line2, -- quhead_billtoaddress2 _b.addr_line3, -- quhead_billtoaddress3, _b.addr_city, -- quhead_billtocity _b.addr_state, -- quhead_billtostate, _b.addr_postalcode, -- quhead_billtozip, quhead_misc_accnt_id, quhead_misc_descrip, quhead_misc, quhead_freight, quhead_commission, quhead_ordercomments, quhead_shipcomments, FALSE, quhead_curr_id, quhead_taxzone_id, quhead_taxtype_id, quhead_ophead_id, 'O', NULL, -- quhead_shipto_cntct_id, '', -- quhead_shipto_cntct_honorific, '', -- quhead_shipto_cntct_first_name '', -- quhead_shipto_cntct_middle, '', -- quhead_shipto_cntct_last_name, '', -- quhead_shipto_cntct_suffix, '', -- quhead_shipto_cntct_phone, '', -- quhead_shipto_cntct_title, '', -- quhead_shipto_cntct_fax, '', -- quhead_shipto_cntct_email, _b.cntct_id, -- quhead_billto_cntct_id, _b.cntct_honorific, -- quhead_billto_cntct_honorific, _b.cntct_first_name, -- quhead_billto_cntct_first_name, _b.cntct_middle, -- quhead_billto_cntct_middle, _b.cntct_last_name, -- quhead_billto_cntct_last_name, _b.cntct_suffix, -- quhead_billto_cntct_suffix, _b.cntct_phone, -- quhead_billto_cntct_phone, _b.cntct_title, -- quhead_billto_cntct_title, _b.cntct_fax, -- quhead_billto_cntct_fax, _b.cntct_email -- quhead_billto_cntct_email FROM quhead WHERE (quhead_id=pquheadid); INSERT INTO quitem ( quitem_quhead_id, quitem_linenumber, quitem_itemsite_id, quitem_scheddate, quitem_promdate, quitem_qtyord, quitem_price, quitem_custprice, quitem_unitcost, quitem_qty_uom_id, quitem_price_uom_id, quitem_qty_invuomratio, quitem_price_invuomratio, quitem_memo, quitem_custpn, quitem_imported, quitem_taxtype_id, quitem_createorder, quitem_order_warehous_id, quitem_item_id, quitem_prcost, quitem_dropship, quitem_itemsrc_id, quitem_pricemode ) SELECT _quheadid, quitem_linenumber, quitem_itemsite_id, COALESCE(pSchedDate, quitem_scheddate), quitem_promdate, quitem_qtyord, quitem_price, quitem_custprice, stdCost(itemsite_item_id), quitem_qty_uom_id, quitem_price_uom_id, quitem_qty_invuomratio, quitem_price_invuomratio, quitem_memo, quitem_custpn, FALSE, quitem_taxtype_id, quitem_createorder, quitem_order_warehous_id, quitem_item_id, quitem_prcost, quitem_dropship, quitem_itemsrc_id, quitem_pricemode FROM quitem, itemsite WHERE ( (quitem_itemsite_id=itemsite_id) AND (quitem_quhead_id=pQuheadid)); INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value) SELECT charass_target_type, b.quitem_id, charass_char_id, charass_value FROM quitem a, charass, quitem b WHERE ((charass_target_type='SI') AND (charass_target_id=a.quitem_id) AND (a.quitem_quhead_id=pquheadid) AND (b.quitem_quhead_id=_quheadid) AND (a.quitem_linenumber=b.quitem_linenumber) ); RETURN _quheadid; END; $$; cDROP FUNCTION public.copyquotetocustomer(pquheadid integer, pcustomerid integer, pscheddate date); publicadminfalse46238125586997copyso(integer, integer, date)FUNCTION4CREATE FUNCTION copyso(psoheadid integer, pcustomer integer, pscheddate date) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _soheadid INTEGER; _soitemid INTEGER; _soitem RECORD; _newCustomer BOOLEAN; _customer RECORD; BEGIN SELECT NEXTVAL('cohead_cohead_id_seq') INTO _soheadid; -- Check whether we are copying to a new customer SELECT (cohead_cust_id <> COALESCE(pCustomer, cohead_cust_id)) INTO _newCustomer FROM cohead WHERE cohead_id = pSoheadid; IF (NOT _newCustomer) THEN INSERT INTO cohead ( cohead_id, cohead_number, cohead_cust_id, cohead_custponumber, cohead_type, cohead_orderdate, cohead_warehous_id, cohead_shipto_id, cohead_shiptoname, cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3, cohead_shiptoaddress4, cohead_shiptoaddress5, cohead_salesrep_id, cohead_terms_id, cohead_fob, cohead_shipvia, cohead_shiptocity, cohead_shiptostate, cohead_shiptozipcode, cohead_freight, cohead_misc, cohead_imported, cohead_ordercomments, cohead_shipcomments, cohead_shiptophone, cohead_shipchrg_id, cohead_shipform_id, cohead_billtoname, cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, cohead_billtocity, cohead_billtostate, cohead_billtozipcode, cohead_misc_accnt_id, cohead_misc_descrip, cohead_commission, cohead_miscdate, cohead_holdtype, cohead_packdate, cohead_prj_id, cohead_wasquote, cohead_lastupdated, cohead_shipcomplete, cohead_created, cohead_creator, cohead_quote_number, cohead_billtocountry, cohead_shiptocountry, cohead_curr_id, cohead_calcfreight, cohead_shipto_cntct_id, cohead_shipto_cntct_honorific, cohead_shipto_cntct_first_name, cohead_shipto_cntct_middle, cohead_shipto_cntct_last_name, cohead_shipto_cntct_suffix, cohead_shipto_cntct_phone, cohead_shipto_cntct_title, cohead_shipto_cntct_fax, cohead_shipto_cntct_email, cohead_billto_cntct_id, cohead_billto_cntct_honorific, cohead_billto_cntct_first_name, cohead_billto_cntct_middle, cohead_billto_cntct_last_name, cohead_billto_cntct_suffix, cohead_billto_cntct_phone, cohead_billto_cntct_title, cohead_billto_cntct_fax, cohead_billto_cntct_email, cohead_taxzone_id, cohead_taxtype_id, cohead_ophead_id, cohead_status, cohead_saletype_id, cohead_shipzone_id ) SELECT _soheadid, fetchSoNumber(), cohead_cust_id, cohead_custponumber, cohead_type, CURRENT_DATE, cohead_warehous_id, cohead_shipto_id, cohead_shiptoname, cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3, cohead_shiptoaddress4, cohead_shiptoaddress5, cohead_salesrep_id, cohead_terms_id, cohead_fob, cohead_shipvia, cohead_shiptocity, cohead_shiptostate, cohead_shiptozipcode, cohead_freight, cohead_misc, FALSE, cohead_ordercomments, cohead_shipcomments, cohead_shiptophone, cohead_shipchrg_id, cohead_shipform_id, cohead_billtoname, cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, cohead_billtocity, cohead_billtostate, cohead_billtozipcode, cohead_misc_accnt_id, cohead_misc_descrip, cohead_commission, cohead_miscdate, cohead_holdtype, COALESCE(pSchedDate, cohead_packdate), cohead_prj_id, FALSE, cohead_lastupdated, cohead_shipcomplete, NULL, getEffectiveXtUser(), NULL, cohead_billtocountry, cohead_shiptocountry, cohead_curr_id, cohead_calcfreight, cohead_shipto_cntct_id, cohead_shipto_cntct_honorific, cohead_shipto_cntct_first_name, cohead_shipto_cntct_middle, cohead_shipto_cntct_last_name, cohead_shipto_cntct_suffix, cohead_shipto_cntct_phone, cohead_shipto_cntct_title, cohead_shipto_cntct_fax, cohead_shipto_cntct_email, cohead_billto_cntct_id, cohead_billto_cntct_honorific, cohead_billto_cntct_first_name, cohead_billto_cntct_middle, cohead_billto_cntct_last_name, cohead_billto_cntct_suffix, cohead_billto_cntct_phone, cohead_billto_cntct_title, cohead_billto_cntct_fax, cohead_billto_cntct_email, cohead_taxzone_id, cohead_taxtype_id, cohead_ophead_id, cohead_status, cohead_saletype_id, cohead_shipzone_id FROM cohead WHERE (cohead_id=pSoheadid); ELSE -- Copy SO to New Customer -- Get Customer details SELECT cust_id, cust_name, cust_salesrep_id, cust_terms_id, cust_shipvia, cust_shipchrg_id, cust_shipform_id, cust_commprcnt, cust_partialship, cust_taxzone_id, cust_curr_id, bc.cntct_id AS billing_contact_id, bc.cntct_honorific AS billing_honorific, bc.cntct_first_name AS billing_first_name, bc.cntct_middle AS billing_middle, bc.cntct_last_name AS billing_last_name, bc.cntct_suffix AS billing_suffix, bc.cntct_phone AS billing_phone, bc.cntct_title AS billing_title, bc.cntct_fax AS billing_fax, bc.cntct_email AS billing_email, ba.addr_line1 AS billing1, ba.addr_line2 AS billing2, ba.addr_line3 AS billing3, ba.addr_city AS billing_city, ba.addr_state AS billing_state, ba.addr_postalcode AS billing_postalcode, ba.addr_country AS billing_country, shipto_id, shipto_name, sc.cntct_id AS shipto_contact_id, sc.cntct_honorific AS shipto_honorific, sc.cntct_phone AS shipto_phone, sc.cntct_first_name AS shipto_first_name, sc.cntct_middle AS shipto_middle, sc.cntct_last_name AS shipto_last_name, sc.cntct_suffix AS shipto_suffix, sc.cntct_phone AS shipto_phone, sc.cntct_title AS shipto_title, sc.cntct_fax AS shipto_fax, sc.cntct_email AS shipto_email, sa.addr_line1 AS shipto1, sa.addr_line2 AS shipto2, sa.addr_line3 AS shipto3, sa.addr_city AS shipto_city, sa.addr_state AS shipto_state, sa.addr_postalcode AS shipto_postalcode, sa.addr_country AS shipto_country INTO _customer FROM custinfo LEFT OUTER join cntct bc ON (cust_cntct_id=bc.cntct_id) LEFT OUTER JOIN addr ba ON (cntct_addr_id=ba.addr_id) LEFT OUTER JOIN shiptoinfo ON ((shipto_cust_id=cust_id) AND (shipto_default)) LEFT OUTER join cntct sc ON (shipto_cntct_id=sc.cntct_id) LEFT OUTER JOIN addr sa ON (shipto_addr_id=sa.addr_id) WHERE cust_id=pCustomer; INSERT INTO cohead ( cohead_id, cohead_number, cohead_cust_id, cohead_custponumber, cohead_type, cohead_orderdate, cohead_warehous_id, cohead_shipto_id, cohead_shiptoname, cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3, cohead_salesrep_id, cohead_terms_id, cohead_fob, cohead_shipvia, cohead_shiptocity, cohead_shiptostate, cohead_shiptozipcode, cohead_freight, cohead_misc, cohead_imported, cohead_ordercomments, cohead_shipcomments, cohead_shiptophone, cohead_shipchrg_id, cohead_shipform_id, cohead_billtoname, cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, cohead_billtocity, cohead_billtostate, cohead_billtozipcode, cohead_misc_accnt_id, cohead_misc_descrip, cohead_commission, cohead_miscdate, cohead_holdtype, cohead_packdate, cohead_prj_id, cohead_wasquote, cohead_lastupdated, cohead_shipcomplete, cohead_created, cohead_creator, cohead_quote_number, cohead_billtocountry, cohead_shiptocountry, cohead_curr_id, cohead_calcfreight, cohead_shipto_cntct_id, cohead_shipto_cntct_honorific, cohead_shipto_cntct_first_name, cohead_shipto_cntct_middle, cohead_shipto_cntct_last_name, cohead_shipto_cntct_suffix, cohead_shipto_cntct_phone, cohead_shipto_cntct_title, cohead_shipto_cntct_fax, cohead_shipto_cntct_email, cohead_billto_cntct_id, cohead_billto_cntct_honorific, cohead_billto_cntct_first_name, cohead_billto_cntct_middle, cohead_billto_cntct_last_name, cohead_billto_cntct_suffix, cohead_billto_cntct_phone, cohead_billto_cntct_title, cohead_billto_cntct_fax, cohead_billto_cntct_email, cohead_taxzone_id, cohead_taxtype_id, cohead_ophead_id, cohead_status, cohead_saletype_id, cohead_shipzone_id ) SELECT _soheadid, fetchSoNumber(), pCustomer, '', cohead_type, CURRENT_DATE, cohead_warehous_id, COALESCE(_customer.shipto_id, NULL), _customer.shipto_name, _customer.shipto1, _customer.shipto2, _customer.shipto3, _customer.cust_salesrep_id, _customer.cust_terms_id, cohead_fob, _customer.cust_shipvia, _customer.shipto_city, _customer.shipto_state, _customer.shipto_postalcode, cohead_freight, cohead_misc, FALSE, cohead_ordercomments, cohead_shipcomments, _customer.shipto_phone, _customer.cust_shipchrg_id, _customer.cust_shipform_id, _customer.cust_name, _customer.billing1, _customer.billing2, _customer.billing3, _customer.billing_city, _customer.billing_state, _customer.billing_postalcode, cohead_misc_accnt_id, cohead_misc_descrip, _customer.cust_commprcnt, cohead_miscdate, cohead_holdtype, COALESCE(pSchedDate, cohead_packdate), NULL, --cohead_prj_id, FALSE, CURRENT_DATE, _customer.cust_partialship, NULL, getEffectiveXtUser(), NULL, _customer.billing_country, _customer.shipto_country, _customer.cust_curr_id, cohead_calcfreight, _customer.shipto_contact_id, _customer.shipto_honorific, _customer.shipto_first_name, _customer.shipto_middle, _customer.shipto_last_name, _customer.shipto_suffix, _customer.shipto_phone, _customer.shipto_title, _customer.shipto_fax, _customer.shipto_email, _customer.billing_contact_id, _customer.billing_honorific, _customer.billing_first_name, _customer.billing_middle, _customer.billing_last_name, _customer.billing_suffix, _customer.billing_phone, _customer.billing_title, _customer.billing_fax, _customer.billing_email, _customer.cust_taxzone_id, cohead_taxtype_id, cohead_ophead_id, 'O', cohead_saletype_id, cohead_shipzone_id FROM cohead WHERE (cohead_id=pSoheadid); END IF; -- Order Header population INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value) SELECT charass_target_type, _soheadid, charass_char_id, charass_value FROM charass WHERE ((charass_target_type='SO') AND (charass_target_id=pSoheadid)); FOR _soitem IN SELECT * FROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id) WHERE ( (coitem_cohead_id=pSoheadid) AND (coitem_status <> 'X') AND (coitem_subnumber = 0) ) LOOP SELECT NEXTVAL('coitem_coitem_id_seq') INTO _soitemid; -- insert characteristics first so they can be copied to associated supply order INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value) SELECT charass_target_type, _soitemid, charass_char_id, charass_value FROM charass WHERE ((charass_target_type='SI') AND (charass_target_id=_soitem.coitem_id)); INSERT INTO coitem ( coitem_id, coitem_cohead_id, coitem_linenumber, coitem_itemsite_id, coitem_status, coitem_scheddate, coitem_promdate, coitem_qtyord, coitem_unitcost, coitem_price, coitem_custprice, coitem_qtyshipped, coitem_order_id, coitem_memo, coitem_imported, coitem_qtyreturned, coitem_closedate, coitem_custpn, coitem_order_type, coitem_close_username, -- coitem_lastupdated, coitem_substitute_item_id, coitem_created, coitem_creator, coitem_prcost, coitem_qty_uom_id, coitem_qty_invuomratio, coitem_price_uom_id, coitem_price_invuomratio, coitem_warranty, coitem_cos_accnt_id, coitem_qtyreserved, coitem_subnumber, coitem_firm, coitem_taxtype_id ) VALUES ( _soitemid, _soheadid, _soitem.coitem_linenumber, _soitem.coitem_itemsite_id, 'O', COALESCE(pSchedDate, _soitem.coitem_scheddate), _soitem.coitem_promdate, _soitem.coitem_qtyord, stdCost(_soitem.itemsite_item_id), _soitem.coitem_price, _soitem.coitem_custprice, 0.0, -1, _soitem.coitem_memo, FALSE, 0.0, NULL, _soitem.coitem_custpn, _soitem.coitem_order_type, NULL, -- NULL, _soitem.coitem_substitute_item_id, NULL, getEffectiveXtUser(), _soitem.coitem_prcost, _soitem.coitem_qty_uom_id, _soitem.coitem_qty_invuomratio, _soitem.coitem_price_uom_id, _soitem.coitem_price_invuomratio, _soitem.coitem_warranty, _soitem.coitem_cos_accnt_id, 0.0, _soitem.coitem_subnumber, _soitem.coitem_firm, _soitem.coitem_taxtype_id ); END LOOP; RETURN _soheadid; END; $$; TDROP FUNCTION public.copyso(psoheadid integer, pcustomer integer, pscheddate date); publicadminfalse84623125578138$copytodoitem(integer, date, integer)FUNCTION, CREATE FUNCTION copytodoitem(integer, date, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pparentid ALIAS FOR $1; _duedate DATE := COALESCE($2, CURRENT_DATE); pincdtid ALIAS FOR $3; _alarmid INTEGER; _todoitemid INTEGER; BEGIN INSERT INTO todoitem( todoitem_name, todoitem_description, todoitem_incdt_id, todoitem_creator_username, todoitem_status, todoitem_active, todoitem_due_date, todoitem_assigned_date, todoitem_seq, todoitem_notes, todoitem_crmacct_id, todoitem_ophead_id, todoitem_owner_username,todoitem_priority_id, todoitem_username, todoitem_recurring_todoitem_id ) SELECT todoitem_name, todoitem_description, CASE WHEN pincdtid IS NULL THEN todoitem_incdt_id ELSE pincdtid END, getEffectiveXtUser(), 'N', TRUE, _duedate, CASE WHEN (todoitem_username IS NOT NULL) THEN CURRENT_DATE ELSE NULL END, todoitem_seq, todoitem_notes, todoitem_crmacct_id, todoitem_ophead_id, todoitem_owner_username,todoitem_priority_id, todoitem_username, todoitem_recurring_todoitem_id FROM todoitem WHERE (todoitem_id=pparentid) RETURNING todoitem_id INTO _todoitemid; IF (_todoitemid IS NULL) THEN RETURN -10; END IF; SELECT saveAlarm(NULL, NULL, _duedate, CAST(alarm_time - DATE_TRUNC('day',alarm_time) AS TIME), alarm_time_offset, alarm_time_qualifier, (alarm_event_recipient IS NOT NULL), alarm_event_recipient, (alarm_email_recipient IS NOT NULL AND fetchMetricBool('EnableBatchManager')), alarm_email_recipient, (alarm_sysmsg_recipient IS NOT NULL), alarm_sysmsg_recipient, 'TODO', _todoitemid, 'CHANGEONE') INTO _alarmid FROM alarm WHERE ((alarm_source='TODO') AND (alarm_source_id=pparentid)); IF (_alarmid < 0) THEN RETURN _alarmid; END IF; RETURN _todoitemid; END; $_$; ;DROP FUNCTION public.copytodoitem(integer, date, integer); publicadminfalse84623125578139copyvoucher(integer, date)FUNCTION3 CREATE FUNCTION copyvoucher(integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVoheadid ALIAS FOR $1; _voheadid INTEGER; _vonumber TEXT; _vodate DATE := COALESCE($2, CURRENT_DATE); _i RECORD; _l RECORD; _vodistid INTEGER; BEGIN SELECT * INTO _i FROM vohead WHERE(vohead_id=pVoheadid); IF(NOT FOUND) THEN RETURN -1; END IF; _vonumber := fetchVoNumber(); _voheadid := nextval('vohead_vohead_id_seq'); INSERT INTO vohead (vohead_id, vohead_number, vohead_pohead_id, vohead_posted, vohead_duedate, vohead_invcnumber, vohead_amount, vohead_docdate, vohead_1099, vohead_distdate, vohead_reference, vohead_terms_id, vohead_vend_id, vohead_curr_id, vohead_adjtaxtype_id, vohead_freighttaxtype_id, vohead_gldistdate, vohead_misc, vohead_taxzone_id, vohead_taxtype_id, vohead_notes, vohead_recurring_vohead_id ) VALUES(_voheadid, _vonumber, _i.vohead_pohead_id, false, determineDueDate(_i.vohead_terms_id, _vodate), _i.vohead_invcnumber, _i.vohead_amount, _vodate, _i.vohead_1099, _vodate, _i.vohead_reference, _i.vohead_terms_id, _i.vohead_vend_id, _i.vohead_curr_id, _i.vohead_adjtaxtype_id, _i.vohead_freighttaxtype_id, _vodate, _i.vohead_misc, _i.vohead_taxzone_id, _i.vohead_taxtype_id, _i.vohead_notes, _i.vohead_recurring_vohead_id); FOR _l IN SELECT * FROM vodist WHERE (vodist_vohead_id=pVoheadid) LOOP SELECT NEXTVAL('vodist_vodist_id_seq') INTO _vodistid; INSERT INTO vodist (vodist_id, vodist_poitem_id, vodist_vohead_id, vodist_costelem_id, vodist_accnt_id, vodist_amount, vodist_qty, vodist_expcat_id, vodist_tax_id, vodist_discountable, vodist_notes) VALUES (_vodistid, _l.vodist_poitem_id, _voheadid, _l.vodist_costelem_id, _l.vodist_accnt_id, _l.vodist_amount, _l.vodist_qty, _l.vodist_expcat_id, _l.vodist_tax_id, _l.vodist_discountable, _l.vodist_notes); END LOOP; RETURN _voheadid; END; $_$; 1DROP FUNCTION public.copyvoucher(integer, date); publicadminfalse462381255781404correctporeceipt(integer, numeric, numeric, integer)FUNCTIONCREATE FUNCTION correctporeceipt(integer, numeric, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPorecvid ALIAS FOR $1; pQty ALIAS FOR $2; pFreight ALIAS FOR $3; pItemlocSeries ALIAS FOR $4; BEGIN RETURN correctReceipt('PO', $1, $2, $3, $4, NULL, NULL); END; $_$; KDROP FUNCTION public.correctporeceipt(integer, numeric, numeric, integer); publicadminfalse46238125578141Ccorrectporeceipt(integer, numeric, numeric, integer, integer, date)FUNCTIONKCREATE FUNCTION correctporeceipt(integer, numeric, numeric, integer, integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN correctReceipt('PO', $1, $2, $3, $4, $5, $6); END; $_$; ZDROP FUNCTION public.correctporeceipt(integer, numeric, numeric, integer, integer, date); publicadminfalse846231255781425correctproduction(integer, numeric, boolean, boolean)FUNCTIONCREATE FUNCTION correctproduction(integer, numeric, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'correctProduction(INTEGER, NUMERIC, BOOLEAN, BOOLEAN) has been deprecated. Use corrrectProduction(INTEGER, NUMERIC, BOOLEAN, INTEGER) or a package-specific version instead.'; RETURN correctProduction($1, $2, $3, 0, now()); END; $_$; LDROP FUNCTION public.correctproduction(integer, numeric, boolean, boolean); publicadminfalse84623125578143>correctproduction(integer, numeric, boolean, boolean, integer)FUNCTION CREATE FUNCTION correctproduction(integer, numeric, boolean, boolean, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'correctProduction(INTEGER, NUMERIC, BOOLEAN, BOOLEAN, INTEGER) has been deprecated. Use corrrectProduction(INTEGER, NUMERIC, BOOLEAN, INTEGER) or a package-specific version instead.'; RETURN correctProduction($1, $2, $3, $5, now()); END; $_$; UDROP FUNCTION public.correctproduction(integer, numeric, boolean, boolean, integer); publicadminfalse46238125578144Ocorrectproduction(integer, numeric, boolean, integer, timestamp with time zone)FUNCTIONCREATE FUNCTION correctproduction(integer, numeric, boolean, integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pQty ALIAS FOR $2; pBackflush ALIAS FOR $3; pItemlocSeries ALIAS FOR $4; pGlDistTS ALIAS FOR $5; BEGIN RETURN correctProduction($1, $2, $3, $4, $5, NULL); END; $_$; fDROP FUNCTION public.correctproduction(integer, numeric, boolean, integer, timestamp with time zone); publicadminfalse46238125578145Xcorrectproduction(integer, numeric, boolean, integer, timestamp with time zone, integer)FUNCTIONCREATE FUNCTION correctproduction(integer, numeric, boolean, integer, timestamp with time zone, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pQty ALIAS FOR $2; pBackflush ALIAS FOR $3; pItemlocSeries ALIAS FOR $4; pGlDistTS ALIAS FOR $5; pInvhistId ALIAS FOR $6; _invhistid INTEGER; _itemlocSeries INTEGER; _r RECORD; _parentWIPAccntid INTEGER; _parentQty NUMERIC; _qty NUMERIC; _wipPost NUMERIC; _sense TEXT; _status TEXT; _type TEXT; _qtyfxd NUMERIC := 0; BEGIN -- Qty is positive for Assembly W/O -- Qty is negative for Disassembly W/O IF (pQty = 0) THEN RETURN pItemlocseries; ELSIF (pQty > 0) THEN _sense := 'from'; ELSE _sense := 'to'; END IF; SELECT item_type, roundQty(item_fractional, pQty), wo_status INTO _type, _parentQty, _status FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (wo_id=pWoid); IF (_status != 'I') THEN RETURN -1; END IF; IF (_type = 'J') THEN RETURN -2; END IF; IF (pItemlocSeries = 0) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; ELSE _itemlocSeries := pItemlocSeries; END IF; -- Calculate the WIP to correct SELECT CASE WHEN (wo_cosmethod = 'D') THEN wo_postedvalue ELSE round(((wo_postedvalue - wo_wipvalue) / wo_qtyrcv * _parentQty), 2) END INTO _wipPost FROM wo WHERE (wo_id=pWoid); -- Post the inventory transaction SELECT postInvTrans( itemsite_id, 'RM', (_parentQty * -1.0), 'W/O', 'WO', formatwonumber(pWoid), '', ('Correct Receive Inventory ' || item_number || ' ' || _sense || ' Manufacturing'), costcat_asset_accnt_id, getPrjAccntId(wo_prj_id, costcat_wip_accnt_id), _itemlocSeries, pGlDistTS, (_wipPost * -1.0), -- only used when cost is average pInvhistId) INTO _invhistid FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id) JOIN item ON (item_id=itemsite_item_id) JOIN costcat ON (costcat_id=itemsite_costcat_id) WHERE (wo_id=pWoid); -- Decrease this W/O's qty. received and increase its WIP value UPDATE wo SET wo_qtyrcv = (wo_qtyrcv - _parentQty), wo_wipvalue = (wo_wipvalue + (CASE WHEN(itemsite_costmethod IN ('A','J')) THEN _wipPost WHEN(itemsite_costmethod='S') THEN stdcost(itemsite_item_id) * _parentQty ELSE 0.0 END)) FROM itemsite WHERE ( (wo_itemsite_id=itemsite_id) AND (wo_id=pWoid) ); IF (pBackflush) THEN FOR _r IN SELECT item_id, item_fractional, itemsite_id, itemsite_warehous_id, itemsite_controlmethod, itemsite_loccntrl, itemsite_costmethod, wo_qtyrcv, wo_prj_id, womatl_id, womatl_qtyfxd, womatl_qtyper, womatl_scrap, womatl_issuemethod, womatl_uom_id FROM wo JOIN womatl ON (womatl_wo_id=wo_id AND womatl_issuemethod='L') JOIN itemsite ON (itemsite_id=womatl_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (wo_id=pWoid) LOOP -- Cache the qty to be issued -- If going back to beginning, unissue fixed qty as well IF (_r.wo_qtyrcv - _parentQty > 0) THEN _qtyfxd := 0; ELSE _qtyfxd := _r.womatl_qtyfxd; END IF; _qty = roundQty(_r.item_fractional, (_qtyfxd + _parentQty * _r.womatl_qtyper) * (1 + _r.womatl_scrap)); IF (_qty > 0) THEN SELECT returnWoMaterial(_r.womatl_id, _qty, _itemlocSeries, pGlDistTS) INTO _itemlocSeries; END IF; END LOOP; -- BEGIN ROB Decrease this W/O's WIP value for custom costing UPDATE wo SET wo_wipvalue = (wo_wipvalue - (itemcost_stdcost * _parentQty)) FROM costelem, itemcost, costcat, itemsite, item WHERE ((wo_id=pWoid) AND (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (costelem_id = itemcost_costelem_id) AND (itemcost_item_id = itemsite_item_id) AND (itemsite_costcat_id = costcat_id) AND (costelem_exp_accnt_id) IS NOT NULL AND (costelem_sys = false)); -- ROB Distribute to G/L - create Cost Variance, debit WIP PERFORM insertGLTransaction( 'W/O', 'WO', formatwonumber(pWoid), ('Correct Post Other Cost ' || item_number || ' ' || _sense || ' Manufacturing'), getPrjAccntId(wo_prj_id, costelem_exp_accnt_id), getPrjAccntId(wo_prj_id, costcat_wip_accnt_id), _invhistid, ((itemcost_stdcost * _parentQty)* -1), CURRENT_DATE ) FROM wo, costelem, itemcost, costcat, itemsite, item WHERE ((wo_id=pWoid) AND (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (costelem_id = itemcost_costelem_id) AND (itemcost_item_id = itemsite_item_id) AND (itemsite_costcat_id = costcat_id) AND (costelem_exp_accnt_id) IS NOT NULL AND (costelem_sys = false)); --End ROB END IF; RETURN _itemlocSeries; END; $_$; oDROP FUNCTION public.correctproduction(integer, numeric, boolean, integer, timestamp with time zone, integer); publicadminfalse84623125578147Acorrectreceipt(integer, numeric, numeric, integer, integer, date)FUNCTIONCREATE FUNCTION correctreceipt(integer, numeric, numeric, integer, integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ BEGIN RETURN correctReceipt($1, $2, $3, $4, $5, $6, NULL); END; $_$; XDROP FUNCTION public.correctreceipt(integer, numeric, numeric, integer, integer, date); publicadminfalse46238125578148Jcorrectreceipt(integer, numeric, numeric, integer, integer, date, numeric)FUNCTION)CREATE FUNCTION correctreceipt(integer, numeric, numeric, integer, integer, date, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE precvid ALIAS FOR $1; pQty ALIAS FOR $2; pFreight ALIAS FOR $3; _itemlocSeries INTEGER := COALESCE($4, 0); _currid INTEGER := $5; pEffective ALIAS FOR $6; pRecvCost ALIAS FOR $7; _freight NUMERIC; _qty NUMERIC; _invhistid INTEGER; _o RECORD; _r RECORD; _recvcost NUMERIC; _tmp INTEGER; _pricevar NUMERIC := 0.00; _journalNumber INTEGER := fetchJournalNumber('GL-MISC'); BEGIN SELECT recv_qty, recv_date::DATE AS recv_date, recv_freight_curr_id, recv_orderitem_id, round(currToCurr(recv_freight_curr_id, COALESCE(_currid, recv_freight_curr_id), recv_freight, recv_date::DATE),2) AS recv_freight, recv_posted, recv_order_type, COALESCE(itemsite_id, -1) AS itemsiteid, itemsite_item_id, itemsite_costmethod, itemsite_controlmethod, (recv_splitfrom_id IS NOT NULL OR (SELECT (count(*) > 0) FROM recv WHERE (recv_splitfrom_id=recv_id))) AS split INTO _r FROM recv LEFT OUTER JOIN itemsite ON (recv_itemsite_id=itemsite_id) WHERE (recv_id=precvid); IF (NOT FOUND) THEN RETURN _itemlocSeries; END IF; IF (NOT _r.recv_order_type IN ('PO', 'RA', 'TO')) THEN RETURN -11; END IF; IF (_r.split) THEN RETURN -12; END IF; SELECT currToBase(orderitem_unitcost_curr_id, orderitem_unitcost, _r.recv_date::DATE) AS unitprice_base, orderhead_number, orderitem_linenumber, orderhead_curr_id AS freight_curr_id, orderitem_orderhead_type, orderitem_qty_invuomratio INTO _o FROM orderhead, orderitem WHERE ((orderhead_id=orderitem_orderhead_id) AND (orderhead_type=orderitem_orderhead_type) AND (orderitem_id=_r.recv_orderitem_id) AND (orderitem_orderhead_type=_r.recv_order_type)); IF (NOT FOUND) THEN RETURN _itemlocSeries; END IF; -- Default to _o.orderitem_unitcost if recv_purchcost is not supplied -- Note: this should never happen, a value is always supplied if (pRecvCost IS NULL) THEN _recvcost := _o.orderitem_unitcost; ELSE -- Note: if the receipt has already been posted, pRecvCost will always -- equal the original recv_purchcost (cannot be modified in GUI) _recvcost := pRecvCost; END IF; IF (_r.recv_posted) THEN _qty := (pQty - _r.recv_qty); IF (_qty <> 0) THEN IF (_r.itemsiteid = -1) THEN PERFORM insertGLTransaction( _journalNumber,'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Non-Inventory from ' || _r.recv_order_type, expcat_liability_accnt_id, getPrjAccntId(poitem_prj_id, expcat_exp_accnt_id), -1, ROUND(_o.unitprice_base * _qty, 2), pEffective ) FROM poitem, expcat WHERE ((poitem_expcat_id=expcat_id) AND (poitem_id=_r.recv_orderitem_id) AND (_o.orderitem_orderhead_type='PO')); UPDATE recv SET recv_qty=pQty, recv_value=(recv_value + ROUND(_o.unitprice_base * _qty, 2)), recv_date = pEffective WHERE (recv_id=precvid); ELSEIF (_r.itemsite_controlmethod = 'N') THEN PERFORM insertGLTransaction( _journalNumber,'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Non-Controlled Inventory from ' || _r.recv_order_type, costcat_liability_accnt_id, getPrjAccntId(poitem_prj_id, costcat_exp_accnt_id), -1, ROUND(_o.unitprice_base * _qty, 2), pEffective ) FROM poitem, itemsite, costcat WHERE ((poitem_itemsite_id=itemsite_id) AND (itemsite_costcat_id=costcat_id) AND (poitem_id=_r.recv_orderitem_id) AND (_o.orderitem_orderhead_type='PO')); UPDATE recv SET recv_qty=pQty, recv_value=(recv_value + ROUND(_o.unitprice_base * _qty, 2)), recv_date = pEffective WHERE (recv_id=precvid); ELSE IF (_itemlocSeries = 0 OR _itemlocSeries IS NULL) THEN _itemlocSeries := NEXTVAL('itemloc_series_seq'); END IF; SELECT postInvTrans( itemsite_id, 'RP', (_qty * _o.orderitem_qty_invuomratio), 'S/R', _r.recv_order_type, _o.orderhead_number::TEXT || '-' || _o.orderitem_linenumber::TEXT, '', 'Receive Inventory from ' || _r.recv_order_type, costcat_asset_accnt_id, costcat_liability_accnt_id, _itemlocSeries, pEffective, ROUND(_recvcost * _qty, 2) -- alway passing since it is ignored if not average costed item ) INTO _tmp FROM itemsite, costcat WHERE ((itemsite_costcat_id=costcat_id) AND (itemsite_id=_r.itemsiteid) ); IF(_r.itemsite_costmethod='A') THEN UPDATE recv SET recv_qty=pQty, recv_value=(recv_value + _recvcost * _qty * _o.orderitem_qty_invuomratio), recv_date = pEffective WHERE(recv_id=precvid); ELSE UPDATE recv SET recv_qty=pQty, recv_value=(recv_value + stdcost(_r.itemsite_item_id) * _qty * _o.orderitem_qty_invuomratio), recv_date = pEffective WHERE(recv_id=precvid); END IF; END IF; IF (_r.recv_order_type = 'PO') THEN UPDATE poitem SET poitem_qty_received=(poitem_qty_received + _qty) WHERE (poitem_id=_r.recv_orderitem_id); ELSIF (_r.recv_order_type = 'RA' AND fetchMetricBool('EnableReturnAuth')) THEN UPDATE raitem SET raitem_qtyreceived=(raitem_qtyreceived + _qty) WHERE (raitem_id=_r.recv_orderitem_id); ELSIF (_r.recv_order_type = 'TO' AND fetchMetricBool('MultiWhs')) THEN UPDATE toitem SET toitem_qty_received=(toitem_qty_received + _qty) WHERE (toitem_id=_r.recv_orderitem_id); END IF; END IF; IF (fetchMetricBool('RecordPPVonReceipt')) THEN -- If the 'Purchase Price Variance on Receipt' option is true _invhistid := _tmp; -- Find the difference in the purchase price value expected from the P/O and the value of the transaction SELECT (((currToBase(pohead_curr_id, COALESCE(recv_purchcost, poitem_unitprice), recv_date::DATE)) * _qty) - (invhist_value_after - invhist_value_before)) INTO _pricevar FROM invhist, recv, pohead, poitem WHERE ((recv_orderitem_id=poitem_id) AND (poitem_pohead_id=pohead_id) AND (recv_id=precvid) AND (invhist_id = _invhistid)); -- If difference exists then IF (_pricevar <> 0.00) THEN -- Record an additional GL Transaction for the purchase price variance SELECT insertGLTransaction( _journalNumber, 'S/R', _r.recv_order_type, _o.orderhead_number, 'Purchase price variance adjusted for P/O ' || _o.orderhead_number || ' for item ' || _o.orderitem_linenumber::TEXT, costcat_liability_accnt_id, getPrjAccntId(poitem_prj_id, costcat_purchprice_accnt_id), -1, _pricevar, pEffective, false ) INTO _tmp FROM itemsite, costcat, poitem, recv WHERE ((itemsite_costcat_id=costcat_id) AND (recv_id=precvid) AND (recv_orderitem_id=poitem_id) AND (itemsite_id=recv_itemsite_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Could not insert G/L transaction: no cost category found for itemsite_id %', _r.itemsite_id; ELSIF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction RETURN _tmp; ELSE -- Posting to trial balance is deferred to prevent locking INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries) VALUES ( _tmp, _itemlocSeries ); END IF; END IF; END IF; _freight := (pFreight - _r.recv_freight); IF (_freight <> 0) THEN IF (_r.itemsiteid = -1) THEN PERFORM insertGLTransaction( _journalNumber,'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Non-Inventory Freight from ' || _r.recv_order_type, expcat_liability_accnt_id, getPrjAccntId(poitem_prj_id, expcat_freight_accnt_id), -1, ROUND(currToBase(_currid, _freight, pEffective), 2), pEffective ) FROM poitem, expcat WHERE ((poitem_expcat_id=expcat_id) AND (poitem_id=_r.recv_orderitem_id) AND (_r.recv_order_type='PO')); ELSE PERFORM insertGLTransaction(_journalNumber,'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Non-Inventory Freight from ' || _r.recv_order_type, costcat_liability_accnt_id, costcat_freight_accnt_id, -1, round(currToBase(_currid, _freight, pEffective), 2), pEffective ) FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_r.itemsiteid) ); END IF; IF (_r.recv_order_type = 'PO') THEN UPDATE poitem SET poitem_freight_received=(poitem_freight_received + currToCurr(_currid, _o.freight_curr_id, _freight, pEffective)) WHERE (poitem_id=_r.recv_orderitem_id); -- raitem does not track freight ELSEIF (_r.recv_order_type = 'TO' AND fetchMetricBool('MultiWhs')) THEN UPDATE toitem SET toitem_freight_received=(toitem_freight_received + currToCurr(_currid, _o.freight_curr_id, _freight, pEffective)) WHERE (toitem_id=_r.recv_orderitem_id); END IF; UPDATE recv SET recv_freight=currToCurr(_currid, recv_freight_curr_id, pFreight, pEffective), recv_date = pEffective WHERE (recv_id=precvid); END IF; ELSE -- Receipt not posted yet UPDATE recv SET recv_qty=pQty, recv_freight=pFreight, recv_purchcost=_recvcost WHERE recv_id=precvid; END IF; RETURN _itemlocSeries; END; $_$; aDROP FUNCTION public.correctreceipt(integer, numeric, numeric, integer, integer, date, numeric); publicadminfalse46238125578150$cosbycustomervalue(integer, integer)FUNCTION3CREATE FUNCTION cosbycustomervalue(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; pPeriodid ALIAS FOR $2; _value NUMERIC; _startDate DATE; _endDate DATE; BEGIN _startDate := findPeriodStart(pPeriodid); _endDate := findPeriodEnd(pPeriodid); -- Returns value in base currency -- ToDo: is cohist_shipdate the right DATE to use? SELECT SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitcost, cohist_shipdate)) INTO _value FROM cohist WHERE ( (cohist_cust_id=pCustid) AND (cohist_invcdate BETWEEN _startDate AND _endDate) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; ;DROP FUNCTION public.cosbycustomervalue(integer, integer); publicadminfalse462381255781514costsbycustomerbyitemsite(integer, integer, integer)FUNCTIONCREATE FUNCTION costsbycustomerbyitemsite(integer, integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pPeriodid ALIAS FOR $3; _value NUMERIC; _startDate DATE; _endDate DATE; BEGIN _startDate := findPeriodStart(pPeriodid); _endDate := findPeriodEnd(pPeriodid); -- Returns value in base currency -- ToDo: is cohist_shipdate the right DATE to use? SELECT SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitcost, cohist_shipdate)) INTO _value FROM cohist WHERE ( (cohist_itemsite_id<>pItemsiteid) AND (cohist_cust_id=pCustid) AND (cohist_invcdate BETWEEN _startDate AND _endDate) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; KDROP FUNCTION public.costsbycustomerbyitemsite(integer, integer, integer); publicadminfalse84623125578152&costsbycustomervalue(integer, integer)FUNCTIONUCREATE FUNCTION costsbycustomervalue(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; pPeriodid ALIAS FOR $2; _value NUMERIC; _startDate DATE; _endDate DATE; BEGIN _startDate := findPeriodStart(pPeriodid); _endDate := findPeriodEnd(pPeriodid); -- Returns value in base currency -- ToDo: is cohist_shipdate the right DATE to use? SELECT SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitcost, cohist_shipdate)) INTO _value FROM cohist WHERE ( (cohist_itemsite_id<>-1) AND (cohist_cust_id=pCustid) AND (cohist_invcdate BETWEEN _startDate AND _endDate) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; =DROP FUNCTION public.costsbycustomervalue(integer, integer); publicadminfalse84623125578153/costsbycustomervalue(integer, integer, integer)FUNCTIONCREATE FUNCTION costsbycustomervalue(integer, integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; pPeriodid ALIAS FOR $2; pProdcatid ALIAS FOR $3; _value NUMERIC; _startDate DATE; _endDate DATE; BEGIN _startDate := findPeriodStart(pPeriodid); _endDate := findPeriodEnd(pPeriodid); -- Returns value in base currency -- ToDo: is cohist_shipdate the right DATE to use? SELECT SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitcost, cohist_shipdate)) INTO _value FROM cohist, itemsite, item WHERE ( (cohist_cust_id=pCustid) AND (cohist_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_prodcat_id=pProdcatid) AND (cohist_invcdate BETWEEN _startDate AND _endDate) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; FDROP FUNCTION public.costsbycustomervalue(integer, integer, integer); publicadminfalse84623125578154,costsbycustomervalue(integer, integer, text)FUNCTIONCREATE FUNCTION costsbycustomervalue(integer, integer, text) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; pPeriodid ALIAS FOR $2; pProdcat ALIAS FOR $3; _value NUMERIC; _startDate DATE; _endDate DATE; BEGIN _startDate := findPeriodStart(pPeriodid); _endDate := findPeriodEnd(pPeriodid); -- Returns value in base currency -- ToDo: is cohist_shipdate the right date to use? SELECT SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitcost, cohist_shipdate)) INTO _value FROM cohist, itemsite, item, prodcat WHERE ( (cohist_cust_id=pCustid) AND (cohist_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_prodcat_id=prodcat_id) AND (prodcat_code ~ pProdcat) AND (cohist_invcdate BETWEEN _startDate AND _endDate) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; CDROP FUNCTION public.costsbycustomervalue(integer, integer, text); publicadminfalse46238125578155"createaccountingperiod(date, date)FUNCTIONuCREATE FUNCTION createaccountingperiod(date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pStartDate ALIAS FOR $1; pEndDate ALIAS FOR $2; BEGIN RETURN createAccountingPeriod(pStartDate, pEndDate, NULL, NULL); END; $_$; 9DROP FUNCTION public.createaccountingperiod(date, date); publicadminfalse846231255781564createaccountingperiod(date, date, integer, integer)FUNCTION CREATE FUNCTION createaccountingperiod(date, date, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pStartDate ALIAS FOR $1; pEndDate ALIAS FOR $2; pYearPeriodId ALIAS FOR $3; pQuarter ALIAS FOR $4; _periodid INTEGER; _check INTEGER; _r RECORD; _initial BOOLEAN; _number INTEGER; BEGIN -- Make that the passed start date doesn't fall into any existing period SELECT period_id INTO _check FROM period WHERE (pStartDate BETWEEN period_start AND period_end); IF (FOUND) THEN RETURN -1; END IF; -- Make that the passed end date doesn't fall into any existing period SELECT period_id INTO _check FROM period WHERE (pEndDate BETWEEN period_start AND period_end); IF (FOUND) THEN RETURN -2; END IF; -- Make that the passed start and end dates don't enclose an existing period SELECT period_id INTO _check FROM period WHERE ( (period_start >= pStartDate) AND (period_end <= pEndDate) ); IF (FOUND) THEN RETURN -3; END IF; -- Make sure period is inside fiscal year SELECT yearperiod_id INTO _check FROM yearperiod WHERE ((yearperiod_id=pYearPeriodId) AND (pStartDate>=yearperiod_start) AND (pEndDate<=yearperiod_end)); IF NOT (FOUND) THEN RETURN -4; END IF; -- Determine if this is the initial accounting period SELECT CASE WHEN(count(*) > 0) THEN FALSE ELSE TRUE END INTO _initial FROM period; -- Determine the next number SELECT COALESCE(MAX(period_number),0) + 1 INTO _number FROM period WHERE (period_yearperiod_id=pYearPeriodId); -- Create the new accounting period SELECT NEXTVAL('period_period_id_seq') INTO _periodid; INSERT INTO period ( period_id, period_start, period_end, period_closed, period_freeze, period_initial, period_number, period_yearperiod_id, period_quarter ) VALUES ( _periodid, pStartDate, pEndDate, FALSE, FALSE, _initial, _number, pYearPeriodId, pQuarter ); -- Post any unposted G/L Transactions into the new period FOR _r IN SELECT DISTINCT gltrans_sequence FROM gltrans WHERE ( (NOT gltrans_posted) AND (gltrans_date BETWEEN pStartDate AND pEndDate) ) LOOP PERFORM postIntoTrialBalance(_r.gltrans_sequence); END LOOP; -- Forward Update Accounting Periods for all G/L Accounts PERFORM forwardupdatetrialbalance(max(trialbal_id)) FROM accnt LEFT OUTER JOIN trialbal ON ( (trialbal_accnt_id=accnt_id) ) GROUP BY accnt_id HAVING max(trialbal_id) IS NOT NULL ORDER BY accnt_id; RETURN _periodid; END; $_$; KDROP FUNCTION public.createaccountingperiod(date, date, integer, integer); publicadminfalse84623125578157&createaccountingyearperiod(date, date)FUNCTIONCREATE FUNCTION createaccountingyearperiod(date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pStartDate ALIAS FOR $1; pEndDate ALIAS FOR $2; _yearperiodid INTEGER; _check INTEGER; _checkBool BOOLEAN; _r RECORD; _initial BOOLEAN; BEGIN -- Make that the passed start date doesn't fall into any existing yearperiod SELECT yearperiod_id INTO _check FROM yearperiod WHERE (pStartDate BETWEEN yearperiod_start AND yearperiod_end); IF (FOUND) THEN RETURN -1; END IF; -- Make that the passed end date doesn't fall into any existing yearperiod SELECT yearperiod_id INTO _check FROM yearperiod WHERE (pEndDate BETWEEN yearperiod_start AND yearperiod_end); IF (FOUND) THEN RETURN -2; END IF; -- Make that the passed start and end dates don't enclose an existing yearperiod SELECT yearperiod_id INTO _check FROM yearperiod WHERE ( (yearperiod_start >= pStartDate) AND (yearperiod_end <= pEndDate) ); IF (FOUND) THEN RETURN -3; END IF; -- Make sure that the passed start is prior to the end date SELECT (pStartDate > pEndDate) INTO _checkBool; IF (_checkBool) THEN RETURN -5; END IF; -- Determine if this is the initial accounting yearperiod SELECT CASE WHEN(count(*) > 0) THEN FALSE ELSE TRUE END INTO _initial FROM yearperiod; -- Create the new accounting yearperiod SELECT NEXTVAL('yearperiod_yearperiod_id_seq') INTO _yearperiodid; INSERT INTO yearperiod ( yearperiod_id, yearperiod_start, yearperiod_end, yearperiod_closed ) VALUES ( _yearperiodid, pStartDate, pEndDate, FALSE ); RETURN _yearperiodid; END; $_$; =DROP FUNCTION public.createaccountingyearperiod(date, date); publicadminfalse46238125578158createapchecks(integer, date)FUNCTION[CREATE FUNCTION createapchecks(integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'createAPChecks() is deprecated - use createChecks() instead'; RETURN createChecks($1, $2); END; $_$; 4DROP FUNCTION public.createapchecks(integer, date); publicadminfalse84623125578159<createapcreditmemo(integer, text, text, date, numeric, text)FUNCTIONCREATE FUNCTION createapcreditmemo(integer, text, text, date, numeric, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pDocNumber ALIAS FOR $2; pPoNumber ALIAS FOR $3; pDocDate ALIAS FOR $4; pAmount ALIAS FOR $5; pNotes ALIAS FOR $6; _result INTEGER; BEGIN SELECT createAPCreditMemo( pVendid, fetchJournalNumber('AP-MISC'), pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, -1, pDocDate, -1, baseCurrId() ) INTO _result; RETURN _result; END; $_$; SDROP FUNCTION public.createapcreditmemo(integer, text, text, date, numeric, text); publicadminfalse46238125578160Ecreateapcreditmemo(integer, integer, text, text, date, numeric, text)FUNCTION\CREATE FUNCTION createapcreditmemo(integer, integer, text, text, date, numeric, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pDocNumber ALIAS FOR $3; pPoNumber ALIAS FOR $4; pDocDate ALIAS FOR $5; pAmount ALIAS FOR $6; pNotes ALIAS FOR $7; BEGIN RETURN createAPCreditMemo(pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, -1, pDocDate, -1, baseCurrId() ); END; $_$; \DROP FUNCTION public.createapcreditmemo(integer, integer, text, text, date, numeric, text); publicadminfalse46238125578161Ecreateapcreditmemo(integer, text, text, date, numeric, text, integer)FUNCTIONCREATE FUNCTION createapcreditmemo(integer, text, text, date, numeric, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pDocNumber ALIAS FOR $2; pPoNumber ALIAS FOR $3; pDocDate ALIAS FOR $4; pAmount ALIAS FOR $5; pNotes ALIAS FOR $6; pAccntid ALIAS FOR $7; _result INTEGER; BEGIN SELECT createAPCreditMemo( pVendid, fetchJournalNumber('AP-MISC'), pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDocDate, -1, baseCurrId() ) INTO _result; RETURN _result; END; $_$; \DROP FUNCTION public.createapcreditmemo(integer, text, text, date, numeric, text, integer); publicadminfalse46238125578162Ncreateapcreditmemo(integer, integer, text, text, date, numeric, text, integer)FUNCTIONCREATE FUNCTION createapcreditmemo(integer, integer, text, text, date, numeric, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pDocNumber ALIAS FOR $3; pPoNumber ALIAS FOR $4; pDocDate ALIAS FOR $5; pAmount ALIAS FOR $6; pNotes ALIAS FOR $7; pAccntid ALIAS FOR $8; BEGIN RETURN createAPCreditMemo( pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDocDate, -1, baseCurrId() ); END; $_$; eDROP FUNCTION public.createapcreditmemo(integer, integer, text, text, date, numeric, text, integer); publicadminfalse46238125578163Tcreateapcreditmemo(integer, text, text, date, numeric, text, integer, date, integer)FUNCTIONCREATE FUNCTION createapcreditmemo(integer, text, text, date, numeric, text, integer, date, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pDocNumber ALIAS FOR $2; pPoNumber ALIAS FOR $3; pDocDate ALIAS FOR $4; pAmount ALIAS FOR $5; pNotes ALIAS FOR $6; pAccntid ALIAS FOR $7; pDueDate ALIAS FOR $8; pTermsid ALIAS FOR $9; _result INTEGER; BEGIN SELECT createAPCreditMemo( pVendid, fetchJournalNumber('AP-MISC'), pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDueDate, pTermsid, baseCurrId() ) INTO _result; RETURN _result; END; $_$; kDROP FUNCTION public.createapcreditmemo(integer, text, text, date, numeric, text, integer, date, integer); publicadminfalse84623125578164]createapcreditmemo(integer, integer, text, text, date, numeric, text, integer, date, integer)FUNCTIONCREATE FUNCTION createapcreditmemo(integer, integer, text, text, date, numeric, text, integer, date, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pDocNumber ALIAS FOR $3; pPoNumber ALIAS FOR $4; pDocDate ALIAS FOR $5; pAmount ALIAS FOR $6; pNotes ALIAS FOR $7; pAccntid ALIAS FOR $8; pDueDate ALIAS FOR $9; pTermsid ALIAS FOR $10; BEGIN RETURN createAPCreditMemo( pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDueDate, pTermsid, baseCurrId() ); END; $_$; tDROP FUNCTION public.createapcreditmemo(integer, integer, text, text, date, numeric, text, integer, date, integer); publicadminfalse46238125578165fcreateapcreditmemo(integer, integer, text, text, date, numeric, text, integer, date, integer, integer)FUNCTIONCREATE FUNCTION createapcreditmemo(integer, integer, text, text, date, numeric, text, integer, date, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pDocNumber ALIAS FOR $3; pPoNumber ALIAS FOR $4; pDocDate ALIAS FOR $5; pAmount ALIAS FOR $6; pNotes ALIAS FOR $7; pAccntid ALIAS FOR $8; pDueDate ALIAS FOR $9; pTermsid ALIAS FOR $10; pCurrId ALIAS FOR $11; BEGIN RETURN createAPCreditMemo( NULL, pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDueDate, pTermsid, pCurrId ); END; $_$; }DROP FUNCTION public.createapcreditmemo(integer, integer, text, text, date, numeric, text, integer, date, integer, integer); publicadminfalse46238125578166ocreateapcreditmemo(integer, integer, integer, text, text, date, numeric, text, integer, date, integer, integer)FUNCTION CREATE FUNCTION createapcreditmemo(integer, integer, integer, text, text, date, numeric, text, integer, date, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pId ALIAS FOR $1; pVendid ALIAS FOR $2; pJournalNumber ALIAS FOR $3; pDocNumber ALIAS FOR $4; pPoNumber ALIAS FOR $5; pDocDate ALIAS FOR $6; pAmount ALIAS FOR $7; pNotes ALIAS FOR $8; pAccntid ALIAS FOR $9; pDueDate ALIAS FOR $10; pTermsid ALIAS FOR $11; pCurrId ALIAS FOR $12; _vendName TEXT; _apAccntid INTEGER; _prepaidAccntid INTEGER; _accntid INTEGER; _glSequence INTEGER; _journalNumber INTEGER; _apopenid INTEGER; _baseAmount NUMERIC; _taxBaseValue NUMERIC; _test INTEGER; BEGIN _apopenid := pId; SELECT findAPAccount(pVendid) INTO _apAccntid; SELECT findAPPrepaidAccount(pVendid) INTO _prepaidAccntid; SELECT vend_name INTO _vendName FROM vendinfo WHERE (vend_id=pVendid); _accntid := pAccntid; PERFORM accnt_id FROM accnt WHERE (accnt_id=_accntid); IF (FOUND) THEN _prepaidAccntid := _accntid; ELSE _accntid := -1; END IF; IF(pJournalNumber IS NULL) THEN SELECT fetchJournalNumber('AP-MISC') INTO _journalNumber; ELSE _journalNumber := pJournalNumber; END IF; SELECT fetchGLSequence() INTO _glSequence; IF (_apopenid IS NOT NULL) THEN UPDATE apopen SET apopen_username=getEffectiveXtUser(), apopen_journalnumber=_journalNumber, apopen_vend_id=pVendid, apopen_docnumber=pDocNumber, apopen_doctype='C', apopen_ponumber=pPoNumber, apopen_docdate=pDocDate, apopen_duedate=pDueDate, apopen_distdate=pDocDate, apopen_terms_id=pTermsid, apopen_amount=pAmount, apopen_paid=0, apopen_open=(pAmount <> 0), apopen_notes=pNotes, apopen_accnt_id=_accntid, apopen_curr_id=pCurrId, apopen_closedate=CASE WHEN (pAmount = 0) THEN pDocdate END WHERE apopen_id = _apopenid; ELSE SELECT NEXTVAL('apopen_apopen_id_seq') INTO _apopenid; INSERT INTO apopen ( apopen_id, apopen_username, apopen_journalnumber, apopen_vend_id, apopen_docnumber, apopen_doctype, apopen_ponumber, apopen_docdate, apopen_duedate, apopen_distdate, apopen_terms_id, apopen_amount, apopen_paid, apopen_open, apopen_notes, apopen_accnt_id, apopen_curr_id, apopen_closedate ) VALUES ( _apopenid, getEffectiveXtUser(), _journalNumber, pVendid, pDocNumber, 'C', pPoNumber, pDocDate, pDueDate, pDocDate, pTermsid, pAmount, 0, (pAmount <> 0), pNotes, _accntid, pCurrId, CASE WHEN (pAmount = 0) THEN pDocDate END ); END IF; _baseAmount := round(currToBase(pCurrId, pAmount, pDocDate), 2); -- Debit the A/P account for the full amount SELECT insertIntoGLSeries ( _glSequence, 'A/P', 'CM', pDocNumber, _apAccntid, (_baseAmount * -1), pDocDate, (_vendName || ' ' || pNotes) ) INTO _test; -- Credit the Tax account for the tax amount _taxBaseValue := addTaxToGLSeries(_glSequence, 'A/P', 'CM', pDocNumber, pCurrId, pDocDate, pDocDate, 'apopentax', _apopenid, _vendName); UPDATE apopentax SET taxhist_journalnumber = _journalNumber WHERE taxhist_parent_id=_apopenid; -- Credit the Prepaid account for the basis amount SELECT insertIntoGLSeries ( _glSequence, 'A/P', 'CM', pDocNumber, _prepaidAccntid, (_baseAmount - _taxBaseValue), pDocDate, (_vendName || ' ' || pNotes) ) INTO _test; -- Commit the GLSeries; SELECT postGLSeries(_glSequence, _journalNumber) INTO _test; IF (_test < 0) THEN DELETE FROM apopen WHERE (apopen_id=_apopenid); PERFORM deleteGLSeries(_glSequence); RAISE EXCEPTION 'postGLSeries commit failed with %', _test; END IF; RETURN pJournalNumber; END; $_$; DROP FUNCTION public.createapcreditmemo(integer, integer, integer, text, text, date, numeric, text, integer, date, integer, integer); publicadminfalse84623125578167Acreateapcreditmemoapplication(integer, integer, numeric, integer)FUNCTIONCREATE FUNCTION createapcreditmemoapplication(psourceapopenid integer, ptargetapopenid integer, pamount numeric, pcurrid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _apCreditApplyId INTEGER; BEGIN IF (pAmount > (SELECT ROUND(currToCurr(apopen_curr_id, pCurrId, (apopen_amount - apopen_paid), apopen_docdate), 2) FROM apopen WHERE (apopen_id=pTargetApopenId))) THEN RETURN -1; END IF; IF (pAmount > (SELECT ROUND((apopen_amount - apopen_paid) - COALESCE(SUM(currToCurr(apcreditapply_curr_id, apopen_curr_id, apcreditapply_amount, apopen_docdate)), 0), 2) FROM apopen LEFT OUTER JOIN apcreditapply ON ((apcreditapply_source_apopen_id=apopen_id) AND (apcreditapply_target_apopen_id<>pTargetApopenId)) WHERE (apopen_id=pSourceApopenId) GROUP BY apopen_amount, apopen_paid)) THEN RETURN -2; END IF; SELECT apcreditapply_id INTO _apCreditApplyId FROM apcreditapply WHERE ((apcreditapply_source_apopen_id=pSourceApopenId) AND (apcreditapply_target_apopen_id=pTargetApopenId)); IF (FOUND) THEN UPDATE apcreditapply SET apcreditapply_amount=pAmount, apcreditapply_curr_id=pCurrId WHERE (apcreditapply_id=_apCreditApplyId); ELSE INSERT INTO apcreditapply ( apcreditapply_source_apopen_id, apcreditapply_target_apopen_id, apcreditapply_amount, apcreditapply_curr_id ) VALUES ( pSourceApopenId, pTargetApopenId, pAmount, pCurrId) RETURNING apcreditapply_id INTO _apCreditApplyId; END IF; RETURN _apCreditApplyId; END; $$; DROP FUNCTION public.createapcreditmemoapplication(psourceapopenid integer, ptargetapopenid integer, pamount numeric, pcurrid integer); publicadminfalse84623125578168;createapdebitmemo(integer, text, text, date, numeric, text)FUNCTIONCREATE FUNCTION createapdebitmemo(integer, text, text, date, numeric, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pDocNumber ALIAS FOR $2; pPoNumber ALIAS FOR $3; pDocDate ALIAS FOR $4; pAmount ALIAS FOR $5; pNotes ALIAS FOR $6; _result INTEGER; BEGIN SELECT createAPDebitMemo( pVendid, fetchJournalNumber('AP-MISC'), pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, -1, pDocDate, -1, baseCurrId() ) INTO _result; RETURN _result; END; $_$; RDROP FUNCTION public.createapdebitmemo(integer, text, text, date, numeric, text); publicadminfalse84623125578169Dcreateapdebitmemo(integer, integer, text, text, date, numeric, text)FUNCTION\CREATE FUNCTION createapdebitmemo(integer, integer, text, text, date, numeric, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pDocNumber ALIAS FOR $3; pPoNumber ALIAS FOR $4; pDocDate ALIAS FOR $5; pAmount ALIAS FOR $6; pNotes ALIAS FOR $7; BEGIN RETURN createAPDebitMemo(pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, -1, pDocDate, -1, baseCurrId() ); END; $_$; [DROP FUNCTION public.createapdebitmemo(integer, integer, text, text, date, numeric, text); publicadminfalse46238125578170Dcreateapdebitmemo(integer, text, text, date, numeric, text, integer)FUNCTIONCREATE FUNCTION createapdebitmemo(integer, text, text, date, numeric, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pDocNumber ALIAS FOR $2; pPoNumber ALIAS FOR $3; pDocDate ALIAS FOR $4; pAmount ALIAS FOR $5; pNotes ALIAS FOR $6; pAccntid ALIAS FOR $7; _result INTEGER; BEGIN SELECT createAPDebitMemo( pVendid, fetchJournalNumber('AP-MISC'), pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDocDate, -1, baseCurrId() ) INTO _result; RETURN _result; END; $_$; [DROP FUNCTION public.createapdebitmemo(integer, text, text, date, numeric, text, integer); publicadminfalse84623125578171Mcreateapdebitmemo(integer, integer, text, text, date, numeric, text, integer)FUNCTIONCREATE FUNCTION createapdebitmemo(integer, integer, text, text, date, numeric, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pDocNumber ALIAS FOR $3; pPoNumber ALIAS FOR $4; pDocDate ALIAS FOR $5; pAmount ALIAS FOR $6; pNotes ALIAS FOR $7; pAccntid ALIAS FOR $8; BEGIN RETURN createAPDebitMemo( pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDocDate, -1, baseCurrId() ); END; $_$; dDROP FUNCTION public.createapdebitmemo(integer, integer, text, text, date, numeric, text, integer); publicadminfalse84623125578172Screateapdebitmemo(integer, text, text, date, numeric, text, integer, date, integer)FUNCTIONCREATE FUNCTION createapdebitmemo(integer, text, text, date, numeric, text, integer, date, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pDocNumber ALIAS FOR $2; pPoNumber ALIAS FOR $3; pDocDate ALIAS FOR $4; pAmount ALIAS FOR $5; pNotes ALIAS FOR $6; pAccntid ALIAS FOR $7; pDueDate ALIAS FOR $8; pTermsid ALIAS FOR $9; _result INTEGER; BEGIN SELECT createAPDebitMemo( pVendid, fetchJournalNumber('AP-MISC'), pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDueDate, pTermsid, baseCurrId() ) INTO _result; RETURN _result; END; $_$; jDROP FUNCTION public.createapdebitmemo(integer, text, text, date, numeric, text, integer, date, integer); publicadminfalse84623125578173\createapdebitmemo(integer, integer, text, text, date, numeric, text, integer, date, integer)FUNCTIONCREATE FUNCTION createapdebitmemo(integer, integer, text, text, date, numeric, text, integer, date, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pDocNumber ALIAS FOR $3; pPoNumber ALIAS FOR $4; pDocDate ALIAS FOR $5; pAmount ALIAS FOR $6; pNotes ALIAS FOR $7; pAccntid ALIAS FOR $8; pDueDate ALIAS FOR $9; pTermsid ALIAS FOR $10; BEGIN RETURN createAPDebitMemo(pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDueDate, pTermsid, baseCurrId() ); END; $_$; sDROP FUNCTION public.createapdebitmemo(integer, integer, text, text, date, numeric, text, integer, date, integer); publicadminfalse46238125578174ecreateapdebitmemo(integer, integer, text, text, date, numeric, text, integer, date, integer, integer)FUNCTIONCREATE FUNCTION createapdebitmemo(integer, integer, text, text, date, numeric, text, integer, date, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pDocNumber ALIAS FOR $3; pPoNumber ALIAS FOR $4; pDocDate ALIAS FOR $5; pAmount ALIAS FOR $6; pNotes ALIAS FOR $7; pAccntid ALIAS FOR $8; pDueDate ALIAS FOR $9; pTermsid ALIAS FOR $10; pCurrId ALIAS FOR $11; BEGIN RETURN createAPDebitMemo(NULL, pVendid, pJournalNumber, pDocNumber, pPoNumber, pDocDate, pAmount, pNotes, pAccntid, pDueDate, pTermsid, pCurrId ); END; $_$; |DROP FUNCTION public.createapdebitmemo(integer, integer, text, text, date, numeric, text, integer, date, integer, integer); publicadminfalse46238125578175ncreateapdebitmemo(integer, integer, integer, text, text, date, numeric, text, integer, date, integer, integer)FUNCTIONWCREATE FUNCTION createapdebitmemo(integer, integer, integer, text, text, date, numeric, text, integer, date, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pId ALIAS FOR $1; pVendid ALIAS FOR $2; pJournalNumber ALIAS FOR $3; pDocNumber ALIAS FOR $4; pPoNumber ALIAS FOR $5; pDocDate ALIAS FOR $6; pAmount ALIAS FOR $7; pNotes ALIAS FOR $8; pAccntid ALIAS FOR $9; pDueDate ALIAS FOR $10; pTermsid ALIAS FOR $11; pCurrId ALIAS FOR $12; _vendName TEXT; _apAccntid INTEGER; _prepaidAccntid INTEGER; _accntid INTEGER; _glSequence INTEGER; _journalNumber INTEGER; _apopenid INTEGER; _baseAmount NUMERIC; _taxBaseValue NUMERIC; _test INTEGER; BEGIN _apopenid := pId; SELECT findAPAccount(pVendid) INTO _apAccntid; SELECT findAPPrepaidAccount(pVendid) INTO _prepaidAccntid; SELECT vend_name INTO _vendName FROM vendinfo WHERE (vend_id=pVendid); _accntid := pAccntid; PERFORM accnt_id FROM accnt WHERE (accnt_id=_accntid); IF (FOUND) THEN _prepaidAccntid := _accntid; ELSE _accntid := -1; END IF; IF(pJournalNumber IS NULL) THEN SELECT fetchJournalNumber('AP-MISC') INTO _journalNumber; ELSE _journalNumber := pJournalNumber; END IF; SELECT fetchGLSequence() INTO _glSequence; IF (_apopenid IS NOT NULL) THEN UPDATE apopen SET apopen_username=getEffectiveXtUser(), apopen_journalnumber=_journalNumber, apopen_vend_id=pVendid, apopen_docnumber=pDocNumber, apopen_doctype='D', apopen_ponumber=pPoNumber, apopen_docdate=pDocDate, apopen_duedate=pDueDate, apopen_distdate=pDocDate, apopen_terms_id=pTermsid, apopen_amount=pAmount, apopen_paid=0, apopen_open=(pAmount <> 0), apopen_notes=pNotes, apopen_accnt_id=_accntid, apopen_curr_id=pCurrId, apopen_closedate=CASE WHEN (pAmount = 0) THEN pDocdate END WHERE apopen_id = _apopenid; ELSE SELECT NEXTVAL('apopen_apopen_id_seq') INTO _apopenid; INSERT INTO apopen ( apopen_id, apopen_username, apopen_journalnumber, apopen_vend_id, apopen_docnumber, apopen_doctype, apopen_ponumber, apopen_docdate, apopen_duedate, apopen_distdate, apopen_terms_id, apopen_amount, apopen_paid, apopen_discountable_amount, apopen_open, apopen_notes, apopen_accnt_id, apopen_curr_id, apopen_closedate ) VALUES ( _apopenid, getEffectiveXtUser(), _journalNumber, pVendid, pDocNumber, 'D', pPoNumber, pDocDate, pDueDate, pDocDate, pTermsid, pAmount, 0, 0, (pAmount <> 0), pNotes, _accntid, pCurrId, CASE WHEN (pAmount = 0) THEN pDocDate END ); END IF; _baseAmount := round(currToBase(pCurrId, pAmount, pDocDate), 2); -- Credit the A/P account for the full amount SELECT insertIntoGLSeries ( _glSequence, 'A/P', 'DM', pDocNumber, _apAccntid, _baseAmount, pDocDate, (_vendName || ' ' || pNotes) ) INTO _test; -- Debit the Tax account for the tax amount _taxBaseValue := addTaxToGLSeries(_glSequence, 'A/P', 'DM', pDocNumber, pCurrId, pDocDate, pDocDate, 'apopentax', _apopenid, _vendName); UPDATE apopentax SET taxhist_journalnumber = _journalNumber WHERE taxhist_parent_id=_apopenid; -- Debit the Prepaid account for the basis amount -- Note, the taxBaseValue is negative so it is added SELECT insertIntoGLSeries ( _glSequence, 'A/P', 'DM', pDocNumber, _prepaidAccntid, (_baseAmount + _taxBaseValue) * -1, pDocDate, (_vendName || ' ' || pNotes) ) INTO _test; -- Commit the GLSeries; SELECT postGLSeries(_glSequence, _journalNumber) INTO _test; IF (_test < 0) THEN DELETE FROM apopen WHERE (apopen_id=_apopenid); PERFORM deleteGLSeries(_glSequence); RAISE EXCEPTION 'postGLSeries commit failed with %', _test; END IF; RETURN _apopenid; END; $_$; DROP FUNCTION public.createapdebitmemo(integer, integer, integer, text, text, date, numeric, text, integer, date, integer, integer); publicadminfalse46238125578176"createapdiscount(integer, numeric)FUNCTIONCREATE FUNCTION createapdiscount(integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pApopenid ALIAS FOR $1; pAmount ALIAS FOR $2; _result INTEGER; BEGIN SELECT createAPDiscount(pApopenid, fetchJournalNumber('AP-MISC'), pAmount) INTO _result; RETURN _result; END; $_$; 9DROP FUNCTION public.createapdiscount(integer, numeric); publicadminfalse46238125578177+createapdiscount(integer, integer, numeric)FUNCTION CREATE FUNCTION createapdiscount(integer, integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pApopenid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pAmount ALIAS FOR $3; _ap RECORD; _sequence INTEGER; _apopenid INTEGER; _apcreditapplyid INTEGER; _result INTEGER; _crAccnt INTEGER; _dbAccnt INTEGER; _reference TEXT; _discountDateAmt NUMERIC; BEGIN SELECT NEXTVAL('apopen_apopen_id_seq') INTO _apopenid; SELECT * INTO _ap FROM apopen WHERE (apopen_id = pApopenid); IF (NOT FOUND) THEN RETURN -1; END IF; _crAccnt := findAPDiscountAccount(_ap.apopen_vend_id); _dbAccnt := findAPAccount(_ap.apopen_vend_id); _reference := ('Discount for ' || _ap.apopen_doctype || ' ' || _ap.apopen_docnumber); SELECT fetchGLSequence() INTO _sequence; _discountDateAmt = round(pAmount / _ap.apopen_curr_rate, 2); PERFORM insertIntoGLSeries( _sequence, 'A/P', 'DS', _ap.apopen_docnumber, _dbAccnt, _discountDateAmt * -1, CURRENT_DATE, _reference); PERFORM insertIntoGLSeries( _sequence, 'A/P', 'DS', _ap.apopen_docnumber, _crAccnt, _discountDateAmt, CURRENT_DATE, _reference); PERFORM postGLSeries(_sequence, pJournalNumber); INSERT INTO apopen ( apopen_id, apopen_username, apopen_journalnumber, apopen_vend_id, apopen_docnumber, apopen_doctype, apopen_ponumber, apopen_docdate, apopen_duedate, apopen_distdate, apopen_terms_id, apopen_curr_id, apopen_amount, apopen_paid, apopen_open, apopen_notes, apopen_discount, apopen_curr_rate ) SELECT _apopenid, getEffectiveXtUser(), pJournalNumber, apopen_vend_id, apopen_docnumber, 'C', apopen_ponumber, CURRENT_DATE, CURRENT_DATE, CURRENT_DATE, -1, apopen_curr_id, pAmount, 0, TRUE, _reference, TRUE, apopen_curr_rate FROM apopen WHERE (apopen_id=pApopenid); SELECT apcreditapply_id INTO _apcreditapplyid FROM apcreditapply WHERE ( (apcreditapply_source_apopen_id=_apopenid) AND (apcreditapply_target_apopen_id=pApopenid) ); IF (FOUND) THEN UPDATE apcreditapply SET apcreditapply_amount=pAmount WHERE (apcreditapply_id=_apcreditapplyid); ELSE SELECT nextval('apcreditapply_apcreditapply_id_seq') INTO _apcreditapplyid; INSERT INTO apcreditapply ( apcreditapply_id, apcreditapply_source_apopen_id, apcreditapply_target_apopen_id, apcreditapply_amount, apcreditapply_curr_id ) VALUES ( _apcreditapplyid, _apopenid, pApopenid, pAmount, _ap.apopen_curr_id ); END IF; SELECT postAPCreditMemoApplication(_apopenid) INTO _result; IF (_result < 0) THEN RETURN _result; END IF; RETURN pJournalNumber; END; $_$; BDROP FUNCTION public.createapdiscount(integer, integer, numeric); publicadminfalse46238125578178Ocreatearcashdeposit(integer, text, text, date, numeric, text, integer, integer)FUNCTIONCREATE FUNCTION createarcashdeposit(integer, text, text, date, numeric, text, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; pDocNumber ALIAS FOR $2; pOrderNumber ALIAS FOR $3; pDocDate ALIAS FOR $4; pAmount ALIAS FOR $5; pNotes ALIAS FOR $6; pJournalNumber ALIAS FOR $7; pCurrId ALIAS FOR $8; _prepaidaccntid INTEGER; _deferredaccntid INTEGER; _glSequence INTEGER; _aropenid INTEGER; BEGIN IF (pAmount <= 0) THEN RETURN 0; END IF; _prepaidaccntid := findPrepaidAccount(pCustid); IF (_prepaidaccntid = -1) THEN RAISE EXCEPTION 'There was an error creating the Customer Deposit GL Transactions. No Prepaid Account is assigned.'; END IF; _deferredaccntid := findDeferredAccount(pCustid); IF (_deferredaccntid = -1) THEN RAISE EXCEPTION 'There was an error creating the Customer Deposit GL Transactions. No Deferred Account is assigned.'; END IF; SELECT NEXTVAL('aropen_aropen_id_seq') INTO _aropenid; SELECT insertGLTransaction( pJournalNumber, 'A/R', 'CD', pDocNumber, pNotes, _deferredaccntid, _prepaidaccntid, _aropenid, round(currToBase(pCurrId, pAmount, pDocDate), 2), pDocDate) INTO _glSequence; INSERT INTO aropen ( aropen_id, aropen_username, aropen_journalnumber, aropen_cust_id, aropen_docnumber, aropen_doctype, aropen_ordernumber, aropen_docdate, aropen_duedate, aropen_distdate, aropen_terms_id, aropen_salesrep_id, aropen_amount, aropen_paid, aropen_commission_due, aropen_commission_paid, aropen_applyto, aropen_ponumber, aropen_cobmisc_id, aropen_open, aropen_notes, aropen_rsncode_id, aropen_salescat_id, aropen_accnt_id, aropen_curr_id ) VALUES ( _aropenid, getEffectiveXtUser(), pJournalNumber, pCustid, pDocNumber, 'R', pOrderNumber, pDocDate, pDocDate, pDocDate, -1, NULL, round(pAmount, 2), 0, 0.0, FALSE, '', '', -1, TRUE, pNotes, -1, -1, -1, pCurrId ); RETURN _aropenid; END; $_$; fDROP FUNCTION public.createarcashdeposit(integer, text, text, date, numeric, text, integer, integer); publicadminfalse46238125578179createarcreditmemo(integer, integer, text, text, date, numeric, text, integer, integer, integer, date, integer, integer, numeric, integer, integer, integer, integer)FUNCTIONCREATE FUNCTION createarcreditmemo(pid integer, pcustid integer, pdocnumber text, pordernumber text, pdocdate date, pamount numeric, pnotes text, prsncodeid integer, psalescatid integer, paccntid integer, pduedate date, ptermsid integer, psalesrepid integer, pcommissiondue numeric DEFAULT 0, pjournalnumber integer DEFAULT NULL::integer, pcurrid integer DEFAULT basecurrid(), paraccntid integer DEFAULT NULL::integer, pcoccpayid integer DEFAULT NULL::integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _accntid INTEGER; _arAccntid INTEGER; _aropenid INTEGER; _cohistid INTEGER; _custName TEXT; _duedate DATE := COALESCE(pDueDate, pDocDate); _glSequence INTEGER; _journalNumber INTEGER; _prepaidAccntid INTEGER; _salescatid INTEGER; _taxBaseValue NUMERIC; _test INTEGER; _tmp INTEGER; BEGIN _aropenid := pId; _arAccntid := COALESCE(pARAccntid, findARAccount(pCustid)); _prepaidAccntid := findPrepaidAccount(pCustid); _accntid := pAccntid; _salescatid := pSalescatid; SELECT cust_name INTO _custName FROM custinfo WHERE (cust_id=pCustid); IF EXISTS(SELECT 1 FROM accnt WHERE (accnt_id=_accntid)) THEN _prepaidAccntid := _accntid; ELSE _accntid := -1; END IF; SELECT accnt_id INTO _tmp FROM salescat, accnt WHERE ((salescat_prepaid_accnt_id=accnt_id) AND (salescat_id=_salescatid)); IF (FOUND) THEN _accntid := -1; _prepaidAccntid := _tmp; ELSE _salescatid = -1; END IF; IF(pJournalNumber IS NULL) THEN SELECT fetchJournalNumber('AR-MISC') INTO _journalNumber; ELSE _journalNumber := pJournalNumber; END IF; _glSequence := fetchGLSequence(); -- CreatelUpdate aropen for full amount IF (_aropenid IS NOT NULL) THEN UPDATE aropen SET aropen_username=getEffectiveXtUser(), aropen_journalnumber=_journalNumber, aropen_cust_id=pCustid, aropen_docnumber=pDocNumber, aropen_doctype='C', aropen_ordernumber=pOrderNumber,aropen_docdate=pDocDate, aropen_duedate=_duedate, aropen_distdate=pDocDate, aropen_terms_id=pTermsid, aropen_salesrep_id=pSalesrepid, aropen_amount=round(pAmount, 2), aropen_paid=0, aropen_commission_due=pCommissiondue, aropen_commission_paid=FALSE, aropen_applyto='', aropen_ponumber='', aropen_cobmisc_id=-1, aropen_open=TRUE, aropen_notes=pNotes, aropen_rsncode_id=pRsncodeid, aropen_salescat_id=_salescatid, aropen_accnt_id=_accntid, aropen_curr_id=pCurrId WHERE aropen_id = pId; ELSE SELECT NEXTVAL('aropen_aropen_id_seq') INTO _aropenid; INSERT INTO aropen ( aropen_id, aropen_username, aropen_journalnumber, aropen_cust_id, aropen_docnumber, aropen_doctype, aropen_ordernumber, aropen_docdate, aropen_duedate, aropen_distdate, aropen_terms_id, aropen_salesrep_id, aropen_amount, aropen_paid, aropen_commission_due, aropen_commission_paid, aropen_applyto, aropen_ponumber, aropen_cobmisc_id, aropen_open, aropen_notes, aropen_rsncode_id, aropen_salescat_id, aropen_accnt_id, aropen_curr_id ) VALUES ( _aropenid, getEffectiveXtUser(), _journalNumber, pCustid, pDocNumber, 'C', pOrderNumber, pDocDate, _duedate, pDocDate, pTermsid, pSalesrepid, round(pAmount, 2), 0, pCommissiondue, FALSE, '', '', -1, TRUE, pNotes, pRsncodeid, _salescatid, _accntid, pCurrId ); END IF; -- Credit the A/R account for the full amount SELECT insertIntoGLSeries ( _glSequence, 'A/R', 'CM', pDocNumber, _arAccntid, round(currToBase(pCurrId, pAmount, pDocDate), 2), pDocDate, (_custName || ' ' || pNotes)) INTO _test; -- Debit the Tax account for the tax amount _taxBaseValue := addTaxToGLSeries(_glSequence, 'A/R', 'CM', pDocNumber, pCurrId, pDocDate, pDocDate, 'aropentax', _aropenid, (_custName || ' ' || pNotes)); UPDATE aropentax SET taxhist_journalnumber = _journalNumber WHERE taxhist_parent_id=_aropenid; -- Debit the Prepaid account for the basis amount -- Note, _taxBaseValue is negative so it is added to pAmount SELECT insertIntoGLSeries ( _glSequence, 'A/R', 'CM', pDocNumber, _prepaidAccntid, round(currToBase(pCurrId, pAmount * -1, pDocDate) + _taxBaseValue * -1, 2), pDocDate, (_custName || ' ' || pNotes)) INTO _test; -- Commit the GLSeries; SELECT postGLSeries(_glSequence, _journalNumber) INTO _test; IF (_test < 0) THEN DELETE FROM aropen WHERE (aropen_id=_aropenid); PERFORM deleteGLSeries(_glSequence); RAISE EXCEPTION 'postGLSeries commit failed with %', _test; END IF; -- Record Sales History INSERT INTO cohist ( cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_misc_type, cohist_misc_descrip, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_curr_id, cohist_sequence, cohist_cohead_ccpay_id) VALUES (CASE WHEN pCustid < 0 THEN NULL ELSE pCustid END, -1, -1, 'M', 'A/R Misc Credit Memo', pDocDate, '', pOrderNumber, '', pDocDate, 'C', pDocNumber, pDocDate, 1, (pAmount + _taxBaseValue) * -1, 0, -- taxBaseValue is negative, so we add CASE WHEN pSalesrepid < 0 THEN NULL ELSE pSalesrepid END, (pCommissiondue * -1.0), FALSE, pCurrId, _glSequence, pCoCcpayId) RETURNING cohist_id INTO _cohistid; INSERT INTO cohisttax ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM aropentax WHERE (taxhist_parent_id=_aropenid); RETURN _aropenid; END; $$; rDROP FUNCTION public.createarcreditmemo(pid integer, pcustid integer, pdocnumber text, pordernumber text, pdocdate date, pamount numeric, pnotes text, prsncodeid integer, psalescatid integer, paccntid integer, pduedate date, ptermsid integer, psalesrepid integer, pcommissiondue numeric, pjournalnumber integer, pcurrid integer, paraccntid integer, pcoccpayid integer); publicadminfalse846231087125578181createardebitmemo(integer, integer, integer, text, text, date, numeric, text, integer, integer, integer, date, integer, integer, numeric, integer)FUNCTIONGCREATE FUNCTION createardebitmemo(integer, integer, integer, text, text, date, numeric, text, integer, integer, integer, date, integer, integer, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pId ALIAS FOR $1; pCustid ALIAS FOR $2; pJournalNumber ALIAS FOR $3; pDocNumber ALIAS FOR $4; pOrderNumber ALIAS FOR $5; pDocDate ALIAS FOR $6; pAmount ALIAS FOR $7; pNotes ALIAS FOR $8; pRsncodeid ALIAS FOR $9; pSalescatid ALIAS FOR $10; pAccntid ALIAS FOR $11; pDueDate ALIAS FOR $12; pTermsid ALIAS FOR $13; pSalesrepid ALIAS FOR $14; pCommissiondue ALIAS FOR $15; pCurrId ALIAS FOR $16; _custName TEXT; _journalNumber INTEGER; _arAccntid INTEGER; _prepaidAccntid INTEGER; _salescatid INTEGER; _accntid INTEGER; _glSequence INTEGER; _aropenid INTEGER; _cohistid INTEGER; _tmp INTEGER; _test INTEGER; _taxBaseValue NUMERIC; BEGIN _aropenid=pId; IF (pAmount <= 0) THEN RETURN 0; END IF; SELECT findARAccount(pCustid) INTO _arAccntid; SELECT findPrepaidAccount(pCustid) INTO _prepaidAccntid; _accntid := pAccntid; _salescatid := pSalescatid; SELECT cust_name INTO _custName FROM custinfo WHERE (cust_id=pCustid); PERFORM accnt_id FROM accnt WHERE (accnt_id=_accntid); IF (FOUND) THEN _prepaidAccntid := _accntid; ELSE _accntid := -1; END IF; SELECT accnt_id INTO _tmp FROM salescat, accnt WHERE ((salescat_prepaid_accnt_id=accnt_id) AND (salescat_id=_salescatid)); IF (FOUND) THEN _accntid := -1; _prepaidAccntid := _tmp; ELSE _salescatid = -1; END IF; IF (pJournalNumber IS NULL) THEN _journalNumber := fetchJournalNumber('AR-MISC'); ELSE _journalNumber := pJournalNumber; END IF; SELECT fetchGLSequence() INTO _glSequence; -- CreatelUpdate aropen for full amount IF (_aropenid IS NOT NULL) THEN UPDATE aropen SET aropen_username=getEffectiveXtUser(), aropen_journalnumber=_journalNumber, aropen_cust_id=pCustid, aropen_docnumber=pDocNumber, aropen_doctype='D', aropen_ordernumber=pOrderNumber,aropen_docdate=pDocDate, aropen_duedate=pDueDate, aropen_distdate=pDocDate, aropen_terms_id=pTermsid, aropen_salesrep_id=pSalesrepid, aropen_amount=round(pAmount, 2), aropen_paid=0, aropen_commission_due=pCommissiondue, aropen_commission_paid=FALSE, aropen_applyto='', aropen_ponumber='', aropen_cobmisc_id=-1, aropen_open=TRUE, aropen_notes=pNotes, aropen_rsncode_id=pRsncodeid, aropen_salescat_id=_salescatid, aropen_accnt_id=_accntid, aropen_curr_id=pCurrId WHERE aropen_id = pId; ELSE SELECT NEXTVAL('aropen_aropen_id_seq') INTO _aropenid; INSERT INTO aropen ( aropen_id, aropen_username, aropen_journalnumber, aropen_cust_id, aropen_docnumber, aropen_doctype, aropen_ordernumber, aropen_docdate, aropen_duedate, aropen_distdate, aropen_terms_id, aropen_salesrep_id, aropen_amount, aropen_paid, aropen_commission_due, aropen_commission_paid, aropen_applyto, aropen_ponumber, aropen_cobmisc_id, aropen_open, aropen_notes, aropen_rsncode_id, aropen_salescat_id, aropen_accnt_id, aropen_curr_id ) VALUES ( _aropenid, getEffectiveXtUser(), _journalNumber, pCustid, pDocNumber, 'D', pOrderNumber, pDocDate, pDueDate, pDocDate, pTermsid, pSalesrepid, round(pAmount, 2), 0, pCommissiondue, FALSE, '', '', -1, TRUE, pNotes, pRsncodeid, _salescatid, _accntid, pCurrId ); END IF; -- Debit the A/R account for the full amount SELECT insertIntoGLSeries ( _glSequence, 'A/R', 'DM', pDocNumber, _arAccntid, round(currToBase(pCurrId, pAmount, pDocDate) * -1, 2), pDocDate, (_custName || ' ' || pNotes)) INTO _test; -- Credit the Tax account for the tax amount _taxBaseValue := addTaxToGLSeries(_glSequence, 'A/R', 'DM', pDocNumber, pCurrId, pDocDate, pDocDate, 'aropentax', _aropenid, (_custName || ' ' || pNotes)); UPDATE aropentax SET taxhist_journalnumber = _journalNumber WHERE taxhist_parent_id=_aropenid; -- Credit the Prepaid account for the basis amount SELECT insertIntoGLSeries ( _glSequence, 'A/R', 'DM', pDocNumber, _prepaidAccntid, round(currToBase(pCurrId, (pAmount), pDocDate), 2) - _taxBaseValue, pDocDate, (_custName || ' ' || pNotes)) INTO _test; -- Commit the GLSeries; SELECT postGLSeries(_glSequence, _journalNumber) INTO _test; IF (_test < 0) THEN DELETE FROM aropen WHERE (aropen_id=_aropenid); PERFORM deleteGLSeries(_glSequence); RAISE EXCEPTION 'postGLSeries commit failed with %', _test; END IF; -- Record Sales History SELECT nextval('cohist_cohist_id_seq') INTO _cohistid; INSERT INTO cohist ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_misc_type, cohist_misc_descrip, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_curr_id, cohist_sequence ) VALUES ( _cohistid, pCustid, -1, -1, 'M', 'A/R Misc Debit Memo', pDocDate, '', '', '', pDocDate, 'D', pDocNumber, pDocDate, 1, (pAmount - _taxBaseValue), 0, pSalesrepid, pCommissiondue, FALSE, pCurrId, _glSequence ); INSERT INTO cohisttax ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM aropentax WHERE (taxhist_parent_id=_aropenid); RETURN _aropenid; END; $_$; DROP FUNCTION public.createardebitmemo(integer, integer, integer, text, text, date, numeric, text, integer, integer, integer, date, integer, integer, numeric, integer); publicadminfalse46238125578183createbillingheader(integer)FUNCTIONCREATE FUNCTION createbillingheader(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; _cobmiscid INTEGER; _cohead cohead%ROWTYPE; _miscApplied NUMERIC := 0.0; _freight NUMERIC; _freighttypeid INTEGER; _invcDate DATE; _schedDate DATE; _shipDate DATE; _shipVia TEXT; _tax NUMERIC; BEGIN -- Fetch cohead SELECT * INTO _cohead FROM cohead WHERE (cohead_id=pSoheadid); -- Check for an existing cobmisc SELECT cobmisc_id INTO _cobmiscid FROM cobmisc WHERE ( (NOT cobmisc_posted) AND (cobmisc_cohead_id=pSoheadid) ); IF (FOUND) THEN -- Find a Shipping-Entered freight charge SELECT SUM(currToCurr(shiphead_freight_curr_id, _cohead.cohead_curr_id, shiphead_freight, CURRENT_DATE)) INTO _freight FROM ( SELECT shiphead_id, shiphead_freight_curr_id, shiphead_freight FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id AND NOT shipitem_invoiced) WHERE ((shiphead_order_type='SO') AND (shiphead_order_id=pSoheadid)) GROUP BY shiphead_id, shiphead_freight_curr_id, shiphead_freight) AS data; IF (_freight IS NOT NULL) THEN UPDATE cobmisc SET cobmisc_freight = _freight WHERE (cobmisc_id=_cobmiscid); END IF; RETURN _cobmiscid; END IF; -- Find misc charges that have already been applied for the S/O SELECT COALESCE(SUM(cobmisc_misc), 0.0) INTO _miscApplied FROM cobmisc WHERE (cobmisc_cohead_id=pSoheadid); SELECT NEXTVAL('cobmisc_cobmisc_id_seq') INTO _cobmiscid; -- Check for a valid shipdate SELECT MIN(shiphead_shipdate) INTO _shipDate FROM shiphead, shipitem WHERE ( (shipitem_shiphead_id=shiphead_id) AND (NOT shipitem_invoiced) AND (shiphead_shipped) AND (shiphead_order_type='SO') AND (shiphead_order_id=pSoheadid) ); -- Schema shouldn't allow, but we'll try for now IF (_shipDate IS NULL) THEN SELECT MAX(shipitem_shipdate) INTO _shipDate FROM shipitem, shiphead WHERE ( (shipitem_shiphead_id=shiphead_id) AND (shiphead_order_type='SO') AND (shiphead_order_id=pSoheadid) ); -- How about a transaction date IF (_shipDate IS NULL) THEN SELECT COALESCE(MAX(shipitem_transdate), CURRENT_DATE) INTO _shipDate FROM shipitem, shiphead WHERE ((shipitem_shiphead_id=shiphead_id) AND (shiphead_order_type='SO') AND (shiphead_order_id=pSoheadid) ); END IF; END IF; -- Get the earliest schedule date for this order. SELECT MIN(coitem_scheddate) INTO _schedDate FROM coitem WHERE ((coitem_status <> 'X') AND (coitem_cohead_id=pSoheadid)); IF (_schedDate IS NULL) THEN _schedDate := _shipDate; END IF; -- Find a Shipping-Entered freight charge SELECT SUM(currToCurr(shiphead_freight_curr_id, _cohead.cohead_curr_id, shiphead_freight, CURRENT_DATE)), shiphead_shipvia INTO _freight, _shipVia FROM ( SELECT shiphead_id, shiphead_freight_curr_id, shiphead_freight, shiphead_shipvia FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id AND NOT shipitem_invoiced) WHERE ((shiphead_order_type='SO') AND (shiphead_order_id=pSoheadid)) GROUP BY shiphead_id, shiphead_freight_curr_id, shiphead_freight, shiphead_shipvia) AS data GROUP BY shiphead_shipvia; -- Nope, use the cohead freight charge IF (_freight IS NULL) THEN _freight := _cohead.cohead_freight; END IF; -- Finally, look for a Shipping-Entered Ship Via SELECT shiphead_shipvia INTO _shipVia FROM shiphead, shipitem WHERE ( (shipitem_shiphead_id=shiphead_id) AND (NOT shipitem_invoiced) AND (shiphead_order_type='SO') AND (shiphead_order_id=pSoheadid) ) LIMIT 1; IF (NOT FOUND) THEN _shipVia := _cohead.cohead_shipvia; END IF; --Determine any tax SELECT getFreightTaxTypeId() INTO _freighttypeid; SELECT SUM(COALESCE(taxdetail_tax, 0.00)) INTO _tax FROM calculatetaxdetail(_cohead.cohead_taxzone_id, _freighttypeid, _cohead.cohead_orderdate,_cohead.cohead_curr_id, _freight); -- Determine if we are using the _shipDate or _schedDate or current_date for the _invcDate IF( fetchMetricText('InvoiceDateSource')='scheddate') THEN _invcDate := _schedDate; ELSIF( fetchMetricText('InvoiceDateSource')='shipdate') THEN _invcDate := _shipDate; ELSE _invcDate := current_date; END IF; INSERT INTO cobmisc ( cobmisc_id, cobmisc_cohead_id, cobmisc_shipvia, cobmisc_freight, cobmisc_misc, cobmisc_payment ,cobmisc_notes,cobmisc_shipdate ,cobmisc_invcdate,cobmisc_posted ,cobmisc_misc_accnt_id ,cobmisc_misc_descrip,cobmisc_closeorder,cobmisc_curr_id ,cobmisc_taxtype_id,cobmisc_taxzone_id ) SELECT _cobmiscid,_cohead.cohead_id,_shipVia,_freight, CASE WHEN (_cohead.cohead_misc - _miscApplied = 0.0) THEN 0.0 ELSE (_cohead.cohead_misc - _miscApplied) END,0, _cohead.cohead_ordercomments,_shipDate,_invcDate,FALSE,_cohead.cohead_misc_accnt_id, _cohead.cohead_misc_descrip,NOT(cust_backorder),_cohead.cohead_curr_id, _cohead.cohead_taxtype_id,_cohead.cohead_taxzone_id FROM custinfo WHERE (cust_id=_cohead.cohead_cust_id); RETURN _cobmiscid; END; $_$; 3DROP FUNCTION public.createbillingheader(integer); publicadminfalse84623125578185createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text)FUNCTIONCREATE FUNCTION createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pBomitemid ALIAS FOR $1; pParentItemid ALIAS FOR $2; pComponentItemid ALIAS FOR $3; pSeqNumber ALIAS FOR $4; pIssueMethod ALIAS FOR $5; pUomId ALIAS FOR $6; pQtyPer ALIAS FOR $7; pScrap ALIAS FOR $8; pEffective ALIAS FOR $9; pExpires ALIAS FOR $10; pCreateWo ALIAS FOR $11; pBOOItemseqid ALIAS FOR $12; pSchedAtWooper ALIAS FOR $13; pECN ALIAS FOR $14; pSubType ALIAS FOR $15; pRevisionid ALIAS FOR $16; pCharId ALIAS FOR $17; pCharVal ALIAS FOR $18; _bomworksetid INTEGER; _temp INTEGER; _bomitemid INTEGER; BEGIN SELECT createBOMItem( pBomitemid, pParentItemid, pComponentItemid, pSeqNumber, pIssueMethod, pUomId, pQtyPer, pScrap, pEffective, pExpires, pCreateWo, pBOOItemseqid, pSchedAtWooper, pECN, pSubType, pRevisionid, pCharId, pCharVal, NULL, NULL ) INTO _bomitemid; RETURN _bomitemid; END; $_$; DROP FUNCTION public.createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text); publicadminfalse84623125578186createbomitem(integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text)FUNCTIONCREATE FUNCTION createbomitem(integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pBomitemid ALIAS FOR $1; pParentItemid ALIAS FOR $2; pComponentItemid ALIAS FOR $3; pIssueMethod ALIAS FOR $4; pUomId ALIAS FOR $5; pQtyPer ALIAS FOR $6; pScrap ALIAS FOR $7; pEffective ALIAS FOR $8; pExpires ALIAS FOR $9; pCreateWo ALIAS FOR $10; pBOOItemseqid ALIAS FOR $11; pSchedAtWooper ALIAS FOR $12; pECN ALIAS FOR $13; pSubType ALIAS FOR $14; pRevisionid ALIAS FOR $15; pCharId ALIAS FOR $16; pCharVal ALIAS FOR $17; pNotes ALIAS FOR $18; pRef ALIAS FOR $19; _seqNumber INTEGER; _bomitemid INTEGER; BEGIN -- Grab the next Sequence Number, if any SELECT MAX(bomitem_seqnumber) INTO _seqNumber FROM bomitem(pParentItemid,pRevisionid); IF (_seqNumber IS NOT NULL) THEN _seqNumber := (_seqNumber + 10); ELSE _seqNumber := 10; END IF; SELECT createBOMItem( pBomitemid, pParentItemid, pComponentItemid, _seqNumber, pIssueMethod, pUomId, pQtyPer, pScrap, pEffective, pExpires, pCreateWo, pBOOItemseqid, pSchedAtWooper, pECN, pSubType, pRevisionid, pCharId, pCharVal, pNotes, pRef ) INTO _bomitemid; RETURN _bomitemid; END; $_$; DROP FUNCTION public.createbomitem(integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text); publicadminfalse84623125578187createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text)FUNCTIONSCREATE FUNCTION createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBomitemid ALIAS FOR $1; pParentItemid ALIAS FOR $2; pComponentItemid ALIAS FOR $3; pSeqNumber ALIAS FOR $4; pIssueMethod ALIAS FOR $5; pUomId ALIAS FOR $6; pQtyFxd ALIAS FOR $7; pQtyPer ALIAS FOR $8; pScrap ALIAS FOR $9; pEffective ALIAS FOR $10; pExpires ALIAS FOR $11; pCreateWo ALIAS FOR $12; pBOOItemseqid ALIAS FOR $13; pSchedAtWooper ALIAS FOR $14; pECN ALIAS FOR $15; pSubType ALIAS FOR $16; pRevisionid ALIAS FOR $17; pCharId ALIAS FOR $18; pCharVal ALIAS FOR $19; _bomworksetid INTEGER; _temp INTEGER; _bomitemid INTEGER; BEGIN SELECT createBOMItem( pBomitemid, pParentItemid, pComponentItemid, pSeqNumber, pIssueMethod, pUomId, pQtyFxd, pQtyPer, pScrap, pEffective, pExpires, pCreateWo, pBOOItemseqid, pSchedAtWooper, pECN, pSubType, pRevisionid, pCharId, pCharVal, NULL, NULL ) INTO _bomitemid; RETURN _bomitemid; END; $_$; DROP FUNCTION public.createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text); publicadminfalse46238125578188createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text)FUNCTIONCREATE FUNCTION createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pBomitemid ALIAS FOR $1; pParentItemid ALIAS FOR $2; pComponentItemid ALIAS FOR $3; pSeqNumber ALIAS FOR $4; pIssueMethod ALIAS FOR $5; pUomId ALIAS FOR $6; pQtyPer ALIAS FOR $7; pScrap ALIAS FOR $8; pEffective ALIAS FOR $9; pExpires ALIAS FOR $10; pCreateWo ALIAS FOR $11; pBOOItemseqid ALIAS FOR $12; pSchedAtWooper ALIAS FOR $13; pECN ALIAS FOR $14; pSubType ALIAS FOR $15; pRevisionid ALIAS FOR $16; pCharId ALIAS FOR $17; pCharVal ALIAS FOR $18; pNotes ALIAS FOR $19; pRef ALIAS FOR $20; _bomworksetid INTEGER; _temp INTEGER; BEGIN -- Make sure that the parent and component are not the same IF (pParentItemid = pComponentItemid) THEN RETURN -1; END IF; -- Make sure that the parent is not used in the component at some level IF ( SELECT (item_type IN ('M', 'F')) FROM item WHERE (item_id=pComponentItemid) ) THEN SELECT indentedWhereUsed(pParentItemid) INTO _bomworksetid; SELECT bomwork_id INTO _temp FROM bomwork WHERE ( (bomwork_set_id=_bomworksetid) AND (bomwork_item_id=pComponentItemid) ) LIMIT 1; IF (FOUND) THEN PERFORM deleteBOMWorkset(_bomworksetid); RETURN -2; END IF; END IF; PERFORM deleteBOMWorkset(_bomworksetid); -- Create the BOM Item INSERT INTO bomitem ( bomitem_id, bomitem_parent_item_id, bomitem_item_id, bomitem_seqnumber, bomitem_issuemethod, bomitem_uom_id, bomitem_qtyper, bomitem_scrap, bomitem_effective, bomitem_expires, bomitem_createwo, bomitem_booitem_seq_id, bomitem_schedatwooper, bomitem_ecn, bomitem_subtype, bomitem_moddate, bomitem_rev_id, bomitem_char_id, bomitem_value, bomitem_notes, bomitem_ref ) VALUES ( pBomitemid, pParentItemid, pComponentItemid, pSeqNumber, pIssueMethod, pUomId, pQtyPer, pScrap, pEffective, pExpires, pCreateWo, pBOOItemseqid, COALESCE(pSchedAtWooper, FALSE), pECN, pSubType, CURRENT_DATE, pRevisionid, pCharId,pCharVal,pNotes, pRef ); RETURN pBomitemid; END; $_$; DROP FUNCTION public.createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text); publicadminfalse84623125578189createbomitem(integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text)FUNCTIONHCREATE FUNCTION createbomitem(integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBomitemid ALIAS FOR $1; pParentItemid ALIAS FOR $2; pComponentItemid ALIAS FOR $3; pIssueMethod ALIAS FOR $4; pUomId ALIAS FOR $5; pQtyFxd ALIAS FOR $6; pQtyPer ALIAS FOR $7; pScrap ALIAS FOR $8; pEffective ALIAS FOR $9; pExpires ALIAS FOR $10; pCreateWo ALIAS FOR $11; pBOOItemseqid ALIAS FOR $12; pSchedAtWooper ALIAS FOR $13; pECN ALIAS FOR $14; pSubType ALIAS FOR $15; pRevisionid ALIAS FOR $16; pCharId ALIAS FOR $17; pCharVal ALIAS FOR $18; pNotes ALIAS FOR $19; pRef ALIAS FOR $20; _seqNumber INTEGER; _bomitemid INTEGER; BEGIN -- Grab the next Sequence Number, if any SELECT MAX(bomitem_seqnumber) INTO _seqNumber FROM bomitem(pParentItemid,pRevisionid); IF (_seqNumber IS NOT NULL) THEN _seqNumber := (_seqNumber + 10); ELSE _seqNumber := 10; END IF; SELECT createBOMItem( pBomitemid, pParentItemid, pComponentItemid, _seqNumber, pIssueMethod, pUomId, pQtyFxd, pQtyPer, pScrap, pEffective, pExpires, pCreateWo, pBOOItemseqid, pSchedAtWooper, pECN, pSubType, pRevisionid, pCharId, pCharVal, pNotes, pRef ) INTO _bomitemid; RETURN _bomitemid; END; $_$; DROP FUNCTION public.createbomitem(integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text); publicadminfalse84623125578190createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text)FUNCTION CREATE FUNCTION createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBomitemid ALIAS FOR $1; pParentItemid ALIAS FOR $2; pComponentItemid ALIAS FOR $3; pSeqNumber ALIAS FOR $4; pIssueMethod ALIAS FOR $5; pUomId ALIAS FOR $6; pQtyFxd ALIAS FOR $7; pQtyPer ALIAS FOR $8; pScrap ALIAS FOR $9; pEffective ALIAS FOR $10; pExpires ALIAS FOR $11; pCreateWo ALIAS FOR $12; pBOOItemseqid ALIAS FOR $13; pSchedAtWooper ALIAS FOR $14; pECN ALIAS FOR $15; pSubType ALIAS FOR $16; pRevisionid ALIAS FOR $17; pCharId ALIAS FOR $18; pCharVal ALIAS FOR $19; pNotes ALIAS FOR $20; pRef ALIAS FOR $21; _bomworksetid INTEGER; _temp INTEGER; BEGIN -- Make sure that the parent and component are not the same IF (pParentItemid = pComponentItemid) THEN RETURN -1; END IF; -- Make sure that the parent is not used in the component at some level SELECT indentedWhereUsed(pParentItemid) INTO _bomworksetid; SELECT bomwork_id INTO _temp FROM bomwork WHERE ( (bomwork_set_id=_bomworksetid) AND (bomwork_item_id=pComponentItemid) ) LIMIT 1; IF (FOUND) THEN PERFORM deleteBOMWorkset(_bomworksetid); RETURN -2; END IF; PERFORM deleteBOMWorkset(_bomworksetid); -- Create the BOM Item INSERT INTO bomitem ( bomitem_id, bomitem_parent_item_id, bomitem_item_id, bomitem_seqnumber, bomitem_issuemethod, bomitem_uom_id, bomitem_qtyfxd, bomitem_qtyper, bomitem_scrap, bomitem_effective, bomitem_expires, bomitem_createwo, bomitem_booitem_seq_id, bomitem_schedatwooper, bomitem_ecn, bomitem_subtype, bomitem_moddate, bomitem_rev_id, bomitem_char_id, bomitem_value, bomitem_notes, bomitem_ref ) VALUES ( pBomitemid, pParentItemid, pComponentItemid, pSeqNumber, pIssueMethod, pUomId, pQtyFxd, pQtyPer, pScrap, pEffective, pExpires, pCreateWo, pBOOItemseqid, COALESCE(pSchedAtWooper, FALSE), pECN, pSubType, CURRENT_DATE, pRevisionid, pCharId,pCharVal,pNotes, pRef ); RETURN pBomitemid; END; $_$; DROP FUNCTION public.createbomitem(integer, integer, integer, integer, character, integer, numeric, numeric, numeric, date, date, boolean, integer, boolean, text, character, integer, integer, text, text, text); publicadminfalse84623125578191bcreatecheck(integer, text, integer, date, numeric, integer, integer, integer, text, text, boolean)FUNCTION#CREATE FUNCTION createcheck(integer, text, integer, date, numeric, integer, integer, integer, text, text, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBankaccntid ALIAS FOR $1; pRecipType ALIAS FOR $2; pRecipId ALIAS FOR $3; pCheckDate ALIAS FOR $4; pAmount ALIAS FOR $5; pCurrid ALIAS FOR $6; pExpcatid ALIAS FOR $7; _journalNumber INTEGER := $8; pFor ALIAS FOR $9; pNotes ALIAS FOR $10; pMisc ALIAS FOR $11; _checkid INTEGER; BEGIN SELECT createCheck(pBankaccntid,pRecipType,pRecipId,pCheckDate,pAmount,pCurrid,pExpcatid,_journalNumber,pFor,pNotes,pMisc,NULL) INTO _checkid; RETURN _checkid; END; $_$; yDROP FUNCTION public.createcheck(integer, text, integer, date, numeric, integer, integer, integer, text, text, boolean); publicadminfalse84623125578192kcreatecheck(integer, text, integer, date, numeric, integer, integer, integer, text, text, boolean, integer)FUNCTIONqCREATE FUNCTION createcheck(integer, text, integer, date, numeric, integer, integer, integer, text, text, boolean, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBankaccntid ALIAS FOR $1; pRecipType ALIAS FOR $2; pRecipId ALIAS FOR $3; pCheckDate ALIAS FOR $4; pAmount ALIAS FOR $5; pCurrid ALIAS FOR $6; pExpcatid ALIAS FOR $7; _journalNumber INTEGER := $8; pFor ALIAS FOR $9; pNotes ALIAS FOR $10; pMisc ALIAS FOR $11; pAropenid ALIAS FOR $12; _checkid INTEGER; _checknumber INTEGER := -1; _check_curr_rate NUMERIC; _bankaccnt_currid INTEGER; _bankaccnt_prnt_check BOOLEAN; BEGIN SELECT bankaccnt_curr_id,currRate(bankaccnt_curr_id,pCheckDate), bankaccnt_prnt_check INTO _bankaccnt_currid, _check_curr_rate, _bankaccnt_prnt_check FROM bankaccnt WHERE bankaccnt_id = pBankaccntid; IF (NOT FOUND) THEN RETURN -1; END IF; IF (pRecipType NOT IN ('C', 'T', 'V')) THEN RETURN -2; END IF; IF (pCheckDate IS NULL) THEN RETURN -3; END IF; IF (pAmount <= 0) THEN RETURN -4; END IF; IF (pCurrid IS NULL OR NOT EXISTS(SELECT * FROM curr_symbol WHERE (curr_id=pCurrid))) THEN RETURN -5; END IF; IF (pExpcatid IS NOT NULL AND NOT EXISTS(SELECT * FROM expcat WHERE (expcat_id=pExpcatid))) THEN RETURN -6; END IF; -- Do not assign Journal Number until check is posted -- if (_journalNumber IS NULL) THEN -- _journalNumber := fetchJournalNumber('AP-CK'); -- END IF; IF (NOT _bankaccnt_prnt_check) THEN SELECT fetchNextCheckNumber(pBankaccntid) INTO _checknumber; END IF; _checkid := NEXTVAL('checkhead_checkhead_id_seq'); INSERT INTO checkhead ( checkhead_id, checkhead_recip_type, checkhead_recip_id, checkhead_bankaccnt_id, checkhead_number, checkhead_amount, checkhead_checkdate, checkhead_misc, checkhead_expcat_id, checkhead_journalnumber, checkhead_for, checkhead_notes, checkhead_curr_id ) VALUES ( _checkid, pRecipType, pRecipId, pBankaccntid, _checknumber, currToCurr(pCurrid, _bankaccnt_currid, pAmount, pCheckDate), pCheckDate, COALESCE(pMisc, FALSE), pExpcatid, _journalNumber, pFor, pNotes, _bankaccnt_currid ); IF (pAropenid IS NOT NULL AND fetchmetricbool('EnableReturnAuth')) THEN INSERT INTO checkitem (checkitem_checkhead_id,checkitem_amount,checkitem_discount,checkitem_ponumber, checkitem_aropen_id,checkitem_docdate,checkitem_curr_id,checkitem_cmnumber, checkitem_ranumber, checkitem_curr_rate) SELECT _checkid, currToCurr(checkhead_curr_id, aropen_curr_id, pAmount, checkhead_checkdate), 0,cmhead_custponumber,pAropenid,aropen_docdate,aropen_curr_id,cmhead_number,rahead_number, 1 / (_check_curr_rate / aropen_curr_rate) FROM checkhead, aropen LEFT OUTER JOIN cmhead ON (aropen_docnumber=cmhead_number) LEFT OUTER JOIN rahead ON (cmhead_rahead_id=rahead_id) WHERE ((aropen_id=pAropenid) AND (checkhead_id=_checkid)); ELSIF (pAropenid IS NOT NULL) THEN INSERT INTO checkitem (checkitem_checkhead_id,checkitem_amount,checkitem_discount,checkitem_ponumber, checkitem_aropen_id,checkitem_docdate,checkitem_curr_id,checkitem_cmnumber, checkitem_ranumber, checkitem_curr_rate) SELECT _checkid,currToCurr(checkhead_curr_id, aropen_curr_id, pAmount, checkhead_checkdate), 0,cmhead_custponumber,pAropenid,aropen_docdate,aropen_curr_id,cmhead_number,NULL, 1 / (_check_curr_rate / aropen_curr_rate) FROM checkhead, aropen LEFT OUTER JOIN cmhead ON (aropen_docnumber=cmhead_number) WHERE ((aropen_id=pAropenid) AND (checkhead_id=_checkid)); END IF; RETURN _checkid; END; $_$; DROP FUNCTION public.createcheck(integer, text, integer, date, numeric, integer, integer, integer, text, text, boolean, integer); publicadminfalse46238125578193createchecks(integer, date)FUNCTION CREATE FUNCTION createchecks(pbankaccntid integer, pcheckdate date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _v RECORD; _r RECORD; _c RECORD; _checkid INTEGER; _counter INTEGER := 0; _check_curr_id INTEGER; _check_curr_rate NUMERIC; BEGIN SELECT bankaccnt_curr_id, currRate(bankaccnt_curr_id, pCheckDate) INTO _check_curr_id, _check_curr_rate FROM bankaccnt WHERE ( bankaccnt_id = pBankaccntid ); FOR _v IN SELECT DISTINCT vend_id, vend_number, vend_name FROM apselect JOIN apopen ON (apselect_apopen_id=apopen_id) JOIN vendinfo ON (apopen_vend_id=vend_id) WHERE ((apselect_bankaccnt_id=pBankaccntid) AND (apselect_date <= pCheckDate)) LOOP -- if we owe this vendor anything (we might not) then create a check -- allow $0 checks IF ((SELECT SUM(CASE apopen_doctype WHEN 'C' THEN (apselect_amount * -1.0) ELSE apselect_amount END * _check_curr_rate / apopen_curr_rate) FROM apselect JOIN apopen ON (apopen_id=apselect_apopen_id) WHERE ((apopen_vend_id=_v.vend_id) AND (apselect_bankaccnt_id=pBankaccntid)) ) >= 0) THEN -- 0.01 is a temporary amount; we''ll update the check amount later _checkid := createCheck(pBankaccntid, 'V', _v.vend_id, pCheckDate, 0.01, _check_curr_id, NULL, NULL, '', '', FALSE); FOR _r IN SELECT apopen_id, apselect_id, apopen_docnumber, apopen_invcnumber, apopen_ponumber, apopen_docdate, apselect_curr_id, apselect_amount, apselect_discount FROM apselect, apopen WHERE ( (apselect_apopen_id=apopen_id) AND (apopen_vend_id=_v.vend_id) AND (apselect_bankaccnt_id=pBankaccntid) ) LOOP INSERT INTO checkitem ( checkitem_checkhead_id, checkitem_apopen_id, checkitem_vouchernumber, checkitem_invcnumber, checkitem_ponumber, checkitem_amount, checkitem_discount, checkitem_docdate, checkitem_curr_id, checkitem_curr_rate ) VALUES ( _checkid, _r.apopen_id, _r.apopen_docnumber, _r.apopen_invcnumber, _r.apopen_ponumber, _r.apselect_amount, _r.apselect_discount, _r.apopen_docdate, _r.apselect_curr_id, 1 / (_check_curr_rate / currRate(_r.apselect_curr_id, pCheckdate)) ); DELETE FROM apselect WHERE (apselect_id=_r.apselect_id); END LOOP; -- one check can pay for purchases on multiple dates in multiple currencies UPDATE checkhead SET checkhead_amount = (SELECT SUM(CASE WHEN (apopen_doctype='C') THEN checkitem_amount / checkitem_curr_rate * -1.0 ELSE checkitem_amount / checkitem_curr_rate END) FROM checkitem LEFT OUTER JOIN apopen ON (apopen_id=checkitem_apopen_id) WHERE (checkitem_checkhead_id=checkhead_id)) WHERE (checkhead_id=_checkid); _counter := (_counter + 1); END IF; END LOOP; RETURN _counter; END; $_$; JDROP FUNCTION public.createchecks(pbankaccntid integer, pcheckdate date); publicadminfalse46238125578194/createcounttag(integer, text, boolean, boolean)FUNCTIONCREATE FUNCTION createcounttag(integer, text, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pComments ALIAS FOR $2; pPriority ALIAS FOR $3; pFreeze ALIAS FOR $4; BEGIN RETURN createCountTag(pItemsiteid, pComments, pPriority, pFreeze, NULL); END; $_$; FDROP FUNCTION public.createcounttag(integer, text, boolean, boolean); publicadminfalse846231255781958createcounttag(integer, text, boolean, boolean, integer)FUNCTIONCREATE FUNCTION createcounttag(integer, text, boolean, boolean, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pComments ALIAS FOR $2; pPriority ALIAS FOR $3; pFreeze ALIAS FOR $4; pLocationid ALIAS FOR $5; _invcntid INTEGER; _whs RECORD; _type CHARACTER; _controlmethod CHARACTER; BEGIN SELECT item_type, itemsite_controlmethod INTO _type, _controlmethod FROM itemsite, item WHERE ((itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid)); IF (NOT FOUND OR _type IN ('F', 'R', 'L','J') OR _controlmethod = 'N') THEN RETURN 0; -- We simply do not do these item types. END IF; -- Test for existing tags IF (pLocationid IS NULL) THEN SELECT invcnt_id INTO _invcntid FROM invcnt WHERE ((NOT invcnt_posted) AND (invcnt_location_id IS NULL) AND (invcnt_itemsite_id=pItemsiteid)); ELSE SELECT invcnt_id INTO _invcntid FROM invcnt WHERE ((NOT invcnt_posted) AND (invcnt_itemsite_id=pItemsiteid) AND (invcnt_location_id=pLocationid)); END IF; IF (NOT FOUND) THEN SELECT NEXTVAL('invcnt_invcnt_id_seq') INTO _invcntid; SELECT whsinfo.* INTO _whs FROM whsinfo, itemsite WHERE ((warehous_id=itemsite_warehous_id) AND (itemsite_id=pItemsiteid)); INSERT INTO invcnt ( invcnt_id, invcnt_itemsite_id, invcnt_tagdate, invcnt_tagnumber, invcnt_tag_username, invcnt_posted, invcnt_priority, invcnt_comments, invcnt_location_id ) VALUES ( _invcntid, pItemsiteid, CURRENT_TIMESTAMP, (_whs.warehous_counttag_prefix || _whs.warehous_counttag_number::TEXT), getEffectiveXtUser(), FALSE, pPriority, pComments, pLocationid ); UPDATE whsinfo SET warehous_counttag_number=(warehous_counttag_number + 1) WHERE (warehous_id=_whs.warehous_id); IF (pFreeze) THEN UPDATE itemsite SET itemsite_freeze=TRUE WHERE (itemsite_id=pItemsiteid); END IF; END IF; RETURN _invcntid; END; $_$; ODROP FUNCTION public.createcounttag(integer, text, boolean, boolean, integer); publicadminfalse46238125578196createcustomer(integer)FUNCTIONCREATE FUNCTION createcustomer(integer) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pcrmacctId ALIAS FOR $1; _custId INTEGER := 0; BEGIN IF (pcrmacctId < 0 OR pcrmacctId IS NULL) THEN RETURN -1; END IF; SELECT crmacct_cust_id INTO _custId FROM crmacct WHERE crmacct_id = pcrmacctId; IF (_custId IS NOT NULL AND _custId <= 0) THEN RETURN -2; END IF; INSERT INTO _customer (active, customer_number, customer_name) SELECT crmacct_active, crmacct_number, crmacct_name FROM crmacct WHERE crmacct_id = pcrmacctId; _custId := CURRVAL('cust_cust_id_seq'); UPDATE crmacct SET crmacct_prospect_id = NULL, crmacct_cust_id = _custId WHERE crmacct_id = pcrmacctId; RETURN _custId; END; $_$; .DROP FUNCTION public.createcustomer(integer); publicadminfalse84623125578197Fcreatecyclecountsbywarehouse(integer, integer, text, boolean, boolean)FUNCTIONCREATE FUNCTION createcyclecountsbywarehouse(integer, integer, text, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pMaxNumber ALIAS FOR $2; pComments ALIAS FOR $3; pPriority ALIAS FOR $4; pFreeze ALIAS FOR $5; BEGIN RETURN createCycleCountsByWarehouse(pWarehousid, pMaxNumber, pComments, pPriority, pFreeze, NULL, FALSE); END; $_$; ]DROP FUNCTION public.createcyclecountsbywarehouse(integer, integer, text, boolean, boolean); publicadminfalse84623125578198Ocreatecyclecountsbywarehouse(integer, integer, integer, text, boolean, boolean)FUNCTIONMCREATE FUNCTION createcyclecountsbywarehouse(integer, integer, integer, text, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pClasscodeid ALIAS FOR $2; pMaxNumber ALIAS FOR $3; pComments ALIAS FOR $4; pPriority ALIAS FOR $5; pFreeze ALIAS FOR $6; BEGIN RETURN createCycleCountsByWarehouseByClassCode(pWarehousid, pClasscodeid, pMaxNumber, pComments, pPriority, pFreeze, NULL, FALSE); END; $_$; fDROP FUNCTION public.createcyclecountsbywarehouse(integer, integer, integer, text, boolean, boolean); publicadminfalse84623125578199Lcreatecyclecountsbywarehouse(integer, text, integer, text, boolean, boolean)FUNCTIONTCREATE FUNCTION createcyclecountsbywarehouse(integer, text, integer, text, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pClasscodePattern ALIAS FOR $2; pMaxNumber ALIAS FOR $3; pComments ALIAS FOR $4; pPriority ALIAS FOR $5; pFreeze ALIAS FOR $6; BEGIN RETURN createCycleCountsByWarehouseByClassCode(pWarehousid, pClasscodePattern, pMaxNumber, pComments, pPriority, pFreeze, NULL, FALSE); END; $_$; cDROP FUNCTION public.createcyclecountsbywarehouse(integer, text, integer, text, boolean, boolean); publicadminfalse84623125578200Xcreatecyclecountsbywarehouse(integer, integer, text, boolean, boolean, integer, boolean)FUNCTION2 CREATE FUNCTION createcyclecountsbywarehouse(integer, integer, text, boolean, boolean, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pMaxNumber ALIAS FOR $2; pComments ALIAS FOR $3; pPriority ALIAS FOR $4; pFreeze ALIAS FOR $5; pLocationid ALIAS FOR $6; pIgnoreZeroBalance ALIAS FOR $7; _itemsites RECORD; _returnVal INTEGER; BEGIN IF (pLocationid IS NULL) THEN FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, itemsite_qtyonhand FROM itemsite, item WHERE ( (itemsite_active) AND (itemsite_item_id=item_id) AND (itemsite_cyclecountfreq > 0) AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE) AND (itemsite_id NOT IN ( SELECT invcnt_itemsite_id FROM invcnt, itemsite WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_warehous_id=pWarehousid) AND (invcnt_location_id IS NULL) AND (NOT invcnt_posted) ) ) ) AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0)) AND ((pLocationid IS NULL) OR (validLocation(pLocationid, itemsite_id))) AND (itemsite_warehous_id=pWarehousid) ) ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass, item_number LIMIT pMaxNumber LOOP _returnVal := createCountTag(_itemsites.itemsite_id, pComments, pPriority, pFreeze, pLocationid); IF (_returnVal < 0) THEN RETURN _returnVal; END IF; END LOOP; ELSE FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, SUM(itemloc_qty) FROM itemsite, itemloc WHERE ( (itemsite_active) AND (itemsite_cyclecountfreq > 0) AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE) AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0)) AND (pLocationid = itemloc_location_id) AND (itemloc_itemsite_id = itemsite_id) AND (itemsite_warehous_id=pWarehousid) ) GROUP BY itemsite_id, itemsite_warehous_id, itemsite_datelastcount, itemsite_cyclecountfreq, itemsite_abcclass ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass LIMIT pMaxNumber LOOP _returnVal := createCountTag(_itemsites.itemsite_id, pComments, pPriority, pFreeze, pLocationid); IF (_returnVal < 0) THEN RETURN _returnVal; END IF; END LOOP; END IF; RETURN 0; END; $_$; oDROP FUNCTION public.createcyclecountsbywarehouse(integer, integer, text, boolean, boolean, integer, boolean); publicadminfalse46238125578201lcreatecyclecountsbywarehousebyclasscode(integer, integer, integer, text, boolean, boolean, integer, boolean)FUNCTION CREATE FUNCTION createcyclecountsbywarehousebyclasscode(integer, integer, integer, text, boolean, boolean, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pClasscodeid ALIAS FOR $2; pMaxNumber ALIAS FOR $3; pComments ALIAS FOR $4; pPriority ALIAS FOR $5; pFreeze ALIAS FOR $6; pLocationid ALIAS FOR $7; pIgnoreZeroBalance ALIAS FOR $8; _itemsites RECORD; _returnVal INTEGER; BEGIN IF (pLocationid IS NULL) THEN FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, itemsite_qtyonhand FROM itemsite, item WHERE ( (itemsite_active) AND (itemsite_item_id=item_id) AND (itemsite_cyclecountfreq > 0) AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE) AND (itemsite_id NOT IN ( SELECT invcnt_itemsite_id FROM invcnt, itemsite WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_warehous_id=pWarehousid) AND (invcnt_location_id IS NULL) AND (NOT invcnt_posted) ) ) ) AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0)) AND ((pLocationid IS NULL) OR (validLocation(pLocationid, itemsite_id))) AND (itemsite_warehous_id=pWarehousid) AND (item_classcode_id=pClasscodeid) ) ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass, item_number LIMIT pMaxNumber LOOP _returnVal := createCountTag(_itemsites.itemsite_id, pComments, pPriority, pFreeze, pLocationid); IF (_returnVal < 0) THEN RETURN _returnVal; END IF; END LOOP; ELSE FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, SUM(itemloc_qty) FROM itemsite, item, itemloc WHERE ( (itemsite_active) AND (itemsite_item_id=item_id) AND (itemsite_cyclecountfreq > 0) AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE) AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0)) AND (pLocationid = itemloc_location_id) AND (itemloc_itemsite_id = itemsite_id) AND (itemsite_warehous_id=pWarehousid) AND (item_classcode_id=pClasscodeid) ) GROUP BY itemsite_id, itemsite_warehous_id, itemsite_datelastcount, itemsite_cyclecountfreq, itemsite_abcclass ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass LIMIT pMaxNumber LOOP _returnVal := createCountTag(_itemsites.itemsite_id, pComments, pPriority, pFreeze, pLocationid); IF (_returnVal < 0) THEN RETURN _returnVal; END IF; END LOOP; END IF; RETURN 0; END; $_$; DROP FUNCTION public.createcyclecountsbywarehousebyclasscode(integer, integer, integer, text, boolean, boolean, integer, boolean); publicadminfalse84623125578202icreatecyclecountsbywarehousebyclasscode(integer, text, integer, text, boolean, boolean, integer, boolean)FUNCTION CREATE FUNCTION createcyclecountsbywarehousebyclasscode(integer, text, integer, text, boolean, boolean, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pClasscodePattern ALIAS FOR $2; pMaxNumber ALIAS FOR $3; pComments ALIAS FOR $4; pPriority ALIAS FOR $5; pFreeze ALIAS FOR $6; pLocationid ALIAS FOR $7; pIgnoreZeroBalance ALIAS FOR $8; _itemsites RECORD; _returnVal INTEGER; BEGIN IF (pLocationid IS NULL) THEN FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, itemsite_qtyonhand FROM itemsite, item, classcode WHERE ( (itemsite_active) AND (itemsite_item_id=item_id) AND (item_classcode_id=classcode_id) AND (itemsite_cyclecountfreq > 0) AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE) AND (itemsite_id NOT IN ( SELECT invcnt_itemsite_id FROM invcnt, itemsite WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_warehous_id=pWarehousid) AND (invcnt_location_id IS NULL) AND (NOT invcnt_posted) ) ) ) AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0)) AND ((pLocationid IS NULL) OR (validLocation(pLocationid, itemsite_id))) AND (itemsite_warehous_id=pWarehousid) AND (classcode_code ~ pClasscodePattern) ) ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass, item_number LIMIT pMaxNumber LOOP _returnVal := createCountTag(_itemsites.itemsite_id, pComments, pPriority, pFreeze, pLocationid); IF (_returnVal < 0) THEN RETURN _returnVal; END IF; END LOOP; ELSE FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, SUM(itemloc_qty) FROM itemsite, item, classcode, itemloc WHERE ( (itemsite_active) AND (itemsite_item_id=item_id) AND (item_classcode_id=classcode_id) AND (itemsite_cyclecountfreq > 0) AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE) AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0)) AND (pLocationid = itemloc_location_id) AND (itemloc_itemsite_id = itemsite_id) AND (itemsite_warehous_id=pWarehousid) AND (classcode_code ~ pClasscodePattern) ) GROUP BY itemsite_id, itemsite_warehous_id, itemsite_datelastcount, itemsite_cyclecountfreq, itemsite_abcclass ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass LIMIT pMaxNumber LOOP _returnVal := createCountTag(_itemsites.itemsite_id, pComments, pPriority, pFreeze, pLocationid); IF (_returnVal < 0) THEN RETURN _returnVal; END IF; END LOOP; END IF; RETURN 0; END; $_$; DROP FUNCTION public.createcyclecountsbywarehousebyclasscode(integer, text, integer, text, boolean, boolean, integer, boolean); publicadminfalse46238125578203kcreatecyclecountsbywarehousebyplannercode(integer, text, integer, text, boolean, boolean, integer, boolean)FUNCTIONo CREATE FUNCTION createcyclecountsbywarehousebyplannercode(integer, text, integer, text, boolean, boolean, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pPlancodePattern ALIAS FOR $2; pMaxNumber ALIAS FOR $3; pComments ALIAS FOR $4; pPriority ALIAS FOR $5; pFreeze ALIAS FOR $6; pLocationid ALIAS FOR $7; pIgnoreZeroBalance ALIAS FOR $8; _itemsites RECORD; _returnVal INTEGER; BEGIN IF (pLocationid IS NULL) THEN FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, itemsite_qtyonhand FROM itemsite, item, plancode WHERE ( (itemsite_active) AND (itemsite_item_id=item_id) AND (itemsite_plancode_id=plancode_id) AND (itemsite_cyclecountfreq > 0) AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE) AND (itemsite_id NOT IN ( SELECT invcnt_itemsite_id FROM invcnt, itemsite WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_warehous_id=pWarehousid) AND (invcnt_location_id IS NULL) AND (NOT invcnt_posted) ) ) ) AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0)) AND ((pLocationid IS NULL) OR (validLocation(pLocationid, itemsite_id))) AND (itemsite_warehous_id=pWarehousid) AND (plancode_code ~ pPlancodePattern) ) ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass, item_number LIMIT pMaxNumber LOOP _returnVal := createCountTag(_itemsites.itemsite_id, pComments, pPriority, pFreeze, pLocationid); IF (_returnVal < 0) THEN RETURN _returnVal; END IF; END LOOP; ELSE FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, SUM(itemloc_qty) FROM itemsite, plancode, itemloc WHERE ( (itemsite_active) AND (itemsite_plancode_id=plancode_id) AND (itemsite_cyclecountfreq > 0) AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE) AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0)) AND (pLocationid = itemloc_location_id) AND (itemloc_itemsite_id = itemsite_id) AND (itemsite_warehous_id=pWarehousid) AND (plancode_code ~ pPlancodePattern) ) GROUP BY itemsite_id, itemsite_warehous_id, itemsite_datelastcount, itemsite_cyclecountfreq, itemsite_abcclass ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass LIMIT pMaxNumber LOOP _returnVal := createCountTag(_itemsites.itemsite_id, pComments, pPriority, pFreeze, pLocationid); IF (_returnVal < 0) THEN RETURN _returnVal; END IF; END LOOP; END IF; RETURN 0; END; $_$; DROP FUNCTION public.createcyclecountsbywarehousebyplannercode(integer, text, integer, text, boolean, boolean, integer, boolean); publicadminfalse84623125578204ncreatecyclecountsbywarehousebyplannercode(integer, integer, integer, text, boolean, boolean, integer, boolean)FUNCTION CREATE FUNCTION createcyclecountsbywarehousebyplannercode(integer, integer, integer, text, boolean, boolean, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pPlancodeid ALIAS FOR $2; pMaxNumber ALIAS FOR $3; pComments ALIAS FOR $4; pPriority ALIAS FOR $5; pFreeze ALIAS FOR $6; pLocationid ALIAS FOR $7; pIgnoreZeroBalance ALIAS FOR $8; _itemsites RECORD; _returnVal INTEGER; BEGIN IF (pLocationid IS NULL) THEN FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, itemsite_qtyonhand FROM itemsite, item WHERE ( (itemsite_active) AND (itemsite_item_id=item_id) AND (itemsite_cyclecountfreq > 0) AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE) AND (itemsite_id NOT IN ( SELECT invcnt_itemsite_id FROM invcnt, itemsite WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_warehous_id=pWarehousid) AND (invcnt_location_id IS NULL) AND (NOT invcnt_posted) ) ) ) AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0)) AND ((pLocationid IS NULL) OR (validLocation(pLocationid, itemsite_id))) AND (itemsite_warehous_id=pWarehousid) AND (itemsite_plancode_id=pPlancodeid) ) ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass, item_number LIMIT pMaxNumber LOOP _returnVal := createCountTag(_itemsites.itemsite_id, pComments, pPriority, pFreeze, pLocationid); IF (_returnVal < 0) THEN RETURN _returnVal; END IF; END LOOP; ELSE FOR _itemsites IN SELECT itemsite_id, itemsite_warehous_id, SUM(itemloc_qty) FROM itemsite, itemloc WHERE ( (itemsite_active) AND (itemsite_cyclecountfreq > 0) AND ((COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq) < CURRENT_DATE) AND ((NOT pIgnoreZeroBalance) OR (itemsite_qtyonhand <> 0)) AND (itemloc_itemsite_id = itemsite_id) AND (itemsite_warehous_id=pWarehousid) AND (pLocationid = itemloc_location_id) AND (itemsite_plancode_id=pPlancodeid) ) GROUP BY itemsite_id, itemsite_warehous_id, itemsite_datelastcount, itemsite_cyclecountfreq, itemsite_abcclass ORDER BY (COALESCE(itemsite_datelastcount, startOfTime()) + itemsite_cyclecountfreq), itemsite_abcclass LIMIT pMaxNumber LOOP _returnVal := createCountTag(_itemsites.itemsite_id, pComments, pPriority, pFreeze, pLocationid); IF (_returnVal < 0) THEN RETURN _returnVal; END IF; END LOOP; END IF; RETURN 0; END; $_$; DROP FUNCTION public.createcyclecountsbywarehousebyplannercode(integer, integer, integer, text, boolean, boolean, integer, boolean); publicadminfalse46238125587004pcreatedoctype(integer, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text)FUNCTIONz CREATE FUNCTION createdoctype(pdocassnum integer, ptype text, pdocass text, pcharass text, pfull text, ptable text, pkey text, pnumber text, pname text, pdesc text, pwidget text DEFAULT ''::text, pjoin text DEFAULT ''::text, pparam text DEFAULT ''::text, pui text DEFAULT ''::text, ppriv text DEFAULT ''::text, pmodule text DEFAULT 'System'::text) RETURNS integer LANGUAGE plpgsql AS $$ /* Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. See www.xtuple.com/CPAL for the full text of the software license. Create a record in the "source" table corresponding to this document type or update existing records. The pDocAssNum MUST match the corresponding Documents::DocumentSources (qt-client/widgets/documents.h) if the record type is there. Otherwise pass NULL or 0 and let the `source` table trigger set a value. See the source table comments for a description of the other arguments. */ declare _id integer := -1; begin select source_id into _id from source where source_name = pType for update; if not found then insert into source (source_docass_num, source_module, source_name, source_descrip, source_table, source_docass, source_charass, source_key_field, source_number_field, source_name_field, source_desc_field, source_joins, source_widget, source_key_param, source_uiform_name, source_create_priv ) values (coalesce(pDocAssNum, 0), pModule, pType, pFull, pTable, pDocAss, pCharAss, pKey, pNumber, pName, pDesc, pJoin, pWidget, pParam, pUi, pPriv) returning source_id into _id; else update source set source_docass_num = coalesce(pDocAssNum, 0), source_module = pModule, source_docass = pDocAss, source_charass = pCharass, source_descrip = pFull, source_table = pTable, source_key_field = pKey, source_number_field = pNumber, source_name_field = pName, source_desc_field = pDesc, source_joins = pJoin, source_widget = pWidget, source_key_param = pParam, source_uiform_name = pUi, source_create_priv = pPriv where source_name = pType returning source_id into _id; end if; return _id; end; $$; DROP FUNCTION public.createdoctype(pdocassnum integer, ptype text, pdocass text, pcharass text, pfull text, ptable text, pkey text, pnumber text, pname text, pdesc text, pwidget text, pjoin text, pparam text, pui text, ppriv text, pmodule text); publicadminfalse84623125578205createfile(text, text, bytea)FUNCTIONvCREATE FUNCTION createfile(text, text, bytea) RETURNS integer LANGUAGE plpgsql AS $_$ declare pTitle ALIAS FOR $1; pDescription ALIAS FOR $2; pStream ALIAS FOR $3; _id integer; begin _id := nextval('file_file_id_seq'); insert into file (file_id, file_title, file_descrip, file_stream) values (_id, pTitle, pDescription, pStream); return _id; end; $_$; 4DROP FUNCTION public.createfile(text, text, bytea); publicadminfalse84623125578206createinvoice(integer)FUNCTION CREATE FUNCTION createinvoice(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCobmiscid ALIAS FOR $1; _invcheadid INTEGER; _invcitemid INTEGER; _qtyToInvoice NUMERIC; _r RECORD; _s RECORD; _lastlinenumber INTEGER := 1; BEGIN IF ( ( SELECT cobmisc_posted FROM cobmisc WHERE (cobmisc_id=pCobmiscid) ) ) THEN RETURN -1; END IF; SELECT NEXTVAL('invchead_invchead_id_seq') INTO _invcheadid; -- Give this selection a number if it has not been assigned one UPDATE cobmisc SET cobmisc_invcnumber=fetchInvcNumber() WHERE ( (cobmisc_invcnumber IS NULL) AND (cobmisc_id=pCobmiscid) ); -- Create the Invoice header INSERT INTO invchead ( invchead_id,invchead_cust_id,invchead_shipto_id,invchead_ordernumber,invchead_orderdate, invchead_posted,invchead_printed,invchead_invcnumber,invchead_invcdate,invchead_shipdate, invchead_ponumber,invchead_shipvia,invchead_fob,invchead_billto_name,invchead_billto_address1, invchead_billto_address2,invchead_billto_address3,invchead_billto_city,invchead_billto_state,invchead_billto_zipcode, invchead_billto_phone,invchead_billto_country,invchead_shipto_name,invchead_shipto_address1,invchead_shipto_address2, invchead_shipto_address3,invchead_shipto_city,invchead_shipto_state,invchead_shipto_zipcode,invchead_shipto_phone, invchead_shipto_country,invchead_salesrep_id,invchead_commission,invchead_terms_id,invchead_freight, invchead_misc_amount,invchead_misc_descrip,invchead_misc_accnt_id,invchead_payment, invchead_paymentref,invchead_notes,invchead_prj_id,invchead_curr_id, invchead_taxzone_id, invchead_shipchrg_id, invchead_saletype_id, invchead_shipzone_id ) SELECT _invcheadid,cohead_cust_id,cohead_shipto_id,cohead_number,cohead_orderdate, FALSE,FALSE,cobmisc_invcnumber,cobmisc_invcdate,cobmisc_shipdate, cohead_custponumber,cobmisc_shipvia,cohead_fob,cohead_billtoname,cohead_billtoaddress1, cohead_billtoaddress2,cohead_billtoaddress3,cohead_billtocity,cohead_billtostate,cohead_billtozipcode, cntct_phone AS cust_phone,cohead_billtocountry,cohead_shiptoname,cohead_shiptoaddress1,cohead_shiptoaddress2, cohead_shiptoaddress3,cohead_shiptocity,cohead_shiptostate,cohead_shiptozipcode,cohead_shipto_cntct_phone, cohead_shiptocountry,cohead_salesrep_id,COALESCE(cohead_commission,0),cohead_terms_id,cobmisc_freight, COALESCE(cobmisc_misc, 0.00),cobmisc_misc_descrip,cobmisc_misc_accnt_id,cobmisc_payment, cobmisc_paymentref,cobmisc_notes,cohead_prj_id,cobmisc_curr_id, cobmisc_taxzone_id, cohead_shipchrg_id, cohead_saletype_id, cohead_shipzone_id FROM cobmisc, cohead, custinfo LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) WHERE ( (cobmisc_cohead_id=cohead_id) AND (cohead_cust_id=cust_id) AND (cobmisc_id=pCobmiscid) ); INSERT INTO invcheadtax(taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate) SELECT _invcheadid,taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate FROM cobmisctax WHERE taxhist_parent_id = pCobmiscid AND taxhist_taxtype_id = getadjustmenttaxtypeid(); -- Create the Invoice Characteristic Assignments INSERT INTO charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price) SELECT 'INV', _invcheadid, charass_char_id, charass_value, charass_default, charass_price FROM cobmisc JOIN cohead ON (cohead_id=cobmisc_cohead_id) JOIN charass ON charass_target_type = 'SO' AND charass_target_id = cohead_id JOIN char ON char_id = charass_char_id JOIN charuse ON char_id = charuse_char_id AND charuse_target_type = 'INV' WHERE cobmisc_id = pCobmiscid; -- Create the Invoice items FOR _r IN SELECT coitem_id, coitem_linenumber, coitem_subnumber, coitem_custpn, coitem_qtyord, cobill_qty, coitem_qty_uom_id, coitem_qty_invuomratio, coitem_custprice, coitem_price, coitem_price_uom_id, coitem_price_invuomratio, coitem_memo, coitem_rev_accnt_id, itemsite_item_id, itemsite_warehous_id, cobill_taxtype_id, formatSoItemNumber(coitem_id) AS ordnumber FROM coitem, cobill, itemsite WHERE ( (cobill_coitem_id=coitem_id) AND (coitem_itemsite_id=itemsite_id) AND (cobill_cobmisc_id=pCobmiscid) ) ORDER BY coitem_linenumber, coitem_subnumber LOOP SELECT NEXTVAL('invcitem_invcitem_id_seq') INTO _invcitemid; INSERT INTO invcitem ( invcitem_id, invcitem_invchead_id, invcitem_linenumber, invcitem_item_id, invcitem_warehous_id, invcitem_custpn, invcitem_number, invcitem_descrip, invcitem_ordered, invcitem_billed, invcitem_qty_uom_id, invcitem_qty_invuomratio, invcitem_custprice, invcitem_price, invcitem_price_uom_id, invcitem_price_invuomratio, invcitem_notes, invcitem_taxtype_id, invcitem_coitem_id, invcitem_rev_accnt_id ) VALUES ( _invcitemid, _invcheadid, _lastlinenumber, _r.itemsite_item_id, _r.itemsite_warehous_id, _r.coitem_custpn, '', '', _r.coitem_qtyord, _r.cobill_qty, _r.coitem_qty_uom_id, _r.coitem_qty_invuomratio, _r.coitem_custprice, _r.coitem_price, _r.coitem_price_uom_id, _r.coitem_price_invuomratio, _r.coitem_memo, _r.cobill_taxtype_id, _r.coitem_id, _r.coitem_rev_accnt_id ); -- Find and mark any Lot/Serial invdetail records associated with this bill UPDATE invdetail SET invdetail_invcitem_id = _invcitemid WHERE (invdetail_id IN (SELECT invdetail_id FROM invhist JOIN invdetail ON (invdetail_invhist_id=invhist_id) WHERE ( (invhist_ordnumber = _r.ordnumber) AND (invhist_ordtype = 'SO') AND (invhist_transtype = 'SH') AND (invdetail_invcitem_id IS NULL) ) )); -- Mark any shipped, uninvoiced shipitems for the current coitem as invoiced _qtyToInvoice := _r.cobill_qty; FOR _s IN SELECT shipitem.*, shipitem_qty = _r.cobill_qty AS matched FROM shipitem, shiphead WHERE ((shipitem_shiphead_id=shiphead_id) AND (shipitem_orderitem_id=_r.coitem_id) AND (shiphead_shipped) AND (shiphead_order_type='SO') AND (NOT shipitem_invoiced)) ORDER BY matched DESC, shipitem_qty DESC FOR UPDATE LOOP IF (_qtyToInvoice >= _s.shipitem_qty) THEN UPDATE shipitem SET shipitem_invoiced=TRUE, shipitem_invcitem_id=_invcitemid WHERE (shipitem_id=_s.shipitem_id); _qtyToInvoice := _qtyToInvoice - _s.shipitem_qty; END IF; IF (_qtyToInvoice <= 0) THEN EXIT; END IF; END LOOP; UPDATE cobill SET cobill_invcnum=cobmisc_invcnumber, cobill_invcitem_id=invcitem_id FROM invcitem, coitem, cobmisc WHERE ((invcitem_linenumber=_lastlinenumber) AND (coitem_id=cobill_coitem_id) AND (cobmisc_id=cobill_cobmisc_id) AND (cobill_cobmisc_id=pCobmiscid) AND (invcitem_invchead_id=_invcheadid)); _lastlinenumber := _lastlinenumber + 1; END LOOP; -- Close all requested coitem's IF ( ( SELECT cobmisc_closeorder FROM cobmisc WHERE (cobmisc_id=pCobmiscid) ) ) THEN UPDATE coitem SET coitem_status='C' FROM cobmisc WHERE ( (coitem_status NOT IN ('C', 'X')) AND (coitem_cohead_id=cobmisc_cohead_id) AND (cobmisc_id=pCobmiscid) ); ELSE UPDATE coitem SET coitem_status='C' FROM cobill WHERE ( (cobill_coitem_id=coitem_id) AND (coitem_status <> 'X') AND (cobill_toclose) AND (cobill_cobmisc_id=pCobmiscid) ); END IF; -- Mark the cobmisc as posted UPDATE cobmisc SET cobmisc_posted=TRUE, cobmisc_invchead_id=_invcheadid WHERE (cobmisc_id=pCobmiscid); -- All done RETURN _invcheadid; END; $_$; -DROP FUNCTION public.createinvoice(integer); publicadminfalse46238125578208"createinvoiceconsolidated(integer)FUNCTION3CREATE FUNCTION createinvoiceconsolidated(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; _invcheadid INTEGER; _invcitemid INTEGER; _qtyToInvoice NUMERIC; _r RECORD; _s RECORD; _c RECORD; _i RECORD; _count INTEGER; _invcnumber INTEGER; _lastlinenumber INTEGER; BEGIN _count := 0; FOR _c IN SELECT min(cobmisc_id) AS cobmisc_id, count(*) AS cnt, -- there are the key values for consolidation cohead_billtoname, cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, cohead_billtocity, cohead_billtostate, cohead_billtozipcode, cntct_phone AS cust_phone, cohead_billtocountry, cohead_salesrep_id, cohead_commission, cohead_terms_id, cobmisc_misc_accnt_id, cohead_prj_id, cobmisc_curr_id, cobmisc_taxzone_id, cohead_shipchrg_id, cohead_saletype_id, cohead_shipzone_id, -- the following are consolidated values to use in creating the header MIN(cohead_number) AS cohead_number, MIN(cohead_orderdate) AS cohead_orderdate, MIN(cobmisc_invcdate) AS cobmisc_invcdate, MIN(cobmisc_shipdate) AS cobmisc_shipdate, SUM(cobmisc_freight) AS cobmisc_freight, SUM(cobmisc_misc) AS cobmisc_misc, SUM(cobmisc_payment) AS cobmisc_payment FROM cobmisc JOIN cohead ON (cobmisc_cohead_id=cohead_id) JOIN custinfo ON (cohead_cust_id=cust_id) LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) WHERE(NOT cobmisc_posted AND (cohead_cust_id=pCustid) ) GROUP BY cohead_billtoname, cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, cohead_billtocity, cohead_billtostate, cohead_billtozipcode, cust_phone, cohead_billtocountry, cohead_salesrep_id, cohead_commission, cohead_terms_id, cobmisc_misc_accnt_id, cohead_prj_id, cobmisc_curr_id, cobmisc_taxzone_id, cohead_shipchrg_id, cohead_saletype_id, cohead_shipzone_id LOOP IF(_c.cnt = 1) THEN PERFORM createInvoice(_c.cobmisc_id); _count := (_count + 1); ELSE SELECT NEXTVAL('invchead_invchead_id_seq'), fetchInvcNumber() INTO _invcheadid, _invcnumber; -- Create the Invoice header INSERT INTO invchead ( invchead_id, invchead_cust_id, invchead_shipto_id, invchead_ordernumber, invchead_orderdate, invchead_posted, invchead_printed, invchead_invcnumber, invchead_invcdate, invchead_shipdate, invchead_ponumber, invchead_shipvia, invchead_fob, invchead_billto_name, invchead_billto_address1, invchead_billto_address2, invchead_billto_address3, invchead_billto_city, invchead_billto_state, invchead_billto_zipcode, invchead_billto_phone, invchead_billto_country, invchead_shipto_name, invchead_shipto_address1, invchead_shipto_address2, invchead_shipto_address3, invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode, invchead_shipto_phone, invchead_shipto_country, invchead_salesrep_id, invchead_commission, invchead_terms_id, invchead_freight, invchead_misc_amount, invchead_misc_descrip, invchead_misc_accnt_id, invchead_payment, invchead_paymentref, invchead_notes, invchead_prj_id, invchead_curr_id, invchead_taxzone_id, invchead_shipchrg_id, invchead_saletype_id, invchead_shipzone_id ) VALUES(_invcheadid, pCustid, -1, NULL, _c.cohead_orderdate, FALSE, FALSE, _invcnumber, _c.cobmisc_invcdate, _c.cobmisc_shipdate, 'MULTIPLE', '', '', _c.cohead_billtoname, _c.cohead_billtoaddress1, _c.cohead_billtoaddress2, _c.cohead_billtoaddress3, _c.cohead_billtocity, _c.cohead_billtostate, _c.cohead_billtozipcode, _c.cust_phone, _c.cohead_billtocountry, '', '', '', '', '', '', '', '', '', _c.cohead_salesrep_id, COALESCE(_c.cohead_commission, 0), _c.cohead_terms_id, _c.cobmisc_freight, _c.cobmisc_misc, CASE WHEN(_c.cobmisc_misc <> 0) THEN 'Multiple' ELSE '' END, _c.cobmisc_misc_accnt_id, _c.cobmisc_payment, '', 'Multiple Sales Order # Invoice', _c.cohead_prj_id, _c.cobmisc_curr_id, _c.cobmisc_taxzone_id, _c.cohead_shipchrg_id, _c.cohead_saletype_id, _c.cohead_shipzone_id ); _lastlinenumber := 1; FOR _i IN SELECT cobmisc_id FROM cobmisc JOIN cohead ON (cobmisc_cohead_id=cohead_id) JOIN custinfo ON (cohead_cust_id=cust_id) LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) WHERE(NOT cobmisc_posted AND (cohead_cust_id=pCustid) AND (COALESCE(cohead_billtoname,'') = COALESCE(_c.cohead_billtoname,'')) AND (COALESCE(cohead_billtoaddress1,'') = COALESCE(_c.cohead_billtoaddress1,'')) AND (COALESCE(cohead_billtoaddress2,'') = COALESCE(_c.cohead_billtoaddress2,'')) AND (COALESCE(cohead_billtoaddress3,'') = COALESCE(_c.cohead_billtoaddress3,'')) AND (COALESCE(cohead_billtocity,'') = COALESCE(_c.cohead_billtocity,'')) AND (COALESCE(cohead_billtostate,'') = COALESCE(_c.cohead_billtostate,'')) AND (COALESCE(cohead_billtozipcode,'') = COALESCE(_c.cohead_billtozipcode,'')) AND (COALESCE(cntct_phone,'') = COALESCE(_c.cust_phone,'')) AND (COALESCE(cohead_billtocountry,'') = COALESCE(_c.cohead_billtocountry,'')) AND (COALESCE(cohead_salesrep_id, 0) = COALESCE(_c.cohead_salesrep_id, 0)) AND (COALESCE(cohead_commission, 0) = COALESCE(_c.cohead_commission, 0)) AND (COALESCE(cohead_terms_id, 0) = COALESCE(_c.cohead_terms_id, 0)) AND (COALESCE(cobmisc_misc_accnt_id, 0) = COALESCE(_c.cobmisc_misc_accnt_id, 0)) AND (COALESCE(cohead_prj_id, 0) = COALESCE(_c.cohead_prj_id, 0)) AND (COALESCE(cobmisc_curr_id, 0) = COALESCE(_c.cobmisc_curr_id, 0)) AND (COALESCE(cobmisc_taxzone_id, 0) = COALESCE(_c.cobmisc_taxzone_id, 0)) AND (COALESCE(cohead_saletype_id, 0) = COALESCE(_c.cohead_saletype_id, 0)) AND (COALESCE(cohead_shipzone_id, 0) = COALESCE(_c.cohead_shipzone_id, 0)) ) LOOP -- Create the Invoice Head tax INSERT INTO invcheadtax(taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate) SELECT _invcheadid,taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate FROM cobmisctax WHERE taxhist_parent_id = _i.cobmisc_id AND taxhist_taxtype_id = getadjustmenttaxtypeid(); -- Give this selection a number if it has not been assigned one UPDATE cobmisc SET cobmisc_invcnumber=_invcnumber WHERE(cobmisc_id=_i.cobmisc_id); -- Create the Invoice items FOR _r IN SELECT coitem_id, coitem_linenumber, coitem_subnumber, coitem_custpn, coitem_qtyord, cobill_qty, coitem_qty_uom_id, coitem_qty_invuomratio, coitem_custprice, coitem_price, coitem_price_uom_id, coitem_price_invuomratio, coitem_memo, itemsite_item_id, itemsite_warehous_id, cobill_taxtype_id FROM cohead, coitem, cobill, itemsite WHERE((cobill_coitem_id=coitem_id) AND (cohead_id=coitem_cohead_id) AND (coitem_itemsite_id=itemsite_id) AND (cobill_cobmisc_id=_i.cobmisc_id) ) ORDER BY cohead_number, coitem_linenumber, coitem_subnumber LOOP SELECT NEXTVAL('invcitem_invcitem_id_seq') INTO _invcitemid; INSERT INTO invcitem ( invcitem_id, invcitem_invchead_id, invcitem_linenumber, invcitem_item_id, invcitem_warehous_id, invcitem_custpn, invcitem_number, invcitem_descrip, invcitem_ordered, invcitem_billed, invcitem_qty_uom_id, invcitem_qty_invuomratio, invcitem_custprice, invcitem_price, invcitem_price_uom_id, invcitem_price_invuomratio, invcitem_notes, invcitem_taxtype_id, invcitem_coitem_id ) VALUES ( _invcitemid, _invcheadid, _lastlinenumber, _r.itemsite_item_id, _r.itemsite_warehous_id, _r.coitem_custpn, '', '', _r.coitem_qtyord, _r.cobill_qty, _r.coitem_qty_uom_id, _r.coitem_qty_invuomratio, _r.coitem_custprice, _r.coitem_price, _r.coitem_price_uom_id, _r.coitem_price_invuomratio, _r.coitem_memo, _r.cobill_taxtype_id, _r.coitem_id ); -- Find and mark any Lot/Serial invdetail records associated with this bill UPDATE invdetail SET invdetail_invcitem_id = _invcitemid WHERE (invdetail_id IN (SELECT invdetail_id FROM coitem, cohead, invhist, invdetail WHERE ((coitem_cohead_id=cohead_id) AND (invdetail_invhist_id=invhist_id) AND (invhist_ordnumber = text(cohead_number||'-'||formatSoLineNumber(coitem_id))) AND (invdetail_invcitem_id IS NULL) AND (coitem_id=_r.coitem_id)) ) ); -- Mark any shipped, uninvoiced shipitems for the current coitem as invoiced _qtyToInvoice := _r.cobill_qty; FOR _s IN SELECT shipitem.*, shipitem_qty = _r.cobill_qty AS matched FROM shipitem, shiphead WHERE ((shipitem_shiphead_id=shiphead_id) AND (shipitem_orderitem_id=_r.coitem_id) AND (shiphead_shipped) AND (shiphead_order_type='SO') AND (NOT shipitem_invoiced)) ORDER BY matched DESC, shipitem_qty DESC FOR UPDATE LOOP IF (_qtyToInvoice >= _s.shipitem_qty) THEN UPDATE shipitem SET shipitem_invoiced=TRUE, shipitem_invcitem_id=_invcitemid WHERE (shipitem_id=_s.shipitem_id); _qtyToInvoice := _qtyToInvoice - _s.shipitem_qty; END IF; IF (_qtyToInvoice <= 0) THEN EXIT; END IF; END LOOP; UPDATE cobill SET cobill_invcnum=cobmisc_invcnumber, cobill_invcitem_id=invcitem_id FROM invcitem, coitem, cobmisc WHERE ((invcitem_linenumber=_lastlinenumber ) AND (coitem_id=cobill_coitem_id) AND (cobmisc_id=cobill_cobmisc_id) AND (cobill_cobmisc_id=_i.cobmisc_id) AND (invcitem_invchead_id=_invcheadid)); _lastlinenumber := _lastlinenumber + 1; END LOOP; -- Close all requested coitem's IF ( ( SELECT cobmisc_closeorder FROM cobmisc WHERE (cobmisc_id=_i.cobmisc_id) ) ) THEN UPDATE coitem SET coitem_status='C' FROM cobmisc WHERE ( (coitem_status NOT IN ('C', 'X')) AND (coitem_cohead_id=cobmisc_cohead_id) AND (cobmisc_id=_i.cobmisc_id) ); ELSE UPDATE coitem SET coitem_status='C' FROM cobill WHERE ( (cobill_coitem_id=coitem_id) AND (coitem_status <> 'X') AND (cobill_toclose) AND (cobill_cobmisc_id=_i.cobmisc_id) ); END IF; -- Mark the cobmisc as posted UPDATE cobmisc SET cobmisc_posted=TRUE, cobmisc_invchead_id=_invcheadid WHERE (cobmisc_id=_i.cobmisc_id); -- All done _count := (_count + 1); END LOOP; END IF; END LOOP; RETURN _count; END; $_$; 9DROP FUNCTION public.createinvoiceconsolidated(integer); publicadminfalse46238125578210createinvoices()FUNCTION CREATE FUNCTION createinvoices() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _counter INTEGER; _cobmisc RECORD; BEGIN _counter := 0; FOR _cobmisc IN SELECT cobmisc_id FROM cobmisc WHERE (NOT cobmisc_posted) LOOP PERFORM createinvoice(_cobmisc.cobmisc_id); _counter := (_counter + 1); END LOOP; RETURN _counter; END; $$; 'DROP FUNCTION public.createinvoices(); publicadminfalse46238125578211createinvoices(integer)FUNCTION CREATE FUNCTION createinvoices(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN createinvoices($1, false); END; $_$; .DROP FUNCTION public.createinvoices(integer); publicadminfalse84623125578212 createinvoices(integer, boolean)FUNCTION&CREATE FUNCTION createinvoices(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustTypeId ALIAS FOR $1; pConsolidate ALIAS FOR $2; _counter INTEGER; _tcounter INTEGER; _cobmisc RECORD; BEGIN _counter := 0; IF (pConsolidate) THEN FOR _cobmisc IN SELECT DISTINCT cust_id FROM cobmisc, cohead, custinfo WHERE((NOT cobmisc_posted) AND (cohead_id=cobmisc_cohead_id) AND (cust_id=cohead_cust_id) AND (cust_custtype_id=pCustTypeId)) LOOP SELECT createinvoiceConsolidated(_cobmisc.cust_id) INTO _tcounter; _counter := (_counter + _tcounter); END LOOP; ELSE FOR _cobmisc IN SELECT cobmisc_id FROM cobmisc, cohead, custinfo WHERE((NOT cobmisc_posted) AND (cohead_id=cobmisc_cohead_id) AND (cust_id=cohead_cust_id) AND (cust_custtype_id=pCustTypeId)) LOOP PERFORM createinvoice(_cobmisc.cobmisc_id); _counter := (_counter + 1); END LOOP; END IF; RETURN _counter; END; $_$; 7DROP FUNCTION public.createinvoices(integer, boolean); publicadminfalse46238125578213Gcreatemiscapcheck(integer, integer, date, numeric, integer, text, text)FUNCTIONCREATE FUNCTION createmiscapcheck(integer, integer, date, numeric, integer, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'createMiscAPCheck() is deprecated - use createCheck() instead'; RETURN createCheck($1, 'V', $2, $3, $4, baseCurrId(), $5, NULL, $6, $7, FALSE); END; $_$; ^DROP FUNCTION public.createmiscapcheck(integer, integer, date, numeric, integer, text, text); publicadminfalse84623125578214Pcreatemiscapcheck(integer, integer, date, numeric, integer, integer, text, text)FUNCTIONCREATE FUNCTION createmiscapcheck(integer, integer, date, numeric, integer, integer, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'createMiscAPCheck() is deprecated - use createCheck() instead'; RETURN createCheck($1, 'V', $2, $3, pAmount, $5, $6, NULL, $7, $8, FALSE); END; $_$; gDROP FUNCTION public.createmiscapcheck(integer, integer, date, numeric, integer, integer, text, text); publicadminfalse46238125578215createpkgschema(text, text)FUNCTION CREATE FUNCTION createpkgschema(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pname ALIAS FOR $1; pcomment ALIAS FOR $2; _namespaceoid INTEGER := -1; _tabs TEXT[] := ARRAY['cmd', 'cmdarg', 'image', 'metasql', 'priv', 'report', 'script', 'uiform'] ; _pkgtab TEXT; BEGIN IF (LENGTH(COALESCE(pname, '')) <= 0) THEN RAISE EXCEPTION 'Cannot create a schema for this package without a name.'; END IF; SELECT oid INTO _namespaceoid FROM pg_namespace WHERE (LOWER(nspname)=LOWER(pname)); IF (NOT FOUND) THEN EXECUTE format('CREATE SCHEMA %s;', LOWER(pname)); EXECUTE format('GRANT ALL ON SCHEMA %s TO GROUP xtrole;', LOWER(pname)); SELECT oid INTO _namespaceoid FROM pg_namespace WHERE (LOWER(nspname)=LOWER(pname)); END IF; FOR i IN ARRAY_LOWER(_tabs,1)..ARRAY_UPPER(_tabs,1) LOOP _pkgtab := 'pkg' || _tabs[i]; IF NOT EXISTS(SELECT oid FROM pg_class WHERE ((relname=_pkgtab) AND (relnamespace=_namespaceoid))) THEN EXECUTE format('CREATE TABLE %s.%s () INHERITS (%s);', pname, _pkgtab, _tabs[i]); EXECUTE format($f$ALTER TABLE %s.%s ALTER %s_id SET NOT NULL, ADD PRIMARY KEY (%s_id), ALTER %s_id SET DEFAULT NEXTVAL('%s_%s_id_seq');$f$, pname, _pkgtab, _tabs[i], _tabs[i], _tabs[i], _tabs[i], _tabs[i]); EXECUTE format('REVOKE ALL ON %s.%s FROM PUBLIC;', pname, _pkgtab); EXECUTE format('GRANT ALL ON %s.%s TO GROUP xtrole;', pname, _pkgtab); IF (_tabs[i] = 'cmdarg') THEN EXECUTE format($f$ALTER TABLE %s.%s ADD FOREIGN KEY (cmdarg_cmd_id) REFERENCES %s.pkgcmd(cmd_id);$f$, pname, _pkgtab, pname); END IF; EXECUTE format('DROP TRIGGER IF EXISTS %sbeforetrigger ON %s.%s;', _pkgtab, pname, _pkgtab); EXECUTE format('CREATE TRIGGER %sbeforetrigger' || ' BEFORE INSERT OR UPDATE OR DELETE ON %s.%s' || ' FOR EACH ROW EXECUTE PROCEDURE _%sbeforetrigger();', _pkgtab, pname, _pkgtab, _pkgtab); EXECUTE format('DROP TRIGGER IF EXISTS %saltertrigger ON %s.%s;', _pkgtab, pname, _pkgtab); EXECUTE format('CREATE TRIGGER %saltertrigger' || ' BEFORE INSERT OR UPDATE OR DELETE ON %s.%s' || ' FOR EACH ROW EXECUTE PROCEDURE _%saltertrigger();', _pkgtab, pname, _pkgtab, _pkgtab); EXECUTE format('DROP TRIGGER IF EXISTS %saftertrigger ON %s.%s;', _pkgtab, pname, _pkgtab); EXECUTE format('CREATE TRIGGER %saftertrigger' || ' AFTER INSERT OR UPDATE OR DELETE ON %s.%s' || ' FOR EACH ROW EXECUTE PROCEDURE _%saftertrigger();', _pkgtab, pname, _pkgtab, _pkgtab); END IF; END LOOP; EXECUTE 'COMMENT ON SCHEMA ' || quote_ident(pname) || ' IS ' || quote_literal(pcomment) || ';'; RETURN _namespaceoid; END; $_$; 2DROP FUNCTION public.createpkgschema(text, text); publicadminfalse84623125578216createpr(character, integer)FUNCTIONCREATE FUNCTION createpr(character, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pParentType ALIAS FOR $1; pParentId ALIAS FOR $2; _orderNumber INTEGER; _prid INTEGER; BEGIN IF (pParentType = 'W') THEN SELECT wo_number INTO _orderNumber FROM wo, womatl WHERE ((womatl_wo_id=wo_id) AND (womatl_id=pParentId)); ELSIF (pParentType = 'S') THEN SELECT CAST(cohead_number AS INTEGER) INTO _orderNumber FROM cohead, coitem WHERE ((coitem_cohead_id=cohead_id) AND (coitem_id=pParentId)); ELSIF (pParentType = 'F') THEN SELECT fetchPrNumber() INTO _orderNumber; ELSE RETURN -2; END IF; IF (NOT FOUND) THEN RETURN -1; END IF; SELECT createPr(_orderNumber, pParentType, pParentId) INTO _prid; RETURN _prid; END; $_$; 3DROP FUNCTION public.createpr(character, integer); publicadminfalse84623125578217%createpr(integer, character, integer)FUNCTION@CREATE FUNCTION createpr(integer, character, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOrderNumber ALIAS FOR $1; pParentType ALIAS FOR $2; pParentId ALIAS FOR $3; _parent RECORD; _prid INTEGER; _orderNumber INTEGER; BEGIN IF (pOrderNumber = -1) THEN SELECT fetchPrNumber() INTO _orderNumber; ELSE _orderNumber := pOrderNumber; END IF; IF (pParentType = 'W') THEN SELECT womatl_itemsite_id AS itemsiteid, itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq) AS qty, womatl_duedate AS duedate, wo_prj_id AS prjid, womatl_notes AS notes INTO _parent FROM wo, womatl, itemsite WHERE ((womatl_wo_id=wo_id) AND (womatl_itemsite_id=itemsite_id) AND (womatl_id=pParentId)); ELSIF (pParentType = 'S') THEN SELECT coitem_itemsite_id AS itemsiteid, (coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS qty, coitem_scheddate AS duedate, cohead_prj_id AS prjid, coitem_memo AS notes INTO _parent FROM coitem, cohead WHERE ((cohead_id=coitem_cohead_id) AND (coitem_id=pParentId)); ELSIF (pParentType = 'F') THEN SELECT planord_itemsite_id AS itemsiteid, planord_qty AS qty, planord_duedate AS duedate, NULL::INTEGER AS prjid, planord_comments AS notes INTO _parent FROM planord WHERE (planord_id=pParentId); ELSE RETURN -2; END IF; IF (NOT FOUND) THEN RETURN -1; END IF; SELECT NEXTVAL('pr_pr_id_seq') INTO _prid; INSERT INTO pr ( pr_id, pr_number, pr_subnumber, pr_status, pr_order_type, pr_order_id, pr_prj_id, pr_itemsite_id, pr_qtyreq, pr_duedate, pr_releasenote ) VALUES ( _prid, _orderNumber, nextPrSubnumber(_orderNumber), 'O', pParentType, pParentId, _parent.prjid, _parent.itemsiteid, validateOrderQty(_parent.itemsiteid, _parent.qty, TRUE), _parent.duedate, _parent.notes ); RETURN _prid; END; $_$; <DROP FUNCTION public.createpr(integer, character, integer); publicadminfalse84623125578218+createpr(integer, character, integer, text)FUNCTIONCREATE FUNCTION createpr(integer, character, integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOrderNumber ALIAS FOR $1; pParentType ALIAS FOR $2; pParentId ALIAS FOR $3; pParentNotes ALIAS FOR $4; _parent RECORD; _prid INTEGER; _orderNumber INTEGER; BEGIN IF (pOrderNumber = -1) THEN SELECT fetchPrNumber() INTO _orderNumber; ELSE _orderNumber := pOrderNumber; END IF; IF (pParentType = 'W') THEN SELECT womatl_itemsite_id AS itemsiteid, itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq) AS qty, womatl_duedate AS duedate, wo_prj_id AS prjid INTO _parent FROM wo, womatl, itemsite WHERE ((womatl_wo_id=wo_id) AND (womatl_itemsite_id=itemsite_id) AND (womatl_id=pParentId)); ELSIF (pParentType = 'S') THEN SELECT coitem_itemsite_id AS itemsiteid, (coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) AS qty, coitem_scheddate AS duedate, cohead_prj_id AS prjid INTO _parent FROM coitem, cohead WHERE ((cohead_id=coitem_cohead_id) AND (coitem_id=pParentId)); ELSIF (pParentType = 'F') THEN SELECT planord_itemsite_id AS itemsiteid, planord_qty AS qty, planord_duedate AS duedate, NULL::INTEGER AS prjid INTO _parent FROM planord WHERE (planord_id=pParentId); ELSE RETURN -2; END IF; IF (NOT FOUND) THEN RETURN -1; END IF; SELECT NEXTVAL('pr_pr_id_seq') INTO _prid; INSERT INTO pr ( pr_id, pr_number, pr_subnumber, pr_status, pr_order_type, pr_order_id, pr_prj_id, pr_itemsite_id, pr_qtyreq, pr_duedate, pr_releasenote ) VALUES ( _prid, _orderNumber, nextPrSubnumber(_orderNumber), 'O', pParentType, pParentId, _parent.prjid, _parent.itemsiteid, validateOrderQty(_parent.itemsiteid, _parent.qty, TRUE), _parent.duedate, pParentNotes ); RETURN _prid; END; $_$; BDROP FUNCTION public.createpr(integer, character, integer, text); publicadminfalse84623125578219/createpr(integer, integer, numeric, date, text)FUNCTIONCREATE FUNCTION createpr(integer, integer, numeric, date, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOrderNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pQty ALIAS FOR $3; pDueDate ALIAS FOR $4; pNotes ALIAS FOR $5; _prid INTEGER; BEGIN SELECT NEXTVAL('pr_pr_id_seq') INTO _prid; INSERT INTO pr ( pr_id, pr_number, pr_subnumber, pr_status, pr_order_type, pr_order_id, pr_itemsite_id, pr_qtyreq, pr_duedate, pr_releasenote ) VALUES ( _prid, pOrderNumber, nextPrSubnumber(pOrderNumber), 'O', 'M', -1, pItemsiteid, pQty, pDuedate, pNotes); RETURN _prid; END; $_$; FDROP FUNCTION public.createpr(integer, integer, numeric, date, text); publicadminfalse84623125578220Ccreatepr(integer, integer, numeric, date, text, character, integer)FUNCTIONGCREATE FUNCTION createpr(integer, integer, numeric, date, text, character, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOrderNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pQty ALIAS FOR $3; pDueDate ALIAS FOR $4; pNotes ALIAS FOR $5; pOrderType ALIAS FOR $6; pOrderId ALIAS FOR $7; _prid INTEGER; BEGIN SELECT NEXTVAL('pr_pr_id_seq') INTO _prid; INSERT INTO pr ( pr_id, pr_number, pr_subnumber, pr_status, pr_order_type, pr_order_id, pr_itemsite_id, pr_qtyreq, pr_duedate, pr_releasenote ) VALUES ( _prid, pOrderNumber, nextPrSubnumber(pOrderNumber), 'O', pOrderType, pOrderId, pItemsiteid, pQty, pDuedate, pNotes ); RETURN _prid; END; $_$; ZDROP FUNCTION public.createpr(integer, integer, numeric, date, text, character, integer); publicadminfalse84623125578221createpriv(text, text, text)FUNCTIONCREATE FUNCTION createpriv(text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pModule ALIAS FOR $1; pName ALIAS FOR $2; pDesc ALIAS FOR $3; _id INTEGER; BEGIN SELECT priv_id INTO _id FROM priv WHERE(priv_name=pName); IF (FOUND) THEN UPDATE priv SET priv_module=pModule, priv_descrip=pDesc WHERE(priv_id=_id); ELSE SELECT nextval('priv_priv_id_seq') INTO _id; INSERT INTO priv (priv_id, priv_module, priv_name, priv_descrip) VALUES(_id, pModule, pName, pDesc); END IF; RETURN _id; END; $_$; 3DROP FUNCTION public.createpriv(text, text, text); publicadminfalse462381255870079createpurchasetoquote(integer, integer, boolean, numeric)FUNCTION?CREATE FUNCTION createpurchasetoquote(pquitemid integer, pitemsourceid integer, pdropship boolean, pprice numeric DEFAULT NULL::numeric) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _pohead INTEGER := NULL; -- Legacy parameter _s RECORD; _w RECORD; _i RECORD; _c RECORD; _shipto RECORD; _poheadid INTEGER := -1; _poitemid INTEGER := -1; _taxtypeid INTEGER := -1; _charassid INTEGER := -1; _polinenumber INTEGER; _ponumber NUMERIC; _price NUMERIC; _temp INTEGER; BEGIN -- Check for existing poitem for this quitem SELECT poitem_id INTO _poitemid FROM poitem WHERE (poitem_order_id=pQuitemId) AND (poitem_order_type='S'); IF (FOUND) THEN RETURN _poitemid; END IF; SELECT quhead_id, quhead_prj_id, quhead_shipcomments, quhead_shipto_cntct_email, quhead_shipto_cntct_fax, quhead_shipto_cntct_first_name, quhead_shipto_cntct_honorific, quhead_shipto_cntct_id, quhead_shipto_cntct_last_name, quhead_shipto_cntct_middle, quhead_shipto_cntct_phone, quhead_shipto_cntct_suffix, quhead_shipto_cntct_title, quhead_shiptoaddress1, quhead_shiptoaddress2, quhead_shiptoaddress3, quhead_shiptocity, quhead_shiptocountry, quhead_shiptoname, quhead_shiptostate, quhead_shiptozipcode, quhead_warehous_id, quitem_itemsite_id, quitem_memo, quitem_scheddate, addr_city, addr_country, addr_id, addr_line1, addr_line2, addr_line3, addr_postalcode, addr_state, cntct_email, cntct_fax, cntct_first_name, cntct_honorific, cntct_last_name cntct_middle, cntct_phone, cntct_suffix, cntct_title, itemsite_id, shipto_addr_id shipto_cntct_id, shipto_name, COALESCE(roundQty(item_fractional, (quitem_qtyord * quitem_qty_invuomratio)), 0.0) AS orderqty INTO _s FROM quitem JOIN quhead ON (quhead_id = quitem_quhead_id) LEFT OUTER JOIN shiptoinfo ON (quhead_shipto_id = shipto_id) LEFT OUTER JOIN addr ON (shipto_addr_id = addr_id) LEFT OUTER JOIN cntct ON (shipto_cntct_id = cntct_id) LEFT OUTER JOIN itemsite ON (quitem_itemsite_id = itemsite_id) LEFT OUTER JOIN item ON (item_id = itemsite_item_id) WHERE (quitem_id = pQuitemId); IF (NOT FOUND) THEN RETURN -1; END IF; SELECT addr_city, addr_country, addr_id, addr_line1, addr_line2, addr_line3, addr_postalcode, addr_state, cntct_email, cntct_fax, cntct_first_name, cntct_honorific, cntct_id, cntct_last_name, cntct_middle, cntct_phone, cntct_suffix, cntct_title INTO _w FROM itemsite JOIN whsinfo ON (warehous_id = itemsite_warehous_id) LEFT OUTER JOIN addr ON (warehous_addr_id = addr_id) LEFT OUTER JOIN cntct ON (warehous_cntct_id = cntct_id) WHERE (itemsite_id = _s.itemsite_id); SELECT itemsrc_vend_id, vend_taxzone_id, vend_curr_id, vend_shipvia, vend_terms_id, cntct_id, addr_city, addr_country, addr_line1, addr_line2, addr_line3, addr_postalcode, addr_state, cntct_email, cntct_fax, cntct_first_name, cntct_honorific, cntct_last_name, cntct_middle, cntct_phone, cntct_suffix, cntct_title, itemsrc_invvendoruomratio, itemsrc_item_id, itemsrc_manuf_item_descrip, itemsrc_manuf_item_number, itemsrc_manuf_name, itemsrc_vend_item_descrip, itemsrc_vend_item_number, itemsrc_vend_uom INTO _i FROM itemsrc JOIN vendinfo ON (itemsrc_vend_id = vend_id) LEFT OUTER JOIN cntct ON (vend_cntct1_id = cntct_id) LEFT OUTER JOIN addr ON (vend_addr_id = addr_id) WHERE (itemsrc_id = pItemSourceId); IF (NOT FOUND) THEN RETURN -2; END IF; -- _pohead - NULL=add to existing PO if one exists -- -1=must create new PO -- >0=must add to existing specified PO IF (pDropShip) THEN SELECT COALESCE(pohead_id, -1) INTO _temp FROM pohead WHERE ( (pohead_status = 'U') AND (pohead_vend_id = _i.itemsrc_vend_id) AND (COALESCE(pohead_shiptoname, '') = COALESCE(_s.quhead_shiptoname, _s.shipto_name, '')) AND (COALESCE(pohead_shiptoaddress1, '') = COALESCE(_s.quhead_shiptoaddress1, _s.addr_line1, '')) AND (COALESCE(pohead_shiptoaddress2, '') = COALESCE(_s.quhead_shiptoaddress2, _s.addr_line2, '')) AND (COALESCE(pohead_shiptoaddress3, '') = COALESCE(_s.quhead_shiptoaddress3, _s.addr_line3, '')) AND (COALESCE(pohead_shiptocity, '') = COALESCE(_s.quhead_shiptocity, _s.addr_city, '')) AND (COALESCE(pohead_shiptostate, '') = COALESCE(_s.quhead_shiptostate, _s.addr_state, '')) AND (COALESCE(pohead_shiptozipcode, '') = COALESCE(_s.quhead_shiptozipcode, _s.addr_postalcode, '')) AND (COALESCE(pohead_shiptocountry, '') = COALESCE(_s.quhead_shiptocountry, _s.addr_country, '')) AND ((pohead_id=_pohead) OR (_pohead IS NULL)) ); ELSE SELECT COALESCE(pohead_id, -1) INTO _temp FROM pohead WHERE ( (pohead_status = 'U') AND (pohead_vend_id = _i.itemsrc_vend_id) AND (COALESCE(pohead_shiptoaddress1, '') = COALESCE(_w.addr_line1, '')) AND (COALESCE(pohead_shiptoaddress2, '') = COALESCE(_w.addr_line2, '')) AND (COALESCE(pohead_shiptoaddress3, '') = COALESCE(_w.addr_line3, '')) AND (COALESCE(pohead_shiptocity, '') = COALESCE(_w.addr_city, '')) AND (COALESCE(pohead_shiptostate, '') = COALESCE(_w.addr_state, '')) AND (COALESCE(pohead_shiptozipcode, '') = COALESCE(_w.addr_postalcode, '')) AND (COALESCE(pohead_shiptocountry, '') = COALESCE(_w.addr_country, '')) AND ((pohead_id=_pohead) OR (_pohead IS NULL)) ); END IF; IF (FOUND) THEN -- Add to Existing _poheadid := _temp; UPDATE pohead SET pohead_dropship = pDropShip WHERE (pohead_id = _poheadid); ELSE -- Create New SELECT NEXTVAL('pohead_pohead_id_seq'), fetchPoNumber() INTO _poheadid, _ponumber; IF (pDropShip) THEN INSERT INTO pohead ( pohead_id, pohead_number, pohead_status, pohead_dropship, pohead_agent_username, pohead_vend_id, pohead_taxzone_id, pohead_orderdate, pohead_curr_id, pohead_warehous_id, pohead_shipvia, pohead_terms_id, pohead_shipto_cntct_id, pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name, pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name, pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone, pohead_shipto_cntct_title, pohead_shipto_cntct_fax, pohead_shipto_cntct_email, pohead_shiptoaddress_id, pohead_shiptoname, pohead_shiptoaddress1, pohead_shiptoaddress2, pohead_shiptoaddress3, pohead_shiptocity, pohead_shiptostate, pohead_shiptozipcode, pohead_shiptocountry, pohead_vend_cntct_id, pohead_vend_cntct_honorific, pohead_vend_cntct_first_name, pohead_vend_cntct_middle, pohead_vend_cntct_last_name, pohead_vend_cntct_suffix, pohead_vend_cntct_phone, pohead_vend_cntct_title, pohead_vend_cntct_fax, pohead_vend_cntct_email, pohead_vendaddress1, pohead_vendaddress2, pohead_vendaddress3, pohead_vendcity, pohead_vendstate, pohead_vendzipcode, pohead_vendcountry, pohead_comments ) VALUES ( _poheadid, _ponumber, 'U', pDropShip, getEffectiveXtUser(), _i.itemsrc_vend_id, _i.vend_taxzone_id, CURRENT_DATE, COALESCE(_i.vend_curr_id, basecurrid()), COALESCE(_s.quhead_warehous_id, -1), COALESCE(_i.vend_shipvia, TEXT('')), COALESCE(_i.vend_terms_id, -1), COALESCE(_s.quhead_shipto_cntct_id, _s.shipto_cntct_id), COALESCE(_s.quhead_shipto_cntct_honorific, _s.cntct_honorific), COALESCE(_s.quhead_shipto_cntct_first_name, _s.cntct_first_name), COALESCE(_s.quhead_shipto_cntct_middle, _s.cntct_middle), COALESCE(_s.quhead_shipto_cntct_last_name, _s.cntct_last_name), COALESCE(_s.quhead_shipto_cntct_suffix, _s.cntct_suffix), COALESCE(_s.quhead_shipto_cntct_phone, _s.cntct_phone), COALESCE(_s.quhead_shipto_cntct_title, _s.cntct_title), COALESCE(_s.quhead_shipto_cntct_fax, _s.cntct_fax), COALESCE(_s.quhead_shipto_cntct_email, _s.cntct_email), COALESCE(_s.shipto_addr_id, _s.addr_id), COALESCE(_s.quhead_shiptoname, _s.shipto_name, ''), COALESCE(_s.quhead_shiptoaddress1, _s.addr_line1, ''), COALESCE(_s.quhead_shiptoaddress2, _s.addr_line2, ''), COALESCE(_s.quhead_shiptoaddress3, _s.addr_line3, ''), COALESCE(_s.quhead_shiptocity, _s.addr_city, ''), COALESCE(_s.quhead_shiptostate, _s.addr_state, ''), COALESCE(_s.quhead_shiptozipcode, _s.addr_postalcode, ''), COALESCE(_s.quhead_shiptocountry, _s.addr_country, ''), _i.cntct_id, COALESCE(_i.cntct_honorific, TEXT('')), COALESCE(_i.cntct_first_name, TEXT('')), COALESCE(_i.cntct_middle, TEXT('')), COALESCE(_i.cntct_last_name, TEXT('')), COALESCE(_i.cntct_suffix, TEXT('')), COALESCE(_i.cntct_phone, TEXT('')), COALESCE(_i.cntct_title, TEXT('')), COALESCE(_i.cntct_fax, TEXT('')), COALESCE(_i.cntct_email, TEXT('')), COALESCE(_i.addr_line1, TEXT('')), COALESCE(_i.addr_line2, TEXT('')), COALESCE(_i.addr_line3, TEXT('')), COALESCE(_i.addr_city, TEXT('')), COALESCE(_i.addr_state, TEXT('')), COALESCE(_i.addr_postalcode, TEXT('')), COALESCE(_i.addr_country, TEXT('')), COALESCE(_s.quhead_shipcomments, TEXT('')) ); ELSE INSERT INTO pohead ( pohead_id, pohead_number, pohead_status, pohead_dropship, pohead_agent_username, pohead_vend_id, pohead_taxzone_id, pohead_orderdate, pohead_curr_id, pohead_warehous_id, pohead_shipvia, pohead_terms_id, pohead_shipto_cntct_id, pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name, pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name, pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone, pohead_shipto_cntct_title, pohead_shipto_cntct_fax, pohead_shipto_cntct_email, pohead_shiptoaddress_id, pohead_shiptoaddress1, pohead_shiptoaddress2, pohead_shiptoaddress3, pohead_shiptocity, pohead_shiptostate, pohead_shiptozipcode, pohead_shiptocountry, pohead_vend_cntct_id, pohead_vend_cntct_honorific, pohead_vend_cntct_first_name, pohead_vend_cntct_middle, pohead_vend_cntct_last_name, pohead_vend_cntct_suffix, pohead_vend_cntct_phone, pohead_vend_cntct_title, pohead_vend_cntct_fax, pohead_vend_cntct_email, pohead_vendaddress1, pohead_vendaddress2, pohead_vendaddress3, pohead_vendcity, pohead_vendstate, pohead_vendzipcode, pohead_vendcountry ) VALUES ( _poheadid, _ponumber, 'U', pDropShip, getEffectiveXtUser(), _i.itemsrc_vend_id, _i.vend_taxzone_id, CURRENT_DATE, COALESCE(_i.vend_curr_id, basecurrid()), COALESCE(_s.quhead_warehous_id, -1), COALESCE(_i.vend_shipvia, TEXT('')), COALESCE(_i.vend_terms_id, -1), _w.cntct_id, _w.cntct_honorific, _w.cntct_first_name, _w.cntct_middle, _w.cntct_last_name, _w.cntct_suffix, _w.cntct_phone, _w.cntct_title, _w.cntct_fax, _w.cntct_email, _w.addr_id, COALESCE(_w.addr_line1, ''), COALESCE(_w.addr_line2, ''), COALESCE(_w.addr_line3, ''), COALESCE(_w.addr_city, ''), COALESCE(_w.addr_state, ''), COALESCE(_w.addr_postalcode, ''), COALESCE(_w.addr_country, ''), _i.cntct_id, COALESCE(_i.cntct_honorific, TEXT('')), COALESCE(_i.cntct_first_name, TEXT('')), COALESCE(_i.cntct_middle, TEXT('')), COALESCE(_i.cntct_last_name, TEXT('')), COALESCE(_i.cntct_suffix, TEXT('')), COALESCE(_i.cntct_phone, TEXT('')), COALESCE(_i.cntct_title, TEXT('')), COALESCE(_i.cntct_fax, TEXT('')), COALESCE(_i.cntct_email, TEXT('')), COALESCE(_i.addr_line1, TEXT('')), COALESCE(_i.addr_line2, TEXT('')), COALESCE(_i.addr_line3, TEXT('')), COALESCE(_i.addr_city, TEXT('')), COALESCE(_i.addr_state, TEXT('')), COALESCE(_i.addr_postalcode, TEXT('')), COALESCE(_i.addr_country, TEXT('')) ); END IF; END IF; -- Copy characteristics from the quhead to the pohead -- while avoiding duplicates FOR _c IN SELECT charass.* FROM charass JOIN char ON char_id = charass_char_id JOIN charuse ON char_id = charuse_char_id AND charuse_target_type = 'PO' WHERE charass_target_type = 'QU' AND charass_target_id = _s.quhead_id LOOP SELECT charass_id INTO _charassid FROM charass WHERE ( (charass_target_type='PO') AND (charass_target_id=_poheadid) AND (charass_char_id=_c.charass_char_id) AND (charass_value=_c.charass_value) ); IF (NOT FOUND) THEN INSERT INTO charass ( charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price ) VALUES ( 'PO', _poheadid, _c.charass_char_id, _c.charass_value, _c.charass_default, _c.charass_price ); END IF; END LOOP; SELECT NEXTVAL('poitem_poitem_id_seq') INTO _poitemid; SELECT (COALESCE(MAX(poitem_linenumber), 0) + 1) INTO _polinenumber FROM poitem WHERE (poitem_pohead_id = _poheadid); SELECT COALESCE(itemtax_taxtype_id, -1) INTO _taxtypeid FROM itemtax WHERE (itemtax_item_id = _i.itemsrc_item_id); IF (pPrice IS NULL) THEN SELECT itemsrcPrice(pItemSourceId, COALESCE(_s.quhead_warehous_id, -1), pDropShip, (_s.orderqty / COALESCE(_i.itemsrc_invvendoruomratio, 1.00)), COALESCE(_i.vend_curr_id, baseCurrId()), CURRENT_DATE) INTO _price; ELSE _price := pPrice; END IF; INSERT INTO poitem ( poitem_id, poitem_status, poitem_pohead_id, poitem_linenumber, poitem_duedate, poitem_itemsite_id, poitem_vend_item_descrip, poitem_vend_uom, poitem_invvenduomratio, poitem_qty_ordered, poitem_unitprice, poitem_vend_item_number, poitem_itemsrc_id, poitem_order_id, poitem_order_type, poitem_prj_id, poitem_stdcost, poitem_manuf_name, poitem_manuf_item_number, poitem_manuf_item_descrip, poitem_taxtype_id, poitem_comments ) VALUES ( _poitemid, 'U', _poheadid, _polinenumber, _s.quitem_scheddate, _s.quitem_itemsite_id, COALESCE(_i.itemsrc_vend_item_descrip, TEXT('')), COALESCE(_i.itemsrc_vend_uom, TEXT('')), COALESCE(_i.itemsrc_invvendoruomratio, 1.00), (_s.orderqty / COALESCE(_i.itemsrc_invvendoruomratio, 1.00)), _price, COALESCE(_i.itemsrc_vend_item_number, TEXT('')), pItemSourceId, pQuitemId, 'Q', _s.quhead_prj_id, stdcost(_i.itemsrc_item_id), COALESCE(_i.itemsrc_manuf_name, TEXT('')), COALESCE(_i.itemsrc_manuf_item_number, TEXT('')), COALESCE(_i.itemsrc_manuf_item_descrip, TEXT('')), _taxtypeid, COALESCE(_s.quitem_memo, TEXT(''))); -- Copy characteristics from the quitem to the poitem INSERT INTO charass ( charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price ) SELECT 'PI', _poitemid, charass_char_id, charass_value, charass_default, charass_price FROM charass JOIN char ON char_id = charass_char_id JOIN charuse ON char_id = charuse_char_id AND charuse_target_type = 'PI' WHERE charass_target_type = 'QI' AND charass_target_id = pQuitemId; -- Generate the PoItemCreatedBySo event notice PERFORM postEvent('PoItemCreatedBySo', 'P', poitem_id, itemsite_warehous_id, (pohead_number || '-'|| poitem_linenumber || ': ' || item_number), NULL, NULL, NULL, NULL) FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id) JOIN itemsite ON (itemsite_id=poitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (poitem_id=_poitemid) AND (poitem_duedate <= (CURRENT_DATE + itemsite_eventfence)); RETURN _poitemid; END; $$; yDROP FUNCTION public.createpurchasetoquote(pquitemid integer, pitemsourceid integer, pdropship boolean, pprice numeric); publicadminfalse46238125578222/createpurchasetosale(integer, integer, boolean)FUNCTIONCREATE FUNCTION createpurchasetosale(integer, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCoitemId ALIAS FOR $1; pItemSourceId ALIAS FOR $2; pDropShip ALIAS FOR $3; BEGIN RETURN createPurchaseToSale(pCoitemId, pItemSourceId, pDropShip, NULL, NULL, NULL); END; $_$; FDROP FUNCTION public.createpurchasetosale(integer, integer, boolean); publicadminfalse846231255782238createpurchasetosale(integer, integer, boolean, numeric)FUNCTIONCREATE FUNCTION createpurchasetosale(integer, integer, boolean, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCoitemId ALIAS FOR $1; pItemSourceId ALIAS FOR $2; pDropShip ALIAS FOR $3; pPrice ALIAS FOR $4; BEGIN RETURN createPurchaseToSale(pCoitemId, pItemSourceId, pDropShip, NULL, NULL, pPrice); END; $_$; ODROP FUNCTION public.createpurchasetosale(integer, integer, boolean, numeric); publicadminfalse84623125578224Gcreatepurchasetosale(integer, integer, boolean, numeric, date, numeric)FUNCTIONCREATE FUNCTION createpurchasetosale(integer, integer, boolean, numeric, date, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCoitemId ALIAS FOR $1; pItemSourceId ALIAS FOR $2; pDropShip ALIAS FOR $3; pQty ALIAS FOR $4; pDueDate ALIAS FOR $5; pPrice ALIAS FOR $6; BEGIN RETURN createPurchaseToSale(pCoitemId, pItemSourceId, pDropShip, pQty, pDueDate, pPrice, NULL); END; $_$; ^DROP FUNCTION public.createpurchasetosale(integer, integer, boolean, numeric, date, numeric); publicadminfalse46238125587009Pcreatepurchasetosale(integer, integer, boolean, numeric, date, numeric, integer)FUNCTION?CREATE FUNCTION createpurchasetosale(pcoitemid integer, pitemsourceid integer, pdropship boolean, pqty numeric, pduedate date, pprice numeric, ppoheadid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _s RECORD; _w RECORD; _i RECORD; _c RECORD; _poheadid INTEGER := -1; _poitemid INTEGER := -1; _taxtypeid INTEGER := -1; _charassid INTEGER := -1; _polinenumber INTEGER; _ponumber NUMERIC; _price NUMERIC; _temp INTEGER; BEGIN -- Check for existing poitem for this coitem SELECT poitem_id INTO _poitemid FROM poitem WHERE (poitem_order_id=pCoitemId) AND (poitem_order_type='S'); IF (FOUND) THEN RETURN _poitemid; END IF; SELECT *, COALESCE(roundQty(item_fractional, (coitem_qtyord * coitem_qty_invuomratio)), 0.0) AS orderqty INTO _s FROM coitem JOIN cohead ON (cohead_id = coitem_cohead_id) LEFT OUTER JOIN shiptoinfo ON (cohead_shipto_id = shipto_id) LEFT OUTER JOIN addr ON (shipto_addr_id = addr_id) LEFT OUTER JOIN cntct ON (shipto_cntct_id = cntct_id) LEFT OUTER JOIN itemsite ON (coitem_itemsite_id = itemsite_id) LEFT OUTER JOIN item ON (item_id = itemsite_item_id) WHERE (coitem_id = pCoitemId); IF (NOT FOUND) THEN RETURN -1; END IF; SELECT * INTO _w FROM itemsite JOIN whsinfo ON (warehous_id = itemsite_warehous_id) LEFT OUTER JOIN addr ON (warehous_addr_id = addr_id) LEFT OUTER JOIN cntct ON (warehous_cntct_id = cntct_id) WHERE (itemsite_id = _s.itemsite_id); SELECT * INTO _i FROM itemsrc JOIN vendinfo ON (itemsrc_vend_id = vend_id) LEFT OUTER JOIN cntct ON (vend_cntct1_id = cntct_id) LEFT OUTER JOIN addr ON (vend_addr_id = addr_id) WHERE (itemsrc_id = pItemSourceId); IF (NOT FOUND) THEN RETURN -2; END IF; -- pPoheadId - NULL=add to existing PO if one exists -- -1=must create new PO -- >0=must add to existing specified PO IF (pDropShip) THEN SELECT COALESCE(pohead_id, -1) INTO _temp FROM pohead WHERE ( (pohead_status = 'U') AND (pohead_vend_id = _i.itemsrc_vend_id) AND (COALESCE(pohead_shiptoname, '') = COALESCE(_s.cohead_shiptoname, _s.shipto_name, '')) AND (COALESCE(pohead_shiptoaddress1, '') = COALESCE(_s.cohead_shiptoaddress1, _s.addr_line1, '')) AND (COALESCE(pohead_shiptoaddress2, '') = COALESCE(_s.cohead_shiptoaddress2, _s.addr_line2, '')) AND (COALESCE(pohead_shiptoaddress3, '') = COALESCE(_s.cohead_shiptoaddress3, _s.addr_line3, '')) AND (COALESCE(pohead_shiptocity, '') = COALESCE(_s.cohead_shiptocity, _s.addr_city, '')) AND (COALESCE(pohead_shiptostate, '') = COALESCE(_s.cohead_shiptostate, _s.addr_state, '')) AND (COALESCE(pohead_shiptozipcode, '') = COALESCE(_s.cohead_shiptozipcode, _s.addr_postalcode, '')) AND (COALESCE(pohead_shiptocountry, '') = COALESCE(_s.cohead_shiptocountry, _s.addr_country, '')) AND ((pohead_id=pPoheadId) OR (pPoheadid IS NULL)) ); ELSE SELECT COALESCE(pohead_id, -1) INTO _temp FROM pohead WHERE ( (pohead_status = 'U') AND (pohead_vend_id = _i.itemsrc_vend_id) AND (COALESCE(pohead_shiptoaddress1, '') = COALESCE(_w.addr_line1, '')) AND (COALESCE(pohead_shiptoaddress2, '') = COALESCE(_w.addr_line2, '')) AND (COALESCE(pohead_shiptoaddress3, '') = COALESCE(_w.addr_line3, '')) AND (COALESCE(pohead_shiptocity, '') = COALESCE(_w.addr_city, '')) AND (COALESCE(pohead_shiptostate, '') = COALESCE(_w.addr_state, '')) AND (COALESCE(pohead_shiptozipcode, '') = COALESCE(_w.addr_postalcode, '')) AND (COALESCE(pohead_shiptocountry, '') = COALESCE(_w.addr_country, '')) AND ((pohead_id=pPoheadId) OR (pPoheadid IS NULL)) ); END IF; IF (FOUND) THEN IF (pPoheadId = -1) THEN RAISE EXCEPTION 'Problem creating new PO'; END IF; _poheadid := _temp; UPDATE pohead SET pohead_dropship = pDropShip WHERE (pohead_id = _poheadid); ELSE IF (pPoheadId > 0) THEN RAISE EXCEPTION 'Problem adding to existing PO'; END IF; SELECT NEXTVAL('pohead_pohead_id_seq') INTO _poheadid; SELECT fetchPoNumber() INTO _ponumber; IF (pDropShip) THEN INSERT INTO pohead ( pohead_id, pohead_number, pohead_status, pohead_dropship, pohead_agent_username, pohead_vend_id, pohead_taxzone_id, pohead_orderdate, pohead_curr_id, pohead_cohead_id, pohead_warehous_id, pohead_shipvia, pohead_terms_id, pohead_shipto_cntct_id, pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name, pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name, pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone, pohead_shipto_cntct_title, pohead_shipto_cntct_fax, pohead_shipto_cntct_email, pohead_shiptoaddress_id, pohead_shiptoname, pohead_shiptoaddress1, pohead_shiptoaddress2, pohead_shiptoaddress3, pohead_shiptocity, pohead_shiptostate, pohead_shiptozipcode, pohead_shiptocountry, pohead_vend_cntct_id, pohead_vend_cntct_honorific, pohead_vend_cntct_first_name, pohead_vend_cntct_middle, pohead_vend_cntct_last_name, pohead_vend_cntct_suffix, pohead_vend_cntct_phone, pohead_vend_cntct_title, pohead_vend_cntct_fax, pohead_vend_cntct_email, pohead_vendaddress1, pohead_vendaddress2, pohead_vendaddress3, pohead_vendcity, pohead_vendstate, pohead_vendzipcode, pohead_vendcountry, pohead_comments ) VALUES ( _poheadid, _ponumber, 'U', pDropShip, getEffectiveXtUser(), _i.itemsrc_vend_id, _i.vend_taxzone_id, CURRENT_DATE, COALESCE(_i.vend_curr_id, basecurrid()), _s.cohead_id, COALESCE(_s.cohead_warehous_id, -1), COALESCE(_i.vend_shipvia, TEXT('')), COALESCE(_i.vend_terms_id, -1), COALESCE(_s.cohead_shipto_cntct_id, _s.shipto_cntct_id), COALESCE(_s.cohead_shipto_cntct_honorific, _s.cntct_honorific), COALESCE(_s.cohead_shipto_cntct_first_name, _s.cntct_first_name), COALESCE(_s.cohead_shipto_cntct_middle, _s.cntct_middle), COALESCE(_s.cohead_shipto_cntct_last_name, _s.cntct_last_name), COALESCE(_s.cohead_shipto_cntct_suffix, _s.cntct_suffix), COALESCE(_s.cohead_shipto_cntct_phone, _s.cntct_phone), COALESCE(_s.cohead_shipto_cntct_title, _s.cntct_title), COALESCE(_s.cohead_shipto_cntct_fax, _s.cntct_fax), COALESCE(_s.cohead_shipto_cntct_email, _s.cntct_email), COALESCE(_s.shipto_addr_id, _s.addr_id), COALESCE(_s.cohead_shiptoname, _s.shipto_name, ''), COALESCE(_s.cohead_shiptoaddress1, _s.addr_line1, ''), COALESCE(_s.cohead_shiptoaddress2, _s.addr_line2, ''), COALESCE(_s.cohead_shiptoaddress3, _s.addr_line3, ''), COALESCE(_s.cohead_shiptocity, _s.addr_city, ''), COALESCE(_s.cohead_shiptostate, _s.addr_state, ''), COALESCE(_s.cohead_shiptozipcode, _s.addr_postalcode, ''), COALESCE(_s.cohead_shiptocountry, _s.addr_country, ''), _i.cntct_id, COALESCE(_i.cntct_honorific, TEXT('')), COALESCE(_i.cntct_first_name, TEXT('')), COALESCE(_i.cntct_middle, TEXT('')), COALESCE(_i.cntct_last_name, TEXT('')), COALESCE(_i.cntct_suffix, TEXT('')), COALESCE(_i.cntct_phone, TEXT('')), COALESCE(_i.cntct_title, TEXT('')), COALESCE(_i.cntct_fax, TEXT('')), COALESCE(_i.cntct_email, TEXT('')), COALESCE(_i.addr_line1, TEXT('')), COALESCE(_i.addr_line2, TEXT('')), COALESCE(_i.addr_line3, TEXT('')), COALESCE(_i.addr_city, TEXT('')), COALESCE(_i.addr_state, TEXT('')), COALESCE(_i.addr_postalcode, TEXT('')), COALESCE(_i.addr_country, TEXT('')), COALESCE(_s.cohead_shipcomments, TEXT('')) ); ELSE INSERT INTO pohead ( pohead_id, pohead_number, pohead_status, pohead_dropship, pohead_agent_username, pohead_vend_id, pohead_taxzone_id, pohead_orderdate, pohead_curr_id, pohead_cohead_id, pohead_warehous_id, pohead_shipvia, pohead_terms_id, pohead_shipto_cntct_id, pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name, pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name, pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone, pohead_shipto_cntct_title, pohead_shipto_cntct_fax, pohead_shipto_cntct_email, pohead_shiptoaddress_id, pohead_shiptoaddress1, pohead_shiptoaddress2, pohead_shiptoaddress3, pohead_shiptocity, pohead_shiptostate, pohead_shiptozipcode, pohead_shiptocountry, pohead_vend_cntct_id, pohead_vend_cntct_honorific, pohead_vend_cntct_first_name, pohead_vend_cntct_middle, pohead_vend_cntct_last_name, pohead_vend_cntct_suffix, pohead_vend_cntct_phone, pohead_vend_cntct_title, pohead_vend_cntct_fax, pohead_vend_cntct_email, pohead_vendaddress1, pohead_vendaddress2, pohead_vendaddress3, pohead_vendcity, pohead_vendstate, pohead_vendzipcode, pohead_vendcountry ) VALUES ( _poheadid, _ponumber, 'U', pDropShip, getEffectiveXtUser(), _i.itemsrc_vend_id, _i.vend_taxzone_id, CURRENT_DATE, COALESCE(_i.vend_curr_id, basecurrid()), _s.cohead_id, COALESCE(_s.cohead_warehous_id, -1), COALESCE(_i.vend_shipvia, TEXT('')), COALESCE(_i.vend_terms_id, -1), _w.cntct_id, _w.cntct_honorific, _w.cntct_first_name, _w.cntct_middle, _w.cntct_last_name, _w.cntct_suffix, _w.cntct_phone, _w.cntct_title, _w.cntct_fax, _w.cntct_email, _w.addr_id, COALESCE(_w.addr_line1, ''), COALESCE(_w.addr_line2, ''), COALESCE(_w.addr_line3, ''), COALESCE(_w.addr_city, ''), COALESCE(_w.addr_state, ''), COALESCE(_w.addr_postalcode, ''), COALESCE(_w.addr_country, ''), _i.cntct_id, COALESCE(_i.cntct_honorific, TEXT('')), COALESCE(_i.cntct_first_name, TEXT('')), COALESCE(_i.cntct_middle, TEXT('')), COALESCE(_i.cntct_last_name, TEXT('')), COALESCE(_i.cntct_suffix, TEXT('')), COALESCE(_i.cntct_phone, TEXT('')), COALESCE(_i.cntct_title, TEXT('')), COALESCE(_i.cntct_fax, TEXT('')), COALESCE(_i.cntct_email, TEXT('')), COALESCE(_i.addr_line1, TEXT('')), COALESCE(_i.addr_line2, TEXT('')), COALESCE(_i.addr_line3, TEXT('')), COALESCE(_i.addr_city, TEXT('')), COALESCE(_i.addr_state, TEXT('')), COALESCE(_i.addr_postalcode, TEXT('')), COALESCE(_i.addr_country, TEXT('')) ); END IF; END IF; -- Copy characteristics from the cohead to the pohead -- while avoiding duplicates FOR _c IN SELECT charass.* FROM charass JOIN char ON char_id = charass_char_id JOIN charuse ON char_id = charuse_char_id AND charuse_target_type = 'PO' WHERE charass_target_type = 'SO' AND charass_target_id = _s.cohead_id LOOP SELECT charass_id INTO _charassid FROM charass WHERE ( (charass_target_type='PO') AND (charass_target_id=_poheadid) AND (charass_char_id=_c.charass_char_id) AND (charass_value=_c.charass_value) ); IF (NOT FOUND) THEN INSERT INTO charass ( charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price ) VALUES ( 'PO', _poheadid, _c.charass_char_id, _c.charass_value, _c.charass_default, _c.charass_price ); END IF; END LOOP; SELECT NEXTVAL('poitem_poitem_id_seq') INTO _poitemid; SELECT (COALESCE(MAX(poitem_linenumber), 0) + 1) INTO _polinenumber FROM poitem WHERE (poitem_pohead_id = _poheadid); SELECT COALESCE(itemtax_taxtype_id, -1) INTO _taxtypeid FROM itemtax WHERE (itemtax_item_id = _i.itemsrc_item_id); IF (pPrice IS NULL) THEN SELECT itemsrcPrice(pItemSourceId, COALESCE(_s.cohead_warehous_id, -1), pDropShip, (COALESCE(pQty, _s.orderqty) / COALESCE(_i.itemsrc_invvendoruomratio, 1.00)), COALESCE(_i.vend_curr_id, baseCurrId()), CURRENT_DATE) INTO _price; ELSE _price := pPrice; END IF; IF (pDropShip) THEN INSERT INTO poitem ( poitem_id, poitem_status, poitem_pohead_id, poitem_linenumber, poitem_duedate, poitem_itemsite_id, poitem_vend_item_descrip, poitem_vend_uom, poitem_invvenduomratio, poitem_qty_ordered, poitem_unitprice, poitem_vend_item_number, poitem_itemsrc_id, poitem_order_id, poitem_order_type, poitem_prj_id, poitem_stdcost, poitem_manuf_name, poitem_manuf_item_number, poitem_manuf_item_descrip, poitem_taxtype_id, poitem_comments ) VALUES ( _poitemid, 'U', _poheadid, _polinenumber, COALESCE(pDueDate, _s.coitem_scheddate), _s.coitem_itemsite_id, COALESCE(_i.itemsrc_vend_item_descrip, TEXT('')), COALESCE(_i.itemsrc_vend_uom, TEXT('')), COALESCE(_i.itemsrc_invvendoruomratio, 1.00), (COALESCE(pQty, _s.orderqty) / COALESCE(_i.itemsrc_invvendoruomratio, 1.00)), _price, COALESCE(_i.itemsrc_vend_item_number, TEXT('')), pItemSourceId, pCoitemId, 'S', _s.cohead_prj_id, stdcost(_i.itemsrc_item_id), COALESCE(_i.itemsrc_manuf_name, TEXT('')), COALESCE(_i.itemsrc_manuf_item_number, TEXT('')), COALESCE(_i.itemsrc_manuf_item_descrip, TEXT('')), _taxtypeid, COALESCE(_s.coitem_memo, TEXT(''))); ELSE INSERT INTO poitem ( poitem_id, poitem_status, poitem_pohead_id, poitem_linenumber, poitem_duedate, poitem_itemsite_id, poitem_vend_item_descrip, poitem_vend_uom, poitem_invvenduomratio, poitem_qty_ordered, poitem_unitprice, poitem_vend_item_number, poitem_itemsrc_id, poitem_order_id, poitem_order_type, poitem_prj_id, poitem_stdcost, poitem_manuf_name, poitem_manuf_item_number, poitem_manuf_item_descrip, poitem_taxtype_id, poitem_comments ) VALUES ( _poitemid, 'U', _poheadid, _polinenumber, COALESCE(pDueDate, _s.coitem_scheddate), _s.coitem_itemsite_id, COALESCE(_i.itemsrc_vend_item_descrip, TEXT('')), COALESCE(_i.itemsrc_vend_uom, TEXT('')), COALESCE(_i.itemsrc_invvendoruomratio, 1.00), (COALESCE(pQty, _s.orderqty) / COALESCE(_i.itemsrc_invvendoruomratio, 1.00)), _price, COALESCE(_i.itemsrc_vend_item_number, TEXT('')), pItemSourceId, pCoitemId, 'S', _s.cohead_prj_id, stdcost(_i.itemsrc_item_id), COALESCE(_i.itemsrc_manuf_name, TEXT('')), COALESCE(_i.itemsrc_manuf_item_number, TEXT('')), COALESCE(_i.itemsrc_manuf_item_descrip, TEXT('')), _taxtypeid, COALESCE(_s.coitem_memo, TEXT(''))); END IF; -- Copy characteristics from the coitem to the poitem INSERT INTO charass ( charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price ) SELECT 'PI', _poitemid, charass_char_id, charass_value, charass_default, charass_price FROM charass JOIN char ON char_id = charass_char_id JOIN charuse ON char_id = charuse_char_id AND charuse_target_type = 'PI' WHERE charass_target_type = 'SI' AND charass_target_id = pCoitemId; UPDATE coitem SET coitem_order_type = 'P', coitem_order_id = _poitemid WHERE ( coitem_id = pCoitemId ); -- Generate the PoItemCreatedBySo event notice PERFORM postEvent('PoItemCreatedBySo', 'P', poitem_id, itemsite_warehous_id, (pohead_number || '-'|| poitem_linenumber || ': ' || item_number), NULL, NULL, NULL, NULL) FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id) JOIN itemsite ON (itemsite_id=poitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (poitem_id=_poitemid) AND (poitem_duedate <= (CURRENT_DATE + itemsite_eventfence)); RETURN _poitemid; END; $$; DROP FUNCTION public.createpurchasetosale(pcoitemid integer, pitemsourceid integer, pdropship boolean, pqty numeric, pduedate date, pprice numeric, ppoheadid integer); publicadminfalse46238125578226createrecurringinvoices()FUNCTIONCREATE FUNCTION createrecurringinvoices() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'createRecurringInvoices() has been deprecated; use createRecurringItems(NULL, ''I'') instead.'; RETURN createRecurringItems(NULL, 'I'); END; $$; 0DROP FUNCTION public.createrecurringinvoices(); publicadminfalse46238125578227#createrecurringitems(integer, text)FUNCTIONtCREATE FUNCTION createrecurringitems(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pParentid ALIAS FOR $1; -- if NULL then all items with the given pType pType TEXT := UPPER($2); -- if NULL then all types -- if both are null then all items of all types _copystmt TEXT; _count INTEGER := 0; _countstmt TEXT; _existcnt INTEGER; _id INTEGER; _interval TEXT; _last TIMESTAMP WITH TIME ZONE; _loopcount INTEGER := 1; _maxstmt TEXT; _maxdate TIMESTAMP WITH TIME ZONE := endOfTime(); _result INTEGER := 0; _next TIMESTAMP WITH TIME ZONE; _r RECORD; _rt RECORD; _tmp INTEGER; BEGIN RAISE DEBUG 'createRecurringItems(%, %) entered', pParentid, pType; FOR _r IN SELECT * FROM recur WHERE ((COALESCE(recur_end, endOfTime()) >= CURRENT_TIMESTAMP) AND (pParentid IS NULL OR recur_parent_id=pParentid) AND (pType IS NULL OR UPPER(recur_parent_type)=UPPER(pType))) LOOP RAISE DEBUG 'createRecurringItems looking at recur %, %', _r.recur_id, _r.recur_parent_type; _r.recur_max := COALESCE(_r.recur_max, CAST(fetchMetricValue('RecurringInvoiceBuffer') AS INTEGER), 1); _interval := CASE _r.recur_period WHEN 'Y' THEN ' year' WHEN 'M' THEN ' month' WHEN 'W' THEN ' week' WHEN 'D' THEN ' day' WHEN 'H' THEN ' hour' WHEN 'm' THEN ' minute' ELSE NULL END; IF (_interval IS NULL OR COALESCE(_r.recur_freq, 0) <= 0) THEN RAISE EXCEPTION 'Unknown recurrence frequency % % ON % %', _r.recur_freq, _r.recur_period, _r.recur_parent_type, _r.recur_parent_id; END IF; SELECT * INTO _rt FROM recurtype WHERE (UPPER(recurtype_type)=UPPER(pType)); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count <= 0) THEN RETURN -10; END IF; -- if the recurrence type has a max lookahead window, use it IF (_r.recur_parent_type = 'I') THEN _maxdate := CURRENT_TIMESTAMP + CAST(fetchMetricText('RecurringInvoiceBuffer') || ' days' AS INTERVAL); END IF; IF (_r.recur_parent_type = 'V') THEN _maxdate := CURRENT_TIMESTAMP + CAST(fetchMetricText('RecurringVoucherBuffer') || ' days' AS INTERVAL); END IF; IF (_maxdate > _r.recur_end) THEN -- if recur_end is null, _maxdate is ok _maxdate = _r.recur_end; END IF; -- build statements dynamically from the recurtype table because packages -- might also require recurring items. this way the algorithm is fixed -- and the details are data-driven _countstmt := 'SELECT COUNT(*) FROM [fulltable]' || ' WHERE (($1=[table]_recurring_[table]_id)' || ' AND NOT([done]) ' || ' AND ([limit]));'; _countstmt := REPLACE(_countstmt, '[fulltable]', _rt.recurtype_table); _countstmt := REPLACE(_countstmt, '[table]', REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', '')); _countstmt := REPLACE(_countstmt, '[done]', _rt.recurtype_donecheck); _countstmt := REPLACE(_countstmt, '[limit]', COALESCE(_rt.recurtype_limit, 'TRUE')); _maxstmt := 'SELECT MAX([schedcol]) FROM [fulltable]' || ' WHERE (($1=[table]_recurring_[table]_id)' || ' AND ([limit]));'; _maxstmt := REPLACE(_maxstmt, '[schedcol]', _rt.recurtype_schedcol); _maxstmt := REPLACE(_maxstmt, '[fulltable]',_rt.recurtype_table); _maxstmt := REPLACE(_maxstmt, '[table]', REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', '')); _maxstmt := REPLACE(_maxstmt, '[limit]', COALESCE(_rt.recurtype_limit, 'TRUE')); _copystmt := 'SELECT [copy]($1, [datetime] [more]);'; _copystmt := REPLACE(_copystmt, '[copy]', _rt.recurtype_copyfunc); _copystmt := REPLACE(_copystmt, '[datetime]', CASE WHEN UPPER(_rt.recurtype_copyargs[2])='DATE' THEN 'CAST(''$2'' AS DATE)' ELSE '''$2''' END); -- 8.4+: -- _copystmt := REPLACE(_copystmt, '[more]', -- REPEAT(', NULL', -- array_length(_rt.recurtype_copyargs) - 2)); _tmp := CAST(REPLACE(REGEXP_REPLACE(array_dims(_rt.recurtype_copyargs), '.*:', ''), ']', '') AS INTEGER); _copystmt := REPLACE(_copystmt, '[more]', REPEAT(', NULL', _tmp - 2)); EXECUTE REPLACE(_countstmt, '$1', _r.recur_parent_id::TEXT) INTO _existcnt; EXECUTE REPLACE(_maxstmt, '$1', _r.recur_parent_id::TEXT) INTO _last; RAISE DEBUG E'% got %, % got %', _countstmt, _existcnt, _maxstmt, _last; _next := _last; _loopcount := 1; WHILE (_existcnt < _r.recur_max AND _next < _maxdate) LOOP _next := _last + CAST(_r.recur_freq * _loopcount || _interval AS INTERVAL); RAISE DEBUG 'createrecurringitems looping, existcnt = %, max = %, is % between % and %?', _existcnt, _r.recur_max, _next, _r.recur_start, _r.recur_end; IF (_next BETWEEN _r.recur_start AND _maxdate) THEN RAISE DEBUG 'createrecurringitems executing % with % and %', _copystmt, _r.recur_parent_id, _next; -- 8.4+: EXECUTE _copystmt INTO _id USING _r.recur_parent_id, _next; EXECUTE REPLACE(REPLACE(_copystmt, '$1', _r.recur_parent_id::TEXT), '$2', _next::TEXT) INTO _id; RAISE DEBUG 'Copying for % returned %', _next, _id; _result := _result + 1; _existcnt := _existcnt + 1; END IF; _loopcount := _loopcount + 1; END LOOP; END LOOP; RETURN _result; END; $_$; :DROP FUNCTION public.createrecurringitems(integer, text); publicadminfalse84623125578229|createtodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, text)FUNCTIONCREATE FUNCTION createtodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN createTodoItem($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, NULL); END; $_$; DROP FUNCTION public.createtodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, text); publicadminfalse84623125578230createtodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, text, integer)FUNCTIONd CREATE FUNCTION createtodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ptodoid ALIAS FOR $1; pusername ALIAS FOR $2; pname ALIAS FOR $3; pdesc ALIAS FOR $4; pincdtid ALIAS FOR $5; pcrmacctid ALIAS FOR $6; pOpheadid ALIAS FOR $7; pstarted ALIAS FOR $8; pdue ALIAS FOR $9; pstatus ALIAS FOR $10; passigned ALIAS FOR $11; pcompleted ALIAS FOR $12; ppriority ALIAS FOR $13; pnotes ALIAS FOR $14; powner ALIAS FOR $15; pcntctid ALIAS FOR $16; _todoid INTEGER; _priority INTEGER := ppriority; _status CHARACTER(1) := pstatus; _incdtid INTEGER := pincdtid; _crmacctid INTEGER := pcrmacctid; _opheadid INTEGER := pOpheadid; _assigned DATE := passigned; _result INTEGER; BEGIN IF (pusername IS NULL OR pusername = '') THEN RETURN -1; END IF; IF (pname IS NULL OR pname = '') THEN RETURN -2; END IF; IF (pdue IS NULL) THEN RETURN -3; END IF; IF (pcompleted IS NOT NULL) THEN _status := 'C'; ELSIF (pstatus IS NULL AND pstarted IS NOT NULL) THEN _status := 'I'; ELSIF (pstatus IS NULL) THEN _status := 'N'; END IF; IF (_incdtid <= 0) THEN _incdtid := NULL; END IF; IF (_crmacctid <= 0) THEN _crmacctid := NULL; END IF; IF (_opheadid <= 0) THEN _opheadid := NULL; END IF; IF (_priority <= 0) THEN _priority := NULL; END IF; IF (_assigned IS NULL) THEN _assigned := CURRENT_DATE; END IF; IF (ptodoid IS NULL) THEN SELECT NEXTVAL('todoitem_todoitem_id_seq') INTO _todoid; ELSE _todoid := ptodoid; END IF; INSERT INTO todoitem ( todoitem_id, todoitem_username, todoitem_name, todoitem_description, todoitem_incdt_id, todoitem_creator_username, todoitem_status, todoitem_active, todoitem_start_date, todoitem_due_date, todoitem_assigned_date, todoitem_completed_date, todoitem_priority_id, todoitem_notes, todoitem_crmacct_id, todoitem_ophead_id, todoitem_owner_username, todoitem_cntct_id ) VALUES ( _todoid, pusername, pname, pdesc, _incdtid, getEffectiveXtUser(), _status, TRUE, pstarted, pdue, _assigned, pcompleted, _priority, pnotes, _crmacctid, _opheadid, powner, pcntctid ); RETURN _todoid; END; $_$; DROP FUNCTION public.createtodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, text, integer); publicadminfalse46238125578231createurl(text, text)FUNCTION.CREATE FUNCTION createurl(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ declare pTitle ALIAS FOR $1; pUrl ALIAS FOR $2; _id integer; begin _id := nextval('urlinfo_url_id_seq'); insert into urlinfo (url_id, url_title, url_url) values (_id, pTitle, pUrl); return _id; end; $_$; ,DROP FUNCTION public.createurl(text, text); publicadminfalse84623125587012createuser(text, boolean)FUNCTIONCREATE FUNCTION createuser(pusername text, pcreateusers boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pCreateUsers) THEN EXECUTE 'CREATE USER "' || pUsername || '" CREATEROLE IN GROUP xtrole;'; ELSE EXECUTE 'CREATE USER "' || pUsername || '" NOCREATEROLE IN GROUP xtrole;'; END IF; RETURN 1; END; $$; GDROP FUNCTION public.createuser(pusername text, pcreateusers boolean); publicadminfalse846231255782338createwo(integer, integer, numeric, integer, date, text)FUNCTION`CREATE FUNCTION createwo(integer, integer, numeric, integer, date, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pQtyOrdered ALIAS FOR $3; pLeadTime ALIAS FOR $4; pDueDate ALIAS FOR $5; pProductionNotes ALIAS FOR $6; BEGIN RETURN createWo( pWoNumber, pItemsiteid, 1, pQtyOrdered, (pDueDate - pLeadTime), pDueDate, pProductionNotes, NULL, NULL, -1 ); END; $_$; ODROP FUNCTION public.createwo(integer, integer, numeric, integer, date, text); publicadminfalse462381255782345createwo(integer, integer, numeric, date, date, text)FUNCTION=CREATE FUNCTION createwo(integer, integer, numeric, date, date, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pQtyOrdered ALIAS FOR $3; pStartDate ALIAS FOR $4; pDueDate ALIAS FOR $5; pProductionNotes ALIAS FOR $6; BEGIN RETURN createWo( pWoNumber, pItemsiteid, 1, pQtyOrdered, pStartDate, pDueDate, pProductionNotes, NULL, NULL, -1); END; $_$; LDROP FUNCTION public.createwo(integer, integer, numeric, date, date, text); publicadminfalse46238125578235Lcreatewo(integer, integer, numeric, integer, date, text, character, integer)FUNCTIONCREATE FUNCTION createwo(integer, integer, numeric, integer, date, text, character, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pQtyOrdered ALIAS FOR $3; pLeadTime ALIAS FOR $4; pDueDate ALIAS FOR $5; pProductionNotes ALIAS FOR $6; pParentType ALIAS FOR $7; pParentId ALIAS FOR $8; BEGIN RETURN createWo( pWoNumber, pItemsiteid, 1, pQtyOrdered, (pDueDate - pLeadTime), pDueDate, pProductionNotes, pParentType, pParentId, -1 ); END; $_$; cDROP FUNCTION public.createwo(integer, integer, numeric, integer, date, text, character, integer); publicadminfalse46238125578236Ucreatewo(integer, integer, integer, numeric, integer, date, text, character, integer)FUNCTIONCREATE FUNCTION createwo(integer, integer, integer, numeric, integer, date, text, character, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pPriority ALIAS FOR $3; pQtyOrdered ALIAS FOR $4; pLeadTime ALIAS FOR $5; pDueDate ALIAS FOR $6; pProductionNotes ALIAS FOR $7; pParentType ALIAS FOR $8; pParentId ALIAS FOR $9; BEGIN RETURN createWo(pWoNumber, pItemsiteid, pPriority, pQtyOrdered, (pDueDate - pLeadTime), pDueDate, pProductionNotes, pParentType, pParentId, -1); END; $_$; lDROP FUNCTION public.createwo(integer, integer, integer, numeric, integer, date, text, character, integer); publicadminfalse46238 125578237^createwo(integer, integer, integer, numeric, integer, date, text, character, integer, integer)FUNCTION CREATE FUNCTION createwo(integer, integer, integer, numeric, integer, date, text, character, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pPriority ALIAS FOR $3; pQtyOrdered ALIAS FOR $4; pLeadTime ALIAS FOR $5; pDueDate ALIAS FOR $6; pProductionNotes ALIAS FOR $7; pParentType ALIAS FOR $8; pParentId ALIAS FOR $9; pProjectId ALIAS FOR $10; BEGIN RETURN createWo(pWoNumber, pItemsiteid, pPriority, pQtyOrdered, (pDueDate - pLeadTime), pDueDate, pProductionNotes, pParentType, pParentId, pProjectId); END; $_$; uDROP FUNCTION public.createwo(integer, integer, integer, numeric, integer, date, text, character, integer, integer); publicadminfalse46238 125578238[createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer)FUNCTIONfCREATE FUNCTION createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pPriority ALIAS FOR $3; pQtyOrdered ALIAS FOR $4; pStartDate ALIAS FOR $5; pDueDate ALIAS FOR $6; pProductionNotes ALIAS FOR $7; pParentType ALIAS FOR $8; pParentId ALIAS FOR $9; pProjectId ALIAS FOR $10; _woid INTEGER; _result INTEGER; _parentType char(1); _bomrevid INTEGER; _boorevid INTEGER; BEGIN SELECT getActiveRevId('BOM',itemsite_item_id) INTO _bomrevid FROM itemsite WHERE (itemsite_id=pItemsiteid); SELECT getActiveRevId('BOO',itemsite_item_id) INTO _boorevid FROM itemsite WHERE (itemsite_id=pItemsiteid); RETURN createWo(pWoNumber, pItemsiteid, pPriority, pQtyOrdered, pStartDate, pDueDate, pProductionNotes, pParentType, pParentId, pProjectId, _bomrevid, _boorevid, NULL); END; $_$; rDROP FUNCTION public.createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer); publicadminfalse84623 125578239pcreatewo(integer, integer, integer, numeric, integer, date, text, character, integer, integer, integer, integer)FUNCTIONmCREATE FUNCTION createwo(integer, integer, integer, numeric, integer, date, text, character, integer, integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pPriority ALIAS FOR $3; pQtyOrdered ALIAS FOR $4; pLeadTime ALIAS FOR $5; pDueDate ALIAS FOR $6; pProductionNotes ALIAS FOR $7; pParentType ALIAS FOR $8; pParentId ALIAS FOR $9; pProjectId ALIAS FOR $10; pBomRevId ALIAS FOR $11; pBooRevId ALIAS FOR $12; BEGIN RETURN createWo(pWoNumber, pItemsiteid, pPriority, pQtyOrdered, (pDueDate - pLeadTime), pDueDate, pProductionNotes, pParentType, pParentId, pProjectId, pBomRevId, pBooRevId, NULL); END; $_$; DROP FUNCTION public.createwo(integer, integer, integer, numeric, integer, date, text, character, integer, integer, integer, integer); publicadminfalse46238 125578240mcreatewo(integer, integer, integer, numeric, date, date, text, character, integer, integer, integer, integer)FUNCTION^CREATE FUNCTION createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pPriority ALIAS FOR $3; pQtyOrdered ALIAS FOR $4; pStartDate ALIAS FOR $5; pDueDate ALIAS FOR $6; pProductionNotes ALIAS FOR $7; pParentType ALIAS FOR $8; pParentId ALIAS FOR $9; pProjectId ALIAS FOR $10; pBomRevId ALIAS FOR $11; pBooRevId ALIAS FOR $12; BEGIN RETURN createWo(pWoNumber, pItemsiteid, pPriority, pQtyOrdered, pStartDate, pDueDate, pProductionNotes, pParentType, pParentId, pProjectId, pBomRevId, pBooRevId, NULL); END; $_$; DROP FUNCTION public.createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer, integer, integer); publicadminfalse84623 125578241screatewo(integer, integer, integer, numeric, date, date, text, character, integer, integer, integer, integer, text)FUNCTION CREATE FUNCTION createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer, integer, integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoNumber ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pPriority ALIAS FOR $3; pQtyOrdered ALIAS FOR $4; pStartDate ALIAS FOR $5; pDueDate ALIAS FOR $6; pProductionNotes ALIAS FOR $7; pParentType ALIAS FOR $8; pParentId ALIAS FOR $9; pProjectId ALIAS FOR $10; pBomRevId ALIAS FOR $11; pBooRevId ALIAS FOR $12; pCosMethod ALIAS FOR $13; _startDate DATE; _woid INTEGER; _result INTEGER; _parentType char(1); _parentId INTEGER; _cosmethod char(1); _itemsite RECORD; BEGIN _parentType := COALESCE(pParentType, ' '); _parentId := COALESCE(pParentId, -1); SELECT * INTO _itemsite FROM itemsite WHERE itemsite_id = pItemsiteid; -- Check to make sure the itemsite specified is supplied at itemsite IF (NOT _itemsite.itemsite_wosupply) THEN RETURN -1; END IF; -- Check to make sure if this is a job item that it is tied to a sales order -- Or if it is just an avarage costed item IF (pCosMethod IN ('D', 'P')) THEN _cosmethod := pCosMethod; ELSE IF (_itemsite.itemsite_costmethod = 'J') THEN IF (_parentType = ' ' OR _parentId = -1) THEN RAISE EXCEPTION 'Work Orders for Item Sites that are Job cost must have a parent order.'; ELSE SELECT COALESCE(itemsite_cosdefault,fetchmetrictext('JobItemCosDefault'),'D') INTO _cosmethod FROM itemsite WHERE itemsite_id=pItemsiteid; END IF; ELSIF (_itemsite.itemsite_costmethod = 'A') THEN _cosmethod := COALESCE(_itemsite.itemsite_cosdefault,fetchmetrictext('JobItemCosDefault'),'D'); END IF; END IF; -- Check to see if the site calendar metric is set, and if so adjust the start date if necessary IF (fetchmetricbool('UseSiteCalendar')) THEN _startDate := calculatenextworkingdate(_itemsite.itemsite_warehous_id, pStartDate, 0); IF (_startDate != pStartDate) THEN _startDate := calculatenextworkingdate(_itemsite.itemsite_warehous_id, pDueDate, -_itemsite.itemsite_leadtime); END IF; ELSE _startDate := pStartDate; END IF; -- Grab the next wo_id SELECT NEXTVAL('wo_wo_id_seq') INTO _woid; -- Create the W/O INSERT INTO wo ( wo_id, wo_number, wo_subnumber, wo_itemsite_id, wo_priority, wo_ordtype, wo_ordid, wo_status, wo_startdate, wo_duedate, wo_qtyord, wo_qtyrcv, wo_prodnotes, wo_prj_id, wo_bom_rev_id, wo_boo_rev_id, wo_cosmethod ) SELECT _woid, pWoNumber, nextWoSubnumber(pWoNumber), itemsite_id, pPriority, _parentType, pParentId, 'O', _startDate, pDueDate, roundQty(item_fractional, pQtyOrdered), 0, pProductionNotes, pProjectId, pBomRevid, pBooRevid, _cosmethod FROM itemsite, item WHERE ((itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid)); -- Explode the newly created W/O according to metrics IF ( ( SELECT (metric_value='t') FROM metric WHERE (metric_name='AutoExplodeWO') ) ) THEN SELECT explodeWo( _woid, ( SELECT (metric_value = 'M') FROM metric WHERE (metric_name='WOExplosionLevel') ) ) INTO _result; ELSE _result := _woid; END IF; RETURN _result; END; $_$; DROP FUNCTION public.createwo(integer, integer, integer, numeric, date, date, text, character, integer, integer, integer, integer, text); publicadminfalse84623125578242?createwomaterial(integer, integer, character, numeric, numeric)FUNCTIONCREATE FUNCTION createwomaterial(integer, integer, character, numeric, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pWoid ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pIssueMethod ALIAS FOR $3; pQtyPer ALIAS FOR $4; pScrap ALIAS FOR $5; _result INTEGER; BEGIN SELECT createWoMaterial(pWoid, pItemsiteid, pIssueMethod, item_inv_uom_id, pQtyPer, pScrap) INTO _result FROM itemsite JOIN item ON (itemsite_item_id=item_id) WHERE(itemsite_id=pItemsiteid); RETURN _result; END; $_$; VDROP FUNCTION public.createwomaterial(integer, integer, character, numeric, numeric); publicadminfalse84623125578243Hcreatewomaterial(integer, integer, character, integer, numeric, numeric)FUNCTIONCREATE FUNCTION createwomaterial(integer, integer, character, integer, numeric, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pWoid ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pIssueMethod ALIAS FOR $3; pUomId ALIAS FOR $4; pQtyPer ALIAS FOR $5; pScrap ALIAS FOR $6; _womatlid INTEGER; BEGIN SELECT createWoMaterial(pWoid,pItemsiteid,pIssueMethod,pUomId,pQtyPer,pScrap,-1, NULL, NULL) INTO _womatlid; RETURN _womatlid; END; $_$; _DROP FUNCTION public.createwomaterial(integer, integer, character, integer, numeric, numeric); publicadminfalse46238125578244Hcreatewomaterial(integer, integer, character, numeric, numeric, numeric)FUNCTIONCREATE FUNCTION createwomaterial(integer, integer, character, numeric, numeric, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pIssueMethod ALIAS FOR $3; pQtyFxd ALIAS FOR $4; pQtyPer ALIAS FOR $5; pScrap ALIAS FOR $6; _result INTEGER; BEGIN SELECT createWoMaterial(pWoid, pItemsiteid, pIssueMethod, item_inv_uom_id, pQtyFxd, pQtyPer, pScrap) INTO _result FROM itemsite JOIN item ON (itemsite_item_id=item_id) WHERE(itemsite_id=pItemsiteid); RETURN _result; END; $_$; _DROP FUNCTION public.createwomaterial(integer, integer, character, numeric, numeric, numeric); publicadminfalse46238125578245Qcreatewomaterial(integer, integer, character, integer, numeric, numeric, integer)FUNCTIONCREATE FUNCTION createwomaterial(integer, integer, character, integer, numeric, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pWoid ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pIssueMethod ALIAS FOR $3; pUomId ALIAS FOR $4; pQtyPer ALIAS FOR $5; pScrap ALIAS FOR $6; pBomitemId ALIAS FOR $7; _womatlid INTEGER; BEGIN _womatlid := (SELECT NEXTVAL('womatl_womatl_id_seq')); INSERT INTO womatl ( womatl_id, womatl_wo_id, womatl_itemsite_id, womatl_issuemethod, womatl_uom_id, womatl_qtyper, womatl_scrap, womatl_qtyreq, womatl_qtyiss, womatl_qtywipscrap, womatl_wooper_id, womatl_bomitem_id, womatl_duedate ) SELECT _womatlid, wo_id, pItemsiteid, pIssueMethod, pUomId, pQtyPer, pScrap, roundQty(item_fractional, (wo_qtyord * (pQtyPer * (1 + pScrap)))), 0, 0, -1, pBomitemId, wo_startdate FROM wo, itemsite, item WHERE ( (itemsite_item_id=item_id) AND (wo_id=pWoid) AND (itemsite_id=pItemsiteid) ); UPDATE wo SET wo_adhoc=TRUE WHERE (wo_id=pWoid); UPDATE wo SET wo_status='E' WHERE ( (wo_status='O') AND (wo_id=pWoid) ); RETURN _womatlid; END; $_$; hDROP FUNCTION public.createwomaterial(integer, integer, character, integer, numeric, numeric, integer); publicadminfalse84623125578246Qcreatewomaterial(integer, integer, character, integer, numeric, numeric, numeric)FUNCTIONzCREATE FUNCTION createwomaterial(integer, integer, character, integer, numeric, numeric, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pIssueMethod ALIAS FOR $3; pUomId ALIAS FOR $4; pQtyFxd ALIAS FOR $5; pQtyPer ALIAS FOR $6; pScrap ALIAS FOR $7; _womatlid INTEGER; BEGIN SELECT createWoMaterial(pWoid,pItemsiteid,pIssueMethod,pUomId,pQtyFxd,pQtyPer,pScrap,-1, NULL, NULL) INTO _womatlid; RETURN _womatlid; END; $_$; hDROP FUNCTION public.createwomaterial(integer, integer, character, integer, numeric, numeric, numeric); publicadminfalse84623125578247]createwomaterial(integer, integer, character, integer, numeric, numeric, integer, text, text)FUNCTION CREATE FUNCTION createwomaterial(integer, integer, character, integer, numeric, numeric, integer, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pWoid ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pIssueMethod ALIAS FOR $3; pUomId ALIAS FOR $4; pQtyPer ALIAS FOR $5; pScrap ALIAS FOR $6; pBomitemId ALIAS FOR $7; pNotes ALIAS FOR $8; pRef ALIAS FOR $9; _womatlid INTEGER; _p RECORD; BEGIN _womatlid := (SELECT NEXTVAL('womatl_womatl_id_seq')); INSERT INTO womatl ( womatl_id, womatl_wo_id, womatl_itemsite_id, womatl_issuemethod, womatl_uom_id, womatl_qtyper, womatl_scrap, womatl_qtyreq, womatl_qtyiss, womatl_qtywipscrap, womatl_wooper_id, womatl_bomitem_id, womatl_duedate, womatl_notes, womatl_ref ) SELECT _womatlid, wo_id, pItemsiteid, pIssueMethod, pUomId, pQtyPer, pScrap, roundQty(item_fractional, (wo_qtyord * (pQtyPer * (1 + pScrap)))), 0, 0, -1, pBomitemId, wo_startdate, pNotes, pRef FROM wo, itemsite, item WHERE ( (itemsite_item_id=item_id) AND (wo_id=pWoid) AND (itemsite_id=pItemsiteid) ); -- Handle all of the Phantom material requirements WHILE ( ( SELECT COUNT(*) FROM womatl, itemsite, item WHERE ( (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (womatl_wo_id=pWoid) AND (item_type='F') ) ) > 0 ) LOOP FOR _p IN SELECT wo_qtyord, wo_startdate, womatl_id, womatl_wooper_id FROM wo, womatl, itemsite, item WHERE ( (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_type='F') AND (womatl_wo_id=wo_id) AND (wo_id=pWoid) ) LOOP INSERT INTO womatl ( womatl_wo_id, womatl_itemsite_id, womatl_wooper_id, womatl_schedatwooper, womatl_duedate, womatl_uom_id, womatl_qtyper, womatl_scrap, womatl_qtyreq, womatl_qtyiss, womatl_qtywipscrap, womatl_lastissue, womatl_lastreturn, womatl_cost, womatl_picklist, womatl_createwo, womatl_issuemethod, womatl_notes, womatl_ref ) SELECT pWoid, cs.itemsite_id, _p.womatl_wooper_id, womatl_schedatwooper, womatl_duedate, bomitem_uom_id, (bomitem_qtyper * womatl_qtyper), bomitem_scrap, roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id), (_p.wo_qtyord * bomitem_qtyper * womatl_qtyper * (1 + bomitem_scrap))), 0, 0, startOfTime(), startOfTime(), 0, ci.item_picklist, ( (ci.item_type='M') AND (bomitem_createwo) ), bomitem_issuemethod, bomitem_notes, bomitem_ref FROM wo, womatl, bomitem, itemsite AS cs, itemsite AS ps, item AS ci, item AS pi WHERE ( (womatl_itemsite_id=ps.itemsite_id) AND (womatl_wo_id=wo_id) AND (bomitem_parent_item_id=pi.item_id) AND (bomitem_item_id=ci.item_id) AND (ps.itemsite_warehous_id=cs.itemsite_warehous_id) AND (cs.itemsite_item_id=ci.item_id) AND (ps.itemsite_item_id=pi.item_id) AND (woEffectiveDate(_p.wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND (womatl_id=_p.womatl_id)); DELETE FROM womatl WHERE (womatl_id=_p.womatl_id); END LOOP; END LOOP; UPDATE wo SET wo_adhoc=TRUE WHERE (wo_id=pWoid); UPDATE wo SET wo_status='E' WHERE ( (wo_status='O') AND (wo_id=pWoid) ); RETURN _womatlid; END; $_$; tDROP FUNCTION public.createwomaterial(integer, integer, character, integer, numeric, numeric, integer, text, text); publicadminfalse84623125578248fcreatewomaterial(integer, integer, character, integer, numeric, numeric, numeric, integer, text, text)FUNCTIONCREATE FUNCTION createwomaterial(integer, integer, character, integer, numeric, numeric, numeric, integer, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pItemsiteid ALIAS FOR $2; pIssueMethod ALIAS FOR $3; pUomId ALIAS FOR $4; pQtyFxd ALIAS FOR $5; pQtyPer ALIAS FOR $6; pScrap ALIAS FOR $7; pBomitemId ALIAS FOR $8; pNotes ALIAS FOR $9; pRef ALIAS FOR $10; _womatlid INTEGER; BEGIN SELECT createWoMaterial(pWoid,pItemsiteid,pIssueMethod,pUomId,pQtyFxd,pQtyPer,pScrap,pBomitemId,pNotes,pRef,NULL,NULL) INTO _womatlid; RETURN _womatlid; END; $_$; }DROP FUNCTION public.createwomaterial(integer, integer, character, integer, numeric, numeric, numeric, integer, text, text); publicadminfalse84623125578249xcreatewomaterial(integer, integer, character, integer, numeric, numeric, numeric, integer, text, text, integer, boolean)FUNCTIONCREATE FUNCTION createwomaterial(pwoid integer, pitemsiteid integer, pissuemethod character, puomid integer, pqtyfxd numeric, pqtyper numeric, pscrap numeric, pbomitemid integer, pnotes text, pref text, pwooperid integer, ppicklist boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _womatlid INTEGER; BEGIN SELECT createWoMaterial(pWoid, pItemsiteid, pIssueMethod, pUomId, pQtyFxd, pQtyPer, pScrap, pBomitemId, pNotes, pRef, pWooperId, pPickList, 0.0) INTO _womatlid; RETURN _womatlid; END; $$; DROP FUNCTION public.createwomaterial(pwoid integer, pitemsiteid integer, pissuemethod character, puomid integer, pqtyfxd numeric, pqtyper numeric, pscrap numeric, pbomitemid integer, pnotes text, pref text, pwooperid integer, ppicklist boolean); publicadminfalse46238125578250createwomaterial(integer, integer, character, integer, numeric, numeric, numeric, integer, text, text, integer, boolean, numeric)FUNCTIONCREATE FUNCTION createwomaterial(pwoid integer, pitemsiteid integer, pissuemethod character, puomid integer, pqtyfxd numeric, pqtyper numeric, pscrap numeric, pbomitemid integer, pnotes text, pref text, pwooperid integer, ppicklist boolean, pprice numeric) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _womatlid INTEGER; _p RECORD; BEGIN _womatlid := (SELECT NEXTVAL('womatl_womatl_id_seq')); INSERT INTO womatl ( womatl_id, womatl_wo_id, womatl_itemsite_id, womatl_issuemethod, womatl_uom_id, womatl_qtyfxd, womatl_qtyper, womatl_scrap, womatl_qtyreq, womatl_qtyiss, womatl_qtywipscrap, womatl_wooper_id, womatl_bomitem_id, womatl_duedate, womatl_notes, womatl_ref, womatl_picklist, womatl_price ) SELECT _womatlid, wo_id, pItemsiteid, pIssueMethod, pUomId, pQtyFxd, pQtyPer, pScrap, roundQty(item_fractional, (pQtyFxd + wo_qtyord * pQtyPer) * (1 + pScrap) ), 0, 0, COALESCE(pWooperId, -1), pBomitemId, wo_startdate, pNotes, pRef, COALESCE(pPickList, item_picklist), pPrice FROM wo, itemsite JOIN item ON (item_id=itemsite_item_id) WHERE ( (wo_id=pWoid) AND (itemsite_id=pItemsiteid) ); -- Handle all of the Phantom material requirements WHILE ( ( SELECT COUNT(*) FROM womatl, itemsite, item WHERE ( (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (womatl_wo_id=pWoid) AND (item_type='F') ) ) > 0 ) LOOP FOR _p IN SELECT wo_qtyord, wo_startdate, womatl_id, womatl_wooper_id FROM wo, womatl, itemsite, item WHERE ( (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_type='F') AND (womatl_wo_id=wo_id) AND (wo_id=pWoid) ) LOOP INSERT INTO womatl ( womatl_wo_id, womatl_itemsite_id, womatl_wooper_id, womatl_schedatwooper, womatl_duedate, womatl_uom_id, womatl_qtyfxd, womatl_qtyper, womatl_scrap, womatl_qtyreq, womatl_qtyiss, womatl_qtywipscrap, womatl_lastissue, womatl_lastreturn, womatl_cost, womatl_picklist, womatl_createwo, womatl_issuemethod, womatl_notes, womatl_ref ) SELECT pWoid, cs.itemsite_id, _p.womatl_wooper_id, womatl_schedatwooper, womatl_duedate, bomitem_uom_id, bomitem_qtyfxd, (bomitem_qtyper * womatl_qtyper), bomitem_scrap, roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id), ((bomitem_qtyfxd + _p.wo_qtyord * bomitem_qtyper) * womatl_qtyper * (1 + bomitem_scrap))), 0, 0, startOfTime(), startOfTime(), 0, ci.item_picklist, ( (ci.item_type='M') AND (bomitem_createwo) ), bomitem_issuemethod, bomitem_notes, bomitem_ref FROM wo, womatl, bomitem, itemsite AS cs, itemsite AS ps, item AS ci, item AS pi WHERE ( (womatl_itemsite_id=ps.itemsite_id) AND (womatl_wo_id=wo_id) AND (bomitem_parent_item_id=pi.item_id) AND (bomitem_item_id=ci.item_id) AND (ps.itemsite_warehous_id=cs.itemsite_warehous_id) AND (cs.itemsite_item_id=ci.item_id) AND (ps.itemsite_item_id=pi.item_id) AND (woEffectiveDate(_p.wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND (womatl_id=_p.womatl_id)); DELETE FROM womatl WHERE (womatl_id=_p.womatl_id); END LOOP; END LOOP; UPDATE wo SET wo_adhoc=TRUE WHERE (wo_id=pWoid); UPDATE wo SET wo_status='E' WHERE ( (wo_status='O') AND (wo_id=pWoid) ); RETURN _womatlid; END; $$; DROP FUNCTION public.createwomaterial(pwoid integer, pitemsiteid integer, pissuemethod character, puomid integer, pqtyfxd numeric, pqtyper numeric, pscrap numeric, pbomitemid integer, pnotes text, pref text, pwooperid integer, ppicklist boolean, pprice numeric); publicadminfalse84623125578251creditmemototal(integer)FUNCTION!CREATE FUNCTION creditmemototal(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCreditmemoId ALIAS FOR $1; _result NUMERIC; BEGIN -- TO DO: Add in line item taxes SELECT COALESCE(cmhead_freight,0.0) + COALESCE(cmhead_misc,0.0) + ( SELECT COALESCE(ROUND(SUM((cmitem_qtycredit * cmitem_qty_invuomratio) * cmitem_unitprice / cmitem_price_invuomratio), 2), 0.0) FROM cmitem WHERE (cmitem_cmhead_id=cmhead_id) ) + (SELECT COALESCE(SUM(tax) * -1, 0) AS tax FROM ( SELECT ROUND(SUM(taxdetail_tax),2) AS tax FROM tax JOIN calculateTaxDetailSummary('CM', cmhead_id, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id) AS data) INTO _result FROM cmhead WHERE (cmhead_id=pCreditmemoId); IF (NOT FOUND) THEN return 0; ELSE RETURN _result; END IF; END; $_$; /DROP FUNCTION public.creditmemototal(integer); publicadminfalse84623125978252crmacctTABLECREATE TABLE crmacct ( crmacct_id integer NOT NULL, crmacct_number text NOT NULL, crmacct_name text, crmacct_active boolean DEFAULT true, crmacct_type character(1), crmacct_cust_id integer, crmacct_competitor_id integer, crmacct_partner_id integer, crmacct_prospect_id integer, crmacct_vend_id integer, crmacct_cntct_id_1 integer, crmacct_cntct_id_2 integer, crmacct_parent_id integer, crmacct_notes text, crmacct_taxauth_id integer, crmacct_owner_username text, crmacct_emp_id integer, crmacct_salesrep_id integer, crmacct_usr_username text, CONSTRAINT crmacct_crmacct_number_check CHECK ((crmacct_number <> ''::text)), CONSTRAINT crmacct_crmacct_type_check CHECK ((crmacct_type = ANY (ARRAY['I'::bpchar, 'O'::bpchar]))), CONSTRAINT crmacct_crmacct_usr_username_check CHECK ((btrim(crmacct_usr_username) <> ''::text)), CONSTRAINT crmacct_owner_username_check CHECK ((btrim(crmacct_owner_username) <> ''::text)) ); DROP TABLE public.crmacct; publicadminfalse599859996000600160028%00 TABLE crmacctCOMMENTCOMMENT ON TABLE crmacct IS 'CRM Accounts are umbrella records that tie together people and organizations with whom we have business relationships.'; publicadminfalse188%00COLUMN crmacct.crmacct_idCOMMENTLCOMMENT ON COLUMN crmacct.crmacct_id IS 'Internal ID of this CRM Account.'; publicadminfalse188%00COLUMN crmacct.crmacct_numberCOMMENTkCOMMENT ON COLUMN crmacct.crmacct_number IS 'Abbreviated human-readable identifier for this CRM Account.'; publicadminfalse188%00COLUMN crmacct.crmacct_nameCOMMENTLCOMMENT ON COLUMN crmacct.crmacct_name IS 'Long name of this CRM Account.'; publicadminfalse188%00COLUMN crmacct.crmacct_activeCOMMENT_COMMENT ON COLUMN crmacct.crmacct_active IS 'This CRM Account is available for new activity.'; publicadminfalse188%00COLUMN crmacct.crmacct_typeCOMMENTCOMMENT ON COLUMN crmacct.crmacct_type IS 'This indicates whether the CRM Account represents an organization or an individual person.'; publicadminfalse188%00COLUMN crmacct.crmacct_cust_idCOMMENTeCOMMENT ON COLUMN crmacct.crmacct_cust_id IS 'If this is not null, this CRM Account is a Customer.'; publicadminfalse188%00$COLUMN crmacct.crmacct_competitor_idCOMMENTCOMMENT ON COLUMN crmacct.crmacct_competitor_id IS 'For now, > 0 indicates this CRM Account is a competitor. Eventually this may become a foreign key to a table of competitors.'; publicadminfalse188%00!COLUMN crmacct.crmacct_partner_idCOMMENTCOMMENT ON COLUMN crmacct.crmacct_partner_id IS 'For now, > 0 indicates this CRM Account is a partner. Eventually this may become a foreign key to a table of partners.'; publicadminfalse188%00"COLUMN crmacct.crmacct_prospect_idCOMMENTiCOMMENT ON COLUMN crmacct.crmacct_prospect_id IS 'If this is not null, this CRM Account is a Prospect.'; publicadminfalse188%00COLUMN crmacct.crmacct_vend_idCOMMENTcCOMMENT ON COLUMN crmacct.crmacct_vend_id IS 'If this is not null, this CRM Account is a Vendor.'; publicadminfalse188%00!COLUMN crmacct.crmacct_cntct_id_1COMMENT\COMMENT ON COLUMN crmacct.crmacct_cntct_id_1 IS 'The primary contact for the CRM Account.'; publicadminfalse188%00!COLUMN crmacct.crmacct_cntct_id_2COMMENT^COMMENT ON COLUMN crmacct.crmacct_cntct_id_2 IS 'The secondary contact for the CRM Account.'; publicadminfalse188%00 COLUMN crmacct.crmacct_parent_idCOMMENTCOMMENT ON COLUMN crmacct.crmacct_parent_id IS 'The internal ID of an (optional) parent CRM Account. For example, if the current CRM Account is a subsidiary of another company, the crmacct_parent_id points to the CRM Account representing that parent company.'; publicadminfalse188%00COLUMN crmacct.crmacct_notesCOMMENT`COMMENT ON COLUMN crmacct.crmacct_notes IS 'Free-form comments pertaining to the CRM Account.'; publicadminfalse188%00!COLUMN crmacct.crmacct_taxauth_idCOMMENTmCOMMENT ON COLUMN crmacct.crmacct_taxauth_id IS 'If this is not null, this CRM Account is a Tax Authority.'; publicadminfalse188%00%COLUMN crmacct.crmacct_owner_usernameCOMMENTnCOMMENT ON COLUMN crmacct.crmacct_owner_username IS 'The application User responsible for this CRM Account.'; publicadminfalse188%00COLUMN crmacct.crmacct_emp_idCOMMENTeCOMMENT ON COLUMN crmacct.crmacct_emp_id IS 'If this is not null, this CRM Account is an Employee.'; publicadminfalse188%00"COLUMN crmacct.crmacct_salesrep_idCOMMENTjCOMMENT ON COLUMN crmacct.crmacct_salesrep_id IS 'If this is not null, this CRM Account is a Sales Rep.'; publicadminfalse188%00#COLUMN crmacct.crmacct_usr_usernameCOMMENTsCOMMENT ON COLUMN crmacct.crmacct_usr_username IS 'If this is not null, this CRM Account is an application User.'; publicadminfalse188%00crmacctACLREVOKE ALL ON TABLE crmacct FROM PUBLIC; REVOKE ALL ON TABLE crmacct FROM admin; GRANT ALL ON TABLE crmacct TO admin; GRANT ALL ON TABLE crmacct TO xtrole; publicadminfalse188125578263 crmacct()FUNCTIONCREATE FUNCTION crmacct() RETURNS SETOF crmacct LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row crmacct%ROWTYPE; _priv TEXT; _grant BOOLEAN; BEGIN -- This query will give us the most permissive privilege the user has been granted SELECT privilege, granted INTO _priv, _grant FROM privgranted WHERE privilege IN ('MaintainAllCRMAccounts','ViewAllCRMAccounts','MaintainPersonalCRMAccounts','ViewPersonalCRMAccounts') ORDER BY granted DESC, sequence LIMIT 1; -- If have an 'All' privilege return all results IF (_priv ~ 'All' AND _grant) THEN FOR _row IN SELECT * FROM crmacct LOOP RETURN NEXT _row; END LOOP; -- Otherwise if have any other grant, must be personal privilege. ELSIF (_grant) THEN FOR _row IN SELECT * FROM crmacct WHERE crmacct_owner_username = getEffectiveXtUser() LOOP RETURN NEXT _row; END LOOP; END IF; RETURN; END; $$; DROP FUNCTION public.crmacct(); publicadminfalse846232791%00FUNCTION crmacct()COMMENTwCOMMENT ON FUNCTION crmacct() IS 'A table function that returns CRM Account results according to privilege settings.'; publicadminfalse1302125578264crypt(text, text)FUNCTIONvCREATE FUNCTION crypt(text, text) RETURNS text LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_crypt'; (DROP FUNCTION public.crypt(text, text); publicadminfalse8125578265currconcat(integer)FUNCTIONCREATE FUNCTION currconcat(integer) RETURNS character varying LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE id ALIAS FOR $1; returnVal VARCHAR(15) := ''; BEGIN SELECT currConcat(curr_abbr, curr_symbol) INTO returnVal FROM curr_symbol WHERE curr_id = id; RETURN returnVal; END; $_$; *DROP FUNCTION public.currconcat(integer); publicadminfalse462381255782660currconcat(character varying, character varying)FUNCTIONCREATE FUNCTION currconcat(character varying, character varying) RETURNS character varying LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE curr_abbr ALIAS FOR $1; curr_symbol ALIAS FOR $2; returnVal VARCHAR(15) := ''; BEGIN IF length(trim(curr_abbr)) > 0 AND length(trim(curr_symbol)) > 0 THEN returnVal := trim(curr_abbr) || ' - ' || trim(curr_symbol); ELSIF length(trim(curr_abbr)) > 0 THEN returnVal := curr_abbr; ELSIF length(trim(curr_symbol)) > 0 THEN returnVal := curr_symbol; END IF; RETURN returnVal; END; $_$; GDROP FUNCTION public.currconcat(character varying, character varying); publicadminfalse84623125578267currentapmemonumber()FUNCTIONCREATE FUNCTION currentapmemonumber() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _number INTEGER; BEGIN SELECT orderseq_number INTO _number FROM orderseq WHERE (orderseq_name='APMemoNumber'); IF (NOT FOUND) THEN _number := 0; END IF; RETURN _number; END; $$; ,DROP FUNCTION public.currentapmemonumber(); publicadminfalse46238125578268currentarmemonumber()FUNCTIONCREATE FUNCTION currentarmemonumber() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _number INTEGER; BEGIN SELECT orderseq_number INTO _number FROM orderseq WHERE (orderseq_name='ARMemoNumber'); IF (NOT FOUND) THEN _number := 0; END IF; RETURN _number; END; $$; ,DROP FUNCTION public.currentarmemonumber(); publicadminfalse84623125578269currentcashrcptnumber()FUNCTIONCREATE FUNCTION currentcashrcptnumber() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _number INTEGER; BEGIN SELECT orderseq_number INTO _number FROM orderseq WHERE (orderseq_name='CashRcptNumber'); IF (NOT FOUND) THEN _number := 0; END IF; RETURN _number; END; $$; .DROP FUNCTION public.currentcashrcptnumber(); publicadminfalse46238125578270currentnumber(text)FUNCTIONCREATE FUNCTION currentnumber(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pName ALIAS FOR $1; _number INTEGER; BEGIN SELECT orderseq_number INTO _number FROM orderseq WHERE (orderseq_name=pName); IF (NOT FOUND) THEN _number := 0; END IF; RETURN _number; END; $_$; *DROP FUNCTION public.currentnumber(text); publicadminfalse46238125578271currexchangecheckoverlap()FUNCTIONCREATE FUNCTION currexchangecheckoverlap() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE numberOfOverlaps INTEGER NOT NULL := 0; curr_string VARCHAR(16); new_id INTEGER; BEGIN new_id := NEW.curr_id; -- ensure that effective date <= expiration date IF NEW.curr_effective > NEW.curr_expires THEN RAISE EXCEPTION 'Effective date % must be earlier than expiration date %', NEW.curr_effective, NEW.curr_expires; END IF; -- ensure new exchange rate does not overlap in time with any others SELECT count(*) INTO numberOfOverlaps FROM curr_rate WHERE curr_id = NEW.curr_id AND curr_rate_id != NEW.curr_rate_id AND ( (curr_effective BETWEEN NEW.curr_effective AND NEW.curr_expires OR curr_expires BETWEEN NEW.curr_effective AND NEW.curr_expires) OR (curr_effective <= NEW.curr_effective AND curr_expires >= NEW.curr_expires) ); IF numberOfOverlaps > 0 THEN SELECT currConcat(curr_symbol, curr_abbr) INTO curr_string FROM curr_symbol WHERE curr_id = new_id; RAISE EXCEPTION 'The date range % to % overlaps with another date range.', NEW.curr_effective, NEW.curr_expires; END IF; RETURN NEW; END; $$; 1DROP FUNCTION public.currexchangecheckoverlap(); publicadminfalse84623125578272&currgain(integer, numeric, date, date)FUNCTIONqCREATE FUNCTION currgain(integer, numeric, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pId ALIAS FOR $1; pValue ALIAS FOR $2; pStart ALIAS FOR $3; pEnd ALIAS FOR $4; _start DATE; _end DATE; _gain NUMERIC; _multiplier INTEGER := 1; BEGIN IF (pEnd = pStart OR pValue = 0) THEN RETURN 0; END IF; IF (pStart > pEnd) THEN _start := pEnd; _end := pStart; _multiplier := -1; ELSE _start := pStart; _end := pEnd; END IF; _gain := currToBase(pId, pValue, _start) - currToBase(pId, pValue, _end); IF (_gain IS NULL) THEN RAISE EXCEPTION 'Missing exchange rate for curr_id % on % or %', pId, _start, _end; END IF; RETURN _gain * _multiplier; END; $_$; =DROP FUNCTION public.currgain(integer, numeric, date, date); publicadminfalse46238125578273 curronebase()FUNCTION"CREATE FUNCTION curronebase() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE baseCount INTEGER := 0; BEGIN IF NEW.curr_base = TRUE THEN SELECT count(*) INTO baseCount FROM curr_symbol WHERE curr_base = TRUE AND curr_id != NEW.curr_id; IF baseCount > 0 THEN RAISE EXCEPTION 'Cannot make % - % the base currency because one is already defined.', NEW.curr_symbol, NEW.curr_abbr; ELSE SELECT count(*) INTO baseCount FROM curr_rate WHERE curr_id = NEW.curr_id; IF baseCount = 0 THEN -- put a row in the curr_rate table to avoid special-case -- code for converting base currency to base currency INSERT INTO curr_rate (curr_id, curr_rate, curr_effective, curr_expires) VALUES (NEW.curr_id, 1, startOfTime(), endOfTime()); END IF; END IF; END IF; RETURN NEW; END; $$; $DROP FUNCTION public.curronebase(); publicadminfalse84623125578274currrate(integer, date)FUNCTIONCREATE FUNCTION currrate(integer, date) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN currRate($1, NULL, $2); END; $_$; .DROP FUNCTION public.currrate(integer, date); publicadminfalse46238125578275 currrate(integer, integer, date)FUNCTION~CREATE FUNCTION currrate(pfromcurr integer, ptocurr integer, pdate date) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _fromRate NUMERIC := 1.0; _toRate NUMERIC := 1.0; _returnVal NUMERIC := 1.0; BEGIN IF pFromCurr = pToCurr THEN RETURN _returnVal; END IF; IF (pFromCurr IS NOT NULL) THEN SELECT curr_rate INTO _fromRate FROM curr_rate WHERE ( (curr_id=pFromCurr) AND (pDate BETWEEN curr_effective AND curr_expires) ); IF ( NOT FOUND) THEN RAISE EXCEPTION 'Currency exchange rate for currency % not found on %', pFromCurr, formatDate(pDate); END IF; END IF; IF (pToCurr IS NOT NULL) THEN SELECT curr_rate INTO _toRate FROM curr_rate WHERE ( (curr_id=pToCurr) AND (pDate BETWEEN curr_effective AND curr_expires) ); IF ( NOT FOUND) THEN RAISE EXCEPTION 'Currency exchange rate for currency % not found on %', pToCurr, formatDate(pDate); END IF; END IF; _returnVal := _fromRate / _toRate; RETURN _returnVal; END; $$; ODROP FUNCTION public.currrate(pfromcurr integer, ptocurr integer, pdate date); publicadminfalse84623125578276"currtobase(integer, numeric, date)FUNCTIONDCREATE FUNCTION currtobase(integer, numeric, date) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pId ALIAS FOR $1; pValue ALIAS FOR $2; _date DATE; _output NUMERIC; BEGIN _date := $3; IF _date IS NULL THEN _date := 'now'; END IF; IF pValue = 0 OR pValue IS NULL THEN _output := 0; ELSIF (baseCurrId() = pId) THEN _output := pValue; ELSE SELECT pValue / curr_rate INTO _output FROM curr_rate WHERE curr_id = pId AND _date BETWEEN curr_effective AND curr_expires; IF (_output IS NULL OR NOT FOUND) THEN RAISE EXCEPTION 'No exchange rate for % on %', pId, _date; END IF; END IF; RETURN _output; END; $_$; 9DROP FUNCTION public.currtobase(integer, numeric, date); publicadminfalse46238125578277+currtocurr(integer, integer, numeric, date)FUNCTION_CREATE FUNCTION currtocurr(integer, integer, numeric, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFromCurr ALIAS FOR $1; pToCurr ALIAS FOR $2; pValue ALIAS FOR $3; pEffective ALIAS FOR $4; _convertedValue NUMERIC; _fromRate NUMERIC; _toRate NUMERIC; BEGIN IF pFromCurr = pToCurr THEN RETURN pValue; END IF; IF pValue = 0 OR pValue IS NULL THEN RETURN 0; END IF; SELECT curr_rate INTO _fromRate FROM curr_rate WHERE curr_id = pFromCurr AND pEffective BETWEEN curr_effective AND curr_expires; IF (NOT FOUND) THEN RAISE EXCEPTION 'No exchange rate for % on %', pFromCurr, pEffective; END IF; SELECT curr_rate INTO _toRate FROM curr_rate WHERE curr_id = pToCurr AND pEffective BETWEEN curr_effective AND curr_expires; IF (NOT FOUND) THEN RAISE EXCEPTION 'No exchange rate for % on %', pToCurr, pEffective; END IF; _convertedValue := pValue * _toRate / _fromRate; RETURN _convertedValue; END; $_$; BDROP FUNCTION public.currtocurr(integer, integer, numeric, date); publicadminfalse46238125578278#currtolocal(integer, numeric, date)FUNCTIONCREATE FUNCTION currtolocal(integer, numeric, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pId ALIAS FOR $1; pValue ALIAS FOR $2; _date DATE; _output NUMERIC; BEGIN _date := $3; IF _date IS NULL THEN _date := 'now'; END IF; IF pValue = 0 OR pValue IS NULL THEN _output := 0; ELSIF (baseCurrId() = pId) THEN _output := pValue; ELSE SELECT pValue * curr_rate INTO _output FROM curr_rate WHERE curr_id = pId AND _date BETWEEN curr_effective AND curr_expires; IF (_output IS NULL OR NOT FOUND) THEN RAISE EXCEPTION 'No exchange rate for % on %', pId, _date; END IF; END IF; RETURN _output; END; $_$; :DROP FUNCTION public.currtolocal(integer, numeric, date); publicadminfalse84623125578279 custitem(integer, integer, date)FUNCTION8CREATE FUNCTION custitem(cust_id integer, shipto_id integer DEFAULT (-1), asof date DEFAULT ('now'::text)::date) RETURNS SETOF integer LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- Non Exclusive SELECT item_id FROM item WHERE (NOT item_exclusive) AND (item_sold) UNION -- Exclusive, Shipto match SELECT item_id FROM item JOIN ipsiteminfo ON (ipsitem_item_id=item_id) JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE (item_exclusive) AND (item_sold) AND ($2 != -1) AND (ipsass_shipto_id=$2) AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1)) UNION SELECT item_id FROM item JOIN ipsiteminfo ON (ipsitem_prodcat_id=item_prodcat_id) JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE (item_exclusive) AND (item_sold) AND ($2 != -1) AND (ipsass_shipto_id=$2) AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1)) UNION -- Exclusive, Shipto pattern match SELECT item_id FROM item JOIN ipsiteminfo ON (ipsitem_item_id=item_id) JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) JOIN shiptoinfo ON (shipto_num ~ ipsass_shipto_pattern) WHERE (item_exclusive) AND (item_sold) AND (COALESCE(length(ipsass_shipto_pattern), 0) > 0) AND (ipsass_cust_id=$1) AND ($2 != -1) AND (shipto_id=$2) AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1)) UNION SELECT item_id FROM item JOIN ipsiteminfo ON (ipsitem_prodcat_id=item_prodcat_id) JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) JOIN shiptoinfo ON (shipto_num ~ ipsass_shipto_pattern) WHERE (item_exclusive) AND (item_sold) AND (COALESCE(length(ipsass_shipto_pattern), 0) > 0) AND (ipsass_cust_id=$1) AND ($2 != -1) AND (shipto_id=$2) AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1)) UNION -- Exclusive, Customer match SELECT item_id FROM item JOIN ipsiteminfo ON (ipsitem_item_id=item_id) JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE (item_exclusive) AND (item_sold) AND (ipsass_cust_id=$1) AND (ipsass_shipto_id=-1) AND (ipsass_shipto_pattern='') AND (ipsass_custtype_id=-1) AND (ipsass_custtype_pattern='') AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1)) UNION SELECT item_id FROM item JOIN ipsiteminfo ON (ipsitem_prodcat_id=item_prodcat_id) JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) WHERE (item_exclusive) AND (item_sold) AND (ipsass_cust_id=$1) AND (ipsass_shipto_id=-1) AND (ipsass_shipto_pattern='') AND (ipsass_custtype_id=-1) AND (ipsass_custtype_pattern='') AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1)) UNION -- Exclusive, Customer Type match SELECT item_id FROM item JOIN ipsiteminfo ON (ipsitem_item_id=item_id) JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) JOIN custinfo ON (ipsass_custtype_id=cust_custtype_id) WHERE (item_exclusive) AND (item_sold) AND (cust_id=$1) AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1)) UNION SELECT item_id FROM item JOIN ipsiteminfo ON (ipsitem_prodcat_id=item_prodcat_id) JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) JOIN custinfo ON (ipsass_custtype_id=cust_custtype_id) WHERE (item_exclusive) AND (item_sold) AND (cust_id=$1) AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1)) UNION -- Exclusive, Customer Type pattern match SELECT item_id FROM item JOIN ipsiteminfo ON (ipsitem_item_id=item_id) JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) JOIN custtype ON (custtype_code ~ ipsass_custtype_pattern) JOIN custinfo ON (cust_custtype_id=custtype_id) WHERE (item_exclusive) AND (item_sold) AND (COALESCE(length(ipsass_custtype_pattern), 0) > 0) AND (cust_id=$1) AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1)) UNION SELECT item_id FROM item JOIN ipsiteminfo ON (ipsitem_prodcat_id=item_prodcat_id) JOIN ipshead ON (ipshead_id=ipsitem_ipshead_id) JOIN ipsass ON (ipsass_ipshead_id=ipshead_id) JOIN custtype ON (custtype_code ~ ipsass_custtype_pattern) JOIN custinfo ON (cust_custtype_id=custtype_id) WHERE (item_exclusive) AND (item_sold) AND (COALESCE(length(ipsass_custtype_pattern), 0) > 0) AND (cust_id=$1) AND ($3 BETWEEN ipshead_effective AND (ipshead_expires - 1)) $_$; NDROP FUNCTION public.custitem(cust_id integer, shipto_id integer, asof date); publicadminfalse8125578280%customercanpurchase(integer, integer)FUNCTIONcCREATE FUNCTION customercanpurchase(integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pitemid ALIAS FOR $1; pCustid ALIAS FOR $2; BEGIN RETURN customerCanPurchase(pitemid, pCustid, -1); END; $_$; <DROP FUNCTION public.customercanpurchase(integer, integer); publicadminfalse84623 125578281.customercanpurchase(integer, integer, integer)FUNCTIONCREATE FUNCTION customercanpurchase(integer, integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pitemid ALIAS FOR $1; pCustid ALIAS FOR $2; pShiptoid AlIAS FOR $3; _id INTEGER; _item RECORD; BEGIN RETURN customerCanPurchase(pitemid, pCustid, pShiptoid, CURRENT_DATE); END; $_$; EDROP FUNCTION public.customercanpurchase(integer, integer, integer); publicadminfalse46238!1255782824customercanpurchase(integer, integer, integer, date)FUNCTIONCREATE FUNCTION customercanpurchase(integer, integer, integer, date) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pitemid ALIAS FOR $1; pCustid ALIAS FOR $2; pShiptoid AlIAS FOR $3; pAsOf ALIAS FOR $4; _id INTEGER; _item RECORD; BEGIN SELECT item_sold, item_exclusive INTO _item FROM item WHERE(item_id=pItemid); -- Make sure that this is at least a sold Item IF (NOT _item.item_sold) THEN RETURN FALSE; END IF; -- Everyone can purchase a non-exclusive item IF (NOT _item.item_exclusive) THEN RETURN TRUE; END IF; IF(pShiptoid != -1) THEN -- Check for a shipto Assigned Price SELECT ipsitem_id INTO _id FROM ipsiteminfo, ipshead, ipsass WHERE((ipsitem_ipshead_id=ipshead_id) AND (ipsass_ipshead_id=ipshead_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsitem_item_id=pItemid) AND (ipsass_shipto_id != -1) AND (ipsass_shipto_id=pShiptoid)) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; SELECT ipsitem_id INTO _id FROM ipsiteminfo, item, ipshead, ipsass WHERE((ipsitem_ipshead_id=ipshead_id) AND (ipsitem_prodcat_id = item_prodcat_id) AND (ipsass_ipshead_id=ipshead_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (item_id=pItemid) AND (ipsass_shipto_id != -1) AND (ipsass_shipto_id=pShiptoid)) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; -- Check for a Shipto Pattern Assigned Price SELECT ipsitem_id INTO _id FROM ipsiteminfo, ipshead, ipsass, shiptoinfo WHERE((ipsitem_ipshead_id=ipshead_id) AND (ipsass_ipshead_id=ipshead_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (COALESCE(length(ipsass_shipto_pattern), 0) > 0) AND (shipto_num ~ ipsass_shipto_pattern) AND (ipsass_cust_id=pCustid) AND (ipsitem_item_id=pItemid) AND (shipto_id=pShiptoid)) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; SELECT ipsitem_id INTO _id FROM ipsiteminfo, item, ipshead, ipsass, shiptoinfo WHERE((ipsitem_ipshead_id=ipshead_id) AND (ipsitem_prodcat_id = item_prodcat_id) AND (ipsass_ipshead_id=ipshead_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (COALESCE(length(ipsass_shipto_pattern), 0) > 0) AND (shipto_num ~ ipsass_shipto_pattern) AND (ipsass_cust_id=pCustid) AND (item_id=pItemid) AND (shipto_id=pShiptoid)) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; END IF; -- Check for a Customer Assigned Price SELECT ipsitem_id INTO _id FROM ipsiteminfo, ipshead, ipsass WHERE((ipsitem_ipshead_id=ipshead_id) AND (ipsass_ipshead_id=ipshead_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsitem_item_id=pItemid) AND (COALESCE(length(ipsass_shipto_pattern), 0) = 0) AND (ipsass_cust_id=pCustid)) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; SELECT ipsitem_id INTO _id FROM ipsiteminfo, item, ipshead, ipsass WHERE((ipsitem_ipshead_id=ipshead_id) AND (ipsitem_prodcat_id = item_prodcat_id) AND (ipsass_ipshead_id=ipshead_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (item_id=pItemid) AND (COALESCE(length(ipsass_shipto_pattern), 0) = 0) AND (ipsass_cust_id=pCustid)) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; -- Check for a Customer Type Assigned Price SELECT ipsitem_id INTO _id FROM ipsiteminfo, ipshead, ipsass, custinfo WHERE( (ipsitem_ipshead_id=ipshead_id) AND (ipsass_ipshead_id=ipshead_id) AND (ipsass_custtype_id != -1) AND (cust_custtype_id = ipsass_custtype_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsitem_item_id=pItemid) AND (cust_id=pCustid)) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; SELECT ipsitem_id INTO _id FROM ipsiteminfo, item, ipshead, ipsass, custinfo WHERE( (ipsitem_ipshead_id=ipshead_id) AND (ipsitem_prodcat_id = item_prodcat_id) AND (ipsass_ipshead_id=ipshead_id) AND (ipsass_custtype_id != -1) AND (cust_custtype_id = ipsass_custtype_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (item_id=pItemid) AND (cust_id=pCustid)) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; -- Check for a Customer Type Pattern Assigned Price SELECT ipsitem_id INTO _id FROM ipsiteminfo, ipshead, ipsass, custtype, custinfo WHERE((ipsitem_ipshead_id=ipshead_id) AND (ipsass_ipshead_id=ipshead_id) AND (coalesce(length(ipsass_custtype_pattern), 0) > 0) AND (custtype_code ~ ipsass_custtype_pattern) AND (cust_custtype_id=custtype_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsitem_item_id=pItemid) AND (cust_id=pCustid)) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; SELECT ipsitem_id INTO _id FROM ipsiteminfo, item, ipshead, ipsass, custtype, custinfo WHERE((ipsitem_ipshead_id=ipshead_id) AND (ipsitem_prodcat_id = item_prodcat_id) AND (ipsass_ipshead_id=ipshead_id) AND (coalesce(length(ipsass_custtype_pattern), 0) > 0) AND (custtype_code ~ ipsass_custtype_pattern) AND (cust_custtype_id=custtype_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (item_id=pItemid) AND (cust_id=pCustid)) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; -- That's it, Sales don't count - yet RETURN FALSE; END; $_$; KDROP FUNCTION public.customercanpurchase(integer, integer, integer, date); publicadminfalse46238125578283 dearmor(text)FUNCTIONuCREATE FUNCTION dearmor(text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_dearmor'; $DROP FUNCTION public.dearmor(text); publicadminfalse8125578284decrypt(bytea, bytea, text)FUNCTIONCREATE FUNCTION decrypt(bytea, bytea, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_decrypt'; 2DROP FUNCTION public.decrypt(bytea, bytea, text); publicadminfalse8125578285%decrypt_iv(bytea, bytea, bytea, text)FUNCTIONCREATE FUNCTION decrypt_iv(bytea, bytea, bytea, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_decrypt_iv'; <DROP FUNCTION public.decrypt_iv(bytea, bytea, bytea, text); publicadminfalse8"125578286defaultlocationname(integer)FUNCTIONKCREATE FUNCTION defaultlocationname(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; _p RECORD; BEGIN SELECT itemsite_location_id, itemsite_location INTO _p FROM itemsite WHERE (itemsite_id=pItemsiteid); IF (NOT FOUND) THEN RETURN 'Error'; ELSIF (_p.itemsite_location_id = -1) THEN RETURN _p.itemsite_location; ELSE RETURN formatLocationName(_p.itemsite_location_id); END IF; END; $_$; 3DROP FUNCTION public.defaultlocationname(integer); publicadminfalse46238#125578287deleteaccount(integer)FUNCTION3CREATE FUNCTION deleteaccount(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAccntid ALIAS FOR $1; _check INTEGER; BEGIN -- Check to see if the passed accnt is used in a Cost Category SELECT costcat_id INTO _check FROM costcat WHERE ( (costcat_asset_accnt_id=pAccntid) OR (costcat_liability_accnt_id=pAccntid) OR (costcat_adjustment_accnt_id=pAccntid) OR (costcat_matusage_accnt_id=pAccntid) OR (costcat_purchprice_accnt_id=pAccntid) OR (costcat_scrap_accnt_id=pAccntid) OR (costcat_invcost_accnt_id=pAccntid) OR (costcat_wip_accnt_id=pAccntid) OR (costcat_shipasset_accnt_id=pAccntid) OR (costcat_mfgscrap_accnt_id=pAccntid) OR (costcat_transform_accnt_id=pAccntid) OR (costcat_freight_accnt_id=pAccntid) OR (costcat_exp_accnt_id=pAccntid) ) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; IF (fetchMetricText('Application') = 'Standard') THEN SELECT costcat_id INTO _check FROM costcat WHERE ( (costcat_toliability_accnt_id=pAccntid) OR (costcat_laboroverhead_accnt_id=pAccntid) ) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; END IF; -- Check to see if the passed accnt is used in a Sales Account Assignment SELECT salesaccnt_id INTO _check FROM salesaccnt WHERE ( (salesaccnt_sales_accnt_id=pAccntid) OR (salesaccnt_credit_accnt_id=pAccntid) OR (salesaccnt_cos_accnt_id=pAccntid) ) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; IF (fetchMetricText('Application') = 'Standard') THEN SELECT salesaccnt_id INTO _check FROM salesaccnt WHERE ( (salesaccnt_returns_accnt_id=pAccntid) OR (salesaccnt_cor_accnt_id=pAccntid) OR (salesaccnt_cow_accnt_id=pAccntid) ) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; END IF; -- Check to see if the passed accnt is used in a Sales Category SELECT salescat_id INTO _check FROM salescat WHERE ( (salescat_sales_accnt_id=pAccntid) OR (salescat_prepaid_accnt_id=pAccntid) OR (salescat_ar_accnt_id=pAccntid) ) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; -- Check to see if the passed accnt is used in a A/R Account Assignment SELECT araccnt_id INTO _check FROM araccnt WHERE ( (araccnt_freight_accnt_id=pAccntid) OR (araccnt_ar_accnt_id=pAccntid) OR (araccnt_prepaid_accnt_id=pAccntid) OR (araccnt_deferred_accnt_id=pAccntid) OR (araccnt_discount_accnt_id=pAccntid) ) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; -- Check to see if the passed accnt is used in a Warehouse IF EXISTS (SELECT 1 FROM whsinfo WHERE (warehous_default_accnt_id=pAccntid)) THEN RETURN -4; END IF; -- Check to see if the passed accnt is used in a Bank Account SELECT bankaccnt_id INTO _check FROM bankaccnt WHERE (bankaccnt_accnt_id=pAccntid) LIMIT 1; IF (FOUND) THEN RETURN -5; END IF; SELECT bankadjtype_id INTO _check FROM bankadjtype WHERE (bankadjtype_accnt_id=pAccntid) LIMIT 1; IF (FOUND) THEN RETURN -5; END IF; -- Check to see if the passed accnt is used in an Expense Category SELECT expcat_id INTO _check FROM expcat WHERE ( (expcat_exp_accnt_id=pAccntid) OR (expcat_liability_accnt_id=pAccntid) OR (expcat_purchprice_accnt_id=pAccntid) OR (expcat_freight_accnt_id=pAccntid) ) LIMIT 1; IF (FOUND) THEN RETURN -6; END IF; -- Check to see if the passed accnt is used in a Tax Code SELECT tax_id INTO _check FROM tax WHERE ( (tax_sales_accnt_id=pAccntid) OR (tax_dist_accnt_id=pAccntid) ) LIMIT 1; IF (FOUND) THEN RETURN -7; END IF; -- Check to see if the passed accnt is used in a Standard Journal Item SELECT stdjrnlitem_id INTO _check FROM stdjrnlitem WHERE (stdjrnlitem_accnt_id=pAccntid) LIMIT 1; IF (FOUND) THEN RETURN -8; END IF; -- Check to see if the passed accnt is used in a A/P Account Assignment SELECT apaccnt_ap_accnt_id INTO _check FROM apaccnt WHERE ( (apaccnt_ap_accnt_id=pAccntid) OR (apaccnt_prepaid_accnt_id=pAccntid) OR (apaccnt_discount_accnt_id=pAccntid) ) LIMIT 1; IF (FOUND) THEN RETURN -9; END IF; -- Check to see if the passed accnt is used in an A/R Open Item record SELECT aropen_accnt_id INTO _check FROM aropen WHERE (aropen_accnt_id=pAccntid) LIMIT 1; IF (FOUND) THEN RETURN -11; END IF; -- Check to see if the passed accnt has been used in the G/L SELECT gltrans_accnt_id INTO _check FROM gltrans WHERE (gltrans_accnt_id=pAccntid) LIMIT 1; IF (FOUND) THEN RETURN -99; END IF; SELECT glseries_accnt_id INTO _check FROM glseries WHERE (glseries_accnt_id=pAccntid) LIMIT 1; IF (FOUND) THEN RETURN -99; END IF; SELECT trialbal_accnt_id INTO _check FROM trialbal WHERE (trialbal_accnt_id=pAccntid) AND (trialbal_beginning != 0 OR trialbal_ending != 0) LIMIT 1; IF (FOUND) THEN RETURN -99; END IF; SELECT cashrcptmisc_accnt_id INTO _check FROM cashrcptmisc WHERE (cashrcptmisc_accnt_id=pAccntid) LIMIT 1; IF (FOUND) THEN RETURN -99; END IF; -- Delete any non-critical use DELETE FROM flitem WHERE (flitem_accnt_id=pAccntid); -- only possible because of trialbal error-check above DELETE FROM trialbal WHERE (trialbal_accnt_id=pAccntid) AND (trialbal_beginning=0) AND (trialbal_ending=0); -- Delete the Account DELETE FROM accnt WHERE (accnt_id=pAccntid); RETURN 0; END; $_$; -DROP FUNCTION public.deleteaccount(integer); publicadminfalse84623$125578288deleteaccountingperiod(integer)FUNCTIONCREATE FUNCTION deleteaccountingperiod(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodid ALIAS FOR $1; _check RECORD; BEGIN -- Check to make sure that the passed period is not closed IF ( ( SELECT period_closed FROM period WHERE (period_id=pPeriodid) ) ) THEN RETURN -1; END IF; -- Check to make sure that there are not any posted G/L Transactions -- in the period. SELECT gltrans_id INTO _check FROM gltrans, period WHERE ( (gltrans_date BETWEEN period_start AND period_end) AND (gltrans_posted) AND (period_id=pPeriodid) ) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; SELECT b.period_id INTO _check FROM period AS a, period AS b WHERE((a.period_id=pPeriodid) AND (a.period_end < b.period_start)) LIMIT 1; IF (FOUND) THEN RETURN -5; END IF; -- Delete the period DELETE FROM period WHERE (period_id=pPeriodid); -- Also Delete the period from TrialBalance DELETE FROM trialbal WHERE (trialbal_period_id=pPeriodid); RETURN 1; END; $_$; 6DROP FUNCTION public.deleteaccountingperiod(integer); publicadminfalse46238%125578289#deleteaccountingyearperiod(integer)FUNCTIONCREATE FUNCTION deleteaccountingyearperiod(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodid ALIAS FOR $1; _check RECORD; BEGIN -- Check to make sure that the passed yearperiod is not closed IF ( ( SELECT yearperiod_closed FROM yearperiod WHERE (yearperiod_id=pPeriodid) ) ) THEN RETURN -1; END IF; -- this yearperiod is in use by existing periods IF (EXISTS(SELECT period_id FROM period WHERE (period_yearperiod_id=pPeriodid))) THEN RETURN -2; END IF; -- Delete the yearperiod DELETE FROM yearperiod WHERE (yearperiod_id=pPeriodid); RETURN 1; END; $_$; :DROP FUNCTION public.deleteaccountingyearperiod(integer); publicadminfalse84623&125578290deleteaddress(integer)FUNCTIONCREATE FUNCTION deleteaddress(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE paddrId ALIAS FOR $1; _count INTEGER := 0; BEGIN SELECT count(*) INTO _count FROM cntct WHERE (cntct_active AND (cntct_addr_id = paddrId)); IF (_count > 0) THEN RETURN -1; END IF; SELECT count(*) INTO _count FROM vendinfo WHERE (vend_active AND (vend_addr_id = paddrId)); IF (_count > 0) THEN RETURN -2; END IF; SELECT count(*) INTO _count FROM shiptoinfo WHERE (shipto_active AND (shipto_addr_id = paddrId)); IF (_count > 0) THEN RETURN -3; END IF; SELECT count(*) INTO _count FROM vendaddrinfo WHERE (vendaddr_addr_id = paddrId); IF (_count > 0) THEN RETURN -4; END IF; SELECT count(*) INTO _count FROM whsinfo WHERE (warehous_active AND (warehous_addr_id = paddrId)); IF (_count > 0) THEN RETURN -5; END IF; UPDATE cntct SET cntct_addr_id = NULL WHERE (cntct_addr_id = paddrId); UPDATE vendinfo SET vend_addr_id = NULL WHERE (vend_addr_id = paddrId); UPDATE shiptoinfo SET shipto_addr_id = NULL WHERE (shipto_addr_id =paddrId); UPDATE vendaddrinfo SET vendaddr_addr_id = NULL WHERE (vendaddr_addr_id = paddrId); UPDATE whsinfo SET warehous_addr_id = NULL WHERE (warehous_addr_id=paddrId); DELETE FROM addr WHERE addr_id = paddrId; RETURN 0; END; $_$; -DROP FUNCTION public.deleteaddress(integer); publicadminfalse46238'125578291deleteapcheck(integer)FUNCTIONMCREATE FUNCTION deleteapcheck(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'deleteAPCheck() is deprecated - use deleteCheck() instead'; RETURN deleteCheck($1); END; $_$; -DROP FUNCTION public.deleteapcheck(integer); publicadminfalse46238)125578292!deletebankadjustmenttype(integer)FUNCTIONCREATE FUNCTION deletebankadjustmenttype(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBankadjtypeid ALIAS FOR $1; _check INTEGER; BEGIN -- Check to see if the the adjustment type is being used in any adjustments SELECT bankadj_bankadjtype_id INTO _check FROM bankadj WHERE (bankadj_bankadjtype_id=pBankadjtypeid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; -- Delete the Account DELETE FROM bankadjtype WHERE (bankadjtype_id=pbankadjtypeid); RETURN 0; END; $_$; 8DROP FUNCTION public.deletebankadjustmenttype(integer); publicadminfalse84623*125578293!deletebankreconciliation(integer)FUNCTIONCREATE FUNCTION deletebankreconciliation(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pbankrecid ALIAS FOR $1; BEGIN DELETE FROM bankrecitem WHERE bankrecitem_bankrec_id=pbankrecid; DELETE FROM bankrec WHERE bankrec_id=pbankrecid; RETURN 0; END; $_$; 8DROP FUNCTION public.deletebankreconciliation(integer); publicadminfalse84623+125578294deletebom(integer)FUNCTIONCREATE FUNCTION deletebom(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; _result INTEGER; BEGIN IF (fetchmetricbool('RevControl')) THEN SELECT rev_id INTO _result FROM rev WHERE ((rev_target_id=pItemid) AND (rev_target_type = 'BOM')) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Bill of Materials has revision control records and may not be deleted.'; END IF; END IF; DELETE FROM bomhead WHERE (bomhead_item_id=pItemid); DELETE FROM bomitem WHERE (bomitem_parent_item_id=pItemid); RETURN 0; END; $_$; )DROP FUNCTION public.deletebom(integer); publicadminfalse46238,125578295deletebomworkset(integer)FUNCTIONCREATE FUNCTION deletebomworkset(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWorksetid ALIAS FOR $1; BEGIN -- All done with the bomwork set indicated by pWorksetid, delete all of it DELETE FROM bomwork WHERE (bomwork_set_id=pWorksetid); RETURN 1; END; $_$; 0DROP FUNCTION public.deletebomworkset(integer); publicadminfalse46238-125578296deletebudget(integer)FUNCTIONCREATE FUNCTION deletebudget(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBudgheadid ALIAS FOR $1; BEGIN DELETE FROM budgitem WHERE (budgitem_budghead_id=pBudgheadid); DELETE FROM budghead WHERE (budghead_id=pBudgheadid); RETURN pBudgheadid; END; $_$; ,DROP FUNCTION public.deletebudget(integer); publicadminfalse46238.125578297deletebudgetitems(integer)FUNCTIONhCREATE FUNCTION deletebudgetitems(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBudgheadid ALIAS FOR $1; BEGIN DELETE FROM budgitem WHERE (budgitem_budghead_id=pBudgheadid); RETURN pBudgheadid; END; $_$; 1DROP FUNCTION public.deletebudgetitems(integer); publicadminfalse84623/125578298deletecashrcpt(integer)FUNCTIONiCREATE FUNCTION deletecashrcpt(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pcashrcptid ALIAS FOR $1; _ccreceipt BOOLEAN; BEGIN IF EXISTS(SELECT cashrcpt_id FROM cashrcpt JOIN ccpay ON (cashrcpt_cust_id=ccpay_cust_id) AND ((CASE WHEN TRIM(COALESCE(cashrcpt_docnumber, ''))='' THEN TEXT(cashrcpt_id) ELSE cashrcpt_docnumber END)=ccpay_order_number) WHERE ((cashrcpt_fundstype IN ('A', 'D', 'M', 'V')) AND (ccpay_status NOT IN ('D', 'X')) AND (ccpay_id NOT IN (SELECT payco_ccpay_id FROM payco)) AND (cashrcpt_id=pcashrcptid))) THEN RETURN -1; END IF; IF EXISTS(SELECT cashrcpt_id FROM cashrcpt WHERE ( (cashrcpt_id=pcashrcptid) AND (cashrcpt_posted) )) THEN RETURN -2; END IF; -- If there are applications for this Cash Receipt then -- it has been posted and reversed. Void instead of delete. IF EXISTS(SELECT cashrcpt_id FROM cashrcpt JOIN cashrcptitem ON (cashrcptitem_cashrcpt_id=cashrcpt_id) JOIN arapply ON ((arapply_reftype='CRA') AND (arapply_ref_id=cashrcptitem_id)) WHERE (cashrcpt_id=pcashrcptid)) OR EXISTS(SELECT cashrcpt_id FROM cashrcpt JOIN cashrcptmisc ON (cashrcptmisc_cashrcpt_id=cashrcpt_id) JOIN arapply ON ((arapply_reftype='CRD') AND (arapply_ref_id=cashrcptmisc_id)) WHERE (cashrcpt_id=pcashrcptid)) THEN UPDATE cashrcpt SET cashrcpt_void = TRUE WHERE (cashrcpt_id=pcashrcptid); RETURN 1; END IF; DELETE FROM cashrcptitem WHERE (cashrcptitem_cashrcpt_id=pcashrcptid); DELETE FROM cashrcptmisc WHERE (cashrcptmisc_cashrcpt_id=pcashrcptid); DELETE FROM cashrcpt WHERE (cashrcpt_id=pcashrcptid); RETURN 1; END; $_$; .DROP FUNCTION public.deletecashrcpt(integer); publicadminfalse846230125578299deletecharacteristic(integer)FUNCTIONCREATE FUNCTION deletecharacteristic(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCharid ALIAS FOR $1; _uses TEXT; BEGIN IF NOT EXISTS(SELECT 1 FROM char WHERE char_id = pCharid) THEN RETURN 0; END IF; SELECT string_agg(DISTINCT(charass_target_type), ':') INTO _uses FROM charass WHERE charass_char_id = pCharid; IF _uses IS NOT NULL THEN RAISE EXCEPTION 'This characteristic cannot be deleted because it is in use [xtuple: deleteCharacteristic, -99, %]', _uses; END IF; DELETE FROM "char" WHERE (char_id=pCharid); RETURN pCharid; END; $_$; 4DROP FUNCTION public.deletecharacteristic(integer); publicadminfalse462381125578300deletecheck(integer)FUNCTIONxCREATE FUNCTION deletecheck(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCheckid ALIAS FOR $1; BEGIN IF (SELECT (NOT checkhead_void) OR checkhead_posted OR checkhead_replaced OR checkhead_deleted OR (checkhead_ach_batch IS NOT NULL AND checkhead_printed) FROM checkhead WHERE (checkhead_id=pCheckid) ) THEN RETURN -1; END IF; UPDATE checkhead SET checkhead_deleted=TRUE WHERE (checkhead_id=pCheckid); RETURN 1; END; $_$; +DROP FUNCTION public.deletecheck(integer); publicadminfalse462382125578301deleteclasscode(integer)FUNCTIONdCREATE FUNCTION deleteclasscode(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pClasscodeid ALIAS FOR $1; _check INTEGER; BEGIN -- Check to see if any items are assigned to the passed classcode SELECT item_id INTO _check FROM item WHERE (item_classcode_id=pClasscodeid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; -- Delete the passed classcode DELETE FROM classcode WHERE (classcode_id=pClasscodeid); RETURN pClasscodeid; END; $_$; /DROP FUNCTION public.deleteclasscode(integer); publicadminfalse846233125578302deletecompany(integer)FUNCTION%CREATE FUNCTION deletecompany(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pcompanyid ALIAS FOR $1; BEGIN IF (EXISTS(SELECT accnt_id FROM accnt, company WHERE ((accnt_company=company_number) AND (company_id=pcompanyid)) )) THEN RETURN -1; END IF; DELETE FROM company WHERE (company_id=pcompanyid); RETURN pcompanyid; END; $_$; -DROP FUNCTION public.deletecompany(integer); publicadminfalse846234125578303deletecreditmemo(integer)FUNCTIONCREATE FUNCTION deletecreditmemo(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmheadid ALIAS FOR $1; BEGIN DELETE FROM cmitem WHERE (cmitem_cmhead_id=pCmheadid); DELETE FROM cmhead WHERE (cmhead_id=pCmheadid); RETURN TRUE; END; $_$; 0DROP FUNCTION public.deletecreditmemo(integer); publicadminfalse462385125578304deletecustomer(integer)FUNCTIONPCREATE FUNCTION deletecustomer(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; BEGIN PERFORM shipto_id FROM shiptoinfo WHERE (shipto_cust_id=pCustid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; PERFORM cohead_id FROM cohead WHERE (cohead_cust_id=pCustid) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; PERFORM cmhead_id FROM cmhead WHERE (cmhead_cust_id=pCustid) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; PERFORM cohist_id FROM cohist WHERE (cohist_cust_id=pCustid) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; PERFORM aropen_id FROM aropen WHERE (aropen_cust_id=pCustid) LIMIT 1; IF (FOUND) THEN RETURN -5; END IF; PERFORM checkhead_recip_id FROM checkhead WHERE ((checkhead_recip_id=pCustid) AND (checkhead_recip_type='C')) LIMIT 1; IF (FOUND) THEN RETURN -6; END IF; PERFORM invchead_id FROM invchead WHERE(invchead_cust_id=pCustid) LIMIT 1; IF (FOUND) THEN RETURN -7; END IF; PERFORM quhead_id FROM quhead WHERE(quhead_cust_id=pCustid) LIMIT 1; IF (FOUND) THEN RETURN -8; END IF; DELETE FROM taxreg WHERE ((taxreg_rel_type='C') AND (taxreg_rel_id=pCustid)); DELETE FROM ipsass WHERE (ipsass_cust_id=pCustid); DELETE FROM custinfo WHERE (cust_id=pCustid); UPDATE crmacct SET crmacct_cust_id = NULL WHERE (crmacct_cust_id=pCustid); RETURN 0; END; $_$; .DROP FUNCTION public.deletecustomer(integer); publicadminfalse462386125578305deletecustomertype(integer)FUNCTIONCREATE FUNCTION deletecustomertype(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCusttypeid ALIAS FOR $1; BEGIN IF EXISTS(SELECT 1 FROM custinfo WHERE (cust_custtype_id=pCusttypeid)) THEN RETURN -1; END IF; DELETE FROM ipsass WHERE (ipsass_custtype_id=pCusttypeid); DELETE FROM salesaccnt WHERE (salesaccnt_custtype_id=pCusttypeid); DELETE FROM araccnt WHERE (araccnt_custtype_id=pCusttypeid); DELETE FROM custform WHERE (custform_custtype_id=pCusttypeid); DELETE FROM custtype WHERE (custtype_id=pCusttypeid); RETURN pCusttypeid; END; $_$; 2DROP FUNCTION public.deletecustomertype(integer); publicadminfalse846237125578306deleteempgrp(integer)FUNCTIONCREATE FUNCTION deleteempgrp(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pempgrpid ALIAS FOR $1; BEGIN -- Check to see if any employees are assigned to the passed empgrp PERFORM empgrpitem_emp_id FROM empgrpitem WHERE (empgrpitem_empgrp_id=pempgrpid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; DELETE FROM empgrp WHERE (empgrp_id=pempgrpid); RETURN 0; END; $_$; ,DROP FUNCTION public.deleteempgrp(integer); publicadminfalse462388125578307deleteexpiredips()FUNCTIONCREATE FUNCTION deleteexpiredips() RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; BEGIN FOR _r IN SELECT ipshead_id FROM ipshead WHERE (ipshead_expires <= current_date) LOOP DELETE FROM ipsass WHERE (ipsass_ipshead_id=_r.ipshead_id); DELETE FROM ipsiteminfo WHERE (ipsitem_ipshead_id=_r.ipshead_id); DELETE FROM ipsfreight WHERE (ipsfreight_ipshead_id=_r.ipshead_id); DELETE FROM ipshead WHERE (ipshead_id=_r.ipshead_id); END LOOP; RETURN TRUE; END; $$; )DROP FUNCTION public.deleteexpiredips(); publicadminfalse462389125578308deletefile(integer)FUNCTIONCREATE FUNCTION deletefile(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ declare pId ALIAS FOR $1; begin delete from file where ( file_id in ( select file_id from file join docass on (docass_target_id=file_id) and (docass_target_type='FILE') where ( docass_id = pId ) ) ); delete from docass where docass_id = pId; return true; end; $_$; *DROP FUNCTION public.deletefile(integer); publicadminfalse84623:125578309deleteflgrp(integer)FUNCTION_CREATE FUNCTION deleteflgrp(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlgrpid ALIAS FOR $1; _r RECORD; BEGIN FOR _r IN SELECT flgrp_id FROM flgrp WHERE (flgrp_flgrp_id=pFlgrpid) LOOP PERFORM deleteFlgrp(_r.flgrp_id); END LOOP; DELETE FROM flitem WHERE (flitem_flgrp_id=pFlgrpid); DELETE FROM flspec WHERE (flspec_flgrp_id=pFlgrpid); DELETE FROM flgrp WHERE (flgrp_id=pFlgrpid); RETURN 1; END; $_$; +DROP FUNCTION public.deleteflgrp(integer); publicadminfalse46238;125578310deleteform(integer)FUNCTIONCREATE FUNCTION deleteform(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFormid ALIAS FOR $1; _key TEXT; _check INTEGER; BEGIN -- Cache the key of the passed form SELECT form_key INTO _key FROM form WHERE (form_id=pFormid); IF (NOT(FOUND)) THEN RETURN 0; END IF; -- Handle checks based on the type of the form IF (_key='Chck') THEN SELECT bankaccnt_id INTO _check FROM bankaccnt WHERE (bankaccnt_check_form_id=pFormid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; END IF; -- Delete the form DELETE FROM form WHERE (form_id=pFormid); RETURN pFormid; END; $_$; *DROP FUNCTION public.deleteform(integer); publicadminfalse46238<125578311deletefreightclass(integer)FUNCTIONCREATE FUNCTION deletefreightclass(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFreightClassid ALIAS FOR $1; _check INTEGER; BEGIN -- Check to see if any items are assigned to the passed freightclass SELECT item_id INTO _check FROM item WHERE (item_freightclass_id=pFreightClassid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; -- Delete the passed freightclass DELETE FROM freightclass WHERE (freightclass_id=pFreightClassid); RETURN pFreightClassid; END; $_$; 2DROP FUNCTION public.deletefreightclass(integer); publicadminfalse84623125578312deleteglseries(integer)FUNCTIONCREATE FUNCTION deleteglseries(integer) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pSequence ALIAS FOR $1; BEGIN DELETE FROM glseries WHERE (glseries_sequence=pSequence); RETURN pSequence; END; $_$; .DROP FUNCTION public.deleteglseries(integer); publicadminfalse84623>125578313deleteglseries(integer, text)FUNCTIONCREATE FUNCTION deleteglseries(integer, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; pNotes ALIAS FOR $2; _trialbalid INTEGER; _count INTEGER; _r RECORD; BEGIN -- March through all of the G/L Transactions for the passed sequence FOR _r IN SELECT gltrans_id, gltrans_date, gltrans_accnt_id, gltrans_amount, gltrans_posted, gltrans_rec, accnt_forwardupdate, period_id, period_closed, period_freeze FROM accnt, gltrans LEFT OUTER JOIN period ON (gltrans_date BETWEEN period_start AND period_end) WHERE ( (gltrans_accnt_id=accnt_id) AND (NOT gltrans_deleted) AND (gltrans_sequence=pSequence) ) LOOP -- If we can post into a Trial Balance, do so IF ( (NOT _r.period_closed) AND ( (NOT _r.period_freeze) OR (checkPrivilege('PostFrozenPeriod')) ) AND ( NOT _r.gltrans_rec) AND ( _r.gltrans_posted ) ) THEN -- Try to find an existing trialbal SELECT trialbal_id INTO _trialbalid FROM trialbal WHERE ( (trialbal_period_id=_r.period_id) AND (trialbal_accnt_id=_r.gltrans_accnt_id) ); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count > 0) THEN -- We found a trialbal, update it with the G/L Transaction -- Note - two stage update to avoid any funny value caching logic IF (_r.gltrans_amount > 0) THEN UPDATE trialbal SET trialbal_credits = (trialbal_credits - _r.gltrans_amount) WHERE (trialbal_id=_trialbalid); ELSE UPDATE trialbal SET trialbal_debits = (trialbal_debits - (_r.gltrans_amount * -1)) WHERE (trialbal_id=_trialbalid); END IF; UPDATE trialbal SET trialbal_ending = (trialbal_beginning - trialbal_debits + trialbal_credits), trialbal_dirty=TRUE WHERE (trialbal_id=_trialbalid); ELSE RAISE EXCEPTION 'Can not delete G/L Series. Trial balance record not found.'; END IF; -- Forward update if we should IF (_r.accnt_forwardupdate AND fetchmetricbool('ManualForwardUpdate')) THEN PERFORM forwardUpdateTrialBalance(_trialbalid); END IF; -- Delete any bank reconciliation records if this was marked cleared but non reconciled DELETE FROM bankrecitem WHERE ((bankrecitem_source='GL') AND (bankrecitem_source_id=_r.gltrans_id)); -- Unflag any journals as posted as a result of this series UPDATE sltrans SET sltrans_posted=false, sltrans_gltrans_journalnumber=null FROM gltrans WHERE ((gltrans_sequence=pSequence) AND (sltrans_gltrans_journalnumber=gltrans_journalnumber)); -- Mark the G/L Transaction as deleted UPDATE gltrans SET gltrans_posted=false, gltrans_deleted=true, gltrans_notes=gltrans_notes || E'\n' || pNotes WHERE (gltrans_id=_r.gltrans_id); ELSIF (_r.period_freeze) THEN RAISE EXCEPTION 'Can not delete a G/L Transaction in a frozen period'; ELSIF (_r.period_closed) THEN RAISE EXCEPTION 'Can not delete a G/L Transaction on account % in a closed period', formatGlAccount(_r.gltrans_accnt_id); ELSIF (_r.gltrans_rec) THEN RAISE EXCEPTION 'Can not delete a G/L Transaction that has been reconciled'; ELSIF (NOT _r.gltrans_posted) THEN RAISE EXCEPTION 'Can not delete a G/L Transaction that has not been posted to Trial Balance'; END IF; END LOOP; RETURN true; END; $_$; 4DROP FUNCTION public.deleteglseries(integer, text); publicadminfalse84623?125578314deleteincident(integer)FUNCTION5CREATE FUNCTION deleteincident(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pincdtid ALIAS FOR $1; _count INTEGER := 0; _incdtnbr INTEGER := 0; BEGIN SELECT COUNT(*) INTO _count FROM todoitem WHERE (todoitem_incdt_id=pincdtid); IF (_count > 0) THEN RETURN -1; END IF; DELETE FROM comment WHERE((comment_source='INCDT') AND (comment_source_id=pincdtid)); DELETE FROM incdthist WHERE (incdthist_incdt_id=pincdtid); DELETE FROM imageass WHERE ((imageass_source='INCDT') AND (imageass_source_id=pincdtid)); DELETE FROM url WHERE ((url_source='INCDT') AND (url_source_id=pincdtid)); SELECT incdt_number INTO _incdtnbr FROM incdt WHERE (incdt_id=pincdtid); DELETE FROM incdt WHERE (incdt_id=pincdtid); -- Incident #11538 needs to be fully resolved before release can be implemented -- PERFORM releaseIncidentNumber(_incdtnbr); RETURN 0; END; $_$; .DROP FUNCTION public.deleteincident(integer); publicadminfalse84623@125578315deleteinvoice(integer)FUNCTION CREATE FUNCTION deleteinvoice(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvcheadid ALIAS FOR $1; _cobmiscid INTEGER := -1; _cobill RECORD; _cobillid INTEGER := -1; BEGIN UPDATE shipitem SET shipitem_invoiced=FALSE, shipitem_invcitem_id=NULL FROM invcitem WHERE ((shipitem_invoiced) AND (shipitem_invcitem_id=invcitem_id) AND (invcitem_invchead_id=pInvcheadid)); UPDATE coitem SET coitem_status = 'O' WHERE ((coitem_status = 'C') AND (coitem_id IN (SELECT cobill_coitem_id FROM cobill, invcitem WHERE ((cobill_invcitem_id=invcitem_id) AND (invcitem_invchead_id=pInvcheadid))))); UPDATE invdetail SET invdetail_invcitem_id=NULL FROM invcitem WHERE ((invdetail_invcitem_id=invcitem_id) AND (invcitem_invchead_id=pInvcheadid)); -- Check for unposted cobmisc for the same S/O -- If found then consolidate SELECT cobmisc_id INTO _cobmiscid FROM cobmisc WHERE ((NOT cobmisc_posted) AND (cobmisc_cohead_id IN (SELECT coitem_cohead_id FROM invcitem JOIN coitem ON (coitem_id=invcitem_coitem_id) WHERE (invcitem_invchead_id=pInvcheadid)))) LIMIT 1; IF (FOUND) THEN -- Check for uposted cobill for the same S/O Item -- If found then consolidate FOR _cobill IN SELECT cobill.* FROM invcitem JOIN cobill ON (cobill_invcitem_id=invcitem_id) WHERE (invcitem_invchead_id=pInvcheadid) LOOP SELECT cobill_id INTO _cobillid FROM cobill WHERE (cobill_cobmisc_id=_cobmiscid) AND (cobill_coitem_id=_cobill.cobill_coitem_id); IF (FOUND) THEN UPDATE cobill SET cobill_qty = cobill_qty + _cobill.cobill_qty WHERE (cobill_id=_cobillid); DELETE FROM cobill WHERE (cobill_id=_cobill.cobill_id); ELSE UPDATE cobill SET cobill_invcnum=NULL, cobill_invcitem_id=NULL, cobill_cobmisc_id=_cobmiscid WHERE (cobill_id=_cobill.cobill_id); END IF; END LOOP; DELETE FROM cobmisc WHERE (cobmisc_invchead_id=pInvcheadid); ELSE UPDATE cobill SET cobill_invcnum=NULL, cobill_invcitem_id=NULL FROM invcitem WHERE ((cobill_invcitem_id=invcitem_id) AND (invcitem_invchead_id=pInvcheadid)); UPDATE cobmisc SET cobmisc_invcnumber=NULL, cobmisc_invchead_id=NULL, cobmisc_posted=FALSE WHERE (cobmisc_invchead_id=pInvcheadid); END IF; DELETE FROM aropenalloc WHERE (aropenalloc_doctype='I') AND (aropenalloc_doc_id=pInvcheadid); DELETE FROM charass WHERE (charass_target_type='INV') AND (charass_target_id=pInvcheadid); DELETE FROM invcitem WHERE (invcitem_invchead_id=pInvcheadid); DELETE FROM invchead WHERE (invchead_id=pInvcheadid); RETURN pInvcheadid; END; $_$; -DROP FUNCTION public.deleteinvoice(integer); publicadminfalse46238A125578316deleteipsitem(integer)FUNCTION>CREATE FUNCTION deleteipsitem(pipsitemid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM ipsiteminfo WHERE ipsitem_id=pIpsItemId; RETURN 1; END; $$; 8DROP FUNCTION public.deleteipsitem(pipsitemid integer); publicadminfalse46238B125578317deleteipsprodcat(integer)FUNCTIONCCREATE FUNCTION deleteipsprodcat(pipsitemid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN DELETE FROM ipsiteminfo WHERE ipsitem_id=pIpsItemId; RETURN 1; END; $$; ;DROP FUNCTION public.deleteipsprodcat(pipsitemid integer); publicadminfalse46238C125578318deleteitem(integer)FUNCTIONCREATE FUNCTION deleteitem(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; _result INTEGER; BEGIN SELECT bomitem_id INTO _result FROM bomitem WHERE (bomitem_item_id=pItemid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; SELECT itemsite_id INTO _result FROM itemsite WHERE (itemsite_item_id=pItemid) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; SELECT itemsub_id INTO _result FROM itemsub WHERE (itemsub_sub_item_id=pItemid) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; IF (fetchmetricbool('RevControl')) THEN SELECT rev_id INTO _result FROM rev WHERE ((rev_target_id=pItemid) AND (rev_target_type = 'BOM')) LIMIT 1; IF (FOUND) THEN RETURN -6; END IF; END IF; DELETE FROM bomhead WHERE (bomhead_item_id=pItemid); DELETE FROM bomitem WHERE (bomitem_item_id=pItemid); DELETE FROM itemcost WHERE (itemcost_item_id=pItemid); DELETE FROM costhist WHERE (costhist_item_id=pItemid); DELETE FROM itemsub WHERE (itemsub_parent_item_id=pItemid); DELETE FROM itemsub WHERE (itemsub_sub_item_id=pItemid); DELETE FROM itemsrcp WHERE (itemsrcp_itemsrc_id IN (SELECT itemsrc_id FROM itemsrc WHERE (itemsrc_item_id=pItemid))); DELETE FROM itemsrc WHERE (itemsrc_item_id=pItemid); DELETE FROM itemalias WHERE (itemalias_item_id=pItemid); DELETE FROM itemgrpitem WHERE (itemgrpitem_item_id=pItemid); DELETE FROM ipsiteminfo WHERE (ipsitem_item_id=pItemid); DELETE FROM imageass WHERE ( (imageass_source='I') AND (imageass_source_id=pItemid) ); DELETE FROM locitem WHERE (locitem_item_id=pItemid); DELETE FROM itemtax WHERE(itemtax_item_id=pItemid); DELETE FROM itemsite WHERE (itemsite_item_id=pItemid); DELETE FROM itemuom WHERE(itemuom_itemuomconv_id IN (SELECT itemuomconv_id FROM itemuomconv WHERE(itemuomconv_item_id=pItemid))); DELETE FROM itemuomconv WHERE(itemuomconv_item_id=pItemid); DELETE FROM item WHERE (item_id=pItemid); RETURN 0; END; $_$; *DROP FUNCTION public.deleteitem(integer); publicadminfalse46238D125578319 deleteitemcost(integer, integer)FUNCTIONCREATE FUNCTION deleteitemcost(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemId ALIAS FOR $1; pCostElemId ALIAS FOR $2; _itemcost_id INTEGER; _postcost_return BOOLEAN; _std_cost NUMERIC; BEGIN SELECT itemcost_id INTO _itemcost_id FROM itemcost WHERE ( (itemcost_item_id = pItemId) AND (itemcost_costelem_id = pCostElemId) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'itemcost % not found for. ', pItemId || ' & ' || pCostElemId; END IF; SELECT itemcost_stdcost INTO _std_cost FROM itemcost WHERE (itemcost_id = _itemcost_id); IF (_std_cost > 0) THEN --Actual Cost is updated to zero to ensure inventory is valued correctly PERFORM updateCost(_itemcost_id, 0); END IF; DELETE FROM itemcost WHERE (itemcost_id=_itemcost_id); RETURN _itemcost_id; END; $_$; 7DROP FUNCTION public.deleteitemcost(integer, integer); publicadminfalse84623=125578320deleteitemsite(integer)FUNCTIONCREATE FUNCTION deleteitemsite(pitemsiteid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _result INTEGER; _lotserial BOOLEAN; _bbom BOOLEAN; _mfg BOOLEAN; _standard BOOLEAN; BEGIN IF ( ( SELECT (itemsite_qtyonhand <> 0) FROM itemsite WHERE (itemsite_id=pItemsiteid) ) ) THEN RETURN -9; END IF; SELECT metric_value='t' INTO _bbom FROM metric WHERE (metric_name='BBOM'); SELECT metric_value='t' INTO _lotserial FROM metric WHERE (metric_name='LotSerialControl'); SELECT metric_value NOT IN ('PostBooks', 'Standard') INTO _mfg FROM metric WHERE (metric_name='Application'); SELECT metric_value='Standard' INTO _standard FROM metric WHERE (metric_name='Application'); SELECT invhist_id INTO _result FROM invhist WHERE (invhist_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; IF (_lotserial) THEN SELECT lsdetail_id INTO _result FROM lsdetail WHERE (lsdetail_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; END IF; SELECT wo_id INTO _result FROM wo WHERE (wo_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; SELECT womatl_id INTO _result FROM womatl WHERE (womatl_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; SELECT womatlvar_id INTO _result FROM womatlvar WHERE ( (womatlvar_parent_itemsite_id=pItemsiteid) OR (womatlvar_component_itemsite_id=pItemsiteid) ) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; IF (_bbom) THEN SELECT brdvar_id INTO _result FROM xtmfg.brdvar WHERE ( (brdvar_itemsite_id=pItemsiteid) OR (brdvar_parent_itemsite_id=pItemsiteid) ) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; END IF; SELECT coitem_id INTO _result FROM coitem WHERE (coitem_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; SELECT cohist_id INTO _result FROM cohist WHERE (cohist_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; SELECT quitem_id INTO _result FROM quitem WHERE (quitem_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; SELECT cmitem_id INTO _result FROM cmitem WHERE (cmitem_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; SELECT poitem_id INTO _result FROM poitem WHERE (poitem_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; SELECT recv_id INTO _result FROM recv WHERE (recv_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; SELECT poreject_id INTO _result FROM poreject WHERE (poreject_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; SELECT pr_id INTO _result FROM pr WHERE (pr_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; IF (_mfg OR _standard) THEN SELECT planord_id INTO _result FROM planord WHERE (planord_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -5; END IF; END IF; IF (_mfg) THEN SELECT pschitem_id INTO _result FROM xtmfg.pschitem WHERE (pschitem_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -6; END IF; SELECT woopervar_id INTO _result FROM xtmfg.woopervar WHERE (woopervar_parent_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; END IF; IF (_mfg OR _standard) THEN SELECT itemsite_id INTO _result FROM itemsite WHERE (itemsite_supply_itemsite_id=pItemsiteid) LIMIT 1; IF (FOUND) THEN RETURN -7; END IF; END IF; DELETE FROM invcnt WHERE (invcnt_itemsite_id=pItemsiteid); DELETE FROM itemloc WHERE (itemloc_itemsite_id=pItemsiteid); DELETE FROM itemlocdist WHERE (itemlocdist_itemsite_id=pItemsiteid); IF (_bbom) THEN DELETE FROM xtmfg.brddist WHERE (brddist_itemsite_id=pItemsiteid); END IF; DELETE FROM itemsite WHERE (itemsite_id=pItemsiteid); RETURN 0; END; $$; :DROP FUNCTION public.deleteitemsite(pitemsiteid integer); publicadminfalse84623E125578321deleteitemuom(integer)FUNCTIONKCREATE FUNCTION deleteitemuom(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemuomid ALIAS FOR $1; BEGIN DELETE FROM itemuom WHERE itemuom_id=pItemuomid; RETURN 0; END; $_$; -DROP FUNCTION public.deleteitemuom(integer); publicadminfalse84623G125578322deleteitemuomconv(integer)FUNCTIONCREATE FUNCTION deleteitemuomconv(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemuomconvid ALIAS FOR $1; _fromuomid INTEGER; _invuomid INTEGER; _itemid INTEGER; _touomid INTEGER; BEGIN SELECT itemuomconv_item_id, item_inv_uom_id, itemuomconv_from_uom_id, itemuomconv_to_uom_id INTO _itemid, _invuomid, _fromuomid, _touomid FROM itemuomconv JOIN item ON (itemuomconv_item_id=item_id) WHERE (itemuomconv_id=pItemuomconvid); IF EXISTS(SELECT * FROM uomusedforitem(_itemid) WHERE ((uom_id IN (_fromuomid, _touomid)) AND (uom_id != _invuomid)) ) THEN RETURN -1; END IF; DELETE FROM itemuom WHERE itemuom_itemuomconv_id=pItemuomconvid; DELETE FROM itemuomconv WHERE itemuomconv_id=pItemuomconvid; RETURN 0; END; $_$; 1DROP FUNCTION public.deleteitemuomconv(integer); publicadminfalse84623H125578323deletelocation(integer)FUNCTIONCREATE FUNCTION deletelocation(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLocationid ALIAS FOR $1; _check INTEGER; BEGIN -- Check to see if any itemsite used the passed location as their default SELECT itemsite_id INTO _check FROM itemsite WHERE (itemsite_location_id=pLocationid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; -- Check to see if any inventory is currently stored at the passed location SELECT itemloc_id INTO _check FROM itemloc WHERE (itemloc_location_id=pLocationid) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; -- Check to see if any undistributed inventory transactions are currently posted at the passed location SELECT itemlocdist_id INTO _check FROM itemlocdist WHERE ( (itemlocdist_source_type='L') AND (itemlocdist_source_id=pLocationid) ) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; -- Check to see if the passed location has any Inventory Detail posted against it SELECT invdetail_id INTO _check FROM invdetail WHERE (invdetail_location_id=pLocationid) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; -- Delete any associated locitem records DELETE FROM locitem WHERE (locitem_location_id=pLocationid); -- Delete the location record DELETE FROM location WHERE (location_id=pLocationid); RETURN pLocationid; END; $_$; .DROP FUNCTION public.deletelocation(integer); publicadminfalse46238I125578324deletemetasql(integer)FUNCTION=CREATE FUNCTION deletemetasql(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pid ALIAS FOR $1; BEGIN DELETE FROM metasql WHERE metasql_id = pid; RETURN 0; END; $_$; -DROP FUNCTION public.deletemetasql(integer); publicadminfalse46238J125578325Jdeleteopenrecurringitems(integer, text, timestamp with time zone, boolean)FUNCTIONCREATE FUNCTION deleteopenrecurringitems(integer, text, timestamp with time zone, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pParentid ALIAS FOR $1; pType TEXT := UPPER($2); pDatetime TIMESTAMP WITH TIME ZONE := COALESCE($3, startOfTime()); pInclParent BOOLEAN := COALESCE($4, FALSE); _count INTEGER := 0; _delchildstmt TEXT; _delparentstmt TEXT; _rt RECORD; _tmp INTEGER; BEGIN RAISE DEBUG 'deleteOpenRecurringItems(%, %, %)', pParentid, pType, pDatetime; IF (pParentid IS NULL) THEN RETURN -11; END IF; SELECT * INTO _rt FROM recurtype WHERE (UPPER(recurtype_type)=pType); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count <= 0) THEN RETURN -10; END IF; -- 2 deletes avoid reparenting problems if the parent gets deleted first IF (_rt.recurtype_delfunc IS NULL) THEN _delchildstmt := 'DELETE FROM [fulltable] ' || ' WHERE (NOT ([done])' || ' AND ([schedcol]>''$2'')' || ' AND ([table]_recurring_[table]_id=$1)' || ' AND ([table]_id!=$1));'; _delparentstmt := 'DELETE FROM [fulltable] USING recur' || ' WHERE (NOT ([done])' || ' AND ([schedcol]>''$2'')' || ' AND ([table]_recurring_[table]_id=$1)' || ' AND ([table]_id=$1));'; ELSE _delchildstmt := 'SELECT [delfunc]([table]_id)' || ' FROM [fulltable] ' || ' WHERE (NOT ([done])' || ' AND ([schedcol]>''$2'')' || ' AND ([table]_recurring_[table]_id=$1)' || ' AND ([table]_id!=$1));'; _delparentstmt := 'SELECT [delfunc]([table]_id)' || ' FROM [fulltable] ' || ' WHERE (NOT ([done])' || ' AND ([schedcol]>''$2'')' || ' AND ([table]_recurring_[table]_id=$1)' || ' AND ([table]_id!=$1));'; _delchildstmt := REPLACE(_delchildstmt, '[delfunc]', _rt.recurtype_delfunc); _delparentstmt := REPLACE(_delparentstmt, '[delfunc]', _rt.recurtype_delfunc); END IF; RAISE DEBUG '_delchildstmt has been set to %', _delchildstmt; _delchildstmt := REPLACE(_delchildstmt, '[fulltable]', _rt.recurtype_table); _delchildstmt := REPLACE(_delchildstmt, '[table]', REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', '')); _delchildstmt := REPLACE(_delchildstmt, '[done]', _rt.recurtype_donecheck); _delchildstmt := REPLACE(_delchildstmt, '[schedcol]', _rt.recurtype_schedcol); _delparentstmt := REPLACE(_delparentstmt, '[fulltable]', _rt.recurtype_table); _delparentstmt := REPLACE(_delparentstmt, '[table]', REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', '')); _delparentstmt := REPLACE(_delparentstmt, '[done]', _rt.recurtype_donecheck); _delparentstmt := REPLACE(_delparentstmt, '[schedcol]', _rt.recurtype_schedcol); RAISE DEBUG 'substitutions changed _delchildstmt to %', _delchildstmt; IF (_rt.recurtype_delfunc IS NULL) THEN -- 8.4+: EXECUTE _delchildstmt USING pDatetime, pType; RAISE DEBUG '% with % and %', _delchildstmt, pType, pDatetime; EXECUTE REPLACE(REPLACE(_delchildstmt, '$1', pParentid::TEXT), '$2', pDatetime::TEXT); GET DIAGNOSTICS _count = ROW_COUNT; IF (pInclParent) THEN -- 8.4+: EXECUTE _delparentstmt USING pDatetime, pType; RAISE DEBUG '% with % and %', _delparentstmt, pType, pDatetime; EXECUTE REPLACE(REPLACE(_delparentstmt, '$1', pParentid::TEXT), '$2', pDatetime::TEXT); GET DIAGNOSTICS _tmp = ROW_COUNT; _count := _count + _tmp; END IF; ELSE -- 8.4+: FOR _tmp IN EXECUTE _delchildstmt USING pDatetime, pType LOOP FOR _tmp IN EXECUTE REPLACE(REPLACE(_delchildstmt, '$1', pParentid::TEXT), '$2', pDatetime::TEXT) LOOP IF _tmp < 0 THEN RETURN _tmp; END IF; _count := _count + 1; END LOOP; IF (pInclParent) THEN -- 8.4+: EXECUTE _delparentstmt INTO _tmp USING pDatetime, pType; EXECUTE REPLACE(REPLACE(_delparentstmt, '$1', pParentid::TEXT), '$2', pDatetime::TEXT) INTO _tmp; IF (_tmp < 0) THEN RETURN _tmp; END IF; _count := _count + 1; END IF; END IF; RAISE DEBUG 'deleteOpenrecurringItems() returning %', _count; RETURN _count; END; $_$; aDROP FUNCTION public.deleteopenrecurringitems(integer, text, timestamp with time zone, boolean); publicadminfalse84623K125578326deleteopportunity(integer)FUNCTIONCREATE FUNCTION deleteopportunity(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOpheadid ALIAS FOR $1; _test INTEGER; BEGIN SELECT todoitem_id INTO _test FROM todoitem WHERE(todoitem_ophead_id=pOpheadid) LIMIT 1; IF(FOUND) THEN RETURN -1; END IF; SELECT quhead_id INTO _test FROM quhead WHERE(quhead_ophead_id=pOpheadid) LIMIT 1; IF(FOUND) THEN RETURN -2; END IF; SELECT cohead_id INTO _test FROM cohead WHERE(cohead_ophead_id=pOpheadid) LIMIT 1; IF(FOUND) THEN RETURN -3; END IF; DELETE FROM charass WHERE((charass_target_type='OPP') AND (charass_target_id=pOpheadid)); DELETE FROM comment WHERE((comment_source='OPP') AND (comment_source_id=pOpheadid)); DELETE FROM ophead WHERE(ophead_id=pOpheadid); return 0; END; $_$; 1DROP FUNCTION public.deleteopportunity(integer); publicadminfalse46238L125578327deletepackage(integer)FUNCTIONCREATE FUNCTION deletepackage(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ppkgheadid ALIAS FOR $1; _i INTEGER := 0; _pkgname TEXT; _r RECORD; _tabs TEXT[] := ARRAY['cmd', 'cmdarg', 'image', 'metasql', 'priv', 'report', 'script', 'uiform']; _debug BOOL := false; BEGIN IF (EXISTS(SELECT * FROM pkgdep WHERE (pkgdep_parent_pkghead_id=ppkgheadid))) THEN RETURN -1; END IF; SELECT pkghead_name INTO _pkgname FROM pkghead WHERE (pkghead_id=ppkgheadid); IF (NOT FOUND) THEN RETURN -2; END IF; IF (LOWER(_pkgname) = 'public' OR LOWER(_pkgname) = 'api') THEN RETURN -3; END IF; FOR _i IN ARRAY_LOWER(_tabs,1)..ARRAY_UPPER(_tabs,1) LOOP EXECUTE 'ALTER TABLE ' || _pkgname || '.pkg' || _tabs[_i] || ' DISABLE TRIGGER pkg' || _tabs[_i] || 'altertrigger;'; END LOOP; DELETE FROM pkghead WHERE pkghead_id=ppkgheadid; RETURN ppkgheadid; END; $_$; -DROP FUNCTION public.deletepackage(integer); publicadminfalse46238M125578328deletepo(integer)FUNCTION9CREATE FUNCTION deletepo(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPoheadid ALIAS FOR $1; _poitemid INTEGER; BEGIN IF ( ( SELECT pohead_status FROM pohead WHERE (pohead_id=pPoheadid) ) = 'U' ) THEN -- Unlink from any Sales Orders UPDATE coitem SET coitem_order_type=NULL, coitem_order_id=NULL FROM poitem WHERE ( (coitem_order_type='P') AND (coitem_order_id=poitem_id) AND (poitem_pohead_id=pPoheadid) ); DELETE FROM poitem WHERE (poitem_pohead_id=pPoheadid); DELETE FROM pohead WHERE (pohead_id=pPoheadid); RETURN TRUE; ELSE RETURN FALSE; END IF; END; $_$; (DROP FUNCTION public.deletepo(integer); publicadminfalse46238N125578329deletepoitem(integer)FUNCTIONCREATE FUNCTION deletepoitem(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPoitemid ALIAS FOR $1; _poheadid INTEGER := -1; _status CHARACTER; BEGIN SELECT poitem_pohead_id, poitem_status INTO _poheadid, _status FROM poitem WHERE (poitem_id=pPoitemid); IF NOT(FOUND) THEN RETURN 0; END IF; IF ( _status = 'U' ) THEN DELETE FROM poitem WHERE (poitem_id=pPoitemid); ELSE IF ( _status = 'O' ) THEN PERFORM recv_id FROM recv WHERE ( (recv_order_type='PO') AND (recv_orderitem_id=pPoitemid) ); IF (FOUND) THEN RETURN -10; ELSE RETURN -20; END IF; ELSE RETURN -10; END IF; END IF; PERFORM poitem_id FROM poitem WHERE poitem_pohead_id = _poheadid; IF NOT(FOUND) THEN DELETE FROM pohead WHERE (pohead_id = _poheadid); END IF; RETURN 0; END; $_$; ,DROP FUNCTION public.deletepoitem(integer); publicadminfalse46238P125578330deletepr(integer)FUNCTIONVCREATE FUNCTION deletepr(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrid ALIAS FOR $1; BEGIN DELETE FROM pr WHERE ( (pr_status='O') AND (pr_id=pPrid) ); RETURN TRUE; END; $_$; (DROP FUNCTION public.deletepr(integer); publicadminfalse46238O125578331deletepr(character, integer)FUNCTIONCREATE FUNCTION deletepr(character, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pParentType ALIAS FOR $1; pParentId ALIAS FOR $2; BEGIN DELETE FROM pr WHERE ((pr_status='O') AND (pr_order_type=pParentType) AND (pr_order_id=pParentId)); RETURN TRUE; END; $_$; 3DROP FUNCTION public.deletepr(character, integer); publicadminfalse46238Q125578332deleteproductcategory(integer)FUNCTIONCREATE FUNCTION deleteproductcategory(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pProdcatid ALIAS FOR $1; _check INTEGER; BEGIN -- Check to see if any items are assigned to the passed classcode SELECT item_id INTO _check FROM item WHERE (item_prodcat_id=pProdcatid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; -- Delete any assocated records DELETE FROM salesaccnt WHERE (salesaccnt_prodcat_id=pProdcatid); -- Delete the passed prodcat DELETE FROM prodcat WHERE (prodcat_id=pProdcatid); RETURN pProdcatid; END; $_$; 5DROP FUNCTION public.deleteproductcategory(integer); publicadminfalse84623R125578333deleteprofitcenter(integer)FUNCTIONCREATE FUNCTION deleteprofitcenter(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pid ALIAS FOR $1; BEGIN IF (EXISTS(SELECT accnt_id FROM accnt, prftcntr WHERE ((accnt_company=prftcntr_number) AND (prftcntr_id=pid)) )) THEN RETURN -1; END IF; DELETE FROM prftcntr WHERE (prftcntr_id=pid); RETURN pid; END; $_$; 2DROP FUNCTION public.deleteprofitcenter(integer); publicadminfalse46238S125578334deleteproject(integer)FUNCTIONCREATE FUNCTION deleteproject(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrjid ALIAS FOR $1; _result INTEGER; BEGIN SELECT quhead_id INTO _result FROM quhead WHERE (quhead_prj_id=pPrjid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; SELECT cohead_id INTO _result FROM cohead WHERE (cohead_prj_id=pPrjid) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; SELECT wo_id INTO _result FROM wo WHERE (wo_prj_id=pPrjid) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; SELECT pr_id INTO _result FROM pr WHERE (pr_prj_id=pPrjid) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; SELECT poitem_id INTO _result FROM poitem WHERE (poitem_prj_id=pPrjid) LIMIT 1; IF (FOUND) THEN RETURN -5; END IF; SELECT invchead_id INTO _result FROM invchead WHERE (invchead_prj_id=pPrjid) LIMIT 1; IF (FOUND) THEN RETURN -6; END IF; DELETE FROM comment WHERE ((comment_source='J') AND (comment_source_id=pPrjid)); DELETE FROM comment WHERE ((comment_source='TA') AND (comment_source_id IN ( SELECT prjtask_id FROM prjtask WHERE (prjtask_prj_id=pPrjId)))); DELETE FROM prjtask WHERE (prjtask_prj_id=pPrjid); UPDATE prj SET prj_recurring_prj_id=null WHERE(prj_recurring_prj_id=pPrjid); DELETE FROM prj WHERE (prj_id=pPrjid); RETURN pPrjid; END; $_$; -DROP FUNCTION public.deleteproject(integer); publicadminfalse46238T125578335deleteprojecttask(integer)FUNCTIONCREATE FUNCTION deleteprojecttask(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrjtaskid ALIAS FOR $1; _row RECORD; _result INTEGER; BEGIN SELECT * INTO _row FROM prjtask WHERE (prjtask_id=pPrjtaskid) LIMIT 1; IF (NOT FOUND) THEN RETURN -1; END IF; IF (COALESCE(_row.prjtask_hours_actual, 0.0) > 0.0) THEN RETURN -2; END IF; IF (COALESCE(_row.prjtask_exp_actual, 0.0) > 0.0) THEN RETURN -3; END IF; DELETE FROM comment WHERE ((comment_source='TA') AND (comment_source_id=pPrjtaskid)); DELETE FROM prjtask WHERE (prjtask_id=pPrjtaskid); RETURN 0; END; $_$; 1DROP FUNCTION public.deleteprojecttask(integer); publicadminfalse84623U125578336deleteqryhead(integer)FUNCTIONCREATE FUNCTION deleteqryhead(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pqryheadid ALIAS FOR $1; BEGIN DELETE FROM qryitem WHERE (qryitem_qryhead_id=pqryheadid); DELETE FROM qryhead WHERE (qryhead_id=pqryheadid); RETURN pqryheadid; END; $_$; -DROP FUNCTION public.deleteqryhead(integer); publicadminfalse84623V125578337deletequote(integer)FUNCTION4CREATE FUNCTION deletequote(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuheadid ALIAS FOR $1; BEGIN RETURN deleteQuote(pQuheadid, NULL::TEXT); END; $_$; +DROP FUNCTION public.deletequote(integer); publicadminfalse46238Z125578338deletequote(integer, text)FUNCTIONfCREATE FUNCTION deletequote(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuheadid ALIAS FOR $1; pQuoteNumber ALIAS FOR $2; _quNumberScheme TEXT; _quoteNumber TEXT; _quitemid INTEGER; _result INTEGER; BEGIN SELECT fetchMetricText('QUNumberGeneration') INTO _quNumberScheme; IF (pQuoteNumber IS NULL) THEN SELECT quhead_number INTO _quoteNumber FROM quhead WHERE (quhead_id=pQuheadid); ELSE _quoteNumber := pQuoteNumber; END IF; PERFORM deleteQuoteItem(quitem_id) FROM quitem WHERE (quitem_quhead_id=pQuheadid); DELETE FROM charass WHERE (charass_target_type='QU') AND (charass_target_id=pQuheadid); DELETE FROM quhead WHERE (quhead_id=pQuheadid); IF (_quoteNumber IS NOT NULL) THEN IF (_quNumberScheme IN ('A', 'O')) THEN -- do not release quote # if quote converted to sales order IF (NOT EXISTS (SELECT cohead_id FROM cohead WHERE (cohead_number=_quoteNumber))) THEN _result = releaseQuNumber(_quoteNumber); END IF; ELSEIF (_quNumberScheme = 'S') THEN _result = releaseSoNumber(_quoteNumber); END IF; END IF; -- Don't care about result of release number RETURN 0; END; $_$; 1DROP FUNCTION public.deletequote(integer, text); publicadminfalse84623W125578339deletequote(integer, integer)FUNCTIONbCREATE FUNCTION deletequote(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuheadid ALIAS FOR $1; pQuoteNumber ALIAS FOR $2; BEGIN RETURN deleteQuote(pQuheadid, pQuoteNumber::TEXT); END; $_$; 4DROP FUNCTION public.deletequote(integer, integer); publicadminfalse46238125578340deletequoteitem(integer)FUNCTIONRCREATE FUNCTION deletequoteitem(integer) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pQuitemid ALIAS FOR $1; _result INTEGER; BEGIN DELETE FROM charass WHERE (charass_target_type='QI') AND (charass_target_id=pQuitemid); DELETE FROM quitem WHERE (quitem_id=pQuitemid); RETURN 0; END; $_$; /DROP FUNCTION public.deletequoteitem(integer); publicadminfalse84623[125578341!deleterecvfororder(text, integer)FUNCTION7CREATE FUNCTION deleterecvfororder(text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; porderid ALIAS FOR $2; BEGIN DELETE FROM recv USING orderitem WHERE ((recv_orderitem_id=orderitem_id) AND (recv_order_type=orderitem_orderhead_type) AND (NOT recv_posted) AND (orderitem_orderhead_id=porderid) AND (orderitem_orderhead_type=pordertype)); RETURN 0; END; $_$; 8DROP FUNCTION public.deleterecvfororder(text, integer); publicadminfalse46238\125578342deletesalescategory(integer)FUNCTIONCREATE FUNCTION deletesalescategory(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSalescatid ALIAS FOR $1; BEGIN PERFORM invcitem_salescat_id FROM invchead, invcitem WHERE ( (invcitem_invchead_id=invchead_id) AND (NOT invchead_posted) AND (invcitem_salescat_id=pSalescatid) ); IF (FOUND) THEN RETURN -1; END IF; PERFORM invcitem_salescat_id FROM invchead, invcitem WHERE ( (invcitem_invchead_id=invchead_id) AND (invchead_posted) AND (invcitem_salescat_id=pSalescatid) ); IF (FOUND) THEN RETURN -2; END IF; PERFORM aropen_salescat_id FROM aropen WHERE (aropen_salescat_id=pSalescatid); IF (FOUND) THEN RETURN -3; END IF; DELETE FROM salescat WHERE (salescat_id=pSalescatid); RETURN 0; END; $_$; 3DROP FUNCTION public.deletesalescategory(integer); publicadminfalse84623]125578343deleteshippingcharge(integer)FUNCTIONCREATE FUNCTION deleteshippingcharge(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipchrgid ALIAS FOR $1; BEGIN IF EXISTS(SELECT 1 FROM custinfo WHERE (cust_shipchrg_id=pShipchrgid)) THEN RETURN -1; END IF; DELETE FROM shipchrg WHERE (shipchrg_id=pShipchrgid); RETURN pShipchrgid; END; $_$; 4DROP FUNCTION public.deleteshippingcharge(integer); publicadminfalse84623^125578344!deleteshippingchargetype(integer)FUNCTIONCREATE FUNCTION deleteshippingchargetype(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipchrgid ALIAS FOR $1; _check INTEGER; BEGIN -- Check to see if the passed shipchrg is used as a default for any customers SELECT cust_id INTO _check FROM custinfo WHERE (cust_shipchrg_id=pShipchrgid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; -- Check to see if the passed shipchrg is used as a default for any shiptos SELECT shipto_id INTO _check FROM shiptoinfo WHERE (shipto_shipchrg_id=pShipchrgid) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; -- Check to see if the passed shipchrg is used on any sales orders SELECT cohead_id INTO _check FROM cohead WHERE (cohead_shipchrg_id=pShipchrgid) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; -- Check to see if the passed shipchrg is used on any shippers SELECT shiphead_id INTO _check FROM shiphead WHERE (shiphead_shipchrg_id=pShipchrgid) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; -- Check to see if the passed shipchrg is used on any invoices SELECT invchead_id INTO _check FROM invchead WHERE (invchead_shipchrg_id=pShipchrgid) LIMIT 1; IF (FOUND) THEN RETURN -5; END IF; -- Delete the passed shipchrg DELETE FROM shipchrg WHERE (shipchrg_id=pShipchrgid); RETURN pShipchrgid; END; $_$; 8DROP FUNCTION public.deleteshippingchargetype(integer); publicadminfalse46238_125578345deleteshipto(integer)FUNCTIONCREATE FUNCTION deleteshipto(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShiptoid ALIAS FOR $1; BEGIN PERFORM asohist_id FROM asohist WHERE (asohist_shipto_id=pShiptoid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; PERFORM cohead_id FROM cohead WHERE (cohead_shipto_id=pShiptoid) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; PERFORM cmhead_id FROM cmhead WHERE (cmhead_shipto_id=pShiptoid) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; PERFORM cohist_id FROM cohist WHERE (cohist_shipto_id=pShiptoid) LIMIT 1; IF (FOUND) THEN RETURN -4; END IF; PERFORM quhead_id FROM quhead WHERE (quhead_shipto_id=pShiptoid) LIMIT 1; IF (FOUND) THEN RETURN -5; END IF; PERFORM invchead_id FROM invchead WHERE (invchead_shipto_id=pShiptoid) LIMIT 1; IF (FOUND) THEN RETURN -6; END IF; DELETE FROM ipsass WHERE (ipsass_shipto_id=pShiptoid); DELETE FROM shiptoinfo WHERE (shipto_id=pShiptoid); RETURN 0; END; $_$; ,DROP FUNCTION public.deleteshipto(integer); publicadminfalse84623`125578346deleteso(integer)FUNCTION+CREATE FUNCTION deleteso(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; BEGIN RETURN deleteSo(pSoheadid, NULL); END; $_$; (DROP FUNCTION public.deleteso(integer); publicadminfalse46238a125578347deleteso(integer, text)FUNCTIONCREATE FUNCTION deleteso(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; pSonumber ALIAS FOR $2; _r RECORD; _coitemid INTEGER; _result INTEGER; _poStatus INTEGER := 0; BEGIN -- Get cohead SELECT * INTO _r FROM cohead WHERE (cohead_id=pSoheadid); IF (NOT FOUND) THEN IF (COALESCE(pSonumber,'') != '') THEN _result := releaseSoNumber(pSonumber); END IF; RETURN 0; END IF; -- Cannot delete if credit card payments IF (EXISTS(SELECT ccpay_id FROM ccpay, payco WHERE ((ccpay_status IN ('C')) AND (ccpay_id=payco_ccpay_id) AND (payco_cohead_id=pSoheadid)))) THEN RETURN -1; END IF; -- Cannot delete if credit card history IF (EXISTS(SELECT ccpay_id FROM ccpay, payco WHERE ((ccpay_status != 'C') AND (ccpay_id=payco_ccpay_id) AND (payco_cohead_id=pSoheadid)))) THEN RETURN -2; END IF; -- Delete Sales Order Items FOR _coitemid IN SELECT coitem_id FROM coitem WHERE ( (coitem_cohead_id=pSoheadid) AND (coitem_subnumber=0) ) LOOP SELECT deleteSoItem(_coitemid) INTO _result; IF (_result < 0) THEN IF (_result = -20) THEN _poStatus := _poStatus - 1; ELSE RETURN _result; END IF; END IF; END LOOP; DELETE FROM pack WHERE (pack_head_id=pSoheadid and pack_head_type = 'SO'); DELETE FROM charass WHERE (charass_target_type='SO') AND (charass_target_id=pSoheadid); DELETE FROM cohead WHERE (cohead_id=pSoheadid); IF (fetchMetricBool('AutoCreateProjectsForOrders')) THEN PERFORM deleteProject(_r.cohead_prj_id); END IF; DELETE FROM aropenalloc WHERE ((aropenalloc_doctype='S') AND (aropenalloc_doc_id=pSoheadid)); IF ( (NOT _r.cohead_wasquote) AND (NOT _r.cohead_imported) ) THEN IF (COALESCE(pSonumber,'') != '') THEN _result = releaseSoNumber(pSonumber); ELSEIF (_r.cohead_number IS NOT NULL) THEN _result = releaseSoNumber(_r.cohead_number); END IF; END IF; IF (_poStatus < 0) THEN RETURN -20; ELSE RETURN 0; END IF; END; $_$; .DROP FUNCTION public.deleteso(integer, text); publicadminfalse46238b125578348deletesoitem(integer)FUNCTIONCREATE FUNCTION deletesoitem(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoitemid ALIAS FOR $1; _r RECORD; _s RECORD; _result INTEGER; _deletePO INTEGER := 0; _recvId INTEGER := -1; _poStatus TEXT; _jobItem BOOLEAN; BEGIN -- Get coitem SELECT * INTO _r FROM coitem WHERE (coitem_id=pSoitemid); IF (NOT FOUND) THEN RETURN -999; END IF; -- Cannot delete if shipped IF (_r.coitem_qtyshipped > 0) THEN RETURN -101; END IF; -- Cannot delete if issued to shipping SELECT shipitem_id INTO _result FROM shipitem JOIN shiphead ON (shiphead_id=shipitem_shiphead_id AND shiphead_order_type='SO') WHERE (shipitem_orderitem_id=pSoitemid) LIMIT 1; IF (FOUND) THEN RETURN -102; END IF; -- Cannot delete if returned IF (fetchMetricBool('MultiWhs')) THEN SELECT raitem_id INTO _result FROM raitem WHERE ( (raitem_orig_coitem_id=pSoitemid) OR (raitem_new_coitem_id=pSoitemid) ) LIMIT 1; IF (FOUND) THEN RETURN -103; END IF; END IF; -- Cannot delete if any inventory history SELECT invhist_id INTO _result FROM invhist WHERE ( (invhist_ordnumber=formatSoNumber(pSoitemid)) AND (invhist_ordtype='SO') ) LIMIT 1; IF (FOUND) THEN RETURN -105; END IF; -- If Kit, check deletion of component items IF (_r.coitem_subnumber = 0) THEN FOR _s IN SELECT * FROM coitem WHERE ((coitem_cohead_id = _r.coitem_cohead_id) AND (coitem_linenumber = _r.coitem_linenumber) AND (coitem_subnumber > 0)) LOOP IF ((COALESCE(_s.coitem_order_id, -1) > 0) AND (_s.coitem_order_type = 'P')) THEN SELECT poitem_status, COALESCE(recv_id, -1) INTO _poStatus, _recvId FROM poitem LEFT OUTER JOIN recv ON ((recv_orderitem_id=poitem_id) AND (recv_order_type='PO')) WHERE (poitem_id = _s.coitem_order_id); IF ((_recvId > 0) OR (_poStatus = 'C')) THEN RETURN -10; ELSIF ((_recvId = -1) AND (_poStatus = 'O')) THEN _deletePO := _deletePO - 1; END IF; END IF; END LOOP; END IF; SELECT (itemsite_costmethod='J') INTO _jobItem FROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id) WHERE (coitem_id=pSoitemid); IF (_jobItem AND _r.coitem_order_type='W') THEN -- Delete associated Job Work Order SELECT deleteWo(_r.coitem_order_id, TRUE, TRUE) INTO _result; IF (_result < 0) THEN RETURN -104; END IF; ELSIF (_r.coitem_order_type='W') THEN -- Delete associated Job Work Order SELECT deleteWo(_r.coitem_order_id, TRUE) INTO _result; IF (_result < 0) THEN -- Cannot delete so break association PERFORM changeWoProject(_r.coitem_order_id, -1, TRUE); END IF; ELSIF (_r.coitem_order_type='R') THEN -- Delete associated Purchase Request PERFORM deletePr(_r.coitem_order_id); ELSIF (_r.coitem_order_type='P') THEN -- Delete associated Purchase Order Item SELECT deletepoitem(_r.coitem_order_id) INTO _result; IF ((_result < 0) AND (_result <> -20)) THEN RETURN _result; ELSIF (_result = -20) THEN _deletePO := _deletePO - 1; END IF; END IF; -- Delete characteristic assignments DELETE FROM charass WHERE (charass_target_type='SI') AND (charass_target_id=pSoitemid); -- Delete reservations IF (fetchMetricBool('EnableSOReservationsByLocation')) THEN DELETE FROM reserve WHERE (reserve_demand_type='SO') AND (reserve_demand_id=pSoitemid); END IF; -- Delete the coitem DELETE FROM coitem WHERE (coitem_id=pSoitemid); IF (_deletePO < 0) THEN RETURN -20; ELSE RETURN 0; END IF; END; $_$; ,DROP FUNCTION public.deletesoitem(integer); publicadminfalse84623c125578349deletestandardjournal(integer)FUNCTIONCREATE FUNCTION deletestandardjournal(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pStdjrnlid ALIAS FOR $1; BEGIN DELETE FROM stdjrnlitem WHERE (stdjrnlitem_stdjrnl_id=pStdjrnlid); DELETE FROM stdjrnlgrpitem WHERE (stdjrnlgrpitem_stdjrnl_id=pStdjrnlid); DELETE FROM stdjrnl WHERE (stdjrnl_id=pStdjrnlid); RETURN 1; END; $_$; 5DROP FUNCTION public.deletestandardjournal(integer); publicadminfalse84623d125578350#deletestandardjournalgroup(integer)FUNCTIONCREATE FUNCTION deletestandardjournalgroup(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pStdjrnlgrpid ALIAS FOR $1; BEGIN DELETE FROM stdjrnlgrpitem WHERE (stdjrnlgrpitem_stdjrnlgrp_id=pStdjrnlgrpid); DELETE FROM stdjrnlgrp WHERE (stdjrnlgrp_id=pStdjrnlgrpid); RETURN 1; END; $_$; :DROP FUNCTION public.deletestandardjournalgroup(integer); publicadminfalse46238e125578351deletesubaccount(integer)FUNCTIONCREATE FUNCTION deletesubaccount(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pid ALIAS FOR $1; BEGIN IF (EXISTS(SELECT accnt_id FROM accnt, subaccnt WHERE ((accnt_company=subaccnt_number) AND (subaccnt_id=pid)) )) THEN RETURN -1; END IF; DELETE FROM subaccnt WHERE (subaccnt_id=pid); RETURN pid; END; $_$; 0DROP FUNCTION public.deletesubaccount(integer); publicadminfalse84623f125578352deletesubaccounttype(integer)FUNCTIONCREATE FUNCTION deletesubaccounttype(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSubAccntTypeid ALIAS FOR $1; _check INTEGER; BEGIN -- Check to see if the passed subaccnttype is used in any accounts SELECT accnt_id INTO _check FROM accnt, subaccnttype WHERE ( (accnt_subaccnttype_code=subaccnttype_code) AND (subaccnttype_id=pSubAccntTypeid) ) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; -- Delete the Sub Account Type DELETE FROM subaccnttype WHERE (subaccnttype_id=pSubAccntTypeid); RETURN 0; END; $_$; 4DROP FUNCTION public.deletesubaccounttype(integer); publicadminfalse84623g125578353deletetax(integer)FUNCTIONCREATE FUNCTION deletetax(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ptaxid ALIAS FOR $1; BEGIN -- these checks allow nice error reporting instead of throwing an SQL error IF EXISTS(SELECT taxass_id FROM taxass WHERE (taxass_tax_id=ptaxid)) THEN RETURN -10; END IF; IF EXISTS(SELECT taxhist_id FROM taxhist WHERE (taxhist_tax_id=ptaxid)) THEN RETURN -20; END IF; DELETE FROM taxrate WHERE (taxrate_tax_id = ptaxid); DELETE FROM tax WHERE (tax_id = ptaxid); RETURN ptaxid; END; $_$; )DROP FUNCTION public.deletetax(integer); publicadminfalse46238h125578354deletetaxclass(integer)FUNCTIONSCREATE FUNCTION deletetaxclass(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxclassid ALIAS FOR $1; _result INTEGER; BEGIN -- Check to find if the tax class is used in any tax code SELECT tax_id INTO _result FROM tax WHERE (tax_taxclass_id = pTaxclassid); IF (FOUND) THEN RETURN -1; END IF; -- Delete the tax class if the above condition doesn't match DELETE FROM taxclass WHERE taxclass_id = pTaxclassid ; RETURN pTaxclassid; END; $_$; .DROP FUNCTION public.deletetaxclass(integer); publicadminfalse46238i125578355deletetaxtype(integer)FUNCTION$CREATE FUNCTION deletetaxtype(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxtypeid ALIAS FOR $1; _result INTEGER; BEGIN SELECT taxtype_id INTO _result FROM taxtype WHERE ((taxtype_sys) AND (taxtype_id=pTaxtypeid)); IF (FOUND) THEN RETURN -1; END IF; SELECT taxass_id INTO _result FROM taxass WHERE (taxass_taxtype_id=pTaxtypeid); IF (FOUND) THEN RETURN -2; END IF; SELECT taxhist_id INTO _result FROM taxhist WHERE (taxhist_taxtype_id=pTaxtypeid); IF (FOUND) THEN RETURN -3; END IF; DELETE FROM taxtype WHERE (taxtype_id=pTaxtypeid); RETURN pTaxtypeid; END; $_$; -DROP FUNCTION public.deletetaxtype(integer); publicadminfalse84623j125578356deletetaxzone(integer)FUNCTIONCREATE FUNCTION deletetaxzone(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxzoneid ALIAS FOR $1; _result INTEGER; BEGIN -- Check to find if the tax zone is used in any tax assignment SELECT taxass_id INTO _result FROM taxass WHERE (taxass_taxzone_id=pTaxzoneid); IF (FOUND) THEN RETURN -1; END IF; -- Check to find if the tax zone has been referenced in any tax registration SELECT taxreg_id INTO _result FROM taxreg WHERE (taxreg_taxzone_id=pTaxzoneid); IF (FOUND) THEN RETURN -2; END IF; -- Delete the tax zone if none of the above conditions match DELETE FROM taxzone WHERE taxzone_id = pTaxzoneid ; RETURN pTaxzoneid; END; $_$; -DROP FUNCTION public.deletetaxzone(integer); publicadminfalse46238k125578357deletetodoitem(integer)FUNCTIONCREATE FUNCTION deletetodoitem(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ptodoItemId ALIAS FOR $1; BEGIN DELETE FROM alarm WHERE ( (alarm_source='TODO') AND (alarm_source_id=ptodoItemId) ); DELETE FROM todoitem WHERE todoitem_id = ptodoItemId; RETURN 0; END; $_$; .DROP FUNCTION public.deletetodoitem(integer); publicadminfalse84623X125578358deleteunusedclasscodes()FUNCTION[CREATE FUNCTION deleteunusedclasscodes() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN DELETE FROM classcode WHERE (classcode_id NOT IN (SELECT DISTINCT item_classcode_id FROM item)); RETURN 0; END; $$; /DROP FUNCTION public.deleteunusedclasscodes(); publicadminfalse46238Y125578359deleteunusedfreightclasses()FUNCTIONuCREATE FUNCTION deleteunusedfreightclasses() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN DELETE FROM freightclass WHERE (freightclass_id NOT IN (SELECT DISTINCT COALESCE(item_freightclass_id, 0) FROM item)); RETURN 0; END; $$; 3DROP FUNCTION public.deleteunusedfreightclasses(); publicadminfalse46238[125578360deleteunusedproductcategories()FUNCTIONCREATE FUNCTION deleteunusedproductcategories() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Delete any associated records DELETE FROM salesaccnt WHERE ( (salesaccnt_prodcat_id <> -1) AND (salesaccnt_prodcat_id NOT IN (SELECT DISTINCT item_prodcat_id FROM item)) ); DELETE FROM prodcat WHERE (prodcat_id NOT IN (SELECT DISTINCT item_prodcat_id FROM item)); RETURN 0; END; $$; 6DROP FUNCTION public.deleteunusedproductcategories(); publicadminfalse46238125578361deleteuom(integer)FUNCTIONCREATE FUNCTION deleteuom(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUomid ALIAS FOR $1; BEGIN DELETE FROM uomconv WHERE uomconv_from_uom_id=pUomid; DELETE FROM uomconv WHERE uomconv_to_uom_id=pUomid; DELETE FROM uom WHERE uom_id=pUomid; RETURN 0; END; $_$; )DROP FUNCTION public.deleteuom(integer); publicadminfalse46238125578362deleteuomconv(integer)FUNCTIONKCREATE FUNCTION deleteuomconv(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUomconvid ALIAS FOR $1; BEGIN DELETE FROM uomconv WHERE uomconv_id=pUomconvid; RETURN 0; END; $_$; -DROP FUNCTION public.deleteuomconv(integer); publicadminfalse84623125578363deleteurl(integer)FUNCTIONCREATE FUNCTION deleteurl(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ declare pId ALIAS FOR $1; begin delete from urlinfo where ( url_id in ( select url_id from urlinfo join docass on (docass_target_id=url_id) and (docass_target_type='URL') where ( docass_id = pId ) ) ); delete from docass where docass_id = pId; return true; end; $_$; )DROP FUNCTION public.deleteurl(integer); publicadminfalse46238F125578364deleteuserpreference(text)FUNCTIONCREATE FUNCTION deleteuserpreference(text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrefname ALIAS FOR $1; _return BOOLEAN; BEGIN SELECT deleteUserPreference(getEffectiveXtUser(), pPrefname) INTO _return; RETURN _return; END; $_$; 1DROP FUNCTION public.deleteuserpreference(text); publicadminfalse84623l125578365 deleteuserpreference(text, text)FUNCTIONCREATE FUNCTION deleteuserpreference(text, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pPrefname ALIAS FOR $2; BEGIN DELETE FROM usrpref WHERE ( (usrpref_username=pUsername) AND (usrpref_name=pPrefname) ); RETURN TRUE; END; $_$; 7DROP FUNCTION public.deleteuserpreference(text, text); publicadminfalse84623m125578366deletevendoraddress(integer)FUNCTIONaCREATE FUNCTION deletevendoraddress(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendaddrid ALIAS FOR $1; _test INTEGER; BEGIN -- Check to see if the passed vendor address is used in pohead SELECT pohead_id INTO _test FROM pohead WHERE (pohead_vendaddr_id=pVendaddrid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; -- Delete the passed vendor address DELETE FROM vendaddrinfo WHERE (vendaddr_id=pVendaddrid); RETURN 0; END; $_$; 3DROP FUNCTION public.deletevendoraddress(integer); publicadminfalse46238n125578367deletevendortype(integer)FUNCTIONTCREATE FUNCTION deletevendortype(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendtypeid ALIAS FOR $1; _test INTEGER; BEGIN -- Check to see if the passed vendor type is used in vendinfo SELECT vend_id INTO _test FROM vendinfo WHERE (vend_vendtype_id=pVendtypeid) LIMIT 1; IF (FOUND) THEN RETURN -1; END IF; -- Delete the passed vendor type DELETE FROM vendtype WHERE (vendtype_id=pVendtypeid); RETURN 0; END; $_$; 0DROP FUNCTION public.deletevendortype(integer); publicadminfalse46238o125578368deletewo(integer, boolean)FUNCTION0CREATE FUNCTION deletewo(pwoid integer, pdeletechildren boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN deleteWo(pWoid, pDeleteChildren, FALSE); END; $$; GDROP FUNCTION public.deletewo(pwoid integer, pdeletechildren boolean); publicadminfalse84623p125578369#deletewo(integer, boolean, boolean)FUNCTIONCREATE FUNCTION deletewo(pwoid integer, pdeletechildren boolean, pdeleteforce boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE woStatus CHAR(1); itemType CHAR(1); ordtype CHAR(1); ordid INTEGER; returnCode INTEGER; _wotcCnt INTEGER; _routings BOOLEAN; BEGIN SELECT wo_status, wo_ordtype, wo_ordid, item_type INTO woStatus, ordtype, ordid, itemType FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (wo_id=pWoid); IF (pDeleteForce) THEN IF (NOT woStatus IN ('O', 'E', 'R', 'C')) THEN RETURN -3; END IF; ELSE IF (NOT woStatus IN ('O', 'E')) THEN RETURN -3; END IF; IF (itemType = 'J') THEN RETURN -2; END IF; END IF; SELECT fetchMetricBool('Routings') INTO _routings; IF (_routings AND woStatus != 'C') THEN SELECT count(*) INTO _wotcCnt FROM xtmfg.wotc WHERE (wotc_wo_id=pWoid); IF (_wotcCnt > 0) THEN RETURN -1; END IF; END IF; IF (woStatus = 'R') THEN PERFORM postEvent('RWoRequestCancel', 'W', wo_id, itemsite_warehous_id, formatWoNumber(wo_id), NULL, NULL, NULL, NULL) FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id) JOIN item ON (item_id=itemsite_item_id) WHERE (wo_id=pWoid); RETURN 0; ELSE IF (woStatus = 'E') THEN returnCode := (SELECT implodeWo(pWoid, FALSE)); END IF; END IF; IF (woStatus IN ('O', 'E', 'C')) THEN DELETE FROM womatl WHERE (womatl_wo_id=pWoid); IF _routings THEN DELETE FROM xtmfg.wotc WHERE (wotc_wo_id=pWoid); DELETE FROM xtmfg.wooper WHERE (wooper_wo_id=pWoid); END IF; IF (ordtype = 'S') THEN UPDATE coitem SET coitem_order_type=NULL, coitem_order_id=NULL WHERE coitem_id=ordid; END IF; DELETE FROM wo WHERE (wo_id=pWoid); END IF; IF (pDeleteChildren) THEN returnCode := (SELECT MAX(deleteWo(wo_id, TRUE)) FROM wo WHERE ((wo_ordtype='W') AND (wo_ordid=pWoid))); END IF; RETURN 0; END; $$; ]DROP FUNCTION public.deletewo(pwoid integer, pdeletechildren boolean, pdeleteforce boolean); publicadminfalse84623q125578370deletewomaterial(integer)FUNCTION CREATE FUNCTION deletewomaterial(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; BEGIN UPDATE wo SET wo_adhoc=TRUE FROM womatl WHERE ((womatl_wo_id=wo_id) AND (womatl_id=pWomatlid)); -- Delete any created P/R for this Womatl PERFORM deletePr('W', pWomatlid); DELETE FROM womatl WHERE (womatl_id=pWomatlid); RETURN 0; END; $_$; 0DROP FUNCTION public.deletewomaterial(integer); publicadminfalse84623r125578371,detachccpayfromso(integer, integer, integer)FUNCTIONCREATE FUNCTION detachccpayfromso(integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pcoheadid ALIAS FOR $1; pwarehousid ALIAS FOR $2; pcustid ALIAS FOR $3; BEGIN RAISE WARNING 'detachCCPayFromSO(INTEGER, INTEGER, INTEGER): deprecated'; RETURN 0; END; $_$; CDROP FUNCTION public.detachccpayfromso(integer, integer, integer); publicadminfalse46238s125578372detachcontact(integer, integer)FUNCTIONCREATE FUNCTION detachcontact(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pcntctId ALIAS FOR $1; pcrmacctId ALIAS FOR $2; BEGIN UPDATE cntct SET cntct_crmacct_id = NULL WHERE cntct_id = pcntctId AND cntct_crmacct_id = pcrmacctId; UPDATE crmacct SET crmacct_cntct_id_1 = NULL WHERE crmacct_id = pcrmacctId AND crmacct_cntct_id_1 = pcntctId; UPDATE crmacct SET crmacct_cntct_id_2 = NULL WHERE crmacct_id = pcrmacctId AND crmacct_cntct_id_2 = pcntctId; RETURN 0; END; $_$; 6DROP FUNCTION public.detachcontact(integer, integer); publicadminfalse46238t125578373 detag(text)FUNCTIONpCREATE FUNCTION detag(text) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSource ALIAS FOR $1; _result TEXT := ''; BEGIN SELECT regexp_replace(pSource, E'<[^>]*>', '', 'g') INTO _result; RETURN _result; END; $_$; "DROP FUNCTION public.detag(text); publicadminfalse46238u125578374detailednnqoh(integer, boolean)FUNCTION6CREATE FUNCTION detailednnqoh(integer, boolean) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- -- Deprecated -- DECLARE pItemsiteid ALIAS FOR $1; pABS ALIAS FOR $2; _qoh NUMERIC; BEGIN IF (pABS) THEN SELECT SUM(noNeg(itemloc_qty)) INTO _qoh FROM itemloc, location WHERE ( (itemloc_location_id=location_id) AND (NOT location_netable) AND (itemloc_itemsite_id=pItemsiteid) ); ELSE SELECT SUM(itemloc_qty) INTO _qoh FROM itemloc, location WHERE ( (itemloc_location_id=location_id) AND (NOT location_netable) AND (itemloc_itemsite_id=pItemsiteid) ); END IF; IF (_qoh IS NULL) THEN _qoh := 0; END IF; RETURN _qoh; END; $_$; 6DROP FUNCTION public.detailednnqoh(integer, boolean); publicadminfalse84623v125578375detailedqoh(integer, boolean)FUNCTIONNCREATE FUNCTION detailedqoh(pitemsiteid integer, pabs boolean) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _qoh NUMERIC; BEGIN IF (pABS) THEN SELECT SUM(noNeg(itemloc_qty)) INTO _qoh FROM itemloc WHERE (itemloc_itemsite_id=pItemsiteid); ELSE SELECT SUM(itemloc_qty) INTO _qoh FROM itemloc WHERE (itemloc_itemsite_id=pItemsiteid); END IF; IF (_qoh IS NULL) THEN _qoh := 0.0; END IF; RETURN _qoh; END; $$; EDROP FUNCTION public.detailedqoh(pitemsiteid integer, pabs boolean); publicadminfalse46238y125578376$determinediscountdate(integer, date)FUNCTIONCREATE FUNCTION determinediscountdate(integer, date) RETURNS date LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTermsid ALIAS FOR $1; pSourceDate ALIAS FOR $2; _discDate DATE; _p RECORD; BEGIN SELECT terms_type, terms_discdays, terms_cutoffday INTO _p FROM terms WHERE (terms_id=pTermsid); IF (NOT FOUND) THEN _discDate := pSourceDate; -- Handle type D terms ELSIF (_p.terms_type = 'D') THEN _discDate := (pSourceDate + _p.terms_discdays); -- Handle type P terms ELSIF (_p.terms_type = 'P') THEN IF (date_part('day', pSourceDate) <= _p.terms_cutoffday) THEN _discDate := (DATE(date_trunc('month', pSourceDate)) + (_p.terms_discdays - 1)); ELSE _discDate := (DATE(date_trunc('month', pSourceDate)) + (_p.terms_discdays - 1) + INTERVAL '1 month'); END IF; -- Handle unknown terms ELSE _discDate := pSourceDate; END IF; RETURN _discDate; END; $_$; ;DROP FUNCTION public.determinediscountdate(integer, date); publicadminfalse46238z125578377determineduedate(integer, date)FUNCTIONCREATE FUNCTION determineduedate(integer, date) RETURNS date LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTermsid ALIAS FOR $1; pSourceDate ALIAS FOR $2; _dueDate DATE; _p RECORD; BEGIN SELECT terms_type, terms_duedays, terms_cutoffday INTO _p FROM terms WHERE (terms_id=pTermsid); IF (NOT FOUND) THEN _dueDate := pSourceDate; -- Handle type D terms ELSIF (_p.terms_type = 'D') THEN _dueDate := (pSourceDate + _p.terms_duedays); -- Handle type P terms ELSIF (_p.terms_type = 'P') THEN IF (date_part('day', pSourceDate) <= _p.terms_cutoffday) THEN _dueDate := (DATE(date_trunc('month', pSourceDate)) + (_p.terms_duedays - 1)); ELSE _dueDate := (DATE(date_trunc('month', pSourceDate)) + (_p.terms_duedays - 1) + INTERVAL '1 month'); END IF; -- Handle unknown terms ELSE _dueDate := pSourceDate; END IF; RETURN _dueDate; END; $_$; 6DROP FUNCTION public.determineduedate(integer, date); publicadminfalse84623125578378digest(text, text)FUNCTIONyCREATE FUNCTION digest(text, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_digest'; )DROP FUNCTION public.digest(text, text); publicadminfalse8125578379digest(bytea, text)FUNCTIONzCREATE FUNCTION digest(bytea, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_digest'; *DROP FUNCTION public.digest(bytea, text); publicadminfalse8{125578380disablepackage(text)FUNCTIONCREATE FUNCTION disablepackage(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ppkgname ALIAS FOR $1; _i INTEGER := 0; _tabs TEXT[] := ARRAY['cmd', 'cmdarg', 'image', 'metasql', 'priv', 'report', 'script', 'uiform']; BEGIN IF (version() < 'PostgreSQL 8.2') THEN RETURN -1; END IF; FOR _i IN ARRAY_LOWER(_tabs,1)..ARRAY_UPPER(_tabs,1) LOOP EXECUTE 'ALTER TABLE ' || ppkgname || '.pkg' || _tabs[_i] || ' NO INHERIT public.' || _tabs[_i] || ';'; END LOOP; RETURN 0; END; $_$; +DROP FUNCTION public.disablepackage(text); publicadminfalse46238|125578381disablepackage(integer)FUNCTIONCREATE FUNCTION disablepackage(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ppkgheadid ALIAS FOR $1; _pkgname TEXT; BEGIN SELECT pkghead_name INTO _pkgname FROM pkghead WHERE (pkghead_id=ppkgheadid); IF (NOT FOUND) THEN RETURN -2; END IF; RETURN disablePackage(_pkgname); END; $_$; .DROP FUNCTION public.disablepackage(integer); publicadminfalse84623}125578382 distributeitemlocseries(integer)FUNCTIONCREATE FUNCTION distributeitemlocseries(pitemlocseries integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _distCounter INTEGER; _itemlocdist RECORD; _itemlocid INTEGER; _invhistid INTEGER; _check BOOLEAN; _debug BOOLEAN := false; BEGIN IF (_debug) THEN RAISE NOTICE 'distributeItemlocSeries, series=%', pItemlocSeries; END IF; _distCounter := 0; -- March through all of the itemlocdists for pItemlocSeries FOR _itemlocdist IN SELECT itemlocdist_id AS itemlocdistid, itemlocdist_source_type AS type, itemlocdist_source_id AS sourceid, itemlocdist_qty AS qty, itemlocdist_itemsite_id AS itemsiteid, itemsite_freeze, itemlocdist_invhist_id AS invhistid, itemlocdist_ls_id AS lotserialid, itemlocdist_expiration AS expiration, itemlocdist_flush, itemlocdist_warranty AS warranty, itemlocdist_series AS series FROM itemlocdist, itemsite WHERE ( (itemlocdist_itemsite_id=itemsite_id) AND (itemlocdist_series=pItemlocSeries) ) ORDER BY itemlocdist_flush DESC LOOP _distCounter := _distCounter + 1; IF (_debug) THEN RAISE NOTICE 'itemlocdist loop %', _distCounter; RAISE NOTICE 'itemlocdistid=%', _itemlocdist.itemlocdistid; RAISE NOTICE 'type=%', _itemlocdist.type; RAISE NOTICE 'sourceid=%', _itemlocdist.sourceid; RAISE NOTICE 'qty=%', _itemlocdist.qty; RAISE NOTICE 'itemsiteid=%', _itemlocdist.itemsiteid; RAISE NOTICE 'freeze=%', _itemlocdist.itemsite_freeze; RAISE NOTICE 'invhistid=%', _itemlocdist.invhistid; RAISE NOTICE 'lotserialid=%', _itemlocdist.lotserialid; RAISE NOTICE 'expiration=%', _itemlocdist.expiration; RAISE NOTICE 'flush=%', _itemlocdist.itemlocdist_flush; RAISE NOTICE 'warranty=%', _itemlocdist.warranty; END IF; -- Commit invhist to itemsite IF (NOT _itemlocdist.itemsite_freeze) THEN PERFORM postInvHist(_itemlocdist.invhistid); END IF; -- Mark the invhist tuple for the itemlocdist in question as having detail UPDATE invhist SET invhist_hasdetail=TRUE WHERE ( (NOT invhist_hasdetail) AND (invhist_id=_itemlocdist.invhistid) ); -- If this itemlocdist is a flush, write a invdetail tuple that records the empty IF (_itemlocdist.itemlocdist_flush) THEN INSERT INTO invdetail ( invdetail_invhist_id, invdetail_location_id, invdetail_ls_id, invdetail_qty, invdetail_qty_before, invdetail_qty_after, invdetail_expiration, invdetail_warrpurc ) SELECT _itemlocdist.invhistid, itemloc_location_id, itemloc_ls_id, (itemloc_qty * -1), itemloc_qty, 0, itemloc_expiration, _itemlocdist.warranty FROM itemloc WHERE ( (itemloc_qty <> 0) AND (itemloc_id=_itemlocdist.sourceid) ); -- Delete the flushed itemloc if its parent itemsite is not frozen IF (NOT _itemlocdist.itemsite_freeze) THEN DELETE FROM itemloc WHERE (itemloc_id=_itemlocdist.sourceid); END IF; ELSE -- If this is a location type distribution, check to see if the target itemloc -- already exists IF (_itemlocdist.type = 'L') THEN SELECT itemloc_id INTO _itemlocid FROM itemloc WHERE ( (itemloc_itemsite_id=_itemlocdist.itemsiteid) AND (itemloc_location_id=_itemlocdist.sourceid) AND (COALESCE(itemloc_ls_id,-1)=COALESCE(_itemlocdist.lotserialid,-1)) AND (COALESCE(itemloc_expiration,endOfTime())=COALESCE(_itemlocdist.expiration,endOfTime())) AND (COALESCE(itemloc_warrpurc,endoftime())=COALESCE(_itemlocdist.warranty,endoftime())) ); -- Nope, create it IF (NOT FOUND) THEN SELECT NEXTVAL('itemloc_itemloc_id_seq') INTO _itemlocid; INSERT INTO itemloc ( itemloc_id, itemloc_itemsite_id, itemloc_location_id, itemloc_qty, itemloc_ls_id, itemloc_expiration, itemloc_warrpurc ) VALUES ( _itemlocid, _itemlocdist.itemsiteid, _itemlocdist.sourceid, 0, _itemlocdist.lotserialid, _itemlocdist.expiration, _itemlocdist.warranty ); END IF; ELSE _itemlocid = _itemlocdist.sourceid; IF (_itemlocid IS NOT NULL AND (SELECT count(itemloc_id) = 0 FROM itemloc WHERE itemloc_id=_itemlocid)) THEN RAISE EXCEPTION 'No record to distribute against. Someone else may have already distributed this record.'; END IF; END IF; -- Record the invdetail INSERT INTO invdetail (invdetail_invhist_id, invdetail_location_id, invdetail_ls_id, invdetail_qty, invdetail_qty_before, invdetail_qty_after, invdetail_expiration, invdetail_warrpurc) SELECT _itemlocdist.invhistid, itemloc_location_id, _itemlocdist.lotserialid, _itemlocdist.qty, itemloc_qty, (itemloc_qty + _itemlocdist.qty), itemloc_expiration,_itemlocdist.warranty FROM itemloc WHERE (itemloc_id=_itemlocid); -- Update the itemloc_qty if its parent itemsite is not frozen IF (NOT _itemlocdist.itemsite_freeze) THEN UPDATE itemloc SET itemloc_qty = (itemloc_qty + _itemlocdist.qty) WHERE (itemloc_id=_itemlocid); END IF; END IF; -- If, after the distribution, the target itemloc_qty = 0, delete the itemloc -- if its parent itemsite is not frozen IF (NOT _itemlocdist.itemsite_freeze) THEN DELETE FROM itemloc WHERE ( (itemloc_qty=0) AND (itemloc_id=_itemlocid) ); END IF; END LOOP; DELETE FROM itemlocdist WHERE (itemlocdist_series=pItemlocSeries); RETURN _distCounter; END; $$; FDROP FUNCTION public.distributeitemlocseries(pitemlocseries integer); publicadminfalse46238~125578384distributetodefault(integer)FUNCTIONJCREATE FUNCTION distributetodefault(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemlocdistid ALIAS FOR $1; BEGIN RETURN distributeToDefault(pItemlocdistid, 'O'); END; $_$; 3DROP FUNCTION public.distributetodefault(integer); publicadminfalse46238125578385"distributetodefault(integer, text)FUNCTIONR CREATE FUNCTION distributetodefault(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemlocdistid ALIAS FOR $1; pTranstype ALIAS FOR $2; _locationid INTEGER; _itemlocdistid INTEGER; _qty NUMERIC; BEGIN -- Make sure that the itemsite in question has a default location SELECT CASE WHEN (pTranstype='R') THEN itemsite_recvlocation_id WHEN (pTranstype='I') THEN itemsite_issuelocation_id ELSE itemsite_location_id END INTO _locationid FROM itemlocdist, itemsite WHERE ( (itemlocdist_itemsite_id=itemsite_id) AND (itemlocdist_id=pItemlocdistid) ); IF ( (NOT FOUND) OR (_locationid = -1) ) THEN RETURN -1; END IF; -- Determine the remaining qty required to distribute SELECT (p.itemlocdist_qty - COALESCE(SUM(c.itemlocdist_qty), 0)) INTO _qty FROM itemlocdist AS p LEFT OUTER JOIN itemlocdist AS c ON (c.itemlocdist_itemlocdist_id=p.itemlocdist_id) WHERE (p.itemlocdist_id=pItemlocdistid) GROUP BY p.itemlocdist_qty; IF (_qty = 0) THEN RETURN -2; END IF; -- Check to see if an itemlocdist with the correct location/lotserial/expiration already exists SELECT target.itemlocdist_id INTO _itemlocdistid FROM itemlocdist AS source, itemlocdist AS target, itemloc, itemsite WHERE ( (target.itemlocdist_source_type='L') AND (target.itemlocdist_source_id=_locationid) AND (target.itemlocdist_itemsite_id=source.itemlocdist_itemsite_id) AND (COALESCE(target.itemlocdist_ls_id)=COALESCE(source.itemlocdist_ls_id)) AND (target.itemlocdist_expiration=source.itemlocdist_expiration) AND (target.itemlocdist_itemlocdist_id=source.itemlocdist_itemlocdist_id) AND (target.itemlocdist_itemsite_id=itemsite_id) AND (source.itemlocdist_id=pItemlocdistid) ); IF (FOUND) THEN UPDATE itemlocdist SET itemlocdist_qty = (itemlocdist_qty + _qty) WHERE (itemlocdist_id=_itemlocdistid); RETURN _itemlocdistid; END IF; -- Create a new itemlocdist SELECT NEXTVAL('itemlocdist_itemlocdist_id_seq') INTO _itemlocdistid; INSERT INTO itemlocdist ( itemlocdist_id, itemlocdist_itemlocdist_id, itemlocdist_source_type, itemlocdist_ls_id, itemlocdist_expiration, itemlocdist_source_id, itemlocdist_itemsite_id, itemlocdist_qty ) SELECT _itemlocdistid, pItemlocdistid, 'L', itemlocdist_ls_id, itemlocdist_expiration, _locationid, itemlocdist_itemsite_id, _qty FROM itemlocdist WHERE (itemlocdist_id=pItemlocdistid); RETURN _itemlocdistid; END; $_$; 9DROP FUNCTION public.distributetodefault(integer, text); publicadminfalse84623125578386#distributetodefaultitemloc(integer)FUNCTIONXCREATE FUNCTION distributetodefaultitemloc(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemlocdistid ALIAS FOR $1; BEGIN RETURN distributeToDefaultItemLoc(pItemlocdistid, 'O'); END; $_$; :DROP FUNCTION public.distributetodefaultitemloc(integer); publicadminfalse84623125578387)distributetodefaultitemloc(integer, text)FUNCTION CREATE FUNCTION distributetodefaultitemloc(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemlocdistid ALIAS FOR $1; pTranstype ALIAS FOR $2; _itemlocid INTEGER; _itemlocdistid INTEGER; _qty NUMERIC; BEGIN -- Make sure that the itemsite in question has a default location SELECT itemloc_id INTO _itemlocid FROM itemlocdist, itemsite, itemloc WHERE ((itemlocdist_itemsite_id=itemsite_id) AND ( (itemsite_location_id=itemloc_location_id AND pTranstype='O') OR (itemsite_recvlocation_id=itemloc_location_id AND pTranstype='R') OR (itemsite_issuelocation_id=itemloc_location_id AND pTranstype='I') ) AND (itemloc_itemsite_id=itemsite_id) AND (itemlocdist_id=pItemlocdistid)); IF ( (NOT FOUND) OR (_itemlocid = -1) ) THEN RETURN -1; END IF; -- Determine the remaining qty required to distribute SELECT (p.itemlocdist_qty - COALESCE(SUM(c.itemlocdist_qty), 0)) INTO _qty FROM itemlocdist AS p LEFT OUTER JOIN itemlocdist AS c ON (c.itemlocdist_itemlocdist_id=p.itemlocdist_id) WHERE (p.itemlocdist_id=pItemlocdistid) GROUP BY p.itemlocdist_qty; IF (_qty = 0) THEN RETURN -2; END IF; -- Check to see if an itemlocdist with the correct location/lotserial/expiration already exists SELECT target.itemlocdist_id INTO _itemlocdistid FROM itemlocdist AS source, itemlocdist AS target WHERE ( (target.itemlocdist_source_type='I') AND (target.itemlocdist_source_id=_itemlocid) AND (COALESCE(target.itemlocdist_ls_id,-1)=COALESCE(source.itemlocdist_ls_id,-1)) AND (target.itemlocdist_expiration=source.itemlocdist_expiration) AND (target.itemlocdist_itemlocdist_id=source.itemlocdist_id) AND (source.itemlocdist_id=pItemlocdistid) ); IF (FOUND) THEN UPDATE itemlocdist SET itemlocdist_qty = (itemlocdist_qty + _qty) WHERE (itemlocdist_id=_itemlocdistid); RETURN _itemlocdistid; END IF; -- Create a new itemlocdist SELECT NEXTVAL('itemlocdist_itemlocdist_id_seq') INTO _itemlocdistid; INSERT INTO itemlocdist ( itemlocdist_id, itemlocdist_itemlocdist_id, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_qty, itemlocdist_expiration ) VALUES ( _itemlocdistid, pItemlocdistid, 'I', _itemlocid, _qty, endOfTime() ); RETURN _itemlocdistid; END; $_$; @DROP FUNCTION public.distributetodefaultitemloc(integer, text); publicadminfalse84623125578388distributetolocations(integer)FUNCTIONCREATE FUNCTION distributetolocations(pitemlocdistid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _distCounter INTEGER; _itemlocdist RECORD; _itemlocid INTEGER; _runningQty NUMERIC; _tmp RECORD; BEGIN _distCounter := 0; _runningQty := 0; -- A scenario can occur where two people try to post distributions -- to the same itemsite against two or more lot/serial/mlc locations -- leading to a deadlock. This line tries to prevent that by locking -- ahead of time all the itemsites that the transaction will need -- before any of the other tables are locked individually. SELECT itemsite_id INTO _tmp FROM itemsite WHERE(itemsite_id in (SELECT DISTINCT itemlocdist_itemsite_id FROM itemlocdist WHERE(itemlocdist_id=pItemlocdistid))) FOR UPDATE; -- March through all of the itemlocdist owned by the passed parent itemlocdist FOR _itemlocdist IN SELECT c.itemlocdist_id AS itemlocdistid, c.itemlocdist_source_type AS type, c.itemlocdist_source_id AS sourceid, c.itemlocdist_qty AS qty, p.itemlocdist_itemsite_id AS itemsiteid, itemsite_freeze, p.itemlocdist_invhist_id AS invhistid, p.itemlocdist_ls_id AS lotserialid, p.itemlocdist_expiration AS expiration, p.itemlocdist_warranty AS warranty, p.itemlocdist_order_type AS ordertype, p.itemlocdist_order_id AS orderid, p.itemlocdist_series AS series FROM itemlocdist AS c, itemlocdist AS p, itemsite WHERE ( (c.itemlocdist_itemlocdist_id=p.itemlocdist_id) AND (p.itemlocdist_source_type='O') AND (p.itemlocdist_itemsite_id=itemsite_id) AND (p.itemlocdist_id=pItemlocdistid) ) LOOP _distCounter := _distCounter + 1; -- If the target for this itemlocdist is a location, check to see if the -- required itemloc already exists IF (_itemlocdist.type = 'L') THEN SELECT itemloc_id INTO _itemlocid FROM itemloc WHERE ( (itemloc_itemsite_id=_itemlocdist.itemsiteid) AND (itemloc_location_id=_itemlocdist.sourceid) AND (COALESCE(itemloc_ls_id, -1)=COALESCE(_itemlocdist.lotserialid, -1)) AND (COALESCE(itemloc_expiration,endOfTime())=COALESCE(_itemlocdist.expiration,endOfTime())) AND (COALESCE(itemloc_warrpurc,endoftime())=COALESCE(_itemlocdist.warranty,endoftime())) ); -- Nope, make it IF (NOT FOUND) THEN SELECT NEXTVAL('itemloc_itemloc_id_seq') INTO _itemlocid; INSERT INTO itemloc ( itemloc_id, itemloc_itemsite_id, itemloc_location_id, itemloc_qty, itemloc_ls_id, itemloc_expiration, itemloc_warrpurc ) VALUES ( _itemlocid, _itemlocdist.itemsiteid, _itemlocdist.sourceid, 0, _itemlocdist.lotserialid, _itemlocdist.expiration, _itemlocdist.warranty ); END IF; ELSE -- Yep, cache it _itemlocid = _itemlocdist.sourceid; IF (_itemlocid IS NOT NULL AND (SELECT count(itemloc_id) = 0 FROM itemloc WHERE itemloc_id=_itemlocid)) THEN RAISE EXCEPTION 'No record to distribute against. Someone else may have already distributed this record.'; END IF; END IF; -- Record the invdetail for this itemlocdist INSERT INTO invdetail ( invdetail_invhist_id, invdetail_location_id, invdetail_ls_id, invdetail_qty, invdetail_qty_before, invdetail_qty_after, invdetail_expiration, invdetail_warrpurc ) SELECT _itemlocdist.invhistid, itemloc_location_id, itemloc_ls_id, _itemlocdist.qty, itemloc_qty, (itemloc_qty + _itemlocdist.qty), itemloc_expiration,_itemlocdist.warranty FROM itemloc WHERE (itemloc_id=_itemlocid); -- Update the parent invhist to indicate that it has invdetail records UPDATE invhist SET invhist_hasdetail=TRUE WHERE ((invhist_hasdetail=FALSE) AND (invhist_id=_itemlocdist.invhistid)); -- Update the itemloc_qty if its parent itemsite is not frozen IF (NOT _itemlocdist.itemsite_freeze) THEN UPDATE itemloc SET itemloc_qty = (itemloc_qty + _itemlocdist.qty) WHERE (itemloc_id=_itemlocid); PERFORM postInvHist(_itemlocdist.invhistid); -- Handle reservation data IF ( (SELECT fetchMetricBool('EnableSOReservationsByLocation')) AND (_itemlocdist.qty < 0) ) THEN -- If a shipment on a sales order, record reservation change before updating -- so it can be reversed later if necessary IF (_itemlocdist.ordertype = 'SO') THEN INSERT INTO shipitemlocrsrv SELECT nextval('shipitemlocrsrv_shipitemlocrsrv_id_seq'), shipitem_id, itemloc_itemsite_id, itemloc_location_id, itemloc_ls_id, itemloc_expiration, itemloc_warrpurc, least((_itemlocdist.qty * -1.0), reserve_qty) FROM shipitem, itemloc JOIN reserve ON (itemloc_id=reserve_supply_id AND reserve_supply_type='I') WHERE ( (shipitem_invhist_id=_itemlocdist.invhistid) AND (itemloc_id=_itemlocid) AND (reserve_demand_type=_itemlocdist.ordertype) AND (reserve_demand_id=_itemlocdist.orderid) ); END IF; -- Update the reservation UPDATE reserve SET reserve_qty = (reserve_qty + _itemlocdist.qty) WHERE ( (reserve_supply_id=_itemlocid) AND (reserve_supply_type='I') AND (reserve_demand_type=_itemlocdist.ordertype) AND (reserve_demand_id=_itemlocdist.orderid) ); -- Delete reservation if fully distributed DELETE FROM reserve WHERE ( (reserve_supply_id=_itemlocid) AND (reserve_supply_type='I') AND (reserve_demand_type=_itemlocdist.ordertype) AND (reserve_demand_id=_itemlocdist.orderid) AND (reserve_qty=0) ); END IF; END IF; -- Cache the running qty. _runningQty := _runningQty + _itemlocdist.qty; -- Dene with the child itemlocdist, so delete it DELETE FROM itemlocdist WHERE (itemlocdist_id=_itemlocdist.itemlocdistid); -- If the target itemloc is now at qty=0, delete it if its parent -- itemsite is not frozen IF (NOT _itemlocdist.itemsite_freeze) THEN DELETE FROM itemloc WHERE ( (itemloc_qty=0) AND (itemloc_id=_itemlocid) ); END IF; END LOOP; -- If the running qty for the detailed distributions is the same as the -- total qty to distribute indicated by the parent itemlocdist, then the -- parent itemlocdist has been fully distributed and should be deleted. IF ( ( SELECT itemlocdist_qty FROM itemlocdist WHERE (itemlocdist_id=pItemlocdistid) ) = _runningQty) THEN DELETE FROM itemlocdist WHERE (itemlocdist_id=pItemlocdistid); ELSE -- There is still some more qty to distribute in the parent itemlocdist. -- Update the qty to distribute with the qty that has been distributed. UPDATE itemlocdist SET itemlocdist_qty = (itemlocdist_qty - _runningQty) WHERE (itemlocdist_id=pItemlocdistid); END IF; RETURN _distCounter; END; $$; DDROP FUNCTION public.distributetolocations(pitemlocdistid integer); publicadminfalse846231255783900distributevoucherline(integer, integer, integer)FUNCTIONCREATE FUNCTION distributevoucherline(integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVoucherId ALIAS FOR $1; pPoitemId ALIAS FOR $2; pCurrId ALIAS FOR $3; _count INTEGER; _costelemId INTEGER; _close BOOLEAN; _r RECORD; _qtyOrdered NUMERIC; _voitemId INTEGER; _taxtypeid INTEGER; BEGIN -- Make sure the P/O and Voucher are same currency SELECT COALESCE(COUNT(*),0) INTO _count FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id) WHERE ((poitem_id=pPoitemid) AND (pohead_curr_id=pCurrId)); IF (_count = 0) THEN RETURN -3; END IF; -- Validate and get cost element SELECT COALESCE(COUNT(*),0) INTO _count FROM itemcost, item, itemsite, poitem WHERE ((itemcost_item_id=item_id) AND (item_id=itemsite_item_id) AND (itemsite_id=poitem_itemsite_id) AND (poitem_id=pPoitemId)); IF (_count > 1) THEN RETURN -5; ELSEIF (_count = 1) THEN SELECT itemcost_costelem_id INTO _costelemId FROM itemcost, item, itemsite, poitem WHERE ((itemcost_item_id=item_id) AND (item_id=itemsite_item_id) AND (itemsite_id=poitem_itemsite_id) AND (poitem_id=pPoitemId)); ELSE SELECT costelem_id INTO _costelemId FROM costelem WHERE (costelem_type='Material'); END IF; -- Clear previous distributions UPDATE recv SET recv_vohead_id=NULL, recv_voitem_id=NULL WHERE ((recv_vohead_id=pVoucherId) AND (recv_orderitem_id=pPoitemId) AND (recv_order_type='PO')); UPDATE poreject SET poreject_vohead_id=NULL, poreject_voitem_id=NULL WHERE ((poreject_vohead_id=pVoucherId) AND (poreject_poitem_id=pPoitemId)); DELETE FROM vodist WHERE ((vodist_poitem_id=pPoitemId) AND (vodist_vohead_id=pVoucherId)); DELETE FROM voitem WHERE ((voitem_poitem_id=pPoitemId) AND (voitem_vohead_id=pVoucherId)); -- Determine Line balances SELECT COALESCE(SUM(qty_received),0) AS qty_received, COALESCE(SUM(qty_rejected),0) AS qty_rejected, COALESCE(SUM(qty_vouchered),0) AS qty_vouchered, round(COALESCE(SUM(balance),0),2) AS balance, round(COALESCE(SUM(freight),0),2) AS freight INTO _r FROM ( SELECT recv_qty AS qty_received, 0 AS qty_rejected, 0 AS qty_vouchered, (recv_qty * COALESCE(recv_purchcost, poitem_unitprice)) AS balance, recv_freight AS freight FROM poitem JOIN recv ON ((recv_orderitem_id=poitem_id) AND (recv_order_type='PO')) WHERE ( (recv_vohead_id IS NULL) AND (NOT recv_invoiced) AND (recv_posted) AND (poitem_id=pPoitemId) ) UNION ALL SELECT 0 AS qty_received, (poreject_qty) AS qty_rejected, 0 AS qty_vouchered, (poreject_qty * -1 * COALESCE(recv_purchcost, poitem_unitprice)) AS balance, 0 AS freight FROM poitem JOIN poreject ON (poreject_poitem_id=poitem_id) LEFT OUTER JOIN recv ON (recv_id=poreject_recv_id) WHERE ( (poreject_posted) AND (poreject_vohead_id IS NULL) AND (NOT poreject_invoiced) AND (poitem_id=pPoitemId) ) UNION ALL SELECT 0 AS qty_received, 0 AS qty_rejected, voitem_qty AS qty_vouchered, 0 AS balance, 0 AS freight FROM voitem, poitem WHERE ( (voitem_poitem_id=pPoitemId) AND (poitem_id=voitem_poitem_id) ) ) AS data; SELECT poitem_qty_ordered INTO _qtyOrdered FROM poitem WHERE (poitem_id=pPoitemId); IF _r.balance < 0 THEN RETURN -4; ELSEIF ( ((_r.qty_received <> 0) OR (_r.qty_received <> 0)) AND (_r.qty_received - _r.qty_rejected = 0) ) THEN RETURN -2; ELSEIF ((_r.qty_received - _r.qty_rejected) = 0) THEN RETURN 0; END IF; -- Determine whether to close P/O item IF (_r.qty_received -_r.qty_rejected + _r.qty_vouchered) >= _qtyOrdered THEN _close:=True; ELSE _close:=False; END IF; -- Create distribution INSERT INTO vodist (vodist_poitem_id,vodist_vohead_id,vodist_costelem_id,vodist_amount,vodist_qty,vodist_expcat_id) VALUES (pPoitemId,pVoucherId,_costelemId,_r.balance,(_r.qty_received -_r.qty_rejected),-1); -- Create voucher item SELECT poitem_taxtype_id INTO _taxtypeid FROM poitem WHERE (poitem_id=pPoitemId); SELECT NEXTVAL('voitem_voitem_id_seq') INTO _voitemId; INSERT INTO voitem (voitem_id,voitem_vohead_id,voitem_poitem_id,voitem_close,voitem_qty,voitem_freight, voitem_taxtype_id) VALUES (_voitemId,pVoucherId,pPoitemId,_close,(_r.qty_received -_r.qty_rejected),_r.freight, _taxtypeid); -- Tag receipt records UPDATE recv SET recv_vohead_id=pVoucherId, recv_voitem_id=_voitemId WHERE ((recv_orderitem_id=pPoitemId) AND (recv_order_type='PO') AND (recv_vohead_id IS NULL)); UPDATE poreject SET poreject_vohead_id=pVoucherId,poreject_voitem_id=_voitemId WHERE ((poreject_poitem_id=pPoitemId) AND (NOT poreject_invoiced) AND (poreject_vohead_id IS NULL)); RETURN 1; END; $_$; GDROP FUNCTION public.distributevoucherline(integer, integer, integer); publicadminfalse84623125578391ndopostcosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean)FUNCTIONcCREATE FUNCTION dopostcosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pMaterial ALIAS FOR $1; plowerMaterial ALIAS FOR $2; pdirectLabor ALIAS FOR $3; plowerDirectLabor ALIAS FOR $4; poverhead ALIAS FOR $5; plowerOverhead ALIAS FOR $6; pmachOverhead ALIAS FOR $7; plowerMachOverhead ALIAS FOR $8; pUser ALIAS FOR $9; plowerUser ALIAS FOR $10; prollUp ALIAS FOR $11; _item RECORD; _result INTEGER := 0; BEGIN PERFORM resetLowLevelCode(-1); FOR _item IN SELECT costUpdate_item_id FROM costUpdate ORDER BY costUpdate_lowlevel_code DESC LOOP PERFORM doPostCosts(_item.costUpdate_item_id, FALSE, pMaterial, plowerMaterial, pdirectLabor, plowerDirectLabor, poverhead, plowerOverhead, pmachOverhead, plowerMachOverhead, puser, plowerUser, prollUp); END LOOP; RETURN _result; END; $_$; DROP FUNCTION public.dopostcosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean); publicadminfalse84623125578392dopostcosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean)FUNCTIONT CREATE FUNCTION dopostcosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemId ALIAS FOR $1; pResetLowLevel ALIAS FOR $2; pMaterial ALIAS FOR $3; plowerMaterial ALIAS FOR $4; pdirectLabor ALIAS FOR $5; plowerDirectLabor ALIAS FOR $6; poverhead ALIAS FOR $7; plowerOverhead ALIAS FOR $8; pmachOverhead ALIAS FOR $9; plowerMachOverhead ALIAS FOR $10; pUser ALIAS FOR $11; plowerUser ALIAS FOR $12; prollUp ALIAS FOR $13; _itemcost RECORD; _result INTEGER; BEGIN IF (pResetLowLevel) THEN PERFORM resetLowLevelCode(pItemId); END IF; FOR _itemcost IN SELECT itemcost_id, costelem_sys, costelem_type, itemcost_lowlevel, costUpdate_lowlevel_code, costUpdate_item_type FROM itemcost, costelem, costUpdate WHERE itemcost_item_id = pItemId AND costUpdate_item_id = itemcost_item_id AND itemcost_costelem_id = costelem_id LOOP IF (NOT _itemcost.costelem_sys) THEN IF ( (pUser) AND ( NOT _itemcost.itemcost_lowlevel) ) THEN PERFORM postCost(_itemcost.itemcost_id); _result := _result + 1; END IF; IF ( (plowerUser) AND ( _itemcost.itemcost_lowlevel) ) THEN PERFORM postCost(_itemcost.itemcost_id); _result := _result + 1; END IF; END IF; IF (_itemcost.costelem_type = 'Material') THEN IF ( (pMaterial) AND ( NOT _itemcost.itemcost_lowlevel) ) THEN PERFORM postCost(_itemcost.itemcost_id); _result := _result + 1; END IF; IF ( (plowerMaterial) AND ( _itemcost.itemcost_lowlevel) ) THEN PERFORM postCost(_itemcost.itemcost_id); _result := _result + 1; END IF; END IF; IF (_itemcost.costelem_type = 'Direct Labor') THEN IF ( (pdirectLabor) AND ( NOT _itemcost.itemcost_lowlevel) ) THEN PERFORM postCost(_itemcost.itemcost_id); _result := _result + 1; END IF; IF ( (plowerDirectLabor) AND ( _itemcost.itemcost_lowlevel) ) THEN PERFORM postCost(_itemcost.itemcost_id); _result := _result + 1; END IF; END IF; IF (_itemcost.costelem_type = 'Overhead') THEN IF ( (poverhead) AND ( NOT _itemcost.itemcost_lowlevel) ) THEN PERFORM postCost(_itemcost.itemcost_id); _result := _result + 1; END IF; IF ( (plowerOverhead) AND ( _itemcost.itemcost_lowlevel) ) THEN PERFORM postCost(_itemcost.itemcost_id); _result := _result + 1; END IF; END IF; IF (_itemcost.costelem_type = 'Machine Overhead') THEN IF ( (pmachOverhead) AND ( NOT _itemcost.itemcost_lowlevel) ) THEN PERFORM postCost(_itemcost.itemcost_id); _result := _result + 1; END IF; IF ( (plowerMachOverhead) AND ( _itemcost.itemcost_lowlevel) ) THEN PERFORM postCost(_itemcost.itemcost_id); _result := _result + 1; END IF; END IF; END LOOP; IF (prollUp) THEN PERFORM rollUpStandardCost(pItemId); _result := _result + 1; END IF; RETURN _result; END; $_$; DROP FUNCTION public.dopostcosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean); publicadminfalse84623125578393^doupdatecosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean)FUNCTIONCREATE FUNCTION doupdatecosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE plowerMaterial ALIAS FOR $1; pdirectLabor ALIAS FOR $2; plowerDirectLabor ALIAS FOR $3; poverhead ALIAS FOR $4; plowerOverhead ALIAS FOR $5; pmachOverhead ALIAS FOR $6; plowerMachOverhead ALIAS FOR $7; plowerUser ALIAS FOR $8; prollUp ALIAS FOR $9; BEGIN RETURN doUpdateCosts(plowerMaterial, pdirectLabor, plowerDirectLabor, poverhead, plowerOverhead, pmachOverhead, plowerMachOverhead, plowerUser, prollUp, TRUE); END; $_$; uDROP FUNCTION public.doupdatecosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean); publicadminfalse84623125578394gdoupdatecosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean)FUNCTION3CREATE FUNCTION doupdatecosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE plowerMaterial ALIAS FOR $1; pdirectLabor ALIAS FOR $2; plowerDirectLabor ALIAS FOR $3; poverhead ALIAS FOR $4; plowerOverhead ALIAS FOR $5; pmachOverhead ALIAS FOR $6; plowerMachOverhead ALIAS FOR $7; plowerUser ALIAS FOR $8; prollUp ALIAS FOR $9; pActual ALIAS FOR $10; _item RECORD; _bom RECORD; _result INTEGER := 0; BEGIN PERFORM resetLowLevelCode(-1); FOR _item IN SELECT costUpdate_item_id FROM costUpdate ORDER BY costUpdate_lowlevel_code DESC LOOP PERFORM doUpdateCosts(_item.costUpdate_item_id, false, plowerMaterial, pdirectLabor, plowerDirectLabor, poverhead, plowerOverhead, pmachOverhead, plowerMachOverhead, plowerUser, prollUp, pActual); END LOOP; RETURN _result; END; $_$; ~DROP FUNCTION public.doupdatecosts(boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean); publicadminfalse84623125578395pdoupdatecosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean)FUNCTIONXCREATE FUNCTION doupdatecosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemId ALIAS FOR $1; pResetLowLevel ALIAS FOR $2; plowerMaterial ALIAS FOR $3; pdirectLabor ALIAS FOR $4; plowerDirectLabor ALIAS FOR $5; poverhead ALIAS FOR $6; plowerOverhead ALIAS FOR $7; pmachOverhead ALIAS FOR $8; plowerMachOverhead ALIAS FOR $9; plowerUser ALIAS FOR $10; prollUp ALIAS FOR $11; BEGIN RETURN doUpdateCosts(pItemId, pResetLowLevel, plowerMaterial, pdirectLabor, plowerDirectLabor, poverhead, plowerOverhead, pmachOverhead, plowerMachOverhead, plowerUser, prollUp, TRUE); END; $_$; DROP FUNCTION public.doupdatecosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean); publicadminfalse84623125578396ydoupdatecosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean)FUNCTION CREATE FUNCTION doupdatecosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemId ALIAS FOR $1; pResetLowLevel ALIAS FOR $2; plowerMaterial ALIAS FOR $3; pdirectLabor ALIAS FOR $4; plowerDirectLabor ALIAS FOR $5; poverhead ALIAS FOR $6; plowerOverhead ALIAS FOR $7; pmachOverhead ALIAS FOR $8; plowerMachOverhead ALIAS FOR $9; plowerUser ALIAS FOR $10; prollUp ALIAS FOR $11; pUpdateActual ALIAS FOR $12; _item RECORD; _bom RECORD; _result INTEGER := 0; _resultFromReset INTEGER; _counterNum INTEGER; _feedBackNum INTEGER; BEGIN IF (pResetLowLevel) THEN PERFORM resetLowLevelCode(pItemId); END IF; SELECT costUpdate_item_id AS item_id, costUpdate_item_type AS item_type INTO _item FROM costUpdate WHERE costUpdate_item_id = pItemId; IF ((plowerMaterial) AND ((_item.item_type <> 'P') AND (_item.item_type <> 'O'))) THEN PERFORM updateSorACost(_item.item_id, 'Material', TRUE, lowerCost(_item.item_id, 'Material', pUpdateActual), pUpdateActual); END IF; IF (pdirectLabor) THEN PERFORM updateSorACost(_item.item_id, 'Direct Labor', FALSE, xtmfg.directLaborCost(_item.item_id), pUpdateActual); END IF; IF (plowerDirectLabor) THEN PERFORM updateSorACost(_item.item_id, 'Direct Labor', TRUE, lowerCost(_item.item_id, 'Direct Labor', pUpdateActual), pUpdateActual); END IF; IF (poverhead) THEN PERFORM updateSorACost(_item.item_id, 'Overhead', FALSE, xtmfg.overheadCost(_item.item_id), pUpdateActual); END IF; IF (plowerOverhead) THEN PERFORM updateSorACost(_item.item_id, 'Overhead', TRUE, lowerCost(_item.item_id, 'Overhead', pUpdateActual), pUpdateActual); END IF; IF (pmachOverhead) THEN PERFORM updateSorACost(_item.item_id, 'Machine Overhead', FALSE, xtmfg.machineOverheadCost(_item.item_id), pUpdateActual); END IF; IF (plowerMachOverhead) THEN PERFORM updateSorACost(_item.item_id, 'Machine Overhead', TRUE, lowerCost(_item.item_id, 'Machine Overhead', pUpdateActual), pUpdateActual); END IF; IF (plowerUser) THEN PERFORM updateLowerUserCosts(_item.item_id, pUpdateActual); END IF; IF (prollUp) THEN PERFORM rollUpSorACost(_item.item_id, pUpdateActual); END IF; RETURN _result; END; $_$; DROP FUNCTION public.doupdatecosts(integer, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean); publicadminfalse46238w125578397dropifexists(text, text)FUNCTIONCREATE FUNCTION dropifexists(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN dropIfExists($1, $2, 'public'); END; $_$; /DROP FUNCTION public.dropifexists(text, text); publicadminfalse46238x125578398dropifexists(text, text, text)FUNCTIONCREATE FUNCTION dropifexists(text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN dropIfExists($1, $2, $3, false); END; $_$; 5DROP FUNCTION public.dropifexists(text, text, text); publicadminfalse46238125578399'dropifexists(text, text, text, boolean)FUNCTIONCREATE FUNCTION dropifexists(text, text, text, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pType ALIAS FOR $1; pObject ALIAS FOR $2; pSchema ALIAS FOR $3; pCascade ALIAS FOR $4; _table TEXT; _query TEXT; BEGIN IF (UPPER(pType) = 'INDEX') THEN _query = 'DROP INDEX ' || quote_ident(LOWER(pSchema)) || '.' || quote_ident(LOWER(pObject)); BEGIN EXECUTE _query; EXCEPTION WHEN undefined_object OR invalid_schema_name THEN RETURN 0; WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM; END; ELSEIF (UPPER(pType) = 'TABLE') THEN _query = 'DROP TABLE ' || quote_ident(LOWER(pSchema)) || '.' || quote_ident(LOWER(pObject)); IF (pCascade) THEN _query = _query || ' CASCADE'; END IF; BEGIN EXECUTE _query; EXCEPTION WHEN undefined_table OR invalid_schema_name THEN RETURN 0; WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM; END; ELSIF (UPPER(pType) = 'VIEW') THEN _query = 'DROP VIEW ' || quote_ident(LOWER(pSchema)) || '.' || quote_ident(LOWER(pObject)); IF (pCascade) THEN _query = _query || ' CASCADE'; END IF; BEGIN EXECUTE _query; EXCEPTION WHEN undefined_table OR invalid_schema_name THEN RETURN 0; WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM; END; ELSIF (UPPER(pType) = 'TRIGGER') THEN SELECT relname INTO _table FROM pg_trigger, pg_class WHERE ((tgrelid=pg_class.oid) AND (UPPER(tgname)=UPPER(pObject))); IF (NOT FOUND) THEN _table := '[no table]'; END IF; _query = 'DROP TRIGGER ' || quote_ident(LOWER(pObject)) || ' ON ' || quote_ident(LOWER(pSchema)) || '.' || quote_ident(LOWER(_table)); BEGIN EXECUTE _query; EXCEPTION WHEN undefined_object THEN RETURN 0; WHEN undefined_table OR invalid_schema_name THEN RETURN 0; WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM; END; ELSIF (UPPER(pType) = 'FUNCTION') THEN _query = 'DROP FUNCTION ' || (LOWER(pSchema)) || '.' || (LOWER(pObject)); BEGIN EXECUTE _query; EXCEPTION WHEN undefined_object OR undefined_function OR invalid_schema_name THEN RETURN 0; WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM; END; ELSIF (UPPER(pType) = 'CONSTRAINT') THEN IF( (SELECT count(*) FROM pg_constraint, pg_class, pg_namespace WHERE((conrelid=pg_class.oid) AND (connamespace=pg_namespace.oid) AND (conname=pObject) AND (nspname=pSchema)) ) > 1 ) THEN RAISE EXCEPTION 'dropIfExists called on constraint name that matches more than 1 constraint.'; END IF; SELECT relname INTO _table FROM pg_constraint, pg_class, pg_namespace WHERE ((conrelid=pg_class.oid) AND (connamespace=pg_namespace.oid) AND (conname=pObject) AND (nspname=pSchema)); IF (NOT FOUND) THEN RETURN 0; END IF; _query = 'ALTER TABLE ' || quote_ident(LOWER(pSchema)) || '.' || quote_ident(LOWER(_table)) || ' DROP CONSTRAINT ' || quote_ident(LOWER(pObject)); BEGIN EXECUTE _query; EXCEPTION WHEN undefined_table OR invalid_schema_name THEN RETURN 0; WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM; END; ELSIF (UPPER(pType) = 'SCHEMA') THEN _query = 'DROP SCHEMA ' || quote_ident(LOWER(pObject)); BEGIN EXECUTE _query; EXCEPTION WHEN invalid_schema_name THEN RETURN 0; WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM; END; ELSIF (UPPER(pType) = 'TYPE') THEN _query = 'DROP TYPE ' || quote_ident(LOWER(pSchema)) || '.' || quote_ident(LOWER(pObject)); IF (pCascade) THEN _query = _query || ' CASCADE'; END IF; BEGIN EXECUTE _query; EXCEPTION WHEN undefined_object OR invalid_schema_name THEN RETURN 0; WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM; END; ELSE RAISE EXCEPTION 'dropIfExists(%, %): unknown pType %', pType, pObject, pType; END IF; RETURN 1; END; $_$; >DROP FUNCTION public.dropifexists(text, text, text, boolean); publicadminfalse84623125578400$dropifexists(text, text, text, text)FUNCTIONCREATE FUNCTION dropifexists(text, text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pType ALIAS FOR $1; pObject ALIAS FOR $2; pSchema ALIAS FOR $3; pRelation ALIAS FOR $4; _table TEXT; _query TEXT; BEGIN IF (UPPER(pType) = 'CONSTRAINT') THEN SELECT relname INTO _table FROM pg_constraint, pg_class, pg_namespace WHERE ((conrelid=pg_class.oid) AND (connamespace=pg_namespace.oid) AND (conname=pObject) AND (relname=pRelation) AND (nspname=pSchema)); IF (NOT FOUND) THEN RETURN 0; END IF; _query = 'ALTER TABLE ' || quote_ident(LOWER(pSchema)) || '.' || quote_ident(LOWER(pRelation)) || ' DROP CONSTRAINT ' || quote_ident(LOWER(pObject)); BEGIN EXECUTE _query; EXCEPTION WHEN undefined_table OR invalid_schema_name THEN RETURN 0; WHEN OTHERS THEN RAISE EXCEPTION '% %', SQLSTATE, SQLERRM; END; ELSE RAISE EXCEPTION 'dropIfExists(%, %, %, %): pType % is not supported when relation is specified', pType, pObject, pSchema, pRelation, pType; END IF; RETURN 1; END; $_$; ;DROP FUNCTION public.dropifexists(text, text, text, text); publicadminfalse46238125578401dropstdopntable()FUNCTIONCREATE FUNCTION dropstdopntable() RETURNS boolean LANGUAGE plpgsql AS $$ BEGIN IF((SELECT metric_value != 'Manufacturing' FROM metric WHERE metric_name = 'Application')) THEN PERFORM dropIfExists('TABLE', 'stdopn'); RETURN true; END IF; RETURN false; END; $$; (DROP FUNCTION public.dropstdopntable(); publicadminfalse84623125578402editccnumber(text, text)FUNCTION CREATE FUNCTION editccnumber(text, text) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCcardnum ALIAS FOR $1; pCcardtype ALIAS FOR $2; card_length INTEGER; card_valid boolean := false; starting_digits TEXT; _sum INTEGER := 0; _digit INTEGER := 0; _timesTwo BOOLEAN := false; BEGIN -- Check the card type IF (pCcardtype NOT IN ('M', 'V', 'A', 'D')) THEN -- Unknown Card Type RETURN -1; END IF; card_length := length(pCcardnum); -- Process Master Card Checking length -- Process Master Card Starting digits IF (pCcardtype = 'M') THEN IF (card_length != 16) THEN -- Bad Card Length Card Type RETURN -2; END IF; starting_digits := substr(pCcardnum, 1, 2); IF (starting_digits < '51' OR starting_digits > '55') THEN -- Bad Starting digits RETURN -6; END IF; END IF; -- Process Visa Card Checking length -- Process Visa Card Starting digits IF (pCcardtype = 'V') THEN IF (card_length != 13 AND card_length != 16) THEN -- Bad Card Length Card Type RETURN -3; END IF; starting_digits := substr(pCcardnum, 1, 1); IF (starting_digits != '4') THEN -- Bad Starting digits RETURN -7; END IF; END IF; -- Process American Express Card Checking length -- Process American Express Card Starting digits IF (pCcardtype = 'A') THEN IF (card_length != 15) THEN -- Bad Card Length Card Type RETURN -4; END IF; starting_digits := substr(pCcardnum, 1, 2); IF (starting_digits != '34' AND starting_digits != '37') THEN -- Bad Starting digits RETURN -8; END IF; END IF; -- Process Discover Card Checking length -- Process Discover Card Starting digits IF (pCcardtype = 'D') THEN IF (card_length != 16) THEN -- Bad Card Length Card Type RETURN -5; END IF; starting_digits := substr(pCcardnum, 1, 4); IF (starting_digits != '6011') THEN -- Bad Starting digits RETURN -9; END IF; END IF; -- Now comes the fun part of doing the "check" for the check sum -- perform a luhn checksum FOR i IN REVERSE card_length .. 1 LOOP _digit := int4(substr(pCcardnum, i, 1)); IF (_timesTwo) THEN _digit := _digit * 2; IF (_digit > 9) THEN _digit := _digit - 9; END IF; END IF; _sum := _sum + _digit; _timesTwo := NOT _timesTwo; END LOOP; IF (mod(_sum, 10) != 0) THEN RETURN -10; END IF; RETURN 0; -- No Error END; $_$; /DROP FUNCTION public.editccnumber(text, text); publicadminfalse46238125578403enablepackage(text)FUNCTIONCREATE FUNCTION enablepackage(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ppkgname ALIAS FOR $1; _i INTEGER := 0; _tabs TEXT[] := ARRAY['cmd', 'cmdarg', 'image', 'metasql', 'priv', 'report', 'script', 'uiform']; BEGIN IF (version() < 'PostgreSQL 8.2') THEN RETURN -1; END IF; FOR _i IN ARRAY_LOWER(_tabs,1)..ARRAY_UPPER(_tabs,1) LOOP EXECUTE 'ALTER TABLE ' || ppkgname || '.pkg' || _tabs[_i] || ' INHERIT public.' || _tabs[_i] || ';'; END LOOP; RETURN 0; END; $_$; *DROP FUNCTION public.enablepackage(text); publicadminfalse84623125578404enablepackage(integer)FUNCTIONCREATE FUNCTION enablepackage(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ppkgheadid ALIAS FOR $1; _pkgname TEXT; BEGIN SELECT pkghead_name INTO _pkgname FROM pkghead WHERE (pkghead_id=ppkgheadid); IF (NOT FOUND) THEN RETURN -2; END IF; RETURN enablePackage(_pkgname); END; $_$; -DROP FUNCTION public.enablepackage(integer); publicadminfalse84623125578405encrypt(bytea, bytea, text)FUNCTIONCREATE FUNCTION encrypt(bytea, bytea, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_encrypt'; 2DROP FUNCTION public.encrypt(bytea, bytea, text); publicadminfalse8125578406%encrypt_iv(bytea, bytea, bytea, text)FUNCTIONCREATE FUNCTION encrypt_iv(bytea, bytea, bytea, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_encrypt_iv'; <DROP FUNCTION public.encrypt_iv(bytea, bytea, bytea, text); publicadminfalse8125578407 endoftime()FUNCTIONCREATE FUNCTION endoftime() RETURNS date LANGUAGE sql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT DATE('2100-01-01') as result; $$; "DROP FUNCTION public.endoftime(); publicadminfalse8125578408"entercount(integer, numeric, text)FUNCTIONDCREATE FUNCTION entercount(integer, numeric, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvcntid ALIAS FOR $1; pQty ALIAS FOR $2; pComments ALIAS FOR $3; BEGIN UPDATE invcnt SET invcnt_qoh_after = pQty, invcnt_comments = CASE WHEN ( (LENGTH(invcnt_comments) = 0) AND (LENGTH(pComments) > 0) ) THEN pComments WHEN (LENGTH(pComments) > 0) THEN (invcnt_comments || E'\n' || pComments) ELSE invcnt_comments END, invcnt_cntdate = CURRENT_TIMESTAMP, invcnt_cnt_username = getEffectiveXtUser() WHERE (invcnt_id=pInvcntid); RETURN 0; END; $_$; 9DROP FUNCTION public.entercount(integer, numeric, text); publicadminfalse46238125578409 enterporeceipt(integer, numeric)FUNCTION+CREATE FUNCTION enterporeceipt(integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN enterReceipt('PO', $1, $2, 0.0, '', NULL, NULL); END; $_$; 7DROP FUNCTION public.enterporeceipt(integer, numeric); publicadminfalse46238125578410&enterporeceipt(integer, numeric, text)FUNCTION3CREATE FUNCTION enterporeceipt(integer, numeric, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN enterPoReceipt('PO', $1, $2, 0.0, $3, NULL, NULL); END; $_$; =DROP FUNCTION public.enterporeceipt(integer, numeric, text); publicadminfalse46238125578411/enterporeceipt(integer, numeric, numeric, text)FUNCTION;CREATE FUNCTION enterporeceipt(integer, numeric, numeric, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN enterPoReceipt('PO', $1, $2, $3, $4, NULL, NULL); END; $_$; FDROP FUNCTION public.enterporeceipt(integer, numeric, numeric, text); publicadminfalse46238125578412>enterporeceipt(integer, numeric, numeric, text, integer, date)FUNCTIONDCREATE FUNCTION enterporeceipt(integer, numeric, numeric, text, integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN enterReceipt('PO', $1, $2, $3, $4, $5, $6); END; $_$; UDROP FUNCTION public.enterporeceipt(integer, numeric, numeric, text, integer, date); publicadminfalse46238125578413(enterporeturn(integer, numeric, integer)FUNCTION#CREATE FUNCTION enterporeturn(integer, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN enterPoReturn($1, $2, $3, NULL); END; $_$; ?DROP FUNCTION public.enterporeturn(integer, numeric, integer); publicadminfalse846231255784141enterporeturn(integer, numeric, integer, integer)FUNCTIONCREATE FUNCTION enterporeturn(integer, numeric, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPoitemid ALIAS FOR $1; pQty ALIAS FOR $2; pRjctcodeid ALIAS FOR $3; pRecvid ALIAS FOR $4; _porejectid INTEGER; BEGIN SELECT NEXTVAL('poreject_poreject_id_seq') INTO _porejectid; INSERT INTO poreject ( poreject_id, poreject_date, poreject_ponumber, poreject_poitem_id, poreject_trans_username, poreject_agent_username, poreject_itemsite_id, poreject_vend_id, poreject_vend_item_number, poreject_vend_item_descrip, poreject_vend_uom, poreject_qty, poreject_rjctcode_id, poreject_posted, poreject_invoiced, poreject_recv_id ) SELECT _porejectid, CURRENT_TIMESTAMP, pohead_number, poitem_id, getEffectiveXtUser(), pohead_agent_username, poitem_itemsite_id, pohead_vend_id, poitem_vend_item_number, poitem_vend_item_descrip, poitem_vend_uom, pQty, pRjctcodeid, FALSE, FALSE, pRecvid FROM poitem JOIN pohead ON (pohead_id=poitem_pohead_id) WHERE (poitem_id=pPoitemid); RETURN _porejectid; END; $_$; HDROP FUNCTION public.enterporeturn(integer, numeric, integer, integer); publicadminfalse46238125578415Benterreceipt(text, integer, numeric, numeric, text, integer, date)FUNCTIONLCREATE FUNCTION enterreceipt(text, integer, numeric, numeric, text, integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN enterReceipt($1, $2, $3, $4, $5, $6, $7, NULL); END; $_$; YDROP FUNCTION public.enterreceipt(text, integer, numeric, numeric, text, integer, date); publicadminfalse46238125578416Kenterreceipt(text, integer, numeric, numeric, text, integer, date, numeric)FUNCTIONCREATE FUNCTION enterreceipt(text, integer, numeric, numeric, text, integer, date, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; porderitemid ALIAS FOR $2; pQty ALIAS FOR $3; pFreight ALIAS FOR $4; pNotes ALIAS FOR $5; pcurrid ALIAS FOR $6; -- NULL is handled by SELECT ... INTO _o precvdate ALIAS FOR $7; -- NULL is handled by INSERT INTO recv pRecvCost ALIAS FOR $8; _timestamp TIMESTAMP; _o RECORD; _recvid INTEGER; _warehouseid INTEGER; _recvcost NUMERIC; BEGIN IF(precvdate IS NULL OR precvdate = CURRENT_DATE) THEN _timestamp := CURRENT_TIMESTAMP; ELSE _timestamp := precvdate; END IF; SELECT NEXTVAL('recv_recv_id_seq') INTO _recvid; DELETE FROM recv WHERE ((NOT recv_posted) AND (recv_order_type=pordertype) AND (recv_orderitem_id=porderitemid) ); IF (pQty > 0) THEN IF (pordertype='PO') THEN SELECT pohead_number AS orderhead_number, poitem_id AS orderitem_id, pohead_agent_username AS orderhead_agent_username, CASE WHEN (poitem_itemsite_id = -1) THEN NULL ELSE poitem_itemsite_id END AS itemsite_id, vend_id, COALESCE(poitem_vend_item_number, '') AS vend_item_number, COALESCE(poitem_vend_item_descrip, '') AS vend_item_descrip, COALESCE(poitem_vend_uom, '') AS vend_uom, poitem_duedate AS duedate, poitem_unitprice AS orderitem_unitcost, pohead_curr_id AS orderitem_unitcost_curr_id, pohead_curr_id AS freight_curr_id, poitem_rlsd_duedate AS rlsd_duedate INTO _o FROM pohead JOIN poitem ON (pohead_id=poitem_pohead_id) JOIN vendinfo ON (pohead_vend_id=vend_id) WHERE (poitem_id=porderitemid); ELSIF (pordertype='RA') THEN SELECT rahead_number AS orderhead_number, raitem_id AS orderitem_id, ''::text AS orderhead_agent_username, raitem_itemsite_id AS itemsite_id, NULL::integer AS vend_id, ''::text AS vend_item_number, ''::text AS vend_item_descrip, ''::text AS vend_uom, raitem_scheddate AS duedate, raitem_unitprice AS orderitem_unitcost, rahead_curr_id AS orderitem_unitcost_curr_id, rahead_curr_id AS freight_curr_id, raitem_scheddate AS rlsd_duedate INTO _o FROM rahead JOIN raitem ON (rahead_id=raitem_rahead_id) WHERE (raitem_id=porderitemid); ELSIF (pordertype='TO') THEN SELECT tohead_number AS orderhead_number, toitem_id AS orderitem_id, tohead_agent_username AS orderhead_agent_username, itemsite_id, NULL::integer AS vend_id, ''::text AS vend_item_number, ''::text AS vend_item_descrip, ''::text AS vend_uom, toitem_duedate AS duedate, toitem_stdcost AS orderitem_unitcost, baseCurrId() AS orderitem_unitcost_curr_id, toitem_freight_curr_id AS freight_curr_id, toitem_duedate AS rlsd_duedate INTO _o FROM itemsite, tohead JOIN toitem ON (tohead_id=toitem_tohead_id) WHERE ((toitem_id=porderitemid) AND (tohead_dest_warehous_id=itemsite_warehous_id) AND (toitem_item_id=itemsite_item_id)); END IF; --Make sure user has site privileges IF ((FOUND) AND (_o.itemsite_id IS NOT NULL)) THEN SELECT warehous_id INTO _warehouseid FROM itemsite,site() WHERE ((itemsite_id=_o.itemsite_id) AND (warehous_id=itemsite_warehous_id)); IF (NOT FOUND) THEN RETURN 0; END IF; END IF; --Make sure we aren't trying to receive a Kit IF ((FOUND) AND (_o.itemsite_id IS NOT NULL)) THEN IF (SELECT (item_type='K') FROM itemsite, item WHERE ((itemsite_id=_o.itemsite_id) AND (item_id=itemsite_item_id))) THEN RETURN 0; END IF; END IF; IF (NOT FOUND) THEN RETURN -1; END IF; -- default to orderitem_unitcost if recv_purchcost is not specified IF(pRecvCost IS NULL) THEN _recvcost := _o.orderitem_unitcost; ELSE _recvcost := pRecvCost; END IF; INSERT INTO recv ( recv_id, recv_date, recv_order_number, recv_order_type, recv_orderitem_id, recv_trans_usr_name, recv_agent_username, recv_itemsite_id, recv_vend_id, recv_vend_item_number, recv_vend_item_descrip, recv_vend_uom, recv_qty, recv_duedate, recv_purchcost, recv_purchcost_curr_id, recv_notes, recv_freight, recv_freight_curr_id, recv_rlsd_duedate ) VALUES ( _recvid, _timestamp, _o.orderhead_number, pordertype, _o.orderitem_id::INTEGER, getEffectiveXtUser(), _o.orderhead_agent_username, _o.itemsite_id::INTEGER, _o.vend_id::INTEGER, _o.vend_item_number, _o.vend_item_descrip, _o.vend_uom, pQty, _o.duedate, _recvcost, _o.orderitem_unitcost_curr_id::INTEGER, pNotes, pFreight, _o.freight_curr_id::INTEGER, _o.rlsd_duedate); END IF; RETURN _recvid; END; $_$; bDROP FUNCTION public.enterreceipt(text, integer, numeric, numeric, text, integer, date, numeric); publicadminfalse46238125578417 expirecreditcard(integer, bytea)FUNCTIONiCREATE FUNCTION expirecreditcard(integer, bytea) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCust ALIAS FOR $1; pKey ALIAS FOR $2; num_updated INTEGER; cc_year INTEGER; cc_month INTEGER; cc_year_t TEXT; cc_month_t TEXT; _dr RECORD; _cc RECORD; bf TEXT; BEGIN num_updated := 0; bf := 'bf'; select cast(date_part('year', CURRENT_DATE) AS INTEGER) AS check_year, cast(date_part('month', CURRENT_DATE) AS INTEGER) AS check_month INTO _dr; FOR _cc IN SELECT ccard_id, decrypt(setbytea(ccard_month_expired), setbytea(pKey), 'bf') AS ccard_month_expired, decrypt(setbytea(ccard_year_expired), setbytea(pKey), 'bf') AS ccard_year_expired FROM ccard WHERE ( (ccard_cust_id=pCust) AND (ccard_active) ) LOOP SELECT formatbytea(_cc.ccard_month_expired) INTO cc_month_t; SELECT formatbytea(_cc.ccard_year_expired) INTO cc_year_t; SELECT cast(cc_month_t AS INTEGER) INTO cc_month; SELECT cast(cc_year_t AS INTEGER) INTO cc_year; IF (cc_year < _dr.check_year) THEN -- We have an expired card UPDATE ccard set ccard_active = FALSE where ccard_id = _cc.ccard_id; num_updated := num_updated + 1; ELSIF (cc_year = _dr.check_year AND cc_month < _dr.check_month) THEN -- We have an expired card UPDATE ccard set ccard_active = FALSE where ccard_id = _cc.ccard_id; num_updated := num_updated + 1; END IF; END LOOP; RETURN num_updated; END; $_$; 7DROP FUNCTION public.expirecreditcard(integer, bytea); publicadminfalse84623125578418%explodebom(integer, integer, integer)FUNCTIONCREATE FUNCTION explodebom(integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pParentid ALIAS FOR $2; pLevel ALIAS FOR $3; _revid INTEGER; BEGIN SELECT getActiveRevId('BOM',pItemid) INTO _revid; RETURN explodeBOM(pItemid, _revid, pParentid, pLevel); END; $_$; <DROP FUNCTION public.explodebom(integer, integer, integer); publicadminfalse46238125578419.explodebom(integer, integer, integer, integer)FUNCTION CREATE FUNCTION explodebom(integer, integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pRevisionid ALIAS FOR $2; pParentid ALIAS FOR $3; pLevel ALIAS FOR $4; _bomworkid INTEGER; _level INTEGER; _p RECORD; _r RECORD; _temp TEXT; BEGIN _level := (pLevel + 1); -- Cache some parameters about the parent SELECT bomwork_item_id, bomwork_set_id, bomwork_qtyreq, bomwork_seqnumber, bomwork_effective, bomwork_expires INTO _p FROM bomwork WHERE (bomwork_id=pParentid); -- Step through all of the components of the parent component FOR _r IN SELECT bomitem.*, item_id, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS qtyfxd, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS qtyper, CASE WHEN (_p.bomwork_effective > bomitem_effective) THEN _p.bomwork_effective ELSE bomitem_effective END AS effective, CASE WHEN (_p.bomwork_expires < bomitem_expires) THEN _p.bomwork_expires ELSE bomitem_expires END AS expires, stdcost(item_id, bomitem_id) AS standardcost, actcost(item_id, bomitem_id) AS actualcost FROM bomitem(pItemid, pRevisionid), item WHERE ( (bomitem_item_id=item_id) AND (bomitem_expires > _p.bomwork_effective) ) LOOP -- Insert the current component and some bomitem parameters into the bomwork set SELECT NEXTVAL('bomwork_bomwork_id_seq') INTO _bomworkid; INSERT INTO bomwork ( bomwork_id, bomwork_set_id, bomwork_parent_id, bomwork_level, bomwork_parent_seqnumber, bomwork_seqnumber, bomwork_item_id, bomwork_createwo, bomwork_qtyreq, bomwork_qtyfxd, bomwork_qtyper, bomwork_scrap, bomwork_issuemethod, bomwork_effective, bomwork_expires, bomwork_stdunitcost, bomwork_actunitcost, bomwork_notes, bomwork_ref, bomwork_bomitem_id, bomwork_ecn ) VALUES ( _bomworkid, _p.bomwork_set_id, pParentid, _level, _p.bomwork_seqnumber, _r.bomitem_seqnumber, _r.item_id, _r.bomitem_createwo, (_p.bomwork_qtyreq * _r.qtyper + _r.qtyfxd), _r.qtyfxd, _r.qtyper, _r.bomitem_scrap, _r.bomitem_issuemethod, _r.effective, _r.expires, _r.standardcost, _r.actualcost, _r.bomitem_notes, _r.bomitem_ref, _r.bomitem_id, _r.bomitem_ecn ); -- Recursively repeat for this component's components PERFORM explodeBOM(_r.item_id, _bomworkid, _level); END LOOP; RETURN 1; END; $_$; EDROP FUNCTION public.explodebom(integer, integer, integer, integer); publicadminfalse462381255784207explodekit(integer, integer, integer, integer, numeric)FUNCTIONCREATE FUNCTION explodekit(integer, integer, integer, integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; pLinenumber ALIAS FOR $2; pSubnumber ALIAS FOR $3; pItemsiteid ALIAS FOR $4; pQty ALIAS FOR $5; BEGIN RETURN explodeKit(pSoheadid, pLinenumber, pSubnumber, pItemsiteid, pQty, CURRENT_DATE, NULL); END; $_$; NDROP FUNCTION public.explodekit(integer, integer, integer, integer, numeric); publicadminfalse84623125578421Cexplodekit(integer, integer, integer, integer, numeric, date, date)FUNCTIONQCREATE FUNCTION explodekit(integer, integer, integer, integer, numeric, date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; pLinenumber ALIAS FOR $2; pSubnumber ALIAS FOR $3; pItemsiteid ALIAS FOR $4; pQty ALIAS FOR $5; pScheddate ALIAS FOR $6; pPromdate ALIAS FOR $7; BEGIN RETURN explodeKit(pSoheadid, pLinenumber, pSubnumber, pItemsiteid, pQty, COALESCE(pScheddate, CURRENT_DATE), pPromdate, ''); END; $_$; ZDROP FUNCTION public.explodekit(integer, integer, integer, integer, numeric, date, date); publicadminfalse84623125578422Iexplodekit(integer, integer, integer, integer, numeric, date, date, text)FUNCTIONCREATE FUNCTION explodekit(integer, integer, integer, integer, numeric, date, date, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; pLinenumber ALIAS FOR $2; pSubnumber ALIAS FOR $3; pItemsiteid ALIAS FOR $4; pQty ALIAS FOR $5; pScheddate ALIAS FOR $6; pPromdate ALIAS FOR $7; pMemo ALIAS FOR $8; _subnumber INTEGER := COALESCE(pSubnumber,0); _revid INTEGER; _itemid INTEGER; _warehousid INTEGER; _item RECORD; _type TEXT; _coitemid INTEGER; _count INTEGER; _orderid INTEGER := 0; _itemsrcid INTEGER; BEGIN SELECT getActiveRevId('BOM',itemsite_item_id), itemsite_warehous_id, itemsite_item_id INTO _revid, _warehousid, _itemid FROM itemsite WHERE(itemsite_id=pItemsiteid); IF(NOT FOUND) THEN RAISE EXCEPTION 'No Item Site for the specified line was found.'; END IF; FOR _item IN SELECT bomitem_id, itemsite_id, itemsite_warehous_id, COALESCE((itemsite_active AND item_active), false) AS active, COALESCE((itemsite_sold AND item_sold), false) AS sold, item_id, item_type, item_price_uom_id, itemsite_createsopr,itemsite_createwo,itemsite_createsopo, itemsite_dropship, bomitem_uom_id, itemuomtouomratio(item_id, bomitem_uom_id, item_inv_uom_id) AS invuomratio, roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id),(bomitem_qtyfxd + bomitem_qtyper * pQty) * (1 + bomitem_scrap)) AS qty FROM bomitem JOIN item ON (item_id=bomitem_item_id) LEFT OUTER JOIN itemsite ON ((itemsite_item_id=item_id) AND (itemsite_warehous_id=_warehousid)) WHERE((bomitem_parent_item_id=_itemid) AND (bomitem_rev_id=_revid) AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1))) ORDER BY bomitem_seqnumber LOOP IF (NOT _item.active) THEN RAISE EXCEPTION 'One or more of the components for the kit is inactive for the selected item site.'; ELSIF (NOT _item.sold) THEN RAISE EXCEPTION 'One or more of the components for the kit is not sold for the selected item site.'; ELSIF (_item.item_type='F') THEN SELECT explodeKit(pSoheadid, pLinenumber, _subnumber, _item.itemsite_id, _item.qty) INTO _subnumber; ELSE IF (_item.itemsite_createsopr) THEN _type := 'R'; ELSIF (_item.itemsite_createsopo) THEN _type := 'P'; ELSIF (_item.itemsite_createwo) THEN _type := 'W'; ELSE _type := NULL; END IF; _subnumber := _subnumber + 1; _coitemid = nextval('coitem_coitem_id_seq'); INSERT INTO coitem (coitem_id, coitem_cohead_id, coitem_linenumber, coitem_subnumber, coitem_itemsite_id, coitem_status, coitem_scheddate, coitem_promdate, coitem_qtyord, coitem_qty_uom_id, coitem_qty_invuomratio, coitem_qtyshipped, coitem_qtyreturned, coitem_unitcost, coitem_custprice, coitem_price, coitem_price_uom_id, coitem_price_invuomratio, coitem_order_type, coitem_order_id, coitem_custpn, coitem_memo, coitem_prcost) VALUES (_coitemid, pSoheadid, pLinenumber, _subnumber, _item.itemsite_id, 'O', pScheddate, pPromdate, _item.qty, _item.bomitem_uom_id, _item.invuomratio, 0, 0, stdCost(_item.item_id), 0, 0, _item.item_price_uom_id, 1, _type, -1, '', pMemo, 0); END IF; END LOOP; RETURN _subnumber; END; $_$; `DROP FUNCTION public.explodekit(integer, integer, integer, integer, numeric, date, date, text); publicadminfalse84623125578424.explodephantomorder(integer, integer, numeric)FUNCTIONcCREATE FUNCTION explodephantomorder(integer, integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPlanordid ALIAS FOR $1; pPhantomid ALIAS FOR $2; pQty ALIAS FOR $3; _b RECORD; BEGIN FOR _b IN SELECT planord_number, c.itemsite_id AS componentsiteid, calculatenextworkingdate(c.itemsite_warehous_id, planord_startdate, (c.itemsite_leadtime * -1)) AS startdate, planord_startdate AS duedate, bomitem_createwo, c.itemsite_planning_type AS planningtype, (itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd + pQty * bomitem_qtyper) * (1 + bomitem_scrap))) AS qtyreq, item_type FROM bomitem, planord, itemsite AS p, itemsite AS c, item WHERE ((bomitem_parent_item_id=p.itemsite_item_id) AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id)) AND (bomitem_item_id=c.itemsite_item_id) AND (p.itemsite_warehous_id=c.itemsite_warehous_id) AND (c.itemsite_item_id=item_id) AND (woEffectiveDate(planord_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND (p.itemsite_id=pPhantomid) AND (planord_id=pPlanordid)) LOOP IF (_b.item_type = 'F') THEN PERFORM explodePhantomOrder(pPlanordid, _b.componentsiteid, _b.qtyreq); ELSE -- Create the Planned Requirement INSERT INTO planreq ( planreq_source, planreq_source_id, planreq_itemsite_id, planreq_qty ) VALUES ( 'P', pPlanordid, _b.componentsiteid, _b.qtyreq ); IF (_b.bomitem_createwo AND _b.planningtype != 'N') THEN PERFORM createPlannedOrder( pPlanordid, _b.planord_number, _b.componentsiteid, _b.qtyreq, _b.startdate, _b.duedate, FALSE, FALSE, NULL, NULL); END IF; END IF; END LOOP; RETURN pPlanordid; END; $_$; EDROP FUNCTION public.explodephantomorder(integer, integer, numeric); publicadminfalse84623125578425explodewo(integer, boolean)FUNCTION6CREATE FUNCTION explodewo(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pExplodeChildren ALIAS FOR $2; resultCode INTEGER; newWo RECORD; _newwoid INTEGER; _p RECORD; _r RECORD; _bbom BOOLEAN; BEGIN -- Find out if Breeder BOMs are enabled SELECT metric_value='t' INTO _bbom FROM metric WHERE (metric_name='BBOM'); -- Make sure that this W/O is Open SELECT wo_id INTO resultCode FROM wo WHERE ((wo_status='O') AND (wo_id=pWoid)); IF (NOT FOUND) THEN RETURN -4; END IF; -- Make sure that all Component Item Sites exist and are valid -- Item Sites must be active and not Job Costed SELECT bomitem_id INTO resultCode FROM wo, bomitem, itemsite WHERE ( (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=bomitem_parent_item_id) AND (woEffectiveDate(wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND (wo_id=pWoid) AND (bomitem_rev_id=wo_bom_rev_id) AND (bomitem_item_id NOT IN ( SELECT component.itemsite_item_id FROM itemsite AS component, itemsite AS parent WHERE ( (wo_itemsite_id=parent.itemsite_id) AND (parent.itemsite_item_id=bomitem_parent_item_id) AND (bomitem_item_id=component.itemsite_item_id) AND (woEffectiveDate(wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND (component.itemsite_active) AND (component.itemsite_warehous_id=parent.itemsite_warehous_id) ) ) ) ) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; -- If the Parent Item is a Breeder, make sure that all the -- Co-Product/By-Product Item Sites exist IF (_bbom) THEN IF ( ( SELECT (item_type='B') FROM wo, itemsite, item WHERE ( (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (wo_id=pWoid) ) ) ) THEN SELECT bbomitem_id INTO resultCode FROM wo, xtmfg.bbomitem, itemsite WHERE ( (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=bbomitem_parent_item_id) AND (woEffectiveDate(wo_startdate) BETWEEN bbomitem_effective AND (bbomitem_expires - 1)) AND (wo_id=pWoid) AND (bbomitem_item_id NOT IN ( SELECT component.itemsite_item_id FROM itemsite AS component, itemsite AS parent WHERE ( (wo_itemsite_id=parent.itemsite_id) AND (parent.itemsite_item_id=bbomitem_parent_item_id) AND (bbomitem_item_id=component.itemsite_item_id) AND (woEffectiveDate(wo_startdate) BETWEEN bbomitem_effective AND (bbomitem_expires - 1)) AND (component.itemsite_active) AND (component.itemsite_warehous_id=parent.itemsite_warehous_id) ) ) ) ) LIMIT 1; IF (FOUND) THEN RETURN -3; END IF; END IF; END IF; -- Create the W/O Material Requirements INSERT INTO womatl ( womatl_wo_id, womatl_bomitem_id, womatl_wooper_id, womatl_schedatwooper, womatl_itemsite_id, womatl_duedate, womatl_uom_id, womatl_qtyfxd, womatl_qtyper, womatl_scrap, womatl_qtyreq, womatl_qtyiss, womatl_qtywipscrap, womatl_lastissue, womatl_lastreturn, womatl_cost, womatl_picklist, womatl_createwo, womatl_issuewo, womatl_issuemethod, womatl_notes, womatl_ref, womatl_price ) SELECT wo_id, bomitem_id, bomitem_booitem_seq_id, bomitem_schedatwooper, matl_itemsite, duedate, bomitem_uom_id, bomitem_qtyfxd, bomitem_qtyper, bomitem_scrap, qtyreq, 0, 0, startOfTime(), startOfTime(), 0, item_picklist, ( (item_type='M') AND (bomitem_createwo) ), issuewo, bomitem_issuemethod, bomitem_notes, bomitem_ref, CASE WHEN (price=-9999.0) THEN 0.0 ELSE price END FROM (SELECT *, cs.itemsite_id AS matl_itemsite, CASE WHEN bomitem_schedatwooper THEN COALESCE(calcWooperStartStub(wo_id,bomitem_booitem_seq_id), wo_startdate) ELSE wo_startdate END AS duedate, roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id), (bomitem_qtyfxd + bomitem_qtyper * wo_qtyord) * (1 + bomitem_scrap)) AS qtyreq, CASE WHEN ( (item_type='M') AND (bomitem_issuewo) ) THEN TRUE WHEN (cs.itemsite_costmethod='J') THEN TRUE ELSE FALSE END AS issuewo, CASE WHEN (cohead_id IS NULL) THEN item_listprice ELSE (SELECT itemprice_price FROM itemIpsPrice(item_id, cohead_cust_id, cohead_shipto_id, roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id), (bomitem_qtyfxd + bomitem_qtyper * wo_qtyord) * (1 + bomitem_scrap)), bomitem_uom_id, bomitem_uom_id, cohead_curr_id, CURRENT_DATE, CURRENT_DATE, cohead_warehous_id) LIMIT 1) END AS price FROM wo JOIN itemsite ps ON (ps.itemsite_id=wo_itemsite_id) JOIN bomitem ON (bomitem_parent_item_id=ps.itemsite_item_id AND bomitem_rev_id=wo_bom_rev_id AND woEffectiveDate(wo_startdate) BETWEEN bomitem_effective and (bomitem_expires - 1)) JOIN itemsite cs ON (cs.itemsite_item_id=bomitem_item_id AND cs.itemsite_warehous_id=ps.itemsite_warehous_id) JOIN item ON (item_id=cs.itemsite_item_id) LEFT OUTER JOIN coitem ON (wo_ordtype='S' AND wo_ordid=coitem_id) LEFT OUTER JOIN cohead ON (cohead_id=coitem_cohead_id) WHERE ( (wo_id=pWoid) AND ((bomitem_char_id IS NULL) OR EXISTS ( SELECT charass_id FROM coitem,charass WHERE ((charass_target_type='SI') AND (charass_target_id=coitem_id) AND (charass_char_id=bomitem_char_id) AND (charass_value=bomitem_value) AND (wo_ordtype='S') AND (coitem_id=wo_ordid)))) ) ) AS data; -- Update any created P/R's the have the project id as the parent WO. UPDATE pr SET pr_prj_id=wo_prj_id FROM womatl, wo WHERE ((wo_id=pWoid) AND (womatl_wo_id=wo_id) AND (pr_order_type='W') AND (pr_order_id=womatl_id)); -- If the parent Item is a Breeder, create the brddist -- records for the Co-Products and By-Products IF (_bbom) THEN INSERT INTO xtmfg.brddist ( brddist_wo_id, brddist_wo_qty, brddist_itemsite_id, brddist_stdqtyper, brddist_qty, brddist_posted ) SELECT wo_id, 0, cs.itemsite_id, bbomitem_qtyper, 0, FALSE FROM wo, xtmfg.bbomitem, itemsite AS ps, itemsite AS cs, item WHERE ( (bbomitem_parent_item_id=ps.itemsite_item_id) AND (wo_itemsite_id=ps.itemsite_id) AND (ps.itemsite_item_id=item_id) AND (item_type='B') AND (bbomitem_item_id=cs.itemsite_item_id) AND (cs.itemsite_warehous_id=ps.itemsite_warehous_id) AND (wo_id=pWoid) ); END IF; -- Insert the W/O Operations if routings enabled IF ( ( SELECT (metric_value='t') FROM metric WHERE (metric_name='Routings') ) ) THEN INSERT INTO xtmfg.wooper ( wooper_wo_id, wooper_booitem_id, wooper_seqnumber, wooper_wrkcnt_id, wooper_stdopn_id, wooper_descrip1, wooper_descrip2, wooper_toolref, wooper_sutime, wooper_sucosttype, wooper_surpt, wooper_rntime, wooper_rncosttype, wooper_rnrpt, wooper_rnqtyper, wooper_produom, wooper_invproduomratio, wooper_issuecomp, wooper_rcvinv, wooper_suconsumed, wooper_sucomplete, wooper_rnconsumed, wooper_rncomplete, wooper_qtyrcv, wooper_instruc, wooper_scheduled, wooper_wip_location_id, wooper_price, wooper_opntype_id ) SELECT wo_id, booitem_id, booitem_seqnumber, booitem_wrkcnt_id, booitem_stdopn_id, booitem_descrip1, booitem_descrip2, booitem_toolref, CASE WHEN (booitem_surpt) THEN booitem_sutime ELSE 0 END, booitem_sucosttype, booitem_surpt, CASE WHEN ((booitem_rnqtyper = 0) OR (booitem_invproduomratio = 0)) THEN 0 WHEN (NOT booitem_rnrpt) THEN 0 ELSE ( ( booitem_rntime / booitem_rnqtyper * booitem_invproduomratio ) * wo_qtyord ) END, booitem_rncosttype, booitem_rnrpt, CASE WHEN (booitem_rnqtyper = 0) THEN 0 WHEN (NOT booitem_rnrpt) THEN 0 ELSE (booitem_rntime / booitem_rnqtyper) END, booitem_produom, booitem_invproduomratio, booitem_issuecomp, booitem_rcvinv, 0::NUMERIC, FALSE, 0::NUMERIC, FALSE, 0::NUMERIC, booitem_instruc, calculatenextworkingdate(itemsite_warehous_id,wo_startdate,booitem_execday-1), booitem_wip_location_id, (xtmfg.directlaborcostoper(booitem_id) + xtmfg.overheadcostoper(booitem_id) + xtmfg.machineoverheadcostoper(booitem_id)), booitem_opntype_id FROM xtmfg.booitem, wo, itemsite WHERE ((wo_itemsite_id=itemsite_id) AND (itemsite_item_id=booitem_item_id) AND (booitem_rev_id=wo_boo_rev_id) AND (woEffectiveDate(wo_startdate) BETWEEN booitem_effective AND (booitem_expires - 1)) AND (wo_id=pWoid)); -- Update womatls item to link to wooper items when the respective -- bomitem record indicates a booitem issue link. UPDATE womatl SET womatl_wooper_id=wooper_id FROM wo,xtmfg.wooper,xtmfg.booitem WHERE ((womatl_wooper_id=booitem_seq_id) AND (wooper_booitem_id=booitem_id) AND (womatl_wo_id=wo_id) AND (wooper_wo_id=wo_id) AND (wo_boo_rev_id=booitem_rev_id) AND (wo_id=pWoid)); END IF; -- Handle all of the Phantom material requirements WHILE ( ( SELECT COUNT(*) FROM womatl, itemsite, item WHERE ( (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (womatl_wo_id=pWoid) AND (item_type='F') ) ) > 0 ) LOOP FOR _p IN SELECT wo_qtyord, wo_startdate, womatl_id, womatl_wooper_id FROM wo, womatl, itemsite, item WHERE ( (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_type='F') AND (womatl_wo_id=wo_id) AND (wo_id=pWoid) ) LOOP INSERT INTO womatl ( womatl_wo_id, womatl_itemsite_id, womatl_wooper_id, womatl_schedatwooper, womatl_duedate, womatl_uom_id, womatl_qtyfxd, womatl_qtyper, womatl_scrap, womatl_qtyreq, womatl_qtyiss, womatl_qtywipscrap, womatl_lastissue, womatl_lastreturn, womatl_cost, womatl_picklist, womatl_createwo, womatl_issuewo, womatl_issuemethod, womatl_notes, womatl_ref ) SELECT pWoid, cs.itemsite_id, _p.womatl_wooper_id, womatl_schedatwooper, womatl_duedate, bomitem_uom_id, bomitem_qtyfxd, (bomitem_qtyper * womatl_qtyper), bomitem_scrap, roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id), (bomitem_qtyfxd + _p.wo_qtyord * bomitem_qtyper * womatl_qtyper) * (1 + bomitem_scrap)), 0, 0, startOfTime(), startOfTime(), 0, ci.item_picklist, ( (ci.item_type='M') AND (bomitem_createwo) ), ( (ci.item_type='M') AND (bomitem_issuewo) ), bomitem_issuemethod, bomitem_notes, bomitem_ref FROM womatl JOIN wo ON (wo_id=womatl_wo_id) JOIN itemsite ps ON (ps.itemsite_id=womatl_itemsite_id) JOIN item pi ON (pi.item_id=ps.itemsite_item_id) JOIN bomitem ON ( (bomitem_parent_item_id=pi.item_id) AND (woEffectiveDate(_p.wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND (bomitem_rev_id=getActiveRevId('BOM', pi.item_id)) ) JOIN item ci ON (ci.item_id=bomitem.bomitem_item_id) JOIN itemsite cs ON ( (cs.itemsite_item_id=ci.item_id) AND (cs.itemsite_warehous_id=ps.itemsite_warehous_id) ) WHERE (womatl_id=_p.womatl_id); DELETE FROM womatl WHERE (womatl_id=_p.womatl_id); END LOOP; END LOOP; -- Create W/Os for manufactured component items FOR newWo IN SELECT wo_number, nextWoSubnumber(wo_number) AS nextSubnumber, itemsite_id, itemsite_leadtime, womatl_duedate, womatl_wo_id, womatl_qtyreq, womatl_uom_id, wo_prj_id, item_id, item_inv_uom_id, womatl_id FROM womatl, wo, itemsite, item WHERE ( (womatl_wo_id=wo_id) AND (womatl_itemsite_id=itemsite_id) AND (womatl_createwo) AND (itemsite_wosupply) AND (itemsite_item_id=item_id) AND (wo_id=pWoid) ) ORDER BY womatl_id LOOP SELECT createWo( newWo.wo_number, newWo.itemsite_id, 1, itemuomtouom(newWo.item_id,newWo.womatl_uom_id,newWo.item_inv_uom_id,newWo.womatl_qtyreq), newWo.itemsite_leadtime, newWo.womatl_duedate, '', 'W', newWo.womatl_wo_id, newWo.wo_prj_id ) INTO _newwoid; UPDATE wo SET wo_womatl_id = newWo.womatl_id WHERE wo_id=_newwoid; END LOOP; UPDATE wo SET wo_status='E', wo_adhoc=FALSE WHERE (wo_id=pWoid); IF (pExplodeChildren) THEN SELECT MAX(explodeWo(wo_id, TRUE)) INTO resultCode FROM wo WHERE ( (wo_ordtype='W') AND (wo_ordid=pWoid) ); END IF; RETURN pWoid; END; $_$; 2DROP FUNCTION public.explodewo(integer, boolean); publicadminfalse84623125578427explodewoeffective()FUNCTIONhCREATE FUNCTION explodewoeffective() RETURNS text LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _value TEXT; BEGIN SELECT metric_value INTO _value FROM metric WHERE (metric_name='ExplodeWOEffective'); RETURN _value; END; $$; +DROP FUNCTION public.explodewoeffective(); publicadminfalse84623125578428fetchapmemonumber()FUNCTIONCREATE FUNCTION fetchapmemonumber() RETURNS integer LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('APMemoNumber')::INTEGER; $$; *DROP FUNCTION public.fetchapmemonumber(); publicadminfalse8125578429fetcharmemonumber()FUNCTIONCREATE FUNCTION fetcharmemonumber() RETURNS text LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('ARMemoNumber'); $$; *DROP FUNCTION public.fetcharmemonumber(); publicadminfalse8125578430fetchcashrcptnumber()FUNCTIONCREATE FUNCTION fetchcashrcptnumber() RETURNS text LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('CashRcptNumber'); $$; ,DROP FUNCTION public.fetchcashrcptnumber(); publicadminfalse8125578431fetchcmnumber()FUNCTIONCREATE FUNCTION fetchcmnumber() RETURNS text LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('CmNumber'); $$; &DROP FUNCTION public.fetchcmnumber(); publicadminfalse8125578432fetchcrmaccountnumber()FUNCTIONCREATE FUNCTION fetchcrmaccountnumber() RETURNS integer LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('CRMAccountNumber')::INTEGER; $$; .DROP FUNCTION public.fetchcrmaccountnumber(); publicadminfalse8125578433fetchdefaultfob(integer)FUNCTION%CREATE FUNCTION fetchdefaultfob(pwarehousid integer) RETURNS text LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT warehous_fob FROM whsinfo WHERE (warehous_id=$1); $_$; ;DROP FUNCTION public.fetchdefaultfob(pwarehousid integer); publicadminfalse8125578434fetchdefaultshipvia()FUNCTIONCREATE FUNCTION fetchdefaultshipvia() RETURNS text LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal TEXT; BEGIN SELECT shipvia_code INTO _returnVal FROM shipvia WHERE shipvia_id= (SELECT CAST(metric_value AS integer) FROM metric WHERE metric_name = 'DefaultShipViaId'); RETURN _returnVal; END; $$; ,DROP FUNCTION public.fetchdefaultshipvia(); publicadminfalse46238125578435fetchglsequence()FUNCTIONQCREATE FUNCTION fetchglsequence() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _sequence INTEGER; BEGIN SELECT NEXTVAL('gltrans_sequence_seq') INTO _sequence; RETURN _sequence; END; $$; (DROP FUNCTION public.fetchglsequence(); publicadminfalse46238125578436fetchincidentnumber()FUNCTION CREATE FUNCTION fetchincidentnumber() RETURNS integer LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('IncidentNumber')::integer; $$; ,DROP FUNCTION public.fetchincidentnumber(); publicadminfalse8125578437fetchinvcnumber()FUNCTIONCREATE FUNCTION fetchinvcnumber() RETURNS integer LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('InvcNumber')::integer; $$; (DROP FUNCTION public.fetchinvcnumber(); publicadminfalse8125578438fetchitemuomconvtypes(integer)FUNCTION~CREATE FUNCTION fetchitemuomconvtypes(integer) RETURNS text[] LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemUomConvId ALIAS FOR $1; _p RECORD; _result text[]; _cnt INTEGER; BEGIN _cnt := 0; FOR _p IN SELECT uomtype_name FROM itemuomconv, itemuom, uomtype WHERE ((itemuomconv_id=pItemUomConvId) AND (itemuomconv_id=itemuom_itemuomconv_id) AND (itemuom_uomtype_id=uomtype_id)) LOOP _result[_cnt] := _p.uomtype_name; _cnt := _cnt + 1; END LOOP; RETURN _result; END; $_$; 5DROP FUNCTION public.fetchitemuomconvtypes(integer); publicadminfalse46238125578439fetchjournalnumber(text)FUNCTIONCREATE FUNCTION fetchjournalnumber(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUse ALIAS FOR $1; _number INTEGER; BEGIN SELECT nextval('journal_number_seq') INTO _number; INSERT INTO jrnluse (jrnluse_date, jrnluse_number, jrnluse_use) VALUES (CURRENT_TIMESTAMP, _number, pUse); RETURN _number; END; $_$; /DROP FUNCTION public.fetchjournalnumber(text); publicadminfalse46238125578440fetchmetricbool(text)FUNCTIONCREATE FUNCTION fetchmetricbool(text) RETURNS boolean LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _pMetricName ALIAS FOR $1; _returnVal BOOLEAN; BEGIN SELECT CASE WHEN MIN(metric_value) = 't' THEN true ELSE false END INTO _returnVal FROM metric WHERE metric_name = _pMetricName; RETURN _returnVal; END; $_$; ,DROP FUNCTION public.fetchmetricbool(text); publicadminfalse46238125578441fetchmetrictext(text)FUNCTIONCREATE FUNCTION fetchmetrictext(text) RETURNS text LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _pMetricName ALIAS FOR $1; _returnVal TEXT; BEGIN SELECT metric_value::TEXT INTO _returnVal FROM metric WHERE metric_name = _pMetricName; RETURN _returnVal; END; $_$; ,DROP FUNCTION public.fetchmetrictext(text); publicadminfalse46238125578442fetchmetricvalue(text)FUNCTIONCREATE FUNCTION fetchmetricvalue(text) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _pMetricName ALIAS FOR $1; _returnVal INTEGER; BEGIN SELECT CASE WHEN (isNumeric(metric_value)) THEN metric_value::INTEGER ELSE NULL END INTO _returnVal FROM metric WHERE metric_name = _pMetricName; RETURN _returnVal; END; $_$; -DROP FUNCTION public.fetchmetricvalue(text); publicadminfalse46238125578443fetchnextchecknumber(integer)FUNCTIONhCREATE FUNCTION fetchnextchecknumber(pbankaccntid integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBankaccntid ALIAS FOR $1; _nextChkNumber INTEGER; _checkheadid INTEGER; BEGIN SELECT bankaccnt_nextchknum INTO _nextChkNumber FROM bankaccnt WHERE (bankaccnt_id=pBankaccntid); WHILE (TRUE) LOOP SELECT checkhead_id INTO _checkheadid FROM checkhead WHERE (checkhead_number=_nextChkNumber) AND (checkhead_bankaccnt_id=pBankaccntid); IF (NOT FOUND) THEN EXIT; ELSE _nextChkNumber := _nextChkNumber + 1; END IF; END LOOP; UPDATE bankaccnt SET bankaccnt_nextchknum = (bankaccnt_nextchknum + 1) WHERE (bankaccnt_id=pBankaccntid); RETURN _nextChkNumber; END; $_$; ADROP FUNCTION public.fetchnextchecknumber(pbankaccntid integer); publicadminfalse84623125578444fetchnextnumber(text)FUNCTIONCREATE FUNCTION fetchnextnumber(text) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE psequence ALIAS FOR $1; _number TEXT; _numcol TEXT; _select TEXT; _table TEXT; _test TEXT; _nextnum INTEGER; _seqiss seqiss; __seqiss seqiss[]; _not_issued BOOLEAN; BEGIN SELECT CAST(orderseq_number AS text), orderseq_number, orderseq_table, orderseq_numcol, COALESCE(orderseq_seqiss, ARRAY[]::seqiss[]) INTO _number, _nextnum, _table, _numcol, __seqiss FROM orderseq WHERE (orderseq_name=psequence) FOR UPDATE; IF (NOT FOUND) THEN RAISE EXCEPTION 'Invalid orderseq_name %', psequence; END IF; LOOP _seqiss := (_nextnum, now()); SELECT count(*) = 0 INTO _not_issued FROM (SELECT UNNEST(__seqiss) AS issued) data WHERE (issued).seqiss_number = _nextnum; _nextnum := _nextnum + 1; -- Test if the number has been issued, but not committed IF (_not_issued) THEN -- Test if the number has been committed -- Have to factor in scenario where Quotes are set to use SO Numbering IF (psequence = 'SoNumber' AND fetchmetrictext('QUNumberGeneration') = 'S') THEN _select := 'SELECT ' || quote_ident(_numcol) || ' FROM ' || _table || ' WHERE (' || quote_ident(_numcol) || '=' || quote_literal(_number) || ') ' || ' UNION SELECT quhead_number FROM quhead WHERE (quhead_number = ' || quote_literal(_number) || ');'; ELSE _select := 'SELECT ' || quote_ident(_numcol) || ' FROM ' || _table || ' WHERE (' || quote_ident(_numcol) || '=' || quote_literal(_number) || ');'; END IF; EXECUTE _select INTO _test; IF (_test IS NULL OR NOT FOUND) THEN EXIT; END IF; END IF; -- Number in use, try again _number = _nextnum::text; END LOOP; UPDATE orderseq SET orderseq_number = _nextnum WHERE (orderseq_name=psequence); IF (fetchMetricBool('EnableGaplessNumbering')) THEN UPDATE orderseq SET orderseq_seqiss = orderseq_seqiss || _seqiss WHERE (orderseq_name=psequence); END IF; RETURN _number; END; $_$; ,DROP FUNCTION public.fetchnextnumber(text); publicadminfalse46238125578445fetchponumber()FUNCTIONCREATE FUNCTION fetchponumber() RETURNS text LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('PoNumber'); $$; &DROP FUNCTION public.fetchponumber(); publicadminfalse8125578446fetchprefwarehousid()FUNCTIONCREATE FUNCTION fetchprefwarehousid() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _result INTEGER; BEGIN SELECT CAST(usrpref_value AS INTEGER) INTO _result FROM usrpref WHERE ((usrpref_username=getEffectiveXtUser()) AND (usrpref_name='PreferredWarehouse')); RETURN _result; END; $$; ,DROP FUNCTION public.fetchprefwarehousid(); publicadminfalse84623125578447fetchprnumber()FUNCTIONCREATE FUNCTION fetchprnumber() RETURNS integer LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('PrNumber')::INTEGER; $$; &DROP FUNCTION public.fetchprnumber(); publicadminfalse8125578448fetchqunumber()FUNCTIONCREATE FUNCTION fetchqunumber() RETURNS text LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('QuNumber'); $$; &DROP FUNCTION public.fetchqunumber(); publicadminfalse8125578449fetchshipmentnumber()FUNCTIONCREATE FUNCTION fetchshipmentnumber() RETURNS text LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _number TEXT; _test INTEGER; BEGIN LOOP SELECT CAST(nextval('shipment_number_seq') AS TEXT) INTO _number; SELECT shiphead_id INTO _test FROM shiphead WHERE (shiphead_number=_number); IF (NOT FOUND) THEN EXIT; END IF; END LOOP; RETURN _number; END; $$; ,DROP FUNCTION public.fetchshipmentnumber(); publicadminfalse46238125578450fetchsonumber()FUNCTIONCREATE FUNCTION fetchsonumber() RETURNS text LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('SoNumber'); $$; &DROP FUNCTION public.fetchsonumber(); publicadminfalse8125578451fetchtonumber()FUNCTIONCREATE FUNCTION fetchtonumber() RETURNS text LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('ToNumber'); $$; &DROP FUNCTION public.fetchtonumber(); publicadminfalse8125578452fetchusrprefbool(text)FUNCTION CREATE FUNCTION fetchusrprefbool(text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _pPrefName ALIAS FOR $1; _returnVal BOOLEAN; BEGIN SELECT CASE WHEN MIN(usrpref_value) = 't' THEN true ELSE false END INTO _returnVal FROM usrpref WHERE ( (usrpref_username=getEffectiveXtUser()) AND (usrpref_name=_pPrefName) ); RETURN _returnVal; END; $_$; -DROP FUNCTION public.fetchusrprefbool(text); publicadminfalse46238125578453fetchvonumber()FUNCTIONCREATE FUNCTION fetchvonumber() RETURNS integer LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('VcNumber')::INTEGER; $$; &DROP FUNCTION public.fetchvonumber(); publicadminfalse8125578454fetchwonumber()FUNCTIONCREATE FUNCTION fetchwonumber() RETURNS integer LANGUAGE sql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT fetchNextNumber('WoNumber')::INTEGER; $$; &DROP FUNCTION public.fetchwonumber(); publicadminfalse8125578455*financialreport(integer, integer, integer)FUNCTIONCREATE FUNCTION financialreport(integer, integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlheadid ALIAS FOR $1; pPeriodid ALIAS FOR $2; pPrjid ALIAS FOR $3; _result bool; BEGIN SELECT financialreport(pFlheadid,pPeriodid,'M', pPrjid) INTO _result; RETURN _result; END; $_$; ADROP FUNCTION public.financialreport(integer, integer, integer); publicadminfalse462381255784565financialreport(integer, integer, character, integer)FUNCTIONk'CREATE FUNCTION financialreport(integer, integer, character, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. /* performance vs. history: versions prior to xTuple ERP 4.5.x (x ?= 1) used public.flrpt to build financial reports. after that release, the function creates a temporary table if necessary. with the temp table, flrpt self-joins no longer require comparing flrpt_username - temp tables are only visible within the current session. however, there are subsidiary functions (eg insertflgroup) that _do_ join on flrpt_username. in addition, flrpt_username has a not-null constraint. to reduce the risk of breakage, this function still sets flrpt_username. */ DECLARE pFlheadid ALIAS FOR $1; pPeriodid ALIAS FOR $2; pInterval ALIAS FOR $3; pPrjid ALIAS FOR $4; _r RECORD; _t RECORD; _s RECORD; _username TEXT := getEffectiveXtUser(); BEGIN -- Validate Interval IF pInterval <> 'M' AND pInterval <> 'Q' AND pInterval <> 'Y' THEN RAISE EXCEPTION 'Invalid Interval --> %', pInterval; END IF; CREATE TEMPORARY TABLE IF NOT EXISTS flrpt (LIKE public.flrpt INCLUDING ALL) ON COMMIT PRESERVE ROWS; -- clear even temp tables because every run builds on data upserted by itself DELETE FROM flrpt WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodId) AND (flrpt_interval=pInterval)); -- Find out if we need to show a Grand Total and which if any of the values -- we want to show in that grand total. SELECT flhead_showtotal, CASE WHEN(flhead_showstart) THEN 0.00 ELSE NULL END AS beginning, CASE WHEN(flhead_showend) THEN 0.00 ELSE NULL END AS ending, CASE WHEN(flhead_showdelta) THEN 0.00 ELSE NULL END AS debits, CASE WHEN(flhead_showdelta) THEN 0.00 ELSE NULL END AS credits, CASE WHEN(flhead_showbudget) THEN 0.00 ELSE NULL END AS budget, CASE WHEN(flhead_showdiff) THEN 0.00 ELSE NULL END AS diff, CASE WHEN(flhead_showcustom) THEN 0.00 ELSE NULL END AS custom, CASE WHEN(flhead_usealttotal) THEN flhead_alttotal ELSE NULL END AS altname INTO _r FROM flhead WHERE (flhead_id=pFlheadid); IF (NOT FOUND) THEN return FALSE; END IF; -- If showing a Grand Total then create a record as a Group which acts -- as a parent to the whole report. This allows the code to update as -- it would for normal group total values. IF (_r.flhead_showtotal) THEN INSERT INTO flrpt (flrpt_flhead_id, flrpt_period_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_beginning, flrpt_ending, flrpt_debits, flrpt_credits, flrpt_budget, flrpt_diff, flrpt_custom, flrpt_altname, flrpt_interval ) VALUES (pFlheadid, pPeriodid, _username, 0, -1, 'G', -1, _r.beginning, _r.ending, _r.debits, _r.credits, _r.budget, _r.diff, _r.custom, _r.altname, pInterval ); END IF; PERFORM insertFlGroup(pFlheadid, pPeriodid, -1, 0, FALSE, pInterval, pPrjid); -- go through the list of records that need percentages calculated and perform -- those calculations. FOR _t IN SELECT flrpt_order, CASE WHEN(flgrp_prcnt_flgrp_id = -1) THEN flgrp_flgrp_id ELSE flgrp_prcnt_flgrp_id END AS flgrp_id FROM flrpt, flgrp WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) AND (flrpt_type='G') AND (flrpt_type_id=flgrp_id)) UNION SELECT flrpt_order, CASE WHEN(flitem_prcnt_flgrp_id = -1) THEN flitem_flgrp_id ELSE flitem_prcnt_flgrp_id END AS flgrp_id FROM flrpt, flitem WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) AND (flrpt_type='I') AND (flrpt_type_id=flitem_id)) UNION SELECT flrpt_order, CASE WHEN(flspec_prcnt_flgrp_id = -1) THEN flspec_flgrp_id ELSE flspec_prcnt_flgrp_id END AS flgrp_id FROM flrpt, flspec WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) AND (flrpt_type='S') AND (flrpt_type_id=flspec_id)) LOOP IF( (_t.flgrp_id=-1) OR (NOT (SELECT flgrp_summarize FROM flgrp WHERE flgrp_id=_t.flgrp_id)) ) THEN SELECT COALESCE(SUM(flrpt_beginning),0) AS beginningTotal, COALESCE(SUM(flrpt_ending),0) AS endingTotal, COALESCE(SUM(flrpt_debits),0) AS debitsTotal, COALESCE(SUM(flrpt_credits),0) AS creditsTotal, COALESCE(SUM(flrpt_budget),0) AS budgetTotal, COALESCE(SUM(flrpt_diff), 0) AS diffTotal, COALESCE(SUM(flrpt_custom), 0) AS customTotal INTO _s FROM flrpt WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) AND (flrpt_type != 'T') AND (flrpt_parent_id=_t.flgrp_id)); ELSE SELECT COALESCE(SUM(flrpt_beginning),0) AS beginningTotal, COALESCE(SUM(flrpt_ending),0) AS endingTotal, COALESCE(SUM(flrpt_debits),0) AS debitsTotal, COALESCE(SUM(flrpt_credits),0) AS creditsTotal, COALESCE(SUM(flrpt_budget),0) AS budgetTotal, COALESCE(SUM(flrpt_diff), 0) AS diffTotal, COALESCE(SUM(flrpt_custom), 0) AS customTotal INTO _s FROM flrpt WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) AND (flrpt_type = 'G') AND (flrpt_type_id=_t.flgrp_id)); END IF; UPDATE flrpt SET flrpt_beginningprcnt = flrpt_beginningprcnt + flrpt_beginning / CASE WHEN (_s.beginningTotal=0) THEN 1 ELSE _s.beginningTotal END, flrpt_endingprcnt = flrpt_endingprcnt + flrpt_ending / CASE WHEN (_s.endingTotal=0) THEN 1 ELSE _s.endingTotal END, flrpt_debitsprcnt = flrpt_debitsprcnt + flrpt_debits / CASE WHEN (_s.debitsTotal=0) THEN 1 ELSE _s.debitsTotal END, flrpt_creditsprcnt = flrpt_creditsprcnt + flrpt_credits / CASE WHEN (_s.creditsTotal=0) THEN 1 ELSE _s.creditsTotal END, flrpt_budgetprcnt = flrpt_budgetprcnt + flrpt_budget / CASE WHEN (_s.budgetTotal=0) THEN 1 ELSE _s.budgetTotal END, flrpt_diffprcnt = flrpt_diffprcnt + flrpt_diff / CASE WHEN (_s.diffTotal=0) THEN 1 ELSE _s.diffTotal END, flrpt_customprcnt = flrpt_customprcnt + flrpt_custom / CASE WHEN (_s.customTotal=0) THEN 1 ELSE _s.customTotal END WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) AND (flrpt_order=_t.flrpt_order)); END LOOP; -- Update any subtotal records to reflect the percentage values of the parents -- since those are calculated after the subtotal records were created. FOR _t IN SELECT a.flrpt_order AS flrpt_order, b.flrpt_beginningprcnt AS flrpt_beginningprcnt, b.flrpt_endingprcnt AS flrpt_endingprcnt, b.flrpt_debitsprcnt AS flrpt_debitsprcnt, b.flrpt_creditsprcnt AS flrpt_creditsprcnt, b.flrpt_budgetprcnt AS flrpt_budgetprcnt, b.flrpt_diffprcnt AS flrpt_diffprcnt, b.flrpt_customprcnt AS flrpt_customprcnt FROM flrpt AS a, flrpt AS b WHERE ((a.flrpt_flhead_id=pFlheadid) AND (a.flrpt_period_id=pPeriodid) AND (a.flrpt_interval=pInterval) AND (a.flrpt_type='T') AND (b.flrpt_flhead_id=a.flrpt_flhead_id) AND (b.flrpt_period_id=a.flrpt_period_id) AND (b.flrpt_interval=pInterval) AND (b.flrpt_type='G') AND (b.flrpt_type_id=a.flrpt_parent_id)) LOOP UPDATE flrpt SET flrpt_beginningprcnt=flrpt_beginningprcnt + _t.flrpt_beginningprcnt, flrpt_endingprcnt=flrpt_endingprcnt + _t.flrpt_endingprcnt, flrpt_debitsprcnt=flrpt_debitsprcnt + _t.flrpt_debitsprcnt, flrpt_creditsprcnt=flrpt_creditsprcnt + _t.flrpt_creditsprcnt, flrpt_budgetprcnt=flrpt_budgetprcnt + _t.flrpt_budgetprcnt, flrpt_diffprcnt=flrpt_diffprcnt + _t.flrpt_diffprcnt, flrpt_customprcnt=flrpt_customprcnt + _t.flrpt_customprcnt WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) AND (flrpt_order=_t.flrpt_order)); END LOOP; -- If showing a Grand total then move the record we created early to the -- end of the report and marked as a Total record. IF (_r.flhead_showtotal) THEN UPDATE flrpt SET flrpt_order = COALESCE((SELECT MAX(flrpt_order) FROM flrpt WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) ) ), 0) + 1, flrpt_level = 0, flrpt_type = 'T' WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) AND (flrpt_order=0) AND (flrpt_level = -1) AND (flrpt_type = 'G') AND (flrpt_type_id=-1)); END IF; return TRUE; END; $_$; LDROP FUNCTION public.financialreport(integer, integer, character, integer); publicadminfalse46238125578458@financialreport(integer, integer[], character, boolean, integer)FUNCTION CREATE FUNCTION financialreport(integer, integer[], character, boolean, integer) RETURNS SETOF fltrenditem LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlheadId ALIAS FOR $1; pPeriodIds ALIAS FOR $2; pInterval ALIAS FOR $3; pShowNumbers ALIAS FOR $4; pPrjid ALIAS FOR $5; _row fltrenditem%ROWTYPE; _type CHAR; _p RECORD; _count INTEGER; _n NUMERIC; _fld NUMERIC[]; _grndttl NUMERIC; _i INTEGER; _first BOOLEAN; _prevlevel INTEGER; _subgrp INTEGER; BEGIN _first := true; _subgrp := 0; IF ARRAY_UPPER(pPeriodIds,1) <= 12 THEN _count := ARRAY_UPPER(pPeriodIds,1); ELSE _count := 12; END IF; --Get Type SELECT flhead_type FROM flhead INTO _type WHERE flhead_id=pFlheadId; --Build Financial Data FOR _i IN 1.._count LOOP PERFORM financialreport(pFlheadId,pPeriodIds[_i],pInterval,pPrjid); END LOOP; --Get Row Data FOR _p IN SELECT flrpt_flhead_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_parent_id, flrpt_accnt_id, formatindent(flgrp.flgrp_name,flrpt.flrpt_level) AS flrpt_name, CASE WHEN (flgrp_summarize AND (_type IN ('I','C'))) THEN (COALESCE(flrpt_diff,0)) WHEN (flgrp_summarize AND (_type = 'B')) THEN (COALESCE(flrpt_ending,0)) ELSE NULL END AS f_fld1, flgrp_summarize AS display FROM flrpt,flgrp WHERE ((flrpt_flhead_id=pFlheadId) AND (flgrp_id=flrpt_type_id) AND (flrpt_type='G') AND (flrpt_period_id=pPeriodIds[1]) AND (flrpt_interval=pInterval) ) UNION SELECT flrpt_flhead_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_parent_id, flrpt_accnt_id, formatindent(accnt_descrip,flrpt.flrpt_level) AS flrpt_name, CASE WHEN (_type IN ('I','C')) THEN (COALESCE(flrpt_diff,0)) WHEN (_type = 'B') THEN (COALESCE(flrpt_ending,0)) ELSE NULL END AS f_fld1, true AS display FROM flrpt,flitem,accnt WHERE ((flrpt_flhead_id=pFlheadId) AND (flrpt_accnt_id=accnt_id) AND (flitem_id=flrpt_type_id) AND (flrpt_type='I') AND (flrpt_period_id=pPeriodIds[1]) AND (flrpt_interval=pInterval) ) UNION SELECT flrpt_flhead_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_parent_id, flrpt_accnt_id, CASE WHEN (flrpt.flrpt_type='T' AND flrpt.flrpt_level=0) THEN COALESCE(flrpt.flrpt_altname, 'Total') WHEN (flrpt.flrpt_type='T') THEN formatindent(COALESCE(flrpt.flrpt_altname, 'Subtotal') ,flrpt.flrpt_level) ELSE formatindent(('Type ' || flrpt.flrpt_type || ' ' || text(flrpt.flrpt_type_id)), flrpt.flrpt_level) END AS flstmtitem_name, CASE WHEN (_type IN ('I','C')) THEN (COALESCE(flrpt_diff,0)) WHEN (_type = 'B') THEN (COALESCE(flrpt_ending,0)) ELSE NULL END AS f_fld1, true AS display FROM flrpt WHERE ((flrpt_flhead_id=pFlheadId) AND (flrpt_type NOT IN ('I','S','G')) AND (flrpt_period_id=pPeriodIds[1]) AND (flrpt_interval=pInterval) ) ORDER BY flrpt_order LOOP IF _type IN ('I','C') THEN _grndttl := _p.f_fld1; END IF; --Loop through and calculate period column values IF (_p.display) THEN FOR _i IN 2.._count LOOP SELECT CASE WHEN (_type IN ('I','C')) THEN COALESCE(flrpt_diff,0) WHEN (_type = 'B') THEN COALESCE(flrpt_ending,0) ELSE NULL END INTO _n FROM flrpt WHERE ((flrpt_flhead_id=pFlheadId) AND (flrpt_period_id=pPeriodIds[_i]) AND (flrpt_interval=pInterval) AND (flrpt_order=_p.flrpt_order)); _fld[_i-1] := _n; IF _type IN ('I','C') THEN _grndttl := _grndttl+_n; END IF; END LOOP; END IF; --Send it all back to the caller IF _prevlevel > _p.flrpt_level THEN _subgrp := _subgrp+1; END IF; _prevlevel:=_p.flrpt_level; _row.fltrenditem_subgrp := _subgrp; IF NOT _first THEN RETURN NEXT _row; END IF; _first := FALSE; _row.fltrenditem_flhead_id := _p.flrpt_flhead_id; _row.fltrenditem_username := _p.flrpt_username; _row.fltrenditem_order := _p.flrpt_order; _row.fltrenditem_level := _p.flrpt_level; _row.fltrenditem_type := _p.flrpt_type; _row.fltrenditem_type_id := _p.flrpt_type_id; _row.fltrenditem_parent_id := _p.flrpt_parent_id; _row.fltrenditem_accnt_id := _p.flrpt_accnt_id; _row.fltrenditem_name := _p.flrpt_name; IF (_p.display) THEN _row.fltrenditem_fld1 := (_p.f_fld1); _row.fltrenditem_fld2 := (_fld[1]); _row.fltrenditem_fld3 := (_fld[2]); _row.fltrenditem_fld4 := (_fld[3]); _row.fltrenditem_fld5 := (_fld[4]); _row.fltrenditem_fld6 := (_fld[5]); _row.fltrenditem_fld7 := (_fld[6]); _row.fltrenditem_fld8 := (_fld[7]); _row.fltrenditem_fld9 := (_fld[8]); _row.fltrenditem_fld10 := (_fld[9]); _row.fltrenditem_fld11 := (_fld[10]); _row.fltrenditem_fld12 := (_fld[11]); _row.fltrenditem_grndttl := (_grndttl); ELSE _row.fltrenditem_fld1 := NULL; _row.fltrenditem_fld2 := NULL; _row.fltrenditem_fld3 := NULL; _row.fltrenditem_fld4 := NULL; _row.fltrenditem_fld5 := NULL; _row.fltrenditem_fld6 := NULL; _row.fltrenditem_fld7 := NULL; _row.fltrenditem_fld8 := NULL; _row.fltrenditem_fld9 := NULL; _row.fltrenditem_fld10 := NULL; _row.fltrenditem_fld11 := NULL; _row.fltrenditem_fld12 := NULL; _row.fltrenditem_grndttl := NULL; END IF; END LOOP; _row.fltrenditem_subgrp := _subgrp + 1; RETURN NEXT _row; END; $_$; WDROP FUNCTION public.financialreport(integer, integer[], character, boolean, integer); publicadminfalse827214623125587017<financialreport(integer, integer, boolean, boolean, integer)FUNCTIONeCREATE FUNCTION financialreport(integer, integer, boolean, boolean, integer) RETURNS SETOF flstmtitem LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- see "performance vs. history" in financialreport(integer,integer,bpchar,integer) DECLARE pFlcolid ALIAS FOR $1; pPeriodid ALIAS FOR $2; pShowNumbers ALIAS FOR $3; pIndentName ALIAS FOR $4; pPrjid ALIAS FOR $5; _row flstmtitem%ROWTYPE; _p RECORD; _x RECORD; _priorMoPeriodId INTEGER; _priorQtPeriodId INTEGER; _priorYrPeriodId INTEGER; _first BOOLEAN; _prevlevel INTEGER; _subgrp INTEGER; _qtrInterval TEXT; --_username TEXT := getEffectiveXtUser(); _yrInterval TEXT; BEGIN _priorMoPeriodId := -1; _priorQtPeriodId := -1; _priorYrPeriodId := -1; _first := TRUE; _prevlevel :=0; _subgrp := 0; --Get Layout Data SELECT flhead_id,flhead_type, flcol_month,flcol_quarter,flcol_year,flcol_priortype, flcol_priormonth,flcol_priorquarter,flcol_prioryear, flcol_priordiff,flcol_priordiffprcnt,flcol_priorprcnt, flcol_budget,flcol_budgetdiff,flcol_budgetdiffprcnt, flcol_budgetprcnt INTO _p FROM flhead,flcol WHERE ((flcol_id=pFlcolid) AND (flhead_id=flcol_flhead_id)); IF (_p.flhead_type='B') THEN _qtrInterval := 'M'; _yrInterval := 'M'; ELSE _qtrInterval := 'Q'; _yrInterval := 'Y'; END IF; CREATE TEMPORARY TABLE IF NOT EXISTS flrpt (LIKE public.flrpt INCLUDING ALL) ON COMMIT PRESERVE ROWS; -- clear even temp tables because every run builds on data upserted by itself DELETE FROM flrpt WHERE (flrpt_flhead_id=_p.flhead_id); --Populate report data... --...for Month IF (_p.flcol_month) THEN PERFORM financialreport(_p.flhead_id,pPeriodid,'M',pPrjid); IF ((_p.flcol_priortype = 'P') AND (_p.flcol_priormonth)) THEN SELECT COALESCE(pp.period_id,-1) INTO _priorMoPeriodId FROM period cp, period pp WHERE ((cp.period_id=pPeriodId) AND (cp.period_start > pp.period_start)) ORDER BY pp.period_start DESC LIMIT 1; IF (_priorMoPeriodId IS NOT NULL) THEN PERFORM financialreport(_p.flhead_id,_priorMoPeriodId,'M',pPrjid); END IF; ELSE IF ((_p.flcol_priortype='Y')AND (_p.flcol_priormonth)) THEN SELECT COALESCE(pp.period_id,-1) INTO _priorMoPeriodId FROM period cp, period pp WHERE ((cp.period_id=pPeriodId) AND (cp.period_id != pp.period_id) AND (cp.period_start > pp.period_start) AND (cp.period_number = pp.period_number)) ORDER BY pp.period_start DESC LIMIT 1; IF (_priorMoPeriodId IS NOT NULL) THEN PERFORM financialreport(_p.flhead_id,_priorMoPeriodId,'M',pPrjid); END IF; END IF; END IF; END IF; --...for Quarter IF (_p.flcol_quarter) THEN PERFORM financialreport(_p.flhead_id,pPeriodid,'Q',pPrjid); END IF; IF ((_p.flcol_priortype='P') AND (_p.flcol_priorquarter)) THEN SELECT COALESCE(pp.period_id,-1) INTO _priorQtPeriodId FROM period cp, period pp WHERE ((cp.period_id=pPeriodId) AND (cp.period_start > pp.period_start) AND (pp.period_quarter= CASE WHEN cp.period_quarter > 1 THEN cp.period_quarter - 1 ELSE 4 END) AND (pp.period_start >= cp.period_start - interval '1 year')) ORDER BY pp.period_start DESC LIMIT 1; IF (_priorQtPeriodId IS NOT NULL) THEN PERFORM financialreport(_p.flhead_id,_priorQtPeriodId,'Q',pPrjid); END IF; ELSE IF ((_p.flcol_priortype='Y')AND (_p.flcol_priorquarter)) THEN SELECT pp.period_id INTO _priorQtPeriodId FROM period cp, period pp, yearperiod cy, yearperiod py WHERE ((cp.period_id=pPeriodId) AND (cp.period_yearperiod_id=cy.yearperiod_id) AND (pp.period_yearperiod_id=py.yearperiod_id) AND (cp.period_quarter=pp.period_quarter) AND (cy.yearperiod_start > py.yearperiod_start)) ORDER BY py.yearperiod_start DESC, pp.period_start DESC LIMIT 1; IF (_priorQtPeriodId IS NOT NULL) THEN PERFORM financialreport(_p.flhead_id,_priorQtPeriodId,'Q',pPrjid); END IF; END IF; END IF; --...for Year IF (_p.flcol_year) THEN PERFORM financialreport(_p.flhead_id,pPeriodid,'Y',pPrjid); END IF; IF (_p.flcol_prioryear='D') THEN SELECT COALESCE(pp.period_id,-1) INTO _priorYrPeriodId FROM period cp, period pp WHERE ((cp.period_id = pPeriodId) AND (cp.period_number = pp.period_number) AND (cp.period_start > pp.period_start)) ORDER BY pp.period_start DESC LIMIT 1; IF (_priorYrPeriodId IS NOT NULL) THEN PERFORM financialreport(_p.flhead_id,_priorYrPeriodId,'Y',pPrjid); END IF; ELSE IF (_p.flcol_prioryear='F') THEN SELECT pp.period_id INTO _priorYrPeriodId FROM period cp, period pp, yearperiod cy, yearperiod py WHERE ((cp.period_id=pPeriodId) AND (cp.period_yearperiod_id=cy.yearperiod_id) AND (pp.period_yearperiod_id=py.yearperiod_id) AND (cy.yearperiod_start > py.yearperiod_start)) ORDER BY pp.period_start DESC LIMIT 1; IF (_priorYrPeriodId IS NOT NULL) THEN PERFORM financialreport(_p.flhead_id,_priorYrPeriodId,'Y',pPrjid); END IF; END IF; END IF; --Return the data FOR _x IN SELECT flrpt.flrpt_flhead_id AS flstmtitem_flhead_id, flrpt.flrpt_period_id AS flstmtitem_period_id, flrpt.flrpt_username AS flstmtitem_username, flrpt.flrpt_order AS flstmtitem_order, flrpt.flrpt_level AS flstmtitem_level, flrpt.flrpt_type AS flstmtitem_type, flrpt.flrpt_type_id AS flstmtitem_type_id, flrpt.flrpt_parent_id AS flstmtitem_parent_id, NULL AS flstmtitem_accnt_id, CASE WHEN (pIndentName) THEN formatindent(flgrp.flgrp_name,flrpt.flrpt_level) ELSE flgrp.flgrp_name END AS flstmtitem_name, CASE WHEN (flgrp_summarize AND (flhead_type IN ('I','C'))) THEN (COALESCE(flrptmo.flrpt_diff,0)) WHEN (flgrp_summarize AND (flhead_type = 'B')) THEN (COALESCE(flrptmo.flrpt_ending,0)) ELSE NULL END AS flstmtitem_month, CASE WHEN (flgrp_summarize) THEN (COALESCE(flrptmo.flrpt_debits,0)) ELSE NULL END AS flstmtitem_monthdb, CASE WHEN (flgrp_summarize) THEN (COALESCE(flrptmo.flrpt_credits,0)) ELSE NULL END AS flstmtitem_monthcr, CASE WHEN (flgrp_summarize AND flgrp_showdiffprcnt) THEN (COALESCE(flrptmo.flrpt_diffprcnt,0)) WHEN (flgrp_summarize AND flgrp_showendprcnt) THEN (COALESCE(flrptmo.flrpt_endingprcnt,0)) ELSE NULL END AS flstmtitem_monthprcnt, CASE WHEN (flgrp_summarize) THEN (flrptmo.flrpt_budget) ELSE NULL END AS flstmtitem_monthbudget, CASE WHEN (flgrp_summarize) THEN (flrptmo.flrpt_budgetprcnt) ELSE NULL END AS flstmtitem_monthbudgetprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE((flrptmo.flrpt_diff-flrptmo.flrpt_budget),0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE((flrptmo.flrpt_ending-flrptmo.flrpt_budget),0)) ELSE NULL END AS flstmtitem_monthbudgetdiff, CASE WHEN (flgrp_summarize AND (flhead_type IN ('I','C')) AND (flrptmo.flrpt_budget > 0)) THEN (COALESCE(((flrptmo.flrpt_diff-flrptmo.flrpt_budget)/flrptmo.flrpt_budget),0)) WHEN (flgrp_summarize AND (flhead_type='B') AND (flrptmo.flrpt_budget > 0)) THEN (COALESCE(((flrptmo.flrpt_ending-flrptmo.flrpt_budget)/flrptmo.flrpt_budget),0)) WHEN (flgrp_summarize AND (flrptmo.flrpt_budget = 0)) THEN NULL ELSE NULL END AS flstmtitem_monthbudgetdiffprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE(flrptqt.flrpt_diff,0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE(flrptqt.flrpt_ending,0)) ELSE NULL END AS flstmtitem_qtr, CASE WHEN (flgrp_summarize) THEN (COALESCE(flrptqt.flrpt_debits,0)) ELSE NULL END AS flstmtitem_qtrdb, CASE WHEN (flgrp_summarize) THEN (COALESCE(flrptqt.flrpt_credits,0)) ELSE NULL END AS flstmtitem_qtrcr, CASE WHEN (flgrp_summarize AND flgrp_showdiffprcnt) THEN (flrptqt.flrpt_diffprcnt) WHEN (flgrp_summarize AND flgrp_showendprcnt) THEN (flrptqt.flrpt_endingprcnt) ELSE NULL END AS flstmtitem_qtrprcnt, CASE WHEN (flgrp_summarize) THEN (COALESCE(flrptqt.flrpt_budget,0)) ELSE NULL END AS flstmtitem_qtrbudget, CASE WHEN (flgrp_summarize) THEN (flrptqt.flrpt_budgetprcnt) ELSE NULL END AS flstmtitem_qtrbudgetprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE((flrptqt.flrpt_diff-flrptqt.flrpt_budget),0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE((flrptqt.flrpt_ending-flrptqt.flrpt_budget),0)) ELSE NULL END AS flstmtitem_qtrbudgetdiff, CASE WHEN (flgrp_summarize AND (flhead_type IN ('I','C')) AND (flrptqt.flrpt_budget > 0)) THEN (COALESCE(((flrptqt.flrpt_diff-flrptqt.flrpt_budget)/flrptqt.flrpt_budget),0)) WHEN (flgrp_summarize AND (flhead_type='B') AND (flrptqt.flrpt_budget > 0)) THEN (COALESCE(((flrptqt.flrpt_ending-flrptqt.flrpt_budget)/flrptqt.flrpt_budget),0)) ELSE NULL END AS flstmtitem_qtrbudgetdiffprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE(flrptyr.flrpt_diff,0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE(flrptyr.flrpt_ending,0)) ELSE NULL END AS flstmtitem_year, CASE WHEN (flgrp_summarize) THEN (COALESCE(flrptyr.flrpt_debits,0)) ELSE NULL END AS flstmtitem_yeardb, CASE WHEN (flgrp_summarize) THEN (COALESCE(flrptyr.flrpt_credits,0)) ELSE NULL END AS flstmtitem_yearcr, CASE WHEN (flgrp_summarize AND flgrp_showdiffprcnt) THEN (COALESCE(flrptyr.flrpt_diffprcnt,0)) WHEN (flgrp_summarize AND flgrp_showendprcnt) THEN (COALESCE(flrptyr.flrpt_endingprcnt,0)) ELSE NULL END AS flstmtitem_yearprcnt, CASE WHEN (flgrp_summarize) THEN (flrptyr.flrpt_budget) ELSE NULL END AS flstmtitem_yearbudget, CASE WHEN (flgrp_summarize) THEN (flrptyr.flrpt_budgetprcnt) ELSE NULL END AS flstmtitem_yearbudgetprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE((flrptyr.flrpt_diff-flrptyr.flrpt_budget),0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE((flrptyr.flrpt_ending-flrptyr.flrpt_budget),0)) ELSE NULL END AS flstmtitem_yearbudgetdiff, CASE WHEN (flgrp_summarize AND (flhead_type IN ('I','C')) AND (flrptyr.flrpt_budget > 0)) THEN (COALESCE(((flrptyr.flrpt_diff-flrptyr.flrpt_budget)/flrptyr.flrpt_budget),0)) WHEN (flgrp_summarize AND (flhead_type = 'B') AND (flrptyr.flrpt_budget > 0)) THEN (COALESCE(((flrptyr.flrpt_ending-flrptyr.flrpt_budget)/flrptyr.flrpt_budget),0)) WHEN (flgrp_summarize AND (flrptyr.flrpt_budget = 0)) THEN NULL ELSE NULL END AS flstmtitem_yearbudgetdiffprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE(flrptprmo.flrpt_diff,0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE(flrptprmo.flrpt_ending,0)) ELSE NULL END AS flstmtitem_prmonth, CASE WHEN (flgrp_summarize AND flgrp_showdiffprcnt) THEN (flrptprmo.flrpt_diffprcnt) WHEN (flgrp_summarize AND flgrp_showendprcnt) THEN (flrptprmo.flrpt_endingprcnt) ELSE NULL END AS flstmtitem_prmonthprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE(flrptmo.flrpt_diff-flrptprmo.flrpt_diff,0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE(flrptmo.flrpt_ending-flrptprmo.flrpt_ending,0)) ELSE NULL END AS flstmtitem_prmonthdiff, CASE WHEN (flgrp_summarize AND (flhead_type IN ('I','C')) AND (flrptprmo.flrpt_diff > 0)) THEN (COALESCE((flrptmo.flrpt_diff-flrptprmo.flrpt_diff)/flrptprmo.flrpt_diff,0)) WHEN (flgrp_summarize AND (flhead_type = 'B') AND (flrptprmo.flrpt_ending > 0)) THEN (COALESCE((flrptmo.flrpt_ending-flrptprmo.flrpt_ending)/flrptprmo.flrpt_ending,0)) WHEN (flgrp_summarize AND (flrptprmo.flrpt_ending = 0)) THEN NULL ELSE NULL END AS flstmtitem_prmonthdiffprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE(flrptprqt.flrpt_diff,0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE(flrptprqt.flrpt_ending,0)) ELSE NULL END AS flstmtitem_prqtr, CASE WHEN (flgrp_summarize AND flgrp_showdiffprcnt) THEN (flrptprqt.flrpt_diffprcnt) WHEN (flgrp_summarize AND flgrp_showendprcnt) THEN (flrptprqt.flrpt_endingprcnt) ELSE NULL END AS flstmtitem_prqtrprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE(flrptqt.flrpt_diff-flrptprqt.flrpt_diff,0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE(flrptqt.flrpt_ending-flrptprqt.flrpt_ending,0)) ELSE NULL END AS flstmtitem_prqtrdiff, CASE WHEN (flgrp_summarize AND (flhead_type IN ('I','C')) AND (flrptprqt.flrpt_diff > 0)) THEN (COALESCE((flrptqt.flrpt_diff-flrptprqt.flrpt_diff)/flrptprqt.flrpt_diff,0)) WHEN (flgrp_summarize AND (flhead_type = 'B') AND (flrptprqt.flrpt_ending > 0)) THEN (COALESCE((flrptqt.flrpt_ending-flrptprqt.flrpt_ending)/flrptprqt.flrpt_ending,0)) WHEN (flgrp_summarize AND (flrptprqt.flrpt_ending = 0)) THEN NULL ELSE NULL END AS flstmtitem_prqtrdiffprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE(flrptpryr.flrpt_diff,0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE(flrptpryr.flrpt_ending,0)) ELSE NULL END AS flstmtitem_pryear, CASE WHEN (flgrp_summarize AND flgrp_showdiffprcnt) THEN (flrptpryr.flrpt_diffprcnt) WHEN (flgrp_summarize AND flgrp_showendprcnt) THEN (flrptpryr.flrpt_endingprcnt) ELSE NULL END AS flstmtitem_pryearprcnt, CASE WHEN (flgrp_summarize AND flhead_type IN ('I','C')) THEN (COALESCE(flrptyr.flrpt_diff-flrptpryr.flrpt_diff,0)) WHEN (flgrp_summarize AND flhead_type = 'B') THEN (COALESCE(flrptyr.flrpt_ending-flrptpryr.flrpt_ending,0)) ELSE NULL END AS flstmtitem_pryeardiff, CASE WHEN (flgrp_summarize AND (flhead_type IN ('I','C')) AND (flrptpryr.flrpt_diff > 0)) THEN (COALESCE((flrptyr.flrpt_diff-flrptpryr.flrpt_diff)/flrptpryr.flrpt_diff,0)) WHEN (flgrp_summarize AND (flhead_type = 'B' ) AND (flrptpryr.flrpt_ending > 0)) THEN (COALESCE((flrptyr.flrpt_ending-flrptpryr.flrpt_ending)/flrptpryr.flrpt_ending,0)) WHEN (flgrp_summarize AND (flrptpryr.flrpt_ending = 0)) THEN NULL ELSE NULL END AS flstmtitem_pryeardiffprcnt FROM flgrp,flhead, (SELECT DISTINCT flrpt_flhead_id, flrpt_period_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_parent_id FROM flrpt WHERE ((flrpt_type='G') AND (flrpt_flhead_id=_p.flhead_id) AND (flrpt_period_id=pPeriodId) )) AS flrpt LEFT OUTER JOIN flrpt flrptmo ON ((flrptmo.flrpt_type=flrpt.flrpt_type) AND (flrptmo.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptmo.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptmo.flrpt_period_id=flrpt.flrpt_period_id) AND (flrptmo.flrpt_interval='M') AND (flrptmo.flrpt_order=flrpt.flrpt_order)) LEFT OUTER JOIN flrpt flrptqt ON ((flrptqt.flrpt_type=flrpt.flrpt_type) AND (flrptqt.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptqt.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptqt.flrpt_period_id=flrpt.flrpt_period_id) AND (flrptqt.flrpt_interval=_qtrInterval) AND (flrptqt.flrpt_order=flrpt.flrpt_order)) LEFT OUTER JOIN flrpt flrptyr ON ((flrptyr.flrpt_type=flrpt.flrpt_type) AND (flrptyr.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptyr.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptyr.flrpt_period_id=flrpt.flrpt_period_id) AND (flrptyr.flrpt_interval=_yrInterval) AND (flrptyr.flrpt_order=flrpt.flrpt_order)) LEFT OUTER JOIN flrpt flrptprmo ON ((flrptprmo.flrpt_type=flrpt.flrpt_type) AND (flrptprmo.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptprmo.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptprmo.flrpt_period_id=_priorMoPeriodId) AND (flrptprmo.flrpt_interval='M') AND (flrptprmo.flrpt_order=flrpt.flrpt_order)) LEFT OUTER JOIN flrpt flrptprqt ON ((flrptprqt.flrpt_type=flrpt.flrpt_type) AND (flrptprqt.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptprqt.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptprqt.flrpt_period_id=_priorQtPeriodId) AND (flrptprqt.flrpt_interval='Q') AND (flrptprqt.flrpt_order=flrpt.flrpt_order)) LEFT OUTER JOIN flrpt flrptpryr ON ((flrptpryr.flrpt_type=flrpt.flrpt_type) AND (flrptpryr.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptpryr.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptpryr.flrpt_period_id=_priorYrPeriodId) AND (flrptpryr.flrpt_interval='Y') AND (flrptpryr.flrpt_order=flrpt.flrpt_order)) WHERE ((flgrp_id = flrpt.flrpt_type_id) AND (flhead_id = flgrp_flhead_id)) UNION SELECT flrpt.flrpt_flhead_id AS flstmtitem_flhead_id, flrpt.flrpt_period_id AS flstmtitem_period_id, flrpt.flrpt_username AS flstmtitem_username, flrpt.flrpt_order AS flstmtitem_order, flrpt.flrpt_level AS flstmtitem_level, flrpt.flrpt_type AS flstmtitem_type, flrpt.flrpt_type_id AS flstmtitem_type_id, flrpt.flrpt_parent_id AS flstmtitem_parent_id, flrpt.flrpt_accnt_id AS flstmtitem_accnt_id, CASE WHEN (pIndentName) THEN formatindent(flrpt.flrpt_name,flrpt.flrpt_level) ELSE flrpt.flrpt_name END AS flstmtitem_name, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptmo.flrpt_diff,0)) ELSE (COALESCE(flrptmo.flrpt_ending,0)) END AS flstmtitem_month, (COALESCE(flrptmo.flrpt_debits,0)) AS flstmtitem_monthdb, (COALESCE(flrptmo.flrpt_credits,0)) AS flstmtitem_monthcr, CASE WHEN (flitem_showdiffprcnt) THEN (flrptmo.flrpt_diffprcnt) WHEN (flitem_showendprcnt) THEN (flrptmo.flrpt_endingprcnt) ELSE NULL END AS flstmtitem_monthprcnt, (COALESCE(flrptmo.flrpt_budget,0)) AS flstmtitem_monthbudget, (flrptmo.flrpt_budgetprcnt) AS flstmtitem_monthbudgetprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE((flrptmo.flrpt_diff-flrptmo.flrpt_budget),0)) ELSE (COALESCE((flrptmo.flrpt_ending-flrptmo.flrpt_budget),0)) END AS flstmtitem_monthbudgetdiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptmo.flrpt_budget > 0)) THEN (COALESCE(((flrptmo.flrpt_diff-flrptmo.flrpt_budget)/flrptmo.flrpt_budget),0)) WHEN ((flhead_type='B') AND (flrptmo.flrpt_budget > 0)) THEN (COALESCE(((flrptmo.flrpt_ending-flrptmo.flrpt_budget)/flrptmo.flrpt_budget),0)) ELSE NULL END AS flstmtitem_monthbudgetdiffprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptqt.flrpt_diff,0)) ELSE (COALESCE(flrptqt.flrpt_ending,0)) END AS flstmtitem_qtr, (COALESCE(flrptqt.flrpt_debits,0)) AS flstmtitem_qtrdb, (COALESCE(flrptqt.flrpt_credits,0)) AS flstmtitem_qtrcr, CASE WHEN (flitem_showdiffprcnt) THEN (COALESCE(flrptqt.flrpt_diffprcnt,0)) WHEN (flitem_showendprcnt) THEN (COALESCE(flrptqt.flrpt_endingprcnt,0)) ELSE NULL END AS flstmtitem_qtrprcnt, (COALESCE(flrptqt.flrpt_budget,0)) AS flstmtitem_qtrbudget, (flrptqt.flrpt_budgetprcnt) AS flstmtitem_qtrbudgetprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE((flrptqt.flrpt_diff-flrptqt.flrpt_budget),0)) ELSE (COALESCE((flrptqt.flrpt_ending-flrptqt.flrpt_budget),0)) END AS flstmtitem_qtrbudgetdiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptqt.flrpt_budget > 0)) THEN (COALESCE(((flrptqt.flrpt_diff-flrptqt.flrpt_budget)/flrptqt.flrpt_budget),0)) WHEN ((flhead_type='B') AND (flrptqt.flrpt_budget > 0)) THEN (COALESCE(((flrptqt.flrpt_ending-flrptqt.flrpt_budget)/flrptqt.flrpt_budget),0)) ELSE NULL END AS flstmtitem_qtrbudgetdiffprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptyr.flrpt_diff,0)) ELSE (COALESCE(flrptyr.flrpt_ending,0)) END AS flstmtitem_year, (COALESCE(flrptyr.flrpt_debits,0)) AS flstmtitem_yeardb, (COALESCE(flrptyr.flrpt_credits,0)) AS flstmtitem_yearcr, CASE WHEN (flitem_showdiffprcnt) THEN (flrptyr.flrpt_diffprcnt) WHEN (flitem_showendprcnt) THEN (flrptyr.flrpt_endingprcnt) ELSE NULL END AS flstmtitem_yearprcnt, (COALESCE(flrptyr.flrpt_budget,0)) AS flstmtitem_yearbudget, (flrptyr.flrpt_budgetprcnt) AS flstmtitem_yearbudgetprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE((flrptyr.flrpt_diff-flrptyr.flrpt_budget),0)) ELSE (COALESCE((flrptyr.flrpt_ending-flrptyr.flrpt_budget),0)) END AS flstmtitem_yearbudgetdiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptyr.flrpt_budget > 0)) THEN (COALESCE(((flrptyr.flrpt_diff-flrptyr.flrpt_budget)/flrptyr.flrpt_budget),0)) WHEN ((flhead_type = 'B') AND (flrptyr.flrpt_budget > 0)) THEN (COALESCE(((flrptyr.flrpt_ending-flrptyr.flrpt_budget)/flrptyr.flrpt_budget),0)) ELSE NULL END AS flstmtitem_yearbudgetdiffprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptprmo.flrpt_diff,0)) ELSE (COALESCE(flrptprmo.flrpt_ending,0)) END AS flstmtitem_prmonth, CASE WHEN (flitem_showdiffprcnt) THEN (flrptprmo.flrpt_diffprcnt) WHEN (flitem_showendprcnt) THEN (flrptprmo.flrpt_endingprcnt) ELSE NULL END AS flstmtitem_prmonthprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptmo.flrpt_diff-flrptprmo.flrpt_diff,0)) ELSE (COALESCE(flrptmo.flrpt_ending-flrptprmo.flrpt_ending,0)) END AS flstmtitem_prmonthdiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptprmo.flrpt_diff > 0)) THEN (COALESCE((flrptmo.flrpt_diff-flrptprmo.flrpt_diff)/flrptprmo.flrpt_diff,0)) WHEN ((flhead_type = 'B') AND (flrptprmo.flrpt_ending > 0)) THEN (COALESCE((flrptmo.flrpt_ending-flrptprmo.flrpt_ending)/flrptprmo.flrpt_ending,0)) ELSE NULL END AS flstmtitem_prmonthdiffprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptprqt.flrpt_diff,0)) ELSE (COALESCE(flrptprqt.flrpt_ending,0)) END AS flstmtitem_prqtr, CASE WHEN (flitem_showdiffprcnt) THEN (flrptprqt.flrpt_diffprcnt) WHEN (flitem_showendprcnt) THEN (flrptprqt.flrpt_endingprcnt) ELSE NULL END AS flstmtitem_prqtrprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptqt.flrpt_diff-flrptprqt.flrpt_diff,0)) ELSE (COALESCE(flrptqt.flrpt_ending-flrptprqt.flrpt_ending,0)) END AS flstmtitem_prqtrdiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptprqt.flrpt_diff > 0)) THEN (COALESCE((flrptqt.flrpt_diff-flrptprqt.flrpt_diff)/flrptprqt.flrpt_diff,0)) WHEN ((flhead_type = 'B') AND (flrptprqt.flrpt_ending > 0)) THEN (COALESCE((flrptqt.flrpt_ending-flrptprqt.flrpt_ending)/flrptprqt.flrpt_ending,0)) ELSE NULL END AS flstmtitem_prqtrdiffprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptpryr.flrpt_diff,0)) ELSE (COALESCE(flrptpryr.flrpt_ending,0)) END AS flstmtitem_pryear, CASE WHEN (flitem_showdiffprcnt) THEN (flrptpryr.flrpt_diffprcnt) WHEN (flitem_showendprcnt) THEN (flrptpryr.flrpt_endingprcnt) ELSE NULL END AS flstmtitem_pryearprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE((flrptyr.flrpt_diff-flrptpryr.flrpt_diff),0)) ELSE (COALESCE((flrptyr.flrpt_ending-flrptpryr.flrpt_ending),0)) END AS flstmtitem_pryeardiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptpryr.flrpt_diff > 0)) THEN (COALESCE((flrptyr.flrpt_diff-flrptpryr.flrpt_diff)/flrptpryr.flrpt_diff,0)) WHEN ((flhead_type = 'B' ) AND (flrptpryr.flrpt_ending > 0)) THEN (COALESCE((flrptyr.flrpt_ending-flrptpryr.flrpt_ending)/flrptpryr.flrpt_ending,0)) ELSE NULL END AS flstmtitem_pryeardiffprcnt FROM flitem,flhead, (SELECT DISTINCT flrpt_flhead_id, flrpt_period_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_parent_id, accnt_id AS flrpt_accnt_id, CASE WHEN (pShowNumbers) THEN (formatGLAccount(accnt_id) || '-' || accnt_descrip) ELSE accnt_descrip END AS flrpt_name FROM flrpt,accnt WHERE ((flrpt_type='I') AND (flrpt_flhead_id=_p.flhead_id) AND (flrpt_period_id=pPeriodid) AND (accnt_id=flrpt_accnt_id))) AS flrpt LEFT OUTER JOIN flrpt flrptmo ON ((flrptmo.flrpt_type=flrpt.flrpt_type) AND (flrptmo.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptmo.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptmo.flrpt_period_id=flrpt.flrpt_period_id) AND (flrptmo.flrpt_interval='M') AND (flrptmo.flrpt_order=flrpt.flrpt_order)) LEFT OUTER JOIN flrpt flrptqt ON ((flrptqt.flrpt_type=flrpt.flrpt_type) AND (flrptqt.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptqt.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptqt.flrpt_period_id=flrpt.flrpt_period_id) AND (flrptqt.flrpt_interval=_qtrInterval) AND (flrptqt.flrpt_order=flrpt.flrpt_order)) LEFT OUTER JOIN flrpt flrptyr ON ((flrptyr.flrpt_type=flrpt.flrpt_type) AND (flrptyr.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptyr.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptyr.flrpt_period_id=flrpt.flrpt_period_id) AND (flrptyr.flrpt_interval=_yrInterval) AND (flrptyr.flrpt_order=flrpt.flrpt_order)) LEFT OUTER JOIN flrpt flrptprmo ON ((flrptprmo.flrpt_type=flrpt.flrpt_type) AND (flrptprmo.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptprmo.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptprmo.flrpt_period_id=_priorMoPeriodId) AND (flrptprmo.flrpt_interval='M') AND (flrptprmo.flrpt_order=flrpt.flrpt_order)) LEFT OUTER JOIN flrpt flrptprqt ON ((flrptprqt.flrpt_type=flrpt.flrpt_type) AND (flrptprqt.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptprqt.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptprqt.flrpt_period_id=_priorQtPeriodId) AND (flrptprqt.flrpt_interval='Q') AND (flrptprqt.flrpt_order=flrpt.flrpt_order)) LEFT OUTER JOIN flrpt flrptpryr ON ((flrptpryr.flrpt_type=flrpt.flrpt_type) AND (flrptpryr.flrpt_type_id=flrpt.flrpt_type_id) AND (flrptpryr.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptpryr.flrpt_period_id=_priorYrPeriodId) AND (flrptpryr.flrpt_interval='Y') AND (flrptpryr.flrpt_order=flrpt.flrpt_order) ) WHERE ((flitem_id = flrpt.flrpt_type_id) AND (flhead_id = flitem_flhead_id)) UNION SELECT flrpt.flrpt_flhead_id AS flstmtitem_flhead_id, flrpt.flrpt_period_id AS flstmtitem_period_id, flrpt.flrpt_username AS flstmtitem_username, flrpt.flrpt_order AS flstmtitem_order, flrpt.flrpt_level AS flstmtitem_level, flrpt.flrpt_type AS flstmtitem_type, flrpt.flrpt_type_id AS flstmtitem_type_id, flrpt.flrpt_parent_id AS flstmtitem_parent_id, NULL AS flstmtitem_accnt_id, CASE WHEN(flrpt.flrpt_type='T' AND flrpt.flrpt_level=0) THEN COALESCE(flrpt.flrpt_altname, 'Total') WHEN(flrpt.flrpt_type='T') THEN formatindent(COALESCE(flrpt.flrpt_altname, 'Subtotal') , (CASE WHEN pIndentName THEN flrpt.flrpt_level ELSE 0 END)) ELSE formatindent(('Type ' || flrpt.flrpt_type || ' ' || text(flrpt.flrpt_type_id)), (CASE WHEN pIndentName THEN flrpt.flrpt_level ELSE 0 END)) END AS flstmtitem_name, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptmo.flrpt_diff,0)) ELSE (COALESCE(flrptmo.flrpt_ending,0)) END AS flstmtitem_month, (COALESCE(flrptmo.flrpt_debits,0)) AS flstmtitem_monthdb, (COALESCE(flrptmo.flrpt_credits,0)) AS flstmtitem_monthcr, CASE WHEN (flhead_type IN ('I','C')) THEN (flrptmo.flrpt_diffprcnt) ELSE (flrptmo.flrpt_endingprcnt) END AS flstmtitem_monthprcnt, (COALESCE(flrptmo.flrpt_budget,0)) AS flstmtitem_monthbudget, (flrptmo.flrpt_budgetprcnt) AS flstmtitem_monthbudgetprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE((flrptmo.flrpt_diff-flrptmo.flrpt_budget),0)) ELSE (COALESCE((flrptmo.flrpt_ending-flrptmo.flrpt_budget),0)) END AS flstmtitem_monthbudgetdiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptmo.flrpt_budget > 0)) THEN (COALESCE(((flrptmo.flrpt_diff-flrptmo.flrpt_budget)/flrptmo.flrpt_budget),0)) WHEN ((flhead_type='B') AND (flrptmo.flrpt_budget > 0)) THEN (COALESCE(((flrptmo.flrpt_ending-flrptmo.flrpt_budget)/flrptmo.flrpt_budget),0)) ELSE NULL END AS flstmtitem_monthbudgetdiffprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptqt.flrpt_diff,0)) ELSE (COALESCE(flrptqt.flrpt_ending,0)) END AS flstmtitem_qtr, (COALESCE(flrptqt.flrpt_debits,0)) AS flstmtitem_qtrdb, (COALESCE(flrptqt.flrpt_credits,0)) AS flstmtitem_qtrcr, CASE WHEN (flhead_type IN ('I','C')) THEN (flrptqt.flrpt_diffprcnt) ELSE (flrptqt.flrpt_endingprcnt) END AS flstmtitem_qtrprcnt, (COALESCE(flrptqt.flrpt_budget,0)) AS flstmtitem_qtrbudget, (flrptqt.flrpt_budgetprcnt) AS flstmtitem_qtrbudgetprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE((flrptqt.flrpt_diff-flrptqt.flrpt_budget),0)) ELSE (COALESCE((flrptqt.flrpt_ending-flrptqt.flrpt_budget),0)) END AS flstmtitem_qtrbudgetdiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptqt.flrpt_budget > 0)) THEN (COALESCE(((flrptqt.flrpt_diff-flrptqt.flrpt_budget)/flrptqt.flrpt_budget),0)) WHEN ((flhead_type='B') AND (flrptqt.flrpt_budget > 0)) THEN (COALESCE(((flrptqt.flrpt_ending-flrptqt.flrpt_budget)/flrptqt.flrpt_budget),0)) ELSE NULL END AS flstmtitem_qtrbudgetdiffprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptyr.flrpt_diff,0)) ELSE (COALESCE(flrptyr.flrpt_ending,0)) END AS flstmtitem_year, (COALESCE(flrptyr.flrpt_debits,0)) AS flstmtitem_yeardb, (COALESCE(flrptyr.flrpt_credits,0)) AS flstmtitem_yearcr, CASE WHEN (flhead_type IN ('I','C')) THEN (flrptyr.flrpt_diffprcnt) ELSE (flrptyr.flrpt_endingprcnt) END AS flstmtitem_yearprcnt, (COALESCE(flrptyr.flrpt_budget,0)) AS flstmtitem_yearbudget, (flrptyr.flrpt_budgetprcnt) AS flstmtitem_yearbudgetprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE((flrptyr.flrpt_diff-flrptyr.flrpt_budget),0)) ELSE (COALESCE((flrptyr.flrpt_ending-flrptyr.flrpt_budget),0)) END AS flstmtitem_yearbudgetdiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptyr.flrpt_budget > 0)) THEN (COALESCE(((flrptyr.flrpt_diff-flrptyr.flrpt_budget)/flrptyr.flrpt_budget),0)) WHEN ((flhead_type = 'B') AND (flrptyr.flrpt_budget > 0)) THEN (COALESCE(((flrptyr.flrpt_ending-flrptyr.flrpt_budget)/flrptyr.flrpt_budget),0)) ELSE NULL END AS flstmtitem_yearbudgetdiffprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptprmo.flrpt_diff,0)) ELSE (COALESCE(flrptprmo.flrpt_ending,0)) END AS flstmtitem_prmonth, CASE WHEN (flhead_type IN ('I','C')) THEN (flrptprmo.flrpt_diffprcnt) ELSE (flrptprmo.flrpt_endingprcnt) END AS flstmtitem_prmonthprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptmo.flrpt_diff-flrptprmo.flrpt_diff,0)) ELSE (COALESCE(flrptmo.flrpt_ending-flrptprmo.flrpt_ending,0)) END AS flstmtitem_prmonthdiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptprmo.flrpt_diff > 0)) THEN (COALESCE((flrptmo.flrpt_diff-flrptprmo.flrpt_diff)/flrptprmo.flrpt_diff,0)) WHEN ((flhead_type = 'B') AND (flrptprmo.flrpt_ending > 0)) THEN (COALESCE((flrptmo.flrpt_ending-flrptprmo.flrpt_ending)/flrptprmo.flrpt_ending,0)) ELSE NULL END AS flstmtitem_prmonthdiffprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptprqt.flrpt_diff,0)) ELSE (COALESCE(flrptprqt.flrpt_ending,0)) END AS flstmtitem_prqtr, CASE WHEN (flhead_type IN ('I','C')) THEN (flrptprqt.flrpt_diffprcnt) ELSE (flrptprqt.flrpt_endingprcnt) END AS flstmtitem_prqtrprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptqt.flrpt_diff-flrptprqt.flrpt_diff,0)) ELSE (COALESCE(flrptqt.flrpt_ending-flrptprqt.flrpt_ending,0)) END AS flstmtitem_prqtrdiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptprqt.flrpt_diff > 0)) THEN (COALESCE((flrptqt.flrpt_diff-flrptprqt.flrpt_diff)/flrptprqt.flrpt_diff,0)) WHEN ((flhead_type = 'B') AND (flrptprqt.flrpt_ending > 0)) THEN (COALESCE((flrptqt.flrpt_ending-flrptprqt.flrpt_ending)/flrptprqt.flrpt_ending,0)) ELSE NULL END AS flstmtitem_prqtrdiffprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptpryr.flrpt_diff,0)) ELSE (COALESCE(flrptpryr.flrpt_ending,0)) END AS flstmtitem_pryear, CASE WHEN (flhead_type IN ('I','C')) THEN (flrptpryr.flrpt_diffprcnt) ELSE (flrptpryr.flrpt_endingprcnt) END AS flstmtitem_pryearprcnt, CASE WHEN (flhead_type IN ('I','C')) THEN (COALESCE(flrptyr.flrpt_diff-flrptpryr.flrpt_diff,0)) ELSE (COALESCE(flrptyr.flrpt_ending-flrptpryr.flrpt_ending,0)) END AS flstmtitem_pryeardiff, CASE WHEN ((flhead_type IN ('I','C')) AND (flrptpryr.flrpt_diff > 0)) THEN (COALESCE((flrptyr.flrpt_diff-flrptpryr.flrpt_diff)/flrptpryr.flrpt_diff,0)) WHEN ((flhead_type = 'B' ) AND (flrptpryr.flrpt_ending > 0)) THEN (COALESCE((flrptyr.flrpt_ending-flrptpryr.flrpt_ending)/flrptpryr.flrpt_ending,0)) ELSE NULL END AS flstmtitem_pryeardiffprcnt FROM flhead CROSS JOIN (SELECT DISTINCT flrpt_flhead_id, flrpt_period_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_parent_id, flrpt_altname FROM flrpt WHERE ((NOT (flrpt_type IN ('G','I','S'))) AND (flrpt_flhead_id=_p.flhead_id) AND (flrpt_period_id=pPeriodId) )) AS flrpt LEFT OUTER JOIN flrpt flrptmo ON ((flrptmo.flrpt_type=flrpt.flrpt_type) AND (flrptmo.flrpt_order=flrpt.flrpt_order) AND (flrptmo.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptmo.flrpt_period_id=flrpt.flrpt_period_id) AND (flrptmo.flrpt_interval='M') ) LEFT OUTER JOIN flrpt flrptqt ON ((flrptqt.flrpt_type=flrpt.flrpt_type) AND (flrptqt.flrpt_order=flrpt.flrpt_order) AND (flrptqt.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptqt.flrpt_period_id=flrpt.flrpt_period_id) AND (flrptqt.flrpt_interval=_qtrInterval) ) LEFT OUTER JOIN flrpt flrptyr ON ((flrptyr.flrpt_type=flrpt.flrpt_type) AND (flrptyr.flrpt_order=flrpt.flrpt_order) AND (flrptyr.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptyr.flrpt_period_id=flrpt.flrpt_period_id) AND (flrptyr.flrpt_interval=_yrInterval) ) LEFT OUTER JOIN flrpt flrptprmo ON ((flrptprmo.flrpt_type=flrpt.flrpt_type) AND (flrptprmo.flrpt_order=flrpt.flrpt_order) AND (flrptprmo.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptprmo.flrpt_period_id=_priorMoPeriodId) AND (flrptprmo.flrpt_interval='M') ) LEFT OUTER JOIN flrpt flrptprqt ON ((flrptprqt.flrpt_type=flrpt.flrpt_type) AND (flrptprqt.flrpt_order=flrpt.flrpt_order) AND (flrptprqt.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptprqt.flrpt_period_id=_priorQtPeriodId) AND (flrptprqt.flrpt_interval='Q') ) LEFT OUTER JOIN flrpt flrptpryr ON ((flrptpryr.flrpt_type=flrpt.flrpt_type) AND (flrptpryr.flrpt_order=flrpt.flrpt_order) AND (flrptpryr.flrpt_flhead_id=flrpt.flrpt_flhead_id) AND (flrptpryr.flrpt_period_id=_priorYrPeriodId) AND (flrptpryr.flrpt_interval='Y') ) WHERE (flhead_id=flrpt.flrpt_flhead_id) ORDER BY flstmtitem_order LOOP IF _prevlevel > _x.flstmtitem_level THEN _subgrp := _subgrp+1; END IF; _prevlevel:=_x.flstmtitem_level; _row.flstmtitem_subgrp := _subgrp; IF NOT _first THEN RETURN NEXT _row; END IF; _first := FALSE; _row.flstmtitem_flhead_id := _x.flstmtitem_flhead_id; _row.flstmtitem_period_id := _x.flstmtitem_period_id; _row.flstmtitem_username := _x.flstmtitem_username; _row.flstmtitem_order := _x.flstmtitem_order; _row.flstmtitem_level := _x.flstmtitem_level; _row.flstmtitem_type := _x.flstmtitem_type; _row.flstmtitem_type_id := _x.flstmtitem_type_id; _row.flstmtitem_parent_id := _x.flstmtitem_parent_id; _row.flstmtitem_accnt_id := _x.flstmtitem_accnt_id; _row.flstmtitem_name := _x.flstmtitem_name; _row.flstmtitem_month := _x.flstmtitem_month; _row.flstmtitem_monthdb := _x.flstmtitem_monthdb; _row.flstmtitem_monthcr := _x.flstmtitem_monthcr; _row.flstmtitem_monthprcnt := _x.flstmtitem_monthprcnt; _row.flstmtitem_monthbudget := _x.flstmtitem_monthbudget; _row.flstmtitem_monthbudgetprcnt := _x.flstmtitem_monthbudgetprcnt; _row.flstmtitem_monthbudgetdiff := _x.flstmtitem_monthbudgetdiff; _row.flstmtitem_monthbudgetdiffprcnt := _x.flstmtitem_monthbudgetdiffprcnt; _row.flstmtitem_qtr := _x.flstmtitem_qtr; _row.flstmtitem_qtrdb := _x.flstmtitem_qtrdb; _row.flstmtitem_qtrcr := _x.flstmtitem_qtrcr; _row.flstmtitem_qtrprcnt := _x.flstmtitem_qtrprcnt; _row.flstmtitem_qtrbudget := _x.flstmtitem_qtrbudget; _row.flstmtitem_qtrbudgetprcnt := _x.flstmtitem_qtrbudgetprcnt; _row.flstmtitem_qtrbudgetdiff := _x.flstmtitem_qtrbudgetdiff; _row.flstmtitem_qtrbudgetdiffprcnt := _x.flstmtitem_qtrbudgetdiffprcnt; _row.flstmtitem_year := _x.flstmtitem_year; _row.flstmtitem_yeardb := _x.flstmtitem_yeardb; _row.flstmtitem_yearcr := _x.flstmtitem_yearcr; _row.flstmtitem_yearprcnt := _x.flstmtitem_yearprcnt; _row.flstmtitem_yearbudget := _x.flstmtitem_yearbudget; _row.flstmtitem_yearbudgetprcnt := _x.flstmtitem_yearbudgetprcnt; _row.flstmtitem_yearbudgetdiff := _x.flstmtitem_yearbudgetdiff; _row.flstmtitem_yearbudgetdiffprcnt := _x.flstmtitem_yearbudgetdiffprcnt; _row.flstmtitem_prmonth := _x.flstmtitem_prmonth; _row.flstmtitem_prmonthprcnt := _x.flstmtitem_prmonthprcnt; _row.flstmtitem_prmonthdiff := _x.flstmtitem_prmonthdiff; _row.flstmtitem_prmonthdiffprcnt := _x.flstmtitem_prmonthdiffprcnt; _row.flstmtitem_prqtr := _x.flstmtitem_prqtr; _row.flstmtitem_prqtrprcnt := _x.flstmtitem_prqtrprcnt; _row.flstmtitem_prqtrdiff := _x.flstmtitem_prqtrdiff; _row.flstmtitem_prqtrdiffprcnt := _x.flstmtitem_prqtrdiffprcnt; _row.flstmtitem_pryear := _x.flstmtitem_pryear; _row.flstmtitem_pryearprcnt := _x.flstmtitem_pryearprcnt; _row.flstmtitem_pryeardiff := _x.flstmtitem_pryeardiff; _row.flstmtitem_pryeardiffprcnt := _x.flstmtitem_pryeardiffprcnt; END LOOP; _row.flstmtitem_subgrp := _subgrp + 1; RETURN NEXT _row; END; $_$; SDROP FUNCTION public.financialreport(integer, integer, boolean, boolean, integer); publicadminfalse462384246125578462findapaccount(integer)FUNCTION\CREATE FUNCTION findapaccount(integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; _accntid INTEGER; BEGIN IF (NOT fetchMetricBool('InterfaceAPToGL')) THEN RETURN 0; END IF; SELECT apaccnt_ap_accnt_id INTO _accntid FROM apaccnt JOIN vendinfo ON (apaccnt_vendtype_id=vend_vendtype_id) WHERE (vend_id=pVendid); IF (FOUND) THEN RETURN _accntid; END IF; SELECT apaccnt_ap_accnt_id INTO _accntid FROM apaccnt JOIN vendtype ON (vendtype_code ~ apaccnt_vendtype) JOIN vendinfo ON (vend_vendtype_id=vendtype_id) WHERE ((apaccnt_vendtype_id=-1) AND (vend_id=pVendid)); IF (FOUND) THEN RETURN _accntid; END IF; RETURN -1; END; $_$; -DROP FUNCTION public.findapaccount(integer); publicadminfalse46238125578463findapdiscountaccount(integer)FUNCTIONiCREATE FUNCTION findapdiscountaccount(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; _accntid INTEGER; BEGIN IF (NOT fetchMetricBool('InterfaceAPToGL')) THEN RETURN 0; END IF; SELECT apaccnt_discount_accnt_id INTO _accntid FROM apaccnt JOIN vendinfo ON (apaccnt_vendtype_id=vend_vendtype_id) WHERE (vend_id=pVendid); IF (FOUND) THEN RETURN _accntid; END IF; SELECT apaccnt_discount_accnt_id INTO _accntid FROM apaccnt JOIN vendtype ON (vendtype_code ~ apaccnt_vendtype) JOIN vendinfo ON (vend_vendtype_id=vendtype_id) WHERE ((apaccnt_vendtype_id=-1) AND (vend_id=pVendid)); IF (FOUND) THEN RETURN _accntid; END IF; RETURN -1; END; $_$; 5DROP FUNCTION public.findapdiscountaccount(integer); publicadminfalse84623125578464findapprepaidaccount(integer)FUNCTIONCREATE FUNCTION findapprepaidaccount(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendid ALIAS FOR $1; _accntid INTEGER; BEGIN IF (NOT fetchMetricBool('InterfaceAPToGL')) THEN RETURN 0; END IF; -- Check for a Vendor Type specific Account SELECT apaccnt_prepaid_accnt_id INTO _accntid FROM apaccnt JOIN vendinfo ON (apaccnt_vendtype_id=vend_vendtype_id) WHERE (vend_id=pVendid); IF (FOUND) THEN RETURN _accntid; END IF; -- Check for a Vendor Type pattern SELECT apaccnt_prepaid_accnt_id INTO _accntid FROM apaccnt JOIN vendtype ON (vendtype_code ~ apaccnt_vendtype) JOIN vendinfo ON (vend_vendtype_id=vendtype_id) WHERE ((apaccnt_vendtype_id=-1) AND (vend_id=pVendid)); IF (FOUND) THEN RETURN _accntid; END IF; RETURN -1; END; $_$; 4DROP FUNCTION public.findapprepaidaccount(integer); publicadminfalse84623125578465findaraccount(integer)FUNCTIONCREATE FUNCTION findaraccount(integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; _accntid INTEGER; BEGIN IF (NOT fetchMetricBool('InterfaceARToGL')) THEN RETURN 0; END IF; -- Check for a Customer Type specific Account SELECT araccnt_ar_accnt_id INTO _accntid FROM araccnt, custinfo WHERE ( (araccnt_custtype_id=cust_custtype_id) AND (cust_id=pCustid) ); IF (FOUND) THEN RETURN _accntid; END IF; -- Check for a Customer Type pattern SELECT araccnt_ar_accnt_id INTO _accntid FROM araccnt, custinfo, custtype WHERE ( (custtype_code ~ araccnt_custtype) AND (araccnt_custtype_id=-1) AND (cust_custtype_id=custtype_id) AND (cust_id=pCustid) ); IF (FOUND) THEN RETURN _accntid; END IF; RETURN -1; END; $_$; -DROP FUNCTION public.findaraccount(integer); publicadminfalse84623125578466findardiscountaccount(integer)FUNCTIONCREATE FUNCTION findardiscountaccount(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; _accntid INTEGER; BEGIN IF (NOT fetchMetricBool('InterfaceARToGL')) THEN RETURN 0; END IF; -- Check for a Customer Type specific Account SELECT araccnt_discount_accnt_id INTO _accntid FROM araccnt, custinfo WHERE ( (araccnt_custtype_id=cust_custtype_id) AND (cust_id=pCustid) ); IF (FOUND) THEN RETURN _accntid; END IF; -- Check for a Customer Type pattern SELECT araccnt_discount_accnt_id INTO _accntid FROM araccnt, custinfo, custtype WHERE ( (custtype_code ~ araccnt_custtype) AND (cust_custtype_id=custtype_id) AND (araccnt_custtype_id=-1) AND (cust_id=pCustid) ); IF (FOUND) THEN RETURN _accntid; END IF; RETURN -1; END; $_$; 5DROP FUNCTION public.findardiscountaccount(integer); publicadminfalse46238125578467findcalendarorigin(integer)FUNCTIONKCREATE FUNCTION findcalendarorigin(integer) RETURNS date LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCalheadid ALIAS FOR $1; _originType CHAR(1); _origin DATE; BEGIN SELECT calhead_origin INTO _originType FROM calhead WHERE (calhead_id=pCalheadid); IF (NOT FOUND) THEN _origin := NULL; ELSIF (_originType = 'D') THEN _origin := CURRENT_DATE; ELSIF (_originType = 'E') THEN _origin := (CURRENT_DATE + 1); ELSIF (_originType = 'W') THEN _origin := (CURRENT_DATE - EXTRACT(DOW FROM CURRENT_DATE)::INTEGER); ELSIF (_originType = 'X') THEN _origin := ((CURRENT_DATE - EXTRACT(DOW FROM CURRENT_DATE)::INTEGER) + INTERVAL '1 week'); ELSIF (_originType = 'M') THEN _origin := date_trunc('month', CURRENT_DATE); ELSIF (_originType = 'N') THEN _origin := (date_trunc('month', CURRENT_DATE) + INTERVAL '1 month'); ELSIF (_originType = 'L') THEN _origin := (date_trunc('year', CURRENT_DATE) - INTERVAL '1 year'); ELSIF (_originType = 'Y') THEN _origin := date_trunc('year', CURRENT_DATE); ELSIF (_originType = 'Z') THEN _origin := (date_trunc('year', CURRENT_DATE) + INTERVAL '1 year'); ELSE _origin := NULL; END IF; RETURN _origin; END; $_$; 2DROP FUNCTION public.findcalendarorigin(integer); publicadminfalse84623125578468$findcustomerform(integer, character)FUNCTIONUCREATE FUNCTION findcustomerform(integer, character) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; pFormtype ALIAS FOR $2; _f RECORD; _found BOOLEAN; BEGIN -- Check for a Customer Type specific Form SELECT custform.* INTO _f FROM custform JOIN custinfo ON (custform_custtype_id=cust_custtype_id) WHERE (cust_id=pCustid); IF (FOUND) THEN _found := TRUE; ELSE -- Check for a Customer Type pattern SELECT custform.* INTO _f FROM custform JOIN custtype ON (custtype_code ~ custform_custtype) JOIN custinfo ON (cust_custtype_id=custtype_id) WHERE ((custform_custtype_id=-1) AND (cust_id=pCustid)); IF (FOUND) THEN _found := TRUE; ELSE _found := FALSE; END IF; END IF; IF (_found) THEN IF ( (pFormType = 'I') AND (_f.custform_invoice_report_name IS NOT NULL) ) THEN RETURN _f.custform_invoice_report_name; ELSIF ( (pFormType = 'C') AND (_f.custform_creditmemo_report_name IS NOT NULL) ) THEN RETURN _f.custform_creditmemo_report_name; ELSIF ( (pFormType = 'S') AND (_f.custform_statement_report_name IS NOT NULL) ) THEN RETURN _f.custform_statement_report_name; ELSIF ( (pFormType = 'Q') AND (_f.custform_quote_report_name IS NOT NULL) ) THEN RETURN _f.custform_quote_report_name; ELSIF ( (pFormType = 'P') AND (_f.custform_packinglist_report_name IS NOT NULL) ) THEN RETURN _f.custform_packinglist_report_name; ELSIF ( (pFormType = 'L') AND (_f.custform_sopicklist_report_name IS NOT NULL) ) THEN RETURN _f.custform_sopicklist_report_name; END IF; END IF; IF (pFormType = 'I') THEN RETURN 'Invoice'; ELSIF (pFormType = 'C') THEN RETURN 'CreditMemo'; ELSIF (pFormType = 'S') THEN RETURN 'Statement'; ELSIF (pFormType = 'Q') THEN RETURN 'Quote'; ELSIF (pFormType = 'P') THEN RETURN 'PackingList-Shipment'; ELSIF (pFormType = 'L') THEN RETURN 'PackingList'; END IF; END; $_$; ;DROP FUNCTION public.findcustomerform(integer, character); publicadminfalse46238125578469finddeferredaccount(integer)FUNCTIONCREATE FUNCTION finddeferredaccount(integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; _accntid INTEGER; BEGIN IF (NOT fetchMetricBool('InterfaceARToGL')) THEN RETURN 0; END IF; -- Check for a Customer Type specific Account SELECT araccnt_deferred_accnt_id INTO _accntid FROM araccnt JOIN custinfo ON (araccnt_custtype_id=cust_custtype_id) WHERE (cust_id=pCustid); IF (FOUND) THEN RETURN _accntid; END IF; -- Check for a Customer Type pattern SELECT araccnt_deferred_accnt_id INTO _accntid FROM araccnt JOIN custtype ON (custtype_code ~ araccnt_custtype) JOIN custinfo ON (cust_custtype_id=custtype_id) WHERE ((araccnt_custtype_id=-1) AND (cust_id=pCustid)); IF (FOUND) THEN RETURN _accntid; END IF; RETURN -1; END; $_$; 3DROP FUNCTION public.finddeferredaccount(integer); publicadminfalse46238125578470findfreightaccount(integer)FUNCTIONWCREATE FUNCTION findfreightaccount(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; _accntid INTEGER; BEGIN IF (NOT fetchMetricBool('InterfaceARToGL')) THEN RETURN 0; END IF; -- Check for a Customer Type specific Account SELECT araccnt_freight_accnt_id INTO _accntid FROM araccnt, custinfo WHERE ( (araccnt_custtype_id=cust_custtype_id) AND (cust_id=pCustid) ); IF (FOUND) THEN RETURN _accntid; END IF; -- Check for a Customer Type pattern SELECT araccnt_freight_accnt_id INTO _accntid FROM araccnt, custinfo, custtype WHERE ( (custtype_code ~ araccnt_custtype) AND (cust_custtype_id=custtype_id) AND (araccnt_custtype_id=-1) AND (cust_id=pCustid) ); IF (FOUND) THEN RETURN _accntid; END IF; -- Find the default SELECT metric_value::INTEGER INTO _accntid FROM metric WHERE (metric_name='FreightAccount'); IF (FOUND) THEN RETURN _accntid; END IF; RETURN -1; END; $_$; 2DROP FUNCTION public.findfreightaccount(integer); publicadminfalse84623125578471findperiodend(integer)FUNCTIONM CREATE FUNCTION findperiodend(integer) RETURNS date LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCalitemid ALIAS FOR $1; _calType CHAR(1); _calItem RECORD; _start DATE; _loop INTEGER; BEGIN SELECT calhead_type INTO _calType FROM calhead, acalitem WHERE ((acalitem_calhead_id=calhead_id) AND (acalitem_id=pCalitemid)); IF (NOT FOUND) THEN SELECT calhead_type INTO _calType FROM calhead, rcalitem WHERE ((rcalitem_calhead_id=calhead_id) AND (rcalitem_id=pCalitemid)); IF (NOT FOUND) THEN RETURN NULL; END IF; END IF; IF (_calType = 'A') THEN RETURN ( SELECT (findPeriodStart(acalitem_id) + acalitem_periodlength - 1) FROM acalitem WHERE (acalitem_id=pCalitemid) ); ELSIF (_calType = 'R') THEN -- Grab the relative calitem's particulars SELECT rcalitem_periodtype, rcalitem_periodcount INTO _calitem FROM rcalitem WHERE (rcalitem_id=pCalitemid); IF (NOT FOUND) THEN RETURN NULL; END If; -- Grab the origin of the calitem SELECT findPeriodStart(pCalitemid) INTO _start; IF (_start IS NULL) THEN -- If days... ELSIF (_calitem.rcalitem_periodtype = 'D') THEN _start := (_start + _calitem.rcalitem_periodcount - 1); -- If weeks... (gotta be a better way) ELSIF (_calitem.rcalitem_periodtype = 'W') THEN _loop := _calitem.rcalitem_periodcount; WHILE (_loop > 0) LOOP _start := (_start + INTERVAL '1 week'); _loop := (_loop - 1); END LOOP; _start := (_start - 1); -- If months... (gotta be a better way) ELSIF (_calitem.rcalitem_periodtype = 'M') THEN _loop := _calitem.rcalitem_periodcount; WHILE (_loop > 0) LOOP _start := (_start + INTERVAL '1 month'); _loop := (_loop - 1); END LOOP; _start := (_start - 1); -- If years... (gotta be a better way) ELSIF (_calitem.rcalitem_periodtype = 'Y') THEN _loop := _calitem.rcalitem_periodcount; WHILE (_loop > 0) LOOP _start := (_start + INTERVAL '1 year'); _loop := (_loop - 1); END LOOP; _start := (_start - 1); ELSE _start := NULL; END IF; ELSE _start := NULL; END IF; RETURN _start; END; $_$; -DROP FUNCTION public.findperiodend(integer); publicadminfalse84623125578472findperiodstart(integer)FUNCTION CREATE FUNCTION findperiodstart(integer) RETURNS date LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCalitemid ALIAS FOR $1; _calType CHAR(1); _calItem RECORD; _start DATE; _loop INTEGER; BEGIN SELECT calhead_type INTO _calType FROM calhead, acalitem WHERE ((acalitem_calhead_id=calhead_id) AND (acalitem_id=pCalitemid)); IF (NOT FOUND) THEN SELECT calhead_type INTO _calType FROM calhead, rcalitem WHERE ((rcalitem_calhead_id=calhead_id) AND (rcalitem_id=pCalitemid)); IF (NOT FOUND) THEN RETURN NULL; END IF; END IF; IF (_calType = 'A') THEN RETURN ( SELECT acalitem_periodstart FROM acalitem WHERE (acalitem_id=pCalitemid) ); ELSIF (_calType = 'R') THEN -- Grab the relative calitem's particulars SELECT rcalitem_offsettype, rcalitem_offsetcount INTO _calitem FROM rcalitem WHERE (rcalitem_id=pCalitemid); IF (NOT FOUND) THEN RETURN NULL; END If; -- Grab the origin of the calitem's parend calhead SELECT findCalendarOrigin(calhead_id) INTO _start FROM calhead, rcalitem WHERE ((rcalitem_calhead_id=calhead_id) AND (rcalitem_id=pCalitemid)); -- If days... IF (_calitem.rcalitem_offsettype = 'D') THEN _start := (_start + _calitem.rcalitem_offsetcount); -- If weeks... ELSIF (_calitem.rcalitem_offsettype = 'W') THEN _start := (_start + (_calitem.rcalitem_offsetcount * 7)); -- If months... (gotta be a better way) ELSIF (_calitem.rcalitem_offsettype = 'M') THEN _loop := _calitem.rcalitem_offsetcount; IF (_loop > 0) THEN WHILE (_loop > 0) LOOP _start := (_start + INTERVAL '1 month'); _loop := _loop - 1; END LOOP; ELSE WHILE (_loop < 0) LOOP _start := (_start - INTERVAL '1 month'); _loop := _loop + 1; END LOOP; END IF; -- If years... (gotta be a better way) ELSIF (_calitem.rcalitem_offsettype = 'Y') THEN _loop := _calitem.rcalitem_offsetcount; IF (_loop > 0) THEN WHILE (_loop > 0) LOOP _start := (_start + INTERVAL '1 year'); _loop := _loop - 1; END LOOP; ELSE WHILE (_loop < 0) LOOP _start := (_start - INTERVAL '1 year'); _loop := _loop + 1; END LOOP; END IF; ELSE _start := NULL; END IF; ELSE _start := NULL; END IF; RETURN _start; END; $_$; /DROP FUNCTION public.findperiodstart(integer); publicadminfalse46238125578473findprepaidaccount(integer)FUNCTIONCREATE FUNCTION findprepaidaccount(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; _accntid INTEGER; BEGIN IF (NOT fetchMetricBool('InterfaceARToGL')) THEN RETURN 0; END IF; -- Check for a Customer Type specific Account SELECT araccnt_prepaid_accnt_id INTO _accntid FROM araccnt JOIN custinfo ON (araccnt_custtype_id=cust_custtype_id) WHERE (cust_id=pCustid); IF (FOUND) THEN RETURN _accntid; END IF; -- Check for a Customer Type pattern SELECT araccnt_prepaid_accnt_id INTO _accntid FROM araccnt JOIN custtype ON (custtype_code ~ araccnt_custtype) JOIN custinfo ON (cust_custtype_id=custtype_id) WHERE ((araccnt_custtype_id=-1) AND (cust_id=pCustid) ); IF (FOUND) THEN RETURN _accntid; END IF; RETURN -1; END; $_$; 2DROP FUNCTION public.findprepaidaccount(integer); publicadminfalse46238125578474 findsalesaccnt(integer, integer)FUNCTION$CREATE FUNCTION findsalesaccnt(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN findSalesAccnt($1, 'IS', $2, NULL, NULL); END; $_$; 7DROP FUNCTION public.findsalesaccnt(integer, integer); publicadminfalse84623125578475&findsalesaccnt(integer, text, integer)FUNCTION(CREATE FUNCTION findsalesaccnt(integer, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN findSalesAccnt($1, $2, $3, NULL, NULL); END; $_$; =DROP FUNCTION public.findsalesaccnt(integer, text, integer); publicadminfalse462381255784768findsalesaccnt(integer, text, integer, integer, integer)FUNCTION CREATE FUNCTION findsalesaccnt(pid integer, pidtype text, pcustid integer, psaletypeid integer, pshipzoneid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _s RECORD; BEGIN IF (pidType = 'I') THEN -- Check for a custtype specific rule SELECT salesaccnt_id, CASE WHEN (salesaccnt_warehous_id<>-1) THEN 1 ELSE 0 END + CASE WHEN (salesaccnt_custtype_id<>-1) THEN 2 ELSE 0 END + CASE WHEN (salesaccnt_prodcat_id<>-1) THEN 3 ELSE 0 END + CASE WHEN (salesaccnt_shipzone_id<>-1) THEN 4 ELSE 0 END + CASE WHEN (salesaccnt_saletype_id<>-1) THEN 5 ELSE 0 END AS orderby INTO _s FROM salesaccnt, item, prodcat, custinfo, custtype WHERE ( (salesaccnt_warehous_id=-1) AND (item_prodcat_id=prodcat_id) AND (cust_custtype_id=custtype_id) AND ( (salesaccnt_prodcat='.*') OR ( (salesaccnt_prodcat_id=-1) AND (salesaccnt_prodcat<>'') AND (prodcat_code ~ salesaccnt_prodcat) ) OR ( (salesaccnt_prodcat_id=prodcat_id) ) ) AND ( (salesaccnt_custtype='.*') OR ( (salesaccnt_custtype_id=-1) AND (salesaccnt_custtype<>'') AND (custtype_code ~ salesaccnt_custtype) ) OR ( (salesaccnt_custtype_id=custtype_id) ) ) AND ( (salesaccnt_shipzone_id=-1) OR (salesaccnt_shipzone_id=pShipzoneid) ) AND ( (salesaccnt_saletype_id=-1) OR (salesaccnt_saletype_id=pSaletypeid) ) AND (item_id=pid) AND (cust_id=pCustid) ) ORDER BY orderby DESC, salesaccnt_custtype DESC, salesaccnt_prodcat DESC, salesaccnt_saletype_id DESC, salesaccnt_shipzone_id DESC LIMIT 1; ELSIF (pidType = 'IS') THEN -- Check for a custtype specific rule SELECT salesaccnt_id, CASE WHEN (salesaccnt_warehous_id<>-1) THEN 1 ELSE 0 END + CASE WHEN (salesaccnt_custtype_id<>-1) THEN 2 ELSE 0 END + CASE WHEN (salesaccnt_prodcat_id<>-1) THEN 3 ELSE 0 END + CASE WHEN (salesaccnt_shipzone_id<>-1) THEN 4 ELSE 0 END + CASE WHEN (salesaccnt_saletype_id<>-1) THEN 5 ELSE 0 END AS orderby INTO _s FROM salesaccnt, itemsite, item, prodcat, custinfo, custtype WHERE ( ( (salesaccnt_warehous_id=-1) OR (salesaccnt_warehous_id=itemsite_warehous_id) ) AND (itemsite_item_id=item_id) AND (item_prodcat_id=prodcat_id) AND (cust_custtype_id=custtype_id) AND ( (salesaccnt_prodcat='.*') OR ( (salesaccnt_prodcat_id=-1) AND (salesaccnt_prodcat<>'') AND (prodcat_code ~ salesaccnt_prodcat) ) OR ( (salesaccnt_prodcat_id=prodcat_id) ) ) AND ( (salesaccnt_custtype='.*') OR ( (salesaccnt_custtype_id=-1) AND (salesaccnt_custtype<>'') AND (custtype_code ~ salesaccnt_custtype) ) OR ( (salesaccnt_custtype_id=custtype_id) ) ) AND ( (salesaccnt_shipzone_id=-1) OR (salesaccnt_shipzone_id=pShipzoneid) ) AND ( (salesaccnt_saletype_id=-1) OR (salesaccnt_saletype_id=pSaletypeid) ) AND (itemsite_id=pid) AND (cust_id=pCustid) ) ORDER BY orderby DESC, salesaccnt_custtype DESC, salesaccnt_prodcat DESC, salesaccnt_warehous_id DESC, salesaccnt_saletype_id DESC, salesaccnt_shipzone_id DESC LIMIT 1; ELSE RETURN -2; -- invalid pidType END IF; IF (FOUND) THEN RETURN _s.salesaccnt_id; END IF; RETURN -1; END; $$; {DROP FUNCTION public.findsalesaccnt(pid integer, pidtype text, pcustid integer, psaletypeid integer, pshipzoneid integer); publicadminfalse84623125578477)findspecialfinancial(text, text, integer)FUNCTIONCREATE FUNCTION findspecialfinancial(text, text, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUnit ALIAS FOR $1; pType ALIAS FOR $2; pPeriodid ALIAS FOR $3; _value NUMERIC; BEGIN _value := 0.00; IF ('OpenAR' = pType) THEN IF ( pUnit IN ('D','E') ) THEN SELECT SUM( CASE WHEN (aropen_doctype IN ('C', 'R')) THEN ((aropen_amount - aropen_paid) * -1) ELSE (aropen_amount - aropen_paid) END ) INTO _value FROM aropen, period WHERE ((aropen_open) AND (aropen_duedate BETWEEN period_start AND period_end) AND (period_id=pPeriodid)); IF ('E' = pUnit) THEN _value := 0.00 - _value; END IF; END IF; END IF; IF ('OpenAP' = pType) THEN IF ( pUnit IN ('C','E') ) THEN SELECT SUM( CASE WHEN (apopen_doctype='C') THEN ((apopen_amount - apopen_paid) * -1) ELSE (apopen_amount - apopen_paid) END ) INTO _value FROM apopen, period WHERE ((apopen_open) AND (apopen_duedate BETWEEN period_start AND period_end) AND (period_id=pPeriodid)); END IF; END IF; RETURN _value; END; $_$; @DROP FUNCTION public.findspecialfinancial(text, text, integer); publicadminfalse46238125578478!first_agg(anyelement, anyelement)FUNCTIONCREATE FUNCTION first_agg(anyelement, anyelement) RETURNS anyelement LANGUAGE sql STABLE AS $_$ SELECT CASE WHEN $1 IS NULL THEN $2 ELSE $1 END; $_$; 8DROP FUNCTION public.first_agg(anyelement, anyelement); publicadminfalse8125578479firstline(text)FUNCTIONCREATE FUNCTION firstline(text) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSource ALIAS FOR $1; _result TEXT := ''; BEGIN SELECT regexp_replace(pSource, E'^(\r?\n)*([^\r\n]*)\r?\n.*', E'\\2') INTO _result; RETURN _result; END; $_$; &DROP FUNCTION public.firstline(text); publicadminfalse46238125578480fixacl()FUNCTIONCREATE FUNCTION fixacl() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; _count INTEGER := 0; _oldgrp BOOLEAN := false; _objtype TEXT; _table TEXT; _schema TEXT; BEGIN IF EXISTS(SELECT 1 FROM pg_group WHERE groname = 'openmfg') THEN _oldgrp := true; END IF; FOR _r IN SELECT relname, nspname, relkind, CASE relkind WHEN 'r' THEN 1 WHEN 'v' THEN 2 WHEN 'S' THEN 3 ELSE 4 END AS seq FROM pg_catalog.pg_class c, pg_namespace n WHERE ((n.oid=c.relnamespace) AND (nspname in ('public', 'api') OR nspname in (SELECT pkghead_name FROM pkghead)) AND (relkind in ('S', 'r', 'v'))) ORDER BY seq LOOP _schema := quote_ident(_r.nspname); _table := quote_ident(_r.relname); RAISE DEBUG '%.%', _schema, _table; IF (_oldgrp) THEN EXECUTE 'REVOKE ALL ON ' || _schema || '.' || _table || ' FROM openmfg;'; END IF; EXECUTE 'REVOKE ALL ON ' || _schema || '.' || _table || ' FROM PUBLIC;'; EXECUTE 'GRANT ALL ON ' || _schema || '.' || _table || ' TO GROUP xtrole;'; _count := _count + 1; _objtype := CASE _r.relkind WHEN 'S' THEN 'SEQUENCE' WHEN 'r' THEN 'TABLE' WHEN 'v' THEN 'VIEW' ELSE NULL END; IF (_objtype IS NOT NULL) THEN BEGIN EXECUTE 'ALTER ' || _objtype || ' ' || _schema || '.' || _table || ' OWNER TO admin;'; EXCEPTION WHEN OTHERS THEN RAISE WARNING 'Could not change ownership of %.% to admin', _schema, _table; END; END IF; END LOOP; RETURN _count; END; $$; DROP FUNCTION public.fixacl(); publicadminfalse84623125587021'formatabachecks(integer, integer, text)FUNCTION0CREATE FUNCTION formatabachecks(integer, integer, text) RETURNS SETOF achline LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pbankaccntid ALIAS FOR $1; -- all unprinted checks for this bankaccnt pcheckheadid ALIAS FOR $2; -- but if 2nd arg not null then just 1 check penckey ALIAS FOR $3; _bank RECORD; _batchcount INTEGER := 0; _batchdate DATE; _check RECORD; _vendnumber TEXT; _vendname TEXT; _filenum TEXT; _prevsec TEXT; _row achline%ROWTYPE; _totalcr NUMERIC := 0; _totaldb NUMERIC := 0; _detailcount INTEGER := 0; -- count of type 1 entries _vendbsb TEXT; BEGIN -- General notes: -- Numeric values are formatted using RPAD(TO_CHAR(#, '0..0SG', #)). -- TO_CHAR(#, ...) (at least in the default server locale) puts a space at -- the beginning of the string for numbers >= 0 and '-' for numbers < 0. -- 'SG' pushes the sign char to the end, then RPAD cuts it off. -- This whole thing is for Australian bank transactions only, and generates entries for an ABA file. -- Currently restricted to checks to Vendor; there's no support for checks to -- customers or tax authorities, or for debits or corrections. -- This function has been adapted from the US-centric ACH formatACHChecks function. IF (NOT fetchMetricBool('ACHEnabled')) THEN RAISE EXCEPTION 'Cannot format the ABA file because the system is not configured for ABA file generation.'; END IF; IF (LENGTH(COALESCE(penckey, '')) <= 0) THEN RAISE EXCEPTION 'Cannot format the ABA file because there is no encryption key.'; END IF; SELECT * INTO _bank FROM bankaccnt WHERE (bankaccnt_id=pbankaccntid); IF (NOT FOUND) THEN RAISE EXCEPTION 'Could not find the bank information to create the ABA file.'; ELSIF (NOT _bank.bankaccnt_ach_enabled) THEN RAISE EXCEPTION 'Cannot format the ABA file because the Bank Account % is not configured for ABA transactions.', _bank.bankaccnt_name; ELSIF (LENGTH(COALESCE(_bank.bankaccnt_routing, '')) <= 0) THEN RAISE EXCEPTION 'Cannot format the ABA file because the Bank Account % has no BSB number.', _bank.bankaccnt_name; END IF; -- Check the BSB number is in the right format and then re-format for output. -- Valid format is \d{3}-\d{3}|\d{6}000 IF (_bank.bankaccnt_routing ~ E'^(\\d{3})(?:-(?=\\d{3}$)|(?=\\d{3}0{3}$))(\\d{3})(0{3})?$') THEN _bank.bankaccnt_routing := regexp_replace( _bank.bankaccnt_routing, E'^(\\d{3})(?:-(?=\\d{3}$)|(?=\\d{3}0{3}$))(\\d{3})(0{3})?$', E'\\1-\\2' ); ELSE RAISE EXCEPTION 'Cannot format the ABA file because the Bank Account % has an invalid BSB number.', _bank.bankaccnt_name; END IF; _filenum := LPAD(fetchNextNumber('ACHBatch'), 8, '0'); IF (COALESCE(_bank.bankaccnt_ach_lastdate,startOfTime()) < CURRENT_DATE OR _bank.bankaccnt_ach_lastfileid IS NULL) THEN _bank.bankaccnt_ach_lastfileid = '0'; ELSIF (_bank.bankaccnt_ach_lastfileid = '9') THEN _bank.bankaccnt_ach_lastfileid = 'A'; ELSIF (_bank.bankaccnt_ach_lastfileid = 'Z') THEN RAISE EXCEPTION 'Cannot write % check % to an ABA file because too many files have been written for this bank already today.', _bank.bankaccnt_name, _check.checkhead_number; ELSE _bank.bankaccnt_ach_lastfileid = CHR(ASCII(_bank.bankaccnt_ach_lastfileid) + 1); END IF; _row.achline_checkhead_id := NULL; _row.achline_batch := _filenum; _row.achline_type := 'HEADER'; _row.achline_value := RPAD( RPAD('0',18) -- Record Type 0 blank filled with 17 spaces || '01' -- Reel sequence number || RPAD(_bank.bankaccnt_bankname,3) -- Approved financial instition abbreviation. || RPAD('',7) -- blank filled || RPAD(fetchMetricText('ACHCompanyName'), 26) -- Name of user supplying ABA file || LPAD(fetchMetricText('ACHCompanyId'),6) -- User identification number APCA issued || RPAD('PAYMENT',12) -- description of entries on file -- currently only use payment description || TO_CHAR(CURRENT_DATE, 'DDMMYY'), -- date to be processed 120 -- blank filled to 120 characters ); RETURN NEXT _row; FOR _check IN SELECT * FROM checkhead JOIN vendinfo ON (checkhead_recip_type='V' AND checkhead_recip_id=vend_id AND vend_ach_enabled) JOIN curr_symbol ON (checkhead_curr_id=curr_id) LEFT OUTER JOIN crmacct ON (crmacct_vend_id=vend_id) WHERE ((checkhead_bankaccnt_id=pbankaccntid) AND (checkhead_amount > 0) AND (checkhead_id=pcheckheadid OR pcheckheadid IS NULL) AND NOT checkhead_posted AND NOT checkhead_replaced AND NOT checkhead_deleted AND NOT checkhead_void AND NOT checkhead_printed AND (LENGTH(COALESCE(checkhead_ach_batch,'')) <= 0) AND (curr_abbr='AUD')) ORDER BY checkhead_checkdate, vend_name LOOP IF (COALESCE(_check.checkhead_number, -1) <= 0 AND _bank.bankaccnt_ach_genchecknum) THEN _check.checkhead_number := fetchNextCheckNumber(_check.checkhead_bankaccnt_id); END IF; -- Although a crmacct record is not required for used in this function -- this code is retained for consistancy with the original formatachchecks function. IF (_check.crmacct_id IS NULL) THEN RAISE WARNING 'Vendor % does not have a corresponding crmacct record.', _check.checkhead_recip_id; ELSIF (_check.crmacct_type IS NULL) THEN RAISE WARNING 'crmacct for vendor % does not have a valid crmacct_type.', _check.checkhead_recip_id; END IF; _vendnumber := CASE WHEN _check.vend_ach_use_vendinfo THEN _check.vend_number ELSE _check.vend_ach_indiv_number END; _vendname := CASE WHEN _check.vend_ach_use_vendinfo THEN _check.vend_name ELSE _check.vend_ach_indiv_name END; IF (COALESCE(_check.vend_ach_routingnumber, '') = '') THEN RAISE EXCEPTION 'Cannot write % check % to an ABA file because the BSB number for % has not been supplied.', _bank.bankaccnt_name, _check.checkhead_number, _vendnumber; ELSIF (COALESCE(_check.vend_ach_accntnumber, '') = '') THEN RAISE EXCEPTION 'Cannot write % check % to an ABA file because the account number for % has not been supplied.', _bank.bankaccnt_name, _check.checkhead_number, _vendnumber; END IF; _check.vend_ach_routingnumber := decrypt(setbytea(_check.vend_ach_routingnumber), setbytea(penckey), 'bf'); _check.vend_ach_accntnumber := decrypt(setbytea(_check.vend_ach_accntnumber), setbytea(penckey), 'bf'); -- Check the BSB number is in the right format and then re-format for output. -- Valid format is \d{3}-\d{3}|\d{6}000 IF (formatbytea(_check.vend_ach_routingnumber) ~ E'^(\\d{3})(?:-(?=\\d{3}$)|(?=\\d{3}0{3}$))(\\d{3})(0{3})?$') THEN _vendbsb := regexp_replace( formatbytea(_check.vend_ach_routingnumber), E'^(\\d{3})(?:-(?=\\d{3}$)|(?=\\d{3}0{3}$))(\\d{3})(0{3})?$', E'\\1-\\2' ); ELSE RAISE EXCEPTION 'Cannot write % check % to an ABA file because the BSB number for % is not valid.', _bank.bankaccnt_name, _check.checkhead_number, _vendnumber; END IF; _row.achline_checkhead_id := _check.checkhead_id; _row.achline_batch := _filenum; _row.achline_type := 'DETAIL'; _totaldb := _totaldb + _check.checkhead_amount; -- Total debits for balancing entry _detailcount := _detailcount + 1; -- Detail record counter (type 1) _totalcr := _totalcr + _check.checkhead_amount; -- Total credits from payments _row.achline_value := RPAD('1' -- record type 1 || _vendbsb -- vendor BSB # || LPAD(formatbytea(_check.vend_ach_accntnumber), 9) -- vendor account no. ||' ' -- withholding tax indicator ||'50' -- transaction code, this should be calculated. || LPAD(to_char(_check.checkhead_amount,'FM99999999V99'),10,'0') -- amount || RPAD(_vendname, 32) -- vendor name || RPAD('Deposit',8) || RPAD('#' , 2) || LPAD (_filenum,8,' ') -- Lodgement Reference || _bank.bankaccnt_routing -- BSB # || RPAD(_bank.bankaccnt_accntnumber, 9) -- company account number || RPAD(fetchMetricText('ACHCompanyName'), 16) -- company account name || LPAD('', 8, '0'), -- Witholding Tax Amount 120 -- line width ); RETURN NEXT _row; UPDATE checkhead SET checkhead_ach_batch=_filenum, checkhead_number=_check.checkhead_number WHERE (checkhead_id=_check.checkhead_id); END LOOP; IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot write an ABA file for % because there are no checks pending in AUD for EFT-enabled Vendors.', _bank.bankaccnt_name; END IF; -- Place a final balancing detail record. -- Check that the balancing record actually balances. IF (_totalcr != _totaldb) THEN RAISE EXCEPTION 'Cannot write an ABA file for % because the total credits: % does not equal the total debits: %, file will not balance.', _bank.bankaccnt_name, _totalcr, _totaldb; END IF; _detailcount := _detailcount + 1; _row.achline_checkhead_id := NULL; _row.achline_batch := _filenum; _row.achline_type := 'BALANCING'; -- keep in sync with the other batchcontrol record format above -- THE FOLLOWING IS THE DEBIT BALANCING RECORD _row.achline_value := RPAD('1' -- record type 1 || _bank.bankaccnt_routing -- Austalian BSB # || LPAD(_bank.bankaccnt_accntnumber, 9) -- company account no. || ' ' -- withholding tax indicator || '13' -- transaction code || to_char(_totaldb,'FM09999999V99') -- the balancing amount || RPAD(fetchMetricText('ACHCompanyName'), 32) -- company name || RPAD('DIRECT DEPOSIT',18) || _bank.bankaccnt_routing -- Austalian BSB # || RPAD(_bank.bankaccnt_accntnumber, 9) -- company account number || RPAD(fetchMetricText('ACHCompanyName'), 16) -- company account name || LPAD('', 8, '0'), -- Witholding Tax Amount 120 -- line width ); RETURN NEXT _row; RAISE DEBUG 'formatABAChecks building TRAILER with _totaldb %, _totalcr %, _detailcount %', _totaldb, _totalcr, _detailcount; -- file control record _row.achline_checkhead_id := NULL; _row.achline_batch := _filenum; _row.achline_type := 'TRAILER'; _row.achline_value := RPAD('7' -- record type 7 || RPAD('999-999', 7) -- BSB format filler || RPAD('' , 12) -- blank || LPAD(to_char((_totaldb - _totalcr),'FM09999999V99'),10,'0') -- net total amount || LPAD(to_char(_totalcr, 'FM09999999V99'),10,'0') -- total credit amount || LPAD(to_char(_totaldb, 'FM09999999V99'),10,'0') -- total debit amount || RPAD('', 24) -- blank || RPAD(to_char(_detailcount, 'FM000000'), 6,'0'), -- count of type 1 records 120 -- blank fill ); RETURN NEXT _row; UPDATE bankaccnt SET bankaccnt_ach_lastdate=CURRENT_DATE, bankaccnt_ach_lastfileid=_bank.bankaccnt_ach_lastfileid WHERE (bankaccnt_id=_bank.bankaccnt_id); RETURN; END; $_$; >DROP FUNCTION public.formatabachecks(integer, integer, text); publicadminfalse842284623125587023'formatachchecks(integer, integer, text)FUNCTION~CCREATE FUNCTION formatachchecks(integer, integer, text) RETURNS SETOF achline LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pbankaccntid ALIAS FOR $1; -- all unprinted checks for this bankaccnt pcheckheadid ALIAS FOR $2; -- but if 2nd arg not null then just 1 check penckey ALIAS FOR $3; _bank RECORD; _batchcount INTEGER := 0; _batchcr NUMERIC := 0; _batchdate DATE; _batchdb NUMERIC := 0; _batchhash INTEGER := 0; _check RECORD; _ccdnumber TEXT; _ccdname TEXT; _entrycount INTEGER := 0; _filenum TEXT; _prevsec TEXT; _row achline%ROWTYPE; _rowcount INTEGER := 0; _sec TEXT; _serviceclass TEXT := '200'; -- 220 = credits, 225 = debits, 200 = mixed _totalcr NUMERIC := 0; _totaldb NUMERIC := 0; _totalentrycnt INTEGER := 0; _totalhash INTEGER := 0; _transactionprefix TEXT; BEGIN -- General notes: -- Numeric values are formatted using RPAD(TO_CHAR(#, '0..0SG', #)). -- TO_CHAR(#, ...) (at least in the default server locale) puts a space at -- the beginning of the string for numbers >= 0 and '-' for numbers < 0. -- 'SG' pushes the sign char to the end, then RPAD cuts it off. -- This whole thing is US-centric, as that's where the NACHA is. -- Currently restricted to checks to Vendor; there's no support for checks to -- customers or tax authorities, or for debits or corrections. IF (NOT fetchMetricBool('ACHEnabled')) THEN RAISE EXCEPTION 'Cannot format the ACH file because the system is not configured for ACH file generation.'; END IF; IF (LENGTH(COALESCE(penckey, '')) <= 0) THEN RAISE EXCEPTION 'Cannot format the ACH file because there is no encryption key.'; END IF; SELECT * INTO _bank FROM bankaccnt WHERE (bankaccnt_id=pbankaccntid); IF (NOT FOUND) THEN RAISE EXCEPTION 'Could not find the bank information to create the ACH file.'; ELSIF (NOT _bank.bankaccnt_ach_enabled) THEN RAISE EXCEPTION 'Cannot format the ACH file because the Bank Account % is not configured for ACH transactions.', _bank.bankaccnt_name; ELSIF (LENGTH(COALESCE(_bank.bankaccnt_routing, '')) <= 0) THEN RAISE EXCEPTION 'Cannot format the ACH file because the Bank Account % has no routing number.', _bank.bankaccnt_name; END IF; _filenum := LPAD(fetchNextNumber('ACHBatch'), 8, '0'); IF (COALESCE(_bank.bankaccnt_ach_lastdate,startOfTime()) < CURRENT_DATE OR _bank.bankaccnt_ach_lastfileid IS NULL) THEN _bank.bankaccnt_ach_lastfileid = '0'; ELSIF (_bank.bankaccnt_ach_lastfileid = '9') THEN _bank.bankaccnt_ach_lastfileid = 'A'; ELSIF (_bank.bankaccnt_ach_lastfileid = 'Z') THEN RAISE EXCEPTION 'Cannot write % check % to an ACH file because too many files have been written for this bank already today.', _bank.bankaccnt_name, _check.checkhead_number; ELSE _bank.bankaccnt_ach_lastfileid = CHR(ASCII(_bank.bankaccnt_ach_lastfileid) + 1); END IF; _rowcount := _rowcount + 1; _row.achline_checkhead_id := NULL; _row.achline_batch := _filenum; _row.achline_type := 'FILEHEADER'; _row.achline_value := RPAD('1' || '01' || RPAD(CASE WHEN _bank.bankaccnt_ach_desttype = 'B' THEN ' ' || _bank.bankaccnt_routing WHEN _bank.bankaccnt_ach_desttype = 'F' THEN ' ' || _bank.bankaccnt_ach_fed_dest ELSE _bank.bankaccnt_ach_dest END, 10) || RPAD(CASE WHEN _bank.bankaccnt_ach_origintype = 'B' THEN ' ' || _bank.bankaccnt_routing WHEN _bank.bankaccnt_ach_origintype = 'I' THEN formatAchCompanyId() ELSE _bank.bankaccnt_ach_origin END, 10) || TO_CHAR(CURRENT_DATE, 'YYMMDD') || TO_CHAR(CURRENT_TIMESTAMP, 'HH24MM') || UPPER(_bank.bankaccnt_ach_lastfileid) || '094' || '10' || '1' || RPAD(CASE WHEN _bank.bankaccnt_ach_desttype = 'B' THEN _bank.bankaccnt_bankname WHEN _bank.bankaccnt_ach_desttype = 'F' THEN 'Federal Reserve' ELSE _bank.bankaccnt_ach_destname END, 23) || RPAD(CASE WHEN _bank.bankaccnt_ach_origintype = 'B' THEN ' ' || _bank.bankaccnt_bankname WHEN _bank.bankaccnt_ach_origintype = 'I' THEN fetchMetricText('ACHCompanyName') ELSE _bank.bankaccnt_ach_originname END, 23) || RPAD(_filenum, 8), 94); RETURN NEXT _row; FOR _check IN SELECT * FROM checkhead JOIN vendinfo ON (checkhead_recip_type='V' AND checkhead_recip_id=vend_id AND vend_ach_enabled) JOIN curr_symbol ON (checkhead_curr_id=curr_id) LEFT OUTER JOIN crmacct ON (crmacct_vend_id=vend_id) WHERE ((checkhead_bankaccnt_id=pbankaccntid) AND (checkhead_amount > 0) AND (checkhead_id=pcheckheadid OR pcheckheadid IS NULL) AND NOT checkhead_posted AND NOT checkhead_replaced AND NOT checkhead_deleted AND NOT checkhead_void AND NOT checkhead_printed AND (LENGTH(COALESCE(checkhead_ach_batch,'')) <= 0) AND (curr_abbr='USD')) ORDER BY checkhead_checkdate, vend_name LOOP IF (COALESCE(_check.checkhead_number, -1) <= 0 AND _bank.bankaccnt_ach_genchecknum) THEN _check.checkhead_number := fetchNextCheckNumber(_check.checkhead_bankaccnt_id); END IF; _prevsec := _sec; IF (_check.crmacct_type = 'I') THEN _sec := 'PPD'; ELSE _sec := 'CCD'; IF (_check.crmacct_id IS NULL) THEN RAISE WARNING 'Vendor % does not have a corresponding crmacct record.', _check.checkhead_recip_id; ELSIF (_check.crmacct_type IS NULL) THEN RAISE WARNING 'crmacct for vendor % does not have a valid crmacct_type.', _check.checkhead_recip_id; END IF; END IF; _ccdnumber := CASE WHEN _check.vend_ach_use_vendinfo THEN _check.vend_number ELSE _check.vend_ach_indiv_number END; _ccdname := CASE WHEN _check.vend_ach_use_vendinfo THEN _check.vend_name ELSE _check.vend_ach_indiv_name END; IF (COALESCE(_check.vend_ach_routingnumber, '') = '') THEN RAISE EXCEPTION 'Cannot write % check % to an ACH file because the routing number for % has not been supplied.', _bank.bankaccnt_name, _check.checkhead_number, _ccdnumber; ELSIF (COALESCE(_check.vend_ach_accntnumber, '') = '') THEN RAISE EXCEPTION 'Cannot write % check % to an ACH file because the account number for % has not been supplied.', _bank.bankaccnt_name, _check.checkhead_number, _ccdnumber; END IF; _check.vend_ach_routingnumber := decrypt(setbytea(_check.vend_ach_routingnumber), setbytea(penckey), 'bf'); _check.vend_ach_accntnumber := decrypt(setbytea(_check.vend_ach_accntnumber), setbytea(penckey), 'bf'); _transactionprefix := CASE WHEN (_check.vend_ach_accnttype = 'K') THEN '2' WHEN (_check.vend_ach_accnttype = 'C') THEN '3' END; -- create separate batches for each check date and for PPD vs CCD IF (COALESCE(_batchdate, startOfTime()) != _check.checkhead_checkdate OR (_prevsec != _sec)) THEN IF (_batchcount > 0) THEN _rowcount := _rowcount + 1; _row.achline_checkhead_id := NULL; _row.achline_batch := _filenum; _row.achline_type := 'BATCHCONTROL'; -- keep in sync with the other batchcontrol record format below _row.achline_value := RPAD('8' || _serviceclass || RPAD(TO_CHAR(_entrycount, '000000SG'), 6) || RPAD(TO_CHAR(_batchhash % 10000000000, '0000000000SG'), 10) || RPAD(TO_CHAR(_batchdb, '0000000000V99SG'), 12) || RPAD(TO_CHAR(_batchcr, '0000000000V99SG'), 12) || RPAD(formatAchCompanyId(), 10) || RPAD(' ', 19) || RPAD(' ', 6) || RPAD(_bank.bankaccnt_routing, 8) || RPAD(TO_CHAR(_batchcount, '0000000SG'), 7), 94); RETURN NEXT _row; END IF; _batchhash := 0; _batchcr := 0; _batchdb := 0; _batchdate := _check.checkhead_checkdate; _entrycount := 0; _rowcount := _rowcount + 1; _batchcount := _batchcount + 1; _row.achline_checkhead_id := NULL; _row.achline_batch := _filenum; _row.achline_type := 'BATCHHEADER'; -- effective entry date = 1 or 2 banking days after the banking day -- of processing (the following accounts for weekends but not holidays) _row.achline_value := RPAD('5' || _serviceclass || RPAD(fetchMetricText('ACHCompanyName'), 16) || RPAD('', 20) -- TODO: find a use || RPAD(formatAchCompanyId(), 10) || _sec || RPAD('xTuple ERP', 10) || TO_CHAR(_check.checkhead_checkdate, 'YYMMDD') || TO_CHAR(CURRENT_DATE + COALESCE(_bank.bankaccnt_ach_leadtime,1) + CASE WHEN EXTRACT(DOW FROM CURRENT_DATE) = 5 THEN 2 WHEN EXTRACT(DOW FROM CURRENT_DATE) = 6 THEN 1 ELSE 0 END, 'YYMMDD') || RPAD('', 3) || '1' || RPAD(_bank.bankaccnt_routing, 8) || RPAD(TO_CHAR(_batchcount, '0000000SG'), 7), 94); RETURN NEXT _row; END IF; _row.achline_checkhead_id := _check.checkhead_id; _row.achline_batch := _filenum; _row.achline_type := _sec; IF (_sec = 'CCD' OR _sec = 'PPD') THEN _rowcount := _rowcount + 1; _entrycount := _entrycount + 1; _totalentrycnt := _totalentrycnt + 1; _batchhash := _batchhash + CAST(SUBSTRING(_bank.bankaccnt_routing FOR 8) AS INTEGER); _totalhash := _totalhash + CAST(SUBSTRING(_bank.bankaccnt_routing FOR 8) AS INTEGER); _batchdb := _batchdb + _check.checkhead_amount; _totaldb := _totaldb + _check.checkhead_amount; _row.achline_value := RPAD('6' || _transactionprefix || '7' -- debit || RPAD(_bank.bankaccnt_routing, 9) -- 2 fields || RPAD(_bank.bankaccnt_accntnumber, 17) || RPAD(TO_CHAR(_check.checkhead_amount, '00000000V99SG'), 10) || RPAD(fetchMetricText('ACHCompanyId'), 15) || RPAD(fetchMetricText('ACHCompanyName'), 22) || RPAD(TO_CHAR(_check.checkhead_id % 100, '00SG'), 2) -- last 2 digits of checkhead_id || '0' || RPAD(_bank.bankaccnt_routing, 9) -- split field || RPAD(TO_CHAR(_entrycount, '000000SG'), 15-9), 94); RETURN NEXT _row; _rowcount := _rowcount + 1; _entrycount := _entrycount + 1; _totalentrycnt := _totalentrycnt + 1; _batchhash := _batchhash + CAST(SUBSTRING(formatbytea(_check.vend_ach_routingnumber) FOR 8) AS INTEGER); _totalhash := _totalhash + CAST(SUBSTRING(formatbytea(_check.vend_ach_routingnumber) FOR 8) AS INTEGER); _totalcr := _totalcr + _check.checkhead_amount; _batchcr := _batchcr + _check.checkhead_amount; _row.achline_value := RPAD('6' || _transactionprefix || '2' -- credit || RPAD(formatbytea(_check.vend_ach_routingnumber), 9) -- 2 fields || RPAD(formatbytea(_check.vend_ach_accntnumber), 17) || RPAD(TO_CHAR(_check.checkhead_amount, '00000000V99SG'), 10) || RPAD(_ccdnumber, 15) || RPAD(_ccdname, 22) || RPAD(TO_CHAR(_check.checkhead_id % 100, '00SG'), 2) -- last 2 digits of checkhead_id || '0' || RPAD(_bank.bankaccnt_routing, 9) -- split field || RPAD(TO_CHAR(_entrycount, '000000SG'), 15-9), 94); RETURN NEXT _row; ELSE RAISE EXCEPTION 'Cannot write % check % to an ACH file because % is not a supported SEC code.', _bank.bankaccnt_name, _check.checkhead_number, _sec; END IF; UPDATE checkhead SET checkhead_ach_batch=_filenum, checkhead_number=_check.checkhead_number WHERE (checkhead_id=_check.checkhead_id); END LOOP; IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot write an ACH file for % because there are no checks pending in USD for ACH-enabled Vendors.', _bank.bankaccnt_name; END IF; -- place a final batch control record IF (_batchcount > 0) THEN _rowcount := _rowcount + 1; _row.achline_checkhead_id := NULL; _row.achline_batch := _filenum; _row.achline_type := 'BATCHCONTROL'; -- keep in sync with the other batchcontrol record format above _row.achline_value := RPAD('8' || _serviceclass || RPAD(TO_CHAR(_entrycount, '000000SG'), 6) || RPAD(TO_CHAR(_batchhash % 10000000000, '0000000000SG'), 10) || RPAD(TO_CHAR(_batchdb, '0000000000V99SG'), 12) || RPAD(TO_CHAR(_batchcr, '0000000000V99SG'), 12) || RPAD(formatAchCompanyId(), 10) || RPAD(' ', 19) || RPAD(' ', 6) || RPAD(_bank.bankaccnt_routing, 8) || RPAD(TO_CHAR(_batchcount, '0000000SG'), 7), 94); RETURN NEXT _row; END IF; -- and end with a file control record _rowcount := _rowcount + 1; _row.achline_checkhead_id := NULL; _row.achline_batch := _filenum; _row.achline_type := 'FILECONTROL'; _row.achline_value := RPAD('9' || RPAD(TO_CHAR(_batchcount, '000000SG'), 6) || RPAD(TO_CHAR(_rowcount, '000000SG'), 6) || RPAD(TO_CHAR(_totalentrycnt, '00000000SG'), 8) || RPAD(TO_CHAR(_totalhash % 10000000000, '0000000000SG'), 10) || RPAD(TO_CHAR(_totaldb, '0000000000V99SG'), 12) || RPAD(TO_CHAR(_totalcr, '0000000000V99SG'), 12) || RPAD('', 39), 94); RETURN NEXT _row; -- file must be a multiple of 10 lines long _row.achline_checkhead_id := NULL; _row.achline_batch := _filenum; _row.achline_type := 'BLOCKFILL'; WHILE (_rowcount % 10 > 0) LOOP _rowcount := _rowcount + 1; _row.achline_value := RPAD('99999999999999999999' || '99999999999999999999' || '99999999999999999999' || '99999999999999999999' || '99999999999999999999', 94); RETURN NEXT _row; END LOOP; UPDATE bankaccnt SET bankaccnt_ach_lastdate=CURRENT_DATE, bankaccnt_ach_lastfileid=_bank.bankaccnt_ach_lastfileid WHERE (bankaccnt_id=_bank.bankaccnt_id); RETURN; END; $_$; >DROP FUNCTION public.formatachchecks(integer, integer, text); publicadminfalse422846238125578485formatachcompanyid()FUNCTIONCREATE FUNCTION formatachcompanyid() RETURNS text LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN CASE WHEN fetchMetricText('ACHCompanyIdType') = 'D' THEN '3' WHEN fetchMetricText('ACHCompanyIdType') = 'E' THEN '1' WHEN fetchMetricText('ACHCompanyIdType') = 'O' THEN '9' END || CASE WHEN fetchMetricText('ACHCompanyIdType') = 'D' OR fetchMetricText('ACHCompanyIdType') = 'E' THEN REPLACE(fetchMetricText('ACHCompanyId'), '-', '') ELSE fetchMetricText('ACHCompanyId') END; END; $$; +DROP FUNCTION public.formatachcompanyid(); publicadminfalse84623125578486formataddr(integer)FUNCTIONKCREATE FUNCTION formataddr(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAddrId ALIAS FOR $1; _return TEXT; BEGIN -- US conventions SELECT formatAddr(addr_line1, addr_line2, addr_line3, (COALESCE(addr_city,'') || ', ' || COALESCE(addr_state,'') || ' ' || COALESCE(addr_postalcode,'')), addr_country) INTO _return FROM addr WHERE (addr_id=pAddrId); RETURN _return; END; $_$; *DROP FUNCTION public.formataddr(integer); publicadminfalse84623125578487+formataddr(text, text, text, text, integer)FUNCTIONCREATE FUNCTION formataddr(text, text, text, text, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE f_addr1 ALIAS FOR $1; f_addr2 ALIAS FOR $2; f_addr3 ALIAS FOR $3; csz ALIAS FOR $4; line ALIAS FOR $5; BEGIN RETURN formatAddr(f_addr1, f_addr2, f_addr3, csz, '', line); END; $_$; BDROP FUNCTION public.formataddr(text, text, text, text, integer); publicadminfalse84623125578488(formataddr(text, text, text, text, text)FUNCTIONCREATE FUNCTION formataddr(text, text, text, text, text) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE f_addr1 ALIAS FOR $1; f_addr2 ALIAS FOR $2; f_addr3 ALIAS FOR $3; csz ALIAS FOR $4; country ALIAS FOR $5; addr TEXT:=''; BEGIN IF (LENGTH(TRIM(both from f_addr1)) > 0) THEN addr:=f_addr1; END IF; IF (LENGTH(TRIM(both from f_addr2)) > 0) THEN IF (LENGTH(TRIM(both from addr)) > 0) THEN addr:=addr || E'\n'; END IF; addr:=addr || f_addr2; END IF; IF (LENGTH(TRIM(both from f_addr3)) > 0) THEN IF (LENGTH(TRIM(both from addr)) > 0) THEN addr:=addr || E'\n'; END IF; addr:=addr || f_addr3; END IF; IF (LENGTH(TRIM(both from csz)) > 0) THEN IF (LENGTH(TRIM(both from addr)) > 0) THEN addr:=addr || E'\n'; END IF; addr:=addr || csz; END IF; IF (LENGTH(TRIM(both from country)) > 0) THEN IF (LENGTH(TRIM(both from addr)) > 0) THEN addr:=addr || E'\n'; END IF; addr:=addr || country; END IF; RETURN addr; END; $_$; ?DROP FUNCTION public.formataddr(text, text, text, text, text); publicadminfalse462381255784891formataddr(text, text, text, text, text, integer)FUNCTION CREATE FUNCTION formataddr(text, text, text, text, text, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE f_addr1 ALIAS FOR $1; f_addr2 ALIAS FOR $2; f_addr3 ALIAS FOR $3; csz ALIAS FOR $4; country ALIAS FOR $5; line ALIAS FOR $6; i int:=0; BEGIN IF (LENGTH(TRIM(both from f_addr1)) > 0) THEN i:=i+1; END IF; IF (i=line) THEN RETURN f_addr1; END IF; IF (LENGTH(TRIM(both from f_addr2)) > 0) THEN i:=i+1; END IF; IF (i=line) THEN RETURN f_addr2; END IF; IF (LENGTH(TRIM(both from f_addr3)) > 0) THEN i:=i+1; END IF; IF (i=line) THEN RETURN f_addr3; END IF; IF (LENGTH(TRIM(both from csz)) > 0) THEN i:=i+1; END IF; IF (i=line) THEN RETURN csz; END IF; IF (LENGTH(TRIM(both from country)) > 0) THEN i:=i+1; END IF; IF (i=line) THEN RETURN country; END IF; RETURN ' '; END; $_$; HDROP FUNCTION public.formataddr(text, text, text, text, text, integer); publicadminfalse46238125578490formatboolyn(boolean)FUNCTIONOCREATE FUNCTION formatboolyn(boolean) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBool ALIAS FOR $1; BEGIN IF (pBool) THEN RETURN 'Yes'; ELSE RETURN 'No'; END IF; END; $_$; ,DROP FUNCTION public.formatboolyn(boolean); publicadminfalse46238125578491formatbooseq(integer, integer)FUNCTIONCREATE FUNCTION formatbooseq(integer, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pBooitemSeqId ALIAS FOR $2; _result TEXT; BEGIN IF (fetchMetricBool('Routings')) THEN SELECT booitem_seqnumber::text INTO _result FROM xtmfg.booitem(pItemid) WHERE (booitem_seq_id=pBooitemSeqId); RETURN _result; ELSE RETURN NULL; END IF; END; $_$; 5DROP FUNCTION public.formatbooseq(integer, integer); publicadminfalse84623125578492formatbytea(bytea)FUNCTIONICREATE FUNCTION formatbytea(bytea) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pField ALIAS FOR $1; output_field TEXT; BEGIN output_field := pField; RETURN output_field; END; $_$; )DROP FUNCTION public.formatbytea(bytea); publicadminfalse84623125578493formatccdashes(text, text)FUNCTION!CREATE FUNCTION formatccdashes(text, text) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCCard ALIAS FOR $1; pCCardType ALIAS FOR $2; _returnCard text; card_length integer; BEGIN IF (pCCardType = 'A') THEN _returnCard := pCCard; RETURN _returnCard; END IF; card_length := length(pCcard); if (card_length = 16) THEN _returnCard := substr(pCCard, 1, 4) || '-' || substr(pCCard, 5, 4) || '-' || substr(pCCard, 9, 4) || '-' || substr(pCCard, 13, 4); ELSE _returnCard := substr(pCCard, 1, 4) || '-' || substr(pCCard, 5, 4) || '-' || substr(pCCard, 9, 4) || '-' || substr(pCCard, 13, 1); END IF; RETURN _returnCard; END; $_$; 1DROP FUNCTION public.formatccdashes(text, text); publicadminfalse84623125578494formatccnumber(text)FUNCTIONCREATE FUNCTION formatccnumber(text) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCcardnum ALIAS FOR $1; card_length INTEGER; output_cardnum TEXT; BEGIN card_length := length(pCcardnum); IF (card_length = 13) THEN output_cardnum := '*********' || substr(pCcardnum, 10, 4); END IF; IF (card_length = 14) THEN output_cardnum := '**********' || substr(pCcardnum, 11, 4); END IF; IF (card_length = 15) THEN output_cardnum := '***********' || substr(pCcardnum, 12, 4); END IF; IF (card_length = 16) THEN output_cardnum := '************' || substr(pCcardnum, 13, 4); END IF; RETURN output_cardnum; END; $_$; +DROP FUNCTION public.formatccnumber(text); publicadminfalse46238125578495formatccnumber(bytea)FUNCTIONCREATE FUNCTION formatccnumber(bytea) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCcardnum ALIAS FOR $1; card_length INTEGER; output_cardnum TEXT; BEGIN card_length := length(pCcardnum); IF (card_length = 13) THEN output_cardnum := '*********' || substr(pCcardnum, 10, 4); END IF; IF (card_length = 14) THEN output_cardnum := '**********' || substr(pCcardnum, 11, 4); END IF; IF (card_length = 15) THEN output_cardnum := '***********' || substr(pCcardnum, 12, 4); END IF; IF (card_length = 16) THEN output_cardnum := '************' || substr(pCcardnum, 13, 4); END IF; RETURN output_cardnum; END; $_$; ,DROP FUNCTION public.formatccnumber(bytea); publicadminfalse84623125578496formatcntctname(integer)FUNCTIONCREATE FUNCTION formatcntctname(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCntctId ALIAS FOR $1; _r RECORD; _rows NUMERIC; BEGIN SELECT cntct_honorific, cntct_first_name, cntct_middle, cntct_last_name, cntct_suffix INTO _r FROM cntct WHERE (cntct_id=pCntctId); GET DIAGNOSTICS _rows = ROW_COUNT; IF (_rows = 0) THEN RETURN ''; END IF; RETURN formatCntctName(_r.cntct_honorific, _r.cntct_first_name, _r.cntct_middle, _r.cntct_last_name, _r.cntct_suffix); END; $_$; /DROP FUNCTION public.formatcntctname(integer); publicadminfalse46238125578497-formatcntctname(text, text, text, text, text)FUNCTIONACREATE FUNCTION formatcntctname(text, text, text, text, text) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pHonorific ALIAS FOR $1; pFirstName ALIAS FOR $2; pMiddle ALIAS FOR $3; pLastName ALIAS FOR $4; pSuffix ALIAS FOR $5; _name TEXT := ''; BEGIN IF (LENGTH(TRIM(both from COALESCE(pHonorific,''))) > 0) THEN IF (POSITION('.' IN COALESCE(pHonorific, '')) > 0) THEN _name:= pHonorific; ELSE _name:= pHonorific || '.'; END IF; END IF; IF (LENGTH(TRIM(both from COALESCE(pFirstName,''))) > 0) THEN IF (LENGTH(TRIM(both from _name)) > 0) THEN _name:=_name || ' '; END IF; _name:=_name || pFirstName; END IF; IF (LENGTH(TRIM(both from COALESCE(pMiddle,''))) > 0) THEN IF (LENGTH(TRIM(both from _name)) > 0) THEN _name:=_name || ' '; END IF; IF (POSITION('.' IN COALESCE(pHonorific, '')) > 0) THEN _name:=_name || pMiddle; ELSE _name:=_name || pMiddle || '.'; END IF; END IF; IF (LENGTH(TRIM(both from COALESCE(pLastName,''))) > 0) THEN IF (LENGTH(TRIM(both from _name)) > 0) THEN _name:=_name || ' '; END IF; _name:=_name || pLastName; END IF; IF (LENGTH(TRIM(both from COALESCE(pSuffix,''))) > 0) THEN IF (LENGTH(TRIM(both from _name)) > 0) THEN _name:=_name || ' '; END IF; _name:=_name || pSuffix; END IF; RETURN _name; END; $_$; DDROP FUNCTION public.formatcntctname(text, text, text, text, text); publicadminfalse84623125578498formatcost(numeric)FUNCTIONCREATE FUNCTION formatcost(numeric) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN formatNumeric($1, 'cost'); END;$_$; *DROP FUNCTION public.formatcost(numeric); publicadminfalse84623125578499formatcounttagbarcode(integer)FUNCTIONCREATE FUNCTION formatcounttagbarcode(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCnttagid ALIAS FOR $1; _barcode TEXT; BEGIN SELECT ( E'\138CTXX' || LTRIM(TO_CHAR(LENGTH(invcnt_tagnumber), '00')) || invcnt_tagnumber ) INTO _barcode FROM invcnt WHERE (invcnt_id=pCnttagid); RETURN _barcode; END; $_$; 5DROP FUNCTION public.formatcounttagbarcode(integer); publicadminfalse84623125578500formatcreditmemonumber(integer)FUNCTIONCREATE FUNCTION formatcreditmemonumber(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmheadid ALIAS FOR $1; BEGIN RETURN ( SELECT COALESCE(cmhead_number::TEXT, '') FROM cmhead WHERE (cmhead_id=pCmheadid) ); END; $_$; 6DROP FUNCTION public.formatcreditmemonumber(integer); publicadminfalse46238125578501formatdate(date)FUNCTIONCREATE FUNCTION formatdate(date) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT TO_CHAR($1, COALESCE((SELECT locale_dateformat FROM locale, usr WHERE ((usr_locale_id=locale_id) AND (usr_username=getEffectiveXtUser())) ), 'yyyy-mm-dd') ) AS result $_$; 'DROP FUNCTION public.formatdate(date); publicadminfalse8125578502$formatdate(timestamp with time zone)FUNCTIONCREATE FUNCTION formatdate(timestamp with time zone) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT TO_CHAR($1, COALESCE((SELECT locale_dateformat FROM locale, usr WHERE ((usr_locale_id=locale_id) AND (usr_username=getEffectiveXtUser())) ), 'yyyy-mm-dd' )) AS result $_$; ;DROP FUNCTION public.formatdate(timestamp with time zone); publicadminfalse8125578503formatdate(date, text)FUNCTIONCREATE FUNCTION formatdate(date, text) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pDate ALIAS FOR $1; pString ALIAS FOR $2; BEGIN IF ( (pDate = startOfTime()) OR (pDate = endOfTime()) OR (pDate IS NULL) ) THEN RETURN pString; ELSE RETURN formatDate(pDate); END IF; END; $_$; -DROP FUNCTION public.formatdate(date, text); publicadminfalse46238125578504(formatdatetime(timestamp with time zone)FUNCTION"CREATE FUNCTION formatdatetime(timestamp with time zone) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT TO_CHAR($1, COALESCE((SELECT locale_timestampformat FROM locale, usr WHERE ((usr_locale_id=locale_id) AND (usr_username=getEffectiveXtUser())) ), 'yyyy-mm-dd HH24:MI:SS')) AS result $_$; ?DROP FUNCTION public.formatdatetime(timestamp with time zone); publicadminfalse8125578505+formatdatetime(timestamp without time zone)FUNCTION%CREATE FUNCTION formatdatetime(timestamp without time zone) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT TO_CHAR($1, COALESCE((SELECT locale_timestampformat FROM locale, usr WHERE ((usr_locale_id=locale_id) AND (usr_username=getEffectiveXtUser())) ), 'yyyy-mm-dd HH24:MI:SS')) AS result $_$; BDROP FUNCTION public.formatdatetime(timestamp without time zone); publicadminfalse8125578506formatextprice(numeric)FUNCTIONCREATE FUNCTION formatextprice(numeric) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN formatNumeric($1, 'extprice'); END;$_$; .DROP FUNCTION public.formatextprice(numeric); publicadminfalse46238125578507formatflitemdescrip(integer)FUNCTION CREATE FUNCTION formatflitemdescrip(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlitemId ALIAS FOR $1; _x RECORD; _descrip TEXT; BEGIN SELECT flitem_accnt_id, flitem_company, flitem_profit, flitem_number, flitem_sub, flitem_type, flitem_subaccnttype_code, accnt_id, accnt_descrip INTO _x FROM flitem LEFT OUTER JOIN accnt ON flitem_accnt_id=accnt_id WHERE flitem_id=pFlitemId; IF _x.flitem_accnt_id > -1 THEN SELECT (formatGLAccount(_x.accnt_id) || '-' || _x.accnt_descrip) INTO _descrip; ELSE _descrip:=''; IF _x.flitem_type = 'A' THEN _descrip:='Type=' || 'Asset'; ELSE IF _x.flitem_type='L' THEN _descrip:='Type=' || 'Liability'; ELSE IF _x.flitem_type='R' THEN _descrip:='Type=' || 'Revenue'; ELSE IF _x.flitem_type='E' THEN _descrip:='Type=' || 'Expense'; ELSE IF _x.flitem_type='Q' THEN _descrip:='Type=' || 'Equity'; END IF; END IF; END IF; END IF; END IF; IF _x.flitem_subaccnttype_code <> 'All' THEN IF (LENGTH(TRIM(both from _descrip)) > 0) THEN _descrip:=_descrip || ', '; END IF; _descrip:=_descrip || 'Sub Accnt Type=' || _x.flitem_subaccnttype_code; END IF; IF _x.flitem_company <> 'All' THEN IF (LENGTH(TRIM(both from _descrip)) > 0) THEN _descrip:=_descrip || ', '; END IF; _descrip:=_descrip || 'Company=' || _x.flitem_company; END IF; IF _x.flitem_profit <> 'All' THEN IF (LENGTH(TRIM(both from _descrip)) > 0) THEN _descrip:=_descrip || ', '; END IF; _descrip:=_descrip || 'Profit=' || _x.flitem_profit; END IF; IF _x.flitem_number <> 'All' THEN IF (LENGTH(TRIM(both from _descrip)) > 0) THEN _descrip:=_descrip || ', '; END IF; _descrip:=_descrip || 'Number=' || _x.flitem_number; END IF; IF _x.flitem_sub <> 'All' THEN IF (LENGTH(TRIM(both from _descrip)) > 0) THEN _descrip:=_descrip || ', '; END IF; _descrip:=_descrip || 'Sub Accnt=' || _x.flitem_sub; END IF; END IF; RETURN _descrip; END; $_$; 3DROP FUNCTION public.formatflitemdescrip(integer); publicadminfalse84623125578508'formatglaccount(text, text, text, text)FUNCTIONCREATE FUNCTION formatglaccount(pcompany text, pprofit text, pnumber text, psub text) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _number TEXT := ''; BEGIN IF (fetchMetricValue('GLCompanySize') > 0) THEN _number := COALESCE(pCompany, '') || '-'; END IF; IF (fetchMetricValue('GLProfitSize') > 0) THEN _number := _number || COALESCE(pProfit, '') || '-'; END IF; _number := _number || pNumber; IF (fetchMetricValue('GLSubaccountSize') > 0) THEN _number := _number || '-' || COALESCE(pSub, ''); END IF; RETURN _number; END; $$; \DROP FUNCTION public.formatglaccount(pcompany text, pprofit text, pnumber text, psub text); publicadminfalse84623125578509formatglaccountlong(integer)FUNCTIONCREATE FUNCTION formatglaccountlong(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAccntid ALIAS FOR $1; _result TEXT; BEGIN SELECT (formatGLAccount(accnt_id) || '-' || accnt_descrip) INTO _result FROM accnt WHERE (accnt_id=pAccntid); RETURN _result; END; $_$; 3DROP FUNCTION public.formatglaccountlong(integer); publicadminfalse46238125578510formatindent(text, integer)FUNCTIONCREATE FUNCTION formatindent(text, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pText ALIAS FOR $1; pIndent ALIAS FOR $2; _i INTEGER; _result TEXT; BEGIN _result := ''; _i := 0; WHILE _i < pIndent LOOP _result := _result || ' '; _i := _i + 1; END LOOP; _result := _result || pText; RETURN _result; END; $_$; 2DROP FUNCTION public.formatindent(text, integer); publicadminfalse84623125578511formatinterval(numeric)FUNCTION<CREATE FUNCTION formatinterval(numeric) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT TO_CHAR(('@ ' || trunc($1) || ' min ' || ($1 - trunc($1)) * 60 || ' sec')::INTERVAL, ( SELECT locale_intervalformat FROM locale, usr WHERE ((usr_locale_id=locale_id) AND (usr_username=getEffectiveXtUser())) ) ) AS result $_$; .DROP FUNCTION public.formatinterval(numeric); publicadminfalse8125578512formatinterval(interval)FUNCTIONCREATE FUNCTION formatinterval(interval) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT TO_CHAR($1, ( SELECT locale_intervalformat FROM locale, usr WHERE ((usr_locale_id=locale_id) AND (usr_username=getEffectiveXtUser())) ) ) AS result $_$; /DROP FUNCTION public.formatinterval(interval); publicadminfalse8125578513formatinvcnumber(integer)FUNCTIONCREATE FUNCTION formatinvcnumber(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCobmiscid ALIAS FOR $1; BEGIN RETURN ( SELECT COALESCE(cobmisc_invcnumber::TEXT, '') FROM cobmisc WHERE (cobmisc_id=pCobmiscid) ); END; $_$; 0DROP FUNCTION public.formatinvcnumber(integer); publicadminfalse84623125578514formatitemsitebarcode(integer)FUNCTION|CREATE FUNCTION formatitemsitebarcode(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; _barcode TEXT; BEGIN SELECT ( E'\138ISXX' || LTRIM(TO_CHAR(LENGTH(item_number), '00')) || LENGTH(warehous_code)::TEXT || item_number || warehous_code ) INTO _barcode FROM itemsite, item, whsinfo WHERE ( (itemsite_item_id=item_id) AND (itemsite_warehous_id=warehous_id) AND (itemsite_id=pItemsiteid) ); RETURN _barcode; END; $_$; 5DROP FUNCTION public.formatitemsitebarcode(integer); publicadminfalse84623125578515formatlocationbarcode(integer)FUNCTION^CREATE FUNCTION formatlocationbarcode(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLocationid ALIAS FOR $1; _barcode TEXT; BEGIN SELECT ( E'\138LOXX' || LENGTH(warehous_code)::TEXT || LTRIM(TO_CHAR(LENGTH(location_name::TEXT), '00')) || warehous_code || location_name ) INTO _barcode FROM location, whsinfo WHERE ( (location_warehous_id=warehous_id) AND (location_id=pLocationid) ); RETURN _barcode; END; $_$; 5DROP FUNCTION public.formatlocationbarcode(integer); publicadminfalse84623125578516&formatlocationcontentsbarcode(integer)FUNCTION`CREATE FUNCTION formatlocationcontentsbarcode(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLocationid ALIAS FOR $1; _barcode TEXT; BEGIN SELECT ( E'\138LOCN' || LENGTH(warehous_code)::TEXT || LTRIM(TO_CHAR(LENGTH(location_name), '00')) || warehous_code || location_name ) INTO _barcode FROM location, whsinfo WHERE ( (location_warehous_id=warehous_id) AND (location_id=pLocationid) ); RETURN _barcode; END; $_$; =DROP FUNCTION public.formatlocationcontentsbarcode(integer); publicadminfalse46238125578517#formatlocationissuebarcode(integer)FUNCTION]CREATE FUNCTION formatlocationissuebarcode(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLocationid ALIAS FOR $1; _barcode TEXT; BEGIN SELECT ( E'\138LOIS' || LENGTH(warehous_code)::TEXT || LTRIM(TO_CHAR(LENGTH(location_name), '00')) || warehous_code || location_name ) INTO _barcode FROM location, whsinfo WHERE ( (location_warehous_id=warehous_id) AND (location_id=pLocationid) ); RETURN _barcode; END; $_$; :DROP FUNCTION public.formatlocationissuebarcode(integer); publicadminfalse84623125578518formatlotserialnumber(integer)FUNCTION CREATE FUNCTION formatlotserialnumber(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLotSerialId ALIAS FOR $1; _lotserial TEXT; BEGIN --See if lot serial control turned on (Postbooks will not ever have this) IF (fetchmetricbool('LotSerialControl')) THEN SELECT ls_number INTO _lotserial FROM ls WHERE (ls_id=pLotSerialId); END IF; RETURN COALESCE(_lotserial,''); END; $_$; 5DROP FUNCTION public.formatlotserialnumber(integer); publicadminfalse84623125578519formatmoney(numeric)FUNCTIONCREATE FUNCTION formatmoney(numeric) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN formatNumeric($1, 'curr'); END;$_$; +DROP FUNCTION public.formatmoney(numeric); publicadminfalse84623125578520formatnumeric(numeric, text)FUNCTION} CREATE FUNCTION formatnumeric(numeric, text) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _value NUMERIC := $1; _type TEXT := LOWER(COALESCE($2, 'curr')); _abs NUMERIC; _magnitudecnt NUMERIC(1000); _wholefmt TEXT := '0'; _scale INTEGER; _neg TEXT; _decimal TEXT; _group TEXT; _string TEXT; _debug BOOL := false; _r RECORD; BEGIN -- If the value passed in is NULL then we want to pass back an empty string IF(_value IS NULL) THEN RETURN ''; END IF; SELECT * INTO _r FROM locale WHERE (locale_id=getUsrLocaleId()); _decimal := COALESCE(SUBSTRING(_r.locale_qtyformat FROM 1 FOR 1), '.'); _neg := COALESCE(SUBSTRING(_r.locale_qtyformat FROM 2 FOR 1), '-'); _group := COALESCE(SUBSTRING(_r.locale_qtyformat FROM 3 FOR 1), ','); _scale := CASE WHEN _type = 'cost' THEN _r.locale_cost_scale WHEN _type = 'extprice' THEN _r.locale_extprice_scale WHEN _type = 'percent' THEN _r.locale_percent_scale WHEN _type = 'purchprice' THEN _r.locale_purchprice_scale WHEN _type = 'qty' THEN _r.locale_qty_scale WHEN _type = 'qtyper' THEN _r.locale_qtyper_scale WHEN _type = 'salesprice' THEN _r.locale_salesprice_scale WHEN _type = 'uomratio' THEN _r.locale_uomratio_scale WHEN _type = 'weight' THEN _r.locale_weight_scale WHEN SUBSTRING(_type FOR 4) = 'curr' THEN _r.locale_curr_scale ELSE 2 END; _value := round(_value, _scale); _abs := ABS(_value); _magnitudecnt := TRUNC(_abs / 10); IF (_debug) THEN RAISE NOTICE '_value % _abs % _scale % _neg % _decimal % _group % ', _value, _abs, _scale, _decimal, _group, _scale; END IF; IF (_value < 0) THEN _string := _neg; ELSE _string := ''; END IF; WHILE (_magnitudecnt >= 1) LOOP _magnitudecnt := TRUNC(_magnitudecnt / 10); IF (LENGTH(_wholefmt) % 3 = 0) THEN _wholefmt := '"' || _group || '"' || _wholefmt; END IF; _wholefmt := '9' || _wholefmt; END LOOP; IF (_scale > 0) THEN _abs := (_abs * (10 ^ _scale)); _abs := TRUNC(_abs); _wholefmt := _wholefmt || '"' || _decimal || '"' || REPEAT('0', _scale); END IF; _wholefmt := 'FM' || _wholefmt; _string := _string || to_char(_abs, _wholefmt); RETURN _string; END;$_$; 3DROP FUNCTION public.formatnumeric(numeric, text); publicadminfalse84623125578521$formatperiodname(integer, character)FUNCTION`CREATE FUNCTION formatperiodname(integer, character) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodId ALIAS FOR $1; pInterval ALIAS FOR $2; _result TEXT; BEGIN --...for Month IF (pInterval='M') THEN SELECT (CASE WHEN period_name='' THEN formatdate(period_start) || '-' || formatdate(period_end) ELSE period_name END) INTO _result FROM period WHERE (period_id=pPeriodId); RETURN _result; --...for Quarter ELSE IF (pInterval='Q') THEN SELECT ('Q' || period_quarter || '-' || EXTRACT(year from yearperiod_end)) INTO _result FROM period, yearperiod WHERE ((period_id=pPeriodId) AND (period_yearperiod_id=yearperiod_id)); RETURN _result; --...for Year ELSE SELECT EXTRACT(year FROM yearperiod_end) INTO _result FROM period,yearperiod WHERE ((period_id=pPeriodId) AND (period_yearperiod_id=yearperiod_id)); RETURN _result; END IF; END IF; RETURN 'Err'; END; $_$; ;DROP FUNCTION public.formatperiodname(integer, character); publicadminfalse84623125578522formatplonumber(integer)FUNCTIONCREATE FUNCTION formatplonumber(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPlanordid ALIAS FOR $1; _result TEXT; BEGIN SELECT (TEXT(planord_number) || '-' || TEXT(planord_subnumber)) INTO _result FROM planord WHERE (planord_id=pPlanordid); RETURN _result; END; $_$; /DROP FUNCTION public.formatplonumber(integer); publicadminfalse84623125578523formatprcnt(numeric)FUNCTIONCREATE FUNCTION formatprcnt(numeric) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT formatNumeric($1 * 100, 'percent') AS result $_$; +DROP FUNCTION public.formatprcnt(numeric); publicadminfalse8125578524formatprice(numeric)FUNCTIONCREATE FUNCTION formatprice(numeric) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT formatNumeric($1, 'salesprice') AS result; $_$; +DROP FUNCTION public.formatprice(numeric); publicadminfalse8125578525formatpurchprice(numeric)FUNCTIONCREATE FUNCTION formatpurchprice(numeric) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN formatNumeric($1, 'purchprice'); END;$_$; 0DROP FUNCTION public.formatpurchprice(numeric); publicadminfalse84623125578526formatqty(numeric)FUNCTION CREATE FUNCTION formatqty(numeric) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN formatNumeric($1, 'qty'); END;$_$; )DROP FUNCTION public.formatqty(numeric); publicadminfalse46238125578527formatqtyper(numeric)FUNCTIONCREATE FUNCTION formatqtyper(numeric) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN formatNumeric($1, 'qtyper'); END;$_$; ,DROP FUNCTION public.formatqtyper(numeric); publicadminfalse84623125578528formatratio(numeric)FUNCTIONCREATE FUNCTION formatratio(numeric) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT formatNumeric($1, 'uomratio'); $_$; +DROP FUNCTION public.formatratio(numeric); publicadminfalse8125578529formatrevnumber(text, integer)FUNCTIONMCREATE FUNCTION formatrevnumber(text, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pRevType ALIAS FOR $1; pRevId ALIAS FOR $2; _revision TEXT; BEGIN --See if revision control turned on (Postbooks will not ever have this) IF (fetchmetricbool('RevControl')) THEN SELECT rev_number INTO _revision FROM rev WHERE ((rev_target_type=pRevType) AND (rev_id=pRevId)); END IF; RETURN COALESCE(_revision,''); END; $_$; 5DROP FUNCTION public.formatrevnumber(text, integer); publicadminfalse46238125578530formatsalesprice(numeric)FUNCTIONCREATE FUNCTION formatsalesprice(numeric) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN formatNumeric($1, 'salesprice'); END;$_$; 0DROP FUNCTION public.formatsalesprice(numeric); publicadminfalse84623125578531formatscrap(numeric)FUNCTIONCREATE FUNCTION formatscrap(numeric) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT formatNumeric(($1 * 100), 'percent') AS result $_$; +DROP FUNCTION public.formatscrap(numeric); publicadminfalse8125578532formatshipmentnumber(integer)FUNCTIONCREATE FUNCTION formatshipmentnumber(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pshipheadid ALIAS FOR $1; BEGIN RETURN ( SELECT COALESCE(shiphead_number::TEXT, '') FROM shiphead WHERE (shiphead_id=pshipheadid) ); END; $_$; 4DROP FUNCTION public.formatshipmentnumber(integer); publicadminfalse84623 125578533formatsobarcode(integer)FUNCTIONCREATE FUNCTION formatsobarcode(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; _barcode TEXT; BEGIN SELECT ( E'\138SOXX' || LENGTH(TEXT(cohead_number)) || TEXT(cohead_number) ) INTO _barcode FROM cohead WHERE (cohead_id=pSoheadid); RETURN _barcode; END; $_$; /DROP FUNCTION public.formatsobarcode(integer); publicadminfalse84623125578534formatsoitembarcode(integer)FUNCTIONWCREATE FUNCTION formatsoitembarcode(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoitemid ALIAS FOR $1; _barcode TEXT; BEGIN SELECT ( E'\138SOLI' || LENGTH(TEXT(cohead_number)) || LENGTH(formatsolinenumber(coitem_id)) || TEXT(cohead_number) || formatsolinenumber(coitem_id) ) INTO _barcode FROM cohead, coitem WHERE ( (coitem_cohead_id=cohead_id) AND (coitem_id=pSoitemid) ); RETURN _barcode; END; $_$; 3DROP FUNCTION public.formatsoitembarcode(integer); publicadminfalse46238 125578535formatsoitemnumber(integer)FUNCTIONCREATE FUNCTION formatsoitemnumber(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE targetSoitemid ALIAS FOR $1; BEGIN RETURN ( SELECT (cohead_number::TEXT || '-' || formatsolinenumber(coitem_id)) FROM cohead, coitem WHERE ((coitem_cohead_id=cohead_id) AND (coitem_id=targetSoitemid)) ); END; $_$; 2DROP FUNCTION public.formatsoitemnumber(integer); publicadminfalse84623 125578536formatsonumber(integer)FUNCTIONCREATE FUNCTION formatsonumber(integer) RETURNS text LANGUAGE sql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT COALESCE((SELECT (text(cohead_number) || '-' || formatSoLineNumber(coitem_id)) FROM coitem JOIN cohead ON (coitem_cohead_id=cohead_id) WHERE (coitem_id=($1))),'DELETED'); $_$; .DROP FUNCTION public.formatsonumber(integer); publicadminfalse8 125578537$formattime(timestamp with time zone)FUNCTIONCREATE FUNCTION formattime(timestamp with time zone) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT TO_CHAR($1, ( SELECT locale_timeformat FROM locale, usr WHERE ((usr_locale_id=locale_id) AND (usr_username=getEffectiveXtUser())) ) ) AS result $_$; ;DROP FUNCTION public.formattime(timestamp with time zone); publicadminfalse8125578538formattime(numeric)FUNCTIONCREATE FUNCTION formattime(numeric) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT LTRIM(TO_CHAR(COALESCE($1, 0), '999999990.0')); $_$; *DROP FUNCTION public.formattime(numeric); publicadminfalse8125578539formatuomratio(numeric)FUNCTIONCREATE FUNCTION formatuomratio(numeric) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN formatNumeric($1, 'uomratio'); END;$_$; .DROP FUNCTION public.formatuomratio(numeric); publicadminfalse46238125578540formatuserbarcode(integer)FUNCTIONCREATE FUNCTION formatuserbarcode(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUserid ALIAS FOR $1; _barcode TEXT; BEGIN SELECT formatUserBarcode(usr_username) INTO _barcode FROM usr WHERE(usr_id=pUserid); RETURN _barcode; END; $_$; 1DROP FUNCTION public.formatuserbarcode(integer); publicadminfalse84623125578541formatuserbarcode(text)FUNCTIONCREATE FUNCTION formatuserbarcode(text) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; _barcode TEXT; BEGIN _barcode := ( E'\138USER' || LENGTH(pUsername)::TEXT || pUsername ); RETURN _barcode; END; $_$; .DROP FUNCTION public.formatuserbarcode(text); publicadminfalse84623125578542formatweight(numeric)FUNCTION CREATE FUNCTION formatweight(numeric) RETURNS text LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT formatNumeric($1, 'weight') AS result $_$; ,DROP FUNCTION public.formatweight(numeric); publicadminfalse8125578543formatwobarcode(integer)FUNCTIONCREATE FUNCTION formatwobarcode(integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; _barcode TEXT; BEGIN SELECT ( E'\138WOXX' || LENGTH(wo_number::TEXT) || LENGTH(wo_subnumber::TEXT) || wo_number::TEXT || wo_subnumber::TEXT ) INTO _barcode FROM wo WHERE (wo_id=pWoid); RETURN _barcode; END; $_$; /DROP FUNCTION public.formatwobarcode(integer); publicadminfalse46238125578544formatwonumber(integer)FUNCTIONCREATE FUNCTION formatwonumber(pwoid integer) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN formatWoNumber(pWoid, 'wo'); END; $$; 4DROP FUNCTION public.formatwonumber(pwoid integer); publicadminfalse84623125587025formatwonumber(integer, text)FUNCTIONGCREATE FUNCTION formatwonumber(pid integer, ptype text) RETURNS text LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pType = 'womatl') THEN RETURN ( SELECT (wo_number::TEXT || '-' || wo_subnumber::TEXT) FROM womatl JOIN wo ON (wo_id=womatl_id) WHERE (womatl_id=pId) ); ELSE RETURN ( SELECT (wo_number::TEXT || '-' || wo_subnumber::TEXT) FROM wo WHERE (wo_id=pId) ); END IF; END; $$; >DROP FUNCTION public.formatwonumber(pid integer, ptype text); publicadminfalse84623125578545formatwooperseq(integer)FUNCTIONCREATE FUNCTION formatwooperseq(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWooperId ALIAS FOR $1; _result TEXT; BEGIN IF pWooperId = -1 THEN RETURN ''; ELSE SELECT wooper_seqnumber INTO _result FROM xtmfg.wooper WHERE (wooper_id=pWooperId); END IF; RETURN _result; END; $_$; /DROP FUNCTION public.formatwooperseq(integer); publicadminfalse84623125578546forwardupdateaccount(integer)FUNCTIONCREATE FUNCTION forwardupdateaccount(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAccntid ALIAS FOR $1; _r RECORD; _trialbalid INTEGER; BEGIN SELECT trialbal_id, trialbal_dirty, CASE WHEN (trialbal_dirty) THEN 0 ELSE 1 END AS dirty_seq INTO _r FROM trialbal, period WHERE ((trialbal_period_id=period_id) AND (trialbal_accnt_id=pAccntid)) ORDER BY dirty_seq, period_start LIMIT 1; IF (FOUND) THEN IF (_r.trialbal_dirty) THEN RETURN forwardUpdateTrialBalance(_r.trialbal_id); ELSE RETURN _r.trialbal_id; END IF; ELSE _trialbalid := nextval('trialbal_trialbal_id_seq'); INSERT INTO trialbal ( trialbal_id, trialbal_period_id, trialbal_accnt_id, trialbal_beginning, trialbal_ending, trialbal_debits, trialbal_credits, trialbal_dirty ) SELECT _trialbalid, period_id, pAccntid, 0, 0, 0, 0, FALSE FROM period ORDER BY period_start LIMIT 1; RETURN forwardUpdateTrialBalance(_trialbalid); END IF; RETURN -1; END; $_$; 4DROP FUNCTION public.forwardupdateaccount(integer); publicadminfalse84623125578547 forwardupdateinvbalance(integer)FUNCTION CREATE FUNCTION forwardupdateinvbalance(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvbalid ALIAS FOR $1; _p RECORD; _r RECORD; _qohEnding NUMERIC; _valueEnding NUMERIC; _nnEnding NUMERIC; _nnvalEnding NUMERIC; BEGIN SELECT invbal_itemsite_id, invbal_qoh_ending, invbal_value_ending, invbal_nn_ending, invbal_nnval_ending, period_end INTO _p FROM invbal JOIN period ON (invbal_period_id=period_id) JOIN itemsite ON (invbal_itemsite_id=itemsite_id) WHERE (invbal_id=pInvbalid); _qohEnding = _p.invbal_qoh_ending; _valueEnding = _p.invbal_value_ending; _nnEnding = _p.invbal_nn_ending; _nnvalEnding = _p.invbal_nnval_ending; -- Find all of the subsequent periods and their inventory balance, if they exist FOR _r IN SELECT period_id, period_end, invbal_id, invbal_qty_in, invbal_qty_out, invbal_value_in, invbal_value_out, invbal_nn_in, invbal_nn_out, invbal_nnval_in, invbal_nnval_out FROM period LEFT OUTER JOIN invbal ON ( (invbal_period_id=period_id) AND (invbal_itemsite_id=_p.invbal_itemsite_id) ) WHERE (period_start > _p.period_end) ORDER BY period_start LOOP IF (_r.invbal_id IS NULL) THEN INSERT INTO invbal ( invbal_period_id, invbal_itemsite_id, invbal_qoh_beginning, invbal_qoh_ending, invbal_qty_in, invbal_qty_out, invbal_value_beginning, invbal_value_ending, invbal_value_in, invbal_value_out, invbal_nn_beginning, invbal_nn_ending, invbal_nn_in, invbal_nn_out, invbal_nnval_beginning, invbal_nnval_ending, invbal_nnval_in, invbal_nnval_out, invbal_dirty ) VALUES ( _r.period_id, _p.invbal_itemsite_id, _qohEnding, _qohEnding, 0, 0, _valueEnding, _valueEnding, 0, 0, _nnEnding, _nnEnding, 0, 0, _nnvalEnding, _nnvalEnding, 0, 0, FALSE ); ELSE UPDATE invbal SET invbal_qoh_beginning = (_qohEnding), invbal_qoh_ending = (_qohEnding + _r.invbal_qty_in - _r.invbal_qty_out), invbal_value_beginning = (_valueEnding), invbal_value_ending = (_valueEnding + _r.invbal_value_in - _r.invbal_value_out), invbal_nn_beginning = (_nnEnding), invbal_nn_ending = (_nnEnding + _r.invbal_nn_in - _r.invbal_nn_out), invbal_nnval_beginning = (_nnvalEnding), invbal_nnval_ending = (_nnvalEnding + _r.invbal_nnval_in - _r.invbal_nnval_out), invbal_dirty = FALSE WHERE (invbal_id=_r.invbal_id); _qohEnding = (_qohEnding + _r.invbal_qty_in - _r.invbal_qty_out); _valueEnding = (_valueEnding + _r.invbal_value_in - _r.invbal_value_out); _nnEnding = (_nnEnding + _r.invbal_nn_in - _r.invbal_nn_out); _nnvalEnding = (_nnvalEnding + _r.invbal_nnval_in - _r.invbal_nnval_out); END IF; END LOOP; UPDATE invbal SET invbal_dirty = false WHERE (invbal_id=pInvbalid); RETURN pInvbalid; END; $_$; 7DROP FUNCTION public.forwardupdateinvbalance(integer); publicadminfalse84623125578548forwardupdateitemsite(integer)FUNCTIONPCREATE FUNCTION forwardupdateitemsite(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteId ALIAS FOR $1; _r RECORD; _invbalid INTEGER; BEGIN SELECT invbal_id INTO _r FROM invbal JOIN period ON (invbal_period_id=period_id) WHERE (invbal_itemsite_id=pItemsiteid) ORDER BY period_start LIMIT 1; IF (FOUND) THEN RETURN forwardUpdateInvbalance(_r.invbal_id); ELSE _invbalid := nextval('invbal_invbal_id_seq'); INSERT INTO invbal ( invbal_id, invbal_period_id, invbal_itemsite_id, invbal_qoh_beginning, invbal_qoh_ending, invbal_qty_in, invbal_qty_out, invbal_value_beginning, invbal_value_ending, invbal_value_in, invbal_value_out, invbal_nn_beginning, invbal_nn_ending, invbal_nn_in, invbal_nn_out, invbal_nnval_beginning, invbal_nnval_ending, invbal_nnval_in, invbal_nnval_out, invbal_dirty ) SELECT _invbalid, period_id, pItemsiteid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false FROM period ORDER BY period_start LIMIT 1; RETURN forwardUpdateInvbalance(_invbalid); END IF; RETURN -1; END; $_$; 5DROP FUNCTION public.forwardupdateitemsite(integer); publicadminfalse84623125578549"forwardupdatetrialbalance(integer)FUNCTION# CREATE FUNCTION forwardupdatetrialbalance(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTrialbalid ALIAS FOR $1; _p RECORD; _r RECORD; _ending NUMERIC; _prevYear INTEGER; _currYear INTEGER; _prevYearClosed BOOLEAN; _currYearClosed BOOLEAN; _result INTEGER; BEGIN SELECT trialbal_accnt_id, trialbal_ending, yearperiod_id, yearperiod_closed, period_end, accnt_type IN ('E', 'R') AS revexp INTO _p FROM trialbal, period, yearperiod, accnt WHERE ( (trialbal_period_id=period_id) AND (yearperiod_id=period_yearperiod_id) AND (trialbal_accnt_id=accnt_id) AND (trialbal_id=pTrialbalid) ); _ending = _p.trialbal_ending; SELECT yearperiod_id, yearperiod_closed INTO _prevYear, _prevYearClosed FROM yearperiod WHERE (_p.period_end BETWEEN yearperiod_start AND yearperiod_end); IF (NOT FOUND) THEN _prevYear := -1; _prevYearClosed := false; END IF; -- Find all of the subsequent periods and their trialbal, if they exist FOR _r IN SELECT period_id, period_end, trialbal_id, trialbal_debits, trialbal_credits, trialbal_yearend FROM period LEFT OUTER JOIN trialbal ON ( (trialbal_period_id=period_id) AND (trialbal_accnt_id=_p.trialbal_accnt_id) ) WHERE (period_start > _p.period_end) ORDER BY period_start LOOP SELECT yearperiod_id, yearperiod_closed INTO _currYear, _currYearClosed FROM yearperiod WHERE (_r.period_end BETWEEN yearperiod_start AND yearperiod_end); IF (NOT FOUND) THEN _currYear := -1; _currYearClosed := false; END IF; IF (_p.revexp AND _currYear != _prevYear) THEN _ending := 0; IF (_prevYearClosed) THEN SELECT updateRetainedEarnings(_prevYear) INTO _result; IF (_result < 0) THEN RETURN _result; END IF; END IF; END IF; _prevYear := _currYear; _prevYearClosed := _currYearClosed; IF (_r.trialbal_id IS NULL) THEN -- SELECT SUM(gltrans_amount) INTO _glAmount -- FROM gltrans -- WHERE ( (gltrans_date BETWEEN _r.period_start and _r.period_end ) -- AND (gltrans_accnt_id=_p.trialbal_accnt_id) -- AND (gltrans_posted) ); -- and change 2nd and 3rd VALUES line of INSERT to read -- _ending, _ending + _glAmount, -- noneg(0 - _glAmount), noneg(_glAmount), FALSE ); INSERT INTO trialbal ( trialbal_period_id, trialbal_accnt_id, trialbal_beginning, trialbal_ending, trialbal_debits, trialbal_credits, trialbal_dirty ) VALUES ( _r.period_id, _p.trialbal_accnt_id, _ending, _ending, 0, 0, FALSE ); ELSE UPDATE trialbal SET trialbal_beginning = (_ending + trialbal_yearend), trialbal_ending = (_ending + trialbal_yearend - _r.trialbal_debits + _r.trialbal_credits), trialbal_dirty = FALSE WHERE (trialbal_id=_r.trialbal_id); _ending = (_ending + _r.trialbal_yearend - _r.trialbal_debits + _r.trialbal_credits); END IF; END LOOP; UPDATE trialbal SET trialbal_dirty = FALSE WHERE (trialbal_id=pTrialbalid); RETURN pTrialbalid; END; $_$; 9DROP FUNCTION public.forwardupdatetrialbalance(integer); publicadminfalse46238125578550freezeaccountingperiod(integer)FUNCTIONHCREATE FUNCTION freezeaccountingperiod(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodid ALIAS FOR $1; BEGIN -- Check to make use that the period is not already frozen IF ( ( SELECT period_freeze FROM period WHERE (period_id=pPeriodid) ) ) THEN RETURN -2; END IF; -- Set the period_freeze flag UPDATE period SET period_freeze=TRUE WHERE (period_id=pPeriodid); RETURN pPeriodid; END; $_$; 6DROP FUNCTION public.freezeaccountingperiod(integer); publicadminfalse84623125587026Cfreightdetail(text, integer, integer, integer, date, text, integer)FUNCTION$CREATE FUNCTION freightdetail(text, integer, integer, integer, date, text, integer) RETURNS SETOF freightdata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOrderType ALIAS FOR $1; pOrderId ALIAS FOR $2; pCustId ALIAS FOR $3; pShiptoId ALIAS FOR $4; pOrderDate ALIAS FOR $5; pShipVia ALIAS FOR $6; pCurrId ALIAS FOR $7; _row freightData%ROWTYPE; _order RECORD; _weights RECORD; _includepkgweight BOOLEAN := FALSE; _qry TEXT; _debug BOOLEAN := FALSE; BEGIN IF (_debug) THEN RAISE NOTICE 'pOrderType = %', pOrderType; RAISE NOTICE 'pOrderId = %', pOrderId; RAISE NOTICE 'pCustId = %', pCustId; RAISE NOTICE 'pShiptoId = %', pShiptoId; RAISE NOTICE 'pOrderDate = %', pOrderDate; RAISE NOTICE 'pShipVia = %', pShipVia; RAISE NOTICE 'pCurrId = %', pCurrId; END IF; SELECT fetchMetricBool('IncludePackageWeight') INTO _includepkgweight; --Get the order header information need to match --against price schedules IF (pOrderType = 'SO') THEN SELECT cust_id AS cust_id, custtype_id, custtype_code, COALESCE(shipto_id, -1) AS shipto_id, COALESCE(shipto_num, '') AS shipto_num, COALESCE(pOrderDate, cohead_orderdate) AS orderdate, COALESCE(pShipVia, cohead_shipvia) AS shipvia, shipto_shipzone_id AS shipzone_id, COALESCE(pCurrId, cohead_curr_id) AS curr_id, currConcat(COALESCE(pCurrId, cohead_curr_id)) AS currAbbr INTO _order FROM cohead JOIN custinfo ON (cust_id=COALESCE(pCustId, cohead_cust_id)) JOIN custtype ON (custtype_id=cust_custtype_id) LEFT OUTER JOIN shiptoinfo ON (shipto_id=COALESCE(pShiptoId, cohead_shipto_id)) WHERE (cohead_id=pOrderId); ELSIF (pOrderType = 'QU') THEN SELECT quhead_cust_id AS cust_id, custtype_id, custtype_code, COALESCE(shipto_id, -1) AS shipto_id, COALESCE(shipto_num, '') AS shipto_num, quhead_quotedate AS orderdate, quhead_shipvia AS shipvia, shipto_shipzone_id AS shipzone_id, quhead_curr_id AS curr_id, currConcat(quhead_curr_id) AS currAbbr INTO _order FROM quhead JOIN custinfo ON (cust_id=quhead_cust_id) JOIN custtype ON (custtype_id=cust_custtype_id) LEFT OUTER JOIN shiptoinfo ON (shipto_id=quhead_shipto_id) WHERE (quhead_id=pOrderId); ELSIF (pOrderType = 'RA') THEN SELECT cust_id AS cust_id, custtype_id, custtype_code, COALESCE(shipto_id, -1) AS shipto_id, COALESCE(shipto_num, '') AS shipto_num, COALESCE(pOrderDate, rahead_authdate) AS orderdate, ''::text AS shipvia, shipto_shipzone_id AS shipzone_id, COALESCE(pCurrId, rahead_curr_id) AS curr_id, currConcat(COALESCE(pCurrId, rahead_curr_id)) AS currAbbr INTO _order FROM rahead JOIN custinfo ON (cust_id=COALESCE(pCustId, rahead_cust_id)) JOIN custtype ON (custtype_id=cust_custtype_id) LEFT OUTER JOIN shiptoinfo ON (shipto_id=COALESCE(pShiptoId, rahead_shipto_id)) WHERE (rahead_id=pOrderId); ELSE RAISE EXCEPTION 'Invalid order type.'; END IF; IF (_debug) THEN RAISE NOTICE 'cust_id = %', _order.cust_id; RAISE NOTICE 'custtype_id = %', _order.custtype_id; RAISE NOTICE 'shipto_id = %', _order.shipto_id; RAISE NOTICE 'shipto_num = %', _order.shipto_num; RAISE NOTICE 'orderdate = %', _order.orderdate; RAISE NOTICE 'shipvia = %', _order.shipvia; RAISE NOTICE 'shipzone_id = %', _order.shipzone_id; RAISE NOTICE 'curr_id = %', _order.curr_id; RAISE NOTICE 'currAbbr = %', _order.currAbbr; END IF; --Get a list of aggregated weights from sites and --freight classes used on order lines IF (_includePkgWeight) THEN _qry := 'SELECT SUM(orderitem_qty_ordered * orderitem_qty_invuomratio * (item_prodweight + item_packweight)) AS weight, '; ELSE _qry := 'SELECT SUM(orderitem_qty_ordered * orderitem_qty_invuomratio * item_prodweight) AS weight, '; END IF; _qry := _qry || 'itemsite_warehous_id, COALESCE(item_freightclass_id, -1) AS item_freightclass_id FROM orderitem JOIN itemsite ON (itemsite_id=orderitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) '; IF (pOrderType = 'RA') THEN _qry := _qry || 'JOIN raitem ON ((orderitem_id=raitem_id) AND (raitem_disposition IN (''C'',''R'',''P''))) '; END IF; _qry := _qry || ' WHERE ( (orderitem_orderhead_type=' || quote_literal(pOrderType) || ') AND (orderitem_orderhead_id=' || quote_literal(pOrderId) || ') AND (orderitem_status <> ''X'') ) GROUP BY itemsite_warehous_id, item_freightclass_id;'; FOR _weights IN EXECUTE _qry LOOP _row := calculateFreightDetail( _order.cust_id, --pCustId _order.custtype_id, --pCustTypeId _order.custtype_code, --pCustTypeCode _order.shipto_id, --pShiptoId _order.shipzone_id, --pShipZoneId _order.shipto_num, --pShiptoNum _order.orderdate, --pOrderDate _order.shipvia, --pShipVia _order.curr_id, --pCurrId _order.currAbbr, --pCurrAbbr _weights.itemsite_warehous_id, --pItemSiteWhsId _weights.item_freightclass_id, --pItemFreightclassId _weights.weight --pWeight ); RETURN NEXT _row; END LOOP; RETURN; END; $_$; ZDROP FUNCTION public.freightdetail(text, integer, integer, integer, date, text, integer); publicadminfalse462384249125587027Jfreightdetailquote(integer, text, integer, text, date, text, text, text[])FUNCTION'CREATE FUNCTION freightdetailquote(integer, text, integer, text, date, text, text, text[]) RETURNS SETOF freightdata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustId ALIAS FOR $1; pCustNumber ALIAS FOR $2; pShiptoId ALIAS FOR $3; pShiptoNum ALIAS FOR $4; pOrderDate ALIAS FOR $5; pShipVia ALIAS FOR $6; pItemArrayType ALIAS FOR $7; pItemQty ALIAS FOR $8; -- Array item_id format = ARRAY[['300','3'],['310','50']] -- Array item_number format = ARRAY[['YTRUCK1','3'],['RTRUCK1','50']] -- Array itemsite_id format = ARRAY[['293','3'],['302','50']] _cust RECORD; _shipto RECORD; _curr RECORD; _includepkgweight BOOLEAN := FALSE; _order_date DATE; _ship_via TEXT; _item_num RECORD; _item_id RECORD; _weights RECORD; _row freightData%ROWTYPE; _debug BOOLEAN := FALSE; BEGIN -- Parameters are setup to allow this function to be called multiple ways. -- Check parameters and lookup what is NULL. -- Check pCustId and pCustNumber. IF (pCustId IS NULL AND (pCustNumber IS NULL OR pCustNumber = '')) THEN RAISE EXCEPTION 'You must specify a Customer ID or Number to get a freight quote.'; ELSIF (pCustId IS NULL AND pCustNumber IS NOT NULL) THEN -- Get customer info using pCustNumber. SELECT cust_id, cust_number, custtype_id, custtype_code, cust_curr_id, cust_shipvia INTO _cust FROM custinfo LEFT JOIN custtype ON cust_custtype_id = custtype_id WHERE 1=1 AND cust_number = pCustNumber; ELSE -- Get customer info using pCustId. SELECT cust_id, cust_number, custtype_id, custtype_code, cust_curr_id, cust_shipvia INTO _cust FROM custinfo LEFT JOIN custtype ON cust_custtype_id = custtype_id WHERE 1=1 AND cust_id = pCustId; END IF; IF(NOT FOUND) THEN RAISE EXCEPTION 'Invalid Customer specified when trying to get a freight quote.'; END IF; -- Check pShiptoId and pShiptoNum. IF (pShiptoId IS NULL AND (pShiptoNum IS NULL OR pShiptoNum = '')) THEN -- Get Customer's default shipto. SELECT shipto_id, shipto_name, shipto_shipzone_id, shipto_shipvia, shipto_num INTO _shipto FROM shiptoinfo WHERE 1=1 AND shipto_cust_id = _cust.cust_id AND shipto_default; ELSIF (pShiptoId IS NULL AND pShiptoNum IS NOT NULL) THEN -- Get shipto info using pShiptoNum. SELECT shipto_id, shipto_name, shipto_shipzone_id, shipto_shipvia, shipto_num INTO _shipto FROM shiptoinfo WHERE 1=1 AND shipto_cust_id = _cust.cust_id AND shipto_num = pShiptoNum; ELSE -- Get shipto info using pShiptoId. SELECT shipto_id, shipto_name, shipto_shipzone_id, shipto_shipvia, shipto_num INTO _shipto FROM shiptoinfo WHERE 1=1 AND shipto_cust_id = _cust.cust_id AND shipto_id = pShiptoId; END IF; IF(NOT FOUND) THEN RAISE EXCEPTION 'Invalid Ship-to specified when trying to get a freight quote.'; END IF; -- Get curr info. SELECT curr_id, curr_abbr INTO _curr FROM curr_symbol WHERE 1=1 AND curr_id = _cust.cust_curr_id; IF(NOT FOUND) THEN RAISE EXCEPTION 'Could not find currency when trying to get a freight quote.'; END IF; -- Check pOrderDate. IF (pOrderDate IS NULL) THEN _order_date := CURRENT_DATE; ELSE _order_date := pOrderDate; END IF; -- Check pShipVia. IF (pShipVia IS NULL OR pShipVia = '') THEN IF (_shipto.shipto_shipvia IS NULL OR _shipto.shipto_shipvia = '') THEN _ship_via := _cust.cust_shipvia; ELSE _ship_via := _shipto.shipto_shipvia; END IF; ELSE _ship_via := pShipVia; END IF; -- Determine if package weight should be included in freight calculation. SELECT fetchMetricBool('IncludePackageWeight') INTO _includepkgweight; -- Check pItemQty. IF (pItemQty IS NULL OR array_upper(pItemQty,1) IS NULL) THEN -- Item Array is NULL. RAISE EXCEPTION 'You must specify an Item ID, Item Number or Itemsite ID to get a freight quote.'; ELSIF (pItemArrayType = 'item_number' AND (array_upper(pItemQty,1) > 0)) THEN -- Using item_number. FOR _weights IN -- Get a list of aggregated weights from sites and freight classes for items. SELECT CASE WHEN _includepkgweight THEN SUM(qty * (item_prodweight + item_packweight)) ELSE SUM(qty * (item_prodweight)) END AS weight, itemsite_warehous_id, COALESCE(item_freightclass_id, -1) AS item_freightclass_id FROM -- Create item_number -> qty record from array. (SELECT unnest((SELECT pItemQty[1:array_upper(pItemQty,1)][1])) AS item_number, unnest((SELECT pItemQty[1:array_upper(pItemQty,1)][2:array_ndims(pItemQty)]))::numeric AS qty ) AS itemnum_qty JOIN item USING (item_number) JOIN itemsite ON item_id=itemsite_item_id WHERE 1=1 AND itemsite_warehous_id = fetchprefwarehousid() GROUP BY itemsite_warehous_id, item_freightclass_id LOOP -- Calculate the freight detail for these item weights. _row := calculateFreightDetail( _cust.cust_id, --pCustId _cust.custtype_id, --pCustTypeId _cust.custtype_code, --pCustTypeCode _shipto.shipto_id, --pShiptoId _shipto.shipto_shipzone_id, --pShipZoneId _shipto.shipto_num, --pShiptoNum _order_date, --pOrderDate _ship_via, --pShipVia _curr.curr_id, --pCurrId _curr.curr_abbr, --pCurrAbbr _weights.itemsite_warehous_id, --pItemSiteWhsId _weights.item_freightclass_id, --pItemFreightclassId _weights.weight --pWeight ); RETURN NEXT _row; END LOOP; ELSIF (pItemArrayType = 'item_id' AND (array_upper(pItemQty,1) > 0)) THEN -- Using item_id. FOR _weights IN -- Get a list of aggregated weights from sites and freight classes for items. SELECT CASE WHEN _includepkgweight THEN SUM(qty * (item_prodweight + item_packweight)) ELSE SUM(qty * (item_prodweight)) END AS weight, itemsite_warehous_id, COALESCE(item_freightclass_id, -1) AS item_freightclass_id FROM -- Create item_id -> qty record from array. (SELECT unnest((SELECT pItemQty[1:array_upper(pItemQty,1)][1]))::integer AS item_id, unnest((SELECT pItemQty[1:array_upper(pItemQty,1)][2:array_ndims(pItemQty)]))::numeric AS qty ) AS itemid_qty JOIN item USING (item_id) JOIN itemsite ON item_id=itemsite_item_id WHERE 1=1 AND itemsite_warehous_id = fetchprefwarehousid() GROUP BY itemsite_warehous_id, item_freightclass_id LOOP -- Calculate the freight detail for these item weights. _row := calculateFreightDetail( _cust.cust_id, --pCustId _cust.custtype_id, --pCustTypeId _cust.custtype_code, --pCustTypeCode _shipto.shipto_id, --pShiptoId _shipto.shipto_shipzone_id, --pShipZoneId _shipto.shipto_num, --pShiptoNum _order_date, --pOrderDate _ship_via, --pShipVia _curr.curr_id, --pCurrId _curr.curr_abbr, --pCurrAbbr _weights.itemsite_warehous_id, --pItemSiteWhsId _weights.item_freightclass_id, --pItemFreightclassId _weights.weight --pWeight ); RETURN NEXT _row; END LOOP; ELSIF (pItemArrayType = 'itemsite_id' AND (array_upper(pItemQty,1) > 0)) THEN -- Using itemsite_id. FOR _weights IN -- Get a list of aggregated weights from sites and freight classes for items. SELECT CASE WHEN _includepkgweight THEN SUM(qty * (item_prodweight + item_packweight)) ELSE SUM(qty * (item_prodweight)) END AS weight, itemsite_warehous_id, COALESCE(item_freightclass_id, -1) AS item_freightclass_id FROM -- Create itemsite_id -> qty record from array. (SELECT unnest((SELECT pItemQty[1:array_upper(pItemQty,1)][1]))::integer AS itemsite_id, unnest((SELECT pItemQty[1:array_upper(pItemQty,1)][2:array_ndims(pItemQty)]))::numeric AS qty ) AS itemsiteid_qty JOIN itemsite USING (itemsite_id) JOIN item ON item_id=itemsite_item_id WHERE 1=1 GROUP BY itemsite_warehous_id, item_freightclass_id LOOP -- Calculate the freight detail for these item weights. _row := calculateFreightDetail( _cust.cust_id, --pCustId _cust.custtype_id, --pCustTypeId _cust.custtype_code, --pCustTypeCode _shipto.shipto_id, --pShiptoId _shipto.shipto_shipzone_id, --pShipZoneId _shipto.shipto_num, --pShiptoNum _order_date, --pOrderDate _ship_via, --pShipVia _curr.curr_id, --pCurrId _curr.curr_abbr, --pCurrAbbr _weights.itemsite_warehous_id, --pItemSiteWhsId _weights.item_freightclass_id, --pItemFreightclassId _weights.weight --pWeight ); RETURN NEXT _row; END LOOP; ELSE -- The item array provided is invalid. RAISE EXCEPTION 'The Item/Itemsite array provided when trying to get a freight quote is invalid.'; END IF; IF(NOT FOUND) THEN RAISE EXCEPTION 'Error trying to aggregated weights when getting a freight quote.'; END IF; -- Print debug. IF (_debug) THEN RAISE NOTICE 'pCustId = %', _cust.cust_id; RAISE NOTICE 'pCustTypeId = %', _cust.custtype_id; RAISE NOTICE 'pCustTypeCode = %', _cust.custtype_code; RAISE NOTICE 'pShiptoId = %', _shipto.shipto_id; RAISE NOTICE 'pShipZoneId = %', _shipto.shipto_shipzone_id; RAISE NOTICE 'pShiptoNum = %', _shipto.shipto_num; RAISE NOTICE 'pOrderDate = %', _order_date; RAISE NOTICE 'pShipVia = %', _ship_via; RAISE NOTICE 'pCurrId = %', _curr.curr_id; RAISE NOTICE 'pCurrAbbr = %', _curr.curr_abbr; END IF; RETURN; END; $_$; aDROP FUNCTION public.freightdetailquote(integer, text, integer, text, date, text, text, text[]); publicadminfalse846234249125578554&freightforrecv(text, integer, boolean)FUNCTIONCREATE FUNCTION freightforrecv(text, integer, boolean) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; porderitemid ALIAS FOR $2; pposted ALIAS FOR $3; _freight NUMERIC; BEGIN IF (pordertype = 'TO' AND NOT fetchMetricBool('MultiWhs')) THEN RETURN 0; ELSIF (pordertype = 'RA' AND NOT fetchMetricBool('EnableReturnAuth')) THEN RETURN 0; END IF; SELECT SUM(COALESCE(recv_freight, 0)) INTO _freight FROM recv WHERE ((recv_orderitem_id=porderitemid) AND (recv_posted = pposted) AND (recv_order_type=pordertype)); RETURN COALESCE(_freight, 0.0); END; $_$; =DROP FUNCTION public.freightforrecv(text, integer, boolean); publicadminfalse46238125578555gen_salt(text)FUNCTIONlCREATE FUNCTION gen_salt(text) RETURNS text LANGUAGE c STRICT AS '$libdir/pgcrypto', 'pg_gen_salt'; %DROP FUNCTION public.gen_salt(text); publicadminfalse8125578556gen_salt(text, integer)FUNCTION|CREATE FUNCTION gen_salt(text, integer) RETURNS text LANGUAGE c STRICT AS '$libdir/pgcrypto', 'pg_gen_salt_rounds'; .DROP FUNCTION public.gen_salt(text, integer); publicadminfalse8125578557getactiverevid(text, integer)FUNCTIONCREATE FUNCTION getactiverevid(text, integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTargetType ALIAS FOR $1; pTargetid ALIAS FOR $2; _revid INTEGER; BEGIN --See if revcontrol turned on IF (fetchmetricbool('RevControl')) THEN IF (pTargetType='BOM') THEN SELECT rev_id INTO _revid FROM rev WHERE ((rev_target_type='BOM') AND (rev_target_id=pTargetid) AND (rev_status='A')); IF (NOT FOUND) THEN _revid:=-1; END IF; ELSE IF (pTargetType='BOO') THEN SELECT rev_id INTO _revid FROM rev WHERE ((rev_target_type='BOO') AND (rev_target_id=pTargetid) AND (rev_status='A')); IF (NOT FOUND) THEN _revid:=-1; END IF; ELSE RAISE EXCEPTION 'Invalid Revision Type'; END IF; END IF; ELSE _revid:=-1; END IF; RETURN _revid; END; $_$; 4DROP FUNCTION public.getactiverevid(text, integer); publicadminfalse46238 125578558getaddrid(text)FUNCTION;CREATE FUNCTION getaddrid(paddressnumber text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pAddressNumber IS NULL OR pAddressNumber = '') THEN RETURN NULL; END IF; SELECT addr_id INTO _returnVal FROM addr WHERE (addr_number=pAddressNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Address Number % not found.', pAddressNumber; END IF; RETURN _returnVal; END; $$; 5DROP FUNCTION public.getaddrid(paddressnumber text); publicadminfalse46238!125578559getadjustmenttaxtypeid()FUNCTIONCREATE FUNCTION getadjustmenttaxtypeid() RETURNS integer LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _taxtypeid INTEGER; BEGIN SELECT taxtype_id INTO _taxtypeid FROM taxtype WHERE (taxtype_name='Adjustment'); RETURN _taxtypeid; END; $$; /DROP FUNCTION public.getadjustmenttaxtypeid(); publicadminfalse84623"125578560"getaropenid(text, character, text)FUNCTIONCREATE FUNCTION getaropenid(text, character, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustNumber ALIAS FOR $1; pDocType ALIAS FOR $2; pDocNumber ALIAS FOR $3; _returnVal INTEGER; BEGIN IF ((pCustNumber IS NULL) OR (pDocType IS NULL) OR (pDocNumber IS NULL)) THEN RETURN NULL; END IF; SELECT aropen_id INTO _returnVal FROM aropen WHERE ((aropen_cust_id=getCustId(pCustNumber,true)) AND (UPPER(aropen_doctype)=UPPER(pDocType)) AND (UPPER(aropen_docnumber)=UPPER(pDocNumber))); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'AR Open Item % not found.', pDocNumber; END IF; RETURN _returnVal; END; $_$; 9DROP FUNCTION public.getaropenid(text, character, text); publicadminfalse84623#125578561getbankaccntid(text)FUNCTIONJCREATE FUNCTION getbankaccntid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBankAccntName ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pBankAccntName IS NULL) THEN RETURN NULL; END IF; SELECT bankaccnt_id INTO _returnVal FROM bankaccnt WHERE (UPPER(bankaccnt_name)=UPPER(pBankAccntName)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Bank Account % not found.', pBankAccntName; END IF; RETURN _returnVal; END; $_$; +DROP FUNCTION public.getbankaccntid(text); publicadminfalse46238$125578562getbomitemid(text, text, text)FUNCTION<CREATE FUNCTION getbomitemid(text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemNumber ALIAS FOR $1; pRevision ALIAS FOR $2; pSeqNumber ALIAS FOR $3; _returnVal INTEGER; BEGIN IF ((pItemNumber IS NULL) OR (pSeqNumber IS NULL) OR (pItemNumber = '') OR (pSeqNumber = '') ) THEN RETURN NULL; END IF; SELECT bomitem_id INTO _returnVal FROM bomitem(getItemId(pItemNumber),COALESCE(getRevId('BOM',pItemNumber,pRevision))) WHERE (bomitem_seqnumber=pSeqNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Sequence % on Bill of Material % Revision % not found.', pSeqNumber, pItemNumber, pRevision; END IF; RETURN _returnVal; END; $_$; 5DROP FUNCTION public.getbomitemid(text, text, text); publicadminfalse46238%125578563getbooitemseqid(text, text)FUNCTIONCREATE FUNCTION getbooitemseqid(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemNumber ALIAS FOR $1; pSeqNumber ALIAS FOR $2; _revid INTEGER; _returnVal INTEGER; BEGIN IF ((pItemNumber IS NULL) OR (pSeqNumber IS NULL)) THEN RETURN NULL; END IF; IF (NOT fetchMetricBool('Routings')) THEN RETURN -1; ELSE SELECT booitem_seq_id INTO _returnVal FROM booitem(getItemId(pItemNumber)) WHERE (booitem_seqnumber=CAST(pSeqNumber AS integer)); END IF; IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Boo Sequence % for Item % not found.', pSeqNumber, pItemNumber; END IF; RETURN _returnVal; END; $_$; 2DROP FUNCTION public.getbooitemseqid(text, text); publicadminfalse84623&125578564getbudgheadid(text)FUNCTION#CREATE FUNCTION getbudgheadid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBudghead ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pBudghead IS NULL) THEN RETURN NULL; END IF; SELECT budghead_id INTO _returnVal FROM budghead WHERE (budghead_name=(pBudghead)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Budget % not found.', pBudghead; END IF; RETURN _returnVal; END; $_$; *DROP FUNCTION public.getbudgheadid(text); publicadminfalse46238'125578565getcashrcptid(text, text, text)FUNCTION"CREATE FUNCTION getcashrcptid(text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustNumber ALIAS FOR $1; pFundsType ALIAS FOR $2; pDocNumber ALIAS FOR $3; _returnVal INTEGER; BEGIN IF ((pCustNumber IS NULL) OR (pFundsType IS NULL) OR (pDocNumber IS NULL)) THEN RETURN NULL; END IF; SELECT cashrcpt_id INTO _returnVal FROM cashrcpt WHERE ((cashrcpt_cust_id=getCustId(pCustNumber,true)) AND (UPPER(cashrcpt_fundstype)=UPPER(pFundsType)) AND (UPPER(cashrcpt_docnumber)=UPPER(pDocNumber))); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Cash Receipt % not found.', pDocNumber; END IF; RETURN _returnVal; END; $_$; 6DROP FUNCTION public.getcashrcptid(text, text, text); publicadminfalse46238(125578566getcharid(text, text)FUNCTIONZCREATE FUNCTION getcharid(pchar text, ptype text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (COALESCE(pChar, '') = '') THEN RETURN NULL; END IF; SELECT char_id INTO _returnVal FROM char JOIN charuse ON char_id = charuse_char_id WHERE char_name = pChar AND (charuse_target_type = pType OR (pType IN ('C', 'CT') AND charuse_target_type = 'C') OR (pType IN ('SI','QI','W','PI','TI') AND charuse_target_type = 'I') ) LIMIT 1; IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Characteristic % not found [xtuple: getCharId, -1, %]', pChar, pChar; END IF; RETURN _returnVal; END; $$; 8DROP FUNCTION public.getcharid(pchar text, ptype text); publicadminfalse46238)125578567getclasscodeid(text)FUNCTION-CREATE FUNCTION getclasscodeid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pClassCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pClassCode IS NULL) THEN RETURN NULL; END IF; SELECT classcode_id INTO _returnVal FROM classcode WHERE (classcode_code=pClassCode); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Class Code % not found.', pClassCode; END IF; RETURN _returnVal; END; $_$; +DROP FUNCTION public.getclasscodeid(text); publicadminfalse46238*125578568getcmheadid(text)FUNCTION;CREATE FUNCTION getcmheadid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCreditMemoNumber ALIAS FOR $1; BEGIN RETURN getCmheadId(pCreditMemoNumber, NULL); END; $_$; (DROP FUNCTION public.getcmheadid(text); publicadminfalse84623+125578569getcmheadid(text, boolean)FUNCTIONCREATE FUNCTION getcmheadid(text, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCreditMemoNumber ALIAS FOR $1; pPosted ALIAS FOR $2; _returnVal INTEGER; BEGIN IF (pCreditMemoNumber IS NULL) THEN RETURN NULL; END IF; SELECT cmhead_id INTO _returnVal FROM cmhead WHERE (UPPER(cmhead_number)=UPPER(pCreditMemoNumber)) AND ((pPosted IS NULL) OR (cmhead_posted=pPosted)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Credit Memo % not found.', pCreditMemoNumber; END IF; RETURN _returnVal; END; $_$; 1DROP FUNCTION public.getcmheadid(text, boolean); publicadminfalse84623,125578570getcmnttypeid(text)FUNCTION@CREATE FUNCTION getcmnttypeid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmntType ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (COALESCE(TRIM(pCmntType), '') = '') THEN RETURN NULL; END IF; SELECT cmnttype_id INTO _returnVal FROM cmnttype WHERE (cmnttype_name=pCmntType) LIMIT 1; IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Comment Type % not found.', pCmntType; END IF; RETURN _returnVal; END; $_$; *DROP FUNCTION public.getcmnttypeid(text); publicadminfalse46238-125578571getcntctid(text)FUNCTIONcCREATE FUNCTION getcntctid(pcontactnumber text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN SELECT getCntctId(pContactNumber,true) INTO _returnVal; RETURN _returnVal; END; $$; 6DROP FUNCTION public.getcntctid(pcontactnumber text); publicadminfalse46238.125578572getcntctid(text, boolean)FUNCTIONCREATE FUNCTION getcntctid(pcontactnumber text, pnotfounderr boolean) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (COALESCE(TRIM(pContactNumber), '') = '') THEN RETURN NULL; END IF; SELECT cntct_id INTO _returnVal FROM cntct WHERE (cntct_number=pContactNumber); IF (_returnVal IS NULL AND pNotFoundErr) THEN RAISE EXCEPTION 'Contact Number % not found.', pContactNumber; ELSIF (_returnVal IS NULL) THEN RETURN NULL; END IF; RETURN _returnVal; END; $$; LDROP FUNCTION public.getcntctid(pcontactnumber text, pnotfounderr boolean); publicadminfalse46238/125578573getcoheadid(text)FUNCTION@CREATE FUNCTION getcoheadid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSalesOrderNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pSalesOrderNumber IS NULL) THEN RETURN NULL; END IF; SELECT cohead_id INTO _returnVal FROM cohead WHERE (cohead_number=pSalesOrderNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Sales Order % not found.', pSalesOrderNumber; END IF; RETURN _returnVal; END; $_$; (DROP FUNCTION public.getcoheadid(text); publicadminfalse462380125578574getcoitemid(text, text)FUNCTIONCREATE FUNCTION getcoitemid(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSalesOrderNumber ALIAS FOR $1; pLineNumber ALIAS FOR $2; _linenumber INTEGER; _subnumber INTEGER; _returnVal INTEGER; BEGIN IF (pSalesOrderNumber IS NULL OR pLineNumber IS NULL) THEN RETURN NULL; END IF; --Parse Line Number IF (position('.' in pLineNumber) > 0) THEN _linenumber := CAST(substring(pLineNumber from 1 for position('.' in pLineNumber)-1) AS INTEGER); _subnumber := CAST(substring(pLineNumber from position('.' in pLineNumber)+1 for length(pLineNumber)) AS INTEGER); ELSE _linenumber := CAST(pLineNumber AS INTEGER); _subnumber := 0; END IF; SELECT coitem_id INTO _returnVal FROM cohead, coitem WHERE ((cohead_number=pSalesOrderNumber) AND (coitem_cohead_id=cohead_id) AND (coitem_linenumber=_linenumber) AND (coitem_subnumber=_subnumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Sales Order % not found.', pSalesOrderNumber; END IF; RETURN _returnVal; END; $_$; .DROP FUNCTION public.getcoitemid(text, text); publicadminfalse846231125587029getcompanyid(integer)FUNCTIONCREATE FUNCTION getcompanyid(pglaccnt integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pGlAccnt IS NULL) THEN RETURN -1; END IF; SELECT accnt_company INTO _returnVal FROM accnt WHERE (accnt_id=pGlAccnt); IF (_returnVal IS NULL) THEN RETURN -1; END IF; RETURN _returnVal; END; $$; 5DROP FUNCTION public.getcompanyid(pglaccnt integer); publicadminfalse46238125578575getcontrcteffective(text)FUNCTION1CREATE FUNCTION getcontrcteffective(pcontrctnumber text) RETURNS date LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal DATE; BEGIN IF (pContrctNumber IS NULL) THEN RETURN NULL; END IF; SELECT contrct_effective INTO _returnVal FROM contrct WHERE (contrct_number=pContrctNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Contract Number % not found.', pContrctNumber; END IF; RETURN _returnVal; END; $$; ?DROP FUNCTION public.getcontrcteffective(pcontrctnumber text); publicadminfalse84623125578576getcontrctexpires(text)FUNCTION-CREATE FUNCTION getcontrctexpires(pcontrctnumber text) RETURNS date LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal DATE; BEGIN IF (pContrctNumber IS NULL) THEN RETURN NULL; END IF; SELECT contrct_expires INTO _returnVal FROM contrct WHERE (contrct_number=pContrctNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Contract Number % not found.', pContrctNumber; END IF; RETURN _returnVal; END; $$; =DROP FUNCTION public.getcontrctexpires(pcontrctnumber text); publicadminfalse84623125578577getcontrctid(text)FUNCTION)CREATE FUNCTION getcontrctid(pcontrctnumber text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pContrctNumber IS NULL) THEN RETURN NULL; END IF; SELECT contrct_id INTO _returnVal FROM contrct WHERE (contrct_number=pContrctNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Contract Number % not found.', pContrctNumber; END IF; RETURN _returnVal; END; $$; 8DROP FUNCTION public.getcontrctid(pcontrctnumber text); publicadminfalse846232125578578getcostcatid(text)FUNCTION"CREATE FUNCTION getcostcatid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCostCat ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pCostCat IS NULL) THEN RETURN NULL; END IF; SELECT costcat_id INTO _returnVal FROM costcat WHERE (costcat_code=pCostCat); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Cost Category Code % not found.', pCostCat; END IF; RETURN _returnVal; END; $_$; )DROP FUNCTION public.getcostcatid(text); publicadminfalse846233125578579getcostelemid(text)FUNCTION4CREATE FUNCTION getcostelemid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCostElemType ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pCostElemType IS NULL) THEN RETURN NULL; END IF; SELECT costelem_id INTO _returnVal FROM costelem WHERE (costelem_type=pCostElemType); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Cost Element % not found.', pCostElemType; END IF; RETURN _returnVal; END; $_$; *DROP FUNCTION public.getcostelemid(text); publicadminfalse846235125578580getcrmacctid(text)FUNCTION@CREATE FUNCTION getcrmacctid(pacctnumber text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pAcctNumber IS NULL) THEN RETURN NULL; END IF; SELECT crmacct_id INTO _returnVal FROM crmacct WHERE (UPPER(crmacct_number)=UPPER(pAcctNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'CRM Account Number % not found.', pAcctNumber; END IF; RETURN _returnVal; END; $$; 5DROP FUNCTION public.getcrmacctid(pacctnumber text); publicadminfalse846236125578581getcurrid(text)FUNCTION CREATE FUNCTION getcurrid(pcurrname text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pCurrName IS NULL) THEN RETURN NULL; END IF; SELECT curr_id INTO _returnVal FROM curr_symbol WHERE (curr_abbr=pCurrName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Currency % not found.', pCurrName; END IF; RETURN _returnVal; END; $$; 0DROP FUNCTION public.getcurrid(pcurrname text); publicadminfalse462388125578582getcustid(text)FUNCTION_CREATE FUNCTION getcustid(pcustnumber text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN SELECT getCustId(pCustNumber,false) INTO _returnVal; RETURN _returnVal; END; $$; 2DROP FUNCTION public.getcustid(pcustnumber text); publicadminfalse846239125578583getcustid(text, boolean)FUNCTIONrCREATE FUNCTION getcustid(pcustnumber text, pinclprospects boolean) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pCustNumber IS NULL) THEN RETURN NULL; END IF; SELECT cust_id INTO _returnVal FROM custinfo WHERE (cust_number=UPPER(pCustNumber)); IF (_returnVal IS NULL) THEN IF (pInclProspects) THEN SELECT prospect_id INTO _returnVal FROM prospect WHERE (UPPER(prospect_number)=UPPER(pCustNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Neither Customer nor Prospect Number % found.', pCustNumber; END IF; ELSE RAISE EXCEPTION 'Customer Number % not found.', pCustNumber; END IF; END IF; RETURN _returnVal; END; $$; JDROP FUNCTION public.getcustid(pcustnumber text, pinclprospects boolean); publicadminfalse462387125578584:getcustnamefrominfo(text, text, text, text, text, boolean)FUNCTIONC CREATE FUNCTION getcustnamefrominfo(text, text, text, text, text, boolean) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _email TEXT := COALESCE(UPPER($1), ''); _company TEXT := COALESCE(UPPER($2), ''); _first TEXT := COALESCE(UPPER($3), ''); _last TEXT := COALESCE(UPPER($4), ''); _fullname TEXT := COALESCE(UPPER($5), ''); _generate BOOLEAN := COALESCE($6, FALSE); _counter INTEGER; _custcount INTEGER := 0; _custname TEXT; _candidate RECORD; _r RECORD; BEGIN IF (_email != '') THEN SELECT count(*), cust_name INTO _custcount, _custname FROM custinfo LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) WHERE (UPPER(cntct_email)=_email) GROUP BY cust_name; IF (NOT FOUND) THEN _custcount := 0; ELSIF(_custcount = 1) THEN RETURN _custname; END IF; END IF; IF (_company != '') THEN SELECT count(*), cust_name INTO _custcount, _custname FROM custinfo WHERE (UPPER(cust_name)=_company) GROUP BY cust_name; IF (NOT FOUND) THEN _custcount := 0; ELSIF(_custcount = 1) THEN RETURN _custname; END IF; END IF; IF (_fullname = '' AND (_first != '' OR _last != '')) THEN _fullname := TRIM(_first || ' ' || _last); END IF; IF (_custcount <= 0 AND _fullname != '') THEN SELECT count(*), cust_name INTO _custcount, _custname FROM custinfo WHERE (UPPER(cust_name)=_fullname) GROUP BY cust_name; IF (NOT FOUND) THEN _custcount := 0; ELSIF(_custcount = 1) THEN RETURN _custname; END IF; END IF; IF (_custcount > 1) THEN RAISE EXCEPTION 'Found % possible Customers for % and % and %', _custcount, _email, _company, _fullname; END IF; IF (_custcount <= 0 AND _generate) THEN IF (_company != '') THEN RETURN _company; ELSIF (_email != '') THEN RETURN _email; ELSIF (_fullname != '') THEN RETURN _fullname; ELSE RAISE EXCEPTION 'Could not generate a new Customer Name without an email address or the name of a company or person'; END IF; END IF; IF (_custname IS NULL OR _custname = '') THEN RAISE EXCEPTION 'Could not find Customer Name for % and %', _company, _fullname; END IF; RETURN _custname; END; $_$; QDROP FUNCTION public.getcustnamefrominfo(text, text, text, text, text, boolean); publicadminfalse84623125578585<getcustnumberfrominfo(text, text, text, text, text, boolean)FUNCTIONCREATE FUNCTION getcustnumberfrominfo(text, text, text, text, text, boolean) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _email TEXT := COALESCE(UPPER($1), ''); _company TEXT := COALESCE(UPPER($2), ''); _first TEXT := COALESCE(UPPER($3), ''); _last TEXT := COALESCE(UPPER($4), ''); _fullname TEXT := COALESCE(UPPER($5), TRIM(_first || ' ' || _last)); _generate BOOLEAN := COALESCE($6, FALSE); _counter INTEGER; _custcount INTEGER := 0; _custnumber TEXT; _candidate TEXT := ''; _loopmax INTEGER := 0; _minlength INTEGER := 5; _maxlength INTEGER := 8; _numformat TEXT := ''; _testme TEXT; BEGIN IF (_email != '') THEN SELECT count(*), cust_number INTO _custcount, _custnumber FROM custinfo LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) WHERE (UPPER(cntct_email)=_email) GROUP BY cust_number; IF (NOT FOUND) THEN _custcount := 0; ELSIF(_custcount = 1) THEN RETURN _custnumber; END IF; END IF; IF (_company != '') THEN SELECT count(*), cust_number INTO _custcount, _custnumber FROM custinfo WHERE (UPPER(cust_name)=_company) GROUP BY cust_number; IF (NOT FOUND) THEN _custcount := 0; ELSIF(_custcount = 1) THEN RETURN _custnumber; END IF; END IF; IF (_fullname = '' AND (_first != '' OR _last != '')) THEN _fullname := TRIM(_first || ' ' || _last); END IF; IF (_custcount <= 0 AND _fullname != '') THEN SELECT count(*), cust_number INTO _custcount, _custnumber FROM custinfo WHERE (UPPER(cust_name)=_fullname) GROUP BY cust_number; IF (NOT FOUND) THEN _custcount := 0; ELSIF(_custcount = 1) THEN RETURN _custnumber; END IF; END IF; IF (_custcount > 1) THEN RAISE EXCEPTION 'Found % possible Customers for % and % and %', _custcount, _email, _company, _fullname; END IF; IF (_custcount <= 0 AND _generate) THEN IF (_maxlength < _minlength) THEN RAISE EXCEPTION 'Fix getCustNumberFromInfo: max length < min length'; END IF; IF (_company != '') THEN _candidate := _company; ELSIF (_email != '') THEN _candidate := SUBSTRING(_email FOR POSITION('@' IN _email) - 1); ELSIF (_last != '') THEN _candidate := _last; IF (_first != '') THEN _candidate := _candidate || _first; END IF; ELSIF (_fullname != '' AND (POSITION(' ' IN _fullname) > 0)) THEN _candidate := SUBSTRING(_fullname FROM POSITION(' ' IN _fullname) + 1) || SUBSTRING(_fullname FOR POSITION(' ' IN _fullname) - 1); END IF; WHILE (POSITION(' ' IN _candidate) > 0) LOOP _candidate := SUBSTRING(_candidate FOR POSITION(' ' IN _candidate) - 1) || SUBSTRING(_candidate FROM POSITION(' ' IN _candidate) + 1); END LOOP; FOR _counter IN _minlength.._maxlength LOOP _testme := SUBSTRING(_candidate FOR _counter); IF (NOT EXISTS(SELECT cust_number FROM custinfo WHERE (cust_number=_testme))) THEN _custnumber := _testme; EXIT; END IF; END LOOP; IF (_custnumber IS NULL OR _custnumber = '') THEN IF (LENGTH(_candidate) < _minlength) THEN _minlength := LENGTH(_candidate); END IF; FOR _counter IN _minlength.._maxlength LOOP _loopmax := _loopmax * 10 + 9; _numformat := _numformat || '0'; END LOOP; FOR _counter IN 1.._loopmax LOOP _testme := SUBSTRING(_candidate FOR _minlength) || TRIM(TO_CHAR(_counter, _numformat)); IF (NOT EXISTS(SELECT cust_number FROM custinfo WHERE (cust_number=_testme))) THEN _custnumber := _testme; EXIT; END IF; END LOOP; END IF; IF (_custnumber IS NULL OR _custnumber = '') THEN RAISE EXCEPTION 'Could not generate a new Customer Number'; END IF; END IF; IF (_custnumber IS NULL OR _custnumber = '') THEN RAISE EXCEPTION 'Could not find Customer Number for % and % and %', _email, _company, _fullname; END IF; RETURN _custnumber; END; $_$; SDROP FUNCTION public.getcustnumberfrominfo(text, text, text, text, text, boolean); publicadminfalse84623:125578586getcusttypeid(text)FUNCTION8CREATE FUNCTION getcusttypeid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustTypeCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pCustTypeCode IS NULL) THEN RETURN NULL; END IF; SELECT custtype_id INTO _returnVal FROM custtype WHERE (custtype_code=pCustTypeCode); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Customer Type % not found.', pCustTypeCode; END IF; RETURN _returnVal; END; $_$; *DROP FUNCTION public.getcusttypeid(text); publicadminfalse84623;125578587getdeptid(text)FUNCTIONACREATE FUNCTION getdeptid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pDeptNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (COALESCE(TRIM(pDeptNumber), '') = '') THEN RETURN NULL; END IF; SELECT dept_id INTO _returnVal FROM dept WHERE (UPPER(dept_number)=UPPER(pDeptNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Department % not found.', pDeptNumber; END IF; RETURN _returnVal; END; $_$; &DROP FUNCTION public.getdeptid(text); publicadminfalse84623<125578588getediprofileid(text)FUNCTIONCREATE FUNCTION getediprofileid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pEdiProfileName ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pEdiProfileName IS NULL) THEN RETURN NULL; END IF; SELECT pkghead_id INTO _returnVal FROM pkghead WHERE(pkghead_name='xtbatch'); IF(NOT FOUND) THEN RETURN NULL; END IF; SELECT ediprofile_id INTO _returnVal FROM xtbatch.ediprofile WHERE (ediprofile_name=pEdiProfileName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'EDI Profile % not found.', pEdiProfileName; END IF; RETURN _returnVal; END; $_$; ,DROP FUNCTION public.getediprofileid(text); publicadminfalse46238=125578589getediprofilename(integer)FUNCTIONfCREATE FUNCTION getediprofilename(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pEdiProfileId ALIAS FOR $1; _returnVal TEXT; BEGIN IF (pEdiProfileId IS NULL) THEN RETURN NULL; END IF; SELECT pkghead_name INTO _returnVal FROM pkghead WHERE(pkghead_name='xtbatch'); IF(NOT FOUND) THEN RETURN NULL; END IF; SELECT ediprofile_name INTO _returnVal FROM xtbatch.ediprofile WHERE (ediprofile_id=pEdiProfileId); RETURN _returnVal; END; $_$; 1DROP FUNCTION public.getediprofilename(integer); publicadminfalse46238@125578590getempid(text)FUNCTION-CREATE FUNCTION getempid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pEmpCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (COALESCE(TRIM(pEmpCode), '') = '') THEN RETURN NULL; END IF; SELECT emp_id INTO _returnVal FROM emp WHERE (UPPER(emp_code)=UPPER(pEmpCode)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Employee % not found.', pEmpCode; END IF; RETURN _returnVal; END; $_$; %DROP FUNCTION public.getempid(text); publicadminfalse84623A125578591getexpcatid(text)FUNCTIONFCREATE FUNCTION getexpcatid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pExpcatCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (COALESCE(TRIM(pExpcatCode), '') = '') THEN RETURN NULL; END IF; SELECT expcat_id INTO _returnVal FROM expcat WHERE (expcat_code=UPPER(pExpcatCode)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Expense Category % not found.', pExpcatCode; END IF; RETURN _returnVal; END; $_$; (DROP FUNCTION public.getexpcatid(text); publicadminfalse84623B125587030getflcoldata(integer, integer)FUNCTIONCREATE FUNCTION getflcoldata(integer, integer) RETURNS SETOF flcoldata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlcolid ALIAS FOR $1; pPeriodid ALIAS FOR $2; _row flcoldata%ROWTYPE; _r RECORD; _start DATE; _end DATE; _col INTEGER := 1; _mult INTEGER; BEGIN --Get Layout Data SELECT * INTO _r FROM flcol WHERE (flcol_id=pFlcolid); -- Handle Month... IF (_r.flcol_month) THEN SELECT period_start, period_end INTO _start, _end FROM period WHERE (period_id=pPeriodid); IF (_r.flcol_showdb) THEN -- Debits Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; -- Credits Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; END IF; -- Month Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; -- These don't have drill down IF (_r.flcol_prcnt) THEN _col := _col + 1; END IF; IF (_r.flcol_budget) THEN _col := _col + 1; IF (_r.flcol_budgetprcnt) THEN _col := _col + 1; END IF; IF (_r.flcol_budgetdiff) THEN _col := _col + 1; END IF; IF (_r.flcol_budgetdiffprcnt) THEN _col := _col + 1; END IF; END IF; END IF; -- Handle Quarter... IF (_r.flcol_quarter) THEN SELECT min(qtr.period_start), max(qtr.period_end) INTO _start, _end FROM period p JOIN period qtr ON (p.period_quarter=qtr.period_quarter) AND (p.period_yearperiod_id=qtr.period_yearperiod_id) WHERE (p.period_id=pPeriodid); IF (_r.flcol_showdb) THEN -- Debits Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; -- Credits Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; END IF; -- Quarter Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; -- These don't have drill down IF (_r.flcol_prcnt) THEN _col := _col + 1; END IF; IF (_r.flcol_budget) THEN _col := _col + 1; IF (_r.flcol_budgetprcnt) THEN _col := _col + 1; END IF; IF (_r.flcol_budgetdiff) THEN _col := _col + 1; END IF; IF (_r.flcol_budgetdiffprcnt) THEN _col := _col + 1; END IF; END IF; END IF; -- Handle Year... IF (_r.flcol_year) THEN SELECT yearperiod_start, period_end INTO _start, _end FROM period p JOIN yearperiod ON (period_yearperiod_id=yearperiod_id) WHERE (p.period_id=pPeriodid); IF (_r.flcol_showdb) THEN -- Debits Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; -- Credits Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; END IF; -- Year Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; -- These don't have drill down IF (_r.flcol_prcnt) THEN _col := _col + 1; END IF; IF (_r.flcol_budget) THEN _col := _col + 1; IF (_r.flcol_budgetprcnt) THEN _col := _col + 1; END IF; IF (_r.flcol_budgetdiff) THEN _col := _col + 1; END IF; IF (_r.flcol_budgetdiffprcnt) THEN _col := _col + 1; END IF; END IF; END IF; -- Handle Prior Month... IF (_r.flcol_priormonth) THEN SELECT prv.period_start, prv.period_end INTO _start, _end FROM period p JOIN period prv ON (prv.period_start < p.period_start) WHERE (p.period_id=pPeriodid) ORDER BY prv.period_start DESC LIMIT 1; -- Prior Month Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; -- These don't have drill down IF (_r.flcol_priorprcnt) THEN _col := _col + 1; END IF; IF (_r.flcol_priordiff) THEN _col := _col + 1; END IF; IF (_r.flcol_priordiffprcnt) THEN _col := _col + 1; END IF; END IF; -- Handle Prior Quarter... IF (_r.flcol_priorquarter) THEN IF (_r.flcol_priortype = 'P') THEN -- Prior Quarter SELECT min(period_start), max(period_end) INTO _start, _end FROM ( SELECT prv.period_start, prv.period_end, prv.period_quarter, prv.period_yearperiod_id FROM period p JOIN period prv ON (prv.period_start < p.period_start) AND (prv.period_quarter != p.period_quarter) WHERE (p.period_id=pPeriodid)) data GROUP BY period_quarter, period_yearperiod_id ORDER BY min(period_start) DESC LIMIT 1; ELSE -- Prior Year Quarter SELECT min(period_start), max(period_end) INTO _start, _end FROM ( SELECT prv.period_start, prv.period_end, prv.period_quarter, prv.period_yearperiod_id FROM period p JOIN period prv ON (prv.period_start < p.period_start) AND (prv.period_yearperiod_id != p.period_yearperiod_id) AND (prv.period_quarter = p.period_quarter) WHERE (p.period_id=pPeriodid)) data GROUP BY period_quarter, period_yearperiod_id ORDER BY min(period_start) DESC LIMIT 1; END IF; -- Prior Quarter Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; -- These don't have drill down IF (_r.flcol_priorprcnt) THEN _col := _col + 1; END IF; IF (_r.flcol_priordiff) THEN _col := _col + 1; END IF; IF (_r.flcol_priordiffprcnt) THEN _col := _col + 1; END IF; END IF; -- Handle Prior Year... IF (_r.flcol_prioryear IN ('D','F')) THEN IF (_r.flcol_prioryear = 'D') THEN -- Prior Year to Date SELECT yearperiod_start, prv.period_end INTO _start, _end FROM period p JOIN period prv ON (prv.period_number = p.period_number) AND (prv.period_yearperiod_id != p.period_yearperiod_id) AND (prv.period_start < p.period_start) JOIN yearperiod ON (prv.period_yearperiod_id=yearperiod_id) WHERE (p.period_id=pPeriodid) ORDER BY prv.period_start DESC LIMIT 1; ELSE -- Prior Full Year SELECT prv.yearperiod_start, prv.yearperiod_end INTO _start, _end FROM period p JOIN yearperiod cur ON (cur.yearperiod_id=p.period_yearperiod_id) JOIN yearperiod prv ON (prv.yearperiod_start < cur.yearperiod_start) WHERE (p.period_id=pPeriodid) ORDER BY prv.yearperiod_start DESC LIMIT 1; END IF; -- Prior Year Column _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + 1; END IF; RETURN; END; $_$; 5DROP FUNCTION public.getflcoldata(integer, integer); publicadminfalse462342438C125587031+getflcoldata(character, integer[], boolean)FUNCTIONoCREATE FUNCTION getflcoldata(character, integer[], boolean) RETURNS SETOF flcoldata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInterval ALIAS FOR $1; pPeriodids ALIAS FOR $2; pBudgets ALIAS FOR $3; _row flcoldata%ROWTYPE; _r RECORD; _start DATE; _end DATE; _col INTEGER := 1; _count INTEGER; _i INTEGER := 1; _incr INTEGER := 1; BEGIN IF (pBudgets) THEN _col := 2; _incr := 2; END IF; _count := ARRAY_UPPER(pPeriodIds,1); IF (pInterval = 'M') THEN FOR _i IN 1.._count LOOP SELECT period_start, period_end INTO _start, _end FROM period WHERE (period_id=pPeriodids[_i]); _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + _incr; END LOOP; ELSIF (pInterval = 'Q') THEN FOR _i IN 1.._count LOOP SELECT min(qtr.period_start), max(qtr.period_end) INTO _start, _end FROM period cur JOIN period qtr ON (cur.period_yearperiod_id=qtr.period_yearperiod_id) AND (cur.period_quarter=qtr.period_quarter) WHERE (cur.period_id=pPeriodids[_i]); _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + _incr; END LOOP; ELSE FOR _i IN 1.._count LOOP SELECT yearperiod_start, yearperiod_end INTO _start, _end FROM period JOIN yearperiod ON (period_yearperiod_id=yearperiod_id) WHERE (period_id=pPeriodids[_i]); _row.flcoldata_column := _col; _row.flcoldata_start := _start; _row.flcoldata_end := _end; RETURN NEXT _row; _col := _col + _incr; END LOOP; END IF; RETURN; END; $_$; BDROP FUNCTION public.getflcoldata(character, integer[], boolean); publicadminfalse462342438D125578594getflstmthead(integer, integer)FUNCTIONtCREATE FUNCTION getflstmthead(integer, integer) RETURNS SETOF flstmthead LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlcolid ALIAS FOR $1; pPeriodid ALIAS FOR $2; _row flstmthead%ROWTYPE; _p RECORD; _month TEXT; _qtr TEXT; _year TEXT; _prmonth TEXT; _prqtr TEXT; _pryear TEXT; _err TEXT; BEGIN SELECT 'No Data' INTO _err; --Get Layout Data SELECT flcol_priortype, flcol_prioryear INTO _p FROM flcol WHERE (flcol_id=pFlcolid); --get data... --...for current Month SELECT (CASE WHEN period_name='' THEN formatdate(period_start) || '-' || formatdate(period_end) ELSE period_name END) INTO _month FROM period WHERE (period_id=pPeriodId); IF _month IS NULL THEN _month := _err; END IF; --...for Quarter SELECT ('Q' || period_quarter || '-' || EXTRACT(year from yearperiod_end)) INTO _qtr FROM period, yearperiod WHERE ((period_id=pPeriodId) AND (period_yearperiod_id=yearperiod_id)); IF _qtr IS NULL THEN _qtr := _err; END IF; --...for Year SELECT COALESCE((CASE WHEN period_name='' THEN (formatdate(period_start) || '-' || formatdate(period_end) || ' YTD') ELSE (period_name || ' YTD') END),'No Data') INTO _year FROM period WHERE (period_id=pPeriodId); IF _year IS NULL THEN _year := _err; END IF; --...for prior month IF (_p.flcol_priortype = 'P') THEN SELECT (CASE WHEN pp.period_name='' THEN formatdate(pp.period_start) || '-' || formatdate(pp.period_end) ELSE pp.period_name END) INTO _prmonth FROM period cp, period pp WHERE ((cp.period_id=pPeriodId) AND (cp.period_start > pp.period_start)) ORDER BY pp.period_start DESC LIMIT 1; ELSE SELECT (CASE WHEN pp.period_name='' THEN formatdate(pp.period_start) || '-' || formatdate(pp.period_end) ELSE pp.period_name END) INTO _prmonth FROM period cp, period pp WHERE ((cp.period_id=pPeriodId) AND (cp.period_id != pp.period_id) AND (cp.period_start > pp.period_start) AND (cp.period_number = pp.period_number)) ORDER BY pp.period_start DESC LIMIT 1; END IF; IF _prmonth IS NULL THEN _prmonth := _err; END IF; --...for prior quarter IF (_p.flcol_priortype='P') THEN SELECT ('Q' || pp.period_quarter || '-' || EXTRACT(year from yearperiod_end)) INTO _prqtr FROM period cp, period pp, yearperiod WHERE ((cp.period_id=pPeriodId) AND (cp.period_start > pp.period_start) AND (pp.period_quarter= CASE WHEN cp.period_quarter > 1 THEN cp.period_quarter - 1 ELSE 4 END) AND (pp.period_start >= cp.period_start - interval '1 year') AND (pp.period_yearperiod_id=yearperiod_id)) ORDER BY pp.period_start DESC LIMIT 1; ELSE SELECT ('Q' || pp.period_quarter || '-' || EXTRACT(year from pp.period_start)) INTO _prqtr FROM period cp, period pp, yearperiod cy, yearperiod py WHERE ((cp.period_id=pPeriodId) AND (cp.period_yearperiod_id=cy.yearperiod_id) AND (pp.period_yearperiod_id=py.yearperiod_id) AND (cp.period_quarter=pp.period_quarter) AND (cy.yearperiod_start > py.yearperiod_start)) ORDER BY py.yearperiod_start DESC, pp.period_start DESC LIMIT 1; END IF; IF _prqtr IS NULL THEN _prqtr := _err; END IF; --...for prior year IF (_p.flcol_prioryear='F') THEN SELECT (EXTRACT(year from py.yearperiod_end)||'') INTO _pryear FROM period cp, yearperiod cy, yearperiod py WHERE ((cp.period_id=pPeriodId) AND (cp.period_yearperiod_id = cy.yearperiod_id) AND (cy.yearperiod_start > py.yearperiod_start)) ORDER BY py.yearperiod_start DESC LIMIT 1; ELSE SELECT (CASE WHEN pp.period_name='' THEN formatdate(pp.period_start) || '-' || formatdate(pp.period_end) || ' YTD' ELSE pp.period_name || ' YTD' END) INTO _pryear FROM period cp, period pp WHERE ((cp.period_id=pPeriodId) AND (cp.period_number = pp.period_number) AND (cp.period_start > pp.period_start)) ORDER BY pp.period_start DESC LIMIT 1; END IF; IF _pryear IS NULL THEN _pryear := _err; END IF; -- RETURN RESULTS SELECT flhead_id AS flstmthead_flhead_id, flcol_id AS flstmthead_flcol_id, pPeriodid AS flstmthead_period, getEffectiveXtUser() AS flstmthead_username, CASE WHEN flhead_type = 'I' THEN 'Income Statement' WHEN flhead_type = 'B' THEN 'Balance Sheet' WHEN flhead_type = 'C' THEN 'Cash Flow Statement' ELSE 'N/A' END AS flstmthead_flhead_typedescrip1, CASE WHEN flhead_type = 'I' THEN 'Income' WHEN flhead_type = 'B' THEN 'Balance' WHEN flhead_type = 'C' THEN 'Cash' ELSE 'N/A' END AS flstmthead_flhead_typedescrip2, flhead_name AS flstmthead_flhead_name, flcol_name AS flstmthead_flcol_name, _month AS flstmthead_month, _qtr AS flstmthead_qtr, _year AS flstmthead_year, _prmonth AS flstmthead_prmonth, _prqtr AS flstmthead_prqtr, _pryear AS flstmthead_pryear INTO _p FROM flhead,flcol WHERE ((flcol_id=pFlcolid) AND (flhead_id=flcol_flhead_id)); _row.flstmthead_flhead_id := _p.flstmthead_flhead_id; _row.flstmthead_flcol_id := _p.flstmthead_flcol_id; _row.flstmthead_period_id := _p.flstmthead_period; _row.flstmthead_username := _p.flstmthead_username; _row.flstmthead_typedescrip1 := _p.flstmthead_flhead_typedescrip1; _row.flstmthead_typedescrip2 := _p.flstmthead_flhead_typedescrip2; _row.flstmthead_flhead_name := _p.flstmthead_flhead_name; _row.flstmthead_flcol_name := _p.flstmthead_flcol_name; _row.flstmthead_month := _p.flstmthead_month; _row.flstmthead_qtr := _p.flstmthead_qtr; _row.flstmthead_year := _p.flstmthead_year; _row.flstmthead_prmonth := _p.flstmthead_prmonth; _row.flstmthead_prqtr := _p.flstmthead_prqtr; _row.flstmthead_pryear := _p.flstmthead_pryear; RETURN NEXT _row; END; $_$; 6DROP FUNCTION public.getflstmthead(integer, integer); publicadminfalse462382715E125578595-getfltrendhead(integer, integer[], character)FUNCTIONPCREATE FUNCTION getfltrendhead(integer, integer[], character) RETURNS SETOF fltrendhead LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlheadid ALIAS FOR $1; pPeriodids ALIAS FOR $2; pInterval ALIAS FOR $3; _row fltrendhead%ROWTYPE; _p RECORD; _count INTEGER; _i INTEGER; _t TEXT; _fld TEXT[]; _type CHAR; BEGIN -- Validate Interval IF pInterval <> 'M' AND pInterval <> 'Q' AND pInterval <> 'Y' THEN RAISE EXCEPTION 'Invalid Interval --> %', pInterval; END IF; IF ARRAY_UPPER(pPeriodIds,1) <= 12 THEN _count := ARRAY_UPPER(pPeriodIds,1); ELSE _count := 12; END IF; SELECT flhead_type INTO _type FROM flhead WHERE flhead_id = pFlheadId; --get data... --...for Month IF (pInterval = 'M') THEN FOR _i IN 1.._count LOOP SELECT (CASE WHEN period_name='' THEN formatdate(period_start) || '-' || formatdate(period_end) ELSE period_name END) INTO _t FROM period WHERE (period_id=pPeriodIds[_i]); _fld[_i] := _t; END LOOP; --...for Quarter ELSE IF (pInterval = 'Q') THEN FOR _i IN 1.._count LOOP SELECT ('Q' || period_quarter || '-' || EXTRACT(year from yearperiod_end)) INTO _t FROM period, yearperiod WHERE ((period_id=pPeriodIds[_i]) AND (period_yearperiod_id=yearperiod_id)); _fld[_i] := _t; END LOOP; --...for Year ELSE FOR _i IN 1.._count LOOP SELECT (EXTRACT(year from yearperiod_end)||'') INTO _t FROM period, yearperiod WHERE ((period_id=pPeriodIds[_i]) AND (period_yearperiod_id=yearperiod_id)); _fld[_i] := _t; END LOOP; END IF; END IF; -- RETURN RESULTS SELECT flhead_id AS fltrendhead_flhead_id, getEffectiveXtUser() AS fltrendhead_username, CASE WHEN flhead_type = 'I' THEN 'Income Statement' WHEN flhead_type = 'B' THEN 'Balance Sheet' WHEN flhead_type = 'C' THEN 'Cash Flow Statement' ELSE 'Ad Hoc' END AS fltrendhead_flhead_typedescrip, flhead_name AS fltrendhead_flhead_name INTO _p FROM flhead WHERE (flhead_id=pFlheadId); _row.fltrendhead_flhead_id := _p.fltrendhead_flhead_id; _row.fltrendhead_username := _p.fltrendhead_username; _row.fltrendhead_typedescrip := _p.fltrendhead_flhead_typedescrip; _row.fltrendhead_flhead_name := _p.fltrendhead_flhead_name; _row.fltrendhead_fld1 := _fld[1]; _row.fltrendhead_fld2 := _fld[2]; _row.fltrendhead_fld3 := _fld[3]; _row.fltrendhead_fld4 := _fld[4]; _row.fltrendhead_fld5 := _fld[5]; _row.fltrendhead_fld6 := _fld[6]; _row.fltrendhead_fld7 := _fld[7]; _row.fltrendhead_fld8 := _fld[8]; _row.fltrendhead_fld9 := _fld[9]; _row.fltrendhead_fld10 := _fld[10]; _row.fltrendhead_fld11 := _fld[11]; _row.fltrendhead_fld12 := _fld[12]; IF (_type IN ('I','C')) THEN _row.fltrendhead_grndttl := 'Total'; END IF; RETURN NEXT _row; END; $_$; DDROP FUNCTION public.getfltrendhead(integer, integer[], character); publicadminfalse271884623F125578596getfreightclassid(text)FUNCTIONXCREATE FUNCTION getfreightclassid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFreightClassCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pFreightClassCode IS NULL) THEN RETURN NULL; END IF; SELECT freightclass_id INTO _returnVal FROM freightclass WHERE (freightclass_code=pFreightClassCode); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Freight Class % not found.', pFreightClassCode; END IF; RETURN _returnVal; END; $_$; .DROP FUNCTION public.getfreightclassid(text); publicadminfalse46238G125578597getfreighttaxtypeid()FUNCTION~CREATE FUNCTION getfreighttaxtypeid() RETURNS integer LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _taxtypeid INTEGER; BEGIN SELECT taxtype_id INTO _taxtypeid FROM taxtype WHERE (taxtype_name='Freight'); RETURN _taxtypeid; END; $$; ,DROP FUNCTION public.getfreighttaxtypeid(); publicadminfalse46238H125578598getgainlossaccntid(integer)FUNCTION7CREATE FUNCTION getgainlossaccntid(integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAccntId ALIAS FOR $1; _returnVal INTEGER; BEGIN IF ( (pAccntId = 0) OR (pAccntId IS NULL) ) THEN RETURN 0; END IF; IF (fetchMetricValue('GLCompanySize') = 0) THEN _returnVal := fetchMetricValue('CurrencyGainLossAccount')::integer; ELSE SELECT company_gainloss_accnt_id INTO _returnVal FROM company JOIN accnt ON (company_number=accnt_company) WHERE (accnt_id=pAccntId); END IF; IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Currency Gain/Loss Account not found for %', formatGlAccountLong(pAccntId); END IF; RETURN _returnVal; END; $_$; 2DROP FUNCTION public.getgainlossaccntid(integer); publicadminfalse84623I125578599getglaccntid(text)FUNCTION'CREATE FUNCTION getglaccntid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pGlAccnt ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pGlAccnt IS NULL) THEN RETURN NULL; END IF; SELECT accnt_id INTO _returnVal FROM accnt WHERE (formatglaccount(accnt_id)=pGlAccnt); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Account Number % not found.', pGlAccnt; END IF; RETURN _returnVal; END; $_$; )DROP FUNCTION public.getglaccntid(text); publicadminfalse84623J125578600$getglaccntid(text, text, text, text)FUNCTIONCREATE FUNCTION getglaccntid(text, text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCompany ALIAS FOR $1; pProfit ALIAS FOR $2; pGlAccnt ALIAS FOR $3; pSub ALIAS FOR $4; _account TEXT; _returnVal INTEGER; BEGIN IF (pGlAccnt IS NULL) THEN RETURN NULL; END IF; IF (pCompany is not null) THEN _account := pCompany || '-'; END IF; IF (pProfit is not null) THEN _account := _account || pProfit || '-'; END IF; IF (pGlAccnt is not null) THEN if (_account is null) then _account := pGlAccnt; else _account := _account || pGlAccnt; end if; END IF; IF (pSub is not null) THEN _account := _account || '-' || pSub; END IF; SELECT accnt_id INTO _returnVal FROM accnt WHERE (formatglaccount(accnt_id)=_account); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Account Number % not found.', _account; END IF; RETURN _returnVal; END; $_$; ;DROP FUNCTION public.getglaccntid(text, text, text, text); publicadminfalse46238K125578601getimageid(text)FUNCTION!CREATE FUNCTION getimageid(pimagename text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (COALESCE(TRIM(pImageName), '') = '') THEN RETURN NULL; END IF; SELECT image_id INTO _returnVal FROM image WHERE (image_name=pImageName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Image % not found.', pImageName; END IF; RETURN _returnVal; END; $$; 2DROP FUNCTION public.getimageid(pimagename text); publicadminfalse46238L125578602getincdtcatid(text)FUNCTION3CREATE FUNCTION getincdtcatid(pincdtcatname text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pIncdtCatName IS NULL) THEN RETURN NULL; END IF; SELECT incdtcat_id INTO _returnVal FROM incdtcat WHERE (incdtcat_name=pIncdtCatName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Incident Category Name % not found.', pIncdtCatName; END IF; RETURN _returnVal; END; $$; 8DROP FUNCTION public.getincdtcatid(pincdtcatname text); publicadminfalse84623M125578603getincdtcrmacctid(integer)FUNCTION<CREATE FUNCTION getincdtcrmacctid(pincidentnumber integer) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pIncidentNumber IS NULL) THEN RETURN NULL; END IF; SELECT incdt_crmacct_id INTO _returnVal FROM incdt WHERE (incdt_number=pIncidentNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Incident Number % not found.', pIncidentNumber; END IF; RETURN _returnVal; END; $$; ADROP FUNCTION public.getincdtcrmacctid(pincidentnumber integer); publicadminfalse46238N125578604getincdtpriorityid(text)FUNCTION[CREATE FUNCTION getincdtpriorityid(pincdtpriorityname text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pIncdtPriorityName IS NULL) THEN RETURN NULL; END IF; SELECT incdtpriority_id INTO _returnVal FROM incdtpriority WHERE (incdtpriority_name=pIncdtPriorityName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Incident Priority Name % not found.', pIncdtPriorityName; END IF; RETURN _returnVal; END; $$; BDROP FUNCTION public.getincdtpriorityid(pincdtpriorityname text); publicadminfalse46238O125578605getincdtresolutionid(text)FUNCTIONmCREATE FUNCTION getincdtresolutionid(pincdtresolutionname text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pIncdtResolutionName IS NULL) THEN RETURN NULL; END IF; SELECT incdtresolution_id INTO _returnVal FROM incdtresolution WHERE (incdtresolution_name=pIncdtResolutionName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Incident Resolution Name % not found.', pIncdtResolutionName; END IF; RETURN _returnVal; END; $$; FDROP FUNCTION public.getincdtresolutionid(pincdtresolutionname text); publicadminfalse46238P125578606getincdtseverityid(text)FUNCTION[CREATE FUNCTION getincdtseverityid(pincdtseverityname text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pIncdtSeverityName IS NULL) THEN RETURN NULL; END IF; SELECT incdtseverity_id INTO _returnVal FROM incdtseverity WHERE (incdtseverity_name=pIncdtSeverityName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Incident Severity Name % not found.', pIncdtSeverityName; END IF; RETURN _returnVal; END; $$; BDROP FUNCTION public.getincdtseverityid(pincdtseverityname text); publicadminfalse84623Q125578607getincidentid(integer)FUNCTION0CREATE FUNCTION getincidentid(pincidentnumber integer) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pIncidentNumber IS NULL) THEN RETURN NULL; END IF; SELECT incdt_id INTO _returnVal FROM incdt WHERE (incdt_number=pIncidentNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Incident Number % not found.', pIncidentNumber; END IF; RETURN _returnVal; END; $$; =DROP FUNCTION public.getincidentid(pincidentnumber integer); publicadminfalse84623R125578608getinvcheadid(text)FUNCTION;CREATE FUNCTION getinvcheadid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvcNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pInvcNumber IS NULL) THEN RETURN NULL; END IF; SELECT invchead_id INTO _returnVal FROM invchead WHERE (UPPER(invchead_invcnumber)=UPPER(pInvcNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Invoice % not found.', pInvcNumber; END IF; RETURN _returnVal; END; $_$; *DROP FUNCTION public.getinvcheadid(text); publicadminfalse46238S125578609getinvcitemlotserial(integer)FUNCTIONACREATE FUNCTION getinvcitemlotserial(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvcitemid ALIAS FOR $1; _lotserial text; _r RECORD; _first BOOLEAN; _newMethod BOOLEAN; BEGIN --Test to see if Lot/Serial Enabled SELECT metric_value INTO _lotserial FROM metric WHERE ((metric_name='LotSerialControl') AND (metric_value ='t')); IF (FOUND) THEN _lotserial := ''; _first := true; -- Two ways of doing this: old method and new method -- First, find out if new method employed. -- (new method is more accurate, but unfortunately no -- way to migrate or correct old data. Have to keep -- old method in case someone reprints an old invoice.) SELECT (COUNT(*) > 0) INTO _newMethod FROM shipitem WHERE ((shipitem_invcitem_id=pInvcitemid) AND (shipitem_invhist_id IS NOT NULL)); IF (_newMethod) THEN FOR _r IN SELECT DISTINCT ls_number FROM invdetail, invhist, shipitem, ls WHERE ((shipitem_invcitem_id=pInvcitemid) AND (shipitem_invhist_id=invhist_id) AND (invhist_id=invdetail_invhist_id) AND (invdetail_ls_id=ls_id)) LOOP IF (_first = false) THEN _lotserial := _lotserial || ', '; END IF; _lotserial := _lotserial || _r.ls_number; _first := false; END LOOP; RETURN _lotserial; ELSE -- Handle it old way FOR _r IN SELECT DISTINCT ls_number FROM ls, invdetail JOIN invhist ON (invdetail_invhist_id=invhist_id) WHERE ((invhist_transtype='SH') AND (invdetail_invcitem_id=pInvcitemid) AND (invdetail_ls_id=ls_id)) LOOP IF (_first = false) THEN _lotserial := _lotserial || ', '; END IF; _lotserial := _lotserial || _r.ls_number; _first := false; END LOOP; RETURN _lotserial; END IF; ELSE RETURN ''; END IF; END $_$; 4DROP FUNCTION public.getinvcitemlotserial(integer); publicadminfalse46238T125578610getipsheadid(text)FUNCTIONCREATE FUNCTION getipsheadid(pipsname text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pIpsName IS NULL) THEN RETURN NULL; END IF; SELECT ipshead_id INTO _returnVal FROM ipshead WHERE (ipshead_name=pIpsName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Pricing Schedule % not found.', pIpsName; END IF; RETURN _returnVal; END; $$; 2DROP FUNCTION public.getipsheadid(pipsname text); publicadminfalse84623U125578611-getipsitemid(text, text, numeric, text, text)FUNCTIONCREATE FUNCTION getipsitemid(pipsname text, pitemnumber text, pqtybreak numeric, pqtyuom text, ppriceuom text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pIpsName IS NULL AND pItemNumber IS NULL AND pQtyBreak IS NULL AND pQtyUom IS NULL AND pPriceUom IS NULL) THEN RETURN NULL; END IF; SELECT ipsitem_id INTO _returnVal FROM ipsiteminfo WHERE ((ipsitem_ipshead_id=getIpsheadId(pIpsName)) AND (ipsitem_item_id=getItemId(pItemNumber)) AND (ipsitem_qtybreak=pQtyBreak) AND (ipsitem_qty_uom_id=getUomId(pQtyUom)) AND (ipsitem_price_uom_id=getUomId(pPriceUom))); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Pricing Schedule Item for Schedule %, Item %,Qt Break %,Qty UOM %, Price UOM % not found.', pIpsName, pItemNumber, pQtyBreak, pQtyUom, pPriceUom; END IF; RETURN _returnVal; END; $$; uDROP FUNCTION public.getipsitemid(pipsname text, pitemnumber text, pqtybreak numeric, pqtyuom text, ppriceuom text); publicadminfalse84623V125578612$getipsprodcatid(text, text, numeric)FUNCTION$CREATE FUNCTION getipsprodcatid(pipsname text, pprodcat text, pqtybreak numeric) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pIpsName IS NULL AND pProdCat IS NULL AND pQtyBreak IS NULL) THEN RETURN NULL; END IF; SELECT ipsitem_id INTO _returnVal FROM ipsiteminfo WHERE ((ipsitem_ipshead_id=getIpsheadId(pIpsName)) AND (ipsitem_prodcat_id=getProdcatId(pProdCat)) AND (ipsitem_qtybreak=pQtyBreak)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Pricing Schedule Product Category for Schedule %, Product Category %,Qt Break % not found.', pIpsName, pProdCat, pQtyBreak; END IF; RETURN _returnVal; END; $$; WDROP FUNCTION public.getipsprodcatid(pipsname text, pprodcat text, pqtybreak numeric); publicadminfalse46238W125578613getitemid(text)FUNCTION'CREATE FUNCTION getitemid(text) RETURNS integer LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pItemNumber IS NULL) THEN RETURN NULL; END IF; SELECT item_id INTO _returnVal FROM item WHERE (item_number=UPPER(pItemNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Item % not found.', pItemNumber; END IF; RETURN _returnVal; END; $_$; &DROP FUNCTION public.getitemid(text); publicadminfalse84623X125578614getitemidfromupc(text)FUNCTIONCREATE FUNCTION getitemidfromupc(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemUPC ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pItemUPC IS NULL) THEN RETURN NULL; END IF; SELECT item_id INTO _returnVal FROM item WHERE (item_upccode=UPPER(pItemUPC)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Item % not found.', pItemUPC; END IF; RETURN _returnVal; END; $_$; -DROP FUNCTION public.getitemidfromupc(text); publicadminfalse46238\125587032getitemsitecompanyid(integer)FUNCTIONFCREATE FUNCTION getitemsitecompanyid(pitemsite integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pItemSite IS NULL) THEN RETURN -1; END IF; SELECT getcompanyid(warehous_default_accnt_id) INTO _returnVal FROM whsinfo JOIN itemsite ON (itemsite_warehous_id=warehous_id) WHERE itemsite_id = pItemSite; IF (_returnVal IS NULL) THEN RETURN -1; END IF; RETURN _returnVal; END; $$; >DROP FUNCTION public.getitemsitecompanyid(pitemsite integer); publicadminfalse84623Y125578615getitemsiteid(text, text)FUNCTIONCREATE FUNCTION getitemsiteid(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehouseCode ALIAS FOR $1; pItemNumber ALIAS FOR $2; _returnVal INTEGER; BEGIN SELECT getItemsiteId(pWarehouseCode,pItemNumber,'ALL') INTO _returnVal; RETURN _returnVal; END; $_$; 0DROP FUNCTION public.getitemsiteid(text, text); publicadminfalse46238[125578616getitemsiteid(text, text, text)FUNCTION-CREATE FUNCTION getitemsiteid(text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehouseCode ALIAS FOR $1; pItemNumber ALIAS FOR $2; pType ALIAS FOR $3; _type TEXT; _p RECORD; BEGIN IF ((pWarehouseCode IS NULL) OR (pItemNumber IS NULL)) THEN RETURN NULL; END IF; IF UPPER(pType) NOT IN ('ALL','ACTIVE','SOLD') THEN RAISE EXCEPTION 'Invalid Type %. Valid Itemsite types are ALL and SOLD', pType; END IF; SELECT * INTO _p FROM itemsite, item WHERE ((itemsite_item_id=item_id) AND (itemsite_warehous_id=getWarehousId(pWarehouseCode,'ALL')) AND (item_number=UPPER(pItemNumber))); IF NOT (FOUND) THEN RAISE EXCEPTION 'Item % not found in Warehouse %', pItemNumber, pWarehouseCode; ELSIF ((UPPER(pType)='ACTIVE') OR (UPPER(pType)='SOLD')) THEN IF NOT (_p.item_active) THEN RAISE EXCEPTION 'Item % is inactive.', pItemNumber; ELSE IF NOT (_p.itemsite_active) THEN RAISE EXCEPTION 'Item % is inactive in Warehouse %', pItemNumber, pWarehouseCode; ELSE IF ((UPPER(pType)='SOLD') AND NOT _p.item_sold) THEN RAISE EXCEPTION 'Item % is not sold', pItemNumber; ELSE IF ((UPPER(pType)='SOLD') AND NOT _p.itemsite_sold) THEN RAISE EXCEPTION 'Item % is not sold from Warehouse %', pItemNumber, pWarehouseCode; END IF; END IF; END IF; END IF; END IF; RETURN _p.itemsite_id; END; $_$; 6DROP FUNCTION public.getitemsiteid(text, text, text); publicadminfalse84623]125578617getitemsrcid(text, text)FUNCTIONCREATE FUNCTION getitemsrcid(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemNumber ALIAS FOR $1; pVendNumber ALIAS FOR $2; _returnVal INTEGER; BEGIN IF ((pItemNumber IS NULL) OR (pVendNumber IS NULL)) THEN RETURN NULL; END IF; SELECT itemsrc_id INTO _returnVal FROM itemsrc WHERE ((itemsrc_item_id=getItemId(pItemNumber)) AND (itemsrc_vend_id=getVendId(pVendNumber))); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Item Source Item % Vendor % not found.', pItemNumber,pVendNumber; END IF; RETURN _returnVal; END; $_$; /DROP FUNCTION public.getitemsrcid(text, text); publicadminfalse46238_125578618#getlasttrialbalid(integer, integer)FUNCTIONsCREATE FUNCTION getlasttrialbalid(integer, integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAccntId ALIAS FOR $1; pPeriodId ALIAS FOR $2; _p RECORD; _accntType TEXT; _result NUMERIC; BEGIN SELECT period_end,period_yearperiod_id INTO _p FROM period WHERE period_id=pPeriodId; SELECT accnt_type INTO _accntType FROM accnt WHERE accnt_id=pAccntId; IF (_accntType IN ('R','E')) THEN SELECT trialbal_id INTO _result FROM trialbal WHERE ((trialbal_accnt_id=pAccntId) AND (trialbal_period_id=pPeriodId)); ELSE SELECT trialbal_id INTO _result FROM (SELECT trialbal_id FROM trialbal,period WHERE ((trialbal_accnt_id=pAccntId) AND (trialbal_period_id=period_id) AND (period_end <= _p.period_end) AND (period_yearperiod_id=_p.period_yearperiod_id)) ORDER BY period_end DESC) AS data; END IF; RETURN _result; END; $_$; :DROP FUNCTION public.getlasttrialbalid(integer, integer); publicadminfalse46238`125578619getlocationid(text, text)FUNCTIONCREATE FUNCTION getlocationid(pwarehouse text, plocation text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pLocation IS NULL) THEN RETURN NULL; END IF; SELECT location_id INTO _returnVal FROM location WHERE ((location_warehous_id=getWarehousId(pWarehouse,'ACTIVE')) AND (location_formatname=pLocation)) LIMIT 1; IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Location % not found in Warehouse %.', pLocation, pWarehouse; END IF; RETURN _returnVal; END; $$; EDROP FUNCTION public.getlocationid(pwarehouse text, plocation text); publicadminfalse46238a125578620getlotserialid(text, text)FUNCTIONCREATE FUNCTION getlotserialid(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemNumber ALIAS FOR $1; pLotSerialNumber ALIAS FOR $2; _returnVal INTEGER; BEGIN IF ((pItemNumber IS NULL) OR (pLotSerialNumber IS NULL) OR (pLotSerialNumber='')) THEN RETURN NULL; END IF; SELECT ls_id INTO _returnVal FROM ls WHERE ((ls_item_id=getItemId(pItemNumber)) AND (UPPER(ls_number)=UPPER(pLotSerialNumber))); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'LotSerial % not found.', pLotSerialNumber; END IF; RETURN _returnVal; END; $_$; 1DROP FUNCTION public.getlotserialid(text, text); publicadminfalse46238i125578621'getopenshipment(text, integer, integer)FUNCTION CREATE FUNCTION getopenshipment(pordertype text, porderid integer, pwarehousid integer) RETURNS text LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _result TEXT := ''; BEGIN IF (pOrderType = 'SO') THEN SELECT shiphead_number INTO _result FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id) JOIN coitem ON (coitem_id=shipitem_orderitem_id) JOIN itemsite ON (itemsite_id=coitem_itemsite_id) WHERE (shiphead_order_id=pOrderId) AND (shiphead_order_type='SO') AND (NOT shiphead_shipped) AND (CASE WHEN (pWarehousId IS NULL) THEN TRUE ELSE itemsite_warehous_id=pWarehousId END) ORDER BY shiphead_number LIMIT 1; ELSEIF (pOrderType = 'TO') THEN SELECT shiphead_number INTO _result FROM shiphead JOIN tohead ON (tohead_id=shiphead_order_id) WHERE (shiphead_order_id=pOrderId) AND (shiphead_order_type='TO') AND (NOT shiphead_shipped) AND (CASE WHEN (pWarehousId IS NULL) THEN TRUE ELSE tohead_src_warehous_id=pWarehousId END) ORDER BY shiphead_number LIMIT 1; END IF; RETURN _result; END; $$; ^DROP FUNCTION public.getopenshipment(pordertype text, porderid integer, pwarehousid integer); publicadminfalse46238j125578622)getopenshipmentid(text, integer, integer)FUNCTION CREATE FUNCTION getopenshipmentid(pordertype text, porderid integer, pwarehousid integer) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _result INTEGER := -1; BEGIN IF (pOrderType = 'SO') THEN SELECT shiphead_id INTO _result FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id) JOIN coitem ON (coitem_id=shipitem_orderitem_id) JOIN itemsite ON (itemsite_id=coitem_itemsite_id) WHERE (shiphead_order_id=pOrderId) AND (shiphead_order_type='SO') AND (NOT shiphead_shipped) AND (CASE WHEN (pWarehousId IS NULL) THEN TRUE ELSE itemsite_warehous_id=pWarehousId END) ORDER BY shiphead_number LIMIT 1; ELSEIF (pOrderType = 'TO') THEN SELECT shiphead_id INTO _result FROM shiphead JOIN tohead ON (tohead_id=shiphead_order_id) WHERE (shiphead_order_id=pOrderId) AND (shiphead_order_type='TO') AND (NOT shiphead_shipped) AND (CASE WHEN (pWarehousId IS NULL) THEN TRUE ELSE tohead_src_warehous_id=pWarehousId END) ORDER BY shiphead_number LIMIT 1; END IF; RETURN _result; END; $$; `DROP FUNCTION public.getopenshipmentid(pordertype text, porderid integer, pwarehousid integer); publicadminfalse84623b125578623getopheadid(text)FUNCTION>CREATE FUNCTION getopheadid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOpHeadName ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pOpHeadName IS NULL) THEN RETURN NULL; END IF; SELECT ophead_id INTO _returnVal FROM ophead WHERE (UPPER(ophead_name)=UPPER(pOpHeadName)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Opportunity % not found.', pOpHeadName; END IF; RETURN _returnVal; END; $_$; (DROP FUNCTION public.getopheadid(text); publicadminfalse46238Z125578624%getpacklistcharname(integer, integer)FUNCTIONCREATE FUNCTION getpacklistcharname(integer, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipheadId ALIAS FOR $1; pOrderItemId ALIAS FOR $2; _charname text; _r RECORD; _first BOOLEAN; BEGIN -- If transfer order, get out SELECT shiphead_order_type INTO _r FROM shiphead WHERE ((shiphead_id=pShipheadId) AND (shiphead_order_type='TO')); IF (FOUND) THEN RETURN ''; END IF; _charname := ''; _first := true; FOR _r IN SELECT char_name FROM char, charass WHERE ((char_id=charass_char_id) AND (charass_target_type='SI') AND (charass_target_id=pOrderItemId)) LOOP IF (_first = false) THEN _charname := _charname || ' '; END IF; _charname := _charname || _r.char_name; _first := false; END LOOP; RETURN _charname; END $_$; <DROP FUNCTION public.getpacklistcharname(integer, integer); publicadminfalse84623d125578625&getpacklistcharvalue(integer, integer)FUNCTIONCREATE FUNCTION getpacklistcharvalue(integer, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipheadId ALIAS FOR $1; pOrderItemId ALIAS FOR $2; _charval text; _r RECORD; _first BOOLEAN; BEGIN -- If transfer order, get out SELECT shiphead_order_type INTO _r FROM shiphead WHERE ((shiphead_id=pShipheadId) AND (shiphead_order_type='TO')); IF (FOUND) THEN RETURN ''; END IF; _charval := ''; _first := true; FOR _r IN SELECT charass_value FROM char, charass WHERE ((char_id=charass_char_id) AND (charass_target_type='SI') AND (charass_target_id=pOrderItemId)) LOOP IF (_first = false) THEN _charval := _charval || ' '; END IF; _charval := _charval || _r.charass_value; _first := false; END LOOP; RETURN _charval; END $_$; =DROP FUNCTION public.getpacklistcharvalue(integer, integer); publicadminfalse84623e125578626*getpacklistitemlotserial(integer, integer)FUNCTIONCREATE FUNCTION getpacklistitemlotserial(integer, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipheadId ALIAS FOR $1; pOrderItemId ALIAS FOR $2; _lotserial text; _r RECORD; _first BOOLEAN; BEGIN --Test to see if Lot/Serial Enabled SELECT metric_value INTO _lotserial FROM metric WHERE ((metric_name='LotSerialControl') AND (metric_value ='t')); IF (FOUND) THEN _lotserial := ''; _first := true; FOR _r IN SELECT DISTINCT ls_number FROM invdetail, invhist, shipitem, ls WHERE ((shipitem_shiphead_id=pShipheadId) AND (shipitem_orderitem_id=pOrderItemId) AND (shipitem_invhist_id=invhist_id) AND (invhist_id=invdetail_invhist_id) AND (invdetail_ls_id=ls_id)) LOOP IF (_first = false) THEN _lotserial := _lotserial || ', '; END IF; _lotserial := _lotserial || _r.ls_number; _first := false; END LOOP; RETURN _lotserial; ELSE RETURN ''; END IF; END $_$; ADROP FUNCTION public.getpacklistitemlotserial(integer, integer); publicadminfalse46238g125578627getperiodid(date)FUNCTION?CREATE FUNCTION getperiodid(date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodDate ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pPeriodDate IS NULL) THEN RETURN NULL; END IF; SELECT period_id INTO _returnVal FROM period WHERE ((pPeriodDate) between period_start AND period_end); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Period for % not found.', pPeriodDate; END IF; RETURN _returnVal; END; $_$; (DROP FUNCTION public.getperiodid(date); publicadminfalse84623f125578628getperiodid(integer, character)FUNCTIONCREATE FUNCTION getperiodid(integer, character) RETURNS SETOF integer LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodId ALIAS FOR $1; pInterval ALIAS FOR $2; _x RECORD; BEGIN -- Validate Interval IF pInterval <> 'M' AND pInterval <> 'Q' AND pInterval <> 'Y' THEN RAISE EXCEPTION 'Invalid Interval --> %', pInterval; END IF; IF pInterval='M' THEN RETURN NEXT pPeriodId; ELSE IF pInterval='Q' THEN FOR _x IN SELECT qp.period_id AS period_id FROM period cp, period qp WHERE ((cp.period_id=pPeriodId) AND (cp.period_yearperiod_id=qp.period_yearperiod_id) AND (cp.period_quarter=qp.period_quarter) AND (cp.period_start>=qp.period_start)) ORDER BY qp.period_start LOOP RETURN NEXT _x.period_id; END LOOP; ELSE FOR _x IN SELECT yp.period_id AS period_id FROM period cp, period yp WHERE ((cp.period_id=pPeriodId) AND (cp.period_yearperiod_id=yp.period_yearperiod_id) AND (cp.period_start>=yp.period_start)) ORDER BY yp.period_start LOOP RETURN NEXT _x.period_id; END LOOP; END IF; END IF; RETURN; END; $_$; 6DROP FUNCTION public.getperiodid(integer, character); publicadminfalse46238h125578629getpkgheadid(text)FUNCTION+CREATE FUNCTION getpkgheadid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ppkgname ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (ppkgname IS NULL) THEN RETURN NULL; END IF; SELECT pkghead_id INTO _returnVal FROM pkghead WHERE (UPPER(pkghead_name)=UPPER(ppkgname)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Package % not found.', ppkgname; END IF; RETURN _returnVal; END; $_$; )DROP FUNCTION public.getpkgheadid(text); publicadminfalse46238c125578630getplancodeid(text)FUNCTION!CREATE FUNCTION getplancodeid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPlanCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pPlanCode IS NULL) THEN RETURN NULL; END IF; SELECT plancode_id INTO _returnVal FROM plancode WHERE (plancode_code=pPlanCode); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Plan Code % not found.', pPlanCode; END IF; RETURN _returnVal; END; $_$; *DROP FUNCTION public.getplancodeid(text); publicadminfalse46238k125578631getpoheadid(text)FUNCTIONOCREATE FUNCTION getpoheadid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPurchaseOrderNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pPurchaseOrderNumber IS NULL) THEN RETURN NULL; END IF; SELECT pohead_id INTO _returnVal FROM pohead WHERE (pohead_number=pPurchaseOrderNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Purchase Order % not found.', pPurchaseOrderNumber; END IF; RETURN _returnVal; END; $_$; (DROP FUNCTION public.getpoheadid(text); publicadminfalse46238l125578632getpoitemid(text, integer)FUNCTIONCREATE FUNCTION getpoitemid(text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPurchaseOrderNumber ALIAS FOR $1; pLineNumber ALIAS FOR $2; _returnVal INTEGER; BEGIN IF (pPurchaseOrderNumber IS NULL OR pLineNumber IS NULL) THEN RETURN NULL; END IF; SELECT poitem_id INTO _returnVal FROM pohead, poitem WHERE ((pohead_number=pPurchaseOrderNumber) AND (poitem_pohead_id=pohead_id) AND (poitem_linenumber=pLineNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Purchase Order % not found.', pSalesOrderNumber; END IF; RETURN _returnVal; END; $_$; 1DROP FUNCTION public.getpoitemid(text, integer); publicadminfalse46238m125578633getprjaccntid(integer, integer)FUNCTIONCREATE FUNCTION getprjaccntid(integer, integer) RETURNS integer LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrjid ALIAS FOR $1; pAccntid ALIAS FOR $2; BEGIN -- Project Accounting is required to fully implement this functionality RETURN pAccntId; END; $_$; 6DROP FUNCTION public.getprjaccntid(integer, integer); publicadminfalse46238n125578634getprjid(text)FUNCTION CREATE FUNCTION getprjid(pprjnumber text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pPrjNumber IS NULL) THEN RETURN NULL; END IF; SELECT prj_id INTO _returnVal FROM prj WHERE (prj_number=pPrjNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Project Number % not found.', pPrjNumber; END IF; RETURN _returnVal; END; $$; 0DROP FUNCTION public.getprjid(pprjnumber text); publicadminfalse46238o125578635getprjtaskid(text, text)FUNCTIONCREATE FUNCTION getprjtaskid(pprjnumber text, ptasknumber text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pPrjNumber IS NULL OR pTaskNumber IS NULL) THEN RETURN NULL; END IF; SELECT prjtask_id INTO _returnVal FROM prjtask JOIN prj ON (prj_id=prjtask_prj_id) WHERE ((prj_number=pPrjNumber) AND (prjtask_number=pTaskNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Project Task Number %-% not found.', pPrjNumber, pTaskNumber; END IF; RETURN _returnVal; END; $$; FDROP FUNCTION public.getprjtaskid(pprjnumber text, ptasknumber text); publicadminfalse46238p125578636getprodcatid(text)FUNCTION#CREATE FUNCTION getprodcatid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pProdCat ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pProdCat IS NULL) THEN RETURN NULL; END IF; SELECT prodcat_id INTO _returnVal FROM prodcat WHERE (prodcat_code=pProdCat); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Product Category % not found.', pProdCat; END IF; RETURN _returnVal; END; $_$; )DROP FUNCTION public.getprodcatid(text); publicadminfalse46238q125578637getprospectid(text)FUNCTIONRCREATE FUNCTION getprospectid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pProspectNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pProspectNumber IS NULL) THEN RETURN NULL; END IF; SELECT prospect_id INTO _returnVal FROM prospect WHERE(UPPER(prospect_number)=UPPER(pProspectNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Prospect Number % found.', pProspectNumber; END IF; RETURN _returnVal; END; $_$; *DROP FUNCTION public.getprospectid(text); publicadminfalse46238r125578638getquoteid(text)FUNCTION,CREATE FUNCTION getquoteid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuoteNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pQuoteNumber IS NULL) THEN RETURN NULL; END IF; SELECT quhead_id INTO _returnVal FROM quhead WHERE (quhead_number=pQuoteNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Quote Number % not found.', pQuoteNumber; END IF; RETURN _returnVal; END; $_$; 'DROP FUNCTION public.getquoteid(text); publicadminfalse84623t125578639!getquotelineitemid(text, integer)FUNCTIONCREATE FUNCTION getquotelineitemid(text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuoteNumber ALIAS FOR $1; pLineNumber ALIAS FOR $2; _returnVal INTEGER; BEGIN IF ((pQuoteNumber IS NULL) OR (pLineNumber IS NULL)) THEN RETURN NULL; END IF; SELECT quitem_id INTO _returnVal FROM quhead, quitem WHERE ((quhead_number=pQuoteNumber) AND (quhead_id=quitem_quhead_id) AND (quitem_linenumber=pLineNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Quote Line Item %-%not found.', pQuoteNumber,pLineNumber; END IF; RETURN _returnVal; END; $_$; 8DROP FUNCTION public.getquotelineitemid(text, integer); publicadminfalse84623s125578640getquotescheddate(integer)FUNCTIONCREATE FUNCTION getquotescheddate(integer) RETURNS date LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuheadid ALIAS FOR $1; _minscheddate DATE; BEGIN SELECT MIN(quitem_scheddate) INTO _minscheddate FROM quitem WHERE (quitem_quhead_id=pQuheadid); RETURN _minscheddate; END; $_$; 1DROP FUNCTION public.getquotescheddate(integer); publicadminfalse46238u125578641getrevid(text, text, text)FUNCTIONDCREATE FUNCTION getrevid(text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pType ALIAS FOR $1; pItemNumber ALIAS FOR $2; pRevision ALIAS FOR $3; _returnVal INTEGER; BEGIN IF (pItemNumber IS NULL) THEN RETURN NULL; END IF; IF (NOT fetchMetricBool('RevControl')) THEN RETURN -1; ELSIF ( (pRevision IS NULL) OR (LENGTH(pRevision)=0) ) THEN SELECT getActiveRevId(pType, getItemId(pItemNumber)) INTO _returnVal; ELSE IF (pType='BOM') THEN SELECT rev_id INTO _returnVal FROM item, bomhead, rev WHERE ((item_id=bomhead_item_id) AND (bomhead_rev_id=rev_id) AND (UPPER(item_number)=UPPER(pItemNumber)) AND (rev_number=pRevision)); ELSIF (pType='BOO') THEN SELECT rev_id INTO _returnVal FROM item, xtmfg.boohead, rev WHERE ((item_id=boohead_item_id) AND (boohead_rev_id=rev_id) AND (UPPER(item_number)=UPPER(pItemNumber)) AND (rev_number=pRevision)); ELSE RAISE EXCEPTION 'Invalid Revision Type.'; END IF; END IF; IF (_returnVal IS NULL) THEN RAISE EXCEPTION '% revision % for % not found.', pType, pRevision, pItemNumber; END IF; RETURN _returnVal; END; $_$; 1DROP FUNCTION public.getrevid(text, text, text); publicadminfalse46238v125578642getrsnid(text)FUNCTIONCREATE FUNCTION getrsnid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pRsnCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pRsnCode IS NULL) THEN RETURN NULL; END IF; SELECT rsncode_id INTO _returnVal FROM rsncode WHERE (rsncode_code=pRsnCode); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Reason Code % not found.', pRsnCode; END IF; RETURN _returnVal; END; $_$; %DROP FUNCTION public.getrsnid(text); publicadminfalse84623w125578643getsalescatid(text)FUNCTION9CREATE FUNCTION getsalescatid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSalesCatName ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pSalesCatName IS NULL) THEN RETURN NULL; END IF; SELECT salescat_id INTO _returnVal FROM salescat WHERE (salescat_name=pSalesCatName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Sales Category % not found.', pSalesCatName; END IF; RETURN _returnVal; END; $_$; *DROP FUNCTION public.getsalescatid(text); publicadminfalse46238x125578644getsaleslineitemid(text)FUNCTIONCREATE FUNCTION getsaleslineitemid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSalesOrderItem ALIAS FOR $1; _delpos INTEGER = 0; _order TEXT; _part TEXT; _ln INTEGER; _sn INTEGER; BEGIN IF (pSalesOrderItem IS NULL) THEN RETURN NULL; END IF; _delpos := strpos(pSalesOrderItem, '-'); IF (_delpos > 0) THEN _order := substr(pSalesOrderItem, 1, (_delpos - 1)); _part := substr(pSalesOrderItem, (_delpos + 1)); _delpos := strpos(_part, '.'); IF (_delpos > 0) THEN _ln := CAST(substr(_part, 1, (_delpos - 1)) AS INTEGER); _sn := CAST(substr(_part, (_delpos + 1)) AS INTEGER); ELSE _ln := CAST(_part AS INTEGER); _sn := 0; END IF; RETURN getSalesLineItemId( _order, _ln, _sn ); END IF; RETURN 0; END; $_$; /DROP FUNCTION public.getsaleslineitemid(text); publicadminfalse46238y125578645!getsaleslineitemid(text, integer)FUNCTIONCREATE FUNCTION getsaleslineitemid(text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN getSalesLineItemId($1, $2, 0); END $_$; 8DROP FUNCTION public.getsaleslineitemid(text, integer); publicadminfalse46238z125578646*getsaleslineitemid(text, integer, integer)FUNCTION3CREATE FUNCTION getsaleslineitemid(text, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSalesOrderNumber ALIAS FOR $1; pLineNumber ALIAS FOR $2; pSubNumber ALIAS FOR $3; _returnVal INTEGER; BEGIN IF ((pSalesOrderNumber IS NULL) OR (pLineNumber IS NULL)) THEN RETURN NULL; END IF; SELECT coitem_id INTO _returnVal FROM cohead, coitem WHERE ((cohead_number=pSalesOrderNumber) AND (cohead_id=coitem_cohead_id) AND (coitem_linenumber=pLineNumber) AND (coitem_subnumber=pSubNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Sales Line Item %-%not found.', pSalesOrderNumber,pLineNumber; END IF; RETURN _returnVal; END; $_$; ADROP FUNCTION public.getsaleslineitemid(text, integer, integer); publicadminfalse46238{125578647getsalesorderid(text)FUNCTIONKCREATE FUNCTION getsalesorderid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSalesOrderNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pSalesOrderNumber IS NULL) THEN RETURN NULL; END IF; SELECT cohead_id INTO _returnVal FROM cohead WHERE (cohead_number=pSalesOrderNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Sales Order Number % not found.', pSalesOrderNumber; END IF; RETURN _returnVal; END; $_$; ,DROP FUNCTION public.getsalesorderid(text); publicadminfalse84623|125578648getsalesrepid(text)FUNCTIONECREATE FUNCTION getsalesrepid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSalesRepNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pSalesRepNumber IS NULL) THEN RETURN NULL; END IF; SELECT salesrep_id INTO _returnVal FROM salesrep WHERE (salesrep_number=pSalesRepNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Sales Rep Number % not found.', pSalesRepNumber; END IF; RETURN _returnVal; END; $_$; *DROP FUNCTION public.getsalesrepid(text); publicadminfalse46238}125578649getsaletypeid(text)FUNCTIONCREATE FUNCTION getsaletypeid(psaletype text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pSaleType IS NULL) THEN RETURN NULL; END IF; SELECT saletype_id INTO _returnVal FROM saletype WHERE (saletype_code=UPPER(pSaleType)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Sale Type % not found.', pSaleType; END IF; RETURN _returnVal; END; $$; 4DROP FUNCTION public.getsaletypeid(psaletype text); publicadminfalse46238~125578650getshiftid(text)FUNCTIONFCREATE FUNCTION getshiftid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShiftNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (COALESCE(TRIM(pShiftNumber), '') = '') THEN RETURN NULL; END IF; SELECT shift_id INTO _returnVal FROM shift WHERE (UPPER(shift_number)=UPPER(pShiftNumber)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Shift % not found.', pShiftNumber; END IF; RETURN _returnVal; END; $_$; 'DROP FUNCTION public.getshiftid(text); publicadminfalse46238125578651getshipchrgid(text)FUNCTION3CREATE FUNCTION getshipchrgid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipChrgName ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pShipChrgName IS NULL) THEN RETURN NULL; END IF; SELECT shipchrg_id INTO _returnVal FROM shipchrg WHERE (shipchrg_name=pShipChrgName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Ship Charge % not found.', pShipChrgName; END IF; RETURN _returnVal; END; $_$; *DROP FUNCTION public.getshipchrgid(text); publicadminfalse46238125578652getshipformid(text)FUNCTION9CREATE FUNCTION getshipformid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipFormName ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pShipFormName IS NULL) THEN RETURN NULL; END IF; SELECT shipform_id INTO _returnVal FROM shipform WHERE (shipform_name=pShipFormName) LIMIT 1; IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Ship Form % not found.', pShipFormName; END IF; RETURN _returnVal; END; $_$; *DROP FUNCTION public.getshipformid(text); publicadminfalse84623125578653getshipheadid(text)FUNCTIONUCREATE FUNCTION getshipheadid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipmentNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pShipmentNumber IS NULL OR pShipmentNumber = '') THEN RETURN NULL; END IF; SELECT shiphead_id INTO _returnVal FROM shiphead WHERE (shiphead_number=pShipmentNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Shipment % not found.', pShipmentNumber; END IF; RETURN _returnVal; END; $_$; *DROP FUNCTION public.getshipheadid(text); publicadminfalse84623125578654getshiptoid(text, text)FUNCTIONCREATE FUNCTION getshiptoid(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustNumber ALIAS FOR $1; pShiptoNumber ALIAS FOR $2; _returnVal INTEGER; BEGIN IF ((pCustNumber IS NULL) OR (pShiptoNumber IS NULL)) THEN RETURN NULL; END IF; SELECT shipto_id INTO _returnVal FROM shiptoinfo WHERE ((shipto_cust_id=getCustId(pCustNumber,true)) AND (UPPER(shipto_num)=UPPER(pShiptoNumber))); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Shipto % not found.', pShiptoNumber; END IF; RETURN _returnVal; END; $_$; .DROP FUNCTION public.getshiptoid(text, text); publicadminfalse46238125578655wgetshiptonumberfrominfo(text, text, text, text, text, text, text, text, text, text, text, text, text, boolean, boolean)FUNCTION9CREATE FUNCTION getshiptonumberfrominfo(text, text, text, text, text, text, text, text, text, text, text, text, text, boolean, boolean) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _custname TEXT := COALESCE(TRIM(UPPER( $1)), ''); _email TEXT := COALESCE(TRIM(UPPER( $2)), ''); _company TEXT := COALESCE(TRIM(UPPER( $3)), ''); _first TEXT := COALESCE(TRIM(UPPER( $4)), ''); _last TEXT := COALESCE(TRIM(UPPER( $5)), ''); _fullname TEXT := COALESCE(TRIM(UPPER( $6)), ''); _addr1 TEXT := COALESCE(TRIM(UPPER( $7)), ''); _addr2 TEXT := COALESCE(TRIM(UPPER( $8)), ''); _addr3 TEXT := COALESCE(TRIM(UPPER( $9)), ''); _city TEXT := COALESCE(TRIM(UPPER($10)), ''); _state TEXT := COALESCE(TRIM(UPPER($11)), ''); _postalcode TEXT := COALESCE(TRIM(UPPER($12)), ''); _country TEXT := COALESCE(TRIM(UPPER($13)), ''); _generate BOOLEAN := COALESCE($14, FALSE); _create BOOLEAN := COALESCE($15, FALSE); _citytrunc TEXT; _counter INTEGER; _custid INTEGER; _custnumber TEXT; _candidate TEXT; _r RECORD; _statetrunc TEXT; BEGIN IF (_custname = '') THEN _custname := getCustNameFromInfo(_email, _company, _first, _last, _fullname, FALSE); END IF; SELECT COUNT(*) INTO _counter FROM custinfo, shiptoinfo, addr WHERE ((UPPER(cust_name)=UPPER(_custname)) AND UPPER(shipto_name)=UPPER(_fullname) AND (cust_id=shipto_cust_id) AND (shipto_addr_id=addr_id)); IF (_counter = 1) THEN SELECT shipto_num INTO _candidate FROM custinfo, shiptoinfo, addr WHERE ((UPPER(cust_name)=UPPER(_custname)) AND UPPER(shipto_name)=UPPER(_fullname) AND (cust_id=shipto_cust_id) AND (shipto_addr_id=addr_id)); RETURN _candidate; ELSE SELECT COUNT(*) INTO _counter FROM custinfo, shiptoinfo, addr WHERE ((UPPER(cust_name)=UPPER(_custname)) AND (cust_id=shipto_cust_id) AND (shipto_addr_id=addr_id)); IF (_counter = 1) THEN SELECT shipto_num INTO _candidate FROM custinfo, shiptoinfo, addr WHERE ((UPPER(cust_name)=UPPER(_custname)) AND (cust_id=shipto_cust_id) AND (shipto_addr_id=addr_id)); RETURN _candidate; ELSIF (_counter > 1) THEN SELECT shipto_num, CASE WHEN (UPPER(addr_country) = _country) THEN 1 ELSE 0 END + CASE WHEN (UPPER(addr_postalcode) = _postalcode) THEN 1 ELSE 0 END + CASE WHEN (UPPER(addr_state) = _state) THEN 1 ELSE 0 END + CASE WHEN (UPPER(addr_city) = _city) THEN 1 ELSE 0 END + CASE WHEN (UPPER(addr_line3) = _addr3) THEN 1 ELSE 0 END + CASE WHEN (UPPER(addr_line2) = _addr2) THEN 1 ELSE 0 END + CASE WHEN (UPPER(addr_line1) = _addr1) THEN 1 ELSE 0 END AS maxquotient INTO _candidate, _counter FROM custinfo, shiptoinfo, addr WHERE ((UPPER(cust_name)=_custname) AND (cust_id=shipto_cust_id) AND (shipto_addr_id=addr_id)) ORDER BY maxquotient desc LIMIT 1; RETURN _candidate; END IF; END IF; IF (_generate) THEN SELECT cust_number, cust_id INTO _custnumber, _custid FROM custinfo WHERE (UPPER(cust_name)=_custname); -- keep the number short _citytrunc := SUBSTRING(_city FOR 5); _statetrunc := SUBSTRING(_state FOR 5); IF (LENGTH(_citytrunc) > 0 AND NOT EXISTS(SELECT UPPER(shipto_num) FROM shiptoinfo WHERE ((shipto_cust_id=_custid) AND (UPPER(shipto_num)=_citytrunc)) )) THEN _candidate := _citytrunc; ELSIF (LENGTH(_last || _citytrunc) > 0 AND NOT EXISTS(SELECT UPPER(shipto_num) FROM shiptoinfo WHERE ((shipto_cust_id=_custid) AND (UPPER(shipto_num)=_last || _citytrunc)) )) THEN _candidate := _last || _citytrunc; ELSIF (LENGTH(_statetrunc) > 0 AND NOT EXISTS(SELECT UPPER(shipto_num) FROM shiptoinfo WHERE ((shipto_cust_id=_custid) AND (UPPER(shipto_num)=_statetrunc)) )) THEN _candidate := _statetrunc; ELSIF (LENGTH(_last || _statetrunc) > 0 AND NOT EXISTS(SELECT UPPER(shipto_num) FROM shiptoinfo WHERE ((shipto_cust_id=_custid) AND (UPPER(shipto_num)=_last || _statetrunc)) )) THEN _candidate := _last || _statetrunc; ELSIF (LENGTH(_citytrunc || _statetrunc) > 0 AND NOT EXISTS(SELECT UPPER(shipto_num) FROM shiptoinfo WHERE ((shipto_cust_id=_custid) AND (UPPER(shipto_num)=_citytrunc || _statetrunc)) )) THEN _candidate := _citytrunc || _statetrunc; ELSE SELECT CAST(COALESCE(MAX(CAST(shipto_num AS INTEGER)), 0) + 1 AS TEXT) INTO _candidate FROM shiptoinfo WHERE ((shipto_cust_id=_custid) AND (shipto_num~'^[0-9]*$')); END IF; IF (_create) THEN INSERT INTO api.custshipto ( customer_number, shipto_number, name, address1, address2, address3, city, state, postal_code, country, address_change, first, last, email, edi_profile ) VALUES ( _custnumber, _candidate, _candidate, _addr1, _addr2, _addr3, _city, _state, _postalcode, _country, 'CHANGEONE', _first, _last, LOWER(_email), 'No EDI' ); END IF; RETURN _candidate; END IF; RETURN ''; END; $_$; DROP FUNCTION public.getshiptonumberfrominfo(text, text, text, text, text, text, text, text, text, text, text, text, text, boolean, boolean); publicadminfalse46238125578656getshipviaid(text)FUNCTION,CREATE FUNCTION getshipviaid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipViaCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pShipViaCode IS NULL) THEN RETURN NULL; END IF; SELECT shipvia_id INTO _returnVal FROM shipvia WHERE (shipvia_code=pShipViaCode); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'ShipVia Code % not found.', pShipViaCode; END IF; RETURN _returnVal; END; $_$; )DROP FUNCTION public.getshipviaid(text); publicadminfalse46238125578657getshipzoneid(text)FUNCTION%CREATE FUNCTION getshipzoneid(pshipzonename text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN IF (pShipZoneName IS NULL) THEN RETURN NULL; END IF; SELECT shipzone_id INTO _returnVal FROM shipzone WHERE (shipzone_name=pShipZoneName); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Ship Zone % not found.', pShipZoneName; END IF; RETURN _returnVal; END; $$; 8DROP FUNCTION public.getshipzoneid(pshipzonename text); publicadminfalse46238125578658getsitetypeid(text)FUNCTION!CREATE FUNCTION getsitetypeid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSiteType ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pSiteType IS NULL) THEN RETURN NULL; END IF; SELECT sitetype_id INTO _returnVal FROM sitetype WHERE (sitetype_name=pSiteType); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Site Type % not found.', pSiteType; END IF; RETURN _returnVal; END; $_$; *DROP FUNCTION public.getsitetypeid(text); publicadminfalse84623125578659getsoitemstatus(integer)FUNCTION CREATE FUNCTION getsoitemstatus(pcoitemid integer) RETURNS text LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _result TEXT; BEGIN SELECT (CASE WHEN (coitem_status='O' AND (SELECT cust_creditstatus FROM custinfo WHERE cust_id=cohead_cust_id)='H') THEN 'H' WHEN (coitem_status='O' AND ((SELECT SUM(invcitem_billed) FROM invchead, invcitem WHERE ((CAST(invchead_ordernumber AS text)=cohead_number) AND (invcitem_invchead_id=invchead_id) AND (invcitem_item_id=itemsite_item_id) AND (invcitem_warehous_id=itemsite_warehous_id) AND (invcitem_linenumber=coitem_linenumber))) >= coitem_qtyord)) THEN 'I' WHEN (coitem_status='O' AND ((SELECT SUM(invcitem_billed) FROM invchead, invcitem WHERE ((CAST(invchead_ordernumber AS text)=cohead_number) AND (invcitem_invchead_id=invchead_id) AND (invcitem_item_id=itemsite_item_id) AND (invcitem_warehous_id=itemsite_warehous_id) AND (invcitem_linenumber=coitem_linenumber))) > 0)) THEN 'P' WHEN (coitem_status='O' AND (qtyAvailable(itemsite_id) - qtyAllocated(itemsite_id, CURRENT_DATE) + qtyOrdered(itemsite_id, CURRENT_DATE)) >= ((coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio)) THEN 'R' ELSE coitem_status END || CASE WHEN (coitem_firm) THEN 'F' ELSE '' END ) INTO _result FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id) JOIN custinfo ON (cust_id=cohead_cust_id) JOIN itemsite ON (itemsite_id=coitem_itemsite_id) WHERE (coitem_id=pCoitemid); RETURN _result; END; $$; 9DROP FUNCTION public.getsoitemstatus(pcoitemid integer); publicadminfalse46238125578660getsoscheddate(integer)FUNCTIONHCREATE FUNCTION getsoscheddate(integer) RETURNS date LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCoheadid ALIAS FOR $1; _minscheddate DATE; BEGIN SELECT MIN(coitem_scheddate) INTO _minscheddate FROM cohead JOIN coitem ON (coitem_cohead_id=pCoheadid) WHERE true AND cohead_id=pCoheadid AND CASE WHEN (cohead_status='C') THEN coitem_status != 'X' ELSE coitem_status NOT IN ('C','X') END; RETURN _minscheddate; END; $_$; .DROP FUNCTION public.getsoscheddate(integer); publicadminfalse46238125578661getsostatus(integer)FUNCTIONCREATE FUNCTION getsostatus(integer) RETURNS character LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCoheadid ALIAS FOR $1; _result char(1); BEGIN SELECT cohead_status INTO _result FROM cohead WHERE (cohead_id=pCoheadid); RETURN _result; END; $_$; +DROP FUNCTION public.getsostatus(integer); publicadminfalse46238125587033getsubtax(integer, integer)FUNCTIONeCREATE FUNCTION getsubtax(integer, integer) RETURNS SETOF subtax LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxCodeId ALIAS FOR $1; pLevel ALIAS FOR $2; _row subtax%ROWTYPE; _x RECORD; _y RECORD; BEGIN FOR _x IN --Select all tax codes whose calculation basis is pTaxCodeId SELECT tax_id, tax_code, tax_descrip FROM tax WHERE tax_basis_tax_id = pTaxCodeId LOOP _row.subtax_taxcode_id := _x.tax_id; _row.subtax_taxcode_code := _x.tax_code; _row.subtax_taxcode_descrip := _x.tax_descrip; _row.subtax_taxcode_level := pLevel + 1; RETURN NEXT _row; FOR _y IN SELECT * from getSubTax(_x.tax_id, pLevel + 1) --This is the recursive part. LOOP _row.subtax_taxcode_id := _y.subtax_taxcode_id; _row.subtax_taxcode_code := _y.subtax_taxcode_code ; _row.subtax_taxcode_descrip := _y.subtax_taxcode_descrip; _row.subtax_taxcode_level := pLevel + 2; RETURN NEXT _row; END LOOP; END LOOP; END; $_$; 2DROP FUNCTION public.getsubtax(integer, integer); publicadminfalse426446238125578663gettaxauthid(text)FUNCTION-CREATE FUNCTION gettaxauthid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxAuthCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pTaxAuthCode IS NULL) THEN RETURN NULL; END IF; SELECT taxauth_id INTO _returnVal FROM taxauth WHERE (taxauth_code=pTaxAuthCode); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Tax Authority % not found.', pTaxAuthCode; END IF; RETURN _returnVal; END; $_$; )DROP FUNCTION public.gettaxauthid(text); publicadminfalse46238125578664gettaxid(text)FUNCTIONCREATE FUNCTION gettaxid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pTaxCode IS NULL) THEN RETURN NULL; END IF; SELECT tax_id INTO _returnVal FROM tax WHERE (tax_code=pTaxCode); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Tax Code % not found.', pTaxCode; END IF; RETURN _returnVal; END; $_$; %DROP FUNCTION public.gettaxid(text); publicadminfalse46238125578665gettaxtypeid(text)FUNCTIONCREATE FUNCTION gettaxtypeid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxType ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pTaxType IS NULL) THEN RETURN NULL; END IF; SELECT taxtype_id INTO _returnVal FROM taxtype WHERE (taxtype_name=pTaxType); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Tax Type % not found.', pTaxType; END IF; RETURN _returnVal; END; $_$; )DROP FUNCTION public.gettaxtypeid(text); publicadminfalse84623125578666gettaxzoneid(text)FUNCTIONCREATE FUNCTION gettaxzoneid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxZone ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pTaxZone IS NULL) THEN RETURN NULL; END IF; SELECT taxzone_id INTO _returnVal FROM taxzone WHERE (taxzone_code=pTaxZone); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Tax Zone % not found.', pTaxZone; END IF; RETURN _returnVal; END; $_$; )DROP FUNCTION public.gettaxzoneid(text); publicadminfalse84623125578667gettermsid(text)FUNCTIONCREATE FUNCTION gettermsid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTermsCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pTermsCode IS NULL) THEN RETURN NULL; END IF; SELECT terms_id INTO _returnVal FROM terms WHERE (terms_code=pTermsCode); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Terms Code % not found.', pTermsCode; END IF; RETURN _returnVal; END; $_$; 'DROP FUNCTION public.gettermsid(text); publicadminfalse84623125587034getunassignedaccntid(integer)FUNCTIONCREATE FUNCTION getunassignedaccntid(pcompanyid integer DEFAULT (-1)) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _test INTEGER; _returnVal INTEGER; BEGIN -- In a Multi-Company scenario we have to check the unassigned accnt for the -- correct Company. Otherwise choose the system metric IF (fetchMetricValue('GLCompanySize') > 0) THEN -- Multi-Company IF (pCompanyid = -1) THEN RAISE EXCEPTION 'Unassigned G/L Account could not be determined for an unknown Company [xtuple: getunassignedaccntid, -1]'; ELSE SELECT company_unassigned_accnt_id INTO _test FROM company WHERE company_id = pCompanyid; END IF; ELSE -- Single Company _test := fetchMetricValue('UnassignedAccount'); END IF; IF (_test IS NULL) THEN RAISE EXCEPTION 'Metric not found for UnassignedAccount [xtuple: getunassignedaccntid, -2]'; END IF; SELECT accnt_id INTO _returnVal FROM accnt WHERE (accnt_id=_test); IF (NOT FOUND) THEN RAISE EXCEPTION 'Metric UnassignedAccount is an invalid G/L Account [xtuple: getunassignedaccntid, -3, %1]', _test; END IF; RETURN _returnVal; END; $$; ?DROP FUNCTION public.getunassignedaccntid(pcompanyid integer); publicadminfalse84623125578669getuomid(text)FUNCTIONCREATE FUNCTION getuomid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUom ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pUom IS NULL) THEN RETURN NULL; END IF; SELECT uom_id INTO _returnVal FROM uom WHERE (uom_name=pUom); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Unit of Measure % not found.', pUom; END IF; RETURN _returnVal; END; $_$; %DROP FUNCTION public.getuomid(text); publicadminfalse46238125578670getuomtypeid(text)FUNCTION2CREATE FUNCTION getuomtypeid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUomType ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pUomType IS NULL) THEN RETURN NULL; END IF; SELECT uomtype_id INTO _returnVal FROM uomtype WHERE (UPPER(uomtype_name)=UPPER(pUomType)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Unit of Measuer Type % not found.', pUomType; END IF; RETURN _returnVal; END; $_$; )DROP FUNCTION public.getuomtypeid(text); publicadminfalse46238125578671getuomtypeid(text[])FUNCTIONCREATE FUNCTION getuomtypeid(text[]) RETURNS integer[] LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUomTypes ALIAS FOR $1; _returnVal INTEGER[]; _val INTEGER; _i INTEGER; BEGIN IF (pUomTypes IS NULL) OR (ARRAY_UPPER(pUomTypes,1) = 0) THEN RETURN NULL; END IF; FOR _i IN 1..ARRAY_UPPER(pUomTypes,1) LOOP SELECT uomtype_id INTO _val FROM uomtype WHERE (UPPER(uomtype_name)=UPPER(pUomTypes[_i])); IF (_val IS NULL) THEN RAISE EXCEPTION 'Unit of Measure Type % not found.', pUomTypes[_i]; ELSE _returnVal[_i] := _val; END IF; END LOOP; RETURN _returnVal; END; $_$; +DROP FUNCTION public.getuomtypeid(text[]); publicadminfalse84623125578672getusrid(text)FUNCTIONCREATE FUNCTION getusrid(pusr text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN SELECT usr_id INTO _returnVal FROM usr WHERE (usr_username=COALESCE(pUsr, getEffectiveXtUser())); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'User % not found.', pUsr; END IF; RETURN _returnVal; END; $$; *DROP FUNCTION public.getusrid(pusr text); publicadminfalse84623125578673getusrlocaleid()FUNCTION&CREATE FUNCTION getusrlocaleid() RETURNS integer LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN SELECT CAST(usrpref_value AS INTEGER) FROM usrpref WHERE (usrpref_username=getEffectiveXTUser()) AND (usrpref_name='locale_id') INTO _returnVal; IF (_returnVal IS NULL) THEN SELECT locale_id FROM locale WHERE (LOWER(locale_code) = 'default') LIMIT 1 INTO _returnVal; END IF; IF (_returnVal IS NULL) THEN SELECT locale_id FROM locale ORDER BY locale_id LIMIT 1 INTO _returnVal; END IF; IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'User Locale not found.'; END IF; RETURN _returnVal; END; $$; 'DROP FUNCTION public.getusrlocaleid(); publicadminfalse84623125578674getvendaddrid(text, text)FUNCTIONCREATE FUNCTION getvendaddrid(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendNumber ALIAS FOR $1; pVendAddrCode ALIAS FOR $2; _returnVal INTEGER; BEGIN IF ( (pVendNumber IS NULL) OR (pVendAddrCode IS NULL) ) THEN RETURN NULL; END IF; SELECT vendaddr_id INTO _returnVal FROM vendaddrinfo JOIN vendinfo ON (vend_id=vendaddr_vend_id) WHERE ( (vendaddr_code=pVendAddrCode) AND (vend_number=pVendNumber) ); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Vendor Number % Address % not found.', pVendNumber, pVendAddrCode; END IF; RETURN _returnVal; END; $_$; 0DROP FUNCTION public.getvendaddrid(text, text); publicadminfalse84623125578675getvendid(text)FUNCTION,CREATE FUNCTION getvendid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendNumber ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pVendNumber IS NULL) THEN RETURN NULL; END IF; SELECT vend_id INTO _returnVal FROM vendinfo WHERE (vend_number=pVendNumber); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Vendor Number % not found.', pVendNumber; END IF; RETURN _returnVal; END; $_$; &DROP FUNCTION public.getvendid(text); publicadminfalse46238125578676getvendtypeid(text)FUNCTIONDCREATE FUNCTION getvendtypeid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVendTypeCode ALIAS FOR $1; _returnVal INTEGER; BEGIN IF (pVendTypeCode IS NULL) THEN RETURN NULL; END IF; SELECT vendtype_id INTO _returnVal FROM vendtype WHERE (UPPER(vendtype_code)=UPPER(pVendTypeCode)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Vendor Type % not found.', pVendTypeCode; END IF; RETURN _returnVal; END; $_$; *DROP FUNCTION public.getvendtypeid(text); publicadminfalse84623125578677getwarehousid(text, text)FUNCTIONCREATE FUNCTION getwarehousid(pwarehouscode text, ptype text) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _active BOOL; _shipping BOOL; _returnVal INTEGER; BEGIN IF (pWarehousCode IS NULL) THEN RETURN NULL; END IF; IF (UPPER(pType) NOT IN ('ALL','ACTIVE','SHIPPING')) THEN RAISE EXCEPTION 'Warehouse lookip type % not valid. Valid types are ALL, ACTIVE and SHIPPING', pType; END IF; SELECT warehous_id, warehous_active, warehous_shipping INTO _returnVal, _active, _shipping FROM site() WHERE (warehous_code=UPPER(pWarehousCode)); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Warehouse Code % not found.', pWarehousCode; ELSE IF ((pType='SHIPPING') AND (_shipping=false)) THEN RAISE EXCEPTION 'Warehouse Code % is not a vaild shipping warehouse.', pWarehousCode; ELSE IF ((pType IN ('SHIPPING','ACTIVE')) AND (_active=false)) THEN RAISE EXCEPTION 'Warehouse Code % is inactive.', pWarehousCode; END IF; END IF; END IF; RETURN _returnVal; END; $$; DDROP FUNCTION public.getwarehousid(pwarehouscode text, ptype text); publicadminfalse46238125578678getwhsezoneid(text, text)FUNCTIONCREATE FUNCTION getwhsezoneid(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWhseCode ALIAS FOR $1; pWhseZoneName ALIAS FOR $2; _returnVal INTEGER; BEGIN IF ((pWhseCode IS NULL) OR (pWhseZoneName IS NULL)) THEN RETURN NULL; END IF; SELECT whsezone_id INTO _returnVal FROM whsezone WHERE ( (whsezone_warehous_id=getWarehousId(pWhseCode, 'ACTIVE')) AND (UPPER(whsezone_name)=UPPER(pWhseZoneName)) ); IF (_returnVal IS NULL) THEN RAISE EXCEPTION 'Whsezone % not found.', pWhseZoneName; END IF; RETURN _returnVal; END; $_$; 0DROP FUNCTION public.getwhsezoneid(text, text); publicadminfalse46238125578679+grantallmodulecmnttypesource(integer, text)FUNCTIONCREATE FUNCTION grantallmodulecmnttypesource(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmnttypeid ALIAS FOR $1; pModuleName ALIAS FOR $2; _source RECORD; _sourceCounter INTEGER; BEGIN _sourceCounter := 0; FOR _source IN SELECT source_id FROM source WHERE (source_module=pModuleName) LOOP IF (SELECT grantCmnttypeSource(pCmnttypeid, _source.source_id)) THEN _sourceCounter := _sourceCounter + 1; END IF; END LOOP; RETURN _sourceCounter; END; $_$; BDROP FUNCTION public.grantallmodulecmnttypesource(integer, text); publicadminfalse84623125578680grantallmodulepriv(text, text)FUNCTIONmCREATE FUNCTION grantallmodulepriv(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pModuleName ALIAS FOR $2; _priv RECORD; _privCounter INTEGER; BEGIN _privCounter := 0; FOR _priv IN SELECT priv_id FROM priv WHERE (priv_module=pModuleName) LOOP IF (SELECT grantPriv(pUsername, _priv.priv_id)) THEN _privCounter := _privCounter + 1; END IF; END LOOP; RETURN _privCounter; END; $_$; 5DROP FUNCTION public.grantallmodulepriv(text, text); publicadminfalse84623125578681&grantallmoduleprivgroup(integer, text)FUNCTIONtCREATE FUNCTION grantallmoduleprivgroup(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pGrpid ALIAS FOR $1; pModuleName ALIAS FOR $2; _priv RECORD; _privCounter INTEGER; BEGIN _privCounter := 0; FOR _priv IN SELECT priv_id FROM priv WHERE (priv_module=pModuleName) LOOP IF (SELECT grantPrivGroup(pGrpid, _priv.priv_id)) THEN _privCounter := _privCounter + 1; END IF; END LOOP; RETURN _privCounter; END; $_$; =DROP FUNCTION public.grantallmoduleprivgroup(integer, text); publicadminfalse46238125578682%grantcmnttypesource(integer, integer)FUNCTIONCREATE FUNCTION grantcmnttypesource(integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmnttypeid ALIAS FOR $1; pSourceid ALIAS FOR $2; _test INTEGER; BEGIN SELECT cmnttypesource_id INTO _test FROM cmnttypesource WHERE ( (cmnttypesource_cmnttype_id=pCmnttypeid) AND (cmnttypesource_source_id=pSourceid) ); IF (FOUND) THEN RETURN FALSE; END IF; INSERT INTO cmnttypesource ( cmnttypesource_cmnttype_id, cmnttypesource_source_id ) VALUES ( pCmnttypeid, pSourceid ); RETURN TRUE; END; $_$; <DROP FUNCTION public.grantcmnttypesource(integer, integer); publicadminfalse84623125578683grantgroup(text, integer)FUNCTIONFCREATE FUNCTION grantgroup(text, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pGrpid ALIAS FOR $2; _test INTEGER; BEGIN SELECT usrgrp_id INTO _test FROM usrgrp WHERE ( (usrgrp_username=pUsername) AND (usrgrp_grp_id=pGrpid) ); IF (FOUND) THEN RETURN FALSE; END IF; INSERT INTO usrgrp ( usrgrp_username, usrgrp_grp_id ) VALUES ( pUsername, pGrpid ); RETURN TRUE; END; $_$; 0DROP FUNCTION public.grantgroup(text, integer); publicadminfalse84623125578684grantpriv(text, integer)FUNCTIONmCREATE FUNCTION grantpriv(text, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pPrivid ALIAS FOR $2; _test INTEGER; BEGIN SELECT usrpriv_id INTO _test FROM usrpriv WHERE ( (usrpriv_username=pUsername) AND (usrpriv_priv_id=pPrivid) ); IF (FOUND) THEN RETURN FALSE; END IF; INSERT INTO usrpriv ( usrpriv_username, usrpriv_priv_id ) VALUES ( pUsername, pPrivid ); NOTIFY "usrprivUpdated"; RETURN TRUE; END; $_$; /DROP FUNCTION public.grantpriv(text, integer); publicadminfalse46238125578685grantpriv(text, text)FUNCTIONCREATE FUNCTION grantpriv(text, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pPrivname ALIAS FOR $2; _test INTEGER; BEGIN SELECT usrpriv_id INTO _test FROM usrpriv JOIN priv ON (usrpriv_priv_id=priv_id) WHERE ((usrpriv_username=pUsername) AND (priv_name=pPrivname) ); IF (FOUND) THEN RETURN FALSE; END IF; INSERT INTO usrpriv ( usrpriv_username, usrpriv_priv_id ) SELECT pUsername, priv_id FROM priv WHERE (priv_name=pPrivname); NOTIFY "usrprivUpdated"; RETURN TRUE; END; $_$; ,DROP FUNCTION public.grantpriv(text, text); publicadminfalse84623125578686 grantprivgroup(integer, integer)FUNCTIONLCREATE FUNCTION grantprivgroup(integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pGrpid ALIAS FOR $1; pPrivid ALIAS FOR $2; _test INTEGER; BEGIN SELECT grppriv_id INTO _test FROM grppriv WHERE ( (grppriv_grp_id=pGrpid) AND (grppriv_priv_id=pPrivid) ); IF (FOUND) THEN RETURN FALSE; END IF; INSERT INTO grppriv ( grppriv_grp_id, grppriv_priv_id ) VALUES ( pGrpid, pPrivid ); RETURN TRUE; END; $_$; 7DROP FUNCTION public.grantprivgroup(integer, integer); publicadminfalse84623125578687 hasalarms()FUNCTION3CREATE FUNCTION hasalarms() RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _alarm RECORD; _alarmtype TEXT := ''; _batchId INTEGER; _evntlogordtype TEXT; _evnttypeid INTEGER; _evnttypename TEXT; _fromEmail TEXT; _itemid INTEGER; _longsource TEXT; _msgId INTEGER; _recipient TEXT; _recipientPart INTEGER; _returnVal BOOLEAN := FALSE; _summary TEXT; _whsId INTEGER := -1; BEGIN FOR _alarm IN SELECT * FROM alarm WHERE ((alarm_creator=getEffectiveXtUser()) AND (CURRENT_TIMESTAMP > alarm_trigger)) LOOP _returnVal := TRUE; IF (_alarm.alarm_source = 'TODO') THEN SELECT (todoitem_name || '-' || todoitem_description), 'T', 'TodoAlarm', 'To-Do Item' INTO _summary, _evntlogordtype, _evnttypename, _longsource FROM todoitem WHERE (todoitem_id = _alarm.alarm_source_id); _alarmtype = 'To-Do: '; ELSIF (_alarm.alarm_source = 'INCDT') THEN SELECT (incdt_number || '-' || incdt_summary), 'I', 'IncidentAlarm', 'Incident' INTO _summary, _evntlogordtype, _evnttypename, _longsource FROM incdt WHERE (incdt_id = _alarm.alarm_source_id); _alarmtype = 'Incident: '; ELSIF (_alarm.alarm_source = 'J') THEN SELECT (prj_number || ' ' || prj_name || '-' || prjtask_name), 'J', 'TaskAlarm', 'Project Task' INTO _summary, _evntlogordtype, _evnttypename, _longsource FROM prjtask JOIN prj ON (prj_id=prjtask_prj_id) WHERE (prjtask_id = _alarm.alarm_source_id); _alarmtype = 'Project: '; ELSE CONTINUE; -- there's nothing to do for this iteration of the loop END IF; -- if event alarm IF (_alarm.alarm_event) THEN SELECT evnttype_id INTO _evnttypeid FROM evnttype WHERE (evnttype_name=_evnttypename); _recipientPart := 1; LOOP _recipient := SPLIT_PART(_alarm.alarm_event_recipient, ',', _recipientPart); EXIT WHEN (LENGTH(_recipient) = 0); SELECT usrpref_value INTO _whsId FROM usrpref WHERE ( (usrpref_username = _recipient) AND (usrpref_name = 'PreferredWarehouse') ); INSERT INTO evntlog (evntlog_evnttime, evntlog_username, evntlog_evnttype_id, evntlog_ordtype, evntlog_ord_id, evntlog_warehous_id, evntlog_number ) VALUES (CURRENT_TIMESTAMP, _recipient, _evnttypeid, _evntlogordtype, _alarm.alarm_source_id, _whsId, _summary); _recipientPart := _recipientPart + 1; END LOOP; END IF; IF (_alarm.alarm_email) THEN SELECT usr_email INTO _fromEmail FROM usr WHERE (usr_username = _alarm.alarm_creator); _recipientPart := 1; LOOP _recipient := SPLIT_PART(_alarm.alarm_email_recipient, ',', _recipientPart); EXIT WHEN (LENGTH(_recipient) <= 0); _batchId := xtbatch.submitEmailToBatch(_fromEmail, _recipient, '', _alarmtype || _summary, 'Alarm reminder for ' || _longsource || '.', NULL, CURRENT_TIMESTAMP, FALSE, NULL, NULL); _recipientPart := _recipientPart + 1; END LOOP; END IF; IF (_alarm.alarm_sysmsg) THEN _recipientPart := 1; LOOP _recipient := SPLIT_PART(_alarm.alarm_sysmsg_recipient, ',', _recipientPart); EXIT WHEN (LENGTH(_recipient) <= 0); _msgId := postMessage(_recipient, (_longsource || ' - ' || _summary)); _recipientPart := _recipientPart + 1; END LOOP; END IF; DELETE FROM alarm WHERE alarm_id=_alarm.alarm_id; END LOOP; RETURN _returnVal; END; $$; "DROP FUNCTION public.hasalarms(); publicadminfalse84623125578688 hasevents()FUNCTIONsCREATE FUNCTION hasevents() RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN PERFORM evntlog_id FROM evntlog WHERE ( (evntlog_dispatched IS NULL) AND (evntlog_username=getEffectiveXtUser()) ) LIMIT 1; RETURN FOUND; END; $$; "DROP FUNCTION public.hasevents(); publicadminfalse46238125578689 hasmessages()FUNCTIONCREATE FUNCTION hasmessages() RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN PERFORM msguser_id FROM msg, msguser WHERE ( (msguser_username=getEffectiveXtUser()) AND (msguser_msg_id=msg_id) AND (CURRENT_TIMESTAMP BETWEEN msg_scheduled AND msg_expires) AND (msguser_viewed IS NULL) ) LIMIT 1; RETURN FOUND; END; $$; $DROP FUNCTION public.hasmessages(); publicadminfalse84623125578690 haspriv(text)FUNCTIONCREATE FUNCTION haspriv(text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrivName ALIAS FOR $1; _result INTEGER; _returnVal BOOLEAN; BEGIN RAISE WARNING 'hasPriv(TEXT) is deprecated. Use checkPrivilege(TEXT) instead.'; SELECT priv_id INTO _result FROM priv, grppriv, usrgrp WHERE((usrgrp_grp_id=grppriv_grp_id) AND (grppriv_priv_id=priv_id) AND (priv_name=pPrivName) AND (usrgrp_username=getEffectiveXtUser())); IF (FOUND) THEN RETURN true; END IF; SELECT COALESCE(usrpriv_id, 0) != 0 INTO _returnVal FROM priv LEFT OUTER JOIN usrpriv ON (priv_id=usrpriv_priv_id AND usrpriv_username = getEffectiveXtUser()) WHERE (priv_name=pPrivName); IF (_returnVal IS NULL) THEN _returnVal := FALSE; END IF; RETURN _returnVal; END; $_$; $DROP FUNCTION public.haspriv(text); publicadminfalse84623125578691*hasprivonobject(text, text, integer, text)FUNCTION'CREATE FUNCTION hasprivonobject(pprivtype text, pobjecttype text, pobjectid integer DEFAULT NULL::integer, puser text DEFAULT NULL::text) RETURNS boolean LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _haspriv BOOLEAN := FALSE; _privfound BOOLEAN := FALSE; _pkey TEXT[]; _privdesc RECORD; _qstr TEXT; BEGIN IF UPPER(pPrivType) NOT IN ('CREATE', 'EDIT', 'VIEW', 'DELETE') THEN RAISE EXCEPTION 'Cannot check if user has % on % [xtuple: hasPrivOnObject, -1, %, %]', pPrivType, pObjectType, pPrivType, pObjectType; END IF; /* TODO: create privdesc table? can't do it yet because this is a fix for a minor release NOTE: only include tables that have a single integer column as pkey NOTE: some of these are part of proprietary extensions. how do we make them part of the extension? */ FOR _privdesc IN WITH privdesc AS ( SELECT 'ADDR' AS otype, 'public' AS masterschema, 'addr' AS mastertable, 'MaintainAddressMasters' AS editall, 'ViewAddressMasters' AS viewall, NULL AS ownerfield, NULL AS editmine, NULL AS viewmine UNION ALL SELECT 'BBH', 'xtmfg', 'bbom', 'MaintainBBOMs', 'ViewBBOMs', NULL, NULL, NULL UNION ALL SELECT 'BBI', 'xtmfg', 'bbom', 'MaintainBBOMs', 'ViewBBOMs', NULL, NULL, NULL UNION ALL SELECT 'BMH', 'public', 'bom', 'MaintainBOMs', 'ViewBOMs', NULL, NULL, NULL UNION ALL SELECT 'BMI', 'public', 'bom', 'MaintainBOMs', 'ViewBOMs', NULL, NULL, NULL UNION ALL SELECT 'BOH', 'xtmfg', 'boo', 'MaintainBOOs', 'ViewBOOs', NULL, NULL, NULL UNION ALL SELECT 'BOI', 'xtmfg', 'boo', 'MaintainBOOs', 'ViewBOOs', NULL, NULL, NULL UNION ALL SELECT 'C', 'public', 'custinfo', 'MaintainCustomerMasters', 'ViewCustomerMasters', NULL, NULL, NULL UNION ALL SELECT 'CRMA', 'public', 'crmacct', 'MaintainAllCRMAccounts', 'ViewAllCRMAccounts', 'crmacct_owner_username', 'MaintainPersonalCRMAccounts', 'ViewPersonalCRMAccounts' UNION ALL SELECT 'EMP', 'public', 'emp', 'MaintainEmployees', 'ViewEmployees', NULL, NULL, NULL UNION ALL SELECT 'I', 'public', 'item', 'MaintainItemMasters', 'ViewItemMasters', NULL, NULL, NULL UNION ALL SELECT 'INCDT', 'public', 'incdt', 'MaintainAllIncidents', 'ViewAllIncidents', 'incdt_owner_username', 'MaintainPersonalIncidents', 'ViewPersonalIncidents' UNION ALL SELECT 'IR', 'public', 'itemsrc', 'MaintainItemSources', 'ViewItemSources', NULL, NULL, NULL UNION ALL SELECT 'IS', 'public', 'itemsite', 'MaintainItemSites', 'ViewItemSites', NULL, NULL, NULL UNION ALL SELECT 'J', 'public', 'prj', 'MaintainAllProjects', 'ViewAllProjects', 'prj_owner_username', 'MaintainPersonalProjects', 'ViewPersonalProjects' UNION ALL SELECT 'J', 'public', 'prj', 'MaintainAllProjects', 'ViewAllProjects', 'prj_username', 'MaintainPersonalProjects', 'ViewPersonalProjects' UNION ALL SELECT 'L', 'public', 'location', 'MaintainLocations', 'ViewLocations', NULL, NULL, NULL UNION ALL SELECT 'OPP', 'public', 'ophead', 'MaintainAllOpportunities', 'ViewAllOpportunities', 'ophead_owner_username', 'MaintainPersonalOpportunities', 'ViewPersonalOpportunities' UNION ALL SELECT 'P', 'public', 'pohead', 'MaintainPurchaseOrders', 'ViewPurchaseOrders', NULL, NULL, NULL UNION ALL SELECT 'PI', 'public', 'pohead', 'MaintainPurchaseOrders', 'ViewPurchaseOrders', NULL, NULL, NULL UNION ALL SELECT 'Q', 'public', 'quhead', 'MaintainQuotes', 'ViewQuotes', NULL, NULL, NULL UNION ALL SELECT 'QI', 'public', 'quhead', 'MaintainQuotes', 'ViewQuotes', NULL, NULL, NULL UNION ALL SELECT 'RA', 'public', 'rahead', 'MaintainReturns', 'ViewReturns', NULL, NULL, NULL UNION ALL SELECT 'RI', 'public', 'rahead', 'MaintainReturns', 'ViewReturns', NULL, NULL, NULL UNION ALL SELECT 'S', 'public', 'cohead', 'MaintainSalesOrders', 'ViewSalesOrders', NULL, NULL, NULL UNION ALL SELECT 'SI', 'public', 'cohead', 'MaintainSalesOrders', 'ViewSalesOrders', NULL, NULL, NULL UNION ALL SELECT 'T', 'public', 'cntct', 'MaintainAllContacts', 'ViewAllContacts', 'cntct_owner_username', 'MaintainPersonalContacts', 'ViewPersonalContacts' UNION ALL SELECT 'TE', 'te', 'tehead', 'MaintainTimeExpense', 'ViewTimeExpenseHistory', 'tehead_username', 'MaintainTimeExpenseSelf', NULL UNION ALL SELECT 'TE', 'te', 'tehead', 'MaintainTimeExpenseOthers', 'ViewTimeExpenseHistory', 'tehead_username', 'MaintainTimeExpenseSelf', NULL UNION ALL SELECT 'TI', 'public', 'tohead', 'MaintainTransferOrders', 'ViewTransferOrders', NULL, NULL, NULL UNION ALL SELECT 'TO', 'public', 'tohead', 'MaintainTransferOrders', 'ViewTransferOrders', NULL, NULL, NULL UNION ALL SELECT 'TODO', 'public', 'todoitem', 'MaintainAllToDoItems', 'ViewAllToDoItems', 'todoitem_owner_username', 'MaintainPersonalToDoItems', 'ViewPersonalToDoItems' UNION ALL SELECT 'V', 'public', 'vendinfo', 'MaintainVendors', 'ViewVendors', NULL, NULL, NULL UNION ALL SELECT 'W', 'public', 'wo', 'MaintainWorkOrders', 'ViewWorkOrders', NULL, NULL, NULL UNION ALL SELECT 'WH', 'public', 'whsinfo', 'MaintainWarehouses', 'ViewWarehouses', NULL, NULL, NULL) -- UNION ALL SELECT 'LS', 'public', 'ls', NULL, NULL, NULL, NULL, NULL -- UNION ALL SELECT 'P', 'public', 'pohead', 'MaintainPostedPurchaseOrders', 'ViewPurchaseOrders', NULL, NULL, NULL -- additional criteria? -- UNION ALL SELECT 'PI', 'public', 'pohead', 'MaintainPostedPurchaseOrders', 'ViewPurchaseOrders', NULL, NULL, NULL -- additional criteria? SELECT * FROM privdesc WHERE otype = pObjectType LOOP _privfound := TRUE; RAISE DEBUG '% % % % % % %', _privdesc.otype, _privdesc.masterschema, _privdesc.mastertable, _privdesc.editall, _privdesc.viewall, _privdesc.editmine, _privdesc.viewmine; IF checkPrivilege(CASE UPPER(pPrivType) WHEN 'CREATE' THEN _privdesc.editall WHEN 'EDIT' THEN _privdesc.editall WHEN 'DELETE' THEN _privdesc.editall WHEN 'VIEW' THEN _privdesc.viewall END) THEN _haspriv = TRUE; ELSIF checkPrivilege(CASE UPPER(pPrivType) WHEN 'CREATE' THEN _privdesc.editmine WHEN 'EDIT' THEN _privdesc.editmine WHEN 'DELETE' THEN _privdesc.editmine WHEN 'VIEW' THEN _privdesc.viewmine END) THEN IF pObjectId IS NULL THEN _haspriv = TRUE; ELSE _pkey := primaryKeyFields(_privdesc.masterschema, _privdesc.mastertable); -- SELECT ... FROM schema.table WHERE pkeyfield = pObjectId AND ownerfield = pUser _qstr := 'SELECT EXISTS(SELECT 1 FROM ' || quote_ident(_privdesc.masterschema) || '.' || quote_ident(_privdesc.mastertable) || ' WHERE ' || quote_ident(_pkey[1]) || ' = ' || pObjectId || ' AND ' || quote_ident(_privdesc.ownerfield) || '= ' || quote_literal(COALESCE(pUser, getEffectiveXtUser())) || ');'; RAISE DEBUG '%', _qstr; EXECUTE _qstr INTO _haspriv; END IF; END IF; EXIT WHEN _haspriv; END LOOP; RETURN _haspriv OR NOT _privfound; END; $$; gDROP FUNCTION public.hasprivonobject(pprivtype text, pobjecttype text, pobjectid integer, puser text); publicadminfalse84623%00YFUNCTION hasprivonobject(pprivtype text, pobjecttype text, pobjectid integer, puser text)COMMENToCOMMENT ON FUNCTION hasprivonobject(pprivtype text, pobjecttype text, pobjectid integer, puser text) IS 'Return if a user has permission to view or edit a specific database object. pPrivType is either CREATE, EDIT, DELETE, or VIEW, and controls which privilege is checked. pObjectType is one of the string constants used by the Documents widget, such as ADDR for Addresses. pObjectId is the internal id of the record in the table associated with pObjectType (defaults to NULL). pUser is the username to be checked for those pObjectTypes that restrict access to individual users (NULL == current user and is the default).'; publicadminfalse1703125578693hmac(text, text, text)FUNCTION{CREATE FUNCTION hmac(text, text, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_hmac'; -DROP FUNCTION public.hmac(text, text, text); publicadminfalse8125578694hmac(bytea, bytea, text)FUNCTION}CREATE FUNCTION hmac(bytea, bytea, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pg_hmac'; /DROP FUNCTION public.hmac(bytea, bytea, text); publicadminfalse8125578695implodewo(integer, boolean)FUNCTIONCREATE FUNCTION implodewo(pwoid integer, pimplodechildren boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE resultCode INTEGER; _routings BOOLEAN; _wo RECORD; BEGIN _routings := fetchMetricBool('Routings'); SELECT * INTO _wo FROM wo WHERE (wo_id=pWoid); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot find W/O id % [xtuple: implodeWo, -9]', pWoid; END IF; IF (_routings) THEN IF (EXISTS(SELECT wotc_wo_id FROM xtmfg.wotc WHERE (wotc_wo_id=pWoid))) THEN RAISE EXCEPTION 'Cannot implode W/O % with labor posting [xtuple: implodeWo, -1]', formatWoNumber(pWoid); END IF; END IF; IF (_wo.wo_status != 'E') THEN RAISE EXCEPTION 'Cannot implode W/O % with status % [xtuple: implodeWo, -2]', formatWoNumber(pWoid), _wo.wo_status; END IF; -- Delete any created P/R's for this W/O PERFORM deletePr('W', womatl_id) FROM womatl WHERE (womatl_wo_id=pWoid); DELETE FROM womatl WHERE (womatl_wo_id=pWoid); IF _routings THEN DELETE FROM xtmfg.wooper WHERE (wooper_wo_id=pWoid); END IF; UPDATE wo SET wo_status='O' WHERE (wo_id=pWoid); IF (pImplodeChildren) THEN resultCode := (SELECT MAX(implodeWo(wo_id, TRUE)) FROM wo WHERE ((wo_ordtype='W') AND (wo_ordid=pWoid))); resultCode := (SELECT MAX(deleteWo(wo_id, TRUE)) FROM wo WHERE ((wo_ordtype='W') AND (wo_ordid=pWoid))); END IF; RETURN 0; END; $$; IDROP FUNCTION public.implodewo(pwoid integer, pimplodechildren boolean); publicadminfalse84623125587036importbankreccleared(integer)FUNCTIONCREATE FUNCTION importbankreccleared(pbankrecid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _bankrecid INTEGER; _result INTEGER := 0; _cleared BOOLEAN; _doctype TEXT; _docid INTEGER := -1; _bankadjid INTEGER := -1; _debitbankadjtypeid INTEGER := -1; _creditbankadjtypeid INTEGER := -1; _b RECORD; _r RECORD; BEGIN -- cache some information IF (pBankrecid = -1) THEN _bankrecid := fetchMetricValue('ImportBankRecId'); ELSE _bankrecid := pBankrecid; END IF; SELECT * INTO _b FROM bankrec JOIN bankaccnt ON (bankaccnt_id=bankrec_bankaccnt_id) WHERE (bankrec_id=_bankrecid); IF (NOT FOUND) THEN RAISE EXCEPTION 'bankrec not found'; END IF; IF (_b.bankrec_posted) THEN RAISE EXCEPTION 'bankrec already posted'; END IF; _debitbankadjtypeid := fetchMetricValue('ImportBankRecDebitAdj'); IF (_debitbankadjtypeid = -1) THEN RAISE EXCEPTION 'Metric ImportBankRecDebitAdj not defined [xtuple: reconcileBankAccount, -1]'; END IF; _creditbankadjtypeid := fetchMetricValue('ImportBankRecCreditAdj'); IF (_creditbankadjtypeid = -1) THEN RAISE EXCEPTION 'Metric ImportBankRecCreditAdj not defined [xtuple: reconcileBankAccount, -2]'; END IF; -- loop thru bankrecimport and toggle cleared items FOR _r IN SELECT *, COALESCE(bankrecimport_debit_amount, 0.0) AS debit, COALESCE(bankrecimport_credit_amount, 0.0) AS credit FROM bankrecimport -- TODO how to handle multiple bank accounts -- WHERE (bankrecimport_?=_b.bankaccnt=?) LOOP -- TODO how to handle duplicate document numbers -- TODO how to handle amount differences -- TODO add support for Project Accounting (sltrans) IF ( (_r.debit > 0.0) AND (_r.credit > 0.0) ) THEN RAISE WARNING 'Bankrecimport % cannot determine if debit or credit', _r.bankrecimport_reference; CONTINUE; END IF; IF (_r.debit > 0.0) THEN -- handle receipts SELECT cashrcpt_id INTO _docid FROM cashrcpt WHERE (cashrcpt_docnumber=_r.bankrecimport_reference) AND (cashrcpt_posted) AND (NOT cashrcpt_void) -- TODO workaround for duplicates ORDER BY cashrcpt_id DESC LIMIT 1; IF (FOUND) THEN SELECT toggleBankrecCleared(_b.bankrec_id, 'GL', gltrans_id, cashrcpt_curr_rate, _r.debit, _r.bankrecimport_effdate) INTO _cleared FROM gltrans LEFT OUTER JOIN bankrecitem ON (bankrecitem_source='GL' AND bankrecitem_source_id=gltrans_id) WHERE (gltrans_source='A/R') AND (gltrans_doctype='CR') AND (gltrans_misc_id=_docid) AND (NOT gltrans_rec) AND (gltrans_accnt_id=_b.bankaccnt_accnt_id) AND (NOT COALESCE(bankrecitem_cleared, FALSE)); ELSE -- create and toggle bank adjustment -- TODO define bank adjustment names _bankadjid := -1; SELECT bankadj_id INTO _bankadjid FROM bankadj JOIN bankadjtype ON (bankadjtype_id=bankadj_bankadjtype_id) WHERE (bankadjtype_id=_debitbankadjtypeid) AND (bankadj_docnumber=_r.bankrecimport_reference) AND (bankadj_bankaccnt_id=_b.bankaccnt_id); IF (NOT FOUND) THEN INSERT INTO bankadj (bankadj_bankaccnt_id, bankadj_bankadjtype_id, bankadj_date, bankadj_docnumber, bankadj_amount, bankadj_notes, bankadj_curr_id) VALUES (_b.bankaccnt_id, _debitbankadjtypeid, _r.bankrecimport_effdate, _r.bankrecimport_reference, _r.debit, 'Import Bankrec Adjustment', _b.bankaccnt_curr_id) RETURNING bankadj_id INTO _bankadjid; END IF; SELECT toggleBankrecCleared(_b.bankrec_id, 'AD', _bankadjid, 1.0, _r.debit, _r.bankrecimport_effdate) INTO _cleared FROM bankadj LEFT OUTER JOIN bankrecitem ON (bankrecitem_source='AD' AND bankrecitem_source_id=bankadj_id) WHERE (bankadj_id=_bankadjid) AND (NOT COALESCE(bankrecitem_cleared, FALSE)); END IF; -- done with receipts ELSE -- handle checks SELECT checkhead_id INTO _docid FROM checkhead WHERE (checkhead_number::TEXT=_r.bankrecimport_reference) AND (checkhead_posted) AND (NOT checkhead_void); IF (FOUND) THEN SELECT toggleBankrecCleared(_b.bankrec_id, 'GL', gltrans_id, checkhead_curr_rate, _r.credit, _r.bankrecimport_effdate) INTO _cleared FROM gltrans LEFT OUTER JOIN bankrecitem ON (bankrecitem_source='GL' AND bankrecitem_source_id=gltrans_id) WHERE (gltrans_source='A/P') AND (gltrans_doctype='CK') AND (gltrans_misc_id=_docid) AND (NOT gltrans_rec) AND (gltrans_accnt_id=_b.bankaccnt_accnt_id) AND (NOT COALESCE(bankrecitem_cleared, FALSE)); ELSE -- create and toggle bank adjustment -- TODO define bank adjustment names _bankadjid := -1; SELECT bankadj_id INTO _bankadjid FROM bankadj JOIN bankadjtype ON (bankadjtype_id=bankadj_bankadjtype_id) WHERE (bankadjtype_id=_creditbankadjtypeid) AND (bankadj_docnumber=_r.bankrecimport_reference); IF (NOT FOUND) THEN INSERT INTO bankadj (bankadj_bankaccnt_id, bankadj_bankadjtype_id, bankadj_date, bankadj_docnumber, bankadj_amount, bankadj_notes, bankadj_curr_id) VALUES (_b.bankaccnt_id, _creditbankadjtypeid, _r.bankrecimport_effdate, _r.bankrecimport_reference, _r.credit, 'Import Bankrec Adjustment', _b.bankaccnt_curr_id) RETURNING bankadj_id INTO _bankadjid; END IF; SELECT toggleBankrecCleared(_b.bankrec_id, 'AD', _bankadjid, 1.0, _r.credit, _r.bankrecimport_effdate) INTO _cleared FROM bankadj LEFT OUTER JOIN bankrecitem ON (bankrecitem_source='AD' AND bankrecitem_source_id=_bankadjid) WHERE (NOT COALESCE(bankrecitem_cleared, FALSE)); END IF; -- done with checks END IF; END LOOP; RETURN _result; END; $$; ?DROP FUNCTION public.importbankreccleared(pbankrecid integer); publicadminfalse46238125978696incdtTABLE CREATE TABLE incdt ( incdt_id integer NOT NULL, incdt_number integer NOT NULL, incdt_crmacct_id integer, incdt_cntct_id integer, incdt_summary text, incdt_descrip text, incdt_item_id integer, incdt_timestamp timestamp without time zone DEFAULT now() NOT NULL, incdt_status character(1) DEFAULT 'N'::bpchar NOT NULL, incdt_assigned_username text, incdt_incdtcat_id integer, incdt_incdtseverity_id integer, incdt_incdtpriority_id integer, incdt_incdtresolution_id integer, incdt_lotserial text, incdt_ls_id integer, incdt_aropen_id integer, incdt_owner_username text, incdt_recurring_incdt_id integer, incdt_updated timestamp without time zone DEFAULT now() NOT NULL, incdt_prj_id integer, incdt_public boolean ); DROP TABLE public.incdt; publicadminfalse6003600460058%00 TABLE incdtCOMMENT,COMMENT ON TABLE incdt IS 'Incident table'; publicadminfalse189%00COLUMN incdt.incdt_lotserialCOMMENTLCOMMENT ON COLUMN incdt.incdt_lotserial IS 'incdt_lotserial is deprecated'; publicadminfalse189%00%COLUMN incdt.incdt_recurring_incdt_idCOMMENTCOMMENT ON COLUMN incdt.incdt_recurring_incdt_id IS 'The first incdt record in the series if this is a recurring Incident. If the incdt_recurring_incdt_id is the same as the incdt_id, this record is the first in the series.'; publicadminfalse189%00incdtACLREVOKE ALL ON TABLE incdt FROM PUBLIC; REVOKE ALL ON TABLE incdt FROM admin; GRANT ALL ON TABLE incdt TO admin; GRANT ALL ON TABLE incdt TO xtrole; publicadminfalse189125578705incdt()FUNCTION&CREATE FUNCTION incdt() RETURNS SETOF incdt LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row incdt%ROWTYPE; _priv TEXT; _grant BOOLEAN; BEGIN -- This query will give us the most permissive privilege the user has been granted SELECT privilege, granted INTO _priv, _grant FROM privgranted WHERE privilege IN ('MaintainAllIncidents','ViewAllIncidents','MaintainPersonalIncidents','ViewPersonalIncidents') ORDER BY granted DESC, sequence LIMIT 1; -- If have an 'All' privilege return all results IF (_priv ~ 'All' AND _grant) THEN FOR _row IN SELECT * FROM incdt LOOP RETURN NEXT _row; END LOOP; -- Otherwise if have any other grant, must be personal privilege. ELSIF (_grant) THEN FOR _row IN SELECT * FROM incdt WHERE getEffectiveXtUser() IN (incdt_owner_username, incdt_assigned_username) LOOP RETURN NEXT _row; END LOOP; END IF; RETURN; END; $$; DROP FUNCTION public.incdt(); publicadminfalse462327958%00FUNCTION incdt()COMMENTrCOMMENT ON FUNCTION incdt() IS 'A table function that returns Incident results according to privilege settings.'; publicadminfalse1707125578706indentedbom(integer)FUNCTIONvCREATE FUNCTION indentedbom(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; _revid INTEGER; BEGIN SELECT getActiveRevId('BOM',pItemid) INTO _revid; RETURN indentedBOM(pItemid, _revid); END; $_$; +DROP FUNCTION public.indentedbom(integer); publicadminfalse84623125578707indentedbom(integer, integer)FUNCTION^ CREATE FUNCTION indentedbom(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pRevisionid ALIAS FOR $2; _bomworkid INTEGER; _indexid INTEGER; _r RECORD; _batchsize NUMERIC; BEGIN -- Get the batch quantity SELECT COALESCE( ( SELECT bomhead_batchsize FROM bomhead WHERE ((bomhead_item_id=pItemId) AND (bomhead_rev_id=pRevisionid)) LIMIT 1),1) INTO _batchsize; -- Check on the temporary workspace -- PERFORM maintainBOMWorkspace(); -- Grab a new index for this bomwork set SELECT NEXTVAL('misc_index_seq') INTO _indexid; -- Step through all of the components of the passed pItemid FOR _r IN SELECT bomitem.*, item_id, itemuomtouom(item_id, item_inv_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') AS qtyreq, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS qtyfxd, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS qtyper, stdcost(item_id, bomitem_id) AS standardcost, actcost(item_id, bomitem_id) AS actualcost FROM bomitem(pItemId, pRevisionid), item WHERE ( (bomitem_item_id=item_id) ) LOOP -- Insert the component and bomitem parameters SELECT NEXTVAL('bomwork_bomwork_id_seq') INTO _bomworkid; INSERT INTO bomwork ( bomwork_id, bomwork_set_id, bomwork_parent_id, bomwork_level, bomwork_parent_seqnumber, bomwork_seqnumber, bomwork_item_id, bomwork_createwo, bomwork_qtyreq, bomwork_qtyfxd, bomwork_qtyper, bomwork_scrap, bomwork_issuemethod, bomwork_effective, bomwork_expires, bomwork_stdunitcost, bomwork_actunitcost, bomwork_char_id, bomwork_value, bomwork_notes, bomwork_ref, bomwork_bomitem_id, bomwork_ecn ) VALUES ( _bomworkid, _indexid, -1, 1, 0, _r.bomitem_seqnumber, _r.item_id, _r.bomitem_createwo, _r.qtyreq, _r.qtyfxd, _r.qtyper, _r.bomitem_scrap, _r.bomitem_issuemethod, _r.bomitem_effective, _r.bomitem_expires, _r.standardcost, _r.actualcost, _r.bomitem_char_id, _r.bomitem_value, _r.bomitem_notes, _r.bomitem_ref, _r.bomitem_id, _r.bomitem_ecn ); -- Explode the components of the current component PERFORM explodeBOM(_r.item_id, _bomworkid, 1); END LOOP; -- Return a key to the result RETURN _indexid; END; $_$; 4DROP FUNCTION public.indentedbom(integer, integer); publicadminfalse46238125587037/indentedbom(integer, integer, integer, integer)FUNCTION$CREATE FUNCTION indentedbom(integer, integer, integer, integer) RETURNS SETOF bomdata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pRevisionid ALIAS FOR $2; pExpiredDays ALIAS FOR $3; pFutureDays ALIAS FOR $4; _row bomdata%ROWTYPE; _bomworksetid INTEGER; _x RECORD; _check CHAR(1); _inactive BOOLEAN := FALSE; _batchsize NUMERIC; BEGIN IF (pRevisionid != -1) THEN --Is this a deactivated revision? SELECT rev_status INTO _check FROM rev WHERE ((rev_id=pRevisionid) AND (rev_status='I')); IF (FOUND) THEN _inactive := TRUE; END IF; END IF; -- Get the batch quantity SELECT COALESCE( ( SELECT bomhead_batchsize FROM bomhead WHERE ((bomhead_item_id=pItemId) AND (bomhead_rev_id=pRevisionid)) LIMIT 1),1) INTO _batchsize; IF NOT (_inactive) THEN --We can explode this out based on current data SELECT indentedBOM(pItemid, pRevisionid) INTO _bomworksetid; FOR _x IN SELECT bomwork_id, bomwork_parent_id, bomwork_level, bomworkSequence(bomwork_id) AS seq_ord, bomwork_seqnumber, item_id, item_number, uom_name, item_descrip1, item_descrip2, (item_descrip1 || ' ' || item_descrip2) AS itemdescription, bomwork_qtyreq, bomwork_qtyfxd, bomwork_qtyper, bomwork_scrap, bomwork_createwo, CASE WHEN (bomwork_issuemethod='S') THEN 'Push' WHEN (bomwork_issuemethod='L') THEN 'Pull' WHEN (bomwork_issuemethod='M') THEN 'Mixed' ELSE 'Special' END AS issuemethod, bomwork_effective, bomwork_expires, (bomwork_expires <= CURRENT_DATE) AS expired, (bomwork_effective > CURRENT_DATE) AS future, bomwork_actunitcost AS actunitcost, bomwork_stdunitcost AS stdunitcost, CASE WHEN item_type NOT IN ('R','T') THEN itemuomtouom(item_id, item_inv_uom_id, NULL, (bomwork_qtyfxd/_batchsize + bomwork_qtyper) * (1 + bomwork_scrap), 'qtyper') * bomwork_actunitcost ELSE 0.0 END AS actextendedcost, CASE WHEN item_type NOT IN ('R','T') THEN itemuomtouom(item_id, item_inv_uom_id, NULL, (bomwork_qtyfxd/_batchsize + bomwork_qtyper) * (1 + bomwork_scrap), 'qtyper') * bomwork_stdunitcost ELSE 0.0 END AS stdextendedcost, bomwork_char_id, bomwork_value, bomwork_notes, bomwork_ref, bomwork_bomitem_id, bomwork_ecn FROM bomwork, item, uom WHERE ( (bomwork_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (bomwork_set_id=_bomworksetid) ) AND (bomwork_expires > (CURRENT_DATE - pExpiredDays)) AND (bomwork_effective <= (CURRENT_DATE + pFutureDays)) UNION SELECT -1, -1, 1, '0', NULL,-1, costelem_type AS bomdata_item_number, '', '', '', '', NULL, NULL, NULL, NULL, NULL, '', NULL, NULL, false, false, currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE) AS actunitcost, itemcost_stdcost AS stdunitcost, currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE) AS actextendedcost, itemcost_stdcost AS stdextendedcost, NULL, NULL,NULL,NULL, NULL,NULL FROM itemcost, costelem WHERE ( (itemcost_costelem_id=costelem_id) AND (NOT itemcost_lowlevel) AND (itemcost_item_id=pItemid) ) ORDER BY seq_ord LOOP _row.bomdata_bomwork_id := _x.bomwork_id; _row.bomdata_bomwork_parent_id := _x.bomwork_parent_id; _row.bomdata_bomwork_level := _x.bomwork_level; _row.bomdata_bomwork_seqnumber := _x.bomwork_seqnumber; _row.bomdata_bomitem_id := _x.bomwork_bomitem_id; _row.bomdata_item_id := _x.item_id; _row.bomdata_item_number := _x.item_number; _row.bomdata_uom_name := _x.uom_name; _row.bomdata_item_descrip1 := _x.item_descrip1; _row.bomdata_item_descrip2 := _x.item_descrip2; _row.bomdata_itemdescription := _x.itemdescription; _row.bomdata_batchsize := _batchsize; _row.bomdata_qtyreq := _x.bomwork_qtyreq; _row.bomdata_qtyfxd := _x.bomwork_qtyfxd; _row.bomdata_qtyper := _x.bomwork_qtyper; _row.bomdata_scrap := _x.bomwork_scrap; _row.bomdata_createchild := _x.bomwork_createwo; _row.bomdata_issuemethod := _x.issuemethod; _row.bomdata_effective := _x.bomwork_effective; _row.bomdata_expires := _x.bomwork_expires; _row.bomdata_expired := _x.expired; _row.bomdata_future := _x.future; _row.bomdata_actunitcost := _x.actunitcost; _row.bomdata_stdunitcost := _x.stdunitcost; _row.bomdata_actextendedcost := _x.actextendedcost; _row.bomdata_stdextendedcost := _x.stdextendedcost; _row.bomdata_ecn := _x.bomwork_ecn; _row.bomdata_char_id := _x.bomwork_char_id; _row.bomdata_value := _x.bomwork_value; _row.bomdata_notes := _x.bomwork_notes; _row.bomdata_ref := _x.bomwork_ref; RETURN NEXT _row; END LOOP; PERFORM deleteBOMWorkset(_bomworksetid); ELSE -- Use historical snapshot for inactive revisions FOR _x IN SELECT bomhist_id, bomhist_parent_id, bomhist_level, bomhistSequence(bomhist_seq_id) AS seq_ord, bomhist_seqnumber, item_id, item_number, uom_name, item_descrip1, item_descrip2, (item_descrip1 || ' ' || item_descrip2) AS itemdescription, bomhist_qtyreq, bomhist_qtyfxd, bomhist_qtyper, bomhist_scrap, bomhist_createwo, CASE WHEN (bomhist_issuemethod='S') THEN 'Push' WHEN (bomhist_issuemethod='L') THEN 'Pull' WHEN (bomhist_issuemethod='M') THEN 'Mixed' ELSE 'Special' END AS issuemethod, bomhist_effective, bomhist_expires, (bomhist_expires <= CURRENT_DATE) AS expired, (bomhist_effective > CURRENT_DATE) AS future, bomhist_actunitcost AS actunitcost, bomhist_stdunitcost AS stdunitcost, CASE WHEN item_type NOT IN ('R','T') THEN (bomhist_qtyfxd/_batchsize + bomhist_qtyper) * (1 + bomhist_scrap) * bomhist_actunitcost ELSE 0 END AS actextendedcost, CASE WHEN item_type NOT IN ('R','T') THEN (bomhist_qtyfxd/_batchsize + bomhist_qtyper) * (1 + bomhist_scrap) * bomhist_stdunitcost ELSE 0 END AS stdextendedcost, bomhist_char_id, bomhist_value, bomhist_notes, bomhist_ref FROM bomhist, item, uom WHERE ( (bomhist_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (bomhist_rev_id=pRevisionid) ) AND (bomhist_expires > (CURRENT_DATE - pExpiredDays)) AND (bomhist_effective <= (CURRENT_DATE + pFutureDays)) UNION SELECT -1, -1, 1, '0', NULL,-1, costelem_type AS bomdata_item_number, '', '', '', '', NULL, NULL, NULL, NULL, false, '', NULL, NULL, false, false, bomhist_actunitcost AS actunitcost, bomhist_stdunitcost AS stdunitcost, bomhist_actunitcost AS actextendedcost, bomhist_stdunitcost AS stdextendedcost, NULL,NULL,NULL,NULL FROM bomhist, costelem WHERE ((bomhist_rev_id=pRevisionid) AND (costelem_id=bomhist_item_id)) ORDER BY seq_ord LOOP _row.bomdata_bomwork_id := _x.bomhist_id; _row.bomdata_bomwork_parent_id := _x.bomhist_parent_id; _row.bomdata_bomwork_level := _x.bomhist_level; _row.bomdata_bomwork_seqnumber := _x.bomhist_seqnumber; _row.bomdata_bomitem_id := -1; _row.bomdata_item_id := _x.item_id; _row.bomdata_item_number := _x.item_number; _row.bomdata_uom_name := _x.uom_name; _row.bomdata_item_descrip1 := _x.item_descrip1; _row.bomdata_item_descrip2 := _x.item_descrip2; _row.bomdata_itemdescription := _x.itemdescription; _row.bomdata_batchsize := _batchsize; _row.bomdata_qtyreq := _x.bomhist_qtyreq; _row.bomdata_qtyfxd := _x.bomhist_qtyfxd; _row.bomdata_qtyper := _x.bomhist_qtyper; _row.bomdata_scrap := _x.bomhist_scrap; _row.bomdata_createchild := _x.bomhist_createwo; _row.bomdata_issuemethod := _x.issuemethod; _row.bomdata_effective := _x.bomhist_effective; _row.bomdata_expires := _x.bomhist_expires; _row.bomdata_expired := _x.expired; _row.bomdata_future := _x.future; _row.bomdata_actunitcost := _x.actunitcost; _row.bomdata_stdunitcost := _x.stdunitcost; _row.bomdata_actextendedcost := _x.actextendedcost; _row.bomdata_stdextendedcost := _x.stdextendedcost; _row.bomdata_ecn := ''; _row.bomdata_char_id := _x.bomhist_char_id; _row.bomdata_value := _x.bomhist_value; _row.bomdata_notes := _x.bomhist_notes; _row.bomdata_ref := _x.bomhist_ref; RETURN NEXT _row; END LOOP; END IF; RETURN; END; $_$; FDROP FUNCTION public.indentedbom(integer, integer, integer, integer); publicadminfalse462384237125578710indentedwhereused(integer)FUNCTION CREATE FUNCTION indentedwhereused(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; _indexid INTEGER; _level INTEGER; BEGIN -- Check on the temporary workspace -- PERFORM maintainBOMWorkspace(); _indexid := (SELECT NEXTVAL('misc_index_seq')); _level := 1; INSERT INTO bomwork ( bomwork_set_id, bomwork_parent_id, bomwork_level, bomwork_seqnumber, bomwork_item_id, bomwork_item_type, bomwork_createwo, bomwork_qtyfxd, bomwork_qtyper, bomwork_scrap, bomwork_issuemethod, bomwork_effective, bomwork_expires, bomwork_status, bomwork_stdunitcost, bomwork_actunitcost ) SELECT _indexid, -1, 1, bomitem_seqnumber, item_id, item_type, bomitem_createwo, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd), (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper), bomitem_scrap, bomitem_issuemethod, bomitem_effective, bomitem_expires, 'U', stdcost(item_id), actcost(item_id) FROM bomitem, item WHERE ((bomitem_item_id=pItemid) AND (bomitem_parent_item_id=item_id) AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id))); WHILE ( ( SELECT count(*) FROM bomwork WHERE ((bomwork_status='U') AND (bomwork_set_id=_indexid)) ) > 0) LOOP _level := _level + 1; INSERT INTO bomwork ( bomwork_set_id, bomwork_parent_id, bomwork_level, bomwork_seqnumber, bomwork_item_id, bomwork_item_type, bomwork_createwo, bomwork_qtyfxd, bomwork_qtyper, bomwork_scrap, bomwork_issuemethod, bomwork_effective, bomwork_expires, bomwork_status, bomwork_stdunitcost, bomwork_actunitcost ) SELECT _indexid, bomwork_id, _level, bomitem_seqnumber, item_id, item_type, bomitem_createwo, (bomwork_qtyper * (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd)), (bomwork_qtyper * (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper)), bomitem_scrap, bomitem_issuemethod, CASE WHEN bomitem_effective < bomwork_effective THEN bomwork_effective ELSE bomitem_effective END, CASE WHEN bomitem_expires > bomwork_expires THEN bomwork_expires ELSE bomitem_expires END, 'N', stdcost(item_id), actcost(item_id) FROM bomwork JOIN bomitem ON ( (bomitem_item_id=bomwork_item_id) AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id)) ) JOIN item ON (item_id=bomitem_parent_item_id) WHERE (bomwork_status='U'); UPDATE bomwork SET bomwork_status='C' WHERE ((bomwork_status='U') AND (bomwork_set_id=_indexid)); UPDATE bomwork SET bomwork_status='U' WHERE ((bomwork_status='N') AND (bomwork_set_id=_indexid)); END LOOP; RETURN _indexid; END; $_$; 1DROP FUNCTION public.indentedwhereused(integer); publicadminfalse84623125587039.indentedwo(integer, boolean, boolean, boolean)FUNCTIONCREATE FUNCTION indentedwo(integer, boolean, boolean, boolean) RETURNS SETOF wodata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pwoid ALIAS FOR $1; pshowops ALIAS FOR $2; pshowmatl ALIAS FOR $3; pshowindent ALIAS FOR $4; _row wodata%ROWTYPE; _subrow wodata%ROWTYPE; _opx wodata%ROWTYPE; _x RECORD; _level INTEGER; BEGIN --The wodata_id_type column is used to indicate the source of the wodata_id --there are three different tables used wo, womatl and womatlvar --wodata_id_type = 1 = wo_id --wodata_id_type = 2 = womatl_id --wodata_id_type = 3 = wooper_id --initialise values _level := 0; --get top level works orders FOR _x IN SELECT wo_id,wo_number,wo_subnumber,wo_status,wo_startdate, wo_duedate,wo_adhoc,wo_itemsite_id,qtyAvailable(itemsite_id) AS availableqoh, wo_qtyord,wo_qtyrcv,wo_prodnotes, item_number, item_descrip1, item_descrip2, item_listprice, uom_name FROM wo, itemsite, item, uom WHERE ((wo_id = pwoid) AND (itemsite_id = wo_itemsite_id) AND (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id)) ORDER BY wo_number, wo_subnumber LOOP _row.wodata_id := _x.wo_id; _row.wodata_id_type := 1; _row.wodata_number := _x.wo_number; _row.wodata_subnumber := _x.wo_subnumber; _row.wodata_itemnumber := _x.item_number; _row.wodata_descrip := _x.item_descrip1 || '-' || _x.item_descrip2; _row.wodata_status := _x.wo_status; _row.wodata_startdate := _x.wo_startdate; _row.wodata_duedate := _x.wo_duedate; _row.wodata_adhoc := _x.wo_adhoc; _row.wodata_itemsite_id := _x.wo_itemsite_id; _row.wodata_custprice := _x.item_listprice; _row.wodata_listprice := _x.item_listprice; _row.wodata_qoh := _x.availableqoh; _row.wodata_short := noneg(_x.wo_qtyord - _x.wo_qtyrcv); _row.wodata_qtyrcv := _x.wo_qtyrcv; _row.wodata_qtyordreq := _x.wo_qtyord; _row.wodata_qtyuom := _x.uom_name; _row.wodata_scrap := 0; _row.wodata_notes := _x.wo_prodnotes; _row.wodata_level := _level; RETURN NEXT _row; IF (pshowmatl AND NOT pshowops) THEN --expand materials FOR _subrow IN SELECT * FROM indentedwomatl(pwoid, _level) LOOP RETURN NEXT _subrow; END LOOP; END IF; IF ((pshowmatl OR pshowindent) AND NOT pshowops) THEN --expand next level down FOR _subrow IN SELECT * FROM indentedwo(_x.wo_id, NULL, _level + 1, pshowmatl, pshowindent) LOOP RETURN NEXT _subrow; END LOOP; END IF; IF (pshowops) THEN --expand materials not on operations IF (pshowmatl) THEN FOR _subrow IN SELECT * FROM indentedwomatl(pwoid, -1, _level) LOOP RETURN NEXT _subrow; END LOOP; END IF; IF (pshowmatl OR pshowindent) THEN --expand next level down FOR _subrow IN SELECT * FROM indentedwo(_x.wo_id, -1, _level + 1, pshowmatl, pshowindent) LOOP RETURN NEXT _subrow; END LOOP; END IF; --expand opeartions FOR _opx IN SELECT * FROM xtmfg.indentedwoops(pwoid,_level) LOOP RETURN NEXT _opx; IF (pshowmatl) THEN --expand materials on operations FOR _subrow IN SELECT * FROM indentedwomatl(pwoid, _opx.wodata_id, _level + 1) LOOP RETURN NEXT _subrow; END LOOP; END IF; IF (pshowmatl OR pshowindent) THEN --expand next level down FOR _subrow IN SELECT * FROM indentedwo(_x.wo_id, _opx.wodata_id, _level + 2, pshowmatl, pshowindent) LOOP RETURN NEXT _subrow; END LOOP; END IF; END LOOP; END IF; END LOOP; RETURN; END; $_$; EDROP FUNCTION public.indentedwo(integer, boolean, boolean, boolean); publicadminfalse4273462381255870407indentedwo(integer, integer, integer, boolean, boolean)FUNCTIONCREATE FUNCTION indentedwo(integer, integer, integer, boolean, boolean) RETURNS SETOF wodata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pwoid ALIAS FOR $1; pwooperid ALIAS FOR $2; plevel ALIAS FOR $3; pshowmatl ALIAS FOR $4; pshowindent ALIAS FOR $5; _row wodata%ROWTYPE; _opx wodata%ROWTYPE; _x RECORD; _subx RECORD; _index INTEGER; _level INTEGER; _qry TEXT; BEGIN --The wodata id column is used to indicate the source of the id --there are three different tables used wo, womatl and womatlvar --wodata_id_type = 1 = wo_id --wodata_id_type = 2 = womatl_id --wodata_id_type = 3 = wooper_id _level := (plevel + 1); --find all WO with the ordid of the next level up _qry := 'SELECT wo_id,wo_number,wo_subnumber,wo_status,wo_startdate,wo_duedate, wo_adhoc,wo_itemsite_id,qtyAvailable(itemsite_id) AS availableqoh,wo_qtyord,wo_qtyrcv, wo_prodnotes, item_number,item_descrip1, item_descrip2, item_listprice, uom_name, womatl_qtyiss, womatl_qtywipscrap, womatl_wooper_id FROM itemsite, wo, item, uom, womatl WHERE ((wo_ordid = ' || pwoid || ') AND (wo_ordtype = ''W'') AND (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (wo_womatl_id=womatl_id) AND (wo_itemsite_id = itemsite_id) '; IF (pwooperid IS NOT NULL) THEN _qry := _qry || ' AND (womatl_wooper_id=' || pwooperid || ') '; END IF; _qry := _qry || ') ORDER BY wo_number, wo_subnumber'; /* if (pwooperid IS NOT NULL) THEN raise exception 'stop %',_qry; END IF;*/ FOR _x IN EXECUTE _qry LOOP _row.wodata_id := _x.wo_id; _row.wodata_id_type := 1; _row.wodata_number := _x.wo_number; _row.wodata_subnumber := _x.wo_subnumber; _row.wodata_itemnumber := _x.item_number; _row.wodata_descrip := _x.item_descrip1 || '-' || _x.item_descrip2; _row.wodata_status := _x.wo_status; _row.wodata_startdate := _x.wo_startdate; _row.wodata_duedate := _x.wo_duedate; _row.wodata_adhoc := _x.wo_adhoc; _row.wodata_itemsite_id := _x.wo_itemsite_id; _row.wodata_custprice := _x.item_listprice; _row.wodata_listprice := _x.item_listprice; _row.wodata_qoh := _x.availableqoh; _row.wodata_short := noneg(_x.wo_qtyord - _x.wo_qtyrcv); _row.wodata_qtyiss := _x.womatl_qtyiss; _row.wodata_qtyrcv := _x.wo_qtyrcv; _row.wodata_qtyordreq := _x.wo_qtyord; _row.wodata_scrap := _x.womatl_qtywipscrap; _row.wodata_notes := _x.wo_prodnotes; _row.wodata_level := plevel; RETURN NEXT _row; --if indentation require expand next level IF (pshowindent AND pwooperid IS NULL) THEN IF (pshowmatl AND pshowindent) THEN --get materials for this level FOR _subx IN SELECT * FROM indentedwomatl(_x.wo_id, plevel) LOOP RETURN NEXT _subx; END LOOP; END IF; IF (pshowindent) THEN --expand lower levels FOR _subx IN SELECT * FROM indentedwo(_x.wo_id, NULL, _level, pshowmatl, pshowindent ) LOOP RETURN NEXT _subx; END LOOP; END IF; ELSIF (pshowindent) THEN --Handle operations --expand materials not on operations IF (pshowmatl) THEN FOR _subx IN SELECT * FROM indentedwomatl(_x.wo_id, -1, plevel) LOOP RETURN NEXT _subx; END LOOP; END IF; --expand next level down not on operations FOR _subx IN SELECT * FROM indentedwo(_x.wo_id, -1, _level, pshowmatl, pshowindent) LOOP RETURN NEXT _subx; END LOOP; --expand operations FOR _opx IN SELECT * FROM xtmfg.indentedwoops(_x.wo_id,plevel) LOOP RETURN NEXT _opx; IF (pshowmatl) THEN --expand materials on operations FOR _subx IN SELECT * FROM indentedwomatl(_x.wo_id, _opx.wodata_id, _level) LOOP RETURN NEXT _subx; -- raise exception 'stop %',_opx.wodata_id; END LOOP; END IF; --expand next level down FOR _subx IN SELECT * FROM indentedwo(_x.wo_id, _opx.wodata_id, _level + 2, pshowmatl, pshowindent) LOOP RETURN NEXT _subx; END LOOP; END LOOP; END IF; END LOOP; RETURN; END; $_$; NDROP FUNCTION public.indentedwo(integer, integer, integer, boolean, boolean); publicadminfalse842734623125587041 indentedwomatl(integer, integer)FUNCTIONCREATE FUNCTION indentedwomatl(integer, integer) RETURNS SETOF wodata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pwoid ALIAS FOR $1; plevel ALIAS FOR $2; _subx RECORD; BEGIN FOR _subx IN SELECT * FROM indentedwomatl(pwoid, NULL::integer, plevel) LOOP RETURN NEXT _subx; END LOOP; RETURN; END; $_$; 7DROP FUNCTION public.indentedwomatl(integer, integer); publicadminfalse462384273125587042)indentedwomatl(integer, integer, integer)FUNCTION CREATE FUNCTION indentedwomatl(integer, integer, integer) RETURNS SETOF wodata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pwoid ALIAS FOR $1; pwooperid ALIAS FOR $2; plevel ALIAS FOR $3; _status TEXT; _subrow wodata%ROWTYPE; _subx RECORD; _level INTEGER; _qry TEXT; BEGIN --The wodata id column is used to indicate the source of the id --there are three different tables used wo, womatl and womatlvar --wodata_id_type = 1 = wo_id --wodata_id_type = 2 = womatl_id --wodata_id_type = 3 = wooper_id _qry := 'SELECT womatl_id, wo_number, wo_subnumber, wo_startdate, womatl_duedate, womatl_itemsite_id, qtyAvailable(itemsite_id) AS availableqoh, womatl_qtyreq, womatl_qtyiss, womatl_qtyper, womatl_qtyreq, womatl_qtywipscrap, womatl_ref, womatl_notes, womatl_price, item_listprice, item_number, item_descrip1, item_descrip2, uom_name FROM womatl, wo, itemsite, item, uom WHERE ((wo_id = womatl_wo_id) AND (wo_id = ' || pwoid || ') AND (womatl_itemsite_id = itemsite_id) AND (itemsite_item_id=item_id) AND (womatl_uom_id=uom_id) '; -- Need to display in case child w/o is deleted -- AND (NOT womatl_createwo OR womatl_createwo IS NULL) '; IF (pwooperid IS NOT NULL) THEN _qry := _qry || 'AND (womatl_wooper_id=' || pwooperid || ')'; END IF; _qry := _qry || ') ORDER BY item_number;'; _level := plevel + 1; SELECT wo_status FROM wo WHERE wo_id = pwoid LIMIT 1 INTO _status; FOR _subx IN EXECUTE _qry LOOP _subrow.wodata_id := _subx.womatl_id; _subrow.wodata_id_type := 2; _subrow.wodata_number := _subx.wo_number; _subrow.wodata_subnumber := _subx.wo_subnumber; _subrow.wodata_itemnumber := _subx.item_number; _subrow.wodata_descrip := _subx.item_descrip1 || '-' || _subx.item_descrip2; _subrow.wodata_status := _status; _subrow.wodata_startdate := _subx.wo_startdate; _subrow.wodata_duedate := _subx.womatl_duedate; _subrow.wodata_itemsite_id := _subx.womatl_itemsite_id; _subrow.wodata_custprice := _subx.womatl_price; _subrow.wodata_listprice := _subx.item_listprice; _subrow.wodata_qoh := _subx.availableqoh; IF((_subx.availableqoh > (_subx.womatl_qtyreq - _subx.womatl_qtyiss))) THEN _subrow.wodata_short := 0; ELSE _subrow.wodata_short := (_subx.womatl_qtyreq - _subx.womatl_qtyiss) - _subx.availableqoh; END IF; _subrow.wodata_qtyper := _subx.womatl_qtyper; _subrow.wodata_qtyiss := _subx.womatl_qtyiss; _subrow.wodata_qtyordreq := _subx.womatl_qtyreq; _subrow.wodata_qtyuom := _subx.uom_name; _subrow.wodata_scrap := _subx.womatl_qtywipscrap; _subrow.wodata_notes := _subx.womatl_notes; _subrow.wodata_ref := _subx.womatl_ref; _subrow.wodata_level := _level; RETURN NEXT _subrow; END LOOP; RETURN; END; $_$; @DROP FUNCTION public.indentedwomatl(integer, integer, integer); publicadminfalse427346238125578715initeffectivextuser()FUNCTIONCREATE FUNCTION initeffectivextuser() RETURNS void LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Effective users use a temporary table to store the user information -- and this function, called by the other functions, makes sure the temp -- tables exist first. PERFORM * FROM pg_catalog.pg_class WHERE relname = 'effective_user' AND relnamespace = pg_catalog.pg_my_temp_schema(); IF NOT FOUND THEN CREATE TEMPORARY TABLE effective_user ( effective_key TEXT, effective_value TEXT ); CREATE UNIQUE INDEX effective_user_pkey ON effective_user (effective_key); END IF; END; $$; ,DROP FUNCTION public.initeffectivextuser(); publicadminfalse84623125578716%initialdistribution(integer, integer)FUNCTIONOCREATE FUNCTION initialdistribution(pitemsiteid integer, plocationid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _itemlocid INTEGER; _invhistid INTEGER; _itemlocSeries INTEGER; _r RECORD; BEGIN -- Make sure the passed itemsite points to a real item IF ( (SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J') FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ) ) ) THEN RETURN 0; END IF; _itemlocSeries := NEXTVAL('itemloc_series_seq'); -- Reassign the location_id for all existing itemlocs if -- the passed itemsite is already lot/serial controlled IF ( ( SELECT (itemsite_controlmethod IN ('L', 'S')) FROM itemsite WHERE (itemsite_id=pItemsiteid) ) ) THEN FOR _r IN SELECT itemloc_id, itemloc_ls_id, itemloc_qty FROM itemloc WHERE (itemloc_itemsite_id=pItemsiteid) LOOP -- Create the RL transaction SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid; INSERT INTO invhist ( invhist_id, invhist_itemsite_id, invhist_series, invhist_transtype, invhist_invqty, invhist_qoh_before, invhist_qoh_after, invhist_comments, invhist_invuom, invhist_unitcost, invhist_hasdetail, invhist_costmethod, invhist_value_before, invhist_value_after ) SELECT _invhistid, itemsite_id, _itemlocSeries, 'RL', 0, _r.itemloc_qty, _r.itemloc_qty, 'Initial Distribution', uom_name, stdCost(item_id), TRUE, itemsite_costmethod, itemsite_value, itemsite_value FROM item, itemsite, uom WHERE ( (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (itemsite_controlmethod <> 'N') AND (itemsite_id=pItemsiteid) ); -- Update the itemloc UPDATE itemloc SET itemloc_location_id=pLocationid WHERE (itemloc_id=_r.itemloc_id); -- Record the detail transaction INSERT INTO invdetail ( invdetail_invhist_id, invdetail_location_id, invdetail_ls_id, invdetail_qty, invdetail_qty_before, invdetail_qty_after ) VALUES ( _invhistid, pLocationid, _r.itemloc_ls_id, _r.itemloc_qty, 0, _r.itemloc_qty ); END LOOP; ELSE -- The passed itemsite is not lot/serial controlled -- Make sure that there are not any stagnent itemlocs DELETE FROM itemloc WHERE (itemloc_itemsite_id=pItemsiteid); -- Create the RL transaction SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid; INSERT INTO invhist ( invhist_id, invhist_itemsite_id, invhist_series, invhist_transtype, invhist_invqty, invhist_qoh_before, invhist_qoh_after, invhist_comments, invhist_invuom, invhist_unitcost, invhist_hasdetail, invhist_costmethod, invhist_value_before, invhist_value_after ) SELECT _invhistid, itemsite_id, _itemlocSeries, 'RL', 0, itemsite_qtyonhand, itemsite_qtyonhand, 'Initial Distribution', uom_name, stdCost(item_id), TRUE, itemsite_costmethod, itemsite_value, itemsite_value FROM item, itemsite, uom WHERE ( (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (itemsite_controlmethod <> 'N') AND (itemsite_id=pItemsiteid) ); -- Create the itemloc SELECT NEXTVAL('itemloc_itemloc_id_seq') INTO _itemlocid; INSERT INTO itemloc ( itemloc_id, itemloc_itemsite_id, itemloc_location_id, itemloc_expiration, itemloc_qty ) SELECT _itemlocid, itemsite_id, pLocationid, endOfTime(), itemsite_qtyonhand FROM itemsite WHERE (itemsite_id=pItemsiteid); -- Record the detail transaction INSERT INTO invdetail ( invdetail_invhist_id, invdetail_location_id, invdetail_qty, invdetail_qty_before, invdetail_qty_after ) SELECT _invhistid, pLocationid, itemsite_qtyonhand, 0, itemsite_qtyonhand FROM itemsite WHERE (itemsite_id=pItemsiteid); END IF; RETURN _itemlocid; END; $$; TDROP FUNCTION public.initialdistribution(pitemsiteid integer, plocationid integer); publicadminfalse46238125978717apopenTABLECREATE TABLE apopen ( apopen_id integer DEFAULT nextval(('"apopen_apopen_id_seq"'::text)::regclass) NOT NULL, apopen_docdate date, apopen_duedate date, apopen_terms_id integer, apopen_vend_id integer, apopen_doctype character(1), apopen_docnumber text, apopen_amount numeric(20,2), apopen_notes text, apopen_posted boolean, apopen_reference text, apopen_invcnumber text, apopen_ponumber text, apopen_journalnumber integer, apopen_paid numeric(20,2) DEFAULT 0, apopen_open boolean, apopen_username text, apopen_discount boolean DEFAULT false NOT NULL, apopen_accnt_id integer DEFAULT (-1), apopen_curr_id integer DEFAULT basecurrid(), apopen_closedate date, apopen_distdate date, apopen_void boolean DEFAULT false NOT NULL, apopen_curr_rate numeric NOT NULL, apopen_discountable_amount numeric(20,2) DEFAULT 0, apopen_status text, CONSTRAINT apopen_apopen_status_check CHECK ((((apopen_status = 'O'::text) OR (apopen_status = 'H'::text)) OR (apopen_status = 'C'::text))), CONSTRAINT apopen_apopen_status_notnull CHECK ((apopen_status IS NOT NULL)) ); DROP TABLE public.apopen; publicadminfalse6007600860096010601160126013601460158%00 TABLE apopenCOMMENTLCOMMENT ON TABLE apopen IS 'Accounts Payable (A/P) open Items information'; publicadminfalse190%00apopenACLREVOKE ALL ON TABLE apopen FROM PUBLIC; REVOKE ALL ON TABLE apopen FROM admin; GRANT ALL ON TABLE apopen TO admin; GRANT ALL ON TABLE apopen TO xtrole; publicadminfalse190125978732 curr_symbolTABLECREATE TABLE curr_symbol ( curr_id integer NOT NULL, curr_base boolean DEFAULT false NOT NULL, curr_name character varying(50) NOT NULL, curr_symbol character varying(9) NOT NULL, curr_abbr character varying(3) NOT NULL ); DROP TABLE public.curr_symbol; publicadminfalse60178%00TABLE curr_symbolCOMMENTNCOMMENT ON TABLE curr_symbol IS 'Currency Names, Symbols, and Abbreviations'; publicadminfalse191%00 curr_symbolACLREVOKE ALL ON TABLE curr_symbol FROM PUBLIC; REVOKE ALL ON TABLE curr_symbol FROM admin; GRANT ALL ON TABLE curr_symbol TO admin; GRANT ALL ON TABLE curr_symbol TO xtrole; publicadminfalse191125978736termsTABLECREATE TABLE terms ( terms_id integer DEFAULT nextval(('terms_terms_id_seq'::text)::regclass) NOT NULL, terms_code text NOT NULL, terms_descrip text, terms_type character(1), terms_duedays integer, terms_discdays integer, terms_discprcnt numeric(10,6), terms_cutoffday integer, terms_ap boolean, terms_ar boolean, terms_fincharg boolean DEFAULT true NOT NULL, CONSTRAINT terms_terms_code_check CHECK ((terms_code <> ''::text)) ); DROP TABLE public.terms; publicadminfalse6018601960208&00 TABLE termsCOMMENT7COMMENT ON TABLE terms IS 'Billing Terms information'; publicadminfalse192&00termsACLREVOKE ALL ON TABLE terms FROM PUBLIC; REVOKE ALL ON TABLE terms FROM admin; GRANT ALL ON TABLE terms TO admin; GRANT ALL ON TABLE terms TO xtrole; publicadminfalse192125978745vendinfoTABLECREATE TABLE vendinfo ( vend_id integer DEFAULT nextval(('vend_vend_id_seq'::text)::regclass) NOT NULL, vend_name text, vend_lastpurchdate date, vend_active boolean, vend_po boolean, vend_comments text, vend_pocomments text, vend_number text NOT NULL, vend_1099 boolean, vend_exported boolean, vend_fobsource character(1), vend_fob text, vend_terms_id integer, vend_shipvia text, vend_vendtype_id integer, vend_qualified boolean, vend_ediemail text, vend_ediemailbody text, vend_edisubject text, vend_edifilename text, vend_accntnum text, vend_emailpodelivery boolean, vend_restrictpurch boolean, vend_edicc text, vend_curr_id integer DEFAULT basecurrid(), vend_cntct1_id integer, vend_cntct2_id integer, vend_addr_id integer, vend_match boolean DEFAULT false NOT NULL, vend_ach_enabled boolean DEFAULT false NOT NULL, vend_ach_accnttype text, vend_ach_use_vendinfo boolean DEFAULT true NOT NULL, vend_ach_indiv_number text DEFAULT ''::text NOT NULL, vend_ach_indiv_name text DEFAULT ''::text NOT NULL, vend_ediemailhtml boolean DEFAULT false NOT NULL, vend_ach_routingnumber bytea DEFAULT '\x00'::bytea NOT NULL, vend_ach_accntnumber bytea DEFAULT '\x00'::bytea NOT NULL, vend_taxzone_id integer, vend_accnt_id integer, vend_expcat_id integer DEFAULT (-1), vend_tax_id integer DEFAULT (-1), CONSTRAINT vendinfo_vend_ach_accnttype_check CHECK (((vend_ach_accnttype = 'K'::text) OR (vend_ach_accnttype = 'C'::text))), CONSTRAINT vendinfo_vend_number_check CHECK ((vend_number <> ''::text)) ); DROP TABLE public.vendinfo; publicadminfalse602160226023602460256026602760286029603060316032603360348&00TABLE vendinfoCOMMENT3COMMENT ON TABLE vendinfo IS 'Vendor information'; publicadminfalse193&00"COLUMN vendinfo.vend_ach_accnttypeCOMMENTCOMMENT ON COLUMN vendinfo.vend_ach_accnttype IS 'Type of bank account: K = checKing, C = Cash = savings. These values were chosen to be consistent with bankaccnt_type.'; publicadminfalse193&00vendinfoACLREVOKE ALL ON TABLE vendinfo FROM PUBLIC; REVOKE ALL ON TABLE vendinfo FROM admin; GRANT ALL ON TABLE vendinfo TO admin; GRANT ALL ON TABLE vendinfo TO xtrole; publicadminfalse193125978765apmemoVIEW CREATE VIEW apmemo AS SELECT vendinfo.vend_number AS vendor_number, apopen.apopen_docdate AS document_date, apopen.apopen_duedate AS due_date, CASE WHEN (apopen.apopen_doctype = 'C'::bpchar) THEN 'Credit Memo'::text ELSE 'Debit Memo'::text END AS document_type, apopen.apopen_docnumber AS document_number, apopen.apopen_ponumber AS po_number, apopen.apopen_journalnumber AS journal_number, terms.terms_code AS terms, curr.curr_abbr AS currency, apopen.apopen_amount AS amount, apopen.apopen_paid AS paid, (apopen.apopen_amount - apopen.apopen_paid) AS balance, apopen.apopen_notes AS notes, CASE WHEN (apopen.apopen_accnt_id = (-1)) THEN NULL::text ELSE public.formatglaccount(apopen.apopen_accnt_id) END AS alternate_prepaid_account FROM (((public.apopen LEFT JOIN public.vendinfo ON ((vendinfo.vend_id = apopen.apopen_vend_id))) LEFT JOIN public.curr_symbol curr ON ((curr.curr_id = apopen.apopen_curr_id))) LEFT JOIN public.terms ON ((terms.terms_id = apopen.apopen_terms_id))) WHERE (apopen.apopen_doctype = ANY (ARRAY['C'::bpchar, 'D'::bpchar])); DROP VIEW api.apmemo; apiadminfalse86336&00 VIEW apmemoCOMMENT7COMMENT ON VIEW apmemo IS 'A/P Credit and Debit Memo'; apiadminfalse194&00apmemoACLREVOKE ALL ON TABLE apmemo FROM PUBLIC; REVOKE ALL ON TABLE apmemo FROM admin; GRANT ALL ON TABLE apmemo TO admin; GRANT ALL ON TABLE apmemo TO xtrole; apiadminfalse194W 125578770insertapmemo(api.apmemo)FUNCTIONiCREATE FUNCTION insertapmemo(api.apmemo) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNew ALIAS FOR $1; _result INTEGER; BEGIN IF (pNew.document_type = 'Credit Memo') THEN SELECT createAPCreditMemo( getVendId(pNew.vendor_number), pNew.document_number, pNew.po_number, pNew.document_date, pNew.amount, pNew.notes, getGLAccntId(pNew.alternate_prepaid_account), pNew.due_date, getTermsId(pNew.terms) ) INTO _result; IF (_result <= 0) THEN RAISE EXCEPTION 'Function createAPCreditMemo failed with result = %', _result; END IF; ELSE IF (pNew.document_type = 'Debit Memo') THEN SELECT createAPDebitMemo( null, getVendId(pNew.vendor_number), pNew.journal_number, pNew.document_number, pNew.po_number, pNew.document_date, pNew.amount, pNew.notes, getGLAccntId(pNew.alternate_prepaid_account), pNew.due_date, getTermsId(pNew.terms), COALESCE(getCurrId(pNew.currency), baseCurrId()) ) INTO _result; IF (_result <= 0) THEN RAISE EXCEPTION 'Function createAPDebitMemo failed with result = %', _result; END IF; ELSE RAISE EXCEPTION 'Function insertAPMemo failed, invalid Document Type'; END IF; END IF; RETURN TRUE; END; $_$; /DROP FUNCTION public.insertapmemo(api.apmemo); publicadminfalse846232814125978771aropenTABLECREATE TABLE aropen ( aropen_id integer DEFAULT nextval(('"aropen_aropen_id_seq"'::text)::regclass) NOT NULL, aropen_docdate date NOT NULL, aropen_duedate date NOT NULL, aropen_terms_id integer, aropen_cust_id integer, aropen_doctype character(1), aropen_docnumber text, aropen_applyto text, aropen_ponumber text, aropen_amount numeric(20,2) NOT NULL, aropen_notes text, aropen_posted boolean DEFAULT false NOT NULL, aropen_salesrep_id integer, aropen_commission_due numeric(20,2), aropen_commission_paid boolean DEFAULT false, aropen_ordernumber text, aropen_cobmisc_id integer DEFAULT (-1), aropen_journalnumber integer, aropen_paid numeric(20,2) DEFAULT 0, aropen_open boolean, aropen_username text, aropen_rsncode_id integer, aropen_salescat_id integer DEFAULT (-1), aropen_accnt_id integer DEFAULT (-1), aropen_curr_id integer DEFAULT basecurrid(), aropen_closedate date, aropen_distdate date, aropen_curr_rate numeric NOT NULL, aropen_discount boolean DEFAULT false NOT NULL, aropen_fincharg_date date, aropen_fincharg_amount numeric(20,2) ); DROP TABLE public.aropen; publicadminfalse6035603660376038603960406041604260438&00 TABLE aropenCOMMENTOCOMMENT ON TABLE aropen IS 'Accounts Receivable (A/R) open Items information'; publicadminfalse195&00aropenACLREVOKE ALL ON TABLE aropen FROM PUBLIC; REVOKE ALL ON TABLE aropen FROM admin; GRANT ALL ON TABLE aropen TO admin; GRANT ALL ON TABLE aropen TO xtrole; publicadminfalse195125978786custinfoTABLECREATE TABLE custinfo ( cust_id integer DEFAULT nextval(('cust_cust_id_seq'::text)::regclass) NOT NULL, cust_active boolean NOT NULL, cust_custtype_id integer, cust_salesrep_id integer, cust_commprcnt numeric(10,6), cust_name text, cust_creditlmt integer, cust_creditrating text, cust_financecharge boolean, cust_backorder boolean NOT NULL, cust_partialship boolean NOT NULL, cust_terms_id integer, cust_discntprcnt numeric(10,6) NOT NULL, cust_balmethod character(1) NOT NULL, cust_ffshipto boolean NOT NULL, cust_shipform_id integer, cust_shipvia text, cust_blanketpos boolean NOT NULL, cust_shipchrg_id integer NOT NULL, cust_creditstatus character(1) NOT NULL, cust_comments text, cust_ffbillto boolean NOT NULL, cust_usespos boolean NOT NULL, cust_number text NOT NULL, cust_dateadded date DEFAULT ('now'::text)::date, cust_exported boolean DEFAULT false, cust_emaildelivery boolean DEFAULT false, cust_ediemail text, cust_edisubject text, cust_edifilename text, cust_ediemailbody text, cust_autoupdatestatus boolean NOT NULL, cust_autoholdorders boolean NOT NULL, cust_edicc text, cust_ediprofile_id integer, cust_preferred_warehous_id integer DEFAULT (-1) NOT NULL, cust_curr_id integer DEFAULT basecurrid(), cust_creditlmt_curr_id integer DEFAULT basecurrid(), cust_cntct_id integer, cust_corrcntct_id integer, cust_soemaildelivery boolean DEFAULT false, cust_soediemail text, cust_soedisubject text, cust_soedifilename text, cust_soediemailbody text, cust_soedicc text, cust_soediprofile_id integer, cust_gracedays integer, cust_ediemailhtml boolean DEFAULT false NOT NULL, cust_soediemailhtml boolean DEFAULT false NOT NULL, cust_taxzone_id integer, cust_statementcycle text, CONSTRAINT custinfo_balmethod_check CHECK (((cust_balmethod = 'B'::bpchar) OR (cust_balmethod = 'O'::bpchar))), CONSTRAINT custinfo_creditstatus_check CHECK ((((cust_creditstatus = 'G'::bpchar) OR (cust_creditstatus = 'W'::bpchar)) OR (cust_creditstatus = 'H'::bpchar))), CONSTRAINT custinfo_cust_number_check CHECK ((cust_number <> ''::text)) ); DROP TABLE public.custinfo; publicadminfalse60446045604660476048604960506051605260536054605560568 &00TABLE custinfoCOMMENT5COMMENT ON TABLE custinfo IS 'Customer information'; publicadminfalse196 &00COLUMN custinfo.cust_ediemailCOMMENTNCOMMENT ON COLUMN custinfo.cust_ediemail IS 'Deprecated column - DO NOT USE'; publicadminfalse196 &00COLUMN custinfo.cust_edisubjectCOMMENTPCOMMENT ON COLUMN custinfo.cust_edisubject IS 'Deprecated column - DO NOT USE'; publicadminfalse196 &00 COLUMN custinfo.cust_edifilenameCOMMENTQCOMMENT ON COLUMN custinfo.cust_edifilename IS 'Deprecated column - DO NOT USE'; publicadminfalse196 &00!COLUMN custinfo.cust_ediemailbodyCOMMENTRCOMMENT ON COLUMN custinfo.cust_ediemailbody IS 'Deprecated column - DO NOT USE'; publicadminfalse196&00COLUMN custinfo.cust_ediccCOMMENTKCOMMENT ON COLUMN custinfo.cust_edicc IS 'Deprecated column - DO NOT USE'; publicadminfalse196&00"COLUMN custinfo.cust_ediprofile_idCOMMENTSCOMMENT ON COLUMN custinfo.cust_ediprofile_id IS 'Deprecated column - DO NOT USE'; publicadminfalse196&00COLUMN custinfo.cust_soediemailCOMMENTPCOMMENT ON COLUMN custinfo.cust_soediemail IS 'Deprecated column - DO NOT USE'; publicadminfalse196&00!COLUMN custinfo.cust_soedisubjectCOMMENTRCOMMENT ON COLUMN custinfo.cust_soedisubject IS 'Deprecated column - DO NOT USE'; publicadminfalse196&00"COLUMN custinfo.cust_soedifilenameCOMMENTSCOMMENT ON COLUMN custinfo.cust_soedifilename IS 'Deprecated column - DO NOT USE'; publicadminfalse196&00#COLUMN custinfo.cust_soediemailbodyCOMMENTTCOMMENT ON COLUMN custinfo.cust_soediemailbody IS 'Deprecated column - DO NOT USE'; publicadminfalse196&00COLUMN custinfo.cust_soediccCOMMENTMCOMMENT ON COLUMN custinfo.cust_soedicc IS 'Deprecated column - DO NOT USE'; publicadminfalse196&00$COLUMN custinfo.cust_soediprofile_idCOMMENTUCOMMENT ON COLUMN custinfo.cust_soediprofile_id IS 'Deprecated column - DO NOT USE'; publicadminfalse196&00!COLUMN custinfo.cust_ediemailhtmlCOMMENTRCOMMENT ON COLUMN custinfo.cust_ediemailhtml IS 'Deprecated column - DO NOT USE'; publicadminfalse196&00#COLUMN custinfo.cust_soediemailhtmlCOMMENTTCOMMENT ON COLUMN custinfo.cust_soediemailhtml IS 'Deprecated column - DO NOT USE'; publicadminfalse196&00custinfoACLREVOKE ALL ON TABLE custinfo FROM PUBLIC; REVOKE ALL ON TABLE custinfo FROM admin; GRANT ALL ON TABLE custinfo TO admin; GRANT ALL ON TABLE custinfo TO xtrole; publicadminfalse196125978805rsncodeTABLECREATE TABLE rsncode ( rsncode_id integer NOT NULL, rsncode_code text NOT NULL, rsncode_descrip text, rsncode_doctype text, CONSTRAINT rsncode_rsncode_code_check CHECK ((rsncode_code <> ''::text)) ); DROP TABLE public.rsncode; publicadminfalse60588&00 TABLE rsncodeCOMMENTICOMMENT ON TABLE rsncode IS 'Debit/Credit Memo Reason Code information'; publicadminfalse197&00rsncodeACLREVOKE ALL ON TABLE rsncode FROM PUBLIC; REVOKE ALL ON TABLE rsncode FROM admin; GRANT ALL ON TABLE rsncode TO admin; GRANT ALL ON TABLE rsncode TO xtrole; publicadminfalse197125978812salescatTABLETCREATE TABLE salescat ( salescat_id integer NOT NULL, salescat_active boolean, salescat_name text NOT NULL, salescat_descrip text, salescat_sales_accnt_id integer, salescat_prepaid_accnt_id integer, salescat_ar_accnt_id integer, CONSTRAINT salescat_salescat_name_check CHECK ((salescat_name <> ''::text)) ); DROP TABLE public.salescat; publicadminfalse60608&00TABLE salescatCOMMENT;COMMENT ON TABLE salescat IS 'Sales Category information'; publicadminfalse198&00salescatACLREVOKE ALL ON TABLE salescat FROM PUBLIC; REVOKE ALL ON TABLE salescat FROM admin; GRANT ALL ON TABLE salescat TO admin; GRANT ALL ON TABLE salescat TO xtrole; publicadminfalse198125978819salesrepTABLECREATE TABLE salesrep ( salesrep_id integer DEFAULT nextval(('salesrep_salesrep_id_seq'::text)::regclass) NOT NULL, salesrep_active boolean, salesrep_number text NOT NULL, salesrep_name text, salesrep_commission numeric(8,4), salesrep_method character(1), salesrep_emp_id integer, CONSTRAINT salesrep_salesrep_number_check CHECK ((salesrep_number <> ''::text)) ); DROP TABLE public.salesrep; publicadminfalse606160628&00TABLE salesrepCOMMENTACOMMENT ON TABLE salesrep IS 'Sales Representative information'; publicadminfalse199&00COLUMN salesrep.salesrep_emp_idCOMMENTCOMMENT ON COLUMN salesrep.salesrep_emp_id IS 'DEPRECATED - the relationship between Sales Rep and Employee is now maintained through the crmacct table.'; publicadminfalse199&00salesrepACLREVOKE ALL ON TABLE salesrep FROM PUBLIC; REVOKE ALL ON TABLE salesrep FROM admin; GRANT ALL ON TABLE salesrep TO admin; GRANT ALL ON TABLE salesrep TO xtrole; publicadminfalse199125978827armemoVIEWCREATE VIEW armemo AS SELECT custinfo.cust_number AS customer_number, aropen.aropen_docdate AS document_date, aropen.aropen_duedate AS due_date, CASE WHEN (aropen.aropen_doctype = 'C'::bpchar) THEN 'Credit Memo'::text ELSE 'Debit Memo'::text END AS document_type, aropen.aropen_docnumber AS document_number, aropen.aropen_applyto AS order_number, aropen.aropen_journalnumber AS journal_number, rsncode.rsncode_code AS reason_code, terms.terms_code AS terms, salesrep.salesrep_number AS sales_rep, curr.curr_abbr AS currency, aropen.aropen_amount AS amount, aropen.aropen_paid AS paid, (aropen.aropen_amount - aropen.aropen_paid) AS balance, aropen.aropen_commission_due AS commission_due, aropen.aropen_commission_paid AS commission_paid, aropen.aropen_notes AS notes, salescat.salescat_name AS alternate_prepaid_sales_category, CASE WHEN (aropen.aropen_accnt_id = (-1)) THEN NULL::text ELSE public.formatglaccount(aropen.aropen_accnt_id) END AS alternate_prepaid_account FROM ((((((public.aropen LEFT JOIN public.custinfo ON ((custinfo.cust_id = aropen.aropen_cust_id))) LEFT JOIN public.curr_symbol curr ON ((curr.curr_id = aropen.aropen_curr_id))) LEFT JOIN public.salesrep ON ((salesrep.salesrep_id = aropen.aropen_salesrep_id))) LEFT JOIN public.terms ON ((terms.terms_id = aropen.aropen_terms_id))) LEFT JOIN public.salescat ON ((salescat.salescat_id = aropen.aropen_salescat_id))) LEFT JOIN public.rsncode ON ((rsncode.rsncode_id = aropen.aropen_rsncode_id))) WHERE (aropen.aropen_doctype = ANY (ARRAY['C'::bpchar, 'D'::bpchar])); DROP VIEW api.armemo; apiadminfalse86346 &00 VIEW armemoCOMMENT7COMMENT ON VIEW armemo IS 'A/R Credit and Debit Memo'; apiadminfalse200!&00armemoACLREVOKE ALL ON TABLE armemo FROM PUBLIC; REVOKE ALL ON TABLE armemo FROM admin; GRANT ALL ON TABLE armemo TO admin; GRANT ALL ON TABLE armemo TO xtrole; apiadminfalse200X 125578832insertarmemo(api.armemo)FUNCTION% CREATE FUNCTION insertarmemo(api.armemo) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNew ALIAS FOR $1; _result INTEGER; BEGIN IF (pNew.document_type = 'Credit Memo') THEN SELECT createARCreditMemo( NULL, getCustId(pNew.customer_number), pNew.document_number, pNew.order_number, pNew.document_date, pNew.amount, pNew.notes, getRsnId(pNew.reason_code), getSalescatId(pNew.alternate_prepaid_sales_category), getGLAccntId(pNew.alternate_prepaid_account), pNew.due_date, getTermsId(pNew.terms), getSalesrepId(pNew.sales_rep), pNew.commission_due, pNew.journal_number, COALESCE(getCurrId(pNew.currency), baseCurrId()) ) INTO _result; IF (_result <= 0) THEN RAISE EXCEPTION 'Function createARCreditMemo failed with result = %', _result; END IF; ELSE IF (pNew.document_type = 'Debit Memo') THEN SELECT createARDebitMemo( null, getCustId(pNew.customer_number), pNew.journal_number, pNew.document_number, pNew.order_number, pNew.document_date, pNew.amount, pNew.notes, getRsnId(pNew.reason_code), getSalescatId(pNew.alternate_prepaid_sales_category), getGLAccntId(pNew.alternate_prepaid_account), pNew.due_date, getTermsId(pNew.terms), getSalesrepId(pNew.sales_rep), pNew.commission_due, COALESCE(getCurrId(pNew.currency), baseCurrId()) ) INTO _result; IF (_result <= 0) THEN RAISE EXCEPTION 'Function createARDebitMemo failed with result = %', _result; END IF; ELSE RAISE EXCEPTION 'Function insertARMemo failed, invalid Document Type'; END IF; END IF; RETURN TRUE; END; $_$; /DROP FUNCTION public.insertarmemo(api.armemo); publicadminfalse828374623125578833linsertccard(text, boolean, text, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, text)FUNCTIONCREATE FUNCTION insertccard(text, boolean, text, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustomer ALIAS FOR $1; pActive ALIAS FOR $2; pType ALIAS FOR $3; pNumber ALIAS FOR $4; pName ALIAS FOR $5; pAddr1 ALIAS FOR $6; pAddr2 ALIAS FOR $7; pCity ALIAS FOR $8; pState ALIAS FOR $9; pPostal ALIAS FOR $10; pCountry ALIAS FOR $11; pMonth ALIAS FOR $12; pYear ALIAS FOR $13; pKey ALIAS FOR $14; _type CHAR; _number TEXT; _month INTEGER; _year INTEGER; _result INTEGER; BEGIN --Initialize _number = CAST(encode(pNumber, 'escape') AS text); _month = CAST(encode(pMonth, 'escape') AS integer); _year = CAST(encode(pYear, 'escape') AS integer); -- Check Card holder info IF (pName IS NULL) THEN RAISE EXCEPTION 'The name of the card holder must be entered'; END IF; IF (pAddr1 IS NULL OR pAddr1 = '') THEN RAISE EXCEPTION 'The first address line must be entered'; END IF; IF (pCity IS NULL OR pCity = '') THEN RAISE EXCEPTION 'The city must be entered'; END IF; IF (pState IS NULL OR pState = '') THEN RAISE EXCEPTION 'The state must be entered'; END IF; IF (pPostal IS NULL OR pPostal = '') THEN RAISE EXCEPTION 'The zip code must be entered'; END IF; IF (pCountry IS NULL OR pCountry = '') THEN RAISE EXCEPTION 'The country must be entered'; END IF; IF (pMonth IS NULL OR pMonth = '') THEN RAISE EXCEPTION 'The Expiration Month must be entered'; END IF; IF (_month < 1 OR _month > 12) THEN RAISE EXCEPTION 'Valid Expiration Months are 01 through 12'; END IF; IF (LENGTH(_year::text) <> 4) THEN RAISE EXCEPTION 'Valid Expiration Years are CCYY in format'; END IF; IF (_year < 1970 OR _year > 2100) THEN RAISE EXCEPTION 'Valid Expiration Years are 1970 through 2100'; END IF; -- Check Number Length IF ((NOT _number ~ '[0-9]{13,16}') OR (LENGTH(_number) = 14) OR (LENGTH(_number) > 16)) THEN RAISE EXCEPTION 'The credit card number must be all numeric (no spaces or hyphens) and must be 13, 15 or 16 characters in length'; END IF; -- Convert Type IF (pType = 'Visa') THEN _type = 'V'; ELSE IF (pType = 'Master Card') THEN _type = 'M'; ELSE IF (pType = 'American Express') THEN _type = 'A'; ELSE IF (pType = 'Discover') THEN _type = 'D'; ELSE RAISE EXCEPTION 'You must select Master Card, Visa, American Express or Discover as the credit card type.'; END IF; END IF; END IF; END IF; -- Check Card Specific Data SELECT editccnumber(_number, _type) INTO _result; IF (_result = -1) THEN RAISE EXCEPTION 'You must select Master Card, Visa, American Express or Discover as the credit card type.'; END IF; IF (_result = -2) THEN RAISE EXCEPTION 'The length of a Master Card credit card number has to be 16 digits.'; END IF; IF (_result = -3) THEN RAISE EXCEPTION 'The length of a Visa credit card number has to be either 13 or 16 digits.'; END IF; IF (_result = -4) THEN RAISE EXCEPTION 'The length of an American Express credit card number has to be 15 digits.'; END IF; IF (_result = -5) THEN RAISE EXCEPTION 'The length of a Discover credit card number has to be 16 digits.'; END IF; IF (_result = -6) THEN RAISE EXCEPTION 'The first two digits for a valid Master Card number must be between 51 and 55'; END IF; IF (_result = -7) THEN RAISE EXCEPTION 'The first digit for a valid Visa number must be 4'; END IF; IF (_result = -8) THEN RAISE EXCEPTION 'The first two digits for a valid American Express number must be 34 or 37.'; END IF; IF (_result = -9) THEN RAISE EXCEPTION 'The first four digits for a valid Discover Express number must be 6011.'; END IF; IF ((_result = -10) AND NOT fetchmetricbool('CCTest')) THEN RAISE EXCEPTION 'The credit card number that you have provided is not valid.'; END IF; IF (_result < -10) THEN RAISE EXCEPTION 'Invalid Credit Card Information'; END IF; -- Insert Record INSERT INTO ccard ( ccard_seq, ccard_cust_id, ccard_active, ccard_name, ccard_address1, ccard_address2, ccard_city, ccard_state, ccard_zip, ccard_country, ccard_number, ccard_month_expired, ccard_year_expired, ccard_type) VALUES ((SELECT COALESCE(MAX(ccard_seq), 0) + 10 FROM ccard WHERE (ccard_cust_id =getCustId(pCustomer))), getCustId(pCustomer), COALESCE(pActive), encrypt(setbytea(pName), setbytea(pKey), 'bf'), encrypt(setbytea(pAddr1), setbytea(pKey), 'bf'), encrypt(setbytea(pAddr2), setbytea(pKey), 'bf'), encrypt(setbytea(pCity), setbytea(pKey), 'bf'), encrypt(setbytea(pState), setbytea(pKey), 'bf'), encrypt(setbytea(pPostal), setbytea(pKey), 'bf'), encrypt(setbytea(pCountry), setbytea(pKey), 'bf'), encrypt(setbytea(pNumber), setbytea(pKey), 'bf'), encrypt(setbytea(pMonth), setbytea(pKey), 'bf'), encrypt(setbytea(pYear), setbytea(pKey), 'bf'), _type ); RETURN true; END; $_$; DROP FUNCTION public.insertccard(text, boolean, text, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, text); publicadminfalse46238"&00uFUNCTION insertccard(text, boolean, text, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, text)COMMENTCOMMENT ON FUNCTION insertccard(text, boolean, text, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, bytea, text) IS 'This function is generally used to support the _custcreditcard API view'; publicadminfalse1722125978835cmheadTABLECREATE TABLE cmhead ( cmhead_id integer DEFAULT nextval(('cmhead_cmhead_id_seq'::text)::regclass) NOT NULL, cmhead_number text NOT NULL, cmhead_posted boolean, cmhead_invcnumber text, cmhead_custponumber text, cmhead_cust_id integer, cmhead_docdate date, cmhead_shipto_id integer, cmhead_shipto_name text, cmhead_shipto_address1 text, cmhead_shipto_address2 text, cmhead_shipto_address3 text, cmhead_shipto_city text, cmhead_shipto_state text, cmhead_shipto_zipcode text, cmhead_salesrep_id integer, cmhead_freight numeric(16,4), cmhead_misc numeric(16,4), cmhead_comments text, cmhead_printed boolean, cmhead_billtoname text, cmhead_billtoaddress1 text, cmhead_billtoaddress2 text, cmhead_billtoaddress3 text, cmhead_billtocity text, cmhead_billtostate text, cmhead_billtozip text, cmhead_hold boolean, cmhead_commission numeric(8,4), cmhead_misc_accnt_id integer, cmhead_misc_descrip text, cmhead_rsncode_id integer, cmhead_curr_id integer DEFAULT basecurrid(), cmhead_freighttaxtype_id integer, cmhead_gldistdate date, cmhead_billtocountry text, cmhead_shipto_country text, cmhead_rahead_id integer, cmhead_taxzone_id integer, cmhead_prj_id integer, cmhead_void boolean DEFAULT false, cmhead_saletype_id integer, cmhead_shipzone_id integer, CONSTRAINT cmhead_cmhead_number_check CHECK ((cmhead_number <> ''::text)) ); DROP TABLE public.cmhead; publicadminfalse60636064606560668#&00 TABLE cmheadCOMMENTACOMMENT ON TABLE cmhead IS 'S/O Credit Memo header information'; publicadminfalse201$&00&COLUMN cmhead.cmhead_freighttaxtype_idCOMMENTWCOMMENT ON COLUMN cmhead.cmhead_freighttaxtype_id IS 'Deprecated column - DO NOT USE'; publicadminfalse201%&00 COLUMN cmhead.cmhead_saletype_idCOMMENTXCOMMENT ON COLUMN cmhead.cmhead_saletype_id IS 'Associated sale type for credit memo.'; publicadminfalse201&&00 COLUMN cmhead.cmhead_shipzone_idCOMMENT\COMMENT ON COLUMN cmhead.cmhead_shipzone_id IS 'Associated shipping zone for credit memo.'; publicadminfalse201'&00cmheadACLREVOKE ALL ON TABLE cmhead FROM PUBLIC; REVOKE ALL ON TABLE cmhead FROM admin; GRANT ALL ON TABLE cmhead TO admin; GRANT ALL ON TABLE cmhead TO xtrole; publicadminfalse201125978845 shiptoinfoTABLECREATE TABLE shiptoinfo ( shipto_id integer DEFAULT nextval(('shipto_shipto_id_seq'::text)::regclass) NOT NULL, shipto_cust_id integer NOT NULL, shipto_name text, shipto_salesrep_id integer, shipto_comments text, shipto_shipcomments text, shipto_shipzone_id integer, shipto_shipvia text, shipto_commission numeric(10,4) NOT NULL, shipto_shipform_id integer, shipto_shipchrg_id integer, shipto_active boolean NOT NULL, shipto_default boolean, shipto_num text, shipto_ediprofile_id integer, shipto_cntct_id integer, shipto_addr_id integer, shipto_taxzone_id integer, shipto_preferred_warehous_id integer DEFAULT (-1) NOT NULL ); DROP TABLE public.shiptoinfo; publicadminfalse606760688(&00TABLE shiptoinfoCOMMENT6COMMENT ON TABLE shiptoinfo IS 'Ship-To information'; publicadminfalse202)&00&COLUMN shiptoinfo.shipto_ediprofile_idCOMMENTWCOMMENT ON COLUMN shiptoinfo.shipto_ediprofile_id IS 'Deprecated column - DO NOT USE'; publicadminfalse202*&00 shiptoinfoACLREVOKE ALL ON TABLE shiptoinfo FROM PUBLIC; REVOKE ALL ON TABLE shiptoinfo FROM admin; GRANT ALL ON TABLE shiptoinfo TO admin; GRANT ALL ON TABLE shiptoinfo TO xtrole; publicadminfalse202125978853taxzoneTABLECREATE TABLE taxzone ( taxzone_id integer NOT NULL, taxzone_code text NOT NULL, taxzone_descrip text, CONSTRAINT taxzone_taxzone_code_check CHECK ((taxzone_code <> ''::text)) ); DROP TABLE public.taxzone; publicadminfalse60708+&00 TABLE taxzoneCOMMENT4COMMENT ON TABLE taxzone IS 'Tax zone information'; publicadminfalse203,&00COLUMN taxzone.taxzone_idCOMMENT7COMMENT ON COLUMN taxzone.taxzone_id IS 'Primary key'; publicadminfalse203-&00COLUMN taxzone.taxzone_codeCOMMENT2COMMENT ON COLUMN taxzone.taxzone_code IS 'Code'; publicadminfalse203.&00COLUMN taxzone.taxzone_descripCOMMENT<COMMENT ON COLUMN taxzone.taxzone_descrip IS 'Description'; publicadminfalse203/&00taxzoneACLREVOKE ALL ON TABLE taxzone FROM PUBLIC; REVOKE ALL ON TABLE taxzone FROM admin; GRANT ALL ON TABLE taxzone TO admin; GRANT ALL ON TABLE taxzone TO xtrole; publicadminfalse2038125987812 creditmemoVIEWCREATE VIEW creditmemo AS SELECT cmhead.cmhead_number AS memo_number, CASE WHEN (cmhead.cmhead_invcnumber = '-1'::text) THEN ''::text ELSE cmhead.cmhead_invcnumber END AS apply_to, cmhead.cmhead_docdate AS memo_date, CASE WHEN cmhead.cmhead_posted THEN 'Posted'::text ELSE 'Unposted'::text END AS status, salesrep.salesrep_number AS sales_rep, cmhead.cmhead_commission AS commission, COALESCE(taxzone.taxzone_code, 'None'::text) AS tax_zone, COALESCE(rsncode.rsncode_code, 'None'::text) AS reason_code, cmhead.cmhead_hold AS on_hold, custinfo.cust_number AS customer_number, cmhead.cmhead_billtoname AS billto_name, cmhead.cmhead_billtoaddress1 AS billto_address1, cmhead.cmhead_billtoaddress2 AS billto_address2, cmhead.cmhead_billtoaddress3 AS billto_address3, cmhead.cmhead_billtocity AS billto_city, cmhead.cmhead_billtostate AS billto_state, cmhead.cmhead_billtozip AS billto_postal_code, cmhead.cmhead_billtocountry AS billto_country, shiptoinfo.shipto_num AS shipto_number, cmhead.cmhead_shipto_name AS shipto_name, cmhead.cmhead_shipto_address1 AS shipto_address1, cmhead.cmhead_shipto_address2 AS shipto_address2, cmhead.cmhead_shipto_address3 AS shipto_address3, cmhead.cmhead_shipto_city AS shipto_city, cmhead.cmhead_shipto_state AS shipto_state, cmhead.cmhead_shipto_zipcode AS shipto_postal_code, cmhead.cmhead_shipto_country AS shipto_country, cmhead.cmhead_custponumber AS customer_po_number, cmhead.cmhead_comments AS notes, curr.curr_abbr AS currency, cmhead.cmhead_misc_descrip AS misc_charge_description, cmhead.cmhead_misc AS misc_charge_amount, CASE WHEN (cmhead.cmhead_misc_accnt_id = (-1)) THEN ''::text ELSE public.formatglaccount(cmhead.cmhead_misc_accnt_id) END AS misc_charge_credit_account, cmhead.cmhead_freight AS freight FROM ((((((public.cmhead LEFT JOIN public.custinfo ON ((custinfo.cust_id = cmhead.cmhead_cust_id))) LEFT JOIN public.shiptoinfo ON ((shiptoinfo.shipto_id = cmhead.cmhead_shipto_id))) LEFT JOIN public.curr_symbol curr ON ((curr.curr_id = cmhead.cmhead_curr_id))) LEFT JOIN public.salesrep ON ((salesrep.salesrep_id = cmhead.cmhead_salesrep_id))) LEFT JOIN public.taxzone ON ((taxzone.taxzone_id = cmhead.cmhead_taxzone_id))) LEFT JOIN public.rsncode ON ((rsncode.rsncode_id = cmhead.cmhead_rsncode_id))); DROP VIEW api.creditmemo; apiadminfalse876760&00VIEW creditmemoCOMMENT4COMMENT ON VIEW creditmemo IS 'Credit Memo Header'; apiadminfalse8241&00 creditmemoACLREVOKE ALL ON TABLE creditmemo FROM PUBLIC; REVOKE ALL ON TABLE creditmemo FROM admin; GRANT ALL ON TABLE creditmemo TO admin; GRANT ALL ON TABLE creditmemo TO xtrole; apiadminfalse824Y 125587817 insertcreditmemo(api.creditmemo)FUNCTIONCREATE FUNCTION insertcreditmemo(api.creditmemo) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNew ALIAS FOR $1; BEGIN -- NOTE: (SELECT getCustId(...)) seems redundant, but it actually produces -- a HUGE performance increase because it makes the Postgres query planner -- use an index scan rather than an sequential table scan on cust_id INSERT INTO cmhead ( cmhead_number, cmhead_posted, cmhead_invcnumber, cmhead_custponumber, cmhead_cust_id, cmhead_docdate, cmhead_shipto_id, cmhead_shipto_name, cmhead_shipto_address1, cmhead_shipto_address2, cmhead_shipto_address3, cmhead_shipto_city, cmhead_shipto_state, cmhead_shipto_zipcode, cmhead_shipto_country, cmhead_salesrep_id, cmhead_freight, cmhead_misc, cmhead_comments, cmhead_printed, cmhead_billtoname, cmhead_billtoaddress1, cmhead_billtoaddress2, cmhead_billtoaddress3, cmhead_billtocity, cmhead_billtostate, cmhead_billtozip, cmhead_billtocountry, cmhead_hold, cmhead_commission, cmhead_misc_accnt_id, cmhead_misc_descrip, cmhead_rsncode_id, cmhead_curr_id, cmhead_taxzone_id, cmhead_gldistdate, cmhead_rahead_id ) SELECT (CASE -- use a case here so we don't unnecessarily fetch a new CM number WHEN pNew.memo_number IS NULL THEN fetchCMNumber() ELSE pNew.memo_number END), FALSE, -- posted pNew.apply_to, pNew.customer_po_number, cust_id, COALESCE(pNew.memo_date, CURRENT_DATE), COALESCE(shipto_id,-1), pNew.shipto_name, pNew.shipto_address1, pNew.shipto_address2, pNew.shipto_address3, pNew.shipto_city, pNew.shipto_state, pNew.shipto_postal_code, pNew.shipto_country, COALESCE(getSalesRepId(pNew.sales_rep),shipto_salesrep_id,cust_salesrep_id), COALESCE(pNew.freight, 0), COALESCE(pNew.misc_charge_amount, 0), pNew.notes, FALSE, -- printed COALESCE(pNew.billto_name, invchead_billto_name, cust_name), COALESCE(pNew.billto_address1, invchead_billto_address1, addr_line1), COALESCE(pNew.billto_address2, invchead_billto_address2, addr_line2), COALESCE(pNew.billto_address3, invchead_billto_address3, addr_line3), COALESCE(pNew.billto_city, invchead_billto_city, addr_city), COALESCE(pNew.billto_state, invchead_billto_state, addr_state), COALESCE(pNew.billto_postal_code, invchead_billto_zipcode, addr_postalcode), COALESCE(pNew.billto_country, invchead_billto_country, addr_country), COALESCE(pNew.on_hold, FALSE), COALESCE(pNew.commission, 0), COALESCE(getGlAccntId(pNew.misc_charge_credit_account),-1), pNew.misc_charge_description, (SELECT rsncode_id FROM rsncode WHERE rsncode_code = pNew.reason_code), COALESCE(getCurrId(pNew.currency),cust_curr_id,basecurrid()), CASE WHEN pNew.tax_zone = 'None' THEN NULL ELSE COALESCE(getTaxZoneID(pNew.tax_zone),cust_taxzone_id) END, NULL, NULL FROM custinfo LEFT OUTER JOIN shiptoinfo ON (shipto_id=(SELECT CASE WHEN getShiptoId(pNew.customer_number,pNew.shipto_number) IS NOT NULL THEN getShiptoId(pNew.customer_number,pNew.shipto_number) ELSE (SELECT shipto_id FROM shiptoinfo WHERE shipto_cust_id=cust_id AND shipto_default) END)) LEFT OUTER JOIN invchead ON (invchead_id=getInvcheadId(pNEW.apply_to)) LEFT OUTER JOIN cntct ON (cntct_id=cust_cntct_id) LEFT OUTER JOIN addr ON (addr_id=cntct_addr_id) WHERE cust_id = (CASE WHEN pNew.customer_number IS NOT NULL THEN (SELECT getCustId(pNew.customer_number)) ELSE (SELECT invchead_cust_id FROM invchead WHERE invchead_invcnumber = pNew.apply_to) END); RETURN TRUE; END; $_$; 7DROP FUNCTION public.insertcreditmemo(api.creditmemo); publicadminfalse440046238125978866cmitemTABLECREATE TABLE cmitem ( cmitem_id integer DEFAULT nextval(('cmitem_cmitem_id_seq'::text)::regclass) NOT NULL, cmitem_cmhead_id integer NOT NULL, cmitem_linenumber integer NOT NULL, cmitem_itemsite_id integer NOT NULL, cmitem_qtycredit numeric(18,6) NOT NULL, cmitem_qtyreturned numeric(18,6) NOT NULL, cmitem_unitprice numeric(16,4) NOT NULL, cmitem_comments text, cmitem_rsncode_id integer, cmitem_taxtype_id integer, cmitem_qty_uom_id integer NOT NULL, cmitem_qty_invuomratio numeric(20,10) NOT NULL, cmitem_price_uom_id integer NOT NULL, cmitem_price_invuomratio numeric(20,10) NOT NULL, cmitem_raitem_id integer, cmitem_updateinv boolean DEFAULT true NOT NULL ); DROP TABLE public.cmitem; publicadminfalse6071607282&00 TABLE cmitemCOMMENTDCOMMENT ON TABLE cmitem IS 'S/O Credit Memo Line Item information'; publicadminfalse2043&00cmitemACLREVOKE ALL ON TABLE cmitem FROM PUBLIC; REVOKE ALL ON TABLE cmitem FROM admin; GRANT ALL ON TABLE cmitem TO admin; GRANT ALL ON TABLE cmitem TO xtrole; publicadminfalse2049125987822creditmemolineVIEWCREATE VIEW creditmemoline AS SELECT cmhead.cmhead_number AS memo_number, cmitem.cmitem_linenumber AS line_number, item.item_number, whsinfo.warehous_code AS recv_site, rsncode.rsncode_code AS reason_code, cmitem.cmitem_qtyreturned AS qty_returned, cmitem.cmitem_qtycredit AS qty_to_credit, COALESCE(qty_uom.uom_name, 'None'::text) AS qty_uom, cmitem.cmitem_unitprice AS net_unit_price, COALESCE(price_uom.uom_name, 'None'::text) AS price_uom, COALESCE(taxtype.taxtype_name, 'None'::text) AS tax_type, cmitem.cmitem_comments AS notes FROM ((((((((public.cmitem LEFT JOIN public.cmhead ON ((cmitem.cmitem_cmhead_id = cmhead.cmhead_id))) LEFT JOIN public.itemsite ON ((itemsite.itemsite_id = cmitem.cmitem_itemsite_id))) LEFT JOIN public.item ON ((item.item_id = itemsite.itemsite_item_id))) LEFT JOIN public.whsinfo ON ((whsinfo.warehous_id = itemsite.itemsite_warehous_id))) LEFT JOIN public.rsncode ON ((rsncode.rsncode_id = cmitem.cmitem_rsncode_id))) LEFT JOIN public.taxtype ON ((taxtype.taxtype_id = cmitem.cmitem_taxtype_id))) LEFT JOIN public.uom qty_uom ON ((qty_uom.uom_id = cmitem.cmitem_qty_uom_id))) LEFT JOIN public.uom price_uom ON ((price_uom.uom_id = cmitem.cmitem_price_uom_id))); DROP VIEW api.creditmemoline; apiadminfalse877164&00VIEW creditmemolineCOMMENT6COMMENT ON VIEW creditmemoline IS 'Credit Memo Line'; apiadminfalse8255&00creditmemolineACLREVOKE ALL ON TABLE creditmemoline FROM PUBLIC; REVOKE ALL ON TABLE creditmemoline FROM admin; GRANT ALL ON TABLE creditmemoline TO admin; GRANT ALL ON TABLE creditmemoline TO xtrole; apiadminfalse825Z 125587827(insertcreditmemoline(api.creditmemoline)FUNCTIONY CREATE FUNCTION insertcreditmemoline(api.creditmemoline) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNew ALIAS FOR $1; _check INTEGER; _r RECORD; BEGIN SELECT cmhead_id INTO _check FROM cmhead WHERE (cmhead_id=getCmheadId(pNew.memo_number, FALSE)); IF (NOT FOUND) THEN RAISE EXCEPTION 'Credit Memo # % not found', pNew.memo_number; END IF; INSERT INTO cmitem ( cmitem_cmhead_id, cmitem_linenumber, cmitem_itemsite_id, cmitem_qtycredit, cmitem_qtyreturned, cmitem_unitprice, cmitem_comments, cmitem_rsncode_id, cmitem_taxtype_id, cmitem_qty_uom_id, cmitem_qty_invuomratio, cmitem_price_uom_id, cmitem_price_invuomratio ) SELECT cmhead_id, COALESCE(pNew.line_number, (SELECT (COALESCE(MAX(cmitem_linenumber), 0) + 1) FROM cmitem WHERE (cmitem_cmhead_id=cmhead_id))), COALESCE(itemsite_id, -1), COALESCE(pNew.qty_to_credit, 0), COALESCE(pNew.qty_returned, 0), COALESCE(pNew.net_unit_price, 0), pNew.notes, getRsnId(pNew.reason_code), taxtype_id, COALESCE(getUomId(pNew.qty_uom), item_inv_uom_id), CASE WHEN item_id IS NOT NULL THEN itemuomtouomratio(item_id, COALESCE(getUomId(pNew.qty_uom),item_inv_uom_id),item_inv_uom_id) ELSE 1 END, COALESCE(getUomId(pNew.price_uom),item_price_uom_id), CASE WHEN item_id IS NOT NULL THEN itemuomtouomratio(item_id, COALESCE(getUomId(pNew.price_uom),item_price_uom_id),item_price_uom_id) ELSE 1 END FROM cmhead LEFT OUTER JOIN item ON (item_id=getItemId(pNew.item_number)) LEFT OUTER JOIN itemsite ON (itemsite_item_id=item_id AND itemsite_warehous_id=getWarehousId(pNew.recv_site, 'ALL')) LEFT OUTER JOIN taxtype ON (taxtype_id=CASE WHEN pNew.tax_type IS NULL THEN getItemTaxType(item_id,cmhead_taxzone_id) WHEN pNew.tax_type = 'None' THEN NULL ELSE getTaxTypeId(pNew.tax_type) END) WHERE (cmhead_id=getCmheadId(pNew.memo_number, FALSE)); RETURN TRUE; END; $_$; ?DROP FUNCTION public.insertcreditmemoline(api.creditmemoline); publicadminfalse844034623125587044Ninsertflgroup(integer, integer, integer, integer, boolean, character, integer)FUNCTIONT`CREATE FUNCTION insertflgroup(pflheadid integer, pperiodid integer, pflgrpid integer, plevel integer, psummarize boolean, pinterval character DEFAULT NULL::bpchar, pprjid integer DEFAULT NULL::integer) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. /* see the "performance vs. history" comment in financialreport() */ DECLARE _subtotal BOOLEAN; _r RECORD; _g RECORD; _all BOOLEAN; _username TEXT := getEffectiveXtUser(); BEGIN _all = COALESCE(pPrjid,-1) = -1; -- Check to see if this group wants a subtotal _subtotal := FALSE; IF (pFlgrpid != -1) THEN SELECT COALESCE(flgrp_subtotal, FALSE) INTO _subtotal FROM flgrp WHERE ((flgrp_flhead_id=pFlheadid) AND (flgrp_id=pFlgrpid)); END IF; FOR _r IN SELECT 'G' AS type, flgrp_id AS type_id, flgrp_order AS orderby, flgrp_summarize AS summarize, flgrp_subtract AS subtract, CASE WHEN(flgrp_summarize AND (NOT flgrp_showstart)) THEN NULL ELSE 0.00 END AS beginning, CASE WHEN(flgrp_summarize AND (NOT flgrp_showend)) THEN NULL ELSE 0.00 END AS ending, CASE WHEN(flgrp_summarize AND (NOT flgrp_showdelta)) THEN NULL ELSE 0.00 END AS debits, CASE WHEN(flgrp_summarize AND (NOT flgrp_showdelta)) THEN NULL ELSE 0.00 END AS credits, CASE WHEN(flgrp_summarize AND (NOT flgrp_showbudget)) THEN NULL ELSE 0.00 END AS budget, CASE WHEN(flgrp_summarize AND (NOT flgrp_showdiff)) THEN NULL ELSE 0.00 END AS diff, CASE WHEN(flgrp_summarize AND (NOT flgrp_showcustom)) THEN NULL ELSE 0.00 END AS custom, CASE WHEN(flgrp_showstartprcnt) THEN 0.00 ELSE NULL END AS beginningprcnt, CASE WHEN(flgrp_showendprcnt) THEN 0.00 ELSE NULL END AS endingprcnt, CASE WHEN(flgrp_showdeltaprcnt) THEN 0.00 ELSE NULL END AS debitsprcnt, CASE WHEN(flgrp_showdeltaprcnt) THEN 0.00 ELSE NULL END AS creditsprcnt, CASE WHEN(flgrp_showbudgetprcnt) THEN 0.00 ELSE NULL END AS budgetprcnt, CASE WHEN(flgrp_showdiffprcnt) THEN 0.00 ELSE NULL END AS diffprcnt, CASE WHEN(flgrp_showcustomprcnt) THEN 0.00 ELSE NULL END AS customprcnt, -1 AS accnt_id, '' AS accnt_number FROM flgrp WHERE ((flgrp_flgrp_id=pFlgrpid) AND (flgrp_flhead_id=pFlheadid)) UNION ALL SELECT 'I' AS type, flitem_id AS type_id, flitem_order AS orderby, FALSE AS summarize, flitem_subtract AS subtract, CASE WHEN (flitem_showstart AND (first_trialbal_id IS NULL)) THEN 0.00 WHEN (flitem_showstart) THEN normalizeTrialBal(first_trialbal_id, 'B') ELSE NULL END AS beginning, CASE WHEN (flitem_showend AND (last_trialbal_id IS NULL)) THEN 0.00 WHEN (flitem_showend) THEN normalizeTrialBal(last_trialbal_id, 'E') ELSE NULL END AS ending, CASE WHEN (flitem_showdelta) THEN sum_trialbal_debits ELSE NULL END AS debits, CASE WHEN (flitem_showdelta) THEN sum_trialbal_credits ELSE NULL END AS credits, CASE WHEN ((flitem_showbudget) AND (accnt_type IN ('R','E')) AND flhead_type IN ('I','C','A')) THEN COALESCE(sum_budget_amount,0) WHEN ((flitem_showbudget) AND (accnt_type IN ('R','E')) AND flhead_type = 'B' ) THEN (SELECT COALESCE(SUM(b.budget_amount),0) FROM budget b, (SELECT ytd.period_id AS ytd_period_id FROM period cp, period ytd WHERE ((cp.period_id = last_flitem_period_id) AND (ytd.period_start <= cp.period_start) AND (ytd.period_yearperiod_id = cp.period_yearperiod_id))) AS periods WHERE ((b.budget_accnt_id=accnt_id) AND (b.budget_period_id=ytd_period_id))) WHEN ((flitem_showbudget) AND (accnt_type IN ('A','L','Q')) AND flhead_type = 'C') THEN calccashbudget(accnt_id,last_flitem_period_id,pInterval) ELSE COALESCE(last_budget_amount,0) END AS budget, CASE WHEN (flitem_showdiff AND (first_trialbal_id IS NULL)) THEN 0.00 WHEN (flitem_showdiff) THEN COALESCE(normalizeTrialBal(last_trialbal_id, 'E') - normalizeTrialBal(first_trialbal_id, 'B'), 0.00) ELSE NULL END AS diff, CASE WHEN (NOT flitem_showcustom) THEN NULL WHEN (flitem_custom_source='S' AND (first_trialbal_id IS NOT NULL)) THEN normalizeTrialBal(first_trialbal_id, 'B') WHEN (flitem_custom_source='E' AND (first_trialbal_id IS NOT NULL)) THEN normalizeTrialBal(last_trialbal_id, 'E') WHEN (flitem_custom_source='D') THEN sum_trialbal_debits WHEN (flitem_custom_source='C') THEN sum_trialbal_credits WHEN (flitem_custom_source='B') THEN ( CASE WHEN (accnt_type IN ('R','E')) THEN sum_budget_amount ELSE last_budget_amount END) WHEN (flitem_custom_source='F' AND (first_trialbal_id IS NOT NULL)) THEN COALESCE(normalizeTrialBal(last_trialbal_id, 'E') - normalizeTrialBal(first_trialbal_id, 'B'), 0.00) ELSE 0.00 END AS custom, CASE WHEN(flitem_showstartprcnt) THEN 0.00 ELSE NULL END AS beginningprcnt, CASE WHEN(flitem_showendprcnt) THEN 0.00 ELSE NULL END AS endingprcnt, CASE WHEN(flitem_showdeltaprcnt) THEN 0.00 ELSE NULL END AS debitsprcnt, CASE WHEN(flitem_showdeltaprcnt) THEN 0.00 ELSE NULL END AS creditsprcnt, CASE WHEN(flitem_showbudgetprcnt) THEN 0.00 ELSE NULL END AS budgetprcnt, CASE WHEN(flitem_showdiffprcnt) THEN 0.00 ELSE NULL END AS diffprcnt, CASE WHEN(flitem_showcustomprcnt) THEN 0.00 ELSE NULL END AS customprcnt, accnt_id, public.formatglaccount(accnt_id) AS accnt_number FROM (SELECT flhead_type,flitem_id,flitem_order,flitem_subtract,flitem_showstart,flitem_showend, flitem_showdelta,flitem_showbudget,flitem_showdiff,flitem_showcustom, flitem_custom_source,flitem_showstartprcnt,flitem_showendprcnt,flitem_showdeltaprcnt, flitem_showbudgetprcnt,flitem_showdiffprcnt,flitem_showcustomprcnt, accnt_id,accnt_type, FIRST(trialbal_id) AS first_trialbal_id, LAST(trialbal_id) AS last_trialbal_id, SUM(trialbal_debits) AS sum_trialbal_debits, SUM(trialbal_credits) AS sum_trialbal_credits, LAST(flitem_period_id) AS last_flitem_period_id, SUM(budget_amount) AS sum_budget_amount, LAST(budget_amount) AS last_budget_amount FROM (SELECT period_id AS flitem_period_id, period_start,flhead_type,flitem_id,flitem_order,flitem_subtract,flitem_showstart,flitem_showend, flitem_showdelta,flitem_showbudget,flitem_showdiff,flitem_showcustom, flitem_custom_source,flitem_showstartprcnt,flitem_showendprcnt,flitem_showdeltaprcnt, flitem_showbudgetprcnt,flitem_showdiffprcnt,flitem_showcustomprcnt, accnt_id,accnt_type,COALESCE(trialbal_id,getlasttrialbalid(accnt_id,period_id)) as trialbal_id,COALESCE(trialbal_debits,0) as trialbal_debits, COALESCE(trialbal_credits,0) AS trialbal_credits,COALESCE(budget_amount,0) AS budget_amount FROM (SELECT period_id, period_start, flhead_type, flitem_id,flitem_order,flitem_subtract,flitem_showstart,flitem_showend, flitem_showdelta,flitem_showbudget,flitem_showdiff,flitem_showcustom,flitem_custom_source,flitem_showstartprcnt, flitem_showendprcnt,flitem_showdeltaprcnt,flitem_showbudgetprcnt,flitem_showdiffprcnt,flitem_showcustomprcnt, accnt_id, accnt_type FROM period,flaccnt WHERE ((flitem_flhead_id=pFlheadid) AND (flitem_flgrp_id=pFlgrpid) AND (_all OR prj_id=pPrjId) AND (period_id IN (SELECT * FROM getperiodid(pPeriodId,pInterval)))) ORDER BY flitem_id ) AS flitem LEFT OUTER JOIN trialbal ON ((trialbal_accnt_id=accnt_id) AND (trialbal_period_id=period_id)) LEFT OUTER JOIN budget ON ((budget_accnt_id=accnt_id) AND (budget_period_id=period_id)) ORDER BY accnt_id, period_start) AS data GROUP BY flhead_type,flitem_id,flitem_order,flitem_subtract,flitem_showstart,flitem_showend, flitem_showdelta,flitem_showbudget,flitem_showdiff,flitem_showcustom, flitem_custom_source,flitem_showstartprcnt,flitem_showendprcnt,flitem_showdeltaprcnt, flitem_showbudgetprcnt,flitem_showdiffprcnt,flitem_showcustomprcnt,accnt_id,accnt_type) AS agg UNION ALL SELECT 'S' AS type, flspec_id AS type_id, flspec_order AS orderby, FALSE AS summarize, flspec_subtract AS subtract, CASE WHEN (flspec_showstart) THEN findSpecialFinancial('S', flspec_type, pPeriodid) ELSE NULL END AS beginning, CASE WHEN (flspec_showend) THEN findSpecialFinancial('E', flspec_type, pPeriodid) ELSE NULL END AS ending, CASE WHEN (flspec_showdelta) THEN findSpecialFinancial('D', flspec_type, pPeriodid) ELSE NULL END AS debits, CASE WHEN (flspec_showdelta) THEN findSpecialFinancial('C', flspec_type, pPeriodid) ELSE NULL END AS credits, CASE WHEN (flspec_showbudget) THEN findSpecialFinancial('B', flspec_type, pPeriodid) ELSE NULL END AS budget, CASE WHEN (flspec_showdiff) THEN findSpecialFinancial('E', flspec_type, pPeriodid) - findSpecialFinancial('S', flspec_type, pPeriodid) ELSE NULL END AS diff, CASE WHEN (NOT flspec_showcustom) THEN NULL WHEN (flspec_custom_source='F') THEN findSpecialFinancial('E', flspec_type, pPeriodid) - findSpecialFinancial('S', flspec_type, pPeriodid) WHEN (flspec_custom_source IN ('S', 'E', 'D', 'C', 'B')) THEN findSpecialFinancial(flspec_custom_source, flspec_type, pPeriodid) ELSE 0.00 END AS custom, CASE WHEN(flspec_showstartprcnt) THEN 0.00 ELSE NULL END AS beginningprcnt, CASE WHEN(flspec_showendprcnt) THEN 0.00 ELSE NULL END AS endingprcnt, CASE WHEN(flspec_showdeltaprcnt) THEN 0.00 ELSE NULL END AS debitsprcnt, CASE WHEN(flspec_showdeltaprcnt) THEN 0.00 ELSE NULL END AS creditsprcnt, CASE WHEN(flspec_showbudgetprcnt) THEN 0.00 ELSE NULL END AS budgetprcnt, CASE WHEN(flspec_showdiffprcnt) THEN 0.00 ELSE NULL END AS diffprcnt, CASE WHEN(flspec_showcustomprcnt) THEN 0.00 ELSE NULL END AS customprcnt, -1 AS accnt_id, '' AS accnt_number FROM flspec WHERE ((flspec_flgrp_id=pFlgrpid) AND (flspec_flhead_id=pFlheadid)) ORDER BY orderby, accnt_number LOOP IF (_r.type = 'G') THEN -- Create a record for the items sub items to be attached to and be able to update the total INSERT INTO flrpt (flrpt_flhead_id, flrpt_period_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_beginning, flrpt_ending, flrpt_debits, flrpt_credits, flrpt_budget, flrpt_diff, flrpt_custom, flrpt_beginningprcnt, flrpt_endingprcnt, flrpt_debitsprcnt, flrpt_creditsprcnt, flrpt_budgetprcnt, flrpt_diffprcnt, flrpt_customprcnt, flrpt_parent_id, flrpt_interval) VALUES (pFlheadid, pPeriodid, _username, (COALESCE(( SELECT MAX(flrpt_order) FROM flrpt WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) -- AND (flrpt_username=_username) ) ), 1) + 1), pLevel, _r.type, _r.type_id, _r.beginning, _r.ending, _r.debits, _r.credits, _r.budget, _r.diff, _r.custom, _r.beginningprcnt, _r.endingprcnt, _r.debitsprcnt, _r.creditsprcnt, _r.budgetprcnt, _r.diffprcnt, _r.customprcnt, pFlgrpid, pInterval); PERFORM insertFlGroup(pFlheadid, pPeriodid, _r.type_id, (pLevel + 1), (pSummarize OR _r.summarize), pInterval, pPrjid); -- Update the parent item SELECT COALESCE(flrpt_beginning, 0.00) AS beginning, COALESCE(flrpt_ending, 0.00) AS ending, COALESCE(flrpt_debits, 0.00) AS debits, COALESCE(flrpt_credits, 0.00) AS credits, COALESCE(flrpt_budget, 0.00) AS budget, COALESCE(flrpt_diff, 0.00) AS diff, COALESCE(flrpt_custom, 0.00) AS custom INTO _g FROM flrpt WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) -- AND (flrpt_username=_username) AND (flrpt_type=_r.type) AND (flrpt_type_id=_r.type_id)); IF (_r.subtract) THEN UPDATE flrpt SET flrpt_beginning = flrpt_beginning - _g.beginning, flrpt_ending = flrpt_ending - _g.ending, flrpt_debits = flrpt_debits - _g.debits, flrpt_credits = flrpt_credits - _g.credits, flrpt_budget = flrpt_budget - _g.budget, flrpt_diff = flrpt_diff - _g.diff, flrpt_custom = flrpt_custom - _g.custom WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) -- AND (flrpt_username=_username) AND (flrpt_type='G') AND (flrpt_type_id=pFlgrpid)); ELSE UPDATE flrpt SET flrpt_beginning = flrpt_beginning + _g.beginning, flrpt_ending = flrpt_ending + _g.ending, flrpt_debits = flrpt_debits + _g.debits, flrpt_credits = flrpt_credits + _g.credits, flrpt_budget = flrpt_budget + _g.budget, flrpt_diff = flrpt_diff + _g.diff, flrpt_custom = flrpt_custom + _g.custom WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) -- AND (flrpt_username=_username) AND (flrpt_type='G') AND (flrpt_type_id=pFlgrpid)); END IF; -- If we are summarizing then we need to remove the record we created now that we have updated the total IF (pSummarize) THEN DELETE FROM flrpt WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) -- AND (flrpt_username=_username) AND (flrpt_type=_r.type) AND (flrpt_type_id=_r.type_id)); END IF; ELSE IF (_r.type = 'I' OR _r.type = 'S' ) THEN -- If we are not summarizing then create a new entry for this record IF (NOT pSummarize) THEN INSERT INTO flrpt (flrpt_flhead_id, flrpt_period_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_beginning, flrpt_ending, flrpt_debits, flrpt_credits, flrpt_budget, flrpt_diff, flrpt_custom, flrpt_beginningprcnt, flrpt_endingprcnt, flrpt_debitsprcnt, flrpt_creditsprcnt, flrpt_budgetprcnt, flrpt_diffprcnt, flrpt_customprcnt, flrpt_parent_id,flrpt_accnt_id,flrpt_interval) VALUES (pFlheadid, pPeriodid, _username, (COALESCE(( SELECT MAX(flrpt_order) FROM flrpt WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) -- AND (flrpt_username=_username) ) ), 1) + 1), pLevel, _r.type, _r.type_id, _r.beginning, _r.ending, _r.debits, _r.credits, _r.budget, _r.diff, _r.custom, _r.beginningprcnt, _r.endingprcnt, _r.debitsprcnt, _r.creditsprcnt, _r.budgetprcnt, _r.diffprcnt, _r.customprcnt, pFlgrpid,_r.accnt_id,pInterval); END IF; -- Update the parent item IF (_r.subtract) THEN UPDATE flrpt SET flrpt_beginning = flrpt_beginning - COALESCE(_r.beginning, 0.00), flrpt_ending = flrpt_ending - COALESCE(_r.ending, 0.00), flrpt_debits = flrpt_debits - COALESCE(_r.debits, 0.00), flrpt_credits = flrpt_credits - COALESCE(_r.credits, 0.00), flrpt_budget = flrpt_budget - COALESCE(_r.budget, 0.00), flrpt_diff = flrpt_diff - COALESCE(_r.diff, 0.00), flrpt_custom = flrpt_custom - COALESCE(_r.custom, 0.00) WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) -- AND (flrpt_username=_username) AND (flrpt_type='G') AND (flrpt_type_id=pFlgrpid)); ELSE UPDATE flrpt SET flrpt_beginning = flrpt_beginning + COALESCE(_r.beginning, 0.00), flrpt_ending = flrpt_ending + COALESCE(_r.ending, 0.00), flrpt_debits = flrpt_debits + COALESCE(_r.debits, 0.00), flrpt_credits = flrpt_credits + COALESCE(_r.credits, 0.00), flrpt_budget = flrpt_budget + COALESCE(_r.budget, 0.00), flrpt_diff = flrpt_diff + COALESCE(_r.diff, 0.00), flrpt_custom = flrpt_custom + COALESCE(_r.custom, 0.00) WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_interval=pInterval) AND (flrpt_period_id=pPeriodid) -- AND (flrpt_username=_username) AND (flrpt_type='G') AND (flrpt_type_id=pFlgrpid)); END IF; END IF; END IF; END LOOP; IF (NOT pSummarize) THEN -- If this group wants a summarized line create it here. IF (_subtotal) THEN INSERT INTO flrpt (flrpt_flhead_id, flrpt_period_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_beginning, flrpt_ending, flrpt_debits, flrpt_credits, flrpt_budget, flrpt_diff, flrpt_custom, flrpt_beginningprcnt, flrpt_endingprcnt, flrpt_debitsprcnt, flrpt_creditsprcnt, flrpt_budgetprcnt, flrpt_diffprcnt, flrpt_customprcnt, flrpt_parent_id, flrpt_altname,flrpt_interval ) SELECT pFlheadid, pPeriodid, _username, (COALESCE(( SELECT MAX(flrpt_order) FROM flrpt WHERE ((flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) -- AND (flrpt_username=_username) ) ), 1) + 1), pLevel, 'T', -1, CASE WHEN (flgrp_showstart) THEN flrpt_beginning ELSE NULL END, CASE WHEN (flgrp_showend) THEN flrpt_ending ELSE NULL END, CASE WHEN (flgrp_showdelta) THEN flrpt_debits ELSE NULL END, CASE WHEN (flgrp_showdelta) THEN flrpt_credits ELSE NULL END, CASE WHEN (flgrp_showbudget) THEN flrpt_budget ELSE NULL END, CASE WHEN (flgrp_showdiff) THEN flrpt_diff ELSE NULL END, CASE WHEN (flgrp_showcustom) THEN flrpt_custom ELSE NULL END, CASE WHEN (flgrp_showstartprcnt) THEN flrpt_beginningprcnt ELSE NULL END, CASE WHEN (flgrp_showendprcnt) THEN flrpt_endingprcnt ELSE NULL END, CASE WHEN (flgrp_showdeltaprcnt) THEN flrpt_debitsprcnt ELSE NULL END, CASE WHEN (flgrp_showdeltaprcnt) THEN flrpt_creditsprcnt ELSE NULL END, CASE WHEN (flgrp_showbudgetprcnt) THEN flrpt_budgetprcnt ELSE NULL END, CASE WHEN (flgrp_showdiffprcnt) THEN flrpt_diffprcnt ELSE NULL END, CASE WHEN (flgrp_showcustomprcnt) THEN flrpt_customprcnt ELSE NULL END, pFlgrpid, CASE WHEN (flgrp_usealtsubtotal) THEN flgrp_altsubtotal ELSE NULL END, pInterval FROM flrpt, flgrp WHERE ((flrpt_flhead_id=flgrp_flhead_id) AND (flrpt_type_id=flgrp_id) AND (flrpt_flhead_id=pFlheadid) AND (flrpt_period_id=pPeriodid) AND (flrpt_interval=pInterval) -- AND (flrpt_username=_username) AND (flrpt_type='G') AND (flrpt_type_id=pFlgrpid)); END IF; END IF; return TRUE; END; $$; DROP FUNCTION public.insertflgroup(pflheadid integer, pperiodid integer, pflgrpid integer, plevel integer, psummarize boolean, pinterval character, pprjid integer); publicadminfalse46238125578884Uinsertgltransaction(text, text, text, text, integer, integer, integer, numeric, date)FUNCTIONCREATE FUNCTION insertgltransaction(text, text, text, text, integer, integer, integer, numeric, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSource ALIAS FOR $1; pDocType ALIAS FOR $2; pDocNumber ALIAS FOR $3; pNotes ALIAS FOR $4; pCreditid ALIAS FOR $5; pDebitid ALIAS FOR $6; pMiscid ALIAS FOR $7; pAmount ALIAS FOR $8; pDistDate ALIAS FOR $9; _return INTEGER; BEGIN SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'), pSource, pDocType, pDocNumber, pNotes, pCreditid, pDebitid, pMiscid, pAmount, pDistDate) INTO _return; RETURN _return; END; $_$; lDROP FUNCTION public.insertgltransaction(text, text, text, text, integer, integer, integer, numeric, date); publicadminfalse46238125578885^insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date)FUNCTIONCREATE FUNCTION insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pJournalNumber ALIAS FOR $1; pSource ALIAS FOR $2; pDocType ALIAS FOR $3; pDocNumber ALIAS FOR $4; pNotes ALIAS FOR $5; pCreditid ALIAS FOR $6; pDebitid ALIAS FOR $7; pMiscid ALIAS FOR $8; pAmount ALIAS FOR $9; pDistDate ALIAS FOR $10; _return INTEGER; BEGIN SELECT insertGLTransaction( pJournalNumber, pSource, pDocType, pDocNumber, pNotes, pCreditid, pDebitid, pMiscid, pAmount, pDistDate, TRUE) INTO _return; RETURN _return; END; $_$; uDROP FUNCTION public.insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date); publicadminfalse46238125578886^insertgltransaction(text, text, text, text, integer, integer, integer, numeric, date, boolean)FUNCTIONNCREATE FUNCTION insertgltransaction(text, text, text, text, integer, integer, integer, numeric, date, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSource ALIAS FOR $1; pDocType ALIAS FOR $2; pDocNumber ALIAS FOR $3; pNotes ALIAS FOR $4; pCreditid ALIAS FOR $5; pDebitid ALIAS FOR $6; pMiscid ALIAS FOR $7; pAmount ALIAS FOR $8; pDistDate ALIAS FOR $9; pPostTrialBal ALIAS FOR $10; _return INTEGER; BEGIN SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'), pSource, pDocType, pDocNumber, pNotes, pCreditid, pDebitid, pMiscid, pAmount, pDistDate, pPostTrialBal) INTO _return; RETURN _return; END; $_$; uDROP FUNCTION public.insertgltransaction(text, text, text, text, integer, integer, integer, numeric, date, boolean); publicadminfalse84623125578887ginsertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date, boolean)FUNCTIONTCREATE FUNCTION insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pJournalNumber ALIAS FOR $1; pSource ALIAS FOR $2; pDocType ALIAS FOR $3; pDocNumber ALIAS FOR $4; pNotes ALIAS FOR $5; pCreditid ALIAS FOR $6; pDebitid ALIAS FOR $7; pMiscid ALIAS FOR $8; pAmount ALIAS FOR $9; pDistDate ALIAS FOR $10; pPostTrialBal ALIAS FOR $11; _return INTEGER; BEGIN SELECT insertGLTransaction( pJournalNumber, pSource, pDocType, pDocNumber, pNotes, pCreditid, pDebitid, pMiscid, pAmount, pDistDate, pPostTrialBal, false) INTO _return; RETURN _return; END; $_$; ~DROP FUNCTION public.insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date, boolean); publicadminfalse46238125578888pinsertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date, boolean, boolean)FUNCTIONhCREATE FUNCTION insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pJournalNumber ALIAS FOR $1; pSource ALIAS FOR $2; pDocType ALIAS FOR $3; pDocNumber ALIAS FOR $4; pNotes ALIAS FOR $5; pCreditid ALIAS FOR $6; pDebitid ALIAS FOR $7; pMiscid ALIAS FOR $8; pAmount ALIAS FOR $9; pDistDate ALIAS FOR $10; pPostTrialBal ALIAS FOR $11; pOnlyGL ALIAS FOR $12; _debitid INTEGER; _creditid INTEGER; _sequence INTEGER; _check INTEGER; BEGIN -- Check GL Interface metric IF (fetchMetricBool('InterfaceToGL') = false AND pSource IN ('I/M', 'P/D', 'S/R', 'W/O')) THEN RETURN 0; END IF; IF (fetchMetricBool('InterfaceAPToGL') = false AND pSource = 'A/P') THEN RETURN 0; END IF; IF (fetchMetricBool('InterfaceARToGL') = false AND pSource IN ('A/R', 'S/O', 'S/R')) THEN RETURN 0; END IF; -- Is there anything to post? -- ToDo - 2 should really be the scale of the base currency IF (round(pAmount, 2) = 0) THEN RETURN -3; END IF; /* Make sure we don't create an imbalance across companies. The 'IgnoreCompanyBalance' metric is a back door mechanism to allow legacy users to create transactions accross companies if they have been using the company segment for something else and they MUST continue to be able to do so. It can only be implemented by direct sql update to the metric table and should otherwise be discouraged. */ IF (COALESCE(fetchMetricValue('GLCompanySize'),0) > 0 AND fetchMetricBool('IgnoreCompany') = false) THEN IF (SELECT (COALESCE(d.accnt_company,'') != COALESCE(c.accnt_company,'')) FROM accnt d, accnt c WHERE ((d.accnt_id=pDebitid) AND (c.accnt_id=pCreditid))) THEN RAISE EXCEPTION 'G/L Transaction can not be posted because accounts % and % reference two different companies.', formatGlaccount(pDebitid), formatGlaccount(pCreditid); END IF; END IF; -- Validate pDebitid IF (pDebitid IN (SELECT accnt_id FROM accnt)) THEN _debitid := pDebitid; ELSE -- Try and work out the unassigned accnt from the credit accnt SELECT getUnassignedAccntId(getcompanyid(pCreditid)) INTO _debitid; END IF; -- Validate pCreditid IF (pCreditid IN (SELECT accnt_id FROM accnt)) THEN _creditid := pCreditid; ELSE -- Try and work out the unassigned accnt from the debit accnt SELECT getUnassignedAccntId(getcompanyid(pDebitid)) INTO _creditid; END IF; -- refuse to accept postings into closed periods IF (SELECT BOOL_AND(COALESCE(period_closed, FALSE)) FROM accnt LEFT OUTER JOIN period ON (pDistDate BETWEEN period_start AND period_end) WHERE (accnt_id IN (_creditid, _debitid))) THEN RAISE EXCEPTION 'Cannot post to closed period (%).', pDistDate; RETURN -4; -- remove raise exception when all callers check return code END IF; -- refuse to accept postings into frozen periods without proper priv IF (SELECT NOT BOOL_AND(checkPrivilege('PostFrozenPeriod')) AND BOOL_AND(COALESCE(period_freeze, FALSE)) FROM accnt LEFT OUTER JOIN period ON (pDistDate BETWEEN period_start AND period_end) WHERE (accnt_id IN (_creditid, _debitid))) THEN RAISE EXCEPTION 'Cannot post to frozen period (%).', pDistDate; RETURN -4; -- remove raise exception when all callers check return code END IF; -- refuse to accept postings into nonexistent periods IF NOT EXISTS(SELECT period_id FROM period WHERE (pDistDate BETWEEN period_start AND period_end)) THEN RAISE EXCEPTION 'Cannot post to nonexistent period (%).', pDistDate; END IF; -- Grab a sequence for the pair SELECT fetchGLSequence() INTO _sequence; IF (NOT pOnlyGL AND fetchMetricBool('UseJournals')) THEN -- First the credit INSERT INTO sltrans ( sltrans_journalnumber, sltrans_posted, sltrans_created, sltrans_date, sltrans_sequence, sltrans_accnt_id, sltrans_source, sltrans_doctype, sltrans_docnumber, sltrans_notes, sltrans_misc_id, sltrans_amount ) VALUES ( pJournalNumber, FALSE, CURRENT_TIMESTAMP, pDistDate, _sequence, _creditid, pSource, pDocType, pDocNumber, pNotes, pMiscid, pAmount ); -- Now the debit INSERT INTO sltrans ( sltrans_journalnumber, sltrans_posted, sltrans_created, sltrans_date, sltrans_sequence, sltrans_accnt_id, sltrans_source, sltrans_doctype, sltrans_docnumber, sltrans_notes, sltrans_misc_id, sltrans_amount ) VALUES ( pJournalNumber, FALSE, CURRENT_TIMESTAMP, pDistDate, _sequence, _debitid, pSource, pDocType, pDocNumber, pNotes, pMiscid, (pAmount * -1) ); ELSE -- First the credit INSERT INTO gltrans ( gltrans_journalnumber, gltrans_posted, gltrans_exported, gltrans_created, gltrans_date, gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_doctype, gltrans_docnumber, gltrans_notes, gltrans_misc_id, gltrans_amount ) VALUES ( pJournalNumber, FALSE, FALSE, CURRENT_TIMESTAMP, pDistDate, _sequence, _creditid, pSource, pDocType, pDocNumber, pNotes, pMiscid, pAmount ); -- Now the debit INSERT INTO gltrans ( gltrans_journalnumber, gltrans_posted, gltrans_exported, gltrans_created, gltrans_date, gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_doctype, gltrans_docnumber, gltrans_notes, gltrans_misc_id, gltrans_amount ) VALUES ( pJournalNumber, FALSE, FALSE, CURRENT_TIMESTAMP, pDistDate, _sequence, _debitid, pSource, pDocType, pDocNumber, pNotes, pMiscid, (pAmount * -1) ); IF (pPostTrialBal) THEN PERFORM postIntoTrialBalance(_sequence); END IF; END IF; RETURN _sequence; END; $_$; DROP FUNCTION public.insertgltransaction(integer, text, text, text, text, integer, integer, integer, numeric, date, boolean, boolean); publicadminfalse46238125578890?insertintoglseries(integer, text, text, text, integer, numeric)FUNCTIONCREATE FUNCTION insertintoglseries(integer, text, text, text, integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; pSource ALIAS FOR $2; pDocType ALIAS FOR $3; pDocNumber ALIAS FOR $4; pAccntid ALIAS FOR $5; pAmount ALIAS FOR $6; _returnValue INTEGER; BEGIN SELECT insertIntoGLSeries( pSequence, pSource, pDocType, pDocNumber, pAccntid, pAmount, CURRENT_DATE, '' ) INTO _returnValue; RETURN _returnValue; END; $_$; VDROP FUNCTION public.insertintoglseries(integer, text, text, text, integer, numeric); publicadminfalse84623125578891Einsertintoglseries(integer, text, text, text, integer, numeric, date)FUNCTIONCREATE FUNCTION insertintoglseries(integer, text, text, text, integer, numeric, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; pSource ALIAS FOR $2; pDocType ALIAS FOR $3; pDocNumber ALIAS FOR $4; pAccntid ALIAS FOR $5; pAmount ALIAS FOR $6; pDistDate ALIAS FOR $7; _returnValue INTEGER; BEGIN SELECT insertIntoGLSeries( pSequence, pSource, pDocType, pDocNumber, pAccntid, pAmount, pDistDate, '' ) INTO _returnValue; RETURN _returnValue; END; $_$; \DROP FUNCTION public.insertintoglseries(integer, text, text, text, integer, numeric, date); publicadminfalse46238125578892Kinsertintoglseries(integer, text, text, text, integer, numeric, date, text)FUNCTIONCREATE FUNCTION insertintoglseries(integer, text, text, text, integer, numeric, date, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; pSource ALIAS FOR $2; pDocType ALIAS FOR $3; pDocNumber ALIAS FOR $4; pAccntid ALIAS FOR $5; pAmount ALIAS FOR $6; pDistDate ALIAS FOR $7; pNotes ALIAS FOR $8; _returnValue INTEGER; BEGIN SELECT insertIntoGLSeries( pSequence, pSource, pDocType, pDocNumber, pAccntid, pAmount, pDistDate, pNotes, NULL ) INTO _returnValue; RETURN _returnValue; END; $_$; bDROP FUNCTION public.insertintoglseries(integer, text, text, text, integer, numeric, date, text); publicadminfalse46238125578893Tinsertintoglseries(integer, text, text, text, integer, numeric, date, text, integer)FUNCTIONF CREATE FUNCTION insertintoglseries(integer, text, text, text, integer, numeric, date, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; pSource ALIAS FOR $2; pDocType ALIAS FOR $3; pDocNumber ALIAS FOR $4; pAccntid ALIAS FOR $5; pAmount ALIAS FOR $6; pDistDate ALIAS FOR $7; pNotes ALIAS FOR $8; pMiscid ALIAS FOR $9; _glseriesid INTEGER; BEGIN -- Check GL Interface metric IF (fetchMetricBool('InterfaceToGL') = false AND pSource IN ('I/M', 'P/D', 'S/R', 'W/O')) THEN RETURN 0; END IF; IF (fetchMetricBool('InterfaceAPToGL') = false AND pSource = 'A/P') THEN RETURN 0; END IF; IF (fetchMetricBool('InterfaceARToGL') = false AND pSource IN ('A/R', 'S/O', 'S/R')) THEN RETURN 0; END IF; -- Verify the target accnt IF ( (pAccntid IS NULL) OR (pAccntid = -1) ) THEN RETURN -1; END IF; -- refuse to accept postings into closed periods IF (SELECT BOOL_AND(COALESCE(period_closed, FALSE)) FROM accnt LEFT OUTER JOIN period ON (pDistDate BETWEEN period_start AND period_end) WHERE (accnt_id = pAccntid)) THEN RAISE EXCEPTION 'Cannot post to closed period (%).', pDistDate; RETURN -4; -- remove raise exception when all callers check return code END IF; -- refuse to accept postings into frozen periods without proper priv IF (SELECT NOT BOOL_AND(checkPrivilege('PostFrozenPeriod')) AND BOOL_AND(COALESCE(period_freeze, FALSE)) FROM accnt LEFT OUTER JOIN period ON (pDistDate BETWEEN period_start AND period_end) WHERE (accnt_id = pAccntid)) THEN RAISE EXCEPTION 'Cannot post to frozen period (%).', pDistDate; RETURN -4; -- remove raise exception when all callers check return code END IF; -- refuse to accept postings into nonexistent periods IF NOT EXISTS(SELECT period_id FROM period WHERE (pDistDate BETWEEN period_start AND period_end)) THEN RAISE EXCEPTION 'Cannot post to nonexistent period (%).', pDistDate; END IF; -- Insert into the glseries SELECT NEXTVAL('glseries_glseries_id_seq') INTO _glseriesid; INSERT INTO glseries ( glseries_id, glseries_sequence, glseries_source, glseries_doctype, glseries_docnumber, glseries_accnt_id, glseries_amount, glseries_distdate, glseries_notes, glseries_misc_id ) VALUES ( _glseriesid, pSequence, pSource, pDocType, pDocNumber, pAccntid, pAmount, pDistDate, pNotes, pMiscid ); RETURN _glseriesid; END; $_$; kDROP FUNCTION public.insertintoglseries(integer, text, text, text, integer, numeric, date, text, integer); publicadminfalse46238125978894invcheadTABLECREATE TABLE invchead ( invchead_id integer NOT NULL, invchead_cust_id integer NOT NULL, invchead_shipto_id integer, invchead_ordernumber text, invchead_orderdate date, invchead_posted boolean NOT NULL, invchead_printed boolean NOT NULL, invchead_invcnumber text NOT NULL, invchead_invcdate date NOT NULL, invchead_shipdate date, invchead_ponumber text, invchead_shipvia text, invchead_fob text, invchead_billto_name text, invchead_billto_address1 text, invchead_billto_address2 text, invchead_billto_address3 text, invchead_billto_city text, invchead_billto_state text, invchead_billto_zipcode text, invchead_billto_phone text, invchead_shipto_name text, invchead_shipto_address1 text, invchead_shipto_address2 text, invchead_shipto_address3 text, invchead_shipto_city text, invchead_shipto_state text, invchead_shipto_zipcode text, invchead_shipto_phone text, invchead_salesrep_id integer, invchead_commission numeric(20,10) NOT NULL, invchead_terms_id integer, invchead_freight numeric(16,2) NOT NULL, invchead_misc_amount numeric(16,2) NOT NULL, invchead_misc_descrip text, invchead_misc_accnt_id integer, invchead_payment numeric(16,2), invchead_paymentref text, invchead_notes text, invchead_billto_country text, invchead_shipto_country text, invchead_prj_id integer, invchead_curr_id integer DEFAULT basecurrid(), invchead_gldistdate date, invchead_recurring boolean DEFAULT false NOT NULL, invchead_recurring_interval integer, invchead_recurring_type text, invchead_recurring_until date, invchead_recurring_invchead_id integer, invchead_shipchrg_id integer, invchead_taxzone_id integer, invchead_void boolean DEFAULT false, invchead_saletype_id integer, invchead_shipzone_id integer, CONSTRAINT invchead_invchead_invcnumber_check CHECK ((invchead_invcnumber <> ''::text)) ); DROP TABLE public.invchead; publicadminfalse607360746075607786&00TABLE invcheadCOMMENT;COMMENT ON TABLE invchead IS 'Invoice header information'; publicadminfalse2057&00"COLUMN invchead.invchead_recurringCOMMENT@COMMENT ON COLUMN invchead.invchead_recurring IS 'Deprecated.'; publicadminfalse2058&00+COLUMN invchead.invchead_recurring_intervalCOMMENTICOMMENT ON COLUMN invchead.invchead_recurring_interval IS 'Deprecated.'; publicadminfalse2059&00'COLUMN invchead.invchead_recurring_typeCOMMENTECOMMENT ON COLUMN invchead.invchead_recurring_type IS 'Deprecated.'; publicadminfalse205:&00(COLUMN invchead.invchead_recurring_untilCOMMENTFCOMMENT ON COLUMN invchead.invchead_recurring_until IS 'Deprecated.'; publicadminfalse205;&00$COLUMN invchead.invchead_saletype_idCOMMENTXCOMMENT ON COLUMN invchead.invchead_saletype_id IS 'Associated sale type for invoice.'; publicadminfalse205<&00$COLUMN invchead.invchead_shipzone_idCOMMENT\COMMENT ON COLUMN invchead.invchead_shipzone_id IS 'Associated shipping zone for invoice.'; publicadminfalse205=&00invcheadACLREVOKE ALL ON TABLE invchead FROM PUBLIC; REVOKE ALL ON TABLE invchead FROM admin; GRANT ALL ON TABLE invchead TO admin; GRANT ALL ON TABLE invchead TO xtrole; publicadminfalse205125978904prjTABLECREATE TABLE prj ( prj_id integer NOT NULL, prj_number text NOT NULL, prj_name text NOT NULL, prj_descrip text, prj_status character(1) NOT NULL, prj_so boolean, prj_wo boolean, prj_po boolean, prj_owner_username text, prj_start_date date, prj_due_date date, prj_assigned_date date, prj_completed_date date, prj_username text, prj_recurring_prj_id integer, prj_crmacct_id integer, prj_cntct_id integer, prj_prjtype_id integer, CONSTRAINT prj_prj_number_check CHECK ((prj_number <> ''::text)), CONSTRAINT prj_prj_status_check CHECK ((prj_status = ANY (ARRAY['P'::bpchar, 'O'::bpchar, 'C'::bpchar]))) ); DROP TABLE public.prj; publicadminfalse607960808>&00 TABLE prjCOMMENT/COMMENT ON TABLE prj IS 'Project information'; publicadminfalse206?&00COLUMN prj.prj_recurring_prj_idCOMMENTCOMMENT ON COLUMN prj.prj_recurring_prj_id IS 'The first prj record in the series if this is a recurring Project. If the prj_recurring_prj_id is the same as the prj_id, this record is the first in the series.'; publicadminfalse206@&00prjACLREVOKE ALL ON TABLE prj FROM PUBLIC; REVOKE ALL ON TABLE prj FROM admin; GRANT ALL ON TABLE prj TO admin; GRANT ALL ON TABLE prj TO xtrole; publicadminfalse206125978912saletypeTABLECREATE TABLE saletype ( saletype_id integer NOT NULL, saletype_code text NOT NULL, saletype_descr text, saletype_active boolean DEFAULT true NOT NULL, saletype_default boolean DEFAULT false NOT NULL ); DROP TABLE public.saletype; publicadminfalse608260838A&00TABLE saletypeCOMMENT=COMMENT ON TABLE saletype IS 'Type or Origination of Sale.'; publicadminfalse207B&00COLUMN saletype.saletype_idCOMMENTPCOMMENT ON COLUMN saletype.saletype_id IS 'Sequence identifier for sale type.'; publicadminfalse207C&00COLUMN saletype.saletype_codeCOMMENTVCOMMENT ON COLUMN saletype.saletype_code IS 'User defined identifier for sale type.'; publicadminfalse207D&00COLUMN saletype.saletype_descrCOMMENTKCOMMENT ON COLUMN saletype.saletype_descr IS 'Description for sale type.'; publicadminfalse207E&00COLUMN saletype.saletype_activeCOMMENTTCOMMENT ON COLUMN saletype.saletype_active IS 'Boolean to deactivate a sale type.'; publicadminfalse207F&00saletypeACLREVOKE ALL ON TABLE saletype FROM PUBLIC; REVOKE ALL ON TABLE saletype FROM admin; GRANT ALL ON TABLE saletype TO admin; GRANT ALL ON TABLE saletype TO xtrole; publicadminfalse207125978919shipzoneTABLECREATE TABLE shipzone ( shipzone_id integer DEFAULT nextval(('shipzone_shipzone_id_seq'::text)::regclass) NOT NULL, shipzone_name text NOT NULL, shipzone_descrip text, CONSTRAINT shipzone_shipzone_name_check CHECK ((shipzone_name <> ''::text)) ); DROP TABLE public.shipzone; publicadminfalse608460858G&00TABLE shipzoneCOMMENT:COMMENT ON TABLE shipzone IS 'Shipping Zone information'; publicadminfalse208H&00shipzoneACLREVOKE ALL ON TABLE shipzone FROM PUBLIC; REVOKE ALL ON TABLE shipzone FROM admin; GRANT ALL ON TABLE shipzone TO admin; GRANT ALL ON TABLE shipzone TO xtrole; publicadminfalse208N125987992invoiceVIEW CREATE VIEW invoice AS SELECT invchead.invchead_invcnumber AS invoice_number, invchead.invchead_ordernumber AS order_number, invchead.invchead_invcdate AS invoice_date, invchead.invchead_shipdate AS ship_date, invchead.invchead_orderdate AS order_date, saletype.saletype_code AS sale_type, salesrep.salesrep_number AS sales_rep, invchead.invchead_commission AS commission, COALESCE(taxzone.taxzone_code, 'None'::text) AS tax_zone, terms.terms_code AS terms, custinfo.cust_number AS customer_number, invchead.invchead_billto_name AS billto_name, invchead.invchead_billto_address1 AS billto_address1, invchead.invchead_billto_address2 AS billto_address2, invchead.invchead_billto_address3 AS billto_address3, invchead.invchead_billto_city AS billto_city, invchead.invchead_billto_state AS billto_state, invchead.invchead_billto_zipcode AS billto_postal_code, invchead.invchead_billto_country AS billto_country, invchead.invchead_billto_phone AS billto_phone, shiptoinfo.shipto_num AS shipto_number, invchead.invchead_shipto_name AS shipto_name, invchead.invchead_shipto_address1 AS shipto_address1, invchead.invchead_shipto_address2 AS shipto_address2, invchead.invchead_shipto_address3 AS shipto_address3, invchead.invchead_shipto_city AS shipto_city, invchead.invchead_shipto_state AS shipto_state, invchead.invchead_shipto_zipcode AS shipto_postal_code, invchead.invchead_shipto_country AS shipto_country, shipzone.shipzone_name AS shipto_shipzone, invchead.invchead_shipto_phone AS shipto_phone, invchead.invchead_ponumber AS po_number, invchead.invchead_shipvia AS ship_via, prj.prj_number AS project_number, invchead.invchead_fob AS fob, invchead.invchead_misc_descrip AS misc_charge_description, invchead.invchead_misc_amount AS misc_charge, CASE WHEN (invchead.invchead_misc_accnt_id = (-1)) THEN NULL::text ELSE public.formatglaccount(invchead.invchead_misc_accnt_id) END AS misc_charge_account_number, invchead.invchead_freight AS freight, curr.curr_abbr AS currency, invchead.invchead_payment AS payment, invchead.invchead_notes AS notes FROM (((((((((public.invchead LEFT JOIN public.custinfo ON ((custinfo.cust_id = invchead.invchead_cust_id))) LEFT JOIN public.shiptoinfo ON ((shiptoinfo.shipto_id = invchead.invchead_shipto_id))) LEFT JOIN public.prj ON ((prj.prj_id = invchead.invchead_prj_id))) LEFT JOIN public.curr_symbol curr ON ((curr.curr_id = invchead.invchead_curr_id))) LEFT JOIN public.salesrep ON ((salesrep.salesrep_id = invchead.invchead_salesrep_id))) LEFT JOIN public.terms ON ((terms.terms_id = invchead.invchead_terms_id))) LEFT JOIN public.taxzone ON ((taxzone.taxzone_id = invchead.invchead_taxzone_id))) LEFT JOIN public.saletype ON ((invchead.invchead_saletype_id = saletype.saletype_id))) LEFT JOIN public.shipzone ON ((invchead.invchead_shipzone_id = shipzone.shipzone_id))); DROP VIEW api.invoice; apiadminfalse88526I&00 VIEW invoiceCOMMENTCOMMENT ON VIEW invoice IS ' This view can be used as an interface to import Invioce Header data directly into the system. Required fields will be checked and default values will be populated'; apiadminfalse846J&00invoiceACLREVOKE ALL ON TABLE invoice FROM PUBLIC; REVOKE ALL ON TABLE invoice FROM admin; GRANT ALL ON TABLE invoice TO admin; GRANT ALL ON TABLE invoice TO xtrole; apiadminfalse846[ 125587998insertinvoice(api.invoice)FUNCTIONCREATE FUNCTION insertinvoice(api.invoice) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNew ALIAS FOR $1; BEGIN -- NOTE: (SELECT getCustId(...)) seems redundant, but it actually produces -- a HUGE performance increase because it makes the Postgres query planner -- use an index scan rather than an sequential table scan on cust_id INSERT INTO invchead ( invchead_invcnumber, invchead_ordernumber, invchead_invcdate, invchead_shipdate, invchead_orderdate, invchead_printed, invchead_posted, invchead_salesrep_id, invchead_commission, invchead_taxzone_id, invchead_terms_id, invchead_cust_id, invchead_billto_name, invchead_billto_address1, invchead_billto_address2, invchead_billto_address3, invchead_billto_city, invchead_billto_state, invchead_billto_zipcode, invchead_billto_country, invchead_billto_phone, invchead_shipto_id, invchead_shipto_name, invchead_shipto_address1, invchead_shipto_address2, invchead_shipto_address3, invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode, invchead_shipto_country, invchead_shipto_phone, invchead_ponumber, invchead_shipvia, invchead_prj_id, invchead_fob, invchead_misc_descrip, invchead_misc_amount, invchead_misc_accnt_id, invchead_freight, invchead_curr_id, invchead_payment, invchead_notes, invchead_saletype_id, invchead_shipzone_id ) SELECT (CASE -- use a case here so we don't unnecessarily fetch a new invoice number WHEN pNew.invoice_number IS NULL THEN CAST(fetchInvcNumber() AS TEXT) WHEN pNew.invoice_number = '' THEN CAST(fetchInvcNumber() AS TEXT) ELSE pNew.invoice_number END), pNew.order_number, COALESCE(pNew.invoice_date, CURRENT_DATE), pNew.ship_date, pNew.order_date, FALSE, FALSE, COALESCE(getSalesRepId(pNew.sales_rep),shipto_salesrep_id,cust_salesrep_id), COALESCE(pNew.commission, 0), CASE WHEN pNew.tax_zone = 'None' THEN NULL ELSE COALESCE(getTaxZoneId(pNew.tax_zone),shipto_taxzone_id,cust_taxzone_id) END, COALESCE(getTermsId(pNew.terms),cust_terms_id), (SELECT getCustId(pNew.customer_number)), COALESCE(pNew.billto_name, cohead_billtoname, cust_name), COALESCE(pNew.billto_address1, cohead_billtoaddress1, addr_line1), COALESCE(pNew.billto_address2, cohead_billtoaddress2, addr_line2), COALESCE(pNew.billto_address3, cohead_billtoaddress3, addr_line3), COALESCE(pNew.billto_city, cohead_billtocity, addr_city), COALESCE(pNew.billto_state, cohead_billtostate, addr_state), COALESCE(pNew.billto_postal_code, cohead_billtozipcode, addr_postalcode), COALESCE(pNew.billto_country, cohead_billtocountry, addr_country), COALESCE(pNew.billto_phone, ''), COALESCE(shipto_id,-1), pNew.shipto_name, pNew.shipto_address1, pNew.shipto_address2, pNew.shipto_address3, pNew.shipto_city, pNew.shipto_state, pNew.shipto_postal_code, pNew.shipto_country, pNew.shipto_phone, COALESCE(pNew.po_number, ''), COALESCE(pNew.ship_via,shipto_shipvia,cust_shipvia), COALESCE(getPrjId(pNew.project_number),-1), COALESCE(pNew.fob,fetchDefaultFob(( SELECT CAST(usrpref_value AS INTEGER) FROM usrpref, whsinfo WHERE ((warehous_id=CAST(usrpref_value AS INTEGER)) AND (warehous_shipping) AND (warehous_active) AND (usrpref_username=getEffectiveXtUser()) AND (usrpref_name='PreferredWarehouse') ) ))), pNew.misc_charge_description, COALESCE(pNew.misc_charge, 0), COALESCE(getGlAccntId(pNew.misc_charge_account_number),-1), COALESCE(pNew.freight, 0), COALESCE(getCurrId(pNew.currency),( SELECT cust_curr_id FROM custinfo WHERE (cust_id=(SELECT getCustId(pNew.customer_number))) ),basecurrid()), COALESCE(pNew.payment,0), COALESCE(pNew.notes,''), getSaleTypeId(pNew.sale_type), getShipZoneId(pNew.shipto_shipzone) FROM custinfo LEFT OUTER JOIN shiptoinfo ON (shipto_id=(SELECT CASE WHEN getShiptoId(pNew.customer_number,pNew.shipto_number) IS NOT NULL THEN getShiptoId(pNew.customer_number,pNew.shipto_number) ELSE (SELECT shipto_id FROM shiptoinfo WHERE shipto_cust_id=cust_id AND shipto_default) END)) LEFT OUTER JOIN cohead ON (cohead_number=pNEW.order_number) LEFT OUTER JOIN cntct ON (cntct_id=cust_cntct_id) LEFT OUTER JOIN addr ON (addr_id=cntct_addr_id) WHERE cust_id = (SELECT getCustId(pNew.customer_number)); RETURN TRUE; END; $_$; 1DROP FUNCTION public.insertinvoice(api.invoice); publicadminfalse446684623125978933invcitemTABLEMCREATE TABLE invcitem ( invcitem_id integer NOT NULL, invcitem_invchead_id integer NOT NULL, invcitem_linenumber integer, invcitem_item_id integer, invcitem_warehous_id integer DEFAULT (-1), invcitem_custpn text, invcitem_number text, invcitem_descrip text, invcitem_ordered numeric(20,6) NOT NULL, invcitem_billed numeric(20,6) NOT NULL, invcitem_custprice numeric(20,4), invcitem_price numeric(20,4) NOT NULL, invcitem_notes text, invcitem_salescat_id integer, invcitem_taxtype_id integer, invcitem_qty_uom_id integer, invcitem_qty_invuomratio numeric(20,10) NOT NULL, invcitem_price_uom_id integer, invcitem_price_invuomratio numeric(20,10) NOT NULL, invcitem_coitem_id integer, invcitem_updateinv boolean DEFAULT false, invcitem_rev_accnt_id integer ); DROP TABLE public.invcitem; publicadminfalse608760888K&00TABLE invcitemCOMMENT>COMMENT ON TABLE invcitem IS 'Invoice Line Item information'; publicadminfalse209L&00invcitemACLREVOKE ALL ON TABLE invcitem FROM PUBLIC; REVOKE ALL ON TABLE invcitem FROM admin; GRANT ALL ON TABLE invcitem TO admin; GRANT ALL ON TABLE invcitem TO xtrole; publicadminfalse209O125988003 invoicelineVIEWCREATE VIEW invoiceline AS SELECT invchead.invchead_invcnumber AS invoice_number, invcitem.invcitem_linenumber AS line_number, item.item_number, invcitem.invcitem_number AS misc_item_number, whsinfo.warehous_code AS site, invcitem.invcitem_descrip AS misc_item_description, salescat.salescat_name AS sales_category, invcitem.invcitem_custpn AS customer_part_number, invcitem.invcitem_ordered AS qty_ordered, invcitem.invcitem_billed AS qty_billed, invcitem.invcitem_updateinv AS update_inventory, invcitem.invcitem_price AS net_unit_price, COALESCE(taxtype.taxtype_name, 'None'::text) AS tax_type, COALESCE(qty_uom.uom_name, 'None'::text) AS qty_uom, COALESCE(price_uom.uom_name, 'None'::text) AS price_uom, invcitem.invcitem_notes AS notes, CASE WHEN (invcitem.invcitem_rev_accnt_id IS NOT NULL) THEN public.formatglaccount(invcitem.invcitem_rev_accnt_id) ELSE NULL::text END AS alternate_rev_account FROM (((((((public.invcitem LEFT JOIN public.invchead ON ((invcitem.invcitem_invchead_id = invchead.invchead_id))) LEFT JOIN public.item ON ((item.item_id = invcitem.invcitem_item_id))) LEFT JOIN public.whsinfo ON ((invcitem.invcitem_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.salescat ON ((salescat.salescat_id = invcitem.invcitem_salescat_id))) LEFT JOIN public.taxtype ON ((taxtype.taxtype_id = invcitem.invcitem_taxtype_id))) LEFT JOIN public.uom qty_uom ON ((qty_uom.uom_id = invcitem.invcitem_qty_uom_id))) LEFT JOIN public.uom price_uom ON ((price_uom.uom_id = invcitem.invcitem_price_uom_id))); DROP VIEW api.invoiceline; apiadminfalse88566M&00VIEW invoicelineCOMMENTCOMMENT ON VIEW invoiceline IS ' This view can be used as an interface to import Invoice Line Items data directly into the system. Required fields will be checked and default values will be populated'; apiadminfalse847N&00 invoicelineACLREVOKE ALL ON TABLE invoiceline FROM PUBLIC; REVOKE ALL ON TABLE invoiceline FROM admin; GRANT ALL ON TABLE invoiceline TO admin; GRANT ALL ON TABLE invoiceline TO xtrole; apiadminfalse847\ 125588008&insertinvoicelineitem(api.invoiceline)FUNCTION CREATE FUNCTION insertinvoicelineitem(api.invoiceline) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNew ALIAS FOR $1; _r RECORD; BEGIN INSERT INTO invcitem ( invcitem_invchead_id, invcitem_linenumber, invcitem_item_id, invcitem_warehous_id, invcitem_custpn, invcitem_number, invcitem_descrip, invcitem_ordered, invcitem_billed, invcitem_updateinv, invcitem_custprice, invcitem_price, invcitem_notes, invcitem_salescat_id, invcitem_taxtype_id, invcitem_qty_uom_id, invcitem_qty_invuomratio, invcitem_price_uom_id, invcitem_price_invuomratio, invcitem_rev_accnt_id ) SELECT invchead_id, COALESCE(pNew.line_number,( SELECT (COALESCE(MAX(invcitem_linenumber), 0) + 1) FROM invcitem WHERE (invcitem_invchead_id=invchead_id) )), COALESCE(item_id, -1), COALESCE(getwarehousid(pNew.site,'ALL'),-1), pNew.customer_part_number, (CASE WHEN item_id IS NULL THEN pNew.misc_item_number ELSE NULL END), (CASE WHEN item_id IS NULL THEN pNew.misc_item_description ELSE NULL END), pNew.qty_ordered, COALESCE(pNew.qty_billed, 0), COALESCE(pNew.update_inventory,FALSE), 0, -- invcitem_custprice COALESCE(pNew.net_unit_price,itemPrice(item_id,invchead_cust_id, invchead_shipto_id,pNew.qty_ordered,invchead_curr_id,invchead_orderdate)), COALESCE(pNew.notes,''), CASE WHEN item_id IS NULL THEN (SELECT salescat_id FROM salescat WHERE salescat_name = pNew.sales_category) ELSE NULL END, taxtype_id, CASE WHEN item_id IS NOT NULL THEN COALESCE((SELECT uom_id FROM uom WHERE (uom_name=pNew.qty_uom)), item_price_uom_id) ELSE NULL END, CASE WHEN item_id IS NOT NULL THEN itemuomtouomratio(item_id, COALESCE((SELECT uom_id FROM uom WHERE uom_name=pNew.qty_uom),item_price_uom_id), item_price_uom_id ) ELSE 1 END, CASE WHEN item_id IS NOT NULL THEN COALESCE((SELECT uom_id FROM uom WHERE uom_name=pNew.price_uom),item_price_uom_id) ELSE NULL END, CASE WHEN item_id IS NOT NULL THEN itemuomtouomratio(item_id, COALESCE((SELECT uom_id FROM uom WHERE uom_name=pNew.price_uom),item_price_uom_id), item_price_uom_id ) ELSE 1 END, getGlAccntId(pNew.alternate_rev_account) FROM invchead LEFT OUTER JOIN item ON (item_id=getItemId(pNew.item_number)) LEFT OUTER JOIN taxtype ON (taxtype_id=CASE WHEN pNew.tax_type IS NULL THEN getItemTaxType(item_id,invchead_taxzone_id) WHEN pNew.tax_type = 'None' THEN NULL ELSE (SELECT taxtype_id FROM taxtype WHERE taxtype_name=pNew.tax_type) END) WHERE (invchead_invcnumber=pNew.invoice_number) AND (invchead_posted=FALSE); RETURN TRUE; END; $_$; =DROP FUNCTION public.insertinvoicelineitem(api.invoiceline); publicadminfalse446984623125578947;insertitemcost(integer, integer, integer, numeric, boolean)FUNCTION7 CREATE FUNCTION insertitemcost(integer, integer, integer, numeric, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemId ALIAS FOR $1; pCostElemId ALIAS FOR $2; pCurrId ALIAS FOR $3; pCost ALIAS FOR $4; pPostToStandard ALIAS FOR $5; _itemcost_id INTEGER; _update_return INTEGER; _postcost_return BOOLEAN; --This function is used with the api.itemcost View for updating and inserting --into the itemcosts table BEGIN IF (pCost IS NULL OR pCost < 0) THEN RAISE EXCEPTION 'itemcost Actual Cost Invalid ', pCost; END IF; -- Check for uniqueness SELECT itemcost_id INTO _itemcost_id FROM itemcost WHERE ( (itemcost_item_id = pItemId) AND (itemcost_costelem_id = pCostElemId) AND (NOT itemcost_lowlevel) ); IF (FOUND) THEN RAISE EXCEPTION 'itemcost already exists for this Item and Cost Element'; END IF; -- Check for valid combination of item_type and costelem_type IF (SELECT (COUNT(*) > 0) FROM item, costelem WHERE (item_id=pItemId) AND (costelem_id=pCostElemId) AND (item_type IN ('M', 'F', 'B', 'C', 'T')) AND (costelem_type IN ('Material'))) THEN RAISE EXCEPTION 'itemcost of this type is invalid for Manufactured Item'; END IF; IF (SELECT (COUNT(*) > 0) FROM item, costelem WHERE (item_id=pItemId) AND (costelem_id=pCostElemId) AND (item_type IN ('O', 'P')) AND (costelem_type IN ('Direct Labor', 'Overhead', 'Machine Overhead'))) THEN RAISE EXCEPTION 'itemcost of this type is invalid for Purchased Item'; END IF; IF (pCost > 0) THEN SELECT NEXTVAL('itemcost_itemcost_id_seq') INTO _itemcost_id; INSERT INTO itemcost ( itemcost_id, itemcost_item_id, itemcost_costelem_id, itemcost_lowlevel, itemcost_stdcost, itemcost_posted, itemcost_actcost, itemcost_updated, itemcost_curr_id ) VALUES ( _itemcost_id, pItemId, pCostElemId, FALSE, 0, startOfTime(), pCost, CURRENT_DATE, pCurrId ); --Only Post Cost to standard if the parameter is set to true IF (pPostToStandard) THEN IF (NOT checkPrivilege('PostStandardCosts')) THEN RAISE EXCEPTION 'You do not have privileges to poststandard itemcosts. Set api.itemcost post_to_standard to false'; END IF; SELECT postcost(_itemcost_id) INTO _postcost_return; IF (NOT _postcost_return) THEN RETURN -2; END IF; END IF; ELSE RETURN -1; END IF; RETURN _itemcost_id; END; $_$; RDROP FUNCTION public.insertitemcost(integer, integer, integer, numeric, boolean); publicadminfalse84623125578948insertsalesline(api.salesline)FUNCTION CREATE FUNCTION insertsalesline(api.salesline) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNEW ALIAS FOR $1; _r RECORD; BEGIN IF (NOT EXISTS (SELECT cohead_id FROM cohead WHERE cohead_number=pNEW.order_number)) THEN RAISE EXCEPTION 'Function insertSalesLine failed because Sales Order % not found', pNEW.order_number; END IF; IF (NOT EXISTS (SELECT item_id FROM item WHERE item_number=pNEW.item_number)) THEN RAISE EXCEPTION 'Function insertSalesLine failed because Item Number % not found', pNEW.item_number; END IF; SELECT * INTO _r FROM cohead, itemsite, item, whsinfo WHERE ((cohead_number=pNEW.order_number) AND (itemsite_warehous_id=warehous_id AND (itemsite_item_id=item_id) AND (itemsite_active) AND (item_number=pNEW.item_number) AND (warehous_active) AND (warehous_id=COALESCE(getWarehousId(pNEW.sold_from_site,'ALL'),cohead_warehous_id,fetchprefwarehousid())))); IF (NOT FOUND) THEN RAISE EXCEPTION 'Function insertSalesLine failed with unknown failure to retrieve Sales Order'; END IF; INSERT INTO coitem ( coitem_cohead_id, coitem_linenumber, coitem_itemsite_id, coitem_status, coitem_scheddate, coitem_promdate, coitem_qtyord, coitem_qty_uom_id, coitem_qty_invuomratio, coitem_qtyshipped, coitem_unitcost, coitem_price, coitem_price_uom_id, coitem_price_invuomratio, coitem_custprice, coitem_order_id, coitem_memo, coitem_imported, coitem_qtyreturned, coitem_custpn, coitem_order_type, coitem_substitute_item_id, coitem_prcost, coitem_taxtype_id, coitem_warranty, coitem_cos_accnt_id, coitem_rev_accnt_id) VALUES ( _r.cohead_id, pNEW.line_number::INTEGER, _r.itemsite_id, pNEW.status, pNEW.scheduled_date, pNEW.promise_date, pNEW.qty_ordered, COALESCE(getUomId(pNEW.qty_uom),_r.item_inv_uom_id), itemuomtouomratio(_r.item_id,COALESCE(getUomId(pNEW.qty_uom),_r.item_inv_uom_id),_r.item_inv_uom_id), 0, stdCost(_r.item_id), COALESCE(pNEW.net_unit_price,itemPrice(_r.item_id,_r.cohead_cust_id, _r.cohead_shipto_id,pNEW.qty_ordered,_r.cohead_curr_id,_r.cohead_orderdate)), COALESCE(getUomId(pNEW.price_uom),_r.item_price_uom_id), itemuomtouomratio(_r.item_id,COALESCE(getUomId(pNEW.price_uom),_r.item_price_uom_id),_r.item_price_uom_id), itemPrice(_r.item_id,_r.cohead_cust_id,_r.cohead_shipto_id,pNEW.qty_ordered,_r.cohead_curr_id,_r.cohead_orderdate), -1, pNEW.notes, true, 0, pNEW.customer_pn, CASE WHEN ((pNEW.create_order AND (_r.item_type = 'M')) OR ((pNEW.create_order IS NULL) AND _r.itemsite_createwo)) THEN 'W' WHEN ((pNEW.create_order AND (_r.item_type = 'P')) OR ((pNEW.create_order IS NULL) AND _r.itemsite_createsopr)) THEN 'R' WHEN ((pNEW.create_order AND (_r.item_type = 'P') AND (_r.itemsite_createsopo)) OR ((pNEW.create_order IS NULL) AND _r.itemsite_createsopo)) THEN 'P' END, getitemid(pNEW.substitute_for), pNEW.overwrite_po_price, COALESCE(getTaxTypeId(pNEW.tax_type), getItemTaxType(_r.itemsite_item_id, _r.cohead_taxzone_id)), pNEW.warranty, getGlAccntId(pNEW.alternate_cos_account), getGlAccntId(pNEW.alternate_rev_account) ); RETURN TRUE; END; $_$; 5DROP FUNCTION public.insertsalesline(api.salesline); publicadminfalse8462327774125578949intervaltominutes(interval)FUNCTIONCREATE FUNCTION intervaltominutes(interval) RETURNS numeric LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT (EXTRACT(DAY FROM $1) * 24 * 60 + EXTRACT(HOUR FROM $1) * 60 + EXTRACT(MINUTE FROM $1) + ROUND((EXTRACT(SECOND FROM $1) / 60)::NUMERIC, 4))::NUMERIC AS result $_$; 2DROP FUNCTION public.intervaltominutes(interval); publicadminfalse8?125578950+invadjustment(integer, numeric, text, text)FUNCTION=CREATE FUNCTION invadjustment(integer, numeric, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN invAdjustment($1, $2, $3, $4, CURRENT_TIMESTAMP, NULL); END; $_$; BDROP FUNCTION public.invadjustment(integer, numeric, text, text); publicadminfalse84623125578951Einvadjustment(integer, numeric, text, text, timestamp with time zone)FUNCTIONHCREATE FUNCTION invadjustment(integer, numeric, text, text, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN invAdjustment($1, $2, $3, $4, $5, NULL); END; $_$; \DROP FUNCTION public.invadjustment(integer, numeric, text, text, timestamp with time zone); publicadminfalse46238125578952Ninvadjustment(integer, numeric, text, text, timestamp with time zone, numeric)FUNCTIONCREATE FUNCTION invadjustment(integer, numeric, text, text, timestamp with time zone, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pQty ALIAS FOR $2; pDocumentNumber ALIAS FOR $3; pComments ALIAS FOR $4; pGlDistTS ALIAS FOR $5; pCostValue ALIAS FOR $6; _invhistid INTEGER; _itemlocSeries INTEGER; BEGIN -- Make sure the passed itemsite points to a real item IF ( ( SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J') FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ) ) ) THEN RETURN 0; END IF; SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; SELECT postInvTrans( itemsite_id, 'AD', pQty, 'I/M', 'AD', pDocumentNumber, '', ('Miscellaneous Adjustment for item ' || item_number || E'\n' || pComments), costcat_asset_accnt_id, costcat_adjustment_accnt_id, _itemlocSeries, pGlDistTS, pCostValue) INTO _invhistid FROM itemsite, item, costcat WHERE ( (itemsite_item_id=item_id) AND (itemsite_costcat_id=costcat_id) AND (itemsite_id=pItemsiteid) ); RETURN _itemlocSeries; END; $_$; eDROP FUNCTION public.invadjustment(integer, numeric, text, text, timestamp with time zone, numeric); publicadminfalse84623125578953Tinvexpense(integer, numeric, integer, text, text, timestamp with time zone, integer)FUNCTIONCREATE FUNCTION invexpense(pitemsiteid integer, pqty numeric, pexpcatid integer, pdocumentnumber text, pcomments text, pgldistts timestamp with time zone DEFAULT now(), pprjid integer DEFAULT NULL::integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _invhistid INTEGER; _itemlocSeries INTEGER; BEGIN -- Make sure the passed itemsite points to a real item IF ( ( SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J') FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ) ) ) THEN RETURN 0; END IF; SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; SELECT postInvTrans( itemsite_id, 'EX', pQty, 'I/M', 'EX', pDocumentNumber, '', CASE WHEN (pQty < 0) THEN ('Reverse Material Expense for item ' || item_number || E'\n' || pComments) ELSE ('Material Expense for item ' || item_number || E'\n' || pComments) END, getPrjAccntId(pPrjid, expcat_exp_accnt_id), costcat_asset_accnt_id, _itemlocSeries, pGlDistTS) INTO _invhistid FROM itemsite, item, costcat, expcat WHERE ( (itemsite_item_id=item_id) AND (itemsite_costcat_id=costcat_id) AND (itemsite_id=pItemsiteid) AND (expcat_id=pExpcatid) ); INSERT INTO invhistexpcat (invhistexpcat_invhist_id, invhistexpcat_expcat_id) VALUES (_invhistid, pExpcatid); RETURN _itemlocSeries; END; $$; DROP FUNCTION public.invexpense(pitemsiteid integer, pqty numeric, pexpcatid integer, pdocumentnumber text, pcomments text, pgldistts timestamp with time zone, pprjid integer); publicadminfalse84623125578954invhistsense(integer)FUNCTIONCREATE FUNCTION invhistsense(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvhistId ALIAS FOR $1; _count INTEGER; _row RECORD; _sense INTEGER; BEGIN SELECT invhist_transtype, invhist_ordnumber, itemsite_warehous_id INTO _row FROM invhist JOIN itemsite ON (itemsite_id=invhist_itemsite_id) WHERE (invhist_id=pInvhistId); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count = 0) THEN RAISE EXCEPTION 'Record not found for invhist_id=%',pInvhistId; END IF; -- increase inventory: AD RM RT RP RR RS RX RB TR -- decrease inventory: IM IB IT SH SI EX RI -- TS and TR are special: shipShipment and recallShipment should not change -- QOH at the Transfer Order src whs (as this was done by issueToShipping) -- but postReceipt should change QOH at the transit whs IF (_row.invhist_transtype='TS') THEN _sense := CASE WHEN (SELECT tohead_trns_warehous_id=_row.itemsite_warehous_id FROM tohead WHERE (tohead_number=_row.invhist_ordnumber)) THEN -1 ELSE 0 END; ELSIF (_row.invhist_transtype='TR') THEN _sense := CASE WHEN (SELECT tohead_src_warehous_id=_row.itemsite_warehous_id FROM tohead WHERE (tohead_number=_row.invhist_ordnumber)) THEN 0 ELSE 1 END; ELSIF (_row.invhist_transtype IN ('IM', 'IB', 'IT', 'SH', 'SI', 'EX', 'RI')) THEN _sense := -1; ELSE _sense := 1; END IF; RETURN _sense; END; $_$; ,DROP FUNCTION public.invhistsense(integer); publicadminfalse46238125578955 invhisttrig()FUNCTIONgCREATE FUNCTION invhisttrig() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN -- Need to allow 'temporary' negative for average costed item that has been frozen. -- Check at itemsite after all of the transactions have been thawed will ensure -- that final Qty On Hand is positive. -- IF (NEW.invhist_qoh_after < 0 AND NEW.invhist_costmethod = 'A') THEN -- RAISE EXCEPTION 'Invhist (%) is recording with average costing and is not allowed to have a negative quantity on hand.', NEW.invhist_id; -- END IF; -- #19160 Exclude frozen check when "Edit Transaction" ABC analyze flag is amended IF ( (TG_OP = 'INSERT') OR (TG_OP = 'UPDATE' AND OLD.invhist_analyze = NEW.invhist_analyze)) THEN IF ( ( SELECT itemsite_freeze FROM itemsite WHERE (itemsite_id=NEW.invhist_itemsite_id) ) ) THEN NEW.invhist_posted = FALSE; END IF; END IF; -- never change the created timestamp, which defaults to CURRENT_TIMESTAMP IF (TG_OP != 'INSERT') THEN NEW.invhist_created = OLD.invhist_created; ELSE -- Always need a series id for distribution posting IF (NEW.invhist_series IS NULL) THEN RAISE EXCEPTION 'Column invhist_series may not be null.'; END IF; END IF; RETURN NEW; END; $$; $DROP FUNCTION public.invhisttrig(); publicadminfalse46238125578956invoicetotal(integer)FUNCTION CREATE FUNCTION invoicetotal(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvoiceId ALIAS FOR $1; _linesum NUMERIC; _linetax NUMERIC; _result NUMERIC; _allocated NUMERIC; _posted BOOLEAN; BEGIN SELECT SUM(ROUND(COALESCE((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / COALESCE(invcitem_price_invuomratio,1)), 0),2)) INTO _linesum FROM invcitem WHERE (invcitem_invchead_id=pInvoiceId); -- TODO: why sum on the result of select round(sum(), 2)? SELECT SUM(tax) INTO _linetax FROM (SELECT ROUND(SUM(COALESCE(taxdetail_tax, 0)),2) AS tax FROM tax JOIN calculateTaxDetailSummary('I', pInvoiceId, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id) AS data; SELECT noNeg(invchead_freight + invchead_misc_amount + COALESCE(_linetax, 0) + COALESCE(_linesum, 0)), invchead_posted INTO _result, _posted FROM invchead WHERE (invchead_id=pInvoiceId); IF NOT FOUND THEN RETURN 0; END IF; IF (_posted) THEN SELECT COALESCE(SUM(currToCurr(arapply_curr_id, aropen_curr_id, arapply_applied, aropen_docdate)),0) INTO _allocated FROM arapply, aropen, invchead WHERE ( (invchead_posted) AND (invchead_id=pInvoiceId) AND (aropen_docnumber=invchead_invcnumber) AND (aropen_doctype='I') AND (arapply_target_aropen_id=aropen_id) AND (arapply_reftype='S') AND (invchead_posted) ) ; ELSE SELECT COALESCE(SUM(CASE WHEN((aropen_amount - aropen_paid) >= currToCurr(aropenalloc_curr_id, aropen_curr_id, aropenalloc_amount, aropen_docdate)) THEN currToCurr(aropenalloc_curr_id, invchead_curr_id, aropenalloc_amount, aropen_docdate) ELSE currToCurr(aropen_curr_id, invchead_curr_id, aropen_amount - aropen_paid, aropen_docdate) END),0) INTO _allocated FROM invchead LEFT OUTER JOIN cohead ON (cohead_number=invchead_ordernumber) JOIN aropenalloc ON ((aropenalloc_doctype='I' AND aropenalloc_doc_id=invchead_id) OR (aropenalloc_doctype='S' AND aropenalloc_doc_id=cohead_id)) JOIN aropen ON (aropen_id=aropenalloc_aropen_id AND (aropen_amount - aropen_paid) > 0.0) WHERE ( (NOT invchead_posted) AND (invchead_id=pInvoiceId) ); END IF; RETURN _result - COALESCE(_allocated, 0); END; $_$; ,DROP FUNCTION public.invoicetotal(integer); publicadminfalse46238125578957.invreceipt(integer, numeric, text, text, text)FUNCTIONACREATE FUNCTION invreceipt(integer, numeric, text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN invReceipt($1, $2, $3, $4, $5, CURRENT_TIMESTAMP, NULL); END; $_$; EDROP FUNCTION public.invreceipt(integer, numeric, text, text, text); publicadminfalse84623125578958Hinvreceipt(integer, numeric, text, text, text, timestamp with time zone)FUNCTIONLCREATE FUNCTION invreceipt(integer, numeric, text, text, text, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN invReceipt($1, $2, $3, $4, $5, $6, NULL); END; $_$; _DROP FUNCTION public.invreceipt(integer, numeric, text, text, text, timestamp with time zone); publicadminfalse46238125578959Qinvreceipt(integer, numeric, text, text, text, timestamp with time zone, numeric)FUNCTION|CREATE FUNCTION invreceipt(integer, numeric, text, text, text, timestamp with time zone, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pQty ALIAS FOR $2; pOrdernumber ALIAS FOR $3; pDocumentNumber ALIAS FOR $4; pComments ALIAS FOR $5; pGlDistTS ALIAS FOR $6; pCostValue ALIAS FOR $7; _invhistid INTEGER; _itemlocSeries INTEGER; BEGIN -- Make sure the passed itemsite points to a real item IF ( ( SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J') FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ) ) ) THEN RETURN 0; END IF; SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; SELECT postInvTrans( itemsite_id, 'RX', pQty, 'I/M', 'RX', pDocumentNumber, '', ('Miscellaneous Receipt for item ' || item_number || E'\n' || pComments), costcat_asset_accnt_id, costcat_liability_accnt_id, _itemlocSeries, pGlDistTS, pCostValue) INTO _invhistid FROM itemsite, item, costcat WHERE ( (itemsite_item_id=item_id) AND (itemsite_costcat_id=costcat_id) AND (itemsite_id=pItemsiteid) ); RETURN _itemlocSeries; END; $_$; hDROP FUNCTION public.invreceipt(integer, numeric, text, text, text, timestamp with time zone, numeric); publicadminfalse46238125578960&invscrap(integer, numeric, text, text)FUNCTION-CREATE FUNCTION invscrap(integer, numeric, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN invScrap($1, $2, $3, $4, CURRENT_TIMESTAMP); END; $_$; =DROP FUNCTION public.invscrap(integer, numeric, text, text); publicadminfalse46238125578961@invscrap(integer, numeric, text, text, timestamp with time zone)FUNCTION>CREATE FUNCTION invscrap(integer, numeric, text, text, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN invScrap($1, $2, $3, $4, $5, NULL); END; $_$; WDROP FUNCTION public.invscrap(integer, numeric, text, text, timestamp with time zone); publicadminfalse84623125578962Iinvscrap(integer, numeric, text, text, timestamp with time zone, integer)FUNCTIONKCREATE FUNCTION invscrap(integer, numeric, text, text, timestamp with time zone, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN invScrap($1, $2, $3, $4, $5, $6, NULL); END; $_$; `DROP FUNCTION public.invscrap(integer, numeric, text, text, timestamp with time zone, integer); publicadminfalse84623125578963Rinvscrap(integer, numeric, text, text, timestamp with time zone, integer, integer)FUNCTIONCREATE FUNCTION invscrap(integer, numeric, text, text, timestamp with time zone, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pQty ALIAS FOR $2; pDocumentNumber ALIAS FOR $3; pComments ALIAS FOR $4; pGlDistTS ALIAS FOR $5; pInvHistId ALIAS FOR $6; pPrjid ALIAS FOR $7; _invhistid INTEGER; _itemlocSeries INTEGER; BEGIN -- Make sure the passed itemsite points to a real item IF ( ( SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J') FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ) ) ) THEN RETURN 0; END IF; IF (pInvHistId IS NOT NULL) THEN SELECT invhist_series INTO _itemlocSeries FROM invhist WHERE invhist_id=pInvHistId; ELSE SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; END IF; SELECT postInvTrans( itemsite_id, 'SI', pQty, 'I/M', 'SI', pDocumentNumber, '', CASE WHEN (pQty < 0) THEN ('Reverse Material Scrap for item ' || item_number || E'\n' || pComments) ELSE ('Material Scrap for item ' || item_number || E'\n' || pComments) END, getPrjAccntId(pPrjid, costcat_scrap_accnt_id), costcat_asset_accnt_id, _itemlocSeries, pGlDistTS, NULL, pInvHistId) INTO _invhistid FROM itemsite, item, costcat WHERE ( (itemsite_item_id=item_id) AND (itemsite_costcat_id=costcat_id) AND (itemsite_id=pItemsiteid) ); RETURN _itemlocSeries; END; $_$; iDROP FUNCTION public.invscrap(integer, numeric, text, text, timestamp with time zone, integer, integer); publicadminfalse84623125578964 isdba(text)FUNCTIONCREATE FUNCTION isdba(text DEFAULT NULL::text) RETURNS boolean LANGUAGE sql AS $_$ SELECT (datdba=pg_roles.oid OR rolsuper) AS issuper FROM pg_database, pg_roles WHERE ((datname=current_database()) AND (rolname=COALESCE($1, getEffectiveXtUser()))); $_$; "DROP FUNCTION public.isdba(text); publicadminfalse8125578965 ismulticurr()FUNCTION#CREATE FUNCTION ismulticurr() RETURNS boolean LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN (SELECT (count(*) > 1) FROM curr_symbol); END; $$; $DROP FUNCTION public.ismulticurr(); publicadminfalse46238125578966isnumeric(text)FUNCTIONvCREATE FUNCTION isnumeric(text) RETURNS boolean LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pText ALIAS FOR $1; _cursor INTEGER; BEGIN IF ( (LENGTH(pText) = 0) OR (pText IS NULL) ) THEN RETURN FALSE; END IF; FOR _cursor IN 1..LENGTH(pText) LOOP IF (SUBSTRING(pText FROM _cursor FOR 1) NOT IN ( '0', '1', '2', '3', '4', '5' ,'6' ,'7' ,'8' ,'9' )) THEN RETURN FALSE; END IF; END LOOP; RETURN TRUE; END; $_$; &DROP FUNCTION public.isnumeric(text); publicadminfalse84623125578967"issueallbalancetoshipping(integer)FUNCTION*CREATE FUNCTION issueallbalancetoshipping(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN issueAllBalanceToShipping('SO', $1, 0, NULL); END; $_$; 9DROP FUNCTION public.issueallbalancetoshipping(integer); publicadminfalse46238125578968Kissueallbalancetoshipping(text, integer, integer, timestamp with time zone)FUNCTION6CREATE FUNCTION issueallbalancetoshipping(text, integer, integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; pheadid ALIAS FOR $2; _itemlocSeries INTEGER := $3; _timestamp TIMESTAMP WITH TIME ZONE := $4; _s RECORD; BEGIN IF (pordertype = 'SO') THEN FOR _s IN SELECT coitem_id, CASE WHEN (fetchMetricBool('RequireSOReservations')) THEN coitem_qtyreserved ELSE noNeg( coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping('SO', coitem_id) ) END AS _balance FROM coitem LEFT OUTER JOIN (itemsite JOIN item ON (itemsite_item_id=item_id)) ON (coitem_itemsite_id=itemsite_id) WHERE ( (coitem_status NOT IN ('C','X')) AND (item_type != 'K') AND (coitem_cohead_id=pheadid) ) LOOP IF (_s.balance <> 0) THEN _itemlocSeries := issueToShipping(pordertype, _s.coitem_id, _s.balance, _itemlocSeries, _timestamp); IF (_itemlocSeries < 0) THEN EXIT; END IF; END IF; END LOOP; ELSEIF (pordertype = 'TO') THEN FOR _s IN SELECT toitem_id, noNeg( toitem_qty_ordered - toitem_qty_shipped - qtyAtShipping('TO', toitem_id) ) AS balance FROM toitem WHERE ( (toitem_status NOT IN ('C','X')) AND (toitem_tohead_id=pheadid) ) LOOP IF (_s.balance <> 0) THEN _itemlocSeries := issueToShipping(pordertype, _s.toitem_id, _s.balance, _itemlocSeries, _timestamp); IF (_itemlocSeries < 0) THEN EXIT; END IF; END IF; END LOOP; ELSE RETURN -1; END IF; RETURN _itemlocSeries; END; $_$; bDROP FUNCTION public.issueallbalancetoshipping(text, integer, integer, timestamp with time zone); publicadminfalse46238125578969#issuelinebalancetoshipping(integer)FUNCTION)CREATE FUNCTION issuelinebalancetoshipping(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN issueLineBalanceToShipping('SO', $1, NULL); END; $_$; :DROP FUNCTION public.issuelinebalancetoshipping(integer); publicadminfalse84623125578970Cissuelinebalancetoshipping(text, integer, timestamp with time zone)FUNCTIONNCREATE FUNCTION issuelinebalancetoshipping(text, integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN issueLineBalanceToShipping($1, $2, $3, 0, NULL); END; $_$; ZDROP FUNCTION public.issuelinebalancetoshipping(text, integer, timestamp with time zone); publicadminfalse84623125578971Uissuelinebalancetoshipping(text, integer, timestamp with time zone, integer, integer)FUNCTIONCREATE FUNCTION issuelinebalancetoshipping(text, integer, timestamp with time zone, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; pitemid ALIAS FOR $2; ptimestamp ALIAS FOR $3; pitemlocseries ALIAS FOR $4; pinvhistid ALIAS FOR $5; _itemlocSeries INTEGER := 0; _qty NUMERIC; BEGIN _itemlocSeries := COALESCE(pitemlocseries,0); IF (pordertype = 'SO') THEN SELECT CASE WHEN (fetchMetricBool('RequireSOReservations')) THEN coitem_qtyreserved ELSE noNeg( coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping('SO', coitem_id) ) END INTO _qty FROM coitem WHERE (coitem_id=pitemid); ELSEIF (pordertype = 'TO') THEN SELECT noNeg( toitem_qty_ordered - toitem_qty_shipped - qtyAtShipping('TO', toitem_id) ) INTO _qty FROM toitem WHERE (toitem_id=pitemid); ELSE RETURN -1; END IF; IF (_qty > 0) THEN _itemlocSeries := issueToShipping(pordertype, pitemid, _qty, _itemlocSeries, ptimestamp, pinvhistid); END IF; RETURN _itemlocSeries; END; $_$; lDROP FUNCTION public.issuelinebalancetoshipping(text, integer, timestamp with time zone, integer, integer); publicadminfalse84623125578972 issues(text)FUNCTIONcCREATE FUNCTION issues(text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTransType ALIAS FOR $1; BEGIN IF (pTransType IN ('IM', 'IB', 'IT')) THEN RETURN TRUE; ELSE RETURN FALSE; END IF; END; $_$; #DROP FUNCTION public.issues(text); publicadminfalse84623125578973!issuetoshipping(integer, numeric)FUNCTION0CREATE FUNCTION issuetoshipping(integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN issueToShipping('SO', $1, $2, 0, CURRENT_TIMESTAMP); END; $_$; 8DROP FUNCTION public.issuetoshipping(integer, numeric); publicadminfalse84623125578974*issuetoshipping(integer, numeric, integer)FUNCTION:CREATE FUNCTION issuetoshipping(integer, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN issueToShipping('SO', $1, $2, $3, CURRENT_TIMESTAMP); END; $_$; ADROP FUNCTION public.issuetoshipping(integer, numeric, integer); publicadminfalse46238125578975Jissuetoshipping(text, integer, numeric, integer, timestamp with time zone)FUNCTIONOCREATE FUNCTION issuetoshipping(text, integer, numeric, integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN issueToShipping($1, $2, $3, $4, $5, NULL); END; $_$; aDROP FUNCTION public.issuetoshipping(text, integer, numeric, integer, timestamp with time zone); publicadminfalse46238125578976Sissuetoshipping(text, integer, numeric, integer, timestamp with time zone, integer)FUNCTION%CREATE FUNCTION issuetoshipping(pordertype text, pitemid integer, pqty numeric, pitemlocseries integer, ptimestamp timestamp with time zone, pinvhistid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _itemlocSeries INTEGER; _timestamp TIMESTAMP WITH TIME ZONE; _coholdtype TEXT; _balance NUMERIC; _invhistid INTEGER; _shipheadid INTEGER; _shipnumber INTEGER; _cntctid INTEGER; _p RECORD; _m RECORD; _value NUMERIC; _warehouseid INTEGER; _shipitemid INTEGER; _freight NUMERIC; BEGIN IF (pTimestamp IS NULL) THEN _timestamp := CURRENT_TIMESTAMP; ELSE _timestamp := pTimestamp; END IF; IF (pItemlocSeries = 0) THEN _itemlocSeries := NEXTVAL('itemloc_series_seq'); ELSE _itemlocSeries := pItemlocSeries; END IF; IF (pordertype = 'SO') THEN -- Check site security SELECT warehous_id INTO _warehouseid FROM coitem,itemsite,site() WHERE ((coitem_id=pitemid) AND (itemsite_id=coitem_itemsite_id) AND (warehous_id=itemsite_warehous_id)); IF (NOT FOUND) THEN RETURN 0; END IF; -- Check for average cost items going negative IF ( SELECT ( (itemsite_costmethod='A') AND ((itemsite_qtyonhand - round(pQty * coitem_qty_invuomratio, 6)) < 0.0) ) FROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id) WHERE (coitem_id=pitemid) ) THEN RETURN -20; END IF; -- Check auto registration IF ( SELECT COALESCE(itemsite_autoreg, FALSE) FROM coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id) WHERE (coitem_id=pitemid) ) THEN SELECT COALESCE(crmacct_cntct_id_1, -1) INTO _cntctid FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id) JOIN crmacct ON (crmacct_cust_id=cohead_cust_id) WHERE (coitem_id=pitemid); IF (_cntctid = -1) THEN RETURN -15; END IF; END IF; -- Check Credit Hold SELECT cohead_holdtype INTO _coholdtype FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id) WHERE (coitem_id=pitemid); SELECT calcSalesOrderAmt(cohead_id) - COALESCE(SUM(currToCurr(aropenalloc_curr_id, cohead_curr_id, aropenalloc_amount, cohead_orderdate)),0) INTO _balance FROM coitem JOIN cohead ON (cohead_id=coitem_cohead_id) LEFT OUTER JOIN aropenalloc ON (aropenalloc_doctype='S' AND aropenalloc_doc_id=cohead_id) WHERE (coitem_id=pitemid) GROUP BY cohead_id; --RAISE NOTICE 'issueToShipping - order balance is %', _balance; IF ( (_coholdtype = 'C') AND (_balance > 0.0) ) THEN RETURN -12; ELSIF (_coholdtype = 'P') THEN RETURN -13; ELSIF (_coholdtype = 'R') THEN RETURN -14; END IF; SELECT shiphead_id INTO _shipheadid FROM shiphead, coitem JOIN itemsite ON (itemsite_id=coitem_itemsite_id) WHERE ( (coitem_id=pitemid) AND (shiphead_number=getOpenShipment(pordertype, coitem_cohead_id, itemsite_warehous_id)) ); IF (NOT FOUND) THEN SELECT NEXTVAL('shiphead_shiphead_id_seq') INTO _shipheadid; _shipnumber := fetchShipmentNumber(); IF (_shipnumber < 0) THEN RETURN -10; END IF; INSERT INTO shiphead ( shiphead_id, shiphead_number, shiphead_order_id, shiphead_order_type, shiphead_shipped, shiphead_sfstatus, shiphead_shipvia, shiphead_shipchrg_id, shiphead_freight, shiphead_freight_curr_id, shiphead_shipdate, shiphead_notes, shiphead_shipform_id ) SELECT _shipheadid, _shipnumber, coitem_cohead_id, pordertype, FALSE, 'N', cohead_shipvia, CASE WHEN (cohead_shipchrg_id <= 0) THEN NULL ELSE cohead_shipchrg_id END, cohead_freight, cohead_curr_id, _timestamp::DATE, cohead_shipcomments, CASE WHEN cohead_shipform_id = -1 THEN NULL ELSE cohead_shipform_id END FROM cohead, coitem WHERE ((coitem_cohead_id=cohead_id) AND (coitem_id=pitemid) ); UPDATE pack SET pack_shiphead_id = _shipheadid, pack_printed = FALSE FROM coitem WHERE ((pack_head_id=coitem_cohead_id) AND (pack_shiphead_id IS NULL) AND (pack_head_type='SO') AND (coitem_id=pitemid)); ELSE UPDATE pack SET pack_printed = FALSE FROM coitem WHERE ((pack_head_id=coitem_cohead_id) AND (pack_shiphead_id=_shipheadid) AND (pack_head_type='SO') AND (coitem_id=pitemid)); END IF; -- Handle g/l transaction SELECT postInvTrans( itemsite_id, 'SH', (pQty * coitem_qty_invuomratio), 'S/R', porderType, formatSoNumber(coitem_id), shiphead_number, ('Issue ' || item_number || ' to Shipping for customer ' || cohead_billtoname), getPrjAccntId(cohead_prj_id, costcat_shipasset_accnt_id), costcat_asset_accnt_id, _itemlocSeries, _timestamp, NULL, pinvhistid ) INTO _invhistid FROM coitem, cohead, itemsite, item, costcat, shiphead WHERE ( (coitem_cohead_id=cohead_id) AND (coitem_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (itemsite_costcat_id=costcat_id) AND (coitem_id=pitemid) AND (shiphead_id=_shipheadid) ); SELECT (invhist_unitcost * invhist_invqty) INTO _value FROM invhist WHERE (invhist_id=_invhistid); _shipitemid := nextval('shipitem_shipitem_id_seq'); INSERT INTO shipitem ( shipitem_id, shipitem_shiphead_id, shipitem_orderitem_id, shipitem_qty, shipitem_transdate, shipitem_trans_username, shipitem_invoiced, shipitem_value, shipitem_invhist_id ) VALUES ( _shipitemid, _shipheadid, pitemid, pQty, _timestamp, getEffectiveXtUser(), FALSE, _value, CASE WHEN _invhistid = -1 THEN NULL ELSE _invhistid END ); -- Handle reservation IF (fetchmetricbool('EnableSOReservations')) THEN -- Remember what was reserved so we can re-reserve if this issue is returned INSERT INTO shipitemrsrv (shipitemrsrv_shipitem_id, shipitemrsrv_qty) SELECT _shipitemid, least(pQty,coitem_qtyreserved) FROM coitem WHERE ((coitem_id=pitemid) AND (coitem_qtyreserved > 0)); -- Update sales order UPDATE coitem SET coitem_qtyreserved = noNeg(coitem_qtyreserved - pQty) WHERE(coitem_id=pitemid); END IF; -- Calculate shipment freight SELECT calcShipFreight(_shipheadid) INTO _freight; UPDATE shiphead SET shiphead_freight=_freight WHERE (shiphead_id=_shipheadid); ELSEIF (pordertype = 'TO') THEN -- Check site security IF (fetchMetricBool('MultiWhs')) THEN SELECT warehous_id INTO _warehouseid FROM toitem, tohead, site() WHERE ( (toitem_id=pitemid) AND (tohead_id=toitem_tohead_id) AND (warehous_id=tohead_src_warehous_id) ); IF (NOT FOUND) THEN RETURN 0; END IF; END IF; SELECT postInvTrans( itemsite_id, 'SH', pQty, 'S/R', pordertype, formatToNumber(toitem_id), '', 'Issue to Shipping', costcat_shipasset_accnt_id, costcat_asset_accnt_id, _itemlocSeries, _timestamp) INTO _invhistid FROM tohead, toitem, itemsite, costcat WHERE ((tohead_id=toitem_tohead_id) AND (itemsite_item_id=toitem_item_id) AND (itemsite_warehous_id=tohead_src_warehous_id) AND (itemsite_costcat_id=costcat_id) AND (toitem_id=pitemid) ); SELECT (invhist_unitcost * invhist_invqty) INTO _value FROM invhist WHERE (invhist_id=_invhistid); SELECT shiphead_id INTO _shipheadid FROM shiphead, toitem JOIN tohead ON (tohead_id=toitem_tohead_id) WHERE ( (toitem_id=pitemid) AND (shiphead_number=getOpenShipment(pordertype, tohead_id, tohead_src_warehous_id)) ); IF (NOT FOUND) THEN _shipheadid := NEXTVAL('shiphead_shiphead_id_seq'); _shipnumber := fetchShipmentNumber(); IF (_shipnumber < 0) THEN RETURN -10; END IF; INSERT INTO shiphead ( shiphead_id, shiphead_number, shiphead_order_id, shiphead_order_type, shiphead_shipped, shiphead_sfstatus, shiphead_shipvia, shiphead_shipchrg_id, shiphead_freight, shiphead_freight_curr_id, shiphead_shipdate, shiphead_notes, shiphead_shipform_id ) SELECT _shipheadid, _shipnumber, tohead_id, pordertype, FALSE, 'N', tohead_shipvia, tohead_shipchrg_id, tohead_freight + SUM(toitem_freight), tohead_freight_curr_id, _timestamp::DATE, tohead_shipcomments, tohead_shipform_id FROM tohead, toitem WHERE ((toitem_tohead_id=tohead_id) AND (tohead_id IN (SELECT toitem_tohead_id FROM toitem WHERE (toitem_id=pitemid))) ) GROUP BY tohead_id, tohead_shipvia, tohead_shipchrg_id, tohead_freight, tohead_freight_curr_id, tohead_shipcomments, tohead_shipform_id; END IF; INSERT INTO shipitem ( shipitem_shiphead_id, shipitem_orderitem_id, shipitem_qty, shipitem_transdate, shipitem_trans_username, shipitem_invoiced, shipitem_value, shipitem_invhist_id ) VALUES ( _shipheadid, pitemid, pQty, _timestamp, getEffectiveXtUser(), FALSE, _value, CASE WHEN _invhistid = -1 THEN NULL ELSE _invhistid END ); ELSE RETURN -11; END IF; RETURN _itemlocSeries; END; $$; DROP FUNCTION public.issuetoshipping(pordertype text, pitemid integer, pqty numeric, pitemlocseries integer, ptimestamp timestamp with time zone, pinvhistid integer); publicadminfalse46238125578978!issuewomaterial(integer, numeric)FUNCTIONCREATE FUNCTION issuewomaterial(integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pQty ALIAS FOR $2; _itemlocSeries INTEGER; BEGIN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; RETURN issueWoMaterial(pWomatlid, pQty, _itemlocSeries); END; $_$; 8DROP FUNCTION public.issuewomaterial(integer, numeric); publicadminfalse46238125578979*issuewomaterial(integer, numeric, integer)FUNCTIONCREATE FUNCTION issuewomaterial(integer, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pQty ALIAS FOR $2; pItemlocSeries ALIAS FOR $3; _p RECORD; _invhistid INTEGER; _itemlocSeries INTEGER; BEGIN RETURN issueWoMaterial(pWomatlid, pQty, pItemlocSeries, now()); END; $_$; ADROP FUNCTION public.issuewomaterial(integer, numeric, integer); publicadminfalse84623125578980*issuewomaterial(integer, numeric, boolean)FUNCTIONCREATE FUNCTION issuewomaterial(integer, numeric, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pQty ALIAS FOR $2; pMarkPush ALIAS FOR $3; _itemlocSeries INTEGER; BEGIN RETURN issueWoMaterial(pWomatlid, pQty, pMarkPush, now()); END; $_$; ADROP FUNCTION public.issuewomaterial(integer, numeric, boolean); publicadminfalse462381255789813issuewomaterial(integer, numeric, integer, boolean)FUNCTIONCREATE FUNCTION issuewomaterial(integer, numeric, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pQty ALIAS FOR $2; pItemlocSeries ALIAS FOR $3; pMarkPush ALIAS FOR $4; _itemlocSeries INTEGER; BEGIN RETURN issueWoMaterial(pWomatlid, pQty, pItemlocSeries,now()); END; $_$; JDROP FUNCTION public.issuewomaterial(integer, numeric, integer, boolean); publicadminfalse46238125578982Dissuewomaterial(integer, numeric, integer, timestamp with time zone)FUNCTIONECREATE FUNCTION issuewomaterial(integer, numeric, integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN issueWoMaterial($1, $2, $3, $4, NULL); END; $_$; [DROP FUNCTION public.issuewomaterial(integer, numeric, integer, timestamp with time zone); publicadminfalse84623125578983Dissuewomaterial(integer, numeric, boolean, timestamp with time zone)FUNCTIONCREATE FUNCTION issuewomaterial(integer, numeric, boolean, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pQty ALIAS FOR $2; pMarkPush ALIAS FOR $3; pGlDistTS ALIAS FOR $4; _itemlocSeries INTEGER; BEGIN SELECT issueWoMaterial(pWomatlid, pQty, 0, pGlDistTS) INTO _itemlocSeries; IF (_itemlocSeries < 0) THEN RETURN _itemlocSeries; END IF; IF (pMarkPush) THEN UPDATE womatl SET womatl_issuemethod='S' WHERE ((womatl_issuemethod='M') AND (womatl_id=pWomatlid)); END IF; RETURN _itemlocSeries; END; $_$; [DROP FUNCTION public.issuewomaterial(integer, numeric, boolean, timestamp with time zone); publicadminfalse84623125578984Missuewomaterial(integer, numeric, integer, boolean, timestamp with time zone)FUNCTIONCREATE FUNCTION issuewomaterial(integer, numeric, integer, boolean, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pQty ALIAS FOR $2; pItemlocSeries ALIAS FOR $3; pMarkPush ALIAS FOR $4; pGlDistTS ALIAS FOR $5; _itemlocSeries INTEGER; BEGIN SELECT issueWoMaterial(pWomatlid, pQty, pItemlocSeries, pGlDistTS) INTO _itemlocSeries; IF (pMarkPush) THEN UPDATE womatl SET womatl_issuemethod='S' WHERE ((womatl_issuemethod='M') AND (womatl_id=pWomatlid)); END IF; RETURN _itemlocSeries; END; $_$; dDROP FUNCTION public.issuewomaterial(integer, numeric, integer, boolean, timestamp with time zone); publicadminfalse46238125578985Missuewomaterial(integer, numeric, integer, timestamp with time zone, integer)FUNCTIONs CREATE FUNCTION issuewomaterial(integer, numeric, integer, timestamp with time zone, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pQty ALIAS FOR $2; pItemlocSeries ALIAS FOR $3; pGlDistTS ALIAS FOR $4; pInvhistid ALIAS FOR $5; _p RECORD; _invhistid INTEGER; _itemlocSeries INTEGER; BEGIN SELECT item_id, itemsite_id AS c_itemsite_id, wo_itemsite_id AS p_itemsite_id, itemsite_loccntrl, itemsite_controlmethod, womatl_wo_id, womatl_qtyreq, itemsite_item_id, womatl_uom_id, wo_prj_id, roundQty(item_fractional, itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, pQty)) AS qty, formatWoNumber(wo_id) AS woNumber, CASE WHEN(itemsite_costmethod='J' AND item_type='P' AND poitem_id IS NOT NULL) THEN poitem_unitprice WHEN(itemsite_costmethod IN ('A','J')) THEN avgcost(itemsite_id) WHEN(itemsite_costmethod='S') THEN stdcost(itemsite_item_id) ELSE 0.0 END AS cost, womatl_issuemethod AS issueMethod INTO _p FROM womatl JOIN wo ON (wo_id=womatl_wo_id) JOIN itemsite ON (itemsite_id=womatl_itemsite_id) JOIN item ON (item_id=itemsite_item_id) LEFT OUTER JOIN poitem ON (poitem_order_id=womatl_id AND poitem_order_type='W') WHERE (womatl_id=pWomatlid); IF (pQty < 0) THEN RETURN pItemlocSeries; END IF; IF (pItemlocSeries <> 0) THEN _itemlocSeries := pItemlocSeries; ELSE SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; END IF; SELECT postInvTrans( ci.itemsite_id, 'IM', _p.qty, 'W/O', 'WO', _p.woNumber, '', ('Material ' || item_number || ' Issue to Work Order'), getPrjAccntId(_p.wo_prj_id, pc.costcat_wip_accnt_id), cc.costcat_asset_accnt_id, _itemlocSeries, pGlDistTS, NULL, pInvhistid ) INTO _invhistid FROM itemsite AS ci, itemsite AS pi, costcat AS cc, costcat AS pc, item WHERE ( (ci.itemsite_costcat_id=cc.costcat_id) AND (pi.itemsite_costcat_id=pc.costcat_id) AND (ci.itemsite_id=_p.c_itemsite_id) AND (pi.itemsite_id=_p.p_itemsite_id) AND (ci.itemsite_item_id=item_id) ); -- Create linkage to the transaction created IF (_invhistid != -1) THEN INSERT INTO womatlpost (womatlpost_womatl_id,womatlpost_invhist_id) VALUES (pWomatlid,_invhistid); END IF; -- Increase the parent W/O's WIP value by the value of the issued components UPDATE wo SET wo_wipvalue = (wo_wipvalue + (_p.cost * _p.qty)), wo_postedvalue = (wo_postedvalue + (_p.cost * _p.qty)) WHERE (wo_id=_p.womatl_wo_id); UPDATE womatl SET womatl_qtyiss = (womatl_qtyiss + itemuomtouom(_p.itemsite_item_id, NULL, _p.womatl_uom_id, _p.qty)), womatl_lastissue = pGlDistTS::DATE WHERE (womatl_id=pWomatlid); UPDATE wo SET wo_status='I' WHERE ( (wo_status <> 'I') AND (wo_id=_p.womatl_wo_id) ); RETURN _itemlocSeries; END; $_$; dDROP FUNCTION public.issuewomaterial(integer, numeric, integer, timestamp with time zone, integer); publicadminfalse84623125578986issuewomaterialbatch(integer)FUNCTIONkCREATE FUNCTION issuewomaterialbatch(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; _itemlocSeries INTEGER; _r RECORD; _woNumber TEXT; BEGIN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; FOR _r IN SELECT womatl_id, CASE WHEN (womatl_qtyreq >= 0) THEN roundQty(itemuomfractionalbyuom(item_id, womatl_uom_id), noNeg(womatl_qtyreq - womatl_qtyiss)) ELSE roundQty(itemuomfractionalbyuom(item_id, womatl_uom_id), noNeg(womatl_qtyiss * -1)) END AS qty FROM womatl, itemsite, item WHERE ( (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (womatl_issuemethod IN ('S', 'M')) AND (womatl_wo_id=pWoid) ) LOOP IF (_r.qty > 0) THEN SELECT issueWoMaterial(_r.womatl_id, _r.qty, _itemlocSeries, TRUE) INTO _itemlocSeries; END IF; END LOOP; RETURN _itemlocSeries; END; $_$; 4DROP FUNCTION public.issuewomaterialbatch(integer); publicadminfalse84623125578987itemaltcapinvrat(integer)FUNCTIONGCREATE FUNCTION itemaltcapinvrat(integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; BEGIN RETURN itemUOMRatioByType(pItemid, 'AltCapacity'); END; $_$; 0DROP FUNCTION public.itemaltcapinvrat(integer); publicadminfalse46238125578988itemaltcapuom(integer)FUNCTION<CREATE FUNCTION itemaltcapuom(integer) RETURNS text LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; BEGIN RETURN itemUOMByType(pItemid, 'AltCapacity'); END; $_$; -DROP FUNCTION public.itemaltcapuom(integer); publicadminfalse46238125578989itemcapinvrat(integer)FUNCTIONACREATE FUNCTION itemcapinvrat(integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; BEGIN RETURN itemUOMRatioByType(pItemid, 'Capacity'); END; $_$; -DROP FUNCTION public.itemcapinvrat(integer); publicadminfalse84623125578990itemcapuom(integer)FUNCTION6CREATE FUNCTION itemcapuom(integer) RETURNS text LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; BEGIN RETURN itemUOMByType(pItemid, 'Capacity'); END; $_$; *DROP FUNCTION public.itemcapuom(integer); publicadminfalse462381255789917itemcharprice(integer, integer, text, integer, numeric)FUNCTIONCREATE FUNCTION itemcharprice(integer, integer, text, integer, numeric) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCharid ALIAS FOR $2; pCharValue ALIAS FOR $3; pCustid ALIAS FOR $4; pQty ALIAS FOR $5; BEGIN RETURN itemCharPrice(pItemid, pCharid, pCharValue, pCustid, -1, pQty, baseCurrId(), CURRENT_DATE); END; $_$; NDROP FUNCTION public.itemcharprice(integer, integer, text, integer, numeric); publicadminfalse84623125578992@itemcharprice(integer, integer, text, integer, integer, numeric)FUNCTIONCREATE FUNCTION itemcharprice(integer, integer, text, integer, integer, numeric) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCharid ALIAS FOR $2; pCharValue ALIAS FOR $3; pCustid ALIAS FOR $4; pShiptoid ALIAS FOR $5; pQty ALIAS FOR $6; BEGIN RETURN itemCharPrice(pItemid, pCharid, pCharValue, pCustid, pShiptoid, pQty, baseCurrId(), CURRENT_DATE); END; $_$; WDROP FUNCTION public.itemcharprice(integer, integer, text, integer, integer, numeric); publicadminfalse84623125578993Iitemcharprice(integer, integer, text, integer, integer, numeric, integer)FUNCTION4CREATE FUNCTION itemcharprice(integer, integer, text, integer, integer, numeric, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCharid ALIAS FOR $2; pCharValue ALIAS FOR $3; pCustid ALIAS FOR $4; pShiptoid ALIAS FOR $5; pQty ALIAS FOR $6; pCurrid ALIAS FOR $7; BEGIN RETURN itemCharPrice(pItemid, pCharid, pCharValue, pCustid, pShiptoid, pQty, pCurrid, CURRENT_DATE); END; $_$; `DROP FUNCTION public.itemcharprice(integer, integer, text, integer, integer, numeric, integer); publicadminfalse84623125578994Oitemcharprice(integer, integer, text, integer, integer, numeric, integer, date)FUNCTIONcCREATE FUNCTION itemcharprice(integer, integer, text, integer, integer, numeric, integer, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCharid ALIAS FOR $2; pCharValue ALIAS FOR $3; pCustid ALIAS FOR $4; pShiptoid ALIAS FOR $5; pQty ALIAS FOR $6; pCurrid ALIAS FOR $7; pEffective ALIAS FOR $8; BEGIN RETURN itemCharPrice(pItemid, pCharid, pCharValue, pCustid, pShiptoid, pQty, pCurrid, CURRENT_DATE, CURRENT_DATE); END; $_$; fDROP FUNCTION public.itemcharprice(integer, integer, text, integer, integer, numeric, integer, date); publicadminfalse84623125578995Uitemcharprice(integer, integer, text, integer, integer, numeric, integer, date, date)FUNCTIONr"CREATE FUNCTION itemcharprice(integer, integer, text, integer, integer, numeric, integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCharid ALIAS FOR $2; pCharValue ALIAS FOR $3; pCustid ALIAS FOR $4; pShiptoid ALIAS FOR $5; pQty ALIAS FOR $6; pCurrid ALIAS FOR $7; pEffective ALIAS FOR $8; pAsOf ALIAS FOR $9; _price NUMERIC; _sales NUMERIC; _item RECORD; _iteminvpricerat NUMERIC; BEGIN -- If the charass_value passed in is NULL, we can skip this function IF (pCharValue IS NULL) THEN RETURN 0; END IF; -- Return the itemCharPrice in the currency passed in as pCurrid -- Get a value here so we do not have to call the function several times SELECT iteminvpricerat(pItemid) INTO _iteminvpricerat; -- First get a sales price if any so we when we find other prices -- we can determine if we want that price or this price. -- Check for a Sale Price SELECT currToCurr(ipshead_curr_id, pCurrid, ipsprice_price - (ipsprice_price * cust_discntprcnt), pEffective) INTO _sales FROM ( SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id, itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) AS ipsprice_qtybreak, (ipsitemchar_price * itemuomtouomratio(ipsitem_item_id, NULL, ipsitem_price_uom_id)) * _iteminvpricerat AS ipsprice_price FROM ipsiteminfo,ipsitemchar WHERE((ipsitem_item_id=pItemid) AND (ipsitemchar_char_id=pCharid) AND (ipsitemchar_value=pCharValue) AND (ipsitemchar_ipsitem_id=ipsitem_id)) ) AS ipsprice, ipshead, sale, custinfo WHERE ( (ipsprice_ipshead_id=ipshead_id) AND (sale_ipshead_id=ipshead_id) AND (pAsOf BETWEEN sale_startdate AND sale_enddate) AND (ipsprice_qtybreak <= pQty) AND (cust_id=pCustid) ) ORDER BY ipsprice_qtybreak DESC, ipsprice_price ASC LIMIT 1; -- Check for a Customer Shipto Price SELECT currToCurr(ipshead_curr_id, pCurrid, ipsprice_price, pEffective) INTO _price FROM ( SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id, itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) AS ipsprice_qtybreak, (ipsitemchar_price * itemuomtouomratio(ipsitem_item_id, NULL, ipsitem_price_uom_id)) * _iteminvpricerat AS ipsprice_price FROM ipsiteminfo,ipsitemchar WHERE ((ipsitem_item_id=pItemid) AND (ipsitemchar_char_id=pCharid) AND (ipsitemchar_value=pCharValue) AND (ipsitemchar_ipsitem_id=ipsitem_id)) ) AS ipsprice, ipshead, ipsass WHERE ( (ipsprice_ipshead_id=ipshead_id) AND (ipsass_ipshead_id=ipshead_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsprice_qtybreak <= pQty) AND (ipsass_shipto_id != -1) AND (ipsass_shipto_id=pShiptoid) ) ORDER BY ipsprice_qtybreak DESC, ipsprice_price ASC LIMIT 1; IF (_price IS NOT NULL) THEN IF ((_sales IS NOT NULL) AND (_sales < _price)) THEN RETURN _sales; END IF; RETURN _price; END IF; -- Check for a Customer Shipto Pattern Price SELECT currToCurr(ipshead_curr_id, pCurrid, ipsprice_price, pEffective) INTO _price FROM ( SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id, itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) AS ipsprice_qtybreak, (ipsitemchar_price * itemuomtouomratio(ipsitem_item_id, NULL, ipsitem_price_uom_id)) * _iteminvpricerat AS ipsprice_price FROM ipsiteminfo,ipsitemchar WHERE ((ipsitem_item_id=pItemid) AND (ipsitemchar_char_id=pCharid) AND (ipsitemchar_value=pCharValue) AND (ipsitemchar_ipsitem_id=ipsitem_id)) ) AS ipsprice, ipshead, ipsass, shiptoinfo WHERE ( (ipsprice_ipshead_id=ipshead_id) AND (ipsass_ipshead_id=ipshead_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsprice_qtybreak <= pQty) AND (COALESCE(length(ipsass_shipto_pattern), 0) > 0) AND (shipto_num ~ ipsass_shipto_pattern) AND (ipsass_cust_id=pCustid) AND (shipto_id=pShiptoid) ) ORDER BY ipsprice_qtybreak DESC, ipsprice_price ASC LIMIT 1; IF (_price IS NOT NULL) THEN IF ((_sales IS NOT NULL) AND (_sales < _price)) THEN RETURN _sales; END IF; RETURN _price; END IF; -- Check for a Customer Price SELECT currToCurr(ipshead_curr_id, pCurrid, ipsprice_price, pEffective) INTO _price FROM ( SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id, itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) AS ipsprice_qtybreak, (ipsitemchar_price * itemuomtouomratio(ipsitem_item_id, NULL, ipsitem_price_uom_id)) * _iteminvpricerat AS ipsprice_price FROM ipsiteminfo,ipsitemchar WHERE ((ipsitem_item_id=pItemid) AND (ipsitemchar_char_id=pCharid) AND (ipsitemchar_value=pCharValue) AND (ipsitemchar_ipsitem_id=ipsitem_id)) ) AS ipsprice, ipshead, ipsass WHERE ( (ipsprice_ipshead_id=ipshead_id) AND (ipsass_ipshead_id=ipshead_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsprice_qtybreak <= pQty) AND (COALESCE(length(ipsass_shipto_pattern), 0) = 0) AND (ipsass_cust_id=pCustid) ) ORDER BY ipsprice_qtybreak DESC, ipsprice_price ASC LIMIT 1; IF (_price IS NOT NULL) THEN IF ((_sales IS NOT NULL) AND (_sales < _price)) THEN RETURN _sales; END IF; RETURN _price; END IF; -- Check for a Customer Type Price SELECT currToCurr(ipshead_curr_id, pCurrid, ipsprice_price, pEffective) INTO _price FROM ( SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id, itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) AS ipsprice_qtybreak, (ipsitemchar_price * itemuomtouomratio(ipsitem_item_id, NULL, ipsitem_price_uom_id)) * _iteminvpricerat AS ipsprice_price FROM ipsiteminfo,ipsitemchar WHERE((ipsitem_item_id=pItemid) AND (ipsitemchar_char_id=pCharid) AND (ipsitemchar_value=pCharValue) AND (ipsitemchar_ipsitem_id=ipsitem_id)) ) AS ipsprice, ipshead, ipsass, custinfo WHERE ( (ipsprice_ipshead_id=ipshead_id) AND (ipsass_ipshead_id=ipshead_id) AND (ipsass_custtype_id=cust_custtype_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsprice_qtybreak <= pQty) AND (cust_id=pCustid) ) ORDER BY ipsprice_qtybreak DESC, ipsprice_price ASC LIMIT 1; IF (_price IS NOT NULL) THEN IF ((_sales IS NOT NULL) AND (_sales < _price)) THEN RETURN _sales; END IF; RETURN _price; END IF; -- Check for a Customer Type Pattern Price SELECT currToCurr(ipshead_curr_id, pCurrid, ipsprice_price, pEffective) INTO _price FROM ( SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id, itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) AS ipsprice_qtybreak, (ipsitemchar_price * itemuomtouomratio(ipsitem_item_id, NULL, ipsitem_price_uom_id)) * _iteminvpricerat AS ipsprice_price FROM ipsiteminfo,ipsitemchar WHERE ((ipsitem_item_id=pItemid) AND (ipsitemchar_char_id=pCharid) AND (ipsitemchar_value=pCharValue) AND (ipsitemchar_ipsitem_id=ipsitem_id)) ) AS ipsprice, ipshead, ipsass, custtype, custinfo WHERE ( (ipsprice_ipshead_id=ipshead_id) AND (ipsass_ipshead_id=ipshead_id) AND (coalesce(length(ipsass_custtype_pattern), 0) > 0) AND (custtype_code ~ ipsass_custtype_pattern) AND (cust_custtype_id=custtype_id) AND (pAsOf BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND (ipsprice_qtybreak <= pQty) AND (cust_id=pCustid) ) ORDER BY ipsprice_qtybreak DESC, ipsprice_price ASC LIMIT 1; IF (_price IS NOT NULL) THEN IF ((_sales IS NOT NULL) AND (_sales < _price)) THEN RETURN _sales; END IF; RETURN _price; END IF; -- If we have not found another price yet and we have a -- sales price we will use that. IF (_sales IS NOT NULL) THEN RETURN _sales; END IF; -- Check for a list price SELECT MIN(currToLocal(pCurrid, charass_price - (charass_price * COALESCE(cust_discntprcnt, 0)), pEffective)) AS price, item_exclusive INTO _item FROM charass,item LEFT OUTER JOIN custinfo ON (cust_id=pCustid) WHERE ((item_id=pItemid) AND (charass_char_id=pCharid) AND (charass_value=pCharValue) AND (charass_target_type='I') AND (charass_target_id=item_id)) GROUP BY item_exclusive; IF (FOUND) THEN IF (NOT _item.item_exclusive) THEN IF (_item.price < 0) THEN RETURN 0; ELSE RETURN _item.price; END IF; ELSE RETURN 0; END IF; ELSE RETURN 0; END IF; END; $_$; lDROP FUNCTION public.itemcharprice(integer, integer, text, integer, integer, numeric, integer, date, date); publicadminfalse46238125578996itemcharvalue(integer, text)FUNCTION9CREATE FUNCTION itemcharvalue(integer, text) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCharName ALIAS FOR $2; _value TEXT; BEGIN SELECT charass_value INTO _value FROM charass, char WHERE ( (charass_char_id=char_id) AND (charass_target_type='I') AND (charass_target_id=pItemid) AND (char_name=pCharName) ); IF (NOT FOUND) THEN _value = ''; END IF; RETURN _value; END; $_$; 3DROP FUNCTION public.itemcharvalue(integer, text); publicadminfalse84623125578997itemcost(integer)FUNCTIONCREATE FUNCTION itemcost(pitemsiteid integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cost NUMERIC; BEGIN SELECT CASE WHEN (itemsite_costmethod='A' AND itemsite_qtyonhand != 0.0) THEN (itemsite_value / itemsite_qtyonhand) WHEN (itemsite_costmethod='A' AND itemsite_qtyonhand = 0.0) THEN stdCost(itemsite_item_id) WHEN (itemsite_costmethod='N') THEN 0.0 ELSE stdCost(itemsite_item_id) END INTO _cost FROM itemsite WHERE(itemsite_id=pItemsiteid); RETURN _cost; END; $$; 4DROP FUNCTION public.itemcost(pitemsiteid integer); publicadminfalse46238125587048\itemcost(integer, integer, integer, numeric, integer, integer, integer, date, date, integer)FUNCTIONCREATE FUNCTION itemcost(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- -- Overload for future costing enhancements -- BEGIN RETURN itemCost(pItemid, pCustid, pShiptoid, pQty, pQtyUOM, pPriceUOM, pCurrid, pEffective, pAsOf, pSiteid, FALSE); END; $$; DROP FUNCTION public.itemcost(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer); publicadminfalse84623125587049eitemcost(integer, integer, integer, numeric, integer, integer, integer, date, date, integer, boolean)FUNCTION[CREATE FUNCTION itemcost(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer, pdropship boolean) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- -- Overload for future costing enhancements -- DECLARE _r RECORD; _cost NUMERIC := 0.0; BEGIN -- cache item info SELECT *, itemInvPriceRat(item_id) AS itempriceinvrat INTO _r FROM itemsite, item WHERE (itemsite_item_id=pItemid) AND (itemsite_warehous_id=pSiteid) AND (item_id=pItemid); IF (_r.item_type = 'K') THEN SELECT SUM(roundQty(itemuomfractionalbyuom(bomitem_item_id, bomitem_uom_id), (bomitem_qtyfxd + bomitem_qtyper) * (1 + bomitem_scrap)) * stdCost(bomitem_item_id)) INTO _cost FROM bomitem WHERE (bomitem_parent_item_id=_r.item_id) AND (bomitem_rev_id=getActiveRevid('BOM', _r.item_id)) AND (pEffective BETWEEN bomitem_effective AND (bomitem_expires - 1)); ELSEIF (fetchMetricBool('WholesalePriceCosting')) THEN _cost := _r.item_listcost / _r.itempriceinvrat; ELSE SELECT itemcost(_r.itemsite_id) INTO _cost; END IF; RETURN _cost; END; $$; DROP FUNCTION public.itemcost(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer, pdropship boolean); publicadminfalse46238125578998iteminventoryuominuse(integer)FUNCTIONCREATE FUNCTION iteminventoryuominuse(pitemid integer) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _uomid INTEGER; _result INTEGER; BEGIN SELECT item_inv_uom_id INTO _uomid FROM item WHERE(item_id=pItemid); SELECT itemuomconv_id INTO _result FROM itemuomconv WHERE(itemuomconv_item_id=pItemid) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; SELECT itemsite_id INTO _result FROM itemsite WHERE ( (itemsite_item_id=pItemid) AND (itemsite_qtyonhand <> 0) ) LIMIT 1; IF (FOUND) THEN RETURN TRUE; END IF; RETURN FALSE; END; $$; =DROP FUNCTION public.iteminventoryuominuse(pitemid integer); publicadminfalse84623125578999iteminvpricerat(integer)FUNCTIONCREATE FUNCTION iteminvpricerat(integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; _fromUomid INTEGER; _toUomid INTEGER; _ratio NUMERIC; BEGIN IF(pItemid IS NULL) THEN RETURN 1.0; END IF; SELECT item_inv_uom_id, item_price_uom_id INTO _fromUomid, _toUomid FROM item WHERE(item_id=pItemid); IF(NOT FOUND) THEN RAISE EXCEPTION 'No item record found for item_id %', pItemid; END IF; IF(_fromUomid = _toUomid) THEN RETURN 1.0; END IF; -- Return the ration as inventory / price SELECT CASE WHEN(itemuomconv_from_uom_id=_fromUomid) THEN itemuomconv_from_value / itemuomconv_to_value ELSE itemuomconv_to_value / itemuomconv_from_value END INTO _ratio FROM itemuomconv WHERE((((itemuomconv_from_uom_id=_fromUomid) AND (itemuomconv_to_uom_id=_toUomid)) OR ((itemuomconv_from_uom_id=_toUomid) AND (itemuomconv_to_uom_id=_fromUomid))) AND (itemuomconv_item_id=pItemid)); IF(NOT FOUND) THEN RAISE EXCEPTION 'No itemuomconv record found for item_id % to item_price_uomid %', pItemid, _toUomid; END IF; RETURN _ratio; END; $_$; /DROP FUNCTION public.iteminvpricerat(integer); publicadminfalse46238125587050`itemipsprice(integer, integer, integer, numeric, integer, integer, integer, date, date, integer)FUNCTION&CREATE FUNCTION itemipsprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer) RETURNS SETOF itemprice LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row itemprice%ROWTYPE; _sale RECORD; _ips RECORD; _item RECORD; _cust RECORD; _shipto RECORD; _itempricepricerat NUMERIC := 1.0; _listprice NUMERIC := 0.0; _qty NUMERIC; _asof DATE; _wholesalepricecosting BOOLEAN := false; _long30markups BOOLEAN := false; _itempricingprecedence BOOLEAN := false; BEGIN _wholesalepricecosting := fetchMetricBool('WholesalePriceCosting'); _long30markups := fetchMetricBool('Long30Markups'); _itempricingprecedence := fetchMetricBool('ItemPricingPrecedence'); -- Return the itemPrice in the currency passed in as pCurrid _qty := itemuomtouom(pItemid, pQtyUOM, NULL, pQty); -- If no as of passed, use current date _asof := COALESCE(pAsOf, CURRENT_DATE); -- Cache Item, Customer and Shipto SELECT item.*, (itemCost(itemsite_id) / itemuomtouomratio(item_id, item_inv_uom_id, item_price_uom_id)) AS invcost INTO _item FROM item LEFT OUTER JOIN itemsite ON (itemsite_item_id=item_id AND itemsite_warehous_id=pSiteid) WHERE (item_id=pItemid); SELECT * INTO _cust FROM custinfo JOIN custtype ON (custtype_id=cust_custtype_id) WHERE (cust_id=pCustid); SELECT * INTO _shipto FROM shiptoinfo WHERE (shipto_id=pShiptoid); -- Get a value here so we do not have to call the function several times SELECT itemuomtouomratio(pItemid, pPriceUOM, _item.item_price_uom_id) AS ratio INTO _itempricepricerat; -- Price Schedule Assignment Order of Precedence -- 1. Specific Customer Shipto Id -- 2. Specific Customer Shipto Pattern -- 3. Any Customer Shipto Pattern -- 4. Specific Customer -- 5. Customer Type -- 6. Customer Type Pattern -- First get a sales price if any so we when we find other prices -- we can determine if we want that price or this price. -- Check for a Sale Price SELECT INTO _sale currToCurr(ipshead_curr_id, pCurrid, ipsprice_price, pEffective) AS rightprice, ipsitem_type AS righttype FROM ( SELECT ipsitem_ipshead_id AS ipsprice_ipshead_id, ipsitem_type, CASE WHEN (ipsitem_type = 'N') THEN (ipsitem_price * itemuomtouomratio(_item.item_id, pPriceUOM, ipsitem_price_uom_id)) WHEN (ipsitem_type = 'D') THEN noNeg(_item.item_listprice - (_item.item_listprice * ipsitem_discntprcnt) - ipsitem_fixedamtdiscount) * _itempricepricerat WHEN ((ipsitem_type = 'M') AND _long30markups AND _wholesalepricecosting) THEN (_item.item_listcost / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat WHEN ((ipsitem_type = 'M') AND _long30markups) THEN (_item.invcost / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat WHEN (ipsitem_type = 'M' AND _wholesalepricecosting) THEN (_item.item_listcost + (_item.item_listcost * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat WHEN (ipsitem_type = 'M') THEN (_item.invcost + (_item.invcost * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat ELSE 0.00 END AS ipsprice_price, CASE WHEN (ipsitem_item_id=_item.item_id) THEN itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) ELSE ipsitem_qtybreak END AS ipsprice_qtybreak, (COALESCE(ipsitem_price_uom_id, -1)=COALESCE(pPriceUOM,-1)) AS uommatched, CASE WHEN (_itempricingprecedence) THEN (COALESCE(ipsitem_item_id, -1)=_item.item_id) ELSE true END AS itemmatched FROM ipsiteminfo WHERE(ipsitem_item_id=_item.item_id) OR (ipsitem_prodcat_id=_item.item_prodcat_id) ) AS ipsprice, ipshead, ipsass, sale WHERE ( (ipsprice_ipshead_id=ipshead_id) AND (sale_ipshead_id=ipsprice_ipshead_id) AND (_asof BETWEEN sale_startdate AND (sale_enddate - 1)) AND (ipsprice_qtybreak <= _qty) AND (ipsass_ipshead_id=ipshead_id) AND ( (ipsass_shipto_id=_shipto.shipto_id) OR ((COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) AND (ipsass_cust_id > -1) AND (_shipto.shipto_num ~ ipsass_shipto_pattern) AND (ipsass_cust_id = _cust.cust_id)) OR ((COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) AND (ipsass_cust_id = -1) AND (_shipto.shipto_num ~ ipsass_shipto_pattern)) OR ((COALESCE(LENGTH(ipsass_shipto_pattern), 0) = 0) AND (ipsass_cust_id=_cust.cust_id)) OR (ipsass_custtype_id=_cust.cust_custtype_id) OR ((COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) AND (_cust.custtype_code ~ ipsass_custtype_pattern)) ) ) ORDER BY itemmatched DESC, uommatched DESC, ipsprice_qtybreak DESC, ipsprice_price ASC LIMIT 1; -- Find the best Price Schedule Price SELECT INTO _ips currToCurr(ipshead_curr_id, pCurrid, protoprice, pEffective) AS rightprice, ipsitem_type AS righttype FROM ( SELECT *, CASE WHEN (COALESCE(ipsass_shipto_id, -1) > 0) THEN 1 WHEN (COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0 AND COALESCE(ipsass_cust_id, -1) > 0) THEN 2 WHEN (COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) THEN 3 WHEN (COALESCE(ipsass_cust_id, -1) > 0) THEN 4 WHEN (COALESCE(ipsass_custtype_id, -1) > 0) THEN 5 WHEN (COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) THEN 6 ELSE 99 END AS assignseq, CASE WHEN (ipsitem_type = 'N') THEN (ipsitem_price * itemuomtouomratio(_item.item_id, pPriceUOM, ipsitem_price_uom_id)) WHEN (ipsitem_type = 'D') THEN noNeg(_item.item_listprice - (_item.item_listprice * ipsitem_discntprcnt) - ipsitem_fixedamtdiscount) * _itempricepricerat WHEN ((ipsitem_type = 'M') AND _long30markups AND _wholesalepricecosting) THEN (_item.item_listcost / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat WHEN ((ipsitem_type = 'M') AND _long30markups) THEN (_item.invcost / (1.0 - ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat WHEN (ipsitem_type = 'M' AND _wholesalepricecosting) THEN (_item.item_listcost + (_item.item_listcost * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat WHEN (ipsitem_type = 'M') THEN (_item.invcost + (_item.invcost * ipsitem_discntprcnt) + ipsitem_fixedamtdiscount) * _itempricepricerat ELSE 0.00 END AS protoprice, CASE WHEN (ipsitem_item_id=_item.item_id) THEN itemuomtouom(ipsitem_item_id, ipsitem_qty_uom_id, NULL, ipsitem_qtybreak) ELSE ipsitem_qtybreak END AS protoqtybreak, (COALESCE(ipsitem_price_uom_id, -1)=COALESCE(pPriceUOM,-1)) AS uommatched, CASE WHEN (_itempricingprecedence) THEN (COALESCE(ipsitem_item_id, -1)=_item.item_id) ELSE true END AS itemmatched FROM ipsass JOIN ipshead ON (ipshead_id=ipsass_ipshead_id) JOIN ipsiteminfo ON (ipsitem_ipshead_id=ipshead_id) WHERE ((ipsitem_item_id=_item.item_id) OR (ipsitem_prodcat_id=_item.item_prodcat_id)) AND (_asof BETWEEN ipshead_effective AND (ipshead_expires - 1)) AND ((ipsitem_warehous_id=pSiteid) OR (ipsitem_warehous_id IS NULL)) AND ( (ipsass_shipto_id=_shipto.shipto_id) OR ((COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) AND (ipsass_cust_id > -1) AND (_shipto.shipto_num ~ ipsass_shipto_pattern) AND (ipsass_cust_id = _cust.cust_id)) OR ((COALESCE(LENGTH(ipsass_shipto_pattern), 0) > 0) AND (ipsass_cust_id = -1) AND (_shipto.shipto_num ~ ipsass_shipto_pattern)) OR ((COALESCE(LENGTH(ipsass_shipto_pattern), 0) = 0) AND (ipsass_cust_id=_cust.cust_id)) OR (ipsass_custtype_id=_cust.cust_custtype_id) OR ((COALESCE(LENGTH(ipsass_custtype_pattern), 0) > 0) AND (_cust.custtype_code ~ ipsass_custtype_pattern)) ) ) AS proto WHERE (protoqtybreak <= pQty) ORDER BY assignseq, itemmatched DESC, protoqtybreak DESC, rightprice LIMIT 1; IF (_ips.rightprice IS NOT NULL) THEN IF ((_sale.rightprice IS NOT NULL) AND (_sale.rightprice < _ips.rightprice)) THEN RAISE DEBUG 'itemprice, item=%, cust=%, shipto=%, sale price= %', pItemid, pCustid, pShiptoid, _sale.rightprice; _row.itemprice_price := _sale.rightprice; _row.itemprice_type := _sale.righttype; RETURN NEXT _row; END IF; RAISE DEBUG 'itemprice, item=%, cust=%, shipto=%, schedule price= %', pItemid, pCustid, pShiptoid, _ips.rightprice; _row.itemprice_price := _ips.rightprice; _row.itemprice_type := _ips.righttype; RETURN NEXT _row; END IF; -- If item is exclusive then list list price does not apply IF (_item.item_exclusive) THEN RAISE DEBUG 'itemprice, item=%, cust=%, shipto=%, item exclusive, price=-9999', pItemid, pCustid, pShiptoid; _row.itemprice_price := -9999.0; _row.itemprice_type := ''; RETURN NEXT _row; END IF; -- Check for a list price _listprice := noNeg(currToLocal(pCurrid, _item.item_listprice - (_item.item_listprice * COALESCE(_cust.cust_discntprcnt, 0.0)), pEffective) * itemuomtouomratio(pItemid, pPriceUOM, _item.item_price_uom_id)); RAISE DEBUG 'itemprice, item=%, cust=%, shipto=%, list price= %', pItemid, pCustid, pShiptoid, _listprice; _row.itemprice_price := _listprice; _row.itemprice_type := 'P'; RETURN NEXT _row; RETURN; END; $$; DROP FUNCTION public.itemipsprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer); publicadminfalse846234252125579002 itemlocdistqty(integer, integer)FUNCTIONRCREATE FUNCTION itemlocdistqty(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLocationid ALIAS FOR $1; pParentid ALIAS FOR $2; _qty NUMERIC; _tempQty NUMERIC; BEGIN SELECT COALESCE(SUM(itemlocdist_qty), 0) INTO _qty FROM itemlocdist WHERE ( (itemlocdist_source_type='L') AND (itemlocdist_source_id=pLocationid) AND (itemlocdist_itemlocdist_id=pParentid) ); SELECT COALESCE(SUM(itemlocdist_qty), 0) INTO _tempQty FROM itemlocdist, itemloc WHERE ( (itemlocdist_source_type='I') AND (itemlocdist_source_id=itemloc_id) AND (itemloc_location_id=pLocationid) AND (itemlocdist_itemlocdist_id=pParentid) ); _qty := (_qty + _tempQty); RETURN _qty; END; $_$; 7DROP FUNCTION public.itemlocdistqty(integer, integer); publicadminfalse84623125579003&itemlocdistqty(text, integer, integer)FUNCTION CREATE FUNCTION itemlocdistqty(text, integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTypes ALIAS FOR $1; pLocationid ALIAS FOR $2; pParentid ALIAS FOR $3; _qty NUMERIC := 0; _tempQty NUMERIC; BEGIN IF (strpos(pTypes, 'L') > 0) THEN SELECT COALESCE(SUM(itemlocdist_qty), 0) INTO _tempQty FROM itemlocdist WHERE ( (itemlocdist_source_type='L') AND (itemlocdist_source_id=pLocationid) AND (itemlocdist_itemlocdist_id=pParentid) ); _qty := (_qty + _tempQty); END IF; IF (strpos(pTypes, 'I') > 0) THEN SELECT COALESCE(SUM(itemlocdist_qty), 0) INTO _tempQty FROM itemlocdist, itemloc WHERE ( (itemlocdist_source_type='I') AND (itemlocdist_source_id=itemloc_id) AND (itemloc_location_id=pLocationid) AND (itemlocdist_itemlocdist_id=pParentid) ); _qty := (_qty + _tempQty); END IF; RETURN _qty; END; $_$; =DROP FUNCTION public.itemlocdistqty(text, integer, integer); publicadminfalse84623125587052<itemprice(integer, integer, integer, numeric, integer, date)FUNCTIONdCREATE FUNCTION itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pcurrid integer, peffective date) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _item RECORD; BEGIN SELECT item_inv_uom_id, item_price_uom_id INTO _item FROM item WHERE(item_id=pItemid); IF (FOUND) THEN RETURN itemPrice(pItemid, pCustid, pShiptoid, pQty, _item.item_inv_uom_id, _item.item_price_uom_id, pCurrid, pEffective); END IF; RETURN -9999; END; $$; DROP FUNCTION public.itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pcurrid integer, peffective date); publicadminfalse46238125587053Nitemprice(integer, integer, integer, numeric, integer, integer, integer, date)FUNCTIONCREATE FUNCTION itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN RETURN itemPrice(pItemid, pCustid, pShiptoid, pQty, pQtyUOM, pPriceUOM, pCurrid, pEffective, CURRENT_DATE); END; $$; DROP FUNCTION public.itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date); publicadminfalse46238125587054Titemprice(integer, integer, integer, numeric, integer, integer, integer, date, date)FUNCTIONCREATE FUNCTION itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN RETURN itemPrice(pItemid, pCustid, pShiptoid, pQty, pQtyUOM, pPriceUOM, pCurrid, pEffective, pAsOf, NULL); END; $$; DROP FUNCTION public.itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date); publicadminfalse84623125587055]itemprice(integer, integer, integer, numeric, integer, integer, integer, date, date, integer)FUNCTIONPCREATE FUNCTION itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; BEGIN SELECT * FROM itemIpsPrice(pItemid, pCustid, pShiptoid, pQty, pQtyUOM, pPriceUOM, pCurrid, pEffective, pAsOf, pSiteid) INTO _r; RETURN _r.itemprice_price; END; $$; DROP FUNCTION public.itemprice(pitemid integer, pcustid integer, pshiptoid integer, pqty numeric, pqtyuom integer, ppriceuom integer, pcurrid integer, peffective date, pasof date, psiteid integer); publicadminfalse84623125579008itemsellinguom(integer)FUNCTION2CREATE FUNCTION itemsellinguom(integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; BEGIN RETURN itemUOMByType(pItemid, 'Selling'); END; $_$; .DROP FUNCTION public.itemsellinguom(integer); publicadminfalse84623125579009-itemsrcprice(integer, numeric, integer, date)FUNCTIONCREATE FUNCTION itemsrcprice(pitemsrcid integer, pqty numeric, pcurrid integer, peffective date) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _price NUMERIC := 0.0; BEGIN SELECT itemsrcPrice(pItemsrcid, -1, FALSE, pQty, pCurrid, pEffective) INTO _price; RETURN _price; END; $$; gDROP FUNCTION public.itemsrcprice(pitemsrcid integer, pqty numeric, pcurrid integer, peffective date); publicadminfalse46238125579010?itemsrcprice(integer, integer, boolean, numeric, integer, date)FUNCTIONhCREATE FUNCTION itemsrcprice(pitemsrcid integer, psiteid integer, pdropship boolean, pqty numeric, pcurrid integer, peffective date) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _price NUMERIC := 0.0; _r RECORD; _effective DATE; BEGIN -- Sometimes NULL itemsrc is passed (#25898) IF (pItemsrcid IS NULL) THEN RETURN NULL; END IF; -- If no pEffective passed, use current date _effective := COALESCE(pEffective, CURRENT_DATE); -- Cache Itemsrc and Item SELECT * INTO _r FROM itemsrc JOIN item ON (item_id=itemsrc_item_id) WHERE (itemsrc_id=pItemsrcid); IF (NOT FOUND) THEN RAISE EXCEPTION 'itemsrc % not found.', pItemsrcid; END IF; -- Determine price SELECT currToCurr(itemsrcp_curr_id, pCurrid, price, _effective) INTO _price FROM ( SELECT *, CASE WHEN (itemsrcp_dropship) THEN 0 ELSE 1 END AS seq, CASE itemsrcp_type WHEN ('N') THEN itemsrcp_price WHEN ('D') THEN (_r.item_listcost - (_r.item_listcost * itemsrcp_discntprcnt) - itemsrcp_fixedamtdiscount) ELSE 0.0 END AS price FROM itemsrcp WHERE ( (itemsrcp_itemsrc_id=_r.itemsrc_id) AND ((itemsrcp_warehous_id=pSiteid) OR (itemsrcp_warehous_id=-1)) AND ((itemsrcp_dropship=pDropship) OR (NOT itemsrcp_dropship)) AND (itemsrcp_qtybreak <= pQty) ) ORDER BY seq, itemsrcp_qtybreak DESC LIMIT 1 ) AS data ; RETURN _price; END; $$; DROP FUNCTION public.itemsrcprice(pitemsrcid integer, psiteid integer, pdropship boolean, pqty numeric, pcurrid integer, peffective date); publicadminfalse84623125579011itemuombytype(integer, text)FUNCTIONCREATE FUNCTION itemuombytype(integer, text) RETURNS text LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pUomtype ALIAS FOR $2; _uom TEXT; BEGIN SELECT uom_name INTO _uom FROM ( SELECT uom_name FROM item JOIN itemuomconv ON (itemuomconv_item_id=item_id) JOIN itemuom ON (itemuom_itemuomconv_id=itemuomconv_id) JOIN uomtype ON (itemuom_uomtype_id=uomtype_id) JOIN uom ON (itemuomconv_to_uom_id=uom_id) WHERE((item_id=pItemid) AND (uomtype_name=pUomtype) AND (item_inv_uom_id != itemuomconv_to_uom_id)) UNION SELECT uom_name FROM item JOIN itemuomconv ON (itemuomconv_item_id=item_id) JOIN itemuom ON (itemuom_itemuomconv_id=itemuomconv_id) JOIN uomtype ON (itemuom_uomtype_id=uomtype_id) JOIN uom ON (itemuomconv_from_uom_id=uom_id) WHERE((item_id=pItemid) AND (uomtype_name=pUomtype) AND (item_inv_uom_id != itemuomconv_from_uom_id))) data LIMIT 1; IF (NOT FOUND) THEN SELECT uom_name INTO _uom FROM item JOIN uom ON (item_inv_uom_id=uom_id) WHERE(item_id=pItemid); END IF; RETURN _uom; END; $_$; 3DROP FUNCTION public.itemuombytype(integer, text); publicadminfalse84623125579012&itemuomfractionalbytype(integer, text)FUNCTION#CREATE FUNCTION itemuomfractionalbytype(integer, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pUomtype ALIAS FOR $2; _frac BOOLEAN; BEGIN SELECT itemuomconv_fractional INTO _frac FROM item JOIN itemuomconv ON (itemuomconv_item_id=item_id) JOIN itemuom ON (itemuom_itemuomconv_id=itemuomconv_id) JOIN uomtype ON (itemuom_uomtype_id=uomtype_id) WHERE((item_id=pItemid) AND (uomtype_name=pUomtype)) LIMIT 1; IF (NOT FOUND) THEN SELECT item_fractional INTO _frac FROM item JOIN uom ON (item_inv_uom_id=uom_id) WHERE(item_id=pItemid); END IF; RETURN _frac; END; $_$; =DROP FUNCTION public.itemuomfractionalbytype(integer, text); publicadminfalse84623125579013(itemuomfractionalbyuom(integer, integer)FUNCTION=CREATE FUNCTION itemuomfractionalbyuom(integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pUomid ALIAS FOR $2; _frac BOOLEAN; BEGIN SELECT itemuomconv_fractional INTO _frac FROM item JOIN itemuomconv ON (itemuomconv_item_id=item_id) WHERE((item_id=pItemid) AND ((itemuomconv_from_uom_id=item_inv_uom_id AND itemuomconv_to_uom_id=pUomid) OR (itemuomconv_to_uom_id=item_inv_uom_id AND itemuomconv_from_uom_id=pUomid))) LIMIT 1; IF (NOT FOUND) THEN SELECT item_fractional INTO _frac FROM item JOIN uom ON (item_inv_uom_id=uom_id) WHERE(item_id=pItemid); END IF; RETURN _frac; END; $_$; ?DROP FUNCTION public.itemuomfractionalbyuom(integer, integer); publicadminfalse46238125579014!itemuomratiobytype(integer, text)FUNCTIONCREATE FUNCTION itemuomratiobytype(integer, text) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pUomtype ALIAS FOR $2; _ratio NUMERIC; BEGIN -- Return the ration as alternate / inventory uom SELECT CASE WHEN(itemuomconv_from_uom_id=item_inv_uom_id) THEN itemuomconv_to_value / itemuomconv_from_value ELSE itemuomconv_from_value / itemuomconv_to_value END INTO _ratio FROM item JOIN itemuomconv ON (itemuomconv_item_id=item_id) JOIN itemuom ON (itemuom_itemuomconv_id=itemuomconv_id) JOIN uomtype ON (itemuom_uomtype_id=uomtype_id) WHERE((item_id=pItemid) AND (uomtype_name=pUomtype)) LIMIT 1; IF (NOT FOUND) THEN _ratio := 1.0; END IF; RETURN _ratio; END; $_$; 8DROP FUNCTION public.itemuomratiobytype(integer, text); publicadminfalse462381255790150itemuomtouom(integer, integer, integer, numeric)FUNCTION6CREATE FUNCTION itemuomtouom(integer, integer, integer, numeric) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN itemuomtouom($1, $2, $3, $4, 'qty'); END; $_$; GDROP FUNCTION public.itemuomtouom(integer, integer, integer, numeric); publicadminfalse846231255790166itemuomtouom(integer, integer, integer, numeric, text)FUNCTIONCREATE FUNCTION itemuomtouom(pitemid integer, puomidfrom integer, puomidto integer, pqtyfrom numeric, plocale text) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _uomidFrom INTEGER; _uomidTo INTEGER; _uomidInv INTEGER; _valueFrom NUMERIC := 0.0; _valueTo NUMERIC := 0.0; _value NUMERIC := 0.0; _item RECORD; _conv RECORD; _frac BOOLEAN := FALSE; BEGIN SELECT item_inv_uom_id, item_fractional INTO _item FROM item WHERE(item_id=pItemid); IF(NOT FOUND) THEN RAISE EXCEPTION 'No item record was found for item id %', pItemid; END IF; _uomidFrom := COALESCE(pUomidFrom, _item.item_inv_uom_id); _uomidTo := COALESCE(pUomidTo, _item.item_inv_uom_id); _uomidInv := _item.item_inv_uom_id; -- Should we round the qty here or not? IF(_uomidFrom = _uomidTo) THEN -- Both from/to are the same. If it is the item inv uom -- then use the item fractional value otherwise assume -- it is fractional for now so the user gets the same value back. IF(_uomidFrom = _item.item_inv_uom_id) THEN _frac := _item.item_fractional; ELSE _frac := true; END IF; RETURN roundLocale(_frac, pQtyFrom, pLocale); END IF; -- Try a direct conversion SELECT itemuomconv_from_uom_id, itemuomconv_from_value, itemuomconv_to_uom_id, itemuomconv_to_value, itemuomconv_fractional INTO _conv FROM itemuomconv WHERE(((itemuomconv_from_uom_id=_uomidFrom AND itemuomconv_to_uom_id=_uomidTo) OR (itemuomconv_from_uom_id=_uomidTo AND itemuomconv_to_uom_id=_uomidFrom)) AND (itemuomconv_item_id=pItemid)); IF(FOUND) THEN IF(_conv.itemuomconv_from_uom_id=_uomidFrom) THEN _valueFrom := _conv.itemuomconv_from_value; _valueTo := _conv.itemuomconv_to_value; ELSE _valueFrom := _conv.itemuomconv_to_value; _valueTo := _conv.itemuomconv_from_value; END IF; -- If we are converting to the item inv uom use the item fractional value -- otherwise use the conversion fractional value. if(_uomidTo = _uomidInv) THEN _frac := _item.item_fractional; ELSE _frac := _conv.itemuomconv_fractional; END IF; _value := roundLocale(_frac, ((_valueTo/_valueFrom) * pQtyFrom), pLocale); ELSE -- Try to convert the from uom to the inventory uom SELECT itemuomconv_from_uom_id, itemuomconv_from_value, itemuomconv_to_uom_id, itemuomconv_to_value, itemuomconv_fractional INTO _conv FROM itemuomconv WHERE(((itemuomconv_from_uom_id=_uomidFrom AND itemuomconv_to_uom_id=_uomidInv) OR (itemuomconv_from_uom_id=_uomidInv AND itemuomconv_to_uom_id=_uomidFrom)) AND (itemuomconv_item_id=pItemid)); IF(NOT FOUND) THEN RAISE EXCEPTION 'A conversion for item_id % from uom_id % to inv_uom_id % was not found.', pItemid, _uomidFrom, _uomidInv; END IF; IF(_conv.itemuomconv_from_uom_id=_uomidInv) THEN _valueFrom := _conv.itemuomconv_from_value; _valueTo := _conv.itemuomconv_to_value; ELSE _valueFrom := _conv.itemuomconv_to_value; _valueTo := _conv.itemuomconv_from_value; END IF; _value := (_valueTo / _valueFrom); IF (_conv.itemuomconv_fractional OR _item.item_fractional) THEN _frac := TRUE; END IF; -- Try to convert the to uom to the inventory uom SELECT itemuomconv_from_uom_id, itemuomconv_from_value, itemuomconv_to_uom_id, itemuomconv_to_value, itemuomconv_fractional INTO _conv FROM itemuomconv WHERE(((itemuomconv_from_uom_id=_uomidInv AND itemuomconv_to_uom_id=_uomidTo) OR (itemuomconv_from_uom_id=_uomidTo AND itemuomconv_to_uom_id=_uomidInv)) AND (itemuomconv_item_id=pItemid)); IF(NOT FOUND) THEN RAISE EXCEPTION 'A conversion for item_id % from uom_id % to inv_uom_id % was not found.', pItemid, _uomidTo, _uomidInv; END IF; IF(_conv.itemuomconv_from_uom_id=_uomidInv) THEN _valueFrom := _conv.itemuomconv_from_value; _valueTo := _conv.itemuomconv_to_value; ELSE _valueFrom := _conv.itemuomconv_to_value; _valueTo := _conv.itemuomconv_from_value; END IF; _value := _value * (_valueTo / _valueFrom); IF (_conv.itemuomconv_fractional OR _item.item_fractional) THEN _frac := TRUE; END IF; _value := roundLocale(_frac, (_value * pQtyFrom), pLocale); END IF; RETURN _value; END; $$; zDROP FUNCTION public.itemuomtouom(pitemid integer, puomidfrom integer, puomidto integer, pqtyfrom numeric, plocale text); publicadminfalse46238125579017,itemuomtouomratio(integer, integer, integer)FUNCTIONa CREATE FUNCTION itemuomtouomratio(pitemid integer, puomidfrom integer, puomidto integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _uomidFrom INTEGER; _uomidTo INTEGER; _uomidInv INTEGER; _valueFrom NUMERIC := 0.0; _valueTo NUMERIC := 0.0; _value NUMERIC := 0.0; _item RECORD; _conv RECORD; BEGIN SELECT item_inv_uom_id INTO _item FROM item WHERE(item_id=pItemid); IF(NOT FOUND) THEN RAISE EXCEPTION 'No item record was found for item id %', pItemid; END IF; _uomidFrom := COALESCE(pUomidFrom, _item.item_inv_uom_id); _uomidTo := COALESCE(pUomidTo, _item.item_inv_uom_id); _uomidInv := _item.item_inv_uom_id; IF(_uomidFrom = _uomidTo) THEN RETURN 1.0; END IF; -- Try a direct conversion SELECT itemuomconv_from_uom_id, itemuomconv_from_value, itemuomconv_to_uom_id, itemuomconv_to_value INTO _conv FROM itemuomconv WHERE(((itemuomconv_from_uom_id=_uomidFrom AND itemuomconv_to_uom_id=_uomidTo) OR (itemuomconv_from_uom_id=_uomidTo AND itemuomconv_to_uom_id=_uomidFrom)) AND (itemuomconv_item_id=pItemid)); IF(FOUND) THEN IF(_conv.itemuomconv_from_uom_id=_uomidFrom) THEN _valueFrom := _conv.itemuomconv_from_value; _valueTo := _conv.itemuomconv_to_value; ELSE _valueFrom := _conv.itemuomconv_to_value; _valueTo := _conv.itemuomconv_from_value; END IF; _value := (_valueTo / _valueFrom); ELSE -- Try to convert the from uom to the inventory uom SELECT itemuomconv_from_uom_id, itemuomconv_from_value, itemuomconv_to_uom_id, itemuomconv_to_value INTO _conv FROM itemuomconv WHERE(((itemuomconv_from_uom_id=_uomidFrom AND itemuomconv_to_uom_id=_uomidInv) OR (itemuomconv_from_uom_id=_uomidInv AND itemuomconv_to_uom_id=_uomidFrom)) AND (itemuomconv_item_id=pItemid)); IF(NOT FOUND) THEN RAISE EXCEPTION 'A conversion for item_id % from uom_id % to inv_uom_id % was not found.', pItemid, _uomidFrom, _uomidInv; END IF; IF(_conv.itemuomconv_from_uom_id=_uomidInv) THEN _valueFrom := _conv.itemuomconv_from_value; _valueTo := _conv.itemuomconv_to_value; ELSE _valueFrom := _conv.itemuomconv_to_value; _valueTo := _conv.itemuomconv_from_value; END IF; _value := (_valueTo / _valueFrom); -- Try to convert the to uom to the inventory uom SELECT itemuomconv_from_uom_id, itemuomconv_from_value, itemuomconv_to_uom_id, itemuomconv_to_value INTO _conv FROM itemuomconv WHERE(((itemuomconv_from_uom_id=_uomidInv AND itemuomconv_to_uom_id=_uomidTo) OR (itemuomconv_from_uom_id=_uomidTo AND itemuomconv_to_uom_id=_uomidInv)) AND (itemuomconv_item_id=pItemid)); IF(NOT FOUND) THEN RAISE EXCEPTION 'A conversion for item_id % from uom_id % to inv_uom_id % was not found.', pItemid, _uomidTo, _uomidInv; END IF; IF(_conv.itemuomconv_from_uom_id=_uomidInv) THEN _valueFrom := _conv.itemuomconv_from_value; _valueTo := _conv.itemuomconv_to_value; ELSE _valueFrom := _conv.itemuomconv_to_value; _valueTo := _conv.itemuomconv_from_value; END IF; _value := _value * (_valueTo / _valueFrom); END IF; RETURN _value; END; $$; _DROP FUNCTION public.itemuomtouomratio(pitemid integer, puomidfrom integer, puomidto integer); publicadminfalse46238125579018 last_agg(anyelement, anyelement)FUNCTIONyCREATE FUNCTION last_agg(anyelement, anyelement) RETURNS anyelement LANGUAGE sql STABLE AS $_$ SELECT $2; $_$; 7DROP FUNCTION public.last_agg(anyelement, anyelement); publicadminfalse8125579019login()FUNCTIONCREATE FUNCTION login() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _p RECORD; BEGIN RETURN login(false); END; $$; DROP FUNCTION public.login(); publicadminfalse84623125579020login(boolean)FUNCTIONCREATE FUNCTION login(boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _setSearchPath ALIAS FOR $1; _p RECORD; BEGIN -- added support for PostgreSQL 9.2.0, Incident 21852 IF (compareversion('9.2.0') <= 0) THEN PERFORM pg_try_advisory_lock(datid::integer, pid) FROM pg_stat_activity WHERE(pid = pg_backend_pid()); ELSE PERFORM pg_try_advisory_lock(datid::integer, procpid) FROM pg_stat_activity WHERE(procpid = pg_backend_pid()); END IF; -- This is new to version 9.0 and higher and will error on older versions IF (compareversion('9.0.0') <= 0) THEN SET bytea_output TO escape; END IF; SELECT usr_id, userCanLogin(usr_username) AS usr_active INTO _p FROM usr WHERE (usr_username=getEffectiveXtUser()); IF (NOT FOUND) THEN RETURN -1; ELSIF (NOT _p.usr_active) THEN IF(SELECT metric_value='AdminOnly' FROM metric WHERE metric_name='AllowedUserLogins') THEN RETURN -3; END IF; RETURN -2; END IF; IF (_setSearchPath) THEN IF EXISTS(SELECT 1 FROM pg_proc JOIN pg_namespace ON (pronamespace=pg_namespace.oid) WHERE nspname='public' AND proname='buildsearchpath') THEN EXECUTE 'SET SEARCH_PATH TO ' || public.buildSearchPath(); END IF; END IF; RETURN 1; END; $_$; %DROP FUNCTION public.login(boolean); publicadminfalse46238125579021logout()FUNCTIONCREATE FUNCTION logout() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (compareversion('9.2.0') <= 0) THEN PERFORM pg_advisory_unlock(datid::integer, pid) FROM pg_stat_activity WHERE(pid = pg_backend_pid()); ELSE PERFORM pg_advisory_unlock(datid::integer, procpid) FROM pg_stat_activity WHERE(procpid = pg_backend_pid()); END IF; RETURN 0; END; $$; DROP FUNCTION public.logout(); publicadminfalse46238125579022lowercost(integer, text)FUNCTIONTCREATE FUNCTION lowercost(integer, text) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCosttype ALIAS FOR $2; BEGIN RETURN lowerCost(pItemid, pCosttype, TRUE); END; $_$; /DROP FUNCTION public.lowercost(integer, text); publicadminfalse46238125579023!lowercost(integer, text, boolean)FUNCTION1CREATE FUNCTION lowercost(integer, text, boolean) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCosttype ALIAS FOR $2; pActual ALIAS FOR $3; _type CHAR(1); _actCost NUMERIC; _actCost1 NUMERIC; _actCost2 NUMERIC; _stdCost NUMERIC; _stdCost1 NUMERIC; _stdCost2 NUMERIC; _cost NUMERIC; _cost1 NUMERIC; _cost2 NUMERIC; _batchsize NUMERIC; BEGIN SELECT item_type INTO _type FROM item WHERE (item_id=pItemid); _batchsize := COALESCE( ( SELECT bomhead_batchsize FROM bomhead WHERE ((bomhead_item_id=pItemId) AND (bomhead_rev_id=getActiveRevId('BOM',pItemId))) LIMIT 1), 1); -- find the lowercost in the base currency at the current conversion rate IF (_type IN ('M', 'F', 'B', 'T')) THEN IF (pActual) THEN SELECT SUM( CASE WHEN (bomitemcost_id IS NOT NULL AND bc.costelem_id IS NOT NULL) THEN round(currToBase(bomitemcost_curr_id, bomitemcost_actcost, CURRENT_DATE),6) * itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') ELSE round(currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE),6) * itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') END ) INTO _cost FROM bomitem(pItemid) JOIN item ON (item_id=bomitem_item_id AND item_type <> 'T') JOIN itemcost ON (itemcost_item_id=bomitem_item_id) JOIN costelem ic ON (ic.costelem_id=itemcost_costelem_id AND ic.costelem_type=pCosttype) LEFT OUTER JOIN bomitemcost ON (bomitemcost_bomitem_id=bomitem_id) LEFT OUTER JOIN costelem bc ON (bc.costelem_id=bomitemcost_costelem_id AND bc.costelem_type=pCosttype) WHERE ( CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1) ); ELSE SELECT SUM( CASE WHEN (bomitemcost_id IS NOT NULL AND bc.costelem_id IS NOT NULL) THEN bomitemcost_stdcost * itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') ELSE itemcost_stdcost * itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') END ) INTO _cost FROM bomitem(pItemid) JOIN item ON (item_id=bomitem_item_id AND item_type <> 'T') JOIN itemcost ON (itemcost_item_id=bomitem_item_id) JOIN costelem ON (costelem_id=itemcost_costelem_id AND costelem_type=pCosttype) LEFT OUTER JOIN bomitemcost ON (bomitemcost_bomitem_id=bomitem_id) LEFT OUTER JOIN costelem bc ON (bc.costelem_id=bomitemcost_costelem_id AND bc.costelem_type=pCosttype) WHERE ( CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1) ); END IF; IF (NOT FOUND) THEN _cost := NULL; END IF; ELSIF (_type IN ('C')) THEN SELECT SUM(CASE WHEN (bbomitem_qtyper = 0) THEN 0 ELSE currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE) / bbomitem_qtyper * bbomitem_costabsorb END), SUM(CASE WHEN (bbomitem_qtyper = 0) THEN 0 ELSE itemcost_stdcost / bbomitem_qtyper * bbomitem_costabsorb END) INTO _actCost1, _stdCost1 FROM itemcost JOIN costelem ON (itemcost_costelem_id=costelem_id) JOIN xtmfg.bbomitem ON (bbomitem_parent_item_id=itemcost_item_id) WHERE ( (bbomitem_item_id=pItemid) AND (CURRENT_DATE BETWEEN bbomitem_effective AND (bbomitem_expires - 1)) AND (costelem_type=pCosttype) ); SELECT SUM(CASE WHEN (t.bbomitem_qtyper = 0) THEN 0 ELSE currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE) * s.bbomitem_qtyper / t.bbomitem_qtyper * t.bbomitem_costabsorb END), SUM(CASE WHEN (t.bbomitem_qtyper = 0) THEN 0 ELSE itemcost_stdcost * s.bbomitem_qtyper / t.bbomitem_qtyper * t.bbomitem_costabsorb END) INTO _actCost2, _stdCost2 FROM costelem JOIN itemcost ON (costelem_id=itemcost_costelem_id) JOIN xtmfg.bbomitem AS s ON (itemcost_item_id=s.bbomitem_item_id) JOIN xtmfg.bbomitem AS t ON (s.bbomitem_parent_item_id=t.bbomitem_parent_item_id) JOIN item ON (s.bbomitem_item_id=item_id) WHERE ( (t.bbomitem_item_id=pItemid) AND ( CURRENT_DATE BETWEEN s.bbomitem_effective AND (s.bbomitem_expires - 1) ) AND ( CURRENT_DATE BETWEEN t.bbomitem_effective AND (t.bbomitem_expires - 1) ) AND (item_type='Y') AND (costelem_type=pCosttype) ); IF (pActual) THEN _cost = _actCost; _cost1 = _actCost1; _cost2 = _actCost2; ELSE _cost = _stdCost; _cost1 = _stdCost1; _cost2 = _stdCost2; -- should this be std or act? END IF; IF (_cost1 IS NULL AND _cost2 IS NULL) THEN _cost = NULL; ELSE _cost = COALESCE(_cost1, 0) + COALESCE(_cost2, 0); END IF; ELSE RETURN NULL; END IF; RETURN round(_cost,6); END; $_$; 8DROP FUNCTION public.lowercost(integer, text, boolean); publicadminfalse84623125579024maintainbomworkspace()FUNCTIONCREATE FUNCTION maintainbomworkspace() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _test TEXT; BEGIN SELECT tablename INTO _test FROM pg_tables WHERE (tablename='bomwork'); IF (NOT FOUND) THEN CREATE TEMPORARY TABLE bomwork ( bomwork_id INTEGER, bomwork_set_id INTEGER, bomwork_parent_id INTEGER, bomwork_seqnumber INTEGER, bomwork_parent_seqnumber INTEGER, bomwork_item_id INTEGER, bomwork_item_type CHARACTER(1), bomwork_status CHARACTER(1), bomwork_qtyper NUMERIC(20, 8), bomwork_scrap NUMERIC(20, 10), bomwork_level INTEGER, bomwork_effective DATE, bomwork_expires DATE, bomwork_stdunitcost NUMERIC(16, 4), bomwork_actunitcost NUMERIC(16, 4), bomwork_createwo BOOLEAN, bomwork_issuemethod CHARACTER(1) ); CREATE INDEX bomwork_set_id_idx ON bomwork(bomwork_set_id); END IF; RETURN 1; END; $$; -DROP FUNCTION public.maintainbomworkspace(); publicadminfalse46238125579025markapcheckasposted(integer)FUNCTIONfCREATE FUNCTION markapcheckasposted(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'markAPCheckAsPosted() is deprecated - use markCheckAsPosted() instead'; RETURN markCheckAsPosted($1); END; $_$; 3DROP FUNCTION public.markapcheckasposted(integer); publicadminfalse46238125579026markapcheckasprinted(integer)FUNCTIONaCREATE FUNCTION markapcheckasprinted(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'markAPCheckAsPrinted() is deprecated - use markCheckAsPrinted()'; RETURN markCheckAsPrinted($1); END; $_$; 4DROP FUNCTION public.markapcheckasprinted(integer); publicadminfalse46238 125579027markcheckasposted(integer)FUNCTIONlCREATE FUNCTION markcheckasposted(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCheckid ALIAS FOR $1; BEGIN UPDATE checkhead SET checkhead_posted=TRUE WHERE (checkhead_id=pCheckid); RETURN 1; END; $_$; 1DROP FUNCTION public.markcheckasposted(integer); publicadminfalse46238 125579028markcheckasprinted(integer)FUNCTIONnCREATE FUNCTION markcheckasprinted(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCheckid ALIAS FOR $1; BEGIN UPDATE checkhead SET checkhead_printed=TRUE WHERE (checkhead_id=pCheckid); RETURN 1; END; $_$; 2DROP FUNCTION public.markcheckasprinted(integer); publicadminfalse84623 125579029&massexpirebomitem(integer, date, text)FUNCTION"CREATE FUNCTION massexpirebomitem(integer, date, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pExpireDate ALIAS FOR $2; pECN ALIAS FOR $3; BEGIN UPDATE bomitem SET bomitem_expires=pExpireDate WHERE ( (bomitem_expires >= CURRENT_DATE) AND (bomitem_item_id=pItemid) AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id)) ); RETURN TRUE; END; $_$; =DROP FUNCTION public.massexpirebomitem(integer, date, text); publicadminfalse46238 1255790300massreplacebomitem(integer, integer, date, text)FUNCTIONCREATE FUNCTION massreplacebomitem(integer, integer, date, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNewItemid ALIAS FOR $1; pOriginalItemid ALIAS FOR $2; pEffectiveDate ALIAS FOR $3; pECN ALIAS FOR $4; _effectiveDate DATE; _result INTEGER; BEGIN _effectiveDate := COALESCE(pEffectiveDate, CURRENT_DATE); IF (BOMContains(pOriginalItemid, pNewItemid) OR BOMContains(pNewItemid, pOriginalItemid)) THEN RETURN -1; END IF; INSERT INTO bomitem ( bomitem_parent_item_id, bomitem_seqnumber, bomitem_item_id, bomitem_qtyfxd, bomitem_qtyper, bomitem_uom_id, bomitem_scrap, bomitem_effective, bomitem_expires, bomitem_ecn, bomitem_createwo, bomitem_issuemethod, bomitem_subtype, bomitem_booitem_seq_id, bomitem_schedatwooper, bomitem_moddate, bomitem_rev_id, bomitem_char_id, bomitem_value ) SELECT bomitem_parent_item_id, bomitem_seqnumber, pNewItemid, bomitem_qtyfxd, bomitem_qtyper, bomitem_uom_id, bomitem_scrap, _effectiveDate, endOfTime(), pECN, bomitem_createwo, bomitem_issuemethod, 'I', bomitem_booitem_seq_id, bomitem_schedatwooper, CURRENT_DATE, getActiveRevId('BOM',bomitem_parent_item_id), bomitem_char_id, bomitem_value FROM bomitem WHERE ( (_effectiveDate < bomitem_expires) AND (bomitem_item_id=pOriginalItemid) AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id)) ); UPDATE bomitem SET bomitem_expires=_effectiveDate WHERE ( (_effectiveDate < bomitem_expires) AND (bomitem_item_id=pOriginalItemid) AND (bomitem_rev_id=getActiveRevid('BOM',bomitem_parent_item_id)) ); RETURN 1; END; $_$; GDROP FUNCTION public.massreplacebomitem(integer, integer, date, text); publicadminfalse46238125579031)merge2crmaccts(integer, integer, boolean)FUNCTIONn0CREATE FUNCTION merge2crmaccts(integer, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSourceId ALIAS FOR $1; pTargetId ALIAS FOR $2; _purge BOOLEAN := COALESCE($3, FALSE); _coldesc RECORD; _count INTEGER := 0; _hassubtype BOOLEAN; _mrgcol BOOLEAN; _result INTEGER := 0; _sel RECORD; _colname TEXT; _tmpid INTEGER; BEGIN -- Validate IF (pSourceId = pTargetId) THEN RAISE WARNING 'Tried to merge a CRM Account with itself: %.', pSourceId; RETURN 0; ELSIF (pSourceId IS NULL) THEN RAISE EXCEPTION 'Merge source id cannot be null [xtuple: merge, -1]'; ELSIF NOT(EXISTS(SELECT 1 FROM crmacct WHERE crmacct_id=pSourceId)) THEN RAISE EXCEPTION 'Merge source % not found [xtuple: merge, -2, %]', pSourceId, pSourceId; ELSIF (pTargetId IS NULL) THEN RAISE EXCEPTION 'Merge target id cannot be null [xtuple: merge, -3]'; ELSIF NOT(EXISTS(SELECT 1 FROM crmacct WHERE crmacct_id=pTargetId)) THEN RAISE EXCEPTION 'Merge target % not found [xtuple: merge, -4, %]', pTargetId, pTargetId; ELSIF NOT(EXISTS(SELECT 1 FROM crmacctsel WHERE (crmacctsel_src_crmacct_id=pSourceId) AND (crmacctsel_dest_crmacct_id=pTargetId))) THEN RAISE EXCEPTION 'Source % and target % have not been selected for merging [xtuple: merge, -5, %, %]', pSourceId, pTargetId, pSourceId, pTargetId; END IF; _result:= changeFkeyPointers('public', 'crmacct', pSourceId, pTargetId, ARRAY[ 'crmacctsel', 'crmacctmrgd' ], _purge) + changePseudoFKeyPointers('public', 'alarm', 'alarm_source_id', pSourceId, 'public', 'crmacct', pTargetId, 'alarm_source', 'CRMA', _purge) + changePseudoFKeyPointers('public', 'charass', 'charass_target_id', pSourceId, 'public', 'crmacct', pTargetId, 'charass_target_type', 'CRMACCT', _purge) + changePseudoFKeyPointers('public', 'comment', 'comment_source_id', pSourceId, 'public', 'crmacct', pTargetId, 'comment_source', 'CRMA', _purge) + changePseudoFKeyPointers('public', 'docass', 'docass_source_id', pSourceId, 'public', 'crmacct', pTargetId, 'docass_source_type', 'CRMA', _purge) + changePseudoFKeyPointers('public', 'docass', 'docass_target_id', pSourceId, 'public', 'crmacct', pTargetId, 'docass_target_type', 'CRMA', _purge) + changePseudoFKeyPointers('public', 'imageass', 'imageass_source_id', pSourceId, 'public', 'crmacct', pTargetId, 'imageass_source', 'CRMA', _purge) ; -- TODO: find a generic way to handle pseudofkeys in packages - see 9401 IF (fetchMetricBool('EnableBatchManager') AND packageIsEnabled('xtbatch')) THEN _result:= _result + changePseudoFKeyPointers('xtbatch', 'emlassc', 'emlassc_assc_id', pSourceId, 'public', 'crmacct', pTargetId, 'emlassc_type', 'CRMA', _purge); END IF; -- back up all of the values in the target record that are about to be changed FOR _coldesc IN SELECT attname, typname FROM pg_attribute JOIN pg_type ON (atttypid=pg_type.oid) JOIN pg_class ON (attrelid=pg_class.oid) JOIN pg_namespace ON (relnamespace=pg_namespace.oid) WHERE (attnum >= 0) AND (relname='crmacct') AND (nspname='public') AND (attname NOT IN ('crmacct_id', 'crmacct_number')) LOOP -- if we're supposed to merge this column at all EXECUTE 'SELECT ' || quote_ident('crmacctsel_mrg_' || _coldesc.attname) || ' FROM crmacctsel WHERE ((crmacctsel_src_crmacct_id=' || pSourceId || ') AND (crmacctsel_dest_crmacct_id=' || pTargetId || '))' INTO _mrgcol; IF (_mrgcol) THEN _colname := REPLACE(_coldesc.attname, 'crmacctsel_mrg_', ''); -- optionally back up the old value from the destination -- we'll back up the old value from the source further down IF (NOT _purge) THEN BEGIN EXECUTE 'INSERT INTO mrgundo ( mrgundo_schema, mrgundo_table, mrgundo_pkey_col, mrgundo_pkey_id, mrgundo_col, mrgundo_value, mrgundo_type, mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id ) SELECT ''public'', ''crmacct'', ''crmacct_id'', crmacct_id, ' || quote_literal(_colname) || ', ' || quote_ident(_colname) || ', ' || quote_literal(_coldesc.typname) || ', ''public'', ''crmacct'', crmacct_id FROM crmacct WHERE (crmacct_id=' || pTargetId || ');' ; EXCEPTION WHEN unique_violation THEN RAISE EXCEPTION 'Could not make a backup copy of % when merging % into % [xtuple: merge, -8, %, %, public, crmacct, %]', _colname, pSourceId, pTargetId, _colname, pSourceId, pTargetId; END; END IF; -- TODO: what do we do about users? /* update the destination crmacct in one of 3 different ways: - crmacct_notes might be concatenated from more than one source record - foreign keys to crm account subtype records (e.g. crmacct_cust_id) must not leave orphaned records and must avoid uniqueness violations - some fields can simply be updated in place */ IF (_colname = 'crmacct_notes') THEN EXECUTE 'UPDATE crmacct dest SET ' || quote_ident(_colname) || '=dest.' || quote_ident(_colname) || E' || E''\\n'' || src.' || _colname || ' FROM crmacct src JOIN crmacctsel ON (src.crmacct_id=crmacctsel_src_crmacct_id) WHERE ((dest.crmacct_id=crmacctsel_dest_crmacct_id) AND (dest.crmacct_id!=crmacctsel_src_crmacct_id));'; ELSIF (_colname IN ('crmacct_cust_id', 'crmacct_prospect_id', 'crmacct_vend_id', 'crmacct_taxauth_id', 'crmacct_emp_id', 'crmacct_salesrep_id')) THEN IF (_colname IN ('crmacct_cust_id', 'crmacct_prospect_id')) THEN EXECUTE 'SELECT src.' || quote_ident(_colname) || ' IS NOT NULL AND (dest.crmacct_prospect_id IS NOT NULL OR dest.crmacct_cust_id IS NOT NULL) FROM crmacct src JOIN crmacctsel ON (src.crmacct_id=crmacctsel_src_crmacct_id) JOIN crmacct dest ON (crmacctsel_dest_crmacct_id=dest.crmacct_id) WHERE ((src.crmacct_id=' || pSourceId || ') AND (dest.crmacct_id=' || pTargetId || '))' INTO _hassubtype; IF (_hassubtype) THEN RAISE EXCEPTION 'Cannot merge two CRM Accounts that both refer to Customers and/or Prospects [xtuple: merge, -6, %, %]', pSourceId, pTargetId; END IF; ELSE EXECUTE 'SELECT src.' || quote_ident(_colname) || ' IS NOT NULL AND dest.'|| quote_ident(_colname) || ' IS NOT NULL FROM crmacct src JOIN crmacctsel ON (src.crmacct_id=crmacctsel_src_crmacct_id) JOIN crmacct dest ON (crmacctsel_dest_crmacct_id=dest.crmacct_id) WHERE ((src.crmacct_id=' || pSourceId || ') AND (dest.crmacct_id=' || pTargetId || '))' INTO _hassubtype; IF (_hassubtype) THEN RAISE EXCEPTION 'Cannot merge CRM Accounts until the % child records have been merged [xtuple: merge, -7, %, %, %]', _colname, _colname, pSourceId, pTargetId; END IF; END IF; /* clearing the source separately from setting the target avoids problems with triggers updating the wrong records */ EXECUTE 'SELECT ' || quote_ident(_colname) || ' FROM crmacct WHERE crmacct_id=' || pSourceId INTO _tmpid; -- now we have the data to back up the source IF (NOT _purge) THEN BEGIN EXECUTE 'INSERT INTO mrgundo ( mrgundo_schema, mrgundo_table, mrgundo_pkey_col, mrgundo_pkey_id, mrgundo_col, mrgundo_value, mrgundo_type, mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id ) SELECT ''public'', ''crmacct'', ''crmacct_id'', crmacct_id, ' || quote_literal(_colname) || ', ' || quote_ident(_colname) || ', ' || quote_literal(_coldesc.typname) || ', ''public'', ''crmacct'', ' || pTargetId || ' FROM crmacct WHERE (crmacct_id=' || pSourceId || ');' ; EXCEPTION WHEN unique_violation THEN RAISE EXCEPTION 'Could not make a backup copy of % when merging % into % [xtuple: merge, -8, %, %, public, crmacct, %]', _colname, pSourceId, pTargetId, _colname, pSourceId, pTargetId; END; END IF; EXECUTE 'UPDATE crmacct SET ' || quote_ident(_colname) || '=NULL WHERE (crmacct_id=' || pSourceId || ');'; EXECUTE 'UPDATE crmacct SET ' || quote_ident(_colname) || '=' || quote_literal(_tmpid) || ' WHERE (crmacct_id=' || pTargetId || ');'; ELSE EXECUTE 'UPDATE crmacct dest SET ' || quote_ident(_colname) || ' =src.' || quote_ident(_colname) || ' FROM crmacct src WHERE ((dest.crmacct_id=' || pTargetId || ') AND (src.crmacct_id=' || pSourceId || '));'; END IF; GET DIAGNOSTICS _count = ROW_COUNT; _result := _result + _count; END IF; END LOOP; IF (_purge) THEN DELETE FROM crmacct WHERE crmacct = pSourceId; ELSE INSERT INTO mrgundo ( mrgundo_schema, mrgundo_table, mrgundo_pkey_col, mrgundo_pkey_id, mrgundo_col, mrgundo_value, mrgundo_type, mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id ) SELECT 'public', 'crmacct', 'crmacct_id', pSourceId, 'crmacct_active', crmacct_active, 'bool', 'public', 'crmacct', pTargetId FROM crmacct WHERE crmacct_active AND (crmacct_id = pSourceId); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count > 0) THEN _result := _result + _count; UPDATE crmacct SET crmacct_active = false WHERE (crmacct_id=pSourceId); END IF; -- make a special record of the source crm account so we can delete it later INSERT INTO mrgundo ( mrgundo_schema, mrgundo_table, mrgundo_pkey_col, mrgundo_pkey_id, mrgundo_col, mrgundo_value, mrgundo_type, mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id ) VALUES ( 'public', 'crmacct', 'crmacct_id', pSourceId, NULL, NULL, NULL, 'public', 'crmacct', pTargetId); END IF; DELETE FROM crmacctsel WHERE (crmacctsel_src_crmacct_id=pSourceId); RETURN _result; END; $_$; @DROP FUNCTION public.merge2crmaccts(integer, integer, boolean); publicadminfalse84623O&002FUNCTION merge2crmaccts(integer, integer, boolean)COMMENTCOMMENT ON FUNCTION merge2crmaccts(integer, integer, boolean) IS 'This function merges two crmacct records as decribed in crmacctsel records. For each field in the crmacctsel record marked TRUE, the data are copied from the crmacct record with crmacct_id=pSourceId to the record with crmacct_id=pTargetId. If the purge argument is TRUE, the source record is deleted. If it is FALSE, then mrgundo records are created so the merge can later be undone.'; publicadminfalse973125579033mergecrmaccts(integer, boolean)FUNCTIONHCREATE FUNCTION mergecrmaccts(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTargetId ALIAS FOR $1; _purge BOOLEAN := COALESCE($2, FALSE); _retval INTEGER; BEGIN /* if crmacctsel says the target should not keep its original notes, clear them. notes are special because the merge allows concatenating them from multiple sources. this needs to be kept in sync with merge2crmaccts' similar check. */ IF NOT (SELECT crmacctsel_mrg_crmacct_notes FROM crmacctsel WHERE crmacctsel_src_crmacct_id=crmacctsel_dest_crmacct_id AND crmacctsel_dest_crmacct_id=pTargetId) THEN IF (NOT _purge) THEN INSERT INTO mrgundo ( mrgundo_schema, mrgundo_table, mrgundo_pkey_col, mrgundo_pkey_id, mrgundo_col, mrgundo_value, mrgundo_type, mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id) SELECT 'public', 'crmacct', crmacct_id, 'public', 'crmacct', 'crmacct_id', crmacct_id, 'crmacct_notes', crmacct_notes, 'text', 'public', 'crmacct', crmacct_id FROM crmacct WHERE (crmacct_id=pTargetId); END IF; UPDATE crmacct SET crmacct_notes = '' WHERE (crmacct_id=pTargetId); END IF; -- merge the data from the various source records SELECT SUM(merge2crmaccts(crmacctsel_src_crmacct_id, pTargetId, _purge)) INTO _retval FROM crmacctsel WHERE ((crmacctsel_dest_crmacct_id=pTargetId) AND (crmacctsel_dest_crmacct_id!=crmacctsel_src_crmacct_id)); DELETE FROM crmacctsel WHERE crmacctsel_dest_crmacct_id=pTargetId; RETURN COALESCE(_retval, 0); END; $_$; 6DROP FUNCTION public.mergecrmaccts(integer, boolean); publicadminfalse46238P&00(FUNCTION mergecrmaccts(integer, boolean)COMMENTfCOMMENT ON FUNCTION mergecrmaccts(integer, boolean) IS 'This function uses the crmacctsel table to merge multiple crmacct records together. Only the merges into the specified target account are performed. Most of the work is done by repeated calls to the merge2crmaccts function. If the purge argument is FALSE, data are kept to allow reversing the merge.'; publicadminfalse1807125579034movebomitemdown(integer)FUNCTIONCREATE FUNCTION movebomitemdown(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBomitemid ALIAS FOR $1; _nextBomitem RECORD; BEGIN SELECT nextbomitem.bomitem_seqnumber AS next_seqnumber, thisbomitem.bomitem_seqnumber AS this_seqnumber, thisbomitem.bomitem_parent_item_id AS parent_item_id, thisbomitem.bomitem_rev_id AS rev_id INTO _nextBomitem FROM bomitem AS nextbomitem, bomitem AS thisbomitem WHERE ((nextbomitem.bomitem_seqnumber > thisbomitem.bomitem_seqnumber) AND (nextbomitem.bomitem_parent_item_id=thisbomitem.bomitem_parent_item_id) AND (nextbomitem.bomitem_rev_id=thisbomitem.bomitem_rev_id) AND (thisbomitem.bomitem_id=pBomitemid)) ORDER BY next_seqnumber LIMIT 1; IF (FOUND) THEN -- Swap the seqnumber of the current bomitem and the next bomitem -- There is the potential for multiple bomitems with the same seqnumber UPDATE bomitem SET bomitem_seqnumber=0 WHERE (bomitem_seqnumber=_nextBomitem.next_seqnumber) AND (bomitem_parent_item_id=_nextBomitem.parent_item_id) AND (bomitem_rev_id=_nextBomitem.rev_id); UPDATE bomitem SET bomitem_seqnumber=_nextBomitem.next_seqnumber WHERE (bomitem_seqnumber=_nextBomitem.this_seqnumber) AND (bomitem_parent_item_id=_nextBomitem.parent_item_id) AND (bomitem_rev_id=_nextBomitem.rev_id); UPDATE bomitem SET bomitem_seqnumber=_nextBomitem.this_seqnumber WHERE (bomitem_seqnumber=0) AND (bomitem_parent_item_id=_nextBomitem.parent_item_id) AND (bomitem_rev_id=_nextBomitem.rev_id); END IF; RETURN 1; END; $_$; /DROP FUNCTION public.movebomitemdown(integer); publicadminfalse46238125579035movebomitemup(integer)FUNCTIONCREATE FUNCTION movebomitemup(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBomitemid ALIAS FOR $1; _nextBomitem RECORD; BEGIN SELECT nextbomitem.bomitem_seqnumber AS next_seqnumber, thisbomitem.bomitem_seqnumber AS this_seqnumber, thisbomitem.bomitem_parent_item_id AS parent_item_id, thisbomitem.bomitem_rev_id AS rev_id INTO _nextBomitem FROM bomitem AS nextbomitem, bomitem AS thisbomitem WHERE ((nextbomitem.bomitem_seqnumber < thisbomitem.bomitem_seqnumber) AND (nextbomitem.bomitem_parent_item_id=thisbomitem.bomitem_parent_item_id) AND (nextbomitem.bomitem_rev_id=thisbomitem.bomitem_rev_id) AND (thisbomitem.bomitem_id=pBomitemid)) ORDER BY next_seqnumber DESC LIMIT 1; IF (FOUND) THEN -- Swap the seqnumber of the current bomitem and the next bomitem -- There is the potential for multiple bomitems with the same seqnumber UPDATE bomitem SET bomitem_seqnumber=0 WHERE (bomitem_seqnumber=_nextBomitem.next_seqnumber) AND (bomitem_parent_item_id=_nextBomitem.parent_item_id) AND (bomitem_rev_id=_nextBomitem.rev_id); UPDATE bomitem SET bomitem_seqnumber=_nextBomitem.next_seqnumber WHERE (bomitem_seqnumber=_nextBomitem.this_seqnumber) AND (bomitem_parent_item_id=_nextBomitem.parent_item_id) AND (bomitem_rev_id=_nextBomitem.rev_id); UPDATE bomitem SET bomitem_seqnumber=_nextBomitem.this_seqnumber WHERE (bomitem_seqnumber=0) AND (bomitem_parent_item_id=_nextBomitem.parent_item_id) AND (bomitem_rev_id=_nextBomitem.rev_id); END IF; RETURN 1; END; $_$; -DROP FUNCTION public.movebomitemup(integer); publicadminfalse84623125579036moveccarddown(integer)FUNCTIONCREATE FUNCTION moveccarddown(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCcardid ALIAS FOR $1; _nextCcard RECORD; BEGIN SELECT nextCcard.ccard_id, nextCcard.ccard_seq AS next_seqnumber, thisCcard.ccard_seq AS this_seqnumber INTO _nextCcard FROM Ccard AS nextCcard, Ccard AS thisCcard WHERE ((nextCcard.ccard_seq > thisCcard.ccard_seq) AND (nextCcard.ccard_cust_id=thisCcard.ccard_cust_id) AND (thisCcard.ccard_id=pCcardid)) ORDER BY next_seqnumber LIMIT 1; IF (FOUND) THEN -- Swap the seqnumber of the current Ccard and the next Ccard UPDATE Ccard SET ccard_seq=_nextCcard.next_seqnumber WHERE (ccard_id=pCcardid); UPDATE Ccard SET ccard_seq=_nextCcard.this_seqnumber WHERE (ccard_id=_nextCcard.ccard_id); END IF; RETURN 1; END; $_$; -DROP FUNCTION public.moveccarddown(integer); publicadminfalse46238125579037moveccardup(integer)FUNCTIONCREATE FUNCTION moveccardup(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCcardid ALIAS FOR $1; _nextCcard RECORD; BEGIN SELECT nextCcard.ccard_id AS ccard_id, nextCcard.ccard_seq AS next_seqnumber, thisCcard.ccard_seq AS this_seqnumber INTO _nextCcard FROM ccard AS nextCcard, ccard AS thisCcard WHERE ((nextCcard.ccard_seq < thisCcard.ccard_seq) AND (nextCcard.ccard_cust_id=thisCcard.ccard_cust_id) AND (thisCcard.ccard_id=pCcardid)) ORDER BY next_seqnumber DESC LIMIT 1; IF (FOUND) THEN -- Swap the seqnumber of the current Ccard and the next Ccard UPDATE Ccard SET ccard_seq=_nextCcard.next_seqnumber WHERE (ccard_id=pCcardid); UPDATE Ccard SET ccard_seq=_nextCcard.this_seqnumber WHERE (ccard_id=_nextCcard.ccard_id); END IF; RETURN 1; END; $_$; +DROP FUNCTION public.moveccardup(integer); publicadminfalse46238125579038moveflgroupdown(integer)FUNCTIONCREATE FUNCTION moveflgroupdown(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlgrpid ALIAS FOR $1; _from RECORD; _to RECORD; BEGIN SELECT flgrp_id AS id, flgrp_flhead_id AS flhead_id, flgrp_flgrp_id AS flgrp_id, flgrp_order AS ord INTO _from FROM flgrp WHERE (flgrp_id=pFlgrpid); IF (NOT FOUND) THEN RETURN -1; END IF; SELECT id, type, ord INTO _to FROM (SELECT flitem_id AS id, 'I' AS type, flitem_order AS ord FROM flitem WHERE ((flitem_flgrp_id=_from.flgrp_id) AND (flitem_flhead_id=_from.flhead_id)) UNION SELECT flgrp_id AS id, 'G' AS type, flgrp_order AS ord FROM flgrp WHERE ((flgrp_flgrp_id=_from.flgrp_id) AND (flgrp_flhead_id=_from.flhead_id)) UNION SELECT flspec_id AS id, 'S' AS type, flspec_order AS ord FROM flspec WHERE ((flspec_flgrp_id=_from.flgrp_id) AND (flspec_flhead_id=_from.flhead_id)) ) AS data WHERE (ord > _from.ord) ORDER BY ord LIMIT 1; IF (FOUND) THEN UPDATE flgrp SET flgrp_order=_to.ord WHERE (flgrp_id=_from.id); IF (_to.type='I') THEN UPDATE flitem SET flitem_order=_from.ord WHERE (flitem_id=_to.id); ELSE IF (_to.type='G') THEN UPDATE flgrp SET flgrp_order=_from.ord WHERE (flgrp_id=_to.id); ELSE IF (_to.type='S') THEN UPDATE flspec SET flspec_order=_from.ord WHERE (flspec_id=_to.id); END IF; END IF; END IF; END IF; RETURN 0; END; $_$; /DROP FUNCTION public.moveflgroupdown(integer); publicadminfalse84623125579039moveflgroupup(integer)FUNCTION CREATE FUNCTION moveflgroupup(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlgrpid ALIAS FOR $1; _from RECORD; _to RECORD; BEGIN SELECT flgrp_id AS id, flgrp_flhead_id AS flhead_id, flgrp_flgrp_id AS flgrp_id, flgrp_order AS ord INTO _from FROM flgrp WHERE (flgrp_id=pFlgrpid); IF (NOT FOUND) THEN RETURN -1; END IF; SELECT id, type, ord INTO _to FROM (SELECT flitem_id AS id, 'I' AS type, flitem_order AS ord FROM flitem WHERE ((flitem_flgrp_id=_from.flgrp_id) AND (flitem_flhead_id=_from.flhead_id)) UNION SELECT flgrp_id AS id, 'G' AS type, flgrp_order AS ord FROM flgrp WHERE ((flgrp_flgrp_id=_from.flgrp_id) AND (flgrp_flhead_id=_from.flhead_id)) UNION SELECT flspec_id AS id, 'S' AS type, flspec_order AS ord FROM flspec WHERE ((flspec_flgrp_id=_from.flgrp_id) AND (flspec_flhead_id=_from.flhead_id)) ) AS data WHERE (ord < _from.ord) ORDER BY ord DESC LIMIT 1; IF (FOUND) THEN UPDATE flgrp SET flgrp_order=_to.ord WHERE (flgrp_id=_from.id); IF (_to.type='I') THEN UPDATE flitem SET flitem_order=_from.ord WHERE (flitem_id=_to.id); ELSE IF (_to.type='G') THEN UPDATE flgrp SET flgrp_order=_from.ord WHERE (flgrp_id=_to.id); ELSE IF (_to.type='S') THEN UPDATE flspec SET flspec_order=_from.ord WHERE (flspec_id=_to.id); END IF; END IF; END IF; END IF; RETURN 0; END; $_$; -DROP FUNCTION public.moveflgroupup(integer); publicadminfalse84623125579040moveflitemdown(integer)FUNCTIONCREATE FUNCTION moveflitemdown(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlitemid ALIAS FOR $1; _from RECORD; _to RECORD; BEGIN SELECT flitem_id AS id, flitem_flhead_id AS flhead_id, flitem_flgrp_id AS flgrp_id, flitem_order AS ord INTO _from FROM flitem WHERE (flitem_id=pFlitemid); IF (NOT FOUND) THEN RETURN -1; END IF; SELECT id, type, ord INTO _to FROM (SELECT flitem_id AS id, 'I' AS type, flitem_order AS ord FROM flitem WHERE ((flitem_flgrp_id=_from.flgrp_id) AND (flitem_flhead_id=_from.flhead_id)) UNION SELECT flgrp_id AS id, 'G' AS type, flgrp_order AS ord FROM flgrp WHERE ((flgrp_flgrp_id=_from.flgrp_id) AND (flgrp_flhead_id=_from.flhead_id)) UNION SELECT flspec_id AS id, 'S' AS type, flspec_order AS ord FROM flspec WHERE ((flspec_flgrp_id=_from.flgrp_id) AND (flspec_flhead_id=_from.flhead_id)) ) AS data WHERE (ord > _from.ord) ORDER BY ord LIMIT 1; IF (FOUND) THEN UPDATE flitem SET flitem_order=_to.ord WHERE (flitem_id=_from.id); IF (_to.type='I') THEN UPDATE flitem SET flitem_order=_from.ord WHERE (flitem_id=_to.id); ELSE IF (_to.type='G') THEN UPDATE flgrp SET flgrp_order=_from.ord WHERE (flgrp_id=_to.id); ELSE IF (_to.type='S') THEN UPDATE flspec SET flspec_order=_from.ord WHERE (flspec_id=_to.id); END IF; END IF; END IF; END IF; RETURN 0; END; $_$; .DROP FUNCTION public.moveflitemdown(integer); publicadminfalse84623125579041moveflitemup(integer)FUNCTIONCREATE FUNCTION moveflitemup(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlitemid ALIAS FOR $1; _from RECORD; _to RECORD; BEGIN SELECT flitem_id AS id, flitem_flhead_id AS flhead_id, flitem_flgrp_id AS flgrp_id, flitem_order AS ord INTO _from FROM flitem WHERE (flitem_id=pFlitemid); IF (NOT FOUND) THEN RETURN -1; END IF; SELECT id, type, ord INTO _to FROM (SELECT flitem_id AS id, 'I' AS type, flitem_order AS ord FROM flitem WHERE ((flitem_flgrp_id=_from.flgrp_id) AND (flitem_flhead_id=_from.flhead_id)) UNION SELECT flgrp_id AS id, 'G' AS type, flgrp_order AS ord FROM flgrp WHERE ((flgrp_flgrp_id=_from.flgrp_id) AND (flgrp_flhead_id=_from.flhead_id)) UNION SELECT flspec_id AS id, 'S' AS type, flspec_order AS ord FROM flspec WHERE ((flspec_flgrp_id=_from.flgrp_id) AND (flspec_flhead_id=_from.flhead_id)) ) AS data WHERE (ord < _from.ord) ORDER BY ord DESC LIMIT 1; IF (FOUND) THEN UPDATE flitem SET flitem_order=_to.ord WHERE (flitem_id=_from.id); IF (_to.type='I') THEN UPDATE flitem SET flitem_order=_from.ord WHERE (flitem_id=_to.id); ELSE IF (_to.type='G') THEN UPDATE flgrp SET flgrp_order=_from.ord WHERE (flgrp_id=_to.id); ELSE IF (_to.type='S') THEN UPDATE flspec SET flspec_order=_from.ord WHERE (flspec_id=_to.id); END IF; END IF; END IF; END IF; RETURN 0; END; $_$; ,DROP FUNCTION public.moveflitemup(integer); publicadminfalse46238125579042moveflspecdown(integer)FUNCTIONCREATE FUNCTION moveflspecdown(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlspecid ALIAS FOR $1; _from RECORD; _to RECORD; BEGIN SELECT flspec_id AS id, flspec_flhead_id AS flhead_id, flspec_flgrp_id AS flgrp_id, flspec_order AS ord INTO _from FROM flspec WHERE (flspec_id=pFlspecid); IF (NOT FOUND) THEN RETURN -1; END IF; SELECT id, type, ord INTO _to FROM (SELECT flitem_id AS id, 'I' AS type, flitem_order AS ord FROM flitem WHERE ((flitem_flgrp_id=_from.flgrp_id) AND (flitem_flhead_id=_from.flhead_id)) UNION SELECT flgrp_id AS id, 'G' AS type, flgrp_order AS ord FROM flgrp WHERE ((flgrp_flgrp_id=_from.flgrp_id) AND (flgrp_flhead_id=_from.flhead_id)) UNION SELECT flspec_id AS id, 'S' AS type, flspec_order AS ord FROM flspec WHERE ((flspec_flgrp_id=_from.flgrp_id) AND (flspec_flhead_id=_from.flhead_id)) ) AS data WHERE (ord > _from.ord) ORDER BY ord LIMIT 1; IF (FOUND) THEN UPDATE flspec SET flspec_order=_to.ord WHERE (flspec_id=_from.id); IF (_to.type='I') THEN UPDATE flitem SET flitem_order=_from.ord WHERE (flitem_id=_to.id); ELSE IF (_to.type='G') THEN UPDATE flgrp SET flgrp_order=_from.ord WHERE (flgrp_id=_to.id); ELSE IF (_to.type='S') THEN UPDATE flspec SET flspec_order=_from.ord WHERE (flspec_id=_to.id); END IF; END IF; END IF; END IF; RETURN 0; END; $_$; .DROP FUNCTION public.moveflspecdown(integer); publicadminfalse46238125579043moveflspecup(integer)FUNCTIONCREATE FUNCTION moveflspecup(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pFlspecid ALIAS FOR $1; _from RECORD; _to RECORD; BEGIN SELECT flspec_id AS id, flspec_flhead_id AS flhead_id, flspec_flgrp_id AS flgrp_id, flspec_order AS ord INTO _from FROM flspec WHERE (flspec_id=pFlspecid); IF (NOT FOUND) THEN RETURN -1; END IF; SELECT id, type, ord INTO _to FROM (SELECT flitem_id AS id, 'I' AS type, flitem_order AS ord FROM flitem WHERE ((flitem_flgrp_id=_from.flgrp_id) AND (flitem_flhead_id=_from.flhead_id)) UNION SELECT flgrp_id AS id, 'G' AS type, flgrp_order AS ord FROM flgrp WHERE ((flgrp_flgrp_id=_from.flgrp_id) AND (flgrp_flhead_id=_from.flhead_id)) UNION SELECT flspec_id AS id, 'S' AS type, flspec_order AS ord FROM flspec WHERE ((flspec_flgrp_id=_from.flgrp_id) AND (flspec_flhead_id=_from.flhead_id)) ) AS data WHERE (ord < _from.ord) ORDER BY ord DESC LIMIT 1; IF (FOUND) THEN UPDATE flspec SET flspec_order=_to.ord WHERE (flspec_id=_from.id); IF (_to.type='I') THEN UPDATE flitem SET flitem_order=_from.ord WHERE (flitem_id=_to.id); ELSE IF (_to.type='G') THEN UPDATE flgrp SET flgrp_order=_from.ord WHERE (flgrp_id=_to.id); ELSE IF (_to.type='S') THEN UPDATE flspec SET flspec_order=_from.ord WHERE (flspec_id=_to.id); END IF; END IF; END IF; END IF; RETURN 0; END; $_$; ,DROP FUNCTION public.moveflspecup(integer); publicadminfalse84623125579044%movescript(integer, integer, integer)FUNCTION CREATE FUNCTION movescript(integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pscriptid ALIAS FOR $1; poldpkgid ALIAS FOR $2; pnewpkgid ALIAS FOR $3; _deletestr TEXT; _destination TEXT; _insertstr TEXT; _rows INTEGER; _selectstr TEXT; _source TEXT; _record RECORD; BEGIN IF (poldpkgid = pnewpkgid) THEN RETURN 0; END IF; IF (poldpkgid = -1) THEN _source = 'public.script'; ELSE SELECT pkghead_name || '.pkgscript' INTO _source FROM pkghead WHERE pkghead_id=poldpkgid; IF NOT FOUND THEN RETURN -1; END IF; END IF; IF (pnewpkgid = -1) THEN _destination = 'public.script'; ELSE SELECT pkghead_name || '.pkgscript' INTO _destination FROM pkghead WHERE pkghead_id=pnewpkgid; IF NOT FOUND THEN RETURN -2; END IF; END IF; _selectstr := ' SELECT * FROM ' || _source || ' WHERE script_id = ' || pscriptid; EXECUTE _selectstr INTO _record; _deletestr := 'DELETE FROM ONLY ' || _source || ' WHERE script_id = ' || pscriptid; EXECUTE _deletestr; GET DIAGNOSTICS _rows = ROW_COUNT; --RAISE NOTICE '% rows from %', _rows, _deletestr; IF (_rows < 1) THEN RETURN -3; ELSIF (_rows > 1) THEN RAISE EXCEPTION 'Tried to delete % scripts with the id % when there should be exactly 1', _rows, pscriptid; END IF; _insertstr := 'INSERT INTO ' || _destination || ' (script_id, script_name, script_order, script_enabled, ' || ' script_source, script_notes) VALUES (' || _record.script_id || ',' || quote_literal(_record.script_name) || ',' || _record.script_order || ',' || _record.script_enabled || ',' || quote_literal(_record.script_source) || ',' || quote_literal(_record.script_notes ) || ');' ; EXECUTE _insertstr; GET DIAGNOSTICS _rows = ROW_COUNT; --RAISE NOTICE '% rows from %', _rows, _insertstr; IF (_rows < 1) THEN RETURN -4; ELSIF (_rows > 1) THEN RAISE EXCEPTION 'Tried to insert % scripts with the id % when there should be exactly 1', _rows, pscriptid; END IF; RETURN pscriptid; END; $_$; <DROP FUNCTION public.movescript(integer, integer, integer); publicadminfalse84623125579045%moveuiform(integer, integer, integer)FUNCTION CREATE FUNCTION moveuiform(integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE puiformid ALIAS FOR $1; poldpkgid ALIAS FOR $2; pnewpkgid ALIAS FOR $3; _deletestr TEXT; _destination TEXT; _insertstr TEXT; _rows INTEGER; _selectstr TEXT; _source TEXT; _record RECORD; BEGIN IF (poldpkgid = pnewpkgid) THEN RETURN 0; END IF; IF (poldpkgid = -1) THEN _source = 'public.uiform'; ELSE SELECT pkghead_name || '.pkguiform' INTO _source FROM pkghead WHERE pkghead_id=poldpkgid; IF NOT FOUND THEN RETURN -1; END IF; END IF; IF (pnewpkgid = -1) THEN _destination = 'public.uiform'; ELSE SELECT pkghead_name || '.pkguiform' INTO _destination FROM pkghead WHERE pkghead_id=pnewpkgid; IF NOT FOUND THEN RETURN -2; END IF; END IF; _selectstr := ' SELECT * FROM ' || _source || ' WHERE uiform_id = ' || puiformid; EXECUTE _selectstr INTO _record; _deletestr := 'DELETE FROM ONLY ' || _source || ' WHERE uiform_id = ' || puiformid; EXECUTE _deletestr; GET DIAGNOSTICS _rows = ROW_COUNT; --RAISE NOTICE '% rows from %', _rows, _deletestr; IF (_rows < 1) THEN RETURN -3; ELSIF (_rows > 1) THEN RAISE EXCEPTION 'Tried to delete % uiforms with the id % when there should be exactly 1', _rows, puiformid; END IF; _insertstr := 'INSERT INTO ' || _destination || ' (uiform_id, uiform_name, uiform_order, uiform_enabled, ' || ' uiform_source, uiform_notes) VALUES (' || _record.uiform_id || ',' || quote_literal(_record.uiform_name) || ',' || _record.uiform_order || ',' || _record.uiform_enabled || ',' || quote_literal(_record.uiform_source) || ',' || quote_literal(_record.uiform_notes ) || ');' ; EXECUTE _insertstr; GET DIAGNOSTICS _rows = ROW_COUNT; --RAISE NOTICE '% rows from %', _rows, _insertstr; IF (_rows < 1) THEN RETURN -4; ELSIF (_rows > 1) THEN RAISE EXCEPTION 'Tried to insert % uiforms with the id % when there should be exactly 1', _rows, puiformid; END IF; RETURN puiformid; END; $_$; <DROP FUNCTION public.moveuiform(integer, integer, integer); publicadminfalse462381255790467moveupdown(integer, text, text, text, text, text, text)FUNCTIONB CREATE FUNCTION moveupdown(pid integer, pschema text, ptable text, pseqcol text, pjoincol text, pextra text, pdir text) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE _keyfield TEXT; _keysize INTEGER; _qry TEXT; _r RECORD; _rowcnt INTEGER; _schema TEXT := COALESCE(pSchema, 'public'); BEGIN RAISE DEBUG 'moveUpDown(%, %, %, %, %, %, %) entered', pId, pSchema, pTable, pSeqCol, pJoinCol, pExtra, pDir; IF (UPPER(pDir) NOT IN ('UP', 'DOWN')) THEN RAISE EXCEPTION 'Cannot change the order of records; unsure what % means for sequencing [xtuple: moveUpDown, -1, %, %.%]', pDir, pDir, _schema, pTable; END IF; SELECT attname, ARRAY_UPPER(conkey, 1) INTO _keyfield, _keysize FROM pg_attribute JOIN pg_constraint ON (attrelid=conrelid AND attnum=conkey[1]) JOIN pg_class ON (conrelid=pg_class.oid) JOIN pg_namespace ON (relnamespace=pg_namespace.oid) WHERE ((contype='p') AND (nspname=_schema) AND (relname=pTable)); RAISE DEBUG 'SELECT attname... returned %, %', _keyfield, _keysize; IF (_keysize > 1) THEN RAISE EXCEPTION 'Cannot change the order of records because %.% has a composite primary key [xtuple: moveUpDown, -2, %.%]', _schema, pTable, _schema, pTable; END IF; /* SELECT next._keyfield AS nextid, next.pSeqCol AS nextseq, this.pSeqCol AS thisseq FROM _schema.pTable AS next, _schema.pTable AS this WHERE (this._keyfield=$1) AND (next.pSeqCol [> or <] this.pSeqCol) [ AND (next.pJoinCol=this.pJoinCol) ] [ AND (pExtra) ] ORDER BY nextseq [ DESC or ASC ] LIMIT 1; */ _qry := 'SELECT next.' || quote_ident(_keyfield) || ' AS nextid, next.' || quote_ident(pSeqCol) || ' AS nextseq, this.' || quote_ident(pSeqCol) || ' AS thisseq FROM ' || _schema || '.' || quote_ident(pTable) || ' AS next, ' || _schema || '.' || quote_ident(pTable) || ' AS this WHERE ((this.' || quote_ident(_keyfield) || '=$1) AND (next.' || quote_ident(pSeqCol) || CASE pDir WHEN 'UP' THEN ' < ' ELSE ' > ' END || 'this.' || quote_ident(pSeqCol) || ')' || CASE WHEN pJoinCol IS NULL THEN '' ELSE ' AND (next.' || quote_ident(pJoinCol) || '=this.' || quote_ident(pJoinCol) || ')' END || ' AND (' || COALESCE(pExtra, 'TRUE') || ')) ORDER BY nextseq ' || CASE pDir WHEN 'UP' THEN 'DESC' ELSE 'ASC' END || ' LIMIT 1;'; RAISE DEBUG 'moveUpDown about to use % when running %', pId, _qry; EXECUTE _qry INTO _r USING pId; GET DIAGNOSTICS _rowcnt = ROW_COUNT; RAISE DEBUG 'next id %, next seq %, this id %, this seq %', _r.nextid, _r.nextseq, pId, _r.thisseq; IF (_rowcnt > 0) THEN _qry := 'UPDATE ' || _schema || '.' || quote_ident(pTable) || ' SET ' || pSeqCol || '=CAST($1 AS INTEGER) WHERE (' || quote_ident(_keyfield) || '=$2);'; EXECUTE _qry USING -1, _r.nextid; EXECUTE _qry USING _r.nextseq, pId; EXECUTE _qry USING _r.thisseq, _r.nextid; RETURN _r.nextid; END IF; RETURN pId; END; $_$; ~DROP FUNCTION public.moveupdown(pid integer, pschema text, ptable text, pseqcol text, pjoincol text, pextra text, pdir text); publicadminfalse46238Q&00pFUNCTION moveupdown(pid integer, pschema text, ptable text, pseqcol text, pjoincol text, pextra text, pdir text)COMMENT4COMMENT ON FUNCTION moveupdown(pid integer, pschema text, ptable text, pseqcol text, pjoincol text, pextra text, pdir text) IS 'moveUpDown moves a particular record up or down in an ordered list. pId argument names the record to move. pSchema (uses public if NULL) and pTable name the table holding the list. pSeqCol is the column that holds the sequence number. pJoinCol is the column that distinguishes one list from another in the same table, or NULL if the table holds only one list. pExtra is an extra join clause that may be required, or NULL. pDir is either UP, meaning move the pId record closer to the beginning, or DOWN. Returns the id of the record with which pId was swapped, or pId if the record was already at the end in the specified direction.'; publicadminfalse1822 125579047&nextperiodbyinterval(integer, integer)FUNCTIONYCREATE FUNCTION nextperiodbyinterval(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodid ALIAS FOR $1; pInterval ALIAS FOR $2; _periodid INTEGER; BEGIN SELECT b.period_id INTO _periodid FROM period AS a, period AS b WHERE ((a.period_id=pPeriodid) AND (b.period_start >= a.period_start)) ORDER BY b.period_start LIMIT 1 OFFSET pInterval; IF (NOT FOUND) THEN RETURN -1; END IF; RETURN _periodid; END; $_$; =DROP FUNCTION public.nextperiodbyinterval(integer, integer); publicadminfalse84623125579048nextprsubnumber(integer)FUNCTIONCREATE FUNCTION nextprsubnumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrNumber ALIAS FOR $1; _subNumber INTEGER; BEGIN SELECT MAX(pr_subnumber) INTO _subNumber FROM pr WHERE (pr_number=pPrNumber); IF (_subNumber IS NULL) THEN _subNumber := 0; END IF; RETURN (_subNumber + 1); END; $_$; /DROP FUNCTION public.nextprsubnumber(integer); publicadminfalse84623125579049nextwosubnumber(integer)FUNCTION&CREATE FUNCTION nextwosubnumber(integer) RETURNS integer LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT COALESCE((MAX(wo_subnumber) + 1), 1) FROM wo WHERE (wo_number=($1)); $_$; /DROP FUNCTION public.nextwosubnumber(integer); publicadminfalse8125579050noneg(numeric)FUNCTIONSCREATE FUNCTION noneg(numeric) RETURNS numeric LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pValue ALIAS FOR $1; BEGIN IF (pValue < 0) THEN RETURN 0; ELSE RETURN pValue; END IF; END; $_$; %DROP FUNCTION public.noneg(numeric); publicadminfalse84623125579051nopos(numeric)FUNCTIONSCREATE FUNCTION nopos(numeric) RETURNS numeric LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pValue ALIAS FOR $1; BEGIN IF (pValue > 0) THEN RETURN 0; ELSE RETURN pValue; END IF; END; $_$; %DROP FUNCTION public.nopos(numeric); publicadminfalse84623 125579052%normalizetrialbal(integer, character)FUNCTIONCREATE FUNCTION normalizetrialbal(integer, character) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTrialbalid ALIAS FOR $1; pSide ALIAS FOR $2; _value NUMERIC; _r RECORD; BEGIN SELECT accnt_type, trialbal_beginning, trialbal_ending INTO _r FROM trialbal, accnt WHERE ( (trialbal_accnt_id=accnt_id) AND (trialbal_id=pTrialbalid) ); IF (NOT FOUND) THEN RETURN -1; END IF; -- If we are looking for the Ending Balance, cache it IF (pSide = 'E') THEN _value = _r.trialbal_ending; -- We had better been looking for the Beginning Balance! ELSE _value = _r.trialbal_beginning; END IF; -- If the accnt_type is Asset or Expense, swap the sense IF (_r.accnt_type IN ('A', 'E')) THEN _value := (_value * -1); END IF; RETURN _value; END; $_$; <DROP FUNCTION public.normalizetrialbal(integer, character); publicadminfalse84623!125579053numofdatabaseusers()FUNCTIONCREATE FUNCTION numofdatabaseusers() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN numOfDatabaseUsers(NULL); END; $$; +DROP FUNCTION public.numofdatabaseusers(); publicadminfalse46238"125587058numofdatabaseusers(text)FUNCTION|CREATE FUNCTION numofdatabaseusers(pappname text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _count INTEGER; BEGIN -- in version 9.2.0 the column "procpid" was changed to just "pid" Incident #21852 IF (compareversion('9.2.0') <= 0) THEN SELECT count(*) INTO _count FROM pg_locks LEFT JOIN pg_stat_activity ON pg_stat_activity.pid = pg_locks.pid WHERE (pg_locks.objsubid = 2) AND (pg_stat_activity.datname = current_database()) AND CASE WHEN (trim(coalesce(pAppName, '')) = '') THEN true ELSE application_name = pAppName END; ELSE SELECT count(*) INTO _count FROM pg_locks LEFT JOIN pg_stat_activity ON pg_stat_activity.procpid = pg_locks.pid WHERE (pg_locks.objsubid = 2) AND (pg_stat_activity.datname = current_database()) AND CASE WHEN (trim(coalesce(pAppName, '')) = '') THEN true ELSE application_name = pAppName END; END IF; IF (_count IS NULL) THEN _count := 0; END IF; RETURN _count; END; $$; 8DROP FUNCTION public.numofdatabaseusers(pappname text); publicadminfalse46238#125579054numofserverusers()FUNCTIONCREATE FUNCTION numofserverusers() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _count INTEGER; BEGIN SELECT COUNT(*) INTO _count FROM pg_stat_activity WHERE datname = current_database(); IF (_count IS NULL) THEN _count := 0; END IF; RETURN _count; END; $$; )DROP FUNCTION public.numofserverusers(); publicadminfalse46238$125579055openaccountingperiod(integer)FUNCTIONCREATE FUNCTION openaccountingperiod(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodid ALIAS FOR $1; _r RECORD; BEGIN -- Check to make use that the period is closed IF ( ( SELECT (NOT period_closed) FROM period WHERE (period_id=pPeriodid) ) ) THEN RETURN -1; END IF; IF ( ( SELECT (count(period_id) > 0) FROM period WHERE ((period_end > ( SELECT period_end FROM period WHERE (period_id=pPeriodId)) ) AND (period_closed)) ) ) THEN RETURN -3; END IF; -- Make sure the year is open IF ( ( SELECT (yearperiod_closed) FROM yearperiod JOIN period ON (period_yearperiod_id=yearperiod_id) WHERE (period_id=pPeriodid) ) ) THEN RETURN -4; END IF; -- Reset the period_closed flag UPDATE period SET period_closed=FALSE WHERE (period_id=pPeriodid); -- Post any unposted G/L Transactions into the new period FOR _r IN SELECT DISTINCT gltrans_sequence FROM gltrans, period WHERE ( (NOT gltrans_posted) AND (gltrans_date BETWEEN period_start AND period_end) AND (period_id=pPeriodid) ) LOOP PERFORM postIntoTrialBalance(_r.gltrans_sequence); END LOOP; RETURN pPeriodid; END; $_$; 4DROP FUNCTION public.openaccountingperiod(integer); publicadminfalse46238%125579056!openaccountingyearperiod(integer)FUNCTIONCREATE FUNCTION openaccountingyearperiod(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pYearPeriodId ALIAS FOR $1; _r RECORD; BEGIN -- Check to make use that the yearperiod is closed IF ( ( SELECT (NOT yearperiod_closed) FROM yearperiod WHERE (yearperiod_id=pYearPeriodId) ) ) THEN RETURN -1; END IF; IF ( ( SELECT (count(yearperiod_id) > 0) FROM yearperiod WHERE ((yearperiod_end> ( SELECT yearperiod_end FROM yearperiod WHERE (yearperiod_id=pYearPeriodId)) ) AND (yearperiod_closed)) ) ) THEN RETURN -2; END IF; -- Reset the yearperiod_closed flag UPDATE yearperiod SET yearperiod_closed=FALSE WHERE (yearperiod_id=pYearPeriodId); RETURN pYearPeriodid; END; $_$; 8DROP FUNCTION public.openaccountingyearperiod(integer); publicadminfalse46238&125579057"openapitemsvalue(integer, integer)FUNCTIONCREATE FUNCTION openapitemsvalue(pvendid integer, pperiodid integer) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _value NUMERIC; BEGIN SELECT SUM( (apopen_amount - apopen_paid) / apopen_curr_rate * CASE WHEN (apopen_doctype IN ('D', 'V')) THEN 1 ELSE -1 END ) INTO _value FROM apopen WHERE ( (apopen_open) AND (apopen_vend_id=pVendid) AND (apopen_duedate BETWEEN findPeriodStart(pPeriodid) AND findPeriodEnd(pPeriodid)) ); RETURN COALESCE(_value, 0.0); END; $$; KDROP FUNCTION public.openapitemsvalue(pvendid integer, pperiodid integer); publicadminfalse46238'125579058"openaritemsvalue(integer, integer)FUNCTIONCREATE FUNCTION openaritemsvalue(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; pPeriodid ALIAS FOR $2; _value NUMERIC; BEGIN SELECT SUM( CASE WHEN (aropen_doctype IN ('C', 'R')) THEN ((aropen_amount - aropen_paid) * -1) ELSE (aropen_amount - aropen_paid) END ) INTO _value FROM aropen WHERE ( (aropen_open) AND (aropen_cust_id=pCustid) AND (aropen_duedate BETWEEN findPeriodStart(pPeriodid) AND findPeriodEnd(pPeriodid)) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; 9DROP FUNCTION public.openaritemsvalue(integer, integer); publicadminfalse84623*125579059;openrecurringitems(integer, text, timestamp with time zone)FUNCTIONCREATE FUNCTION openrecurringitems(integer, text, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pParentid ALIAS FOR $1; pType TEXT := UPPER($2); pDatetime TIMESTAMP WITH TIME ZONE := COALESCE($3, CURRENT_TIMESTAMP); _count INTEGER := -1; _countstmt TEXT; _rt RECORD; BEGIN IF (pParentid IS NULL) THEN RETURN -11; END IF; SELECT * INTO _rt FROM recurtype WHERE (UPPER(recurtype_type)=pType); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count <= 0) THEN RETURN -10; END IF; _countstmt := 'SELECT COUNT(*) FROM [fulltable]' || ' WHERE (NOT ([done])' || ' AND ([schedcol]>=''$1'')' || ' AND ([table]_recurring_[table]_id=''$2''));'; _countstmt := REPLACE(_countstmt, '[fulltable]', _rt.recurtype_table); _countstmt := REPLACE(_countstmt, '[table]', REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', '')); _countstmt := REPLACE(_countstmt, '[done]', _rt.recurtype_donecheck); _countstmt := REPLACE(_countstmt, '[schedcol]', _rt.recurtype_schedcol); -- 8.4+: EXECUTE _countstmt INTO _count USING pDatetime, pParentid; EXECUTE REPLACE(REPLACE(_countstmt, '$1', pDatetime::TEXT), '$2', pParentid::TEXT) INTO _count; RETURN _count; END; $_$; RDROP FUNCTION public.openrecurringitems(integer, text, timestamp with time zone); publicadminfalse46238125979060opheadTABLECREATE TABLE ophead ( ophead_id integer NOT NULL, ophead_name text NOT NULL, ophead_crmacct_id integer, ophead_owner_username text, ophead_opstage_id integer, ophead_opsource_id integer, ophead_optype_id integer, ophead_probability_prcnt integer, ophead_amount numeric(20,4), ophead_target_date date, ophead_actual_date date, ophead_notes text, ophead_curr_id integer, ophead_active boolean DEFAULT true, ophead_cntct_id integer, ophead_username text, ophead_start_date date, ophead_assigned_date date, ophead_priority_id integer, ophead_number text NOT NULL, CONSTRAINT ophead_ophead_number_check CHECK ((ophead_number <> ''::text)) ); DROP TABLE public.ophead; publicadminfalse609060918R&00 TABLE opheadCOMMENT2COMMENT ON TABLE ophead IS 'Opportunity header.'; publicadminfalse210S&00opheadACLREVOKE ALL ON TABLE ophead FROM PUBLIC; REVOKE ALL ON TABLE ophead FROM admin; GRANT ALL ON TABLE ophead TO admin; GRANT ALL ON TABLE ophead TO xtrole; publicadminfalse210+125579068ophead()FUNCTION3CREATE FUNCTION ophead() RETURNS SETOF ophead LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row ophead%ROWTYPE; _priv TEXT; _grant BOOLEAN; BEGIN -- This query will give us the most permissive privilege the user has been granted SELECT privilege, granted INTO _priv, _grant FROM privgranted WHERE privilege IN ('MaintainAllOpportunities','ViewAllOpportunities','MaintainPersonalOpportunities','ViewPersonalOpportunities') ORDER BY granted DESC, sequence LIMIT 1; -- If have an 'All' privilege return all results IF (_priv ~ 'All' AND _grant) THEN FOR _row IN SELECT * FROM ophead LOOP RETURN NEXT _row; END LOOP; -- Otherwise if have any other grant, must be personal privilege. ELSIF (_grant) THEN FOR _row IN SELECT * FROM ophead WHERE getEffectiveXtUser() IN (ophead_owner_username, ophead_username) LOOP RETURN NEXT _row; END LOOP; END IF; RETURN; END; $$; DROP FUNCTION public.ophead(); publicadminfalse846232875T&00FUNCTION ophead()COMMENTvCOMMENT ON FUNCTION ophead() IS 'A table function that returns Opportunity results according to privilege settings.'; publicadminfalse1835,125579069orderedbypo(integer, integer)FUNCTIONCREATE FUNCTION orderedbypo(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pLookAhead ALIAS FOR $2; _qty NUMERIC; BEGIN SELECT orderedByPo(pItemsiteid, startOfTime(), (CURRENT_DATE + pLookAhead)) INTO _qty; RETURN _qty; END; $_$; 4DROP FUNCTION public.orderedbypo(integer, integer); publicadminfalse46238-125579070 orderedbypo(integer, date, date)FUNCTIONpCREATE FUNCTION orderedbypo(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _qty NUMERIC; BEGIN SELECT COALESCE(SUM(noNeg(poitem_qty_ordered - poitem_qty_received) * poitem_invvenduomratio), 0.0) INTO _qty FROM poitem WHERE ( (poitem_itemsite_id=pItemsiteid) AND (poitem_status <> 'C') AND (poitem_duedate BETWEEN pStartDate AND pEndDate) ); RETURN _qty; END; $_$; 7DROP FUNCTION public.orderedbypo(integer, date, date); publicadminfalse46238.125579071orderedbywo(integer, integer)FUNCTIONCREATE FUNCTION orderedbywo(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pLookAheadDays ALIAS FOR $2; BEGIN RETURN orderedByWo(pItemsiteid, startOfTime(), (CURRENT_DATE + pLookAheadDays)); END; $_$; 4DROP FUNCTION public.orderedbywo(integer, integer); publicadminfalse46238/125579072 orderedbywo(integer, date, date)FUNCTION CREATE FUNCTION orderedbywo(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _itemType CHARACTER(1); _qty NUMERIC := 0; BEGIN SELECT item_type INTO _itemType FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ); IF (_itemType NOT IN ('C','T')) THEN SELECT COALESCE(SUM(noNeg(wo_qtyord - wo_qtyrcv)), 0.0) INTO _qty FROM wo WHERE ( (wo_status <> 'C') AND (wo_itemsite_id=pItemsiteid) AND (wo_duedate BETWEEN pStartDate AND pEndDate) ); ELSIF (_itemType = 'C') THEN SELECT COALESCE(SUM((noNeg(wo_qtyord - wo_qtyrcv) * brddist_stdqtyper)), 0.0) INTO _qty FROM wo, xtmfg.brddist WHERE ( (wo_status <> 'C') AND (brddist_wo_id=wo_id) AND (brddist_itemsite_id=pItemsiteid) AND (wo_duedate BETWEEN pStartDate AND pEndDate) ); ELSIF (_itemType = 'T' AND fetchMetricBool('Routings')) THEN -- Tooling: Determine quantity already returned SELECT -- Qty Required COALESCE(SUM(noNeg(womatl_qtyreq)),0) - -- Qty Returned (SELECT COALESCE(SUM(abs(invhist_invqty)),0) FROM wo JOIN womatl ON (womatl_wo_id=wo_id) JOIN womatlpost ON (womatl_id=womatlpost_womatl_id) JOIN invhist ON ((womatlpost_invhist_id=invhist_id) AND (invhist_invqty < 0)) LEFT OUTER JOIN xtmfg.wooper ON (womatl_wooper_id=wooper_id) WHERE ( NOT (COALESCE(wooper_rncomplete,wo_status = 'C')) AND (womatl_itemsite_id=pItemsiteid) AND (wo_duedate BETWEEN pStartDate AND pEndDate) ) ) INTO _qty FROM wo JOIN womatl ON (womatl_wo_id=wo_id) LEFT OUTER JOIN xtmfg.wooper ON (womatl_wooper_id=wooper_id) WHERE ( NOT (COALESCE(wooper_rncomplete,wo_status = 'C')) AND (womatl_itemsite_id=pItemsiteid) AND (wo_duedate BETWEEN pStartDate AND pEndDate) ) GROUP BY womatl_qtyreq; ELSIF (_itemType = 'T') THEN -- Tooling: Determine quantity already returned SELECT -- Qty Required COALESCE(SUM(noNeg(womatl_qtyreq)),0) - -- Qty Returned (SELECT COALESCE(SUM(abs(invhist_invqty)),0) FROM wo JOIN womatl ON (womatl_wo_id=wo_id) JOIN womatlpost ON (womatl_id=womatlpost_womatl_id) JOIN invhist ON ((womatlpost_invhist_id=invhist_id) AND (invhist_invqty < 0)) WHERE ( NOT (wo_status = 'C') AND (womatl_itemsite_id=pItemsiteid) AND (wo_duedate BETWEEN pStartDate AND pEndDate) ) ) INTO _qty FROM wo JOIN womatl ON (womatl_wo_id=wo_id) WHERE ( NOT (wo_status = 'C') AND (womatl_itemsite_id=pItemsiteid) AND (wo_duedate BETWEEN pStartDate AND pEndDate) ) GROUP BY womatl_qtyreq; END IF; RETURN COALESCE(_qty,0); END; $_$; 7DROP FUNCTION public.orderedbywo(integer, date, date); publicadminfalse846230125587059 orderhead()FUNCTION( CREATE FUNCTION orderhead() RETURNS SETOF ordhead LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row ordhead%ROWTYPE; _query TEXT; BEGIN _query := ' SELECT DISTINCT * FROM ( SELECT pohead_id AS orderhead_id, ''PO'' AS orderhead_type, pohead_number AS orderhead_number, pohead_status AS orderhead_status, pohead_orderdate AS orderhead_orderdate, (SELECT count(*) FROM poitem WHERE poitem_pohead_id=pohead_id) AS orderhead_linecount, pohead_vend_id AS orderhead_from_id, vend_name AS orderhead_from, NULL AS orderhead_to_id, '''' AS orderhead_to, pohead_curr_id AS orderhead_curr_id, pohead_agent_username AS orderhead_agent_username, pohead_shipvia AS orderhead_shipvia FROM pohead LEFT OUTER JOIN vendinfo ON (pohead_vend_id=vend_id) UNION SELECT cohead_id AS orderhead_id, ''SO'' AS orderhead_type, cohead_number AS orderhead_number, COALESCE(coitem_status,''C'') AS orderhead_status, cohead_orderdate AS orderhead_orderdate, (SELECT count(*) FROM coitem WHERE coitem_cohead_id=cohead_id) AS orderhead_linecount, NULL AS orderhead_from_id, '''' AS orderhead_from, cohead_cust_id AS orderhead_to_id, cust_name AS orderhead_to, cohead_curr_id AS orderhead_curr_id, '''' AS orderhead_agent_username, cohead_shipvia AS orderhead_shipvia FROM cohead LEFT OUTER JOIN custinfo ON (cohead_cust_id=cust_id) LEFT OUTER JOIN coitem ON ((cohead_id=coitem_cohead_id) AND (coitem_status=''O''))'; IF (fetchmetricbool('MultiWhs')) THEN _query := _query || ' UNION SELECT tohead_id AS orderhead_id, ''TO'' AS orderhead_type, tohead_number AS orderhead_number, tohead_status AS orderhead_status, tohead_orderdate AS orderhead_orderdate, (SELECT count(*) FROM toitem WHERE toitem_tohead_id=tohead_id) AS orderhead_linecount, tohead_src_warehous_id AS orderhead_from_id, tohead_srcname AS orderhead_from, tohead_dest_warehous_id AS orderhead_to_id, tohead_destname AS orderhead_to, tohead_freight_curr_id AS orderhead_curr_id, tohead_agent_username AS orderhead_agent_username, tohead_shipvia AS orderhead_shipvia FROM tohead'; END IF; IF (fetchmetricbool('EnableReturnAuth')) THEN _query := _query || ' UNION SELECT rahead_id AS orderhead_id, ''RA'' AS orderhead_type, rahead_number AS orderhead_number, COALESCE(raitem_status,''C'') AS orderhead_status, rahead_authdate AS orderhead_orderdate, (SELECT count(*) FROM raitem WHERE raitem_rahead_id=rahead_id) AS orderhead_linecount, rahead_cust_id AS orderhead_from_id, cust_name AS orderhead_from, NULL AS orderhead_to_id, '''' AS orderhead_to, rahead_curr_id AS orderhead_curr_id, '''' AS orderhead_agent_username, '''' AS orderhead_shipvia FROM rahead LEFT OUTER JOIN custinfo ON (rahead_cust_id=cust_id) LEFT OUTER JOIN raitem ON ((rahead_id=raitem_rahead_id) AND (raitem_status=''O''))'; END IF; _query := _query || ') AS data ORDER BY orderhead_type, orderhead_number ;'; FOR _row IN EXECUTE _query LOOP RETURN NEXT _row; END LOOP; RETURN; END; $$; "DROP FUNCTION public.orderhead(); publicadminfalse8462342551125587060 orderitem()FUNCTIONCREATE FUNCTION orderitem() RETURNS SETOF orditem LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row orditem%ROWTYPE; _query TEXT; BEGIN _query := ' SELECT poitem_id AS orderitem_id, ''PO'' AS orderitem_orderhead_type, poitem_pohead_id AS orderitem_orderhead_id, poitem_linenumber AS orderitem_linenumber, poitem_status AS orderitem_status, poitem_itemsite_id AS orderitem_itemsite_id, poitem_duedate AS orderitem_scheddate, poitem_qty_ordered AS orderitem_qty_ordered, poitem_qty_returned AS orderitem_qty_shipped, poitem_qty_received AS orderitem_qty_received, uom_id AS orderitem_qty_uom_id, poitem_invvenduomratio AS orderitem_qty_invuomratio, poitem_unitprice AS orderitem_unitcost, pohead_curr_id AS orderitem_unitcost_curr_id, poitem_freight AS orderitem_freight, poitem_freight_received AS orderitem_freight_received, pohead_curr_id AS orderitem_freight_curr_id FROM poitem LEFT OUTER JOIN pohead ON (poitem_pohead_id=pohead_id) LEFT OUTER JOIN uom ON (uom_name=poitem_vend_uom) UNION SELECT coitem_id AS orderitem_id, ''SO'' AS orderitem_orderhead_type, coitem_cohead_id AS orderitem_orderhead_id, coitem_linenumber AS orderitem_linenumber, coitem_status AS orderitem_status, coitem_itemsite_id AS orderitem_itemsite_id, coitem_scheddate AS orderitem_scheddate, coitem_qtyord AS orderitem_qty_ordered, coitem_qtyshipped AS orderitem_qty_shipped, coitem_qtyreturned AS orderitem_qty_received, coitem_qty_uom_id AS orderitem_qty_uom_id, coitem_qty_invuomratio AS orderitem_qty_invuomratio, coitem_unitcost AS orderitem_unitcost, basecurrid() AS orderitem_unitcost_curr_id, NULL AS orderitem_freight, NULL AS orderitem_freight_received, basecurrid() AS orderitem_freight_curr_id FROM coitem'; IF (fetchmetricbool('MultiWhs')) THEN _query := _query || ' UNION SELECT toitem_id AS orderitem_id, ''TO'' AS orderitem_orderhead_type, toitem_tohead_id AS orderitem_orderhead_id, toitem_linenumber AS orderitem_linenumber, toitem_status AS orderitem_status, itemsite_id AS orderitem_itemsite_id, toitem_duedate AS orderitem_scheddate, toitem_qty_ordered AS orderitem_qty_ordered, toitem_qty_shipped AS orderitem_qty_shipped, toitem_qty_received AS orderitem_qty_received, uom_id AS orderitem_qty_uom_id, 1 AS orderitem_qty_invuomratio, toitem_stdcost AS orderitem_unitcost, basecurrid() AS orderitem_unitcost_curr_id, toitem_freight AS orderitem_freight, toitem_freight_received AS orderitem_freight_received, toitem_freight_curr_id AS orderitem_freight_curr_id FROM tohead, itemsite, toitem LEFT OUTER JOIN uom ON (uom_name=toitem_uom) WHERE ((toitem_tohead_id=tohead_id) AND (tohead_src_warehous_id=itemsite_warehous_id) AND (toitem_item_id=itemsite_item_id)) '; END IF; IF (fetchmetricbool('EnableReturnAuth')) THEN _query := _query || ' UNION SELECT raitem_id AS orderitem_id, ''RA'' AS orderitem_orderhead_type, raitem_rahead_id AS orderitem_orderhead_id, raitem_linenumber AS orderitem_linenumber, raitem_status AS orderitem_status, raitem_itemsite_id AS orderitem_itemsite_id, raitem_scheddate AS orderitem_scheddate, raitem_qtyauthorized AS orderitem_qty_ordered, 0 AS orderitem_qty_shipped, raitem_qtyreceived AS orderitem_qty_received, raitem_qty_uom_id AS orderitem_qty_uom_id, raitem_qty_invuomratio AS orderitem_qty_invuomratio, raitem_unitprice AS orderitem_unitcost, basecurrid() AS orderitem_unitcost_curr_id, NULL AS orderitem_freight, NULL AS orderitem_freight_received, basecurrid() AS orderitem_freight_curr_id FROM raitem'; END IF; FOR _row IN EXECUTE _query LOOP RETURN NEXT _row; END LOOP; RETURN; END; $$; "DROP FUNCTION public.orderitem(); publicadminfalse4258846232125579075%orderitemdata(text, integer, integer)FUNCTION(CREATE FUNCTION orderitemdata(text, integer, integer) RETURNS SETOF orderitemtype LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pOrdertype ALIAS FOR $1; pOrderheadid ALIAS FOR $2; pOrderitemid ALIAS FOR $3; _row orderitemtype%ROWTYPE; _set RECORD; BEGIN IF(UPPER(pOrdertype)='PO') THEN FOR _set IN SELECT poitem_id AS orderitem_id, 'PO' AS orderitem_orderhead_type, poitem_pohead_id AS orderitem_orderhead_id, poitem_linenumber AS orderitem_linenumber, poitem_status AS orderitem_status, poitem_itemsite_id AS orderitem_itemsite_id, poitem_duedate AS orderitem_scheddate, poitem_qty_ordered AS orderitem_qty_ordered, poitem_qty_returned AS orderitem_qty_shipped, poitem_qty_received AS orderitem_qty_received, uom_id AS orderitem_qty_uom_id, poitem_invvenduomratio AS orderitem_qty_invuomratio, poitem_unitprice AS orderitem_unitcost, (SELECT pohead_curr_id FROM pohead WHERE pohead_id=poitem_pohead_id) AS orderitem_unitcost_curr_id, poitem_freight AS orderitem_freight, poitem_freight_received AS orderitem_freight_received, (SELECT pohead_curr_id FROM pohead WHERE pohead_id=poitem_pohead_id) AS orderitem_freight_curr_id FROM poitem LEFT OUTER JOIN uom ON (uom_name=poitem_vend_uom) WHERE(((pOrderheadid IS NULL) OR (poitem_pohead_id=pOrderheadid)) AND ((pOrderitemid IS NULL) OR (poitem_id=pOrderitemid))) LOOP _row.orderitem_id := _set.orderitem_id; _row.orderitem_orderhead_type := _set.orderitem_orderhead_type; _row.orderitem_orderhead_id := _set.orderitem_orderhead_id; _row.orderitem_linenumber := _set.orderitem_linenumber; _row.orderitem_status := _set.orderitem_status; _row.orderitem_itemsite_id := _set.orderitem_itemsite_id; _row.orderitem_scheddate := _set.orderitem_scheddate; _row.orderitem_qty_ordered := _set.orderitem_qty_ordered; _row.orderitem_qty_shipped := _set.orderitem_qty_shipped; _row.orderitem_qty_received := _set.orderitem_qty_received; _row.orderitem_qty_uom_id := _set.orderitem_qty_uom_id; _row.orderitem_qty_invuomratio := _set.orderitem_qty_invuomratio; _row.orderitem_unitcost := _set.orderitem_unitcost; _row.orderitem_unitcost_curr_id := _set.orderitem_unitcost_curr_id; _row.orderitem_freight := _set.orderitem_freight; _row.orderitem_freight_received := _set.orderitem_freight_received; _row.orderitem_freight_curr_id := _set.orderitem_freight_curr_id; RETURN NEXT _row; END LOOP; ELSEIF(UPPER(pOrdertype)='SO') THEN FOR _set IN SELECT coitem_id AS orderitem_id, 'SO' AS orderitem_orderhead_type, coitem_cohead_id AS orderitem_orderhead_id, coitem_linenumber AS orderitem_linenumber, coitem_status AS orderitem_status, coitem_itemsite_id AS orderitem_itemsite_id, coitem_scheddate AS orderitem_scheddate, coitem_qtyord AS orderitem_qty_ordered, coitem_qtyshipped AS orderitem_qty_shipped, coitem_qtyreturned AS orderitem_qty_received, coitem_qty_uom_id AS orderitem_qty_uom_id, coitem_qty_invuomratio AS orderitem_qty_invuomratio, coitem_unitcost AS orderitem_unitcost, basecurrid() AS orderitem_unitcost_curr_id, NULL AS orderitem_freight, NULL AS orderitem_freight_received, basecurrid() AS orderitem_freight_curr_id FROM coitem WHERE(((pOrderheadid IS NULL) OR (coitem_cohead_id=pOrderheadid)) AND ((pOrderitemid IS NULL) OR (coitem_id=pOrderitemid))) LOOP _row.orderitem_id := _set.orderitem_id; _row.orderitem_orderhead_type := _set.orderitem_orderhead_type; _row.orderitem_orderhead_id := _set.orderitem_orderhead_id; _row.orderitem_linenumber := _set.orderitem_linenumber; _row.orderitem_status := _set.orderitem_status; _row.orderitem_itemsite_id := _set.orderitem_itemsite_id; _row.orderitem_scheddate := _set.orderitem_scheddate; _row.orderitem_qty_ordered := _set.orderitem_qty_ordered; _row.orderitem_qty_shipped := _set.orderitem_qty_shipped; _row.orderitem_qty_received := _set.orderitem_qty_received; _row.orderitem_qty_uom_id := _set.orderitem_qty_uom_id; _row.orderitem_qty_invuomratio := _set.orderitem_qty_invuomratio; _row.orderitem_unitcost := _set.orderitem_unitcost; _row.orderitem_unitcost_curr_id := _set.orderitem_unitcost_curr_id; _row.orderitem_freight := _set.orderitem_freight; _row.orderitem_freight_received := _set.orderitem_freight_received; _row.orderitem_freight_curr_id := _set.orderitem_freight_curr_id; RETURN NEXT _row; END LOOP; ELSEIF(UPPER(pOrdertype)='RA') THEN FOR _set IN SELECT raitem_id AS orderitem_id, 'RA' AS orderitem_orderhead_type, raitem_rahead_id AS orderitem_orderhead_id, raitem_linenumber AS orderitem_linenumber, raitem_status AS orderitem_status, raitem_itemsite_id AS orderitem_itemsite_id, raitem_scheddate AS orderitem_scheddate, raitem_qtyauthorized AS orderitem_qty_ordered, 0 AS orderitem_qty_shipped, raitem_qtyreceived AS orderitem_qty_received, raitem_qty_uom_id AS orderitem_qty_uom_id, raitem_qty_invuomratio AS orderitem_qty_invuomratio, raitem_unitprice AS orderitem_unitcost, basecurrid() AS orderitem_unitcost_curr_id, NULL AS orderitem_freight, NULL AS orderitem_freight_received, basecurrid() AS orderitem_freight_curr_id FROM raitem WHERE(((pOrderheadid IS NULL) OR (raitem_rahead_id=pOrderheadid)) AND ((pOrderitemid IS NULL) OR (raitem_id=pOrderitemid))) LOOP _row.orderitem_id := _set.orderitem_id; _row.orderitem_orderhead_type := _set.orderitem_orderhead_type; _row.orderitem_orderhead_id := _set.orderitem_orderhead_id; _row.orderitem_linenumber := _set.orderitem_linenumber; _row.orderitem_status := _set.orderitem_status; _row.orderitem_itemsite_id := _set.orderitem_itemsite_id; _row.orderitem_scheddate := _set.orderitem_scheddate; _row.orderitem_qty_ordered := _set.orderitem_qty_ordered; _row.orderitem_qty_shipped := _set.orderitem_qty_shipped; _row.orderitem_qty_received := _set.orderitem_qty_received; _row.orderitem_qty_uom_id := _set.orderitem_qty_uom_id; _row.orderitem_qty_invuomratio := _set.orderitem_qty_invuomratio; _row.orderitem_unitcost := _set.orderitem_unitcost; _row.orderitem_unitcost_curr_id := _set.orderitem_unitcost_curr_id; _row.orderitem_freight := _set.orderitem_freight; _row.orderitem_freight_received := _set.orderitem_freight_received; _row.orderitem_freight_curr_id := _set.orderitem_freight_curr_id; RETURN NEXT _row; END LOOP; ELSEIF(UPPER(pOrdertype)='TO') THEN FOR _set IN SELECT toitem_id AS orderitem_id, 'TO' AS orderitem_orderhead_type, toitem_tohead_id AS orderitem_orderhead_id, toitem_linenumber AS orderitem_linenumber, toitem_status AS orderitem_status, itemsite_id AS orderitem_itemsite_id, toitem_duedate AS orderitem_scheddate, toitem_qty_ordered AS orderitem_qty_ordered, toitem_qty_shipped AS orderitem_qty_shipped, toitem_qty_received AS orderitem_qty_received, uom_id AS orderitem_qty_uom_id, 1 AS orderitem_qty_invuomratio, toitem_stdcost AS orderitem_unitcost, basecurrid() AS orderitem_unitcost_curr_id, toitem_freight AS orderitem_freight, toitem_freight_received AS orderitem_freight_received, toitem_freight_curr_id AS orderitem_freight_curr_id FROM tohead, itemsite, toitem LEFT OUTER JOIN uom ON (uom_name=toitem_uom) WHERE((toitem_tohead_id=tohead_id) AND (tohead_src_warehous_id=itemsite_warehous_id) AND (toitem_item_id=itemsite_item_id) AND ((pOrderheadid IS NULL) OR (toitem_tohead_id=pOrderheadid)) AND ((pOrderitemid IS NULL) OR (toitem_id=pOrderitemid))) LOOP _row.orderitem_id := _set.orderitem_id; _row.orderitem_orderhead_type := _set.orderitem_orderhead_type; _row.orderitem_orderhead_id := _set.orderitem_orderhead_id; _row.orderitem_linenumber := _set.orderitem_linenumber; _row.orderitem_status := _set.orderitem_status; _row.orderitem_itemsite_id := _set.orderitem_itemsite_id; _row.orderitem_scheddate := _set.orderitem_scheddate; _row.orderitem_qty_ordered := _set.orderitem_qty_ordered; _row.orderitem_qty_shipped := _set.orderitem_qty_shipped; _row.orderitem_qty_received := _set.orderitem_qty_received; _row.orderitem_qty_uom_id := _set.orderitem_qty_uom_id; _row.orderitem_qty_invuomratio := _set.orderitem_qty_invuomratio; _row.orderitem_unitcost := _set.orderitem_unitcost; _row.orderitem_unitcost_curr_id := _set.orderitem_unitcost_curr_id; _row.orderitem_freight := _set.orderitem_freight; _row.orderitem_freight_received := _set.orderitem_freight_received; _row.orderitem_freight_curr_id := _set.orderitem_freight_curr_id; RETURN NEXT _row; END LOOP; END IF; RETURN; END; $_$; <DROP FUNCTION public.orderitemdata(text, integer, integer); publicadminfalse4623272483125579076packageisenabled(integer)FUNCTIONCREATE FUNCTION packageisenabled(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT COUNT(*) >= 8 FROM pg_inherits, pg_class, pg_namespace, pkghead WHERE ((inhrelid=pg_class.oid) AND (relnamespace=pg_namespace.oid) AND (nspname=lower(pkghead_name)) AND (pkghead_id=$1)); $_$; 0DROP FUNCTION public.packageisenabled(integer); publicadminfalse84125579077packageisenabled(text)FUNCTIONCREATE FUNCTION packageisenabled(text) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT COUNT(*) >= 8 FROM pg_inherits, pg_class, pg_namespace WHERE ((inhrelid=pg_class.oid) AND (relnamespace=pg_namespace.oid) AND (nspname=lower($1))); $_$; -DROP FUNCTION public.packageisenabled(text); publicadminfalse8125579078pgp_key_id(bytea)FUNCTIONzCREATE FUNCTION pgp_key_id(bytea) RETURNS text LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_key_id_w'; (DROP FUNCTION public.pgp_key_id(bytea); publicadminfalse8125579079pgp_pub_decrypt(bytea, bytea)FUNCTIONCREATE FUNCTION pgp_pub_decrypt(bytea, bytea) RETURNS text LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_pub_decrypt_text'; 4DROP FUNCTION public.pgp_pub_decrypt(bytea, bytea); publicadminfalse8125579080#pgp_pub_decrypt(bytea, bytea, text)FUNCTIONCREATE FUNCTION pgp_pub_decrypt(bytea, bytea, text) RETURNS text LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_pub_decrypt_text'; :DROP FUNCTION public.pgp_pub_decrypt(bytea, bytea, text); publicadminfalse8125579081)pgp_pub_decrypt(bytea, bytea, text, text)FUNCTIONCREATE FUNCTION pgp_pub_decrypt(bytea, bytea, text, text) RETURNS text LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_pub_decrypt_text'; @DROP FUNCTION public.pgp_pub_decrypt(bytea, bytea, text, text); publicadminfalse8125579082#pgp_pub_decrypt_bytea(bytea, bytea)FUNCTIONCREATE FUNCTION pgp_pub_decrypt_bytea(bytea, bytea) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_pub_decrypt_bytea'; :DROP FUNCTION public.pgp_pub_decrypt_bytea(bytea, bytea); publicadminfalse8125579083)pgp_pub_decrypt_bytea(bytea, bytea, text)FUNCTIONCREATE FUNCTION pgp_pub_decrypt_bytea(bytea, bytea, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_pub_decrypt_bytea'; @DROP FUNCTION public.pgp_pub_decrypt_bytea(bytea, bytea, text); publicadminfalse8125579084/pgp_pub_decrypt_bytea(bytea, bytea, text, text)FUNCTIONCREATE FUNCTION pgp_pub_decrypt_bytea(bytea, bytea, text, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_pub_decrypt_bytea'; FDROP FUNCTION public.pgp_pub_decrypt_bytea(bytea, bytea, text, text); publicadminfalse8125579085pgp_pub_encrypt(text, bytea)FUNCTIONCREATE FUNCTION pgp_pub_encrypt(text, bytea) RETURNS bytea LANGUAGE c STRICT AS '$libdir/pgcrypto', 'pgp_pub_encrypt_text'; 3DROP FUNCTION public.pgp_pub_encrypt(text, bytea); publicadminfalse8125579086"pgp_pub_encrypt(text, bytea, text)FUNCTIONCREATE FUNCTION pgp_pub_encrypt(text, bytea, text) RETURNS bytea LANGUAGE c STRICT AS '$libdir/pgcrypto', 'pgp_pub_encrypt_text'; 9DROP FUNCTION public.pgp_pub_encrypt(text, bytea, text); publicadminfalse8125579087#pgp_pub_encrypt_bytea(bytea, bytea)FUNCTIONCREATE FUNCTION pgp_pub_encrypt_bytea(bytea, bytea) RETURNS bytea LANGUAGE c STRICT AS '$libdir/pgcrypto', 'pgp_pub_encrypt_bytea'; :DROP FUNCTION public.pgp_pub_encrypt_bytea(bytea, bytea); publicadminfalse8125579088)pgp_pub_encrypt_bytea(bytea, bytea, text)FUNCTIONCREATE FUNCTION pgp_pub_encrypt_bytea(bytea, bytea, text) RETURNS bytea LANGUAGE c STRICT AS '$libdir/pgcrypto', 'pgp_pub_encrypt_bytea'; @DROP FUNCTION public.pgp_pub_encrypt_bytea(bytea, bytea, text); publicadminfalse8125579089pgp_sym_decrypt(bytea, text)FUNCTIONCREATE FUNCTION pgp_sym_decrypt(bytea, text) RETURNS text LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_sym_decrypt_text'; 3DROP FUNCTION public.pgp_sym_decrypt(bytea, text); publicadminfalse8125579090"pgp_sym_decrypt(bytea, text, text)FUNCTIONCREATE FUNCTION pgp_sym_decrypt(bytea, text, text) RETURNS text LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_sym_decrypt_text'; 9DROP FUNCTION public.pgp_sym_decrypt(bytea, text, text); publicadminfalse8125579091"pgp_sym_decrypt_bytea(bytea, text)FUNCTIONCREATE FUNCTION pgp_sym_decrypt_bytea(bytea, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_sym_decrypt_bytea'; 9DROP FUNCTION public.pgp_sym_decrypt_bytea(bytea, text); publicadminfalse8125579092(pgp_sym_decrypt_bytea(bytea, text, text)FUNCTIONCREATE FUNCTION pgp_sym_decrypt_bytea(bytea, text, text) RETURNS bytea LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgcrypto', 'pgp_sym_decrypt_bytea'; ?DROP FUNCTION public.pgp_sym_decrypt_bytea(bytea, text, text); publicadminfalse8125579093pgp_sym_encrypt(text, text)FUNCTIONCREATE FUNCTION pgp_sym_encrypt(text, text) RETURNS bytea LANGUAGE c STRICT AS '$libdir/pgcrypto', 'pgp_sym_encrypt_text'; 2DROP FUNCTION public.pgp_sym_encrypt(text, text); publicadminfalse8125579094!pgp_sym_encrypt(text, text, text)FUNCTIONCREATE FUNCTION pgp_sym_encrypt(text, text, text) RETURNS bytea LANGUAGE c STRICT AS '$libdir/pgcrypto', 'pgp_sym_encrypt_text'; 8DROP FUNCTION public.pgp_sym_encrypt(text, text, text); publicadminfalse8125579095"pgp_sym_encrypt_bytea(bytea, text)FUNCTIONCREATE FUNCTION pgp_sym_encrypt_bytea(bytea, text) RETURNS bytea LANGUAGE c STRICT AS '$libdir/pgcrypto', 'pgp_sym_encrypt_bytea'; 9DROP FUNCTION public.pgp_sym_encrypt_bytea(bytea, text); publicadminfalse8125579096(pgp_sym_encrypt_bytea(bytea, text, text)FUNCTIONCREATE FUNCTION pgp_sym_encrypt_bytea(bytea, text, text) RETURNS bytea LANGUAGE c STRICT AS '$libdir/pgcrypto', 'pgp_sym_encrypt_bytea'; ?DROP FUNCTION public.pgp_sym_encrypt_bytea(bytea, text, text); publicadminfalse85125579097pkgmaybemodified(name)FUNCTIONCREATE FUNCTION pkgmaybemodified(name) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pschemaname ALIAS FOR $1; _returnval BOOLEAN; BEGIN SELECT pkghead_indev INTO _returnval FROM pkghead WHERE (pkghead_name=pschemaname); IF (NOT FOUND) THEN RETURN FALSE; END IF; RETURN _returnval; END; $_$; -DROP FUNCTION public.pkgmaybemodified(name); publicadminfalse46238125579098plpgsql_call_handler()FUNCTIONCREATE FUNCTION plpgsql_call_handler() RETURNS language_handler LANGUAGE c AS '$libdir/plpgsql', 'plpgsql_call_handler'; -DROP FUNCTION public.plpgsql_call_handler(); publicadminfalse8125579099plpgsql_validator(oid)FUNCTIONrCREATE FUNCTION plpgsql_validator(oid) RETURNS void LANGUAGE c AS '$libdir/plpgsql', 'plpgsql_validator'; -DROP FUNCTION public.plpgsql_validator(oid); publicadminfalse86125579100postapcheck(integer)FUNCTIONbCREATE FUNCTION postapcheck(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'postAPCheck() is deprecated - use postCheck() instead'; RETURN postCheck($1, fetchJournalNumber('AP-CK')); END; $_$; +DROP FUNCTION public.postapcheck(integer); publicadminfalse846237125579101postapcheck(integer, integer)FUNCTIONRCREATE FUNCTION postapcheck(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'postAPCheck() is deprecated - use postCheck() instead'; RETURN postCheck($1, $2); END; $_$; 4DROP FUNCTION public.postapcheck(integer, integer); publicadminfalse846238125579102postapchecks(integer)FUNCTIONKCREATE FUNCTION postapchecks(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'postAPChecks() is deprecated - use postChecks() instead'; RETURN postChecks($1); END; $_$; ,DROP FUNCTION public.postapchecks(integer); publicadminfalse462389125579103$postapcreditmemoapplication(integer)FUNCTIONCREATE FUNCTION postapcreditmemoapplication(papopenid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _src RECORD; _r RECORD; _totalAmount NUMERIC := 0.0; _exchGain NUMERIC := 0.0; _apaccntid INTEGER; BEGIN -- pApopenid is the apopen_id of the C/M being applied SELECT apopen_docnumber, (apopen_amount - apopen_paid) AS balance, SUM(apcreditapply_amount) AS toApply INTO _src FROM apopen JOIN apcreditapply ON (apcreditapply_source_apopen_id=apopen_id) WHERE (apopen_id=pApopenid) GROUP BY apopen_docnumber, apopen_amount, apopen_paid; IF (NOT FOUND) THEN RAISE EXCEPTION 'A/P Credit Memo applications not found [xtuple: postAPCreditMemoApplication, -1]'; ELSIF (_src.toApply = 0) THEN RAISE EXCEPTION 'A/P Credit Memo application amount is zero. [xtuple: postAPCreditMemoApplication, -2]'; ELSIF (_src.toApply > _src.balance) THEN RAISE EXCEPTION 'A/P Credit Memo application amount greater than balance. [xtuple: postAPCreditMemoApplication, -3]'; ELSIF (_src.toApply IS NULL) THEN RAISE EXCEPTION 'A/P Credit Memo application amount is null. [xtuple: postAPCreditMemoApplication, -4]'; END IF; -- cache the C/M SELECT * INTO _src FROM apopen WHERE (apopen_id=pApopenid); IF (NOT FOUND) THEN RAISE EXCEPTION 'The A/P Credit Memo to apply was not found. [xtuple: postAPCreditMemoApplication, -5]'; END IF; -- loop thru the pending applications FOR _r IN SELECT apcreditapply_id, apcreditapply_target_apopen_id, apcreditapply_amount AS apply_amountSource, currToCurr(apcreditapply_curr_id, apopen_curr_id, apcreditapply_amount, CURRENT_DATE) AS apply_amountTarget, apopen_id, apopen_doctype, apopen_docnumber, apopen_curr_id, apopen_curr_rate, apopen_docdate, (apopen_amount - apopen_paid) AS targetBalance FROM apcreditapply JOIN apopen ON (apcreditapply_target_apopen_id=apopen_id) WHERE (apcreditapply_source_apopen_id=pApopenid) LOOP IF (_r.apply_amountTarget IS NULL) THEN RAISE EXCEPTION 'A/P Credit Memo application amount is null. [xtuple: postAPCreditMemoApplication, -6]'; END IF; IF (_r.apply_amountTarget > _r.targetBalance) THEN RAISE EXCEPTION 'A/P Credit Memo application amount greater than target balance. [xtuple: postAPCreditMemoApplication, -7]'; END IF; IF (_r.apply_amountTarget > 0) THEN -- Update the apopen item to post the paid amount UPDATE apopen SET apopen_paid = (apopen_paid + _r.apply_amountTarget) WHERE (apopen_id=_r.apcreditapply_target_apopen_id); UPDATE apopen SET apopen_open = false, apopen_closedate = CURRENT_DATE WHERE ( (apopen_id=_r.apcreditapply_target_apopen_id) AND (apopen_amount <= apopen_paid) ); -- Cache the running amount posted _totalAmount := (_totalAmount + _r.apply_amountSource); -- Record the application INSERT INTO apapply ( apapply_vend_id, apapply_amount, apapply_source_apopen_id, apapply_source_doctype, apapply_source_docnumber, apapply_target_apopen_id, apapply_target_doctype, apapply_target_docnumber, apapply_postdate, apapply_journalnumber, apapply_username, apapply_curr_id ) VALUES ( _src.apopen_vend_id, round(_r.apply_amountSource, 2), pApopenid, 'C', _src.apopen_docnumber, _r.apopen_id, _r.apopen_doctype, _r.apopen_docnumber, CURRENT_DATE, 0, getEffectiveXtUser(), _src.apopen_curr_id ); END IF; -- Delete the posted apcreditapply record DELETE FROM apcreditapply WHERE (apcreditapply_id=_r.apcreditapply_id); END LOOP; -- Record the amount posted and mark the source apopen as closed if it is completely posted UPDATE apopen SET apopen_paid = (apopen_paid + _totalAmount) WHERE (apopen_id=pApopenid); UPDATE apopen SET apopen_open = false, apopen_closedate = CURRENT_DATE WHERE ( (apopen_id=pApopenid) AND (apopen_amount <= apopen_paid) ); IF (_r.apopen_curr_id = _src.apopen_curr_id) THEN IF (_r.apopen_docdate > _src.apopen_docdate) THEN _exchGain := (_totalAmount / _r.apopen_curr_rate - _totalAmount / _src.apopen_curr_rate) * -1; ELSE _exchGain := _totalAmount / _src.apopen_curr_rate - _totalAmount / _r.apopen_curr_rate; END IF; END IF; -- do not post gain/loss to alternate prepaid -- IF (_src.apopen_accnt_id > -1) THEN -- _apaccntid := _src.apopen_accnt_id; -- ELSE _apaccntid := findAPAccount(_src.apopen_vend_id); -- END IF; PERFORM insertGLTransaction(fetchJournalNumber('AP-MISC'), 'A/P', 'CM', _src.apopen_docnumber, 'CM Application', _apaccntid, getGainLossAccntId(_apaccntid), -1, _exchGain, CURRENT_DATE); RETURN pApopenid; END; $$; EDROP FUNCTION public.postapcreditmemoapplication(papopenid integer); publicadminfalse46238:125579104postapopenitems()FUNCTION8CREATE FUNCTION postapopenitems() RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN UPDATE apopen SET apopen_posted=TRUE WHERE (NOT apopen_posted); RETURN TRUE; END; $$; (DROP FUNCTION public.postapopenitems(); publicadminfalse84623;125579105$postarcreditmemoapplication(integer)FUNCTION<CREATE FUNCTION postarcreditmemoapplication(paropenid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN postARCreditMemoApplication(pAropenid, CURRENT_DATE); END; $$; EDROP FUNCTION public.postarcreditmemoapplication(paropenid integer); publicadminfalse84623<125579106*postarcreditmemoapplication(integer, date)FUNCTIONCREATE FUNCTION postarcreditmemoapplication(paropenid integer, papplydate date) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _applyDate DATE; _p RECORD; _r RECORD; _totalSource NUMERIC := 0; _totalTarget NUMERIC := 0; _exchGain NUMERIC := 0; _result NUMERIC; _araccntid INTEGER; BEGIN _applyDate := COALESCE(pApplyDate, CURRENT_DATE); -- find source CM and calc total amount to apply in CM currency SELECT ROUND(aropen_amount - aropen_paid, 2) AS balance, ROUND(SUM(currToCurr(arcreditapply_curr_id, aropen_curr_id, COALESCE(arcreditapply_amount, 0), _applyDate)), 2) AS toApply INTO _p FROM aropen JOIN arcreditapply ON (arcreditapply_source_aropen_id=aropen_id) WHERE (aropen_id=pAropenid) GROUP BY aropen_amount, aropen_paid; IF (NOT FOUND) THEN RETURN -1; ELSIF (_p.toApply = 0) THEN RETURN -2; ELSIF (_p.toApply > _p.balance) THEN RETURN -3; END IF; -- cache source CM SELECT aropen_cust_id, aropen_docnumber, aropen_doctype, aropen_amount, aropen_curr_id, aropen_docdate, aropen_accnt_id, aropen_cust_id, aropen_curr_id, aropen_curr_rate INTO _p FROM aropen WHERE (aropen_id=pAropenid); IF (NOT FOUND) THEN RETURN -5; END IF; -- loop thru each arcreditapply FOR _r IN SELECT arcreditapply_id, arcreditapply_target_aropen_id, arcreditapply_reftype, arcreditapply_ref_id, arcreditapply_curr_id, currToCurr(arcreditapply_curr_id, _p.aropen_curr_id, arcreditapply_amount, _applyDate) AS arcreditapply_amountSource, currToCurr(arcreditapply_curr_id, aropen_curr_id, arcreditapply_amount, _applyDate) AS arcreditapply_amountTarget, aropen_doctype, aropen_docnumber, aropen_docdate, aropen_curr_rate FROM arcreditapply JOIN aropen ON (aropen_id=arcreditapply_target_aropen_id) WHERE (arcreditapply_source_aropen_id=pAropenid) LOOP IF (_r.arcreditapply_amountTarget IS NULL) THEN RETURN -4; END IF; IF (_r.arcreditapply_amountTarget <> 0) THEN -- Update the target invoice aropen item to post the paid amount UPDATE aropen SET aropen_paid = round(aropen_paid + _r.arcreditapply_amountTarget, 2) WHERE (aropen_id=_r.arcreditapply_target_aropen_id); UPDATE aropen SET aropen_open = (round(aropen_amount, 2) > round(aropen_paid, 2)) WHERE (aropen_id=_r.arcreditapply_target_aropen_id); -- Cache the running amount posted _totalSource := (_totalSource + _r.arcreditapply_amountSource); _totalTarget := (_totalTarget + _r.arcreditapply_amountTarget); -- Record the application INSERT INTO arapply ( arapply_cust_id, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_applied, arapply_closed, arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_username, arapply_curr_id, arapply_reftype, arapply_ref_id ) VALUES ( _p.aropen_cust_id, pAropenid, _p.aropen_doctype, _p.aropen_docnumber, _r.arcreditapply_target_aropen_id, _r.aropen_doctype, _r.aropen_docnumber, '', '', round(_r.arcreditapply_amountSource, 2), TRUE, _applyDate, _applyDate, 0, getEffectiveXtUser(), _p.aropen_curr_id, _r.arcreditapply_reftype, _r.arcreditapply_ref_id ); END IF; -- Delete the posted arcreditapply record DELETE FROM arcreditapply WHERE (arcreditapply_id=_r.arcreditapply_id); IF (_r.aropen_docdate > _p.aropen_docdate) THEN _exchGain := (_totalTarget / _r.aropen_curr_rate - _totalSource / _p.aropen_curr_rate) * -1; ELSE _exchGain := _totalSource / _p.aropen_curr_rate - _totalTarget / _r.aropen_curr_rate; END IF; IF (_p.aropen_accnt_id > -1) THEN _araccntid := _p.aropen_accnt_id; ELSE _araccntid := findARAccount(_p.aropen_cust_id); END IF; IF (_exchGain <> 0) THEN PERFORM insertGLTransaction(fetchJournalNumber('AR-MISC'), 'A/R', 'CR', _p.aropen_docnumber, 'CM Application', _araccntid, getGainLossAccntId(_araccntid), -1, _exchGain * -1, _applyDate); END IF; END LOOP; -- TODO: If this is a Customer Deposit (aropen_doctype='R') -- the we need to convert the total to a base transaction IF(_p.aropen_doctype='R') THEN SELECT insertGLTransaction(fetchJournalNumber('AR-MISC'), 'A/R', 'CD', _p.aropen_docnumber, 'CM Application', cr.accnt_id, db.accnt_id, -1, (_totalSource / _p.aropen_curr_rate), _applyDate) INTO _result FROM accnt AS cr, accnt AS db WHERE ((db.accnt_id = findDeferredAccount(_p.aropen_cust_id)) AND (cr.accnt_id = findARAccount(_p.aropen_cust_id)) ); IF(NOT FOUND OR _result < 0) THEN RAISE EXCEPTION 'There was an error posting the Customer Deposit GL Transactions.'; END IF; END IF; -- Record the amount posted and mark the source CM aropen as closed if it is completely posted UPDATE aropen SET aropen_paid = round(aropen_paid + _totalSource, 2) WHERE (aropen_id=pAropenid); UPDATE aropen SET aropen_open = (round(aropen_amount, 2) > round(aropen_paid, 2)) WHERE (aropen_id=pAropenid); RETURN pAropenid; END; $$; VDROP FUNCTION public.postarcreditmemoapplication(paropenid integer, papplydate date); publicadminfalse84623=125579108postaropenitems()FUNCTION8CREATE FUNCTION postaropenitems() RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN UPDATE aropen SET aropen_posted=TRUE WHERE (NOT aropen_posted); RETURN TRUE; END; $$; (DROP FUNCTION public.postaropenitems(); publicadminfalse46238>125579109postbankadjustment(integer)FUNCTIONCREATE FUNCTION postbankadjustment(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBankadjid ALIAS FOR $1; _sequence INTEGER; _r RECORD; BEGIN -- Post the G/L transaction SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'), 'G/L', 'AD', bankadj_docnumber, (bankadjtype_name || '-' || bankadj_notes), bankadjtype_accnt_id, bankaccnt_accnt_id, bankadj_id, round(currToBase(bankaccnt_curr_id, CASE WHEN(bankadjtype_iscredit) THEN (bankadj_amount * -1) ELSE bankadj_amount END, bankadj_date), 2), bankadj_date, TRUE, TRUE ) INTO _sequence FROM bankadj, bankaccnt, bankadjtype WHERE ( (bankadj_bankaccnt_id=bankaccnt_id) AND (bankadj_bankadjtype_id=bankadjtype_id) AND (NOT bankadj_posted) AND (bankadj_id=pBankadjid) ); IF ( NOT FOUND ) THEN RETURN -1; END IF; IF (_sequence >= 0) THEN -- Update the bankadj record with this sequence and mark it posted UPDATE bankadj SET bankadj_sequence = _sequence, bankadj_posted = TRUE WHERE bankadj_id=pBankadjid; END IF; RETURN _sequence; END; $_$; 2DROP FUNCTION public.postbankadjustment(integer); publicadminfalse46238?125579110postbankreconciliation(integer)FUNCTION*CREATE FUNCTION postbankreconciliation(pbankrecid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN bankReconciliation(pBankrecid, 'post'); END; $$; ADROP FUNCTION public.postbankreconciliation(pbankrecid integer); publicadminfalse46238@125579111postbillingselection(integer)FUNCTIONCREATE FUNCTION postbillingselection(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCobmiscid ALIAS FOR $1; BEGIN RAISE WARNING 'postBillingselection(integer) has been deprecated. Please use createInvoice(integer).'; RETURN createInvoice(pCobmiscid); END; $_$; 4DROP FUNCTION public.postbillingselection(integer); publicadminfalse46238A125579112)postbillingselectionconsolidated(integer)FUNCTIONCREATE FUNCTION postbillingselectionconsolidated(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustid ALIAS FOR $1; BEGIN RAISE WARNING 'postBillingselectionConsolidated(integer) has been deprecated. Please use createInvoiceConsolidated(integer).'; RETURN createInvoiceConsolidated(pCustid); END; $_$; @DROP FUNCTION public.postbillingselectionconsolidated(integer); publicadminfalse46238B125579113postbillingselections()FUNCTION`CREATE FUNCTION postbillingselections() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'postBillingselections() has been deprecated. Please use createInvoices().'; RETURN createInvoices(); END; $$; .DROP FUNCTION public.postbillingselections(); publicadminfalse46238C125579114postbillingselections(integer)FUNCTIONvCREATE FUNCTION postbillingselections(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'postBillingselections(int) has been deprecated. Please use createInvoices(int).'; RETURN createInvoices($1, false); END; $_$; 5DROP FUNCTION public.postbillingselections(integer); publicadminfalse46238D125579115'postbillingselections(integer, boolean)FUNCTIONCREATE FUNCTION postbillingselections(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCustTypeId ALIAS FOR $1; pConsolidate ALIAS FOR $2; BEGIN RAISE WARNING 'postBillingselections(int,bool) has been deprecated. Please use createInvoices(int,bool).'; RETURN createInvoices(pCustTypeId, pConsolidate); END; $_$; >DROP FUNCTION public.postbillingselections(integer, boolean); publicadminfalse84623E125579116!postcashreceipt(integer, integer)FUNCTIONCCREATE FUNCTION postcashreceipt(pcashrcptid integer, pjournalnumber integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _ccpayid INTEGER; _cctype TEXT; _p RECORD; _r RECORD; _t RECORD; _v RECORD; _postToAR NUMERIC; _postToMisc NUMERIC; _postToCM NUMERIC; _posted_base NUMERIC := 0; _posted NUMERIC := 0; _sequence INTEGER; _aropenid INTEGER; _arMemoNumber TEXT; _arAccntid INTEGER; _closed BOOLEAN; _debitAccntid INTEGER; _exchGain NUMERIC; _comment TEXT; _predist BOOLEAN; _check INTEGER; BEGIN _posted := 0; _posted_base := 0; SELECT fetchGLSequence() INTO _sequence; SELECT accnt_id INTO _arAccntid FROM cashrcpt, accnt, salescat WHERE ((cashrcpt_salescat_id=salescat_id) AND (salescat_ar_accnt_id=accnt_id) AND (cashrcpt_id=pCashrcptid)); IF (NOT FOUND) THEN SELECT accnt_id INTO _arAccntid FROM cashrcpt LEFT OUTER JOIN accnt ON (accnt_id=findARAccount(cashrcpt_cust_id)) WHERE ( (findARAccount(cashrcpt_cust_id)=0 OR accnt_id > 0) -- G/L interface might be disabled AND (cashrcpt_id=pCashrcptid) ); IF (NOT FOUND) THEN RETURN -5; END IF; END IF; SELECT cashrcpt.*, (cust_number||'-'||cust_name) AS custnote, (cashrcpt_amount / cashrcpt_curr_rate) AS cashrcpt_amount_base, (cashrcpt_discount / cashrcpt_curr_rate) AS cashrcpt_discount_base, cashrcpt_bankaccnt_id AS bankaccnt_id, accnt_id AS prepaid_accnt_id, COALESCE(cashrcpt_applydate, cashrcpt_distdate) AS applydate INTO _p FROM cashrcpt LEFT OUTER JOIN custinfo ON (cashrcpt_cust_id=cust_id) LEFT OUTER JOIN accnt ON (accnt_id=findPrepaidAccount(cashrcpt_cust_id)) WHERE ( (findPrepaidAccount(cashrcpt_cust_id)=0 OR accnt_id > 0) -- G/L interface might be disabled AND (cashrcpt_id=pCashrcptid) ); IF (NOT FOUND) THEN RETURN -7; END IF; IF (COALESCE(_p.cashrcpt_distdate > _p.applydate, false)) THEN RAISE EXCEPTION 'Cannot post cashrcpt % because application date is before distribution date.', _p.cashrcpt_docnumber; END IF; IF (COALESCE(_p.cashrcpt_posted, false)) THEN RAISE EXCEPTION 'Cannot post cashrcpt % because the document has already been posted.', _p.cashrcpt_docnumber; END IF; IF (COALESCE(_p.cashrcpt_void, false)) THEN RAISE EXCEPTION 'Cannot post cashrcpt % because the document has been voided.', _p.cashrcpt_docnumber; END IF; _predist := COALESCE(_p.cashrcpt_distdate < _p.applydate, false); IF (_p.cashrcpt_fundstype IN ('A', 'D', 'M', 'V')) THEN SELECT ccpay_id, ccpay_type INTO _ccpayid, _cctype FROM ccpay WHERE ((ccpay_r_ordernum IN (CAST(pCashrcptid AS TEXT), _p.cashrcpt_docnumber)) AND (ccpay_status IN ('C', 'A'))); IF NOT FOUND THEN -- the following select seems to work except for xikar - bug 8848. why? -- raise warning so there is some visibility if people fall into this path. SELECT ccpay_id, ccpay_type INTO _ccpayid, _cctype FROM ccpay WHERE ((ccpay_order_number IN (CAST(pCashrcptid AS TEXT), _p.cashrcpt_docnumber)) AND (ccpay_status IN ('C', 'A'))); IF (NOT FOUND) THEN RETURN -8; ELSE RAISE WARNING 'PostCashReceipt() found ccpay_id % for order number %/% (ref 8848).', _ccpayid, pCashrcptid, _p.cashrcpt_docnumber; END IF; END IF; -- If there is a ccpay entry and the card was charged directly, use the prepaid account IF (_cctype = 'C' ) THEN _debitAccntid := findPrepaidAccount(_p.cashrcpt_cust_id); -- If there is a ccpay entry and the card was preauthed and then charged, use the Bank account ELSE SELECT accnt_id INTO _debitAccntid FROM cashrcpt, bankaccnt, accnt WHERE ( (cashrcpt_bankaccnt_id=bankaccnt_id) AND (bankaccnt_accnt_id=accnt_id) AND (cashrcpt_id=pCashrcptid) ); IF (NOT FOUND) THEN RETURN -6; END IF; END IF; ELSE SELECT accnt_id INTO _debitAccntid FROM cashrcpt, bankaccnt, accnt WHERE ( (cashrcpt_bankaccnt_id=bankaccnt_id) AND (bankaccnt_accnt_id=accnt_id) AND (cashrcpt_id=pCashrcptid) ); IF (NOT FOUND) THEN RETURN -6; END IF; END IF; -- Determine the amount to post to A/R Open Items SELECT COALESCE(SUM(cashrcptitem_amount), 0) INTO _postToAR FROM cashrcptitem JOIN aropen ON (aropen_id=cashrcptitem_aropen_id) WHERE (cashrcptitem_cashrcpt_id=pCashrcptid); IF (NOT FOUND) THEN _postToAR := 0; END IF; -- Determine the amount to post to Misc. Distributions SELECT COALESCE(SUM(cashrcptmisc_amount), 0) INTO _postToMisc FROM cashrcptmisc WHERE (cashrcptmisc_cashrcpt_id=pCashrcptid); IF (NOT FOUND) THEN _postToMisc := 0; END IF; -- Determine the amount to post to Discount Credit Memo SELECT COALESCE(SUM(cashrcptitem_discount), 0) INTO _postToCM FROM cashrcptitem JOIN aropen ON ( (aropen_id=cashrcptitem_aropen_id) AND (aropen_doctype IN ('I', 'D')) ) WHERE (cashrcptitem_cashrcpt_id=pCashrcptid); IF (NOT FOUND) THEN _postToCM := 0; END IF; -- Check to see if the C/R is over applied IF ((_postToAR + _postToMisc) > _p.cashrcpt_amount) THEN RETURN -1; END IF; -- Check to see if the C/R is positive amount IF (_p.cashrcpt_amount <= 0) THEN RETURN -2; END IF; -- Distribute A/R Applications FOR _r IN SELECT aropen_id, aropen_doctype, aropen_docnumber, aropen_docdate, aropen_duedate, aropen_curr_id, aropen_curr_rate, aropen_amount, round(aropen_amount - aropen_paid, 2) <= round(currToCurr(_p.cashrcpt_curr_id, aropen_curr_id,abs(cashrcptitem_amount + cashrcptitem_discount),_p.cashrcpt_distdate),2) AS closed, cashrcptitem_id, cashrcptitem_amount, cashrcptitem_discount, (cashrcptitem_amount / _p.cashrcpt_curr_rate) AS cashrcptitem_amount_base, (cashrcptitem_discount / _p.cashrcpt_curr_rate) AS cashrcptitem_discount_base, round(aropen_paid + currToCurr(_p.cashrcpt_curr_id, aropen_curr_id,abs(cashrcptitem_amount),_p.cashrcpt_distdate),2) AS new_paid, round(currToCurr(_p.cashrcpt_curr_id, aropen_curr_id,cashrcptitem_discount,_p.cashrcpt_distdate),2) AS new_discount FROM cashrcptitem JOIN aropen ON (aropen_id=cashrcptitem_aropen_id) WHERE ((cashrcptitem_cashrcpt_id=pCashrcptid) AND (NOT _predist OR aropen_doctype IN ('C','R'))) LOOP -- Handle discount IF (_r.cashrcptitem_discount_base > 0) THEN PERFORM postCashReceiptDisc(_r.cashrcptitem_id, pJournalNumber); END IF; -- Update the aropen item to post the paid amount UPDATE aropen SET aropen_paid = _r.new_paid + _r.new_discount, aropen_open = (NOT _r.closed), aropen_closedate = CASE WHEN _r.closed THEN _p.cashrcpt_distdate END WHERE (aropen_id=_r.aropen_id); -- Cache the running amount posted _posted_base := _posted_base + _r.cashrcptitem_amount_base; _posted := _posted + _r.cashrcptitem_amount; -- Record the cashrcpt application IF (_r.aropen_doctype IN ('I','D')) THEN INSERT INTO arapply ( arapply_cust_id, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_reftype, arapply_ref_id, arapply_applied, arapply_closed, arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_username, arapply_curr_id ) VALUES ( _p.cashrcpt_cust_id, -1, 'K', _p.cashrcpt_number, _r.aropen_id, _r.aropen_doctype, _r.aropen_docnumber, _p.cashrcpt_fundstype, _p.cashrcpt_docnumber, 'CRA', _r.cashrcptitem_id, round(_r.cashrcptitem_amount, 2), _r.closed, _p.applydate, _p.cashrcpt_distdate, pJournalNumber, getEffectiveXtUser(), _p.cashrcpt_curr_id); ELSE INSERT INTO arapply ( arapply_cust_id, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_reftype, arapply_ref_id, arapply_applied, arapply_closed, arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_username, arapply_curr_id ) VALUES ( _p.cashrcpt_cust_id, _r.aropen_id, _r.aropen_doctype, _r.aropen_docnumber, -1, 'R', _p.cashrcpt_number, '', '', 'CRA', _r.cashrcptitem_id, round(abs(_r.cashrcptitem_amount), 2), _r.closed, _p.applydate, _p.cashrcpt_distdate, pJournalNumber, getEffectiveXtUser(), _p.cashrcpt_curr_id ); END IF; _exchGain := arCurrGain(_r.aropen_id,_p.cashrcpt_curr_id, abs(_r.cashrcptitem_amount), _p.cashrcpt_distdate); PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', (_r.aropen_doctype || '-' || _r.aropen_docnumber), CASE WHEN _r.aropen_doctype != 'R' THEN _arAccntid ELSE findDeferredAccount(_p.cashrcpt_cust_id) END, round(_r.cashrcptitem_amount_base + _exchGain, 2), _p.cashrcpt_distdate, _p.custnote, pCashrcptid ); IF (_exchGain <> 0) THEN PERFORM insertIntoGLSeries(_sequence, 'A/R', 'CR', _r.aropen_doctype || '-' || _r.aropen_docnumber, getGainLossAccntId( CASE WHEN _r.aropen_doctype != 'R' THEN _arAccntid ELSE findDeferredAccount(_p.cashrcpt_cust_id) END ), round(_exchGain, 2) * -1, _p.cashrcpt_distdate, _p.custnote, pCashrcptid); END IF; END LOOP; -- Distribute Misc. Applications FOR _r IN SELECT cashrcptmisc_id, cashrcptmisc_accnt_id, cashrcptmisc_amount, (cashrcptmisc_amount / cashrcpt_curr_rate) AS cashrcptmisc_amount_base, cashrcptmisc_notes, cashrcpt_curr_id FROM cashrcptmisc JOIN cashrcpt ON (cashrcptmisc_cashrcpt_id = cashrcpt_id) WHERE (cashrcptmisc_cashrcpt_id=pCashrcptid) LOOP -- Cache the running amount posted _posted_base := (_posted_base + _r.cashrcptmisc_amount_base); _posted := (_posted + _r.cashrcptmisc_amount); -- Record the cashrcpt application INSERT INTO arapply ( arapply_cust_id, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_applied, arapply_closed, arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_username, arapply_curr_id, arapply_reftype, arapply_ref_id ) VALUES ( _p.cashrcpt_cust_id, -1, 'K', '', -1, 'Misc.', '', _p.cashrcpt_fundstype, _p.cashrcpt_docnumber, round(_r.cashrcptmisc_amount, 2), TRUE, _p.applydate, _p.cashrcpt_distdate, pJournalNumber, getEffectiveXtUser(), _r.cashrcpt_curr_id, 'CRD', _r.cashrcptmisc_id ); PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', _r.cashrcptmisc_notes, _r.cashrcptmisc_accnt_id, round(_r.cashrcptmisc_amount_base, 2), _p.cashrcpt_distdate, _p.custnote, pCashrcptid ); END LOOP; -- Post any remaining Cash to an A/R Cash Despoit (Credit Memo) -- this credit memo may absorb an occasional currency exchange rounding error IF (round(_posted_base, 2) < round(_p.cashrcpt_amount_base, 2)) THEN _comment := ('Unapplied from ' || _p.cashrcpt_fundstype || '-' || _p.cashrcpt_docnumber); PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', _comment, _p.prepaid_accnt_id, round(_p.cashrcpt_amount_base, 2) - round(_posted_base, 2), _p.cashrcpt_distdate, _p.custnote, pCashrcptid ); SELECT fetchArMemoNumber() INTO _arMemoNumber; IF(_p.cashrcpt_usecustdeposit) THEN -- Post Customer Deposit SELECT createARCashDeposit(_p.cashrcpt_cust_id, _arMemoNumber, '', _p.cashrcpt_distdate, (_p.cashrcpt_amount - _posted), _comment, pJournalNumber, _p.cashrcpt_curr_id) INTO _aropenid; ELSE -- Post A/R Credit Memo _aropenid := createARCreditMemo(NULL, _p.cashrcpt_cust_id, _arMemoNumber, '', _p.cashrcpt_distdate, (_p.cashrcpt_amount - _posted), _comment, -1, -1, -1, _p.cashrcpt_distdate, -1, NULL, 0, pJournalNumber, _p.cashrcpt_curr_id, _arAccntid); END IF; IF (_ccpayid IS NOT NULL) THEN INSERT INTO payaropen (payaropen_ccpay_id, payaropen_aropen_id, payaropen_amount, payaropen_curr_id ) VALUES (_ccpayid, _aropenid, _p.cashrcpt_amount, _p.cashrcpt_curr_id); END IF; -- Create Cash Receipt Item to capture posting IF (_predist=false) THEN INSERT INTO cashrcptitem ( cashrcptitem_cashrcpt_id, cashrcptitem_aropen_id, cashrcptitem_amount, cashrcptitem_applied ) VALUES ( pCashrcptid, _aropenid, (_p.cashrcpt_amount - _posted), false ); END IF; ELSIF (round(_posted_base, 2) > round((_p.cashrcpt_amount_base), 2)) THEN PERFORM insertIntoGLSeries(_sequence, 'A/R', 'CR', 'Currency Exchange Rounding - ' || _p.cashrcpt_docnumber, getGainLossAccntId(_debitAccntid), round(_posted_base, 2) - round((_p.cashrcpt_amount_base + _p.cashrcpt_discount_base), 2), _p.cashrcpt_distdate, _p.custnote, pCashrcptid); END IF; -- Debit Cash PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', (_p.cashrcpt_fundstype || '-' || _p.cashrcpt_docnumber), _debitAccntid, round(_p.cashrcpt_amount_base, 2) * -1, _p.cashrcpt_distdate, _p.custnote, pCashrcptid ); -- Post any gain/loss from the alternate currency exchange rate IF (COALESCE(_p.cashrcpt_alt_curr_rate, 0.0) <> 0.0) THEN _exchGain := ROUND((_p.cashrcpt_amount / _p.cashrcpt_alt_curr_rate) - (_p.cashrcpt_amount / _p.cashrcpt_curr_rate), 2); IF (_exchGain <> 0) THEN PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', (_p.cashrcpt_fundstype || '-' || _p.cashrcpt_docnumber), _debitAccntid, (_exchGain * -1.0), _p.cashrcpt_distdate, _p.custnote, pCashrcptid ); PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', (_p.cashrcpt_fundstype || '-' || _p.cashrcpt_docnumber), getGainLossAccntId(_debitAccntid), _exchGain, _p.cashrcpt_distdate, _p.custnote, pCashrcptid ); END IF; END IF; PERFORM postGLSeries(_sequence, pJournalNumber); -- convert the cashrcptitem records to applications against the cm/cd if we are _predist IF(_predist=true) THEN FOR _r IN SELECT * FROM cashrcptitem WHERE ((cashrcptitem_cashrcpt_id=pCashrcptid) AND (cashrcptitem_amount > 0)) LOOP -- Handle discount if applicable IF (_r.cashrcptitem_discount > 0) THEN PERFORM postCashReceiptDisc(_r.cashrcptitem_id, pJournalNumber); END IF; INSERT INTO arcreditapply (arcreditapply_source_aropen_id, arcreditapply_target_aropen_id, arcreditapply_amount, arcreditapply_curr_id) VALUES(_aropenid, _r.cashrcptitem_aropen_id, _r.cashrcptitem_amount, _p.cashrcpt_curr_id); _posted := (_posted + _r.cashrcptitem_amount); END LOOP; PERFORM postArCreditMemoApplication(_aropenid, _p.applydate); -- If there is any left over go ahead and create an additional cashrcptitem record for it with the amount IF (round(_posted, 2) < round(_p.cashrcpt_amount, 2)) THEN INSERT INTO cashrcptitem ( cashrcptitem_cashrcpt_id, cashrcptitem_aropen_id, cashrcptitem_amount, cashrcptitem_applied ) VALUES ( pCashrcptid, _aropenid, (_p.cashrcpt_amount - _posted), false ); END IF; END IF; -- Update the posted cashrcpt UPDATE cashrcpt SET cashrcpt_posted=TRUE, cashrcpt_posteddate=CURRENT_DATE, cashrcpt_postedby=getEffectiveXtUser() WHERE (cashrcpt_id=pCashrcptid); RETURN 1; END; $$; SDROP FUNCTION public.postcashreceipt(pcashrcptid integer, pjournalnumber integer); publicadminfalse84623F125579118%postcashreceiptdisc(integer, integer)FUNCTIONCREATE FUNCTION postcashreceiptdisc(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCashrcptItemId ALIAS FOR $1; pJournalNumber ALIAS FOR $2; _r RECORD; _t RECORD; _v RECORD; _ardiscountid INTEGER; _arMemoNumber TEXT; _arAccntid INTEGER; _discountAccntid INTEGER; _comment TEXT; _discprcnt NUMERIC; _check INTEGER; BEGIN -- Fetch base records for processing SELECT aropen_id, aropen_doctype, aropen_amount, cashrcptitem_discount, cashrcpt_cust_id, cashrcpt_distdate, cashrcpt_applydate, cashrcpt_curr_id, cashrcpt_fundstype, cashrcpt_docnumber, round(currToCurr(cashrcpt_curr_id, aropen_curr_id, cashrcptitem_discount, cashrcpt_distdate),2) AS aropen_discount INTO _r FROM cashrcptitem JOIN cashrcpt ON (cashrcptitem_cashrcpt_id=cashrcpt_id) JOIN aropen ON ( (aropen_id=cashrcptitem_aropen_id) AND (aropen_doctype IN ('I', 'D')) ) WHERE (cashrcptitem_id=pCashrcptItemId); -- Get discount account _discountAccntid := findardiscountaccount(_r.cashrcpt_cust_id); IF (_r.cashrcptitem_discount > 0) THEN -- Determine discount percentage _discprcnt := _r.aropen_discount / _r.aropen_amount; SELECT fetchArMemoNumber() INTO _arMemoNumber; _comment := 'Discount Credit from ' || _r.cashrcpt_fundstype || '-' || _r.cashrcpt_docnumber; -- Create misc credit memo record _ardiscountid := nextval('aropen_aropen_id_seq'); INSERT INTO aropen ( aropen_id, aropen_docdate, aropen_duedate, aropen_doctype, aropen_docnumber, aropen_curr_id, aropen_posted, aropen_amount) VALUES ( _ardiscountid, _r.cashrcpt_distdate, _r.cashrcpt_distdate, 'C', _arMemoNumber, _r.cashrcpt_curr_id, false,_r.cashrcptitem_discount); IF (fetchMetricBool('CreditTaxDiscount')) THEN -- proportional tax credits calculated and implemented for the credit memo generated by the discount IF (_r.aropen_doctype = 'I') THEN -- Tax for invoices SELECT aropen_cobmisc_id AS invcheadid, invchead_curr_id, invchead_invcdate INTO _t FROM aropen LEFT OUTER JOIN invchead ON (aropen_cobmisc_id = invchead_id) LEFT OUTER JOIN invcitem ON (invchead_id = invcitem_invchead_id) WHERE aropen_id = _r.aropen_id; FOR _v IN SELECT tax_sales_accnt_id, tax_id, round(sum(taxdetail_tax), 2) AS tax, currToBase(_t.invchead_curr_id, round(sum(taxdetail_tax), 2), _t.invchead_invcdate) AS taxbasevalue FROM tax JOIN calculateTaxDetailSummary('I', _t.invcheadid, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id, tax_sales_accnt_id LOOP INSERT INTO aropentax( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_basis) VALUES ( _ardiscountid, getadjustmenttaxtypeid(), _v.tax_id, 0.00, 0.00, (round((_v.tax * _discprcnt), 2) * -1), _r.cashrcpt_distdate, 0.00); END LOOP; ELSIF (_r.aropen_doctype = 'D') THEN -- Tax for debit memos INSERT INTO aropentax( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_basis) SELECT _ardiscountid, taxhist_taxtype_id, taxhist_tax_id, 0.00, 0.00, (round((taxhist_tax * _discprcnt), 2) * -1), _r.cashrcpt_distdate, 0.00 FROM aropentax WHERE (taxhist_parent_id=_r.aropen_id); END IF; END IF; -- End taxes -- Create credit memo for discount SELECT createARCreditMemo(_ardiscountid, _r.cashrcpt_cust_id, _arMemoNumber, '', _r.cashrcpt_distdate, _r.cashrcptitem_discount, _comment, -1, -1, _discountAccntid, _r.cashrcpt_distdate, -1, NULL, 0, pJournalNumber, _r.cashrcpt_curr_id) INTO _ardiscountid; -- Apply discount credit memo INSERT INTO arcreditapply ( arcreditapply_source_aropen_id, arcreditapply_target_aropen_id, arcreditapply_amount, arcreditapply_curr_id ) VALUES ( _ardiscountid, _r.aropen_id, _r.cashrcptitem_discount, _r.cashrcpt_curr_id ); SELECT postARCreditMemoApplication(_ardiscountid, _r.cashrcpt_applydate) INTO _check; IF (_check < 0) THEN RAISE EXCEPTION 'Error posting discount credit memo application. Code %', _check; END IF; END IF; -- End handle Discount RETURN 1; END; $_$; <DROP FUNCTION public.postcashreceiptdisc(integer, integer); publicadminfalse46238G1255791202postcccashreceipt(integer, integer, text, numeric)FUNCTIONCREATE FUNCTION postcccashreceipt(pccpay integer, pdocid integer, pdoctype text DEFAULT NULL::text, pamount numeric DEFAULT NULL::numeric) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _aropenid INTEGER; _bankaccnt_id INTEGER; _c RECORD; _ccOrderDesc TEXT; _journal INTEGER; _realaccnt INTEGER; _return INTEGER := 0; BEGIN SELECT * INTO _c FROM ccpay JOIN custinfo ON ccpay_cust_id = cust_id WHERE (ccpay_id = pCCpay); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot find the Credit Card transaction information [xtuple: postCCcashReceipt, -11, %]', pCCpay; END IF; IF (pamount IS NOT NULL) THEN _c.ccpay_amount = pamount; END IF; SELECT bankaccnt_id, bankaccnt_accnt_id INTO _bankaccnt_id, _realaccnt FROM ccbank JOIN bankaccnt ON (ccbank_bankaccnt_id=bankaccnt_id) WHERE (ccbank_ccard_type=_c.ccpay_card_type); IF (_bankaccnt_id IS NULL) THEN RAISE EXCEPTION 'Cannot find the default Bank Account for this Credit Card [xtuple: postCCcredit, -1, %]', _c.ccpay_card_type; END IF; _ccOrderDesc := (_c.ccpay_card_type || '-' || _c.ccpay_order_number::TEXT || '-' || _c.ccpay_order_number_seq::TEXT); _journal := fetchJournalNumber('C/R'); IF (pdoctype = 'cashrcpt') THEN IF (COALESCE(pdocid, -1) < 0) THEN INSERT INTO cashrcpt ( cashrcpt_cust_id, cashrcpt_amount, cashrcpt_curr_id, cashrcpt_fundstype, cashrcpt_docnumber, cashrcpt_notes, cashrcpt_distdate, cashrcpt_bankaccnt_id, cashrcpt_usecustdeposit ) VALUES ( _c.ccpay_cust_id, _c.ccpay_amount, _c.ccpay_curr_id, _c.ccpay_card_type, _c.ccpay_r_ordernum, _ccOrderDesc, CURRENT_DATE, _bankaccnt_id, fetchMetricBool('EnableCustomerDeposits')) RETURNING cashrcpt_id INTO _return; ELSE UPDATE cashrcpt SET cashrcpt_cust_id=_c.ccpay_cust_id, cashrcpt_amount=_c.ccpay_amount, cashrcpt_curr_id=_c.ccpay_curr_id, cashrcpt_fundstype=_c.ccpay_card_type, cashrcpt_docnumber=_c.ccpay_r_ordernum, cashrcpt_notes=_ccOrderDesc, cashrcpt_distdate=CURRENT_DATE, cashrcpt_bankaccnt_id=_bankaccnt_id WHERE (cashrcpt_id=pdocid); _return := pdocid; END IF; ELSIF (pdoctype = 'cohead') THEN SELECT createARCreditMemo(NULL, _c.ccpay_cust_id, fetchArMemoNumber(), cohead_number, CURRENT_DATE, _c.ccpay_amount, 'Unapplied from ' || _ccOrderDesc, NULL, NULL, NULL, CURRENT_DATE, NULL, cohead_salesrep_id, NULL, _journal, _c.ccpay_curr_id, NULL, pCCpay) INTO _aropenid FROM cohead WHERE cohead_id = pdocid; IF (COALESCE(_aropenid, -1) < 0) THEN -- coalesce handles not-found case RAISE EXCEPTION '[xtuple: createARCreditMemo, %]', _aropenid; END IF; INSERT INTO payaropen (payaropen_ccpay_id, payaropen_aropen_id, payaropen_amount, payaropen_curr_id) VALUES (pccpay, _aropenid, _c.ccpay_amount, _c.ccpay_curr_id); INSERT INTO aropenalloc (aropenalloc_aropen_id, aropenalloc_doctype, aropenalloc_doc_id, aropenalloc_amount, aropenalloc_curr_id) VALUES (_aropenid, 'S', pdocid, _c.ccpay_amount, _c.ccpay_curr_id); _return := _aropenid; END IF; PERFORM insertGLTransaction(_journal, 'A/R', 'CR', _ccOrderDesc, ('Cash Receipt from Credit Card ' || _c.cust_name), findPrepaidAccount(_c.ccpay_cust_id), _realaccnt, NULL, ROUND(currToBase(_c.ccpay_curr_id, _c.ccpay_amount, _c.ccpay_transaction_datetime::DATE),2), CURRENT_DATE); RETURN _return; END; $$; hDROP FUNCTION public.postcccashreceipt(pccpay integer, pdocid integer, pdoctype text, pamount numeric); publicadminfalse46238I125579121$postcccredit(integer, text, integer)FUNCTIONZCREATE FUNCTION postcccredit(integer, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCCpay ALIAS FOR $1; preftype ALIAS FOR $2; prefid ALIAS FOR $3; _c RECORD; _ccOrderDesc TEXT; _cglaccnt INTEGER; _dglaccnt INTEGER; _glseriesres INTEGER; _notes TEXT := 'Credit via Credit Card'; _r RECORD; _sequence INTEGER; _dmaropenid INTEGER; BEGIN IF ((preftype = 'cohead') AND NOT EXISTS(SELECT cohead_id FROM cohead WHERE (cohead_id=prefid))) THEN RAISE EXCEPTION 'Cannot find original Sales Order for this Credit Card credit [xtuple: postCCcredit, -2, %, %, %]', pCCpay, preftype, prefid; ELSIF ((preftype = 'aropen') AND NOT EXISTS(SELECT aropen_id FROM aropen WHERE (aropen_id=prefid))) THEN RAISE EXCEPTION 'Cannot find original A/R Open record for this Credit Card credit [xtuple: postCCcredit, -2, %, %, %]', pCCpay, preftype, prefid; ELSIF ((preftype = 'cmhead') AND NOT EXISTS(SELECT cmhead_id FROM cmhead WHERE cmhead_id=prefid)) THEN RAISE EXCEPTION 'Cannot find original Credit Memo record for this Credit Card credit [xtuple: postCCcredit, -2, %, %, %]', pCCpay, preftype, prefid; END IF; SELECT * INTO _c FROM ccpay WHERE (ccpay_id = pCCpay); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot find the record for this Credit Card credit [xtuple: postCCcredit, -3, %, %, %]', pCCpay, preftype, prefid; END IF; IF (preftype = 'cohead') THEN _dglaccnt := findPrepaidAccount(_c.ccpay_cust_id); ELSE _dglaccnt := findARAccount(_c.ccpay_cust_id); END IF; SELECT bankaccnt_accnt_id INTO _cglaccnt FROM ccbank JOIN bankaccnt ON (ccbank_bankaccnt_id=bankaccnt_id) WHERE (ccbank_ccard_type=_c.ccpay_card_type); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot find the default Bank Account for this Credit Card [xtuple: postCCcredit, -1, %]', pCCpay; END IF; IF (_c.ccpay_type != 'R') THEN RAISE EXCEPTION 'This Credit Card transaction is not a credit/refund [xtuple: postCCcredit, -4, %]', pCCpay; END IF; _sequence := fetchGLSequence(); IF (_c.ccpay_r_ref IS NOT NULL) THEN _ccOrderDesc := (_c.ccpay_card_type || '-' || _c.ccpay_r_ref); ELSE _ccOrderDesc := (_c.ccpay_card_type || '-' || _c.ccpay_order_number::TEXT || '-' || COALESCE(_c.ccpay_order_number_seq::TEXT, '')); END IF; _glseriesres := insertIntoGLSeries(_sequence, 'A/R', 'CC', _ccOrderDesc, _dglaccnt, ROUND(currToBase(_c.ccpay_curr_id, _c.ccpay_amount, _c.ccpay_transaction_datetime::DATE), 2) * -1, CURRENT_DATE, _notes); IF (_glseriesres < 0) THEN RAISE EXCEPTION 'Could not write debit side of Credit Card credit to the G/L [xtuple: insertIntoGLSeries, %]', _glseriesres; END IF; _glseriesres := insertIntoGLSeries(_sequence, 'A/R', 'CC', _ccOrderDesc, _cglaccnt, ROUND(currToBase(_c.ccpay_curr_id, _c.ccpay_amount, _c.ccpay_transaction_datetime::DATE),2), CURRENT_DATE, _notes); IF (_glseriesres < 0) THEN RAISE EXCEPTION 'Could not write credit side of Credit Card credit to the G/L [xtuple: insertIntoGLSeries, %]', _glseriesres; END IF; _glseriesres := postGLSeries(_sequence, fetchJournalNumber('C/R') ); IF (_glseriesres < 0) THEN RAISE EXCEPTION 'Could not post Credit Card credit to the G/L [xtuple: postglseries, %]', _glseriesres; END IF; IF (preftype = 'aropen') THEN SELECT * INTO _r FROM aropen WHERE (aropen_id=prefid); ELSE SELECT aropen.* INTO _r FROM ccpay n JOIN ccpay o ON (o.ccpay_id=n.ccpay_ccpay_id) JOIN payaropen ON (payaropen_ccpay_id=o.ccpay_id) JOIN aropen ON (payaropen_aropen_id=aropen_id) WHERE (n.ccpay_id=pCCpay); END IF; IF (FOUND) THEN SELECT createardebitmemo( NULL, _r.aropen_cust_id, NULL, fetchARMemoNumber(), _r.aropen_ordernumber, current_date, _c.ccpay_amount, _notes, -1, -1, -1, CURRENT_DATE, -1, NULL, 0, _r.aropen_curr_id) INTO _dmaropenid; IF (_r.aropen_open) THEN PERFORM applyARCreditMemoToBalance(_r.aropen_id, _dmaropenid); PERFORM postARCreditMemoApplication(_r.aropen_id); END IF; END IF; IF (preftype = 'cohead') THEN INSERT INTO payco ( payco_ccpay_id, payco_cohead_id, payco_amount, payco_curr_id ) VALUES ( pCCpay, prefid, 0 - _c.ccpay_amount, _c.ccpay_curr_id ); END IF; RETURN 0; END; $_$; ;DROP FUNCTION public.postcccredit(integer, text, integer); publicadminfalse84623J125579122postccvoid(integer)FUNCTIONCREATE FUNCTION postccvoid(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pccpayid ALIAS FOR $1; BEGIN -- for now this is very simple: mark the ccpay record voided. -- in the future this might be expanded to back out changes to other tables -- but for now the VOID request is sent to the credit card processing company -- before those other tables are modified. UPDATE ccpay SET ccpay_status = 'V' WHERE (ccpay_id=pccpayid); IF (NOT FOUND) THEN RETURN -1; END IF; RETURN 0; END; $_$; *DROP FUNCTION public.postccvoid(integer); publicadminfalse46238K125579123postcheck(integer, integer)FUNCTION20CREATE FUNCTION postcheck(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pcheckid ALIAS FOR $1; _journalNumber INTEGER := $2; _amount_base NUMERIC := 0; _credit_glaccnt INTEGER; _exchGain NUMERIC := 0; _exchGainTmp NUMERIC := 0; _gltransNote TEXT; _p RECORD; _r RECORD; _t RECORD; _sequence INTEGER; _test INTEGER; _cm BOOLEAN; _amount_check NUMERIC := 0; BEGIN _cm := FALSE; SELECT fetchGLSequence() INTO _sequence; IF (_journalNumber IS NULL) THEN _journalNumber := fetchJournalNumber('AP-CK'); END IF; SELECT checkhead.*, checkhead_amount / checkhead_curr_rate AS checkhead_amount_base, bankaccnt_accnt_id AS bankaccntid INTO _p FROM checkhead JOIN bankaccnt ON (checkhead_bankaccnt_id=bankaccnt_id) WHERE (checkhead_id=pcheckid); IF (FOUND) THEN IF (_p.checkhead_recip_type = 'V') THEN SELECT vend_number AS checkrecip_number, vend_name AS checkrecip_name, findAPAccount(vend_id) AS checkrecip_accnt_id, 'A/P'::text AS checkrecip_gltrans_source INTO _t FROM vendinfo WHERE (vend_id=_p.checkhead_recip_id); ELSIF (_p.checkhead_recip_type = 'C') THEN SELECT cust_number AS checkrecip_number, cust_name AS checkrecip_name, findARAccount(cust_id) AS checkrecip_accnt_id, 'A/R'::text AS checkrecip_gltrans_source INTO _t FROM custinfo WHERE (cust_id=_p.checkhead_recip_id); ELSIF (_p.checkhead_recip_type = 'T') THEN SELECT taxauth_code AS checkrecip_number, taxauth_name AS checkrecip_name, taxauth_accnt_id AS checkrecip_accnt_id, 'G/L'::text AS checkrecip_gltrans_source INTO _t FROM taxauth WHERE (taxauth_id=_p.checkhead_recip_id); ELSE RETURN -11; END IF; ELSE RETURN -11; END IF; IF (_p.checkhead_posted) THEN RETURN -10; END IF; IF (_p.checkhead_recip_type = 'C') THEN SELECT checkitem_id FROM checkitem INTO _test WHERE (checkitem_checkhead_id=pcheckid) LIMIT 1; IF (FOUND) THEN _cm := TRUE; END IF; END IF; _gltransNote := _t.checkrecip_number || '-' || _t.checkrecip_name || '\n' || _p.checkhead_for || '\n' || _p.checkhead_notes; IF (_p.checkhead_misc AND NOT _cm) THEN IF (COALESCE(_p.checkhead_expcat_id, -1) < 0) THEN IF (_p.checkhead_recip_type = 'V') THEN PERFORM createAPCreditMemo( _p.checkhead_recip_id, _journalNumber, CAST(fetchAPMemoNumber() AS text), '', _p.checkhead_checkdate, _p.checkhead_amount, _gltransNote || ' ' || _p.checkhead_notes, -1, _p.checkhead_checkdate, -1, _p.checkhead_curr_id ); _credit_glaccnt := findAPPrepaidAccount(_p.checkhead_recip_id); ELSIF (_p.checkhead_recip_type = 'C') THEN PERFORM createARDebitMemo(NULL, _p.checkhead_recip_id, NULL, fetchARMemoNumber(), '', _p.checkhead_checkdate, _p.checkhead_amount, _gltransNote || ' ' || _p.checkhead_notes, -1, -1, -1, _p.checkhead_checkdate, -1, NULL, 0, _p.checkhead_curr_id ); _credit_glaccnt := findPrepaidAccount(_p.checkhead_recip_id); ELSIF (_p.checkhead_recip_type = 'T') THEN -- TODO: should we create a credit memo for the tax authority? how? _credit_glaccnt := _t.checkrecip_accnt_id; END IF; -- recip type ELSE IF (_cm) THEN _credit_glaccnt := findARAccount(_p.checkhead_recip_id); ELSE SELECT expcat_exp_accnt_id INTO _credit_glaccnt FROM expcat WHERE (expcat_id=_p.checkhead_expcat_id); IF (NOT FOUND) THEN RETURN -12; END IF; END IF; END IF; IF (COALESCE(_credit_glaccnt, -1) < 0) THEN RETURN -13; END IF; PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source, 'CK', CAST(_p.checkhead_number AS TEXT), _credit_glaccnt, round(_p.checkhead_amount_base, 2) * -1, _p.checkhead_checkdate, _gltransNote, pcheckid ); _amount_base := _p.checkhead_amount_base; ELSE FOR _r IN SELECT checkitem_amount, checkitem_discount, CASE WHEN (checkitem_apopen_id IS NOT NULL AND apopen_doctype='C') THEN checkitem_amount / apopen_curr_rate * -1.0 WHEN (checkitem_apopen_id IS NOT NULL) THEN checkitem_amount / apopen_curr_rate ELSE currToBase(checkitem_curr_id, checkitem_amount, COALESCE(checkitem_docdate, _p.checkhead_checkdate)) END AS checkitem_amount_base, currTocurr(checkitem_curr_id, _p.checkhead_curr_id, CASE WHEN (checkitem_apopen_id IS NOT NULL AND apopen_doctype='C') THEN checkitem_amount * -1.0 ELSE checkitem_amount END, _p.checkhead_checkdate) AS amount_check, apopen_id, apopen_doctype, apopen_docnumber, aropen_id, aropen_doctype, aropen_docnumber, checkitem_curr_id, checkitem_curr_rate, apopen_curr_rate, COALESCE(checkitem_docdate, _p.checkhead_checkdate) AS docdate FROM (checkitem LEFT OUTER JOIN apopen ON (checkitem_apopen_id=apopen_id)) LEFT OUTER JOIN aropen ON (checkitem_aropen_id=aropen_id) WHERE (checkitem_checkhead_id=pcheckid) LOOP _exchGainTmp := 0; IF (_r.apopen_id IS NOT NULL) THEN -- take the discount if specified before we do anything else IF(_r.checkitem_discount > 0.0) THEN PERFORM createAPDiscount(_r.apopen_id, _r.checkitem_discount); END IF; UPDATE apopen SET apopen_paid = round(apopen_paid + _r.checkitem_amount, 2), apopen_open = round(apopen_amount, 2) > round(apopen_paid + _r.checkitem_amount, 2), apopen_closedate = CASE WHEN (round(apopen_amount, 2) <= round(apopen_paid + _r.checkitem_amount, 2)) THEN _p.checkhead_checkdate END WHERE (apopen_id=_r.apopen_id); -- Post the application INSERT INTO apapply ( apapply_vend_id, apapply_postdate, apapply_username, apapply_source_apopen_id, apapply_source_doctype, apapply_source_docnumber, apapply_target_apopen_id, apapply_target_doctype, apapply_target_docnumber, apapply_journalnumber, apapply_amount, apapply_curr_id, apapply_checkhead_id ) VALUES ( _p.checkhead_recip_id, _p.checkhead_checkdate, getEffectiveXtUser(), -1, 'K', _p.checkhead_number, _r.apopen_id, _r.apopen_doctype, _r.apopen_docnumber, _journalNumber, _r.checkitem_amount, _r.checkitem_curr_id, _p.checkhead_id ); END IF; -- if check item's apopen_id is not null IF (_r.aropen_id IS NOT NULL) THEN UPDATE aropen SET aropen_paid = round(aropen_paid + _r.checkitem_amount, 2), aropen_open = round(aropen_amount, 2) > round(aropen_paid + _r.checkitem_amount, 2), aropen_closedate = CASE WHEN (round(aropen_amount, 2) <= round(aropen_paid + _r.checkitem_amount, 2)) THEN _p.checkhead_checkdate END WHERE (aropen_id=_r.aropen_id); -- Post the application INSERT INTO arapply ( arapply_cust_id, arapply_postdate, arapply_distdate, arapply_username, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_journalnumber, arapply_applied, arapply_curr_id ) VALUES ( _p.checkhead_recip_id, _p.checkhead_checkdate, _p.checkhead_checkdate, getEffectiveXtUser(), _r.aropen_id,_r.aropen_doctype, _r.aropen_docnumber, -1, 'K',_p.checkhead_number , _journalNumber, _r.checkitem_amount, _r.checkitem_curr_id ); END IF; -- if check item's aropen_id is not null IF (_r.apopen_id IS NOT NULL) THEN SELECT apCurrGain(_r.apopen_id,_r.checkitem_curr_id, _r.checkitem_amount, _p.checkhead_checkdate) INTO _exchGainTmp; ELSIF (_r.aropen_id IS NOT NULL) THEN SELECT arCurrGain(_r.aropen_id,_r.checkitem_curr_id, _r.checkitem_amount, _p.checkhead_checkdate) INTO _exchGainTmp; END IF; _exchGain := _exchGain + _exchGainTmp; PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source, 'CK', CAST(_p.checkhead_number AS TEXT), _t.checkrecip_accnt_id, round(_r.checkitem_amount_base, 2) * -1.0, _p.checkhead_checkdate, _gltransNote, pcheckid ); IF (_exchGainTmp <> 0) THEN PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source, 'CK', CAST(_p.checkhead_number AS TEXT), getGainLossAccntId(_t.checkrecip_accnt_id), round(_exchGainTmp,2), _p.checkhead_checkdate, _gltransNote, pcheckid ); END IF; _amount_check := (_amount_check + _r.amount_check); _amount_base := (_amount_base + _r.checkitem_amount_base); END LOOP; IF( (_amount_check - _p.checkhead_amount) <> 0.0 ) THEN _exchGainTmp := currToBase(_p.checkhead_curr_id, _amount_check - _p.checkhead_amount, _p.checkhead_checkdate); _exchGain := _exchGain + _exchGainTmp; END IF; -- ensure that the check balances, attribute rounding errors to gain/loss IF round(_amount_base, 2) - round(_exchGain, 2) <> round(_p.checkhead_amount_base, 2) THEN IF round(_amount_base - _exchGain, 2) = round(_p.checkhead_amount_base, 2) THEN PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source, 'CK', CAST(_p.checkhead_number AS TEXT), getGainLossAccntId(_p.bankaccntid), round(_amount_base, 2) - round(_exchGain, 2) - round(_p.checkhead_amount_base, 2), _p.checkhead_checkdate, _gltransNote, pcheckid ); ELSE RAISE EXCEPTION 'checkhead_id % does not balance (% - % <> %)', pcheckid, _amount_base, _exchGain, _p.checkhead_amount_base; END IF; END IF; END IF; PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source, 'CK', CAST(_p.checkhead_number AS TEXT), _p.bankaccntid, round(_p.checkhead_amount_base, 2), _p.checkhead_checkdate, _gltransNote, pcheckid ); -- Post any gain/loss from the alternate currency exchange rate IF (COALESCE(_p.checkhead_alt_curr_rate, 0.0) <> 0.0) THEN _exchGain := ROUND((_p.checkhead_curr_rate - _p.checkhead_alt_curr_rate) * _p.checkhead_amount_base, 2); IF (_exchGain <> 0) THEN PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source, 'CK', CAST(_p.checkhead_number AS TEXT), _p.bankaccntid, (_exchGain * -1.0), _p.checkhead_checkdate, _gltransNote, pcheckid ); PERFORM insertIntoGLSeries( _sequence, _t.checkrecip_gltrans_source, 'CK', CAST(_p.checkhead_number AS TEXT), getGainLossAccntId(_p.bankaccntid), _exchGain, _p.checkhead_checkdate, _gltransNote, pcheckid ); END IF; END IF; PERFORM postGLSeries(_sequence, _journalNumber); UPDATE checkhead SET checkhead_posted=TRUE, checkhead_journalnumber=_journalNumber WHERE (checkhead_id=pcheckid); RETURN _journalNumber; END; $_$; 2DROP FUNCTION public.postcheck(integer, integer); publicadminfalse46238L125579125postchecks(integer)FUNCTIONCREATE FUNCTION postchecks(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBankaccntid ALIAS FOR $1; _journalNumber INTEGER; BEGIN SELECT fetchJournalNumber('AP-CK') INTO _journalNumber; PERFORM postCheck(checkhead_id, _journalNumber) FROM checkhead JOIN bankaccnt ON (bankaccnt_id=checkhead_bankaccnt_id) WHERE ( (NOT checkhead_void) AND (NOT checkhead_posted) AND CASE WHEN (bankaccnt_prnt_check) THEN (checkhead_printed) ELSE 1=1 END AND (checkhead_bankaccnt_id=pBankaccntid) ); RETURN _journalNumber; END; $_$; *DROP FUNCTION public.postchecks(integer); publicadminfalse46238N125579126)postcomment(integer, text, integer, text)FUNCTIONhCREATE FUNCTION postcomment(pcmnttypeid integer, psource text, psourceid integer, ptext text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN RETURN postComment(pCmnttypeid, pSource, pSourceid, pText, NULL); END $$; dDROP FUNCTION public.postcomment(pcmnttypeid integer, psource text, psourceid integer, ptext text); publicadminfalse84623M125579127&postcomment(text, text, integer, text)FUNCTION<CREATE FUNCTION postcomment(pcmnttypename text, psource text, psourceid integer, ptext text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cmnttypeid INTEGER; BEGIN SELECT cmnttype_id INTO _cmnttypeid FROM cmnttype WHERE (cmnttype_name=pCmnttypename); IF (NOT FOUND) THEN RAISE EXCEPTION 'Comment type % not found.', pCmnttypename; END IF; RETURN postComment(_cmnttypeid, pSource, pSourceid, pText, NULL); END $$; cDROP FUNCTION public.postcomment(pcmnttypename text, psource text, psourceid integer, ptext text); publicadminfalse84623O1255791282postcomment(integer, text, integer, text, boolean)FUNCTIONCREATE FUNCTION postcomment(pcmnttypeid integer, psource text, psourceid integer, ptext text, ppublic boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _commentid INTEGER; _public BOOLEAN; BEGIN _public := COALESCE(pPublic, fetchmetricbool('CommentPublicDefault')); INSERT INTO comment ( comment_cmnttype_id, comment_source, comment_source_id, comment_date, comment_user, comment_text, comment_public ) VALUES ( pCmnttypeid, pSource, pSourceid, CURRENT_TIMESTAMP, getEffectiveXtUser(), pText, _public ) RETURNING comment_id INTO _commentid; RETURN _commentid; END; $$; uDROP FUNCTION public.postcomment(pcmnttypeid integer, psource text, psourceid integer, ptext text, ppublic boolean); publicadminfalse84623P125579129postcost(integer)FUNCTIONCREATE FUNCTION postcost(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemcostid ALIAS FOR $1; _p RECORD; BEGIN SELECT round(currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE),6) AS newcost, itemcost_curr_id, CURRENT_DATE AS effective, item_number, itemcost_stdcost AS oldcost INTO _p FROM itemcost, item WHERE ((itemcost_item_id=item_id) AND (itemcost_id=pItemcostid)); IF (_p.newcost IS NULL) THEN RAISE EXCEPTION 'There is no valid Exchange Rate for this currency. (%, %)', _p.itemcost_curr_id, _p.effective; RETURN FALSE; END IF; RETURN updateStdCost(pItemcostid, _p.newcost, _p.oldcost, 'Post Cost', ('Post Actual Cost to Standard for item ' || _p.item_number)); END; $_$; (DROP FUNCTION public.postcost(integer); publicadminfalse84623R125579130postcountslip(integer)FUNCTIONACREATE FUNCTION postcountslip(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCntslipid ALIAS FOR $1; _p RECORD; _comments TEXT; _temp TEXT; BEGIN SELECT itemsite_loccntrl, itemsite_controlmethod, cntslip_posted, cntslip_lotserial, cntslip_comments, cntslip_number, cntslip_qty INTO _p FROM cntslip, invcnt, itemsite WHERE ( (cntslip_cnttag_id=invcnt_id) AND (invcnt_itemsite_id=itemsite_id) AND (cntslip_id=pCntslipid) ); IF (NOT _p.cntslip_posted) THEN SELECT ( E'\nCount Slip #' || _p.cntslip_number || ' counted ' || formatQty(_p.cntslip_qty) ) INTO _comments; -- Add the Location name if the itemsite is MLC IF (_p.itemsite_loccntrl) THEN SELECT ( ', Location:' || location_name ) INTO _temp FROM location, cntslip WHERE ( (cntslip_location_id=location_id) AND (cntslip_id=pCntslipid) ); _comments := (_comments || _temp); END IF; -- Add the Lot/Serial if the itemsite is Lot or Serial controlled IF (_p.itemsite_controlmethod = 'L') THEN _comments := (_comments || ( ', Lot #:' || _p.cntslip_lotserial)); ELSIF (_p.itemsite_controlmethod = 'S') THEN _comments := (_comments || ( ', Serial #:' || _p.cntslip_lotserial)); END IF; _comments := (_comments || ' ' || _p.cntslip_comments); UPDATE cntslip SET cntslip_posted=TRUE WHERE (cntslip_id=pCntslipid); UPDATE invcnt SET invcnt_qoh_after = ( COALESCE(invcnt_qoh_after, 0) + cntslip_qty), invcnt_comments = (invcnt_comments || _comments) FROM cntslip WHERE ( (cntslip_cnttag_id=invcnt_id) AND (cntslip_id=pCntslipid) ); RETURN 1; ELSE RETURN -1; END IF; END; $_$; -DROP FUNCTION public.postcountslip(integer); publicadminfalse84623S125579131postcounttag(integer, boolean)FUNCTION_'CREATE FUNCTION postcounttag(pinvcntid integer, pthaw boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _avgCostingMethod TEXT; _invhistid INTEGER; _postDate TIMESTAMP; _runningQty NUMERIC; _errorCode INTEGER; _itemlocSeries INTEGER := 0; _hasDetail BOOLEAN; _p RECORD; _itemloc RECORD; _cntslip RECORD; _lsid INTEGER; BEGIN SELECT COALESCE(fetchMetricText('CountAvgCostMethod'), 'STD') INTO _avgCostingMethod; SELECT invcnt_id, invcnt_tagnumber, invcnt_qoh_after, invcnt_location_id, item_number, itemsite_id, itemsite_freeze, itemsite_qtyonhand, itemsite_loccntrl, itemsite_location_id, CASE WHEN (itemsite_costmethod = 'N') THEN 0 WHEN ( (itemsite_costmethod = 'A') AND (itemsite_qtyonhand = 0) AND (_avgCostingMethod = 'ACT') ) THEN actcost(itemsite_item_id) WHEN ( (itemsite_costmethod = 'A') AND (_avgCostingMethod IN ('ACT', 'AVG')) ) THEN avgcost(itemsite_id) ELSE stdcost(itemsite_item_id) END AS cost, itemsite_costmethod, itemsite_controlmethod, itemsite_value INTO _p FROM invcnt, itemsite, item WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (invcnt_qoh_after IS NOT NULL) AND (NOT invcnt_posted) AND (invcnt_id=pInvcntid) ); IF (FOUND) THEN -- If the invcnt_location_id is not null then -- call a separate function so as not to affect -- the existing functionality. IF (_p.invcnt_location_id IS NOT NULL) THEN RETURN postCountTagLocation(pInvcntid, pThaw); END IF; SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid; IF (_p.itemsite_freeze) THEN SELECT invcnt_tagdate INTO _postDate FROM invcnt WHERE (invcnt_id=pInvcntid) ; ELSE _postDate = CURRENT_TIMESTAMP; END IF; _hasDetail = FALSE; -- Post the detail indicated by cntslips IF ( (_p.itemsite_loccntrl) OR (_p.itemsite_controlmethod IN ('L', 'S')) ) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; -- Adjust any existing detail to 0 FOR _itemloc IN SELECT itemloc_id, itemloc_location_id, itemloc_ls_id, itemloc_qty FROM itemloc WHERE (itemloc_itemsite_id=_p.itemsite_id) LOOP _hasDetail = TRUE; -- Create the itemlocdist flushing records INSERT INTO itemlocdist ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_expiration, itemlocdist_itemsite_id, itemlocdist_invhist_id, itemlocdist_flush ) VALUES ( _itemlocSeries, 'I', _itemloc.itemloc_id, endOfTime(), _p.itemsite_id, _invhistid, TRUE ); END LOOP; -- Clear the running detail Qty _runningQty := 0; -- Adjust the detail to the cntslip indicated value FOR _cntslip IN SELECT cntslip_location_id, cntslip_lotserial, cntslip_lotserial_expiration, cntslip_lotserial_warrpurc, SUM(cntslip_qty) AS qty, itemsite_item_id FROM cntslip, invcnt, itemsite WHERE ((cntslip_cnttag_id=pInvcntid) AND (cntslip_cnttag_id=invcnt_id) AND (invcnt_itemsite_id=itemsite_id)) GROUP BY cntslip_location_id, cntslip_lotserial, cntslip_lotserial_expiration, cntslip_lotserial_warrpurc,itemsite_item_id LOOP -- Handle the LotSerial IF (LENGTH(_cntslip.cntslip_lotserial)>0) THEN SELECT ls_id INTO _lsid FROM ls WHERE ((ls_item_id=_cntslip.itemsite_item_id) AND (UPPER(ls_number)=UPPER(_cntslip.cntslip_lotserial))); IF (NOT FOUND) THEN _lsid := NEXTVAL('ls_ls_id_seq'); INSERT INTO ls VALUES (_lsid,_cntslip.itemsite_item_id,UPPER(_cntslip.cntslip_lotserial)); END IF; END IF; -- Track the running Qty _runningQty := (_runningQty + _cntslip.qty); _hasDetail = TRUE; -- Create the itemlocdist populating record INSERT INTO itemlocdist ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_itemsite_id, itemlocdist_ls_id, itemlocdist_expiration, itemlocdist_warranty, itemlocdist_qty, itemlocdist_invhist_id ) VALUES ( _itemlocSeries, 'L', _cntslip.cntslip_location_id, _p.itemsite_id, _lsid, COALESCE(_cntslip.cntslip_lotserial_expiration, endOfTime()), _cntslip.cntslip_lotserial_warrpurc,_cntslip.qty, _invhistid ); END LOOP; IF (_runningQty > _p.invcnt_qoh_after) THEN -- The total Count Slip Qty is greater than the Count Tag Qty, -- Don't post the Count. _errorCode = -1; ELSIF ( (_runningQty < _p.invcnt_qoh_after) AND (_p.itemsite_controlmethod IN ('L', 'S')) ) THEN -- The total Count Slip Qty is less than the Count Tag Qty, -- and the Item Site is Lot/Serial controlled. -- Don't post the Count. _errorCode = -2; ELSIF (_runningQty < _p.invcnt_qoh_after) THEN IF ( (NOT _p.itemsite_loccntrl) OR (_p.itemsite_location_id = -1) ) THEN -- The total Count Slip Qty is less than the Count Tag Qty, -- and there isn't a default location to post into. -- Don't post the Count. _errorCode = -3; ELSIF ( SELECT (metric_value='f') FROM metric WHERE (metric_name='PostCountTagToDefault') ) THEN -- The total Count Slip Qty is less than the Count Tag Qty, -- and we don't post Count Tags to default Locations -- Don't post the Count. _errorCode = -4; ELSE -- Distribute the remaining qty into the default location. INSERT INTO itemlocdist ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_itemsite_id, itemlocdist_expiration, itemlocdist_qty, itemlocdist_invhist_id ) SELECT _itemlocSeries, 'L', _p.itemsite_location_id, _p.itemsite_id, endOfTime(), (_p.invcnt_qoh_after - _runningQty), _invhistid; _hasDetail = TRUE; _errorCode = 0; END IF; ELSE -- The Count Slip Qty. must equal the Count Tag Qty. _errorCode = 0; END IF; -- If we shouldn't post the count then delete the itemlocdist records, -- and return with the error. IF (_errorCode <> 0) THEN DELETE FROM itemlocdist WHERE (itemlocdist_series=_itemlocSeries); RETURN _errorCode; END IF; END IF; -- Mod. the Count Tag. UPDATE invcnt SET invcnt_qoh_before=_p.itemsite_qtyonhand, invcnt_postdate=_postDate, invcnt_posted=TRUE, invcnt_invhist_id=_invhistid, invcnt_post_username=getEffectiveXtUser() WHERE (invcnt_id=pInvcntid); -- Create the CC transaction INSERT INTO invhist ( invhist_id, invhist_itemsite_id, invhist_transdate, invhist_transtype, invhist_invqty, invhist_qoh_before, invhist_qoh_after, invhist_docnumber, invhist_comments, invhist_invuom, invhist_unitcost, invhist_hasdetail, invhist_costmethod, invhist_value_before, invhist_value_after, invhist_series ) SELECT _invhistid, itemsite_id, _postDate, 'CC', (invcnt_qoh_after - invcnt_qoh_before), invcnt_qoh_before, invcnt_qoh_after, invcnt_tagnumber, invcnt_comments, uom_name, _p.cost, _hasDetail, _p.itemsite_costmethod, _p.itemsite_value, _p.itemsite_value + (_p.cost * (invcnt_qoh_after - invcnt_qoh_before)), _itemlocSeries FROM itemsite, invcnt, item, uom WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (itemsite_controlmethod <> 'N') AND (invcnt_id=pInvcntid) ); IF ( SELECT metric_value FROM metric WHERE ((metric_name = 'EnableAsOfQOH') AND (metric_value = 't'))) THEN IF (NOT postIntoInvBalance(_invhistid)) THEN RAISE EXCEPTION 'Post into Inventory Balance for invhist_id=% was unsuccessful',_invhistid; END IF; END IF; -- Update the QOH -- Avoid negative value when average cost item UPDATE itemsite SET itemsite_qtyonhand=_p.invcnt_qoh_after, itemsite_value = CASE WHEN ((itemsite_costmethod='A') AND (_p.itemsite_value + (_p.cost * (_p.invcnt_qoh_after - itemsite_qtyonhand))) < 0.0) THEN 0.0 ELSE (_p.itemsite_value + (_p.cost * (_p.invcnt_qoh_after - itemsite_qtyonhand))) END, itemsite_datelastcount=_postDate WHERE (itemsite_id=_p.itemsite_id); -- Post the detail, if any IF (_hasDetail) THEN PERFORM distributeItemlocSeries(_itemlocSeries); END IF; -- Thaw the itemsite if it's frozen IF (pThaw) THEN PERFORM thawItemSite(invcnt_itemsite_id) FROM invcnt WHERE (invcnt_id=pInvcntid); END IF; -- Distribute to G/L PERFORM insertGLTransaction( 'I/M', 'CT', _p.invcnt_tagnumber, ('Post Count Tag #' || _p.invcnt_tagnumber || ' for Item ' || _p.item_number), costcat_adjustment_accnt_id, costcat_asset_accnt_id, _invhistid, ( (_p.invcnt_qoh_after - _p.itemsite_qtyonhand) * _p.cost), _postDate::DATE ) FROM invcnt, itemsite, costcat WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_costcat_id=costcat_id) AND (invcnt_id=pInvcntid) ); RETURN 0; ELSE RETURN -9; END IF; END; $$; EDROP FUNCTION public.postcounttag(pinvcntid integer, pthaw boolean); publicadminfalse84623T125579133&postcounttaglocation(integer, boolean)FUNCTIONv$CREATE FUNCTION postcounttaglocation(pinvcntid integer, pthaw boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _avgCostingMethod TEXT; _invhistid INTEGER; _postDate TIMESTAMP; _runningQty NUMERIC; _errorCode INTEGER; _itemlocSeries INTEGER := 0; _hasDetail BOOLEAN; _p RECORD; _itemloc RECORD; _cntslip RECORD; _origLocQty NUMERIC; _lsid INTEGER; BEGIN SELECT COALESCE(fetchMetricText('CountAvgCostMethod'), 'STD') INTO _avgCostingMethod; SELECT invcnt_id, invcnt_tagnumber, invcnt_qoh_after, invcnt_location_id, invcnt_tagdate, item_number, itemsite_id, itemsite_freeze, itemsite_qtyonhand, itemsite_loccntrl, COALESCE(invcnt_location_id, -1) AS itemsite_location_id, CASE WHEN (itemsite_costmethod = 'N') THEN 0 WHEN ( (itemsite_costmethod = 'A') AND (itemsite_qtyonhand = 0.0) AND (_avgCostingMethod = 'ACT') ) THEN actcost(itemsite_item_id) WHEN ( (itemsite_costmethod = 'A') AND (_avgCostingMethod IN ('ACT', 'AVG')) ) THEN avgcost(itemsite_id) ELSE stdcost(itemsite_item_id) END AS cost, itemsite_costmethod, itemsite_controlmethod, itemsite_value INTO _p FROM invcnt, itemsite, item WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (invcnt_qoh_after IS NOT NULL) AND (NOT invcnt_posted) AND (invcnt_id=pInvcntid) ); IF (NOT FOUND) THEN RETURN -9; END IF; SELECT COALESCE(SUM(itemloc_qty),0.0) INTO _origLocQty FROM itemloc WHERE ((itemloc_itemsite_id=_p.itemsite_id) AND (itemloc_location_id=_p.invcnt_location_id)); IF (NOT FOUND) THEN _origLocQty := 0.0; END IF; SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid; IF (_p.itemsite_freeze) THEN _postDate := _p.invcnt_tagdate; ELSE _postDate := CURRENT_TIMESTAMP; END IF; _hasDetail = FALSE; -- Post the detail indicated by cntslips IF ( (_p.itemsite_loccntrl) OR (_p.itemsite_controlmethod IN ('L', 'S')) ) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; -- Adjust any existing detail to 0 FOR _itemloc IN SELECT itemloc_id, itemloc_location_id, itemloc_ls_id, itemloc_qty FROM itemloc WHERE ((itemloc_itemsite_id=_p.itemsite_id) AND (itemloc_location_id=_p.invcnt_location_id)) LOOP _hasDetail = TRUE; -- Create the itemlocdist flushing records INSERT INTO itemlocdist ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_expiration, itemlocdist_itemsite_id, itemlocdist_invhist_id, itemlocdist_flush ) VALUES ( _itemlocSeries, 'I', _itemloc.itemloc_id, endOfTime(), _p.itemsite_id, _invhistid, TRUE ); END LOOP; -- Clear the running detail Qty _runningQty := 0; -- Adjust the detail to the cntslip indicated value FOR _cntslip IN SELECT cntslip_location_id, cntslip_lotserial, cntslip_lotserial_expiration, cntslip_lotserial_warrpurc, SUM(cntslip_qty) AS qty, itemsite_item_id FROM cntslip,invcnt,itemsite WHERE ((cntslip_cnttag_id=pInvcntid) AND (cntslip_cnttag_id=invcnt_id) AND (invcnt_itemsite_id=itemsite_id)) GROUP BY cntslip_location_id, cntslip_lotserial, cntslip_lotserial_expiration, cntslip_lotserial_warrpurc, itemsite_item_id LOOP -- Handle the LotSerial IF (LENGTH(_cntslip.cntslip_lotserial)>0) THEN SELECT ls_id INTO _lsid FROM ls WHERE ((ls_item_id=_cntslip.itemsite_item_id) AND (UPPER(ls_number)=UPPER(_cntslip.cntslip_lotserial))); IF (NOT FOUND) THEN _lsid := NEXTVAL('ls_ls_id_seq'); INSERT INTO ls VALUES (_lsid,_cntslip.itemsite_item_id,UPPER(_cntslip.cntslip_lotserial)); END IF; END IF; -- Track the running Qty _runningQty := (_runningQty + _cntslip.qty); _hasDetail = TRUE; -- Create the itemlocdist populating record INSERT INTO itemlocdist ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_itemsite_id, itemlocdist_ls_id, itemlocdist_expiration, itemlocdist_warranty, itemlocdist_qty, itemlocdist_invhist_id ) VALUES ( _itemlocSeries, 'L', _cntslip.cntslip_location_id, _p.itemsite_id, _lsid, COALESCE(_cntslip.cntslip_lotserial_expiration, endOfTime()), _cntslip.cntslip_lotserial_warrpurc, _cntslip.qty, _invhistid ); END LOOP; IF (_runningQty > _p.invcnt_qoh_after) THEN -- The total Count Slip Qty is greater than the Count Tag Qty, -- Don't post the Count. _errorCode = -1; ELSIF ( (_runningQty < _p.invcnt_qoh_after) AND (_p.itemsite_controlmethod IN ('L', 'S')) ) THEN -- The total Count Slip Qty is less than the Count Tag Qty, -- and the Item Site is Lot/Serial controlled. -- Don't post the Count. _errorCode = -2; ELSIF (_runningQty < _p.invcnt_qoh_after) THEN IF ( (NOT _p.itemsite_loccntrl) OR (_p.itemsite_location_id = -1) ) THEN -- The total Count Slip Qty is less than the Count Tag Qty, -- and there isn't a default location to post into. -- Don't post the Count. _errorCode = -3; ELSIF ( SELECT (metric_value='f') FROM metric WHERE (metric_name='PostCountTagToDefault') ) THEN -- The total Count Slip Qty is less than the Count Tag Qty, -- and we don't post Count Tags to default Locations -- Don't post the Count. _errorCode = -4; ELSE -- Distribute the remaining qty into the default location. INSERT INTO itemlocdist ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_itemsite_id, itemlocdist_ls_id, itemlocdist_expiration, itemlocdist_qty, itemlocdist_invhist_id ) SELECT _itemlocSeries, 'L', _p.itemsite_location_id, _p.itemsite_id, _lsid, endOfTime(), (_p.invcnt_qoh_after - _runningQty), _invhistid; _hasDetail = TRUE; _errorCode = 0; END IF; ELSE -- The Count Slip Qty. must equal the Count Tag Qty. _errorCode = 0; END IF; -- If we shouldn't post the count then delete the itemlocdist records, -- and return with the error. IF (_errorCode <> 0) THEN DELETE FROM itemlocdist WHERE (itemlocdist_series=_itemlocSeries); RETURN _errorCode; END IF; END IF; -- Mod. the Count Tag. UPDATE invcnt SET invcnt_qoh_before=_origLocQty, invcnt_postdate=_postDate, invcnt_posted=TRUE, invcnt_invhist_id=_invhistid, invcnt_post_username=getEffectiveXtUser() WHERE (invcnt_id=pInvcntid); -- Create the CC transaction INSERT INTO invhist ( invhist_id, invhist_itemsite_id, invhist_transdate, invhist_transtype, invhist_invqty, invhist_qoh_before, invhist_qoh_after, invhist_docnumber, invhist_comments, invhist_invuom, invhist_unitcost, invhist_hasdetail, invhist_costmethod, invhist_value_before, invhist_value_after, invhist_series ) SELECT _invhistid, itemsite_id, _postDate, 'CC', (invcnt_qoh_after - invcnt_qoh_before), invcnt_qoh_before, invcnt_qoh_after, invcnt_tagnumber, invcnt_comments, uom_name, _p.cost, _hasDetail, _p.itemsite_costmethod, _p.itemsite_value, _p.itemsite_value + (_p.cost * (invcnt_qoh_after - invcnt_qoh_before)), _itemlocSeries FROM itemsite, invcnt, item, uom WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (itemsite_controlmethod <> 'N') AND (invcnt_id=pInvcntid) ); -- Update the QOH UPDATE itemsite SET itemsite_qtyonhand= itemsite_qtyonhand + (_p.invcnt_qoh_after - _origLocQty), itemsite_datelastcount=_postDate WHERE (itemsite_id=_p.itemsite_id); UPDATE itemsite SET itemsite_value = itemsite_qtyonhand * _p.cost WHERE (itemsite_id=_p.itemsite_id); -- Post the detail, if any IF (_hasDetail) THEN PERFORM distributeItemlocSeries(_itemlocSeries); END IF; -- Thaw the itemsite if it's frozen IF (pThaw) THEN PERFORM thawItemSite(invcnt_itemsite_id) FROM invcnt WHERE (invcnt_id=pInvcntid); END IF; -- Distribute to G/L PERFORM insertGLTransaction( 'I/M', 'CT', _p.invcnt_tagnumber, ('Post Count Tag #' || _p.invcnt_tagnumber || ' for Item ' || _p.item_number), costcat_adjustment_accnt_id, costcat_asset_accnt_id, _invhistid, ( (_p.invcnt_qoh_after - _origLocQty) * _p.cost), CURRENT_DATE ) FROM invcnt, itemsite, costcat WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_costcat_id=costcat_id) AND (invcnt_id=pInvcntid) ); RETURN 0; END; $$; MDROP FUNCTION public.postcounttaglocation(pinvcntid integer, pthaw boolean); publicadminfalse46238125579135,postcounttaglocation(integer, boolean, text)FUNCTION$CREATE FUNCTION postcounttaglocation(integer, boolean, text) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pInvcntid ALIAS FOR $1; pThaw ALIAS FOR $2; pAvgCostingMethod ALIAS FOR $3; _invhistid INTEGER; _postDate TIMESTAMP; _runningQty NUMERIC; _errorCode INTEGER; _itemlocSeries INTEGER := 0; _hasDetail BOOLEAN; _p RECORD; _itemloc RECORD; _cntslip RECORD; _origLocQty NUMERIC; _netable BOOLEAN; _lsid INTEGER; BEGIN SELECT invcnt_id, invcnt_tagnumber, invcnt_qoh_after, invcnt_location_id, invcnt_tagdate, item_number, itemsite_id, itemsite_freeze, itemsite_qtyonhand, itemsite_loccntrl, COALESCE(invcnt_location_id, -1) AS itemsite_location_id, CASE WHEN (itemsite_costmethod = 'N') THEN 0 WHEN ( (itemsite_costmethod = 'A') AND (itemsite_qtyonhand = 0) AND (pAvgCostingMethod = 'ACT') ) THEN actcost(itemsite_item_id) WHEN ( (itemsite_costmethod = 'A') AND (pAvgCostingMethod IN ('ACT', 'AVG')) ) THEN avgcost(itemsite_id) ELSE stdcost(itemsite_item_id) END AS cost, itemsite_costmethod, itemsite_controlmethod, itemsite_value INTO _p FROM invcnt, itemsite, item WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (invcnt_qoh_after IS NOT NULL) AND (NOT invcnt_posted) AND (invcnt_id=pInvcntid) ); IF (NOT FOUND) THEN RETURN -9; END IF; SELECT COALESCE(SUM(itemloc_qty),0.0), location_netable INTO _origLocQty,_netable FROM itemloc,location WHERE ((itemloc_itemsite_id=_p.itemsite_id) AND (location_id=itemloc_location_id) AND (itemloc_location_id=_p.invcnt_location_id)) GROUP BY location_netable; IF (NOT FOUND) THEN _origLocQty := 0.0; _netable := TRUE; END IF; SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid; IF (_p.itemsite_freeze) THEN _postDate := _p.invcnt_tagdate; ELSE _postDate := CURRENT_TIMESTAMP; END IF; _hasDetail = FALSE; -- Post the detail indicated by cntslips IF ( (_p.itemsite_loccntrl) OR (_p.itemsite_controlmethod IN ('L', 'S')) ) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; -- Adjust any existing detail to 0 FOR _itemloc IN SELECT itemloc_id, itemloc_location_id, itemloc_ls_id, itemloc_qty FROM itemloc WHERE ((itemloc_itemsite_id=_p.itemsite_id) AND (itemloc_location_id=_p.invcnt_location_id)) LOOP _hasDetail = TRUE; -- Create the itemlocdist flushing records INSERT INTO itemlocdist ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_expiration, itemlocdist_itemsite_id, itemlocdist_invhist_id, itemlocdist_flush ) VALUES ( _itemlocSeries, 'I', _itemloc.itemloc_id, endOfTime(), _p.itemsite_id, _invhistid, TRUE ); END LOOP; -- Clear the running detail Qty _runningQty := 0; -- Adjust the detail to the cntslip indicated value FOR _cntslip IN SELECT cntslip_location_id, cntslip_lotserial, cntslip_lotserial_expiration, cntslip_lotserial_warrpurc, SUM(cntslip_qty) AS qty, itemsite_item_id FROM cntslip,invcnt,itemsite WHERE ((cntslip_cnttag_id=pInvcntid) AND (cntslip_cnttag_id=invcnt_id) AND (invcnt_itemsite_id=itemsite_id)) GROUP BY cntslip_location_id, cntslip_lotserial, cntslip_lotserial_expiration, cntslip_lotserial_warrpurc, itemsite_item_id LOOP -- Handle the LotSerial IF (LENGTH(_cntslip.cntslip_lotserial)>0) THEN SELECT ls_id INTO _lsid FROM ls WHERE ((ls_item_id=_cntslip.itemsite_item_id) AND (UPPER(ls_number)=UPPER(_cntslip.cntslip_lotserial))); IF (NOT FOUND) THEN _lsid := NEXTVAL('ls_ls_id_seq'); INSERT INTO ls VALUES (_lsid,_cntslip.itemsite_item_id,UPPER(_cntslip.cntslip_lotserial)); END IF; END IF; -- Track the running Qty _runningQty := (_runningQty + _cntslip.qty); _hasDetail = TRUE; -- Create the itemlocdist populating record INSERT INTO itemlocdist ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_itemsite_id, itemlocdist_ls_id, itemlocdist_expiration, itemlocdist_warranty, itemlocdist_qty, itemlocdist_invhist_id ) VALUES ( _itemlocSeries, 'L', _cntslip.cntslip_location_id, _p.itemsite_id, _lsid, COALESCE(_cntslip.cntslip_lotserial_expiration, endOfTime()), _cntslip.cntslip_lotserial_warrpurc, _cntslip.qty, _invhistid ); END LOOP; IF (_runningQty > _p.invcnt_qoh_after) THEN -- The total Count Slip Qty is greater than the Count Tag Qty, -- Don't post the Count. _errorCode = -1; ELSIF ( (_runningQty < _p.invcnt_qoh_after) AND (_p.itemsite_controlmethod IN ('L', 'S')) ) THEN -- The total Count Slip Qty is less than the Count Tag Qty, -- and the Item Site is Lot/Serial controlled. -- Don't post the Count. _errorCode = -2; ELSIF (_runningQty < _p.invcnt_qoh_after) THEN IF ( (NOT _p.itemsite_loccntrl) OR (_p.itemsite_location_id = -1) ) THEN -- The total Count Slip Qty is less than the Count Tag Qty, -- and there isn't a default location to post into. -- Don't post the Count. _errorCode = -3; ELSIF ( SELECT (metric_value='f') FROM metric WHERE (metric_name='PostCountTagToDefault') ) THEN -- The total Count Slip Qty is less than the Count Tag Qty, -- and we don't post Count Tags to default Locations -- Don't post the Count. _errorCode = -4; ELSE -- Distribute the remaining qty into the default location. INSERT INTO itemlocdist ( itemlocdist_series, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_itemsite_id, itemlocdist_ls_id, itemlocdist_expiration, itemlocdist_qty, itemlocdist_invhist_id ) SELECT _itemlocSeries, 'L', _p.itemsite_location_id, _p.itemsite_id, _lsid, endOfTime(), (_p.invcnt_qoh_after - _runningQty), _invhistid; _hasDetail = TRUE; _errorCode = 0; END IF; ELSE -- The Count Slip Qty. must equal the Count Tag Qty. _errorCode = 0; END IF; -- If we shouldn't post the count then delete the itemlocdist records, -- and return with the error. IF (_errorCode <> 0) THEN DELETE FROM itemlocdist WHERE (itemlocdist_series=_itemlocSeries); RETURN _errorCode; END IF; END IF; -- Mod. the Count Tag. UPDATE invcnt SET invcnt_qoh_before=_origLocQty, invcnt_postdate=_postDate, invcnt_posted=TRUE, invcnt_invhist_id=_invhistid, invcnt_post_username=CURRENT_USER WHERE (invcnt_id=pInvcntid); -- Create the CC transaction INSERT INTO invhist ( invhist_id, invhist_itemsite_id, invhist_transdate, invhist_transtype, invhist_invqty, invhist_qoh_before, invhist_qoh_after, invhist_docnumber, invhist_comments, invhist_invuom, invhist_unitcost, invhist_hasdetail, invhist_costmethod, invhist_value_before, invhist_value_after, invhist_series ) SELECT _invhistid, itemsite_id, _postDate, 'CC', (invcnt_qoh_after - invcnt_qoh_before), invcnt_qoh_before, invcnt_qoh_after, invcnt_tagnumber, invcnt_comments, uom_name, _p.cost, _hasDetail, _p.itemsite_costmethod, _p.itemsite_value, _p.itemsite_value + (_p.cost * (invcnt_qoh_after - invcnt_qoh_before)), _itemlocSeries FROM itemsite, invcnt, item, uom WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (itemsite_controlmethod <> 'N') AND (invcnt_id=pInvcntid) ); -- Update the QOH IF (_netable) THEN UPDATE itemsite SET itemsite_qtyonhand= itemsite_qtyonhand + (_p.invcnt_qoh_after - _origLocQty), itemsite_datelastcount=_postDate WHERE (itemsite_id=_p.itemsite_id); ELSE UPDATE itemsite SET itemsite_nnqoh = itemsite_nnqoh - _origLocQty, itemsite_qtyonhand = itemsite_qtyonhand + _p.invcnt_qoh_after, itemsite_datelastcount=_postDate WHERE (itemsite_id=_p.itemsite_id); END IF; -- Post the detail, if any IF (_hasDetail) THEN PERFORM distributeItemlocSeries(_itemlocSeries); END IF; -- Thaw the itemsite if it's frozen IF (pThaw) THEN PERFORM thawItemSite(invcnt_itemsite_id) FROM invcnt WHERE (invcnt_id=pInvcntid); END IF; -- Distribute to G/L PERFORM insertGLTransaction( 'I/M', 'CT', _p.invcnt_tagnumber, ('Post Count Tag #' || _p.invcnt_tagnumber || ' for Item ' || _p.item_number), costcat_adjustment_accnt_id, costcat_asset_accnt_id, _invhistid, ( (_p.invcnt_qoh_after - _origLocQty) * _p.cost), CURRENT_DATE ) FROM invcnt, itemsite, costcat WHERE ( (invcnt_itemsite_id=itemsite_id) AND (itemsite_costcat_id=costcat_id) AND (invcnt_id=pInvcntid) ); RETURN 0; END; $_$; CDROP FUNCTION public.postcounttaglocation(integer, boolean, text); publicadminfalse84623U125579137postcounttags(integer, boolean)FUNCTIONNCREATE FUNCTION postcounttags(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pThaw ALIAS FOR $2; _invcnt RECORD; _result INTEGER := 0; _return INTEGER := 0; BEGIN FOR _invcnt IN SELECT invcnt_id FROM invcnt, itemsite WHERE ( (invcnt_itemsite_id=itemsite_id) AND ( (pWarehousid=-1) OR (itemsite_warehous_id=pWarehousid) ) AND (invcnt_qoh_after IS NOT NULL) AND (NOT invcnt_posted) ) LOOP SELECT postCountTag(_invcnt.invcnt_id, pThaw) INTO _result; IF (_result < _return) THEN _return := _result; END IF; END LOOP; RETURN _return; END; $_$; 6DROP FUNCTION public.postcounttags(integer, boolean); publicadminfalse84623V125579138 postcreditmemo(integer, integer)FUNCTIONCREATE FUNCTION postcreditmemo(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmheadid ALIAS FOR $1; pItemlocSeries ALIAS FOR $2; _return INTEGER; BEGIN SELECT postCreditMemo(pCmheadid, fetchJournalNumber('AR-CM'), pItemlocSeries) INTO _return; RETURN _return; END; $_$; 7DROP FUNCTION public.postcreditmemo(integer, integer); publicadminfalse84623W125579139)postcreditmemo(integer, integer, integer)FUNCTIONUCREATE FUNCTION postcreditmemo(integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmheadid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pItemlocSeries ALIAS FOR $3; _r RECORD; _p RECORD; _aropenid INTEGER; _cohistid INTEGER; _sequence INTEGER; _itemlocSeries INTEGER; _invhistid INTEGER; _test INTEGER; _totalAmount NUMERIC := 0; _commissionDue NUMERIC := 0; _toApply NUMERIC; _toClose BOOLEAN; _glDate DATE; _taxBaseValue NUMERIC := 0; BEGIN -- Cache some parameters SELECT cmhead.*, findARAccount(cmhead_cust_id) AS ar_accnt_id, ( SELECT COALESCE(SUM(taxhist_tax), 0) FROM cmheadtax WHERE ( (taxhist_parent_id = cmhead_id) AND (taxhist_taxtype_id = getAdjustmentTaxtypeId()) ) ) AS adjtax INTO _p FROM cmhead WHERE (cmhead_id=pCmheadid); IF (_p.cmhead_posted) THEN RETURN -10; END IF; IF (_p.cmhead_hold) THEN RETURN -11; END IF; _glDate := COALESCE(_p.cmhead_gldistdate, _p.cmhead_docdate); _itemlocSeries = pItemlocSeries; SELECT fetchGLSequence() INTO _sequence; -- Start by handling taxes FOR _r IN SELECT tax_sales_accnt_id, round(sum(taxdetail_tax),2) AS tax, currToBase(_p.cmhead_curr_id, round(sum(taxdetail_tax),2), _p.cmhead_docdate) AS taxbasevalue FROM tax JOIN calculateTaxDetailSummary('CM', pCmheadid, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id, tax_sales_accnt_id LOOP PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CM', _p.cmhead_number, _r.tax_sales_accnt_id, _r.taxbasevalue, _glDate, _p.cmhead_billtoname ); _totalAmount := _totalAmount + _r.tax * -1; END LOOP; -- Update item tax records with posting data UPDATE cmitemtax SET taxhist_docdate=_p.cmhead_docdate, taxhist_distdate=_glDate, taxhist_curr_id=_p.cmhead_curr_id, taxhist_curr_rate=curr_rate, taxhist_journalnumber=pJournalNumber FROM cmhead JOIN cmitem ON (cmhead_id=cmitem_cmhead_id), curr_rate WHERE ((cmhead_id=pCmheadId) AND (taxhist_parent_id=cmitem_id) AND (_p.cmhead_curr_id=curr_id) AND (_p.cmhead_docdate BETWEEN curr_effective AND curr_expires) ); -- Update Header taxes (Freight and Adjustments) with posting data UPDATE cmheadtax SET taxhist_docdate=_p.cmhead_docdate, taxhist_distdate=_glDate, taxhist_curr_id=_p.cmhead_curr_id, taxhist_curr_rate=curr_rate, taxhist_journalnumber=pJournalNumber FROM curr_rate WHERE ((taxhist_parent_id=pCmheadId) AND (_p.cmhead_curr_id=curr_id) AND (_p.cmhead_docdate BETWEEN curr_effective AND curr_expires) ); -- Process line items -- Always use std cost FOR _r IN SELECT *, stdCost(item_id) AS std_cost FROM creditmemoitem WHERE ( (cmitem_cmhead_id=pCmheadid) AND (cmitem_qtycredit <> 0 ) ) LOOP -- Calcuate the Commission to be debited _commissionDue := (_commissionDue + (_r.extprice * _p.cmhead_commission)); IF (_r.extprice <> 0) THEN -- Debit the Sales Account for the current cmitem SELECT insertIntoGLSeries( _sequence, 'A/R', 'CM', _p.cmhead_number, CASE WHEN _p.cmhead_rahead_id IS NULL THEN getPrjAccntId(_p.cmhead_prj_id, salesaccnt_credit_accnt_id) ELSE getPrjAccntId(_p.cmhead_prj_id, salesaccnt_returns_accnt_id) END, round(currToBase(_p.cmhead_curr_id, _r.extprice * -1, _p.cmhead_docdate), 2), _glDate, _p.cmhead_billtoname) INTO _test FROM salesaccnt WHERE (salesaccnt_id=findSalesAccnt(_r.cmitem_itemsite_id, 'IS', _p.cmhead_cust_id, _p.cmhead_saletype_id, _p.cmhead_shipzone_id)); IF (NOT FOUND) THEN PERFORM deleteGLSeries(_sequence); RETURN -12; END IF; END IF; -- Record Sales History for this C/M Item SELECT nextval('cohist_cohist_id_seq') INTO _cohistid; INSERT INTO cohist ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_curr_id, cohist_taxtype_id, cohist_taxzone_id, cohist_shipzone_id, cohist_saletype_id ) VALUES ( _cohistid, _p.cmhead_cust_id, _r.cmitem_itemsite_id, _p.cmhead_shipto_id, _p.cmhead_docdate, '', _p.cmhead_number, _p.cmhead_custponumber, _p.cmhead_docdate, 'C', _p.cmhead_invcnumber, _p.cmhead_docdate, (_r.qty * -1), _r.unitprice, _r.std_cost, _p.cmhead_salesrep_id, (_p.cmhead_commission * _r.extprice * -1), FALSE, _p.cmhead_billtoname, _p.cmhead_billtoaddress1, _p.cmhead_billtoaddress2, _p.cmhead_billtoaddress3, _p.cmhead_billtocity, _p.cmhead_billtostate, _p.cmhead_billtozip, _p.cmhead_shipto_name, _p.cmhead_shipto_address1, _p.cmhead_shipto_address2, _p.cmhead_shipto_address3, _p.cmhead_shipto_city, _p.cmhead_shipto_state, _p.cmhead_shipto_zipcode, _p.cmhead_curr_id, _r.cmitem_taxtype_id, _p.cmhead_taxzone_id, _p.cmhead_shipzone_id, _p.cmhead_saletype_id ); INSERT INTO cohisttax ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM cmitemtax WHERE (taxhist_parent_id=_r.cmitem_id); _totalAmount := _totalAmount + round(_r.extprice, 2); END LOOP; -- Credit the Misc. Account for Miscellaneous Charges IF (_p.cmhead_misc <> 0) THEN SELECT insertIntoGLSeries( _sequence, 'A/R', 'CM', _p.cmhead_number, getPrjAccntId(_p.cmhead_prj_id, accnt_id), round(currToBase(_p.cmhead_curr_id, _p.cmhead_misc * -1, _p.cmhead_docdate), 2), _glDate, _p.cmhead_billtoname) INTO _test FROM accnt WHERE (accnt_id=_p.cmhead_misc_accnt_id); -- If the Misc. Charges Account was not found then punt IF (NOT FOUND) THEN PERFORM deleteGLSeries(_sequence); RETURN -14; END IF; -- Record the Sales History for any Misc. Charge INSERT INTO cohist ( cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_misc_type, cohist_misc_descrip, cohist_misc_id, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_curr_id, cohist_shipzone_id, cohist_saletype_id ) VALUES ( _p.cmhead_cust_id, -1, _p.cmhead_shipto_id, 'M', _p.cmhead_misc_descrip, _p.cmhead_misc_accnt_id, _p.cmhead_docdate, '', _p.cmhead_number, _p.cmhead_custponumber, _p.cmhead_docdate, 'C', _p.cmhead_invcnumber, _p.cmhead_docdate, 1, (_p.cmhead_misc * -1), (_p.cmhead_misc * -1), _p.cmhead_salesrep_id, 0, FALSE, _p.cmhead_billtoname, _p.cmhead_billtoaddress1, _p.cmhead_billtoaddress2, _p.cmhead_billtoaddress3, _p.cmhead_billtocity, _p.cmhead_billtostate, _p.cmhead_billtozip, _p.cmhead_shipto_name, _p.cmhead_shipto_address1, _p.cmhead_shipto_address2, _p.cmhead_shipto_address3, _p.cmhead_shipto_city, _p.cmhead_shipto_state, _p.cmhead_shipto_zipcode, _p.cmhead_curr_id, _p.cmhead_shipzone_id, _p.cmhead_saletype_id ); -- Cache the Misc. Amount distributed _totalAmount := _totalAmount + _p.cmhead_misc; END IF; -- Credit Tax Adjustments IF (_p.adjtax <> 0) THEN -- Record the Sales History for Tax Adjustment SELECT nextval('cohist_cohist_id_seq') INTO _cohistid; INSERT INTO cohist ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_misc_type, cohist_misc_descrip, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_curr_id, cohist_taxtype_id, cohist_taxzone_id, cohist_shipzone_id, cohist_saletype_id ) VALUES ( _cohistid, _p.cmhead_cust_id, -1, _p.cmhead_shipto_id, 'T', 'Misc Tax Adjustment', _p.cmhead_docdate, '', _p.cmhead_number, _p.cmhead_custponumber, _p.cmhead_docdate, 'C', _p.cmhead_invcnumber, _p.cmhead_docdate, 0, 0, 0, _p.cmhead_salesrep_id, 0, FALSE, _p.cmhead_billtoname, _p.cmhead_billtoaddress1, _p.cmhead_billtoaddress2, _p.cmhead_billtoaddress3, _p.cmhead_billtocity, _p.cmhead_billtostate, _p.cmhead_billtozip, _p.cmhead_shipto_name, _p.cmhead_shipto_address1, _p.cmhead_shipto_address2, _p.cmhead_shipto_address3, _p.cmhead_shipto_city, _p.cmhead_shipto_state, _p.cmhead_shipto_zipcode, _p.cmhead_curr_id, getAdjustmentTaxtypeId(), _p.cmhead_taxzone_id, _p.cmhead_shipzone_id, _p.cmhead_saletype_id ); INSERT INTO cohisttax ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id, (taxhist_basis * -1), taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM cmheadtax WHERE ( (taxhist_parent_id=_p.cmhead_id) AND (taxhist_taxtype_id=getAdjustmentTaxtypeId()) ); END IF; -- Debit the Freight Account IF (_p.cmhead_freight <> 0) THEN SELECT insertIntoGLSeries( _sequence, 'A/R', 'CM', _p.cmhead_number, getPrjAccntId(_p.cmhead_prj_id, accnt_id), round(currToBase(_p.cmhead_curr_id, _p.cmhead_freight * -1, _p.cmhead_docdate), 2), _glDate, _p.cmhead_billtoname) INTO _test FROM accnt WHERE (accnt_id=findFreightAccount(_p.cmhead_cust_id)); -- If the Freight Charges Account was not found then punt IF (NOT FOUND) THEN PERFORM deleteGLSeries(_sequence); RETURN -16; END IF; -- Cache the Amount Distributed to Freight _totalAmount := _totalAmount + _p.cmhead_freight; -- Record the Sales History for any Freight SELECT nextval('cohist_cohist_id_seq') INTO _cohistid; INSERT INTO cohist ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_misc_type, cohist_misc_descrip, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_curr_id, cohist_taxtype_id, cohist_taxzone_id, cohist_shipzone_id, cohist_saletype_id ) VALUES ( _cohistid, _p.cmhead_cust_id, -1, _p.cmhead_shipto_id, 'F', 'Freight Charge', _p.cmhead_docdate, '', _p.cmhead_number, _p.cmhead_custponumber, _p.cmhead_docdate, 'C', _p.cmhead_invcnumber, _p.cmhead_docdate, 1, (_p.cmhead_freight * -1), (_p.cmhead_freight * -1), _p.cmhead_salesrep_id, 0, FALSE, _p.cmhead_billtoname, _p.cmhead_billtoaddress1, _p.cmhead_billtoaddress2, _p.cmhead_billtoaddress3, _p.cmhead_billtocity, _p.cmhead_billtostate, _p.cmhead_billtozip, _p.cmhead_shipto_name, _p.cmhead_shipto_address1, _p.cmhead_shipto_address2, _p.cmhead_shipto_address3, _p.cmhead_shipto_city, _p.cmhead_shipto_state, _p.cmhead_shipto_zipcode, _p.cmhead_curr_id, getFreightTaxtypeId(), _p.cmhead_taxzone_id, _p.cmhead_shipzone_id, _p.cmhead_saletype_id ); INSERT INTO cohisttax ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id, (taxhist_basis * -1), taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM cmheadtax WHERE ( (taxhist_parent_id=_p.cmhead_id) AND (taxhist_taxtype_id=getFreightTaxtypeId()) ); END IF; _totalAmount := _totalAmount; -- Credit the A/R for the total Amount IF (_totalAmount <> 0) THEN IF (_p.ar_accnt_id != -1) THEN PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CM', _p.cmhead_number, _p.ar_accnt_id, round(currToBase(_p.cmhead_curr_id, _totalAmount, _p.cmhead_docdate), 2), _glDate, _p.cmhead_billtoname); ELSE PERFORM deleteGLSeries(_sequence); RETURN -18; END IF; END IF; -- Commit the GLSeries; PERFORM postGLSeries(_sequence, pJournalNumber); -- Create the Invoice aropen item SELECT NEXTVAL('aropen_aropen_id_seq') INTO _aropenid; INSERT INTO aropen ( aropen_id, aropen_username, aropen_journalnumber, aropen_open, aropen_posted, aropen_cust_id, aropen_ponumber, aropen_docnumber, aropen_applyto, aropen_doctype, aropen_docdate, aropen_duedate, aropen_distdate, aropen_terms_id, aropen_amount, aropen_paid, aropen_salesrep_id, aropen_commission_due, aropen_commission_paid, aropen_ordernumber, aropen_notes, aropen_rsncode_id, aropen_curr_id ) SELECT _aropenid, getEffectiveXtUser(), pJournalNumber, TRUE, FALSE, cmhead_cust_id, cmhead_custponumber, cmhead_number, CASE WHEN (cmhead_invcnumber='-1') THEN 'OPEN' ELSE (cmhead_invcnumber::TEXT) END, 'C', cmhead_docdate, cmhead_docdate, _glDate, -1, _totalAmount, 0, cmhead_salesrep_id, (_commissionDue * -1), FALSE, cmhead_number::TEXT, cmhead_comments, cmhead_rsncode_id, cmhead_curr_id FROM cmhead WHERE (cmhead_id=pCmheadid); -- Handle the Inventory and G/L Transactions for any returned Inventory where cmitem_updateinv is true FOR _r IN SELECT itemsite_id, itemsite_costmethod, item_number, stdCost(item_id) AS std_cost, costcat_asset_accnt_id, SUM(cmitem_qtyreturned * cmitem_qty_invuomratio) AS qty FROM cmhead JOIN cmitem ON (cmitem_cmhead_id=cmhead_id) JOIN itemsite ON (itemsite_id=cmitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) JOIN costcat ON (costcat_id=itemsite_costcat_id) WHERE ( (cmitem_qtyreturned <> 0) AND (cmitem_updateinv) AND (cmhead_id=pCmheadid) ) GROUP BY itemsite_id, itemsite_costmethod, item_number, item_id, costcat_asset_accnt_id LOOP -- Return credited stock to inventory IF (_itemlocSeries = 0) THEN _itemlocSeries := NEXTVAL('itemloc_series_seq'); END IF; IF (_r.itemsite_costmethod != 'J') THEN SELECT postInvTrans(_r.itemsite_id, 'RS', _r.qty, 'S/O', 'CM', _p.cmhead_number, '', ('Credit Return ' || _r.item_number), _r.costcat_asset_accnt_id, getPrjAccntId(_p.cmhead_prj_id, resolveCOSAccount(_r.itemsite_id, _p.cmhead_cust_id, _p.cmhead_saletype_id, _p.cmhead_shipzone_id)), _itemlocSeries, _glDate, (_r.std_cost * _r.qty)) INTO _invhistid; ELSE RAISE DEBUG 'postCreditMemo(%, %, %) tried to postInvTrans a %-costed item', pCmheadid, pJournalNumber, pItemlocSeries, _r.itemsite_costmethod; END IF; END LOOP; -- Update coitem to reflect the returned qty where cmitem_updateinv is true FOR _r IN SELECT cmitem_qtyreturned, cmitem_itemsite_id, cohead_id FROM cmitem, cmhead, invchead, cohead WHERE ( (cmitem_cmhead_id=cmhead_id) AND (cmhead_invcnumber=invchead_invcnumber) AND (invchead_ordernumber=cohead_number) AND (cmitem_qtyreturned <> 0) AND (cmitem_updateinv) AND (cmhead_id=pCmheadid) ) LOOP UPDATE coitem SET coitem_qtyreturned = (coitem_qtyreturned + _r.cmitem_qtyreturned) WHERE coitem_id IN ( SELECT coitem_id FROM coitem WHERE ( (coitem_cohead_id=_r.cohead_id) AND (coitem_itemsite_id = _r.cmitem_itemsite_id) ) LIMIT 1 ); END LOOP; -- Mark the cmhead as posted UPDATE cmhead SET cmhead_posted=TRUE, cmhead_gldistdate=_glDate WHERE (cmhead_id=pCmheadid); -- Find the apply-to document and make the application SELECT cmhead_number, cmhead_curr_id, cmhead_docdate, aropen_id, aropen_cust_id, aropen_docnumber, currToCurr(aropen_curr_id, cmhead_curr_id, aropen_amount - aropen_paid, cmhead_docdate) AS balance INTO _p FROM aropen, cmhead WHERE ( (aropen_doctype='I') AND (aropen_docnumber=cmhead_invcnumber) AND (cmhead_id=pCmheadid) ); IF (FOUND) THEN IF round(_totalAmount, 2) <= round(_p.balance, 2) THEN _toApply = _totalAmount; ELSE _toApply = _p.balance; END IF; UPDATE aropen SET aropen_paid = round(aropen_paid + currToCurr(_p.cmhead_curr_id, aropen_curr_id, _toApply, _p.cmhead_docdate), 2) WHERE (aropen_id=_p.aropen_id); -- Alter the new A/R Open Item to reflect the application UPDATE aropen SET aropen_paid = round(currToCurr(_p.cmhead_curr_id, aropen_curr_id, _toApply, _p.cmhead_docdate), 2) WHERE (aropen_id=_aropenid); -- Record the application INSERT INTO arapply ( arapply_cust_id, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_applied, arapply_closed, arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_curr_id ) VALUES ( _p.aropen_cust_id, _aropenid, 'C', _p.cmhead_number, _p.aropen_id, 'I', _p.aropen_docnumber, '', '', round(_toApply, 2), _toClose, CURRENT_DATE, _p.cmhead_docdate, 0, _p.cmhead_curr_id ); END IF; RETURN _itemlocSeries; END; $_$; @DROP FUNCTION public.postcreditmemo(integer, integer, integer); publicadminfalse84623X125579141postcreditmemos(boolean)FUNCTION]CREATE FUNCTION postcreditmemos(boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPostUnprinted ALIAS FOR $1; _cmhead RECORD; _result INTEGER; _return INTEGER := 0; _itemlocSeries INTEGER := 0; BEGIN _itemlocSeries := 0; FOR _cmhead IN SELECT cmhead_id FROM cmhead WHERE ( (NOT cmhead_posted) AND (NOT cmhead_hold) AND (checkCreditMemoSitePrivs(cmhead_id)) AND ((pPostUnprinted) OR (cmhead_printed)) ) LOOP SELECT postCreditMemo(_cmhead.cmhead_id, _itemlocSeries) INTO _result; IF (_result < _return) THEN _return := _result; END IF; END LOOP; RETURN _return; END; $_$; /DROP FUNCTION public.postcreditmemos(boolean); publicadminfalse84623Y125579142!postcreditmemos(boolean, integer)FUNCTIONCREATE FUNCTION postcreditmemos(boolean, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPostUnprinted ALIAS FOR $1; pJournalNumber ALIAS FOR $2; _r RECORD; _itemlocSeries INTEGER := 0; BEGIN _itemlocSeries := 0; FOR _r IN SELECT cmhead_id FROM cmhead WHERE ( (NOT cmhead_posted) AND (NOT cmhead_hold) AND (checkCreditMemoSitePrivs(cmhead_id)) AND ((pPostUnprinted) OR (cmhead_printed)) ) LOOP SELECT postCreditMemo(_r.cmhead_id, pJournalNumber, _itemlocSeries) INTO _itemlocSeries; END LOOP; RETURN _itemlocSeries; END; $_$; 8DROP FUNCTION public.postcreditmemos(boolean, integer); publicadminfalse46238125579143Kpostevent(text, text, integer, integer, text, numeric, numeric, date, date)FUNCTION2CREATE FUNCTION postevent(pevnttypename text, pordtype text, pordid integer, pwhsid integer, pnumber text, pnewvalue numeric, poldvalue numeric, pnewdate date, polddate date) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _evnttypeid INTEGER; _whsid INTEGER; BEGIN -- Find event type SELECT evnttype_id INTO _evnttypeid FROM evnttype WHERE (evnttype_name=pEvnttypename); IF (NOT FOUND) THEN RAISE EXCEPTION 'Event type % not found.', pEvnttypename; END IF; IF (pWhsid IS NULL) THEN -- Find user preferred warehouse SELECT usrpref_value INTO _whsid FROM usrpref WHERE usrpref_username = getEffectiveXtUser() AND usrpref_name = 'PreferredWarehouse'; ELSE _whsid := pWhsid; END IF; INSERT INTO evntlog ( evntlog_evnttime, evntlog_evnttype_id, evntlog_ordtype, evntlog_ord_id, evntlog_warehous_id, evntlog_number, evntlog_newvalue, evntlog_oldvalue, evntlog_newdate, evntlog_olddate, evntlog_username ) SELECT CURRENT_TIMESTAMP, evnttype_id, pOrdtype, pOrdid, _whsid, pNumber, pNewValue, pOldValue, pNewDate, pOldDate, evntnot_username FROM evnttype JOIN evntnot ON ( (evntnot_evnttype_id=evnttype_id) AND (evntnot_warehous_id=_whsid) ) WHERE (evnttype_id=_evnttypeid); RETURN 0; END $$; DROP FUNCTION public.postevent(pevnttypename text, pordtype text, pordid integer, pwhsid integer, pnumber text, pnewvalue numeric, poldvalue numeric, pnewdate date, polddate date); publicadminfalse84623Z125579144postglseries(integer)FUNCTIONCREATE FUNCTION postglseries(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; _journalNumber INTEGER; _returnValue INTEGER; BEGIN SELECT postGLSeries(pSequence, fetchJournalNumber('G/L')) INTO _returnValue; RETURN _returnValue; END; $_$; ,DROP FUNCTION public.postglseries(integer); publicadminfalse46238[125579145postglseries(integer, integer)FUNCTIONCREATE FUNCTION postglseries(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; pJournalNumber ALIAS FOR $2; _returnValue INTEGER; BEGIN SELECT postGLSeries(pSequence, pJournalNumber, true) INTO _returnValue; RETURN _returnValue; END; $_$; 5DROP FUNCTION public.postglseries(integer, integer); publicadminfalse84623\125579146'postglseries(integer, integer, boolean)FUNCTIONCCREATE FUNCTION postglseries(integer, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pPostZero ALIAS FOR $3; _glseries RECORD; _transCount INTEGER := 0; _delta NUMERIC; _discrepDate DATE; _discrepAccntid INTEGER; _rows INTEGER; BEGIN /* Make sure we don't create an imbalance across companies. The 'IgnoreCompanyBalance' metric is a back door mechanism to allow legacy users to create transactions accross companies if they have been using the company segment for something else and they MUST continue to be able to do so. It can only be implemented by direct sql update to the metric table and should otherwise be discouraged. */ IF (COALESCE(fetchMetricValue('GLCompanySize'),0) > 0 AND fetchMetricBool('IgnoreCompany') = false) THEN SELECT count(accnt_company) INTO _rows FROM ( SELECT DISTINCT accnt_company FROM accnt JOIN glseries ON (glseries_accnt_id=accnt_id) WHERE (glseries_sequence=pSequence)) _data; IF (_rows > 1) THEN RAISE EXCEPTION 'G/L Series can not be posted because multiple companies are referenced in the same series.'; END IF; END IF; -- Make sure that we balance SELECT SUM(glseries_amount), MAX(glseries_distdate) INTO _delta, _discrepDate FROM glseries WHERE (glseries_sequence=pSequence); IF ( _delta <> 0 ) THEN IF (COALESCE(fetchMetricValue('GLCompanySize'),0) = 0) THEN SELECT accnt_id INTO _discrepAccntid FROM accnt, metric WHERE ((metric_name='GLSeriesDiscrepancyAccount') AND (accnt_id=CAST(metric_value AS INTEGER))); ELSE SELECT company_dscrp_accnt_id INTO _discrepAccntid FROM company JOIN accnt ON (accnt_company=company_number) JOIN glseries ON (glseries_accnt_id=accnt_id) WHERE (glseries_sequence=pSequence) LIMIT 1; END IF; IF (NOT FOUND) THEN RETURN -5; END IF; INSERT INTO glseries ( glseries_sequence, glseries_source, glseries_doctype, glseries_docnumber, glseries_accnt_id, glseries_amount, glseries_distdate, glseries_notes ) SELECT glseries_sequence, glseries_source, glseries_doctype, glseries_docnumber, _discrepAccntid, (_delta * -1), _discrepDate, 'G/L Series Discrepancy' FROM glseries WHERE (glseries_sequence=pSequence) LIMIT 1; END IF; -- March through the glseries members, posting them one at a time FOR _glseries IN SELECT glseries_source, glseries_doctype, glseries_docnumber, glseries_accnt_id, glseries_distdate, glseries_notes, glseries_misc_id, SUM(glseries_amount) as amount FROM glseries WHERE ((glseries_amount<>0.0) AND (glseries_sequence=pSequence)) GROUP BY glseries_source, glseries_doctype, glseries_docnumber, glseries_accnt_id, glseries_distdate, glseries_notes, glseries_misc_id LOOP -- refuse to accept postings into closed periods IF (SELECT BOOL_AND(COALESCE(period_closed, FALSE)) FROM accnt LEFT OUTER JOIN period ON (_glseries.glseries_distdate BETWEEN period_start AND period_end) WHERE (accnt_id = _glseries.glseries_accnt_id)) THEN RAISE EXCEPTION 'Cannot post to closed period (%).', _glseries.glseries_distdate; RETURN -4; -- remove raise exception when all callers check return code END IF; -- refuse to accept postings into frozen periods without proper priv IF (SELECT NOT BOOL_AND(checkPrivilege('PostFrozenPeriod')) AND BOOL_AND(COALESCE(period_freeze, FALSE)) FROM accnt LEFT OUTER JOIN period ON (_glseries.glseries_distdate BETWEEN period_start AND period_end) WHERE (accnt_id = _glseries.glseries_accnt_id)) THEN RAISE EXCEPTION 'Cannot post to frozen period (%).', _glseries.glseries_distdate; RETURN -4; -- remove raise exception when all callers check return code END IF; -- refuse to accept postings into nonexistent periods IF NOT EXISTS(SELECT period_id FROM period WHERE (_glseries.glseries_distdate BETWEEN period_start AND period_end)) THEN RAISE EXCEPTION 'Cannot post to nonexistent period (%).', pDistDate; END IF; IF (_glseries.amount != 0 OR pPostZero) THEN IF (fetchMetricBool('UseJournals')) THEN INSERT INTO sltrans ( sltrans_posted, sltrans_created, sltrans_date, sltrans_misc_id, sltrans_sequence, sltrans_accnt_id, sltrans_source, sltrans_notes, sltrans_doctype, sltrans_docnumber, sltrans_amount, sltrans_journalnumber ) VALUES ( FALSE, CURRENT_TIMESTAMP, _glseries.glseries_distdate, _glseries.glseries_misc_id, pSequence, _glseries.glseries_accnt_id, _glseries.glseries_source, _glseries.glseries_notes, _glseries.glseries_doctype, _glseries.glseries_docnumber, _glseries.amount, pJournalNumber ); ELSE INSERT INTO gltrans ( gltrans_posted, gltrans_exported, gltrans_created, gltrans_date, gltrans_misc_id, gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_notes, gltrans_doctype, gltrans_docnumber, gltrans_amount, gltrans_journalnumber ) VALUES ( FALSE, FALSE, CURRENT_TIMESTAMP, _glseries.glseries_distdate, _glseries.glseries_misc_id, pSequence, _glseries.glseries_accnt_id, _glseries.glseries_source, _glseries.glseries_notes, _glseries.glseries_doctype, _glseries.glseries_docnumber, _glseries.amount, pJournalNumber ); END IF; _transCount := _transCount + 1; END IF; END LOOP; -- Delete all of the posted glseries members DELETE FROM glseries WHERE (glseries_sequence=pSequence); PERFORM postIntoTrialBalance(pSequence); RETURN _transCount; END; $_$; >DROP FUNCTION public.postglseries(integer, integer, boolean); publicadminfalse46238]125579148postglseriesnosumm(integer)FUNCTIONCREATE FUNCTION postglseriesnosumm(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; _journalNumber INTEGER; _returnValue INTEGER; BEGIN SELECT postGLSeriesNoSumm(pSequence, fetchJournalNumber('G/L')) INTO _returnValue; RETURN _returnValue; END; $_$; 2DROP FUNCTION public.postglseriesnosumm(integer); publicadminfalse84623^125579149$postglseriesnosumm(integer, integer)FUNCTIONgCREATE FUNCTION postglseriesnosumm(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; pJournalNumber ALIAS FOR $2; _glseries RECORD; _transCount INTEGER := 0; _rows INTEGER; BEGIN /* Make sure we don't create an imbalance across companies. The 'IgnoreCompanyBalance' metric is a back door mechanism to allow legacy users to create transactions accross companies if they have been using the company segment for something else and they MUST continue to be able to do so. It can only be implemented by direct sql update to the metric table and should otherwise be discouraged. */ IF (COALESCE(fetchMetricValue('GLCompanySize'),0) > 0 AND fetchMetricBool('IgnoreCompany') = false) THEN SELECT count(accnt_company) INTO _rows FROM ( SELECT DISTINCT accnt_company FROM accnt JOIN glseries ON (glseries_accnt_id=accnt_id) WHERE (glseries_sequence=pSequence)) _data; IF (_rows > 1) THEN RAISE EXCEPTION 'G/L Series can not be posted because multiple companies are referenced in the same series.'; END IF; END IF; -- Make sure that we balance IF ( ( SELECT SUM(glseries_amount) FROM glseries WHERE (glseries_sequence=pSequence) ) <> 0 ) THEN RETURN -1; END IF; -- March through the glseries members, posting them one at a time FOR _glseries IN SELECT glseries_source, glseries_doctype, glseries_docnumber, glseries_accnt_id, glseries_distdate, glseries_notes, glseries_misc_id, glseries_amount as amount FROM glseries WHERE ((glseries_amount<>0.0) AND (glseries_sequence=pSequence)) LOOP -- refuse to accept postings into closed periods IF (SELECT BOOL_AND(COALESCE(period_closed, FALSE)) FROM accnt LEFT OUTER JOIN period ON (_glseries.glseries_distdate BETWEEN period_start AND period_end) WHERE (accnt_id = _glseries.glseries_accnt_id)) THEN RAISE EXCEPTION 'Cannot post to closed period (%).', _glseries.glseries_distdate; RETURN -4; -- remove raise exception when all callers check return code END IF; -- refuse to accept postings into frozen periods without proper priv IF (SELECT NOT BOOL_AND(checkPrivilege('PostFrozenPeriod')) AND BOOL_AND(COALESCE(period_freeze, FALSE)) FROM accnt LEFT OUTER JOIN period ON (_glseries.glseries_distdate BETWEEN period_start AND period_end) WHERE (accnt_id = _glseries.glseries_accnt_id)) THEN RAISE EXCEPTION 'Cannot post to frozen period (%).', _glseries.glseries_distdate; RETURN -4; -- remove raise exception when all callers check return code END IF; -- refuse to accept postings into nonexistent periods IF NOT EXISTS(SELECT period_id FROM period WHERE (_glseries.glseries_distdate BETWEEN period_start AND period_end)) THEN RAISE EXCEPTION 'Cannot post to nonexistent period (%).', pDistDate; END IF; IF (fetchMetricBool('UseJournals')) THEN INSERT INTO sltrans ( sltrans_posted, sltrans_created, sltrans_date, sltrans_misc_id, sltrans_sequence, sltrans_accnt_id, sltrans_source, sltrans_notes, sltrans_doctype, sltrans_docnumber, sltrans_amount, sltrans_journalnumber ) VALUES ( FALSE, CURRENT_TIMESTAMP, _glseries.glseries_distdate, _glseries.glseries_misc_id, pSequence, _glseries.glseries_accnt_id, _glseries.glseries_source, _glseries.glseries_notes, _glseries.glseries_doctype, _glseries.glseries_docnumber, _glseries.amount, pJournalNumber ); ELSE INSERT INTO gltrans ( gltrans_posted, gltrans_exported, gltrans_created, gltrans_date, gltrans_misc_id, gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_notes, gltrans_doctype, gltrans_docnumber, gltrans_amount, gltrans_journalnumber ) VALUES ( FALSE, FALSE, CURRENT_TIMESTAMP, _glseries.glseries_distdate, _glseries.glseries_misc_id, pSequence, _glseries.glseries_accnt_id, _glseries.glseries_source, _glseries.glseries_notes, _glseries.glseries_doctype, _glseries.glseries_docnumber, _glseries.amount, pJournalNumber ); END IF; _transCount := _transCount + 1; END LOOP; -- Delete all of the posted glseries members DELETE FROM glseries WHERE (glseries_sequence=pSequence); PERFORM postIntoTrialBalance(pSequence); RETURN _transCount; END; $_$; ;DROP FUNCTION public.postglseriesnosumm(integer, integer); publicadminfalse84623125579151postintoinvbalance(integer)FUNCTIONCREATE FUNCTION postintoinvbalance(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvhistId ALIAS FOR $1; _invbalid INTEGER; _r RECORD; _count INTEGER; _qty NUMERIC; BEGIN -- Grab the invhist record to post -- Special fix for transit sites when transtype=TS and invqty<0 -- Set the sense to 1 to correct invhist populated incorrectly. SELECT invhist.*, CASE WHEN (invhist_transtype='TS' AND invhist_invqty < 0.0 AND warehous_transit) THEN 1 ELSE invhistSense(invhist_id) END AS sense, period_id INTO _r FROM invhist JOIN itemsite ON (itemsite_id=invhist_itemsite_id) JOIN whsinfo ON (warehous_id=itemsite_warehous_id) LEFT OUTER JOIN period ON (invhist_transdate::date BETWEEN period_start AND period_end) WHERE ( invhist_id=pInvhistId ); GET DIAGNOSTICS _count = ROW_COUNT; -- If we can post into a Inv Balance, do so IF ( _count > 0 ) THEN -- Validate IF (_r.period_id IS NULL) THEN RAISE EXCEPTION 'No accounting period exists for invhist_id %, transaction date %. Transaction can not be posted.', _r.invhist_id, formatDate(_r.invhist_transdate); END IF; -- If cycle count, then we need to reference balance which needs to be accurate -- IF (_r.invhist_transtype = 'CC') THEN -- PERFORM forwardupdateitemsite(_r.invhist_itemsite_id); -- END IF; -- Try to find an existing invbal SELECT invbal_id, -- CASE WHEN (_r.invhist_transtype != 'CC') THEN _r.invhist_invqty ELSE _r.invhist_invqty - invbal_qoh_ending END _r.invhist_invqty INTO _invbalid, _qty FROM invbal WHERE ( (invbal_period_id=_r.period_id) AND (invbal_itemsite_id=_r.invhist_itemsite_id) ); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count > 0) THEN -- We found a invbal, update it with the Inventory Transaction -- Note - two stage update to avoid any funny value caching logic IF (_r.sense * _qty > 0) THEN UPDATE invbal SET invbal_qty_in = (invbal_qty_in + abs(_qty)), invbal_value_in = (invbal_value_in + abs(_qty) * _r.invhist_unitcost) WHERE (invbal_id=_invbalid); ELSIF (_r.sense * _qty < 0) THEN UPDATE invbal SET invbal_qty_out = (invbal_qty_out + abs(_qty)), invbal_value_out = (invbal_value_out + abs(_qty) * _r.invhist_unitcost) WHERE (invbal_id=_invbalid); END IF; -- Non-netable transactions have their own balances IF (_r.invhist_transtype = 'NN') THEN UPDATE invbal SET invbal_nn_in = (invbal_nn_in + _qty * -1), invbal_nnval_in = (invbal_nnval_in + _qty * -1 * _r.invhist_unitcost) WHERE (invbal_id=_invbalid); END IF; UPDATE invbal SET invbal_qoh_ending = (invbal_qoh_beginning + invbal_qty_in - invbal_qty_out), invbal_value_ending = (invbal_value_beginning + invbal_value_in - invbal_value_out), invbal_nn_ending = (invbal_nn_beginning + invbal_nn_in - invbal_nn_out), invbal_nnval_ending = (invbal_nnval_beginning + invbal_nnval_in - invbal_nnval_out), invbal_dirty=true WHERE (invbal_id=_invbalid); ELSE -- No existing invbal, make one SELECT NEXTVAL('invbal_invbal_id_seq') INTO _invbalid; INSERT INTO invbal ( invbal_id, invbal_itemsite_id, invbal_period_id, invbal_qoh_beginning, invbal_qoh_ending, invbal_qty_in, invbal_qty_out, invbal_value_beginning, invbal_value_ending, invbal_value_in, invbal_value_out, invbal_nn_beginning, invbal_nn_ending, invbal_nn_in, invbal_nn_out, invbal_nnval_beginning, invbal_nnval_ending, invbal_nnval_in, invbal_nnval_out, invbal_dirty ) VALUES ( _invbalid, _r.invhist_itemsite_id, _r.period_id, -- Netable 0, _r.invhist_invqty * _r.sense, CASE WHEN (_r.sense > 0) THEN _r.invhist_invqty ELSE 0 END, CASE WHEN (_r.sense < 0) THEN (_r.invhist_invqty) ELSE 0 END, 0, _r.invhist_invqty * _r.invhist_unitcost * _r.sense, CASE WHEN (_r.sense > 0) THEN _r.invhist_invqty * _r.invhist_unitcost ELSE 0 END, CASE WHEN (_r.sense < 0) THEN (_r.invhist_invqty * _r.invhist_unitcost) ELSE 0 END, -- Non netable 0, CASE WHEN (_r.invhist_transtype='NN') THEN _r.invhist_invqty * -1 ELSE 0 END, CASE WHEN (_r.sense > 0 AND _r.invhist_transtype='NN') THEN _r.invhist_invqty * -1 ELSE 0 END, CASE WHEN (_r.sense < 0 AND _r.invhist_transtype='NN') THEN _r.invhist_invqty * -1 ELSE 0 END, 0, CASE WHEN (_r.invhist_transtype='NN') THEN _r.invhist_invqty * _r.invhist_unitcost * -1 ELSE 0 END, CASE WHEN (_r.sense > 0 AND _r.invhist_transtype='NN') THEN _r.invhist_invqty * -1 * _r.invhist_unitcost ELSE 0 END, CASE WHEN (_r.sense < 0 AND _r.invhist_transtype='NN') THEN (_r.invhist_invqty * -1 * _r.invhist_unitcost) ELSE 0 END, true ); END IF; ELSE RETURN FALSE; END IF; RETURN TRUE; END; $_$; 2DROP FUNCTION public.postintoinvbalance(integer); publicadminfalse46238Q125579153postintotrialbalance(integer)FUNCTION CREATE FUNCTION postintotrialbalance(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; _trialbalid INTEGER; _r RECORD; BEGIN -- March through all of the G/L Transactions for the passed sequence that are not posted FOR _r IN SELECT gltrans_id, gltrans_date, gltrans_accnt_id, gltrans_amount, accnt_forwardupdate, period_id, period_closed, period_freeze FROM accnt, gltrans LEFT OUTER JOIN period ON (gltrans_date BETWEEN period_start AND period_end) WHERE ( (gltrans_accnt_id=accnt_id) AND (NOT gltrans_posted) AND (NOT gltrans_deleted) AND (gltrans_sequence=pSequence) ) LOOP -- If we can post into a Trial Balance, do so IF ( (NOT _r.period_closed) AND ( (NOT _r.period_freeze) OR (checkPrivilege('PostFrozenPeriod')) ) ) THEN -- Try to find an existing trialbal SELECT trialbal_id INTO _trialbalid FROM trialbal WHERE ( (trialbal_period_id=_r.period_id) AND (trialbal_accnt_id=_r.gltrans_accnt_id) ); IF (FOUND) THEN -- We found a trialbal, update it with the G/L Transaction -- Note - two stage update to avoid any funny value caching logic IF (_r.gltrans_amount > 0) THEN UPDATE trialbal SET trialbal_credits = (trialbal_credits + _r.gltrans_amount) WHERE (trialbal_id=_trialbalid); ELSE UPDATE trialbal SET trialbal_debits = (trialbal_debits + (_r.gltrans_amount * -1)) WHERE (trialbal_id=_trialbalid); END IF; UPDATE trialbal SET trialbal_ending = (trialbal_beginning - trialbal_debits + trialbal_credits), trialbal_dirty=TRUE WHERE (trialbal_id=_trialbalid); ELSE -- No existing trialbal, make one SELECT NEXTVAL('trialbal_trialbal_id_seq') INTO _trialbalid; INSERT INTO trialbal ( trialbal_id, trialbal_accnt_id, trialbal_period_id, trialbal_beginning, trialbal_dirty, trialbal_ending, trialbal_credits, trialbal_debits ) VALUES ( _trialbalid, _r.gltrans_accnt_id, _r.period_id, 0, TRUE, _r.gltrans_amount, CASE WHEN (_r.gltrans_amount > 0) THEN _r.gltrans_amount ELSE 0 END, CASE WHEN (_r.gltrans_amount < 0) THEN (_r.gltrans_amount * -1) ELSE 0 END ); END IF; -- Forward update if we should IF (_r.accnt_forwardupdate AND fetchmetricbool('ManualForwardUpdate')) THEN PERFORM forwardUpdateTrialBalance(_trialbalid); END IF; -- Mark the G/L Transaction as posted UPDATE gltrans SET gltrans_posted=TRUE WHERE (gltrans_id=_r.gltrans_id); END IF; END LOOP; RETURN 1; END; $_$; 4DROP FUNCTION public.postintotrialbalance(integer); publicadminfalse84623H125579154postinvhist(integer)FUNCTIONgCREATE FUNCTION postinvhist(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvhistId ALIAS FOR $1; _r RECORD; BEGIN IF ( SELECT metric_value FROM metric WHERE ((metric_name = 'EnableAsOfQOH') AND (metric_value = 't'))) THEN IF (NOT postIntoInvBalance(pInvhistId)) THEN RAISE EXCEPTION 'Post into Inventory Balance for invhist_id=% was unsuccessful',pInvhistId; END IF; END IF; --Update itemsite qoh and change posted flag UPDATE itemsite SET itemsite_qtyonhand = (itemsite_qtyonhand + (invhist_invqty * invhistSense(invhist_id))), itemsite_value = itemsite_value + invhist_value_after - invhist_value_before FROM invhist WHERE ( (itemsite_id=invhist_itemsite_id) AND (invhist_id=pInvhistId) AND (NOT invhist_posted) ); --Flag as posted UPDATE invhist SET invhist_posted=TRUE WHERE ( (invhist_id=pInvhistId) AND (invhist_posted=FALSE) ); RETURN TRUE; END; $_$; +DROP FUNCTION public.postinvhist(integer); publicadminfalse84623125579155postinvoice(integer)FUNCTION.CREATE FUNCTION postinvoice(pinvcheadid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN postInvoice(pInvcheadid, fetchJournalNumber('AR-IN')); END; $$; 7DROP FUNCTION public.postinvoice(pinvcheadid integer); publicadminfalse84623(125579156postinvoice(integer, integer)FUNCTIONCREATE FUNCTION postinvoice(pinvcheadid integer, pjournalnumber integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _itemlocSeries INTEGER; BEGIN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; RETURN postInvoice(pInvcheadid, pJournalNumber, _itemlocseries); END; $$; ODROP FUNCTION public.postinvoice(pinvcheadid integer, pjournalnumber integer); publicadminfalse46238)125579157&postinvoice(integer, integer, integer)FUNCTIONtCREATE FUNCTION postinvoice(pinvcheadid integer, pjournalnumber integer, pitemlocseries integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _aropenid INTEGER; _cohistid INTEGER; _itemlocSeries INTEGER := 0; _invhistid INTEGER := 0; _amount NUMERIC; _roundedBase NUMERIC; _sequence INTEGER; _r RECORD; _p RECORD; _test INTEGER; _totalAmount NUMERIC := 0; _totalRoundedBase NUMERIC := 0; _totalAmountBase NUMERIC := 0; _appliedAmount NUMERIC := 0; _commissionDue NUMERIC := 0; _tmpAccntId INTEGER; _tmpCurrId INTEGER; _firstExchDate DATE; _glDate DATE; _exchGain NUMERIC := 0; BEGIN IF ( ( SELECT invchead_posted FROM invchead WHERE (invchead_id=pInvcheadid) ) ) THEN RETURN -10; END IF; -- Cache some parameters SELECT invchead.*, fetchGLSequence() AS sequence, findFreightAccount(invchead_cust_id) AS freightaccntid, findARAccount(invchead_cust_id) AS araccntid, ( SELECT COALESCE(SUM(taxhist_tax), 0) FROM invcheadtax WHERE ( (taxhist_parent_id = invchead_id) AND (taxhist_taxtype_id = getFreightTaxtypeId()) ) ) AS freighttax, ( SELECT COALESCE(SUM(taxhist_tax), 0) FROM invcheadtax WHERE ( (taxhist_parent_id = invchead_id) AND (taxhist_taxtype_id = getAdjustmentTaxtypeId()) ) ) AS adjtax INTO _p FROM invchead WHERE (invchead_id=pInvcheadid); _itemlocSeries = pItemlocSeries; _glDate := COALESCE(_p.invchead_gldistdate, _p.invchead_invcdate); IF (_p.invchead_salesrep_id < 0) THEN RAISE WARNING 'Patch negative invchead_salesrep_id until invchead_salesrep_id is a true fkey'; _p.invchead_salesrep_id := NULL; END IF; -- the 1st MC iteration used the cohead_orderdate so we could get curr exch -- gain/loss between the sales and invoice dates, but see issue 3892. leave -- this condition TRUE until we make this configurable or decide not to. IF TRUE THEN _firstExchDate := _p.invchead_invcdate; ELSE -- can we save a select by using: _firstExchDate := _p.invchead_orderdate; SELECT cohead_orderdate INTO _firstExchDate FROM cohead JOIN invchead ON (cohead_number = invchead_ordernumber) WHERE (invchead_id = pInvcheadid); END IF; -- Start by handling taxes FOR _r IN SELECT tax_sales_accnt_id, round(sum(taxdetail_tax),2) AS tax, currToBase(_p.invchead_curr_id, round(sum(taxdetail_tax),2), _firstExchDate) AS taxbasevalue FROM tax JOIN calculateTaxDetailSummary('I', pInvcheadid, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id, tax_sales_accnt_id LOOP PERFORM insertIntoGLSeries( _p.sequence, 'A/R', 'IN', _p.invchead_invcnumber, _r.tax_sales_accnt_id, _r.taxbasevalue, _glDate, _p.invchead_billto_name ); _totalAmount := _totalAmount + _r.tax; _totalRoundedBase := _totalRoundedBase + _r.taxbasevalue; END LOOP; -- Update item tax records with posting data UPDATE invcitemtax SET taxhist_docdate=_firstExchDate, taxhist_distdate=_glDate, taxhist_curr_id=_p.invchead_curr_id, taxhist_curr_rate=curr_rate, taxhist_journalnumber=pJournalNumber FROM invchead JOIN invcitem ON (invchead_id=invcitem_invchead_id), curr_rate WHERE ((invchead_id=pInvcheadId) AND (taxhist_parent_id=invcitem_id) AND (_p.invchead_curr_id=curr_id) AND ( _firstExchDate BETWEEN curr_effective AND curr_expires) ); -- Update Invchead taxes (Freight and Adjustments) with posting data UPDATE invcheadtax SET taxhist_docdate=_firstExchDate, taxhist_distdate=_glDate, taxhist_curr_id=_p.invchead_curr_id, taxhist_curr_rate=curr_rate, taxhist_journalnumber=pJournalNumber FROM curr_rate WHERE ((taxhist_parent_id=pInvcheadid) AND (_p.invchead_curr_id=curr_id) AND ( _firstExchDate BETWEEN curr_effective AND curr_expires) ); -- March through the Non-Misc. Invcitems FOR _r IN SELECT * FROM invoiceitem WHERE ( (invcitem_invchead_id = pInvcheadid) AND (invcitem_item_id <> -1) ) LOOP -- Cache the amount due for this line _amount := _r.extprice; IF (_amount > 0) THEN -- Credit the Sales Account for the invcitem item IF (_r.invcitem_rev_accnt_id IS NOT NULL) THEN SELECT getPrjAccntId(_p.invchead_prj_id, _r.invcitem_rev_accnt_id) INTO _tmpAccntId; ELSEIF (_r.itemsite_id IS NULL) THEN SELECT getPrjAccntId(_p.invchead_prj_id, salesaccnt_sales_accnt_id) INTO _tmpAccntId FROM salesaccnt WHERE (salesaccnt_id=findSalesAccnt(_r.invcitem_item_id, 'I', _p.invchead_cust_id, _p.invchead_saletype_id, _p.invchead_shipzone_id)); ELSE SELECT getPrjAccntId(_p.invchead_prj_id, salesaccnt_sales_accnt_id) INTO _tmpAccntId FROM salesaccnt WHERE (salesaccnt_id=findSalesAccnt(_r.itemsite_id, 'IS', _p.invchead_cust_id, _p.invchead_saletype_id, _p.invchead_shipzone_id)); END IF; -- If the Sales Account Assignment was not found then punt IF (NOT FOUND) THEN PERFORM deleteGLSeries(_p.sequence); DELETE FROM cohist WHERE ((cohist_sequence=_p.sequence) AND (cohist_invcnumber=_p.invchead_invcnumber)); RETURN -11; END IF; _roundedBase := round(currToBase(_p.invchead_curr_id, _amount, _firstExchDate), 2); SELECT insertIntoGLSeries( _p.sequence, 'A/R', 'IN', _p.invchead_invcnumber, _tmpAccntId, _roundedBase, _glDate, _p.invchead_billto_name ) INTO _test; _totalAmount := (_totalAmount + _amount); _totalRoundedBase := _totalRoundedBase + _roundedBase; _commissionDue := (_commissionDue + (_amount * _p.invchead_commission)); END IF; _totalAmount := _totalAmount; _totalRoundedBase := _totalRoundedBase; -- Record Sales History for this S/O Item SELECT nextval('cohist_cohist_id_seq') INTO _cohistid; INSERT INTO cohist ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_curr_id, cohist_sequence, cohist_taxtype_id, cohist_taxzone_id, cohist_shipzone_id, cohist_saletype_id ) VALUES ( _cohistid, _p.invchead_cust_id, _r.itemsite_id, _p.invchead_shipto_id, _p.invchead_shipdate, _p.invchead_shipvia, COALESCE(_p.invchead_ordernumber, _r.cohead_number), _p.invchead_ponumber, _p.invchead_orderdate, 'I', _p.invchead_invcnumber, _p.invchead_invcdate, _r.qty, _r.unitprice, _r.unitcost, _p.invchead_salesrep_id, (_p.invchead_commission * _r.extprice), FALSE, _p.invchead_billto_name, _p.invchead_billto_address1, _p.invchead_billto_address2, _p.invchead_billto_address3, _p.invchead_billto_city, _p.invchead_billto_state, _p.invchead_billto_zipcode, _p.invchead_shipto_name, _p.invchead_shipto_address1, _p.invchead_shipto_address2, _p.invchead_shipto_address3, _p.invchead_shipto_city, _p.invchead_shipto_state, _p.invchead_shipto_zipcode, _p.invchead_curr_id, _p.sequence, _r.invcitem_taxtype_id, _p.invchead_taxzone_id, _p.invchead_shipzone_id, _p.invchead_saletype_id ); INSERT INTO cohisttax ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM invcitemtax WHERE (taxhist_parent_id=_r.invcitem_id); END LOOP; -- March through the Misc. Invcitems FOR _r IN SELECT * FROM invoiceitem JOIN salescat ON (salescat_id = invcitem_salescat_id) WHERE ( (invcitem_item_id = -1) AND (invcitem_invchead_id=pInvcheadid) ) LOOP -- Cache the amount due for this line and the commission due for such _amount := _r.extprice; IF (_amount > 0) THEN -- Credit the Sales Account for the invcitem item _roundedBase = round(currToBase(_p.invchead_curr_id, _amount, _firstExchDate), 2); SELECT insertIntoGLSeries( _p.sequence, 'A/R', 'IN', _p.invchead_invcnumber, getPrjAccntId(_p.invchead_prj_id, COALESCE(_r.invcitem_rev_accnt_id, _r.salescat_sales_accnt_id)), _roundedBase, _glDate, _p.invchead_billto_name ) INTO _test; IF (_test < 0) THEN PERFORM deleteGLSeries(_p.sequence); DELETE FROM cohist WHERE ((cohist_sequence=_p.sequence) AND (cohist_invcnumber=_p.invchead_invcnumber)); RETURN _test; END IF; _totalAmount := (_totalAmount + _amount); _totalRoundedBase := _totalRoundedBase + _roundedBase; _commissionDue := (_commissionDue + (_amount * _p.invchead_commission)); END IF; -- Record Sales History for this S/O Item SELECT nextval('cohist_cohist_id_seq') INTO _cohistid; INSERT INTO cohist ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_misc_type, cohist_misc_descrip, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_curr_id, cohist_sequence, cohist_taxtype_id, cohist_taxzone_id, cohist_shipzone_id, cohist_saletype_id ) VALUES ( _cohistid, _p.invchead_cust_id, -1, _p.invchead_shipto_id, 'M', (_r.invcitem_number || '-' || _r.invcitem_descrip), _p.invchead_shipdate, _p.invchead_shipvia, COALESCE(_p.invchead_ordernumber, _r.cohead_number), _p.invchead_ponumber, _p.invchead_orderdate, 'I', _p.invchead_invcnumber, _p.invchead_invcdate, _r.qty, _r.unitprice, 0, _p.invchead_salesrep_id, (_p.invchead_commission * _r.extprice), FALSE, _p.invchead_billto_name, _p.invchead_billto_address1, _p.invchead_billto_address2, _p.invchead_billto_address3, _p.invchead_billto_city, _p.invchead_billto_state, _p.invchead_billto_zipcode, _p.invchead_shipto_name, _p.invchead_shipto_address1, _p.invchead_shipto_address2, _p.invchead_shipto_address3, _p.invchead_shipto_city, _p.invchead_shipto_state, _p.invchead_shipto_zipcode, _p.invchead_curr_id, _p.sequence, _r.invcitem_taxtype_id, _p.invchead_taxzone_id, _p.invchead_shipzone_id, _p.invchead_saletype_id ); INSERT INTO cohisttax ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM invcitemtax WHERE (taxhist_parent_id=_r.invcitem_id); END LOOP; -- Credit the Freight Account for Freight Charges IF (_p.invchead_freight <> 0) THEN IF (_p.freightaccntid <> -1) THEN _roundedBase = round(currToBase(_p.invchead_curr_id, _p.invchead_freight, _firstExchDate), 2); SELECT insertIntoGLSeries( _p.sequence, 'A/R', 'IN', _p.invchead_invcnumber, getPrjAccntId(_p.invchead_prj_id,_p.freightaccntid), _roundedBase, _glDate, _p.invchead_billto_name ) INTO _test; -- Cache the Freight Amount distributed _totalAmount := (_totalAmount + _p.invchead_freight); _totalRoundedBase := _totalRoundedBase + _roundedBase; ELSE _test := -14; END IF; -- If the Freight Account was not found then punt IF (_test < 0) THEN PERFORM deleteGLSeries(_p.sequence); DELETE FROM cohist WHERE ((cohist_sequence=_p.sequence) AND (cohist_invcnumber=_p.invchead_invcnumber)); RETURN _test; END IF; -- Record Sales History for the Freight SELECT nextval('cohist_cohist_id_seq') INTO _cohistid; INSERT INTO cohist ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_misc_type, cohist_misc_descrip, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_curr_id, cohist_sequence, cohist_taxtype_id, cohist_taxzone_id, cohist_shipzone_id, cohist_saletype_id ) VALUES ( _cohistid, _p.invchead_cust_id, -1, _p.invchead_shipto_id, 'F', 'Freight', _p.invchead_shipdate, _p.invchead_shipvia, _p.invchead_ordernumber, _p.invchead_ponumber, _p.invchead_orderdate, 'I', _p.invchead_invcnumber, _p.invchead_invcdate, 1, _p.invchead_freight, _p.invchead_freight, _p.invchead_salesrep_id, 0, FALSE, _p.invchead_billto_name, _p.invchead_billto_address1, _p.invchead_billto_address2, _p.invchead_billto_address3, _p.invchead_billto_city, _p.invchead_billto_state, _p.invchead_billto_zipcode, _p.invchead_shipto_name, _p.invchead_shipto_address1, _p.invchead_shipto_address2, _p.invchead_shipto_address3, _p.invchead_shipto_city, _p.invchead_shipto_state, _p.invchead_shipto_zipcode, _p.invchead_curr_id, _p.sequence, getFreightTaxtypeId(), _p.invchead_taxzone_id, _p.invchead_shipzone_id, _p.invchead_saletype_id ); INSERT INTO cohisttax ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM invcheadtax WHERE ( (taxhist_parent_id=_p.invchead_id) AND (taxhist_taxtype_id=getFreightTaxtypeId()) ); END IF; -- Credit the Misc. Account for Miscellaneous Charges IF (_p.invchead_misc_amount <> 0) THEN _roundedBase := round(currToBase(_p.invchead_curr_id, _p.invchead_misc_amount, _firstExchDate), 2); SELECT insertIntoGLSeries( _p.sequence, 'A/R', 'IN', _p.invchead_invcnumber, getPrjAccntId(_p.invchead_prj_id, _p.invchead_misc_accnt_id), _roundedBase, _glDate, _p.invchead_billto_name ) INTO _test; -- If the Misc. Charges Account was not found then punt IF (_test < 0) THEN PERFORM deleteGLSeries(_p.sequence); DELETE FROM cohist WHERE ((cohist_sequence=_p.sequence) AND (cohist_invcnumber=_p.invchead_invcnumber)); RETURN _test; END IF; -- Cache the Misc. Amount distributed _totalAmount := (_totalAmount + _p.invchead_misc_amount); _totalRoundedBase := _totalRoundedBase + _roundedBase; -- Record Sales History for the Misc. Charge INSERT INTO cohist ( cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_misc_type, cohist_misc_descrip, cohist_misc_id, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_curr_id, cohist_sequence, cohist_shipzone_id, cohist_saletype_id ) VALUES ( _p.invchead_cust_id, -1, _p.invchead_shipto_id, 'M', _p.invchead_misc_descrip, _p.invchead_misc_accnt_id, _p.invchead_shipdate, _p.invchead_shipvia, _p.invchead_ordernumber, _p.invchead_ponumber, _p.invchead_orderdate, 'I', _p.invchead_invcnumber, _p.invchead_invcdate, 1, _p.invchead_misc_amount, _p.invchead_misc_amount, _p.invchead_salesrep_id, 0, FALSE, _p.invchead_billto_name, _p.invchead_billto_address1, _p.invchead_billto_address2, _p.invchead_billto_address3, _p.invchead_billto_city, _p.invchead_billto_state, _p.invchead_billto_zipcode, _p.invchead_shipto_name, _p.invchead_shipto_address1, _p.invchead_shipto_address2, _p.invchead_shipto_address3, _p.invchead_shipto_city, _p.invchead_shipto_state, _p.invchead_shipto_zipcode, _p.invchead_curr_id, _p.sequence, _p.invchead_shipzone_id, _p.invchead_saletype_id ); END IF; -- Record Sales History for the Tax Adjustment IF (_p.adjtax <> 0) THEN SELECT nextval('cohist_cohist_id_seq') INTO _cohistid; INSERT INTO cohist ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipto_id, cohist_misc_type, cohist_misc_descrip, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_ponumber, cohist_orderdate, cohist_doctype, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_salesrep_id, cohist_commission, cohist_commissionpaid, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_curr_id, cohist_sequence, cohist_taxtype_id, cohist_taxzone_id, cohist_shipzone_id, cohist_saletype_id ) VALUES ( _cohistid, _p.invchead_cust_id, -1, _p.invchead_shipto_id, 'T', 'Misc Tax Adjustment', _p.invchead_shipdate, _p.invchead_shipvia, _p.invchead_ordernumber, _p.invchead_ponumber, _p.invchead_orderdate, 'I', _p.invchead_invcnumber, _p.invchead_invcdate, 1, 0.0, 0.0, _p.invchead_salesrep_id, 0, FALSE, _p.invchead_billto_name, _p.invchead_billto_address1, _p.invchead_billto_address2, _p.invchead_billto_address3, _p.invchead_billto_city, _p.invchead_billto_state, _p.invchead_billto_zipcode, _p.invchead_shipto_name, _p.invchead_shipto_address1, _p.invchead_shipto_address2, _p.invchead_shipto_address3, _p.invchead_shipto_city, _p.invchead_shipto_state, _p.invchead_shipto_zipcode, _p.invchead_curr_id, _p.sequence, getAdjustmentTaxtypeId(), _p.invchead_taxzone_id, _p.invchead_shipzone_id, _p.invchead_saletype_id ); INSERT INTO cohisttax ( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT _cohistid, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM invcheadtax WHERE ( (taxhist_parent_id=_p.invchead_id) AND (taxhist_taxtype_id=getAdjustmentTaxtypeId()) ); END IF; -- ToDo: handle rounding errors _exchGain := currGain(_p.invchead_curr_id, _totalAmount, _firstExchDate, _glDate); IF (_exchGain <> 0) THEN SELECT insertIntoGLSeries( _p.sequence, 'A/R', 'IN', _p.invchead_invcnumber, getGainLossAccntId(_p.araccntid), round(_exchGain, 2) * -1, _glDate, _p.invchead_billto_name ) INTO _test ; IF (_test < 0) THEN PERFORM deleteGLSeries(_p.sequence); DELETE FROM cohist WHERE ((cohist_sequence=_p.sequence) AND (cohist_invcnumber=_p.invchead_invcnumber)); RETURN _test; END IF; END IF; -- Debit A/R for the total Amount IF (_totalRoundedBase <> 0) THEN IF (_p.araccntid != -1) THEN PERFORM insertIntoGLSeries( _p.sequence, 'A/R', 'IN', _p.invchead_invcnumber, _p.araccntid, round(_totalRoundedBase * -1, 2), _glDate, _p.invchead_billto_name ); ELSE PERFORM deleteGLSeries(_p.sequence); DELETE FROM cohist WHERE ((cohist_sequence=_p.sequence) AND (cohist_invcnumber=_p.invchead_invcnumber)); RETURN -17; END IF; END IF; -- Commit the GLSeries; SELECT postGLSeries(_p.sequence, pJournalNumber) INTO _test; IF (_test < 0) THEN PERFORM deleteGLSeries(_p.sequence); DELETE FROM cohist WHERE ((cohist_sequence=_p.sequence) AND (cohist_invcnumber=_p.invchead_invcnumber)); RETURN _test; END IF; -- Create the Invoice aropen item SELECT nextval('aropen_aropen_id_seq') INTO _aropenid; INSERT INTO aropen ( aropen_id, aropen_username, aropen_journalnumber, aropen_open, aropen_posted, aropen_cust_id, aropen_ponumber, aropen_docnumber, aropen_applyto, aropen_doctype, aropen_docdate, aropen_duedate, aropen_distdate, aropen_terms_id, aropen_amount, aropen_paid, aropen_salesrep_id, aropen_commission_due, aropen_commission_paid, aropen_ordernumber, aropen_notes, aropen_cobmisc_id, aropen_curr_id ) VALUES ( _aropenid, getEffectiveXtUser(), pJournalNumber, TRUE, FALSE, _p.invchead_cust_id, _p.invchead_ponumber, _p.invchead_invcnumber, _p.invchead_invcnumber, 'I', _p.invchead_invcdate, determineDueDate(_p.invchead_terms_id, _p.invchead_invcdate), _glDate, _p.invchead_terms_id, round(_totalAmount, 2), 0, _p.invchead_salesrep_id, _commissionDue, FALSE, _p.invchead_ordernumber::text, _p.invchead_notes, pInvcheadid, _p.invchead_curr_id ); -- Handle the Inventory and G/L Transactions for any billed Inventory where invcitem_updateinv is true FOR _r IN SELECT itemsite_id AS itemsite_id, invcitem_id, (invcitem_billed * invcitem_qty_invuomratio) AS qty, invchead_invcnumber, invchead_cust_id AS cust_id, item_number, invchead_saletype_id AS saletype_id, invchead_shipzone_id AS shipzone_id, invchead_prj_id, itemsite_costmethod FROM invchead JOIN invcitem ON ( (invcitem_invchead_id=invchead_id) AND (invcitem_billed <> 0) AND (invcitem_updateinv) ) JOIN itemsite ON ( (itemsite_item_id=invcitem_item_id) AND (itemsite_warehous_id=invcitem_warehous_id) ) JOIN item ON (item_id=invcitem_item_id) WHERE (invchead_id=pInvcheadid) LOOP -- Issue billed stock from inventory IF (_itemlocSeries = 0) THEN _itemlocSeries := NEXTVAL('itemloc_series_seq'); END IF; IF (_r.itemsite_costmethod != 'J') THEN SELECT postInvTrans(itemsite_id, 'SH', _r.qty, 'S/O', 'IN', _r.invchead_invcnumber, '', ('Invoice Billed ' || _r.item_number), getPrjAccntId(_r.invchead_prj_id, resolveCOSAccount(itemsite_id, _r.cust_id, _r.saletype_id, _r.shipzone_id)), costcat_asset_accnt_id, _itemlocSeries, _glDate) INTO _invhistid FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_r.itemsite_id) ); ELSE RAISE DEBUG 'postInvoice(%, %, %) tried to postInvTrans a %-costed item', pInvcheadid, pJournalNumber, pItemlocSeries, _r.itemsite_costmethod; END IF; END LOOP; -- Mark the invoice as posted UPDATE invchead SET invchead_posted=TRUE, invchead_gldistdate=_glDate WHERE (invchead_id=pInvcheadid); -- Check for allocated CMs and Payments -- All amounts in invoice currency IF (_totalAmount > 0) THEN FOR _r IN SELECT aropen_id, CASE WHEN (currToCurr(aropen_curr_id, _p.invchead_curr_id, (aropen_amount - aropen_paid), _firstExchDate) >= currToCurr(aropenalloc_curr_id, _p.invchead_curr_id, aropenalloc_amount, _firstExchDate)) THEN currToCurr(aropenalloc_curr_id, _p.invchead_curr_id, aropenalloc_amount, _firstExchDate) ELSE currToCurr(aropen_curr_id, _p.invchead_curr_id, (aropen_amount - aropen_paid), _firstExchDate) END AS balance, aropenalloc_doctype, aropenalloc_doc_id FROM aropenalloc JOIN aropen ON (aropen_id=aropenalloc_aropen_id) WHERE ((aropenalloc_doctype='S' AND aropenalloc_doc_id=(SELECT cohead_id FROM cohead WHERE cohead_number=_p.invchead_ordernumber)) OR (aropenalloc_doctype='I' AND aropenalloc_doc_id=_p.invchead_id)) LOOP _appliedAmount := _r.balance; IF (_totalAmount < _appliedAmount) THEN _appliedAmount := _totalAmount; END IF; -- ignore if no appliable balance IF (_appliedAmount > 0) THEN -- create an arcreditapply record linking the source c/m and the target invoice -- for an amount that is equal to the balance on the invoice or the balance on -- c/m whichever is greater. INSERT INTO arcreditapply (arcreditapply_source_aropen_id, arcreditapply_target_aropen_id, arcreditapply_amount, arcreditapply_curr_id, arcreditapply_reftype, arcreditapply_ref_id) VALUES(_r.aropen_id, _aropenid, _appliedAmount, _p.invchead_curr_id, 'S', _r.aropenalloc_doc_id); -- call postARCreditMemoApplication(aropen_id of C/M) SELECT postARCreditMemoApplication(_r.aropen_id) into _test; -- if no error decrement the balance and contiue on IF (_test >= 0) THEN _totalAmount := _totalAmount - _appliedAmount; END IF; END IF; END LOOP; END IF; -- Delete any allocated CMs and Payments DELETE FROM aropenalloc WHERE ((aropenalloc_doctype='S' AND aropenalloc_doc_id=(SELECT cohead_id FROM cohead WHERE cohead_number=_p.invchead_ordernumber)) OR (aropenalloc_doctype='I' AND aropenalloc_doc_id=_p.invchead_id)); RETURN _itemlocSeries; END; $$; gDROP FUNCTION public.postinvoice(pinvcheadid integer, pjournalnumber integer, pitemlocseries integer); publicadminfalse84623125579159postinvoices(boolean)FUNCTION;CREATE FUNCTION postinvoices(boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPostUnprinted ALIAS FOR $1; BEGIN RETURN postInvoices(pPostUnprinted, FALSE); END; $_$; ,DROP FUNCTION public.postinvoices(boolean); publicadminfalse84623125579160postinvoices(boolean, boolean)FUNCTIONCREATE FUNCTION postinvoices(boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPostUnprinted ALIAS FOR $1; pInclZeros ALIAS FOR $2; BEGIN RETURN postInvoices(pPostUnprinted, pInclZeros, fetchJournalNumber('AR-IN')); END; $_$; 5DROP FUNCTION public.postinvoices(boolean, boolean); publicadminfalse46238_125579161'postinvoices(boolean, boolean, integer)FUNCTIONCREATE FUNCTION postinvoices(boolean, boolean, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPostUnprinted ALIAS FOR $1; pInclZeros ALIAS FOR $2; pJournalNumber ALIAS FOR $3; _invcheadid INTEGER; _itemlocSeries INTEGER; _counter INTEGER; _r RECORD; BEGIN _itemlocSeries := 0; IF (pInclZeros) THEN FOR _invcheadid IN SELECT invchead_id FROM invchead WHERE ( (NOT invchead_posted) AND (checkInvoiceSitePrivs(invchead_id)) AND (pPostUnprinted OR invchead_printed) ) LOOP SELECT postInvoice(_invcheadid, pJournalNumber, _itemlocSeries) INTO _itemlocSeries; IF (_itemlocSeries < 0) THEN RETURN _itemlocSeries; END IF; END LOOP; ELSE FOR _invcheadid IN SELECT invchead_id FROM invchead LEFT OUTER JOIN invcitem ON (invchead_id=invcitem_invchead_id) LEFT OUTER JOIN item ON (invcitem_item_id=item_id) WHERE((NOT invchead_posted) AND (checkInvoiceSitePrivs(invchead_id)) AND (pPostUnprinted OR invchead_printed)) GROUP BY invchead_id, invchead_freight, invchead_misc_amount HAVING (COALESCE(SUM(round((invcitem_billed * invcitem_qty_invuomratio) * (invcitem_price / CASE WHEN (item_id IS NULL) THEN 1 ELSE invcitem_price_invuomratio END), 2)),0) + invchead_freight + invchead_misc_amount) > 0 LOOP SELECT postInvoice(_invcheadid, pJournalNumber, _itemlocSeries) INTO _itemlocSeries; IF (_itemlocSeries < 0) THEN RETURN _itemlocSeries; END IF; END LOOP; END IF; RETURN _itemlocSeries; END; $_$; >DROP FUNCTION public.postinvoices(boolean, boolean, integer); publicadminfalse84623`125579162postinvtrans(integer, text, numeric, text, text, text, text, text, integer, integer, integer, timestamp with time zone, numeric, integer)FUNCTION"CREATE FUNCTION postinvtrans(pitemsiteid integer, ptranstype text, pqty numeric, pmodule text, pordertype text, pordernumber text, pdocnumber text, pcomments text, pdebitid integer, pcreditid integer, pitemlocseries integer, ptimestamp timestamp with time zone DEFAULT now(), pcostovrld numeric DEFAULT NULL::numeric, pinvhistid integer DEFAULT NULL::integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. -- pInvhistid is the original transaction to be returned, reversed, etc. DECLARE _creditid INTEGER; _debitid INTEGER; _glreturn INTEGER; _invhistid INTEGER; _itemlocdistid INTEGER; _r RECORD; _sense INTEGER; -- direction in which to adjust inventory QOH _t RECORD; _timestamp TIMESTAMP WITH TIME ZONE; _xferwhsid INTEGER; BEGIN -- Cache item and itemsite info SELECT CASE WHEN(itemsite_costmethod IN ('A','J')) THEN COALESCE(abs(pCostOvrld / pQty), avgcost(itemsite_id)) ELSE stdCost(itemsite_item_id) END AS cost, itemsite_costmethod, itemsite_qtyonhand, itemsite_warehous_id, ( (item_type = 'R') OR (itemsite_controlmethod = 'N') ) AS nocontrol, (itemsite_controlmethod IN ('L', 'S')) AS lotserial, (itemsite_loccntrl) AS loccntrl, itemsite_freeze AS frozen INTO _r FROM itemsite JOIN item ON (item_id=itemsite_item_id) WHERE (itemsite_id=pItemsiteid); --Post the Inventory Transactions IF (_r.nocontrol) THEN RETURN -1; -- non-fatal error so dont throw an exception? END IF; IF (COALESCE(pItemlocSeries,0) = 0) THEN RAISE EXCEPTION 'Transaction series must be provided'; END IF; SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid; IF ((pTimestamp IS NULL) OR (CAST(pTimestamp AS date)=CURRENT_DATE)) THEN _timestamp := CURRENT_TIMESTAMP; ELSE _timestamp := pTimestamp; END IF; IF (pTransType = 'TS' OR pTransType = 'TR') THEN SELECT * INTO _t FROM tohead WHERE (tohead_number=pDocNumber); IF (pTransType = 'TS') THEN _xferwhsid := CASE WHEN (_t.tohead_src_warehous_id=_r.itemsite_warehous_id) THEN _t.tohead_trns_warehous_id WHEN (_t.tohead_trns_warehous_id=_r.itemsite_warehous_id AND pComments ~* 'recall') THEN _t.tohead_src_warehous_id WHEN (_t.tohead_trns_warehous_id=_r.itemsite_warehous_id) THEN _t.tohead_dest_warehous_id WHEN (_t.tohead_dest_warehous_id=_r.itemsite_warehous_id) THEN _t.tohead_trns_warehous_id ELSE NULL END; ELSIF (pTransType = 'TR') THEN _xferwhsid := CASE WHEN (_t.tohead_src_warehous_id=_r.itemsite_warehous_id) THEN _t.tohead_trns_warehous_id WHEN (_t.tohead_trns_warehous_id=_r.itemsite_warehous_id AND pComments ~* 'recall') THEN _t.tohead_dest_warehous_id WHEN (_t.tohead_trns_warehous_id=_r.itemsite_warehous_id) THEN _t.tohead_src_warehous_id WHEN (_t.tohead_dest_warehous_id=_r.itemsite_warehous_id) THEN _t.tohead_trns_warehous_id ELSE NULL END; END IF; END IF; -- increase inventory: AD RM RT RP RR RS RX RB TR -- decrease inventory: IM IB IT SH SI EX RI -- TS and TR are special: shipShipment and recallShipment should not change -- QOH at the Transfer Order src whs (as this was done by issueToShipping) -- but postReceipt should change QOH at the transit whs IF (pTransType='TS') THEN _sense := CASE WHEN (SELECT tohead_trns_warehous_id=_r.itemsite_warehous_id FROM tohead WHERE (tohead_number=pDocNumber)) THEN -1 ELSE 0 END; ELSIF (pTransType='TR') THEN _sense := CASE WHEN (SELECT tohead_src_warehous_id=_r.itemsite_warehous_id FROM tohead WHERE (tohead_number=pDocNumber)) THEN 0 ELSE 1 END; ELSIF (pTransType IN ('IM', 'IB', 'IT', 'SH', 'SI', 'EX', 'RI')) THEN _sense := -1; ELSE _sense := 1; END IF; IF((_r.itemsite_costmethod='A') AND (_r.itemsite_qtyonhand + round(_sense * pQty, 6)) < 0) THEN -- Can not let average costed itemsites go negative RAISE EXCEPTION 'This transaction will cause an Average Costed item to go negative which is not allowed [xtuple: postinvtrans, -2]'; END IF; INSERT INTO invhist ( invhist_id, invhist_itemsite_id, invhist_transtype, invhist_transdate, invhist_invqty, invhist_qoh_before, invhist_qoh_after, invhist_costmethod, invhist_value_before, invhist_value_after, invhist_ordtype, invhist_ordnumber, invhist_docnumber, invhist_comments, invhist_invuom, invhist_unitcost, invhist_xfer_warehous_id, invhist_posted, invhist_series ) SELECT _invhistid, itemsite_id, pTransType, _timestamp, pQty, itemsite_qtyonhand, (itemsite_qtyonhand + (_sense * pQty)), itemsite_costmethod, itemsite_value, -- sanity check to ensure that value = 0 when qtyonhand = 0 CASE WHEN ((itemsite_qtyonhand + (_sense * pQty))) = 0.0 THEN 0.0 ELSE itemsite_value + (_r.cost * _sense * pQty) END, pOrderType, pOrderNumber, pDocNumber, pComments, uom_name, _r.cost, _xferwhsid, FALSE, pItemlocSeries FROM itemsite, item, uom WHERE ( (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (itemsite_id=pItemsiteid) ); IF (pCreditid IN (SELECT accnt_id FROM accnt)) THEN _creditid = pCreditid; ELSE SELECT warehous_default_accnt_id INTO _creditid FROM itemsite, whsinfo WHERE ( (itemsite_warehous_id=warehous_id) AND (itemsite_id=pItemsiteid) ); END IF; IF (pDebitid IN (SELECT accnt_id FROM accnt)) THEN _debitid = pDebitid; ELSE SELECT warehous_default_accnt_id INTO _debitid FROM itemsite, whsinfo WHERE ( (itemsite_warehous_id=warehous_id) AND (itemsite_id=pItemsiteid) ); END IF; -- Post the G/L Transaction IF (_creditid <> _debitid) THEN SELECT insertGLTransaction(pModule, pOrderType, pOrderNumber, pComments, _creditid, _debitid, _invhistid, (_r.cost * pQty), _timestamp::DATE, FALSE) INTO _glreturn; END IF; -- Distribute this if this itemsite is controlled IF ( _r.lotserial OR _r.loccntrl ) THEN _itemlocdistid := nextval('itemlocdist_itemlocdist_id_seq'); INSERT INTO itemlocdist ( itemlocdist_id, itemlocdist_itemsite_id, itemlocdist_source_type, itemlocdist_reqlotserial, itemlocdist_distlotserial, itemlocdist_expiration, itemlocdist_qty, itemlocdist_series, itemlocdist_invhist_id, itemlocdist_order_type, itemlocdist_order_id ) SELECT _itemlocdistid, pItemsiteid, 'O', (((pQty * _sense) > 0) AND _r.lotserial), ((pQty * _sense) < 0), endOfTime(), (_sense * pQty), pItemlocSeries, _invhistid, pOrderType, CASE WHEN pOrderType='SO' THEN getSalesLineItemId(pOrderNumber) ELSE NULL END; -- populate distributions if invhist_id parameter passed to undo IF (pInvhistid IS NOT NULL) THEN INSERT INTO itemlocdist ( itemlocdist_itemlocdist_id, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_itemsite_id, itemlocdist_ls_id, itemlocdist_expiration, itemlocdist_qty, itemlocdist_series, itemlocdist_invhist_id ) SELECT _itemlocdistid, 'L', COALESCE(invdetail_location_id, -1), invhist_itemsite_id, invdetail_ls_id, COALESCE(invdetail_expiration, endoftime()), (invdetail_qty * -1.0), pItemlocSeries, _invhistid FROM invhist JOIN invdetail ON (invdetail_invhist_id=invhist_id) WHERE (invhist_id=pInvhistid); IF ( _r.lotserial) THEN INSERT INTO lsdetail ( lsdetail_itemsite_id, lsdetail_ls_id, lsdetail_created, lsdetail_source_type, lsdetail_source_id, lsdetail_source_number ) SELECT invhist_itemsite_id, invdetail_ls_id, CURRENT_TIMESTAMP, 'I', _itemlocdistid, '' FROM invhist JOIN invdetail ON (invdetail_invhist_id=invhist_id) WHERE (invhist_id=pInvhistid); END IF; PERFORM distributeitemlocseries(pItemlocSeries); END IF; END IF; -- end of distributions -- These records will be used for posting G/L transactions to trial balance after records committed. -- If we try to do it now concurrency locking prevents any transactions while -- user enters item distribution information. Cant have that. INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries) VALUES ( _glreturn, pItemlocSeries ); RETURN _invhistid; END; $$; 4DROP FUNCTION public.postinvtrans(pitemsiteid integer, ptranstype text, pqty numeric, pmodule text, pordertype text, pordernumber text, pdocnumber text, pcomments text, pdebitid integer, pcreditid integer, pitemlocseries integer, ptimestamp timestamp with time zone, pcostovrld numeric, pinvhistid integer); publicadminfalse46238a125579164postitemlocseries(integer)FUNCTION|CREATE FUNCTION postitemlocseries(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemlocseries ALIAS FOR $1; _result INTEGER; BEGIN PERFORM postIntoTrialBalance(itemlocpost_glseq) FROM ( SELECT DISTINCT itemlocpost_glseq, gltrans_accnt_id FROM itemlocpost JOIN gltrans ON (itemlocpost_glseq=gltrans_sequence) WHERE (itemlocpost_itemlocseries=pItemlocseries) ORDER BY gltrans_accnt_id ) AS data; PERFORM postInvHist(invhist_id) FROM invhist JOIN itemsite ON (invhist_itemsite_id=itemsite_id) WHERE ( (invhist_series=pItemlocseries) AND ( NOT invhist_posted) AND ( NOT itemsite_freeze) ); DELETE FROM itemlocpost WHERE (itemlocpost_itemlocseries=pItemlocseries); RETURN TRUE; END; $_$; 1DROP FUNCTION public.postitemlocseries(integer); publicadminfalse46238b125579165postjournals(integer)FUNCTION CREATE FUNCTION postjournals(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; _transCount INTEGER := 0; _journalnumber INTEGER := fetchJournalNumber('J/P'); _sequence INTEGER := fetchGLSequence(); _sltrans RECORD; BEGIN -- Make sure that we balance IF (SELECT SUM(sltrans_amount) != 0 FROM sltrans WHERE ((NOT sltrans_posted ) AND (sltrans_sequence=pSequence))) THEN RAISE EXCEPTION 'Can not post journals. Transactions do not balance in selected date range.'; END IF; -- March through the sltrans members, posting them one at a time FOR _sltrans IN SELECT sltrans_source, sltrans_accnt_id, SUM(sltrans_amount) as amount FROM sltrans WHERE ((sltrans_amount<>0.0) AND (NOT sltrans_posted) AND (sltrans_sequence=pSequence)) GROUP BY sltrans_source, sltrans_accnt_id LOOP -- refuse to accept postings into closed periods IF (SELECT BOOL_AND(COALESCE(period_closed, FALSE)) FROM accnt LEFT OUTER JOIN period ON (CURRENT_DATE BETWEEN period_start AND period_end) WHERE (accnt_id = _sltrans.sltrans_accnt_id)) THEN RAISE EXCEPTION 'Cannot post to closed period (%).', _sltrans.sltrans_distdate; RETURN -4; -- remove raise exception when all callers check return code END IF; -- refuse to accept postings into frozen periods without proper priv IF (SELECT NOT BOOL_AND(checkPrivilege('PostFrozenPeriod')) AND BOOL_AND(COALESCE(period_freeze, FALSE)) FROM accnt LEFT OUTER JOIN period ON (CURRENT_DATE BETWEEN period_start AND period_end) WHERE (accnt_id = _sltrans.sltrans_accnt_id)) THEN RAISE EXCEPTION 'Cannot post to frozen period (%).', _sltrans.sltrans_distdate; RETURN -4; -- remove raise exception when all callers check return code END IF; IF (_sltrans.amount != 0) THEN INSERT INTO gltrans ( gltrans_posted, gltrans_exported, gltrans_created, gltrans_date, gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_notes, gltrans_doctype, gltrans_docnumber, gltrans_amount, gltrans_journalnumber, gltrans_rec ) VALUES ( FALSE, FALSE, CURRENT_TIMESTAMP, CURRENT_DATE, _sequence, _sltrans.sltrans_accnt_id, _sltrans.sltrans_source, 'Journal Posting', 'JP', _journalnumber, _sltrans.amount, _journalnumber, TRUE ); _transCount := _transCount + 1; END IF; END LOOP; -- Update all of the posted sltrans members UPDATE sltrans SET sltrans_posted=true, sltrans_gltrans_journalnumber=_journalnumber WHERE ((NOT sltrans_posted) AND (sltrans_sequence=pSequence)); PERFORM postIntoTrialBalance(_sequence); RETURN _journalnumber; END; $_$; ,DROP FUNCTION public.postjournals(integer); publicadminfalse84623c125579166&postjournals(text[], date, date, date)FUNCTIONCREATE FUNCTION postjournals(text[], date, date, date) RETURNS SETOF integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSources ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; pDistDate ALIAS FOR $4; _i INTEGER; BEGIN FOR _i IN 1..ARRAY_UPPER(pSources,1) LOOP RETURN NEXT postJournals(pSources[_i], pStartDate, pEndDate, pDistDate); END LOOP; RETURN; END; $_$; =DROP FUNCTION public.postjournals(text[], date, date, date); publicadminfalse84623d125579167$postjournals(text, date, date, date)FUNCTION CREATE FUNCTION postjournals(text, date, date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSource ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; pDistDate ALIAS FOR $4; _transCount INTEGER := 0; _journalnumber INTEGER := fetchJournalNumber('J/P'); _sequence INTEGER := fetchGLSequence(); _sltrans RECORD; BEGIN -- Make sure that we balance IF (SELECT SUM(sltrans_amount) != 0 FROM sltrans WHERE ((NOT sltrans_posted ) AND (sltrans_source=pSource) AND (sltrans_date BETWEEN pStartDate AND pEndDate))) THEN RAISE EXCEPTION 'Can not post journals. Transactions do not balance in selected date range.'; END IF; -- March through the sltrans members, posting them one at a time FOR _sltrans IN SELECT sltrans_source, sltrans_accnt_id, SUM(sltrans_amount) as amount FROM sltrans WHERE ((sltrans_amount<>0.0) AND (NOT sltrans_posted) AND (sltrans_source=pSource) AND (sltrans_date BETWEEN pStartDate AND pEndDate)) GROUP BY sltrans_source, sltrans_accnt_id LOOP -- refuse to accept postings into frozen periods if any of the accounts disallow it IF (SELECT NOT BOOL_AND(checkPrivilege('PostFrozenPeriod')) AND BOOL_AND(COALESCE(period_freeze, FALSE)) FROM accnt LEFT OUTER JOIN period ON (pDistDate BETWEEN period_start AND period_end) WHERE (accnt_id = _sltrans.sltrans_accnt_id)) THEN RAISE EXCEPTION 'Cannot post to frozen period (%).', _sltrans.sltrans_distdate; RETURN -4; -- remove raise exception when all callers check return code END IF; IF (_sltrans.amount != 0) THEN INSERT INTO gltrans ( gltrans_posted, gltrans_exported, gltrans_created, gltrans_date, gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_notes, gltrans_doctype, gltrans_docnumber, gltrans_amount, gltrans_journalnumber ) VALUES ( FALSE, FALSE, CURRENT_TIMESTAMP, pDistDate, _sequence, _sltrans.sltrans_accnt_id, _sltrans.sltrans_source, 'Journal Posting', 'JP', _journalnumber, _sltrans.amount, _journalnumber ); _transCount := _transCount + 1; END IF; END LOOP; -- Update all of the posted sltrans members UPDATE sltrans SET sltrans_posted=true, sltrans_gltrans_journalnumber=_journalnumber WHERE ((NOT sltrans_posted) AND (sltrans_source=pSource) AND (sltrans_date BETWEEN pStartDate AND pEndDate)); PERFORM postIntoTrialBalance(_sequence); RETURN _journalnumber; END; $_$; ;DROP FUNCTION public.postjournals(text, date, date, date); publicadminfalse84623i125579168postmessage(text, text)FUNCTIONCREATE FUNCTION postmessage(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pText ALIAS FOR $2; _msgid INTEGER; BEGIN SELECT NEXTVAL('msg_msg_id_seq') INTO _msgid; INSERT INTO msg (msg_id, msg_posted, msg_scheduled, msg_expires, msg_username, msg_text) VALUES (_msgid, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, endOfTime(), getEffectiveXtUser(), pText); INSERT INTO msguser ( msguser_msg_id, msguser_username ) VALUES ( _msgid, pUsername ); NOTIFY "messagePosted"; RETURN _msgid; END; $_$; .DROP FUNCTION public.postmessage(text, text); publicadminfalse46238h125579169Kpostmessage(timestamp without time zone, timestamp without time zone, text)FUNCTION/CREATE FUNCTION postmessage(timestamp without time zone, timestamp without time zone, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pScheduled ALIAS FOR $1; pExpires ALIAS FOR $2; pText ALIAS FOR $3; _msgid INTEGER; BEGIN SELECT NEXTVAL('msg_msg_id_seq') INTO _msgid; INSERT INTO msg (msg_id, msg_posted, msg_scheduled, msg_expires, msg_username, msg_text) VALUES (_msgid, CURRENT_TIMESTAMP, pScheduled, pExpires, getEffectiveXtUser(), pText); INSERT INTO msguser ( msguser_msg_id, msguser_username ) SELECT _msgid, usr_username FROM usr WHERE (usr_username <> getEffectiveXtUser()); NOTIFY "messagePosted"; RETURN _msgid; END; $_$; bDROP FUNCTION public.postmessage(timestamp without time zone, timestamp without time zone, text); publicadminfalse46238g125579170Qpostmessage(timestamp without time zone, timestamp without time zone, text, text)FUNCTIONCREATE FUNCTION postmessage(timestamp without time zone, timestamp without time zone, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pScheduled ALIAS FOR $1; pExpires ALIAS FOR $2; pUsername ALIAS FOR $3; pText ALIAS FOR $4; _msgid INTEGER; BEGIN SELECT NEXTVAL('msg_msg_id_seq') INTO _msgid; INSERT INTO msg (msg_id, msg_posted, msg_scheduled, msg_expires, msg_username, msg_text) VALUES (_msgid, CURRENT_TIMESTAMP, pScheduled, pExpires, getEffectiveXtUser(), pText); INSERT INTO msguser ( msguser_msg_id, msguser_username ) VALUES ( _msgid, pUsername ); NOTIFY "messagePosted"; RETURN _msgid; END; $_$; hDROP FUNCTION public.postmessage(timestamp without time zone, timestamp without time zone, text, text); publicadminfalse84623j125579171%postmisccount(integer, numeric, text)FUNCTIONCREATE FUNCTION postmisccount(pitemsiteid integer, pqty numeric, pcomments text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pQty ALIAS FOR $2; pComments ALIAS FOR $3; _invcntid INTEGER; _result INTEGER; BEGIN IF (pItemsiteid IS NULL OR pQty IS NULL) THEN RAISE EXCEPTION 'You must enter an Item Site and a Quantity.'; END IF; -- Make sure the passed itemsite points to a real item IF ( ( SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J') FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ) ) ) THEN RETURN 0; END IF; SELECT invcnt_id INTO _invcntid FROM invcnt WHERE ( (NOT invcnt_posted) AND (invcnt_itemsite_id=pItemsiteid) ); IF (_invcntid IS NULL) THEN _invcntid := NEXTVAL('invcnt_invcnt_id_seq'); INSERT INTO invcnt ( invcnt_id, invcnt_itemsite_id, invcnt_tagdate, invcnt_qoh_before, invcnt_qoh_after, invcnt_tag_username, invcnt_cntdate, invcnt_cnt_username, invcnt_postdate, invcnt_post_username, invcnt_posted, invcnt_priority, invcnt_comments ) SELECT _invcntid, pItemsiteid, now(), itemsite_qtyonhand, pQty, getEffectiveXtUser(), now(), getEffectiveXtUser(), now(), getEffectiveXtUser(), FALSE, FALSE, pComments FROM itemsite WHERE (itemsite_id=pItemsiteid); SELECT postCountTag(_invcntid, FALSE) INTO _result; IF (_result < 0) THEN DELETE FROM invcnt WHERE (invcnt_id=_invcntid); END IF; RETURN _result; ELSE RETURN -2; END IF; END; $_$; WDROP FUNCTION public.postmisccount(pitemsiteid integer, pqty numeric, pcomments text); publicadminfalse46238k125579172postpogltransactions()FUNCTIONCREATE FUNCTION postpogltransactions() RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN UPDATE gltrans SET gltrans_exported=TRUE WHERE ( (NOT gltrans_exported) AND (gltrans_source='A/P') AND (gltrans_doctype IN ('VO')) ); RETURN TRUE; END; $$; -DROP FUNCTION public.postpogltransactions(); publicadminfalse84623l125579173postporeceipt(integer, integer)FUNCTIONCREATE FUNCTION postporeceipt(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN postReceipt($1, $2); END; $_$; 6DROP FUNCTION public.postporeceipt(integer, integer); publicadminfalse84623m125579174postporeceipts(integer)FUNCTIONCREATE FUNCTION postporeceipts(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN postReceipts('PO', $1, NULL); END; $_$; .DROP FUNCTION public.postporeceipts(integer); publicadminfalse84623n125579175postporeturncreditmemo(integer)FUNCTIONICREATE FUNCTION postporeturncreditmemo(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPorejectId ALIAS FOR $1; BEGIN RETURN postPoReturnCreditMemo(pPorejectId, NULL); END; $_$; 6DROP FUNCTION public.postporeturncreditmemo(integer); publicadminfalse46238125579176(postporeturncreditmemo(integer, numeric)FUNCTIONCREATE FUNCTION postporeturncreditmemo(integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPorejectId ALIAS FOR $1; pAmount ALIAS FOR $2; _p RECORD; _a RECORD; _itemsiteId INTEGER; _docNumber TEXT; _sequence INTEGER; _journalNumber INTEGER; _apopenid INTEGER; _exchGainItem NUMERIC; _itemAmount_base NUMERIC; _itemAmount NUMERIC; _glseriesTotal NUMERIC; _tmpTotal NUMERIC; _test INTEGER; _exchDate DATE; _tax RECORD; _taxAmount NUMERIC := 0; _taxAmount_base NUMERIC; _apaccntid INTEGER; BEGIN --Set things up SELECT NEXTVAL('apopen_apopen_id_seq') INTO _apopenid; SELECT fetchGLSequence() INTO _sequence; SELECT fetchJournalNumber('AP-MISC') INTO _journalNumber; SELECT fetchapmemonumber() INTO _docNumber; _glseriesTotal := 0; --Get poreject data SELECT pohead_vend_id, pohead_number, pohead_curr_id, pohead_orderdate, pohead_taxzone_id, poitem_id, poitem_itemsite_id,poitem_expcat_id, poitem_taxtype_id, itemsite_costcat_id, poreject_qty, poreject_date, ('Return of Item ' || COALESCE(item_number,poitem_vend_item_number) || ', qty. ' || formatqty(poreject_qty)) AS notes, poreject_value AS value, currToBase(pohead_curr_id,(poitem_unitprice * poreject_qty),CURRENT_DATE) AS itemAmount_base, (poitem_unitprice * poreject_qty) AS itemAmount INTO _p FROM pohead, poreject, poitem LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id) LEFT OUTER JOIN item ON (itemsite_item_id=item_id) WHERE ((poreject_poitem_id=poitem_id) AND (pohead_id=poitem_pohead_id) AND (poreject_id=pPorejectId)); _itemAmount := _p.itemAmount; _itemAmount_base := _p.itemAmount_base; IF (pAmount IS NOT NULL) THEN _itemAmount := pAmount; _itemAmount_base := currToBase(_p.pohead_curr_id, pAmount, CURRENT_DATE); END IF; -- Grab the G/L Accounts IF (COALESCE(_p.poitem_itemsite_id, -1) = -1) THEN SELECT pp.accnt_id AS pp_accnt_id, lb.accnt_id AS lb_accnt_id INTO _a FROM expcat, accnt AS pp, accnt AS lb WHERE ( (expcat_purchprice_accnt_id=pp.accnt_id) AND (expcat_liability_accnt_id=lb.accnt_id) AND (expcat_id=_p.poitem_expcat_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Post Credit Memo due to unassigned G/L Accounts.'; END IF; ELSE SELECT pp.accnt_id AS pp_accnt_id, lb.accnt_id AS lb_accnt_id INTO _a FROM costcat, accnt AS pp, accnt AS lb WHERE ( (costcat_purchprice_accnt_id=pp.accnt_id) AND (costcat_liability_accnt_id=lb.accnt_id) AND (costcat_id=_p.itemsite_costcat_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Post Credit Memo due to unassigned G/L Accounts.'; END IF; END IF; -- AP Open Item record INSERT INTO apopen ( apopen_id, apopen_username, apopen_journalnumber, apopen_vend_id, apopen_docnumber, apopen_doctype, apopen_ponumber, apopen_docdate, apopen_duedate, apopen_distdate, apopen_terms_id, apopen_amount, apopen_paid, apopen_open, apopen_notes, apopen_accnt_id, apopen_curr_id, apopen_closedate ) VALUES ( _apopenid, getEffectiveXtUser(), _journalNumber, _p.pohead_vend_id, _docNumber, 'C', _p.pohead_number, CURRENT_DATE, CURRENT_DATE, CURRENT_DATE, -1, round(_itemAmount, 2), 0, (round(_itemAmount, 2) <> 0), _p.notes, -1, _p.pohead_curr_id, CASE WHEN (round(_itemAmount, 2) = 0) THEN _p.poreject_date END ); -- Taxes FOR _tax IN SELECT taxdetail_tax_id, sum(taxdetail_tax) AS taxdetail_tax, currToBase(_p.pohead_curr_id, round(sum(taxdetail_tax),2), current_date) AS taxbasevalue FROM calculateTaxDetail(_p.pohead_taxzone_id, _p.poitem_taxtype_id, current_date, _p.pohead_curr_id, _itemAmount) GROUP BY taxdetail_tax_id LOOP INSERT INTO apopentax (taxhist_basis,taxhist_percent,taxhist_amount,taxhist_docdate, taxhist_tax_id, taxhist_tax, taxhist_taxtype_id, taxhist_parent_id, taxhist_journalnumber ) VALUES (0, 0, 0, current_date, _tax.taxdetail_tax_id, _tax.taxdetail_tax, getadjustmenttaxtypeid(), _apopenid, _journalNumber); _taxAmount := _taxAmount + _tax.taxdetail_tax; END LOOP; _taxAmount_base := addTaxToGLSeries(_sequence, 'A/P', 'CM', _docNumber, _p.pohead_curr_id, current_date, current_date, 'apopentax', _apopenid, _p.notes); UPDATE apopen SET apopen_amount = round(_itemAmount + _taxAmount,2) WHERE (apopen_id = _apopenid); -- Distribute from the clearing account PERFORM insertIntoGLSeries( _sequence, 'A/P', 'CM', _docNumber, _a.lb_accnt_id, round(_p.value, 2), current_date, _p.notes ); _glseriesTotal := _glseriesTotal + round(_p.value, 2); -- Distribute the remaining variance to the Purchase Price Variance account IF (round(_itemAmount_base, 2) <> round(_p.value, 2)) THEN _tmpTotal := round(_itemAmount_base, 2) - round(_p.value, 2); PERFORM insertIntoGLSeries( _sequence, 'A/P', 'CM', _docNumber, _a.pp_accnt_id, _tmpTotal, current_date, _p.notes ); _glseriesTotal := _glseriesTotal + _tmpTotal; END IF; -- Post the reject item for this P/O Item as Invoiced UPDATE poreject SET poreject_invoiced=TRUE WHERE poreject_id=pPorejectId; -- Update the qty vouchered field UPDATE poitem SET poitem_qty_vouchered = (poitem_qty_vouchered - _p.poreject_qty) WHERE (poitem_id=_p.poitem_id); -- Post to A/P SELECT findAPAccount(_p.pohead_vend_id) INTO _apaccntid; IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Post Credit Memo due to an unassigned A/P Account.'; END IF; SELECT insertIntoGLSeries( _sequence, 'A/P', 'CM', _docNumber, _apaccntid, round(_itemAmount_base + _taxAmount_base, 2) *-1, current_date, _p.notes ) INTO _test; IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Post Credit Memo.'; END IF; -- Clean up loose ends _glseriesTotal := _glseriesTotal + round(_itemAmount_base, 2)*-1; IF (round(_glseriesTotal, 2) != 0) THEN PERFORM insertIntoGLSeries(_sequence, 'A/P', 'CM', 'Currency Exchange Rounding - ' || _docNumber, getGainLossAccntId(_apaccntid), round(_glseriesTotal, 2) * -1, current_date, _p.notes); END IF; -- Post it all PERFORM postGLSeries(_sequence, _journalNumber); RETURN _journalNumber; END; $_$; ?DROP FUNCTION public.postporeturncreditmemo(integer, numeric); publicadminfalse84623p125579178postporeturns(integer)FUNCTIONCREATE FUNCTION postporeturns(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPoheadid ALIAS FOR $1; _itemlocSeries INTEGER; _p RECORD; _returnval INTEGER; BEGIN _itemlocSeries := 0; SELECT postPoReturns(pPoheadid,false) INTO _itemlocseries; RETURN _itemlocSeries; END; $_$; -DROP FUNCTION public.postporeturns(integer); publicadminfalse84623o125579179postporeturns(integer, boolean)FUNCTIONoCREATE FUNCTION postporeturns(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPoheadid ALIAS FOR $1; pCreateMemo ALIAS FOR $2; _itemlocSeries INTEGER; _p RECORD; _returnval INTEGER; _tmp INTEGER; _pricevar NUMERIC := 0.00; _invhistid INTEGER; _journalNumber INTEGER := fetchJournalNumber('GL-MISC'); BEGIN _itemlocSeries := 0; FOR _p IN SELECT pohead_number, pohead_curr_id, poreject_id, poitem_prj_id, poreject_poitem_id, poitem_id, poitem_expcat_id, poitem_linenumber, currToBase(COALESCE(recv_purchcost_curr_id, pohead_curr_id), COALESCE(recv_purchcost, poitem_unitprice), pohead_orderdate) AS poitem_unitprice_base, COALESCE(itemsite_id, -1) AS itemsiteid, poitem_invvenduomratio, SUM(poreject_qty) AS totalqty, itemsite_item_id, itemsite_costmethod, itemsite_controlmethod, recv_date FROM pohead JOIN poitem ON (poitem_pohead_id=pohead_id) JOIN poreject ON (poreject_poitem_id=poitem_id AND NOT poreject_posted) LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id) LEFT OUTER JOIN recv ON (recv_id=poreject_recv_id) WHERE (pohead_id=pPoheadid) GROUP BY poreject_id, pohead_number, poreject_poitem_id, poitem_id, poitem_prj_id, poitem_expcat_id, poitem_linenumber, poitem_unitprice, pohead_curr_id, pohead_orderdate, itemsite_id, poitem_invvenduomratio, itemsite_item_id, itemsite_costmethod, itemsite_controlmethod, recv_date, recv_purchcost_curr_id, recv_purchcost LOOP IF (_p.itemsiteid = -1) THEN SELECT insertGLTransaction( 'S/R', 'PO', _p.pohead_number, 'Return Non-Inventory to P/O', expcat_liability_accnt_id, getPrjAccntId(_p.poitem_prj_id, expcat_exp_accnt_id), -1, round(_p.poitem_unitprice_base * _p.totalqty * -1, 2), CURRENT_DATE ) INTO _returnval FROM expcat WHERE (expcat_id=_p.poitem_expcat_id); UPDATE poreject SET poreject_posted=TRUE, poreject_value= round(_p.poitem_unitprice_base * _p.totalqty, 2) WHERE (poreject_id=_p.poreject_id); ELSEIF (_p.itemsite_controlmethod='N') THEN SELECT insertGLTransaction('S/R', 'PO', _p.pohead_number, 'Return Non-Controlled Inventory from PO', costcat_liability_accnt_id, getPrjAccntId(_p.poitem_prj_id, costcat_exp_accnt_id), -1, round((_p.poitem_unitprice_base * _p.totalqty * -1), 2), CURRENT_DATE ) INTO _returnval FROM itemsite, costcat WHERE((itemsite_costcat_id=costcat_id) AND (itemsite_id=_p.itemsiteid)); IF (_returnval = -3) THEN -- zero value transaction _returnval := 0; END IF; UPDATE poreject SET poreject_posted=TRUE, poreject_value= round(_p.poitem_unitprice_base * _p.totalqty, 2) WHERE (poreject_id=_p.poreject_id); ELSE IF (_itemlocSeries = 0) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; END IF; SELECT postInvTrans( itemsite_id, 'RP', (_p.totalqty * _p.poitem_invvenduomratio * -1), 'S/R', 'PO', (_p.pohead_number || '-' || _p.poitem_linenumber::TEXT), '', 'Return Inventory to P/O', costcat_asset_accnt_id, costcat_liability_accnt_id, _itemlocSeries, CURRENT_TIMESTAMP) INTO _returnval FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_p.itemsiteid) ); UPDATE poreject SET poreject_posted=TRUE, poreject_value=(invhist_unitcost *_p.totalqty * _p.poitem_invvenduomratio) FROM invhist WHERE ((poreject_id=_p.poreject_id) AND (invhist_id=_returnval)); END IF; IF (_returnval < 0) THEN RETURN _returnval; END IF; UPDATE poitem SET poitem_qty_returned=(poitem_qty_returned + _p.totalqty), poitem_status='O' WHERE (poitem_id=_p.poitem_id); IF (fetchMetricBool('RecordPPVonReceipt')) THEN -- If the 'Purchase Price Variance on Receipt' option is true _invhistid := _returnval; -- Find the difference in the purchase price value expected from the P/O and the value of the transaction SELECT ((_p.poitem_unitprice_base * poitem_qty_returned) - (invhist_value_before - invhist_value_after)) INTO _pricevar FROM invhist, poitem WHERE ((invhist_id = _invhistid) AND (poitem_id=_p.poitem_id)); -- If difference exists then IF (_pricevar <> 0.00) THEN -- Record an additional GL Transaction for the purchase price variance SELECT insertGLTransaction( _journalNumber, 'S/R', 'PO', _p.pohead_number, 'Purchase price variance adjusted for P/O ' || _p.pohead_number || ' for item ' || _p.poitem_linenumber::TEXT, costcat_liability_accnt_id, getPrjAccntId(_p.poitem_prj_id, costcat_purchprice_accnt_id), -1, _pricevar, CURRENT_DATE, false ) INTO _tmp FROM itemsite, costcat, poitem WHERE ((itemsite_costcat_id=costcat_id) AND (itemsite_id=poitem_itemsite_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Could not insert G/L transaction: no cost category found for itemsite_id %', _p.itemsiteid; ELSIF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction RETURN _tmp; ELSE -- Posting to trial balance is deferred to prevent locking INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries) VALUES ( _tmp, _itemlocSeries ); END IF; END IF; END IF; IF (pCreateMemo) THEN SELECT postPoReturnCreditMemo(_p.poreject_id) INTO _returnval; END IF; IF (_returnval < 0) THEN RETURN _returnval; END IF; END LOOP; RETURN _itemlocSeries; END; $_$; 6DROP FUNCTION public.postporeturns(integer, boolean); publicadminfalse46238r1255791812postproduction(integer, numeric, boolean, boolean)FUNCTIONCREATE FUNCTION postproduction(integer, numeric, boolean, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'postProduction(INTEGER, NUMERIC, BOOLEAN, BOOLEAN) is deprecated. please use postProduction(INTEGER, NUMERIC, BOOLEAN, INTEGER, TIMESTAMP WITH TIME ZONE) instead'; RETURN postProduction($1, $2, $3, 0, now()); END; $_$; IDROP FUNCTION public.postproduction(integer, numeric, boolean, boolean); publicadminfalse46238s125579182;postproduction(integer, numeric, boolean, boolean, integer)FUNCTIONCREATE FUNCTION postproduction(integer, numeric, boolean, boolean, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'postProduction(INTEGER, NUMERIC, BOOLEAN, BOOLEAN, INTEGER) is deprecated. please use postProduction(INTEGER, NUMERIC, BOOLEAN, INTEGER, TIMESTAMP WITH TIME ZONE) instead'; RETURN postProduction($1, $2, $3, $5, now()); END; $_$; RDROP FUNCTION public.postproduction(integer, numeric, boolean, boolean, integer); publicadminfalse46238q125579183Lpostproduction(integer, numeric, boolean, integer, timestamp with time zone)FUNCTIONCREATE FUNCTION postproduction(integer, numeric, boolean, integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pQty ALIAS FOR $2; pBackflush ALIAS FOR $3; pItemlocSeries ALIAS FOR $4; pGlDistTS ALIAS FOR $5; _test INTEGER; _invhistid INTEGER; _itemlocSeries INTEGER; _parentQty NUMERIC; _r RECORD; _sense TEXT; _wipPost NUMERIC; _woNumber TEXT; _ucost NUMERIC; BEGIN IF (pQty = 0) THEN RETURN 0; ELSIF (pQty > 0) THEN _sense = 'from'; ELSE _sense = 'to'; END IF; IF ( ( SELECT wo_status FROM wo WHERE (wo_id=pWoid) ) NOT IN ('R','E','I') ) THEN RETURN -1; END IF; -- Make sure that all Component Item Sites exist SELECT bomitem_id INTO _test FROM wo, bomitem, itemsite WHERE ( (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=bomitem_parent_item_id) AND (woEffectiveDate(wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND (wo_id=pWoid) AND (bomitem_rev_id=wo_bom_rev_id) AND (bomitem_item_id NOT IN ( SELECT component.itemsite_item_id FROM itemsite AS component, itemsite AS parent WHERE ( (wo_itemsite_id=parent.itemsite_id) AND (parent.itemsite_item_id=bomitem_parent_item_id) AND (bomitem_item_id=component.itemsite_item_id) AND (woEffectiveDate(wo_startdate) BETWEEN bomitem_effective AND (bomitem_expires - 1)) AND (bomitem_rev_id=wo_bom_rev_id) AND (component.itemsite_active) AND (component.itemsite_warehous_id=parent.itemsite_warehous_id) ) ) ) ) LIMIT 1; IF (FOUND AND pBackflush) THEN RETURN -2; END IF; SELECT formatWoNumber(pWoid) INTO _woNumber; SELECT roundQty(item_fractional, pQty) INTO _parentQty FROM wo, itemsite, item WHERE ((wo_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (wo_id=pWoid)); -- Create the material receipt transaction IF (pItemlocSeries = 0) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; ELSE _itemlocSeries = pItemlocSeries; END IF; IF (pBackflush) THEN FOR _r IN SELECT womatl_id, womatl_qtyiss + (CASE WHEN (womatl_qtywipscrap > ((womatl_qtyfxd + (_parentQty + wo_qtyrcv) * womatl_qtyper) * womatl_scrap)) THEN (womatl_qtyfxd + (_parentQty + wo_qtyrcv) * womatl_qtyper) * womatl_scrap ELSE womatl_qtywipscrap END) AS consumed, (womatl_qtyfxd + ((_parentQty + wo_qtyrcv) * womatl_qtyper)) * (1 + womatl_scrap) AS expected FROM womatl, wo, itemsite, item WHERE ((womatl_issuemethod IN ('L', 'M')) AND (womatl_wo_id=pWoid) AND (womatl_wo_id=wo_id) AND (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id)) LOOP -- Don't issue more than should have already been consumed at this point IF (pQty > 0) THEN IF (noNeg(_r.expected - _r.consumed) > 0) THEN SELECT issueWoMaterial(_r.womatl_id, noNeg(_r.expected - _r.consumed), _itemlocSeries, pGlDistTS) INTO _itemlocSeries; END IF; ELSE -- Used by postMiscProduction of disassembly SELECT returnWoMaterial(_r.womatl_id, (_r.expected * -1.0), _itemlocSeries, CURRENT_TIMESTAMP, true) INTO _itemlocSeries; END IF; UPDATE womatl SET womatl_issuemethod='L' WHERE ( (womatl_issuemethod='M') AND (womatl_id=_r.womatl_id) ); END LOOP; END IF; SELECT CASE WHEN (pQty < 0 AND itemsite_costmethod='S') THEN stdcost(itemsite_item_id) * pQty WHEN (pQty < 0) THEN avgcost(itemsite_id) * pQty WHEN (wo_cosmethod = 'D') THEN wo_wipvalue ELSE round((wo_wipvalue - (wo_postedvalue / wo_qtyord * (wo_qtyord - CASE WHEN (wo_qtyord < wo_qtyrcv + pQty) THEN wo_qtyord ELSE wo_qtyrcv + pQty END ))),2) END INTO _wipPost FROM wo JOIN itemsite ON (wo_itemsite_id=itemsite_id) WHERE (wo_id=pWoid); SELECT postInvTrans( itemsite_id, 'RM', _parentQty, 'W/O', 'WO', _woNumber, '', ('Receive Inventory ' || item_number || ' ' || _sense || ' Manufacturing'), costcat_asset_accnt_id, getPrjAccntId(wo_prj_id, costcat_wip_accnt_id), _itemlocSeries, pGlDistTS, -- the following is only actually used when the item is average or job costed _wipPost ) INTO _invhistid FROM wo, itemsite, item, costcat WHERE ( (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (itemsite_costcat_id=costcat_id) AND (wo_id=pWoid) ); IF (pQty < 0 ) THEN _wipPost := _wipPost * -1; END IF; -- Increase this W/O's received qty decrease its WIP value UPDATE wo SET wo_qtyrcv = (wo_qtyrcv + _parentQty), wo_wipvalue = (wo_wipvalue - (CASE WHEN (itemsite_costmethod IN ('A','J')) THEN _wipPost WHEN (itemsite_costmethod='S') THEN (stdcost(itemsite_item_id) * _parentQty) ELSE 0.0 END)) FROM itemsite, item WHERE ((wo_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (wo_id=pWoid)); -- ROB Increase this W/O's WIP value for custom costing SELECT SUM(itemcost_stdcost * _parentQty) INTO _ucost FROM wo JOIN itemsite ON (itemsite_id=wo_itemsite_id) JOIN itemcost ON (itemcost_item_id=itemsite_item_id) JOIN costelem ON ((costelem_id=itemcost_costelem_id) AND (costelem_exp_accnt_id IS NOT NULL) AND (NOT costelem_sys)) WHERE (wo_id=pWoid); UPDATE wo SET wo_wipvalue = (wo_wipvalue + coalesce(_ucost,0)) WHERE (wo_id=pWoid); -- ROB Distribute to G/L - create Cost Variance, debit WIP PERFORM insertGLTransaction( 'W/O', 'WO', _woNumber, ('Post Other Cost ' || item_number || ' ' || _sense || ' Manufacturing'), getPrjAccntId(wo_prj_id, costelem_exp_accnt_id), getPrjAccntId(wo_prj_id,costcat_wip_accnt_id), _invhistid, (itemcost_stdcost * _parentQty), pGlDistTS::DATE ) FROM wo, costelem, itemcost, costcat, itemsite, item WHERE ((wo_id=pWoid) AND (wo_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (costelem_id = itemcost_costelem_id) AND (itemcost_item_id = itemsite_item_id) AND (itemsite_costcat_id = costcat_id) AND (costelem_exp_accnt_id) IS NOT NULL AND (costelem_sys = false)); --End -- Make sure the W/O is at issue status UPDATE wo SET wo_status='I' WHERE (wo_id=pWoid); RETURN _itemlocSeries; END; $_$; cDROP FUNCTION public.postproduction(integer, numeric, boolean, integer, timestamp with time zone); publicadminfalse84623e125579185Gpostproduction(integer, numeric, boolean, boolean, integer, text, text)FUNCTIONCREATE FUNCTION postproduction(integer, numeric, boolean, boolean, integer, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'postProduction(INTEGER, NUMERIC, BOOLEAN, BOOLEAN, INTEGER, TEXT, TEXT) is deprecated. please use postProduction(INTEGER, NUMERIC, BOOLEAN, INTEGER, TIMESTAMP WITH TIME ZONE) instead'; RETURN postProduction($1, $2, $3, $5, now()); END; $_$; ^DROP FUNCTION public.postproduction(integer, numeric, boolean, boolean, integer, text, text); publicadminfalse46238f125579186postreceipt(integer, integer)FUNCTIONfCREATE FUNCTION postreceipt(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE precvid ALIAS FOR $1; _itemlocSeries INTEGER := COALESCE($2, 0); _freightAccnt INTEGER; _glDate TIMESTAMP WITH TIME ZONE; _o RECORD; _ordertypeabbr TEXT; _r RECORD; _ra RECORD; _recvinvqty NUMERIC := 0.00; _recvvalue NUMERIC := 0.00; _pricevar NUMERIC := 0.00; _tmp INTEGER; _toitemitemid INTEGER; _coheadid INTEGER; _coitemid INTEGER; _linenumber INTEGER; _invhistid INTEGER; _shipheadid INTEGER; _ship BOOLEAN; _i RECORD; BEGIN SELECT recv_id, recv_order_type, recv_orderitem_id, recv_qty, round(currToBase(recv_freight_curr_id, recv_freight, recv_date::DATE), 2) AS recv_freight_base, recv_freight, recv_freight_curr_id, recv_date, recv_gldistdate, itemsite_id, itemsite_item_id, item_inv_uom_id, itemsite_costmethod, itemsite_controlmethod, vend_name, item_number, item_fractional INTO _r FROM recv LEFT OUTER JOIN itemsite ON (recv_itemsite_id=itemsite_id) LEFT OUTER JOIN item ON (itemsite_item_id=item_id) LEFT OUTER JOIN vendinfo ON (recv_vend_id=vend_id) WHERE ((recv_id=precvid) AND (NOT recv_posted)); IF (NOT FOUND) THEN IF (_itemlocSeries = 0) THEN RETURN -10; END IF; RETURN _itemlocSeries; ELSEIF (_r.recv_qty <= 0) THEN RETURN -11; ELSIF (_r.recv_order_type ='PO') THEN _ordertypeabbr := ('P/O for ' || _r.vend_name || ' for item ' || _r.item_number); SELECT pohead_number AS orderhead_number, poitem_id AS orderitem_id, poitem_linenumber AS orderitem_linenumber, currToBase(pohead_curr_id, COALESCE(recv_purchcost, poitem_unitprice), recv_date::DATE) AS item_unitprice_base, poitem_invvenduomratio AS invvenduomratio, pohead_orderdate AS orderdate, pohead_dropship, poitem_prj_id AS prj_id INTO _o FROM recv, pohead, poitem WHERE ((recv_orderitem_id=poitem_id) AND (poitem_pohead_id=pohead_id) AND (NOT recv_posted) AND (recv_id=precvid)); ELSIF (_r.recv_order_type ='RA') THEN _ordertypeabbr := 'R/A for item ' || _r.item_number; SELECT rahead_id AS orderhead_id, rahead_number AS orderhead_number, raitem_id AS orderitem_id, raitem_linenumber AS orderitem_linenumber, currToBase(rahead_curr_id, raitem_unitprice, recv_date::DATE) AS item_unitprice_base, raitem_qty_invuomratio AS invvenduomratio, rahead_authdate AS orderdate, raitem_unitcost AS unitcost, rahead_prj_id AS prj_id INTO _o FROM recv, rahead, raitem WHERE ((recv_orderitem_id=raitem_id) AND (raitem_rahead_id=rahead_id) AND (NOT recv_posted) AND (recv_id=precvid)); ELSIF (_r.recv_order_type ='TO') THEN _ordertypeabbr := 'T/O for item ' || _r.item_number; SELECT tohead_number AS orderhead_number, toitem_id AS orderitem_id, toitem_linenumber AS orderitem_linenumber, toitem_stdcost AS item_unitprice_base, 1.0 AS invvenduomratio, tohead_orderdate AS orderdate, NULL AS prj_id INTO _o FROM recv, tohead, toitem WHERE ((recv_orderitem_id=toitem_id) AND (toitem_tohead_id=tohead_id) AND (NOT recv_posted) AND (recv_id=precvid)); ELSE RETURN -13; -- don't know how to handle this order type END IF; IF (NOT FOUND) THEN IF (_itemlocSeries = 0) THEN RETURN -10; END IF; RETURN _itemlocSeries; END IF; IF (_itemlocSeries = 0) THEN _itemlocSeries := NEXTVAL('itemloc_series_seq'); ELSEIF (_itemlocSeries < 0) THEN RETURN _itemlocSeries; END IF; _glDate := COALESCE(_r.recv_gldistdate, _r.recv_date); _recvinvqty := roundQty(_r.item_fractional, (_r.recv_qty * _o.invvenduomratio)); IF ( (_r.recv_order_type = 'PO') AND (_r.itemsite_id = -1 OR _r.itemsite_id IS NULL OR _r.itemsite_controlmethod = 'N') ) THEN IF (_r.itemsite_id IS NOT NULL) THEN SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'), 'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Non-Controlled Inventory from ' || _ordertypeabbr, costcat_liability_accnt_id, getPrjAccntId(_o.prj_id, costcat_exp_accnt_id), -1, round((_o.item_unitprice_base * _r.recv_qty),2), _glDate::DATE, false ) INTO _tmp FROM poitem, itemsite, costcat WHERE((poitem_itemsite_id=itemsite_id) AND (itemsite_costcat_id=costcat_id) AND (poitem_id=_o.orderitem_id)); ELSE SELECT insertGLTransaction(fetchJournalNumber('GL-MISC'), 'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Non-Inventory from ' || 'P/O for ' || _r.vend_name || ' for ' || expcat_code, expcat_liability_accnt_id, getPrjAccntId(_o.prj_id, expcat_exp_accnt_id), -1, round((_o.item_unitprice_base * _r.recv_qty),2), _glDate::DATE, false ) INTO _tmp FROM poitem, expcat WHERE((poitem_expcat_id=expcat_id) AND (poitem_id=_o.orderitem_id)); END IF; IF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction RETURN _tmp; ELSE -- Posting to trial balance is deferred to prevent locking INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries) VALUES ( _tmp, _itemlocSeries ); END IF; SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'), 'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Non-Inventory Freight from ' || _ordertypeabbr, expcat_liability_accnt_id, getPrjAccntId(_o.prj_id, expcat_freight_accnt_id), -1, _r.recv_freight_base, _glDate::DATE, false ), expcat_freight_accnt_id INTO _tmp, _freightAccnt FROM poitem, expcat WHERE((poitem_expcat_id=expcat_id) AND (poitem_id=_o.orderitem_id)); IF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction RETURN _tmp; ELSE -- Posting to trial balance is deferred to prevent locking INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries) VALUES ( _tmp, _itemlocSeries ); END IF; _recvvalue := ROUND((_o.item_unitprice_base * _r.recv_qty),2); UPDATE poitem SET poitem_qty_received = (poitem_qty_received + _r.recv_qty), poitem_freight_received = (poitem_freight_received + _r.recv_freight) WHERE (poitem_id=_o.orderitem_id); ELSEIF ( (_r.recv_order_type = 'RA') AND (_r.itemsite_id = -1 OR _r.itemsite_id IS NULL) ) THEN RAISE WARNING 'itemsite controlmethod is %, cannot post receipt.', _r.itemsite_controlmethod; RETURN -14; -- otherwise how do we get the accounts? ELSEIF ( (_r.recv_order_type = 'TO') AND (_r.itemsite_id = -1 OR _r.itemsite_id IS NULL) ) THEN RAISE WARNING 'itemsite missing'; RETURN -14; -- otherwise how do we get the accounts? ELSE -- not ELSIF: some code is shared between diff order types IF (_r.recv_order_type = 'PO') THEN SELECT postInvTrans( itemsite_id, 'RP'::TEXT, _recvinvqty, 'S/R'::TEXT, _r.recv_order_type::TEXT, _o.orderhead_number::TEXT || '-' || _o.orderitem_linenumber::TEXT, ''::TEXT, 'Receive Inventory from ' || _ordertypeabbr, costcat_asset_accnt_id, costcat_liability_accnt_id, _itemlocSeries, _glDate, round((_o.item_unitprice_base * _r.recv_qty),2) -- always passing this in since it is ignored if it is not average costed item ) INTO _tmp FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_r.itemsite_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Could not post inventory transaction: no cost category found for itemsite_id %', _r.itemsite_id; ELSIF (_tmp < -1) THEN -- less than -1 because -1 means it is a none controlled item IF(_tmp = -3) THEN RETURN -12; -- The GL trans value was 0 which means we likely do not have a std cost END IF; RETURN _tmp; END IF; -- If the 'Purchase Price Variance on Receipt' option is true IF (fetchMetricBool('RecordPPVonReceipt')) THEN _invhistid := _tmp; -- Find the difference in the purchase price value expected from the P/O and the value of the transaction SELECT ((_o.item_unitprice_base * _r.recv_qty) - (invhist_value_after - invhist_value_before)) INTO _pricevar FROM invhist WHERE (invhist_id = _invhistid); -- If difference exists then IF (_pricevar <> 0.00) THEN -- Record an additional GL Transaction for the purchase price variance SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'), 'S/R', _r.recv_order_type, _o.orderhead_number, 'Purchase price variance adjusted for P/O ' || _o.orderhead_number || ' for item ' || _r.item_number, costcat_liability_accnt_id, getPrjAccntId(_o.prj_id, costcat_purchprice_accnt_id), -1, _pricevar, _glDate::DATE, false ) INTO _tmp FROM itemsite, costcat WHERE ((itemsite_costcat_id=costcat_id) AND (itemsite_id=_r.itemsite_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Could not insert G/L transaction: no cost category found for itemsite_id %', _r.itemsite_id; ELSIF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction RETURN _tmp; ELSE -- Posting to trial balance is deferred to prevent locking INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries) VALUES ( _tmp, _itemlocSeries ); END IF; END IF; END IF; SELECT insertGLTransaction(fetchJournalNumber('GL-MISC'), 'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Inventory Freight from ' || _o.orderhead_number || ' for item ' || _r.item_number, costcat_liability_accnt_id, getPrjAccntId(_o.prj_id, costcat_freight_accnt_id), -1, _r.recv_freight_base, _glDate::DATE, false ), costcat_freight_accnt_id INTO _tmp, _freightAccnt FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_r.itemsite_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Could not insert G/L transaction: no cost category found for itemsite_id %', _r.itemsite_id; ELSIF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction RETURN _tmp; ELSE -- Posting to trial balance is deferred to prevent locking INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries) VALUES ( _tmp, _itemlocSeries ); END IF; UPDATE poitem SET poitem_qty_received = (poitem_qty_received + _r.recv_qty), poitem_freight_received = (poitem_freight_received + _r.recv_freight) WHERE (poitem_id=_o.orderitem_id); ELSIF (_r.recv_order_type = 'RA') THEN SELECT rahead.*, raitem.* INTO _ra FROM rahead, raitem WHERE ((rahead_id=raitem_rahead_id) AND (raitem_id=_r.recv_orderitem_id)); IF (_r.itemsite_controlmethod = 'N') THEN SELECT insertGLTransaction( fetchJournalNumber('GL-MISC'), 'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Non-Controlled Inventory from ' || _ordertypeabbr, costcat_liability_accnt_id, getPrjAccntId(_o.prj_id, costcat_exp_accnt_id), -1, round((_o.item_unitprice_base * _r.recv_qty),2), _glDate::DATE, false ) INTO _tmp FROM itemsite JOIN costcat ON (costcat_id=itemsite_costcat_id) WHERE(itemsite_id=_r.itemsite_id); IF (NOT FOUND) THEN RAISE EXCEPTION 'Could not post inventory transaction: no cost category found for itemsite_id %', _r.itemsite_id; -- ELSIF (_tmp < -1) THEN -- RETURN _tmp; END IF; ELSE SELECT postInvTrans(_r.itemsite_id, 'RR', _recvinvqty, 'S/R', _r.recv_order_type, _ra.rahead_number::TEXT || '-' || _ra.raitem_linenumber::TEXT, '', 'Receive Inventory from ' || _ordertypeabbr, costcat_asset_accnt_id, CASE WHEN(COALESCE(_ra.raitem_cos_accnt_id, -1) != -1) THEN getPrjAccntId(_o.prj_id, _ra.raitem_cos_accnt_id) WHEN (_ra.raitem_warranty) THEN getPrjAccntId(_o.prj_id, resolveCOWAccount(_r.itemsite_id, _ra.rahead_cust_id, _ra.rahead_saletype_id, _ra.rahead_shipzone_id)) ELSE getPrjAccntId(_o.prj_id, resolveCORAccount(_r.itemsite_id, _ra.rahead_cust_id, _ra.rahead_saletype_id, _ra.rahead_shipzone_id)) END, _itemlocSeries, _glDate, COALESCE(_o.unitcost,stdcost(itemsite_item_id)) * _recvinvqty) INTO _tmp FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_r.itemsite_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Could not post inventory transaction: no cost category found for itemsite_id %', _r.itemsite_id; ELSIF (_tmp < -1) THEN -- less than -1 because -1 means it is a none controlled item IF(_tmp = -3) THEN RAISE WARNING 'The GL trans value was 0 which means we likely do not have a std cost'; RETURN -12; -- The GL trans value was 0 which means we likely do not have a std cost END IF; RETURN _tmp; END IF; END IF; INSERT INTO rahist (rahist_itemsite_id, rahist_date, rahist_descrip, rahist_qty, rahist_uom_id, rahist_source, rahist_source_id, rahist_rahead_id ) VALUES (_r.itemsite_id, _glDate, 'Receive Inventory from ' || _ordertypeabbr, _recvinvqty, _r.item_inv_uom_id, 'RR', _r.recv_id, _ra.rahead_id ); SELECT insertGLTransaction(fetchJournalNumber('GL-MISC'), 'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Inventory Freight from ' || _o.orderhead_number || ' for item ' || _r.item_number, costcat_liability_accnt_id, getPrjAccntId(_o.prj_id, costcat_freight_accnt_id), -1, _r.recv_freight_base, _glDate::DATE, false ), costcat_freight_accnt_id INTO _tmp, _freightAccnt FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_r.itemsite_id) ); IF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction RETURN _tmp; ELSE -- Posting to trial balance is deferred to prevent locking INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries) VALUES ( _tmp, _itemlocSeries ); END IF; INSERT INTO rahist (rahist_date, rahist_descrip, rahist_source, rahist_source_id, rahist_curr_id, rahist_amount, rahist_rahead_id ) VALUES (_glDate, 'Receive Inventory Freight from ' || _ordertypeabbr, 'RR', _r.recv_id, _r.recv_freight_curr_id, _r.recv_freight, _ra.rahead_id ); UPDATE raitem SET raitem_qtyreceived = (raitem_qtyreceived + _r.recv_qty) WHERE (raitem_id=_o.orderitem_id); -- Expire date doesn't mean anything once the RA is received -- WARNING: INSERTING 'NULL' MIGHT CAUSE PROBLEMS!! UPDATE rahead SET rahead_expiredate = NULL WHERE (rahead_id=_o.orderhead_id); -- Look for 'ship' lines SELECT (count(*) > 0) INTO _ship FROM raitem WHERE ((raitem_disposition = 'S') AND (raitem_new_coitem_id IS NULL) AND (raitem_rahead_id=_ra.rahead_id)); -- If receiving a qty on a shippable and upon receipt item, create coitem IF ((_ra.rahead_timing='R') AND (_ship OR ( (_ra.raitem_disposition IN ('P','V')) AND (_ra.raitem_new_coitem_id IS NULL) AND (_ra.raitem_qtyauthorized > 0)))) THEN IF (_ra.rahead_new_cohead_id IS NOT NULL) THEN _coheadid = _ra.rahead_new_cohead_id; ELSE -- No header, so create a Sales Order header first. SELECT nextval('cohead_cohead_id_seq') INTO _coheadid; INSERT INTO cohead ( cohead_id,cohead_number,cohead_cust_id,cohead_custponumber, cohead_orderdate,cohead_salesrep_id,cohead_terms_id, cohead_shipvia,cohead_shipto_id,cohead_shiptoname, cohead_shiptoaddress1,cohead_shiptoaddress2,cohead_shiptoaddress3, cohead_shiptocity,cohead_shiptostate,cohead_shiptozipcode, cohead_shiptocountry,cohead_freight,cohead_shiptophone, cohead_shipto_cntct_id, cohead_shipto_cntct_honorific, cohead_shipto_cntct_first_name, cohead_shipto_cntct_middle, cohead_shipto_cntct_last_name, cohead_shipto_cntct_suffix, cohead_shipto_cntct_phone, cohead_shipto_cntct_title, cohead_shipto_cntct_fax, cohead_shipto_cntct_email, cohead_shipchrg_id, cohead_shipform_id,cohead_billtoname, cohead_billtoaddress1,cohead_billtoaddress2,cohead_billtoaddress3, cohead_billtocity,cohead_billtostate,cohead_billtozipcode, cohead_billtocountry,cohead_misc_accnt_id,cohead_misc_descrip, cohead_commission,cohead_holdtype,cohead_prj_id,cohead_shipcomplete, cohead_curr_id,cohead_taxzone_id,cohead_saletype_id,cohead_shipzone_id) SELECT _coheadid,fetchsonumber(),rahead_cust_id,rahead_custponumber, current_date,rahead_salesrep_id,COALESCE(cohead_terms_id,cust_terms_id), COALESCE(cohead_shipvia,cust_shipvia),rahead_shipto_id,rahead_shipto_name, rahead_shipto_address1,rahead_shipto_address2,rahead_shipto_address3, rahead_shipto_city,rahead_shipto_state,rahead_shipto_zipcode, rahead_shipto_country,0,COALESCE(cohead_shiptophone,''), cntct_id, cntct_honorific, cntct_first_name, cntct_middle, cntct_last_name, cntct_suffix, cntct_phone, cntct_title, cntct_fax, cntct_email, COALESCE(cohead_shipchrg_id,cust_shipchrg_id), COALESCE(cohead_shipform_id,cust_shipform_id), rahead_billtoname,rahead_billtoaddress1,rahead_billtoaddress2,rahead_billtoaddress3, rahead_billtocity,rahead_billtostate,rahead_billtozip, rahead_billtocountry,NULL,'',rahead_commission, 'N', rahead_prj_id, COALESCE(cohead_shipcomplete, CASE WHEN cust_partialship THEN false ELSE true END),rahead_curr_id,rahead_taxzone_id,rahead_saletype_id,rahead_shipzone_id FROM rahead JOIN custinfo ON (rahead_cust_id=cust_id) LEFT OUTER JOIN cohead ON (rahead_orig_cohead_id=cohead_id) LEFT OUTER JOIN shiptoinfo ON (rahead_shipto_id=shipto_id) LEFT OUTER JOIN cntct ON (shipto_cntct_id=cntct_id) WHERE (rahead_id=_ra.rahead_id); UPDATE rahead SET rahead_new_cohead_id=_coheadid WHERE rahead_id=_ra.rahead_id; END IF; -- Now enter the line item(s) IF (_ra.raitem_disposition IN ('P','V')) AND (_ra.raitem_new_coitem_id IS NULL) AND (_ra.raitem_qtyauthorized > 0) THEN SELECT nextval('coitem_coitem_id_seq') INTO _coitemid; SELECT COALESCE(MAX(coitem_linenumber),0)+1 INTO _linenumber FROM coitem WHERE (coitem_cohead_id=_coheadid); INSERT INTO coitem ( coitem_id,coitem_cohead_id,coitem_linenumber,coitem_itemsite_id, coitem_status,coitem_scheddate,coitem_promdate, coitem_qtyord, coitem_unitcost,coitem_price,coitem_custprice,coitem_qtyshipped, coitem_order_id,coitem_memo,coitem_qtyreturned, coitem_taxtype_id,coitem_qty_uom_id,coitem_qty_invuomratio, coitem_price_uom_id,coitem_price_invuomratio,coitem_warranty, coitem_cos_accnt_id,coitem_order_type, coitem_custpn) SELECT _coitemid,_coheadid,_linenumber,_ra.raitem_coitem_itemsite_id, 'O',_ra.raitem_scheddate,_ra.raitem_scheddate,_ra.raitem_qtyauthorized, stdcost(itemsite_item_id),COALESCE(_ra.raitem_saleprice,0),0,0, -1,_ra.raitem_notes,0, _ra.raitem_taxtype_id,_ra.raitem_qty_uom_id,_ra.raitem_qty_invuomratio, _ra.raitem_price_uom_id,_ra.raitem_price_invuomratio,_ra.raitem_warranty, _ra.raitem_cos_accnt_id, CASE WHEN itemsite_createwo THEN 'W' ELSE NULL END, _ra.raitem_custpn FROM itemsite WHERE (itemsite_id=_ra.raitem_coitem_itemsite_id); UPDATE raitem SET raitem_new_coitem_id=_coitemid WHERE (raitem_id=_ra.raitem_id); END IF; -- Create items to ship that have no direct relation to receipts. IF (_ship) THEN FOR _i IN SELECT raitem_id FROM raitem WHERE ((raitem_rahead_id=_ra.rahead_id) AND (raitem_disposition = 'S') AND (raitem_new_coitem_id IS NULL)) LOOP SELECT nextval('coitem_coitem_id_seq') INTO _coitemid; SELECT COALESCE(MAX(coitem_linenumber),0)+1 INTO _linenumber FROM coitem WHERE (coitem_cohead_id=_coheadid); INSERT INTO coitem ( coitem_id,coitem_cohead_id,coitem_linenumber,coitem_itemsite_id, coitem_status,coitem_scheddate,coitem_promdate, coitem_qtyord, coitem_unitcost,coitem_price,coitem_custprice,coitem_qtyshipped, coitem_order_id,coitem_memo,coitem_qtyreturned, coitem_taxtype_id,coitem_qty_uom_id,coitem_qty_invuomratio, coitem_price_uom_id,coitem_price_invuomratio,coitem_warranty, coitem_cos_accnt_id,coitem_order_type,coitem_custpn) SELECT _coitemid,_coheadid,_linenumber,raitem_coitem_itemsite_id, 'O',raitem_scheddate,raitem_scheddate,raitem_qtyauthorized, stdcost(itemsite_item_id),COALESCE(raitem_saleprice,0),0,0, -1,raitem_notes,0, raitem_taxtype_id,raitem_qty_uom_id,raitem_qty_invuomratio, raitem_price_uom_id,raitem_price_invuomratio,raitem_warranty, raitem_cos_accnt_id, CASE WHEN itemsite_createwo THEN 'W' ELSE NULL END,raitem_custpn FROM raitem JOIN itemsite ON (itemsite_id=raitem_itemsite_id) WHERE (raitem_id=_i.raitem_id); UPDATE raitem SET raitem_new_coitem_id=_coitemid WHERE (raitem_id=_i.raitem_id); END LOOP; END IF; END IF; ELSIF (_r.recv_order_type = 'TO' AND fetchMetricBool('MultiWhs')) THEN SELECT interWarehouseTransfer(toitem_item_id, tohead_trns_warehous_id, tohead_dest_warehous_id, _r.recv_qty, 'TO', formatToNumber(toitem_id), 'Receive from Transit To Dest Warehouse', _itemlocSeries, _glDate ) INTO _tmp FROM tohead, toitem WHERE ((tohead_id=toitem_tohead_id) AND (toitem_id=_r.recv_orderitem_id)); IF (_tmp < 0) THEN RETURN _tmp; END IF; SELECT insertGLTransaction(fetchJournalNumber('GL-MISC'), 'S/R', _r.recv_order_type, _o.orderhead_number, 'Receive Inventory Freight from ' || _o.orderhead_number || ' for item ' || _r.item_number, costcat_toliability_accnt_id, costcat_freight_accnt_id, -1, _r.recv_freight_base, _glDate::DATE, false ), costcat_freight_accnt_id INTO _tmp, _freightAccnt FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_r.itemsite_id) ); IF (_tmp < 0 AND _tmp != -3) THEN -- error but not 0-value transaction RETURN _tmp; ELSE -- Posting to trial balance is deferred to prevent locking INSERT INTO itemlocpost ( itemlocpost_glseq, itemlocpost_itemlocseries) VALUES ( _tmp, _itemlocSeries ); END IF; UPDATE toitem SET toitem_qty_received = (toitem_qty_received + _r.recv_qty), toitem_freight_received = (toitem_freight_received + currToCurr(_r.recv_freight_curr_id, toitem_freight_curr_id, _r.recv_freight, _glDate::DATE)) WHERE (toitem_id=_o.orderitem_id); END IF; IF(_r.itemsite_costmethod='A') THEN _recvvalue := ROUND((_o.item_unitprice_base * _r.recv_qty),2); ELSIF (fetchMetricBool('RecordPPVonReceipt')) THEN _recvvalue := ROUND((_o.item_unitprice_base * _r.recv_qty), 2); ELSE _recvvalue := ROUND(stdcost(_r.itemsite_item_id) * _recvinvqty, 2); END IF; END IF; UPDATE recv SET recv_value=_recvvalue, recv_recvcost=_recvvalue / recv_qty, recv_posted=TRUE, recv_gldistdate=_glDate::DATE WHERE (recv_id=precvid); IF (_r.recv_order_type = 'PO') THEN -- If this is a drop-shipped PO, then Issue the item to Shipping and Ship the item IF (_o.pohead_dropship = TRUE) THEN -- Generate the PoItemDropShipped event PERFORM postEvent('PoItemDropShipped', 'P', poitem_id, itemsite_warehous_id, (pohead_number || '-' || poitem_linenumber || ': ' || item_number), NULL, NULL, NULL, NULL) FROM poitem JOIN itemsite ON (itemsite_id=poitem_itemsite_id) JOIN item ON (item_id=itemsite_item_id) JOIN pohead ON (pohead_id=poitem_pohead_id) WHERE (poitem_id=_o.orderitem_id) AND (poitem_duedate <= (CURRENT_DATE + itemsite_eventfence)); END IF; END IF; RETURN _itemlocSeries; END; $_$; 4DROP FUNCTION public.postreceipt(integer, integer); publicadminfalse84623t125579188$postreceipts(text, integer, integer)FUNCTIONCREATE FUNCTION postreceipts(text, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; porderid ALIAS FOR $2; _itemlocSeries INTEGER := $3; _qtyToRecv NUMERIC; _r RECORD; BEGIN SELECT SUM(qtyToReceive(pordertype, recv_orderitem_id)) INTO _qtyToRecv FROM recv, orderitem WHERE ((recv_orderitem_id=orderitem_id) AND (recv_order_type=pordertype) AND (orderitem_orderhead_type=pordertype) AND (orderitem_orderhead_id=porderid)); IF (_qtyToRecv <= 0) THEN RETURN -11; END IF; IF (_itemlocSeries IS NULL OR _itemlocSeries <= 0) THEN _itemlocSeries := NEXTVAL('itemloc_series_seq'); END IF; FOR _r IN SELECT postReceipt(recv_id, _itemlocSeries) AS postResult FROM recv, orderitem WHERE ((recv_orderitem_id=orderitem_id) AND (orderitem_orderhead_id=porderid) AND (orderitem_orderhead_type=pordertype) AND (NOT recv_posted) -- Check for multiple users receiving the same order AND (recv_trans_usr_name=getEffectiveXtUser()) AND (recv_order_type=pordertype)) LOOP IF (_r.postResult < 0 AND _r.postResult != -11) THEN RETURN _r.postResult; -- fail on 1st error but ignore lines with qty == 0 END IF; END LOOP; RETURN _itemlocSeries; END; $_$; ;DROP FUNCTION public.postreceipts(text, integer, integer); publicadminfalse84623u125579189postsogltransactions()FUNCTIONCREATE FUNCTION postsogltransactions() RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN UPDATE gltrans SET gltrans_exported=TRUE WHERE ( (NOT gltrans_exported) AND (gltrans_source='A/R') AND (gltrans_doctype IN ('IN', 'CM')) ); RETURN TRUE; END; $$; -DROP FUNCTION public.postsogltransactions(); publicadminfalse84623v1255791907postsoitemproduction(integer, timestamp with time zone)FUNCTIONACREATE FUNCTION postsoitemproduction(integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoitemId ALIAS FOR $1; pGlDistTS ALIAS FOR $2; _qty NUMERIC; BEGIN -- Issuing all, so determine line balance SELECT noNeg( coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - ( SELECT COALESCE(SUM(shipitem_qty), 0) FROM shipitem, shiphead WHERE ((shipitem_orderitem_id=coitem_id) AND (shipitem_shiphead_id=shiphead_id) AND (NOT shiphead_shipped) ) ) ) INTO _qty FROM coitem WHERE (coitem_id=pSoitemId); RETURN postSoItemProduction($1, _qty, $2); END; $_$; NDROP FUNCTION public.postsoitemproduction(integer, timestamp with time zone); publicadminfalse84623w125579191@postsoitemproduction(integer, numeric, timestamp with time zone)FUNCTIONCREATE FUNCTION postsoitemproduction(integer, numeric, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoitemId ALIAS FOR $1; pQty ALIAS FOR $2; pGlDistTS ALIAS FOR $3; _itemlocSeries INTEGER := 0; BEGIN --If this cost method is not Job then we are using the wrong function IF (NOT EXISTS(SELECT itemsite_costmethod FROM coitem,itemsite WHERE ((coitem_id=pSoitemId) AND (coitem_itemsite_id=itemsite_id) AND (itemsite_costmethod = 'J')))) THEN RAISE EXCEPTION 'The postSoLineBalanceProduction function may only be used with Job costed item sites'; END IF; IF (pQty > 0) THEN SELECT COALESCE(postProduction(wo_id, (pQty * coitem_qty_invuomratio), true, 0, pGlDistTS),-1) INTO _itemlocSeries FROM wo, coitem WHERE ((wo_ordid=pSoItemid) AND (wo_ordtype='S') AND (coitem_id=pSoItemid)); UPDATE wo SET wo_status = 'C' WHERE ((wo_ordid=pSoItemid) AND (wo_ordtype='S') AND (wo_qtyrcv >= wo_qtyord)); END IF; RETURN _itemlocSeries; END; $_$; WDROP FUNCTION public.postsoitemproduction(integer, numeric, timestamp with time zone); publicadminfalse84623x125579192"poststandardjournal(integer, date)FUNCTIONOCREATE FUNCTION poststandardjournal(pstdjrnlid integer, pdate date) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN postStandardJournal(pStdjrnlid, pDate, FALSE, fetchGLSequence()); END; $$; JDROP FUNCTION public.poststandardjournal(pstdjrnlid integer, pdate date); publicadminfalse46238z125579193+poststandardjournal(integer, date, integer)FUNCTION^CREATE FUNCTION poststandardjournal(pstdjrnlid integer, pdate date, pglsequence integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN postStandardJournal(pStdjrnlid, pDate, FALSE, pGlSequence); END; $$; _DROP FUNCTION public.poststandardjournal(pstdjrnlid integer, pdate date, pglsequence integer); publicadminfalse46238y125579194+poststandardjournal(integer, date, boolean)FUNCTIONdCREATE FUNCTION poststandardjournal(pstdjrnlid integer, pdate date, preverse boolean) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN postStandardJournal(pStdjrnlid, pDate, pReverse, fetchGLSequence()); END; $$; \DROP FUNCTION public.poststandardjournal(pstdjrnlid integer, pdate date, preverse boolean); publicadminfalse46238{1255791954poststandardjournal(integer, date, boolean, integer)FUNCTIONCREATE FUNCTION poststandardjournal(pstdjrnlid integer, pdate date, preverse boolean, pglsequence integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN INSERT INTO glseries ( glseries_sequence, glseries_source, glseries_doctype, glseries_docnumber, glseries_notes, glseries_accnt_id, glseries_amount, glseries_distdate ) SELECT pGlSequence, 'G/L', 'ST', stdjrnl_name, (COALESCE(stdjrnl_notes, '') || ' ' || COALESCE(stdjrnlitem_notes, '')), stdjrnlitem_accnt_id, CASE WHEN (pReverse=TRUE) THEN (stdjrnlitem_amount * -1) ELSE stdjrnlitem_amount END, pDate FROM stdjrnl JOIN stdjrnlitem ON (stdjrnlitem_stdjrnl_id=stdjrnl_id) WHERE (stdjrnl_id=pStdjrnlid); RETURN pGlSequence; END; $$; qDROP FUNCTION public.poststandardjournal(pstdjrnlid integer, pdate date, preverse boolean, pglsequence integer); publicadminfalse84623|125579196'poststandardjournalgroup(integer, date)FUNCTIONtCREATE FUNCTION poststandardjournalgroup(integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pStdjrnlgrpid ALIAS FOR $1; pDate ALIAS FOR $2; BEGIN RETURN postStandardJournalGroup(pStdjrnlgrpid, pDate, FALSE); END; $_$; >DROP FUNCTION public.poststandardjournalgroup(integer, date); publicadminfalse462381255791970poststandardjournalgroup(integer, date, boolean)FUNCTIONmCREATE FUNCTION poststandardjournalgroup(integer, date, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pStdjrnlgrpid ALIAS FOR $1; pDate ALIAS FOR $2; pReverse ALIAS FOR $3; _r RECORD; _glSequence INTEGER := -1; BEGIN FOR _r IN SELECT stdjrnlgrpitem_id, stdjrnlgrpitem_stdjrnl_id FROM stdjrnlgrpitem WHERE ( (stdjrnlgrpitem_stdjrnlgrp_id=pStdjrnlgrpid) AND (CURRENT_DATE BETWEEN stdjrnlgrpitem_effective AND (stdjrnlgrpitem_expires - 1)) AND ( (stdjrnlgrpitem_toapply = -1) OR (stdjrnlgrpitem_toapply > stdjrnlgrpitem_applied) ) ) LOOP IF (_glSequence = -1) THEN SELECT fetchGLSequence() INTO _glSequence; END IF; PERFORM postStandardJournal(_r.stdjrnlgrpitem_stdjrnl_id, pDate, pReverse, _glSequence); UPDATE stdjrnlgrpitem SET stdjrnlgrpitem_applied=(stdjrnlgrpitem_applied + 1) WHERE (stdjrnlgrpitem_id=_r.stdjrnlgrpitem_id); END LOOP; RETURN _glSequence; END; $_$; GDROP FUNCTION public.poststandardjournalgroup(integer, date, boolean); publicadminfalse46238125579198Jpostvalueintoinvbalance(integer, date, numeric, numeric, numeric, numeric)FUNCTION1 CREATE FUNCTION postvalueintoinvbalance(integer, date, numeric, numeric, numeric, numeric) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteId ALIAS FOR $1; pDate ALIAS FOR $2; pQoh ALIAS FOR $3; pNn ALIAS FOR $4; pOldCost ALIAS FOR $5; pNewCost ALIAS FOR $6; _invbalid INTEGER; _r RECORD; _count INTEGER; _valChange NUMERIC; _nnvalChange NUMERIC; BEGIN -- Grab the costhist record to post SELECT period_id INTO _r FROM period WHERE (pDate BETWEEN period_start AND period_end); GET DIAGNOSTICS _count = ROW_COUNT; -- Find an inventory balance to post into IF ( _count > 0 ) THEN -- Try to find an existing invbal SELECT invbal_id INTO _invbalid FROM invbal WHERE ( (invbal_period_id=_r.period_id) AND (invbal_itemsite_id=pItemsiteId) ); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count = 0) THEN -- Wasn't there, so forward update PERFORM forwardUpdateItemsite(pItemsiteId); -- Try to find an existing invbal again SELECT invbal_id INTO _invbalid FROM invbal WHERE ( (invbal_period_id=_r.period_id) AND (invbal_itemsite_id=pItemsiteId) ); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count = 0) THEN RAISE EXCEPTION 'An inventory balance record was not found for updating standard costs'; END IF; END IF; _valChange := round((pNewCost - pOldCost) * pQoh, 2); _nnvalChange := round((pNewCost - pOldCost) * pNn, 2); -- We found an invbal, update it with the change IF (_valChange > 0) THEN UPDATE invbal SET invbal_value_in = (invbal_value_in + _valChange) WHERE (invbal_id=_invbalid); ELSE UPDATE invbal SET invbal_value_out = (invbal_value_out - _valChange) WHERE (invbal_id=_invbalid); END IF; IF (_nnvalChange > 0) THEN UPDATE invbal SET invbal_nnval_in = (invbal_nnval_in + _nnvalChange) WHERE (invbal_id=_invbalid); ELSE UPDATE invbal SET invbal_nnval_out = (invbal_nnval_out - _nnvalChange) WHERE (invbal_id=_invbalid); END IF; UPDATE invbal SET invbal_value_ending = (invbal_value_beginning + invbal_value_in - invbal_value_out), invbal_nnval_ending = (invbal_nnval_beginning + invbal_nnval_in - invbal_nnval_out), invbal_dirty=true WHERE (invbal_id=_invbalid); ELSE RAISE EXCEPTION 'No period exists for date %.', pDate; END IF; RETURN TRUE; END; $_$; aDROP FUNCTION public.postvalueintoinvbalance(integer, date, numeric, numeric, numeric, numeric); publicadminfalse84623125579199postvoucher(integer, boolean)FUNCTIONuCREATE FUNCTION postvoucher(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVoheadid ALIAS FOR $1; pPostCosts ALIAS FOR $2; BEGIN RETURN postVoucher(pVoheadid, fetchJournalNumber('AP-VO'), pPostCosts); END; $_$; 4DROP FUNCTION public.postvoucher(integer, boolean); publicadminfalse84623125579200&postvoucher(integer, integer, boolean)FUNCTIONECREATE FUNCTION postvoucher(integer, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pVoheadid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pPostCosts ALIAS FOR $3; _sequence INTEGER; _totalAmount_base NUMERIC; _totalAmount NUMERIC; _itemAmount_base NUMERIC; _itemAmount NUMERIC; _totalDiscountableAmount NUMERIC; _test INTEGER; _a RECORD; _d RECORD; _g RECORD; _p RECORD; _r RECORD; _costx RECORD; _pPostCosts BOOLEAN; _pExplain BOOLEAN; _pLowLevel BOOLEAN; _exchGainFreight NUMERIC; _taxBaseValue NUMERIC; _firstExchDateFreight DATE; _tmpTotal NUMERIC; _glDate DATE; BEGIN RAISE DEBUG 'postVoucher(%, %, %)', pVoheadid, pJournalNumber, pPostCosts; _pPostCosts := TRUE; _totalAmount_base := 0; _totalAmount := 0; _totalDiscountableAmount := 0; SELECT fetchGLSequence() INTO _sequence; -- Cache Voucher Infomation SELECT vohead.*, vend_number || '-' || vend_name || ' ' || vohead_reference AS glnotes, COALESCE(pohead_orderdate, vohead_docdate) AS pohead_orderdate, COALESCE(pohead_curr_id, vohead_curr_id) AS pohead_curr_id INTO _p FROM vendinfo, vohead LEFT OUTER JOIN pohead ON (vohead_pohead_id = pohead_id) WHERE ( (vohead_id=pVoheadid) AND (vend_id=vohead_vend_id) ) FOR UPDATE OF vohead; IF (_p.vohead_posted) THEN RAISE EXCEPTION 'Cannot post Voucher #% as it is already posted [xtuple: postVoucher, -10, %]', _p.vohead_number, _p.vohead_number; END IF; _glDate := COALESCE(_p.vohead_gldistdate, _p.vohead_distdate); -- If the vohead_distdate is NULL, assume that this is a NULL vohead and quietly delete it IF (_p.vohead_distdate IS NULL) THEN DELETE FROM vohead WHERE vohead_id = pVoheadid; RETURN 0; END IF; IF (_p.vohead_amount <= 0) THEN RAISE EXCEPTION 'Cannot Post Voucher #% for a negative or zero amount (%) [xtuple: postVoucher, -1, %, %]', _p.vohead_number, _p.vohead_amount, _p.vohead_number, _p.vohead_amount; END IF; -- there is no currency gain/loss on items, see issue 3892, -- but there might be on freight, which is first encountered at p/o receipt SELECT recv_date::DATE INTO _firstExchDateFreight FROM recv WHERE (recv_vohead_id = pVoheadid); SELECT round(SUM(amount),4) INTO _tmpTotal FROM ( SELECT SUM(vodist_amount) AS amount FROM vodist WHERE ( (vodist_vohead_id=pVoheadid) AND (vodist_tax_id=-1) ) UNION ALL SELECT SUM(voitem_freight) AS amount FROM voitem WHERE (voitem_vohead_id=pVoheadid) UNION ALL SELECT SUM(tax*-1) FROM (SELECT round(sum(taxdetail_tax),2) AS tax, currToBase(_p.vohead_curr_id, round(sum(taxdetail_tax),2), _p.vohead_docdate) AS taxbasevalue FROM tax JOIN calculateTaxDetailSummary('VO', pVoheadid, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id, tax_sales_accnt_id ) AS taxdata ) AS data; IF (_tmpTotal IS NULL OR _tmpTotal <= 0) THEN RAISE EXCEPTION 'Cannot Post Voucher #% with negative or zero distributions (%) [xtuple: postVoucher, -2, %, %]', _p.vohead_number, _tmpTotal, _p.vohead_number, _tmpTotal; END IF; IF (_tmpTotal > _p.vohead_amount) THEN RAISE EXCEPTION 'Cannot Post Voucher #% with distributions greater than the voucher amount (% > %) [xtuple: postVoucher, -3, %, %, %]', _p.vohead_number, _tmpTotal, _p.vohead_amount, _p.vohead_number, _tmpTotal, _p.vohead_amount; END IF; IF (_tmpTotal < _p.vohead_amount) THEN RAISE EXCEPTION 'Cannot Post Voucher #% with distributions less than the voucher amount (% < %) [xtuple: postVoucher, -4, %, %, %]', _p.vohead_number, _tmpTotal, _p.vohead_amount, _p.vohead_number, _tmpTotal, _p.vohead_amount; END IF; SELECT DISTINCT poitem_linenumber INTO _test FROM vodist, voitem, poitem WHERE ( (vodist_poitem_id=poitem_id) AND (voitem_poitem_id=poitem_id) AND (voitem_vohead_id=vodist_vohead_id) AND ((poitem_qty_received - poitem_qty_vouchered) = 0) AND (vodist_vohead_id=pVoheadid) ) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Cannot Post Voucher #% as one or more of the line items have already been fully vouchered. Check P/O Line #% [postVoucher, -6, %, %]', _p.vohead_number, _test, _p.vohead_number, _test; END IF; -- Start by handling taxes FOR _r IN SELECT tax_sales_accnt_id, round(sum(taxdetail_tax),2) AS tax, currToBase(_p.vohead_curr_id, round(sum(taxdetail_tax),2), _p.vohead_docdate) AS taxbasevalue FROM tax JOIN calculateTaxDetailSummary('VO', pVoheadid, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id, tax_sales_accnt_id LOOP PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', _p.vohead_number, _r.tax_sales_accnt_id, _r.taxbasevalue, _glDate, _p.glnotes ); RAISE DEBUG 'postVoucher: _r.tax=%', _r.tax; _totalAmount_base := (_totalAmount_base - _r.taxbasevalue); _totalAmount := (_totalAmount - _r.tax); END LOOP; -- Update item tax records with posting data UPDATE voitemtax SET taxhist_docdate=_p.vohead_docdate, taxhist_distdate=_glDate, taxhist_curr_id=_p.vohead_curr_id, taxhist_curr_rate=curr_rate, taxhist_journalnumber=pJournalNumber FROM vohead JOIN voitem ON (vohead_id=voitem_vohead_id), curr_rate WHERE ((vohead_id=pVoheadId) AND (taxhist_parent_id=voitem_id) AND (_p.vohead_curr_id=curr_id) AND (_p.vohead_docdate BETWEEN curr_effective AND curr_expires) ); -- Update Misc distributions with posting data UPDATE voheadtax SET taxhist_docdate=_p.vohead_docdate, taxhist_distdate=_glDate, taxhist_curr_id=_p.vohead_curr_id, taxhist_curr_rate=curr_rate, taxhist_journalnumber=pJournalNumber FROM curr_rate WHERE ((taxhist_parent_id=pVoheadid) AND (_p.vohead_curr_id=curr_id) AND (_p.vohead_docdate BETWEEN curr_effective AND curr_expires) ); -- Loop through the vodist records for the passed vohead that -- are posted against a P/O Item FOR _g IN SELECT DISTINCT poitem_id, voitem_id, voitem_qty, poitem_expcat_id, poitem_invvenduomratio, poitem_prj_id, COALESCE(itemsite_id, -1) AS itemsiteid, COALESCE(itemsite_costcat_id, -1) AS costcatid, COALESCE(itemsite_item_id, -1) AS itemsite_item_id, COALESCE(item_type, '') AS item_type, (SELECT SUM(value) FROM ( SELECT SUM(recv_value) AS value FROM recv WHERE (recv_voitem_id=voitem_id) UNION SELECT SUM(poreject_value)*-1 AS value FROM poreject WHERE (poreject_voitem_id=voitem_id)) as data) AS value_base, (poitem_freight_received - poitem_freight_vouchered) / (poitem_qty_received - poitem_qty_vouchered) * voitem_qty AS vouchered_freight, currToBase(_p.pohead_curr_id, (poitem_freight_received - poitem_freight_vouchered) / (poitem_qty_received - poitem_qty_vouchered) * voitem_qty, _firstExchDateFreight ) AS vouchered_freight_base, voitem_freight, currToBase(_p.vohead_curr_id, voitem_freight, _p.vohead_distdate) AS voitem_freight_base FROM vodist, voitem, poitem LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id) LEFT OUTER JOIN item ON (item_id=itemsite_item_id) WHERE ( (vodist_poitem_id=poitem_id) AND (voitem_poitem_id=poitem_id) AND (voitem_vohead_id=vodist_vohead_id) AND (vodist_vohead_id=pVoheadid)) LOOP -- Grab the G/L Accounts IF (_g.costcatid = -1) THEN SELECT getPrjAccntId(_g.poitem_prj_id, pp.accnt_id) AS pp_accnt_id, lb.accnt_id AS lb_accnt_id, fr.accnt_id AS freight_accnt_id INTO _a FROM expcat, accnt AS pp, accnt AS lb, accnt AS fr WHERE ( (expcat_purchprice_accnt_id=pp.accnt_id) AND (expcat_liability_accnt_id=lb.accnt_id) AND (expcat_freight_accnt_id=fr.accnt_id) AND (expcat_id=_g.poitem_expcat_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Post Voucher #% due to unassigned G/L Accounts [xtuple: postVoucher, -7, %]', _p.vohead_number, _p.vohead_number; END IF; ELSE SELECT getPrjAccntId(_g.poitem_prj_id, costcat_purchprice_accnt_id) AS pp_accnt_id, getPrjAccntId(_g.poitem_prj_id, costcat_liability_accnt_id) AS lb_accnt_id, getPrjAccntId(_g.poitem_prj_id, costcat_freight_accnt_id) AS freight_accnt_id INTO _a FROM costcat WHERE (costcat_id=_g.costcatid); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Post Voucher #% due to unassigned G/L Accounts [xtuple: postVoucher, -8, %]', _p.vohead_number, _p.vohead_number; END IF; END IF; -- Clear the Item Amount accumulator _itemAmount_base := 0; _itemAmount := 0; -- Figure out the total posted value for this line item FOR _d IN SELECT vodist_id, vodist_amount, vodist_discountable, _p.vohead_curr_id, vodist_costelem_id, currToBase(_p.vohead_curr_id, vodist_amount, _p.vohead_distdate) AS vodist_amount_base FROM vodist WHERE ( (vodist_vohead_id=pVoheadid) AND (vodist_poitem_id=_g.poitem_id) ) LOOP _pExplain := FALSE; SELECT * INTO _costx FROM itemcost WHERE ( (itemcost_item_id = _g.itemsite_item_id) AND (itemcost_costelem_id = _d.vodist_costelem_id) ); IF (FOUND) THEN _pExplain := _costx.itemcost_lowlevel; END IF; -- Post the cost to the Actual if requested -- and item type is not manufactured -- IF ( (pPostCosts) AND (_d.vodist_costelem_id <> -1) ) THEN IF ( (_d.vodist_costelem_id <> -1) AND (_g.itemsite_item_id <> -1) AND (_g.item_type <> 'M') ) THEN PERFORM updateCost( _g.itemsite_item_id, _d.vodist_costelem_id, _pExplain, (_d.vodist_amount / (_g.voitem_qty * _g.poitem_invvenduomratio)), _p.vohead_curr_id ); END IF; -- Add the Distribution Amount to the Item Amount RAISE DEBUG 'postVoucher: _d.vodist_amount=%', _d.vodist_amount; _itemAmount_base := _itemAmount_base + ROUND(_d.vodist_amount_base, 2); _itemAmount := _itemAmount + _d.vodist_amount; IF (_d.vodist_discountable) THEN _totalDiscountableAmount := (_totalDiscountableAmount + _d.vodist_amount); END IF; END LOOP; -- Distribute from the clearing account PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number), _a.lb_accnt_id, round(_g.value_base + _g.vouchered_freight_base, 2) * -1, _glDate, _p.glnotes ); -- Attribute the correct portion to currency gain/loss _exchGainFreight := 0; SELECT currGain(_p.pohead_curr_id, _g.vouchered_freight, _firstExchDateFreight, _p.vohead_distdate ) INTO _exchGainFreight; IF (round(_exchGainFreight, 2) <> 0) THEN PERFORM insertIntoGLSeries(_sequence, 'A/P', 'VO', text(_p.vohead_number), getGainLossAccntId(_a.lb_accnt_id), round(_exchGainFreight, 2), _glDate, _p.glnotes); END IF; -- Distribute the remaining variance to the Purchase Price Variance account IF (round(_itemAmount_base, 2) <> round(_g.value_base, 2)) THEN _tmpTotal := round(_itemAmount_base, 2) - round(_g.value_base, 2); PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number), _a.pp_accnt_id, _tmpTotal * -1, _glDate, _p.glnotes ); END IF; -- Distribute the remaining freight variance to the Purchase Price Variance account IF (round(_g.voitem_freight_base + _exchGainFreight, 2) <> round(_g.vouchered_freight_base, 2)) THEN _tmpTotal := round(_g.voitem_freight_base + _exchGainFreight, 2) - round(_g.vouchered_freight_base, 2); PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number), _a.freight_accnt_id, _tmpTotal * -1, _glDate, _p.glnotes ); END IF; -- Add the distribution amount to the total amount to distribute RAISE DEBUG 'postVoucher: _itemAmount=%', _itemAmount; _totalAmount_base := (_totalAmount_base + _itemAmount_base + _g.voitem_freight_base); _totalAmount := (_totalAmount + _itemAmount + _g.voitem_freight); -- Post all the Tagged Receivings for this P/O Item as Invoiced and -- record the purchase and receive costs -- Comment out because recv cost is set at receiving now. UPDATE recv SET recv_invoiced=TRUE, recv_recvcost_curr_id=basecurrid(), recv_recvcost=round(_g.value_base / _g.voitem_qty, 2) FROM poitem WHERE ((recv_orderitem_id=poitem_id) AND (recv_order_type='PO') AND (recv_orderitem_id=_g.poitem_id) AND (recv_vohead_id=pVoheadid) ); -- Post all the Tagged Rejections for this P/O Item as Invoiced UPDATE poreject SET poreject_invoiced=TRUE WHERE ( (poreject_poitem_id=_g.poitem_id) AND (poreject_vohead_id=pVoheadid) ); -- Update the qty and freight vouchered fields UPDATE poitem SET poitem_qty_vouchered = (poitem_qty_vouchered + _g.voitem_qty), poitem_freight_vouchered = (poitem_freight_vouchered + _g.vouchered_freight) WHERE (poitem_id=_g.poitem_id); END LOOP; -- Loop through the vodist records for the passed vohead that -- are not posted against a P/O Item -- Skip the tax distributions FOR _d IN SELECT vodist_id, vodist_discountable, currToBase(_p.vohead_curr_id, vodist_amount, _p.vohead_distdate) AS vodist_amount_base, vodist_amount, vodist_accnt_id, vodist_expcat_id FROM vodist WHERE ( (vodist_vohead_id=pVoheadid) AND (vodist_poitem_id=-1) AND (vodist_tax_id=-1) ) LOOP -- Distribute from the misc. account IF (_d.vodist_accnt_id = -1) THEN PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number), expcat_exp_accnt_id, round(_d.vodist_amount_base, 2) * -1, _glDate, _p.glnotes ) FROM expcat WHERE (expcat_id=_d.vodist_expcat_id); ELSE PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number), _d.vodist_accnt_id, round(_d.vodist_amount_base, 2) * -1, _glDate, _p.glnotes ); END IF; -- Add the Distribution Amount to the Total Amount RAISE DEBUG 'postVoucher: _d.vodist_amount=%', _d.vodist_amount; _totalAmount_base := _totalAmount_base + ROUND(_d.vodist_amount_base, 2); _totalAmount := _totalAmount + _d.vodist_amount; IF (_d.vodist_discountable) THEN _totalDiscountableAmount := (_totalDiscountableAmount + _d.vodist_amount); END IF; END LOOP; SELECT insertIntoGLSeries( _sequence, 'A/P', 'VO', text(vohead_number), accnt_id, round(_totalAmount_base, 2), _glDate, _p.glnotes ) INTO _test FROM vohead LEFT OUTER JOIN accnt ON (accnt_id=findAPAccount(vohead_vend_id)) WHERE ( (findAPAccount(vohead_vend_id)=0 OR accnt_id > 0) -- G/L interface might be disabled AND (vohead_id=pVoheadid) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Post Voucher #% due to an unassigned A/P Account [xtuple: postVoucher, -9, %]', _p.vohead_number, _p.vohead_number; END IF; PERFORM postGLSeries(_sequence, pJournalNumber); -- Create the A/P Open Item RAISE DEBUG 'postVoucher: _totalAmount=%, _totalDiscountableAmount=%', _totalAmount, _totalDiscountableAmount; INSERT INTO apopen ( apopen_journalnumber, apopen_docdate, apopen_duedate, apopen_distdate, apopen_open, apopen_terms_id, apopen_vend_id, apopen_doctype, apopen_docnumber, apopen_invcnumber, apopen_ponumber, apopen_reference, apopen_amount, apopen_paid, apopen_notes, apopen_username, apopen_posted, apopen_curr_id, apopen_discountable_amount ) -- TODO: SELECT pJournalNumber, vohead_docdate, vohead_duedate, _glDate, TRUE, vohead_terms_id, vohead_vend_id, 'V', vohead_number, vohead_invcnumber, COALESCE(TEXT(pohead_number), 'Misc.'), vohead_reference, round(_totalAmount, 2), 0, '', getEffectiveXtUser(), FALSE, vohead_curr_id, round(_totalDiscountableAmount, 2) FROM vohead LEFT OUTER JOIN pohead ON (vohead_pohead_id=pohead_id) WHERE (vohead_id=pVoheadid); -- Close all of the P/O Items that should be closed by this Voucher UPDATE poitem SET poitem_status='C' FROM voitem WHERE ( (voitem_poitem_id=poitem_id) AND (voitem_close) AND (voitem_vohead_id=pVoheadid) ); -- Check the P/O items and if they are all closed go ahead -- and close the P/O head. IF ( (SELECT (count(*) < 1) FROM vohead, poitem WHERE ((vohead_pohead_id=poitem_pohead_id) AND (poitem_status<>'C') AND (vohead_id=pVoheadid) ) ) ) THEN PERFORM closePo(vohead_pohead_id) FROM vohead WHERE (vohead_id=pVoheadid); END IF; -- Set the vohead as posted UPDATE vohead SET vohead_posted=TRUE, vohead_gldistdate=_glDate WHERE (vohead_id=pVoheadid); RETURN pJournalNumber; END; $_$; =DROP FUNCTION public.postvoucher(integer, integer, boolean); publicadminfalse46238125579202postvouchers(boolean)FUNCTIONCREATE FUNCTION postvouchers(boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPostCosts ALIAS FOR $1; _journalNumber INTEGER; BEGIN SELECT fetchJournalNumber('AP-VO') INTO _journalNumber; PERFORM postVoucher(vohead_id, _journalNumber, pPostCosts) FROM vohead WHERE (NOT vohead_posted); RETURN _journalNumber; END; $_$; ,DROP FUNCTION public.postvouchers(boolean); publicadminfalse84623125579203primarykeyfields(text, text)FUNCTION@CREATE FUNCTION primarykeyfields(text, text) RETURNS text[] LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSchema ALIAS FOR $1; pRelation ALIAS FOR $2; _colname TEXT; _counter INTEGER := 0; _result TEXT[]; BEGIN EXECUTE 'SELECT ARRAY(SELECT attname FROM pg_attribute JOIN pg_class idx ON (attrelid = idx.oid) JOIN pg_namespace ON (idx.relnamespace = pg_namespace.oid) JOIN pg_index ON (idx.oid = indexrelid) JOIN pg_class tab ON (indrelid = tab.oid) WHERE NOT attisdropped AND nspname = ''' || pSchema || ''' AND indisprimary AND LOWER(tab.relname) = ''' || pRelation || ''' ORDER BY attnum);' INTO _result; RETURN _result; END; $_$; 3DROP FUNCTION public.primarykeyfields(text, text); publicadminfalse84623U&00%FUNCTION primarykeyfields(text, text)COMMENTCOMMENT ON FUNCTION primarykeyfields(text, text) IS 'Return an array containing the names of the primary key fields of pSchema.pRelation. The first key field is in _result[1].'; publicadminfalse1923125579204prj()FUNCTION CREATE FUNCTION prj() RETURNS SETOF prj LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row prj%ROWTYPE; _priv TEXT; _grant BOOLEAN; BEGIN -- This query will give us the most permissive privilege the user has been granted SELECT privilege, granted INTO _priv, _grant FROM privgranted WHERE privilege IN ('MaintainAllProjects','ViewAllProjects','MaintainPersonalProjects','ViewPersonalProjects') ORDER BY granted DESC, sequence LIMIT 1; -- If have an 'All' privilege return all results IF (_priv ~ 'All' AND _grant) THEN FOR _row IN SELECT * FROM prj LOOP RETURN NEXT _row; END LOOP; -- Otherwise if have any other grant, must be personal privilege. ELSIF (_grant) THEN FOR _row IN SELECT * FROM prj WHERE getEffectiveXtUser() IN (prj_owner_username, prj_username) LOOP RETURN NEXT _row; END LOOP; END IF; RETURN; END; $$; DROP FUNCTION public.prj(); publicadminfalse462328608V&00FUNCTION prj()COMMENToCOMMENT ON FUNCTION prj() IS 'A table function that returns Project results according to privilege settings.'; publicadminfalse1924125979205prjtaskTABLECREATE TABLE prjtask ( prjtask_id integer NOT NULL, prjtask_number text NOT NULL, prjtask_name text NOT NULL, prjtask_descrip text, prjtask_prj_id integer NOT NULL, prjtask_anyuser boolean, prjtask_status character(1) NOT NULL, prjtask_hours_budget numeric(18,6) NOT NULL, prjtask_hours_actual numeric(18,6) NOT NULL, prjtask_exp_budget numeric(16,4) NOT NULL, prjtask_exp_actual numeric(16,4) NOT NULL, prjtask_owner_username text, prjtask_start_date date, prjtask_due_date date, prjtask_assigned_date date, prjtask_completed_date date, prjtask_username text, CONSTRAINT prjtask_prjtask_status_check CHECK ((prjtask_status = ANY (ARRAY['P'::bpchar, 'O'::bpchar, 'C'::bpchar]))) ); DROP TABLE public.prjtask; publicadminfalse60938W&00 TABLE prjtaskCOMMENT8COMMENT ON TABLE prjtask IS 'Project Task information'; publicadminfalse211X&00prjtaskACLREVOKE ALL ON TABLE prjtask FROM PUBLIC; REVOKE ALL ON TABLE prjtask FROM admin; GRANT ALL ON TABLE prjtask TO admin; GRANT ALL ON TABLE prjtask TO xtrole; publicadminfalse211125579212 prjtask()FUNCTIONtCREATE FUNCTION prjtask() RETURNS SETOF prjtask LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row prjtask%ROWTYPE; _priv TEXT; _grant BOOLEAN; BEGIN -- This query will give us the most permissive privilege the user has been granted SELECT privilege, granted INTO _priv, _grant FROM privgranted WHERE privilege IN ('MaintainAllProjects','ViewAllProjects','MaintainPersonalProjects','ViewPersonalProjects') ORDER BY granted DESC, sequence LIMIT 1; -- If have an 'All' privilege return all results IF (_priv ~ 'All' AND _grant) THEN FOR _row IN SELECT * FROM prjtask LOOP RETURN NEXT _row; END LOOP; -- Otherwise if have any other grant, must be personal privilege. ELSIF (_grant) THEN FOR _row IN SELECT prjtask.* FROM prjtask JOIN prj ON prj_id=prjtask_prj_id WHERE getEffectiveXtUser() IN (prjtask_owner_username,prjtask_username,prj_username,prj_owner_username) LOOP RETURN NEXT _row; END LOOP; END IF; RETURN; END; $$; DROP FUNCTION public.prjtask(); publicadminfalse462382879Y&00FUNCTION prjtask()COMMENTsCOMMENT ON FUNCTION prjtask() IS 'A table function that returns Project results according to privilege settings.'; publicadminfalse1925125579213purgecreditmemos(date)FUNCTIONWCREATE FUNCTION purgecreditmemos(date) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCutoffDate ALIAS FOR $1; BEGIN DELETE FROM cmitem WHERE (cmitem_id IN ( SELECT cmitem_id FROM cmitem, cmhead WHERE ( (cmitem_cmhead_id=cmhead_id) AND (cmhead_posted) AND (cmhead_printed) AND (cmhead_docdate<=pCutoffDate) AND (checkCreditMemoSitePrivs(cmhead_id)) ) ) ); DELETE FROM cmhead WHERE ( (cmhead_posted) AND (cmhead_printed) AND (cmhead_docdate<=pCutoffDate) AND (checkCreditMemoSitePrivs(cmhead_id)) ); RETURN TRUE; END; $_$; -DROP FUNCTION public.purgecreditmemos(date); publicadminfalse84623125579214purgecrmacctmerge(integer)FUNCTION CREATE FUNCTION purgecrmacctmerge(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pDestid ALIAS FOR $1; _result INTEGER := 0; _tmpcount INTEGER := 0; BEGIN IF EXISTS(SELECT 1 FROM crmacctsel WHERE crmacctsel_dest_crmacct_id=pDestid) THEN DELETE FROM crmacctsel WHERE crmacctsel_dest_crmacct_id = pDestid; GET DIAGNOSTICS _result = ROW_COUNT; ELSIF EXISTS(SELECT 1 FROM mrgundo WHERE mrgundo_base_schema='public' AND mrgundo_base_table='crmacct' AND mrgundo_base_id=pDestid) THEN DELETE FROM crmacct WHERE crmacct_id IN ( SELECT mrgundo_pkey_id FROM mrgundo WHERE mrgundo_schema = 'public' AND mrgundo_table = 'crmacct' and mrgundo_pkey_col = 'crmacct_id' AND mrgundo_col IS NULL AND mrgundo_base_schema = 'public' AND mrgundo_base_table = 'crmacct' AND mrgundo_base_id = pDestid) AND crmacct_id != pDestid; GET DIAGNOSTICS _result = ROW_COUNT; DELETE FROM mrgundo WHERE mrgundo_base_schema ='public' AND mrgundo_base_table ='crmacct' AND mrgundo_base_id = pDestid; GET DIAGNOSTICS _tmpcount = ROW_COUNT; _result := _result + _tmpcount; END IF; RETURN _result; END; $_$; 1DROP FUNCTION public.purgecrmacctmerge(integer); publicadminfalse84623125579215!purgeinvoicerecord(date, integer)FUNCTION!BCREATE FUNCTION purgeinvoicerecord(date, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCutoffDate ALIAS FOR $1; pInvcheadId ALIAS FOR $2; _r RECORD; _ra RECORD; _raheadid INTEGER; _result INTEGER; _debug BOOLEAN := FALSE; BEGIN -- Purge records where the entire Invoice, Billing, Shipper, Sales Order -- chain of associated documents are closed and complete FOR _r IN SELECT invchead_id, cobmisc_id, shiphead_id, ordershipped.cohead_id AS ordship_id, orderinvoiced.cohead_id AS ordinv_id FROM invchead LEFT OUTER JOIN invcitem ON (invcitem_invchead_id=invchead_id) LEFT OUTER JOIN cobmisc ON (cobmisc_invcnumber::TEXT=invchead_invcnumber) LEFT OUTER JOIN shipitem ON (shipitem_invcitem_id=invcitem_id) LEFT OUTER JOIN shiphead ON (shiphead_id=shipitem_shiphead_id) LEFT OUTER JOIN cohead ordershipped ON (ordershipped.cohead_id=shiphead_order_id) LEFT OUTER JOIN coitem ON (coitem_id=invcitem_coitem_id) LEFT OUTER JOIN cohead orderinvoiced ON (orderinvoiced.cohead_id=coitem_cohead_id) WHERE ( (invchead_id = pInvcheadId) AND (invchead_posted) AND (checkInvoiceSitePrivs(invchead_id)) ) GROUP BY invchead_id, cobmisc_id, shiphead_id, ordship_id, ordinv_id LOOP -- Check Billing -- Billing header (cobmisc) must be posted SELECT cobmisc_id INTO _result FROM cobmisc WHERE ( (cobmisc_id=_r.cobmisc_id) AND (NOT cobmisc_posted) ); IF (FOUND) THEN RETURN 'Billing not closed'; END IF; -- Billing line items (cobill), associated Invoice line items, and -- associated Sales Order line items must be closed, posted, and after cutoff date SELECT cobill_id INTO _result FROM cobill JOIN invcitem ON (invcitem_id=cobill_invcitem_id) JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND ((NOT invchead_posted) OR (invchead_invcdate > pCutoffDate)) ) JOIN coitem ON ( (coitem_id=cobill_coitem_id) AND (coitem_status NOT IN ('C', 'X')) ) WHERE (cobill_cobmisc_id=_r.cobmisc_id); IF (FOUND) THEN RETURN 'Invoice/Sales Order associated with Billing not closed'; END IF; -- Check Shipping -- Shipping header (shiphead) must be shipped SELECT shiphead_id INTO _result FROM shiphead WHERE ( (shiphead_id=_r.shiphead_id) AND (NOT shiphead_shipped) ); IF (FOUND) THEN RETURN 'Shipper not closed'; END IF; -- Shipping line items (shipitem) and associated Sales Order line items -- must be closed SELECT shiphead_id INTO _result FROM shiphead, cohead, coitem WHERE ( (shiphead_id=_r.shiphead_id) AND ( (shiphead_order_type='SO') AND (shiphead_order_id=cohead_id) ) AND (coitem_cohead_id=cohead_id) AND (coitem_status NOT IN ('C', 'X')) ); IF (FOUND) THEN RETURN 'Sales Order associated with Shipper not closed'; END IF; -- Shipping line items (shipitem) and associated Invoices must be posted -- and after cutoff date SELECT shiphead_id INTO _result FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id) JOIN invcitem ON (invcitem_id=shipitem_invcitem_id) JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND ((NOT invchead_posted) OR (invchead_invcdate > pCutoffDate)) ) WHERE (shiphead_id=_r.shiphead_id); IF (FOUND) THEN RETURN 'Invoice associated with Shipper not closed'; END IF; -- Check Sales Order -- Sales Order line items (coitem) must be closed SELECT cohead_id INTO _result FROM cohead JOIN coitem ON ( (coitem_cohead_id=cohead_id) AND (coitem_status NOT IN ('C', 'X')) ) WHERE (cohead_id=_r.ordship_id); IF (FOUND) THEN RETURN 'Shipped Sales Order not closed'; END IF; SELECT cohead_id INTO _result FROM cohead JOIN coitem ON ( (coitem_cohead_id=cohead_id) AND (coitem_status NOT IN ('C', 'X')) ) WHERE (cohead_id=_r.ordinv_id); IF (FOUND) THEN RETURN 'Invoiced Sales Order not closed'; END IF; IF (fetchMetricBool('MultiWhs')) THEN -- Check Original Return Authorization and cross check to New Sales Order SELECT rahead_id INTO _result FROM rahead JOIN raitem ON ( (raitem_rahead_id=rahead_id) AND (raitem_status NOT IN ('C', 'X')) ) JOIN coitem ON ( (coitem_id=raitem_new_coitem_id) AND (coitem_status NOT IN ('C', 'X')) ) JOIN invcitem ON (invcitem_coitem_id=coitem_id) JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND ((NOT invchead_posted) OR (invchead_invcdate > pCutoffDate)) ) WHERE (rahead_orig_cohead_id=_r.ordship_id); IF (FOUND) THEN RETURN 'Shipped Original Return Authorization not closed'; END IF; SELECT rahead_id INTO _result FROM rahead JOIN raitem ON ( (raitem_rahead_id=rahead_id) AND (raitem_status NOT IN ('C', 'X')) ) JOIN coitem ON ( (coitem_id=raitem_new_coitem_id) AND (coitem_status NOT IN ('C', 'X')) ) JOIN invcitem ON (invcitem_coitem_id=coitem_id) JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND ((NOT invchead_posted) OR (invchead_invcdate > pCutoffDate)) ) WHERE (rahead_orig_cohead_id=_r.ordinv_id); IF (FOUND) THEN RETURN 'Invoiced Original Return Authorization not closed'; END IF; -- Check New Return Authorization SELECT rahead_id INTO _result FROM rahead JOIN raitem ON ( (raitem_rahead_id=rahead_id) AND (NOT raitem_status IN ('C', 'X')) ) JOIN coitem ON ( (coitem_id=raitem_orig_coitem_id) AND (NOT coitem_status IN ('C', 'X')) ) JOIN invcitem ON (invcitem_coitem_id=coitem_id) JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND ((NOT invchead_posted) OR (invchead_invcdate > pCutoffDate)) ) WHERE (rahead_new_cohead_id=_r.ordship_id); IF (FOUND) THEN RETURN 'Shipped New Return Authorization not closed'; END IF; SELECT rahead_id INTO _result FROM rahead JOIN raitem ON ( (raitem_rahead_id=rahead_id) AND (NOT raitem_status IN ('C', 'X')) ) JOIN coitem ON ( (coitem_id=raitem_orig_coitem_id) AND (NOT coitem_status IN ('C', 'X')) ) JOIN invcitem ON (invcitem_coitem_id=coitem_id) JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND ((NOT invchead_posted) OR (invchead_invcdate > pCutoffDate)) ) WHERE (rahead_new_cohead_id=_r.ordinv_id); IF (FOUND) THEN RETURN 'Invoiced New Return Authorization not closed'; END IF; END IF; -- Check Lot/Serial Registration IF (fetchMetricBool('MultiWhs')) THEN -- Registration associated with Sales Order must be expired SELECT lsreg_id INTO _result FROM lsreg WHERE ( (lsreg_cohead_id=_r.ordship_id) AND (lsreg_expiredate > CURRENT_DATE) ); IF (FOUND) THEN RETURN 'Shipped Sales Order Lot/Serial Registration not closed'; END IF; SELECT lsreg_id INTO _result FROM lsreg WHERE ( (lsreg_cohead_id=_r.ordinv_id) AND (lsreg_expiredate > CURRENT_DATE) ); IF (FOUND) THEN RETURN 'Invoiced Sales Order Lot/Serial Registration not closed'; END IF; -- Registration associated with Shipping must be expired SELECT lsreg_id INTO _result FROM lsreg WHERE ( (lsreg_cohead_id=_r.shiphead_id) AND (lsreg_expiredate > CURRENT_DATE) ); IF (FOUND) THEN RETURN 'Shipper Lot/Serial Registration not closed'; END IF; END IF; IF (fetchMetricBool('MultiWhs')) THEN -- Registration associated with Original Return Authorization must be expired SELECT rahead_id INTO _result FROM rahead JOIN raitem ON (raitem_rahead_id=rahead_id) JOIN raitemls ON (raitemls_raitem_id=raitem_id) JOIN lsreg ON ( (lsreg_ls_id=raitemls_ls_id) AND (lsreg_expiredate > CURRENT_DATE) ) WHERE (rahead_orig_cohead_id=_r.ordship_id); IF (FOUND) THEN RETURN 'Shipped Original Return Authorization Lot/Serial Registration not closed'; END IF; SELECT rahead_id INTO _result FROM rahead JOIN raitem ON (raitem_rahead_id=rahead_id) JOIN raitemls ON (raitemls_raitem_id=raitem_id) JOIN lsreg ON ( (lsreg_ls_id=raitemls_ls_id) AND (lsreg_expiredate > CURRENT_DATE) ) WHERE (rahead_orig_cohead_id=_r.ordinv_id); IF (FOUND) THEN RETURN 'Invoiced Original Return Authorization Lot/Serial Registration not closed'; END IF; -- Registration associated with New Return Authorization must be expired SELECT rahead_id INTO _result FROM rahead JOIN raitem ON (raitem_rahead_id=rahead_id) JOIN raitemls ON (raitemls_raitem_id=raitem_id) JOIN lsreg ON ( (lsreg_ls_id=raitemls_ls_id) AND (lsreg_expiredate > CURRENT_DATE) ) WHERE (rahead_new_cohead_id=_r.ordship_id); IF (FOUND) THEN RETURN 'Shipped New Return Authorization Lot/Serial Registration not closed'; END IF; SELECT rahead_id INTO _result FROM rahead JOIN raitem ON (raitem_rahead_id=rahead_id) JOIN raitemls ON (raitemls_raitem_id=raitem_id) JOIN lsreg ON ( (lsreg_ls_id=raitemls_ls_id) AND (lsreg_expiredate > CURRENT_DATE) ) WHERE (rahead_new_cohead_id=_r.ordinv_id); IF (FOUND) THEN RETURN 'Invoiced New Return Authorization Lot/Serial Registration not closed'; END IF; END IF; -- Cash Advances associated with Sales Order cannot exist SELECT aropenalloc_doc_id INTO _result FROM aropenalloc WHERE ((aropenalloc_doctype='S') AND (aropenalloc_doc_id=_r.ordship_id)); IF (FOUND) THEN RETURN 'Shipped Cash Advance not closed'; END IF; SELECT aropenalloc_doc_id INTO _result FROM aropenalloc WHERE ((aropenalloc_doctype='S') AND (aropenalloc_doc_id=_r.ordinv_id)); IF (FOUND) THEN RETURN 'Invoiced Cash Advance not closed'; END IF; END LOOP; -- Everything is OK, delete the chain FOR _r IN SELECT invchead_id, cobmisc_id, shiphead_id, ordershipped.cohead_id AS ordship_id, orderinvoiced.cohead_id AS ordinv_id FROM invchead LEFT OUTER JOIN invcitem ON (invcitem_invchead_id=invchead_id) LEFT OUTER JOIN cobmisc ON (cobmisc_invcnumber::TEXT=invchead_invcnumber) LEFT OUTER JOIN shipitem ON (shipitem_invcitem_id=invcitem_id) LEFT OUTER JOIN shiphead ON (shiphead_id=shipitem_shiphead_id) LEFT OUTER JOIN cohead ordershipped ON (ordershipped.cohead_id=shiphead_order_id) LEFT OUTER JOIN coitem ON (coitem_id=invcitem_coitem_id) LEFT OUTER JOIN cohead orderinvoiced ON (orderinvoiced.cohead_id=coitem_cohead_id) WHERE ( (invchead_id = pInvcheadId) AND (invchead_posted) AND (checkInvoiceSitePrivs(invchead_id)) ) GROUP BY invchead_id, cobmisc_id, shiphead_id, ordship_id, ordinv_id LOOP IF (fetchMetricBool('MultiWhs')) THEN FOR _ra IN SELECT rahead_id FROM rahead WHERE (rahead_orig_cohead_id=_r.ordship_id) LOOP IF (_debug) THEN RAISE NOTICE 'Deleting Original Return head id %', _ra.rahead_id; END IF; DELETE FROM raitemls WHERE (raitemls_raitem_id IN (SELECT raitem_id FROM raitem WHERE (raitem_rahead_id=_ra.rahead_id))); DELETE FROM rahist WHERE (rahist_rahead_id=_ra.rahead_id); DELETE FROM raitem WHERE (raitem_rahead_id=_ra.rahead_id); DELETE FROM rahead WHERE (rahead_id=_ra.rahead_id); END LOOP; FOR _ra IN SELECT rahead_id FROM rahead WHERE (rahead_orig_cohead_id=_r.ordinv_id) LOOP IF (_debug) THEN RAISE NOTICE 'Deleting Original Return head id %', _ra.rahead_id; END IF; DELETE FROM raitemls WHERE (raitemls_raitem_id IN (SELECT raitem_id FROM raitem WHERE (raitem_rahead_id=_ra.rahead_id))); DELETE FROM rahist WHERE (rahist_rahead_id=_ra.rahead_id); DELETE FROM raitem WHERE (raitem_rahead_id=_ra.rahead_id); DELETE FROM rahead WHERE (rahead_id=_ra.rahead_id); END LOOP; FOR _ra IN SELECT rahead_id FROM rahead WHERE (rahead_new_cohead_id=_r.ordship_id) LOOP IF (_debug) THEN RAISE NOTICE 'Deleting New Return head id %', _ra.rahead_id; END IF; DELETE FROM raitemls WHERE (raitemls_raitem_id IN (SELECT raitem_id FROM raitem WHERE (raitem_rahead_id=_ra.rahead_id))); DELETE FROM rahist WHERE (rahist_rahead_id=_ra.rahead_id); DELETE FROM raitem WHERE (raitem_rahead_id=_ra.rahead_id); DELETE FROM rahead WHERE (rahead_id=_ra.rahead_id); END LOOP; FOR _ra IN SELECT rahead_id FROM rahead WHERE (rahead_new_cohead_id=_r.ordinv_id) LOOP IF (_debug) THEN RAISE NOTICE 'Deleting New Return head id %', _ra.rahead_id; END IF; DELETE FROM raitemls WHERE (raitemls_raitem_id IN (SELECT raitem_id FROM raitem WHERE (raitem_rahead_id=_ra.rahead_id))); DELETE FROM rahist WHERE (rahist_rahead_id=_ra.rahead_id); DELETE FROM raitem WHERE (raitem_rahead_id=_ra.rahead_id); DELETE FROM rahead WHERE (rahead_id=_ra.rahead_id); END LOOP; END IF; IF (fetchMetricBool('MultiWhs')) THEN IF (_debug) THEN RAISE NOTICE 'Deleting Lot/Serial Registrations'; END IF; DELETE FROM lsreg WHERE (lsreg_cohead_id=_r.ordship_id); DELETE FROM lsreg WHERE (lsreg_cohead_id=_r.ordinv_id); DELETE FROM lsreg WHERE (lsreg_shiphead_id=_r.shiphead_id); END IF; IF (_debug) THEN RAISE NOTICE 'Deleting Shipped Sales Order head id %', _r.ordship_id; END IF; DELETE FROM payco WHERE (payco_cohead_id=_r.ordship_id); -- Delete kit components first DELETE FROM coitem WHERE (coitem_cohead_id=_r.ordship_id AND coitem_subnumber > 0); DELETE FROM coitem WHERE (coitem_cohead_id=_r.ordship_id); DELETE FROM cohead WHERE (cohead_id=_r.ordship_id); IF (_debug) THEN RAISE NOTICE 'Deleting Sales Order head id %', _r.ordinv_id; END IF; DELETE FROM payco WHERE (payco_cohead_id=_r.ordinv_id); -- Delete kit components first DELETE FROM coitem WHERE (coitem_cohead_id=_r.ordinv_id AND coitem_subnumber > 0); DELETE FROM coitem WHERE (coitem_cohead_id=_r.ordinv_id); DELETE FROM cohead WHERE (cohead_id=_r.ordinv_id); IF (_debug) THEN RAISE NOTICE 'Deleting Ship head id %', _r.shiphead_id; END IF; DELETE FROM shipitem WHERE (shipitem_shiphead_id=_r.shiphead_id); DELETE FROM pack WHERE (pack_shiphead_id=_r.shiphead_id); DELETE FROM shiphead WHERE (shiphead_id=_r.shiphead_id); IF (_debug) THEN RAISE NOTICE 'Deleting Billing head id %', _r.cobmisc_id; END IF; DELETE FROM cobill WHERE (cobill_cobmisc_id=_r.cobmisc_id); DELETE FROM cobmisc WHERE (cobmisc_id=_r.cobmisc_id); END LOOP; -- Everything is OK, delete the Invoice IF (_debug) THEN RAISE NOTICE 'Deleting Invoice head id %', _r.invchead_id; END IF; DELETE FROM invcitem WHERE (invcitem_invchead_id=_r.invchead_id); DELETE FROM invchead WHERE (invchead_id=_r.invchead_id); RETURN 'Purged'; END; $_$; 8DROP FUNCTION public.purgeinvoicerecord(date, integer); publicadminfalse84623125579217purgeinvoicerecords(date)FUNCTIONCREATE FUNCTION purgeinvoicerecords(date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCutoffDate ALIAS FOR $1; BEGIN -- Remove the shipitem records DELETE FROM shipitem WHERE (shipitem_invcitem_id IN (SELECT invcitem_id FROM invcitem WHERE invcitem_invchead_id IN ( SELECT invchead_id FROM invchead WHERE ( (invchead_invcdate <= pCutoffDate) AND (checkInvoiceSitePrivs(invchead_id)) AND (invchead_posted) ) ) ) ); -- Remove the cobill and cobmisc records DELETE FROM cobill WHERE (cobill_cobmisc_id IN ( SELECT cobmisc_id FROM cobmisc, invchead WHERE ( (invchead_invcnumber=cobmisc_invcnumber::TEXT) AND (checkInvoiceSitePrivs(invchead_id)) AND (cobmisc_invcdate <= pCutoffDate) AND (cobmisc_posted)) ) ); DELETE FROM cobmisc WHERE ( (checkInvoiceSitePrivs(getInvcheadId(cobmisc_invcnumber::TEXT))) AND (cobmisc_invcdate <= pCutoffDate) AND (cobmisc_posted) ); -- Remove the invchead and invcitem records DELETE FROM invcitem WHERE (invcitem_invchead_id IN ( SELECT invchead_id FROM invchead WHERE ( (invchead_invcdate <= pCutoffDate) AND (checkInvoiceSitePrivs(invchead_id)) AND (invchead_posted) ) ) ); DELETE FROM invchead WHERE ( (invchead_invcdate <= pCutoffDate) AND (checkInvoiceSitePrivs(invchead_id)) AND (invchead_posted) ); RETURN 1; END; $_$; 0DROP FUNCTION public.purgeinvoicerecords(date); publicadminfalse84623125579218$purgepostedcountslips(date, integer)FUNCTIONCREATE FUNCTION purgepostedcountslips(date, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCutoffDate ALIAS FOR $1; pWarehousid ALIAS FOR $2; BEGIN IF (pWarehousid = -1) THEN DELETE FROM cntslip WHERE (cntslip_id IN ( SELECT cntslip_id FROM cntslip, invcnt WHERE ( (cntslip_cnttag_id=invcnt_id) AND (invcnt_posted) AND (cntslip_posted) AND (date(invcnt_postdate) <= pCutoffDate) ) ) ); ELSE DELETE FROM cntslip WHERE (cntslip_id IN ( SELECT cntslip_id FROM invcnt, itemsite WHERE ( (cntslip_cnttag_id=invcnt_id) AND (invcnt_posted) AND (cntslip_posted) AND (invcnt_itemsite_id=itemsite_id) AND (date(invcnt_postdate) <= pCutoffDate) AND (itemsite_warehous_id=pWarehousid) ) ) ); END IF; RETURN 1; END; $_$; ;DROP FUNCTION public.purgepostedcountslips(date, integer); publicadminfalse84623125579219#purgepostedcounttags(date, integer)FUNCTIONCREATE FUNCTION purgepostedcounttags(date, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCutoffDate ALIAS FOR $1; pWarehousid ALIAS FOR $2; BEGIN IF (pWarehousid = -1) THEN DELETE FROM cntslip WHERE (cntslip_cnttag_id IN ( SELECT invcnt_id FROM invcnt WHERE ( (invcnt_posted) AND (date(invcnt_postdate) <= pCutoffDate) ) ) ); DELETE FROM invcnt WHERE ((invcnt_posted) AND (date(invcnt_postdate) <= pCutoffDate)); ELSE DELETE FROM cntslip WHERE (cntslip_cnttag_id IN ( SELECT invcnt_id FROM invcnt, itemsite WHERE ( (invcnt_posted) AND (invcnt_itemsite_id=itemsite_id) AND (date(invcnt_postdate) <= pCutoffDate) AND (itemsite_warehous_id=pWarehousid) ) ) ); DELETE FROM invcnt WHERE (invcnt_id IN ( SELECT invcnt_id FROM invcnt, itemsite WHERE ( (invcnt_posted) AND (invcnt_itemsite_id=itemsite_id) AND (date(invcnt_postdate) <= pCutoffDate) AND (itemsite_warehous_id=pWarehousid) ) ) ); END IF; RETURN 1; END; $_$; :DROP FUNCTION public.purgepostedcounttags(date, integer); publicadminfalse84623125579220purgeshipments(date)FUNCTIONCREATE FUNCTION purgeshipments(date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pcutoff ALIAS FOR $1; _r RECORD; BEGIN -- Used for transfer orders shipments (which are never invoiced) FOR _r IN SELECT shiphead_id FROM shiphead WHERE ( (shiphead_order_type='TO') AND (shiphead_shipped) AND (shiphead_shipdate <= pcutoff) ) LOOP DELETE FROM shipitem WHERE (shipitem_shiphead_id=_r.shiphead_id); DELETE FROM shiphead WHERE (shiphead_id=_r.shiphead_id); END LOOP; RETURN 0; END; $_$; +DROP FUNCTION public.purgeshipments(date); publicadminfalse46238125579221qtyallocated(integer, integer)FUNCTIONCREATE FUNCTION qtyallocated(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pLookAheaddays ALIAS FOR $2; BEGIN RETURN qtyAllocated(pItemsiteid, startOfTime(), (CURRENT_DATE + pLookAheadDays)); END; $_$; 5DROP FUNCTION public.qtyallocated(integer, integer); publicadminfalse46238125579222qtyallocated(integer, date)FUNCTIONcCREATE FUNCTION qtyallocated(integer, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pDate ALIAS FOR $2; BEGIN RETURN qtyAllocated(pItemsiteid, startOfTime(), pDate); END; $_$; 2DROP FUNCTION public.qtyallocated(integer, date); publicadminfalse46238125579223!qtyallocated(integer, date, date)FUNCTIONCREATE FUNCTION qtyallocated(integer, date, date) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; BEGIN IF ( fetchMetricBool('MultiWhs')) THEN IF ( SELECT item_sold FROM itemsite, item WHERE ((itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid)) ) THEN RETURN (allocatedForTo(pItemsiteid, pStartDate, pEndDate) + allocatedForWo(pItemsiteid, pStartDate, pEndDate) + allocatedForSo(pItemsiteid, pStartDate, pEndDate)); ELSE RETURN (allocatedForTo(pItemsiteid, pStartDate, pEndDate) + allocatedForWo(pItemsiteid, pStartDate, pEndDate)); END IF; ELSE IF ( SELECT item_sold FROM itemsite, item WHERE ((itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid)) ) THEN RETURN (allocatedForWo(pItemsiteid, pStartDate, pEndDate) + allocatedForSo(pItemsiteid, pStartDate, pEndDate)); ELSE RETURN (allocatedForWo(pItemsiteid, pStartDate, pEndDate)); END IF; END IF; END; $_$; 8DROP FUNCTION public.qtyallocated(integer, date, date); publicadminfalse46238125587079qtyatlocation(integer, integer)FUNCTIONCREATE FUNCTION qtyatlocation(pitemsiteid integer, plocationid integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _qty NUMERIC := 0.0; BEGIN IF (pLocationid IS NULL) THEN SELECT COALESCE(itemsite_qtyonhand, 0.0) INTO _qty FROM itemsite WHERE (itemsite_id=pItemsiteid); ELSE SELECT COALESCE(SUM(itemloc_qty), 0.0) INTO _qty FROM itemsite LEFT OUTER JOIN itemloc ON (itemloc_itemsite_id=itemsite_id) WHERE ((itemsite_id=pItemsiteid) AND (itemloc_location_id=pLocationid)); END IF; RETURN _qty; END; $$; NDROP FUNCTION public.qtyatlocation(pitemsiteid integer, plocationid integer); publicadminfalse46238125579224qtyatshipping(integer)FUNCTION CREATE FUNCTION qtyatshipping(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN qtyAtShipping('SO', $1); END; $_$; -DROP FUNCTION public.qtyatshipping(integer); publicadminfalse84623125579225qtyatshipping(text, integer)FUNCTIONCREATE FUNCTION qtyatshipping(text, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN qtyAtShipping($1, $2, 'U'); END; $_$; 3DROP FUNCTION public.qtyatshipping(text, integer); publicadminfalse46238125579226"qtyatshipping(text, integer, text)FUNCTIONCREATE FUNCTION qtyatshipping(text, integer, text) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; plineitemid ALIAS FOR $2; pstatus ALIAS FOR $3; _qty NUMERIC := 0.0; BEGIN -- pstatus U=unshipped -- S=shipped -- B=both unshipped and shipped IF (pordertype NOT IN ('SO', 'TO')) THEN RAISE EXCEPTION '% is not a valid order type', pordertype; END IF; IF (pstatus NOT IN ('U', 'S', 'B')) THEN RAISE EXCEPTION '% is not a valid status', pstatus; END IF; SELECT COALESCE(SUM(shipitem_qty), 0.0) INTO _qty FROM shipitem, shiphead WHERE ((shipitem_shiphead_id=shiphead_id) AND (shiphead_order_type=pordertype) AND (shipitem_orderitem_id=plineitemid) AND (((shiphead_shipped) AND (pstatus IN ('S', 'B'))) OR ((NOT shiphead_shipped) AND (pstatus IN ('U', 'B')))) ); RETURN _qty; END; $_$; 9DROP FUNCTION public.qtyatshipping(text, integer, text); publicadminfalse84623125587080qtyavailable(integer)FUNCTIONZCREATE FUNCTION qtyavailable(pitemsiteid integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _qty NUMERIC = 0.0; BEGIN _qty := qtyAvailable(pItemsiteId, TRUE); RETURN _qty; END; $$; 8DROP FUNCTION public.qtyavailable(pitemsiteid integer); publicadminfalse84623125579227qtyavailable(integer, integer)FUNCTIONCREATE FUNCTION qtyavailable(pitemsiteid integer, plookaheaddays integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN RETURN ( ( SELECT qtyAvailable(itemsite_id) FROM itemsite WHERE (itemsite_id=pItemsiteid) ) + (SELECT qtyOrdered(pItemsiteid, pLookAheadDays)) - (SELECT qtyAllocated(pitemsiteid, pLookAheadDays)) ); END; $$; PDROP FUNCTION public.qtyavailable(pitemsiteid integer, plookaheaddays integer); publicadminfalse46238125579228qtyavailable(integer, date)FUNCTIONCREATE FUNCTION qtyavailable(pitemsiteid integer, pdate date) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE BEGIN RETURN ( ( SELECT qtyAvailable(itemsite_id) FROM itemsite WHERE (itemsite_id=pItemsiteid) ) + (SELECT qtyOrdered(pItemsiteid, (pDate - CURRENT_DATE))) - (SELECT qtyAllocated(pItemsiteid, (pDate - CURRENT_DATE))) ); END; $$; DDROP FUNCTION public.qtyavailable(pitemsiteid integer, pdate date); publicadminfalse84623125587081qtyavailable(integer, boolean)FUNCTIONnCREATE FUNCTION qtyavailable(pitemsiteid integer, pusable boolean) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _qty NUMERIC = 0.0; BEGIN IF (pUsable) THEN -- Summarize itemloc qty for this itemsite/usable locations -- or use itemsite_qtyonhand for regular/non-lot SELECT COALESCE(SUM(itemloc_qty), itemsite_qtyonhand) INTO _qty FROM itemsite LEFT OUTER JOIN itemloc ON (itemloc_itemsite_id=itemsite_id) LEFT OUTER JOIN location ON (location_id=itemloc_location_id) WHERE (itemsite_id=pItemsiteId) AND ((location_id IS NULL) OR (COALESCE(location_usable, true))) GROUP BY itemsite_qtyonhand; ELSE -- Summarize itemloc qty for this itemsite/non-usable locations SELECT COALESCE(SUM(itemloc_qty), 0.0) INTO _qty FROM itemloc JOIN location ON (location_id=itemloc_location_id) WHERE (itemloc_itemsite_id=pItemsiteId) AND (NOT COALESCE(location_usable, true)); END IF; RETURN _qty; END; $$; IDROP FUNCTION public.qtyavailable(pitemsiteid integer, pusable boolean); publicadminfalse46238125579229%qtyinshipment(text, integer, integer)FUNCTION CREATE FUNCTION qtyinshipment(text, integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; plineitemid ALIAS FOR $2; pshipheadid ALIAS FOR $3; _qty NUMERIC; BEGIN IF (pordertype NOT IN ('SO', 'TO')) THEN RAISE EXCEPTION '% is not a valid order type', pordertype; END IF; IF (pshipheadid IS NULL) THEN RAISE EXCEPTION 'Cannot calculate quantity in a shipment with a NULL shipment'; END IF; SELECT SUM(COALESCE(shipitem_qty, 0.0)) INTO _qty FROM shipitem, shiphead WHERE ((shipitem_shiphead_id=shiphead_id) AND (shiphead_order_type=pordertype) AND (shipitem_orderitem_id=plineitemid) AND (shiphead_id=pshipheadid)); IF (NOT FOUND) THEN RAISE WARNING 'Quantity of % item % is 0 because shipment % does not exist.', pordertype, plineitemid, pshipheadid; END IF; RETURN _qty; END; $_$; <DROP FUNCTION public.qtyinshipment(text, integer, integer); publicadminfalse46238125579230Jqtylocation(integer, integer, date, date, integer, text, integer, integer)FUNCTION) CREATE FUNCTION qtylocation(integer, integer, date, date, integer, text, integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLocationId ALIAS FOR $1; pLsId ALIAS FOR $2; pExpiration ALIAS FOR $3; pWarranty ALIAS FOR $4; pItemsiteId ALIAS FOR $5; pOrderType ALIAS FOR $6; pOrderId ALIAS FOR $7; pItemlocdistId ALIAS FOR $8; _qty NUMERIC = 0.0; _qtyDist NUMERIC = 0.0; _qtyReserved NUMERIC = 0.0; BEGIN -- Summarize itemloc qty for this location/itemsite SELECT COALESCE(SUM(itemloc_qty), 0) INTO _qty FROM itemloc WHERE ( (itemloc_itemsite_id=pItemsiteId) AND (itemloc_location_id=pLocationId) AND (COALESCE(itemloc_ls_id, -1)=COALESCE(pLsId, itemloc_ls_id, -1)) AND (COALESCE(itemloc_expiration, endoftime())=COALESCE(pExpiration, itemloc_expiration, endoftime())) AND (COALESCE(itemloc_warrpurc, endoftime())=COALESCE(pWarranty, itemloc_warrpurc, endoftime())) ); -- Summarize qty distributed but not yet committed by previous distributions SELECT COALESCE(SUM(loc.itemlocdist_qty), 0) INTO _qtyDist FROM itemlocdist loc JOIN itemlocdist ls ON ((ls.itemlocdist_source_type='O') AND (ls.itemlocdist_id=loc.itemlocdist_itemlocdist_id)) WHERE ( (ls.itemlocdist_itemsite_id=pItemsiteId) AND (loc.itemlocdist_source_type='L') AND (loc.itemlocdist_source_id=pLocationId) AND (COALESCE(ls.itemlocdist_ls_id, -1)=COALESCE(pLsId, ls.itemlocdist_ls_id, -1)) AND (COALESCE(ls.itemlocdist_expiration, endoftime())=COALESCE(pExpiration, ls.itemlocdist_expiration, endoftime())) AND (COALESCE(ls.itemlocdist_warranty, endoftime())=COALESCE(pWarranty, ls.itemlocdist_warranty, endoftime())) AND (ls.itemlocdist_id != pItemlocdistId ) ); -- Summarize reserved qty for this location/itemsite -- that is reserved for a different order IF (fetchMetricBool('EnableSOReservationsByLocation')) THEN SELECT COALESCE(SUM(reserve_qty), 0) INTO _qtyReserved FROM itemloc JOIN reserve ON ( (reserve_supply_id=itemloc_id AND reserve_supply_type='I') AND ((reserve_demand_type <> COALESCE(pOrderType, '')) OR (reserve_demand_id <> COALESCE(pOrderId, -1))) ) WHERE ( (itemloc_itemsite_id=pItemsiteId) AND (itemloc_location_id=pLocationId) AND (COALESCE(itemloc_ls_id, -1)=COALESCE(pLsId, itemloc_ls_id, -1)) AND (COALESCE(itemloc_expiration, endoftime())=COALESCE(pExpiration, itemloc_expiration, endoftime())) AND (COALESCE(itemloc_warrpurc, endoftime())=COALESCE(pWarranty, itemloc_warrpurc, endoftime())) ); END IF; RETURN (_qty + _qtyDist - _qtyReserved); END; $_$; aDROP FUNCTION public.qtylocation(integer, integer, date, date, integer, text, integer, integer); publicadminfalse46238125587082qtynetable(integer)FUNCTIONVCREATE FUNCTION qtynetable(pitemsiteid integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _qty NUMERIC = 0.0; BEGIN _qty := qtyNetable(pItemsiteId, TRUE); RETURN _qty; END; $$; 6DROP FUNCTION public.qtynetable(pitemsiteid integer); publicadminfalse46238125587083qtynetable(integer, boolean)FUNCTIONrCREATE FUNCTION qtynetable(pitemsiteid integer, pnetable boolean) RETURNS numeric LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _qty NUMERIC = 0.0; BEGIN IF (pNetable) THEN -- Summarize itemloc qty for this itemsite/netable locations -- or use itemsite_qtyonhand for regular/non-lot SELECT COALESCE(SUM(itemloc_qty), itemsite_qtyonhand) INTO _qty FROM itemsite LEFT OUTER JOIN itemloc ON (itemloc_itemsite_id=itemsite_id) LEFT OUTER JOIN location ON (location_id=itemloc_location_id) WHERE (itemsite_id=pItemsiteId) AND ((location_id IS NULL) OR (COALESCE(location_netable, true))) GROUP BY itemsite_qtyonhand; ELSE -- Summarize itemloc qty for this itemsite/non-netable locations SELECT COALESCE(SUM(itemloc_qty), 0.0) INTO _qty FROM itemloc JOIN location ON (location_id=itemloc_location_id) WHERE (itemloc_itemsite_id=pItemsiteId) AND (NOT COALESCE(location_netable, true)); END IF; RETURN _qty; END; $$; HDROP FUNCTION public.qtynetable(pitemsiteid integer, pnetable boolean); publicadminfalse84623125579231qtyordered(integer, integer)FUNCTIONCREATE FUNCTION qtyordered(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pLookahead ALIAS FOR $2; _itemType TEXT; _result NUMERIC; BEGIN RETURN qtyOrdered(pItemsiteid, startOfTime(), (CURRENT_DATE + pLookahead)); END; $_$; 3DROP FUNCTION public.qtyordered(integer, integer); publicadminfalse84623125579232qtyordered(integer, date)FUNCTION_CREATE FUNCTION qtyordered(integer, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pDate ALIAS FOR $2; BEGIN RETURN qtyOrdered(pItemsiteid, startOfTime(), pDate); END; $_$; 0DROP FUNCTION public.qtyordered(integer, date); publicadminfalse46238125579233qtyordered(integer, date, date)FUNCTIONCREATE FUNCTION qtyordered(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _itemType TEXT; BEGIN SELECT item_type INTO _itemType FROM item, itemsite WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ); IF ( SELECT metric_value FROM metric WHERE ((metric_name = 'MultiWhs') AND (metric_value = 't'))) THEN RETURN orderedByPo(pItemsiteid, pStartDate, pEndDate) + orderedByWo(pItemsiteid, pStartDate, pEndDate) + orderedByTo(pItemsiteid, pStartDate, pEndDate); ELSE RETURN orderedByPo(pItemsiteid, pStartDate, pEndDate) + orderedByWo(pItemsiteid, pStartDate, pEndDate); END IF; END; $_$; 6DROP FUNCTION public.qtyordered(integer, date, date); publicadminfalse46238125579234qtypr(integer, integer)FUNCTIONrCREATE FUNCTION qtypr(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pLookahead ALIAS FOR $2; BEGIN RETURN qtypr(pItemsiteid, startOfTime(), (CURRENT_DATE + pLookahead)); END; $_$; .DROP FUNCTION public.qtypr(integer, integer); publicadminfalse84623125579235qtypr(integer, date)FUNCTIONSCREATE FUNCTION qtypr(integer, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pDate ALIAS FOR $2; BEGIN RETURN qtypr(pItemsiteid, startOfTime(), pDate); END; $_$; +DROP FUNCTION public.qtypr(integer, date); publicadminfalse46238125579236qtypr(integer, date, date)FUNCTIONICREATE FUNCTION qtypr(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _prtotal NUMERIC; BEGIN SELECT SUM(pr_qtyreq) INTO _prtotal FROM pr WHERE ((pr_status = 'O') AND (pr_itemsite_id=pItemsiteid) AND (pr_duedate BETWEEN pStartDate AND pEndDate)); IF (_prtotal IS NULL) THEN RETURN 0.0; END IF; RETURN _prtotal; END; $_$; 1DROP FUNCTION public.qtypr(integer, date, date); publicadminfalse46238125579237qtyreserved(integer)FUNCTIONCREATE FUNCTION qtyreserved(integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/EULA for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; _qty NUMERIC; BEGIN SELECT COALESCE(SUM(coitem_qtyreserved),0) INTO _qty FROM coitem WHERE(coitem_itemsite_id=pItemsiteid); RETURN _qty; END; $_$; +DROP FUNCTION public.qtyreserved(integer); publicadminfalse46238125579238qtytoreceive(text, integer)FUNCTIONCREATE FUNCTION qtytoreceive(text, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; porderitemid ALIAS FOR $2; _qty NUMERIC; BEGIN IF (pordertype = 'TO' AND NOT fetchMetricBool('MultiWhs')) THEN RETURN 0; END IF; IF (pordertype = 'RA' AND NOT fetchMetricBool('EnableReturnAuth')) THEN RETURN 0; END IF; SELECT SUM(recv_qty) INTO _qty FROM recv WHERE ((recv_orderitem_id=porderitemid) AND (NOT recv_posted) AND (recv_order_type=pordertype)); RETURN COALESCE(_qty, 0.0); END; $_$; 2DROP FUNCTION public.qtytoreceive(text, integer); publicadminfalse46238125579239recallshipment(integer)FUNCTIONCREATE FUNCTION recallshipment(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN recallShipment($1, CURRENT_TIMESTAMP); END; $_$; .DROP FUNCTION public.recallshipment(integer); publicadminfalse84623}1255792401recallshipment(integer, timestamp with time zone)FUNCTION-CREATE FUNCTION recallshipment(integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pshipheadid ALIAS FOR $1; _timestamp TIMESTAMP WITH TIME ZONE := $2; _allInvoiced BOOLEAN; _invoicePosted BOOLEAN; _in RECORD; _co RECORD; _cobill RECORD; _h RECORD; _result INTEGER; _invhistid INTEGER; _itemlocSeries INTEGER; _qty NUMERIC; _qtyFromDest NUMERIC; _qtyFromTransit NUMERIC; _qtyToBill NUMERIC; _shiphead RECORD; _to RECORD; _ti RECORD; _value NUMERIC; BEGIN IF (_timestamp IS NULL) THEN _timestamp := CURRENT_TIMESTAMP; END IF; SELECT * INTO _shiphead FROM shiphead WHERE (shiphead_id=pshipheadid); IF (NOT FOUND OR NOT _shiphead.shiphead_shipped) THEN RETURN -1; END IF; IF (_shiphead.shiphead_order_type = 'SO') THEN SELECT cohead_number AS head_number, cohead_cust_id AS cust_id, cohead_prj_id AS prj_id, cohead_saletype_id AS saletype_id, cohead_shipzone_id AS shipzone_id INTO _h FROM cohead WHERE (cohead_id=_shiphead.shiphead_order_id); IF (NOT FOUND) THEN RETURN -1; END IF; SELECT COALESCE(BOOL_AND(shipitem_invoiced), FALSE) INTO _allInvoiced FROM cobill, shipitem WHERE ((cobill_coitem_id=shipitem_orderitem_id) AND (shipitem_shiphead_id=pshipheadid)); IF (_allInvoiced AND NOT checkPrivilege('RecallInvoicedShipment')) THEN RETURN -2; END IF; -- Check for any associated posted Invoices SELECT COALESCE(BOOL_AND(invchead_posted), FALSE) INTO _invoicePosted FROM shipitem JOIN invcitem ON (invcitem_id=shipitem_invcitem_id) JOIN invchead ON (invchead_id=invcitem_invchead_id) WHERE (shipitem_shiphead_id=pshipheadid); IF (_invoicePosted) THEN RETURN -4; END IF; -- Delete any associated unposted Invoices FOR _in IN SELECT DISTINCT invchead_id FROM shipitem JOIN invcitem ON (invcitem_id=shipitem_invcitem_id) JOIN invchead ON ( (invchead_id=invcitem_invchead_id) AND (NOT invchead_posted) ) WHERE (shipitem_shiphead_id=pshipheadid) LOOP SELECT deleteInvoice(_in.invchead_id) INTO _result; IF (_result < 0) THEN RETURN _result; END IF; END LOOP; FOR _co IN SELECT coitem_id, coitem_itemsite_id, coitem_qty_invuomratio, coitem_warranty, coitem_cos_accnt_id, itemsite_controlmethod FROM coitem JOIN itemsite ON (coitem_itemsite_id=itemsite_id) WHERE(coitem_id IN (SELECT shipitem_orderitem_id FROM shipitem, shiphead WHERE((shipitem_shiphead_id=shiphead_id) AND (shiphead_shipped) AND (shiphead_id=pshipheadid)))) FOR UPDATE LOOP SELECT SUM(shipitem_qty),SUM(COALESCE(shipitem_value, 0)) INTO _qty, _value FROM shipitem WHERE ( (shipitem_orderitem_id=_co.coitem_id) AND (shipitem_shiphead_id=pshipheadid) ); UPDATE coitem SET coitem_qtyshipped = (coitem_qtyshipped - _qty) WHERE (coitem_id=_co.coitem_id); _qtyToBill := _qty; FOR _cobill IN SELECT cobill_id, cobill_qty FROM cobill, shipitem WHERE ((cobill_coitem_id=shipitem_orderitem_id) AND (shipitem_shiphead_id=pshipheadid) AND (cobill_coitem_id=_co.coitem_id)) FOR UPDATE LOOP IF (noNeg(_cobill.cobill_qty - _qtyToBill) = 0) THEN DELETE FROM cobill WHERE (cobill_id=_cobill.cobill_id); ELSE UPDATE cobill SET cobill_qty = noNeg(cobill_qty - _qtyToBill) WHERE (cobill_id=_cobill.cobill_id); END IF; _qtyToBill = _qtyToBill - _cobill.cobill_qty; EXIT WHEN (_qtyToBill <= 0.0); END LOOP; -- Check to see if all of the cobills have been deleted for this cobmisc IF (EXISTS(SELECT cobmisc_id FROM cobmisc JOIN cobill ON (cobill_cobmisc_id=cobmisc_id) WHERE (cobmisc_cohead_id=_shiphead.shiphead_order_id AND NOT cobmisc_posted))) THEN -- Lines exist, update the freight UPDATE cobmisc SET cobmisc_freight = (cobmisc_freight - _shiphead.shiphead_freight) WHERE (cobmisc_cohead_id=_shiphead.shiphead_order_id AND NOT cobmisc_posted); ELSE -- No lines exist, delete the cobmisc DELETE FROM cobmisc WHERE (cobmisc_cohead_id=_shiphead.shiphead_order_id AND NOT cobmisc_posted); END IF; -- Distribute to G/L, debit Shipping Asset, credit COS IF (_co.itemsite_controlmethod != 'N') THEN PERFORM insertGLTransaction( 'S/R', _shiphead.shiphead_order_type, _h.head_number::TEXT, 'Recall Shipment', CASE WHEN(COALESCE(_co.coitem_cos_accnt_id, -1) != -1) THEN getPrjAccntId(_h.prj_id, _co.coitem_cos_accnt_id) WHEN(_co.coitem_warranty = TRUE) THEN getPrjAccntId(_h.prj_id, resolveCOWAccount(itemsite_id, _h.cust_id, _h.saletype_id, _h.shipzone_id)) ELSE getPrjAccntId(_h.prj_id, resolveCOSAccount(itemsite_id, _h.cust_id, _h.saletype_id, _h.shipzone_id)) END, getPrjAccntId(_h.prj_id,costcat_shipasset_accnt_id), -1, _value, _timestamp::DATE ) FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_co.coitem_itemsite_id) ); END IF; END LOOP; -- Kit billing selection -- Set kit billing qty to zero since kits are shipped complete FOR _cobill IN SELECT cobill_id, cobill_qty FROM shipitem JOIN coitem sub ON (sub.coitem_id=shipitem_orderitem_id) JOIN coitem kit ON (kit.coitem_id <> sub.coitem_id AND kit.coitem_cohead_id = sub.coitem_cohead_id AND kit.coitem_linenumber = sub.coitem_linenumber AND kit.coitem_subnumber = 0) JOIN cobill ON (cobill_coitem_id=kit.coitem_id) WHERE (shipitem_shiphead_id=pshipheadid) AND (sub.coitem_subnumber > 0) GROUP BY cobill_id, cobill_qty LOOP UPDATE cobill SET cobill_qty = 0.0 WHERE (cobill_id=_cobill.cobill_id); END LOOP; ELSEIF (_shiphead.shiphead_order_type = 'TO') THEN SELECT * INTO _to FROM tohead WHERE (tohead_id=_shiphead.shiphead_order_id); IF (NOT FOUND) THEN RETURN -1; END IF; IF (_to.tohead_status = 'C') THEN RETURN -6; END IF; FOR _ti IN SELECT toitem_id, toitem_qty_received, sis.itemsite_id AS src_itemsite_id, tis.itemsite_id AS trns_itemsite_id, dis.itemsite_id AS dest_itemsite_id, scc.costcat_shipasset_accnt_id AS src_shipasset_accnt_id, tcc.costcat_asset_accnt_id AS trns_asset_accnt_id, itemcost(tis.itemsite_id) AS trns_cost, SUM(shipitem_qty) AS recall_qty FROM shipitem JOIN toitem ON (toitem_id=shipitem_orderitem_id) JOIN itemsite sis ON (sis.itemsite_item_id=toitem_item_id AND sis.itemsite_warehous_id=_to.tohead_src_warehous_id) JOIN itemsite tis ON (tis.itemsite_item_id=toitem_item_id AND tis.itemsite_warehous_id=_to.tohead_trns_warehous_id) JOIN itemsite dis ON (dis.itemsite_item_id=toitem_item_id AND dis.itemsite_warehous_id=_to.tohead_dest_warehous_id) JOIN costcat scc ON (scc.costcat_id=sis.itemsite_costcat_id) JOIN costcat tcc ON (tcc.costcat_id=tis.itemsite_costcat_id) WHERE (shipitem_shiphead_id=pshipheadid) GROUP BY toitem_id, toitem_qty_received, sis.itemsite_id, tis.itemsite_id, dis.itemsite_id, scc.costcat_shipasset_accnt_id, tcc.costcat_asset_accnt_id LOOP _itemlocSeries := NEXTVAL('itemloc_series_seq'); SELECT postInvTrans(_ti.src_itemsite_id, 'TS', (_ti.recall_qty * -1.0), 'I/M', _shiphead.shiphead_order_type, formatToNumber(_ti.toitem_id), _to.tohead_number, 'Recall TO Shipment To Src Warehouse', _ti.trns_asset_accnt_id, _ti.src_shipasset_accnt_id, _itemlocSeries, _timestamp, (_ti.trns_cost * _ti.recall_qty * -1.0)) INTO _invhistid; IF (_invhistid < 0) THEN RETURN _invhistid; END IF; -- post the inventory history if lot/serial or location control PERFORM postItemlocseries(_itemlocSeries); -- determine the qty to be recalled from destination warehouse and -- qty to be recalled from transit warehouse IF (_ti.toitem_qty_received >= _ti.recall_qty) THEN _qtyFromDest := _ti.recall_qty; _qtyFromTransit := 0.0; ELSE _qtyFromDest := _ti.toitem_qty_received; _qtyFromTransit := _ti.recall_qty - _qtyFromDest; END IF; -- record inventory history and qoh changes at destination warehouse but -- there is only one g/l account to touch IF (_qtyFromDest > 0.0) THEN SELECT postInvTrans(_ti.dest_itemsite_id, 'TR', (_qtyFromDest * -1.0), 'I/M', _shiphead.shiphead_order_type, formatToNumber(_ti.toitem_id), _to.tohead_number, 'Recall TO Shipment From Destination Warehouse', _ti.trns_asset_accnt_id, _ti.trns_asset_accnt_id, _itemlocSeries, _timestamp, (_ti.trns_cost * _qtyFromDest * -1.0)) INTO _invhistid; IF (_invhistid < 0) THEN RETURN _invhistid; END IF; END IF; -- record inventory history and qoh changes at transit warehouse but -- there is only one g/l account to touch IF (_qtyFromTransit > 0.0) THEN SELECT postInvTrans(_ti.trns_itemsite_id, 'TR', (_qtyFromTransit * -1.0), 'I/M', _shiphead.shiphead_order_type, formatToNumber(_ti.toitem_id), _to.tohead_number, 'Recall TO Shipment From Transit Warehouse', _ti.trns_asset_accnt_id, _ti.trns_asset_accnt_id, _itemlocSeries, _timestamp, (_ti.trns_cost * _qtyFromTransit * -1.0)) INTO _invhistid; IF (_invhistid < 0) THEN RETURN _invhistid; END IF; END IF; -- post the inventory history if lot/serial or location control PERFORM postItemlocseries(_itemlocSeries); UPDATE toitem SET toitem_qty_shipped = (toitem_qty_shipped - _ti.recall_qty), toitem_qty_received = (toitem_qty_received - _qtyFromDest) WHERE (toitem_id=_ti.toitem_id); UPDATE shipitem SET shipitem_shipdate=NULL, shipitem_shipped=FALSE, shipitem_value=(shipitem_qty * _ti.trns_cost) WHERE ((shipitem_orderitem_id=_ti.toitem_id) AND (shipitem_shiphead_id=pshipheadid)); DELETE FROM recv WHERE ((recv_orderitem_id=_ti.toitem_id) AND (recv_order_type='TO') AND (NOT recv_posted)); END LOOP; END IF; UPDATE shiphead SET shiphead_shipped=FALSE WHERE (shiphead_id=pshipheadid); RETURN _itemlocSeries; END; $_$; HDROP FUNCTION public.recallshipment(integer, timestamp with time zone); publicadminfalse84623~125579242recallwo(integer, boolean)FUNCTIONjCREATE FUNCTION recallwo(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; recallChildren ALIAS FOR $2; returnCode INTEGER; BEGIN UPDATE wo SET wo_status='E' WHERE ((wo_status='R') AND (wo_id=pWoid)); IF (recallChildren) THEN returnCode := (SELECT MAX(recallWo(wo_id, TRUE)) FROM wo WHERE ((wo_ordtype='W') AND (wo_ordid=pWoid))); END IF; RETURN 0; END; $_$; 1DROP FUNCTION public.recallwo(integer, boolean); publicadminfalse84623125579243receipts(text)FUNCTION}CREATE FUNCTION receipts(text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTransType ALIAS FOR $1; BEGIN IF (pTransType IN ('RM', 'RB', 'RT', 'RP', 'RR', 'RX', 'TR')) THEN RETURN TRUE; ELSE RETURN FALSE; END IF; END; $_$; %DROP FUNCTION public.receipts(text); publicadminfalse84623125579244releaseapmemonumber(integer)FUNCTIONCREATE FUNCTION releaseapmemonumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('APMemoNumber', $1::INTEGER) > 0; $_$; 3DROP FUNCTION public.releaseapmemonumber(integer); publicadminfalse8125579245releasearmemonumber(integer)FUNCTIONCREATE FUNCTION releasearmemonumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. select releaseNumber('ARMemoNumber', $1::INTEGER) > 0; $_$; 3DROP FUNCTION public.releasearmemonumber(integer); publicadminfalse8125579246releasecashrcptnumber(integer)FUNCTIONCREATE FUNCTION releasecashrcptnumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('CashRcptNumber', $1) > 0; $_$; 5DROP FUNCTION public.releasecashrcptnumber(integer); publicadminfalse8125579247releasecmnumber(integer)FUNCTIONCREATE FUNCTION releasecmnumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('CmNumber', $1) > 0; $_$; /DROP FUNCTION public.releasecmnumber(integer); publicadminfalse8125579248releasecmnumber(text)FUNCTION CREATE FUNCTION releasecmnumber(text) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('CmNumber', $1::INTEGER) > 0; $_$; ,DROP FUNCTION public.releasecmnumber(text); publicadminfalse8125579249 releasecrmaccountnumber(integer)FUNCTIONCREATE FUNCTION releasecrmaccountnumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('CRMAccountNumber', $1::INTEGER) > 0; $_$; 7DROP FUNCTION public.releasecrmaccountnumber(integer); publicadminfalse8125579250releaseincidentnumber(integer)FUNCTIONCREATE FUNCTION releaseincidentnumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('IncidentNumber', $1) = 1; $_$; 5DROP FUNCTION public.releaseincidentnumber(integer); publicadminfalse8125579251releaseinvcnumber(integer)FUNCTION CREATE FUNCTION releaseinvcnumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('InvcNumber', $1) > 0; $_$; 1DROP FUNCTION public.releaseinvcnumber(integer); publicadminfalse86125579252releaseinvcnumber(text)FUNCTIONCREATE FUNCTION releaseinvcnumber(text) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('InvcNumber', $1::INTEGER) > 0; $_$; .DROP FUNCTION public.releaseinvcnumber(text); publicadminfalse8125579253releasenumber(text, integer)FUNCTIONq CREATE FUNCTION releasenumber(psequence text, pnumber integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _isManual BOOLEAN; _test INTEGER; _number INTEGER; _table TEXT; _numcol TEXT; _select TEXT; BEGIN IF (fetchMetricBool('EnableGaplessNumbering')) THEN -- drop the number back into the pool if it was not committed PERFORM clearNumberIssue(psequence, pnumber); UPDATE orderseq SET orderseq_number = LEAST(pnumber, orderseq_number) WHERE (orderseq_name=psequence); ELSE -- get the current state of the sequence SELECT orderseq_number::integer, orderseq_table, orderseq_numcol INTO _number, _table, _numcol FROM orderseq WHERE (orderseq_name=psequence); IF (NOT FOUND) THEN RAISE EXCEPTION 'Invalid orderseq_name %', psequence; END IF; -- check if an order exists with the given order number -- Have to factor in scenario where Quotes are set to use SO Numbering IF (psequence = 'SoNumber' AND fetchmetrictext('QUNumberGeneration') = 'S') THEN _select := 'SELECT ' || quote_ident(_numcol) || ' FROM ' || _table || ' WHERE (' || quote_ident(_numcol) || '=' || quote_literal(_number - 1) || ') ' || ' UNION SELECT quhead_number FROM quhead WHERE (quhead_number = ' || quote_literal(_number - 1) || ');'; ELSE _select := 'SELECT ' || quote_ident(_numcol) || ' FROM ' || _table || ' WHERE (' || quote_ident(_numcol) || '=' || quote_literal(_number - 1) || ');'; END IF; EXECUTE _select INTO _test; -- Check if order seq has been incremented past the given order number -- Problem occurred with open but not saved orders (i.e. open by two or more people -- at the same time) so need to check for that as well. IF ((FOUND AND (_test > pnumber)) OR ((_test IS NULL) AND ((_number - 1) > pnumber)) OR (_number = pnumber)) THEN RETURN 0; END IF; SELECT metric_value = 'M' INTO _isManual FROM metric WHERE (metric_name = CASE WHEN psequence='CmNumber' THEN 'CMNumberGeneration' WHEN psequence='SoNumber' THEN 'CONumberGeneration' WHEN psequence='InvcNumber' THEN 'InvcNumberGeneration' WHEN psequence='PoNumber' THEN 'PONumberGeneration' WHEN psequence='PrNumber' THEN 'PrNumberGeneration' WHEN psequence='QuNumber' THEN 'QUNumberGeneration' WHEN psequence='RaNumber' THEN 'RANumberGeneration' -- WHEN psequence='??Number' THEN 'ShipmentNumberGeneration' WHEN psequence='ToNumber' THEN 'TONumberGeneration' WHEN psequence='VcNumber' THEN 'VoucherNumberGeneration' WHEN psequence='WoNumber' THEN 'WONumberGeneration' ELSE NULL END); -- release the given order number for reuse IF (NOT FOUND OR NOT _isManual) THEN UPDATE orderseq SET orderseq_number = (_number - 1) WHERE (orderseq_name=psequence); ELSE RAISE WARNING 'cannot update orderseq'; END IF; END IF; RETURN 1; END; $$; EDROP FUNCTION public.releasenumber(psequence text, pnumber integer); publicadminfalse46238125579254releaseponumber(integer)FUNCTIONCREATE FUNCTION releaseponumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('PoNumber', $1) > 0; $_$; /DROP FUNCTION public.releaseponumber(integer); publicadminfalse8125579255releaseponumber(text)FUNCTION CREATE FUNCTION releaseponumber(text) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('PoNumber', $1::INTEGER) > 0; $_$; ,DROP FUNCTION public.releaseponumber(text); publicadminfalse8125587085releasepr(integer)FUNCTIONt$CREATE FUNCTION releasepr(pprid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _pr RECORD; _w RECORD; _i RECORD; _rows INTEGER := 0; _itemsrcid INTEGER := -1; _poheadid INTEGER := -1; _poitemid INTEGER := -1; _taxtypeid INTEGER := -1; _polinenumber INTEGER; _ponumber NUMERIC; _price NUMERIC; BEGIN -- Cache information SELECT *, CASE WHEN(pr_order_type='W') THEN pr_order_id ELSE -1 END AS parentwo, CASE WHEN(pr_order_type='S') THEN pr_order_id ELSE -1 END AS parentso INTO _pr FROM pr LEFT OUTER JOIN itemsite ON (pr_itemsite_id = itemsite_id) LEFT OUTER JOIN item ON (item_id = itemsite_item_id) LEFT OUTER JOIN prj ON (prj_id = pr_prj_id) WHERE (pr_id = pPrId); IF (NOT FOUND) THEN RETURN -1; END IF; SELECT * INTO _w FROM itemsite JOIN whsinfo ON (warehous_id = itemsite_warehous_id) LEFT OUTER JOIN addr ON (warehous_addr_id = addr_id) LEFT OUTER JOIN cntct ON (warehous_cntct_id = cntct_id) WHERE (itemsite_id = _pr.itemsite_id); -- Must either be a single itemsrc or a default itemsrc SELECT itemsrc_id INTO _itemsrcid FROM itemsrc WHERE (itemsrc_item_id = _pr.item_id) AND (_pr.pr_duedate BETWEEN COALESCE(itemsrc_effective, startOfTime()) AND COALESCE(itemsrc_expires, endOfTime())) AND (itemsrc_default); IF (NOT FOUND) THEN SELECT MAX(itemsrc_id), count(*) INTO _itemsrcid, _rows FROM itemsrc WHERE (itemsrc_item_id = _pr.item_id) AND (_pr.pr_duedate BETWEEN COALESCE(itemsrc_effective, startOfTime()) AND COALESCE(itemsrc_expires, endOfTime())) GROUP BY itemsrc_item_id; IF (NOT FOUND) THEN RETURN -2; END IF; IF (_rows > 1) THEN RETURN -2; END IF; END IF; SELECT * INTO _i FROM itemsrc JOIN vendinfo ON (itemsrc_vend_id = vend_id) LEFT OUTER JOIN cntct ON (vend_cntct1_id = cntct_id) LEFT OUTER JOIN addr ON (vend_addr_id = addr_id) WHERE (itemsrc_id = _itemsrcid); --RAISE NOTICE 'releasepr selected itemsrc_id = % for pr = %', _itemsrcid, _pr.pr_id; -- Find matching unreleased PO SELECT COALESCE(pohead_id, -1) INTO _poheadid FROM pohead WHERE ( (pohead_status = 'U') AND (pohead_vend_id = _i.itemsrc_vend_id) AND (COALESCE(pohead_shiptoaddress1, '') = COALESCE(_w.addr_line1, '')) AND (COALESCE(pohead_shiptoaddress2, '') = COALESCE(_w.addr_line2, '')) AND (COALESCE(pohead_shiptoaddress3, '') = COALESCE(_w.addr_line3, '')) AND (COALESCE(pohead_shiptocity, '') = COALESCE(_w.addr_city, '')) AND (COALESCE(pohead_shiptostate, '') = COALESCE(_w.addr_state, '')) AND (COALESCE(pohead_shiptozipcode, '') = COALESCE(_w.addr_postalcode, '')) AND (COALESCE(pohead_shiptocountry, '') = COALESCE(_w.addr_country, '')) ); IF (NOT FOUND) THEN -- Create new PO SELECT NEXTVAL('pohead_pohead_id_seq') INTO _poheadid; SELECT fetchPoNumber() INTO _ponumber; INSERT INTO pohead ( pohead_id, pohead_number, pohead_status, pohead_dropship, pohead_agent_username, pohead_vend_id, pohead_taxzone_id, pohead_orderdate, pohead_curr_id, pohead_cohead_id, pohead_warehous_id, pohead_shipvia, pohead_terms_id, pohead_shipto_cntct_id, pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name, pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name, pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone, pohead_shipto_cntct_title, pohead_shipto_cntct_fax, pohead_shipto_cntct_email, pohead_shiptoaddress_id, pohead_shiptoaddress1, pohead_shiptoaddress2, pohead_shiptoaddress3, pohead_shiptocity, pohead_shiptostate, pohead_shiptozipcode, pohead_shiptocountry, pohead_vend_cntct_id, pohead_vend_cntct_honorific, pohead_vend_cntct_first_name, pohead_vend_cntct_middle, pohead_vend_cntct_last_name, pohead_vend_cntct_suffix, pohead_vend_cntct_phone, pohead_vend_cntct_title, pohead_vend_cntct_fax, pohead_vend_cntct_email, pohead_vendaddress1, pohead_vendaddress2, pohead_vendaddress3, pohead_vendcity, pohead_vendstate, pohead_vendzipcode, pohead_vendcountry ) VALUES ( _poheadid, _ponumber, 'U', FALSE, getEffectiveXtUser(), _i.itemsrc_vend_id, _i.vend_taxzone_id, CURRENT_DATE, COALESCE(_i.vend_curr_id, basecurrid()), NULL, COALESCE(_pr.itemsite_warehous_id, -1), COALESCE(_i.vend_shipvia, TEXT('')), COALESCE(_i.vend_terms_id, -1), _w.cntct_id, _w.cntct_honorific, _w.cntct_first_name, _w.cntct_middle, _w.cntct_last_name, _w.cntct_suffix, _w.cntct_phone, _w.cntct_title, _w.cntct_fax, _w.cntct_email, _w.addr_id, COALESCE(_w.addr_line1, ''), COALESCE(_w.addr_line2, ''), COALESCE(_w.addr_line3, ''), COALESCE(_w.addr_city, ''), COALESCE(_w.addr_state, ''), COALESCE(_w.addr_postalcode, ''), COALESCE(_w.addr_country, ''), _i.cntct_id, COALESCE(_i.cntct_honorific, TEXT('')), COALESCE(_i.cntct_first_name, TEXT('')), COALESCE(_i.cntct_middle, TEXT('')), COALESCE(_i.cntct_last_name, TEXT('')), COALESCE(_i.cntct_suffix, TEXT('')), COALESCE(_i.cntct_phone, TEXT('')), COALESCE(_i.cntct_title, TEXT('')), COALESCE(_i.cntct_fax, TEXT('')), COALESCE(_i.cntct_email, TEXT('')), COALESCE(_i.addr_line1, TEXT('')), COALESCE(_i.addr_line2, TEXT('')), COALESCE(_i.addr_line3, TEXT('')), COALESCE(_i.addr_city, TEXT('')), COALESCE(_i.addr_state, TEXT('')), COALESCE(_i.addr_postalcode, TEXT('')), COALESCE(_i.addr_country, TEXT('')) ); END IF; SELECT NEXTVAL('poitem_poitem_id_seq') INTO _poitemid; SELECT (COALESCE(MAX(poitem_linenumber), 0) + 1) INTO _polinenumber FROM poitem WHERE (poitem_pohead_id = _poheadid); SELECT COALESCE(itemtax_taxtype_id, -1) INTO _taxtypeid FROM itemtax WHERE (itemtax_item_id = _i.itemsrc_item_id); SELECT itemsrcPrice(_i.itemsrc_id, COALESCE(_pr.itemsite_warehous_id, -1), FALSE, (_pr.pr_qtyreq / COALESCE(_i.itemsrc_invvendoruomratio, 1.00)), COALESCE(_i.vend_curr_id, baseCurrId()), CURRENT_DATE) INTO _price; -- Create PO Item INSERT INTO poitem ( poitem_id, poitem_status, poitem_pohead_id, poitem_linenumber, poitem_duedate, poitem_itemsite_id, poitem_vend_item_descrip, poitem_vend_uom, poitem_invvenduomratio, poitem_qty_ordered, poitem_unitprice, poitem_vend_item_number, poitem_itemsrc_id, poitem_order_id, poitem_order_type, poitem_prj_id, poitem_stdcost, poitem_manuf_name, poitem_manuf_item_number, poitem_manuf_item_descrip, poitem_taxtype_id, poitem_comments ) VALUES ( _poitemid, 'U', _poheadid, _polinenumber, _pr.pr_duedate, _pr.itemsite_id, COALESCE(_i.itemsrc_vend_item_descrip, TEXT('')), COALESCE(_i.itemsrc_vend_uom, TEXT('')), COALESCE(_i.itemsrc_invvendoruomratio, 1.00), (_pr.pr_qtyreq / COALESCE(_i.itemsrc_invvendoruomratio, 1.00)), _price, COALESCE(_i.itemsrc_vend_item_number, TEXT('')), _i.itemsrc_id, CASE WHEN (_pr.parentwo > 0) THEN _pr.parentwo WHEN (_pr.parentso > 0) THEN _pr.parentso ELSE -1 END, CASE WHEN (_pr.parentwo > 0) THEN 'W' WHEN (_pr.parentso > 0) THEN 'S' ELSE '' END, _pr.prj_id, stdcost(_i.itemsrc_item_id), COALESCE(_i.itemsrc_manuf_name, TEXT('')), COALESCE(_i.itemsrc_manuf_item_number, TEXT('')), COALESCE(_i.itemsrc_manuf_item_descrip, TEXT('')), _taxtypeid, COALESCE(_pr.pr_releasenote, TEXT(''))); -- Copy characteristics from the pr to the poitem INSERT INTO charass ( charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price ) SELECT 'PI', _poitemid, charass_char_id, charass_value, charass_default, charass_price FROM charass WHERE ( (charass_target_type='PR') AND (charass_target_id=pPrId) ); -- Copy characteristics from the coitem to the poitem IF (_pr.parentso > 0) THEN INSERT INTO charass ( charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price ) SELECT 'PI', _poitemid, charass_char_id, charass_value, charass_default, charass_price FROM charass WHERE ( (charass_target_type='SI') AND (charass_target_id=_pr.parentso) ); END IF; -- Copy price override from the coitem to the poitem IF (_pr.parentso > 0) THEN SELECT coitem_prcost INTO _price FROM coitem WHERE (coitem_id=_pr.parentso); IF (_price > 0) THEN UPDATE poitem SET poitem_unitprice=_price WHERE (poitem_id=_poitemid); END IF; END IF; -- Update coitem with the poitem_id IF (_pr.parentso > 0) THEN UPDATE coitem SET coitem_order_id=_poitemid WHERE (coitem_id=_pr.parentso); END IF; -- Delete the PR PERFORM deletePr(pPrId); RETURN _poitemid; END; $$; /DROP FUNCTION public.releasepr(pprid integer); publicadminfalse46238125579256releaseprnumber(integer)FUNCTIONCREATE FUNCTION releaseprnumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('PrNumber', $1) > 0; $_$; /DROP FUNCTION public.releaseprnumber(integer); publicadminfalse8125579257releasepurchaseorder(integer)FUNCTIONCREATE FUNCTION releasepurchaseorder(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPoheadid ALIAS FOR $1; BEGIN IF ( ( SELECT (COUNT(*) = 0) FROM poitem WHERE ( (poitem_pohead_id=pPoheadid) AND (poitem_status='U') ) ) ) THEN RETURN -1; END IF; IF ( ( SELECT (pohead_status='U') FROM pohead WHERE (pohead_id=pPoheadid) ) ) THEN --update status and store the date that the order was released on UPDATE pohead SET pohead_status='O', pohead_released = current_date WHERE (pohead_id=pPoheadid); END IF; --update status and store the duedates at release UPDATE poitem SET poitem_status='O', poitem_rlsd_duedate = poitem_duedate WHERE (poitem_pohead_id=pPoheadid); RETURN 1; END; $_$; 4DROP FUNCTION public.releasepurchaseorder(integer); publicadminfalse84623125579258releasequnumber(integer)FUNCTIONCREATE FUNCTION releasequnumber(integer) RETURNS integer LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('QuNumber', $1); $_$; /DROP FUNCTION public.releasequnumber(integer); publicadminfalse8125579259releasequnumber(text)FUNCTIONCREATE FUNCTION releasequnumber(text) RETURNS integer LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('QuNumber', $1::INTEGER); $_$; ,DROP FUNCTION public.releasequnumber(text); publicadminfalse8125579260releaseshipmentnumber(integer)FUNCTIONCREATE FUNCTION releaseshipmentnumber(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _test INTEGER; BEGIN -- Check to see if a Shipment exists with the passed number SELECT shiphead_id INTO _test FROM shiphead WHERE (shiphead_number=pNumber); IF (FOUND) THEN RETURN FALSE; END IF; -- Check to see if ShipmentNumber orderseq has been incremented past the passed number SELECT orderseq_number INTO _test FROM orderseq WHERE (orderseq_name='ShipmentNumber'); IF ((_test - 1) <> pNumber) THEN RETURN FALSE; END IF; -- Decrement the orderseq, releasing the passed number UPDATE orderseq SET orderseq_number = (orderseq_number - 1) WHERE (orderseq_name='ShipmentNumber'); RETURN TRUE; END; $_$; 5DROP FUNCTION public.releaseshipmentnumber(integer); publicadminfalse46238125579261releasesohead(integer)FUNCTIONCREATE FUNCTION releasesohead(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; BEGIN DELETE FROM soheadlock WHERE ( (soheadlock_sohead_id=pSoheadid) AND (soheadlock_username=getEffectiveXtUser()) AND (soheadlock_procpid=pg_backend_pid()) ); RETURN TRUE; END; $_$; -DROP FUNCTION public.releasesohead(integer); publicadminfalse84623125579262releasesonumber(integer)FUNCTIONCREATE FUNCTION releasesonumber(integer) RETURNS integer LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('SoNumber', $1); $_$; /DROP FUNCTION public.releasesonumber(integer); publicadminfalse8125579263releasesonumber(text)FUNCTIONtCREATE FUNCTION releasesonumber(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (COALESCE($1, '') = '' OR $1 ~ '[^0-9]') THEN --do nothing; RETURN 1; ELSE RETURN releaseNumber('SoNumber', $1::INTEGER); END IF; END; $_$; ,DROP FUNCTION public.releasesonumber(text); publicadminfalse46238125579264#releaseunusedbillingheader(integer)FUNCTIONtCREATE FUNCTION releaseunusedbillingheader(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCobmiscid ALIAS FOR $1; _p RECORD; BEGIN IF ( ( SELECT cobmisc_posted FROM cobmisc WHERE (cobmisc_id=pCobmiscid) ) ) THEN RETURN -1; END IF; SELECT cobill_id INTO _p FROM cobill WHERE (cobill_cobmisc_id=pCobmiscid) LIMIT 1; IF (FOUND) THEN RETURN -2; END IF; DELETE FROM cobmisc WHERE (cobmisc_id=pCobmiscid); RETURN 0; END; $_$; :DROP FUNCTION public.releaseunusedbillingheader(integer); publicadminfalse84623125579265releasevonumber(integer)FUNCTIONCREATE FUNCTION releasevonumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('VcNumber', $1) > 0; $_$; /DROP FUNCTION public.releasevonumber(integer); publicadminfalse8125579266releasewo(integer, boolean)FUNCTIONlCREATE FUNCTION releasewo(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; releaseChildren ALIAS FOR $2; returnCode INTEGER; BEGIN UPDATE wo SET wo_status='R' WHERE ((wo_status='E') AND (wo_id=pWoid)); IF (releaseChildren) THEN returnCode := (SELECT MAX(releaseWo(wo_id, TRUE)) FROM wo WHERE ((wo_ordtype='W') AND (wo_ordid=pWoid))); END IF; RETURN 0; END; $_$; 2DROP FUNCTION public.releasewo(integer, boolean); publicadminfalse84623125579267releasewonumber(integer)FUNCTIONCREATE FUNCTION releasewonumber(integer) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT releaseNumber('WoNumber', $1) > 0; $_$; /DROP FUNCTION public.releasewonumber(integer); publicadminfalse8125579268;relocateinventory(integer, integer, integer, numeric, text)FUNCTIONOCREATE FUNCTION relocateinventory(integer, integer, integer, numeric, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN relocateInventory($1, $2, $3, $4, $5, CURRENT_TIMESTAMP); END; $_$; RDROP FUNCTION public.relocateinventory(integer, integer, integer, numeric, text); publicadminfalse46238125579269Urelocateinventory(integer, integer, integer, numeric, text, timestamp with time zone)FUNCTIONyCREATE FUNCTION relocateinventory(psourceitemlocid integer, ptargetlocationid integer, pitemsiteid integer, pqty numeric, pcomments text, pgldistts timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _GlDistTS TIMESTAMP WITH TIME ZONE; _targetItemlocid INTEGER; _invhistid INTEGER; _p RECORD; _rsrv RECORD; _qty NUMERIC; _qtyunreserved NUMERIC := 0.0; _qtytomove NUMERIC := 0.0; _result INTEGER := -1; _itemlocSeries INTEGER := NEXTVAL('itemloc_series_seq'); BEGIN IF ((pGlDistTS IS NULL) OR (CAST(pGlDistTS AS date)=CURRENT_DATE)) THEN _GlDistTS := CURRENT_TIMESTAMP; ELSE _GLDistTS := pGLDistTS; END IF; -- Make sure the passed itemsite points to a real item IF ( ( SELECT (item_type IN ('R', 'F') OR itemsite_costmethod = 'J') FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ) ) ) THEN RETURN 0; END IF; -- Cache some parameters SELECT itemloc_ls_id, itemloc_itemsite_id AS itemsiteid, itemloc_expiration, itemloc_warrpurc, itemloc_qty INTO _p FROM itemloc WHERE (itemloc_id=pSourceItemlocid); -- Check to make sure the qty being transfered exists IF (_p.itemloc_qty < pQty) THEN RETURN -1; END IF; -- Create the RL transaction SELECT NEXTVAL('invhist_invhist_id_seq') INTO _invhistid; INSERT INTO invhist ( invhist_id, invhist_itemsite_id, invhist_transtype, invhist_invqty, invhist_qoh_before, invhist_qoh_after, invhist_comments, invhist_transdate, invhist_invuom, invhist_unitcost, invhist_costmethod, invhist_value_before, invhist_value_after, invhist_series) SELECT _invhistid, itemsite_id, 'RL', 0, itemsite_qtyonhand, itemsite_qtyonhand, pComments, _GlDistTS, uom_name, CASE WHEN (itemsite_costmethod='A') THEN avgcost(itemsite_id) ELSE stdCost(item_id) END, itemsite_costmethod, itemsite_value, itemsite_value, _itemlocSeries FROM item, itemsite, uom WHERE ((itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (itemsite_controlmethod <> 'N') AND (itemsite_id=pItemsiteid)); -- Relocate the inventory from the source and record the transactions INSERT INTO invdetail ( invdetail_invhist_id, invdetail_location_id, invdetail_ls_id, invdetail_qty, invdetail_qty_before, invdetail_qty_after, invdetail_expiration, invdetail_warrpurc ) SELECT _invhistid, itemloc_location_id, itemloc_ls_id, (pQty * -1), itemloc_qty, (itemloc_qty - pQty), itemloc_expiration, itemloc_warrpurc FROM itemloc WHERE (itemloc_id=pSourceItemlocid); UPDATE itemloc SET itemloc_qty=(itemloc_qty - pQty) FROM itemsite WHERE ( (itemloc_itemsite_id=itemsite_id) AND (NOT itemsite_freeze) AND (itemloc_id=pSourceItemlocid) ); -- Check to see if any of the current Lot/Serial #/Expiration exists at the target location SELECT itemloc_id INTO _targetItemlocid FROM itemloc WHERE ( (COALESCE(itemloc_ls_id, -1)=COALESCE(_p.itemloc_ls_id,-1)) AND (COALESCE(itemloc_expiration,endOfTime())=COALESCE(_p.itemloc_expiration,endOfTime())) AND (COALESCE(itemloc_warrpurc,endOfTime())=COALESCE(_p.itemloc_warrpurc,endOfTime())) AND (itemloc_itemsite_id=pItemsiteid) AND (itemloc_location_id=pTargetLocationid) ); IF (NOT FOUND) THEN SELECT NEXTVAL('itemloc_itemloc_id_seq') INTO _targetItemlocid; INSERT INTO itemloc ( itemloc_id, itemloc_itemsite_id, itemloc_location_id, itemloc_ls_id, itemloc_expiration, itemloc_warrpurc, itemloc_qty ) VALUES ( _targetItemlocid, pItemsiteid, pTargetLocationid, _p.itemloc_ls_id, _p.itemloc_expiration, _p.itemloc_warrpurc, 0 ); END IF; -- Relocate the inventory to the resultant target and record the transactions INSERT INTO invdetail ( invdetail_invhist_id, invdetail_location_id, invdetail_ls_id, invdetail_qty, invdetail_qty_before, invdetail_qty_after, invdetail_expiration, invdetail_warrpurc ) SELECT _invhistid, pTargetLocationid, _p.itemloc_ls_id, pQty, itemloc_qty, (itemloc_qty + pQty), _p.itemloc_expiration, _p.itemloc_warrpurc FROM itemloc WHERE (itemloc_id=_targetItemlocid); UPDATE itemloc SET itemloc_qty=(itemloc_qty + pQty) FROM itemsite WHERE ( (itemloc_itemsite_id=itemsite_id) AND (NOT itemsite_freeze) AND (itemloc_id=_targetItemlocid) ); UPDATE invhist SET invhist_hasdetail=TRUE WHERE (invhist_id=_invhistid); -- Check to see if there is anything left at the target Itemloc and delete if not -- Could be zero if relocate increased a negative quantity to zero DELETE FROM itemloc WHERE ( (itemloc_qty=0) AND (itemloc_id=_targetItemlocid) ); -- Handle Reservations IF (fetchMetricBool('EnableSOReservationsByLocation')) THEN SELECT CASE WHEN (qtyReservedLocation(itemloc_id) > itemloc_qty) THEN (qtyReservedLocation(itemloc_id) - itemloc_qty) ELSE 0.0 END INTO _qtyunreserved FROM itemloc WHERE (itemloc_id=pSourceItemlocid); -- Move reservations as necessary WHILE (_qtyunreserved > 0.0) LOOP SELECT * INTO _rsrv FROM reserve WHERE ((reserve_supply_type='I') AND (reserve_supply_id=pSourceItemlocid)) ORDER BY reserve_qty; IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot find reservation to unreserve.'; END IF; IF (_rsrv.reserve_qty > _qtyunreserved) THEN _qtytomove := _qtyunreserved; ELSE _qtytomove := _rsrv.reserve_qty; END IF; -- Unreserve Source Location SELECT unreserveSOLineQty(_rsrv.reserve_demand_id, _qtytomove, pSourceItemlocid) INTO _result; IF (_result < 0) THEN RAISE EXCEPTION 'unreserveSOLineQty failed with result=%, reserve_id=%, qty=%', _result, _rsrv.reserve_id, _qtytomove; END IF; -- Reserve to new Location SELECT reserveSOLineQty(_rsrv.reserve_demand_id, TRUE, _qtytomove, _targetItemlocid) INTO _result; IF (_result < 0) THEN RAISE EXCEPTION 'reserveSOLineQty failed with result=%, reserve_id=%, qty=%', _result, _rsrv.reserve_id, _qtytomove; END IF; -- Calculate running total _qtyunreserved := _qtyunreserved - _qtytomove; END LOOP; END IF; -- Check to see if there is anything left at the source Itemloc and delete if not DELETE FROM itemloc WHERE ( (itemloc_qty=0) AND (itemloc_id=pSourceItemlocid) ); -- Return the invhist_id RETURN _invhistid; END; $$; DROP FUNCTION public.relocateinventory(psourceitemlocid integer, ptargetlocationid integer, pitemsiteid integer, pqty numeric, pcomments text, pgldistts timestamp with time zone); publicadminfalse84623125579271!reopenbankreconciliation(integer)FUNCTION.CREATE FUNCTION reopenbankreconciliation(pbankrecid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN bankReconciliation(pBankrecid, 'reopen'); END; $$; CDROP FUNCTION public.reopenbankreconciliation(pbankrecid integer); publicadminfalse84623125579272&reorderdate(integer, integer, boolean)FUNCTIONOCREATE FUNCTION reorderdate(integer, integer, boolean) RETURNS date LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pLookAhead ALIAS FOR $2; pIncludePlanned ALIAS FOR $3; _runningAvailability NUMERIC; _reorderLevel NUMERIC; _availability RECORD; BEGIN -- Make sure that we know how to handle the passed part IF ( SELECT (NOT (item_type IN ('M', 'P'))) FROM item, itemsite WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ) ) THEN RETURN NULL; END IF; -- Load the initial QOH SELECT itemsite_qtyonhand INTO _runningAvailability FROM itemsite WHERE (itemsite_id=pItemsiteid); -- Grab the Reorder Level, if any IF ( ( SELECT itemsite_useparams FROM itemsite WHERE (itemsite_id=pItemsiteid) ) ) THEN SELECT itemsite_reorderlevel INTO _reorderLevel FROM itemsite WHERE (itemsite_id=pItemsiteid); ELSE _reorderLevel := 0; END IF; -- If we are already below the Reorder Level then we should order ASAP IF (_runningAvailability <= _reorderLevel) THEN RETURN CURRENT_DATE; END IF; -- Grab all of the availability trigger points FOR _availability IN SELECT 1 AS seq, wo_duedate AS orderdate, (noNeg(wo_qtyord - wo_qtyrcv)) AS balance FROM wo WHERE ((wo_status IN ('O', 'E', 'R', 'I')) AND (wo_duedate <= (CURRENT_DATE + pLookAhead)) AND (wo_itemsite_id=pItemsiteid)) UNION SELECT 2 AS seq, womatl_duedate AS orderdate, (noNeg(itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq - womatl_qtyiss)) * -1) AS balance FROM womatl, wo, itemsite WHERE ((wo_status IN ('O', 'E', 'R', 'I')) AND (womatl_wo_id=wo_id) AND (womatl_itemsite_id=itemsite_id) AND (womatl_duedate <= (CURRENT_DATE + pLookahead)) AND (womatl_itemsite_id=pItemsiteid)) UNION SELECT 1 AS seq, poitem_duedate AS orderdate, (noNeg(poitem_qty_ordered - poitem_qty_received) * poitem_invvenduomratio) AS balance FROM pohead, poitem WHERE ((poitem_pohead_id=pohead_id) AND (poitem_status = 'O') AND (poitem_duedate <= (CURRENT_DATE + pLookAhead)) AND (poitem_itemsite_id=pItemsiteid)) UNION SELECT 2 AS seq, coitem_scheddate AS orderdate, (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * -1) AS balance FROM coitem, cohead WHERE ((coitem_status = 'O') AND (coitem_cohead_id=cohead_id) AND (coitem_scheddate <= (CURRENT_DATE + pLookAhead)) AND (coitem_itemsite_id=pItemsiteid)) UNION SELECT 2 AS seq, planord_startdate AS orderdate, (planreq_qty * -1) AS balance FROM planreq, planord WHERE ( (pIncludePlanned) AND (planreq_source='P') AND (planreq_source_id=planord_id) AND (planord_startdate <= (CURRENT_DATE + pLookAhead)) AND (planord_itemsite_id=pItemsiteid) ) UNION SELECT 1 AS seq, planord_duedate AS orderdate, planord_qty AS balance FROM planord WHERE ( (pIncludePlanned) AND (planord_duedate <= (CURRENT_DATE + pLookAhead)) AND (planord_itemsite_id=pItemsiteid) ) ORDER BY orderdate, seq LOOP -- Calculate the new projected availability _runningAvailability := (_runningAvailability + _availability.balance); -- Check to see if the project availability drop below the reorder level IF (_runningAvailability < _reorderLevel) THEN RETURN _availability.orderdate; END IF; END LOOP; -- The reorder level was not reached within the look ahead period RETURN NULL; END; $_$; =DROP FUNCTION public.reorderdate(integer, integer, boolean); publicadminfalse84623125579273!replaceallvoidedapchecks(integer)FUNCTIONyCREATE FUNCTION replaceallvoidedapchecks(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'replaceAllVoidedAPChecks() is deprecated - use replaceAllVoidedChecks() instead'; RETURN replaceAllVoidedChecks($1); END; $_$; 8DROP FUNCTION public.replaceallvoidedapchecks(integer); publicadminfalse84623125579274replaceallvoidedchecks(integer)FUNCTIONSCREATE FUNCTION replaceallvoidedchecks(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBankaccntid ALIAS FOR $1; _returnValue INTEGER := 0; BEGIN SELECT MIN(replaceVoidedCheck(checkhead_id)) INTO _returnValue FROM checkhead WHERE ( (checkhead_void) AND (NOT checkhead_posted) AND (NOT checkhead_replaced) AND (NOT checkhead_deleted) AND (checkhead_bankaccnt_id=pBankaccntid) ); RETURN _returnValue; END; $_$; 6DROP FUNCTION public.replaceallvoidedchecks(integer); publicadminfalse46238125579275replacevoidedapcheck(integer)FUNCTIONaCREATE FUNCTION replacevoidedapcheck(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'replaceVoidedAPCheck() is deprecated - use replaceVoidedCheck()'; RETURN replaceVoidedCheck($1); END; $_$; 4DROP FUNCTION public.replacevoidedapcheck(integer); publicadminfalse46238125579276replacevoidedcheck(integer)FUNCTION, CREATE FUNCTION replacevoidedcheck(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCheckid ALIAS FOR $1; _newCheckid INTEGER; BEGIN IF ( ( SELECT ( (NOT checkhead_void) OR checkhead_posted OR checkhead_replaced ) FROM checkhead WHERE (checkhead_id=pCheckid) ) ) THEN RETURN -1; END IF; -- has someone created a new check for one of the items while this was void? IF EXISTS (SELECT dup.checkitem_id FROM checkitem orig, checkitem dup, checkhead AS duphead WHERE ((COALESCE(orig.checkitem_aropen_id,-1)=COALESCE(dup.checkitem_aropen_id,-1)) AND (COALESCE(orig.checkitem_apopen_id,-1)=COALESCE(dup.checkitem_apopen_id,-1)) AND (orig.checkitem_checkhead_id!=dup.checkitem_checkhead_id) AND (dup.checkitem_checkhead_id=duphead.checkhead_id) AND (NOT duphead.checkhead_void) AND (orig.checkitem_checkhead_id=pCheckid))) THEN RETURN -2; END IF; SELECT NEXTVAL('checkhead_checkhead_id_seq') INTO _newCheckid; INSERT INTO checkhead ( checkhead_id, checkhead_recip_id, checkhead_recip_type, checkhead_bankaccnt_id, checkhead_checkdate, checkhead_number, checkhead_amount, checkhead_for, checkhead_journalnumber, checkhead_notes, checkhead_misc, checkhead_expcat_id, checkhead_curr_id ) SELECT _newCheckid, checkhead_recip_id, checkhead_recip_type, checkhead_bankaccnt_id, checkhead_checkdate, -1, -- fetchNextCheckNumber(checkhead_bankaccnt_id), checkhead_amount, checkhead_for, checkhead_journalnumber, checkhead_notes || ' Replaces voided check ' || checkhead_number, checkhead_misc, checkhead_expcat_id, checkhead_curr_id FROM checkhead WHERE (checkhead_id=pCheckid); INSERT INTO checkitem ( checkitem_checkhead_id, checkitem_amount, checkitem_discount, checkitem_ponumber, checkitem_vouchernumber, checkitem_invcnumber, checkitem_apopen_id, checkitem_aropen_id, checkitem_docdate, checkitem_curr_id, checkitem_curr_rate ) SELECT _newCheckid, checkitem_amount, checkitem_discount, checkitem_ponumber, checkitem_vouchernumber, checkitem_invcnumber, checkitem_apopen_id, checkitem_aropen_id, checkitem_docdate, checkitem_curr_id, checkitem_curr_rate FROM checkitem WHERE (checkitem_checkhead_id=pCheckid); UPDATE checkhead SET checkhead_replaced=TRUE WHERE (checkhead_id=pCheckid); RETURN _newCheckid; END; $_$; 2DROP FUNCTION public.replacevoidedcheck(integer); publicadminfalse84623125579277)reprioritizewo(integer, integer, boolean)FUNCTIONRCREATE FUNCTION reprioritizewo(integer, integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; pPriority ALIAS FOR $2; pChangeChildren ALIAS FOR $3; _status CHAR(1); _result INTEGER; BEGIN SELECT wo_status INTO _status FROM wo WHERE (wo_id=pWoid); IF (NOT (_status IN ('O', 'E','R','I'))) THEN return -1; END IF; UPDATE wo SET wo_priority=pPriority WHERE (wo_id=pWoid); IF ( (_status IN ('E','R','I')) AND (pChangeChildren) ) THEN SELECT COALESCE(MIN(reprioritizeWo(wo_id, pPriority, TRUE)), 1) INTO _result FROM wo WHERE ( (wo_ordtype='W') AND (wo_ordid=pWoid) ); ELSE _result = 1; END IF; RETURN _result; END; $_$; @DROP FUNCTION public.reprioritizewo(integer, integer, boolean); publicadminfalse84623125579278resetdbobjperms()FUNCTIONCREATE FUNCTION resetdbobjperms() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _count INTEGER := 0; BEGIN SELECT SUM(resetDBObjPerms(nspname || '.' || relname)) INTO _count FROM pg_catalog.pg_class, pg_catalog.pg_namespace WHERE (relkind IN ('r', 'S', 'v') AND (relnamespace=pg_namespace.oid) AND (nspname IN ('public', 'api'))); RETURN _count; END; $$; (DROP FUNCTION public.resetdbobjperms(); publicadminfalse46238125579279resetdbobjperms(text)FUNCTIONCREATE FUNCTION resetdbobjperms(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pObjname ALIAS FOR $1; BEGIN EXECUTE 'ALTER TABLE ' || pObjname || ' OWNER TO ' || getEffectiveXtUser() || ';'; EXECUTE 'REVOKE ALL ON ' || pObjname || ' FROM PUBLIC;'; EXECUTE 'GRANT ALL ON ' || pObjname || ' TO GROUP xtrole;'; RETURN 1; END; $_$; ,DROP FUNCTION public.resetdbobjperms(text); publicadminfalse46238125579280resetlowlevelcode(integer)FUNCTIONCREATE FUNCTION resetlowlevelcode(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemId ALIAS FOR $1; _result INTEGER; _counterNum INTEGER := 1; _feedBackNum INTEGER := 1; _r RECORD; BEGIN DELETE FROM costUpdate; IF pItemId = -1 THEN -- -1 is an invalid item_id => do them all INSERT INTO costUpdate ( costUpdate_item_id, costUpdate_item_type ) SELECT item_id, item_type FROM item; -- Recalculate the Item Lowlevel codes WHILE _feedBackNum > 0 LOOP SELECT updateLowlevel(_counterNum) INTO _feedBackNum; _counterNum := _counterNum + 1; END LOOP; ELSE INSERT INTO costUpdate ( costUpdate_item_id, costUpdate_item_type ) SELECT item_id, item_type FROM item WHERE (item_id=pItemId); FOR _r IN SELECT item_id, bomdata_bomwork_level, item_type FROM item, indentedBOM(pItemId, getActiveRevId('BOM',pItemId),0,0) WHERE (bomdata_item_id=item_id) ORDER BY bomdata_bomwork_level LOOP -- this only works because of the ORDER BY in the loop SELECT UPDATE costUpdate SET costupdate_lowlevel_code = _r.bomdata_bomwork_level WHERE (costupdate_item_id=_r.item_id); IF (NOT FOUND) THEN INSERT INTO costUpdate ( costUpdate_item_id, costUpdate_lowlevel_code, costUpdate_item_type ) VALUES ( _r.item_id, _r.bomdata_bomwork_level, _r.item_type ); END IF; END LOOP; END IF; SELECT count(*) INTO _result FROM costUpdate; RETURN _result; END; $_$; 1DROP FUNCTION public.resetlowlevelcode(integer); publicadminfalse84623125579281resetqohbalance(integer)FUNCTIONCREATE FUNCTION resetqohbalance(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN resetQOHBalance($1, CURRENT_TIMESTAMP); END; $_$; /DROP FUNCTION public.resetqohbalance(integer); publicadminfalse846231255792822resetqohbalance(integer, timestamp with time zone)FUNCTIONCREATE FUNCTION resetqohbalance(integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pGlDistTS ALIAS FOR $2; _invhistid INTEGER; _itemlocSeries INTEGER; BEGIN IF ( ( SELECT ( (itemsite_controlmethod IN ('L', 'S')) OR (item_type = 'R') OR (itemsite_costmethod = 'J') OR (itemsite_loccntrl) OR (itemsite_qtyonhand > 0) ) FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ) ) ) THEN RETURN 0; END IF; _itemlocSeries := NEXTVAL('itemloc_series_seq'); SELECT postInvTrans( itemsite_id, 'AD', (itemsite_qtyonhand * -1), 'I/M', '', '', 'RESET', 'Reset QOH Balance to 0', costcat_asset_accnt_id, costcat_adjustment_accnt_id, _itemlocSeries, pGlDistTS ) INTO _invhistid FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=pItemsiteid) ); PERFORM postItemLocSeries(_itemlocSeries); RETURN _invhistid; END; $_$; IDROP FUNCTION public.resetqohbalance(integer, timestamp with time zone); publicadminfalse46238125579283#resolvecosaccount(integer, integer)FUNCTION)CREATE FUNCTION resolvecosaccount(integer, integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN resolveCOSAccount($1, $2, -1, -1); END; $_$; :DROP FUNCTION public.resolvecosaccount(integer, integer); publicadminfalse462381255792845resolvecosaccount(integer, integer, integer, integer)FUNCTIONCREATE FUNCTION resolvecosaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer) RETURNS integer LANGUAGE plpgsql STABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _salesaccntid INTEGER; _accntid INTEGER; BEGIN SELECT findSalesAccnt(pItemsiteid, 'IS', pCustid, pSaletypeid, pShipzoneid) INTO _salesaccntid; IF (_salesaccntid = -1) THEN SELECT getUnassignedAccntId(getitemsitecompanyid(pItemsiteid)) INTO _accntid; ELSE SELECT salesaccnt_cos_accnt_id INTO _accntid FROM salesaccnt WHERE (salesaccnt_id=_salesaccntid); END IF; RETURN _accntid; END; $$; xDROP FUNCTION public.resolvecosaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer); publicadminfalse84623125579285#resolvecowaccount(integer, integer)FUNCTION)CREATE FUNCTION resolvecowaccount(integer, integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN resolveCOWAccount($1, $2, -1, -1); END; $_$; :DROP FUNCTION public.resolvecowaccount(integer, integer); publicadminfalse846231255792865resolvecowaccount(integer, integer, integer, integer)FUNCTIONCREATE FUNCTION resolvecowaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _salesaccntid INTEGER; _accntid INTEGER; BEGIN SELECT findSalesAccnt(pItemsiteid, 'IS', pCustid, pSaletypeid, pShipzoneid) INTO _salesaccntid; IF (_salesaccntid = -1) THEN SELECT getUnassignedAccntId(getitemsitecompanyid(pItemsiteid)) INTO _accntid; ELSE SELECT salesaccnt_cow_accnt_id INTO _accntid FROM salesaccnt WHERE (salesaccnt_id=_salesaccntid); END IF; RETURN _accntid; END; $$; xDROP FUNCTION public.resolvecowaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer); publicadminfalse84623125579287&resolvecreditaccount(integer, integer)FUNCTION/CREATE FUNCTION resolvecreditaccount(integer, integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN resolveCreditAccount($1, $2, -1, -1); END; $_$; =DROP FUNCTION public.resolvecreditaccount(integer, integer); publicadminfalse846231255792888resolvecreditaccount(integer, integer, integer, integer)FUNCTIONCREATE FUNCTION resolvecreditaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _salesaccntid INTEGER; _accntid INTEGER; BEGIN SELECT findSalesAccnt(pItemsiteid, 'IS', pCustid, pSaletypeid, pShipzoneid) INTO _salesaccntid; IF (_salesaccntid = -1) THEN SELECT getUnassignedAccntId(getitemsitecompanyid(pItemsiteid)) INTO _accntid; ELSE SELECT salesaccnt_credit_accnt_id INTO _accntid FROM salesaccnt WHERE (salesaccnt_id=_salesaccntid); END IF; RETURN _accntid; END; $$; {DROP FUNCTION public.resolvecreditaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer); publicadminfalse84623(125579289%resolvesalesaccount(integer, integer)FUNCTION-CREATE FUNCTION resolvesalesaccount(integer, integer) RETURNS integer LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN resolveSalesAccount($1, $2, -1, -1); END; $_$; <DROP FUNCTION public.resolvesalesaccount(integer, integer); publicadminfalse462381255792907resolvesalesaccount(integer, integer, integer, integer)FUNCTIONCREATE FUNCTION resolvesalesaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _salesaccntid INTEGER; _accntid INTEGER; BEGIN SELECT findSalesAccnt(pItemsiteid, 'IS', pCustid, pSaletypeid, pShipzoneid) INTO _salesaccntid; IF (_salesaccntid = -1) THEN SELECT getUnassignedAccntId(getitemsitecompanyid(pItemsiteid)) INTO _accntid; ELSE SELECT salesaccnt_sales_accnt_id INTO _accntid FROM salesaccnt WHERE (salesaccnt_id=_salesaccntid); END IF; RETURN _accntid; END; $$; zDROP FUNCTION public.resolvesalesaccount(pitemsiteid integer, pcustid integer, psaletypeid integer, pshipzoneid integer); publicadminfalse84623125579291restoresaleshistory(integer)FUNCTIONCREATE FUNCTION restoresaleshistory(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAsohistid ALIAS FOR $1; BEGIN INSERT INTO cohist ( cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipdate, cohist_invcdate, cohist_duedate, cohist_promisedate, cohist_ordernumber, cohist_invcnumber, cohist_qtyshipped, cohist_unitprice, cohist_unitcost, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_shipto_id, cohist_shipvia, cohist_salesrep_id, cohist_misc_type, cohist_misc_descrip, cohist_misc_id, cohist_commission, cohist_commissionpaid, cohist_doctype, cohist_orderdate, cohist_imported, cohist_ponumber, cohist_curr_id, cohist_taxtype_id, cohist_taxzone_id ) SELECT asohist_id, CASE asohist_cust_id WHEN -1 THEN NULL ELSE asohist_cust_id END, asohist_itemsite_id, asohist_shipdate, asohist_invcdate, asohist_duedate, asohist_promisedate, asohist_ordernumber, asohist_invcnumber, asohist_qtyshipped, asohist_unitprice, asohist_unitcost, asohist_billtoname, asohist_billtoaddress1, asohist_billtoaddress2, asohist_billtoaddress3, asohist_billtocity, asohist_billtostate, asohist_billtozip, asohist_shiptoname, asohist_shiptoaddress1, asohist_shiptoaddress2, asohist_shiptoaddress3, asohist_shiptocity, asohist_shiptostate, asohist_shiptozip, asohist_shipto_id, asohist_shipvia, CASE asohist_salesrep_id WHEN -1 THEN NULL ELSE asohist_salesrep_id END, asohist_misc_type, asohist_misc_descrip, asohist_misc_id, asohist_commission, asohist_commissionpaid, asohist_doctype, asohist_orderdate, asohist_imported, asohist_ponumber, asohist_curr_id, asohist_taxtype_id, asohist_taxzone_id FROM asohist WHERE (asohist_id=pAsohistid); INSERT INTO cohisttax ( taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber ) SELECT taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber FROM asohisttax WHERE (taxhist_parent_id=pAsohistid); DELETE FROM asohisttax WHERE (taxhist_parent_id=pAsohistid); DELETE FROM asohist WHERE (asohist_id=pAsohistid); RETURN pAsohistid; END; $_$; 3DROP FUNCTION public.restoresaleshistory(integer); publicadminfalse46238125579292returncompleteshipment(integer)FUNCTION+CREATE FUNCTION returncompleteshipment(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN returnCompleteShipment($1, 0, CURRENT_TIMESTAMP); END; $_$; 6DROP FUNCTION public.returncompleteshipment(integer); publicadminfalse84623125579293Breturncompleteshipment(integer, integer, timestamp with time zone)FUNCTIONKCREATE FUNCTION returncompleteshipment(integer, integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pshipheadid ALIAS FOR $1; _itemlocSeries INTEGER := $2; _timestamp TIMESTAMP WITH TIME ZONE := $3; _r RECORD; _result RECORD; _shiphead_number TEXT := ''; _count INTEGER := 0; _countsum INTEGER := 0; BEGIN FOR _r IN SELECT shipitem_id FROM shipitem, shiphead WHERE ( (shipitem_shiphead_id=shiphead_id) AND (NOT shiphead_shipped) AND (shiphead_id=pshipheadid) ) LOOP _itemlocSeries := returnShipmentTransaction(_r.shipitem_id, _itemlocSeries, _timestamp); END LOOP; FOR _result IN SELECT shiphead_number FROM shiphead WHERE ( (shiphead_id=pshipheadid) ) LOOP _shiphead_number := _result.shiphead_number; END LOOP; SELECT COUNT(*) INTO _count FROM shipdata WHERE(shipdata_shiphead_number=_shiphead_number); SELECT COUNT(*) INTO _countsum FROM shipdatasum WHERE(shipdatasum_shiphead_number=_shiphead_number); IF (_count > 0) THEN DELETE FROM shipdata WHERE(shipdata_shiphead_number=_shiphead_number); END IF; IF (_countsum > 0) THEN DELETE FROM shipdatasum WHERE(shipdatasum_shiphead_number=_shiphead_number); END IF; DELETE FROM pack WHERE(pack_shiphead_id=pshipheadid); DELETE FROM shiphead WHERE (shiphead_id=pshipheadid); RETURN _itemlocSeries; END; $_$; YDROP FUNCTION public.returncompleteshipment(integer, integer, timestamp with time zone); publicadminfalse84623125579294returnitemshipments(integer)FUNCTION+CREATE FUNCTION returnitemshipments(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN returnItemShipments('SO', $1, 0, CURRENT_TIMESTAMP); END; $_$; 3DROP FUNCTION public.returnitemshipments(integer); publicadminfalse46238125579295%returnitemshipments(integer, integer)FUNCTION5CREATE FUNCTION returnitemshipments(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN returnItemShipments('SO', $1, $2, CURRENT_TIMESTAMP); END; $_$; <DROP FUNCTION public.returnitemshipments(integer, integer); publicadminfalse46238125579296Ereturnitemshipments(text, integer, integer, timestamp with time zone)FUNCTIONCREATE FUNCTION returnitemshipments(text, integer, integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; pitemid ALIAS FOR $2; _itemlocSeries INTEGER := $3; _timestamp TIMESTAMP WITH TIME ZONE := $4; _invhistid INTEGER; _r RECORD; BEGIN IF (COALESCE(_itemlocSeries,0) = 0 ) THEN _itemlocSeries := NEXTVAL('itemloc_series_seq'); END IF; FOR _r IN SELECT shipitem_id FROM shipitem JOIN shiphead ON (shiphead_id=shipitem_shiphead_id) WHERE ((NOT shiphead_shipped) AND (shiphead_order_type=pordertype) AND (shipitem_orderitem_id=pitemid)) LOOP SELECT returnShipmentTransaction(_r.shipitem_id, _itemlocSeries, _timestamp) INTO _itemlocSeries; IF (_itemlocSeries < 0) THEN RETURN _itemlocSeries; END IF; END LOOP; RETURN _itemlocSeries; END; $_$; \DROP FUNCTION public.returnitemshipments(text, integer, integer, timestamp with time zone); publicadminfalse84623125579297"returnshipmenttransaction(integer)FUNCTION1CREATE FUNCTION returnshipmenttransaction(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN returnShipmentTransaction($1, 0, CURRENT_TIMESTAMP); END; $_$; 9DROP FUNCTION public.returnshipmenttransaction(integer); publicadminfalse46238125579298+returnshipmenttransaction(integer, integer)FUNCTION;CREATE FUNCTION returnshipmenttransaction(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN returnShipmentTransaction($1, $2, CURRENT_TIMESTAMP); END; $_$; BDROP FUNCTION public.returnshipmenttransaction(integer, integer); publicadminfalse46238125579299Ereturnshipmenttransaction(integer, integer, timestamp with time zone)FUNCTION$CREATE FUNCTION returnshipmenttransaction(integer, integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipitemId ALIAS FOR $1; pItemlocSeries ALIAS FOR $2; pTimestamp ALIAS FOR $3; _itemlocSeries INTEGER; _invhistid INTEGER; _reserveid INTEGER; _coheadid INTEGER; _rows INTEGER; _r RECORD; _rsrv RECORD; BEGIN IF (COALESCE(pItemlocSeries, 0) = 0 ) THEN _itemlocSeries := NEXTVAL('itemloc_series_seq'); ELSE _itemlocSeries := pItemlocSeries; END IF; -- Find the shipment transaction record SELECT shipitem.*, shiphead_id, shiphead_number, shiphead_order_type, invhist_series, itemsite_loccntrl, itemsite_costmethod, itemsite_controlmethod, cohead_prj_id AS prj_id INTO _r FROM shipitem JOIN shiphead ON (shiphead_id=shipitem_shiphead_id) JOIN invhist ON (invhist_id=shipitem_invhist_id) JOIN itemsite ON (itemsite_id=invhist_itemsite_id) LEFT OUTER JOIN cohead ON ((shiphead_order_type = 'SO') AND (shiphead_order_id = cohead_id)) WHERE ((NOT shiphead_shipped) AND (shipitem_id=pShipitemId)); GET DIAGNOSTICS _rows = ROW_COUNT; IF (_rows = 0 ) THEN -- Was it a non-controlled sales order item? SELECT shipitem.*, shiphead_id, shiphead_number, shiphead_order_type, itemsite_loccntrl, itemsite_costmethod, itemsite_controlmethod, cohead_prj_id AS prj_id INTO _r FROM shipitem JOIN shiphead ON (shiphead_id=shipitem_shiphead_id) JOIN coitem ON (shipitem_orderitem_id=coitem_id) JOIN cohead ON (cohead_id=coitem_cohead_id) JOIN itemsite ON (itemsite_id=coitem_itemsite_id) WHERE ((NOT shiphead_shipped) AND (shipitem_id=pShipitemId) AND (shiphead_order_type = 'SO')); END IF; GET DIAGNOSTICS _rows = ROW_COUNT; IF (_rows = 0 AND fetchmetricbool('MultiWhs') ) THEN -- Was it a non-controlled transfer order item? SELECT shipitem.*, shiphead_id, shiphead_number, shiphead_order_type, itemsite_loccntrl, itemsite_costmethod, itemsite_controlmethod, NULL AS prj_id INTO _r FROM shipitem JOIN shiphead ON (shiphead_id=shipitem_shiphead_id) JOIN toitem ON (shipitem_orderitem_id=toitem_id) JOIN itemsite ON (itemsite_id=coitem_itemsite_id) WHERE ((NOT shiphead_shipped) AND (shipitem_id=pShipitemId) AND (shiphead_order_type = 'TO')); END IF; IF (_rows > 0 ) THEN IF (_r.shiphead_order_type = 'SO') THEN -- Handle inventory transaction IF (_r.itemsite_controlmethod != 'N' OR _r.itemsite_costmethod = 'J') THEN SELECT postInvTrans( itemsite_id, 'RS', (_r.shipitem_qty * coitem_qty_invuomratio), 'S/R', _r.shiphead_order_type, formatSoNumber(_r.shipitem_orderitem_id), shiphead_number, 'Return from Shipping', costcat_asset_accnt_id, getPrjAccntId(_r.prj_id, costcat_shipasset_accnt_id), _itemlocSeries, pTimestamp, _r.shipitem_value, _r.shipitem_invhist_id ) INTO _invhistid FROM coitem, itemsite, costcat, shiphead, shipitem WHERE ((coitem_itemsite_id=itemsite_id) AND (itemsite_costcat_id=costcat_id) AND (coitem_id=_r.shipitem_orderitem_id) AND (shiphead_order_type=_r.shiphead_order_type) AND (shiphead_id=shipitem_shiphead_id) AND (shipitem_orderitem_id=_r.shipitem_orderitem_id)); -- We know the distribution so post this through so the any w/o activity knows about it PERFORM postItemlocseries(_itemlocSeries); END IF; IF (_r.itemsite_costmethod = 'J') THEN -- Reopen the work order UPDATE wo SET wo_status = 'I' WHERE ((wo_ordtype='S') AND (wo_ordid=_r.shipitem_orderitem_id)); -- Job cost, so correct Production Posting referencing original receipt for reverse info. PERFORM correctProduction(wo_id, invhist_invqty, false, _itemlocSeries, pTimestamp, invhist_id) FROM wo, invhist WHERE ((wo_ordtype = 'S') AND (wo_ordid = _r.shipitem_orderitem_id) AND (invhist_series=_r.invhist_series) AND (invhist_transtype='RM')); -- Return eligble material PERFORM returnWoMaterial(womatlpost_womatl_id, _itemlocSeries, pTimestamp, womatlpost_invhist_id) FROM womatlpost, invhist m, invhist s WHERE ((womatlpost_invhist_id=m.invhist_id) AND (m.invhist_series=s.invhist_series) AND (m.invhist_transtype='IM') AND (s.invhist_id=_r.shipitem_invhist_id)); END IF; -- end Job Costing ELSIF (_r.shiphead_order_type = 'TO') THEN SELECT postInvTrans(itemsite_id, 'RS', _r.shipitem_qty, 'S/R', _r.shiphead_order_type, formatToNumber(toitem_id), tohead_number, 'Return from Shipping', costcat_asset_accnt_id, costcat_shipasset_accnt_id, _itemlocSeries, pTimestamp, _r.shipitem_value, _r.shipitem_invhist_id ) INTO _invhistid FROM toitem, tohead, itemsite, costcat WHERE ((toitem_item_id=itemsite_item_id) AND (toitem_tohead_id=tohead_id) AND (tohead_src_warehous_id=itemsite_warehous_id) AND (itemsite_costcat_id=costcat_id) AND (toitem_id=_r.shipitem_orderitem_id)); ELSE -- Don't know what kind of order this is RETURN -11; END IF; UPDATE shiphead SET shiphead_sfstatus='D' WHERE ((shiphead_id=_r.shiphead_id) AND (shiphead_sfstatus='P')); -- Handle reservation if applicable IF (fetchmetricbool('EnableSOReservations')) THEN UPDATE coitem SET coitem_qtyreserved = (coitem_qtyreserved + shipitemrsrv_qty) FROM shipitemrsrv WHERE ((coitem_id=_r.shipitem_orderitem_id) AND (shipitemrsrv_shipitem_id=_r.shipitem_id)); -- Handle location reservations if applicable FOR _rsrv IN SELECT * FROM shipitemlocrsrv WHERE (shipitemlocrsrv_shipitem_id=_r.shipitem_id) LOOP -- See if a reservation record still exists SELECT reserve_id INTO _reserveid FROM reserve JOIN itemloc ON (reserve_supply_id=itemloc_id) WHERE ((reserve_supply_type='I') AND (reserve_demand_type = 'SO') AND (reserve_demand_id = _r.shipitem_orderitem_id ) AND (itemloc_itemsite_id=_rsrv.shipitemlocrsrv_itemsite_id) AND (itemloc_location_id=_rsrv.shipitemlocrsrv_location_id) AND (COALESCE(itemloc_ls_id, -1)=COALESCE(_rsrv.shipitemlocrsrv_ls_id, -1)) AND (COALESCE(itemloc_expiration, endOfTime())=COALESCE(_rsrv.shipitemlocrsrv_expiration, endOfTime())) AND (COALESCE(itemloc_warrpurc, endoftime())=COALESCE(_rsrv.shipitemlocrsrv_warrpurc, endoftime())) ); GET DIAGNOSTICS _rows = ROW_COUNT; IF (_rows > 0 ) THEN -- Update existing UPDATE reserve SET reserve_qty = (reserve_qty + _rsrv.shipitemlocrsrv_qty) WHERE (reserve_id=_reserveid); ELSE -- Recreate record INSERT INTO reserve SELECT nextval('reserve_reserve_id_seq'), 'SO', _r.shipitem_orderitem_id, 'I', itemloc_id, _rsrv.shipitemlocrsrv_qty, 'R' FROM itemloc WHERE ((itemloc_itemsite_id=_rsrv.shipitemlocrsrv_itemsite_id) AND (itemloc_location_id=_rsrv.shipitemlocrsrv_location_id) AND (COALESCE(itemloc_ls_id, -1)=COALESCE(_rsrv.shipitemlocrsrv_ls_id, -1)) AND (COALESCE(itemloc_expiration, endOfTime())=COALESCE(_rsrv.shipitemlocrsrv_expiration, endOfTime())) AND (COALESCE(itemloc_warrpurc, endoftime())=COALESCE(_rsrv.shipitemlocrsrv_warrpurc, endoftime())) ); END IF; END LOOP; END IF; DELETE FROM shipitem WHERE (shipitem_id = _r.shipitem_id ); -- Clean up if this is the last shipitem on the shipment IF (NOT EXISTS(SELECT shipitem_shiphead_id FROM shipitem WHERE (shipitem_shiphead_id=_r.shiphead_id))) THEN DELETE FROM shipdata WHERE(shipdata_shiphead_number=_r.shiphead_number); DELETE FROM shipdatasum WHERE(shipdatasum_shiphead_number=_r.shiphead_number); DELETE FROM pack WHERE(pack_shiphead_id=_r.shiphead_id); DELETE FROM shiphead WHERE (shiphead_id=_r.shiphead_id); END IF; END IF; RETURN _itemlocSeries; END; $_$; \DROP FUNCTION public.returnshipmenttransaction(integer, integer, timestamp with time zone); publicadminfalse46238125579301<returnwomaterial(integer, numeric, timestamp with time zone)FUNCTIONCREATE FUNCTION returnwomaterial(integer, numeric, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pQty ALIAS FOR $2; pGlDistTS ALIAS FOR $3; _itemlocSeries INTEGER; BEGIN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; RETURN returnWoMaterial(pWomatlid, pQty, _itemlocSeries, pGlDistTS); END; $_$; SDROP FUNCTION public.returnwomaterial(integer, numeric, timestamp with time zone); publicadminfalse46238125579302Ereturnwomaterial(integer, integer, timestamp with time zone, integer)FUNCTIONCREATE FUNCTION returnwomaterial(integer, integer, timestamp with time zone, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pItemlocSeries ALIAS FOR $2; pGlDistTS ALIAS FOR $3; pInvhistId ALIAS FOR $4; _woNumber TEXT; _invhistid INTEGER; _itemlocSeries INTEGER; _invqty NUMERIC; _womatlqty NUMERIC; _cost NUMERIC := 0; _rows INTEGER; BEGIN _itemlocSeries := 0; SELECT invhist_invqty, invhist_invqty * invhist_unitcost INTO _invqty, _cost FROM invhist WHERE (invhist_id=pInvhistId); GET DIAGNOSTICS _rows = ROW_COUNT; IF (_rows = 0) THEN RAISE EXCEPTION 'No transaction found for invhist_id %', pInvhistId; END IF; SELECT itemuomtouom(itemsite_item_id, NULL, womatl_uom_id, _invqty) INTO _womatlqty FROM womatl, itemsite WHERE((womatl_itemsite_id=itemsite_id) AND (womatl_id=pWomatlid)); GET DIAGNOSTICS _rows = ROW_COUNT; IF (_rows = 0) THEN _womatlqty := _invqty; END IF; IF ( SELECT ( CASE WHEN (womatl_qtyreq >= 0) THEN womatl_qtyiss < _womatlqty ELSE womatl_qtyiss > _womatlqty END ) FROM womatl WHERE ( womatl_id=pWomatlid ) ) THEN RETURN pItemlocSeries; END IF; SELECT formatWoNumber(womatl_wo_id) INTO _woNumber FROM womatl WHERE (womatl_id=pWomatlid); IF (pItemlocSeries = 0) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; ELSE _itemlocSeries = pItemlocSeries; END IF; -- Post the transaction SELECT postInvTrans( ci.itemsite_id, 'IM', (_invqty * -1), 'W/O', 'WO', _woNumber, '', ('Return ' || item_number || ' from Work Order'), getPrjAccntId(wo_prj_id, pc.costcat_wip_accnt_id), cc.costcat_asset_accnt_id, _itemlocSeries, pGlDistTS, -- Cost will be ignored by Standard Cost items sites _cost, pInvhistId) INTO _invhistid FROM womatl, wo, itemsite AS ci, costcat AS cc, itemsite AS pi, costcat AS pc, item WHERE((womatl_itemsite_id=ci.itemsite_id) AND (ci.itemsite_costcat_id=cc.costcat_id) AND (womatl_wo_id=wo_id) AND (wo_itemsite_id=pi.itemsite_id) AND (pi.itemsite_costcat_id=pc.costcat_id) AND (ci.itemsite_item_id=item_id) AND (womatl_id=pWomatlid) ); -- Create linkage to the transaction created INSERT INTO womatlpost (womatlpost_womatl_id,womatlpost_invhist_id) VALUES (pWomatlid,_invhistid); -- Decrease the parent W/O's WIP value by the value of the returned components UPDATE wo SET wo_wipvalue = (wo_wipvalue - (CASE WHEN(itemsite_costmethod IN ('A','J')) THEN _cost WHEN(itemsite_costmethod='S') THEN stdcost(itemsite_item_id) * _invqty ELSE 0.0 END )), wo_postedvalue = (wo_postedvalue - (CASE WHEN(itemsite_costmethod IN ('A','J')) THEN _cost WHEN(itemsite_costmethod='S') THEN stdcost(itemsite_item_id) * _invqty ELSE 0.0 END )) FROM womatl, itemsite WHERE ( (wo_id=womatl_wo_id) AND (womatl_itemsite_id=itemsite_id) AND (womatl_id=pWomatlid) ); UPDATE womatl SET womatl_qtyiss = (womatl_qtyiss - _womatlqty), womatl_lastreturn = CURRENT_DATE WHERE (womatl_id=pWomatlid); RETURN _itemlocSeries; END; $_$; \DROP FUNCTION public.returnwomaterial(integer, integer, timestamp with time zone, integer); publicadminfalse84623Z&00NFUNCTION returnwomaterial(integer, integer, timestamp with time zone, integer)COMMENTCOMMENT ON FUNCTION returnwomaterial(integer, integer, timestamp with time zone, integer) IS 'Returns material by reversing a specific historical transaction'; publicadminfalse2007125579303Nreturnwomaterial(integer, numeric, integer, timestamp with time zone, boolean)FUNCTION CREATE FUNCTION returnwomaterial(integer, numeric, integer, timestamp with time zone, boolean DEFAULT false) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pQty ALIAS FOR $2; pItemlocSeries ALIAS FOR $3; pGlDistTS ALIAS FOR $4; pReqStdCost ALIAS FOR $5; _woNumber TEXT; _invhistid INTEGER; _itemlocSeries INTEGER; _qty NUMERIC; _cost NUMERIC := 0; BEGIN _itemlocSeries := 0; IF ( SELECT ( CASE WHEN (womatl_qtyreq >= 0) THEN womatl_qtyiss < pQty ELSE womatl_qtyiss > pQty END ) FROM womatl WHERE ( womatl_id=pWomatlid ) ) THEN RETURN pItemlocSeries; END IF; SELECT itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, pQty) INTO _qty FROM womatl, itemsite WHERE((womatl_itemsite_id=itemsite_id) AND (womatl_id=pWomatlid)); IF (NOT FOUND) THEN _qty := pQty; END IF; SELECT formatWoNumber(womatl_wo_id) INTO _woNumber FROM womatl WHERE (womatl_id=pWomatlid); IF (pItemlocSeries = 0) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; ELSE _itemlocSeries = pItemlocSeries; END IF; -- Get the cost average IF (pReqStdCost) THEN SELECT stdcost(itemsite_item_id) * _qty INTO _cost FROM womatl, itemsite WHERE((womatl_itemsite_id=itemsite_id) AND (womatl_id=pWomatlid)); ELSE SELECT SUM(invhist_value_before - invhist_value_after) / SUM(invhist_qoh_before - invhist_qoh_after) * _qty INTO _cost FROM invhist, womatlpost, womatl WHERE((womatlpost_womatl_id=womatl_id) AND (womatlpost_invhist_id=invhist_id) AND (invhist_qoh_before > invhist_qoh_after) AND (womatl_id=pWomatlId)); END IF; _cost := COALESCE(_cost, 0); -- make sure it's not a null value -- Post the transaction SELECT postInvTrans( ci.itemsite_id, 'IM', (_qty * -1), 'W/O', 'WO', _woNumber, '', ('Return ' || item_number || ' from Work Order'), getPrjAccntId(wo_prj_id, pc.costcat_wip_accnt_id), cc.costcat_asset_accnt_id, _itemlocSeries, pGlDistTS, -- Cost will be ignored by Standard Cost items sites _cost) INTO _invhistid FROM womatl, wo, itemsite AS ci, costcat AS cc, itemsite AS pi, costcat AS pc, item WHERE((womatl_itemsite_id=ci.itemsite_id) AND (ci.itemsite_costcat_id=cc.costcat_id) AND (womatl_wo_id=wo_id) AND (wo_itemsite_id=pi.itemsite_id) AND (pi.itemsite_costcat_id=pc.costcat_id) AND (ci.itemsite_item_id=item_id) AND (womatl_id=pWomatlid) ); -- Create linkage to the transaction created IF (_invhistid != -1) THEN INSERT INTO womatlpost (womatlpost_womatl_id,womatlpost_invhist_id) VALUES (pWomatlid,_invhistid); END IF; -- Decrease the parent W/O's WIP value by the value of the returned components UPDATE wo SET wo_wipvalue = (wo_wipvalue - (CASE WHEN(itemsite_costmethod IN ('A','J')) THEN _cost WHEN(itemsite_costmethod='S') THEN stdcost(itemsite_item_id) * _qty ELSE 0.0 END )), wo_postedvalue = (wo_postedvalue - (CASE WHEN(itemsite_costmethod IN ('A','J')) THEN _cost WHEN(itemsite_costmethod='S') THEN stdcost(itemsite_item_id) * _qty ELSE 0.0 END )) FROM womatl, itemsite WHERE ( (wo_id=womatl_wo_id) AND (womatl_itemsite_id=itemsite_id) AND (womatl_id=pWomatlid) ); UPDATE womatl SET womatl_qtyiss = (womatl_qtyiss - pQty), womatl_lastreturn = CURRENT_DATE WHERE (womatl_id=pWomatlid); RETURN _itemlocSeries; END; $_$; eDROP FUNCTION public.returnwomaterial(integer, numeric, integer, timestamp with time zone, boolean); publicadminfalse84623125579304returnwomaterialbatch(integer)FUNCTIONCREATE FUNCTION returnwomaterialbatch(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoid ALIAS FOR $1; _itemlocSeries INTEGER; _woid INTEGER; _r RECORD; BEGIN SELECT wo_id INTO _woid FROM wo WHERE ( (wo_status IN ('E','I')) AND (wo_id=pWoid) ); IF (FOUND) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; FOR _r IN SELECT womatl_id, CASE WHEN wo_qtyord >= 0 THEN womatl_qtyiss ELSE ((womatl_qtyreq - womatl_qtyiss) * -1) END AS qty FROM wo, womatl, itemsite WHERE ((wo_id=womatl_wo_id) AND (womatl_itemsite_id=itemsite_id) AND ( (wo_qtyord < 0) OR (womatl_issuemethod IN ('S','M')) ) AND (womatl_wo_id=pWoid)) LOOP IF (_r.qty != 0) THEN PERFORM returnWoMaterial(_r.womatl_id, _r.qty, _itemlocSeries, now()); END IF; END LOOP; -- Reset the W/O Status to E UPDATE wo SET wo_status='E' WHERE (wo_id=pWoid); RETURN _itemlocSeries; ELSE RETURN -1; END IF; END; $_$; 5DROP FUNCTION public.returnwomaterialbatch(integer); publicadminfalse84623125579305$reversecashreceipt(integer, integer)FUNCTIONv2CREATE FUNCTION reversecashreceipt(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCashrcptid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; _p RECORD; _r RECORD; _postToAR NUMERIC; _postToMisc NUMERIC; _posted_base NUMERIC := 0; _posted NUMERIC := 0; _sequence INTEGER; _aropenid INTEGER; _arMemoNumber TEXT; _arAccntid INTEGER; _closed BOOLEAN; _debitAccntid INTEGER; _exchGain NUMERIC; _comment TEXT; _ccpayid INTEGER; _cctype TEXT; BEGIN _posted := 0; _posted_base := 0; SELECT fetchGLSequence() INTO _sequence; SELECT accnt_id INTO _arAccntid FROM cashrcpt, accnt, salescat WHERE ((cashrcpt_salescat_id=salescat_id) AND (salescat_ar_accnt_id=accnt_id) AND (cashrcpt_id=pCashrcptid)); IF (NOT FOUND) THEN SELECT accnt_id INTO _arAccntid FROM cashrcpt, accnt WHERE ( (findARAccount(cashrcpt_cust_id)=accnt_id) AND (cashrcpt_id=pCashrcptid) ); IF (NOT FOUND) THEN RETURN -5; END IF; END IF; SELECT cashrcpt_cust_id, ('Reverse Cash Receipt posting for ' || cust_number||'-'||cust_name) AS custnote, cashrcpt_fundstype, cashrcpt_number, cashrcpt_docnumber, cashrcpt_distdate, cashrcpt_amount, cashrcpt_discount, (cashrcpt_amount / cashrcpt_curr_rate) AS cashrcpt_amount_base, (cashrcpt_discount / cashrcpt_curr_rate) AS cashrcpt_discount_base, cashrcpt_notes, cashrcpt_bankaccnt_id AS bankaccnt_id, accnt_id AS prepaid_accnt_id, cashrcpt_usecustdeposit, cashrcpt_curr_id, cashrcpt_curr_rate INTO _p FROM accnt, cashrcpt LEFT OUTER JOIN custinfo ON (cashrcpt_cust_id=cust_id) WHERE ( (findPrepaidAccount(cashrcpt_cust_id)=accnt_id) AND (cashrcpt_id=pCashrcptid) ); IF (NOT FOUND) THEN RETURN -7; END IF; IF (_p.cashrcpt_fundstype IN ('A', 'D', 'M', 'V')) THEN SELECT ccpay_id, ccpay_type INTO _ccpayid, _cctype FROM ccpay WHERE ((ccpay_r_ordernum IN (CAST(pCashrcptid AS TEXT), _p.cashrcpt_docnumber)) AND (ccpay_status IN ('C', 'A'))); IF NOT FOUND THEN -- the following select seems to work except for xikar - bug 8848. why? -- raise warning so there is some visibility if people fall into this path. SELECT ccpay_id, ccpay_type INTO _ccpayid, _cctype FROM ccpay WHERE ((ccpay_order_number IN (CAST(pCashrcptid AS TEXT), _p.cashrcpt_docnumber)) AND (ccpay_status IN ('C', 'A'))); IF (NOT FOUND) THEN RETURN -8; ELSE RAISE WARNING 'PostCashReceipt() found ccpay_id % for order number %/% (ref 8848).', _ccpayid, pCashrcptid, _p.cashrcpt_docnumber; END IF; END IF; -- If there is a ccpay entry and the card was charged directly, use the prepaid account IF (_cctype = 'C' ) THEN _debitAccntid := findPrepaidAccount(_p.cashrcpt_cust_id); -- If there is a ccpay entry and the card was preauthed and then charged, use the Bank account ELSE SELECT accnt_id INTO _debitAccntid FROM cashrcpt, bankaccnt, accnt WHERE ( (cashrcpt_bankaccnt_id=bankaccnt_id) AND (bankaccnt_accnt_id=accnt_id) AND (cashrcpt_id=pCashrcptid) ); IF (NOT FOUND) THEN RETURN -6; END IF; END IF; ELSE SELECT accnt_id INTO _debitAccntid FROM cashrcpt, bankaccnt, accnt WHERE ( (cashrcpt_bankaccnt_id=bankaccnt_id) AND (bankaccnt_accnt_id=accnt_id) AND (cashrcpt_id=pCashrcptid) ); IF (NOT FOUND) THEN RETURN -6; END IF; END IF; -- Determine the amount to post to A/R Open Items SELECT COALESCE(SUM(cashrcptitem_amount),0) INTO _postToAR FROM cashrcptitem JOIN aropen ON (aropen_id=cashrcptitem_aropen_id) WHERE ((cashrcptitem_cashrcpt_id=pCashrcptid) AND (cashrcptitem_applied)); IF (NOT FOUND) THEN _postToAR := 0; END IF; -- Determine the amount to post to Misc. Distributions SELECT COALESCE(SUM(cashrcptmisc_amount),0) INTO _postToMisc FROM cashrcptmisc WHERE (cashrcptmisc_cashrcpt_id=pCashrcptid); IF (NOT FOUND) THEN _postToMisc := 0; END IF; -- Check to see if the C/R is over applied IF ((_postToAR + _postToMisc) > _p.cashrcpt_amount) THEN RETURN -1; END IF; -- Check to see if the C/R is positive amount IF (_p.cashrcpt_amount <= 0) THEN RETURN -2; END IF; -- Distribute A/R Applications FOR _r IN SELECT aropen_id, aropen_doctype, aropen_docnumber, aropen_docdate, aropen_duedate, aropen_curr_id, aropen_curr_rate, round(aropen_amount - aropen_paid, 2) <= round(aropen_paid + currToCurr(_p.cashrcpt_curr_id, aropen_curr_id,abs(cashrcptitem_amount + cashrcptitem_discount),_p.cashrcpt_distdate),2) AS closed, cashrcptitem_id, cashrcptitem_amount, cashrcptitem_discount, (cashrcptitem_amount / _p.cashrcpt_curr_rate) AS cashrcptitem_amount_base, (cashrcptitem_discount / _p.cashrcpt_curr_rate) AS cashrcptitem_discount_base, round(aropen_paid - currToCurr(_p.cashrcpt_curr_id, aropen_curr_id,abs(cashrcptitem_amount),_p.cashrcpt_distdate),2) AS new_paid, round(currToCurr(_p.cashrcpt_curr_id, aropen_curr_id,abs(cashrcptitem_discount),_p.cashrcpt_distdate),2) AS new_discount FROM cashrcptitem JOIN aropen ON (cashrcptitem_aropen_id=aropen_id) WHERE ((cashrcptitem_cashrcpt_id=pCashrcptid) AND (cashrcptitem_applied)) LOOP -- Handle discount IF (_r.cashrcptitem_discount_base > 0) THEN PERFORM reverseCashReceiptDisc(_r.cashrcptitem_id, pJournalNumber); END IF; -- Update the aropen item to post the paid amount UPDATE aropen SET aropen_paid = _r.new_paid - _r.new_discount, aropen_open = TRUE, aropen_closedate = NULL WHERE (aropen_id=_r.aropen_id); -- Cache the running amount posted _posted_base := _posted_base + _r.cashrcptitem_amount_base; _posted := _posted + _r.cashrcptitem_amount; -- Record the cashrcpt application IF (_r.aropen_doctype IN ('I','D')) THEN INSERT INTO arapply ( arapply_cust_id, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_reftype, arapply_ref_id, arapply_applied, arapply_closed, arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_username, arapply_curr_id ) VALUES ( _p.cashrcpt_cust_id, -1, 'K', _p.cashrcpt_number, _r.aropen_id, _r.aropen_doctype, _r.aropen_docnumber, _p.cashrcpt_fundstype, _p.cashrcpt_docnumber, 'CRA', _r.cashrcptitem_id, (round(_r.cashrcptitem_amount, 2) * -1.0), _r.closed, CURRENT_DATE, _p.cashrcpt_distdate, pJournalNumber, getEffectiveXtUser(), _p.cashrcpt_curr_id ); ELSE INSERT INTO arapply ( arapply_cust_id, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_reftype, arapply_ref_id, arapply_applied, arapply_closed, arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_username, arapply_curr_id ) VALUES ( _p.cashrcpt_cust_id, _r.aropen_id, _r.aropen_doctype, _r.aropen_docnumber, -1, 'R', _p.cashrcpt_number, '', '', 'CRA', _r.cashrcptitem_id, (round(abs(_r.cashrcptitem_amount), 2) * -1.0), _r.closed, CURRENT_DATE, _p.cashrcpt_distdate, pJournalNumber, getEffectiveXtUser(), _p.cashrcpt_curr_id ); END IF; _exchGain := arCurrGain(_r.aropen_id,_p.cashrcpt_curr_id, abs(_r.cashrcptitem_amount), _p.cashrcpt_distdate); PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', (_r.aropen_doctype || '-' || _r.aropen_docnumber), CASE WHEN _r.aropen_doctype != 'R' THEN _arAccntid ELSE findDeferredAccount(_p.cashrcpt_cust_id) END, (round(_r.cashrcptitem_amount_base + _exchGain, 2) * -1.0), _p.cashrcpt_distdate, _p.custnote ); IF (_exchGain <> 0) THEN PERFORM insertIntoGLSeries(_sequence, 'A/R', 'CR', _r.aropen_doctype || '-' || _r.aropen_docnumber, getGainLossAccntId( CASE WHEN _r.aropen_doctype != 'R' THEN _arAccntid ELSE findDeferredAccount(_p.cashrcpt_cust_id) END ), round(_exchGain, 2), _p.cashrcpt_distdate, _p.custnote); END IF; END LOOP; -- Distribute Misc. Applications FOR _r IN SELECT cashrcptmisc_id, cashrcptmisc_accnt_id, cashrcptmisc_amount, (cashrcptmisc_amount / _p.cashrcpt_curr_rate) AS cashrcptmisc_amount_base, cashrcptmisc_notes FROM cashrcptmisc WHERE (cashrcptmisc_cashrcpt_id=pCashrcptid) LOOP -- Cache the running amount posted _posted_base := (_posted_base + _r.cashrcptmisc_amount_base); _posted := (_posted + _r.cashrcptmisc_amount); -- Record the cashrcpt application INSERT INTO arapply ( arapply_cust_id, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_applied, arapply_closed, arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_username, arapply_curr_id, arapply_reftype, arapply_ref_id ) VALUES ( _p.cashrcpt_cust_id, -1, 'K', '', -1, 'Misc.', '', _p.cashrcpt_fundstype, _p.cashrcpt_docnumber, (round(_r.cashrcptmisc_amount, 2) * -1.0), TRUE, CURRENT_DATE, _p.cashrcpt_distdate, pJournalNumber, getEffectiveXtUser(), _p.cashrcpt_curr_id, 'CRD', _r.cashrcptmisc_id ); PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', _r.cashrcptmisc_notes, _r.cashrcptmisc_accnt_id, (round(_r.cashrcptmisc_amount_base, 2) * -1.0), _p.cashrcpt_distdate, _p.custnote ); END LOOP; -- Post any remaining Cash to an A/R Debit Memo -- this credit memo may absorb an occasional currency exchange rounding error IF (round(_posted_base, 2) < round(_p.cashrcpt_amount_base, 2)) THEN _comment := ('Unapplied from ' || _p.cashrcpt_fundstype || '-' || _p.cashrcpt_docnumber); PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', _comment, _p.prepaid_accnt_id, ((round(_p.cashrcpt_amount_base, 2) - round(_posted_base, 2)) * -1.0), _p.cashrcpt_distdate, _p.custnote ); SELECT fetchArMemoNumber() INTO _arMemoNumber; -- Post A/R Debit Memo SELECT createARDebitMemo(NULL, _p.cashrcpt_cust_id, pJournalNumber, _arMemoNumber, '', _p.cashrcpt_distdate, (_p.cashrcpt_amount - _posted), _comment, -1, -1, -1, _p.cashrcpt_distdate, -1, NULL, 0, _p.cashrcpt_curr_id) INTO _aropenid; -- Create Cash Receipt Item to capture posting INSERT INTO cashrcptitem ( cashrcptitem_cashrcpt_id, cashrcptitem_aropen_id, cashrcptitem_amount ) VALUES ( pCashrcptid, _aropenid, ((_p.cashrcpt_amount - _posted) * 1.0) ); ELSIF (round(_posted_base, 2) > round(_p.cashrcpt_amount_base, 2)) THEN PERFORM insertIntoGLSeries(_sequence, 'A/R', 'CR', 'Currency Exchange Rounding - ' || _p.cashrcpt_docnumber, getGainLossAccntId(_debitAccntid), ((round(_posted_base, 2) - round((_p.cashrcpt_amount_base + _p.cashrcpt_discount_base), 2)) * 1.0), _p.cashrcpt_distdate, _p.custnote); END IF; -- Debit Cash PERFORM insertIntoGLSeries( _sequence, 'A/R', 'CR', (_p.cashrcpt_fundstype || '-' || _p.cashrcpt_docnumber), _debitAccntid, round(_p.cashrcpt_amount_base, 2), _p.cashrcpt_distdate, _p.custnote ); PERFORM postGLSeries(_sequence, pJournalNumber); -- Update and void the posted cashrcpt UPDATE cashrcpt SET cashrcpt_posted=FALSE, cashrcpt_posteddate=NULL, cashrcpt_postedby=NULL, cashrcpt_void=TRUE WHERE (cashrcpt_id=pCashrcptid); RETURN 1; END; $_$; ;DROP FUNCTION public.reversecashreceipt(integer, integer); publicadminfalse84623125579307(reversecashreceiptdisc(integer, integer)FUNCTIONCREATE FUNCTION reversecashreceiptdisc(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCashrcptItemId ALIAS FOR $1; pJournalNumber ALIAS FOR $2; _r RECORD; _t RECORD; _v RECORD; _ardiscountid INTEGER; _arMemoNumber TEXT; _arAccntid INTEGER; _discountAccntid INTEGER; _comment TEXT; _discprcnt NUMERIC; _check INTEGER; BEGIN -- Fetch base records for processing SELECT aropen_id, aropen_doctype, aropen_amount, cashrcptitem_discount, cashrcpt_cust_id, cashrcpt_distdate, cashrcpt_applydate, cashrcpt_curr_id, cashrcpt_fundstype, cashrcpt_docnumber, round(currToCurr(cashrcpt_curr_id, aropen_curr_id, cashrcptitem_discount, cashrcpt_distdate),2) AS aropen_discount INTO _r FROM cashrcptitem JOIN cashrcpt ON (cashrcptitem_cashrcpt_id=cashrcpt_id) JOIN aropen ON ( (aropen_id=cashrcptitem_aropen_id) AND (aropen_doctype IN ('I', 'D')) ) WHERE (cashrcptitem_id=pCashrcptItemId); -- Get discount account _discountAccntid := findardiscountaccount(_r.cashrcpt_cust_id); IF (_r.cashrcptitem_discount > 0) THEN -- Determine discount percentage _discprcnt := _r.aropen_discount / _r.aropen_amount; SELECT fetchArMemoNumber() INTO _arMemoNumber; _comment := 'Discount Credit Reversal from ' || _r.cashrcpt_fundstype || '-' || _r.cashrcpt_docnumber; -- Create misc debit memo record _ardiscountid := nextval('aropen_aropen_id_seq'); INSERT INTO aropen ( aropen_id, aropen_docdate, aropen_duedate, aropen_doctype, aropen_docnumber, aropen_curr_id, aropen_posted, aropen_amount ) VALUES ( _ardiscountid, _r.cashrcpt_distdate, _r.cashrcpt_distdate, 'D', _arMemoNumber, _r.cashrcpt_curr_id, false,_r.cashrcptitem_discount); IF (fetchMetricBool('CreditTaxDiscount')) THEN -- proportional tax credits calculated and implemented for the debit memo generated by the discount IF (_r.aropen_doctype = 'I') THEN -- Tax for invoices SELECT aropen_cobmisc_id AS invcheadid, invchead_curr_id, invchead_invcdate INTO _t FROM aropen LEFT OUTER JOIN invchead ON (aropen_cobmisc_id = invchead_id) LEFT OUTER JOIN invcitem ON (invchead_id = invcitem_invchead_id) WHERE aropen_id = _r.aropen_id; FOR _v IN SELECT tax_sales_accnt_id, tax_id, round(sum(taxdetail_tax), 2) AS tax, currToBase(_t.invchead_curr_id, round(sum(taxdetail_tax), 2), _t.invchead_invcdate) AS taxbasevalue FROM tax JOIN calculateTaxDetailSummary('I', _t.invcheadid, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id, tax_sales_accnt_id LOOP INSERT INTO aropentax( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_basis) VALUES ( _ardiscountid, getadjustmenttaxtypeid(), _v.tax_id, 0.00, 0.00, (round((_v.tax * _discprcnt), 2)), _r.cashrcpt_distdate, 0.00); END LOOP; ELSIF (_r.aropen_doctype = 'D') THEN -- Tax for debit memos INSERT INTO aropentax( taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_basis) SELECT _ardiscountid, taxhist_taxtype_id, taxhist_tax_id, 0.00, 0.00, (round((taxhist_tax * _discprcnt), 2)), _r.cashrcpt_distdate, 0.00 FROM aropentax WHERE (taxhist_parent_id=_r.aropen_id); END IF; END IF; -- End taxes -- Create negative credit memo for discount SELECT createARCreditMemo(_ardiscountid, _r.cashrcpt_cust_id, _arMemoNumber, '', _r.cashrcpt_distdate, (_r.cashrcptitem_discount * -1.0), _comment, -1, -1, _discountAccntid, _r.cashrcpt_distdate, -1, NULL, 0, pJournalNumber, _r.cashrcpt_curr_id) INTO _ardiscountid; -- Apply discount negative credit memo INSERT INTO arcreditapply ( arcreditapply_source_aropen_id, arcreditapply_target_aropen_id, arcreditapply_amount, arcreditapply_curr_id ) VALUES ( _ardiscountid, _r.aropen_id, (_r.cashrcptitem_discount * -1.0), _r.cashrcpt_curr_id ); SELECT postARCreditMemoApplication(_ardiscountid, _r.cashrcpt_applydate) INTO _check; IF (_check < 0) THEN RAISE EXCEPTION 'Error posting discount credit memo application. Code %', _check; END IF; END IF; -- End handle Discount RETURN 1; END; $_$; ?DROP FUNCTION public.reversecashreceiptdisc(integer, integer); publicadminfalse84623125579308$reverseglseries(integer, date, text)FUNCTIONp CREATE FUNCTION reverseglseries(integer, date, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSequence ALIAS FOR $1; pDistDate ALIAS FOR $2; pNotes ALIAS FOR $3; _sequence INTEGER := fetchGLSequence(); _journal INTEGER; BEGIN IF (SELECT COUNT(gltrans_sequence) > 0 FROM gltrans WHERE gltrans_sequence = pSequence) THEN SELECT fetchJournalNumber(jrnluse_use) INTO _journal FROM gltrans JOIN jrnluse ON (gltrans_journalnumber=jrnluse_number) WHERE (gltrans_sequence=pSequence) LIMIT 1; INSERT INTO gltrans (gltrans_created, gltrans_posted, gltrans_exported, gltrans_date, gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_docnumber, gltrans_misc_id, gltrans_amount, gltrans_notes, gltrans_journalnumber, gltrans_doctype) SELECT CURRENT_TIMESTAMP, FALSE, FALSE, pDistDate, _sequence, gltrans_accnt_id, gltrans_source, gltrans_docnumber, gltrans_misc_id, (gltrans_amount * -1), pNotes, _journal, gltrans_doctype FROM gltrans WHERE (gltrans_sequence=pSequence); PERFORM postIntoTrialBalance(_sequence); ELSE SELECT fetchJournalNumber(jrnluse_use) INTO _journal FROM sltrans JOIN jrnluse ON (sltrans_journalnumber=jrnluse_number) WHERE (sltrans_sequence=pSequence) LIMIT 1; INSERT INTO sltrans (sltrans_created, sltrans_posted, sltrans_date, sltrans_sequence, sltrans_accnt_id, sltrans_source, sltrans_docnumber, sltrans_misc_id, sltrans_amount, sltrans_notes, sltrans_journalnumber, sltrans_doctype) SELECT CURRENT_TIMESTAMP, FALSE, pDistDate, _sequence, sltrans_accnt_id, sltrans_source, sltrans_docnumber, sltrans_misc_id, (sltrans_amount * -1), pNotes, _journal, sltrans_doctype FROM sltrans WHERE (sltrans_sequence=pSequence); END IF; RETURN _journal; END; $_$; ;DROP FUNCTION public.reverseglseries(integer, date, text); publicadminfalse84623125579309,revokeallmodulecmnttypesource(integer, text)FUNCTIONCREATE FUNCTION revokeallmodulecmnttypesource(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmnttypeid ALIAS FOR $1; pModuleName ALIAS FOR $2; BEGIN DELETE FROM cmnttypesource WHERE (cmnttypesource_id IN ( SELECT cmnttypesource_id FROM cmnttypesource, source WHERE ( (cmnttypesource_source_id=source_id) AND (cmnttypesource_cmnttype_id=pCmnttypeid) AND (source_module=pModuleName) ) ) ); RETURN 1; END; $_$; CDROP FUNCTION public.revokeallmodulecmnttypesource(integer, text); publicadminfalse84623125579310revokeallmodulepriv(text, text)FUNCTION|CREATE FUNCTION revokeallmodulepriv(text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pModuleName ALIAS FOR $2; BEGIN DELETE FROM usrpriv WHERE (usrpriv_id IN ( SELECT usrpriv_id FROM usrpriv, priv WHERE ( (usrpriv_priv_id=priv_id) AND (usrpriv_username=pUsername) AND (priv_module=pModuleName) ) ) ); NOTIFY "usrprivUpdated"; RETURN 1; END; $_$; 6DROP FUNCTION public.revokeallmodulepriv(text, text); publicadminfalse84623125579311'revokeallmoduleprivgroup(integer, text)FUNCTION`CREATE FUNCTION revokeallmoduleprivgroup(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pGrpid ALIAS FOR $1; pModuleName ALIAS FOR $2; BEGIN DELETE FROM grppriv WHERE (grppriv_id IN ( SELECT grppriv_id FROM grppriv, priv WHERE ( (grppriv_priv_id=priv_id) AND (grppriv_grp_id=pGrpid) AND (priv_module=pModuleName) ) ) ); RETURN 1; END; $_$; >DROP FUNCTION public.revokeallmoduleprivgroup(integer, text); publicadminfalse46238125579312&revokecmnttypesource(integer, integer)FUNCTIONCREATE FUNCTION revokecmnttypesource(integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmnttypeid ALIAS FOR $1; pSourceid ALIAS FOR $2; BEGIN DELETE FROM cmnttypesource WHERE ( (cmnttypesource_cmnttype_id=pCmnttypeid) AND (cmnttypesource_source_id=pSourceid) ); RETURN TRUE; END; $_$; =DROP FUNCTION public.revokecmnttypesource(integer, integer); publicadminfalse84623125579313revokegroup(text, integer)FUNCTIONCREATE FUNCTION revokegroup(text, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pGrpid ALIAS FOR $2; BEGIN DELETE FROM usrgrp WHERE ( (usrgrp_username=pUsername) AND (usrgrp_grp_id=pGrpid) ); RETURN TRUE; END; $_$; 1DROP FUNCTION public.revokegroup(text, integer); publicadminfalse84623125579314revokepriv(text, integer)FUNCTIONCREATE FUNCTION revokepriv(text, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pPrivid ALIAS FOR $2; BEGIN DELETE FROM usrpriv WHERE ( (usrpriv_username=pUsername) AND (usrpriv_priv_id=pPrivid) ); NOTIFY "usrprivUpdated"; RETURN TRUE; END; $_$; 0DROP FUNCTION public.revokepriv(text, integer); publicadminfalse46238125579315revokepriv(text, text)FUNCTIONCREATE FUNCTION revokepriv(text, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pPrivname ALIAS FOR $2; BEGIN DELETE FROM usrpriv WHERE ( (usrpriv_username=pUsername) AND (usrpriv_priv_id IN (SELECT priv_id FROM priv WHERE priv_name=pPrivname) )); NOTIFY "usrprivUpdated"; RETURN TRUE; END; $_$; -DROP FUNCTION public.revokepriv(text, text); publicadminfalse84623125579316!revokeprivgroup(integer, integer)FUNCTIONCREATE FUNCTION revokeprivgroup(integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pGrpid ALIAS FOR $1; pPrivid ALIAS FOR $2; BEGIN DELETE FROM grppriv WHERE ( (grppriv_grp_id=pGrpid) AND (grppriv_priv_id=pPrivid) ); NOTIFY "usrprivUpdated"; RETURN TRUE; END; $_$; 8DROP FUNCTION public.revokeprivgroup(integer, integer); publicadminfalse84623125579317rollupactualcost(integer)FUNCTION7CREATE FUNCTION rollupactualcost(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; BEGIN RETURN rollUpSorACost(pitemid, TRUE); END; $_$; 0DROP FUNCTION public.rollupactualcost(integer); publicadminfalse84623125579318 rollupsoracost(integer, boolean)FUNCTIONCREATE FUNCTION rollupsoracost(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pActual ALIAS FOR $2; _counter INTEGER; _setid INTEGER; _consumers RECORD; BEGIN _counter := 0; SELECT indentedWhereUsed(pItemid) INTO _setid; FOR _consumers IN SELECT bomwork_item_id FROM bomwork WHERE (bomwork_set_id=_setid) ORDER BY bomwork_level LOOP PERFORM updateSorACost( _consumers.bomwork_item_id, costelem_type, TRUE, lowerCost(_consumers.bomwork_item_id, costelem_type, pActual), pActual ) FROM costelem WHERE (costelem_sys); PERFORM updateLowerUserCosts(_consumers.bomwork_item_id, pActual); _counter := _counter + 1; END LOOP; PERFORM deleteBOMWorkset(_setid); RETURN _counter; END; $_$; 7DROP FUNCTION public.rollupsoracost(integer, boolean); publicadminfalse84623125579319rollupstandardcost(integer)FUNCTION:CREATE FUNCTION rollupstandardcost(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; BEGIN RETURN rollUpSorACost(pItemid, FALSE); END; $_$; 2DROP FUNCTION public.rollupstandardcost(integer); publicadminfalse46238125579320roundcost(numeric)FUNCTIONCREATE FUNCTION roundcost(pcost numeric) RETURNS numeric LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _scale INTEGER; BEGIN IF (pCost IS NULL) THEN RETURN NULL; END IF; SELECT locale_cost_scale INTO _scale FROM locale WHERE (locale_id=getUsrLocaleId()); RETURN ROUND(pCost, _scale); END; $$; /DROP FUNCTION public.roundcost(pcost numeric); publicadminfalse84623125579321#roundlocale(boolean, numeric, text)FUNCTIONCREATE FUNCTION roundlocale(pfractional boolean, pqty numeric, plocale text) RETURNS numeric LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; _scale INTEGER; BEGIN IF (pFractional) THEN SELECT * INTO _r FROM locale WHERE (locale_id=getUsrLocaleId()); _scale := CASE pLocale WHEN 'qtyper' THEN _r.locale_qtyper_scale WHEN 'cost' THEN _r.locale_cost_scale ELSE _r.locale_qty_scale END; RETURN ROUND(pQty, _scale); ELSE IF (TRUNC(pQty) < pQty) THEN RETURN (TRUNC(pQty) + 1); ELSE RETURN TRUNC(pQty); END IF; END IF; END; $$; SDROP FUNCTION public.roundlocale(pfractional boolean, pqty numeric, plocale text); publicadminfalse46238125579322roundqty(boolean, numeric)FUNCTIONBCREATE FUNCTION roundqty(pfractional boolean, pqty numeric) RETURNS numeric LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _scale INTEGER; BEGIN SELECT locale_qty_scale INTO _scale FROM locale WHERE (locale_id=getUsrLocaleId()); IF (pFractional) THEN RETURN ROUND(pQty, _scale); ELSE IF (TRUNC(pQty) < ROUND(pQty, _scale)) THEN RETURN (TRUNC(pQty) + 1); ELSE RETURN TRUNC(pQty); END IF; END IF; END; $$; BDROP FUNCTION public.roundqty(pfractional boolean, pqty numeric); publicadminfalse46238125579323roundsale(numeric)FUNCTIONCREATE FUNCTION roundsale(psale numeric) RETURNS numeric LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _scale INTEGER; BEGIN IF (pSale IS NULL) THEN RETURN NULL; END IF; SELECT locale_salesprice_scale INTO _scale FROM locale WHERE (locale_id=getUsrLocaleId()); RETURN ROUND(pSale, _scale); END; $$; /DROP FUNCTION public.roundsale(psale numeric); publicadminfalse46238125579324roundup(numeric)FUNCTIONCREATE FUNCTION roundup(numeric) RETURNS numeric LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pValue ALIAS FOR $1; _checkValue integer; BEGIN _checkValue := pValue::integer; IF (_checkValue::numeric < pValue) THEN RETURN (_checkValue + 1)::numeric; ELSE RETURN _checkValue::numeric; END IF; END; $_$; 'DROP FUNCTION public.roundup(numeric); publicadminfalse84623125579325Gsaveaddr(integer, text, text, text, text, text, text, text, text, text)FUNCTIONCREATE FUNCTION saveaddr(integer, text, text, text, text, text, text, text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAddrId ALIAS FOR $1; pNumber ALIAS FOR $2; pAddr1 ALIAS FOR $3; pAddr2 ALIAS FOR $4; pAddr3 ALIAS FOR $5; pCity ALIAS FOR $6; pState ALIAS FOR $7; pPostalCode ALIAS FOR $8; pCountry ALIAS FOR $9; pFlag ALIAS FOR $10; _returnVal INTEGER; BEGIN SELECT saveAddr(pAddrId,pNumber, pAddr1,pAddr2,pAddr3,pCity,pState,pPostalCode,pCountry,true,'',pFlag) INTO _returnVal; RETURN _returnVal; END; $_$; ^DROP FUNCTION public.saveaddr(integer, text, text, text, text, text, text, text, text, text); publicadminfalse46238125579326Vsaveaddr(integer, text, text, text, text, text, text, text, text, boolean, text, text)FUNCTIONCREATE FUNCTION saveaddr(integer, text, text, text, text, text, text, text, text, boolean, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAddrId ALIAS FOR $1; pNumber ALIAS FOR $2; pAddr1 ALIAS FOR $3; pAddr2 ALIAS FOR $4; pAddr3 ALIAS FOR $5; pCity ALIAS FOR $6; pState ALIAS FOR $7; pPostalCode ALIAS FOR $8; pCountry ALIAS FOR $9; pActive ALIAS FOR $10; pNotes ALIAS FOR $11; pFlag ALIAS FOR $12; _addrId INTEGER; _addrNumber INTEGER; _flag TEXT; _p RECORD; _cnt INTEGER; _notes TEXT; BEGIN --Validate IF ((pFlag IS NULL) OR (pFlag = '') OR (pFlag = 'CHECK') OR (pFlag = 'CHANGEONE') OR (pFlag = 'CHANGEALL')) THEN IF (pFlag='') THEN _flag := 'CHECK'; ELSE _flag := COALESCE(pFlag,'CHECK'); END IF; ELSE RAISE EXCEPTION 'Invalid Flag (%). Valid flags are CHECK, CHANGEONE or CHANGEALL', pFlag; END IF; _notes := COALESCE(pNotes,''); --If there is nothing here, get out IF ( (pNumber = '' OR pNumber IS NULL) AND (pAddr1 = '' OR pAddr1 IS NULL) AND (pAddr2 = '' OR pAddr2 IS NULL) AND (pAddr3 = '' OR pAddr3 IS NULL) AND (pCity = '' OR pCity IS NULL) AND (pState = '' OR pState IS NULL) AND (pPostalCode = '' OR pPostalCode IS NULL) AND (pCountry = '' OR pCountry IS NULL) ) THEN RETURN NULL; END IF; _addrId := COALESCE(pAddrId,-1); --If we have an ID see if anything has changed, if not get out IF (_addrId >= 0) THEN SELECT * FROM addr INTO _p WHERE ((pAddrId=addr_id) AND (COALESCE(pNumber,addr_number)=addr_number) AND (COALESCE(pAddr1, '')=COALESCE(addr_line1, '')) AND (COALESCE(pAddr2, '')=COALESCE(addr_line2, '')) AND (COALESCE(pAddr3, '')=COALESCE(addr_line3, '')) AND (COALESCE(pCity, '')=COALESCE(addr_city, '')) AND (COALESCE(pState, '')=COALESCE(addr_state, '')) AND (COALESCE(pPostalCode, '')=COALESCE(addr_postalcode, '')) AND (COALESCE(pCountry, '')=COALESCE(addr_country, '')) AND (pActive=addr_active) AND (_notes=COALESCE(addr_notes,''))); IF (FOUND) THEN RETURN _addrId; END IF; END IF; --Check to see if duplicate address exists SELECT addr_id, addr_notes INTO _p FROM addr WHERE ((_addrId <> addr_id) AND (COALESCE(UPPER(addr_line1),'') = COALESCE(UPPER(pAddr1),'')) AND (COALESCE(UPPER(addr_line2),'') = COALESCE(UPPER(pAddr2),'')) AND (COALESCE(UPPER(addr_line3),'') = COALESCE(UPPER(pAddr3),'')) AND (COALESCE(UPPER(addr_city),'') = COALESCE(UPPER(pCity),'')) AND (COALESCE(UPPER(addr_state),'') = COALESCE(UPPER(pState),'')) AND (COALESCE(UPPER(addr_postalcode),'') = COALESCE(UPPER(pPostalcode),'')) AND (COALESCE(UPPER(addr_country),'') = COALESCE(UPPER(pCountry),''))); IF (FOUND) THEN --Note: To prevent overwriting of existing notes, the application --needs to load any existing notes for a matching address before altering them. IF (_notes <> _p.addr_notes) THEN UPDATE addr SET addr_notes=addr_notes || ' ' || _notes WHERE addr_id=_p.addr_id; END IF; RETURN _p.addr_id; --A matching address exits END IF; IF (_addrId < 0) THEN _flag := 'CHANGEONE'; END IF; IF (_flag = 'CHECK') THEN IF addrUseCount(_addrId) > 1 THEN RETURN -2; ELSIF (SELECT COUNT(addr_id)=0 FROM addr WHERE (addr_id=_addrId)) THEN _flag := 'CHANGEONE'; ELSE _flag := 'CHANGEALL'; END IF; END IF; IF (_flag = 'CHANGEALL') THEN _addrNumber := pNumber; IF (_addrNumber IS NULL) THEN SELECT addr_number INTO _addrNumber FROM addr WHERE(addr_id = _addrId); IF (_addrNumber IS NULL) THEN _addrNumber := fetchNextNumber('AddressNumber'); END IF; END IF; UPDATE addr SET addr_line1 = pAddr1, addr_line2 = pAddr2, addr_line3 = pAddr3, addr_city = pCity, addr_state = pState, addr_postalcode = pPostalcode, addr_country = pCountry, addr_active = pActive, addr_notes = pNotes WHERE addr_id = _addrId; RETURN _addrId; ELSE SELECT NEXTVAL('addr_addr_id_seq') INTO _addrId; IF (_flag = 'CHANGEONE') THEN _addrNumber := fetchNextNumber('AddressNumber'); ELSE _addrNumber := COALESCE(pNumber::text,fetchNextNumber('AddressNumber')); END IF; INSERT INTO addr ( addr_id, addr_number, addr_line1, addr_line2, addr_line3, addr_city, addr_state, addr_postalcode, addr_country, addr_active, addr_notes ) VALUES ( _addrId, _addrNumber, pAddr1, pAddr2, pAddr3, pCity, pState, pPostalcode, pCountry, pActive, _notes); RETURN _addrId; END IF; END; $_$; mDROP FUNCTION public.saveaddr(integer, text, text, text, text, text, text, text, text, boolean, text, text); publicadminfalse84623125579327savealarm(integer, text, date, time without time zone, integer, text, boolean, text, boolean, text, boolean, text, text, integer, text)FUNCTIONCREATE FUNCTION savealarm(integer, text, date, time without time zone, integer, text, boolean, text, boolean, text, boolean, text, text, integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAlarmId ALIAS FOR $1; pAlarmNumber ALIAS FOR $2; pDate ALIAS FOR $3; pTime ALIAS FOR $4; pOffset ALIAS FOR $5; pQualifier ALIAS FOR $6; pEvent ALIAS FOR $7; pEventRecipient ALIAS FOR $8; pEmail ALIAS FOR $9; pEmailRecipient ALIAS FOR $10; pSysmsg ALIAS FOR $11; pSysmsgRecipient ALIAS FOR $12; pSource ALIAS FOR $13; pSourceId ALIAS FOR $14; pFlag ALIAS FOR $15; _alarmId INTEGER; _alarmNumber TEXT; _alarmTime TIMESTAMP; _alarmInterval INTERVAL; _alarmTrigger TIMESTAMP; _isNew BOOLEAN; _flag TEXT; _alarmCount INTEGER := 0; _debug BOOLEAN := false; BEGIN IF (_debug) THEN RAISE NOTICE 'pAlarmId = %', pAlarmId; RAISE NOTICE 'pAlarmNumber = %', pAlarmNumber; RAISE NOTICE 'pDate = %', pDate; RAISE NOTICE 'pTime = %', pTime; RAISE NOTICE 'pOffset = %', pOffset; RAISE NOTICE 'pQualifier = %', pQualifier; RAISE NOTICE 'pEvent = %', pEvent; RAISE NOTICE 'pEventRecipient = %', pEventRecipient; RAISE NOTICE 'pEmail = %', pEmail; RAISE NOTICE 'pEmailRecipient = %', pEmailRecipient; RAISE NOTICE 'pSysmsg = %', pSysmsg; RAISE NOTICE 'pSysmsgRecipient = %', pSysmsgRecipient; RAISE NOTICE 'pSource = %', pSource; RAISE NOTICE 'pSourceId = %', pSourceId; RAISE NOTICE 'pFlag = %', pFlag; END IF; --Validate IF ((pFlag IS NULL) OR (pFlag = '') OR (pFlag = 'CHECK') OR (pFlag = 'CHANGEONE') OR (pFlag = 'CHANGEALL')) THEN IF (pFlag='') THEN _flag := 'CHECK'; ELSE _flag := COALESCE(pFlag,'CHECK'); END IF; ELSE RAISE EXCEPTION 'Invalid Flag (%). Valid flags are CHECK, CHANGEONE or CHANGEALL', pFlag; END IF; --If there is nothing here get out IF ( (pAlarmId IS NULL OR pAlarmId = -1) AND (pOffset IS NULL) AND (pSourceId IS NULL) AND (COALESCE(pQualifier, '') = '') AND (COALESCE(pEventRecipient, '') = '') AND (COALESCE(pEmailRecipient, '') = '') AND (COALESCE(pSysmsgRecipient, '') = '') AND (COALESCE(pSource, '') = '') ) THEN RETURN NULL; END IF; IF (pAlarmId IS NULL OR pAlarmId = -1) THEN _isNew := true; _alarmId := nextval('alarm_alarm_id_seq'); _alarmNumber := fetchNextNumber('AlarmNumber'); ELSE SELECT COUNT(alarm_id) INTO _alarmCount FROM alarm WHERE ((alarm_id=pAlarmId) AND (alarm_source=pSource) AND (alarm_source_id=pSourceId)); -- ask whether new or update if name changes -- but only if this isn't a new record with a pre-allocated id IF (_alarmCount < 1 AND _flag = 'CHECK') THEN IF (EXISTS(SELECT alarm_id FROM alarm WHERE (alarm_id=pAlarmId))) THEN RETURN -10; ELSE _isNew := true; _alarmNumber := fetchNextNumber('AlarmNumber'); END IF; ELSIF (_flag = 'CHANGEONE') THEN _isNew := true; _alarmId := nextval('alarm_alarm_id_seq'); _alarmNumber := fetchNextNumber('AlarmNumber'); END IF; END IF; _alarmNumber := COALESCE(_alarmNumber,pAlarmNumber,fetchNextNumber('AlarmNumber')); _alarmTime := COALESCE(pDate, CURRENT_DATE) + COALESCE(pTime, CURRENT_TIME); IF (COALESCE(pOffset, 0) > 0) THEN _alarmInterval := CASE WHEN (pQualifier IN ('MB', 'MA')) THEN CAST(pOffset AS TEXT) || ' minutes' WHEN (pQualifier IN ('HB', 'HA')) THEN CAST(pOffset AS TEXT) || ' hours' WHEN (pQualifier IN ('DB', 'DA')) THEN CAST(pOffset AS TEXT) || ' days' ELSE '' END; _alarmTrigger := CASE WHEN (pQualifier IN ('MB', 'HB', 'DB')) THEN _alarmTime - _alarmInterval WHEN (pQualifier IN ('MA', 'HA', 'DA')) THEN _alarmTime + _alarmInterval ELSE _alarmTime END; ELSE _alarmTrigger := _alarmTime; END IF; IF (_isNew) THEN _alarmId := COALESCE(_alarmId,pAlarmId,nextval('alarm_alarm_id_seq')); INSERT INTO alarm ( alarm_id,alarm_number, alarm_event, alarm_email, alarm_sysmsg, alarm_trigger, alarm_time, alarm_time_offset, alarm_time_qualifier, alarm_creator, alarm_event_recipient, alarm_email_recipient, alarm_sysmsg_recipient, alarm_source, alarm_source_id ) VALUES ( _alarmId, _alarmNumber, pEvent, pEmail, pSysmsg, _alarmTrigger, _alarmTime, pOffset, pQualifier, getEffectiveXtUser(), pEventRecipient, pEmailRecipient, pSysmsgRecipient, pSource, pSourceId ); RETURN _alarmId; ELSE UPDATE alarm SET alarm_number=_alarmNumber, alarm_event=COALESCE(pEvent, alarm_event), alarm_email=COALESCE(pEmail, alarm_event), alarm_sysmsg=COALESCE(pSysmsg, alarm_event), alarm_trigger=_alarmTrigger, alarm_time=_alarmTime, alarm_time_offset=COALESCE(pOffset, alarm_time_offset), alarm_time_qualifier=COALESCE(pQualifier, alarm_time_qualifier), alarm_event_recipient=COALESCE(pEventRecipient, alarm_event_recipient), alarm_email_recipient=COALESCE(pEmailRecipient, alarm_email_recipient), alarm_sysmsg_recipient=COALESCE(pSysmsgRecipient, alarm_sysmsg_recipient) WHERE (alarm_id=pAlarmId); RETURN pAlarmId; END IF; END; $_$; DROP FUNCTION public.savealarm(integer, text, date, time without time zone, integer, text, boolean, text, boolean, text, boolean, text, text, integer, text); publicadminfalse462381255793298savebomhead(integer, text, date, text, numeric, numeric)FUNCTIONCREATE FUNCTION savebomhead(integer, text, date, text, numeric, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pRevision ALIAS FOR $2; pRevisionDate ALIAS FOR $3; pDocumentNumber ALIAS FOR $4; pBatchSize ALIAS FOR $5; pRequiredQtyPer ALIAS FOR $6; _seq INTEGER; _p RECORD; _revid INTEGER; BEGIN IF (NOT fetchMetricBool('RevControl')) THEN -- Deal with BOM if Rev Control Turned off SELECT bomhead_id INTO _seq FROM bomhead WHERE (bomhead_item_id=pItemid); IF (NOT FOUND) THEN -- No bomhead exists _seq := NEXTVAL('bomhead_bomhead_id_seq'); INSERT INTO bomhead (bomhead_id,bomhead_item_id,bomhead_docnum,bomhead_revision, bomhead_revisiondate,bomhead_batchsize,bomhead_requiredqtyper,bomhead_rev_id) VALUES (_seq,pItemid, pDocumentNumber, pRevision, pRevisionDate, pBatchSize, pRequiredQtyPer,-1); ELSE UPDATE bomhead SET bomhead_revision = pRevision, bomhead_revisiondate = pRevisionDate, bomhead_docnum = pDocumentNumber, bomhead_batchsize = pBatchSize, bomhead_requiredqtyper = pRequiredQtyPer WHERE (bomhead_id=_seq); END IF; RETURN _seq; ELSE -- Deal with Revision Control IF (COALESCE(pRevision,'') = '' AND getActiveRevId('BOM',pItemid) != -1) THEN RAISE EXCEPTION 'Revision Control records exist for item. You must provide a new or existing revision number.'; END IF; SELECT * INTO _p FROM bomhead LEFT OUTER JOIN rev ON (bomhead_rev_id=rev_id), item WHERE ((bomhead_item_id=pItemid) AND (COALESCE(bomhead_revision,'')=COALESCE(pRevision,'')) AND (bomhead_item_id=item_id)); IF (NOT FOUND) THEN -- This is a new bomhead record IF LENGTH(pRevision) > 0 THEN -- We need to create a revision record SELECT createbomrev(pItemid, pRevision) INTO _revid; UPDATE bomhead SET bomhead_revisiondate = pRevisiondate, bomhead_docnum = pDocumentNumber, bomhead_batchsize = pBatchsize, bomhead_requiredqtyper = pRequiredqtyper WHERE (bomhead_rev_id=_revid); SELECT bomhead_id INTO _seq FROM bomhead WHERE (bomhead_rev_id=_revid); RETURN _seq; ELSE -- Just create a regular bom header record _seq := NEXTVAL('bomhead_bomhead_id_seq'); INSERT INTO bomhead (bomhead_id,bomhead_item_id,bomhead_docnum,bomhead_revision, bomhead_revisiondate,bomhead_batchsize,bomhead_requiredqtyper,bomhead_rev_id) VALUES (_seq,pItemid, pDocumentNumber, pRevision, pRevisionDate, pBatchSize, pRequiredQtyPer,-1); RETURN _seq; END IF; ELSE -- We need to update a record IF (_p.rev_status = 'I') THEN RAISE EXCEPTION 'Revision % for % is inactive. Update not allowed.', _p.rev_number, _p.item_number; ELSIF (COALESCE(pRevision,'') = COALESCE(_p.bomhead_revision,'')) THEN -- No change, just update UPDATE bomhead SET bomhead_revisiondate = pRevisiondate, bomhead_docnum = pDocumentNumber, bomhead_batchsize = pBatchSize, bomhead_requiredqtyper = pRequiredqtyper WHERE (bomhead_id=_p.bomhead_id); RETURN _p.bomhead_id; ELSE -- Need a new revision SELECT createbomrev(pItemid, pRevision) INTO _revid; UPDATE bomhead SET bomhead_revisiondate = pRevisiondate, bomhead_docnum = pDocumentNumber, bomhead_batchsize = pBatchSize, bomhead_requiredqtyper = pRequiredqtyper WHERE (bomhead_rev_id=_revid); SELECT bomhead_id INTO _seq FROM bomhead WHERE (bomhead_rev_id=_revid); RETURN _seq; END IF; END IF; END IF; RETURN _seq; END; $_$; ODROP FUNCTION public.savebomhead(integer, text, date, text, numeric, numeric); publicadminfalse46238125579330isavecntct(integer, text, integer, text, text, text, text, text, text, text, text, text, text, text, text)FUNCTIONCREATE FUNCTION savecntct(pcntctid integer, pcontactnumber text, paddrid integer, phonorific text, pfirstname text, pmiddlename text, plastname text, psuffix text, pphone text, pphone2 text, pfax text, pemail text, pwebaddr text, ptitle text, pflag text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN SELECT saveCntct(pCntctId,pContactNumber,NULL,pAddrId,pHonorific,pFirstName,pMiddleName,pLastName,pSuffix,NULL, NULL,pPhone,pPhone2,pFax,pEmail,pWebAddr,NULL,pTitle,pFlag, NULL) INTO _returnVal; RETURN _returnVal; END; $$; DROP FUNCTION public.savecntct(pcntctid integer, pcontactnumber text, paddrid integer, phonorific text, pfirstname text, pmiddlename text, plastname text, psuffix text, pphone text, pphone2 text, pfax text, pemail text, pwebaddr text, ptitle text, pflag text); publicadminfalse84623125579331savecntct(integer, text, integer, integer, text, text, text, text, text, text, boolean, text, text, text, text, text, text, text, text)FUNCTION CREATE FUNCTION savecntct(pcntctid integer, pcontactnumber text, pcrmacctid integer, paddrid integer, phonorific text, pfirstname text, pmiddlename text, plastname text, psuffix text, pinitials text, pactive boolean, pphone text, pphone2 text, pfax text, pemail text, pwebaddr text, pnotes text, ptitle text, pflag text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _returnVal INTEGER; BEGIN SELECT saveCntct( pCntctId, pContactNumber, pCrmAcctId, pAddrId, pHonorific, pFirstName, pMiddleName, pLastName, pSuffix, pInitials, pActive, pPhone, pPhone2, pFax, pEmail, pWebAddr, pNotes, pTitle, pFlag, NULL) INTO _returnVal; RETURN _returnVal; END; $$; GDROP FUNCTION public.savecntct(pcntctid integer, pcontactnumber text, pcrmacctid integer, paddrid integer, phonorific text, pfirstname text, pmiddlename text, plastname text, psuffix text, pinitials text, pactive boolean, pphone text, pphone2 text, pfax text, pemail text, pwebaddr text, pnotes text, ptitle text, pflag text); publicadminfalse84623125579332savecntct(integer, text, integer, integer, text, text, text, text, text, text, boolean, text, text, text, text, text, text, text, text, text)FUNCTIONCREATE FUNCTION savecntct(pcntctid integer, pcontactnumber text, pcrmacctid integer, paddrid integer, phonorific text, pfirstname text, pmiddlename text, plastname text, psuffix text, pinitials text, pactive boolean, pphone text, pphone2 text, pfax text, pemail text, pwebaddr text, pnotes text, ptitle text, pflag text, pownerusername text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cntctId INTEGER; _cntctNumber TEXT; _isNew BOOLEAN; _flag TEXT; _contactCount INTEGER := 0; BEGIN --Validate IF ((pFlag IS NULL) OR (pFlag = '') OR (pFlag = 'CHECK') OR (pFlag = 'CHANGEONE') OR (pFlag = 'CHANGEALL')) THEN IF (pFlag='') THEN _flag := 'CHECK'; ELSE _flag := COALESCE(pFlag,'CHECK'); END IF; ELSE RAISE EXCEPTION 'Invalid Flag (%). Valid flags are CHECK, CHANGEONE or CHANGEALL', pFlag; END IF; --If there is nothing here get out IF ( (pCntctId IS NULL OR pCntctId = -1) AND (pAddrId IS NULL) AND (COALESCE(pFirstName, '') = '') AND (COALESCE(pMiddleName, '') = '') AND (COALESCE(pLastName, '') = '') AND (COALESCE(pSuffix, '') = '') AND (COALESCE(pHonorific, '') = '') AND (COALESCE(pInitials, '') = '') AND (COALESCE(pPhone, '') = '') AND (COALESCE(pPhone2, '') = '') AND (COALESCE(pFax, '') = '') AND (COALESCE(pEmail, '') = '') AND (COALESCE(pWebAddr, '') = '') AND (COALESCE(pNotes, '') = '') AND (COALESCE(pTitle, '') = '') ) THEN RETURN NULL; END IF; IF (pCntctId IS NULL OR pCntctId = -1) THEN _isNew := true; _cntctId := nextval('cntct_cntct_id_seq'); _cntctNumber := COALESCE(pContactNumber,fetchNextNumber('ContactNumber')); ELSE SELECT COUNT(cntct_id) INTO _contactCount FROM cntct WHERE ((cntct_id=pCntctId) AND (cntct_first_name=pFirstName) AND (cntct_last_name=pLastName)); -- ask whether new or update if name changes -- but only if this isn't a new record with a pre-allocated id IF (_contactCount < 1 AND _flag = 'CHECK') THEN IF (EXISTS(SELECT cntct_id FROM cntct WHERE (cntct_id=pCntctId))) THEN RETURN -10; ELSE _isNew := true; _cntctNumber := fetchNextNumber('ContactNumber'); END IF; ELSIF (_flag = 'CHANGEONE') THEN _isNew := true; _cntctId := nextval('cntct_cntct_id_seq'); _cntctNumber := fetchNextNumber('ContactNumber'); ELSIF (_flag = 'CHANGEALL') THEN _isNew := false; END IF; END IF; IF (pContactNumber = '') THEN _cntctNumber := fetchNextNumber('ContactNumber'); ELSE _cntctNumber := COALESCE(_cntctNumber,pContactNumber,fetchNextNumber('ContactNumber')); END IF; IF (_isNew) THEN _cntctId := COALESCE(_cntctId,pCntctId,nextval('cntct_cntct_id_seq')); INSERT INTO cntct ( cntct_id,cntct_number, cntct_crmacct_id,cntct_addr_id,cntct_first_name, cntct_last_name,cntct_honorific,cntct_initials, cntct_active,cntct_phone,cntct_phone2, cntct_fax,cntct_email,cntct_webaddr, cntct_notes,cntct_title,cntct_middle,cntct_suffix, cntct_owner_username ) VALUES ( _cntctId, COALESCE(_cntctNumber,fetchNextNumber('ContactNumber')) ,pCrmAcctId,pAddrId, pFirstName,pLastName,pHonorific, pInitials,COALESCE(pActive,true),pPhone,pPhone2,pFax, pEmail,pWebAddr,pNotes,pTitle,pMiddleName,pSuffix,pOwnerUsername ); RETURN _cntctId; ELSE UPDATE cntct SET cntct_number=COALESCE(_cntctNumber,fetchNextNumber('ContactNumber')), cntct_crmacct_id=COALESCE(pCrmAcctId,cntct_crmacct_id), cntct_addr_id=COALESCE(pAddrId,cntct_addr_id), cntct_first_name=COALESCE(pFirstName,cntct_first_name), cntct_last_name=COALESCE(pLastName,cntct_last_name), cntct_honorific=COALESCE(pHonorific,cntct_honorific), cntct_initials=COALESCE(pInitials,cntct_initials), cntct_active=COALESCE(pActive,cntct_active), cntct_phone=COALESCE(pPhone,cntct_phone), cntct_phone2=COALESCE(pPhone2,cntct_phone2), cntct_fax=COALESCE(pFax,cntct_fax), cntct_email=COALESCE(pEmail,cntct_email), cntct_webaddr=COALESCE(pWebAddr,cntct_webaddr), cntct_notes=COALESCE(pNotes,cntct_notes), cntct_title=COALESCE(pTitle,cntct_title), cntct_middle=COALESCE(pMiddleName,cntct_middle), cntct_suffix=COALESCE(pSuffix,cntct_suffix), cntct_owner_username=COALESCE(pOwnerUsername, cntct_owner_username) WHERE (cntct_id=pCntctId); RETURN pCntctId; END IF; END; $$; \DROP FUNCTION public.savecntct(pcntctid integer, pcontactnumber text, pcrmacctid integer, paddrid integer, phonorific text, pfirstname text, pmiddlename text, plastname text, psuffix text, pinitials text, pactive boolean, pphone text, pphone2 text, pfax text, pemail text, pwebaddr text, pnotes text, ptitle text, pflag text, pownerusername text); publicadminfalse84623125579334/saveimageass(text, integer, character, integer)FUNCTIONCREATE FUNCTION saveimageass(text, integer, character, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSource ALIAS FOR $1; pSourceId ALIAS FOR $2; pPurpose ALIAS FOR $3; pImageid ALIAS FOR $4; _imageassId INTEGER = 0; BEGIN -- See if this link already exists SELECT imageass_id INTO _imageassId FROM imageass WHERE ((imageass_source_id=pSourceId) AND (imageass_source=pSource) AND (imageass_image_id=pImageId) AND (imageass_purpose=pPurpose)); IF (FOUND) THEN RETURN _imageassId; END IF; -- See if a record with this purpose already exists (item only) IF (pSource = 'I' AND pPurpose != 'M') THEN SELECT imageass_id INTO _imageassId FROM imageass WHERE ((imageass_source_id=pSourceId) AND (imageass_source=pSource) AND (imageass_purpose=pPurpose)); END IF; IF (_imageassId > 0) THEN UPDATE imageass SET imageass_image_id=pImageId WHERE (imageass_id=_imageassId); ELSE _imageassId := NEXTVAL('imageass_imageass_id_seq'); INSERT INTO imageass (imageass_id, imageass_source_id, imageass_source, imageass_image_id, imageass_purpose) VALUES (_imageassId, pSourceId, pSource, pImageid, CASE WHEN pSource='I' THEN pPurpose ELSE 'M' END); END IF; RETURN _imageassId; END; $_$; FDROP FUNCTION public.saveimageass(text, integer, character, integer); publicadminfalse46238125579335Jsaveipsitem(integer, integer, integer, numeric, numeric, integer, integer)FUNCTIONCREATE FUNCTION saveipsitem(integer, integer, integer, numeric, numeric, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pIpsItemId ALIAS FOR $1; pIpsHeadId ALIAS FOR $2; pItemId ALIAS FOR $3; pQtyBreak ALIAS FOR $4; pPrice ALIAS FOR $5; pQtyUomId ALIAS FOR $6; pPriceUomId ALIAS FOR $7; _ipsitemid INTEGER; _new BOOLEAN; BEGIN -- Validation IF (SELECT COUNT(item_id)=0 FROM item WHERE (item_id=pItemId)) THEN RAISE EXCEPTION 'You must provide a valid Item'; ELSIF (COALESCE(pQtyBreak,0) < 0) THEN RAISE EXCEPTION 'Quantity can not be a negative value'; ELSIF (COALESCE(pPrice,0) < 0) THEN RAISE EXCEPTION 'Price must be a negative value'; ELSIF ((pQtyUomId IS NOT NULL) AND (SELECT COUNT(item_id)=0 FROM (SELECT item_id FROM item WHERE ((item_id=pItemId) AND (item_inv_uom_id=pQtyUomId)) UNION SELECT item_id FROM item,itemuomconv,itemuom,uomtype WHERE ((item_id=pItemId) AND (itemuomconv_item_id=item_id) AND (itemuomconv_from_uom_id=pQtyUomId) AND (itemuom_itemuomconv_id=itemuomconv_id) AND (itemuom_uomtype_id=uomtype_id) AND (uomtype_name='Selling')) UNION SELECT item_id FROM item,itemuomconv,itemuom,uomtype WHERE ((item_id=pItemId) AND (itemuomconv_item_id=item_id) AND (itemuomconv_to_uom_id=pQtyUomId) AND (itemuom_itemuomconv_id=itemuomconv_id) AND (itemuom_uomtype_id=uomtype_id) AND (uomtype_name='Selling'))) AS data)) THEN RAISE EXCEPTION 'Qty UOM Must be a valid Selling UOM for the Item'; ELSIF ((pPriceUomId IS NOT NULL) AND (SELECT COUNT(item_id)=0 FROM (SELECT item_id FROM item WHERE ((item_id=pItemId) AND (item_inv_uom_id=pPriceUomId)) UNION SELECT item_id FROM item,itemuomconv,itemuom,uomtype WHERE ((item_id=pItemId) AND (itemuomconv_item_id=item_id) AND (itemuomconv_from_uom_id=pPriceUomId) AND (itemuom_itemuomconv_id=itemuomconv_id) AND (itemuom_uomtype_id=uomtype_id) AND (uomtype_name='Selling')) UNION SELECT item_id FROM item,itemuomconv,itemuom,uomtype WHERE ((item_id=pItemId) AND (itemuomconv_item_id=item_id) AND (itemuomconv_to_uom_id=pPriceUomId) AND (itemuom_itemuomconv_id=itemuomconv_id) AND (itemuom_uomtype_id=uomtype_id) AND (uomtype_name='Selling'))) AS data)) THEN RAISE EXCEPTION 'Price UOM Must be a valid Selling UOM for the Item'; END IF; _new := TRUE; IF (pIpsItemId IS NOT NULL) THEN SELECT ipsitem_id INTO _ipsitemid FROM ipsitem WHERE (ipsitem_id=pIpsItemId); IF (FOUND) THEN _new := FALSE; ELSE RAISE EXCEPTION 'Pricing Schedule Item not found.'; END IF; ELSE SELECT ipsitem_id INTO _ipsitemid FROM ipsitem WHERE ((ipsitem_ipshead_id = pIpsheadId) AND (ipsitem_item_id = pItemId) AND (ipsitem_qtybreak = pQtyBreak) AND (ipsitem_qty_uom_id = COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId))) AND (ipsitem_price_uom_id = CASE WHEN (pQtyUomId = (SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) THEN COALESCE(pPriceUomId,pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) ELSE COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) END)); END IF; IF (FOUND) THEN _new := false; ELSE _ipsitemid := nextval('ipsitem_ipsitem_id_seq'); END IF; IF (_new) THEN INSERT INTO ipsitem ( ipsitem_id, ipsitem_ipshead_id, ipsitem_item_id, ipsitem_qtybreak, ipsitem_price, ipsitem_qty_uom_id, ipsitem_price_uom_id, ipsitem_discntprcnt, ipsitem_fixedamtdiscount) VALUES ( _ipsitemid, pIpsheadId, pItemId, pQtyBreak, pPrice, COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)), CASE WHEN (pQtyUomId = (SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) THEN COALESCE(pPriceUomId,pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) ELSE COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) END, 0.0, 0.0); ELSE UPDATE ipsitem SET ipsitem_qtybreak = pQtyBreak, ipsitem_price = pPrice, ipsitem_qty_uom_id = COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)), ipsitem_price_uom_id = CASE WHEN (pQtyUomId = (SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) THEN COALESCE(pPriceUomId,pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) ELSE COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) END WHERE (ipsitem_id=_ipsitemid); END IF; RETURN _ipsitemid; END; $_$; aDROP FUNCTION public.saveipsitem(integer, integer, integer, numeric, numeric, integer, integer); publicadminfalse84623125579336bsaveipsitem(integer, integer, integer, numeric, numeric, integer, integer, numeric, numeric, text)FUNCTIONCREATE FUNCTION saveipsitem(pipsitemid integer, pipsheadid integer, pitemid integer, pqtybreak numeric, pprice numeric, pqtyuomid integer, ppriceuomid integer, ppercent numeric, pfixedamt numeric, ptype text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _ipsitemid INTEGER; _new BOOLEAN; BEGIN -- Validation IF (SELECT COUNT(item_id)=0 FROM item WHERE (item_id=pItemId)) THEN RAISE EXCEPTION 'You must provide a valid Item'; ELSIF (COALESCE(pQtyBreak,0) < 0) THEN RAISE EXCEPTION 'Quantity can not be a negative value'; ELSIF (COALESCE(pPrice,0) < 0) THEN RAISE EXCEPTION 'Price must be a negative value'; ELSIF ((pQtyUomId IS NOT NULL) AND (SELECT COUNT(item_id)=0 FROM (SELECT item_id FROM item WHERE ((item_id=pItemId) AND (item_inv_uom_id=pQtyUomId)) UNION SELECT item_id FROM item,itemuomconv,itemuom,uomtype WHERE ((item_id=pItemId) AND (itemuomconv_item_id=item_id) AND (itemuomconv_from_uom_id=pQtyUomId) AND (itemuom_itemuomconv_id=itemuomconv_id) AND (itemuom_uomtype_id=uomtype_id) AND (uomtype_name='Selling')) UNION SELECT item_id FROM item,itemuomconv,itemuom,uomtype WHERE ((item_id=pItemId) AND (itemuomconv_item_id=item_id) AND (itemuomconv_to_uom_id=pQtyUomId) AND (itemuom_itemuomconv_id=itemuomconv_id) AND (itemuom_uomtype_id=uomtype_id) AND (uomtype_name='Selling'))) AS data)) THEN RAISE EXCEPTION 'Qty UOM Must be a valid Selling UOM for the Item'; ELSIF ((pPriceUomId IS NOT NULL) AND (SELECT COUNT(item_id)=0 FROM (SELECT item_id FROM item WHERE ((item_id=pItemId) AND (item_inv_uom_id=pPriceUomId)) UNION SELECT item_id FROM item,itemuomconv,itemuom,uomtype WHERE ((item_id=pItemId) AND (itemuomconv_item_id=item_id) AND (itemuomconv_from_uom_id=pPriceUomId) AND (itemuom_itemuomconv_id=itemuomconv_id) AND (itemuom_uomtype_id=uomtype_id) AND (uomtype_name='Selling')) UNION SELECT item_id FROM item,itemuomconv,itemuom,uomtype WHERE ((item_id=pItemId) AND (itemuomconv_item_id=item_id) AND (itemuomconv_to_uom_id=pPriceUomId) AND (itemuom_itemuomconv_id=itemuomconv_id) AND (itemuom_uomtype_id=uomtype_id) AND (uomtype_name='Selling'))) AS data)) THEN RAISE EXCEPTION 'Price UOM Must be a valid Selling UOM for the Item'; END IF; _new := TRUE; IF (pIpsItemId IS NOT NULL) THEN SELECT ipsitem_id INTO _ipsitemid FROM ipsiteminfo WHERE (ipsitem_id=pIpsItemId); IF (FOUND) THEN _new := FALSE; ELSE RAISE EXCEPTION 'Pricing Schedule Item not found.'; END IF; ELSE SELECT ipsitem_id INTO _ipsitemid FROM ipsiteminfo WHERE ((ipsitem_ipshead_id = pIpsheadId) AND (ipsitem_item_id = pItemId) AND (ipsitem_qtybreak = pQtyBreak) AND (ipsitem_qty_uom_id = COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId))) AND (ipsitem_price_uom_id = CASE WHEN (pQtyUomId = (SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) THEN COALESCE(pPriceUomId,pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) ELSE COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) END)); END IF; IF (FOUND) THEN _new := false; END IF; IF (_new) THEN INSERT INTO ipsiteminfo ( ipsitem_ipshead_id, ipsitem_item_id, ipsitem_qtybreak, ipsitem_price, ipsitem_qty_uom_id, ipsitem_price_uom_id, ipsitem_discntprcnt, ipsitem_fixedamtdiscount, ipsitem_type) VALUES ( pIpsheadId, pItemId, pQtyBreak, pPrice, COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)), CASE WHEN (pQtyUomId = (SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) THEN COALESCE(pPriceUomId,pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) ELSE COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) END, pPercent, pFixedAmt, pType) RETURNING ipsitem_id INTO _ipsitemid; ELSE UPDATE ipsiteminfo SET ipsitem_qtybreak = pQtyBreak, ipsitem_price = pPrice, ipsitem_qty_uom_id = COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)), ipsitem_price_uom_id = CASE WHEN (pQtyUomId = (SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) THEN COALESCE(pPriceUomId,pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) ELSE COALESCE(pQtyUomId,(SELECT item_inv_uom_id FROM item WHERE item_id = pItemId)) END, ipsitem_discntprcnt=pPercent, ipsitem_fixedamtdiscount=pFixedAmt, ipsitem_type=pType WHERE (ipsitem_id=_ipsitemid); END IF; RETURN _ipsitemid; END; $$; DROP FUNCTION public.saveipsitem(pipsitemid integer, pipsheadid integer, pitemid integer, pqtybreak numeric, pprice numeric, pqtyuomid integer, ppriceuomid integer, ppercent numeric, pfixedamt numeric, ptype text); publicadminfalse46238125579337;saveipsprodcat(integer, integer, integer, numeric, numeric)FUNCTIONCREATE FUNCTION saveipsprodcat(integer, integer, integer, numeric, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ DECLARE pIpsProdcatId ALIAS FOR $1; pIpsHeadId ALIAS FOR $2; pProdCatId ALIAS FOR $3; pQtyBreak ALIAS FOR $4; pDiscount ALIAS FOR $5; _ipsprodcatid INTEGER; _new BOOLEAN; BEGIN -- Validation IF (SELECT COUNT(*)=0 FROM prodcat WHERE (prodcat_id=pProdcatId)) THEN RAISE EXCEPTION 'You must provide a valid Product Category'; ELSIF (COALESCE(pQtyBreak,0) < 0) THEN RAISE EXCEPTION 'Quantity can not be a negative value'; ELSIF (COALESCE(pDiscount,0) < 0) THEN RAISE EXCEPTION 'Discount must be a negative value'; END IF; _new := TRUE; IF (pIpsProdcatId IS NOT NULL) THEN SELECT ipsprodcat_id INTO _ipsprodcatid FROM ipsprodcat WHERE (ipsprodcat_id=pIpsprodcatId); IF (FOUND) THEN _new := FALSE; ELSE RAISE EXCEPTION 'Pricing Schedule Product Category not found'; END IF; ELSE SELECT ipsprodcat_id INTO _ipsprodcatid FROM ipsprodcat WHERE ((ipsprodcat_ipshead_id=pIpsheadId) AND (ipsprodcat_prodcat_id=pProdcatId) AND (ipsprodcat_qtybreak=pQtyBreak)); IF (FOUND) THEN _new := false; ELSE _ipsprodcatid := nextval('ipsprodcat_ipsprodcat_id_seq'); END IF; END IF; IF (_new) THEN INSERT INTO ipsprodcat ( ipsprodcat_id, ipsprodcat_ipshead_id, ipsprodcat_prodcat_id, ipsprodcat_qtybreak, ipsprodcat_discntprcnt) VALUES ( _ipsprodcatid, pIpsheadId, pProdcatId, pQtyBreak, pDiscount * .01); ELSE UPDATE ipsprodcat SET ipsprodcat_qtybreak = pQtyBreak, ipsprodcat_discntprcnt = pDiscount * .01 WHERE (ipsprodcat_id=_ipsprodcatid); END IF; RETURN _ipsprodcatid; END; $_$; RDROP FUNCTION public.saveipsprodcat(integer, integer, integer, numeric, numeric); publicadminfalse84623125579338Dsaveipsprodcat(integer, integer, integer, numeric, numeric, numeric)FUNCTIONICREATE FUNCTION saveipsprodcat(integer, integer, integer, numeric, numeric, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pIpsProdcatId ALIAS FOR $1; pIpsHeadId ALIAS FOR $2; pProdCatId ALIAS FOR $3; pQtyBreak ALIAS FOR $4; pDiscount ALIAS FOR $5; pFixedAmtDiscount ALIAS FOR $6; _ipsprodcatid INTEGER; _new BOOLEAN; BEGIN -- Validation IF (SELECT COUNT(*)=0 FROM prodcat WHERE (prodcat_id=pProdcatId)) THEN RAISE EXCEPTION 'You must provide a valid Product Category'; ELSIF (COALESCE(pQtyBreak,0) < 0) THEN RAISE EXCEPTION 'Quantity can not be a negative value'; ELSIF (COALESCE(pDiscount,0) < 0) THEN RAISE EXCEPTION 'Discount must be a negative value'; END IF; _new := TRUE; IF (pIpsProdcatId IS NOT NULL) THEN SELECT ipsprodcat_id INTO _ipsprodcatid FROM ipsprodcat WHERE (ipsprodcat_id=pIpsprodcatId); IF (FOUND) THEN _new := FALSE; ELSE RAISE EXCEPTION 'Pricing Schedule Product Category not found'; END IF; ELSE SELECT ipsprodcat_id INTO _ipsprodcatid FROM ipsprodcat WHERE ((ipsprodcat_ipshead_id=pIpsheadId) AND (ipsprodcat_prodcat_id=pProdcatId) AND (ipsprodcat_qtybreak=pQtyBreak)); IF (FOUND) THEN _new := false; ELSE _ipsprodcatid := nextval('ipsprodcat_ipsprodcat_id_seq'); END IF; END IF; IF (_new) THEN INSERT INTO ipsprodcat ( ipsprodcat_id, ipsprodcat_ipshead_id, ipsprodcat_prodcat_id, ipsprodcat_qtybreak, ipsprodcat_discntprcnt, ipsprodcat_fixedamtdiscount) VALUES ( _ipsprodcatid, pIpsheadId, pProdcatId, pQtyBreak, pDiscount * .01, pFixedAmtDiscount); ELSE UPDATE ipsprodcat SET ipsprodcat_qtybreak = pQtyBreak, ipsprodcat_discntprcnt = pDiscount * .01, ipsprodcat_fixedamtdiscount = pFixedAmtDiscount WHERE (ipsprodcat_id=_ipsprodcatid); END IF; RETURN _ipsprodcatid; END; $_$; [DROP FUNCTION public.saveipsprodcat(integer, integer, integer, numeric, numeric, numeric); publicadminfalse84623125579339Jsaveipsprodcat(integer, integer, integer, numeric, numeric, numeric, text)FUNCTION CREATE FUNCTION saveipsprodcat(pipsprodcatid integer, pipsheadid integer, pprodcatid integer, pqtybreak numeric, pdiscount numeric, pfixedamtdiscount numeric, ptype text) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _ipsitemid INTEGER; _new BOOLEAN; BEGIN -- Validation IF (SELECT COUNT(*)=0 FROM prodcat WHERE (prodcat_id=pProdcatId)) THEN RAISE EXCEPTION 'You must provide a valid Product Category'; ELSIF (COALESCE(pQtyBreak,0) < 0) THEN RAISE EXCEPTION 'Quantity can not be a negative value'; ELSIF (COALESCE(pDiscount,0) < 0) THEN RAISE EXCEPTION 'Discount must be a negative value'; END IF; _new := TRUE; IF (pIpsProdcatId IS NOT NULL) THEN SELECT ipsitem_id INTO _ipsitemid FROM ipsiteminfo WHERE (ipsprodcat_id=pIpsprodcatId); IF (FOUND) THEN _new := FALSE; ELSE RAISE EXCEPTION 'Pricing Schedule Product Category not found'; END IF; ELSE SELECT ipsitem_id INTO _ipsitemid FROM ipsiteminfo WHERE ((ipsitem_ipshead_id=pIpsheadId) AND (ipsitem_prodcat_id=pProdcatId) AND (ipsitem_qtybreak=pQtyBreak)); IF (FOUND) THEN _new := false; ELSE _ipsitemid := nextval('ipsitem_ipsitem_id_seq'); END IF; END IF; IF (_new) THEN INSERT INTO ipsiteminfo ( ipsitem_id, ipsitem_ipshead_id, ipsitem_prodcat_id, ipsitem_qtybreak, ipsitem_price, ipsitem_discntprcnt, ipsitem_fixedamtdiscount, ipsitem_type) VALUES ( _ipsitemid, pIpsheadId, pProdcatId, pQtyBreak, 0.0, pDiscount * .01, pFixedAmtDiscount, pType); ELSE UPDATE ipsiteminfo SET ipsitem_qtybreak = pQtyBreak, ipsitem_discntprcnt = pDiscount * .01, ipsitem_fixedamtdiscount = pFixedAmtDiscount, ipsitem_type = pType WHERE (ipsitem_id=_ipsitemid); END IF; RETURN _ipsitemid; END; $$; DROP FUNCTION public.saveipsprodcat(pipsprodcatid integer, pipsheadid integer, pprodcatid integer, pqtybreak numeric, pdiscount numeric, pfixedamtdiscount numeric, ptype text); publicadminfalse84623125579340*saveitemimage(integer, character, integer)FUNCTIONCREATE FUNCTION saveitemimage(integer, character, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pPurpose ALIAS FOR $2; pImageid ALIAS FOR $3; _itemimageId INTEGER; BEGIN -- See if a record with this purpose already exists SELECT imageass_id INTO _itemimageId FROM imageass WHERE ( (imageass_source='I') AND (imageass_source_id=pItemid) AND (imageass_purpose=pPurpose) ); IF (FOUND) THEN UPDATE imageass SET imageass_image_id=pImageId WHERE (imageass_id=_itemimageId); ELSE _itemimageId := NEXTVAL('imageass_imageass_id_seq'); INSERT INTO imageass (imageass_id, imageass_source_id, imageass_source, imageass_image_id, imageass_purpose) VALUES (_itemimageId, pItemid, 'I', pImageid, pPurpose); END IF; RETURN _itemimageId; END; $_$; ADROP FUNCTION public.saveitemimage(integer, character, integer); publicadminfalse46238125579341Psaveitemuomconv(integer, integer, numeric, integer, numeric, boolean, integer[])FUNCTIONQ CREATE FUNCTION saveitemuomconv(integer, integer, numeric, integer, numeric, boolean, integer[]) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemId ALIAS FOR $1; pFromUomId ALIAS FOR $2; pFromValue ALIAS FOR $3; pToUomId ALIAS FOR $4; pToValue ALIAS FOR $5; pFractional ALIAS FOR $6; pUomTypes ALIAS FOR $7; _p RECORD; _fromUomId INTEGER; _fromValue NUMERIC; _toUomId INTEGER; _toValue NUMERIC; _fractional BOOLEAN; _seq INTEGER; _i INTEGER; _uomtype TEXT; BEGIN -- Make sure we have some itemtypes IF (pUomTypes IS NULL) OR (ARRAY_UPPER(pUomTypes,1) = 0) THEN RAISE EXCEPTION 'You must include at least one item type.'; END IF; -- If this is a global UOM, over-ride with global data. SELECT * INTO _p FROM uomconv WHERE ((((uomconv_from_uom_id=pFromUomId) AND (uomconv_to_uom_id=pToUomId)) OR ((uomconv_from_uom_id=pToUomId) AND (uomconv_to_uom_id=pFromUomId)))); IF (FOUND) THEN _fromUomId := _p.uomconv_from_uom_id; _toUomId := _p.uomconv_to_uom_id; _fromValue := _p.uomconv_from_value; _toValue := _p.uomconv_to_value; _fractional := _p.uomconv_fractional; --RAISE NOTICE 'Defaulted to global Unit of Measure conversion ratios.'; ELSE _fromUomId := pFromUomId; _fromValue := pFromValue; _toUomId := pToUomId; _toValue := pToValue; _fractional := pFractional; END IF; -- See if an item conversion exists going the other way SELECT f.uom_name AS f_uom, t.uom_name as t_uom INTO _p FROM itemuomconv,uom f, uom t WHERE ((itemuomconv_item_id=pItemId) AND (itemuomconv_from_uom_id=_toUomId) AND (itemuomconv_to_uom_id=_fromUomId) AND (f.uom_id=itemuomconv_from_uom_id) AND (t.uom_id=itemuomconv_to_uom_id)); IF (FOUND) THEN RAISE EXCEPTION 'Unit of measure conversion already exists going from % to %.',_p.f_uom,_p.t_uom; END IF; -- See if an item conversion record exists SELECT * INTO _p FROM itemuomconv WHERE ((itemuomconv_item_id=pItemId) AND (itemuomconv_from_uom_id=_fromUomId) AND (itemuomconv_to_uom_id=_toUomId)); -- Update if found IF (FOUND) THEN UPDATE itemuomconv SET itemuomconv_from_value=_fromValue, itemuomconv_to_value=_toValue, itemuomconv_fractional=_fractional WHERE (itemuomconv_id=_p.itemuomconv_id); _seq := _p.itemuomconv_id; --Delete old type list DELETE FROM itemuom WHERE itemuom_itemuomconv_id=_p.itemuomconv_id; ELSE -- Otherwise create a new one SELECT NEXTVAL('itemuomconv_itemuomconv_id_seq') INTO _seq; INSERT INTO itemuomconv VALUES (_seq, pItemId,_fromUomId,_fromValue,_toUomId,_toValue,_fractional); END IF; -- Build new type list FOR _i IN 1..ARRAY_UPPER(pUomTypes,1) LOOP SELECT uomtype_name INTO _uomtype FROM itemuomconv, itemuom, uomtype WHERE ((itemuom_uomtype_id=uomtype_id) AND (itemuomconv_id=itemuom_itemuomconv_id) AND (itemuomconv_item_id=pItemId) AND (uomtype_name != 'Selling') AND (itemuom_uomtype_id=pUomTypes[_i])); IF (FOUND) THEN RAISE EXCEPTION 'Unit of Measure Type % is already used on this item',_uomtype; ELSE INSERT INTO itemuom (itemuom_itemuomconv_id,itemuom_uomtype_id) VALUES (_seq,pUomTypes[_i]); END IF; END LOOP; RETURN _seq; END; $_$; gDROP FUNCTION public.saveitemuomconv(integer, integer, numeric, integer, numeric, boolean, integer[]); publicadminfalse84623125579342#savemetasql(text, text, text, text)FUNCTION)CREATE FUNCTION savemetasql(text, text, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN saveMetasql($1, $2, $3, $4, true, NULL, 0); END; $_$; :DROP FUNCTION public.savemetasql(text, text, text, text); publicadminfalse84623125579343,savemetasql(text, text, text, text, boolean)FUNCTION0CREATE FUNCTION savemetasql(text, text, text, text, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN saveMetasql($1, $2, $3, $4, $5, NULL, 0); END; $_$; CDROP FUNCTION public.savemetasql(text, text, text, text, boolean); publicadminfalse846231255793442savemetasql(text, text, text, text, boolean, text)FUNCTION4CREATE FUNCTION savemetasql(text, text, text, text, boolean, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN saveMetasql($1, $2, $3, $4, $5, $6, 0); END; $_$; IDROP FUNCTION public.savemetasql(text, text, text, text, boolean, text); publicadminfalse84623125579345;savemetasql(text, text, text, text, boolean, text, integer)FUNCTIONCREATE FUNCTION savemetasql(text, text, text, text, boolean, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pGroup ALIAS FOR $1; pName ALIAS FOR $2; pNotes ALIAS FOR $3; pQuery ALIAS FOR $4; pSystem ALIAS FOR $5; pSchema ALIAS FOR $6; pGrade ALIAS FOR $7; _metasqlid INTEGER; _debug BOOL := false; _grade INTEGER; _insertstr TEXT; _table TEXT; BEGIN --See if Query already exists SELECT metasql_id INTO _metasqlid FROM metasql WHERE ((metasql_group=pGroup) AND (metasql_name=pName) AND (metasql_grade=pGrade)); IF (FOUND) THEN IF (_debug) THEN RAISE NOTICE 'update metasql'; END IF; UPDATE metasql SET metasql_group=pGroup, metasql_name=pName, metasql_notes=pNotes, metasql_query=pQuery WHERE (metasql_id=_metasqlid); ELSE IF (COALESCE(pSchema, 'public') = 'public' OR TRIM(pSchema) = '') THEN _table := 'metasql'; ELSE _table := pSchema || '.pkgmetasql'; END IF; IF (pGrade IS NULL) THEN SELECT MAX(metasql_grade) + 1 INTO _grade FROM metasql WHERE ((metasql_group=pGroup) AND (metasql_name=pName)); ELSE _grade := pGrade; END IF; _insertstr := 'INSERT INTO ' || _table || ' (metasql_group, metasql_name, metasql_notes, ' || ' metasql_query, metasql_grade) VALUES (' || COALESCE(quote_literal(pGroup),'NULL') || ',' || COALESCE(quote_literal(pName), 'NULL') || ',' || COALESCE(quote_literal(pNotes), 'NULL') || ',' || COALESCE(quote_literal(pQuery), 'NULL') ||',' || COALESCE(quote_literal(_grade), 'NULL') || ') RETURNING metasql_id;' ; IF (_debug) THEN RAISE NOTICE '%', _insertstr; END IF; EXECUTE _insertstr INTO _metasqlid; END IF; RETURN _metasqlid; END; $_$; RDROP FUNCTION public.savemetasql(text, text, text, text, boolean, text, integer); publicadminfalse46238125579346 scraps(text)FUNCTIONcCREATE FUNCTION scraps(text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTransType ALIAS FOR $1; BEGIN IF (pTransType IN ('SI', 'SM', 'EX')) THEN RETURN TRUE; ELSE RETURN FALSE; END IF; END; $_$; #DROP FUNCTION public.scraps(text); publicadminfalse84623125579347!scrapwomaterial(integer, numeric)FUNCTION'CREATE FUNCTION scrapwomaterial(integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN scrapWoMaterial($1, $2, CURRENT_TIMESTAMP); END; $_$; 8DROP FUNCTION public.scrapwomaterial(integer, numeric); publicadminfalse84623125579348;scrapwomaterial(integer, numeric, timestamp with time zone)FUNCTION CREATE FUNCTION scrapwomaterial(integer, numeric, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWomatlid ALIAS FOR $1; pQty ALIAS FOR $2; pGlDistTS ALIAS FOR $3; _costmethod CHAR(1); _scrapValue NUMERIC; _r RECORD; BEGIN -- Validate IF (pQty <= 0) THEN RAISE EXCEPTION 'Scrap quantity must be a positive number'; ELSIF ( ( SELECT (womatl_qtyiss < pQty) FROM womatl WHERE (womatl_id=pWomatlid) ) ) THEN RAISE EXCEPTION 'You may not scrap more material than has been issued'; END IF; -- Get the wip G/L account SELECT costcat_wip_accnt_id INTO _r FROM womatl, wo, itemsite, costcat WHERE((womatl_wo_id=wo_id) AND (wo_itemsite_id=itemsite_id) AND (itemsite_costcat_id=costcat_id) AND (womatl_id=pWomatlid)); -- Calculate scrap value SELECT itemsite_costmethod INTO _costmethod FROM womatl JOIN itemsite ON (womatl_itemsite_id=itemsite_id) WHERE (womatl_id=pWomatlid); IF (_costmethod = 'S') THEN SELECT ROUND((stdCost(itemsite_item_id) * itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, pQty)),2) INTO _scrapValue FROM womatl JOIN itemsite ON (womatl_itemsite_id=itemsite_id) WHERE (womatl_id=pWomatlid); ELSIF (_costmethod = 'A') THEN SELECT ROUND((SUM(invhist_invqty * invhist_unitcost)-womatl_scrapvalue)/ (CASE WHEN (SUM(invhist_invqty)-itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtywipscrap) = 0) THEN 1 ELSE SUM(invhist_invqty)-itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtywipscrap) END),2) * itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, pQty) INTO _scrapValue FROM womatl JOIN womatlpost ON (womatl_id=womatlpost_womatl_id) JOIN invhist ON (womatlpost_invhist_id=invhist_id) JOIN itemsite ON (womatl_itemsite_id=itemsite_id) WHERE (womatl_id=pWomatlid) GROUP BY itemsite_item_id,womatl_uom_id,womatl_qtywipscrap,womatl_scrapvalue; ELSE RAISE EXCEPTION 'Cost method not supported to scrap this item'; END IF; -- Distribute to G/L PERFORM insertGLTransaction( 'W/O', 'WO', formatWoNumber(womatl_wo_id), ('Scrap ' || item_number || ' from Work Order'), getPrjAccntId(wo_prj_id, _r.costcat_wip_accnt_id), getPrjAccntId(wo_prj_id, costcat_mfgscrap_accnt_id), -1, _scrapValue, date(pGlDistTS) ) FROM wo, womatl, itemsite, item, costcat WHERE ( (wo_id=womatl_wo_id) AND (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (itemsite_costcat_id=costcat_id) AND (womatl_id=pWomatlid) ); UPDATE womatl SET womatl_qtywipscrap=(womatl_qtywipscrap + pQty), womatl_scrapvalue = womatl_scrapvalue + _scrapValue, womatl_qtyiss=(womatl_qtyiss - pQty) WHERE (womatl_id=pWomatlid); UPDATE wo SET wo_wipvalue = wo_wipvalue-_scrapValue, wo_postedvalue = wo_postedvalue-_scrapValue FROM womatl WHERE ((womatl_id=pWomatlid) AND (wo_id=womatl_wo_id)); RETURN pWomatlid; END; $_$; RDROP FUNCTION public.scrapwomaterial(integer, numeric, timestamp with time zone); publicadminfalse84623125579349 selectbalanceforbilling(integer)FUNCTION CREATE FUNCTION selectbalanceforbilling(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoheadid ALIAS FOR $1; _returnval BOOLEAN := TRUE; _doSelect BOOLEAN; _result INTEGER; _soitem RECORD; BEGIN FOR _soitem IN -- Get the shipments for this SO. Kits are not shipped SELECT cust_partialship, coitem_id, coitem_linenumber, 'NOTK' AS item_type, SUM(shipitem_qty) AS qty, ( (SUM(shipitem_qty) >= (coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned + SUM(shipitem_qty))) OR (NOT cust_partialship) ) AS toclose FROM cohead JOIN custinfo ON (cust_id=cohead_cust_id) JOIN coitem ON (coitem_cohead_id=cohead_id) JOIN shipitem ON ( (shipitem_orderitem_id=coitem_id) AND (NOT shipitem_invoiced) ) JOIN shiphead ON ( (shiphead_id=shipitem_shiphead_id) AND (shiphead_order_type='SO') AND (shiphead_shipped) ) WHERE (cohead_id=pSoheadid) GROUP BY cust_partialship, coitem_id, item_type, coitem_linenumber, coitem_qtyord, coitem_qtyshipped, coitem_qtyreturned UNION -- Get the Kits for this SO SELECT cust_partialship, coitem_id, coitem_linenumber, 'K' AS item_type, coitem_qtyord AS qty, TRUE AS toclose FROM cohead JOIN custinfo ON (cust_id=cohead_cust_id) JOIN coitem ON (coitem_cohead_id=cohead_id AND coitem_status='O') JOIN itemsite ON (itemsite_id=coitem_itemsite_id) JOIN item ON ( (item_id=itemsite_item_id) AND (item_type='K') ) WHERE (cohead_id=pSoheadid) LOOP _doSelect := true; IF(_soitem.item_type = 'K') THEN -- see if all the sub items are shipped SELECT coitem_id INTO _result FROM coitem WHERE((coitem_cohead_id=pSoheadid) AND (coitem_linenumber=_soitem.coitem_linenumber) AND (coitem_subnumber > 0) AND ((coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) > 0)) LIMIT 1; IF( FOUND ) THEN _doSelect := false; END IF; END IF; IF (_doSelect) THEN -- do as much as we can but still report errors if they occur IF (selectForBilling(_soitem.coitem_id, _soitem.qty, _soitem.toclose) < 0) THEN _returnval := FALSE; END IF; END IF; END LOOP; RETURN _returnval; END; $_$; 7DROP FUNCTION public.selectbalanceforbilling(integer); publicadminfalse46238125579350/selectdiscountitemsforpayment(integer, integer)FUNCTIONCREATE FUNCTION selectdiscountitemsforpayment(pvendid integer, pbankaccntid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _currid INTEGER; _r RECORD; BEGIN SELECT bankaccnt_curr_id INTO _currid FROM bankaccnt WHERE (bankaccnt_id=pBankaccntid); FOR _r IN SELECT apopen_id FROM apopen, terms WHERE((CURRENT_DATE <= determineDiscountDate(apopen_terms_id, apopen_docdate)) AND (terms_discprcnt > 0.0) AND (apopen_terms_id=terms_id) AND (apopen_open) AND (apopen_status = 'O') AND (apopen_doctype IN ('V', 'D')) AND (apopen_vend_id=pVendid) AND (apopen_curr_id=_currid) ) LOOP PERFORM selectPayment(_r.apopen_id, pBankaccntid); END LOOP; RETURN 1; END; $$; [DROP FUNCTION public.selectdiscountitemsforpayment(pvendid integer, pbankaccntid integer); publicadminfalse46238125579351*selectdueitemsforpayment(integer, integer)FUNCTIONCREATE FUNCTION selectdueitemsforpayment(pvendid integer, pbankaccntid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _currid INTEGER; BEGIN SELECT bankaccnt_curr_id INTO _currid FROM bankaccnt WHERE (bankaccnt_id=pBankaccntid); PERFORM selectPayment(apopen_id, pBankaccntid) FROM apopen WHERE((apopen_open) AND (apopen_vend_id=pVendid) AND (apopen_duedate <= CURRENT_DATE) AND (apopen_status = 'O') AND (apopen_doctype IN ('V', 'D')) AND (apopen_curr_id=_currid) ); RETURN 1; END; $$; VDROP FUNCTION public.selectdueitemsforpayment(pvendid integer, pbankaccntid integer); publicadminfalse46238125579352+selectforbilling(integer, numeric, boolean)FUNCTIONPCREATE FUNCTION selectforbilling(integer, numeric, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoitemid ALIAS FOR $1; pQty ALIAS FOR $2; pClose ALIAS FOR $3; _itemid INTEGER := NULL; _taxzoneid INTEGER := NULL; _taxid INTEGER := NULL; _taxtypeid INTEGER := NULL; BEGIN SELECT cobmisc_taxzone_id, item_id, coitem_taxtype_id INTO _taxzoneid, _itemid, _taxtypeid FROM cobmisc, coitem, itemsite, item WHERE ((cobmisc_cohead_id = coitem_cohead_id) AND (NOT cobmisc_posted) AND (coitem_itemsite_id = itemsite_id) AND (itemsite_item_id = item_id) AND (coitem_id = pSoitemid) ) LIMIT 1; RETURN selectforbilling(pSoitemid, pQty, pClose, _taxtypeid); END; $_$; BDROP FUNCTION public.selectforbilling(integer, numeric, boolean); publicadminfalse462381255793534selectforbilling(integer, numeric, boolean, integer)FUNCTIONCREATE FUNCTION selectforbilling(integer, numeric, boolean, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoitemid ALIAS FOR $1; pQty ALIAS FOR $2; pClose ALIAS FOR $3; ptaxtypeid ALIAS FOR $4; _cobillid INTEGER; _r RECORD; BEGIN -- Get some information SELECT cobmisc_id, cobmisc_taxzone_id, coitem_id, coitem_price, coitem_price_invuomratio AS invpricerat, coitem_qty_invuomratio, item_id INTO _r FROM cobmisc, coitem, itemsite, item, site() WHERE ((cobmisc_cohead_id = coitem_cohead_id) AND (NOT cobmisc_posted) AND (coitem_itemsite_id = itemsite_id) AND (itemsite_item_id = item_id) AND (coitem_id = pSoitemid) AND (itemsite_warehous_id = warehous_id) ) LIMIT 1; -- check to make sure the qty to bill for is not less than -- the total un-invoiced shipped amount IF ((SELECT (pQty < SUM(shipitem_qty)) FROM shipitem, shiphead, coitem WHERE ( (shipitem_shiphead_id=shiphead_id) AND (shiphead_order_type='SO') AND (shiphead_order_id=coitem_cohead_id) AND (shipitem_orderitem_id=coitem_id) AND (shiphead_shipped) AND (NOT shipitem_invoiced) AND (coitem_id=pSoitemid) ) ) ) THEN RETURN -1; END IF; SELECT cobill_id INTO _cobillid FROM cobill, cobmisc, coitem WHERE ((cobill_cobmisc_id = cobmisc_id) AND (cobmisc_cohead_id = coitem_cohead_id) AND (cobill_coitem_id = coitem_id) AND (NOT cobmisc_posted) AND (coitem_id = pSoitemid)); IF (FOUND) THEN UPDATE cobill SET cobill_selectdate = CURRENT_DATE, cobill_select_username = getEffectiveXtUser(), cobill_qty = pQty, cobill_toclose = pClose, cobill_taxtype_id = ptaxtypeid WHERE (cobill_id=_cobillid); ELSE SELECT NEXTVAL('cobill_cobill_id_seq') INTO _cobillid; INSERT INTO cobill (cobill_id, cobill_coitem_id, cobill_cobmisc_id, cobill_selectdate, cobill_select_username, cobill_qty, cobill_toclose, cobill_taxtype_id) VALUES (_cobillid, _r.coitem_id, _r.cobmisc_id, CURRENT_DATE, getEffectiveXtUser(), pQty, pClose, ptaxtypeid); END IF; RETURN _cobillid; END; $_$; KDROP FUNCTION public.selectforbilling(integer, numeric, boolean, integer); publicadminfalse46238125579354selectpayment(integer, integer)FUNCTIONCREATE FUNCTION selectpayment(papopenid integer, pbankaccntid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _p RECORD; _amount NUMERIC; _discount NUMERIC; BEGIN SELECT apopen_amount, apopen_paid, apopen_doctype, apopen_docdate, apopen_curr_id, apopen_amount - apopen_paid - apCheckPending(apopen_id) AS balance, noNeg(COALESCE(apopen_discountable_amount, 0) * CASE WHEN (CURRENT_DATE <= determineDiscountDate(apopen_terms_id, apopen_docdate)) THEN terms_discprcnt ELSE 0.0 END - discount_applied) AS discount_available INTO _p FROM apopen LEFT OUTER JOIN terms ON (apopen_terms_id=terms_id), (SELECT COALESCE(SUM(apapply_amount),0) AS discount_applied FROM apapply, apopen WHERE((apapply_target_apopen_id=pApopenid) AND (apapply_source_apopen_id=apopen_id) AND (apopen_discount)) ) AS data WHERE(apopen_id=pApopenid); IF(NOT FOUND OR (NOT _p.apopen_doctype IN ('V','D','C'))) THEN RAISE EXCEPTION 'Apopen not found or invalid document type [xtuple: selectPayment, -1]'; END IF; _discount := round(_p.discount_available, 2); _amount := noNeg(round(_p.balance, 2) - _discount); RETURN selectPayment(pApopenid, pBankaccntid, _p.apopen_docdate, _p.apopen_curr_id, _amount, _discount); END; $$; MDROP FUNCTION public.selectpayment(papopenid integer, pbankaccntid integer); publicadminfalse46238125587093@selectpayment(integer, integer, date, integer, numeric, numeric)FUNCTIONd CREATE FUNCTION selectpayment(papopenid integer, pbankaccntid integer, pdocdate date, pcurrid integer, pamount numeric, pdiscount numeric) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _p RECORD; _bankcompany TEXT; _distcompany TEXT; _apselectid INTEGER; _amount NUMERIC; _discount NUMERIC; BEGIN SELECT apopen_amount, apopen_paid, apopen_doctype, apopen_docdate, apopen_docnumber, apopen_curr_id, apopen_amount - apopen_paid - apCheckPending(apopen_id) AS balance INTO _p FROM apopen WHERE(apopen_id=pApopenid); IF(NOT FOUND OR (NOT _p.apopen_doctype IN ('V','D','C'))) THEN RAISE EXCEPTION 'Apopen not found or invalid document type [xtuple: selectPayment, -1]'; END IF; IF (round(_p.balance,2) < (pDiscount + pAmount)) THEN RAISE EXCEPTION 'Apopen balance less than amount plus discount [xtuple: selectPayment, -2]'; END IF; IF (_p.apopen_doctype = 'V') THEN SELECT COALESCE(accnt_company, '') INTO _bankcompany FROM bankaccnt JOIN accnt ON (accnt_id=bankaccnt_accnt_id) WHERE (bankaccnt_id=pBankaccntid); SELECT COALESCE(accnt_company, '') INTO _distcompany FROM vohead JOIN vodist ON (vodist_vohead_id=vohead_id) JOIN accnt ON (accnt_id=vodist_accnt_id) WHERE (vohead_number=_p.apopen_docnumber) AND (COALESCE(accnt_company, '') != _bankcompany); IF (FOUND) THEN RAISE EXCEPTION 'Bank account company does not match Voucher distribution company [xtuple: selectPayment, -3]'; END IF; SELECT COALESCE(accnt_company, '') INTO _distcompany FROM vohead JOIN vodist ON (vodist_vohead_id=vohead_id) JOIN expcat ON (expcat_id=vodist_expcat_id) JOIN accnt ON (accnt_id=expcat_exp_accnt_id) WHERE (vohead_number=_p.apopen_docnumber) AND (COALESCE(accnt_company, '') != _bankcompany); IF (FOUND) THEN RAISE EXCEPTION 'Bank account company does not match Voucher distribution company [xtuple: selectPayment, -3]'; END IF; END IF; IF (pAmount > 0.0) THEN SELECT apselect_id INTO _apselectid FROM apselect WHERE (apselect_apopen_id=pApopenid); IF (FOUND) THEN UPDATE apselect SET apselect_amount=pAmount, apselect_discount=pDiscount, apselect_curr_id=pCurrid WHERE(apselect_id=_apselectid); ELSE INSERT INTO apselect ( apselect_apopen_id, apselect_amount, apselect_discount, apselect_bankaccnt_id, apselect_curr_id, apselect_date ) VALUES ( pApopenid, pAmount, pDiscount, pBankaccntid, pCurrid, pDocdate ) RETURNING apselect_id INTO _apselectid; END IF; ELSE _apselectid := 0; END IF; RETURN _apselectid; END; $$; DROP FUNCTION public.selectpayment(papopenid integer, pbankaccntid integer, pdocdate date, pcurrid integer, pamount numeric, pdiscount numeric); publicadminfalse46238125579355!selectuninvoicedshipment(integer)FUNCTIONCREATE FUNCTION selectuninvoicedshipment(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipheadid ALIAS FOR $1; _cobmiscid INTEGER; _coheadid INTEGER; _r RECORD; _cobillid INTEGER; BEGIN -- make a cobmisc head if it doesn't already exist for this cohead SELECT shiphead_order_id, createBillingHeader(shiphead_order_id) INTO _coheadid, _cobmiscid FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id) WHERE (shiphead_shipped AND NOT shipitem_invoiced AND (shiphead_id=pShipheadid)); -- Grab all of the uninvoiced shipitem records FOR _r IN SELECT cohead_id, coitem_id, SUM(shipitem_qty) AS qty, coitem_price, coitem_price_invuomratio AS invpricerat, coitem_qty_invuomratio, item_id, ( ((coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) <= 0) OR (NOT cust_partialship) ) AS toclose, coitem_taxtype_id FROM shiphead, shipitem, coitem, cohead, custinfo, itemsite, item WHERE ( (shipitem_shiphead_id=shiphead_id) AND (shipitem_orderitem_id=coitem_id) AND (coitem_cohead_id=cohead_id) AND (shiphead_shipped) AND (NOT shipitem_invoiced) AND (coitem_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (cohead_cust_id=cust_id) AND (item_type != 'K') AND (cohead_id=_coheadid) AND (shiphead_id=pShipheadid) ) GROUP BY cohead_id, coitem_id, cust_partialship, coitem_taxtype_id, coitem_qtyord, coitem_qtyshipped, coitem_qtyreturned, coitem_price, invpricerat, coitem_qty_invuomratio, item_id UNION SELECT cohead_id, coitem_id, coitem_qtyord AS qty, coitem_price, coitem_price_invuomratio AS invpricerat, coitem_qty_invuomratio, item_id, true AS toclose, coitem_taxtype_id FROM shiphead, cohead, custinfo, itemsite, item, coitem AS kit WHERE((shiphead_order_id=cohead_id) AND (coitem_cohead_id=cohead_id) AND (coitem_status='O') AND (shiphead_shipped) AND (coitem_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (cohead_cust_id=cust_id) AND (item_type = 'K') AND (cohead_id=_coheadid) AND (shiphead_id=pShipheadid) AND (coitem_linenumber NOT IN (SELECT sub.coitem_linenumber FROM coitem AS sub WHERE sub.coitem_cohead_id=cohead_id -- cohead for kit AND sub.coitem_linenumber=kit.coitem_linenumber AND sub.coitem_subnumber > 0 AND ((sub.coitem_qtyord - sub.coitem_qtyshipped + sub.coitem_qtyreturned) > 0) LIMIT 1) )) GROUP BY cohead_id, coitem_id, cust_partialship, coitem_taxtype_id, coitem_qtyord, coitem_qtyshipped, coitem_qtyreturned, coitem_price, invpricerat, coitem_qty_invuomratio, item_id, coitem_linenumber LOOP SELECT cobill_id INTO _cobillid FROM cobill, cobmisc, coitem WHERE ((cobill_cobmisc_id=cobmisc_id) AND (cobmisc_cohead_id=coitem_cohead_id) AND (cobill_coitem_id=coitem_id) AND (NOT cobmisc_posted) AND (cobill_cobmisc_id=_cobmiscid) AND (coitem_id=_r.coitem_id)) LIMIT 1; IF (FOUND) THEN UPDATE cobill SET cobill_selectdate = CURRENT_DATE, cobill_select_username = getEffectiveXtUser(), cobill_qty = cobill_qty + _r.qty, cobill_toclose = _r.toclose, cobill_taxtype_id = _r.coitem_taxtype_id WHERE (cobill_id=_cobillid); ELSE -- Now insert the cobill line INSERT INTO cobill ( cobill_cobmisc_id, cobill_coitem_id, cobill_selectdate, cobill_select_username, cobill_qty, cobill_toclose, cobill_taxtype_id ) VALUES ( _cobmiscid, _r.coitem_id, CURRENT_DATE, getEffectiveXtUser(), _r.qty, _r.toclose, _r.coitem_taxtype_id ); END IF; END LOOP; RETURN _cobmiscid; END; $_$; 8DROP FUNCTION public.selectuninvoicedshipment(integer); publicadminfalse46238 125579356"selectuninvoicedshipments(integer)FUNCTIONCREATE FUNCTION selectuninvoicedshipments(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; _r RECORD; _recordCounter INTEGER := 0; BEGIN -- Grab all of the uninvoiced shipitem records FOR _r IN SELECT DISTINCT shiphead_id FROM shiphead, shipitem, coitem, itemsite WHERE ( (shiphead_order_type='SO') AND (shipitem_shiphead_id=shiphead_id) AND (shipitem_orderitem_id=coitem_id) AND (coitem_itemsite_id=itemsite_id) AND (coitem_status <> 'C') AND ( (pWarehousid = -1) OR (itemsite_warehous_id=pWarehousid) ) AND (shiphead_shipped) AND (NOT shipitem_invoiced) AND (coitem_id NOT IN ( SELECT cobill_coitem_id FROM cobmisc, cobill WHERE ((cobill_cobmisc_id=cobmisc_id) AND (NOT cobmisc_posted) ) ) ) ) LOOP PERFORM selectUninvoicedShipment(_r.shiphead_id); _recordCounter := _recordCounter + 1; END LOOP; RETURN _recordCounter; END; $_$; 9DROP FUNCTION public.selectuninvoicedshipments(integer); publicadminfalse84623 125579357(selectuninvoicedshipments(integer, text)FUNCTIONCREATE FUNCTION selectuninvoicedshipments(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pCusttype ALIAS FOR $2; _r RECORD; _recordCounter INTEGER := 0; BEGIN -- Grab all of the uninvoiced shipitem records FOR _r IN SELECT DISTINCT shiphead_id FROM shiphead, shipitem, coitem, itemsite, cohead, custinfo, custtype WHERE ( (shiphead_order_type='SO') AND (shipitem_shiphead_id=shiphead_id) AND (shipitem_orderitem_id=coitem_id) AND (coitem_itemsite_id=itemsite_id) AND (coitem_status <> 'C') AND (coitem_cohead_id=cohead_id) AND (cohead_cust_id=cust_id) AND (cust_custtype_id=custtype_id) AND ( (pWarehousid = -1) OR (itemsite_warehous_id=pWarehousid) ) AND (custtype_code ~ pCusttype) AND (shiphead_shipped) AND (NOT shipitem_invoiced) AND (coitem_id NOT IN ( SELECT cobill_coitem_id FROM cobmisc, cobill WHERE ((cobill_cobmisc_id=cobmisc_id) AND (NOT cobmisc_posted) ) ) ) ) LOOP PERFORM selectUninvoicedShipment(_r.shiphead_id); _recordCounter := _recordCounter + 1; END LOOP; RETURN _recordCounter; END; $_$; ?DROP FUNCTION public.selectuninvoicedshipments(integer, text); publicadminfalse46238 125579358+selectuninvoicedshipments(integer, integer)FUNCTIONCREATE FUNCTION selectuninvoicedshipments(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWarehousid ALIAS FOR $1; pCusttypeid ALIAS FOR $2; _r RECORD; _recordCounter INTEGER := 0; BEGIN -- Grab all of the uninvoiced shipitem records FOR _r IN SELECT DISTINCT shiphead_id FROM shiphead, shipitem, coitem, itemsite, cohead, custinfo WHERE ( (shiphead_order_type='SO') AND (shipitem_shiphead_id=shiphead_id) AND (shipitem_orderitem_id=coitem_id) AND (coitem_itemsite_id=itemsite_id) AND (coitem_status <> 'C') AND (coitem_cohead_id=cohead_id) AND (cohead_cust_id=cust_id) AND (cust_custtype_id=pCusttypeid) AND ( (pWarehousid = -1) OR (itemsite_warehous_id=pWarehousid) ) AND (shiphead_shipped) AND (NOT shipitem_invoiced) AND (coitem_id NOT IN ( SELECT cobill_coitem_id FROM cobmisc, cobill WHERE ((cobill_cobmisc_id=cobmisc_id) AND (NOT cobmisc_posted) ) ) ) ) LOOP PERFORM selectUninvoicedShipment(_r.shiphead_id); _recordCounter := _recordCounter + 1; END LOOP; RETURN _recordCounter; END; $_$; BDROP FUNCTION public.selectuninvoicedshipments(integer, integer); publicadminfalse46238 125579359setapjournalnumber()FUNCTIONCREATE FUNCTION setapjournalnumber() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _journalNumber INTEGER; _r RECORD; BEGIN -- Fetch the next Journal Number SELECT fetchJournalNumber('A/P') INTO _journalNumber; -- Walk through all of the A/P Open Items FOR _r IN SELECT apopen_id, apopen_docnumber FROM apopen WHERE (NOT apopen_posted) LOOP -- Set the Journal Number for all of the G/L Transactions -- for the A/P Open Item UPDATE gltrans SET gltrans_journalnumber=_journalNumber WHERE ( (gltrans_source='P/O') AND (gltrans_doctype IN ('VO')) AND (gltrans_docnumber=_r.apopen_docnumber) AND (NOT gltrans_exported) ); -- Set the Journal Number for the A/P Open Item UPDATE apopen SET apopen_journalnumber=_journalNumber WHERE (apopen_id=_r.apopen_id); END LOOP; RETURN _journalNumber; END; $$; +DROP FUNCTION public.setapjournalnumber(); publicadminfalse46238125579360setarjournalnumber()FUNCTIONCREATE FUNCTION setarjournalnumber() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _journalNumber INTEGER; _r RECORD; BEGIN -- Fetch the next Journal Number SELECT fetchJournalNumber('A/R') INTO _journalNumber; -- Walk through all of the A/R Open Items FOR _r IN SELECT aropen_id, aropen_docnumber FROM aropen WHERE (NOT aropen_posted) LOOP -- Set the Journal Number for all of the G/L Transactions -- for the A/R Open Item UPDATE gltrans SET gltrans_journalnumber=_journalNumber WHERE ( (gltrans_source='S/O') AND (gltrans_doctype IN ('CM', 'IN')) AND (gltrans_docnumber=_r.aropen_docnumber) AND (NOT gltrans_exported) ); -- Set the Journal Number for the A/R Open Item UPDATE aropen SET aropen_journalnumber=_journalNumber WHERE (aropen_id=_r.aropen_id); END LOOP; RETURN _journalNumber; END; $$; +DROP FUNCTION public.setarjournalnumber(); publicadminfalse84623125579361$setbudget(integer, integer, numeric)FUNCTION~CREATE FUNCTION setbudget(integer, integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodid ALIAS FOR $1; pAccntid ALIAS FOR $2; pAmount ALIAS FOR $3; BEGIN RETURN setBudget(1, pPeriodid, pAccntid, pAmount); END; $_$; ;DROP FUNCTION public.setbudget(integer, integer, numeric); publicadminfalse84623125579362-setbudget(integer, integer, integer, numeric)FUNCTIONCREATE FUNCTION setbudget(integer, integer, integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBudgheadid ALIAS FOR $1; pPeriodid ALIAS FOR $2; pAccntid ALIAS FOR $3; pAmount ALIAS FOR $4; _budgetid INTEGER; BEGIN SELECT budgitem_id INTO _budgetid FROM budgitem WHERE ((budgitem_period_id=pPeriodid) AND (budgitem_budghead_id=pBudgheadid) AND (budgitem_accnt_id=pAccntid)); IF (FOUND) THEN UPDATE budgitem SET budgitem_amount = pAmount WHERE (budgitem_id=_budgetid); ELSE SELECT nextval('budgitem_budgitem_id_seq') INTO _budgetid; INSERT INTO budgitem (budgitem_id, budgitem_budghead_id, budgitem_period_id, budgitem_accnt_id, budgitem_amount) VALUES(_budgetid, pBudgheadid, pPeriodid, pAccntid, pAmount); END IF; RETURN _budgetid; END; $_$; DDROP FUNCTION public.setbudget(integer, integer, integer, numeric); publicadminfalse46238125579363setbytea(text)FUNCTIONQCREATE FUNCTION setbytea(text) RETURNS bytea LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pMetricName ALIAS FOR $1; _value bytea; BEGIN _value := decode(pMetricName, 'escape'); RETURN _value; END; $_$; %DROP FUNCTION public.setbytea(text); publicadminfalse84623125579364setbytea(bytea)FUNCTION@CREATE FUNCTION setbytea(bytea) RETURNS bytea LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pMetricName ALIAS FOR $1; _value bytea; BEGIN _value := pMetricName; RETURN _value; END; $_$; &DROP FUNCTION public.setbytea(bytea); publicadminfalse46238125579365setccbankaccnt(text, integer)FUNCTION2CREATE FUNCTION setccbankaccnt(text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pccardtype ALIAS FOR $1; pbankaccntid ALIAS FOR $2; _ccbankid INTEGER; _numfound INTEGER; BEGIN RAISE DEBUG 'setCCBankAccount(%, %) entered', pccardtype, pbankaccntid; UPDATE ccbank SET ccbank_bankaccnt_id=pbankaccntid WHERE ccbank_ccard_type=pccardtype RETURNING ccbank_id INTO _ccbankid; GET DIAGNOSTICS _numfound = ROW_COUNT; IF (_numfound <= 0) THEN INSERT INTO ccbank (ccbank_ccard_type, ccbank_bankaccnt_id) VALUES (pccardtype, pbankaccntid) RETURNING ccbank_id INTO _ccbankid; END IF; RETURN _ccbankid; END; $_$; 4DROP FUNCTION public.setccbankaccnt(text, integer); publicadminfalse46238125579366seteffectivextuser(text)FUNCTIONzCREATE FUNCTION seteffectivextuser(text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; BEGIN PERFORM initEffectiveXtUser(); PERFORM * FROM effective_user WHERE effective_key = 'username'; IF FOUND THEN UPDATE effective_user SET effective_value = pUsername WHERE effective_key = 'username'; ELSE INSERT INTO effective_user (effective_key, effective_value) VALUES('username', pUsername); END IF; RETURN true; END; $_$; /DROP FUNCTION public.seteffectivextuser(text); publicadminfalse84623125579367setgljournalnumber(date, date)FUNCTIONCREATE FUNCTION setgljournalnumber(date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pStartDate ALIAS FOR $1; pEndDate ALIAS FOR $2; _journalNumber INTEGER; BEGIN -- Fetch the next Journal Number SELECT fetchJournalNumber('G/L') INTO _journalNumber; -- Set the Journal Number for all of the unposted G/L Transactions -- in the passed date range. UPDATE gltrans SET gltrans_journalnumber=_journalNumber WHERE ( (NOT gltrans_exported) AND (gltrans_date BETWEEN pStartDate and pEndDate) ); RETURN _journalNumber; END; $_$; 5DROP FUNCTION public.setgljournalnumber(date, date); publicadminfalse46238125579368setmetric(text, text)FUNCTION{CREATE FUNCTION setmetric(text, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pMetricName ALIAS FOR $1; pMetricValue ALIAS FOR $2; _metricid INTEGER; BEGIN SELECT metric_id INTO _metricid FROM metric WHERE (metric_name=pMetricName); IF (FOUND) THEN UPDATE metric SET metric_value=pMetricValue WHERE (metric_id=_metricid); ELSE INSERT INTO metric (metric_name, metric_value) VALUES (pMetricName, pMetricValue); END IF; RETURN TRUE; END; $_$; ,DROP FUNCTION public.setmetric(text, text); publicadminfalse84623125579369setmetricenc(text, text, text)FUNCTIONICREATE FUNCTION setmetricenc(text, text, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pMetricName ALIAS FOR $1; pMetricValue ALIAS FOR $2; pMetricEnc ALIAS FOR $3; _metricid INTEGER; _value bytea; _key bytea; BEGIN _value = decode(pMetricValue, 'escape'); _key = decode(pMetricEnc, 'escape'); SELECT metricenc_id INTO _metricid FROM metricenc WHERE (metricenc_name=pMetricName); IF (FOUND) THEN UPDATE metricenc SET metricenc_value=encrypt(_value, _key, 'bf') WHERE (metricenc_id=_metricid); ELSE INSERT INTO metricenc (metricenc_name, metricenc_value) VALUES (pMetricName, encrypt(_value, _key, 'bf')); END IF; RETURN TRUE; END; $_$; 5DROP FUNCTION public.setmetricenc(text, text, text); publicadminfalse46238125579370setnextapmemonumber(integer)FUNCTIONwCREATE FUNCTION setnextapmemonumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='APMemoNumber'); IF (FOUND) THEN UPDATE orderseq SET orderseq_number=pNumber WHERE (orderseq_id=_orderseqid); ELSE INSERT INTO orderseq (orderseq_name, orderseq_number) VALUES ('APMemoNumber', pNumber); END IF; RETURN 1; END; $_$; 3DROP FUNCTION public.setnextapmemonumber(integer); publicadminfalse46238125579371setnextarmemonumber(integer)FUNCTIONwCREATE FUNCTION setnextarmemonumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='ARMemoNumber'); IF (FOUND) THEN UPDATE orderseq SET orderseq_number=pNumber WHERE (orderseq_id=_orderseqid); ELSE INSERT INTO orderseq (orderseq_name, orderseq_number) VALUES ('ARMemoNumber', pNumber); END IF; RETURN 1; END; $_$; 3DROP FUNCTION public.setnextarmemonumber(integer); publicadminfalse84623125579372setnextcashrcptnumber(integer)FUNCTION}CREATE FUNCTION setnextcashrcptnumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='CashRcptNumber'); IF (FOUND) THEN UPDATE orderseq SET orderseq_number=pNumber WHERE (orderseq_id=_orderseqid); ELSE INSERT INTO orderseq (orderseq_name, orderseq_number) VALUES ('CashRcptNumber', pNumber); END IF; RETURN 1; END; $_$; 5DROP FUNCTION public.setnextcashrcptnumber(integer); publicadminfalse84623125579373$setnextchecknumber(integer, integer)FUNCTIONCREATE FUNCTION setnextchecknumber(pbankaccntid integer, pnextchecknumber integer) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _nextChkNumber INTEGER; _checkheadid INTEGER; BEGIN _nextChkNumber := pNextCheckNumber; WHILE (TRUE) LOOP SELECT checkhead_id INTO _checkheadid FROM checkhead WHERE (checkhead_number=_nextChkNumber) AND (checkhead_bankaccnt_id=pBankaccntid); IF (NOT FOUND) THEN EXIT; ELSE _nextChkNumber := _nextChkNumber + 1; END IF; END LOOP; UPDATE bankaccnt SET bankaccnt_nextchknum=_nextChkNumber WHERE (bankaccnt_id=pBankaccntid); RETURN TRUE; END; $$; YDROP FUNCTION public.setnextchecknumber(pbankaccntid integer, pnextchecknumber integer); publicadminfalse46238125579374setnextcmnumber(integer)FUNCTIONCREATE FUNCTION setnextcmnumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='CmNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'CmNumber', pNumber); ELSE UPDATE orderseq SET orderseq_number=pNumber WHERE (orderseq_name='CmNumber'); END IF; RETURN _orderseqid; END; $_$; /DROP FUNCTION public.setnextcmnumber(integer); publicadminfalse46238125579375 setnextcrmaccountnumber(integer)FUNCTIONCREATE FUNCTION setnextcrmaccountnumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='CRMAccountNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'CRMAccountNumber', pNumber); ELSE UPDATE orderseq SET orderseq_number=pNumber WHERE (orderseq_name='CRMAccountNumber'); END IF; RETURN _orderseqid; END; $_$; 7DROP FUNCTION public.setnextcrmaccountnumber(integer); publicadminfalse84623125579376setnextincidentnumber(integer)FUNCTIONCREATE FUNCTION setnextincidentnumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='IncidentNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'IncidentNumber', pNumber); ELSE UPDATE orderseq SET orderseq_number=pNumber WHERE (orderseq_name='IncidentNumber'); END IF; RETURN _orderseqid; END; $_$; 5DROP FUNCTION public.setnextincidentnumber(integer); publicadminfalse46238125579377setnextinvcnumber(integer)FUNCTIONCREATE FUNCTION setnextinvcnumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='InvcNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'InvcNumber', pNumber); ELSE UPDATE orderseq SET orderseq_number=pNumber WHERE (orderseq_name='InvcNumber'); END IF; RETURN _orderseqid; END; $_$; 1DROP FUNCTION public.setnextinvcnumber(integer); publicadminfalse46238125579378setnextnumber(text, integer)FUNCTION CREATE FUNCTION setnextnumber(text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE psequence ALIAS FOR $1; pnumber ALIAS FOR $2; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name=psequence); IF (NOT FOUND) THEN INSERT INTO orderseq (orderseq_name, orderseq_number, orderseq_table, orderseq_numcol) VALUES (psequence, pnumber, CASE WHEN (psequence='APMemoNumber') THEN 'apopen' WHEN (psequence='ARMemoNumber') THEN 'aropen' WHEN (psequence='CmNumber') THEN 'cmhead' WHEN (psequence='IncidentNumber') THEN 'incdt' WHEN (psequence='InvcNumber') THEN 'invchead' WHEN (psequence='JournalNumber') THEN 'gltrans' WHEN (psequence='PlanNumber') THEN 'planord' WHEN (psequence='PoNumber') THEN 'pohead' WHEN (psequence='PrNumber') THEN 'pr' WHEN (psequence='QuNumber') THEN 'quhead' WHEN (psequence='ShipmentNumber') THEN 'shiphead' WHEN (psequence='SoNumber') THEN 'cohead' WHEN (psequence='ToNumber') THEN 'tohead' WHEN (psequence='VcNumber') THEN 'vohead' WHEN (psequence='WoNumber') THEN 'wo' ELSE '' END, CASE WHEN (psequence='APMemoNumber') THEN 'apopen_docnumber' WHEN (psequence='ARMemoNumber') THEN 'aropen_docnumber' WHEN (psequence='CmNumber') THEN 'cmhead_number' WHEN (psequence='IncidentNumber') THEN 'incdt_number' WHEN (psequence='InvcNumber') THEN 'invchead_invcnumber' WHEN (psequence='JournalNumber') THEN 'gltrans_journalnumber' WHEN (psequence='PlanNumber') THEN 'planord_number' WHEN (psequence='PoNumber') THEN 'pohead_number' WHEN (psequence='PrNumber') THEN 'pr_number' WHEN (psequence='QuNumber') THEN 'quhead_number' WHEN (psequence='ShipmentNumber') THEN 'shiphead_number' WHEN (psequence='SoNumber') THEN 'cohead_number' WHEN (psequence='ToNumber') THEN 'tohead_number' WHEN (psequence='VcNumber') THEN 'vohead_number' WHEN (psequence='WoNumber') THEN 'wo_number' ELSE '' END ); ELSE UPDATE orderseq SET orderseq_number=pnumber WHERE (orderseq_name=psequence); END IF; RETURN 0; END; $_$; 3DROP FUNCTION public.setnextnumber(text, integer); publicadminfalse84623 125579379setnextponumber(integer)FUNCTIONCREATE FUNCTION setnextponumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='PoNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'PoNumber', pNumber); ELSE UPDATE orderseq SET orderseq_number=pNumber WHERE (orderseq_name='PoNumber'); END IF; RETURN _orderseqid; END; $_$; /DROP FUNCTION public.setnextponumber(integer); publicadminfalse84623!125579380setnextprnumber(integer)FUNCTIONCREATE FUNCTION setnextprnumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='PrNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'PrNumber', pNumber); ELSE UPDATE orderseq SET orderseq_number=pNumber WHERE (orderseq_name='PrNumber'); END IF; RETURN _orderseqid; END; $_$; /DROP FUNCTION public.setnextprnumber(integer); publicadminfalse84623"125579381setnextqunumber(integer)FUNCTIONCREATE FUNCTION setnextqunumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pQuNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='QuNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'QuNumber', pQuNumber); ELSE UPDATE orderseq SET orderseq_number=pQuNumber WHERE (orderseq_name='QuNumber'); END IF; RETURN _orderseqid; END; $_$; /DROP FUNCTION public.setnextqunumber(integer); publicadminfalse84623#125579382setnextshipmentnumber(integer)FUNCTIONCREATE FUNCTION setnextshipmentnumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pShipmentNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='ShipmentNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'ShipmentNumber', pShipmentNumber); ELSE UPDATE orderseq SET orderseq_number=pShipmentNumber WHERE (orderseq_name='ShipmentNumber'); END IF; RETURN _orderseqid; END; $_$; 5DROP FUNCTION public.setnextshipmentnumber(integer); publicadminfalse46238$125579383setnextsonumber(integer)FUNCTIONCREATE FUNCTION setnextsonumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSoNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='SoNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'SoNumber', pSoNumber); ELSE UPDATE orderseq SET orderseq_number=pSoNumber WHERE (orderseq_name='SoNumber'); END IF; RETURN _orderseqid; END; $_$; /DROP FUNCTION public.setnextsonumber(integer); publicadminfalse46238%125579384setnextvcnumber(integer)FUNCTIONCREATE FUNCTION setnextvcnumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='VcNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'VcNumber', pNumber); ELSE UPDATE orderseq SET orderseq_number=pNumber WHERE (orderseq_name='VcNumber'); END IF; RETURN _orderseqid; END; $_$; /DROP FUNCTION public.setnextvcnumber(integer); publicadminfalse46238&125579385setnextwonumber(integer)FUNCTIONCREATE FUNCTION setnextwonumber(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pWoNumber ALIAS FOR $1; _orderseqid INTEGER; BEGIN SELECT orderseq_id INTO _orderseqid FROM orderseq WHERE (orderseq_name='WoNumber'); IF (NOT FOUND) THEN SELECT NEXTVAL('orderseq_orderseq_id_seq') INTO _orderseqid; INSERT INTO orderseq (orderseq_id, orderseq_name, orderseq_number) VALUES (_orderseqid, 'WoNumber', pWoNumber); ELSE UPDATE orderseq SET orderseq_number=pWoNumber WHERE (orderseq_name='WoNumber'); END IF; RETURN _orderseqid; END; $_$; /DROP FUNCTION public.setnextwonumber(integer); publicadminfalse84623'125587094$setusercancreateusers(text, boolean)FUNCTIONCREATE FUNCTION setusercancreateusers(pusername text, pcreateuser boolean) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF (pCreateUser) THEN EXECUTE 'ALTER USER "' || pUsername || '" CREATEROLE;'; ELSE EXECUTE 'ALTER USER "' || pUsername || '" NOCREATEROLE;'; END IF; RETURN TRUE; END; $$; QDROP FUNCTION public.setusercancreateusers(pusername text, pcreateuser boolean); publicadminfalse46238(125579387setuserpreference(text, text)FUNCTIONvCREATE FUNCTION setuserpreference(text, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPrefName ALIAS FOR $1; pPrefValue ALIAS FOR $2; BEGIN RETURN setUserPreferences(getEffectiveXtUser(), pPrefName, pPrefValue); END; $_$; 4DROP FUNCTION public.setuserpreference(text, text); publicadminfalse84623*125579388#setuserpreference(text, text, text)FUNCTIONCREATE FUNCTION setuserpreference(text, text, text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; pPrefName ALIAS FOR $2; pPrefValue ALIAS FOR $3; _usrprefid INTEGER; BEGIN SELECT usrpref_id INTO _usrprefid FROM usrpref WHERE ( (usrpref_username=pUsername) AND (usrpref_name=pPrefName) ); IF (FOUND) THEN UPDATE usrpref SET usrpref_value=pPrefValue WHERE (usrpref_id=_usrprefid); ELSE INSERT INTO usrpref (usrpref_username, usrpref_name, usrpref_value) VALUES (pUsername, pPrefName, pPrefValue); END IF; RETURN TRUE; END; $_$; :DROP FUNCTION public.setuserpreference(text, text, text); publicadminfalse84623+125579389shipments(text)FUNCTIONrCREATE FUNCTION shipments(text) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTransType ALIAS FOR $1; BEGIN IF (pTransType IN ('SC', 'SV', 'SH', 'RS', 'TS')) THEN RETURN TRUE; ELSE RETURN FALSE; END IF; END; $_$; &DROP FUNCTION public.shipments(text); publicadminfalse46238125579390shipshipment(integer)FUNCTIONCREATE FUNCTION shipshipment(integer) RETURNS integer LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT shipShipment($1, CURRENT_TIMESTAMP); $_$; ,DROP FUNCTION public.shipshipment(integer); publicadminfalse8,125579391/shipshipment(integer, timestamp with time zone)FUNCTION6CREATE FUNCTION shipshipment(integer, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pshipheadid ALIAS FOR $1; _timestamp TIMESTAMP WITH TIME ZONE := $2; _billedQty NUMERIC; _c RECORD; _coholdtype TEXT; _gldate DATE; _invhistid INTEGER; _itemlocSeries INTEGER; _lineitemsToClose INTEGER[]; _newQty NUMERIC; _result INTEGER; _s RECORD; _shipcomplete BOOLEAN; _shiphead RECORD; _ti RECORD; _to RECORD; _variance NUMERIC; _k RECORD; BEGIN IF (_timestamp IS NULL) THEN _timestamp := CURRENT_TIMESTAMP; END IF; _gldate := _timestamp::DATE; SELECT * INTO _shiphead FROM shiphead WHERE (shiphead_id=pshipheadid); IF (NOT FOUND) THEN RETURN -50; END IF; IF (_shiphead.shiphead_order_type = 'SO') THEN SELECT cohead_shipcomplete, cohead_holdtype INTO _shipcomplete, _coholdtype FROM cohead, shiphead WHERE ((shiphead_order_id=cohead_id) AND (NOT shiphead_shipped) AND (shiphead_order_type=_shiphead.shiphead_order_type) AND (shiphead_id=pshipheadid)); IF (_coholdtype = 'C') THEN RETURN -12; ELSIF (_coholdtype = 'P') THEN RETURN -13; ELSIF (_coholdtype = 'R') THEN RETURN -14; ELSIF (_coholdtype = 'S') THEN RETURN -15; END IF; ---Must Ship Kit components (coitem_subnumber <> 0 complete--------------- IF (( -- Test to see if order's customer accepts backorders and partials -- If not then test for shipping kit components complete SELECT cohead_number FROM shiphead, cohead, custinfo WHERE (shiphead_order_id = cohead_id) AND (cohead_cust_id = cust_id) AND (shiphead_order_type = 'SO') AND (cust_partialship) AND (cust_backorder) AND (shiphead_id = pshipheadid) ) IS NULL) THEN FOR _k IN SELECT (coitem_qtyord - (COALESCE(SUM(shipitem_qty),0) + (coitem_qtyshipped - coitem_qtyreturned))) AS remain FROM (coitem LEFT OUTER JOIN (itemsite JOIN item ON (itemsite_item_id=item_id)) ON (coitem_itemsite_id=itemsite_id)) LEFT OUTER JOIN shipitem ON (shipitem_orderitem_id=coitem_id AND shipitem_shiphead_id=pshipheadid) WHERE ((coitem_status NOT IN ('C','X')) AND (item_type != 'K') AND (coitem_cohead_id=_shiphead.shiphead_order_id) AND (coitem_subnumber <> 0) ) GROUP BY coitem_id, coitem_qtyshipped, coitem_qtyord, coitem_qtyreturned LOOP IF (_k.remain > 0) THEN RAISE EXCEPTION 'Kit component item not shipped complete. Kits must be shipped and shipped complete or closed on the order.'; END IF; END LOOP; END IF; ---End-------------------------------------------------------------------- IF ( _shipcomplete ) THEN FOR _c IN SELECT (coitem_qtyord - (COALESCE(SUM(shipitem_qty),0) + (coitem_qtyshipped - coitem_qtyreturned))) AS remain FROM (coitem LEFT OUTER JOIN (itemsite JOIN item ON (itemsite_item_id=item_id)) ON (coitem_itemsite_id=itemsite_id)) LEFT OUTER JOIN shipitem ON (shipitem_orderitem_id=coitem_id AND shipitem_shiphead_id=pshipheadid) WHERE ((coitem_status<>'X') AND (item_type != 'K') AND (coitem_cohead_id=_shiphead.shiphead_order_id)) GROUP BY coitem_id, coitem_qtyshipped, coitem_qtyord, coitem_qtyreturned LOOP IF (_c.remain > 0) THEN RETURN -99; END IF; END LOOP; END IF; FOR _c IN SELECT coitem_id, cohead_number, cohead_cust_id, cohead_billtoname, cohead_prj_id, cohead_saletype_id, cohead_shipzone_id, itemsite_id, itemsite_item_id, coitem_qty_invuomratio, coitem_warranty, coitem_cos_accnt_id, SUM(shipitem_qty) AS _qty, SUM(shipitem_value) AS _value FROM coitem, cohead, shiphead, shipitem, itemsite WHERE ( (coitem_cohead_id=cohead_id) AND (coitem_itemsite_id=itemsite_id) AND (shiphead_order_id=cohead_id) AND (shipitem_shiphead_id=shiphead_id) AND (shipitem_orderitem_id=coitem_id) AND (NOT shiphead_shipped) AND (shiphead_id=pshipheadid) ) GROUP BY coitem_id, coitem_qty_invuomratio, cohead_number, cohead_cust_id, cohead_billtoname, itemsite_id, itemsite_item_id, coitem_warranty, coitem_cos_accnt_id, cohead_prj_id, cohead_saletype_id, cohead_shipzone_id LOOP IF _c._value > 0 THEN -- Distribute to G/L, credit Shipping Asset, debit COS SELECT MIN(insertGLTransaction( 'S/R', 'SH', _shiphead.shiphead_number, ('Ship Order ' || _c.cohead_number || ' for Customer ' || _c.cohead_billtoname), getPrjAccntId(_c.cohead_prj_id, costcat_shipasset_accnt_id), CASE WHEN (COALESCE(_c.coitem_cos_accnt_id, -1) != -1) THEN getPrjAccntId(_c.cohead_prj_id, _c.coitem_cos_accnt_id) WHEN (_c.coitem_warranty=TRUE) THEN getPrjAccntId(_c.cohead_prj_id, resolveCOWAccount(itemsite_id, _c.cohead_cust_id, _c.cohead_saletype_id, _c.cohead_shipzone_id)) ELSE getPrjAccntId(_c.cohead_prj_id, resolveCOSAccount(itemsite_id, _c.cohead_cust_id, _c.cohead_saletype_id, _c.cohead_shipzone_id)) END, -1, _c._value, _gldate )) INTO _result FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_c.itemsite_id) ); IF (_result < 0 AND _result != -3) THEN -- ignore -3 as it just means it's not posting a 0 value RETURN _result; END IF; END IF; UPDATE coitem SET coitem_qtyshipped = (coitem_qtyshipped + _c._qty) WHERE (coitem_id=_c.coitem_id); -- check to see if we have more invoiced than shipped items -- if we do we will need to mark some of these records as invoiced SELECT noNeg(( SELECT COALESCE(SUM(cobill_qty), 0.0) FROM cobill, cobmisc, coitem WHERE ( (cobill_cobmisc_id=cobmisc_id) AND (cobmisc_cohead_id=coitem_cohead_id) AND (cobill_coitem_id=coitem_id) AND (cobmisc_posted) AND (coitem_id=_c.coitem_id) ) ) - ( SELECT COALESCE(SUM(shipitem_qty), 0.0) FROM shipitem, shiphead, coitem WHERE ( (shipitem_shiphead_id=shiphead_id) AND (shiphead_order_id=coitem_cohead_id) AND (shipitem_orderitem_id=coitem_id) AND (shiphead_order_type=_shiphead.shiphead_order_type) AND (shiphead_shipped) AND (coitem_id=_c.coitem_id) ) ) ) INTO _billedQty; IF (_billedQty > 0.0) THEN FOR _s IN SELECT shipitem_id, shipitem_qty FROM shipitem, shiphead WHERE ( (shipitem_shiphead_id=shiphead_id) AND (shipitem_orderitem_id=_c.coitem_id) AND (shiphead_order_type=_shiphead.shiphead_order_type) AND (NOT shiphead_shipped) AND (shiphead_id=pshipheadid) ) ORDER BY shipitem_qty LOOP IF (_billedQty > 0.0) THEN IF (_billedQty >= _s.shipitem_qty) THEN UPDATE shipitem SET shipitem_invoiced=TRUE WHERE shipitem_id=_s.shipitem_id; -- must wait to close coitems until after shiphead_shipped -> true _lineitemsToClose := _lineitemsToClose || _c.coitem_id; ELSE _newQty := _s.shipitem_qty - _billedQty; UPDATE shipitem SET shipitem_invoiced=TRUE, shipitem_qty=_billedQty WHERE shipitem_id=_s.shipitem_id; INSERT INTO shipitem ( shipitem_orderitem_id, shipitem_shipdate, shipitem_qty, shipitem_transdate, shipitem_invoiced, shipitem_shiphead_id, shipitem_trans_username) SELECT shipitem_orderitem_id, shipitem_shipdate, _newQty, shipitem_transdate, FALSE, shipitem_shiphead_id, shipitem_trans_username FROM shipitem WHERE (shipitem_id=_s.shipitem_id); END IF; _billedQty := _billedQty - _s.shipitem_qty; END IF; END LOOP; END IF; END LOOP; ELSEIF (_shiphead.shiphead_order_type = 'TO') THEN IF (_shiphead.shiphead_shipped) THEN RETURN -8; END IF; SELECT tohead.* INTO _to FROM tohead WHERE (tohead_id=_shiphead.shiphead_order_id); IF ( _to.tohead_shipcomplete ) THEN -- use sufficientInventory...()? FOR _ti IN SELECT (toitem_qty_ordered - (COALESCE(SUM(shipitem_qty),0) + toitem_qty_shipped)) AS remain FROM toitem LEFT OUTER JOIN shipitem ON (shipitem_orderitem_id=toitem_id) WHERE ((toitem_status<>'X') AND (toitem_tohead_id=_shiphead.shiphead_order_id)) GROUP BY toitem_qty_shipped, toitem_qty_ordered LOOP IF (_ti.remain > 0) THEN RETURN -99; END IF; END LOOP; END IF; FOR _ti IN SELECT toitem_id, toitem_item_id, SUM(shipitem_qty) AS qty, SUM(shipitem_value) AS value FROM toitem, shipitem WHERE ((toitem_tohead_id=_to.tohead_id) AND (shipitem_orderitem_id=toitem_id) AND (shipitem_shiphead_id=pshipheadid)) GROUP BY toitem_id, toitem_item_id LOOP IF (NOT EXISTS(SELECT itemsite_id FROM itemsite WHERE ((itemsite_item_id=_ti.toitem_item_id) AND (itemsite_warehous_id = _to.tohead_trns_warehous_id)) )) THEN RETURN -6; END IF; _itemlocSeries := NEXTVAL('itemloc_series_seq'); SELECT postInvTrans(si.itemsite_id, 'TS', _ti.qty, 'I/M', _shiphead.shiphead_order_type, formatToNumber(_ti.toitem_id), _to.tohead_number, 'Ship from Src to Transit Warehouse', tc.costcat_asset_accnt_id, sc.costcat_shipasset_accnt_id, _itemlocSeries, _timestamp, _ti.value) INTO _invhistid FROM itemsite AS ti, costcat AS tc, itemsite AS si, costcat AS sc WHERE ( (ti.itemsite_costcat_id=tc.costcat_id) AND (si.itemsite_costcat_id=sc.costcat_id) AND (ti.itemsite_item_id=_ti.toitem_item_id) AND (si.itemsite_item_id=_ti.toitem_item_id) AND (ti.itemsite_warehous_id=_to.tohead_trns_warehous_id) AND (si.itemsite_warehous_id=_to.tohead_src_warehous_id) ); --We do not need to distribute lot/serial info for transit, post trans and discard dist detail PERFORM postIntoTrialBalance(itemlocpost_glseq) FROM itemlocpost WHERE (itemlocpost_itemlocseries=_itemlocSeries); IF (_invhistid > 0) THEN PERFORM postInvHist(_invhistid); END IF; DELETE FROM itemlocdist WHERE (itemlocdist_series=_itemlocSeries); DELETE FROM itemlocpost WHERE (itemlocpost_itemlocSeries=_itemlocSeries); IF (_result < 0) THEN RETURN _result; END IF; -- record inventory history and qoh changes at transit warehouse but -- there is only one g/l account to touch SELECT postInvTrans(ti.itemsite_id, 'TR', _ti.qty, 'I/M', _shiphead.shiphead_order_type, formatToNumber(_ti.toitem_id), _to.tohead_number, 'Receive into Transit from Src Warehouse', tc.costcat_asset_accnt_id, tc.costcat_asset_accnt_id, _itemlocSeries, _timestamp, _ti.value) INTO _invhistid FROM itemsite AS ti, costcat AS tc WHERE ((ti.itemsite_costcat_id=tc.costcat_id) AND (ti.itemsite_item_id=_ti.toitem_item_id) AND (ti.itemsite_warehous_id=_to.tohead_trns_warehous_id)); --We do not need to distribute lot/serial info for transit, post trans and discard dist detail PERFORM postIntoTrialBalance(itemlocpost_glseq) FROM itemlocpost WHERE (itemlocpost_itemlocseries=_itemlocSeries); IF (_invhistid > 0) THEN PERFORM postInvHist(_invhistid); END IF; DELETE FROM itemlocdist WHERE (itemlocdist_series=_itemlocSeries); DELETE FROM itemlocpost WHERE (itemlocpost_itemlocSeries=_itemlocSeries); --See if there was a change in values during the transfer, if so record the variance SELECT (invhist_invqty * invhist_unitcost - _ti.value) INTO _variance FROM invhist WHERE (invhist_id=_invhistid); IF (_variance > 0) THEN PERFORM insertGLTransaction( 'S/R', _shiphead.shiphead_order_type, _to.tohead_number, 'Transfer Order - Transfer Variance', tc.costcat_invcost_accnt_id, tc.costcat_asset_accnt_id, _invhistid, _variance, CAST(_timestamp AS DATE) ) FROM itemsite AS ti, costcat AS tc WHERE ( (ti.itemsite_costcat_id=tc.costcat_id) AND (ti.itemsite_item_id=_ti.toitem_item_id) AND (ti.itemsite_warehous_id=_to.tohead_trns_warehous_id) ); END IF; IF (_result < 0) THEN RETURN _result; END IF; UPDATE shipitem SET shipitem_shipdate=_timestamp, shipitem_shipped=TRUE WHERE ((shipitem_orderitem_id=_ti.toitem_id) AND (shipitem_shiphead_id=pshipheadid)); UPDATE toitem SET toitem_qty_shipped = (toitem_qty_shipped + _ti.qty) WHERE (toitem_id=_ti.toitem_id); END LOOP; END IF; UPDATE shiphead SET shiphead_shipped=TRUE, shiphead_shipdate=_gldate WHERE (shiphead_id=pshipheadid); -- now try to close line items that are fully shipped and invoiced IF (_shiphead.shiphead_order_type = 'SO') THEN UPDATE coitem SET coitem_status='C' WHERE ((coitem_id = ANY (_lineitemsToClose)) AND (coitem_qtyshipped >= coitem_qtyord)); END IF; RETURN _itemlocSeries; END; $_$; FDROP FUNCTION public.shipshipment(integer, timestamp with time zone); publicadminfalse46238 125586818show_search_path()FUNCTION'CREATE FUNCTION show_search_path() RETURNS text LANGUAGE plpgsql AS $$ declare path text; rec record; begin -- This exists because show search_path command doesn't work in plv8 for rec in execute 'show search_path' loop return rec.search_path::text; end loop; end; $$; )DROP FUNCTION public.show_search_path(); publicadminfalse46238-125579393Asinglecharacteristicstostring(text, integer, text, text, integer)FUNCTIONCREATE FUNCTION singlecharacteristicstostring(text, integer, text, text, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTargetType ALIAS FOR $1; pTargetId ALIAS FOR $2; pValKeySep ALIAS FOR $3; pPairSep ALIAS FOR $4; pCharId ALIAS FOR $5; _string TEXT := ''; _extra BOOLEAN := false; _r RECORD; BEGIN FOR _r IN SELECT char_name, charass_value FROM charass, char WHERE ((charass_char_id=char_id) AND (charass_char_id=pCharId) AND (charass_target_type=pTargetType) AND (charass_target_id=pTargetId)) LOOP IF(_extra) THEN _string := _string || pPairSep; END IF; _extra := true; _string := _string || _r.char_name || pValKeySep || _r.charass_value; END LOOP; RETURN _string; END; $_$; XDROP FUNCTION public.singlecharacteristicstostring(text, integer, text, text, integer); publicadminfalse46238.1255870962singlelevelbom(integer, integer, integer, integer)FUNCTION%CREATE FUNCTION singlelevelbom(integer, integer, integer, integer) RETURNS SETOF bomdata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pRevisionid ALIAS FOR $2; pExpiredDays ALIAS FOR $3; pFutureDays ALIAS FOR $4; _row bomdata%ROWTYPE; _bomworksetid INTEGER; _x RECORD; _check CHAR(1); _inactive BOOLEAN; _batchsize NUMERIC; BEGIN _inactive := FALSE; IF (pRevisionid != -1) THEN --Is this a deactivated revision? SELECT rev_status INTO _check FROM rev WHERE ((rev_id=pRevisionid) AND (rev_status='I')); IF (FOUND) THEN _inactive := TRUE; END IF; END IF; -- Get the batch quantity SELECT COALESCE( ( SELECT bomhead_batchsize FROM bomhead WHERE ((bomhead_item_id=pItemId) AND (bomhead_rev_id=pRevisionid))),1) INTO _batchsize; IF NOT (_inactive) THEN FOR _x IN SELECT bomitem_id, bomitem_seqnumber, bomitem_seqnumber AS f_bomitem_seqnumber, item_id, item_number, uom_name, item_descrip1, item_descrip2, (item_descrip1 || ' ' || item_descrip2) AS itemdescription, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS qtyfxd, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS qtyper, bomitem_scrap, bomitem_createwo, CASE WHEN (bomitem_issuemethod='S') THEN 'Push' WHEN (bomitem_issuemethod='L') THEN 'Pull' WHEN (bomitem_issuemethod='M') THEN 'Mixed' ELSE 'Special' END AS issuemethod, bomitem_effective, bomitem_expires, CASE WHEN (bomitem_expires <= CURRENT_DATE) THEN TRUE ELSE FALSE END AS expired, CASE WHEN (bomitem_effective > CURRENT_DATE) THEN TRUE ELSE FALSE END AS future, actcost(bomitem_item_id, bomitem_id) AS actunitcost, stdcost(bomitem_item_id, bomitem_id) AS stdunitcost, CASE WHEN item_type NOT IN ('R','T') THEN itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') * actcost(bomitem_item_id, bomitem_id) ELSE 0.0 END AS actextendedcost, CASE WHEN item_type NOT IN ('R','T') THEN itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') * stdcost(bomitem_item_id, bomitem_id) ELSE 0.0 END AS stdextendedcost, bomitem_char_id, bomitem_value, bomitem_notes, bomitem_ref FROM bomitem(pItemid,pRevisionid), item, uom WHERE ( (item_inv_uom_id=uom_id) AND (bomitem_item_id=item_id) AND (bomitem_expires > (CURRENT_DATE - pExpiredDays)) AND (bomitem_effective <= (CURRENT_DATE + pFutureDays)) ) UNION SELECT -1, -1, NULL, -1, costelem_type AS bomdata_item_number, '', '', '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, false,false, currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE) AS actunitcost, itemcost_stdcost AS stdunitcost, currToBase(itemcost_curr_id, itemcost_actcost, CURRENT_DATE) AS actextendedcost, itemcost_stdcost AS stdextendedcost, NULL, NULL, NULL, NULL FROM itemcost, costelem WHERE ( (itemcost_costelem_id=costelem_id) AND (NOT itemcost_lowlevel) AND (itemcost_item_id=pItemid) ) ORDER BY bomitem_seqnumber, bomitem_effective, item_number LOOP _row.bomdata_bomitem_id := _x.bomitem_id; _row.bomdata_bomwork_seqnumber := _x.f_bomitem_seqnumber; _row.bomdata_item_id := _x.item_id; _row.bomdata_item_number := _x.item_number; _row.bomdata_uom_name := _x.uom_name; _row.bomdata_item_descrip1 := _x.item_descrip1; _row.bomdata_item_descrip2 := _x.item_descrip2; _row.bomdata_itemdescription := _x.itemdescription; _row.bomdata_batchsize := _batchsize; _row.bomdata_qtyfxd := _x.qtyfxd; _row.bomdata_qtyper := _x.qtyper; _row.bomdata_scrap := _x.bomitem_scrap; _row.bomdata_createchild := _x.bomitem_createwo; _row.bomdata_issuemethod := _x.issuemethod; _row.bomdata_effective := _x.bomitem_effective; _row.bomdata_expires := _x.bomitem_expires; _row.bomdata_expired := _x.expired; _row.bomdata_future := _x.future; _row.bomdata_actunitcost := _x.actunitcost; _row.bomdata_stdunitcost := _x.stdunitcost; _row.bomdata_actextendedcost := _x.actextendedcost; _row.bomdata_stdextendedcost := _x.stdextendedcost; _row.bomdata_char_id := _x.bomitem_char_id; _row.bomdata_value := _x.bomitem_value; _row.bomdata_notes := _x.bomitem_notes; _row.bomdata_ref := _x.bomitem_ref; RETURN NEXT _row; END LOOP; ELSE -- Use historical snapshot for inactive revisions FOR _x IN SELECT bomitem_id, bomitem_seqnumber, bomitem_seqnumber AS f_bomitem_seqnumber, item_id, item_number, uom_name, item_descrip1, item_descrip2, (item_descrip1 || ' ' || item_descrip2) AS itemdescription, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS qtyfxd, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS qtyper, bomitem_scrap, bomitem_createwo, CASE WHEN (bomitem_issuemethod='S') THEN 'Push' WHEN (bomitem_issuemethod='L') THEN 'Pull' WHEN (bomitem_issuemethod='M') THEN 'Mixed' ELSE 'Special' END AS issuemethod, bomitem_effective, bomitem_expires, CASE WHEN (bomitem_expires <= CURRENT_DATE) THEN TRUE ELSE FALSE END AS expired, CASE WHEN (bomitem_effective > CURRENT_DATE) THEN TRUE ELSE FALSE END AS future, actcost(bomitem_item_id) AS actunitcost, stdcost(bomitem_item_id) AS stdunitcost, CASE WHEN item_type NOT IN ('R','T') THEN itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') * actcost(bomitem_item_id) ELSE 0.0 END AS actextendedcost, CASE WHEN item_type NOT IN ('R','T') THEN itemuomtouom(bomitem_item_id, bomitem_uom_id, NULL, (bomitem_qtyfxd/_batchsize + bomitem_qtyper) * (1 + bomitem_scrap), 'qtyper') * stdcost(bomitem_item_id) ELSE 0.0 END AS stdextendedcost, bomitem_char_id, bomitem_value, bomitem_notes, bomitem_ref FROM bomitem(pItemid,pRevisionid), item, uom WHERE ( (item_inv_uom_id=uom_id) AND (bomitem_item_id=item_id) AND (bomitem_expires > (CURRENT_DATE - pExpiredDays)) AND (bomitem_effective <= (CURRENT_DATE + pFutureDays)) ) UNION SELECT -1, -1, NULL, -1, costelem_type AS bomdata_item_number, '', '', '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, false,false, bomhist_actunitcost AS actunitcost, bomhist_stdunitcost AS stdunitcost, bomhist_actunitcost AS actextendedcost, bomhist_stdunitcost AS stdextendedcost, NULL, NULL, NULL, NULL FROM bomhist, costelem WHERE ( (bomhist_item_id=costelem_id) AND (bomhist_item_type='E') AND (bomhist_rev_id=pRevisionid) ) ORDER BY bomitem_seqnumber, bomitem_effective, item_number LOOP _row.bomdata_bomitem_id := _x.bomitem_id; _row.bomdata_bomwork_seqnumber := _x.f_bomitem_seqnumber; _row.bomdata_item_id := _x.item_id; _row.bomdata_item_number := _x.item_number; _row.bomdata_uom_name := _x.uom_name; _row.bomdata_item_descrip1 := _x.item_descrip1; _row.bomdata_item_descrip2 := _x.item_descrip2; _row.bomdata_itemdescription := _x.itemdescription; _row.bomdata_batchsize := _batchsize; _row.bomdata_qtyfxd := _x.qtyfxd; _row.bomdata_qtyper := _x.qtyper; _row.bomdata_scrap := _x.bomitem_scrap; _row.bomdata_createchild := _x.bomitem_createwo; _row.bomdata_issuemethod := _x.issuemethod; _row.bomdata_effective := _x.bomitem_effective; _row.bomdata_expires := _x.bomitem_expires; _row.bomdata_expired := _x.expired; _row.bomdata_future := _x.future; _row.bomdata_actunitcost := _x.actunitcost; _row.bomdata_stdunitcost := _x.stdunitcost; _row.bomdata_actextendedcost := _x.actextendedcost; _row.bomdata_stdextendedcost := _x.stdextendedcost; _row.bomdata_char_id := _x.bomitem_char_id; _row.bomdata_value := _x.bomitem_value; _row.bomdata_notes := _x.bomitem_notes; _row.bomdata_ref := _x.bomitem_ref; RETURN NEXT _row; END LOOP; END IF; RETURN; END; $_$; IDROP FUNCTION public.singlelevelbom(integer, integer, integer, integer); publicadminfalse423784623/125579396site()FUNCTIONKCREATE FUNCTION site() RETURNS SETOF whsinfo LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row whsinfo%ROWTYPE; _r RECORD; BEGIN IF ( (fetchMetricBool('MultiWhs')) AND (SELECT (COUNT(usrpref_id)=1) FROM usrpref WHERE ((usrpref_name='selectedSites') AND (usrpref_value='t') AND (usrpref_username=getEffectiveXtUser()))) ) THEN FOR _r IN SELECT * FROM whsinfo,usrsite WHERE ((warehous_id=usrsite_warehous_id) AND (usrsite_username=getEffectiveXtUser())) LOOP _row.warehous_id:=_r.warehous_id; _row.warehous_code:=_r.warehous_code; _row.warehous_descrip:=_r.warehous_descrip; _row.warehous_fob:=_r.warehous_fob; _row.warehous_active:=_r.warehous_active; _row.warehous_counttag_prefix:=_r.warehous_counttag_prefix; _row.warehous_counttag_number:=_r.warehous_counttag_number; _row.warehous_bol_prefix:=_r.warehous_bol_prefix; _row.warehous_bol_number:=_r.warehous_bol_number; _row.warehous_shipping:=_r.warehous_shipping; _row.warehous_useslips:=_r.warehous_useslips; _row.warehous_usezones:=_r.warehous_usezones; _row.warehous_aislesize:=_r.warehous_aislesize; _row.warehous_racksize:=_r.warehous_racksize; _row.warehous_binsize:=_r.warehous_binsize; _row.warehous_binalpha:=_r.warehous_binalpha; _row.warehous_locationsize:=_r.warehous_locationsize; _row.warehous_locationalpha:=_r.warehous_locationalpha; _row.warehous_enforcearbl:=_r.warehous_enforcearbl; _row.warehous_default_accnt_id:=_r.warehous_default_accnt_id; _row.warehous_shipping_commission:=_r.warehous_shipping_commission; _row.warehous_cntct_id:=_r.warehous_cntct_id; _row.warehous_addr_id:=_r.warehous_addr_id; _row.warehous_taxzone_id:=_r.warehous_taxzone_id; _row.warehous_transit:=_r.warehous_transit; _row.warehous_shipform_id:=_r.warehous_shipform_id; _row.warehous_shipvia_id:=_r.warehous_shipvia_id; _row.warehous_shipcomments:=_r.warehous_shipcomments; _row.warehous_costcat_id:=_r.warehous_costcat_id; _row.warehous_sitetype_id:=_r.warehous_sitetype_id; RETURN NEXT _row; END LOOP; ELSE FOR _r IN SELECT * FROM whsinfo LOOP _row.warehous_id:=_r.warehous_id; _row.warehous_code:=_r.warehous_code; _row.warehous_descrip:=_r.warehous_descrip; _row.warehous_fob:=_r.warehous_fob; _row.warehous_active:=_r.warehous_active; _row.warehous_counttag_prefix:=_r.warehous_counttag_prefix; _row.warehous_counttag_number:=_r.warehous_counttag_number; _row.warehous_bol_prefix:=_r.warehous_bol_prefix; _row.warehous_bol_number:=_r.warehous_bol_number; _row.warehous_shipping:=_r.warehous_shipping; _row.warehous_useslips:=_r.warehous_useslips; _row.warehous_usezones:=_r.warehous_usezones; _row.warehous_aislesize:=_r.warehous_aislesize; _row.warehous_racksize:=_r.warehous_racksize; _row.warehous_binsize:=_r.warehous_binsize; _row.warehous_binalpha:=_r.warehous_binalpha; _row.warehous_locationsize:=_r.warehous_locationsize; _row.warehous_locationalpha:=_r.warehous_locationalpha; _row.warehous_enforcearbl:=_r.warehous_enforcearbl; _row.warehous_default_accnt_id:=_r.warehous_default_accnt_id; _row.warehous_shipping_commission:=_r.warehous_shipping_commission; _row.warehous_cntct_id:=_r.warehous_cntct_id; _row.warehous_addr_id:=_r.warehous_addr_id; _row.warehous_taxzone_id:=_r.warehous_taxzone_id; _row.warehous_transit:=_r.warehous_transit; _row.warehous_shipform_id:=_r.warehous_shipform_id; _row.warehous_shipvia_id:=_r.warehous_shipvia_id; _row.warehous_shipcomments:=_r.warehous_shipcomments; _row.warehous_costcat_id:=_r.warehous_costcat_id; _row.warehous_sitetype_id:=_r.warehous_sitetype_id; RETURN NEXT _row; END LOOP; END IF; RETURN; END; $$; DROP FUNCTION public.site(); publicadminfalse2746462380125579397snoozemessage(integer)FUNCTIONCREATE FUNCTION snoozemessage(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pMsgid ALIAS FOR $1; snooze INTERVAL := '10 minutes'; BEGIN UPDATE msg SET msg_scheduled=(msg_scheduled + snooze) WHERE (msg_id=pMsgid); RETURN TRUE; END; $_$; -DROP FUNCTION public.snoozemessage(integer); publicadminfalse462381125579398spellamount(numeric)FUNCTION CREATE FUNCTION spellamount(numeric) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN spellAmount($1, baseCurrId()); END; $_$; +DROP FUNCTION public.spellamount(numeric); publicadminfalse846232125579399spellamount(numeric, integer)FUNCTIONCREATE FUNCTION spellamount(numeric, integer) RETURNS text LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pN ALIAS FOR $1; pCurrId ALIAS FOR $2; _t text; _dollars text; _cents text; _l integer; _p integer; _words text; _word text; _hundreds char; _tens char; _ones char; _fractionalPartName text; _curr curr_symbol%ROWTYPE; BEGIN _t := ltrim(to_char(pN, '999999999990D99'),' '); IF strpos(_t, '.') > 0 THEN _dollars := split_part(_t, '.', 1); _cents := split_part(_t, '.', 2); ELSIF strpos(_t, ',') > 0 THEN _dollars := split_part(_t, ',', 1); _cents := split_part(_t, ',', 2); END IF; _p := 0; _l := length(_dollars); _words := ''; WHILE (_p < _l) LOOP IF((_l - _p - 2) < 1) THEN _hundreds := '0'; ELSE _hundreds := substr(_dollars, _l - _p - 2, 1); END IF; IF((_l - _p - 1) < 1) THEN _tens := '0'; ELSE _tens := substr(_dollars, _l - _p - 1, 1); END IF; IF((_l - _p) < 1) THEN _ones := '0'; ELSE _ones := substr(_dollars, _l - _p, 1); END IF; IF(_hundreds != '0' OR _tens != '0' OR _ones != '0') THEN IF (_p = 3) THEN _words := 'thousand ' || _words; ELSIF (_p = 6) THEN _words := 'million ' || _words; ELSIF (_p = 9) THEN _words := 'billion ' || _words; END IF; _word := ''; IF(_tens = '1') THEN IF(_ones = '0') THEN _word := 'ten'; ELSIF(_ones = '1') THEN _word := 'eleven'; ELSIF(_ones = '2') THEN _word := 'twelve'; ELSIF(_ones = '3') THEN _word := 'thirteen'; ELSIF(_ones = '4') THEN _word := 'fourteen'; ELSIF(_ones = '5') THEN _word := 'fifteen'; ELSIF(_ones = '6') THEN _word := 'sixteen'; ELSIF(_ones = '7') THEN _word := 'seventeen'; ELSIF(_ones = '8') THEN _word := 'eighteen'; ELSIF(_ones = '9') THEN _word := 'nineteen'; ELSE _word := 'ERROR'; END IF; ELSE IF(_ones = '1') THEN _word := 'one'; ELSIF(_ones = '2') THEN _word := 'two'; ELSIF(_ones = '3') THEN _word := 'three'; ELSIF(_ones = '4') THEN _word := 'four'; ELSIF(_ones = '5') THEN _word := 'five'; ELSIF(_ones = '6') THEN _word := 'six'; ELSIF(_ones = '7') THEN _word := 'seven'; ELSIF(_ones = '8') THEN _word := 'eight'; ELSIF(_ones = '9') THEN _word := 'nine'; ELSIF(_ones != '0') THEN _word := 'ERROR'; END IF; if(_tens != '0') THEN _word := '-' || _word; END IF; IF(_tens = '2') THEN _word := 'twenty' || _word; ELSIF(_tens = '3') THEN _word := 'thirty' || _word; ELSIF(_tens = '4') THEN _word := 'forty' || _word; ELSIF(_tens = '5') THEN _word := 'fifty' || _word; ELSIF(_tens = '6') THEN _word := 'sixty' || _word; ELSIF(_tens = '7') THEN _word := 'seventy' || _word; ELSIF(_tens = '8') THEN _word := 'eighty' || _word; ELSIF(_tens = '9') THEN _word := 'ninety' || _word; ELSIF(_tens != '0' AND _tens != '1') THEN _word := 'ERROR' || _word; END IF; END IF; if(_word != '') THEN _words := _word || ' ' || _words; END IF; _word := ''; IF(_hundreds = '1') THEN _word := 'one hundred'; ELSIF(_hundreds = '2') THEN _word := 'two hundred'; ELSIF(_hundreds = '3') THEN _word := 'three hundred'; ELSIF(_hundreds = '4') THEN _word := 'four hundred'; ELSIF(_hundreds = '5') THEN _word := 'five hundred'; ELSIF(_hundreds = '6') THEN _word := 'six hundred'; ELSIF(_hundreds = '7') THEN _word := 'seven hundred'; ELSIF(_hundreds = '8') THEN _word := 'eight hundred'; ELSIF(_hundreds = '9') THEN _word := 'nine hundred'; ELSIF(_hundreds != '0') THEN _words := 'ERROR'; END IF; if(_word != '') THEN _words := _word || ' ' || _words; END IF; END IF; _p := _p + 3; END LOOP; _words := rtrim(_words, ' '); IF(_words = '') THEN _words := 'zero'; END IF; SELECT * INTO _curr FROM curr_symbol WHERE curr_id = pCurrId; IF(_words = 'one') AND TRIM(_curr.curr_name) ~ '.*s' THEN _word := rtrim(_curr.curr_name, ' s'); ELSE _word := trim(_curr.curr_name); END IF; IF _curr.curr_abbr = 'USD' OR _curr.curr_abbr = 'CAD' THEN IF (_cents = '1') THEN _fractionalPartName = ' cent'; ELSE _fractionalPartName = ' cents'; END IF; ELSE _fractionalPartName = ' / 100 '; END IF; RETURN _words || ' ' || _word || ' and ' || _cents || _fractionalPartName; END; $_$; 4DROP FUNCTION public.spellamount(numeric, integer); publicadminfalse846235125579400'splitreceipt(integer, numeric, numeric)FUNCTIONaCREATE FUNCTION splitreceipt(integer, numeric, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE precvid ALIAS FOR $1; pqty ALIAS FOR $2; pfreight ALIAS FOR $3; _check RECORD; _seq INTEGER; BEGIN -- validate IF (COALESCE(pQty,0) <= 0) THEN RETURN -7; END IF; SELECT * INTO _check FROM recv WHERE (recv_id=precvid); IF (FOUND) THEN IF (_check.recv_order_type != 'PO') THEN RETURN -1; ELSIF ( NOT _check.recv_posted) THEN RETURN -2; ELSIF ( (_check.recv_invoiced) OR (_check.recv_vohead_id IS NOT NULL) OR (_check.recv_voitem_id IS NOT NULL) ) THEN RETURN -3; ELSIF (pqty >= _check.recv_qty) THEN RETURN -4; ELSIF (COALESCE(pfreight,0) > _check.recv_freight) THEN RETURN -5; END IF; ELSE RETURN -6; END IF; -- Create new receipt record _seq := nextval('recv_recv_id_seq'); INSERT INTO recv SELECT _seq, recv_order_type,recv_order_number, recv_orderitem_id, recv_agent_username, recv_itemsite_id, recv_vend_id, recv_vend_item_number, recv_vend_item_descrip, recv_vend_uom, recv_purchcost, recv_purchcost_curr_id, recv_duedate, pqty, recv_recvcost, recv_recvcost_curr_id, COALESCE(pfreight,0), recv_freight_curr_id, recv_date, ROUND(recv_value/recv_qty * pqty, 2), TRUE, FALSE, NULL, NULL, recv_trans_usr_name, recv_notes, recv_gldistdate, precvid FROM recv WHERE (recv_id=precvid); -- Update qty and value of old record UPDATE recv SET recv_qty = recv_qty-pqty, recv_value = recv_value - ROUND(recv_value/recv_qty * pqty, 2), recv_freight = recv_freight - COALESCE(pfreight,0) WHERE (recv_id=precvid); RETURN _seq; END; $_$; >DROP FUNCTION public.splitreceipt(integer, numeric, numeric); publicadminfalse4623861255794018splitrecurrence(integer, text, timestamp with time zone)FUNCTION CREATE FUNCTION splitrecurrence(integer, text, timestamp with time zone) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pParentid ALIAS FOR $1; pType TEXT := UPPER($2); pDatetime TIMESTAMP WITH TIME ZONE := COALESCE($3, CURRENT_TIMESTAMP); _count INTEGER; _newrecurid INTEGER; _newparentid INTEGER; _newparentstmt TEXT; _rt RECORD; _updchildstmt TEXT; BEGIN IF (pParentid IS NULL) THEN RETURN -11; END IF; SELECT * INTO _rt FROM recurtype WHERE (UPPER(recurtype_type)=pType); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count <= 0) THEN RETURN -10; END IF; _newparentstmt := 'SELECT [table]_id FROM [fulltable]' || ' WHERE (([table]_recurring_[table]_id=$1)' || ' AND NOT ([done])' || ' AND ([schedcol]>=''$2''))' || ' ORDER BY [schedcol]' || ' LIMIT 1;'; _newparentstmt := REPLACE(_newparentstmt, '[fulltable]', _rt.recurtype_table); _newparentstmt := REPLACE(_newparentstmt, '[table]', REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', '')); _newparentstmt := REPLACE(_newparentstmt, '[done]', _rt.recurtype_donecheck); _newparentstmt := REPLACE(_newparentstmt, '[schedcol]', _rt.recurtype_schedcol); _updchildstmt := 'UPDATE [fulltable] SET [table]_recurring_[table]_id=$1' || ' WHERE (([table]_recurring_[table]_id=$2)' || ' AND NOT ([done])' || ' AND ([schedcol] > ''$3''));'; _updchildstmt := REPLACE(_updchildstmt, '[fulltable]', _rt.recurtype_table); _updchildstmt := REPLACE(_updchildstmt, '[table]', REGEXP_REPLACE(_rt.recurtype_table, E'.*\\.', '')); _updchildstmt := REPLACE(_updchildstmt, '[done]', _rt.recurtype_donecheck); _updchildstmt := REPLACE(_updchildstmt, '[schedcol]', _rt.recurtype_schedcol); -- 8.4+: EXECUTE _newparentstmt INTO _newparentid USING pParentid, pDatetime; EXECUTE REPLACE(REPLACE(_newparentstmt, '$1', pParentid::TEXT), '$2', pDatetime::TEXT) INTO _newparentid; -- if nothing to split IF (_newparentid = pParentid OR _newparentid IS NULL) THEN SELECT recur_id INTO _newrecurid FROM recur WHERE ((recur_parent_id=pParentid) AND (recur_parent_type=pType)); ELSE INSERT INTO recur (recur_parent_id, recur_parent_type, recur_period, recur_freq, recur_start, recur_end, recur_max, recur_data ) SELECT _newparentid, pType, recur_period, recur_freq, pDatetime, recur_end, recur_max, recur_data FROM recur WHERE ((recur_parent_id=pParentid) AND (recur_parent_type=pType)) RETURNING recur_id INTO _newrecurid; UPDATE recur SET recur_end=pDatetime WHERE ((recur_parent_id=pParentid) AND (recur_parent_type=pType)); -- 8.4+: EXECUTE _updchildstmt USING _newparentid, pParentid, pDatetime; EXECUTE REPLACE(REPLACE(REPLACE(_updchildstmt, '$1', _newparentid::TEXT), '$2', pParentid::TEXT), '$3', pDatetime::TEXT); END IF; RETURN _newrecurid; END; $_$; ODROP FUNCTION public.splitrecurrence(integer, text, timestamp with time zone); publicadminfalse462387125579402 startoftime()FUNCTIONCREATE FUNCTION startoftime() RETURNS date LANGUAGE sql IMMUTABLE AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT DATE('1970-01-01') AS return; $$; $DROP FUNCTION public.startoftime(); publicadminfalse88125579403stdcost(integer)FUNCTIONCREATE FUNCTION stdcost(integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN stdCost($1, NULL); END; $_$; 'DROP FUNCTION public.stdcost(integer); publicadminfalse846239125579404stdcost(integer, integer)FUNCTIONCREATE FUNCTION stdcost(integer, integer) RETURNS numeric LANGUAGE plpgsql STABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pBomitemid ALIAS FOR $2; _cost NUMERIC; BEGIN SELECT SUM(COALESCE(bomitemcost_stdcost, itemcost_stdcost)) INTO _cost FROM itemcost LEFT OUTER JOIN bomitemcost ON (bomitemcost_bomitem_id=pBomitemid AND bomitemcost_costelem_id=itemcost_costelem_id) WHERE (itemcost_item_id=pItemid); IF (_cost IS NULL) THEN RETURN 0; ELSE RETURN _cost; END IF; END; $_$; 0DROP FUNCTION public.stdcost(integer, integer); publicadminfalse46238:125579405,sufficientinventorytoshipitem(text, integer)FUNCTIONCREATE FUNCTION sufficientinventorytoshipitem(text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; porderitemid ALIAS FOR $2; BEGIN RETURN sufficientInventoryToShipItem(pordertype, porderitemid, NULL); END; $_$; CDROP FUNCTION public.sufficientinventorytoshipitem(text, integer); publicadminfalse84623;1255794065sufficientinventorytoshipitem(text, integer, numeric)FUNCTIONCREATE FUNCTION sufficientinventorytoshipitem(text, integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; porderitemid ALIAS FOR $2; pqty ALIAS FOR $3; _returnVal INTEGER; _isqtyavail BOOLEAN; BEGIN IF (porderitemid IS NULL) THEN RETURN -1; END IF; IF (pordertype = 'SO') THEN IF ( SELECT fetchMetricBool('EnableSOReservations') ) THEN IF (SELECT (itemsite_costmethod = 'J') FROM coitem JOIN itemsite ON (coitem_itemsite_id=itemsite_id) WHERE (coitem_id=porderitemid)) THEN RETURN 0; END IF; SELECT (((COALESCE(pqty, roundQty(item_fractional, noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping(pordertype, coitem_id) ))) - coitem_qtyreserved) * coitem_qty_invuomratio ) <= qtyAvailable(itemsite_id)) AND (((COALESCE(pqty, roundQty(item_fractional, noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping(pordertype, coitem_id) ))) - coitem_qtyreserved) * coitem_qty_invuomratio ) <= qtyunreserved(itemsite_id)) INTO _isqtyavail FROM coitem, itemsite, item WHERE ((coitem_itemsite_id=itemsite_id) AND (coitem_status <> 'X') AND (NOT ((item_type IN ('R','J')) OR (itemsite_controlmethod = 'N'))) AND (itemsite_item_id=item_id) AND (coitem_id=porderitemid)); ELSE SELECT (COALESCE(pqty, roundQty(item_fractional, noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping(pordertype, coitem_id) - coitem_qtyreserved ) * coitem_qty_invuomratio ) ) <= qtyAvailable(itemsite_id)) INTO _isqtyavail FROM coitem, itemsite, item WHERE ((coitem_itemsite_id=itemsite_id) AND (coitem_status <> 'X') AND (NOT ((item_type IN ('R','J')) OR (itemsite_controlmethod = 'N'))) AND (itemsite_item_id=item_id) AND (coitem_id=porderitemid)); END IF; ELSEIF (pordertype = 'TO') THEN SELECT (COALESCE(pqty, roundQty(item_fractional, noNeg(toitem_qty_ordered - toitem_qty_shipped - qtyAtShipping(pordertype, toitem_id) ) ) ) <= qtyAvailable(itemsite_id)) INTO _isqtyavail FROM toitem, tohead, itemsite, item WHERE ((toitem_tohead_id=tohead_id) AND (tohead_src_warehous_id=itemsite_warehous_id) AND (toitem_item_id=itemsite_item_id) AND (itemsite_warehous_id=tohead_src_warehous_id) AND (itemsite_item_id=item_id) AND (toitem_status <> 'X') AND (NOT ((item_type IN ('R','J')) OR (itemsite_controlmethod = 'N'))) AND (toitem_id=porderitemid)); ELSE RETURN -11; END IF; IF (NOT _isqtyavail) THEN RETURN -2; END IF; IF (pordertype = 'SO') THEN SELECT (COALESCE((SELECT SUM(itemloc_qty) FROM itemloc WHERE (itemloc_itemsite_id=itemsite_id)), 0.0) >= roundQty(item_fractional, COALESCE(pQty, noNeg( coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned - qtyAtShipping(pordertype, coitem_id) )) * coitem_qty_invuomratio )) INTO _isqtyavail FROM coitem, itemsite, item WHERE ((coitem_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (NOT ((item_type ='R') OR (itemsite_controlmethod = 'N'))) AND ((itemsite_controlmethod IN ('L', 'S')) OR (itemsite_loccntrl)) AND (coitem_id=porderitemid)); ELSEIF (pordertype = 'TO') THEN SELECT (COALESCE((SELECT SUM(itemloc_qty) FROM itemloc WHERE (itemloc_itemsite_id=itemsite_id)), 0.0) >= roundQty(item_fractional, noNeg( toitem_qty_ordered - toitem_qty_shipped - qtyAtShipping(pordertype, toitem_id) ) )) INTO _isqtyavail FROM toitem, tohead, itemsite, item WHERE ((toitem_tohead_id=tohead_id) AND (tohead_src_warehous_id=itemsite_warehous_id) AND (toitem_item_id=itemsite_item_id) AND (itemsite_item_id=item_id) AND (toitem_status <> 'X') AND (NOT ((item_type ='R') OR (itemsite_costmethod = 'J') OR (itemsite_controlmethod = 'N'))) AND ((itemsite_controlmethod IN ('L', 'S')) OR (itemsite_loccntrl)) AND (toitem_id=porderitemid)); END IF; IF (NOT _isqtyavail) THEN RETURN -3; END IF; IF (pordertype = 'SO') THEN IF ( SELECT fetchMetricBool('RequireSOReservations') ) THEN SELECT (COALESCE(pqty, coitem_qtyreserved) <= coitem_qtyreserved) INTO _isqtyavail FROM coitem, itemsite, item WHERE ((coitem_itemsite_id=itemsite_id) AND (coitem_status <> 'X') AND (NOT ((item_type IN ('R','J')) OR (itemsite_controlmethod = 'N'))) AND (itemsite_item_id=item_id) AND (coitem_id=porderitemid)); END IF; END IF; IF (NOT _isqtyavail) THEN RETURN -4; END IF; RETURN 0; END; $_$; LDROP FUNCTION public.sufficientinventorytoshipitem(text, integer, numeric); publicadminfalse46238<125579407-sufficientinventorytoshiporder(text, integer)FUNCTIONCREATE FUNCTION sufficientinventorytoshiporder(text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pordertype ALIAS FOR $1; porderid ALIAS FOR $2; _s RECORD; _returnVal INTEGER := 0; BEGIN IF (pordertype = 'SO') THEN FOR _s IN SELECT coitem_id FROM coitem JOIN itemsite ON (coitem_itemsite_id=itemsite_id) WHERE((coitem_cohead_id=porderid) AND (itemsite_costmethod != 'J')) LOOP _returnVal := sufficientInventoryToShipItem(pordertype, _s.coitem_id); EXIT WHEN (_returnVal < 0); END LOOP; ELSEIF (pordertype = 'TO') THEN FOR _s IN SELECT toitem_id FROM toitem WHERE(toitem_tohead_id=porderid) LOOP _returnVal := sufficientInventoryToShipItem(pordertype, _s.toitem_id); EXIT WHEN (_returnVal < 0); END LOOP; END IF; RETURN _returnVal; END; $_$; DDROP FUNCTION public.sufficientinventorytoshiporder(text, integer); publicadminfalse46238=125579408summarizedbom(integer)FUNCTION|CREATE FUNCTION summarizedbom(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; _revid INTEGER; BEGIN SELECT getActiveRevId('BOM',pItemid) INTO _revid; RETURN summarizedBOM(pItemid, _revid); END; $_$; -DROP FUNCTION public.summarizedbom(integer); publicadminfalse462383125579409summarizedbom(integer, integer)FUNCTIONCREATE FUNCTION summarizedbom(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pRevisionid ALIAS FOR $2; _bomworkid INTEGER; _indexid INTEGER; _r RECORD; BEGIN -- Check on the temporary workspace -- PERFORM maintainBOMWorkspace(); -- Grab a new index for this bomwork set SELECT NEXTVAL('misc_index_seq') INTO _indexid; -- Step through all of the components of the passed pItemid FOR _r IN SELECT bomitem.*, item_id, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyfxd) AS qtyfxd, (itemuomtouomratio(bomitem_item_id, bomitem_uom_id, NULL) * bomitem_qtyper) AS qtyper, stdcost(item_id, bomitem_id) AS standardcost, actcost(item_id, bomitem_id) AS actualcost FROM bomitem(pItemid, pRevisionid), item WHERE (bomitem_item_id=item_id) LOOP -- Insert the component and bomitem parameters SELECT NEXTVAL('bomwork_bomwork_id_seq') INTO _bomworkid; INSERT INTO bomwork ( bomwork_id, bomwork_set_id, bomwork_parent_id, bomwork_level, bomwork_parent_seqnumber, bomwork_seqnumber, bomwork_item_id, bomwork_createwo, bomwork_qtyreq, bomwork_qtyfxd, bomwork_qtyper, bomwork_scrap, bomwork_issuemethod, bomwork_effective, bomwork_expires, bomwork_stdunitcost, bomwork_actunitcost ) VALUES ( _bomworkid, _indexid, -1, 1, 0, _r.bomitem_seqnumber, _r.item_id, _r.bomitem_createwo, (_r.qtyfxd + _r.qtyper), _r.qtyfxd, _r.qtyper, _r.bomitem_scrap, _r.bomitem_issuemethod, _r.bomitem_effective, _r.bomitem_expires, _r.standardcost, _r.actualcost, _r.bomitem_char_id, _r.bomitem_value, _r.bomitem_notes, _r.bomitem_ref, _r.bomitem_id, _r.bomitem_ecn ); -- Explode the components of the current component PERFORM explodeBOM(_r.item_id, _bomworkid, 1); END LOOP; -- Return a key to the result RETURN _indexid; END; $_$; 6DROP FUNCTION public.summarizedbom(integer, integer); publicadminfalse846234125579410(summarizedbom(integer, integer, integer)FUNCTIONCREATE FUNCTION summarizedbom(integer, integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pExpired ALIAS FOR $2; pFuture ALIAS FOR $3; _revid INTEGER; BEGIN SELECT getActiveRevId('BOM',pItemid) INTO _revid; RETURN summarizedBOM(pItemid, _revid, pExpired, pFuture); END; $_$; ?DROP FUNCTION public.summarizedbom(integer, integer, integer); publicadminfalse84623>1255870981summarizedbom(integer, integer, integer, integer)FUNCTIONCREATE FUNCTION summarizedbom(integer, integer, integer, integer) RETURNS SETOF bomdata LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pRevisionid ALIAS FOR $2; pExpiredDays INTEGER := COALESCE($3, 0); pFutureDays INTEGER := COALESCE($4, 0); _row bomdata%ROWTYPE; _bomworksetid INTEGER; _x RECORD; _check CHAR(1); _inactive BOOLEAN := FALSE; _batchsize NUMERIC; BEGIN IF (pRevisionid != -1) THEN --Is this a deactivated revision? SELECT rev_status INTO _check FROM rev WHERE ((rev_id=pRevisionid) AND (rev_status='I')); IF (FOUND) THEN _inactive := TRUE; END IF; END IF; -- Get the batch quantity SELECT COALESCE( ( SELECT bomhead_batchsize FROM bomhead WHERE ((bomhead_item_id=pItemId) AND (bomhead_rev_id=pRevisionid))),1) INTO _batchsize; IF NOT (_inactive) THEN --We can explode this out based on current data SELECT indentedBOM(pItemid, pRevisionid) INTO _bomworksetid; FOR _x IN SELECT item_number, uom_name, item_descrip1, item_descrip2, (item_descrip1 || ' ' || item_descrip2) AS itemdescription, SUM(bomwork_qtyreq) AS qtyreq, SUM(bomwork_qtyfxd * (1 + bomwork_scrap)) AS qtyfxd, SUM(bomwork_qtyper * (1 + bomwork_scrap)) AS qtyper, MAX(bomwork_actunitcost) AS actunitcost, MAX(bomwork_stdunitcost) AS stdunitcost, CASE WHEN item_type NOT IN ('R','T') THEN SUM(bomwork_actunitcost * bomwork_qtyreq) ELSE 0 END AS actextendedcost, CASE WHEN item_type NOT IN ('R','T') THEN SUM(bomwork_stdunitcost * bomwork_qtyreq) ELSE 0 END AS stdextendedcost, bomwork_effective, bomwork_expires, bomwork_effective > CURRENT_DATE AS future, bomwork_expires <= CURRENT_DATE AS expired FROM ( SELECT item_number, item_type, uom_name, item_descrip1, item_descrip2, bomwork_qtyreq, bomwork_qtyfxd, bomwork_qtyper, bomwork_scrap, bomwork_actunitcost, bomwork_stdunitcost, CASE WHEN (bomwork_effective > CURRENT_DATE) THEN (CURRENT_DATE + 1) ELSE CURRENT_DATE END AS bomwork_effective, CASE WHEN (bomwork_expires <= CURRENT_DATE) THEN (CURRENT_DATE - 1) ELSE (CURRENT_DATE + 1) END AS bomwork_expires FROM bomwork, item, uom WHERE ( (bomwork_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (bomwork_set_id=_bomworksetid) ) AND (bomwork_expires > (CURRENT_DATE - pExpiredDays)) AND (bomwork_effective <= (CURRENT_DATE + pFutureDays)) ) AS data GROUP BY item_number, uom_name, item_type, item_descrip1, item_descrip2, bomwork_effective, bomwork_expires ORDER BY item_number LOOP _row.bomdata_item_number := _x.item_number; _row.bomdata_uom_name := _x.uom_name; _row.bomdata_item_descrip1 := _x.item_descrip1; _row.bomdata_item_descrip2 := _x.item_descrip2; _row.bomdata_itemdescription := _x.itemdescription; _row.bomdata_qtyreq := _x.qtyreq; _row.bomdata_qtyfxd := _x.qtyfxd; _row.bomdata_qtyper := _x.qtyper; _row.bomdata_actunitcost := _x.actunitcost; _row.bomdata_stdunitcost := _x.stdunitcost; _row.bomdata_actextendedcost := _x.actextendedcost; _row.bomdata_stdextendedcost := _x.stdextendedcost; _row.bomdata_effective := _x.bomwork_effective; _row.bomdata_expires := _x.bomwork_expires; _row.bomdata_future := _x.future; _row.bomdata_expired := _x.expired; RETURN NEXT _row; END LOOP; PERFORM deleteBOMWorkset(_bomworksetid); ELSE -- Use historical snapshot for inactive revisions FOR _x IN SELECT item_number, uom_name, item_descrip1, item_descrip2, (item_descrip1 || ' ' || item_descrip2) AS itemdescription, SUM(bomhist_qtyreq * (1 + bomhist_scrap)) AS qtyreq, SUM(bomhist_qtyfxd * (1 + bomhist_scrap)) AS qtyfxd, SUM(bomhist_qtyper * (1 + bomhist_scrap)) AS qtyper, MAX(bomhist_actunitcost) AS actunitcost, MAX(bomhist_stdunitcost) AS stdunitcost, CASE WHEN item_type NOT IN ('R','T') THEN MAX(bomhist_actunitcost) * SUM((bomhist_qtyfxd/_batchsize + bomhist_qtyper) * (1 + bomhist_scrap)) ELSE 0 END AS actextendedcost, CASE WHEN item_type NOT IN ('R','T') THEN MAX(bomhist_stdunitcost) * SUM((bomhist_qtyfxd/_batchsize + bomhist_qtyper) * (1 + bomhist_scrap)) ELSE 0 END AS stdextendedcost FROM bomhist, item, uom WHERE ( (bomhist_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (bomhist_rev_id=pRevisionid) ) AND (bomhist_expires > (CURRENT_DATE - pExpiredDays)) AND (bomhist_effective <= (CURRENT_DATE + pFutureDays)) GROUP BY item_number, uom_name, item_type, item_descrip1, item_descrip2 ORDER BY item_number LOOP _row.bomdata_item_number := _x.item_number; _row.bomdata_uom_name := _x.uom_name; _row.bomdata_item_descrip1 := _x.item_descrip1; _row.bomdata_item_descrip2 := _x.item_descrip2; _row.bomdata_itemdescription := _x.itemdescription; _row.bomdata_qtyreq := _x.qtyreq; _row.bomdata_qtyfxd := _x.qtyfxd; _row.bomdata_qtyper := _x.qtyper; _row.bomdata_actunitcost := _x.actunitcost; _row.bomdata_stdunitcost := _x.stdunitcost; _row.bomdata_actextendedcost := _x.actextendedcost; _row.bomdata_stdextendedcost := _x.stdextendedcost; RETURN NEXT _row; END LOOP; END IF; RETURN; END; $_$; HDROP FUNCTION public.summarizedbom(integer, integer, integer, integer); publicadminfalse846234237?125579412*summarizetransactions(integer, date, date)FUNCTION CREATE FUNCTION summarizetransactions(integer, date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _startDate DATE; _endDate DATE; _invhist RECORD; _itemuom TEXT; _transCounter INTEGER; _itemlocSeries INTEGER; BEGIN -- Cache the uom_name SELECT uom_name INTO _itemuom FROM itemsite, item, uom WHERE ((itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) AND (itemsite_id=pItemsiteid)); -- Can't summarize into the future... IF (pEndDate > CURRENT_DATE) THEN _endDate := CURRENT_DATE; ELSE _endDate := pEndDate; END IF; -- Verify date bounds IF (pStartDate > pEndDate) THEN _startDate := pEndDate; ELSE _startDate := pStartDate; END IF; -- Verify that history is not referenced elsewhere SELECT invhist_id INTO _transCounter FROM invhist JOIN womatlpost ON (womatlpost_invhist_id=invhist_id) WHERE ((invhist_itemsite_id=pItemsiteid) AND (invhist_transdate::DATE BETWEEN _startDate AND _endDate)) LIMIT 1; IF (FOUND) THEN RETURN 0; END IF; SELECT invhist_id INTO _transCounter FROM invhist JOIN shipitem ON (shipitem_invhist_id=invhist_id) WHERE ((invhist_itemsite_id=pItemsiteid) AND (invhist_transdate::DATE BETWEEN _startDate AND _endDate)) LIMIT 1; IF (FOUND) THEN RETURN 0; END IF; _transCounter := 0; _itemlocSeries := NEXTVAL('itemloc_series_seq'); FOR _invhist IN SELECT invhist_transtype, invhist_costmethod, SUM(invhist_invqty) AS qty FROM invhist WHERE ((invhist_itemsite_id=pItemsiteid) AND (invhist_transdate::DATE BETWEEN _startDate AND _endDate)) GROUP BY invhist_transtype, invhist_costmethod LOOP DELETE FROM invhist WHERE ((invhist_transdate::DATE BETWEEN _startDate AND _endDate) AND (invhist_transtype=_invhist.invhist_transtype) AND (invhist_itemsite_id=pItemsiteid)); INSERT INTO invhist ( invhist_itemsite_id, invhist_transdate, invhist_transtype, invhist_invqty, invhist_qoh_before, invhist_qoh_after, invhist_invuom, invhist_user, invhist_ordnumber, invhist_costmethod, invhist_value_before, invhist_value_after, invhist_series ) VALUES ( pItemsiteid, _endDate, _invhist.invhist_transtype, _invhist.qty, 0, 0, _itemuom, getEffectiveXtUser(), 'Summary', _invhist.invhist_costmethod, 0, 0, _itemlocSeries ); _transCounter := (_transCounter + 1); END LOOP; RETURN _transCounter; END; $_$; ADROP FUNCTION public.summarizetransactions(integer, date, date); publicadminfalse84623A125579413summdemand(integer, integer)FUNCTIONCREATE FUNCTION summdemand(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pCalitemid ALIAS FOR $2; _value NUMERIC; BEGIN SELECT summDemand(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value; RETURN _value; END; $_$; 3DROP FUNCTION public.summdemand(integer, integer); publicadminfalse84623@125579414summdemand(integer, date, date)FUNCTIONgCREATE FUNCTION summdemand(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _value NUMERIC; BEGIN SELECT SUM(wo_qtyord - wo_qtyrcv) INTO _value FROM wo WHERE ( (wo_itemsite_id=pItemsiteid) AND (wo_status IN ('R', 'I')) AND (wo_startdate::DATE BETWEEN pStartDate AND pEndDate) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; 6DROP FUNCTION public.summdemand(integer, date, date); publicadminfalse46238C125579415summprod(integer, integer)FUNCTIONCREATE FUNCTION summprod(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pCalitemid ALIAS FOR $2; _value NUMERIC; BEGIN SELECT summProd(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value; RETURN _value; END; $_$; 1DROP FUNCTION public.summprod(integer, integer); publicadminfalse46238B125579416summprod(integer, date, date)FUNCTIONwCREATE FUNCTION summprod(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _value NUMERIC; BEGIN SELECT SUM(invhist_invqty) INTO _value FROM invhist WHERE ( (invhist_itemsite_id=pItemsiteid) AND (invhist_transtype IN ('RM', 'RB')) AND (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; 4DROP FUNCTION public.summprod(integer, date, date); publicadminfalse46238E125579417summtransa(integer, integer)FUNCTIONCREATE FUNCTION summtransa(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pCalitemid ALIAS FOR $2; _value NUMERIC; BEGIN SELECT summTransA(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value; RETURN _value; END; $_$; 3DROP FUNCTION public.summtransa(integer, integer); publicadminfalse84623D125579418summtransa(integer, date, date)FUNCTIONwCREATE FUNCTION summtransa(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _value NUMERIC; BEGIN SELECT SUM(invhist_invqty) INTO _value FROM invhist WHERE ((invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) AND (invhist_transtype IN ('AD', 'CC')) AND (invhist_itemsite_id=pItemsiteid)); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; 6DROP FUNCTION public.summtransa(integer, date, date); publicadminfalse46238G125579419summtransc(integer, integer)FUNCTIONCREATE FUNCTION summtransc(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pCalitemid ALIAS FOR $2; _value NUMERIC; BEGIN SELECT summTransC(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value; RETURN _value; END; $_$; 3DROP FUNCTION public.summtransc(integer, integer); publicadminfalse84623F125579420summtransc(integer, date, date)FUNCTIONqCREATE FUNCTION summtransc(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDAte ALIAS FOR $3; _value NUMERIC; BEGIN SELECT SUM(invhist_invqty) INTO _value FROM invhist WHERE ((invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) AND (invhist_transtype IN ('SI')) AND (invhist_itemsite_id=pItemsiteid)); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; 6DROP FUNCTION public.summtransc(integer, date, date); publicadminfalse84623I125579421summtransi(integer, integer)FUNCTIONCREATE FUNCTION summtransi(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pCalitemid ALIAS FOR $2; _value NUMERIC; BEGIN SELECT summTransI(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value; RETURN _value; END; $_$; 3DROP FUNCTION public.summtransi(integer, integer); publicadminfalse46238H125579422summtransi(integer, date, date)FUNCTIONwCREATE FUNCTION summtransi(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _value NUMERIC; BEGIN SELECT SUM(invhist_invqty) INTO _value FROM invhist WHERE ((invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) AND (invhist_transtype IN ('IM', 'IC')) AND (invhist_itemsite_id=pItemsiteid)); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; 6DROP FUNCTION public.summtransi(integer, date, date); publicadminfalse84623K125579423summtransr(integer, integer)FUNCTIONCREATE FUNCTION summtransr(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pCalitemid ALIAS FOR $2; _value NUMERIC; BEGIN SELECT summTransR(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value; RETURN _value; END; $_$; 3DROP FUNCTION public.summtransr(integer, integer); publicadminfalse46238J125579424summtransr(integer, date, date)FUNCTION~CREATE FUNCTION summtransr(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _value NUMERIC; BEGIN SELECT SUM(invhist_invqty) INTO _value FROM invhist WHERE ((invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) AND (invhist_transtype IN ('RM', 'RP', 'RX')) AND (invhist_itemsite_id=pItemsiteid) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; 6DROP FUNCTION public.summtransr(integer, date, date); publicadminfalse46238M125579425summtranss(integer, integer)FUNCTIONCREATE FUNCTION summtranss(pitemsiteid integer, pcalitemid integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pCalitemid ALIAS FOR $2; _value NUMERIC; BEGIN SELECT summTransS(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value; RETURN _value; END; $_$; JDROP FUNCTION public.summtranss(pitemsiteid integer, pcalitemid integer); publicadminfalse46238L125579426summtranss(integer, date, date)FUNCTIONCREATE FUNCTION summtranss(pitemsiteid integer, pstartdate date, penddate date) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _value NUMERIC; BEGIN SELECT SUM( CASE WHEN (invhist_transtype = 'RS') THEN (invhist_invqty * -1) ELSE (invhist_invqty) END ) INTO _value FROM invhist WHERE ( (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) AND (invhist_transtype IN ('SC', 'SH', 'SV', 'RS')) AND (invhist_ordtype != 'TO') AND (invhist_itemsite_id=pItemsiteid) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $$; VDROP FUNCTION public.summtranss(pitemsiteid integer, pstartdate date, penddate date); publicadminfalse84623O125579427summtranst(integer, integer)FUNCTIONCREATE FUNCTION summtranst(integer, integer) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pCalitemid ALIAS FOR $2; _value NUMERIC; BEGIN SELECT summTransT(pItemsiteid, findPeriodStart(pCalitemid), findPeriodEnd(pCalitemid)) INTO _value; RETURN _value; END; $_$; 3DROP FUNCTION public.summtranst(integer, integer); publicadminfalse84623N125579428summtranst(integer, date, date)FUNCTIONCREATE FUNCTION summtranst(integer, date, date) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pStartDate ALIAS FOR $2; pEndDate ALIAS FOR $3; _value NUMERIC; BEGIN SELECT SUM( CASE WHEN (invhist_transtype = 'TS') THEN (invhist_invqty * -1) ELSE (invhist_invqty) END ) INTO _value FROM invhist WHERE ( (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) AND (invhist_transtype IN ('TS', 'TR', 'TW')) AND (invhist_itemsite_id=pItemsiteid) ); IF (_value IS NULL) THEN _value := 0; END IF; RETURN _value; END; $_$; 6DROP FUNCTION public.summtranst(integer, date, date); publicadminfalse46238P125587099 taxassignments(integer, integer)FUNCTIONCREATE FUNCTION taxassignments(integer, integer) RETURNS SETOF taxassign LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTaxZoneId ALIAS FOR $1; pTaxTypeId ALIAS FOR $2; _row taxassign%ROWTYPE; _qry text; _x RECORD; _y RECORD; _z RECORD; BEGIN _qry = 'SELECT DISTINCT COALESCE(taxass_taxzone_id, -1) AS taxass_taxzone_id, COALESCE(taxass_taxtype_id, -1) AS taxass_taxtype_id, '; _qry = _qry || 'taxzone_code, taxtype_name FROM taxass LEFT OUTER JOIN taxzone ON (taxass_taxzone_id=taxzone_id) '; _qry = _qry || 'LEFT OUTER JOIN taxtype ON (taxass_taxtype_id=taxtype_id) '; IF ((pTaxZoneId > 0) OR (pTaxTypeId > 0)) THEN _qry := _qry || ' WHERE '; IF (pTaxZoneId > 0) THEN _qry := _qry || ' (taxass_taxzone_id = ' || pTaxZoneId ||')'; IF (pTaxTypeId > 0) THEN _qry := _qry || ' AND '; END IF; END IF; IF (pTaxTypeId > 0) THEN _qry := _qry || ' (taxass_taxtype_id = ' || pTaxTypeId || ')'; END IF; END IF; --This first query gets all the distinct tax zone and type groupings as if it were its own table. --This allows us to have a level 0 record as pictured in Tax Assignments window that code assignements will --Subordinate to. FOR _x IN EXECUTE _qry LOOP --Map values to _row here _row.taxassign_taxzone_id = _x.taxass_taxzone_id; _row.taxassign_taxtype_id = _x.taxass_taxtype_id; _row.taxassign_level = 0; _row.taxassign_zone_code = _x.taxzone_code; _row.taxassign_type_descrip = _x.taxtype_name; _row.taxassign_taxclass_code = ''; _row.taxassign_taxclass_sequence = NULL; RETURN NEXT _row; --so we get a level tax zone/type 0 record. -- Now get all the tax code assignments that belong to this Zone and Type pair FOR _y IN SELECT taxass_id, COALESCE(taxzone_id, -1) AS taxzone_id, tax_id, tax_code, tax_descrip, COALESCE(taxtype_id, -1) AS taxtype_id, taxzone_code, taxtype_descrip, taxclass_code, COALESCE(taxclass_sequence, 0) AS taxclass_sequence FROM taxass JOIN tax LEFT OUTER JOIN taxclass ON (tax_taxclass_id = taxclass_id) ON (taxass_tax_id = tax_id) LEFT OUTER JOIN taxzone ON (taxass_taxzone_id = taxzone_id) LEFT OUTER JOIN taxtype ON (taxass_taxtype_id = taxtype_id) WHERE COALESCE(taxass_taxzone_id, -1) = _x.taxass_taxzone_id AND COALESCE(taxass_taxtype_id, -1) = _x.taxass_taxtype_id LOOP --Map results to _row _row.taxassign_taxzone_id = _y.taxzone_id; _row.taxassign_taxtype_id = _y.taxtype_id; _row.taxassign_level = 1; _row.taxassign_zone_code = _y.tax_code; _row.taxassign_type_descrip = _y.tax_descrip; _row.taxassign_taxclass_code = _y.taxclass_code; _row.taxassign_taxclass_sequence = _y.taxclass_sequence; RETURN NEXT _row; --to get code detail record; FOR _z IN SELECT * FROM getsubtax(_y.tax_id, 1) --a new recursive function described above LOOP --Map results to _row _row.taxassign_taxzone_id = _y.taxzone_id; _row.taxassign_taxtype_id = _y.taxtype_id; _row.taxassign_level = _z.subtax_taxcode_level; _row.taxassign_zone_code = _z.subtax_taxcode_code; _row.taxassign_type_descrip = _z.subtax_taxcode_descrip; _row.taxassign_taxclass_code = _y.taxclass_code; _row.taxassign_taxclass_sequence = _y.taxclass_sequence; RETURN NEXT _row; END LOOP; END LOOP; END LOOP; END; $_$; 7DROP FUNCTION public.taxassignments(integer, integer); publicadminfalse846234267Q125579430thawaccountingperiod(integer)FUNCTIONCREATE FUNCTION thawaccountingperiod(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pPeriodid ALIAS FOR $1; _r RECORD; BEGIN -- Check to make sure that the period is frozen IF ( ( SELECT (NOT period_freeze) FROM period WHERE (period_id=pPeriodid) ) ) THEN RETURN -2; END IF; -- Check to make sure that the period is not closed IF ( ( SELECT (period_closed) FROM period WHERE (period_id=pPeriodid) ) ) THEN RETURN -1; END IF; -- Reset the period_freeze flag UPDATE period SET period_freeze=FALSE WHERE (period_id=pPeriodid); -- Post any unposted G/L Transactions into the period FOR _r IN SELECT DISTINCT gltrans_sequence FROM gltrans, accnt, period WHERE ( (gltrans_accnt_id=accnt_id) AND (NOT gltrans_posted) AND (gltrans_date BETWEEN period_start AND period_end) AND (period_id=pPeriodid) ) LOOP PERFORM postIntoTrialBalance(_r.gltrans_sequence); END LOOP; RETURN pPeriodid; END; $_$; 4DROP FUNCTION public.thawaccountingperiod(integer); publicadminfalse84623125579431thawitemsite(integer)FUNCTIONECREATE FUNCTION thawitemsite(pitemsiteid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _qoh NUMERIC := 0; _value NUMERIC := 0; _itemlocid INTEGER; _itemloc RECORD; _invhist RECORD; _coarse RECORD; _fine RECORD; BEGIN IF ( SELECT itemsite_freeze FROM itemsite WHERE (itemsite_id=pItemsiteid) ) THEN SELECT invhist_id INTO _invhist FROM invhist WHERE ( (invhist_itemsite_id=pItemsiteid) AND (NOT invhist_posted) ) LIMIT 1; IF (NOT FOUND) THEN -- no inventory transactions to thaw, update itemsite and return UPDATE itemsite SET itemsite_freeze=FALSE WHERE (itemsite_id=pItemsiteid); RETURN pItemsiteid; END IF; -- Run through any invdetail if this itemsite is still MLC and/or Lot/Serial IF ( SELECT ( (itemsite_loccntrl) OR (itemsite_controlmethod IN ('L', 'S')) ) FROM itemsite WHERE (itemsite_id=pItemsiteid) ) THEN -- Grab all of the itemsite/location/lot/serial combinations -- that have unposted detail FOR _coarse IN SELECT DISTINCT invdetail_location_id, invdetail_ls_id, invdetail_expiration, invdetail_warrpurc FROM invhist, invdetail WHERE ( (invdetail_invhist_id=invhist_id) AND (NOT invhist_posted) AND (invhist_itemsite_id=pItemsiteid) ) ORDER BY invdetail_location_id, invdetail_ls_id LOOP -- Cache the initial qty of the itemloc specified by the -- itemsite/location/lot/serial SELECT itemloc_id, itemloc_qty INTO _itemloc FROM itemloc WHERE ( (itemloc_itemsite_id=pItemsiteid) AND (itemloc_location_id=_coarse.invdetail_location_id) AND (COALESCE(itemloc_ls_id,-1)=COALESCE(_coarse.invdetail_ls_id,-1)) AND (COALESCE(itemloc_expiration,endOfTime())=COALESCE(_coarse.invdetail_expiration,endOfTime())) AND (COALESCE(itemloc_warrpurc,endOfTime())=COALESCE(_coarse.invdetail_warrpurc,endOfTime())) ); -- If the itemloc in question cannot be found, create it IF (NOT FOUND) THEN SELECT NEXTVAL('itemloc_itemloc_id_seq') INTO _itemlocid; INSERT INTO itemloc ( itemloc_id, itemloc_itemsite_id, itemloc_location_id, itemloc_ls_id, itemloc_qty, itemloc_expiration ) VALUES ( _itemlocid, pItemsiteid, _coarse.invdetail_location_id, _coarse.invdetail_ls_id, 0, endOfTime() ); _qoh := 0.0; ELSE _itemlocid := _itemloc.itemloc_id; _qoh := _itemloc.itemloc_qty; END IF; -- Now step through each unposted invdetail record for a given -- itemsite/location/lot/serial FOR _fine IN SELECT invdetail_id, invdetail_qty FROM invhist, invdetail WHERE ( (invdetail_invhist_id=invhist_id) AND (NOT invhist_posted) AND (invhist_itemsite_id=pItemsiteid) AND (invdetail_location_id=_coarse.invdetail_location_id) AND (COALESCE(invdetail_ls_id,-1)=COALESCE(_coarse.invdetail_ls_id,-1)) AND (COALESCE(invdetail_expiration,endOfTime())=COALESCE(_coarse.invdetail_expiration,endOfTime())) AND (COALESCE(invdetail_warrpurc,endOfTime())=COALESCE(_coarse.invdetail_warrpurc,endOfTime())) ) ORDER BY invhist_transdate LOOP -- Update the running qoh fields in the detail record UPDATE invdetail SET invdetail_qty_before = _qoh, invdetail_qty_after = (_qoh + invdetail_qty) WHERE (invdetail_id=_fine.invdetail_id); -- Update the running qoh _qoh = (_qoh + _fine.invdetail_qty); END LOOP; -- If the running qoh end up at 0, delete the itemloc in question IF (_qoh = 0) THEN DELETE FROM itemloc WHERE (itemloc_id=_itemlocid); -- Otherwise, update the itemloc in question with the resultant qty ELSE UPDATE itemloc SET itemloc_qty=_qoh WHERE (itemloc_id=_itemlocid); END IF; END LOOP; END IF; -- Cache the inital qoh of the itemsite SELECT itemsite_qtyonhand, itemsite_value INTO _qoh, _value FROM itemsite WHERE (itemsite_id=pItemsiteid); -- We have to un-freeze the itemsite before update-ing its QOH -- so that that itemsite trigger won't block the QOH update. -- Also so the invhist trigger won't block the posted update. UPDATE itemsite SET itemsite_freeze=FALSE WHERE (itemsite_id=pItemsiteid); FOR _invhist IN SELECT invhist_id, invhist_qoh_before, invhist_qoh_after, invhist_value_before, invhist_value_after FROM invhist WHERE((invhist_itemsite_id=pItemsiteid) AND (NOT invhist_posted)) ORDER BY invhist_transdate LOOP UPDATE invhist SET invhist_qoh_before = _qoh, invhist_qoh_after = ( _qoh + _invhist.invhist_qoh_after - _invhist.invhist_qoh_before ), invhist_value_before = _value, invhist_value_after = ( _value + _invhist.invhist_value_after - _invhist.invhist_value_before ), invhist_posted = TRUE WHERE (invhist_id=_invhist.invhist_id); _qoh := (_qoh + (_invhist.invhist_qoh_after - _invhist.invhist_qoh_before)); _value := (_value + (_invhist.invhist_value_after - _invhist.invhist_value_before)); END LOOP; UPDATE itemsite SET itemsite_qtyonhand = _qoh, itemsite_value = CASE WHEN ((itemsite_costmethod='A') AND (_value < 0.0)) THEN 0.0 ELSE _value END WHERE(itemsite_id=pItemsiteid); END IF; RETURN pItemsiteid; END; $$; 8DROP FUNCTION public.thawitemsite(pitemsiteid integer); publicadminfalse84623125979433todoitemTABLECREATE TABLE todoitem ( todoitem_id integer NOT NULL, todoitem_name text NOT NULL, todoitem_description text, todoitem_incdt_id integer, todoitem_creator_username text DEFAULT geteffectivextuser() NOT NULL, todoitem_status character(1), todoitem_active boolean DEFAULT true NOT NULL, todoitem_start_date date, todoitem_due_date date, todoitem_assigned_date date, todoitem_completed_date date, todoitem_seq integer DEFAULT 0 NOT NULL, todoitem_notes text, todoitem_crmacct_id integer, todoitem_ophead_id integer, todoitem_owner_username text, todoitem_priority_id integer, todoitem_username text, todoitem_recurring_todoitem_id integer, todoitem_cntct_id integer ); DROP TABLE public.todoitem; publicadminfalse6094609560968[&00TABLE todoitemCOMMENT2COMMENT ON TABLE todoitem IS 'To-Do List items.'; publicadminfalse212\&00.COLUMN todoitem.todoitem_recurring_todoitem_idCOMMENTCOMMENT ON COLUMN todoitem.todoitem_recurring_todoitem_id IS 'The first todoitem record in the series if this is a recurring To-Do item. If the todoitem_recurring_todoitem_id is the same as the todoitem_id, this record is the first in the series.'; publicadminfalse212]&00todoitemACLREVOKE ALL ON TABLE todoitem FROM PUBLIC; REVOKE ALL ON TABLE todoitem FROM admin; GRANT ALL ON TABLE todoitem TO admin; GRANT ALL ON TABLE todoitem TO xtrole; publicadminfalse212R125579442 todoitem()FUNCTION1CREATE FUNCTION todoitem() RETURNS SETOF todoitem LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row todoitem%ROWTYPE; _priv TEXT; _grant BOOLEAN; BEGIN -- This query will give us the most permissive privilege the user has been granted SELECT privilege, granted INTO _priv, _grant FROM privgranted WHERE privilege IN ('MaintainAllToDoItems','ViewAllToDoItems','MaintainPersonalToDoItems','ViewPersonalToDoItems') ORDER BY granted DESC, sequence LIMIT 1; -- If have an 'All' privilege return all results IF (_priv ~ 'All' AND _grant) THEN FOR _row IN SELECT * FROM todoitem LOOP RETURN NEXT _row; END LOOP; -- Otherwise if have any other grant, must be personal privilege. ELSIF (_grant) THEN FOR _row IN SELECT * FROM todoitem WHERE getEffectiveXtUser() IN (todoitem_owner_username, todoitem_username) LOOP RETURN NEXT _row; END LOOP; END IF; RETURN; END; $$; !DROP FUNCTION public.todoitem(); publicadminfalse288346238^&00FUNCTION todoitem()COMMENTxCOMMENT ON FUNCTION todoitem() IS 'A table function that returns To Do Items results according to privilege settings.'; publicadminfalse2130S125579443todoitemmove(integer, integer)FUNCTIONCREATE FUNCTION todoitemmove(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ptodoItemId ALIAS FOR $1; pHowFar ALIAS FOR $2; -- -1 moves toward front of list, +1 toward back _howFar INTEGER := pHowFar; _username TEXT; _currseq INTEGER; BEGIN SELECT todoitem_username, todoitem_seq INTO _username, _currseq FROM todoitem WHERE todoitem_id = ptodoItemId; IF NOT FOUND THEN RETURN -1; END IF; IF (_currseq + pHowFar <= 0) THEN _howFar = 1 - _currseq; -- move to beginning END IF; UPDATE todoitem SET todoitem_seq=todoitem_seq - _howFar WHERE todoitem_seq >= _currseq + _howFar AND todoitem_id != ptodoItemId AND todoitem_username = _username AND todoitem_status != 'C'; UPDATE todoitem SET todoitem_seq=_currseq + _howFar WHERE todoitem_id = ptodoItemId; RETURN 0; END; $_$; 5DROP FUNCTION public.todoitemmove(integer, integer); publicadminfalse84623T125579444todoitemmovedown(integer)FUNCTIONWCREATE FUNCTION todoitemmovedown(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ptodoItemId ALIAS FOR $1; BEGIN RETURN todoItemMove(ptodoItemId, 1); -- move toward end of list END; $_$; 0DROP FUNCTION public.todoitemmovedown(integer); publicadminfalse84623U125579445todoitemmoveup(integer)FUNCTIONWCREATE FUNCTION todoitemmoveup(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ptodoItemId ALIAS FOR $1; BEGIN RETURN todoItemMove(ptodoItemId, -1); -- move toward front of list END; $_$; .DROP FUNCTION public.todoitemmoveup(integer); publicadminfalse462381255794475togglebankreccleared(integer, text, integer, numeric)FUNCTIONCREATE FUNCTION togglebankreccleared(integer, text, integer, numeric) RETURNS boolean LANGUAGE plpgsql AS $_$ DECLARE pBankrecid ALIAS FOR $1; pSource ALIAS FOR $2; pSourceid ALIAS FOR $3; pCurrrate ALIAS FOR $4; _cleared BOOLEAN; _r RECORD; BEGIN SELECT bankrecitem_id, bankrecitem_cleared INTO _r FROM bankrecitem WHERE ( (bankrecitem_bankrec_id=pBankrecid) AND (bankrecitem_source=pSource) AND (bankrecitem_source_id=pSourceid) ); IF ( NOT FOUND ) THEN _cleared := TRUE; INSERT INTO bankrecitem (bankrecitem_bankrec_id, bankrecitem_source, bankrecitem_source_id, bankrecitem_cleared, bankrecitem_curr_rate) VALUES (pBankrecid, pSource, pSourceid, _cleared, pCurrrate); ELSE _cleared := (NOT _r.bankrecitem_cleared); UPDATE bankrecitem SET bankrecitem_cleared=_cleared, bankrecitem_curr_rate=pCurrrate WHERE (bankrecitem_id=_r.bankrecitem_id); END IF; RETURN _cleared; END; $_$; LDROP FUNCTION public.togglebankreccleared(integer, text, integer, numeric); publicadminfalse46238V125579448>togglebankreccleared(integer, text, integer, numeric, numeric)FUNCTIONCREATE FUNCTION togglebankreccleared(pbankrecid integer, psource text, psourceid integer, pcurrrate numeric, pbaseamount numeric) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN toggleBankrecCleared(pBankrecid, pSource, pSourceid, pCurrrate, pBaseAmount, NULL); END; $$; DROP FUNCTION public.togglebankreccleared(pbankrecid integer, psource text, psourceid integer, pcurrrate numeric, pbaseamount numeric); publicadminfalse46238W125587101Dtogglebankreccleared(integer, text, integer, numeric, numeric, date)FUNCTIONGCREATE FUNCTION togglebankreccleared(pbankrecid integer, psource text, psourceid integer, pcurrrate numeric, pbaseamount numeric, pdate date) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _cleared BOOLEAN; _r RECORD; BEGIN SELECT bankrecitem_id, bankrecitem_cleared INTO _r FROM bankrecitem WHERE ( (bankrecitem_bankrec_id=pBankrecid) AND (bankrecitem_source=pSource) AND (bankrecitem_source_id=pSourceid) ); IF ( NOT FOUND ) THEN _cleared := TRUE; INSERT INTO bankrecitem (bankrecitem_bankrec_id, bankrecitem_source, bankrecitem_source_id, bankrecitem_cleared, bankrecitem_curr_rate, bankrecitem_amount, bankrecitem_effdate) VALUES (pBankrecid, pSource, pSourceid, _cleared, CASE WHEN (fetchMetricValue('CurrencyExchangeSense') = 1) THEN ROUND(1.0 / pCurrrate, 8) ELSE ROUND(pCurrrate,8) END, CASE WHEN (fetchMetricValue('CurrencyExchangeSense') = 1) THEN ROUND(pBaseAmount * ROUND(1.0 / pCurrrate,8),2) ELSE ROUND(pBaseAmount * ROUND(pCurrrate,8),2) END, pDate); ELSE _cleared := FALSE; DELETE FROM bankrecitem WHERE bankrecitem_id = _r.bankrecitem_id; END IF; RETURN _cleared; END; $$; DROP FUNCTION public.togglebankreccleared(pbankrecid integer, psource text, psourceid integer, pcurrrate numeric, pbaseamount numeric, pdate date); publicadminfalse84623X125579449#togglebomitemcost(integer, boolean)FUNCTIONCREATE FUNCTION togglebomitemcost(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pBomitemid ALIAS FOR $1; pEnabled ALIAS FOR $2; BEGIN IF (pEnabled) THEN INSERT INTO bomitemcost (bomitemcost_bomitem_id, bomitemcost_costelem_id, bomitemcost_lowlevel, bomitemcost_stdcost, bomitemcost_posted, bomitemcost_actcost, bomitemcost_updated, bomitemcost_curr_id) SELECT bomitem_id, itemcost_costelem_id, itemcost_lowlevel, itemcost_stdcost, itemcost_posted, itemcost_actcost, itemcost_updated, itemcost_curr_id FROM bomitem JOIN itemcost ON (itemcost_item_id=bomitem_item_id) WHERE (bomitem_id=pBomitemid); ELSE DELETE FROM bomitemcost WHERE (bomitemcost_bomitem_id=pBomitemid); END IF; RETURN 0; END; $_$; :DROP FUNCTION public.togglebomitemcost(integer, boolean); publicadminfalse84623Y125579450tonumeric(text, numeric)FUNCTIONCREATE FUNCTION tonumeric(text, numeric) RETURNS numeric LANGUAGE plpgsql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pText ALIAS FOR $1; pDefault ALIAS FOR $2; BEGIN IF (isNumeric(pText)) THEN RETURN TO_NUMBER(pText, '999999999999'); ELSE RETURN pDefault; END IF; END; $_$; /DROP FUNCTION public.tonumeric(text, numeric); publicadminfalse46238[125579451 transitwhs()FUNCTIONnCREATE FUNCTION transitwhs() RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _id INTEGER; BEGIN _id = fetchMetricValue('TransitWarehouse'); IF (_id IS NOT NULL AND EXISTS(SELECT warehous_id FROM whsinfo WHERE (warehous_id=_id)) ) THEN RETURN _id; END IF; SELECT warehous_id INTO _id FROM whsinfo WHERE warehous_transit; IF (NOT FOUND) THEN _id := NEXTVAL('warehous_warehous_id_seq'); INSERT INTO whsinfo ( warehous_id, warehous_code, warehous_descrip, --warehous_fob, warehous_active, --warehous_counttag_prefix, --warehous_counttag_number, --warehous_bol_prefix, --warehous_bol_number, warehous_shipping, warehous_useslips, warehous_usezones, --warehous_aislesize, --warehous_aislealpha, --warehous_racksize, --warehous_rackalpha, --warehous_binsize, --warehous_binalpha, --warehous_locationsize, --warehous_locationalpha, warehous_enforcearbl, warehous_default_accnt_id, --warehous_shipping_commission, --warehous_cntct_id, --warehous_addr_id, warehous_taxzone_id ) VALUES ( _id, 'TRANSIT', 'Intermediate Warehouse for Inter-Warehouse Transfers', --text, TRUE, --text, --integer, --text, --integer, TRUE, FALSE, FALSE, --integer, --boolean, --integer, --boolean, --integer, --boolean, --integer, --boolean, FALSE, fetchMetricValue('UnassignedAccount'), --numeric(8,4) default 0.00, --integer, --integer, NULL ); END IF; PERFORM setMetric('TransitWarehouse', _id); RETURN _id; END; $$; #DROP FUNCTION public.transitwhs(); publicadminfalse84623\125579452transtype(text, integer)FUNCTIONCREATE FUNCTION transtype(text, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTransType ALIAS FOR $1; pTargetType ALIAS FOR $2; BEGIN IF (pTargetType = 255) THEN RETURN TRUE; ELSIF (pTargetType = 1) THEN RETURN receipts(pTransType); ELSIF (pTargetType = 2) THEN RETURN issues(pTransType); ELSIF (pTargetType = 4) THEN RETURN shipments(pTransType); ELSIF (pTargetType = 8) THEN RETURN adjustments(pTransType); ELSIF (pTargetType = 16) THEN RETURN transfers(pTransType); ELSIF (pTargetType = 32) THEN RETURN scraps(pTransType); ELSE RETURN TRUE; END IF; END; $_$; /DROP FUNCTION public.transtype(text, integer); publicadminfalse84623]125579453trylock(integer, integer)FUNCTIONCREATE FUNCTION trylock(integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pKey1 ALIAS FOR $1; pKey2 ALIAS FOR $2; _pid integer; BEGIN /* The standard try lock ignores locks made by the current user in same session. Check for ANY lock on this id, whether by this user or not */ SELECT pid INTO _pid FROM pg_locks WHERE ((classid=pKey1) AND (objid=pKey2) AND (objsubid=2)); IF (FOUND) THEN RETURN false; ELSE RETURN pg_try_advisory_lock(pKey1,pKey2); END IF; END; $_$; 0DROP FUNCTION public.trylock(integer, integer); publicadminfalse46238^125579454undomerge(text, text, integer)FUNCTIONfCREATE FUNCTION undomerge(text, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSchema ALIAS FOR $1; pTable ALIAS FOR $2; pId ALIAS FOR $3; _qry TEXT; _r RECORD; _result INTEGER; BEGIN FOR _r IN SELECT * FROM mrgundo WHERE mrgundo_base_schema = pSchema AND mrgundo_base_table = pTable AND mrgundo_base_id = pId AND mrgundo_col IS NOT NULL -- NULL mrgundo_col signals a row to delete on purge LOOP IF (_r.mrgundo_value IS NULL) THEN _qry := 'UPDATE ' || quote_ident(_r.mrgundo_schema) || '.' || quote_ident(_r.mrgundo_table) || ' SET ' || quote_ident(_r.mrgundo_col) || '= NULL WHERE (' || _r.mrgundo_pkey_col || '=' || _r.mrgundo_pkey_id || ');'; ELSE _qry := 'UPDATE ' || quote_ident(_r.mrgundo_schema) || '.' || quote_ident(_r.mrgundo_table) || ' SET ' || quote_ident(_r.mrgundo_col) || '= CAST(' || quote_literal(_r.mrgundo_value) || ' AS ' || quote_ident(_r.mrgundo_type) || ') WHERE (' || _r.mrgundo_pkey_col || '=' || _r.mrgundo_pkey_id || ');'; END IF; EXECUTE _qry; END LOOP; DELETE FROM mrgundo WHERE mrgundo_base_schema = pSchema AND mrgundo_base_table = pTable AND mrgundo_base_id = pId; GET DIAGNOSTICS _result = ROW_COUNT; RETURN _result; END; $_$; 5DROP FUNCTION public.undomerge(text, text, integer); publicadminfalse84623_125579455unreleasepurchaseorder(integer)FUNCTIONCREATE FUNCTION unreleasepurchaseorder(ppoheadid integer) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN IF ( ( SELECT (COUNT(*) > 0) FROM poitem LEFT OUTER JOIN recv ON (recv_order_type='PO' AND recv_orderitem_id=poitem_id) WHERE ( (poitem_pohead_id=pPoheadid) AND ( (poitem_status='C') OR (poitem_qty_received > 0.0) OR (poitem_qty_returned > 0.0) OR (poitem_qty_vouchered > 0.0) OR (recv_id IS NOT NULL) ) ) ) ) THEN RETURN -1; END IF; IF ( ( SELECT (pohead_status='O') FROM pohead WHERE (pohead_id=pPoheadid) ) ) THEN --update status and erase the date that the order was released on UPDATE pohead SET pohead_status='U', pohead_released = NULL WHERE (pohead_id=pPoheadid); END IF; --update status and erase the duedates at release UPDATE poitem SET poitem_status='U', poitem_rlsd_duedate = NULL WHERE (poitem_pohead_id=pPoheadid); RETURN 1; END; $$; @DROP FUNCTION public.unreleasepurchaseorder(ppoheadid integer); publicadminfalse84623`125579456uomusedforitem(integer)FUNCTION CREATE FUNCTION uomusedforitem(integer) RETURNS SETOF uom LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pitemid ALIAS FOR $1; _row uom%ROWTYPE; BEGIN FOR _row IN SELECT DISTINCT * FROM uom WHERE uom_id IN ( SELECT bomitem_uom_id AS uom_id FROM bomitem WHERE (bomitem_item_id=pitemid) UNION SELECT cmitem_qty_uom_id FROM cmitem, itemsite WHERE ((cmitem_itemsite_id=itemsite_id) AND (itemsite_item_id=pitemid)) UNION SELECT cmitem_price_uom_id FROM cmitem, itemsite WHERE ((cmitem_itemsite_id=itemsite_id) AND (itemsite_item_id=pitemid)) UNION SELECT coitem_qty_uom_id FROM coitem, itemsite WHERE ((coitem_itemsite_id=itemsite_id) AND (itemsite_item_id=pitemid)) UNION SELECT coitem_price_uom_id FROM coitem, itemsite WHERE ((coitem_itemsite_id=itemsite_id) AND (itemsite_item_id=pitemid)) UNION SELECT invcitem_qty_uom_id FROM invcitem WHERE ((invcitem_item_id=pitemid)) UNION SELECT invcitem_price_uom_id FROM invcitem WHERE ((invcitem_item_id=pitemid)) UNION SELECT ipsitem_qty_uom_id FROM ipsiteminfo WHERE (ipsitem_item_id=pitemid) UNION SELECT ipsitem_price_uom_id FROM ipsiteminfo WHERE (ipsitem_item_id=pitemid) UNION SELECT quitem_qty_uom_id FROM quitem, itemsite WHERE ((quitem_itemsite_id=itemsite_id) AND (itemsite_item_id=pitemid)) UNION SELECT quitem_price_uom_id FROM quitem, itemsite WHERE ((quitem_itemsite_id=itemsite_id) AND (itemsite_item_id=pitemid)) UNION SELECT womatl_uom_id FROM womatl, itemsite WHERE ((womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=pitemid)) ) LOOP RETURN NEXT _row; END LOOP; IF (fetchmetricbool('MultiWhs')) THEN FOR _row IN SELECT DISTINCT * FROM uom WHERE uom_id IN ( SELECT rahist_uom_id FROM rahist, itemsite WHERE ((rahist_itemsite_id=itemsite_id) AND (itemsite_item_id=pitemid)) ) LOOP RETURN NEXT _row; END LOOP; END IF; RETURN; END; $_$; .DROP FUNCTION public.uomusedforitem(integer); publicadminfalse277384623a1255794572updateabcclass(text, numeric, numeric, date, date)FUNCTION"CREATE FUNCTION updateabcclass(text, numeric, numeric, date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pClassCodePattern ALIAS FOR $1; pACutoff ALIAS FOR $2; pBCutoff ALIAS FOR $3; pStartDate ALIAS FOR $4; pEndDate ALIAS FOR $5; _result INTEGER; BEGIN SELECT updateABCClass(pClassCodePattern, -1, pACutoff, pBCutoff, pStartDate, pEndDate) INTO _result; RETURN _result; END; $_$; IDROP FUNCTION public.updateabcclass(text, numeric, numeric, date, date); publicadminfalse46238 1255794585updateabcclass(integer, numeric, numeric, date, date)FUNCTIONCREATE FUNCTION updateabcclass(integer, numeric, numeric, date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pClasscodeid ALIAS FOR $1; pACutoff ALIAS FOR $2; pBCutoff ALIAS FOR $3; pStartDate ALIAS FOR $4; pEndDate ALIAS FOR $5; _result INTEGER; BEGIN SELECT updateABCClass(pClassCodeid, -1, pACutoff, pBCutoff, pStartDate, pEndDate) INTO _result; RETURN _result; END; $_$; LDROP FUNCTION public.updateabcclass(integer, numeric, numeric, date, date); publicadminfalse46238Z125579459;updateabcclass(text, integer, numeric, numeric, date, date)FUNCTIONNCREATE FUNCTION updateabcclass(text, integer, numeric, numeric, date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pClassCodePattern ALIAS FOR $1; pWarehousid ALIAS FOR $2; pACutoff ALIAS FOR $3; pBCutoff ALIAS FOR $4; pStartDate ALIAS FOR $5; pEndDate ALIAS FOR $6; _updateCount INTEGER; _totalValue NUMERIC; _cumulativeValue NUMERIC; _itemsite RECORD; BEGIN SELECT COUNT(*) INTO _updateCount FROM itemsite, item, classcode WHERE ( (itemsite_item_id=item_id) AND (item_classcode_id=classcode_id) AND (itemsite_autoabcclass) AND (classcode_code ~ pClassCodePattern) AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) ); IF (_updateCount IS NULL) THEN RETURN 0; ELSE UPDATE itemsite SET itemsite_abcclass='T' FROM item, classcode WHERE ( (itemsite_item_id=item_id) AND (item_classcode_id=classcode_id) AND (itemsite_autoabcclass) AND (classcode_code ~ pClassCodePattern) AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) ); SELECT SUM(ABS(invhist_qoh_before - invhist_qoh_after) * invhist_unitcost) INTO _totalValue FROM invhist, itemsite, item, classcode WHERE ( (invhist_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_classcode_id=classcode_id) AND (invhist_analyze) AND (invhist_transtype ~ '^[IR]') AND (itemsite_autoabcclass) AND (classcode_code ~ pClassCodePattern) AND (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) ); IF ( (_totalValue IS NULL) OR (_totalValue = 0) ) THEN UPDATE itemsite SET itemsite_abcclass='A' WHERE (itemsite_abcclass='T'); ELSE _cumulativeValue := 0; FOR _itemsite IN SELECT itemsite_id, item_number, SUM(ABS(invhist_qoh_before - invhist_qoh_after) * invhist_unitcost) AS value FROM invhist, itemsite, item, classcode WHERE ( (invhist_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_classcode_id=classcode_id) AND (invhist_analyze) AND (invhist_transtype ~ '^[IR]') AND (itemsite_autoabcclass) AND (classcode_code ~ pClassCodePattern) AND (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) ) GROUP BY itemsite_id, item_number ORDER BY value DESC LOOP IF (_itemsite.value IS NOT NULL) THEN _cumulativeValue := _cumulativeValue + _itemsite.value; END IF; IF ((_cumulativeValue / _totalValue) <= pACutoff) THEN UPDATE itemsite SET itemsite_abcclass='A' WHERE (itemsite_id=_itemsite.itemsite_id); ELSE IF ((_cumulativeValue / _totalValue) <= pBCutoff) THEN UPDATE itemsite SET itemsite_abcclass='B' WHERE (itemsite_id=_itemsite.itemsite_id); ELSE UPDATE itemsite SET itemsite_abcclass='C' WHERE (itemsite_id=_itemsite.itemsite_id); END IF; END IF; END LOOP; UPDATE itemsite SET itemsite_abcclass='C' WHERE (itemsite_abcclass='T'); END IF; END IF; RETURN _updateCount; END; $_$; RDROP FUNCTION public.updateabcclass(text, integer, numeric, numeric, date, date); publicadminfalse46238b125579460>updateabcclass(integer, integer, numeric, numeric, date, date)FUNCTION' CREATE FUNCTION updateabcclass(integer, integer, numeric, numeric, date, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pClasscodeid ALIAS FOR $1; pWarehousid ALIAS FOR $2; pACutoff ALIAS FOR $3; pBCutoff ALIAS FOR $4; pStartDate ALIAS FOR $5; pEndDate ALIAS FOR $6; _updateCount INTEGER; _totalValue NUMERIC; _cumulativeValue NUMERIC; _itemsite RECORD; BEGIN SELECT COUNT(*) INTO _updateCount FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND ((item_classcode_id=pClasscodeid) OR (pClasscodeid=-1)) AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) ); IF (_updateCount IS NULL) THEN _updateCount := 0; ELSE UPDATE itemsite SET itemsite_abcclass='T' FROM item WHERE ( (itemsite_item_id=item_id) AND ((item_classcode_id=pClasscodeid) OR (pClasscodeid=-1)) AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) ); SELECT SUM(ABS(invhist_qoh_before - invhist_qoh_after) * invhist_unitcost) INTO _totalValue FROM invhist, itemsite, item WHERE ( (invhist_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (invhist_analyze) AND (invhist_transtype ~ '^[IR]') AND ((item_classcode_id=pClasscodeid) OR (pClasscodeid=-1)) AND (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) ); IF ( (_totalValue IS NULL) OR (_totalValue = 0) ) THEN UPDATE itemsite SET itemsite_abcclass='A' WHERE (itemsite_abcclass='T'); ELSE _cumulativeValue := 0; FOR _itemsite IN SELECT itemsite_id, item_number, SUM(ABS(invhist_qoh_before - invhist_qoh_after) * invhist_unitcost) AS value FROM invhist, itemsite, item WHERE ( (invhist_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (invhist_analyze) AND (invhist_transtype ~ '^[IR]') AND ((item_classcode_id=pClasscodeid) OR (pClasscodeid=-1)) AND (invhist_transdate::DATE BETWEEN pStartDate AND pEndDate) AND ((itemsite_warehous_id=pWarehousid) OR (pWarehousid=-1)) ) GROUP BY itemsite_id, item_number ORDER BY value DESC LOOP IF (_itemsite.value IS NOT NULL) THEN _cumulativeValue := _cumulativeValue + _itemsite.value; END IF; IF ((_cumulativeValue / _totalValue) <= pACutoff) THEN UPDATE itemsite SET itemsite_abcclass='A' WHERE (itemsite_id=_itemsite.itemsite_id); ELSE IF ((_cumulativeValue / _totalValue) <= pBCutoff) THEN UPDATE itemsite SET itemsite_abcclass='B' WHERE (itemsite_id=_itemsite.itemsite_id); ELSE UPDATE itemsite SET itemsite_abcclass='C' WHERE (itemsite_id=_itemsite.itemsite_id); END IF; END IF; END LOOP; UPDATE itemsite SET itemsite_abcclass='C' WHERE (itemsite_abcclass='T'); END IF; END IF; RETURN _updateCount; END; $_$; UDROP FUNCTION public.updateabcclass(integer, integer, numeric, numeric, date, date); publicadminfalse46238c1255794612updatecharassignment(text, integer, integer, text)FUNCTIONCREATE FUNCTION updatecharassignment(text, integer, integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTargetType ALIAS FOR $1; pTargetId ALIAS FOR $2; pCharId ALIAS FOR $3; pValue ALIAS FOR $4; _charassid INTEGER; BEGIN SELECT updateCharAssignment(pTargetType, pTargetId, pCharId, pValue, 0) INTO _charassid; RETURN _charassid; END; $_$; IDROP FUNCTION public.updatecharassignment(text, integer, integer, text); publicadminfalse84623d125579462;updatecharassignment(text, integer, integer, text, numeric)FUNCTIONLCREATE FUNCTION updatecharassignment(text, integer, integer, text, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTargetType ALIAS FOR $1; pTargetId ALIAS FOR $2; pCharId ALIAS FOR $3; pValue ALIAS FOR $4; pPrice ALIAS FOR $5; _charassid INTEGER; _charassprice NUMERIC; _explodedJob BOOLEAN = FALSE; _value TEXT; BEGIN -- Check for Valid Assignment IF (pTargetType='SI') THEN SELECT (item_config AND wo_status != 'O') INTO _explodedJob FROM coitem,itemsite,item,wo WHERE ((coitem_id=pTargetId) AND (itemsite_id=coitem_itemsite_id) AND (item_id=itemsite_item_id) AND (wo_ordtype='S') AND (wo_ordid=coitem_id)); END IF; SELECT charass_id,charass_value INTO _charassid, _value FROM charass WHERE ((charass_target_type=pTargetType) AND (charass_target_id=pTargetId) AND (charass_char_id=pCharId) ) LIMIT 1; IF (FOUND) THEN IF (_explodedJob AND pValue != _value) THEN RAISE EXCEPTION 'Characteristic may not be updated for Configured Item with exploded Work Order.'; ELSIF(COALESCE(pValue, '')!='') THEN UPDATE charass SET charass_value = pValue, charass_price = pPrice WHERE (charass_id=_charassid); ELSE DELETE FROM charass WHERE (charass_id=_charassid); _charassid := 0; END IF; ELSE IF ( (_explodedJob) AND (COALESCE(pValue, '')!='') ) THEN RAISE EXCEPTION 'Characteristics may not be updated for Configured Item with exploded Work Order.'; ELSIF(COALESCE(pValue, '')!='') THEN SELECT nextval('charass_charass_id_seq') INTO _charassid; INSERT INTO charass (charass_id, charass_target_type, charass_target_id, charass_char_id, charass_value, charass_price) VALUES(_charassid, pTargetType, pTargetId, pCharId, pValue, pPrice); ELSE _charassid := 0; END IF; END IF; RETURN _charassid; END; $_$; RDROP FUNCTION public.updatecharassignment(text, integer, integer, text, numeric); publicadminfalse46238e125579463updatecost(integer, numeric)FUNCTION_CREATE FUNCTION updatecost(integer, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemcostid ALIAS FOR $1; pCost ALIAS FOR $2; BEGIN RETURN updateCost(pItemcostid, pCost, baseCurrId()); END; $_$; 3DROP FUNCTION public.updatecost(integer, numeric); publicadminfalse84623f125579464%updatecost(integer, numeric, integer)FUNCTIONCREATE FUNCTION updatecost(integer, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemcostid ALIAS FOR $1; pCost ALIAS FOR $2; pCurrId ALIAS FOR $3; BEGIN IF ( ( SELECT (itemcost_stdcost > 0) FROM itemcost WHERE (itemcost_id=pItemcostid) ) OR (pCost > 0) ) THEN UPDATE itemcost SET itemcost_actcost=pCost, itemcost_updated=CURRENT_DATE, itemcost_curr_id=pCurrId WHERE (itemcost_id=pItemcostid); RETURN pItemcostid; ELSE DELETE FROM itemcost WHERE (itemcost_id=pItemcostid); RETURN -1; END IF; END; $_$; <DROP FUNCTION public.updatecost(integer, numeric, integer); publicadminfalse46238g125579465+updatecost(integer, text, boolean, numeric)FUNCTIONpCREATE FUNCTION updatecost(integer, text, boolean, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE returnVal INTEGER; BEGIN SELECT updateCost($1, $2, $3, $4, baseCurrId()) INTO returnVal; RETURN returnVal; END; $_$; BDROP FUNCTION public.updatecost(integer, text, boolean, numeric); publicadminfalse46238h125579466.updatecost(integer, integer, boolean, numeric)FUNCTIONsCREATE FUNCTION updatecost(integer, integer, boolean, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE returnVal INTEGER; BEGIN SELECT updateCost($1, $2, $3, $4, baseCurrId()) INTO returnVal; RETURN returnVal; END; $_$; EDROP FUNCTION public.updatecost(integer, integer, boolean, numeric); publicadminfalse46238i1255794674updatecost(integer, text, boolean, numeric, integer)FUNCTIONCREATE FUNCTION updatecost(integer, text, boolean, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCosttype ALIAS FOR $2; pLevel ALIAS FOR $3; pCost ALIAS FOR $4; pCurrid ALIAS FOR $5; _cost NUMERIC; _currId INTEGER; _p RECORD; _itemcostid INTEGER; BEGIN IF (pCost IS NULL) THEN _cost = 0; ELSE _cost = pCost; END IF; IF (pCurrId IS NULL) THEN _currId := baseCurrID(); ELSE _currId := pCurrId; END IF; SELECT itemcost_id, itemcost_stdcost INTO _p FROM itemcost, costelem WHERE ( (itemcost_costelem_id=costelem_id) AND (itemcost_item_id=pItemid) AND (itemcost_lowlevel=pLevel) AND (costelem_type=pCosttype) ); IF (NOT FOUND) THEN IF (_cost > 0) THEN SELECT NEXTVAL('itemcost_itemcost_id_seq') INTO _itemcostid; INSERT INTO itemcost ( itemcost_id, itemcost_item_id, itemcost_costelem_id, itemcost_lowlevel, itemcost_stdcost, itemcost_posted, itemcost_actcost, itemcost_updated, itemcost_curr_id ) SELECT _itemcostid, pItemid, costelem_id, pLevel, 0, startOfTime(), _cost, CURRENT_DATE, _currId FROM costelem WHERE (costelem_type=pCosttype); RETURN _itemcostid; ELSE RETURN -1; END IF; ELSIF ( (_p.itemcost_stdcost > 0) OR (_cost > 0) ) THEN UPDATE itemcost SET itemcost_actcost=_cost, itemcost_curr_id = _currId, itemcost_updated=CURRENT_DATE WHERE (itemcost_id=_p.itemcost_id); RETURN _p.itemcost_id; ELSE DELETE FROM itemcost WHERE (itemcost_id=_p.itemcost_id); RETURN -1; END IF; END; $_$; KDROP FUNCTION public.updatecost(integer, text, boolean, numeric, integer); publicadminfalse84623k1255794687updatecost(integer, integer, boolean, numeric, integer)FUNCTIONCREATE FUNCTION updatecost(integer, integer, boolean, numeric, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCostelemid ALIAS FOR $2; pLevel ALIAS FOR $3; pCost ALIAS FOR $4; pCurrid ALIAS FOR $5; _cost NUMERIC; _currId INTEGER; _p RECORD; _itemcostid INTEGER; BEGIN IF (pCost IS NULL) THEN _cost = 0; ELSE _cost = pCost; END IF; IF (pCurrId IS NULL) THEN _currId := baseCurrID(); ELSE _currId := pCurrId; END IF; SELECT itemcost_id, itemcost_stdcost INTO _p FROM itemcost WHERE ((itemcost_costelem_id=pCostelemid) AND (itemcost_item_id=pItemid) AND (itemcost_lowlevel=pLevel) ); IF (NOT FOUND) THEN IF (_cost > 0) THEN SELECT NEXTVAL('itemcost_itemcost_id_seq') INTO _itemcostid; INSERT INTO itemcost ( itemcost_id, itemcost_item_id, itemcost_costelem_id, itemcost_lowlevel, itemcost_stdcost, itemcost_posted, itemcost_actcost, itemcost_updated, itemcost_curr_id ) SELECT _itemcostid, pItemid, costelem_id, pLevel, 0, startOfTime(), _cost, CURRENT_DATE, _currId FROM costelem WHERE (costelem_id=pCostelemid); RETURN _itemcostid; ELSE RETURN -1; END IF; ELSIF ( (_p.itemcost_stdcost > 0) OR (_cost > 0) ) THEN UPDATE itemcost SET itemcost_actcost=_cost, itemcost_curr_id = _currId, itemcost_updated=CURRENT_DATE WHERE (itemcost_id=_p.itemcost_id); RETURN _p.itemcost_id; ELSE DELETE FROM itemcost WHERE (itemcost_id=_p.itemcost_id); RETURN -1; END IF; END; $_$; NDROP FUNCTION public.updatecost(integer, integer, boolean, numeric, integer); publicadminfalse84623U 125587828<updatecreditmemoline(api.creditmemoline, api.creditmemoline)FUNCTIONg CREATE FUNCTION updatecreditmemoline(api.creditmemoline, api.creditmemoline) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNew ALIAS FOR $1; pOld ALIAS FOR $2; _check INTEGER; _r RECORD; BEGIN SELECT cmitem_id INTO _check FROM cmitem WHERE ( (cmitem_cmhead_id=getCmheadId(pOld.memo_number, FALSE)) AND (cmitem_linenumber=pOld.line_number) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Credit Memo # % Line Number # not found', pOld.memo_number, pOld.line_number; END IF; UPDATE cmitem SET cmitem_itemsite_id=COALESCE(itemsite_id, -1), cmitem_qtycredit=pNew.qty_to_credit, cmitem_qtyreturned=pNew.qty_returned, cmitem_unitprice=pNew.net_unit_price, cmitem_comments=pNew.notes, cmitem_rsncode_id=getRsnId(pNew.reason_code), cmitem_taxtype_id=taxtype_id, cmitem_qty_uom_id=COALESCE(getUomId(pNew.qty_uom), item_inv_uom_id), cmitem_qty_invuomratio=CASE WHEN item_id IS NOT NULL THEN itemuomtouomratio(item_id, COALESCE(getUomId(pNew.qty_uom),item_inv_uom_id),item_inv_uom_id) ELSE 1 END, cmitem_price_uom_id=COALESCE(getUomId(pNew.price_uom),item_price_uom_id), cmitem_price_invuomratio=CASE WHEN item_id IS NOT NULL THEN itemuomtouomratio(item_id, COALESCE(getUomId(pNew.price_uom),item_price_uom_id),item_price_uom_id) ELSE 1 END FROM cmhead LEFT OUTER JOIN item ON (item_id=getItemId(pNew.item_number)) LEFT OUTER JOIN itemsite ON (itemsite_item_id=item_id AND itemsite_warehous_id=getWarehousId(pNew.recv_site, 'ALL')) LEFT OUTER JOIN taxtype ON (taxtype_id=CASE WHEN pNew.tax_type IS NULL THEN getItemTaxType(item_id,cmhead_taxzone_id) WHEN pNew.tax_type = 'None' THEN NULL ELSE getTaxTypeId(pNew.tax_type) END) WHERE cmitem_cmhead_id=cmhead_id AND cmhead_number=pOld.memo_number AND cmitem_linenumber=pOld.line_number AND cmhead_posted=FALSE; RETURN TRUE; END; $_$; SDROP FUNCTION public.updatecreditmemoline(api.creditmemoline, api.creditmemoline); publicadminfalse4403462384403l125579470updatecustomprivs()FUNCTIONCREATE FUNCTION updatecustomprivs() RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; BEGIN FOR _r IN SELECT priv_id FROM priv WHERE ((priv_name IN (SELECT priv_name FROM priv WHERE (priv_module='Custom') EXCEPT SELECT ('Custom'||cmd_privname) FROM cmd)) AND (priv_module='Custom')) LOOP -- TODO: something here DELETE FROM grppriv WHERE grppriv_priv_id=_r.priv_id; DELETE FROM usrpriv WHERE usrpriv_priv_id=_r.priv_id; DELETE FROM priv WHERE priv_id=_r.priv_id; END LOOP; FOR _r IN SELECT ('Custom'||cmd_privname) AS privname FROM cmd EXCEPT SELECT priv_name FROM priv WHERE (priv_module='Custom') LOOP -- TODO: something here INSERT INTO priv (priv_module, priv_name, priv_descrip) VALUES ('Custom', _r.privname, 'Auto Generated Custom Priv.'); END LOOP; RETURN TRUE; END; $$; *DROP FUNCTION public.updatecustomprivs(); publicadminfalse46238] 1255880097updateinvoicelineitem(api.invoiceline, api.invoiceline)FUNCTION CREATE FUNCTION updateinvoicelineitem(api.invoiceline, api.invoiceline) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pNew ALIAS FOR $1; pOld ALIAS FOR $2; _r RECORD; BEGIN UPDATE invcitem SET invcitem_linenumber=pNew.line_number, invcitem_item_id=COALESCE(item_id, -1), invcitem_custpn=pNew.customer_part_number, invcitem_number=(CASE WHEN item_id IS NULL THEN pNew.misc_item_number ELSE NULL END), invcitem_warehous_id=(CASE WHEN invcitem_warehous_id IS NULL THEN COALESCE(getwarehousid(pNew.site,'ALL'),-1) ELSE NULL END), invcitem_descrip=(CASE WHEN item_id IS NULL THEN pNew.misc_item_description ELSE NULL END), invcitem_ordered=pNew.qty_ordered, invcitem_billed=COALESCE(pNew.qty_billed, 0), invcitem_updateinv=COALESCE(pNew.update_inventory,FALSE), invcitem_price=COALESCE(pNew.net_unit_price,itemPrice(item_id,invchead_cust_id, invchead_shipto_id,pNew.qty_ordered,invchead_curr_id,invchead_orderdate)), invcitem_notes=COALESCE(pNew.notes,''), invcitem_salescat_id=CASE WHEN item_id IS NULL THEN (SELECT salescat_id FROM salescat WHERE salescat_name = pNew.sales_category) ELSE NULL END, invcitem_taxtype_id=taxtype_id, invcitem_qty_uom_id=CASE WHEN item_id IS NOT NULL THEN COALESCE((SELECT uom_id FROM uom WHERE (uom_name=pNew.qty_uom)), item_price_uom_id) ELSE NULL END, invcitem_qty_invuomratio=CASE WHEN item_id IS NOT NULL THEN itemuomtouomratio(item_id, COALESCE((SELECT uom_id FROM uom WHERE uom_name=pNew.qty_uom),item_price_uom_id), item_price_uom_id ) ELSE 1 END, invcitem_price_uom_id=CASE WHEN item_id IS NOT NULL THEN COALESCE((SELECT uom_id FROM uom WHERE uom_name=pNew.price_uom),item_price_uom_id) ELSE NULL END, invcitem_price_invuomratio=CASE WHEN item_id IS NOT NULL THEN itemuomtouomratio(item_id, COALESCE((SELECT uom_id FROM uom WHERE uom_name=pNew.price_uom),item_price_uom_id), item_price_uom_id ) ELSE 1 END, invcitem_rev_accnt_id=getGlAccntId(alternate_rev_account) FROM invchead LEFT OUTER JOIN item ON (item_id=getItemId(pNew.item_number)) LEFT OUTER JOIN taxtype ON (taxtype_id=CASE WHEN pNew.tax_type IS NULL THEN getItemTaxType(item_id,invchead_taxzone_id) WHEN pNew.tax_type = 'None' THEN NULL ELSE (SELECT taxtype_id FROM taxtype WHERE taxtype_name=pNew.tax_type) END) WHERE invcitem_invchead_id=invchead_id AND invcitem_linenumber=pOld.line_number AND invchead_invcnumber=pOld.invoice_number AND invchead_posted=FALSE; RETURN TRUE; END; $_$; NDROP FUNCTION public.updateinvoicelineitem(api.invoiceline, api.invoiceline); publicadminfalse4623844694469m125579472;updateitemcost(integer, integer, integer, numeric, boolean)FUNCTIONCREATE FUNCTION updateitemcost(integer, integer, integer, numeric, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemId ALIAS FOR $1; pCostElemId ALIAS FOR $2; pCurrId ALIAS FOR $3; pCost ALIAS FOR $4; pPostToStandard ALIAS FOR $5; _itemcost_id INTEGER; _update_return INTEGER; _postcost_return BOOLEAN; --This function is used with the api.itemcost View for updating --the itemcost table BEGIN SELECT itemcost_id INTO _itemcost_id FROM itemcost WHERE ( (itemcost_item_id = pItemId) AND (itemcost_costelem_id = pCostElemId) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'itemcost % not found for. ', pItemId || ' & ' || pCostElemId; END IF; IF (pCost IS NULL OR pCost < 0) THEN RAISE EXCEPTION 'itemcost Actual Cost Invalid ', pCost; END IF; IF (pCost > 0) THEN UPDATE itemcost SET itemcost_actcost=pCost, itemcost_curr_id = pCurrId WHERE (itemcost_id=_itemcost_id); --Only Post Cost to standard if the parameter is set to true IF (pPostToStandard) THEN IF (NOT checkPrivilege('PostStandardCosts')) THEN RAISE EXCEPTION 'You do not have privileges to poststandard itemcosts. Set api.itemcost post_to_standard to false'; END IF; SELECT postcost(_itemcost_id) INTO _postcost_return; IF (NOT _postcost_return) THEN RETURN -2; END IF; END IF; ELSE RETURN -1; END IF; RETURN _itemcost_id; END; $_$; RDROP FUNCTION public.updateitemcost(integer, integer, integer, numeric, boolean); publicadminfalse46238n125579473(updateitemsiteleadtime(integer, integer)FUNCTION*CREATE FUNCTION updateitemsiteleadtime(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pPad ALIAS FOR $2; _p RECORD; _materialLeadTime INTEGER; _productionLeadTime INTEGER; _leadTime INTEGER; BEGIN SELECT item_type, itemsite_wosupply INTO _p FROM item, itemsite WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pitemsiteid) ); IF ( (_p.item_type IN ('M', 'P')) ) THEN IF (_p.item_type = 'M') THEN SELECT COALESCE(MAX(component.itemsite_leadtime), 0) INTO _materialLeadTime FROM bomitem, itemsite AS parent, itemsite AS component WHERE ( (bomitem_parent_item_id=parent.itemsite_item_id) AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id)) AND (bomitem_item_id=component.itemsite_item_id) AND (parent.itemsite_warehous_id=component.itemsite_warehous_id) AND (parent.itemsite_id=pItemsiteid) ); SELECT COALESCE(MAX(booitem_execday), 0) INTO _productionLeadTime FROM xtmfg.booitem, itemsite WHERE ( (booitem_item_id=itemsite_item_id) AND (booitem_rev_id=getActiveRevId('BOO',booitem_item_id)) AND (itemsite_id=pItemsiteid) ); _leadTime := (_materialLeadTime + _productionLeadTime + pPad); ELSIF (_p.item_type IN ('P')) THEN SELECT COALESCE(MAX(itemsrc_leadtime), 0) INTO _leadTime FROM itemsrc, itemsite WHERE ( (itemsite_item_id=itemsrc_item_id) AND (itemsite_id=pItemsiteid) ); _leadTime := (_leadTime + pPad); END IF; ELSE _leadTime = pPad; END IF; UPDATE itemsite SET itemsite_leadtime=_leadTime WHERE (itemsite_id=pItemsiteid); RETURN _leadTime; END; $_$; ?DROP FUNCTION public.updateitemsiteleadtime(integer, integer); publicadminfalse46238o125579474!updatelistprice(integer, numeric)FUNCTIONCREATE FUNCTION updatelistprice(integer, numeric) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pUpdateBy ALIAS FOR $2; BEGIN UPDATE item SET item_listprice = (item_listprice * pUpdateBy) WHERE (item_id=pItemid); RETURN 1; END; $_$; 8DROP FUNCTION public.updatelistprice(integer, numeric); publicadminfalse84623p125579475updatelowerusercosts(integer)FUNCTION?CREATE FUNCTION updatelowerusercosts(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; BEGIN RETURN updateLowerUserCosts(pItemid, TRUE); END; $_$; 4DROP FUNCTION public.updatelowerusercosts(integer); publicadminfalse46238j125579476&updatelowerusercosts(integer, boolean)FUNCTION= CREATE FUNCTION updatelowerusercosts(integer, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pUpdateActual ALIAS FOR $2; _bomitem RECORD; _type CHAR(1); BEGIN SELECT item_type INTO _type FROM item WHERE (item_id=pItemid); IF (_type IN ('M', 'F', 'B', 'T')) THEN FOR _bomitem IN SELECT DISTINCT costelem_type FROM ( SELECT COALESCE(bc.costelem_type, ic.costelem_type) AS costelem_type FROM bomitem(pItemid) JOIN item ON (item_id=bomitem_item_id AND item_type <> 'T') JOIN itemcost ON (itemcost_item_id=bomitem_item_id) JOIN costelem ic ON (ic.costelem_id=itemcost_costelem_id AND NOT ic.costelem_sys) LEFT OUTER JOIN bomitemcost ON (bomitemcost_bomitem_id=bomitem_id) LEFT OUTER JOIN costelem bc ON (bc.costelem_id=bomitemcost_costelem_id AND NOT bc.costelem_sys) WHERE ( CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1) ) UNION SELECT costelem_type FROM itemcost, costelem WHERE ( (itemcost_costelem_id=costelem_id) AND (itemcost_item_id=pItemid) ) ) AS data LOOP PERFORM updateSorACost( pItemid, _bomitem.costelem_type, TRUE, lowerCost(pItemid, _bomitem.costelem_type, pUpdateActual), pUpdateActual); END LOOP; ELSIF (_type = 'C') THEN FOR _bomitem IN SELECT DISTINCT costelem_type FROM ( SELECT costelem_type FROM itemcost, costelem, xtmfg.bbomitem WHERE ( (bbomitem_item_id=pItemid) AND ( CURRENT_DATE BETWEEN bbomitem_effective AND (bbomitem_expires - 1) ) AND (NOT costelem_sys) AND (bbomitem_item_id=itemcost_item_id) AND (itemcost_costelem_id=costelem_id) ) UNION SELECT costelem_type FROM itemcost, costelem, xtmfg.bbomitem AS t, xtmfg.bbomitem AS s WHERE ( (t.bbomitem_item_id=pItemid) AND ( CURRENT_DATE BETWEEN s.bbomitem_effective AND (s.bbomitem_expires - 1) ) AND ( CURRENT_DATE BETWEEN t.bbomitem_effective AND (t.bbomitem_expires - 1) ) AND (s.bbomitem_parent_item_id=t.bbomitem_parent_item_id) AND (NOT costelem_sys) AND (s.bbomitem_item_id=itemcost_item_id) AND (itemcost_costelem_id=costelem_id) ) ) AS data LOOP PERFORM updateSorACost( pItemid, _bomitem.costelem_type, TRUE, lowerCost(pItemid, _bomitem.costelem_type, pUpdateActual), pUpdateActual); END LOOP; END IF; RETURN 1; END; $_$; =DROP FUNCTION public.updatelowerusercosts(integer, boolean); publicadminfalse46238r125579477updatelowlevel(integer)FUNCTIONaCREATE FUNCTION updatelowlevel(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLowlevel ALIAS FOR $1; _num_back INTEGER; BEGIN UPDATE costUpdate SET costUpdate_lowlevel_code = (pLowlevel + 1) WHERE costUpdate_item_id IN ( SELECT bomitem_item_id FROM bomitem JOIN costUpdate ON (bomitem_parent_item_id = costUpdate_item_id) WHERE ((costUpdate_lowlevel_code = pLowlevel) AND (bomitem_rev_id=getActiveRevId('BOM',bomitem_parent_item_id)) AND (CURRENT_DATE BETWEEN bomitem_effective AND (bomitem_expires - 1)))) AND costUpdate_lowlevel_code >= pLowlevel; GET DIAGNOSTICS _num_back = ROW_COUNT; RETURN _num_back; END; $_$; .DROP FUNCTION public.updatelowlevel(integer); publicadminfalse46238s125579478+updateoutlevel(integer, integer, integer[])FUNCTIONCREATE FUNCTION updateoutlevel(integer, integer, integer[]) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pDays ALIAS FOR $2; pPeriods ALIAS FOR $3; _cursor INTEGER; _periodid INTEGER; _usage NUMERIC; _totalUsage NUMERIC; _totalDays INTEGER; _outLevel NUMERIC; _averageUsage NUMERIC; BEGIN _cursor := 1; _totalUsage := 0; _totalDays := 0; _periodid = pPeriods[_cursor]; WHILE (_periodid IS NOT NULL) LOOP SELECT COALESCE(SUM(invhist_invqty), 0) INTO _usage FROM invhist WHERE ( (invhist_itemsite_id=pItemsiteid) AND ( invhist_transdate::DATE BETWEEN findPeriodStart(_periodid) AND findPeriodEnd(_periodid) ) AND (invhist_transtype IN ('SH', 'IM')) ); _totalUsage := (_totalUsage + _usage); _totalDays := ( _totalDays + ( findPeriodEnd(_periodid) - findPeriodStart(_periodid) + 1 ) ); _cursor := (_cursor + 1); _periodid = pPeriods[_cursor]; END LOOP; IF (_totalDays > 0) THEN _outLevel := round(_totalUsage / _totalDays * pDays); IF (_outLevel > 0) THEN UPDATE itemsite SET itemsite_ordertoqty = _outLevel WHERE (itemsite_id=pItemsiteid); ELSE UPDATE itemsite SET itemsite_ordertoqty = 0 WHERE (itemsite_id=pItemsiteid); END IF; RETURN TRUE; ELSE RETURN FALSE; END IF; END; $_$; BDROP FUNCTION public.updateoutlevel(integer, integer, integer[]); publicadminfalse84623125579479updateprice(integer, numeric)FUNCTION`CREATE FUNCTION updateprice(integer, numeric) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pIpsitemid ALIAS FOR $1; pUpdateBy ALIAS FOR $2; BEGIN RETURN updatePrice(pIpsitemid, 'P', pUpdateBy); END; $_$; 4DROP FUNCTION public.updateprice(integer, numeric); publicadminfalse84623125579480(updateprice(integer, character, numeric)FUNCTIONuCREATE FUNCTION updateprice(integer, character, numeric) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pIpsitemid ALIAS FOR $1; pUpdateType ALIAS FOR $2; pUpdateBy ALIAS FOR $3; BEGIN IF (pUpdateType IN('V')) THEN UPDATE ipsitem SET ipsitem_price = (ipsitem_price + pUpdateBy) WHERE (ipsitem_id=pIpsitemid); RETURN 1; ELSE UPDATE ipsitem SET ipsitem_price = (ipsitem_price * pUpdateBy) WHERE (ipsitem_id=pIpsitemid); RETURN 1; END IF; END; $_$; ?DROP FUNCTION public.updateprice(integer, character, numeric); publicadminfalse46238125579481Cupdatepricesbypricingschedule(integer, character, numeric, boolean)FUNCTIONCREATE FUNCTION updatepricesbypricingschedule(pipsheadid integer, pupdatetype character, pupdateby numeric, pupdatecharprices boolean) RETURNS numeric LANGUAGE plpgsql AS $$ DECLARE _percentMultiplier NUMERIC; _currencyDecimals INTEGER; _itemRows INTEGER :=0; _charRows INTEGER :=0; BEGIN IF NOT (checkPrivilege('MaintainPricingSchedules')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Price Schedules.'; END IF; -- Get the current user's currency precision SELECT COALESCE(locale_curr_scale, 2) INTO _currencyDecimals FROM locale, usr WHERE usr_locale_id = locale_id AND usr_username = CURRENT_USER; IF (pUpdateType = 'V') THEN UPDATE ipsitem SET ipsitem_price = noNeg(ROUND( (ipsitem_price + pUpdateBy), _currencyDecimals)) WHERE (ipsitem_ipshead_id = pIpsHeadId); GET DIAGNOSTICS _itemRows = ROW_COUNT; ELSE _percentMultiplier := (1.0 + (pUpdateBy / 100.0)); UPDATE ipsitem SET ipsitem_price = noNeg(ROUND( (ipsitem_price * _percentMultiplier), _currencyDecimals)) WHERE (ipsitem_ipshead_id = pIpsHeadId); GET DIAGNOSTICS _itemRows = ROW_COUNT; IF (pUpdateCharPrices) THEN UPDATE ipsitemchar SET ipsitemchar_price = noNeg(ROUND( (ipsitemchar_price * _percentMultiplier), _currencyDecimals)) FROM ipsitem WHERE ipsitemchar_ipsitem_id = ipsitem_id AND ipsitem_ipshead_id = pIpsHeadId; GET DIAGNOSTICS _charRows = ROW_COUNT; END IF; END IF; RETURN _itemRows + _charRows; END; $$; DROP FUNCTION public.updatepricesbypricingschedule(pipsheadid integer, pupdatetype character, pupdateby numeric, pupdatecharprices boolean); publicadminfalse84623125579482Iupdatepricesbyproductcategory(integer, text, character, numeric, boolean)FUNCTION CREATE FUNCTION updatepricesbyproductcategory(pprodcatid integer, pprodcatpattern text, pupdatetype character, pupdateby numeric, pupdatecharprices boolean) RETURNS numeric LANGUAGE plpgsql AS $$ DECLARE _percentMultiplier NUMERIC; _currencyDecimals INTEGER; _itemRows INTEGER :=0; _charRows INTEGER :=0; BEGIN IF NOT (checkPrivilege('MaintainPricingSchedules')) THEN RAISE EXCEPTION 'You do not have privileges to maintain Price Schedules.'; END IF; -- Get the current user's currency precision SELECT COALESCE(locale_curr_scale, 2) INTO _currencyDecimals FROM locale, usr WHERE usr_locale_id = locale_id AND usr_username = CURRENT_USER; _percentMultiplier := (1.0 + (pUpdateBy / 100.0)); IF (pUpdateType = 'V') THEN IF (pProdCatId IS NOT NULL) THEN -- Specified category id UPDATE ipsitem SET ipsitem_price = noNeg(ROUND( (ipsitem_price + pUpdateBy), _currencyDecimals )) FROM item WHERE ipsitem_item_id = item_id AND item_prodcat_id = pProdCatId; ELSIF (pProdCatPattern IS NOT NULL) THEN -- Pattern match category UPDATE ipsitem SET ipsitem_price = noNeg(ROUND( (ipsitem_price + pUpdateBy), _currencyDecimals )) FROM item WHERE ipsitem_item_id = item_id AND item_prodcat_id IN ( SELECT prodcat_id FROM prodcat WHERE (prodcat_code ~ pProdCatPattern) ); ELSE -- All categories UPDATE ipsitem SET ipsitem_price = noNeg(ROUND( (ipsitem_price + pUpdateBy), _currencyDecimals )); END IF; GET DIAGNOSTICS _itemRows = ROW_COUNT; ELSE IF (pProdCatId IS NOT NULL) THEN -- Specified category id UPDATE ipsitem SET ipsitem_price = noNeg(ROUND( (ipsitem_price * _percentMultiplier), _currencyDecimals )) FROM item WHERE ipsitem_item_id = item_id AND item_prodcat_id = pProdCatId; GET DIAGNOSTICS _itemRows = ROW_COUNT; IF(pUpdateCharPrices) THEN UPDATE ipsitemchar SET ipsitemchar_price = noNeg(ROUND( (ipsitemchar_price * _percentMultiplier), _currencyDecimals )) FROM ipsitem, item WHERE item_prodcat_id = pProdCatId AND ipsitem_item_id = item_id AND ipsitemchar_ipsitem_id = ipsitem_id; GET DIAGNOSTICS _charRows = ROW_COUNT; END IF; ELSIF (pProdCatPattern IS NOT NULL) THEN -- Pattern match category UPDATE ipsitem SET ipsitem_price = noNeg(ROUND( (ipsitem_price * _percentMultiplier), _currencyDecimals )) FROM item WHERE item_prodcat_id IN ( SELECT prodcat_id FROM prodcat WHERE (prodcat_code ~ pProdCatPattern ) ) AND ipsitem_item_id = item_id; GET DIAGNOSTICS _itemRows = ROW_COUNT; IF(pUpdateCharPrices) THEN UPDATE ipsitemchar SET ipsitemchar_price = noNeg(ROUND( (ipsitemchar_price * _percentMultiplier), _currencyDecimals )) FROM ipsitem, item WHERE item_prodcat_id IN ( SELECT prodcat_id FROM prodcat WHERE (prodcat_code ~ pProdCatPattern ) ) AND ipsitem_item_id = item_id AND ipsitemchar_ipsitem_id = ipsitem_id; GET DIAGNOSTICS _charRows = ROW_COUNT; END IF; ELSE -- All categories UPDATE ipsitem SET ipsitem_price = noNeg(ROUND( (ipsitem_price * _percentMultiplier), _currencyDecimals )); GET DIAGNOSTICS _itemRows = ROW_COUNT; IF(pUpdateCharPrices) THEN UPDATE ipsitemchar SET ipsitemchar_price = noNeg(ROUND( (ipsitemchar_price * _percentMultiplier), _currencyDecimals )); GET DIAGNOSTICS _charRows = ROW_COUNT; END IF; END IF; END IF; RETURN _itemRows + _charRows; END; $$; DROP FUNCTION public.updatepricesbyproductcategory(pprodcatid integer, pprodcatpattern text, pupdatetype character, pupdateby numeric, pupdatecharprices boolean); publicadminfalse46238t125579483/updatereorderlevel(integer, integer, integer[])FUNCTIONCREATE FUNCTION updatereorderlevel(integer, integer, integer[]) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pDays ALIAS FOR $2; pPeriods ALIAS FOR $3; _cursor INTEGER; _periodid INTEGER; _usage NUMERIC; _totalUsage NUMERIC; _totalDays INTEGER; _reorderLevel INTEGER; _averageUsage NUMERIC; _result TEXT; BEGIN _cursor := 1; _totalUsage := 0; _totalDays := 0; _periodid = pPeriods[_cursor]; WHILE (_periodid IS NOT NULL) LOOP SELECT COALESCE(SUM(invhist_invqty), 0) INTO _usage FROM invhist WHERE ( (invhist_itemsite_id=pItemsiteid) AND ( invhist_transdate::DATE BETWEEN findPeriodStart(_periodid) AND findPeriodEnd(_periodid) ) AND (invhist_transtype IN ('SH', 'IM')) ); _totalUsage := (_totalUsage + _usage); _totalDays := ( _totalDays + ( findPeriodEnd(_periodid) - findPeriodStart(_periodid) + 1 ) ); _cursor := (_cursor + 1); _periodid = pPeriods[_cursor]; END LOOP; IF (_totalDays > 0) THEN _reorderLevel := round(_totalUsage / _totalDays * pDays); SELECT itemsite_stocked INTO _result from itemsite WHERE (itemsite_id=pItemsiteid); IF (_reorderLevel = 0 AND _result='t') THEN _reorderLevel := 1; END IF; IF (_reorderLevel > 0) THEN UPDATE itemsite SET itemsite_reorderlevel = _reorderLevel WHERE (itemsite_id=pItemsiteid); ELSE UPDATE itemsite SET itemsite_reorderlevel = 0 WHERE (itemsite_id=pItemsiteid); END IF; RETURN TRUE; ELSE RETURN FALSE; END IF; END; $_$; FDROP FUNCTION public.updatereorderlevel(integer, integer, integer[]); publicadminfalse46238u125587102:updatereorderlevel(integer[], integer, boolean, integer[])FUNCTION CREATE FUNCTION updatereorderlevel(integer[], integer, boolean, integer[]) RETURNS SETOF reordlvl LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteids ALIAS FOR $1; pDays ALIAS FOR $2; pAddLeadtime ALIAS FOR $3; pPeriodIds ALIAS FOR $4; _icursor INTEGER := 1; _pcursor INTEGER := 1; _totalUsage NUMERIC := 0; _totalDays INTEGER := 0; _reorderLevel INTEGER := 0; _result TEXT; _usage NUMERIC; _averageUsage NUMERIC; _row reordlvl %ROWTYPE; BEGIN -- Validate IF (pItemsiteIds[1] IS NULL OR pPeriodIds[1] IS NULL) THEN RETURN; END IF; -- Calculate total days FOR _pcursor IN 1..ARRAY_UPPER(pPeriodIds,1) LOOP _totalDays := ( _totalDays + ( findPeriodEnd(pPeriodIds[_pcursor]) - findPeriodStart(pPeriodIds[_pcursor]) + 1 ) ); END LOOP; -- Loop through each itemsite id FOR _icursor IN 1..ARRAY_UPPER(pItemsiteIds,1) LOOP -- Get itemsite data SELECT itemsite_id, item_id, warehous_code, item_number, item_descrip1, itemsite_leadtime, 0, itemsite_reorderlevel, 0, 0, 0 INTO _row FROM itemsite JOIN item ON (itemsite_item_id=item_id) JOIN whsinfo ON (itemsite_warehous_id=warehous_id) WHERE (itemsite_id=pItemsiteIds[_icursor]); IF (FOUND) THEN IF (pAddLeadtime) THEN _row.reordlvl_daysofstock := pDays + _row.reordlvl_leadtime; ELSE _row.reordlvl_daysofstock := pDays; END IF; -- Loop through each period id FOR _pcursor IN 1..ARRAY_UPPER(pPeriodIds,1) LOOP -- Sum days and usage shipping and inventory transactions SELECT COALESCE(SUM(invhist_invqty), 0) INTO _usage FROM invhist WHERE ( (invhist_itemsite_id=pItemsiteIds[_icursor]) AND ( invhist_transdate::DATE BETWEEN findPeriodStart(pPeriodIds[_pcursor]) AND findPeriodEnd(pPeriodIds[_pcursor]) ) AND (invhist_transtype IN ('SH', 'IM')) ); _totalUsage := (_totalUsage + _usage); END LOOP; -- Calculate reorder level IF (_totalDays > 0) THEN _reorderLevel := round(_totalUsage / _totalDays * _row.reordlvl_daysofstock); END IF; IF (_reorderLevel <= 0) THEN _reorderLevel := 0; END IF; SELECT itemsite_stocked INTO _result from itemsite WHERE (itemsite_id=pItemsiteIds[_icursor]); IF (_reorderLevel = 0 AND _result='t') THEN _reorderLevel := 1; END IF; -- Set values _row.reordlvl_total_days := _totalDays; _row.reordlvl_total_usage := _totalUsage; _row.reordlvl_calc_level := _reorderLevel; -- Return result RETURN NEXT _row; END IF; _usage := 0; _averageUsage := 0; _totalUsage := 0; _reorderLevel := 0; END LOOP; RETURN; END; $_$; QDROP FUNCTION public.updatereorderlevel(integer[], integer, boolean, integer[]); publicadminfalse462384261v125579485updateretainedearnings(integer)FUNCTION|CREATE FUNCTION updateretainedearnings(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pYearPeriodid ALIAS FOR $1; _r RECORD; _n RECORD; _c RECORD; _beginningPeriodid INTEGER; _trialbalid INTEGER; _accntid INTEGER; _totalProfitLoss NUMERIC; _periodid INTEGER; _forwardupdate INTEGER; BEGIN -- First thing we need to do is to get the yearperiod SELECT * INTO _r FROM yearperiod where yearperiod_id = pYearPeriodid; IF (NOT FOUND) THEN RETURN -6; END IF; -- Now we need to find the next yearperiod SELECT * INTO _n FROM yearperiod WHERE yearperiod_start = _r.yearperiod_end + interval '1 day'; IF (NOT FOUND) THEN RETURN -4; END IF; -- Now we have to find where to stick the end of year data SELECT period_id INTO _periodid FROM period WHERE period_start = _n.yearperiod_start; IF (NOT FOUND) THEN RETURN -8; END IF; -- Loop through companies and process each one IF (coalesce(fetchMetricValue('GLCompanySize'),0) = 0) THEN -- Process for installs not using company segment -- Now we need to get the default account number for year end closing SELECT CAST ( metric_value AS integer ) INTO _accntid FROM metric WHERE metric_name = 'YearEndEquityAccount'; IF (NOT FOUND) THEN RETURN -7; END IF; -- So far so good. Now we need to calculate the profit-loss for the year that we are closing SELECT SUM(gltrans_amount) INTO _totalProfitLoss FROM gltrans, accnt WHERE ( (gltrans_accnt_id = accnt_id) AND (accnt_type IN ( 'R', 'E' ) ) AND (gltrans_posted) AND (NOT gltrans_deleted) AND (gltrans_date between _r.yearperiod_start and _r.yearperiod_end ) ); IF (_totalProfitLoss IS NULL) THEN _totalProfitLoss := 0; END IF; -- Get the trailbal_id SELECT trialbal_id INTO _trialbalid FROM trialbal WHERE ( (trialbal_period_id = _periodid ) AND (trialbal_accnt_id = _accntid) ); IF (NOT FOUND) THEN RETURN -9; END IF; -- Lets do the update for the trialbal UPDATE trialbal SET trialbal_beginning = trialbal_beginning - trialbal_yearend + _totalProfitLoss, trialbal_ending = trialbal_beginning - trialbal_yearend - trialbal_debits + trialbal_credits + _totalProfitLoss, trialbal_yearend = _totalProfitLoss WHERE trialbal_id = _trialbalid; -- Now the forward update SELECT forwardupdatetrialbalance(_trialbalid) INTO _forwardupdate; ELSE -- Process for a multi-company set up FOR _c IN SELECT company_number, company_yearend_accnt_id FROM company LOOP -- Calculate the profit-loss for the year that we are closing SELECT SUM(gltrans_amount) INTO _totalProfitLoss FROM gltrans, accnt WHERE ( (gltrans_accnt_id = accnt_id) AND (accnt_type IN ( 'R', 'E' ) ) AND (gltrans_posted) AND (NOT gltrans_deleted) AND (accnt_company = _c.company_number) AND (gltrans_date between _r.yearperiod_start and _r.yearperiod_end ) ); IF(_totalProfitLoss IS NULL) THEN _totalProfitLoss := 0; END IF; -- Get the trailbal_id SELECT trialbal_id INTO _trialbalid FROM trialbal JOIN accnt ON (trialbal_accnt_id=accnt_id) WHERE ( (trialbal_period_id = _periodid ) AND (trialbal_accnt_id = _c.company_yearend_accnt_id) ); IF (NOT FOUND) THEN -- Create a trial balance record SELECT NEXTVAL('trialbal_trialbal_id_seq') INTO _trialbalid; INSERT INTO trialbal ( trialbal_id, trialbal_accnt_id, trialbal_period_id, trialbal_beginning, trialbal_dirty, trialbal_ending, trialbal_credits, trialbal_debits, trialbal_yearend ) VALUES ( _trialbalid, _c.company_yearend_accnt_id, _periodid, _totalProfitLoss, TRUE, _totalProfitLoss, 0, 0, _totalProfitLoss ); ELSE -- Lets do the update for the trialbal UPDATE trialbal SET trialbal_beginning = trialbal_beginning - trialbal_yearend + _totalProfitLoss, trialbal_ending = trialbal_beginning - trialbal_yearend - trialbal_debits + trialbal_credits + _totalProfitLoss, trialbal_yearend = _totalProfitLoss WHERE trialbal_id = _trialbalid; END IF; -- Now the forward update SELECT forwardupdatetrialbalance(_trialbalid) INTO _forwardupdate; END LOOP; END IF; RETURN 0; END; $_$; 6DROP FUNCTION public.updateretainedearnings(integer); publicadminfalse84623x1255794868updatesoracost(integer, text, boolean, numeric, boolean)FUNCTION2CREATE FUNCTION updatesoracost(integer, text, boolean, numeric, boolean) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCosttype ALIAS FOR $2; pLevel ALIAS FOR $3; pCost ALIAS FOR $4; pUpdateActual ALIAS FOR $5; BEGIN IF (pUpdateActual) THEN RETURN updateCost(pItemid, pCosttype, pLevel, pCost); ELSE RETURN updateStdCost(pItemid, pCosttype, pLevel, pCost); END IF; END; $_$; ODROP FUNCTION public.updatesoracost(integer, text, boolean, numeric, boolean); publicadminfalse84623z125579487.updatestdcost(integer, text, boolean, numeric)FUNCTIONKCREATE FUNCTION updatestdcost(integer, text, boolean, numeric) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemid ALIAS FOR $1; pCostType ALIAS FOR $2; pLevel ALIAS FOR $3; pCost ALIAS FOR $4; _newCost NUMERIC; _oldCost NUMERIC := 0; _itemcostid INTEGER; _updateRet BOOLEAN; _itemNumber TEXT; BEGIN IF (pCost IS NULL) THEN _newCost = 0; ELSE _newCost = pCost; END IF; SELECT itemcost_id, itemcost_stdCost, item_number INTO _itemcostid, _oldCost, _itemNumber FROM itemcost, costelem, item WHERE ((itemcost_costelem_id=costelem_id) AND (itemcost_item_id=item_id) AND (item_id=pItemid) AND (itemcost_lowlevel=pLevel) AND (costelem_type=pCosttype)); -- RAISE NOTICE 'updateStdCost(%, %, %, %) has itemcost_id % and stdcost %', -- pItemid, pCostType, plevel, _newCost, _itemcostid, _oldCost; IF (NOT FOUND) AND (_newCost > 0) THEN SELECT NEXTVAL('itemcost_itemcost_id_seq') INTO _itemcostid; -- RAISE NOTICE 'updateStdCost() inserting itemcost_id %', _itemcostid; INSERT INTO itemcost (itemcost_id, itemcost_item_id, itemcost_costelem_id, itemcost_lowlevel, itemcost_stdcost, itemcost_posted, itemcost_actcost, itemcost_updated) SELECT _itemcostid, pItemid, costelem_id, pLevel, _newCost, CURRENT_DATE, 0, CURRENT_DATE FROM costelem WHERE (costelem_type=pCosttype); END IF; IF (_itemcostid IS NOT NULL) THEN SELECT updateStdCost(_itemcostid, _newCost, _oldCost, 'Post Cost', ('Set Standard Cost - ' || pCosttype || ' for item ' || _itemNumber)) INTO _updateRet; IF (_updateRet) THEN RETURN _itemcostid; END IF; END IF; RETURN -1; END; $_$; EDROP FUNCTION public.updatestdcost(integer, text, boolean, numeric); publicadminfalse84623y1255794884updatestdcost(integer, numeric, numeric, text, text)FUNCTION CREATE FUNCTION updatestdcost(pitemcostid integer, pnewcost numeric, poldcost numeric, pdocnumber text, pnotes text) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _itemcostid INTEGER; _r RECORD; _newcost NUMERIC; _oldcost NUMERIC; BEGIN IF (pNewcost IS NULL) THEN _newcost := 0; ELSE _newcost := pNewcost; END IF; IF (pOldcost IS NULL) THEN _oldcost := 0; ELSE _oldcost := pOldcost; END IF; IF (_newcost > 0) THEN UPDATE itemcost SET itemcost_stdcost=_newcost, itemcost_posted=CURRENT_DATE WHERE (itemcost_id=pItemcostid); END IF; -- Distribute to G/L, debit Inventory Asset, credit Inventory Cost Variance FOR _r IN SELECT itemsite_id, itemsite_qtyonhand AS totalQty, costcat_invcost_accnt_id, costcat_asset_accnt_id, itemsite_costmethod FROM itemcost, itemsite, costcat WHERE ( (itemsite_item_id=itemcost_item_id) AND (itemsite_costcat_id=costcat_id) AND (itemsite_costmethod != 'A') AND (itemsite_qtyonhand <> 0.0) AND (itemcost_id=pItemcostid) ) LOOP -- IF (_newcost <> _oldcost) THEN -- RAISE NOTICE 'itemcost_id = %, Qty = %, Old Cost = %, New Cost = %', pItemcostid, _r.totalQty, _oldcost, _newcost; -- END IF; PERFORM insertGLTransaction( 'P/D', '', pDocNumber, pNotes, _r.costcat_invcost_accnt_id, _r.costcat_asset_accnt_id, _r.itemsite_id, ((_newcost - _oldcost) * _r.totalQty), CURRENT_DATE ); -- Update Itemsite Value if not Average Cost IF (_r.itemsite_costmethod <> 'A') THEN -- RAISE NOTICE 'itemsite_id = %, Qty = %, New Cost = %', _r.itemsite_id, _r.totalQty, _newcost; UPDATE itemsite SET itemsite_value=(_r.totalQty * stdCost(itemsite_item_id)) WHERE (itemsite_id=_r.itemsite_id); END IF; END LOOP; IF (_newcost = 0) THEN DELETE FROM itemcost WHERE (itemcost_id=pItemcostid); RETURN FALSE; END IF; IF ( SELECT metric_value FROM metric WHERE ((metric_name = 'EnableAsOfQOH') AND (metric_value = 't'))) THEN IF (pNewcost IS NOT NULL) THEN _newcost := pNewcost; END IF; IF (pOldcost IS NULL) THEN _oldcost := 0; ELSE _oldcost := pOldcost; END IF; -- Distribute to G/L, debit Inventory Asset, credit Inventory Cost Variance PERFORM postValueIntoInvBalance( itemsite_id, current_date, asofinvqty(itemsite_id,current_date), asofinvnn(itemsite_id,current_date), _oldcost, _newcost) FROM itemsite JOIN item ON (itemsite_item_id=item_id) JOIN itemcost ON (itemcost_item_id=item_id) WHERE((itemsite_costmethod = 'S') AND (itemcost_id=pItemcostid)); END IF; RETURN TRUE; END; $$; {DROP FUNCTION public.updatestdcost(pitemcostid integer, pnewcost numeric, poldcost numeric, pdocnumber text, pnotes text); publicadminfalse84623{125579489updatetodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, boolean, text)FUNCTIONCREATE FUNCTION updatetodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, boolean, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN updateTodoItem($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, NULL); END; $_$; DROP FUNCTION public.updatetodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, boolean, text); publicadminfalse46238|125579490updatetodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, boolean, text, integer)FUNCTION# CREATE FUNCTION updatetodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, boolean, text, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE ptodoitemid ALIAS FOR $1; pusername ALIAS FOR $2; pname ALIAS FOR $3; pdesc ALIAS FOR $4; pincdtid ALIAS FOR $5; pcrmacctid ALIAS FOR $6; pOpheadid ALIAS FOR $7; pstarted ALIAS FOR $8; pdue ALIAS FOR $9; pstatus ALIAS FOR $10; passigned ALIAS FOR $11; pcompleted ALIAS FOR $12; ppriority ALIAS FOR $13; pnotes ALIAS FOR $14; pactive ALIAS FOR $15; powner ALIAS FOR $16; pcntctid ALIAS FOR $17; _priority INTEGER := ppriority; _status CHARACTER(1) := pstatus; _incdtid INTEGER := pincdtid; _crmacctid INTEGER := pcrmacctid; _opheadid INTEGER := pOpheadid; _assigned DATE := passigned; _active BOOL := pactive; _result INTEGER; BEGIN IF (pusername IS NULL OR pusername = '') THEN RETURN -1; END IF; IF (pname IS NULL OR pname = '') THEN RETURN -2; END IF; IF (pdue IS NULL) THEN RETURN -3; END IF; IF (ptodoitemid IS NULL OR ptodoitemid <= 0) THEN RETURN -10; END IF; IF (pcompleted IS NOT NULL) THEN _status := 'C'; ELSIF (pstatus IS NULL AND pstarted IS NOT NULL) THEN _status := 'I'; ELSIF (pstatus IS NULL) THEN _status := 'N'; END IF; IF (_incdtid <= 0) THEN _incdtid := NULL; END IF; IF (_crmacctid <= 0) THEN _crmacctid := NULL; END IF; IF (_opheadid <= 0) THEN _opheadid := NULL; END IF; IF (_priority <= 0) THEN _priority := NULL; END IF; IF (_assigned IS NULL) THEN _assigned := CURRENT_DATE; END IF; IF (_active IS NULL) THEN _active := TRUE; END IF; UPDATE todoitem SET todoitem_username=pusername, todoitem_name=pname, todoitem_description=pdesc, todoitem_incdt_id=_incdtid, todoitem_status=_status, todoitem_active=_active, todoitem_start_date=pstarted, todoitem_due_date=pdue, todoitem_assigned_date=_assigned, todoitem_completed_date=pcompleted, todoitem_priority_id=_priority, todoitem_notes=pnotes, todoitem_crmacct_id=_crmacctid, todoitem_ophead_id=_opheadid, todoitem_owner_username=powner, todoitem_cntct_id=pcntctid WHERE (todoitem_id=ptodoitemid); RETURN ptodoitemid; END; $_$; DROP FUNCTION public.updatetodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, boolean, text, integer); publicadminfalse84623}125579491usedefaultlocation(integer)FUNCTIONrCREATE FUNCTION usedefaultlocation(integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; _p RECORD; BEGIN SELECT itemsite_location_id, LENGTH(itemsite_location) AS locationlength INTO _p FROM itemsite WHERE (itemsite_id=pItemsiteid); IF (NOT FOUND) THEN RETURN FALSE; ELSIF (_p.itemsite_location_id <> -1) THEN RETURN TRUE; ELSIF (_p.locationlength > 0) THEN RETURN TRUE; ELSE RETURN FALSE; END IF; END; $_$; 2DROP FUNCTION public.usedefaultlocation(integer); publicadminfalse46238~125579492usercancreateusers(text)FUNCTION CREATE FUNCTION usercancreateusers(text) RETURNS boolean LANGUAGE sql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT rolcreaterole OR rolsuper FROM pg_roles WHERE rolname=($1); $_$; /DROP FUNCTION public.usercancreateusers(text); publicadminfalse8125579493usercanlogin(text)FUNCTIONCREATE FUNCTION usercanlogin(pusername text) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _isactive BOOLEAN; _mode TEXT; BEGIN IF (isDBA(pUsername) OR userCanCreateUsers(pUsername)) THEN RETURN TRUE; ELSIF (pg_has_role(pUsername, 'xtrole', 'member')) THEN _mode := COALESCE(fetchMetricText('AllowedUserLogins'), ''); IF (_mode = 'AdminOnly') THEN RETURN FALSE; -- administrators were checked above END IF; IF (_mode NOT IN ('AdminOnly','ActiveOnly','Any')) THEN _mode := 'ActiveOnly'; END IF; SELECT (usrpref_value = 't') INTO _isactive FROM usrpref WHERE usrpref_username = pUsername AND usrpref_name = 'active'; IF (_isactive OR _mode = 'Any') THEN RETURN TRUE; END IF; END IF; RETURN FALSE; END; $$; 3DROP FUNCTION public.usercanlogin(pusername text); publicadminfalse84623q125579494 userid(text)FUNCTIONCREATE FUNCTION userid(text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pUsername ALIAS FOR $1; _userId INTEGER; BEGIN SELECT usesysid INTO _userId FROM pg_user WHERE (usename=pUsername); IF (FOUND) THEN RETURN _userId; ELSE RETURN -1; END IF; END; $_$; #DROP FUNCTION public.userid(text); publicadminfalse46238125579495+validateorderqty(integer, numeric, boolean)FUNCTIONHCREATE FUNCTION validateorderqty(integer, numeric, boolean) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pItemsiteid ALIAS FOR $1; pQty ALIAS FOR $2; pManual ALIAS FOR $3; _p RECORD; _qty NUMERIC; BEGIN _qty := pQty; SELECT itemsite_useparams, CASE WHEN (itemsite_useparams) THEN itemsite_useparamsmanual ELSE FALSE END AS itemsite_useparamsmanual, CASE WHEN (itemsite_useparams) THEN itemsite_minordqty ELSE 0.0 END AS itemsite_minordqty, CASE WHEN (itemsite_useparams) THEN itemsite_multordqty ELSE 0.0 END AS itemsite_multordqty, item_fractional, item_type INTO _p FROM itemsite, item WHERE ( (itemsite_item_id=item_id) AND (itemsite_id=pItemsiteid) ); IF ( (pManual AND (_p.itemsite_useparamsmanual)) OR ((NOT pManual) AND (_p.itemsite_useparams)) ) THEN IF (_qty < _p.itemsite_minordqty) THEN _qty := _p.itemsite_minordqty; END IF; IF ( (_p.itemsite_multordqty > 0) AND ((_qty % _p.itemsite_multordqty) > 0) ) THEN _qty := ((TRUNC(_qty / _p.itemsite_multordqty) * _p.itemsite_multordqty) + _p.itemsite_multordqty); END IF; END IF; _qty := roundQty(_p.item_fractional, _qty); RETURN _qty; END; $_$; BDROP FUNCTION public.validateorderqty(integer, numeric, boolean); publicadminfalse46238125579496validlocation(integer, integer)FUNCTIONCREATE FUNCTION validlocation(integer, integer) RETURNS boolean LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pLocationid ALIAS FOR $1; pItemsiteid ALIAS FOR $2; _p RECORD; BEGIN SELECT location_restrict INTO _p FROM location, itemsite WHERE ( (location_warehous_id=itemsite_warehous_id) AND (itemsite_id=pItemsiteid) AND (location_id=pLocationid) ); IF (FOUND) THEN IF (_p.location_restrict) THEN SELECT locitem_id INTO _p FROM locitem, itemsite WHERE ( (locitem_item_id=itemsite_item_id) AND (itemsite_id=pItemsiteid) AND (locitem_location_id=pLocationid) ); IF (FOUND) THEN RETURN TRUE; END IF; ELSE RETURN TRUE; END IF; ELSE RETURN FALSE; END IF; RETURN FALSE; END; $_$; 6DROP FUNCTION public.validlocation(integer, integer); publicadminfalse46238125579497valueatshipping(integer)FUNCTION CREATE FUNCTION valueatshipping(plineitemid integer) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN valueAtShipping('SO', plineitemid); END; $$; ;DROP FUNCTION public.valueatshipping(plineitemid integer); publicadminfalse46238125579498valueatshipping(text, integer)FUNCTIONCREATE FUNCTION valueatshipping(pordertype text, plineitemid integer) RETURNS numeric LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _value NUMERIC := 0.0; BEGIN IF (pordertype NOT IN ('SO', 'TO')) THEN RAISE EXCEPTION '% is not a valid order type', pordertype; END IF; SELECT COALESCE(SUM(shipitem_value), 0.0) INTO _value FROM shipitem JOIN shiphead ON (shipitem_shiphead_id=shiphead_id) WHERE ( (NOT shiphead_shipped) AND (shiphead_order_type=pordertype) AND (shipitem_orderitem_id=plineitemid) ); RETURN _value; END; $$; LDROP FUNCTION public.valueatshipping(pordertype text, plineitemid integer); publicadminfalse46238125579499voidapcheck(integer)FUNCTIONECREATE FUNCTION voidapcheck(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'voidAPCheck() is deprecated - use voidCheck() instead'; RETURN voidCheck($1); END; $_$; +DROP FUNCTION public.voidapcheck(integer); publicadminfalse84623125579500voidapopenvoucher(integer)FUNCTIONQCREATE FUNCTION voidapopenvoucher(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pApopenid ALIAS FOR $1; BEGIN RETURN voidApopenVoucher(pApopenid, fetchJournalNumber('AP-VO')); END; $_$; 1DROP FUNCTION public.voidapopenvoucher(integer); publicadminfalse84623125579501#voidapopenvoucher(integer, integer)FUNCTION8CREATE FUNCTION voidapopenvoucher(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pApopenid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; _apopenid INTEGER; _apcreditapplyid INTEGER; _reference TEXT; _result INTEGER; _sequence INTEGER; _totalAmount_base NUMERIC; _totalAmount NUMERIC; _itemAmount_base NUMERIC; _itemAmount NUMERIC; _test INTEGER; _a RECORD; _d RECORD; _g RECORD; _p RECORD; _n RECORD; _r RECORD; _costx RECORD; _pExplain BOOLEAN; _pLowLevel BOOLEAN; _exchGainFreight NUMERIC; _firstExchDateFreight DATE; _tmpTotal NUMERIC; _glDate DATE; BEGIN _totalAmount_base := 0; _totalAmount := 0; SELECT fetchGLSequence() INTO _sequence; -- Cache APOpen Information SELECT apopen.* INTO _n FROM apopen WHERE ( (apopen_doctype='V') AND (apopen_id=pApopenid) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Void Voucher Id % as apopen not found [xtuple: voidAPOpenVoucher, -10, %]', pApopenid, pApopenid; END IF; -- Cache Voucher Infomation SELECT vohead.*, vend_number || '-' || vend_name || ' ' || vohead_reference AS glnotes, COALESCE(pohead_orderdate, vohead_docdate) AS pohead_orderdate, COALESCE(pohead_curr_id, vohead_curr_id) AS pohead_curr_id INTO _p FROM vohead JOIN vendinfo ON (vend_id=vohead_vend_id) LEFT OUTER JOIN pohead ON (vohead_pohead_id = pohead_id) WHERE (vohead_number=_n.apopen_docnumber); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Void Voucher #% as vohead not found [xtuple: voidAPOpenVoucher, -20, %]', _n.apopen_docnumber, _n.apopen_docnumber; END IF; -- Check for APApplications SELECT apapply_id INTO _test FROM apapply WHERE (apapply_target_apopen_id=_n.apopen_id) LIMIT 1; IF (FOUND) THEN RAISE EXCEPTION 'Cannot Void Voucher #% as applications exist [xtuple: voidAPOpenVoucher, -30, %]', _n.apopen_docnumber, _n.apopen_docnumber; END IF; _glDate := COALESCE(_p.vohead_gldistdate, _p.vohead_distdate); -- there is no currency gain/loss on items, see issue 3892, -- but there might be on freight, which is first encountered at p/o receipt SELECT recv_date::DATE INTO _firstExchDateFreight FROM recv WHERE (recv_vohead_id = _p.vohead_id); -- Start by handling taxes FOR _r IN SELECT tax_sales_accnt_id, round(sum(taxdetail_tax),2) AS tax, currToBase(_p.vohead_curr_id, round(sum(taxdetail_tax),2), _p.vohead_docdate) AS taxbasevalue FROM tax JOIN calculateTaxDetailSummary('VO', _p.vohead_id, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id, tax_sales_accnt_id LOOP PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', _p.vohead_number, _r.tax_sales_accnt_id, (_r.taxbasevalue * -1), _glDate, _p.glnotes ); _totalAmount_base := (_totalAmount_base - _r.taxbasevalue); _totalAmount := (_totalAmount - _r.tax); END LOOP; -- Loop through the vodist records for the passed vohead that -- are posted against a P/O Item FOR _g IN SELECT DISTINCT poitem_id, voitem_qty, poitem_expcat_id, poitem_invvenduomratio, COALESCE(itemsite_id, -1) AS itemsiteid, COALESCE(itemsite_costcat_id, -1) AS costcatid, COALESCE(itemsite_item_id, -1) AS itemsite_item_id, (SELECT SUM(value) FROM ( SELECT SUM(recv_value) AS value FROM recv WHERE (recv_voitem_id=voitem_id) UNION SELECT SUM(poreject_value)*-1 AS value FROM poreject WHERE (poreject_voitem_id=voitem_id)) as data) AS value_base, (poitem_freight_vouchered / poitem_qty_vouchered) * voitem_qty AS vouchered_freight, currToBase(_p.pohead_curr_id, (poitem_freight_vouchered / poitem_qty_vouchered) * voitem_qty, _firstExchDateFreight ) AS vouchered_freight_base, voitem_freight, currToBase(_p.vohead_curr_id, voitem_freight, _p.vohead_distdate) AS voitem_freight_base FROM vodist, voitem, poitem LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id) WHERE ( (vodist_poitem_id=poitem_id) AND (voitem_poitem_id=poitem_id) AND (voitem_vohead_id=vodist_vohead_id) AND (vodist_vohead_id=_p.vohead_id)) LOOP -- Grab the G/L Accounts IF (_g.costcatid = -1) THEN SELECT pp.accnt_id AS pp_accnt_id, lb.accnt_id AS lb_accnt_id INTO _a FROM expcat, accnt AS pp, accnt AS lb WHERE ( (expcat_purchprice_accnt_id=pp.accnt_id) AND (expcat_liability_accnt_id=lb.accnt_id) AND (expcat_id=_g.poitem_expcat_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Void Voucher #% due to unassigned G/L Accounts [xtuple: voidAPOpenVoucher, -40, %]', _p.vohead_number, _p.vohead_number; END IF; ELSE SELECT pp.accnt_id AS pp_accnt_id, lb.accnt_id AS lb_accnt_id INTO _a FROM costcat, accnt AS pp, accnt AS lb WHERE ( (costcat_purchprice_accnt_id=pp.accnt_id) AND (costcat_liability_accnt_id=lb.accnt_id) AND (costcat_id=_g.costcatid) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Void Voucher #% due to unassigned G/L Accounts [xtuple: voidAPOpenVoucher, -50, %]', _p.vohead_number, _p.vohead_number; END IF; END IF; -- Clear the Item Amount accumulator _itemAmount_base := 0; _itemAmount := 0; -- Figure out the total posted value for this line item FOR _d IN SELECT vodist_id, vodist_amount, _p.vohead_curr_id, vodist_costelem_id, currToBase(_p.vohead_curr_id, vodist_amount, _p.vohead_distdate) AS vodist_amount_base FROM vodist WHERE ( (vodist_vohead_id=_p.vohead_id) AND (vodist_poitem_id=_g.poitem_id) ) LOOP _pExplain := TRUE; SELECT * INTO _costx FROM itemcost WHERE ( (itemcost_item_id = _g.itemsite_item_id) AND (itemcost_costelem_id = _d.vodist_costelem_id) ); IF (FOUND) THEN _pExplain := _costx.itemcost_lowlevel; END IF; -- Add the Distribution Amount to the Item Amount _itemAmount_base := _itemAmount_base + ROUND(_d.vodist_amount_base, 2); _itemAmount := _itemAmount + _d.vodist_amount; END LOOP; -- Distribute from the clearing account PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number), _a.lb_accnt_id, round(_g.value_base + _g.vouchered_freight_base, 2), _glDate, _p.glnotes ); -- Attribute the correct portion to currency gain/loss _exchGainFreight := 0; SELECT currGain(_p.pohead_curr_id, _g.vouchered_freight, _firstExchDateFreight, _p.vohead_distdate ) INTO _exchGainFreight; IF (round(_exchGainFreight, 2) <> 0) THEN PERFORM insertIntoGLSeries(_sequence, 'A/P', 'VO', text(_p.vohead_number), getGainLossAccntId(_a.lb_accnt_id), round(_exchGainFreight, 2) * -1, _glDate, _p.glnotes); END IF; -- Distribute the remaining variance to the Purchase Price Variance account IF (round(_itemAmount_base, 2) <> round(_g.value_base, 2)) THEN _tmpTotal := round(_itemAmount_base, 2) - round(_g.value_base, 2); PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number), _a.pp_accnt_id, _tmpTotal, _glDate, _p.glnotes ); END IF; -- Distribute the remaining freight variance to the Purchase Price Variance account IF (round(_g.voitem_freight_base + _exchGainFreight, 2) <> round(_g.vouchered_freight_base, 2)) THEN _tmpTotal := round(_g.voitem_freight_base + _exchGainFreight, 2) - round(_g.vouchered_freight_base, 2); PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number), _a.pp_accnt_id, _tmpTotal, _glDate, _p.glnotes ); END IF; -- Add the distribution amount to the total amount to distribute _totalAmount_base := (_totalAmount_base + _itemAmount_base + _g.voitem_freight_base); _totalAmount := (_totalAmount + _itemAmount + _g.voitem_freight); -- Reverse the posting for all the Tagged Receivings for this P/O Item UPDATE recv SET recv_invoiced=FALSE, recv_recvcost_curr_id=basecurrid(), recv_recvcost=0, recv_vohead_id=NULL, recv_voitem_id=NULL FROM poitem WHERE ( (recv_orderitem_id=poitem_id) AND (recv_order_type='PO') AND (recv_orderitem_id=_g.poitem_id) AND (recv_vohead_id=_p.vohead_id) ); -- Reverse the posting for all the Tagged Rejections for this P/O Item UPDATE poreject SET poreject_invoiced=FALSE, poreject_vohead_id=NULL, poreject_voitem_id=NULL WHERE ( (poreject_poitem_id=_g.poitem_id) AND (poreject_vohead_id=_p.vohead_id) ); -- Update the qty and freight vouchered fields UPDATE poitem SET poitem_qty_vouchered = (poitem_qty_vouchered - _g.voitem_qty), poitem_freight_vouchered = (poitem_freight_vouchered - _g.voitem_freight) WHERE (poitem_id=_g.poitem_id); END LOOP; -- Loop through the vodist records for the passed vohead that -- are not posted against a P/O Item -- Skip the tax distributions FOR _d IN SELECT vodist_id, currToBase(_p.vohead_curr_id, vodist_amount, _p.vohead_distdate) AS vodist_amount_base, vodist_amount, vodist_accnt_id, vodist_expcat_id FROM vodist WHERE ( (vodist_vohead_id=_p.vohead_id) AND (vodist_poitem_id=-1) AND (vodist_tax_id=-1) ) LOOP -- Distribute from the misc. account IF (_d.vodist_accnt_id = -1) THEN PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number), expcat_exp_accnt_id, round(_d.vodist_amount_base, 2), _glDate, _p.glnotes ) FROM expcat WHERE (expcat_id=_d.vodist_expcat_id); ELSE PERFORM insertIntoGLSeries( _sequence, 'A/P', 'VO', text(_p.vohead_number), _d.vodist_accnt_id, round(_d.vodist_amount_base, 2), _glDate, _p.glnotes ); END IF; -- Add the Distribution Amount to the Total Amount _totalAmount_base := _totalAmount_base + ROUND(_d.vodist_amount_base, 2); _totalAmount := _totalAmount + _d.vodist_amount; END LOOP; SELECT insertIntoGLSeries( _sequence, 'A/P', 'VO', text(vohead_number), accnt_id, round(_totalAmount_base, 2) * -1, _glDate, _p.glnotes ) INTO _test FROM vohead LEFT OUTER JOIN accnt ON (accnt_id=findAPAccount(vohead_vend_id)) WHERE ( (findAPAccount(vohead_vend_id)=0 OR accnt_id > 0) -- G/L interface might be disabled AND (vohead_id=_p.vohead_id) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Void Voucher #% due to an unassigned A/P Account [xtuple: voidAPOpenVoucher, -60, %]', _p.vohead_number, _p.vohead_number; END IF; PERFORM postGLSeries(_sequence, pJournalNumber); -- Create the A/P Open Item SELECT NEXTVAL('apopen_apopen_id_seq') INTO _apopenid; _reference := ('Void Voucher #' || _n.apopen_docnumber); INSERT INTO apopen ( apopen_id, apopen_username, apopen_journalnumber, apopen_vend_id, apopen_docnumber, apopen_doctype, apopen_ponumber, apopen_docdate, apopen_duedate, apopen_distdate, apopen_terms_id, apopen_curr_id, apopen_amount, apopen_paid, apopen_open, apopen_notes, apopen_discount, apopen_curr_rate ) SELECT _apopenid, getEffectiveXtUser(), pJournalnumber, apopen_vend_id, apopen_docnumber, 'C', apopen_ponumber, _glDate, _glDate, _glDate, -1, apopen_curr_id, apopen_amount - apopen_paid, 0, TRUE, _reference, TRUE, apopen_curr_rate FROM apopen WHERE (apopen_id=_n.apopen_id); SELECT apcreditapply_id INTO _apcreditapplyid FROM apcreditapply WHERE ( (apcreditapply_source_apopen_id=_apopenid) AND (apcreditapply_target_apopen_id=_n.apopen_id) ); IF (FOUND) THEN UPDATE apcreditapply SET apcreditapply_amount=_n.apopen_amount-_n.apopen_paid WHERE (apcreditapply_id=_apcreditapplyid); ELSE SELECT nextval('apcreditapply_apcreditapply_id_seq') INTO _apcreditapplyid; INSERT INTO apcreditapply ( apcreditapply_id, apcreditapply_source_apopen_id, apcreditapply_target_apopen_id, apcreditapply_amount, apcreditapply_curr_id ) VALUES ( _apcreditapplyid, _apopenid, _n.apopen_id, _n.apopen_amount-_n.apopen_paid, _n.apopen_curr_id ); END IF; SELECT postAPCreditMemoApplication(_apopenid) INTO _result; IF (_result < 0) THEN RAISE EXCEPTION 'Credit application failed with result % [xtuple: voidAPOpenVoucher, -70, %]', _result, _result; END IF; -- Reopen all of the P/O Items that were closed by this Voucher UPDATE poitem SET poitem_status='O' FROM voitem WHERE ( (voitem_poitem_id=poitem_id) AND (voitem_close) AND (voitem_vohead_id=_p.vohead_id) ); -- Reopen the P/O UPDATE pohead SET pohead_status='O' WHERE (pohead_id=_p.vohead_pohead_id); -- Delete any apselect approval records to prevent incorrect payment runs DELETE FROM apselect WHERE (apselect_apopen_id=_n.apopen_id); -- Mark as voided UPDATE apopen SET apopen_void=TRUE WHERE (apopen_id=_n.apopen_id); RETURN pJournalNumber; END; $_$; :DROP FUNCTION public.voidapopenvoucher(integer, integer); publicadminfalse46238125579503voidcheck(integer)FUNCTIONCREATE FUNCTION voidcheck(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCheckid ALIAS FOR $1; BEGIN IF ( SELECT (checkhead_void OR checkhead_posted OR checkhead_replaced) FROM checkhead WHERE (checkhead_id=pCheckid) ) THEN RETURN -1; END IF; UPDATE checkhead SET checkhead_void=TRUE WHERE (checkhead_id=pCheckid); RETURN 1; END; $_$; )DROP FUNCTION public.voidcheck(integer); publicadminfalse84623125579504voidcreditmemo(integer)FUNCTION$CREATE FUNCTION voidcreditmemo(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCmheadid ALIAS FOR $1; _r RECORD; _p RECORD; _n RECORD; _glSequence INTEGER := 0; _glJournal INTEGER := 0; _itemlocSeries INTEGER := 0; _invhistid INTEGER; _test INTEGER; _amount NUMERIC; _roundedBase NUMERIC; _totalAmount NUMERIC := 0; _totalRoundedBase NUMERIC := 0; _commissionDue NUMERIC := 0; _toApply NUMERIC; _toClose BOOLEAN; _glDate DATE; _taxBaseValue NUMERIC := 0; BEGIN -- Cache C/M information SELECT cmhead.*, findARAccount(cmhead_cust_id) AS ar_accnt_id, ( SELECT COALESCE(SUM(taxhist_tax), 0) FROM cmheadtax WHERE ( (taxhist_parent_id = cmhead_id) AND (taxhist_taxtype_id = getAdjustmentTaxtypeId()) ) ) AS adjtax INTO _p FROM cmhead WHERE (cmhead_id=pCmheadid); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Void Credit Memo as cmhead not found'; END IF; IF (NOT _p.cmhead_posted) THEN RETURN -10; END IF; -- Cache AROpen Information SELECT aropen.* INTO _n FROM aropen WHERE ( (aropen_doctype='C') AND (aropen_docnumber=_p.cmhead_number) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Void Credit Memo as aropen not found'; END IF; -- Check for ARApplications SELECT arapply_id INTO _test FROM arapply WHERE (arapply_target_aropen_id=_n.aropen_id) OR (arapply_source_aropen_id=_n.aropen_id) LIMIT 1; IF (FOUND) THEN RETURN -20; END IF; _glDate := COALESCE(_p.cmhead_gldistdate, _p.cmhead_docdate); SELECT fetchGLSequence() INTO _glSequence; SELECT fetchJournalNumber('AR-IN') INTO _glJournal; -- Start by handling taxes (reverse sense) FOR _r IN SELECT tax_sales_accnt_id, round(sum(taxdetail_tax),2) AS tax, currToBase(_p.cmhead_curr_id, round(sum(taxdetail_tax),2), _p.cmhead_docdate) AS taxbasevalue FROM tax JOIN calculateTaxDetailSummary('CM', _p.cmhead_id, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id, tax_sales_accnt_id LOOP PERFORM insertIntoGLSeries( _glSequence, 'A/R', 'CM', _p.cmhead_number, _r.tax_sales_accnt_id, (_r.taxbasevalue * -1.0), _glDate, ('Void-' || _p.cmhead_billtoname) ); _totalAmount := _totalAmount + _r.tax * -1; _totalRoundedBase := _totalRoundedBase + _r.taxbasevalue * -1; END LOOP; -- Process line items FOR _r IN SELECT * FROM creditmemoitem WHERE ( (cmitem_cmhead_id=_p.cmhead_id) AND (cmitem_qtycredit <> 0 ) ) LOOP IF (_r.extprice <> 0) THEN -- Debit the Sales Account for the current cmitem (reverse sense) _roundedBase := round(currToBase(_p.cmhead_curr_id, _r.extprice, _p.cmhead_docdate), 2); SELECT insertIntoGLSeries( _glSequence, 'A/R', 'CM', _p.cmhead_number, CASE WHEN _p.cmhead_rahead_id IS NULL THEN getPrjAccntId(_p.cmhead_prj_id, salesaccnt_credit_accnt_id) ELSE getPrjAccntId(_p.cmhead_prj_id, salesaccnt_returns_accnt_id) END, _roundedBase, _glDate, ('Void-' || _p.cmhead_billtoname) ) INTO _test FROM salesaccnt WHERE (salesaccnt_id=findSalesAccnt(_r.cmitem_itemsite_id, 'IS', _p.cmhead_cust_id, _p.cmhead_saletype_id, _p.cmhead_shipzone_id)); IF (NOT FOUND) THEN PERFORM deleteGLSeries(_glSequence); RETURN -11; END IF; END IF; _totalAmount := _totalAmount + round(_r.extprice, 2); _totalRoundedBase := _totalRoundedBase + _roundedBase; END LOOP; -- Credit the Misc. Account for Miscellaneous Charges (reverse sense) IF (_p.cmhead_misc <> 0) THEN _roundedBase := round(currToBase(_p.cmhead_curr_id, _p.cmhead_misc, _p.cmhead_docdate), 2); SELECT insertIntoGLSeries( _glSequence, 'A/R', 'CM', _p.cmhead_number, getPrjAccntId(_p.cmhead_prj_id, accnt_id), _roundedBase, _glDate, ('Void-' ||_p.cmhead_billtoname) ) INTO _test FROM accnt WHERE (accnt_id=_p.cmhead_misc_accnt_id); -- If the Misc. Charges Account was not found then punt IF (NOT FOUND) THEN PERFORM deleteGLSeries(_glSequence); RETURN _test; END IF; -- Cache the Misc. Amount distributed _totalAmount := _totalAmount + _p.cmhead_misc; _totalRoundedBase := _totalRoundedBase + _roundedBase; END IF; -- Debit the Freight Account (reverse sense) IF (_p.cmhead_freight <> 0) THEN _roundedBase := round(currToBase(_p.cmhead_curr_id, _p.cmhead_freight, _p.cmhead_docdate), 2); SELECT insertIntoGLSeries( _glSequence, 'A/R', 'CM', _p.cmhead_number, getPrjAccntId(_p.cmhead_prj_id, accnt_id), _roundedBase, _glDate, ('Void-' || _p.cmhead_billtoname) ) INTO _test FROM accnt WHERE (accnt_id=findFreightAccount(_p.cmhead_cust_id)); -- If the Freight Charges Account was not found then punt IF (NOT FOUND) THEN PERFORM deleteGLSeries(_glSequence); RETURN _test; END IF; -- Cache the Amount Distributed to Freight _totalAmount := _totalAmount + _p.cmhead_freight; _totalRoundedBase := _totalRoundedBase + _roundedBase; END IF; _totalAmount := _totalAmount; -- Credit the A/R for the total Amount (reverse sense) IF (_totalAmount <> 0) THEN IF (_p.ar_accnt_id != -1) THEN SELECT insertIntoGLSeries( _glSequence, 'A/R', 'CM', _p.cmhead_number, _p.ar_accnt_id, (_totalRoundedBase * -1.0), _glDate, ('Void-' || _p.cmhead_billtoname) ) INTO _test; ELSE PERFORM deleteGLSeries(_glSequence); RETURN _test; END IF; END IF; -- Commit the GLSeries; SELECT postGLSeries(_glSequence, _glJournal) INTO _test; IF (_test < 0) THEN PERFORM deleteGLSeries(_glSequence); RETURN _test; END IF; -- Delete sales history DELETE FROM cohisttax WHERE (taxhist_parent_id IN (SELECT cohist_id FROM cohist WHERE (cohist_doctype='C' AND cohist_ordernumber=_p.cmhead_number))); DELETE FROM cohist WHERE (cohist_doctype='C' AND cohist_ordernumber=_p.cmhead_number); -- Delete the Invoice aropen item DELETE FROM aropen WHERE (aropen_doctype='C' AND aropen_docnumber=_p.cmhead_number); -- Handle the Inventory and G/L Transactions for any returned Inventory where cmitem_updateinv is true (reverse sense) FOR _r IN SELECT cmitem_itemsite_id AS itemsite_id, cmitem_id, (cmitem_qtyreturned * cmitem_qty_invuomratio) AS qty, cmhead_number, cmhead_cust_id AS cust_id, item_number, cmhead_prj_id AS prj_id, cmhead_saletype_id AS saletype_id, cmhead_shipzone_id AS shipzone_id FROM cmhead, cmitem, itemsite, item WHERE ( (cmitem_cmhead_id=cmhead_id) AND (cmitem_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (cmitem_qtyreturned <> 0) AND (cmitem_updateinv) AND (cmhead_id=_p.cmhead_id) ) LOOP -- Return credited stock to inventory IF (_itemlocSeries = 0) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; END IF; SELECT postInvTrans( itemsite_id, 'RS', (_r.qty * -1), 'S/O', 'CM', _r.cmhead_number, '', ('Credit Voided ' || _r.item_number), costcat_asset_accnt_id, getPrjAccntId(_r.prj_id, resolveCOSAccount(itemsite_id, _r.cust_id, _r.saletype_id, _r.shipzone_id)), _itemlocSeries, _glDate) INTO _invhistid FROM itemsite, costcat WHERE ( (itemsite_costcat_id=costcat_id) AND (itemsite_id=_r.itemsite_id) ); END LOOP; -- Update coitem to reflect the returned qty where cmitem_updateinv is true (reverse sense) FOR _r IN SELECT cmitem_qtyreturned, cmitem_itemsite_id, cohead_id FROM cmitem, cmhead, invchead, cohead WHERE ( (cmitem_cmhead_id=cmhead_id) AND (cmhead_invcnumber=invchead_invcnumber) AND (invchead_ordernumber=cohead_number) AND (cmitem_qtyreturned <> 0) AND (cmitem_updateinv) AND (cmhead_id=_p.cmhead_id) ) LOOP UPDATE coitem SET coitem_qtyreturned = (coitem_qtyreturned + (_r.cmitem_qtyreturned * -1.0)) WHERE coitem_id IN ( SELECT coitem_id FROM coitem WHERE ( (coitem_cohead_id=_r.cohead_id) AND (coitem_itemsite_id = _r.cmitem_itemsite_id) ) LIMIT 1 ); END LOOP; -- Mark the cmhead as voided UPDATE cmhead SET cmhead_void=TRUE WHERE (cmhead_id=_p.cmhead_id); RETURN _itemlocSeries; END; $_$; .DROP FUNCTION public.voidcreditmemo(integer); publicadminfalse84623125579506voidinvoice(integer)FUNCTION;CREATE FUNCTION voidinvoice(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pInvcheadid ALIAS FOR $1; _glSequence INTEGER := 0; _glJournal INTEGER := 0; _itemlocSeries INTEGER := 0; _aropenid INTEGER := 0; _invhistid INTEGER := 0; _amount NUMERIC; _roundedBase NUMERIC; _r RECORD; _p RECORD; _n RECORD; _test INTEGER; _totalAmount NUMERIC := 0; _totalRoundedBase NUMERIC := 0; _totalAmountBase NUMERIC := 0; _appliedAmount NUMERIC := 0; _commissionDue NUMERIC := 0; _tmpAccntId INTEGER; _tmpCurrId INTEGER; _firstExchDate DATE; _glDate DATE; _exchGain NUMERIC := 0; BEGIN -- Cache Invoice information SELECT invchead.*, findFreightAccount(invchead_cust_id) AS freightaccntid, findARAccount(invchead_cust_id) AS araccntid, aropen_id, cohist_unitcost, ( SELECT COALESCE(SUM(taxhist_tax), 0) FROM invcheadtax WHERE ( (taxhist_parent_id = invchead_id) AND (taxhist_taxtype_id = getFreightTaxtypeId()) ) ) AS freighttax, ( SELECT COALESCE(SUM(taxhist_tax), 0) FROM invcheadtax WHERE ( (taxhist_parent_id = invchead_id) AND (taxhist_taxtype_id = getAdjustmentTaxtypeId()) ) ) AS adjtax INTO _p FROM invchead JOIN aropen ON (aropen_doctype='I' AND aropen_docnumber=invchead_invcnumber) JOIN cohist ON (cohist_doctype='I' AND cohist_invcnumber=invchead_invcnumber) WHERE (invchead_id=pInvcheadid); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Void Invoice as invchead not found'; END IF; IF (NOT _p.invchead_posted) THEN RETURN -10; END IF; -- Cache AROpen Information SELECT aropen.* INTO _n FROM aropen WHERE ( (aropen_doctype='I') AND (aropen_docnumber=_p.invchead_invcnumber) ); IF (NOT FOUND) THEN RAISE EXCEPTION 'Cannot Void Invoice as aropen not found'; END IF; -- Check for ARApplications SELECT arapply_id INTO _test FROM arapply WHERE (arapply_target_aropen_id=_n.aropen_id) LIMIT 1; IF (FOUND) THEN RETURN -20; END IF; SELECT fetchGLSequence() INTO _glSequence; SELECT fetchJournalNumber('AR-IN') INTO _glJournal; _glDate := COALESCE(_p.invchead_gldistdate, _p.invchead_invcdate); -- the 1st MC iteration used the cohead_orderdate so we could get curr exch -- gain/loss between the sales and invoice dates, but see issue 3892. leave -- this condition TRUE until we make this configurable or decide not to. IF TRUE THEN _firstExchDate := _p.invchead_invcdate; ELSE -- can we save a select by using: _firstExchDate := _p.invchead_orderdate; SELECT cohead_orderdate INTO _firstExchDate FROM cohead WHERE (cohead_number = _p.invchead_ordernumber); END IF; -- Start by handling taxes (reverse sense) FOR _r IN SELECT tax_sales_accnt_id, round(sum(taxdetail_tax),2) AS tax, currToBase(_p.invchead_curr_id, round(sum(taxdetail_tax),2), _firstExchDate) AS taxbasevalue FROM tax JOIN calculateTaxDetailSummary('I', _p.invchead_id, 'T') ON (taxdetail_tax_id=tax_id) GROUP BY tax_id, tax_sales_accnt_id LOOP PERFORM insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber, _r.tax_sales_accnt_id, (_r.taxbasevalue * -1.0), _glDate, ('Void-' || _p.invchead_billto_name) ); _totalAmount := _totalAmount + _r.tax; _totalRoundedBase := _totalRoundedBase + _r.taxbasevalue; END LOOP; -- March through the Non-Misc. Invcitems FOR _r IN SELECT * FROM invoiceitem WHERE ( (invcitem_invchead_id = _p.invchead_id) AND (invcitem_item_id <> -1) ) LOOP -- Cache the amount due for this line _amount := _r.extprice; IF (_amount > 0) THEN -- Credit the Sales Account for the invcitem item (reverse sense) IF (_r.invcitem_rev_accnt_id IS NOT NULL) THEN SELECT getPrjAccntId(_p.invchead_prj_id, _r.invcitem_rev_accnt_id) INTO _tmpAccntId; ELSEIF (_r.itemsite_id IS NULL) THEN SELECT getPrjAccntId(_p.invchead_prj_id, salesaccnt_sales_accnt_id) INTO _tmpAccntId FROM salesaccnt WHERE (salesaccnt_id=findSalesAccnt(_r.invcitem_item_id, 'I', _p.invchead_cust_id, _p.invchead_saletype_id, _p.invchead_shipzone_id)); ELSE SELECT getPrjAccntId(_p.invchead_prj_id, salesaccnt_sales_accnt_id) INTO _tmpAccntId FROM salesaccnt WHERE (salesaccnt_id=findSalesAccnt(_r.itemsite_id, 'IS', _p.invchead_cust_id, _p.invchead_saletype_id, _p.invchead_shipzone_id)); END IF; -- If the Sales Account Assignment was not found then punt IF (NOT FOUND) THEN PERFORM deleteGLSeries(_glSequence); RETURN -11; END IF; _roundedBase := round(currToBase(_p.invchead_curr_id, _amount, _firstExchDate), 2); SELECT insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber, _tmpAccntId, (_roundedBase * -1.0), _glDate, ('Void-' || _p.invchead_billto_name) ) INTO _test; _totalAmount := (_totalAmount + _amount); _totalRoundedBase := _totalRoundedBase + _roundedBase; _commissionDue := (_commissionDue + (_amount * _p.invchead_commission)); END IF; _totalAmount := _totalAmount; _totalRoundedBase := _totalRoundedBase; END LOOP; -- March through the Misc. Invcitems FOR _r IN SELECT * FROM invoiceitem JOIN salescat ON (salescat_id = invcitem_salescat_id) WHERE ( (invcitem_item_id = -1) AND (invcitem_invchead_id=_p.invchead_id) ) LOOP -- Cache the amount due for this line and the commission due for such _amount := _r.extprice; IF (_amount > 0) THEN -- Credit the Sales Account for the invcitem item (reverse sense) _roundedBase = round(currToBase(_p.invchead_curr_id, _amount, _firstExchDate), 2); SELECT insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber, getPrjAccntId(_p.invchead_prj_id, COALESCE(_r.invcitem_rev_accnt_id, _r.salescat_sales_accnt_id)), (_roundedBase * -1.0), _glDate, ('Void-' || _p.invchead_billto_name) ) INTO _test; IF (_test < 0) THEN PERFORM deleteGLSeries(_glSequence); RETURN _test; END IF; _totalAmount := (_totalAmount + _amount); _totalRoundedBase := _totalRoundedBase + _roundedBase; _commissionDue := (_commissionDue + (_amount * _p.invchead_commission)); END IF; END LOOP; -- Credit the Freight Account for Freight Charges (reverse sense) IF (_p.invchead_freight <> 0) THEN IF (_p.freightaccntid <> -1) THEN _roundedBase = round(currToBase(_p.invchead_curr_id, _p.invchead_freight, _firstExchDate), 2); SELECT insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber, getPrjAccntId(_p.invchead_prj_id,_p.freightaccntid), (_roundedBase * -1.0), _glDate, ('Void-' || _p.invchead_billto_name) ) INTO _test; -- Cache the Freight Amount distributed _totalAmount := (_totalAmount + _p.invchead_freight); _totalRoundedBase := _totalRoundedBase + _roundedBase; ELSE _test := -14; END IF; -- If the Freight Account was not found then punt IF (_test < 0) THEN PERFORM deleteGLSeries(_glSequence); RETURN _test; END IF; END IF; -- Credit the Misc. Account for Miscellaneous Charges (reverse sense) IF (_p.invchead_misc_amount <> 0) THEN _roundedBase := round(currToBase(_p.invchead_curr_id, _p.invchead_misc_amount, _firstExchDate), 2); SELECT insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber, getPrjAccntId(_p.invchead_prj_id, _p.invchead_misc_accnt_id), (_roundedBase * -1.0), _glDate, ('Void-' || _p.invchead_billto_name) ) INTO _test; -- If the Misc. Charges Account was not found then punt IF (_test < 0) THEN PERFORM deleteGLSeries(_glSequence); RETURN _test; END IF; -- Cache the Misc. Amount distributed _totalAmount := (_totalAmount + _p.invchead_misc_amount); _totalRoundedBase := _totalRoundedBase + _roundedBase; END IF; -- ToDo: handle rounding errors (reverse sense) _exchGain := currGain(_p.invchead_curr_id, _totalAmount, _firstExchDate, _glDate); IF (_exchGain <> 0) THEN SELECT insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber, getGainLossAccntId(_p.araccntid), round(_exchGain, 2), _glDate, ('Void-' || _p.invchead_billto_name) ) INTO _test ; IF (_test < 0) THEN PERFORM deleteGLSeries(_glSequence); RETURN _test; END IF; END IF; -- Debit A/R for the total Amount (reverse sense) IF (_totalRoundedBase <> 0) THEN IF (_p.araccntid != -1) THEN SELECT insertIntoGLSeries( _glSequence, 'A/R', 'IN', _p.invchead_invcnumber, _p.araccntid, round(_totalRoundedBase, 2), _glDate, ('Void-' || _p.invchead_billto_name) ) INTO _test; ELSE PERFORM deleteGLSeries(_glSequence); RETURN _test; END IF; END IF; -- Commit the GLSeries; SELECT postGLSeries(_glSequence, _glJournal) INTO _test; IF (_test < 0) THEN PERFORM deleteGLSeries(_glSequence); RETURN _test; END IF; -- Delete sales history DELETE FROM cohisttax WHERE (taxhist_parent_id IN (SELECT cohist_id FROM cohist WHERE (cohist_doctype='I' AND cohist_invcnumber=_p.invchead_invcnumber))); DELETE FROM cohist WHERE (cohist_doctype='I' AND cohist_invcnumber=_p.invchead_invcnumber); -- Create the Credit aropen item SELECT nextval('aropen_aropen_id_seq') INTO _aropenid; INSERT INTO aropen ( aropen_id, aropen_username, aropen_journalnumber, aropen_open, aropen_posted, aropen_cust_id, aropen_ponumber, aropen_docnumber, aropen_applyto, aropen_doctype, aropen_docdate, aropen_duedate, aropen_distdate, aropen_terms_id, aropen_amount, aropen_paid, aropen_salesrep_id, aropen_commission_due, aropen_commission_paid, aropen_ordernumber, aropen_notes, aropen_cobmisc_id, aropen_curr_id ) VALUES ( _aropenid, getEffectiveXtUser(), _glJournal, TRUE, FALSE, _p.invchead_cust_id, _p.invchead_ponumber, _p.invchead_invcnumber, _p.invchead_invcnumber, 'C', _p.invchead_invcdate, determineDueDate(_p.invchead_terms_id, _p.invchead_invcdate), _glDate, _p.invchead_terms_id, round(_totalAmount, 2), round(_totalAmount, 2), _p.invchead_salesrep_id, _commissionDue, FALSE, _p.invchead_ordernumber::text, _p.invchead_notes, pInvcheadid, _p.invchead_curr_id ); -- Alter the Invoice A/R Open Item to reflect the application UPDATE aropen SET aropen_paid = round(_totalAmount, 2) WHERE (aropen_id=_p.aropen_id); -- Record the application INSERT INTO arapply ( arapply_cust_id, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_applied, arapply_closed, arapply_postdate, arapply_distdate, arapply_journalnumber, arapply_curr_id ) VALUES ( _p.invchead_cust_id, _aropenid, 'C', _p.invchead_invcnumber, _p.aropen_id, 'I', _p.invchead_invcnumber, '', '', round(_totalAmount, 2), TRUE, CURRENT_DATE, _p.invchead_invcdate, 0, _p.invchead_curr_id ); -- Handle the Inventory and G/L Transactions for any billed Inventory where invcitem_updateinv is true (reverse sense) FOR _r IN SELECT itemsite_id AS itemsite_id, invcitem_id, (invcitem_billed * invcitem_qty_invuomratio) AS qty, invchead_invcnumber, invchead_cust_id AS cust_id, item_number, invchead_prj_id AS prj_id, invchead_saletype_id AS saletype_id, invchead_shipzone_id AS shipzone_id FROM invchead JOIN invcitem ON ( (invcitem_invchead_id=invchead_id) AND (invcitem_billed <> 0) AND (invcitem_updateinv) ) JOIN itemsite ON ( (itemsite_item_id=invcitem_item_id) AND (itemsite_warehous_id=invcitem_warehous_id) ) JOIN item ON (item_id=invcitem_item_id) WHERE (invchead_id=_p.invchead_id) LOOP -- Return billed stock to inventory IF (_itemlocSeries = 0) THEN SELECT NEXTVAL('itemloc_series_seq') INTO _itemlocSeries; END IF; SELECT postInvTrans( itemsite_id, 'SH', (_r.qty * -1.0), 'S/O', 'IN', _r.invchead_invcnumber, '', ('Invoice Voided ' || _r.item_number), getPrjAccntId(_r.prj_id, resolveCOSAccount(itemsite_id, _r.cust_id, _r.saletype_id, _r.shipzone_id)), costcat_asset_accnt_id, _itemlocSeries, _glDate, (_p.cohist_unitcost * _r.qty)) INTO _invhistid FROM itemsite JOIN costcat ON (itemsite_costcat_id=costcat_id) WHERE (itemsite_id=_r.itemsite_id); END LOOP; -- Reopen Sales Order UPDATE coitem SET coitem_status='O' WHERE (coitem_id IN (SELECT cobill_coitem_id FROM invcitem JOIN cobill ON (cobill_invcitem_id=invcitem_id) WHERE (invcitem_invchead_id=_p.invchead_id))); -- Reopen Billing UPDATE shipitem SET shipitem_invoiced=FALSE, shipitem_invcitem_id=NULL WHERE (shipitem_invcitem_id IN (SELECT invcitem_id FROM invcitem WHERE (invcitem_invchead_id=_p.invchead_id))); UPDATE cobill SET cobill_invcnum=NULL, cobill_invcitem_id=NULL WHERE (cobill_invcitem_id IN (SELECT invcitem_id FROM invcitem WHERE (invcitem_invchead_id=_p.invchead_id))); UPDATE cobmisc SET cobmisc_posted=FALSE, cobmisc_invcnumber=NULL, cobmisc_invchead_id=NULL WHERE (cobmisc_invchead_id=_p.invchead_id); -- Mark the invoice as voided UPDATE invchead SET invchead_void=TRUE, invchead_notes=(invchead_notes || 'Voided on ' || current_date || ' by ' || getEffectiveXtUser()) WHERE (invchead_id=_p.invchead_id); RETURN _itemlocSeries; END; $_$; +DROP FUNCTION public.voidinvoice(integer); publicadminfalse84623125579508voidpostedapcheck(integer)FUNCTIONCREATE FUNCTION voidpostedapcheck(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'voidPostedAPCheck() is deprecated - use voidPostedCheck() instead'; RETURN voidPostedCheck($1, fetchJournalNumber('AP-CK'), CURRENT_DATE); END; $_$; 1DROP FUNCTION public.voidpostedapcheck(integer); publicadminfalse46238125579509#voidpostedapcheck(integer, integer)FUNCTIONxCREATE FUNCTION voidpostedapcheck(integer, integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'voidPostedAPCheck() is deprecated - use voidPostedCheck() instead'; RETURN voidPostedCheck($1, $2, CURRENT_DATE); END; $_$; :DROP FUNCTION public.voidpostedapcheck(integer, integer); publicadminfalse46238125579510)voidpostedapcheck(integer, integer, date)FUNCTIONtCREATE FUNCTION voidpostedapcheck(integer, integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RAISE WARNING 'voidPostedAPCheck() is deprecated - use voidPostedCheck() instead'; RETURN voidPostedCheck($1, $2, $3); END; $_$; @DROP FUNCTION public.voidpostedapcheck(integer, integer, date); publicadminfalse46238125579511'voidpostedcheck(integer, integer, date)FUNCTION5CREATE FUNCTION voidpostedcheck(integer, integer, date) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pCheckid ALIAS FOR $1; pJournalNumber ALIAS FOR $2; pVoidDate ALIAS FOR $3; _amount_base NUMERIC := 0; _result INTEGER; _apopenid INTEGER; _credit_glaccnt INTEGER; _docnumber TEXT; _exchGain NUMERIC := 0; _exchGainTmp NUMERIC := 0; _gltransNote TEXT; _p RECORD; _r RECORD; _sequence INTEGER; _amount_check NUMERIC := 0; BEGIN SELECT fetchGLSequence() INTO _sequence; SELECT checkhead.*, checkhead_amount / checkhead_curr_rate AS checkhead_amount_base, bankaccnt_accnt_id AS bankaccntid, findPrepaidAccount(checkhead_recip_id) AS prepaidaccntid, checkrecip.* INTO _p FROM bankaccnt, checkhead LEFT OUTER JOIN checkrecip ON ((checkrecip_type=checkhead_recip_type) AND (checkrecip_id=checkhead_recip_id)) WHERE ((checkhead_bankaccnt_id=bankaccnt_id) AND (checkhead_id=pCheckid)); IF (NOT _p.checkhead_posted) THEN RETURN -10; END IF; IF (_p.checkrecip_id IS NULL) THEN -- outer join failed RETURN -11; END IF; -- Cannot void if already reconciled SELECT trans_id INTO _result FROM ( SELECT gltrans_id AS trans_id FROM gltrans LEFT OUTER JOIN bankrecitem ON (bankrecitem_source='GL' AND bankrecitem_source_id=gltrans_id) WHERE ( (gltrans_doctype='CK') AND (gltrans_misc_id=_p.checkhead_id) AND ((gltrans_rec) OR (bankrecitem_id IS NOT NULL)) ) UNION ALL SELECT sltrans_id AS trans_id FROM sltrans LEFT OUTER JOIN bankrecitem ON (bankrecitem_source='GL' AND bankrecitem_source_id=sltrans_id) WHERE ( (sltrans_doctype='CK') AND (sltrans_misc_id=_p.checkhead_id) AND ((sltrans_rec) OR (bankrecitem_id IS NOT NULL)) ) ) AS data; IF (FOUND) THEN RETURN -14; END IF; _gltransNote := 'Void Posted Check #' || _p.checkhead_number || ' ' || _p.checkrecip_number || '-' || _p.checkrecip_name; IF (_p.checkhead_misc) THEN IF (COALESCE(_p.checkhead_expcat_id, -1) < 0) THEN IF (_p.checkhead_recip_type = 'V') THEN PERFORM createAPDebitMemo(_p.checkhead_recip_id, pJournalNumber, CAST(fetchAPMemoNumber() AS text), '', pVoidDate, _p.checkhead_amount, _gltransNote || ' '|| _p.checkhead_notes, -1, pVoidDate, -1, _p.checkhead_curr_id ); _credit_glaccnt := findAPPrepaidAccount(_p.checkhead_recip_id); ELSIF (_p.checkhead_recip_type = 'C') THEN PERFORM createARCreditMemo(NULL, _p.checkhead_recip_id, fetchARMemoNumber(), '', pVoidDate, _p.checkhead_amount, _gltransNote || ' '|| _p.checkhead_notes, -1, -1, -1, pVoidDate, -1, NULL, 0.0, pJournalNumber, _p.checkhead_curr_id ); _credit_glaccnt := _p.prepaidaccntid; ELSIF (_p.checkhead_recip_type = 'T') THEN -- TODO: should we create a debit memo for the tax authority? how? _credit_glaccnt := _p.checkrecip_accnt_id; END IF; -- recip type ELSE SELECT expcat_exp_accnt_id INTO _credit_glaccnt FROM expcat WHERE (expcat_id=_p.checkhead_expcat_id); IF (NOT FOUND) THEN RETURN -12; END IF; END IF; IF (COALESCE(_credit_glaccnt, -1) < 0) THEN RETURN -13; END IF; PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source, 'CK', text(_p.checkhead_number), _credit_glaccnt, round(_p.checkhead_amount_base, 2), pVoidDate, _gltransNote, pCheckid); _amount_base := _p.checkhead_amount_base; ELSE FOR _r IN SELECT checkitem_amount, checkitem_discount, CASE WHEN (checkitem_apopen_id IS NOT NULL AND apopen_doctype='C') THEN checkitem_amount / apopen_curr_rate * -1.0 WHEN (checkitem_apopen_id IS NOT NULL) THEN checkitem_amount / apopen_curr_rate ELSE currToBase(checkitem_curr_id, checkitem_amount, COALESCE(checkitem_docdate, _p.checkhead_checkdate)) END AS checkitem_amount_base, currTocurr(checkitem_curr_id, _p.checkhead_curr_id, CASE WHEN (checkitem_apopen_id IS NOT NULL AND apopen_doctype='C') THEN checkitem_amount * -1.0 ELSE checkitem_amount END, _p.checkhead_checkdate) AS amount_check, apopen_id, apopen_doctype, apopen_docnumber, apopen_curr_rate, apopen_docdate, aropen_id, aropen_doctype, aropen_docnumber, checkitem_curr_id, checkitem_curr_rate, COALESCE(checkitem_docdate, _p.checkhead_checkdate) AS docdate FROM (checkitem LEFT OUTER JOIN apopen ON (checkitem_apopen_id=apopen_id)) LEFT OUTER JOIN aropen ON (checkitem_aropen_id=aropen_id) WHERE (checkitem_checkhead_id=pcheckid) LOOP _exchGainTmp := 0; IF (_r.apopen_id IS NOT NULL) THEN -- undo the APDiscount Credit Memo if a discount was taken IF(_r.checkitem_discount > 0) THEN SELECT NEXTVAL('apopen_apopen_id_seq') INTO _apopenid; SELECT fetchAPMemoNumber() INTO _docnumber; INSERT INTO apopen ( apopen_id, apopen_username, apopen_journalnumber, apopen_vend_id, apopen_docnumber, apopen_doctype, apopen_ponumber, apopen_docdate, apopen_duedate, apopen_distdate, apopen_terms_id, apopen_amount, apopen_paid, apopen_open, apopen_notes, apopen_accnt_id, apopen_curr_id, apopen_discount, apopen_curr_rate, apopen_closedate ) VALUES ( _apopenid, getEffectiveXtUser(), pJournalNumber, _p.checkhead_recip_id, _docnumber, 'D', '', pVoidDate, pVoidDate, pVoidDate, -1, _r.checkitem_discount, _r.checkitem_discount, FALSE, ('Reverse Posted Discount ' || _r.apopen_doctype || ' ' || _r.apopen_docnumber), -1, _p.checkhead_curr_id, TRUE, _r.apopen_curr_rate, current_date ); PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source, 'DS', _r.apopen_docnumber, findAPDiscountAccount(_p.checkhead_recip_id), round(_r.checkitem_discount / _r.apopen_curr_rate, 2) * -1, pVoidDate, _gltransNote, pCheckid); PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source, 'DS', _r.apopen_docnumber, findAPAccount(_p.checkhead_recip_id), round(_r.checkitem_discount / _r.apopen_curr_rate, 2), pVoidDate, _gltransNote, pCheckid); -- Post the application INSERT INTO apapply ( apapply_vend_id, apapply_postdate, apapply_username, apapply_source_apopen_id, apapply_source_doctype, apapply_source_docnumber, apapply_target_apopen_id, apapply_target_doctype, apapply_target_docnumber, apapply_journalnumber, apapply_amount, apapply_curr_id ) VALUES ( _p.checkhead_recip_id, pVoidDate, getEffectiveXtUser(), _apopenid, 'D', _docnumber, _r.apopen_id, _r.apopen_doctype, _r.apopen_docnumber, pJournalNumber, (_r.checkitem_discount * -1), _r.checkitem_curr_id ); END IF; -- discount was taken UPDATE apopen SET apopen_paid = round(apopen_paid - (_r.checkitem_amount + noNeg(_r.checkitem_discount)), 2), apopen_open = round(apopen_amount, 2) > round(apopen_paid - (_r.checkitem_amount + noNeg(_r.checkitem_discount)), 2), apopen_closedate = CASE WHEN (round(apopen_amount, 2) > round(apopen_paid - (_r.checkitem_amount + noNeg(_r.checkitem_discount)))) THEN NULL ELSE apopen_closedate END WHERE (apopen_id=_r.apopen_id); -- Post the application INSERT INTO apapply ( apapply_vend_id, apapply_postdate, apapply_username, apapply_source_apopen_id, apapply_source_doctype, apapply_source_docnumber, apapply_target_apopen_id, apapply_target_doctype, apapply_target_docnumber, apapply_journalnumber, apapply_amount, apapply_curr_id ) VALUES ( _p.checkhead_recip_id, pVoidDate, getEffectiveXtUser(), -1, 'K', _p.checkhead_number, _r.apopen_id, _r.apopen_doctype, _r.apopen_docnumber, pJournalNumber, (_r.checkitem_amount * -1), _r.checkitem_curr_id ); END IF; -- if check item's apopen_id is not null IF (_r.aropen_id IS NOT NULL) THEN UPDATE aropen SET aropen_paid = round(aropen_paid -_r.checkitem_amount, 2), aropen_open = round(aropen_amount, 2) > round(aropen_paid - _r.checkitem_amount, 2) WHERE (aropen_id=_r.aropen_id); -- Post the application INSERT INTO arapply ( arapply_cust_id, arapply_postdate, arapply_distdate, arapply_username, arapply_source_aropen_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_aropen_id, arapply_target_doctype, arapply_target_docnumber, arapply_journalnumber, arapply_applied, arapply_curr_id ) VALUES ( _p.checkhead_recip_id, pVoidDate, pVoidDate, getEffectiveXtUser(), -1, 'K', _p.checkhead_number, _r.aropen_id, _r.aropen_doctype, _r.aropen_docnumber, pJournalNumber, (_r.checkitem_amount * -1), _r.checkitem_curr_id ); END IF; -- if check item's aropen_id is not null -- calculate currency gain/loss IF (_r.apopen_id IS NOT NULL) THEN IF (_p.checkhead_curr_id = _r.checkitem_curr_id) THEN IF (_r.apopen_docdate > _p.checkhead_checkdate) THEN _exchGainTmp := ((_r.checkitem_amount/_p.checkhead_curr_rate) - (_r.checkitem_amount / _r.apopen_curr_rate)) * -1; ELSE _exchGainTmp := ((_r.checkitem_amount / _r.apopen_curr_rate) - (_r.checkitem_amount/_p.checkhead_curr_rate)); END IF; ELSE -- unusual condition where bank overridden and different currency from voucher -- this does not work for all situations --IF (_r.apopen_docdate > _p.checkhead_checkdate) THEN -- _exchGainTmp := ((_r.checkitem_amount/_r.checkitem_curr_rate) - (_r.checkitem_amount / _r.apopen_curr_rate)) * -1; --ELSE -- _exchGainTmp := ((_r.checkitem_amount / _r.apopen_curr_rate) - (_r.checkitem_amount/_r.checkitem_curr_rate)); --END IF; _exchGainTmp := 0.0; END IF; ELSE SELECT arCurrGain(_r.aropen_id,_r.checkitem_curr_id, _r.checkitem_amount, _p.checkhead_checkdate) INTO _exchGainTmp; END IF; _exchGain := _exchGain + _exchGainTmp; PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source, 'CK', text(_p.checkhead_number), _p.checkrecip_accnt_id, round(_r.checkitem_amount_base, 2), pVoidDate, _gltransNote, pCheckid); IF (_exchGainTmp <> 0) THEN PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source, 'CK', text(_p.checkhead_number), getGainLossAccntId(_p.checkrecip_accnt_id), round(_exchGainTmp, 2) * -1, pVoidDate, _gltransNote, pCheckid); END IF; _amount_check := (_amount_check + _r.amount_check); _amount_base := (_amount_base + _r.checkitem_amount_base); END LOOP; IF( (_amount_check - _p.checkhead_amount) <> 0.0 ) THEN _exchGainTmp := (_amount_check - _p.checkhead_amount) / _p.checkhead_curr_rate; _exchGain := _exchGain + _exchGainTmp; END IF; -- ensure that the check balances, attribute rounding errors to gain/loss IF round(_amount_base, 2) - round(_exchGain, 2) <> round(_p.checkhead_amount_base, 2) THEN IF round(_amount_base - _exchGain, 2) = round(_p.checkhead_amount_base, 2) THEN PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source, 'CK', text(_p.checkhead_number), getGainLossAccntId(_p.bankaccntid), (round(_amount_base, 2) - round(_exchGain, 2) - round(_p.checkhead_amount_base, 2)) * -1, pVoidDate, _gltransNote, pCheckid); ELSE RAISE EXCEPTION 'checkhead_id % does not balance (% - % <> %)', pCheckid, _amount_base, _exchGain, _p.checkhead_amount_base; END IF; END IF; END IF; PERFORM insertIntoGLSeries( _sequence, _p.checkrecip_gltrans_source, 'CK', text(_p.checkhead_number), _p.bankaccntid, round(_p.checkhead_amount_base, 2) * -1, pVoidDate, _gltransNote, pCheckid); PERFORM postGLSeries(_sequence, pJournalNumber); UPDATE gltrans SET gltrans_misc_id=pCheckid WHERE gltrans_sequence=_sequence; UPDATE checkhead SET checkhead_posted=false, checkhead_void=true, checkhead_journalnumber=pJournalNumber WHERE (checkhead_id=pCheckid); RETURN pJournalNumber; END; $_$; >DROP FUNCTION public.voidpostedcheck(integer, integer, date); publicadminfalse46238125579513woeffectivedate(date)FUNCTIONqCREATE FUNCTION woeffectivedate(date) RETURNS date LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pStartDate ALIAS FOR $1; BEGIN IF (explodeWoEffective() = 'E') THEN RETURN CURRENT_DATE; ELSE RETURN pStartDate; END IF; END; $_$; ,DROP FUNCTION public.woeffectivedate(date); publicadminfalse46238125587108.woinvavail(integer, integer, boolean, boolean)FUNCTIONV CREATE FUNCTION woinvavail(integer, integer, boolean, boolean) RETURNS SETOF woinvav LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pwoid ALIAS FOR $1; plevel ALIAS FOR $2; pshowshortage ALIAS FOR $3; pshowlowinventory ALIAS FOR $4; _row woinvav%ROWTYPE; _x RECORD; _subx RECORD; _index INTEGER; _level INTEGER; _qry TEXT; BEGIN FOR _x IN SELECT wo_id, itemsite_id, item_type, wo_number, wo_subnumber, item_number, item_descrip1, item_descrip2, uom_name, qoh, wobalance, allocated, ordered, reorderlevel, (qoh + ordered - wobalance) AS woavail, (qoh + ordered - allocated) AS totalavail FROM(SELECT wo_id, itemsite_id, item_type, wo_number, wo_subnumber, item_number, item_descrip1, item_descrip2, uom_name, noNeg(qtyAvailable(itemsite_id)) AS qoh, noNeg(wo_qtyord - wo_qtyrcv) AS wobalance, qtyAllocated(itemsite_id, wo_duedate) AS allocated, qtyOrdered(itemsite_id, wo_duedate) AS ordered, CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel FROM wo, itemsite, item, uom WHERE ((wo_ordid = pwoid AND wo_ordtype = 'W') AND NOT (wo_status = 'C') AND (itemsite_id = wo_itemsite_id) AND (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id)) ORDER BY wo_number, wo_subnumber) AS data LOOP _row.woinvav_itemsite_id := _x.itemsite_id; _row.woinvav_womatl_id := -1; _row.woinvav_type := _x.item_type; _row.woinvav_item_wo_number := _x.wo_number || '-' || _x.wo_subnumber; _row.woinvav_descrip := _x.item_descrip1 || ' ' || _x.item_descrip2; _row.woinvav_uomname := _x.uom_name; _row.woinvav_qoh := _x.qoh; _row.woinvav_balance := _x.wobalance; _row.woinvav_allocated := _x.allocated; _row.woinvav_ordered := _x.ordered; _row.woinvav_woavail := _x.woavail; _row.woinvav_totalavail := _x.totalavail; _row.woinvav_reorderlevel := _x.reorderlevel; _row.woinvav_level := plevel; RETURN NEXT _row; --get materials for this level FOR _subx IN SELECT * FROM woinvavailmatl(_x.wo_id, plevel + 1, pshowshortage, pshowlowinventory) LOOP RETURN NEXT _subx; END LOOP; --get next level wo FOR _subx IN SELECT * FROM woinvavail(_x.wo_id, plevel + 1, pshowshortage, pshowlowinventory) LOOP RETURN NEXT _subx; END LOOP; END LOOP; RETURN; END; $_$; EDROP FUNCTION public.woinvavail(integer, integer, boolean, boolean); publicadminfalse4276462381255871077woinvavail(integer, boolean, boolean, boolean, boolean)FUNCTIONCREATE FUNCTION woinvavail(integer, boolean, boolean, boolean, boolean) RETURNS SETOF woinvav LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pwoid ALIAS FOR $1; pshowchildindent ALIAS FOR $2; pshowchildsum ALIAS FOR $3; pshowshortage ALIAS FOR $4; pshowlowinventory ALIAS FOR $5; _row woinvav%ROWTYPE; _subrow woinvav%ROWTYPE; _wonumber TEXT; _x RECORD; _subx RECORD; _qry TEXT; BEGIN IF(pshowchildindent) THEN --get top level order FOR _x IN SELECT wo_id, itemsite_id, item_type, wo_number, wo_subnumber, item_number, item_descrip1, item_descrip2, uom_name, qoh, wobalance, allocated, ordered, reorderlevel, (qoh + ordered - wobalance) AS woavail, (qoh + ordered - allocated) AS totalavail FROM(SELECT wo_id, itemsite_id, item_type, wo_number, wo_subnumber, item_number, item_descrip1, item_descrip2, uom_name, noNeg(qtyAvailable(itemsite_id)) AS qoh, noNeg(wo_qtyord - wo_qtyrcv) AS wobalance, qtyAllocated(itemsite_id, wo_duedate) AS allocated, qtyOrdered(itemsite_id, wo_duedate) AS ordered, CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel FROM wo, itemsite, item, uom WHERE ((wo_id = pwoid) AND (itemsite_id = wo_itemsite_id) AND (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id)) ORDER BY wo_number, wo_subnumber) AS data LOOP _row.woinvav_itemsite_id := _x.itemsite_id; _row.woinvav_womatl_id := -1; _row.woinvav_type := _x.item_type; _row.woinvav_item_wo_number := _x.wo_number || '-' || _x.wo_subnumber; _row.woinvav_descrip := _x.item_descrip1 || ' ' || _x.item_descrip2; _row.woinvav_uomname := _x.uom_name; _row.woinvav_qoh := _x.qoh; _row.woinvav_balance := _x.wobalance; _row.woinvav_allocated := _x.allocated; _row.woinvav_ordered := _x.ordered; _row.woinvav_woavail := _x.woavail; _row.woinvav_totalavail := _x.totalavail; _row.woinvav_reorderlevel := _x.reorderlevel; _row.woinvav_level := 0; RETURN NEXT _row; --get materials for this level FOR _subx IN SELECT * FROM woinvavailmatl(_x.wo_id, 1, pshowshortage, pshowlowinventory) LOOP RETURN NEXT _subx; END LOOP; FOR _subx IN SELECT * FROM woinvavail(_x.wo_id, 1, pshowshortage, pshowlowinventory) LOOP RETURN NEXT _subx; END LOOP; END LOOP; ELSE SELECT wo_number FROM wo WHERE wo_id=pwoid LIMIT 1 INTO _wonumber; --display a single level sum of work order requirements _qry := 'SELECT wo_id, itemsite_id, womatl_id, item_type, wo_number, item_number, item_descrip1, item_descrip2, uom_name, qoh, wobalance, allocated, ordered, reorderlevel, (qoh + ordered - wobalance) AS woavail, (qoh + ordered - allocated) AS totalavail FROM (SELECT wo_id, itemsite_id, womatl_id, item_type, wo_number, item_number, item_descrip1, item_descrip2, uom_name, noNeg(qtyAvailable(itemsite_id)) AS qoh, noNeg(itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq - womatl_qtyiss)) AS wobalance, qtyAllocated(itemsite_id, womatl_duedate) AS allocated, qtyOrdered(itemsite_id, womatl_duedate) AS ordered, CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel FROM wo, womatl, itemsite, item, uom WHERE (womatl_wo_id=wo_id) AND (womatl_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (item_inv_uom_id=uom_id) '; IF(pshowchildsum) THEN _qry := _qry || ' AND (wo_number=' || _wonumber || ')'; ELSE _qry := _qry || ' AND (womatl_wo_id=' || pwoid || ')'; END IF; _qry := _qry || ' ORDER BY item_number) AS data '; IF(pshowshortage) THEN _qry := _qry || ' WHERE (((qoh + ordered - allocated) < 0) OR ((qoh + ordered - wobalance) < 0)) '; END IF; IF(pshowlowinventory AND NOT pshowshortage) THEN _qry := _qry || ' WHERE (((qoh - allocated) < 0) OR ((qoh - wobalance) < 0)) '; END IF; FOR _x IN EXECUTE _qry LOOP _row.woinvav_itemsite_id := _x.itemsite_id; _row.woinvav_womatl_id := _x.womatl_id; _row.woinvav_type := _x.item_type; _row.woinvav_item_wo_number := _x.item_number; _row.woinvav_descrip := _x.item_descrip1 || ' ' || _x.item_descrip2; _row.woinvav_uomname := _x.uom_name; _row.woinvav_qoh := _x.qoh; _row.woinvav_balance := _x.wobalance; _row.woinvav_allocated := _x.allocated; _row.woinvav_ordered := _x.ordered; _row.woinvav_woavail := _x.woavail; _row.woinvav_totalavail := _x.totalavail; _row.woinvav_reorderlevel := _x.reorderlevel; _row.woinvav_level := 0; RETURN NEXT _row; END LOOP; END IF; RETURN; END; $_$; NDROP FUNCTION public.woinvavail(integer, boolean, boolean, boolean, boolean); publicadminfalse8427646231255871092woinvavailmatl(integer, integer, boolean, boolean)FUNCTION CREATE FUNCTION woinvavailmatl(integer, integer, boolean, boolean) RETURNS SETOF woinvav LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pwoid ALIAS FOR $1; plevel ALIAS FOR $2; pshowshortage ALIAS FOR $3; pshowlowinventory ALIAS FOR $4; _subrow woinvav%ROWTYPE; _subx RECORD; _qry TEXT; BEGIN _qry := 'SELECT itemsite_id, womatl_id, item_type, wo_number, wo_subnumber, womatl_ref, womatl_notes, item_number, item_descrip1, item_descrip2, uom_name, qoh, wobalance, allocated, ordered, (qoh + ordered - wobalance) AS woavail, (qoh + ordered - allocated) AS totalavail, reorderlevel FROM(SELECT itemsite_id, womatl_id, item_type, wo_number, wo_subnumber, womatl_ref, womatl_notes, item_number, item_descrip1, item_descrip2, uom_name, noNeg(qtyAvailable(itemsite_id)) AS qoh, noNeg(itemuomtouom(itemsite_item_id, womatl_uom_id, NULL, womatl_qtyreq - womatl_qtyiss)) AS wobalance, qtyAllocated(itemsite_id, womatl_duedate) AS allocated, qtyOrdered(itemsite_id, womatl_duedate) AS ordered, CASE WHEN(itemsite_useparams) THEN itemsite_reorderlevel ELSE 0.0 END AS reorderlevel FROM womatl, wo, itemsite, item, uom WHERE ((wo_id = womatl_wo_id) AND (womatl_itemsite_id = itemsite_id) AND (itemsite_item_id=item_id) AND (womatl_uom_id=uom_id) AND (NOT womatl_createwo OR womatl_createwo IS NULL))'; _qry := _qry || ' AND (wo_id=' || pwoid || ') ORDER BY item_number) AS data'; IF(pshowshortage) THEN _qry := _qry || ' WHERE (((qoh + ordered - allocated) < 0) OR ((qoh + ordered - wobalance) < 0)) '; END IF; IF(pshowlowinventory AND NOT pshowshortage) THEN _qry := _qry || ' WHERE (((qoh - allocated) < 0) OR ((qoh - wobalance) < 0)) '; END IF; FOR _subx IN EXECUTE _qry LOOP _subrow.woinvav_itemsite_id := _subx.itemsite_id; _subrow.woinvav_womatl_id := _subx.womatl_id; _subrow.woinvav_type := _subx.item_type; _subrow.woinvav_item_wo_number := _subx.item_number; _subrow.woinvav_descrip := _subx.item_descrip1 || ' ' || _subx.item_descrip2; _subrow.woinvav_uomname := _subx.uom_name; _subrow.woinvav_qoh := _subx.qoh; _subrow.woinvav_balance := _subx.wobalance; _subrow.woinvav_allocated := _subx.allocated; _subrow.woinvav_ordered := _subx.ordered; _subrow.woinvav_woavail := _subx.woavail; _subrow.woinvav_totalavail := _subx.totalavail; _subrow.woinvav_reorderlevel := _subx.reorderlevel; _subrow.woinvav_level := plevel; RETURN NEXT _subrow; END LOOP; RETURN; END; $_$; IDROP FUNCTION public.woinvavailmatl(integer, integer, boolean, boolean); publicadminfalse427684623125579517wostarted(integer)FUNCTIONCREATE FUNCTION wostarted(pwoid integer) RETURNS boolean LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _result BOOLEAN := FALSE; BEGIN -- is it really this simple? SELECT (wo_wipvalue > 0) INTO _result FROM wo WHERE wo_id=pWoid; RETURN COALESCE(_result, FALSE); END; $$; /DROP FUNCTION public.wostarted(pwoid integer); publicadminfalse84623125579518calcrate(numeric, character)FUNCTIONtCREATE FUNCTION calcrate(numeric, character) RETURNS numeric LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pAmount ALIAS FOR $1; pPeriod ALIAS FOR $2; _state integer; _count integer; BEGIN -- Convert amount to hourly rate IF (pPeriod = 'H') THEN -- hourly RETURN round(pAmount,2); ELSIF (pPeriod = 'D') THEN -- daily RETURN round(pAmount / 8, 2); ELSIF (pPeriod = 'W') THEN -- weekly RETURN round(pAmount / 40, 2); ELSIF (pPeriod = 'BW') THEN -- bi-weekly RETURN round(pAmount / 80, 2); ELSIF (pPeriod = 'M') THEN -- monthly RETURN round(pAmount / 160, 2); ELSIF (pPeriod = 'Y') THEN -- annually RETURN round(pAmount / 2080, 2); ELSE RAISE EXCEPTION 'Unknown period type passed: %', pPeriod; END IF; END; $_$; /DROP FUNCTION te.calcrate(numeric, character); teadminfalse94623125579519copyitem(integer, text)FUNCTIONCREATE FUNCTION copyitem(integer, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pSItemid ALIAS FOR $1; pTItemNumber ALIAS FOR $2; _itemid INTEGER; _r RECORD; _id INTEGER; BEGIN _itemid := public.copyItem(pSItemid, pTItemNumber); INSERT INTO te.teexp SELECT _itemid, teexp_expcat_id, teexp_accnt_id FROM te.teexp src WHERE (src.teexp_id=pSItemid); RETURN _itemid; END; $_$; *DROP FUNCTION te.copyitem(integer, text); teadminfalse94623125579520invoicesheets(integer[])FUNCTION$CREATE FUNCTION invoicesheets(pheadids integer[]) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. BEGIN RETURN te.invoicesheets(pHeadIDs, CURRENT_DATE); END; $$; 4DROP FUNCTION te.invoicesheets(pheadids integer[]); teadminfalse946231255153472invoicesheets(integer[], date)FUNCTIONCREATE FUNCTION invoicesheets(pheadids integer[], pinvcdate date) RETURNS integer LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2012 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _invcnum text; _invcheadid integer; _invcitemid integer; _s record; _t record; _linenum integer; BEGIN -- Loop through time sheet items with matching criteria and make invoices FOR _s in SELECT DISTINCT teitem_cust_id, teitem_po, prj_id, teitem_curr_id FROM te.tehead JOIN te.teitem ON (teitem_tehead_id=tehead_id AND teitem_billable) JOIN prjtask ON (teitem_prjtask_id=prjtask_id) JOIN prj ON (prjtask_prj_id=prj_id) WHERE ((tehead_id IN (SELECT * FROM te.unnest(pHeadIDs) ) ) AND (teitem_billable) AND (teitem_invcitem_id IS NULL)) -- loop thru records and create invoices by customer, by PO for the provided headid LOOP --select nextval('invchead_invchead_id_seq') into _invcid; _invcnum := CAST(fetchInvcNumber() AS TEXT); _invcheadid := nextval('invchead_invchead_id_seq'); _linenum := 1; INSERT INTO invchead (invchead_id, invchead_cust_id, invchead_shipto_id, invchead_ordernumber, invchead_orderdate, invchead_posted, invchead_printed, invchead_invcnumber, invchead_invcdate, invchead_shipdate, invchead_ponumber, invchead_shipvia, invchead_fob, invchead_billto_name, invchead_billto_address1, invchead_billto_address2, invchead_billto_address3, invchead_billto_city, invchead_billto_state, invchead_billto_zipcode, invchead_billto_phone, invchead_shipto_name, invchead_shipto_address1, invchead_shipto_address2, invchead_shipto_address3, invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode, invchead_shipto_phone, invchead_salesrep_id, invchead_commission, invchead_terms_id, invchead_freight, invchead_misc_amount, invchead_misc_descrip, invchead_misc_accnt_id, invchead_payment, invchead_paymentref, invchead_notes, invchead_billto_country, invchead_shipto_country, invchead_prj_id, invchead_curr_id, invchead_gldistdate, invchead_recurring, invchead_recurring_interval, invchead_recurring_type, invchead_recurring_until, invchead_recurring_invchead_id, invchead_shipchrg_id, invchead_taxzone_id, invchead_void, invchead_saletype_id, invchead_shipzone_id) SELECT _invcheadid, cust_id, -1, '', current_date, false, false, _invcnum, COALESCE(pInvcdate, current_date), current_date, _s.teitem_po, '', '', cust_name, COALESCE(addr_line1,''), COALESCE(addr_line2,''), COALESCE(addr_line3,''), COALESCE(addr_city,''), COALESCE(addr_state,''), COALESCE(addr_postalcode,''), cntct_phone, '', '', '', '', '', '', '', '', cust_salesrep_id, salesrep_commission, cust_terms_id, 0, 0, '', -1, 0, '', '', COALESCE(addr_country,''), '', _s.prj_id, _s.teitem_curr_id, current_date, false, null, null, null, null, null, cust_taxzone_id, false, null, null FROM custinfo JOIN salesrep ON (cust_salesrep_id=salesrep_id) LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id) LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id) WHERE (cust_id=_s.teitem_cust_id); -- loop thru all lines of the sheet FOR _t IN SELECT teitem_id, teitem_linenumber, tehead_warehous_id, teitem_type, tehead_emp_id, cust_taxzone_id, item_number, teitem_cust_id, teitem_po, teitem_item_id, teitem_qty, teitem_uom_id, teitem_rate, teitem_notes FROM te.teitem JOIN te.tehead ON (teitem_tehead_id = tehead_id) JOIN custinfo ON (cust_id = teitem_cust_id) JOIN item ON (item_id = teitem_item_id) JOIN prjtask ON (teitem_prjtask_id=prjtask_id) JOIN prj ON (prjtask_prj_id=prj_id) WHERE ((tehead_id IN (SELECT * FROM te.unnest(pHeadIDs) ) ) AND (teitem_billable) AND (teitem_invcitem_id IS NULL) AND (item_id = teitem_item_id) AND (teitem_cust_id = _s.teitem_cust_id) AND (teitem_po = _s.teitem_po) AND (prj_id = _s.prj_id) AND (teitem_curr_id = _s.teitem_curr_id)) ORDER BY teitem_linenumber LOOP _invcitemid := nextval('invcitem_invcitem_id_seq'); INSERT INTO invcitem (invcitem_id, invcitem_invchead_id, invcitem_linenumber, invcitem_item_id, invcitem_warehous_id, invcitem_custpn, invcitem_number, invcitem_descrip, invcitem_ordered, invcitem_billed, invcitem_custprice, invcitem_price, invcitem_notes, invcitem_salescat_id, invcitem_taxtype_id, invcitem_qty_uom_id, invcitem_qty_invuomratio, invcitem_price_uom_id, invcitem_price_invuomratio, invcitem_coitem_id, invcitem_updateinv, invcitem_rev_accnt_id) SELECT _invcitemid, _invcheadid, _linenum, _t.teitem_item_id, _t.tehead_warehous_id, '', '', '', _t.teitem_qty, _t.teitem_qty, _t.teitem_rate, _t.teitem_rate, _t.teitem_notes, -1, getItemTaxType(item_id, _t.cust_taxzone_id), _t.teitem_uom_id, itemuomtouomratio(item_id, _t.teitem_uom_id, item_inv_uom_id), _t.teitem_uom_id, itemuomtouomratio(item_id, _t.teitem_uom_id, item_inv_uom_id), null, false, null FROM item WHERE (item_id=_t.teitem_item_id); _linenum := _linenum + 1; -- Update the time sheet item record UPDATE te.teitem SET teitem_invcitem_id = _invcitemid WHERE (teitem_id = _t.teitem_id); END LOOP; END LOOP; RETURN 1; END; $$; DDROP FUNCTION te.invoicesheets(pheadids integer[], pinvcdate date); teadminfalse94623125579521postsheet(integer, text, text)FUNCTION CREATE FUNCTION postsheet(integer, text, text) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTeheadId ALIAS FOR $1; pPhrase1 ALIAS FOR $2; pPhrase2 ALIAS FOR $3; _r record; _notes TEXT; _value NUMERIC; _olaccntid INTEGER; _expaccntid INTEGER; _count INTEGER; BEGIN -- Validate: No posting for contractors IF (SELECT (count(teemp_id) > 0) FROM te.tehead JOIN te.teemp ON (tehead_emp_id=teemp_emp_id) WHERE ((tehead_id=pTeheadId) AND (teemp_contractor))) THEN RAISE EXCEPTION 'Time and Expense Sheets can not be posted for contractors. Voucher instead.'; END IF; -- Get labor and overhead account SELECT accnt_id INTO _olaccntid FROM accnt WHERE (accnt_id=fetchmetricvalue('PrjLaborAndOverhead')); GET DIAGNOSTICS _count = ROW_COUNT; IF (_count = 0) THEN RAISE EXCEPTION 'No valid Project Labor and Overhead Account Defined'; END IF; -- Get applicable time sheets FOR _r IN SELECT tehead_number, teitem_id, teitem_linenumber, teitem_type, teitem_notes, item_descrip1, teitem_qty, teexp_expcat_id, teexp_accnt_id, emp_code, emp_wage, emp_wage_period, prj_id, prj_number FROM te.tehead JOIN te.teitem ON (teitem_tehead_id=tehead_id) JOIN item ON (teitem_item_id=item_id) JOIN te.teexp ON (teitem_item_id=teexp_id) JOIN emp ON (tehead_emp_id=emp_id) JOIN prjtask ON (prjtask_id=teitem_prjtask_id) JOIN prj ON (prj_id=prjtask_prj_id) WHERE ((tehead_id = pTeheadId) AND (NOT teitem_posted) AND (teitem_vodist_id IS NULL) AND (teitem_type = 'T')) LOOP -- Determine value _value := te.calcRate(_r.emp_wage, _r.emp_wage_period) * _r.teitem_qty; -- Determine G/L account to post to IF (_r.teexp_accnt_id > 1) THEN _expaccntid := getPrjAccntId(_r.prj_id, _r.teexp_accnt_id); ELSE SELECT getPrjAccntId(_r.prj_id, expcat_exp_accnt_id) INTO _expaccntid FROM expcat WHERE (expcat_id=_r.teexp_expcat_id); END IF; -- Execute the posting _notes := (pPhrase1 || _r.item_descrip1 || '/' || _r.emp_code || pPhrase2 || ' ' || _r.prj_number); PERFORM insertGLTransaction( 'T/E', 'TE', _r.tehead_number, _notes, _olaccntid, _expaccntid, -1, _value, current_date ); -- Update the time sheet item UPDATE te.teitem SET teitem_posted = true, teitem_postedvalue = teitem_postedvalue + _value WHERE (teitem_id=_r.teitem_id); END LOOP; RETURN 1; END; $_$; 1DROP FUNCTION te.postsheet(integer, text, text); teadminfalse94623125579522sheetstate(integer, character)FUNCTIONCREATE FUNCTION sheetstate(integer, character) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pTeheadId ALIAS FOR $1; pType ALIAS FOR $2; _state INTEGER := -1; BEGIN -- Check and return the process state of the sheet -- 1 = All processed -- 0 = Processing required -- -1 = Not Applicable IF (pType = 'I') THEN SELECT MIN(CASE teitem_invcitem_id IS NULL WHEN TRUE THEN 0 ELSE 1 END) INTO _state FROM te.teitem WHERE ((teitem_tehead_id=pTeheadId) AND (teitem_billable) AND (teitem_qty >= 0)); ELSIF (pType = 'V') THEN -- todo: why outer join then check teitem_type and vend_id is not null? SELECT MIN(CASE teitem_vodist_id IS NULL WHEN TRUE THEN 0 ELSE 1 END) INTO _state FROM te.tehead JOIN emp ON (tehead_emp_id=emp_id) LEFT OUTER JOIN te.teemp ON (emp_id=teemp_emp_id) LEFT OUTER JOIN te.teitem ON (teitem_tehead_id=tehead_id) LEFT OUTER JOIN vendinfo ON (UPPER(emp_code)=UPPER(vend_number)) WHERE ((teitem_tehead_id=pTeheadId) AND ((teitem_type = 'E' AND NOT teitem_prepaid) OR (teitem_type = 'T' AND COALESCE(teemp_contractor,false))) AND (vend_id IS NOT NULL) AND (teitem_qty > 0)); ELSIF (pType = 'P') THEN SELECT MIN(CASE teitem_posted WHEN FALSE THEN 0 ELSE 1 END) INTO _state FROM te.teitem JOIN te.tehead ON (teitem_tehead_id=tehead_id) LEFT JOIN te.teemp ON (tehead_emp_id=teemp_emp_id) WHERE ((teitem_tehead_id=pTeheadId) AND (teitem_type = 'T') AND (teemp_contractor IS NULL or teemp_contractor = false)); ELSE -- TODO: either make ErrorReporter::error find this or use xtuple RAISE EXCEPTION 'Unknown process type % [xtte: sheetstate, -2, %]', pType, pType; END IF; RETURN _state; END; $_$; 1DROP FUNCTION te.sheetstate(integer, character); teadminfalse94623125579523triggertehead()FUNCTIONCREATE FUNCTION triggertehead() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; _sense INTEGER := 0; BEGIN -- Determine whether we are adding or subtracting totals IF (TG_OP = 'UPDATE') THEN IF (OLD.tehead_status = 'O' AND NEW.tehead_status = 'A') THEN -- Approving so add _sense := 1; ELSIF (OLD.tehead_status = 'A' AND NEW.tehead_status = 'O') THEN -- Unapproving so subtract _sense := -1; END IF; END IF; IF (_sense != 0) THEN -- Loop thru all lines of the sheet and update project FOR _r in SELECT teitem_prjtask_id, teitem_type, teitem_qty, teitem_total FROM te.teitem WHERE teitem_tehead_id = NEW.tehead_id LOOP IF (_r.teitem_type = 'T') THEN UPDATE prjtask SET prjtask_hours_actual = prjtask_hours_actual + _r.teitem_qty * _sense WHERE prjtask_id = _r.teitem_prjtask_id; ELSE UPDATE prjtask SET prjtask_exp_actual = prjtask_exp_actual + _r.teitem_total * _sense WHERE prjtask_id = _r.teitem_prjtask_id; END IF; END LOOP; END IF; RETURN NEW; END; $$; "DROP FUNCTION te.triggertehead(); teadminfalse94623125579524triggerteitem()FUNCTIONF CREATE FUNCTION triggerteitem() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _r RECORD; _status CHAR(1) := 'O'; BEGIN -- Validate whether we can take this action IF (TG_OP = 'UPDATE') THEN IF ((OLD.teitem_type != NEW.teitem_type) OR (OLD.teitem_workdate != NEW.teitem_workdate) OR (OLD.teitem_cust_id != NEW.teitem_cust_id) OR (OLD.teitem_po != NEW.teitem_po) OR (OLD.teitem_item_id != NEW.teitem_item_id) OR (OLD.teitem_qty != NEW.teitem_qty) OR (OLD.teitem_rate != NEW.teitem_rate) OR (OLD.teitem_total != NEW.teitem_total) OR (OLD.teitem_billable != NEW.teitem_billable) OR (OLD.teitem_prepaid != NEW.teitem_prepaid) OR (OLD.teitem_notes != NEW.teitem_notes)) THEN SELECT tehead_status INTO _status FROM te.tehead WHERE tehead_id=NEW.teitem_tehead_id; END IF; ELSIF (TG_OP = 'INSERT') THEN SELECT tehead_status INTO _status FROM te.tehead WHERE tehead_id=NEW.teitem_tehead_id; ELSE -- Must be delete SELECT tehead_status INTO _status FROM te.tehead WHERE tehead_id=OLD.teitem_tehead_id; END IF; IF (_status != 'O') THEN RAISE EXCEPTION 'Time and Expense Sheets may only be edited or deleted when the status is Open'; END IF; _status := 'C'; -- Update header status, default is to close if all processing complete IF (TG_OP = 'UPDATE') THEN IF ((COALESCE(OLD.teitem_invcitem_id,-1) != COALESCE(NEW.teitem_invcitem_id,-1)) OR (COALESCE(OLD.teitem_vodist_id,-1) != COALESCE(NEW.teitem_vodist_id,-1)) OR (OLD.teitem_posted != NEW.teitem_posted)) THEN SELECT te.sheetstate(NEW.teitem_tehead_id, 'I') AS invoiced, te.sheetstate(NEW.teitem_tehead_id, 'V') AS vouchered, te.sheetstate(NEW.teitem_tehead_id, 'P') AS posted INTO _r; IF (_r.invoiced = 0 OR _r.vouchered = 0 OR _r.posted = 0) THEN _status := 'A'; -- Something is still open, so approved END IF; UPDATE te.tehead SET tehead_status = _status WHERE (tehead_id=NEW.teitem_tehead_id); END IF; END IF; -- Update header with last use info IF (TG_OP = 'DELETE') THEN UPDATE te.tehead SET tehead_lastupdated=('now'::text)::timestamp(6) with time zone WHERE (tehead_id=OLD.teitem_tehead_id); ELSE UPDATE te.tehead SET tehead_lastupdated=('now'::text)::timestamp(6) with time zone, tehead_username=getEffectiveXtUser() WHERE (tehead_id=NEW.teitem_tehead_id); END IF; RETURN NEW; END; $$; "DROP FUNCTION te.triggerteitem(); teadminfalse94623125579525triggerteprj()FUNCTIONCREATE FUNCTION triggerteprj() RETURNS trigger LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _update BOOLEAN := false; BEGIN IF (TG_OP = 'INSERT') THEN _update = true; ELSIF (TG_OP = 'UPDATE') THEN IF (COALESCE(OLD.teprj_cust_id,-1) != COALESCE(NEW.teprj_cust_id,-1)) THEN _update = true; END IF; END IF; IF (_update) THEN UPDATE te.teprjtask SET teprjtask_cust_id=NEW.teprj_cust_id FROM prjtask WHERE ((teprjtask_prjtask_id=prjtask_id) AND (prjtask_prj_id=NEW.teprj_prj_id)); END IF; RETURN NEW; END; $$; !DROP FUNCTION te.triggerteprj(); teadminfalse94623125579526unnest(anyarray)FUNCTIONGCREATE FUNCTION unnest(anyarray) RETURNS SETOF anyelement LANGUAGE sql IMMUTABLE AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. SELECT $1[i] FROM generate_series(array_lower($1,1), array_upper($1,1)) i; $_$; #DROP FUNCTION te.unnest(anyarray); teadminfalse9125579527vouchersheet(integer)FUNCTIONCREATE FUNCTION vouchersheet(integer) RETURNS integer LANGUAGE plpgsql AS $_$ -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE pHeadID ALIAS FOR $1; _distamt NUMERIC; _glaccnt INTEGER; _notes TEXT; _s RECORD; _total NUMERIC := 0; _v RECORD; _vodistid INTEGER; _voheadid INTEGER; BEGIN FOR _v IN -- distinct filters duplicate rows returned because of the teitem join -- TODO: can we push the teitem down into the loop and avoid the distinct? SELECT DISTINCT tehead_id, tehead_number, tehead_weekending, tehead_notes, teitem_curr_id, emp_wage, emp_wage_period, vend_id, vend_taxzone_id, vend_terms_id, vend_number, vend_1099, COALESCE(teemp_contractor, false) AS isContractor FROM te.tehead JOIN te.teitem ON (teitem_tehead_id=tehead_id) JOIN emp ON (tehead_emp_id=emp_id) JOIN vendinfo ON (UPPER(emp_code)=UPPER(vend_number)) LEFT OUTER JOIN te.teemp ON (emp_id=teemp_emp_id) WHERE ((tehead_id = pHeadID) AND (teitem_prepaid = false) AND (teitem_vodist_id IS NULL) AND (teitem_type = 'E' OR (COALESCE(teemp_contractor,false) AND (teitem_empcost > 0 OR emp_wage > 0 )))) LOOP INSERT INTO vohead (vohead_id, vohead_number, vohead_vend_id, vohead_distdate, vohead_docdate, vohead_duedate, vohead_terms_id, vohead_taxzone_id, vohead_invcnumber, vohead_reference, vohead_amount, vohead_1099, vohead_curr_id, vohead_notes, vohead_posted, vohead_misc, vohead_pohead_id) VALUES (DEFAULT, fetchVoNumber(), _v.vend_id, _v.tehead_weekending, _v.tehead_weekending, determineDueDate(_v.vend_terms_id, _v.tehead_weekending), _v.vend_terms_id, _v.vend_taxzone_id, 'N/A', ('T&E Sheet ' || _v.tehead_number), 0, _v.vend_1099, _v.teitem_curr_id, _v.tehead_notes, false, true, -1) RETURNING vohead_id INTO _voheadid; FOR _s IN SELECT teitem_id, teitem_linenumber, teitem_workdate, teitem_type, item_number, teitem_item_id, teitem_qty, prjtask_prj_id, CASE WHEN teitem_empcost > 0 THEN teitem_empcost ELSE te.calcRate(_v.emp_wage, _v.emp_wage_period) END AS rate, teitem_total, teitem_type, teitem_notes, teexp_expcat_id, teexp_accnt_id FROM te.teitem JOIN te.teexp ON (teitem_item_id=teexp_id) JOIN item ON (teitem_item_id=item_id) JOIN prjtask ON (teitem_prjtask_id=prjtask_id) WHERE ((teitem_tehead_id = _v.tehead_id) AND (teitem_curr_id = _v.teitem_curr_id) AND (teitem_prepaid = false) AND (teitem_vodist_id IS NULL) AND (teitem_type = 'E' OR (_v.isContractor AND (teitem_empcost > 0 OR _v.emp_wage > 0 )))) -- Loop thru records and create vouchers by supplier for the provided headid LOOP -- insert vodist records here _vodistid = nextval('vodist_vodist_id_seq'); -- Map expense directly to account so we can get project account mapping if applicable IF (_s.teexp_accnt_id > 1) THEN _glaccnt := getPrjAccntId(_s.prjtask_prj_id, _s.teexp_accnt_id); ELSE SELECT getPrjAccntId(_s.prjtask_prj_id, expcat_exp_accnt_id) INTO _glaccnt FROM expcat WHERE (expcat_id=_s.teexp_expcat_id); END IF; IF (_s.teitem_type = 'T') THEN -- Time sheet record _notes := formatdate(_s.teitem_workdate) || E'\t' || _s.item_number || E'\t' || formatQty(_s.teitem_qty) || ' hours' || E'\t'; _distamt := _s.rate * _s.teitem_qty; ELSE -- Expense record _notes := formatdate(_s.teitem_workdate) || E'\t' || _s.item_number || E'\t' || _s.teitem_notes || E'\t'; _distamt := _s.teitem_total; END IF; INSERT INTO vodist (vodist_id, vodist_vohead_id, vodist_poitem_id, vodist_costelem_id, vodist_accnt_id, vodist_amount, vodist_expcat_id, vodist_notes) VALUES (_vodistid, _voheadid, -1, -1, _glaccnt, _distamt, -1, _notes); _total := _total + _distamt; -- Update the te.teitem record with the relationship UPDATE te.teitem SET teitem_vodist_id = _vodistid WHERE teitem_id = _s.teitem_id; END LOOP; UPDATE vohead SET vohead_amount = _total WHERE (vohead_id=_voheadid); _total := 0; END LOOP; RETURN 1; END; $_$; (DROP FUNCTION te.vouchersheet(integer); teadminfalse46239125586812.add_column(text, text, text, text, text, text)FUNCTIONACREATE FUNCTION add_column(table_name text, column_name text, type_name text, constraint_text text DEFAULT NULL::text, schema_name text DEFAULT 'xt'::text, column_comment text DEFAULT NULL::text) RETURNS boolean LANGUAGE plpgsql AS $$ declare count integer; query text; comment_query text; begin perform * from pg_class c, pg_namespace n, pg_attribute a, pg_type t where c.relname = table_name and n.nspname = schema_name and a.attname = column_name and n.oid = c.relnamespace and a.attnum > 0 and a.attrelid = c.oid and a.atttypid = t.oid; get diagnostics count = row_count; if (count > 0) then return false; end if; query = 'alter table ' || schema_name || '.' || table_name || ' add column ' || column_name || ' ' || type_name || ' ' || coalesce(constraint_text, ''); execute query; if (column_comment is not null) then comment_query = 'comment on column ' || schema_name || '.' || table_name || '.' || column_name || ' is ' || quote_literal(column_comment); execute comment_query; end if; return true; end; $$; DROP FUNCTION xt.add_column(table_name text, column_name text, type_name text, constraint_text text, schema_name text, column_comment text); xtadminfalse114623125586813"add_comment_type(text, text, text)FUNCTIONCREATE FUNCTION add_comment_type(text, text, text) RETURNS boolean LANGUAGE plpgsql AS $_$ DECLARE _module ALIAS FOR $1; _comment ALIAS FOR $2; _descr ALIAS FOR $3; _cmntid INTEGER; BEGIN SELECT source_id INTO _cmntid FROM source WHERE source_name = _comment; IF (NOT FOUND) THEN INSERT INTO source (source_module, source_name, source_descrip) VALUES (_module, _comment, _descr) RETURNING source_id INTO _cmntid; INSERT INTO cmnttypesource (cmnttypesource_cmnttype_id, cmnttypesource_source_id) VALUES (1, _cmntid); -- General Comments INSERT INTO cmnttypesource (cmnttypesource_cmnttype_id, cmnttypesource_source_id) VALUES (2, _cmntid); -- ChangeLog Comments END IF; RETURN true; END; $_$; 5DROP FUNCTION xt.add_comment_type(text, text, text); xtadminfalse114623125586814&add_constraint(text, text, text, text)FUNCTIONCREATE FUNCTION add_constraint(table_name text, constraint_name text, constraint_text text, schema_name text DEFAULT 'xt'::text) RETURNS boolean LANGUAGE plpgsql AS $$ declare count integer; query text; begin perform * from pg_constraint join pg_namespace on (connamespace=pg_namespace.oid) join pg_class f on (conrelid=f.oid) where f.relname = table_name and nspname = schema_name and conname = constraint_name; get diagnostics count = row_count; if (count > 0) then return false; end if; query = 'alter table ' || schema_name || '.' || table_name || ' add constraint ' || constraint_name || ' ' || constraint_text || ';'; execute query; return true; end; $$; pDROP FUNCTION xt.add_constraint(table_name text, constraint_name text, constraint_text text, schema_name text); xtadminfalse462311125586815'add_index(text, text, text, text, text)FUNCTIONCREATE FUNCTION add_index(table_name text, column_names text, index_name text, using_name text DEFAULT 'btree'::text, schema_name text DEFAULT 'xt'::text) RETURNS boolean LANGUAGE plpgsql AS $$ declare count integer; query text; begin perform * from pg_index join pg_class s on (indexrelid=s.oid) join pg_class f on (indrelid=f.oid) join pg_namespace on (f.relnamespace=pg_namespace.oid) where f.relname = table_name and nspname = schema_name and s.relname = index_name; get diagnostics count = row_count; if (count > 0) then return false; end if; query = 'create index ' || index_name || ' on ' || schema_name || '.' || table_name || ' using ' || using_name || '(' || column_names || ');'; execute query; return true; end; $$; tDROP FUNCTION xt.add_index(table_name text, column_names text, index_name text, using_name text, schema_name text); xtadminfalse462311125586816!add_primary_key(text, text, text)FUNCTIONCREATE FUNCTION add_primary_key(table_name text, column_name text, schema_name text DEFAULT 'xt'::text) RETURNS boolean LANGUAGE plpgsql AS $$ declare count integer; query text; begin perform * from pg_constraint join pg_namespace on (connamespace=pg_namespace.oid) join pg_class f on (conrelid=f.oid) where f.relname = table_name and nspname = schema_name and contype = 'p'; get diagnostics count = row_count; if (count > 0) then return false; end if; query = 'alter table ' || schema_name || '.' || table_name || ' add primary key (' || column_name || ');'; execute query; return true; end; $$; WDROP FUNCTION xt.add_primary_key(table_name text, column_name text, schema_name text); xtadminfalse114623125586817'create_table(text, text, boolean, text)FUNCTIONCREATE FUNCTION create_table(table_name text, schema_name text DEFAULT 'xt'::text, with_oids boolean DEFAULT false, inherit_table text DEFAULT NULL::text) RETURNS boolean LANGUAGE plpgsql AS $$ declare count integer; query text; with_clause text := ''; inherit_from text := ''; begin perform * from pg_tables where schemaname = schema_name and tablename = table_name; get diagnostics count = row_count; if (count > 0) then return false; end if; if (with_oids) then with_clause := 'with (OIDS=TRUE)'; end if; if (inherit_table is not null) then inherit_from := ' INHERITS (' || inherit_table || ') '; end if; query = 'create table ' || schema_name || '.' || table_name || '()' || inherit_from || with_clause || '; grant all on ' || schema_name || '.' || table_name || ' to xtrole;'; execute query; return true; end; $$; iDROP FUNCTION xt.create_table(table_name text, schema_name text, with_oids boolean, inherit_table text); xtadminfalse462311 125586861+install_js(text, text, text, text, boolean)FUNCTIONCREATE FUNCTION install_js(name_space text, type_name text, context text, javascript text, is_extension boolean DEFAULT false) RETURNS void LANGUAGE plv8 AS $_$ if(!name_space) throw new Error("A name space is required"); if(!type_name) throw new Error("A type is required"); if(!context) throw new Error("A context is required"); sql = 'select js_id as "id", ' + ' js_ext as "isExtension" ' + 'from xt.js ' + 'where js_namespace = $1 ' + ' and js_type = $2 ' + ' and js_context = $3'; js = plv8.execute(sql, [name_space, type_name, context])[0]; if(js) { if(js.isExtension !== is_extension) throw new Error("Can not change extension state for {namespace}.{type} in context {context}." .replace(/{namespace}/, name_space) .replace(/{type}/, type_name) .replace(/{context}/, context)); sql = 'update xt.js set ' + ' js_text = $1 ' + 'where js_id = $2'; plv8.execute(sql, [javascript, js.id]); } else { sql = 'insert into xt.js ( js_namespace, js_type, js_context, js_text, js_ext ) values ($1, $2, $3, $4, $5)'; plv8.execute(sql, [name_space, type_name, context, javascript, is_extension]); } // Reinitialize our plv8 code now that is has changed. plv8.execute("SELECT xt.js_init(false, true)"); $_$; sDROP FUNCTION xt.install_js(name_space text, type_name text, context text, javascript text, is_extension boolean); xtadminfalse462411 125586862js_init(boolean, boolean)FUNCTION~}CREATE FUNCTION js_init(debug boolean DEFAULT false, initialize boolean DEFAULT false) RETURNS void LANGUAGE plv8 AS $_$ return (function () { if (plv8.XT && !initialize && !debug) { return; } DEBUG = debug ? debug : false; if (plv8.version < '1.3.0'){ plv8.elog(ERROR, 'plv8 version 1.3.0 or greater required. This version is = ', plv8.version); } // .......................................................... // METHODS // /** Return whether an array contains an item. @param {Any} @returns Boolean */ Array.prototype.contains = function (item) { var i = this.length; while (i--) { if (this[i] === item) { return true; } } return false; } /** Return the index of an item in an array @param {Any} @returns Any */ Array.prototype.indexOf = function (item) { var i = this.length; while (i--) { if (this[i] === item) { return i; } } return -1; } /** Remove an item from an array and return it. @param {Any} @returns Any */ Array.prototype.remove = function (item) { return this.contains(item) ? this.splice(this.indexOf(item), 1) : false; } /** Returns an the first item in an array with a property matching the passed value. @param {String} property name to search on @param {Any} value to search for @param Object item found or null */ Array.prototype.findProperty = function (key, value) { for (var i = 0; i < this.length; i++) { for (var prop in this[i]) { if (prop === key && this[i][prop] === value) { return this[i]; } } } return false; } /** Remove duplicates from an array. @returns Array with no duplicates. */ /* TODO: Or add underscore.js support. */ Array.prototype.unique = function () { var a = this.concat(); for(var i=0; i 0) { sql = sql + ","; } sql = sql + "$" + (i + 1); if(cast) { sql = sql + "::" + cast; } } sql = sql + ") as result"; if (DEBUG) { XT.debug('sql =', sql); XT.debug('params =', params); } var result = plv8.execute(sql, params)[0].result; if(typeof result === 'number' && result < 0) { errorString = XT.errorToString(functionName, result); throw new handleError(errorString, 424); } else { return result; } }; /** * Wrap PostgreSQL's format() function to format SQL Injection safe queires or general strings. * http://www.postgresql.org/docs/9.1/interactive/functions-string.html#FUNCTIONS-STRING-OTHER * * Example: var query = XT.format("select * from %I", ["cntct"]); * Returns: 'select * from cntct' * Example: var query = XT.format("select %1$I.* from %2$I.%1$I {join} where %1$I.%3$I = $1", ["contact", "xm", "id"]); * Returns: 'select contact.* from xm.contact {join} where contact.number = $1' * * SQL Injection attemp: * Example: var query = XT.format("SELECT * FROM %I", ["cntct; select * from pg_roles; --"]); * Safely escaped/quoted query: * Returns: 'SELECT * FROM "cntct; select * from pg_roles; --"' * * @param {String} The string with format tokens to replace. * @param {Array} An array of replacement strings. * @returns {String} Safely escaped string with tokens replaced. */ XT.format = function (string, args) { if (typeof string !== 'string' || XT.typeOf(args) !== 'array' || !args.length) { return false; } var query = "select format($1", params = ""; for(var i = 0; i < args.length; i++) { params = params + ", $" + (i + 2); } query = query + params + ")"; /* Pass 'string' to format() as the first parameter. */ args.unshift(string); /* if (DEBUG) { XT.debug('XT.format sql =', query); XT.debug('XT.format args =', args); } */ string = plv8.execute(query, args)[0].format; /* Remove 'string' from args to prevent reference errors. */ args.shift(); return string; }; /** * Wrap formatDate() * * @param Object The date. * @returns {String} Date string in user's locale. */ XT.formatDate = function (string) { var query = "select formatdate($1);" if (DEBUG) { XT.debug('XT.formatDate sql =', query); XT.debug('XT.formatDate arg =', string); } ret = plv8.execute(query, [string])[0]; return ret; }; /** * Wrap formatCost() * * @param Number The cost. * @returns {Number} Cost number in user's locale & scale. */ XT.formatCost = function (numb) { var query = "select formatcost($1);" if (DEBUG) { XT.debug('XT.formatCost sql =', query); XT.debug('XT.formatCost arg =', numb); } ret = plv8.execute(query, [numb])[0]; return ret; }; /** * Wrap formatMoney() * * @param Number The money. * @returns {Number} Money in user's locale & scale. */ XT.formatMoney = function (numb) { var query = "select formatmoney($1);" if (DEBUG) { XT.debug('XT.formatMoney sql =', query); XT.debug('XT.formatMoney arg =', numb); } ret = plv8.execute(query, [numb])[0]; return ret; }; /** * Wrap formatSalesPrice() * * @param Number The price. * @returns {Number} Price in user's locale & scale. */ XT.formatSalesPrice = function (numb) { var query = "select formatsalesprice($1);" if (DEBUG) { XT.debug('XT.formatSalesPrice sql =', query); XT.debug('XT.formatSalesPrice arg =', numb); } ret = plv8.execute(query, [numb])[0]; return ret; }; /** * Wrap formatPurchPrice() * * @param Number The price. * @returns {Number} Price in user's locale & scale. */ XT.formatPurchPrice = function (numb) { var query = "select formatpurchprice($1);" if (DEBUG) { XT.debug('XT.formatPurchPrice sql =', query); XT.debug('XT.formatPurchPrice arg =', numb); } ret = plv8.execute(query, [numb])[0]; return ret; }; /** * Wrap formatExtPrice() * * @param Number The price. * @returns {Number} Price in user's locale & scale. */ XT.formatExtPrice = function (numb) { var query = "select formatExtPrice($1);" if (DEBUG) { XT.debug('XT.formatExtPrice sql =', query); XT.debug('XT.formatExtPrice arg =', numb); } ret = plv8.execute(query, [numb])[0]; return ret; }; /** * Wrap formatQty() * * @param Number The quantity. * @returns {Number} Quantity in user's locale & scale. */ XT.formatQty = function (numb) { var query = "select formatqty($1);" if (DEBUG) { XT.debug('XT.formatQty sql =', query); XT.debug('XT.formatQty arg =', numb); } ret = plv8.execute(query, [numb])[0]; return ret; }; /** * Wrap formatQtyPer() * * @param Number The quantity per. * @returns {Number} Quantity per in user's locale & scale. */ XT.formatQtyPer = function (numb) { var query = "select formatqtyper($1);" if (DEBUG) { XT.debug('XT.formatQtyPer sql =', query); XT.debug('XT.formatQtyPer arg =', numb); } ret = plv8.execute(query, [numb])[0]; return ret; }; /** * Wrap formatRatio() * * @param Number The ratio. * @returns {Number} Ratio in user's locale & scale. */ XT.formatRatio = function (numb) { var query = "select formatRatio($1);" if (DEBUG) { XT.debug('XT.formatRatio sql =', query); XT.debug('XT.formatRatio arg =', numb); } ret = plv8.execute(query, [numb])[0]; return ret; }; /** * Wrap formatPrcnt() * * @param Number The percent. * @returns {Number} Percent in user's locale & scale. */ XT.formatPrcnt = function (numb) { var query = "select formatprcnt($1);" if (DEBUG) { XT.debug('XT.formatPrcnt sql =', query); XT.debug('XT.formatPrcnt arg =', numb); } ret = plv8.execute(query, [numb])[0]; return ret; }; /** * Wrap formatWeight() * * @param Number The weight. * @returns {Number} Weight in user's locale & scale. */ XT.formatWeight = function (numb) { var query = "select formatweight($1);" if (DEBUG) { XT.debug('XT.formatWeight sql =', query); XT.debug('XT.formatWeight arg =', numb); } ret = plv8.execute(query, [numb])[0]; return ret; }; /** * Wrap formatNumeric() * * @param Number. * @returns {Number} Number in user's locale & scale. */ XT.formatNumeric = function (numb, text) { var query = "select formatNumeric($1, $2);" if (DEBUG) { XT.debug('XT.formatNumeric sql =', query); XT.debug('XT.formatNumeric arg1 =', numb); XT.debug('XT.formatNumeric arg2 =', text); } ret = plv8.execute(query, [numb, text])[0]; return ret; }; /** Return a universally unique identifier. We're using this solution: http://stackoverflow.com/a/8809472/251019 From here: http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript @return {String} */ XT.generateUUID = function () { var d = new Date().getTime(); var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = (d + Math.random() * 16) % 16 | 0; d = Math.floor(d / 16); return (c === 'x' ? r : (r&0x7|0x8)).toString(16); }); return uuid; }; XT.message = function (code, message) { var msg = {code: code, message: message.substring(0, 90)}; plv8.elog(INFO, JSON.stringify(msg)); return 'Handled by XT.message'; } /** Extended version of javascript 'typeof' that also recognizes arrays */ XT.typeOf = function(value) { var str = typeof value; if (str === 'object') { if (value) { if (typeof value.length === 'number' && !(value.propertyIsEnumerable('length')) && typeof value.splice === 'function') { str = 'array'; } } else str = 'null'; } return str; } XT.extend = function(obj) { Array.prototype.slice.call(arguments, 1).forEach(function(source) { for (var prop in source) { obj[prop] = source[prop]; } }); return obj; } // .......................................................... // PROCESS // var res, sql, path; /* put xt at the front of the search path */ path = plv8.execute('select show_search_path() as path'); path = path[0].path; plv8.execute('set search_path to xt,' + path); /* create namespace objects for all registered javascript */ sql = 'select distinct js_namespace as "nameSpace" ' + 'from xt.js ' + 'where js_active; ' res = plv8.execute(sql); if(res.length) { for(var i = 0; i < res.length; i++) { if(!plv8[res[i].nameSpace]) { plv8[res[i].nameSpace] = eval([res[i].nameSpace] + " = {}"); } } /* load up all active javascript installed in the database */ /* TODO: What about dependencies? */ sql = 'select js_type, js_text as "javascript" ' + 'from xt.js ' + 'where js_active ' + 'order by js_ext, ' + 'js_context = \'xtuple\' DESC'; res = plv8.execute(sql); if(res.length) { for(var i = 0; i < res.length; i++) { if(DEBUG) XT.debug('loading javascript for type->', res[i].js_type); eval(res[i].javascript); var ns = eval(res[i].js_namespace); if (ns && ns[js_type]) { if (Object.isFrozen(ns[js_type])) { plv8.elog(WARNING, 'object already frozen: '+ ns + '.' + js_type); } Object.freeze(ns[js_type]); } } } plv8.__initialized = true; } }()); $_$; =DROP FUNCTION xt.js_init(debug boolean, initialize boolean); xtadminfalse462411b 125588623parseediprofile(text, text)FUNCTIONCREATE FUNCTION parseediprofile(ediprofile text, options text DEFAULT '{}'::text) RETURNS text LANGUAGE plv8 AS $$ var editext = ''; /** * Call the parser with this functions parameters. */ try { editext += XT.EDIProfile.parser.parse(ediprofile, JSON.parse(options)); } catch (err) { plv8.elog(ERROR, 'Cannot parse EDI Profile Tokens. ERROR: ', err); } return editext; $$; ADROP FUNCTION xt.parseediprofile(ediprofile text, options text); xtadminfalse462411` 125588621parsemetasql(text, text)FUNCTIONCREATE FUNCTION parsemetasql(metasql text, options text DEFAULT '{}'::text) RETURNS text LANGUAGE plv8 AS $$ /** * xt.parsemetasql(text, text) * =========================== * * Wrapper function for the plv8 MetaSQL PEG parser: * - XT.MetaSQL.parser.parse(metasql, options); * * @param {string} metasql - The MetaSQL query text string. * @param {string} options - A JSON string of options in the format of: * '{"params":{"your-metasql-parameter-here":"your-value-here","Pn":"Vn"}}' * @returns {string} - Returns a query text string with the MetaSQL * - parameters replaced with your values * * Example Usage: * SELECT xt.parsemetasql( * 'SELECT AS baz;', * '{"params":{"foo":"bar"}}' * ); * * Returns: "SELECT 'bar' AS baz;" */ var sql = ''; /* * Call the parser with this functions parameters. */ try { sql += XT.MetaSQL.parser.parse(metasql, JSON.parse(options)); } catch (err) { plv8.elog(ERROR, 'Cannot parse MetaSQL. ERROR: ', err); } return sql; $$; ;DROP FUNCTION xt.parsemetasql(metasql text, options text); xtadminfalse114624a 125588622parsemetasql(text, text, text)FUNCTIONnCREATE FUNCTION parsemetasql(pgroup text, pname text, poptions text) RETURNS text LANGUAGE plpgsql AS $$ DECLARE qry TEXT; BEGIN -- Overload for xt.parsemetasql(text, text) that loads the MetaSQL from the -- metasql table based on pGroup and pName then passes it to the parser along -- with pOptions. SELECT metasql_query INTO qry FROM metasql WHERE metasql_name = pName AND metasql_group = pGroup ORDER BY metasql_grade DESC LIMIT 1; IF (NOT FOUND) THEN RAISE EXCEPTION 'MetaSQL Query %-% was not found.', pGroup, pName; END IF; RETURN xt.parsemetasql(qry, pOptions); END; $$; GDROP FUNCTION xt.parsemetasql(pgroup text, pname text, poptions text); xtadminfalse114623125579529fetchwelcomehtml()FUNCTIONUCREATE FUNCTION fetchwelcomehtml() RETURNS text LANGUAGE plpgsql IMMUTABLE AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _html TEXT; BEGIN _html := '

Welcome to xTuple


You are not connected to the internet at this time

'; RETURN _html; END; $$; ,DROP FUNCTION xtdesktop.fetchwelcomehtml();  xtdesktopadminfalse1046231255154476fetchxtupleserverhtml()FUNCTIONqCREATE FUNCTION fetchxtupleserverhtml() RETURNS text LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _html TEXT; BEGIN _html := '

Welcome to xTuple


You are not connected to an xTuple Server at this time.

You require a suitable xTuple Server to view Dashboards.

'; RETURN _html; END; $$; 1DROP FUNCTION xtdesktop.fetchxtupleserverhtml();  xtdesktopadminfalse1046231255154477 usersonline()FUNCTIONsCREATE FUNCTION usersonline() RETURNS SETOF usersonline LANGUAGE plpgsql AS $$ -- Copyright (c) 1999-2015 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. DECLARE _row xtdesktop.usersonline%ROWTYPE; _query TEXT; BEGIN -- first part of our query doesn't care what PG version it is _query := 'SELECT usr.usr_id, usr.usr_username, usr.usr_propername, usr.usr_email, ' || 'min(backend_start) AS client_start, max(query_start) AS query_start, ' || 'sum(CASE WHEN(database IS NULL) THEN 0 ELSE 1 END) AS cnt_internal, ' || 'sum(CASE WHEN(database IS NULL) THEN 1 ELSE 0 END) AS cnt_external, ' || 'client_addr ' || 'FROM pg_stat_activity ' || 'JOIN public.usr ON (usr.usr_id=usesysid) '; -- use the integer comparison to compare server version to 9.2.0, where procpid was changed to just pid IF (compareversion('9.2.0') <= 0) THEN _query := _query || 'LEFT OUTER JOIN pg_locks ON (database=datid AND classid=datid AND objid=pg_stat_activity.pid AND objsubid=2) '; ELSE _query := _query || 'LEFT OUTER JOIN pg_locks ON (database=datid AND classid=datid AND objid=procpid AND objsubid=2) '; END IF; -- the rest of the query _query := _query || 'WHERE(datname=current_database()) ' || 'GROUP BY usr_id, usr_username, usr_propername, usr_email, client_addr '; -- loop over the rows that executing this query returns, and return them to the calling user FOR _row IN EXECUTE _query LOOP RETURN NEXT _row; END LOOP; RETURN; END; $$; 'DROP FUNCTION xtdesktop.usersonline();  xtdesktopadminfalse1046234620_&00FUNCTION usersonline()COMMENTxCOMMENT ON FUNCTION usersonline() IS 'A table function that returns a PostgreSQL-version aware count of users online.';  xtdesktopadminfalse919125586989concatagg(text) AGGREGATEfCREATE AGGREGATE concatagg(text) ( SFUNC = concataggsfunc, STYPE = text, INITCOND = '' ); 'DROP AGGREGATE public.concatagg(text); publicadminfalse11738125587020first(anyelement) AGGREGATEVCREATE AGGREGATE first(anyelement) ( SFUNC = first_agg, STYPE = anyelement ); )DROP AGGREGATE public.first(anyelement); publicadminfalse81491125587056last(anyelement) AGGREGATETCREATE AGGREGATE last(anyelement) ( SFUNC = last_agg, STYPE = anyelement ); (DROP AGGREGATE public.last(anyelement); publicadminfalse9728125979534addrTABLECREATE TABLE addr ( addr_id integer NOT NULL, addr_active boolean DEFAULT true, addr_line1 text DEFAULT ''::text, addr_line2 text DEFAULT ''::text, addr_line3 text DEFAULT ''::text, addr_city text DEFAULT ''::text, addr_state text DEFAULT ''::text, addr_postalcode text DEFAULT ''::text, addr_country text DEFAULT ''::text, addr_notes text DEFAULT ''::text, addr_number text NOT NULL, CONSTRAINT addr_addr_number_check CHECK ((addr_number <> ''::text)) ); DROP TABLE public.addr; publicadminfalse60986099610061016102610361046105610661088`&00 TABLE addrCOMMENT+COMMENT ON TABLE addr IS 'Postal Address'; publicadminfalse213a&00addrACLREVOKE ALL ON TABLE addr FROM PUBLIC; REVOKE ALL ON TABLE addr FROM admin; GRANT ALL ON TABLE addr TO admin; GRANT ALL ON TABLE addr TO xtrole; publicadminfalse213$125987646accountVIEW CREATE VIEW account AS SELECT (c.crmacct_number)::character varying AS account_number, p.crmacct_number AS parent_account, c.crmacct_name AS account_name, c.crmacct_active AS active, CASE WHEN (c.crmacct_type = 'O'::bpchar) THEN 'Organization'::text ELSE 'Individual'::text END AS type, pc.cntct_number AS primary_contact_number, pc.cntct_honorific AS primary_contact_honorific, pc.cntct_first_name AS primary_contact_first, pc.cntct_middle AS primary_contact_middle, pc.cntct_last_name AS primary_contact_last, pc.cntct_suffix AS primary_contact_suffix, pc.cntct_title AS primary_contact_job_title, pc.cntct_phone AS primary_contact_voice, pc.cntct_fax AS primary_contact_fax, pc.cntct_email AS primary_contact_email, ''::text AS primary_contact_change, m.addr_number AS primary_contact_address_number, m.addr_line1 AS primary_contact_address1, m.addr_line2 AS primary_contact_address2, m.addr_line3 AS primary_contact_address3, m.addr_city AS primary_contact_city, m.addr_state AS primary_contact_state, m.addr_postalcode AS primary_contact_postalcode, m.addr_country AS primary_contact_country, ''::text AS primary_contact_address_change, sc.cntct_number AS secondary_contact_number, sc.cntct_honorific AS secondary_contact_honorific, sc.cntct_first_name AS secondary_contact_first, sc.cntct_middle AS secondary_contact_middle, sc.cntct_last_name AS secondary_contact_last, sc.cntct_suffix AS secondary_contact_suffix, sc.cntct_title AS secondary_contact_job_title, sc.cntct_phone AS secondary_contact_voice, sc.cntct_fax AS secondary_contact_fax, sc.cntct_email AS secondary_contact_email, sc.cntct_webaddr AS secondary_contact_web, ''::text AS secondary_contact_change, s.addr_number AS secondary_contact_address_number, s.addr_line1 AS secondary_contact_address1, s.addr_line2 AS secondary_contact_address2, s.addr_line3 AS secondary_contact_address3, s.addr_city AS secondary_contact_city, s.addr_state AS secondary_contact_state, s.addr_postalcode AS secondary_contact_postalcode, s.addr_country AS secondary_contact_country, ''::text AS secondary_contact_address_change, c.crmacct_notes AS notes FROM (((((public.crmacct c LEFT JOIN public.crmacct p ON ((c.crmacct_parent_id = p.crmacct_id))) LEFT JOIN public.cntct pc ON ((c.crmacct_cntct_id_1 = pc.cntct_id))) LEFT JOIN public.addr m ON ((pc.cntct_addr_id = m.addr_id))) LEFT JOIN public.cntct sc ON ((c.crmacct_cntct_id_2 = sc.cntct_id))) LEFT JOIN public.addr s ON ((sc.cntct_addr_id = s.addr_id))); DROP VIEW api.account; apiadminfalse86876b&00 VIEW accountCOMMENT&COMMENT ON VIEW account IS 'Account'; apiadminfalse804c&00accountACLREVOKE ALL ON TABLE account FROM PUBLIC; REVOKE ALL ON TABLE account FROM admin; GRANT ALL ON TABLE account TO admin; GRANT ALL ON TABLE account TO xtrole; apiadminfalse804125979555charTABLECREATE TABLE "char" ( char_id integer NOT NULL, char_name text NOT NULL, char_items boolean, char_options boolean, char_attributes boolean, char_lotserial boolean, char_notes text, char_customers boolean, char_crmaccounts boolean, char_addresses boolean, char_contacts boolean, char_opportunity boolean, char_employees boolean DEFAULT false, char_mask text, char_validator text, char_incidents boolean DEFAULT false, char_type integer DEFAULT 0 NOT NULL, char_order integer DEFAULT 0 NOT NULL, char_search boolean DEFAULT true NOT NULL, char_quotes boolean DEFAULT false, char_salesorders boolean DEFAULT false, char_invoices boolean DEFAULT false, char_vendors boolean DEFAULT false, char_purchaseorders boolean DEFAULT false, char_vouchers boolean DEFAULT false, char_projects boolean DEFAULT false, char_tasks boolean DEFAULT false, CONSTRAINT char_char_name_check CHECK ((char_name <> ''::text)) ); DROP TABLE public."char"; publicadminfalse610961106111611261136114611561166117611861196120612161238d&00 TABLE "char"COMMENT9COMMENT ON TABLE "char" IS 'Characteristic information'; publicadminfalse214e&00COLUMN "char".char_itemsCOMMENTCOMMENT ON COLUMN "char".char_items IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type I'; publicadminfalse214f&00COLUMN "char".char_lotserialCOMMENTCOMMENT ON COLUMN "char".char_lotserial IS 'DEPRECATED - this column has been replaced by rows in the charuse table with target_types LS and LSR'; publicadminfalse214g&00COLUMN "char".char_customersCOMMENTCOMMENT ON COLUMN "char".char_customers IS 'DEPRECATED - this column has been replaced by rows in the charuse table with target_types C and CT'; publicadminfalse214h&00COLUMN "char".char_crmaccountsCOMMENTCOMMENT ON COLUMN "char".char_crmaccounts IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type CRMA'; publicadminfalse214i&00COLUMN "char".char_addressesCOMMENTCOMMENT ON COLUMN "char".char_addresses IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type ADDR'; publicadminfalse214j&00COLUMN "char".char_contactsCOMMENTCOMMENT ON COLUMN "char".char_contacts IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type CNTCT'; publicadminfalse214k&00COLUMN "char".char_opportunityCOMMENTCOMMENT ON COLUMN "char".char_opportunity IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type OPP'; publicadminfalse214l&00COLUMN "char".char_employeesCOMMENTCOMMENT ON COLUMN "char".char_employees IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type EMP'; publicadminfalse214m&00COLUMN "char".char_incidentsCOMMENTCOMMENT ON COLUMN "char".char_incidents IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type INCDT'; publicadminfalse214n&00COLUMN "char".char_quotesCOMMENTCOMMENT ON COLUMN "char".char_quotes IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type QU'; publicadminfalse214o&00COLUMN "char".char_salesordersCOMMENTCOMMENT ON COLUMN "char".char_salesorders IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type SO'; publicadminfalse214p&00COLUMN "char".char_invoicesCOMMENTCOMMENT ON COLUMN "char".char_invoices IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type INV'; publicadminfalse214q&00COLUMN "char".char_vendorsCOMMENTCOMMENT ON COLUMN "char".char_vendors IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type V'; publicadminfalse214r&00!COLUMN "char".char_purchaseordersCOMMENTCOMMENT ON COLUMN "char".char_purchaseorders IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type PO'; publicadminfalse214s&00COLUMN "char".char_vouchersCOMMENTCOMMENT ON COLUMN "char".char_vouchers IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type VCH'; publicadminfalse214t&00COLUMN "char".char_projectsCOMMENTCOMMENT ON COLUMN "char".char_projects IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type PROJ'; publicadminfalse214u&00COLUMN "char".char_tasksCOMMENTCOMMENT ON COLUMN "char".char_tasks IS 'DEPRECATED - this column has been replaced by a row in the charuse table with target_type TASK'; publicadminfalse214v&00charACLREVOKE ALL ON TABLE "char" FROM PUBLIC; REVOKE ALL ON TABLE "char" FROM admin; GRANT ALL ON TABLE "char" TO admin; GRANT ALL ON TABLE "char" TO xtrole; publicadminfalse214125979575charassTABLECREATE TABLE charass ( charass_id integer NOT NULL, charass_target_type text, charass_target_id integer, charass_char_id integer, charass_value text, charass_default boolean DEFAULT false NOT NULL, charass_price numeric(16,4) DEFAULT 0 NOT NULL ); DROP TABLE public.charass; publicadminfalse612561268w&00 TABLE charassCOMMENTECOMMENT ON TABLE charass IS 'Characteristic assignment information'; publicadminfalse215x&00charassACLREVOKE ALL ON TABLE charass FROM PUBLIC; REVOKE ALL ON TABLE charass FROM admin; GRANT ALL ON TABLE charass TO admin; GRANT ALL ON TABLE charass TO xtrole; publicadminfalse215%125987656 accountcharVIEWCREATE VIEW accountchar AS SELECT (crmacct.crmacct_number)::character varying AS account_number, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value FROM public.crmacct, public."char", public.charass WHERE ((('CRMACCT'::text = charass.charass_target_type) AND (crmacct.crmacct_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id)); DROP VIEW api.accountchar; apiadminfalse86916y&00VIEW accountcharCOMMENT:COMMENT ON VIEW accountchar IS 'Account Characteristics'; apiadminfalse805z&00 accountcharACLREVOKE ALL ON TABLE accountchar FROM PUBLIC; REVOKE ALL ON TABLE accountchar FROM admin; GRANT ALL ON TABLE accountchar TO admin; GRANT ALL ON TABLE accountchar TO xtrole; apiadminfalse805125979587cmnttypeTABLEoCREATE TABLE cmnttype ( cmnttype_id integer NOT NULL, cmnttype_name text NOT NULL, cmnttype_descrip text NOT NULL, cmnttype_usedin text, cmnttype_sys boolean DEFAULT false NOT NULL, cmnttype_editable boolean DEFAULT false NOT NULL, cmnttype_order integer, CONSTRAINT cmnttype_cmnttype_name_check CHECK ((cmnttype_name <> ''::text)) ); DROP TABLE public.cmnttype; publicadminfalse6128612961308{&00TABLE cmnttypeCOMMENT9COMMENT ON TABLE cmnttype IS 'Comment Type information'; publicadminfalse216|&00cmnttypeACLREVOKE ALL ON TABLE cmnttype FROM PUBLIC; REVOKE ALL ON TABLE cmnttype FROM admin; GRANT ALL ON TABLE cmnttype TO admin; GRANT ALL ON TABLE cmnttype TO xtrole; publicadminfalse216125979596commentTABLEFCREATE TABLE comment ( comment_id integer DEFAULT nextval(('"comment_comment_id_seq"'::text)::regclass) NOT NULL, comment_source_id integer, comment_date timestamp with time zone, comment_user text, comment_text text, comment_cmnttype_id integer, comment_source text, comment_public boolean ); DROP TABLE public.comment; publicadminfalse61318}&00 TABLE commentCOMMENT3COMMENT ON TABLE comment IS 'Comment information'; publicadminfalse217~&00commentACLREVOKE ALL ON TABLE comment FROM PUBLIC; REVOKE ALL ON TABLE comment FROM admin; GRANT ALL ON TABLE comment TO admin; GRANT ALL ON TABLE comment TO xtrole; publicadminfalse217&125987663accountcommentVIEWCREATE VIEW accountcomment AS SELECT (crmacct.crmacct_number)::character varying AS account_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.crmacct, public.cmnttype, public.comment WHERE (((comment.comment_source = 'CRMA'::text) AND (comment.comment_source_id = crmacct.crmacct_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); DROP VIEW api.accountcomment; apiadminfalse86956&00VIEW accountcommentCOMMENT5COMMENT ON VIEW accountcomment IS 'Account Comment'; apiadminfalse806&00accountcommentACLREVOKE ALL ON TABLE accountcomment FROM PUBLIC; REVOKE ALL ON TABLE accountcomment FROM admin; GRANT ALL ON TABLE accountcomment TO admin; GRANT ALL ON TABLE accountcomment TO xtrole; apiadminfalse806125979607docassTABLEsCREATE TABLE docass ( docass_id integer NOT NULL, docass_source_id integer NOT NULL, docass_source_type text NOT NULL, docass_target_id integer NOT NULL, docass_target_type text DEFAULT 'URL'::text NOT NULL, docass_purpose character(1) DEFAULT 'S'::bpchar NOT NULL, CONSTRAINT docass_docass_purpose_check CHECK (((((((((docass_purpose = 'I'::bpchar) OR (docass_purpose = 'E'::bpchar)) OR (docass_purpose = 'M'::bpchar)) OR (docass_purpose = 'P'::bpchar)) OR (docass_purpose = 'A'::bpchar)) OR (docass_purpose = 'C'::bpchar)) OR (docass_purpose = 'S'::bpchar)) OR (docass_purpose = 'D'::bpchar))) ); DROP TABLE public.docass; publicadminfalse6133613461358&00 TABLE docassCOMMENT>COMMENT ON TABLE docass IS 'Document Assignement References'; publicadminfalse218&00docassACLREVOKE ALL ON TABLE docass FROM PUBLIC; REVOKE ALL ON TABLE docass FROM admin; GRANT ALL ON TABLE docass TO admin; GRANT ALL ON TABLE docass TO xtrole; publicadminfalse218125979616fileTABLECREATE TABLE file ( file_id integer NOT NULL, file_title text NOT NULL, file_stream bytea, file_descrip text NOT NULL ); DROP TABLE public.file; publicadminfalse8&00fileACLREVOKE ALL ON TABLE file FROM PUBLIC; REVOKE ALL ON TABLE file FROM admin; GRANT ALL ON TABLE file TO admin; GRANT ALL ON TABLE file TO xtrole; publicadminfalse219125979622urlinfoTABLEnCREATE TABLE urlinfo ( url_id integer NOT NULL, url_title text NOT NULL, url_url text NOT NULL ); DROP TABLE public.urlinfo; publicadminfalse8&00urlinfoACLREVOKE ALL ON TABLE urlinfo FROM PUBLIC; REVOKE ALL ON TABLE urlinfo FROM admin; GRANT ALL ON TABLE urlinfo TO admin; GRANT ALL ON TABLE urlinfo TO xtrole; publicadminfalse220125979628urlVIEWCREATE VIEW url AS SELECT docass.docass_id AS url_id, docass.docass_source_id AS url_source_id, docass.docass_source_type AS url_source, file.file_title AS url_title, file.file_descrip AS url_url, file.file_stream AS url_stream FROM (file JOIN docass ON (((docass.docass_target_id = file.file_id) AND (docass.docass_target_type = 'FILE'::text)))) UNION ALL SELECT docass.docass_id AS url_id, docass.docass_source_id AS url_source_id, docass.docass_source_type AS url_source, urlinfo.url_title, urlinfo.url_url, NULL::bytea AS url_stream FROM (urlinfo JOIN docass ON (((docass.docass_target_id = urlinfo.url_id) AND (docass.docass_target_type = 'URL'::text)))); DROP VIEW public.url; publicadminfalse86358&00urlACLREVOKE ALL ON TABLE url FROM PUBLIC; REVOKE ALL ON TABLE url FROM admin; GRANT ALL ON TABLE url TO admin; GRANT ALL ON TABLE url TO xtrole; publicadminfalse221'125987670 accountfileVIEWCREATE VIEW accountfile AS SELECT crmacct.crmacct_number AS account_number, url.url_title AS title, url.url_url AS url FROM public.crmacct, public.url WHERE ((crmacct.crmacct_id = url.url_source_id) AND (url.url_source = 'CRMA'::text)); DROP VIEW api.accountfile; apiadminfalse86996&00VIEW accountfileCOMMENT/COMMENT ON VIEW accountfile IS 'Account File'; apiadminfalse807&00 accountfileACLREVOKE ALL ON TABLE accountfile FROM PUBLIC; REVOKE ALL ON TABLE accountfile FROM admin; GRANT ALL ON TABLE accountfile TO admin; GRANT ALL ON TABLE accountfile TO xtrole; apiadminfalse807125979637docass_docass_id_seqSEQUENCEvCREATE SEQUENCE docass_docass_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.docass_docass_id_seq; publicadminfalse8218&00docass_docass_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE docass_docass_id_seq OWNED BY docass.docass_id; publicadminfalse222&00docass_docass_id_seqACLREVOKE ALL ON SEQUENCE docass_docass_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE docass_docass_id_seq FROM admin; GRANT ALL ON SEQUENCE docass_docass_id_seq TO admin; GRANT ALL ON SEQUENCE docass_docass_id_seq TO xtrole; publicadminfalse222125979639imageTABLECREATE TABLE image ( image_id integer DEFAULT nextval(('"image_image_id_seq"'::text)::regclass) NOT NULL, image_name text, image_descrip text, image_data text ); DROP TABLE public.image; publicadminfalse61388&00 TABLE imageCOMMENT/COMMENT ON TABLE image IS 'Image information'; publicadminfalse223&00imageACLREVOKE ALL ON TABLE image FROM PUBLIC; REVOKE ALL ON TABLE image FROM admin; GRANT ALL ON TABLE image TO admin; GRANT ALL ON TABLE image TO xtrole; publicadminfalse223125979646imageassTABLEqCREATE TABLE imageass ( imageass_id integer DEFAULT nextval('docass_docass_id_seq'::regclass) NOT NULL, imageass_source_id integer NOT NULL, imageass_source text NOT NULL, imageass_image_id integer NOT NULL, imageass_purpose character(1) NOT NULL, CONSTRAINT imageass_imageass_purpose_check CHECK (((((((((imageass_purpose = 'I'::bpchar) OR (imageass_purpose = 'E'::bpchar)) OR (imageass_purpose = 'M'::bpchar)) OR (imageass_purpose = 'P'::bpchar)) OR (imageass_purpose = 'A'::bpchar)) OR (imageass_purpose = 'C'::bpchar)) OR (imageass_purpose = 'D'::bpchar)) OR (imageass_purpose = 'S'::bpchar))) ); DROP TABLE public.imageass; publicadminfalse613961408&00TABLE imageassCOMMENT=COMMENT ON TABLE imageass IS 'Image Assignement References'; publicadminfalse224&00imageassACLREVOKE ALL ON TABLE imageass FROM PUBLIC; REVOKE ALL ON TABLE imageass FROM admin; GRANT ALL ON TABLE imageass TO admin; GRANT ALL ON TABLE imageass TO xtrole; publicadminfalse224(125987677 accountimageVIEW3CREATE VIEW accountimage AS SELECT crmacct.crmacct_number AS account_number, image.image_name FROM public.crmacct, public.imageass, public.image WHERE (((crmacct.crmacct_id = imageass.imageass_source_id) AND (imageass.imageass_source = 'CRMA'::text)) AND (imageass.imageass_image_id = image.image_id)); DROP VIEW api.accountimage; apiadminfalse87036&00VIEW accountimageCOMMENT1COMMENT ON VIEW accountimage IS 'Account Image'; apiadminfalse808&00 accountimageACLREVOKE ALL ON TABLE accountimage FROM PUBLIC; REVOKE ALL ON TABLE accountimage FROM admin; GRANT ALL ON TABLE accountimage TO admin; GRANT ALL ON TABLE accountimage TO xtrole; apiadminfalse808)125987684addressVIEWCREATE VIEW address AS SELECT (addr.addr_number)::character varying AS address_number, addr.addr_line1 AS address1, addr.addr_line2 AS address2, addr.addr_line3 AS address3, addr.addr_city AS city, addr.addr_state AS state, addr.addr_postalcode AS postal_code, addr.addr_country AS country, addr.addr_active AS active, addr.addr_notes AS notes, ''::text AS change FROM public.addr; DROP VIEW api.address; apiadminfalse87076&00 VIEW addressCOMMENT&COMMENT ON VIEW address IS 'Address'; apiadminfalse809&00addressACLREVOKE ALL ON TABLE address FROM PUBLIC; REVOKE ALL ON TABLE address FROM admin; GRANT ALL ON TABLE address TO admin; GRANT ALL ON TABLE address TO xtrole; apiadminfalse809*125987691 addresscharVIEW}CREATE VIEW addresschar AS SELECT (addr.addr_number)::character varying AS address_number, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value FROM public.addr, public."char", public.charass WHERE ((('ADDR'::text = charass.charass_target_type) AND (addr.addr_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id)); DROP VIEW api.addresschar; apiadminfalse87116&00VIEW addresscharCOMMENT:COMMENT ON VIEW addresschar IS 'Address Characteristics'; apiadminfalse810&00 addresscharACLREVOKE ALL ON TABLE addresschar FROM PUBLIC; REVOKE ALL ON TABLE addresschar FROM admin; GRANT ALL ON TABLE addresschar TO admin; GRANT ALL ON TABLE addresschar TO xtrole; apiadminfalse810+125987698addresscommentVIEWCREATE VIEW addresscomment AS SELECT (addr.addr_number)::character varying AS address_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.addr, public.cmnttype, public.comment WHERE (((comment.comment_source = 'ADDR'::text) AND (comment.comment_source_id = addr.addr_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); DROP VIEW api.addresscomment; apiadminfalse87156&00VIEW addresscommentCOMMENT5COMMENT ON VIEW addresscomment IS 'Address Comment'; apiadminfalse811&00addresscommentACLREVOKE ALL ON TABLE addresscomment FROM PUBLIC; REVOKE ALL ON TABLE addresscomment FROM admin; GRANT ALL ON TABLE addresscomment TO admin; GRANT ALL ON TABLE addresscomment TO xtrole; apiadminfalse811125979670bomheadTABLECREATE TABLE bomhead ( bomhead_id integer DEFAULT nextval(('"bomhead_bomhead_id_seq"'::text)::regclass) NOT NULL, bomhead_item_id integer NOT NULL, bomhead_serial integer, bomhead_docnum text, bomhead_revision text, bomhead_revisiondate date, bomhead_batchsize numeric(18,6), bomhead_requiredqtyper numeric(20,8), bomhead_rev_id integer DEFAULT (-1), CONSTRAINT bomhead_bomhead_batchsize_check CHECK ((bomhead_batchsize > (0)::numeric)) ); DROP TABLE public.bomhead; publicadminfalse6141614261438&00 TABLE bomheadCOMMENTJCOMMENT ON TABLE bomhead IS 'Bill of Materials (BOM) header information'; publicadminfalse225&00bomheadACLREVOKE ALL ON TABLE bomhead FROM PUBLIC; REVOKE ALL ON TABLE bomhead FROM admin; GRANT ALL ON TABLE bomhead TO admin; GRANT ALL ON TABLE bomhead TO xtrole; publicadminfalse225,125987709bomVIEWCREATE VIEW bom AS SELECT (item.item_number)::character varying AS item_number, (bomhead.bomhead_revision)::character varying AS revision, bomhead.bomhead_docnum AS document_number, bomhead.bomhead_revisiondate AS revision_date, bomhead.bomhead_batchsize AS batch_size, bomhead.bomhead_requiredqtyper AS total_qty_per FROM public.bomhead, public.item WHERE (bomhead.bomhead_item_id = item.item_id); DROP VIEW api.bom; apiadminfalse87196&00VIEW bomCOMMENT2COMMENT ON VIEW bom IS 'Bill of Material Header'; apiadminfalse812&00bomACLREVOKE ALL ON TABLE bom FROM PUBLIC; REVOKE ALL ON TABLE bom FROM admin; GRANT ALL ON TABLE bom TO admin; GRANT ALL ON TABLE bom TO xtrole; apiadminfalse812-125987716bomitemVIEWCREATE VIEW bomitem AS SELECT bomitem.bomitem_id AS id, (p.item_number)::character varying AS bom_item_number, (bomhead.bomhead_revision)::character varying AS bom_revision, bomitem.bomitem_seqnumber AS sequence_number, i.item_number, CASE WHEN (bomitem.bomitem_effective = public.startoftime()) THEN 'Always'::text ELSE public.formatdate(bomitem.bomitem_effective) END AS effective, CASE WHEN (bomitem.bomitem_expires = public.endoftime()) THEN 'Never'::text ELSE public.formatdate(bomitem.bomitem_expires) END AS expires, bomitem.bomitem_qtyper AS qty_per, uom.uom_name AS issue_uom, bomitem.bomitem_scrap AS scrap, bomitem.bomitem_createwo AS create_child_wo, CASE WHEN (bomitem.bomitem_issuemethod = 'M'::bpchar) THEN 'Mixed'::text WHEN (bomitem.bomitem_issuemethod = 'L'::bpchar) THEN 'Pull'::text WHEN (bomitem.bomitem_issuemethod = 'S'::bpchar) THEN 'Push'::text ELSE NULL::text END AS issue_method, public.formatbooseq(p.item_id, bomitem.bomitem_booitem_seq_id) AS used_at, bomitem.bomitem_schedatwooper AS schedule_at_wo_operation, bomitem.bomitem_ecn AS ecn_number, bomitem.bomitem_notes AS notes, bomitem.bomitem_ref AS reference, CASE WHEN (bomitem.bomitem_subtype = 'N'::bpchar) THEN 'No'::text WHEN (bomitem.bomitem_subtype = 'I'::bpchar) THEN 'Item-Defined'::text WHEN (bomitem.bomitem_subtype = 'B'::bpchar) THEN 'BOM-Defined'::text ELSE NULL::text END AS substitutions, "char".char_name AS characteristic, bomitem.bomitem_value AS value FROM ((public.bomitem LEFT JOIN public.bomhead ON (((bomitem.bomitem_parent_item_id = bomhead.bomhead_item_id) AND (bomitem.bomitem_rev_id = bomhead.bomhead_rev_id)))) LEFT JOIN public."char" ON ((bomitem.bomitem_char_id = "char".char_id))), public.item p, public.item i, public.uom WHERE (((bomitem.bomitem_parent_item_id = p.item_id) AND (bomitem.bomitem_item_id = i.item_id)) AND (bomitem.bomitem_uom_id = uom.uom_id)) ORDER BY p.item_number, bomitem.bomitem_seqnumber; DROP VIEW api.bomitem; apiadminfalse87236&00 VIEW bomitemCOMMENT4COMMENT ON VIEW bomitem IS 'Bill of Material Item'; apiadminfalse813&00bomitemACLREVOKE ALL ON TABLE bomitem FROM PUBLIC; REVOKE ALL ON TABLE bomitem FROM admin; GRANT ALL ON TABLE bomitem TO admin; GRANT ALL ON TABLE bomitem TO xtrole; apiadminfalse813.125987726bomitemcommentVIEWCREATE VIEW bomitemcomment AS SELECT bomitem.bomitem_id, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM (public.bomitem LEFT JOIN public.bomhead ON (((bomitem.bomitem_parent_item_id = bomhead.bomhead_item_id) AND (bomitem.bomitem_rev_id = bomhead.bomhead_rev_id)))), public.item, public.cmnttype, public.comment WHERE ((((comment.comment_source = 'BMI'::text) AND (comment.comment_source_id = bomitem.bomitem_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)) AND (bomitem.bomitem_parent_item_id = item.item_id)) ORDER BY item.item_number, bomhead.bomhead_revision, bomitem.bomitem_seqnumber, comment.comment_date; DROP VIEW api.bomitemcomment; apiadminfalse87276&00VIEW bomitemcommentCOMMENT>COMMENT ON VIEW bomitemcomment IS 'Bill of Material Comment'; apiadminfalse814&00bomitemcommentACLREVOKE ALL ON TABLE bomitemcomment FROM PUBLIC; REVOKE ALL ON TABLE bomitemcomment FROM admin; GRANT ALL ON TABLE bomitemcomment TO admin; GRANT ALL ON TABLE bomitemcomment TO xtrole; apiadminfalse814125979693 bomitemsubTABLECREATE TABLE bomitemsub ( bomitemsub_id integer NOT NULL, bomitemsub_bomitem_id integer NOT NULL, bomitemsub_item_id integer NOT NULL, bomitemsub_uomratio numeric(20,10) NOT NULL, bomitemsub_rank integer NOT NULL ); DROP TABLE public.bomitemsub; publicadminfalse8&00TABLE bomitemsubCOMMENT\COMMENT ON TABLE bomitemsub IS 'Bill of Materials (BOM) defined Substitutions information'; publicadminfalse226&00 bomitemsubACLREVOKE ALL ON TABLE bomitemsub FROM PUBLIC; REVOKE ALL ON TABLE bomitemsub FROM admin; GRANT ALL ON TABLE bomitemsub TO admin; GRANT ALL ON TABLE bomitemsub TO xtrole; publicadminfalse226/125987734bomitemsubstituteVIEWCREATE VIEW bomitemsubstitute AS SELECT bomitem.bomitem_id, (p.item_number)::character varying AS bom_item_number, (bomhead.bomhead_revision)::character varying AS bom_revision, bomitem.bomitem_seqnumber AS sequence_number, (s.item_number)::character varying AS substitute_item_number, bomitemsub.bomitemsub_uomratio AS sub_parent_uom_ratio, bomitemsub.bomitemsub_rank AS ranking FROM public.item p, public.item s, (public.bomitem LEFT JOIN public.bomhead ON (((bomitem.bomitem_parent_item_id = bomhead.bomhead_item_id) AND (bomitem.bomitem_rev_id = bomhead.bomhead_rev_id)))), public.bomitemsub WHERE (((p.item_id = bomitem.bomitem_parent_item_id) AND (s.item_id = bomitemsub.bomitemsub_item_id)) AND (bomitemsub.bomitemsub_bomitem_id = bomitem.bomitem_id)); !DROP VIEW api.bomitemsubstitute; apiadminfalse87316&00VIEW bomitemsubstituteCOMMENTICOMMENT ON VIEW bomitemsubstitute IS 'Bill of Material Item Substitute'; apiadminfalse815&00bomitemsubstituteACLREVOKE ALL ON TABLE bomitemsubstitute FROM PUBLIC; REVOKE ALL ON TABLE bomitemsubstitute FROM admin; GRANT ALL ON TABLE bomitemsubstitute TO admin; GRANT ALL ON TABLE bomitemsubstitute TO xtrole; apiadminfalse815125979701budgheadTABLECREATE TABLE budghead ( budghead_id integer NOT NULL, budghead_name text NOT NULL, budghead_descrip text, CONSTRAINT budghead_budghead_name_check CHECK ((budghead_name <> ''::text)) ); DROP TABLE public.budghead; publicadminfalse61468&00budgheadACLREVOKE ALL ON TABLE budghead FROM PUBLIC; REVOKE ALL ON TABLE budghead FROM admin; GRANT ALL ON TABLE budghead TO admin; GRANT ALL ON TABLE budghead TO xtrole; publicadminfalse2270125987742budgetVIEWCREATE VIEW budget AS SELECT budghead.budghead_name AS name, budghead.budghead_descrip AS description FROM public.budghead ORDER BY budghead.budghead_name; DROP VIEW api.budget; apiadminfalse87356&00 VIEW budgetCOMMENT+COMMENT ON VIEW budget IS 'Budget Header'; apiadminfalse816&00budgetACLREVOKE ALL ON TABLE budget FROM PUBLIC; REVOKE ALL ON TABLE budget FROM admin; GRANT ALL ON TABLE budget TO admin; GRANT ALL ON TABLE budget TO xtrole; apiadminfalse816125979712accntTABLEyCREATE TABLE accnt ( accnt_id integer DEFAULT nextval(('accnt_accnt_id_seq'::text)::regclass) NOT NULL, accnt_number text, accnt_descrip text, accnt_comments text, accnt_profit text, accnt_sub text, accnt_type character(1) NOT NULL, accnt_extref text, accnt_company text, accnt_forwardupdate boolean, accnt_subaccnttype_code text, accnt_curr_id integer DEFAULT basecurrid(), accnt_active boolean DEFAULT true NOT NULL, accnt_name text, CONSTRAINT accnt_accnt_type_check CHECK ((accnt_type = ANY (ARRAY['A'::bpchar, 'E'::bpchar, 'L'::bpchar, 'Q'::bpchar, 'R'::bpchar]))) ); DROP TABLE public.accnt; publicadminfalse61476148614961508&00 TABLE accntCOMMENTMCOMMENT ON TABLE accnt IS 'General Ledger (G/L) Account Number information'; publicadminfalse228&00accntACLREVOKE ALL ON TABLE accnt FROM PUBLIC; REVOKE ALL ON TABLE accnt FROM admin; GRANT ALL ON TABLE accnt TO admin; GRANT ALL ON TABLE accnt TO xtrole; publicadminfalse228125979722budgitemTABLECREATE TABLE budgitem ( budgitem_id integer NOT NULL, budgitem_budghead_id integer NOT NULL, budgitem_period_id integer NOT NULL, budgitem_accnt_id integer NOT NULL, budgitem_amount numeric(20,4) NOT NULL ); DROP TABLE public.budgitem; publicadminfalse8&00budgitemACLREVOKE ALL ON TABLE budgitem FROM PUBLIC; REVOKE ALL ON TABLE budgitem FROM admin; GRANT ALL ON TABLE budgitem TO admin; GRANT ALL ON TABLE budgitem TO xtrole; publicadminfalse229125979725periodTABLE<CREATE TABLE period ( period_id integer NOT NULL, period_start date, period_end date, period_closed boolean, period_freeze boolean, period_initial boolean DEFAULT false, period_name text, period_yearperiod_id integer, period_quarter integer, period_number integer NOT NULL ); DROP TABLE public.period; publicadminfalse61538&00 TABLE periodCOMMENT<COMMENT ON TABLE period IS 'Accounting Period information'; publicadminfalse230&00periodACLREVOKE ALL ON TABLE period FROM PUBLIC; REVOKE ALL ON TABLE period FROM admin; GRANT ALL ON TABLE period TO admin; GRANT ALL ON TABLE period TO xtrole; publicadminfalse2301125987749 budgetentryVIEWCREATE VIEW budgetentry AS SELECT budghead.budghead_name AS name, public.formatglaccount(accnt.accnt_id) AS account, period.period_start, budgitem.budgitem_amount AS amount FROM public.budgitem, public.budghead, public.period, public.accnt WHERE (((budgitem.budgitem_budghead_id = budghead.budghead_id) AND (budgitem.budgitem_period_id = period.period_id)) AND (budgitem.budgitem_accnt_id = accnt.accnt_id)) ORDER BY budghead.budghead_name, period.period_start, public.formatglaccount(accnt.accnt_id); DROP VIEW api.budgetentry; apiadminfalse87396&00VIEW budgetentryCOMMENT/COMMENT ON VIEW budgetentry IS 'Budget Entry'; apiadminfalse817&00 budgetentryACLREVOKE ALL ON TABLE budgetentry FROM PUBLIC; REVOKE ALL ON TABLE budgetentry FROM admin; GRANT ALL ON TABLE budgetentry TO admin; GRANT ALL ON TABLE budgetentry TO xtrole; apiadminfalse817125979736 bankaccntTABLECREATE TABLE bankaccnt ( bankaccnt_id integer NOT NULL, bankaccnt_name text NOT NULL, bankaccnt_descrip text, bankaccnt_bankname text, bankaccnt_accntnumber text, bankaccnt_ar boolean, bankaccnt_ap boolean, bankaccnt_nextchknum integer, bankaccnt_type character(1), bankaccnt_accnt_id integer, bankaccnt_check_form_id integer, bankaccnt_userec boolean, bankaccnt_rec_accnt_id integer, bankaccnt_curr_id integer DEFAULT basecurrid(), bankaccnt_notes text, bankaccnt_routing text DEFAULT ''::text NOT NULL, bankaccnt_ach_enabled boolean DEFAULT false NOT NULL, bankaccnt_ach_origin text DEFAULT ''::text NOT NULL, bankaccnt_ach_genchecknum boolean DEFAULT false NOT NULL, bankaccnt_ach_leadtime integer, bankaccnt_ach_lastdate date, bankaccnt_ach_lastfileid character(1), bankaccnt_ach_origintype text, bankaccnt_ach_originname text, bankaccnt_ach_desttype text, bankaccnt_ach_fed_dest text, bankaccnt_ach_destname text, bankaccnt_ach_dest text, bankaccnt_prnt_check boolean DEFAULT true NOT NULL, CONSTRAINT bankaccnt_bankaccnt_name_check CHECK ((bankaccnt_name <> ''::text)) ); DROP TABLE public.bankaccnt; publicadminfalse61546155615661576158616061618&00TABLE bankaccntCOMMENT:COMMENT ON TABLE bankaccnt IS 'Bank Account information'; publicadminfalse231&00 bankaccntACLREVOKE ALL ON TABLE bankaccnt FROM PUBLIC; REVOKE ALL ON TABLE bankaccnt FROM admin; GRANT ALL ON TABLE bankaccnt TO admin; GRANT ALL ON TABLE bankaccnt TO xtrole; publicadminfalse231125979748cashrcptTABLECREATE TABLE cashrcpt ( cashrcpt_id integer NOT NULL, cashrcpt_cust_id integer NOT NULL, cashrcpt_amount numeric(20,2) NOT NULL, cashrcpt_fundstype character(1) NOT NULL, cashrcpt_docnumber text, cashrcpt_bankaccnt_id integer NOT NULL, cashrcpt_notes text, cashrcpt_distdate date DEFAULT ('now'::text)::date, cashrcpt_salescat_id integer DEFAULT (-1), cashrcpt_curr_id integer DEFAULT basecurrid(), cashrcpt_usecustdeposit boolean DEFAULT false NOT NULL, cashrcpt_void boolean DEFAULT false NOT NULL, cashrcpt_number text NOT NULL, cashrcpt_docdate date, cashrcpt_posted boolean DEFAULT false NOT NULL, cashrcpt_posteddate date, cashrcpt_postedby text, cashrcpt_applydate date, cashrcpt_discount numeric(20,2) DEFAULT 0.00 NOT NULL, cashrcpt_curr_rate numeric NOT NULL, cashrcpt_alt_curr_rate numeric, CONSTRAINT cashrcpt_cashrcpt_number_check CHECK ((cashrcpt_number <> ''::text)) ); DROP TABLE public.cashrcpt; publicadminfalse616261636164616561666167616861708&00TABLE cashrcptCOMMENTuCOMMENT ON TABLE cashrcpt IS 'Temporary table for storing Cash Receipt information before Cash Receipts are posted'; publicadminfalse232&00cashrcptACLREVOKE ALL ON TABLE cashrcpt FROM PUBLIC; REVOKE ALL ON TABLE cashrcpt FROM admin; GRANT ALL ON TABLE cashrcpt TO admin; GRANT ALL ON TABLE cashrcpt TO xtrole; publicadminfalse2322125987756 cashreceiptVIEW/CREATE VIEW cashreceipt AS SELECT (custinfo.cust_number)::character varying AS customer_number, cashrcpt.cashrcpt_number AS cashreceipt_number, CASE WHEN (cashrcpt.cashrcpt_fundstype = 'C'::bpchar) THEN 'Check'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'T'::bpchar) THEN 'Certified Check'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'M'::bpchar) THEN 'Master Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'V'::bpchar) THEN 'Visa'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'A'::bpchar) THEN 'American Express'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'D'::bpchar) THEN 'Discover Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'R'::bpchar) THEN 'Other Credit Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'K'::bpchar) THEN 'Cash'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'W'::bpchar) THEN 'Wire Transfer'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'O'::bpchar) THEN 'Other'::character varying ELSE NULL::character varying END AS funds_type, (cashrcpt.cashrcpt_docnumber)::character varying AS check_document_number, custinfo.cust_name AS customer_name, m.addr_line1 AS customer_address, curr_symbol.curr_abbr AS currency, cashrcpt.cashrcpt_amount AS amount_received, bankaccnt.bankaccnt_name AS post_to, public.formatdate(cashrcpt.cashrcpt_distdate) AS distribution_date, CASE WHEN cashrcpt.cashrcpt_usecustdeposit THEN 'Customer Deposit'::text ELSE 'Credit Memo'::text END AS apply_balance_as, salescat.salescat_name AS sales_category, cashrcpt.cashrcpt_notes AS notes FROM ((((((public.cashrcpt LEFT JOIN public.custinfo ON ((custinfo.cust_id = cashrcpt.cashrcpt_cust_id))) LEFT JOIN public.cntct mc ON ((custinfo.cust_cntct_id = mc.cntct_id))) LEFT JOIN public.addr m ON ((mc.cntct_addr_id = m.addr_id))) LEFT JOIN public.curr_symbol ON ((curr_symbol.curr_id = cashrcpt.cashrcpt_curr_id))) LEFT JOIN public.bankaccnt ON ((bankaccnt.bankaccnt_id = cashrcpt.cashrcpt_bankaccnt_id))) LEFT JOIN public.salescat ON ((salescat.salescat_id = cashrcpt.cashrcpt_salescat_id))); DROP VIEW api.cashreceipt; apiadminfalse87436&00VIEW cashreceiptCOMMENTCOMMENT ON VIEW cashreceipt IS ' This view can be used as an interface to import Cash Receipt data directly into the system. Required fields will be checked and default values will be populated'; apiadminfalse818&00 cashreceiptACLREVOKE ALL ON TABLE cashreceipt FROM PUBLIC; REVOKE ALL ON TABLE cashreceipt FROM admin; GRANT ALL ON TABLE cashreceipt TO admin; GRANT ALL ON TABLE cashreceipt TO xtrole; apiadminfalse818125979767 cashrcptitemTABLE>CREATE TABLE cashrcptitem ( cashrcptitem_id integer NOT NULL, cashrcptitem_cashrcpt_id integer NOT NULL, cashrcptitem_aropen_id integer NOT NULL, cashrcptitem_amount numeric(20,2) NOT NULL, cashrcptitem_discount numeric(20,2) DEFAULT 0.00 NOT NULL, cashrcptitem_applied boolean DEFAULT true ); DROP TABLE public.cashrcptitem; publicadminfalse617261738&00TABLE cashrcptitemCOMMENTCOMMENT ON TABLE cashrcptitem IS 'Temporary table for storing information about applications of Cash Receipts before Cash Receipts are posted'; publicadminfalse233&00 cashrcptitemACLREVOKE ALL ON TABLE cashrcptitem FROM PUBLIC; REVOKE ALL ON TABLE cashrcptitem FROM admin; GRANT ALL ON TABLE cashrcptitem TO admin; GRANT ALL ON TABLE cashrcptitem TO xtrole; publicadminfalse2333125987767cashreceiptapplyVIEW CREATE VIEW cashreceiptapply AS SELECT (custinfo.cust_number)::character varying AS customer_number, CASE WHEN (cashrcpt.cashrcpt_fundstype = 'C'::bpchar) THEN 'Check'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'T'::bpchar) THEN 'Certified Check'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'M'::bpchar) THEN 'Master Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'V'::bpchar) THEN 'Visa'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'A'::bpchar) THEN 'American Express'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'D'::bpchar) THEN 'Discover Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'R'::bpchar) THEN 'Other Credit Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'K'::bpchar) THEN 'Cash'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'W'::bpchar) THEN 'Wire Transfer'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'O'::bpchar) THEN 'Other'::character varying ELSE NULL::character varying END AS funds_type, (cashrcpt.cashrcpt_docnumber)::character varying AS check_document_number, (aropen.aropen_doctype)::character varying AS doc_type, (aropen.aropen_docnumber)::character varying AS doc_number, custinfo.cust_name AS customer_name, m.addr_line1 AS customer_address, public.formatdate(aropen.aropen_docdate) AS doc_date, public.formatdate(aropen.aropen_duedate) AS due_date, curr_symbol.curr_abbr AS currency, aropen.aropen_amount AS open_amount, cashrcptitem.cashrcptitem_amount AS amount_to_apply, cashrcptitem.cashrcptitem_discount FROM ((((((public.cashrcptitem LEFT JOIN public.cashrcpt ON ((cashrcpt.cashrcpt_id = cashrcptitem.cashrcptitem_cashrcpt_id))) LEFT JOIN public.custinfo ON ((custinfo.cust_id = cashrcpt.cashrcpt_cust_id))) LEFT JOIN public.cntct mc ON ((custinfo.cust_cntct_id = mc.cntct_id))) LEFT JOIN public.addr m ON ((mc.cntct_addr_id = m.addr_id))) LEFT JOIN public.curr_symbol ON ((curr_symbol.curr_id = cashrcpt.cashrcpt_curr_id))) LEFT JOIN public.aropen ON ((aropen.aropen_id = cashrcptitem.cashrcptitem_aropen_id))); DROP VIEW api.cashreceiptapply; apiadminfalse87476&00VIEW cashreceiptapplyCOMMENTCOMMENT ON VIEW cashreceiptapply IS ' This view can be used as an interface to import Cash Receipt Application data directly into the system. Required fields will be checked and default values will be populated'; apiadminfalse819&00cashreceiptapplyACLREVOKE ALL ON TABLE cashreceiptapply FROM PUBLIC; REVOKE ALL ON TABLE cashreceiptapply FROM admin; GRANT ALL ON TABLE cashreceiptapply TO admin; GRANT ALL ON TABLE cashreceiptapply TO xtrole; apiadminfalse819125979777 cashrcptmiscTABLECREATE TABLE cashrcptmisc ( cashrcptmisc_id integer NOT NULL, cashrcptmisc_cashrcpt_id integer NOT NULL, cashrcptmisc_accnt_id integer NOT NULL, cashrcptmisc_amount numeric(20,2) NOT NULL, cashrcptmisc_notes text ); DROP TABLE public.cashrcptmisc; publicadminfalse8&00TABLE cashrcptmiscCOMMENTWCOMMENT ON TABLE cashrcptmisc IS 'Cash Receipt Miscellaneous Application information'; publicadminfalse234&00 cashrcptmiscACLREVOKE ALL ON TABLE cashrcptmisc FROM PUBLIC; REVOKE ALL ON TABLE cashrcptmisc FROM admin; GRANT ALL ON TABLE cashrcptmisc TO admin; GRANT ALL ON TABLE cashrcptmisc TO xtrole; publicadminfalse2344125987778cashreceiptapplymiscVIEWCREATE VIEW cashreceiptapplymisc AS SELECT (custinfo.cust_number)::character varying AS customer_number, CASE WHEN (cashrcpt.cashrcpt_fundstype = 'C'::bpchar) THEN 'Check'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'T'::bpchar) THEN 'Certified Check'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'M'::bpchar) THEN 'Master Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'V'::bpchar) THEN 'Visa'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'A'::bpchar) THEN 'American Express'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'D'::bpchar) THEN 'Discover Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'R'::bpchar) THEN 'Other Credit Card'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'K'::bpchar) THEN 'Cash'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'W'::bpchar) THEN 'Wire Transfer'::character varying WHEN (cashrcpt.cashrcpt_fundstype = 'O'::bpchar) THEN 'Other'::character varying ELSE NULL::character varying END AS funds_type, (cashrcpt.cashrcpt_docnumber)::character varying AS check_document_number, (public.formatglaccount(accnt.accnt_id))::character varying AS account, custinfo.cust_name AS customer_name, m.addr_line1 AS customer_address, accnt.accnt_descrip AS account_description, curr_symbol.curr_abbr AS currency, cashrcptmisc.cashrcptmisc_amount AS amount_to_distribute, cashrcptmisc.cashrcptmisc_notes AS notes FROM ((((((public.cashrcptmisc LEFT JOIN public.cashrcpt ON ((cashrcpt.cashrcpt_id = cashrcptmisc.cashrcptmisc_cashrcpt_id))) LEFT JOIN public.custinfo ON ((custinfo.cust_id = cashrcpt.cashrcpt_cust_id))) LEFT JOIN public.cntct mc ON ((custinfo.cust_cntct_id = mc.cntct_id))) LEFT JOIN public.addr m ON ((mc.cntct_addr_id = m.addr_id))) LEFT JOIN public.curr_symbol ON ((curr_symbol.curr_id = cashrcpt.cashrcpt_curr_id))) LEFT JOIN public.accnt ON ((accnt.accnt_id = cashrcptmisc.cashrcptmisc_accnt_id))); $DROP VIEW api.cashreceiptapplymisc; apiadminfalse87516&00VIEW cashreceiptapplymiscCOMMENTCOMMENT ON VIEW cashreceiptapplymisc IS ' This view can be used as an interface to import Cash Receipt Miscellaneous Application data directly into the system. Required fields will be checked and default values will be populated'; apiadminfalse820&00cashreceiptapplymiscACLREVOKE ALL ON TABLE cashreceiptapplymisc FROM PUBLIC; REVOKE ALL ON TABLE cashreceiptapplymisc FROM admin; GRANT ALL ON TABLE cashreceiptapplymisc TO admin; GRANT ALL ON TABLE cashreceiptapplymisc TO xtrole; apiadminfalse8205125987789contactVIEWCREATE VIEW contact AS SELECT (cntct.cntct_number)::character varying AS contact_number, cntct.cntct_honorific AS honorific, cntct.cntct_first_name AS first, cntct.cntct_middle AS middle, cntct.cntct_last_name AS last, cntct.cntct_suffix AS suffix, cntct.cntct_initials AS initials, crmacct.crmacct_number AS crm_account, cntct.cntct_active AS active, cntct.cntct_title AS job_title, cntct.cntct_phone AS voice, cntct.cntct_phone2 AS alternate, cntct.cntct_fax AS fax, cntct.cntct_email AS email, cntct.cntct_webaddr AS web, ''::text AS contact_change, addr.addr_number AS address_number, addr.addr_line1 AS address1, addr.addr_line2 AS address2, addr.addr_line3 AS address3, addr.addr_city AS city, addr.addr_state AS state, addr.addr_postalcode AS postal_code, addr.addr_country AS country, cntct.cntct_notes AS notes, ''::text AS address_change FROM ((public.cntct LEFT JOIN public.addr ON ((cntct.cntct_addr_id = addr.addr_id))) LEFT JOIN public.crmacct ON ((cntct.cntct_crmacct_id = crmacct.crmacct_id))); DROP VIEW api.contact; apiadminfalse87556&00 VIEW contactCOMMENT&COMMENT ON VIEW contact IS 'Contact'; apiadminfalse821&00contactACLREVOKE ALL ON TABLE contact FROM PUBLIC; REVOKE ALL ON TABLE contact FROM admin; GRANT ALL ON TABLE contact TO admin; GRANT ALL ON TABLE contact TO xtrole; apiadminfalse8216125987798 contactcharVIEWnCREATE VIEW contactchar AS SELECT cntct.cntct_number AS contact_number, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value FROM public.cntct, public."char", public.charass WHERE ((('CNTCT'::text = charass.charass_target_type) AND (cntct.cntct_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id)); DROP VIEW api.contactchar; apiadminfalse87596&00VIEW contactcharCOMMENT:COMMENT ON VIEW contactchar IS 'Contact Characteristics'; apiadminfalse822&00 contactcharACLREVOKE ALL ON TABLE contactchar FROM PUBLIC; REVOKE ALL ON TABLE contactchar FROM admin; GRANT ALL ON TABLE contactchar TO admin; GRANT ALL ON TABLE contactchar TO xtrole; apiadminfalse8227125987805contactcommentVIEWCREATE VIEW contactcomment AS SELECT cntct.cntct_number AS contact_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.cntct, public.cmnttype, public.comment WHERE (((comment.comment_source = 'T'::text) AND (comment.comment_source_id = cntct.cntct_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); DROP VIEW api.contactcomment; apiadminfalse87636&00VIEW contactcommentCOMMENT5COMMENT ON VIEW contactcomment IS 'Contact Comment'; apiadminfalse823&00contactcommentACLREVOKE ALL ON TABLE contactcomment FROM PUBLIC; REVOKE ALL ON TABLE contactcomment FROM admin; GRANT ALL ON TABLE contactcomment TO admin; GRANT ALL ON TABLE contactcomment TO xtrole; apiadminfalse823:125987832custcharVIEWCREATE VIEW custchar AS SELECT (custinfo.cust_number)::character varying AS customer_number, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value FROM public.custinfo, public."char", public.charass WHERE ((('C'::text = charass.charass_target_type) AND (custinfo.cust_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id)); DROP VIEW api.custchar; apiadminfalse87756&00 VIEW custcharCOMMENT8COMMENT ON VIEW custchar IS 'Customer Characteristics'; apiadminfalse826&00custcharACLREVOKE ALL ON TABLE custchar FROM PUBLIC; REVOKE ALL ON TABLE custchar FROM admin; GRANT ALL ON TABLE custchar TO admin; GRANT ALL ON TABLE custchar TO xtrole; apiadminfalse826;125987840 custcommentVIEWCREATE VIEW custcomment AS SELECT (custinfo.cust_number)::character varying AS customer_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.custinfo, public.cmnttype, public.comment WHERE (((comment.comment_source = 'C'::text) AND (comment.comment_source_id = custinfo.cust_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); DROP VIEW api.custcomment; apiadminfalse87796&00VIEW custcommentCOMMENT3COMMENT ON VIEW custcomment IS 'Customer Comment'; apiadminfalse827&00 custcommentACLREVOKE ALL ON TABLE custcomment FROM PUBLIC; REVOKE ALL ON TABLE custcomment FROM admin; GRANT ALL ON TABLE custcomment TO admin; GRANT ALL ON TABLE custcomment TO xtrole; apiadminfalse827125979810ccardTABLEgCREATE TABLE ccard ( ccard_id integer NOT NULL, ccard_seq integer DEFAULT 10 NOT NULL, ccard_cust_id integer NOT NULL, ccard_active boolean DEFAULT true, ccard_name bytea, ccard_address1 bytea, ccard_address2 bytea, ccard_city bytea, ccard_state bytea, ccard_zip bytea, ccard_country bytea, ccard_number bytea, ccard_debit boolean DEFAULT false, ccard_month_expired bytea, ccard_year_expired bytea, ccard_type character(1) NOT NULL, ccard_date_added timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL, ccard_lastupdated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL, ccard_added_by_username text DEFAULT geteffectivextuser() NOT NULL, ccard_last_updated_by_username text DEFAULT geteffectivextuser() NOT NULL ); DROP TABLE public.ccard; publicadminfalse61756176617761786179618061818&00 TABLE ccardCOMMENTSCOMMENT ON TABLE ccard IS 'Credit Card Information - all bytea data is encrypted'; publicadminfalse235&00ccardACLREVOKE ALL ON TABLE ccard FROM PUBLIC; REVOKE ALL ON TABLE ccard FROM admin; GRANT ALL ON TABLE ccard TO admin; GRANT ALL ON TABLE ccard TO xtrole; publicadminfalse235<125987847custcreditcardVIEWCREATE VIEW custcreditcard AS SELECT (custinfo.cust_number)::character varying AS customer_number, CASE WHEN (ccard.ccard_type = 'V'::bpchar) THEN 'Visa'::text WHEN (ccard.ccard_type = 'M'::bpchar) THEN 'Master Card'::text WHEN (ccard.ccard_type = 'A'::bpchar) THEN 'American Express'::text WHEN (ccard.ccard_type = 'D'::bpchar) THEN 'Discover'::text ELSE 'Not Supported'::text END AS credit_card_type, ccard.ccard_active AS active, ccard.ccard_number AS credit_card_number, ccard.ccard_name AS name, ccard.ccard_address1 AS street_address1, ccard.ccard_address2 AS street_address2, ccard.ccard_city AS city, ccard.ccard_state AS state, ccard.ccard_zip AS postal_code, ccard.ccard_country AS country, ccard.ccard_month_expired AS expiration_month, ccard.ccard_year_expired AS expiration_year, ''::text AS key FROM public.ccard, public.custinfo WHERE (ccard.ccard_cust_id = custinfo.cust_id); DROP VIEW api.custcreditcard; apiadminfalse87836&00VIEW custcreditcardCOMMENT<COMMENT ON VIEW custcreditcard IS 'Customer Credit Cards.'; apiadminfalse828&00custcreditcardACLREVOKE ALL ON TABLE custcreditcard FROM PUBLIC; REVOKE ALL ON TABLE custcreditcard FROM admin; GRANT ALL ON TABLE custcreditcard TO admin; GRANT ALL ON TABLE custcreditcard TO xtrole; apiadminfalse828125979828custtypeTABLEBCREATE TABLE custtype ( custtype_id integer DEFAULT nextval(('custtype_custtype_id_seq'::text)::regclass) NOT NULL, custtype_code text NOT NULL, custtype_descrip text NOT NULL, custtype_char boolean DEFAULT false NOT NULL, CONSTRAINT custtype_custtype_code_check CHECK ((custtype_code <> ''::text)) ); DROP TABLE public.custtype; publicadminfalse6183618461858&00TABLE custtypeCOMMENT:COMMENT ON TABLE custtype IS 'Customer Type information'; publicadminfalse236&00custtypeACLREVOKE ALL ON TABLE custtype FROM PUBLIC; REVOKE ALL ON TABLE custtype FROM admin; GRANT ALL ON TABLE custtype TO admin; GRANT ALL ON TABLE custtype TO xtrole; publicadminfalse236125979837shipchrgTABLECREATE TABLE shipchrg ( shipchrg_id integer NOT NULL, shipchrg_name text NOT NULL, shipchrg_descrip text, shipchrg_custfreight boolean, shipchrg_handling character(1), CONSTRAINT shipchrg_shipchrg_name_check CHECK ((shipchrg_name <> ''::text)) ); DROP TABLE public.shipchrg; publicadminfalse61878&00TABLE shipchrgCOMMENT<COMMENT ON TABLE shipchrg IS 'Shipping Charge information'; publicadminfalse237&00shipchrgACLREVOKE ALL ON TABLE shipchrg FROM PUBLIC; REVOKE ALL ON TABLE shipchrg FROM admin; GRANT ALL ON TABLE shipchrg TO admin; GRANT ALL ON TABLE shipchrg TO xtrole; publicadminfalse237125979844shipformTABLE-CREATE TABLE shipform ( shipform_id integer DEFAULT nextval(('"shipform_shipform_id_seq"'::text)::regclass) NOT NULL, shipform_name text NOT NULL, shipform_report_id integer, shipform_report_name text, CONSTRAINT shipform_shipform_name_check CHECK ((shipform_name <> ''::text)) ); DROP TABLE public.shipform; publicadminfalse618861898&00TABLE shipformCOMMENT:COMMENT ON TABLE shipform IS 'Shipping Form information'; publicadminfalse238&00"COLUMN shipform.shipform_report_idCOMMENThCOMMENT ON COLUMN shipform.shipform_report_id IS 'Obsolete -- reference shipform_report_name instead.'; publicadminfalse238&00shipformACLREVOKE ALL ON TABLE shipform FROM PUBLIC; REVOKE ALL ON TABLE shipform FROM admin; GRANT ALL ON TABLE shipform TO admin; GRANT ALL ON TABLE shipform TO xtrole; publicadminfalse238=125987855customerVIEWCREATE VIEW customer AS SELECT (custinfo.cust_number)::character varying AS customer_number, custtype.custtype_code AS customer_type, custinfo.cust_name AS customer_name, custinfo.cust_active AS active, salesrep.salesrep_number AS sales_rep, (custinfo.cust_commprcnt * (100)::numeric) AS commission, custinfo.cust_shipvia AS ship_via, shipform.shipform_name AS ship_form, shipchrg.shipchrg_name AS shipping_charges, custinfo.cust_backorder AS accepts_backorders, custinfo.cust_partialship AS accepts_partial_shipments, custinfo.cust_ffshipto AS allow_free_form_shipto, custinfo.cust_ffbillto AS allow_free_form_billto, whsinfo.warehous_code AS preferred_selling_site, taxzone.taxzone_code AS default_tax_zone, terms.terms_code AS default_terms, CASE WHEN (custinfo.cust_balmethod = 'B'::bpchar) THEN 'Balance Forward'::text ELSE 'Open Item'::text END AS balance_method, custinfo.cust_discntprcnt AS default_discount, dc.curr_abbr AS default_currency, clc.curr_abbr AS credit_limit_currency, custinfo.cust_creditlmt AS credit_limit, CASE WHEN (COALESCE(custinfo.cust_gracedays, 0) > 0) THEN custinfo.cust_gracedays ELSE NULL::integer END AS alternate_grace_days, custinfo.cust_creditrating AS credit_rating, CASE WHEN (custinfo.cust_creditstatus = 'G'::bpchar) THEN 'In Good Standing'::text WHEN (custinfo.cust_creditstatus = 'W'::bpchar) THEN 'On Credit Warning'::text ELSE 'On Credit Hold'::text END AS credit_status, custinfo.cust_autoupdatestatus AS credit_status_exceed_warn, custinfo.cust_autoholdorders AS credit_status_exceed_hold, custinfo.cust_usespos AS uses_purchase_orders, custinfo.cust_blanketpos AS uses_blanket_pos, mc.cntct_number AS billing_contact_number, mc.cntct_honorific AS billing_contact_honorific, mc.cntct_first_name AS billing_contact_first, mc.cntct_middle AS billing_contact_middle, mc.cntct_last_name AS billing_contact_last, mc.cntct_suffix AS billing_contact_suffix, mc.cntct_title AS billing_contact_job_title, mc.cntct_phone AS billing_contact_voice, mc.cntct_phone2 AS billing_contact_alternate, mc.cntct_fax AS billing_contact_fax, mc.cntct_email AS billing_contact_email, mc.cntct_webaddr AS billing_contact_web, ''::text AS billing_contact_change, m.addr_number AS billing_contact_address_number, m.addr_line1 AS billing_contact_address1, m.addr_line2 AS billing_contact_address2, m.addr_line3 AS billing_contact_address3, m.addr_city AS billing_contact_city, m.addr_state AS billing_contact_state, m.addr_postalcode AS billing_contact_postalcode, m.addr_country AS billing_contact_country, ''::text AS billing_contact_address_change, cc.cntct_number AS correspond_contact_number, cc.cntct_honorific AS correspond_contact_honorific, cc.cntct_first_name AS correspond_contact_first, cc.cntct_middle AS correspond_contact_middle, cc.cntct_last_name AS correspond_contact_last, cc.cntct_suffix AS correspond_contact_suffix, cc.cntct_title AS correspond_contact_job_title, cc.cntct_phone AS correspond_contact_voice, cc.cntct_phone2 AS correspond_contact_alternate, cc.cntct_fax AS correspond_contact_fax, cc.cntct_email AS correspond_contact_email, cc.cntct_webaddr AS correspond_contact_web, ''::text AS correspond_contact_change, c.addr_number AS correspond_contact_address_number, c.addr_line1 AS correspond_contact_address1, c.addr_line2 AS correspond_contact_address2, c.addr_line3 AS correspond_contact_address3, c.addr_city AS correspond_contact_city, c.addr_state AS correspond_contact_state, c.addr_postalcode AS correspond_contact_postalcode, c.addr_country AS correspond_contact_country, ''::text AS correspond_contact_address_change, custinfo.cust_comments AS notes FROM ((((((((public.custinfo LEFT JOIN public.shipchrg ON ((custinfo.cust_shipchrg_id = shipchrg.shipchrg_id))) LEFT JOIN public.whsinfo ON ((custinfo.cust_preferred_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.cntct mc ON ((custinfo.cust_cntct_id = mc.cntct_id))) LEFT JOIN public.addr m ON ((mc.cntct_addr_id = m.addr_id))) LEFT JOIN public.cntct cc ON ((custinfo.cust_corrcntct_id = cc.cntct_id))) LEFT JOIN public.addr c ON ((cc.cntct_addr_id = c.addr_id))) LEFT JOIN public.taxzone ON ((custinfo.cust_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.shipform ON ((custinfo.cust_shipform_id = shipform.shipform_id))), public.custtype, public.salesrep, public.curr_symbol dc, public.curr_symbol clc, public.terms WHERE (((((custinfo.cust_custtype_id = custtype.custtype_id) AND (custinfo.cust_salesrep_id = salesrep.salesrep_id)) AND (custinfo.cust_curr_id = dc.curr_id)) AND (custinfo.cust_creditlmt_curr_id = clc.curr_id)) AND (custinfo.cust_terms_id = terms.terms_id)); DROP VIEW api.customer; apiadminfalse87876&00 VIEW customerCOMMENT(COMMENT ON VIEW customer IS 'Customer'; apiadminfalse829&00customerACLREVOKE ALL ON TABLE customer FROM PUBLIC; REVOKE ALL ON TABLE customer FROM admin; GRANT ALL ON TABLE customer TO admin; GRANT ALL ON TABLE customer TO xtrole; apiadminfalse829125979857taxauthTABLEICREATE TABLE taxauth ( taxauth_id integer NOT NULL, taxauth_code text NOT NULL, taxauth_name text, taxauth_extref text, taxauth_addr_id integer, taxauth_curr_id integer, taxauth_county text, taxauth_accnt_id integer, CONSTRAINT taxauth_taxauth_code_check CHECK ((taxauth_code <> ''::text)) ); DROP TABLE public.taxauth; publicadminfalse61918&00 TABLE taxauthCOMMENT8COMMENT ON TABLE taxauth IS 'The Tax Authority table.'; publicadminfalse239&00COLUMN taxauth.taxauth_curr_idCOMMENTCOMMENT ON COLUMN taxauth.taxauth_curr_id IS 'The required currency for recording tax information as. NULL means no preference.'; publicadminfalse239&00taxauthACLREVOKE ALL ON TABLE taxauth FROM PUBLIC; REVOKE ALL ON TABLE taxauth FROM admin; GRANT ALL ON TABLE taxauth TO admin; GRANT ALL ON TABLE taxauth TO xtrole; publicadminfalse239125979864taxregTABLECREATE TABLE taxreg ( taxreg_id integer NOT NULL, taxreg_rel_id integer NOT NULL, taxreg_rel_type character(1), taxreg_taxauth_id integer, taxreg_number text NOT NULL, taxreg_taxzone_id integer, taxreg_effective date DEFAULT startoftime(), taxreg_expires date DEFAULT endoftime(), taxreg_notes text DEFAULT ''::text, CONSTRAINT taxreg_taxreg_number_check CHECK ((taxreg_number <> ''::text)) ); DROP TABLE public.taxreg; publicadminfalse61926193619461968&00 TABLE taxregCOMMENTCOMMENT ON TABLE taxreg IS 'Stores Tax Registration numbers related to objects and a given tax authority. The rel_id specifies the object id and teh rel_type specifies the object type. See column comment for additional detail on types.'; publicadminfalse240&00COLUMN taxreg.taxreg_rel_typeCOMMENTCOMMENT ON COLUMN taxreg.taxreg_rel_type IS 'The type of relation this record is for. Known values are C=Customer, V=Vendor, NULL=This Manufacturer in which case taxreg_rel_id is meaningless and should be -1.'; publicadminfalse240&00taxregACLREVOKE ALL ON TABLE taxreg FROM PUBLIC; REVOKE ALL ON TABLE taxreg FROM admin; GRANT ALL ON TABLE taxreg TO admin; GRANT ALL ON TABLE taxreg TO xtrole; publicadminfalse240>125987866customertaxregVIEWCREATE VIEW customertaxreg AS SELECT (custinfo.cust_number)::character varying AS customer_number, (COALESCE(taxzone.taxzone_code, 'Any'::text))::character varying AS tax_zone, (taxauth.taxauth_code)::character varying AS tax_authority, taxreg.taxreg_number AS registration_number, CASE WHEN (taxreg.taxreg_effective = public.startoftime()) THEN 'Always'::text ELSE public.formatdate(taxreg.taxreg_effective) END AS start_date, CASE WHEN (taxreg.taxreg_expires = public.endoftime()) THEN 'Never'::text ELSE public.formatdate(taxreg.taxreg_expires) END AS end_date, taxreg.taxreg_notes AS notes FROM (((public.taxreg LEFT JOIN public.custinfo ON ((custinfo.cust_id = taxreg.taxreg_rel_id))) LEFT JOIN public.taxauth ON ((taxauth.taxauth_id = taxreg.taxreg_taxauth_id))) LEFT JOIN public.taxzone ON ((taxzone.taxzone_id = taxreg.taxreg_taxzone_id))) WHERE (taxreg.taxreg_rel_type = 'C'::bpchar) ORDER BY custinfo.cust_number, taxreg.taxreg_number; DROP VIEW api.customertaxreg; apiadminfalse87916&00VIEW customertaxregCOMMENT@COMMENT ON VIEW customertaxreg IS 'Customer Tax Registrations'; apiadminfalse830&00customertaxregACLREVOKE ALL ON TABLE customertaxreg FROM PUBLIC; REVOKE ALL ON TABLE customertaxreg FROM admin; GRANT ALL ON TABLE customertaxreg TO admin; GRANT ALL ON TABLE customertaxreg TO xtrole; apiadminfalse830?125987873 customertypeVIEWCREATE VIEW customertype AS SELECT (custtype.custtype_code)::character varying AS code, custtype.custtype_descrip AS description, custtype.custtype_char AS enable_characteristics_profile FROM public.custtype ORDER BY custtype.custtype_code; DROP VIEW api.customertype; apiadminfalse87936&00VIEW customertypeCOMMENT1COMMENT ON VIEW customertype IS 'Customer Type'; apiadminfalse831&00 customertypeACLREVOKE ALL ON TABLE customertype FROM PUBLIC; REVOKE ALL ON TABLE customertype FROM admin; GRANT ALL ON TABLE customertype TO admin; GRANT ALL ON TABLE customertype TO xtrole; apiadminfalse831@125987880customertypecharVIEWCREATE VIEW customertypechar AS SELECT (custtype.custtype_code)::character varying AS customer_type, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value, charass.charass_default AS is_default FROM public.custtype, public."char", public.charass WHERE ((('CT'::text = charass.charass_target_type) AND (custtype.custtype_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id)); DROP VIEW api.customertypechar; apiadminfalse87976&00VIEW customertypecharCOMMENTECOMMENT ON VIEW customertypechar IS 'Customer Type Characteristics'; apiadminfalse832&00customertypecharACLREVOKE ALL ON TABLE customertypechar FROM PUBLIC; REVOKE ALL ON TABLE customertypechar FROM admin; GRANT ALL ON TABLE customertypechar TO admin; GRANT ALL ON TABLE customertypechar TO xtrole; apiadminfalse832A125987887 custshiptoVIEWcCREATE VIEW custshipto AS SELECT (custinfo.cust_number)::character varying AS customer_number, (shiptoinfo.shipto_num)::character varying AS shipto_number, shiptoinfo.shipto_active AS active, shiptoinfo.shipto_name AS name, shiptoinfo.shipto_default AS default_flag, addr.addr_number AS address_number, addr.addr_line1 AS address1, addr.addr_line2 AS address2, addr.addr_line3 AS address3, addr.addr_city AS city, addr.addr_state AS state, addr.addr_postalcode AS postal_code, addr.addr_country AS country, ''::text AS address_change, cntct.cntct_number AS contact_number, cntct.cntct_honorific AS honorific, cntct.cntct_first_name AS first, cntct.cntct_middle AS middle, cntct.cntct_last_name AS last, cntct.cntct_suffix AS suffix, cntct.cntct_title AS job_title, cntct.cntct_phone AS phone, cntct.cntct_fax AS fax, cntct.cntct_email AS email, ''::text AS contact_change, salesrep.salesrep_number AS sales_rep, (shiptoinfo.shipto_commission * 100.0) AS commission, shipzone.shipzone_name AS zone, taxzone.taxzone_code AS tax_zone, shiptoinfo.shipto_shipvia AS ship_via, shipform.shipform_name AS ship_form, shipchrg.shipchrg_name AS shipping_charges, CASE WHEN (shiptoinfo.shipto_ediprofile_id = (-1)) THEN 'No EDI'::text WHEN (shiptoinfo.shipto_ediprofile_id = (-2)) THEN 'Use Customer Master'::text ELSE public.getediprofilename(shiptoinfo.shipto_ediprofile_id) END AS edi_profile, shiptoinfo.shipto_comments AS general_notes, shiptoinfo.shipto_shipcomments AS shipping_notes FROM public.custinfo, ((((((public.shiptoinfo LEFT JOIN public.shipchrg ON ((shiptoinfo.shipto_shipchrg_id = shipchrg.shipchrg_id))) LEFT JOIN public.cntct ON ((shiptoinfo.shipto_cntct_id = cntct.cntct_id))) LEFT JOIN public.addr ON ((shiptoinfo.shipto_addr_id = addr.addr_id))) LEFT JOIN public.taxzone ON ((shiptoinfo.shipto_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.shipzone ON ((shiptoinfo.shipto_shipzone_id = shipzone.shipzone_id))) LEFT JOIN public.salesrep ON ((shiptoinfo.shipto_salesrep_id = salesrep.salesrep_id))), public.shipform WHERE ((custinfo.cust_id = shiptoinfo.shipto_cust_id) AND (custinfo.cust_shipform_id = shipform.shipform_id)); DROP VIEW api.custshipto; apiadminfalse88016&00VIEW custshiptoCOMMENT9COMMENT ON VIEW custshipto IS 'Customer Shipto Address'; apiadminfalse833&00 custshiptoACLREVOKE ALL ON TABLE custshipto FROM PUBLIC; REVOKE ALL ON TABLE custshipto FROM admin; GRANT ALL ON TABLE custshipto TO admin; GRANT ALL ON TABLE custshipto TO xtrole; apiadminfalse833B125987897custtaxVIEWCREATE VIEW custtax AS SELECT (custinfo.cust_number)::character varying AS customer_number, (taxauth.taxauth_code)::character varying AS tax_authority, taxreg.taxreg_number AS registration_number FROM public.custinfo, public.taxauth, public.taxreg WHERE (((taxreg.taxreg_rel_type = 'C'::bpchar) AND (taxreg.taxreg_rel_id = custinfo.cust_id)) AND (taxreg.taxreg_taxauth_id = taxauth.taxauth_id)); DROP VIEW api.custtax; apiadminfalse88056&00 VIEW custtaxCOMMENT8COMMENT ON VIEW custtax IS 'Customer Tax Registration'; apiadminfalse834&00custtaxACLREVOKE ALL ON TABLE custtax FROM PUBLIC; REVOKE ALL ON TABLE custtax FROM admin; GRANT ALL ON TABLE custtax TO admin; GRANT ALL ON TABLE custtax TO xtrole; apiadminfalse834125979896deptTABLECREATE TABLE dept ( dept_id integer NOT NULL, dept_number text NOT NULL, dept_name text NOT NULL, CONSTRAINT dept_dept_number_check CHECK ((dept_number <> ''::text)) ); DROP TABLE public.dept; publicadminfalse61988&00 TABLE deptCOMMENT0COMMENT ON TABLE dept IS 'List of Departments'; publicadminfalse241&00deptACLREVOKE ALL ON TABLE dept FROM PUBLIC; REVOKE ALL ON TABLE dept FROM admin; GRANT ALL ON TABLE dept TO admin; GRANT ALL ON TABLE dept TO xtrole; publicadminfalse241125979903empTABLECREATE TABLE emp ( emp_id integer NOT NULL, emp_code text NOT NULL, emp_number text NOT NULL, emp_active boolean DEFAULT true NOT NULL, emp_cntct_id integer, emp_warehous_id integer, emp_mgr_emp_id integer, emp_wage_type text NOT NULL, emp_wage numeric, emp_wage_curr_id integer DEFAULT basecurrid(), emp_wage_period text NOT NULL, emp_dept_id integer, emp_shift_id integer, emp_notes text, emp_image_id integer, emp_username text, emp_extrate numeric, emp_extrate_period text NOT NULL, emp_startdate date DEFAULT ('now'::text)::date, emp_name text NOT NULL, CONSTRAINT emp_check CHECK (((((COALESCE(emp_wage_type, ''::text) = ''::text) OR (COALESCE(emp_wage_type, ''::text) = 'H'::text)) OR (COALESCE(emp_wage_type, ''::text) = 'S'::text)) AND ((COALESCE(emp_wage, (0)::numeric) = (0)::numeric) OR ((COALESCE(emp_wage_type, ''::text) <> ''::text) AND (emp_wage IS NOT NULL))))), CONSTRAINT emp_emp_code_check CHECK ((emp_code <> ''::text)), CONSTRAINT emp_emp_number_check CHECK ((emp_number <> ''::text)), CONSTRAINT emp_emp_wage_period_check CHECK ((((((((COALESCE(emp_wage_period, ''::text) = ''::text) OR (COALESCE(emp_wage_period, ''::text) = 'H'::text)) OR (COALESCE(emp_wage_period, ''::text) = 'D'::text)) OR (COALESCE(emp_wage_period, ''::text) = 'W'::text)) OR (COALESCE(emp_wage_period, ''::text) = 'BW'::text)) OR (COALESCE(emp_wage_period, ''::text) = 'M'::text)) OR (COALESCE(emp_wage_period, ''::text) = 'Y'::text))) ); DROP TABLE public.emp; publicadminfalse61996200620162036204620562068&00 TABLE empCOMMENT~COMMENT ON TABLE emp IS 'Employee table describing the basic properties of an employee. Employees need not be system users.'; publicadminfalse242&00COLUMN emp.emp_codeCOMMENTCOMMENT ON COLUMN emp.emp_code IS 'Short, human-readable name for employee. This value is kept synchronized with usr_username and salesrep_number, and so is unique across all three tables emp, usr, and salesrep.'; publicadminfalse242&00COLUMN emp.emp_numberCOMMENTCOMMENT ON COLUMN emp.emp_number IS 'Official employee number. This might be used for ID badges, payroll accounting, or other purposes.'; publicadminfalse242&00COLUMN emp.emp_mgr_emp_idCOMMENT_COMMENT ON COLUMN emp.emp_mgr_emp_id IS 'Internal ID of this employee''s manager/supervisor.'; publicadminfalse242&00COLUMN emp.emp_wage_typeCOMMENTCOMMENT ON COLUMN emp.emp_wage_type IS 'The nature of the wage or employment agreement. ''H'' indicates this employee is paid on an hourly basis (or some other period) while ''S'' indicates this employee is salaried.'; publicadminfalse242&00COLUMN emp.emp_wage_periodCOMMENTCOMMENT ON COLUMN emp.emp_wage_period IS 'The periodicity of wage payment: ''H'' for hourly, ''D'' for daily, ''W'' for weekly, ''BW'' for biweekly, ''M'' for monthly, ''Y'' for yearly.'; publicadminfalse242&00COLUMN emp.emp_usernameCOMMENTCOMMENT ON COLUMN emp.emp_username IS 'DEPRECATED - the relationship between Employee and User is now maintained through the crmacct table.'; publicadminfalse242&00COLUMN emp.emp_extrate_periodCOMMENTCOMMENT ON COLUMN emp.emp_extrate_period IS 'The periodicity of external rate payment: ''H'' for hourly, ''D'' for daily, ''W'' for weekly, ''BW'' for biweekly, ''M'' for monthly, ''Y'' for yearly.'; publicadminfalse242&00empACLREVOKE ALL ON TABLE emp FROM PUBLIC; REVOKE ALL ON TABLE emp FROM admin; GRANT ALL ON TABLE emp TO admin; GRANT ALL ON TABLE emp TO xtrole; publicadminfalse242125979916shiftTABLECREATE TABLE shift ( shift_id integer NOT NULL, shift_number text NOT NULL, shift_name text NOT NULL, CONSTRAINT shift_shift_number_check CHECK ((shift_number <> ''::text)) ); DROP TABLE public.shift; publicadminfalse62088&00 TABLE shiftCOMMENT1COMMENT ON TABLE shift IS 'List of work Shifts'; publicadminfalse243&00shiftACLREVOKE ALL ON TABLE shift FROM PUBLIC; REVOKE ALL ON TABLE shift FROM admin; GRANT ALL ON TABLE shift TO admin; GRANT ALL ON TABLE shift TO xtrole; publicadminfalse243C125987904employeeVIEWE CREATE VIEW employee AS SELECT (e.emp_code)::character varying AS code, (e.emp_number)::character varying AS number, e.emp_active AS active, e.emp_startdate AS start_date, cntct.cntct_number AS contact_number, cntct.cntct_honorific AS honorific, cntct.cntct_first_name AS first, cntct.cntct_middle AS middle, cntct.cntct_last_name AS last, cntct.cntct_suffix AS suffix, cntct.cntct_title AS job_title, cntct.cntct_phone AS voice, cntct.cntct_phone2 AS alternate, cntct.cntct_fax AS fax, cntct.cntct_email AS email, cntct.cntct_webaddr AS web, ''::text AS contact_change, addr.addr_number AS address_number, addr.addr_line1 AS address1, addr.addr_line2 AS address2, addr.addr_line3 AS address3, addr.addr_city AS city, addr.addr_state AS state, addr.addr_postalcode AS postalcode, addr.addr_country AS country, ''::text AS address_change, whsinfo.warehous_code AS site, m.emp_code AS manager_code, CASE WHEN (e.emp_wage_type = 'H'::text) THEN 'Hourly'::text WHEN (e.emp_wage_type = 'S'::text) THEN 'Salaried'::text WHEN (e.emp_wage_type IS NULL) THEN NULL::text ELSE 'Error'::text END AS wage_type, e.emp_wage AS wage, curr_symbol.curr_abbr AS wage_currency, CASE WHEN (e.emp_wage_period = 'H'::text) THEN 'Hour'::text WHEN (e.emp_wage_period = 'D'::text) THEN 'Day'::text WHEN (e.emp_wage_period = 'W'::text) THEN 'Week'::text WHEN (e.emp_wage_period = 'BW'::text) THEN 'Biweek'::text WHEN (e.emp_wage_period = 'M'::text) THEN 'Month'::text WHEN (e.emp_wage_period = 'Y'::text) THEN 'Year'::text WHEN (e.emp_wage_period IS NULL) THEN NULL::text ELSE 'Error'::text END AS wage_period, dept.dept_number AS department, shift.shift_number AS shift, (crmacct.crmacct_usr_username IS NOT NULL) AS is_user, (salesrep.salesrep_id IS NOT NULL) AS is_salesrep, (vendinfo.vend_id IS NOT NULL) AS is_vendor, e.emp_notes AS notes, image.image_name AS image, e.emp_extrate AS rate, curr_symbol.curr_abbr AS billing_currency, CASE WHEN (e.emp_extrate_period = 'H'::text) THEN 'Hour'::text WHEN (e.emp_extrate_period = 'D'::text) THEN 'Day'::text WHEN (e.emp_extrate_period = 'W'::text) THEN 'Week'::text WHEN (e.emp_extrate_period = 'BW'::text) THEN 'Biweek'::text WHEN (e.emp_extrate_period = 'M'::text) THEN 'Month'::text WHEN (e.emp_extrate_period = 'Y'::text) THEN 'Year'::text WHEN (e.emp_extrate_period IS NULL) THEN NULL::text ELSE 'Error'::text END AS billing_period FROM (((((((((((public.emp e JOIN public.crmacct ON ((e.emp_id = crmacct.crmacct_emp_id))) LEFT JOIN public.cntct ON ((e.emp_cntct_id = cntct.cntct_id))) LEFT JOIN public.addr ON ((cntct.cntct_addr_id = addr.addr_id))) LEFT JOIN public.whsinfo ON ((e.emp_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.emp m ON ((e.emp_mgr_emp_id = m.emp_id))) LEFT JOIN public.dept ON ((e.emp_dept_id = dept.dept_id))) LEFT JOIN public.shift ON ((e.emp_shift_id = shift.shift_id))) LEFT JOIN public.salesrep ON ((crmacct.crmacct_salesrep_id = salesrep.salesrep_id))) LEFT JOIN public.vendinfo ON ((crmacct.crmacct_vend_id = vendinfo.vend_id))) LEFT JOIN public.image ON ((e.emp_image_id = image.image_id))) LEFT JOIN public.curr_symbol ON ((e.emp_wage_curr_id = curr_symbol.curr_id))); DROP VIEW api.employee; apiadminfalse88096&00 VIEW employeeCOMMENT(COMMENT ON VIEW employee IS 'Employee'; apiadminfalse835&00employeeACLREVOKE ALL ON TABLE employee FROM PUBLIC; REVOKE ALL ON TABLE employee FROM admin; GRANT ALL ON TABLE employee TO admin; GRANT ALL ON TABLE employee TO xtrole; apiadminfalse835D125987914 employeecharVIEWuCREATE VIEW employeechar AS SELECT (emp.emp_code)::character varying AS employee_code, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value FROM public.emp, public."char", public.charass WHERE ((('EMP'::text = charass.charass_target_type) AND (emp.emp_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id)); DROP VIEW api.employeechar; apiadminfalse88136&00VIEW employeecharCOMMENT<COMMENT ON VIEW employeechar IS 'Employee Characteristics'; apiadminfalse836&00 employeecharACLREVOKE ALL ON TABLE employeechar FROM PUBLIC; REVOKE ALL ON TABLE employeechar FROM admin; GRANT ALL ON TABLE employeechar TO admin; GRANT ALL ON TABLE employeechar TO xtrole; apiadminfalse836E125987921employeecommentVIEWCREATE VIEW employeecomment AS SELECT (emp.emp_code)::character varying AS code, (cmnttype.cmnttype_name)::character varying AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.emp, public.cmnttype, public.comment WHERE (((comment.comment_source = 'EMP'::text) AND (comment.comment_source_id = emp.emp_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); DROP VIEW api.employeecomment; apiadminfalse88176&00VIEW employeecommentCOMMENT7COMMENT ON VIEW employeecomment IS 'Employee Comment'; apiadminfalse837&00employeecommentACLREVOKE ALL ON TABLE employeecomment FROM PUBLIC; REVOKE ALL ON TABLE employeecomment FROM admin; GRANT ALL ON TABLE employeecomment TO admin; GRANT ALL ON TABLE employeecomment TO xtrole; apiadminfalse837125979936shipdataTABLECREATE TABLE shipdata ( shipdata_cohead_number text NOT NULL, shipdata_cosmisc_tracknum text NOT NULL, shipdata_cosmisc_packnum_tracknum text NOT NULL, shipdata_weight numeric(16,4), shipdata_base_freight numeric(16,4), shipdata_total_freight numeric(16,4), shipdata_shipper text DEFAULT 'UPS'::text, shipdata_billing_option text, shipdata_package_type text, shipdata_void_ind character(1) NOT NULL, shipdata_lastupdated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL, shipdata_shiphead_number text, shipdata_base_freight_curr_id integer DEFAULT basecurrid(), shipdata_total_freight_curr_id integer DEFAULT basecurrid() ); DROP TABLE public.shipdata; publicadminfalse62096210621162128&00TABLE shipdataCOMMENTCOMMENT ON TABLE shipdata IS 'Shipping Interface information - note that the shipdata_cohead_nember is text and not int. That is due to ODBC chopping off during the transfer'; publicadminfalse244&00shipdataACLREVOKE ALL ON TABLE shipdata FROM PUBLIC; REVOKE ALL ON TABLE shipdata FROM admin; GRANT ALL ON TABLE shipdata TO admin; GRANT ALL ON TABLE shipdata TO xtrole; publicadminfalse244F125987928 extshipmaintVIEW&CREATE VIEW extshipmaint AS SELECT (shipdata.shipdata_cohead_number)::character varying AS so_number, (shipdata.shipdata_shiphead_number)::character varying AS shipment_number, (shipdata.shipdata_shipper)::character varying AS shipper, (shipdata.shipdata_cosmisc_packnum_tracknum)::character varying AS package_tracking_number, shipdata.shipdata_void_ind AS void, shipdata.shipdata_billing_option AS billing_option, shipdata.shipdata_weight AS weight, shipdata.shipdata_base_freight AS base_freight, base.curr_abbr AS base_freight_currency, shipdata.shipdata_total_freight AS total_freight, total.curr_abbr AS total_freight_currency, shipdata.shipdata_package_type AS package_type, shipdata.shipdata_cosmisc_tracknum AS tracking_number, shipdata.shipdata_lastupdated AS last_updated FROM public.shipdata, public.curr_symbol base, public.curr_symbol total WHERE ((shipdata.shipdata_base_freight_curr_id = base.curr_id) AND (shipdata.shipdata_total_freight_curr_id = total.curr_id)) ORDER BY shipdata.shipdata_cohead_number, shipdata.shipdata_shiphead_number; DROP VIEW api.extshipmaint; apiadminfalse88216&00VIEW extshipmaintCOMMENTACOMMENT ON VIEW extshipmaint IS 'External Shipping Maintenance'; apiadminfalse838&00 extshipmaintACLREVOKE ALL ON TABLE extshipmaint FROM PUBLIC; REVOKE ALL ON TABLE extshipmaint FROM admin; GRANT ALL ON TABLE extshipmaint TO admin; GRANT ALL ON TABLE extshipmaint TO xtrole; apiadminfalse838125979950 freightclassTABLECREATE TABLE freightclass ( freightclass_id integer NOT NULL, freightclass_code text NOT NULL, freightclass_descrip text, CONSTRAINT freightclass_freightclass_code_check CHECK ((freightclass_code <> ''::text)) ); DROP TABLE public.freightclass; publicadminfalse62148&00TABLE freightclassCOMMENTOCOMMENT ON TABLE freightclass IS 'This table is the freight price schedules.'; publicadminfalse245&00 freightclassACLREVOKE ALL ON TABLE freightclass FROM PUBLIC; REVOKE ALL ON TABLE freightclass FROM admin; GRANT ALL ON TABLE freightclass TO admin; GRANT ALL ON TABLE freightclass TO xtrole; publicadminfalse245125979957 ipsfreightTABLECREATE TABLE ipsfreight ( ipsfreight_id integer NOT NULL, ipsfreight_ipshead_id integer NOT NULL, ipsfreight_qtybreak numeric DEFAULT 0 NOT NULL, ipsfreight_price numeric DEFAULT 0 NOT NULL, ipsfreight_type character(1) NOT NULL, ipsfreight_warehous_id integer, ipsfreight_shipzone_id integer, ipsfreight_freightclass_id integer, ipsfreight_shipvia text ); DROP TABLE public.ipsfreight; publicadminfalse621662178&00 ipsfreightACLREVOKE ALL ON TABLE ipsfreight FROM PUBLIC; REVOKE ALL ON TABLE ipsfreight FROM admin; GRANT ALL ON TABLE ipsfreight TO admin; GRANT ALL ON TABLE ipsfreight TO xtrole; publicadminfalse246125979965ipsheadTABLECREATE TABLE ipshead ( ipshead_id integer DEFAULT nextval(('"ipshead_ipshead_id_seq"'::text)::regclass) NOT NULL, ipshead_name text NOT NULL, ipshead_descrip text, ipshead_effective date, ipshead_expires date, ipshead_curr_id integer DEFAULT basecurrid() NOT NULL, ipshead_updated date, CONSTRAINT ipshead_ipshead_name_check CHECK ((ipshead_name <> ''::text)) ); DROP TABLE public.ipshead; publicadminfalse6218621962208&00 TABLE ipsheadCOMMENTCCOMMENT ON TABLE ipshead IS 'Pricing Schedule header information'; publicadminfalse247&00ipsheadACLREVOKE ALL ON TABLE ipshead FROM PUBLIC; REVOKE ALL ON TABLE ipshead FROM admin; GRANT ALL ON TABLE ipshead TO admin; GRANT ALL ON TABLE ipshead TO xtrole; publicadminfalse247G125987935freightpricingscheduleitemVIEW;CREATE VIEW freightpricingscheduleitem AS SELECT (ipshead.ipshead_name)::character varying AS pricing_schedule, ipsfreight.ipsfreight_qtybreak AS qty_break, (qtyuom.uom_name)::character varying AS qty_uom, ipsfreight.ipsfreight_price AS price, CASE WHEN (ipsfreight.ipsfreight_type = 'F'::bpchar) THEN 'Flat Rate'::text ELSE 'Price Per UOM'::text END AS price_type, COALESCE(whsinfo.warehous_code, 'Any'::text) AS from_site, COALESCE(shipzone.shipzone_name, 'Any'::text) AS to_shipzone, COALESCE(ipsfreight.ipsfreight_shipvia, 'Any'::text) AS ship_via, COALESCE(freightclass.freightclass_code, 'Any'::text) AS freight_class FROM (((((public.ipsfreight JOIN public.ipshead ON ((ipsfreight.ipsfreight_ipshead_id = ipshead.ipshead_id))) LEFT JOIN public.uom qtyuom ON (qtyuom.uom_item_weight)) LEFT JOIN public.whsinfo ON ((whsinfo.warehous_id = ipsfreight.ipsfreight_warehous_id))) LEFT JOIN public.shipzone ON ((shipzone.shipzone_id = ipsfreight.ipsfreight_shipzone_id))) LEFT JOIN public.freightclass ON ((freightclass.freightclass_id = ipsfreight.ipsfreight_freightclass_id))); *DROP VIEW api.freightpricingscheduleitem; apiadminfalse88256&00VIEW freightpricingscheduleitemCOMMENTOCOMMENT ON VIEW freightpricingscheduleitem IS 'Freight Pricing Schedule Item'; apiadminfalse839&00freightpricingscheduleitemACLREVOKE ALL ON TABLE freightpricingscheduleitem FROM PUBLIC; REVOKE ALL ON TABLE freightpricingscheduleitem FROM admin; GRANT ALL ON TABLE freightpricingscheduleitem TO admin; GRANT ALL ON TABLE freightpricingscheduleitem TO xtrole; apiadminfalse839H125987945 glaccountVIEWCREATE VIEW glaccount AS SELECT (accnt.accnt_company)::character varying AS company, (accnt.accnt_profit)::character varying AS profit_center, (accnt.accnt_number)::character varying AS account_number, (accnt.accnt_sub)::character varying AS sub_account, accnt.accnt_descrip AS description, accnt.accnt_extref AS ext_reference, CASE WHEN (accnt.accnt_type = 'A'::bpchar) THEN 'Asset'::text WHEN (accnt.accnt_type = 'L'::bpchar) THEN 'Liability'::text WHEN (accnt.accnt_type = 'E'::bpchar) THEN 'Expense'::text WHEN (accnt.accnt_type = 'R'::bpchar) THEN 'Revenue'::text WHEN (accnt.accnt_type = 'Q'::bpchar) THEN 'Equity'::text ELSE '?'::text END AS type, accnt.accnt_subaccnttype_code AS sub_type, accnt.accnt_forwardupdate AS forward_update_trial_balances, accnt.accnt_comments AS notes FROM public.accnt ORDER BY accnt.accnt_company, accnt.accnt_profit, accnt.accnt_number, accnt.accnt_sub; DROP VIEW api.glaccount; apiadminfalse88296&00VIEW glaccountCOMMENT+COMMENT ON VIEW glaccount IS 'GL Account'; apiadminfalse840'00 glaccountACLREVOKE ALL ON TABLE glaccount FROM PUBLIC; REVOKE ALL ON TABLE glaccount FROM admin; GRANT ALL ON TABLE glaccount TO admin; GRANT ALL ON TABLE glaccount TO xtrole; apiadminfalse840125979984incdtcatTABLE CREATE TABLE incdtcat ( incdtcat_id integer NOT NULL, incdtcat_name text NOT NULL, incdtcat_order integer, incdtcat_descrip text, incdtcat_ediprofile_id integer, CONSTRAINT incdtcat_incdtcat_name_check CHECK ((incdtcat_name <> ''::text)) ); DROP TABLE public.incdtcat; publicadminfalse62228'00TABLE incdtcatCOMMENT8COMMENT ON TABLE incdtcat IS 'Incident Category table'; publicadminfalse248'00incdtcatACLREVOKE ALL ON TABLE incdtcat FROM PUBLIC; REVOKE ALL ON TABLE incdtcat FROM admin; GRANT ALL ON TABLE incdtcat TO admin; GRANT ALL ON TABLE incdtcat TO xtrole; publicadminfalse248125979991 incdtpriorityTABLE CREATE TABLE incdtpriority ( incdtpriority_id integer NOT NULL, incdtpriority_name text NOT NULL, incdtpriority_order integer, incdtpriority_descrip text, CONSTRAINT incdtpriority_incdtpriority_name_check CHECK ((incdtpriority_name <> ''::text)) ); !DROP TABLE public.incdtpriority; publicadminfalse62248'00TABLE incdtpriorityCOMMENT=COMMENT ON TABLE incdtpriority IS 'Incident Priority table'; publicadminfalse249'00 incdtpriorityACLREVOKE ALL ON TABLE incdtpriority FROM PUBLIC; REVOKE ALL ON TABLE incdtpriority FROM admin; GRANT ALL ON TABLE incdtpriority TO admin; GRANT ALL ON TABLE incdtpriority TO xtrole; publicadminfalse249125979998incdtresolutionTABLECREATE TABLE incdtresolution ( incdtresolution_id integer NOT NULL, incdtresolution_name text NOT NULL, incdtresolution_order integer, incdtresolution_descrip text, CONSTRAINT incdtresolution_incdtresolution_name_check CHECK ((incdtresolution_name <> ''::text)) ); #DROP TABLE public.incdtresolution; publicadminfalse62268'00TABLE incdtresolutionCOMMENTACOMMENT ON TABLE incdtresolution IS 'Incident Resolution table'; publicadminfalse250'00incdtresolutionACLREVOKE ALL ON TABLE incdtresolution FROM PUBLIC; REVOKE ALL ON TABLE incdtresolution FROM admin; GRANT ALL ON TABLE incdtresolution TO admin; GRANT ALL ON TABLE incdtresolution TO xtrole; publicadminfalse250125980005 incdtseverityTABLE CREATE TABLE incdtseverity ( incdtseverity_id integer NOT NULL, incdtseverity_name text NOT NULL, incdtseverity_order integer, incdtseverity_descrip text, CONSTRAINT incdtseverity_incdtseverity_name_check CHECK ((incdtseverity_name <> ''::text)) ); !DROP TABLE public.incdtseverity; publicadminfalse62288'00TABLE incdtseverityCOMMENT=COMMENT ON TABLE incdtseverity IS 'Incident Severity table'; publicadminfalse251'00 incdtseverityACLREVOKE ALL ON TABLE incdtseverity FROM PUBLIC; REVOKE ALL ON TABLE incdtseverity FROM admin; GRANT ALL ON TABLE incdtseverity TO admin; GRANT ALL ON TABLE incdtseverity TO xtrole; publicadminfalse251I125987954incidentVIEWCREATE VIEW incident AS SELECT incdt.incdt_number AS incident_number, incdtcat.incdtcat_name AS category, incdt.incdt_summary AS description, crmacct.crmacct_number AS crm_account, incdt.incdt_assigned_username AS assigned_to, CASE WHEN (incdt.incdt_status = 'N'::bpchar) THEN 'New'::text WHEN (incdt.incdt_status = 'F'::bpchar) THEN 'Feedback'::text WHEN (incdt.incdt_status = 'C'::bpchar) THEN 'Confirmed'::text WHEN (incdt.incdt_status = 'A'::bpchar) THEN 'Assigned'::text WHEN (incdt.incdt_status = 'R'::bpchar) THEN 'Resolved'::text WHEN (incdt.incdt_status = 'L'::bpchar) THEN 'Closed'::text ELSE '?'::text END AS status, incdtseverity.incdtseverity_name AS severity, incdtpriority.incdtpriority_name AS priority, incdtresolution.incdtresolution_name AS resolution, cntct.cntct_number AS contact_number, cntct.cntct_honorific AS honorific, cntct.cntct_first_name AS first, cntct.cntct_middle AS middle, cntct.cntct_last_name AS last, cntct.cntct_suffix AS suffix, cntct.cntct_title AS job_title, cntct.cntct_phone AS phone, cntct.cntct_fax AS fax, cntct.cntct_email AS email, ''::text AS contact_change, incdt.incdt_descrip AS notes, item.item_number, incdt.incdt_lotserial AS lot_serial_number, CASE WHEN (aropen.aropen_doctype = 'C'::bpchar) THEN 'C/M'::text WHEN (aropen.aropen_doctype = 'D'::bpchar) THEN 'D/M'::text WHEN (aropen.aropen_doctype = 'I'::bpchar) THEN 'Invoice'::text WHEN (aropen.aropen_doctype = 'R'::bpchar) THEN 'C/D'::text ELSE ''::text END AS ar_doc_type, aropen.aropen_docnumber AS ar_doc_number FROM ((((((((public.incdt LEFT JOIN public.incdtcat ON ((incdtcat.incdtcat_id = incdt.incdt_incdtcat_id))) LEFT JOIN public.crmacct ON ((crmacct.crmacct_id = incdt.incdt_crmacct_id))) LEFT JOIN public.incdtseverity ON ((incdtseverity.incdtseverity_id = incdt.incdt_incdtseverity_id))) LEFT JOIN public.incdtpriority ON ((incdtpriority.incdtpriority_id = incdt.incdt_incdtpriority_id))) LEFT JOIN public.incdtresolution ON ((incdtresolution.incdtresolution_id = incdt.incdt_incdtresolution_id))) LEFT JOIN public.cntct ON ((cntct.cntct_id = incdt.incdt_cntct_id))) LEFT JOIN public.item ON ((item.item_id = incdt.incdt_item_id))) LEFT JOIN public.aropen ON ((aropen.aropen_id = incdt.incdt_aropen_id))); DROP VIEW api.incident; apiadminfalse88326 '00 VIEW incidentCOMMENT(COMMENT ON VIEW incident IS 'Incident'; apiadminfalse841 '00incidentACLREVOKE ALL ON TABLE incident FROM PUBLIC; REVOKE ALL ON TABLE incident FROM admin; GRANT ALL ON TABLE incident TO admin; GRANT ALL ON TABLE incident TO xtrole; apiadminfalse841J125987964 incidentcharVIEWpCREATE VIEW incidentchar AS SELECT incdt.incdt_number AS incident_number, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value FROM public.incdt, public."char", public.charass WHERE ((('INCDT'::text = charass.charass_target_type) AND (incdt.incdt_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id)); DROP VIEW api.incidentchar; apiadminfalse88366 '00VIEW incidentcharCOMMENT<COMMENT ON VIEW incidentchar IS 'Incident Characteristics'; apiadminfalse842 '00 incidentcharACLREVOKE ALL ON TABLE incidentchar FROM PUBLIC; REVOKE ALL ON TABLE incidentchar FROM admin; GRANT ALL ON TABLE incidentchar TO admin; GRANT ALL ON TABLE incidentchar TO xtrole; apiadminfalse842K125987971incidentcommentVIEWCREATE VIEW incidentcomment AS SELECT incdt.incdt_number AS incident_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text, comment.comment_public AS public FROM public.incdt, public.cmnttype, public.comment WHERE (((comment.comment_source = 'INCDT'::text) AND (comment.comment_source_id = incdt.incdt_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); DROP VIEW api.incidentcomment; apiadminfalse88406 '00VIEW incidentcommentCOMMENT7COMMENT ON VIEW incidentcomment IS 'Incident Comment'; apiadminfalse843'00incidentcommentACLREVOKE ALL ON TABLE incidentcomment FROM PUBLIC; REVOKE ALL ON TABLE incidentcomment FROM admin; GRANT ALL ON TABLE incidentcomment TO admin; GRANT ALL ON TABLE incidentcomment TO xtrole; apiadminfalse843L125987978 incidentfileVIEWCREATE VIEW incidentfile AS SELECT incdt.incdt_number AS incident_number, url.url_title AS title, url.url_url AS url FROM public.incdt, public.url WHERE ((incdt.incdt_id = url.url_source_id) AND (url.url_source = 'INCDT'::text)); DROP VIEW api.incidentfile; apiadminfalse88446'00VIEW incidentfileCOMMENT1COMMENT ON VIEW incidentfile IS 'Incident File'; apiadminfalse844'00 incidentfileACLREVOKE ALL ON TABLE incidentfile FROM PUBLIC; REVOKE ALL ON TABLE incidentfile FROM admin; GRANT ALL ON TABLE incidentfile TO admin; GRANT ALL ON TABLE incidentfile TO xtrole; apiadminfalse844M125987985 incidentimageVIEW,CREATE VIEW incidentimage AS SELECT incdt.incdt_number AS incident_number, image.image_name FROM public.incdt, public.imageass, public.image WHERE (((incdt.incdt_id = imageass.imageass_source_id) AND (imageass.imageass_source = 'INCDT'::text)) AND (imageass.imageass_image_id = image.image_id)); DROP VIEW api.incidentimage; apiadminfalse88486'00VIEW incidentimageCOMMENT3COMMENT ON VIEW incidentimage IS 'Incident Image'; apiadminfalse845'00 incidentimageACLREVOKE ALL ON TABLE incidentimage FROM PUBLIC; REVOKE ALL ON TABLE incidentimage FROM admin; GRANT ALL ON TABLE incidentimage TO admin; GRANT ALL ON TABLE incidentimage TO xtrole; apiadminfalse845125980033 classcodeTABLECREATE TABLE classcode ( classcode_id integer DEFAULT nextval(('classcode_classcode_id_seq'::text)::regclass) NOT NULL, classcode_code text NOT NULL, classcode_descrip text, classcode_mfg boolean, classcode_creator text, classcode_created timestamp without time zone, classcode_modifier text, classcode_modified timestamp without time zone, classcode_type text, CONSTRAINT classcode_classcode_code_check CHECK ((classcode_code <> ''::text)) ); DROP TABLE public.classcode; publicadminfalse622962308'00TABLE classcodeCOMMENT8COMMENT ON TABLE classcode IS 'Class Code information'; publicadminfalse252'00 classcodeACLREVOKE ALL ON TABLE classcode FROM PUBLIC; REVOKE ALL ON TABLE classcode FROM admin; GRANT ALL ON TABLE classcode TO admin; GRANT ALL ON TABLE classcode TO xtrole; publicadminfalse252125980041prodcatTABLECREATE TABLE prodcat ( prodcat_id integer DEFAULT nextval(('prodcat_prodcat_id_seq'::text)::regclass) NOT NULL, prodcat_code text NOT NULL, prodcat_descrip text, CONSTRAINT prodcat_prodcat_code_check CHECK ((prodcat_code <> ''::text)) ); DROP TABLE public.prodcat; publicadminfalse623162328'00 TABLE prodcatCOMMENT<COMMENT ON TABLE prodcat IS 'Product Category information'; publicadminfalse253'00prodcatACLREVOKE ALL ON TABLE prodcat FROM PUBLIC; REVOKE ALL ON TABLE prodcat FROM admin; GRANT ALL ON TABLE prodcat TO admin; GRANT ALL ON TABLE prodcat TO xtrole; publicadminfalse253P125988013itemVIEWxCREATE VIEW item AS SELECT (item.item_number)::character varying AS item_number, item.item_active AS active, item.item_descrip1 AS description1, item.item_descrip2 AS description2, CASE WHEN (item.item_type = 'P'::bpchar) THEN 'Purchased'::text WHEN (item.item_type = 'M'::bpchar) THEN 'Manufactured'::text WHEN (item.item_type = 'J'::bpchar) THEN 'Job'::text WHEN (item.item_type = 'K'::bpchar) THEN 'Kit'::text WHEN (item.item_type = 'F'::bpchar) THEN 'Phantom'::text WHEN (item.item_type = 'R'::bpchar) THEN 'Reference'::text WHEN (item.item_type = 'S'::bpchar) THEN 'Costing'::text WHEN (item.item_type = 'T'::bpchar) THEN 'Tooling'::text WHEN (item.item_type = 'O'::bpchar) THEN 'Outside Process'::text WHEN (item.item_type = 'L'::bpchar) THEN 'Planning'::text WHEN (item.item_type = 'B'::bpchar) THEN 'Breeder'::text WHEN (item.item_type = 'C'::bpchar) THEN 'Co-Product'::text WHEN (item.item_type = 'Y'::bpchar) THEN 'By-Product'::text ELSE NULL::text END AS item_type, item.item_maxcost AS maximum_desired_cost, classcode.classcode_code AS class_code, i.uom_name AS inventory_uom, item.item_picklist AS pick_list_item, item.item_fractional AS fractional, item.item_config AS configured, item.item_sold AS item_is_sold, prodcat.prodcat_code AS product_category, item.item_exclusive AS exclusive, item.item_listprice AS list_price, item.item_listcost AS list_cost, p.uom_name AS list_price_uom, item.item_upccode AS upc_code, item.item_prodweight AS product_weight, item.item_packweight AS packaging_weight, item.item_comments AS notes, item.item_extdescrip AS ext_description FROM (public.item LEFT JOIN public.prodcat ON ((item.item_prodcat_id = prodcat.prodcat_id))), public.classcode, public.uom i, public.uom p WHERE (((item.item_classcode_id = classcode.classcode_id) AND (item.item_inv_uom_id = i.uom_id)) AND (item.item_price_uom_id = p.uom_id)) ORDER BY (item.item_number)::character varying; DROP VIEW api.item; apiadminfalse88606'00 VIEW itemCOMMENT COMMENT ON VIEW item IS 'Item'; apiadminfalse848'00itemACLREVOKE ALL ON TABLE item FROM PUBLIC; REVOKE ALL ON TABLE item FROM admin; GRANT ALL ON TABLE item TO admin; GRANT ALL ON TABLE item TO xtrole; apiadminfalse848125980054 itemaliasTABLECREATE TABLE itemalias ( itemalias_id integer DEFAULT nextval(('"itemalias_itemalias_id_seq"'::text)::regclass) NOT NULL, itemalias_item_id integer NOT NULL, itemalias_number text NOT NULL, itemalias_comments text, itemalias_usedescrip boolean NOT NULL, itemalias_descrip1 text, itemalias_descrip2 text, itemalias_crmacct_id integer, CONSTRAINT itemalias_itemalias_number_check CHECK ((itemalias_number <> ''::text)) ); DROP TABLE public.itemalias; publicadminfalse623362348'00TABLE itemaliasCOMMENT8COMMENT ON TABLE itemalias IS 'Item Alias information'; publicadminfalse254'00%COLUMN itemalias.itemalias_crmacct_idCOMMENTZCOMMENT ON COLUMN itemalias.itemalias_crmacct_id IS 'Associated crmacct for item alias.'; publicadminfalse254'00 itemaliasACLREVOKE ALL ON TABLE itemalias FROM PUBLIC; REVOKE ALL ON TABLE itemalias FROM admin; GRANT ALL ON TABLE itemalias TO admin; GRANT ALL ON TABLE itemalias TO xtrole; publicadminfalse254Q125988023 itemaliasVIEW.CREATE VIEW itemalias AS SELECT (item.item_number)::character varying AS item_number, itemalias.itemalias_number AS alias_number, COALESCE(crmacct.crmacct_number, ''::text) AS crmacct_number, itemalias.itemalias_usedescrip AS use_description, itemalias.itemalias_descrip1 AS description1, itemalias.itemalias_descrip2 AS description2, itemalias.itemalias_comments AS comments FROM ((public.item JOIN public.itemalias ON ((item.item_id = itemalias.itemalias_item_id))) LEFT JOIN public.crmacct ON ((crmacct.crmacct_id = itemalias.itemalias_crmacct_id))); DROP VIEW api.itemalias; apiadminfalse88646'00VIEW itemaliasCOMMENT+COMMENT ON VIEW itemalias IS 'Item Alias'; apiadminfalse849'00 itemaliasACLREVOKE ALL ON TABLE itemalias FROM PUBLIC; REVOKE ALL ON TABLE itemalias FROM admin; GRANT ALL ON TABLE itemalias TO admin; GRANT ALL ON TABLE itemalias TO xtrole; apiadminfalse849R125988031itemcharVIEWCREATE VIEW itemchar AS SELECT (item.item_number)::character varying AS item_number, ("char".char_name)::character varying AS characteristic, charass.charass_value AS value, charass.charass_default AS is_default FROM public.item, public."char", public.charass WHERE ((('I'::text = charass.charass_target_type) AND (item.item_id = charass.charass_target_id)) AND (charass.charass_char_id = "char".char_id)); DROP VIEW api.itemchar; apiadminfalse88686'00 VIEW itemcharCOMMENT3COMMENT ON VIEW itemchar IS 'Item Characteristic'; apiadminfalse850'00itemcharACLREVOKE ALL ON TABLE itemchar FROM PUBLIC; REVOKE ALL ON TABLE itemchar FROM admin; GRANT ALL ON TABLE itemchar TO admin; GRANT ALL ON TABLE itemchar TO xtrole; apiadminfalse850S125988038 itemcommentVIEWCREATE VIEW itemcomment AS SELECT (item.item_number)::character varying AS item_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.item, public.cmnttype, public.comment WHERE (((comment.comment_source = 'I'::text) AND (comment.comment_source_id = item.item_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); DROP VIEW api.itemcomment; apiadminfalse88726 '00VIEW itemcommentCOMMENT0COMMENT ON VIEW itemcomment IS 'Item Comments'; apiadminfalse851!'00 itemcommentACLREVOKE ALL ON TABLE itemcomment FROM PUBLIC; REVOKE ALL ON TABLE itemcomment FROM admin; GRANT ALL ON TABLE itemcomment TO admin; GRANT ALL ON TABLE itemcomment TO xtrole; apiadminfalse851125980074costelemTABLECREATE TABLE costelem ( costelem_id integer DEFAULT nextval(('costelem_costelem_id_seq'::text)::regclass) NOT NULL, costelem_type text NOT NULL, costelem_sys boolean, costelem_po boolean, costelem_active boolean, costelem_exp_accnt_id integer, costelem_cost_item_id integer, CONSTRAINT costelem_costelem_type_check CHECK ((costelem_type <> ''::text)) ); DROP TABLE public.costelem; publicadminfalse623562368"'00TABLE costelemCOMMENT<COMMENT ON TABLE costelem IS 'Costing Element information'; publicadminfalse255#'00costelemACLREVOKE ALL ON TABLE costelem FROM PUBLIC; REVOKE ALL ON TABLE costelem FROM admin; GRANT ALL ON TABLE costelem TO admin; GRANT ALL ON TABLE costelem TO xtrole; publicadminfalse255125980082itemcostTABLECREATE TABLE itemcost ( itemcost_id integer DEFAULT nextval(('itemcost_itemcost_id_seq'::text)::regclass) NOT NULL, itemcost_item_id integer NOT NULL, itemcost_costelem_id integer NOT NULL, itemcost_lowlevel boolean DEFAULT false NOT NULL, itemcost_stdcost numeric(16,6) DEFAULT 0 NOT NULL, itemcost_posted date, itemcost_actcost numeric(16,6) DEFAULT 0 NOT NULL, itemcost_updated date, itemcost_curr_id integer DEFAULT basecurrid() NOT NULL ); DROP TABLE public.itemcost; publicadminfalse623762386239624062418$'00TABLE itemcostCOMMENT6COMMENT ON TABLE itemcost IS 'Item Cost information'; publicadminfalse256%'00itemcostACLREVOKE ALL ON TABLE itemcost FROM PUBLIC; REVOKE ALL ON TABLE itemcost FROM admin; GRANT ALL ON TABLE itemcost TO admin; GRANT ALL ON TABLE itemcost TO xtrole; publicadminfalse256T125988045itemcostVIEW|CREATE VIEW itemcost AS SELECT (item.item_number)::character varying(100) AS item_number, (costelem.costelem_type)::character varying(100) AS costing_element, itemcost.itemcost_actcost AS actual_cost, curr_symbol.curr_abbr AS currency, false AS post_to_standard FROM (((public.itemcost LEFT JOIN public.item ON ((itemcost.itemcost_item_id = item.item_id))) LEFT JOIN public.costelem ON ((itemcost.itemcost_costelem_id = costelem.costelem_id))) LEFT JOIN public.curr_symbol ON ((itemcost.itemcost_curr_id = curr_symbol.curr_id))) ORDER BY (item.item_number)::character varying(100), (costelem.costelem_type)::character varying(100); DROP VIEW api.itemcost; apiadminfalse88766&'00 VIEW itemcostCOMMENT)COMMENT ON VIEW itemcost IS 'Item Cost'; apiadminfalse852''00itemcostACLREVOKE ALL ON TABLE itemcost FROM PUBLIC; REVOKE ALL ON TABLE itemcost FROM admin; GRANT ALL ON TABLE itemcost TO admin; GRANT ALL ON TABLE itemcost TO xtrole; apiadminfalse852U125988053itemfileVIEWCREATE VIEW itemfile AS SELECT (item.item_number)::character varying AS item_number, url.url_title AS title, url.url_url AS url FROM public.item, public.url WHERE ((item.item_id = url.url_source_id) AND (url.url_source = 'I'::text)); DROP VIEW api.itemfile; apiadminfalse88806('00 VIEW itemfileCOMMENT)COMMENT ON VIEW itemfile IS 'Item File'; apiadminfalse853)'00itemfileACLREVOKE ALL ON TABLE itemfile FROM PUBLIC; REVOKE ALL ON TABLE itemfile FROM admin; GRANT ALL ON TABLE itemfile TO admin; GRANT ALL ON TABLE itemfile TO xtrole; apiadminfalse853V125988060 itemimageVIEWCREATE VIEW itemimage AS SELECT (item.item_number)::character varying AS item_number, CASE WHEN (imageass.imageass_purpose = 'P'::bpchar) THEN 'Product Description'::text WHEN (imageass.imageass_purpose = 'I'::bpchar) THEN 'Inventory Description'::text WHEN (imageass.imageass_purpose = 'E'::bpchar) THEN 'Engineering Reference'::text WHEN (imageass.imageass_purpose = 'M'::bpchar) THEN 'Miscellaneous'::text ELSE 'Other'::text END AS purpose, image.image_name FROM public.item, public.imageass, public.image WHERE (((item.item_id = imageass.imageass_source_id) AND (imageass.imageass_source = 'I'::text)) AND (imageass.imageass_image_id = image.image_id)); DROP VIEW api.itemimage; apiadminfalse88846*'00VIEW itemimageCOMMENT+COMMENT ON VIEW itemimage IS 'Item Image'; apiadminfalse854+'00 itemimageACLREVOKE ALL ON TABLE itemimage FROM PUBLIC; REVOKE ALL ON TABLE itemimage FROM admin; GRANT ALL ON TABLE itemimage TO admin; GRANT ALL ON TABLE itemimage TO xtrole; apiadminfalse854125980104costcatTABLEDCREATE TABLE costcat ( costcat_id integer DEFAULT nextval(('costcat_costcat_id_seq'::text)::regclass) NOT NULL, costcat_code text NOT NULL, costcat_descrip text, costcat_asset_accnt_id integer, costcat_liability_accnt_id integer, costcat_adjustment_accnt_id integer, costcat_matusage_accnt_id integer, costcat_purchprice_accnt_id integer, costcat_laboroverhead_accnt_id integer, costcat_scrap_accnt_id integer, costcat_invcost_accnt_id integer, costcat_wip_accnt_id integer, costcat_shipasset_accnt_id integer, costcat_mfgscrap_accnt_id integer, costcat_transform_accnt_id integer, costcat_freight_accnt_id integer, costcat_toliability_accnt_id integer, costcat_exp_accnt_id integer, CONSTRAINT costcat_costcat_code_check CHECK ((costcat_code <> ''::text)) ); DROP TABLE public.costcat; publicadminfalse624262438,'00 TABLE costcatCOMMENT9COMMENT ON TABLE costcat IS 'Cost Category information'; publicadminfalse257-'00costcatACLREVOKE ALL ON TABLE costcat FROM PUBLIC; REVOKE ALL ON TABLE costcat FROM admin; GRANT ALL ON TABLE costcat TO admin; GRANT ALL ON TABLE costcat TO xtrole; publicadminfalse257125980112plancodeTABLECREATE TABLE plancode ( plancode_id integer DEFAULT nextval(('plancode_plancode_id_seq'::text)::regclass) NOT NULL, plancode_code text NOT NULL, plancode_name text, plancode_mpsexplosion character(1), plancode_consumefcst boolean, plancode_mrpexcp_resched boolean, plancode_mrpexcp_delete boolean, CONSTRAINT plancode_plancode_code_check CHECK ((plancode_code <> ''::text)) ); DROP TABLE public.plancode; publicadminfalse624462458.'00TABLE plancodeCOMMENT9COMMENT ON TABLE plancode IS 'Planner Code information'; publicadminfalse258/'00plancodeACLREVOKE ALL ON TABLE plancode FROM PUBLIC; REVOKE ALL ON TABLE plancode FROM admin; GRANT ALL ON TABLE plancode TO admin; GRANT ALL ON TABLE plancode TO xtrole; publicadminfalse258W125988068itemsiteVIEWCREATE VIEW itemsite AS SELECT (item.item_number)::character varying AS item_number, (whsinfo.warehous_code)::character varying AS site, itemsite.itemsite_active AS active, itemsite.itemsite_wosupply AS wo_supplied_at_site, itemsite.itemsite_createwo AS create_wos, itemsite.itemsite_posupply AS po_supplied_at_site, itemsite.itemsite_createpr AS create_prs, itemsite.itemsite_createsopr AS create_soprs, itemsite.itemsite_createsopo AS create_sopos, itemsite.itemsite_dropship AS dropship, itemsite.itemsite_sold AS sold_from_site, itemsite.itemsite_soldranking AS ranking, CASE WHEN (itemsite.itemsite_costmethod = 'N'::bpchar) THEN 'None'::text WHEN (itemsite.itemsite_costmethod = 'A'::bpchar) THEN 'Average'::text WHEN (itemsite.itemsite_costmethod = 'S'::bpchar) THEN 'Standard'::text WHEN (itemsite.itemsite_costmethod = 'J'::bpchar) THEN 'Job'::text ELSE NULL::text END AS cost_method, CASE WHEN (itemsite.itemsite_controlmethod = 'N'::bpchar) THEN 'None'::text WHEN (itemsite.itemsite_controlmethod = 'R'::bpchar) THEN 'Regular'::text WHEN (itemsite.itemsite_controlmethod = 'S'::bpchar) THEN 'Serial #'::text WHEN (itemsite.itemsite_controlmethod = 'L'::bpchar) THEN 'Lot #'::text ELSE NULL::text END AS control_method, plancode.plancode_code AS planner_code, costcat.costcat_code AS cost_category, itemsite.itemsite_stocked AS stocked, itemsite.itemsite_abcclass AS abc_class, itemsite.itemsite_autoabcclass AS allow_automatic_updates, itemsite.itemsite_cyclecountfreq AS cycl_cnt_freq, itemsite.itemsite_eventfence AS event_fence, itemsite.itemsite_loccntrl AS multiple_location_control, public.formatlocationname(itemsite.itemsite_location_id) AS location, public.formatlocationname(itemsite.itemsite_recvlocation_id) AS receive_location, public.formatlocationname(itemsite.itemsite_issuelocation_id) AS issue_location, itemsite.itemsite_location_dist AS auto_distr_location, itemsite.itemsite_recvlocation_dist AS auto_distr_receive_location, itemsite.itemsite_issuelocation_dist AS auto_distr_issue_location, itemsite.itemsite_location AS user_defined_location, itemsite.itemsite_location_comments AS location_comment, itemsite.itemsite_disallowblankwip AS disallow_blank_wip_locations, itemsite.itemsite_useparams AS enforce_order_parameters, itemsite.itemsite_reorderlevel AS reorder_level, itemsite.itemsite_ordertoqty AS order_up_to, itemsite.itemsite_minordqty AS minimum_order, itemsite.itemsite_maxordqty AS maximum_order, itemsite.itemsite_multordqty AS order_multiple, itemsite.itemsite_useparamsmanual AS enforce_on_manual_orders, CASE WHEN (itemsite.itemsite_planning_type = 'N'::bpchar) THEN 'None'::text WHEN (itemsite.itemsite_planning_type = 'M'::bpchar) THEN 'MRP'::text WHEN (itemsite.itemsite_planning_type = 'S'::bpchar) THEN 'MPS'::text ELSE NULL::text END AS planning_system, itemsite.itemsite_ordergroup AS group_mps_mrp_orders, itemsite.itemsite_ordergroup_first AS first_group, itemsite.itemsite_mps_timefence AS mps_time_fence, itemsite.itemsite_leadtime AS lead_time, itemsite.itemsite_safetystock AS safety_stock, COALESCE((SELECT whsinfo.warehous_code FROM (public.itemsite supplysite JOIN public.whsinfo ON ((whsinfo.warehous_id = supplysite.itemsite_warehous_id))) WHERE (supplysite.itemsite_id = itemsite.itemsite_supply_itemsite_id)), 'None'::text) AS supplied_from_site, itemsite.itemsite_notes AS notes, itemsite.itemsite_perishable AS perishable, itemsite.itemsite_warrpurc AS require_warranty, itemsite.itemsite_autoreg AS auto_register FROM ((((public.itemsite JOIN public.item ON ((item.item_id = itemsite.itemsite_item_id))) JOIN public.plancode ON ((plancode.plancode_id = itemsite.itemsite_plancode_id))) JOIN public.costcat ON ((costcat.costcat_id = itemsite.itemsite_costcat_id))) JOIN public.whsinfo ON ((whsinfo.warehous_id = itemsite.itemsite_warehous_id))); DROP VIEW api.itemsite; apiadminfalse888860'00 VIEW itemsiteCOMMENT)COMMENT ON VIEW itemsite IS 'Item Site'; apiadminfalse8551'00itemsiteACLREVOKE ALL ON TABLE itemsite FROM PUBLIC; REVOKE ALL ON TABLE itemsite FROM admin; GRANT ALL ON TABLE itemsite TO admin; GRANT ALL ON TABLE itemsite TO xtrole; apiadminfalse855X125988078itemsitecommentVIEWrCREATE VIEW itemsitecomment AS SELECT (item.item_number)::character varying AS item_number, (whsinfo.warehous_code)::character varying AS site, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.itemsite, public.item, public.whsinfo, public.cmnttype, public.comment WHERE ((itemsite.itemsite_item_id = item.item_id) AND ((((itemsite.itemsite_warehous_id = whsinfo.warehous_id) AND (comment.comment_source = 'IS'::text)) AND (comment.comment_source_id = itemsite.itemsite_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id))); DROP VIEW api.itemsitecomment; apiadminfalse889262'00VIEW itemsitecommentCOMMENT9COMMENT ON VIEW itemsitecomment IS 'Item Site Comments'; apiadminfalse8563'00itemsitecommentACLREVOKE ALL ON TABLE itemsitecomment FROM PUBLIC; REVOKE ALL ON TABLE itemsitecomment FROM admin; GRANT ALL ON TABLE itemsitecomment TO admin; GRANT ALL ON TABLE itemsitecomment TO xtrole; apiadminfalse856125980130contrctTABLECREATE TABLE contrct ( contrct_id integer NOT NULL, contrct_number text NOT NULL, contrct_vend_id integer NOT NULL, contrct_descrip text, contrct_effective date NOT NULL, contrct_expires date NOT NULL, contrct_note text ); DROP TABLE public.contrct; publicadminfalse84'00 TABLE contrctCOMMENTqCOMMENT ON TABLE contrct IS 'Grouping of Item Sources for a Vendor with common effective and expiration dates.'; publicadminfalse2595'00COLUMN contrct.contrct_idCOMMENTMCOMMENT ON COLUMN contrct.contrct_id IS 'Sequence identifier for contract.'; publicadminfalse2596'00COLUMN contrct.contrct_numberCOMMENTUCOMMENT ON COLUMN contrct.contrct_number IS 'User defined identifier for contract.'; publicadminfalse2597'00COLUMN contrct.contrct_vend_idCOMMENTQCOMMENT ON COLUMN contrct.contrct_vend_id IS 'Vendor associated with contract.'; publicadminfalse2598'00COLUMN contrct.contrct_descripCOMMENTJCOMMENT ON COLUMN contrct.contrct_descrip IS 'Description for contract.'; publicadminfalse2599'00 COLUMN contrct.contrct_effectiveCOMMENThCOMMENT ON COLUMN contrct.contrct_effective IS 'Effective date for contract. Constraint for overlap.'; publicadminfalse259:'00COLUMN contrct.contrct_expiresCOMMENTgCOMMENT ON COLUMN contrct.contrct_expires IS 'Expiration date for contract. Constraint for overlap.'; publicadminfalse259;'00COLUMN contrct.contrct_noteCOMMENTACOMMENT ON COLUMN contrct.contrct_note IS 'Notes for contract.'; publicadminfalse259<'00contrctACLREVOKE ALL ON TABLE contrct FROM PUBLIC; REVOKE ALL ON TABLE contrct FROM admin; GRANT ALL ON TABLE contrct TO admin; GRANT ALL ON TABLE contrct TO xtrole; publicadminfalse259125980136itemsrcTABLE+CREATE TABLE itemsrc ( itemsrc_id integer DEFAULT nextval(('"itemsrc_itemsrc_id_seq"'::text)::regclass) NOT NULL, itemsrc_item_id integer NOT NULL, itemsrc_vend_id integer NOT NULL, itemsrc_vend_item_number text, itemsrc_vend_item_descrip text, itemsrc_comments text, itemsrc_vend_uom text NOT NULL, itemsrc_invvendoruomratio numeric(20,10) NOT NULL, itemsrc_minordqty numeric(18,6) NOT NULL, itemsrc_multordqty numeric(18,6) NOT NULL, itemsrc_leadtime integer NOT NULL, itemsrc_ranking integer NOT NULL, itemsrc_active boolean NOT NULL, itemsrc_manuf_name text DEFAULT ''::text NOT NULL, itemsrc_manuf_item_number text DEFAULT ''::text NOT NULL, itemsrc_manuf_item_descrip text, itemsrc_default boolean, itemsrc_upccode text, itemsrc_effective date DEFAULT startoftime() NOT NULL, itemsrc_expires date DEFAULT endoftime() NOT NULL, itemsrc_contrct_id integer, itemsrc_contrct_max numeric(18,6) DEFAULT 0.0 NOT NULL, itemsrc_contrct_min numeric(18,6) DEFAULT 0.0 NOT NULL ); DROP TABLE public.itemsrc; publicadminfalse62476248624962506251625262538='00 TABLE itemsrcCOMMENT7COMMENT ON TABLE itemsrc IS 'Item Source information'; publicadminfalse260>'00 COLUMN itemsrc.itemsrc_effectiveCOMMENTkCOMMENT ON COLUMN itemsrc.itemsrc_effective IS 'Effective date for item source. Constraint for overlap.'; publicadminfalse260?'00COLUMN itemsrc.itemsrc_expiresCOMMENTjCOMMENT ON COLUMN itemsrc.itemsrc_expires IS 'Expiration date for item source. Constraint for overlap.'; publicadminfalse260@'00!COLUMN itemsrc.itemsrc_contrct_idCOMMENTCOMMENT ON COLUMN itemsrc.itemsrc_contrct_id IS 'Associated contract for item source. Inherits effective, expiration dates.'; publicadminfalse260A'00itemsrcACLREVOKE ALL ON TABLE itemsrc FROM PUBLIC; REVOKE ALL ON TABLE itemsrc FROM admin; GRANT ALL ON TABLE itemsrc TO admin; GRANT ALL ON TABLE itemsrc TO xtrole; publicadminfalse260Y125988086 itemsourceVIEW(CREATE VIEW itemsource AS SELECT (item.item_number)::character varying AS item_number, (vendinfo.vend_number)::character varying AS vendor, itemsrc.itemsrc_vend_item_number AS vendor_item_number, itemsrc.itemsrc_active AS active, itemsrc.itemsrc_default, itemsrc.itemsrc_vend_uom AS vendor_uom, itemsrc.itemsrc_invvendoruomratio AS inventory_vendor_uom_ratio, itemsrc.itemsrc_minordqty AS minimum_order, itemsrc.itemsrc_multordqty AS order_multiple, itemsrc.itemsrc_ranking AS vendor_ranking, itemsrc.itemsrc_leadtime AS lead_time, itemsrc.itemsrc_comments AS notes, itemsrc.itemsrc_vend_item_descrip AS vendor_description, itemsrc.itemsrc_manuf_name AS manufacturer_name, itemsrc.itemsrc_manuf_item_number AS manufacturer_item_number, itemsrc.itemsrc_manuf_item_descrip AS manufacturer_description, itemsrc.itemsrc_upccode AS bar_code, contrct.contrct_number AS contract_number, itemsrc.itemsrc_effective AS effective_date, itemsrc.itemsrc_expires AS expires_date FROM (((public.itemsrc LEFT JOIN public.item ON ((itemsrc.itemsrc_item_id = item.item_id))) LEFT JOIN public.vendinfo ON ((itemsrc.itemsrc_vend_id = vendinfo.vend_id))) LEFT JOIN public.contrct ON ((itemsrc.itemsrc_contrct_id = contrct.contrct_id))) ORDER BY (item.item_number)::character varying(100), (vendinfo.vend_number)::character varying(100); DROP VIEW api.itemsource; apiadminfalse88966B'00VIEW itemsourceCOMMENT-COMMENT ON VIEW itemsource IS 'Item Source'; apiadminfalse857C'00 itemsourceACLREVOKE ALL ON TABLE itemsource FROM PUBLIC; REVOKE ALL ON TABLE itemsource FROM admin; GRANT ALL ON TABLE itemsource TO admin; GRANT ALL ON TABLE itemsource TO xtrole; apiadminfalse857125980154itemsrcpTABLECREATE TABLE itemsrcp ( itemsrcp_id integer DEFAULT nextval(('itemsrcp_itemsrcp_id_seq'::text)::regclass) NOT NULL, itemsrcp_itemsrc_id integer NOT NULL, itemsrcp_qtybreak numeric(18,6) NOT NULL, itemsrcp_price numeric(16,6), itemsrcp_updated date, itemsrcp_curr_id integer DEFAULT basecurrid() NOT NULL, itemsrcp_dropship boolean DEFAULT false NOT NULL, itemsrcp_warehous_id integer DEFAULT (-1) NOT NULL, itemsrcp_type character(1) NOT NULL, itemsrcp_discntprcnt numeric(16,6), itemsrcp_fixedamtdiscount numeric(16,6), CONSTRAINT valid_itemsrcp_type CHECK ((itemsrcp_type = ANY (ARRAY['N'::bpchar, 'D'::bpchar]))) ); DROP TABLE public.itemsrcp; publicadminfalse625462556256625762588D'00TABLE itemsrcpCOMMENT>COMMENT ON TABLE itemsrcp IS 'Item Source Price information'; publicadminfalse261E'00!COLUMN itemsrcp.itemsrcp_dropshipCOMMENTCOMMENT ON COLUMN itemsrcp.itemsrcp_dropship IS 'Used to determine if item source price applies only to drop ship purchase orders.'; publicadminfalse261F'00$COLUMN itemsrcp.itemsrcp_warehous_idCOMMENTCOMMENT ON COLUMN itemsrcp.itemsrcp_warehous_id IS 'Used to determine if item source price applies only to specific site on purchase orders.'; publicadminfalse261G'00COLUMN itemsrcp.itemsrcp_typeCOMMENTCOMMENT ON COLUMN itemsrcp.itemsrcp_type IS 'Pricing type for item source price. Valid values are N-nominal and D-discount.'; publicadminfalse261H'00$COLUMN itemsrcp.itemsrcp_discntprcntCOMMENT^COMMENT ON COLUMN itemsrcp.itemsrcp_discntprcnt IS 'Discount percent for item source price.'; publicadminfalse261I'00)COLUMN itemsrcp.itemsrcp_fixedamtdiscountCOMMENThCOMMENT ON COLUMN itemsrcp.itemsrcp_fixedamtdiscount IS 'Fixed amount discount for item source price.'; publicadminfalse261J'00itemsrcpACLREVOKE ALL ON TABLE itemsrcp FROM PUBLIC; REVOKE ALL ON TABLE itemsrcp FROM admin; GRANT ALL ON TABLE itemsrcp TO admin; GRANT ALL ON TABLE itemsrcp TO xtrole; publicadminfalse261Z125988096itemsourcepriceVIEWCREATE VIEW itemsourceprice AS SELECT (item.item_number)::character varying AS item_number, (vendinfo.vend_number)::character varying AS vendor, itemsrcp.itemsrcp_qtybreak AS qty_break, CASE WHEN (itemsrcp.itemsrcp_type = 'N'::bpchar) THEN 'Nominal'::text ELSE 'Discount'::text END AS pricing_type, CASE WHEN (itemsrcp.itemsrcp_warehous_id = (-1)) THEN 'All'::text ELSE whsinfo.warehous_code END AS pricing_site, itemsrcp.itemsrcp_dropship AS dropship_only, itemsrcp.itemsrcp_price AS price_per_unit, curr_symbol.curr_abbr AS currency, (itemsrcp.itemsrcp_discntprcnt * 100.0) AS discount_percent, itemsrcp.itemsrcp_fixedamtdiscount AS discount_fixed_amount FROM (((((public.itemsrcp LEFT JOIN public.itemsrc ON ((itemsrc.itemsrc_id = itemsrcp.itemsrcp_itemsrc_id))) LEFT JOIN public.item ON ((itemsrc.itemsrc_item_id = item.item_id))) LEFT JOIN public.vendinfo ON ((itemsrc.itemsrc_vend_id = vendinfo.vend_id))) LEFT JOIN public.curr_symbol ON ((itemsrcp.itemsrcp_curr_id = curr_symbol.curr_id))) LEFT JOIN public.whsinfo ON ((itemsrcp.itemsrcp_warehous_id = whsinfo.warehous_id))) ORDER BY (item.item_number)::character varying(100), (vendinfo.vend_number)::character varying(100); DROP VIEW api.itemsourceprice; apiadminfalse89006K'00VIEW itemsourcepriceCOMMENT8COMMENT ON VIEW itemsourceprice IS 'Item Source Price'; apiadminfalse858L'00itemsourcepriceACLREVOKE ALL ON TABLE itemsourceprice FROM PUBLIC; REVOKE ALL ON TABLE itemsourceprice FROM admin; GRANT ALL ON TABLE itemsourceprice TO admin; GRANT ALL ON TABLE itemsourceprice TO xtrole; apiadminfalse858125980167itemsubTABLECREATE TABLE itemsub ( itemsub_id integer DEFAULT nextval(('itemsub_itemsub_id_seq'::text)::regclass) NOT NULL, itemsub_parent_item_id integer NOT NULL, itemsub_sub_item_id integer NOT NULL, itemsub_uomratio numeric(20,10) NOT NULL, itemsub_rank integer NOT NULL ); DROP TABLE public.itemsub; publicadminfalse62598M'00 TABLE itemsubCOMMENT<COMMENT ON TABLE itemsub IS 'Item Substitutes information'; publicadminfalse262N'00itemsubACLREVOKE ALL ON TABLE itemsub FROM PUBLIC; REVOKE ALL ON TABLE itemsub FROM admin; GRANT ALL ON TABLE itemsub TO admin; GRANT ALL ON TABLE itemsub TO xtrole; publicadminfalse262[125988106itemsubstituteVIEWCREATE VIEW itemsubstitute AS SELECT (p.item_number)::character varying AS root_item_number, (s.item_number)::character varying AS substitute_item_number, itemsub.itemsub_uomratio AS sub_parent_uom_ratio, itemsub.itemsub_rank AS ranking FROM public.item p, public.item s, public.itemsub WHERE ((p.item_id = itemsub.itemsub_parent_item_id) AND (s.item_id = itemsub.itemsub_sub_item_id)); DROP VIEW api.itemsubstitute; apiadminfalse89046O'00VIEW itemsubstituteCOMMENT5COMMENT ON VIEW itemsubstitute IS 'Item Substitute'; apiadminfalse859P'00itemsubstituteACLREVOKE ALL ON TABLE itemsubstitute FROM PUBLIC; REVOKE ALL ON TABLE itemsubstitute FROM admin; GRANT ALL ON TABLE itemsubstitute TO admin; GRANT ALL ON TABLE itemsubstitute TO xtrole; apiadminfalse859125980175itemtaxTABLECREATE TABLE itemtax ( itemtax_id integer NOT NULL, itemtax_item_id integer NOT NULL, itemtax_taxtype_id integer NOT NULL, itemtax_taxzone_id integer ); DROP TABLE public.itemtax; publicadminfalse8Q'00 TABLE itemtaxCOMMENTpCOMMENT ON TABLE itemtax IS 'This table associates tax types in a specified tax authority for the given item.'; publicadminfalse263R'00itemtaxACLREVOKE ALL ON TABLE itemtax FROM PUBLIC; REVOKE ALL ON TABLE itemtax FROM admin; GRANT ALL ON TABLE itemtax TO admin; GRANT ALL ON TABLE itemtax TO xtrole; publicadminfalse263\125988113 itemtaxtypeVIEWCREATE VIEW itemtaxtype AS SELECT (item.item_number)::character varying AS item_number, CASE WHEN (taxzone.taxzone_id IS NULL) THEN 'Any'::character varying ELSE (taxzone.taxzone_code)::character varying END AS tax_zone, taxtype.taxtype_name AS tax_type FROM public.item, (public.itemtax LEFT JOIN public.taxzone ON ((itemtax.itemtax_taxzone_id = taxzone.taxzone_id))), public.taxtype WHERE ((item.item_id = itemtax.itemtax_item_id) AND (itemtax.itemtax_taxtype_id = taxtype.taxtype_id)); DROP VIEW api.itemtaxtype; apiadminfalse89086S'00VIEW itemtaxtypeCOMMENT0COMMENT ON VIEW itemtaxtype IS 'Item Tax Type'; apiadminfalse860T'00 itemtaxtypeACLREVOKE ALL ON TABLE itemtaxtype FROM PUBLIC; REVOKE ALL ON TABLE itemtaxtype FROM admin; GRANT ALL ON TABLE itemtaxtype TO admin; GRANT ALL ON TABLE itemtaxtype TO xtrole; apiadminfalse860125980182 itemuomconvTABLECREATE TABLE itemuomconv ( itemuomconv_id integer NOT NULL, itemuomconv_item_id integer NOT NULL, itemuomconv_from_uom_id integer NOT NULL, itemuomconv_from_value numeric(20,10) NOT NULL, itemuomconv_to_uom_id integer NOT NULL, itemuomconv_to_value numeric(20,10) NOT NULL, itemuomconv_fractional boolean DEFAULT false NOT NULL, itemuomconv_active boolean DEFAULT true NOT NULL, CONSTRAINT itemuomconv_uom CHECK ((itemuomconv_from_uom_id <> itemuomconv_to_uom_id)) ); DROP TABLE public.itemuomconv; publicadminfalse6262626362648U'00TABLE itemuomconvCOMMENTfCOMMENT ON TABLE itemuomconv IS 'UOM conversion information. From Unit to To Unit with a value per.'; publicadminfalse264V'00%COLUMN itemuomconv.itemuomconv_activeCOMMENT[COMMENT ON COLUMN itemuomconv.itemuomconv_active IS 'Item UOM conversion active/inactive'; publicadminfalse264W'00 itemuomconvACLREVOKE ALL ON TABLE itemuomconv FROM PUBLIC; REVOKE ALL ON TABLE itemuomconv FROM admin; GRANT ALL ON TABLE itemuomconv TO admin; GRANT ALL ON TABLE itemuomconv TO xtrole; publicadminfalse264]125988120itemuomconversionVIEWgCREATE VIEW itemuomconversion AS SELECT (item.item_number)::character varying AS item_number, (f.uom_name)::character varying AS uom, itemuomconv.itemuomconv_from_value AS uom_value, p.uom_name AS per_uom, itemuomconv.itemuomconv_to_value AS per_uom_value, itemuomconv.itemuomconv_fractional AS fractional, public.fetchitemuomconvtypes(itemuomconv.itemuomconv_id) AS selected_types FROM public.item, public.itemuomconv, public.uom f, public.uom p WHERE (((item.item_id = itemuomconv.itemuomconv_item_id) AND (itemuomconv.itemuomconv_from_uom_id = f.uom_id)) AND (itemuomconv.itemuomconv_to_uom_id = p.uom_id)); !DROP VIEW api.itemuomconversion; apiadminfalse89126X'00VIEW itemuomconversionCOMMENTHCOMMENT ON VIEW itemuomconversion IS 'Item Unit of Measure Conversion'; apiadminfalse861Y'00itemuomconversionACLREVOKE ALL ON TABLE itemuomconversion FROM PUBLIC; REVOKE ALL ON TABLE itemuomconversion FROM admin; GRANT ALL ON TABLE itemuomconversion TO admin; GRANT ALL ON TABLE itemuomconversion TO xtrole; apiadminfalse861 125980191gltransTABLECREATE TABLE gltrans ( gltrans_id integer DEFAULT nextval(('"gltrans_gltrans_id_seq"'::text)::regclass) NOT NULL, gltrans_exported boolean, gltrans_created timestamp with time zone, gltrans_date date NOT NULL, gltrans_sequence integer, gltrans_accnt_id integer NOT NULL, gltrans_source text, gltrans_docnumber text, gltrans_misc_id integer, gltrans_amount numeric(20,2) NOT NULL, gltrans_notes text, gltrans_journalnumber integer, gltrans_posted boolean NOT NULL, gltrans_doctype text, gltrans_rec boolean DEFAULT false NOT NULL, gltrans_username text DEFAULT geteffectivextuser() NOT NULL, gltrans_deleted boolean DEFAULT false ); DROP TABLE public.gltrans; publicadminfalse62656266626762688Z'00 TABLE gltransCOMMENTLCOMMENT ON TABLE gltrans IS 'General Ledger (G/L) transaction information'; publicadminfalse265['00gltransACLREVOKE ALL ON TABLE gltrans FROM PUBLIC; REVOKE ALL ON TABLE gltrans FROM admin; GRANT ALL ON TABLE gltrans TO admin; GRANT ALL ON TABLE gltrans TO xtrole; publicadminfalse265^125988127 journalentryVIEWCREATE VIEW journalentry AS SELECT curr_symbol.curr_abbr AS currency, c.gltrans_amount AS amount, c.gltrans_date AS dist_date, c.gltrans_docnumber AS doc_number, public.formatglaccount(da.accnt_id) AS debit, public.formatglaccount(ca.accnt_id) AS credit, c.gltrans_notes AS notes FROM public.gltrans d, public.gltrans c, public.accnt da, public.accnt ca, public.curr_symbol WHERE ((((((((d.gltrans_sequence = c.gltrans_sequence) AND (d.gltrans_accnt_id = da.accnt_id)) AND (c.gltrans_accnt_id = ca.accnt_id)) AND (d.gltrans_amount < (0)::numeric)) AND (c.gltrans_amount > (0)::numeric)) AND (d.gltrans_doctype = 'JE'::text)) AND (c.gltrans_doctype = 'JE'::text)) AND (curr_symbol.curr_id = public.basecurrid())) ORDER BY d.gltrans_date DESC; DROP VIEW api.journalentry; apiadminfalse89166\'00VIEW journalentryCOMMENT1COMMENT ON VIEW journalentry IS 'Journal Entry'; apiadminfalse862]'00 journalentryACLREVOKE ALL ON TABLE journalentry FROM PUBLIC; REVOKE ALL ON TABLE journalentry FROM admin; GRANT ALL ON TABLE journalentry TO admin; GRANT ALL ON TABLE journalentry TO xtrole; apiadminfalse862 125980206locationTABLECREATE TABLE location ( location_id integer DEFAULT nextval(('location_location_id_seq'::text)::regclass) NOT NULL, location_warehous_id integer NOT NULL, location_name text NOT NULL, location_descrip text, location_restrict boolean, location_netable boolean, location_whsezone_id integer, location_aisle text, location_rack text, location_bin text, location_formatname text, location_usable boolean ); DROP TABLE public.location; publicadminfalse62698^'00TABLE locationCOMMENT?COMMENT ON TABLE location IS 'Warehouse Location information'; publicadminfalse266_'00locationACLREVOKE ALL ON TABLE location FROM PUBLIC; REVOKE ALL ON TABLE location FROM admin; GRANT ALL ON TABLE location TO admin; GRANT ALL ON TABLE location TO xtrole; publicadminfalse266 125980213whsezoneTABLECREATE TABLE whsezone ( whsezone_id integer NOT NULL, whsezone_warehous_id integer NOT NULL, whsezone_name text NOT NULL, whsezone_descrip text ); DROP TABLE public.whsezone; publicadminfalse8`'00TABLE whsezoneCOMMENT;COMMENT ON TABLE whsezone IS 'Warehouse Zone information'; publicadminfalse267a'00whsezoneACLREVOKE ALL ON TABLE whsezone FROM PUBLIC; REVOKE ALL ON TABLE whsezone FROM admin; GRANT ALL ON TABLE whsezone TO admin; GRANT ALL ON TABLE whsezone TO xtrole; publicadminfalse267_125988135locationVIEWCREATE VIEW location AS SELECT (whsinfo.warehous_code)::character varying AS site, (location.location_aisle)::character varying AS aisle, (location.location_rack)::character varying AS rack, (location.location_bin)::character varying AS bin, (location.location_name)::character varying AS location, whsezone.whsezone_name AS zone, location.location_netable AS netable, location.location_usable AS usable, location.location_restrict AS restricted, location.location_descrip AS description FROM ((public.location LEFT JOIN public.whsinfo ON ((whsinfo.warehous_id = location.location_warehous_id))) LEFT JOIN public.whsezone ON ((whsezone.whsezone_id = location.location_whsezone_id))); DROP VIEW api.location; apiadminfalse89206b'00 VIEW locationCOMMENT(COMMENT ON VIEW location IS 'Location'; apiadminfalse863c'00locationACLREVOKE ALL ON TABLE location FROM PUBLIC; REVOKE ALL ON TABLE location FROM admin; GRANT ALL ON TABLE location TO admin; GRANT ALL ON TABLE location TO xtrole; apiadminfalse863`125988143 misccounttagVIEWCREATE VIEW misccounttag AS SELECT 'This view is for inserts only'::text AS site, 'This view is for inserts only'::text AS item_number, (0)::numeric AS quantity, 'This view is for inserts only'::text AS comment; DROP VIEW api.misccounttag; apiadminfalse89246d'00VIEW misccounttagCOMMENT;COMMENT ON VIEW misccounttag IS 'Miscellaneous Count Tag'; apiadminfalse864e'00 misccounttagACLREVOKE ALL ON TABLE misccounttag FROM PUBLIC; REVOKE ALL ON TABLE misccounttag FROM admin; GRANT ALL ON TABLE misccounttag TO admin; GRANT ALL ON TABLE misccounttag TO xtrole; apiadminfalse864a125988151pricingscheduleVIEWCREATE VIEW pricingschedule AS SELECT (ipshead.ipshead_name)::character varying AS name, ipshead.ipshead_descrip AS description, public.formatdate(ipshead.ipshead_effective, 'Always'::text) AS effective, public.formatdate(ipshead.ipshead_expires, 'Never'::text) AS expires, curr_symbol.curr_abbr AS currency FROM public.ipshead, public.curr_symbol WHERE (curr_symbol.curr_id = ipshead.ipshead_curr_id); DROP VIEW api.pricingschedule; apiadminfalse89286f'00VIEW pricingscheduleCOMMENT7COMMENT ON VIEW pricingschedule IS 'Pricing Schedule'; apiadminfalse865g'00pricingscheduleACLREVOKE ALL ON TABLE pricingschedule FROM PUBLIC; REVOKE ALL ON TABLE pricingschedule FROM admin; GRANT ALL ON TABLE pricingschedule TO admin; GRANT ALL ON TABLE pricingschedule TO xtrole; apiadminfalse865 125980232ipsassTABLE CREATE TABLE ipsass ( ipsass_id integer NOT NULL, ipsass_ipshead_id integer NOT NULL, ipsass_cust_id integer, ipsass_custtype_id integer, ipsass_custtype_pattern text, ipsass_shipto_id integer DEFAULT (-1), ipsass_shipto_pattern text ); DROP TABLE public.ipsass; publicadminfalse62728h'00 TABLE ipsassCOMMENTFCOMMENT ON TABLE ipsass IS 'Pricing Schedule assignment information'; publicadminfalse268i'00ipsassACLREVOKE ALL ON TABLE ipsass FROM PUBLIC; REVOKE ALL ON TABLE ipsass FROM admin; GRANT ALL ON TABLE ipsass TO admin; GRANT ALL ON TABLE ipsass TO xtrole; publicadminfalse268b125988159pricingscheduleassignVIEWCREATE VIEW pricingscheduleassign AS SELECT (COALESCE(custinfo.cust_number, 'Any'::text))::character varying AS customer_number, (COALESCE(shiptoinfo.shipto_num, 'Any'::text))::character varying AS customer_shipto, (COALESCE(ipsass.ipsass_shipto_pattern, 'N/A'::text))::character varying AS customer_shipto_pattern, (COALESCE(custtype.custtype_code, 'N/A'::text))::character varying AS customer_type, (COALESCE(ipsass.ipsass_custtype_pattern, 'N/A'::text))::character varying AS customer_type_pattern, (ipshead.ipshead_name)::character varying AS pricing_schedule FROM ((((public.ipshead JOIN public.ipsass ON ((ipshead.ipshead_id = ipsass.ipsass_ipshead_id))) LEFT JOIN public.custinfo ON ((ipsass.ipsass_cust_id = custinfo.cust_id))) LEFT JOIN public.custtype ON ((ipsass.ipsass_custtype_id = custtype.custtype_id))) LEFT JOIN public.shiptoinfo ON ((ipsass.ipsass_shipto_id = shiptoinfo.shipto_id))) ORDER BY (COALESCE(custinfo.cust_number, 'Any'::text))::character varying, (COALESCE(shiptoinfo.shipto_num, 'Any'::text))::character varying, (COALESCE(custtype.custtype_code, 'N/A'::text))::character varying, (COALESCE(ipsass.ipsass_custtype_pattern, 'N/A'::text))::character varying, (ipshead.ipshead_name)::character varying; %DROP VIEW api.pricingscheduleassign; apiadminfalse89326j'00VIEW pricingscheduleassignCOMMENTICOMMENT ON VIEW pricingscheduleassign IS 'Pricing Schedule Assignments'; apiadminfalse866k'00pricingscheduleassignACLREVOKE ALL ON TABLE pricingscheduleassign FROM PUBLIC; REVOKE ALL ON TABLE pricingscheduleassign FROM admin; GRANT ALL ON TABLE pricingscheduleassign TO admin; GRANT ALL ON TABLE pricingscheduleassign TO xtrole; apiadminfalse866 125980244 ipsiteminfoTABLECREATE TABLE ipsiteminfo ( ipsitem_id integer DEFAULT nextval(('"ipsitem_ipsitem_id_seq"'::text)::regclass) NOT NULL, ipsitem_ipshead_id integer, ipsitem_item_id integer, ipsitem_qtybreak numeric(18,6) NOT NULL, ipsitem_price numeric(16,4) NOT NULL, ipsitem_qty_uom_id integer, ipsitem_price_uom_id integer, ipsitem_discntprcnt numeric(10,6) DEFAULT 0.00 NOT NULL, ipsitem_fixedamtdiscount numeric(16,4) DEFAULT 0.00 NOT NULL, ipsitem_prodcat_id integer, ipsitem_type character(1) NOT NULL, ipsitem_warehous_id integer, CONSTRAINT valid_ipsitem_type CHECK ((ipsitem_type = ANY (ARRAY['N'::bpchar, 'D'::bpchar, 'M'::bpchar]))) ); DROP TABLE public.ipsiteminfo; publicadminfalse62736274627562768l'00TABLE ipsiteminfoCOMMENTECOMMENT ON TABLE ipsiteminfo IS 'Pricing Schedule Item information'; publicadminfalse269m'00%COLUMN ipsiteminfo.ipsitem_prodcat_idCOMMENTcCOMMENT ON COLUMN ipsiteminfo.ipsitem_prodcat_id IS 'Product category for pricing schedule item.'; publicadminfalse269n'00COLUMN ipsiteminfo.ipsitem_typeCOMMENTCOMMENT ON COLUMN ipsiteminfo.ipsitem_type IS 'Pricing type for pricing schedule item. Valid values are N-nominal, D-discount, and M-markup'; publicadminfalse269o'00&COLUMN ipsiteminfo.ipsitem_warehous_idCOMMENTvCOMMENT ON COLUMN ipsiteminfo.ipsitem_warehous_id IS 'Site for pricing schedule item which enables pricing by site.'; publicadminfalse269p'00 ipsiteminfoACLREVOKE ALL ON TABLE ipsiteminfo FROM PUBLIC; REVOKE ALL ON TABLE ipsiteminfo FROM admin; GRANT ALL ON TABLE ipsiteminfo TO admin; GRANT ALL ON TABLE ipsiteminfo TO xtrole; publicadminfalse269c125988168pricingscheduleitemVIEWCREATE VIEW pricingscheduleitem AS SELECT (ipshead.ipshead_name)::character varying AS pricing_schedule, CASE WHEN (COALESCE(ipsiteminfo.ipsitem_item_id, (-1)) > 0) THEN 'Item'::character varying ELSE 'Product Category'::character varying END AS type, (COALESCE(item.item_number, ''::text))::character varying AS item_number, (COALESCE(prodcat.prodcat_code, ''::text))::character varying AS product_category, ipsiteminfo.ipsitem_qtybreak AS qty_break, (qtyuom.uom_name)::character varying AS qty_uom, (priceuom.uom_name)::character varying AS price_uom, ipsiteminfo.ipsitem_price AS price, ipsiteminfo.ipsitem_discntprcnt AS percent, ipsiteminfo.ipsitem_fixedamtdiscount AS fixedamt, CASE WHEN (ipsiteminfo.ipsitem_type = 'N'::bpchar) THEN 'Nominal'::character varying WHEN (ipsiteminfo.ipsitem_type = 'D'::bpchar) THEN 'Discount'::character varying WHEN (ipsiteminfo.ipsitem_type = 'M'::bpchar) THEN 'Markup'::character varying ELSE NULL::character varying END AS pricing_type FROM (((((public.ipsiteminfo JOIN public.ipshead ON ((ipsiteminfo.ipsitem_ipshead_id = ipshead.ipshead_id))) LEFT JOIN public.item ON ((ipsiteminfo.ipsitem_item_id = item.item_id))) LEFT JOIN public.prodcat ON ((ipsiteminfo.ipsitem_prodcat_id = prodcat.prodcat_id))) LEFT JOIN public.uom qtyuom ON ((ipsiteminfo.ipsitem_qty_uom_id = qtyuom.uom_id))) LEFT JOIN public.uom priceuom ON ((ipsiteminfo.ipsitem_price_uom_id = priceuom.uom_id))); #DROP VIEW api.pricingscheduleitem; apiadminfalse89366q'00VIEW pricingscheduleitemCOMMENT@COMMENT ON VIEW pricingscheduleitem IS 'Pricing Schedule Item'; apiadminfalse867r'00pricingscheduleitemACLREVOKE ALL ON TABLE pricingscheduleitem FROM PUBLIC; REVOKE ALL ON TABLE pricingscheduleitem FROM admin; GRANT ALL ON TABLE pricingscheduleitem TO admin; GRANT ALL ON TABLE pricingscheduleitem TO xtrole; apiadminfalse867125980256 ipsitemcharTABLECREATE TABLE ipsitemchar ( ipsitemchar_id integer NOT NULL, ipsitemchar_ipsitem_id integer NOT NULL, ipsitemchar_char_id integer NOT NULL, ipsitemchar_value text NOT NULL, ipsitemchar_price numeric(16,4) ); DROP TABLE public.ipsitemchar; publicadminfalse8s'00TABLE ipsitemcharCOMMENTNCOMMENT ON TABLE ipsitemchar IS 'Item Price Schedule Characteristic Prices.'; publicadminfalse270t'00 ipsitemcharACLREVOKE ALL ON TABLE ipsitemchar FROM PUBLIC; REVOKE ALL ON TABLE ipsitemchar FROM admin; GRANT ALL ON TABLE ipsitemchar TO admin; GRANT ALL ON TABLE ipsitemchar TO xtrole; publicadminfalse270d125988178pricingscheduleitemcharVIEWCREATE VIEW pricingscheduleitemchar AS SELECT (ipshead.ipshead_name)::character varying AS pricing_schedule, (item.item_number)::character varying AS item_number, ipsiteminfo.ipsitem_qtybreak AS qty_break, (qtyuom.uom_name)::character varying AS qty_uom, (priceuom.uom_name)::character varying AS price_uom, ("char".char_name)::character varying AS characteristic, (ipsitemchar.ipsitemchar_value)::character varying AS value, ipsitemchar.ipsitemchar_price AS price FROM public.ipshead, public.ipsiteminfo, public.ipsitemchar, public.item, public."char", public.uom qtyuom, public.uom priceuom WHERE ((((((ipshead.ipshead_id = ipsiteminfo.ipsitem_ipshead_id) AND (ipsiteminfo.ipsitem_id = ipsitemchar.ipsitemchar_ipsitem_id)) AND (ipsiteminfo.ipsitem_item_id = item.item_id)) AND (ipsiteminfo.ipsitem_qty_uom_id = qtyuom.uom_id)) AND (ipsiteminfo.ipsitem_price_uom_id = priceuom.uom_id)) AND (ipsitemchar.ipsitemchar_char_id = "char".char_id)); 'DROP VIEW api.pricingscheduleitemchar; apiadminfalse89406u'00VIEW pricingscheduleitemcharCOMMENTTCOMMENT ON VIEW pricingscheduleitemchar IS 'Pricing Schedule Item Characteristics'; apiadminfalse868v'00pricingscheduleitemcharACLREVOKE ALL ON TABLE pricingscheduleitemchar FROM PUBLIC; REVOKE ALL ON TABLE pricingscheduleitemchar FROM admin; GRANT ALL ON TABLE pricingscheduleitemchar TO admin; GRANT ALL ON TABLE pricingscheduleitemchar TO xtrole; apiadminfalse868e125988186projectVIEWnCREATE VIEW project AS SELECT prj.prj_number AS number, prj.prj_name AS name, prj.prj_descrip AS description, prj.prj_owner_username AS owner, prj.prj_username AS assigned_to, prj.prj_so AS sales_orders, prj.prj_wo AS work_orders, prj.prj_po AS purchase_orders, CASE WHEN (prj.prj_status = 'P'::bpchar) THEN 'Concept'::text WHEN (prj.prj_status = 'O'::bpchar) THEN 'In-Process'::text WHEN (prj.prj_status = 'C'::bpchar) THEN 'Closed'::text ELSE 'Error'::text END AS status, prj.prj_due_date AS due, prj.prj_assigned_date AS assigned, prj.prj_start_date AS started, prj.prj_completed_date AS completed FROM public.prj; DROP VIEW api.project; apiadminfalse89446w'00 VIEW projectCOMMENT&COMMENT ON VIEW project IS 'Project'; apiadminfalse869x'00projectACLREVOKE ALL ON TABLE project FROM PUBLIC; REVOKE ALL ON TABLE project FROM admin; GRANT ALL ON TABLE project TO admin; GRANT ALL ON TABLE project TO xtrole; apiadminfalse869f125988194projectcommentVIEWCREATE VIEW projectcomment AS SELECT (prj.prj_number)::character varying AS project_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.prj, public.cmnttype, public.comment WHERE (((comment.comment_source = 'J'::text) AND (comment.comment_source_id = prj.prj_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); DROP VIEW api.projectcomment; apiadminfalse89486y'00VIEW projectcommentCOMMENT5COMMENT ON VIEW projectcomment IS 'Project Comment'; apiadminfalse870z'00projectcommentACLREVOKE ALL ON TABLE projectcomment FROM PUBLIC; REVOKE ALL ON TABLE projectcomment FROM admin; GRANT ALL ON TABLE projectcomment TO admin; GRANT ALL ON TABLE projectcomment TO xtrole; apiadminfalse870125980275cust_cust_id_seqSEQUENCErCREATE SEQUENCE cust_cust_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 'DROP SEQUENCE public.cust_cust_id_seq; publicadminfalse8{'00cust_cust_id_seqACLREVOKE ALL ON SEQUENCE cust_cust_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cust_cust_id_seq FROM admin; GRANT ALL ON SEQUENCE cust_cust_id_seq TO admin; GRANT ALL ON SEQUENCE cust_cust_id_seq TO xtrole; publicadminfalse271125980277prospectTABLECREATE TABLE prospect ( prospect_id integer DEFAULT nextval('cust_cust_id_seq'::regclass) NOT NULL, prospect_active boolean DEFAULT true NOT NULL, prospect_number text NOT NULL, prospect_name text NOT NULL, prospect_cntct_id integer, prospect_comments text, prospect_created date DEFAULT ('now'::text)::date NOT NULL, prospect_salesrep_id integer, prospect_warehous_id integer, prospect_taxzone_id integer, CONSTRAINT prospect_prospect_number_check CHECK ((prospect_number <> ''::text)) ); DROP TABLE public.prospect; publicadminfalse62786279628062818|'00TABLE prospectCOMMENT5COMMENT ON TABLE prospect IS 'Prospect Information'; publicadminfalse272}'00prospectACLREVOKE ALL ON TABLE prospect FROM PUBLIC; REVOKE ALL ON TABLE prospect FROM admin; GRANT ALL ON TABLE prospect TO admin; GRANT ALL ON TABLE prospect TO xtrole; publicadminfalse272g125988201prospectVIEWCREATE VIEW prospect AS SELECT (prospect.prospect_number)::character varying AS prospect_number, prospect.prospect_name, prospect.prospect_active AS active, salesrep.salesrep_number AS sales_rep, whsinfo.warehous_code AS site_code, taxzone.taxzone_code AS default_tax_zone, prospect.prospect_comments AS notes, cntct.cntct_number AS contact_number, cntct.cntct_honorific AS contact_honorific, cntct.cntct_first_name AS contact_first, cntct.cntct_middle AS contact_middle, cntct.cntct_last_name AS contact_last, cntct.cntct_suffix AS contact_suffix, cntct.cntct_title AS contact_job_title, cntct.cntct_phone AS contact_voice, cntct.cntct_phone2 AS contact_alternate, cntct.cntct_fax AS contact_fax, cntct.cntct_email AS contact_email, cntct.cntct_webaddr AS contact_web, ''::text AS contact_change, addr.addr_number AS contact_address_number, addr.addr_line1 AS contact_address1, addr.addr_line2 AS contact_address2, addr.addr_line3 AS contact_address3, addr.addr_city AS contact_city, addr.addr_state AS contact_state, addr.addr_postalcode AS contact_postalcode, addr.addr_country AS contact_country, ''::text AS contact_address_change FROM (((((public.prospect LEFT JOIN public.cntct ON ((prospect.prospect_cntct_id = cntct.cntct_id))) LEFT JOIN public.addr ON ((cntct.cntct_addr_id = addr.addr_id))) LEFT JOIN public.taxzone ON ((prospect.prospect_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.salesrep ON ((prospect.prospect_salesrep_id = salesrep.salesrep_id))) LEFT JOIN public.whsinfo ON ((prospect.prospect_warehous_id = whsinfo.warehous_id))); DROP VIEW api.prospect; apiadminfalse89526~'00 VIEW prospectCOMMENT(COMMENT ON VIEW prospect IS 'Prospect'; apiadminfalse871'00prospectACLREVOKE ALL ON TABLE prospect FROM PUBLIC; REVOKE ALL ON TABLE prospect FROM admin; GRANT ALL ON TABLE prospect TO admin; GRANT ALL ON TABLE prospect TO xtrole; apiadminfalse871125980292expcatTABLEkCREATE TABLE expcat ( expcat_id integer NOT NULL, expcat_code text NOT NULL, expcat_descrip text, expcat_exp_accnt_id integer, expcat_liability_accnt_id integer, expcat_active boolean, expcat_purchprice_accnt_id integer, expcat_freight_accnt_id integer, CONSTRAINT expcat_expcat_code_check CHECK ((expcat_code <> ''::text)) ); DROP TABLE public.expcat; publicadminfalse62838'00 TABLE expcatCOMMENT;COMMENT ON TABLE expcat IS 'Expense Category information'; publicadminfalse273'00expcatACLREVOKE ALL ON TABLE expcat FROM PUBLIC; REVOKE ALL ON TABLE expcat FROM admin; GRANT ALL ON TABLE expcat TO admin; GRANT ALL ON TABLE expcat TO xtrole; publicadminfalse273125980299womatlTABLECREATE TABLE womatl ( womatl_id integer DEFAULT nextval(('womatl_womatl_id_seq'::text)::regclass) NOT NULL, womatl_wo_id integer, womatl_itemsite_id integer, womatl_qtyper numeric(20,8) NOT NULL, womatl_scrap numeric(8,4) NOT NULL, womatl_qtyreq numeric(18,6) NOT NULL, womatl_qtyiss numeric(18,6) NOT NULL, womatl_qtywipscrap numeric(18,6) NOT NULL, womatl_lastissue date, womatl_lastreturn date, womatl_cost numeric(16,6), womatl_picklist boolean, womatl_status character(1), womatl_imported boolean DEFAULT false, womatl_createwo boolean, womatl_issuemethod character(1), womatl_wooper_id integer, womatl_bomitem_id integer, womatl_duedate date, womatl_schedatwooper boolean, womatl_uom_id integer NOT NULL, womatl_notes text, womatl_ref text, womatl_scrapvalue numeric(16,6) DEFAULT 0, womatl_qtyfxd numeric(20,8) DEFAULT 0 NOT NULL, womatl_issuewo boolean DEFAULT false NOT NULL, womatl_price numeric(16,6) DEFAULT 0 NOT NULL ); DROP TABLE public.womatl; publicadminfalse6284628562866287628862898'00 TABLE womatlCOMMENTKCOMMENT ON TABLE womatl IS 'Work Order Material Requirements information'; publicadminfalse274'00COLUMN womatl.womatl_qtyfxdCOMMENTICOMMENT ON COLUMN womatl.womatl_qtyfxd IS 'The fixed quantity required'; publicadminfalse274'00womatlACLREVOKE ALL ON TABLE womatl FROM PUBLIC; REVOKE ALL ON TABLE womatl FROM admin; GRANT ALL ON TABLE womatl TO admin; GRANT ALL ON TABLE womatl TO xtrole; publicadminfalse274h125988210 purchaselineVIEWCREATE VIEW purchaseline AS SELECT (pohead.pohead_number)::character varying AS order_number, poitem.poitem_linenumber AS line_number, item.item_number, whsinfo.warehous_code AS site, expcat.expcat_code AS expense_category, poitem.poitem_qty_ordered AS qty_ordered, poitem.poitem_unitprice AS unit_price, poitem.poitem_freight AS freight, poitem.poitem_duedate AS due_date, prj.prj_number AS project_number, poitem.poitem_vend_item_number AS vend_item_number, poitem.poitem_vend_item_descrip AS vendor_description, poitem.poitem_manuf_name AS manufacturer_name, poitem.poitem_manuf_item_number AS manufacturer_item_number, poitem.poitem_manuf_item_descrip AS manufacturer_description, poitem.poitem_comments AS notes, public.formatrevnumber('BOM'::text, poitem.poitem_bom_rev_id) AS bill_of_materials_revision, public.formatrevnumber('BOO'::text, poitem.poitem_boo_rev_id) AS bill_of_operations_revision, public.formatsonumber(coitem.coitem_id) AS sales_order_number, public.formatwonumber(womatl.womatl_wo_id) AS work_order_number FROM ((((((((public.pohead JOIN public.poitem ON ((pohead.pohead_id = poitem.poitem_pohead_id))) LEFT JOIN public.prj ON ((poitem.poitem_prj_id = prj.prj_id))) LEFT JOIN public.expcat ON ((poitem.poitem_expcat_id = expcat.expcat_id))) LEFT JOIN public.itemsite ON ((poitem.poitem_itemsite_id = itemsite.itemsite_id))) LEFT JOIN public.item ON ((itemsite.itemsite_item_id = item.item_id))) LEFT JOIN public.whsinfo ON ((itemsite.itemsite_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.coitem ON (((coitem.coitem_id = poitem.poitem_order_id) AND (poitem.poitem_order_type = 'S'::bpchar)))) LEFT JOIN public.womatl ON (((womatl.womatl_id = poitem.poitem_order_id) AND (poitem.poitem_order_type = 'W'::bpchar)))) ORDER BY pohead.pohead_number, poitem.poitem_linenumber; DROP VIEW api.purchaseline; apiadminfalse89566'00VIEW purchaselineCOMMENT7COMMENT ON VIEW purchaseline IS 'Purchase Order Line'; apiadminfalse872'00 purchaselineACLREVOKE ALL ON TABLE purchaseline FROM PUBLIC; REVOKE ALL ON TABLE purchaseline FROM admin; GRANT ALL ON TABLE purchaseline TO admin; GRANT ALL ON TABLE purchaseline TO xtrole; apiadminfalse872i125988222purchaselinecharVIEWYCREATE VIEW purchaselinechar AS SELECT (data.order_number)::character varying AS order_number, data.line_number, data.characteristic, COALESCE(pi.charass_value, i3.charass_value) AS value FROM (((((SELECT DISTINCT "char".char_id, poitem.poitem_id, poitem.poitem_itemsite_id, pohead.pohead_number AS order_number, poitem.poitem_linenumber AS line_number, "char".char_name AS characteristic FROM public.pohead, public.poitem, public.itemsite, public.item, public.charass, public."char" WHERE ((((((pohead.pohead_id = poitem.poitem_pohead_id) AND (poitem.poitem_itemsite_id = itemsite.itemsite_id)) AND (itemsite.itemsite_item_id = item.item_id)) AND (charass.charass_char_id = "char".char_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id))) data LEFT JOIN public.charass pi ON ((((data.poitem_id = pi.charass_target_id) AND ('PI'::text = pi.charass_target_type)) AND (pi.charass_char_id = data.char_id)))) LEFT JOIN public.itemsite i1 ON ((data.poitem_itemsite_id = i1.itemsite_id))) LEFT JOIN public.item i2 ON ((i1.itemsite_item_id = i2.item_id))) LEFT JOIN public.charass i3 ON (((((i2.item_id = i3.charass_target_id) AND ('I'::text = i3.charass_target_type)) AND (i3.charass_char_id = data.char_id)) AND i3.charass_default))) ORDER BY (data.order_number)::character varying, data.line_number, data.characteristic; DROP VIEW api.purchaselinechar; apiadminfalse89616'00VIEW purchaselinecharCOMMENTOCOMMENT ON VIEW purchaselinechar IS 'Purchase Order Line Item Characteristic'; apiadminfalse873'00purchaselinecharACLREVOKE ALL ON TABLE purchaselinechar FROM PUBLIC; REVOKE ALL ON TABLE purchaselinechar FROM admin; GRANT ALL ON TABLE purchaselinechar TO admin; GRANT ALL ON TABLE purchaselinechar TO xtrole; apiadminfalse873j125988232purchaselinecommentVIEWuCREATE VIEW purchaselinecomment AS SELECT (pohead.pohead_number)::character varying AS order_number, poitem.poitem_linenumber AS line_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.pohead, public.poitem, public.cmnttype, public.comment WHERE ((((pohead.pohead_id = poitem.poitem_pohead_id) AND (comment.comment_source = 'PI'::text)) AND (comment.comment_source_id = poitem.poitem_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)) ORDER BY pohead.pohead_number, poitem.poitem_linenumber, comment.comment_date DESC; #DROP VIEW api.purchaselinecomment; apiadminfalse89656'00VIEW purchaselinecommentCOMMENTKCOMMENT ON VIEW purchaselinecomment IS 'Purchase Order Line Item Comment'; apiadminfalse874'00purchaselinecommentACLREVOKE ALL ON TABLE purchaselinecomment FROM PUBLIC; REVOKE ALL ON TABLE purchaselinecomment FROM admin; GRANT ALL ON TABLE purchaselinecomment TO admin; GRANT ALL ON TABLE purchaselinecomment TO xtrole; apiadminfalse874125980326taxTABLErCREATE TABLE tax ( tax_id integer DEFAULT nextval(('"tax_tax_id_seq"'::text)::regclass) NOT NULL, tax_code text NOT NULL, tax_descrip text, tax_sales_accnt_id integer, tax_taxclass_id integer, tax_taxauth_id integer, tax_basis_tax_id integer, tax_dist_accnt_id integer, CONSTRAINT tax_tax_code_check CHECK ((tax_code <> ''::text)) ); DROP TABLE public.tax; publicadminfalse629062918'00 TABLE taxCOMMENT+COMMENT ON TABLE tax IS 'Tax information'; publicadminfalse275'00COLUMN tax.tax_sales_accnt_idCOMMENTNCOMMENT ON COLUMN tax.tax_sales_accnt_id IS 'Deprecated column - DO NOT USE'; publicadminfalse275'00taxACLREVOKE ALL ON TABLE tax FROM PUBLIC; REVOKE ALL ON TABLE tax FROM admin; GRANT ALL ON TABLE tax TO admin; GRANT ALL ON TABLE tax TO xtrole; publicadminfalse275125980334 vendaddrinfoTABLEFCREATE TABLE vendaddrinfo ( vendaddr_id integer DEFAULT nextval(('vendaddr_vendaddr_id_seq'::text)::regclass) NOT NULL, vendaddr_vend_id integer, vendaddr_code text, vendaddr_name text, vendaddr_comments text, vendaddr_cntct_id integer, vendaddr_addr_id integer, vendaddr_taxzone_id integer ); DROP TABLE public.vendaddrinfo; publicadminfalse62928'00TABLE vendaddrinfoCOMMENT?COMMENT ON TABLE vendaddrinfo IS 'Vendor Address information'; publicadminfalse276'00 vendaddrinfoACLREVOKE ALL ON TABLE vendaddrinfo FROM PUBLIC; REVOKE ALL ON TABLE vendaddrinfo FROM admin; GRANT ALL ON TABLE vendaddrinfo TO admin; GRANT ALL ON TABLE vendaddrinfo TO xtrole; publicadminfalse276k125988241 purchaseorderVIEWCREATE VIEW purchaseorder AS SELECT (pohead.pohead_number)::character varying AS order_number, pohead.pohead_orderdate AS order_date, terms.terms_code AS terms, taxzone.taxzone_code AS tax_zone, whsinfo.warehous_code AS receiving_site, pohead.pohead_agent_username AS purchasing_agent, vendinfo.vend_number AS vendor_number, COALESCE(ua.vendaddr_code, 'MAIN'::text) AS alt_address, pohead.pohead_fob AS fob, pohead.pohead_shipvia AS ship_via, curr_symbol.curr_abbr AS currency, (SELECT COALESCE(sum(data.tax), 0.00) AS tax FROM (SELECT round(sum(calculatetaxdetailsummary.taxdetail_tax), 2) AS tax FROM (public.tax JOIN public.calculatetaxdetailsummary('PO'::text, pohead.pohead_id, 'T'::text) calculatetaxdetailsummary(taxdetail_tax_id, taxdetail_tax_code, taxdetail_tax_descrip, taxdetail_tax_basis_tax_id, taxdetail_taxrate_percent, taxdetail_taxrate_amount, taxdetail_level, taxdetail_taxclass_id, taxdetail_taxclass_code, taxdetail_taxclass_sequence, taxdetail_tax, taxdetail_curr_id, taxdetail_curr_abbr) ON ((calculatetaxdetailsummary.taxdetail_tax_id = tax.tax_id))) GROUP BY tax.tax_id) data) AS tax, pohead.pohead_freight AS freight, pohead.pohead_comments AS notes, pohead.pohead_dropship AS dropship, vc.cntct_number AS vend_contact_number, pohead.pohead_vend_cntct_honorific AS vend_cntct_honorific, pohead.pohead_vend_cntct_first_name AS vend_cntct_first_name, pohead.pohead_vend_cntct_middle AS vend_cntct_middle, pohead.pohead_vend_cntct_last_name AS vend_cntct_last_name, pohead.pohead_vend_cntct_suffix AS vend_cntct_suffix, pohead.pohead_vend_cntct_phone AS vend_cntct_phone, pohead.pohead_vend_cntct_title AS vend_cntct_title, pohead.pohead_vend_cntct_fax AS vend_cntct_fax, pohead.pohead_vend_cntct_email AS vend_cntct_email, pohead.pohead_vendaddress1 AS vendaddress1, pohead.pohead_vendaddress2 AS vendaddress2, pohead.pohead_vendaddress3 AS vendaddress3, pohead.pohead_vendcity AS vendcity, pohead.pohead_vendstate AS vendstate, pohead.pohead_vendzipcode AS vendzipcode, pohead.pohead_vendcountry AS vendcountry, sc.cntct_number AS shipto_contact_number, pohead.pohead_shipto_cntct_honorific AS shipto_cntct_honorific, pohead.pohead_shipto_cntct_first_name AS shipto_cntct_first_name, pohead.pohead_shipto_cntct_middle AS shipto_cntct_middle, pohead.pohead_shipto_cntct_last_name AS shipto_cntct_last_name, pohead.pohead_shipto_cntct_suffix AS shipto_cntct_suffix, pohead.pohead_shipto_cntct_phone AS shipto_cntct_phone, pohead.pohead_shipto_cntct_title AS shipto_cntct_title, pohead.pohead_shipto_cntct_fax AS shipto_cntct_fax, pohead.pohead_shipto_cntct_email AS shipto_cntct_email, addr.addr_number AS shiptoaddress_number, pohead.pohead_shiptoaddress1 AS shiptoaddress1, pohead.pohead_shiptoaddress2 AS shiptoaddress2, pohead.pohead_shiptoaddress3 AS shiptoaddress3, pohead.pohead_shiptocity AS shiptocity, pohead.pohead_shiptostate AS shiptostate, pohead.pohead_shiptozipcode AS shiptozipcode, pohead.pohead_shiptocountry AS shiptocountry, cohead.cohead_number AS sales_order_number FROM ((((((((((public.pohead LEFT JOIN public.cntct vc ON ((pohead.pohead_vend_cntct_id = vc.cntct_id))) LEFT JOIN public.cntct sc ON ((pohead.pohead_shipto_cntct_id = sc.cntct_id))) LEFT JOIN public.addr ON ((pohead.pohead_shiptoaddress_id = addr.addr_id))) LEFT JOIN public.terms ON ((pohead.pohead_terms_id = terms.terms_id))) LEFT JOIN public.taxzone ON ((pohead.pohead_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.whsinfo ON ((pohead.pohead_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.vendaddrinfo ua ON ((pohead.pohead_vendaddr_id = ua.vendaddr_id))) LEFT JOIN public.cohead ON ((pohead.pohead_cohead_id = cohead.cohead_id))) JOIN public.vendinfo ON ((pohead.pohead_vend_id = vendinfo.vend_id))) JOIN public.curr_symbol ON ((pohead.pohead_curr_id = curr_symbol.curr_id))) ORDER BY pohead.pohead_number; DROP VIEW api.purchaseorder; apiadminfalse89696'00VIEW purchaseorderCOMMENT3COMMENT ON VIEW purchaseorder IS 'Purchase Order'; apiadminfalse875'00 purchaseorderACLREVOKE ALL ON TABLE purchaseorder FROM PUBLIC; REVOKE ALL ON TABLE purchaseorder FROM admin; GRANT ALL ON TABLE purchaseorder TO admin; GRANT ALL ON TABLE purchaseorder TO xtrole; apiadminfalse875l125988251purchaseordercommentVIEWCREATE VIEW purchaseordercomment AS SELECT (pohead.pohead_number)::character varying AS order_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.pohead, public.cmnttype, public.comment WHERE (((comment.comment_source = 'P'::text) AND (comment.comment_source_id = pohead.pohead_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); $DROP VIEW api.purchaseordercomment; apiadminfalse89736'00VIEW purchaseordercommentCOMMENTBCOMMENT ON VIEW purchaseordercomment IS 'Purchase Order Comment'; apiadminfalse876'00purchaseordercommentACLREVOKE ALL ON TABLE purchaseordercomment FROM PUBLIC; REVOKE ALL ON TABLE purchaseordercomment FROM admin; GRANT ALL ON TABLE purchaseordercomment TO admin; GRANT ALL ON TABLE purchaseordercomment TO xtrole; apiadminfalse876125980350quheadTABLE CREATE TABLE quhead ( quhead_id integer DEFAULT nextval(('"quhead_quhead_id_seq"'::text)::regclass) NOT NULL, quhead_number text NOT NULL, quhead_cust_id integer NOT NULL, quhead_quotedate date, quhead_shipto_id integer, quhead_shiptoname text, quhead_shiptoaddress1 text, quhead_shiptoaddress2 text, quhead_shiptoaddress3 text, quhead_shiptocity text, quhead_shiptostate text, quhead_shiptozipcode text, quhead_shiptophone text, quhead_salesrep_id integer, quhead_terms_id integer, quhead_freight numeric(16,4), quhead_ordercomments text, quhead_shipcomments text, quhead_billtoname text, quhead_billtoaddress1 text, quhead_billtoaddress2 text, quhead_billtoaddress3 text, quhead_billtocity text, quhead_billtostate text, quhead_billtozip text, quhead_commission numeric(16,4), quhead_custponumber text, quhead_fob text, quhead_shipvia text, quhead_warehous_id integer, quhead_packdate date, quhead_prj_id integer, quhead_misc numeric(16,4) DEFAULT 0 NOT NULL, quhead_misc_accnt_id integer, quhead_misc_descrip text, quhead_billtocountry text, quhead_shiptocountry text, quhead_curr_id integer DEFAULT basecurrid(), quhead_imported boolean DEFAULT false, quhead_expire date, quhead_calcfreight boolean DEFAULT false NOT NULL, quhead_shipto_cntct_id integer, quhead_shipto_cntct_honorific text, quhead_shipto_cntct_first_name text, quhead_shipto_cntct_middle text, quhead_shipto_cntct_last_name text, quhead_shipto_cntct_suffix text, quhead_shipto_cntct_phone text, quhead_shipto_cntct_title text, quhead_shipto_cntct_fax text, quhead_shipto_cntct_email text, quhead_billto_cntct_id integer, quhead_billto_cntct_honorific text, quhead_billto_cntct_first_name text, quhead_billto_cntct_middle text, quhead_billto_cntct_last_name text, quhead_billto_cntct_suffix text, quhead_billto_cntct_phone text, quhead_billto_cntct_title text, quhead_billto_cntct_fax text, quhead_billto_cntct_email text, quhead_taxzone_id integer, quhead_taxtype_id integer, quhead_ophead_id integer, quhead_status text, quhead_saletype_id integer, quhead_shipzone_id integer, CONSTRAINT quhead_check CHECK ((((quhead_misc = (0)::numeric) AND (quhead_misc_accnt_id IS NULL)) OR ((quhead_misc <> (0)::numeric) AND (quhead_misc_accnt_id IS NOT NULL)))), CONSTRAINT quhead_quhead_number_check CHECK ((quhead_number <> ''::text)), CONSTRAINT quhead_quhead_status_check CHECK ((((quhead_status = 'O'::text) OR (quhead_status = 'C'::text)) OR (quhead_status = 'X'::text))) ); DROP TABLE public.quhead; publicadminfalse629362946295629662976298629963008'00 TABLE quheadCOMMENT7COMMENT ON TABLE quhead IS 'Quote header information'; publicadminfalse277'00 COLUMN quhead.quhead_saletype_idCOMMENTRCOMMENT ON COLUMN quhead.quhead_saletype_id IS 'Associated sale type for quote.'; publicadminfalse277'00 COLUMN quhead.quhead_shipzone_idCOMMENTVCOMMENT ON COLUMN quhead.quhead_shipzone_id IS 'Associated shipping zone for quote.'; publicadminfalse277'00quheadACLREVOKE ALL ON TABLE quhead FROM PUBLIC; REVOKE ALL ON TABLE quhead FROM admin; GRANT ALL ON TABLE quhead TO admin; GRANT ALL ON TABLE quhead TO xtrole; publicadminfalse277m125988258quoteVIEW CREATE VIEW quote AS SELECT (quhead.quhead_number)::character varying AS quote_number, whsinfo.warehous_code AS site, quhead.quhead_quotedate AS quote_date, quhead.quhead_packdate AS pack_date, saletype.saletype_code AS sale_type, salesrep.salesrep_number AS sales_rep, quhead.quhead_commission AS commission, taxzone.taxzone_code AS tax_zone, taxtype.taxtype_name AS tax_type, terms.terms_code AS terms, prj.prj_number AS project_number, COALESCE(custinfo.cust_number, prospect.prospect_number) AS customer_number, quhead.quhead_billtoname AS billto_name, quhead.quhead_billtoaddress1 AS billto_address1, quhead.quhead_billtoaddress2 AS billto_address2, quhead.quhead_billtoaddress3 AS billto_address3, quhead.quhead_billtocity AS billto_city, quhead.quhead_billtostate AS billto_state, quhead.quhead_billtozip AS billto_postal_code, quhead.quhead_billtocountry AS billto_country, shiptoinfo.shipto_num AS shipto_number, quhead.quhead_shiptoname AS shipto_name, quhead.quhead_shiptophone AS shipto_phone, quhead.quhead_shiptoaddress1 AS shipto_address1, quhead.quhead_shiptoaddress2 AS shipto_address2, quhead.quhead_shiptoaddress3 AS shipto_address3, quhead.quhead_shiptocity AS shipto_city, quhead.quhead_shiptostate AS shipto_state, quhead.quhead_shiptozipcode AS shipto_postal_code, quhead.quhead_shiptocountry AS shipto_country, shipzone.shipzone_name AS shipto_shipzone, quhead.quhead_custponumber AS cust_po_number, quhead.quhead_fob AS fob, quhead.quhead_shipvia AS ship_via, curr_symbol.curr_abbr AS currency, quhead.quhead_misc_descrip AS misc_charge_description, CASE WHEN (quhead.quhead_misc_accnt_id IS NULL) THEN NULL::text ELSE public.formatglaccount(quhead.quhead_misc_accnt_id) END AS misc_account_number, quhead.quhead_misc AS misc_charge, quhead.quhead_freight AS freight, quhead.quhead_ordercomments AS order_notes, quhead.quhead_shipcomments AS shipping_notes, false AS add_to_packing_list_batch, quhead.quhead_expire AS expire_date, CASE WHEN (quhead.quhead_status = 'C'::text) THEN 'Converted'::text ELSE 'Open'::text END AS status FROM public.curr_symbol, (((((((((((public.quhead LEFT JOIN public.whsinfo ON ((quhead.quhead_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.prj ON ((quhead.quhead_prj_id = prj.prj_id))) LEFT JOIN public.shiptoinfo ON ((quhead.quhead_shipto_id = shiptoinfo.shipto_id))) LEFT JOIN public.taxzone ON ((quhead.quhead_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.taxtype ON ((quhead.quhead_taxtype_id = taxtype.taxtype_id))) LEFT JOIN public.custinfo ON ((quhead.quhead_cust_id = custinfo.cust_id))) LEFT JOIN public.prospect ON ((quhead.quhead_cust_id = prospect.prospect_id))) LEFT JOIN public.salesrep ON ((quhead.quhead_salesrep_id = salesrep.salesrep_id))) LEFT JOIN public.terms ON ((quhead.quhead_terms_id = terms.terms_id))) LEFT JOIN public.saletype ON ((quhead.quhead_saletype_id = saletype.saletype_id))) LEFT JOIN public.shipzone ON ((quhead.quhead_shipzone_id = shipzone.shipzone_id))) WHERE (quhead.quhead_curr_id = curr_symbol.curr_id); DROP VIEW api.quote; apiadminfalse89776'00 VIEW quoteCOMMENT"COMMENT ON VIEW quote IS 'Quote'; apiadminfalse877'00quoteACLREVOKE ALL ON TABLE quote FROM PUBLIC; REVOKE ALL ON TABLE quote FROM admin; GRANT ALL ON TABLE quote TO admin; GRANT ALL ON TABLE quote TO xtrole; apiadminfalse877n125988268 quotecommentVIEWCREATE VIEW quotecomment AS SELECT quhead.quhead_number AS quote_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.quhead, public.cmnttype, public.comment WHERE (((comment.comment_source = 'Q'::text) AND (comment.comment_source_id = quhead.quhead_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); DROP VIEW api.quotecomment; apiadminfalse89816'00VIEW quotecommentCOMMENT1COMMENT ON VIEW quotecomment IS 'Quote Comment'; apiadminfalse878'00 quotecommentACLREVOKE ALL ON TABLE quotecomment FROM PUBLIC; REVOKE ALL ON TABLE quotecomment FROM admin; GRANT ALL ON TABLE quotecomment TO admin; GRANT ALL ON TABLE quotecomment TO xtrole; apiadminfalse878125980373quitemTABLE9CREATE TABLE quitem ( quitem_id integer DEFAULT nextval(('"quitem_quitem_id_seq"'::text)::regclass) NOT NULL, quitem_quhead_id integer, quitem_linenumber integer, quitem_itemsite_id integer, quitem_scheddate date, quitem_qtyord numeric(18,6), quitem_unitcost numeric(16,6), quitem_price numeric(16,4), quitem_custprice numeric(16,4), quitem_memo text, quitem_custpn text, quitem_createorder boolean, quitem_order_warehous_id integer, quitem_item_id integer, quitem_prcost numeric(16,6), quitem_imported boolean DEFAULT false, quitem_qty_uom_id integer NOT NULL, quitem_qty_invuomratio numeric(20,10) NOT NULL, quitem_price_uom_id integer NOT NULL, quitem_price_invuomratio numeric(20,10) NOT NULL, quitem_promdate date, quitem_taxtype_id integer, quitem_dropship boolean DEFAULT false, quitem_itemsrc_id integer, quitem_pricemode character(1) DEFAULT 'D'::bpchar NOT NULL, CONSTRAINT valid_quitem_pricemode CHECK ((quitem_pricemode = ANY (ARRAY['D'::bpchar, 'M'::bpchar]))) ); DROP TABLE public.quitem; publicadminfalse630163026303630463058'00 TABLE quitemCOMMENT:COMMENT ON TABLE quitem IS 'Quote Line Item information'; publicadminfalse278'00COLUMN quitem.quitem_pricemodeCOMMENTxCOMMENT ON COLUMN quitem.quitem_pricemode IS 'Pricing mode for quote item. Valid values are D-discount, and M-markup'; publicadminfalse278'00quitemACLREVOKE ALL ON TABLE quitem FROM PUBLIC; REVOKE ALL ON TABLE quitem FROM admin; GRANT ALL ON TABLE quitem TO admin; GRANT ALL ON TABLE quitem TO xtrole; publicadminfalse278o125988275 quotelineVIEWCREATE VIEW quoteline AS SELECT quhead.quhead_number AS quote_number, quitem.quitem_linenumber AS line_number, l.item_number, quitem.quitem_custpn AS customer_pn, i.warehous_code AS sold_from_site, quitem.quitem_qtyord AS qty_ordered, q.uom_name AS qty_uom, quitem.quitem_price AS net_unit_price, p.uom_name AS price_uom, quitem.quitem_scheddate AS scheduled_date, COALESCE((SELECT taxtype.taxtype_name FROM public.taxtype WHERE (taxtype.taxtype_id = public.getitemtaxtype(l.item_id, quhead.quhead_taxzone_id))), 'None'::text) AS tax_type, CASE WHEN (quitem.quitem_price = (0)::numeric) THEN '100'::text WHEN (quitem.quitem_custprice = (0)::numeric) THEN 'N/A'::text ELSE (round((((1)::numeric - (quitem.quitem_price / quitem.quitem_custprice)) * (100)::numeric), 4))::text END AS discount_pct_from_list, quitem.quitem_createorder AS create_order, s.warehous_code AS supplying_site, quitem.quitem_prcost AS overwrite_po_price, quitem.quitem_memo AS notes FROM public.quhead, public.uom q, public.uom p, (public.quitem LEFT JOIN public.whsinfo s ON ((quitem.quitem_order_warehous_id = s.warehous_id))), public.itemsite il, public.item l, public.whsinfo i WHERE ((((((quhead.quhead_id = quitem.quitem_quhead_id) AND (quitem.quitem_itemsite_id = il.itemsite_id)) AND (il.itemsite_item_id = l.item_id)) AND (il.itemsite_warehous_id = i.warehous_id)) AND (quitem.quitem_qty_uom_id = q.uom_id)) AND (quitem.quitem_price_uom_id = p.uom_id)) ORDER BY quhead.quhead_number, quitem.quitem_linenumber; DROP VIEW api.quoteline; apiadminfalse89856'00VIEW quotelineCOMMENT0COMMENT ON VIEW quoteline IS 'Quote Line Item'; apiadminfalse879'00 quotelineACLREVOKE ALL ON TABLE quoteline FROM PUBLIC; REVOKE ALL ON TABLE quoteline FROM admin; GRANT ALL ON TABLE quoteline TO admin; GRANT ALL ON TABLE quoteline TO xtrole; apiadminfalse879p125988285 quotelinecharVIEWCREATE VIEW quotelinechar AS SELECT DISTINCT quhead.quhead_number AS quote_number, quitem.quitem_linenumber AS line_number, "char".char_name AS characteristic, COALESCE((SELECT b.charass_value FROM public.charass b WHERE (((b.charass_target_type = 'QI'::text) AND (b.charass_target_id = quitem.quitem_id)) AND (b.charass_char_id = "char".char_id))), (SELECT c.charass_value FROM public.charass c WHERE ((((c.charass_target_type = 'I'::text) AND (c.charass_target_id = item.item_id)) AND c.charass_default) AND (c.charass_char_id = "char".char_id)) LIMIT 1)) AS value FROM public.quhead, public.quitem, public.itemsite, public.item, public.charass a, public."char" WHERE ((((((quhead.quhead_id = quitem.quitem_quhead_id) AND (quitem.quitem_itemsite_id = itemsite.itemsite_id)) AND (itemsite.itemsite_item_id = item.item_id)) AND (a.charass_char_id = "char".char_id)) AND (a.charass_target_type = 'I'::text)) AND (a.charass_target_id = item.item_id)) ORDER BY quhead.quhead_number, quitem.quitem_linenumber, "char".char_name; DROP VIEW api.quotelinechar; apiadminfalse89896'00VIEW quotelinecharCOMMENTDCOMMENT ON VIEW quotelinechar IS 'Quote Line Item Characteristics'; apiadminfalse880'00 quotelinecharACLREVOKE ALL ON TABLE quotelinechar FROM PUBLIC; REVOKE ALL ON TABLE quotelinechar FROM admin; GRANT ALL ON TABLE quotelinechar TO admin; GRANT ALL ON TABLE quotelinechar TO xtrole; apiadminfalse880q125988295quotelinecommentVIEW]CREATE VIEW quotelinecomment AS SELECT quhead.quhead_number AS quote_number, quitem.quitem_linenumber AS line_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.quhead, public.quitem, public.cmnttype, public.comment WHERE ((((quhead.quhead_id = quitem.quitem_quhead_id) AND (comment.comment_source = 'QI'::text)) AND (comment.comment_source_id = quitem.quitem_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)) ORDER BY quhead.quhead_number, quitem.quitem_linenumber, comment.comment_date DESC; DROP VIEW api.quotelinecomment; apiadminfalse89936'00VIEW quotelinecommentCOMMENT?COMMENT ON VIEW quotelinecomment IS 'Quote Line Item Comment'; apiadminfalse881'00quotelinecommentACLREVOKE ALL ON TABLE quotelinecomment FROM PUBLIC; REVOKE ALL ON TABLE quotelinecomment FROM admin; GRANT ALL ON TABLE quotelinecomment TO admin; GRANT ALL ON TABLE quotelinecomment TO xtrole; apiadminfalse881125980399 aropenallocTABLECREATE TABLE aropenalloc ( aropenalloc_aropen_id integer NOT NULL, aropenalloc_doctype character(1) NOT NULL, aropenalloc_doc_id integer NOT NULL, aropenalloc_amount numeric(20,2) DEFAULT 0.00 NOT NULL, aropenalloc_curr_id integer DEFAULT basecurrid() ); DROP TABLE public.aropenalloc; publicadminfalse630663078'00 aropenallocACLREVOKE ALL ON TABLE aropenalloc FROM PUBLIC; REVOKE ALL ON TABLE aropenalloc FROM admin; GRANT ALL ON TABLE aropenalloc TO admin; GRANT ALL ON TABLE aropenalloc TO xtrole; publicadminfalse279r125988303 salescreditVIEWCREATE VIEW salescredit AS SELECT custinfo.cust_number AS customer_number, aropen.aropen_docnumber AS cm_number, cohead.cohead_number AS so_number, (aropenalloc.aropenalloc_amount)::numeric(16,4) AS amount, curr.curr_abbr AS currency FROM ((((public.aropenalloc LEFT JOIN public.aropen ON ((aropen.aropen_id = aropenalloc.aropenalloc_aropen_id))) LEFT JOIN public.custinfo ON ((custinfo.cust_id = aropen.aropen_cust_id))) LEFT JOIN public.cohead ON (((aropenalloc.aropenalloc_doctype = 'S'::bpchar) AND (cohead.cohead_id = aropenalloc.aropenalloc_doc_id)))) LEFT JOIN public.curr_symbol curr ON ((curr.curr_id = aropenalloc.aropenalloc_curr_id))) WHERE (aropenalloc.aropenalloc_doctype = 'S'::bpchar); DROP VIEW api.salescredit; apiadminfalse89976'00VIEW salescreditCOMMENTVCOMMENT ON VIEW salescredit IS 'Payments (credit memos) pre-applied to sales orders'; apiadminfalse882'00 salescreditACLREVOKE ALL ON TABLE salescredit FROM PUBLIC; REVOKE ALL ON TABLE salescredit FROM admin; GRANT ALL ON TABLE salescredit TO admin; GRANT ALL ON TABLE salescredit TO xtrole; apiadminfalse882125980409cohistTABLECREATE TABLE cohist ( cohist_id integer DEFAULT nextval(('cohist_cohist_id_seq'::text)::regclass) NOT NULL, cohist_cust_id integer, cohist_itemsite_id integer, cohist_shipdate date, cohist_shipvia text, cohist_ordernumber text, cohist_orderdate date, cohist_invcnumber text, cohist_invcdate date, cohist_qtyshipped numeric(18,6), cohist_unitprice numeric(16,4), cohist_shipto_id integer, cohist_salesrep_id integer, cohist_duedate date, cohist_imported boolean DEFAULT false, cohist_billtoname text, cohist_billtoaddress1 text, cohist_billtoaddress2 text, cohist_billtoaddress3 text, cohist_billtocity text, cohist_billtostate text, cohist_billtozip text, cohist_shiptoname text, cohist_shiptoaddress1 text, cohist_shiptoaddress2 text, cohist_shiptoaddress3 text, cohist_shiptocity text, cohist_shiptostate text, cohist_shiptozip text, cohist_commission numeric(16,4), cohist_commissionpaid boolean, cohist_unitcost numeric(18,6), cohist_misc_type character(1), cohist_misc_descrip text, cohist_misc_id integer, cohist_doctype text, cohist_promisedate date, cohist_ponumber text, cohist_curr_id integer DEFAULT basecurrid(), cohist_sequence integer, cohist_taxtype_id integer, cohist_taxzone_id integer, cohist_cohead_ccpay_id integer, cohist_saletype_id integer, cohist_shipzone_id integer ); DROP TABLE public.cohist; publicadminfalse6308630963108'00 TABLE cohistCOMMENT2COMMENT ON TABLE cohist IS 'Sales Order history'; publicadminfalse280'00$COLUMN cohist.cohist_cohead_ccpay_idCOMMENTCOMMENT ON COLUMN cohist.cohist_cohead_ccpay_id IS 'Credit card payments made at sales order time (as opposed to invoice time) need special treatment. This field allows checking for this case.'; publicadminfalse280'00 COLUMN cohist.cohist_saletype_idCOMMENTZCOMMENT ON COLUMN cohist.cohist_saletype_id IS 'Associated sale type for sales history.'; publicadminfalse280'00 COLUMN cohist.cohist_shipzone_idCOMMENT^COMMENT ON COLUMN cohist.cohist_shipzone_id IS 'Associated shipping zone for sales history.'; publicadminfalse280'00cohistACLREVOKE ALL ON TABLE cohist FROM PUBLIC; REVOKE ALL ON TABLE cohist FROM admin; GRANT ALL ON TABLE cohist TO admin; GRANT ALL ON TABLE cohist TO xtrole; publicadminfalse280125980418taxhistTABLE-CREATE TABLE taxhist ( taxhist_id integer NOT NULL, taxhist_parent_id integer NOT NULL, taxhist_taxtype_id integer, taxhist_tax_id integer NOT NULL, taxhist_basis numeric(16,2) NOT NULL, taxhist_basis_tax_id integer, taxhist_sequence integer, taxhist_percent numeric(10,6) NOT NULL, taxhist_amount numeric(16,2) NOT NULL, taxhist_tax numeric(16,6) NOT NULL, taxhist_docdate date NOT NULL, taxhist_distdate date, taxhist_curr_id integer, taxhist_curr_rate numeric, taxhist_journalnumber integer ); DROP TABLE public.taxhist; publicadminfalse8'00 TABLE taxhistCOMMENTCOMMENT ON TABLE taxhist IS 'A table type to record tax transaction history. Inherited by other tables that actually record history. As the parent, queries can be run against it that will join all child tables. '; publicadminfalse281'00COLUMN taxhist.taxhist_idCOMMENT7COMMENT ON COLUMN taxhist.taxhist_id IS 'Primary key'; publicadminfalse281'00 COLUMN taxhist.taxhist_parent_idCOMMENTDCOMMENT ON COLUMN taxhist.taxhist_parent_id IS 'Source parent id.'; publicadminfalse281'00!COLUMN taxhist.taxhist_taxtype_idCOMMENT?COMMENT ON COLUMN taxhist.taxhist_taxtype_id IS 'Tax type id'; publicadminfalse281'00COLUMN taxhist.taxhist_tax_idCOMMENT<COMMENT ON COLUMN taxhist.taxhist_tax_id IS 'Tax code id.'; publicadminfalse281'00COLUMN taxhist.taxhist_basisCOMMENTgCOMMENT ON COLUMN taxhist.taxhist_basis IS 'Base price amount on which the tax calculation is based.'; publicadminfalse281'00#COLUMN taxhist.taxhist_basis_tax_idCOMMENTCOMMENT ON COLUMN taxhist.taxhist_basis_tax_id IS 'Tax rate calculation basis. If null, then the amount of the parent document, otherwise calculated on the result amount of the tax code id referenced.'; publicadminfalse281'00COLUMN taxhist.taxhist_amountCOMMENT@COMMENT ON COLUMN taxhist.taxhist_amount IS 'Flat tax amount.'; publicadminfalse281'00COLUMN taxhist.taxhist_taxCOMMENTCCOMMENT ON COLUMN taxhist.taxhist_tax IS 'Calculated tax amount.'; publicadminfalse281'00COLUMN taxhist.taxhist_docdateCOMMENTQCOMMENT ON COLUMN taxhist.taxhist_docdate IS 'The date of the parent document.'; publicadminfalse281'00COLUMN taxhist.taxhist_distdateCOMMENTcCOMMENT ON COLUMN taxhist.taxhist_distdate IS 'The G/L distribution date of the parent document.'; publicadminfalse281'00taxhistACLREVOKE ALL ON TABLE taxhist FROM PUBLIC; REVOKE ALL ON TABLE taxhist FROM admin; GRANT ALL ON TABLE taxhist TO admin; GRANT ALL ON TABLE taxhist TO xtrole; publicadminfalse281125980424 cohisttaxTABLE/CREATE TABLE cohisttax ( ) INHERITS (taxhist); DROP TABLE public.cohisttax; publicadminfalse8281'00 cohisttaxACLREVOKE ALL ON TABLE cohisttax FROM PUBLIC; REVOKE ALL ON TABLE cohisttax FROM admin; GRANT ALL ON TABLE cohisttax TO admin; GRANT ALL ON TABLE cohisttax TO xtrole; publicadminfalse282s125988309 saleshistoryVIEW) CREATE VIEW saleshistory AS SELECT custinfo.cust_number AS customer_number, item.item_number, whsinfo.warehous_code AS site_code, cohist.cohist_shipdate AS ship_date, cohist.cohist_shipvia AS ship_via, cohist.cohist_ordernumber AS order_number, cohist.cohist_ponumber AS purchase_order_number, cohist.cohist_orderdate AS order_date, cohist.cohist_invcnumber AS invoice_number, cohist.cohist_invcdate AS invoice_date, cohist.cohist_qtyshipped AS quantity_shipped, cohist.cohist_unitprice AS unit_price, shiptoinfo.shipto_num AS shipto_number, salesrep.salesrep_number AS sales_rep, cohist.cohist_duedate AS due_date, cohist.cohist_promisedate AS promise_date, cohist.cohist_imported AS imported, cohist.cohist_billtoname AS billto_name, cohist.cohist_billtoaddress1 AS billto_address1, cohist.cohist_billtoaddress2 AS billto_address2, cohist.cohist_billtoaddress3 AS billto_address3, cohist.cohist_billtocity AS billto_city, cohist.cohist_billtostate AS billto_state, cohist.cohist_billtozip AS billto_zip, cohist.cohist_shiptoname AS shipto_name, cohist.cohist_shiptoaddress1 AS shipto_address1, cohist.cohist_shiptoaddress2 AS shipto_address2, cohist.cohist_shiptoaddress3 AS shipto_address3, cohist.cohist_shiptocity AS shipto_city, cohist.cohist_shiptostate AS shipto_state, cohist.cohist_shiptozip AS shipto_zip, cohist.cohist_commission AS commission, cohist.cohist_commissionpaid AS commission_paid, cohist.cohist_unitcost AS unit_cost, CASE WHEN (cohist.cohist_misc_type IS NULL) THEN ''::text WHEN (cohist.cohist_misc_type = 'M'::bpchar) THEN 'Misc. Charge'::text WHEN (cohist.cohist_misc_type = 'F'::bpchar) THEN 'Freight'::text ELSE 'Unknown'::text END AS misc_type, cohist.cohist_misc_descrip AS misc_description, CASE WHEN (cohist.cohist_misc_id IS NULL) THEN ''::text WHEN (cohist.cohist_misc_type = 'M'::bpchar) THEN public.formatglaccount(cohist.cohist_misc_id) ELSE 'Unknown'::text END AS misc_info, taxzone.taxzone_code AS tax_zone, taxtype.taxtype_name AS tax_type, CASE WHEN (cohist.cohist_doctype = 'I'::text) THEN 'Invoice'::text WHEN (cohist.cohist_doctype = 'C'::text) THEN 'Credit Memo'::text ELSE 'Unknown'::text END AS document_type, curr_symbol.curr_abbr AS currency, cohist.cohist_sequence AS gl_sequence, (SELECT sum(cohisttax.taxhist_tax) AS sum FROM public.cohisttax WHERE (cohisttax.taxhist_parent_id = cohist.cohist_id)) AS tax FROM (((((((((public.cohist LEFT JOIN public.custinfo ON ((cohist.cohist_cust_id = custinfo.cust_id))) LEFT JOIN public.shiptoinfo ON ((cohist.cohist_shipto_id = shiptoinfo.shipto_id))) LEFT JOIN public.taxzone ON ((cohist.cohist_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.taxtype ON ((cohist.cohist_taxtype_id = taxtype.taxtype_id))) LEFT JOIN public.salesrep ON ((cohist.cohist_salesrep_id = salesrep.salesrep_id))) LEFT JOIN public.itemsite ON ((cohist.cohist_itemsite_id = itemsite.itemsite_id))) LEFT JOIN public.item ON ((itemsite.itemsite_item_id = item.item_id))) LEFT JOIN public.whsinfo ON ((itemsite.itemsite_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.curr_symbol ON ((cohist.cohist_curr_id = curr_symbol.curr_id))); DROP VIEW api.saleshistory; apiadminfalse89996'00VIEW saleshistoryCOMMENT1COMMENT ON VIEW saleshistory IS 'Sales History'; apiadminfalse883'00 saleshistoryACLREVOKE ALL ON TABLE saleshistory FROM PUBLIC; REVOKE ALL ON TABLE saleshistory FROM admin; GRANT ALL ON TABLE saleshistory TO admin; GRANT ALL ON TABLE saleshistory TO xtrole; apiadminfalse883t125988320 saleslinecharVIEWCREATE VIEW saleslinechar AS SELECT (data.order_number)::character varying AS order_number, data.line_number, data.characteristic, COALESCE(si.charass_value, i3.charass_value) AS value, (COALESCE(si.charass_price, public.itemcharprice(data.item_id, data.char_id, COALESCE(si.charass_value, i3.charass_value), data.cohead_cust_id, data.cohead_shipto_id, data.coitem_qtyord, data.cohead_curr_id, data.cohead_orderdate), (0)::numeric))::numeric(16,4) AS price FROM (((((SELECT DISTINCT cohead.cohead_cust_id, cohead.cohead_shipto_id, cohead.cohead_curr_id, cohead.cohead_orderdate, coitem.coitem_id, coitem.coitem_itemsite_id, coitem.coitem_qtyord, "char".char_id, item.item_id, cohead.cohead_number AS order_number, CASE WHEN (coitem.coitem_subnumber = 0) THEN ((coitem.coitem_linenumber)::character varying)::text ELSE ((((coitem.coitem_linenumber)::character varying)::text || ('.'::character varying)::text) || ((coitem.coitem_subnumber)::character varying)::text) END AS line_number, "char".char_name AS characteristic FROM public.cohead, public.coitem, public.itemsite, public.item, public.charass, public."char" WHERE ((((((cohead.cohead_id = coitem.coitem_cohead_id) AND (coitem.coitem_itemsite_id = itemsite.itemsite_id)) AND (itemsite.itemsite_item_id = item.item_id)) AND (charass.charass_char_id = "char".char_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id))) data LEFT JOIN public.charass si ON ((((data.coitem_id = si.charass_target_id) AND ('SI'::text = si.charass_target_type)) AND (si.charass_char_id = data.char_id)))) LEFT JOIN public.itemsite i1 ON ((data.coitem_itemsite_id = i1.itemsite_id))) LEFT JOIN public.item i2 ON ((i1.itemsite_item_id = i2.item_id))) LEFT JOIN public.charass i3 ON (((((i2.item_id = i3.charass_target_id) AND ('I'::text = i3.charass_target_type)) AND (i3.charass_char_id = data.char_id)) AND i3.charass_default))) ORDER BY (data.order_number)::character varying, data.line_number, data.characteristic; DROP VIEW api.saleslinechar; apiadminfalse90036'00VIEW saleslinecharCOMMENTICOMMENT ON VIEW saleslinechar IS 'Sales Order Line Item Characteristic'; apiadminfalse884'00 saleslinecharACLREVOKE ALL ON TABLE saleslinechar FROM PUBLIC; REVOKE ALL ON TABLE saleslinechar FROM admin; GRANT ALL ON TABLE saleslinechar TO admin; GRANT ALL ON TABLE saleslinechar TO xtrole; apiadminfalse884u125988330saleslinecommentVIEWYCREATE VIEW saleslinecomment AS SELECT (cohead.cohead_number)::character varying AS order_number, CASE WHEN (coitem.coitem_subnumber = 0) THEN ((coitem.coitem_linenumber)::character varying)::text ELSE ((((coitem.coitem_linenumber)::character varying)::text || ('.'::character varying)::text) || ((coitem.coitem_subnumber)::character varying)::text) END AS line_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.cohead, public.coitem, public.cmnttype, public.comment WHERE ((((cohead.cohead_id = coitem.coitem_cohead_id) AND (comment.comment_source = 'SI'::text)) AND (comment.comment_source_id = coitem.coitem_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)) ORDER BY cohead.cohead_number, coitem.coitem_linenumber, comment.comment_date DESC; DROP VIEW api.saleslinecomment; apiadminfalse90076'00VIEW saleslinecommentCOMMENTECOMMENT ON VIEW saleslinecomment IS 'Sales Order Line Item Comment'; apiadminfalse885'00saleslinecommentACLREVOKE ALL ON TABLE saleslinecomment FROM PUBLIC; REVOKE ALL ON TABLE saleslinecomment FROM admin; GRANT ALL ON TABLE saleslinecomment TO admin; GRANT ALL ON TABLE saleslinecomment TO xtrole; apiadminfalse885v125988338 salesorderVIEW9CREATE VIEW salesorder AS SELECT (cohead.cohead_number)::character varying AS order_number, whsinfo.warehous_code AS site, cohead.cohead_orderdate AS order_date, cohead.cohead_packdate AS pack_date, saletype.saletype_code AS sale_type, salesrep.salesrep_number AS sales_rep, cohead.cohead_commission AS commission, COALESCE(taxzone.taxzone_code, 'None'::text) AS tax_zone, terms.terms_code AS terms, prj.prj_number AS project_number, custinfo.cust_number AS customer_number, bc.cntct_number AS billto_contact_number, cohead.cohead_billto_cntct_honorific AS billto_contact_name, cohead.cohead_billto_cntct_first_name AS billto_contact_first, cohead.cohead_billto_cntct_middle AS billto_contact_middle, cohead.cohead_billto_cntct_last_name AS billto_contact_last, cohead.cohead_billto_cntct_suffix AS billto_contact_suffix, cohead.cohead_billto_cntct_phone AS billto_contact_phone, cohead.cohead_billto_cntct_title AS billto_contact_title, cohead.cohead_billto_cntct_fax AS billto_contct_fax, cohead.cohead_billto_cntct_email AS billto_contact_email, cohead.cohead_billtoname AS billto_name, cohead.cohead_billtoaddress1 AS billto_address1, cohead.cohead_billtoaddress2 AS billto_address2, cohead.cohead_billtoaddress3 AS billto_address3, cohead.cohead_billtocity AS billto_city, cohead.cohead_billtostate AS billto_state, cohead.cohead_billtozipcode AS billto_postal_code, cohead.cohead_billtocountry AS billto_country, shiptoinfo.shipto_num AS shipto_number, sc.cntct_number AS shipto_contact_number, cohead.cohead_shipto_cntct_honorific AS shipto_contact_honorific, cohead.cohead_shipto_cntct_first_name AS shipto_contact_first, cohead.cohead_shipto_cntct_middle AS shipto_contact_middle, cohead.cohead_shipto_cntct_last_name AS shipto_contact_last, cohead.cohead_shipto_cntct_suffix AS shipto_contact_suffix, cohead.cohead_shipto_cntct_phone AS shipto_contact_phone, cohead.cohead_shipto_cntct_title AS shipto_contact_title, cohead.cohead_shipto_cntct_fax AS shipto_contact_fax, cohead.cohead_shipto_cntct_email AS shipto_contact_email, cohead.cohead_shiptoname AS shipto_name, cohead.cohead_shiptophone AS shipto_phone, cohead.cohead_shiptoaddress1 AS shipto_address1, cohead.cohead_shiptoaddress2 AS shipto_address2, cohead.cohead_shiptoaddress3 AS shipto_address3, cohead.cohead_shiptocity AS shipto_city, cohead.cohead_shiptostate AS shipto_state, cohead.cohead_shiptozipcode AS shipto_postal_code, cohead.cohead_shiptocountry AS shipto_country, shipzone.shipzone_name AS shipto_shipzone, cohead.cohead_custponumber AS cust_po_number, cohead.cohead_fob AS fob, cohead.cohead_shipvia AS ship_via, CASE WHEN (cohead.cohead_holdtype = 'N'::bpchar) THEN 'None'::text WHEN (cohead.cohead_holdtype = 'C'::bpchar) THEN 'Credit'::text WHEN (cohead.cohead_holdtype = 'S'::bpchar) THEN 'Shipping'::text WHEN (cohead.cohead_holdtype = 'P'::bpchar) THEN 'Packing'::text WHEN (cohead.cohead_holdtype = 'R'::bpchar) THEN 'Return'::text ELSE 'Error'::text END AS hold_type, shipchrg.shipchrg_name AS shipping_chgs, shipform.shipform_name AS shipping_form, cohead.cohead_shipcomplete AS ship_complete, curr_symbol.curr_abbr AS currency, cohead.cohead_misc_descrip AS misc_charge_description, CASE WHEN (cohead.cohead_misc_accnt_id IS NULL) THEN NULL::text ELSE public.formatglaccount(cohead.cohead_misc_accnt_id) END AS misc_account_number, cohead.cohead_misc AS misc_charge, cohead.cohead_freight AS freight, cohead.cohead_calcfreight AS calculate_freight, cohead.cohead_ordercomments AS order_notes, cohead.cohead_shipcomments AS shipping_notes, false AS add_to_packing_list_batch FROM (((((((((public.cohead LEFT JOIN public.cntct bc ON ((cohead.cohead_billto_cntct_id = bc.cntct_id))) LEFT JOIN public.cntct sc ON ((cohead.cohead_shipto_cntct_id = sc.cntct_id))) LEFT JOIN public.whsinfo ON ((cohead.cohead_warehous_id = whsinfo.warehous_id))) LEFT JOIN public.prj ON ((cohead.cohead_prj_id = prj.prj_id))) LEFT JOIN public.shiptoinfo ON ((cohead.cohead_shipto_id = shiptoinfo.shipto_id))) LEFT JOIN public.shipchrg ON ((cohead.cohead_shipchrg_id = shipchrg.shipchrg_id))) LEFT JOIN public.taxzone ON ((cohead.cohead_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.saletype ON ((cohead.cohead_saletype_id = saletype.saletype_id))) LEFT JOIN public.shipzone ON ((cohead.cohead_shipzone_id = shipzone.shipzone_id))), public.custinfo, public.shipform, public.salesrep, public.terms, public.curr_symbol WHERE (((((cohead.cohead_cust_id = custinfo.cust_id) AND (cohead.cohead_shipform_id = shipform.shipform_id)) AND (cohead.cohead_salesrep_id = salesrep.salesrep_id)) AND (cohead.cohead_terms_id = terms.terms_id)) AND (cohead.cohead_curr_id = curr_symbol.curr_id)); DROP VIEW api.salesorder; apiadminfalse90116'00VIEW salesorderCOMMENT-COMMENT ON VIEW salesorder IS 'Sales Order'; apiadminfalse886'00 salesorderACLREVOKE ALL ON TABLE salesorder FROM PUBLIC; REVOKE ALL ON TABLE salesorder FROM admin; GRANT ALL ON TABLE salesorder TO admin; GRANT ALL ON TABLE salesorder TO xtrole; apiadminfalse886w125988349salesordercommentVIEWCREATE VIEW salesordercomment AS SELECT (cohead.cohead_number)::character varying AS order_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.cohead, public.cmnttype, public.comment WHERE (((comment.comment_source = 'S'::text) AND (comment.comment_source_id = cohead.cohead_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); !DROP VIEW api.salesordercomment; apiadminfalse90156'00VIEW salesordercommentCOMMENT<COMMENT ON VIEW salesordercomment IS 'Sales Order Comment'; apiadminfalse887'00salesordercommentACLREVOKE ALL ON TABLE salesordercomment FROM PUBLIC; REVOKE ALL ON TABLE salesordercomment FROM admin; GRANT ALL ON TABLE salesordercomment TO admin; GRANT ALL ON TABLE salesordercomment TO xtrole; apiadminfalse887x125988357salesrepVIEW~CREATE VIEW salesrep AS SELECT (salesrep.salesrep_number)::character varying AS number, salesrep.salesrep_active AS active, salesrep.salesrep_name AS name, (salesrep.salesrep_commission * (100)::numeric) AS commission_percent, emp.emp_number AS employee FROM (public.salesrep LEFT JOIN public.emp ON ((emp.emp_id = salesrep.salesrep_emp_id))) ORDER BY salesrep.salesrep_number; DROP VIEW api.salesrep; apiadminfalse90196'00 VIEW salesrepCOMMENT)COMMENT ON VIEW salesrep IS 'Sales Rep'; apiadminfalse888'00salesrepACLREVOKE ALL ON TABLE salesrep FROM PUBLIC; REVOKE ALL ON TABLE salesrep FROM admin; GRANT ALL ON TABLE salesrep TO admin; GRANT ALL ON TABLE salesrep TO xtrole; apiadminfalse888125980460shipviaTABLECREATE TABLE shipvia ( shipvia_id integer DEFAULT nextval(('shipvia_shipvia_id_seq'::text)::regclass) NOT NULL, shipvia_code text NOT NULL, shipvia_descrip text, CONSTRAINT shipvia_shipvia_code_check CHECK ((shipvia_code <> ''::text)) ); DROP TABLE public.shipvia; publicadminfalse631363148'00 TABLE shipviaCOMMENT4COMMENT ON TABLE shipvia IS 'Ship Via information'; publicadminfalse283'00shipviaACLREVOKE ALL ON TABLE shipvia FROM PUBLIC; REVOKE ALL ON TABLE shipvia FROM admin; GRANT ALL ON TABLE shipvia TO admin; GRANT ALL ON TABLE shipvia TO xtrole; publicadminfalse283125980468sitetypeTABLECREATE TABLE sitetype ( sitetype_id integer NOT NULL, sitetype_name text NOT NULL, sitetype_descrip text, CONSTRAINT sitetype_sitetype_name_check CHECK ((sitetype_name <> ''::text)) ); DROP TABLE public.sitetype; publicadminfalse63168'00TABLE sitetypeCOMMENTLCOMMENT ON TABLE sitetype IS 'This table is the different types of sites.'; publicadminfalse284'00sitetypeACLREVOKE ALL ON TABLE sitetype FROM PUBLIC; REVOKE ALL ON TABLE sitetype FROM admin; GRANT ALL ON TABLE sitetype TO admin; GRANT ALL ON TABLE sitetype TO xtrole; publicadminfalse284y125988365siteVIEWCREATE VIEW site AS SELECT (whsinfo.warehous_code)::character varying AS code, st.sitetype_name AS type, whsinfo.warehous_active AS active, whsinfo.warehous_descrip AS description, m.addr_number AS address_number, m.addr_line1 AS address1, m.addr_line2 AS address2, m.addr_line3 AS address3, m.addr_city AS city, m.addr_state AS state, m.addr_postalcode AS postal_code, m.addr_country AS country, ''::text AS address_change, c.cntct_number AS contact_number, c.cntct_honorific AS honorific, c.cntct_first_name AS first, c.cntct_middle AS middle, c.cntct_last_name AS last, c.cntct_suffix AS suffix, c.cntct_title AS job_title, c.cntct_phone AS phone, c.cntct_fax AS fax, c.cntct_email AS email, ''::text AS contact_change, public.formatglaccount(a.accnt_id) AS post_unassigned_transactions_to, a.accnt_descrip AS post_unassigned_transactions_to_description, whsinfo.warehous_transit AS transit_type, CASE WHEN whsinfo.warehous_transit THEN false ELSE true END AS inventory_type, CASE WHEN whsinfo.warehous_transit THEN ''::text ELSE whsinfo.warehous_bol_prefix END AS next_bill_of_lading_prefix, CASE WHEN whsinfo.warehous_transit THEN 0 ELSE whsinfo.warehous_bol_number END AS next_bill_of_lading_number, CASE WHEN whsinfo.warehous_transit THEN false ELSE whsinfo.warehous_shipping END AS shipping_site, CASE WHEN whsinfo.warehous_transit THEN ''::text ELSE whsinfo.warehous_counttag_prefix END AS next_count_tag_prefix, CASE WHEN whsinfo.warehous_transit THEN 0 ELSE whsinfo.warehous_counttag_number END AS next_count_tag_number, CASE WHEN whsinfo.warehous_transit THEN false ELSE whsinfo.warehous_useslips END AS force_the_use_of_count_slips, CASE WHEN whsinfo.warehous_transit THEN false ELSE whsinfo.warehous_usezones END AS force_the_use_of_zones, CASE WHEN whsinfo.warehous_transit THEN 0 ELSE whsinfo.warehous_sequence END AS scheduling_sequence, CASE WHEN whsinfo.warehous_transit THEN (0)::numeric ELSE (whsinfo.warehous_shipping_commission * 100.0) END AS shipping_commission, CASE WHEN whsinfo.warehous_transit THEN ''::text ELSE t.taxzone_code END AS tax_zone, CASE WHEN whsinfo.warehous_transit THEN ''::text ELSE whsinfo.warehous_fob END AS default_fob, CASE WHEN whsinfo.warehous_transit THEN s.shipvia_code ELSE ''::text END AS default_ship_via, CASE WHEN whsinfo.warehous_transit THEN f.shipform_name ELSE ''::text END AS default_shipping_form, CASE WHEN whsinfo.warehous_transit THEN cc.costcat_code ELSE ''::text END AS default_cost_category, CASE WHEN whsinfo.warehous_transit THEN whsinfo.warehous_shipcomments ELSE ''::text END AS shipping_comments, CASE WHEN whsinfo.warehous_transit THEN false ELSE whsinfo.warehous_enforcearbl END AS enforce_arbl_naming_convention, CASE WHEN whsinfo.warehous_transit THEN 0 WHEN whsinfo.warehous_enforcearbl THEN whsinfo.warehous_aislesize ELSE 0 END AS aisle_size, CASE WHEN whsinfo.warehous_transit THEN false WHEN (whsinfo.warehous_enforcearbl AND whsinfo.warehous_aislealpha) THEN true ELSE false END AS aisle_allow_alpha_characters, CASE WHEN whsinfo.warehous_transit THEN 0 WHEN whsinfo.warehous_enforcearbl THEN whsinfo.warehous_racksize ELSE 0 END AS rack_size, CASE WHEN whsinfo.warehous_transit THEN false WHEN (whsinfo.warehous_enforcearbl AND whsinfo.warehous_rackalpha) THEN true ELSE false END AS rack_allow_alpha_characters, CASE WHEN whsinfo.warehous_transit THEN 0 WHEN whsinfo.warehous_enforcearbl THEN whsinfo.warehous_binsize ELSE 0 END AS bin_size, CASE WHEN whsinfo.warehous_transit THEN false WHEN (whsinfo.warehous_enforcearbl AND whsinfo.warehous_binalpha) THEN true ELSE false END AS bin_allow_alpha_characters, CASE WHEN whsinfo.warehous_transit THEN 0 WHEN whsinfo.warehous_enforcearbl THEN whsinfo.warehous_locationsize ELSE 0 END AS location_size, CASE WHEN whsinfo.warehous_transit THEN false WHEN (whsinfo.warehous_enforcearbl AND whsinfo.warehous_locationalpha) THEN true ELSE false END AS location_allow_alpha_characters FROM ((((((((public.whsinfo LEFT JOIN public.addr m ON ((whsinfo.warehous_addr_id = m.addr_id))) LEFT JOIN public.cntct c ON ((whsinfo.warehous_cntct_id = c.cntct_id))) LEFT JOIN public.accnt a ON ((whsinfo.warehous_default_accnt_id = a.accnt_id))) LEFT JOIN public.taxzone t ON ((whsinfo.warehous_taxzone_id = t.taxzone_id))) LEFT JOIN public.shipvia s ON ((whsinfo.warehous_shipvia_id = s.shipvia_id))) LEFT JOIN public.shipform f ON ((whsinfo.warehous_shipform_id = f.shipform_id))) LEFT JOIN public.costcat cc ON ((whsinfo.warehous_costcat_id = cc.costcat_id))) LEFT JOIN public.sitetype st ON ((whsinfo.warehous_sitetype_id = st.sitetype_id))) ORDER BY whsinfo.warehous_code; DROP VIEW api.site; apiadminfalse90236'00 VIEW siteCOMMENT COMMENT ON VIEW site IS 'Site'; apiadminfalse889'00siteACLREVOKE ALL ON TABLE site FROM PUBLIC; REVOKE ALL ON TABLE site FROM admin; GRANT ALL ON TABLE site TO admin; GRANT ALL ON TABLE site TO xtrole; apiadminfalse889z125988375sitezoneVIEW!CREATE VIEW sitezone AS SELECT (whsinfo.warehous_code)::character varying AS site, (whsezone.whsezone_name)::character varying AS name, whsezone.whsezone_descrip AS description FROM (public.whsezone LEFT JOIN public.whsinfo ON ((whsinfo.warehous_id = whsezone.whsezone_warehous_id))); DROP VIEW api.sitezone; apiadminfalse90276'00 VIEW sitezoneCOMMENT)COMMENT ON VIEW sitezone IS 'Site Zone'; apiadminfalse890'00sitezoneACLREVOKE ALL ON TABLE sitezone FROM PUBLIC; REVOKE ALL ON TABLE sitezone FROM admin; GRANT ALL ON TABLE sitezone TO admin; GRANT ALL ON TABLE sitezone TO xtrole; apiadminfalse890{125988383taskVIEWCREATE VIEW task AS SELECT prj.prj_number AS project_number, prjtask.prjtask_number AS number, CASE WHEN (prjtask.prjtask_status = 'P'::bpchar) THEN 'Concept'::text WHEN (prjtask.prjtask_status = 'O'::bpchar) THEN 'In-Process'::text WHEN (prjtask.prjtask_status = 'C'::bpchar) THEN 'Closed'::text ELSE 'Error'::text END AS status, prjtask.prjtask_name AS name, prjtask.prjtask_descrip AS description, prjtask.prjtask_owner_username AS owner, prjtask.prjtask_username AS assigned_to, prjtask.prjtask_hours_budget AS hours_budgeted, prjtask.prjtask_hours_actual AS hours_actual, prjtask.prjtask_exp_budget AS expenses_budgeted, prjtask.prjtask_exp_actual AS expenses_actual, prjtask.prjtask_due_date AS due, prjtask.prjtask_assigned_date AS assigned, prjtask.prjtask_start_date AS started, prjtask.prjtask_completed_date AS completed FROM (public.prjtask JOIN public.prj ON ((prj.prj_id = prjtask.prjtask_prj_id))); DROP VIEW api.task; apiadminfalse90316'00 VIEW taskCOMMENT COMMENT ON VIEW task IS 'Task'; apiadminfalse891'00taskACLREVOKE ALL ON TABLE task FROM PUBLIC; REVOKE ALL ON TABLE task FROM admin; GRANT ALL ON TABLE task TO admin; GRANT ALL ON TABLE task TO xtrole; apiadminfalse891|125988393 taskcommentVIEW"CREATE VIEW taskcomment AS SELECT (prj.prj_number)::character varying AS project_number, (prjtask.prjtask_number)::character varying AS task_number, cmnttype.cmnttype_name AS type, comment.comment_date AS date, comment.comment_user AS username, comment.comment_text AS text FROM public.prj, public.prjtask, public.cmnttype, public.comment WHERE ((((comment.comment_source = 'TA'::text) AND (prj.prj_id = prjtask.prjtask_prj_id)) AND (comment.comment_source_id = prjtask.prjtask_id)) AND (comment.comment_cmnttype_id = cmnttype.cmnttype_id)); DROP VIEW api.taskcomment; apiadminfalse90356'00VIEW taskcommentCOMMENT/COMMENT ON VIEW taskcomment IS 'Task Comment'; apiadminfalse892'00 taskcommentACLREVOKE ALL ON TABLE taskcomment FROM PUBLIC; REVOKE ALL ON TABLE taskcomment FROM admin; GRANT ALL ON TABLE taskcomment TO admin; GRANT ALL ON TABLE taskcomment TO xtrole; apiadminfalse892}125988400todoVIEWCREATE VIEW todo AS SELECT todoitem.todoitem_id AS task_number, todoitem.todoitem_owner_username AS owner, todoitem.todoitem_username AS assigned_to, todoitem.todoitem_name AS task_name, incdtpriority.incdtpriority_name AS priority, incdt.incdt_number AS incident, ophead.ophead_name AS opportunity, crmacct.crmacct_number AS account, public.formatdate(todoitem.todoitem_due_date) AS date_due, public.formatdate(todoitem.todoitem_assigned_date) AS date_assigned, public.formatdate(todoitem.todoitem_start_date) AS date_started, public.formatdate(todoitem.todoitem_completed_date) AS date_completed, CASE WHEN (todoitem.todoitem_status = 'P'::bpchar) THEN 'Pending Input'::text WHEN (todoitem.todoitem_status = 'D'::bpchar) THEN 'Deferred'::text ELSE 'Neither'::text END AS status, todoitem.todoitem_active AS active, todoitem.todoitem_description AS description, todoitem.todoitem_notes AS notes FROM ((((public.todoitem LEFT JOIN public.incdt ON ((incdt.incdt_id = todoitem.todoitem_incdt_id))) LEFT JOIN public.ophead ON ((ophead.ophead_id = todoitem.todoitem_ophead_id))) LEFT JOIN public.crmacct ON ((crmacct.crmacct_id = todoitem.todoitem_crmacct_id))) LEFT JOIN public.incdtpriority ON ((incdtpriority.incdtpriority_id = todoitem.todoitem_priority_id))); DROP VIEW api.todo; apiadminfalse90396'00 VIEW todoCOMMENT&COMMENT ON VIEW todo IS 'To-Do List'; apiadminfalse893'00todoACLREVOKE ALL ON TABLE todo FROM PUBLIC; REVOKE ALL ON TABLE todo FROM admin; GRANT ALL ON TABLE todo TO admin; GRANT ALL ON TABLE todo TO xtrole; apiadminfalse893125980499vendtypeTABLECREATE TABLE vendtype ( vendtype_id integer NOT NULL, vendtype_code text NOT NULL, vendtype_descrip text, CONSTRAINT vendtype_vendtype_code_check CHECK ((vendtype_code <> ''::text)) ); DROP TABLE public.vendtype; publicadminfalse63188'00TABLE vendtypeCOMMENT8COMMENT ON TABLE vendtype IS 'Vendor Type information'; publicadminfalse285'00vendtypeACLREVOKE ALL ON TABLE vendtype FROM PUBLIC; REVOKE ALL ON TABLE vendtype FROM admin; GRANT ALL ON TABLE vendtype TO admin; GRANT ALL ON TABLE vendtype TO xtrole; publicadminfalse285~125988410vendorVIEW[ CREATE VIEW vendor AS SELECT (vendinfo.vend_number)::character varying AS vendor_number, vendtype.vendtype_code AS vendor_type, vendinfo.vend_name AS vendor_name, vendinfo.vend_active AS active, vendinfo.vend_accntnum AS account_number, addr.addr_number AS address_number, addr.addr_line1 AS address1, addr.addr_line2 AS address2, addr.addr_line3 AS address3, addr.addr_city AS city, addr.addr_state AS state, addr.addr_postalcode AS postalcode, addr.addr_country AS country, ''::text AS address_change, terms.terms_code AS default_terms, vendinfo.vend_shipvia AS ship_via, curr_symbol.curr_abbr AS default_currency, CASE WHEN (vendinfo.vend_fobsource = 'W'::bpchar) THEN 'Receiving Site'::text ELSE vendinfo.vend_fob END AS default_fob, vendinfo.vend_po AS sells_purchase_order_items, vendinfo.vend_restrictpurch AS may_only_sell_item_source, vendinfo.vend_qualified AS qualified, vendinfo.vend_match AS matching_vo_po_amounts, vendinfo.vend_1099 AS receives_1099, taxzone.taxzone_code AS default_tax_zone, CASE WHEN (accnt.accnt_id IS NULL) THEN 'N/A'::text ELSE public.formatglaccount(accnt.accnt_id) END AS default_dist_gl_account, CASE WHEN (expcat.expcat_id IS NULL) THEN 'N/A'::text ELSE expcat.expcat_code END AS default_dist_expense_category, CASE WHEN (tax.tax_id IS NULL) THEN 'N/A'::text ELSE tax.tax_code END AS default_dist_tax_code, c1.cntct_number AS contact1_number, c1.cntct_honorific AS contact1_honorific, c1.cntct_first_name AS contact1_first, c1.cntct_middle AS contact1_middle, c1.cntct_last_name AS contact1_last, c1.cntct_suffix AS contact1_suffix, c1.cntct_title AS contact1_job_title, c1.cntct_phone AS contact1_voice, c1.cntct_phone2 AS contact1_alternate, c1.cntct_fax AS contact1_fax, c1.cntct_email AS contact1_email, c1.cntct_webaddr AS contact1_web, ''::text AS contact1_change, c2.cntct_number AS contact2_number, c2.cntct_honorific AS contact2_honorific, c2.cntct_first_name AS contact2_first, c2.cntct_middle AS contact2_middle, c2.cntct_last_name AS contact2_last, c2.cntct_suffix AS contact2_suffix, c2.cntct_title AS contact2_job_title, c2.cntct_phone AS contact2_voice, c2.cntct_phone2 AS contact2_alternate, c2.cntct_fax AS contact2_fax, c2.cntct_email AS contact2_email, c2.cntct_webaddr AS contact2_web, ''::text AS contact2_change, vendinfo.vend_comments AS notes, vendinfo.vend_pocomments AS po_comments, vendinfo.vend_emailpodelivery AS allow_email_po_delivery, vendinfo.vend_ediemail AS po_edi_email, vendinfo.vend_edicc AS po_edi_cc, vendinfo.vend_edisubject AS po_edi_subject, vendinfo.vend_edifilename AS po_edi_filename, vendinfo.vend_ediemailbody AS po_edi_emailbody FROM ((((((((((public.vendinfo LEFT JOIN public.addr ON ((vendinfo.vend_addr_id = addr.addr_id))) LEFT JOIN public.cntct c1 ON ((vendinfo.vend_cntct1_id = c1.cntct_id))) LEFT JOIN public.cntct c2 ON ((vendinfo.vend_cntct2_id = c2.cntct_id))) LEFT JOIN public.taxzone ON ((vendinfo.vend_taxzone_id = taxzone.taxzone_id))) LEFT JOIN public.curr_symbol ON ((vendinfo.vend_curr_id = curr_symbol.curr_id))) LEFT JOIN public.terms ON ((vendinfo.vend_terms_id = terms.terms_id))) LEFT JOIN public.vendtype ON ((vendinfo.vend_vendtype_id = vendtype.vendtype_id))) LEFT JOIN public.accnt ON ((vendinfo.vend_accnt_id = accnt.accnt_id))) LEFT JOIN public.expcat ON ((vendinfo.vend_expcat_id = expcat.expcat_id))) LEFT JOIN public.tax ON ((vendinfo.vend_tax_id = tax.tax_id))) ORDER BY vendinfo.vend_number; DROP VIEW api.vendor; apiadminfalse90436'00 VIEW vendorCOMMENT$COMMENT ON VIEW vendor IS 'vendor'; apiadminfalse894'00vendorACLREVOKE ALL ON TABLE vendor FROM PUBLIC; REVOKE ALL ON TABLE vendor FROM admin; GRANT ALL ON TABLE vendor TO admin; GRANT ALL ON TABLE vendor TO xtrole; apiadminfalse894125988420 vendoraddressVIEWLCREATE VIEW vendoraddress AS SELECT (vendinfo.vend_number)::character varying AS vendor_number, vendinfo.vend_name AS vendor_name, (vendaddrinfo.vendaddr_code)::character varying AS vendor_address_number, vendaddrinfo.vendaddr_name AS vendor_address_name, addr.addr_number AS address_number, addr.addr_line1 AS address1, addr.addr_line2 AS address2, addr.addr_line3 AS address3, addr.addr_city AS city, addr.addr_state AS state, addr.addr_postalcode AS postalcode, addr.addr_country AS country, ''::text AS address_change, cntct.cntct_number AS contact_number, cntct.cntct_honorific AS contact_honorific, cntct.cntct_first_name AS contact_first, cntct.cntct_middle AS contact_middle, cntct.cntct_last_name AS contact_last, cntct.cntct_suffix AS contact_suffix, cntct.cntct_title AS contact_job_title, cntct.cntct_phone AS contact_voice, cntct.cntct_phone2 AS contact_alternate, cntct.cntct_fax AS contact_fax, cntct.cntct_email AS contact_email, cntct.cntct_webaddr AS contact_web, ''::text AS contact_change, vendaddrinfo.vendaddr_comments AS notes FROM (((public.vendaddrinfo LEFT JOIN public.vendinfo ON ((vendinfo.vend_id = vendaddrinfo.vendaddr_vend_id))) LEFT JOIN public.addr ON ((vendaddrinfo.vendaddr_addr_id = addr.addr_id))) LEFT JOIN public.cntct ON ((vendaddrinfo.vendaddr_cntct_id = cntct.cntct_id))) ORDER BY vendaddrinfo.vendaddr_code; DROP VIEW api.vendoraddress; apiadminfalse90476'00VIEW vendoraddressCOMMENT3COMMENT ON VIEW vendoraddress IS 'vendor address'; apiadminfalse895'00 vendoraddressACLREVOKE ALL ON TABLE vendoraddress FROM PUBLIC; REVOKE ALL ON TABLE vendoraddress FROM admin; GRANT ALL ON TABLE vendoraddress TO admin; GRANT ALL ON TABLE vendoraddress TO xtrole; apiadminfalse895125988430 vendortypeVIEWCREATE VIEW vendortype AS SELECT (vendtype.vendtype_code)::character varying AS code, vendtype.vendtype_descrip AS description FROM public.vendtype ORDER BY vendtype.vendtype_code; DROP VIEW api.vendortype; apiadminfalse90516'00VIEW vendortypeCOMMENT-COMMENT ON VIEW vendortype IS 'Vendor Type'; apiadminfalse896'00 vendortypeACLREVOKE ALL ON TABLE vendortype FROM PUBLIC; REVOKE ALL ON TABLE vendortype FROM admin; GRANT ALL ON TABLE vendortype TO admin; GRANT ALL ON TABLE vendortype TO xtrole; apiadminfalse896125980520cmdTABLECREATE TABLE cmd ( cmd_id integer NOT NULL, cmd_module text NOT NULL, cmd_title text NOT NULL, cmd_descrip text, cmd_privname text, cmd_executable text NOT NULL, cmd_name text ); DROP TABLE public.cmd; publicadminfalse8'00 TABLE cmdCOMMENT6COMMENT ON TABLE cmd IS 'Custom menu command table.'; publicadminfalse286'00cmdACLREVOKE ALL ON TABLE cmd FROM PUBLIC; REVOKE ALL ON TABLE cmd FROM admin; GRANT ALL ON TABLE cmd TO admin; GRANT ALL ON TABLE cmd TO xtrole; publicadminfalse286125980526cmd_cmd_id_seqSEQUENCEpCREATE SEQUENCE cmd_cmd_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; %DROP SEQUENCE public.cmd_cmd_id_seq; publicadminfalse8286'00cmd_cmd_id_seqSEQUENCE OWNED BY3ALTER SEQUENCE cmd_cmd_id_seq OWNED BY cmd.cmd_id; publicadminfalse287'00cmd_cmd_id_seqACLREVOKE ALL ON SEQUENCE cmd_cmd_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cmd_cmd_id_seq FROM admin; GRANT ALL ON SEQUENCE cmd_cmd_id_seq TO admin; GRANT ALL ON SEQUENCE cmd_cmd_id_seq TO xtrole; publicadminfalse287 125980528pkgcmdTABLEuCREATE TABLE pkgcmd ( cmd_id integer DEFAULT nextval('public.cmd_cmd_id_seq'::regclass) ) INHERITS (public.cmd); DROP TABLE fixcountry.pkgcmd;  fixcountryadminfalse63207286'00pkgcmdACLREVOKE ALL ON TABLE pkgcmd FROM PUBLIC; REVOKE ALL ON TABLE pkgcmd FROM admin; GRANT ALL ON TABLE pkgcmd TO admin; GRANT ALL ON TABLE pkgcmd TO xtrole;  fixcountryadminfalse288!125980535cmdargTABLECREATE TABLE cmdarg ( cmdarg_id integer NOT NULL, cmdarg_cmd_id integer NOT NULL, cmdarg_order integer NOT NULL, cmdarg_arg text NOT NULL ); DROP TABLE public.cmdarg; publicadminfalse8'00 TABLE cmdargCOMMENTNCOMMENT ON TABLE cmdarg IS 'Command argument for custom menu command table.'; publicadminfalse289'00cmdargACLREVOKE ALL ON TABLE cmdarg FROM PUBLIC; REVOKE ALL ON TABLE cmdarg FROM admin; GRANT ALL ON TABLE cmdarg TO admin; GRANT ALL ON TABLE cmdarg TO xtrole; publicadminfalse289"125980541cmdarg_cmdarg_id_seqSEQUENCEvCREATE SEQUENCE cmdarg_cmdarg_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.cmdarg_cmdarg_id_seq; publicadminfalse8289'00cmdarg_cmdarg_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE cmdarg_cmdarg_id_seq OWNED BY cmdarg.cmdarg_id; publicadminfalse290'00cmdarg_cmdarg_id_seqACLREVOKE ALL ON SEQUENCE cmdarg_cmdarg_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cmdarg_cmdarg_id_seq FROM admin; GRANT ALL ON SEQUENCE cmdarg_cmdarg_id_seq TO admin; GRANT ALL ON SEQUENCE cmdarg_cmdarg_id_seq TO xtrole; publicadminfalse290#125980543 pkgcmdargTABLECREATE TABLE pkgcmdarg ( cmdarg_id integer DEFAULT nextval('public.cmdarg_cmdarg_id_seq'::regclass) ) INHERITS (public.cmdarg); !DROP TABLE fixcountry.pkgcmdarg;  fixcountryadminfalse63227289'00 pkgcmdargACLREVOKE ALL ON TABLE pkgcmdarg FROM PUBLIC; REVOKE ALL ON TABLE pkgcmdarg FROM admin; GRANT ALL ON TABLE pkgcmdarg TO admin; GRANT ALL ON TABLE pkgcmdarg TO xtrole;  fixcountryadminfalse291$125980550image_image_id_seqSEQUENCE|CREATE SEQUENCE image_image_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; )DROP SEQUENCE public.image_image_id_seq; publicadminfalse8'00image_image_id_seqACLREVOKE ALL ON SEQUENCE image_image_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE image_image_id_seq FROM admin; GRANT ALL ON SEQUENCE image_image_id_seq TO admin; GRANT ALL ON SEQUENCE image_image_id_seq TO xtrole; publicadminfalse292%125980552pkgimageTABLECREATE TABLE pkgimage ( image_id integer DEFAULT nextval('public.image_image_id_seq'::regclass) ) INHERITS (public.image); DROP TABLE fixcountry.pkgimage;  fixcountryadminfalse63237223'00pkgimageACLREVOKE ALL ON TABLE pkgimage FROM PUBLIC; REVOKE ALL ON TABLE pkgimage FROM admin; GRANT ALL ON TABLE pkgimage TO admin; GRANT ALL ON TABLE pkgimage TO xtrole;  fixcountryadminfalse293&125980559metasqlTABLECREATE TABLE metasql ( metasql_id integer NOT NULL, metasql_group text, metasql_name text, metasql_notes text, metasql_query text, metasql_lastuser text, metasql_lastupdate date, metasql_grade integer DEFAULT 0 NOT NULL ); DROP TABLE public.metasql; publicadminfalse63258'00 TABLE metasqlCOMMENT-COMMENT ON TABLE metasql IS 'MetaSQL Table'; publicadminfalse294'00metasqlACLREVOKE ALL ON TABLE metasql FROM PUBLIC; REVOKE ALL ON TABLE metasql FROM admin; GRANT ALL ON TABLE metasql TO admin; GRANT ALL ON TABLE metasql TO xtrole; publicadminfalse294'125980566metasql_metasql_id_seqSEQUENCExCREATE SEQUENCE metasql_metasql_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.metasql_metasql_id_seq; publicadminfalse8294'00metasql_metasql_id_seqSEQUENCE OWNED BYCALTER SEQUENCE metasql_metasql_id_seq OWNED BY metasql.metasql_id; publicadminfalse295'00metasql_metasql_id_seqACLREVOKE ALL ON SEQUENCE metasql_metasql_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE metasql_metasql_id_seq FROM admin; GRANT ALL ON SEQUENCE metasql_metasql_id_seq TO admin; GRANT ALL ON SEQUENCE metasql_metasql_id_seq TO xtrole; publicadminfalse295(125980568 pkgmetasqlTABLECREATE TABLE pkgmetasql ( metasql_id integer DEFAULT nextval('public.metasql_metasql_id_seq'::regclass) ) INHERITS (public.metasql); "DROP TABLE fixcountry.pkgmetasql;  fixcountryadminfalse63267294'00 pkgmetasqlACLREVOKE ALL ON TABLE pkgmetasql FROM PUBLIC; REVOKE ALL ON TABLE pkgmetasql FROM admin; GRANT ALL ON TABLE pkgmetasql TO admin; GRANT ALL ON TABLE pkgmetasql TO xtrole;  fixcountryadminfalse296)125980576privTABLECREATE TABLE priv ( priv_id integer DEFAULT nextval(('priv_priv_id_seq'::text)::regclass) NOT NULL, priv_module text, priv_name text, priv_descrip text, priv_seq integer ); DROP TABLE public.priv; publicadminfalse63288'00 TABLE privCOMMENT9COMMENT ON TABLE priv IS 'System Privilege information'; publicadminfalse297'00privACLREVOKE ALL ON TABLE priv FROM PUBLIC; REVOKE ALL ON TABLE priv FROM admin; GRANT ALL ON TABLE priv TO admin; GRANT ALL ON TABLE priv TO xtrole; publicadminfalse297*125980583priv_priv_id_seqSEQUENCEzCREATE SEQUENCE priv_priv_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; 'DROP SEQUENCE public.priv_priv_id_seq; publicadminfalse8'00priv_priv_id_seqACLREVOKE ALL ON SEQUENCE priv_priv_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE priv_priv_id_seq FROM admin; GRANT ALL ON SEQUENCE priv_priv_id_seq TO admin; GRANT ALL ON SEQUENCE priv_priv_id_seq TO xtrole; publicadminfalse298+125980585pkgprivTABLEzCREATE TABLE pkgpriv ( priv_id integer DEFAULT nextval('public.priv_priv_id_seq'::regclass) ) INHERITS (public.priv); DROP TABLE fixcountry.pkgpriv;  fixcountryadminfalse63297297'00pkgprivACLREVOKE ALL ON TABLE pkgpriv FROM PUBLIC; REVOKE ALL ON TABLE pkgpriv FROM admin; GRANT ALL ON TABLE pkgpriv TO admin; GRANT ALL ON TABLE pkgpriv TO xtrole;  fixcountryadminfalse299,125980592reportTABLE%CREATE TABLE report ( report_id integer DEFAULT nextval(('report_report_id_seq'::text)::regclass) NOT NULL, report_name text, report_sys boolean, report_source text, report_descrip text, report_grade integer NOT NULL, report_loaddate timestamp without time zone ); DROP TABLE public.report; publicadminfalse63308'00 TABLE reportCOMMENT<COMMENT ON TABLE report IS 'Report definition information'; publicadminfalse300'00reportACLREVOKE ALL ON TABLE report FROM PUBLIC; REVOKE ALL ON TABLE report FROM admin; GRANT ALL ON TABLE report TO admin; GRANT ALL ON TABLE report TO xtrole; publicadminfalse300-125980599report_report_id_seqSEQUENCE~CREATE SEQUENCE report_report_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; +DROP SEQUENCE public.report_report_id_seq; publicadminfalse8'00report_report_id_seqACLREVOKE ALL ON SEQUENCE report_report_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE report_report_id_seq FROM admin; GRANT ALL ON SEQUENCE report_report_id_seq TO admin; GRANT ALL ON SEQUENCE report_report_id_seq TO xtrole; publicadminfalse301.125980601 pkgreportTABLECREATE TABLE pkgreport ( report_id integer DEFAULT nextval('public.report_report_id_seq'::regclass) ) INHERITS (public.report); !DROP TABLE fixcountry.pkgreport;  fixcountryadminfalse63317300'00 pkgreportACLREVOKE ALL ON TABLE pkgreport FROM PUBLIC; REVOKE ALL ON TABLE pkgreport FROM admin; GRANT ALL ON TABLE pkgreport TO admin; GRANT ALL ON TABLE pkgreport TO xtrole;  fixcountryadminfalse302/125980608scriptTABLECREATE TABLE script ( script_id integer NOT NULL, script_name text NOT NULL, script_order integer NOT NULL, script_enabled boolean DEFAULT false NOT NULL, script_source text NOT NULL, script_notes text ); DROP TABLE public.script; publicadminfalse63338'00scriptACLREVOKE ALL ON TABLE script FROM PUBLIC; REVOKE ALL ON TABLE script FROM admin; GRANT ALL ON TABLE script TO admin; GRANT ALL ON TABLE script TO xtrole; publicadminfalse3030125980615script_script_id_seqSEQUENCEvCREATE SEQUENCE script_script_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.script_script_id_seq; publicadminfalse3038'00script_script_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE script_script_id_seq OWNED BY script.script_id; publicadminfalse304'00script_script_id_seqACLREVOKE ALL ON SEQUENCE script_script_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE script_script_id_seq FROM admin; GRANT ALL ON SEQUENCE script_script_id_seq TO admin; GRANT ALL ON SEQUENCE script_script_id_seq TO xtrole; publicadminfalse3041125980617 pkgscriptTABLECREATE TABLE pkgscript ( script_id integer DEFAULT nextval('public.script_script_id_seq'::regclass) ) INHERITS (public.script); !DROP TABLE fixcountry.pkgscript;  fixcountryadminfalse63347303'00 pkgscriptACLREVOKE ALL ON TABLE pkgscript FROM PUBLIC; REVOKE ALL ON TABLE pkgscript FROM admin; GRANT ALL ON TABLE pkgscript TO admin; GRANT ALL ON TABLE pkgscript TO xtrole;  fixcountryadminfalse3052125980625uiformTABLECREATE TABLE uiform ( uiform_id integer NOT NULL, uiform_name text NOT NULL, uiform_order integer NOT NULL, uiform_enabled boolean DEFAULT false NOT NULL, uiform_source text NOT NULL, uiform_notes text ); DROP TABLE public.uiform; publicadminfalse63378'00uiformACLREVOKE ALL ON TABLE uiform FROM PUBLIC; REVOKE ALL ON TABLE uiform FROM admin; GRANT ALL ON TABLE uiform TO admin; GRANT ALL ON TABLE uiform TO xtrole; publicadminfalse3063125980632uiform_uiform_id_seqSEQUENCEvCREATE SEQUENCE uiform_uiform_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.uiform_uiform_id_seq; publicadminfalse8306'00uiform_uiform_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE uiform_uiform_id_seq OWNED BY uiform.uiform_id; publicadminfalse307'00uiform_uiform_id_seqACLREVOKE ALL ON SEQUENCE uiform_uiform_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE uiform_uiform_id_seq FROM admin; GRANT ALL ON SEQUENCE uiform_uiform_id_seq TO admin; GRANT ALL ON SEQUENCE uiform_uiform_id_seq TO xtrole; publicadminfalse3074125980634 pkguiformTABLECREATE TABLE pkguiform ( uiform_id integer DEFAULT nextval('public.uiform_uiform_id_seq'::regclass) ) INHERITS (public.uiform); !DROP TABLE fixcountry.pkguiform;  fixcountryadminfalse63387306'00 pkguiformACLREVOKE ALL ON TABLE pkguiform FROM PUBLIC; REVOKE ALL ON TABLE pkguiform FROM admin; GRANT ALL ON TABLE pkguiform TO admin; GRANT ALL ON TABLE pkguiform TO xtrole;  fixcountryadminfalse3085125980642acalitemTABLECREATE TABLE acalitem ( acalitem_id integer DEFAULT nextval(('"xcalitem_xcalitem_id_seq"'::text)::regclass) NOT NULL, acalitem_calhead_id integer, acalitem_periodstart date, acalitem_periodlength integer, acalitem_name text ); DROP TABLE public.acalitem; publicadminfalse63408'00TABLE acalitemCOMMENTCCOMMENT ON TABLE acalitem IS 'Absolute Calendar Item information'; publicadminfalse309'00acalitemACLREVOKE ALL ON TABLE acalitem FROM PUBLIC; REVOKE ALL ON TABLE acalitem FROM admin; GRANT ALL ON TABLE acalitem TO admin; GRANT ALL ON TABLE acalitem TO xtrole; publicadminfalse3096125980649accnt_accnt_id_seqSEQUENCE|CREATE SEQUENCE accnt_accnt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; )DROP SEQUENCE public.accnt_accnt_id_seq; publicadminfalse8'00accnt_accnt_id_seqACLREVOKE ALL ON SEQUENCE accnt_accnt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE accnt_accnt_id_seq FROM admin; GRANT ALL ON SEQUENCE accnt_accnt_id_seq TO admin; GRANT ALL ON SEQUENCE accnt_accnt_id_seq TO xtrole; publicadminfalse3107125980651addr_addr_id_seqSEQUENCErCREATE SEQUENCE addr_addr_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 'DROP SEQUENCE public.addr_addr_id_seq; publicadminfalse2138(00addr_addr_id_seqSEQUENCE OWNED BY7ALTER SEQUENCE addr_addr_id_seq OWNED BY addr.addr_id; publicadminfalse311(00addr_addr_id_seqACLREVOKE ALL ON SEQUENCE addr_addr_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE addr_addr_id_seq FROM admin; GRANT ALL ON SEQUENCE addr_addr_id_seq TO admin; GRANT ALL ON SEQUENCE addr_addr_id_seq TO xtrole; publicadminfalse311125987575addressVIEWKCREATE VIEW address AS SELECT addr.addr_id, addr.addr_active, addr.addr_line1, addr.addr_line2, addr.addr_line3, addr.addr_city, addr.addr_state, addr.addr_postalcode, addr.addr_country, addr.addr_notes, addr.addr_number, COALESCE(addresses.crmacct_id, (-1)) AS crmacct_id, addresses.crmacct_number, addresses.crmacct_name FROM (addr LEFT JOIN ((((SELECT cntct.cntct_addr_id AS join_id, crmacct.crmacct_id, crmacct.crmacct_number, crmacct.crmacct_name FROM (cntct JOIN crmacct ON ((cntct.cntct_crmacct_id = crmacct.crmacct_id))) UNION SELECT vendinfo.vend_addr_id, crmacct.crmacct_id, crmacct.crmacct_number, crmacct.crmacct_name FROM (vendinfo JOIN crmacct ON ((vendinfo.vend_id = crmacct.crmacct_vend_id)))) UNION SELECT vendaddrinfo.vendaddr_addr_id, crmacct.crmacct_id, crmacct.crmacct_number, crmacct.crmacct_name FROM (vendaddrinfo JOIN crmacct ON ((vendaddrinfo.vendaddr_vend_id = crmacct.crmacct_vend_id)))) UNION SELECT taxauth.taxauth_addr_id, crmacct.crmacct_id, crmacct.crmacct_number, crmacct.crmacct_name FROM (taxauth JOIN crmacct ON ((taxauth.taxauth_id = crmacct.crmacct_taxauth_id)))) UNION SELECT shiptoinfo.shipto_addr_id, crmacct.crmacct_id, crmacct.crmacct_number, crmacct.crmacct_name FROM (shiptoinfo JOIN crmacct ON ((shiptoinfo.shipto_cust_id = crmacct.crmacct_cust_id)))) addresses ON ((addr.addr_id = addresses.join_id))); DROP VIEW public.address; publicadminfalse86738(00addressACLREVOKE ALL ON TABLE address FROM PUBLIC; REVOKE ALL ON TABLE address FROM admin; GRANT ALL ON TABLE address TO admin; GRANT ALL ON TABLE address TO xtrole; publicadminfalse7908125980658alarmTABLE'CREATE TABLE alarm ( alarm_id integer NOT NULL, alarm_number text NOT NULL, alarm_event boolean DEFAULT false NOT NULL, alarm_email boolean DEFAULT false NOT NULL, alarm_sysmsg boolean DEFAULT false NOT NULL, alarm_trigger timestamp with time zone, alarm_time timestamp with time zone, alarm_time_offset integer, alarm_time_qualifier text, alarm_creator text, alarm_event_recipient text, alarm_email_recipient text, alarm_sysmsg_recipient text, alarm_source text, alarm_source_id integer ); DROP TABLE public.alarm; publicadminfalse6341634263438(00 TABLE alarmCOMMENT<COMMENT ON TABLE alarm IS 'This table is the open alarms.'; publicadminfalse312(00alarmACLREVOKE ALL ON TABLE alarm FROM PUBLIC; REVOKE ALL ON TABLE alarm FROM admin; GRANT ALL ON TABLE alarm TO admin; GRANT ALL ON TABLE alarm TO xtrole; publicadminfalse3129125980667alarm_alarm_id_seqSEQUENCEtCREATE SEQUENCE alarm_alarm_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; )DROP SEQUENCE public.alarm_alarm_id_seq; publicadminfalse8312(00alarm_alarm_id_seqSEQUENCE OWNED BY;ALTER SEQUENCE alarm_alarm_id_seq OWNED BY alarm.alarm_id; publicadminfalse313(00alarm_alarm_id_seqACLREVOKE ALL ON SEQUENCE alarm_alarm_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE alarm_alarm_id_seq FROM admin; GRANT ALL ON SEQUENCE alarm_alarm_id_seq TO admin; GRANT ALL ON SEQUENCE alarm_alarm_id_seq TO xtrole; publicadminfalse313:125980669apaccntTABLECREATE TABLE apaccnt ( apaccnt_id integer NOT NULL, apaccnt_vendtype_id integer, apaccnt_vendtype text, apaccnt_ap_accnt_id integer NOT NULL, apaccnt_prepaid_accnt_id integer, apaccnt_discount_accnt_id integer ); DROP TABLE public.apaccnt; publicadminfalse8(00 TABLE apaccntCOMMENTUCOMMENT ON TABLE apaccnt IS 'Accounts Payable (A/P) Account assignment information'; publicadminfalse314(00apaccntACLREVOKE ALL ON TABLE apaccnt FROM PUBLIC; REVOKE ALL ON TABLE apaccnt FROM admin; GRANT ALL ON TABLE apaccnt TO admin; GRANT ALL ON TABLE apaccnt TO xtrole; publicadminfalse314;125980675apaccnt_apaccnt_id_seqSEQUENCExCREATE SEQUENCE apaccnt_apaccnt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.apaccnt_apaccnt_id_seq; publicadminfalse8314 (00apaccnt_apaccnt_id_seqSEQUENCE OWNED BYCALTER SEQUENCE apaccnt_apaccnt_id_seq OWNED BY apaccnt.apaccnt_id; publicadminfalse315 (00apaccnt_apaccnt_id_seqACLREVOKE ALL ON SEQUENCE apaccnt_apaccnt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE apaccnt_apaccnt_id_seq FROM admin; GRANT ALL ON SEQUENCE apaccnt_apaccnt_id_seq TO admin; GRANT ALL ON SEQUENCE apaccnt_apaccnt_id_seq TO xtrole; publicadminfalse315<125980677apapplyTABLE!CREATE TABLE apapply ( apapply_id integer NOT NULL, apapply_vend_id integer, apapply_postdate date, apapply_username text, apapply_source_apopen_id integer, apapply_source_doctype text, apapply_source_docnumber text, apapply_target_apopen_id integer, apapply_target_doctype text, apapply_target_docnumber text, apapply_journalnumber integer, apapply_amount numeric(20,2), apapply_curr_id integer DEFAULT basecurrid(), apapply_target_paid numeric(20,2), apapply_checkhead_id integer ); DROP TABLE public.apapply; publicadminfalse63478 (00 TABLE apapplyCOMMENTxCOMMENT ON TABLE apapply IS 'Applications (e.g., Payments, A/P Credit Memos) made to Accounts Payable (A/P) Documents'; publicadminfalse316 (00'COLUMN apapply.apapply_source_apopen_idCOMMENTCOMMENT ON COLUMN apapply.apapply_source_apopen_id IS 'If apapply_source_doctype is "C" (credit memo) then apapply_source_apopen_id acts as a foreign key to the apopen table. If the source doctype is "K" (check) then the apapply_source_apopen_id acts as a foreign key to the checkhead table. If the apapply_source_apopen_id is -1 then the internal id of the source document is not known (always the case for checks posted before release 3.2.0BETA).'; publicadminfalse316 (00apapplyACLREVOKE ALL ON TABLE apapply FROM PUBLIC; REVOKE ALL ON TABLE apapply FROM admin; GRANT ALL ON TABLE apapply TO admin; GRANT ALL ON TABLE apapply TO xtrole; publicadminfalse316=125980684apapply_apapply_id_seqSEQUENCExCREATE SEQUENCE apapply_apapply_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.apapply_apapply_id_seq; publicadminfalse8316(00apapply_apapply_id_seqSEQUENCE OWNED BYCALTER SEQUENCE apapply_apapply_id_seq OWNED BY apapply.apapply_id; publicadminfalse317(00apapply_apapply_id_seqACLREVOKE ALL ON SEQUENCE apapply_apapply_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE apapply_apapply_id_seq FROM admin; GRANT ALL ON SEQUENCE apapply_apapply_id_seq TO admin; GRANT ALL ON SEQUENCE apapply_apapply_id_seq TO xtrole; publicadminfalse317>125980686 checkheadTABLECREATE TABLE checkhead ( checkhead_id integer NOT NULL, checkhead_recip_id integer NOT NULL, checkhead_recip_type text NOT NULL, checkhead_bankaccnt_id integer NOT NULL, checkhead_printed boolean DEFAULT false NOT NULL, checkhead_checkdate date NOT NULL, checkhead_number integer NOT NULL, checkhead_amount numeric(20,2) NOT NULL, checkhead_void boolean DEFAULT false NOT NULL, checkhead_replaced boolean DEFAULT false NOT NULL, checkhead_posted boolean DEFAULT false NOT NULL, checkhead_rec boolean DEFAULT false NOT NULL, checkhead_misc boolean DEFAULT false NOT NULL, checkhead_expcat_id integer, checkhead_for text NOT NULL, checkhead_notes text NOT NULL, checkhead_journalnumber integer, checkhead_curr_id integer DEFAULT basecurrid() NOT NULL, checkhead_deleted boolean DEFAULT false NOT NULL, checkhead_ach_batch text, checkhead_curr_rate numeric NOT NULL, checkhead_alt_curr_rate numeric, CONSTRAINT checkhead_checkhead_amount_check CHECK ((checkhead_amount > (0)::numeric)), CONSTRAINT checkhead_checkhead_recip_type_check CHECK ((((checkhead_recip_type = 'C'::text) OR (checkhead_recip_type = 'V'::text)) OR (checkhead_recip_type = 'T'::text))) ); DROP TABLE public.checkhead; publicadminfalse63486349635063516352635363546355635763588(00TABLE checkheadCOMMENTDCOMMENT ON TABLE checkhead IS 'Accounts Payable Check Information'; publicadminfalse318(00 checkheadACLREVOKE ALL ON TABLE checkhead FROM PUBLIC; REVOKE ALL ON TABLE checkhead FROM admin; GRANT ALL ON TABLE checkhead TO admin; GRANT ALL ON TABLE checkhead TO xtrole; publicadminfalse318?125980702apchkVIEWCREATE VIEW apchk AS SELECT checkhead.checkhead_id AS apchk_id, checkhead.checkhead_recip_id AS apchk_vend_id, checkhead.checkhead_bankaccnt_id AS apchk_bankaccnt_id, checkhead.checkhead_printed AS apchk_printed, checkhead.checkhead_checkdate AS apchk_checkdate, checkhead.checkhead_number AS apchk_number, checkhead.checkhead_amount AS apchk_amount, checkhead.checkhead_void AS apchk_void, checkhead.checkhead_replaced AS apchk_replaced, checkhead.checkhead_posted AS apchk_posted, checkhead.checkhead_rec AS apchk_rec, checkhead.checkhead_misc AS apchk_misc, checkhead.checkhead_expcat_id AS apchk_expcat_id, checkhead.checkhead_for AS apchk_for, checkhead.checkhead_notes AS apchk_notes, checkhead.checkhead_journalnumber AS apchk_journalnumber, checkhead.checkhead_curr_id AS apchk_curr_id, checkhead.checkhead_deleted AS apchk_deleted FROM checkhead WHERE (checkhead.checkhead_recip_type = 'V'::text); DROP VIEW public.apchk; publicadminfalse86368(00apchkACLREVOKE ALL ON TABLE apchk FROM PUBLIC; REVOKE ALL ON TABLE apchk FROM admin; GRANT ALL ON TABLE apchk TO admin; GRANT ALL ON TABLE apchk TO xtrole; publicadminfalse319@125980706 checkitemTABLECREATE TABLE checkitem ( checkitem_id integer NOT NULL, checkitem_checkhead_id integer NOT NULL, checkitem_amount numeric(20,2) DEFAULT 0.0 NOT NULL, checkitem_discount numeric(20,2) DEFAULT 0.0 NOT NULL, checkitem_ponumber text, checkitem_vouchernumber text, checkitem_invcnumber text, checkitem_apopen_id integer, checkitem_aropen_id integer, checkitem_docdate date, checkitem_curr_id integer DEFAULT basecurrid() NOT NULL, checkitem_cmnumber text, checkitem_ranumber text, checkitem_curr_rate numeric, CONSTRAINT checkitem_check CHECK ((NOT ((checkitem_apopen_id IS NOT NULL) AND (checkitem_aropen_id IS NOT NULL)))) ); DROP TABLE public.checkitem; publicadminfalse63596360636163638(00TABLE checkitemCOMMENTNCOMMENT ON TABLE checkitem IS 'Accounts Payable Check Line Item Information'; publicadminfalse320(00 checkitemACLREVOKE ALL ON TABLE checkitem FROM PUBLIC; REVOKE ALL ON TABLE checkitem FROM admin; GRANT ALL ON TABLE checkitem TO admin; GRANT ALL ON TABLE checkitem TO xtrole; publicadminfalse320A125980716 apchkitemVIEWCREATE VIEW apchkitem AS SELECT checkitem.checkitem_id AS apchkitem_id, checkitem.checkitem_checkhead_id AS apchkitem_apchk_id, checkitem.checkitem_vouchernumber AS apchkitem_vouchernumber, checkitem.checkitem_ponumber AS apchkitem_ponumber, checkitem.checkitem_amount AS apchkitem_amount, checkitem.checkitem_invcnumber AS apchkitem_invcnumber, checkitem.checkitem_apopen_id AS apchkitem_apopen_id, checkitem.checkitem_docdate AS apchkitem_docdate, checkitem.checkitem_curr_id AS apchkitem_curr_id, checkitem.checkitem_discount AS apchkitem_discount FROM checkhead, checkitem WHERE ((checkitem.checkitem_checkhead_id = checkhead.checkhead_id) AND (checkhead.checkhead_recip_type = 'V'::text)); DROP VIEW public.apchkitem; publicadminfalse86378(00 apchkitemACLREVOKE ALL ON TABLE apchkitem FROM PUBLIC; REVOKE ALL ON TABLE apchkitem FROM admin; GRANT ALL ON TABLE apchkitem TO admin; GRANT ALL ON TABLE apchkitem TO xtrole; publicadminfalse321B125980720 apcreditapplyTABLECREATE TABLE apcreditapply ( apcreditapply_id integer NOT NULL, apcreditapply_source_apopen_id integer, apcreditapply_target_apopen_id integer, apcreditapply_amount numeric(20,2), apcreditapply_curr_id integer DEFAULT basecurrid() ); !DROP TABLE public.apcreditapply; publicadminfalse63658(00TABLE apcreditapplyCOMMENTCOMMENT ON TABLE apcreditapply IS 'Temporary table for storing details of Accounts Payable (A/P) Credit Memo applications before those applications are posted'; publicadminfalse322(00 apcreditapplyACLREVOKE ALL ON TABLE apcreditapply FROM PUBLIC; REVOKE ALL ON TABLE apcreditapply FROM admin; GRANT ALL ON TABLE apcreditapply TO admin; GRANT ALL ON TABLE apcreditapply TO xtrole; publicadminfalse322C125980724"apcreditapply_apcreditapply_id_seqSEQUENCECREATE SEQUENCE apcreditapply_apcreditapply_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 9DROP SEQUENCE public.apcreditapply_apcreditapply_id_seq; publicadminfalse8322(00"apcreditapply_apcreditapply_id_seqSEQUENCE OWNED BY[ALTER SEQUENCE apcreditapply_apcreditapply_id_seq OWNED BY apcreditapply.apcreditapply_id; publicadminfalse323(00"apcreditapply_apcreditapply_id_seqACLREVOKE ALL ON SEQUENCE apcreditapply_apcreditapply_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE apcreditapply_apcreditapply_id_seq FROM admin; GRANT ALL ON SEQUENCE apcreditapply_apcreditapply_id_seq TO admin; GRANT ALL ON SEQUENCE apcreditapply_apcreditapply_id_seq TO xtrole; publicadminfalse323D125980726apmemoVIEWCREATE VIEW apmemo AS SELECT apopen.apopen_id, apopen.apopen_docnumber FROM apopen WHERE (apopen.apopen_doctype = ANY (ARRAY['D'::bpchar, 'C'::bpchar])); DROP VIEW public.apmemo; publicadminfalse86388(00apmemoACLREVOKE ALL ON TABLE apmemo FROM PUBLIC; REVOKE ALL ON TABLE apmemo FROM admin; GRANT ALL ON TABLE apmemo TO admin; GRANT ALL ON TABLE apmemo TO xtrole; publicadminfalse324E125980730apopen_apopen_id_seqSEQUENCEvCREATE SEQUENCE apopen_apopen_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.apopen_apopen_id_seq; publicadminfalse8(00apopen_apopen_id_seqACLREVOKE ALL ON SEQUENCE apopen_apopen_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE apopen_apopen_id_seq FROM admin; GRANT ALL ON SEQUENCE apopen_apopen_id_seq TO admin; GRANT ALL ON SEQUENCE apopen_apopen_id_seq TO xtrole; publicadminfalse325F125980732 apopentaxTABLE/CREATE TABLE apopentax ( ) INHERITS (taxhist); DROP TABLE public.apopentax; publicadminfalse8281(00 apopentaxACLREVOKE ALL ON TABLE apopentax FROM PUBLIC; REVOKE ALL ON TABLE apopentax FROM admin; GRANT ALL ON TABLE apopentax TO admin; GRANT ALL ON TABLE apopentax TO xtrole; publicadminfalse326G125980738apselectTABLE9CREATE TABLE apselect ( apselect_id integer NOT NULL, apselect_apopen_id integer NOT NULL, apselect_amount numeric(20,2) NOT NULL, apselect_bankaccnt_id integer, apselect_curr_id integer DEFAULT basecurrid(), apselect_date date, apselect_discount numeric(20,2) DEFAULT 0.0 NOT NULL ); DROP TABLE public.apselect; publicadminfalse636863698(00TABLE apselectCOMMENTqCOMMENT ON TABLE apselect IS 'Temporary table for storing details of Accounts Payable (A/P) Payment selections'; publicadminfalse327(00apselectACLREVOKE ALL ON TABLE apselect FROM PUBLIC; REVOKE ALL ON TABLE apselect FROM admin; GRANT ALL ON TABLE apselect TO admin; GRANT ALL ON TABLE apselect TO xtrole; publicadminfalse327H125980743apselect_apselect_id_seqSEQUENCEzCREATE SEQUENCE apselect_apselect_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.apselect_apselect_id_seq; publicadminfalse8327(00apselect_apselect_id_seqSEQUENCE OWNED BYGALTER SEQUENCE apselect_apselect_id_seq OWNED BY apselect.apselect_id; publicadminfalse328 (00apselect_apselect_id_seqACLREVOKE ALL ON SEQUENCE apselect_apselect_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE apselect_apselect_id_seq FROM admin; GRANT ALL ON SEQUENCE apselect_apselect_id_seq TO admin; GRANT ALL ON SEQUENCE apselect_apselect_id_seq TO xtrole; publicadminfalse328I125980745araccntTABLEmCREATE TABLE araccnt ( araccnt_id integer DEFAULT nextval(('araccnt_araccnt_id_seq'::text)::regclass) NOT NULL, araccnt_custtype_id integer, araccnt_custtype text, araccnt_freight_accnt_id integer, araccnt_ar_accnt_id integer, araccnt_prepaid_accnt_id integer, araccnt_deferred_accnt_id integer, araccnt_discount_accnt_id integer ); DROP TABLE public.araccnt; publicadminfalse63708!(00 TABLE araccntCOMMENTXCOMMENT ON TABLE araccnt IS 'Accounts Receivable (A/R) Account assignment information'; publicadminfalse329"(00araccntACLREVOKE ALL ON TABLE araccnt FROM PUBLIC; REVOKE ALL ON TABLE araccnt FROM admin; GRANT ALL ON TABLE araccnt TO admin; GRANT ALL ON TABLE araccnt TO xtrole; publicadminfalse329J125980752araccnt_araccnt_id_seqSEQUENCExCREATE SEQUENCE araccnt_araccnt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.araccnt_araccnt_id_seq; publicadminfalse8#(00araccnt_araccnt_id_seqACLREVOKE ALL ON SEQUENCE araccnt_araccnt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE araccnt_araccnt_id_seq FROM admin; GRANT ALL ON SEQUENCE araccnt_araccnt_id_seq TO admin; GRANT ALL ON SEQUENCE araccnt_araccnt_id_seq TO xtrole; publicadminfalse330K125980754arapplyTABLECREATE TABLE arapply ( arapply_id integer NOT NULL, arapply_postdate date, arapply_cust_id integer, arapply_source_doctype text, arapply_source_docnumber text, arapply_target_doctype text, arapply_target_docnumber text, arapply_fundstype text, arapply_refnumber text, arapply_applied numeric(20,2), arapply_closed boolean, arapply_journalnumber text, arapply_source_aropen_id integer, arapply_target_aropen_id integer, arapply_username text, arapply_curr_id integer DEFAULT basecurrid(), arapply_distdate date NOT NULL, arapply_target_paid numeric(20,2), arapply_reftype text, arapply_ref_id integer ); DROP TABLE public.arapply; publicadminfalse63728$(00 TABLE arapplyCOMMENTCOMMENT ON TABLE arapply IS 'Applications (e.g., Cash Receipts, A/R Credit Memos) made to Accounts Receivable (A/R) Documents'; publicadminfalse331%(00arapplyACLREVOKE ALL ON TABLE arapply FROM PUBLIC; REVOKE ALL ON TABLE arapply FROM admin; GRANT ALL ON TABLE arapply TO admin; GRANT ALL ON TABLE arapply TO xtrole; publicadminfalse331L125980761arapply_arapply_id_seqSEQUENCExCREATE SEQUENCE arapply_arapply_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.arapply_arapply_id_seq; publicadminfalse8331&(00arapply_arapply_id_seqSEQUENCE OWNED BYCALTER SEQUENCE arapply_arapply_id_seq OWNED BY arapply.arapply_id; publicadminfalse332'(00arapply_arapply_id_seqACLREVOKE ALL ON SEQUENCE arapply_arapply_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE arapply_arapply_id_seq FROM admin; GRANT ALL ON SEQUENCE arapply_arapply_id_seq TO admin; GRANT ALL ON SEQUENCE arapply_arapply_id_seq TO xtrole; publicadminfalse332M125980763 cashrcptitem_cashrcptitem_id_seqSEQUENCECREATE SEQUENCE cashrcptitem_cashrcptitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 7DROP SEQUENCE public.cashrcptitem_cashrcptitem_id_seq; publicadminfalse8233((00 cashrcptitem_cashrcptitem_id_seqSEQUENCE OWNED BYWALTER SEQUENCE cashrcptitem_cashrcptitem_id_seq OWNED BY cashrcptitem.cashrcptitem_id; publicadminfalse333)(00 cashrcptitem_cashrcptitem_id_seqACL REVOKE ALL ON SEQUENCE cashrcptitem_cashrcptitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cashrcptitem_cashrcptitem_id_seq FROM admin; GRANT ALL ON SEQUENCE cashrcptitem_cashrcptitem_id_seq TO admin; GRANT ALL ON SEQUENCE cashrcptitem_cashrcptitem_id_seq TO xtrole; publicadminfalse333N125980765 arcreditapplyTABLE~CREATE TABLE arcreditapply ( arcreditapply_id integer DEFAULT nextval('cashrcptitem_cashrcptitem_id_seq'::regclass) NOT NULL, arcreditapply_source_aropen_id integer, arcreditapply_target_aropen_id integer, arcreditapply_amount numeric(20,2), arcreditapply_curr_id integer DEFAULT basecurrid(), arcreditapply_reftype text, arcreditapply_ref_id integer ); !DROP TABLE public.arcreditapply; publicadminfalse637363748*(00TABLE arcreditapplyCOMMENTCOMMENT ON TABLE arcreditapply IS 'Temporary table for storing details of Accounts Receivable (A/R) Credit Memo applications before those applications are posted'; publicadminfalse334+(00 arcreditapplyACLREVOKE ALL ON TABLE arcreditapply FROM PUBLIC; REVOKE ALL ON TABLE arcreditapply FROM admin; GRANT ALL ON TABLE arcreditapply TO admin; GRANT ALL ON TABLE arcreditapply TO xtrole; publicadminfalse334O125980773"arcreditapply_arcreditapply_id_seqSEQUENCECREATE SEQUENCE arcreditapply_arcreditapply_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 9DROP SEQUENCE public.arcreditapply_arcreditapply_id_seq; publicadminfalse8334,(00"arcreditapply_arcreditapply_id_seqSEQUENCE OWNED BY[ALTER SEQUENCE arcreditapply_arcreditapply_id_seq OWNED BY arcreditapply.arcreditapply_id; publicadminfalse335-(00"arcreditapply_arcreditapply_id_seqACLREVOKE ALL ON SEQUENCE arcreditapply_arcreditapply_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE arcreditapply_arcreditapply_id_seq FROM admin; GRANT ALL ON SEQUENCE arcreditapply_arcreditapply_id_seq TO admin; GRANT ALL ON SEQUENCE arcreditapply_arcreditapply_id_seq TO xtrole; publicadminfalse335P125980775armemoVIEW CREATE VIEW armemo AS SELECT aropen.aropen_id, aropen.aropen_docnumber FROM aropen WHERE (aropen.aropen_doctype = ANY (ARRAY['D'::bpchar, 'C'::bpchar, 'R'::bpchar])) UNION SELECT cmhead.cmhead_id AS aropen_id, cmhead.cmhead_number AS aropen_docnumber FROM cmhead; DROP VIEW public.armemo; publicadminfalse86398.(00armemoACLREVOKE ALL ON TABLE armemo FROM PUBLIC; REVOKE ALL ON TABLE armemo FROM admin; GRANT ALL ON TABLE armemo TO admin; GRANT ALL ON TABLE armemo TO xtrole; publicadminfalse336Q125980779aropen_aropen_id_seqSEQUENCE~CREATE SEQUENCE aropen_aropen_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; +DROP SEQUENCE public.aropen_aropen_id_seq; publicadminfalse8/(00aropen_aropen_id_seqACLREVOKE ALL ON SEQUENCE aropen_aropen_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE aropen_aropen_id_seq FROM admin; GRANT ALL ON SEQUENCE aropen_aropen_id_seq TO admin; GRANT ALL ON SEQUENCE aropen_aropen_id_seq TO xtrole; publicadminfalse337R125980781 aropentaxTABLE/CREATE TABLE aropentax ( ) INHERITS (taxhist); DROP TABLE public.aropentax; publicadminfalse82810(00 aropentaxACLREVOKE ALL ON TABLE aropentax FROM PUBLIC; REVOKE ALL ON TABLE aropentax FROM admin; GRANT ALL ON TABLE aropentax TO admin; GRANT ALL ON TABLE aropentax TO xtrole; publicadminfalse338S125980787asohistTABLE#CREATE TABLE asohist ( asohist_id integer NOT NULL, asohist_cust_id integer, asohist_itemsite_id integer, asohist_shipdate date, asohist_invcdate date, asohist_duedate date, asohist_promisedate date, asohist_ordernumber text, asohist_invcnumber text, asohist_qtyshipped numeric(18,6), asohist_unitprice numeric(16,4), asohist_unitcost numeric(16,6), asohist_billtoname text, asohist_billtoaddress1 text, asohist_billtoaddress2 text, asohist_billtoaddress3 text, asohist_billtocity text, asohist_billtostate text, asohist_billtozip text, asohist_shiptoname text, asohist_shiptoaddress1 text, asohist_shiptoaddress2 text, asohist_shiptoaddress3 text, asohist_shiptocity text, asohist_shiptostate text, asohist_shiptozip text, asohist_shipto_id integer, asohist_shipvia text, asohist_salesrep_id integer, asohist_misc_type character(1), asohist_misc_descrip text, asohist_misc_id integer, asohist_commission numeric(16,4), asohist_commissionpaid boolean, asohist_doctype text, asohist_orderdate date, asohist_imported boolean, asohist_ponumber text, asohist_curr_id integer DEFAULT basecurrid(), asohist_taxtype_id integer, asohist_taxzone_id integer ); DROP TABLE public.asohist; publicadminfalse637781(00 TABLE asohistCOMMENT6COMMENT ON TABLE asohist IS 'Archived Sales history'; publicadminfalse3392(00asohistACLREVOKE ALL ON TABLE asohist FROM PUBLIC; REVOKE ALL ON TABLE asohist FROM admin; GRANT ALL ON TABLE asohist TO admin; GRANT ALL ON TABLE asohist TO xtrole; publicadminfalse339T125980794asohist_asohist_id_seqSEQUENCExCREATE SEQUENCE asohist_asohist_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.asohist_asohist_id_seq; publicadminfalse83393(00asohist_asohist_id_seqSEQUENCE OWNED BYCALTER SEQUENCE asohist_asohist_id_seq OWNED BY asohist.asohist_id; publicadminfalse3404(00asohist_asohist_id_seqACLREVOKE ALL ON SEQUENCE asohist_asohist_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE asohist_asohist_id_seq FROM admin; GRANT ALL ON SEQUENCE asohist_asohist_id_seq TO admin; GRANT ALL ON SEQUENCE asohist_asohist_id_seq TO xtrole; publicadminfalse340U125980796 asohisttaxTABLE0CREATE TABLE asohisttax ( ) INHERITS (taxhist); DROP TABLE public.asohisttax; publicadminfalse82815(00 asohisttaxACLREVOKE ALL ON TABLE asohisttax FROM PUBLIC; REVOKE ALL ON TABLE asohisttax FROM admin; GRANT ALL ON TABLE asohisttax TO admin; GRANT ALL ON TABLE asohisttax TO xtrole; publicadminfalse341V125980802atlasmapTABLErCREATE TABLE atlasmap ( atlasmap_id integer NOT NULL, atlasmap_name text NOT NULL, atlasmap_filter text NOT NULL, atlasmap_filtertype text NOT NULL, atlasmap_atlas text NOT NULL, atlasmap_map text NOT NULL, atlasmap_headerline boolean DEFAULT false NOT NULL, CONSTRAINT atlasmap_atlasmap_name_check CHECK ((atlasmap_name <> ''::text)) ); DROP TABLE public.atlasmap; publicadminfalse6380638186(00TABLE atlasmapCOMMENT.COMMENT ON TABLE atlasmap IS 'Describes heuristics for finding a CSVImp atlas for a given CSV file. When looking for a CSV Atlas to use when importing a CSV file, the first atlasmap record found that matches the CSV file is used to select the Atlas file and Map in that Atlas to import the CSV file.'; publicadminfalse3427(00COLUMN atlasmap.atlasmap_idCOMMENT[COMMENT ON COLUMN atlasmap.atlasmap_id IS 'The internal id of this CSVImp atlas mapping.'; publicadminfalse3428(00COLUMN atlasmap.atlasmap_nameCOMMENT^COMMENT ON COLUMN atlasmap.atlasmap_name IS 'The human-readable name of this atlas mapping.'; publicadminfalse3429(00COLUMN atlasmap.atlasmap_filterCOMMENTCOMMENT ON COLUMN atlasmap.atlasmap_filter IS 'A regular expression that should match the CSV file. Which part of the file that matches is determined by the filter type.'; publicadminfalse342:(00#COLUMN atlasmap.atlasmap_filtertypeCOMMENT4COMMENT ON COLUMN atlasmap.atlasmap_filtertype IS 'A description of what aspect of the CSV file the filter should be compared with. Handled values are: ''filename'' - the filter is matched against the name of the file; and ''firstline'' - the filter is matched against the first line of the file contents.'; publicadminfalse342;(00COLUMN atlasmap.atlasmap_atlasCOMMENTHCOMMENT ON COLUMN atlasmap.atlasmap_atlas IS 'The name of the CSVImp Atlas file. This should be a simple pathname, not an absolute or relative name if possible. The full path will be determined by concatenating the operating-system-specific CSV Atlas default directory with the value here unless this is an absolute pathname.'; publicadminfalse342<(00COLUMN atlasmap.atlasmap_mapCOMMENTCOMMENT ON COLUMN atlasmap.atlasmap_map IS 'The name of the Map inside the Atlas to use if the filter and filter type match the CVS file.'; publicadminfalse342=(00#COLUMN atlasmap.atlasmap_headerlineCOMMENTCOMMENT ON COLUMN atlasmap.atlasmap_headerline IS 'An indicator of whether the first line of the CSV file should be treated as a header line or as data.'; publicadminfalse342>(00atlasmapACLREVOKE ALL ON TABLE atlasmap FROM PUBLIC; REVOKE ALL ON TABLE atlasmap FROM admin; GRANT ALL ON TABLE atlasmap TO admin; GRANT ALL ON TABLE atlasmap TO xtrole; publicadminfalse342W125980810atlasmap_atlasmap_id_seqSEQUENCEzCREATE SEQUENCE atlasmap_atlasmap_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.atlasmap_atlasmap_id_seq; publicadminfalse8342?(00atlasmap_atlasmap_id_seqSEQUENCE OWNED BYGALTER SEQUENCE atlasmap_atlasmap_id_seq OWNED BY atlasmap.atlasmap_id; publicadminfalse343@(00atlasmap_atlasmap_id_seqACLREVOKE ALL ON SEQUENCE atlasmap_atlasmap_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE atlasmap_atlasmap_id_seq FROM admin; GRANT ALL ON SEQUENCE atlasmap_atlasmap_id_seq TO admin; GRANT ALL ON SEQUENCE atlasmap_atlasmap_id_seq TO xtrole; publicadminfalse343X125980812 backup_usrTABLE2CREATE TABLE backup_usr ( usr_id integer, usr_username text, usr_propername text, usr_passwd text, usr_locale_id integer, usr_initials text, usr_agent boolean, usr_active boolean, usr_email text, usr_dept_id integer, usr_shift_id integer, usr_window text ); DROP TABLE public.backup_usr; publicadminfalse8A(00 backup_usrACLREVOKE ALL ON TABLE backup_usr FROM PUBLIC; REVOKE ALL ON TABLE backup_usr FROM admin; GRANT ALL ON TABLE backup_usr TO admin; GRANT ALL ON TABLE backup_usr TO xtrole; publicadminfalse344Y125980818bankaccnt_bankaccnt_id_seqSEQUENCE|CREATE SEQUENCE bankaccnt_bankaccnt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 1DROP SEQUENCE public.bankaccnt_bankaccnt_id_seq; publicadminfalse2318B(00bankaccnt_bankaccnt_id_seqSEQUENCE OWNED BYKALTER SEQUENCE bankaccnt_bankaccnt_id_seq OWNED BY bankaccnt.bankaccnt_id; publicadminfalse345C(00bankaccnt_bankaccnt_id_seqACLREVOKE ALL ON SEQUENCE bankaccnt_bankaccnt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bankaccnt_bankaccnt_id_seq FROM admin; GRANT ALL ON SEQUENCE bankaccnt_bankaccnt_id_seq TO admin; GRANT ALL ON SEQUENCE bankaccnt_bankaccnt_id_seq TO xtrole; publicadminfalse345Z125980820bankadjTABLE<CREATE TABLE bankadj ( bankadj_id integer NOT NULL, bankadj_bankaccnt_id integer NOT NULL, bankadj_bankadjtype_id integer NOT NULL, bankadj_created timestamp without time zone DEFAULT now() NOT NULL, bankadj_username text DEFAULT geteffectivextuser() NOT NULL, bankadj_date date NOT NULL, bankadj_docnumber text, bankadj_amount numeric(10,2) NOT NULL, bankadj_notes text, bankadj_sequence integer, bankadj_posted boolean DEFAULT false NOT NULL, bankadj_curr_id integer DEFAULT basecurrid(), bankadj_curr_rate numeric ); DROP TABLE public.bankadj; publicadminfalse63826383638463858D(00 TABLE bankadjCOMMENT<COMMENT ON TABLE bankadj IS 'Bank Adjustments information'; publicadminfalse346E(00bankadjACLREVOKE ALL ON TABLE bankadj FROM PUBLIC; REVOKE ALL ON TABLE bankadj FROM admin; GRANT ALL ON TABLE bankadj TO admin; GRANT ALL ON TABLE bankadj TO xtrole; publicadminfalse346[125980830bankadj_bankadj_id_seqSEQUENCExCREATE SEQUENCE bankadj_bankadj_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.bankadj_bankadj_id_seq; publicadminfalse8346F(00bankadj_bankadj_id_seqSEQUENCE OWNED BYCALTER SEQUENCE bankadj_bankadj_id_seq OWNED BY bankadj.bankadj_id; publicadminfalse347G(00bankadj_bankadj_id_seqACLREVOKE ALL ON SEQUENCE bankadj_bankadj_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bankadj_bankadj_id_seq FROM admin; GRANT ALL ON SEQUENCE bankadj_bankadj_id_seq TO admin; GRANT ALL ON SEQUENCE bankadj_bankadj_id_seq TO xtrole; publicadminfalse347\125980832 bankadjtypeTABLEBCREATE TABLE bankadjtype ( bankadjtype_id integer NOT NULL, bankadjtype_name text NOT NULL, bankadjtype_descrip text, bankadjtype_accnt_id integer NOT NULL, bankadjtype_iscredit boolean DEFAULT false NOT NULL, CONSTRAINT bankadjtype_bankadjtype_name_check CHECK ((bankadjtype_name <> ''::text)) ); DROP TABLE public.bankadjtype; publicadminfalse638863898H(00TABLE bankadjtypeCOMMENTECOMMENT ON TABLE bankadjtype IS 'Bank Adjustment Types information'; publicadminfalse348I(00 bankadjtypeACLREVOKE ALL ON TABLE bankadjtype FROM PUBLIC; REVOKE ALL ON TABLE bankadjtype FROM admin; GRANT ALL ON TABLE bankadjtype TO admin; GRANT ALL ON TABLE bankadjtype TO xtrole; publicadminfalse348]125980840bankadjtype_bankadjtype_id_seqSEQUENCECREATE SEQUENCE bankadjtype_bankadjtype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 5DROP SEQUENCE public.bankadjtype_bankadjtype_id_seq; publicadminfalse8348J(00bankadjtype_bankadjtype_id_seqSEQUENCE OWNED BYSALTER SEQUENCE bankadjtype_bankadjtype_id_seq OWNED BY bankadjtype.bankadjtype_id; publicadminfalse349K(00bankadjtype_bankadjtype_id_seqACLREVOKE ALL ON SEQUENCE bankadjtype_bankadjtype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bankadjtype_bankadjtype_id_seq FROM admin; GRANT ALL ON SEQUENCE bankadjtype_bankadjtype_id_seq TO admin; GRANT ALL ON SEQUENCE bankadjtype_bankadjtype_id_seq TO xtrole; publicadminfalse349^125980842bankrecTABLECREATE TABLE bankrec ( bankrec_id integer NOT NULL, bankrec_created timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL, bankrec_username text DEFAULT geteffectivextuser() NOT NULL, bankrec_bankaccnt_id integer, bankrec_opendate date, bankrec_enddate date, bankrec_openbal numeric(20,2), bankrec_endbal numeric(20,2), bankrec_posted boolean DEFAULT false, bankrec_postdate timestamp without time zone ); DROP TABLE public.bankrec; publicadminfalse6390639163928L(00 TABLE bankrecCOMMENTCCOMMENT ON TABLE bankrec IS 'Bank Reconciliation posting history'; publicadminfalse350M(00bankrecACLREVOKE ALL ON TABLE bankrec FROM PUBLIC; REVOKE ALL ON TABLE bankrec FROM admin; GRANT ALL ON TABLE bankrec TO admin; GRANT ALL ON TABLE bankrec TO xtrole; publicadminfalse350_125980851bankrec_bankrec_id_seqSEQUENCExCREATE SEQUENCE bankrec_bankrec_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.bankrec_bankrec_id_seq; publicadminfalse8350N(00bankrec_bankrec_id_seqSEQUENCE OWNED BYCALTER SEQUENCE bankrec_bankrec_id_seq OWNED BY bankrec.bankrec_id; publicadminfalse351O(00bankrec_bankrec_id_seqACLREVOKE ALL ON SEQUENCE bankrec_bankrec_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bankrec_bankrec_id_seq FROM admin; GRANT ALL ON SEQUENCE bankrec_bankrec_id_seq TO admin; GRANT ALL ON SEQUENCE bankrec_bankrec_id_seq TO xtrole; publicadminfalse351125987327 bankrecimportTABLE>CREATE TABLE bankrecimport ( bankrecimport_id integer NOT NULL, bankrecimport_reference text, bankrecimport_descrip text, bankrecimport_comment text, bankrecimport_debit_amount numeric, bankrecimport_credit_amount numeric, bankrecimport_effdate date, bankrecimport_curr_rate numeric ); !DROP TABLE public.bankrecimport; publicadminfalse8P(00 bankrecimportACLREVOKE ALL ON TABLE bankrecimport FROM PUBLIC; REVOKE ALL ON TABLE bankrecimport FROM admin; GRANT ALL ON TABLE bankrecimport TO admin; GRANT ALL ON TABLE bankrecimport TO xtrole; publicadminfalse783125987330"bankrecimport_bankrecimport_id_seqSEQUENCECREATE SEQUENCE bankrecimport_bankrecimport_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 9DROP SEQUENCE public.bankrecimport_bankrecimport_id_seq; publicadminfalse8783Q(00"bankrecimport_bankrecimport_id_seqSEQUENCE OWNED BY[ALTER SEQUENCE bankrecimport_bankrecimport_id_seq OWNED BY bankrecimport.bankrecimport_id; publicadminfalse784R(00"bankrecimport_bankrecimport_id_seqACLREVOKE ALL ON SEQUENCE bankrecimport_bankrecimport_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bankrecimport_bankrecimport_id_seq FROM admin; GRANT ALL ON SEQUENCE bankrecimport_bankrecimport_id_seq TO admin; GRANT ALL ON SEQUENCE bankrecimport_bankrecimport_id_seq TO xtrole; publicadminfalse784`125980853 bankrecitemTABLEQCREATE TABLE bankrecitem ( bankrecitem_id integer NOT NULL, bankrecitem_bankrec_id integer NOT NULL, bankrecitem_source text NOT NULL, bankrecitem_source_id integer NOT NULL, bankrecitem_cleared boolean DEFAULT false, bankrecitem_curr_rate numeric, bankrecitem_amount numeric, bankrecitem_effdate date ); DROP TABLE public.bankrecitem; publicadminfalse63958S(00TABLE bankrecitemCOMMENTTCOMMENT ON TABLE bankrecitem IS 'Posted Bank Reconciliation Line Item information'; publicadminfalse352T(00 bankrecitemACLREVOKE ALL ON TABLE bankrecitem FROM PUBLIC; REVOKE ALL ON TABLE bankrecitem FROM admin; GRANT ALL ON TABLE bankrecitem TO admin; GRANT ALL ON TABLE bankrecitem TO xtrole; publicadminfalse352a125980860bankrecitem_bankrecitem_id_seqSEQUENCECREATE SEQUENCE bankrecitem_bankrecitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 5DROP SEQUENCE public.bankrecitem_bankrecitem_id_seq; publicadminfalse8352U(00bankrecitem_bankrecitem_id_seqSEQUENCE OWNED BYSALTER SEQUENCE bankrecitem_bankrecitem_id_seq OWNED BY bankrecitem.bankrecitem_id; publicadminfalse353V(00bankrecitem_bankrecitem_id_seqACLREVOKE ALL ON SEQUENCE bankrecitem_bankrecitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bankrecitem_bankrecitem_id_seq FROM admin; GRANT ALL ON SEQUENCE bankrecitem_bankrecitem_id_seq TO admin; GRANT ALL ON SEQUENCE bankrecitem_bankrecitem_id_seq TO xtrole; publicadminfalse353b125980862bomhead_bomhead_id_seqSEQUENCECREATE SEQUENCE bomhead_bomhead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.bomhead_bomhead_id_seq; publicadminfalse8W(00bomhead_bomhead_id_seqACLREVOKE ALL ON SEQUENCE bomhead_bomhead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bomhead_bomhead_id_seq FROM admin; GRANT ALL ON SEQUENCE bomhead_bomhead_id_seq TO admin; GRANT ALL ON SEQUENCE bomhead_bomhead_id_seq TO xtrole; publicadminfalse354c125980864bomitem_bomitem_id_seqSEQUENCECREATE SEQUENCE bomitem_bomitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.bomitem_bomitem_id_seq; publicadminfalse8X(00bomitem_bomitem_id_seqACLREVOKE ALL ON SEQUENCE bomitem_bomitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bomitem_bomitem_id_seq FROM admin; GRANT ALL ON SEQUENCE bomitem_bomitem_id_seq TO admin; GRANT ALL ON SEQUENCE bomitem_bomitem_id_seq TO xtrole; publicadminfalse355d125980866 bomitemcostTABLECREATE TABLE bomitemcost ( bomitemcost_id integer NOT NULL, bomitemcost_bomitem_id integer NOT NULL, bomitemcost_costelem_id integer NOT NULL, bomitemcost_lowlevel boolean DEFAULT false NOT NULL, bomitemcost_stdcost numeric(16,6) DEFAULT 0 NOT NULL, bomitemcost_posted date, bomitemcost_actcost numeric(16,6) DEFAULT 0 NOT NULL, bomitemcost_updated date, bomitemcost_curr_id integer DEFAULT basecurrid() NOT NULL ); DROP TABLE public.bomitemcost; publicadminfalse63966397639863998Y(00TABLE bomitemcostCOMMENT<COMMENT ON TABLE bomitemcost IS 'Bomitem Cost information'; publicadminfalse356Z(00 bomitemcostACLREVOKE ALL ON TABLE bomitemcost FROM PUBLIC; REVOKE ALL ON TABLE bomitemcost FROM admin; GRANT ALL ON TABLE bomitemcost TO admin; GRANT ALL ON TABLE bomitemcost TO xtrole; publicadminfalse356e125980873bomitemcost_bomitemcost_id_seqSEQUENCECREATE SEQUENCE bomitemcost_bomitemcost_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 5DROP SEQUENCE public.bomitemcost_bomitemcost_id_seq; publicadminfalse8356[(00bomitemcost_bomitemcost_id_seqSEQUENCE OWNED BYSALTER SEQUENCE bomitemcost_bomitemcost_id_seq OWNED BY bomitemcost.bomitemcost_id; publicadminfalse357\(00bomitemcost_bomitemcost_id_seqACLREVOKE ALL ON SEQUENCE bomitemcost_bomitemcost_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bomitemcost_bomitemcost_id_seq FROM admin; GRANT ALL ON SEQUENCE bomitemcost_bomitemcost_id_seq TO admin; GRANT ALL ON SEQUENCE bomitemcost_bomitemcost_id_seq TO xtrole; publicadminfalse357f125980875bomitemsub_bomitemsub_id_seqSEQUENCE~CREATE SEQUENCE bomitemsub_bomitemsub_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 3DROP SEQUENCE public.bomitemsub_bomitemsub_id_seq; publicadminfalse8226](00bomitemsub_bomitemsub_id_seqSEQUENCE OWNED BYOALTER SEQUENCE bomitemsub_bomitemsub_id_seq OWNED BY bomitemsub.bomitemsub_id; publicadminfalse358^(00bomitemsub_bomitemsub_id_seqACLREVOKE ALL ON SEQUENCE bomitemsub_bomitemsub_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bomitemsub_bomitemsub_id_seq FROM admin; GRANT ALL ON SEQUENCE bomitemsub_bomitemsub_id_seq TO admin; GRANT ALL ON SEQUENCE bomitemsub_bomitemsub_id_seq TO xtrole; publicadminfalse358g125980877bomworkTABLEFCREATE TABLE bomwork ( bomwork_id integer NOT NULL, bomwork_set_id integer, bomwork_seqnumber integer, bomwork_item_id integer, bomwork_item_type character(1), bomwork_qtyper numeric(20,8), bomwork_scrap numeric(20,10), bomwork_status character(1), bomwork_level integer, bomwork_parent_id integer, bomwork_effective date, bomwork_expires date, bomwork_stdunitcost numeric(16,6), bomwork_actunitcost numeric(16,6), bomwork_parent_seqnumber integer, bomwork_createwo boolean, bomwork_issuemethod character(1), bomwork_char_id integer, bomwork_value text, bomwork_notes text, bomwork_ref text, bomwork_bomitem_id integer, bomwork_ecn text, bomwork_qtyfxd numeric(20,8) DEFAULT 0 NOT NULL, bomwork_qtyreq numeric(20,8) DEFAULT 0 NOT NULL ); DROP TABLE public.bomwork; publicadminfalse640264038_(00 TABLE bomworkCOMMENTCOMMENT ON TABLE bomwork IS 'Temporary table for storing information requested by Bill of Materials (BOM) displays and reports'; publicadminfalse359`(00COLUMN bomwork.bomwork_qtyfxdCOMMENTKCOMMENT ON COLUMN bomwork.bomwork_qtyfxd IS 'The fixed quantity required'; publicadminfalse359a(00COLUMN bomwork.bomwork_qtyreqCOMMENTKCOMMENT ON COLUMN bomwork.bomwork_qtyreq IS 'The total quantity required'; publicadminfalse359b(00bomworkACLREVOKE ALL ON TABLE bomwork FROM PUBLIC; REVOKE ALL ON TABLE bomwork FROM admin; GRANT ALL ON TABLE bomwork TO admin; GRANT ALL ON TABLE bomwork TO xtrole; publicadminfalse359h125980885bomwork_bomwork_id_seqSEQUENCExCREATE SEQUENCE bomwork_bomwork_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.bomwork_bomwork_id_seq; publicadminfalse8359c(00bomwork_bomwork_id_seqSEQUENCE OWNED BYCALTER SEQUENCE bomwork_bomwork_id_seq OWNED BY bomwork.bomwork_id; publicadminfalse360d(00bomwork_bomwork_id_seqACLREVOKE ALL ON SEQUENCE bomwork_bomwork_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE bomwork_bomwork_id_seq FROM admin; GRANT ALL ON SEQUENCE bomwork_bomwork_id_seq TO admin; GRANT ALL ON SEQUENCE bomwork_bomwork_id_seq TO xtrole; publicadminfalse360125987580budgetVIEWCREATE VIEW budget AS SELECT budgitem.budgitem_id AS budget_id, budgitem.budgitem_period_id AS budget_period_id, budgitem.budgitem_accnt_id AS budget_accnt_id, budgitem.budgitem_amount AS budget_amount FROM budgitem; DROP VIEW public.budget; publicadminfalse86748e(00budgetACLREVOKE ALL ON TABLE budget FROM PUBLIC; REVOKE ALL ON TABLE budget FROM admin; GRANT ALL ON TABLE budget TO admin; GRANT ALL ON TABLE budget TO xtrole; publicadminfalse791i125980891budghead_budghead_id_seqSEQUENCEzCREATE SEQUENCE budghead_budghead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.budghead_budghead_id_seq; publicadminfalse8227f(00budghead_budghead_id_seqSEQUENCE OWNED BYGALTER SEQUENCE budghead_budghead_id_seq OWNED BY budghead.budghead_id; publicadminfalse361g(00budghead_budghead_id_seqACLREVOKE ALL ON SEQUENCE budghead_budghead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE budghead_budghead_id_seq FROM admin; GRANT ALL ON SEQUENCE budghead_budghead_id_seq TO admin; GRANT ALL ON SEQUENCE budghead_budghead_id_seq TO xtrole; publicadminfalse361j125980893budgitem_budgitem_id_seqSEQUENCEzCREATE SEQUENCE budgitem_budgitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.budgitem_budgitem_id_seq; publicadminfalse8229h(00budgitem_budgitem_id_seqSEQUENCE OWNED BYGALTER SEQUENCE budgitem_budgitem_id_seq OWNED BY budgitem.budgitem_id; publicadminfalse362i(00budgitem_budgitem_id_seqACLREVOKE ALL ON SEQUENCE budgitem_budgitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE budgitem_budgitem_id_seq FROM admin; GRANT ALL ON SEQUENCE budgitem_budgitem_id_seq TO admin; GRANT ALL ON SEQUENCE budgitem_budgitem_id_seq TO xtrole; publicadminfalse362k125980895calheadTABLE@CREATE TABLE calhead ( calhead_id integer DEFAULT nextval(('"calhead_calhead_id_seq"'::text)::regclass) NOT NULL, calhead_type character(1), calhead_name text NOT NULL, calhead_descrip text, calhead_origin character(1), CONSTRAINT calhead_calhead_name_check CHECK ((calhead_name <> ''::text)) ); DROP TABLE public.calhead; publicadminfalse640464058j(00 TABLE calheadCOMMENT;COMMENT ON TABLE calhead IS 'Calendar header information'; publicadminfalse363k(00calheadACLREVOKE ALL ON TABLE calhead FROM PUBLIC; REVOKE ALL ON TABLE calhead FROM admin; GRANT ALL ON TABLE calhead TO admin; GRANT ALL ON TABLE calhead TO xtrole; publicadminfalse363l125980903calhead_calhead_id_seqSEQUENCECREATE SEQUENCE calhead_calhead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.calhead_calhead_id_seq; publicadminfalse8l(00calhead_calhead_id_seqACLREVOKE ALL ON SEQUENCE calhead_calhead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE calhead_calhead_id_seq FROM admin; GRANT ALL ON SEQUENCE calhead_calhead_id_seq TO admin; GRANT ALL ON SEQUENCE calhead_calhead_id_seq TO xtrole; publicadminfalse364m125980905carrier_carrier_id_seqSEQUENCECREATE SEQUENCE carrier_carrier_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.carrier_carrier_id_seq; publicadminfalse8m(00carrier_carrier_id_seqACLREVOKE ALL ON SEQUENCE carrier_carrier_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE carrier_carrier_id_seq FROM admin; GRANT ALL ON SEQUENCE carrier_carrier_id_seq TO admin; GRANT ALL ON SEQUENCE carrier_carrier_id_seq TO xtrole; publicadminfalse365n125980907cashrcpt_cashrcpt_id_seqSEQUENCEzCREATE SEQUENCE cashrcpt_cashrcpt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.cashrcpt_cashrcpt_id_seq; publicadminfalse8232n(00cashrcpt_cashrcpt_id_seqSEQUENCE OWNED BYGALTER SEQUENCE cashrcpt_cashrcpt_id_seq OWNED BY cashrcpt.cashrcpt_id; publicadminfalse366o(00cashrcpt_cashrcpt_id_seqACLREVOKE ALL ON SEQUENCE cashrcpt_cashrcpt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cashrcpt_cashrcpt_id_seq FROM admin; GRANT ALL ON SEQUENCE cashrcpt_cashrcpt_id_seq TO admin; GRANT ALL ON SEQUENCE cashrcpt_cashrcpt_id_seq TO xtrole; publicadminfalse366o125980909 cashrcptmisc_cashrcptmisc_id_seqSEQUENCECREATE SEQUENCE cashrcptmisc_cashrcptmisc_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 7DROP SEQUENCE public.cashrcptmisc_cashrcptmisc_id_seq; publicadminfalse8234p(00 cashrcptmisc_cashrcptmisc_id_seqSEQUENCE OWNED BYWALTER SEQUENCE cashrcptmisc_cashrcptmisc_id_seq OWNED BY cashrcptmisc.cashrcptmisc_id; publicadminfalse367q(00 cashrcptmisc_cashrcptmisc_id_seqACL REVOKE ALL ON SEQUENCE cashrcptmisc_cashrcptmisc_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cashrcptmisc_cashrcptmisc_id_seq FROM admin; GRANT ALL ON SEQUENCE cashrcptmisc_cashrcptmisc_id_seq TO admin; GRANT ALL ON SEQUENCE cashrcptmisc_cashrcptmisc_id_seq TO xtrole; publicadminfalse367p125980911ccard_ccard_id_seqSEQUENCEtCREATE SEQUENCE ccard_ccard_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; )DROP SEQUENCE public.ccard_ccard_id_seq; publicadminfalse8235r(00ccard_ccard_id_seqSEQUENCE OWNED BY;ALTER SEQUENCE ccard_ccard_id_seq OWNED BY ccard.ccard_id; publicadminfalse368s(00ccard_ccard_id_seqACLREVOKE ALL ON SEQUENCE ccard_ccard_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ccard_ccard_id_seq FROM admin; GRANT ALL ON SEQUENCE ccard_ccard_id_seq TO admin; GRANT ALL ON SEQUENCE ccard_ccard_id_seq TO xtrole; publicadminfalse368q125980913ccardaudTABLECREATE TABLE ccardaud ( ccardaud_id integer NOT NULL, ccardaud_ccard_id integer, ccardaud_ccard_seq_old integer, ccardaud_ccard_seq_new integer, ccardaud_ccard_cust_id_old integer, ccardaud_ccard_cust_id_new integer, ccardaud_ccard_active_old boolean, ccardaud_ccard_active_new boolean, ccardaud_ccard_name_old bytea, ccardaud_ccard_name_new bytea, ccardaud_ccard_address1_old bytea, ccardaud_ccard_address1_new bytea, ccardaud_ccard_address2_old bytea, ccardaud_ccard_address2_new bytea, ccardaud_ccard_city_old bytea, ccardaud_ccard_city_new bytea, ccardaud_ccard_state_old bytea, ccardaud_ccard_state_new bytea, ccardaud_ccard_zip_old bytea, ccardaud_ccard_zip_new bytea, ccardaud_ccard_country_old bytea, ccardaud_ccard_country_new bytea, ccardaud_ccard_number_old bytea, ccardaud_ccard_number_new bytea, ccardaud_ccard_debit_old boolean, ccardaud_ccard_debit_new boolean, ccardaud_ccard_month_expired_old bytea, ccardaud_ccard_month_expired_new bytea, ccardaud_ccard_year_expired_old bytea, ccardaud_ccard_year_expired_new bytea, ccardaud_ccard_type_old character(1), ccardaud_ccard_type_new character(1), ccardaud_ccard_last_updated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL, ccardaud_ccard_last_updated_by_username text DEFAULT geteffectivextuser() NOT NULL ); DROP TABLE public.ccardaud; publicadminfalse640764088t(00TABLE ccardaudCOMMENTFCOMMENT ON TABLE ccardaud IS 'Credit Card Information tracking data'; publicadminfalse369u(00ccardaudACLREVOKE ALL ON TABLE ccardaud FROM PUBLIC; REVOKE ALL ON TABLE ccardaud FROM admin; GRANT ALL ON TABLE ccardaud TO admin; GRANT ALL ON TABLE ccardaud TO xtrole; publicadminfalse369r125980921ccardaud_ccardaud_id_seqSEQUENCEzCREATE SEQUENCE ccardaud_ccardaud_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.ccardaud_ccardaud_id_seq; publicadminfalse8369v(00ccardaud_ccardaud_id_seqSEQUENCE OWNED BYGALTER SEQUENCE ccardaud_ccardaud_id_seq OWNED BY ccardaud.ccardaud_id; publicadminfalse370w(00ccardaud_ccardaud_id_seqACLREVOKE ALL ON SEQUENCE ccardaud_ccardaud_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ccardaud_ccardaud_id_seq FROM admin; GRANT ALL ON SEQUENCE ccardaud_ccardaud_id_seq TO admin; GRANT ALL ON SEQUENCE ccardaud_ccardaud_id_seq TO xtrole; publicadminfalse370s125980923ccbankTABLECREATE TABLE ccbank ( ccbank_id integer NOT NULL, ccbank_ccard_type text NOT NULL, ccbank_bankaccnt_id integer, CONSTRAINT ccbank_ccbank_ccard_type_check CHECK ((ccbank_ccard_type = ANY (ARRAY['A'::text, 'D'::text, 'M'::text, 'P'::text, 'V'::text, 'O'::text]))) ); DROP TABLE public.ccbank; publicadminfalse64108x(00ccbankACLREVOKE ALL ON TABLE ccbank FROM PUBLIC; REVOKE ALL ON TABLE ccbank FROM admin; GRANT ALL ON TABLE ccbank TO admin; GRANT ALL ON TABLE ccbank TO xtrole; publicadminfalse371t125980930ccbank_ccbank_id_seqSEQUENCEvCREATE SEQUENCE ccbank_ccbank_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.ccbank_ccbank_id_seq; publicadminfalse8371y(00ccbank_ccbank_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE ccbank_ccbank_id_seq OWNED BY ccbank.ccbank_id; publicadminfalse372z(00ccbank_ccbank_id_seqACLREVOKE ALL ON SEQUENCE ccbank_ccbank_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ccbank_ccbank_id_seq FROM admin; GRANT ALL ON SEQUENCE ccbank_ccbank_id_seq TO admin; GRANT ALL ON SEQUENCE ccbank_ccbank_id_seq TO xtrole; publicadminfalse372u125980932ccpayTABLECREATE TABLE ccpay ( ccpay_id integer NOT NULL, ccpay_ccard_id integer, ccpay_cust_id integer, ccpay_amount numeric(20,2) DEFAULT 0.00 NOT NULL, ccpay_auth boolean DEFAULT true NOT NULL, ccpay_status character(1) NOT NULL, ccpay_type character(1) NOT NULL, ccpay_auth_charge character(1) NOT NULL, ccpay_order_number text, ccpay_order_number_seq integer, ccpay_r_avs text, ccpay_r_ordernum text, ccpay_r_error text, ccpay_r_approved text, ccpay_r_code text, ccpay_r_message text, ccpay_yp_r_time timestamp without time zone, ccpay_r_ref text, ccpay_yp_r_tdate text, ccpay_r_tax text, ccpay_r_shipping text, ccpay_yp_r_score integer, ccpay_transaction_datetime timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL, ccpay_by_username text DEFAULT geteffectivextuser() NOT NULL, ccpay_curr_id integer DEFAULT basecurrid(), ccpay_ccpay_id integer, ccpay_card_pan_trunc text, ccpay_card_type text ); DROP TABLE public.ccpay; publicadminfalse641164126413641464158{(00 TABLE ccpayCOMMENT<COMMENT ON TABLE ccpay IS 'Track Credit Card PAYments, although really this table tracs communications with Credit Card processing companies. Records in this table may progress from preauthorizations through captures to credits, or they may simply remain in their original state if there is no further processing.'; publicadminfalse373|(00COLUMN ccpay.ccpay_idCOMMENTICOMMENT ON COLUMN ccpay.ccpay_id IS 'Internal ID of this ccpay record.'; publicadminfalse373}(00COLUMN ccpay.ccpay_ccard_idCOMMENTgCOMMENT ON COLUMN ccpay.ccpay_ccard_id IS 'Internal ID of the Credit Card used for this transaction.'; publicadminfalse373~(00COLUMN ccpay.ccpay_cust_idCOMMENT_COMMENT ON COLUMN ccpay.ccpay_cust_id IS 'Internal ID of the Customer owning the Credit Card'; publicadminfalse373(00COLUMN ccpay.ccpay_amountCOMMENTNCOMMENT ON COLUMN ccpay.ccpay_amount IS 'Actual amount of this transaction.'; publicadminfalse373(00COLUMN ccpay.ccpay_authCOMMENTCOMMENT ON COLUMN ccpay.ccpay_auth IS 'Boolean indicator of whether this transaction started out as a pre-authorization or not.'; publicadminfalse373(00COLUMN ccpay.ccpay_statusCOMMENTCOMMENT ON COLUMN ccpay.ccpay_status IS 'The status of the last attempted transaction for this record. Values include A = Authorized, C = Charged, D = Declined or otherwise rejected, V = Voided, X = Error.'; publicadminfalse373(00COLUMN ccpay.ccpay_typeCOMMENTCOMMENT ON COLUMN ccpay.ccpay_type IS 'The most recent type of transaction attempted with this record. Values include A = Authorize, C = Capture or Charge, R = cRedit, V = reVerse or Void.'; publicadminfalse373(00COLUMN ccpay.ccpay_auth_chargeCOMMENTCOMMENT ON COLUMN ccpay.ccpay_auth_charge IS 'The original type of transaction attempted with this record. Values are the same as for ccpay_type.'; publicadminfalse373(00COLUMN ccpay.ccpay_order_numberCOMMENTCOMMENT ON COLUMN ccpay.ccpay_order_number IS 'The original xTuple ERP order for which this credit card transaction applies. This will usually be either a Sales Order number or Credit Memo number.'; publicadminfalse373(00#COLUMN ccpay.ccpay_order_number_seqCOMMENTCOMMENT ON COLUMN ccpay.ccpay_order_number_seq IS 'A sequence number to differentiate between different transactions for the same ccpay_order_number. For example, if a Customer makes a down payment and a final payment for a single order, there will be two distinct ccpay records with the same ccpay_order_number but different ccpay_order_number_seq values (1 and 2, respectively).'; publicadminfalse373(00COLUMN ccpay.ccpay_r_avsCOMMENTCOMMENT ON COLUMN ccpay.ccpay_r_avs IS 'The Address Verification System code returned by the credit card processing company.'; publicadminfalse373(00COLUMN ccpay.ccpay_r_ordernumCOMMENTCOMMENT ON COLUMN ccpay.ccpay_r_ordernum IS 'A transaction ID returned by the credit card processing company to be used when referring to this transaction later. It may be used for voiding, crediting, or capturing previous transactions.'; publicadminfalse373(00COLUMN ccpay.ccpay_r_errorCOMMENTCOMMENT ON COLUMN ccpay.ccpay_r_error IS 'Error message, if any, describing why this record failed to be processed properly.'; publicadminfalse373(00COLUMN ccpay.ccpay_r_approvedCOMMENTCOMMENT ON COLUMN ccpay.ccpay_r_approved IS 'English text stating whether the transaction was approved, declined, hit an error, or was held for review. Specific values differ depending on the credit card processor.'; publicadminfalse373(00COLUMN ccpay.ccpay_r_codeCOMMENTCOMMENT ON COLUMN ccpay.ccpay_r_code IS 'The transaction Approval code returned by the credit card processor. Specific values differ depending on the credit card processor.'; publicadminfalse373(00COLUMN ccpay.ccpay_r_messageCOMMENTCOMMENT ON COLUMN ccpay.ccpay_r_message IS 'Additional text that describes the status of the transaction. This may be empty.'; publicadminfalse373(00COLUMN ccpay.ccpay_yp_r_timeCOMMENTCOMMENT ON COLUMN ccpay.ccpay_yp_r_time IS 'The time the transaction was posted according to the credit card processing company. May be blank.'; publicadminfalse373(00COLUMN ccpay.ccpay_r_refCOMMENTCOMMENT ON COLUMN ccpay.ccpay_r_ref IS 'An additional reference number assigned to this transaction by the credit card processing company.'; publicadminfalse373(00COLUMN ccpay.ccpay_yp_r_tdateCOMMENTCOMMENT ON COLUMN ccpay.ccpay_yp_r_tdate IS 'The date the transaction was posted according to the credit card processing company. May be blank.'; publicadminfalse373(00COLUMN ccpay.ccpay_r_taxCOMMENT9COMMENT ON COLUMN ccpay.ccpay_r_tax IS '[ deprecated ]'; publicadminfalse373(00COLUMN ccpay.ccpay_r_shippingCOMMENT>COMMENT ON COLUMN ccpay.ccpay_r_shipping IS '[ deprecated ]'; publicadminfalse373(00COLUMN ccpay.ccpay_yp_r_scoreCOMMENTzCOMMENT ON COLUMN ccpay.ccpay_yp_r_score IS 'A potential fraud score returned by the credit card company. May be blank.'; publicadminfalse373(00'COLUMN ccpay.ccpay_transaction_datetimeCOMMENTCOMMENT ON COLUMN ccpay.ccpay_transaction_datetime IS 'The date and time this record was created, unless explicitly set by the application.'; publicadminfalse373(00COLUMN ccpay.ccpay_by_usernameCOMMENT|COMMENT ON COLUMN ccpay.ccpay_by_username IS 'The user who created this record, unless explicitly set by the application.'; publicadminfalse373(00COLUMN ccpay.ccpay_curr_idCOMMENTaCOMMENT ON COLUMN ccpay.ccpay_curr_id IS 'The internal ID of the currency of the ccpay_amount.'; publicadminfalse373(00COLUMN ccpay.ccpay_ccpay_idCOMMENTCOMMENT ON COLUMN ccpay.ccpay_ccpay_id IS 'Foreign key to another ccpay record. This will have a value if a new ccpay record is created to record a Refund for part or all of another ccpay record.'; publicadminfalse373(00!COLUMN ccpay.ccpay_card_pan_truncCOMMENTrCOMMENT ON COLUMN ccpay.ccpay_card_pan_trunc IS 'External Pre-Auth truncated PAN. Last four digits of the card.'; publicadminfalse373(00COLUMN ccpay.ccpay_card_typeCOMMENTCOMMENT ON COLUMN ccpay.ccpay_card_type IS 'External Pre-Auth card type: V=Visa, M=MasterCard, A=American Express, D=Discover.'; publicadminfalse373(00ccpayACLREVOKE ALL ON TABLE ccpay FROM PUBLIC; REVOKE ALL ON TABLE ccpay FROM admin; GRANT ALL ON TABLE ccpay TO admin; GRANT ALL ON TABLE ccpay TO xtrole; publicadminfalse373v125980943ccpay_ccpay_id_seqSEQUENCEtCREATE SEQUENCE ccpay_ccpay_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; )DROP SEQUENCE public.ccpay_ccpay_id_seq; publicadminfalse8373(00ccpay_ccpay_id_seqSEQUENCE OWNED BY;ALTER SEQUENCE ccpay_ccpay_id_seq OWNED BY ccpay.ccpay_id; publicadminfalse374(00ccpay_ccpay_id_seqACLREVOKE ALL ON SEQUENCE ccpay_ccpay_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ccpay_ccpay_id_seq FROM admin; GRANT ALL ON SEQUENCE ccpay_ccpay_id_seq TO admin; GRANT ALL ON SEQUENCE ccpay_ccpay_id_seq TO xtrole; publicadminfalse374w125980945char_char_id_seqSEQUENCErCREATE SEQUENCE char_char_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 'DROP SEQUENCE public.char_char_id_seq; publicadminfalse8214(00char_char_id_seqSEQUENCE OWNED BY9ALTER SEQUENCE char_char_id_seq OWNED BY "char".char_id; publicadminfalse375(00char_char_id_seqACLREVOKE ALL ON SEQUENCE char_char_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE char_char_id_seq FROM admin; GRANT ALL ON SEQUENCE char_char_id_seq TO admin; GRANT ALL ON SEQUENCE char_char_id_seq TO xtrole; publicadminfalse375x125980947charass_charass_id_seqSEQUENCExCREATE SEQUENCE charass_charass_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.charass_charass_id_seq; publicadminfalse8215(00charass_charass_id_seqSEQUENCE OWNED BYCALTER SEQUENCE charass_charass_id_seq OWNED BY charass.charass_id; publicadminfalse376(00charass_charass_id_seqACLREVOKE ALL ON SEQUENCE charass_charass_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE charass_charass_id_seq FROM admin; GRANT ALL ON SEQUENCE charass_charass_id_seq TO admin; GRANT ALL ON SEQUENCE charass_charass_id_seq TO xtrole; publicadminfalse376y125980949charoptTABLECREATE TABLE charopt ( charopt_id integer NOT NULL, charopt_char_id integer, charopt_value text NOT NULL, charopt_order integer DEFAULT 0 NOT NULL ); DROP TABLE public.charopt; publicadminfalse64188(00 TABLE charoptCOMMENTGCOMMENT ON TABLE charopt IS 'Stores list options for characteristics'; publicadminfalse377(00COLUMN charopt.charopt_idCOMMENT7COMMENT ON COLUMN charopt.charopt_id IS 'Primary key'; publicadminfalse377(00COLUMN charopt.charopt_char_idCOMMENTHCOMMENT ON COLUMN charopt.charopt_char_id IS 'Reference to char table'; publicadminfalse377(00COLUMN charopt.charopt_valueCOMMENT;COMMENT ON COLUMN charopt.charopt_value IS 'Option value'; publicadminfalse377(00COLUMN charopt.charopt_orderCOMMENT@COMMENT ON COLUMN charopt.charopt_order IS 'Option sort order'; publicadminfalse377(00charoptACLREVOKE ALL ON TABLE charopt FROM PUBLIC; REVOKE ALL ON TABLE charopt FROM admin; GRANT ALL ON TABLE charopt TO admin; GRANT ALL ON TABLE charopt TO xtrole; publicadminfalse377z125980956charopt_charopt_id_seqSEQUENCExCREATE SEQUENCE charopt_charopt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.charopt_charopt_id_seq; publicadminfalse8377(00charopt_charopt_id_seqSEQUENCE OWNED BYCALTER SEQUENCE charopt_charopt_id_seq OWNED BY charopt.charopt_id; publicadminfalse378(00charopt_charopt_id_seqACLREVOKE ALL ON SEQUENCE charopt_charopt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE charopt_charopt_id_seq FROM admin; GRANT ALL ON SEQUENCE charopt_charopt_id_seq TO admin; GRANT ALL ON SEQUENCE charopt_charopt_id_seq TO xtrole; publicadminfalse378125987343charuseTABLECREATE TABLE charuse ( charuse_id integer NOT NULL, charuse_char_id integer, charuse_target_type text DEFAULT ''::text NOT NULL, charuse_created timestamp with time zone DEFAULT now() NOT NULL, charuse_last_modified timestamp with time zone DEFAULT now() NOT NULL ); DROP TABLE public.charuse; publicadminfalse6817681868198(00COLUMN charuse.charuse_idCOMMENTOCOMMENT ON COLUMN charuse.charuse_id IS 'Internal ID of this charuse record.'; publicadminfalse785(00"COLUMN charuse.charuse_target_typeCOMMENTCOMMENT ON COLUMN charuse.charuse_target_type IS 'If a row exists in the charuse table for a given target type, characteristic assignments can be used'; publicadminfalse785(00charuseACLREVOKE ALL ON TABLE charuse FROM PUBLIC; REVOKE ALL ON TABLE charuse FROM admin; GRANT ALL ON TABLE charuse TO admin; GRANT ALL ON TABLE charuse TO xtrole; publicadminfalse785125987346charuse_charuse_id_seqSEQUENCExCREATE SEQUENCE charuse_charuse_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.charuse_charuse_id_seq; publicadminfalse7858(00charuse_charuse_id_seqSEQUENCE OWNED BYCALTER SEQUENCE charuse_charuse_id_seq OWNED BY charuse.charuse_id; publicadminfalse786(00charuse_charuse_id_seqACLREVOKE ALL ON SEQUENCE charuse_charuse_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE charuse_charuse_id_seq FROM admin; GRANT ALL ON SEQUENCE charuse_charuse_id_seq TO admin; GRANT ALL ON SEQUENCE charuse_charuse_id_seq TO xtrole; publicadminfalse786{125980958checkhead_checkhead_id_seqSEQUENCE|CREATE SEQUENCE checkhead_checkhead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 1DROP SEQUENCE public.checkhead_checkhead_id_seq; publicadminfalse8318(00checkhead_checkhead_id_seqSEQUENCE OWNED BYKALTER SEQUENCE checkhead_checkhead_id_seq OWNED BY checkhead.checkhead_id; publicadminfalse379(00checkhead_checkhead_id_seqACLREVOKE ALL ON SEQUENCE checkhead_checkhead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE checkhead_checkhead_id_seq FROM admin; GRANT ALL ON SEQUENCE checkhead_checkhead_id_seq TO admin; GRANT ALL ON SEQUENCE checkhead_checkhead_id_seq TO xtrole; publicadminfalse379|125980960checkitem_checkitem_id_seqSEQUENCE|CREATE SEQUENCE checkitem_checkitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 1DROP SEQUENCE public.checkitem_checkitem_id_seq; publicadminfalse8320(00checkitem_checkitem_id_seqSEQUENCE OWNED BYKALTER SEQUENCE checkitem_checkitem_id_seq OWNED BY checkitem.checkitem_id; publicadminfalse380(00checkitem_checkitem_id_seqACLREVOKE ALL ON SEQUENCE checkitem_checkitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE checkitem_checkitem_id_seq FROM admin; GRANT ALL ON SEQUENCE checkitem_checkitem_id_seq TO admin; GRANT ALL ON SEQUENCE checkitem_checkitem_id_seq TO xtrole; publicadminfalse380125987584 checkrecipVIEWCREATE VIEW checkrecip AS (SELECT custinfo.cust_id AS checkrecip_id, 'C'::text AS checkrecip_type, custinfo.cust_number AS checkrecip_number, custinfo.cust_name AS checkrecip_name, 'A/R'::text AS checkrecip_gltrans_source, findaraccount(custinfo.cust_id) AS checkrecip_accnt_id, cntct.cntct_addr_id AS checkrecip_addr_id FROM (custinfo LEFT JOIN cntct ON ((custinfo.cust_cntct_id = cntct.cntct_id))) UNION ALL SELECT taxauth.taxauth_id AS checkrecip_id, 'T'::text AS checkrecip_type, taxauth.taxauth_code AS checkrecip_number, taxauth.taxauth_name AS checkrecip_name, 'G/L'::text AS checkrecip_gltrans_source, taxauth.taxauth_accnt_id AS checkrecip_accnt_id, taxauth.taxauth_addr_id AS checkrecip_addr_id FROM taxauth) UNION ALL SELECT vendinfo.vend_id AS checkrecip_id, 'V'::text AS checkrecip_type, vendinfo.vend_number AS checkrecip_number, vendinfo.vend_name AS checkrecip_name, 'A/P'::text AS checkrecip_gltrans_source, findapaccount(vendinfo.vend_id) AS checkrecip_accnt_id, vendaddrinfo.vendaddr_addr_id AS checkrecip_addr_id FROM (vendinfo LEFT JOIN vendaddrinfo ON (((vendinfo.vend_id = vendaddrinfo.vendaddr_vend_id) AND (upper(vendaddrinfo.vendaddr_code) = 'REMIT'::text)))); DROP VIEW public.checkrecip; publicadminfalse86758(00 checkrecipACLREVOKE ALL ON TABLE checkrecip FROM PUBLIC; REVOKE ALL ON TABLE checkrecip FROM admin; GRANT ALL ON TABLE checkrecip TO admin; GRANT ALL ON TABLE checkrecip TO xtrole; publicadminfalse792}125980967classcode_classcode_id_seqSEQUENCECREATE SEQUENCE classcode_classcode_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; 1DROP SEQUENCE public.classcode_classcode_id_seq; publicadminfalse8(00classcode_classcode_id_seqACLREVOKE ALL ON SEQUENCE classcode_classcode_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE classcode_classcode_id_seq FROM admin; GRANT ALL ON SEQUENCE classcode_classcode_id_seq TO admin; GRANT ALL ON SEQUENCE classcode_classcode_id_seq TO xtrole; publicadminfalse381~125980969cmhead_cmhead_id_seqSEQUENCE~CREATE SEQUENCE cmhead_cmhead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; +DROP SEQUENCE public.cmhead_cmhead_id_seq; publicadminfalse8(00cmhead_cmhead_id_seqACLREVOKE ALL ON SEQUENCE cmhead_cmhead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cmhead_cmhead_id_seq FROM admin; GRANT ALL ON SEQUENCE cmhead_cmhead_id_seq TO admin; GRANT ALL ON SEQUENCE cmhead_cmhead_id_seq TO xtrole; publicadminfalse382125980971 cmheadtaxTABLE/CREATE TABLE cmheadtax ( ) INHERITS (taxhist); DROP TABLE public.cmheadtax; publicadminfalse8281(00 cmheadtaxACLREVOKE ALL ON TABLE cmheadtax FROM PUBLIC; REVOKE ALL ON TABLE cmheadtax FROM admin; GRANT ALL ON TABLE cmheadtax TO admin; GRANT ALL ON TABLE cmheadtax TO xtrole; publicadminfalse383125980977cmitem_cmitem_id_seqSEQUENCE~CREATE SEQUENCE cmitem_cmitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; +DROP SEQUENCE public.cmitem_cmitem_id_seq; publicadminfalse8(00cmitem_cmitem_id_seqACLREVOKE ALL ON SEQUENCE cmitem_cmitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cmitem_cmitem_id_seq FROM admin; GRANT ALL ON SEQUENCE cmitem_cmitem_id_seq TO admin; GRANT ALL ON SEQUENCE cmitem_cmitem_id_seq TO xtrole; publicadminfalse384125980979 cmitemtaxTABLE/CREATE TABLE cmitemtax ( ) INHERITS (taxhist); DROP TABLE public.cmitemtax; publicadminfalse8281(00 cmitemtaxACLREVOKE ALL ON TABLE cmitemtax FROM PUBLIC; REVOKE ALL ON TABLE cmitemtax FROM admin; GRANT ALL ON TABLE cmitemtax TO admin; GRANT ALL ON TABLE cmitemtax TO xtrole; publicadminfalse385125980985cmnttype_cmnttype_id_seqSEQUENCEzCREATE SEQUENCE cmnttype_cmnttype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.cmnttype_cmnttype_id_seq; publicadminfalse8216(00cmnttype_cmnttype_id_seqSEQUENCE OWNED BYGALTER SEQUENCE cmnttype_cmnttype_id_seq OWNED BY cmnttype.cmnttype_id; publicadminfalse386(00cmnttype_cmnttype_id_seqACLREVOKE ALL ON SEQUENCE cmnttype_cmnttype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cmnttype_cmnttype_id_seq FROM admin; GRANT ALL ON SEQUENCE cmnttype_cmnttype_id_seq TO admin; GRANT ALL ON SEQUENCE cmnttype_cmnttype_id_seq TO xtrole; publicadminfalse386125980987cmnttypesourceTABLECREATE TABLE cmnttypesource ( cmnttypesource_id integer NOT NULL, cmnttypesource_cmnttype_id integer NOT NULL, cmnttypesource_source_id integer NOT NULL ); "DROP TABLE public.cmnttypesource; publicadminfalse8(00TABLE cmnttypesourceCOMMENTCOMMENT ON TABLE cmnttypesource IS 'Description of which types of comment the user should be allowed to select for various types of document (source).'; publicadminfalse387(00cmnttypesourceACLREVOKE ALL ON TABLE cmnttypesource FROM PUBLIC; REVOKE ALL ON TABLE cmnttypesource FROM admin; GRANT ALL ON TABLE cmnttypesource TO admin; GRANT ALL ON TABLE cmnttypesource TO xtrole; publicadminfalse387125980990$cmnttypesource_cmnttypesource_id_seqSEQUENCECREATE SEQUENCE cmnttypesource_cmnttypesource_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ;DROP SEQUENCE public.cmnttypesource_cmnttypesource_id_seq; publicadminfalse3878(00$cmnttypesource_cmnttypesource_id_seqSEQUENCE OWNED BY_ALTER SEQUENCE cmnttypesource_cmnttypesource_id_seq OWNED BY cmnttypesource.cmnttypesource_id; publicadminfalse388(00$cmnttypesource_cmnttypesource_id_seqACLREVOKE ALL ON SEQUENCE cmnttypesource_cmnttypesource_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cmnttypesource_cmnttypesource_id_seq FROM admin; GRANT ALL ON SEQUENCE cmnttypesource_cmnttypesource_id_seq TO admin; GRANT ALL ON SEQUENCE cmnttypesource_cmnttypesource_id_seq TO xtrole; publicadminfalse388125980992cntct_cntct_id_seqSEQUENCEtCREATE SEQUENCE cntct_cntct_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; )DROP SEQUENCE public.cntct_cntct_id_seq; publicadminfalse8187(00cntct_cntct_id_seqSEQUENCE OWNED BY;ALTER SEQUENCE cntct_cntct_id_seq OWNED BY cntct.cntct_id; publicadminfalse389(00cntct_cntct_id_seqACLREVOKE ALL ON SEQUENCE cntct_cntct_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cntct_cntct_id_seq FROM admin; GRANT ALL ON SEQUENCE cntct_cntct_id_seq TO admin; GRANT ALL ON SEQUENCE cntct_cntct_id_seq TO xtrole; publicadminfalse389125980994 cntctaddrTABLECREATE TABLE cntctaddr ( cntctaddr_id integer NOT NULL, cntctaddr_cntct_id integer, cntctaddr_primary boolean NOT NULL, cntctaddr_addr_id integer NOT NULL, cntctaddr_type character(2) NOT NULL ); DROP TABLE public.cntctaddr; publicadminfalse8(00 cntctaddrACLREVOKE ALL ON TABLE cntctaddr FROM PUBLIC; REVOKE ALL ON TABLE cntctaddr FROM admin; GRANT ALL ON TABLE cntctaddr TO admin; GRANT ALL ON TABLE cntctaddr TO xtrole; publicadminfalse390125980997cntctaddr_cntctaddr_id_seqSEQUENCE|CREATE SEQUENCE cntctaddr_cntctaddr_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 1DROP SEQUENCE public.cntctaddr_cntctaddr_id_seq; publicadminfalse8390(00cntctaddr_cntctaddr_id_seqSEQUENCE OWNED BYKALTER SEQUENCE cntctaddr_cntctaddr_id_seq OWNED BY cntctaddr.cntctaddr_id; publicadminfalse391(00cntctaddr_cntctaddr_id_seqACLREVOKE ALL ON SEQUENCE cntctaddr_cntctaddr_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cntctaddr_cntctaddr_id_seq FROM admin; GRANT ALL ON SEQUENCE cntctaddr_cntctaddr_id_seq TO admin; GRANT ALL ON SEQUENCE cntctaddr_cntctaddr_id_seq TO xtrole; publicadminfalse391125980999 cntctdataTABLECREATE TABLE cntctdata ( cntctdata_id integer NOT NULL, cntctdata_cntct_id integer, cntctdata_primary boolean NOT NULL, cntctdata_text text NOT NULL, cntctdata_type character(2) NOT NULL ); DROP TABLE public.cntctdata; publicadminfalse8(00 cntctdataACLREVOKE ALL ON TABLE cntctdata FROM PUBLIC; REVOKE ALL ON TABLE cntctdata FROM admin; GRANT ALL ON TABLE cntctdata TO admin; GRANT ALL ON TABLE cntctdata TO xtrole; publicadminfalse392125981005cntctdata_cntctdata_id_seqSEQUENCE|CREATE SEQUENCE cntctdata_cntctdata_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 1DROP SEQUENCE public.cntctdata_cntctdata_id_seq; publicadminfalse8392(00cntctdata_cntctdata_id_seqSEQUENCE OWNED BYKALTER SEQUENCE cntctdata_cntctdata_id_seq OWNED BY cntctdata.cntctdata_id; publicadminfalse393(00cntctdata_cntctdata_id_seqACLREVOKE ALL ON SEQUENCE cntctdata_cntctdata_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cntctdata_cntctdata_id_seq FROM admin; GRANT ALL ON SEQUENCE cntctdata_cntctdata_id_seq TO admin; GRANT ALL ON SEQUENCE cntctdata_cntctdata_id_seq TO xtrole; publicadminfalse393125981007cntctemlTABLECREATE TABLE cntcteml ( cntcteml_id integer NOT NULL, cntcteml_cntct_id integer, cntcteml_primary boolean DEFAULT false NOT NULL, cntcteml_email text NOT NULL ); DROP TABLE public.cntcteml; publicadminfalse64258(00TABLE cntctemlCOMMENTDCOMMENT ON TABLE cntcteml IS 'Stores email addresses for contacts'; publicadminfalse394(00COLUMN cntcteml.cntcteml_idCOMMENT9COMMENT ON COLUMN cntcteml.cntcteml_id IS 'Primary key'; publicadminfalse394(00!COLUMN cntcteml.cntcteml_cntct_idCOMMENTNCOMMENT ON COLUMN cntcteml.cntcteml_cntct_id IS 'Reference to contact table'; publicadminfalse394(00 COLUMN cntcteml.cntcteml_primaryCOMMENTbCOMMENT ON COLUMN cntcteml.cntcteml_primary IS 'Flags whether this is the primary email address'; publicadminfalse394(00COLUMN cntcteml.cntcteml_emailCOMMENTFCOMMENT ON COLUMN cntcteml.cntcteml_email IS 'Alternate information'; publicadminfalse394(00cntctemlACLREVOKE ALL ON TABLE cntcteml FROM PUBLIC; REVOKE ALL ON TABLE cntcteml FROM admin; GRANT ALL ON TABLE cntcteml TO admin; GRANT ALL ON TABLE cntcteml TO xtrole; publicadminfalse394125981014cntcteml_cntcteml_id_seqSEQUENCEzCREATE SEQUENCE cntcteml_cntcteml_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.cntcteml_cntcteml_id_seq; publicadminfalse8394(00cntcteml_cntcteml_id_seqSEQUENCE OWNED BYGALTER SEQUENCE cntcteml_cntcteml_id_seq OWNED BY cntcteml.cntcteml_id; publicadminfalse395(00cntcteml_cntcteml_id_seqACLREVOKE ALL ON SEQUENCE cntcteml_cntcteml_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cntcteml_cntcteml_id_seq FROM admin; GRANT ALL ON SEQUENCE cntcteml_cntcteml_id_seq TO admin; GRANT ALL ON SEQUENCE cntcteml_cntcteml_id_seq TO xtrole; publicadminfalse395125981016 cntctmrgdTABLEoCREATE TABLE cntctmrgd ( cntctmrgd_cntct_id integer NOT NULL, cntctmrgd_error boolean DEFAULT false ); DROP TABLE public.cntctmrgd; publicadminfalse64268(00 cntctmrgdACLREVOKE ALL ON TABLE cntctmrgd FROM PUBLIC; REVOKE ALL ON TABLE cntctmrgd FROM admin; GRANT ALL ON TABLE cntctmrgd TO admin; GRANT ALL ON TABLE cntctmrgd TO xtrole; publicadminfalse396125981020cntctselTABLEbCREATE TABLE cntctsel ( cntctsel_cntct_id integer NOT NULL, cntctsel_target boolean, cntctsel_mrg_crmacct_id boolean DEFAULT false, cntctsel_mrg_addr_id boolean DEFAULT false, cntctsel_mrg_first_name boolean DEFAULT false, cntctsel_mrg_last_name boolean DEFAULT false, cntctsel_mrg_honorific boolean DEFAULT false, cntctsel_mrg_initials boolean DEFAULT false, cntctsel_mrg_phone boolean DEFAULT false, cntctsel_mrg_phone2 boolean DEFAULT false, cntctsel_mrg_fax boolean DEFAULT false, cntctsel_mrg_email boolean DEFAULT false, cntctsel_mrg_webaddr boolean DEFAULT false, cntctsel_mrg_notes boolean DEFAULT false, cntctsel_mrg_title boolean DEFAULT false, cntctsel_mrg_middle boolean DEFAULT false, cntctsel_mrg_suffix boolean DEFAULT false, cntctsel_mrg_owner_username boolean DEFAULT false ); DROP TABLE public.cntctsel; publicadminfalse64276428642964306431643264336434643564366437643864396440644164428(00cntctselACLREVOKE ALL ON TABLE cntctsel FROM PUBLIC; REVOKE ALL ON TABLE cntctsel FROM admin; GRANT ALL ON TABLE cntctsel TO admin; GRANT ALL ON TABLE cntctsel TO xtrole; publicadminfalse397125981039cntslip_cntslip_id_seqSEQUENCECREATE SEQUENCE cntslip_cntslip_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.cntslip_cntslip_id_seq; publicadminfalse8(00cntslip_cntslip_id_seqACLREVOKE ALL ON SEQUENCE cntslip_cntslip_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cntslip_cntslip_id_seq FROM admin; GRANT ALL ON SEQUENCE cntslip_cntslip_id_seq TO admin; GRANT ALL ON SEQUENCE cntslip_cntslip_id_seq TO xtrole; publicadminfalse398125981041cobillTABLECREATE TABLE cobill ( cobill_id integer DEFAULT nextval(('cobill_cobill_id_seq'::text)::regclass) NOT NULL, cobill_coitem_id integer, cobill_selectdate timestamp with time zone, cobill_qty numeric(18,6), cobill_invcnum integer, cobill_toclose boolean, cobill_cobmisc_id integer, cobill_select_username text, cobill_invcitem_id integer, cobill_taxtype_id integer ); DROP TABLE public.cobill; publicadminfalse64438(00 TABLE cobillCOMMENTFCOMMENT ON TABLE cobill IS 'Billing Selection Line Item information'; publicadminfalse399(00cobillACLREVOKE ALL ON TABLE cobill FROM PUBLIC; REVOKE ALL ON TABLE cobill FROM admin; GRANT ALL ON TABLE cobill TO admin; GRANT ALL ON TABLE cobill TO xtrole; publicadminfalse399125981048cobill_cobill_id_seqSEQUENCE~CREATE SEQUENCE cobill_cobill_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; +DROP SEQUENCE public.cobill_cobill_id_seq; publicadminfalse8(00cobill_cobill_id_seqACLREVOKE ALL ON SEQUENCE cobill_cobill_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cobill_cobill_id_seq FROM admin; GRANT ALL ON SEQUENCE cobill_cobill_id_seq TO admin; GRANT ALL ON SEQUENCE cobill_cobill_id_seq TO xtrole; publicadminfalse400125981050 cobilltaxTABLE/CREATE TABLE cobilltax ( ) INHERITS (taxhist); DROP TABLE public.cobilltax; publicadminfalse8281(00 cobilltaxACLREVOKE ALL ON TABLE cobilltax FROM PUBLIC; REVOKE ALL ON TABLE cobilltax FROM admin; GRANT ALL ON TABLE cobilltax TO admin; GRANT ALL ON TABLE cobilltax TO xtrole; publicadminfalse401125981056cobmiscTABLECREATE TABLE cobmisc ( cobmisc_id integer DEFAULT nextval(('cobmisc_cobmisc_id_seq'::text)::regclass) NOT NULL, cobmisc_cohead_id integer, cobmisc_shipvia text, cobmisc_freight numeric(16,4), cobmisc_misc numeric(16,4), cobmisc_payment numeric(16,4), cobmisc_paymentref text, cobmisc_notes text, cobmisc_shipdate date, cobmisc_invcnumber integer, cobmisc_invcdate date, cobmisc_posted boolean, cobmisc_misc_accnt_id integer, cobmisc_misc_descrip text, cobmisc_closeorder boolean, cobmisc_curr_id integer DEFAULT basecurrid(), cobmisc_invchead_id integer, cobmisc_taxzone_id integer, cobmisc_taxtype_id integer ); DROP TABLE public.cobmisc; publicadminfalse644564468(00 TABLE cobmiscCOMMENTLCOMMENT ON TABLE cobmisc IS 'General information about Billing Selections'; publicadminfalse402(00cobmiscACLREVOKE ALL ON TABLE cobmisc FROM PUBLIC; REVOKE ALL ON TABLE cobmisc FROM admin; GRANT ALL ON TABLE cobmisc TO admin; GRANT ALL ON TABLE cobmisc TO xtrole; publicadminfalse402125981064cobmisc_cobmisc_id_seqSEQUENCECREATE SEQUENCE cobmisc_cobmisc_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.cobmisc_cobmisc_id_seq; publicadminfalse8(00cobmisc_cobmisc_id_seqACLREVOKE ALL ON SEQUENCE cobmisc_cobmisc_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cobmisc_cobmisc_id_seq FROM admin; GRANT ALL ON SEQUENCE cobmisc_cobmisc_id_seq TO admin; GRANT ALL ON SEQUENCE cobmisc_cobmisc_id_seq TO xtrole; publicadminfalse403125981066 cobmisctaxTABLE0CREATE TABLE cobmisctax ( ) INHERITS (taxhist); DROP TABLE public.cobmisctax; publicadminfalse8281(00 cobmisctaxACLREVOKE ALL ON TABLE cobmisctax FROM PUBLIC; REVOKE ALL ON TABLE cobmisctax FROM admin; GRANT ALL ON TABLE cobmisctax TO admin; GRANT ALL ON TABLE cobmisctax TO xtrole; publicadminfalse404125981072cohead_cohead_id_seqSEQUENCE~CREATE SEQUENCE cohead_cohead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; +DROP SEQUENCE public.cohead_cohead_id_seq; publicadminfalse8(00cohead_cohead_id_seqACLREVOKE ALL ON SEQUENCE cohead_cohead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cohead_cohead_id_seq FROM admin; GRANT ALL ON SEQUENCE cohead_cohead_id_seq TO admin; GRANT ALL ON SEQUENCE cohead_cohead_id_seq TO xtrole; publicadminfalse405125981074cohist_cohist_id_seqSEQUENCE~CREATE SEQUENCE cohist_cohist_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; +DROP SEQUENCE public.cohist_cohist_id_seq; publicadminfalse8(00cohist_cohist_id_seqACLREVOKE ALL ON SEQUENCE cohist_cohist_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cohist_cohist_id_seq FROM admin; GRANT ALL ON SEQUENCE cohist_cohist_id_seq TO admin; GRANT ALL ON SEQUENCE cohist_cohist_id_seq TO xtrole; publicadminfalse406125981076coitem_coitem_id_seqSEQUENCE~CREATE SEQUENCE coitem_coitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; +DROP SEQUENCE public.coitem_coitem_id_seq; publicadminfalse8(00coitem_coitem_id_seqACLREVOKE ALL ON SEQUENCE coitem_coitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE coitem_coitem_id_seq FROM admin; GRANT ALL ON SEQUENCE coitem_coitem_id_seq TO admin; GRANT ALL ON SEQUENCE coitem_coitem_id_seq TO xtrole; publicadminfalse407125981078comment_comment_id_seqSEQUENCExCREATE SEQUENCE comment_comment_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.comment_comment_id_seq; publicadminfalse8(00comment_comment_id_seqACLREVOKE ALL ON SEQUENCE comment_comment_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE comment_comment_id_seq FROM admin; GRANT ALL ON SEQUENCE comment_comment_id_seq TO admin; GRANT ALL ON SEQUENCE comment_comment_id_seq TO xtrole; publicadminfalse408125981080companyTABLE.CREATE TABLE company ( company_id integer NOT NULL, company_number text NOT NULL, company_descrip text, company_external boolean DEFAULT false NOT NULL, company_server text, company_port integer, company_database text, company_curr_id integer, company_yearend_accnt_id integer, company_gainloss_accnt_id integer, company_dscrp_accnt_id integer, company_unrlzgainloss_accnt_id integer, company_unassigned_accnt_id integer, CONSTRAINT company_company_number_check CHECK ((company_number <> ''::text)) ); DROP TABLE public.company; publicadminfalse644964508(00 TABLE companyCOMMENT3COMMENT ON TABLE company IS 'Company information'; publicadminfalse409(00companyACLREVOKE ALL ON TABLE company FROM PUBLIC; REVOKE ALL ON TABLE company FROM admin; GRANT ALL ON TABLE company TO admin; GRANT ALL ON TABLE company TO xtrole; publicadminfalse409125981088company_company_id_seqSEQUENCExCREATE SEQUENCE company_company_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.company_company_id_seq; publicadminfalse8409(00company_company_id_seqSEQUENCE OWNED BYCALTER SEQUENCE company_company_id_seq OWNED BY company.company_id; publicadminfalse410(00company_company_id_seqACLREVOKE ALL ON SEQUENCE company_company_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE company_company_id_seq FROM admin; GRANT ALL ON SEQUENCE company_company_id_seq TO admin; GRANT ALL ON SEQUENCE company_company_id_seq TO xtrole; publicadminfalse410125981090contrct_contrct_id_seqSEQUENCExCREATE SEQUENCE contrct_contrct_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.contrct_contrct_id_seq; publicadminfalse8259(00contrct_contrct_id_seqSEQUENCE OWNED BYCALTER SEQUENCE contrct_contrct_id_seq OWNED BY contrct.contrct_id; publicadminfalse411(00contrct_contrct_id_seqACLREVOKE ALL ON SEQUENCE contrct_contrct_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE contrct_contrct_id_seq FROM admin; GRANT ALL ON SEQUENCE contrct_contrct_id_seq TO admin; GRANT ALL ON SEQUENCE contrct_contrct_id_seq TO xtrole; publicadminfalse411125981092shipheadTABLECREATE TABLE shiphead ( shiphead_id integer NOT NULL, shiphead_order_id integer NOT NULL, shiphead_order_type text NOT NULL, shiphead_number text NOT NULL, shiphead_shipvia text, shiphead_freight numeric(16,4) DEFAULT 0.0 NOT NULL, shiphead_freight_curr_id integer DEFAULT basecurrid() NOT NULL, shiphead_notes text, shiphead_shipped boolean DEFAULT false NOT NULL, shiphead_shipdate date, shiphead_shipchrg_id integer, shiphead_shipform_id integer, shiphead_sfstatus character(1) NOT NULL, shiphead_tracknum text, CONSTRAINT shiphead_shiphead_number_check CHECK ((shiphead_number <> ''::text)), CONSTRAINT shiphead_shiphead_order_type_check CHECK (((shiphead_order_type = 'SO'::text) OR (shiphead_order_type = 'TO'::text))), CONSTRAINT shiphead_shiphead_sfstatus_check CHECK ((((shiphead_sfstatus = 'D'::bpchar) OR (shiphead_sfstatus = 'N'::bpchar)) OR (shiphead_sfstatus = 'P'::bpchar))) ); DROP TABLE public.shiphead; publicadminfalse6451645264536455645664578(00TABLE shipheadCOMMENTDCOMMENT ON TABLE shiphead IS 'General information about Shipments'; publicadminfalse412(00shipheadACLREVOKE ALL ON TABLE shiphead FROM PUBLIC; REVOKE ALL ON TABLE shiphead FROM admin; GRANT ALL ON TABLE shiphead TO admin; GRANT ALL ON TABLE shiphead TO xtrole; publicadminfalse412125981104shipitemTABLECREATE TABLE shipitem ( shipitem_id integer NOT NULL, shipitem_orderitem_id integer NOT NULL, shipitem_shiphead_id integer NOT NULL, shipitem_qty numeric(18,6) NOT NULL, shipitem_shipped boolean DEFAULT false NOT NULL, shipitem_shipdate timestamp with time zone, shipitem_transdate timestamp with time zone, shipitem_trans_username text, shipitem_invoiced boolean DEFAULT false NOT NULL, shipitem_invcitem_id integer, shipitem_value numeric(18,6), shipitem_invhist_id integer ); DROP TABLE public.shipitem; publicadminfalse645964608(00TABLE shipitemCOMMENTFCOMMENT ON TABLE shipitem IS 'Information about Shipment Line Items'; publicadminfalse413(00shipitemACLREVOKE ALL ON TABLE shipitem FROM PUBLIC; REVOKE ALL ON TABLE shipitem FROM admin; GRANT ALL ON TABLE shipitem TO admin; GRANT ALL ON TABLE shipitem TO xtrole; publicadminfalse413125981112coshipVIEWCREATE VIEW coship AS SELECT shipitem.shipitem_id AS coship_id, shipitem.shipitem_orderitem_id AS coship_coitem_id, shipitem.shipitem_shipdate AS coship_shipdate, shipitem.shipitem_qty AS coship_qty, shipitem.shipitem_transdate AS coship_transdate, shipitem.shipitem_shipped AS coship_shipped, shipitem.shipitem_invoiced AS coship_invoiced, shipitem.shipitem_shiphead_id AS coship_cosmisc_id, shipitem.shipitem_trans_username AS coship_trans_username, shipitem.shipitem_invcitem_id AS coship_invcitem_id FROM shipitem, shiphead WHERE ((shipitem.shipitem_shiphead_id = shiphead.shiphead_id) AND (shiphead.shiphead_order_type = 'SO'::text)); DROP VIEW public.coship; publicadminfalse86408(00coshipACLREVOKE ALL ON TABLE coship FROM PUBLIC; REVOKE ALL ON TABLE coship FROM admin; GRANT ALL ON TABLE coship TO admin; GRANT ALL ON TABLE coship TO xtrole; publicadminfalse414125981116coship_coship_id_seqSEQUENCE~CREATE SEQUENCE coship_coship_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; +DROP SEQUENCE public.coship_coship_id_seq; publicadminfalse8(00coship_coship_id_seqACLREVOKE ALL ON SEQUENCE coship_coship_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE coship_coship_id_seq FROM admin; GRANT ALL ON SEQUENCE coship_coship_id_seq TO admin; GRANT ALL ON SEQUENCE coship_coship_id_seq TO xtrole; publicadminfalse415125981118cosmiscVIEWCREATE VIEW cosmisc AS SELECT shiphead.shiphead_id AS cosmisc_id, shiphead.shiphead_order_id AS cosmisc_cohead_id, shiphead.shiphead_shipvia AS cosmisc_shipvia, shiphead.shiphead_freight AS cosmisc_freight, shiphead.shiphead_notes AS cosmisc_notes, shiphead.shiphead_shipdate AS cosmisc_shipdate, shiphead.shiphead_shipchrg_id AS cosmisc_shipchrg_id, shiphead.shiphead_shipform_id AS cosmisc_shipform_id, shiphead.shiphead_shipped AS cosmisc_shipped, shiphead.shiphead_sfstatus AS cosmisc_sfstatus, shiphead.shiphead_tracknum AS cosmisc_tracknum, shiphead.shiphead_number AS cosmisc_number FROM shiphead WHERE (shiphead.shiphead_order_type = 'SO'::text); DROP VIEW public.cosmisc; publicadminfalse86418(00cosmiscACLREVOKE ALL ON TABLE cosmisc FROM PUBLIC; REVOKE ALL ON TABLE cosmisc FROM admin; GRANT ALL ON TABLE cosmisc TO admin; GRANT ALL ON TABLE cosmisc TO xtrole; publicadminfalse416125981122cosmisc_cosmisc_id_seqSEQUENCECREATE SEQUENCE cosmisc_cosmisc_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.cosmisc_cosmisc_id_seq; publicadminfalse8(00cosmisc_cosmisc_id_seqACLREVOKE ALL ON SEQUENCE cosmisc_cosmisc_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cosmisc_cosmisc_id_seq FROM admin; GRANT ALL ON SEQUENCE cosmisc_cosmisc_id_seq TO admin; GRANT ALL ON SEQUENCE cosmisc_cosmisc_id_seq TO xtrole; publicadminfalse417125981124cosrc_cosrc_id_seqSEQUENCE|CREATE SEQUENCE cosrc_cosrc_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; )DROP SEQUENCE public.cosrc_cosrc_id_seq; publicadminfalse8(00cosrc_cosrc_id_seqACLREVOKE ALL ON SEQUENCE cosrc_cosrc_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cosrc_cosrc_id_seq FROM admin; GRANT ALL ON SEQUENCE cosrc_cosrc_id_seq TO admin; GRANT ALL ON SEQUENCE cosrc_cosrc_id_seq TO xtrole; publicadminfalse418125981126costcat_costcat_id_seqSEQUENCECREATE SEQUENCE costcat_costcat_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.costcat_costcat_id_seq; publicadminfalse8(00costcat_costcat_id_seqACLREVOKE ALL ON SEQUENCE costcat_costcat_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE costcat_costcat_id_seq FROM admin; GRANT ALL ON SEQUENCE costcat_costcat_id_seq TO admin; GRANT ALL ON SEQUENCE costcat_costcat_id_seq TO xtrole; publicadminfalse419125981128costelem_costelem_id_seqSEQUENCECREATE SEQUENCE costelem_costelem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; /DROP SEQUENCE public.costelem_costelem_id_seq; publicadminfalse8(00costelem_costelem_id_seqACLREVOKE ALL ON SEQUENCE costelem_costelem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE costelem_costelem_id_seq FROM admin; GRANT ALL ON SEQUENCE costelem_costelem_id_seq TO admin; GRANT ALL ON SEQUENCE costelem_costelem_id_seq TO xtrole; publicadminfalse420125981130costhistTABLECREATE TABLE costhist ( costhist_id integer DEFAULT nextval(('"costhist_costhist_id_seq"'::text)::regclass) NOT NULL, costhist_item_id integer, costhist_costelem_id integer, costhist_type character(1), costhist_date timestamp with time zone, costhist_oldcost numeric(16,6), costhist_newcost numeric(16,6), costhist_lowlevel boolean, costhist_oldcurr_id integer DEFAULT basecurrid(), costhist_newcurr_id integer DEFAULT basecurrid(), costhist_username text ); DROP TABLE public.costhist; publicadminfalse6461646264638(00TABLE costhistCOMMENT2COMMENT ON TABLE costhist IS 'Item Cost history'; publicadminfalse421(00costhistACLREVOKE ALL ON TABLE costhist FROM PUBLIC; REVOKE ALL ON TABLE costhist FROM admin; GRANT ALL ON TABLE costhist TO admin; GRANT ALL ON TABLE costhist TO xtrole; publicadminfalse421125981139costhist_costhist_id_seqSEQUENCEzCREATE SEQUENCE costhist_costhist_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.costhist_costhist_id_seq; publicadminfalse8(00costhist_costhist_id_seqACLREVOKE ALL ON SEQUENCE costhist_costhist_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE costhist_costhist_id_seq FROM admin; GRANT ALL ON SEQUENCE costhist_costhist_id_seq TO admin; GRANT ALL ON SEQUENCE costhist_costhist_id_seq TO xtrole; publicadminfalse422125981141 costupdateTABLECREATE TABLE costupdate ( costupdate_item_id integer, costupdate_lowlevel_code integer DEFAULT 1 NOT NULL, costupdate_item_type character(1) ); DROP TABLE public.costupdate; publicadminfalse64648(00TABLE costupdateCOMMENTYCOMMENT ON TABLE costupdate IS 'Scratch area for sequencing the updating of item costs'; publicadminfalse423(00 costupdateACLREVOKE ALL ON TABLE costupdate FROM PUBLIC; REVOKE ALL ON TABLE costupdate FROM admin; GRANT ALL ON TABLE costupdate TO admin; GRANT ALL ON TABLE costupdate TO xtrole; publicadminfalse423125981145countryTABLECREATE TABLE country ( country_id integer NOT NULL, country_abbr character(2), country_name text, country_curr_abbr character(3), country_curr_name text, country_curr_number character(3), country_curr_symbol character varying(9), country_qt_number integer, CONSTRAINT country_country_abbr_check CHECK ((country_abbr <> ''::bpchar)), CONSTRAINT country_country_name_check CHECK ((country_name <> ''::text)) ); DROP TABLE public.country; publicadminfalse646664678(00 TABLE countryCOMMENTQCOMMENT ON TABLE country IS 'Basic information and properties about countries.'; publicadminfalse424(00countryACLREVOKE ALL ON TABLE country FROM PUBLIC; REVOKE ALL ON TABLE country FROM admin; GRANT ALL ON TABLE country TO admin; GRANT ALL ON TABLE country TO xtrole; publicadminfalse424125981153country_country_id_seqSEQUENCExCREATE SEQUENCE country_country_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.country_country_id_seq; publicadminfalse8424(00country_country_id_seqSEQUENCE OWNED BYCALTER SEQUENCE country_country_id_seq OWNED BY country.country_id; publicadminfalse425(00country_country_id_seqACLREVOKE ALL ON SEQUENCE country_country_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE country_country_id_seq FROM admin; GRANT ALL ON SEQUENCE country_country_id_seq TO admin; GRANT ALL ON SEQUENCE country_country_id_seq TO xtrole; publicadminfalse425125981155 salesaccntTABLEYCREATE TABLE salesaccnt ( salesaccnt_id integer DEFAULT nextval(('"salesaccnt_salesaccnt_id_seq"'::text)::regclass) NOT NULL, salesaccnt_custtype_id integer, salesaccnt_prodcat_id integer, salesaccnt_warehous_id integer, salesaccnt_sales_accnt_id integer, salesaccnt_credit_accnt_id integer, salesaccnt_cos_accnt_id integer, salesaccnt_custtype text, salesaccnt_prodcat text, salesaccnt_returns_accnt_id integer, salesaccnt_cor_accnt_id integer, salesaccnt_cow_accnt_id integer, salesaccnt_saletype_id integer, salesaccnt_shipzone_id integer ); DROP TABLE public.salesaccnt; publicadminfalse64688(00TABLE salesaccntCOMMENTGCOMMENT ON TABLE salesaccnt IS 'Sales Account assignment information'; publicadminfalse426(00(COLUMN salesaccnt.salesaccnt_saletype_idCOMMENTbCOMMENT ON COLUMN salesaccnt.salesaccnt_saletype_id IS 'Associated sale type for sales account.'; publicadminfalse426(00(COLUMN salesaccnt.salesaccnt_shipzone_idCOMMENTfCOMMENT ON COLUMN salesaccnt.salesaccnt_shipzone_id IS 'Associated shipping zone for sales account.'; publicadminfalse426(00 salesaccntACLREVOKE ALL ON TABLE salesaccnt FROM PUBLIC; REVOKE ALL ON TABLE salesaccnt FROM admin; GRANT ALL ON TABLE salesaccnt TO admin; GRANT ALL ON TABLE salesaccnt TO xtrole; publicadminfalse426125987589creditmemoeditlistVIEWnCREATE VIEW creditmemoeditlist AS ((((SELECT cmhead.cmhead_id AS orderid, (-2) AS itemid, ('C/M-'::text || formatcreditmemonumber(cmhead.cmhead_id)) AS documentnumber, custinfo.cust_number, cmhead.cmhead_billtoname AS billtoname, cmhead.cmhead_number AS ordernumber, (-1) AS linenumber, ''::text AS item, ''::text AS itemdescrip, ''::text AS iteminvuom, ''::text AS qtytobill, ''::text AS price, formatmoney((((calccmheadamt(cmhead.cmhead_id) + cmhead.cmhead_freight) + cmhead.cmhead_misc) + calccmheadtax(cmhead.cmhead_id))) AS extprice, 'Credit'::text AS sence, COALESCE((SELECT formatglaccountlong(accnt.accnt_id) AS formatglaccountlong FROM accnt WHERE (accnt.accnt_id = findaraccount(custinfo.cust_id))), 'Not Assigned'::text) AS account FROM custinfo, cmhead WHERE ((((cmhead.cmhead_cust_id = custinfo.cust_id) AND (cmhead.cmhead_cust_id = custinfo.cust_id)) AND (NOT cmhead.cmhead_posted)) AND (NOT cmhead.cmhead_hold)) UNION SELECT cmhead.cmhead_id AS orderid, (-1) AS itemid, ''::text AS documentnumber, ''::text AS cust_number, ''::text AS billtoname, cmhead.cmhead_number AS ordernumber, (-1) AS linenumber, 'Freight'::text AS item, 'Freight Charge'::text AS itemdescrip, ''::text AS iteminvuom, ''::text AS qtytobill, formatmoney(cmhead.cmhead_freight) AS price, formatmoney(cmhead.cmhead_freight) AS extprice, 'Debit'::text AS sence, CASE WHEN (accnt.accnt_id IS NULL) THEN 'Not Assigned'::text ELSE formatglaccountlong(accnt.accnt_id) END AS account FROM (cmhead LEFT JOIN accnt ON ((accnt.accnt_id = findfreightaccount(cmhead.cmhead_cust_id)))) WHERE (((NOT cmhead.cmhead_posted) AND (NOT cmhead.cmhead_hold)) AND (cmhead.cmhead_freight <> (0)::numeric))) UNION SELECT cmhead.cmhead_id AS orderid, (-1) AS itemid, ''::text AS documentnumber, ''::text AS cust_number, ''::text AS billtoname, cmhead.cmhead_number AS ordernumber, (-1) AS linenumber, 'Misc. Charge'::text AS item, cmhead.cmhead_misc_descrip AS itemdescrip, ''::text AS iteminvuom, ''::text AS qtytobill, formatmoney(cmhead.cmhead_misc) AS price, formatmoney(cmhead.cmhead_misc) AS extprice, 'Debit'::text AS sence, formatglaccountlong(cmhead.cmhead_misc_accnt_id) AS account FROM cmhead WHERE (((NOT cmhead.cmhead_posted) AND (NOT cmhead.cmhead_hold)) AND (cmhead.cmhead_misc <> (0)::numeric))) UNION SELECT cmhead.cmhead_id AS orderid, (-1) AS itemid, ''::text AS documentnumber, ''::text AS cust_number, ''::text AS billtoname, cmhead.cmhead_number AS ordernumber, (-1) AS linenumber, 'Sales Tax'::text AS item, tax.tax_descrip AS itemdescrip, ''::text AS iteminvuom, ''::text AS qtytobill, formatmoney((cmheadtax.taxhist_tax * (-1.0))) AS price, formatmoney((cmheadtax.taxhist_tax * (-1.0))) AS extprice, 'Debit'::text AS sence, CASE WHEN (accnt.accnt_id IS NULL) THEN 'Not Assigned'::text ELSE ((formatglaccountlong(accnt.accnt_id) || ' - '::text) || accnt.accnt_descrip) END AS account FROM (((cmhead JOIN cmheadtax ON ((cmheadtax.taxhist_parent_id = cmhead.cmhead_id))) JOIN tax ON ((tax.tax_id = cmheadtax.taxhist_tax_id))) LEFT JOIN accnt ON ((accnt.accnt_id = tax.tax_sales_accnt_id))) WHERE ((NOT cmhead.cmhead_posted) AND (NOT cmhead.cmhead_hold))) UNION SELECT cmhead.cmhead_id AS orderid, (-1) AS itemid, ''::text AS documentnumber, ''::text AS cust_number, ''::text AS billtoname, cmhead.cmhead_number AS ordernumber, (-1) AS linenumber, 'Sales Tax'::text AS item, tax.tax_descrip AS itemdescrip, ''::text AS iteminvuom, ''::text AS qtytobill, formatmoney((cmitemtax.taxhist_tax * (-1.0))) AS price, formatmoney((cmitemtax.taxhist_tax * (-1.0))) AS extprice, 'Debit'::text AS sence, CASE WHEN (accnt.accnt_id IS NULL) THEN 'Not Assigned'::text ELSE ((formatglaccountlong(accnt.accnt_id) || ' - '::text) || accnt.accnt_descrip) END AS account FROM ((((cmhead JOIN cmitem ON ((cmitem.cmitem_cmhead_id = cmhead.cmhead_id))) JOIN cmitemtax ON ((cmitemtax.taxhist_parent_id = cmitem.cmitem_id))) JOIN tax ON ((tax.tax_id = cmitemtax.taxhist_tax_id))) LEFT JOIN accnt ON ((accnt.accnt_id = tax.tax_sales_accnt_id))) WHERE ((NOT cmhead.cmhead_posted) AND (NOT cmhead.cmhead_hold))) UNION SELECT cmhead.cmhead_id AS orderid, cmitem.cmitem_id AS itemid, ''::text AS documentnumber, ''::text AS cust_number, ''::text AS billtoname, cmhead.cmhead_number AS ordernumber, cmitem.cmitem_linenumber AS linenumber, item.item_number AS item, item.item_descrip1 AS itemdescrip, uom.uom_name AS iteminvuom, formatqty(COALESCE((cmitem.cmitem_qtycredit * cmitem.cmitem_qty_invuomratio), (0)::numeric)) AS qtytobill, formatprice(COALESCE((cmitem.cmitem_unitprice / cmitem.cmitem_price_invuomratio), (0)::numeric)) AS price, formatmoney(COALESCE(round(((cmitem.cmitem_qtycredit * cmitem.cmitem_qty_invuomratio) * (cmitem.cmitem_unitprice / cmitem.cmitem_price_invuomratio)), 2), (0)::numeric)) AS extprice, 'Debit'::text AS sence, COALESCE((SELECT formatglaccountlong(accnt.accnt_id) AS formatglaccountlong FROM accnt, salesaccnt WHERE ((salesaccnt.salesaccnt_sales_accnt_id = accnt.accnt_id) AND (salesaccnt.salesaccnt_id = findsalesaccnt(cmitem.cmitem_itemsite_id, 'IS'::text, cmhead.cmhead_cust_id, cmhead.cmhead_saletype_id, cmhead.cmhead_shipzone_id)))), 'Not Assigned'::text) AS account FROM item, itemsite, cmhead, cmitem, uom WHERE ((((((cmitem.cmitem_cmhead_id = cmhead.cmhead_id) AND (cmitem.cmitem_itemsite_id = itemsite.itemsite_id)) AND (itemsite.itemsite_item_id = item.item_id)) AND (item.item_inv_uom_id = uom.uom_id)) AND (NOT cmhead.cmhead_posted)) AND (NOT cmhead.cmhead_hold)) ORDER BY 6, 7; %DROP VIEW public.creditmemoeditlist; publicadminfalse86768(00creditmemoeditlistACLREVOKE ALL ON TABLE creditmemoeditlist FROM PUBLIC; REVOKE ALL ON TABLE creditmemoeditlist FROM admin; GRANT ALL ON TABLE creditmemoeditlist TO admin; GRANT ALL ON TABLE creditmemoeditlist TO xtrole; publicadminfalse793125987594creditmemoitemVIEWCREATE VIEW creditmemoitem AS SELECT cmitem.cmitem_id, cmitem.cmitem_cmhead_id, cmitem.cmitem_linenumber, cmitem.cmitem_itemsite_id, cmitem.cmitem_qtycredit, cmitem.cmitem_qtyreturned, cmitem.cmitem_unitprice, cmitem.cmitem_comments, cmitem.cmitem_rsncode_id, cmitem.cmitem_taxtype_id, cmitem.cmitem_qty_uom_id, cmitem.cmitem_qty_invuomratio, cmitem.cmitem_price_uom_id, cmitem.cmitem_price_invuomratio, cmitem.cmitem_raitem_id, cmitem.cmitem_updateinv, itemsite.itemsite_item_id AS item_id, COALESCE((cmitem.cmitem_qtycredit * cmitem.cmitem_qty_invuomratio), (0)::numeric) AS qty, COALESCE((cmitem.cmitem_unitprice / cmitem.cmitem_price_invuomratio), (0)::numeric) AS unitprice, COALESCE(round(((cmitem.cmitem_qtycredit * cmitem.cmitem_qty_invuomratio) * (cmitem.cmitem_unitprice / cmitem.cmitem_price_invuomratio)), 2), (0)::numeric) AS extprice, currtobase(cmhead.cmhead_curr_id, COALESCE(round(((cmitem.cmitem_qtycredit * cmitem.cmitem_qty_invuomratio) * (cmitem.cmitem_unitprice / cmitem.cmitem_price_invuomratio)), 2), (0)::numeric), cmhead.cmhead_docdate) AS baseextprice, (SELECT COALESCE(sum(cmitemtax.taxhist_tax), (0)::numeric) AS "coalesce" FROM cmitemtax WHERE (cmitemtax.taxhist_parent_id = cmitem.cmitem_id)) AS tax, CASE WHEN (itemsite.itemsite_costmethod = 'A'::bpchar) THEN avgcost(itemsite.itemsite_id) ELSE stdcost(itemsite.itemsite_item_id) END AS unitcost FROM ((cmitem JOIN cmhead ON ((cmhead.cmhead_id = cmitem.cmitem_cmhead_id))) LEFT JOIN itemsite ON ((itemsite.itemsite_id = cmitem.cmitem_itemsite_id))); !DROP VIEW public.creditmemoitem; publicadminfalse86778(00VIEW creditmemoitemCOMMENT^COMMENT ON VIEW creditmemoitem IS 'Single point for credit memo item (cmitem) calculations.'; publicadminfalse794(00creditmemoitemACLREVOKE ALL ON TABLE creditmemoitem FROM PUBLIC; REVOKE ALL ON TABLE creditmemoitem FROM admin; GRANT ALL ON TABLE creditmemoitem TO admin; GRANT ALL ON TABLE creditmemoitem TO xtrole; publicadminfalse794125981172crmacct_crmacct_id_seqSEQUENCExCREATE SEQUENCE crmacct_crmacct_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.crmacct_crmacct_id_seq; publicadminfalse8188(00crmacct_crmacct_id_seqSEQUENCE OWNED BYCALTER SEQUENCE crmacct_crmacct_id_seq OWNED BY crmacct.crmacct_id; publicadminfalse427(00crmacct_crmacct_id_seqACLREVOKE ALL ON SEQUENCE crmacct_crmacct_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE crmacct_crmacct_id_seq FROM admin; GRANT ALL ON SEQUENCE crmacct_crmacct_id_seq TO admin; GRANT ALL ON SEQUENCE crmacct_crmacct_id_seq TO xtrole; publicadminfalse427125981174 crmacctselTABLEGCREATE TABLE crmacctsel ( crmacctsel_src_crmacct_id integer NOT NULL, crmacctsel_dest_crmacct_id integer, crmacctsel_mrg_crmacct_active boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_cntct_id_1 boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_cntct_id_2 boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_competitor_id boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_cust_id boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_emp_id boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_name boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_notes boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_owner_username boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_parent_id boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_partner_id boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_prospect_id boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_salesrep_id boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_taxauth_id boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_type boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_usr_username boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_vend_id boolean DEFAULT false NOT NULL, crmacctsel_mrg_crmacct_number boolean DEFAULT false NOT NULL ); DROP TABLE public.crmacctsel; publicadminfalse6469647064716472647364746475647664776478647964806481648264836484648564868(00TABLE crmacctselCOMMENT6COMMENT ON TABLE crmacctsel IS 'This table records the proposed conditions of a CRM Account merge. When this merge is performed, the BOOLEAN columns in this table indicate which values in the crmacct table will be copied to the target record. Data in this table are temporary and will be removed by a purge.'; publicadminfalse428(00+COLUMN crmacctsel.crmacctsel_src_crmacct_idCOMMENTCOMMENT ON COLUMN crmacctsel.crmacctsel_src_crmacct_id IS 'This is the internal ID of the CRM Account record the data will come from during the merge.'; publicadminfalse428)00,COLUMN crmacctsel.crmacctsel_dest_crmacct_idCOMMENTCOMMENT ON COLUMN crmacctsel.crmacctsel_dest_crmacct_id IS 'This is the internal ID of the CRM Account record the data will go to during the merge. If crmacctsel_src_crmacct_id = crmacctsel_dest_crmacct_id, they indicate which crmacct record is the destination of the merge, meaning this is the record that will remain in the database after the merge has been completed and the intermediate data have been purged.'; publicadminfalse428)00 crmacctselACLREVOKE ALL ON TABLE crmacctsel FROM PUBLIC; REVOKE ALL ON TABLE crmacctsel FROM admin; GRANT ALL ON TABLE crmacctsel TO admin; GRANT ALL ON TABLE crmacctsel TO xtrole; publicadminfalse428125981195 curr_rateTABLECREATE TABLE curr_rate ( curr_rate_id integer NOT NULL, curr_id integer NOT NULL, curr_rate numeric(16,8) NOT NULL, curr_effective date NOT NULL, curr_expires date NOT NULL, CONSTRAINT curr_rate_curr_rate_check CHECK ((curr_rate > (0)::numeric)) ); DROP TABLE public.curr_rate; publicadminfalse64888)00TABLE curr_rateCOMMENTTCOMMENT ON TABLE curr_rate IS 'Exchange Rates Between Base and Foreign Currencies'; publicadminfalse429)00 curr_rateACLREVOKE ALL ON TABLE curr_rate FROM PUBLIC; REVOKE ALL ON TABLE curr_rate FROM admin; GRANT ALL ON TABLE curr_rate TO admin; GRANT ALL ON TABLE curr_rate TO xtrole; publicadminfalse429125981199curr_rate_curr_rate_id_seqSEQUENCE|CREATE SEQUENCE curr_rate_curr_rate_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 1DROP SEQUENCE public.curr_rate_curr_rate_id_seq; publicadminfalse8429)00curr_rate_curr_rate_id_seqSEQUENCE OWNED BYKALTER SEQUENCE curr_rate_curr_rate_id_seq OWNED BY curr_rate.curr_rate_id; publicadminfalse430)00curr_rate_curr_rate_id_seqACLREVOKE ALL ON SEQUENCE curr_rate_curr_rate_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE curr_rate_curr_rate_id_seq FROM admin; GRANT ALL ON SEQUENCE curr_rate_curr_rate_id_seq TO admin; GRANT ALL ON SEQUENCE curr_rate_curr_rate_id_seq TO xtrole; publicadminfalse430125981201curr_symbol_curr_id_seqSEQUENCEyCREATE SEQUENCE curr_symbol_curr_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; .DROP SEQUENCE public.curr_symbol_curr_id_seq; publicadminfalse8191)00curr_symbol_curr_id_seqSEQUENCE OWNED BYEALTER SEQUENCE curr_symbol_curr_id_seq OWNED BY curr_symbol.curr_id; publicadminfalse431)00curr_symbol_curr_id_seqACLREVOKE ALL ON SEQUENCE curr_symbol_curr_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE curr_symbol_curr_id_seq FROM admin; GRANT ALL ON SEQUENCE curr_symbol_curr_id_seq TO admin; GRANT ALL ON SEQUENCE curr_symbol_curr_id_seq TO xtrole; publicadminfalse431125981203custVIEW>CREATE VIEW cust AS SELECT custinfo.cust_id, custinfo.cust_active, custinfo.cust_custtype_id, custinfo.cust_salesrep_id, custinfo.cust_commprcnt, custinfo.cust_name, m.addr_line1 AS cust_address1, m.addr_line2 AS cust_address2, m.addr_line3 AS cust_address3, m.addr_city AS cust_city, m.addr_state AS cust_state, m.addr_postalcode AS cust_zipcode, btrim(((mc.cntct_first_name || ' '::text) || mc.cntct_last_name)) AS cust_contact, mc.cntct_phone AS cust_phone, mc.cntct_fax AS cust_fax, mc.cntct_email AS cust_email, c.addr_line1 AS cust_corraddress1, c.addr_line2 AS cust_corraddress2, c.addr_line3 AS cust_corraddress3, c.addr_city AS cust_corrcity, c.addr_state AS cust_corrstate, c.addr_postalcode AS cust_corrzipcode, btrim(((cc.cntct_first_name || ' '::text) || cc.cntct_last_name)) AS cust_corrcontact, cc.cntct_phone AS cust_corrphone, cc.cntct_fax AS cust_corrfax, cc.cntct_email AS cust_corremail, custinfo.cust_creditlmt, custinfo.cust_creditrating, custinfo.cust_financecharge, custinfo.cust_backorder, custinfo.cust_partialship, custinfo.cust_terms_id, custinfo.cust_discntprcnt, custinfo.cust_taxzone_id, custinfo.cust_balmethod, custinfo.cust_ffshipto, custinfo.cust_shipform_id, custinfo.cust_shipvia, custinfo.cust_blanketpos, custinfo.cust_shipchrg_id, custinfo.cust_creditstatus, custinfo.cust_comments, custinfo.cust_ffbillto, m.addr_country AS cust_country, c.addr_country AS cust_corrcountry, custinfo.cust_usespos, custinfo.cust_number, custinfo.cust_dateadded, custinfo.cust_exported, custinfo.cust_emaildelivery, custinfo.cust_ediemail, custinfo.cust_edisubject, custinfo.cust_edifilename, custinfo.cust_ediemailbody, custinfo.cust_autoupdatestatus, custinfo.cust_autoholdorders, custinfo.cust_edicc, custinfo.cust_ediprofile_id, custinfo.cust_preferred_warehous_id, custinfo.cust_curr_id, custinfo.cust_creditlmt_curr_id FROM ((((custinfo LEFT JOIN cntct mc ON ((custinfo.cust_cntct_id = mc.cntct_id))) LEFT JOIN addr m ON ((mc.cntct_addr_id = m.addr_id))) LEFT JOIN cntct cc ON ((custinfo.cust_corrcntct_id = cc.cntct_id))) LEFT JOIN addr c ON ((cc.cntct_addr_id = c.addr_id))); DROP VIEW public.cust; publicadminfalse86428)00custACLREVOKE ALL ON TABLE cust FROM PUBLIC; REVOKE ALL ON TABLE cust FROM admin; GRANT ALL ON TABLE cust TO admin; GRANT ALL ON TABLE cust TO xtrole; publicadminfalse432125981208cust_serial_seqSEQUENCEyCREATE SEQUENCE cust_serial_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; &DROP SEQUENCE public.cust_serial_seq; publicadminfalse8 )00cust_serial_seqACLREVOKE ALL ON SEQUENCE cust_serial_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE cust_serial_seq FROM admin; GRANT ALL ON SEQUENCE cust_serial_seq TO admin; GRANT ALL ON SEQUENCE cust_serial_seq TO xtrole; publicadminfalse433125981210custformTABLECREATE TABLE custform ( custform_id integer DEFAULT nextval(('"custform_custform_id_seq"'::text)::regclass) NOT NULL, custform_custtype_id integer, custform_custtype text, custform_invoice_report_id integer, custform_creditmemo_report_id integer, custform_quote_report_id integer, custform_packinglist_report_id integer, custform_statement_report_id integer, custform_sopicklist_report_id integer, custform_invoice_report_name text, custform_creditmemo_report_name text, custform_quote_report_name text, custform_packinglist_report_name text, custform_statement_report_name text, custform_sopicklist_report_name text ); DROP TABLE public.custform; publicadminfalse64898 )00TABLE custformCOMMENTECOMMENT ON TABLE custform IS 'Customer Form assignment information'; publicadminfalse434 )00*COLUMN custform.custform_invoice_report_idCOMMENTxCOMMENT ON COLUMN custform.custform_invoice_report_id IS 'Obsolete -- reference custform_invoice_report_name instead.'; publicadminfalse434 )00-COLUMN custform.custform_creditmemo_report_idCOMMENT~COMMENT ON COLUMN custform.custform_creditmemo_report_id IS 'Obsolete -- reference custform_creditmemo_report_name instead.'; publicadminfalse434 )00(COLUMN custform.custform_quote_report_idCOMMENTtCOMMENT ON COLUMN custform.custform_quote_report_id IS 'Obsolete -- reference custform_quote_report_name instead.'; publicadminfalse434)00.COLUMN custform.custform_packinglist_report_idCOMMENTCOMMENT ON COLUMN custform.custform_packinglist_report_id IS 'Obsolete -- reference custform_packinglist_report_name instead.'; publicadminfalse434)00,COLUMN custform.custform_statement_report_idCOMMENT|COMMENT ON COLUMN custform.custform_statement_report_id IS 'Obsolete -- reference custform_statement_report_name instead.'; publicadminfalse434)00-COLUMN custform.custform_sopicklist_report_idCOMMENT~COMMENT ON COLUMN custform.custform_sopicklist_report_id IS 'Obsolete -- reference custform_sopicklist_report_name instead.'; publicadminfalse434)00custformACLREVOKE ALL ON TABLE custform FROM PUBLIC; REVOKE ALL ON TABLE custform FROM admin; GRANT ALL ON TABLE custform TO admin; GRANT ALL ON TABLE custform TO xtrole; publicadminfalse434125981217custform_custform_id_seqSEQUENCEzCREATE SEQUENCE custform_custform_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.custform_custform_id_seq; publicadminfalse8)00custform_custform_id_seqACLREVOKE ALL ON SEQUENCE custform_custform_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE custform_custform_id_seq FROM admin; GRANT ALL ON SEQUENCE custform_custform_id_seq TO admin; GRANT ALL ON SEQUENCE custform_custform_id_seq TO xtrole; publicadminfalse435125981219custgrpTABLECREATE TABLE custgrp ( custgrp_id integer DEFAULT nextval(('"custgrp_custgrp_id_seq"'::text)::regclass) NOT NULL, custgrp_name text NOT NULL, custgrp_descrip text, CONSTRAINT custgrp_custgrp_name_check CHECK ((custgrp_name <> ''::text)) ); DROP TABLE public.custgrp; publicadminfalse649064918)00 TABLE custgrpCOMMENT:COMMENT ON TABLE custgrp IS 'Customer Group information'; publicadminfalse436)00custgrpACLREVOKE ALL ON TABLE custgrp FROM PUBLIC; REVOKE ALL ON TABLE custgrp FROM admin; GRANT ALL ON TABLE custgrp TO admin; GRANT ALL ON TABLE custgrp TO xtrole; publicadminfalse436125981227custgrp_custgrp_id_seqSEQUENCExCREATE SEQUENCE custgrp_custgrp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.custgrp_custgrp_id_seq; publicadminfalse8)00custgrp_custgrp_id_seqACLREVOKE ALL ON SEQUENCE custgrp_custgrp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE custgrp_custgrp_id_seq FROM admin; GRANT ALL ON SEQUENCE custgrp_custgrp_id_seq TO admin; GRANT ALL ON SEQUENCE custgrp_custgrp_id_seq TO xtrole; publicadminfalse437125981229 custgrpitemTABLECREATE TABLE custgrpitem ( custgrpitem_id integer DEFAULT nextval(('"custgrpitem_custgrpitem_id_seq"'::text)::regclass) NOT NULL, custgrpitem_custgrp_id integer, custgrpitem_cust_id integer ); DROP TABLE public.custgrpitem; publicadminfalse64928)00TABLE custgrpitemCOMMENTCCOMMENT ON TABLE custgrpitem IS 'Customer Group Item information'; publicadminfalse438)00 custgrpitemACLREVOKE ALL ON TABLE custgrpitem FROM PUBLIC; REVOKE ALL ON TABLE custgrpitem FROM admin; GRANT ALL ON TABLE custgrpitem TO admin; GRANT ALL ON TABLE custgrpitem TO xtrole; publicadminfalse438125981233custgrpitem_custgrpitem_id_seqSEQUENCECREATE SEQUENCE custgrpitem_custgrpitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 5DROP SEQUENCE public.custgrpitem_custgrpitem_id_seq; publicadminfalse8)00custgrpitem_custgrpitem_id_seqACLREVOKE ALL ON SEQUENCE custgrpitem_custgrpitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE custgrpitem_custgrpitem_id_seq FROM admin; GRANT ALL ON SEQUENCE custgrpitem_custgrpitem_id_seq TO admin; GRANT ALL ON SEQUENCE custgrpitem_custgrpitem_id_seq TO xtrole; publicadminfalse439125981235custtype_custtype_id_seqSEQUENCECREATE SEQUENCE custtype_custtype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; /DROP SEQUENCE public.custtype_custtype_id_seq; publicadminfalse8)00custtype_custtype_id_seqACLREVOKE ALL ON SEQUENCE custtype_custtype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE custtype_custtype_id_seq FROM admin; GRANT ALL ON SEQUENCE custtype_custtype_id_seq TO admin; GRANT ALL ON SEQUENCE custtype_custtype_id_seq TO xtrole; publicadminfalse440125981237dept_dept_id_seqSEQUENCErCREATE SEQUENCE dept_dept_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 'DROP SEQUENCE public.dept_dept_id_seq; publicadminfalse8241)00dept_dept_id_seqSEQUENCE OWNED BY7ALTER SEQUENCE dept_dept_id_seq OWNED BY dept.dept_id; publicadminfalse441)00dept_dept_id_seqACLREVOKE ALL ON SEQUENCE dept_dept_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE dept_dept_id_seq FROM admin; GRANT ALL ON SEQUENCE dept_dept_id_seq TO admin; GRANT ALL ON SEQUENCE dept_dept_id_seq TO xtrole; publicadminfalse441125981239 destinationTABLECREATE TABLE destination ( destination_id integer DEFAULT nextval(('"destination_destination_id_seq"'::text)::regclass) NOT NULL, destination_name text, destination_city text, destination_state text, destination_comments text ); DROP TABLE public.destination; publicadminfalse64938)00TABLE destinationCOMMENT;COMMENT ON TABLE destination IS 'Destination information'; publicadminfalse442)00 destinationACLREVOKE ALL ON TABLE destination FROM PUBLIC; REVOKE ALL ON TABLE destination FROM admin; GRANT ALL ON TABLE destination TO admin; GRANT ALL ON TABLE destination TO xtrole; publicadminfalse442125981246destination_destination_id_seqSEQUENCECREATE SEQUENCE destination_destination_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; 5DROP SEQUENCE public.destination_destination_id_seq; publicadminfalse8)00destination_destination_id_seqACLREVOKE ALL ON SEQUENCE destination_destination_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE destination_destination_id_seq FROM admin; GRANT ALL ON SEQUENCE destination_destination_id_seq TO admin; GRANT ALL ON SEQUENCE destination_destination_id_seq TO xtrole; publicadminfalse443125987599docinfoVIEWCREATE VIEW docinfo AS SELECT outer_wrapper.id, outer_wrapper.target_number, outer_wrapper.target_type, outer_wrapper.target_id, outer_wrapper.source_type_docinfo, outer_wrapper.source_id_docinfo, outer_wrapper.name, outer_wrapper.description, outer_wrapper.purpose, outer_wrapper.source_type, outer_wrapper.source_id FROM (SELECT (unnest(inner_wrapper._docinfo)).id AS id, (unnest(inner_wrapper._docinfo)).target_number AS target_number, (unnest(inner_wrapper._docinfo)).target_type AS target_type, (unnest(inner_wrapper._docinfo)).target_id AS target_id, (unnest(inner_wrapper._docinfo)).source_type AS source_type_docinfo, (unnest(inner_wrapper._docinfo)).source_id AS source_id_docinfo, (unnest(inner_wrapper._docinfo)).name AS name, (unnest(inner_wrapper._docinfo)).description AS description, (unnest(inner_wrapper._docinfo)).purpose AS purpose, inner_wrapper.source_type, inner_wrapper.source_id FROM (SELECT docinfo.docass_source_type, docinfo.docass_source_id, docinfo.source_type, docinfo.source_id, ARRAY(SELECT _docinfo(docinfo.docass_source_id, docinfo.docass_source_type) AS _docinfo) AS _docinfo FROM (SELECT docass.docass_source_type, docass.docass_source_id, docass.docass_source_type AS source_type, docass.docass_source_id AS source_id FROM docass) docinfo) inner_wrapper) outer_wrapper; DROP VIEW public.docinfo; publicadminfalse86788)00docinfoACLREVOKE ALL ON TABLE docinfo FROM PUBLIC; REVOKE ALL ON TABLE docinfo FROM admin; GRANT ALL ON TABLE docinfo TO admin; GRANT ALL ON TABLE docinfo TO xtrole; publicadminfalse795125981268emp_emp_id_seqSEQUENCEpCREATE SEQUENCE emp_emp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; %DROP SEQUENCE public.emp_emp_id_seq; publicadminfalse8242 )00emp_emp_id_seqSEQUENCE OWNED BY3ALTER SEQUENCE emp_emp_id_seq OWNED BY emp.emp_id; publicadminfalse445!)00emp_emp_id_seqACLREVOKE ALL ON SEQUENCE emp_emp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE emp_emp_id_seq FROM admin; GRANT ALL ON SEQUENCE emp_emp_id_seq TO admin; GRANT ALL ON SEQUENCE emp_emp_id_seq TO xtrole; publicadminfalse445125981270empgrpTABLECREATE TABLE empgrp ( empgrp_id integer NOT NULL, empgrp_name text NOT NULL, empgrp_descrip text NOT NULL, CONSTRAINT empgrp_empgrp_name_check CHECK ((empgrp_name <> ''::text)) ); DROP TABLE public.empgrp; publicadminfalse65048")00empgrpACLREVOKE ALL ON TABLE empgrp FROM PUBLIC; REVOKE ALL ON TABLE empgrp FROM admin; GRANT ALL ON TABLE empgrp TO admin; GRANT ALL ON TABLE empgrp TO xtrole; publicadminfalse446125981277empgrp_empgrp_id_seqSEQUENCEvCREATE SEQUENCE empgrp_empgrp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.empgrp_empgrp_id_seq; publicadminfalse8446#)00empgrp_empgrp_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE empgrp_empgrp_id_seq OWNED BY empgrp.empgrp_id; publicadminfalse447$)00empgrp_empgrp_id_seqACLREVOKE ALL ON SEQUENCE empgrp_empgrp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE empgrp_empgrp_id_seq FROM admin; GRANT ALL ON SEQUENCE empgrp_empgrp_id_seq TO admin; GRANT ALL ON SEQUENCE empgrp_empgrp_id_seq TO xtrole; publicadminfalse447125981279 empgrpitemTABLECREATE TABLE empgrpitem ( empgrpitem_id integer NOT NULL, empgrpitem_empgrp_id integer NOT NULL, empgrpitem_emp_id integer NOT NULL ); DROP TABLE public.empgrpitem; publicadminfalse8%)00 empgrpitemACLREVOKE ALL ON TABLE empgrpitem FROM PUBLIC; REVOKE ALL ON TABLE empgrpitem FROM admin; GRANT ALL ON TABLE empgrpitem TO admin; GRANT ALL ON TABLE empgrpitem TO xtrole; publicadminfalse448125981282empgrpitem_empgrpitem_id_seqSEQUENCE~CREATE SEQUENCE empgrpitem_empgrpitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 3DROP SEQUENCE public.empgrpitem_empgrpitem_id_seq; publicadminfalse8448&)00empgrpitem_empgrpitem_id_seqSEQUENCE OWNED BYOALTER SEQUENCE empgrpitem_empgrpitem_id_seq OWNED BY empgrpitem.empgrpitem_id; publicadminfalse449')00empgrpitem_empgrpitem_id_seqACLREVOKE ALL ON SEQUENCE empgrpitem_empgrpitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE empgrpitem_empgrpitem_id_seq FROM admin; GRANT ALL ON SEQUENCE empgrpitem_empgrpitem_id_seq TO admin; GRANT ALL ON SEQUENCE empgrpitem_empgrpitem_id_seq TO xtrole; publicadminfalse449125981284evntlogTABLE!CREATE TABLE evntlog ( evntlog_id integer DEFAULT nextval(('evntlog_evntlog_id_seq'::text)::regclass) NOT NULL, evntlog_evnttime timestamp with time zone, evntlog_evnttype_id integer, evntlog_ord_id integer, evntlog_dispatched timestamp with time zone, evntlog_action text, evntlog_warehous_id integer, evntlog_number text, evntlog_newvalue numeric(20,10), evntlog_oldvalue numeric(20,10), evntlog_newdate date, evntlog_olddate date, evntlog_ordtype character(2), evntlog_username text ); DROP TABLE public.evntlog; publicadminfalse65068()00 TABLE evntlogCOMMENT:COMMENT ON TABLE evntlog IS 'Event Notification history'; publicadminfalse450))00evntlogACLREVOKE ALL ON TABLE evntlog FROM PUBLIC; REVOKE ALL ON TABLE evntlog FROM admin; GRANT ALL ON TABLE evntlog TO admin; GRANT ALL ON TABLE evntlog TO xtrole; publicadminfalse450125981291evntlog_evntlog_id_seqSEQUENCECREATE SEQUENCE evntlog_evntlog_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.evntlog_evntlog_id_seq; publicadminfalse8*)00evntlog_evntlog_id_seqACLREVOKE ALL ON SEQUENCE evntlog_evntlog_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE evntlog_evntlog_id_seq FROM admin; GRANT ALL ON SEQUENCE evntlog_evntlog_id_seq TO admin; GRANT ALL ON SEQUENCE evntlog_evntlog_id_seq TO xtrole; publicadminfalse451125981293evntnotTABLECREATE TABLE evntnot ( evntnot_id integer DEFAULT nextval(('evntnot_evntnot_id_seq'::text)::regclass) NOT NULL, evntnot_evnttype_id integer, evntnot_warehous_id integer, evntnot_username text ); DROP TABLE public.evntnot; publicadminfalse65078+)00 TABLE evntnotCOMMENTpCOMMENT ON TABLE evntnot IS 'Temporary table for storing information about user Event Notification selections'; publicadminfalse452,)00evntnotACLREVOKE ALL ON TABLE evntnot FROM PUBLIC; REVOKE ALL ON TABLE evntnot FROM admin; GRANT ALL ON TABLE evntnot TO admin; GRANT ALL ON TABLE evntnot TO xtrole; publicadminfalse452125981300evntnot_evntnot_id_seqSEQUENCECREATE SEQUENCE evntnot_evntnot_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.evntnot_evntnot_id_seq; publicadminfalse8-)00evntnot_evntnot_id_seqACLREVOKE ALL ON SEQUENCE evntnot_evntnot_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE evntnot_evntnot_id_seq FROM admin; GRANT ALL ON SEQUENCE evntnot_evntnot_id_seq TO admin; GRANT ALL ON SEQUENCE evntnot_evntnot_id_seq TO xtrole; publicadminfalse453125981302evnttypeTABLE!CREATE TABLE evnttype ( evnttype_id integer DEFAULT nextval(('evnttype_evnttype_id_seq'::text)::regclass) NOT NULL, evnttype_name text NOT NULL, evnttype_descrip text, evnttype_module text, CONSTRAINT evnttype_evnttype_name_check CHECK ((evnttype_name <> ''::text)) ); DROP TABLE public.evnttype; publicadminfalse650865098.)00TABLE evnttypeCOMMENT7COMMENT ON TABLE evnttype IS 'Event Type information'; publicadminfalse454/)00evnttypeACLREVOKE ALL ON TABLE evnttype FROM PUBLIC; REVOKE ALL ON TABLE evnttype FROM admin; GRANT ALL ON TABLE evnttype TO admin; GRANT ALL ON TABLE evnttype TO xtrole; publicadminfalse454125981310evnttype_evnttype_id_seqSEQUENCECREATE SEQUENCE evnttype_evnttype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; /DROP SEQUENCE public.evnttype_evnttype_id_seq; publicadminfalse80)00evnttype_evnttype_id_seqACLREVOKE ALL ON SEQUENCE evnttype_evnttype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE evnttype_evnttype_id_seq FROM admin; GRANT ALL ON SEQUENCE evnttype_evnttype_id_seq TO admin; GRANT ALL ON SEQUENCE evnttype_evnttype_id_seq TO xtrole; publicadminfalse455125981312expcat_expcat_id_seqSEQUENCEvCREATE SEQUENCE expcat_expcat_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.expcat_expcat_id_seq; publicadminfalse82731)00expcat_expcat_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE expcat_expcat_id_seq OWNED BY expcat.expcat_id; publicadminfalse4562)00expcat_expcat_id_seqACLREVOKE ALL ON SEQUENCE expcat_expcat_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE expcat_expcat_id_seq FROM admin; GRANT ALL ON SEQUENCE expcat_expcat_id_seq TO admin; GRANT ALL ON SEQUENCE expcat_expcat_id_seq TO xtrole; publicadminfalse456125981314file_file_id_seqSEQUENCErCREATE SEQUENCE file_file_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 'DROP SEQUENCE public.file_file_id_seq; publicadminfalse82193)00file_file_id_seqSEQUENCE OWNED BY7ALTER SEQUENCE file_file_id_seq OWNED BY file.file_id; publicadminfalse4574)00file_file_id_seqACLREVOKE ALL ON SEQUENCE file_file_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE file_file_id_seq FROM admin; GRANT ALL ON SEQUENCE file_file_id_seq TO admin; GRANT ALL ON SEQUENCE file_file_id_seq TO xtrole; publicadminfalse457125981316filterTABLECREATE TABLE filter ( filter_id integer NOT NULL, filter_screen text NOT NULL, filter_value text NOT NULL, filter_username text, filter_name text NOT NULL, filter_selected boolean DEFAULT false ); DROP TABLE public.filter; publicadminfalse651185)00filterACLREVOKE ALL ON TABLE filter FROM PUBLIC; REVOKE ALL ON TABLE filter FROM admin; GRANT ALL ON TABLE filter TO admin; GRANT ALL ON TABLE filter TO xtrole; publicadminfalse458125981323filter_filter_id_seqSEQUENCEvCREATE SEQUENCE filter_filter_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.filter_filter_id_seq; publicadminfalse84586)00filter_filter_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE filter_filter_id_seq OWNED BY filter.filter_id; publicadminfalse4597)00filter_filter_id_seqACLREVOKE ALL ON SEQUENCE filter_filter_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE filter_filter_id_seq FROM admin; GRANT ALL ON SEQUENCE filter_filter_id_seq TO admin; GRANT ALL ON SEQUENCE filter_filter_id_seq TO xtrole; publicadminfalse459125981325finchargTABLE$CREATE TABLE fincharg ( fincharg_id integer NOT NULL, fincharg_mincharg numeric NOT NULL, fincharg_graceperiod integer NOT NULL, fincharg_assessoverdue boolean NOT NULL, fincharg_calcfrom integer NOT NULL, fincharg_markoninvoice text NOT NULL, fincharg_air numeric NOT NULL, fincharg_accnt_id integer NOT NULL, fincharg_salescat_id integer NOT NULL, fincharg_lastfc_statementcyclefrom text, fincharg_lastfc_custidfrom text, fincharg_lastfc_custidto text, fincharg_lastfc_statementcycleto text ); DROP TABLE public.fincharg; publicadminfalse88)00TABLE finchargCOMMENTICOMMENT ON TABLE fincharg IS 'Finance Charge configuration information'; publicadminfalse4609)00finchargACLREVOKE ALL ON TABLE fincharg FROM PUBLIC; REVOKE ALL ON TABLE fincharg FROM admin; GRANT ALL ON TABLE fincharg TO admin; GRANT ALL ON TABLE fincharg TO xtrole; publicadminfalse460125981331fincharg_fincharg_id_seqSEQUENCEzCREATE SEQUENCE fincharg_fincharg_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.fincharg_fincharg_id_seq; publicadminfalse8460:)00fincharg_fincharg_id_seqSEQUENCE OWNED BYGALTER SEQUENCE fincharg_fincharg_id_seq OWNED BY fincharg.fincharg_id; publicadminfalse461;)00fincharg_fincharg_id_seqACLREVOKE ALL ON SEQUENCE fincharg_fincharg_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE fincharg_fincharg_id_seq FROM admin; GRANT ALL ON SEQUENCE fincharg_fincharg_id_seq TO admin; GRANT ALL ON SEQUENCE fincharg_fincharg_id_seq TO xtrole; publicadminfalse461125981333flheadTABLE:CREATE TABLE flhead ( flhead_id integer NOT NULL, flhead_name text NOT NULL, flhead_descrip text, flhead_showtotal boolean DEFAULT false NOT NULL, flhead_showstart boolean DEFAULT true NOT NULL, flhead_showend boolean DEFAULT true NOT NULL, flhead_showdelta boolean DEFAULT true NOT NULL, flhead_showbudget boolean DEFAULT true NOT NULL, flhead_showdiff boolean DEFAULT false NOT NULL, flhead_showcustom boolean DEFAULT false NOT NULL, flhead_custom_label text, flhead_usealttotal boolean DEFAULT false NOT NULL, flhead_alttotal text, flhead_usealtbegin boolean DEFAULT false NOT NULL, flhead_altbegin text, flhead_usealtend boolean DEFAULT false NOT NULL, flhead_altend text, flhead_usealtdebits boolean DEFAULT false NOT NULL, flhead_altdebits text, flhead_usealtcredits boolean DEFAULT false NOT NULL, flhead_altcredits text, flhead_usealtbudget boolean DEFAULT false NOT NULL, flhead_altbudget text, flhead_usealtdiff boolean DEFAULT false NOT NULL, flhead_altdiff text, flhead_type character(1) DEFAULT 'A'::bpchar NOT NULL, flhead_active boolean DEFAULT true NOT NULL, flhead_sys boolean DEFAULT false, flhead_notes text DEFAULT ''::text, CONSTRAINT flhead_flhead_name_check CHECK ((flhead_name <> ''::text)) ); DROP TABLE public.flhead; publicadminfalse65136514651565166517651865196520652165226523652465256526652765286529653065328<)00 TABLE flheadCOMMENTBCOMMENT ON TABLE flhead IS 'Financial Layout header information'; publicadminfalse462=)00flheadACLREVOKE ALL ON TABLE flhead FROM PUBLIC; REVOKE ALL ON TABLE flhead FROM admin; GRANT ALL ON TABLE flhead TO admin; GRANT ALL ON TABLE flhead TO xtrole; publicadminfalse462125981358flitemTABLE0CREATE TABLE flitem ( flitem_id integer NOT NULL, flitem_flhead_id integer, flitem_flgrp_id integer, flitem_order integer, flitem_accnt_id integer, flitem_showstart boolean, flitem_showend boolean, flitem_showdelta boolean, flitem_showbudget boolean DEFAULT false NOT NULL, flitem_subtract boolean DEFAULT false NOT NULL, flitem_showstartprcnt boolean DEFAULT false NOT NULL, flitem_showendprcnt boolean DEFAULT false NOT NULL, flitem_showdeltaprcnt boolean DEFAULT false NOT NULL, flitem_showbudgetprcnt boolean DEFAULT false NOT NULL, flitem_prcnt_flgrp_id integer DEFAULT (-1) NOT NULL, flitem_showdiff boolean DEFAULT false NOT NULL, flitem_showdiffprcnt boolean DEFAULT false NOT NULL, flitem_showcustom boolean DEFAULT false NOT NULL, flitem_showcustomprcnt boolean DEFAULT false NOT NULL, flitem_custom_source character(1), flitem_company text, flitem_profit text, flitem_number text, flitem_sub text, flitem_type character(1), flitem_subaccnttype_code text ); DROP TABLE public.flitem; publicadminfalse653365346535653665376538653965406541654265438>)00 TABLE flitemCOMMENTCCOMMENT ON TABLE flitem IS 'Financial Layout Account information'; publicadminfalse463?)00flitemACLREVOKE ALL ON TABLE flitem FROM PUBLIC; REVOKE ALL ON TABLE flitem FROM admin; GRANT ALL ON TABLE flitem TO admin; GRANT ALL ON TABLE flitem TO xtrole; publicadminfalse463125987604flaccntVIEW CREATE VIEW flaccnt AS SELECT flhead.flhead_type, flitem.flitem_id, flitem.flitem_flhead_id, flitem.flitem_flgrp_id, flitem.flitem_order, flitem.flitem_accnt_id, flitem.flitem_showstart, flitem.flitem_showend, flitem.flitem_showdelta, flitem.flitem_showbudget, flitem.flitem_subtract, flitem.flitem_showstartprcnt, flitem.flitem_showendprcnt, flitem.flitem_showdeltaprcnt, flitem.flitem_showbudgetprcnt, flitem.flitem_prcnt_flgrp_id, flitem.flitem_showdiff, flitem.flitem_showdiffprcnt, flitem.flitem_showcustom, flitem.flitem_showcustomprcnt, flitem.flitem_custom_source, flitem.flitem_company, flitem.flitem_profit, flitem.flitem_number, flitem.flitem_sub, flitem.flitem_type, flitem.flitem_subaccnttype_code, accnt.accnt_id, accnt.accnt_type, accnt.accnt_company, accnt.accnt_profit, accnt.accnt_number, accnt.accnt_sub, (-1) AS prj_id FROM ((flhead JOIN flitem ON ((flhead.flhead_id = flitem.flitem_flhead_id))) JOIN accnt ON ((flitem.flitem_accnt_id = accnt.accnt_id))) UNION ALL SELECT flhead.flhead_type, flitem.flitem_id, flitem.flitem_flhead_id, flitem.flitem_flgrp_id, flitem.flitem_order, flitem.flitem_accnt_id, flitem.flitem_showstart, flitem.flitem_showend, flitem.flitem_showdelta, flitem.flitem_showbudget, flitem.flitem_subtract, flitem.flitem_showstartprcnt, flitem.flitem_showendprcnt, flitem.flitem_showdeltaprcnt, flitem.flitem_showbudgetprcnt, flitem.flitem_prcnt_flgrp_id, flitem.flitem_showdiff, flitem.flitem_showdiffprcnt, flitem.flitem_showcustom, flitem.flitem_showcustomprcnt, flitem.flitem_custom_source, flitem.flitem_company, flitem.flitem_profit, flitem.flitem_number, flitem.flitem_sub, flitem.flitem_type, flitem.flitem_subaccnttype_code, accnt.accnt_id, accnt.accnt_type, accnt.accnt_company, accnt.accnt_profit, accnt.accnt_number, accnt.accnt_sub, (-1) AS prj_id FROM (flhead JOIN flitem ON ((flhead.flhead_id = flitem.flitem_flhead_id))), accnt WHERE (((((((flitem.flitem_accnt_id = (-1)) AND ((flitem.flitem_type = ''::bpchar) OR (accnt.accnt_type = flitem.flitem_type))) AND ((flitem.flitem_company = 'All'::text) OR (accnt.accnt_company = flitem.flitem_company))) AND ((flitem.flitem_profit = 'All'::text) OR (accnt.accnt_profit = flitem.flitem_profit))) AND ((flitem.flitem_number = 'All'::text) OR (accnt.accnt_number = flitem.flitem_number))) AND ((flitem.flitem_sub = 'All'::text) OR (accnt.accnt_sub = flitem.flitem_sub))) AND ((flitem.flitem_subaccnttype_code = 'All'::text) OR (accnt.accnt_subaccnttype_code = flitem.flitem_subaccnttype_code))) ORDER BY 30, 31, 32, 33; DROP VIEW public.flaccnt; publicadminfalse86798@)00flaccntACLREVOKE ALL ON TABLE flaccnt FROM PUBLIC; REVOKE ALL ON TABLE flaccnt FROM admin; GRANT ALL ON TABLE flaccnt TO admin; GRANT ALL ON TABLE flaccnt TO xtrole; publicadminfalse796125981380flcolTABLE~CREATE TABLE flcol ( flcol_id integer NOT NULL, flcol_flhead_id integer NOT NULL, flcol_name text, flcol_descrip text, flcol_report_id integer, flcol_month boolean, flcol_quarter boolean, flcol_year boolean, flcol_showdb boolean, flcol_prcnt boolean, flcol_priortype character(1), flcol_priormonth boolean, flcol_priorquarter boolean, flcol_prioryear character(1), flcol_priorprcnt boolean, flcol_priordiff boolean, flcol_priordiffprcnt boolean, flcol_budget boolean, flcol_budgetprcnt boolean, flcol_budgetdiff boolean, flcol_budgetdiffprcnt boolean ); DROP TABLE public.flcol; publicadminfalse8A)00flcolACLREVOKE ALL ON TABLE flcol FROM PUBLIC; REVOKE ALL ON TABLE flcol FROM admin; GRANT ALL ON TABLE flcol TO admin; GRANT ALL ON TABLE flcol TO xtrole; publicadminfalse464125981386flcol_flcol_id_seqSEQUENCEtCREATE SEQUENCE flcol_flcol_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; )DROP SEQUENCE public.flcol_flcol_id_seq; publicadminfalse8464B)00flcol_flcol_id_seqSEQUENCE OWNED BY;ALTER SEQUENCE flcol_flcol_id_seq OWNED BY flcol.flcol_id; publicadminfalse465C)00flcol_flcol_id_seqACLREVOKE ALL ON SEQUENCE flcol_flcol_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE flcol_flcol_id_seq FROM admin; GRANT ALL ON SEQUENCE flcol_flcol_id_seq TO admin; GRANT ALL ON SEQUENCE flcol_flcol_id_seq TO xtrole; publicadminfalse465125981388flgrpTABLEdCREATE TABLE flgrp ( flgrp_id integer NOT NULL, flgrp_flhead_id integer, flgrp_flgrp_id integer, flgrp_order integer, flgrp_name text, flgrp_descrip text, flgrp_subtotal boolean DEFAULT false NOT NULL, flgrp_summarize boolean DEFAULT false NOT NULL, flgrp_subtract boolean DEFAULT false NOT NULL, flgrp_showstart boolean DEFAULT true NOT NULL, flgrp_showend boolean DEFAULT true NOT NULL, flgrp_showdelta boolean DEFAULT true NOT NULL, flgrp_showbudget boolean DEFAULT true NOT NULL, flgrp_showstartprcnt boolean DEFAULT false NOT NULL, flgrp_showendprcnt boolean DEFAULT false NOT NULL, flgrp_showdeltaprcnt boolean DEFAULT false NOT NULL, flgrp_showbudgetprcnt boolean DEFAULT false NOT NULL, flgrp_prcnt_flgrp_id integer DEFAULT (-1) NOT NULL, flgrp_showdiff boolean DEFAULT false NOT NULL, flgrp_showdiffprcnt boolean DEFAULT false NOT NULL, flgrp_showcustom boolean DEFAULT false NOT NULL, flgrp_showcustomprcnt boolean DEFAULT false NOT NULL, flgrp_usealtsubtotal boolean DEFAULT false NOT NULL, flgrp_altsubtotal text ); DROP TABLE public.flgrp; publicadminfalse654665476548654965506551655265536554655565566557655865596560656165628D)00 TABLE flgrpCOMMENT@COMMENT ON TABLE flgrp IS 'Financial Layout Group information'; publicadminfalse466E)00flgrpACLREVOKE ALL ON TABLE flgrp FROM PUBLIC; REVOKE ALL ON TABLE flgrp FROM admin; GRANT ALL ON TABLE flgrp TO admin; GRANT ALL ON TABLE flgrp TO xtrole; publicadminfalse466125981411flgrp_flgrp_id_seqSEQUENCEtCREATE SEQUENCE flgrp_flgrp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; )DROP SEQUENCE public.flgrp_flgrp_id_seq; publicadminfalse4668F)00flgrp_flgrp_id_seqSEQUENCE OWNED BY;ALTER SEQUENCE flgrp_flgrp_id_seq OWNED BY flgrp.flgrp_id; publicadminfalse467G)00flgrp_flgrp_id_seqACLREVOKE ALL ON SEQUENCE flgrp_flgrp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE flgrp_flgrp_id_seq FROM admin; GRANT ALL ON SEQUENCE flgrp_flgrp_id_seq TO admin; GRANT ALL ON SEQUENCE flgrp_flgrp_id_seq TO xtrole; publicadminfalse467125981413flhead_flhead_id_seqSEQUENCEvCREATE SEQUENCE flhead_flhead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.flhead_flhead_id_seq; publicadminfalse8462H)00flhead_flhead_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE flhead_flhead_id_seq OWNED BY flhead.flhead_id; publicadminfalse468I)00flhead_flhead_id_seqACLREVOKE ALL ON SEQUENCE flhead_flhead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE flhead_flhead_id_seq FROM admin; GRANT ALL ON SEQUENCE flhead_flhead_id_seq TO admin; GRANT ALL ON SEQUENCE flhead_flhead_id_seq TO xtrole; publicadminfalse468125981415flitem_flitem_id_seqSEQUENCEvCREATE SEQUENCE flitem_flitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.flitem_flitem_id_seq; publicadminfalse8463J)00flitem_flitem_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE flitem_flitem_id_seq OWNED BY flitem.flitem_id; publicadminfalse469K)00flitem_flitem_id_seqACLREVOKE ALL ON SEQUENCE flitem_flitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE flitem_flitem_id_seq FROM admin; GRANT ALL ON SEQUENCE flitem_flitem_id_seq TO admin; GRANT ALL ON SEQUENCE flitem_flitem_id_seq TO xtrole; publicadminfalse469125981417flnotesTABLECREATE TABLE flnotes ( flnotes_id integer NOT NULL, flnotes_flhead_id integer, flnotes_period_id integer, flnotes_notes text DEFAULT ''::text ); DROP TABLE public.flnotes; publicadminfalse65658L)00flnotesACLREVOKE ALL ON TABLE flnotes FROM PUBLIC; REVOKE ALL ON TABLE flnotes FROM admin; GRANT ALL ON TABLE flnotes TO admin; GRANT ALL ON TABLE flnotes TO xtrole; publicadminfalse470125981424flnotes_flnotes_id_seqSEQUENCExCREATE SEQUENCE flnotes_flnotes_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.flnotes_flnotes_id_seq; publicadminfalse8470M)00flnotes_flnotes_id_seqSEQUENCE OWNED BYCALTER SEQUENCE flnotes_flnotes_id_seq OWNED BY flnotes.flnotes_id; publicadminfalse471N)00flnotes_flnotes_id_seqACLREVOKE ALL ON SEQUENCE flnotes_flnotes_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE flnotes_flnotes_id_seq FROM admin; GRANT ALL ON SEQUENCE flnotes_flnotes_id_seq TO admin; GRANT ALL ON SEQUENCE flnotes_flnotes_id_seq TO xtrole; publicadminfalse471125981426flrptTABLE/CREATE TABLE flrpt ( flrpt_flhead_id integer NOT NULL, flrpt_period_id integer NOT NULL, flrpt_username text NOT NULL, flrpt_order integer NOT NULL, flrpt_level integer NOT NULL, flrpt_type text NOT NULL, flrpt_type_id integer NOT NULL, flrpt_beginning numeric, flrpt_ending numeric, flrpt_debits numeric, flrpt_credits numeric, flrpt_budget numeric, flrpt_beginningprcnt numeric, flrpt_endingprcnt numeric, flrpt_debitsprcnt numeric, flrpt_creditsprcnt numeric, flrpt_budgetprcnt numeric, flrpt_parent_id integer, flrpt_diff numeric, flrpt_diffprcnt numeric, flrpt_custom numeric, flrpt_customprcnt numeric, flrpt_altname text, flrpt_accnt_id integer, flrpt_interval character(1), flrpt_id integer NOT NULL ); DROP TABLE public.flrpt; publicadminfalse8O)00 TABLE flrptCOMMENTvCOMMENT ON TABLE flrpt IS 'Scratch table where financial reporting information is processed before being displayed.'; publicadminfalse472P)00flrptACLREVOKE ALL ON TABLE flrpt FROM PUBLIC; REVOKE ALL ON TABLE flrpt FROM admin; GRANT ALL ON TABLE flrpt TO admin; GRANT ALL ON TABLE flrpt TO xtrole; publicadminfalse472125981432flrpt_flrpt_id_seqSEQUENCEtCREATE SEQUENCE flrpt_flrpt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; )DROP SEQUENCE public.flrpt_flrpt_id_seq; publicadminfalse8472Q)00flrpt_flrpt_id_seqSEQUENCE OWNED BY;ALTER SEQUENCE flrpt_flrpt_id_seq OWNED BY flrpt.flrpt_id; publicadminfalse473R)00flrpt_flrpt_id_seqACLREVOKE ALL ON SEQUENCE flrpt_flrpt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE flrpt_flrpt_id_seq FROM admin; GRANT ALL ON SEQUENCE flrpt_flrpt_id_seq TO admin; GRANT ALL ON SEQUENCE flrpt_flrpt_id_seq TO xtrole; publicadminfalse473125981434flspecTABLECREATE TABLE flspec ( flspec_id integer NOT NULL, flspec_flhead_id integer NOT NULL, flspec_flgrp_id integer NOT NULL, flspec_order integer NOT NULL, flspec_name text, flspec_type text, flspec_showstart boolean DEFAULT true NOT NULL, flspec_showend boolean DEFAULT true NOT NULL, flspec_showdelta boolean DEFAULT true NOT NULL, flspec_showbudget boolean DEFAULT false NOT NULL, flspec_subtract boolean DEFAULT false NOT NULL, flspec_showstartprcnt boolean DEFAULT false NOT NULL, flspec_showendprcnt boolean DEFAULT false NOT NULL, flspec_showdeltaprcnt boolean DEFAULT false NOT NULL, flspec_showbudgetprcnt boolean DEFAULT false NOT NULL, flspec_showdiff boolean DEFAULT false NOT NULL, flspec_showdiffprcnt boolean DEFAULT false NOT NULL, flspec_prcnt_flgrp_id integer DEFAULT (-1) NOT NULL, flspec_showcustom boolean DEFAULT false NOT NULL, flspec_showcustomprcnt boolean DEFAULT false NOT NULL, flspec_custom_source character(1) ); DROP TABLE public.flspec; publicadminfalse656765686569657065716572657365746575657665776578657965808S)00 TABLE flspecCOMMENT@COMMENT ON TABLE flspec IS 'Financial Layout Special entries.'; publicadminfalse474T)00flspecACLREVOKE ALL ON TABLE flspec FROM PUBLIC; REVOKE ALL ON TABLE flspec FROM admin; GRANT ALL ON TABLE flspec TO admin; GRANT ALL ON TABLE flspec TO xtrole; publicadminfalse474125981454flspec_flspec_id_seqSEQUENCEvCREATE SEQUENCE flspec_flspec_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.flspec_flspec_id_seq; publicadminfalse8474U)00flspec_flspec_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE flspec_flspec_id_seq OWNED BY flspec.flspec_id; publicadminfalse475V)00flspec_flspec_id_seqACLREVOKE ALL ON SEQUENCE flspec_flspec_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE flspec_flspec_id_seq FROM admin; GRANT ALL ON SEQUENCE flspec_flspec_id_seq TO admin; GRANT ALL ON SEQUENCE flspec_flspec_id_seq TO xtrole; publicadminfalse475125981456formTABLE?CREATE TABLE form ( form_id integer DEFAULT nextval(('"form_form_id_seq"'::text)::regclass) NOT NULL, form_name text NOT NULL, form_descrip text, form_report_id integer, form_key character varying(4), form_report_name text, CONSTRAINT form_form_name_check CHECK ((form_name <> ''::text)) ); DROP TABLE public.form; publicadminfalse658265838W)00 TABLE formCOMMENT-COMMENT ON TABLE form IS 'Form information'; publicadminfalse476X)00COLUMN form.form_report_idCOMMENT\COMMENT ON COLUMN form.form_report_id IS 'Obsolete -- reference form_report_name instead.'; publicadminfalse476Y)00formACLREVOKE ALL ON TABLE form FROM PUBLIC; REVOKE ALL ON TABLE form FROM admin; GRANT ALL ON TABLE form TO admin; GRANT ALL ON TABLE form TO xtrole; publicadminfalse476125981464form_form_id_seqSEQUENCEzCREATE SEQUENCE form_form_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; 'DROP SEQUENCE public.form_form_id_seq; publicadminfalse8Z)00form_form_id_seqACLREVOKE ALL ON SEQUENCE form_form_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE form_form_id_seq FROM admin; GRANT ALL ON SEQUENCE form_form_id_seq TO admin; GRANT ALL ON SEQUENCE form_form_id_seq TO xtrole; publicadminfalse477125981466 freightclass_freightclass_id_seqSEQUENCECREATE SEQUENCE freightclass_freightclass_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 7DROP SEQUENCE public.freightclass_freightclass_id_seq; publicadminfalse8245[)00 freightclass_freightclass_id_seqSEQUENCE OWNED BYWALTER SEQUENCE freightclass_freightclass_id_seq OWNED BY freightclass.freightclass_id; publicadminfalse478\)00 freightclass_freightclass_id_seqACL REVOKE ALL ON SEQUENCE freightclass_freightclass_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE freightclass_freightclass_id_seq FROM admin; GRANT ALL ON SEQUENCE freightclass_freightclass_id_seq TO admin; GRANT ALL ON SEQUENCE freightclass_freightclass_id_seq TO xtrole; publicadminfalse478125981468glseriesTABLECREATE TABLE glseries ( glseries_id integer DEFAULT nextval(('"glseries_glseries_id_seq"'::text)::regclass) NOT NULL, glseries_sequence integer, glseries_doctype character(2), glseries_docnumber text, glseries_accnt_id integer, glseries_amount numeric(20,2), glseries_source text, glseries_distdate date, glseries_notes text, glseries_misc_id integer ); DROP TABLE public.glseries; publicadminfalse65848])00TABLE glseriesCOMMENTCOMMENT ON TABLE glseries IS 'Temporary table for storing information about General Ledger (G/L) Series Entries before Series Entries are posted'; publicadminfalse479^)00glseriesACLREVOKE ALL ON TABLE glseries FROM PUBLIC; REVOKE ALL ON TABLE glseries FROM admin; GRANT ALL ON TABLE glseries TO admin; GRANT ALL ON TABLE glseries TO xtrole; publicadminfalse479125981475glseries_glseries_id_seqSEQUENCECREATE SEQUENCE glseries_glseries_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; /DROP SEQUENCE public.glseries_glseries_id_seq; publicadminfalse8_)00glseries_glseries_id_seqACLREVOKE ALL ON SEQUENCE glseries_glseries_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE glseries_glseries_id_seq FROM admin; GRANT ALL ON SEQUENCE glseries_glseries_id_seq TO admin; GRANT ALL ON SEQUENCE glseries_glseries_id_seq TO xtrole; publicadminfalse480125981477gltrans_gltrans_id_seqSEQUENCECREATE SEQUENCE gltrans_gltrans_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.gltrans_gltrans_id_seq; publicadminfalse8`)00gltrans_gltrans_id_seqACLREVOKE ALL ON SEQUENCE gltrans_gltrans_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE gltrans_gltrans_id_seq FROM admin; GRANT ALL ON SEQUENCE gltrans_gltrans_id_seq TO admin; GRANT ALL ON SEQUENCE gltrans_gltrans_id_seq TO xtrole; publicadminfalse481125981479gltrans_sequence_seqSEQUENCE~CREATE SEQUENCE gltrans_sequence_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; +DROP SEQUENCE public.gltrans_sequence_seq; publicadminfalse8a)00gltrans_sequence_seqACLREVOKE ALL ON SEQUENCE gltrans_sequence_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE gltrans_sequence_seq FROM admin; GRANT ALL ON SEQUENCE gltrans_sequence_seq TO admin; GRANT ALL ON SEQUENCE gltrans_sequence_seq TO xtrole; publicadminfalse482125981481grpTABLECREATE TABLE grp ( grp_id integer NOT NULL, grp_name text NOT NULL, grp_descrip text, CONSTRAINT grp_grp_name_check CHECK ((grp_name <> ''::text)) ); DROP TABLE public.grp; publicadminfalse65868b)00 TABLE grpCOMMENTFCOMMENT ON TABLE grp IS 'This table is the basic group information.'; publicadminfalse483c)00grpACLREVOKE ALL ON TABLE grp FROM PUBLIC; REVOKE ALL ON TABLE grp FROM admin; GRANT ALL ON TABLE grp TO admin; GRANT ALL ON TABLE grp TO xtrole; publicadminfalse483125981488grp_grp_id_seqSEQUENCEpCREATE SEQUENCE grp_grp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; %DROP SEQUENCE public.grp_grp_id_seq; publicadminfalse8483d)00grp_grp_id_seqSEQUENCE OWNED BY3ALTER SEQUENCE grp_grp_id_seq OWNED BY grp.grp_id; publicadminfalse484e)00grp_grp_id_seqACLREVOKE ALL ON SEQUENCE grp_grp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE grp_grp_id_seq FROM admin; GRANT ALL ON SEQUENCE grp_grp_id_seq TO admin; GRANT ALL ON SEQUENCE grp_grp_id_seq TO xtrole; publicadminfalse484125981490grpprivTABLECREATE TABLE grppriv ( grppriv_id integer NOT NULL, grppriv_grp_id integer NOT NULL, grppriv_priv_id integer NOT NULL ); DROP TABLE public.grppriv; publicadminfalse8f)00 TABLE grpprivCOMMENTMCOMMENT ON TABLE grppriv IS 'This is a specific priv for a specific group.'; publicadminfalse485g)00grpprivACLREVOKE ALL ON TABLE grppriv FROM PUBLIC; REVOKE ALL ON TABLE grppriv FROM admin; GRANT ALL ON TABLE grppriv TO admin; GRANT ALL ON TABLE grppriv TO xtrole; publicadminfalse485125981493grppriv_grppriv_id_seqSEQUENCExCREATE SEQUENCE grppriv_grppriv_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.grppriv_grppriv_id_seq; publicadminfalse8485h)00grppriv_grppriv_id_seqSEQUENCE OWNED BYCALTER SEQUENCE grppriv_grppriv_id_seq OWNED BY grppriv.grppriv_id; publicadminfalse486i)00grppriv_grppriv_id_seqACLREVOKE ALL ON SEQUENCE grppriv_grppriv_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE grppriv_grppriv_id_seq FROM admin; GRANT ALL ON SEQUENCE grppriv_grppriv_id_seq TO admin; GRANT ALL ON SEQUENCE grppriv_grppriv_id_seq TO xtrole; publicadminfalse486125981495hnfcTABLECREATE TABLE hnfc ( hnfc_id integer NOT NULL, hnfc_code text NOT NULL, CONSTRAINT hnfc_hnfc_code_check CHECK ((hnfc_code <> ''::text)) ); DROP TABLE public.hnfc; publicadminfalse65898j)00 TABLE hnfcCOMMENTTCOMMENT ON TABLE hnfc IS 'List of personal titles/honorifics used in cntct table.'; publicadminfalse487k)00hnfcACLREVOKE ALL ON TABLE hnfc FROM PUBLIC; REVOKE ALL ON TABLE hnfc FROM admin; GRANT ALL ON TABLE hnfc TO admin; GRANT ALL ON TABLE hnfc TO xtrole; publicadminfalse487125981502hnfc_hnfc_id_seqSEQUENCErCREATE SEQUENCE hnfc_hnfc_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 'DROP SEQUENCE public.hnfc_hnfc_id_seq; publicadminfalse8487l)00hnfc_hnfc_id_seqSEQUENCE OWNED BY7ALTER SEQUENCE hnfc_hnfc_id_seq OWNED BY hnfc.hnfc_id; publicadminfalse488m)00hnfc_hnfc_id_seqACLREVOKE ALL ON SEQUENCE hnfc_hnfc_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE hnfc_hnfc_id_seq FROM admin; GRANT ALL ON SEQUENCE hnfc_hnfc_id_seq TO admin; GRANT ALL ON SEQUENCE hnfc_hnfc_id_seq TO xtrole; publicadminfalse488125981504incdt_incdt_id_seqSEQUENCEtCREATE SEQUENCE incdt_incdt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; )DROP SEQUENCE public.incdt_incdt_id_seq; publicadminfalse8189n)00incdt_incdt_id_seqSEQUENCE OWNED BY;ALTER SEQUENCE incdt_incdt_id_seq OWNED BY incdt.incdt_id; publicadminfalse489o)00incdt_incdt_id_seqACLREVOKE ALL ON SEQUENCE incdt_incdt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE incdt_incdt_id_seq FROM admin; GRANT ALL ON SEQUENCE incdt_incdt_id_seq TO admin; GRANT ALL ON SEQUENCE incdt_incdt_id_seq TO xtrole; publicadminfalse489125981506incdtcat_incdtcat_id_seqSEQUENCEzCREATE SEQUENCE incdtcat_incdtcat_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.incdtcat_incdtcat_id_seq; publicadminfalse8248p)00incdtcat_incdtcat_id_seqSEQUENCE OWNED BYGALTER SEQUENCE incdtcat_incdtcat_id_seq OWNED BY incdtcat.incdtcat_id; publicadminfalse490q)00incdtcat_incdtcat_id_seqACLREVOKE ALL ON SEQUENCE incdtcat_incdtcat_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE incdtcat_incdtcat_id_seq FROM admin; GRANT ALL ON SEQUENCE incdtcat_incdtcat_id_seq TO admin; GRANT ALL ON SEQUENCE incdtcat_incdtcat_id_seq TO xtrole; publicadminfalse490125981508 incdthistTABLEVCREATE TABLE incdthist ( incdthist_id integer NOT NULL, incdthist_incdt_id integer NOT NULL, incdthist_change character(1), incdthist_target_id integer, incdthist_timestamp timestamp without time zone DEFAULT now() NOT NULL, incdthist_username text DEFAULT geteffectivextuser() NOT NULL, incdthist_descrip text ); DROP TABLE public.incdthist; publicadminfalse659165928r)00TABLE incdthistCOMMENT:COMMENT ON TABLE incdthist IS 'Incident history changes'; publicadminfalse491s)00 incdthistACLREVOKE ALL ON TABLE incdthist FROM PUBLIC; REVOKE ALL ON TABLE incdthist FROM admin; GRANT ALL ON TABLE incdthist TO admin; GRANT ALL ON TABLE incdthist TO xtrole; publicadminfalse491125981516incdthist_incdthist_id_seqSEQUENCE|CREATE SEQUENCE incdthist_incdthist_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 1DROP SEQUENCE public.incdthist_incdthist_id_seq; publicadminfalse4918t)00incdthist_incdthist_id_seqSEQUENCE OWNED BYKALTER SEQUENCE incdthist_incdthist_id_seq OWNED BY incdthist.incdthist_id; publicadminfalse492u)00incdthist_incdthist_id_seqACLREVOKE ALL ON SEQUENCE incdthist_incdthist_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE incdthist_incdthist_id_seq FROM admin; GRANT ALL ON SEQUENCE incdthist_incdthist_id_seq TO admin; GRANT ALL ON SEQUENCE incdthist_incdthist_id_seq TO xtrole; publicadminfalse492125981518"incdtpriority_incdtpriority_id_seqSEQUENCECREATE SEQUENCE incdtpriority_incdtpriority_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 9DROP SEQUENCE public.incdtpriority_incdtpriority_id_seq; publicadminfalse8249v)00"incdtpriority_incdtpriority_id_seqSEQUENCE OWNED BY[ALTER SEQUENCE incdtpriority_incdtpriority_id_seq OWNED BY incdtpriority.incdtpriority_id; publicadminfalse493w)00"incdtpriority_incdtpriority_id_seqACLREVOKE ALL ON SEQUENCE incdtpriority_incdtpriority_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE incdtpriority_incdtpriority_id_seq FROM admin; GRANT ALL ON SEQUENCE incdtpriority_incdtpriority_id_seq TO admin; GRANT ALL ON SEQUENCE incdtpriority_incdtpriority_id_seq TO xtrole; publicadminfalse493125981520&incdtresolution_incdtresolution_id_seqSEQUENCECREATE SEQUENCE incdtresolution_incdtresolution_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; =DROP SEQUENCE public.incdtresolution_incdtresolution_id_seq; publicadminfalse8250x)00&incdtresolution_incdtresolution_id_seqSEQUENCE OWNED BYcALTER SEQUENCE incdtresolution_incdtresolution_id_seq OWNED BY incdtresolution.incdtresolution_id; publicadminfalse494y)00&incdtresolution_incdtresolution_id_seqACL$REVOKE ALL ON SEQUENCE incdtresolution_incdtresolution_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE incdtresolution_incdtresolution_id_seq FROM admin; GRANT ALL ON SEQUENCE incdtresolution_incdtresolution_id_seq TO admin; GRANT ALL ON SEQUENCE incdtresolution_incdtresolution_id_seq TO xtrole; publicadminfalse494125981522"incdtseverity_incdtseverity_id_seqSEQUENCECREATE SEQUENCE incdtseverity_incdtseverity_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 9DROP SEQUENCE public.incdtseverity_incdtseverity_id_seq; publicadminfalse8251z)00"incdtseverity_incdtseverity_id_seqSEQUENCE OWNED BY[ALTER SEQUENCE incdtseverity_incdtseverity_id_seq OWNED BY incdtseverity.incdtseverity_id; publicadminfalse495{)00"incdtseverity_incdtseverity_id_seqACLREVOKE ALL ON SEQUENCE incdtseverity_incdtseverity_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE incdtseverity_incdtseverity_id_seq FROM admin; GRANT ALL ON SEQUENCE incdtseverity_incdtseverity_id_seq TO admin; GRANT ALL ON SEQUENCE incdtseverity_incdtseverity_id_seq TO xtrole; publicadminfalse495125981524invbal_invbal_id_seqSEQUENCEvCREATE SEQUENCE invbal_invbal_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.invbal_invbal_id_seq; publicadminfalse8185|)00invbal_invbal_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE invbal_invbal_id_seq OWNED BY invbal.invbal_id; publicadminfalse496})00invbal_invbal_id_seqACLREVOKE ALL ON SEQUENCE invbal_invbal_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE invbal_invbal_id_seq FROM admin; GRANT ALL ON SEQUENCE invbal_invbal_id_seq TO admin; GRANT ALL ON SEQUENCE invbal_invbal_id_seq TO xtrole; publicadminfalse496125981526invc_invc_id_seqSEQUENCEzCREATE SEQUENCE invc_invc_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; 'DROP SEQUENCE public.invc_invc_id_seq; publicadminfalse8~)00invc_invc_id_seqACLREVOKE ALL ON SEQUENCE invc_invc_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE invc_invc_id_seq FROM admin; GRANT ALL ON SEQUENCE invc_invc_id_seq TO admin; GRANT ALL ON SEQUENCE invc_invc_id_seq TO xtrole; publicadminfalse497125981528invchead_invchead_id_seqSEQUENCEzCREATE SEQUENCE invchead_invchead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.invchead_invchead_id_seq; publicadminfalse8205)00invchead_invchead_id_seqSEQUENCE OWNED BYGALTER SEQUENCE invchead_invchead_id_seq OWNED BY invchead.invchead_id; publicadminfalse498)00invchead_invchead_id_seqACLREVOKE ALL ON SEQUENCE invchead_invchead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE invchead_invchead_id_seq FROM admin; GRANT ALL ON SEQUENCE invchead_invchead_id_seq TO admin; GRANT ALL ON SEQUENCE invchead_invchead_id_seq TO xtrole; publicadminfalse498125981530 invcheadtaxTABLE1CREATE TABLE invcheadtax ( ) INHERITS (taxhist); DROP TABLE public.invcheadtax; publicadminfalse8281)00 invcheadtaxACLREVOKE ALL ON TABLE invcheadtax FROM PUBLIC; REVOKE ALL ON TABLE invcheadtax FROM admin; GRANT ALL ON TABLE invcheadtax TO admin; GRANT ALL ON TABLE invcheadtax TO xtrole; publicadminfalse499125981536invcitem_invcitem_id_seqSEQUENCEzCREATE SEQUENCE invcitem_invcitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.invcitem_invcitem_id_seq; publicadminfalse8209)00invcitem_invcitem_id_seqSEQUENCE OWNED BYGALTER SEQUENCE invcitem_invcitem_id_seq OWNED BY invcitem.invcitem_id; publicadminfalse500)00invcitem_invcitem_id_seqACLREVOKE ALL ON SEQUENCE invcitem_invcitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE invcitem_invcitem_id_seq FROM admin; GRANT ALL ON SEQUENCE invcitem_invcitem_id_seq TO admin; GRANT ALL ON SEQUENCE invcitem_invcitem_id_seq TO xtrole; publicadminfalse500125981538 invcitemtaxTABLE1CREATE TABLE invcitemtax ( ) INHERITS (taxhist); DROP TABLE public.invcitemtax; publicadminfalse8281)00 invcitemtaxACLREVOKE ALL ON TABLE invcitemtax FROM PUBLIC; REVOKE ALL ON TABLE invcitemtax FROM admin; GRANT ALL ON TABLE invcitemtax TO admin; GRANT ALL ON TABLE invcitemtax TO xtrole; publicadminfalse501125981544invcnt_invcnt_id_seqSEQUENCE~CREATE SEQUENCE invcnt_invcnt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; +DROP SEQUENCE public.invcnt_invcnt_id_seq; publicadminfalse8)00invcnt_invcnt_id_seqACLREVOKE ALL ON SEQUENCE invcnt_invcnt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE invcnt_invcnt_id_seq FROM admin; GRANT ALL ON SEQUENCE invcnt_invcnt_id_seq TO admin; GRANT ALL ON SEQUENCE invcnt_invcnt_id_seq TO xtrole; publicadminfalse502125981546 invdetailTABLECREATE TABLE invdetail ( invdetail_id integer DEFAULT nextval(('"invdetail_invdetail_id_seq"'::text)::regclass) NOT NULL, invdetail_transtype character(2), invdetail_invhist_id integer, invdetail_location_id integer, invdetail_qty numeric(18,6), invdetail_comments text, invdetail_qty_before numeric(18,6), invdetail_qty_after numeric(18,6), invdetail_invcitem_id integer, invdetail_expiration date, invdetail_warrpurc date, invdetail_ls_id integer ); DROP TABLE public.invdetail; publicadminfalse65958)00TABLE invdetailCOMMENTCOMMENT ON TABLE invdetail IS 'Detailed Inventory transaction information for Lot/Serial and Multiple Location Control (MLC) Items'; publicadminfalse503)00 invdetailACLREVOKE ALL ON TABLE invdetail FROM PUBLIC; REVOKE ALL ON TABLE invdetail FROM admin; GRANT ALL ON TABLE invdetail TO admin; GRANT ALL ON TABLE invdetail TO xtrole; publicadminfalse503125981553invdetail_invdetail_id_seqSEQUENCECREATE SEQUENCE invdetail_invdetail_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; 1DROP SEQUENCE public.invdetail_invdetail_id_seq; publicadminfalse8)00invdetail_invdetail_id_seqACLREVOKE ALL ON SEQUENCE invdetail_invdetail_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE invdetail_invdetail_id_seq FROM admin; GRANT ALL ON SEQUENCE invdetail_invdetail_id_seq TO admin; GRANT ALL ON SEQUENCE invdetail_invdetail_id_seq TO xtrole; publicadminfalse504125981555invhistTABLE:CREATE TABLE invhist ( invhist_id integer DEFAULT nextval(('invhist_invhist_id_seq'::text)::regclass) NOT NULL, invhist_itemsite_id integer, invhist_transdate timestamp with time zone DEFAULT ('now'::text)::timestamp(6) with time zone, invhist_transtype character(2), invhist_invqty numeric(18,6), invhist_invuom text, invhist_ordnumber text, invhist_docnumber text, invhist_qoh_before numeric(18,6), invhist_qoh_after numeric(18,6), invhist_unitcost numeric(16,6), invhist_acct_id integer, invhist_xfer_warehous_id integer, invhist_comments text, invhist_posted boolean DEFAULT true, invhist_imported boolean, invhist_hasdetail boolean DEFAULT false, invhist_ordtype text, invhist_analyze boolean DEFAULT true, invhist_user text DEFAULT geteffectivextuser(), invhist_created timestamp with time zone DEFAULT now() NOT NULL, invhist_costmethod character(1) NOT NULL, invhist_value_before numeric(12,2) NOT NULL, invhist_value_after numeric(12,2) NOT NULL, invhist_series integer ); DROP TABLE public.invhist; publicadminfalse65966597659865996600660166028)00 TABLE invhistCOMMENT=COMMENT ON TABLE invhist IS 'Inventory transaction history'; publicadminfalse505)00invhistACLREVOKE ALL ON TABLE invhist FROM PUBLIC; REVOKE ALL ON TABLE invhist FROM admin; GRANT ALL ON TABLE invhist TO admin; GRANT ALL ON TABLE invhist TO xtrole; publicadminfalse505125981568invhist_invhist_id_seqSEQUENCECREATE SEQUENCE invhist_invhist_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.invhist_invhist_id_seq; publicadminfalse8)00invhist_invhist_id_seqACLREVOKE ALL ON SEQUENCE invhist_invhist_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE invhist_invhist_id_seq FROM admin; GRANT ALL ON SEQUENCE invhist_invhist_id_seq TO admin; GRANT ALL ON SEQUENCE invhist_invhist_id_seq TO xtrole; publicadminfalse506125981570 invhistexpcatTABLECREATE TABLE invhistexpcat ( invhistexpcat_id integer NOT NULL, invhistexpcat_invhist_id integer NOT NULL, invhistexpcat_expcat_id integer NOT NULL ); !DROP TABLE public.invhistexpcat; publicadminfalse8)00TABLE invhistexpcatCOMMENTCOMMENT ON TABLE invhistexpcat IS 'Track the relationship between an EX transaction in the invhist table and the corresponding Expense Category.'; publicadminfalse507)00 invhistexpcatACLREVOKE ALL ON TABLE invhistexpcat FROM PUBLIC; REVOKE ALL ON TABLE invhistexpcat FROM admin; GRANT ALL ON TABLE invhistexpcat TO admin; GRANT ALL ON TABLE invhistexpcat TO xtrole; publicadminfalse507125981573"invhistexpcat_invhistexpcat_id_seqSEQUENCECREATE SEQUENCE invhistexpcat_invhistexpcat_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 9DROP SEQUENCE public.invhistexpcat_invhistexpcat_id_seq; publicadminfalse8507)00"invhistexpcat_invhistexpcat_id_seqSEQUENCE OWNED BY[ALTER SEQUENCE invhistexpcat_invhistexpcat_id_seq OWNED BY invhistexpcat.invhistexpcat_id; publicadminfalse508)00"invhistexpcat_invhistexpcat_id_seqACLREVOKE ALL ON SEQUENCE invhistexpcat_invhistexpcat_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE invhistexpcat_invhistexpcat_id_seq FROM admin; GRANT ALL ON SEQUENCE invhistexpcat_invhistexpcat_id_seq TO admin; GRANT ALL ON SEQUENCE invhistexpcat_invhistexpcat_id_seq TO xtrole; publicadminfalse508125987609 invoiceitemVIEWCREATE VIEW invoiceitem AS SELECT invcitem.invcitem_id, invcitem.invcitem_invchead_id, invcitem.invcitem_linenumber, invcitem.invcitem_item_id, invcitem.invcitem_warehous_id, invcitem.invcitem_custpn, invcitem.invcitem_number, invcitem.invcitem_descrip, invcitem.invcitem_ordered, invcitem.invcitem_billed, invcitem.invcitem_custprice, invcitem.invcitem_price, invcitem.invcitem_notes, invcitem.invcitem_salescat_id, invcitem.invcitem_taxtype_id, invcitem.invcitem_qty_uom_id, invcitem.invcitem_qty_invuomratio, invcitem.invcitem_price_uom_id, invcitem.invcitem_price_invuomratio, invcitem.invcitem_coitem_id, invcitem.invcitem_updateinv, invcitem.invcitem_rev_accnt_id, itemsite.itemsite_id, cohead.cohead_number, COALESCE((invcitem.invcitem_billed * invcitem.invcitem_qty_invuomratio), (0)::numeric) AS qty, COALESCE((invcitem.invcitem_price / invcitem.invcitem_price_invuomratio), (0)::numeric) AS unitprice, COALESCE(round(((invcitem.invcitem_billed * invcitem.invcitem_qty_invuomratio) * (invcitem.invcitem_price / invcitem.invcitem_price_invuomratio)), 2), (0)::numeric) AS extprice, currtobase(invchead.invchead_curr_id, COALESCE(round(((invcitem.invcitem_billed * invcitem.invcitem_qty_invuomratio) * (invcitem.invcitem_price / invcitem.invcitem_price_invuomratio)), 2), (0)::numeric), invchead.invchead_invcdate) AS baseextprice, (SELECT COALESCE(sum(invcitemtax.taxhist_tax), (0)::numeric) AS "coalesce" FROM invcitemtax WHERE (invcitemtax.taxhist_parent_id = invcitem.invcitem_id)) AS tax, ((SELECT COALESCE(sum(shipitem.shipitem_value), (itemcost(itemsite.itemsite_id) * invcitem.invcitem_billed), 0.0) AS "coalesce" FROM shipitem WHERE (shipitem.shipitem_invcitem_id = invcitem.invcitem_id)) / CASE WHEN (invcitem.invcitem_billed <> (0)::numeric) THEN (invcitem.invcitem_billed * invcitem.invcitem_qty_invuomratio) ELSE (1)::numeric END) AS unitcost FROM ((((invcitem JOIN invchead ON ((invchead.invchead_id = invcitem.invcitem_invchead_id))) LEFT JOIN coitem ON ((coitem.coitem_id = invcitem.invcitem_coitem_id))) LEFT JOIN cohead ON ((cohead.cohead_id = coitem.coitem_cohead_id))) LEFT JOIN itemsite ON (((itemsite.itemsite_item_id = invcitem.invcitem_item_id) AND (itemsite.itemsite_warehous_id = invcitem.invcitem_warehous_id)))); DROP VIEW public.invoiceitem; publicadminfalse86808)00VIEW invoiceitemCOMMENTYCOMMENT ON VIEW invoiceitem IS 'Single point for invoice item (invcitem) calculations.'; publicadminfalse797)00 invoiceitemACLREVOKE ALL ON TABLE invoiceitem FROM PUBLIC; REVOKE ALL ON TABLE invoiceitem FROM admin; GRANT ALL ON TABLE invoiceitem TO admin; GRANT ALL ON TABLE invoiceitem TO xtrole; publicadminfalse797125981580ipsass_ipsass_id_seqSEQUENCEvCREATE SEQUENCE ipsass_ipsass_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.ipsass_ipsass_id_seq; publicadminfalse8268)00ipsass_ipsass_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE ipsass_ipsass_id_seq OWNED BY ipsass.ipsass_id; publicadminfalse509)00ipsass_ipsass_id_seqACLREVOKE ALL ON SEQUENCE ipsass_ipsass_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ipsass_ipsass_id_seq FROM admin; GRANT ALL ON SEQUENCE ipsass_ipsass_id_seq TO admin; GRANT ALL ON SEQUENCE ipsass_ipsass_id_seq TO xtrole; publicadminfalse509125981582ipsctyp_ipsctyp_id_seqSEQUENCExCREATE SEQUENCE ipsctyp_ipsctyp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.ipsctyp_ipsctyp_id_seq; publicadminfalse8)00ipsctyp_ipsctyp_id_seqACLREVOKE ALL ON SEQUENCE ipsctyp_ipsctyp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ipsctyp_ipsctyp_id_seq FROM admin; GRANT ALL ON SEQUENCE ipsctyp_ipsctyp_id_seq TO admin; GRANT ALL ON SEQUENCE ipsctyp_ipsctyp_id_seq TO xtrole; publicadminfalse510125981584ipscust_ipscust_id_seqSEQUENCExCREATE SEQUENCE ipscust_ipscust_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.ipscust_ipscust_id_seq; publicadminfalse8)00ipscust_ipscust_id_seqACLREVOKE ALL ON SEQUENCE ipscust_ipscust_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ipscust_ipscust_id_seq FROM admin; GRANT ALL ON SEQUENCE ipscust_ipscust_id_seq TO admin; GRANT ALL ON SEQUENCE ipscust_ipscust_id_seq TO xtrole; publicadminfalse511125981586ipsfreight_ipsfreight_id_seqSEQUENCE~CREATE SEQUENCE ipsfreight_ipsfreight_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 3DROP SEQUENCE public.ipsfreight_ipsfreight_id_seq; publicadminfalse8246)00ipsfreight_ipsfreight_id_seqSEQUENCE OWNED BYOALTER SEQUENCE ipsfreight_ipsfreight_id_seq OWNED BY ipsfreight.ipsfreight_id; publicadminfalse512)00ipsfreight_ipsfreight_id_seqACLREVOKE ALL ON SEQUENCE ipsfreight_ipsfreight_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ipsfreight_ipsfreight_id_seq FROM admin; GRANT ALL ON SEQUENCE ipsfreight_ipsfreight_id_seq TO admin; GRANT ALL ON SEQUENCE ipsfreight_ipsfreight_id_seq TO xtrole; publicadminfalse512125981588ipshead_ipshead_id_seqSEQUENCExCREATE SEQUENCE ipshead_ipshead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.ipshead_ipshead_id_seq; publicadminfalse8)00ipshead_ipshead_id_seqACLREVOKE ALL ON SEQUENCE ipshead_ipshead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ipshead_ipshead_id_seq FROM admin; GRANT ALL ON SEQUENCE ipshead_ipshead_id_seq TO admin; GRANT ALL ON SEQUENCE ipshead_ipshead_id_seq TO xtrole; publicadminfalse513125981590ipsitem_ipsitem_id_seqSEQUENCExCREATE SEQUENCE ipsitem_ipsitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.ipsitem_ipsitem_id_seq; publicadminfalse8)00ipsitem_ipsitem_id_seqACLREVOKE ALL ON SEQUENCE ipsitem_ipsitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ipsitem_ipsitem_id_seq FROM admin; GRANT ALL ON SEQUENCE ipsitem_ipsitem_id_seq TO admin; GRANT ALL ON SEQUENCE ipsitem_ipsitem_id_seq TO xtrole; publicadminfalse514125981592ipsitemchar_ipsitemchar_id_seqSEQUENCECREATE SEQUENCE ipsitemchar_ipsitemchar_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 5DROP SEQUENCE public.ipsitemchar_ipsitemchar_id_seq; publicadminfalse8270)00ipsitemchar_ipsitemchar_id_seqSEQUENCE OWNED BYSALTER SEQUENCE ipsitemchar_ipsitemchar_id_seq OWNED BY ipsitemchar.ipsitemchar_id; publicadminfalse515)00ipsitemchar_ipsitemchar_id_seqACLREVOKE ALL ON SEQUENCE ipsitemchar_ipsitemchar_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ipsitemchar_ipsitemchar_id_seq FROM admin; GRANT ALL ON SEQUENCE ipsitemchar_ipsitemchar_id_seq TO admin; GRANT ALL ON SEQUENCE ipsitemchar_ipsitemchar_id_seq TO xtrole; publicadminfalse515125987614ipspriceVIEWCREATE VIEW ipsprice AS SELECT ipsiteminfo.ipsitem_id AS ipsprice_id, 'I'::text AS ipsprice_source, ipsiteminfo.ipsitem_ipshead_id AS ipsprice_ipshead_id, ipsiteminfo.ipsitem_item_id AS ipsprice_item_id, itemuomtouom(ipsiteminfo.ipsitem_item_id, ipsiteminfo.ipsitem_qty_uom_id, NULL::integer, ipsiteminfo.ipsitem_qtybreak) AS ipsprice_qtybreak, CASE WHEN (ipsiteminfo.ipsitem_type = 'N'::bpchar) THEN ((ipsiteminfo.ipsitem_price * itemuomtouomratio(ipsiteminfo.ipsitem_item_id, NULL::integer, ipsiteminfo.ipsitem_price_uom_id)) * iteminvpricerat(ipsiteminfo.ipsitem_item_id)) WHEN (ipsiteminfo.ipsitem_type = 'D'::bpchar) THEN ((item.item_listprice - (item.item_listprice * ipsiteminfo.ipsitem_discntprcnt)) - ipsiteminfo.ipsitem_fixedamtdiscount) WHEN ((ipsiteminfo.ipsitem_type = 'M'::bpchar) AND fetchmetricbool('Long30Markups'::text)) THEN ((stdcost(item.item_id) / (1.0 - ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) WHEN (ipsiteminfo.ipsitem_type = 'M'::bpchar) THEN ((item.item_listcost + (item.item_listcost * ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) ELSE NULL::numeric END AS ipsprice_price, ipsiteminfo.ipsitem_qtybreak AS ipsprice_uomqtybreak, ipsiteminfo.ipsitem_qty_uom_id AS ipsprice_uomqtybreak_uom_id, CASE WHEN (ipsiteminfo.ipsitem_type = 'N'::bpchar) THEN ipsiteminfo.ipsitem_price WHEN (ipsiteminfo.ipsitem_type = 'D'::bpchar) THEN ((item.item_listprice - (item.item_listprice * ipsiteminfo.ipsitem_discntprcnt)) - ipsiteminfo.ipsitem_fixedamtdiscount) WHEN ((ipsiteminfo.ipsitem_type = 'M'::bpchar) AND fetchmetricbool('Long30Markups'::text)) THEN ((stdcost(item.item_id) / (1.0 - ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) WHEN (ipsiteminfo.ipsitem_type = 'M'::bpchar) THEN ((item.item_listcost + (item.item_listcost * ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) ELSE NULL::numeric END AS ipsprice_uomprice, ipsiteminfo.ipsitem_price_uom_id AS ipsprice_uomprice_uom_id, ipsiteminfo.ipsitem_discntprcnt AS ipsprice_discountpercent, ipsiteminfo.ipsitem_fixedamtdiscount AS ipsprice_discountfixed, ipsiteminfo.ipsitem_type AS ipsprice_type FROM (ipsiteminfo JOIN item ON ((item.item_id = ipsiteminfo.ipsitem_item_id))) UNION SELECT ipsiteminfo.ipsitem_id AS ipsprice_id, 'P'::text AS ipsprice_source, ipsiteminfo.ipsitem_ipshead_id AS ipsprice_ipshead_id, item.item_id AS ipsprice_item_id, ipsiteminfo.ipsitem_qtybreak AS ipsprice_qtybreak, CASE WHEN (ipsiteminfo.ipsitem_type = 'D'::bpchar) THEN ((item.item_listprice - (item.item_listprice * ipsiteminfo.ipsitem_discntprcnt)) - ipsiteminfo.ipsitem_fixedamtdiscount) WHEN ((ipsiteminfo.ipsitem_type = 'M'::bpchar) AND fetchmetricbool('Long30Markups'::text)) THEN ((stdcost(item.item_id) / (1.0 - ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) WHEN (ipsiteminfo.ipsitem_type = 'M'::bpchar) THEN ((item.item_listcost + (item.item_listcost * ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) ELSE NULL::numeric END AS ipsprice_price, ipsiteminfo.ipsitem_qtybreak AS ipsprice_uomqtybreak, item.item_inv_uom_id AS ipsprice_uomqtybreak_uom_id, CASE WHEN (ipsiteminfo.ipsitem_type = 'D'::bpchar) THEN ((item.item_listprice - (item.item_listprice * ipsiteminfo.ipsitem_discntprcnt)) - ipsiteminfo.ipsitem_fixedamtdiscount) WHEN ((ipsiteminfo.ipsitem_type = 'M'::bpchar) AND fetchmetricbool('Long30Markups'::text)) THEN ((stdcost(item.item_id) / (1.0 - ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) WHEN (ipsiteminfo.ipsitem_type = 'M'::bpchar) THEN ((item.item_listcost + (item.item_listcost * ipsiteminfo.ipsitem_discntprcnt)) + ipsiteminfo.ipsitem_fixedamtdiscount) ELSE NULL::numeric END AS ipsprice_uomprice, item.item_price_uom_id AS ipsprice_uomprice_uom_id, ipsiteminfo.ipsitem_discntprcnt AS ipsprice_discountpercent, ipsiteminfo.ipsitem_fixedamtdiscount AS ipsprice_discountfixed, ipsiteminfo.ipsitem_type AS ipsprice_type FROM (ipsiteminfo JOIN item ON ((ipsiteminfo.ipsitem_prodcat_id = item.item_prodcat_id))); DROP VIEW public.ipsprice; publicadminfalse86818)00ipspriceACLREVOKE ALL ON TABLE ipsprice FROM PUBLIC; REVOKE ALL ON TABLE ipsprice FROM admin; GRANT ALL ON TABLE ipsprice TO admin; GRANT ALL ON TABLE ipsprice TO xtrole; publicadminfalse798125981599ipsprodcat_bakTABLEDCREATE TABLE ipsprodcat_bak ( ipsprodcat_id integer NOT NULL, ipsprodcat_ipshead_id integer NOT NULL, ipsprodcat_prodcat_id integer NOT NULL, ipsprodcat_qtybreak numeric(18,6) NOT NULL, ipsprodcat_discntprcnt numeric(10,6) NOT NULL, ipsprodcat_fixedamtdiscount numeric(16,4) DEFAULT 0.00 NOT NULL ); "DROP TABLE public.ipsprodcat_bak; publicadminfalse66058)00TABLE ipsprodcat_bakCOMMENTUCOMMENT ON TABLE ipsprodcat_bak IS 'Pricing Schedule Product Category information.'; publicadminfalse516)00ipsprodcat_bakACLREVOKE ALL ON TABLE ipsprodcat_bak FROM PUBLIC; REVOKE ALL ON TABLE ipsprodcat_bak FROM admin; GRANT ALL ON TABLE ipsprodcat_bak TO admin; GRANT ALL ON TABLE ipsprodcat_bak TO xtrole; publicadminfalse516125981603ipsprodcat_ipsprodcat_id_seqSEQUENCE~CREATE SEQUENCE ipsprodcat_ipsprodcat_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 3DROP SEQUENCE public.ipsprodcat_ipsprodcat_id_seq; publicadminfalse8516)00ipsprodcat_ipsprodcat_id_seqSEQUENCE OWNED BYSALTER SEQUENCE ipsprodcat_ipsprodcat_id_seq OWNED BY ipsprodcat_bak.ipsprodcat_id; publicadminfalse517)00ipsprodcat_ipsprodcat_id_seqACLREVOKE ALL ON SEQUENCE ipsprodcat_ipsprodcat_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ipsprodcat_ipsprodcat_id_seq FROM admin; GRANT ALL ON SEQUENCE ipsprodcat_ipsprodcat_id_seq TO admin; GRANT ALL ON SEQUENCE ipsprodcat_ipsprodcat_id_seq TO xtrole; publicadminfalse517125981605item_item_id_seqSEQUENCEzCREATE SEQUENCE item_item_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; 'DROP SEQUENCE public.item_item_id_seq; publicadminfalse8)00item_item_id_seqACLREVOKE ALL ON SEQUENCE item_item_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE item_item_id_seq FROM admin; GRANT ALL ON SEQUENCE item_item_id_seq TO admin; GRANT ALL ON SEQUENCE item_item_id_seq TO xtrole; publicadminfalse518125981607itemalias_itemalias_id_seqSEQUENCECREATE SEQUENCE itemalias_itemalias_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; 1DROP SEQUENCE public.itemalias_itemalias_id_seq; publicadminfalse8)00itemalias_itemalias_id_seqACLREVOKE ALL ON SEQUENCE itemalias_itemalias_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemalias_itemalias_id_seq FROM admin; GRANT ALL ON SEQUENCE itemalias_itemalias_id_seq TO admin; GRANT ALL ON SEQUENCE itemalias_itemalias_id_seq TO xtrole; publicadminfalse519125981609itematr_itematr_id_seqSEQUENCECREATE SEQUENCE itematr_itematr_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.itematr_itematr_id_seq; publicadminfalse8)00itematr_itematr_id_seqACLREVOKE ALL ON SEQUENCE itematr_itematr_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itematr_itematr_id_seq FROM admin; GRANT ALL ON SEQUENCE itematr_itematr_id_seq TO admin; GRANT ALL ON SEQUENCE itematr_itematr_id_seq TO xtrole; publicadminfalse520 125981611itemcost_itemcost_id_seqSEQUENCECREATE SEQUENCE itemcost_itemcost_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; /DROP SEQUENCE public.itemcost_itemcost_id_seq; publicadminfalse8)00itemcost_itemcost_id_seqACLREVOKE ALL ON SEQUENCE itemcost_itemcost_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemcost_itemcost_id_seq FROM admin; GRANT ALL ON SEQUENCE itemcost_itemcost_id_seq TO admin; GRANT ALL ON SEQUENCE itemcost_itemcost_id_seq TO xtrole; publicadminfalse521 125981613itemfrez_itemfrez_seqSEQUENCECREATE SEQUENCE itemfrez_itemfrez_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; ,DROP SEQUENCE public.itemfrez_itemfrez_seq; publicadminfalse8)00itemfrez_itemfrez_seqACLREVOKE ALL ON SEQUENCE itemfrez_itemfrez_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemfrez_itemfrez_seq FROM admin; GRANT ALL ON SEQUENCE itemfrez_itemfrez_seq TO admin; GRANT ALL ON SEQUENCE itemfrez_itemfrez_seq TO xtrole; publicadminfalse522 125981615itemgrpTABLE4CREATE TABLE itemgrp ( itemgrp_id integer DEFAULT nextval(('"itemgrp_itemgrp_id_seq"'::text)::regclass) NOT NULL, itemgrp_name text NOT NULL, itemgrp_descrip text, itemgrp_catalog boolean DEFAULT false NOT NULL, CONSTRAINT itemgrp_itemgrp_name_check CHECK ((itemgrp_name <> ''::text)) ); DROP TABLE public.itemgrp; publicadminfalse6606660766088)00 TABLE itemgrpCOMMENT6COMMENT ON TABLE itemgrp IS 'Item Group information'; publicadminfalse523)00itemgrpACLREVOKE ALL ON TABLE itemgrp FROM PUBLIC; REVOKE ALL ON TABLE itemgrp FROM admin; GRANT ALL ON TABLE itemgrp TO admin; GRANT ALL ON TABLE itemgrp TO xtrole; publicadminfalse523 125981624itemgrp_itemgrp_id_seqSEQUENCECREATE SEQUENCE itemgrp_itemgrp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.itemgrp_itemgrp_id_seq; publicadminfalse8)00itemgrp_itemgrp_id_seqACLREVOKE ALL ON SEQUENCE itemgrp_itemgrp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemgrp_itemgrp_id_seq FROM admin; GRANT ALL ON SEQUENCE itemgrp_itemgrp_id_seq TO admin; GRANT ALL ON SEQUENCE itemgrp_itemgrp_id_seq TO xtrole; publicadminfalse524 125981626 itemgrpitemTABLECREATE TABLE itemgrpitem ( itemgrpitem_id integer DEFAULT nextval(('"itemgrpitem_itemgrpitem_id_seq"'::text)::regclass) NOT NULL, itemgrpitem_itemgrp_id integer, itemgrpitem_item_id integer, itemgrpitem_item_type character(1) DEFAULT 'I'::bpchar NOT NULL, CONSTRAINT itemgrpitem_valid_item_type CHECK ((itemgrpitem_item_type = ANY (ARRAY['I'::bpchar, 'G'::bpchar]))) ); DROP TABLE public.itemgrpitem; publicadminfalse6609661066118)00TABLE itemgrpitemCOMMENT?COMMENT ON TABLE itemgrpitem IS 'Item Group Item information'; publicadminfalse525)00 itemgrpitemACLREVOKE ALL ON TABLE itemgrpitem FROM PUBLIC; REVOKE ALL ON TABLE itemgrpitem FROM admin; GRANT ALL ON TABLE itemgrpitem TO admin; GRANT ALL ON TABLE itemgrpitem TO xtrole; publicadminfalse525125981632itemgrpitem_itemgrpitem_id_seqSEQUENCECREATE SEQUENCE itemgrpitem_itemgrpitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; 5DROP SEQUENCE public.itemgrpitem_itemgrpitem_id_seq; publicadminfalse8)00itemgrpitem_itemgrpitem_id_seqACLREVOKE ALL ON SEQUENCE itemgrpitem_itemgrpitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemgrpitem_itemgrpitem_id_seq FROM admin; GRANT ALL ON SEQUENCE itemgrpitem_itemgrpitem_id_seq TO admin; GRANT ALL ON SEQUENCE itemgrpitem_itemgrpitem_id_seq TO xtrole; publicadminfalse526125981634 itemimageVIEWCREATE VIEW itemimage AS SELECT imageass.imageass_id AS itemimage_id, imageass.imageass_source_id AS itemimage_item_id, imageass.imageass_image_id AS itemimage_image_id, imageass.imageass_purpose AS itemimage_purpose FROM imageass WHERE (imageass.imageass_source = 'I'::text); DROP VIEW public.itemimage; publicadminfalse86438)00VIEW itemimageCOMMENTCOMMENT ON VIEW itemimage IS 'Itemimage view for legacy support. Use of itemimage is deprecated. Use imageass table for future development'; publicadminfalse527)00 itemimageACLREVOKE ALL ON TABLE itemimage FROM PUBLIC; REVOKE ALL ON TABLE itemimage FROM admin; GRANT ALL ON TABLE itemimage TO admin; GRANT ALL ON TABLE itemimage TO xtrole; publicadminfalse527125981638itemimage_itemimage_id_seqSEQUENCE|CREATE SEQUENCE itemimage_itemimage_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 1DROP SEQUENCE public.itemimage_itemimage_id_seq; publicadminfalse8)00itemimage_itemimage_id_seqACLREVOKE ALL ON SEQUENCE itemimage_itemimage_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemimage_itemimage_id_seq FROM admin; GRANT ALL ON SEQUENCE itemimage_itemimage_id_seq TO admin; GRANT ALL ON SEQUENCE itemimage_itemimage_id_seq TO xtrole; publicadminfalse528125981640itemlocTABLEpCREATE TABLE itemloc ( itemloc_id integer DEFAULT nextval(('"itemloc_itemloc_id_seq"'::text)::regclass) NOT NULL, itemloc_itemsite_id integer NOT NULL, itemloc_location_id integer NOT NULL, itemloc_qty numeric(18,6) NOT NULL, itemloc_expiration date NOT NULL, itemloc_consolflag boolean, itemloc_ls_id integer, itemloc_warrpurc date ); DROP TABLE public.itemloc; publicadminfalse66128)00 TABLE itemlocCOMMENTvCOMMENT ON TABLE itemloc IS 'Detailed Location information for Lot/Serial and Multiple Location Control (MLC) Items'; publicadminfalse529)00itemlocACLREVOKE ALL ON TABLE itemloc FROM PUBLIC; REVOKE ALL ON TABLE itemloc FROM admin; GRANT ALL ON TABLE itemloc TO admin; GRANT ALL ON TABLE itemloc TO xtrole; publicadminfalse529125981644itemloc_itemloc_id_seqSEQUENCExCREATE SEQUENCE itemloc_itemloc_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.itemloc_itemloc_id_seq; publicadminfalse8)00itemloc_itemloc_id_seqACLREVOKE ALL ON SEQUENCE itemloc_itemloc_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemloc_itemloc_id_seq FROM admin; GRANT ALL ON SEQUENCE itemloc_itemloc_id_seq TO admin; GRANT ALL ON SEQUENCE itemloc_itemloc_id_seq TO xtrole; publicadminfalse530125981646itemloc_series_seqSEQUENCE|CREATE SEQUENCE itemloc_series_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; )DROP SEQUENCE public.itemloc_series_seq; publicadminfalse8)00itemloc_series_seqACLREVOKE ALL ON SEQUENCE itemloc_series_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemloc_series_seq FROM admin; GRANT ALL ON SEQUENCE itemloc_series_seq TO admin; GRANT ALL ON SEQUENCE itemloc_series_seq TO xtrole; publicadminfalse531125981648 itemlocdistTABLECREATE TABLE itemlocdist ( itemlocdist_id integer DEFAULT nextval(('"itemlocdist_itemlocdist_id_seq"'::text)::regclass) NOT NULL, itemlocdist_itemlocdist_id integer, itemlocdist_source_type character(1), itemlocdist_source_id integer, itemlocdist_qty numeric(18,6), itemlocdist_series integer, itemlocdist_invhist_id integer, itemlocdist_itemsite_id integer, itemlocdist_reqlotserial boolean DEFAULT false, itemlocdist_flush boolean DEFAULT false, itemlocdist_expiration date, itemlocdist_distlotserial boolean, itemlocdist_warranty date, itemlocdist_ls_id integer, itemlocdist_order_type text, itemlocdist_order_id integer ); DROP TABLE public.itemlocdist; publicadminfalse6613661466158)00TABLE itemlocdistCOMMENTCOMMENT ON TABLE itemlocdist IS 'Temporary table for storing information about Inventory distributions involving Lot/Serial and Multiple Location Control (MLC) Items'; publicadminfalse532)00 itemlocdistACLREVOKE ALL ON TABLE itemlocdist FROM PUBLIC; REVOKE ALL ON TABLE itemlocdist FROM admin; GRANT ALL ON TABLE itemlocdist TO admin; GRANT ALL ON TABLE itemlocdist TO xtrole; publicadminfalse532125981657itemlocdist_itemlocdist_id_seqSEQUENCECREATE SEQUENCE itemlocdist_itemlocdist_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 5DROP SEQUENCE public.itemlocdist_itemlocdist_id_seq; publicadminfalse8)00itemlocdist_itemlocdist_id_seqACLREVOKE ALL ON SEQUENCE itemlocdist_itemlocdist_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemlocdist_itemlocdist_id_seq FROM admin; GRANT ALL ON SEQUENCE itemlocdist_itemlocdist_id_seq TO admin; GRANT ALL ON SEQUENCE itemlocdist_itemlocdist_id_seq TO xtrole; publicadminfalse533125981659 itemlocpostTABLECREATE TABLE itemlocpost ( itemlocpost_id integer NOT NULL, itemlocpost_itemlocseries integer, itemlocpost_glseq integer ); DROP TABLE public.itemlocpost; publicadminfalse8)00TABLE itemlocpostCOMMENTCOMMENT ON TABLE itemlocpost IS 'Temporary table for storing information about Inventory distribution G/L postings involving Lot/Serial and Multiple Location Control (MLC) Items'; publicadminfalse534)00 itemlocpostACLREVOKE ALL ON TABLE itemlocpost FROM PUBLIC; REVOKE ALL ON TABLE itemlocpost FROM admin; GRANT ALL ON TABLE itemlocpost TO admin; GRANT ALL ON TABLE itemlocpost TO xtrole; publicadminfalse534125981662itemlocpost_itemlocpost_id_seqSEQUENCECREATE SEQUENCE itemlocpost_itemlocpost_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 5DROP SEQUENCE public.itemlocpost_itemlocpost_id_seq; publicadminfalse8534)00itemlocpost_itemlocpost_id_seqSEQUENCE OWNED BYSALTER SEQUENCE itemlocpost_itemlocpost_id_seq OWNED BY itemlocpost.itemlocpost_id; publicadminfalse535)00itemlocpost_itemlocpost_id_seqACLREVOKE ALL ON SEQUENCE itemlocpost_itemlocpost_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemlocpost_itemlocpost_id_seq FROM admin; GRANT ALL ON SEQUENCE itemlocpost_itemlocpost_id_seq TO admin; GRANT ALL ON SEQUENCE itemlocpost_itemlocpost_id_seq TO xtrole; publicadminfalse535125981664itemopn_itemopn_id_seqSEQUENCECREATE SEQUENCE itemopn_itemopn_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.itemopn_itemopn_id_seq; publicadminfalse8)00itemopn_itemopn_id_seqACLREVOKE ALL ON SEQUENCE itemopn_itemopn_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemopn_itemopn_id_seq FROM admin; GRANT ALL ON SEQUENCE itemopn_itemopn_id_seq TO admin; GRANT ALL ON SEQUENCE itemopn_itemopn_id_seq TO xtrole; publicadminfalse536125981666itemsite_itemsite_id_seqSEQUENCECREATE SEQUENCE itemsite_itemsite_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; /DROP SEQUENCE public.itemsite_itemsite_id_seq; publicadminfalse8)00itemsite_itemsite_id_seqACLREVOKE ALL ON SEQUENCE itemsite_itemsite_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemsite_itemsite_id_seq FROM admin; GRANT ALL ON SEQUENCE itemsite_itemsite_id_seq TO admin; GRANT ALL ON SEQUENCE itemsite_itemsite_id_seq TO xtrole; publicadminfalse537125981668itemsrc_itemsrc_id_seqSEQUENCECREATE SEQUENCE itemsrc_itemsrc_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.itemsrc_itemsrc_id_seq; publicadminfalse8)00itemsrc_itemsrc_id_seqACLREVOKE ALL ON SEQUENCE itemsrc_itemsrc_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemsrc_itemsrc_id_seq FROM admin; GRANT ALL ON SEQUENCE itemsrc_itemsrc_id_seq TO admin; GRANT ALL ON SEQUENCE itemsrc_itemsrc_id_seq TO xtrole; publicadminfalse538125981670itemsrcp_itemsrcp_id_seqSEQUENCECREATE SEQUENCE itemsrcp_itemsrcp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; /DROP SEQUENCE public.itemsrcp_itemsrcp_id_seq; publicadminfalse8)00itemsrcp_itemsrcp_id_seqACLREVOKE ALL ON SEQUENCE itemsrcp_itemsrcp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemsrcp_itemsrcp_id_seq FROM admin; GRANT ALL ON SEQUENCE itemsrcp_itemsrcp_id_seq TO admin; GRANT ALL ON SEQUENCE itemsrcp_itemsrcp_id_seq TO xtrole; publicadminfalse539125981672itemsub_itemsub_id_seqSEQUENCECREATE SEQUENCE itemsub_itemsub_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.itemsub_itemsub_id_seq; publicadminfalse8)00itemsub_itemsub_id_seqACLREVOKE ALL ON SEQUENCE itemsub_itemsub_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemsub_itemsub_id_seq FROM admin; GRANT ALL ON SEQUENCE itemsub_itemsub_id_seq TO admin; GRANT ALL ON SEQUENCE itemsub_itemsub_id_seq TO xtrole; publicadminfalse540125981674itemtax_itemtax_id_seqSEQUENCExCREATE SEQUENCE itemtax_itemtax_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.itemtax_itemtax_id_seq; publicadminfalse8263)00itemtax_itemtax_id_seqSEQUENCE OWNED BYCALTER SEQUENCE itemtax_itemtax_id_seq OWNED BY itemtax.itemtax_id; publicadminfalse541)00itemtax_itemtax_id_seqACLREVOKE ALL ON SEQUENCE itemtax_itemtax_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemtax_itemtax_id_seq FROM admin; GRANT ALL ON SEQUENCE itemtax_itemtax_id_seq TO admin; GRANT ALL ON SEQUENCE itemtax_itemtax_id_seq TO xtrole; publicadminfalse541125981676 itemtransTABLECREATE TABLE itemtrans ( itemtrans_id integer NOT NULL, itemtrans_source_item_id integer, itemtrans_target_item_id integer ); DROP TABLE public.itemtrans; publicadminfalse8)00TABLE itemtransCOMMENTACOMMENT ON TABLE itemtrans IS 'Item Transformation information'; publicadminfalse542)00 itemtransACLREVOKE ALL ON TABLE itemtrans FROM PUBLIC; REVOKE ALL ON TABLE itemtrans FROM admin; GRANT ALL ON TABLE itemtrans TO admin; GRANT ALL ON TABLE itemtrans TO xtrole; publicadminfalse542125981679itemtrans_itemtrans_id_seqSEQUENCE|CREATE SEQUENCE itemtrans_itemtrans_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 1DROP SEQUENCE public.itemtrans_itemtrans_id_seq; publicadminfalse8542)00itemtrans_itemtrans_id_seqSEQUENCE OWNED BYKALTER SEQUENCE itemtrans_itemtrans_id_seq OWNED BY itemtrans.itemtrans_id; publicadminfalse543)00itemtrans_itemtrans_id_seqACLREVOKE ALL ON SEQUENCE itemtrans_itemtrans_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemtrans_itemtrans_id_seq FROM admin; GRANT ALL ON SEQUENCE itemtrans_itemtrans_id_seq TO admin; GRANT ALL ON SEQUENCE itemtrans_itemtrans_id_seq TO xtrole; publicadminfalse543 125981681itemuomTABLECREATE TABLE itemuom ( itemuom_id integer NOT NULL, itemuom_itemuomconv_id integer NOT NULL, itemuom_uomtype_id integer NOT NULL ); DROP TABLE public.itemuom; publicadminfalse8)00 TABLE itemuomCOMMENTNCOMMENT ON TABLE itemuom IS 'A UOM type relation for a specific conversion.'; publicadminfalse544)00itemuomACLREVOKE ALL ON TABLE itemuom FROM PUBLIC; REVOKE ALL ON TABLE itemuom FROM admin; GRANT ALL ON TABLE itemuom TO admin; GRANT ALL ON TABLE itemuom TO xtrole; publicadminfalse544!125981684itemuom_itemuom_id_seqSEQUENCExCREATE SEQUENCE itemuom_itemuom_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.itemuom_itemuom_id_seq; publicadminfalse8544)00itemuom_itemuom_id_seqSEQUENCE OWNED BYCALTER SEQUENCE itemuom_itemuom_id_seq OWNED BY itemuom.itemuom_id; publicadminfalse545)00itemuom_itemuom_id_seqACLREVOKE ALL ON SEQUENCE itemuom_itemuom_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemuom_itemuom_id_seq FROM admin; GRANT ALL ON SEQUENCE itemuom_itemuom_id_seq TO admin; GRANT ALL ON SEQUENCE itemuom_itemuom_id_seq TO xtrole; publicadminfalse545"125981686itemuomconv_itemuomconv_id_seqSEQUENCECREATE SEQUENCE itemuomconv_itemuomconv_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 5DROP SEQUENCE public.itemuomconv_itemuomconv_id_seq; publicadminfalse8264)00itemuomconv_itemuomconv_id_seqSEQUENCE OWNED BYSALTER SEQUENCE itemuomconv_itemuomconv_id_seq OWNED BY itemuomconv.itemuomconv_id; publicadminfalse546)00itemuomconv_itemuomconv_id_seqACLREVOKE ALL ON SEQUENCE itemuomconv_itemuomconv_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE itemuomconv_itemuomconv_id_seq FROM admin; GRANT ALL ON SEQUENCE itemuomconv_itemuomconv_id_seq TO admin; GRANT ALL ON SEQUENCE itemuomconv_itemuomconv_id_seq TO xtrole; publicadminfalse546#125981688journal_number_seqSEQUENCEtCREATE SEQUENCE journal_number_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; )DROP SEQUENCE public.journal_number_seq; publicadminfalse8)00journal_number_seqACLREVOKE ALL ON SEQUENCE journal_number_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE journal_number_seq FROM admin; GRANT ALL ON SEQUENCE journal_number_seq TO admin; GRANT ALL ON SEQUENCE journal_number_seq TO xtrole; publicadminfalse547$125981690jrnluseTABLECREATE TABLE jrnluse ( jrnluse_id integer DEFAULT nextval(('"jrnluse_jrnluse_id_seq"'::text)::regclass) NOT NULL, jrnluse_date timestamp without time zone, jrnluse_number integer, jrnluse_use text ); DROP TABLE public.jrnluse; publicadminfalse66198)00 TABLE jrnluseCOMMENTACOMMENT ON TABLE jrnluse IS 'Journal entry and use information'; publicadminfalse548)00jrnluseACLREVOKE ALL ON TABLE jrnluse FROM PUBLIC; REVOKE ALL ON TABLE jrnluse FROM admin; GRANT ALL ON TABLE jrnluse TO admin; GRANT ALL ON TABLE jrnluse TO xtrole; publicadminfalse548%125981697jrnluse_jrnluse_id_seqSEQUENCExCREATE SEQUENCE jrnluse_jrnluse_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.jrnluse_jrnluse_id_seq; publicadminfalse8)00jrnluse_jrnluse_id_seqACLREVOKE ALL ON SEQUENCE jrnluse_jrnluse_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE jrnluse_jrnluse_id_seq FROM admin; GRANT ALL ON SEQUENCE jrnluse_jrnluse_id_seq TO admin; GRANT ALL ON SEQUENCE jrnluse_jrnluse_id_seq TO xtrole; publicadminfalse549&125981699labeldefTABLECREATE TABLE labeldef ( labeldef_id integer NOT NULL, labeldef_name text NOT NULL, labeldef_papersize text NOT NULL, labeldef_columns integer NOT NULL, labeldef_rows integer NOT NULL, labeldef_width integer NOT NULL, labeldef_height integer NOT NULL, labeldef_start_offset_x integer NOT NULL, labeldef_start_offset_y integer NOT NULL, labeldef_horizontal_gap integer NOT NULL, labeldef_vertical_gap integer NOT NULL ); DROP TABLE public.labeldef; publicadminfalse8)00labeldefACLREVOKE ALL ON TABLE labeldef FROM PUBLIC; REVOKE ALL ON TABLE labeldef FROM admin; GRANT ALL ON TABLE labeldef TO admin; GRANT ALL ON TABLE labeldef TO xtrole; publicadminfalse550'125981705labeldef_labeldef_id_seqSEQUENCEzCREATE SEQUENCE labeldef_labeldef_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.labeldef_labeldef_id_seq; publicadminfalse8550)00labeldef_labeldef_id_seqSEQUENCE OWNED BYGALTER SEQUENCE labeldef_labeldef_id_seq OWNED BY labeldef.labeldef_id; publicadminfalse551)00labeldef_labeldef_id_seqACLREVOKE ALL ON SEQUENCE labeldef_labeldef_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE labeldef_labeldef_id_seq FROM admin; GRANT ALL ON SEQUENCE labeldef_labeldef_id_seq TO admin; GRANT ALL ON SEQUENCE labeldef_labeldef_id_seq TO xtrole; publicadminfalse551(125981707 labelformTABLEVCREATE TABLE labelform ( labelform_id integer DEFAULT nextval(('"labelform_labelform_id_seq"'::text)::regclass) NOT NULL, labelform_name text NOT NULL, labelform_report_id integer, labelform_perpage integer, labelform_report_name text, CONSTRAINT labelform_labelform_name_check CHECK ((labelform_name <> ''::text)) ); DROP TABLE public.labelform; publicadminfalse662166228)00TABLE labelformCOMMENT8COMMENT ON TABLE labelform IS 'Label Form information'; publicadminfalse552)00$COLUMN labelform.labelform_report_idCOMMENTkCOMMENT ON COLUMN labelform.labelform_report_id IS 'Obsolete -- reference labelform_report_name instead.'; publicadminfalse552)00 labelformACLREVOKE ALL ON TABLE labelform FROM PUBLIC; REVOKE ALL ON TABLE labelform FROM admin; GRANT ALL ON TABLE labelform TO admin; GRANT ALL ON TABLE labelform TO xtrole; publicadminfalse552)125981715labelform_labelform_id_seqSEQUENCE|CREATE SEQUENCE labelform_labelform_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 1DROP SEQUENCE public.labelform_labelform_id_seq; publicadminfalse8)00labelform_labelform_id_seqACLREVOKE ALL ON SEQUENCE labelform_labelform_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE labelform_labelform_id_seq FROM admin; GRANT ALL ON SEQUENCE labelform_labelform_id_seq TO admin; GRANT ALL ON SEQUENCE labelform_labelform_id_seq TO xtrole; publicadminfalse553*125981717langTABLECREATE TABLE lang ( lang_id integer NOT NULL, lang_qt_number integer, lang_abbr3 text, lang_abbr2 text, lang_name text NOT NULL ); DROP TABLE public.lang; publicadminfalse8)00 TABLE langCOMMENTCOMMENT ON TABLE lang IS 'Table mapping ISO 639-1 and 639-2 language codes to Qt''s enum QLocale::Language integer values. See http://www.loc.gov/standards/iso639-2/php/code_list.php and the QLocale documentation..'; publicadminfalse554)00COLUMN lang.lang_abbr3COMMENTCOMMENT ON COLUMN lang.lang_abbr3 IS 'ISO 639-2 code for language. Where there is a choice between bibliographic (B) and terminology (T) usage, this value is the T code'; publicadminfalse554)00COLUMN lang.lang_abbr2COMMENTDCOMMENT ON COLUMN lang.lang_abbr2 IS 'ISO 639-1 code for language'; publicadminfalse554)00COLUMN lang.lang_nameCOMMENThCOMMENT ON COLUMN lang.lang_name IS 'Name of a human language, taken from the ISO 639-2 documentation'; publicadminfalse554)00langACLREVOKE ALL ON TABLE lang FROM PUBLIC; REVOKE ALL ON TABLE lang FROM admin; GRANT ALL ON TABLE lang TO admin; GRANT ALL ON TABLE lang TO xtrole; publicadminfalse554+125981723lang_lang_id_seqSEQUENCErCREATE SEQUENCE lang_lang_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 'DROP SEQUENCE public.lang_lang_id_seq; publicadminfalse8554)00lang_lang_id_seqSEQUENCE OWNED BY7ALTER SEQUENCE lang_lang_id_seq OWNED BY lang.lang_id; publicadminfalse555)00lang_lang_id_seqACLREVOKE ALL ON SEQUENCE lang_lang_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE lang_lang_id_seq FROM admin; GRANT ALL ON SEQUENCE lang_lang_id_seq TO admin; GRANT ALL ON SEQUENCE lang_lang_id_seq TO xtrole; publicadminfalse555,125981725localeTABLECREATE TABLE locale ( locale_id integer DEFAULT nextval(('locale_locale_id_seq'::text)::regclass) NOT NULL, locale_code text NOT NULL, locale_descrip text, locale_lang_file text, locale_dateformat text, locale_currformat text, locale_qtyformat text, locale_comments text, locale_qtyperformat text, locale_salespriceformat text, locale_extpriceformat text, locale_timeformat text, locale_timestampformat text, local_costformat text, locale_costformat text, locale_purchpriceformat text, locale_uomratioformat text, locale_intervalformat text, locale_lang_id integer, locale_country_id integer, locale_error_color text, locale_warning_color text, locale_emphasis_color text, locale_altemphasis_color text, locale_expired_color text, locale_future_color text, locale_curr_scale integer, locale_salesprice_scale integer, locale_purchprice_scale integer, locale_extprice_scale integer, locale_cost_scale integer, locale_qty_scale integer, locale_qtyper_scale integer, locale_uomratio_scale integer, locale_percent_scale integer DEFAULT 2, locale_weight_scale integer DEFAULT 2 NOT NULL, CONSTRAINT locale_locale_code_check CHECK ((locale_code <> ''::text)) ); DROP TABLE public.locale; publicadminfalse66246625662666278)00 TABLE localeCOMMENT5COMMENT ON TABLE locale IS 'The locale table holds information required to show data to the user in a localized format. Colors are either names documented by the WWW Consortium or RGB colors. Format for RGB colors is #RGB, #RRGGBB, or #RRRGGGBBB, where the letters R, G, and B stand for hexidecimal digits.'; publicadminfalse556)00COLUMN locale.locale_lang_fileCOMMENT;COMMENT ON COLUMN locale.locale_lang_file IS 'Deprecated'; publicadminfalse556)00COLUMN locale.locale_dateformatCOMMENT<COMMENT ON COLUMN locale.locale_dateformat IS 'Deprecated'; publicadminfalse556)00COLUMN locale.locale_currformatCOMMENT<COMMENT ON COLUMN locale.locale_currformat IS 'Deprecated'; publicadminfalse556)00COLUMN locale.locale_qtyformatCOMMENT;COMMENT ON COLUMN locale.locale_qtyformat IS 'Deprecated'; publicadminfalse556)00!COLUMN locale.locale_qtyperformatCOMMENT>COMMENT ON COLUMN locale.locale_qtyperformat IS 'Deprecated'; publicadminfalse556)00%COLUMN locale.locale_salespriceformatCOMMENTBCOMMENT ON COLUMN locale.locale_salespriceformat IS 'Deprecated'; publicadminfalse556)00#COLUMN locale.locale_extpriceformatCOMMENT@COMMENT ON COLUMN locale.locale_extpriceformat IS 'Deprecated'; publicadminfalse556)00COLUMN locale.locale_timeformatCOMMENT<COMMENT ON COLUMN locale.locale_timeformat IS 'Deprecated'; publicadminfalse556)00$COLUMN locale.locale_timestampformatCOMMENTACOMMENT ON COLUMN locale.locale_timestampformat IS 'Deprecated'; publicadminfalse556)00COLUMN locale.local_costformatCOMMENT;COMMENT ON COLUMN locale.local_costformat IS 'Deprecated'; publicadminfalse556)00COLUMN locale.locale_costformatCOMMENT<COMMENT ON COLUMN locale.locale_costformat IS 'Deprecated'; publicadminfalse556)00%COLUMN locale.locale_purchpriceformatCOMMENTBCOMMENT ON COLUMN locale.locale_purchpriceformat IS 'Deprecated'; publicadminfalse556)00#COLUMN locale.locale_uomratioformatCOMMENT@COMMENT ON COLUMN locale.locale_uomratioformat IS 'Deprecated'; publicadminfalse556)00#COLUMN locale.locale_intervalformatCOMMENT@COMMENT ON COLUMN locale.locale_intervalformat IS 'Deprecated'; publicadminfalse556)00 COLUMN locale.locale_error_colorCOMMENTnCOMMENT ON COLUMN locale.locale_error_color IS 'Color to use to mark data that require immediate attention.'; publicadminfalse556)00"COLUMN locale.locale_warning_colorCOMMENTkCOMMENT ON COLUMN locale.locale_warning_color IS 'Color to use to mark data that require attention soon.'; publicadminfalse556)00#COLUMN locale.locale_emphasis_colorCOMMENT|COMMENT ON COLUMN locale.locale_emphasis_color IS 'Color to use to mark data that need to stand out but are not in error.'; publicadminfalse556)00&COLUMN locale.locale_altemphasis_colorCOMMENTCOMMENT ON COLUMN locale.locale_altemphasis_color IS 'Color to use to mark data that need to stand out and be differentiated from other emphasized data.'; publicadminfalse556)00"COLUMN locale.locale_expired_colorCOMMENTjCOMMENT ON COLUMN locale.locale_expired_color IS 'Color to use to mark data that are no longer current.'; publicadminfalse556)00!COLUMN locale.locale_future_colorCOMMENTCOMMENT ON COLUMN locale.locale_future_color IS 'Color to use to mark data that will not be effective until some point in the future.'; publicadminfalse556)00COLUMN locale.locale_curr_scaleCOMMENTsCOMMENT ON COLUMN locale.locale_curr_scale IS 'Number of decimal places to show when displaying Currency values.'; publicadminfalse556)00%COLUMN locale.locale_salesprice_scaleCOMMENTvCOMMENT ON COLUMN locale.locale_salesprice_scale IS 'Number of decimal places to show when displaying Sales Prices.'; publicadminfalse556)00%COLUMN locale.locale_purchprice_scaleCOMMENTyCOMMENT ON COLUMN locale.locale_purchprice_scale IS 'Number of decimal places to show when displaying Purchase Prices.'; publicadminfalse556)00#COLUMN locale.locale_extprice_scaleCOMMENTwCOMMENT ON COLUMN locale.locale_extprice_scale IS 'Number of decimal places to show when displaying Extended Prices.'; publicadminfalse556)00COLUMN locale.locale_cost_scaleCOMMENTiCOMMENT ON COLUMN locale.locale_cost_scale IS 'Number of decimal places to show when displaying Costs.'; publicadminfalse556)00COLUMN locale.locale_qty_scaleCOMMENTmCOMMENT ON COLUMN locale.locale_qty_scale IS 'Number of decimal places to show when displaying Quantities.'; publicadminfalse556)00!COLUMN locale.locale_qtyper_scaleCOMMENTtCOMMENT ON COLUMN locale.locale_qtyper_scale IS 'Number of decimal places to show when displaying Quantities Per.'; publicadminfalse556)00#COLUMN locale.locale_uomratio_scaleCOMMENTrCOMMENT ON COLUMN locale.locale_uomratio_scale IS 'Number of decimal places to show when displaying UOM Ratios.'; publicadminfalse556)00localeACLREVOKE ALL ON TABLE locale FROM PUBLIC; REVOKE ALL ON TABLE locale FROM admin; GRANT ALL ON TABLE locale TO admin; GRANT ALL ON TABLE locale TO xtrole; publicadminfalse556-125981735locale_locale_id_seqSEQUENCE~CREATE SEQUENCE locale_locale_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; +DROP SEQUENCE public.locale_locale_id_seq; publicadminfalse8)00locale_locale_id_seqACLREVOKE ALL ON SEQUENCE locale_locale_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE locale_locale_id_seq FROM admin; GRANT ALL ON SEQUENCE locale_locale_id_seq TO admin; GRANT ALL ON SEQUENCE locale_locale_id_seq TO xtrole; publicadminfalse557.125981737location_location_id_seqSEQUENCECREATE SEQUENCE location_location_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; /DROP SEQUENCE public.location_location_id_seq; publicadminfalse8)00location_location_id_seqACLREVOKE ALL ON SEQUENCE location_location_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE location_location_id_seq FROM admin; GRANT ALL ON SEQUENCE location_location_id_seq TO admin; GRANT ALL ON SEQUENCE location_location_id_seq TO xtrole; publicadminfalse558/125981739locitemTABLECREATE TABLE locitem ( locitem_id integer DEFAULT nextval(('"locitem_locitem_id_seq"'::text)::regclass) NOT NULL, locitem_location_id integer, locitem_item_id integer ); DROP TABLE public.locitem; publicadminfalse66288)00 TABLE locitemCOMMENTYCOMMENT ON TABLE locitem IS 'Restricted Warehouse Location Allowable Items information'; publicadminfalse559)00locitemACLREVOKE ALL ON TABLE locitem FROM PUBLIC; REVOKE ALL ON TABLE locitem FROM admin; GRANT ALL ON TABLE locitem TO admin; GRANT ALL ON TABLE locitem TO xtrole; publicadminfalse5590125981743locitem_locitem_id_seqSEQUENCECREATE SEQUENCE locitem_locitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.locitem_locitem_id_seq; publicadminfalse8)00locitem_locitem_id_seqACLREVOKE ALL ON SEQUENCE locitem_locitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE locitem_locitem_id_seq FROM admin; GRANT ALL ON SEQUENCE locitem_locitem_id_seq TO admin; GRANT ALL ON SEQUENCE locitem_locitem_id_seq TO xtrole; publicadminfalse5601125981745log_log_id_seqSEQUENCExCREATE SEQUENCE log_log_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; %DROP SEQUENCE public.log_log_id_seq; publicadminfalse8*00log_log_id_seqACLREVOKE ALL ON SEQUENCE log_log_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE log_log_id_seq FROM admin; GRANT ALL ON SEQUENCE log_log_id_seq TO admin; GRANT ALL ON SEQUENCE log_log_id_seq TO xtrole; publicadminfalse5612125981747metricTABLE CREATE TABLE metric ( metric_id integer DEFAULT nextval(('metric_metric_id_seq'::text)::regclass) NOT NULL, metric_name text NOT NULL, metric_value text, metric_module text, CONSTRAINT metric_metric_name_check CHECK ((metric_name <> ''::text)) ); DROP TABLE public.metric; publicadminfalse662966308*00 TABLE metricCOMMENTDCOMMENT ON TABLE metric IS 'Application-wide settings information'; publicadminfalse562*00metricACLREVOKE ALL ON TABLE metric FROM PUBLIC; REVOKE ALL ON TABLE metric FROM admin; GRANT ALL ON TABLE metric TO admin; GRANT ALL ON TABLE metric TO xtrole; publicadminfalse5623125981755metric_metric_id_seqSEQUENCE~CREATE SEQUENCE metric_metric_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; +DROP SEQUENCE public.metric_metric_id_seq; publicadminfalse8*00metric_metric_id_seqACLREVOKE ALL ON SEQUENCE metric_metric_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE metric_metric_id_seq FROM admin; GRANT ALL ON SEQUENCE metric_metric_id_seq TO admin; GRANT ALL ON SEQUENCE metric_metric_id_seq TO xtrole; publicadminfalse5634125981757 metricencTABLECREATE TABLE metricenc ( metricenc_id integer NOT NULL, metricenc_name text NOT NULL, metricenc_value bytea, metricenc_module text, CONSTRAINT metricenc_metricenc_name_check CHECK ((metricenc_name <> ''::text)) ); DROP TABLE public.metricenc; publicadminfalse66328*00TABLE metricencCOMMENTVCOMMENT ON TABLE metricenc IS 'Application-wide settings information encrypted data'; publicadminfalse564*00 metricencACLREVOKE ALL ON TABLE metricenc FROM PUBLIC; REVOKE ALL ON TABLE metricenc FROM admin; GRANT ALL ON TABLE metricenc TO admin; GRANT ALL ON TABLE metricenc TO xtrole; publicadminfalse5645125981764metricenc_metricenc_id_seqSEQUENCE|CREATE SEQUENCE metricenc_metricenc_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 1DROP SEQUENCE public.metricenc_metricenc_id_seq; publicadminfalse8564*00metricenc_metricenc_id_seqSEQUENCE OWNED BYKALTER SEQUENCE metricenc_metricenc_id_seq OWNED BY metricenc.metricenc_id; publicadminfalse565*00metricenc_metricenc_id_seqACLREVOKE ALL ON SEQUENCE metricenc_metricenc_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE metricenc_metricenc_id_seq FROM admin; GRANT ALL ON SEQUENCE metricenc_metricenc_id_seq TO admin; GRANT ALL ON SEQUENCE metricenc_metricenc_id_seq TO xtrole; publicadminfalse5656125981766misc_index_seqSEQUENCExCREATE SEQUENCE misc_index_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; %DROP SEQUENCE public.misc_index_seq; publicadminfalse8*00misc_index_seqACLREVOKE ALL ON SEQUENCE misc_index_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE misc_index_seq FROM admin; GRANT ALL ON SEQUENCE misc_index_seq TO admin; GRANT ALL ON SEQUENCE misc_index_seq TO xtrole; publicadminfalse5667125981768mrghistTABLECREATE TABLE mrghist ( mrghist_cntct_id integer NOT NULL, mrghist_table text NOT NULL, mrghist_pkey_col text NOT NULL, mrghist_pkey_id integer NOT NULL, mrghist_cntct_col text NOT NULL ); DROP TABLE public.mrghist; publicadminfalse8 *00mrghistACLREVOKE ALL ON TABLE mrghist FROM PUBLIC; REVOKE ALL ON TABLE mrghist FROM admin; GRANT ALL ON TABLE mrghist TO admin; GRANT ALL ON TABLE mrghist TO xtrole; publicadminfalse5678125981774mrgundoTABLECREATE TABLE mrgundo ( mrgundo_base_schema text, mrgundo_base_table text, mrgundo_base_id integer, mrgundo_schema text, mrgundo_table text, mrgundo_pkey_col text, mrgundo_pkey_id integer, mrgundo_col text, mrgundo_value text, mrgundo_type text ); DROP TABLE public.mrgundo; publicadminfalse8 *00 TABLE mrgundoCOMMENT COMMENT ON TABLE mrgundo IS 'This table keeps track of the original values of changes made while merging two records. It is a generalization of mrghist and trgthist, which are specific to merging contacts. The schema, table, and pkey_id columns uniquely identify the record that was changed while the _base_ columns identify the merge target. The _base_ columns are required to allow finding all of the records that pertain to a particular merge (e.g. find changes to the comment table that pertain to a crmacct merge).'; publicadminfalse568 *00"COLUMN mrgundo.mrgundo_base_schemaCOMMENTbCOMMENT ON COLUMN mrgundo.mrgundo_base_schema IS 'The schema in which the merge target resides.'; publicadminfalse568 *00!COLUMN mrgundo.mrgundo_base_tableCOMMENT`COMMENT ON COLUMN mrgundo.mrgundo_base_table IS 'The table in which the merge target resides.'; publicadminfalse568 *00COLUMN mrgundo.mrgundo_base_idCOMMENT\COMMENT ON COLUMN mrgundo.mrgundo_base_id IS 'The internal id of the merge target record.'; publicadminfalse568*00COLUMN mrgundo.mrgundo_schemaCOMMENTkCOMMENT ON COLUMN mrgundo.mrgundo_schema IS 'The name of the schema in which the modified table resides.'; publicadminfalse568*00COLUMN mrgundo.mrgundo_tableCOMMENTfCOMMENT ON COLUMN mrgundo.mrgundo_table IS 'The name of the table that was modified during a merge.'; publicadminfalse568*00COLUMN mrgundo.mrgundo_pkey_colCOMMENTCOMMENT ON COLUMN mrgundo.mrgundo_pkey_col IS 'The name of the primary key column in the modified table. This could be derived during the undo processing but it is simpler just to store it during the merge.'; publicadminfalse568*00COLUMN mrgundo.mrgundo_pkey_idCOMMENTXCOMMENT ON COLUMN mrgundo.mrgundo_pkey_id IS 'The primary key of the modified record.'; publicadminfalse568*00COLUMN mrgundo.mrgundo_colCOMMENTJCOMMENT ON COLUMN mrgundo.mrgundo_col IS 'The column that was modified.'; publicadminfalse568*00COLUMN mrgundo.mrgundo_valueCOMMENTYCOMMENT ON COLUMN mrgundo.mrgundo_value IS 'The value of the column before the change.'; publicadminfalse568*00COLUMN mrgundo.mrgundo_typeCOMMENTCOMMENT ON COLUMN mrgundo.mrgundo_type IS 'The data type of the modified column. This could be derived during the undo processing but it is simpler just to store it during the merge.'; publicadminfalse568*00mrgundoACLREVOKE ALL ON TABLE mrgundo FROM PUBLIC; REVOKE ALL ON TABLE mrgundo FROM admin; GRANT ALL ON TABLE mrgundo TO admin; GRANT ALL ON TABLE mrgundo TO xtrole; publicadminfalse5689125981780msgTABLECREATE TABLE msg ( msg_id integer DEFAULT nextval(('"msg_msg_id_seq"'::text)::regclass) NOT NULL, msg_posted timestamp with time zone, msg_scheduled timestamp with time zone, msg_text text, msg_expires timestamp with time zone, msg_username text ); DROP TABLE public.msg; publicadminfalse66338*00 TABLE msgCOMMENT6COMMENT ON TABLE msg IS 'System Message information'; publicadminfalse569*00msgACLREVOKE ALL ON TABLE msg FROM PUBLIC; REVOKE ALL ON TABLE msg FROM admin; GRANT ALL ON TABLE msg TO admin; GRANT ALL ON TABLE msg TO xtrole; publicadminfalse569:125981787msg_msg_id_seqSEQUENCExCREATE SEQUENCE msg_msg_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; %DROP SEQUENCE public.msg_msg_id_seq; publicadminfalse8*00msg_msg_id_seqACLREVOKE ALL ON SEQUENCE msg_msg_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE msg_msg_id_seq FROM admin; GRANT ALL ON SEQUENCE msg_msg_id_seq TO admin; GRANT ALL ON SEQUENCE msg_msg_id_seq TO xtrole; publicadminfalse570;125981789msguserTABLECREATE TABLE msguser ( msguser_id integer DEFAULT nextval(('"msguser_msguser_id_seq"'::text)::regclass) NOT NULL, msguser_msg_id integer, msguser_viewed timestamp with time zone, msguser_username text ); DROP TABLE public.msguser; publicadminfalse66348*00 TABLE msguserCOMMENT?COMMENT ON TABLE msguser IS 'System Message user information'; publicadminfalse571*00msguserACLREVOKE ALL ON TABLE msguser FROM PUBLIC; REVOKE ALL ON TABLE msguser FROM admin; GRANT ALL ON TABLE msguser TO admin; GRANT ALL ON TABLE msguser TO xtrole; publicadminfalse571<125981796msguser_msguser_id_seqSEQUENCECREATE SEQUENCE msguser_msguser_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.msguser_msguser_id_seq; publicadminfalse8*00msguser_msguser_id_seqACLREVOKE ALL ON SEQUENCE msguser_msguser_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE msguser_msguser_id_seq FROM admin; GRANT ALL ON SEQUENCE msguser_msguser_id_seq TO admin; GRANT ALL ON SEQUENCE msguser_msguser_id_seq TO xtrole; publicadminfalse572=125981798nvend_nvend_id_seqSEQUENCE|CREATE SEQUENCE nvend_nvend_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; )DROP SEQUENCE public.nvend_nvend_id_seq; publicadminfalse8*00nvend_nvend_id_seqACLREVOKE ALL ON SEQUENCE nvend_nvend_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE nvend_nvend_id_seq FROM admin; GRANT ALL ON SEQUENCE nvend_nvend_id_seq TO admin; GRANT ALL ON SEQUENCE nvend_nvend_id_seq TO xtrole; publicadminfalse573>125981800 obsolete_taxTABLECREATE TABLE obsolete_tax ( tax_id integer DEFAULT nextval(('"tax_tax_id_seq"'::text)::regclass) NOT NULL, tax_code text, tax_descrip text, tax_ratea numeric(8,4), tax_sales_accnt_id integer, tax_freight boolean DEFAULT false NOT NULL, tax_cumulative boolean DEFAULT false NOT NULL, tax_rateb numeric(8,4), tax_salesb_accnt_id integer, tax_ratec numeric(8,4), tax_salesc_accnt_id integer ); DROP TABLE public.obsolete_tax; publicadminfalse6635663666378*00TABLE obsolete_taxCOMMENTOCOMMENT ON TABLE obsolete_tax IS 'Tax information. Obsolete table structure.'; publicadminfalse574*00COLUMN obsolete_tax.tax_freightCOMMENTCOMMENT ON COLUMN obsolete_tax.tax_freight IS 'Deprecated in 2.1 and moved to taxsel table where taxtype is the system defined Freight.'; publicadminfalse574*00 obsolete_taxACLREVOKE ALL ON TABLE obsolete_tax FROM PUBLIC; REVOKE ALL ON TABLE obsolete_tax FROM admin; GRANT ALL ON TABLE obsolete_tax TO admin; GRANT ALL ON TABLE obsolete_tax TO xtrole; publicadminfalse574?125981809ophead_ophead_id_seqSEQUENCEvCREATE SEQUENCE ophead_ophead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.ophead_ophead_id_seq; publicadminfalse8210 *00ophead_ophead_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE ophead_ophead_id_seq OWNED BY ophead.ophead_id; publicadminfalse575!*00ophead_ophead_id_seqACLREVOKE ALL ON SEQUENCE ophead_ophead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE ophead_ophead_id_seq FROM admin; GRANT ALL ON SEQUENCE ophead_ophead_id_seq TO admin; GRANT ALL ON SEQUENCE ophead_ophead_id_seq TO xtrole; publicadminfalse575@125981811opsourceTABLECREATE TABLE opsource ( opsource_id integer NOT NULL, opsource_name text NOT NULL, opsource_descrip text, CONSTRAINT opsource_opsource_name_check CHECK ((opsource_name <> ''::text)) ); DROP TABLE public.opsource; publicadminfalse66398"*00TABLE opsourceCOMMENT@COMMENT ON TABLE opsource IS 'Opportunity Lead Source values.'; publicadminfalse576#*00opsourceACLREVOKE ALL ON TABLE opsource FROM PUBLIC; REVOKE ALL ON TABLE opsource FROM admin; GRANT ALL ON TABLE opsource TO admin; GRANT ALL ON TABLE opsource TO xtrole; publicadminfalse576A125981818opsource_opsource_id_seqSEQUENCEzCREATE SEQUENCE opsource_opsource_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.opsource_opsource_id_seq; publicadminfalse8576$*00opsource_opsource_id_seqSEQUENCE OWNED BYGALTER SEQUENCE opsource_opsource_id_seq OWNED BY opsource.opsource_id; publicadminfalse577%*00opsource_opsource_id_seqACLREVOKE ALL ON SEQUENCE opsource_opsource_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE opsource_opsource_id_seq FROM admin; GRANT ALL ON SEQUENCE opsource_opsource_id_seq TO admin; GRANT ALL ON SEQUENCE opsource_opsource_id_seq TO xtrole; publicadminfalse577B125981820opstageTABLECREATE TABLE opstage ( opstage_id integer NOT NULL, opstage_name text NOT NULL, opstage_descrip text, opstage_order integer DEFAULT 0 NOT NULL, opstage_opinactive boolean DEFAULT false, CONSTRAINT opstage_opstage_name_check CHECK ((opstage_name <> ''::text)) ); DROP TABLE public.opstage; publicadminfalse6641664266438&*00 TABLE opstageCOMMENT9COMMENT ON TABLE opstage IS 'Opportunity stage values.'; publicadminfalse578'*00opstageACLREVOKE ALL ON TABLE opstage FROM PUBLIC; REVOKE ALL ON TABLE opstage FROM admin; GRANT ALL ON TABLE opstage TO admin; GRANT ALL ON TABLE opstage TO xtrole; publicadminfalse578C125981829opstage_opstage_id_seqSEQUENCExCREATE SEQUENCE opstage_opstage_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.opstage_opstage_id_seq; publicadminfalse8578(*00opstage_opstage_id_seqSEQUENCE OWNED BYCALTER SEQUENCE opstage_opstage_id_seq OWNED BY opstage.opstage_id; publicadminfalse579)*00opstage_opstage_id_seqACLREVOKE ALL ON SEQUENCE opstage_opstage_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE opstage_opstage_id_seq FROM admin; GRANT ALL ON SEQUENCE opstage_opstage_id_seq TO admin; GRANT ALL ON SEQUENCE opstage_opstage_id_seq TO xtrole; publicadminfalse579D125981831optypeTABLECREATE TABLE optype ( optype_id integer NOT NULL, optype_name text NOT NULL, optype_descrip text, CONSTRAINT optype_optype_name_check CHECK ((optype_name <> ''::text)) ); DROP TABLE public.optype; publicadminfalse66458**00 TABLE optypeCOMMENT7COMMENT ON TABLE optype IS 'Opportunity Type values.'; publicadminfalse580+*00optypeACLREVOKE ALL ON TABLE optype FROM PUBLIC; REVOKE ALL ON TABLE optype FROM admin; GRANT ALL ON TABLE optype TO admin; GRANT ALL ON TABLE optype TO xtrole; publicadminfalse580E125981838optype_optype_id_seqSEQUENCEvCREATE SEQUENCE optype_optype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.optype_optype_id_seq; publicadminfalse8580,*00optype_optype_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE optype_optype_id_seq OWNED BY optype.optype_id; publicadminfalse581-*00optype_optype_id_seqACLREVOKE ALL ON SEQUENCE optype_optype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE optype_optype_id_seq FROM admin; GRANT ALL ON SEQUENCE optype_optype_id_seq TO admin; GRANT ALL ON SEQUENCE optype_optype_id_seq TO xtrole; publicadminfalse581125987619 orderheadVIEWCREATE VIEW orderhead AS SELECT DISTINCT data.orderhead_id, data.orderhead_type, data.orderhead_number, data.orderhead_status, data.orderhead_orderdate, data.orderhead_linecount, data.orderhead_from_id, data.orderhead_from, data.orderhead_to_id, data.orderhead_to, data.orderhead_curr_id, data.orderhead_agent_username, data.orderhead_shipvia FROM (SELECT pohead.pohead_id AS orderhead_id, 'PO'::text AS orderhead_type, pohead.pohead_number AS orderhead_number, pohead.pohead_status AS orderhead_status, pohead.pohead_orderdate AS orderhead_orderdate, (SELECT count(*) AS count FROM poitem WHERE (poitem.poitem_pohead_id = pohead.pohead_id)) AS orderhead_linecount, pohead.pohead_vend_id AS orderhead_from_id, vendinfo.vend_name AS orderhead_from, NULL::integer AS orderhead_to_id, ''::text AS orderhead_to, pohead.pohead_curr_id AS orderhead_curr_id, pohead.pohead_agent_username AS orderhead_agent_username, pohead.pohead_shipvia AS orderhead_shipvia FROM (pohead LEFT JOIN vendinfo ON ((pohead.pohead_vend_id = vendinfo.vend_id))) UNION ALL SELECT cohead.cohead_id AS orderhead_id, 'SO'::text AS orderhead_type, cohead.cohead_number AS orderhead_number, cohead.cohead_status AS orderhead_status, cohead.cohead_orderdate AS orderhead_orderdate, (SELECT count(*) AS count FROM coitem WHERE (coitem.coitem_cohead_id = cohead.cohead_id)) AS orderhead_linecount, NULL::integer AS orderhead_from_id, ''::text AS orderhead_from, cohead.cohead_cust_id AS orderhead_to_id, CASE WHEN (length(cohead.cohead_shiptoname) > 0) THEN cohead.cohead_shiptoname ELSE cohead.cohead_billtoname END AS orderhead_to, cohead.cohead_curr_id AS orderhead_curr_id, ''::text AS orderhead_agent_username, cohead.cohead_shipvia AS orderhead_shipvia FROM cohead) data; DROP VIEW public.orderhead; publicadminfalse86828.*00VIEW orderheadCOMMENTCOMMENT ON VIEW orderhead IS 'Union of all orders for use by widgets and stored procedures which process multiple types of order'; publicadminfalse799/*00 orderheadACLREVOKE ALL ON TABLE orderhead FROM PUBLIC; REVOKE ALL ON TABLE orderhead FROM admin; GRANT ALL ON TABLE orderhead TO admin; GRANT ALL ON TABLE orderhead TO xtrole; publicadminfalse799 125987624 orderitemVIEW CREATE VIEW orderitem AS (SELECT poitem.poitem_id AS orderitem_id, 'PO'::text AS orderitem_orderhead_type, poitem.poitem_pohead_id AS orderitem_orderhead_id, poitem.poitem_linenumber AS orderitem_linenumber, poitem.poitem_status AS orderitem_status, poitem.poitem_itemsite_id AS orderitem_itemsite_id, poitem.poitem_duedate AS orderitem_scheddate, poitem.poitem_qty_ordered AS orderitem_qty_ordered, poitem.poitem_qty_returned AS orderitem_qty_shipped, poitem.poitem_qty_received AS orderitem_qty_received, uom.uom_id AS orderitem_qty_uom_id, poitem.poitem_invvenduomratio AS orderitem_qty_invuomratio, poitem.poitem_unitprice AS orderitem_unitcost, pohead.pohead_curr_id AS orderitem_unitcost_curr_id, poitem.poitem_freight AS orderitem_freight, poitem.poitem_freight_received AS orderitem_freight_received, pohead.pohead_curr_id AS orderitem_freight_curr_id FROM ((poitem LEFT JOIN pohead ON ((poitem.poitem_pohead_id = pohead.pohead_id))) LEFT JOIN uom ON ((uom.uom_name = poitem.poitem_vend_uom))) UNION ALL SELECT coitem.coitem_id AS orderitem_id, 'SO'::text AS orderitem_orderhead_type, coitem.coitem_cohead_id AS orderitem_orderhead_id, coitem.coitem_linenumber AS orderitem_linenumber, coitem.coitem_status AS orderitem_status, coitem.coitem_itemsite_id AS orderitem_itemsite_id, coitem.coitem_scheddate AS orderitem_scheddate, coitem.coitem_qtyord AS orderitem_qty_ordered, coitem.coitem_qtyshipped AS orderitem_qty_shipped, coitem.coitem_qtyreturned AS orderitem_qty_received, coitem.coitem_qty_uom_id AS orderitem_qty_uom_id, coitem.coitem_qty_invuomratio AS orderitem_qty_invuomratio, coitem.coitem_unitcost AS orderitem_unitcost, basecurrid() AS orderitem_unitcost_curr_id, NULL::numeric AS orderitem_freight, NULL::numeric AS orderitem_freight_received, basecurrid() AS orderitem_freight_curr_id FROM coitem) UNION ALL SELECT quitem.quitem_id AS orderitem_id, 'QU'::text AS orderitem_orderhead_type, quitem.quitem_quhead_id AS orderitem_orderhead_id, quitem.quitem_linenumber AS orderitem_linenumber, 'O'::bpchar AS orderitem_status, quitem.quitem_itemsite_id AS orderitem_itemsite_id, quitem.quitem_scheddate AS orderitem_scheddate, quitem.quitem_qtyord AS orderitem_qty_ordered, 0 AS orderitem_qty_shipped, 0 AS orderitem_qty_received, quitem.quitem_qty_uom_id AS orderitem_qty_uom_id, quitem.quitem_qty_invuomratio AS orderitem_qty_invuomratio, quitem.quitem_unitcost AS orderitem_unitcost, basecurrid() AS orderitem_unitcost_curr_id, NULL::numeric AS orderitem_freight, NULL::numeric AS orderitem_freight_received, basecurrid() AS orderitem_freight_curr_id FROM quitem; DROP VIEW public.orderitem; publicadminfalse868380*00VIEW orderitemCOMMENTCOMMENT ON VIEW orderitem IS 'Union of all order line items for use by widgets and stored procedures which process multiple types of order'; publicadminfalse8001*00 orderitemACLREVOKE ALL ON TABLE orderitem FROM PUBLIC; REVOKE ALL ON TABLE orderitem FROM admin; GRANT ALL ON TABLE orderitem TO admin; GRANT ALL ON TABLE orderitem TO xtrole; publicadminfalse800F125981850orderseqTABLEZCREATE TABLE orderseq ( orderseq_id integer DEFAULT nextval(('orderseq_orderseq_id_seq'::text)::regclass) NOT NULL, orderseq_name text NOT NULL, orderseq_number integer, orderseq_table text, orderseq_numcol text, orderseq_seqiss seqiss[], CONSTRAINT orderseq_orderseq_name_check CHECK ((orderseq_name <> ''::text)) ); DROP TABLE public.orderseq; publicadminfalse66466647272882*00TABLE orderseqCOMMENTYCOMMENT ON TABLE orderseq IS 'Configuration information for common numbering sequences'; publicadminfalse5823*00orderseqACLREVOKE ALL ON TABLE orderseq FROM PUBLIC; REVOKE ALL ON TABLE orderseq FROM admin; GRANT ALL ON TABLE orderseq TO admin; GRANT ALL ON TABLE orderseq TO xtrole; publicadminfalse582G125981858orderseq_orderseq_id_seqSEQUENCECREATE SEQUENCE orderseq_orderseq_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; /DROP SEQUENCE public.orderseq_orderseq_id_seq; publicadminfalse84*00orderseq_orderseq_id_seqACLREVOKE ALL ON SEQUENCE orderseq_orderseq_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE orderseq_orderseq_id_seq FROM admin; GRANT ALL ON SEQUENCE orderseq_orderseq_id_seq TO admin; GRANT ALL ON SEQUENCE orderseq_orderseq_id_seq TO xtrole; publicadminfalse583H125981860packTABLE;CREATE TABLE pack ( pack_id integer NOT NULL, pack_head_id integer NOT NULL, pack_head_type text NOT NULL, pack_shiphead_id integer, pack_printed boolean DEFAULT false NOT NULL, CONSTRAINT pack_pack_head_type_check CHECK (((pack_head_type = 'SO'::text) OR (pack_head_type = 'TO'::text))) ); DROP TABLE public.pack; publicadminfalse6649665085*00 TABLE packCOMMENTqCOMMENT ON TABLE pack IS 'Temporary table for storing information about Orders added to the Packing List Batch'; publicadminfalse5846*00packACLREVOKE ALL ON TABLE pack FROM PUBLIC; REVOKE ALL ON TABLE pack FROM admin; GRANT ALL ON TABLE pack TO admin; GRANT ALL ON TABLE pack TO xtrole; publicadminfalse584I125981868pack_pack_id_seqSEQUENCErCREATE SEQUENCE pack_pack_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 'DROP SEQUENCE public.pack_pack_id_seq; publicadminfalse85847*00pack_pack_id_seqSEQUENCE OWNED BY7ALTER SEQUENCE pack_pack_id_seq OWNED BY pack.pack_id; publicadminfalse5858*00pack_pack_id_seqACLREVOKE ALL ON SEQUENCE pack_pack_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE pack_pack_id_seq FROM admin; GRANT ALL ON SEQUENCE pack_pack_id_seq TO admin; GRANT ALL ON SEQUENCE pack_pack_id_seq TO xtrole; publicadminfalse585J125981870 payaropenTABLECREATE TABLE payaropen ( payaropen_ccpay_id integer NOT NULL, payaropen_aropen_id integer NOT NULL, payaropen_amount numeric(20,2) DEFAULT 0.00 NOT NULL, payaropen_curr_id integer DEFAULT basecurrid() ); DROP TABLE public.payaropen; publicadminfalse6651665289*00TABLE payaropenCOMMENTOCOMMENT ON TABLE payaropen IS 'Credit Card payment to credit memo join table'; publicadminfalse586:*00 payaropenACLREVOKE ALL ON TABLE payaropen FROM PUBLIC; REVOKE ALL ON TABLE payaropen FROM admin; GRANT ALL ON TABLE payaropen TO admin; GRANT ALL ON TABLE payaropen TO xtrole; publicadminfalse586K125981875paycoTABLECREATE TABLE payco ( payco_ccpay_id integer NOT NULL, payco_cohead_id integer NOT NULL, payco_amount numeric(20,2) DEFAULT 0.00 NOT NULL, payco_curr_id integer DEFAULT basecurrid(), payco_id integer NOT NULL ); DROP TABLE public.payco; publicadminfalse665366548;*00 TABLE paycoCOMMENTKCOMMENT ON TABLE payco IS 'Credit Card payment to sales order join table'; publicadminfalse587<*00COLUMN payco.payco_idCOMMENT@COMMENT ON COLUMN payco.payco_id IS 'payco table primary key.'; publicadminfalse587=*00paycoACLREVOKE ALL ON TABLE payco FROM PUBLIC; REVOKE ALL ON TABLE payco FROM admin; GRANT ALL ON TABLE payco TO admin; GRANT ALL ON TABLE payco TO xtrole; publicadminfalse587125987405payco_payco_id_seqSEQUENCEtCREATE SEQUENCE payco_payco_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; )DROP SEQUENCE public.payco_payco_id_seq; publicadminfalse8587>*00payco_payco_id_seqSEQUENCE OWNED BY;ALTER SEQUENCE payco_payco_id_seq OWNED BY payco.payco_id; publicadminfalse787?*00payco_payco_id_seqACLREVOKE ALL ON SEQUENCE payco_payco_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE payco_payco_id_seq FROM admin; GRANT ALL ON SEQUENCE payco_payco_id_seq TO admin; GRANT ALL ON SEQUENCE payco_payco_id_seq TO xtrole; publicadminfalse787L125981880period_period_id_seqSEQUENCEvCREATE SEQUENCE period_period_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.period_period_id_seq; publicadminfalse8230@*00period_period_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE period_period_id_seq OWNED BY period.period_id; publicadminfalse588A*00period_period_id_seqACLREVOKE ALL ON SEQUENCE period_period_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE period_period_id_seq FROM admin; GRANT ALL ON SEQUENCE period_period_id_seq TO admin; GRANT ALL ON SEQUENCE period_period_id_seq TO xtrole; publicadminfalse588M125981882pkgdepTABLECREATE TABLE pkgdep ( pkgdep_id integer NOT NULL, pkgdep_pkghead_id integer NOT NULL, pkgdep_parent_pkghead_id integer NOT NULL ); DROP TABLE public.pkgdep; publicadminfalse8B*00 TABLE pkgdepCOMMENTyCOMMENT ON TABLE pkgdep IS 'Package Dependencies list describing which packages are dependent on which other packages.'; publicadminfalse589C*00COLUMN pkgdep.pkgdep_pkghead_idCOMMENTCOMMENT ON COLUMN pkgdep.pkgdep_pkghead_id IS 'This is the internal ID of a package which requires at least one other package to be installed first to operate successfully'; publicadminfalse589D*00&COLUMN pkgdep.pkgdep_parent_pkghead_idCOMMENTCOMMENT ON COLUMN pkgdep.pkgdep_parent_pkghead_id IS 'This is the internal ID of a package which must be installed for the package pointed to by pkgdep_pkghead_id to operate successfully.'; publicadminfalse589E*00pkgdepACLREVOKE ALL ON TABLE pkgdep FROM PUBLIC; REVOKE ALL ON TABLE pkgdep FROM admin; GRANT ALL ON TABLE pkgdep TO admin; GRANT ALL ON TABLE pkgdep TO xtrole; publicadminfalse589N125981885pkgdep_pkgdep_id_seqSEQUENCEvCREATE SEQUENCE pkgdep_pkgdep_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.pkgdep_pkgdep_id_seq; publicadminfalse8589F*00pkgdep_pkgdep_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE pkgdep_pkgdep_id_seq OWNED BY pkgdep.pkgdep_id; publicadminfalse590G*00pkgdep_pkgdep_id_seqACLREVOKE ALL ON SEQUENCE pkgdep_pkgdep_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE pkgdep_pkgdep_id_seq FROM admin; GRANT ALL ON SEQUENCE pkgdep_pkgdep_id_seq TO admin; GRANT ALL ON SEQUENCE pkgdep_pkgdep_id_seq TO xtrole; publicadminfalse590O125981887pkgheadTABLECREATE TABLE pkghead ( pkghead_id integer NOT NULL, pkghead_name text NOT NULL, pkghead_descrip text, pkghead_version text NOT NULL, pkghead_developer text NOT NULL, pkghead_notes text, pkghead_created timestamp with time zone, pkghead_updated timestamp with time zone, pkghead_indev boolean DEFAULT false NOT NULL, CONSTRAINT pkghead_pkghead_name_check CHECK ((pkghead_name <> ''::text)) ); DROP TABLE public.pkghead; publicadminfalse665866598H*00 TABLE pkgheadCOMMENTYCOMMENT ON TABLE pkghead IS 'Information about non-core Packages added to the database'; publicadminfalse591I*00COLUMN pkghead.pkghead_indevCOMMENTCOMMENT ON COLUMN pkghead.pkghead_indev IS 'Flag indicating whether the contents of this package may be modified in-place - this package is /in dev/elopment.'; publicadminfalse591J*00pkgheadACLREVOKE ALL ON TABLE pkghead FROM PUBLIC; REVOKE ALL ON TABLE pkghead FROM admin; GRANT ALL ON TABLE pkghead TO admin; GRANT ALL ON TABLE pkghead TO xtrole; publicadminfalse591P125981895pkghead_pkghead_id_seqSEQUENCExCREATE SEQUENCE pkghead_pkghead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.pkghead_pkghead_id_seq; publicadminfalse8591K*00pkghead_pkghead_id_seqSEQUENCE OWNED BYCALTER SEQUENCE pkghead_pkghead_id_seq OWNED BY pkghead.pkghead_id; publicadminfalse592L*00pkghead_pkghead_id_seqACLREVOKE ALL ON SEQUENCE pkghead_pkghead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE pkghead_pkghead_id_seq FROM admin; GRANT ALL ON SEQUENCE pkghead_pkghead_id_seq TO admin; GRANT ALL ON SEQUENCE pkghead_pkghead_id_seq TO xtrole; publicadminfalse592Q125981897pkgitemTABLECREATE TABLE pkgitem ( pkgitem_id integer NOT NULL, pkgitem_pkghead_id integer, pkgitem_type text, pkgitem_item_id integer NOT NULL, pkgitem_name text NOT NULL, pkgitem_descrip text, CONSTRAINT pkgitem_pkgitem_type_check CHECK (((((((((((((pkgitem_type = 'C'::text) OR (pkgitem_type = 'D'::text)) OR (pkgitem_type = 'F'::text)) OR (pkgitem_type = 'G'::text)) OR (pkgitem_type = 'I'::text)) OR (pkgitem_type = 'M'::text)) OR (pkgitem_type = 'P'::text)) OR (pkgitem_type = 'R'::text)) OR (pkgitem_type = 'S'::text)) OR (pkgitem_type = 'T'::text)) OR (pkgitem_type = 'U'::text)) OR (pkgitem_type = 'V'::text))) ); DROP TABLE public.pkgitem; publicadminfalse66618M*00 TABLE pkgitemCOMMENTCOMMENT ON TABLE pkgitem IS 'Deprecated - the pkgitem table is no longer used to track package contents. It has been replaced by direct queries to the database schema and component tables. This table will be removed when all users have switched to Updater 2.2.0 or later.'; publicadminfalse593N*00pkgitemACLREVOKE ALL ON TABLE pkgitem FROM PUBLIC; REVOKE ALL ON TABLE pkgitem FROM admin; GRANT ALL ON TABLE pkgitem TO admin; GRANT ALL ON TABLE pkgitem TO xtrole; publicadminfalse593R125981904pkgitem_pkgitem_id_seqSEQUENCExCREATE SEQUENCE pkgitem_pkgitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.pkgitem_pkgitem_id_seq; publicadminfalse8593O*00pkgitem_pkgitem_id_seqSEQUENCE OWNED BYCALTER SEQUENCE pkgitem_pkgitem_id_seq OWNED BY pkgitem.pkgitem_id; publicadminfalse594P*00pkgitem_pkgitem_id_seqACLREVOKE ALL ON SEQUENCE pkgitem_pkgitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE pkgitem_pkgitem_id_seq FROM admin; GRANT ALL ON SEQUENCE pkgitem_pkgitem_id_seq TO admin; GRANT ALL ON SEQUENCE pkgitem_pkgitem_id_seq TO xtrole; publicadminfalse594S125981906plancode_plancode_id_seqSEQUENCEzCREATE SEQUENCE plancode_plancode_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.plancode_plancode_id_seq; publicadminfalse8Q*00plancode_plancode_id_seqACLREVOKE ALL ON SEQUENCE plancode_plancode_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE plancode_plancode_id_seq FROM admin; GRANT ALL ON SEQUENCE plancode_plancode_id_seq TO admin; GRANT ALL ON SEQUENCE plancode_plancode_id_seq TO xtrole; publicadminfalse595T125981908planord_planord_id_seqSEQUENCECREATE SEQUENCE planord_planord_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.planord_planord_id_seq; publicadminfalse8R*00planord_planord_id_seqACLREVOKE ALL ON SEQUENCE planord_planord_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE planord_planord_id_seq FROM admin; GRANT ALL ON SEQUENCE planord_planord_id_seq TO admin; GRANT ALL ON SEQUENCE planord_planord_id_seq TO xtrole; publicadminfalse596U125981910pohead_pohead_id_seqSEQUENCE~CREATE SEQUENCE pohead_pohead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; +DROP SEQUENCE public.pohead_pohead_id_seq; publicadminfalse8S*00pohead_pohead_id_seqACLREVOKE ALL ON SEQUENCE pohead_pohead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE pohead_pohead_id_seq FROM admin; GRANT ALL ON SEQUENCE pohead_pohead_id_seq TO admin; GRANT ALL ON SEQUENCE pohead_pohead_id_seq TO xtrole; publicadminfalse597V125981912poitem_poitem_id_seqSEQUENCE~CREATE SEQUENCE poitem_poitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; +DROP SEQUENCE public.poitem_poitem_id_seq; publicadminfalse8T*00poitem_poitem_id_seqACLREVOKE ALL ON SEQUENCE poitem_poitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE poitem_poitem_id_seq FROM admin; GRANT ALL ON SEQUENCE poitem_poitem_id_seq TO admin; GRANT ALL ON SEQUENCE poitem_poitem_id_seq TO xtrole; publicadminfalse598W125981914recvTABLEzCREATE TABLE recv ( recv_id integer NOT NULL, recv_order_type text NOT NULL, recv_order_number text NOT NULL, recv_orderitem_id integer NOT NULL, recv_agent_username text, recv_itemsite_id integer, recv_vend_id integer, recv_vend_item_number text, recv_vend_item_descrip text, recv_vend_uom text, recv_purchcost numeric(16,6), recv_purchcost_curr_id integer, recv_duedate date, recv_qty numeric(18,6), recv_recvcost numeric(16,6), recv_recvcost_curr_id integer, recv_freight numeric(16,4), recv_freight_curr_id integer, recv_date timestamp with time zone, recv_value numeric(18,6), recv_posted boolean DEFAULT false NOT NULL, recv_invoiced boolean DEFAULT false NOT NULL, recv_vohead_id integer, recv_voitem_id integer, recv_trans_usr_name text DEFAULT geteffectivextuser() NOT NULL, recv_notes text, recv_gldistdate date, recv_splitfrom_id integer, recv_rlsd_duedate date, CONSTRAINT recv_recv_order_type_check CHECK ((((recv_order_type = 'PO'::text) OR (recv_order_type = 'RA'::text)) OR (recv_order_type = 'TO'::text))) ); DROP TABLE public.recv; publicadminfalse66626663666466668U*00 TABLE recvCOMMENT?COMMENT ON TABLE recv IS 'Information about Received Orders.'; publicadminfalse599V*00recvACLREVOKE ALL ON TABLE recv FROM PUBLIC; REVOKE ALL ON TABLE recv FROM admin; GRANT ALL ON TABLE recv TO admin; GRANT ALL ON TABLE recv TO xtrole; publicadminfalse599X125981924porecvVIEW4CREATE VIEW porecv AS SELECT recv.recv_id AS porecv_id, recv.recv_date AS porecv_date, recv.recv_rlsd_duedate AS porecv_rlsd_duedate, pohead.pohead_orderdate AS porecv_orderdate, pohead.pohead_released AS porecv_released, recv.recv_order_number AS porecv_ponumber, recv.recv_itemsite_id AS porecv_itemsite_id, recv.recv_vend_id AS porecv_vend_id, item.item_number AS porecv_item_number, recv.recv_vend_item_number AS porecv_vend_item_number, COALESCE(item.item_descrip1, recv.recv_vend_item_descrip) AS porecv_vend_item_descrip, recv.recv_vend_uom AS porecv_vend_uom, recv.recv_qty AS porecv_qty, recv.recv_posted AS porecv_posted, recv.recv_invoiced AS porecv_invoiced, (pg_user.usesysid)::integer AS porecv_trans_usr_id, recv.recv_orderitem_id AS porecv_poitem_id, NULL::integer AS porecv_linenumber, recv.recv_purchcost AS porecv_purchcost, recv.recv_vohead_id AS porecv_vohead_id, recv.recv_recvcost AS porecv_recvcost, recv.recv_duedate AS porecv_duedate, recv.recv_agent_username AS porecv_agent_username, recv.recv_notes AS porecv_notes, recv.recv_freight AS porecv_freight, recv.recv_freight_curr_id AS porecv_curr_id, recv.recv_gldistdate AS porecv_gldistdate, recv.recv_voitem_id AS porecv_voitem_id, recv.recv_value AS porecv_value FROM ((((recv LEFT JOIN pg_user ON ((recv.recv_trans_usr_name = (pg_user.usename)::text))) LEFT JOIN pohead ON ((recv.recv_order_number = pohead.pohead_number))) LEFT JOIN itemsite ON ((recv.recv_itemsite_id = itemsite.itemsite_id))) LEFT JOIN item ON ((itemsite.itemsite_item_id = item.item_id))) WHERE (recv.recv_order_type = 'PO'::text); DROP VIEW public.porecv; publicadminfalse86448W*00porecvACLREVOKE ALL ON TABLE porecv FROM PUBLIC; REVOKE ALL ON TABLE porecv FROM admin; GRANT ALL ON TABLE porecv TO admin; GRANT ALL ON TABLE porecv TO xtrole; publicadminfalse600Y125981929porecv_porecv_id_seqSEQUENCE~CREATE SEQUENCE porecv_porecv_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; +DROP SEQUENCE public.porecv_porecv_id_seq; publicadminfalse8X*00porecv_porecv_id_seqACLREVOKE ALL ON SEQUENCE porecv_porecv_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE porecv_porecv_id_seq FROM admin; GRANT ALL ON SEQUENCE porecv_porecv_id_seq TO admin; GRANT ALL ON SEQUENCE porecv_porecv_id_seq TO xtrole; publicadminfalse601Z125981931porejectTABLECREATE TABLE poreject ( poreject_id integer DEFAULT nextval(('"poreject_poreject_id_seq"'::text)::regclass) NOT NULL, poreject_date timestamp with time zone, poreject_ponumber text, poreject_itemsite_id integer, poreject_vend_id integer, poreject_vend_item_number text, poreject_vend_item_descrip text, poreject_vend_uom text, poreject_qty numeric(18,6), poreject_posted boolean, poreject_rjctcode_id integer, poreject_poitem_id integer, poreject_invoiced boolean, poreject_vohead_id integer, poreject_agent_username text, poreject_voitem_id integer, poreject_value numeric(18,6), poreject_trans_username text, poreject_recv_id integer ); DROP TABLE public.poreject; publicadminfalse66678Y*00TABLE porejectCOMMENTqCOMMENT ON TABLE poreject IS 'The poreject table describes Purchase Order Items that were returned to Vendors.'; publicadminfalse602Z*00COLUMN poreject.poreject_idCOMMENT]COMMENT ON COLUMN poreject.poreject_id IS 'This is the internal id of this poreject record'; publicadminfalse602[*00COLUMN poreject.poreject_dateCOMMENTrCOMMENT ON COLUMN poreject.poreject_date IS 'This is the date and time the return was entered into the database'; publicadminfalse602\*00!COLUMN poreject.poreject_ponumberCOMMENTrCOMMENT ON COLUMN poreject.poreject_ponumber IS 'This is the number of the original Purchase Order of this item'; publicadminfalse602]*00$COLUMN poreject.poreject_itemsite_idCOMMENTrCOMMENT ON COLUMN poreject.poreject_itemsite_id IS 'This is the Item Site into which the item had been received'; publicadminfalse602^*00 COLUMN poreject.poreject_vend_idCOMMENTlCOMMENT ON COLUMN poreject.poreject_vend_id IS 'This is the Vendor from which the item had been purchased'; publicadminfalse602_*00)COLUMN poreject.poreject_vend_item_numberCOMMENTkCOMMENT ON COLUMN poreject.poreject_vend_item_number IS 'This is the Vendor''s item number for this item'; publicadminfalse602`*00*COLUMN poreject.poreject_vend_item_descripCOMMENTkCOMMENT ON COLUMN poreject.poreject_vend_item_descrip IS 'This is the Vendor''s description of this item'; publicadminfalse602a*00!COLUMN poreject.poreject_vend_uomCOMMENTrCOMMENT ON COLUMN poreject.poreject_vend_uom IS 'This is the Unit of Measure in which the Vendor sold this item'; publicadminfalse602b*00COLUMN poreject.poreject_qtyCOMMENTaCOMMENT ON COLUMN poreject.poreject_qty IS 'This is the quantity of the item that was returned'; publicadminfalse602c*00COLUMN poreject.poreject_postedCOMMENTCOMMENT ON COLUMN poreject.poreject_posted IS 'This indicates whether or not the return has been recorded in the General Ledger, Inventory History, and Purchase Order Item'; publicadminfalse602d*00$COLUMN poreject.poreject_rjctcode_idCOMMENT_COMMENT ON COLUMN poreject.poreject_rjctcode_id IS 'This indicates the reason for the return'; publicadminfalse602e*00"COLUMN poreject.poreject_poitem_idCOMMENTpCOMMENT ON COLUMN poreject.poreject_poitem_id IS 'This is the internal id of the original Purchase Order Item'; publicadminfalse602f*00!COLUMN poreject.poreject_invoicedCOMMENTCOMMENT ON COLUMN poreject.poreject_invoiced IS 'This indicates whether the Credit Memo associated with the return has been posted'; publicadminfalse602g*00"COLUMN poreject.poreject_vohead_idCOMMENTpCOMMENT ON COLUMN poreject.poreject_vohead_id IS 'This is the Voucher associated with the Purchase Order Item'; publicadminfalse602h*00'COLUMN poreject.poreject_agent_usernameCOMMENTCOMMENT ON COLUMN poreject.poreject_agent_username IS 'This is the Purchase Order Agent responsible for the original Purchase Order'; publicadminfalse602i*00"COLUMN poreject.poreject_voitem_idCOMMENTuCOMMENT ON COLUMN poreject.poreject_voitem_id IS 'This is the Voucher Item associated with the Purchase Order Item'; publicadminfalse602j*00COLUMN poreject.poreject_valueCOMMENTCOMMENT ON COLUMN poreject.poreject_value IS 'This is the value (in base currency) of the return at the time it was posted to the General Ledger'; publicadminfalse602k*00'COLUMN poreject.poreject_trans_usernameCOMMENTbCOMMENT ON COLUMN poreject.poreject_trans_username IS 'This is the user who recorded the return'; publicadminfalse602l*00porejectACLREVOKE ALL ON TABLE poreject FROM PUBLIC; REVOKE ALL ON TABLE poreject FROM admin; GRANT ALL ON TABLE poreject TO admin; GRANT ALL ON TABLE poreject TO xtrole; publicadminfalse602[125981938poreject_poreject_id_seqSEQUENCECREATE SEQUENCE poreject_poreject_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; /DROP SEQUENCE public.poreject_poreject_id_seq; publicadminfalse8m*00poreject_poreject_id_seqACLREVOKE ALL ON SEQUENCE poreject_poreject_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE poreject_poreject_id_seq FROM admin; GRANT ALL ON SEQUENCE poreject_poreject_id_seq TO admin; GRANT ALL ON SEQUENCE poreject_poreject_id_seq TO xtrole; publicadminfalse603\125981940prTABLECREATE TABLE pr ( pr_id integer DEFAULT nextval(('"pr_pr_id_seq"'::text)::regclass) NOT NULL, pr_number integer, pr_subnumber integer, pr_status character(1), pr_order_type character(1), pr_order_id integer, pr_poitem_id integer, pr_duedate date, pr_itemsite_id integer, pr_qtyreq numeric(18,6), pr_prj_id integer, pr_releasenote text, pr_createdate timestamp without time zone DEFAULT now() ); DROP TABLE public.pr; publicadminfalse666866698n*00TABLE prCOMMENT7COMMENT ON TABLE pr IS 'Purchase Request information'; publicadminfalse604o*00prACLREVOKE ALL ON TABLE pr FROM PUBLIC; REVOKE ALL ON TABLE pr FROM admin; GRANT ALL ON TABLE pr TO admin; GRANT ALL ON TABLE pr TO xtrole; publicadminfalse604]125981948 pr_pr_id_seqSEQUENCEnCREATE SEQUENCE pr_pr_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; #DROP SEQUENCE public.pr_pr_id_seq; publicadminfalse8p*00 pr_pr_id_seqACLREVOKE ALL ON SEQUENCE pr_pr_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE pr_pr_id_seq FROM admin; GRANT ALL ON SEQUENCE pr_pr_id_seq TO admin; GRANT ALL ON SEQUENCE pr_pr_id_seq TO xtrole; publicadminfalse605^125981950prftcntrTABLECREATE TABLE prftcntr ( prftcntr_id integer NOT NULL, prftcntr_number text NOT NULL, prftcntr_descrip text, CONSTRAINT prftcntr_prftcntr_number_check CHECK ((prftcntr_number <> ''::text)) ); DROP TABLE public.prftcntr; publicadminfalse66718q*00TABLE prftcntrCOMMENT:COMMENT ON TABLE prftcntr IS 'Profit Center information'; publicadminfalse606r*00prftcntrACLREVOKE ALL ON TABLE prftcntr FROM PUBLIC; REVOKE ALL ON TABLE prftcntr FROM admin; GRANT ALL ON TABLE prftcntr TO admin; GRANT ALL ON TABLE prftcntr TO xtrole; publicadminfalse606_125981957prftcntr_prftcntr_id_seqSEQUENCEzCREATE SEQUENCE prftcntr_prftcntr_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.prftcntr_prftcntr_id_seq; publicadminfalse8606s*00prftcntr_prftcntr_id_seqSEQUENCE OWNED BYGALTER SEQUENCE prftcntr_prftcntr_id_seq OWNED BY prftcntr.prftcntr_id; publicadminfalse607t*00prftcntr_prftcntr_id_seqACLREVOKE ALL ON SEQUENCE prftcntr_prftcntr_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE prftcntr_prftcntr_id_seq FROM admin; GRANT ALL ON SEQUENCE prftcntr_prftcntr_id_seq TO admin; GRANT ALL ON SEQUENCE prftcntr_prftcntr_id_seq TO xtrole; publicadminfalse607`125981959usrgrpTABLECREATE TABLE usrgrp ( usrgrp_id integer NOT NULL, usrgrp_grp_id integer NOT NULL, usrgrp_username text NOT NULL ); DROP TABLE public.usrgrp; publicadminfalse8u*00 TABLE usrgrpCOMMENTECOMMENT ON TABLE usrgrp IS 'This is which group a user belongs to.'; publicadminfalse608v*00usrgrpACLREVOKE ALL ON TABLE usrgrp FROM PUBLIC; REVOKE ALL ON TABLE usrgrp FROM admin; GRANT ALL ON TABLE usrgrp TO admin; GRANT ALL ON TABLE usrgrp TO xtrole; publicadminfalse608a125981965usrprivTABLECREATE TABLE usrpriv ( usrpriv_id integer DEFAULT nextval(('usrpriv_usrpriv_id_seq'::text)::regclass) NOT NULL, usrpriv_priv_id integer, usrpriv_username text ); DROP TABLE public.usrpriv; publicadminfalse66738w*00 TABLE usrprivCOMMENT;COMMENT ON TABLE usrpriv IS 'User Privileges information'; publicadminfalse609x*00usrprivACLREVOKE ALL ON TABLE usrpriv FROM PUBLIC; REVOKE ALL ON TABLE usrpriv FROM admin; GRANT ALL ON TABLE usrpriv TO admin; GRANT ALL ON TABLE usrpriv TO xtrole; publicadminfalse609!125987629 privgrantedVIEW'CREATE VIEW privgranted AS SELECT priv.priv_name AS privilege, (COALESCE(usrpriv.usrpriv_priv_id, grppriv.grppriv_priv_id, (-1)) > 0) AS granted, priv.priv_seq AS sequence FROM ((priv LEFT JOIN usrpriv ON (((priv.priv_id = usrpriv.usrpriv_priv_id) AND (usrpriv.usrpriv_username = geteffectivextuser())))) LEFT JOIN (SELECT DISTINCT grppriv.grppriv_priv_id FROM (grppriv JOIN usrgrp ON (((grppriv.grppriv_grp_id = usrgrp.usrgrp_grp_id) AND (usrgrp.usrgrp_username = geteffectivextuser()))))) grppriv ON ((grppriv.grppriv_priv_id = priv.priv_id))); DROP VIEW public.privgranted; publicadminfalse86848y*00 privgrantedACLREVOKE ALL ON TABLE privgranted FROM PUBLIC; REVOKE ALL ON TABLE privgranted FROM admin; GRANT ALL ON TABLE privgranted TO admin; GRANT ALL ON TABLE privgranted TO xtrole; publicadminfalse801b125981977prj_prj_id_seqSEQUENCEpCREATE SEQUENCE prj_prj_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; %DROP SEQUENCE public.prj_prj_id_seq; publicadminfalse8206z*00prj_prj_id_seqSEQUENCE OWNED BY3ALTER SEQUENCE prj_prj_id_seq OWNED BY prj.prj_id; publicadminfalse610{*00prj_prj_id_seqACLREVOKE ALL ON SEQUENCE prj_prj_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE prj_prj_id_seq FROM admin; GRANT ALL ON SEQUENCE prj_prj_id_seq TO admin; GRANT ALL ON SEQUENCE prj_prj_id_seq TO xtrole; publicadminfalse610c125981979prjtask_prjtask_id_seqSEQUENCExCREATE SEQUENCE prjtask_prjtask_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.prjtask_prjtask_id_seq; publicadminfalse8211|*00prjtask_prjtask_id_seqSEQUENCE OWNED BYCALTER SEQUENCE prjtask_prjtask_id_seq OWNED BY prjtask.prjtask_id; publicadminfalse611}*00prjtask_prjtask_id_seqACLREVOKE ALL ON SEQUENCE prjtask_prjtask_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE prjtask_prjtask_id_seq FROM admin; GRANT ALL ON SEQUENCE prjtask_prjtask_id_seq TO admin; GRANT ALL ON SEQUENCE prjtask_prjtask_id_seq TO xtrole; publicadminfalse611d125981981 prjtaskuserTABLECREATE TABLE prjtaskuser ( prjtaskuser_id integer NOT NULL, prjtaskuser_prjtask_id integer, prjtaskuser_username text ); DROP TABLE public.prjtaskuser; publicadminfalse8~*00TABLE prjtaskuserCOMMENTACOMMENT ON TABLE prjtaskuser IS 'Project Task user information'; publicadminfalse612*00 prjtaskuserACLREVOKE ALL ON TABLE prjtaskuser FROM PUBLIC; REVOKE ALL ON TABLE prjtaskuser FROM admin; GRANT ALL ON TABLE prjtaskuser TO admin; GRANT ALL ON TABLE prjtaskuser TO xtrole; publicadminfalse612e125981987prjtaskuser_prjtaskuser_id_seqSEQUENCECREATE SEQUENCE prjtaskuser_prjtaskuser_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 5DROP SEQUENCE public.prjtaskuser_prjtaskuser_id_seq; publicadminfalse8612*00prjtaskuser_prjtaskuser_id_seqSEQUENCE OWNED BYSALTER SEQUENCE prjtaskuser_prjtaskuser_id_seq OWNED BY prjtaskuser.prjtaskuser_id; publicadminfalse613*00prjtaskuser_prjtaskuser_id_seqACLREVOKE ALL ON SEQUENCE prjtaskuser_prjtaskuser_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE prjtaskuser_prjtaskuser_id_seq FROM admin; GRANT ALL ON SEQUENCE prjtaskuser_prjtaskuser_id_seq TO admin; GRANT ALL ON SEQUENCE prjtaskuser_prjtaskuser_id_seq TO xtrole; publicadminfalse613f125981989prjtypeTABLECREATE TABLE prjtype ( prjtype_id integer NOT NULL, prjtype_code text, prjtype_descr text, prjtype_active boolean DEFAULT true ); DROP TABLE public.prjtype; publicadminfalse66768*00prjtypeACLREVOKE ALL ON TABLE prjtype FROM PUBLIC; REVOKE ALL ON TABLE prjtype FROM admin; GRANT ALL ON TABLE prjtype TO admin; GRANT ALL ON TABLE prjtype TO xtrole; publicadminfalse614g125981996prjtype_prjtype_id_seqSEQUENCExCREATE SEQUENCE prjtype_prjtype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.prjtype_prjtype_id_seq; publicadminfalse8614*00prjtype_prjtype_id_seqSEQUENCE OWNED BYCALTER SEQUENCE prjtype_prjtype_id_seq OWNED BY prjtype.prjtype_id; publicadminfalse615*00prjtype_prjtype_id_seqACLREVOKE ALL ON SEQUENCE prjtype_prjtype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE prjtype_prjtype_id_seq FROM admin; GRANT ALL ON SEQUENCE prjtype_prjtype_id_seq TO admin; GRANT ALL ON SEQUENCE prjtype_prjtype_id_seq TO xtrole; publicadminfalse615h125981998prodcat_prodcat_id_seqSEQUENCECREATE SEQUENCE prodcat_prodcat_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.prodcat_prodcat_id_seq; publicadminfalse8*00prodcat_prodcat_id_seqACLREVOKE ALL ON SEQUENCE prodcat_prodcat_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE prodcat_prodcat_id_seq FROM admin; GRANT ALL ON SEQUENCE prodcat_prodcat_id_seq TO admin; GRANT ALL ON SEQUENCE prodcat_prodcat_id_seq TO xtrole; publicadminfalse616i125982000qryheadTABLEZCREATE TABLE qryhead ( qryhead_id integer NOT NULL, qryhead_name text NOT NULL, qryhead_descrip text, qryhead_notes text, qryhead_username text DEFAULT geteffectivextuser() NOT NULL, qryhead_updated date DEFAULT ('now'::text)::date NOT NULL, CONSTRAINT qryhead_qryhead_name_check CHECK ((qryhead_name <> ''::text)) ); DROP TABLE public.qryhead; publicadminfalse6678667966808*00 TABLE qryheadCOMMENTxCOMMENT ON TABLE qryhead IS 'A header record for a set of queries to be run sequentially. One use is for data export.'; publicadminfalse617*00COLUMN qryhead.qryhead_idCOMMENTzCOMMENT ON COLUMN qryhead.qryhead_id IS 'The primary key, holding an internal value used to cross-reference this table.'; publicadminfalse617*00COLUMN qryhead.qryhead_nameCOMMENTcCOMMENT ON COLUMN qryhead.qryhead_name IS 'The user-assigned short name for this set of queries.'; publicadminfalse617*00COLUMN qryhead.qryhead_descripCOMMENTjCOMMENT ON COLUMN qryhead.qryhead_descrip IS 'A long description of the purpose of this set of queries.'; publicadminfalse617*00COLUMN qryhead.qryhead_notesCOMMENTWCOMMENT ON COLUMN qryhead.qryhead_notes IS 'General information about this queryset.'; publicadminfalse617*00COLUMN qryhead.qryhead_usernameCOMMENTmCOMMENT ON COLUMN qryhead.qryhead_username IS 'The name of the user who last modified this qryhead record.'; publicadminfalse617*00COLUMN qryhead.qryhead_updatedCOMMENTYCOMMENT ON COLUMN qryhead.qryhead_updated IS 'The date this qryhead was last modified.'; publicadminfalse617*00qryheadACLREVOKE ALL ON TABLE qryhead FROM PUBLIC; REVOKE ALL ON TABLE qryhead FROM admin; GRANT ALL ON TABLE qryhead TO admin; GRANT ALL ON TABLE qryhead TO xtrole; publicadminfalse617j125982009qryhead_qryhead_id_seqSEQUENCExCREATE SEQUENCE qryhead_qryhead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.qryhead_qryhead_id_seq; publicadminfalse8617*00qryhead_qryhead_id_seqSEQUENCE OWNED BYCALTER SEQUENCE qryhead_qryhead_id_seq OWNED BY qryhead.qryhead_id; publicadminfalse618*00qryhead_qryhead_id_seqACLREVOKE ALL ON SEQUENCE qryhead_qryhead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE qryhead_qryhead_id_seq FROM admin; GRANT ALL ON SEQUENCE qryhead_qryhead_id_seq TO admin; GRANT ALL ON SEQUENCE qryhead_qryhead_id_seq TO xtrole; publicadminfalse618k125982011qryitemTABLECREATE TABLE qryitem ( qryitem_id integer NOT NULL, qryitem_qryhead_id integer NOT NULL, qryitem_name text NOT NULL, qryitem_order integer NOT NULL, qryitem_src text NOT NULL, qryitem_group text, qryitem_detail text NOT NULL, qryitem_notes text DEFAULT ''::text NOT NULL, qryitem_username text DEFAULT geteffectivextuser() NOT NULL, qryitem_updated date DEFAULT ('now'::text)::date NOT NULL, CONSTRAINT qryitem_qryitem_detail_check CHECK ((btrim(qryitem_detail) <> ''::text)), CONSTRAINT qryitem_qryitem_src_check CHECK ((qryitem_src = ANY (ARRAY['REL'::text, 'MQL'::text, 'CUSTOM'::text]))) ); DROP TABLE public.qryitem; publicadminfalse668166826683668566868*00 TABLE qryitemCOMMENTdCOMMENT ON TABLE qryitem IS 'The description of a query to be run as part of a set (see qryhead).'; publicadminfalse619*00COLUMN qryitem.qryitem_idCOMMENTzCOMMENT ON COLUMN qryitem.qryitem_id IS 'The primary key, holding an internal value used to cross-reference this table.'; publicadminfalse619*00!COLUMN qryitem.qryitem_qryhead_idCOMMENT|COMMENT ON COLUMN qryitem.qryitem_qryhead_id IS 'The primary key of the query set to which this individual query belongs.'; publicadminfalse619*00COLUMN qryitem.qryitem_orderCOMMENToCOMMENT ON COLUMN qryitem.qryitem_order IS 'The order in which query items within a query set should be run.'; publicadminfalse619*00COLUMN qryitem.qryitem_srcCOMMENTCOMMENT ON COLUMN qryitem.qryitem_src IS 'The source of the query. If the qryitem_src is "REL" then the qryitem_group and _detail name a particular table or view and all rows will be returned. If the source is "MQL" then the qryitem_group and _detail name a pre-defined MetaSQL query in the metasql table. If the source is "CUSTOM" then the qryitem_detail contains the full MetaSQL text of the query to run.'; publicadminfalse619*00COLUMN qryitem.qryitem_groupCOMMENTCOMMENT ON COLUMN qryitem.qryitem_group IS 'Information to help find the query to run. If the qryitem_src is "REL" then this is the schema in which to find the table or view to query and all rows will be returned (the qryitem_detail names the table or view). If the qryitem_src is "MQL" then this is the group of the query in the metasql table to run (the name is in qryitem_detail). If the qryitem_src IS "CUSTOM" then this ignored.'; publicadminfalse619*00COLUMN qryitem.qryitem_detailCOMMENTwCOMMENT ON COLUMN qryitem.qryitem_detail IS 'The particular query to run. If the qryitem_src is "REL" then this is the name of the table or view to query and all rows will be returned. If the qryitem_src is "MQL" then this is the name of the query in the metasql table to run. If the qryitem_src IS "CUSTOM" then this is the actual MetaSQL query text to be parsed and run.'; publicadminfalse619*00COLUMN qryitem.qryitem_notesCOMMENTTCOMMENT ON COLUMN qryitem.qryitem_notes IS 'General information about this query.'; publicadminfalse619*00COLUMN qryitem.qryitem_usernameCOMMENTmCOMMENT ON COLUMN qryitem.qryitem_username IS 'The name of the user who last modified this qryitem record.'; publicadminfalse619*00COLUMN qryitem.qryitem_updatedCOMMENTYCOMMENT ON COLUMN qryitem.qryitem_updated IS 'The date this qryitem was last modified.'; publicadminfalse619*00qryitemACLREVOKE ALL ON TABLE qryitem FROM PUBLIC; REVOKE ALL ON TABLE qryitem FROM admin; GRANT ALL ON TABLE qryitem TO admin; GRANT ALL ON TABLE qryitem TO xtrole; publicadminfalse619l125982022qryitem_qryitem_id_seqSEQUENCExCREATE SEQUENCE qryitem_qryitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.qryitem_qryitem_id_seq; publicadminfalse8619*00qryitem_qryitem_id_seqSEQUENCE OWNED BYCALTER SEQUENCE qryitem_qryitem_id_seq OWNED BY qryitem.qryitem_id; publicadminfalse620*00qryitem_qryitem_id_seqACLREVOKE ALL ON SEQUENCE qryitem_qryitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE qryitem_qryitem_id_seq FROM admin; GRANT ALL ON SEQUENCE qryitem_qryitem_id_seq TO admin; GRANT ALL ON SEQUENCE qryitem_qryitem_id_seq TO xtrole; publicadminfalse620m125982024quhead_quhead_id_seqSEQUENCEvCREATE SEQUENCE quhead_quhead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.quhead_quhead_id_seq; publicadminfalse8*00quhead_quhead_id_seqACLREVOKE ALL ON SEQUENCE quhead_quhead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE quhead_quhead_id_seq FROM admin; GRANT ALL ON SEQUENCE quhead_quhead_id_seq TO admin; GRANT ALL ON SEQUENCE quhead_quhead_id_seq TO xtrole; publicadminfalse621n125982026quitem_quitem_id_seqSEQUENCEvCREATE SEQUENCE quitem_quitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.quitem_quitem_id_seq; publicadminfalse8*00quitem_quitem_id_seqACLREVOKE ALL ON SEQUENCE quitem_quitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE quitem_quitem_id_seq FROM admin; GRANT ALL ON SEQUENCE quitem_quitem_id_seq TO admin; GRANT ALL ON SEQUENCE quitem_quitem_id_seq TO xtrole; publicadminfalse622o125982028rcalitemTABLEECREATE TABLE rcalitem ( rcalitem_id integer DEFAULT nextval(('"xcalitem_xcalitem_id_seq"'::text)::regclass) NOT NULL, rcalitem_calhead_id integer, rcalitem_offsettype character(1), rcalitem_offsetcount integer, rcalitem_periodtype character(1), rcalitem_periodcount integer, rcalitem_name text ); DROP TABLE public.rcalitem; publicadminfalse66878*00TABLE rcalitemCOMMENTCCOMMENT ON TABLE rcalitem IS 'Relative Calendar Item information'; publicadminfalse623*00rcalitemACLREVOKE ALL ON TABLE rcalitem FROM PUBLIC; REVOKE ALL ON TABLE rcalitem FROM admin; GRANT ALL ON TABLE rcalitem TO admin; GRANT ALL ON TABLE rcalitem TO xtrole; publicadminfalse623p125982035recurTABLECREATE TABLE recur ( recur_id integer NOT NULL, recur_parent_id integer NOT NULL, recur_parent_type text NOT NULL, recur_period text NOT NULL, recur_freq integer DEFAULT 1 NOT NULL, recur_start timestamp with time zone DEFAULT now(), recur_end timestamp with time zone, recur_max integer, recur_data text, CONSTRAINT recur_recur_period_check CHECK ((recur_period = ANY (ARRAY['m'::text, 'H'::text, 'D'::text, 'W'::text, 'M'::text, 'Y'::text, 'C'::text]))) ); DROP TABLE public.recur; publicadminfalse6689669066918*00 TABLE recurCOMMENTACOMMENT ON TABLE recur IS 'Track recurring events and objects.'; publicadminfalse624*00COLUMN recur.recur_idCOMMENTNCOMMENT ON COLUMN recur.recur_id IS 'Internal ID of this recurrence record.'; publicadminfalse624*00COLUMN recur.recur_parent_idCOMMENT_COMMENT ON COLUMN recur.recur_parent_id IS 'The internal ID of the event/object that recurs.'; publicadminfalse624*00COLUMN recur.recur_parent_typeCOMMENTiCOMMENT ON COLUMN recur.recur_parent_type IS 'The table in which the parent event or object is stored.'; publicadminfalse624*00COLUMN recur.recur_periodCOMMENTCOMMENT ON COLUMN recur.recur_period IS 'With recur_freq, how often this event recurs. Values are "m" for every minute, "H" for every hour, "D" for daily, "W" for weekly, "M" for monthly, "Y" for yearly, and "C" for customized or complex.'; publicadminfalse624*00COLUMN recur.recur_freqCOMMENTCOMMENT ON COLUMN recur.recur_freq IS 'With recur_period, how often this event recurs. Values are integers counts of recur_periods. For example, if recur_freq = 2 and recur_period = w then the event recurs every 2 weeks.'; publicadminfalse624*00COLUMN recur.recur_startCOMMENT[COMMENT ON COLUMN recur.recur_start IS 'The first date/time when the event should occur.'; publicadminfalse624*00COLUMN recur.recur_endCOMMENTCOMMENT ON COLUMN recur.recur_end IS 'The last date/time when the event should occur. NULL means there is no end date/time and the event should recur forever.'; publicadminfalse624*00COLUMN recur.recur_maxCOMMENTCOMMENT ON COLUMN recur.recur_max IS 'The maximum number of recurrence events to create at one time. If this is NULL then when new events are created, a system-wide default will limit the number.'; publicadminfalse624*00COLUMN recur.recur_dataCOMMENTCOMMENT ON COLUMN recur.recur_data IS 'Not yet used and format still undetermined. Additional data to describe how to apply the period and frequency, particularly when period = "C".'; publicadminfalse624*00recurACLREVOKE ALL ON TABLE recur FROM PUBLIC; REVOKE ALL ON TABLE recur FROM admin; GRANT ALL ON TABLE recur TO admin; GRANT ALL ON TABLE recur TO xtrole; publicadminfalse624q125982044recur_recur_id_seqSEQUENCEtCREATE SEQUENCE recur_recur_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; )DROP SEQUENCE public.recur_recur_id_seq; publicadminfalse8624*00recur_recur_id_seqSEQUENCE OWNED BY;ALTER SEQUENCE recur_recur_id_seq OWNED BY recur.recur_id; publicadminfalse625*00recur_recur_id_seqACLREVOKE ALL ON SEQUENCE recur_recur_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE recur_recur_id_seq FROM admin; GRANT ALL ON SEQUENCE recur_recur_id_seq TO admin; GRANT ALL ON SEQUENCE recur_recur_id_seq TO xtrole; publicadminfalse625r125982046 recurtypeTABLETCREATE TABLE recurtype ( recurtype_id integer NOT NULL, recurtype_type text NOT NULL, recurtype_table text NOT NULL, recurtype_donecheck text NOT NULL, recurtype_schedcol text NOT NULL, recurtype_limit text, recurtype_copyfunc text NOT NULL, recurtype_copyargs text[] NOT NULL, recurtype_delfunc text ); DROP TABLE public.recurtype; publicadminfalse8*00TABLE recurtypeCOMMENTCOMMENT ON TABLE recurtype IS 'Describes the properties of recurring items/events in way that can be used by stored procedures to maintain the recurrence.'; publicadminfalse626*00COLUMN recurtype.recurtype_idCOMMENT_COMMENT ON COLUMN recurtype.recurtype_id IS 'The internal id of this recurrence description.'; publicadminfalse626*00COLUMN recurtype.recurtype_typeCOMMENTCOMMENT ON COLUMN recurtype.recurtype_type IS 'A code value used by the RecurrenceWidget and the code that uses it to describe the item/event that will recur. Examples include "INCDT" for CRM Incidents and "J" for Projects.'; publicadminfalse626*00 COLUMN recurtype.recurtype_tableCOMMENTgCOMMENT ON COLUMN recurtype.recurtype_table IS 'The table that holds the item/event that will recur.'; publicadminfalse626*00$COLUMN recurtype.recurtype_donecheckCOMMENTCOMMENT ON COLUMN recurtype.recurtype_donecheck IS 'A boolean expression that returns TRUE if an individual item/event record in the recurtype_table has already been completed.'; publicadminfalse626*00#COLUMN recurtype.recurtype_schedcolCOMMENTCOMMENT ON COLUMN recurtype.recurtype_schedcol IS 'The name of the column in the recurtype_table holding the date or timestamp by which the item is scheduled to be completed or at which the event is supposed to occur.'; publicadminfalse626*00 COLUMN recurtype.recurtype_limitCOMMENTCOMMENT ON COLUMN recurtype.recurtype_limit IS 'A boolean expression that returns TRUE if the current user should see the row in the recurtype_table. NULL indicates there is no specific limitation. For example, the maintainance of recurring TODO items should restricted to those items belonging to the user unless s/he has been granted the privilege to modify other people''s todo lists.'; publicadminfalse626*00#COLUMN recurtype.recurtype_copyfuncCOMMENTXCOMMENT ON COLUMN recurtype.recurtype_copyfunc IS 'The name of the function to copy an existing item/event record. The copy function is expected to take at least 2 arguments: the id of the item to copy and the new date/timestamp. If the function accepts more than 2, it must be able to accept NULL values for the 3rd and following arguments.'; publicadminfalse626*00#COLUMN recurtype.recurtype_copyargsCOMMENTCOMMENT ON COLUMN recurtype.recurtype_copyargs IS 'An abbreviated argument list for the copy function. This is used to determine whether the second argument must be cast to a date or a timestamp, and to figure out how many additional arguments to pass.'; publicadminfalse626*00"COLUMN recurtype.recurtype_delfuncCOMMENTCOMMENT ON COLUMN recurtype.recurtype_delfunc IS 'The name of the function to delete an existing item/event record. The function is expected to take exactly one argument: the id of the item to delete. NULL indicates there is no delete function and that an SQL DELETE statement can be used. In this case, the id column name will be built as the recurtype_table concatenated with the "_id" suffix.'; publicadminfalse626*00 recurtypeACLREVOKE ALL ON TABLE recurtype FROM PUBLIC; REVOKE ALL ON TABLE recurtype FROM admin; GRANT ALL ON TABLE recurtype TO admin; GRANT ALL ON TABLE recurtype TO xtrole; publicadminfalse626s125982052recurtype_recurtype_id_seqSEQUENCE|CREATE SEQUENCE recurtype_recurtype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 1DROP SEQUENCE public.recurtype_recurtype_id_seq; publicadminfalse6268*00recurtype_recurtype_id_seqSEQUENCE OWNED BYKALTER SEQUENCE recurtype_recurtype_id_seq OWNED BY recurtype.recurtype_id; publicadminfalse627*00recurtype_recurtype_id_seqACLREVOKE ALL ON SEQUENCE recurtype_recurtype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE recurtype_recurtype_id_seq FROM admin; GRANT ALL ON SEQUENCE recurtype_recurtype_id_seq TO admin; GRANT ALL ON SEQUENCE recurtype_recurtype_id_seq TO xtrole; publicadminfalse627t125982054recv_recv_id_seqSEQUENCErCREATE SEQUENCE recv_recv_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 'DROP SEQUENCE public.recv_recv_id_seq; publicadminfalse8599*00recv_recv_id_seqSEQUENCE OWNED BY7ALTER SEQUENCE recv_recv_id_seq OWNED BY recv.recv_id; publicadminfalse628*00recv_recv_id_seqACLREVOKE ALL ON SEQUENCE recv_recv_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE recv_recv_id_seq FROM admin; GRANT ALL ON SEQUENCE recv_recv_id_seq TO admin; GRANT ALL ON SEQUENCE recv_recv_id_seq TO xtrole; publicadminfalse628u125982056remittoVIEW"CREATE VIEW remitto AS SELECT (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_name'::text)) AS remitto_name, (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_address1'::text)) AS remitto_address1, (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_address2'::text)) AS remitto_address2, (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_address3'::text)) AS remitto_address3, (((((SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_city'::text)) || ' '::text) || (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_state'::text))) || ' '::text) || (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_zipcode'::text))) AS remitto_citystatezip, (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_country'::text)) AS remitto_country, (SELECT metric.metric_value FROM metric WHERE (metric.metric_name = 'remitto_phone'::text)) AS remitto_phone; DROP VIEW public.remitto; publicadminfalse86458*00remittoACLREVOKE ALL ON TABLE remitto FROM PUBLIC; REVOKE ALL ON TABLE remitto FROM admin; GRANT ALL ON TABLE remitto TO admin; GRANT ALL ON TABLE remitto TO xtrole; publicadminfalse629v125982060rjctcodeTABLE CREATE TABLE rjctcode ( rjctcode_id integer DEFAULT nextval(('"rjctcode_rjctcode_id_seq"'::text)::regclass) NOT NULL, rjctcode_code text NOT NULL, rjctcode_descrip text, CONSTRAINT rjctcode_rjctcode_code_check CHECK ((rjctcode_code <> ''::text)) ); DROP TABLE public.rjctcode; publicadminfalse669366948*00TABLE rjctcodeCOMMENT8COMMENT ON TABLE rjctcode IS 'Reject Code information'; publicadminfalse630*00rjctcodeACLREVOKE ALL ON TABLE rjctcode FROM PUBLIC; REVOKE ALL ON TABLE rjctcode FROM admin; GRANT ALL ON TABLE rjctcode TO admin; GRANT ALL ON TABLE rjctcode TO xtrole; publicadminfalse630w125982068rjctcode_rjctcode_id_seqSEQUENCECREATE SEQUENCE rjctcode_rjctcode_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; /DROP SEQUENCE public.rjctcode_rjctcode_id_seq; publicadminfalse8*00rjctcode_rjctcode_id_seqACLREVOKE ALL ON SEQUENCE rjctcode_rjctcode_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE rjctcode_rjctcode_id_seq FROM admin; GRANT ALL ON SEQUENCE rjctcode_rjctcode_id_seq TO admin; GRANT ALL ON SEQUENCE rjctcode_rjctcode_id_seq TO xtrole; publicadminfalse631x125982070rsncode_rsncode_id_seqSEQUENCExCREATE SEQUENCE rsncode_rsncode_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.rsncode_rsncode_id_seq; publicadminfalse8197*00rsncode_rsncode_id_seqSEQUENCE OWNED BYCALTER SEQUENCE rsncode_rsncode_id_seq OWNED BY rsncode.rsncode_id; publicadminfalse632*00rsncode_rsncode_id_seqACLREVOKE ALL ON SEQUENCE rsncode_rsncode_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE rsncode_rsncode_id_seq FROM admin; GRANT ALL ON SEQUENCE rsncode_rsncode_id_seq TO admin; GRANT ALL ON SEQUENCE rsncode_rsncode_id_seq TO xtrole; publicadminfalse632y125982072saleTABLE2CREATE TABLE sale ( sale_id integer DEFAULT nextval(('"sale_sale_id_seq"'::text)::regclass) NOT NULL, sale_name text NOT NULL, sale_descrip text, sale_ipshead_id integer, sale_startdate date, sale_enddate date, CONSTRAINT sale_sale_name_check CHECK ((sale_name <> ''::text)) ); DROP TABLE public.sale; publicadminfalse669566968*00 TABLE saleCOMMENT-COMMENT ON TABLE sale IS 'Sale information'; publicadminfalse633*00saleACLREVOKE ALL ON TABLE sale FROM PUBLIC; REVOKE ALL ON TABLE sale FROM admin; GRANT ALL ON TABLE sale TO admin; GRANT ALL ON TABLE sale TO xtrole; publicadminfalse633z125982080sale_sale_id_seqSEQUENCErCREATE SEQUENCE sale_sale_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 'DROP SEQUENCE public.sale_sale_id_seq; publicadminfalse8*00sale_sale_id_seqACLREVOKE ALL ON SEQUENCE sale_sale_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE sale_sale_id_seq FROM admin; GRANT ALL ON SEQUENCE sale_sale_id_seq TO admin; GRANT ALL ON SEQUENCE sale_sale_id_seq TO xtrole; publicadminfalse634{125982082salesaccnt_salesaccnt_id_seqSEQUENCECREATE SEQUENCE salesaccnt_salesaccnt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; 3DROP SEQUENCE public.salesaccnt_salesaccnt_id_seq; publicadminfalse8*00salesaccnt_salesaccnt_id_seqACLREVOKE ALL ON SEQUENCE salesaccnt_salesaccnt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE salesaccnt_salesaccnt_id_seq FROM admin; GRANT ALL ON SEQUENCE salesaccnt_salesaccnt_id_seq TO admin; GRANT ALL ON SEQUENCE salesaccnt_salesaccnt_id_seq TO xtrole; publicadminfalse635|125982084salescat_salescat_id_seqSEQUENCEzCREATE SEQUENCE salescat_salescat_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.salescat_salescat_id_seq; publicadminfalse8198*00salescat_salescat_id_seqSEQUENCE OWNED BYGALTER SEQUENCE salescat_salescat_id_seq OWNED BY salescat.salescat_id; publicadminfalse636*00salescat_salescat_id_seqACLREVOKE ALL ON SEQUENCE salescat_salescat_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE salescat_salescat_id_seq FROM admin; GRANT ALL ON SEQUENCE salescat_salescat_id_seq TO admin; GRANT ALL ON SEQUENCE salescat_salescat_id_seq TO xtrole; publicadminfalse636"125987634 saleshistoryVIEWCREATE VIEW saleshistory AS SELECT data.cohist_id, data.cohist_cust_id, data.cohist_itemsite_id, data.cohist_shipdate, data.cohist_shipvia, data.cohist_ordernumber, data.cohist_orderdate, data.cohist_invcnumber, data.cohist_invcdate, data.cohist_qtyshipped, data.cohist_unitprice, data.cohist_shipto_id, data.cohist_salesrep_id, data.cohist_duedate, data.cohist_imported, data.cohist_billtoname, data.cohist_billtoaddress1, data.cohist_billtoaddress2, data.cohist_billtoaddress3, data.cohist_billtocity, data.cohist_billtostate, data.cohist_billtozip, data.cohist_shiptoname, data.cohist_shiptoaddress1, data.cohist_shiptoaddress2, data.cohist_shiptoaddress3, data.cohist_shiptocity, data.cohist_shiptostate, data.cohist_shiptozip, data.cohist_commission, data.cohist_commissionpaid, data.cohist_unitcost, data.cohist_misc_type, data.cohist_misc_descrip, data.cohist_misc_id, data.cohist_doctype, data.cohist_promisedate, data.cohist_ponumber, data.cohist_curr_id, data.cohist_sequence, data.cohist_taxtype_id, data.cohist_taxzone_id, data.cohist_cohead_ccpay_id, data.cohist_saletype_id, data.cohist_shipzone_id, data.cohead_id, data.cust_id, data.cust_number, data.cust_name, data.cust_curr_id, data.custtype_id, data.custtype_code, data.custtype_descrip, data.salesrep_id, data.salesrep_number, data.salesrep_name, data.shipzone_id, data.shipzone_name, data.shipzone_descrip, data.saletype_code, data.saletype_descr, data.itemsite_id, data.warehous_id, data.warehous_code, data.warehous_descrip, data.item_id, data.item_number, data.item_descrip1, data.item_descrip2, data.itemdescription, data.itemnumber, data.prodcat_id, data.prodcat_code, data.classcode_id, data.classcode_code, data.basecommission, data.baseunitprice, data.custunitprice, round((data.cohist_qtyshipped * data.cohist_unitprice), 2) AS extprice, round((data.cohist_qtyshipped * data.baseunitprice), 2) AS baseextprice, round((data.cohist_qtyshipped * data.custunitprice), 2) AS custextprice, round((data.cohist_qtyshipped * data.cohist_unitcost), 4) AS extcost, round(((data.cohist_qtyshipped * data.baseunitprice) - (data.cohist_qtyshipped * data.cohist_unitcost)), 2) AS margin, CASE WHEN (round((data.cohist_qtyshipped * data.baseunitprice), 2) > 0.0) THEN (round(((data.cohist_qtyshipped * data.baseunitprice) - (data.cohist_qtyshipped * data.cohist_unitcost)), 2) / round((data.cohist_qtyshipped * data.baseunitprice), 2)) ELSE 0.0 END AS marginpercent, currconcat(data.cohist_curr_id) AS currabbr, 'qty'::text AS cohist_qtyshipped_xtnumericrole, 'salesprice'::text AS cohist_unitprice_xtnumericrole, 'salesprice'::text AS baseunitprice_xtnumericrole, 'curr'::text AS custunitprice_xtnumericrole, 'curr'::text AS custextprice_xtnumericrole, 'curr'::text AS extprice_xtnumericrole, 'curr'::text AS baseextprice_xtnumericrole, 'cost'::text AS cohist_unitcost_xtnumericrole, 'curr'::text AS extcost_xtnumericrole, 'curr'::text AS margin_xtnumericrole, 'percent'::text AS marginpercent_xtnumericrole, 'curr'::text AS cohist_commission_xtnumericrole, 'curr'::text AS basecommission_xtnumericrole FROM (SELECT cohist.cohist_id, cohist.cohist_cust_id, cohist.cohist_itemsite_id, cohist.cohist_shipdate, cohist.cohist_shipvia, cohist.cohist_ordernumber, cohist.cohist_orderdate, cohist.cohist_invcnumber, cohist.cohist_invcdate, cohist.cohist_qtyshipped, cohist.cohist_unitprice, cohist.cohist_shipto_id, cohist.cohist_salesrep_id, cohist.cohist_duedate, cohist.cohist_imported, cohist.cohist_billtoname, cohist.cohist_billtoaddress1, cohist.cohist_billtoaddress2, cohist.cohist_billtoaddress3, cohist.cohist_billtocity, cohist.cohist_billtostate, cohist.cohist_billtozip, cohist.cohist_shiptoname, cohist.cohist_shiptoaddress1, cohist.cohist_shiptoaddress2, cohist.cohist_shiptoaddress3, cohist.cohist_shiptocity, cohist.cohist_shiptostate, cohist.cohist_shiptozip, cohist.cohist_commission, cohist.cohist_commissionpaid, cohist.cohist_unitcost, cohist.cohist_misc_type, cohist.cohist_misc_descrip, cohist.cohist_misc_id, cohist.cohist_doctype, cohist.cohist_promisedate, cohist.cohist_ponumber, cohist.cohist_curr_id, cohist.cohist_sequence, cohist.cohist_taxtype_id, cohist.cohist_taxzone_id, cohist.cohist_cohead_ccpay_id, cohist.cohist_saletype_id, cohist.cohist_shipzone_id, COALESCE(cohead.cohead_id, (-1)) AS cohead_id, custinfo.cust_id, custinfo.cust_number, custinfo.cust_name, custinfo.cust_curr_id, custtype.custtype_id, custtype.custtype_code, custtype.custtype_descrip, salesrep.salesrep_id, salesrep.salesrep_number, salesrep.salesrep_name, shipzone.shipzone_id, shipzone.shipzone_name, shipzone.shipzone_descrip, saletype.saletype_code, saletype.saletype_descr, itemsite.itemsite_id, site.warehous_id, site.warehous_code, site.warehous_descrip, item.item_id, item.item_number, item.item_descrip1, item.item_descrip2, ((item.item_descrip1 || ' '::text) || item.item_descrip2) AS itemdescription, COALESCE(item.item_number, cohist.cohist_misc_descrip) AS itemnumber, prodcat.prodcat_id, prodcat.prodcat_code, classcode.classcode_id, classcode.classcode_code, currtobase(cohist.cohist_curr_id, cohist.cohist_commission, cohist.cohist_invcdate) AS basecommission, currtobase(cohist.cohist_curr_id, cohist.cohist_unitprice, cohist.cohist_invcdate) AS baseunitprice, currtocurr(cohist.cohist_curr_id, custinfo.cust_curr_id, cohist.cohist_unitprice, cohist.cohist_invcdate) AS custunitprice FROM ((((((((((((cohist JOIN custinfo ON ((custinfo.cust_id = cohist.cohist_cust_id))) LEFT JOIN cohead ON ((cohead.cohead_number = cohist.cohist_ordernumber))) LEFT JOIN custtype ON ((custtype.custtype_id = custinfo.cust_custtype_id))) LEFT JOIN salesrep ON ((salesrep.salesrep_id = cohist.cohist_salesrep_id))) LEFT JOIN shiptoinfo ON ((shiptoinfo.shipto_id = cohist.cohist_shipto_id))) LEFT JOIN shipzone ON ((shipzone.shipzone_id = shiptoinfo.shipto_shipzone_id))) LEFT JOIN saletype ON ((saletype.saletype_id = cohist.cohist_saletype_id))) JOIN itemsite ON ((itemsite.itemsite_id = cohist.cohist_itemsite_id))) JOIN site() site(warehous_id, warehous_code, warehous_descrip, warehous_fob, warehous_active, warehous_counttag_prefix, warehous_counttag_number, warehous_bol_prefix, warehous_bol_number, warehous_shipping, warehous_useslips, warehous_usezones, warehous_aislesize, warehous_aislealpha, warehous_racksize, warehous_rackalpha, warehous_binsize, warehous_binalpha, warehous_locationsize, warehous_locationalpha, warehous_enforcearbl, warehous_default_accnt_id, warehous_shipping_commission, warehous_cntct_id, warehous_addr_id, warehous_transit, warehous_shipform_id, warehous_shipvia_id, warehous_shipcomments, warehous_costcat_id, warehous_sitetype_id, warehous_taxzone_id, warehous_sequence) ON ((site.warehous_id = itemsite.itemsite_warehous_id))) JOIN item ON ((item.item_id = itemsite.itemsite_item_id))) JOIN prodcat ON ((prodcat.prodcat_id = item.item_prodcat_id))) JOIN classcode ON ((classcode.classcode_id = item.item_classcode_id)))) data; DROP VIEW public.saleshistory; publicadminfalse86858*00VIEW saleshistoryCOMMENTPCOMMENT ON VIEW saleshistory IS 'Single point for sales history calculations.'; publicadminfalse802*00 saleshistoryACLREVOKE ALL ON TABLE saleshistory FROM PUBLIC; REVOKE ALL ON TABLE saleshistory FROM admin; GRANT ALL ON TABLE saleshistory TO admin; GRANT ALL ON TABLE saleshistory TO xtrole; publicadminfalse802#125987639saleshistorymiscVIEWCREATE VIEW saleshistorymisc AS SELECT data.cohist_id, data.cohist_cust_id, data.cohist_itemsite_id, data.cohist_shipdate, data.cohist_shipvia, data.cohist_ordernumber, data.cohist_orderdate, data.cohist_invcnumber, data.cohist_invcdate, data.cohist_qtyshipped, data.cohist_unitprice, data.cohist_shipto_id, data.cohist_salesrep_id, data.cohist_duedate, data.cohist_imported, data.cohist_billtoname, data.cohist_billtoaddress1, data.cohist_billtoaddress2, data.cohist_billtoaddress3, data.cohist_billtocity, data.cohist_billtostate, data.cohist_billtozip, data.cohist_shiptoname, data.cohist_shiptoaddress1, data.cohist_shiptoaddress2, data.cohist_shiptoaddress3, data.cohist_shiptocity, data.cohist_shiptostate, data.cohist_shiptozip, data.cohist_commission, data.cohist_commissionpaid, data.cohist_unitcost, data.cohist_misc_type, data.cohist_misc_descrip, data.cohist_misc_id, data.cohist_doctype, data.cohist_promisedate, data.cohist_ponumber, data.cohist_curr_id, data.cohist_sequence, data.cohist_taxtype_id, data.cohist_taxzone_id, data.cohist_cohead_ccpay_id, data.cohist_saletype_id, data.cohist_shipzone_id, data.cohead_id, data.cust_id, data.cust_number, data.cust_name, data.cust_curr_id, data.custtype_id, data.custtype_code, data.custtype_descrip, data.salesrep_id, data.salesrep_number, data.salesrep_name, data.shipzone_id, data.shipzone_name, data.shipzone_descrip, data.saletype_code, data.saletype_descr, data.itemsite_id, data.warehous_id, data.warehous_code, data.warehous_descrip, data.item_id, data.item_number, data.item_descrip1, data.item_descrip2, data.itemdescription, data.itemnumber, data.prodcat_id, data.prodcat_code, data.classcode_id, data.classcode_code, data.basecommission, data.baseunitprice, data.custunitprice, round((data.cohist_qtyshipped * data.cohist_unitprice), 2) AS extprice, round((data.cohist_qtyshipped * data.baseunitprice), 2) AS baseextprice, round((data.cohist_qtyshipped * data.custunitprice), 2) AS custextprice, round((data.cohist_qtyshipped * data.cohist_unitcost), 4) AS extcost, round(((data.cohist_qtyshipped * data.baseunitprice) - (data.cohist_qtyshipped * data.cohist_unitcost)), 2) AS margin, CASE WHEN (round((data.cohist_qtyshipped * data.baseunitprice), 2) > 0.0) THEN (round(((data.cohist_qtyshipped * data.baseunitprice) - (data.cohist_qtyshipped * data.cohist_unitcost)), 2) / round((data.cohist_qtyshipped * data.baseunitprice), 2)) ELSE 0.0 END AS marginpercent, currconcat(data.cohist_curr_id) AS currabbr, 'qty'::text AS cohist_qtyshipped_xtnumericrole, 'salesprice'::text AS cohist_unitprice_xtnumericrole, 'salesprice'::text AS baseunitprice_xtnumericrole, 'curr'::text AS custunitprice_xtnumericrole, 'curr'::text AS custextprice_xtnumericrole, 'curr'::text AS extprice_xtnumericrole, 'curr'::text AS baseextprice_xtnumericrole, 'cost'::text AS cohist_unitcost_xtnumericrole, 'curr'::text AS extcost_xtnumericrole, 'curr'::text AS margin_xtnumericrole, 'percent'::text AS marginpercent_xtnumericrole, 'curr'::text AS cohist_commission_xtnumericrole, 'curr'::text AS basecommission_xtnumericrole FROM (SELECT cohist.cohist_id, cohist.cohist_cust_id, cohist.cohist_itemsite_id, cohist.cohist_shipdate, cohist.cohist_shipvia, cohist.cohist_ordernumber, cohist.cohist_orderdate, cohist.cohist_invcnumber, cohist.cohist_invcdate, cohist.cohist_qtyshipped, cohist.cohist_unitprice, cohist.cohist_shipto_id, cohist.cohist_salesrep_id, cohist.cohist_duedate, cohist.cohist_imported, cohist.cohist_billtoname, cohist.cohist_billtoaddress1, cohist.cohist_billtoaddress2, cohist.cohist_billtoaddress3, cohist.cohist_billtocity, cohist.cohist_billtostate, cohist.cohist_billtozip, cohist.cohist_shiptoname, cohist.cohist_shiptoaddress1, cohist.cohist_shiptoaddress2, cohist.cohist_shiptoaddress3, cohist.cohist_shiptocity, cohist.cohist_shiptostate, cohist.cohist_shiptozip, cohist.cohist_commission, cohist.cohist_commissionpaid, cohist.cohist_unitcost, cohist.cohist_misc_type, cohist.cohist_misc_descrip, cohist.cohist_misc_id, cohist.cohist_doctype, cohist.cohist_promisedate, cohist.cohist_ponumber, cohist.cohist_curr_id, cohist.cohist_sequence, cohist.cohist_taxtype_id, cohist.cohist_taxzone_id, cohist.cohist_cohead_ccpay_id, cohist.cohist_saletype_id, cohist.cohist_shipzone_id, COALESCE(cohead.cohead_id, (-1)) AS cohead_id, custinfo.cust_id, custinfo.cust_number, custinfo.cust_name, custinfo.cust_curr_id, custtype.custtype_id, custtype.custtype_code, custtype.custtype_descrip, salesrep.salesrep_id, salesrep.salesrep_number, salesrep.salesrep_name, shipzone.shipzone_id, shipzone.shipzone_name, shipzone.shipzone_descrip, saletype.saletype_code, saletype.saletype_descr, itemsite.itemsite_id, site.warehous_id, site.warehous_code, site.warehous_descrip, item.item_id, item.item_number, item.item_descrip1, item.item_descrip2, ((item.item_descrip1 || ' '::text) || item.item_descrip2) AS itemdescription, COALESCE(item.item_number, cohist.cohist_misc_descrip) AS itemnumber, prodcat.prodcat_id, prodcat.prodcat_code, classcode.classcode_id, classcode.classcode_code, currtobase(cohist.cohist_curr_id, cohist.cohist_commission, cohist.cohist_invcdate) AS basecommission, currtobase(cohist.cohist_curr_id, cohist.cohist_unitprice, cohist.cohist_invcdate) AS baseunitprice, currtocurr(cohist.cohist_curr_id, custinfo.cust_curr_id, cohist.cohist_unitprice, cohist.cohist_invcdate) AS custunitprice FROM ((((((((((((cohist JOIN custinfo ON ((custinfo.cust_id = cohist.cohist_cust_id))) LEFT JOIN cohead ON ((cohead.cohead_number = cohist.cohist_ordernumber))) LEFT JOIN custtype ON ((custtype.custtype_id = custinfo.cust_custtype_id))) LEFT JOIN salesrep ON ((salesrep.salesrep_id = cohist.cohist_salesrep_id))) LEFT JOIN shiptoinfo ON ((shiptoinfo.shipto_id = cohist.cohist_shipto_id))) LEFT JOIN shipzone ON ((shipzone.shipzone_id = shiptoinfo.shipto_shipzone_id))) LEFT JOIN saletype ON ((saletype.saletype_id = cohist.cohist_saletype_id))) LEFT JOIN itemsite ON ((itemsite.itemsite_id = cohist.cohist_itemsite_id))) LEFT JOIN site() site(warehous_id, warehous_code, warehous_descrip, warehous_fob, warehous_active, warehous_counttag_prefix, warehous_counttag_number, warehous_bol_prefix, warehous_bol_number, warehous_shipping, warehous_useslips, warehous_usezones, warehous_aislesize, warehous_aislealpha, warehous_racksize, warehous_rackalpha, warehous_binsize, warehous_binalpha, warehous_locationsize, warehous_locationalpha, warehous_enforcearbl, warehous_default_accnt_id, warehous_shipping_commission, warehous_cntct_id, warehous_addr_id, warehous_transit, warehous_shipform_id, warehous_shipvia_id, warehous_shipcomments, warehous_costcat_id, warehous_sitetype_id, warehous_taxzone_id, warehous_sequence) ON ((site.warehous_id = itemsite.itemsite_warehous_id))) LEFT JOIN item ON ((item.item_id = itemsite.itemsite_item_id))) LEFT JOIN prodcat ON ((prodcat.prodcat_id = item.item_prodcat_id))) LEFT JOIN classcode ON ((classcode.classcode_id = item.item_classcode_id))) WHERE ((COALESCE(cohist.cohist_misc_type, ''::bpchar) <> 'F'::bpchar) AND (COALESCE(cohist.cohist_misc_type, ''::bpchar) <> 'T'::bpchar))) data; #DROP VIEW public.saleshistorymisc; publicadminfalse86868*00VIEW saleshistorymiscCOMMENTlCOMMENT ON VIEW saleshistorymisc IS 'Single point for sales history (including misc. items) calculations.'; publicadminfalse803*00saleshistorymiscACLREVOKE ALL ON TABLE saleshistorymisc FROM PUBLIC; REVOKE ALL ON TABLE saleshistorymisc FROM admin; GRANT ALL ON TABLE saleshistorymisc TO admin; GRANT ALL ON TABLE saleshistorymisc TO xtrole; publicadminfalse803}125982096salesrep_salesrep_id_seqSEQUENCEzCREATE SEQUENCE salesrep_salesrep_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.salesrep_salesrep_id_seq; publicadminfalse8*00salesrep_salesrep_id_seqACLREVOKE ALL ON SEQUENCE salesrep_salesrep_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE salesrep_salesrep_id_seq FROM admin; GRANT ALL ON SEQUENCE salesrep_salesrep_id_seq TO admin; GRANT ALL ON SEQUENCE salesrep_salesrep_id_seq TO xtrole; publicadminfalse637~125982098saletype_saletype_id_seqSEQUENCEzCREATE SEQUENCE saletype_saletype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.saletype_saletype_id_seq; publicadminfalse8207*00saletype_saletype_id_seqSEQUENCE OWNED BYGALTER SEQUENCE saletype_saletype_id_seq OWNED BY saletype.saletype_id; publicadminfalse638*00saletype_saletype_id_seqACLREVOKE ALL ON SEQUENCE saletype_saletype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE saletype_saletype_id_seq FROM admin; GRANT ALL ON SEQUENCE saletype_saletype_id_seq TO admin; GRANT ALL ON SEQUENCE saletype_saletype_id_seq TO xtrole; publicadminfalse638125982100 schemaordTABLE/CREATE TABLE schemaord ( schemaord_id integer NOT NULL, schemaord_name text NOT NULL, schemaord_order integer NOT NULL, CONSTRAINT schemaord_schemaord_name_check CHECK ((length(schemaord_name) > 0)), CONSTRAINT schemaord_schemaord_name_check1 CHECK ((schemaord_name <> ''::text)) ); DROP TABLE public.schemaord; publicadminfalse669866998*00TABLE schemaordCOMMENTnCOMMENT ON TABLE schemaord IS 'Set the order in which db schemas will appear in the search path after login'; publicadminfalse639*00 schemaordACLREVOKE ALL ON TABLE schemaord FROM PUBLIC; REVOKE ALL ON TABLE schemaord FROM admin; GRANT ALL ON TABLE schemaord TO admin; GRANT ALL ON TABLE schemaord TO xtrole; publicadminfalse639125982108schemaord_schemaord_id_seqSEQUENCE|CREATE SEQUENCE schemaord_schemaord_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 1DROP SEQUENCE public.schemaord_schemaord_id_seq; publicadminfalse8639*00schemaord_schemaord_id_seqSEQUENCE OWNED BYKALTER SEQUENCE schemaord_schemaord_id_seq OWNED BY schemaord.schemaord_id; publicadminfalse640*00schemaord_schemaord_id_seqACLREVOKE ALL ON SEQUENCE schemaord_schemaord_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE schemaord_schemaord_id_seq FROM admin; GRANT ALL ON SEQUENCE schemaord_schemaord_id_seq TO admin; GRANT ALL ON SEQUENCE schemaord_schemaord_id_seq TO xtrole; publicadminfalse640125982110sequenceTABLE6CREATE TABLE sequence ( sequence_value integer ); DROP TABLE public.sequence; publicadminfalse8*00TABLE sequenceCOMMENTxCOMMENT ON TABLE sequence IS 'Pre-populated list of sequence numbers (1-1000) used for printing Labels and other uses'; publicadminfalse641*00sequenceACLREVOKE ALL ON TABLE sequence FROM PUBLIC; REVOKE ALL ON TABLE sequence FROM admin; GRANT ALL ON TABLE sequence TO admin; GRANT ALL ON TABLE sequence TO xtrole; publicadminfalse641125982113shift_shift_id_seqSEQUENCEtCREATE SEQUENCE shift_shift_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; )DROP SEQUENCE public.shift_shift_id_seq; publicadminfalse8243*00shift_shift_id_seqSEQUENCE OWNED BY;ALTER SEQUENCE shift_shift_id_seq OWNED BY shift.shift_id; publicadminfalse642*00shift_shift_id_seqACLREVOKE ALL ON SEQUENCE shift_shift_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE shift_shift_id_seq FROM admin; GRANT ALL ON SEQUENCE shift_shift_id_seq TO admin; GRANT ALL ON SEQUENCE shift_shift_id_seq TO xtrole; publicadminfalse642125982115shipchrg_shipchrg_id_seqSEQUENCEzCREATE SEQUENCE shipchrg_shipchrg_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.shipchrg_shipchrg_id_seq; publicadminfalse8237*00shipchrg_shipchrg_id_seqSEQUENCE OWNED BYGALTER SEQUENCE shipchrg_shipchrg_id_seq OWNED BY shipchrg.shipchrg_id; publicadminfalse643*00shipchrg_shipchrg_id_seqACLREVOKE ALL ON SEQUENCE shipchrg_shipchrg_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE shipchrg_shipchrg_id_seq FROM admin; GRANT ALL ON SEQUENCE shipchrg_shipchrg_id_seq TO admin; GRANT ALL ON SEQUENCE shipchrg_shipchrg_id_seq TO xtrole; publicadminfalse643125982117 shipdatasumTABLECREATE TABLE shipdatasum ( shipdatasum_cohead_number text NOT NULL, shipdatasum_cosmisc_tracknum text NOT NULL, shipdatasum_cosmisc_packnum_tracknum text NOT NULL, shipdatasum_weight numeric(16,4), shipdatasum_base_freight numeric(16,4), shipdatasum_total_freight numeric(16,4), shipdatasum_shipper text DEFAULT 'UPS'::text, shipdatasum_billing_option text, shipdatasum_package_type text, shipdatasum_lastupdated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL, shipdatasum_shipped boolean DEFAULT false, shipdatasum_shiphead_number text, shipdatasum_base_freight_curr_id integer DEFAULT basecurrid(), shipdatasum_total_freight_curr_id integer DEFAULT basecurrid() ); DROP TABLE public.shipdatasum; publicadminfalse670067016702670367048*00TABLE shipdatasumCOMMENTCCOMMENT ON TABLE shipdatasum IS 'Shipping Interface information.'; publicadminfalse644*00 shipdatasumACLREVOKE ALL ON TABLE shipdatasum FROM PUBLIC; REVOKE ALL ON TABLE shipdatasum FROM admin; GRANT ALL ON TABLE shipdatasum TO admin; GRANT ALL ON TABLE shipdatasum TO xtrole; publicadminfalse644125982128shipform_shipform_id_seqSEQUENCECREATE SEQUENCE shipform_shipform_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; /DROP SEQUENCE public.shipform_shipform_id_seq; publicadminfalse8*00shipform_shipform_id_seqACLREVOKE ALL ON SEQUENCE shipform_shipform_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE shipform_shipform_id_seq FROM admin; GRANT ALL ON SEQUENCE shipform_shipform_id_seq TO admin; GRANT ALL ON SEQUENCE shipform_shipform_id_seq TO xtrole; publicadminfalse645125982130shiphead_shiphead_id_seqSEQUENCEzCREATE SEQUENCE shiphead_shiphead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.shiphead_shiphead_id_seq; publicadminfalse8412*00shiphead_shiphead_id_seqSEQUENCE OWNED BYGALTER SEQUENCE shiphead_shiphead_id_seq OWNED BY shiphead.shiphead_id; publicadminfalse646*00shiphead_shiphead_id_seqACLREVOKE ALL ON SEQUENCE shiphead_shiphead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE shiphead_shiphead_id_seq FROM admin; GRANT ALL ON SEQUENCE shiphead_shiphead_id_seq TO admin; GRANT ALL ON SEQUENCE shiphead_shiphead_id_seq TO xtrole; publicadminfalse646125982132shipitem_shipitem_id_seqSEQUENCEzCREATE SEQUENCE shipitem_shipitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.shipitem_shipitem_id_seq; publicadminfalse4138*00shipitem_shipitem_id_seqSEQUENCE OWNED BYGALTER SEQUENCE shipitem_shipitem_id_seq OWNED BY shipitem.shipitem_id; publicadminfalse647*00shipitem_shipitem_id_seqACLREVOKE ALL ON SEQUENCE shipitem_shipitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE shipitem_shipitem_id_seq FROM admin; GRANT ALL ON SEQUENCE shipitem_shipitem_id_seq TO admin; GRANT ALL ON SEQUENCE shipitem_shipitem_id_seq TO xtrole; publicadminfalse647125982134shipment_number_seqSEQUENCEuCREATE SEQUENCE shipment_number_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; *DROP SEQUENCE public.shipment_number_seq; publicadminfalse8*00shipment_number_seqACLREVOKE ALL ON SEQUENCE shipment_number_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE shipment_number_seq FROM admin; GRANT ALL ON SEQUENCE shipment_number_seq TO admin; GRANT ALL ON SEQUENCE shipment_number_seq TO xtrole; publicadminfalse648125982136shiptoVIEWCREATE VIEW shipto AS SELECT shiptoinfo.shipto_id, shiptoinfo.shipto_cust_id, shiptoinfo.shipto_name, m.addr_line1 AS shipto_address1, m.addr_line2 AS shipto_address2, m.addr_line3 AS shipto_address3, m.addr_city AS shipto_city, m.addr_state AS shipto_state, m.addr_postalcode AS shipto_zipcode, shiptoinfo.shipto_taxzone_id, shiptoinfo.shipto_salesrep_id, c1.cntct_phone AS shipto_phone, shiptoinfo.shipto_comments, shiptoinfo.shipto_shipcomments, btrim(((c1.cntct_first_name || ' '::text) || c1.cntct_last_name)) AS shipto_contact, c1.cntct_fax AS shipto_fax, c1.cntct_email AS shipto_email, shiptoinfo.shipto_shipzone_id, shiptoinfo.shipto_shipvia, shiptoinfo.shipto_commission, shiptoinfo.shipto_shipform_id, shiptoinfo.shipto_shipchrg_id, shiptoinfo.shipto_active, shiptoinfo.shipto_default, shiptoinfo.shipto_num, shiptoinfo.shipto_ediprofile_id, m.addr_country AS shipto_country FROM ((shiptoinfo LEFT JOIN cntct c1 ON ((shiptoinfo.shipto_cntct_id = c1.cntct_id))) LEFT JOIN addr m ON ((shiptoinfo.shipto_addr_id = m.addr_id))); DROP VIEW public.shipto; publicadminfalse86468*00shiptoACLREVOKE ALL ON TABLE shipto FROM PUBLIC; REVOKE ALL ON TABLE shipto FROM admin; GRANT ALL ON TABLE shipto TO admin; GRANT ALL ON TABLE shipto TO xtrole; publicadminfalse649125982141shipto_shipto_id_seqSEQUENCE~CREATE SEQUENCE shipto_shipto_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; +DROP SEQUENCE public.shipto_shipto_id_seq; publicadminfalse8*00shipto_shipto_id_seqACLREVOKE ALL ON SEQUENCE shipto_shipto_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE shipto_shipto_id_seq FROM admin; GRANT ALL ON SEQUENCE shipto_shipto_id_seq TO admin; GRANT ALL ON SEQUENCE shipto_shipto_id_seq TO xtrole; publicadminfalse650125982143shipvia_shipvia_id_seqSEQUENCECREATE SEQUENCE shipvia_shipvia_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.shipvia_shipvia_id_seq; publicadminfalse8*00shipvia_shipvia_id_seqACLREVOKE ALL ON SEQUENCE shipvia_shipvia_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE shipvia_shipvia_id_seq FROM admin; GRANT ALL ON SEQUENCE shipvia_shipvia_id_seq TO admin; GRANT ALL ON SEQUENCE shipvia_shipvia_id_seq TO xtrole; publicadminfalse651125982145shipzone_shipzone_id_seqSEQUENCECREATE SEQUENCE shipzone_shipzone_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; /DROP SEQUENCE public.shipzone_shipzone_id_seq; publicadminfalse8*00shipzone_shipzone_id_seqACLREVOKE ALL ON SEQUENCE shipzone_shipzone_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE shipzone_shipzone_id_seq FROM admin; GRANT ALL ON SEQUENCE shipzone_shipzone_id_seq TO admin; GRANT ALL ON SEQUENCE shipzone_shipzone_id_seq TO xtrole; publicadminfalse652125982147sitetype_sitetype_id_seqSEQUENCEzCREATE SEQUENCE sitetype_sitetype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.sitetype_sitetype_id_seq; publicadminfalse8284*00sitetype_sitetype_id_seqSEQUENCE OWNED BYGALTER SEQUENCE sitetype_sitetype_id_seq OWNED BY sitetype.sitetype_id; publicadminfalse653*00sitetype_sitetype_id_seqACLREVOKE ALL ON SEQUENCE sitetype_sitetype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE sitetype_sitetype_id_seq FROM admin; GRANT ALL ON SEQUENCE sitetype_sitetype_id_seq TO admin; GRANT ALL ON SEQUENCE sitetype_sitetype_id_seq TO xtrole; publicadminfalse653125982149sltransTABLECREATE TABLE sltrans ( sltrans_id integer DEFAULT nextval('gltrans_gltrans_id_seq'::regclass) NOT NULL, sltrans_created timestamp with time zone, sltrans_date date NOT NULL, sltrans_sequence integer, sltrans_accnt_id integer NOT NULL, sltrans_source text, sltrans_docnumber text, sltrans_misc_id integer, sltrans_amount numeric(20,2) NOT NULL, sltrans_notes text, sltrans_journalnumber integer, sltrans_posted boolean NOT NULL, sltrans_doctype text, sltrans_username text DEFAULT geteffectivextuser() NOT NULL, sltrans_gltrans_journalnumber integer, sltrans_rec boolean DEFAULT false NOT NULL ); DROP TABLE public.sltrans; publicadminfalse6705670667078*00 TABLE sltransCOMMENT?COMMENT ON TABLE sltrans IS 'Journal transaction information'; publicadminfalse654*00sltransACLREVOKE ALL ON TABLE sltrans FROM PUBLIC; REVOKE ALL ON TABLE sltrans FROM admin; GRANT ALL ON TABLE sltrans TO admin; GRANT ALL ON TABLE sltrans TO xtrole; publicadminfalse654125982158sltrans_backupTABLEXCREATE TABLE sltrans_backup ( sltrans_old_id integer, sltrans_new_id integer ); "DROP TABLE public.sltrans_backup; publicadminfalse8*00TABLE sltrans_backupCOMMENTjCOMMENT ON TABLE sltrans_backup IS 'backup cross references of old and new ids for sltrans 4.0 upgrade.'; publicadminfalse655*00sltrans_backupACLREVOKE ALL ON TABLE sltrans_backup FROM PUBLIC; REVOKE ALL ON TABLE sltrans_backup FROM admin; GRANT ALL ON TABLE sltrans_backup TO admin; GRANT ALL ON TABLE sltrans_backup TO xtrole; publicadminfalse655125982161sopackVIEWCREATE VIEW sopack AS SELECT pack.pack_id AS sopack_id, pack.pack_head_id AS sopack_sohead_id, pack.pack_printed AS sopack_printed, pack.pack_shiphead_id AS sopack_cosmisc_id FROM pack WHERE (pack.pack_head_type = 'SO'::text); DROP VIEW public.sopack; publicadminfalse86478*00sopackACLREVOKE ALL ON TABLE sopack FROM PUBLIC; REVOKE ALL ON TABLE sopack FROM admin; GRANT ALL ON TABLE sopack TO admin; GRANT ALL ON TABLE sopack TO xtrole; publicadminfalse656125982165sopack_sopack_id_seqSEQUENCEvCREATE SEQUENCE sopack_sopack_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.sopack_sopack_id_seq; publicadminfalse8*00sopack_sopack_id_seqACLREVOKE ALL ON SEQUENCE sopack_sopack_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE sopack_sopack_id_seq FROM admin; GRANT ALL ON SEQUENCE sopack_sopack_id_seq TO admin; GRANT ALL ON SEQUENCE sopack_sopack_id_seq TO xtrole; publicadminfalse657125982167sourceTABLECREATE TABLE source ( source_id integer NOT NULL, source_module text, source_name text NOT NULL, source_descrip text, source_docass_num integer DEFAULT 0 NOT NULL, source_docass text DEFAULT ''::text NOT NULL, source_charass text DEFAULT ''::text NOT NULL, source_table text DEFAULT ''::text NOT NULL, source_key_field text DEFAULT ''::text NOT NULL, source_number_field text DEFAULT ''::text NOT NULL, source_name_field text DEFAULT ''::text NOT NULL, source_desc_field text DEFAULT ''::text NOT NULL, source_widget text DEFAULT ''::text NOT NULL, source_joins text DEFAULT ''::text NOT NULL, source_key_param text DEFAULT ''::text NOT NULL, source_uiform_name text DEFAULT ''::text NOT NULL, source_create_priv text DEFAULT ''::text NOT NULL, source_created timestamp with time zone DEFAULT now() NOT NULL, source_last_modified timestamp with time zone DEFAULT now() NOT NULL, CONSTRAINT source_source_name_check CHECK ((source_name <> ''::text)) ); DROP TABLE public.source; publicadminfalse67096710671167126713671467156716671767186719672067216722672367248*00 TABLE sourceCOMMENTCOMMENT ON TABLE source IS 'Used to describe different types of document for tax classes, document associations, comment associations, and characteristic associations'; publicadminfalse658*00COLUMN source.source_idCOMMENT5COMMENT ON COLUMN source.source_id IS 'Primary key'; publicadminfalse658*00COLUMN source.source_moduleCOMMENT@COMMENT ON COLUMN source.source_module IS 'Application module'; publicadminfalse658*00COLUMN source.source_nameCOMMENTmCOMMENT ON COLUMN source.source_name IS 'Abbreviation for this document type used on comment associations.'; publicadminfalse658*00COLUMN source.source_descripCOMMENTCOMMENT ON COLUMN source.source_descrip IS 'Human-readable English name for this document type. The client application tries to translate this whenever possible.'; publicadminfalse658*00COLUMN source.source_docass_numCOMMENTCOMMENT ON COLUMN source.source_docass_num IS 'Value from the desktop client''s Document::DocumentSources enumeration corresponding to this document type.'; publicadminfalse658*00COLUMN source.source_docassCOMMENTCOMMENT ON COLUMN source.source_docass IS 'Abbreviation for this document type used on document associations (docass). Empty indicates cannot used for document associations (see source_widget).'; publicadminfalse658*00COLUMN source.source_charassCOMMENTCOMMENT ON COLUMN source.source_charass IS 'Abbreviation for this document type used on characteristic associations (charass). Empty indicates not used for characteristics.'; publicadminfalse658*00COLUMN source.source_tableCOMMENT`COMMENT ON COLUMN source.source_table IS 'The primary table in which this document is stored.'; publicadminfalse658*00COLUMN source.source_key_fieldCOMMENTsCOMMENT ON COLUMN source.source_key_field IS 'The primary key field in the primary table for this document type.'; publicadminfalse658*00!COLUMN source.source_number_fieldCOMMENTCOMMENT ON COLUMN source.source_number_field IS 'The column holding the main human-readable identifier for this document (e.g. Bill of Materials document number).'; publicadminfalse658*00COLUMN source.source_name_fieldCOMMENTCOMMENT ON COLUMN source.source_name_field IS 'The column holding the secondary description of this document (e.g. the Item built by a Bill of Materials).'; publicadminfalse658*00COLUMN source.source_desc_fieldCOMMENTCOMMENT ON COLUMN source.source_desc_field IS 'The column holding the longer description of this document (e.g. the first line of the Item''s Description for a Bill of Materials).'; publicadminfalse658*00COLUMN source.source_widgetCOMMENTCOMMENT ON COLUMN source.source_widget IS 'A hint to the client application of how to let the user select a document to attach. "core" means that the C++ application handles this document type natively. A value starting with "SELECT" is interpreted as a query to populate a combobox, while values containing "Cluster" are treated as the name of a C++ VirtualCluster subclass to instantiate. Empty string means this cannot be used by the desktop client to create document associations (see source_docass).'; publicadminfalse658*00COLUMN source.source_joinsCOMMENTCOMMENT ON COLUMN source.source_joins IS 'An optional string to add to the FROM clause to get auxiliary information (e.g. "join item_id on bomhead_item_id=item_id").'; publicadminfalse658*00COLUMN source.source_key_paramCOMMENTTCOMMENT ON COLUMN source.source_key_param IS 'The name of the parameter interpreted by the desktop client''s "set" method as containing the primary key to retrieve the main document record for editing or viewing (e.g. most desktop windows take the sales order id in a "sohead_id" parameter even though the database field is "cohead_id").'; publicadminfalse658*00 COLUMN source.source_uiform_nameCOMMENTCOMMENT ON COLUMN source.source_uiform_name IS 'The name of the desktop client application window to open to view or edit this document (e.g. "salesOrder").'; publicadminfalse658*00 COLUMN source.source_create_privCOMMENTCOMMENT ON COLUMN source.source_create_priv IS 'A space- or +-delimited set of privileges required to allow creating a new document. If this is specified, an item will be added to the desktop client''s "New" button menu.'; publicadminfalse658+00COLUMN source.source_createdCOMMENTCOMMENT ON COLUMN source.source_created IS 'The date this source record was created (or the date this column was added to the table:-).'; publicadminfalse658+00"COLUMN source.source_last_modifiedCOMMENTaCOMMENT ON COLUMN source.source_last_modified IS 'The date this source record was last edited.'; publicadminfalse658+00sourceACLREVOKE ALL ON TABLE source FROM PUBLIC; REVOKE ALL ON TABLE source FROM admin; GRANT ALL ON TABLE source TO admin; GRANT ALL ON TABLE source TO xtrole; publicadminfalse658125982174source_source_id_seqSEQUENCEvCREATE SEQUENCE source_source_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.source_source_id_seq; publicadminfalse8658+00source_source_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE source_source_id_seq OWNED BY source.source_id; publicadminfalse659+00source_source_id_seqACLREVOKE ALL ON SEQUENCE source_source_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE source_source_id_seq FROM admin; GRANT ALL ON SEQUENCE source_source_id_seq TO admin; GRANT ALL ON SEQUENCE source_source_id_seq TO xtrole; publicadminfalse659125982176stateTABLECREATE TABLE state ( state_id integer NOT NULL, state_name text NOT NULL, state_abbr text, state_country_id integer, CONSTRAINT state_state_name_check CHECK ((state_name <> ''::text)) ); DROP TABLE public.state; publicadminfalse67268+00 TABLE stateCOMMENTkCOMMENT ON TABLE state IS 'List of states, provinces, and territories associated with various countries.'; publicadminfalse660+00stateACLREVOKE ALL ON TABLE state FROM PUBLIC; REVOKE ALL ON TABLE state FROM admin; GRANT ALL ON TABLE state TO admin; GRANT ALL ON TABLE state TO xtrole; publicadminfalse660125982183state_state_id_seqSEQUENCEtCREATE SEQUENCE state_state_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; )DROP SEQUENCE public.state_state_id_seq; publicadminfalse8660+00state_state_id_seqSEQUENCE OWNED BY;ALTER SEQUENCE state_state_id_seq OWNED BY state.state_id; publicadminfalse661+00state_state_id_seqACLREVOKE ALL ON SEQUENCE state_state_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE state_state_id_seq FROM admin; GRANT ALL ON SEQUENCE state_state_id_seq TO admin; GRANT ALL ON SEQUENCE state_state_id_seq TO xtrole; publicadminfalse661125982185statusTABLECREATE TABLE status ( status_id integer NOT NULL, status_type text NOT NULL, status_code character(1) NOT NULL, status_name text, status_seq integer, status_color text DEFAULT 'white'::text ); DROP TABLE public.status; publicadminfalse67288 +00statusACLREVOKE ALL ON TABLE status FROM PUBLIC; REVOKE ALL ON TABLE status FROM admin; GRANT ALL ON TABLE status TO admin; GRANT ALL ON TABLE status TO xtrole; publicadminfalse662125982192status_status_id_seqSEQUENCEvCREATE SEQUENCE status_status_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.status_status_id_seq; publicadminfalse8662 +00status_status_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE status_status_id_seq OWNED BY status.status_id; publicadminfalse663 +00status_status_id_seqACLREVOKE ALL ON SEQUENCE status_status_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE status_status_id_seq FROM admin; GRANT ALL ON SEQUENCE status_status_id_seq TO admin; GRANT ALL ON SEQUENCE status_status_id_seq TO xtrole; publicadminfalse663125982194stdjrnlTABLECREATE TABLE stdjrnl ( stdjrnl_id integer NOT NULL, stdjrnl_name text NOT NULL, stdjrnl_descrip text, stdjrnl_notes text, CONSTRAINT stdjrnl_stdjrnl_name_check CHECK ((stdjrnl_name <> ''::text)) ); DROP TABLE public.stdjrnl; publicadminfalse67308 +00 TABLE stdjrnlCOMMENT<COMMENT ON TABLE stdjrnl IS 'Standard Journal information'; publicadminfalse664 +00stdjrnlACLREVOKE ALL ON TABLE stdjrnl FROM PUBLIC; REVOKE ALL ON TABLE stdjrnl FROM admin; GRANT ALL ON TABLE stdjrnl TO admin; GRANT ALL ON TABLE stdjrnl TO xtrole; publicadminfalse664125982201stdjrnl_stdjrnl_id_seqSEQUENCExCREATE SEQUENCE stdjrnl_stdjrnl_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.stdjrnl_stdjrnl_id_seq; publicadminfalse8664+00stdjrnl_stdjrnl_id_seqSEQUENCE OWNED BYCALTER SEQUENCE stdjrnl_stdjrnl_id_seq OWNED BY stdjrnl.stdjrnl_id; publicadminfalse665+00stdjrnl_stdjrnl_id_seqACLREVOKE ALL ON SEQUENCE stdjrnl_stdjrnl_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE stdjrnl_stdjrnl_id_seq FROM admin; GRANT ALL ON SEQUENCE stdjrnl_stdjrnl_id_seq TO admin; GRANT ALL ON SEQUENCE stdjrnl_stdjrnl_id_seq TO xtrole; publicadminfalse665125982203 stdjrnlgrpTABLECREATE TABLE stdjrnlgrp ( stdjrnlgrp_id integer NOT NULL, stdjrnlgrp_name text NOT NULL, stdjrnlgrp_descrip text, CONSTRAINT stdjrnlgrp_stdjrnlgrp_name_check CHECK ((stdjrnlgrp_name <> ''::text)) ); DROP TABLE public.stdjrnlgrp; publicadminfalse67328+00TABLE stdjrnlgrpCOMMENTECOMMENT ON TABLE stdjrnlgrp IS 'Standard Journal Group information'; publicadminfalse666+00 stdjrnlgrpACLREVOKE ALL ON TABLE stdjrnlgrp FROM PUBLIC; REVOKE ALL ON TABLE stdjrnlgrp FROM admin; GRANT ALL ON TABLE stdjrnlgrp TO admin; GRANT ALL ON TABLE stdjrnlgrp TO xtrole; publicadminfalse666125982210stdjrnlgrp_stdjrnlgrp_id_seqSEQUENCE~CREATE SEQUENCE stdjrnlgrp_stdjrnlgrp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 3DROP SEQUENCE public.stdjrnlgrp_stdjrnlgrp_id_seq; publicadminfalse8666+00stdjrnlgrp_stdjrnlgrp_id_seqSEQUENCE OWNED BYOALTER SEQUENCE stdjrnlgrp_stdjrnlgrp_id_seq OWNED BY stdjrnlgrp.stdjrnlgrp_id; publicadminfalse667+00stdjrnlgrp_stdjrnlgrp_id_seqACLREVOKE ALL ON SEQUENCE stdjrnlgrp_stdjrnlgrp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE stdjrnlgrp_stdjrnlgrp_id_seq FROM admin; GRANT ALL ON SEQUENCE stdjrnlgrp_stdjrnlgrp_id_seq TO admin; GRANT ALL ON SEQUENCE stdjrnlgrp_stdjrnlgrp_id_seq TO xtrole; publicadminfalse667125982212stdjrnlgrpitemTABLE%CREATE TABLE stdjrnlgrpitem ( stdjrnlgrpitem_id integer NOT NULL, stdjrnlgrpitem_stdjrnl_id integer, stdjrnlgrpitem_toapply integer, stdjrnlgrpitem_applied integer, stdjrnlgrpitem_effective date, stdjrnlgrpitem_expires date, stdjrnlgrpitem_stdjrnlgrp_id integer ); "DROP TABLE public.stdjrnlgrpitem; publicadminfalse8+00TABLE stdjrnlgrpitemCOMMENTNCOMMENT ON TABLE stdjrnlgrpitem IS 'Standard Journal Group Item information'; publicadminfalse668+00stdjrnlgrpitemACLREVOKE ALL ON TABLE stdjrnlgrpitem FROM PUBLIC; REVOKE ALL ON TABLE stdjrnlgrpitem FROM admin; GRANT ALL ON TABLE stdjrnlgrpitem TO admin; GRANT ALL ON TABLE stdjrnlgrpitem TO xtrole; publicadminfalse668125982215$stdjrnlgrpitem_stdjrnlgrpitem_id_seqSEQUENCECREATE SEQUENCE stdjrnlgrpitem_stdjrnlgrpitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; ;DROP SEQUENCE public.stdjrnlgrpitem_stdjrnlgrpitem_id_seq; publicadminfalse8668+00$stdjrnlgrpitem_stdjrnlgrpitem_id_seqSEQUENCE OWNED BY_ALTER SEQUENCE stdjrnlgrpitem_stdjrnlgrpitem_id_seq OWNED BY stdjrnlgrpitem.stdjrnlgrpitem_id; publicadminfalse669+00$stdjrnlgrpitem_stdjrnlgrpitem_id_seqACLREVOKE ALL ON SEQUENCE stdjrnlgrpitem_stdjrnlgrpitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE stdjrnlgrpitem_stdjrnlgrpitem_id_seq FROM admin; GRANT ALL ON SEQUENCE stdjrnlgrpitem_stdjrnlgrpitem_id_seq TO admin; GRANT ALL ON SEQUENCE stdjrnlgrpitem_stdjrnlgrpitem_id_seq TO xtrole; publicadminfalse669125982217 stdjrnlitemTABLECREATE TABLE stdjrnlitem ( stdjrnlitem_id integer NOT NULL, stdjrnlitem_stdjrnl_id integer NOT NULL, stdjrnlitem_accnt_id integer NOT NULL, stdjrnlitem_amount numeric(20,2) NOT NULL, stdjrnlitem_notes text ); DROP TABLE public.stdjrnlitem; publicadminfalse8+00TABLE stdjrnlitemCOMMENTECOMMENT ON TABLE stdjrnlitem IS 'Standard Journal Item information'; publicadminfalse670+00 stdjrnlitemACLREVOKE ALL ON TABLE stdjrnlitem FROM PUBLIC; REVOKE ALL ON TABLE stdjrnlitem FROM admin; GRANT ALL ON TABLE stdjrnlitem TO admin; GRANT ALL ON TABLE stdjrnlitem TO xtrole; publicadminfalse670125982223stdjrnlitem_stdjrnlitem_id_seqSEQUENCECREATE SEQUENCE stdjrnlitem_stdjrnlitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 5DROP SEQUENCE public.stdjrnlitem_stdjrnlitem_id_seq; publicadminfalse8670+00stdjrnlitem_stdjrnlitem_id_seqSEQUENCE OWNED BYSALTER SEQUENCE stdjrnlitem_stdjrnlitem_id_seq OWNED BY stdjrnlitem.stdjrnlitem_id; publicadminfalse671+00stdjrnlitem_stdjrnlitem_id_seqACLREVOKE ALL ON SEQUENCE stdjrnlitem_stdjrnlitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE stdjrnlitem_stdjrnlitem_id_seq FROM admin; GRANT ALL ON SEQUENCE stdjrnlitem_stdjrnlitem_id_seq TO admin; GRANT ALL ON SEQUENCE stdjrnlitem_stdjrnlitem_id_seq TO xtrole; publicadminfalse671125982225subaccntTABLECREATE TABLE subaccnt ( subaccnt_id integer NOT NULL, subaccnt_number text NOT NULL, subaccnt_descrip text, CONSTRAINT subaccnt_subaccnt_number_check CHECK ((subaccnt_number <> ''::text)) ); DROP TABLE public.subaccnt; publicadminfalse67368+00TABLE subaccntCOMMENT7COMMENT ON TABLE subaccnt IS 'Subaccount information'; publicadminfalse672+00subaccntACLREVOKE ALL ON TABLE subaccnt FROM PUBLIC; REVOKE ALL ON TABLE subaccnt FROM admin; GRANT ALL ON TABLE subaccnt TO admin; GRANT ALL ON TABLE subaccnt TO xtrole; publicadminfalse672125982232subaccnt_subaccnt_id_seqSEQUENCEzCREATE SEQUENCE subaccnt_subaccnt_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.subaccnt_subaccnt_id_seq; publicadminfalse8672+00subaccnt_subaccnt_id_seqSEQUENCE OWNED BYGALTER SEQUENCE subaccnt_subaccnt_id_seq OWNED BY subaccnt.subaccnt_id; publicadminfalse673+00subaccnt_subaccnt_id_seqACLREVOKE ALL ON SEQUENCE subaccnt_subaccnt_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE subaccnt_subaccnt_id_seq FROM admin; GRANT ALL ON SEQUENCE subaccnt_subaccnt_id_seq TO admin; GRANT ALL ON SEQUENCE subaccnt_subaccnt_id_seq TO xtrole; publicadminfalse673125982234 subaccnttypeTABLECREATE TABLE subaccnttype ( subaccnttype_id integer NOT NULL, subaccnttype_accnt_type character(1) NOT NULL, subaccnttype_code text NOT NULL, subaccnttype_descrip text ); DROP TABLE public.subaccnttype; publicadminfalse8 +00TABLE subaccnttypeCOMMENTDCOMMENT ON TABLE subaccnttype IS 'User defined Sub Account Types.'; publicadminfalse674!+00 subaccnttypeACLREVOKE ALL ON TABLE subaccnttype FROM PUBLIC; REVOKE ALL ON TABLE subaccnttype FROM admin; GRANT ALL ON TABLE subaccnttype TO admin; GRANT ALL ON TABLE subaccnttype TO xtrole; publicadminfalse674125982240 subaccnttype_subaccnttype_id_seqSEQUENCECREATE SEQUENCE subaccnttype_subaccnttype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 7DROP SEQUENCE public.subaccnttype_subaccnttype_id_seq; publicadminfalse6748"+00 subaccnttype_subaccnttype_id_seqSEQUENCE OWNED BYWALTER SEQUENCE subaccnttype_subaccnttype_id_seq OWNED BY subaccnttype.subaccnttype_id; publicadminfalse675#+00 subaccnttype_subaccnttype_id_seqACL REVOKE ALL ON SEQUENCE subaccnttype_subaccnttype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE subaccnttype_subaccnttype_id_seq FROM admin; GRANT ALL ON SEQUENCE subaccnttype_subaccnttype_id_seq TO admin; GRANT ALL ON SEQUENCE subaccnttype_subaccnttype_id_seq TO xtrole; publicadminfalse675125982242tax_tax_id_seqSEQUENCEpCREATE SEQUENCE tax_tax_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; %DROP SEQUENCE public.tax_tax_id_seq; publicadminfalse8$+00tax_tax_id_seqACLREVOKE ALL ON SEQUENCE tax_tax_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE tax_tax_id_seq FROM admin; GRANT ALL ON SEQUENCE tax_tax_id_seq TO admin; GRANT ALL ON SEQUENCE tax_tax_id_seq TO xtrole; publicadminfalse676125982244taxassTABLECREATE TABLE taxass ( taxass_id integer NOT NULL, taxass_taxzone_id integer, taxass_taxtype_id integer, taxass_tax_id integer NOT NULL ); DROP TABLE public.taxass; publicadminfalse8%+00 TABLE taxassCOMMENTCOMMENT ON TABLE taxass IS 'The tax assignment table associates different tax zones and tax types to a given set of tax codes.'; publicadminfalse677&+00COLUMN taxass.taxass_taxzone_idCOMMENTjCOMMENT ON COLUMN taxass.taxass_taxzone_id IS 'The id of the tax zone. If NULL any tax zone will apply.'; publicadminfalse677'+00COLUMN taxass.taxass_taxtype_idCOMMENTjCOMMENT ON COLUMN taxass.taxass_taxtype_id IS 'The id of the tax type. If NULL any tax type will apply.'; publicadminfalse677(+00COLUMN taxass.taxass_tax_idCOMMENTECOMMENT ON COLUMN taxass.taxass_tax_id IS 'The id of the tax code.'; publicadminfalse677)+00taxassACLREVOKE ALL ON TABLE taxass FROM PUBLIC; REVOKE ALL ON TABLE taxass FROM admin; GRANT ALL ON TABLE taxass TO admin; GRANT ALL ON TABLE taxass TO xtrole; publicadminfalse677125982247taxass_taxass_id_seqSEQUENCEvCREATE SEQUENCE taxass_taxass_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.taxass_taxass_id_seq; publicadminfalse8677*+00taxass_taxass_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE taxass_taxass_id_seq OWNED BY taxass.taxass_id; publicadminfalse678++00taxass_taxass_id_seqACLREVOKE ALL ON SEQUENCE taxass_taxass_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE taxass_taxass_id_seq FROM admin; GRANT ALL ON SEQUENCE taxass_taxass_id_seq TO admin; GRANT ALL ON SEQUENCE taxass_taxass_id_seq TO xtrole; publicadminfalse678125982249taxauth_taxauth_id_seqSEQUENCExCREATE SEQUENCE taxauth_taxauth_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.taxauth_taxauth_id_seq; publicadminfalse8239,+00taxauth_taxauth_id_seqSEQUENCE OWNED BYCALTER SEQUENCE taxauth_taxauth_id_seq OWNED BY taxauth.taxauth_id; publicadminfalse679-+00taxauth_taxauth_id_seqACLREVOKE ALL ON SEQUENCE taxauth_taxauth_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE taxauth_taxauth_id_seq FROM admin; GRANT ALL ON SEQUENCE taxauth_taxauth_id_seq TO admin; GRANT ALL ON SEQUENCE taxauth_taxauth_id_seq TO xtrole; publicadminfalse679125982251taxclassTABLECREATE TABLE taxclass ( taxclass_id integer NOT NULL, taxclass_code text NOT NULL, taxclass_descrip text, taxclass_sequence integer, CONSTRAINT taxclass_taxclass_code_check CHECK ((taxclass_code <> ''::text)) ); DROP TABLE public.taxclass; publicadminfalse67408.+00TABLE taxclassCOMMENT6COMMENT ON TABLE taxclass IS 'Tax class information'; publicadminfalse680/+00COLUMN taxclass.taxclass_idCOMMENT9COMMENT ON COLUMN taxclass.taxclass_id IS 'Primary key'; publicadminfalse6800+00COLUMN taxclass.taxclass_codeCOMMENT4COMMENT ON COLUMN taxclass.taxclass_code IS 'Code'; publicadminfalse6801+00 COLUMN taxclass.taxclass_descripCOMMENT>COMMENT ON COLUMN taxclass.taxclass_descrip IS 'Description'; publicadminfalse6802+00!COLUMN taxclass.taxclass_sequenceCOMMENTBCOMMENT ON COLUMN taxclass.taxclass_sequence IS 'Group sequence'; publicadminfalse6803+00taxclassACLREVOKE ALL ON TABLE taxclass FROM PUBLIC; REVOKE ALL ON TABLE taxclass FROM admin; GRANT ALL ON TABLE taxclass TO admin; GRANT ALL ON TABLE taxclass TO xtrole; publicadminfalse680125982258taxclass_taxclass_id_seqSEQUENCEzCREATE SEQUENCE taxclass_taxclass_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.taxclass_taxclass_id_seq; publicadminfalse86804+00taxclass_taxclass_id_seqSEQUENCE OWNED BYGALTER SEQUENCE taxclass_taxclass_id_seq OWNED BY taxclass.taxclass_id; publicadminfalse6815+00taxclass_taxclass_id_seqACLREVOKE ALL ON SEQUENCE taxclass_taxclass_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE taxclass_taxclass_id_seq FROM admin; GRANT ALL ON SEQUENCE taxclass_taxclass_id_seq TO admin; GRANT ALL ON SEQUENCE taxclass_taxclass_id_seq TO xtrole; publicadminfalse681125982260taxhist_taxhist_id_seqSEQUENCExCREATE SEQUENCE taxhist_taxhist_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.taxhist_taxhist_id_seq; publicadminfalse82816+00taxhist_taxhist_id_seqSEQUENCE OWNED BYCALTER SEQUENCE taxhist_taxhist_id_seq OWNED BY taxhist.taxhist_id; publicadminfalse6827+00taxhist_taxhist_id_seqACLREVOKE ALL ON SEQUENCE taxhist_taxhist_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE taxhist_taxhist_id_seq FROM admin; GRANT ALL ON SEQUENCE taxhist_taxhist_id_seq TO admin; GRANT ALL ON SEQUENCE taxhist_taxhist_id_seq TO xtrole; publicadminfalse682125987560taxpayTABLECREATE TABLE taxpay ( taxpay_id integer NOT NULL, taxpay_taxhist_id integer NOT NULL, taxpay_apply_id integer NOT NULL, taxpay_distdate date NOT NULL, taxpay_tax numeric NOT NULL ); DROP TABLE public.taxpay; publicadminfalse88+00taxpayACLREVOKE ALL ON TABLE taxpay FROM PUBLIC; REVOKE ALL ON TABLE taxpay FROM admin; GRANT ALL ON TABLE taxpay TO admin; GRANT ALL ON TABLE taxpay TO xtrole; publicadminfalse788125987563taxpay_taxpay_id_seqSEQUENCEvCREATE SEQUENCE taxpay_taxpay_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.taxpay_taxpay_id_seq; publicadminfalse78889+00taxpay_taxpay_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE taxpay_taxpay_id_seq OWNED BY taxpay.taxpay_id; publicadminfalse789:+00taxpay_taxpay_id_seqACLREVOKE ALL ON SEQUENCE taxpay_taxpay_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE taxpay_taxpay_id_seq FROM admin; GRANT ALL ON SEQUENCE taxpay_taxpay_id_seq TO admin; GRANT ALL ON SEQUENCE taxpay_taxpay_id_seq TO xtrole; publicadminfalse789125982262taxrateTABLE CREATE TABLE taxrate ( taxrate_id integer NOT NULL, taxrate_tax_id integer NOT NULL, taxrate_percent numeric(10,6) NOT NULL, taxrate_curr_id integer, taxrate_amount numeric(16,2) NOT NULL, taxrate_effective date, taxrate_expires date ); DROP TABLE public.taxrate; publicadminfalse8;+00 TABLE taxrateCOMMENT*COMMENT ON TABLE taxrate IS 'Tax rates.'; publicadminfalse683<+00COLUMN taxrate.taxrate_idCOMMENT8COMMENT ON COLUMN taxrate.taxrate_id IS 'Primary key.'; publicadminfalse683=+00COLUMN taxrate.taxrate_tax_idCOMMENTNCOMMENT ON COLUMN taxrate.taxrate_tax_id IS 'The id of the parent tax code.'; publicadminfalse683>+00COLUMN taxrate.taxrate_percentCOMMENTECOMMENT ON COLUMN taxrate.taxrate_percent IS 'Tax rate percentage.'; publicadminfalse683?+00COLUMN taxrate.taxrate_curr_idCOMMENTYCOMMENT ON COLUMN taxrate.taxrate_curr_id IS 'The currency id of the flat rate amount.'; publicadminfalse683@+00COLUMN taxrate.taxrate_amountCOMMENTECOMMENT ON COLUMN taxrate.taxrate_amount IS 'Flat tax rate amount.'; publicadminfalse683A+00 COLUMN taxrate.taxrate_effectiveCOMMENTpCOMMENT ON COLUMN taxrate.taxrate_effective IS 'The effective date of the tax rate. NULL value means always.'; publicadminfalse683B+00COLUMN taxrate.taxrate_expiresCOMMENTjCOMMENT ON COLUMN taxrate.taxrate_expires IS 'The expire date of the tax rate. NULL value means never.'; publicadminfalse683C+00taxrateACLREVOKE ALL ON TABLE taxrate FROM PUBLIC; REVOKE ALL ON TABLE taxrate FROM admin; GRANT ALL ON TABLE taxrate TO admin; GRANT ALL ON TABLE taxrate TO xtrole; publicadminfalse683125982265taxrate_taxrate_id_seqSEQUENCExCREATE SEQUENCE taxrate_taxrate_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.taxrate_taxrate_id_seq; publicadminfalse8683D+00taxrate_taxrate_id_seqSEQUENCE OWNED BYCALTER SEQUENCE taxrate_taxrate_id_seq OWNED BY taxrate.taxrate_id; publicadminfalse684E+00taxrate_taxrate_id_seqACLREVOKE ALL ON SEQUENCE taxrate_taxrate_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE taxrate_taxrate_id_seq FROM admin; GRANT ALL ON SEQUENCE taxrate_taxrate_id_seq TO admin; GRANT ALL ON SEQUENCE taxrate_taxrate_id_seq TO xtrole; publicadminfalse684125982267taxreg_taxreg_id_seqSEQUENCEvCREATE SEQUENCE taxreg_taxreg_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.taxreg_taxreg_id_seq; publicadminfalse8240F+00taxreg_taxreg_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE taxreg_taxreg_id_seq OWNED BY taxreg.taxreg_id; publicadminfalse685G+00taxreg_taxreg_id_seqACLREVOKE ALL ON SEQUENCE taxreg_taxreg_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE taxreg_taxreg_id_seq FROM admin; GRANT ALL ON SEQUENCE taxreg_taxreg_id_seq TO admin; GRANT ALL ON SEQUENCE taxreg_taxreg_id_seq TO xtrole; publicadminfalse685125982269taxtype_taxtype_id_seqSEQUENCExCREATE SEQUENCE taxtype_taxtype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.taxtype_taxtype_id_seq; publicadminfalse8182H+00taxtype_taxtype_id_seqSEQUENCE OWNED BYCALTER SEQUENCE taxtype_taxtype_id_seq OWNED BY taxtype.taxtype_id; publicadminfalse686I+00taxtype_taxtype_id_seqACLREVOKE ALL ON SEQUENCE taxtype_taxtype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE taxtype_taxtype_id_seq FROM admin; GRANT ALL ON SEQUENCE taxtype_taxtype_id_seq TO admin; GRANT ALL ON SEQUENCE taxtype_taxtype_id_seq TO xtrole; publicadminfalse686125982271taxzone_taxzone_id_seqSEQUENCExCREATE SEQUENCE taxzone_taxzone_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.taxzone_taxzone_id_seq; publicadminfalse8203J+00taxzone_taxzone_id_seqSEQUENCE OWNED BYCALTER SEQUENCE taxzone_taxzone_id_seq OWNED BY taxzone.taxzone_id; publicadminfalse687K+00taxzone_taxzone_id_seqACLREVOKE ALL ON SEQUENCE taxzone_taxzone_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE taxzone_taxzone_id_seq FROM admin; GRANT ALL ON SEQUENCE taxzone_taxzone_id_seq TO admin; GRANT ALL ON SEQUENCE taxzone_taxzone_id_seq TO xtrole; publicadminfalse687125982273terms_terms_id_seqSEQUENCE|CREATE SEQUENCE terms_terms_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; )DROP SEQUENCE public.terms_terms_id_seq; publicadminfalse8L+00terms_terms_id_seqACLREVOKE ALL ON SEQUENCE terms_terms_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE terms_terms_id_seq FROM admin; GRANT ALL ON SEQUENCE terms_terms_id_seq TO admin; GRANT ALL ON SEQUENCE terms_terms_id_seq TO xtrole; publicadminfalse688125982275todoitem_todoitem_id_seqSEQUENCEzCREATE SEQUENCE todoitem_todoitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.todoitem_todoitem_id_seq; publicadminfalse8212M+00todoitem_todoitem_id_seqSEQUENCE OWNED BYGALTER SEQUENCE todoitem_todoitem_id_seq OWNED BY todoitem.todoitem_id; publicadminfalse689N+00todoitem_todoitem_id_seqACLREVOKE ALL ON SEQUENCE todoitem_todoitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE todoitem_todoitem_id_seq FROM admin; GRANT ALL ON SEQUENCE todoitem_todoitem_id_seq TO admin; GRANT ALL ON SEQUENCE todoitem_todoitem_id_seq TO xtrole; publicadminfalse689125982277trgthistTABLECREATE TABLE trgthist ( trgthist_src_cntct_id integer NOT NULL, trgthist_trgt_cntct_id integer NOT NULL, trgthist_col text NOT NULL, trgthist_value text NOT NULL ); DROP TABLE public.trgthist; publicadminfalse8O+00trgthistACLREVOKE ALL ON TABLE trgthist FROM PUBLIC; REVOKE ALL ON TABLE trgthist FROM admin; GRANT ALL ON TABLE trgthist TO admin; GRANT ALL ON TABLE trgthist TO xtrole; publicadminfalse690125982283trialbalTABLEaCREATE TABLE trialbal ( trialbal_id integer NOT NULL, trialbal_period_id integer, trialbal_accnt_id integer, trialbal_beginning numeric(20,2), trialbal_ending numeric(20,2), trialbal_credits numeric(20,2), trialbal_debits numeric(20,2), trialbal_dirty boolean, trialbal_yearend numeric(20,2) DEFAULT 0.00 NOT NULL ); DROP TABLE public.trialbal; publicadminfalse67438P+00TABLE trialbalCOMMENT:COMMENT ON TABLE trialbal IS 'Trial Balance information'; publicadminfalse691Q+00trialbalACLREVOKE ALL ON TABLE trialbal FROM PUBLIC; REVOKE ALL ON TABLE trialbal FROM admin; GRANT ALL ON TABLE trialbal TO admin; GRANT ALL ON TABLE trialbal TO xtrole; publicadminfalse691125982287trialbal_trialbal_id_seqSEQUENCEzCREATE SEQUENCE trialbal_trialbal_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.trialbal_trialbal_id_seq; publicadminfalse6918R+00trialbal_trialbal_id_seqSEQUENCE OWNED BYGALTER SEQUENCE trialbal_trialbal_id_seq OWNED BY trialbal.trialbal_id; publicadminfalse692S+00trialbal_trialbal_id_seqACLREVOKE ALL ON SEQUENCE trialbal_trialbal_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE trialbal_trialbal_id_seq FROM admin; GRANT ALL ON SEQUENCE trialbal_trialbal_id_seq TO admin; GRANT ALL ON SEQUENCE trialbal_trialbal_id_seq TO xtrole; publicadminfalse692125982289uom_uom_id_seqSEQUENCEpCREATE SEQUENCE uom_uom_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; %DROP SEQUENCE public.uom_uom_id_seq; publicadminfalse8183T+00uom_uom_id_seqSEQUENCE OWNED BY3ALTER SEQUENCE uom_uom_id_seq OWNED BY uom.uom_id; publicadminfalse693U+00uom_uom_id_seqACLREVOKE ALL ON SEQUENCE uom_uom_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE uom_uom_id_seq FROM admin; GRANT ALL ON SEQUENCE uom_uom_id_seq TO admin; GRANT ALL ON SEQUENCE uom_uom_id_seq TO xtrole; publicadminfalse693125982291uomconvTABLE!CREATE TABLE uomconv ( uomconv_id integer NOT NULL, uomconv_from_uom_id integer NOT NULL, uomconv_from_value numeric(20,10) NOT NULL, uomconv_to_uom_id integer NOT NULL, uomconv_to_value numeric(20,10) NOT NULL, uomconv_fractional boolean DEFAULT false NOT NULL ); DROP TABLE public.uomconv; publicadminfalse67458V+00 TABLE uomconvCOMMENThCOMMENT ON TABLE uomconv IS 'UOM conversion information. From Unit to To Unit with a value per ratio.'; publicadminfalse694W+00uomconvACLREVOKE ALL ON TABLE uomconv FROM PUBLIC; REVOKE ALL ON TABLE uomconv FROM admin; GRANT ALL ON TABLE uomconv TO admin; GRANT ALL ON TABLE uomconv TO xtrole; publicadminfalse694125982295uomconv_uomconv_id_seqSEQUENCExCREATE SEQUENCE uomconv_uomconv_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.uomconv_uomconv_id_seq; publicadminfalse8694X+00uomconv_uomconv_id_seqSEQUENCE OWNED BYCALTER SEQUENCE uomconv_uomconv_id_seq OWNED BY uomconv.uomconv_id; publicadminfalse695Y+00uomconv_uomconv_id_seqACLREVOKE ALL ON SEQUENCE uomconv_uomconv_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE uomconv_uomconv_id_seq FROM admin; GRANT ALL ON SEQUENCE uomconv_uomconv_id_seq TO admin; GRANT ALL ON SEQUENCE uomconv_uomconv_id_seq TO xtrole; publicadminfalse695125982297uomtypeTABLECREATE TABLE uomtype ( uomtype_id integer NOT NULL, uomtype_name text NOT NULL, uomtype_descrip text, uomtype_multiple boolean DEFAULT false NOT NULL, CONSTRAINT uomtype_uomtype_name_check CHECK ((uomtype_name <> ''::text)) ); DROP TABLE public.uomtype; publicadminfalse674767488Z+00 TABLE uomtypeCOMMENT0COMMENT ON TABLE uomtype IS 'UOM Type values.'; publicadminfalse696[+00uomtypeACLREVOKE ALL ON TABLE uomtype FROM PUBLIC; REVOKE ALL ON TABLE uomtype FROM admin; GRANT ALL ON TABLE uomtype TO admin; GRANT ALL ON TABLE uomtype TO xtrole; publicadminfalse696125982305uomtype_uomtype_id_seqSEQUENCExCREATE SEQUENCE uomtype_uomtype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.uomtype_uomtype_id_seq; publicadminfalse8696\+00uomtype_uomtype_id_seqSEQUENCE OWNED BYCALTER SEQUENCE uomtype_uomtype_id_seq OWNED BY uomtype.uomtype_id; publicadminfalse697]+00uomtype_uomtype_id_seqACLREVOKE ALL ON SEQUENCE uomtype_uomtype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE uomtype_uomtype_id_seq FROM admin; GRANT ALL ON SEQUENCE uomtype_uomtype_id_seq TO admin; GRANT ALL ON SEQUENCE uomtype_uomtype_id_seq TO xtrole; publicadminfalse697125982307urlinfo_url_id_seqSEQUENCEtCREATE SEQUENCE urlinfo_url_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; )DROP SEQUENCE public.urlinfo_url_id_seq; publicadminfalse8220^+00urlinfo_url_id_seqSEQUENCE OWNED BY;ALTER SEQUENCE urlinfo_url_id_seq OWNED BY urlinfo.url_id; publicadminfalse698_+00urlinfo_url_id_seqACLREVOKE ALL ON SEQUENCE urlinfo_url_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE urlinfo_url_id_seq FROM admin; GRANT ALL ON SEQUENCE urlinfo_url_id_seq TO admin; GRANT ALL ON SEQUENCE urlinfo_url_id_seq TO xtrole; publicadminfalse698125982309usrprefTABLECREATE TABLE usrpref ( usrpref_id integer DEFAULT nextval(('usrpref_usrpref_id_seq'::text)::regclass) NOT NULL, usrpref_name text, usrpref_value text, usrpref_username text ); DROP TABLE public.usrpref; publicadminfalse67498`+00 TABLE usrprefCOMMENT<COMMENT ON TABLE usrpref IS 'User Preferences information'; publicadminfalse699a+00usrprefACLREVOKE ALL ON TABLE usrpref FROM PUBLIC; REVOKE ALL ON TABLE usrpref FROM admin; GRANT ALL ON TABLE usrpref TO admin; GRANT ALL ON TABLE usrpref TO xtrole; publicadminfalse699125982316usrVIEWCREATE VIEW usr AS SELECT (pg_user.usesysid)::integer AS usr_id, (pg_user.usename)::text AS usr_username, COALESCE((SELECT usrpref.usrpref_value FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'propername'::text))), ''::text) AS usr_propername, NULL::text AS usr_passwd, COALESCE((SELECT (usrpref.usrpref_value)::integer AS usrpref_value FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'locale_id'::text))), COALESCE((SELECT locale.locale_id FROM locale WHERE (lower(locale.locale_code) = 'default'::text) LIMIT 1), (SELECT locale.locale_id FROM locale ORDER BY locale.locale_id LIMIT 1))) AS usr_locale_id, COALESCE((SELECT usrpref.usrpref_value FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'initials'::text))), ''::text) AS usr_initials, COALESCE((SELECT CASE WHEN (usrpref.usrpref_value = 't'::text) THEN true ELSE false END AS "case" FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'agent'::text))), false) AS usr_agent, COALESCE((SELECT CASE WHEN (usrpref.usrpref_value = 't'::text) THEN true ELSE false END AS "case" FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'active'::text))), usercanlogin((pg_user.usename)::text)) AS usr_active, COALESCE((SELECT usrpref.usrpref_value FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'email'::text))), ''::text) AS usr_email, COALESCE((SELECT usrpref.usrpref_value FROM usrpref WHERE ((usrpref.usrpref_username = (pg_user.usename)::text) AND (usrpref.usrpref_name = 'window'::text))), ''::text) AS usr_window FROM pg_user; DROP VIEW public.usr; publicadminfalse86488b+00usrACLREVOKE ALL ON TABLE usr FROM PUBLIC; REVOKE ALL ON TABLE usr FROM admin; GRANT ALL ON TABLE usr TO admin; GRANT ALL ON TABLE usr TO xtrole; publicadminfalse700125982321usr_bakTABLE]CREATE TABLE usr_bak ( usr_id integer DEFAULT nextval(('usr_usr_id_seq'::text)::regclass) NOT NULL, usr_username text NOT NULL, usr_propername text, usr_passwd text, usr_locale_id integer NOT NULL, usr_initials text, usr_agent boolean NOT NULL, usr_active boolean NOT NULL, usr_email text, usr_window text ); DROP TABLE public.usr_bak; publicadminfalse67508c+00 TABLE usr_bakCOMMENT0COMMENT ON TABLE usr_bak IS 'User information'; publicadminfalse701d+00usr_bakACLREVOKE ALL ON TABLE usr_bak FROM PUBLIC; REVOKE ALL ON TABLE usr_bak FROM admin; GRANT ALL ON TABLE usr_bak TO admin; GRANT ALL ON TABLE usr_bak TO xtrole; publicadminfalse701125982328usr_usr_id_seqSEQUENCExCREATE SEQUENCE usr_usr_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; %DROP SEQUENCE public.usr_usr_id_seq; publicadminfalse8e+00usr_usr_id_seqACLREVOKE ALL ON SEQUENCE usr_usr_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE usr_usr_id_seq FROM admin; GRANT ALL ON SEQUENCE usr_usr_id_seq TO admin; GRANT ALL ON SEQUENCE usr_usr_id_seq TO xtrole; publicadminfalse702125982330usrgrp_usrgrp_id_seqSEQUENCEvCREATE SEQUENCE usrgrp_usrgrp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.usrgrp_usrgrp_id_seq; publicadminfalse8608f+00usrgrp_usrgrp_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE usrgrp_usrgrp_id_seq OWNED BY usrgrp.usrgrp_id; publicadminfalse703g+00usrgrp_usrgrp_id_seqACLREVOKE ALL ON SEQUENCE usrgrp_usrgrp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE usrgrp_usrgrp_id_seq FROM admin; GRANT ALL ON SEQUENCE usrgrp_usrgrp_id_seq TO admin; GRANT ALL ON SEQUENCE usrgrp_usrgrp_id_seq TO xtrole; publicadminfalse703125982332usrpref_usrpref_id_seqSEQUENCECREATE SEQUENCE usrpref_usrpref_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.usrpref_usrpref_id_seq; publicadminfalse8h+00usrpref_usrpref_id_seqACLREVOKE ALL ON SEQUENCE usrpref_usrpref_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE usrpref_usrpref_id_seq FROM admin; GRANT ALL ON SEQUENCE usrpref_usrpref_id_seq TO admin; GRANT ALL ON SEQUENCE usrpref_usrpref_id_seq TO xtrole; publicadminfalse704125982334usrpriv_usrpriv_id_seqSEQUENCECREATE SEQUENCE usrpriv_usrpriv_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; -DROP SEQUENCE public.usrpriv_usrpriv_id_seq; publicadminfalse8i+00usrpriv_usrpriv_id_seqACLREVOKE ALL ON SEQUENCE usrpriv_usrpriv_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE usrpriv_usrpriv_id_seq FROM admin; GRANT ALL ON SEQUENCE usrpriv_usrpriv_id_seq TO admin; GRANT ALL ON SEQUENCE usrpriv_usrpriv_id_seq TO xtrole; publicadminfalse705125982336vendVIEWCREATE VIEW vend AS SELECT vendinfo.vend_id, vendinfo.vend_name, m.addr_line1 AS vend_address1, m.addr_line2 AS vend_address2, m.addr_line3 AS vend_address3, m.addr_city AS vend_city, m.addr_state AS vend_state, m.addr_postalcode AS vend_zip, btrim(((c1.cntct_first_name || ' '::text) || c1.cntct_last_name)) AS vend_contact1, c1.cntct_phone AS vend_phone1, btrim(((c2.cntct_first_name || ' '::text) || c2.cntct_last_name)) AS vend_contact2, c2.cntct_phone AS vend_phone2, vendinfo.vend_lastpurchdate, vendinfo.vend_active, vendinfo.vend_po, vendinfo.vend_comments, vendinfo.vend_pocomments, vendinfo.vend_number, c1.cntct_fax AS vend_fax1, c2.cntct_fax AS vend_fax2, c1.cntct_email AS vend_email1, c2.cntct_email AS vend_email2, vendinfo.vend_1099, vendinfo.vend_exported, vendinfo.vend_fobsource, vendinfo.vend_fob, vendinfo.vend_terms_id, vendinfo.vend_shipvia, vendinfo.vend_vendtype_id, vendinfo.vend_qualified, vendinfo.vend_ediemail, vendinfo.vend_ediemailbody, vendinfo.vend_edisubject, vendinfo.vend_edifilename, vendinfo.vend_accntnum, vendinfo.vend_emailpodelivery, vendinfo.vend_restrictpurch, vendinfo.vend_edicc, m.addr_country AS vend_country, vendinfo.vend_curr_id, vendinfo.vend_taxzone_id FROM (((vendinfo LEFT JOIN cntct c1 ON ((vendinfo.vend_cntct1_id = c1.cntct_id))) LEFT JOIN addr m ON ((vendinfo.vend_addr_id = m.addr_id))) LEFT JOIN cntct c2 ON ((vendinfo.vend_cntct2_id = c2.cntct_id))); DROP VIEW public.vend; publicadminfalse86498j+00vendACLREVOKE ALL ON TABLE vend FROM PUBLIC; REVOKE ALL ON TABLE vend FROM admin; GRANT ALL ON TABLE vend TO admin; GRANT ALL ON TABLE vend TO xtrole; publicadminfalse706125982341vend_vend_id_seqSEQUENCEzCREATE SEQUENCE vend_vend_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; 'DROP SEQUENCE public.vend_vend_id_seq; publicadminfalse8k+00vend_vend_id_seqACLREVOKE ALL ON SEQUENCE vend_vend_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE vend_vend_id_seq FROM admin; GRANT ALL ON SEQUENCE vend_vend_id_seq TO admin; GRANT ALL ON SEQUENCE vend_vend_id_seq TO xtrole; publicadminfalse707125982343vendaddrVIEWCREATE VIEW vendaddr AS SELECT vendaddrinfo.vendaddr_id, vendaddrinfo.vendaddr_vend_id, vendaddrinfo.vendaddr_code, vendaddrinfo.vendaddr_name, m.addr_line1 AS vendaddr_address1, m.addr_line2 AS vendaddr_address2, m.addr_line3 AS vendaddr_address3, btrim(((c1.cntct_first_name || ' '::text) || c1.cntct_last_name)) AS vendaddr_contact1, c1.cntct_phone AS vendaddr_phone1, c1.cntct_fax AS vendaddr_fax1, m.addr_city AS vendaddr_city, m.addr_state AS vendaddr_state, m.addr_postalcode AS vendaddr_zipcode, m.addr_country AS vendaddr_country FROM ((vendaddrinfo LEFT JOIN cntct c1 ON ((vendaddrinfo.vendaddr_cntct_id = c1.cntct_id))) LEFT JOIN addr m ON ((vendaddrinfo.vendaddr_addr_id = m.addr_id))); DROP VIEW public.vendaddr; publicadminfalse86508l+00vendaddrACLREVOKE ALL ON TABLE vendaddr FROM PUBLIC; REVOKE ALL ON TABLE vendaddr FROM admin; GRANT ALL ON TABLE vendaddr TO admin; GRANT ALL ON TABLE vendaddr TO xtrole; publicadminfalse708125982348vendaddr_vendaddr_id_seqSEQUENCECREATE SEQUENCE vendaddr_vendaddr_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; /DROP SEQUENCE public.vendaddr_vendaddr_id_seq; publicadminfalse8m+00vendaddr_vendaddr_id_seqACLREVOKE ALL ON SEQUENCE vendaddr_vendaddr_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE vendaddr_vendaddr_id_seq FROM admin; GRANT ALL ON SEQUENCE vendaddr_vendaddr_id_seq TO admin; GRANT ALL ON SEQUENCE vendaddr_vendaddr_id_seq TO xtrole; publicadminfalse709125982350vendtype_vendtype_id_seqSEQUENCEzCREATE SEQUENCE vendtype_vendtype_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.vendtype_vendtype_id_seq; publicadminfalse8285n+00vendtype_vendtype_id_seqSEQUENCE OWNED BYGALTER SEQUENCE vendtype_vendtype_id_seq OWNED BY vendtype.vendtype_id; publicadminfalse710o+00vendtype_vendtype_id_seqACLREVOKE ALL ON SEQUENCE vendtype_vendtype_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE vendtype_vendtype_id_seq FROM admin; GRANT ALL ON SEQUENCE vendtype_vendtype_id_seq TO admin; GRANT ALL ON SEQUENCE vendtype_vendtype_id_seq TO xtrole; publicadminfalse710125982352vodistTABLECREATE TABLE vodist ( vodist_id integer DEFAULT nextval(('"vodist_vodist_id_seq"'::text)::regclass) NOT NULL, vodist_poitem_id integer, vodist_vohead_id integer, vodist_costelem_id integer, vodist_accnt_id integer, vodist_amount numeric(18,6), vodist_qty numeric(18,6), vodist_expcat_id integer DEFAULT (-1), vodist_tax_id integer DEFAULT (-1), vodist_discountable boolean DEFAULT true NOT NULL, vodist_notes text ); DROP TABLE public.vodist; publicadminfalse67516752675367548p+00 TABLE vodistCOMMENT?COMMENT ON TABLE vodist IS 'Voucher distribution information'; publicadminfalse711q+00vodistACLREVOKE ALL ON TABLE vodist FROM PUBLIC; REVOKE ALL ON TABLE vodist FROM admin; GRANT ALL ON TABLE vodist TO admin; GRANT ALL ON TABLE vodist TO xtrole; publicadminfalse711125982362vodist_vodist_id_seqSEQUENCEvCREATE SEQUENCE vodist_vodist_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.vodist_vodist_id_seq; publicadminfalse8r+00vodist_vodist_id_seqACLREVOKE ALL ON SEQUENCE vodist_vodist_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE vodist_vodist_id_seq FROM admin; GRANT ALL ON SEQUENCE vodist_vodist_id_seq TO admin; GRANT ALL ON SEQUENCE vodist_vodist_id_seq TO xtrole; publicadminfalse712125982364voheadTABLE<CREATE TABLE vohead ( vohead_id integer DEFAULT nextval(('vohead_vohead_id_seq'::text)::regclass) NOT NULL, vohead_number text NOT NULL, vohead_pohead_id integer, vohead_posted boolean, vohead_duedate date, vohead_invcnumber text, vohead_amount numeric(16,4), vohead_docdate date, vohead_1099 boolean, vohead_distdate date, vohead_reference text, vohead_terms_id integer, vohead_vend_id integer, vohead_curr_id integer DEFAULT basecurrid(), vohead_adjtaxtype_id integer, vohead_freighttaxtype_id integer, vohead_gldistdate date, vohead_misc boolean, vohead_taxzone_id integer, vohead_taxtype_id integer, vohead_notes text, vohead_recurring_vohead_id integer, CONSTRAINT vohead_vohead_number_check CHECK ((vohead_number <> ''::text)) ); DROP TABLE public.vohead; publicadminfalse6755675667578s+00 TABLE voheadCOMMENT9COMMENT ON TABLE vohead IS 'Voucher header information'; publicadminfalse713t+00voheadACLREVOKE ALL ON TABLE vohead FROM PUBLIC; REVOKE ALL ON TABLE vohead FROM admin; GRANT ALL ON TABLE vohead TO admin; GRANT ALL ON TABLE vohead TO xtrole; publicadminfalse713125982373vohead_vohead_id_seqSEQUENCEvCREATE SEQUENCE vohead_vohead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.vohead_vohead_id_seq; publicadminfalse8u+00vohead_vohead_id_seqACLREVOKE ALL ON SEQUENCE vohead_vohead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE vohead_vohead_id_seq FROM admin; GRANT ALL ON SEQUENCE vohead_vohead_id_seq TO admin; GRANT ALL ON SEQUENCE vohead_vohead_id_seq TO xtrole; publicadminfalse714125982375 voheadtaxTABLE/CREATE TABLE voheadtax ( ) INHERITS (taxhist); DROP TABLE public.voheadtax; publicadminfalse8281v+00 voheadtaxACLREVOKE ALL ON TABLE voheadtax FROM PUBLIC; REVOKE ALL ON TABLE voheadtax FROM admin; GRANT ALL ON TABLE voheadtax TO admin; GRANT ALL ON TABLE voheadtax TO xtrole; publicadminfalse715125982381voitemTABLE>CREATE TABLE voitem ( voitem_id integer DEFAULT nextval(('"voitem_voitem_id_seq"'::text)::regclass) NOT NULL, voitem_vohead_id integer, voitem_poitem_id integer, voitem_close boolean, voitem_qty numeric(18,6), voitem_freight numeric(16,4) DEFAULT 0.0 NOT NULL, voitem_taxtype_id integer ); DROP TABLE public.voitem; publicadminfalse675967608w+00 TABLE voitemCOMMENT<COMMENT ON TABLE voitem IS 'Voucher Line Item information'; publicadminfalse716x+00voitemACLREVOKE ALL ON TABLE voitem FROM PUBLIC; REVOKE ALL ON TABLE voitem FROM admin; GRANT ALL ON TABLE voitem TO admin; GRANT ALL ON TABLE voitem TO xtrole; publicadminfalse716125982386voitem_voitem_id_seqSEQUENCEvCREATE SEQUENCE voitem_voitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +DROP SEQUENCE public.voitem_voitem_id_seq; publicadminfalse8y+00voitem_voitem_id_seqACLREVOKE ALL ON SEQUENCE voitem_voitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE voitem_voitem_id_seq FROM admin; GRANT ALL ON SEQUENCE voitem_voitem_id_seq TO admin; GRANT ALL ON SEQUENCE voitem_voitem_id_seq TO xtrole; publicadminfalse717125982388 voitemtaxTABLE/CREATE TABLE voitemtax ( ) INHERITS (taxhist); DROP TABLE public.voitemtax; publicadminfalse8281z+00 voitemtaxACLREVOKE ALL ON TABLE voitemtax FROM PUBLIC; REVOKE ALL ON TABLE voitemtax FROM admin; GRANT ALL ON TABLE voitemtax TO admin; GRANT ALL ON TABLE voitemtax TO xtrole; publicadminfalse718125982394warehousVIEWdCREATE VIEW warehous AS SELECT whsinfo.warehous_id, whsinfo.warehous_code, whsinfo.warehous_descrip, m.addr_line1 AS warehous_addr1, m.addr_line2 AS warehous_addr2, m.addr_line3 AS warehous_addr3, m.addr_city AS warehous_addr4, m.addr_city AS warehous_city, m.addr_state AS warehous_state, m.addr_postalcode AS warehous_zip, m.addr_country AS warehous_country, whsinfo.warehous_fob, whsinfo.warehous_active, whsinfo.warehous_sitetype_id, whsinfo.warehous_counttag_prefix, whsinfo.warehous_counttag_number, whsinfo.warehous_bol_prefix, whsinfo.warehous_bol_number, whsinfo.warehous_shipping, whsinfo.warehous_useslips, whsinfo.warehous_usezones, whsinfo.warehous_aislesize, whsinfo.warehous_aislealpha, whsinfo.warehous_racksize, whsinfo.warehous_rackalpha, whsinfo.warehous_binsize, whsinfo.warehous_binalpha, whsinfo.warehous_locationsize, whsinfo.warehous_locationalpha, whsinfo.warehous_enforcearbl, whsinfo.warehous_default_accnt_id, whsinfo.warehous_shipping_commission FROM ((whsinfo LEFT JOIN cntct c1 ON ((whsinfo.warehous_cntct_id = c1.cntct_id))) LEFT JOIN addr m ON ((whsinfo.warehous_addr_id = m.addr_id))); DROP VIEW public.warehous; publicadminfalse86518{+00warehousACLREVOKE ALL ON TABLE warehous FROM PUBLIC; REVOKE ALL ON TABLE warehous FROM admin; GRANT ALL ON TABLE warehous TO admin; GRANT ALL ON TABLE warehous TO xtrole; publicadminfalse719125982399warehous_warehous_id_seqSEQUENCECREATE SEQUENCE warehous_warehous_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; /DROP SEQUENCE public.warehous_warehous_id_seq; publicadminfalse8|+00warehous_warehous_id_seqACLREVOKE ALL ON SEQUENCE warehous_warehous_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE warehous_warehous_id_seq FROM admin; GRANT ALL ON SEQUENCE warehous_warehous_id_seq TO admin; GRANT ALL ON SEQUENCE warehous_warehous_id_seq TO xtrole; publicadminfalse720125982401whsezone_whsezone_id_seqSEQUENCEzCREATE SEQUENCE whsezone_whsezone_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.whsezone_whsezone_id_seq; publicadminfalse8267}+00whsezone_whsezone_id_seqSEQUENCE OWNED BYGALTER SEQUENCE whsezone_whsezone_id_seq OWNED BY whsezone.whsezone_id; publicadminfalse721~+00whsezone_whsezone_id_seqACLREVOKE ALL ON SEQUENCE whsezone_whsezone_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE whsezone_whsezone_id_seq FROM admin; GRANT ALL ON SEQUENCE whsezone_whsezone_id_seq TO admin; GRANT ALL ON SEQUENCE whsezone_whsezone_id_seq TO xtrole; publicadminfalse721125981248woTABLECREATE TABLE wo ( wo_id integer DEFAULT nextval(('wo_wo_id_seq'::text)::regclass) NOT NULL, wo_number integer, wo_subnumber integer, wo_status character(1), wo_itemsite_id integer, wo_startdate date, wo_duedate date, wo_ordtype character(1), wo_ordid integer, wo_qtyord numeric(18,6), wo_qtyrcv numeric(18,6), wo_adhoc boolean, wo_itemcfg_series integer, wo_imported boolean, wo_wipvalue numeric(16,6) DEFAULT 0, wo_postedvalue numeric(16,6) DEFAULT 0, wo_prodnotes text, wo_prj_id integer, wo_priority integer DEFAULT 1 NOT NULL, wo_brdvalue numeric(16,6) DEFAULT 0, wo_bom_rev_id integer DEFAULT (-1), wo_boo_rev_id integer DEFAULT (-1), wo_cosmethod character(1), wo_womatl_id integer, wo_username text DEFAULT geteffectivextuser(), CONSTRAINT chk_wo_cosmethod CHECK ((((wo_cosmethod = NULL::bpchar) OR (wo_cosmethod = 'D'::bpchar)) OR (wo_cosmethod = 'P'::bpchar))) ); DROP TABLE public.wo; publicadminfalse6494649564966497649864996500650165028+00TABLE woCOMMENT1COMMENT ON TABLE wo IS 'Work Order information'; publicadminfalse444+00woACLREVOKE ALL ON TABLE wo FROM PUBLIC; REVOKE ALL ON TABLE wo FROM admin; GRANT ALL ON TABLE wo TO admin; GRANT ALL ON TABLE wo TO xtrole; publicadminfalse444125982403 wo_wo_id_seqSEQUENCEvCREATE SEQUENCE wo_wo_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; #DROP SEQUENCE public.wo_wo_id_seq; publicadminfalse8+00 wo_wo_id_seqACLREVOKE ALL ON SEQUENCE wo_wo_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE wo_wo_id_seq FROM admin; GRANT ALL ON SEQUENCE wo_wo_id_seq TO admin; GRANT ALL ON SEQUENCE wo_wo_id_seq TO xtrole; publicadminfalse722125982405womatl_womatl_id_seqSEQUENCE~CREATE SEQUENCE womatl_womatl_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; +DROP SEQUENCE public.womatl_womatl_id_seq; publicadminfalse8+00womatl_womatl_id_seqACLREVOKE ALL ON SEQUENCE womatl_womatl_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE womatl_womatl_id_seq FROM admin; GRANT ALL ON SEQUENCE womatl_womatl_id_seq TO admin; GRANT ALL ON SEQUENCE womatl_womatl_id_seq TO xtrole; publicadminfalse723125982407 womatlpostTABLECREATE TABLE womatlpost ( womatlpost_id integer NOT NULL, womatlpost_womatl_id integer, womatlpost_invhist_id integer ); DROP TABLE public.womatlpost; publicadminfalse8+00TABLE womatlpostCOMMENTtCOMMENT ON TABLE womatlpost IS 'Table to tie work order to work order material transactions for efficient queries'; publicadminfalse724+00 womatlpostACLREVOKE ALL ON TABLE womatlpost FROM PUBLIC; REVOKE ALL ON TABLE womatlpost FROM admin; GRANT ALL ON TABLE womatlpost TO admin; GRANT ALL ON TABLE womatlpost TO xtrole; publicadminfalse724125982410womatlpost_womatlpost_id_seqSEQUENCE~CREATE SEQUENCE womatlpost_womatlpost_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 3DROP SEQUENCE public.womatlpost_womatlpost_id_seq; publicadminfalse8724+00womatlpost_womatlpost_id_seqSEQUENCE OWNED BYOALTER SEQUENCE womatlpost_womatlpost_id_seq OWNED BY womatlpost.womatlpost_id; publicadminfalse725+00womatlpost_womatlpost_id_seqACLREVOKE ALL ON SEQUENCE womatlpost_womatlpost_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE womatlpost_womatlpost_id_seq FROM admin; GRANT ALL ON SEQUENCE womatlpost_womatlpost_id_seq TO admin; GRANT ALL ON SEQUENCE womatlpost_womatlpost_id_seq TO xtrole; publicadminfalse725125982412 womatlvarTABLECREATE TABLE womatlvar ( womatlvar_id integer DEFAULT nextval(('"womatlvar_womatlvar_id_seq"'::text)::regclass) NOT NULL, womatlvar_number integer, womatlvar_subnumber integer, womatlvar_posted date, womatlvar_parent_itemsite_id integer, womatlvar_component_itemsite_id integer, womatlvar_qtyord numeric(18,6), womatlvar_qtyrcv numeric(18,6), womatlvar_qtyiss numeric(18,6), womatlvar_qtyper numeric(18,6), womatlvar_scrap numeric(18,6), womatlvar_wipscrap numeric(18,6), womatlvar_bomitem_id integer, womatlvar_ref text, womatlvar_notes text, womatlvar_qtyfxd numeric(20,8) DEFAULT 0 NOT NULL ); DROP TABLE public.womatlvar; publicadminfalse676367648+00TABLE womatlvarCOMMENTWCOMMENT ON TABLE womatlvar IS 'Work Order Material Requirements Variance information'; publicadminfalse726+00!COLUMN womatlvar.womatlvar_qtyfxdCOMMENTOCOMMENT ON COLUMN womatlvar.womatlvar_qtyfxd IS 'The fixed quantity required'; publicadminfalse726+00 womatlvarACLREVOKE ALL ON TABLE womatlvar FROM PUBLIC; REVOKE ALL ON TABLE womatlvar FROM admin; GRANT ALL ON TABLE womatlvar TO admin; GRANT ALL ON TABLE womatlvar TO xtrole; publicadminfalse726125982420womatlvar_womatlvar_id_seqSEQUENCECREATE SEQUENCE womatlvar_womatlvar_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE MAXVALUE 2147483647 CACHE 1; 1DROP SEQUENCE public.womatlvar_womatlvar_id_seq; publicadminfalse8+00womatlvar_womatlvar_id_seqACLREVOKE ALL ON SEQUENCE womatlvar_womatlvar_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE womatlvar_womatlvar_id_seq FROM admin; GRANT ALL ON SEQUENCE womatlvar_womatlvar_id_seq TO admin; GRANT ALL ON SEQUENCE womatlvar_womatlvar_id_seq TO xtrole; publicadminfalse727125982422xcalitem_xcalitem_id_seqSEQUENCEzCREATE SEQUENCE xcalitem_xcalitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE public.xcalitem_xcalitem_id_seq; publicadminfalse8+00xcalitem_xcalitem_id_seqACLREVOKE ALL ON SEQUENCE xcalitem_xcalitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE xcalitem_xcalitem_id_seq FROM admin; GRANT ALL ON SEQUENCE xcalitem_xcalitem_id_seq TO admin; GRANT ALL ON SEQUENCE xcalitem_xcalitem_id_seq TO xtrole; publicadminfalse728125982424xsltmapTABLE"CREATE TABLE xsltmap ( xsltmap_id integer NOT NULL, xsltmap_name text NOT NULL, xsltmap_doctype text NOT NULL, xsltmap_system text NOT NULL, xsltmap_import text NOT NULL, xsltmap_export text DEFAULT ''::text NOT NULL, CONSTRAINT xsltmap_check CHECK (((xsltmap_doctype <> ''::text) OR (xsltmap_system <> ''::text))), CONSTRAINT xsltmap_xsltmap_importexport_check CHECK (((xsltmap_import <> ''::text) OR (xsltmap_export <> ''::text))), CONSTRAINT xsltmap_xsltmap_name_check CHECK ((xsltmap_name <> ''::text)) ); DROP TABLE public.xsltmap; publicadminfalse67666767676867698+00 TABLE xsltmapCOMMENT^COMMENT ON TABLE xsltmap IS 'Mapping of XML System identifiers to XSLT transformation files'; publicadminfalse729+00xsltmapACLREVOKE ALL ON TABLE xsltmap FROM PUBLIC; REVOKE ALL ON TABLE xsltmap FROM admin; GRANT ALL ON TABLE xsltmap TO admin; GRANT ALL ON TABLE xsltmap TO xtrole; publicadminfalse729125982434xsltmap_xsltmap_id_seqSEQUENCExCREATE SEQUENCE xsltmap_xsltmap_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE public.xsltmap_xsltmap_id_seq; publicadminfalse8729+00xsltmap_xsltmap_id_seqSEQUENCE OWNED BYCALTER SEQUENCE xsltmap_xsltmap_id_seq OWNED BY xsltmap.xsltmap_id; publicadminfalse730+00xsltmap_xsltmap_id_seqACLREVOKE ALL ON SEQUENCE xsltmap_xsltmap_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE xsltmap_xsltmap_id_seq FROM admin; GRANT ALL ON SEQUENCE xsltmap_xsltmap_id_seq TO admin; GRANT ALL ON SEQUENCE xsltmap_xsltmap_id_seq TO xtrole; publicadminfalse730125982436 yearperiodTABLECREATE TABLE yearperiod ( yearperiod_id integer NOT NULL, yearperiod_start date NOT NULL, yearperiod_end date NOT NULL, yearperiod_closed boolean DEFAULT false NOT NULL ); DROP TABLE public.yearperiod; publicadminfalse67718+00TABLE yearperiodCOMMENTFCOMMENT ON TABLE yearperiod IS 'Accounting Year Periods information'; publicadminfalse731+00 yearperiodACLREVOKE ALL ON TABLE yearperiod FROM PUBLIC; REVOKE ALL ON TABLE yearperiod FROM admin; GRANT ALL ON TABLE yearperiod TO admin; GRANT ALL ON TABLE yearperiod TO xtrole; publicadminfalse731125982440yearperiod_yearperiod_id_seqSEQUENCE~CREATE SEQUENCE yearperiod_yearperiod_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 3DROP SEQUENCE public.yearperiod_yearperiod_id_seq; publicadminfalse8731+00yearperiod_yearperiod_id_seqSEQUENCE OWNED BYOALTER SEQUENCE yearperiod_yearperiod_id_seq OWNED BY yearperiod.yearperiod_id; publicadminfalse732+00yearperiod_yearperiod_id_seqACLREVOKE ALL ON SEQUENCE yearperiod_yearperiod_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE yearperiod_yearperiod_id_seq FROM admin; GRANT ALL ON SEQUENCE yearperiod_yearperiod_id_seq TO admin; GRANT ALL ON SEQUENCE yearperiod_yearperiod_id_seq TO xtrole; publicadminfalse732125982442pkgcmdTABLEuCREATE TABLE pkgcmd ( cmd_id integer DEFAULT nextval('public.cmd_cmd_id_seq'::regclass) ) INHERITS (public.cmd); DROP TABLE te.pkgcmd; teadminfalse67729286+00pkgcmdACLREVOKE ALL ON TABLE pkgcmd FROM PUBLIC; REVOKE ALL ON TABLE pkgcmd FROM admin; GRANT ALL ON TABLE pkgcmd TO admin; GRANT ALL ON TABLE pkgcmd TO xtrole; teadminfalse733125982449 pkgcmdargTABLECREATE TABLE pkgcmdarg ( cmdarg_id integer DEFAULT nextval('public.cmdarg_cmdarg_id_seq'::regclass) ) INHERITS (public.cmdarg); DROP TABLE te.pkgcmdarg; teadminfalse67739289+00 pkgcmdargACLREVOKE ALL ON TABLE pkgcmdarg FROM PUBLIC; REVOKE ALL ON TABLE pkgcmdarg FROM admin; GRANT ALL ON TABLE pkgcmdarg TO admin; GRANT ALL ON TABLE pkgcmdarg TO xtrole; teadminfalse734125982456pkgimageTABLECREATE TABLE pkgimage ( image_id integer DEFAULT nextval('public.image_image_id_seq'::regclass) ) INHERITS (public.image); DROP TABLE te.pkgimage; teadminfalse67749223+00pkgimageACLREVOKE ALL ON TABLE pkgimage FROM PUBLIC; REVOKE ALL ON TABLE pkgimage FROM admin; GRANT ALL ON TABLE pkgimage TO admin; GRANT ALL ON TABLE pkgimage TO xtrole; teadminfalse735125982463 pkgmetasqlTABLECREATE TABLE pkgmetasql ( metasql_id integer DEFAULT nextval('public.metasql_metasql_id_seq'::regclass) ) INHERITS (public.metasql); DROP TABLE te.pkgmetasql; teadminfalse67759294+00 pkgmetasqlACLREVOKE ALL ON TABLE pkgmetasql FROM PUBLIC; REVOKE ALL ON TABLE pkgmetasql FROM admin; GRANT ALL ON TABLE pkgmetasql TO admin; GRANT ALL ON TABLE pkgmetasql TO xtrole; teadminfalse736125982471pkgprivTABLEzCREATE TABLE pkgpriv ( priv_id integer DEFAULT nextval('public.priv_priv_id_seq'::regclass) ) INHERITS (public.priv); DROP TABLE te.pkgpriv; teadminfalse67779297+00pkgprivACLREVOKE ALL ON TABLE pkgpriv FROM PUBLIC; REVOKE ALL ON TABLE pkgpriv FROM admin; GRANT ALL ON TABLE pkgpriv TO admin; GRANT ALL ON TABLE pkgpriv TO xtrole; teadminfalse737125982478 pkgreportTABLECREATE TABLE pkgreport ( report_id integer DEFAULT nextval('public.report_report_id_seq'::regclass) ) INHERITS (public.report); DROP TABLE te.pkgreport; teadminfalse67789300+00 pkgreportACLREVOKE ALL ON TABLE pkgreport FROM PUBLIC; REVOKE ALL ON TABLE pkgreport FROM admin; GRANT ALL ON TABLE pkgreport TO admin; GRANT ALL ON TABLE pkgreport TO xtrole; teadminfalse738125982485 pkgscriptTABLECREATE TABLE pkgscript ( script_id integer DEFAULT nextval('public.script_script_id_seq'::regclass) ) INHERITS (public.script); DROP TABLE te.pkgscript; teadminfalse67799303+00 pkgscriptACLREVOKE ALL ON TABLE pkgscript FROM PUBLIC; REVOKE ALL ON TABLE pkgscript FROM admin; GRANT ALL ON TABLE pkgscript TO admin; GRANT ALL ON TABLE pkgscript TO xtrole; teadminfalse739125982493 pkguiformTABLECREATE TABLE pkguiform ( uiform_id integer DEFAULT nextval('public.uiform_uiform_id_seq'::regclass) ) INHERITS (public.uiform); DROP TABLE te.pkguiform; teadminfalse67819306+00 pkguiformACLREVOKE ALL ON TABLE pkguiform FROM PUBLIC; REVOKE ALL ON TABLE pkguiform FROM admin; GRANT ALL ON TABLE pkguiform TO admin; GRANT ALL ON TABLE pkguiform TO xtrole; teadminfalse740125982501 tecustrateTABLECREATE TABLE tecustrate ( tecustrate_cust_id integer NOT NULL, tecustrate_rate numeric(16,4) NOT NULL, tecustrate_id integer NOT NULL, tecustrate_curr_id integer DEFAULT public.basecurrid() NOT NULL ); DROP TABLE te.tecustrate; teadminfalse67849+00TABLE tecustrateCOMMENT0COMMENT ON TABLE tecustrate IS 'Customer rate'; teadminfalse741+00 tecustrateACLREVOKE ALL ON TABLE tecustrate FROM PUBLIC; REVOKE ALL ON TABLE tecustrate FROM admin; GRANT ALL ON TABLE tecustrate TO admin; GRANT ALL ON TABLE tecustrate TO xtrole; teadminfalse741125982505tecustrate_tecustrate_id_seqSEQUENCE~CREATE SEQUENCE tecustrate_tecustrate_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; /DROP SEQUENCE te.tecustrate_tecustrate_id_seq; teadminfalse9741+00tecustrate_tecustrate_id_seqSEQUENCE OWNED BYOALTER SEQUENCE tecustrate_tecustrate_id_seq OWNED BY tecustrate.tecustrate_id; teadminfalse742+00tecustrate_tecustrate_id_seqACLREVOKE ALL ON SEQUENCE tecustrate_tecustrate_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE tecustrate_tecustrate_id_seq FROM admin; GRANT ALL ON SEQUENCE tecustrate_tecustrate_id_seq TO admin; GRANT ALL ON SEQUENCE tecustrate_tecustrate_id_seq TO xtrole; teadminfalse742125982507teempTABLE|CREATE TABLE teemp ( teemp_id integer NOT NULL, teemp_emp_id integer, teemp_contractor boolean DEFAULT false ); DROP TABLE te.teemp; teadminfalse67869+00 TABLE teempCOMMENT3COMMENT ON TABLE teemp IS 'Time Expense Employee'; teadminfalse743+00teempACLREVOKE ALL ON TABLE teemp FROM PUBLIC; REVOKE ALL ON TABLE teemp FROM admin; GRANT ALL ON TABLE teemp TO admin; GRANT ALL ON TABLE teemp TO xtrole; teadminfalse743125982511teemp_teemp_id_seqSEQUENCEtCREATE SEQUENCE teemp_teemp_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; %DROP SEQUENCE te.teemp_teemp_id_seq; teadminfalse9743+00teemp_teemp_id_seqSEQUENCE OWNED BY;ALTER SEQUENCE teemp_teemp_id_seq OWNED BY teemp.teemp_id; teadminfalse744+00teemp_teemp_id_seqACLREVOKE ALL ON SEQUENCE teemp_teemp_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE teemp_teemp_id_seq FROM admin; GRANT ALL ON SEQUENCE teemp_teemp_id_seq TO admin; GRANT ALL ON SEQUENCE teemp_teemp_id_seq TO xtrole; teadminfalse744125982513teexpTABLEoCREATE TABLE teexp ( teexp_id integer NOT NULL, teexp_expcat_id integer, teexp_accnt_id integer ); DROP TABLE te.teexp; teadminfalse9+00 TABLE teexpCOMMENT6COMMENT ON TABLE teexp IS 'Time Expense Item Master'; teadminfalse745+00teexpACLREVOKE ALL ON TABLE teexp FROM PUBLIC; REVOKE ALL ON TABLE teexp FROM admin; GRANT ALL ON TABLE teexp TO admin; GRANT ALL ON TABLE teexp TO xtrole; teadminfalse745125982516 timesheet_seqSEQUENCErCREATE SEQUENCE timesheet_seq START WITH 1000 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; DROP SEQUENCE te.timesheet_seq; teadminfalse9+00 timesheet_seqACLREVOKE ALL ON SEQUENCE timesheet_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE timesheet_seq FROM admin; GRANT ALL ON SEQUENCE timesheet_seq TO admin; GRANT ALL ON SEQUENCE timesheet_seq TO xtrole; teadminfalse746125982518teheadTABLE9CREATE TABLE tehead ( tehead_id integer NOT NULL, tehead_number text DEFAULT nextval('timesheet_seq'::regclass), tehead_weekending date, tehead_lastupdated timestamp without time zone DEFAULT now() NOT NULL, tehead_notes text, tehead_status character(1) DEFAULT 'O'::bpchar NOT NULL, tehead_emp_id integer, tehead_warehous_id integer NOT NULL, tehead_username text DEFAULT public.geteffectivextuser() NOT NULL, CONSTRAINT tehead_tehead_status_check CHECK ((tehead_status = ANY (ARRAY['O'::bpchar, 'A'::bpchar, 'C'::bpchar]))) ); DROP TABLE te.tehead; teadminfalse678767886789679167929+00 TABLE teheadCOMMENT<COMMENT ON TABLE tehead IS 'Time/Expense Worksheet Header'; teadminfalse747+00teheadACLREVOKE ALL ON TABLE tehead FROM PUBLIC; REVOKE ALL ON TABLE tehead FROM admin; GRANT ALL ON TABLE tehead TO admin; GRANT ALL ON TABLE tehead TO xtrole; teadminfalse747125982529tehead_tehead_id_seqSEQUENCEvCREATE SEQUENCE tehead_tehead_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 'DROP SEQUENCE te.tehead_tehead_id_seq; teadminfalse9747+00tehead_tehead_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE tehead_tehead_id_seq OWNED BY tehead.tehead_id; teadminfalse748+00tehead_tehead_id_seqACLREVOKE ALL ON SEQUENCE tehead_tehead_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE tehead_tehead_id_seq FROM admin; GRANT ALL ON SEQUENCE tehead_tehead_id_seq TO admin; GRANT ALL ON SEQUENCE tehead_tehead_id_seq TO xtrole; teadminfalse748125982531teitemTABLECREATE TABLE teitem ( teitem_id integer NOT NULL, teitem_tehead_id integer, teitem_linenumber integer NOT NULL, teitem_type character(1) NOT NULL, teitem_workdate date, teitem_cust_id integer, teitem_vend_id integer, teitem_po text, teitem_item_id integer NOT NULL, teitem_qty numeric NOT NULL, teitem_rate numeric NOT NULL, teitem_total numeric NOT NULL, teitem_prjtask_id integer, teitem_lastupdated timestamp without time zone DEFAULT ('now'::text)::timestamp(6) with time zone NOT NULL, teitem_billable boolean, teitem_prepaid boolean, teitem_notes text, teitem_posted boolean DEFAULT false, teitem_curr_id integer DEFAULT public.basecurrid() NOT NULL, teitem_uom_id integer, teitem_invcitem_id integer, teitem_vodist_id integer, teitem_postedvalue numeric DEFAULT 0 NOT NULL, teitem_empcost numeric ); DROP TABLE te.teitem; teadminfalse67936794679567969+00 TABLE teitemCOMMENT:COMMENT ON TABLE teitem IS 'Time Expense Worksheet Item'; teadminfalse749+00COLUMN teitem.teitem_typeCOMMENT2COMMENT ON COLUMN teitem.teitem_type IS 'T or E'; teadminfalse749+00COLUMN teitem.teitem_vend_idCOMMENT^COMMENT ON COLUMN teitem.teitem_vend_id IS 'future use - for payment of vendor for expenses'; teadminfalse749+00COLUMN teitem.teitem_prepaidCOMMENTjCOMMENT ON COLUMN teitem.teitem_prepaid IS 'Used for expenses only. CC paid expenses would be prepaid.'; teadminfalse749+00teitemACLREVOKE ALL ON TABLE teitem FROM PUBLIC; REVOKE ALL ON TABLE teitem FROM admin; GRANT ALL ON TABLE teitem TO admin; GRANT ALL ON TABLE teitem TO xtrole; teadminfalse749125982541teitem_teitem_id_seqSEQUENCEvCREATE SEQUENCE teitem_teitem_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; 'DROP SEQUENCE te.teitem_teitem_id_seq; teadminfalse9749+00teitem_teitem_id_seqSEQUENCE OWNED BY?ALTER SEQUENCE teitem_teitem_id_seq OWNED BY teitem.teitem_id; teadminfalse750+00teitem_teitem_id_seqACLREVOKE ALL ON SEQUENCE teitem_teitem_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE teitem_teitem_id_seq FROM admin; GRANT ALL ON SEQUENCE teitem_teitem_id_seq TO admin; GRANT ALL ON SEQUENCE teitem_teitem_id_seq TO xtrole; teadminfalse750125982543teprjTABLECREATE TABLE teprj ( teprj_id integer NOT NULL, teprj_prj_id integer, teprj_cust_id integer, teprj_rate numeric, teprj_curr_id integer ); DROP TABLE te.teprj; teadminfalse9+00 TABLE teprjCOMMENTCCOMMENT ON TABLE teprj IS 'Time/Expense Information for Projects'; teadminfalse751+00teprjACLREVOKE ALL ON TABLE teprj FROM PUBLIC; REVOKE ALL ON TABLE teprj FROM admin; GRANT ALL ON TABLE teprj TO admin; GRANT ALL ON TABLE teprj TO xtrole; teadminfalse751125982549teprj_teprj_id_seqSEQUENCEtCREATE SEQUENCE teprj_teprj_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; %DROP SEQUENCE te.teprj_teprj_id_seq; teadminfalse9751+00teprj_teprj_id_seqSEQUENCE OWNED BY;ALTER SEQUENCE teprj_teprj_id_seq OWNED BY teprj.teprj_id; teadminfalse752+00teprj_teprj_id_seqACLREVOKE ALL ON SEQUENCE teprj_teprj_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE teprj_teprj_id_seq FROM admin; GRANT ALL ON SEQUENCE teprj_teprj_id_seq TO admin; GRANT ALL ON SEQUENCE teprj_teprj_id_seq TO xtrole; teadminfalse752125982551 teprjtaskTABLECREATE TABLE teprjtask ( teprjtask_id integer NOT NULL, teprjtask_cust_id integer, teprjtask_rate numeric, teprjtask_item_id integer, teprjtask_prjtask_id integer NOT NULL, teprjtask_curr_id integer DEFAULT public.basecurrid() ); DROP TABLE te.teprjtask; teadminfalse68009+00TABLE teprjtaskCOMMENT;COMMENT ON TABLE teprjtask IS 'Time Expense Project Task'; teadminfalse753+00 teprjtaskACLREVOKE ALL ON TABLE teprjtask FROM PUBLIC; REVOKE ALL ON TABLE teprjtask FROM admin; GRANT ALL ON TABLE teprjtask TO admin; GRANT ALL ON TABLE teprjtask TO xtrole; teadminfalse753125982558teprjtask_teprjtask_id_seqSEQUENCE|CREATE SEQUENCE teprjtask_teprjtask_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; -DROP SEQUENCE te.teprjtask_teprjtask_id_seq; teadminfalse9753+00teprjtask_teprjtask_id_seqSEQUENCE OWNED BYKALTER SEQUENCE teprjtask_teprjtask_id_seq OWNED BY teprjtask.teprjtask_id; teadminfalse754+00teprjtask_teprjtask_id_seqACLREVOKE ALL ON SEQUENCE teprjtask_teprjtask_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE teprjtask_teprjtask_id_seq FROM admin; GRANT ALL ON SEQUENCE teprjtask_teprjtask_id_seq TO admin; GRANT ALL ON SEQUENCE teprjtask_teprjtask_id_seq TO xtrole; teadminfalse754125986819jsTABLECREATE TABLE js ( js_id integer NOT NULL, js_text text NOT NULL, js_namespace text NOT NULL, js_type text NOT NULL, js_context text NOT NULL, js_ext boolean DEFAULT false NOT NULL, js_active boolean DEFAULT true NOT NULL ); DROP TABLE xt.js; xtadminfalse6813681411+00TABLE jsCOMMENTMCOMMENT ON TABLE js IS 'Core table for xTuple JavaScript Objects Reference'; xtadminfalse763+00jsACLREVOKE ALL ON TABLE js FROM PUBLIC; REVOKE ALL ON TABLE js FROM admin; GRANT ALL ON TABLE js TO admin; GRANT ALL ON TABLE js TO xtrole; xtadminfalse763125986822 js_js_id_seqSEQUENCEnCREATE SEQUENCE js_js_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; DROP SEQUENCE xt.js_js_id_seq; xtadminfalse11763+00 js_js_id_seqSEQUENCE OWNED BY/ALTER SEQUENCE js_js_id_seq OWNED BY js.js_id; xtadminfalse764125982560pkgcmdTABLEuCREATE TABLE pkgcmd ( cmd_id integer DEFAULT nextval('public.cmd_cmd_id_seq'::regclass) ) INHERITS (public.cmd); DROP TABLE xtdesktop.pkgcmd;  xtdesktopadminfalse680110286+00pkgcmdACLREVOKE ALL ON TABLE pkgcmd FROM PUBLIC; REVOKE ALL ON TABLE pkgcmd FROM admin; GRANT ALL ON TABLE pkgcmd TO admin; GRANT ALL ON TABLE pkgcmd TO xtrole;  xtdesktopadminfalse755125982567 pkgcmdargTABLECREATE TABLE pkgcmdarg ( cmdarg_id integer DEFAULT nextval('public.cmdarg_cmdarg_id_seq'::regclass) ) INHERITS (public.cmdarg); DROP TABLE xtdesktop.pkgcmdarg;  xtdesktopadminfalse680210289+00 pkgcmdargACLREVOKE ALL ON TABLE pkgcmdarg FROM PUBLIC; REVOKE ALL ON TABLE pkgcmdarg FROM admin; GRANT ALL ON TABLE pkgcmdarg TO admin; GRANT ALL ON TABLE pkgcmdarg TO xtrole;  xtdesktopadminfalse756125982574pkgimageTABLECREATE TABLE pkgimage ( image_id integer DEFAULT nextval('public.image_image_id_seq'::regclass) ) INHERITS (public.image); DROP TABLE xtdesktop.pkgimage;  xtdesktopadminfalse680310223+00pkgimageACLREVOKE ALL ON TABLE pkgimage FROM PUBLIC; REVOKE ALL ON TABLE pkgimage FROM admin; GRANT ALL ON TABLE pkgimage TO admin; GRANT ALL ON TABLE pkgimage TO xtrole;  xtdesktopadminfalse757125982581 pkgmetasqlTABLECREATE TABLE pkgmetasql ( metasql_id integer DEFAULT nextval('public.metasql_metasql_id_seq'::regclass) ) INHERITS (public.metasql); !DROP TABLE xtdesktop.pkgmetasql;  xtdesktopadminfalse680410294+00 pkgmetasqlACLREVOKE ALL ON TABLE pkgmetasql FROM PUBLIC; REVOKE ALL ON TABLE pkgmetasql FROM admin; GRANT ALL ON TABLE pkgmetasql TO admin; GRANT ALL ON TABLE pkgmetasql TO xtrole;  xtdesktopadminfalse758125982589pkgprivTABLEzCREATE TABLE pkgpriv ( priv_id integer DEFAULT nextval('public.priv_priv_id_seq'::regclass) ) INHERITS (public.priv); DROP TABLE xtdesktop.pkgpriv;  xtdesktopadminfalse680610297+00pkgprivACLREVOKE ALL ON TABLE pkgpriv FROM PUBLIC; REVOKE ALL ON TABLE pkgpriv FROM admin; GRANT ALL ON TABLE pkgpriv TO admin; GRANT ALL ON TABLE pkgpriv TO xtrole;  xtdesktopadminfalse759125982596 pkgreportTABLECREATE TABLE pkgreport ( report_id integer DEFAULT nextval('public.report_report_id_seq'::regclass) ) INHERITS (public.report); DROP TABLE xtdesktop.pkgreport;  xtdesktopadminfalse680710300+00 pkgreportACLREVOKE ALL ON TABLE pkgreport FROM PUBLIC; REVOKE ALL ON TABLE pkgreport FROM admin; GRANT ALL ON TABLE pkgreport TO admin; GRANT ALL ON TABLE pkgreport TO xtrole;  xtdesktopadminfalse760125982603 pkgscriptTABLECREATE TABLE pkgscript ( script_id integer DEFAULT nextval('public.script_script_id_seq'::regclass) ) INHERITS (public.script); DROP TABLE xtdesktop.pkgscript;  xtdesktopadminfalse680810303+00 pkgscriptACLREVOKE ALL ON TABLE pkgscript FROM PUBLIC; REVOKE ALL ON TABLE pkgscript FROM admin; GRANT ALL ON TABLE pkgscript TO admin; GRANT ALL ON TABLE pkgscript TO xtrole;  xtdesktopadminfalse761125982611 pkguiformTABLECREATE TABLE pkguiform ( uiform_id integer DEFAULT nextval('public.uiform_uiform_id_seq'::regclass) ) INHERITS (public.uiform); DROP TABLE xtdesktop.pkguiform;  xtdesktopadminfalse681010306+00 pkguiformACLREVOKE ALL ON TABLE pkguiform FROM PUBLIC; REVOKE ALL ON TABLE pkguiform FROM admin; GRANT ALL ON TABLE pkguiform TO admin; GRANT ALL ON TABLE pkguiform TO xtrole;  xtdesktopadminfalse762260482619 metasql_gradeDEFAULTFALTER TABLE ONLY pkgmetasql ALTER COLUMN metasql_grade SET DEFAULT 0; KALTER TABLE fixcountry.pkgmetasql ALTER COLUMN metasql_grade DROP DEFAULT;  fixcountryadminfalse296296260482620script_enabledDEFAULTJALTER TABLE ONLY pkgscript ALTER COLUMN script_enabled SET DEFAULT false; KALTER TABLE fixcountry.pkgscript ALTER COLUMN script_enabled DROP DEFAULT;  fixcountryadminfalse305305260482621uiform_enabledDEFAULTJALTER TABLE ONLY pkguiform ALTER COLUMN uiform_enabled SET DEFAULT false; KALTER TABLE fixcountry.pkguiform ALTER COLUMN uiform_enabled DROP DEFAULT;  fixcountryadminfalse308308260482622addr_idDEFAULT^ALTER TABLE ONLY addr ALTER COLUMN addr_id SET DEFAULT nextval('addr_addr_id_seq'::regclass); ;ALTER TABLE public.addr ALTER COLUMN addr_id DROP DEFAULT; publicadminfalse311213260482623alarm_idDEFAULTbALTER TABLE ONLY alarm ALTER COLUMN alarm_id SET DEFAULT nextval('alarm_alarm_id_seq'::regclass); =ALTER TABLE public.alarm ALTER COLUMN alarm_id DROP DEFAULT; publicadminfalse313312260482624 apaccnt_idDEFAULTjALTER TABLE ONLY apaccnt ALTER COLUMN apaccnt_id SET DEFAULT nextval('apaccnt_apaccnt_id_seq'::regclass); AALTER TABLE public.apaccnt ALTER COLUMN apaccnt_id DROP DEFAULT; publicadminfalse315314260482625 apapply_idDEFAULTjALTER TABLE ONLY apapply ALTER COLUMN apapply_id SET DEFAULT nextval('apapply_apapply_id_seq'::regclass); AALTER TABLE public.apapply ALTER COLUMN apapply_id DROP DEFAULT; publicadminfalse317316260482626apcreditapply_idDEFAULTALTER TABLE ONLY apcreditapply ALTER COLUMN apcreditapply_id SET DEFAULT nextval('apcreditapply_apcreditapply_id_seq'::regclass); MALTER TABLE public.apcreditapply ALTER COLUMN apcreditapply_id DROP DEFAULT; publicadminfalse323322260482627 taxhist_idDEFAULTlALTER TABLE ONLY apopentax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); CALTER TABLE public.apopentax ALTER COLUMN taxhist_id DROP DEFAULT; publicadminfalse326326682260482628 apselect_idDEFAULTnALTER TABLE ONLY apselect ALTER COLUMN apselect_id SET DEFAULT nextval('apselect_apselect_id_seq'::regclass); CALTER TABLE public.apselect ALTER COLUMN apselect_id DROP DEFAULT; publicadminfalse328327260482629 arapply_idDEFAULTjALTER TABLE ONLY arapply ALTER COLUMN arapply_id SET DEFAULT nextval('arapply_arapply_id_seq'::regclass); AALTER TABLE public.arapply ALTER COLUMN arapply_id DROP DEFAULT; publicadminfalse332331260482630 taxhist_idDEFAULTlALTER TABLE ONLY aropentax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); CALTER TABLE public.aropentax ALTER COLUMN taxhist_id DROP DEFAULT; publicadminfalse338338682260482631 asohist_idDEFAULTjALTER TABLE ONLY asohist ALTER COLUMN asohist_id SET DEFAULT nextval('asohist_asohist_id_seq'::regclass); AALTER TABLE public.asohist ALTER COLUMN asohist_id DROP DEFAULT; publicadminfalse340339260482632 taxhist_idDEFAULTmALTER TABLE ONLY asohisttax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); DALTER TABLE public.asohisttax ALTER COLUMN taxhist_id DROP DEFAULT; publicadminfalse341341682260482633 atlasmap_idDEFAULTnALTER TABLE ONLY atlasmap ALTER COLUMN atlasmap_id SET DEFAULT nextval('atlasmap_atlasmap_id_seq'::regclass); CALTER TABLE public.atlasmap ALTER COLUMN atlasmap_id DROP DEFAULT; publicadminfalse343342260482634 bankaccnt_idDEFAULTrALTER TABLE ONLY bankaccnt ALTER COLUMN bankaccnt_id SET DEFAULT nextval('bankaccnt_bankaccnt_id_seq'::regclass); EALTER TABLE public.bankaccnt ALTER COLUMN bankaccnt_id DROP DEFAULT; publicadminfalse345231260482635 bankadj_idDEFAULTjALTER TABLE ONLY bankadj ALTER COLUMN bankadj_id SET DEFAULT nextval('bankadj_bankadj_id_seq'::regclass); AALTER TABLE public.bankadj ALTER COLUMN bankadj_id DROP DEFAULT; publicadminfalse347346260482636bankadjtype_idDEFAULTzALTER TABLE ONLY bankadjtype ALTER COLUMN bankadjtype_id SET DEFAULT nextval('bankadjtype_bankadjtype_id_seq'::regclass); IALTER TABLE public.bankadjtype ALTER COLUMN bankadjtype_id DROP DEFAULT; publicadminfalse349348260482637 bankrec_idDEFAULTjALTER TABLE ONLY bankrec ALTER COLUMN bankrec_id SET DEFAULT nextval('bankrec_bankrec_id_seq'::regclass); AALTER TABLE public.bankrec ALTER COLUMN bankrec_id DROP DEFAULT; publicadminfalse351350260487332bankrecimport_idDEFAULTALTER TABLE ONLY bankrecimport ALTER COLUMN bankrecimport_id SET DEFAULT nextval('bankrecimport_bankrecimport_id_seq'::regclass); MALTER TABLE public.bankrecimport ALTER COLUMN bankrecimport_id DROP DEFAULT; publicadminfalse784783260482638bankrecitem_idDEFAULTzALTER TABLE ONLY bankrecitem ALTER COLUMN bankrecitem_id SET DEFAULT nextval('bankrecitem_bankrecitem_id_seq'::regclass); IALTER TABLE public.bankrecitem ALTER COLUMN bankrecitem_id DROP DEFAULT; publicadminfalse353352260482639bomitemcost_idDEFAULTzALTER TABLE ONLY bomitemcost ALTER COLUMN bomitemcost_id SET DEFAULT nextval('bomitemcost_bomitemcost_id_seq'::regclass); IALTER TABLE public.bomitemcost ALTER COLUMN bomitemcost_id DROP DEFAULT; publicadminfalse357356260482640 bomitemsub_idDEFAULTvALTER TABLE ONLY bomitemsub ALTER COLUMN bomitemsub_id SET DEFAULT nextval('bomitemsub_bomitemsub_id_seq'::regclass); GALTER TABLE public.bomitemsub ALTER COLUMN bomitemsub_id DROP DEFAULT; publicadminfalse358226260482641 bomwork_idDEFAULTjALTER TABLE ONLY bomwork ALTER COLUMN bomwork_id SET DEFAULT nextval('bomwork_bomwork_id_seq'::regclass); AALTER TABLE public.bomwork ALTER COLUMN bomwork_id DROP DEFAULT; publicadminfalse360359260482642 budghead_idDEFAULTnALTER TABLE ONLY budghead ALTER COLUMN budghead_id SET DEFAULT nextval('budghead_budghead_id_seq'::regclass); CALTER TABLE public.budghead ALTER COLUMN budghead_id DROP DEFAULT; publicadminfalse361227260482643 budgitem_idDEFAULTnALTER TABLE ONLY budgitem ALTER COLUMN budgitem_id SET DEFAULT nextval('budgitem_budgitem_id_seq'::regclass); CALTER TABLE public.budgitem ALTER COLUMN budgitem_id DROP DEFAULT; publicadminfalse362229260482644 cashrcpt_idDEFAULTnALTER TABLE ONLY cashrcpt ALTER COLUMN cashrcpt_id SET DEFAULT nextval('cashrcpt_cashrcpt_id_seq'::regclass); CALTER TABLE public.cashrcpt ALTER COLUMN cashrcpt_id DROP DEFAULT; publicadminfalse366232260482645cashrcptitem_idDEFAULT~ALTER TABLE ONLY cashrcptitem ALTER COLUMN cashrcptitem_id SET DEFAULT nextval('cashrcptitem_cashrcptitem_id_seq'::regclass); KALTER TABLE public.cashrcptitem ALTER COLUMN cashrcptitem_id DROP DEFAULT; publicadminfalse333233260482646cashrcptmisc_idDEFAULT~ALTER TABLE ONLY cashrcptmisc ALTER COLUMN cashrcptmisc_id SET DEFAULT nextval('cashrcptmisc_cashrcptmisc_id_seq'::regclass); KALTER TABLE public.cashrcptmisc ALTER COLUMN cashrcptmisc_id DROP DEFAULT; publicadminfalse367234&260482647ccard_idDEFAULTbALTER TABLE ONLY ccard ALTER COLUMN ccard_id SET DEFAULT nextval('ccard_ccard_id_seq'::regclass); =ALTER TABLE public.ccard ALTER COLUMN ccard_id DROP DEFAULT; publicadminfalse368235260482648 ccardaud_idDEFAULTnALTER TABLE ONLY ccardaud ALTER COLUMN ccardaud_id SET DEFAULT nextval('ccardaud_ccardaud_id_seq'::regclass); CALTER TABLE public.ccardaud ALTER COLUMN ccardaud_id DROP DEFAULT; publicadminfalse370369 260482649 ccbank_idDEFAULTfALTER TABLE ONLY ccbank ALTER COLUMN ccbank_id SET DEFAULT nextval('ccbank_ccbank_id_seq'::regclass); ?ALTER TABLE public.ccbank ALTER COLUMN ccbank_id DROP DEFAULT; publicadminfalse372371260482650ccpay_idDEFAULTbALTER TABLE ONLY ccpay ALTER COLUMN ccpay_id SET DEFAULT nextval('ccpay_ccpay_id_seq'::regclass); =ALTER TABLE public.ccpay ALTER COLUMN ccpay_id DROP DEFAULT; publicadminfalse374373260482651char_idDEFAULT`ALTER TABLE ONLY "char" ALTER COLUMN char_id SET DEFAULT nextval('char_char_id_seq'::regclass); =ALTER TABLE public."char" ALTER COLUMN char_id DROP DEFAULT; publicadminfalse375214260482652 charass_idDEFAULTjALTER TABLE ONLY charass ALTER COLUMN charass_id SET DEFAULT nextval('charass_charass_id_seq'::regclass); AALTER TABLE public.charass ALTER COLUMN charass_id DROP DEFAULT; publicadminfalse376215260482653 charopt_idDEFAULTjALTER TABLE ONLY charopt ALTER COLUMN charopt_id SET DEFAULT nextval('charopt_charopt_id_seq'::regclass); AALTER TABLE public.charopt ALTER COLUMN charopt_id DROP DEFAULT; publicadminfalse378377260487348 charuse_idDEFAULTjALTER TABLE ONLY charuse ALTER COLUMN charuse_id SET DEFAULT nextval('charuse_charuse_id_seq'::regclass); AALTER TABLE public.charuse ALTER COLUMN charuse_id DROP DEFAULT; publicadminfalse786785260482654 checkhead_idDEFAULTrALTER TABLE ONLY checkhead ALTER COLUMN checkhead_id SET DEFAULT nextval('checkhead_checkhead_id_seq'::regclass); EALTER TABLE public.checkhead ALTER COLUMN checkhead_id DROP DEFAULT; publicadminfalse379318260482655 checkitem_idDEFAULTrALTER TABLE ONLY checkitem ALTER COLUMN checkitem_id SET DEFAULT nextval('checkitem_checkitem_id_seq'::regclass); EALTER TABLE public.checkitem ALTER COLUMN checkitem_id DROP DEFAULT; publicadminfalse380320260482656cmd_idDEFAULTZALTER TABLE ONLY cmd ALTER COLUMN cmd_id SET DEFAULT nextval('cmd_cmd_id_seq'::regclass); 9ALTER TABLE public.cmd ALTER COLUMN cmd_id DROP DEFAULT; publicadminfalse287286260482657 cmdarg_idDEFAULTfALTER TABLE ONLY cmdarg ALTER COLUMN cmdarg_id SET DEFAULT nextval('cmdarg_cmdarg_id_seq'::regclass); ?ALTER TABLE public.cmdarg ALTER COLUMN cmdarg_id DROP DEFAULT; publicadminfalse290289260482658 taxhist_idDEFAULTlALTER TABLE ONLY cmheadtax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); CALTER TABLE public.cmheadtax ALTER COLUMN taxhist_id DROP DEFAULT; publicadminfalse383383682260482659 taxhist_idDEFAULTlALTER TABLE ONLY cmitemtax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); CALTER TABLE public.cmitemtax ALTER COLUMN taxhist_id DROP DEFAULT; publicadminfalse385385682260482660 cmnttype_idDEFAULTnALTER TABLE ONLY cmnttype ALTER COLUMN cmnttype_id SET DEFAULT nextval('cmnttype_cmnttype_id_seq'::regclass); CALTER TABLE public.cmnttype ALTER COLUMN cmnttype_id DROP DEFAULT; publicadminfalse386216260482661cmnttypesource_idDEFAULTALTER TABLE ONLY cmnttypesource ALTER COLUMN cmnttypesource_id SET DEFAULT nextval('cmnttypesource_cmnttypesource_id_seq'::regclass); OALTER TABLE public.cmnttypesource ALTER COLUMN cmnttypesource_id DROP DEFAULT; publicadminfalse388387k260482662cntct_idDEFAULTbALTER TABLE ONLY cntct ALTER COLUMN cntct_id SET DEFAULT nextval('cntct_cntct_id_seq'::regclass); =ALTER TABLE public.cntct ALTER COLUMN cntct_id DROP DEFAULT; publicadminfalse389187260482663 cntctaddr_idDEFAULTrALTER TABLE ONLY cntctaddr ALTER COLUMN cntctaddr_id SET DEFAULT nextval('cntctaddr_cntctaddr_id_seq'::regclass); EALTER TABLE public.cntctaddr ALTER COLUMN cntctaddr_id DROP DEFAULT; publicadminfalse391390260482664 cntctdata_idDEFAULTrALTER TABLE ONLY cntctdata ALTER COLUMN cntctdata_id SET DEFAULT nextval('cntctdata_cntctdata_id_seq'::regclass); EALTER TABLE public.cntctdata ALTER COLUMN cntctdata_id DROP DEFAULT; publicadminfalse393392260482665 cntcteml_idDEFAULTnALTER TABLE ONLY cntcteml ALTER COLUMN cntcteml_id SET DEFAULT nextval('cntcteml_cntcteml_id_seq'::regclass); CALTER TABLE public.cntcteml ALTER COLUMN cntcteml_id DROP DEFAULT; publicadminfalse395394,260482666 taxhist_idDEFAULTlALTER TABLE ONLY cobilltax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); CALTER TABLE public.cobilltax ALTER COLUMN taxhist_id DROP DEFAULT; publicadminfalse401401682/260482667 taxhist_idDEFAULTmALTER TABLE ONLY cobmisctax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); DALTER TABLE public.cobmisctax ALTER COLUMN taxhist_id DROP DEFAULT; publicadminfalse404404682260482668 taxhist_idDEFAULTlALTER TABLE ONLY cohisttax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); CALTER TABLE public.cohisttax ALTER COLUMN taxhist_id DROP DEFAULT; publicadminfalse2822826820260482669 company_idDEFAULTjALTER TABLE ONLY company ALTER COLUMN company_id SET DEFAULT nextval('company_company_id_seq'::regclass); AALTER TABLE public.company ALTER COLUMN company_id DROP DEFAULT; publicadminfalse410409f260482670 contrct_idDEFAULTjALTER TABLE ONLY contrct ALTER COLUMN contrct_id SET DEFAULT nextval('contrct_contrct_id_seq'::regclass); AALTER TABLE public.contrct ALTER COLUMN contrct_id DROP DEFAULT; publicadminfalse411259A260482671 country_idDEFAULTjALTER TABLE ONLY country ALTER COLUMN country_id SET DEFAULT nextval('country_country_id_seq'::regclass); AALTER TABLE public.country ALTER COLUMN country_id DROP DEFAULT; publicadminfalse425424m260482672 crmacct_idDEFAULTjALTER TABLE ONLY crmacct ALTER COLUMN crmacct_id SET DEFAULT nextval('crmacct_crmacct_id_seq'::regclass); AALTER TABLE public.crmacct ALTER COLUMN crmacct_id DROP DEFAULT; publicadminfalse427188W260482673 curr_rate_idDEFAULTrALTER TABLE ONLY curr_rate ALTER COLUMN curr_rate_id SET DEFAULT nextval('curr_rate_curr_rate_id_seq'::regclass); EALTER TABLE public.curr_rate ALTER COLUMN curr_rate_id DROP DEFAULT; publicadminfalse430429260482674curr_idDEFAULTlALTER TABLE ONLY curr_symbol ALTER COLUMN curr_id SET DEFAULT nextval('curr_symbol_curr_id_seq'::regclass); BALTER TABLE public.curr_symbol ALTER COLUMN curr_id DROP DEFAULT; publicadminfalse4311915260482675dept_idDEFAULT^ALTER TABLE ONLY dept ALTER COLUMN dept_id SET DEFAULT nextval('dept_dept_id_seq'::regclass); ;ALTER TABLE public.dept ALTER COLUMN dept_id DROP DEFAULT; publicadminfalse441241260482676 docass_idDEFAULTfALTER TABLE ONLY docass ALTER COLUMN docass_id SET DEFAULT nextval('docass_docass_id_seq'::regclass); ?ALTER TABLE public.docass ALTER COLUMN docass_id DROP DEFAULT; publicadminfalse222218:260482677emp_idDEFAULTZALTER TABLE ONLY emp ALTER COLUMN emp_id SET DEFAULT nextval('emp_emp_id_seq'::regclass); 9ALTER TABLE public.emp ALTER COLUMN emp_id DROP DEFAULT; publicadminfalse445242g260482678 empgrp_idDEFAULTfALTER TABLE ONLY empgrp ALTER COLUMN empgrp_id SET DEFAULT nextval('empgrp_empgrp_id_seq'::regclass); ?ALTER TABLE public.empgrp ALTER COLUMN empgrp_id DROP DEFAULT; publicadminfalse447446i260482679 empgrpitem_idDEFAULTvALTER TABLE ONLY empgrpitem ALTER COLUMN empgrpitem_id SET DEFAULT nextval('empgrpitem_empgrpitem_id_seq'::regclass); GALTER TABLE public.empgrpitem ALTER COLUMN empgrpitem_id DROP DEFAULT; publicadminfalse449448260482680 expcat_idDEFAULTfALTER TABLE ONLY expcat ALTER COLUMN expcat_id SET DEFAULT nextval('expcat_expcat_id_seq'::regclass); ?ALTER TABLE public.expcat ALTER COLUMN expcat_id DROP DEFAULT; publicadminfalse456273260482681file_idDEFAULT^ALTER TABLE ONLY file ALTER COLUMN file_id SET DEFAULT nextval('file_file_id_seq'::regclass); ;ALTER TABLE public.file ALTER COLUMN file_id DROP DEFAULT; publicadminfalse457219n260482682 filter_idDEFAULTfALTER TABLE ONLY filter ALTER COLUMN filter_id SET DEFAULT nextval('filter_filter_id_seq'::regclass); ?ALTER TABLE public.filter ALTER COLUMN filter_id DROP DEFAULT; publicadminfalse459458p260482683 fincharg_idDEFAULTnALTER TABLE ONLY fincharg ALTER COLUMN fincharg_id SET DEFAULT nextval('fincharg_fincharg_id_seq'::regclass); CALTER TABLE public.fincharg ALTER COLUMN fincharg_id DROP DEFAULT; publicadminfalse461460260482684flcol_idDEFAULTbALTER TABLE ONLY flcol ALTER COLUMN flcol_id SET DEFAULT nextval('flcol_flcol_id_seq'::regclass); =ALTER TABLE public.flcol ALTER COLUMN flcol_id DROP DEFAULT; publicadminfalse465464260482685flgrp_idDEFAULTbALTER TABLE ONLY flgrp ALTER COLUMN flgrp_id SET DEFAULT nextval('flgrp_flgrp_id_seq'::regclass); =ALTER TABLE public.flgrp ALTER COLUMN flgrp_id DROP DEFAULT; publicadminfalse467466260482686 flhead_idDEFAULTfALTER TABLE ONLY flhead ALTER COLUMN flhead_id SET DEFAULT nextval('flhead_flhead_id_seq'::regclass); ?ALTER TABLE public.flhead ALTER COLUMN flhead_id DROP DEFAULT; publicadminfalse468462260482687 flitem_idDEFAULTfALTER TABLE ONLY flitem ALTER COLUMN flitem_id SET DEFAULT nextval('flitem_flitem_id_seq'::regclass); ?ALTER TABLE public.flitem ALTER COLUMN flitem_id DROP DEFAULT; publicadminfalse469463260482688 flnotes_idDEFAULTjALTER TABLE ONLY flnotes ALTER COLUMN flnotes_id SET DEFAULT nextval('flnotes_flnotes_id_seq'::regclass); AALTER TABLE public.flnotes ALTER COLUMN flnotes_id DROP DEFAULT; publicadminfalse471470260482689flrpt_idDEFAULTbALTER TABLE ONLY flrpt ALTER COLUMN flrpt_id SET DEFAULT nextval('flrpt_flrpt_id_seq'::regclass); =ALTER TABLE public.flrpt ALTER COLUMN flrpt_id DROP DEFAULT; publicadminfalse473472260482690 flspec_idDEFAULTfALTER TABLE ONLY flspec ALTER COLUMN flspec_id SET DEFAULT nextval('flspec_flspec_id_seq'::regclass); ?ALTER TABLE public.flspec ALTER COLUMN flspec_id DROP DEFAULT; publicadminfalse475474E260482691freightclass_idDEFAULT~ALTER TABLE ONLY freightclass ALTER COLUMN freightclass_id SET DEFAULT nextval('freightclass_freightclass_id_seq'::regclass); KALTER TABLE public.freightclass ALTER COLUMN freightclass_id DROP DEFAULT; publicadminfalse478245260482692grp_idDEFAULTZALTER TABLE ONLY grp ALTER COLUMN grp_id SET DEFAULT nextval('grp_grp_id_seq'::regclass); 9ALTER TABLE public.grp ALTER COLUMN grp_id DROP DEFAULT; publicadminfalse484483260482693 grppriv_idDEFAULTjALTER TABLE ONLY grppriv ALTER COLUMN grppriv_id SET DEFAULT nextval('grppriv_grppriv_id_seq'::regclass); AALTER TABLE public.grppriv ALTER COLUMN grppriv_id DROP DEFAULT; publicadminfalse486485260482694hnfc_idDEFAULT^ALTER TABLE ONLY hnfc ALTER COLUMN hnfc_id SET DEFAULT nextval('hnfc_hnfc_id_seq'::regclass); ;ALTER TABLE public.hnfc ALTER COLUMN hnfc_id DROP DEFAULT; publicadminfalse488487v260482695incdt_idDEFAULTbALTER TABLE ONLY incdt ALTER COLUMN incdt_id SET DEFAULT nextval('incdt_incdt_id_seq'::regclass); =ALTER TABLE public.incdt ALTER COLUMN incdt_id DROP DEFAULT; publicadminfalse489189M260482696 incdtcat_idDEFAULTnALTER TABLE ONLY incdtcat ALTER COLUMN incdtcat_id SET DEFAULT nextval('incdtcat_incdtcat_id_seq'::regclass); CALTER TABLE public.incdtcat ALTER COLUMN incdtcat_id DROP DEFAULT; publicadminfalse490248260482697 incdthist_idDEFAULTrALTER TABLE ONLY incdthist ALTER COLUMN incdthist_id SET DEFAULT nextval('incdthist_incdthist_id_seq'::regclass); EALTER TABLE public.incdthist ALTER COLUMN incdthist_id DROP DEFAULT; publicadminfalse492491O260482698incdtpriority_idDEFAULTALTER TABLE ONLY incdtpriority ALTER COLUMN incdtpriority_id SET DEFAULT nextval('incdtpriority_incdtpriority_id_seq'::regclass); MALTER TABLE public.incdtpriority ALTER COLUMN incdtpriority_id DROP DEFAULT; publicadminfalse493249Q260482699incdtresolution_idDEFAULTALTER TABLE ONLY incdtresolution ALTER COLUMN incdtresolution_id SET DEFAULT nextval('incdtresolution_incdtresolution_id_seq'::regclass); QALTER TABLE public.incdtresolution ALTER COLUMN incdtresolution_id DROP DEFAULT; publicadminfalse494250S260482700incdtseverity_idDEFAULTALTER TABLE ONLY incdtseverity ALTER COLUMN incdtseverity_id SET DEFAULT nextval('incdtseverity_incdtseverity_id_seq'::regclass); MALTER TABLE public.incdtseverity ALTER COLUMN incdtseverity_id DROP DEFAULT; publicadminfalse495251b260482701 invbal_idDEFAULTfALTER TABLE ONLY invbal ALTER COLUMN invbal_id SET DEFAULT nextval('invbal_invbal_id_seq'::regclass); ?ALTER TABLE public.invbal ALTER COLUMN invbal_id DROP DEFAULT; publicadminfalse496185260482702 invchead_idDEFAULTnALTER TABLE ONLY invchead ALTER COLUMN invchead_id SET DEFAULT nextval('invchead_invchead_id_seq'::regclass); CALTER TABLE public.invchead ALTER COLUMN invchead_id DROP DEFAULT; publicadminfalse498205260482703 taxhist_idDEFAULTnALTER TABLE ONLY invcheadtax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); EALTER TABLE public.invcheadtax ALTER COLUMN taxhist_id DROP DEFAULT; publicadminfalse499499682260482704 invcitem_idDEFAULTnALTER TABLE ONLY invcitem ALTER COLUMN invcitem_id SET DEFAULT nextval('invcitem_invcitem_id_seq'::regclass); CALTER TABLE public.invcitem ALTER COLUMN invcitem_id DROP DEFAULT; publicadminfalse500209260482705 taxhist_idDEFAULTnALTER TABLE ONLY invcitemtax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); EALTER TABLE public.invcitemtax ALTER COLUMN taxhist_id DROP DEFAULT; publicadminfalse501501682260482706invhistexpcat_idDEFAULTALTER TABLE ONLY invhistexpcat ALTER COLUMN invhistexpcat_id SET DEFAULT nextval('invhistexpcat_invhistexpcat_id_seq'::regclass); MALTER TABLE public.invhistexpcat ALTER COLUMN invhistexpcat_id DROP DEFAULT; publicadminfalse508507260482707 ipsass_idDEFAULTfALTER TABLE ONLY ipsass ALTER COLUMN ipsass_id SET DEFAULT nextval('ipsass_ipsass_id_seq'::regclass); ?ALTER TABLE public.ipsass ALTER COLUMN ipsass_id DROP DEFAULT; publicadminfalse509268G260482708 ipsfreight_idDEFAULTvALTER TABLE ONLY ipsfreight ALTER COLUMN ipsfreight_id SET DEFAULT nextval('ipsfreight_ipsfreight_id_seq'::regclass); GALTER TABLE public.ipsfreight ALTER COLUMN ipsfreight_id DROP DEFAULT; publicadminfalse512246260482709ipsitemchar_idDEFAULTzALTER TABLE ONLY ipsitemchar ALTER COLUMN ipsitemchar_id SET DEFAULT nextval('ipsitemchar_ipsitemchar_id_seq'::regclass); IALTER TABLE public.ipsitemchar ALTER COLUMN ipsitemchar_id DROP DEFAULT; publicadminfalse515270260482710 ipsprodcat_idDEFAULTzALTER TABLE ONLY ipsprodcat_bak ALTER COLUMN ipsprodcat_id SET DEFAULT nextval('ipsprodcat_ipsprodcat_id_seq'::regclass); KALTER TABLE public.ipsprodcat_bak ALTER COLUMN ipsprodcat_id DROP DEFAULT; publicadminfalse517516260482711itemlocpost_idDEFAULTzALTER TABLE ONLY itemlocpost ALTER COLUMN itemlocpost_id SET DEFAULT nextval('itemlocpost_itemlocpost_id_seq'::regclass); IALTER TABLE public.itemlocpost ALTER COLUMN itemlocpost_id DROP DEFAULT; publicadminfalse535534t260482712 itemtax_idDEFAULTjALTER TABLE ONLY itemtax ALTER COLUMN itemtax_id SET DEFAULT nextval('itemtax_itemtax_id_seq'::regclass); AALTER TABLE public.itemtax ALTER COLUMN itemtax_id DROP DEFAULT; publicadminfalse541263260482713 itemtrans_idDEFAULTrALTER TABLE ONLY itemtrans ALTER COLUMN itemtrans_id SET DEFAULT nextval('itemtrans_itemtrans_id_seq'::regclass); EALTER TABLE public.itemtrans ALTER COLUMN itemtrans_id DROP DEFAULT; publicadminfalse543542260482714 itemuom_idDEFAULTjALTER TABLE ONLY itemuom ALTER COLUMN itemuom_id SET DEFAULT nextval('itemuom_itemuom_id_seq'::regclass); AALTER TABLE public.itemuom ALTER COLUMN itemuom_id DROP DEFAULT; publicadminfalse545544u260482715itemuomconv_idDEFAULTzALTER TABLE ONLY itemuomconv ALTER COLUMN itemuomconv_id SET DEFAULT nextval('itemuomconv_itemuomconv_id_seq'::regclass); IALTER TABLE public.itemuomconv ALTER COLUMN itemuomconv_id DROP DEFAULT; publicadminfalse546264260482716 labeldef_idDEFAULTnALTER TABLE ONLY labeldef ALTER COLUMN labeldef_id SET DEFAULT nextval('labeldef_labeldef_id_seq'::regclass); CALTER TABLE public.labeldef ALTER COLUMN labeldef_id DROP DEFAULT; publicadminfalse551550260482717lang_idDEFAULT^ALTER TABLE ONLY lang ALTER COLUMN lang_id SET DEFAULT nextval('lang_lang_id_seq'::regclass); ;ALTER TABLE public.lang ALTER COLUMN lang_id DROP DEFAULT; publicadminfalse555554260482718 metasql_idDEFAULTjALTER TABLE ONLY metasql ALTER COLUMN metasql_id SET DEFAULT nextval('metasql_metasql_id_seq'::regclass); AALTER TABLE public.metasql ALTER COLUMN metasql_id DROP DEFAULT; publicadminfalse295294260482719 metricenc_idDEFAULTrALTER TABLE ONLY metricenc ALTER COLUMN metricenc_id SET DEFAULT nextval('metricenc_metricenc_id_seq'::regclass); EALTER TABLE public.metricenc ALTER COLUMN metricenc_id DROP DEFAULT; publicadminfalse565564260482720 ophead_idDEFAULTfALTER TABLE ONLY ophead ALTER COLUMN ophead_id SET DEFAULT nextval('ophead_ophead_id_seq'::regclass); ?ALTER TABLE public.ophead ALTER COLUMN ophead_id DROP DEFAULT; publicadminfalse575210260482721 opsource_idDEFAULTnALTER TABLE ONLY opsource ALTER COLUMN opsource_id SET DEFAULT nextval('opsource_opsource_id_seq'::regclass); CALTER TABLE public.opsource ALTER COLUMN opsource_id DROP DEFAULT; publicadminfalse577576260482722 opstage_idDEFAULTjALTER TABLE ONLY opstage ALTER COLUMN opstage_id SET DEFAULT nextval('opstage_opstage_id_seq'::regclass); AALTER TABLE public.opstage ALTER COLUMN opstage_id DROP DEFAULT; publicadminfalse579578260482723 optype_idDEFAULTfALTER TABLE ONLY optype ALTER COLUMN optype_id SET DEFAULT nextval('optype_optype_id_seq'::regclass); ?ALTER TABLE public.optype ALTER COLUMN optype_id DROP DEFAULT; publicadminfalse581580260482724pack_idDEFAULT^ALTER TABLE ONLY pack ALTER COLUMN pack_id SET DEFAULT nextval('pack_pack_id_seq'::regclass); ;ALTER TABLE public.pack ALTER COLUMN pack_id DROP DEFAULT; publicadminfalse585584260487407payco_idDEFAULTbALTER TABLE ONLY payco ALTER COLUMN payco_id SET DEFAULT nextval('payco_payco_id_seq'::regclass); =ALTER TABLE public.payco ALTER COLUMN payco_id DROP DEFAULT; publicadminfalse787587260482725 period_idDEFAULTfALTER TABLE ONLY period ALTER COLUMN period_id SET DEFAULT nextval('period_period_id_seq'::regclass); ?ALTER TABLE public.period ALTER COLUMN period_id DROP DEFAULT; publicadminfalse588230260482726 pkgdep_idDEFAULTfALTER TABLE ONLY pkgdep ALTER COLUMN pkgdep_id SET DEFAULT nextval('pkgdep_pkgdep_id_seq'::regclass); ?ALTER TABLE public.pkgdep ALTER COLUMN pkgdep_id DROP DEFAULT; publicadminfalse590589260482727 pkghead_idDEFAULTjALTER TABLE ONLY pkghead ALTER COLUMN pkghead_id SET DEFAULT nextval('pkghead_pkghead_id_seq'::regclass); AALTER TABLE public.pkghead ALTER COLUMN pkghead_id DROP DEFAULT; publicadminfalse592591260482728 pkgitem_idDEFAULTjALTER TABLE ONLY pkgitem ALTER COLUMN pkgitem_id SET DEFAULT nextval('pkgitem_pkgitem_id_seq'::regclass); AALTER TABLE public.pkgitem ALTER COLUMN pkgitem_id DROP DEFAULT; publicadminfalse594593260482729 prftcntr_idDEFAULTnALTER TABLE ONLY prftcntr ALTER COLUMN prftcntr_id SET DEFAULT nextval('prftcntr_prftcntr_id_seq'::regclass); CALTER TABLE public.prftcntr ALTER COLUMN prftcntr_id DROP DEFAULT; publicadminfalse607606260482730prj_idDEFAULTZALTER TABLE ONLY prj ALTER COLUMN prj_id SET DEFAULT nextval('prj_prj_id_seq'::regclass); 9ALTER TABLE public.prj ALTER COLUMN prj_id DROP DEFAULT; publicadminfalse610206260482731 prjtask_idDEFAULTjALTER TABLE ONLY prjtask ALTER COLUMN prjtask_id SET DEFAULT nextval('prjtask_prjtask_id_seq'::regclass); AALTER TABLE public.prjtask ALTER COLUMN prjtask_id DROP DEFAULT; publicadminfalse611211260482732prjtaskuser_idDEFAULTzALTER TABLE ONLY prjtaskuser ALTER COLUMN prjtaskuser_id SET DEFAULT nextval('prjtaskuser_prjtaskuser_id_seq'::regclass); IALTER TABLE public.prjtaskuser ALTER COLUMN prjtaskuser_id DROP DEFAULT; publicadminfalse613612260482733 prjtype_idDEFAULTjALTER TABLE ONLY prjtype ALTER COLUMN prjtype_id SET DEFAULT nextval('prjtype_prjtype_id_seq'::regclass); AALTER TABLE public.prjtype ALTER COLUMN prjtype_id DROP DEFAULT; publicadminfalse615614260482734 qryhead_idDEFAULTjALTER TABLE ONLY qryhead ALTER COLUMN qryhead_id SET DEFAULT nextval('qryhead_qryhead_id_seq'::regclass); AALTER TABLE public.qryhead ALTER COLUMN qryhead_id DROP DEFAULT; publicadminfalse618617260482735 qryitem_idDEFAULTjALTER TABLE ONLY qryitem ALTER COLUMN qryitem_id SET DEFAULT nextval('qryitem_qryitem_id_seq'::regclass); AALTER TABLE public.qryitem ALTER COLUMN qryitem_id DROP DEFAULT; publicadminfalse620619 260482736recur_idDEFAULTbALTER TABLE ONLY recur ALTER COLUMN recur_id SET DEFAULT nextval('recur_recur_id_seq'::regclass); =ALTER TABLE public.recur ALTER COLUMN recur_id DROP DEFAULT; publicadminfalse625624$260482737 recurtype_idDEFAULTrALTER TABLE ONLY recurtype ALTER COLUMN recurtype_id SET DEFAULT nextval('recurtype_recurtype_id_seq'::regclass); EALTER TABLE public.recurtype ALTER COLUMN recurtype_id DROP DEFAULT; publicadminfalse627626 260482738recv_idDEFAULT^ALTER TABLE ONLY recv ALTER COLUMN recv_id SET DEFAULT nextval('recv_recv_id_seq'::regclass); ;ALTER TABLE public.recv ALTER COLUMN recv_id DROP DEFAULT; publicadminfalse628599260482739 rsncode_idDEFAULTjALTER TABLE ONLY rsncode ALTER COLUMN rsncode_id SET DEFAULT nextval('rsncode_rsncode_id_seq'::regclass); AALTER TABLE public.rsncode ALTER COLUMN rsncode_id DROP DEFAULT; publicadminfalse632197260482740 salescat_idDEFAULTnALTER TABLE ONLY salescat ALTER COLUMN salescat_id SET DEFAULT nextval('salescat_salescat_id_seq'::regclass); CALTER TABLE public.salescat ALTER COLUMN salescat_id DROP DEFAULT; publicadminfalse636198260482741 saletype_idDEFAULTnALTER TABLE ONLY saletype ALTER COLUMN saletype_id SET DEFAULT nextval('saletype_saletype_id_seq'::regclass); CALTER TABLE public.saletype ALTER COLUMN saletype_id DROP DEFAULT; publicadminfalse638207)260482742 schemaord_idDEFAULTrALTER TABLE ONLY schemaord ALTER COLUMN schemaord_id SET DEFAULT nextval('schemaord_schemaord_id_seq'::regclass); EALTER TABLE public.schemaord ALTER COLUMN schemaord_id DROP DEFAULT; publicadminfalse640639260482743 script_idDEFAULTfALTER TABLE ONLY script ALTER COLUMN script_id SET DEFAULT nextval('script_script_id_seq'::regclass); ?ALTER TABLE public.script ALTER COLUMN script_id DROP DEFAULT; publicadminfalse304303?260482744shift_idDEFAULTbALTER TABLE ONLY shift ALTER COLUMN shift_id SET DEFAULT nextval('shift_shift_id_seq'::regclass); =ALTER TABLE public.shift ALTER COLUMN shift_id DROP DEFAULT; publicadminfalse642243*260482745 shipchrg_idDEFAULTnALTER TABLE ONLY shipchrg ALTER COLUMN shipchrg_id SET DEFAULT nextval('shipchrg_shipchrg_id_seq'::regclass); CALTER TABLE public.shipchrg ALTER COLUMN shipchrg_id DROP DEFAULT; publicadminfalse6432376260482746 shiphead_idDEFAULTnALTER TABLE ONLY shiphead ALTER COLUMN shiphead_id SET DEFAULT nextval('shiphead_shiphead_id_seq'::regclass); CALTER TABLE public.shiphead ALTER COLUMN shiphead_id DROP DEFAULT; publicadminfalse646412:260482747 shipitem_idDEFAULTnALTER TABLE ONLY shipitem ALTER COLUMN shipitem_id SET DEFAULT nextval('shipitem_shipitem_id_seq'::regclass); CALTER TABLE public.shipitem ALTER COLUMN shipitem_id DROP DEFAULT; publicadminfalse647413260482748 sitetype_idDEFAULTnALTER TABLE ONLY sitetype ALTER COLUMN sitetype_id SET DEFAULT nextval('sitetype_sitetype_id_seq'::regclass); CALTER TABLE public.sitetype ALTER COLUMN sitetype_id DROP DEFAULT; publicadminfalse6532844260482749 source_idDEFAULTfALTER TABLE ONLY source ALTER COLUMN source_id SET DEFAULT nextval('source_source_id_seq'::regclass); ?ALTER TABLE public.source ALTER COLUMN source_id DROP DEFAULT; publicadminfalse659658E260482750state_idDEFAULTbALTER TABLE ONLY state ALTER COLUMN state_id SET DEFAULT nextval('state_state_id_seq'::regclass); =ALTER TABLE public.state ALTER COLUMN state_id DROP DEFAULT; publicadminfalse661660G260482751 status_idDEFAULTfALTER TABLE ONLY status ALTER COLUMN status_id SET DEFAULT nextval('status_status_id_seq'::regclass); ?ALTER TABLE public.status ALTER COLUMN status_id DROP DEFAULT; publicadminfalse663662I260482752 stdjrnl_idDEFAULTjALTER TABLE ONLY stdjrnl ALTER COLUMN stdjrnl_id SET DEFAULT nextval('stdjrnl_stdjrnl_id_seq'::regclass); AALTER TABLE public.stdjrnl ALTER COLUMN stdjrnl_id DROP DEFAULT; publicadminfalse665664K260482753 stdjrnlgrp_idDEFAULTvALTER TABLE ONLY stdjrnlgrp ALTER COLUMN stdjrnlgrp_id SET DEFAULT nextval('stdjrnlgrp_stdjrnlgrp_id_seq'::regclass); GALTER TABLE public.stdjrnlgrp ALTER COLUMN stdjrnlgrp_id DROP DEFAULT; publicadminfalse667666M260482754stdjrnlgrpitem_idDEFAULTALTER TABLE ONLY stdjrnlgrpitem ALTER COLUMN stdjrnlgrpitem_id SET DEFAULT nextval('stdjrnlgrpitem_stdjrnlgrpitem_id_seq'::regclass); OALTER TABLE public.stdjrnlgrpitem ALTER COLUMN stdjrnlgrpitem_id DROP DEFAULT; publicadminfalse669668N260482755stdjrnlitem_idDEFAULTzALTER TABLE ONLY stdjrnlitem ALTER COLUMN stdjrnlitem_id SET DEFAULT nextval('stdjrnlitem_stdjrnlitem_id_seq'::regclass); IALTER TABLE public.stdjrnlitem ALTER COLUMN stdjrnlitem_id DROP DEFAULT; publicadminfalse671670O260482756 subaccnt_idDEFAULTnALTER TABLE ONLY subaccnt ALTER COLUMN subaccnt_id SET DEFAULT nextval('subaccnt_subaccnt_id_seq'::regclass); CALTER TABLE public.subaccnt ALTER COLUMN subaccnt_id DROP DEFAULT; publicadminfalse673672Q260482757subaccnttype_idDEFAULT~ALTER TABLE ONLY subaccnttype ALTER COLUMN subaccnttype_id SET DEFAULT nextval('subaccnttype_subaccnttype_id_seq'::regclass); KALTER TABLE public.subaccnttype ALTER COLUMN subaccnttype_id DROP DEFAULT; publicadminfalse675674R260482758 taxass_idDEFAULTfALTER TABLE ONLY taxass ALTER COLUMN taxass_id SET DEFAULT nextval('taxass_taxass_id_seq'::regclass); ?ALTER TABLE public.taxass ALTER COLUMN taxass_id DROP DEFAULT; publicadminfalse678677.260482759 taxauth_idDEFAULTjALTER TABLE ONLY taxauth ALTER COLUMN taxauth_id SET DEFAULT nextval('taxauth_taxauth_id_seq'::regclass); AALTER TABLE public.taxauth ALTER COLUMN taxauth_id DROP DEFAULT; publicadminfalse679239S260482760 taxclass_idDEFAULTnALTER TABLE ONLY taxclass ALTER COLUMN taxclass_id SET DEFAULT nextval('taxclass_taxclass_id_seq'::regclass); CALTER TABLE public.taxclass ALTER COLUMN taxclass_id DROP DEFAULT; publicadminfalse681680260482761 taxhist_idDEFAULTjALTER TABLE ONLY taxhist ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); AALTER TABLE public.taxhist ALTER COLUMN taxhist_id DROP DEFAULT; publicadminfalse682281260487565 taxpay_idDEFAULTfALTER TABLE ONLY taxpay ALTER COLUMN taxpay_id SET DEFAULT nextval('taxpay_taxpay_id_seq'::regclass); ?ALTER TABLE public.taxpay ALTER COLUMN taxpay_id DROP DEFAULT; publicadminfalse789788U260482762 taxrate_idDEFAULTjALTER TABLE ONLY taxrate ALTER COLUMN taxrate_id SET DEFAULT nextval('taxrate_taxrate_id_seq'::regclass); AALTER TABLE public.taxrate ALTER COLUMN taxrate_id DROP DEFAULT; publicadminfalse6846833260482763 taxreg_idDEFAULTfALTER TABLE ONLY taxreg ALTER COLUMN taxreg_id SET DEFAULT nextval('taxreg_taxreg_id_seq'::regclass); ?ALTER TABLE public.taxreg ALTER COLUMN taxreg_id DROP DEFAULT; publicadminfalse685240\260482764 taxtype_idDEFAULTjALTER TABLE ONLY taxtype ALTER COLUMN taxtype_id SET DEFAULT nextval('taxtype_taxtype_id_seq'::regclass); AALTER TABLE public.taxtype ALTER COLUMN taxtype_id DROP DEFAULT; publicadminfalse686182260482765 taxzone_idDEFAULTjALTER TABLE ONLY taxzone ALTER COLUMN taxzone_id SET DEFAULT nextval('taxzone_taxzone_id_seq'::regclass); AALTER TABLE public.taxzone ALTER COLUMN taxzone_id DROP DEFAULT; publicadminfalse687203260482766 todoitem_idDEFAULTnALTER TABLE ONLY todoitem ALTER COLUMN todoitem_id SET DEFAULT nextval('todoitem_todoitem_id_seq'::regclass); CALTER TABLE public.todoitem ALTER COLUMN todoitem_id DROP DEFAULT; publicadminfalse689212V260482767 trialbal_idDEFAULTnALTER TABLE ONLY trialbal ALTER COLUMN trialbal_id SET DEFAULT nextval('trialbal_trialbal_id_seq'::regclass); CALTER TABLE public.trialbal ALTER COLUMN trialbal_id DROP DEFAULT; publicadminfalse692691260482768 uiform_idDEFAULTfALTER TABLE ONLY uiform ALTER COLUMN uiform_id SET DEFAULT nextval('uiform_uiform_id_seq'::regclass); ?ALTER TABLE public.uiform ALTER COLUMN uiform_id DROP DEFAULT; publicadminfalse307306_260482769uom_idDEFAULTZALTER TABLE ONLY uom ALTER COLUMN uom_id SET DEFAULT nextval('uom_uom_id_seq'::regclass); 9ALTER TABLE public.uom ALTER COLUMN uom_id DROP DEFAULT; publicadminfalse693183X260482770 uomconv_idDEFAULTjALTER TABLE ONLY uomconv ALTER COLUMN uomconv_id SET DEFAULT nextval('uomconv_uomconv_id_seq'::regclass); AALTER TABLE public.uomconv ALTER COLUMN uomconv_id DROP DEFAULT; publicadminfalse695694Z260482771 uomtype_idDEFAULTjALTER TABLE ONLY uomtype ALTER COLUMN uomtype_id SET DEFAULT nextval('uomtype_uomtype_id_seq'::regclass); AALTER TABLE public.uomtype ALTER COLUMN uomtype_id DROP DEFAULT; publicadminfalse697696260482772url_idDEFAULTbALTER TABLE ONLY urlinfo ALTER COLUMN url_id SET DEFAULT nextval('urlinfo_url_id_seq'::regclass); =ALTER TABLE public.urlinfo ALTER COLUMN url_id DROP DEFAULT; publicadminfalse698220260482773 usrgrp_idDEFAULTfALTER TABLE ONLY usrgrp ALTER COLUMN usrgrp_id SET DEFAULT nextval('usrgrp_usrgrp_id_seq'::regclass); ?ALTER TABLE public.usrgrp ALTER COLUMN usrgrp_id DROP DEFAULT; publicadminfalse703608260482774 vendtype_idDEFAULTnALTER TABLE ONLY vendtype ALTER COLUMN vendtype_id SET DEFAULT nextval('vendtype_vendtype_id_seq'::regclass); CALTER TABLE public.vendtype ALTER COLUMN vendtype_id DROP DEFAULT; publicadminfalse710285f260482775 taxhist_idDEFAULTlALTER TABLE ONLY voheadtax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); CALTER TABLE public.voheadtax ALTER COLUMN taxhist_id DROP DEFAULT; publicadminfalse715715682i260482776 taxhist_idDEFAULTlALTER TABLE ONLY voitemtax ALTER COLUMN taxhist_id SET DEFAULT nextval('taxhist_taxhist_id_seq'::regclass); CALTER TABLE public.voitemtax ALTER COLUMN taxhist_id DROP DEFAULT; publicadminfalse718718682~260482777 whsezone_idDEFAULTnALTER TABLE ONLY whsezone ALTER COLUMN whsezone_id SET DEFAULT nextval('whsezone_whsezone_id_seq'::regclass); CALTER TABLE public.whsezone ALTER COLUMN whsezone_id DROP DEFAULT; publicadminfalse721267j260482778 womatlpost_idDEFAULTvALTER TABLE ONLY womatlpost ALTER COLUMN womatlpost_id SET DEFAULT nextval('womatlpost_womatlpost_id_seq'::regclass); GALTER TABLE public.womatlpost ALTER COLUMN womatlpost_id DROP DEFAULT; publicadminfalse725724m260482779 xsltmap_idDEFAULTjALTER TABLE ONLY xsltmap ALTER COLUMN xsltmap_id SET DEFAULT nextval('xsltmap_xsltmap_id_seq'::regclass); AALTER TABLE public.xsltmap ALTER COLUMN xsltmap_id DROP DEFAULT; publicadminfalse730729r260482780 yearperiod_idDEFAULTvALTER TABLE ONLY yearperiod ALTER COLUMN yearperiod_id SET DEFAULT nextval('yearperiod_yearperiod_id_seq'::regclass); GALTER TABLE public.yearperiod ALTER COLUMN yearperiod_id DROP DEFAULT; publicadminfalse732731x260482781 metasql_gradeDEFAULTFALTER TABLE ONLY pkgmetasql ALTER COLUMN metasql_grade SET DEFAULT 0; CALTER TABLE te.pkgmetasql ALTER COLUMN metasql_grade DROP DEFAULT; teadminfalse736736|260482782script_enabledDEFAULTJALTER TABLE ONLY pkgscript ALTER COLUMN script_enabled SET DEFAULT false; CALTER TABLE te.pkgscript ALTER COLUMN script_enabled DROP DEFAULT; teadminfalse739739~260482783uiform_enabledDEFAULTJALTER TABLE ONLY pkguiform ALTER COLUMN uiform_enabled SET DEFAULT false; CALTER TABLE te.pkguiform ALTER COLUMN uiform_enabled DROP DEFAULT; teadminfalse740740260482784 tecustrate_idDEFAULTvALTER TABLE ONLY tecustrate ALTER COLUMN tecustrate_id SET DEFAULT nextval('tecustrate_tecustrate_id_seq'::regclass); CALTER TABLE te.tecustrate ALTER COLUMN tecustrate_id DROP DEFAULT; teadminfalse742741260482785teemp_idDEFAULTbALTER TABLE ONLY teemp ALTER COLUMN teemp_id SET DEFAULT nextval('teemp_teemp_id_seq'::regclass); 9ALTER TABLE te.teemp ALTER COLUMN teemp_id DROP DEFAULT; teadminfalse744743260482786 tehead_idDEFAULTfALTER TABLE ONLY tehead ALTER COLUMN tehead_id SET DEFAULT nextval('tehead_tehead_id_seq'::regclass); ;ALTER TABLE te.tehead ALTER COLUMN tehead_id DROP DEFAULT; teadminfalse748747260482787 teitem_idDEFAULTfALTER TABLE ONLY teitem ALTER COLUMN teitem_id SET DEFAULT nextval('teitem_teitem_id_seq'::regclass); ;ALTER TABLE te.teitem ALTER COLUMN teitem_id DROP DEFAULT; teadminfalse750749260482788teprj_idDEFAULTbALTER TABLE ONLY teprj ALTER COLUMN teprj_id SET DEFAULT nextval('teprj_teprj_id_seq'::regclass); 9ALTER TABLE te.teprj ALTER COLUMN teprj_id DROP DEFAULT; teadminfalse752751260482789 teprjtask_idDEFAULTrALTER TABLE ONLY teprjtask ALTER COLUMN teprjtask_id SET DEFAULT nextval('teprjtask_teprjtask_id_seq'::regclass); AALTER TABLE te.teprjtask ALTER COLUMN teprjtask_id DROP DEFAULT; teadminfalse754753260486824js_idDEFAULTVALTER TABLE ONLY js ALTER COLUMN js_id SET DEFAULT nextval('js_js_id_seq'::regclass); 3ALTER TABLE xt.js ALTER COLUMN js_id DROP DEFAULT; xtadminfalse764763260482790 metasql_gradeDEFAULTFALTER TABLE ONLY pkgmetasql ALTER COLUMN metasql_grade SET DEFAULT 0; JALTER TABLE xtdesktop.pkgmetasql ALTER COLUMN metasql_grade DROP DEFAULT;  xtdesktopadminfalse758758260482791script_enabledDEFAULTJALTER TABLE ONLY pkgscript ALTER COLUMN script_enabled SET DEFAULT false; JALTER TABLE xtdesktop.pkgscript ALTER COLUMN script_enabled DROP DEFAULT;  xtdesktopadminfalse761761260482792uiform_enabledDEFAULTJALTER TABLE ONLY pkguiform ALTER COLUMN uiform_enabled SET DEFAULT false; JALTER TABLE xtdesktop.pkguiform ALTER COLUMN uiform_enabled DROP DEFAULT;  xtdesktopadminfalse762762#080528pkgcmd TABLE DATAmCOPY pkgcmd (cmd_id, cmd_module, cmd_title, cmd_descrip, cmd_privname, cmd_executable, cmd_name) FROM stdin; fixcountryadminfalse28896344VJ#080543 pkgcmdarg TABLE DATAPCOPY pkgcmdarg (cmdarg_id, cmdarg_cmd_id, cmdarg_order, cmdarg_arg) FROM stdin; fixcountryadminfalse2919634QVJ#080552pkgimage TABLE DATALCOPY pkgimage (image_id, image_name, image_descrip, image_data) FROM stdin; fixcountryadminfalse2939634nVJ#080568 pkgmetasql TABLE DATACOPY pkgmetasql (metasql_id, metasql_group, metasql_name, metasql_notes, metasql_query, metasql_lastuser, metasql_lastupdate, metasql_grade) FROM stdin; fixcountryadminfalse2969634VJ#080585pkgpriv TABLE DATASCOPY pkgpriv (priv_id, priv_module, priv_name, priv_descrip, priv_seq) FROM stdin; fixcountryadminfalse2999634YJ#080601 pkgreport TABLE DATA~COPY pkgreport (report_id, report_name, report_sys, report_source, report_descrip, report_grade, report_loaddate) FROM stdin; fixcountryadminfalse3029634YJ#080617 pkgscript TABLE DATAoCOPY pkgscript (script_id, script_name, script_order, script_enabled, script_source, script_notes) FROM stdin; fixcountryadminfalse3059634ZJ#080634 pkguiform TABLE DATAoCOPY pkguiform (uiform_id, uiform_name, uiform_order, uiform_enabled, uiform_source, uiform_notes) FROM stdin; fixcountryadminfalse3089634SeJ#080642acalitem TABLE DATAyCOPY acalitem (acalitem_id, acalitem_calhead_id, acalitem_periodstart, acalitem_periodlength, acalitem_name) FROM stdin; publicadminfalse3099634nJ#079712accnt TABLE DATACOPY accnt (accnt_id, accnt_number, accnt_descrip, accnt_comments, accnt_profit, accnt_sub, accnt_type, accnt_extref, accnt_company, accnt_forwardupdate, accnt_subaccnttype_code, accnt_curr_id, accnt_active, accnt_name) FROM stdin; publicadminfalse2289634nJ+00accnt_accnt_id_seq SEQUENCE SET;SELECT pg_catalog.setval('accnt_accnt_id_seq', 136, true); publicadminfalse310#079534addr TABLE DATACOPY addr (addr_id, addr_active, addr_line1, addr_line2, addr_line3, addr_city, addr_state, addr_postalcode, addr_country, addr_notes, addr_number) FROM stdin; publicadminfalse2139634$sJ+00addr_addr_id_seq SEQUENCE SET7SELECT pg_catalog.setval('addr_addr_id_seq', 3, true); publicadminfalse311#080658alarm TABLE DATACOPY alarm (alarm_id, alarm_number, alarm_event, alarm_email, alarm_sysmsg, alarm_trigger, alarm_time, alarm_time_offset, alarm_time_qualifier, alarm_creator, alarm_event_recipient, alarm_email_recipient, alarm_sysmsg_recipient, alarm_source, alarm_source_id) FROM stdin; publicadminfalse3129634sJ+00alarm_alarm_id_seq SEQUENCE SET:SELECT pg_catalog.setval('alarm_alarm_id_seq', 1, false); publicadminfalse313#080669apaccnt TABLE DATACOPY apaccnt (apaccnt_id, apaccnt_vendtype_id, apaccnt_vendtype, apaccnt_ap_accnt_id, apaccnt_prepaid_accnt_id, apaccnt_discount_accnt_id) FROM stdin; publicadminfalse3149634sJ+00apaccnt_apaccnt_id_seq SEQUENCE SET>SELECT pg_catalog.setval('apaccnt_apaccnt_id_seq', 20, true); publicadminfalse315#080677apapply TABLE DATAVCOPY apapply (apapply_id, apapply_vend_id, apapply_postdate, apapply_username, apapply_source_apopen_id, apapply_source_doctype, apapply_source_docnumber, apapply_target_apopen_id, apapply_target_doctype, apapply_target_docnumber, apapply_journalnumber, apapply_amount, apapply_curr_id, apapply_target_paid, apapply_checkhead_id) FROM stdin; publicadminfalse3169634"tJ+00apapply_apapply_id_seq SEQUENCE SET>SELECT pg_catalog.setval('apapply_apapply_id_seq', 1, false); publicadminfalse317#080720 apcreditapply TABLE DATACOPY apcreditapply (apcreditapply_id, apcreditapply_source_apopen_id, apcreditapply_target_apopen_id, apcreditapply_amount, apcreditapply_curr_id) FROM stdin; publicadminfalse3229634?tJ+00"apcreditapply_apcreditapply_id_seq SEQUENCE SETJSELECT pg_catalog.setval('apcreditapply_apcreditapply_id_seq', 1, false); publicadminfalse323o#078717apopen TABLE DATACOPY apopen (apopen_id, apopen_docdate, apopen_duedate, apopen_terms_id, apopen_vend_id, apopen_doctype, apopen_docnumber, apopen_amount, apopen_notes, apopen_posted, apopen_reference, apopen_invcnumber, apopen_ponumber, apopen_journalnumber, apopen_paid, apopen_open, apopen_username, apopen_discount, apopen_accnt_id, apopen_curr_id, apopen_closedate, apopen_distdate, apopen_void, apopen_curr_rate, apopen_discountable_amount, apopen_status) FROM stdin; publicadminfalse1909634\tJ+00apopen_apopen_id_seq SEQUENCE SET<SELECT pg_catalog.setval('apopen_apopen_id_seq', 70, true); publicadminfalse325#080732 apopentax TABLE DATA"COPY apopentax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; publicadminfalse3269634ytJ#080738apselect TABLE DATACOPY apselect (apselect_id, apselect_apopen_id, apselect_amount, apselect_bankaccnt_id, apselect_curr_id, apselect_date, apselect_discount) FROM stdin; publicadminfalse3279634tJ+00apselect_apselect_id_seq SEQUENCE SETASELECT pg_catalog.setval('apselect_apselect_id_seq', 501, true); publicadminfalse328#080745araccnt TABLE DATACOPY araccnt (araccnt_id, araccnt_custtype_id, araccnt_custtype, araccnt_freight_accnt_id, araccnt_ar_accnt_id, araccnt_prepaid_accnt_id, araccnt_deferred_accnt_id, araccnt_discount_accnt_id) FROM stdin; publicadminfalse3299634tJ+00araccnt_araccnt_id_seq SEQUENCE SET>SELECT pg_catalog.setval('araccnt_araccnt_id_seq', 39, true); publicadminfalse330#080754arapply TABLE DATACOPY arapply (arapply_id, arapply_postdate, arapply_cust_id, arapply_source_doctype, arapply_source_docnumber, arapply_target_doctype, arapply_target_docnumber, arapply_fundstype, arapply_refnumber, arapply_applied, arapply_closed, arapply_journalnumber, arapply_source_aropen_id, arapply_target_aropen_id, arapply_username, arapply_curr_id, arapply_distdate, arapply_target_paid, arapply_reftype, arapply_ref_id) FROM stdin; publicadminfalse3319634tJ+00arapply_arapply_id_seq SEQUENCE SET>SELECT pg_catalog.setval('arapply_arapply_id_seq', 1, false); publicadminfalse332#080765 arcreditapply TABLE DATACOPY arcreditapply (arcreditapply_id, arcreditapply_source_aropen_id, arcreditapply_target_aropen_id, arcreditapply_amount, arcreditapply_curr_id, arcreditapply_reftype, arcreditapply_ref_id) FROM stdin; publicadminfalse3349634uJ+00"arcreditapply_arcreditapply_id_seq SEQUENCE SETJSELECT pg_catalog.setval('arcreditapply_arcreditapply_id_seq', 1, false); publicadminfalse335s#078771aropen TABLE DATA;COPY aropen (aropen_id, aropen_docdate, aropen_duedate, aropen_terms_id, aropen_cust_id, aropen_doctype, aropen_docnumber, aropen_applyto, aropen_ponumber, aropen_amount, aropen_notes, aropen_posted, aropen_salesrep_id, aropen_commission_due, aropen_commission_paid, aropen_ordernumber, aropen_cobmisc_id, aropen_journalnumber, aropen_paid, aropen_open, aropen_username, aropen_rsncode_id, aropen_salescat_id, aropen_accnt_id, aropen_curr_id, aropen_closedate, aropen_distdate, aropen_curr_rate, aropen_discount, aropen_fincharg_date, aropen_fincharg_amount) FROM stdin; publicadminfalse1959634%uJ+00aropen_aropen_id_seq SEQUENCE SET=SELECT pg_catalog.setval('aropen_aropen_id_seq', 292, true); publicadminfalse337#080399 aropenalloc TABLE DATACOPY aropenalloc (aropenalloc_aropen_id, aropenalloc_doctype, aropenalloc_doc_id, aropenalloc_amount, aropenalloc_curr_id) FROM stdin; publicadminfalse2799634BuJ#080781 aropentax TABLE DATA"COPY aropentax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; publicadminfalse3389634_uJ#080787asohist TABLE DATAHCOPY asohist (asohist_id, asohist_cust_id, asohist_itemsite_id, asohist_shipdate, asohist_invcdate, asohist_duedate, asohist_promisedate, asohist_ordernumber, asohist_invcnumber, asohist_qtyshipped, asohist_unitprice, asohist_unitcost, asohist_billtoname, asohist_billtoaddress1, asohist_billtoaddress2, asohist_billtoaddress3, asohist_billtocity, asohist_billtostate, asohist_billtozip, asohist_shiptoname, asohist_shiptoaddress1, asohist_shiptoaddress2, asohist_shiptoaddress3, asohist_shiptocity, asohist_shiptostate, asohist_shiptozip, asohist_shipto_id, asohist_shipvia, asohist_salesrep_id, asohist_misc_type, asohist_misc_descrip, asohist_misc_id, asohist_commission, asohist_commissionpaid, asohist_doctype, asohist_orderdate, asohist_imported, asohist_ponumber, asohist_curr_id, asohist_taxtype_id, asohist_taxzone_id) FROM stdin; publicadminfalse3399634|uJ+00asohist_asohist_id_seq SEQUENCE SET>SELECT pg_catalog.setval('asohist_asohist_id_seq', 1, false); publicadminfalse340#080796 asohisttax TABLE DATA#COPY asohisttax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; publicadminfalse3419634uJ$080802atlasmap TABLE DATACOPY atlasmap (atlasmap_id, atlasmap_name, atlasmap_filter, atlasmap_filtertype, atlasmap_atlas, atlasmap_map, atlasmap_headerline) FROM stdin; publicadminfalse3429634uJ+00atlasmap_atlasmap_id_seq SEQUENCE SET@SELECT pg_catalog.setval('atlasmap_atlasmap_id_seq', 1, false); publicadminfalse343$080812 backup_usr TABLE DATACOPY backup_usr (usr_id, usr_username, usr_propername, usr_passwd, usr_locale_id, usr_initials, usr_agent, usr_active, usr_email, usr_dept_id, usr_shift_id, usr_window) FROM stdin; publicadminfalse3449634uJ#079736 bankaccnt TABLE DATACOPY bankaccnt (bankaccnt_id, bankaccnt_name, bankaccnt_descrip, bankaccnt_bankname, bankaccnt_accntnumber, bankaccnt_ar, bankaccnt_ap, bankaccnt_nextchknum, bankaccnt_type, bankaccnt_accnt_id, bankaccnt_check_form_id, bankaccnt_userec, bankaccnt_rec_accnt_id, bankaccnt_curr_id, bankaccnt_notes, bankaccnt_routing, bankaccnt_ach_enabled, bankaccnt_ach_origin, bankaccnt_ach_genchecknum, bankaccnt_ach_leadtime, bankaccnt_ach_lastdate, bankaccnt_ach_lastfileid, bankaccnt_ach_origintype, bankaccnt_ach_originname, bankaccnt_ach_desttype, bankaccnt_ach_fed_dest, bankaccnt_ach_destname, bankaccnt_ach_dest, bankaccnt_prnt_check) FROM stdin; publicadminfalse2319634;vJ+00bankaccnt_bankaccnt_id_seq SEQUENCE SETBSELECT pg_catalog.setval('bankaccnt_bankaccnt_id_seq', 13, true); publicadminfalse345$080820bankadj TABLE DATACOPY bankadj (bankadj_id, bankadj_bankaccnt_id, bankadj_bankadjtype_id, bankadj_created, bankadj_username, bankadj_date, bankadj_docnumber, bankadj_amount, bankadj_notes, bankadj_sequence, bankadj_posted, bankadj_curr_id, bankadj_curr_rate) FROM stdin; publicadminfalse3469634vJ+00bankadj_bankadj_id_seq SEQUENCE SET>SELECT pg_catalog.setval('bankadj_bankadj_id_seq', 1, false); publicadminfalse347$080832 bankadjtype TABLE DATACOPY bankadjtype (bankadjtype_id, bankadjtype_name, bankadjtype_descrip, bankadjtype_accnt_id, bankadjtype_iscredit) FROM stdin; publicadminfalse3489634vJ+00bankadjtype_bankadjtype_id_seq SEQUENCE SETFSELECT pg_catalog.setval('bankadjtype_bankadjtype_id_seq', 1, false); publicadminfalse349$080842bankrec TABLE DATACOPY bankrec (bankrec_id, bankrec_created, bankrec_username, bankrec_bankaccnt_id, bankrec_opendate, bankrec_enddate, bankrec_openbal, bankrec_endbal, bankrec_posted, bankrec_postdate) FROM stdin; publicadminfalse3509634vJ+00bankrec_bankrec_id_seq SEQUENCE SET>SELECT pg_catalog.setval('bankrec_bankrec_id_seq', 1, false); publicadminfalse351%087327 bankrecimport TABLE DATACOPY bankrecimport (bankrecimport_id, bankrecimport_reference, bankrecimport_descrip, bankrecimport_comment, bankrecimport_debit_amount, bankrecimport_credit_amount, bankrecimport_effdate, bankrecimport_curr_rate) FROM stdin; publicadminfalse7839634vJ+00"bankrecimport_bankrecimport_id_seq SEQUENCE SETJSELECT pg_catalog.setval('bankrecimport_bankrecimport_id_seq', 1, false); publicadminfalse784 $080853 bankrecitem TABLE DATACOPY bankrecitem (bankrecitem_id, bankrecitem_bankrec_id, bankrecitem_source, bankrecitem_source_id, bankrecitem_cleared, bankrecitem_curr_rate, bankrecitem_amount, bankrecitem_effdate) FROM stdin; publicadminfalse3529634vJ+00bankrecitem_bankrecitem_id_seq SEQUENCE SETFSELECT pg_catalog.setval('bankrecitem_bankrecitem_id_seq', 1, false); publicadminfalse353#079670bomhead TABLE DATACOPY bomhead (bomhead_id, bomhead_item_id, bomhead_serial, bomhead_docnum, bomhead_revision, bomhead_revisiondate, bomhead_batchsize, bomhead_requiredqtyper, bomhead_rev_id) FROM stdin; publicadminfalse2259634wJ+00bomhead_bomhead_id_seq SEQUENCE SET>SELECT pg_catalog.setval('bomhead_bomhead_id_seq', 54, true); publicadminfalse354k#077994bomitem TABLE DATACOPY bomitem (bomitem_id, bomitem_parent_item_id, bomitem_seqnumber, bomitem_item_id, bomitem_qtyper, bomitem_scrap, bomitem_status, bomitem_effective, bomitem_expires, bomitem_createwo, bomitem_issuemethod, bomitem_schedatwooper, bomitem_ecn, bomitem_moddate, bomitem_subtype, bomitem_uom_id, bomitem_rev_id, bomitem_booitem_seq_id, bomitem_char_id, bomitem_value, bomitem_notes, bomitem_ref, bomitem_qtyfxd, bomitem_issuewo) FROM stdin; publicadminfalse18696342wJ+00bomitem_bomitem_id_seq SEQUENCE SET?SELECT pg_catalog.setval('bomitem_bomitem_id_seq', 167, true); publicadminfalse355$080866 bomitemcost TABLE DATACOPY bomitemcost (bomitemcost_id, bomitemcost_bomitem_id, bomitemcost_costelem_id, bomitemcost_lowlevel, bomitemcost_stdcost, bomitemcost_posted, bomitemcost_actcost, bomitemcost_updated, bomitemcost_curr_id) FROM stdin; publicadminfalse3569634OwJ+00bomitemcost_bomitemcost_id_seq SEQUENCE SETFSELECT pg_catalog.setval('bomitemcost_bomitemcost_id_seq', 1, false); publicadminfalse357#079693 bomitemsub TABLE DATA}COPY bomitemsub (bomitemsub_id, bomitemsub_bomitem_id, bomitemsub_item_id, bomitemsub_uomratio, bomitemsub_rank) FROM stdin; publicadminfalse2269634lwJ+00bomitemsub_bomitemsub_id_seq SEQUENCE SETDSELECT pg_catalog.setval('bomitemsub_bomitemsub_id_seq', 1, false); publicadminfalse358$080877bomwork TABLE DATACOPY bomwork (bomwork_id, bomwork_set_id, bomwork_seqnumber, bomwork_item_id, bomwork_item_type, bomwork_qtyper, bomwork_scrap, bomwork_status, bomwork_level, bomwork_parent_id, bomwork_effective, bomwork_expires, bomwork_stdunitcost, bomwork_actunitcost, bomwork_parent_seqnumber, bomwork_createwo, bomwork_issuemethod, bomwork_char_id, bomwork_value, bomwork_notes, bomwork_ref, bomwork_bomitem_id, bomwork_ecn, bomwork_qtyfxd, bomwork_qtyreq) FROM stdin; publicadminfalse3599634wJ+00bomwork_bomwork_id_seq SEQUENCE SET>SELECT pg_catalog.setval('bomwork_bomwork_id_seq', 1, false); publicadminfalse360#079701budghead TABLE DATAICOPY budghead (budghead_id, budghead_name, budghead_descrip) FROM stdin; publicadminfalse2279634wJ+00budghead_budghead_id_seq SEQUENCE SET?SELECT pg_catalog.setval('budghead_budghead_id_seq', 2, true); publicadminfalse361#079722budgitem TABLE DATAvCOPY budgitem (budgitem_id, budgitem_budghead_id, budgitem_period_id, budgitem_accnt_id, budgitem_amount) FROM stdin; publicadminfalse2299634wJ+00budgitem_budgitem_id_seq SEQUENCE SET?SELECT pg_catalog.setval('budgitem_budgitem_id_seq', 1, true); publicadminfalse362$080895calhead TABLE DATAcCOPY calhead (calhead_id, calhead_type, calhead_name, calhead_descrip, calhead_origin) FROM stdin; publicadminfalse3639634xJ+00calhead_calhead_id_seq SEQUENCE SET>SELECT pg_catalog.setval('calhead_calhead_id_seq', 48, true); publicadminfalse364+00carrier_carrier_id_seq SEQUENCE SET>SELECT pg_catalog.setval('carrier_carrier_id_seq', 15, true); publicadminfalse365#079748cashrcpt TABLE DATACOPY cashrcpt (cashrcpt_id, cashrcpt_cust_id, cashrcpt_amount, cashrcpt_fundstype, cashrcpt_docnumber, cashrcpt_bankaccnt_id, cashrcpt_notes, cashrcpt_distdate, cashrcpt_salescat_id, cashrcpt_curr_id, cashrcpt_usecustdeposit, cashrcpt_void, cashrcpt_number, cashrcpt_docdate, cashrcpt_posted, cashrcpt_posteddate, cashrcpt_postedby, cashrcpt_applydate, cashrcpt_discount, cashrcpt_curr_rate, cashrcpt_alt_curr_rate) FROM stdin; publicadminfalse2329634kxJ+00cashrcpt_cashrcpt_id_seq SEQUENCE SETASELECT pg_catalog.setval('cashrcpt_cashrcpt_id_seq', 112, true); publicadminfalse366#079767 cashrcptitem TABLE DATACOPY cashrcptitem (cashrcptitem_id, cashrcptitem_cashrcpt_id, cashrcptitem_aropen_id, cashrcptitem_amount, cashrcptitem_discount, cashrcptitem_applied) FROM stdin; publicadminfalse2339634xJ+00 cashrcptitem_cashrcptitem_id_seq SEQUENCE SETISELECT pg_catalog.setval('cashrcptitem_cashrcptitem_id_seq', 170, true); publicadminfalse333#079777 cashrcptmisc TABLE DATACOPY cashrcptmisc (cashrcptmisc_id, cashrcptmisc_cashrcpt_id, cashrcptmisc_accnt_id, cashrcptmisc_amount, cashrcptmisc_notes) FROM stdin; publicadminfalse2349634xJ+00 cashrcptmisc_cashrcptmisc_id_seq SEQUENCE SETHSELECT pg_catalog.setval('cashrcptmisc_cashrcptmisc_id_seq', 26, true); publicadminfalse367#079810ccard TABLE DATAWCOPY ccard (ccard_id, ccard_seq, ccard_cust_id, ccard_active, ccard_name, ccard_address1, ccard_address2, ccard_city, ccard_state, ccard_zip, ccard_country, ccard_number, ccard_debit, ccard_month_expired, ccard_year_expired, ccard_type, ccard_date_added, ccard_lastupdated, ccard_added_by_username, ccard_last_updated_by_username) FROM stdin; publicadminfalse2359634xJ+00ccard_ccard_id_seq SEQUENCE SET:SELECT pg_catalog.setval('ccard_ccard_id_seq', 1, false); publicadminfalse368$080913ccardaud TABLE DATACOPY ccardaud (ccardaud_id, ccardaud_ccard_id, ccardaud_ccard_seq_old, ccardaud_ccard_seq_new, ccardaud_ccard_cust_id_old, ccardaud_ccard_cust_id_new, ccardaud_ccard_active_old, ccardaud_ccard_active_new, ccardaud_ccard_name_old, ccardaud_ccard_name_new, ccardaud_ccard_address1_old, ccardaud_ccard_address1_new, ccardaud_ccard_address2_old, ccardaud_ccard_address2_new, ccardaud_ccard_city_old, ccardaud_ccard_city_new, ccardaud_ccard_state_old, ccardaud_ccard_state_new, ccardaud_ccard_zip_old, ccardaud_ccard_zip_new, ccardaud_ccard_country_old, ccardaud_ccard_country_new, ccardaud_ccard_number_old, ccardaud_ccard_number_new, ccardaud_ccard_debit_old, ccardaud_ccard_debit_new, ccardaud_ccard_month_expired_old, ccardaud_ccard_month_expired_new, ccardaud_ccard_year_expired_old, ccardaud_ccard_year_expired_new, ccardaud_ccard_type_old, ccardaud_ccard_type_new, ccardaud_ccard_last_updated, ccardaud_ccard_last_updated_by_username) FROM stdin; publicadminfalse3699634xJ+00ccardaud_ccardaud_id_seq SEQUENCE SET@SELECT pg_catalog.setval('ccardaud_ccardaud_id_seq', 1, false); publicadminfalse370$080923ccbank TABLE DATALCOPY ccbank (ccbank_id, ccbank_ccard_type, ccbank_bankaccnt_id) FROM stdin; publicadminfalse3719634xJ+00ccbank_ccbank_id_seq SEQUENCE SET;SELECT pg_catalog.setval('ccbank_ccbank_id_seq', 5, true); publicadminfalse372$080932ccpay TABLE DATACOPY ccpay (ccpay_id, ccpay_ccard_id, ccpay_cust_id, ccpay_amount, ccpay_auth, ccpay_status, ccpay_type, ccpay_auth_charge, ccpay_order_number, ccpay_order_number_seq, ccpay_r_avs, ccpay_r_ordernum, ccpay_r_error, ccpay_r_approved, ccpay_r_code, ccpay_r_message, ccpay_yp_r_time, ccpay_r_ref, ccpay_yp_r_tdate, ccpay_r_tax, ccpay_r_shipping, ccpay_yp_r_score, ccpay_transaction_datetime, ccpay_by_username, ccpay_curr_id, ccpay_ccpay_id, ccpay_card_pan_trunc, ccpay_card_type) FROM stdin; publicadminfalse37396342yJ+00ccpay_ccpay_id_seq SEQUENCE SET:SELECT pg_catalog.setval('ccpay_ccpay_id_seq', 1, false); publicadminfalse374#079555char TABLE DATACOPY "char" (char_id, char_name, char_items, char_options, char_attributes, char_lotserial, char_notes, char_customers, char_crmaccounts, char_addresses, char_contacts, char_opportunity, char_employees, char_mask, char_validator, char_incidents, char_type, char_order, char_search, char_quotes, char_salesorders, char_invoices, char_vendors, char_purchaseorders, char_vouchers, char_projects, char_tasks) FROM stdin; publicadminfalse2149634OyJ+00char_char_id_seq SEQUENCE SET8SELECT pg_catalog.setval('char_char_id_seq', 15, true); publicadminfalse375#079575charass TABLE DATACOPY charass (charass_id, charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default, charass_price) FROM stdin; publicadminfalse2159634yJ+00charass_charass_id_seq SEQUENCE SET>SELECT pg_catalog.setval('charass_charass_id_seq', 1, false); publicadminfalse376#$080949charopt TABLE DATAUCOPY charopt (charopt_id, charopt_char_id, charopt_value, charopt_order) FROM stdin; publicadminfalse3779634yJ+00charopt_charopt_id_seq SEQUENCE SET=SELECT pg_catalog.setval('charopt_charopt_id_seq', 3, true); publicadminfalse378%087343charuse TABLE DATAtCOPY charuse (charuse_id, charuse_char_id, charuse_target_type, charuse_created, charuse_last_modified) FROM stdin; publicadminfalse7859634.zJ+00charuse_charuse_id_seq SEQUENCE SET=SELECT pg_catalog.setval('charuse_charuse_id_seq', 5, true); publicadminfalse786#080686 checkhead TABLE DATACOPY checkhead (checkhead_id, checkhead_recip_id, checkhead_recip_type, checkhead_bankaccnt_id, checkhead_printed, checkhead_checkdate, checkhead_number, checkhead_amount, checkhead_void, checkhead_replaced, checkhead_posted, checkhead_rec, checkhead_misc, checkhead_expcat_id, checkhead_for, checkhead_notes, checkhead_journalnumber, checkhead_curr_id, checkhead_deleted, checkhead_ach_batch, checkhead_curr_rate, checkhead_alt_curr_rate) FROM stdin; publicadminfalse3189634zJ+00checkhead_checkhead_id_seq SEQUENCE SETBSELECT pg_catalog.setval('checkhead_checkhead_id_seq', 1, false); publicadminfalse379#080706 checkitem TABLE DATA8COPY checkitem (checkitem_id, checkitem_checkhead_id, checkitem_amount, checkitem_discount, checkitem_ponumber, checkitem_vouchernumber, checkitem_invcnumber, checkitem_apopen_id, checkitem_aropen_id, checkitem_docdate, checkitem_curr_id, checkitem_cmnumber, checkitem_ranumber, checkitem_curr_rate) FROM stdin; publicadminfalse3209634zJ+00checkitem_checkitem_id_seq SEQUENCE SETBSELECT pg_catalog.setval('checkitem_checkitem_id_seq', 1, false); publicadminfalse380#080033 classcode TABLE DATACOPY classcode (classcode_id, classcode_code, classcode_descrip, classcode_mfg, classcode_creator, classcode_created, classcode_modifier, classcode_modified, classcode_type) FROM stdin; publicadminfalse2529634zJ+00classcode_classcode_id_seq SEQUENCE SETBSELECT pg_catalog.setval('classcode_classcode_id_seq', 36, true); publicadminfalse381#080520cmd TABLE DATAjCOPY cmd (cmd_id, cmd_module, cmd_title, cmd_descrip, cmd_privname, cmd_executable, cmd_name) FROM stdin; publicadminfalse2869634U{J+00cmd_cmd_id_seq SEQUENCE SET5SELECT pg_catalog.setval('cmd_cmd_id_seq', 6, true); publicadminfalse287#080535cmdarg TABLE DATAMCOPY cmdarg (cmdarg_id, cmdarg_cmd_id, cmdarg_order, cmdarg_arg) FROM stdin; publicadminfalse2899634r{J+00cmdarg_cmdarg_id_seq SEQUENCE SET;SELECT pg_catalog.setval('cmdarg_cmdarg_id_seq', 6, true); publicadminfalse290x#078835cmhead TABLE DATALCOPY cmhead (cmhead_id, cmhead_number, cmhead_posted, cmhead_invcnumber, cmhead_custponumber, cmhead_cust_id, cmhead_docdate, cmhead_shipto_id, cmhead_shipto_name, cmhead_shipto_address1, cmhead_shipto_address2, cmhead_shipto_address3, cmhead_shipto_city, cmhead_shipto_state, cmhead_shipto_zipcode, cmhead_salesrep_id, cmhead_freight, cmhead_misc, cmhead_comments, cmhead_printed, cmhead_billtoname, cmhead_billtoaddress1, cmhead_billtoaddress2, cmhead_billtoaddress3, cmhead_billtocity, cmhead_billtostate, cmhead_billtozip, cmhead_hold, cmhead_commission, cmhead_misc_accnt_id, cmhead_misc_descrip, cmhead_rsncode_id, cmhead_curr_id, cmhead_freighttaxtype_id, cmhead_gldistdate, cmhead_billtocountry, cmhead_shipto_country, cmhead_rahead_id, cmhead_taxzone_id, cmhead_prj_id, cmhead_void, cmhead_saletype_id, cmhead_shipzone_id) FROM stdin; publicadminfalse2019634{J+00cmhead_cmhead_id_seq SEQUENCE SET=SELECT pg_catalog.setval('cmhead_cmhead_id_seq', 206, true); publicadminfalse382)$080971 cmheadtax TABLE DATA"COPY cmheadtax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; publicadminfalse3839634{J{#078866cmitem TABLE DATAJCOPY cmitem (cmitem_id, cmitem_cmhead_id, cmitem_linenumber, cmitem_itemsite_id, cmitem_qtycredit, cmitem_qtyreturned, cmitem_unitprice, cmitem_comments, cmitem_rsncode_id, cmitem_taxtype_id, cmitem_qty_uom_id, cmitem_qty_invuomratio, cmitem_price_uom_id, cmitem_price_invuomratio, cmitem_raitem_id, cmitem_updateinv) FROM stdin; publicadminfalse2049634{J+00cmitem_cmitem_id_seq SEQUENCE SET<SELECT pg_catalog.setval('cmitem_cmitem_id_seq', 83, true); publicadminfalse384+$080979 cmitemtax TABLE DATA"COPY cmitemtax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; publicadminfalse3859634{J#079587cmnttype TABLE DATACOPY cmnttype (cmnttype_id, cmnttype_name, cmnttype_descrip, cmnttype_usedin, cmnttype_sys, cmnttype_editable, cmnttype_order) FROM stdin; publicadminfalse2169634|J+00cmnttype_cmnttype_id_seq SEQUENCE SET?SELECT pg_catalog.setval('cmnttype_cmnttype_id_seq', 3, true); publicadminfalse386-$080987cmnttypesource TABLE DATAjCOPY cmnttypesource (cmnttypesource_id, cmnttypesource_cmnttype_id, cmnttypesource_source_id) FROM stdin; publicadminfalse3879634|J+00$cmnttypesource_cmnttypesource_id_seq SEQUENCE SETLSELECT pg_catalog.setval('cmnttypesource_cmnttypesource_id_seq', 76, true); publicadminfalse388l#078087cntct TABLE DATA=COPY cntct (cntct_id, cntct_crmacct_id, cntct_addr_id, cntct_first_name, cntct_last_name, cntct_honorific, cntct_initials, cntct_active, cntct_phone, cntct_phone2, cntct_fax, cntct_email, cntct_webaddr, cntct_notes, cntct_title, cntct_number, cntct_middle, cntct_suffix, cntct_owner_username, cntct_name) FROM stdin; publicadminfalse1879634}J+00cntct_cntct_id_seq SEQUENCE SET9SELECT pg_catalog.setval('cntct_cntct_id_seq', 2, true); publicadminfalse3890$080994 cntctaddr TABLE DATAtCOPY cntctaddr (cntctaddr_id, cntctaddr_cntct_id, cntctaddr_primary, cntctaddr_addr_id, cntctaddr_type) FROM stdin; publicadminfalse3909634}J+00cntctaddr_cntctaddr_id_seq SEQUENCE SETBSELECT pg_catalog.setval('cntctaddr_cntctaddr_id_seq', 1, false); publicadminfalse3912$080999 cntctdata TABLE DATAqCOPY cntctdata (cntctdata_id, cntctdata_cntct_id, cntctdata_primary, cntctdata_text, cntctdata_type) FROM stdin; publicadminfalse3929634}J+00cntctdata_cntctdata_id_seq SEQUENCE SETBSELECT pg_catalog.setval('cntctdata_cntctdata_id_seq', 1, false); publicadminfalse3934$081007cntcteml TABLE DATA]COPY cntcteml (cntcteml_id, cntcteml_cntct_id, cntcteml_primary, cntcteml_email) FROM stdin; publicadminfalse3949634~J+00cntcteml_cntcteml_id_seq SEQUENCE SET@SELECT pg_catalog.setval('cntcteml_cntcteml_id_seq', 1, false); publicadminfalse3956$081016 cntctmrgd TABLE DATAACOPY cntctmrgd (cntctmrgd_cntct_id, cntctmrgd_error) FROM stdin; publicadminfalse3969634"~J7$081020cntctsel TABLE DATACOPY cntctsel (cntctsel_cntct_id, cntctsel_target, cntctsel_mrg_crmacct_id, cntctsel_mrg_addr_id, cntctsel_mrg_first_name, cntctsel_mrg_last_name, cntctsel_mrg_honorific, cntctsel_mrg_initials, cntctsel_mrg_phone, cntctsel_mrg_phone2, cntctsel_mrg_fax, cntctsel_mrg_email, cntctsel_mrg_webaddr, cntctsel_mrg_notes, cntctsel_mrg_title, cntctsel_mrg_middle, cntctsel_mrg_suffix, cntctsel_mrg_owner_username) FROM stdin; publicadminfalse3979634?~J_#077567cntslip TABLE DATACOPY cntslip (cntslip_id, cntslip_cnttag_id, cntslip_entered, cntslip_posted, cntslip_number, cntslip_qty, cntslip_comments, cntslip_location_id, cntslip_lotserial, cntslip_lotserial_expiration, cntslip_lotserial_warrpurc, cntslip_username) FROM stdin; publicadminfalse1729634\~J+00cntslip_cntslip_id_seq SEQUENCE SET>SELECT pg_catalog.setval('cntslip_cntslip_id_seq', 97, true); publicadminfalse3989$081041cobill TABLE DATACOPY cobill (cobill_id, cobill_coitem_id, cobill_selectdate, cobill_qty, cobill_invcnum, cobill_toclose, cobill_cobmisc_id, cobill_select_username, cobill_invcitem_id, cobill_taxtype_id) FROM stdin; publicadminfalse3999634y~J+00cobill_cobill_id_seq SEQUENCE SET=SELECT pg_catalog.setval('cobill_cobill_id_seq', 528, true); publicadminfalse400;$081050 cobilltax TABLE DATA"COPY cobilltax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; publicadminfalse4019634~J<$081056cobmisc TABLE DATAtCOPY cobmisc (cobmisc_id, cobmisc_cohead_id, cobmisc_shipvia, cobmisc_freight, cobmisc_misc, cobmisc_payment, cobmisc_paymentref, cobmisc_notes, cobmisc_shipdate, cobmisc_invcnumber, cobmisc_invcdate, cobmisc_posted, cobmisc_misc_accnt_id, cobmisc_misc_descrip, cobmisc_closeorder, cobmisc_curr_id, cobmisc_invchead_id, cobmisc_taxzone_id, cobmisc_taxtype_id) FROM stdin; publicadminfalse4029634~J+00cobmisc_cobmisc_id_seq SEQUENCE SET?SELECT pg_catalog.setval('cobmisc_cobmisc_id_seq', 204, true); publicadminfalse403>$081066 cobmisctax TABLE DATA#COPY cobmisctax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; publicadminfalse4049634~Jd#077657cohead TABLE DATACOPY cohead (cohead_id, cohead_number, cohead_cust_id, cohead_custponumber, cohead_type, cohead_orderdate, cohead_warehous_id, cohead_shipto_id, cohead_shiptoname, cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3, cohead_shiptoaddress4, cohead_shiptoaddress5, cohead_salesrep_id, cohead_terms_id, cohead_fob, cohead_shipvia, cohead_shiptocity, cohead_shiptostate, cohead_shiptozipcode, cohead_freight, cohead_misc, cohead_imported, cohead_ordercomments, cohead_shipcomments, cohead_shiptophone, cohead_shipchrg_id, cohead_shipform_id, cohead_billtoname, cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, cohead_billtocity, cohead_billtostate, cohead_billtozipcode, cohead_misc_accnt_id, cohead_misc_descrip, cohead_commission, cohead_miscdate, cohead_holdtype, cohead_packdate, cohead_prj_id, cohead_wasquote, cohead_lastupdated, cohead_shipcomplete, cohead_created, cohead_creator, cohead_quote_number, cohead_billtocountry, cohead_shiptocountry, cohead_curr_id, cohead_calcfreight, cohead_shipto_cntct_id, cohead_shipto_cntct_honorific, cohead_shipto_cntct_first_name, cohead_shipto_cntct_middle, cohead_shipto_cntct_last_name, cohead_shipto_cntct_suffix, cohead_shipto_cntct_phone, cohead_shipto_cntct_title, cohead_shipto_cntct_fax, cohead_shipto_cntct_email, cohead_billto_cntct_id, cohead_billto_cntct_honorific, cohead_billto_cntct_first_name, cohead_billto_cntct_middle, cohead_billto_cntct_last_name, cohead_billto_cntct_suffix, cohead_billto_cntct_phone, cohead_billto_cntct_title, cohead_billto_cntct_fax, cohead_billto_cntct_email, cohead_taxzone_id, cohead_taxtype_id, cohead_ophead_id, cohead_status, cohead_saletype_id, cohead_shipzone_id) FROM stdin; publicadminfalse1789634~J+00cohead_cohead_id_seq SEQUENCE SET>SELECT pg_catalog.setval('cohead_cohead_id_seq', 2952, true); publicadminfalse405#080409cohist TABLE DATAoCOPY cohist (cohist_id, cohist_cust_id, cohist_itemsite_id, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_orderdate, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_shipto_id, cohist_salesrep_id, cohist_duedate, cohist_imported, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_commission, cohist_commissionpaid, cohist_unitcost, cohist_misc_type, cohist_misc_descrip, cohist_misc_id, cohist_doctype, cohist_promisedate, cohist_ponumber, cohist_curr_id, cohist_sequence, cohist_taxtype_id, cohist_taxzone_id, cohist_cohead_ccpay_id, cohist_saletype_id, cohist_shipzone_id) FROM stdin; publicadminfalse2809634 J+00cohist_cohist_id_seq SEQUENCE SET=SELECT pg_catalog.setval('cohist_cohist_id_seq', 493, true); publicadminfalse406#080424 cohisttax TABLE DATA"COPY cohisttax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; publicadminfalse2829634'Je#077676coitem TABLE DATACOPY coitem (coitem_id, coitem_cohead_id, coitem_linenumber, coitem_itemsite_id, coitem_status, coitem_scheddate, coitem_promdate, coitem_qtyord, coitem_unitcost, coitem_price, coitem_custprice, coitem_qtyshipped, coitem_order_id, coitem_memo, coitem_imported, coitem_qtyreturned, coitem_closedate, coitem_custpn, coitem_order_type, coitem_close_username, coitem_lastupdated, coitem_substitute_item_id, coitem_created, coitem_creator, coitem_prcost, coitem_qty_uom_id, coitem_qty_invuomratio, coitem_price_uom_id, coitem_price_invuomratio, coitem_warranty, coitem_cos_accnt_id, coitem_qtyreserved, coitem_subnumber, coitem_firm, coitem_taxtype_id, coitem_rev_accnt_id, coitem_pricemode) FROM stdin; publicadminfalse1799634DJ+00coitem_coitem_id_seq SEQUENCE SET=SELECT pg_catalog.setval('coitem_coitem_id_seq', 564, true); publicadminfalse407#079596comment TABLE DATACOPY comment (comment_id, comment_source_id, comment_date, comment_user, comment_text, comment_cmnttype_id, comment_source, comment_public) FROM stdin; publicadminfalse2179634aJ,00comment_comment_id_seq SEQUENCE SET>SELECT pg_catalog.setval('comment_comment_id_seq', 63, true); publicadminfalse408C$081080company TABLE DATA$COPY company (company_id, company_number, company_descrip, company_external, company_server, company_port, company_database, company_curr_id, company_yearend_accnt_id, company_gainloss_accnt_id, company_dscrp_accnt_id, company_unrlzgainloss_accnt_id, company_unassigned_accnt_id) FROM stdin; publicadminfalse4099634'J,00company_company_id_seq SEQUENCE SET=SELECT pg_catalog.setval('company_company_id_seq', 1, true); publicadminfalse410#080130contrct TABLE DATACOPY contrct (contrct_id, contrct_number, contrct_vend_id, contrct_descrip, contrct_effective, contrct_expires, contrct_note) FROM stdin; publicadminfalse2599634DJ,00contrct_contrct_id_seq SEQUENCE SET>SELECT pg_catalog.setval('contrct_contrct_id_seq', 1, false); publicadminfalse411,00coship_coship_id_seq SEQUENCE SET=SELECT pg_catalog.setval('coship_coship_id_seq', 441, true); publicadminfalse415,00cosmisc_cosmisc_id_seq SEQUENCE SET?SELECT pg_catalog.setval('cosmisc_cosmisc_id_seq', 202, true); publicadminfalse417,00cosrc_cosrc_id_seq SEQUENCE SET:SELECT pg_catalog.setval('cosrc_cosrc_id_seq', 1, false); publicadminfalse418#080104costcat TABLE DATACOPY costcat (costcat_id, costcat_code, costcat_descrip, costcat_asset_accnt_id, costcat_liability_accnt_id, costcat_adjustment_accnt_id, costcat_matusage_accnt_id, costcat_purchprice_accnt_id, costcat_laboroverhead_accnt_id, costcat_scrap_accnt_id, costcat_invcost_accnt_id, costcat_wip_accnt_id, costcat_shipasset_accnt_id, costcat_mfgscrap_accnt_id, costcat_transform_accnt_id, costcat_freight_accnt_id, costcat_toliability_accnt_id, costcat_exp_accnt_id) FROM stdin; publicadminfalse2579634aJ,00costcat_costcat_id_seq SEQUENCE SET>SELECT pg_catalog.setval('costcat_costcat_id_seq', 30, true); publicadminfalse419#080074costelem TABLE DATACOPY costelem (costelem_id, costelem_type, costelem_sys, costelem_po, costelem_active, costelem_exp_accnt_id, costelem_cost_item_id) FROM stdin; publicadminfalse2559634€J,00costelem_costelem_id_seq SEQUENCE SET@SELECT pg_catalog.setval('costelem_costelem_id_seq', 23, true); publicadminfalse420M$081130costhist TABLE DATACOPY costhist (costhist_id, costhist_item_id, costhist_costelem_id, costhist_type, costhist_date, costhist_oldcost, costhist_newcost, costhist_lowlevel, costhist_oldcurr_id, costhist_newcurr_id, costhist_username) FROM stdin; publicadminfalse4219634J,00costhist_costhist_id_seq SEQUENCE SETASELECT pg_catalog.setval('costhist_costhist_id_seq', 992, true); publicadminfalse422O$081141 costupdate TABLE DATAaCOPY costupdate (costupdate_item_id, costupdate_lowlevel_code, costupdate_item_type) FROM stdin; publicadminfalse4239634߁JP$081145country TABLE DATACOPY country (country_id, country_abbr, country_name, country_curr_abbr, country_curr_name, country_curr_number, country_curr_symbol, country_qt_number) FROM stdin; publicadminfalse4249634J ,00country_country_id_seq SEQUENCE SET?SELECT pg_catalog.setval('country_country_id_seq', 242, true); publicadminfalse425m#078252crmacct TABLE DATAuCOPY crmacct (crmacct_id, crmacct_number, crmacct_name, crmacct_active, crmacct_type, crmacct_cust_id, crmacct_competitor_id, crmacct_partner_id, crmacct_prospect_id, crmacct_vend_id, crmacct_cntct_id_1, crmacct_cntct_id_2, crmacct_parent_id, crmacct_notes, crmacct_taxauth_id, crmacct_owner_username, crmacct_emp_id, crmacct_salesrep_id, crmacct_usr_username) FROM stdin; publicadminfalse1889634J ,00crmacct_crmacct_id_seq SEQUENCE SET>SELECT pg_catalog.setval('crmacct_crmacct_id_seq', 26, true); publicadminfalse427T$081174 crmacctsel TABLE DATACOPY crmacctsel (crmacctsel_src_crmacct_id, crmacctsel_dest_crmacct_id, crmacctsel_mrg_crmacct_active, crmacctsel_mrg_crmacct_cntct_id_1, crmacctsel_mrg_crmacct_cntct_id_2, crmacctsel_mrg_crmacct_competitor_id, crmacctsel_mrg_crmacct_cust_id, crmacctsel_mrg_crmacct_emp_id, crmacctsel_mrg_crmacct_name, crmacctsel_mrg_crmacct_notes, crmacctsel_mrg_crmacct_owner_username, crmacctsel_mrg_crmacct_parent_id, crmacctsel_mrg_crmacct_partner_id, crmacctsel_mrg_crmacct_prospect_id, crmacctsel_mrg_crmacct_salesrep_id, crmacctsel_mrg_crmacct_taxauth_id, crmacctsel_mrg_crmacct_type, crmacctsel_mrg_crmacct_usr_username, crmacctsel_mrg_crmacct_vend_id, crmacctsel_mrg_crmacct_number) FROM stdin; publicadminfalse4289634VJU$081195 curr_rate TABLE DATA\COPY curr_rate (curr_rate_id, curr_id, curr_rate, curr_effective, curr_expires) FROM stdin; publicadminfalse4299634sJ ,00curr_rate_curr_rate_id_seq SEQUENCE SETASELECT pg_catalog.setval('curr_rate_curr_rate_id_seq', 1, true); publicadminfalse430p#078732 curr_symbol TABLE DATAUCOPY curr_symbol (curr_id, curr_base, curr_name, curr_symbol, curr_abbr) FROM stdin; publicadminfalse1919634J ,00curr_symbol_curr_id_seq SEQUENCE SET>SELECT pg_catalog.setval('curr_symbol_curr_id_seq', 1, true); publicadminfalse431 ,00cust_cust_id_seq SEQUENCE SET8SELECT pg_catalog.setval('cust_cust_id_seq', 96, true); publicadminfalse271,00cust_serial_seq SEQUENCE SET7SELECT pg_catalog.setval('cust_serial_seq', 1, false); publicadminfalse433Y$081210custform TABLE DATACOPY custform (custform_id, custform_custtype_id, custform_custtype, custform_invoice_report_id, custform_creditmemo_report_id, custform_quote_report_id, custform_packinglist_report_id, custform_statement_report_id, custform_sopicklist_report_id, custform_invoice_report_name, custform_creditmemo_report_name, custform_quote_report_name, custform_packinglist_report_name, custform_statement_report_name, custform_sopicklist_report_name) FROM stdin; publicadminfalse4349634J,00custform_custform_id_seq SEQUENCE SET?SELECT pg_catalog.setval('custform_custform_id_seq', 8, true); publicadminfalse435[$081219custgrp TABLE DATAECOPY custgrp (custgrp_id, custgrp_name, custgrp_descrip) FROM stdin; publicadminfalse4369634eJ,00custgrp_custgrp_id_seq SEQUENCE SET>SELECT pg_catalog.setval('custgrp_custgrp_id_seq', 24, true); publicadminfalse437]$081229 custgrpitem TABLE DATA[COPY custgrpitem (custgrpitem_id, custgrpitem_custgrp_id, custgrpitem_cust_id) FROM stdin; publicadminfalse4389634J,00custgrpitem_custgrpitem_id_seq SEQUENCE SETFSELECT pg_catalog.setval('custgrpitem_custgrpitem_id_seq', 47, true); publicadminfalse439t#078786custinfo TABLE DATACOPY custinfo (cust_id, cust_active, cust_custtype_id, cust_salesrep_id, cust_commprcnt, cust_name, cust_creditlmt, cust_creditrating, cust_financecharge, cust_backorder, cust_partialship, cust_terms_id, cust_discntprcnt, cust_balmethod, cust_ffshipto, cust_shipform_id, cust_shipvia, cust_blanketpos, cust_shipchrg_id, cust_creditstatus, cust_comments, cust_ffbillto, cust_usespos, cust_number, cust_dateadded, cust_exported, cust_emaildelivery, cust_ediemail, cust_edisubject, cust_edifilename, cust_ediemailbody, cust_autoupdatestatus, cust_autoholdorders, cust_edicc, cust_ediprofile_id, cust_preferred_warehous_id, cust_curr_id, cust_creditlmt_curr_id, cust_cntct_id, cust_corrcntct_id, cust_soemaildelivery, cust_soediemail, cust_soedisubject, cust_soedifilename, cust_soediemailbody, cust_soedicc, cust_soediprofile_id, cust_gracedays, cust_ediemailhtml, cust_soediemailhtml, cust_taxzone_id, cust_statementcycle) FROM stdin; publicadminfalse1969634J#079828custtype TABLE DATAXCOPY custtype (custtype_id, custtype_code, custtype_descrip, custtype_char) FROM stdin; publicadminfalse2369634J,00custtype_custtype_id_seq SEQUENCE SET@SELECT pg_catalog.setval('custtype_custtype_id_seq', 18, true); publicadminfalse440#079896dept TABLE DATA8COPY dept (dept_id, dept_number, dept_name) FROM stdin; publicadminfalse2419634J,00dept_dept_id_seq SEQUENCE SET7SELECT pg_catalog.setval('dept_dept_id_seq', 2, true); publicadminfalse441a$081239 destination TABLE DATA{COPY destination (destination_id, destination_name, destination_city, destination_state, destination_comments) FROM stdin; publicadminfalse4429634;J,00destination_destination_id_seq SEQUENCE SETFSELECT pg_catalog.setval('destination_destination_id_seq', 12, true); publicadminfalse443#079607docass TABLE DATACOPY docass (docass_id, docass_source_id, docass_source_type, docass_target_id, docass_target_type, docass_purpose) FROM stdin; publicadminfalse2189634XJ,00docass_docass_id_seq SEQUENCE SET;SELECT pg_catalog.setval('docass_docass_id_seq', 1, true); publicadminfalse222#079903emp TABLE DATA'COPY emp (emp_id, emp_code, emp_number, emp_active, emp_cntct_id, emp_warehous_id, emp_mgr_emp_id, emp_wage_type, emp_wage, emp_wage_curr_id, emp_wage_period, emp_dept_id, emp_shift_id, emp_notes, emp_image_id, emp_username, emp_extrate, emp_extrate_period, emp_startdate, emp_name) FROM stdin; publicadminfalse2429634uJ,00emp_emp_id_seq SEQUENCE SET5SELECT pg_catalog.setval('emp_emp_id_seq', 2, true); publicadminfalse445e$081270empgrp TABLE DATAACOPY empgrp (empgrp_id, empgrp_name, empgrp_descrip) FROM stdin; publicadminfalse4469634ؙJ,00empgrp_empgrp_id_seq SEQUENCE SET<SELECT pg_catalog.setval('empgrp_empgrp_id_seq', 1, false); publicadminfalse447g$081279 empgrpitem TABLE DATAUCOPY empgrpitem (empgrpitem_id, empgrpitem_empgrp_id, empgrpitem_emp_id) FROM stdin; publicadminfalse4489634J,00empgrpitem_empgrpitem_id_seq SEQUENCE SETDSELECT pg_catalog.setval('empgrpitem_empgrpitem_id_seq', 1, false); publicadminfalse449i$081284evntlog TABLE DATACOPY evntlog (evntlog_id, evntlog_evnttime, evntlog_evnttype_id, evntlog_ord_id, evntlog_dispatched, evntlog_action, evntlog_warehous_id, evntlog_number, evntlog_newvalue, evntlog_oldvalue, evntlog_newdate, evntlog_olddate, evntlog_ordtype, evntlog_username) FROM stdin; publicadminfalse4509634J,00evntlog_evntlog_id_seq SEQUENCE SET?SELECT pg_catalog.setval('evntlog_evntlog_id_seq', 262, true); publicadminfalse451k$081293evntnot TABLE DATAbCOPY evntnot (evntnot_id, evntnot_evnttype_id, evntnot_warehous_id, evntnot_username) FROM stdin; publicadminfalse4529634/J,00evntnot_evntnot_id_seq SEQUENCE SET?SELECT pg_catalog.setval('evntnot_evntnot_id_seq', 819, true); publicadminfalse453m$081302evnttype TABLE DATAZCOPY evnttype (evnttype_id, evnttype_name, evnttype_descrip, evnttype_module) FROM stdin; publicadminfalse4549634ܚJ,00evnttype_evnttype_id_seq SEQUENCE SET@SELECT pg_catalog.setval('evnttype_evnttype_id_seq', 45, true); publicadminfalse455#080292expcat TABLE DATACOPY expcat (expcat_id, expcat_code, expcat_descrip, expcat_exp_accnt_id, expcat_liability_accnt_id, expcat_active, expcat_purchprice_accnt_id, expcat_freight_accnt_id) FROM stdin; publicadminfalse2739634J,00expcat_expcat_id_seq SEQUENCE SET<SELECT pg_catalog.setval('expcat_expcat_id_seq', 19, true); publicadminfalse456#079616file TABLE DATAGCOPY file (file_id, file_title, file_stream, file_descrip) FROM stdin; publicadminfalse2199634VJ,00file_file_id_seq SEQUENCE SET8SELECT pg_catalog.setval('file_file_id_seq', 1, false); publicadminfalse457q$081316filter TABLE DATApCOPY filter (filter_id, filter_screen, filter_value, filter_username, filter_name, filter_selected) FROM stdin; publicadminfalse4589634sJ,00filter_filter_id_seq SEQUENCE SET<SELECT pg_catalog.setval('filter_filter_id_seq', 1, false); publicadminfalse459s$081325fincharg TABLE DATAGCOPY fincharg (fincharg_id, fincharg_mincharg, fincharg_graceperiod, fincharg_assessoverdue, fincharg_calcfrom, fincharg_markoninvoice, fincharg_air, fincharg_accnt_id, fincharg_salescat_id, fincharg_lastfc_statementcyclefrom, fincharg_lastfc_custidfrom, fincharg_lastfc_custidto, fincharg_lastfc_statementcycleto) FROM stdin; publicadminfalse4609634J,00fincharg_fincharg_id_seq SEQUENCE SET@SELECT pg_catalog.setval('fincharg_fincharg_id_seq', 1, false); publicadminfalse461w$081380flcol TABLE DATAmCOPY flcol (flcol_id, flcol_flhead_id, flcol_name, flcol_descrip, flcol_report_id, flcol_month, flcol_quarter, flcol_year, flcol_showdb, flcol_prcnt, flcol_priortype, flcol_priormonth, flcol_priorquarter, flcol_prioryear, flcol_priorprcnt, flcol_priordiff, flcol_priordiffprcnt, flcol_budget, flcol_budgetprcnt, flcol_budgetdiff, flcol_budgetdiffprcnt) FROM stdin; publicadminfalse4649634J ,00flcol_flcol_id_seq SEQUENCE SET:SELECT pg_catalog.setval('flcol_flcol_id_seq', 24, true); publicadminfalse465y$081388flgrp TABLE DATACOPY flgrp (flgrp_id, flgrp_flhead_id, flgrp_flgrp_id, flgrp_order, flgrp_name, flgrp_descrip, flgrp_subtotal, flgrp_summarize, flgrp_subtract, flgrp_showstart, flgrp_showend, flgrp_showdelta, flgrp_showbudget, flgrp_showstartprcnt, flgrp_showendprcnt, flgrp_showdeltaprcnt, flgrp_showbudgetprcnt, flgrp_prcnt_flgrp_id, flgrp_showdiff, flgrp_showdiffprcnt, flgrp_showcustom, flgrp_showcustomprcnt, flgrp_usealtsubtotal, flgrp_altsubtotal) FROM stdin; publicadminfalse4669634wJ!,00flgrp_flgrp_id_seq SEQUENCE SET;SELECT pg_catalog.setval('flgrp_flgrp_id_seq', 111, true); publicadminfalse467u$081333flhead TABLE DATACOPY flhead (flhead_id, flhead_name, flhead_descrip, flhead_showtotal, flhead_showstart, flhead_showend, flhead_showdelta, flhead_showbudget, flhead_showdiff, flhead_showcustom, flhead_custom_label, flhead_usealttotal, flhead_alttotal, flhead_usealtbegin, flhead_altbegin, flhead_usealtend, flhead_altend, flhead_usealtdebits, flhead_altdebits, flhead_usealtcredits, flhead_altcredits, flhead_usealtbudget, flhead_altbudget, flhead_usealtdiff, flhead_altdiff, flhead_type, flhead_active, flhead_sys, flhead_notes) FROM stdin; publicadminfalse4629634/J",00flhead_flhead_id_seq SEQUENCE SET<SELECT pg_catalog.setval('flhead_flhead_id_seq', 16, true); publicadminfalse468v$081358flitem TABLE DATACOPY flitem (flitem_id, flitem_flhead_id, flitem_flgrp_id, flitem_order, flitem_accnt_id, flitem_showstart, flitem_showend, flitem_showdelta, flitem_showbudget, flitem_subtract, flitem_showstartprcnt, flitem_showendprcnt, flitem_showdeltaprcnt, flitem_showbudgetprcnt, flitem_prcnt_flgrp_id, flitem_showdiff, flitem_showdiffprcnt, flitem_showcustom, flitem_showcustomprcnt, flitem_custom_source, flitem_company, flitem_profit, flitem_number, flitem_sub, flitem_type, flitem_subaccnttype_code) FROM stdin; publicadminfalse4639634J#,00flitem_flitem_id_seq SEQUENCE SET=SELECT pg_catalog.setval('flitem_flitem_id_seq', 255, true); publicadminfalse469}$081417flnotes TABLE DATA[COPY flnotes (flnotes_id, flnotes_flhead_id, flnotes_period_id, flnotes_notes) FROM stdin; publicadminfalse4709634ݥJ$,00flnotes_flnotes_id_seq SEQUENCE SET>SELECT pg_catalog.setval('flnotes_flnotes_id_seq', 1, false); publicadminfalse471$081426flrpt TABLE DATACOPY flrpt (flrpt_flhead_id, flrpt_period_id, flrpt_username, flrpt_order, flrpt_level, flrpt_type, flrpt_type_id, flrpt_beginning, flrpt_ending, flrpt_debits, flrpt_credits, flrpt_budget, flrpt_beginningprcnt, flrpt_endingprcnt, flrpt_debitsprcnt, flrpt_creditsprcnt, flrpt_budgetprcnt, flrpt_parent_id, flrpt_diff, flrpt_diffprcnt, flrpt_custom, flrpt_customprcnt, flrpt_altname, flrpt_accnt_id, flrpt_interval, flrpt_id) FROM stdin; publicadminfalse4729634J%,00flrpt_flrpt_id_seq SEQUENCE SET<SELECT pg_catalog.setval('flrpt_flrpt_id_seq', 2378, true); publicadminfalse473$081434flspec TABLE DATACOPY flspec (flspec_id, flspec_flhead_id, flspec_flgrp_id, flspec_order, flspec_name, flspec_type, flspec_showstart, flspec_showend, flspec_showdelta, flspec_showbudget, flspec_subtract, flspec_showstartprcnt, flspec_showendprcnt, flspec_showdeltaprcnt, flspec_showbudgetprcnt, flspec_showdiff, flspec_showdiffprcnt, flspec_prcnt_flgrp_id, flspec_showcustom, flspec_showcustomprcnt, flspec_custom_source) FROM stdin; publicadminfalse47496349J&,00flspec_flspec_id_seq SEQUENCE SET<SELECT pg_catalog.setval('flspec_flspec_id_seq', 1, false); publicadminfalse475$081456form TABLE DATAeCOPY form (form_id, form_name, form_descrip, form_report_id, form_key, form_report_name) FROM stdin; publicadminfalse4769634VJ',00form_form_id_seq SEQUENCE SET8SELECT pg_catalog.setval('form_form_id_seq', 22, true); publicadminfalse477#079950 freightclass TABLE DATAYCOPY freightclass (freightclass_id, freightclass_code, freightclass_descrip) FROM stdin; publicadminfalse2459634J(,00 freightclass_freightclass_id_seq SEQUENCE SETHSELECT pg_catalog.setval('freightclass_freightclass_id_seq', 1, false); publicadminfalse478$081468glseries TABLE DATACOPY glseries (glseries_id, glseries_sequence, glseries_doctype, glseries_docnumber, glseries_accnt_id, glseries_amount, glseries_source, glseries_distdate, glseries_notes, glseries_misc_id) FROM stdin; publicadminfalse4799634J),00glseries_glseries_id_seq SEQUENCE SETBSELECT pg_catalog.setval('glseries_glseries_id_seq', 1563, true); publicadminfalse480#080191gltrans TABLE DATA6COPY gltrans (gltrans_id, gltrans_exported, gltrans_created, gltrans_date, gltrans_sequence, gltrans_accnt_id, gltrans_source, gltrans_docnumber, gltrans_misc_id, gltrans_amount, gltrans_notes, gltrans_journalnumber, gltrans_posted, gltrans_doctype, gltrans_rec, gltrans_username, gltrans_deleted) FROM stdin; publicadminfalse2659634J*,00gltrans_gltrans_id_seq SEQUENCE SET@SELECT pg_catalog.setval('gltrans_gltrans_id_seq', 7008, true); publicadminfalse481+,00gltrans_sequence_seq SEQUENCE SET>SELECT pg_catalog.setval('gltrans_sequence_seq', 3583, true); publicadminfalse482$081481grp TABLE DATA5COPY grp (grp_id, grp_name, grp_descrip) FROM stdin; publicadminfalse4839634J,,00grp_grp_id_seq SEQUENCE SET5SELECT pg_catalog.setval('grp_grp_id_seq', 1, true); publicadminfalse484$081490grppriv TABLE DATAGCOPY grppriv (grppriv_id, grppriv_grp_id, grppriv_priv_id) FROM stdin; publicadminfalse4859634DJ-,00grppriv_grppriv_id_seq SEQUENCE SET?SELECT pg_catalog.setval('grppriv_grppriv_id_seq', 374, true); publicadminfalse486$081495hnfc TABLE DATA+COPY hnfc (hnfc_id, hnfc_code) FROM stdin; publicadminfalse4879634 K.,00hnfc_hnfc_id_seq SEQUENCE SET7SELECT pg_catalog.setval('hnfc_hnfc_id_seq', 5, true); publicadminfalse488#079639image TABLE DATAICOPY image (image_id, image_name, image_descrip, image_data) FROM stdin; publicadminfalse2239634AK/,00image_image_id_seq SEQUENCE SET<SELECT pg_catalog.setval('image_image_id_seq', 6632, true); publicadminfalse292#079646imageass TABLE DATArCOPY imageass (imageass_id, imageass_source_id, imageass_source, imageass_image_id, imageass_purpose) FROM stdin; publicadminfalse2249634 Kn#078696incdt TABLE DATACOPY incdt (incdt_id, incdt_number, incdt_crmacct_id, incdt_cntct_id, incdt_summary, incdt_descrip, incdt_item_id, incdt_timestamp, incdt_status, incdt_assigned_username, incdt_incdtcat_id, incdt_incdtseverity_id, incdt_incdtpriority_id, incdt_incdtresolution_id, incdt_lotserial, incdt_ls_id, incdt_aropen_id, incdt_owner_username, incdt_recurring_incdt_id, incdt_updated, incdt_prj_id, incdt_public) FROM stdin; publicadminfalse1899634 K0,00incdt_incdt_id_seq SEQUENCE SET:SELECT pg_catalog.setval('incdt_incdt_id_seq', 1, false); publicadminfalse489#079984incdtcat TABLE DATAqCOPY incdtcat (incdtcat_id, incdtcat_name, incdtcat_order, incdtcat_descrip, incdtcat_ediprofile_id) FROM stdin; publicadminfalse2489634 K1,00incdtcat_incdtcat_id_seq SEQUENCE SET?SELECT pg_catalog.setval('incdtcat_incdtcat_id_seq', 1, true); publicadminfalse490$081508 incdthist TABLE DATACOPY incdthist (incdthist_id, incdthist_incdt_id, incdthist_change, incdthist_target_id, incdthist_timestamp, incdthist_username, incdthist_descrip) FROM stdin; publicadminfalse4919634 K2,00incdthist_incdthist_id_seq SEQUENCE SETBSELECT pg_catalog.setval('incdthist_incdthist_id_seq', 1, false); publicadminfalse492#079991 incdtpriority TABLE DATArCOPY incdtpriority (incdtpriority_id, incdtpriority_name, incdtpriority_order, incdtpriority_descrip) FROM stdin; publicadminfalse2499634 K3,00"incdtpriority_incdtpriority_id_seq SEQUENCE SETISELECT pg_catalog.setval('incdtpriority_incdtpriority_id_seq', 5, true); publicadminfalse493#079998incdtresolution TABLE DATA|COPY incdtresolution (incdtresolution_id, incdtresolution_name, incdtresolution_order, incdtresolution_descrip) FROM stdin; publicadminfalse2509634j K4,00&incdtresolution_incdtresolution_id_seq SEQUENCE SETMSELECT pg_catalog.setval('incdtresolution_incdtresolution_id_seq', 4, true); publicadminfalse494#080005 incdtseverity TABLE DATArCOPY incdtseverity (incdtseverity_id, incdtseverity_name, incdtseverity_order, incdtseverity_descrip) FROM stdin; publicadminfalse2519634 K5,00"incdtseverity_incdtseverity_id_seq SEQUENCE SETISELECT pg_catalog.setval('incdtseverity_incdtseverity_id_seq', 5, true); publicadminfalse495j#077978invbal TABLE DATACOPY invbal (invbal_id, invbal_period_id, invbal_itemsite_id, invbal_qoh_beginning, invbal_qoh_ending, invbal_qty_in, invbal_qty_out, invbal_value_beginning, invbal_value_ending, invbal_value_in, invbal_value_out, invbal_nn_beginning, invbal_nn_ending, invbal_nn_in, invbal_nn_out, invbal_nnval_beginning, invbal_nnval_ending, invbal_nnval_in, invbal_nnval_out, invbal_dirty) FROM stdin; publicadminfalse1859634 K6,00invbal_invbal_id_seq SEQUENCE SET<SELECT pg_catalog.setval('invbal_invbal_id_seq', 1, false); publicadminfalse4967,00invc_invc_id_seq SEQUENCE SET8SELECT pg_catalog.setval('invc_invc_id_seq', 1, false); publicadminfalse497|#078894invchead TABLE DATACOPY invchead (invchead_id, invchead_cust_id, invchead_shipto_id, invchead_ordernumber, invchead_orderdate, invchead_posted, invchead_printed, invchead_invcnumber, invchead_invcdate, invchead_shipdate, invchead_ponumber, invchead_shipvia, invchead_fob, invchead_billto_name, invchead_billto_address1, invchead_billto_address2, invchead_billto_address3, invchead_billto_city, invchead_billto_state, invchead_billto_zipcode, invchead_billto_phone, invchead_shipto_name, invchead_shipto_address1, invchead_shipto_address2, invchead_shipto_address3, invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode, invchead_shipto_phone, invchead_salesrep_id, invchead_commission, invchead_terms_id, invchead_freight, invchead_misc_amount, invchead_misc_descrip, invchead_misc_accnt_id, invchead_payment, invchead_paymentref, invchead_notes, invchead_billto_country, invchead_shipto_country, invchead_prj_id, invchead_curr_id, invchead_gldistdate, invchead_recurring, invchead_recurring_interval, invchead_recurring_type, invchead_recurring_until, invchead_recurring_invchead_id, invchead_shipchrg_id, invchead_taxzone_id, invchead_void, invchead_saletype_id, invchead_shipzone_id) FROM stdin; publicadminfalse20596344 K8,00invchead_invchead_id_seq SEQUENCE SET?SELECT pg_catalog.setval('invchead_invchead_id_seq', 2, true); publicadminfalse498$081530 invcheadtax TABLE DATA$COPY invcheadtax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; publicadminfalse4999634Q K#078933invcitem TABLE DATACOPY invcitem (invcitem_id, invcitem_invchead_id, invcitem_linenumber, invcitem_item_id, invcitem_warehous_id, invcitem_custpn, invcitem_number, invcitem_descrip, invcitem_ordered, invcitem_billed, invcitem_custprice, invcitem_price, invcitem_notes, invcitem_salescat_id, invcitem_taxtype_id, invcitem_qty_uom_id, invcitem_qty_invuomratio, invcitem_price_uom_id, invcitem_price_invuomratio, invcitem_coitem_id, invcitem_updateinv, invcitem_rev_accnt_id) FROM stdin; publicadminfalse2099634n K9,00invcitem_invcitem_id_seq SEQUENCE SET@SELECT pg_catalog.setval('invcitem_invcitem_id_seq', 1, false); publicadminfalse500$081538 invcitemtax TABLE DATA$COPY invcitemtax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; publicadminfalse5019634 K`#077574invcnt TABLE DATAHCOPY invcnt (invcnt_id, invcnt_itemsite_id, invcnt_tagdate, invcnt_cntdate, invcnt_qoh_before, invcnt_qoh_after, invcnt_matcost, invcnt_posted, invcnt_postdate, invcnt_comments, invcnt_priority, invcnt_tagnumber, invcnt_invhist_id, invcnt_location_id, invcnt_cnt_username, invcnt_post_username, invcnt_tag_username) FROM stdin; publicadminfalse1739634 K:,00invcnt_invcnt_id_seq SEQUENCE SET=SELECT pg_catalog.setval('invcnt_invcnt_id_seq', 213, true); publicadminfalse502$081546 invdetail TABLE DATA COPY invdetail (invdetail_id, invdetail_transtype, invdetail_invhist_id, invdetail_location_id, invdetail_qty, invdetail_comments, invdetail_qty_before, invdetail_qty_after, invdetail_invcitem_id, invdetail_expiration, invdetail_warrpurc, invdetail_ls_id) FROM stdin; publicadminfalse5039634 K;,00invdetail_invdetail_id_seq SEQUENCE SETDSELECT pg_catalog.setval('invdetail_invdetail_id_seq', 1326, true); publicadminfalse504$081555invhist TABLE DATACOPY invhist (invhist_id, invhist_itemsite_id, invhist_transdate, invhist_transtype, invhist_invqty, invhist_invuom, invhist_ordnumber, invhist_docnumber, invhist_qoh_before, invhist_qoh_after, invhist_unitcost, invhist_acct_id, invhist_xfer_warehous_id, invhist_comments, invhist_posted, invhist_imported, invhist_hasdetail, invhist_ordtype, invhist_analyze, invhist_user, invhist_created, invhist_costmethod, invhist_value_before, invhist_value_after, invhist_series) FROM stdin; publicadminfalse5059634 K<,00invhist_invhist_id_seq SEQUENCE SET@SELECT pg_catalog.setval('invhist_invhist_id_seq', 2859, true); publicadminfalse506$081570 invhistexpcat TABLE DATAeCOPY invhistexpcat (invhistexpcat_id, invhistexpcat_invhist_id, invhistexpcat_expcat_id) FROM stdin; publicadminfalse5079634 K=,00"invhistexpcat_invhistexpcat_id_seq SEQUENCE SETJSELECT pg_catalog.setval('invhistexpcat_invhistexpcat_id_seq', 1, false); publicadminfalse508#080232ipsass TABLE DATACOPY ipsass (ipsass_id, ipsass_ipshead_id, ipsass_cust_id, ipsass_custtype_id, ipsass_custtype_pattern, ipsass_shipto_id, ipsass_shipto_pattern) FROM stdin; publicadminfalse2689634 K>,00ipsass_ipsass_id_seq SEQUENCE SET<SELECT pg_catalog.setval('ipsass_ipsass_id_seq', 1, false); publicadminfalse509?,00ipsctyp_ipsctyp_id_seq SEQUENCE SET>SELECT pg_catalog.setval('ipsctyp_ipsctyp_id_seq', 16, true); publicadminfalse510@,00ipscust_ipscust_id_seq SEQUENCE SET>SELECT pg_catalog.setval('ipscust_ipscust_id_seq', 21, true); publicadminfalse511#079957 ipsfreight TABLE DATACOPY ipsfreight (ipsfreight_id, ipsfreight_ipshead_id, ipsfreight_qtybreak, ipsfreight_price, ipsfreight_type, ipsfreight_warehous_id, ipsfreight_shipzone_id, ipsfreight_freightclass_id, ipsfreight_shipvia) FROM stdin; publicadminfalse24696349 KA,00ipsfreight_ipsfreight_id_seq SEQUENCE SETDSELECT pg_catalog.setval('ipsfreight_ipsfreight_id_seq', 1, false); publicadminfalse512#079965ipshead TABLE DATACOPY ipshead (ipshead_id, ipshead_name, ipshead_descrip, ipshead_effective, ipshead_expires, ipshead_curr_id, ipshead_updated) FROM stdin; publicadminfalse2479634V KB,00ipshead_ipshead_id_seq SEQUENCE SET>SELECT pg_catalog.setval('ipshead_ipshead_id_seq', 58, true); publicadminfalse513C,00ipsitem_ipsitem_id_seq SEQUENCE SET>SELECT pg_catalog.setval('ipsitem_ipsitem_id_seq', 75, true); publicadminfalse514#080256 ipsitemchar TABLE DATACOPY ipsitemchar (ipsitemchar_id, ipsitemchar_ipsitem_id, ipsitemchar_char_id, ipsitemchar_value, ipsitemchar_price) FROM stdin; publicadminfalse2709634s KD,00ipsitemchar_ipsitemchar_id_seq SEQUENCE SETFSELECT pg_catalog.setval('ipsitemchar_ipsitemchar_id_seq', 1, false); publicadminfalse515#080244 ipsiteminfo TABLE DATACOPY ipsiteminfo (ipsitem_id, ipsitem_ipshead_id, ipsitem_item_id, ipsitem_qtybreak, ipsitem_price, ipsitem_qty_uom_id, ipsitem_price_uom_id, ipsitem_discntprcnt, ipsitem_fixedamtdiscount, ipsitem_prodcat_id, ipsitem_type, ipsitem_warehous_id) FROM stdin; publicadminfalse2699634 K$081599ipsprodcat_bak TABLE DATACOPY ipsprodcat_bak (ipsprodcat_id, ipsprodcat_ipshead_id, ipsprodcat_prodcat_id, ipsprodcat_qtybreak, ipsprodcat_discntprcnt, ipsprodcat_fixedamtdiscount) FROM stdin; publicadminfalse5169634 KE,00ipsprodcat_ipsprodcat_id_seq SEQUENCE SETDSELECT pg_catalog.setval('ipsprodcat_ipsprodcat_id_seq', 1, false); publicadminfalse517a#077581item TABLE DATACOPY item (item_id, item_number, item_descrip1, item_descrip2, item_classcode_id, item_picklist, item_comments, item_sold, item_fractional, item_active, item_type, item_prodweight, item_packweight, item_prodcat_id, item_exclusive, item_listprice, item_config, item_extdescrip, item_upccode, item_maxcost, item_inv_uom_id, item_price_uom_id, item_warrdays, item_freightclass_id, item_tax_recoverable, item_listcost) FROM stdin; publicadminfalse1749634 KF,00item_item_id_seq SEQUENCE SET9SELECT pg_catalog.setval('item_item_id_seq', 300, true); publicadminfalse518#080054 itemalias TABLE DATACOPY itemalias (itemalias_id, itemalias_item_id, itemalias_number, itemalias_comments, itemalias_usedescrip, itemalias_descrip1, itemalias_descrip2, itemalias_crmacct_id) FROM stdin; publicadminfalse2549634 KG,00itemalias_itemalias_id_seq SEQUENCE SETBSELECT pg_catalog.setval('itemalias_itemalias_id_seq', 15, true); publicadminfalse519H,00itematr_itematr_id_seq SEQUENCE SET>SELECT pg_catalog.setval('itematr_itematr_id_seq', 29, true); publicadminfalse520#080082itemcost TABLE DATACOPY itemcost (itemcost_id, itemcost_item_id, itemcost_costelem_id, itemcost_lowlevel, itemcost_stdcost, itemcost_posted, itemcost_actcost, itemcost_updated, itemcost_curr_id) FROM stdin; publicadminfalse2569634KI,00itemcost_itemcost_id_seq SEQUENCE SETASELECT pg_catalog.setval('itemcost_itemcost_id_seq', 299, true); publicadminfalse521J,00itemfrez_itemfrez_seq SEQUENCE SET=SELECT pg_catalog.setval('itemfrez_itemfrez_seq', 1, false); publicadminfalse522$081615itemgrp TABLE DATAVCOPY itemgrp (itemgrp_id, itemgrp_name, itemgrp_descrip, itemgrp_catalog) FROM stdin; publicadminfalse5239634!KK,00itemgrp_itemgrp_id_seq SEQUENCE SET>SELECT pg_catalog.setval('itemgrp_itemgrp_id_seq', 19, true); publicadminfalse524$081626 itemgrpitem TABLE DATArCOPY itemgrpitem (itemgrpitem_id, itemgrpitem_itemgrp_id, itemgrpitem_item_id, itemgrpitem_item_type) FROM stdin; publicadminfalse5259634>KL,00itemgrpitem_itemgrpitem_id_seq SEQUENCE SETGSELECT pg_catalog.setval('itemgrpitem_itemgrpitem_id_seq', 112, true); publicadminfalse526M,00itemimage_itemimage_id_seq SEQUENCE SETBSELECT pg_catalog.setval('itemimage_itemimage_id_seq', 20, true); publicadminfalse528$081640itemloc TABLE DATACOPY itemloc (itemloc_id, itemloc_itemsite_id, itemloc_location_id, itemloc_qty, itemloc_expiration, itemloc_consolflag, itemloc_ls_id, itemloc_warrpurc) FROM stdin; publicadminfalse5299634[KN,00itemloc_itemloc_id_seq SEQUENCE SET?SELECT pg_catalog.setval('itemloc_itemloc_id_seq', 511, true); publicadminfalse530O,00itemloc_series_seq SEQUENCE SET<SELECT pg_catalog.setval('itemloc_series_seq', 1022, true); publicadminfalse531$081648 itemlocdist TABLE DATACOPY itemlocdist (itemlocdist_id, itemlocdist_itemlocdist_id, itemlocdist_source_type, itemlocdist_source_id, itemlocdist_qty, itemlocdist_series, itemlocdist_invhist_id, itemlocdist_itemsite_id, itemlocdist_reqlotserial, itemlocdist_flush, itemlocdist_expiration, itemlocdist_distlotserial, itemlocdist_warranty, itemlocdist_ls_id, itemlocdist_order_type, itemlocdist_order_id) FROM stdin; publicadminfalse5329634xKP,00itemlocdist_itemlocdist_id_seq SEQUENCE SETHSELECT pg_catalog.setval('itemlocdist_itemlocdist_id_seq', 2133, true); publicadminfalse533$081659 itemlocpost TABLE DATA\COPY itemlocpost (itemlocpost_id, itemlocpost_itemlocseries, itemlocpost_glseq) FROM stdin; publicadminfalse5349634KQ,00itemlocpost_itemlocpost_id_seq SEQUENCE SETFSELECT pg_catalog.setval('itemlocpost_itemlocpost_id_seq', 1, false); publicadminfalse535R,00itemopn_itemopn_id_seq SEQUENCE SET>SELECT pg_catalog.setval('itemopn_itemopn_id_seq', 39, true); publicadminfalse536b#077601itemsite TABLE DATACOPY itemsite (itemsite_id, itemsite_item_id, itemsite_warehous_id, itemsite_qtyonhand, itemsite_reorderlevel, itemsite_ordertoqty, itemsite_cyclecountfreq, itemsite_datelastcount, itemsite_datelastused, itemsite_loccntrl, itemsite_safetystock, itemsite_minordqty, itemsite_multordqty, itemsite_leadtime, itemsite_abcclass, itemsite_issuemethod, itemsite_controlmethod, itemsite_active, itemsite_plancode_id, itemsite_costcat_id, itemsite_eventfence, itemsite_sold, itemsite_stocked, itemsite_freeze, itemsite_location_id, itemsite_useparams, itemsite_useparamsmanual, itemsite_soldranking, itemsite_createpr, itemsite_location, itemsite_location_comments, itemsite_notes, itemsite_perishable, itemsite_autoabcclass, itemsite_ordergroup, itemsite_disallowblankwip, itemsite_maxordqty, itemsite_mps_timefence, itemsite_createwo, itemsite_warrpurc, itemsite_autoreg, itemsite_costmethod, itemsite_value, itemsite_ordergroup_first, itemsite_supply_itemsite_id, itemsite_planning_type, itemsite_wosupply, itemsite_posupply, itemsite_lsseq_id, itemsite_cosdefault, itemsite_createsopr, itemsite_createsopo, itemsite_dropship, itemsite_recvlocation_id, itemsite_issuelocation_id, itemsite_location_dist, itemsite_recvlocation_dist, itemsite_issuelocation_dist) FROM stdin; publicadminfalse1759634KS,00itemsite_itemsite_id_seq SEQUENCE SETASELECT pg_catalog.setval('itemsite_itemsite_id_seq', 292, true); publicadminfalse537#080136itemsrc TABLE DATACOPY itemsrc (itemsrc_id, itemsrc_item_id, itemsrc_vend_id, itemsrc_vend_item_number, itemsrc_vend_item_descrip, itemsrc_comments, itemsrc_vend_uom, itemsrc_invvendoruomratio, itemsrc_minordqty, itemsrc_multordqty, itemsrc_leadtime, itemsrc_ranking, itemsrc_active, itemsrc_manuf_name, itemsrc_manuf_item_number, itemsrc_manuf_item_descrip, itemsrc_default, itemsrc_upccode, itemsrc_effective, itemsrc_expires, itemsrc_contrct_id, itemsrc_contrct_max, itemsrc_contrct_min) FROM stdin; publicadminfalse2609634KT,00itemsrc_itemsrc_id_seq SEQUENCE SET>SELECT pg_catalog.setval('itemsrc_itemsrc_id_seq', 83, true); publicadminfalse538#080154itemsrcp TABLE DATACOPY itemsrcp (itemsrcp_id, itemsrcp_itemsrc_id, itemsrcp_qtybreak, itemsrcp_price, itemsrcp_updated, itemsrcp_curr_id, itemsrcp_dropship, itemsrcp_warehous_id, itemsrcp_type, itemsrcp_discntprcnt, itemsrcp_fixedamtdiscount) FROM stdin; publicadminfalse2619634KU,00itemsrcp_itemsrcp_id_seq SEQUENCE SET@SELECT pg_catalog.setval('itemsrcp_itemsrcp_id_seq', 84, true); publicadminfalse539#080167itemsub TABLE DATAsCOPY itemsub (itemsub_id, itemsub_parent_item_id, itemsub_sub_item_id, itemsub_uomratio, itemsub_rank) FROM stdin; publicadminfalse2629634 KV,00itemsub_itemsub_id_seq SEQUENCE SET>SELECT pg_catalog.setval('itemsub_itemsub_id_seq', 16, true); publicadminfalse540#080175itemtax TABLE DATA_COPY itemtax (itemtax_id, itemtax_item_id, itemtax_taxtype_id, itemtax_taxzone_id) FROM stdin; publicadminfalse2639634&KW,00itemtax_itemtax_id_seq SEQUENCE SET>SELECT pg_catalog.setval('itemtax_itemtax_id_seq', 1, false); publicadminfalse541$081676 itemtrans TABLE DATA^COPY itemtrans (itemtrans_id, itemtrans_source_item_id, itemtrans_target_item_id) FROM stdin; publicadminfalse5429634CKX,00itemtrans_itemtrans_id_seq SEQUENCE SETBSELECT pg_catalog.setval('itemtrans_itemtrans_id_seq', 1, false); publicadminfalse543$081681itemuom TABLE DATARCOPY itemuom (itemuom_id, itemuom_itemuomconv_id, itemuom_uomtype_id) FROM stdin; publicadminfalse5449634`KY,00itemuom_itemuom_id_seq SEQUENCE SET>SELECT pg_catalog.setval('itemuom_itemuom_id_seq', 1, false); publicadminfalse545#080182 itemuomconv TABLE DATACOPY itemuomconv (itemuomconv_id, itemuomconv_item_id, itemuomconv_from_uom_id, itemuomconv_from_value, itemuomconv_to_uom_id, itemuomconv_to_value, itemuomconv_fractional, itemuomconv_active) FROM stdin; publicadminfalse2649634}KZ,00itemuomconv_itemuomconv_id_seq SEQUENCE SETFSELECT pg_catalog.setval('itemuomconv_itemuomconv_id_seq', 1, false); publicadminfalse546[,00journal_number_seq SEQUENCE SET<SELECT pg_catalog.setval('journal_number_seq', 2274, true); publicadminfalse547$081690jrnluse TABLE DATAQCOPY jrnluse (jrnluse_id, jrnluse_date, jrnluse_number, jrnluse_use) FROM stdin; publicadminfalse5489634K\,00jrnluse_jrnluse_id_seq SEQUENCE SET?SELECT pg_catalog.setval('jrnluse_jrnluse_id_seq', 280, true); publicadminfalse549$081699labeldef TABLE DATACOPY labeldef (labeldef_id, labeldef_name, labeldef_papersize, labeldef_columns, labeldef_rows, labeldef_width, labeldef_height, labeldef_start_offset_x, labeldef_start_offset_y, labeldef_horizontal_gap, labeldef_vertical_gap) FROM stdin; publicadminfalse5509634K],00labeldef_labeldef_id_seq SEQUENCE SET?SELECT pg_catalog.setval('labeldef_labeldef_id_seq', 4, true); publicadminfalse551$081707 labelform TABLE DATAyCOPY labelform (labelform_id, labelform_name, labelform_report_id, labelform_perpage, labelform_report_name) FROM stdin; publicadminfalse5529634@K^,00labelform_labelform_id_seq SEQUENCE SETASELECT pg_catalog.setval('labelform_labelform_id_seq', 6, true); publicadminfalse553$081717lang TABLE DATASCOPY lang (lang_id, lang_qt_number, lang_abbr3, lang_abbr2, lang_name) FROM stdin; publicadminfalse5549634]K_,00lang_lang_id_seq SEQUENCE SET9SELECT pg_catalog.setval('lang_lang_id_seq', 499, true); publicadminfalse555$081725locale TABLE DATACOPY locale (locale_id, locale_code, locale_descrip, locale_lang_file, locale_dateformat, locale_currformat, locale_qtyformat, locale_comments, locale_qtyperformat, locale_salespriceformat, locale_extpriceformat, locale_timeformat, locale_timestampformat, local_costformat, locale_costformat, locale_purchpriceformat, locale_uomratioformat, locale_intervalformat, locale_lang_id, locale_country_id, locale_error_color, locale_warning_color, locale_emphasis_color, locale_altemphasis_color, locale_expired_color, locale_future_color, locale_curr_scale, locale_salesprice_scale, locale_purchprice_scale, locale_extprice_scale, locale_cost_scale, locale_qty_scale, locale_qtyper_scale, locale_uomratio_scale, locale_percent_scale, locale_weight_scale) FROM stdin; publicadminfalse5569634x)K`,00locale_locale_id_seq SEQUENCE SET<SELECT pg_catalog.setval('locale_locale_id_seq', 29, true); publicadminfalse557#080206location TABLE DATACOPY location (location_id, location_warehous_id, location_name, location_descrip, location_restrict, location_netable, location_whsezone_id, location_aisle, location_rack, location_bin, location_formatname, location_usable) FROM stdin; publicadminfalse2669634*Ka,00location_location_id_seq SEQUENCE SETASELECT pg_catalog.setval('location_location_id_seq', 121, true); publicadminfalse558$081739locitem TABLE DATALCOPY locitem (locitem_id, locitem_location_id, locitem_item_id) FROM stdin; publicadminfalse5599634*Kb,00locitem_locitem_id_seq SEQUENCE SET>SELECT pg_catalog.setval('locitem_locitem_id_seq', 21, true); publicadminfalse560c,00log_log_id_seq SEQUENCE SET7SELECT pg_catalog.setval('log_log_id_seq', 747, true); publicadminfalse561#080559metasql TABLE DATACOPY metasql (metasql_id, metasql_group, metasql_name, metasql_notes, metasql_query, metasql_lastuser, metasql_lastupdate, metasql_grade) FROM stdin; publicadminfalse2949634*Kd,00metasql_metasql_id_seq SEQUENCE SET?SELECT pg_catalog.setval('metasql_metasql_id_seq', 494, true); publicadminfalse295$081747metric TABLE DATANCOPY metric (metric_id, metric_name, metric_value, metric_module) FROM stdin; publicadminfalse5629634Me,00metric_metric_id_seq SEQUENCE SET=SELECT pg_catalog.setval('metric_metric_id_seq', 301, true); publicadminfalse563$081757 metricenc TABLE DATA]COPY metricenc (metricenc_id, metricenc_name, metricenc_value, metricenc_module) FROM stdin; publicadminfalse5649634Y#Mf,00metricenc_metricenc_id_seq SEQUENCE SETBSELECT pg_catalog.setval('metricenc_metricenc_id_seq', 1, false); publicadminfalse565g,00misc_index_seq SEQUENCE SET8SELECT pg_catalog.setval('misc_index_seq', 1166, true); publicadminfalse566$081768mrghist TABLE DATAqCOPY mrghist (mrghist_cntct_id, mrghist_table, mrghist_pkey_col, mrghist_pkey_id, mrghist_cntct_col) FROM stdin; publicadminfalse5679634v#M$081774mrgundo TABLE DATACOPY mrgundo (mrgundo_base_schema, mrgundo_base_table, mrgundo_base_id, mrgundo_schema, mrgundo_table, mrgundo_pkey_col, mrgundo_pkey_id, mrgundo_col, mrgundo_value, mrgundo_type) FROM stdin; publicadminfalse5689634#M$081780msg TABLE DATA^COPY msg (msg_id, msg_posted, msg_scheduled, msg_text, msg_expires, msg_username) FROM stdin; publicadminfalse5699634#Mh,00msg_msg_id_seq SEQUENCE SET6SELECT pg_catalog.setval('msg_msg_id_seq', 16, true); publicadminfalse570$081789msguser TABLE DATAXCOPY msguser (msguser_id, msguser_msg_id, msguser_viewed, msguser_username) FROM stdin; publicadminfalse5719634#Mi,00msguser_msguser_id_seq SEQUENCE SET>SELECT pg_catalog.setval('msguser_msguser_id_seq', 12, true); publicadminfalse572j,00nvend_nvend_id_seq SEQUENCE SET:SELECT pg_catalog.setval('nvend_nvend_id_seq', 1, false); publicadminfalse573$081800 obsolete_tax TABLE DATACOPY obsolete_tax (tax_id, tax_code, tax_descrip, tax_ratea, tax_sales_accnt_id, tax_freight, tax_cumulative, tax_rateb, tax_salesb_accnt_id, tax_ratec, tax_salesc_accnt_id) FROM stdin; publicadminfalse5749634#M#079060ophead TABLE DATACOPY ophead (ophead_id, ophead_name, ophead_crmacct_id, ophead_owner_username, ophead_opstage_id, ophead_opsource_id, ophead_optype_id, ophead_probability_prcnt, ophead_amount, ophead_target_date, ophead_actual_date, ophead_notes, ophead_curr_id, ophead_active, ophead_cntct_id, ophead_username, ophead_start_date, ophead_assigned_date, ophead_priority_id, ophead_number) FROM stdin; publicadminfalse2109634+$Mk,00ophead_ophead_id_seq SEQUENCE SET;SELECT pg_catalog.setval('ophead_ophead_id_seq', 1, true); publicadminfalse575$081811opsource TABLE DATAICOPY opsource (opsource_id, opsource_name, opsource_descrip) FROM stdin; publicadminfalse5769634H$Ml,00opsource_opsource_id_seq SEQUENCE SET@SELECT pg_catalog.setval('opsource_opsource_id_seq', 1, false); publicadminfalse577$081820opstage TABLE DATAhCOPY opstage (opstage_id, opstage_name, opstage_descrip, opstage_order, opstage_opinactive) FROM stdin; publicadminfalse5789634e$Mm,00opstage_opstage_id_seq SEQUENCE SET>SELECT pg_catalog.setval('opstage_opstage_id_seq', 1, false); publicadminfalse579$081831optype TABLE DATAACOPY optype (optype_id, optype_name, optype_descrip) FROM stdin; publicadminfalse5809634$Mn,00optype_optype_id_seq SEQUENCE SET<SELECT pg_catalog.setval('optype_optype_id_seq', 1, false); publicadminfalse581$081850orderseq TABLE DATAzCOPY orderseq (orderseq_id, orderseq_name, orderseq_number, orderseq_table, orderseq_numcol, orderseq_seqiss) FROM stdin; publicadminfalse5829634$Mo,00orderseq_orderseq_id_seq SEQUENCE SET@SELECT pg_catalog.setval('orderseq_orderseq_id_seq', 23, true); publicadminfalse583$081860pack TABLE DATA^COPY pack (pack_id, pack_head_id, pack_head_type, pack_shiphead_id, pack_printed) FROM stdin; publicadminfalse5849634&Mp,00pack_pack_id_seq SEQUENCE SET7SELECT pg_catalog.setval('pack_pack_id_seq', 1, true); publicadminfalse585$081870 payaropen TABLE DATAjCOPY payaropen (payaropen_ccpay_id, payaropen_aropen_id, payaropen_amount, payaropen_curr_id) FROM stdin; publicadminfalse5869634;&M$081875payco TABLE DATA`COPY payco (payco_ccpay_id, payco_cohead_id, payco_amount, payco_curr_id, payco_id) FROM stdin; publicadminfalse5879634X&Mq,00payco_payco_id_seq SEQUENCE SET:SELECT pg_catalog.setval('payco_payco_id_seq', 1, false); publicadminfalse787#079725period TABLE DATACOPY period (period_id, period_start, period_end, period_closed, period_freeze, period_initial, period_name, period_yearperiod_id, period_quarter, period_number) FROM stdin; publicadminfalse2309634u&Mr,00period_period_id_seq SEQUENCE SET=SELECT pg_catalog.setval('period_period_id_seq', 147, true); publicadminfalse588$081882pkgdep TABLE DATAQCOPY pkgdep (pkgdep_id, pkgdep_pkghead_id, pkgdep_parent_pkghead_id) FROM stdin; publicadminfalse58996344+Ms,00pkgdep_pkgdep_id_seq SEQUENCE SET;SELECT pg_catalog.setval('pkgdep_pkgdep_id_seq', 1, true); publicadminfalse590$081887pkghead TABLE DATACOPY pkghead (pkghead_id, pkghead_name, pkghead_descrip, pkghead_version, pkghead_developer, pkghead_notes, pkghead_created, pkghead_updated, pkghead_indev) FROM stdin; publicadminfalse5919634Q+Mt,00pkghead_pkghead_id_seq SEQUENCE SET=SELECT pg_catalog.setval('pkghead_pkghead_id_seq', 7, true); publicadminfalse592$081897pkgitem TABLE DATAxCOPY pkgitem (pkgitem_id, pkgitem_pkghead_id, pkgitem_type, pkgitem_item_id, pkgitem_name, pkgitem_descrip) FROM stdin; publicadminfalse5939634-Mu,00pkgitem_pkgitem_id_seq SEQUENCE SET>SELECT pg_catalog.setval('pkgitem_pkgitem_id_seq', 1, false); publicadminfalse594#080112plancode TABLE DATACOPY plancode (plancode_id, plancode_code, plancode_name, plancode_mpsexplosion, plancode_consumefcst, plancode_mrpexcp_resched, plancode_mrpexcp_delete) FROM stdin; publicadminfalse2589634-Mv,00plancode_plancode_id_seq SEQUENCE SET@SELECT pg_catalog.setval('plancode_plancode_id_seq', 26, true); publicadminfalse595w,00planord_planord_id_seq SEQUENCE SET@SELECT pg_catalog.setval('planord_planord_id_seq', 1022, true); publicadminfalse596f#077694pohead TABLE DATACOPY pohead (pohead_id, pohead_status, pohead_number, pohead_orderdate, pohead_vend_id, pohead_fob, pohead_shipvia, pohead_comments, pohead_freight, pohead_printed, pohead_terms_id, pohead_warehous_id, pohead_vendaddr_id, pohead_agent_username, pohead_curr_id, pohead_saved, pohead_taxzone_id, pohead_taxtype_id, pohead_dropship, pohead_vend_cntct_id, pohead_vend_cntct_honorific, pohead_vend_cntct_first_name, pohead_vend_cntct_middle, pohead_vend_cntct_last_name, pohead_vend_cntct_suffix, pohead_vend_cntct_phone, pohead_vend_cntct_title, pohead_vend_cntct_fax, pohead_vend_cntct_email, pohead_vendaddress1, pohead_vendaddress2, pohead_vendaddress3, pohead_vendcity, pohead_vendstate, pohead_vendzipcode, pohead_vendcountry, pohead_shipto_cntct_id, pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name, pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name, pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone, pohead_shipto_cntct_title, pohead_shipto_cntct_fax, pohead_shipto_cntct_email, pohead_shiptoaddress_id, pohead_shiptoaddress1, pohead_shiptoaddress2, pohead_shiptoaddress3, pohead_shiptocity, pohead_shiptostate, pohead_shiptozipcode, pohead_shiptocountry, pohead_cohead_id, pohead_released, pohead_shiptoname) FROM stdin; publicadminfalse1809634[.Mx,00pohead_pohead_id_seq SEQUENCE SET=SELECT pg_catalog.setval('pohead_pohead_id_seq', 344, true); publicadminfalse597g#077708poitem TABLE DATACOPY poitem (poitem_id, poitem_status, poitem_pohead_id, poitem_linenumber, poitem_duedate, poitem_itemsite_id, poitem_vend_item_descrip, poitem_vend_uom, poitem_invvenduomratio, poitem_qty_ordered, poitem_qty_received, poitem_qty_returned, poitem_qty_vouchered, poitem_unitprice, poitem_vend_item_number, poitem_comments, poitem_qty_toreceive, poitem_expcat_id, poitem_itemsrc_id, poitem_freight, poitem_freight_received, poitem_freight_vouchered, poitem_prj_id, poitem_stdcost, poitem_bom_rev_id, poitem_boo_rev_id, poitem_manuf_name, poitem_manuf_item_number, poitem_manuf_item_descrip, poitem_taxtype_id, poitem_tax_recoverable, poitem_rlsd_duedate, poitem_order_id, poitem_order_type) FROM stdin; publicadminfalse1819634x.My,00poitem_poitem_id_seq SEQUENCE SET=SELECT pg_catalog.setval('poitem_poitem_id_seq', 426, true); publicadminfalse598z,00porecv_porecv_id_seq SEQUENCE SET=SELECT pg_catalog.setval('porecv_porecv_id_seq', 127, true); publicadminfalse601$081931poreject TABLE DATACOPY poreject (poreject_id, poreject_date, poreject_ponumber, poreject_itemsite_id, poreject_vend_id, poreject_vend_item_number, poreject_vend_item_descrip, poreject_vend_uom, poreject_qty, poreject_posted, poreject_rjctcode_id, poreject_poitem_id, poreject_invoiced, poreject_vohead_id, poreject_agent_username, poreject_voitem_id, poreject_value, poreject_trans_username, poreject_recv_id) FROM stdin; publicadminfalse6029634.M{,00poreject_poreject_id_seq SEQUENCE SET@SELECT pg_catalog.setval('poreject_poreject_id_seq', 41, true); publicadminfalse603%081940pr TABLE DATACOPY pr (pr_id, pr_number, pr_subnumber, pr_status, pr_order_type, pr_order_id, pr_poitem_id, pr_duedate, pr_itemsite_id, pr_qtyreq, pr_prj_id, pr_releasenote, pr_createdate) FROM stdin; publicadminfalse6049634.M|,00 pr_pr_id_seq SEQUENCE SET5SELECT pg_catalog.setval('pr_pr_id_seq', 185, true); publicadminfalse605%081950prftcntr TABLE DATAKCOPY prftcntr (prftcntr_id, prftcntr_number, prftcntr_descrip) FROM stdin; publicadminfalse6069634.M},00prftcntr_prftcntr_id_seq SEQUENCE SET?SELECT pg_catalog.setval('prftcntr_prftcntr_id_seq', 1, true); publicadminfalse607#080576priv TABLE DATAPCOPY priv (priv_id, priv_module, priv_name, priv_descrip, priv_seq) FROM stdin; publicadminfalse2979634.M~,00priv_priv_id_seq SEQUENCE SET9SELECT pg_catalog.setval('priv_priv_id_seq', 649, true); publicadminfalse298}#078904prj TABLE DATACOPY prj (prj_id, prj_number, prj_name, prj_descrip, prj_status, prj_so, prj_wo, prj_po, prj_owner_username, prj_start_date, prj_due_date, prj_assigned_date, prj_completed_date, prj_username, prj_recurring_prj_id, prj_crmacct_id, prj_cntct_id, prj_prjtype_id) FROM stdin; publicadminfalse2069634wIM,00prj_prj_id_seq SEQUENCE SET5SELECT pg_catalog.setval('prj_prj_id_seq', 1, true); publicadminfalse610#079205prjtask TABLE DATAYCOPY prjtask (prjtask_id, prjtask_number, prjtask_name, prjtask_descrip, prjtask_prj_id, prjtask_anyuser, prjtask_status, prjtask_hours_budget, prjtask_hours_actual, prjtask_exp_budget, prjtask_exp_actual, prjtask_owner_username, prjtask_start_date, prjtask_due_date, prjtask_assigned_date, prjtask_completed_date, prjtask_username) FROM stdin; publicadminfalse2119634IM,00prjtask_prjtask_id_seq SEQUENCE SET>SELECT pg_catalog.setval('prjtask_prjtask_id_seq', 1, false); publicadminfalse611 %081981 prjtaskuser TABLE DATA\COPY prjtaskuser (prjtaskuser_id, prjtaskuser_prjtask_id, prjtaskuser_username) FROM stdin; publicadminfalse6129634IM,00prjtaskuser_prjtaskuser_id_seq SEQUENCE SETFSELECT pg_catalog.setval('prjtaskuser_prjtaskuser_id_seq', 1, false); publicadminfalse613 %081989prjtype TABLE DATASCOPY prjtype (prjtype_id, prjtype_code, prjtype_descr, prjtype_active) FROM stdin; publicadminfalse6149634IM,00prjtype_prjtype_id_seq SEQUENCE SET>SELECT pg_catalog.setval('prjtype_prjtype_id_seq', 1, false); publicadminfalse615#080041prodcat TABLE DATAECOPY prodcat (prodcat_id, prodcat_code, prodcat_descrip) FROM stdin; publicadminfalse2539634JM,00prodcat_prodcat_id_seq SEQUENCE SET>SELECT pg_catalog.setval('prodcat_prodcat_id_seq', 30, true); publicadminfalse616#080277prospect TABLE DATACOPY prospect (prospect_id, prospect_active, prospect_number, prospect_name, prospect_cntct_id, prospect_comments, prospect_created, prospect_salesrep_id, prospect_warehous_id, prospect_taxzone_id) FROM stdin; publicadminfalse27296344JM%082000qryhead TABLE DATAwCOPY qryhead (qryhead_id, qryhead_name, qryhead_descrip, qryhead_notes, qryhead_username, qryhead_updated) FROM stdin; publicadminfalse6179634QJM,00qryhead_qryhead_id_seq SEQUENCE SET>SELECT pg_catalog.setval('qryhead_qryhead_id_seq', 1, false); publicadminfalse618%082011qryitem TABLE DATACOPY qryitem (qryitem_id, qryitem_qryhead_id, qryitem_name, qryitem_order, qryitem_src, qryitem_group, qryitem_detail, qryitem_notes, qryitem_username, qryitem_updated) FROM stdin; publicadminfalse6199634nJM,00qryitem_qryitem_id_seq SEQUENCE SET>SELECT pg_catalog.setval('qryitem_qryitem_id_seq', 1, false); publicadminfalse620#080350quhead TABLE DATACOPY quhead (quhead_id, quhead_number, quhead_cust_id, quhead_quotedate, quhead_shipto_id, quhead_shiptoname, quhead_shiptoaddress1, quhead_shiptoaddress2, quhead_shiptoaddress3, quhead_shiptocity, quhead_shiptostate, quhead_shiptozipcode, quhead_shiptophone, quhead_salesrep_id, quhead_terms_id, quhead_freight, quhead_ordercomments, quhead_shipcomments, quhead_billtoname, quhead_billtoaddress1, quhead_billtoaddress2, quhead_billtoaddress3, quhead_billtocity, quhead_billtostate, quhead_billtozip, quhead_commission, quhead_custponumber, quhead_fob, quhead_shipvia, quhead_warehous_id, quhead_packdate, quhead_prj_id, quhead_misc, quhead_misc_accnt_id, quhead_misc_descrip, quhead_billtocountry, quhead_shiptocountry, quhead_curr_id, quhead_imported, quhead_expire, quhead_calcfreight, quhead_shipto_cntct_id, quhead_shipto_cntct_honorific, quhead_shipto_cntct_first_name, quhead_shipto_cntct_middle, quhead_shipto_cntct_last_name, quhead_shipto_cntct_suffix, quhead_shipto_cntct_phone, quhead_shipto_cntct_title, quhead_shipto_cntct_fax, quhead_shipto_cntct_email, quhead_billto_cntct_id, quhead_billto_cntct_honorific, quhead_billto_cntct_first_name, quhead_billto_cntct_middle, quhead_billto_cntct_last_name, quhead_billto_cntct_suffix, quhead_billto_cntct_phone, quhead_billto_cntct_title, quhead_billto_cntct_fax, quhead_billto_cntct_email, quhead_taxzone_id, quhead_taxtype_id, quhead_ophead_id, quhead_status, quhead_saletype_id, quhead_shipzone_id) FROM stdin; publicadminfalse2779634JM,00quhead_quhead_id_seq SEQUENCE SET<SELECT pg_catalog.setval('quhead_quhead_id_seq', 86, true); publicadminfalse621#080373quitem TABLE DATACOPY quitem (quitem_id, quitem_quhead_id, quitem_linenumber, quitem_itemsite_id, quitem_scheddate, quitem_qtyord, quitem_unitcost, quitem_price, quitem_custprice, quitem_memo, quitem_custpn, quitem_createorder, quitem_order_warehous_id, quitem_item_id, quitem_prcost, quitem_imported, quitem_qty_uom_id, quitem_qty_invuomratio, quitem_price_uom_id, quitem_price_invuomratio, quitem_promdate, quitem_taxtype_id, quitem_dropship, quitem_itemsrc_id, quitem_pricemode) FROM stdin; publicadminfalse2789634JM,00quitem_quitem_id_seq SEQUENCE SET<SELECT pg_catalog.setval('quitem_quitem_id_seq', 89, true); publicadminfalse622%082028rcalitem TABLE DATACOPY rcalitem (rcalitem_id, rcalitem_calhead_id, rcalitem_offsettype, rcalitem_offsetcount, rcalitem_periodtype, rcalitem_periodcount, rcalitem_name) FROM stdin; publicadminfalse6239634JM%082035recur TABLE DATACOPY recur (recur_id, recur_parent_id, recur_parent_type, recur_period, recur_freq, recur_start, recur_end, recur_max, recur_data) FROM stdin; publicadminfalse62496348KM,00recur_recur_id_seq SEQUENCE SET:SELECT pg_catalog.setval('recur_recur_id_seq', 1, false); publicadminfalse625%082046 recurtype TABLE DATACOPY recurtype (recurtype_id, recurtype_type, recurtype_table, recurtype_donecheck, recurtype_schedcol, recurtype_limit, recurtype_copyfunc, recurtype_copyargs, recurtype_delfunc) FROM stdin; publicadminfalse6269634UKM,00recurtype_recurtype_id_seq SEQUENCE SETASELECT pg_catalog.setval('recurtype_recurtype_id_seq', 5, true); publicadminfalse627$081914recv TABLE DATACOPY recv (recv_id, recv_order_type, recv_order_number, recv_orderitem_id, recv_agent_username, recv_itemsite_id, recv_vend_id, recv_vend_item_number, recv_vend_item_descrip, recv_vend_uom, recv_purchcost, recv_purchcost_curr_id, recv_duedate, recv_qty, recv_recvcost, recv_recvcost_curr_id, recv_freight, recv_freight_curr_id, recv_date, recv_value, recv_posted, recv_invoiced, recv_vohead_id, recv_voitem_id, recv_trans_usr_name, recv_notes, recv_gldistdate, recv_splitfrom_id, recv_rlsd_duedate) FROM stdin; publicadminfalse5999634LM,00recv_recv_id_seq SEQUENCE SET7SELECT pg_catalog.setval('recv_recv_id_seq', 1, true); publicadminfalse628#080592report TABLE DATA{COPY report (report_id, report_name, report_sys, report_source, report_descrip, report_grade, report_loaddate) FROM stdin; publicadminfalse3009634LM,00report_report_id_seq SEQUENCE SET=SELECT pg_catalog.setval('report_report_id_seq', 483, true); publicadminfalse301%082060rjctcode TABLE DATAICOPY rjctcode (rjctcode_id, rjctcode_code, rjctcode_descrip) FROM stdin; publicadminfalse6309634fQ,00rjctcode_rjctcode_id_seq SEQUENCE SET@SELECT pg_catalog.setval('rjctcode_rjctcode_id_seq', 18, true); publicadminfalse631u#078805rsncode TABLE DATAVCOPY rsncode (rsncode_id, rsncode_code, rsncode_descrip, rsncode_doctype) FROM stdin; publicadminfalse1979634Q,00rsncode_rsncode_id_seq SEQUENCE SET=SELECT pg_catalog.setval('rsncode_rsncode_id_seq', 4, true); publicadminfalse632%082072sale TABLE DATAhCOPY sale (sale_id, sale_name, sale_descrip, sale_ipshead_id, sale_startdate, sale_enddate) FROM stdin; publicadminfalse6339634)Q,00sale_sale_id_seq SEQUENCE SET8SELECT pg_catalog.setval('sale_sale_id_seq', 12, true); publicadminfalse634R$081155 salesaccnt TABLE DATAkCOPY salesaccnt (salesaccnt_id, salesaccnt_custtype_id, salesaccnt_prodcat_id, salesaccnt_warehous_id, salesaccnt_sales_accnt_id, salesaccnt_credit_accnt_id, salesaccnt_cos_accnt_id, salesaccnt_custtype, salesaccnt_prodcat, salesaccnt_returns_accnt_id, salesaccnt_cor_accnt_id, salesaccnt_cow_accnt_id, salesaccnt_saletype_id, salesaccnt_shipzone_id) FROM stdin; publicadminfalse4269634FQ,00salesaccnt_salesaccnt_id_seq SEQUENCE SETDSELECT pg_catalog.setval('salesaccnt_salesaccnt_id_seq', 32, true); publicadminfalse635v#078812salescat TABLE DATACOPY salescat (salescat_id, salescat_active, salescat_name, salescat_descrip, salescat_sales_accnt_id, salescat_prepaid_accnt_id, salescat_ar_accnt_id) FROM stdin; publicadminfalse1989634}Q,00salescat_salescat_id_seq SEQUENCE SET?SELECT pg_catalog.setval('salescat_salescat_id_seq', 2, true); publicadminfalse636w#078819salesrep TABLE DATACOPY salesrep (salesrep_id, salesrep_active, salesrep_number, salesrep_name, salesrep_commission, salesrep_method, salesrep_emp_id) FROM stdin; publicadminfalse1999634Q,00salesrep_salesrep_id_seq SEQUENCE SET@SELECT pg_catalog.setval('salesrep_salesrep_id_seq', 29, true); publicadminfalse637~#078912saletype TABLE DATAjCOPY saletype (saletype_id, saletype_code, saletype_descr, saletype_active, saletype_default) FROM stdin; publicadminfalse2079634(Q,00saletype_saletype_id_seq SEQUENCE SET?SELECT pg_catalog.setval('saletype_saletype_id_seq', 3, true); publicadminfalse638#%082100 schemaord TABLE DATAKCOPY schemaord (schemaord_id, schemaord_name, schemaord_order) FROM stdin; publicadminfalse6399634yQ,00schemaord_schemaord_id_seq SEQUENCE SETBSELECT pg_catalog.setval('schemaord_schemaord_id_seq', 1, false); publicadminfalse640#080608script TABLE DATAlCOPY script (script_id, script_name, script_order, script_enabled, script_source, script_notes) FROM stdin; publicadminfalse3039634Q,00script_script_id_seq SEQUENCE SET=SELECT pg_catalog.setval('script_script_id_seq', 136, true); publicadminfalse304%%082110sequence TABLE DATA+COPY sequence (sequence_value) FROM stdin; publicadminfalse6419634QQ#079916shift TABLE DATA<COPY shift (shift_id, shift_number, shift_name) FROM stdin; publicadminfalse2439634Q,00shift_shift_id_seq SEQUENCE SET9SELECT pg_catalog.setval('shift_shift_id_seq', 1, true); publicadminfalse642#079837shipchrg TABLE DATArCOPY shipchrg (shipchrg_id, shipchrg_name, shipchrg_descrip, shipchrg_custfreight, shipchrg_handling) FROM stdin; publicadminfalse2379634ØQ,00shipchrg_shipchrg_id_seq SEQUENCE SET?SELECT pg_catalog.setval('shipchrg_shipchrg_id_seq', 5, true); publicadminfalse643#079936shipdata TABLE DATAuCOPY shipdata (shipdata_cohead_number, shipdata_cosmisc_tracknum, shipdata_cosmisc_packnum_tracknum, shipdata_weight, shipdata_base_freight, shipdata_total_freight, shipdata_shipper, shipdata_billing_option, shipdata_package_type, shipdata_void_ind, shipdata_lastupdated, shipdata_shiphead_number, shipdata_base_freight_curr_id, shipdata_total_freight_curr_id) FROM stdin; publicadminfalse2449634'Q(%082117 shipdatasum TABLE DATACOPY shipdatasum (shipdatasum_cohead_number, shipdatasum_cosmisc_tracknum, shipdatasum_cosmisc_packnum_tracknum, shipdatasum_weight, shipdatasum_base_freight, shipdatasum_total_freight, shipdatasum_shipper, shipdatasum_billing_option, shipdatasum_package_type, shipdatasum_lastupdated, shipdatasum_shipped, shipdatasum_shiphead_number, shipdatasum_base_freight_curr_id, shipdatasum_total_freight_curr_id) FROM stdin; publicadminfalse6449634DQ#079844shipform TABLE DATAaCOPY shipform (shipform_id, shipform_name, shipform_report_id, shipform_report_name) FROM stdin; publicadminfalse2389634aQ,00shipform_shipform_id_seq SEQUENCE SET@SELECT pg_catalog.setval('shipform_shipform_id_seq', 12, true); publicadminfalse645F$081092shiphead TABLE DATA&COPY shiphead (shiphead_id, shiphead_order_id, shiphead_order_type, shiphead_number, shiphead_shipvia, shiphead_freight, shiphead_freight_curr_id, shiphead_notes, shiphead_shipped, shiphead_shipdate, shiphead_shipchrg_id, shiphead_shipform_id, shiphead_sfstatus, shiphead_tracknum) FROM stdin; publicadminfalse4129634Q,00shiphead_shiphead_id_seq SEQUENCE SET@SELECT pg_catalog.setval('shiphead_shiphead_id_seq', 1, false); publicadminfalse646G$081104shipitem TABLE DATACOPY shipitem (shipitem_id, shipitem_orderitem_id, shipitem_shiphead_id, shipitem_qty, shipitem_shipped, shipitem_shipdate, shipitem_transdate, shipitem_trans_username, shipitem_invoiced, shipitem_invcitem_id, shipitem_value, shipitem_invhist_id) FROM stdin; publicadminfalse4139634Q,00shipitem_shipitem_id_seq SEQUENCE SET@SELECT pg_catalog.setval('shipitem_shipitem_id_seq', 1, false); publicadminfalse647,00shipment_number_seq SEQUENCE SET>SELECT pg_catalog.setval('shipment_number_seq', 80000, true); publicadminfalse648,00shipto_shipto_id_seq SEQUENCE SET<SELECT pg_catalog.setval('shipto_shipto_id_seq', 30, true); publicadminfalse650y#078845 shiptoinfo TABLE DATAqCOPY shiptoinfo (shipto_id, shipto_cust_id, shipto_name, shipto_salesrep_id, shipto_comments, shipto_shipcomments, shipto_shipzone_id, shipto_shipvia, shipto_commission, shipto_shipform_id, shipto_shipchrg_id, shipto_active, shipto_default, shipto_num, shipto_ediprofile_id, shipto_cntct_id, shipto_addr_id, shipto_taxzone_id, shipto_preferred_warehous_id) FROM stdin; publicadminfalse2029634ۙQ#080460shipvia TABLE DATAECOPY shipvia (shipvia_id, shipvia_code, shipvia_descrip) FROM stdin; publicadminfalse2839634Q,00shipvia_shipvia_id_seq SEQUENCE SET>SELECT pg_catalog.setval('shipvia_shipvia_id_seq', 24, true); publicadminfalse651#078919shipzone TABLE DATAICOPY shipzone (shipzone_id, shipzone_name, shipzone_descrip) FROM stdin; publicadminfalse2089634Q,00shipzone_shipzone_id_seq SEQUENCE SET@SELECT pg_catalog.setval('shipzone_shipzone_id_seq', 45, true); publicadminfalse652#080468sitetype TABLE DATAICOPY sitetype (sitetype_id, sitetype_name, sitetype_descrip) FROM stdin; publicadminfalse2849634 Q,00sitetype_sitetype_id_seq SEQUENCE SET?SELECT pg_catalog.setval('sitetype_sitetype_id_seq', 1, true); publicadminfalse6531%082149sltrans TABLE DATA2COPY sltrans (sltrans_id, sltrans_created, sltrans_date, sltrans_sequence, sltrans_accnt_id, sltrans_source, sltrans_docnumber, sltrans_misc_id, sltrans_amount, sltrans_notes, sltrans_journalnumber, sltrans_posted, sltrans_doctype, sltrans_username, sltrans_gltrans_journalnumber, sltrans_rec) FROM stdin; publicadminfalse6549634;Q2%082158sltrans_backup TABLE DATAACOPY sltrans_backup (sltrans_old_id, sltrans_new_id) FROM stdin; publicadminfalse6559634XQ,00sopack_sopack_id_seq SEQUENCE SET<SELECT pg_catalog.setval('sopack_sopack_id_seq', 60, true); publicadminfalse6574%082167source TABLE DATAZCOPY source (source_id, source_module, source_name, source_descrip, source_docass_num, source_docass, source_charass, source_table, source_key_field, source_number_field, source_name_field, source_desc_field, source_widget, source_joins, source_key_param, source_uiform_name, source_create_priv, source_created, source_last_modified) FROM stdin; publicadminfalse6589634uQ,00source_source_id_seq SEQUENCE SET<SELECT pg_catalog.setval('source_source_id_seq', 49, true); publicadminfalse6596%082176state TABLE DATALCOPY state (state_id, state_name, state_abbr, state_country_id) FROM stdin; publicadminfalse6609634Q,00state_state_id_seq SEQUENCE SET;SELECT pg_catalog.setval('state_state_id_seq', 158, true); publicadminfalse6618%082185status TABLE DATAeCOPY status (status_id, status_type, status_code, status_name, status_seq, status_color) FROM stdin; publicadminfalse6629634XQ,00status_status_id_seq SEQUENCE SET;SELECT pg_catalog.setval('status_status_id_seq', 6, true); publicadminfalse663:%082194stdjrnl TABLE DATATCOPY stdjrnl (stdjrnl_id, stdjrnl_name, stdjrnl_descrip, stdjrnl_notes) FROM stdin; publicadminfalse6649634Q,00stdjrnl_stdjrnl_id_seq SEQUENCE SET>SELECT pg_catalog.setval('stdjrnl_stdjrnl_id_seq', 30, true); publicadminfalse665<%082203 stdjrnlgrp TABLE DATAQCOPY stdjrnlgrp (stdjrnlgrp_id, stdjrnlgrp_name, stdjrnlgrp_descrip) FROM stdin; publicadminfalse6669634Q,00stdjrnlgrp_stdjrnlgrp_id_seq SEQUENCE SETDSELECT pg_catalog.setval('stdjrnlgrp_stdjrnlgrp_id_seq', 12, true); publicadminfalse667>%082212stdjrnlgrpitem TABLE DATACOPY stdjrnlgrpitem (stdjrnlgrpitem_id, stdjrnlgrpitem_stdjrnl_id, stdjrnlgrpitem_toapply, stdjrnlgrpitem_applied, stdjrnlgrpitem_effective, stdjrnlgrpitem_expires, stdjrnlgrpitem_stdjrnlgrp_id) FROM stdin; publicadminfalse6689634+Q,00$stdjrnlgrpitem_stdjrnlgrpitem_id_seq SEQUENCE SETLSELECT pg_catalog.setval('stdjrnlgrpitem_stdjrnlgrpitem_id_seq', 18, true); publicadminfalse669@%082217 stdjrnlitem TABLE DATACOPY stdjrnlitem (stdjrnlitem_id, stdjrnlitem_stdjrnl_id, stdjrnlitem_accnt_id, stdjrnlitem_amount, stdjrnlitem_notes) FROM stdin; publicadminfalse6709634HQ,00stdjrnlitem_stdjrnlitem_id_seq SEQUENCE SETFSELECT pg_catalog.setval('stdjrnlitem_stdjrnlitem_id_seq', 28, true); publicadminfalse671B%082225subaccnt TABLE DATAKCOPY subaccnt (subaccnt_id, subaccnt_number, subaccnt_descrip) FROM stdin; publicadminfalse6729634eQ,00subaccnt_subaccnt_id_seq SEQUENCE SET?SELECT pg_catalog.setval('subaccnt_subaccnt_id_seq', 1, true); publicadminfalse673D%082234 subaccnttype TABLE DATArCOPY subaccnttype (subaccnttype_id, subaccnttype_accnt_type, subaccnttype_code, subaccnttype_descrip) FROM stdin; publicadminfalse6749634Q,00 subaccnttype_subaccnttype_id_seq SEQUENCE SETHSELECT pg_catalog.setval('subaccnttype_subaccnttype_id_seq', 19, true); publicadminfalse675#080326tax TABLE DATACOPY tax (tax_id, tax_code, tax_descrip, tax_sales_accnt_id, tax_taxclass_id, tax_taxauth_id, tax_basis_tax_id, tax_dist_accnt_id) FROM stdin; publicadminfalse2759634ЮQ,00tax_tax_id_seq SEQUENCE SET6SELECT pg_catalog.setval('tax_tax_id_seq', 13, true); publicadminfalse676G%082244taxass TABLE DATAYCOPY taxass (taxass_id, taxass_taxzone_id, taxass_taxtype_id, taxass_tax_id) FROM stdin; publicadminfalse6779634Q,00taxass_taxass_id_seq SEQUENCE SET<SELECT pg_catalog.setval('taxass_taxass_id_seq', 1, false); publicadminfalse678#079857taxauth TABLE DATACOPY taxauth (taxauth_id, taxauth_code, taxauth_name, taxauth_extref, taxauth_addr_id, taxauth_curr_id, taxauth_county, taxauth_accnt_id) FROM stdin; publicadminfalse2399634*Q,00taxauth_taxauth_id_seq SEQUENCE SET=SELECT pg_catalog.setval('taxauth_taxauth_id_seq', 1, true); publicadminfalse679J%082251taxclass TABLE DATA\COPY taxclass (taxclass_id, taxclass_code, taxclass_descrip, taxclass_sequence) FROM stdin; publicadminfalse6809634xQ,00taxclass_taxclass_id_seq SEQUENCE SET?SELECT pg_catalog.setval('taxclass_taxclass_id_seq', 3, true); publicadminfalse681#080418taxhist TABLE DATA COPY taxhist (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; publicadminfalse2819634Q,00taxhist_taxhist_id_seq SEQUENCE SET>SELECT pg_catalog.setval('taxhist_taxhist_id_seq', 1, false); publicadminfalse682%087560taxpay TABLE DATAeCOPY taxpay (taxpay_id, taxpay_taxhist_id, taxpay_apply_id, taxpay_distdate, taxpay_tax) FROM stdin; publicadminfalse7889634֯Q,00taxpay_taxpay_id_seq SEQUENCE SET<SELECT pg_catalog.setval('taxpay_taxpay_id_seq', 1, false); publicadminfalse789M%082262taxrate TABLE DATACOPY taxrate (taxrate_id, taxrate_tax_id, taxrate_percent, taxrate_curr_id, taxrate_amount, taxrate_effective, taxrate_expires) FROM stdin; publicadminfalse6839634Q,00taxrate_taxrate_id_seq SEQUENCE SET=SELECT pg_catalog.setval('taxrate_taxrate_id_seq', 1, true); publicadminfalse684#079864taxreg TABLE DATACOPY taxreg (taxreg_id, taxreg_rel_id, taxreg_rel_type, taxreg_taxauth_id, taxreg_number, taxreg_taxzone_id, taxreg_effective, taxreg_expires, taxreg_notes) FROM stdin; publicadminfalse24096343Q,00taxreg_taxreg_id_seq SEQUENCE SET<SELECT pg_catalog.setval('taxreg_taxreg_id_seq', 1, false); publicadminfalse685h#077723taxtype TABLE DATARCOPY taxtype (taxtype_id, taxtype_name, taxtype_descrip, taxtype_sys) FROM stdin; publicadminfalse1829634PQ,00taxtype_taxtype_id_seq SEQUENCE SET=SELECT pg_catalog.setval('taxtype_taxtype_id_seq', 3, true); publicadminfalse686z#078853taxzone TABLE DATAECOPY taxzone (taxzone_id, taxzone_code, taxzone_descrip) FROM stdin; publicadminfalse2039634ưQ,00taxzone_taxzone_id_seq SEQUENCE SET=SELECT pg_catalog.setval('taxzone_taxzone_id_seq', 2, true); publicadminfalse687q#078736terms TABLE DATACOPY terms (terms_id, terms_code, terms_descrip, terms_type, terms_duedays, terms_discdays, terms_discprcnt, terms_cutoffday, terms_ap, terms_ar, terms_fincharg) FROM stdin; publicadminfalse1929634 Q,00terms_terms_id_seq SEQUENCE SET:SELECT pg_catalog.setval('terms_terms_id_seq', 43, true); publicadminfalse688#079433todoitem TABLE DATACOPY todoitem (todoitem_id, todoitem_name, todoitem_description, todoitem_incdt_id, todoitem_creator_username, todoitem_status, todoitem_active, todoitem_start_date, todoitem_due_date, todoitem_assigned_date, todoitem_completed_date, todoitem_seq, todoitem_notes, todoitem_crmacct_id, todoitem_ophead_id, todoitem_owner_username, todoitem_priority_id, todoitem_username, todoitem_recurring_todoitem_id, todoitem_cntct_id) FROM stdin; publicadminfalse2129634bQ,00todoitem_todoitem_id_seq SEQUENCE SET@SELECT pg_catalog.setval('todoitem_todoitem_id_seq', 1, false); publicadminfalse689T%082277trgthist TABLE DATAhCOPY trgthist (trgthist_src_cntct_id, trgthist_trgt_cntct_id, trgthist_col, trgthist_value) FROM stdin; publicadminfalse6909634QU%082283trialbal TABLE DATACOPY trialbal (trialbal_id, trialbal_period_id, trialbal_accnt_id, trialbal_beginning, trialbal_ending, trialbal_credits, trialbal_debits, trialbal_dirty, trialbal_yearend) FROM stdin; publicadminfalse6919634Q,00trialbal_trialbal_id_seq SEQUENCE SETBSELECT pg_catalog.setval('trialbal_trialbal_id_seq', 9147, true); publicadminfalse692#080625uiform TABLE DATAlCOPY uiform (uiform_id, uiform_name, uiform_order, uiform_enabled, uiform_source, uiform_notes) FROM stdin; publicadminfalse3069634vQ,00uiform_uiform_id_seq SEQUENCE SET<SELECT pg_catalog.setval('uiform_uiform_id_seq', 65, true); publicadminfalse307i#077731uom TABLE DATAFCOPY uom (uom_id, uom_name, uom_descrip, uom_item_weight) FROM stdin; publicadminfalse1839634Q,00uom_uom_id_seq SEQUENCE SET5SELECT pg_catalog.setval('uom_uom_id_seq', 8, true); publicadminfalse693X%082291uomconv TABLE DATACOPY uomconv (uomconv_id, uomconv_from_uom_id, uomconv_from_value, uomconv_to_uom_id, uomconv_to_value, uomconv_fractional) FROM stdin; publicadminfalse6949634Q,00uomconv_uomconv_id_seq SEQUENCE SET=SELECT pg_catalog.setval('uomconv_uomconv_id_seq', 1, true); publicadminfalse695Z%082297uomtype TABLE DATAWCOPY uomtype (uomtype_id, uomtype_name, uomtype_descrip, uomtype_multiple) FROM stdin; publicadminfalse6969634 Q,00uomtype_uomtype_id_seq SEQUENCE SET=SELECT pg_catalog.setval('uomtype_uomtype_id_seq', 4, true); publicadminfalse697#079622urlinfo TABLE DATA6COPY urlinfo (url_id, url_title, url_url) FROM stdin; publicadminfalse2209634Q,00urlinfo_url_id_seq SEQUENCE SET:SELECT pg_catalog.setval('urlinfo_url_id_seq', 1, false); publicadminfalse698^%082321usr_bak TABLE DATACOPY usr_bak (usr_id, usr_username, usr_propername, usr_passwd, usr_locale_id, usr_initials, usr_agent, usr_active, usr_email, usr_window) FROM stdin; publicadminfalse7019634Q,00usr_usr_id_seq SEQUENCE SET5SELECT pg_catalog.setval('usr_usr_id_seq', 9, true); publicadminfalse702%081959usrgrp TABLE DATADCOPY usrgrp (usrgrp_id, usrgrp_grp_id, usrgrp_username) FROM stdin; publicadminfalse6089634 Q,00usrgrp_usrgrp_id_seq SEQUENCE SET;SELECT pg_catalog.setval('usrgrp_usrgrp_id_seq', 1, true); publicadminfalse703]%082309usrpref TABLE DATAUCOPY usrpref (usrpref_id, usrpref_name, usrpref_value, usrpref_username) FROM stdin; publicadminfalse6999634GQ,00usrpref_usrpref_id_seq SEQUENCE SET?SELECT pg_catalog.setval('usrpref_usrpref_id_seq', 421, true); publicadminfalse704%081965usrpriv TABLE DATAICOPY usrpriv (usrpriv_id, usrpriv_priv_id, usrpriv_username) FROM stdin; publicadminfalse6099634Q,00usrpriv_usrpriv_id_seq SEQUENCE SET@SELECT pg_catalog.setval('usrpriv_usrpriv_id_seq', 2880, true); publicadminfalse705,00vend_vend_id_seq SEQUENCE SET8SELECT pg_catalog.setval('vend_vend_id_seq', 78, true); publicadminfalse707,00vendaddr_vendaddr_id_seq SEQUENCE SET@SELECT pg_catalog.setval('vendaddr_vendaddr_id_seq', 33, true); publicadminfalse709#080334 vendaddrinfo TABLE DATACOPY vendaddrinfo (vendaddr_id, vendaddr_vend_id, vendaddr_code, vendaddr_name, vendaddr_comments, vendaddr_cntct_id, vendaddr_addr_id, vendaddr_taxzone_id) FROM stdin; publicadminfalse2769634Qr#078745vendinfo TABLE DATACOPY vendinfo (vend_id, vend_name, vend_lastpurchdate, vend_active, vend_po, vend_comments, vend_pocomments, vend_number, vend_1099, vend_exported, vend_fobsource, vend_fob, vend_terms_id, vend_shipvia, vend_vendtype_id, vend_qualified, vend_ediemail, vend_ediemailbody, vend_edisubject, vend_edifilename, vend_accntnum, vend_emailpodelivery, vend_restrictpurch, vend_edicc, vend_curr_id, vend_cntct1_id, vend_cntct2_id, vend_addr_id, vend_match, vend_ach_enabled, vend_ach_accnttype, vend_ach_use_vendinfo, vend_ach_indiv_number, vend_ach_indiv_name, vend_ediemailhtml, vend_ach_routingnumber, vend_ach_accntnumber, vend_taxzone_id, vend_accnt_id, vend_expcat_id, vend_tax_id) FROM stdin; publicadminfalse1939634Q#080499vendtype TABLE DATAICOPY vendtype (vendtype_id, vendtype_code, vendtype_descrip) FROM stdin; publicadminfalse2859634mQ,00vendtype_vendtype_id_seq SEQUENCE SET@SELECT pg_catalog.setval('vendtype_vendtype_id_seq', 20, true); publicadminfalse710f%082352vodist TABLE DATACOPY vodist (vodist_id, vodist_poitem_id, vodist_vohead_id, vodist_costelem_id, vodist_accnt_id, vodist_amount, vodist_qty, vodist_expcat_id, vodist_tax_id, vodist_discountable, vodist_notes) FROM stdin; publicadminfalse7119634Q,00vodist_vodist_id_seq SEQUENCE SET=SELECT pg_catalog.setval('vodist_vodist_id_seq', 117, true); publicadminfalse712h%082364vohead TABLE DATACOPY vohead (vohead_id, vohead_number, vohead_pohead_id, vohead_posted, vohead_duedate, vohead_invcnumber, vohead_amount, vohead_docdate, vohead_1099, vohead_distdate, vohead_reference, vohead_terms_id, vohead_vend_id, vohead_curr_id, vohead_adjtaxtype_id, vohead_freighttaxtype_id, vohead_gldistdate, vohead_misc, vohead_taxzone_id, vohead_taxtype_id, vohead_notes, vohead_recurring_vohead_id) FROM stdin; publicadminfalse7139634Q,00vohead_vohead_id_seq SEQUENCE SET=SELECT pg_catalog.setval('vohead_vohead_id_seq', 174, true); publicadminfalse714j%082375 voheadtax TABLE DATA"COPY voheadtax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; publicadminfalse7159634Qk%082381voitem TABLE DATACOPY voitem (voitem_id, voitem_vohead_id, voitem_poitem_id, voitem_close, voitem_qty, voitem_freight, voitem_taxtype_id) FROM stdin; publicadminfalse7169634-Q,00voitem_voitem_id_seq SEQUENCE SET=SELECT pg_catalog.setval('voitem_voitem_id_seq', 110, true); publicadminfalse717m%082388 voitemtax TABLE DATA"COPY voitemtax (taxhist_id, taxhist_parent_id, taxhist_taxtype_id, taxhist_tax_id, taxhist_basis, taxhist_basis_tax_id, taxhist_sequence, taxhist_percent, taxhist_amount, taxhist_tax, taxhist_docdate, taxhist_distdate, taxhist_curr_id, taxhist_curr_rate, taxhist_journalnumber) FROM stdin; publicadminfalse7189634JQ,00warehous_warehous_id_seq SEQUENCE SET@SELECT pg_catalog.setval('warehous_warehous_id_seq', 35, true); publicadminfalse720#080213whsezone TABLE DATA_COPY whsezone (whsezone_id, whsezone_warehous_id, whsezone_name, whsezone_descrip) FROM stdin; publicadminfalse2679634gQ,00whsezone_whsezone_id_seq SEQUENCE SET?SELECT pg_catalog.setval('whsezone_whsezone_id_seq', 6, true); publicadminfalse721c#077634whsinfo TABLE DATACOPY whsinfo (warehous_id, warehous_code, warehous_descrip, warehous_fob, warehous_active, warehous_counttag_prefix, warehous_counttag_number, warehous_bol_prefix, warehous_bol_number, warehous_shipping, warehous_useslips, warehous_usezones, warehous_aislesize, warehous_aislealpha, warehous_racksize, warehous_rackalpha, warehous_binsize, warehous_binalpha, warehous_locationsize, warehous_locationalpha, warehous_enforcearbl, warehous_default_accnt_id, warehous_shipping_commission, warehous_cntct_id, warehous_addr_id, warehous_transit, warehous_shipform_id, warehous_shipvia_id, warehous_shipcomments, warehous_costcat_id, warehous_sitetype_id, warehous_taxzone_id, warehous_sequence) FROM stdin; publicadminfalse1769634Qc$081248wo TABLE DATAWCOPY wo (wo_id, wo_number, wo_subnumber, wo_status, wo_itemsite_id, wo_startdate, wo_duedate, wo_ordtype, wo_ordid, wo_qtyord, wo_qtyrcv, wo_adhoc, wo_itemcfg_series, wo_imported, wo_wipvalue, wo_postedvalue, wo_prodnotes, wo_prj_id, wo_priority, wo_brdvalue, wo_bom_rev_id, wo_boo_rev_id, wo_cosmethod, wo_womatl_id, wo_username) FROM stdin; publicadminfalse4449634Q,00 wo_wo_id_seq SEQUENCE SET5SELECT pg_catalog.setval('wo_wo_id_seq', 445, true); publicadminfalse722#080299womatl TABLE DATACOPY womatl (womatl_id, womatl_wo_id, womatl_itemsite_id, womatl_qtyper, womatl_scrap, womatl_qtyreq, womatl_qtyiss, womatl_qtywipscrap, womatl_lastissue, womatl_lastreturn, womatl_cost, womatl_picklist, womatl_status, womatl_imported, womatl_createwo, womatl_issuemethod, womatl_wooper_id, womatl_bomitem_id, womatl_duedate, womatl_schedatwooper, womatl_uom_id, womatl_notes, womatl_ref, womatl_scrapvalue, womatl_qtyfxd, womatl_issuewo, womatl_price) FROM stdin; publicadminfalse2749634Q,00womatl_womatl_id_seq SEQUENCE SET>SELECT pg_catalog.setval('womatl_womatl_id_seq', 1292, true); publicadminfalse723r%082407 womatlpost TABLE DATAYCOPY womatlpost (womatlpost_id, womatlpost_womatl_id, womatlpost_invhist_id) FROM stdin; publicadminfalse7249634Q,00womatlpost_womatlpost_id_seq SEQUENCE SETDSELECT pg_catalog.setval('womatlpost_womatlpost_id_seq', 1, false); publicadminfalse725t%082412 womatlvar TABLE DATAWCOPY womatlvar (womatlvar_id, womatlvar_number, womatlvar_subnumber, womatlvar_posted, womatlvar_parent_itemsite_id, womatlvar_component_itemsite_id, womatlvar_qtyord, womatlvar_qtyrcv, womatlvar_qtyiss, womatlvar_qtyper, womatlvar_scrap, womatlvar_wipscrap, womatlvar_bomitem_id, womatlvar_ref, womatlvar_notes, womatlvar_qtyfxd) FROM stdin; publicadminfalse72696348Q,00womatlvar_womatlvar_id_seq SEQUENCE SETBSELECT pg_catalog.setval('womatlvar_womatlvar_id_seq', 44, true); publicadminfalse727,00xcalitem_xcalitem_id_seq SEQUENCE SETASELECT pg_catalog.setval('xcalitem_xcalitem_id_seq', 145, true); publicadminfalse728w%082424xsltmap TABLE DATAuCOPY xsltmap (xsltmap_id, xsltmap_name, xsltmap_doctype, xsltmap_system, xsltmap_import, xsltmap_export) FROM stdin; publicadminfalse7299634UQ,00xsltmap_xsltmap_id_seq SEQUENCE SET=SELECT pg_catalog.setval('xsltmap_xsltmap_id_seq', 1, true); publicadminfalse730y%082436 yearperiod TABLE DATAaCOPY yearperiod (yearperiod_id, yearperiod_start, yearperiod_end, yearperiod_closed) FROM stdin; publicadminfalse7319634Q,00yearperiod_yearperiod_id_seq SEQUENCE SETDSELECT pg_catalog.setval('yearperiod_yearperiod_id_seq', 11, true); publicadminfalse732{%082442pkgcmd TABLE DATAmCOPY pkgcmd (cmd_id, cmd_module, cmd_title, cmd_descrip, cmd_privname, cmd_executable, cmd_name) FROM stdin; teadminfalse7339634Q|%082449 pkgcmdarg TABLE DATAPCOPY pkgcmdarg (cmdarg_id, cmdarg_cmd_id, cmdarg_order, cmdarg_arg) FROM stdin; teadminfalse7349634ALTER TABLE ONLY public.apaccnt DROP CONSTRAINT apaccnt_pkey; publicadminfalse3143149635~260682822 apapply_pkey CONSTRAINTSALTER TABLE ONLY apapply ADD CONSTRAINT apapply_pkey PRIMARY KEY (apapply_id); >ALTER TABLE ONLY public.apapply DROP CONSTRAINT apapply_pkey; publicadminfalse3163169635260682824apcreditapply_pkey CONSTRAINTeALTER TABLE ONLY apcreditapply ADD CONSTRAINT apcreditapply_pkey PRIMARY KEY (apcreditapply_id); JALTER TABLE ONLY public.apcreditapply DROP CONSTRAINT apcreditapply_pkey; publicadminfalse3223229635260682826 apopen_pkey CONSTRAINTPALTER TABLE ONLY apopen ADD CONSTRAINT apopen_pkey PRIMARY KEY (apopen_id); <ALTER TABLE ONLY public.apopen DROP CONSTRAINT apopen_pkey; publicadminfalse1901909635260682828apopentax_pkey CONSTRAINTWALTER TABLE ONLY apopentax ADD CONSTRAINT apopentax_pkey PRIMARY KEY (taxhist_id); BALTER TABLE ONLY public.apopentax DROP CONSTRAINT apopentax_pkey; publicadminfalse3263269635260682830apselect_apselect_apopen_id_key CONSTRAINTjALTER TABLE ONLY apselect ADD CONSTRAINT apselect_apselect_apopen_id_key UNIQUE (apselect_apopen_id); RALTER TABLE ONLY public.apselect DROP CONSTRAINT apselect_apselect_apopen_id_key; publicadminfalse3273279635260682832 apselect_pkey CONSTRAINTVALTER TABLE ONLY apselect ADD CONSTRAINT apselect_pkey PRIMARY KEY (apselect_id); @ALTER TABLE ONLY public.apselect DROP CONSTRAINT apselect_pkey; publicadminfalse3273279635260682834 araccnt_pkey CONSTRAINTSALTER TABLE ONLY araccnt ADD CONSTRAINT araccnt_pkey PRIMARY KEY (araccnt_id); >ALTER TABLE ONLY public.araccnt DROP CONSTRAINT araccnt_pkey; publicadminfalse3293299635260682836 arapply_pkey CONSTRAINTSALTER TABLE ONLY arapply ADD CONSTRAINT arapply_pkey PRIMARY KEY (arapply_id); >ALTER TABLE ONLY public.arapply DROP CONSTRAINT arapply_pkey; publicadminfalse3313319635260682838arcreditapply_pkey CONSTRAINTeALTER TABLE ONLY arcreditapply ADD CONSTRAINT arcreditapply_pkey PRIMARY KEY (arcreditapply_id); JALTER TABLE ONLY public.arcreditapply DROP CONSTRAINT arcreditapply_pkey; publicadminfalse3343349635260682840 aropen_pkey CONSTRAINTPALTER TABLE ONLY aropen ADD CONSTRAINT aropen_pkey PRIMARY KEY (aropen_id); <ALTER TABLE ONLY public.aropen DROP CONSTRAINT aropen_pkey; publicadminfalse19519596357260682842aropenalloc_pkey CONSTRAINTALTER TABLE ONLY aropenalloc ADD CONSTRAINT aropenalloc_pkey PRIMARY KEY (aropenalloc_aropen_id, aropenalloc_doctype, aropenalloc_doc_id); FALTER TABLE ONLY public.aropenalloc DROP CONSTRAINT aropenalloc_pkey; publicadminfalse2792792792799635260682844aropentax_pkey CONSTRAINTWALTER TABLE ONLY aropentax ADD CONSTRAINT aropentax_pkey PRIMARY KEY (taxhist_id); BALTER TABLE ONLY public.aropentax DROP CONSTRAINT aropentax_pkey; publicadminfalse3383389635260682846 asohist_pkey CONSTRAINTSALTER TABLE ONLY asohist ADD CONSTRAINT asohist_pkey PRIMARY KEY (asohist_id); >ALTER TABLE ONLY public.asohist DROP CONSTRAINT asohist_pkey; publicadminfalse3393399635260682848asohisttax_pkey CONSTRAINTYALTER TABLE ONLY asohisttax ADD CONSTRAINT asohisttax_pkey PRIMARY KEY (taxhist_id); DALTER TABLE ONLY public.asohisttax DROP CONSTRAINT asohisttax_pkey; publicadminfalse3413419635260682850atlasmap_atlasmap_name_key CONSTRAINT`ALTER TABLE ONLY atlasmap ADD CONSTRAINT atlasmap_atlasmap_name_key UNIQUE (atlasmap_name); MALTER TABLE ONLY public.atlasmap DROP CONSTRAINT atlasmap_atlasmap_name_key; publicadminfalse3423429635260682852 atlasmap_pkey CONSTRAINTVALTER TABLE ONLY atlasmap ADD CONSTRAINT atlasmap_pkey PRIMARY KEY (atlasmap_id); @ALTER TABLE ONLY public.atlasmap DROP CONSTRAINT atlasmap_pkey; publicadminfalse3423429635260682854bankaccnt_bankaccnt_name_key CONSTRAINTdALTER TABLE ONLY bankaccnt ADD CONSTRAINT bankaccnt_bankaccnt_name_key UNIQUE (bankaccnt_name); PALTER TABLE ONLY public.bankaccnt DROP CONSTRAINT bankaccnt_bankaccnt_name_key; publicadminfalse2312319635260682856bankaccnt_pkey CONSTRAINTYALTER TABLE ONLY bankaccnt ADD CONSTRAINT bankaccnt_pkey PRIMARY KEY (bankaccnt_id); BALTER TABLE ONLY public.bankaccnt DROP CONSTRAINT bankaccnt_pkey; publicadminfalse2312319635260682858 bankadj_pkey CONSTRAINTSALTER TABLE ONLY bankadj ADD CONSTRAINT bankadj_pkey PRIMARY KEY (bankadj_id); >ALTER TABLE ONLY public.bankadj DROP CONSTRAINT bankadj_pkey; publicadminfalse3463469635260682860 bankadjtype_bankadjtype_name_key CONSTRAINTlALTER TABLE ONLY bankadjtype ADD CONSTRAINT bankadjtype_bankadjtype_name_key UNIQUE (bankadjtype_name); VALTER TABLE ONLY public.bankadjtype DROP CONSTRAINT bankadjtype_bankadjtype_name_key; publicadminfalse3483489635260682862bankadjtype_pkey CONSTRAINT_ALTER TABLE ONLY bankadjtype ADD CONSTRAINT bankadjtype_pkey PRIMARY KEY (bankadjtype_id); FALTER TABLE ONLY public.bankadjtype DROP CONSTRAINT bankadjtype_pkey; publicadminfalse3483489635260682864 bankrec_pkey CONSTRAINTSALTER TABLE ONLY bankrec ADD CONSTRAINT bankrec_pkey PRIMARY KEY (bankrec_id); >ALTER TABLE ONLY public.bankrec DROP CONSTRAINT bankrec_pkey; publicadminfalse3503509635260687334bankrecimport_pkey CONSTRAINTeALTER TABLE ONLY bankrecimport ADD CONSTRAINT bankrecimport_pkey PRIMARY KEY (bankrecimport_id); JALTER TABLE ONLY public.bankrecimport DROP CONSTRAINT bankrecimport_pkey; publicadminfalse7837839635260682866bankrecitem_pkey CONSTRAINT_ALTER TABLE ONLY bankrecitem ADD CONSTRAINT bankrecitem_pkey PRIMARY KEY (bankrecitem_id); FALTER TABLE ONLY public.bankrecitem DROP CONSTRAINT bankrecitem_pkey; publicadminfalse3523529635w260682868 bomhead_pkey CONSTRAINTSALTER TABLE ONLY bomhead ADD CONSTRAINT bomhead_pkey PRIMARY KEY (bomhead_id); >ALTER TABLE ONLY public.bomhead DROP CONSTRAINT bomhead_pkey; publicadminfalse2252259635260682870 bomitem_pkey CONSTRAINTSALTER TABLE ONLY bomitem ADD CONSTRAINT bomitem_pkey PRIMARY KEY (bomitem_id); >ALTER TABLE ONLY public.bomitem DROP CONSTRAINT bomitem_pkey; publicadminfalse1861869635260682872bomitemcost_pkey CONSTRAINT_ALTER TABLE ONLY bomitemcost ADD CONSTRAINT bomitemcost_pkey PRIMARY KEY (bomitemcost_id); FALTER TABLE ONLY public.bomitemcost DROP CONSTRAINT bomitemcost_pkey; publicadminfalse3563569635y260682874bomitemsub_pkey CONSTRAINT\ALTER TABLE ONLY bomitemsub ADD CONSTRAINT bomitemsub_pkey PRIMARY KEY (bomitemsub_id); DALTER TABLE ONLY public.bomitemsub DROP CONSTRAINT bomitemsub_pkey; publicadminfalse2262269635260682876 bomwork_pkey CONSTRAINTSALTER TABLE ONLY bomwork ADD CONSTRAINT bomwork_pkey PRIMARY KEY (bomwork_id); >ALTER TABLE ONLY public.bomwork DROP CONSTRAINT bomwork_pkey; publicadminfalse3593599635{260682878budghead_budghead_name_key CONSTRAINT`ALTER TABLE ONLY budghead ADD CONSTRAINT budghead_budghead_name_key UNIQUE (budghead_name); MALTER TABLE ONLY public.budghead DROP CONSTRAINT budghead_budghead_name_key; publicadminfalse2272279635}260682880 budghead_pkey CONSTRAINTVALTER TABLE ONLY budghead ADD CONSTRAINT budghead_pkey PRIMARY KEY (budghead_id); @ALTER TABLE ONLY public.budghead DROP CONSTRAINT budghead_pkey; publicadminfalse2272279635260682882 budgitem_pkey CONSTRAINTVALTER TABLE ONLY budgitem ADD CONSTRAINT budgitem_pkey PRIMARY KEY (budgitem_id); @ALTER TABLE ONLY public.budgitem DROP CONSTRAINT budgitem_pkey; publicadminfalse2292299635260682884 calhead_pkey CONSTRAINTSALTER TABLE ONLY calhead ADD CONSTRAINT calhead_pkey PRIMARY KEY (calhead_id); >ALTER TABLE ONLY public.calhead DROP CONSTRAINT calhead_pkey; publicadminfalse3633639635260682886cashrcpt_cashrcpt_number_key CONSTRAINTdALTER TABLE ONLY cashrcpt ADD CONSTRAINT cashrcpt_cashrcpt_number_key UNIQUE (cashrcpt_number); OALTER TABLE ONLY public.cashrcpt DROP CONSTRAINT cashrcpt_cashrcpt_number_key; publicadminfalse2322329635260682888 cashrcpt_pkey CONSTRAINTVALTER TABLE ONLY cashrcpt ADD CONSTRAINT cashrcpt_pkey PRIMARY KEY (cashrcpt_id); @ALTER TABLE ONLY public.cashrcpt DROP CONSTRAINT cashrcpt_pkey; publicadminfalse2322329635260682890cashrcptitem_pkey CONSTRAINTbALTER TABLE ONLY cashrcptitem ADD CONSTRAINT cashrcptitem_pkey PRIMARY KEY (cashrcptitem_id); HALTER TABLE ONLY public.cashrcptitem DROP CONSTRAINT cashrcptitem_pkey; publicadminfalse2332339635260682892cashrcptmisc_pkey CONSTRAINTbALTER TABLE ONLY cashrcptmisc ADD CONSTRAINT cashrcptmisc_pkey PRIMARY KEY (cashrcptmisc_id); HALTER TABLE ONLY public.cashrcptmisc DROP CONSTRAINT cashrcptmisc_pkey; publicadminfalse2342349635260682894 ccard_pkey CONSTRAINTMALTER TABLE ONLY ccard ADD CONSTRAINT ccard_pkey PRIMARY KEY (ccard_id); :ALTER TABLE ONLY public.ccard DROP CONSTRAINT ccard_pkey; publicadminfalse2352359635260682896ccardaud_ccard_pkey CONSTRAINT\ALTER TABLE ONLY ccardaud ADD CONSTRAINT ccardaud_ccard_pkey PRIMARY KEY (ccardaud_id); FALTER TABLE ONLY public.ccardaud DROP CONSTRAINT ccardaud_ccard_pkey; publicadminfalse3693699635260682898ccbank_ccbank_ccard_type_key CONSTRAINTdALTER TABLE ONLY ccbank ADD CONSTRAINT ccbank_ccbank_ccard_type_key UNIQUE (ccbank_ccard_type); MALTER TABLE ONLY public.ccbank DROP CONSTRAINT ccbank_ccbank_ccard_type_key; publicadminfalse3713719635260682900 ccbank_pkey CONSTRAINTPALTER TABLE ONLY ccbank ADD CONSTRAINT ccbank_pkey PRIMARY KEY (ccbank_id); <ALTER TABLE ONLY public.ccbank DROP CONSTRAINT ccbank_pkey; publicadminfalse3713719635260682902 ccpay_pkey CONSTRAINTMALTER TABLE ONLY ccpay ADD CONSTRAINT ccpay_pkey PRIMARY KEY (ccpay_id); :ALTER TABLE ONLY public.ccpay DROP CONSTRAINT ccpay_pkey; publicadminfalse3733739635Z260682904char_char_name_key CONSTRAINTRALTER TABLE ONLY "char" ADD CONSTRAINT char_char_name_key UNIQUE (char_name); CALTER TABLE ONLY public."char" DROP CONSTRAINT char_char_name_key; publicadminfalse2142149635\260682906 char_pkey CONSTRAINTLALTER TABLE ONLY "char" ADD CONSTRAINT char_pkey PRIMARY KEY (char_id); :ALTER TABLE ONLY public."char" DROP CONSTRAINT char_pkey; publicadminfalse2142149635_260682908 charass_pkey CONSTRAINTSALTER TABLE ONLY charass ADD CONSTRAINT charass_pkey PRIMARY KEY (charass_id); >ALTER TABLE ONLY public.charass DROP CONSTRAINT charass_pkey; publicadminfalse2152159635260682910 charopt_pkey CONSTRAINTSALTER TABLE ONLY charopt ADD CONSTRAINT charopt_pkey PRIMARY KEY (charopt_id); >ALTER TABLE ONLY public.charopt DROP CONSTRAINT charopt_pkey; publicadminfalse3773779635260687350 charuse_pkey CONSTRAINTSALTER TABLE ONLY charuse ADD CONSTRAINT charuse_pkey PRIMARY KEY (charuse_id); >ALTER TABLE ONLY public.charuse DROP CONSTRAINT charuse_pkey; publicadminfalse7857859635260682912checkhead_pkey CONSTRAINTYALTER TABLE ONLY checkhead ADD CONSTRAINT checkhead_pkey PRIMARY KEY (checkhead_id); BALTER TABLE ONLY public.checkhead DROP CONSTRAINT checkhead_pkey; publicadminfalse3183189635260682914checkitem_pkey CONSTRAINTYALTER TABLE ONLY checkitem ADD CONSTRAINT checkitem_pkey PRIMARY KEY (checkitem_id); BALTER TABLE ONLY public.checkitem DROP CONSTRAINT checkitem_pkey; publicadminfalse3203209635260682916classcode_classcode_code_key CONSTRAINTdALTER TABLE ONLY classcode ADD CONSTRAINT classcode_classcode_code_key UNIQUE (classcode_code); PALTER TABLE ONLY public.classcode DROP CONSTRAINT classcode_classcode_code_key; publicadminfalse2522529635260682918classcode_pkey CONSTRAINTYALTER TABLE ONLY classcode ADD CONSTRAINT classcode_pkey PRIMARY KEY (classcode_id); BALTER TABLE ONLY public.classcode DROP CONSTRAINT classcode_pkey; publicadminfalse2522529635V260682920cmd_pkey CONSTRAINTGALTER TABLE ONLY cmd ADD CONSTRAINT cmd_pkey PRIMARY KEY (cmd_id); 6ALTER TABLE ONLY public.cmd DROP CONSTRAINT cmd_pkey; publicadminfalse2862869635Z260682922 cmdarg_pkey CONSTRAINTPALTER TABLE ONLY cmdarg ADD CONSTRAINT cmdarg_pkey PRIMARY KEY (cmdarg_id); <ALTER TABLE ONLY public.cmdarg DROP CONSTRAINT cmdarg_pkey; publicadminfalse2892899635$260682924cmhead_cmhead_number_key CONSTRAINT\ALTER TABLE ONLY cmhead ADD CONSTRAINT cmhead_cmhead_number_key UNIQUE (cmhead_number); IALTER TABLE ONLY public.cmhead DROP CONSTRAINT cmhead_cmhead_number_key; publicadminfalse2012019635'260682926 cmhead_pkey CONSTRAINTPALTER TABLE ONLY cmhead ADD CONSTRAINT cmhead_pkey PRIMARY KEY (cmhead_id); <ALTER TABLE ONLY public.cmhead DROP CONSTRAINT cmhead_pkey; publicadminfalse2012019635260682928cmheadtax_pkey CONSTRAINTWALTER TABLE ONLY cmheadtax ADD CONSTRAINT cmheadtax_pkey PRIMARY KEY (taxhist_id); BALTER TABLE ONLY public.cmheadtax DROP CONSTRAINT cmheadtax_pkey; publicadminfalse38338396351260682930"cmitem_cmhead_id_linenumber_unique CONSTRAINT|ALTER TABLE ONLY cmitem ADD CONSTRAINT cmitem_cmhead_id_linenumber_unique UNIQUE (cmitem_cmhead_id, cmitem_linenumber); SALTER TABLE ONLY public.cmitem DROP CONSTRAINT cmitem_cmhead_id_linenumber_unique; publicadminfalse20420420496353260682932 cmitem_pkey CONSTRAINTPALTER TABLE ONLY cmitem ADD CONSTRAINT cmitem_pkey PRIMARY KEY (cmitem_id); <ALTER TABLE ONLY public.cmitem DROP CONSTRAINT cmitem_pkey; publicadminfalse2042049635260682934cmitemtax_pkey CONSTRAINTWALTER TABLE ONLY cmitemtax ADD CONSTRAINT cmitemtax_pkey PRIMARY KEY (taxhist_id); BALTER TABLE ONLY public.cmitemtax DROP CONSTRAINT cmitemtax_pkey; publicadminfalse3853859635b260682936cmnttype_cmnttype_name_key CONSTRAINT`ALTER TABLE ONLY cmnttype ADD CONSTRAINT cmnttype_cmnttype_name_key UNIQUE (cmnttype_name); MALTER TABLE ONLY public.cmnttype DROP CONSTRAINT cmnttype_cmnttype_name_key; publicadminfalse2162169635d260682938 cmnttype_pkey CONSTRAINTVALTER TABLE ONLY cmnttype ADD CONSTRAINT cmnttype_pkey PRIMARY KEY (cmnttype_id); @ALTER TABLE ONLY public.cmnttype DROP CONSTRAINT cmnttype_pkey; publicadminfalse2162169635260682940cmnttypesource_pkey CONSTRAINThALTER TABLE ONLY cmnttypesource ADD CONSTRAINT cmnttypesource_pkey PRIMARY KEY (cmnttypesource_id); LALTER TABLE ONLY public.cmnttypesource DROP CONSTRAINT cmnttypesource_pkey; publicadminfalse3873879635260682942cntct_cntct_number_key CONSTRAINTXALTER TABLE ONLY cntct ADD CONSTRAINT cntct_cntct_number_key UNIQUE (cntct_number); FALTER TABLE ONLY public.cntct DROP CONSTRAINT cntct_cntct_number_key; publicadminfalse1871879635260682944 cntct_pkey CONSTRAINTMALTER TABLE ONLY cntct ADD CONSTRAINT cntct_pkey PRIMARY KEY (cntct_id); :ALTER TABLE ONLY public.cntct DROP CONSTRAINT cntct_pkey; publicadminfalse1871879635260682946cntctaddr_pkey CONSTRAINTYALTER TABLE ONLY cntctaddr ADD CONSTRAINT cntctaddr_pkey PRIMARY KEY (cntctaddr_id); BALTER TABLE ONLY public.cntctaddr DROP CONSTRAINT cntctaddr_pkey; publicadminfalse3903909635260682948cntctdata_pkey CONSTRAINTYALTER TABLE ONLY cntctdata ADD CONSTRAINT cntctdata_pkey PRIMARY KEY (cntctdata_id); BALTER TABLE ONLY public.cntctdata DROP CONSTRAINT cntctdata_pkey; publicadminfalse3923929635260682950 cntcteml_pkey CONSTRAINTVALTER TABLE ONLY cntcteml ADD CONSTRAINT cntcteml_pkey PRIMARY KEY (cntcteml_id); @ALTER TABLE ONLY public.cntcteml DROP CONSTRAINT cntcteml_pkey; publicadminfalse3943949635260682952cntctmrgd_pkey CONSTRAINT_ALTER TABLE ONLY cntctmrgd ADD CONSTRAINT cntctmrgd_pkey PRIMARY KEY (cntctmrgd_cntct_id); BALTER TABLE ONLY public.cntctmrgd DROP CONSTRAINT cntctmrgd_pkey; publicadminfalse3963969635260682954 cntctsel_pkey CONSTRAINT\ALTER TABLE ONLY cntctsel ADD CONSTRAINT cntctsel_pkey PRIMARY KEY (cntctsel_cntct_id); @ALTER TABLE ONLY public.cntctsel DROP CONSTRAINT cntctsel_pkey; publicadminfalse3973979635260682956 cntslip_pkey CONSTRAINTSALTER TABLE ONLY cntslip ADD CONSTRAINT cntslip_pkey PRIMARY KEY (cntslip_id); >ALTER TABLE ONLY public.cntslip DROP CONSTRAINT cntslip_pkey; publicadminfalse1721729635260682958 cobill_pkey CONSTRAINTPALTER TABLE ONLY cobill ADD CONSTRAINT cobill_pkey PRIMARY KEY (cobill_id); <ALTER TABLE ONLY public.cobill DROP CONSTRAINT cobill_pkey; publicadminfalse3993999635260682960cobilltax_pkey CONSTRAINTWALTER TABLE ONLY cobilltax ADD CONSTRAINT cobilltax_pkey PRIMARY KEY (taxhist_id); BALTER TABLE ONLY public.cobilltax DROP CONSTRAINT cobilltax_pkey; publicadminfalse4014019635260682962 cobmisc_pkey CONSTRAINTSALTER TABLE ONLY cobmisc ADD CONSTRAINT cobmisc_pkey PRIMARY KEY (cobmisc_id); >ALTER TABLE ONLY public.cobmisc DROP CONSTRAINT cobmisc_pkey; publicadminfalse4024029635260682964cobmisctax_pkey CONSTRAINTYALTER TABLE ONLY cobmisctax ADD CONSTRAINT cobmisctax_pkey PRIMARY KEY (taxhist_id); DALTER TABLE ONLY public.cobmisctax DROP CONSTRAINT cobmisctax_pkey; publicadminfalse4044049635260682966cohead_cohead_number_key CONSTRAINT\ALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_number_key UNIQUE (cohead_number); IALTER TABLE ONLY public.cohead DROP CONSTRAINT cohead_cohead_number_key; publicadminfalse1781789635260682968 cohead_pkey CONSTRAINTPALTER TABLE ONLY cohead ADD CONSTRAINT cohead_pkey PRIMARY KEY (cohead_id); <ALTER TABLE ONLY public.cohead DROP CONSTRAINT cohead_pkey; publicadminfalse1781789635<260682970 cohist_pkey CONSTRAINTPALTER TABLE ONLY cohist ADD CONSTRAINT cohist_pkey PRIMARY KEY (cohist_id); <ALTER TABLE ONLY public.cohist DROP CONSTRAINT cohist_pkey; publicadminfalse2802809635E260682972cohisttax_pkey CONSTRAINTWALTER TABLE ONLY cohisttax ADD CONSTRAINT cohisttax_pkey PRIMARY KEY (taxhist_id); BALTER TABLE ONLY public.cohisttax DROP CONSTRAINT cohisttax_pkey; publicadminfalse2822829635260682974 coitem_pkey CONSTRAINTPALTER TABLE ONLY coitem ADD CONSTRAINT coitem_pkey PRIMARY KEY (coitem_id); <ALTER TABLE ONLY public.coitem DROP CONSTRAINT coitem_pkey; publicadminfalse1791799635g260682976 comment_pkey CONSTRAINTSALTER TABLE ONLY comment ADD CONSTRAINT comment_pkey PRIMARY KEY (comment_id); >ALTER TABLE ONLY public.comment DROP CONSTRAINT comment_pkey; publicadminfalse2172179635260682978company_company_number_key CONSTRAINT`ALTER TABLE ONLY company ADD CONSTRAINT company_company_number_key UNIQUE (company_number); LALTER TABLE ONLY public.company DROP CONSTRAINT company_company_number_key; publicadminfalse4094099635260682980 company_pkey CONSTRAINTSALTER TABLE ONLY company ADD CONSTRAINT company_pkey PRIMARY KEY (company_id); >ALTER TABLE ONLY public.company DROP CONSTRAINT company_pkey; publicadminfalse4094099635260682982 contrct_pkey CONSTRAINTSALTER TABLE ONLY contrct ADD CONSTRAINT contrct_pkey PRIMARY KEY (contrct_id); >ALTER TABLE ONLY public.contrct DROP CONSTRAINT contrct_pkey; publicadminfalse2592599635260682984costcat_costcat_code_key CONSTRAINT\ALTER TABLE ONLY costcat ADD CONSTRAINT costcat_costcat_code_key UNIQUE (costcat_code); JALTER TABLE ONLY public.costcat DROP CONSTRAINT costcat_costcat_code_key; publicadminfalse2572579635260682986 costcat_pkey CONSTRAINTSALTER TABLE ONLY costcat ADD CONSTRAINT costcat_pkey PRIMARY KEY (costcat_id); >ALTER TABLE ONLY public.costcat DROP CONSTRAINT costcat_pkey; publicadminfalse2572579635260682988costelem_costelem_type_key CONSTRAINT`ALTER TABLE ONLY costelem ADD CONSTRAINT costelem_costelem_type_key UNIQUE (costelem_type); MALTER TABLE ONLY public.costelem DROP CONSTRAINT costelem_costelem_type_key; publicadminfalse2552559635260682990 costelem_pkey CONSTRAINTVALTER TABLE ONLY costelem ADD CONSTRAINT costelem_pkey PRIMARY KEY (costelem_id); @ALTER TABLE ONLY public.costelem DROP CONSTRAINT costelem_pkey; publicadminfalse2552559635260682992 costhist_pkey CONSTRAINTVALTER TABLE ONLY costhist ADD CONSTRAINT costhist_pkey PRIMARY KEY (costhist_id); @ALTER TABLE ONLY public.costhist DROP CONSTRAINT costhist_pkey; publicadminfalse4214219635260682994!costupdate_costupdate_item_id_key CONSTRAINTnALTER TABLE ONLY costupdate ADD CONSTRAINT costupdate_costupdate_item_id_key UNIQUE (costupdate_item_id); VALTER TABLE ONLY public.costupdate DROP CONSTRAINT costupdate_costupdate_item_id_key; publicadminfalse4234239635260682996country_country_abbr_key CONSTRAINT\ALTER TABLE ONLY country ADD CONSTRAINT country_country_abbr_key UNIQUE (country_abbr); JALTER TABLE ONLY public.country DROP CONSTRAINT country_country_abbr_key; publicadminfalse4244249635260682998country_country_name_key CONSTRAINT\ALTER TABLE ONLY country ADD CONSTRAINT country_country_name_key UNIQUE (country_name); JALTER TABLE ONLY public.country DROP CONSTRAINT country_country_name_key; publicadminfalse4244249635 260683000 country_pkey CONSTRAINTSALTER TABLE ONLY country ADD CONSTRAINT country_pkey PRIMARY KEY (country_id); >ALTER TABLE ONLY public.country DROP CONSTRAINT country_pkey; publicadminfalse4244249635260683002crmacct_crmacct_number_key CONSTRAINT`ALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_crmacct_number_key UNIQUE (crmacct_number); LALTER TABLE ONLY public.crmacct DROP CONSTRAINT crmacct_crmacct_number_key; publicadminfalse1881889635260683004 crmacct_pkey CONSTRAINTSALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_pkey PRIMARY KEY (crmacct_id); >ALTER TABLE ONLY public.crmacct DROP CONSTRAINT crmacct_pkey; publicadminfalse1881889635260683006crmacctsel_pkey CONSTRAINThALTER TABLE ONLY crmacctsel ADD CONSTRAINT crmacctsel_pkey PRIMARY KEY (crmacctsel_src_crmacct_id); DALTER TABLE ONLY public.crmacctsel DROP CONSTRAINT crmacctsel_pkey; publicadminfalse4284289635260683008curr_rate_curr_id_key CONSTRAINTfALTER TABLE ONLY curr_rate ADD CONSTRAINT curr_rate_curr_id_key UNIQUE (curr_id, curr_effective); IALTER TABLE ONLY public.curr_rate DROP CONSTRAINT curr_rate_curr_id_key; publicadminfalse4294294299635260683010curr_rate_pkey CONSTRAINTYALTER TABLE ONLY curr_rate ADD CONSTRAINT curr_rate_pkey PRIMARY KEY (curr_rate_id); BALTER TABLE ONLY public.curr_rate DROP CONSTRAINT curr_rate_pkey; publicadminfalse4294299635260683012curr_symbol_curr_abbr_key CONSTRAINT^ALTER TABLE ONLY curr_symbol ADD CONSTRAINT curr_symbol_curr_abbr_key UNIQUE (curr_abbr); OALTER TABLE ONLY public.curr_symbol DROP CONSTRAINT curr_symbol_curr_abbr_key; publicadminfalse1911919635260683014curr_symbol_curr_name_key CONSTRAINT^ALTER TABLE ONLY curr_symbol ADD CONSTRAINT curr_symbol_curr_name_key UNIQUE (curr_name); OALTER TABLE ONLY public.curr_symbol DROP CONSTRAINT curr_symbol_curr_name_key; publicadminfalse1911919635260683016curr_symbol_pkey CONSTRAINTXALTER TABLE ONLY curr_symbol ADD CONSTRAINT curr_symbol_pkey PRIMARY KEY (curr_id); FALTER TABLE ONLY public.curr_symbol DROP CONSTRAINT curr_symbol_pkey; publicadminfalse1911919635260683018 cust_pkey CONSTRAINTNALTER TABLE ONLY custinfo ADD CONSTRAINT cust_pkey PRIMARY KEY (cust_id); <ALTER TABLE ONLY public.custinfo DROP CONSTRAINT cust_pkey; publicadminfalse1961969635260683020 custform_pkey CONSTRAINTVALTER TABLE ONLY custform ADD CONSTRAINT custform_pkey PRIMARY KEY (custform_id); @ALTER TABLE ONLY public.custform DROP CONSTRAINT custform_pkey; publicadminfalse4344349635260683022 custgrp_pkey CONSTRAINTSALTER TABLE ONLY custgrp ADD CONSTRAINT custgrp_pkey PRIMARY KEY (custgrp_id); >ALTER TABLE ONLY public.custgrp DROP CONSTRAINT custgrp_pkey; publicadminfalse4364369635260683024custgrpitem_pkey CONSTRAINT_ALTER TABLE ONLY custgrpitem ADD CONSTRAINT custgrpitem_pkey PRIMARY KEY (custgrpitem_id); FALTER TABLE ONLY public.custgrpitem DROP CONSTRAINT custgrpitem_pkey; publicadminfalse4384389635260683026custinfo_cust_number_key CONSTRAINT\ALTER TABLE ONLY custinfo ADD CONSTRAINT custinfo_cust_number_key UNIQUE (cust_number); KALTER TABLE ONLY public.custinfo DROP CONSTRAINT custinfo_cust_number_key; publicadminfalse1961969635260683028custtype_custtype_code_key CONSTRAINT`ALTER TABLE ONLY custtype ADD CONSTRAINT custtype_custtype_code_key UNIQUE (custtype_code); MALTER TABLE ONLY public.custtype DROP CONSTRAINT custtype_custtype_code_key; publicadminfalse2362369635260683030 custtype_pkey CONSTRAINTVALTER TABLE ONLY custtype ADD CONSTRAINT custtype_pkey PRIMARY KEY (custtype_id); @ALTER TABLE ONLY public.custtype DROP CONSTRAINT custtype_pkey; publicadminfalse2362369635260683032dept_dept_number_key CONSTRAINTTALTER TABLE ONLY dept ADD CONSTRAINT dept_dept_number_key UNIQUE (dept_number); CALTER TABLE ONLY public.dept DROP CONSTRAINT dept_dept_number_key; publicadminfalse2412419635260683034 dept_pkey CONSTRAINTJALTER TABLE ONLY dept ADD CONSTRAINT dept_pkey PRIMARY KEY (dept_id); 8ALTER TABLE ONLY public.dept DROP CONSTRAINT dept_pkey; publicadminfalse2412419635260683036destination_pkey CONSTRAINT_ALTER TABLE ONLY destination ADD CONSTRAINT destination_pkey PRIMARY KEY (destination_id); FALTER TABLE ONLY public.destination DROP CONSTRAINT destination_pkey; publicadminfalse4424429635i260683038 docass_pkey CONSTRAINTPALTER TABLE ONLY docass ADD CONSTRAINT docass_pkey PRIMARY KEY (docass_id); <ALTER TABLE ONLY public.docass DROP CONSTRAINT docass_pkey; publicadminfalse2182189635260683040emp_emp_code_key CONSTRAINTLALTER TABLE ONLY emp ADD CONSTRAINT emp_emp_code_key UNIQUE (emp_code); >ALTER TABLE ONLY public.emp DROP CONSTRAINT emp_emp_code_key; publicadminfalse2422429635260683042emp_emp_number_key CONSTRAINTPALTER TABLE ONLY emp ADD CONSTRAINT emp_emp_number_key UNIQUE (emp_number); @ALTER TABLE ONLY public.emp DROP CONSTRAINT emp_emp_number_key; publicadminfalse2422429635260683044emp_pkey CONSTRAINTGALTER TABLE ONLY emp ADD CONSTRAINT emp_pkey PRIMARY KEY (emp_id); 6ALTER TABLE ONLY public.emp DROP CONSTRAINT emp_pkey; publicadminfalse2422429635%260683046empgrp_empgrp_name_key CONSTRAINTXALTER TABLE ONLY empgrp ADD CONSTRAINT empgrp_empgrp_name_key UNIQUE (empgrp_name); GALTER TABLE ONLY public.empgrp DROP CONSTRAINT empgrp_empgrp_name_key; publicadminfalse4464469635'260683048 empgrp_pkey CONSTRAINTPALTER TABLE ONLY empgrp ADD CONSTRAINT empgrp_pkey PRIMARY KEY (empgrp_id); <ALTER TABLE ONLY public.empgrp DROP CONSTRAINT empgrp_pkey; publicadminfalse4464469635)260683050empgrpitem_pkey CONSTRAINT\ALTER TABLE ONLY empgrpitem ADD CONSTRAINT empgrpitem_pkey PRIMARY KEY (empgrpitem_id); DALTER TABLE ONLY public.empgrpitem DROP CONSTRAINT empgrpitem_pkey; publicadminfalse4484489635-260683052 evntlog_pkey CONSTRAINTSALTER TABLE ONLY evntlog ADD CONSTRAINT evntlog_pkey PRIMARY KEY (evntlog_id); >ALTER TABLE ONLY public.evntlog DROP CONSTRAINT evntlog_pkey; publicadminfalse45045096350260683054 evntnot_pkey CONSTRAINTSALTER TABLE ONLY evntnot ADD CONSTRAINT evntnot_pkey PRIMARY KEY (evntnot_id); >ALTER TABLE ONLY public.evntnot DROP CONSTRAINT evntnot_pkey; publicadminfalse45245296353260683056evnttype_evnttype_name_key CONSTRAINT`ALTER TABLE ONLY evnttype ADD CONSTRAINT evnttype_evnttype_name_key UNIQUE (evnttype_name); MALTER TABLE ONLY public.evnttype DROP CONSTRAINT evnttype_evnttype_name_key; publicadminfalse45445496355260683058 evnttype_pkey CONSTRAINTVALTER TABLE ONLY evnttype ADD CONSTRAINT evnttype_pkey PRIMARY KEY (evnttype_id); @ALTER TABLE ONLY public.evnttype DROP CONSTRAINT evnttype_pkey; publicadminfalse4544549635"260683060expcat_expcat_code_key CONSTRAINTXALTER TABLE ONLY expcat ADD CONSTRAINT expcat_expcat_code_key UNIQUE (expcat_code); GALTER TABLE ONLY public.expcat DROP CONSTRAINT expcat_expcat_code_key; publicadminfalse2732739635$260683062 expcat_pkey CONSTRAINTPALTER TABLE ONLY expcat ADD CONSTRAINT expcat_pkey PRIMARY KEY (expcat_id); <ALTER TABLE ONLY public.expcat DROP CONSTRAINT expcat_pkey; publicadminfalse2732739635o260683064 file_pkey CONSTRAINTJALTER TABLE ONLY file ADD CONSTRAINT file_pkey PRIMARY KEY (file_id); 8ALTER TABLE ONLY public.file DROP CONSTRAINT file_pkey; publicadminfalse21921996358260683066 filter_pkey CONSTRAINTPALTER TABLE ONLY filter ADD CONSTRAINT filter_pkey PRIMARY KEY (filter_id); <ALTER TABLE ONLY public.filter DROP CONSTRAINT filter_pkey; publicadminfalse4584589635:260683068 fincharg_pkey CONSTRAINTVALTER TABLE ONLY fincharg ADD CONSTRAINT fincharg_pkey PRIMARY KEY (fincharg_id); @ALTER TABLE ONLY public.fincharg DROP CONSTRAINT fincharg_pkey; publicadminfalse4604609635B260683070fkey_flcol_key CONSTRAINTQALTER TABLE ONLY flcol ADD CONSTRAINT fkey_flcol_key PRIMARY KEY (flcol_id); >ALTER TABLE ONLY public.flcol DROP CONSTRAINT fkey_flcol_key; publicadminfalse4644649635D260683072 flgrp_pkey CONSTRAINTMALTER TABLE ONLY flgrp ADD CONSTRAINT flgrp_pkey PRIMARY KEY (flgrp_id); :ALTER TABLE ONLY public.flgrp DROP CONSTRAINT flgrp_pkey; publicadminfalse4664669635<260683074flhead_flhead_name_key CONSTRAINTXALTER TABLE ONLY flhead ADD CONSTRAINT flhead_flhead_name_key UNIQUE (flhead_name); GALTER TABLE ONLY public.flhead DROP CONSTRAINT flhead_flhead_name_key; publicadminfalse4624629635>260683076 flhead_pkey CONSTRAINTPALTER TABLE ONLY flhead ADD CONSTRAINT flhead_pkey PRIMARY KEY (flhead_id); <ALTER TABLE ONLY public.flhead DROP CONSTRAINT flhead_pkey; publicadminfalse4624629635@260683078 flitem_pkey CONSTRAINTPALTER TABLE ONLY flitem ADD CONSTRAINT flitem_pkey PRIMARY KEY (flitem_id); <ALTER TABLE ONLY public.flitem DROP CONSTRAINT flitem_pkey; publicadminfalse4634639635F260683080flnotes_flnotes_flhead_id_key CONSTRAINTyALTER TABLE ONLY flnotes ADD CONSTRAINT flnotes_flnotes_flhead_id_key UNIQUE (flnotes_flhead_id, flnotes_period_id); OALTER TABLE ONLY public.flnotes DROP CONSTRAINT flnotes_flnotes_flhead_id_key; publicadminfalse4704704709635H260683082 flrpt_pkey CONSTRAINTMALTER TABLE ONLY flrpt ADD CONSTRAINT flrpt_pkey PRIMARY KEY (flrpt_id); :ALTER TABLE ONLY public.flrpt DROP CONSTRAINT flrpt_pkey; publicadminfalse4724729635J260683084 flspec_pkey CONSTRAINTPALTER TABLE ONLY flspec ADD CONSTRAINT flspec_pkey PRIMARY KEY (flspec_id); <ALTER TABLE ONLY public.flspec DROP CONSTRAINT flspec_pkey; publicadminfalse4744749635L260683086form_form_name_key CONSTRAINTPALTER TABLE ONLY form ADD CONSTRAINT form_form_name_key UNIQUE (form_name); AALTER TABLE ONLY public.form DROP CONSTRAINT form_form_name_key; publicadminfalse4764769635N260683088 form_pkey CONSTRAINTJALTER TABLE ONLY form ADD CONSTRAINT form_pkey PRIMARY KEY (form_id); 8ALTER TABLE ONLY public.form DROP CONSTRAINT form_pkey; publicadminfalse4764769635260683090"freightclass_freightclass_code_key CONSTRAINTpALTER TABLE ONLY freightclass ADD CONSTRAINT freightclass_freightclass_code_key UNIQUE (freightclass_code); YALTER TABLE ONLY public.freightclass DROP CONSTRAINT freightclass_freightclass_code_key; publicadminfalse2452459635260683092freightclass_pkey CONSTRAINTbALTER TABLE ONLY freightclass ADD CONSTRAINT freightclass_pkey PRIMARY KEY (freightclass_id); HALTER TABLE ONLY public.freightclass DROP CONSTRAINT freightclass_pkey; publicadminfalse2452459635P260683094 glseries_pkey CONSTRAINTVALTER TABLE ONLY glseries ADD CONSTRAINT glseries_pkey PRIMARY KEY (glseries_id); @ALTER TABLE ONLY public.glseries DROP CONSTRAINT glseries_pkey; publicadminfalse4794799635260683096 gltrans_pkey CONSTRAINTSALTER TABLE ONLY gltrans ADD CONSTRAINT gltrans_pkey PRIMARY KEY (gltrans_id); >ALTER TABLE ONLY public.gltrans DROP CONSTRAINT gltrans_pkey; publicadminfalse2652659635R260683098grp_grp_name_key CONSTRAINTLALTER TABLE ONLY grp ADD CONSTRAINT grp_grp_name_key UNIQUE (grp_name); >ALTER TABLE ONLY public.grp DROP CONSTRAINT grp_grp_name_key; publicadminfalse4834839635T260683100grp_pkey CONSTRAINTGALTER TABLE ONLY grp ADD CONSTRAINT grp_pkey PRIMARY KEY (grp_id); 6ALTER TABLE ONLY public.grp DROP CONSTRAINT grp_pkey; publicadminfalse4834839635V260683102 grppriv_pkey CONSTRAINTSALTER TABLE ONLY grppriv ADD CONSTRAINT grppriv_pkey PRIMARY KEY (grppriv_id); >ALTER TABLE ONLY public.grppriv DROP CONSTRAINT grppriv_pkey; publicadminfalse4854859635X260683104hnfc_hnfc_code_key CONSTRAINTPALTER TABLE ONLY hnfc ADD CONSTRAINT hnfc_hnfc_code_key UNIQUE (hnfc_code); AALTER TABLE ONLY public.hnfc DROP CONSTRAINT hnfc_hnfc_code_key; publicadminfalse4874879635Z260683106 hnfc_pkey CONSTRAINTJALTER TABLE ONLY hnfc ADD CONSTRAINT hnfc_pkey PRIMARY KEY (hnfc_id); 8ALTER TABLE ONLY public.hnfc DROP CONSTRAINT hnfc_pkey; publicadminfalse4874879635s260683108 image_pkey CONSTRAINTMALTER TABLE ONLY image ADD CONSTRAINT image_pkey PRIMARY KEY (image_id); :ALTER TABLE ONLY public.image DROP CONSTRAINT image_pkey; publicadminfalse2232239635u260683110 imageass_pkey CONSTRAINTVALTER TABLE ONLY imageass ADD CONSTRAINT imageass_pkey PRIMARY KEY (imageass_id); @ALTER TABLE ONLY public.imageass DROP CONSTRAINT imageass_pkey; publicadminfalse2242249635260683112incdt_incdt_number_key CONSTRAINTXALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_number_key UNIQUE (incdt_number); FALTER TABLE ONLY public.incdt DROP CONSTRAINT incdt_incdt_number_key; publicadminfalse1891899635260683114 incdt_pkey CONSTRAINTMALTER TABLE ONLY incdt ADD CONSTRAINT incdt_pkey PRIMARY KEY (incdt_id); :ALTER TABLE ONLY public.incdt DROP CONSTRAINT incdt_pkey; publicadminfalse1891899635260683116incdtcat_incdtcat_name_key CONSTRAINT`ALTER TABLE ONLY incdtcat ADD CONSTRAINT incdtcat_incdtcat_name_key UNIQUE (incdtcat_name); MALTER TABLE ONLY public.incdtcat DROP CONSTRAINT incdtcat_incdtcat_name_key; publicadminfalse2482489635260683118 incdtcat_pkey CONSTRAINTVALTER TABLE ONLY incdtcat ADD CONSTRAINT incdtcat_pkey PRIMARY KEY (incdtcat_id); @ALTER TABLE ONLY public.incdtcat DROP CONSTRAINT incdtcat_pkey; publicadminfalse2482489635\260683120incdthist_pkey CONSTRAINTYALTER TABLE ONLY incdthist ADD CONSTRAINT incdthist_pkey PRIMARY KEY (incdthist_id); BALTER TABLE ONLY public.incdthist DROP CONSTRAINT incdthist_pkey; publicadminfalse4914919635260683122$incdtpriority_incdtpriority_name_key CONSTRAINTtALTER TABLE ONLY incdtpriority ADD CONSTRAINT incdtpriority_incdtpriority_name_key UNIQUE (incdtpriority_name); \ALTER TABLE ONLY public.incdtpriority DROP CONSTRAINT incdtpriority_incdtpriority_name_key; publicadminfalse2492499635260683124incdtpriority_pkey CONSTRAINTeALTER TABLE ONLY incdtpriority ADD CONSTRAINT incdtpriority_pkey PRIMARY KEY (incdtpriority_id); JALTER TABLE ONLY public.incdtpriority DROP CONSTRAINT incdtpriority_pkey; publicadminfalse2492499635260683126(incdtresolution_incdtresolution_name_key CONSTRAINT|ALTER TABLE ONLY incdtresolution ADD CONSTRAINT incdtresolution_incdtresolution_name_key UNIQUE (incdtresolution_name); bALTER TABLE ONLY public.incdtresolution DROP CONSTRAINT incdtresolution_incdtresolution_name_key; publicadminfalse2502509635260683128incdtresolution_pkey CONSTRAINTkALTER TABLE ONLY incdtresolution ADD CONSTRAINT incdtresolution_pkey PRIMARY KEY (incdtresolution_id); NALTER TABLE ONLY public.incdtresolution DROP CONSTRAINT incdtresolution_pkey; publicadminfalse2502509635260683130$incdtseverity_incdtseverity_name_key CONSTRAINTtALTER TABLE ONLY incdtseverity ADD CONSTRAINT incdtseverity_incdtseverity_name_key UNIQUE (incdtseverity_name); \ALTER TABLE ONLY public.incdtseverity DROP CONSTRAINT incdtseverity_incdtseverity_name_key; publicadminfalse2512519635260683132incdtseverity_pkey CONSTRAINTeALTER TABLE ONLY incdtseverity ADD CONSTRAINT incdtseverity_pkey PRIMARY KEY (incdtseverity_id); JALTER TABLE ONLY public.incdtseverity DROP CONSTRAINT incdtseverity_pkey; publicadminfalse2512519635260683134 invbal_pkey CONSTRAINTPALTER TABLE ONLY invbal ADD CONSTRAINT invbal_pkey PRIMARY KEY (invbal_id); <ALTER TABLE ONLY public.invbal DROP CONSTRAINT invbal_pkey; publicadminfalse18518596357260683136invchead_invcnumber_unique CONSTRAINTfALTER TABLE ONLY invchead ADD CONSTRAINT invchead_invcnumber_unique UNIQUE (invchead_invcnumber); MALTER TABLE ONLY public.invchead DROP CONSTRAINT invchead_invcnumber_unique; publicadminfalse20520596359260683138 invchead_pkey CONSTRAINTVALTER TABLE ONLY invchead ADD CONSTRAINT invchead_pkey PRIMARY KEY (invchead_id); @ALTER TABLE ONLY public.invchead DROP CONSTRAINT invchead_pkey; publicadminfalse2052059635^260683140invcheadtax_pkey CONSTRAINT[ALTER TABLE ONLY invcheadtax ADD CONSTRAINT invcheadtax_pkey PRIMARY KEY (taxhist_id); FALTER TABLE ONLY public.invcheadtax DROP CONSTRAINT invcheadtax_pkey; publicadminfalse4994999635E260683142&invcitem_invchead_id_linenumber_unique CONSTRAINTALTER TABLE ONLY invcitem ADD CONSTRAINT invcitem_invchead_id_linenumber_unique UNIQUE (invcitem_invchead_id, invcitem_linenumber); YALTER TABLE ONLY public.invcitem DROP CONSTRAINT invcitem_invchead_id_linenumber_unique; publicadminfalse2092092099635I260683144 invcitem_pkey CONSTRAINTVALTER TABLE ONLY invcitem ADD CONSTRAINT invcitem_pkey PRIMARY KEY (invcitem_id); @ALTER TABLE ONLY public.invcitem DROP CONSTRAINT invcitem_pkey; publicadminfalse2092099635c260683146invcitemtax_pkey CONSTRAINT[ALTER TABLE ONLY invcitemtax ADD CONSTRAINT invcitemtax_pkey PRIMARY KEY (taxhist_id); FALTER TABLE ONLY public.invcitemtax DROP CONSTRAINT invcitemtax_pkey; publicadminfalse5015019635260683148 invcnt_pkey CONSTRAINTPALTER TABLE ONLY invcnt ADD CONSTRAINT invcnt_pkey PRIMARY KEY (invcnt_id); <ALTER TABLE ONLY public.invcnt DROP CONSTRAINT invcnt_pkey; publicadminfalse1731739635j260683150invdetail_pkey CONSTRAINTYALTER TABLE ONLY invdetail ADD CONSTRAINT invdetail_pkey PRIMARY KEY (invdetail_id); BALTER TABLE ONLY public.invdetail DROP CONSTRAINT invdetail_pkey; publicadminfalse5035039635o260683152 invhist_pkey CONSTRAINTSALTER TABLE ONLY invhist ADD CONSTRAINT invhist_pkey PRIMARY KEY (invhist_id); >ALTER TABLE ONLY public.invhist DROP CONSTRAINT invhist_pkey; publicadminfalse5055059635t260683154"invhistexpcat_invhist_id_expcat_id CONSTRAINTALTER TABLE ONLY invhistexpcat ADD CONSTRAINT invhistexpcat_invhist_id_expcat_id UNIQUE (invhistexpcat_invhist_id, invhistexpcat_expcat_id); ZALTER TABLE ONLY public.invhistexpcat DROP CONSTRAINT invhistexpcat_invhist_id_expcat_id; publicadminfalse5075075079635v260683156invhistexpcat_pkey CONSTRAINTeALTER TABLE ONLY invhistexpcat ADD CONSTRAINT invhistexpcat_pkey PRIMARY KEY (invhistexpcat_id); JALTER TABLE ONLY public.invhistexpcat DROP CONSTRAINT invhistexpcat_pkey; publicadminfalse5075079635260683158ipsass_ipsass_ipshead_id_key CONSTRAINTALTER TABLE ONLY ipsass ADD CONSTRAINT ipsass_ipsass_ipshead_id_key UNIQUE (ipsass_ipshead_id, ipsass_cust_id, ipsass_custtype_id, ipsass_custtype_pattern, ipsass_shipto_id, ipsass_shipto_pattern); MALTER TABLE ONLY public.ipsass DROP CONSTRAINT ipsass_ipsass_ipshead_id_key; publicadminfalse2682682682682682682689635260683160 ipsass_pkey CONSTRAINTPALTER TABLE ONLY ipsass ADD CONSTRAINT ipsass_pkey PRIMARY KEY (ipsass_id); <ALTER TABLE ONLY public.ipsass DROP CONSTRAINT ipsass_pkey; publicadminfalse2682689635260683162ipsfreight_pkey CONSTRAINT\ALTER TABLE ONLY ipsfreight ADD CONSTRAINT ipsfreight_pkey PRIMARY KEY (ipsfreight_id); DALTER TABLE ONLY public.ipsfreight DROP CONSTRAINT ipsfreight_pkey; publicadminfalse2462469635260683164ipshead_ipshead_name_key CONSTRAINT\ALTER TABLE ONLY ipshead ADD CONSTRAINT ipshead_ipshead_name_key UNIQUE (ipshead_name); JALTER TABLE ONLY public.ipshead DROP CONSTRAINT ipshead_ipshead_name_key; publicadminfalse2472479635260683166 ipshead_pkey CONSTRAINTSALTER TABLE ONLY ipshead ADD CONSTRAINT ipshead_pkey PRIMARY KEY (ipshead_id); >ALTER TABLE ONLY public.ipshead DROP CONSTRAINT ipshead_pkey; publicadminfalse2472479635260683168ipsitem_ipsitem_ipshead_id_key CONSTRAINTALTER TABLE ONLY ipsiteminfo ADD CONSTRAINT ipsitem_ipsitem_ipshead_id_key UNIQUE (ipsitem_ipshead_id, ipsitem_item_id, ipsitem_prodcat_id, ipsitem_qtybreak, ipsitem_qty_uom_id, ipsitem_price_uom_id); TALTER TABLE ONLY public.ipsiteminfo DROP CONSTRAINT ipsitem_ipsitem_ipshead_id_key; publicadminfalse2692692692692692692699635260683170 ipsitem_pkey CONSTRAINTWALTER TABLE ONLY ipsiteminfo ADD CONSTRAINT ipsitem_pkey PRIMARY KEY (ipsitem_id); BALTER TABLE ONLY public.ipsiteminfo DROP CONSTRAINT ipsitem_pkey; publicadminfalse2692699635260683172&ipsitemchar_ipsitemchar_ipsitem_id_key CONSTRAINTALTER TABLE ONLY ipsitemchar ADD CONSTRAINT ipsitemchar_ipsitemchar_ipsitem_id_key UNIQUE (ipsitemchar_ipsitem_id, ipsitemchar_char_id, ipsitemchar_value); \ALTER TABLE ONLY public.ipsitemchar DROP CONSTRAINT ipsitemchar_ipsitemchar_ipsitem_id_key; publicadminfalse2702702702709635260683174'ipsitemchar_ipsitemchar_ipsitem_id_key1 CONSTRAINTALTER TABLE ONLY ipsitemchar ADD CONSTRAINT ipsitemchar_ipsitemchar_ipsitem_id_key1 UNIQUE (ipsitemchar_ipsitem_id, ipsitemchar_char_id, ipsitemchar_value); ]ALTER TABLE ONLY public.ipsitemchar DROP CONSTRAINT ipsitemchar_ipsitemchar_ipsitem_id_key1; publicadminfalse2702702702709635260683176ipsitemchar_pkey CONSTRAINT_ALTER TABLE ONLY ipsitemchar ADD CONSTRAINT ipsitemchar_pkey PRIMARY KEY (ipsitemchar_id); FALTER TABLE ONLY public.ipsitemchar DROP CONSTRAINT ipsitemchar_pkey; publicadminfalse2702709635x260683178ipsprodcat_pkey CONSTRAINT`ALTER TABLE ONLY ipsprodcat_bak ADD CONSTRAINT ipsprodcat_pkey PRIMARY KEY (ipsprodcat_id); HALTER TABLE ONLY public.ipsprodcat_bak DROP CONSTRAINT ipsprodcat_pkey; publicadminfalse5165169635260683180item_item_number_key CONSTRAINTTALTER TABLE ONLY item ADD CONSTRAINT item_item_number_key UNIQUE (item_number); CALTER TABLE ONLY public.item DROP CONSTRAINT item_item_number_key; publicadminfalse1741749635260683182 item_pkey CONSTRAINTJALTER TABLE ONLY item ADD CONSTRAINT item_pkey PRIMARY KEY (item_id); 8ALTER TABLE ONLY public.item DROP CONSTRAINT item_pkey; publicadminfalse1741749635260683184itemalias_itemalias_item_id_key CONSTRAINT|ALTER TABLE ONLY itemalias ADD CONSTRAINT itemalias_itemalias_item_id_key UNIQUE (itemalias_item_id, itemalias_number); SALTER TABLE ONLY public.itemalias DROP CONSTRAINT itemalias_itemalias_item_id_key; publicadminfalse2542542549635260683186itemalias_pkey CONSTRAINTYALTER TABLE ONLY itemalias ADD CONSTRAINT itemalias_pkey PRIMARY KEY (itemalias_id); BALTER TABLE ONLY public.itemalias DROP CONSTRAINT itemalias_pkey; publicadminfalse2542549635260683188 itemcost_pkey CONSTRAINTVALTER TABLE ONLY itemcost ADD CONSTRAINT itemcost_pkey PRIMARY KEY (itemcost_id); @ALTER TABLE ONLY public.itemcost DROP CONSTRAINT itemcost_pkey; publicadminfalse2562569635z260683190itemgrp_itemgrp_name_key CONSTRAINT\ALTER TABLE ONLY itemgrp ADD CONSTRAINT itemgrp_itemgrp_name_key UNIQUE (itemgrp_name); JALTER TABLE ONLY public.itemgrp DROP CONSTRAINT itemgrp_itemgrp_name_key; publicadminfalse5235239635|260683192 itemgrp_pkey CONSTRAINTSALTER TABLE ONLY itemgrp ADD CONSTRAINT itemgrp_pkey PRIMARY KEY (itemgrp_id); >ALTER TABLE ONLY public.itemgrp DROP CONSTRAINT itemgrp_pkey; publicadminfalse5235239635~260683194itemgrpitem_pkey CONSTRAINT_ALTER TABLE ONLY itemgrpitem ADD CONSTRAINT itemgrpitem_pkey PRIMARY KEY (itemgrpitem_id); FALTER TABLE ONLY public.itemgrpitem DROP CONSTRAINT itemgrpitem_pkey; publicadminfalse5255259635260683196itemgrpitem_unique_key CONSTRAINTALTER TABLE ONLY itemgrpitem ADD CONSTRAINT itemgrpitem_unique_key UNIQUE (itemgrpitem_itemgrp_id, itemgrpitem_item_id, itemgrpitem_item_type); LALTER TABLE ONLY public.itemgrpitem DROP CONSTRAINT itemgrpitem_unique_key; publicadminfalse5255255255259635260683198 itemloc_pkey CONSTRAINTSALTER TABLE ONLY itemloc ADD CONSTRAINT itemloc_pkey PRIMARY KEY (itemloc_id); >ALTER TABLE ONLY public.itemloc DROP CONSTRAINT itemloc_pkey; publicadminfalse5295299635260683200itemlocdist_pkey CONSTRAINT_ALTER TABLE ONLY itemlocdist ADD CONSTRAINT itemlocdist_pkey PRIMARY KEY (itemlocdist_id); FALTER TABLE ONLY public.itemlocdist DROP CONSTRAINT itemlocdist_pkey; publicadminfalse5325329635260683202itemlocpost_pkey CONSTRAINT_ALTER TABLE ONLY itemlocpost ADD CONSTRAINT itemlocpost_pkey PRIMARY KEY (itemlocpost_id); FALTER TABLE ONLY public.itemlocpost DROP CONSTRAINT itemlocpost_pkey; publicadminfalse5345349635260683204 itemsite_pkey CONSTRAINTVALTER TABLE ONLY itemsite ADD CONSTRAINT itemsite_pkey PRIMARY KEY (itemsite_id); @ALTER TABLE ONLY public.itemsite DROP CONSTRAINT itemsite_pkey; publicadminfalse1751759635260683206itemsrc_itemsrc_vend_id_key CONSTRAINTALTER TABLE ONLY itemsrc ADD CONSTRAINT itemsrc_itemsrc_vend_id_key UNIQUE (itemsrc_vend_id, itemsrc_item_id, itemsrc_effective, itemsrc_expires, itemsrc_vend_item_number, itemsrc_manuf_name, itemsrc_manuf_item_number, itemsrc_contrct_id); MALTER TABLE ONLY public.itemsrc DROP CONSTRAINT itemsrc_itemsrc_vend_id_key; publicadminfalse2602602602602602602602602609635260683208 itemsrc_pkey CONSTRAINTSALTER TABLE ONLY itemsrc ADD CONSTRAINT itemsrc_pkey PRIMARY KEY (itemsrc_id); >ALTER TABLE ONLY public.itemsrc DROP CONSTRAINT itemsrc_pkey; publicadminfalse2602609635260683210 itemsrcp_itemsrcp_itemsrc_id_key CONSTRAINTALTER TABLE ONLY itemsrcp ADD CONSTRAINT itemsrcp_itemsrcp_itemsrc_id_key UNIQUE (itemsrcp_itemsrc_id, itemsrcp_warehous_id, itemsrcp_dropship, itemsrcp_qtybreak); SALTER TABLE ONLY public.itemsrcp DROP CONSTRAINT itemsrcp_itemsrcp_itemsrc_id_key; publicadminfalse2612612612612619635260683212 itemsrcp_pkey CONSTRAINTVALTER TABLE ONLY itemsrcp ADD CONSTRAINT itemsrcp_pkey PRIMARY KEY (itemsrcp_id); @ALTER TABLE ONLY public.itemsrcp DROP CONSTRAINT itemsrcp_pkey; publicadminfalse2612619635260683214"itemsub_itemsub_parent_item_id_key CONSTRAINTALTER TABLE ONLY itemsub ADD CONSTRAINT itemsub_itemsub_parent_item_id_key UNIQUE (itemsub_parent_item_id, itemsub_sub_item_id); TALTER TABLE ONLY public.itemsub DROP CONSTRAINT itemsub_itemsub_parent_item_id_key; publicadminfalse2622622629635260683216 itemsub_pkey CONSTRAINTSALTER TABLE ONLY itemsub ADD CONSTRAINT itemsub_pkey PRIMARY KEY (itemsub_id); >ALTER TABLE ONLY public.itemsub DROP CONSTRAINT itemsub_pkey; publicadminfalse2622629635260683218 itemtax_pkey CONSTRAINTSALTER TABLE ONLY itemtax ADD CONSTRAINT itemtax_pkey PRIMARY KEY (itemtax_id); >ALTER TABLE ONLY public.itemtax DROP CONSTRAINT itemtax_pkey; publicadminfalse2632639635260683220&itemtrans_itemtrans_source_item_id_key CONSTRAINTALTER TABLE ONLY itemtrans ADD CONSTRAINT itemtrans_itemtrans_source_item_id_key UNIQUE (itemtrans_source_item_id, itemtrans_target_item_id); ZALTER TABLE ONLY public.itemtrans DROP CONSTRAINT itemtrans_itemtrans_source_item_id_key; publicadminfalse5425425429635260683222itemtrans_pkey CONSTRAINTYALTER TABLE ONLY itemtrans ADD CONSTRAINT itemtrans_pkey PRIMARY KEY (itemtrans_id); BALTER TABLE ONLY public.itemtrans DROP CONSTRAINT itemtrans_pkey; publicadminfalse5425429635260683224 itemuom_pkey CONSTRAINTSALTER TABLE ONLY itemuom ADD CONSTRAINT itemuom_pkey PRIMARY KEY (itemuom_id); >ALTER TABLE ONLY public.itemuom DROP CONSTRAINT itemuom_pkey; publicadminfalse5445449635260683226itemuomconv_pkey CONSTRAINT_ALTER TABLE ONLY itemuomconv ADD CONSTRAINT itemuomconv_pkey PRIMARY KEY (itemuomconv_id); FALTER TABLE ONLY public.itemuomconv DROP CONSTRAINT itemuomconv_pkey; publicadminfalse2642649635260683228 jrnluse_pkey CONSTRAINTSALTER TABLE ONLY jrnluse ADD CONSTRAINT jrnluse_pkey PRIMARY KEY (jrnluse_id); >ALTER TABLE ONLY public.jrnluse DROP CONSTRAINT jrnluse_pkey; publicadminfalse5485489635260683230 labeldef_pkey CONSTRAINTVALTER TABLE ONLY labeldef ADD CONSTRAINT labeldef_pkey PRIMARY KEY (labeldef_id); @ALTER TABLE ONLY public.labeldef DROP CONSTRAINT labeldef_pkey; publicadminfalse5505509635260683232labelform_labelform_name_key CONSTRAINTdALTER TABLE ONLY labelform ADD CONSTRAINT labelform_labelform_name_key UNIQUE (labelform_name); PALTER TABLE ONLY public.labelform DROP CONSTRAINT labelform_labelform_name_key; publicadminfalse5525529635260683234labelform_pkey CONSTRAINTYALTER TABLE ONLY labelform ADD CONSTRAINT labelform_pkey PRIMARY KEY (labelform_id); BALTER TABLE ONLY public.labelform DROP CONSTRAINT labelform_pkey; publicadminfalse5525529635260683236 lang_pkey CONSTRAINTJALTER TABLE ONLY lang ADD CONSTRAINT lang_pkey PRIMARY KEY (lang_id); 8ALTER TABLE ONLY public.lang DROP CONSTRAINT lang_pkey; publicadminfalse5545549635260683238locale_locale_code_key CONSTRAINTXALTER TABLE ONLY locale ADD CONSTRAINT locale_locale_code_key UNIQUE (locale_code); GALTER TABLE ONLY public.locale DROP CONSTRAINT locale_locale_code_key; publicadminfalse5565569635260683240 locale_pkey CONSTRAINTPALTER TABLE ONLY locale ADD CONSTRAINT locale_pkey PRIMARY KEY (locale_id); <ALTER TABLE ONLY public.locale DROP CONSTRAINT locale_pkey; publicadminfalse5565569635 260683242 location_pkey CONSTRAINTVALTER TABLE ONLY location ADD CONSTRAINT location_pkey PRIMARY KEY (location_id); @ALTER TABLE ONLY public.location DROP CONSTRAINT location_pkey; publicadminfalse2662669635260683244 locitem_pkey CONSTRAINTSALTER TABLE ONLY locitem ADD CONSTRAINT locitem_pkey PRIMARY KEY (locitem_id); >ALTER TABLE ONLY public.locitem DROP CONSTRAINT locitem_pkey; publicadminfalse5595599635`260683246$metasql_metasql_group_name_grade_key CONSTRAINTALTER TABLE ONLY metasql ADD CONSTRAINT metasql_metasql_group_name_grade_key UNIQUE (metasql_group, metasql_name, metasql_grade); VALTER TABLE ONLY public.metasql DROP CONSTRAINT metasql_metasql_group_name_grade_key; publicadminfalse2942942942949635b260683248 metasql_pkey CONSTRAINTSALTER TABLE ONLY metasql ADD CONSTRAINT metasql_pkey PRIMARY KEY (metasql_id); >ALTER TABLE ONLY public.metasql DROP CONSTRAINT metasql_pkey; publicadminfalse2942949635260683250metric_metric_name_key CONSTRAINTXALTER TABLE ONLY metric ADD CONSTRAINT metric_metric_name_key UNIQUE (metric_name); GALTER TABLE ONLY public.metric DROP CONSTRAINT metric_metric_name_key; publicadminfalse5625629635260683252 metric_pkey CONSTRAINTPALTER TABLE ONLY metric ADD CONSTRAINT metric_pkey PRIMARY KEY (metric_id); <ALTER TABLE ONLY public.metric DROP CONSTRAINT metric_pkey; publicadminfalse5625629635260683254metricenc_metricenc_name_key CONSTRAINTdALTER TABLE ONLY metricenc ADD CONSTRAINT metricenc_metricenc_name_key UNIQUE (metricenc_name); PALTER TABLE ONLY public.metricenc DROP CONSTRAINT metricenc_metricenc_name_key; publicadminfalse5645649635260683256metricenc_pkey CONSTRAINTYALTER TABLE ONLY metricenc ADD CONSTRAINT metricenc_pkey PRIMARY KEY (metricenc_id); BALTER TABLE ONLY public.metricenc DROP CONSTRAINT metricenc_pkey; publicadminfalse5645649635260683258 mrghist_pkey CONSTRAINTALTER TABLE ONLY mrghist ADD CONSTRAINT mrghist_pkey PRIMARY KEY (mrghist_cntct_id, mrghist_table, mrghist_pkey_col, mrghist_pkey_id, mrghist_cntct_col); >ALTER TABLE ONLY public.mrghist DROP CONSTRAINT mrghist_pkey; publicadminfalse5675675675675675679635260683260mrgundo_mrgundo_schema_key CONSTRAINTALTER TABLE ONLY mrgundo ADD CONSTRAINT mrgundo_mrgundo_schema_key UNIQUE (mrgundo_schema, mrgundo_table, mrgundo_pkey_col, mrgundo_pkey_id, mrgundo_col); LALTER TABLE ONLY public.mrgundo DROP CONSTRAINT mrgundo_mrgundo_schema_key; publicadminfalse5685685685685685689635260683262msg_pkey CONSTRAINTGALTER TABLE ONLY msg ADD CONSTRAINT msg_pkey PRIMARY KEY (msg_id); 6ALTER TABLE ONLY public.msg DROP CONSTRAINT msg_pkey; publicadminfalse5695699635260683264 msguser_pkey CONSTRAINTSALTER TABLE ONLY msguser ADD CONSTRAINT msguser_pkey PRIMARY KEY (msguser_id); >ALTER TABLE ONLY public.msguser DROP CONSTRAINT msguser_pkey; publicadminfalse5715719635260683266obsolete_tax_pkey CONSTRAINTYALTER TABLE ONLY obsolete_tax ADD CONSTRAINT obsolete_tax_pkey PRIMARY KEY (tax_id); HALTER TABLE ONLY public.obsolete_tax DROP CONSTRAINT obsolete_tax_pkey; publicadminfalse5745749635K260683268ophead_ophead_number_key CONSTRAINT\ALTER TABLE ONLY ophead ADD CONSTRAINT ophead_ophead_number_key UNIQUE (ophead_number); IALTER TABLE ONLY public.ophead DROP CONSTRAINT ophead_ophead_number_key; publicadminfalse2102109635M260683270 ophead_pkey CONSTRAINTPALTER TABLE ONLY ophead ADD CONSTRAINT ophead_pkey PRIMARY KEY (ophead_id); <ALTER TABLE ONLY public.ophead DROP CONSTRAINT ophead_pkey; publicadminfalse2102109635260683272opsource_opsource_name_key CONSTRAINT`ALTER TABLE ONLY opsource ADD CONSTRAINT opsource_opsource_name_key UNIQUE (opsource_name); MALTER TABLE ONLY public.opsource DROP CONSTRAINT opsource_opsource_name_key; publicadminfalse5765769635260683274 opsource_pkey CONSTRAINTVALTER TABLE ONLY opsource ADD CONSTRAINT opsource_pkey PRIMARY KEY (opsource_id); @ALTER TABLE ONLY public.opsource DROP CONSTRAINT opsource_pkey; publicadminfalse5765769635260683276opstage_opstage_name_key CONSTRAINT\ALTER TABLE ONLY opstage ADD CONSTRAINT opstage_opstage_name_key UNIQUE (opstage_name); JALTER TABLE ONLY public.opstage DROP CONSTRAINT opstage_opstage_name_key; publicadminfalse5785789635260683278 opstage_pkey CONSTRAINTSALTER TABLE ONLY opstage ADD CONSTRAINT opstage_pkey PRIMARY KEY (opstage_id); >ALTER TABLE ONLY public.opstage DROP CONSTRAINT opstage_pkey; publicadminfalse5785789635260683280optype_optype_name_key CONSTRAINTXALTER TABLE ONLY optype ADD CONSTRAINT optype_optype_name_key UNIQUE (optype_name); GALTER TABLE ONLY public.optype DROP CONSTRAINT optype_optype_name_key; publicadminfalse5805809635260683282 optype_pkey CONSTRAINTPALTER TABLE ONLY optype ADD CONSTRAINT optype_pkey PRIMARY KEY (optype_id); <ALTER TABLE ONLY public.optype DROP CONSTRAINT optype_pkey; publicadminfalse5805809635260683284orderseq_orderseq_name_key CONSTRAINT`ALTER TABLE ONLY orderseq ADD CONSTRAINT orderseq_orderseq_name_key UNIQUE (orderseq_name); MALTER TABLE ONLY public.orderseq DROP CONSTRAINT orderseq_orderseq_name_key; publicadminfalse5825829635260683286 orderseq_pkey CONSTRAINTVALTER TABLE ONLY orderseq ADD CONSTRAINT orderseq_pkey PRIMARY KEY (orderseq_id); @ALTER TABLE ONLY public.orderseq DROP CONSTRAINT orderseq_pkey; publicadminfalse5825829635260683288 pack_pkey CONSTRAINTJALTER TABLE ONLY pack ADD CONSTRAINT pack_pkey PRIMARY KEY (pack_id); 8ALTER TABLE ONLY public.pack DROP CONSTRAINT pack_pkey; publicadminfalse5845849635260683290payaropen_pkey CONSTRAINTtALTER TABLE ONLY payaropen ADD CONSTRAINT payaropen_pkey PRIMARY KEY (payaropen_ccpay_id, payaropen_aropen_id); BALTER TABLE ONLY public.payaropen DROP CONSTRAINT payaropen_pkey; publicadminfalse5865865869635260687409 payco_pkey CONSTRAINTMALTER TABLE ONLY payco ADD CONSTRAINT payco_pkey PRIMARY KEY (payco_id); :ALTER TABLE ONLY public.payco DROP CONSTRAINT payco_pkey; publicadminfalse5875879635260687404payco_unique_ccpay_id_cohead_id CONSTRAINTtALTER TABLE ONLY payco ADD CONSTRAINT payco_unique_ccpay_id_cohead_id UNIQUE (payco_ccpay_id, payco_cohead_id); OALTER TABLE ONLY public.payco DROP CONSTRAINT payco_unique_ccpay_id_cohead_id; publicadminfalse5875875879635260683292 period_pkey CONSTRAINTPALTER TABLE ONLY period ADD CONSTRAINT period_pkey PRIMARY KEY (period_id); <ALTER TABLE ONLY public.period DROP CONSTRAINT period_pkey; publicadminfalse2302309635260683294 pk_prjtype CONSTRAINTQALTER TABLE ONLY prjtype ADD CONSTRAINT pk_prjtype PRIMARY KEY (prjtype_id); <ALTER TABLE ONLY public.prjtype DROP CONSTRAINT pk_prjtype; publicadminfalse6146149635260683296 pkgdep_pkey CONSTRAINTPALTER TABLE ONLY pkgdep ADD CONSTRAINT pkgdep_pkey PRIMARY KEY (pkgdep_id); <ALTER TABLE ONLY public.pkgdep DROP CONSTRAINT pkgdep_pkey; publicadminfalse5895899635260683298 pkghead_pkey CONSTRAINTSALTER TABLE ONLY pkghead ADD CONSTRAINT pkghead_pkey PRIMARY KEY (pkghead_id); >ALTER TABLE ONLY public.pkghead DROP CONSTRAINT pkghead_pkey; publicadminfalse5915919635260683300 pkgitem_pkey CONSTRAINTSALTER TABLE ONLY pkgitem ADD CONSTRAINT pkgitem_pkey PRIMARY KEY (pkgitem_id); >ALTER TABLE ONLY public.pkgitem DROP CONSTRAINT pkgitem_pkey; publicadminfalse5935939635260683302pkgitem_pkgitem_pkghead_id_key CONSTRAINTALTER TABLE ONLY pkgitem ADD CONSTRAINT pkgitem_pkgitem_pkghead_id_key UNIQUE (pkgitem_pkghead_id, pkgitem_type, pkgitem_name); PALTER TABLE ONLY public.pkgitem DROP CONSTRAINT pkgitem_pkgitem_pkghead_id_key; publicadminfalse5935935935939635260683304pkgitem_pkgitem_pkghead_id_key1 CONSTRAINTALTER TABLE ONLY pkgitem ADD CONSTRAINT pkgitem_pkgitem_pkghead_id_key1 UNIQUE (pkgitem_pkghead_id, pkgitem_type, pkgitem_item_id); QALTER TABLE ONLY public.pkgitem DROP CONSTRAINT pkgitem_pkgitem_pkghead_id_key1; publicadminfalse5935935935939635260683306 plancode_pkey CONSTRAINTVALTER TABLE ONLY plancode ADD CONSTRAINT plancode_pkey PRIMARY KEY (plancode_id); @ALTER TABLE ONLY public.plancode DROP CONSTRAINT plancode_pkey; publicadminfalse2582589635260683308plancode_plancode_code_key CONSTRAINT`ALTER TABLE ONLY plancode ADD CONSTRAINT plancode_plancode_code_key UNIQUE (plancode_code); MALTER TABLE ONLY public.plancode DROP CONSTRAINT plancode_plancode_code_key; publicadminfalse2582589635260683310 pohead_pkey CONSTRAINTPALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pkey PRIMARY KEY (pohead_id); <ALTER TABLE ONLY public.pohead DROP CONSTRAINT pohead_pkey; publicadminfalse1801809635260683312pohead_pohead_number_key CONSTRAINT\ALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_number_key UNIQUE (pohead_number); IALTER TABLE ONLY public.pohead DROP CONSTRAINT pohead_pohead_number_key; publicadminfalse1801809635260683314 poitem_pkey CONSTRAINTPALTER TABLE ONLY poitem ADD CONSTRAINT poitem_pkey PRIMARY KEY (poitem_id); <ALTER TABLE ONLY public.poitem DROP CONSTRAINT poitem_pkey; publicadminfalse1811819635260683316poitem_poitem_pohead_id_key CONSTRAINTuALTER TABLE ONLY poitem ADD CONSTRAINT poitem_poitem_pohead_id_key UNIQUE (poitem_pohead_id, poitem_linenumber); LALTER TABLE ONLY public.poitem DROP CONSTRAINT poitem_poitem_pohead_id_key; publicadminfalse1811811819635260683318 poreject_pkey CONSTRAINTVALTER TABLE ONLY poreject ADD CONSTRAINT poreject_pkey PRIMARY KEY (poreject_id); @ALTER TABLE ONLY public.poreject DROP CONSTRAINT poreject_pkey; publicadminfalse6026029635260683320pr_pkey CONSTRAINTDALTER TABLE ONLY pr ADD CONSTRAINT pr_pkey PRIMARY KEY (pr_id); 4ALTER TABLE ONLY public.pr DROP CONSTRAINT pr_pkey; publicadminfalse6046049635260683322 prftcntr_pkey CONSTRAINTVALTER TABLE ONLY prftcntr ADD CONSTRAINT prftcntr_pkey PRIMARY KEY (prftcntr_id); @ALTER TABLE ONLY public.prftcntr DROP CONSTRAINT prftcntr_pkey; publicadminfalse6066069635260683324prftcntr_prftcntr_number_key CONSTRAINTdALTER TABLE ONLY prftcntr ADD CONSTRAINT prftcntr_prftcntr_number_key UNIQUE (prftcntr_number); OALTER TABLE ONLY public.prftcntr DROP CONSTRAINT prftcntr_prftcntr_number_key; publicadminfalse6066069635g260683326 priv_pkey CONSTRAINTJALTER TABLE ONLY priv ADD CONSTRAINT priv_pkey PRIMARY KEY (priv_id); 8ALTER TABLE ONLY public.priv DROP CONSTRAINT priv_pkey; publicadminfalse2972979635;260683328prj_pkey CONSTRAINTGALTER TABLE ONLY prj ADD CONSTRAINT prj_pkey PRIMARY KEY (prj_id); 6ALTER TABLE ONLY public.prj DROP CONSTRAINT prj_pkey; publicadminfalse2062069635=260683330prj_prj_number_key CONSTRAINTPALTER TABLE ONLY prj ADD CONSTRAINT prj_prj_number_key UNIQUE (prj_number); @ALTER TABLE ONLY public.prj DROP CONSTRAINT prj_prj_number_key; publicadminfalse2062069635O260683332 prjtask_pkey CONSTRAINTSALTER TABLE ONLY prjtask ADD CONSTRAINT prjtask_pkey PRIMARY KEY (prjtask_id); >ALTER TABLE ONLY public.prjtask DROP CONSTRAINT prjtask_pkey; publicadminfalse2112119635Q260683334prjtask_prjtask_prj_id_key CONSTRAINTpALTER TABLE ONLY prjtask ADD CONSTRAINT prjtask_prjtask_prj_id_key UNIQUE (prjtask_prj_id, prjtask_number); LALTER TABLE ONLY public.prjtask DROP CONSTRAINT prjtask_prjtask_prj_id_key; publicadminfalse2112112119635260683336prjtaskuser_pkey CONSTRAINT_ALTER TABLE ONLY prjtaskuser ADD CONSTRAINT prjtaskuser_pkey PRIMARY KEY (prjtaskuser_id); FALTER TABLE ONLY public.prjtaskuser DROP CONSTRAINT prjtaskuser_pkey; publicadminfalse6126129635260683338 prodcat_pkey CONSTRAINTSALTER TABLE ONLY prodcat ADD CONSTRAINT prodcat_pkey PRIMARY KEY (prodcat_id); >ALTER TABLE ONLY public.prodcat DROP CONSTRAINT prodcat_pkey; publicadminfalse2532539635260683340prodcat_prodcat_code_key CONSTRAINT\ALTER TABLE ONLY prodcat ADD CONSTRAINT prodcat_prodcat_code_key UNIQUE (prodcat_code); JALTER TABLE ONLY public.prodcat DROP CONSTRAINT prodcat_prodcat_code_key; publicadminfalse2532539635260683342 prospect_pkey CONSTRAINTVALTER TABLE ONLY prospect ADD CONSTRAINT prospect_pkey PRIMARY KEY (prospect_id); @ALTER TABLE ONLY public.prospect DROP CONSTRAINT prospect_pkey; publicadminfalse2722729635 260683344prospect_prospect_number_key CONSTRAINTdALTER TABLE ONLY prospect ADD CONSTRAINT prospect_prospect_number_key UNIQUE (prospect_number); OALTER TABLE ONLY public.prospect DROP CONSTRAINT prospect_prospect_number_key; publicadminfalse2722729635260683346 qryhead_pkey CONSTRAINTSALTER TABLE ONLY qryhead ADD CONSTRAINT qryhead_pkey PRIMARY KEY (qryhead_id); >ALTER TABLE ONLY public.qryhead DROP CONSTRAINT qryhead_pkey; publicadminfalse6176179635260683348qryhead_qryhead_name_key CONSTRAINT\ALTER TABLE ONLY qryhead ADD CONSTRAINT qryhead_qryhead_name_key UNIQUE (qryhead_name); JALTER TABLE ONLY public.qryhead DROP CONSTRAINT qryhead_qryhead_name_key; publicadminfalse6176179635260683350qryitem_qryitem_qryhead_id_key CONSTRAINTvALTER TABLE ONLY qryitem ADD CONSTRAINT qryitem_qryitem_qryhead_id_key UNIQUE (qryitem_qryhead_id, qryitem_name); PALTER TABLE ONLY public.qryitem DROP CONSTRAINT qryitem_qryitem_qryhead_id_key; publicadminfalse6196196199635260683352qryitem_qryitem_qryhead_id_key1 CONSTRAINTxALTER TABLE ONLY qryitem ADD CONSTRAINT qryitem_qryitem_qryhead_id_key1 UNIQUE (qryitem_qryhead_id, qryitem_order); QALTER TABLE ONLY public.qryitem DROP CONSTRAINT qryitem_qryitem_qryhead_id_key1; publicadminfalse6196196199635.260683354 quhead_pkey CONSTRAINTPALTER TABLE ONLY quhead ADD CONSTRAINT quhead_pkey PRIMARY KEY (quhead_id); <ALTER TABLE ONLY public.quhead DROP CONSTRAINT quhead_pkey; publicadminfalse27727796350260683356quhead_quhead_number_key CONSTRAINT\ALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_number_key UNIQUE (quhead_number); IALTER TABLE ONLY public.quhead DROP CONSTRAINT quhead_quhead_number_key; publicadminfalse27727796352260683358 quitem_pkey CONSTRAINTPALTER TABLE ONLY quitem ADD CONSTRAINT quitem_pkey PRIMARY KEY (quitem_id); <ALTER TABLE ONLY public.quitem DROP CONSTRAINT quitem_pkey; publicadminfalse2782789635260683360 rcalitem_pkey CONSTRAINTVALTER TABLE ONLY rcalitem ADD CONSTRAINT rcalitem_pkey PRIMARY KEY (rcalitem_id); @ALTER TABLE ONLY public.rcalitem DROP CONSTRAINT rcalitem_pkey; publicadminfalse6236239635260683362 recur_pkey CONSTRAINTMALTER TABLE ONLY recur ADD CONSTRAINT recur_pkey PRIMARY KEY (recur_id); :ALTER TABLE ONLY public.recur DROP CONSTRAINT recur_pkey; publicadminfalse6246249635260683364recur_recur_parent_id_key CONSTRAINTqALTER TABLE ONLY recur ADD CONSTRAINT recur_recur_parent_id_key UNIQUE (recur_parent_id, recur_parent_type); IALTER TABLE ONLY public.recur DROP CONSTRAINT recur_recur_parent_id_key; publicadminfalse6246246249635260683366recurtype_pkey CONSTRAINTYALTER TABLE ONLY recurtype ADD CONSTRAINT recurtype_pkey PRIMARY KEY (recurtype_id); BALTER TABLE ONLY public.recurtype DROP CONSTRAINT recurtype_pkey; publicadminfalse6266269635260683368recurtype_recurtype_type_key CONSTRAINTdALTER TABLE ONLY recurtype ADD CONSTRAINT recurtype_recurtype_type_key UNIQUE (recurtype_type); PALTER TABLE ONLY public.recurtype DROP CONSTRAINT recurtype_recurtype_type_key; publicadminfalse6266269635260683370 recv_pkey CONSTRAINTJALTER TABLE ONLY recv ADD CONSTRAINT recv_pkey PRIMARY KEY (recv_id); 8ALTER TABLE ONLY public.recv DROP CONSTRAINT recv_pkey; publicadminfalse5995999635l260683372 report_pkey CONSTRAINTPALTER TABLE ONLY report ADD CONSTRAINT report_pkey PRIMARY KEY (report_id); <ALTER TABLE ONLY public.report DROP CONSTRAINT report_pkey; publicadminfalse3003009635260683374 rjctcode_pkey CONSTRAINTVALTER TABLE ONLY rjctcode ADD CONSTRAINT rjctcode_pkey PRIMARY KEY (rjctcode_id); @ALTER TABLE ONLY public.rjctcode DROP CONSTRAINT rjctcode_pkey; publicadminfalse6306309635260683376rjctcode_rjctcode_code_key CONSTRAINT`ALTER TABLE ONLY rjctcode ADD CONSTRAINT rjctcode_rjctcode_code_key UNIQUE (rjctcode_code); MALTER TABLE ONLY public.rjctcode DROP CONSTRAINT rjctcode_rjctcode_code_key; publicadminfalse6306309635260683378 rsncode_pkey CONSTRAINTSALTER TABLE ONLY rsncode ADD CONSTRAINT rsncode_pkey PRIMARY KEY (rsncode_id); >ALTER TABLE ONLY public.rsncode DROP CONSTRAINT rsncode_pkey; publicadminfalse1971979635260683380rsncode_rsncode_code_key CONSTRAINT\ALTER TABLE ONLY rsncode ADD CONSTRAINT rsncode_rsncode_code_key UNIQUE (rsncode_code); JALTER TABLE ONLY public.rsncode DROP CONSTRAINT rsncode_rsncode_code_key; publicadminfalse1971979635260683382 sale_pkey CONSTRAINTJALTER TABLE ONLY sale ADD CONSTRAINT sale_pkey PRIMARY KEY (sale_id); 8ALTER TABLE ONLY public.sale DROP CONSTRAINT sale_pkey; publicadminfalse6336339635260683384sale_sale_name_key CONSTRAINTPALTER TABLE ONLY sale ADD CONSTRAINT sale_sale_name_key UNIQUE (sale_name); AALTER TABLE ONLY public.sale DROP CONSTRAINT sale_sale_name_key; publicadminfalse6336339635 260683386salesaccnt_pkey CONSTRAINT\ALTER TABLE ONLY salesaccnt ADD CONSTRAINT salesaccnt_pkey PRIMARY KEY (salesaccnt_id); DALTER TABLE ONLY public.salesaccnt DROP CONSTRAINT salesaccnt_pkey; publicadminfalse4264269635260683388 salescat_pkey CONSTRAINTVALTER TABLE ONLY salescat ADD CONSTRAINT salescat_pkey PRIMARY KEY (salescat_id); @ALTER TABLE ONLY public.salescat DROP CONSTRAINT salescat_pkey; publicadminfalse1981989635260683390salescat_salescat_name_key CONSTRAINT`ALTER TABLE ONLY salescat ADD CONSTRAINT salescat_salescat_name_key UNIQUE (salescat_name); MALTER TABLE ONLY public.salescat DROP CONSTRAINT salescat_salescat_name_key; publicadminfalse1981989635 260683392 salesrep_pkey CONSTRAINTVALTER TABLE ONLY salesrep ADD CONSTRAINT salesrep_pkey PRIMARY KEY (salesrep_id); @ALTER TABLE ONLY public.salesrep DROP CONSTRAINT salesrep_pkey; publicadminfalse1991999635"260683394salesrep_salesrep_number_key CONSTRAINTdALTER TABLE ONLY salesrep ADD CONSTRAINT salesrep_salesrep_number_key UNIQUE (salesrep_number); OALTER TABLE ONLY public.salesrep DROP CONSTRAINT salesrep_salesrep_number_key; publicadminfalse1991999635?260683396 saletype_pkey CONSTRAINTVALTER TABLE ONLY saletype ADD CONSTRAINT saletype_pkey PRIMARY KEY (saletype_id); @ALTER TABLE ONLY public.saletype DROP CONSTRAINT saletype_pkey; publicadminfalse2072079635260683398schemaord_pkey CONSTRAINTYALTER TABLE ONLY schemaord ADD CONSTRAINT schemaord_pkey PRIMARY KEY (schemaord_id); BALTER TABLE ONLY public.schemaord DROP CONSTRAINT schemaord_pkey; publicadminfalse6396399635 260683400schemaord_schemaord_name_key CONSTRAINTdALTER TABLE ONLY schemaord ADD CONSTRAINT schemaord_schemaord_name_key UNIQUE (schemaord_name); PALTER TABLE ONLY public.schemaord DROP CONSTRAINT schemaord_schemaord_name_key; publicadminfalse6396399635 260683402schemaord_schemaord_order_key CONSTRAINTfALTER TABLE ONLY schemaord ADD CONSTRAINT schemaord_schemaord_order_key UNIQUE (schemaord_order); QALTER TABLE ONLY public.schemaord DROP CONSTRAINT schemaord_schemaord_order_key; publicadminfalse6396399635p260683404 script_pkey CONSTRAINTPALTER TABLE ONLY script ADD CONSTRAINT script_pkey PRIMARY KEY (script_id); <ALTER TABLE ONLY public.script DROP CONSTRAINT script_pkey; publicadminfalse3033039635260683406 shift_pkey CONSTRAINTMALTER TABLE ONLY shift ADD CONSTRAINT shift_pkey PRIMARY KEY (shift_id); :ALTER TABLE ONLY public.shift DROP CONSTRAINT shift_pkey; publicadminfalse2432439635260683408 shipchrg_pkey CONSTRAINTVALTER TABLE ONLY shipchrg ADD CONSTRAINT shipchrg_pkey PRIMARY KEY (shipchrg_id); @ALTER TABLE ONLY public.shipchrg DROP CONSTRAINT shipchrg_pkey; publicadminfalse2372379635260683410 shipdata_pkey CONSTRAINTALTER TABLE ONLY shipdata ADD CONSTRAINT shipdata_pkey PRIMARY KEY (shipdata_cohead_number, shipdata_cosmisc_tracknum, shipdata_cosmisc_packnum_tracknum, shipdata_void_ind); @ALTER TABLE ONLY public.shipdata DROP CONSTRAINT shipdata_pkey; publicadminfalse2442442442442449635260683412shipdatasum_pkey CONSTRAINTALTER TABLE ONLY shipdatasum ADD CONSTRAINT shipdatasum_pkey PRIMARY KEY (shipdatasum_cohead_number, shipdatasum_cosmisc_tracknum, shipdatasum_cosmisc_packnum_tracknum); FALTER TABLE ONLY public.shipdatasum DROP CONSTRAINT shipdatasum_pkey; publicadminfalse6446446446449635260683414 shipform_pkey CONSTRAINTVALTER TABLE ONLY shipform ADD CONSTRAINT shipform_pkey PRIMARY KEY (shipform_id); @ALTER TABLE ONLY public.shipform DROP CONSTRAINT shipform_pkey; publicadminfalse2382389635260683416shipform_shipform_name_key CONSTRAINT`ALTER TABLE ONLY shipform ADD CONSTRAINT shipform_shipform_name_key UNIQUE (shipform_name); MALTER TABLE ONLY public.shipform DROP CONSTRAINT shipform_shipform_name_key; publicadminfalse2382389635260683418 shiphead_pkey CONSTRAINTVALTER TABLE ONLY shiphead ADD CONSTRAINT shiphead_pkey PRIMARY KEY (shiphead_id); @ALTER TABLE ONLY public.shiphead DROP CONSTRAINT shiphead_pkey; publicadminfalse4124129635260683420shiphead_shiphead_number_key CONSTRAINTdALTER TABLE ONLY shiphead ADD CONSTRAINT shiphead_shiphead_number_key UNIQUE (shiphead_number); OALTER TABLE ONLY public.shiphead DROP CONSTRAINT shiphead_shiphead_number_key; publicadminfalse4124129635260683422 shipitem_pkey CONSTRAINTVALTER TABLE ONLY shipitem ADD CONSTRAINT shipitem_pkey PRIMARY KEY (shipitem_id); @ALTER TABLE ONLY public.shipitem DROP CONSTRAINT shipitem_pkey; publicadminfalse4134139635)260683424shipto_num_cust_unique CONSTRAINTkALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shipto_num_cust_unique UNIQUE (shipto_cust_id, shipto_num); KALTER TABLE ONLY public.shiptoinfo DROP CONSTRAINT shipto_num_cust_unique; publicadminfalse2022022029635+260683426 shipto_pkey CONSTRAINTTALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shipto_pkey PRIMARY KEY (shipto_id); @ALTER TABLE ONLY public.shiptoinfo DROP CONSTRAINT shipto_pkey; publicadminfalse2022029635J260683428 shipvia_pkey CONSTRAINTSALTER TABLE ONLY shipvia ADD CONSTRAINT shipvia_pkey PRIMARY KEY (shipvia_id); >ALTER TABLE ONLY public.shipvia DROP CONSTRAINT shipvia_pkey; publicadminfalse2832839635L260683430shipvia_shipvia_code_key CONSTRAINT\ALTER TABLE ONLY shipvia ADD CONSTRAINT shipvia_shipvia_code_key UNIQUE (shipvia_code); JALTER TABLE ONLY public.shipvia DROP CONSTRAINT shipvia_shipvia_code_key; publicadminfalse2832839635A260683432 shipzone_pkey CONSTRAINTVALTER TABLE ONLY shipzone ADD CONSTRAINT shipzone_pkey PRIMARY KEY (shipzone_id); @ALTER TABLE ONLY public.shipzone DROP CONSTRAINT shipzone_pkey; publicadminfalse2082089635C260683434shipzone_shipzone_name_key CONSTRAINT`ALTER TABLE ONLY shipzone ADD CONSTRAINT shipzone_shipzone_name_key UNIQUE (shipzone_name); MALTER TABLE ONLY public.shipzone DROP CONSTRAINT shipzone_shipzone_name_key; publicadminfalse2082089635N260683436 sitetype_pkey CONSTRAINTVALTER TABLE ONLY sitetype ADD CONSTRAINT sitetype_pkey PRIMARY KEY (sitetype_id); @ALTER TABLE ONLY public.sitetype DROP CONSTRAINT sitetype_pkey; publicadminfalse2842849635P260683438sitetype_sitetype_name_key CONSTRAINT`ALTER TABLE ONLY sitetype ADD CONSTRAINT sitetype_sitetype_name_key UNIQUE (sitetype_name); MALTER TABLE ONLY public.sitetype DROP CONSTRAINT sitetype_sitetype_name_key; publicadminfalse2842849635260683440 sltrans_pkey CONSTRAINTSALTER TABLE ONLY sltrans ADD CONSTRAINT sltrans_pkey PRIMARY KEY (sltrans_id); >ALTER TABLE ONLY public.sltrans DROP CONSTRAINT sltrans_pkey; publicadminfalse6546549635260683442 source_pkey CONSTRAINTPALTER TABLE ONLY source ADD CONSTRAINT source_pkey PRIMARY KEY (source_id); <ALTER TABLE ONLY public.source DROP CONSTRAINT source_pkey; publicadminfalse6586589635260683444source_source_name_key CONSTRAINTXALTER TABLE ONLY source ADD CONSTRAINT source_source_name_key UNIQUE (source_name); GALTER TABLE ONLY public.source DROP CONSTRAINT source_source_name_key; publicadminfalse6586589635260683446 state_pkey CONSTRAINTMALTER TABLE ONLY state ADD CONSTRAINT state_pkey PRIMARY KEY (state_id); :ALTER TABLE ONLY public.state DROP CONSTRAINT state_pkey; publicadminfalse6606609635260683448state_state_country_id_key CONSTRAINTlALTER TABLE ONLY state ADD CONSTRAINT state_state_country_id_key UNIQUE (state_country_id, state_name); JALTER TABLE ONLY public.state DROP CONSTRAINT state_state_country_id_key; publicadminfalse6606606609635260683450 status_pkey CONSTRAINTPALTER TABLE ONLY status ADD CONSTRAINT status_pkey PRIMARY KEY (status_id); <ALTER TABLE ONLY public.status DROP CONSTRAINT status_pkey; publicadminfalse6626629635!260683452status_status_type_key CONSTRAINTeALTER TABLE ONLY status ADD CONSTRAINT status_status_type_key UNIQUE (status_type, status_code); GALTER TABLE ONLY public.status DROP CONSTRAINT status_status_type_key; publicadminfalse6626626629635#260683454 stdjrnl_pkey CONSTRAINTSALTER TABLE ONLY stdjrnl ADD CONSTRAINT stdjrnl_pkey PRIMARY KEY (stdjrnl_id); >ALTER TABLE ONLY public.stdjrnl DROP CONSTRAINT stdjrnl_pkey; publicadminfalse6646649635%260683456stdjrnl_stdjrnl_name_key CONSTRAINT\ALTER TABLE ONLY stdjrnl ADD CONSTRAINT stdjrnl_stdjrnl_name_key UNIQUE (stdjrnl_name); JALTER TABLE ONLY public.stdjrnl DROP CONSTRAINT stdjrnl_stdjrnl_name_key; publicadminfalse6646649635'260683458stdjrnlgrp_pkey CONSTRAINT\ALTER TABLE ONLY stdjrnlgrp ADD CONSTRAINT stdjrnlgrp_pkey PRIMARY KEY (stdjrnlgrp_id); DALTER TABLE ONLY public.stdjrnlgrp DROP CONSTRAINT stdjrnlgrp_pkey; publicadminfalse6666669635)260683460stdjrnlgrp_stdjrnlgrp_name_key CONSTRAINThALTER TABLE ONLY stdjrnlgrp ADD CONSTRAINT stdjrnlgrp_stdjrnlgrp_name_key UNIQUE (stdjrnlgrp_name); SALTER TABLE ONLY public.stdjrnlgrp DROP CONSTRAINT stdjrnlgrp_stdjrnlgrp_name_key; publicadminfalse6666669635+260683462stdjrnlgrpitem_pkey CONSTRAINThALTER TABLE ONLY stdjrnlgrpitem ADD CONSTRAINT stdjrnlgrpitem_pkey PRIMARY KEY (stdjrnlgrpitem_id); LALTER TABLE ONLY public.stdjrnlgrpitem DROP CONSTRAINT stdjrnlgrpitem_pkey; publicadminfalse6686689635-260683464stdjrnlitem_pkey CONSTRAINT_ALTER TABLE ONLY stdjrnlitem ADD CONSTRAINT stdjrnlitem_pkey PRIMARY KEY (stdjrnlitem_id); FALTER TABLE ONLY public.stdjrnlitem DROP CONSTRAINT stdjrnlitem_pkey; publicadminfalse6706709635/260683466 subaccnt_pkey CONSTRAINTVALTER TABLE ONLY subaccnt ADD CONSTRAINT subaccnt_pkey PRIMARY KEY (subaccnt_id); @ALTER TABLE ONLY public.subaccnt DROP CONSTRAINT subaccnt_pkey; publicadminfalse67267296351260683468subaccnt_subaccnt_number_key CONSTRAINTdALTER TABLE ONLY subaccnt ADD CONSTRAINT subaccnt_subaccnt_number_key UNIQUE (subaccnt_number); OALTER TABLE ONLY public.subaccnt DROP CONSTRAINT subaccnt_subaccnt_number_key; publicadminfalse67267296354260683470subaccnttype_pkey CONSTRAINTbALTER TABLE ONLY subaccnttype ADD CONSTRAINT subaccnttype_pkey PRIMARY KEY (subaccnttype_id); HALTER TABLE ONLY public.subaccnttype DROP CONSTRAINT subaccnttype_pkey; publicadminfalse6746749635*260683472tax_pkey CONSTRAINTGALTER TABLE ONLY tax ADD CONSTRAINT tax_pkey PRIMARY KEY (tax_id); 6ALTER TABLE ONLY public.tax DROP CONSTRAINT tax_pkey; publicadminfalse27527596356260683474 taxass_pkey CONSTRAINTPALTER TABLE ONLY taxass ADD CONSTRAINT taxass_pkey PRIMARY KEY (taxass_id); <ALTER TABLE ONLY public.taxass DROP CONSTRAINT taxass_pkey; publicadminfalse67767796358260683476taxass_taxass_taxzone_id_key CONSTRAINTALTER TABLE ONLY taxass ADD CONSTRAINT taxass_taxass_taxzone_id_key UNIQUE (taxass_taxzone_id, taxass_taxtype_id, taxass_tax_id); MALTER TABLE ONLY public.taxass DROP CONSTRAINT taxass_taxass_taxzone_id_key; publicadminfalse6776776776779635260683478 taxauth_pkey CONSTRAINTSALTER TABLE ONLY taxauth ADD CONSTRAINT taxauth_pkey PRIMARY KEY (taxauth_id); >ALTER TABLE ONLY public.taxauth DROP CONSTRAINT taxauth_pkey; publicadminfalse2392399635260683480taxauth_taxauth_code_key CONSTRAINT\ALTER TABLE ONLY taxauth ADD CONSTRAINT taxauth_taxauth_code_key UNIQUE (taxauth_code); JALTER TABLE ONLY public.taxauth DROP CONSTRAINT taxauth_taxauth_code_key; publicadminfalse2392399635:260683482 taxclass_pkey CONSTRAINTVALTER TABLE ONLY taxclass ADD CONSTRAINT taxclass_pkey PRIMARY KEY (taxclass_id); @ALTER TABLE ONLY public.taxclass DROP CONSTRAINT taxclass_pkey; publicadminfalse6806809635<260683484taxclass_taxclass_code_key CONSTRAINT`ALTER TABLE ONLY taxclass ADD CONSTRAINT taxclass_taxclass_code_key UNIQUE (taxclass_code); MALTER TABLE ONLY public.taxclass DROP CONSTRAINT taxclass_taxclass_code_key; publicadminfalse6806809635@260683486 taxhist_pkey CONSTRAINTSALTER TABLE ONLY taxhist ADD CONSTRAINT taxhist_pkey PRIMARY KEY (taxhist_id); >ALTER TABLE ONLY public.taxhist DROP CONSTRAINT taxhist_pkey; publicadminfalse2812819635260687567 taxpay_pkey CONSTRAINTPALTER TABLE ONLY taxpay ADD CONSTRAINT taxpay_pkey PRIMARY KEY (taxpay_id); <ALTER TABLE ONLY public.taxpay DROP CONSTRAINT taxpay_pkey; publicadminfalse7887889635>260683488 taxrate_pkey CONSTRAINTSALTER TABLE ONLY taxrate ADD CONSTRAINT taxrate_pkey PRIMARY KEY (taxrate_id); >ALTER TABLE ONLY public.taxrate DROP CONSTRAINT taxrate_pkey; publicadminfalse6836839635260683490 taxreg_pkey CONSTRAINTPALTER TABLE ONLY taxreg ADD CONSTRAINT taxreg_pkey PRIMARY KEY (taxreg_id); <ALTER TABLE ONLY public.taxreg DROP CONSTRAINT taxreg_pkey; publicadminfalse2402409635260683492 taxtype_pkey CONSTRAINTSALTER TABLE ONLY taxtype ADD CONSTRAINT taxtype_pkey PRIMARY KEY (taxtype_id); >ALTER TABLE ONLY public.taxtype DROP CONSTRAINT taxtype_pkey; publicadminfalse1821829635260683494taxtype_taxtype_name_key CONSTRAINT\ALTER TABLE ONLY taxtype ADD CONSTRAINT taxtype_taxtype_name_key UNIQUE (taxtype_name); JALTER TABLE ONLY public.taxtype DROP CONSTRAINT taxtype_taxtype_name_key; publicadminfalse1821829635-260683496 taxzone_pkey CONSTRAINTSALTER TABLE ONLY taxzone ADD CONSTRAINT taxzone_pkey PRIMARY KEY (taxzone_id); >ALTER TABLE ONLY public.taxzone DROP CONSTRAINT taxzone_pkey; publicadminfalse2032039635/260683498taxzone_taxzone_code_key CONSTRAINT\ALTER TABLE ONLY taxzone ADD CONSTRAINT taxzone_taxzone_code_key UNIQUE (taxzone_code); JALTER TABLE ONLY public.taxzone DROP CONSTRAINT taxzone_taxzone_code_key; publicadminfalse2032039635260683500 terms_pkey CONSTRAINTMALTER TABLE ONLY terms ADD CONSTRAINT terms_pkey PRIMARY KEY (terms_id); :ALTER TABLE ONLY public.terms DROP CONSTRAINT terms_pkey; publicadminfalse1921929635260683502terms_terms_code_key CONSTRAINTTALTER TABLE ONLY terms ADD CONSTRAINT terms_terms_code_key UNIQUE (terms_code); DALTER TABLE ONLY public.terms DROP CONSTRAINT terms_terms_code_key; publicadminfalse1921929635S260683504 todoitem_pkey CONSTRAINTVALTER TABLE ONLY todoitem ADD CONSTRAINT todoitem_pkey PRIMARY KEY (todoitem_id); @ALTER TABLE ONLY public.todoitem DROP CONSTRAINT todoitem_pkey; publicadminfalse2122129635A260683506 trialbal_pkey CONSTRAINTVALTER TABLE ONLY trialbal ADD CONSTRAINT trialbal_pkey PRIMARY KEY (trialbal_id); @ALTER TABLE ONLY public.trialbal DROP CONSTRAINT trialbal_pkey; publicadminfalse6916919635t260683508 uiform_pkey CONSTRAINTPALTER TABLE ONLY uiform ADD CONSTRAINT uiform_pkey PRIMARY KEY (uiform_id); <ALTER TABLE ONLY public.uiform DROP CONSTRAINT uiform_pkey; publicadminfalse3063069635260683510unq_prjtype_code CONSTRAINTTALTER TABLE ONLY prjtype ADD CONSTRAINT unq_prjtype_code UNIQUE (prjtype_code); BALTER TABLE ONLY public.prjtype DROP CONSTRAINT unq_prjtype_code; publicadminfalse6146149635260683512uom_pkey CONSTRAINTGALTER TABLE ONLY uom ADD CONSTRAINT uom_pkey PRIMARY KEY (uom_id); 6ALTER TABLE ONLY public.uom DROP CONSTRAINT uom_pkey; publicadminfalse1831839635260683514uom_uom_name_key CONSTRAINTLALTER TABLE ONLY uom ADD CONSTRAINT uom_uom_name_key UNIQUE (uom_name); >ALTER TABLE ONLY public.uom DROP CONSTRAINT uom_uom_name_key; publicadminfalse1831839635C260683516 uomconv_pkey CONSTRAINTSALTER TABLE ONLY uomconv ADD CONSTRAINT uomconv_pkey PRIMARY KEY (uomconv_id); >ALTER TABLE ONLY public.uomconv DROP CONSTRAINT uomconv_pkey; publicadminfalse6946949635E260683518 uomtype_pkey CONSTRAINTSALTER TABLE ONLY uomtype ADD CONSTRAINT uomtype_pkey PRIMARY KEY (uomtype_id); >ALTER TABLE ONLY public.uomtype DROP CONSTRAINT uomtype_pkey; publicadminfalse6966969635G260683520uomtype_uomtype_name_key CONSTRAINT\ALTER TABLE ONLY uomtype ADD CONSTRAINT uomtype_uomtype_name_key UNIQUE (uomtype_name); JALTER TABLE ONLY public.uomtype DROP CONSTRAINT uomtype_uomtype_name_key; publicadminfalse6966969635q260683522 urlinfo_pkey CONSTRAINTOALTER TABLE ONLY urlinfo ADD CONSTRAINT urlinfo_pkey PRIMARY KEY (url_id); >ALTER TABLE ONLY public.urlinfo DROP CONSTRAINT urlinfo_pkey; publicadminfalse2202209635L260683524usr_pkey CONSTRAINTKALTER TABLE ONLY usr_bak ADD CONSTRAINT usr_pkey PRIMARY KEY (usr_id); :ALTER TABLE ONLY public.usr_bak DROP CONSTRAINT usr_pkey; publicadminfalse7017019635N260683526usr_usr_username_key CONSTRAINTXALTER TABLE ONLY usr_bak ADD CONSTRAINT usr_usr_username_key UNIQUE (usr_username); FALTER TABLE ONLY public.usr_bak DROP CONSTRAINT usr_usr_username_key; publicadminfalse7017019635260683528 usrgrp_pkey CONSTRAINTPALTER TABLE ONLY usrgrp ADD CONSTRAINT usrgrp_pkey PRIMARY KEY (usrgrp_id); <ALTER TABLE ONLY public.usrgrp DROP CONSTRAINT usrgrp_pkey; publicadminfalse6086089635I260683530 usrpref_pkey CONSTRAINTSALTER TABLE ONLY usrpref ADD CONSTRAINT usrpref_pkey PRIMARY KEY (usrpref_id); >ALTER TABLE ONLY public.usrpref DROP CONSTRAINT usrpref_pkey; publicadminfalse6996999635260683532 usrpriv_pkey CONSTRAINTSALTER TABLE ONLY usrpriv ADD CONSTRAINT usrpriv_pkey PRIMARY KEY (usrpriv_id); >ALTER TABLE ONLY public.usrpriv DROP CONSTRAINT usrpriv_pkey; publicadminfalse6096099635260683534 vend_pkey CONSTRAINTNALTER TABLE ONLY vendinfo ADD CONSTRAINT vend_pkey PRIMARY KEY (vend_id); <ALTER TABLE ONLY public.vendinfo DROP CONSTRAINT vend_pkey; publicadminfalse1931939635,260683536 vendaddr_pkey CONSTRAINTZALTER TABLE ONLY vendaddrinfo ADD CONSTRAINT vendaddr_pkey PRIMARY KEY (vendaddr_id); DALTER TABLE ONLY public.vendaddrinfo DROP CONSTRAINT vendaddr_pkey; publicadminfalse2762769635 260683538vendinfo_vend_number_key CONSTRAINT\ALTER TABLE ONLY vendinfo ADD CONSTRAINT vendinfo_vend_number_key UNIQUE (vend_number); KALTER TABLE ONLY public.vendinfo DROP CONSTRAINT vendinfo_vend_number_key; publicadminfalse1931939635R260683540 vendtype_pkey CONSTRAINTVALTER TABLE ONLY vendtype ADD CONSTRAINT vendtype_pkey PRIMARY KEY (vendtype_id); @ALTER TABLE ONLY public.vendtype DROP CONSTRAINT vendtype_pkey; publicadminfalse2852859635T260683542vendtype_vendtype_code_key CONSTRAINT`ALTER TABLE ONLY vendtype ADD CONSTRAINT vendtype_vendtype_code_key UNIQUE (vendtype_code); MALTER TABLE ONLY public.vendtype DROP CONSTRAINT vendtype_vendtype_code_key; publicadminfalse2852859635P260683544 vodist_pkey CONSTRAINTPALTER TABLE ONLY vodist ADD CONSTRAINT vodist_pkey PRIMARY KEY (vodist_id); <ALTER TABLE ONLY public.vodist DROP CONSTRAINT vodist_pkey; publicadminfalse7117119635R260683546 vohead_pkey CONSTRAINTPALTER TABLE ONLY vohead ADD CONSTRAINT vohead_pkey PRIMARY KEY (vohead_id); <ALTER TABLE ONLY public.vohead DROP CONSTRAINT vohead_pkey; publicadminfalse7137139635T260683548vohead_vohead_number_key CONSTRAINT\ALTER TABLE ONLY vohead ADD CONSTRAINT vohead_vohead_number_key UNIQUE (vohead_number); IALTER TABLE ONLY public.vohead DROP CONSTRAINT vohead_vohead_number_key; publicadminfalse7137139635V260683550voheadtax_pkey CONSTRAINTWALTER TABLE ONLY voheadtax ADD CONSTRAINT voheadtax_pkey PRIMARY KEY (taxhist_id); BALTER TABLE ONLY public.voheadtax DROP CONSTRAINT voheadtax_pkey; publicadminfalse7157159635[260683552 voitem_pkey CONSTRAINTPALTER TABLE ONLY voitem ADD CONSTRAINT voitem_pkey PRIMARY KEY (voitem_id); <ALTER TABLE ONLY public.voitem DROP CONSTRAINT voitem_pkey; publicadminfalse7167169635]260683554voitemtax_pkey CONSTRAINTWALTER TABLE ONLY voitemtax ADD CONSTRAINT voitemtax_pkey PRIMARY KEY (taxhist_id); BALTER TABLE ONLY public.voitemtax DROP CONSTRAINT voitemtax_pkey; publicadminfalse7187189635260683556 warehous_pkey CONSTRAINTUALTER TABLE ONLY whsinfo ADD CONSTRAINT warehous_pkey PRIMARY KEY (warehous_id); ?ALTER TABLE ONLY public.whsinfo DROP CONSTRAINT warehous_pkey; publicadminfalse1761769635 260683558 whsezone_pkey CONSTRAINTVALTER TABLE ONLY whsezone ADD CONSTRAINT whsezone_pkey PRIMARY KEY (whsezone_id); @ALTER TABLE ONLY public.whsezone DROP CONSTRAINT whsezone_pkey; publicadminfalse2672679635260683560whsinfo_warehous_code_key CONSTRAINT^ALTER TABLE ONLY whsinfo ADD CONSTRAINT whsinfo_warehous_code_key UNIQUE (warehous_code); KALTER TABLE ONLY public.whsinfo DROP CONSTRAINT whsinfo_warehous_code_key; publicadminfalse1761769635!260683562wo_pkey CONSTRAINTDALTER TABLE ONLY wo ADD CONSTRAINT wo_pkey PRIMARY KEY (wo_id); 4ALTER TABLE ONLY public.wo DROP CONSTRAINT wo_pkey; publicadminfalse4444449635'260683564 womatl_pkey CONSTRAINTPALTER TABLE ONLY womatl ADD CONSTRAINT womatl_pkey PRIMARY KEY (womatl_id); <ALTER TABLE ONLY public.womatl DROP CONSTRAINT womatl_pkey; publicadminfalse2742749635b260683566womatlpost_pkey CONSTRAINT\ALTER TABLE ONLY womatlpost ADD CONSTRAINT womatlpost_pkey PRIMARY KEY (womatlpost_id); DALTER TABLE ONLY public.womatlpost DROP CONSTRAINT womatlpost_pkey; publicadminfalse7247249635e260683568womatlvar_pkey CONSTRAINTYALTER TABLE ONLY womatlvar ADD CONSTRAINT womatlvar_pkey PRIMARY KEY (womatlvar_id); BALTER TABLE ONLY public.womatlvar DROP CONSTRAINT womatlvar_pkey; publicadminfalse7267269635g260683570xsltmap_name_key CONSTRAINTTALTER TABLE ONLY xsltmap ADD CONSTRAINT xsltmap_name_key UNIQUE (xsltmap_name); BALTER TABLE ONLY public.xsltmap DROP CONSTRAINT xsltmap_name_key; publicadminfalse7297299635i260683572 xsltmap_pkey CONSTRAINTSALTER TABLE ONLY xsltmap ADD CONSTRAINT xsltmap_pkey PRIMARY KEY (xsltmap_id); >ALTER TABLE ONLY public.xsltmap DROP CONSTRAINT xsltmap_pkey; publicadminfalse7297299635k260683574yearperiod_pkey CONSTRAINT\ALTER TABLE ONLY yearperiod ADD CONSTRAINT yearperiod_pkey PRIMARY KEY (yearperiod_id); DALTER TABLE ONLY public.yearperiod DROP CONSTRAINT yearperiod_pkey; publicadminfalse7317319635m260683576 pkgcmd_pkey CONSTRAINTMALTER TABLE ONLY pkgcmd ADD CONSTRAINT pkgcmd_pkey PRIMARY KEY (cmd_id); 8ALTER TABLE ONLY te.pkgcmd DROP CONSTRAINT pkgcmd_pkey; teadminfalse7337339635o260683578pkgcmdarg_pkey CONSTRAINTVALTER TABLE ONLY pkgcmdarg ADD CONSTRAINT pkgcmdarg_pkey PRIMARY KEY (cmdarg_id); >ALTER TABLE ONLY te.pkgcmdarg DROP CONSTRAINT pkgcmdarg_pkey; teadminfalse7347349635q260683580 pkgimage_pkey CONSTRAINTSALTER TABLE ONLY pkgimage ADD CONSTRAINT pkgimage_pkey PRIMARY KEY (image_id); <ALTER TABLE ONLY te.pkgimage DROP CONSTRAINT pkgimage_pkey; teadminfalse7357359635s260683582pkgmetasql_pkey CONSTRAINTYALTER TABLE ONLY pkgmetasql ADD CONSTRAINT pkgmetasql_pkey PRIMARY KEY (metasql_id); @ALTER TABLE ONLY te.pkgmetasql DROP CONSTRAINT pkgmetasql_pkey; teadminfalse7367369635u260683584 pkgpriv_pkey CONSTRAINTPALTER TABLE ONLY pkgpriv ADD CONSTRAINT pkgpriv_pkey PRIMARY KEY (priv_id); :ALTER TABLE ONLY te.pkgpriv DROP CONSTRAINT pkgpriv_pkey; teadminfalse7377379635w260683586pkgreport_pkey CONSTRAINTVALTER TABLE ONLY pkgreport ADD CONSTRAINT pkgreport_pkey PRIMARY KEY (report_id); >ALTER TABLE ONLY te.pkgreport DROP CONSTRAINT pkgreport_pkey; teadminfalse7387389635y260683588pkgscript_pkey CONSTRAINTVALTER TABLE ONLY pkgscript ADD CONSTRAINT pkgscript_pkey PRIMARY KEY (script_id); >ALTER TABLE ONLY te.pkgscript DROP CONSTRAINT pkgscript_pkey; teadminfalse7397399635{260683590pkguiform_pkey CONSTRAINTVALTER TABLE ONLY pkguiform ADD CONSTRAINT pkguiform_pkey PRIMARY KEY (uiform_id); >ALTER TABLE ONLY te.pkguiform DROP CONSTRAINT pkguiform_pkey; teadminfalse7407409635}260683592tecustrate_pkey CONSTRAINTaALTER TABLE ONLY tecustrate ADD CONSTRAINT tecustrate_pkey PRIMARY KEY (tecustrate_cust_id); @ALTER TABLE ONLY te.tecustrate DROP CONSTRAINT tecustrate_pkey; teadminfalse7417419635260683594 teexp_pkey CONSTRAINTMALTER TABLE ONLY teexp ADD CONSTRAINT teexp_pkey PRIMARY KEY (teexp_id); 6ALTER TABLE ONLY te.teexp DROP CONSTRAINT teexp_pkey; teadminfalse7457459635260683596 tehead_pkey CONSTRAINTPALTER TABLE ONLY tehead ADD CONSTRAINT tehead_pkey PRIMARY KEY (tehead_id); 8ALTER TABLE ONLY te.tehead DROP CONSTRAINT tehead_pkey; teadminfalse7477479635260683598 teitem_pkey CONSTRAINTPALTER TABLE ONLY teitem ADD CONSTRAINT teitem_pkey PRIMARY KEY (teitem_id); 8ALTER TABLE ONLY te.teitem DROP CONSTRAINT teitem_pkey; teadminfalse7497499635260683600 teprj_pkey CONSTRAINTMALTER TABLE ONLY teprj ADD CONSTRAINT teprj_pkey PRIMARY KEY (teprj_id); 6ALTER TABLE ONLY te.teprj DROP CONSTRAINT teprj_pkey; teadminfalse75175196352606153492teprj_teprj_prj_id CONSTRAINTTALTER TABLE ONLY teprj ADD CONSTRAINT teprj_teprj_prj_id UNIQUE (teprj_prj_id); >ALTER TABLE ONLY te.teprj DROP CONSTRAINT teprj_teprj_prj_id; teadminfalse7517519635260683602teprjtask_pkey CONSTRAINTYALTER TABLE ONLY teprjtask ADD CONSTRAINT teprjtask_pkey PRIMARY KEY (teprjtask_id); >ALTER TABLE ONLY te.teprjtask DROP CONSTRAINT teprjtask_pkey; teadminfalse7537539635260683604"teprjtask_teprjtask_prjtask_id_key CONSTRAINTpALTER TABLE ONLY teprjtask ADD CONSTRAINT teprjtask_teprjtask_prjtask_id_key UNIQUE (teprjtask_prjtask_id); RALTER TABLE ONLY te.teprjtask DROP CONSTRAINT teprjtask_teprjtask_prjtask_id_key; teadminfalse7537539635260686851"js_js_namespace_js_type_js_context CONSTRAINTvALTER TABLE ONLY js ADD CONSTRAINT js_js_namespace_js_type_js_context UNIQUE (js_namespace, js_type, js_context); KALTER TABLE ONLY xt.js DROP CONSTRAINT js_js_namespace_js_type_js_context; xtadminfalse7637637637639635260686826js_pkey CONSTRAINTDALTER TABLE ONLY js ADD CONSTRAINT js_pkey PRIMARY KEY (js_id); 0ALTER TABLE ONLY xt.js DROP CONSTRAINT js_pkey; xtadminfalse7637639635260683606 pkgcmd_pkey CONSTRAINTMALTER TABLE ONLY pkgcmd ADD CONSTRAINT pkgcmd_pkey PRIMARY KEY (cmd_id); ?ALTER TABLE ONLY xtdesktop.pkgcmd DROP CONSTRAINT pkgcmd_pkey;  xtdesktopadminfalse7557559635260683608pkgcmdarg_pkey CONSTRAINTVALTER TABLE ONLY pkgcmdarg ADD CONSTRAINT pkgcmdarg_pkey PRIMARY KEY (cmdarg_id); EALTER TABLE ONLY xtdesktop.pkgcmdarg DROP CONSTRAINT pkgcmdarg_pkey;  xtdesktopadminfalse7567569635260683610 pkgimage_pkey CONSTRAINTSALTER TABLE ONLY pkgimage ADD CONSTRAINT pkgimage_pkey PRIMARY KEY (image_id); CALTER TABLE ONLY xtdesktop.pkgimage DROP CONSTRAINT pkgimage_pkey;  xtdesktopadminfalse7577579635260683612pkgmetasql_pkey CONSTRAINTYALTER TABLE ONLY pkgmetasql ADD CONSTRAINT pkgmetasql_pkey PRIMARY KEY (metasql_id); GALTER TABLE ONLY xtdesktop.pkgmetasql DROP CONSTRAINT pkgmetasql_pkey;  xtdesktopadminfalse7587589635260683614 pkgpriv_pkey CONSTRAINTPALTER TABLE ONLY pkgpriv ADD CONSTRAINT pkgpriv_pkey PRIMARY KEY (priv_id); AALTER TABLE ONLY xtdesktop.pkgpriv DROP CONSTRAINT pkgpriv_pkey;  xtdesktopadminfalse7597599635260683616pkgreport_pkey CONSTRAINTVALTER TABLE ONLY pkgreport ADD CONSTRAINT pkgreport_pkey PRIMARY KEY (report_id); EALTER TABLE ONLY xtdesktop.pkgreport DROP CONSTRAINT pkgreport_pkey;  xtdesktopadminfalse7607609635260683618pkgscript_pkey CONSTRAINTVALTER TABLE ONLY pkgscript ADD CONSTRAINT pkgscript_pkey PRIMARY KEY (script_id); EALTER TABLE ONLY xtdesktop.pkgscript DROP CONSTRAINT pkgscript_pkey;  xtdesktopadminfalse7617619635260683620pkguiform_pkey CONSTRAINTVALTER TABLE ONLY pkguiform ADD CONSTRAINT pkguiform_pkey PRIMARY KEY (uiform_id); EALTER TABLE ONLY xtdesktop.pkguiform DROP CONSTRAINT pkguiform_pkey;  xtdesktopadminfalse7627629635125983621accnt_unique_idxINDEXrCREATE UNIQUE INDEX accnt_unique_idx ON accnt USING btree (accnt_number, accnt_profit, accnt_sub, accnt_company); $DROP INDEX public.accnt_unique_idx; publicadminfalse2282282282289635125983622apopen_apopen_open_idxINDEXICREATE INDEX apopen_apopen_open_idx ON apopen USING btree (apopen_open); *DROP INDEX public.apopen_apopen_open_idx; publicadminfalse1909635125983623apopen_apopen_vend_id_idxINDEXOCREATE INDEX apopen_apopen_vend_id_idx ON apopen USING btree (apopen_vend_id); -DROP INDEX public.apopen_apopen_vend_id_idx; publicadminfalse1909635125986864apopentax_taxhist_parent_id_idxINDEX[CREATE INDEX apopentax_taxhist_parent_id_idx ON apopentax USING btree (taxhist_parent_id); 3DROP INDEX public.apopentax_taxhist_parent_id_idx; publicadminfalse3269635125986866!apopentax_taxhist_parent_type_idxINDEXqCREATE INDEX apopentax_taxhist_parent_type_idx ON apopentax USING btree (taxhist_parent_id, taxhist_taxtype_id); 5DROP INDEX public.apopentax_taxhist_parent_type_idx; publicadminfalse3263269635125986865 apopentax_taxhist_taxtype_id_idxINDEX]CREATE INDEX apopentax_taxhist_taxtype_id_idx ON apopentax USING btree (taxhist_taxtype_id); 4DROP INDEX public.apopentax_taxhist_taxtype_id_idx; publicadminfalse3269635125983624apselect_apselect_apopen_id_idxINDEX[CREATE INDEX apselect_apselect_apopen_id_idx ON apselect USING btree (apselect_apopen_id); 3DROP INDEX public.apselect_apselect_apopen_id_idx; publicadminfalse3279635125983625$arapply_arapply_target_docnumber_idxINDEXeCREATE INDEX arapply_arapply_target_docnumber_idx ON arapply USING btree (arapply_target_docnumber); 8DROP INDEX public.arapply_arapply_target_docnumber_idx; publicadminfalse3319635 125983626aropen_aropen_cust_id_idxINDEXOCREATE INDEX aropen_aropen_cust_id_idx ON aropen USING btree (aropen_cust_id); -DROP INDEX public.aropen_aropen_cust_id_idx; publicadminfalse1959635 125983627aropen_aropen_docnumber_idxINDEXSCREATE INDEX aropen_aropen_docnumber_idx ON aropen USING btree (aropen_docnumber); /DROP INDEX public.aropen_aropen_docnumber_idx; publicadminfalse1959635 125983628aropen_aropen_doctype_idxINDEXOCREATE INDEX aropen_aropen_doctype_idx ON aropen USING btree (aropen_doctype); -DROP INDEX public.aropen_aropen_doctype_idx; publicadminfalse1959635125983629aropen_aropen_open_idxINDEXICREATE INDEX aropen_aropen_open_idx ON aropen USING btree (aropen_open); *DROP INDEX public.aropen_aropen_open_idx; publicadminfalse1959635125983630aropen_posted_idxINDEXFCREATE INDEX aropen_posted_idx ON aropen USING btree (aropen_posted); %DROP INDEX public.aropen_posted_idx; publicadminfalse19596354125983631aropenalloc_aropen_id_idxINDEX[CREATE INDEX aropenalloc_aropen_id_idx ON aropenalloc USING btree (aropenalloc_aropen_id); -DROP INDEX public.aropenalloc_aropen_id_idx; publicadminfalse27996355125983632aropenalloc_doc_id_idxINDEXUCREATE INDEX aropenalloc_doc_id_idx ON aropenalloc USING btree (aropenalloc_doc_id); *DROP INDEX public.aropenalloc_doc_id_idx; publicadminfalse2799635125986867aropentax_taxhist_parent_id_idxINDEX[CREATE INDEX aropentax_taxhist_parent_id_idx ON aropentax USING btree (taxhist_parent_id); 3DROP INDEX public.aropentax_taxhist_parent_id_idx; publicadminfalse3389635125986869!aropentax_taxhist_parent_type_idxINDEXqCREATE INDEX aropentax_taxhist_parent_type_idx ON aropentax USING btree (taxhist_parent_id, taxhist_taxtype_id); 5DROP INDEX public.aropentax_taxhist_parent_type_idx; publicadminfalse3383389635125986868 aropentax_taxhist_taxtype_id_idxINDEX]CREATE INDEX aropentax_taxhist_taxtype_id_idx ON aropentax USING btree (taxhist_taxtype_id); 4DROP INDEX public.aropentax_taxhist_taxtype_id_idx; publicadminfalse3389635125986870 asohisttax_taxhist_parent_id_idxINDEX]CREATE INDEX asohisttax_taxhist_parent_id_idx ON asohisttax USING btree (taxhist_parent_id); 4DROP INDEX public.asohisttax_taxhist_parent_id_idx; publicadminfalse3419635125986872"asohisttax_taxhist_parent_type_idxINDEXsCREATE INDEX asohisttax_taxhist_parent_type_idx ON asohisttax USING btree (taxhist_parent_id, taxhist_taxtype_id); 6DROP INDEX public.asohisttax_taxhist_parent_type_idx; publicadminfalse3413419635125986871!asohisttax_taxhist_taxtype_id_idxINDEX_CREATE INDEX asohisttax_taxhist_taxtype_id_idx ON asohisttax USING btree (taxhist_taxtype_id); 5DROP INDEX public.asohisttax_taxhist_taxtype_id_idx; publicadminfalse3419635125983633bomitem_bomitem_item_id_idxINDEXSCREATE INDEX bomitem_bomitem_item_id_idx ON bomitem USING btree (bomitem_item_id); /DROP INDEX public.bomitem_bomitem_item_id_idx; publicadminfalse1869635125983634bomitem_effective_keyINDEXOCREATE INDEX bomitem_effective_key ON bomitem USING btree (bomitem_effective); )DROP INDEX public.bomitem_effective_key; publicadminfalse1869635125983635bomitem_expires_keyINDEXKCREATE INDEX bomitem_expires_key ON bomitem USING btree (bomitem_expires); 'DROP INDEX public.bomitem_expires_key; publicadminfalse1869635125983636bomitem_parent_item_idINDEXUCREATE INDEX bomitem_parent_item_id ON bomitem USING btree (bomitem_parent_item_id); *DROP INDEX public.bomitem_parent_item_id; publicadminfalse1869635125983637bomitemcost_bomitem_id_keyINDEX]CREATE INDEX bomitemcost_bomitem_id_key ON bomitemcost USING btree (bomitemcost_bomitem_id); .DROP INDEX public.bomitemcost_bomitem_id_key; publicadminfalse3569635125983638bomitemcost_master_idxINDEXCREATE UNIQUE INDEX bomitemcost_master_idx ON bomitemcost USING btree (bomitemcost_bomitem_id, bomitemcost_costelem_id, bomitemcost_lowlevel); *DROP INDEX public.bomitemcost_master_idx; publicadminfalse3563563569635125983639cashrcptitem_aropen_idxINDEX[CREATE INDEX cashrcptitem_aropen_idx ON cashrcptitem USING btree (cashrcptitem_aropen_id); +DROP INDEX public.cashrcptitem_aropen_idx; publicadminfalse2339635125983640cashrcptitem_cashrcpt_idxINDEX_CREATE INDEX cashrcptitem_cashrcpt_idx ON cashrcptitem USING btree (cashrcptitem_cashrcpt_id); -DROP INDEX public.cashrcptitem_cashrcpt_idx; publicadminfalse2339635125983641ccard_cust_id_idxINDEXECREATE INDEX ccard_cust_id_idx ON ccard USING btree (ccard_cust_id); %DROP INDEX public.ccard_cust_id_idx; publicadminfalse2359635125983642ccardaud_ccard_cust_id_idxINDEX^CREATE INDEX ccardaud_ccard_cust_id_idx ON ccardaud USING btree (ccardaud_ccard_cust_id_new); .DROP INDEX public.ccardaud_ccard_cust_id_idx; publicadminfalse3699635125983643ccardaud_ccard_id_idxINDEXPCREATE INDEX ccardaud_ccard_id_idx ON ccardaud USING btree (ccardaud_ccard_id); )DROP INDEX public.ccardaud_ccard_id_idx; publicadminfalse3699635125983644ccpay_ccard_id_idxINDEXGCREATE INDEX ccpay_ccard_id_idx ON ccpay USING btree (ccpay_ccard_id); &DROP INDEX public.ccpay_ccard_id_idx; publicadminfalse3739635125983645ccpay_cust_id_idxINDEXECREATE INDEX ccpay_cust_id_idx ON ccpay USING btree (ccpay_cust_id); %DROP INDEX public.ccpay_cust_id_idx; publicadminfalse3739635125983646ccpay_order_number_idxINDEXOCREATE INDEX ccpay_order_number_idx ON ccpay USING btree (ccpay_order_number); *DROP INDEX public.ccpay_order_number_idx; publicadminfalse3739635]125986873charass_char_id_target_type_idxINDEXlCREATE INDEX charass_char_id_target_type_idx ON charass USING btree (charass_char_id, charass_target_type); 3DROP INDEX public.charass_char_id_target_type_idx; publicadminfalse2152159635`125983647charass_target_idxINDEXaCREATE INDEX charass_target_idx ON charass USING btree (charass_target_type, charass_target_id); &DROP INDEX public.charass_target_idx; publicadminfalse2152159635125983648checkhead_posted_idxINDEXOCREATE INDEX checkhead_posted_idx ON checkhead USING btree (checkhead_posted); (DROP INDEX public.checkhead_posted_idx; publicadminfalse3189635125983649checkhead_replaced_idxINDEXSCREATE INDEX checkhead_replaced_idx ON checkhead USING btree (checkhead_replaced); *DROP INDEX public.checkhead_replaced_idx; publicadminfalse3189635125983650checkitem_apopenitem_id_idxINDEXYCREATE INDEX checkitem_apopenitem_id_idx ON checkitem USING btree (checkitem_apopen_id); /DROP INDEX public.checkitem_apopenitem_id_idx; publicadminfalse3209635%125983651cmhead_invcnumber_idxINDEXNCREATE INDEX cmhead_invcnumber_idx ON cmhead USING btree (cmhead_invcnumber); )DROP INDEX public.cmhead_invcnumber_idx; publicadminfalse2019635125986874cmheadtax_taxhist_parent_id_idxINDEX[CREATE INDEX cmheadtax_taxhist_parent_id_idx ON cmheadtax USING btree (taxhist_parent_id); 3DROP INDEX public.cmheadtax_taxhist_parent_id_idx; publicadminfalse3839635125986876!cmheadtax_taxhist_parent_type_idxINDEXqCREATE INDEX cmheadtax_taxhist_parent_type_idx ON cmheadtax USING btree (taxhist_parent_id, taxhist_taxtype_id); 5DROP INDEX public.cmheadtax_taxhist_parent_type_idx; publicadminfalse3833839635125986875 cmheadtax_taxhist_taxtype_id_idxINDEX]CREATE INDEX cmheadtax_taxhist_taxtype_id_idx ON cmheadtax USING btree (taxhist_taxtype_id); 4DROP INDEX public.cmheadtax_taxhist_taxtype_id_idx; publicadminfalse3839635125986877cmitemtax_taxhist_parent_id_idxINDEX[CREATE INDEX cmitemtax_taxhist_parent_id_idx ON cmitemtax USING btree (taxhist_parent_id); 3DROP INDEX public.cmitemtax_taxhist_parent_id_idx; publicadminfalse3859635125986879!cmitemtax_taxhist_parent_type_idxINDEXqCREATE INDEX cmitemtax_taxhist_parent_type_idx ON cmitemtax USING btree (taxhist_parent_id, taxhist_taxtype_id); 5DROP INDEX public.cmitemtax_taxhist_parent_type_idx; publicadminfalse3853859635125986878 cmitemtax_taxhist_taxtype_id_idxINDEX]CREATE INDEX cmitemtax_taxhist_taxtype_id_idx ON cmitemtax USING btree (taxhist_taxtype_id); 4DROP INDEX public.cmitemtax_taxhist_taxtype_id_idx; publicadminfalse3859635125983652cntct_email_idxINDEXACREATE INDEX cntct_email_idx ON cntct USING btree (cntct_email); #DROP INDEX public.cntct_email_idx; publicadminfalse1879635125983653cntct_name_idxINDEX?CREATE INDEX cntct_name_idx ON cntct USING btree (cntct_name); "DROP INDEX public.cntct_name_idx; publicadminfalse1879635125983654cobill_cobmisc_idINDEXJCREATE INDEX cobill_cobmisc_id ON cobill USING btree (cobill_cobmisc_id); %DROP INDEX public.cobill_cobmisc_id; publicadminfalse3999635125983655cobill_coitem_idINDEXHCREATE INDEX cobill_coitem_id ON cobill USING btree (cobill_coitem_id); $DROP INDEX public.cobill_coitem_id; publicadminfalse3999635125986880cobilltax_taxhist_parent_id_idxINDEX[CREATE INDEX cobilltax_taxhist_parent_id_idx ON cobilltax USING btree (taxhist_parent_id); 3DROP INDEX public.cobilltax_taxhist_parent_id_idx; publicadminfalse4019635125986882!cobilltax_taxhist_parent_type_idxINDEXqCREATE INDEX cobilltax_taxhist_parent_type_idx ON cobilltax USING btree (taxhist_parent_id, taxhist_taxtype_id); 5DROP INDEX public.cobilltax_taxhist_parent_type_idx; publicadminfalse4014019635125986881 cobilltax_taxhist_taxtype_id_idxINDEX]CREATE INDEX cobilltax_taxhist_taxtype_id_idx ON cobilltax USING btree (taxhist_taxtype_id); 4DROP INDEX public.cobilltax_taxhist_taxtype_id_idx; publicadminfalse4019635125983656cobmisc_cohead_idINDEXKCREATE INDEX cobmisc_cohead_id ON cobmisc USING btree (cobmisc_cohead_id); %DROP INDEX public.cobmisc_cohead_id; publicadminfalse4029635125983657cobmisc_postedINDEXECREATE INDEX cobmisc_posted ON cobmisc USING btree (cobmisc_posted); "DROP INDEX public.cobmisc_posted; publicadminfalse4029635125986883 cobmisctax_taxhist_parent_id_idxINDEX]CREATE INDEX cobmisctax_taxhist_parent_id_idx ON cobmisctax USING btree (taxhist_parent_id); 4DROP INDEX public.cobmisctax_taxhist_parent_id_idx; publicadminfalse4049635125986885"cobmisctax_taxhist_parent_type_idxINDEXsCREATE INDEX cobmisctax_taxhist_parent_type_idx ON cobmisctax USING btree (taxhist_parent_id, taxhist_taxtype_id); 6DROP INDEX public.cobmisctax_taxhist_parent_type_idx; publicadminfalse4044049635125986884!cobmisctax_taxhist_taxtype_id_idxINDEX_CREATE INDEX cobmisctax_taxhist_taxtype_id_idx ON cobmisctax USING btree (taxhist_taxtype_id); 5DROP INDEX public.cobmisctax_taxhist_taxtype_id_idx; publicadminfalse4049635125983658cohead_cohead_status_idxINDEXMCREATE INDEX cohead_cohead_status_idx ON cohead USING btree (cohead_status); ,DROP INDEX public.cohead_cohead_status_idx; publicadminfalse1789635125983659cohead_cust_id_keyINDEXHCREATE INDEX cohead_cust_id_key ON cohead USING btree (cohead_cust_id); &DROP INDEX public.cohead_cust_id_key; publicadminfalse1789635125983660cohead_custponumber_idxINDEXRCREATE INDEX cohead_custponumber_idx ON cohead USING btree (cohead_custponumber); +DROP INDEX public.cohead_custponumber_idx; publicadminfalse1789635125983661cohead_number_idxINDEXMCREATE UNIQUE INDEX cohead_number_idx ON cohead USING btree (cohead_number); %DROP INDEX public.cohead_number_idx; publicadminfalse1789635125983662cohead_shipto_idINDEXHCREATE INDEX cohead_shipto_id ON cohead USING btree (cohead_shipto_id); $DROP INDEX public.cohead_shipto_id; publicadminfalse17896358125983663cohist_cust_idINDEXDCREATE INDEX cohist_cust_id ON cohist USING btree (cohist_cust_id); "DROP INDEX public.cohist_cust_id; publicadminfalse28096359125983664cohist_invcnumberINDEXJCREATE INDEX cohist_invcnumber ON cohist USING btree (cohist_invcnumber); %DROP INDEX public.cohist_invcnumber; publicadminfalse2809635:125983665cohist_itemsite_idINDEXLCREATE INDEX cohist_itemsite_id ON cohist USING btree (cohist_itemsite_id); &DROP INDEX public.cohist_itemsite_id; publicadminfalse2809635=125983666cohist_shipdateINDEXFCREATE INDEX cohist_shipdate ON cohist USING btree (cohist_shipdate); #DROP INDEX public.cohist_shipdate; publicadminfalse2809635>125983667cohist_shipto_idINDEXHCREATE INDEX cohist_shipto_id ON cohist USING btree (cohist_shipto_id); $DROP INDEX public.cohist_shipto_id; publicadminfalse2809635F125986886cohisttax_taxhist_parent_id_idxINDEX[CREATE INDEX cohisttax_taxhist_parent_id_idx ON cohisttax USING btree (taxhist_parent_id); 3DROP INDEX public.cohisttax_taxhist_parent_id_idx; publicadminfalse2829635G125986888!cohisttax_taxhist_parent_type_idxINDEXqCREATE INDEX cohisttax_taxhist_parent_type_idx ON cohisttax USING btree (taxhist_parent_id, taxhist_taxtype_id); 5DROP INDEX public.cohisttax_taxhist_parent_type_idx; publicadminfalse2822829635H125986887 cohisttax_taxhist_taxtype_id_idxINDEX]CREATE INDEX cohisttax_taxhist_taxtype_id_idx ON cohisttax USING btree (taxhist_taxtype_id); 4DROP INDEX public.cohisttax_taxhist_taxtype_id_idx; publicadminfalse2829635125983668coitem_cohead_id_keyINDEXLCREATE INDEX coitem_cohead_id_key ON coitem USING btree (coitem_cohead_id); (DROP INDEX public.coitem_cohead_id_key; publicadminfalse1799635125983669coitem_coitem_cohead_id_keyINDEXCREATE UNIQUE INDEX coitem_coitem_cohead_id_key ON coitem USING btree (coitem_cohead_id, coitem_linenumber, coitem_subnumber); /DROP INDEX public.coitem_coitem_cohead_id_key; publicadminfalse1791791799635125983670coitem_itemsite_idINDEXLCREATE INDEX coitem_itemsite_id ON coitem USING btree (coitem_itemsite_id); &DROP INDEX public.coitem_itemsite_id; publicadminfalse1799635125983671coitem_linenumber_keyINDEXNCREATE INDEX coitem_linenumber_key ON coitem USING btree (coitem_linenumber); )DROP INDEX public.coitem_linenumber_key; publicadminfalse1799635125983672coitem_status_keyINDEXFCREATE INDEX coitem_status_key ON coitem USING btree (coitem_status); %DROP INDEX public.coitem_status_key; publicadminfalse1799635e125983673comment_comment_source_idxINDEXdCREATE INDEX comment_comment_source_idx ON comment USING btree (comment_source, comment_source_id); .DROP INDEX public.comment_comment_source_idx; publicadminfalse2172179635125983674contrct_master_idxINDEXaCREATE UNIQUE INDEX contrct_master_idx ON contrct USING btree (contrct_number, contrct_vend_id); &DROP INDEX public.contrct_master_idx; publicadminfalse2592599635125983675cust_number_idxINDEXKCREATE UNIQUE INDEX cust_number_idx ON custinfo USING btree (cust_number); #DROP INDEX public.cust_number_idx; publicadminfalse1969635j125986889docass_source_id_idxINDEXLCREATE INDEX docass_source_id_idx ON docass USING btree (docass_source_id); (DROP INDEX public.docass_source_id_idx; publicadminfalse2189635k125986890docass_source_type_idxINDEXPCREATE INDEX docass_source_type_idx ON docass USING btree (docass_source_type); *DROP INDEX public.docass_source_type_idx; publicadminfalse2189635l125986891docass_target_id_idxINDEXLCREATE INDEX docass_target_id_idx ON docass USING btree (docass_target_id); (DROP INDEX public.docass_target_id_idx; publicadminfalse2189635m125986892docass_target_type_idxINDEXPCREATE INDEX docass_target_type_idx ON docass USING btree (docass_target_type); *DROP INDEX public.docass_target_type_idx; publicadminfalse2189635*125983676evntlog_dispatched_idxINDEXQCREATE INDEX evntlog_dispatched_idx ON evntlog USING btree (evntlog_dispatched); *DROP INDEX public.evntlog_dispatched_idx; publicadminfalse4509635+125986893evntlog_evntlog_username_idxINDEXUCREATE INDEX evntlog_evntlog_username_idx ON evntlog USING btree (evntlog_username); 0DROP INDEX public.evntlog_evntlog_username_idx; publicadminfalse4509635.125983678evntnot_evnttype_id_idxINDEXSCREATE INDEX evntnot_evnttype_id_idx ON evntnot USING btree (evntnot_evnttype_id); +DROP INDEX public.evntnot_evnttype_id_idx; publicadminfalse45296351125983679evntnot_warehous_id_idxINDEXSCREATE INDEX evntnot_warehous_id_idx ON evntnot USING btree (evntnot_warehous_id); +DROP INDEX public.evntnot_warehous_id_idx; publicadminfalse45296356125983680 filter_idxINDEX]CREATE INDEX filter_idx ON filter USING btree (filter_screen, filter_username, filter_name); DROP INDEX public.filter_idx; publicadminfalse4584584589635125983681gltrans_gltrans_accnt_id_idxINDEXUCREATE INDEX gltrans_gltrans_accnt_id_idx ON gltrans USING btree (gltrans_accnt_id); 0DROP INDEX public.gltrans_gltrans_accnt_id_idx; publicadminfalse2659635125983682gltrans_gltrans_date_idxINDEXMCREATE INDEX gltrans_gltrans_date_idx ON gltrans USING btree (gltrans_date); ,DROP INDEX public.gltrans_gltrans_date_idx; publicadminfalse2659635125983683!gltrans_gltrans_journalnumber_idxINDEX_CREATE INDEX gltrans_gltrans_journalnumber_idx ON gltrans USING btree (gltrans_journalnumber); 5DROP INDEX public.gltrans_gltrans_journalnumber_idx; publicadminfalse2659635125983684gltrans_sequence_idxINDEXMCREATE INDEX gltrans_sequence_idx ON gltrans USING btree (gltrans_sequence); (DROP INDEX public.gltrans_sequence_idx; publicadminfalse26596354125986894invchead_invchead_cust_id_idxINDEXWCREATE INDEX invchead_invchead_cust_id_idx ON invchead USING btree (invchead_cust_id); 1DROP INDEX public.invchead_invchead_cust_id_idx; publicadminfalse20596355125983685!invchead_invchead_ordernumber_idxINDEX_CREATE INDEX invchead_invchead_ordernumber_idx ON invchead USING btree (invchead_ordernumber); 5DROP INDEX public.invchead_invchead_ordernumber_idx; publicadminfalse2059635_125986895!invcheadtax_taxhist_parent_id_idxINDEX_CREATE INDEX invcheadtax_taxhist_parent_id_idx ON invcheadtax USING btree (taxhist_parent_id); 5DROP INDEX public.invcheadtax_taxhist_parent_id_idx; publicadminfalse4999635`125986897#invcheadtax_taxhist_parent_type_idxINDEXuCREATE INDEX invcheadtax_taxhist_parent_type_idx ON invcheadtax USING btree (taxhist_parent_id, taxhist_taxtype_id); 7DROP INDEX public.invcheadtax_taxhist_parent_type_idx; publicadminfalse4994999635a125986896"invcheadtax_taxhist_taxtype_id_idxINDEXaCREATE INDEX invcheadtax_taxhist_taxtype_id_idx ON invcheadtax USING btree (taxhist_taxtype_id); 6DROP INDEX public.invcheadtax_taxhist_taxtype_id_idx; publicadminfalse4999635F125983686!invcitem_invcitem_invchead_id_idxINDEX_CREATE INDEX invcitem_invcitem_invchead_id_idx ON invcitem USING btree (invcitem_invchead_id); 5DROP INDEX public.invcitem_invcitem_invchead_id_idx; publicadminfalse2099635G125983687!invcitem_invcitem_itemsite_id_idxINDEXqCREATE INDEX invcitem_invcitem_itemsite_id_idx ON invcitem USING btree (invcitem_item_id, invcitem_warehous_id); 5DROP INDEX public.invcitem_invcitem_itemsite_id_idx; publicadminfalse2092099635d125983688!invcitemtax_taxhist_parent_id_idxINDEX_CREATE INDEX invcitemtax_taxhist_parent_id_idx ON invcitemtax USING btree (taxhist_parent_id); 5DROP INDEX public.invcitemtax_taxhist_parent_id_idx; publicadminfalse5019635e125986899#invcitemtax_taxhist_parent_type_idxINDEXuCREATE INDEX invcitemtax_taxhist_parent_type_idx ON invcitemtax USING btree (taxhist_parent_id, taxhist_taxtype_id); 7DROP INDEX public.invcitemtax_taxhist_parent_type_idx; publicadminfalse5015019635f125986898"invcitemtax_taxhist_taxtype_id_idxINDEXaCREATE INDEX invcitemtax_taxhist_taxtype_id_idx ON invcitemtax USING btree (taxhist_taxtype_id); 6DROP INDEX public.invcitemtax_taxhist_taxtype_id_idx; publicadminfalse5019635g125983689#invdetail_invdetail_invcitem_id_idxINDEXcCREATE INDEX invdetail_invdetail_invcitem_id_idx ON invdetail USING btree (invdetail_invcitem_id); 7DROP INDEX public.invdetail_invdetail_invcitem_id_idx; publicadminfalse5039635h125983690"invdetail_invdetail_invhist_id_idxINDEXaCREATE INDEX invdetail_invdetail_invhist_id_idx ON invdetail USING btree (invdetail_invhist_id); 6DROP INDEX public.invdetail_invdetail_invhist_id_idx; publicadminfalse5039635k125983691invhist_hasdetailINDEXKCREATE INDEX invhist_hasdetail ON invhist USING btree (invhist_hasdetail); %DROP INDEX public.invhist_hasdetail; publicadminfalse5059635l125983692invhist_invhist_ordnumber_idxINDEXWCREATE INDEX invhist_invhist_ordnumber_idx ON invhist USING btree (invhist_ordnumber); 1DROP INDEX public.invhist_invhist_ordnumber_idx; publicadminfalse5059635m125983693invhist_itemsite_idINDEXOCREATE INDEX invhist_itemsite_id ON invhist USING btree (invhist_itemsite_id); 'DROP INDEX public.invhist_itemsite_id; publicadminfalse5059635p125983694invhist_seriesINDEXECREATE INDEX invhist_series ON invhist USING btree (invhist_series); "DROP INDEX public.invhist_series; publicadminfalse5059635q125983695invhist_transdateINDEXKCREATE INDEX invhist_transdate ON invhist USING btree (invhist_transdate); %DROP INDEX public.invhist_transdate; publicadminfalse5059635r125983696invhist_transtypeINDEXKCREATE INDEX invhist_transtype ON invhist USING btree (invhist_transtype); %DROP INDEX public.invhist_transtype; publicadminfalse5059635125983697ipsitem_ipshead_id_idxINDEXUCREATE INDEX ipsitem_ipshead_id_idx ON ipsiteminfo USING btree (ipsitem_ipshead_id); *DROP INDEX public.ipsitem_ipshead_id_idx; publicadminfalse2699635125983698item_classcode_idINDEXHCREATE INDEX item_classcode_id ON item USING btree (item_classcode_id); %DROP INDEX public.item_classcode_id; publicadminfalse1749635125983699item_number_idxINDEXGCREATE UNIQUE INDEX item_number_idx ON item USING btree (item_number); #DROP INDEX public.item_number_idx; publicadminfalse1749635125983700item_prodcat_id_idxINDEXHCREATE INDEX item_prodcat_id_idx ON item USING btree (item_prodcat_id); 'DROP INDEX public.item_prodcat_id_idx; publicadminfalse1749635125983701item_upccode_idxINDEXBCREATE INDEX item_upccode_idx ON item USING btree (item_upccode); $DROP INDEX public.item_upccode_idx; publicadminfalse1749635125983702itemcost_item_id_keyINDEXNCREATE INDEX itemcost_item_id_key ON itemcost USING btree (itemcost_item_id); (DROP INDEX public.itemcost_item_id_key; publicadminfalse2569635125983703itemcost_master_idxINDEX}CREATE UNIQUE INDEX itemcost_master_idx ON itemcost USING btree (itemcost_item_id, itemcost_costelem_id, itemcost_lowlevel); 'DROP INDEX public.itemcost_master_idx; publicadminfalse2562562569635125983704itemloc_itemsite_idxINDEXPCREATE INDEX itemloc_itemsite_idx ON itemloc USING btree (itemloc_itemsite_id); (DROP INDEX public.itemloc_itemsite_idx; publicadminfalse5299635125983705itemloc_location_idxINDEXPCREATE INDEX itemloc_location_idx ON itemloc USING btree (itemloc_location_id); (DROP INDEX public.itemloc_location_idx; publicadminfalse5299635125983706itemsite_active_keyINDEXLCREATE INDEX itemsite_active_key ON itemsite USING btree (itemsite_active); 'DROP INDEX public.itemsite_active_key; publicadminfalse1759635125983707itemsite_item_id_keyINDEXNCREATE INDEX itemsite_item_id_key ON itemsite USING btree (itemsite_item_id); (DROP INDEX public.itemsite_item_id_key; publicadminfalse1759635125983708itemsite_item_warehous_id_keyINDEXtCREATE UNIQUE INDEX itemsite_item_warehous_id_key ON itemsite USING btree (itemsite_item_id, itemsite_warehous_id); 1DROP INDEX public.itemsite_item_warehous_id_key; publicadminfalse1751759635125983709itemsite_plancode_id_keyINDEXVCREATE INDEX itemsite_plancode_id_key ON itemsite USING btree (itemsite_plancode_id); ,DROP INDEX public.itemsite_plancode_id_key; publicadminfalse1759635125983710itemsite_warehous_id_keyINDEXVCREATE INDEX itemsite_warehous_id_key ON itemsite USING btree (itemsite_warehous_id); ,DROP INDEX public.itemsite_warehous_id_key; publicadminfalse1759635125983711itemsrc_vend_id_idxINDEXKCREATE INDEX itemsrc_vend_id_idx ON itemsrc USING btree (itemsrc_vend_id); 'DROP INDEX public.itemsrc_vend_id_idx; publicadminfalse2609635125983712itemsrcp_itemsrc_id_keyINDEXTCREATE INDEX itemsrcp_itemsrc_id_key ON itemsrcp USING btree (itemsrcp_itemsrc_id); +DROP INDEX public.itemsrcp_itemsrc_id_key; publicadminfalse2619635125983713itemsub_parent_item_id_keyINDEXYCREATE INDEX itemsub_parent_item_id_key ON itemsub USING btree (itemsub_parent_item_id); .DROP INDEX public.itemsub_parent_item_id_key; publicadminfalse2629635125983714itemsub_sub_item_id_keyINDEXSCREATE INDEX itemsub_sub_item_id_key ON itemsub USING btree (itemsub_sub_item_id); +DROP INDEX public.itemsub_sub_item_id_key; publicadminfalse2629635125987402 location_location_formatname_idxINDEX]CREATE INDEX location_location_formatname_idx ON location USING btree (location_formatname); 4DROP INDEX public.location_location_formatname_idx; publicadminfalse2669635 125983715location_warehous_idxINDEXSCREATE INDEX location_warehous_idx ON location USING btree (location_warehous_id); )DROP INDEX public.location_warehous_idx; publicadminfalse2669635125983716payaropen_aropen_id_idxINDEXUCREATE INDEX payaropen_aropen_id_idx ON payaropen USING btree (payaropen_aropen_id); +DROP INDEX public.payaropen_aropen_id_idx; publicadminfalse5869635125983717payaropen_ccpay_id_idxINDEXSCREATE INDEX payaropen_ccpay_id_idx ON payaropen USING btree (payaropen_ccpay_id); *DROP INDEX public.payaropen_ccpay_id_idx; publicadminfalse5869635125983718payco_ccpay_id_idxINDEXGCREATE INDEX payco_ccpay_id_idx ON payco USING btree (payco_ccpay_id); &DROP INDEX public.payco_ccpay_id_idx; publicadminfalse5879635125983719payco_cohead_id_idxINDEXICREATE INDEX payco_cohead_id_idx ON payco USING btree (payco_cohead_id); 'DROP INDEX public.payco_cohead_id_idx; publicadminfalse5879635125983720pohead_pohead_status_idxINDEXMCREATE INDEX pohead_pohead_status_idx ON pohead USING btree (pohead_status); ,DROP INDEX public.pohead_pohead_status_idx; publicadminfalse1809635125983721poitem_itemsite_id_keyINDEXPCREATE INDEX poitem_itemsite_id_key ON poitem USING btree (poitem_itemsite_id); *DROP INDEX public.poitem_itemsite_id_key; publicadminfalse1819635125983722"poitem_itemsite_status_duedate_keyINDEX{CREATE INDEX poitem_itemsite_status_duedate_key ON poitem USING btree (poitem_itemsite_id, poitem_status, poitem_duedate); 6DROP INDEX public.poitem_itemsite_status_duedate_key; publicadminfalse1811811819635125983723poitem_pohead_id_keyINDEXLCREATE INDEX poitem_pohead_id_key ON poitem USING btree (poitem_pohead_id); (DROP INDEX public.poitem_pohead_id_key; publicadminfalse1819635125983724poitem_status_keyINDEXFCREATE INDEX poitem_status_key ON poitem USING btree (poitem_status); %DROP INDEX public.poitem_status_key; publicadminfalse1819635e125983725 priv_name_idxINDEXCCREATE UNIQUE INDEX priv_name_idx ON priv USING btree (priv_name); !DROP INDEX public.priv_name_idx; publicadminfalse29796353125983726quitem_quhead_id_keyINDEXLCREATE INDEX quitem_quhead_id_key ON quitem USING btree (quitem_quhead_id); (DROP INDEX public.quitem_quhead_id_key; publicadminfalse2789635125983727recv_ordertypeid_idxINDEX\CREATE INDEX recv_ordertypeid_idx ON recv USING btree (recv_order_type, recv_orderitem_id); (DROP INDEX public.recv_ordertypeid_idx; publicadminfalse5995999635j125983728report_name_grade_idxINDEX]CREATE UNIQUE INDEX report_name_grade_idx ON report USING btree (report_name, report_grade); )DROP INDEX public.report_name_grade_idx; publicadminfalse3003009635 125983729salesaccnt_prodcat_id_idxINDEXZCREATE INDEX salesaccnt_prodcat_id_idx ON salesaccnt USING btree (salesaccnt_prodcat_id); -DROP INDEX public.salesaccnt_prodcat_id_idx; publicadminfalse4269635125983730salesaccnt_warehous_id_idxINDEX\CREATE INDEX salesaccnt_warehous_id_idx ON salesaccnt USING btree (salesaccnt_warehous_id); .DROP INDEX public.salesaccnt_warehous_id_idx; publicadminfalse4269635125983731shipdata_cohead_number_idxINDEXZCREATE INDEX shipdata_cohead_number_idx ON shipdata USING btree (shipdata_cohead_number); .DROP INDEX public.shipdata_cohead_number_idx; publicadminfalse2449635 125983732shipdatasum_cohead_number_idxINDEXcCREATE INDEX shipdatasum_cohead_number_idx ON shipdatasum USING btree (shipdatasum_cohead_number); 1DROP INDEX public.shipdatasum_cohead_number_idx; publicadminfalse6449635 125983733 shipdatasum_cosmisc_tracknum_idxINDEXiCREATE INDEX shipdatasum_cosmisc_tracknum_idx ON shipdatasum USING btree (shipdatasum_cosmisc_tracknum); 4DROP INDEX public.shipdatasum_cosmisc_tracknum_idx; publicadminfalse6449635125983734shiphead_order_id_idxINDEXPCREATE INDEX shiphead_order_id_idx ON shiphead USING btree (shiphead_order_id); )DROP INDEX public.shiphead_order_id_idx; publicadminfalse4129635125983735shiphead_shipped_idxINDEXNCREATE INDEX shiphead_shipped_idx ON shiphead USING btree (shiphead_shipped); (DROP INDEX public.shiphead_shipped_idx; publicadminfalse4129635125986901shipitem_invcitem_id_idxINDEXVCREATE INDEX shipitem_invcitem_id_idx ON shipitem USING btree (shipitem_invcitem_id); ,DROP INDEX public.shipitem_invcitem_id_idx; publicadminfalse4139635125986900shipitem_orderitem_id_idxINDEXXCREATE INDEX shipitem_orderitem_id_idx ON shipitem USING btree (shipitem_orderitem_id); -DROP INDEX public.shipitem_orderitem_id_idx; publicadminfalse4139635125983738shipitem_shiphead_id_idxINDEXVCREATE INDEX shipitem_shiphead_id_idx ON shipitem USING btree (shipitem_shiphead_id); ,DROP INDEX public.shipitem_shiphead_id_idx; publicadminfalse4139635125983739sltrans_sequence_idxINDEXMCREATE INDEX sltrans_sequence_idx ON sltrans USING btree (sltrans_sequence); (DROP INDEX public.sltrans_sequence_idx; publicadminfalse6549635125983740sltrans_sltrans_accnt_id_idxINDEXUCREATE INDEX sltrans_sltrans_accnt_id_idx ON sltrans USING btree (sltrans_accnt_id); 0DROP INDEX public.sltrans_sltrans_accnt_id_idx; publicadminfalse6549635125983741sltrans_sltrans_date_idxINDEXMCREATE INDEX sltrans_sltrans_date_idx ON sltrans USING btree (sltrans_date); ,DROP INDEX public.sltrans_sltrans_date_idx; publicadminfalse6549635125983742!sltrans_sltrans_journalnumber_idxINDEX_CREATE INDEX sltrans_sltrans_journalnumber_idx ON sltrans USING btree (sltrans_journalnumber); 5DROP INDEX public.sltrans_sltrans_journalnumber_idx; publicadminfalse65496352125983743subaccnttype_code_idxINDEX[CREATE UNIQUE INDEX subaccnttype_code_idx ON subaccnttype USING btree (subaccnttype_code); )DROP INDEX public.subaccnttype_code_idx; publicadminfalse6749635A125986902taxhist_taxhist_parent_id_idxINDEXWCREATE INDEX taxhist_taxhist_parent_id_idx ON taxhist USING btree (taxhist_parent_id); 1DROP INDEX public.taxhist_taxhist_parent_id_idx; publicadminfalse2819635B125986904taxhist_taxhist_parent_type_idxINDEXmCREATE INDEX taxhist_taxhist_parent_type_idx ON taxhist USING btree (taxhist_parent_id, taxhist_taxtype_id); 3DROP INDEX public.taxhist_taxhist_parent_type_idx; publicadminfalse2812819635C125986903taxhist_taxhist_taxtype_id_idxINDEXYCREATE INDEX taxhist_taxhist_taxtype_id_idx ON taxhist USING btree (taxhist_taxtype_id); 2DROP INDEX public.taxhist_taxhist_taxtype_id_idx; publicadminfalse2819635T125983744todoitem_todoitem_username_idxINDEXYCREATE INDEX todoitem_todoitem_username_idx ON todoitem USING btree (todoitem_username); 2DROP INDEX public.todoitem_todoitem_username_idx; publicadminfalse2129635?125983745trialbal_accnt_period_idxINDEXoCREATE UNIQUE INDEX trialbal_accnt_period_idx ON trialbal USING btree (trialbal_accnt_id, trialbal_period_id); -DROP INDEX public.trialbal_accnt_period_idx; publicadminfalse6916919635J125983746usrpref_userpref_name_idxINDEXNCREATE INDEX usrpref_userpref_name_idx ON usrpref USING btree (usrpref_name); -DROP INDEX public.usrpref_userpref_name_idx; publicadminfalse6999635125983747vend_number_idxINDEXKCREATE UNIQUE INDEX vend_number_idx ON vendinfo USING btree (vend_number); #DROP INDEX public.vend_number_idx; publicadminfalse1939635W125986905voheadtax_taxhist_parent_id_idxINDEX[CREATE INDEX voheadtax_taxhist_parent_id_idx ON voheadtax USING btree (taxhist_parent_id); 3DROP INDEX public.voheadtax_taxhist_parent_id_idx; publicadminfalse7159635X125986907!voheadtax_taxhist_parent_type_idxINDEXqCREATE INDEX voheadtax_taxhist_parent_type_idx ON voheadtax USING btree (taxhist_parent_id, taxhist_taxtype_id); 5DROP INDEX public.voheadtax_taxhist_parent_type_idx; publicadminfalse7157159635Y125986906 voheadtax_taxhist_taxtype_id_idxINDEX]CREATE INDEX voheadtax_taxhist_taxtype_id_idx ON voheadtax USING btree (taxhist_taxtype_id); 4DROP INDEX public.voheadtax_taxhist_taxtype_id_idx; publicadminfalse7159635^125986908voitemtax_taxhist_parent_id_idxINDEX[CREATE INDEX voitemtax_taxhist_parent_id_idx ON voitemtax USING btree (taxhist_parent_id); 3DROP INDEX public.voitemtax_taxhist_parent_id_idx; publicadminfalse7189635_125986910!voitemtax_taxhist_parent_type_idxINDEXqCREATE INDEX voitemtax_taxhist_parent_type_idx ON voitemtax USING btree (taxhist_parent_id, taxhist_taxtype_id); 5DROP INDEX public.voitemtax_taxhist_parent_type_idx; publicadminfalse7187189635`125986909 voitemtax_taxhist_taxtype_id_idxINDEX]CREATE INDEX voitemtax_taxhist_taxtype_id_idx ON voitemtax USING btree (taxhist_taxtype_id); 4DROP INDEX public.voitemtax_taxhist_taxtype_id_idx; publicadminfalse7189635125983748warehous_code_keyINDEXRCREATE INDEX warehous_code_key ON whsinfo USING btree (warehous_code bpchar_ops); %DROP INDEX public.warehous_code_key; publicadminfalse1769635125983749 wo_duedateINDEX8CREATE INDEX wo_duedate ON wo USING btree (wo_duedate); DROP INDEX public.wo_duedate; publicadminfalse4449635125983750wo_itemsite_idINDEX@CREATE INDEX wo_itemsite_id ON wo USING btree (wo_itemsite_id); "DROP INDEX public.wo_itemsite_id; publicadminfalse4449635125983751 wo_ordtypeINDEX8CREATE INDEX wo_ordtype ON wo USING btree (wo_ordtype); DROP INDEX public.wo_ordtype; publicadminfalse4449635"125983752 wo_startdateINDEX<CREATE INDEX wo_startdate ON wo USING btree (wo_startdate); DROP INDEX public.wo_startdate; publicadminfalse4449635#125983753 wo_statusINDEX6CREATE INDEX wo_status ON wo USING btree (wo_status); DROP INDEX public.wo_status; publicadminfalse4449635%125983754womatl_itemsite_id_keyINDEXPCREATE INDEX womatl_itemsite_id_key ON womatl USING btree (womatl_itemsite_id); *DROP INDEX public.womatl_itemsite_id_key; publicadminfalse2749635(125983755womatl_wo_id_keyINDEXDCREATE INDEX womatl_wo_id_key ON womatl USING btree (womatl_wo_id); $DROP INDEX public.womatl_wo_id_key; publicadminfalse2749635c125986911womatlpost_womatl_id_idxINDEXXCREATE INDEX womatlpost_womatl_id_idx ON womatlpost USING btree (womatlpost_womatl_id); ,DROP INDEX public.womatlpost_womatl_id_idx; publicadminfalse7249635125983756teitem_teitem_tehead_id_idxINDEXSCREATE INDEX teitem_teitem_tehead_id_idx ON teitem USING btree (teitem_tehead_id); +DROP INDEX te.teitem_teitem_tehead_id_idx; teadminfalse7499635!261883757_DELETERULE!CREATE RULE "_DELETE" AS ON DELETE TO salesline DO INSTEAD DELETE FROM public.coitem WHERE (((coitem.coitem_cohead_id = public.getcoheadid((old.order_number)::text)) AND (((coitem.coitem_linenumber)::character varying)::text = (old.line_number)::text)) AND (coitem.coitem_subnumber = 0)); &DROP RULE "_DELETE" ON api.salesline; apiadminfalse18415831791791841841791849635!261883758_DELETERULEACREATE RULE "_DELETE" AS ON DELETE TO apmemo DO INSTEAD NOTHING; #DROP RULE "_DELETE" ON api.apmemo; apiadminfalse1941941949635!261883759_DELETERULEACREATE RULE "_DELETE" AS ON DELETE TO armemo DO INSTEAD NOTHING; #DROP RULE "_DELETE" ON api.armemo; apiadminfalse2002002009635!261883760_DELETERULEGCREATE RULE "_DELETE" AS ON DELETE TO physinvcount DO INSTEAD NOTHING; )DROP RULE "_DELETE" ON api.physinvcount; apiadminfalse1771771779635!261887655_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO account DO INSTEAD DELETE FROM public.crmacct WHERE (crmacct.crmacct_number = (old.account_number)::text); $DROP RULE "_DELETE" ON api.account; apiadminfalse8041888048049635!261887662_DELETERULECCREATE RULE "_DELETE" AS ON DELETE TO accountchar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'CRMACCT'::text) AND (charass.charass_target_id = public.getcrmacctid((old.account_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'CRMACCT'::text))); (DROP RULE "_DELETE" ON api.accountchar; apiadminfalse805215805215215158915768058059635!261887669_DELETERULEICREATE RULE "_DELETE" AS ON DELETE TO accountcomment DO INSTEAD NOTHING; +DROP RULE "_DELETE" ON api.accountcomment; apiadminfalse8068068069635!261887676_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO accountfile DO INSTEAD DELETE FROM public.url WHERE ((((url.url_source_id = public.getcrmacctid(old.account_number)) AND (url.url_source = 'CRMA'::text)) AND (url.url_title = old.title)) AND (url.url_url = old.url)); (DROP RULE "_DELETE" ON api.accountfile; apiadminfalse80722122122115898072218078078079635"261887683_DELETERULE CREATE RULE "_DELETE" AS ON DELETE TO accountimage DO INSTEAD DELETE FROM public.imageass WHERE (((imageass.imageass_source_id = public.getcrmacctid(old.account_number)) AND (imageass.imageass_source = 'CRMA'::text)) AND (imageass.imageass_image_id = public.getimageid(old.image_name))); )DROP RULE "_DELETE" ON api.accountimage; apiadminfalse808224161115898082242248088089635"261887690_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO address DO INSTEAD SELECT public.deleteaddress(public.getaddrid((old.address_number)::text)) AS deleteaddress; $DROP RULE "_DELETE" ON api.address; apiadminfalse809156813188098099635 "261887697_DELETERULE:CREATE RULE "_DELETE" AS ON DELETE TO addresschar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'ADDR'::text) AND (charass.charass_target_id = public.getaddrid((old.address_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'ADDR'::text))); (DROP RULE "_DELETE" ON api.addresschar; apiadminfalse810157615688102152158102158109635"261887704_DELETERULEICREATE RULE "_DELETE" AS ON DELETE TO addresscomment DO INSTEAD NOTHING; +DROP RULE "_DELETE" ON api.addresscomment; apiadminfalse8118118119635"261887715_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO bom DO INSTEAD SELECT public.deletebom(public.getitemid((old.item_number)::text)) AS deletebom; DROP RULE "_DELETE" ON api.bom; apiadminfalse812812162381213239635"261887725_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO bomitem DO INSTEAD DELETE FROM public.bomitem WHERE ((bomitem.bomitem_id = old.id) AND public.fetchmetricbool('AllowBOMItemDelete'::text)); $DROP RULE "_DELETE" ON api.bomitem; apiadminfalse81318614558138139635"261887733_DELETERULEICREATE RULE "_DELETE" AS ON DELETE TO bomitemcomment DO INSTEAD NOTHING; +DROP RULE "_DELETE" ON api.bomitemcomment; apiadminfalse8148148149635"261887741_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO bomitemsubstitute DO INSTEAD DELETE FROM public.bomitemsub WHERE ((bomitemsub.bomitemsub_bomitem_id = old.bomitem_id) AND (bomitemsub.bomitemsub_item_id = public.getitemid((old.substitute_item_number)::text))); .DROP RULE "_DELETE" ON api.bomitemsubstitute; apiadminfalse81581522622616238158159635""261887748_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO budget DO INSTEAD DELETE FROM public.budghead WHERE (budghead.budghead_name = old.name); #DROP RULE "_DELETE" ON api.budget; apiadminfalse8168162278169635&"261887755_DELETERULE2CREATE RULE "_DELETE" AS ON DELETE TO budgetentry DO INSTEAD DELETE FROM public.budgitem WHERE (((budgitem.budgitem_budghead_id = public.getbudgheadid(old.name)) AND (budgitem.budgitem_period_id = public.getperiodid(old.period_start))) AND (budgitem.budgitem_accnt_id = public.getglaccntid(old.account))); (DROP RULE "_DELETE" ON api.budgetentry; apiadminfalse8178178178172292292291639817160915749635*"261887765_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO cashreceipt DO INSTEAD SELECT public.deletecashrcpt(cashrcpt.cashrcpt_id) AS deletecashrcpt FROM public.cashrcpt WHERE (cashrcpt.cashrcpt_id = public.getcashrcptid((old.customer_number)::text, CASE WHEN ((old.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((old.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((old.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((old.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((old.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((old.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((old.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((old.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((old.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (old.check_document_number)::text)); (DROP RULE "_DELETE" ON api.cashreceipt; apiadminfalse818818818232132715758188189635."261887776_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO cashreceiptapply DO INSTEAD DELETE FROM public.cashrcptitem WHERE ((cashrcptitem.cashrcptitem_cashrcpt_id = public.getcashrcptid((old.customer_number)::text, CASE WHEN ((old.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((old.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((old.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((old.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((old.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((old.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((old.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((old.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((old.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (old.check_document_number)::text)) AND (cashrcptitem.cashrcptitem_aropen_id = public.getaropenid((old.customer_number)::text, (old.doc_type)::bpchar, (old.doc_number)::text))); -DROP RULE "_DELETE" ON api.cashreceiptapply; apiadminfalse8198198191570233157581981923381981996352"261887787_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO cashreceiptapplymisc DO INSTEAD DELETE FROM public.cashrcptmisc WHERE ((cashrcptmisc.cashrcptmisc_cashrcpt_id = public.getcashrcptid((old.customer_number)::text, CASE WHEN ((old.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((old.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((old.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((old.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((old.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((old.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((old.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((old.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((old.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (old.check_document_number)::text)) AND (cashrcptmisc.cashrcptmisc_accnt_id = public.getglaccntid((old.account)::text))); 1DROP RULE "_DELETE" ON api.cashreceiptapplymisc; apiadminfalse8202342341609157582082082082082096356"261887797_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO contact DO INSTEAD DELETE FROM public.cntct WHERE (cntct.cntct_number = (old.contact_number)::text); $DROP RULE "_DELETE" ON api.contact; apiadminfalse8218211878219635:"261887804_DELETERULE5CREATE RULE "_DELETE" AS ON DELETE TO contactchar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'CNTCT'::text) AND (charass.charass_target_id = public.getcntctid(old.contact_number))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'CNTCT'::text))); (DROP RULE "_DELETE" ON api.contactchar; apiadminfalse822822215157621521582215818229635>"261887811_DELETERULEICREATE RULE "_DELETE" AS ON DELETE TO contactcomment DO INSTEAD NOTHING; +DROP RULE "_DELETE" ON api.contactcomment; apiadminfalse8238238239635B"261887821_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO creditmemo DO INSTEAD SELECT public.deletecreditmemo(cmhead.cmhead_id) AS deletecreditmemo FROM public.cmhead WHERE ((cmhead.cmhead_number = old.memo_number) AND (cmhead.cmhead_posted = false)); 'DROP RULE "_DELETE" ON api.creditmemo; apiadminfalse82420120113328242018249635F"261887831_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO creditmemoline DO INSTEAD DELETE FROM public.cmitem WHERE ((cmitem.cmitem_cmhead_id = public.getcmheadid(old.memo_number, false)) AND (cmitem.cmitem_linenumber = old.line_number)); +DROP RULE "_DELETE" ON api.creditmemoline; apiadminfalse82582582582520420415799635J"261887839_DELETERULE2CREATE RULE "_DELETE" AS ON DELETE TO custchar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'C'::text) AND (charass.charass_target_id = public.getcustid((old.customer_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'C'::text))); %DROP RULE "_DELETE" ON api.custchar; apiadminfalse826826215215157615928262158269635N"261887846_DELETERULEFCREATE RULE "_DELETE" AS ON DELETE TO custcomment DO INSTEAD NOTHING; (DROP RULE "_DELETE" ON api.custcomment; apiadminfalse8278278279635R"261887854_DELETERULEICREATE RULE "_DELETE" AS ON DELETE TO custcreditcard DO INSTEAD NOTHING; +DROP RULE "_DELETE" ON api.custcreditcard; apiadminfalse8288288289635V"261887864_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO customer DO INSTEAD DELETE FROM public.custinfo WHERE (custinfo.cust_number = (old.customer_number)::text); %DROP RULE "_DELETE" ON api.customer; apiadminfalse8298291968299635\"261887879_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO customertype DO INSTEAD DELETE FROM public.custtype WHERE (custtype.custtype_code = (old.code)::text); )DROP RULE "_DELETE" ON api.customertype; apiadminfalse8318318312369635`"261887886_DELETERULE>CREATE RULE "_DELETE" AS ON DELETE TO customertypechar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'CT'::text) AND (charass.charass_target_id = public.getcusttypeid((old.customer_type)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'CT'::text))); -DROP RULE "_DELETE" ON api.customertypechar; apiadminfalse832157683221515942152158328329635d"261887896_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO custshipto DO INSTEAD SELECT public.deleteshipto(public.getshiptoid((old.customer_number)::text, (old.shipto_number)::text)) AS deleteshipto; 'DROP RULE "_DELETE" ON api.custshipto; apiadminfalse833137583383383316679635h"261887903_DELETERULE CREATE RULE "_DELETE" AS ON DELETE TO custtax DO INSTEAD DELETE FROM public.taxreg WHERE (((taxreg.taxreg_rel_type = 'C'::bpchar) AND (taxreg.taxreg_rel_id = public.getcustid((old.customer_number)::text))) AND (taxreg.taxreg_taxauth_id = public.gettaxauthid((old.tax_authority)::text))); $DROP RULE "_DELETE" ON api.custtax; apiadminfalse834240240167715928348342408349635l"261887913_DELETERULEzCREATE RULE "_DELETE" AS ON DELETE TO employee DO INSTEAD DELETE FROM public.emp WHERE (emp.emp_code = (old.code)::text); %DROP RULE "_DELETE" ON api.employee; apiadminfalse8358358352429635p"261887920_DELETERULE7CREATE RULE "_DELETE" AS ON DELETE TO employeechar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'EMP'::text) AND (charass.charass_target_id = public.getempid((old.employee_code)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'EMP'::text))); )DROP RULE "_DELETE" ON api.employeechar; apiadminfalse836157683683683621521516002159635t"261887927_DELETERULEJCREATE RULE "_DELETE" AS ON DELETE TO employeecomment DO INSTEAD NOTHING; ,DROP RULE "_DELETE" ON api.employeecomment; apiadminfalse8378378379635x"261887934_DELETERULEtCREATE RULE "_DELETE" AS ON DELETE TO extshipmaint DO INSTEAD DELETE FROM public.shipdata WHERE ((((shipdata.shipdata_cohead_number = (old.so_number)::text) AND (shipdata.shipdata_shiphead_number = (old.shipment_number)::text)) AND (shipdata.shipdata_shipper = (old.shipper)::text)) AND (shipdata.shipdata_cosmisc_packnum_tracknum = (old.package_tracking_number)::text)); )DROP RULE "_DELETE" ON api.extshipmaint; apiadminfalse8388388382442442448382448388389635|"261887943_DELETERULE2CREATE RULE "_DELETE" AS ON DELETE TO freightpricingscheduleitem DO INSTEAD DELETE FROM public.ipsfreight WHERE (((((((((ipsfreight.ipsfreight_ipshead_id = public.getipsheadid((old.pricing_schedule)::text)) AND (ipsfreight.ipsfreight_qtybreak = old.qty_break)) AND (ipsfreight.ipsfreight_price = old.price)) AND ((ipsfreight.ipsfreight_type)::text = CASE WHEN (old.price_type = 'Flat Rate'::text) THEN 'F'::text WHEN (old.price_type = 'Price Per UOM'::text) THEN 'P'::text ELSE NULL::text END)) AND ((ipsfreight.ipsfreight_warehous_id IS NULL) AND (old.from_site = 'Any'::text))) OR ((ipsfreight.ipsfreight_warehous_id = CASE WHEN (old.from_site = 'Any'::text) THEN 0 ELSE public.getwarehousid(old.from_site, 'All'::text) END) AND ((ipsfreight.ipsfreight_shipzone_id IS NULL) AND (old.to_shipzone = 'Any'::text)))) OR ((ipsfreight.ipsfreight_shipzone_id = CASE WHEN (old.to_shipzone = 'Any'::text) THEN 0 ELSE public.getshipzoneid(old.to_shipzone) END) AND ((ipsfreight.ipsfreight_freightclass_id IS NULL) AND (old.freight_class = 'Any'::text)))) OR ((ipsfreight.ipsfreight_freightclass_id = CASE WHEN (old.freight_class = 'Any'::text) THEN 0 ELSE public.getfreightclassid(old.freight_class) END) AND ((ipsfreight.ipsfreight_shipvia IS NULL) AND (old.ship_via = 'Any'::text)))) OR (ipsfreight.ipsfreight_shipvia = old.ship_via)); 7DROP RULE "_DELETE" ON api.freightpricingscheduleitem; apiadminfalse83924624624616881670162016068392468392462468398392462468398398398398399635"261887963_DELETERULECCREATE RULE "_DELETE" AS ON DELETE TO incident DO INSTEAD NOTHING; %DROP RULE "_DELETE" ON api.incident; apiadminfalse8418418419635"261887970_DELETERULE:CREATE RULE "_DELETE" AS ON DELETE TO incidentchar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'INCDT'::text) AND (charass.charass_target_id = public.getincidentid(old.incident_number))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'INCDT'::text))); )DROP RULE "_DELETE" ON api.incidentchar; apiadminfalse842161715768422152152158428429635"261887975_DELETERULEJCREATE RULE "_DELETE" AS ON DELETE TO incidentcomment DO INSTEAD NOTHING; ,DROP RULE "_DELETE" ON api.incidentcomment; apiadminfalse8438438439635"261887984_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO incidentfile DO INSTEAD DELETE FROM public.url WHERE ((((url.url_source_id = public.getincidentid(old.incident_number)) AND (url.url_source = 'INCDT'::text)) AND (url.url_title = old.title)) AND (url.url_url = old.url)); )DROP RULE "_DELETE" ON api.incidentfile; apiadminfalse84484484484422122122122116178449635"261887991_DELETERULE$CREATE RULE "_DELETE" AS ON DELETE TO incidentimage DO INSTEAD DELETE FROM public.imageass WHERE (((imageass.imageass_source_id = public.getincidentid(old.incident_number)) AND (imageass.imageass_source = 'INCDT'::text)) AND (imageass.imageass_image_id = public.getimageid(old.image_name))); *DROP RULE "_DELETE" ON api.incidentimage; apiadminfalse845224224161716118458458452249635"261888002_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO invoice DO INSTEAD SELECT public.deleteinvoice(invchead.invchead_id) AS deleteinvoice FROM public.invchead WHERE ((invchead.invchead_invcnumber = old.invoice_number) AND (invchead.invchead_posted = false)); $DROP RULE "_DELETE" ON api.invoice; apiadminfalse84620513448468462052059635"261888012_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO invoiceline DO INSTEAD DELETE FROM public.invcitem WHERE (invcitem.invcitem_invchead_id = (SELECT invchead.invchead_id FROM public.invchead WHERE ((invchead.invchead_invcnumber = old.invoice_number) AND (invchead.invchead_posted = false)))); (DROP RULE "_DELETE" ON api.invoiceline; apiadminfalse8472058478472052092059635"261888022_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO item DO INSTEAD SELECT public.deleteitem(public.getitemid((old.item_number)::text)) AS deleteitem; !DROP RULE "_DELETE" ON api.item; apiadminfalse848848162313478489635"261888030_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO itemalias DO INSTEAD DELETE FROM public.itemalias WHERE ((itemalias.itemalias_item_id = public.getitemid((old.item_number)::text)) AND (itemalias.itemalias_number = old.alias_number)); &DROP RULE "_DELETE" ON api.itemalias; apiadminfalse84925425416238498498499635"261888037_DELETERULE.CREATE RULE "_DELETE" AS ON DELETE TO itemchar DO INSTEAD DELETE FROM public.charass WHERE (((charass.charass_target_type = 'I'::text) AND (charass.charass_target_id = public.getitemid((old.item_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'I'::text))); %DROP RULE "_DELETE" ON api.itemchar; apiadminfalse850157616238508508502152152159635"261888044_DELETERULEFCREATE RULE "_DELETE" AS ON DELETE TO itemcomment DO INSTEAD NOTHING; (DROP RULE "_DELETE" ON api.itemcomment; apiadminfalse8518518519635"261888052_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO itemcost DO INSTEAD SELECT public.deleteitemcost(public.getitemid((old.item_number)::text), public.getcostelemid((old.costing_element)::text)) AS deleteitemcost; %DROP RULE "_DELETE" ON api.itemcost; apiadminfalse8528528521348852162315879635"261888059_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO itemfile DO INSTEAD DELETE FROM public.url WHERE ((((url.url_source_id = public.getitemid((old.item_number)::text)) AND (url.url_source = 'I'::text)) AND (url.url_title = old.title)) AND (url.url_url = old.url)); %DROP RULE "_DELETE" ON api.itemfile; apiadminfalse85385385322122122185322116238539635"261888067_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO itemimage DO INSTEAD DELETE FROM public.imageass WHERE (((imageass.imageass_source_id = public.getitemid((old.item_number)::text)) AND (imageass.imageass_source = 'I'::text)) AND (imageass.imageass_image_id = public.getimageid(old.image_name))); &DROP RULE "_DELETE" ON api.itemimage; apiadminfalse854854224224224854162316118549635"261888077_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO itemsite DO INSTEAD SELECT public.deleteitemsite(public.getitemsiteid((old.site)::text, (old.item_number)::text)) AS deleteitemsite; %DROP RULE "_DELETE" ON api.itemsite; apiadminfalse855134116258558558559635"261888085_DELETERULEJCREATE RULE "_DELETE" AS ON DELETE TO itemsitecomment DO INSTEAD NOTHING; ,DROP RULE "_DELETE" ON api.itemsitecomment; apiadminfalse8568568569635"261888095_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO itemsource DO INSTEAD DELETE FROM public.itemsrc WHERE (((((itemsrc.itemsrc_item_id = public.getitemid((old.item_number)::text)) AND (itemsrc.itemsrc_vend_id = public.getvendid((old.vendor)::text))) AND (itemsrc.itemsrc_vend_item_number = old.vendor_item_number)) AND (itemsrc.itemsrc_manuf_name = old.manufacturer_name)) AND (itemsrc.itemsrc_manuf_item_number = old.manufacturer_item_number)); 'DROP RULE "_DELETE" ON api.itemsource; apiadminfalse857857857857168626016238578578572602602602609635"261888105_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO itemsourceprice DO INSTEAD DELETE FROM public.itemsrcp WHERE ((itemsrcp.itemsrcp_itemsrc_id = public.getitemsrcid((old.item_number)::text, (old.vendor)::text)) AND (itemsrcp.itemsrcp_qtybreak = old.qty_break)); ,DROP RULE "_DELETE" ON api.itemsourceprice; apiadminfalse85816298582618588588582619635"261888112_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO itemsubstitute DO INSTEAD DELETE FROM public.itemsub WHERE ((itemsub.itemsub_parent_item_id = public.getitemid((old.root_item_number)::text)) AND (itemsub.itemsub_sub_item_id = public.getitemid((old.substitute_item_number)::text))); +DROP RULE "_DELETE" ON api.itemsubstitute; apiadminfalse85985926226216238598599635"261888119_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO itemtaxtype DO INSTEAD DELETE FROM public.itemtax WHERE (((itemtax.itemtax_item_id = public.getitemid((old.item_number)::text)) AND CASE WHEN ((old.tax_zone)::text = 'Any'::text) THEN (itemtax.itemtax_taxzone_id IS NULL) ELSE (itemtax.itemtax_taxzone_id = public.gettaxzoneid((old.tax_zone)::text)) END) AND (itemtax.itemtax_taxtype_id = public.gettaxtypeid(old.tax_type))); (DROP RULE "_DELETE" ON api.itemtaxtype; apiadminfalse8601679162386026386016808608602632639635"261888126_DELETERULE0CREATE RULE "_DELETE" AS ON DELETE TO itemuomconversion DO INSTEAD SELECT public.deleteitemuomconv(itemuomconv.itemuomconv_id) AS deleteitemuomconv FROM public.itemuomconv WHERE ((itemuomconv.itemuomconv_item_id = public.getitemid((old.item_number)::text)) AND (((itemuomconv.itemuomconv_from_uom_id = public.getuomid((old.uom)::text)) AND (itemuomconv.itemuomconv_to_uom_id = public.getuomid(old.per_uom))) OR ((itemuomconv.itemuomconv_from_uom_id = public.getuomid(old.per_uom)) AND (itemuomconv.itemuomconv_to_uom_id = public.getuomid((old.uom)::text))))); .DROP RULE "_DELETE" ON api.itemuomconversion; apiadminfalse8618612641623861135116832642642648618619635"261888134_DELETERULEGCREATE RULE "_DELETE" AS ON DELETE TO journalentry DO INSTEAD NOTHING; )DROP RULE "_DELETE" ON api.journalentry; apiadminfalse8628628629635"261888142_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO location DO INSTEAD DELETE FROM public.location WHERE ((location.location_warehous_id = public.getwarehousid((old.site)::text, 'ACTIVE'::text)) AND (location.location_name = (old.location)::text)); %DROP RULE "_DELETE" ON api.location; apiadminfalse86326616882668638638639635"261888149_DELETERULEGCREATE RULE "_DELETE" AS ON DELETE TO misccounttag DO INSTEAD NOTHING; )DROP RULE "_DELETE" ON api.misccounttag; apiadminfalse8648648649635"261888158_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO pricingschedule DO INSTEAD DELETE FROM public.ipshead WHERE ((old.name)::text = ipshead.ipshead_name); ,DROP RULE "_DELETE" ON api.pricingschedule; apiadminfalse8652478658659635"261888167_DELETERULE7CREATE RULE "_DELETE" AS ON DELETE TO pricingscheduleassign DO INSTEAD DELETE FROM public.ipsass WHERE ((((((ipsass.ipsass_ipshead_id = public.getipsheadid((old.pricing_schedule)::text)) AND (ipsass.ipsass_cust_id = CASE WHEN ((old.customer_number)::text = 'Any'::text) THEN (-1) ELSE public.getcustid((old.customer_number)::text) END)) AND (ipsass.ipsass_custtype_id = CASE WHEN ((old.customer_type)::text = 'N/A'::text) THEN (-1) ELSE public.getcusttypeid((old.customer_type)::text) END)) AND (ipsass.ipsass_custtype_pattern = (old.customer_type_pattern)::text)) AND (ipsass.ipsass_shipto_id = CASE WHEN ((old.customer_shipto)::text = 'Any'::text) THEN (-1) ELSE public.getshiptoid((old.customer_number)::text, (old.customer_shipto)::text) END)) AND (ipsass.ipsass_shipto_pattern = (old.customer_shipto_pattern)::text)); 2DROP RULE "_DELETE" ON api.pricingscheduleassign; apiadminfalse86615941592866268268866268268268166716202688668668668668669635"261888177_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO pricingscheduleitem DO INSTEAD SELECT CASE WHEN ((old.type)::text = 'Item'::text) THEN public.deleteipsitem(public.getipsitemid((old.pricing_schedule)::text, (old.item_number)::text, old.qty_break, (old.qty_uom)::text, (old.price_uom)::text)) WHEN ((old.type)::text = 'Product Category'::text) THEN public.deleteipsprodcat(public.getipsprodcatid((old.pricing_schedule)::text, (old.product_category)::text, old.qty_break)) ELSE NULL::integer END AS result; 0DROP RULE "_DELETE" ON api.pricingscheduleitem; apiadminfalse86713458671622867867162113468678678678678679635"261888185_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO pricingscheduleitemchar DO INSTEAD DELETE FROM public.ipsitemchar WHERE (((ipsitemchar.ipsitemchar_ipsitem_id = public.getipsitemid((old.pricing_schedule)::text, (old.item_number)::text, old.qty_break, (old.qty_uom)::text, (old.price_uom)::text)) AND (ipsitemchar.ipsitemchar_char_id = public.getcharid((old.characteristic)::text, 'I'::text))) AND (ipsitemchar.ipsitemchar_value = (old.value)::text)); 4DROP RULE "_DELETE" ON api.pricingscheduleitemchar; apiadminfalse868270868270270868157686816218688688688688689635"261888193_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO project DO INSTEAD SELECT public.deleteproject(public.getprjid(old.number)) AS deleteproject; $DROP RULE "_DELETE" ON api.project; apiadminfalse869164686913638699635"261888200_DELETERULEICREATE RULE "_DELETE" AS ON DELETE TO projectcomment DO INSTEAD NOTHING; +DROP RULE "_DELETE" ON api.projectcomment; apiadminfalse8708708709635"261888209_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO prospect DO INSTEAD DELETE FROM public.prospect WHERE (prospect.prospect_number = (old.prospect_number)::text); %DROP RULE "_DELETE" ON api.prospect; apiadminfalse8712728718719635#261888221_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO purchaseline DO INSTEAD DELETE FROM public.poitem WHERE (poitem.poitem_id = public.getpoitemid((old.order_number)::text, old.line_number)); )DROP RULE "_DELETE" ON api.purchaseline; apiadminfalse87287287287218116449635#261888231_DELETERULEKCREATE RULE "_DELETE" AS ON DELETE TO purchaselinechar DO INSTEAD NOTHING; -DROP RULE "_DELETE" ON api.purchaselinechar; apiadminfalse8738738739635#261888240_DELETERULENCREATE RULE "_DELETE" AS ON DELETE TO purchaselinecomment DO INSTEAD NOTHING; 0DROP RULE "_DELETE" ON api.purchaselinecomment; apiadminfalse8748748749635 #261888250_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO purchaseorder DO INSTEAD SELECT public.deletepo(pohead.pohead_id) AS deletepo FROM public.pohead WHERE (pohead.pohead_number = (old.order_number)::text); *DROP RULE "_DELETE" ON api.purchaseorder; apiadminfalse87587513578751801809635#261888257_DELETERULEOCREATE RULE "_DELETE" AS ON DELETE TO purchaseordercomment DO INSTEAD NOTHING; 1DROP RULE "_DELETE" ON api.purchaseordercomment; apiadminfalse8768768769635#261888267_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO quote DO INSTEAD SELECT public.deletequote(quhead.quhead_id, (old.quote_number)::text) AS deletequote FROM public.quhead WHERE (quhead.quhead_number = (old.quote_number)::text); "DROP RULE "_DELETE" ON api.quote; apiadminfalse87713708772772778779635#261888274_DELETERULEGCREATE RULE "_DELETE" AS ON DELETE TO quotecomment DO INSTEAD NOTHING; )DROP RULE "_DELETE" ON api.quotecomment; apiadminfalse8788788789635#261888284_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO quoteline DO INSTEAD DELETE FROM public.quitem WHERE ((quitem.quitem_quhead_id = public.getquoteid(old.quote_number)) AND (quitem.quitem_linenumber = old.line_number)); &DROP RULE "_DELETE" ON api.quoteline; apiadminfalse87927827816508798798799635 #261888294_DELETERULEHCREATE RULE "_DELETE" AS ON DELETE TO quotelinechar DO INSTEAD NOTHING; *DROP RULE "_DELETE" ON api.quotelinechar; apiadminfalse8808808809635$#261888302_DELETERULEKCREATE RULE "_DELETE" AS ON DELETE TO quotelinecomment DO INSTEAD NOTHING; -DROP RULE "_DELETE" ON api.quotelinecomment; apiadminfalse8818818819635*#261888317_DELETERULEGCREATE RULE "_DELETE" AS ON DELETE TO saleshistory DO INSTEAD NOTHING; )DROP RULE "_DELETE" ON api.saleshistory; apiadminfalse8838838839635.#261888329_DELETERULEHCREATE RULE "_DELETE" AS ON DELETE TO saleslinechar DO INSTEAD NOTHING; *DROP RULE "_DELETE" ON api.saleslinechar; apiadminfalse88488488496352#261888337_DELETERULEKCREATE RULE "_DELETE" AS ON DELETE TO saleslinecomment DO INSTEAD NOTHING; -DROP RULE "_DELETE" ON api.saleslinecomment; apiadminfalse88588588596356#261888347_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO salesorder DO INSTEAD SELECT public.deleteso(cohead.cohead_id, (old.order_number)::text) AS deleteso FROM public.cohead WHERE (cohead.cohead_number = (old.order_number)::text); 'DROP RULE "_DELETE" ON api.salesorder; apiadminfalse88688613771781788869635:#261888356_DELETERULELCREATE RULE "_DELETE" AS ON DELETE TO salesordercomment DO INSTEAD NOTHING; .DROP RULE "_DELETE" ON api.salesordercomment; apiadminfalse8878878879635>#261888364_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO salesrep DO INSTEAD DELETE FROM public.salesrep WHERE (salesrep.salesrep_number = (old.number)::text); %DROP RULE "_DELETE" ON api.salesrep; apiadminfalse8888881998889635B#261888374_DELETERULE7CREATE RULE "_DELETE" AS ON DELETE TO site DO NOTHING; !DROP RULE "_DELETE" ON api.site; apiadminfalse8898898899635F#261888382_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO sitezone DO INSTEAD DELETE FROM public.whsezone WHERE ((whsezone.whsezone_warehous_id = public.getwarehousid((old.site)::text, 'ACTIVE'::text)) AND (whsezone.whsezone_name = (old.name)::text)); %DROP RULE "_DELETE" ON api.sitezone; apiadminfalse89016888902678902678909635J#261888392_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO task DO INSTEAD DELETE FROM public.prjtask WHERE ((prjtask.prjtask_prj_id = public.getprjid(old.project_number)) AND (prjtask.prjtask_number = old.number)); !DROP RULE "_DELETE" ON api.task; apiadminfalse89116468912118912118919635N#261888399_DELETERULEFCREATE RULE "_DELETE" AS ON DELETE TO taskcomment DO INSTEAD NOTHING; (DROP RULE "_DELETE" ON api.taskcomment; apiadminfalse8928928929635R#261888409_DELETERULEwCREATE RULE "_DELETE" AS ON DELETE TO todo DO INSTEAD SELECT public.deletetodoitem(old.task_number) AS deletetodoitem; !DROP RULE "_DELETE" ON api.todo; apiadminfalse89313878938939635V#261888419_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO vendor DO INSTEAD DELETE FROM public.vendinfo WHERE (vendinfo.vend_number = (old.vendor_number)::text); #DROP RULE "_DELETE" ON api.vendor; apiadminfalse8941938948949635Z#261888429_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO vendoraddress DO INSTEAD SELECT public.deletevendoraddress(public.getvendaddrid((old.vendor_number)::text, (old.vendor_address_number)::text)) AS deletevendoraddress; *DROP RULE "_DELETE" ON api.vendoraddress; apiadminfalse895895895167513898959635^#261888436_DELETERULECREATE RULE "_DELETE" AS ON DELETE TO vendortype DO INSTEAD SELECT public.deletevendortype(public.getvendtypeid((old.code)::text)) AS deletevendortype; 'DROP RULE "_DELETE" ON api.vendortype; apiadminfalse896896168713908969635!261883857_INSERTRULEtCREATE RULE "_INSERT" AS ON INSERT TO salesline DO INSTEAD SELECT public.insertsalesline(new.*) AS insertsalesline; &DROP RULE "_INSERT" ON api.salesline; apiadminfalse1849701841849635!261883858_INSERTRULEkCREATE RULE "_INSERT" AS ON INSERT TO apmemo DO INSTEAD SELECT public.insertapmemo(new.*) AS insertapmemo; #DROP RULE "_INSERT" ON api.apmemo; apiadminfalse19419419423919635!261883859_INSERTRULEkCREATE RULE "_INSERT" AS ON INSERT TO armemo DO INSTEAD SELECT public.insertarmemo(new.*) AS insertarmemo; #DROP RULE "_INSERT" ON api.armemo; apiadminfalse20020020023929635!261883860_INSERTRULEvCREATE RULE "_INSERT" AS ON INSERT TO physinvcount DO INSTEAD SELECT insertphysinvcount(new.*) AS insertphysinvcount; )DROP RULE "_INSERT" ON api.physinvcount; apiadminfalse17717723981779635!261887651_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO account DO INSTEAD INSERT INTO public.crmacct (crmacct_number, crmacct_parent_id, crmacct_name, crmacct_active, crmacct_type, crmacct_cntct_id_1, crmacct_cntct_id_2, crmacct_notes) VALUES (COALESCE(new.account_number, ((public.fetchcrmaccountnumber())::text)::character varying), public.getcrmacctid(new.parent_account), new.account_name, COALESCE(new.active, true), CASE WHEN (new.type = 'Individual'::text) THEN 'I'::text ELSE 'O'::text END, public.savecntct(public.getcntctid(new.primary_contact_number), new.primary_contact_number, public.saveaddr(public.getaddrid(new.primary_contact_address_number), new.primary_contact_address_number, new.primary_contact_address1, new.primary_contact_address2, new.primary_contact_address3, new.primary_contact_city, new.primary_contact_state, new.primary_contact_postalcode, new.primary_contact_country, new.primary_contact_address_change), new.primary_contact_honorific, new.primary_contact_first, new.primary_contact_middle, new.primary_contact_last, new.primary_contact_suffix, new.primary_contact_voice, NULL::text, new.primary_contact_fax, new.primary_contact_email, NULL::text, new.primary_contact_job_title, new.primary_contact_change), public.savecntct(public.getcntctid(new.secondary_contact_number), new.secondary_contact_number, public.saveaddr(public.getaddrid(new.secondary_contact_address_number), new.secondary_contact_address_number, new.secondary_contact_address1, new.secondary_contact_address2, new.secondary_contact_address3, new.secondary_contact_city, new.secondary_contact_state, new.secondary_contact_postalcode, new.secondary_contact_country, new.secondary_contact_address_change), new.secondary_contact_honorific, new.secondary_contact_first, new.secondary_contact_middle, new.secondary_contact_last, new.secondary_contact_suffix, new.secondary_contact_voice, NULL::text, new.secondary_contact_fax, new.secondary_contact_email, NULL::text, new.secondary_contact_job_title, new.secondary_contact_change), new.notes); $DROP RULE "_INSERT" ON api.account; apiadminfalse8048048048048048042029158914471581156880480418820348048048048048048048048048048048048048048048048048048048048048048048048048048048048048048048048048048048048048048048048049635!261887660_INSERTRULENCREATE RULE "_INSERT" AS ON INSERT TO accountchar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('CRMACCT'::text, public.getcrmacctid((new.account_number)::text), public.getcharid((new.characteristic)::text, 'CRMACCT'::text), new.value, false); (DROP RULE "_INSERT" ON api.accountchar; apiadminfalse805158921515768058058058059635!261887667_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO accountcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'CRMA'::text, public.getcrmacctid((new.account_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); +DROP RULE "_INSERT" ON api.accountcomment; apiadminfalse8061589158015988068068062178068068069635!261887674_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO accountfile DO INSTEAD INSERT INTO public.url (url_source_id, url_source, url_title, url_url) VALUES (public.getcrmacctid(new.account_number), 'CRMA'::text, new.title, new.url); (DROP RULE "_INSERT" ON api.accountfile; apiadminfalse80780780780780722115899635"261887681_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO accountimage DO INSTEAD SELECT public.saveimageass('CRMA'::text, public.getcrmacctid(new.account_number), 'M'::bpchar, public.getimageid(new.image_name)) AS saveimageass; )DROP RULE "_INSERT" ON api.accountimage; apiadminfalse8081611158980820388088089635"261887688_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO address DO INSTEAD SELECT public.saveaddr(NULL::integer, (new.address_number)::text, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, COALESCE(new.active, true), new.notes, NULL::text) AS saveaddr; $DROP RULE "_INSERT" ON api.address; apiadminfalse80980920288098098098098098098098098098099635"261887695_INSERTRULEECREATE RULE "_INSERT" AS ON INSERT TO addresschar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('ADDR'::text, public.getaddrid((new.address_number)::text), public.getcharid((new.characteristic)::text, 'ADDR'::text), new.value, false); (DROP RULE "_INSERT" ON api.addresschar; apiadminfalse810810810156881021515768109635 "261887702_INSERTRULE}CREATE RULE "_INSERT" AS ON INSERT TO addresscomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'ADDR'::text, public.getaddrid((new.address_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); +DROP RULE "_INSERT" ON api.addresscomment; apiadminfalse8111580156815988118112178118118118119635"261887713_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO bom DO INSTEAD SELECT public.savebomhead(public.getitemid((new.item_number)::text), (new.revision)::text, new.revision_date, new.document_number, COALESCE(new.batch_size, (0)::numeric), new.total_qty_per) AS savebomhead; DROP RULE "_INSERT" ON api.bom; apiadminfalse812162381281220318128128128128129635"261887721_INSERTRULEGCREATE RULE "_INSERT" AS ON INSERT TO bomitem DO INSTEAD SELECT public.createbomitem(COALESCE(new.id, (nextval('public.bomitem_bomitem_id_seq'::regclass))::integer), public.getitemid((new.bom_item_number)::text), public.getitemid(new.item_number), COALESCE(new.sequence_number, (SELECT (max(bomitem.bomitem_seqnumber) + 10) FROM public.bomitem(public.getitemid((new.bom_item_number)::text), COALESCE(public.getrevid('BOM'::text, (new.bom_item_number)::text, (new.bom_revision)::text))) bomitem(bomitem_id, bomitem_parent_item_id, bomitem_seqnumber, bomitem_item_id, bomitem_qtyper, bomitem_scrap, bomitem_status, bomitem_effective, bomitem_expires, bomitem_createwo, bomitem_issuemethod, bomitem_schedatwooper, bomitem_ecn, bomitem_moddate, bomitem_subtype, bomitem_uom_id, bomitem_rev_id, bomitem_booitem_seq_id, bomitem_char_id, bomitem_value, bomitem_notes, bomitem_ref, bomitem_qtyfxd, bomitem_issuewo)), 10), (CASE WHEN (new.issue_method = 'Mixed'::text) THEN 'M'::text WHEN (new.issue_method = 'Push'::text) THEN 'S'::text WHEN (new.issue_method = 'Pull'::text) THEN 'L'::text ELSE public.fetchmetrictext('DefaultWomatlIssueMethod'::text) END)::bpchar, COALESCE(public.getuomid(new.issue_uom), (SELECT item.item_inv_uom_id FROM public.item WHERE (item.item_id = public.getitemid(new.item_number)))), new.qty_per, new.scrap, CASE WHEN (new.effective = 'Always'::text) THEN public.startoftime() ELSE COALESCE((new.effective)::date, public.startoftime()) END, CASE WHEN (new.expires = 'Never'::text) THEN public.endoftime() ELSE COALESCE((new.expires)::date, public.endoftime()) END, COALESCE(new.create_child_wo, false), COALESCE(public.getbooitemseqid((new.bom_item_number)::text, new.used_at), (-1)), COALESCE(new.schedule_at_wo_operation, false), new.ecn_number, (CASE WHEN (new.substitutions = 'No'::text) THEN 'N'::text WHEN (new.substitutions = 'BOM-Defined'::text) THEN 'B'::text ELSE 'I'::text END)::bpchar, COALESCE(public.getrevid('BOM'::text, (new.bom_item_number)::text, (new.bom_revision)::text)), public.getcharid(new.characteristic, 'I'::text), new.value, new.notes, new.reference) AS createbomitem; $DROP RULE "_INSERT" ON api.bomitem; apiadminfalse8138131623813813174157610908131573813813813813813813174813813813813813813813813210335514258131683165314569378138139635"261887731_INSERTRULE^CREATE RULE "_INSERT" AS ON INSERT TO bomitemcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'BMI'::text, new.bomitem_id, COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); +DROP RULE "_INSERT" ON api.bomitemcomment; apiadminfalse814159881421715808148148148148149635"261887739_INSERTRULENCREATE RULE "_INSERT" AS ON INSERT TO bomitemsubstitute DO INSTEAD INSERT INTO public.bomitemsub (bomitemsub_bomitem_id, bomitemsub_item_id, bomitemsub_uomratio, bomitemsub_rank) VALUES (new.bomitem_id, public.getitemid((new.substitute_item_number)::text), COALESCE(new.sub_parent_uom_ratio, (1)::numeric), COALESCE(new.ranking, 1)); .DROP RULE "_INSERT" ON api.bomitemsubstitute; apiadminfalse81581522616238158158158159635 "261887746_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO budget DO INSTEAD INSERT INTO public.budghead (budghead_name, budghead_descrip) VALUES (new.name, new.description); #DROP RULE "_INSERT" ON api.budget; apiadminfalse8168162278168169635$"261887753_INSERTRULE%CREATE RULE "_INSERT" AS ON INSERT TO budgetentry DO INSTEAD INSERT INTO public.budgitem (budgitem_budghead_id, budgitem_period_id, budgitem_accnt_id, budgitem_amount) VALUES (public.getbudgheadid(new.name), public.getperiodid(new.period_start), public.getglaccntid(new.account), new.amount); (DROP RULE "_INSERT" ON api.budgetentry; apiadminfalse8178178171639160981781715742298179635("261887761_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO cashreceipt DO INSTEAD INSERT INTO public.cashrcpt (cashrcpt_cust_id, cashrcpt_number, cashrcpt_amount, cashrcpt_fundstype, cashrcpt_docnumber, cashrcpt_bankaccnt_id, cashrcpt_notes, cashrcpt_distdate, cashrcpt_salescat_id, cashrcpt_curr_id, cashrcpt_usecustdeposit) VALUES (public.getcustid((new.customer_number)::text), (SELECT public.fetchcashrcptnumber() AS fetchcashrcptnumber), COALESCE(new.amount_received, (0)::numeric), CASE WHEN ((new.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((new.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((new.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((new.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((new.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((new.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((new.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((new.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((new.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, COALESCE(new.check_document_number, ''::character varying), public.getbankaccntid(new.post_to), COALESCE(new.notes, ''::text), CASE WHEN (new.distribution_date > ''::text) THEN ((new.distribution_date)::date)::timestamp with time zone ELSE now() END, COALESCE(public.getsalescatid(new.sales_category), (-1)), public.getcurrid((new.currency)::text), CASE WHEN (new.apply_balance_as = 'Customer Deposit'::text) THEN true ELSE false END); (DROP RULE "_INSERT" ON api.cashreceipt; apiadminfalse818159015718181445818818232818818165515928188188188188188189635,"261887772_INSERTRULETCREATE RULE "_INSERT" AS ON INSERT TO cashreceiptapply DO INSTEAD INSERT INTO public.cashrcptitem (cashrcptitem_cashrcpt_id, cashrcptitem_aropen_id, cashrcptitem_amount, cashrcptitem_discount) VALUES (public.getcashrcptid((new.customer_number)::text, CASE WHEN ((new.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((new.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((new.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((new.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((new.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((new.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((new.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((new.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((new.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (new.check_document_number)::text), public.getaropenid((new.customer_number)::text, (new.doc_type)::bpchar, (new.doc_number)::text), COALESCE(new.amount_to_apply, (0)::numeric), COALESCE(new.cashrcptitem_discount, (0)::numeric)); -DROP RULE "_INSERT" ON api.cashreceiptapply; apiadminfalse8192331570819157581981981981981981981996350"261887783_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO cashreceiptapplymisc DO INSTEAD INSERT INTO public.cashrcptmisc (cashrcptmisc_cashrcpt_id, cashrcptmisc_accnt_id, cashrcptmisc_amount, cashrcptmisc_notes) VALUES (public.getcashrcptid((new.customer_number)::text, CASE WHEN ((new.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((new.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((new.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((new.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((new.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((new.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((new.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((new.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((new.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (new.check_document_number)::text), public.getglaccntid((new.account)::text), COALESCE(new.amount_to_distribute, (0)::numeric), COALESCE(new.notes, ''::text)); 1DROP RULE "_INSERT" ON api.cashreceiptapplymisc; apiadminfalse8208201575160982023482082082082082096354"261887794_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO contact DO INSTEAD SELECT public.savecntct(NULL::integer, (new.contact_number)::text, public.getcrmacctid(new.crm_account), public.saveaddr(CASE WHEN (NOT (EXISTS (SELECT addr.addr_id FROM public.addr WHERE (addr.addr_number = new.address_number)))) THEN NULL::integer ELSE public.getaddrid(new.address_number) END, new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.address_change), new.honorific, new.first, new.middle, new.last, new.suffix, new.initials, COALESCE(new.active, true), new.voice, new.alternate, new.fax, new.email, new.web, new.notes, new.job_title, new.contact_change) AS savecntct; $DROP RULE "_INSERT" ON api.contact; apiadminfalse821213202921315891568203382182182182182182182182182182182182182182182182182182182182182182182182182182182196358"261887802_INSERTRULE@CREATE RULE "_INSERT" AS ON INSERT TO contactchar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('CNTCT'::text, public.getcntctid(new.contact_number), public.getcharid((new.characteristic)::text, 'CNTCT'::text), new.value, false); (DROP RULE "_INSERT" ON api.contactchar; apiadminfalse822158115768222158228228229635<"261887809_INSERTRULEsCREATE RULE "_INSERT" AS ON INSERT TO contactcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'T'::text, public.getcntctid(new.contact_number), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); +DROP RULE "_INSERT" ON api.contactcomment; apiadminfalse8231581158021715988238238238238238239635@"261887818_INSERTRULEwCREATE RULE "_INSERT" AS ON INSERT TO creditmemo DO INSTEAD SELECT public.insertcreditmemo(new.*) AS insertcreditmemo; 'DROP RULE "_INSERT" ON api.creditmemo; apiadminfalse82482423938249635D"261887829_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO creditmemoline DO INSTEAD SELECT public.insertcreditmemoline(new.*) AS insertcreditmemoline; +DROP RULE "_INSERT" ON api.creditmemoline; apiadminfalse82523948258259635H"261887837_INSERTRULE=CREATE RULE "_INSERT" AS ON INSERT TO custchar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('C'::text, public.getcustid((new.customer_number)::text), public.getcharid((new.characteristic)::text, 'C'::text), new.value, false); %DROP RULE "_INSERT" ON api.custchar; apiadminfalse826826826157682621515928269635L"261887844_INSERTRULExCREATE RULE "_INSERT" AS ON INSERT TO custcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'C'::text, public.getcustid((new.customer_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); (DROP RULE "_INSERT" ON api.custcomment; apiadminfalse8271592158015982178278278278278278279635P"261887852_INSERTRULE\CREATE RULE "_INSERT" AS ON INSERT TO custcreditcard DO INSTEAD SELECT public.insertccard((new.customer_number)::text, new.active, new.credit_card_type, new.credit_card_number, new.name, new.street_address1, new.street_address2, new.city, new.state, new.postal_code, new.country, new.expiration_month, new.expiration_year, new.key) AS insertccard; +DROP RULE "_INSERT" ON api.custcreditcard; apiadminfalse82882882882882817228288288288288288288288288288288289635T"261887860_INSERTRULE0CREATE RULE "_INSERT" AS ON INSERT TO customer DO INSTEAD INSERT INTO public.custinfo (cust_active, cust_custtype_id, cust_salesrep_id, cust_commprcnt, cust_name, cust_creditlmt, cust_creditrating, cust_backorder, cust_partialship, cust_terms_id, cust_discntprcnt, cust_balmethod, cust_ffshipto, cust_shipform_id, cust_shipvia, cust_blanketpos, cust_shipchrg_id, cust_creditstatus, cust_comments, cust_ffbillto, cust_usespos, cust_number, cust_autoupdatestatus, cust_autoholdorders, cust_preferred_warehous_id, cust_curr_id, cust_creditlmt_curr_id, cust_cntct_id, cust_corrcntct_id, cust_taxzone_id, cust_gracedays) VALUES (COALESCE(new.active, true), COALESCE((public.getcusttypeid(new.customer_type))::numeric, public.fetchmetricvalue('DefaultCustType'::text)), COALESCE((public.getsalesrepid(new.sales_rep))::numeric, public.fetchmetricvalue('DefaultSalesRep'::text)), COALESCE((new.commission * 0.01), (SELECT salesrep.salesrep_commission FROM public.salesrep WHERE (salesrep.salesrep_id = public.getsalesrepid(new.sales_rep)))), COALESCE(new.customer_name, ''::text), COALESCE((new.credit_limit)::numeric, public.fetchmetricvalue('SOCreditLimit'::text)), COALESCE(new.credit_rating, public.fetchmetrictext('SOCreditRate'::text)), COALESCE(new.accepts_backorders, public.fetchmetricbool('DefaultBackOrders'::text), false), COALESCE(new.accepts_partial_shipments, public.fetchmetricbool('DefaultPartialShipments'::text), false), COALESCE((public.gettermsid(new.default_terms))::numeric, public.fetchmetricvalue('DefaultTerms'::text)), COALESCE(new.default_discount, (0)::numeric), CASE WHEN (new.balance_method = 'Balance Forward'::text) THEN 'B'::text WHEN (new.balance_method = 'Open Items'::text) THEN 'O'::text ELSE COALESCE(public.fetchmetrictext('DefaultBalanceMethod'::text), 'B'::text) END, COALESCE(new.allow_free_form_shipto, public.fetchmetricbool('DefaultFreeFormShiptos'::text), false), COALESCE((public.getshipformid(new.ship_form))::numeric, public.fetchmetricvalue('DefaultShipFormId'::text)), COALESCE(new.ship_via, public.fetchdefaultshipvia()), COALESCE(new.uses_blanket_pos, false), COALESCE(public.getshipchrgid(new.shipping_charges), (-1)), CASE WHEN (new.credit_status = 'On Credit Warning'::text) THEN 'W'::text WHEN (new.credit_status = 'On Credit Hold'::text) THEN 'H'::text ELSE 'G'::text END, COALESCE(new.notes, ''::text), COALESCE(new.allow_free_form_billto, false), COALESCE(new.uses_purchase_orders, false), COALESCE(upper((new.customer_number)::text), (public.fetchcrmaccountnumber())::text), COALESCE(new.credit_status_exceed_warn, false), COALESCE(new.credit_status_exceed_hold, false), COALESCE(public.getwarehousid(new.preferred_selling_site, 'ACTIVE'::text), (-1)), COALESCE(public.getcurrid((new.default_currency)::text), public.basecurrid()), COALESCE(public.getcurrid((new.credit_limit_currency)::text), public.basecurrid()), public.savecntct(public.getcntctid(new.billing_contact_number, false), new.billing_contact_number, public.saveaddr(public.getaddrid(new.billing_contact_address_number), new.billing_contact_address_number, new.billing_contact_address1, new.billing_contact_address2, new.billing_contact_address3, new.billing_contact_city, new.billing_contact_state, new.billing_contact_postalcode, new.billing_contact_country, new.billing_contact_address_change), new.billing_contact_honorific, new.billing_contact_first, new.billing_contact_middle, new.billing_contact_last, new.billing_contact_suffix, new.billing_contact_voice, new.billing_contact_alternate, new.billing_contact_fax, new.billing_contact_email, new.billing_contact_web, new.billing_contact_job_title, new.billing_contact_change), public.savecntct(public.getcntctid(new.correspond_contact_number, false), new.correspond_contact_number, public.saveaddr(public.getaddrid(new.correspond_contact_address_number), new.correspond_contact_address_number, new.correspond_contact_address1, new.correspond_contact_address2, new.correspond_contact_address3, new.correspond_contact_city, new.correspond_contact_state, new.correspond_contact_postalcode, new.correspond_contact_country, new.correspond_contact_address_change), new.correspond_contact_honorific, new.correspond_contact_first, new.correspond_contact_middle, new.correspond_contact_last, new.correspond_contact_suffix, new.correspond_contact_voice, new.correspond_contact_alternate, new.correspond_contact_fax, new.correspond_contact_email, new.correspond_contact_web, new.correspond_contact_job_title, new.correspond_contact_change), public.gettaxzoneid(new.default_tax_zone), CASE WHEN (COALESCE(new.alternate_grace_days, 0) > 0) THEN new.alternate_grace_days ELSE NULL::integer END); %DROP RULE "_INSERT" ON api.customer; apiadminfalse8291991447196829108714551449158215901456156814572029166316601594203416881664168116808298298291998298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298298299635X"261887871_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO customertaxreg DO INSTEAD INSERT INTO public.taxreg (taxreg_rel_id, taxreg_rel_type, taxreg_taxauth_id, taxreg_taxzone_id, taxreg_number, taxreg_effective, taxreg_expires, taxreg_notes) VALUES (public.getcustid((new.customer_number)::text), 'C'::bpchar, public.gettaxauthid((new.tax_authority)::text), (SELECT custinfo.cust_taxzone_id FROM public.custinfo WHERE (custinfo.cust_id = public.getcustid((new.customer_number)::text))), COALESCE(new.registration_number, ''::text), CASE WHEN (new.start_date = 'Always'::text) THEN public.startoftime() ELSE COALESCE((new.start_date)::date, public.startoftime()) END, CASE WHEN (new.end_date = 'Never'::text) THEN public.endoftime() ELSE COALESCE((new.end_date)::date, public.endoftime()) END, new.notes); +DROP RULE "_INSERT" ON api.customertaxreg; apiadminfalse83021038301677159214258302401961968308308308308309635Z"261887877_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO customertype DO INSTEAD INSERT INTO public.custtype (custtype_code, custtype_descrip, custtype_char) VALUES (new.code, COALESCE(new.description, ''::text), COALESCE(new.enable_characteristics_profile, false)); )DROP RULE "_INSERT" ON api.customertype; apiadminfalse8312368318318318319635^"261887884_INSERTRULEcCREATE RULE "_INSERT" AS ON INSERT TO customertypechar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('CT'::text, public.getcusttypeid((new.customer_type)::text), public.getcharid((new.characteristic)::text, 'CT'::text), new.value, COALESCE(new.is_default, false)); -DROP RULE "_INSERT" ON api.customertypechar; apiadminfalse832215159415768328328328328329635b"261887892_INSERTRULE CREATE RULE "_INSERT" AS ON INSERT TO custshipto DO INSTEAD INSERT INTO public.shiptoinfo (shipto_cust_id, shipto_name, shipto_salesrep_id, shipto_comments, shipto_shipcomments, shipto_shipzone_id, shipto_shipvia, shipto_commission, shipto_shipform_id, shipto_shipchrg_id, shipto_active, shipto_default, shipto_num, shipto_ediprofile_id, shipto_cntct_id, shipto_addr_id, shipto_taxzone_id) VALUES (public.getcustid((new.customer_number)::text), COALESCE(new.name, ''::text), COALESCE(public.getsalesrepid(new.sales_rep), (SELECT custinfo.cust_salesrep_id FROM public.custinfo WHERE (custinfo.cust_id = public.getcustid((new.customer_number)::text)))), COALESCE(new.general_notes, ''::text), COALESCE(new.shipping_notes, ''::text), public.getshipzoneid(new.zone), COALESCE(new.ship_via, (SELECT custinfo.cust_shipvia FROM public.custinfo WHERE (custinfo.cust_id = public.getcustid((new.customer_number)::text)))), COALESCE((new.commission / 100.0), (0)::numeric), COALESCE(public.getshipformid(new.ship_form), (SELECT custinfo.cust_shipform_id FROM public.custinfo WHERE (custinfo.cust_id = public.getcustid((new.customer_number)::text)))), COALESCE(public.getshipchrgid(new.shipping_charges), (SELECT custinfo.cust_shipchrg_id FROM public.custinfo WHERE (custinfo.cust_id = public.getcustid((new.customer_number)::text)))), COALESCE(new.active, true), COALESCE(new.default_flag, false), COALESCE(new.shipto_number, (((SELECT (COALESCE(max((shiptoinfo.shipto_num)::integer), 0) + 1) FROM public.shiptoinfo WHERE ((shiptoinfo.shipto_cust_id = public.getcustid((new.customer_number)::text)) AND (shiptoinfo.shipto_num ~ '^[0-9]*$'::text))))::text)::character varying), CASE WHEN (new.edi_profile = 'No EDI'::text) THEN (-1) WHEN (new.edi_profile = 'Use Customer Master'::text) THEN (-2) ELSE public.getediprofileid(new.edi_profile) END, public.savecntct(public.getcntctid(new.contact_number), new.contact_number, NULL::integer, new.honorific, new.first, new.middle, new.last, new.suffix, new.phone, NULL::text, new.fax, new.email, NULL::text, new.job_title, new.contact_change), public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.address_change), COALESCE(public.gettaxzoneid(new.tax_zone), (SELECT custinfo.cust_taxzone_id FROM public.custinfo WHERE (custinfo.cust_id = public.getcustid((new.customer_number)::text))))); 'DROP RULE "_INSERT" ON api.custshipto; apiadminfalse833166015688338338338338331664166383383383383383383383383383383383315818331596159283383383383383383383383383383383383383383383383383383383320220219616701961680202920341961961961969635f"261887901_INSERTRULE$CREATE RULE "_INSERT" AS ON INSERT TO custtax DO INSTEAD INSERT INTO public.taxreg (taxreg_rel_type, taxreg_rel_id, taxreg_taxauth_id, taxreg_number) VALUES ('C'::bpchar, public.getcustid((new.customer_number)::text), public.gettaxauthid((new.tax_authority)::text), new.registration_number); $DROP RULE "_INSERT" ON api.custtax; apiadminfalse834834240167715928348348349635j"261887909_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO employee DO INSTEAD INSERT INTO public.emp (emp_code, emp_number, emp_active, emp_cntct_id, emp_warehous_id, emp_mgr_emp_id, emp_wage_type, emp_wage, emp_wage_curr_id, emp_wage_period, emp_dept_id, emp_shift_id, emp_image_id, emp_extrate, emp_extrate_period, emp_startdate, emp_notes) VALUES (new.code, new.number, COALESCE(new.active, true), public.savecntct(public.getcntctid(new.contact_number), new.contact_number, public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change), new.honorific, new.first, new.middle, new.last, new.suffix, new.voice, new.alternate, new.fax, new.email, new.web, new.job_title, new.contact_change), public.getwarehousid(new.site, 'ALL'::text), (SELECT emp.emp_id FROM public.emp WHERE (emp.emp_code = new.manager_code)), CASE WHEN (new.wage_type = 'Hourly'::text) THEN 'H'::text WHEN (new.wage_type = 'Salaried'::text) THEN 'S'::text ELSE NULL::text END, new.wage, COALESCE(public.getcurrid((new.wage_currency)::text), public.basecurrid()), CASE WHEN (new.wage_period = 'Hour'::text) THEN 'H'::text WHEN (new.wage_period = 'Day'::text) THEN 'D'::text WHEN (new.wage_period = 'Week'::text) THEN 'W'::text WHEN (new.wage_period = 'Biweek'::text) THEN 'BW'::text WHEN (new.wage_period = 'Month'::text) THEN 'M'::text WHEN (new.wage_period = 'Year'::text) THEN 'Y'::text ELSE NULL::text END, public.getdeptid(new.department), public.getshiftid(new.shift), public.getimageid(new.image), new.rate, CASE WHEN (new.billing_period = 'Hour'::text) THEN 'H'::text WHEN (new.billing_period = 'Day'::text) THEN 'D'::text WHEN (new.billing_period = 'Week'::text) THEN 'W'::text WHEN (new.billing_period = 'Biweek'::text) THEN 'BW'::text WHEN (new.billing_period = 'Month'::text) THEN 'M'::text WHEN (new.billing_period = 'Year'::text) THEN 'Y'::text ELSE NULL::text END, new.start_date, COALESCE(new.notes, ''::text)); %DROP RULE "_INSERT" ON api.employee; apiadminfalse83583583583515952421590835158115681087166216112422034168820298358358358358358358358358358358358358358358358358358358358358358358358358358358358358358358358358358358359635n"261887918_INSERTRULEBCREATE RULE "_INSERT" AS ON INSERT TO employeechar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('EMP'::text, public.getempid((new.employee_code)::text), public.getcharid((new.characteristic)::text, 'EMP'::text), new.value, false); )DROP RULE "_INSERT" ON api.employeechar; apiadminfalse836215160015768368368368369635r"261887925_INSERTRULEzCREATE RULE "_INSERT" AS ON INSERT TO employeecomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'EMP'::text, public.getempid((new.code)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid((new.type)::text), new.text); ,DROP RULE "_INSERT" ON api.employeecomment; apiadminfalse8371598837158083721716008378378378379635v"261887932_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO extshipmaint DO INSTEAD INSERT INTO public.shipdata (shipdata_cohead_number, shipdata_shiphead_number, shipdata_void_ind, shipdata_shipper, shipdata_billing_option, shipdata_weight, shipdata_base_freight, shipdata_base_freight_curr_id, shipdata_total_freight, shipdata_total_freight_curr_id, shipdata_package_type, shipdata_cosmisc_tracknum, shipdata_cosmisc_packnum_tracknum, shipdata_lastupdated) VALUES (new.so_number, new.shipment_number, new.void, new.shipper, new.billing_option, new.weight, new.base_freight, public.getcurrid((new.base_freight_currency)::text), new.total_freight, public.getcurrid((new.total_freight_currency)::text), new.package_type, new.tracking_number, new.package_tracking_number, new.last_updated); )DROP RULE "_INSERT" ON api.extshipmaint; apiadminfalse83883883883883883883883883883883883883883824415908388389635z"261887940_INSERTRULEhCREATE RULE "_INSERT" AS ON INSERT TO freightpricingscheduleitem DO INSTEAD INSERT INTO public.ipsfreight (ipsfreight_ipshead_id, ipsfreight_qtybreak, ipsfreight_price, ipsfreight_type, ipsfreight_warehous_id, ipsfreight_shipzone_id, ipsfreight_freightclass_id, ipsfreight_shipvia) VALUES (public.getipsheadid((new.pricing_schedule)::text), new.qty_break, new.price, CASE WHEN (new.price_type = 'Flat Rate'::text) THEN 'F'::text ELSE 'P'::text END, CASE WHEN (new.from_site = 'Any'::text) THEN NULL::integer ELSE public.getwarehousid(new.from_site, 'All'::text) END, CASE WHEN (new.to_shipzone = 'Any'::text) THEN NULL::integer ELSE public.getshipzoneid(new.to_shipzone) END, CASE WHEN (new.freight_class = 'Any'::text) THEN NULL::integer ELSE public.getfreightclassid(new.freight_class) END, CASE WHEN (new.ship_via = 'Any'::text) THEN NULL::text ELSE new.ship_via END); 7DROP RULE "_INSERT" ON api.freightpricingscheduleitem; apiadminfalse83983983983916701620160683924683916888398398398399635~"261887950_INSERTRULE0CREATE RULE "_INSERT" AS ON INSERT TO glaccount DO INSTEAD INSERT INTO public.accnt (accnt_number, accnt_descrip, accnt_comments, accnt_profit, accnt_sub, accnt_type, accnt_extref, accnt_company, accnt_forwardupdate, accnt_subaccnttype_code) VALUES (COALESCE(new.account_number, ''::character varying), COALESCE(new.description, ''::text), COALESCE(new.notes, ''::text), new.profit_center, new.sub_account, CASE WHEN (new.type = 'Asset'::text) THEN 'A'::text WHEN (new.type = 'Liability'::text) THEN 'L'::text WHEN (new.type = 'Expense'::text) THEN 'E'::text WHEN (new.type = 'Revenue'::text) THEN 'R'::text WHEN (new.type = 'Equity'::text) THEN 'Q'::text ELSE NULL::text END, COALESCE(new.ext_reference, ''::text), new.company, COALESCE(new.forward_update_trial_balances, false), COALESCE(new.sub_type, ''::text)); &DROP RULE "_INSERT" ON api.glaccount; apiadminfalse8408408408408408408408408402288408408409635"261887959_INSERTRULElCREATE RULE "_INSERT" AS ON INSERT TO incident DO INSTEAD INSERT INTO public.incdt (incdt_number, incdt_crmacct_id, incdt_cntct_id, incdt_summary, incdt_descrip, incdt_item_id, incdt_status, incdt_assigned_username, incdt_incdtcat_id, incdt_incdtseverity_id, incdt_incdtpriority_id, incdt_incdtresolution_id, incdt_lotserial, incdt_ls_id) VALUES (new.incident_number, public.getcrmacctid(new.crm_account), public.savecntct(public.getcntctid(new.contact_number), new.contact_number, NULL::integer, new.honorific, new.first, new.middle, new.last, new.suffix, new.phone, NULL::text, new.fax, new.email, NULL::text, new.job_title, new.contact_change), COALESCE(new.description, ''::text), COALESCE(new.notes, ''::text), public.getitemid(new.item_number), CASE WHEN (new.status = 'New'::text) THEN 'N'::text WHEN (new.status = 'Feedback'::text) THEN 'F'::text WHEN (new.status = 'Confirmed'::text) THEN 'C'::text WHEN (new.status = 'Assigned'::text) THEN 'A'::text WHEN (new.status = 'Resolved'::text) THEN 'R'::text WHEN (new.status = 'Closed'::text) THEN 'L'::text ELSE ''::text END, COALESCE(new.assigned_to, ''::text), public.getincdtcatid(new.category), public.getincdtseverityid(new.severity), public.getincdtpriorityid(new.priority), public.getincdtresolutionid(new.resolution), COALESCE(new.lot_serial_number, ''::text), public.getlotserialid(new.item_number, new.lot_serial_number)); %DROP RULE "_INSERT" ON api.incident; apiadminfalse8418418418411581841189161416121589203416331615162316168418418418418418418418418418418418418418418418418418418418419635"261887968_INSERTRULEECREATE RULE "_INSERT" AS ON INSERT TO incidentchar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('INCDT'::text, public.getincidentid(new.incident_number), public.getcharid((new.characteristic)::text, 'INCDT'::text), new.value, false); )DROP RULE "_INSERT" ON api.incidentchar; apiadminfalse842215161715768428428428429635"261887976_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO incidentcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text, comment_public) VALUES (COALESCE(new.date, now()), 'INCDT'::text, public.getincidentid(new.incident_number), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text, COALESCE(new.public, true)); ,DROP RULE "_INSERT" ON api.incidentcomment; apiadminfalse8438438438432171580159884316178438438439635"261887982_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO incidentfile DO INSTEAD INSERT INTO public.url (url_source_id, url_source, url_title, url_url) VALUES (public.getincidentid(new.incident_number), 'INCDT'::text, new.title, new.url); )DROP RULE "_INSERT" ON api.incidentfile; apiadminfalse84484484422184416178449635"261887989_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO incidentimage DO INSTEAD SELECT public.saveimageass('INCDT'::text, public.getincidentid(new.incident_number), 'M'::bpchar, public.getimageid(new.image_name)) AS saveimageass; *DROP RULE "_INSERT" ON api.incidentimage; apiadminfalse8458458452038161716118459635"261887999_INSERTRULEnCREATE RULE "_INSERT" AS ON INSERT TO invoice DO INSTEAD SELECT public.insertinvoice(new.*) AS insertinvoice; $DROP RULE "_INSERT" ON api.invoice; apiadminfalse84684623958469635"261888010_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO invoiceline DO INSTEAD SELECT public.insertinvoicelineitem(new.*) AS insertinvoicelineitem; (DROP RULE "_INSERT" ON api.invoiceline; apiadminfalse84784723968479635"261888018_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO item DO INSTEAD INSERT INTO public.item (item_number, item_active, item_descrip1, item_descrip2, item_type, item_maxcost, item_classcode_id, item_inv_uom_id, item_picklist, item_fractional, item_config, item_sold, item_prodcat_id, item_exclusive, item_listprice, item_listcost, item_price_uom_id, item_upccode, item_prodweight, item_packweight, item_comments, item_extdescrip) VALUES (upper((new.item_number)::text), COALESCE(new.active, true), COALESCE(new.description1, ''::text), COALESCE(new.description2, ''::text), CASE WHEN (new.item_type = 'Purchased'::text) THEN 'P'::text WHEN (new.item_type = 'Manufactured'::text) THEN 'M'::text WHEN (new.item_type = 'Job'::text) THEN 'J'::text WHEN (new.item_type = 'Kit'::text) THEN 'K'::text WHEN (new.item_type = 'Phantom'::text) THEN 'F'::text WHEN (new.item_type = 'Reference'::text) THEN 'R'::text WHEN (new.item_type = 'Costing'::text) THEN 'S'::text WHEN (new.item_type = 'Tooling'::text) THEN 'T'::text WHEN (new.item_type = 'Outside Process'::text) THEN 'O'::text WHEN (new.item_type = 'Planning'::text) THEN 'L'::text WHEN (new.item_type = 'Breeder'::text) THEN 'B'::text WHEN (new.item_type = 'Co-Product'::text) THEN 'C'::text WHEN (new.item_type = 'By-Product'::text) THEN 'Y'::text ELSE NULL::text END, COALESCE(new.maximum_desired_cost, (0)::numeric), public.getclasscodeid(new.class_code), public.getuomid(new.inventory_uom), COALESCE(new.pick_list_item, true), COALESCE(new.fractional, false), COALESCE(new.configured, false), COALESCE(new.item_is_sold, true), COALESCE(public.getprodcatid(new.product_category), (-1)), COALESCE(new.exclusive, false), COALESCE(new.list_price, (0)::numeric), COALESCE(new.list_cost, (0)::numeric), COALESCE(public.getuomid(new.list_price_uom), public.getuomid(new.inventory_uom)), new.upc_code, COALESCE(new.product_weight, (0)::numeric), COALESCE(new.packaging_weight, (0)::numeric), new.notes, new.ext_description); !DROP RULE "_INSERT" ON api.item; apiadminfalse8488488488488481683164884815778481748488488488488488488488488488488488488488488488488489635"261888028_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO itemalias DO INSTEAD INSERT INTO public.itemalias (itemalias_item_id, itemalias_number, itemalias_usedescrip, itemalias_descrip1, itemalias_descrip2, itemalias_comments, itemalias_crmacct_id) VALUES (public.getitemid((new.item_number)::text), new.alias_number, COALESCE(new.use_description, false), COALESCE(new.description1, ''::text), COALESCE(new.description2, ''::text), new.comments, public.getcrmacctid(new.crmacct_number)); &DROP RULE "_INSERT" ON api.itemalias; apiadminfalse849849849849254162384915898498498498499635"261888035_INSERTRULESCREATE RULE "_INSERT" AS ON INSERT TO itemchar DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value, charass_default) VALUES ('I'::text, public.getitemid((new.item_number)::text), public.getcharid((new.characteristic)::text, 'I'::text), new.value, COALESCE(new.is_default, false)); %DROP RULE "_INSERT" ON api.itemchar; apiadminfalse850162315768508508502158508509635"261888042_INSERTRULEuCREATE RULE "_INSERT" AS ON INSERT TO itemcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'IS'::text, public.getitemid((new.item_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); (DROP RULE "_INSERT" ON api.itemcomment; apiadminfalse8511598851162315808512178518518518519635"261888050_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO itemcost DO INSTEAD SELECT public.insertitemcost(public.getitemid((new.item_number)::text), public.getcostelemid((new.costing_element)::text), public.getcurrid((new.currency)::text), new.actual_cost, new.post_to_standard) AS insertitemcost; %DROP RULE "_INSERT" ON api.itemcost; apiadminfalse85285285215878528521623159085217298529635"261888057_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO itemfile DO INSTEAD INSERT INTO public.url (url_source_id, url_source, url_title, url_url) VALUES (public.getitemid((new.item_number)::text), 'I'::text, new.title, new.url); %DROP RULE "_INSERT" ON api.itemfile; apiadminfalse85385322116238538538539635"261888065_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO itemimage DO INSTEAD SELECT public.saveimageass('I'::text, public.getitemid((new.item_number)::text), (CASE WHEN (new.purpose = 'Product Description'::text) THEN 'P'::text WHEN (new.purpose = 'Inventory Description'::text) THEN 'I'::text WHEN (new.purpose = 'Engineering Reference'::text) THEN 'E'::text WHEN (new.purpose = 'Miscellaneous'::text) THEN 'M'::text ELSE 'X'::text END)::bpchar, public.getimageid(new.image_name)) AS saveimageass; &DROP RULE "_INSERT" ON api.itemimage; apiadminfalse8541623161185485420388548549635"261888073_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO itemsite DO INSTEAD INSERT INTO public.itemsite (itemsite_item_id, itemsite_warehous_id, itemsite_active, itemsite_dropship, itemsite_posupply, itemsite_createpr, itemsite_wosupply, itemsite_createwo, itemsite_createsopr, itemsite_createsopo, itemsite_sold, itemsite_soldranking, itemsite_costmethod, itemsite_controlmethod, itemsite_perishable, itemsite_plancode_id, itemsite_costcat_id, itemsite_loccntrl, itemsite_location_id, itemsite_recvlocation_id, itemsite_issuelocation_id, itemsite_location_dist, itemsite_recvlocation_dist, itemsite_issuelocation_dist, itemsite_location, itemsite_location_comments, itemsite_disallowblankwip, itemsite_stocked, itemsite_abcclass, itemsite_autoabcclass, itemsite_cyclecountfreq, itemsite_eventfence, itemsite_useparams, itemsite_reorderlevel, itemsite_ordertoqty, itemsite_minordqty, itemsite_maxordqty, itemsite_multordqty, itemsite_useparamsmanual, itemsite_ordergroup, itemsite_ordergroup_first, itemsite_mps_timefence, itemsite_leadtime, itemsite_safetystock, itemsite_supply_itemsite_id, itemsite_notes, itemsite_qtyonhand, itemsite_warrpurc, itemsite_autoreg, itemsite_freeze, itemsite_value, itemsite_planning_type) VALUES (public.getitemid((new.item_number)::text), public.getwarehousid((new.site)::text, 'ACTIVE'::text), COALESCE(new.active, true), COALESCE(new.dropship, false), COALESCE(new.po_supplied_at_site, false), COALESCE(new.create_prs, false), COALESCE(new.wo_supplied_at_site, false), COALESCE(new.create_wos, false), COALESCE(new.create_soprs, false), COALESCE(new.create_sopos, false), COALESCE(new.sold_from_site, true), COALESCE(new.ranking, 1), CASE WHEN (new.cost_method = 'None'::text) THEN 'N'::text WHEN (new.cost_method = 'Average'::text) THEN 'A'::text WHEN (new.cost_method = 'Standard'::text) THEN 'S'::text WHEN (new.cost_method = 'Job'::text) THEN 'J'::text ELSE NULL::text END, CASE WHEN (new.control_method = 'None'::text) THEN 'N'::text WHEN (new.control_method = 'Regular'::text) THEN 'R'::text WHEN (new.control_method = 'Serial #'::text) THEN 'S'::text WHEN (new.control_method = 'Lot #'::text) THEN 'L'::text ELSE NULL::text END, COALESCE(new.perishable, false), public.getplancodeid(new.planner_code), public.getcostcatid(new.cost_category), COALESCE(new.multiple_location_control, false), COALESCE(public.getlocationid((new.site)::text, new.location), (-1)), COALESCE(public.getlocationid((new.site)::text, new.receive_location), (-1)), COALESCE(public.getlocationid((new.site)::text, new.issue_location), (-1)), COALESCE(new.auto_distr_location, false), COALESCE(new.auto_distr_receive_location, false), COALESCE(new.auto_distr_issue_location, false), COALESCE(new.user_defined_location, ''::text), COALESCE(new.location_comment, ''::text), COALESCE(new.disallow_blank_wip_locations, false), COALESCE(new.stocked, false), COALESCE(new.abc_class, 'A'::bpchar), COALESCE(new.allow_automatic_updates, false), COALESCE(new.cycl_cnt_freq, 0), COALESCE((new.event_fence)::numeric, public.fetchmetricvalue('DefaultEventFence'::text)), COALESCE(new.enforce_order_parameters, false), COALESCE(new.reorder_level, (0)::numeric), COALESCE(new.order_up_to, (0)::numeric), COALESCE(new.minimum_order, (0)::numeric), COALESCE(new.maximum_order, (0)::numeric), COALESCE(new.order_multiple, (0)::numeric), COALESCE(new.enforce_on_manual_orders, false), COALESCE(new.group_mps_mrp_orders, 0), COALESCE(new.first_group, false), COALESCE(new.mps_time_fence, 0), COALESCE(new.lead_time, 0), COALESCE(new.safety_stock, (0)::numeric), CASE WHEN (new.supplied_from_site = 'None'::text) THEN NULL::integer WHEN (new.supplied_from_site = ''::text) THEN NULL::integer ELSE public.getitemsiteid(new.supplied_from_site, (new.item_number)::text) END, COALESCE(new.notes, ''::text), 0, COALESCE(new.require_warranty, false), COALESCE(new.auto_register, false), false, 0, CASE WHEN (new.planning_system = 'None'::text) THEN 'N'::text WHEN (new.planning_system = 'MPS'::text) THEN 'S'::text ELSE 'M'::text END); %DROP RULE "_INSERT" ON api.itemsite; apiadminfalse85585585585585585585516238551586162514578558558558551635163285517516888558558558558558558558558558558558558558558558558558558558558558558558558558558558558558558558558558558558558558559635"261888083_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO itemsitecomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'IS'::text, public.getitemsiteid((new.site)::text, (new.item_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); ,DROP RULE "_INSERT" ON api.itemsitecomment; apiadminfalse8568568561598158085685621716258568568569635"261888091_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO itemsource DO INSTEAD INSERT INTO public.itemsrc (itemsrc_item_id, itemsrc_vend_id, itemsrc_vend_item_number, itemsrc_vend_item_descrip, itemsrc_comments, itemsrc_vend_uom, itemsrc_invvendoruomratio, itemsrc_minordqty, itemsrc_multordqty, itemsrc_leadtime, itemsrc_ranking, itemsrc_active, itemsrc_default, itemsrc_manuf_name, itemsrc_manuf_item_number, itemsrc_manuf_item_descrip, itemsrc_upccode, itemsrc_contrct_id, itemsrc_effective, itemsrc_expires) VALUES (public.getitemid((new.item_number)::text), public.getvendid((new.vendor)::text), new.vendor_item_number, COALESCE(new.vendor_description, ''::text), COALESCE(new.notes, ''::text), new.vendor_uom, new.inventory_vendor_uom_ratio, new.minimum_order, new.order_multiple, new.lead_time, new.vendor_ranking, COALESCE(new.active, true), COALESCE(new.itemsrc_default, true), COALESCE(new.manufacturer_name, ''::text), COALESCE(new.manufacturer_item_number, ''::text), new.manufacturer_description, new.bar_code, public.getcontrctid(new.contract_number), COALESCE(public.getcontrcteffective(new.contract_number), new.effective_date), COALESCE(public.getcontrctexpires(new.contract_number), new.expires_date)); 'DROP RULE "_INSERT" ON api.itemsource; apiadminfalse857857857857857857960959958260162316868578578578578578578578578578578578578578578578579635"261888101_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO itemsourceprice DO INSTEAD INSERT INTO public.itemsrcp (itemsrcp_itemsrc_id, itemsrcp_qtybreak, itemsrcp_price, itemsrcp_curr_id, itemsrcp_updated, itemsrcp_dropship, itemsrcp_warehous_id, itemsrcp_type, itemsrcp_discntprcnt, itemsrcp_fixedamtdiscount) VALUES (public.getitemsrcid((new.item_number)::text, (new.vendor)::text), new.qty_break, new.price_per_unit, public.getcurrid((new.currency)::text), now(), COALESCE(new.dropship_only, false), CASE WHEN (new.pricing_site = 'All'::text) THEN (-1) ELSE COALESCE(public.getwarehousid(new.pricing_site, 'ALL'::text), (-1)) END, CASE WHEN (new.pricing_type = 'Discount'::text) THEN 'D'::text ELSE 'N'::text END, (COALESCE(new.discount_percent, 0.0) / 100.0), new.discount_fixed_amount); ,DROP RULE "_INSERT" ON api.itemsourceprice; apiadminfalse8588588581629858159085885885826116888588588588588589635"261888110_INSERTRULEdCREATE RULE "_INSERT" AS ON INSERT TO itemsubstitute DO INSTEAD INSERT INTO public.itemsub (itemsub_parent_item_id, itemsub_sub_item_id, itemsub_uomratio, itemsub_rank) VALUES (public.getitemid((new.root_item_number)::text), public.getitemid((new.substitute_item_number)::text), COALESCE(new.sub_parent_uom_ratio, (1)::numeric), COALESCE(new.ranking, 1)); +DROP RULE "_INSERT" ON api.itemsubstitute; apiadminfalse85985985985926216238598599635"261888117_INSERTRULE_CREATE RULE "_INSERT" AS ON INSERT TO itemtaxtype DO INSTEAD INSERT INTO public.itemtax (itemtax_item_id, itemtax_taxzone_id, itemtax_taxtype_id) VALUES (public.getitemid((new.item_number)::text), CASE WHEN ((new.tax_zone)::text = 'Any'::text) THEN NULL::integer ELSE public.gettaxzoneid((new.tax_zone)::text) END, public.gettaxtypeid(new.tax_type)); (DROP RULE "_INSERT" ON api.itemtaxtype; apiadminfalse8601623860860168016798602638609635"261888124_INSERTRULErCREATE RULE "_INSERT" AS ON INSERT TO itemuomconversion DO INSTEAD SELECT public.saveitemuomconv(public.getitemid((new.item_number)::text), COALESCE(public.getuomid((new.uom)::text), (SELECT item.item_inv_uom_id FROM public.item WHERE (item.item_id = public.getitemid((new.item_number)::text)))), COALESCE(new.uom_value, (1)::numeric), COALESCE(public.getuomid(new.per_uom), (SELECT item.item_inv_uom_id FROM public.item WHERE (item.item_id = public.getitemid((new.item_number)::text)))), COALESCE(new.per_uom_value, (1)::numeric), COALESCE(new.fractional, false), public.getuomtypeid(new.selected_types)) AS saveitemuomconv; .DROP RULE "_INSERT" ON api.itemuomconversion; apiadminfalse86186116838611623861861861168520421748611748618619635"261888132_INSERTRULEXCREATE RULE "_INSERT" AS ON INSERT TO journalentry DO INSTEAD SELECT public.insertgltransaction('G/L'::text, 'JE'::text, new.doc_number, new.notes, public.getglaccntid(new.credit), public.getglaccntid(new.debit), (-1), public.currtobase(public.getcurrid((new.currency)::text), new.amount, new.dist_date), new.dist_date) AS insertgltransaction; )DROP RULE "_INSERT" ON api.journalentry; apiadminfalse86286286213078628621609172415908628628628629635"261888140_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO location DO INSTEAD INSERT INTO public.location (location_warehous_id, location_name, location_descrip, location_restrict, location_netable, location_usable, location_whsezone_id, location_aisle, location_rack, location_bin) VALUES (public.getwarehousid((new.site)::text, 'ACTIVE'::text), COALESCE(new.location, ''::character varying), COALESCE(new.description, ''::text), COALESCE(new.restricted, false), COALESCE(new.netable, true), COALESCE(new.usable, true), public.getwhsezoneid((new.site)::text, new.zone), COALESCE(new.aisle, ''::character varying), COALESCE(new.rack, ''::character varying), COALESCE(new.bin, ''::character varying)); %DROP RULE "_INSERT" ON api.location; apiadminfalse863168916888638638638638632668638638638638638639635"261888147_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO misccounttag DO INSTEAD SELECT public.postmisccount(public.getitemsiteid(COALESCE(new.site, (SELECT whsinfo.warehous_code FROM public.usrpref, public.whsinfo WHERE (((usrpref.usrpref_username = public.geteffectivextuser()) AND (usrpref.usrpref_name = 'PreferredWarehouse'::text)) AND (whsinfo.warehous_id = (usrpref.usrpref_value)::integer)))), new.item_number), new.quantity, new.comment) AS postmisccount; )DROP RULE "_INSERT" ON api.misccounttag; apiadminfalse8648648648648641761761898162515986996998646999635"261888155_INSERTRULEqCREATE RULE "_INSERT" AS ON INSERT TO pricingschedule DO INSTEAD INSERT INTO public.ipshead (ipshead_id, ipshead_name, ipshead_descrip, ipshead_effective, ipshead_expires, ipshead_curr_id, ipshead_updated) VALUES (nextval('public.ipshead_ipshead_id_seq'::regclass), new.name, new.description, CASE WHEN (new.effective = 'Always'::text) THEN '1970-01-01'::date ELSE (COALESCE(new.effective, '1970-01-01'::text))::date END, CASE WHEN (new.expires = 'Never'::text) THEN '2100-01-01'::date ELSE (COALESCE(new.expires, '2100-01-01'::text))::date END, COALESCE(public.getcurrid((new.currency)::text), public.basecurrid()), now()); ,DROP RULE "_INSERT" ON api.pricingschedule; apiadminfalse865513247159010878658658658658658659635"261888164_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO pricingscheduleassign DO INSTEAD INSERT INTO public.ipsass (ipsass_ipshead_id, ipsass_cust_id, ipsass_custtype_id, ipsass_custtype_pattern, ipsass_shipto_id, ipsass_shipto_pattern) VALUES (public.getipsheadid((new.pricing_schedule)::text), CASE WHEN ((new.customer_number)::text = 'Any'::text) THEN (-1) ELSE public.getcustid((new.customer_number)::text) END, CASE WHEN ((new.customer_type)::text = 'N/A'::text) THEN (-1) ELSE public.getcusttypeid((new.customer_type)::text) END, new.customer_type_pattern, CASE WHEN (((new.customer_number)::text = 'Any'::text) OR ((new.customer_shipto)::text = 'Any'::text)) THEN (-1) ELSE public.getshiptoid((new.customer_number)::text, (new.customer_shipto)::text) END, new.customer_shipto_pattern); 2DROP RULE "_INSERT" ON api.pricingscheduleassign; apiadminfalse86686686686686686686626816671620159286615949635"261888173_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO pricingscheduleitem DO INSTEAD SELECT CASE WHEN ((new.type)::text = 'Item'::text) THEN public.saveipsitem(NULL::integer, public.getipsheadid((new.pricing_schedule)::text), public.getitemid((new.item_number)::text), COALESCE(new.qty_break, (0)::numeric), COALESCE(new.price, (0)::numeric), public.getuomid((new.qty_uom)::text), public.getuomid((new.price_uom)::text), new.percent, new.fixedamt, CASE new.pricing_type WHEN 'Nominal'::text THEN 'N'::text WHEN 'Discount'::text THEN 'D'::text WHEN 'Markup'::text THEN 'M'::text ELSE '?'::text END) WHEN ((new.type)::text = 'Product Category'::text) THEN public.saveipsprodcat(NULL::integer, public.getipsheadid((new.pricing_schedule)::text), public.getprodcatid((new.product_category)::text), new.qty_break, new.percent, new.fixedamt, CASE new.pricing_type WHEN 'Nominal'::text THEN 'N'::text WHEN 'Discount'::text THEN 'D'::text WHEN 'Markup'::text THEN 'M'::text ELSE '?'::text END) ELSE NULL::integer END AS "case"; 0DROP RULE "_INSERT" ON api.pricingscheduleitem; apiadminfalse8671648162316208678678672040168320398678678678678678678678678679635"261888183_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO pricingscheduleitemchar DO INSTEAD INSERT INTO public.ipsitemchar (ipsitemchar_ipsitem_id, ipsitemchar_char_id, ipsitemchar_value, ipsitemchar_price) VALUES (public.getipsitemid((new.pricing_schedule)::text, (new.item_number)::text, new.qty_break, (new.qty_uom)::text, (new.price_uom)::text), public.getcharid((new.characteristic)::text, 'I'::text), new.value, COALESCE(new.price, (0)::numeric)); 4DROP RULE "_INSERT" ON api.pricingscheduleitemchar; apiadminfalse868868868868868270162115768688688688688689635"261888190_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO project DO INSTEAD INSERT INTO public.prj (prj_number, prj_name, prj_descrip, prj_owner_username, prj_username, prj_so, prj_wo, prj_po, prj_status, prj_due_date, prj_assigned_date, prj_start_date, prj_completed_date) VALUES (new.number, COALESCE(new.name, ''::text), COALESCE(new.description, ''::text), COALESCE(new.owner, public.geteffectivextuser()), COALESCE(new.assigned_to, public.geteffectivextuser()), COALESCE(new.sales_orders, true), COALESCE(new.work_orders, true), COALESCE(new.purchase_orders, true), CASE WHEN (new.status = 'In-Process'::text) THEN 'O'::text WHEN (new.status = 'Completed'::text) THEN 'C'::text ELSE 'P'::text END, new.due, new.assigned, new.started, new.completed); $DROP RULE "_INSERT" ON api.project; apiadminfalse86986986920686986986986986986915988698698698698698699635"261888198_INSERTRULEyCREATE RULE "_INSERT" AS ON INSERT TO projectcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'J'::text, public.getprjid((new.project_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); +DROP RULE "_INSERT" ON api.projectcomment; apiadminfalse8701598870217870164615808708708708709635"261888206_INSERTRULEICREATE RULE "_INSERT" AS ON INSERT TO prospect DO INSTEAD INSERT INTO public.prospect (prospect_number, prospect_name, prospect_active, prospect_cntct_id, prospect_taxzone_id, prospect_salesrep_id, prospect_warehous_id, prospect_comments) VALUES (upper((new.prospect_number)::text), COALESCE(new.prospect_name, ''::text), COALESCE(new.active, true), public.savecntct(public.getcntctid(new.contact_number), new.contact_number, public.saveaddr(public.getaddrid(new.contact_address_number), new.contact_address_number, new.contact_address1, new.contact_address2, new.contact_address3, new.contact_city, new.contact_state, new.contact_postalcode, new.contact_country, new.contact_address_change), new.contact_honorific, new.contact_first, new.contact_middle, new.contact_last, new.contact_suffix, new.contact_voice, new.contact_alternate, new.contact_fax, new.contact_email, new.contact_web, new.contact_job_title, new.contact_change), public.gettaxzoneid(new.default_tax_zone), public.getsalesrepid(new.sales_rep), public.getwarehousid(new.site_code, 'ACTIVE'::text), COALESCE(new.notes, ''::text)); %DROP RULE "_INSERT" ON api.prospect; apiadminfalse87187115811568871871202987187187187187116601688168027220348718718718718718718718718718718718718718718718718718718718718718719635"261888215_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO purchaseline DO INSTEAD INSERT INTO public.poitem (poitem_pohead_id, poitem_linenumber, poitem_duedate, poitem_itemsite_id, poitem_vend_item_descrip, poitem_qty_ordered, poitem_unitprice, poitem_vend_item_number, poitem_manuf_name, poitem_manuf_item_number, poitem_manuf_item_descrip, poitem_comments, poitem_expcat_id, poitem_freight, poitem_prj_id, poitem_bom_rev_id, poitem_boo_rev_id) VALUES (public.getpoheadid((new.order_number)::text), new.line_number, new.due_date, public.getitemsiteid(COALESCE(new.site, (SELECT whsinfo.warehous_code FROM (public.pohead JOIN public.whsinfo ON ((whsinfo.warehous_id = pohead.pohead_warehous_id))) WHERE (pohead.pohead_id = public.getpoheadid((new.order_number)::text))), (SELECT whsinfo.warehous_code FROM public.whsinfo WHERE (whsinfo.warehous_id = public.fetchprefwarehousid()))), new.item_number), new.vendor_description, new.qty_ordered, new.unit_price, new.vend_item_number, new.manufacturer_name, new.manufacturer_item_number, new.manufacturer_description, new.notes, public.getexpcatid(new.expense_category), new.freight, public.getprjid(new.project_number), public.getrevid('BOM'::text, new.item_number, new.bill_of_materials_revision), public.getrevid('BOO'::text, new.item_number, new.bill_of_operations_revision)); )DROP RULE "_INSERT" ON api.purchaseline; apiadminfalse8728728728728721818721808728728728728728728728728728728721808721761768721653164687216431461162516019635#261888227_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO purchaselinechar DO INSTEAD SELECT DISTINCT public.updatecharassignment('PI'::text, poitem.poitem_id, charass.charass_char_id, new.value) AS updatecharassignment FROM public.pohead, public.poitem, public.itemsite, public.item, public.charass, public."char" WHERE (((((((((pohead.pohead_number = (new.order_number)::text) AND (pohead.pohead_id = poitem.poitem_pohead_id)) AND (poitem.poitem_linenumber = new.line_number)) AND (poitem.poitem_itemsite_id = itemsite.itemsite_id)) AND (item.item_id = itemsite.itemsite_item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND ("char".char_id = charass.charass_char_id)) AND ("char".char_name = new.characteristic)); -DROP RULE "_INSERT" ON api.purchaselinechar; apiadminfalse87318118018087317517521471742142158732141811811818738732152158739635#261888237_INSERTRULEsCREATE RULE "_INSERT" AS ON INSERT TO purchaselinecomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) SELECT COALESCE(new.date, (('now'::text)::date)::timestamp with time zone) AS "coalesce", 'PI', poitem.poitem_id, COALESCE(new.username, public.geteffectivextuser()) AS "coalesce", public.getcmnttypeid(new.type) AS getcmnttypeid, new.text FROM public.poitem, public.pohead WHERE (((pohead.pohead_number = (new.order_number)::text) AND (poitem.poitem_pohead_id = pohead.pohead_id)) AND (poitem.poitem_linenumber = new.line_number)); 0DROP RULE "_INSERT" ON api.purchaselinecomment; apiadminfalse874874874180217158015981811801811818748748748748749635 #261888246_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO purchaseorder DO INSTEAD INSERT INTO public.pohead (pohead_number, pohead_orderdate, pohead_status, pohead_terms_id, pohead_taxzone_id, pohead_warehous_id, pohead_agent_username, pohead_vend_id, pohead_vendaddr_id, pohead_fob, pohead_shipvia, pohead_curr_id, pohead_freight, pohead_comments, pohead_dropship, pohead_vend_cntct_id, pohead_vend_cntct_honorific, pohead_vend_cntct_first_name, pohead_vend_cntct_middle, pohead_vend_cntct_last_name, pohead_vend_cntct_suffix, pohead_vend_cntct_phone, pohead_vend_cntct_title, pohead_vend_cntct_fax, pohead_vend_cntct_email, pohead_vendaddress1, pohead_vendaddress2, pohead_vendaddress3, pohead_vendcity, pohead_vendstate, pohead_vendzipcode, pohead_vendcountry, pohead_shipto_cntct_id, pohead_shipto_cntct_honorific, pohead_shipto_cntct_first_name, pohead_shipto_cntct_middle, pohead_shipto_cntct_last_name, pohead_shipto_cntct_suffix, pohead_shipto_cntct_phone, pohead_shipto_cntct_title, pohead_shipto_cntct_fax, pohead_shipto_cntct_email, pohead_shiptoaddress_id, pohead_shiptoaddress1, pohead_shiptoaddress2, pohead_shiptoaddress3, pohead_shiptocity, pohead_shiptostate, pohead_shiptozipcode, pohead_shiptocountry, pohead_cohead_id) SELECT new.order_number, COALESCE(new.order_date, ('now'::text)::date) AS "coalesce", 'U', COALESCE(public.gettermsid(new.terms), vendinfo.vend_terms_id) AS "coalesce", COALESCE(public.gettaxzoneid(new.tax_zone), vendinfo.vend_taxzone_id) AS "coalesce", COALESCE(public.getwarehousid(new.receiving_site, 'ALL'::text), public.fetchprefwarehousid()) AS "coalesce", COALESCE(new.purchasing_agent, public.geteffectivextuser()) AS "coalesce", public.getvendid(new.vendor_number) AS getvendid, CASE WHEN (new.alt_address = 'MAIN'::text) THEN NULL::integer ELSE public.getvendaddrid(new.vendor_number, new.alt_address) END AS getvendaddrid, COALESCE(new.fob, CASE WHEN (vendinfo.vend_fobsource = 'W'::bpchar) THEN (SELECT whsinfo.warehous_fob FROM public.whsinfo WHERE (whsinfo.warehous_id = COALESCE(public.getwarehousid(new.receiving_site, 'ALL'::text), public.fetchprefwarehousid()))) ELSE vendinfo.vend_fob END) AS "coalesce", COALESCE(new.ship_via, vendinfo.vend_shipvia) AS "coalesce", COALESCE(public.getcurrid((new.currency)::text), vendinfo.vend_curr_id) AS "coalesce", COALESCE(new.freight, (0)::numeric) AS "coalesce", new.notes, COALESCE(new.dropship, false) AS "coalesce", public.getcntctid(new.vend_contact_number) AS getcntctid, COALESCE(new.vend_cntct_honorific, ''::text) AS "coalesce", COALESCE(new.vend_cntct_first_name, ''::text) AS "coalesce", COALESCE(new.vend_cntct_middle, ''::text) AS "coalesce", COALESCE(new.vend_cntct_last_name, ''::text) AS "coalesce", COALESCE(new.vend_cntct_suffix, ''::text) AS "coalesce", COALESCE(new.vend_cntct_phone, ''::text) AS "coalesce", COALESCE(new.vend_cntct_title, ''::text) AS "coalesce", COALESCE(new.vend_cntct_fax, ''::text) AS "coalesce", COALESCE(new.vend_cntct_email, ''::text) AS "coalesce", COALESCE(new.vendaddress1, ''::text) AS "coalesce", COALESCE(new.vendaddress2, ''::text) AS "coalesce", COALESCE(new.vendaddress3, ''::text) AS "coalesce", COALESCE(new.vendcity, ''::text) AS "coalesce", COALESCE(new.vendstate, ''::text) AS "coalesce", COALESCE(new.vendzipcode, ''::text) AS "coalesce", COALESCE(new.vendcountry, ''::text) AS "coalesce", public.getcntctid(new.shipto_contact_number) AS getcntctid, COALESCE(new.shipto_cntct_honorific, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_first_name, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_middle, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_last_name, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_suffix, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_phone, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_title, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_fax, ''::text) AS "coalesce", COALESCE(new.shipto_cntct_email, ''::text) AS "coalesce", public.getaddrid(new.shiptoaddress_number) AS getaddrid, COALESCE(new.shiptoaddress1, ''::text) AS "coalesce", COALESCE(new.shiptoaddress2, ''::text) AS "coalesce", COALESCE(new.shiptoaddress3, ''::text) AS "coalesce", COALESCE(new.shiptocity, ''::text) AS "coalesce", COALESCE(new.shiptostate, ''::text) AS "coalesce", COALESCE(new.shiptozipcode, ''::text) AS "coalesce", COALESCE(new.shiptocountry, ''::text) AS "coalesce", public.getcoheadid(new.sales_order_number) AS getcoheadid FROM public.vendinfo WHERE (vendinfo.vend_id = public.getvendid(new.vendor_number)); *DROP RULE "_INSERT" ON api.purchaseorder; apiadminfalse875875158315988751581146117615688751680168815901681168616751808751931761931931938751931931938758758758758758758758758758758758758758758758758758758758758758758758758758758758758758758758758758758758758758758758758758758758758758759635#261888255_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO purchaseordercomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, (('now'::text)::date)::timestamp with time zone), 'P'::text, public.getpoheadid((new.order_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); 1DROP RULE "_INSERT" ON api.purchaseordercomment; apiadminfalse8768768768768762171643876159887615809635#261888263_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO quote DO INSTEAD INSERT INTO public.quhead (quhead_number, quhead_cust_id, quhead_custponumber, quhead_quotedate, quhead_warehous_id, quhead_shipto_id, quhead_shiptoname, quhead_shiptoaddress1, quhead_shiptoaddress2, quhead_shiptoaddress3, quhead_salesrep_id, quhead_terms_id, quhead_fob, quhead_shipvia, quhead_shiptocity, quhead_shiptostate, quhead_shiptozipcode, quhead_freight, quhead_misc, quhead_ordercomments, quhead_shipcomments, quhead_shiptophone, quhead_billtoname, quhead_billtoaddress1, quhead_billtoaddress2, quhead_billtoaddress3, quhead_billtocity, quhead_billtostate, quhead_billtozip, quhead_misc_accnt_id, quhead_misc_descrip, quhead_commission, quhead_packdate, quhead_prj_id, quhead_billtocountry, quhead_shiptocountry, quhead_curr_id, quhead_taxzone_id, quhead_taxtype_id, quhead_imported, quhead_expire, quhead_status, quhead_saletype_id, quhead_shipzone_id) VALUES (new.quote_number, public.getcustid(new.customer_number, true), new.cust_po_number, new.quote_date, public.getwarehousid(new.site, 'SHIPPING'::text), public.getshiptoid(new.customer_number, new.shipto_number), new.shipto_name, new.shipto_address1, new.shipto_address2, new.shipto_address3, public.getsalesrepid(new.sales_rep), public.gettermsid(new.terms), new.fob, new.ship_via, new.shipto_city, new.shipto_state, new.shipto_postal_code, new.freight, new.misc_charge, new.order_notes, new.shipping_notes, new.shipto_phone, new.billto_name, new.billto_address1, new.billto_address2, new.billto_address3, new.billto_city, new.billto_state, new.billto_postal_code, public.getglaccntid(new.misc_account_number), new.misc_charge_description, new.commission, new.pack_date, public.getprjid(new.project_number), new.billto_country, new.shipto_country, public.getcurrid((new.currency)::text), public.gettaxzoneid(new.tax_zone), public.gettaxtypeid(new.tax_type), true, new.expire_date, CASE WHEN (new.status = 'Converted'::text) THEN 'C'::text ELSE 'O'::text END, public.getsaletypeid(new.sale_type), public.getshipzoneid(new.shipto_shipzone)); "DROP RULE "_INSERT" ON api.quote; apiadminfalse8778771593168827715908778771681166116601646160916801667877877167987716708778778778778778778778778778778778778778778778778778778778778778778778778778778778778778778778778778778778778778779635#261888272_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO quotecomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, (('now'::text)::date)::timestamp with time zone), 'Q'::text, public.getquoteid(new.quote_number), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); )DROP RULE "_INSERT" ON api.quotecomment; apiadminfalse8788781598165015802178788788788788789635#261888280_INSERTRULE CREATE RULE "_INSERT" AS ON INSERT TO quoteline DO INSTEAD INSERT INTO public.quitem (quitem_quhead_id, quitem_linenumber, quitem_itemsite_id, quitem_scheddate, quitem_qtyord, quitem_unitcost, quitem_price, quitem_custprice, quitem_memo, quitem_imported, quitem_custpn, quitem_createorder, quitem_order_warehous_id, quitem_item_id, quitem_prcost, quitem_taxtype_id, quitem_qty_uom_id, quitem_qty_invuomratio, quitem_price_uom_id, quitem_price_invuomratio) SELECT public.getquoteid(new.quote_number) AS getquoteid, COALESCE(new.line_number, (SELECT (COALESCE(max(quitem.quitem_linenumber), 0) + 1) FROM public.quitem WHERE (quitem.quitem_quhead_id = public.getquoteid(new.quote_number)))) AS "coalesce", itemsite.itemsite_id, COALESCE(new.scheduled_date, (SELECT min(quitem.quitem_scheddate) AS min FROM public.quitem WHERE (quitem.quitem_quhead_id = public.getquoteid(new.quote_number)))) AS "coalesce", new.qty_ordered, public.stdcost(item.item_id) AS stdcost, COALESCE(new.net_unit_price, public.itemprice(public.getitemid(new.item_number), quhead.quhead_cust_id, quhead.quhead_shipto_id, new.qty_ordered, quhead.quhead_curr_id, quhead.quhead_quotedate)) AS "coalesce", public.itemprice(public.getitemid(new.item_number), quhead.quhead_cust_id, quhead.quhead_shipto_id, new.qty_ordered, quhead.quhead_curr_id, quhead.quhead_quotedate) AS itemprice, COALESCE(new.notes, ''::text) AS "coalesce", true AS bool, new.customer_pn, COALESCE(new.create_order, false) AS "coalesce", COALESCE(public.getwarehousid(new.supplying_site, 'SHIPPING'::text), itemsite.itemsite_warehous_id) AS "coalesce", public.getitemid(new.item_number) AS getitemid, COALESCE(new.overwrite_po_price, (0)::numeric) AS "coalesce", COALESCE(public.gettaxtypeid(new.tax_type), public.getitemtaxtype(itemsite.itemsite_item_id, quhead.quhead_taxzone_id)) AS "coalesce", COALESCE(public.getuomid(new.qty_uom), item.item_inv_uom_id) AS "coalesce", public.itemuomtouomratio(item.item_id, COALESCE(public.getuomid(new.qty_uom), item.item_inv_uom_id), item.item_inv_uom_id) AS itemuomtouomratio, COALESCE(public.getuomid(new.price_uom), item.item_price_uom_id) AS "coalesce", public.itemuomtouomratio(item.item_id, COALESCE(public.getuomid(new.price_uom), item.item_price_uom_id), item.item_price_uom_id) AS itemuomtouomratio FROM public.quhead, public.itemsite, public.item, public.whsinfo WHERE ((quhead.quhead_number = new.quote_number) AND (((((((itemsite.itemsite_warehous_id = whsinfo.warehous_id) AND (itemsite.itemsite_item_id = item.item_id)) AND itemsite.itemsite_active) AND (item.item_number = new.item_number)) AND whsinfo.warehous_active) AND whsinfo.warehous_shipping) AND (whsinfo.warehous_code = COALESCE(new.sold_from_site, (SELECT whsinfo.warehous_code FROM public.usrpref, public.whsinfo WHERE (((usrpref.usrpref_username = public.geteffectivextuser()) AND (usrpref.usrpref_name = 'PreferredWarehouse'::text)) AND (whsinfo.warehous_id = (usrpref.usrpref_value)::integer))))))); &DROP RULE "_INSERT" ON api.quoteline; apiadminfalse87916831679165016231630879159869927817417801688879210417941741741741752781761751751761761752772782771762772772772778798798796998798796998798798798798798798798798799635#261888290_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO quotelinechar DO INSTEAD SELECT DISTINCT public.updatecharassignment('QI'::text, quitem.quitem_id, charass.charass_char_id, new.value) AS updatecharassignment FROM public.quhead, public.quitem, public.itemsite, public.item, public.charass, public."char" WHERE (((((((((quhead.quhead_number = new.quote_number) AND (quhead.quhead_id = quitem.quitem_quhead_id)) AND (quitem.quitem_linenumber = new.line_number)) AND (quitem.quitem_itemsite_id = itemsite.itemsite_id)) AND (item.item_id = itemsite.itemsite_item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND ("char".char_id = charass.charass_char_id)) AND ("char".char_name = new.characteristic)); *DROP RULE "_INSERT" ON api.quotelinechar; apiadminfalse88027888027827888088088027727721472782152141758801751742142152159635"#261888300_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO quotelinecomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, (('now'::text)::date)::timestamp with time zone), 'QI'::text, public.getquotelineitemid(new.quote_number, new.line_number), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); -DROP RULE "_INSERT" ON api.quotelinecomment; apiadminfalse8818818812171652159888115808818818818819635&#261888308_INSERTRULExCREATE RULE "_INSERT" AS ON INSERT TO salescredit DO INSTEAD INSERT INTO public.aropenalloc (aropenalloc_aropen_id, aropenalloc_doctype, aropenalloc_doc_id, aropenalloc_amount, aropenalloc_curr_id) VALUES (public.getaropenid(new.customer_number, 'C'::bpchar, new.cm_number), 'S'::bpchar, public.getcoheadid(new.so_number), new.amount, public.getcurrid((new.currency)::text)); (DROP RULE "_INSERT" ON api.salescredit; apiadminfalse8828828828821590158315708828822798829635(#261888314_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO saleshistory DO INSTEAD INSERT INTO public.cohist (cohist_cust_id, cohist_itemsite_id, cohist_shipdate, cohist_shipvia, cohist_ordernumber, cohist_orderdate, cohist_invcnumber, cohist_invcdate, cohist_qtyshipped, cohist_unitprice, cohist_shipto_id, cohist_salesrep_id, cohist_duedate, cohist_imported, cohist_billtoname, cohist_billtoaddress1, cohist_billtoaddress2, cohist_billtoaddress3, cohist_billtocity, cohist_billtostate, cohist_billtozip, cohist_shiptoname, cohist_shiptoaddress1, cohist_shiptoaddress2, cohist_shiptoaddress3, cohist_shiptocity, cohist_shiptostate, cohist_shiptozip, cohist_commission, cohist_commissionpaid, cohist_unitcost, cohist_misc_type, cohist_misc_descrip, cohist_misc_id, cohist_doctype, cohist_promisedate, cohist_ponumber, cohist_curr_id, cohist_sequence, cohist_taxzone_id, cohist_taxtype_id) VALUES (public.getcustid(new.customer_number), public.getitemsiteid(new.site_code, new.item_number), new.ship_date, new.ship_via, new.order_number, new.order_date, new.invoice_number, new.invoice_date, new.quantity_shipped, COALESCE(new.unit_price, (0)::numeric), public.getshiptoid(new.customer_number, new.shipto_number), public.getsalesrepid(new.sales_rep), new.due_date, true, new.billto_name, new.billto_address1, new.billto_address2, new.billto_address3, new.billto_city, new.billto_state, new.billto_zip, new.shipto_name, new.shipto_address1, new.shipto_address2, new.shipto_address3, new.shipto_city, new.shipto_state, new.shipto_zip, COALESCE(new.commission, (0)::numeric), COALESCE(new.commission_paid, false), COALESCE(new.unit_cost, (0)::numeric), CASE WHEN (new.misc_type = 'Misc. Charge'::text) THEN 'M'::text WHEN (new.misc_type = 'Freight'::text) THEN 'F'::text ELSE NULL::text END, new.misc_description, CASE WHEN (new.misc_type = 'Misc. Charge'::text) THEN public.getglaccntid(new.misc_info) ELSE NULL::integer END, CASE WHEN (new.document_type = 'Invoice'::text) THEN 'I'::text WHEN (new.document_type = 'Credit Memo'::text) THEN 'C'::text ELSE NULL::text END, new.promise_date, new.purchase_order_number, COALESCE(public.getcurrid((new.currency)::text), public.basecurrid()), new.gl_sequence, public.gettaxzoneid(new.tax_zone), public.gettaxtypeid(new.tax_type)); )DROP RULE "_INSERT" ON api.saleshistory; apiadminfalse8838838838838838838838838838838838831087168088316791667166016251609159215908838838838838832808838838838838838838838838838838838838838838838838838838838838838838838838839635,#261888325_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO saleslinechar DO INSTEAD SELECT DISTINCT public.updatecharassignment('SI'::text, coitem.coitem_id, charass.charass_char_id, new.value, public.itemcharprice(item.item_id, "char".char_id, new.value, cohead.cohead_cust_id, cohead.cohead_shipto_id, coitem.coitem_qtyord, cohead.cohead_curr_id, cohead.cohead_orderdate)) AS updatecharassignment FROM public.cohead, public.coitem, public.itemsite, public.item, public.charass, public."char" WHERE (((((((((cohead.cohead_number = (new.order_number)::text) AND (cohead.cohead_id = coitem.coitem_cohead_id)) AND (coitem.coitem_id = public.getcoitemid((new.order_number)::text, new.line_number))) AND (coitem.coitem_itemsite_id = itemsite.itemsite_id)) AND (item.item_id = itemsite.itemsite_item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND ("char".char_id = charass.charass_char_id)) AND ("char".char_name = new.characteristic)); *DROP RULE "_INSERT" ON api.saleslinechar; apiadminfalse88421517817682151781584884174214214178214817817517917517917917817817988488488488421596350#261888335_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO saleslinecomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, (('now'::text)::date)::timestamp with time zone), 'SI'::text, public.getcoitemid((new.order_number)::text, new.line_number), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); -DROP RULE "_INSERT" ON api.saleslinecomment; apiadminfalse88588588588588588588588515841598217158096354#261888343_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO salesorder DO INSTEAD INSERT INTO public.cohead (cohead_number, cohead_cust_id, cohead_custponumber, cohead_orderdate, cohead_warehous_id, cohead_shipto_id, cohead_shiptoname, cohead_shiptoaddress1, cohead_shiptoaddress2, cohead_shiptoaddress3, cohead_salesrep_id, cohead_terms_id, cohead_fob, cohead_shipvia, cohead_shiptocity, cohead_shiptostate, cohead_shiptozipcode, cohead_freight, cohead_calcfreight, cohead_misc, cohead_imported, cohead_ordercomments, cohead_shipcomments, cohead_shiptophone, cohead_shipchrg_id, cohead_shipform_id, cohead_billtoname, cohead_billtoaddress1, cohead_billtoaddress2, cohead_billtoaddress3, cohead_billtocity, cohead_billtostate, cohead_billtozipcode, cohead_misc_accnt_id, cohead_misc_descrip, cohead_commission, cohead_holdtype, cohead_packdate, cohead_prj_id, cohead_shipcomplete, cohead_billtocountry, cohead_shiptocountry, cohead_curr_id, cohead_taxzone_id, cohead_shipto_cntct_id, cohead_shipto_cntct_honorific, cohead_shipto_cntct_first_name, cohead_shipto_cntct_middle, cohead_shipto_cntct_last_name, cohead_shipto_cntct_suffix, cohead_shipto_cntct_phone, cohead_shipto_cntct_title, cohead_shipto_cntct_fax, cohead_shipto_cntct_email, cohead_billto_cntct_id, cohead_billto_cntct_honorific, cohead_billto_cntct_first_name, cohead_billto_cntct_middle, cohead_billto_cntct_last_name, cohead_billto_cntct_suffix, cohead_billto_cntct_phone, cohead_billto_cntct_title, cohead_billto_cntct_fax, cohead_billto_cntct_email, cohead_saletype_id, cohead_shipzone_id) SELECT new.order_number, public.getcustid(new.customer_number) AS getcustid, new.cust_po_number, new.order_date, public.getwarehousid(new.site, 'SHIPPING'::text) AS getwarehousid, public.getshiptoid(new.customer_number, new.shipto_number) AS getshiptoid, new.shipto_name, new.shipto_address1, new.shipto_address2, new.shipto_address3, public.getsalesrepid(new.sales_rep) AS getsalesrepid, public.gettermsid(new.terms) AS gettermsid, new.fob, new.ship_via, new.shipto_city, new.shipto_state, new.shipto_postal_code, CASE WHEN COALESCE(new.calculate_freight, public.fetchmetricbool('CalculateFreight'::text)) THEN (0)::numeric ELSE new.freight END AS freight, COALESCE(new.calculate_freight, public.fetchmetricbool('CalculateFreight'::text)) AS "coalesce", new.misc_charge, true AS bool, new.order_notes, new.shipping_notes, new.shipto_phone, public.getshipchrgid(new.shipping_chgs) AS getshipchrgid, public.getshipformid(new.shipping_form) AS getshipformid, new.billto_name, new.billto_address1, new.billto_address2, new.billto_address3, new.billto_city, new.billto_state, new.billto_postal_code, public.getglaccntid(new.misc_account_number) AS getglaccntid, new.misc_charge_description, new.commission, CASE WHEN (new.hold_type = 'Credit'::text) THEN 'C'::text WHEN (new.hold_type = 'Shipping'::text) THEN 'S'::text WHEN (new.hold_type = 'Packing'::text) THEN 'P'::text ELSE 'N'::text END AS "case", new.pack_date, public.getprjid(new.project_number) AS getprjid, new.ship_complete, new.billto_country, new.shipto_country, public.getcurrid((new.currency)::text) AS getcurrid, CASE WHEN (new.tax_zone = 'None'::text) THEN (-1) ELSE public.gettaxzoneid(new.tax_zone) END AS gettaxzoneid, public.getcntctid(new.shipto_contact_number) AS getcntctid, new.shipto_contact_honorific, new.shipto_contact_first, new.shipto_contact_middle, new.shipto_contact_last, new.shipto_contact_suffix, new.shipto_contact_phone, new.shipto_contact_title, new.shipto_contact_fax, new.shipto_contact_email, public.getcntctid(new.billto_contact_number) AS getcntctid, new.billto_contact_name, new.billto_contact_first, new.billto_contact_middle, new.billto_contact_last, new.billto_contact_suffix, new.billto_contact_phone, new.billto_contact_title, new.billto_contct_fax, new.billto_contact_email, public.getsaletypeid(new.sale_type) AS getsaletypeid, public.getshipzoneid(new.shipto_shipzone) AS getshipzoneid FROM public.custinfo WHERE (custinfo.cust_number = new.customer_number); 'DROP RULE "_INSERT" ON api.salesorder; apiadminfalse88616611592159088688688688688688616091581166016461681886886168016701667166416631688886886886178196886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886145588688688688688688688688688688688688688688688688688696358#261888354_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO salesordercomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, (('now'::text)::date)::timestamp with time zone), 'S'::text, public.getsalesorderid((new.order_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); .DROP RULE "_INSERT" ON api.salesordercomment; apiadminfalse8878872178878871659158088788715988879635<#261888362_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO salesrep DO INSTEAD INSERT INTO public.salesrep (salesrep_active, salesrep_number, salesrep_name, salesrep_commission, salesrep_method, salesrep_emp_id) VALUES (COALESCE(new.active, true), COALESCE(new.number, ''::character varying), COALESCE(new.name, ''::text), COALESCE((new.commission_percent * 0.01), (0)::numeric), ''::bpchar, public.getempid(new.employee)); %DROP RULE "_INSERT" ON api.salesrep; apiadminfalse88888816008888881998888888889635@#261888370_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO site DO INSTEAD INSERT INTO public.whsinfo (warehous_code, warehous_descrip, warehous_fob, warehous_active, warehous_counttag_prefix, warehous_counttag_number, warehous_bol_prefix, warehous_bol_number, warehous_shipping, warehous_useslips, warehous_usezones, warehous_aislesize, warehous_aislealpha, warehous_racksize, warehous_rackalpha, warehous_binsize, warehous_binalpha, warehous_locationsize, warehous_locationalpha, warehous_enforcearbl, warehous_default_accnt_id, warehous_shipping_commission, warehous_cntct_id, warehous_addr_id, warehous_taxzone_id, warehous_transit, warehous_shipform_id, warehous_shipvia_id, warehous_shipcomments, warehous_costcat_id, warehous_sitetype_id, warehous_sequence) VALUES (COALESCE(new.code, ''::character varying), COALESCE(new.description, ''::text), CASE WHEN new.inventory_type THEN COALESCE(new.default_fob, ''::text) ELSE ''::text END, COALESCE(new.active, true), CASE WHEN new.inventory_type THEN COALESCE(new.next_count_tag_prefix, ''::text) ELSE ''::text END, CASE WHEN new.inventory_type THEN COALESCE(new.next_count_tag_number, 0) ELSE 0 END, CASE WHEN new.inventory_type THEN COALESCE(new.next_bill_of_lading_prefix, ''::text) ELSE ''::text END, CASE WHEN new.inventory_type THEN COALESCE(new.next_bill_of_lading_number, 0) ELSE 0 END, CASE WHEN new.inventory_type THEN COALESCE(new.shipping_site, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.force_the_use_of_count_slips, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.force_the_use_of_zones, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.aisle_size, 0) ELSE 0 END, CASE WHEN new.inventory_type THEN COALESCE(new.aisle_allow_alpha_characters, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.rack_size, 0) ELSE 0 END, CASE WHEN new.inventory_type THEN COALESCE(new.rack_allow_alpha_characters, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.bin_size, 0) ELSE 0 END, CASE WHEN new.inventory_type THEN COALESCE(new.bin_allow_alpha_characters, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.location_size, 0) ELSE 0 END, CASE WHEN new.inventory_type THEN COALESCE(new.location_allow_alpha_characters, false) ELSE false END, CASE WHEN new.inventory_type THEN COALESCE(new.enforce_arbl_naming_convention, false) ELSE false END, COALESCE(public.getglaccntid(new.post_unassigned_transactions_to), (-1)), CASE WHEN new.inventory_type THEN COALESCE((new.shipping_commission * 0.01), (0)::numeric) ELSE (0)::numeric END, public.savecntct(public.getcntctid(new.contact_number), new.contact_number, NULL::integer, new.honorific, new.first, new.middle, new.last, new.suffix, new.phone, NULL::text, new.fax, new.email, NULL::text, new.job_title, new.contact_change), public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.address_change), CASE WHEN new.inventory_type THEN COALESCE(public.gettaxzoneid(new.tax_zone), (-1)) ELSE NULL::integer END, CASE WHEN new.inventory_type THEN false WHEN new.transit_type THEN true ELSE false END, CASE WHEN new.transit_type THEN COALESCE((public.getshipformid(new.default_shipping_form))::numeric, public.fetchmetricvalue('DefaultShipFormId'::text)) ELSE NULL::numeric END, CASE WHEN new.transit_type THEN COALESCE((public.getshipviaid(new.default_ship_via))::numeric, public.fetchmetricvalue('DefaultShipViaId'::text)) ELSE NULL::numeric END, CASE WHEN new.transit_type THEN COALESCE(new.shipping_comments, ''::text) ELSE ''::text END, CASE WHEN new.transit_type THEN COALESCE(public.getcostcatid(new.default_cost_category), (-1)) ELSE NULL::integer END, COALESCE(public.getsitetypeid(new.type), (-1)), COALESCE(new.scheduling_sequence, 0)); !DROP RULE "_INSERT" ON api.site; apiadminfalse889889889889176202916698891664889889160915681457158615818898891671889889889889168088988920348898898898898898898898898898898898898898898898898898898898898898898898898898898898898898898898898898898898898898899635D#261888380_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO sitezone DO INSTEAD INSERT INTO public.whsezone (whsezone_warehous_id, whsezone_name, whsezone_descrip) VALUES (public.getwarehousid((new.site)::text, 'ACTIVE'::text), COALESCE(new.name, ''::character varying), COALESCE(new.description, ''::text)); %DROP RULE "_INSERT" ON api.sitezone; apiadminfalse89089089026716888908909635H#261888388_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO task DO INSTEAD INSERT INTO public.prjtask (prjtask_prj_id, prjtask_number, prjtask_name, prjtask_descrip, prjtask_owner_username, prjtask_username, prjtask_hours_budget, prjtask_hours_actual, prjtask_exp_budget, prjtask_exp_actual, prjtask_status, prjtask_due_date, prjtask_assigned_date, prjtask_start_date, prjtask_completed_date) VALUES (public.getprjid(new.project_number), new.number, COALESCE(new.name, ''::text), COALESCE(new.description, ''::text), COALESCE(new.owner, public.geteffectivextuser()), COALESCE(new.assigned_to, public.geteffectivextuser()), COALESCE(new.hours_budgeted, (0)::numeric), COALESCE(new.hours_actual, (0)::numeric), COALESCE(new.expenses_budgeted, (0)::numeric), COALESCE(new.expenses_actual, (0)::numeric), CASE WHEN (new.status = 'In-Process'::text) THEN 'O'::text WHEN (new.status = 'Completed'::text) THEN 'C'::text ELSE 'P'::text END, new.due, new.assigned, new.started, new.completed); !DROP RULE "_INSERT" ON api.task; apiadminfalse891891891891891891891159889121116468918918918918918918918918919635L#261888397_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO taskcomment DO INSTEAD INSERT INTO public.comment (comment_date, comment_source, comment_source_id, comment_user, comment_cmnttype_id, comment_text) VALUES (COALESCE(new.date, now()), 'TA'::text, public.getprjtaskid((new.project_number)::text, (new.task_number)::text), COALESCE(new.username, public.geteffectivextuser()), public.getcmnttypeid(new.type), new.text); (DROP RULE "_INSERT" ON api.taskcomment; apiadminfalse8921598892217164715808928928928928928929635P#261888405_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO todo DO INSTEAD SELECT public.createtodoitem(NULL::integer, new.assigned_to, COALESCE(new.task_name, ''::text), COALESCE(new.description, ''::text), public.getincidentid(new.incident), COALESCE(public.getincdtcrmacctid(new.incident), public.getcrmacctid(new.account)), public.getopheadid(new.opportunity), CASE WHEN (new.date_started > ''::text) THEN (new.date_started)::date ELSE NULL::date END, CASE WHEN (new.date_due > ''::text) THEN (new.date_due)::date ELSE NULL::date END, (CASE WHEN (new.status = 'Pending Input'::text) THEN 'P'::text WHEN (new.status = 'Deferred'::text) THEN 'D'::text ELSE 'N'::text END)::bpchar, CASE WHEN (new.date_assigned > ''::text) THEN (new.date_assigned)::date ELSE NULL::date END, CASE WHEN (new.date_completed > ''::text) THEN (new.date_completed)::date ELSE NULL::date END, public.getincdtpriorityid(new.priority), COALESCE(new.notes, ''::text), new.owner) AS createtodoitem; !DROP RULE "_INSERT" ON api.todo; apiadminfalse8938938938931614893161716341613158912838938938938938938938938938938938939635T#261888415_INSERTRULEh CREATE RULE "_INSERT" AS ON INSERT TO vendor DO INSTEAD INSERT INTO public.vendinfo (vend_name, vend_lastpurchdate, vend_active, vend_po, vend_comments, vend_pocomments, vend_number, vend_1099, vend_exported, vend_fobsource, vend_fob, vend_terms_id, vend_shipvia, vend_vendtype_id, vend_qualified, vend_ediemail, vend_ediemailbody, vend_edisubject, vend_edifilename, vend_accntnum, vend_emailpodelivery, vend_restrictpurch, vend_edicc, vend_curr_id, vend_cntct1_id, vend_cntct2_id, vend_addr_id, vend_match, vend_taxzone_id, vend_ach_routingnumber, vend_ach_accntnumber, vend_accnt_id, vend_expcat_id, vend_tax_id) VALUES (COALESCE(new.vendor_name, ''::text), NULL::date, COALESCE(new.active, true), COALESCE(new.sells_purchase_order_items, false), COALESCE(new.notes, ''::text), COALESCE(new.po_comments, ''::text), COALESCE(new.vendor_number, ''::character varying), COALESCE(new.receives_1099, false), false, CASE WHEN (new.default_fob = 'Receiving Site'::text) THEN 'W'::text ELSE 'V'::text END, CASE WHEN (new.default_fob = 'Receiving Site'::text) THEN ''::text ELSE new.default_fob END, COALESCE((public.gettermsid(new.default_terms))::numeric, public.fetchmetricvalue('DefaultTerms'::text)), COALESCE(new.ship_via, public.fetchdefaultshipvia()), public.getvendtypeid(new.vendor_type), COALESCE(new.qualified, false), COALESCE(new.po_edi_email, ''::text), COALESCE(new.po_edi_emailbody, ''::text), COALESCE(new.po_edi_subject, ''::text), COALESCE(new.po_edi_filename, ''::text), COALESCE(new.account_number, ''::text), COALESCE(new.allow_email_po_delivery, false), COALESCE(new.may_only_sell_item_source, false), COALESCE(new.po_edi_cc, ''::text), COALESCE(public.getcurrid((new.default_currency)::text), public.basecurrid()), public.savecntct(public.getcntctid(new.contact1_number), new.contact1_number, NULL::integer, new.contact1_honorific, new.contact1_first, new.contact1_middle, new.contact1_last, new.contact1_suffix, new.contact1_voice, new.contact1_alternate, new.contact1_fax, new.contact1_email, new.contact1_web, new.contact1_job_title, new.contact1_change), public.savecntct(public.getcntctid(new.contact2_number), new.contact2_number, NULL::integer, new.contact2_honorific, new.contact2_first, new.contact2_middle, new.contact2_last, new.contact2_suffix, new.contact2_voice, new.contact2_alternate, new.contact2_fax, new.contact2_email, new.contact2_web, new.contact2_job_title, new.contact2_change), public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change), COALESCE(new.matching_vo_po_amounts, false), public.gettaxzoneid(new.default_tax_zone), '\x'::bytea, '\x'::bytea, COALESCE(public.getglaccntid(new.default_dist_gl_account), (-1)), COALESCE(public.getexpcatid(new.default_dist_expense_category), (-1)), COALESCE(public.gettaxid(new.default_dist_tax_code), (-1))); #DROP RULE "_INSERT" ON api.vendor; apiadminfalse894894894894894894894894894894894894894894156810871457144989420291687158116811680160115901678160919320348948948948948948948948948948948948948948948948948948948948948948948948948948948948948948948948948948948948948948948948948948948948948948948948949635X#261888425_INSERTRULE7CREATE RULE "_INSERT" AS ON INSERT TO vendoraddress DO INSTEAD INSERT INTO public.vendaddrinfo (vendaddr_vend_id, vendaddr_code, vendaddr_name, vendaddr_comments, vendaddr_cntct_id, vendaddr_addr_id) VALUES (public.getvendid((new.vendor_number)::text), COALESCE(new.vendor_address_number, ''::character varying), COALESCE(new.vendor_address_name, ''::text), COALESCE(new.notes, ''::text), public.savecntct(public.getcntctid(new.contact_number), new.contact_number, public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change), new.contact_honorific, new.contact_first, new.contact_middle, new.contact_last, new.contact_suffix, new.contact_voice, new.contact_alternate, new.contact_fax, new.contact_email, new.contact_web, new.contact_job_title, new.contact_change), public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change)); *DROP RULE "_INSERT" ON api.vendoraddress; apiadminfalse895895895895158189515688951686202927620348958958958958958958958958958958958958958958958958958958958958958959635\#261888434_INSERTRULECREATE RULE "_INSERT" AS ON INSERT TO vendortype DO INSTEAD INSERT INTO public.vendtype (vendtype_code, vendtype_descrip) VALUES (new.code, COALESCE(new.description, ''::text)); 'DROP RULE "_INSERT" ON api.vendortype; apiadminfalse8962858968968969635"261888217 _INSERT_CHARRULECREATE RULE "_INSERT_CHAR" AS ON INSERT TO purchaseline DO INSTEAD INSERT INTO public.charass (charass_target_type, charass_target_id, charass_char_id, charass_value) SELECT 'PI', poitem.poitem_id, "char".char_id, charass.charass_value FROM public.pohead, public.poitem, public.charass, public."char", public.itemsite, public.item WHERE (((((((((pohead.pohead_number = (new.order_number)::text) AND (poitem.poitem_pohead_id = pohead.pohead_id)) AND (poitem.poitem_linenumber = new.line_number)) AND (itemsite.itemsite_id = poitem.poitem_itemsite_id)) AND (itemsite.itemsite_item_id = item.item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND charass.charass_default) AND ("char".char_id = charass.charass_char_id)); .DROP RULE "_INSERT_CHAR" ON api.purchaseline; apiadminfalse8721812151812141812151741758722151812151751801802158728729635!261883989_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO salesline DO INSTEAD UPDATE public.coitem SET coitem_status = new.status, coitem_scheddate = new.scheduled_date, coitem_promdate = new.promise_date, coitem_qtyord = new.qty_ordered, coitem_qty_uom_id = public.getuomid(new.qty_uom), coitem_qty_invuomratio = public.itemuomtouomratio(item.item_id, public.getuomid(new.qty_uom), item.item_inv_uom_id), coitem_price = new.net_unit_price, coitem_price_uom_id = public.getuomid(new.price_uom), coitem_price_invuomratio = public.itemuomtouomratio(item.item_id, public.getuomid(new.price_uom), item.item_price_uom_id), coitem_memo = new.notes, coitem_order_type = CASE WHEN (((NOT old.create_order) AND new.create_order) AND (item.item_type = 'M'::bpchar)) THEN 'W'::text WHEN ((((NOT old.create_order) AND new.create_order) AND (item.item_type = 'P'::bpchar)) AND itemsite.itemsite_createsopo) THEN 'P'::text WHEN (((NOT old.create_order) AND new.create_order) AND (item.item_type = 'P'::bpchar)) THEN 'R'::text ELSE NULL::text END, coitem_substitute_item_id = public.getitemid(new.substitute_for), coitem_prcost = new.overwrite_po_price, coitem_taxtype_id = CASE WHEN (new.tax_type = 'None'::text) THEN NULL::integer ELSE public.gettaxtypeid(new.tax_type) END, coitem_warranty = new.warranty, coitem_cos_accnt_id = public.getglaccntid(new.alternate_cos_account), coitem_rev_accnt_id = public.getglaccntid(new.alternate_rev_account) FROM (public.item JOIN public.itemsite ON ((item.item_id = itemsite.itemsite_item_id))) WHERE ((((item.item_number = old.item_number) AND (coitem.coitem_cohead_id = public.getcoheadid((old.order_number)::text))) AND (coitem.coitem_id = public.getcoitemid((old.order_number)::text, (old.line_number)::text))) AND (coitem.coitem_subnumber = 0)); &DROP RULE "_UPDATE" ON api.salesline; apiadminfalse18418418418415841841623168317418417941741841741841841741841841679175179179184184184174158318418418416091841751841791849635!261883991_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO apmemo DO INSTEAD UPDATE public.apopen SET apopen_duedate = new.due_date, apopen_terms_id = public.gettermsid(new.terms), apopen_amount = new.amount, apopen_notes = new.notes WHERE ((apopen.apopen_docnumber = old.document_number) AND ((apopen.apopen_doctype)::text = CASE WHEN (old.document_type = 'Credit Memo'::text) THEN 'C'::text WHEN (old.document_type = 'Debit Memo'::text) THEN 'D'::text ELSE ''::text END)); #DROP RULE "_UPDATE" ON api.apmemo; apiadminfalse19419416811941941901901941941941949635!261883992_UPDATERULEbCREATE RULE "_UPDATE" AS ON UPDATE TO armemo DO INSTEAD UPDATE public.aropen SET aropen_duedate = new.due_date, aropen_terms_id = public.gettermsid(new.terms), aropen_salesrep_id = public.getsalesrepid(new.sales_rep), aropen_amount = new.amount, aropen_commission_due = new.commission_due, aropen_notes = new.notes, aropen_rsncode_id = public.getrsnid(new.reason_code) WHERE ((aropen.aropen_docnumber = old.document_number) AND ((aropen.aropen_doctype)::text = CASE WHEN (old.document_type = 'Credit Memo'::text) THEN 'C'::text WHEN (old.document_type = 'Debit Memo'::text) THEN 'D'::text ELSE ''::text END)); #DROP RULE "_UPDATE" ON api.armemo; apiadminfalse2001951681166016542001952002002002002002002002002009635!261883994_UPDATERULEGCREATE RULE "_UPDATE" AS ON UPDATE TO physinvcount DO INSTEAD NOTHING; )DROP RULE "_UPDATE" ON api.physinvcount; apiadminfalse1771771779635!261887653_UPDATERULE0CREATE RULE "_UPDATE" AS ON UPDATE TO account DO INSTEAD UPDATE public.crmacct SET crmacct_number = new.account_number, crmacct_parent_id = public.getcrmacctid(new.parent_account), crmacct_name = new.account_name, crmacct_active = new.active, crmacct_type = CASE WHEN (new.type = 'Individual'::text) THEN 'I'::text ELSE 'O'::text END, crmacct_cntct_id_1 = public.getcntctid(new.primary_contact_number), crmacct_cntct_id_2 = public.getcntctid(new.secondary_contact_number), crmacct_notes = new.notes WHERE (crmacct.crmacct_number = (old.account_number)::text); $DROP RULE "_UPDATE" ON api.account; apiadminfalse804804804804804804158915818048041888048049635!261887661_UPDATERULE\CREATE RULE "_UPDATE" AS ON UPDATE TO accountchar DO INSTEAD UPDATE public.charass SET charass_value = new.value WHERE (((charass.charass_target_type = 'CRMACCT'::text) AND (charass.charass_target_id = public.getcrmacctid((old.account_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'CRMACCT'::text))); (DROP RULE "_UPDATE" ON api.accountchar; apiadminfalse805805805157680521515892152158059635!261887668_UPDATERULEICREATE RULE "_UPDATE" AS ON UPDATE TO accountcomment DO INSTEAD NOTHING; +DROP RULE "_UPDATE" ON api.accountcomment; apiadminfalse8068068069635!261887675_UPDATERULE'CREATE RULE "_UPDATE" AS ON UPDATE TO accountfile DO INSTEAD UPDATE public.url SET url_title = new.title, url_url = new.url WHERE ((((url.url_source_id = public.getcrmacctid(old.account_number)) AND (url.url_source = 'CRMA'::text)) AND (url.url_title = old.title)) AND (url.url_url = old.url)); (DROP RULE "_UPDATE" ON api.accountfile; apiadminfalse80780722115892212212218078078079635"261887682_UPDATERULEUCREATE RULE "_UPDATE" AS ON UPDATE TO accountimage DO INSTEAD UPDATE public.imageass SET imageass_image_id = public.getimageid(new.image_name) WHERE (((imageass.imageass_source_id = public.getcrmacctid(old.account_number)) AND (imageass.imageass_source = 'CRMA'::text)) AND (imageass.imageass_image_id = public.getimageid(old.image_name))); )DROP RULE "_UPDATE" ON api.accountimage; apiadminfalse808808224224224808161115898089635"261887689_UPDATERULE'CREATE RULE "_UPDATE" AS ON UPDATE TO address DO INSTEAD SELECT public.saveaddr(public.getaddrid((new.address_number)::text), (new.address_number)::text, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.active, new.notes, new.change) AS saveaddr; $DROP RULE "_UPDATE" ON api.address; apiadminfalse809202815688098098098098098098098098098098098099635 "261887696_UPDATERULESCREATE RULE "_UPDATE" AS ON UPDATE TO addresschar DO INSTEAD UPDATE public.charass SET charass_value = new.value WHERE (((charass.charass_target_type = 'ADDR'::text) AND (charass.charass_target_id = public.getaddrid((old.address_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'ADDR'::text))); (DROP RULE "_UPDATE" ON api.addresschar; apiadminfalse810810215810156881021521515768109635 "261887703_UPDATERULEICREATE RULE "_UPDATE" AS ON UPDATE TO addresscomment DO INSTEAD NOTHING; +DROP RULE "_UPDATE" ON api.addresscomment; apiadminfalse8118118119635"261887714_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO bom DO INSTEAD SELECT public.savebomhead(public.getitemid((new.item_number)::text), (new.revision)::text, new.revision_date, new.document_number, COALESCE(new.batch_size, (0)::numeric), new.total_qty_per) AS savebomhead; DROP RULE "_UPDATE" ON api.bom; apiadminfalse812812162381281281281281281220319635"261887723_UPDATERULE^CREATE RULE "_UPDATE" AS ON UPDATE TO bomitem DO INSTEAD UPDATE public.bomitem SET bomitem_issuemethod = CASE WHEN (new.issue_method = 'Mixed'::text) THEN 'M'::text WHEN (new.issue_method = 'Push'::text) THEN 'S'::text WHEN (new.issue_method = 'Pull'::text) THEN 'L'::text ELSE NULL::text END, bomitem_uom_id = public.getuomid(new.issue_uom), bomitem_qtyper = new.qty_per, bomitem_scrap = new.scrap, bomitem_effective = CASE WHEN (new.effective = 'Always'::text) THEN public.startoftime() ELSE (new.effective)::date END, bomitem_expires = CASE WHEN (new.expires = 'Never'::text) THEN public.endoftime() ELSE (new.expires)::date END, bomitem_createwo = new.create_child_wo, bomitem_booitem_seq_id = COALESCE(public.getbooitemseqid((new.bom_item_number)::text, new.used_at), (-1)), bomitem_schedatwooper = new.schedule_at_wo_operation, bomitem_ecn = new.ecn_number, bomitem_subtype = CASE WHEN (new.substitutions = 'No'::text) THEN 'N'::text WHEN (new.substitutions = 'Item-Defined'::text) THEN 'I'::text WHEN (new.substitutions = 'BOM-Defined'::text) THEN 'B'::text ELSE NULL::text END, bomitem_rev_id = public.getrevid('BOM'::text, (new.bom_item_number)::text, (new.bom_revision)::text), bomitem_char_id = public.getcharid(new.characteristic, 'I'::text), bomitem_value = new.value, bomitem_notes = new.notes, bomitem_ref = new.reference WHERE (bomitem.bomitem_id = old.id); $DROP RULE "_UPDATE" ON api.bomitem; apiadminfalse8131683157615731653142581381321038138138138138131868138138138138138138138138138138138139635"261887732_UPDATERULEICREATE RULE "_UPDATE" AS ON UPDATE TO bomitemcomment DO INSTEAD NOTHING; +DROP RULE "_UPDATE" ON api.bomitemcomment; apiadminfalse8148148149635"261887740_UPDATERULEFCREATE RULE "_UPDATE" AS ON UPDATE TO bomitemsubstitute DO INSTEAD UPDATE public.bomitemsub SET bomitemsub_uomratio = new.sub_parent_uom_ratio, bomitemsub_rank = new.ranking WHERE ((bomitemsub.bomitemsub_bomitem_id = old.bomitem_id) AND (bomitemsub.bomitemsub_item_id = public.getitemid((old.substitute_item_number)::text))); .DROP RULE "_UPDATE" ON api.bomitemsubstitute; apiadminfalse81581581581581522622616238159635!"261887747_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO budget DO INSTEAD UPDATE public.budghead SET budghead_name = new.name, budghead_descrip = new.description WHERE (budghead.budghead_name = old.name); #DROP RULE "_UPDATE" ON api.budget; apiadminfalse8162278168168169635%"261887754_UPDATERULENCREATE RULE "_UPDATE" AS ON UPDATE TO budgetentry DO INSTEAD UPDATE public.budgitem SET budgitem_amount = new.amount WHERE (((budgitem.budgitem_budghead_id = public.getbudgheadid(old.name)) AND (budgitem.budgitem_period_id = public.getperiodid(old.period_start))) AND (budgitem.budgitem_accnt_id = public.getglaccntid(old.account))); (DROP RULE "_UPDATE" ON api.budgetentry; apiadminfalse8172292291574160981716392298178178178179635)"261887763_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO cashreceipt DO INSTEAD UPDATE public.cashrcpt SET cashrcpt_amount = new.amount_received, cashrcpt_number = new.cashreceipt_number, cashrcpt_fundstype = CASE WHEN ((new.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((new.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((new.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((new.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((new.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((new.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((new.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((new.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((new.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, cashrcpt_docnumber = new.check_document_number, cashrcpt_bankaccnt_id = public.getbankaccntid(new.post_to), cashrcpt_notes = new.notes, cashrcpt_distdate = CASE WHEN (new.distribution_date > ''::text) THEN (new.distribution_date)::date ELSE NULL::date END, cashrcpt_salescat_id = public.getsalescatid(new.sales_category), cashrcpt_curr_id = public.getcurrid((new.currency)::text), cashrcpt_usecustdeposit = CASE WHEN (new.apply_balance_as = 'Customer Deposit'::text) THEN true ELSE false END WHERE (cashrcpt.cashrcpt_id = public.getcashrcptid((old.customer_number)::text, CASE WHEN ((old.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((old.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((old.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((old.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((old.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((old.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((old.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((old.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((old.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (old.check_document_number)::text)); (DROP RULE "_UPDATE" ON api.cashreceipt; apiadminfalse81815711655818159015758188188188188188182328188188188188189635-"261887774_UPDATERULEECREATE RULE "_UPDATE" AS ON UPDATE TO cashreceiptapply DO INSTEAD UPDATE public.cashrcptitem SET cashrcptitem_amount = new.amount_to_apply, cashrcptitem_discount = new.cashrcptitem_discount WHERE ((cashrcptitem.cashrcptitem_cashrcpt_id = public.getcashrcptid((old.customer_number)::text, CASE WHEN ((old.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((old.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((old.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((old.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((old.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((old.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((old.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((old.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((old.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (old.check_document_number)::text)) AND (cashrcptitem.cashrcptitem_aropen_id = public.getaropenid((old.customer_number)::text, (old.doc_type)::bpchar, (old.doc_number)::text))); -DROP RULE "_UPDATE" ON api.cashreceiptapply; apiadminfalse8198198198198198198198192331570233819157596351"261887785_UPDATERULEECREATE RULE "_UPDATE" AS ON UPDATE TO cashreceiptapplymisc DO INSTEAD UPDATE public.cashrcptmisc SET cashrcptmisc_accnt_id = public.getglaccntid((new.account)::text), cashrcptmisc_amount = new.amount_to_distribute, cashrcptmisc_notes = new.notes WHERE ((cashrcptmisc.cashrcptmisc_cashrcpt_id = public.getcashrcptid((old.customer_number)::text, CASE WHEN ((old.funds_type)::text = 'Check'::text) THEN 'C'::text WHEN ((old.funds_type)::text = 'Certified Check'::text) THEN 'T'::text WHEN ((old.funds_type)::text = 'Master Card'::text) THEN 'M'::text WHEN ((old.funds_type)::text = 'Visa'::text) THEN 'V'::text WHEN ((old.funds_type)::text = 'American Express'::text) THEN 'A'::text WHEN ((old.funds_type)::text = 'Discover Card'::text) THEN 'D'::text WHEN ((old.funds_type)::text = 'Other Credit Card'::text) THEN 'R'::text WHEN ((old.funds_type)::text = 'Cash'::text) THEN 'K'::text WHEN ((old.funds_type)::text = 'Wire Transfer'::text) THEN 'W'::text ELSE 'O'::text END, (old.check_document_number)::text)) AND (cashrcptmisc.cashrcptmisc_accnt_id = public.getglaccntid((old.account)::text))); 1DROP RULE "_UPDATE" ON api.cashreceiptapplymisc; apiadminfalse8202348202341609820157582082082082082096355"261887796_UPDATERULEGCREATE RULE "_UPDATE" AS ON UPDATE TO contact DO INSTEAD SELECT public.savecntct(public.getcntctid((new.contact_number)::text), (new.contact_number)::text, public.getcrmacctid(new.crm_account), public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.address_change), new.honorific, new.first, new.middle, new.last, new.suffix, new.initials, new.active, new.voice, new.alternate, new.fax, new.email, new.web, new.notes, new.job_title, new.contact_change) AS savecntct; $DROP RULE "_UPDATE" ON api.contact; apiadminfalse8218218218212033156820298211589158182182182182182182182182182182182182182182182182182182182182182182182196359"261887803_UPDATERULENCREATE RULE "_UPDATE" AS ON UPDATE TO contactchar DO INSTEAD UPDATE public.charass SET charass_value = new.value WHERE (((charass.charass_target_type = 'CNTCT'::text) AND (charass.charass_target_id = public.getcntctid(old.contact_number))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'CNTCT'::text))); (DROP RULE "_UPDATE" ON api.contactchar; apiadminfalse822822158115762152152158228228229635="261887810_UPDATERULEICREATE RULE "_UPDATE" AS ON UPDATE TO contactcomment DO INSTEAD NOTHING; +DROP RULE "_UPDATE" ON api.contactcomment; apiadminfalse8238238239635A"261887819_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO creditmemo DO INSTEAD UPDATE public.cmhead SET cmhead_custponumber = new.customer_po_number, cmhead_docdate = new.memo_date, cmhead_shipto_id = COALESCE(public.getshiptoid(new.customer_number, new.shipto_number), (-1)), cmhead_shipto_name = new.shipto_name, cmhead_shipto_address1 = new.shipto_address1, cmhead_shipto_address2 = new.shipto_address2, cmhead_shipto_address3 = new.shipto_address3, cmhead_shipto_city = new.shipto_city, cmhead_shipto_state = new.shipto_state, cmhead_shipto_zipcode = new.shipto_postal_code, cmhead_shipto_country = new.shipto_country, cmhead_salesrep_id = public.getsalesrepid(new.sales_rep), cmhead_freight = COALESCE(new.freight, (0)::numeric), cmhead_misc = COALESCE(new.misc_charge_amount, (0)::numeric), cmhead_comments = new.notes, cmhead_billtoname = new.billto_name, cmhead_billtoaddress1 = new.billto_address1, cmhead_billtoaddress2 = new.billto_address2, cmhead_billtoaddress3 = new.billto_address3, cmhead_billtocity = new.billto_city, cmhead_billtostate = new.billto_state, cmhead_billtozip = new.billto_postal_code, cmhead_billtocountry = new.billto_country, cmhead_hold = COALESCE(new.on_hold, false), cmhead_commission = COALESCE(new.commission, (0)::numeric), cmhead_misc_accnt_id = COALESCE(public.getglaccntid(new.misc_charge_credit_account), (-1)), cmhead_misc_descrip = new.misc_charge_description, cmhead_rsncode_id = (SELECT rsncode.rsncode_id FROM public.rsncode WHERE (rsncode.rsncode_code = new.reason_code)), cmhead_curr_id = COALESCE(public.getcurrid((new.currency)::text), (-1)), cmhead_taxzone_id = public.gettaxzoneid(NULLIF(new.tax_zone, 'None'::text)) WHERE ((cmhead.cmhead_number = old.memo_number) AND (cmhead.cmhead_posted = false)); 'DROP RULE "_UPDATE" ON api.creditmemo; apiadminfalse824824824201824197824824201824824824824824824824824824824824824824824824824824824824824824824824824824824824197166016091680159016678249635E"261887830_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO creditmemoline DO INSTEAD SELECT public.updatecreditmemoline(new.*, old.*) AS updatecreditmemoline; +DROP RULE "_UPDATE" ON api.creditmemoline; apiadminfalse82582523898259635I"261887838_UPDATERULEKCREATE RULE "_UPDATE" AS ON UPDATE TO custchar DO INSTEAD UPDATE public.charass SET charass_value = new.value WHERE (((charass.charass_target_type = 'C'::text) AND (charass.charass_target_id = public.getcustid((old.customer_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'C'::text))); %DROP RULE "_UPDATE" ON api.custchar; apiadminfalse826826215826826215159282621515769635M"261887845_UPDATERULEFCREATE RULE "_UPDATE" AS ON UPDATE TO custcomment DO INSTEAD NOTHING; (DROP RULE "_UPDATE" ON api.custcomment; apiadminfalse8278278279635Q"261887853_UPDATERULEICREATE RULE "_UPDATE" AS ON UPDATE TO custcreditcard DO INSTEAD NOTHING; +DROP RULE "_UPDATE" ON api.custcreditcard; apiadminfalse8288288289635U"261887862_UPDATERULE CREATE RULE "_UPDATE" AS ON UPDATE TO customer DO INSTEAD UPDATE public.custinfo SET cust_active = new.active, cust_custtype_id = public.getcusttypeid(new.customer_type), cust_salesrep_id = public.getsalesrepid(new.sales_rep), cust_commprcnt = (new.commission * 0.01), cust_name = new.customer_name, cust_creditlmt = new.credit_limit, cust_creditrating = new.credit_rating, cust_backorder = new.accepts_backorders, cust_partialship = new.accepts_partial_shipments, cust_terms_id = public.gettermsid(new.default_terms), cust_discntprcnt = new.default_discount, cust_balmethod = CASE WHEN (new.balance_method = 'Balance Forward'::text) THEN 'B'::text WHEN (new.balance_method = 'Open Items'::text) THEN 'O'::text ELSE NULL::text END, cust_ffshipto = new.allow_free_form_shipto, cust_shipform_id = public.getshipformid(new.ship_form), cust_shipvia = new.ship_via, cust_blanketpos = new.uses_blanket_pos, cust_shipchrg_id = COALESCE(public.getshipchrgid(new.shipping_charges), (-1)), cust_creditstatus = CASE WHEN (new.credit_status = 'On Credit Warning'::text) THEN 'W'::text WHEN (new.credit_status = 'On Credit Hold'::text) THEN 'H'::text ELSE 'G'::text END, cust_comments = new.notes, cust_ffbillto = new.allow_free_form_billto, cust_usespos = new.uses_purchase_orders, cust_number = new.customer_number, cust_autoupdatestatus = new.credit_status_exceed_warn, cust_autoholdorders = new.credit_status_exceed_hold, cust_preferred_warehous_id = COALESCE(public.getwarehousid(new.preferred_selling_site, 'ACTIVE'::text), (-1)), cust_curr_id = public.getcurrid((new.default_currency)::text), cust_creditlmt_curr_id = public.getcurrid((new.credit_limit_currency)::text), cust_cntct_id = public.savecntct(public.getcntctid(new.billing_contact_number, false), new.billing_contact_number, public.saveaddr(public.getaddrid(new.billing_contact_address_number), new.billing_contact_address_number, new.billing_contact_address1, new.billing_contact_address2, new.billing_contact_address3, new.billing_contact_city, new.billing_contact_state, new.billing_contact_postalcode, new.billing_contact_country, new.billing_contact_address_change), new.billing_contact_honorific, new.billing_contact_first, new.billing_contact_middle, new.billing_contact_last, new.billing_contact_suffix, new.billing_contact_voice, new.billing_contact_alternate, new.billing_contact_fax, new.billing_contact_email, new.billing_contact_web, new.billing_contact_job_title, new.billing_contact_change), cust_corrcntct_id = public.savecntct(public.getcntctid(new.correspond_contact_number, false), new.correspond_contact_number, public.saveaddr(public.getaddrid(new.correspond_contact_address_number), new.correspond_contact_address_number, new.correspond_contact_address1, new.correspond_contact_address2, new.correspond_contact_address3, new.correspond_contact_city, new.correspond_contact_state, new.correspond_contact_postalcode, new.correspond_contact_country, new.correspond_contact_address_change), new.correspond_contact_honorific, new.correspond_contact_first, new.correspond_contact_middle, new.correspond_contact_last, new.correspond_contact_suffix, new.correspond_contact_voice, new.correspond_contact_alternate, new.correspond_contact_fax, new.correspond_contact_email, new.correspond_contact_web, new.correspond_contact_job_title, new.correspond_contact_change), cust_taxzone_id = public.gettaxzoneid(new.default_tax_zone), cust_gracedays = CASE WHEN (COALESCE(new.alternate_grace_days, 0) > 0) THEN new.alternate_grace_days ELSE NULL::integer END WHERE (custinfo.cust_id = public.getcustid((old.customer_number)::text)); %DROP RULE "_UPDATE" ON api.customer; apiadminfalse82982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982982920348291590202982982982915828291568829196829168182915941592829168016601664166316888298298298298298298298298298298298298298298298298298299635["261887878_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO customertype DO INSTEAD UPDATE public.custtype SET custtype_code = new.code, custtype_descrip = new.description, custtype_char = new.enable_characteristics_profile WHERE (custtype.custtype_code = (old.code)::text); )DROP RULE "_UPDATE" ON api.customertype; apiadminfalse8318318312368318319635_"261887885_UPDATERULEyCREATE RULE "_UPDATE" AS ON UPDATE TO customertypechar DO INSTEAD UPDATE public.charass SET charass_value = new.value, charass_default = new.is_default WHERE (((charass.charass_target_type = 'CT'::text) AND (charass.charass_target_id = public.getcusttypeid((old.customer_type)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'CT'::text))); -DROP RULE "_UPDATE" ON api.customertypechar; apiadminfalse832832159415768322152158328328322159635c"261887894_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO custshipto DO INSTEAD UPDATE public.shiptoinfo SET shipto_cust_id = public.getcustid((new.customer_number)::text), shipto_name = new.name, shipto_salesrep_id = public.getsalesrepid(new.sales_rep), shipto_comments = new.general_notes, shipto_shipcomments = new.shipping_notes, shipto_shipzone_id = public.getshipzoneid(new.zone), shipto_shipvia = new.ship_via, shipto_commission = (new.commission / (100)::numeric), shipto_shipform_id = public.getshipformid(new.ship_form), shipto_shipchrg_id = public.getshipchrgid(new.shipping_charges), shipto_active = new.active, shipto_default = new.default_flag, shipto_num = old.shipto_number, shipto_ediprofile_id = CASE WHEN (new.edi_profile = 'No EDI'::text) THEN (-1) WHEN (new.edi_profile = 'Use Customer Master'::text) THEN (-2) ELSE public.getediprofileid(new.edi_profile) END, shipto_cntct_id = public.savecntct(public.getcntctid(new.contact_number), new.contact_number, NULL::integer, new.honorific, new.first, new.middle, new.last, new.suffix, new.phone, NULL::text, new.fax, new.email, NULL::text, new.job_title, new.contact_change), shipto_addr_id = public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.address_change), shipto_taxzone_id = public.gettaxzoneid(new.tax_zone) WHERE (shiptoinfo.shipto_id = public.getshiptoid((old.customer_number)::text, (old.shipto_number)::text)); 'DROP RULE "_UPDATE" ON api.custshipto; apiadminfalse8338331660159615681592833158183383316808331670166316671664202833203420298338338338338338338338338338338338338338338338338338338338338338338338338338338338338338339635g"261887902_UPDATERULEGCREATE RULE "_UPDATE" AS ON UPDATE TO custtax DO INSTEAD UPDATE public.taxreg SET taxreg_number = new.registration_number WHERE (((taxreg.taxreg_rel_type = 'C'::bpchar) AND (taxreg.taxreg_rel_id = public.getcustid((old.customer_number)::text))) AND (taxreg.taxreg_taxauth_id = public.gettaxauthid((old.tax_authority)::text))); $DROP RULE "_UPDATE" ON api.custtax; apiadminfalse834834240240240834167715928348349635k"261887911_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO employee DO INSTEAD UPDATE public.emp SET emp_code = new.code, emp_number = new.number, emp_active = new.active, emp_startdate = new.start_date, emp_cntct_id = public.savecntct(public.getcntctid(new.contact_number), new.contact_number, public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change), new.honorific, new.first, new.middle, new.last, new.suffix, new.voice, new.alternate, new.fax, new.email, new.web, new.job_title, new.contact_change), emp_warehous_id = public.getwarehousid(new.site, 'ALL'::text), emp_mgr_emp_id = (SELECT emp.emp_id FROM public.emp WHERE (emp.emp_code = new.manager_code)), emp_wage_type = CASE WHEN (new.wage_type = 'Hourly'::text) THEN 'H'::text WHEN (new.wage_type = 'Salaried'::text) THEN 'S'::text ELSE NULL::text END, emp_wage = new.wage, emp_wage_curr_id = COALESCE(public.getcurrid((new.wage_currency)::text), public.basecurrid()), emp_wage_period = CASE WHEN (new.wage_period = 'Hour'::text) THEN 'H'::text WHEN (new.wage_period = 'Day'::text) THEN 'D'::text WHEN (new.wage_period = 'Week'::text) THEN 'W'::text WHEN (new.wage_period = 'Biweek'::text) THEN 'BW'::text WHEN (new.wage_period = 'Month'::text) THEN 'M'::text WHEN (new.wage_period = 'Year'::text) THEN 'Y'::text ELSE NULL::text END, emp_dept_id = public.getdeptid(new.department), emp_shift_id = public.getshiftid(new.shift), emp_image_id = public.getimageid(new.image), emp_extrate = new.rate, emp_extrate_period = CASE WHEN (new.billing_period = 'Hour'::text) THEN 'H'::text WHEN (new.billing_period = 'Day'::text) THEN 'D'::text WHEN (new.billing_period = 'Week'::text) THEN 'W'::text WHEN (new.billing_period = 'Biweek'::text) THEN 'BW'::text WHEN (new.billing_period = 'Month'::text) THEN 'M'::text WHEN (new.billing_period = 'Year'::text) THEN 'Y'::text ELSE NULL::text END, emp_notes = COALESCE(new.notes, ''::text) WHERE (emp.emp_code = (old.code)::text); %DROP RULE "_UPDATE" ON api.employee; apiadminfalse83583583510872428351568158124220341590159516112029168816628358358358358358358358358358358358358358358358358358358358358358358358358358358358358358358358358358358358359635o"261887919_UPDATERULEPCREATE RULE "_UPDATE" AS ON UPDATE TO employeechar DO INSTEAD UPDATE public.charass SET charass_value = new.value WHERE (((charass.charass_target_type = 'EMP'::text) AND (charass.charass_target_id = public.getempid((old.employee_code)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'EMP'::text))); )DROP RULE "_UPDATE" ON api.employeechar; apiadminfalse836215215215160015768368368368369635s"261887926_UPDATERULEJCREATE RULE "_UPDATE" AS ON UPDATE TO employeecomment DO INSTEAD NOTHING; ,DROP RULE "_UPDATE" ON api.employeecomment; apiadminfalse8378378379635w"261887933_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO extshipmaint DO INSTEAD UPDATE public.shipdata SET shipdata_cohead_number = new.so_number, shipdata_shiphead_number = new.shipment_number, shipdata_void_ind = new.void, shipdata_shipper = new.shipper, shipdata_billing_option = new.billing_option, shipdata_weight = new.weight, shipdata_base_freight = new.base_freight, shipdata_base_freight_curr_id = public.getcurrid((new.base_freight_currency)::text), shipdata_total_freight = new.total_freight, shipdata_total_freight_curr_id = public.getcurrid((new.total_freight_currency)::text), shipdata_package_type = new.package_type, shipdata_cosmisc_tracknum = new.tracking_number, shipdata_cosmisc_packnum_tracknum = new.package_tracking_number, shipdata_lastupdated = new.last_updated WHERE ((((shipdata.shipdata_cohead_number = (old.so_number)::text) AND (shipdata.shipdata_shiphead_number = (old.shipment_number)::text)) AND (shipdata.shipdata_shipper = (old.shipper)::text)) AND (shipdata.shipdata_cosmisc_packnum_tracknum = (old.package_tracking_number)::text)); )DROP RULE "_UPDATE" ON api.extshipmaint; apiadminfalse83883883883883824415908388382442442448388388388388388388388388389635{"261887941_UPDATERULEjCREATE RULE "_UPDATE" AS ON UPDATE TO freightpricingscheduleitem DO INSTEAD UPDATE public.ipsfreight SET ipsfreight_ipshead_id = public.getipsheadid((old.pricing_schedule)::text), ipsfreight_qtybreak = new.qty_break, ipsfreight_price = new.price, ipsfreight_type = CASE WHEN (new.price_type = 'Flat Rate'::text) THEN 'F'::text WHEN (new.price_type = 'Price Per UOM'::text) THEN 'P'::text ELSE NULL::text END, ipsfreight_warehous_id = CASE WHEN (new.from_site = 'Any'::text) THEN NULL::integer ELSE public.getwarehousid(new.from_site, 'All'::text) END, ipsfreight_shipzone_id = CASE WHEN (new.to_shipzone = 'Any'::text) THEN NULL::integer ELSE public.getshipzoneid(new.to_shipzone) END, ipsfreight_freightclass_id = CASE WHEN (new.freight_class = 'Any'::text) THEN NULL::integer ELSE public.getfreightclassid(new.freight_class) END, ipsfreight_shipvia = CASE WHEN (new.ship_via = 'Any'::text) THEN NULL::text ELSE new.ship_via END WHERE (((((((((ipsfreight.ipsfreight_ipshead_id = public.getipsheadid((old.pricing_schedule)::text)) AND (ipsfreight.ipsfreight_qtybreak = old.qty_break)) AND (ipsfreight.ipsfreight_price = old.price)) AND ((ipsfreight.ipsfreight_type)::text = CASE WHEN (old.price_type = 'Flat Rate'::text) THEN 'F'::text WHEN (old.price_type = 'Price Per UOM'::text) THEN 'P'::text ELSE NULL::text END)) AND ((ipsfreight.ipsfreight_warehous_id IS NULL) AND (old.from_site = 'Any'::text))) OR ((ipsfreight.ipsfreight_warehous_id = CASE WHEN (old.from_site = 'Any'::text) THEN 0 ELSE public.getwarehousid(old.from_site, 'All'::text) END) AND ((ipsfreight.ipsfreight_shipzone_id IS NULL) AND (old.to_shipzone = 'Any'::text)))) OR ((ipsfreight.ipsfreight_shipzone_id = CASE WHEN (old.to_shipzone = 'Any'::text) THEN 0 ELSE public.getshipzoneid(old.to_shipzone) END) AND ((ipsfreight.ipsfreight_freightclass_id IS NULL) AND (old.freight_class = 'Any'::text)))) OR ((ipsfreight.ipsfreight_freightclass_id = CASE WHEN (old.freight_class = 'Any'::text) THEN 0 ELSE public.getfreightclassid(old.freight_class) END) AND ((ipsfreight.ipsfreight_shipvia IS NULL) AND (old.ship_via = 'Any'::text)))) OR (ipsfreight.ipsfreight_shipvia = old.ship_via)); 7DROP RULE "_UPDATE" ON api.freightpricingscheduleitem; apiadminfalse83983924616202461606167024624616888392462462468398392468398398398398399635"261887952_UPDATERULE?CREATE RULE "_UPDATE" AS ON UPDATE TO glaccount DO INSTEAD UPDATE public.accnt SET accnt_number = new.account_number, accnt_descrip = new.description, accnt_comments = new.notes, accnt_profit = new.profit_center, accnt_sub = new.sub_account, accnt_type = CASE WHEN (new.type = 'Asset'::text) THEN 'A'::text WHEN (new.type = 'Liability'::text) THEN 'L'::text WHEN (new.type = 'Expense'::text) THEN 'E'::text WHEN (new.type = 'Revenue'::text) THEN 'R'::text WHEN (new.type = 'Equity'::text) THEN 'Q'::text ELSE NULL::text END, accnt_extref = new.ext_reference, accnt_company = new.company, accnt_forwardupdate = new.forward_update_trial_balances, accnt_subaccnttype_code = new.sub_type WHERE (accnt.accnt_id = public.getglaccntid((old.company)::text, (old.profit_center)::text, (old.account_number)::text, (old.sub_account)::text)); &DROP RULE "_UPDATE" ON api.glaccount; apiadminfalse84022884016108408408408408408408408408408409635"261887961_UPDATERULE@CREATE RULE "_UPDATE" AS ON UPDATE TO incident DO INSTEAD UPDATE public.incdt SET incdt_crmacct_id = public.getcrmacctid(new.crm_account), incdt_cntct_id = public.savecntct(public.getcntctid(new.contact_number), new.contact_number, NULL::integer, new.honorific, new.first, new.middle, new.last, new.suffix, new.phone, NULL::text, new.fax, new.email, NULL::text, new.job_title, new.contact_change), incdt_descrip = new.notes, incdt_summary = new.description, incdt_item_id = public.getitemid(new.item_number), incdt_status = CASE WHEN (new.status = 'New'::text) THEN 'N'::text WHEN (new.status = 'Feedback'::text) THEN 'F'::text WHEN (new.status = 'Confirmed'::text) THEN 'C'::text WHEN (new.status = 'Assigned'::text) THEN 'A'::text WHEN (new.status = 'Resolved'::text) THEN 'R'::text WHEN (new.status = 'Closed'::text) THEN 'L'::text ELSE NULL::text END, incdt_assigned_username = new.assigned_to, incdt_incdtcat_id = public.getincdtcatid(new.category), incdt_incdtseverity_id = public.getincdtseverityid(new.severity), incdt_incdtpriority_id = public.getincdtpriorityid(new.priority), incdt_incdtresolution_id = public.getincdtresolutionid(new.resolution), incdt_lotserial = new.lot_serial_number, incdt_ls_id = public.getlotserialid(new.item_number, new.lot_serial_number) WHERE (incdt.incdt_id = public.getincidentid(old.incident_number)); %DROP RULE "_UPDATE" ON api.incident; apiadminfalse84116128411589161516148411616163320341623161784184184118984184184184184184184184184184184184184184184184184184184115819635"261887969_UPDATERULESCREATE RULE "_UPDATE" AS ON UPDATE TO incidentchar DO INSTEAD UPDATE public.charass SET charass_value = new.value WHERE (((charass.charass_target_type = 'INCDT'::text) AND (charass.charass_target_id = public.getincidentid(old.incident_number))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'INCDT'::text))); )DROP RULE "_UPDATE" ON api.incidentchar; apiadminfalse842842842215215161784215762158429635"261887977_UPDATERULEJCREATE RULE "_UPDATE" AS ON UPDATE TO incidentcomment DO INSTEAD NOTHING; ,DROP RULE "_UPDATE" ON api.incidentcomment; apiadminfalse8438438439635"261887983_UPDATERULE+CREATE RULE "_UPDATE" AS ON UPDATE TO incidentfile DO INSTEAD UPDATE public.url SET url_title = new.title, url_url = new.url WHERE ((((url.url_source_id = public.getincidentid(old.incident_number)) AND (url.url_source = 'INCDT'::text)) AND (url.url_title = old.title)) AND (url.url_url = old.url)); )DROP RULE "_UPDATE" ON api.incidentfile; apiadminfalse84416178442212212212218448448449635"261887990_UPDATERULEYCREATE RULE "_UPDATE" AS ON UPDATE TO incidentimage DO INSTEAD UPDATE public.imageass SET imageass_image_id = public.getimageid(new.image_name) WHERE (((imageass.imageass_source_id = public.getincidentid(old.incident_number)) AND (imageass.imageass_source = 'INCDT'::text)) AND (imageass.imageass_image_id = public.getimageid(old.image_name))); *DROP RULE "_UPDATE" ON api.incidentimage; apiadminfalse845845845224224845224161116179635"261888000_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO invoice DO INSTEAD UPDATE public.invchead SET invchead_invcnumber = old.invoice_number, invchead_ordernumber = new.order_number, invchead_invcdate = new.invoice_date, invchead_shipdate = new.ship_date, invchead_orderdate = new.order_date, invchead_salesrep_id = public.getsalesrepid(new.sales_rep), invchead_commission = new.commission, invchead_taxzone_id = public.gettaxzoneid(NULLIF(new.tax_zone, 'None'::text)), invchead_terms_id = public.gettermsid(new.terms), invchead_cust_id = (SELECT public.getcustid(new.customer_number) AS getcustid), invchead_billto_name = new.billto_name, invchead_billto_address1 = new.billto_address1, invchead_billto_address2 = new.billto_address2, invchead_billto_address3 = new.billto_address3, invchead_billto_city = new.billto_city, invchead_billto_state = new.billto_state, invchead_billto_zipcode = new.billto_postal_code, invchead_billto_country = new.billto_country, invchead_billto_phone = new.billto_phone, invchead_shipto_id = COALESCE(public.getshiptoid(new.customer_number, new.shipto_number), (-1)), invchead_shipto_name = new.shipto_name, invchead_shipto_address1 = new.shipto_address1, invchead_shipto_address2 = new.shipto_address2, invchead_shipto_address3 = new.shipto_address3, invchead_shipto_city = new.shipto_city, invchead_shipto_state = new.shipto_state, invchead_shipto_zipcode = new.shipto_postal_code, invchead_shipto_country = new.shipto_country, invchead_shipto_phone = new.shipto_phone, invchead_ponumber = new.po_number, invchead_shipvia = new.ship_via, invchead_prj_id = COALESCE(public.getprjid(new.project_number), (-1)), invchead_fob = new.fob, invchead_misc_descrip = new.misc_charge_description, invchead_misc_amount = new.misc_charge, invchead_misc_accnt_id = COALESCE(public.getglaccntid(new.misc_charge_account_number), (-1)), invchead_freight = new.freight, invchead_curr_id = COALESCE(public.getcurrid((new.currency)::text), (-1)), invchead_payment = new.payment, invchead_notes = new.notes, invchead_saletype_id = public.getsaletypeid(new.sale_type), invchead_shipzone_id = public.getshipzoneid(new.shipto_shipzone) WHERE ((invchead.invchead_invcnumber = old.invoice_number) AND (invchead.invchead_posted = false)); $DROP RULE "_UPDATE" ON api.invoice; apiadminfalse84616461590160984615922058461681166116601680846167016672058468468468468468468468468468468468468468468468468468468468468468468468468468468468468468468468468468468468468468468468469635"261888011_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO invoiceline DO INSTEAD SELECT public.updateinvoicelineitem(new.*, old.*) AS updateinvoicelineitem; (DROP RULE "_UPDATE" ON api.invoiceline; apiadminfalse84784723978479635"261888020_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO item DO INSTEAD UPDATE public.item SET item_active = new.active, item_descrip1 = new.description1, item_descrip2 = new.description2, item_type = CASE WHEN (new.item_type = 'Purchased'::text) THEN 'P'::text WHEN (new.item_type = 'Manufactured'::text) THEN 'M'::text WHEN (new.item_type = 'Job'::text) THEN 'J'::text WHEN (new.item_type = 'Kit'::text) THEN 'K'::text WHEN (new.item_type = 'Phantom'::text) THEN 'F'::text WHEN (new.item_type = 'Reference'::text) THEN 'R'::text WHEN (new.item_type = 'Costing'::text) THEN 'S'::text WHEN (new.item_type = 'Tooling'::text) THEN 'T'::text WHEN (new.item_type = 'Outside Process'::text) THEN 'O'::text WHEN (new.item_type = 'Planning'::text) THEN 'L'::text WHEN (new.item_type = 'Breeder'::text) THEN 'B'::text WHEN (new.item_type = 'Co-Product'::text) THEN 'C'::text WHEN (new.item_type = 'By-Product'::text) THEN 'Y'::text ELSE NULL::text END, item_maxcost = new.maximum_desired_cost, item_classcode_id = public.getclasscodeid(new.class_code), item_inv_uom_id = public.getuomid(new.inventory_uom), item_picklist = new.pick_list_item, item_fractional = new.fractional, item_config = new.configured, item_sold = new.item_is_sold, item_prodcat_id = COALESCE(public.getprodcatid(new.product_category), (-1)), item_exclusive = new.exclusive, item_listprice = new.list_price, item_listcost = new.list_cost, item_price_uom_id = public.getuomid(new.list_price_uom), item_upccode = new.upc_code, item_prodweight = new.product_weight, item_packweight = new.packaging_weight, item_comments = new.notes, item_extdescrip = new.ext_description WHERE (item.item_id = public.getitemid((old.item_number)::text)); !DROP RULE "_UPDATE" ON api.item; apiadminfalse84884884884884884815778488488481648162384816838488481748488488488488488488488488488488488489635"261888029_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO itemalias DO INSTEAD UPDATE public.itemalias SET itemalias_number = new.alias_number, itemalias_usedescrip = new.use_description, itemalias_descrip1 = new.description1, itemalias_descrip2 = new.description2, itemalias_comments = new.comments, itemalias_crmacct_id = public.getcrmacctid(new.crmacct_number) WHERE ((itemalias.itemalias_item_id = public.getitemid((old.item_number)::text)) AND (itemalias.itemalias_number = old.alias_number)); &DROP RULE "_UPDATE" ON api.itemalias; apiadminfalse849849849162315898492548498498492548498499635"261888036_UPDATERULEiCREATE RULE "_UPDATE" AS ON UPDATE TO itemchar DO INSTEAD UPDATE public.charass SET charass_value = new.value, charass_default = new.is_default WHERE (((charass.charass_target_type = 'I'::text) AND (charass.charass_target_id = public.getitemid((old.item_number)::text))) AND (charass.charass_char_id = public.getcharid((old.characteristic)::text, 'I'::text))); %DROP RULE "_UPDATE" ON api.itemchar; apiadminfalse850157685021521516232158508508508509635"261888043_UPDATERULEFCREATE RULE "_UPDATE" AS ON UPDATE TO itemcomment DO INSTEAD NOTHING; (DROP RULE "_UPDATE" ON api.itemcomment; apiadminfalse8518518519635"261888051_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO itemcost DO INSTEAD SELECT public.updateitemcost(public.getitemid((new.item_number)::text), public.getcostelemid((new.costing_element)::text), public.getcurrid((new.currency)::text), new.actual_cost, new.post_to_standard) AS updateitemcost; %DROP RULE "_UPDATE" ON api.itemcost; apiadminfalse85285216238522157159085285215878528529635"261888058_UPDATERULE#CREATE RULE "_UPDATE" AS ON UPDATE TO itemfile DO INSTEAD UPDATE public.url SET url_title = new.title, url_url = new.url WHERE ((((url.url_source_id = public.getitemid((old.item_number)::text)) AND (url.url_source = 'I'::text)) AND (url.url_title = old.title)) AND (url.url_url = old.url)); %DROP RULE "_UPDATE" ON api.itemfile; apiadminfalse85322122116238532212218538538539635"261888066_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO itemimage DO INSTEAD SELECT public.saveimageass('I'::text, public.getitemid((new.item_number)::text), (CASE WHEN (new.purpose = 'Product Description'::text) THEN 'P'::text WHEN (new.purpose = 'Inventory Description'::text) THEN 'I'::text WHEN (new.purpose = 'Engineering Reference'::text) THEN 'E'::text WHEN (new.purpose = 'Miscellaneous'::text) THEN 'M'::text ELSE 'X'::text END)::bpchar, public.getimageid(new.image_name)) AS saveimageass; &DROP RULE "_UPDATE" ON api.itemimage; apiadminfalse8541611854854854162385420389635"261888075_UPDATERULE CREATE RULE "_UPDATE" AS ON UPDATE TO itemsite DO INSTEAD UPDATE public.itemsite SET itemsite_active = new.active, itemsite_dropship = new.dropship, itemsite_posupply = new.po_supplied_at_site, itemsite_createpr = new.create_prs, itemsite_wosupply = new.wo_supplied_at_site, itemsite_createwo = new.create_wos, itemsite_createsopr = new.create_soprs, itemsite_createsopo = new.create_sopos, itemsite_sold = new.sold_from_site, itemsite_soldranking = new.ranking, itemsite_costmethod = CASE WHEN (new.cost_method = 'None'::text) THEN 'N'::text WHEN (new.cost_method = 'Average'::text) THEN 'A'::text WHEN (new.cost_method = 'Standard'::text) THEN 'S'::text WHEN (new.cost_method = 'Job'::text) THEN 'J'::text ELSE NULL::text END, itemsite_controlmethod = CASE WHEN (new.control_method = 'None'::text) THEN 'N'::text WHEN (new.control_method = 'Regular'::text) THEN 'R'::text WHEN (new.control_method = 'Serial #'::text) THEN 'S'::text WHEN (new.control_method = 'Lot #'::text) THEN 'L'::text ELSE NULL::text END, itemsite_perishable = new.perishable, itemsite_plancode_id = public.getplancodeid(new.planner_code), itemsite_costcat_id = public.getcostcatid(new.cost_category), itemsite_loccntrl = new.multiple_location_control, itemsite_location_id = CASE WHEN (new.location = 'N/A'::text) THEN (-1) ELSE public.getlocationid((new.site)::text, new.location) END, itemsite_recvlocation_id = CASE WHEN (new.receive_location = 'N/A'::text) THEN (-1) ELSE public.getlocationid((new.site)::text, new.receive_location) END, itemsite_issuelocation_id = CASE WHEN (new.issue_location = 'N/A'::text) THEN (-1) ELSE public.getlocationid((new.site)::text, new.issue_location) END, itemsite_location_dist = new.auto_distr_location, itemsite_recvlocation_dist = new.auto_distr_receive_location, itemsite_issuelocation_dist = new.auto_distr_issue_location, itemsite_location = new.user_defined_location, itemsite_location_comments = new.user_defined_location, itemsite_disallowblankwip = new.disallow_blank_wip_locations, itemsite_stocked = new.stocked, itemsite_abcclass = new.abc_class, itemsite_autoabcclass = new.allow_automatic_updates, itemsite_cyclecountfreq = new.cycl_cnt_freq, itemsite_eventfence = new.event_fence, itemsite_useparams = new.enforce_order_parameters, itemsite_reorderlevel = new.reorder_level, itemsite_ordertoqty = new.order_up_to, itemsite_minordqty = new.minimum_order, itemsite_maxordqty = new.maximum_order, itemsite_multordqty = new.order_multiple, itemsite_useparamsmanual = new.enforce_on_manual_orders, itemsite_ordergroup = new.group_mps_mrp_orders, itemsite_ordergroup_first = new.first_group, itemsite_mps_timefence = new.mps_time_fence, itemsite_leadtime = new.lead_time, itemsite_safetystock = new.safety_stock, itemsite_supply_itemsite_id = CASE WHEN (new.supplied_from_site = 'None'::text) THEN NULL::integer WHEN (new.supplied_from_site = ''::text) THEN NULL::integer ELSE public.getitemsiteid(new.supplied_from_site, (new.item_number)::text) END, itemsite_notes = new.notes, itemsite_warrpurc = new.require_warranty, itemsite_autoreg = new.auto_register, itemsite_planning_type = CASE WHEN (new.planning_system = 'None'::text) THEN 'N'::text WHEN (new.planning_system = 'MPS'::text) THEN 'S'::text ELSE 'M'::text END WHERE (itemsite.itemsite_id = public.getitemsiteid((old.site)::text, (old.item_number)::text)); %DROP RULE "_UPDATE" ON api.itemsite; apiadminfalse85585585585585585585517585516351586855163216258558558558558558558558558558558558558558558558558558558558558558558558558558558558558558558558558558558558558558558558558559635"261888084_UPDATERULEJCREATE RULE "_UPDATE" AS ON UPDATE TO itemsitecomment DO INSTEAD NOTHING; ,DROP RULE "_UPDATE" ON api.itemsitecomment; apiadminfalse8568568569635"261888093_UPDATERULE/CREATE RULE "_UPDATE" AS ON UPDATE TO itemsource DO INSTEAD UPDATE public.itemsrc SET itemsrc_vend_item_number = new.vendor_item_number, itemsrc_vend_item_descrip = new.vendor_description, itemsrc_comments = new.notes, itemsrc_vend_uom = new.vendor_uom, itemsrc_invvendoruomratio = new.inventory_vendor_uom_ratio, itemsrc_minordqty = new.minimum_order, itemsrc_multordqty = new.order_multiple, itemsrc_leadtime = new.lead_time, itemsrc_ranking = new.vendor_ranking, itemsrc_active = new.active, itemsrc_default = new.itemsrc_default, itemsrc_manuf_name = new.manufacturer_name, itemsrc_manuf_item_number = new.manufacturer_item_number, itemsrc_manuf_item_descrip = new.manufacturer_description, itemsrc_upccode = new.bar_code, itemsrc_contrct_id = public.getcontrctid(new.contract_number), itemsrc_effective = COALESCE(public.getcontrcteffective(new.contract_number), new.effective_date), itemsrc_expires = COALESCE(public.getcontrctexpires(new.contract_number), new.expires_date) WHERE (((((itemsrc.itemsrc_item_id = public.getitemid((old.item_number)::text)) AND (itemsrc.itemsrc_vend_id = public.getvendid((old.vendor)::text))) AND (itemsrc.itemsrc_vend_item_number = old.vendor_item_number)) AND (itemsrc.itemsrc_manuf_name = old.manufacturer_name)) AND (itemsrc.itemsrc_manuf_item_number = old.manufacturer_item_number)); 'DROP RULE "_UPDATE" ON api.itemsource; apiadminfalse857960857958959857260260168616232602608578578578572608578578578578578578578578578578578578578578579635"261888103_UPDATERULEFCREATE RULE "_UPDATE" AS ON UPDATE TO itemsourceprice DO INSTEAD UPDATE public.itemsrcp SET itemsrcp_qtybreak = new.qty_break, itemsrcp_price = new.price_per_unit, itemsrcp_updated = now(), itemsrcp_curr_id = public.getcurrid((new.currency)::text), itemsrcp_dropship = COALESCE(new.dropship_only, false), itemsrcp_warehous_id = CASE WHEN (new.pricing_site = 'All'::text) THEN (-1) ELSE COALESCE(public.getwarehousid(new.pricing_site, 'ALL'::text), (-1)) END, itemsrcp_type = CASE WHEN (new.pricing_type = 'Discount'::text) THEN 'D'::text ELSE 'N'::text END, itemsrcp_discntprcnt = (COALESCE(new.discount_percent, 0.0) / 100.0), itemsrcp_fixedamtdiscount = new.discount_fixed_amount WHERE ((itemsrcp.itemsrcp_itemsrc_id = public.getitemsrcid((old.item_number)::text, (new.vendor)::text)) AND (itemsrcp.itemsrcp_qtybreak = old.qty_break)); ,DROP RULE "_UPDATE" ON api.itemsourceprice; apiadminfalse8588588588588588588588588588582612611629159016888588589635"261888111_UPDATERULEVCREATE RULE "_UPDATE" AS ON UPDATE TO itemsubstitute DO INSTEAD UPDATE public.itemsub SET itemsub_uomratio = new.sub_parent_uom_ratio, itemsub_rank = new.ranking WHERE ((itemsub.itemsub_parent_item_id = public.getitemid((old.root_item_number)::text)) AND (itemsub.itemsub_sub_item_id = public.getitemid((old.substitute_item_number)::text))); +DROP RULE "_UPDATE" ON api.itemsubstitute; apiadminfalse85985926285985985926216238599635"261888118_UPDATERULE^CREATE RULE "_UPDATE" AS ON UPDATE TO itemtaxtype DO INSTEAD UPDATE public.itemtax SET itemtax_taxzone_id = CASE WHEN ((new.tax_zone)::text = 'Any'::text) THEN NULL::integer ELSE public.gettaxzoneid((new.tax_zone)::text) END, itemtax_taxtype_id = public.gettaxtypeid(new.tax_type) WHERE (((itemtax.itemtax_item_id = public.getitemid((old.item_number)::text)) AND CASE WHEN ((old.tax_zone)::text = 'Any'::text) THEN (itemtax.itemtax_taxzone_id IS NULL) ELSE (itemtax.itemtax_taxzone_id = public.gettaxzoneid((old.tax_zone)::text)) END) AND (itemtax.itemtax_taxtype_id = public.gettaxtypeid(old.tax_type))); (DROP RULE "_UPDATE" ON api.itemtaxtype; apiadminfalse8601623263263263168016798608608608609635"261888125_UPDATERULErCREATE RULE "_UPDATE" AS ON UPDATE TO itemuomconversion DO INSTEAD SELECT public.saveitemuomconv(public.getitemid((new.item_number)::text), COALESCE(public.getuomid((new.uom)::text), (SELECT item.item_inv_uom_id FROM public.item WHERE (item.item_id = public.getitemid((new.item_number)::text)))), COALESCE(new.uom_value, (1)::numeric), COALESCE(public.getuomid(new.per_uom), (SELECT item.item_inv_uom_id FROM public.item WHERE (item.item_id = public.getitemid((new.item_number)::text)))), COALESCE(new.per_uom_value, (1)::numeric), COALESCE(new.fractional, false), public.getuomtypeid(new.selected_types)) AS saveitemuomconv; .DROP RULE "_UPDATE" ON api.itemuomconversion; apiadminfalse86186186117486117416851683861204216238618618618619635"261888133_UPDATERULEGCREATE RULE "_UPDATE" AS ON UPDATE TO journalentry DO INSTEAD NOTHING; )DROP RULE "_UPDATE" ON api.journalentry; apiadminfalse8628628629635"261888141_UPDATERULE%CREATE RULE "_UPDATE" AS ON UPDATE TO location DO INSTEAD UPDATE public.location SET location_name = new.location, location_descrip = new.description, location_restrict = new.restricted, location_netable = new.netable, location_usable = new.usable, location_whsezone_id = public.getwhsezoneid((new.site)::text, new.zone), location_aisle = new.aisle, location_rack = new.rack, location_bin = new.bin WHERE ((location.location_warehous_id = public.getwarehousid((old.site)::text, 'ACTIVE'::text)) AND (location.location_name = (old.location)::text)); %DROP RULE "_UPDATE" ON api.location; apiadminfalse863266863266863168916888638638638638638638638638639635"261888148_UPDATERULEGCREATE RULE "_UPDATE" AS ON UPDATE TO misccounttag DO INSTEAD NOTHING; )DROP RULE "_UPDATE" ON api.misccounttag; apiadminfalse8648648649635"261888156_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO pricingschedule DO INSTEAD UPDATE public.ipshead SET ipshead_descrip = new.description, ipshead_effective = CASE WHEN (new.effective = 'Always'::text) THEN '1970-01-01'::date ELSE (new.effective)::date END, ipshead_expires = CASE WHEN (new.expires = 'Never'::text) THEN '2100-01-01'::date ELSE (new.expires)::date END, ipshead_updated = now(), ipshead_curr_id = CASE WHEN (SELECT (count(ipsiteminfo.ipsitem_id) = 0) FROM public.ipsiteminfo WHERE (ipsiteminfo.ipsitem_ipshead_id = public.getipsheadid((old.name)::text))) THEN COALESCE(public.getcurrid((new.currency)::text), public.basecurrid()) ELSE public.getcurrid((old.currency)::text) END WHERE (ipshead.ipshead_name = (old.name)::text); ,DROP RULE "_UPDATE" ON api.pricingschedule; apiadminfalse8652698652471620108715902698658658658658659635"261888165_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO pricingscheduleassign DO INSTEAD UPDATE public.ipsass SET ipsass_ipshead_id = public.getipsheadid((new.pricing_schedule)::text), ipsass_cust_id = CASE WHEN ((new.customer_number)::text = 'Any'::text) THEN (-1) ELSE public.getcustid((new.customer_number)::text) END, ipsass_custtype_id = CASE WHEN ((new.customer_type)::text = 'N/A'::text) THEN (-1) ELSE public.getcusttypeid((new.customer_type)::text) END, ipsass_custtype_pattern = new.customer_type_pattern, ipsass_shipto_id = CASE WHEN (((new.customer_number)::text = 'Any'::text) OR ((new.customer_shipto)::text = 'Any'::text)) THEN (-1) ELSE public.getshiptoid((new.customer_number)::text, (new.customer_shipto)::text) END, ipsass_shipto_pattern = new.customer_shipto_pattern WHERE ((((((ipsass.ipsass_ipshead_id = public.getipsheadid((old.pricing_schedule)::text)) AND (ipsass.ipsass_cust_id = CASE WHEN ((old.customer_number)::text = 'Any'::text) THEN (-1) ELSE public.getcustid((old.customer_number)::text) END)) AND (ipsass.ipsass_custtype_id = CASE WHEN ((old.customer_type)::text = 'N/A'::text) THEN (-1) ELSE public.getcusttypeid((old.customer_type)::text) END)) AND (ipsass.ipsass_custtype_pattern = (old.customer_type_pattern)::text)) AND (ipsass.ipsass_shipto_id = CASE WHEN ((old.customer_shipto)::text = 'Any'::text) THEN (-1) ELSE public.getshiptoid((old.customer_number)::text, (old.customer_shipto)::text) END)) AND (ipsass.ipsass_shipto_pattern = (old.customer_shipto_pattern)::text)); 2DROP RULE "_UPDATE" ON api.pricingscheduleassign; apiadminfalse86616201592866159426826826816672688662688668662688668668669635"261888175_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO pricingscheduleitem DO INSTEAD SELECT CASE WHEN ((old.type)::text = 'Item'::text) THEN public.saveipsitem(public.getipsitemid((old.pricing_schedule)::text, (old.item_number)::text, old.qty_break, (old.qty_uom)::text, (old.price_uom)::text), public.getipsheadid((new.pricing_schedule)::text), public.getitemid((new.item_number)::text), new.qty_break, new.price, public.getuomid((new.qty_uom)::text), public.getuomid((new.price_uom)::text), new.percent, new.fixedamt, CASE new.pricing_type WHEN 'Nominal'::text THEN 'N'::text WHEN 'Discount'::text THEN 'D'::text WHEN 'Markup'::text THEN 'M'::text ELSE '?'::text END) WHEN ((old.type)::text = 'Product Category'::text) THEN public.saveipsprodcat(public.getipsprodcatid((old.pricing_schedule)::text, (old.product_category)::text, old.qty_break), public.getipsheadid((new.pricing_schedule)::text), public.getprodcatid((new.product_category)::text), new.qty_break, new.percent, new.fixedamt, CASE new.pricing_type WHEN 'Nominal'::text THEN 'N'::text WHEN 'Discount'::text THEN 'D'::text WHEN 'Markup'::text THEN 'M'::text ELSE '?'::text END) ELSE NULL::integer END AS result; 0DROP RULE "_UPDATE" ON api.pricingscheduleitem; apiadminfalse867867867867867162116208672040867867162320398671622168316488678678678679635"261888184_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO pricingscheduleitemchar DO INSTEAD UPDATE public.ipsitemchar SET ipsitemchar_price = new.price WHERE (((ipsitemchar.ipsitemchar_ipsitem_id = public.getipsitemid((old.pricing_schedule)::text, (old.item_number)::text, old.qty_break, (old.qty_uom)::text, (old.price_uom)::text)) AND (ipsitemchar.ipsitemchar_char_id = public.getcharid((old.characteristic)::text, 'I'::text))) AND (ipsitemchar.ipsitemchar_value = (old.value)::text)); 4DROP RULE "_UPDATE" ON api.pricingscheduleitemchar; apiadminfalse868868157686886816218682708682702708688688688689635"261888192_UPDATERULEGCREATE RULE "_UPDATE" AS ON UPDATE TO project DO INSTEAD UPDATE public.prj SET prj_name = new.name, prj_descrip = new.description, prj_owner_username = new.owner, prj_username = new.assigned_to, prj_so = new.sales_orders, prj_wo = new.work_orders, prj_po = new.purchase_orders, prj_status = CASE WHEN (new.status = 'In-Process'::text) THEN 'O'::text WHEN (new.status = 'Completed'::text) THEN 'C'::text ELSE 'P'::text END, prj_due_date = new.due, prj_assigned_date = new.assigned, prj_start_date = new.started, prj_completed_date = new.completed WHERE (prj.prj_number = old.number); $DROP RULE "_UPDATE" ON api.project; apiadminfalse8698698698698698698698698692068698698698698698699635"261888199_UPDATERULEICREATE RULE "_UPDATE" AS ON UPDATE TO projectcomment DO INSTEAD NOTHING; +DROP RULE "_UPDATE" ON api.projectcomment; apiadminfalse8708708709635"261888208_UPDATERULE@CREATE RULE "_UPDATE" AS ON UPDATE TO prospect DO INSTEAD UPDATE public.prospect SET prospect_number = upper((new.prospect_number)::text), prospect_name = new.prospect_name, prospect_active = new.active, prospect_cntct_id = public.getcntctid(new.contact_number), prospect_taxzone_id = public.gettaxzoneid(new.default_tax_zone), prospect_salesrep_id = public.getsalesrepid(new.sales_rep), prospect_warehous_id = public.getwarehousid(new.site_code, 'ACTIVE'::text), prospect_comments = new.notes WHERE (prospect.prospect_id = public.getprospectid((old.prospect_number)::text)); %DROP RULE "_UPDATE" ON api.prospect; apiadminfalse871871871871272871164916801688158116608718718718718719635"261888219_UPDATERULEPCREATE RULE "_UPDATE" AS ON UPDATE TO purchaseline DO INSTEAD UPDATE public.poitem SET poitem_duedate = new.due_date, poitem_qty_ordered = new.qty_ordered, poitem_unitprice = new.unit_price, poitem_vend_item_number = new.vend_item_number, poitem_vend_item_descrip = new.vendor_description, poitem_manuf_name = new.manufacturer_name, poitem_manuf_item_number = new.manufacturer_item_number, poitem_manuf_item_descrip = new.manufacturer_description, poitem_comments = new.notes, poitem_freight = new.freight, poitem_prj_id = public.getprjid(new.project_number), poitem_bom_rev_id = public.getrevid('BOM'::text, old.item_number, new.bill_of_materials_revision), poitem_boo_rev_id = public.getrevid('BOO'::text, old.item_number, new.bill_of_operations_revision) WHERE (poitem.poitem_id = public.getpoitemid((old.order_number)::text, old.line_number)); )DROP RULE "_UPDATE" ON api.purchaseline; apiadminfalse8728728728728728728728728728728728728721644872872872872872181164616539635#261888229_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO purchaselinechar DO INSTEAD SELECT DISTINCT public.updatecharassignment('PI'::text, poitem.poitem_id, charass.charass_char_id, new.value) AS updatecharassignment FROM public.pohead, public.poitem, public.itemsite, public.item, public.charass, public."char" WHERE (((((((((pohead.pohead_number = (old.order_number)::text) AND (pohead.pohead_id = poitem.poitem_pohead_id)) AND (poitem.poitem_linenumber = old.line_number)) AND (poitem.poitem_itemsite_id = itemsite.itemsite_id)) AND (item.item_id = itemsite.itemsite_item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND ("char".char_id = charass.charass_char_id)) AND ("char".char_name = old.characteristic)); -DROP RULE "_UPDATE" ON api.purchaselinechar; apiadminfalse87387387318118018017517521471748738732152141811811812152148732159635#261888239_UPDATERULENCREATE RULE "_UPDATE" AS ON UPDATE TO purchaselinecomment DO INSTEAD NOTHING; 0DROP RULE "_UPDATE" ON api.purchaselinecomment; apiadminfalse8748748749635 #261888248_UPDATERULE CREATE RULE "_UPDATE" AS ON UPDATE TO purchaseorder DO INSTEAD UPDATE public.pohead SET pohead_terms_id = public.gettermsid(new.terms), pohead_taxzone_id = public.gettaxzoneid(new.tax_zone), pohead_warehous_id = public.getwarehousid(new.receiving_site, 'ALL'::text), pohead_agent_username = new.purchasing_agent, pohead_vendaddr_id = CASE WHEN (new.alt_address = 'MAIN'::text) THEN NULL::integer ELSE public.getvendaddrid(old.vendor_number, new.alt_address) END, pohead_fob = new.fob, pohead_shipvia = new.ship_via, pohead_curr_id = public.getcurrid((new.currency)::text), pohead_freight = new.freight, pohead_comments = new.notes, pohead_dropship = new.dropship, pohead_vend_cntct_id = public.getcntctid(new.vend_contact_number), pohead_vend_cntct_honorific = new.vend_cntct_honorific, pohead_vend_cntct_first_name = new.vend_cntct_first_name, pohead_vend_cntct_middle = new.vend_cntct_middle, pohead_vend_cntct_last_name = new.vend_cntct_last_name, pohead_vend_cntct_suffix = new.vend_cntct_suffix, pohead_vend_cntct_phone = new.vend_cntct_phone, pohead_vend_cntct_title = new.vend_cntct_title, pohead_vend_cntct_fax = new.vend_cntct_fax, pohead_vend_cntct_email = new.vend_cntct_email, pohead_vendaddress1 = new.vendaddress1, pohead_vendaddress2 = new.vendaddress2, pohead_vendaddress3 = new.vendaddress3, pohead_vendcity = new.vendcity, pohead_vendstate = new.vendstate, pohead_vendzipcode = new.vendzipcode, pohead_vendcountry = new.vendcountry, pohead_shipto_cntct_id = public.getcntctid(new.shipto_contact_number), pohead_shipto_cntct_honorific = new.shipto_cntct_honorific, pohead_shipto_cntct_first_name = new.shipto_cntct_first_name, pohead_shipto_cntct_middle = new.shipto_cntct_middle, pohead_shipto_cntct_last_name = new.shipto_cntct_last_name, pohead_shipto_cntct_suffix = new.shipto_cntct_suffix, pohead_shipto_cntct_phone = new.shipto_cntct_phone, pohead_shipto_cntct_title = new.shipto_cntct_title, pohead_shipto_cntct_fax = new.shipto_cntct_fax, pohead_shipto_cntct_email = new.shipto_cntct_email, pohead_shiptoaddress_id = public.getaddrid(new.shiptoaddress_number), pohead_shiptoaddress1 = new.shiptoaddress1, pohead_shiptoaddress2 = new.shiptoaddress2, pohead_shiptoaddress3 = new.shiptoaddress3, pohead_shiptocity = new.shiptocity, pohead_shiptostate = new.shiptostate, pohead_shiptozipcode = new.shiptozipcode, pohead_shiptocountry = new.shiptocountry, pohead_cohead_id = public.getcoheadid(new.sales_order_number) WHERE (pohead.pohead_number = (old.order_number)::text); *DROP RULE "_UPDATE" ON api.purchaseorder; apiadminfalse875875875875875875875875875875875875875875875875875875875875875875875875875875875875875875875875875875875875875180875875158316881581156815901675168116808758758758758758758758758758758758759635#261888256_UPDATERULEOCREATE RULE "_UPDATE" AS ON UPDATE TO purchaseordercomment DO INSTEAD NOTHING; 1DROP RULE "_UPDATE" ON api.purchaseordercomment; apiadminfalse8768768769635#261888265_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO quote DO INSTEAD UPDATE public.quhead SET quhead_number = old.quote_number, quhead_cust_id = public.getcustid(new.customer_number, true), quhead_custponumber = new.cust_po_number, quhead_quotedate = new.quote_date, quhead_warehous_id = public.getwarehousid(new.site, 'SHIPPING'::text), quhead_shipto_id = public.getshiptoid(new.customer_number, new.shipto_number), quhead_shiptoname = new.shipto_name, quhead_shiptoaddress1 = new.shipto_address1, quhead_shiptoaddress2 = new.shipto_address2, quhead_shiptoaddress3 = new.shipto_address3, quhead_salesrep_id = public.getsalesrepid(new.sales_rep), quhead_terms_id = public.gettermsid(new.terms), quhead_fob = new.fob, quhead_shipvia = new.ship_via, quhead_shiptocity = new.shipto_city, quhead_shiptostate = new.shipto_state, quhead_shiptozipcode = new.shipto_postal_code, quhead_freight = new.freight, quhead_misc = new.misc_charge, quhead_ordercomments = new.order_notes, quhead_shipcomments = new.shipping_notes, quhead_shiptophone = new.shipto_phone, quhead_billtoname = new.billto_name, quhead_billtoaddress1 = new.billto_address1, quhead_billtoaddress2 = new.billto_address2, quhead_billtoaddress3 = new.billto_address3, quhead_billtocity = new.billto_city, quhead_billtostate = new.billto_state, quhead_billtozip = new.billto_postal_code, quhead_misc_accnt_id = public.getglaccntid(new.misc_account_number), quhead_misc_descrip = new.misc_charge_description, quhead_commission = new.commission, quhead_packdate = new.pack_date, quhead_prj_id = public.getprjid(new.project_number), quhead_billtocountry = new.billto_country, quhead_shiptocountry = new.shipto_country, quhead_curr_id = public.getcurrid((new.currency)::text), quhead_taxzone_id = public.gettaxzoneid(new.tax_zone), quhead_taxtype_id = public.gettaxtypeid(new.tax_type), quhead_expire = new.expire_date, quhead_saletype_id = public.getsaletypeid(new.sale_type), quhead_shipzone_id = public.getshipzoneid(new.shipto_shipzone) WHERE (quhead.quhead_number = (old.quote_number)::text); "DROP RULE "_UPDATE" ON api.quote; apiadminfalse8771670166716611660164616091593159087787787787787787727787716811688168016798778778778778778778778778778778778778778778778778778778778778778778778778778778778778778778778778778778778779635#261888273_UPDATERULEGCREATE RULE "_UPDATE" AS ON UPDATE TO quotecomment DO INSTEAD NOTHING; )DROP RULE "_UPDATE" ON api.quotecomment; apiadminfalse8788788789635#261888282_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO quoteline DO INSTEAD UPDATE public.quitem SET quitem_scheddate = new.scheduled_date, quitem_qtyord = new.qty_ordered, quitem_qty_uom_id = public.getuomid(new.qty_uom), quitem_qty_invuomratio = public.itemuomtouomratio(item.item_id, COALESCE(public.getuomid(new.qty_uom), item.item_inv_uom_id), item.item_inv_uom_id), quitem_price = new.net_unit_price, quitem_price_uom_id = public.getuomid(new.price_uom), quitem_price_invuomratio = public.itemuomtouomratio(item.item_id, COALESCE(public.getuomid(new.price_uom), item.item_inv_uom_id), item.item_inv_uom_id), quitem_memo = new.notes, quitem_createorder = new.create_order, quitem_order_warehous_id = public.getwarehousid(new.supplying_site, 'SHIPPING'::text), quitem_prcost = new.overwrite_po_price, quitem_taxtype_id = public.gettaxtypeid(new.tax_type) FROM public.item WHERE ((quitem.quitem_quhead_id = public.getquoteid(old.quote_number)) AND (quitem.quitem_linenumber = old.line_number)); &DROP RULE "_UPDATE" ON api.quoteline; apiadminfalse879179416881683167916508791748792781748798798792788798798798798798798798799635#261888292_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO quotelinechar DO INSTEAD SELECT DISTINCT public.updatecharassignment('QI'::text, quitem.quitem_id, charass.charass_char_id, new.value) AS updatecharassignment FROM public.quhead, public.quitem, public.itemsite, public.item, public.charass, public."char" WHERE (((((((((quhead.quhead_number = old.quote_number) AND (quhead.quhead_id = quitem.quitem_quhead_id)) AND (quitem.quitem_linenumber = old.line_number)) AND (quitem.quitem_itemsite_id = itemsite.itemsite_id)) AND (item.item_id = itemsite.itemsite_item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND ("char".char_id = charass.charass_char_id)) AND ("char".char_name = old.characteristic)); *DROP RULE "_UPDATE" ON api.quotelinechar; apiadminfalse88088017521471742782152152148802141752158808802772778802782782789635##261888301_UPDATERULEKCREATE RULE "_UPDATE" AS ON UPDATE TO quotelinecomment DO INSTEAD NOTHING; -DROP RULE "_UPDATE" ON api.quotelinecomment; apiadminfalse8818818819635)#261888316_UPDATERULEGCREATE RULE "_UPDATE" AS ON UPDATE TO saleshistory DO INSTEAD NOTHING; )DROP RULE "_UPDATE" ON api.saleshistory; apiadminfalse8838838839635-#261888327_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO saleslinechar DO INSTEAD SELECT DISTINCT public.updatecharassignment('SI'::text, coitem.coitem_id, charass.charass_char_id, new.value, public.itemcharprice(item.item_id, "char".char_id, new.value, cohead.cohead_cust_id, cohead.cohead_shipto_id, coitem.coitem_qtyord, cohead.cohead_curr_id, cohead.cohead_orderdate)) AS updatecharassignment FROM public.cohead, public.coitem, public.itemsite, public.item, public.charass, public."char" WHERE (((((((((cohead.cohead_number = (old.order_number)::text) AND (cohead.cohead_id = coitem.coitem_cohead_id)) AND (coitem.coitem_id = public.getcoitemid((old.order_number)::text, old.line_number))) AND (coitem.coitem_itemsite_id = itemsite.itemsite_id)) AND (item.item_id = itemsite.itemsite_item_id)) AND (charass.charass_target_type = 'I'::text)) AND (charass.charass_target_id = item.item_id)) AND ("char".char_id = charass.charass_char_id)) AND ("char".char_name = old.characteristic)); *DROP RULE "_UPDATE" ON api.saleslinechar; apiadminfalse88421517917888417817817681584175214817517488488417917917817817821521421417921588488496351#261888336_UPDATERULEKCREATE RULE "_UPDATE" AS ON UPDATE TO saleslinecomment DO INSTEAD NOTHING; -DROP RULE "_UPDATE" ON api.saleslinecomment; apiadminfalse88588588596355#261888345_UPDATERULERCREATE RULE "_UPDATE" AS ON UPDATE TO salesorder DO INSTEAD UPDATE public.cohead SET cohead_number = old.order_number, cohead_cust_id = public.getcustid(new.customer_number), cohead_custponumber = new.cust_po_number, cohead_orderdate = new.order_date, cohead_warehous_id = public.getwarehousid(new.site, 'SHIPPING'::text), cohead_shipto_id = public.getshiptoid(new.customer_number, new.shipto_number), cohead_shiptoname = new.shipto_name, cohead_shiptoaddress1 = new.shipto_address1, cohead_shiptoaddress2 = new.shipto_address2, cohead_shiptoaddress3 = new.shipto_address3, cohead_salesrep_id = public.getsalesrepid(new.sales_rep), cohead_terms_id = public.gettermsid(new.terms), cohead_fob = new.fob, cohead_shipvia = new.ship_via, cohead_shiptocity = new.shipto_city, cohead_shiptostate = new.shipto_state, cohead_shiptozipcode = new.shipto_postal_code, cohead_freight = CASE WHEN new.calculate_freight THEN COALESCE((SELECT sum(freightdetail.freightdata_total) AS sum FROM public.freightdetail('SO'::text, public.getcoheadid((old.order_number)::text), public.getcustid(new.customer_number), public.getshiptoid(new.customer_number, new.shipto_number), new.order_date, new.ship_via, public.getcurrid((new.currency)::text)) freightdetail(freightdata_schedule, freightdata_from, freightdata_to, freightdata_shipvia, freightdata_freightclass, freightdata_weight, freightdata_uom, freightdata_price, freightdata_type, freightdata_total, freightdata_currency)), (0)::numeric) ELSE new.freight END, cohead_calcfreight = new.calculate_freight, cohead_misc = new.misc_charge, cohead_ordercomments = new.order_notes, cohead_shipcomments = new.shipping_notes, cohead_shiptophone = new.shipto_phone, cohead_shipchrg_id = public.getshipchrgid(new.shipping_chgs), cohead_shipform_id = public.getshipformid(new.shipping_form), cohead_billtoname = new.billto_name, cohead_billtoaddress1 = new.billto_address1, cohead_billtoaddress2 = new.billto_address2, cohead_billtoaddress3 = new.billto_address3, cohead_billtocity = new.billto_city, cohead_billtostate = new.billto_state, cohead_billtozipcode = new.billto_postal_code, cohead_misc_accnt_id = public.getglaccntid(new.misc_account_number), cohead_misc_descrip = new.misc_charge_description, cohead_commission = new.commission, cohead_holdtype = CASE WHEN (new.hold_type = 'Credit'::text) THEN 'C'::text WHEN (new.hold_type = 'Shipping'::text) THEN 'S'::text WHEN (new.hold_type = 'Packing'::text) THEN 'P'::text ELSE 'N'::text END, cohead_packdate = new.pack_date, cohead_prj_id = public.getprjid(new.project_number), cohead_shipcomplete = new.ship_complete, cohead_billtocountry = new.billto_country, cohead_shiptocountry = new.shipto_country, cohead_curr_id = public.getcurrid((new.currency)::text), cohead_taxzone_id = public.gettaxzoneid(new.tax_zone), cohead_lastupdated = ('now'::text)::timestamp(6) with time zone, cohead_shipto_cntct_id = public.getcntctid(new.shipto_contact_number), cohead_shipto_cntct_honorific = new.shipto_contact_honorific, cohead_shipto_cntct_first_name = new.shipto_contact_first, cohead_shipto_cntct_middle = new.shipto_contact_middle, cohead_shipto_cntct_last_name = new.shipto_contact_last, cohead_shipto_cntct_suffix = new.shipto_contact_suffix, cohead_shipto_cntct_phone = new.shipto_contact_phone, cohead_shipto_cntct_title = new.shipto_contact_title, cohead_shipto_cntct_fax = new.shipto_contact_fax, cohead_shipto_cntct_email = new.shipto_contact_email, cohead_billto_cntct_id = public.getcntctid(new.billto_contact_number), cohead_billto_cntct_honorific = new.billto_contact_name, cohead_billto_cntct_first_name = new.billto_contact_first, cohead_billto_cntct_middle = new.billto_contact_middle, cohead_billto_cntct_last_name = new.billto_contact_last, cohead_billto_cntct_suffix = new.billto_contact_suffix, cohead_billto_cntct_phone = new.billto_contact_phone, cohead_billto_cntct_title = new.billto_contact_title, cohead_billto_cntct_fax = new.billto_contct_fax, cohead_billto_cntct_email = new.billto_contact_email, cohead_saletype_id = public.getsaletypeid(new.sale_type), cohead_shipzone_id = public.getshipzoneid(new.shipto_shipzone) WHERE (cohead.cohead_number = (old.order_number)::text); 'DROP RULE "_UPDATE" ON api.salesorder; apiadminfalse886886886886886886886178166315641688886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886886168116091680158115928861590158316701646166116601667166496359#261888355_UPDATERULELCREATE RULE "_UPDATE" AS ON UPDATE TO salesordercomment DO INSTEAD NOTHING; .DROP RULE "_UPDATE" ON api.salesordercomment; apiadminfalse8878878879635=#261888363_UPDATERULEICREATE RULE "_UPDATE" AS ON UPDATE TO salesrep DO INSTEAD UPDATE public.salesrep SET salesrep_active = new.active, salesrep_number = new.number, salesrep_name = new.name, salesrep_commission = (new.commission_percent * 0.01), salesrep_emp_id = public.getempid(new.employee) WHERE (salesrep.salesrep_number = (old.number)::text); %DROP RULE "_UPDATE" ON api.salesrep; apiadminfalse88888888888888888819916008889635A#261888372_UPDATERULE CREATE RULE "_UPDATE" AS ON UPDATE TO site DO INSTEAD UPDATE public.whsinfo SET warehous_descrip = new.description, warehous_fob = CASE WHEN new.inventory_type THEN new.default_fob ELSE NULL::text END, warehous_active = new.active, warehous_counttag_prefix = CASE WHEN new.inventory_type THEN new.next_count_tag_prefix ELSE NULL::text END, warehous_counttag_number = CASE WHEN new.inventory_type THEN new.next_count_tag_number ELSE NULL::integer END, warehous_bol_prefix = CASE WHEN new.inventory_type THEN new.next_bill_of_lading_prefix ELSE NULL::text END, warehous_bol_number = CASE WHEN new.inventory_type THEN new.next_bill_of_lading_number ELSE NULL::integer END, warehous_shipping = CASE WHEN new.inventory_type THEN new.shipping_site ELSE NULL::boolean END, warehous_useslips = CASE WHEN new.inventory_type THEN new.force_the_use_of_count_slips ELSE NULL::boolean END, warehous_usezones = CASE WHEN new.inventory_type THEN new.force_the_use_of_zones ELSE NULL::boolean END, warehous_aislesize = CASE WHEN new.inventory_type THEN new.aisle_size ELSE NULL::integer END, warehous_aislealpha = CASE WHEN new.inventory_type THEN new.aisle_allow_alpha_characters ELSE NULL::boolean END, warehous_racksize = CASE WHEN new.inventory_type THEN new.rack_size ELSE NULL::integer END, warehous_rackalpha = CASE WHEN new.inventory_type THEN new.rack_allow_alpha_characters ELSE NULL::boolean END, warehous_binsize = CASE WHEN new.inventory_type THEN new.bin_size ELSE NULL::integer END, warehous_binalpha = CASE WHEN new.inventory_type THEN new.bin_allow_alpha_characters ELSE NULL::boolean END, warehous_locationsize = CASE WHEN new.inventory_type THEN new.location_size ELSE NULL::integer END, warehous_locationalpha = CASE WHEN new.inventory_type THEN new.location_allow_alpha_characters ELSE NULL::boolean END, warehous_enforcearbl = CASE WHEN new.inventory_type THEN new.enforce_arbl_naming_convention ELSE NULL::boolean END, warehous_default_accnt_id = public.getglaccntid(new.post_unassigned_transactions_to), warehous_shipping_commission = CASE WHEN new.inventory_type THEN (new.shipping_commission * 0.01) ELSE NULL::numeric END, warehous_cntct_id = public.savecntct(public.getcntctid(new.contact_number), new.contact_number, NULL::integer, new.honorific, new.first, new.middle, new.last, new.suffix, new.phone, NULL::text, new.fax, new.email, NULL::text, new.job_title, new.contact_change), warehous_addr_id = public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postal_code, new.country, new.address_change), warehous_taxzone_id = CASE WHEN new.inventory_type THEN public.gettaxzoneid(new.tax_zone) ELSE NULL::integer END, warehous_transit = CASE WHEN new.inventory_type THEN false WHEN new.transit_type THEN true ELSE NULL::boolean END, warehous_shipform_id = CASE WHEN new.transit_type THEN public.getshipformid(new.default_shipping_form) ELSE NULL::integer END, warehous_shipvia_id = CASE WHEN new.transit_type THEN public.getshipviaid(new.default_ship_via) ELSE NULL::integer END, warehous_shipcomments = CASE WHEN new.transit_type THEN new.shipping_comments ELSE NULL::text END, warehous_costcat_id = CASE WHEN new.transit_type THEN public.getcostcatid(new.default_cost_category) ELSE NULL::integer END, warehous_sitetype_id = public.getsitetypeid(new.type), warehous_sequence = new.scheduling_sequence WHERE (whsinfo.warehous_id = public.getwarehousid((old.code)::text, 'ALL'::text)); !DROP RULE "_UPDATE" ON api.site; apiadminfalse889889167188988988988915861581889156888988988917688916098898892034889202916641688166916808898898898898898898898898898898898898898898898898898898898898898898898898898898898898898898898898898898898898898898899635E#261888381_UPDATERULE CREATE RULE "_UPDATE" AS ON UPDATE TO sitezone DO INSTEAD UPDATE public.whsezone SET whsezone_descrip = new.description WHERE ((whsezone.whsezone_warehous_id = public.getwarehousid((old.site)::text, 'ACTIVE'::text)) AND (whsezone.whsezone_name = (old.name)::text)); %DROP RULE "_UPDATE" ON api.sitezone; apiadminfalse89089089026726716888908909635I#261888390_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO task DO INSTEAD UPDATE public.prjtask SET prjtask_name = new.name, prjtask_descrip = new.description, prjtask_owner_username = new.owner, prjtask_username = new.assigned_to, prjtask_hours_budget = new.hours_budgeted, prjtask_hours_actual = new.hours_actual, prjtask_exp_budget = new.expenses_budgeted, prjtask_exp_actual = new.expenses_actual, prjtask_status = CASE WHEN (new.status = 'In-Process'::text) THEN 'O'::text WHEN (new.status = 'Completed'::text) THEN 'C'::text ELSE 'P'::text END, prjtask_due_date = new.due, prjtask_assigned_date = new.assigned, prjtask_start_date = new.started, prjtask_completed_date = new.completed WHERE ((prjtask.prjtask_prj_id = public.getprjid(old.project_number)) AND (prjtask.prjtask_number = old.number)); !DROP RULE "_UPDATE" ON api.task; apiadminfalse89189189116462118912118918918918918918918918918918918918918919635M#261888398_UPDATERULEFCREATE RULE "_UPDATE" AS ON UPDATE TO taskcomment DO INSTEAD NOTHING; (DROP RULE "_UPDATE" ON api.taskcomment; apiadminfalse8928928929635Q#261888407_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO todo DO INSTEAD SELECT public.updatetodoitem(old.task_number, old.assigned_to, new.task_name, new.description, public.getincidentid(new.incident), COALESCE(public.getincdtcrmacctid(new.incident), public.getcrmacctid(new.account)), public.getopheadid(new.opportunity), CASE WHEN (new.date_started > ''::text) THEN (new.date_started)::date ELSE NULL::date END, CASE WHEN (new.date_due > ''::text) THEN (new.date_due)::date ELSE NULL::date END, (CASE WHEN (new.status = 'Pending Input'::text) THEN 'P'::text WHEN (new.status = 'Deferred'::text) THEN 'D'::text WHEN (new.status = 'Neither'::text) THEN 'N'::text ELSE NULL::text END)::bpchar, CASE WHEN (new.date_assigned > ''::text) THEN (new.date_assigned)::date ELSE NULL::date END, CASE WHEN (new.date_completed > ''::text) THEN (new.date_completed)::date ELSE NULL::date END, public.getincdtpriorityid(new.priority), new.notes, new.active, new.owner) AS updatetodoitem; !DROP RULE "_UPDATE" ON api.todo; apiadminfalse8931613158989389389316171614893217116348938938938938938938938938938938938938939635U#261888417_UPDATERULE CREATE RULE "_UPDATE" AS ON UPDATE TO vendor DO INSTEAD UPDATE public.vendinfo SET vend_name = new.vendor_name, vend_active = new.active, vend_po = new.sells_purchase_order_items, vend_comments = new.notes, vend_pocomments = new.po_comments, vend_1099 = new.receives_1099, vend_fobsource = CASE WHEN (new.default_fob IS NULL) THEN NULL::text WHEN (new.default_fob = 'Receiving Site'::text) THEN 'W'::text ELSE 'V'::text END, vend_fob = CASE WHEN (new.default_fob IS NULL) THEN NULL::text WHEN (new.default_fob = 'Receiving Site'::text) THEN ''::text ELSE new.default_fob END, vend_terms_id = public.gettermsid(new.default_terms), vend_shipvia = new.ship_via, vend_vendtype_id = public.getvendtypeid(new.vendor_type), vend_qualified = new.qualified, vend_ediemail = new.po_edi_email, vend_ediemailbody = new.po_edi_emailbody, vend_edisubject = new.po_edi_subject, vend_edifilename = new.po_edi_filename, vend_accntnum = new.account_number, vend_emailpodelivery = new.allow_email_po_delivery, vend_restrictpurch = new.may_only_sell_item_source, vend_edicc = new.po_edi_cc, vend_curr_id = public.getcurrid((new.default_currency)::text), vend_cntct1_id = public.savecntct(public.getcntctid(new.contact1_number), new.contact1_number, NULL::integer, new.contact1_honorific, new.contact1_first, new.contact1_middle, new.contact1_last, new.contact1_suffix, new.contact1_voice, new.contact1_alternate, new.contact1_fax, new.contact1_email, new.contact1_web, new.contact1_job_title, new.contact1_change), vend_cntct2_id = public.savecntct(public.getcntctid(new.contact2_number), new.contact2_number, NULL::integer, new.contact2_honorific, new.contact2_first, new.contact2_middle, new.contact2_last, new.contact2_suffix, new.contact2_voice, new.contact2_alternate, new.contact2_fax, new.contact2_email, new.contact2_web, new.contact2_job_title, new.contact2_change), vend_addr_id = public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change), vend_match = new.matching_vo_po_amounts, vend_taxzone_id = public.gettaxzoneid(new.default_tax_zone), vend_accnt_id = COALESCE(public.getglaccntid(NULLIF(new.default_dist_gl_account, 'N/A'::text)), (-1)), vend_expcat_id = COALESCE(public.getexpcatid(NULLIF(new.default_dist_expense_category, 'N/A'::text)), (-1)), vend_tax_id = COALESCE(public.gettaxid(NULLIF(new.default_dist_tax_code, 'N/A'::text)), (-1)) WHERE (vendinfo.vend_id = public.getvendid((old.vendor_number)::text)); #DROP RULE "_UPDATE" ON api.vendor; apiadminfalse8941681894894894894894894894894894894894894894894894168089416781687894168689489489489489489489489489489489489489489489489489419316098948948948948948948948948948948948948948941601894894894894894894203489489489415908948948942029894158115688949635Y#261888427_UPDATERULE_CREATE RULE "_UPDATE" AS ON UPDATE TO vendoraddress DO INSTEAD UPDATE public.vendaddrinfo SET vendaddr_vend_id = public.getvendid((new.vendor_number)::text), vendaddr_code = new.vendor_address_number, vendaddr_name = new.vendor_address_name, vendaddr_comments = new.notes, vendaddr_cntct_id = public.savecntct(public.getcntctid(new.contact_number), new.contact_number, public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change), new.contact_honorific, new.contact_first, new.contact_middle, new.contact_last, new.contact_suffix, new.contact_voice, new.contact_alternate, new.contact_fax, new.contact_email, new.contact_web, new.contact_job_title, new.contact_change), vendaddr_addr_id = public.saveaddr(public.getaddrid(new.address_number), new.address_number, new.address1, new.address2, new.address3, new.city, new.state, new.postalcode, new.country, new.address_change) WHERE (vendaddrinfo.vendaddr_id = public.getvendaddrid((old.vendor_number)::text, (old.vendor_address_number)::text)); *DROP RULE "_UPDATE" ON api.vendoraddress; apiadminfalse8958958958958958958958952768951568895203489515812029895168616758958958958958958958958958958958958958958958958959635]#261888435_UPDATERULECREATE RULE "_UPDATE" AS ON UPDATE TO vendortype DO INSTEAD UPDATE public.vendtype SET vendtype_code = new.code, vendtype_descrip = new.description WHERE (vendtype.vendtype_code = (old.code)::text); 'DROP RULE "_UPDATE" ON api.vendortype; apiadminfalse8962858968968969635!261884119_DELETERULE>CREATE RULE "_DELETE" AS ON DELETE TO url DO INSTEAD NOTHING; #DROP RULE "_DELETE" ON public.url; publicadminfalse2212212219635!261884120 _DELETE_FILERULECREATE RULE "_DELETE_FILE" AS ON DELETE TO url WHERE (old.url_stream IS NOT NULL) DO INSTEAD SELECT deletefile(old.url_id) AS deletefile; (DROP RULE "_DELETE_FILE" ON public.url; publicadminfalse22122122113372219635!261884121 _DELETE_URLRULECREATE RULE "_DELETE_URL" AS ON DELETE TO url WHERE (old.url_stream IS NULL) DO INSTEAD SELECT deleteurl(old.url_id) AS deleteurl; 'DROP RULE "_DELETE_URL" ON public.url; publicadminfalse22122122112872219635!261884122_INSERTRULE>CREATE RULE "_INSERT" AS ON INSERT TO url DO INSTEAD NOTHING; #DROP RULE "_INSERT" ON public.url; publicadminfalse2212212219635!261884123 _INSERT_FILERULECREATE RULE "_INSERT_FILE" AS ON INSERT TO url WHERE (new.url_stream IS NOT NULL) DO INSTEAD INSERT INTO docass (docass_id, docass_source_id, docass_source_type, docass_target_id, docass_target_type, docass_purpose) VALUES (COALESCE((new.url_id)::bigint, nextval('docass_docass_id_seq'::regclass)), new.url_source_id, new.url_source, createfile(new.url_title, new.url_url, new.url_stream), 'FILE'::text, 'S'::bpchar); (DROP RULE "_INSERT_FILE" ON public.url; publicadminfalse22122122122122122122121812612212212229635!261884124 _INSERT_URLRULECREATE RULE "_INSERT_URL" AS ON INSERT TO url WHERE (new.url_stream IS NULL) DO INSTEAD INSERT INTO docass (docass_id, docass_source_id, docass_source_type, docass_target_id, docass_target_type, docass_purpose) VALUES (COALESCE((new.url_id)::bigint, nextval('docass_docass_id_seq'::regclass)), new.url_source_id, new.url_source, createurl(new.url_title, new.url_url), 'URL'::text, 'S'::bpchar); 'DROP RULE "_INSERT_URL" ON public.url; publicadminfalse22122122122121812852212212212222219635!261884125_UPDATERULE>CREATE RULE "_UPDATE" AS ON UPDATE TO url DO INSTEAD NOTHING; #DROP RULE "_UPDATE" ON public.url; publicadminfalse2212212219635!261884126 _UPDATE_FILERULE9CREATE RULE "_UPDATE_FILE" AS ON UPDATE TO url WHERE (new.url_stream IS NOT NULL) DO INSTEAD UPDATE file SET file_title = new.url_title, file_stream = new.url_stream FROM docass WHERE (((docass.docass_id = old.url_id) AND (docass.docass_target_id = file.file_id)) AND (docass.docass_target_type = 'FILE'::text)); (DROP RULE "_UPDATE_FILE" ON public.url; publicadminfalse2212212182212212182192182212219635!261884127 _UPDATE_URLRULE0CREATE RULE "_UPDATE_URL" AS ON UPDATE TO url WHERE (new.url_stream IS NULL) DO INSTEAD UPDATE urlinfo SET url_title = new.url_title, url_url = new.url_url FROM docass WHERE (((docass.docass_id = old.url_id) AND (docass.docass_target_id = urlinfo.url_id)) AND (docass.docass_target_type = 'URL'::text)); 'DROP RULE "_UPDATE_URL" ON public.url; publicadminfalse2212212212182182212212182212209635 262084128pkgcmdaftertriggerTRIGGERCREATE TRIGGER pkgcmdaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdaftertrigger(); 6DROP TRIGGER pkgcmdaftertrigger ON fixcountry.pkgcmd;  fixcountryadminfalse23032889635 262084129pkgcmdaltertriggerTRIGGERCREATE TRIGGER pkgcmdaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdaltertrigger(); 6DROP TRIGGER pkgcmdaltertrigger ON fixcountry.pkgcmd;  fixcountryadminfalse23022889635 262084130pkgcmdargaftertriggerTRIGGERCREATE TRIGGER pkgcmdargaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargaftertrigger(); <DROP TRIGGER pkgcmdargaftertrigger ON fixcountry.pkgcmdarg;  fixcountryadminfalse23062919635 262084131pkgcmdargaltertriggerTRIGGERCREATE TRIGGER pkgcmdargaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargaltertrigger(); <DROP TRIGGER pkgcmdargaltertrigger ON fixcountry.pkgcmdarg;  fixcountryadminfalse23052919635 262084132pkgcmdargbeforetriggerTRIGGERCREATE TRIGGER pkgcmdargbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargbeforetrigger(); =DROP TRIGGER pkgcmdargbeforetrigger ON fixcountry.pkgcmdarg;  fixcountryadminfalse23042919635 262084133pkgcmdbeforetriggerTRIGGERCREATE TRIGGER pkgcmdbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdbeforetrigger(); 7DROP TRIGGER pkgcmdbeforetrigger ON fixcountry.pkgcmd;  fixcountryadminfalse23012889635 262084134pkgimageaftertriggerTRIGGERCREATE TRIGGER pkgimageaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimageaftertrigger(); :DROP TRIGGER pkgimageaftertrigger ON fixcountry.pkgimage;  fixcountryadminfalse23092939635 262084135pkgimagealtertriggerTRIGGERCREATE TRIGGER pkgimagealtertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimagealtertrigger(); :DROP TRIGGER pkgimagealtertrigger ON fixcountry.pkgimage;  fixcountryadminfalse23082939635 262084136pkgimagebeforetriggerTRIGGERCREATE TRIGGER pkgimagebeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimagebeforetrigger(); ;DROP TRIGGER pkgimagebeforetrigger ON fixcountry.pkgimage;  fixcountryadminfalse23072939635 262084137pkgmetasqlaftertriggerTRIGGERCREATE TRIGGER pkgmetasqlaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlaftertrigger(); >DROP TRIGGER pkgmetasqlaftertrigger ON fixcountry.pkgmetasql;  fixcountryadminfalse29623129635 262084138pkgmetasqlaltertriggerTRIGGERCREATE TRIGGER pkgmetasqlaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlaltertrigger(); >DROP TRIGGER pkgmetasqlaltertrigger ON fixcountry.pkgmetasql;  fixcountryadminfalse23112969635 262084139pkgmetasqlbeforetriggerTRIGGERCREATE TRIGGER pkgmetasqlbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlbeforetrigger(); ?DROP TRIGGER pkgmetasqlbeforetrigger ON fixcountry.pkgmetasql;  fixcountryadminfalse29623109635 262084140pkgprivaftertriggerTRIGGERCREATE TRIGGER pkgprivaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivaftertrigger(); 8DROP TRIGGER pkgprivaftertrigger ON fixcountry.pkgpriv;  fixcountryadminfalse23152999635 262084141pkgprivaltertriggerTRIGGERCREATE TRIGGER pkgprivaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivaltertrigger(); 8DROP TRIGGER pkgprivaltertrigger ON fixcountry.pkgpriv;  fixcountryadminfalse29923149635 262084142pkgprivbeforetriggerTRIGGERCREATE TRIGGER pkgprivbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivbeforetrigger(); 9DROP TRIGGER pkgprivbeforetrigger ON fixcountry.pkgpriv;  fixcountryadminfalse23132999635 262084143pkgreportaftertriggerTRIGGERCREATE TRIGGER pkgreportaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportaftertrigger(); <DROP TRIGGER pkgreportaftertrigger ON fixcountry.pkgreport;  fixcountryadminfalse20533029635 262084144pkgreportaltertriggerTRIGGERCREATE TRIGGER pkgreportaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportaltertrigger(); <DROP TRIGGER pkgreportaltertrigger ON fixcountry.pkgreport;  fixcountryadminfalse23173029635 262084145pkgreportbeforetriggerTRIGGERCREATE TRIGGER pkgreportbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportbeforetrigger(); =DROP TRIGGER pkgreportbeforetrigger ON fixcountry.pkgreport;  fixcountryadminfalse23163029635 262084146pkgscriptaftertriggerTRIGGERCREATE TRIGGER pkgscriptaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptaftertrigger(); <DROP TRIGGER pkgscriptaftertrigger ON fixcountry.pkgscript;  fixcountryadminfalse23193059635 262084147pkgscriptaltertriggerTRIGGERCREATE TRIGGER pkgscriptaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptaltertrigger(); <DROP TRIGGER pkgscriptaltertrigger ON fixcountry.pkgscript;  fixcountryadminfalse23183059635 262084148pkgscriptbeforetriggerTRIGGERCREATE TRIGGER pkgscriptbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptbeforetrigger(); =DROP TRIGGER pkgscriptbeforetrigger ON fixcountry.pkgscript;  fixcountryadminfalse20893059635 262084149pkguiformaftertriggerTRIGGERCREATE TRIGGER pkguiformaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformaftertrigger(); <DROP TRIGGER pkguiformaftertrigger ON fixcountry.pkguiform;  fixcountryadminfalse23223089635 262084150pkguiformaltertriggerTRIGGERCREATE TRIGGER pkguiformaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformaltertrigger(); <DROP TRIGGER pkguiformaltertrigger ON fixcountry.pkguiform;  fixcountryadminfalse23213089635 262084151pkguiformbeforetriggerTRIGGERCREATE TRIGGER pkguiformbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformbeforetrigger(); =DROP TRIGGER pkguiformbeforetrigger ON fixcountry.pkguiform;  fixcountryadminfalse23203089635 262087112accntdeletetriggerTRIGGERoCREATE TRIGGER accntdeletetrigger BEFORE DELETE ON accnt FOR EACH ROW EXECUTE PROCEDURE _accntdeletetrigger(); 1DROP TRIGGER accntdeletetrigger ON public.accnt; publicadminfalse22821979635 262087110 accnttriggerTRIGGERmCREATE TRIGGER accnttrigger BEFORE INSERT OR UPDATE ON accnt FOR EACH ROW EXECUTE PROCEDURE _accnttrigger(); +DROP TRIGGER accnttrigger ON public.accnt; publicadminfalse22821959635 262087111accntuniquetriggerTRIGGERoCREATE TRIGGER accntuniquetrigger BEFORE INSERT ON accnt FOR EACH ROW EXECUTE PROCEDURE _accntuniquetrigger(); 1DROP TRIGGER accntuniquetrigger ON public.accnt; publicadminfalse21962289635 262087115addrafterdeletetriggerTRIGGERuCREATE TRIGGER addrafterdeletetrigger AFTER DELETE ON addr FOR EACH ROW EXECUTE PROCEDURE _addrafterdeletetrigger(); 4DROP TRIGGER addrafterdeletetrigger ON public.addr; publicadminfalse21321999635 262087113 addrtriggerTRIGGERtCREATE TRIGGER addrtrigger BEFORE INSERT OR DELETE OR UPDATE ON addr FOR EACH ROW EXECUTE PROCEDURE _addrtrigger(); )DROP TRIGGER addrtrigger ON public.addr; publicadminfalse21321989635 262087116alarmbeforetriggerTRIGGERoCREATE TRIGGER alarmbeforetrigger BEFORE INSERT ON alarm FOR EACH ROW EXECUTE PROCEDURE _alarmbeforetrigger(); 1DROP TRIGGER alarmbeforetrigger ON public.alarm; publicadminfalse22003129635 262087117apapplytriggerTRIGGERsCREATE TRIGGER apapplytrigger BEFORE INSERT OR UPDATE ON apapply FOR EACH ROW EXECUTE PROCEDURE _apapplytrigger(); /DROP TRIGGER apapplytrigger ON public.apapply; publicadminfalse22013169635x 262087118 apopentriggerTRIGGERpCREATE TRIGGER apopentrigger BEFORE INSERT OR UPDATE ON apopen FOR EACH ROW EXECUTE PROCEDURE _apopentrigger(); -DROP TRIGGER apopentrigger ON public.apopen; publicadminfalse19022029635 262087119arapplytriggerTRIGGERsCREATE TRIGGER arapplytrigger BEFORE INSERT OR UPDATE ON arapply FOR EACH ROW EXECUTE PROCEDURE _arapplytrigger(); /DROP TRIGGER arapplytrigger ON public.arapply; publicadminfalse33122039635 262087122aropenaftertriggerTRIGGERyCREATE TRIGGER aropenaftertrigger AFTER INSERT OR UPDATE ON aropen FOR EACH ROW EXECUTE PROCEDURE _aropenaftertrigger(); 2DROP TRIGGER aropenaftertrigger ON public.aropen; publicadminfalse19522059635 262087121 aropentriggerTRIGGERpCREATE TRIGGER aropentrigger BEFORE INSERT OR UPDATE ON aropen FOR EACH ROW EXECUTE PROCEDURE _aropentrigger(); -DROP TRIGGER aropentrigger ON public.aropen; publicadminfalse22041959635 262087123bomheadtriggerTRIGGER|CREATE TRIGGER bomheadtrigger AFTER INSERT OR DELETE OR UPDATE ON bomhead FOR EACH ROW EXECUTE PROCEDURE _bomheadtrigger(); /DROP TRIGGER bomheadtrigger ON public.bomhead; publicadminfalse22062259635k 262087126bomitemaftertriggerTRIGGER|CREATE TRIGGER bomitemaftertrigger AFTER INSERT OR UPDATE ON bomitem FOR EACH ROW EXECUTE PROCEDURE _bomitemaftertrigger(); 4DROP TRIGGER bomitemaftertrigger ON public.bomitem; publicadminfalse18622089635l 262087127bomitembeforedeletetriggerTRIGGERCREATE TRIGGER bomitembeforedeletetrigger BEFORE DELETE ON bomitem FOR EACH ROW EXECUTE PROCEDURE _bomitembeforedeletetrigger(); ;DROP TRIGGER bomitembeforedeletetrigger ON public.bomitem; publicadminfalse18622099635j 262087125bomitembeforetriggerTRIGGERCREATE TRIGGER bomitembeforetrigger BEFORE INSERT OR UPDATE ON bomitem FOR EACH ROW EXECUTE PROCEDURE _bomitembeforetrigger(); 5DROP TRIGGER bomitembeforetrigger ON public.bomitem; publicadminfalse18622079635 262087128bomitemsubtriggerTRIGGERCREATE TRIGGER bomitemsubtrigger BEFORE INSERT OR DELETE OR UPDATE ON bomitemsub FOR EACH ROW EXECUTE PROCEDURE _bomitemsubtrigger(); 5DROP TRIGGER bomitemsubtrigger ON public.bomitemsub; publicadminfalse22622109635 262087131cashrcptitemaftertriggerTRIGGERCREATE TRIGGER cashrcptitemaftertrigger AFTER INSERT OR UPDATE ON cashrcptitem FOR EACH ROW EXECUTE PROCEDURE _cashrcptitemaftertrigger(); >DROP TRIGGER cashrcptitemaftertrigger ON public.cashrcptitem; publicadminfalse22132339635 262087130cashrcptitemtriggerTRIGGERCREATE TRIGGER cashrcptitemtrigger BEFORE INSERT OR UPDATE ON cashrcptitem FOR EACH ROW EXECUTE PROCEDURE _cashrcptitemtrigger(); 9DROP TRIGGER cashrcptitemtrigger ON public.cashrcptitem; publicadminfalse23322129635 262087132cashrcptmisctriggerTRIGGERCREATE TRIGGER cashrcptmisctrigger BEFORE INSERT OR UPDATE ON cashrcptmisc FOR EACH ROW EXECUTE PROCEDURE _cashrcptmisctrigger(); 9DROP TRIGGER cashrcptmisctrigger ON public.cashrcptmisc; publicadminfalse23422159635 262087129cashrcpttriggerTRIGGERvCREATE TRIGGER cashrcpttrigger BEFORE INSERT OR UPDATE ON cashrcpt FOR EACH ROW EXECUTE PROCEDURE _cashrcpttrigger(); 1DROP TRIGGER cashrcpttrigger ON public.cashrcpt; publicadminfalse23222119635 262087133 ccardtriggerTRIGGERmCREATE TRIGGER ccardtrigger BEFORE INSERT OR UPDATE ON ccard FOR EACH ROW EXECUTE PROCEDURE _ccardtrigger(); +DROP TRIGGER ccardtrigger ON public.ccard; publicadminfalse23522169635 262087135ccpaybeforetriggerTRIGGERyCREATE TRIGGER ccpaybeforetrigger BEFORE INSERT OR UPDATE ON ccpay FOR EACH ROW EXECUTE PROCEDURE _ccpaybeforetrigger(); 1DROP TRIGGER ccpaybeforetrigger ON public.ccpay; publicadminfalse22173739635 262087138charasshistorytriggerTRIGGERCREATE TRIGGER charasshistorytrigger BEFORE INSERT OR DELETE OR UPDATE ON charass FOR EACH ROW EXECUTE PROCEDURE _charasshistorytrigger(); 6DROP TRIGGER charasshistorytrigger ON public.charass; publicadminfalse21522209635 262087137charasstriggerTRIGGERrCREATE TRIGGER charasstrigger AFTER INSERT OR UPDATE ON charass FOR EACH ROW EXECUTE PROCEDURE _charasstrigger(); /DROP TRIGGER charasstrigger ON public.charass; publicadminfalse22192159635 262087136charbeforetriggerTRIGGERxCREATE TRIGGER charbeforetrigger BEFORE INSERT OR UPDATE ON "char" FOR EACH ROW EXECUTE PROCEDURE _charbeforetrigger(); 1DROP TRIGGER charbeforetrigger ON public."char"; publicadminfalse21422189635 262087139charopttriggerTRIGGERrCREATE TRIGGER charopttrigger AFTER DELETE OR UPDATE ON charopt FOR EACH ROW EXECUTE PROCEDURE _charopttrigger(); /DROP TRIGGER charopttrigger ON public.charopt; publicadminfalse22223779635Q!262088618charusebeforeupserttriggerTRIGGERCREATE TRIGGER charusebeforeupserttrigger BEFORE INSERT OR UPDATE ON charuse FOR EACH ROW EXECUTE PROCEDURE _charusebeforeupserttrigger(); ;DROP TRIGGER charusebeforeupserttrigger ON public.charuse; publicadminfalse78523999635 262087140checkheadbeforetriggerTRIGGERCREATE TRIGGER checkheadbeforetrigger BEFORE INSERT OR UPDATE ON checkhead FOR EACH ROW EXECUTE PROCEDURE _checkheadbeforetrigger(); 9DROP TRIGGER checkheadbeforetrigger ON public.checkhead; publicadminfalse31822239635 262087141cmheadbeforetriggerTRIGGERCREATE TRIGGER cmheadbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON cmhead FOR EACH ROW EXECUTE PROCEDURE _cmheadbeforetrigger(); 3DROP TRIGGER cmheadbeforetrigger ON public.cmhead; publicadminfalse20122249635 262087142 cmheadtriggerTRIGGERyCREATE TRIGGER cmheadtrigger AFTER INSERT OR DELETE OR UPDATE ON cmhead FOR EACH ROW EXECUTE PROCEDURE _cmheadtrigger(); -DROP TRIGGER cmheadtrigger ON public.cmhead; publicadminfalse22252019635 262087143cmitembeforetriggerTRIGGERCREATE TRIGGER cmitembeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON cmitem FOR EACH ROW EXECUTE PROCEDURE _cmitembeforetrigger(); 3DROP TRIGGER cmitembeforetrigger ON public.cmitem; publicadminfalse22262049635 262087144 cmitemtriggerTRIGGERyCREATE TRIGGER cmitemtrigger AFTER INSERT OR DELETE OR UPDATE ON cmitem FOR EACH ROW EXECUTE PROCEDURE _cmitemtrigger(); -DROP TRIGGER cmitemtrigger ON public.cmitem; publicadminfalse20422279635o 262087148cntctafterdeletetriggerTRIGGERxCREATE TRIGGER cntctafterdeletetrigger AFTER DELETE ON cntct FOR EACH ROW EXECUTE PROCEDURE _cntctafterdeletetrigger(); 6DROP TRIGGER cntctafterdeletetrigger ON public.cntct; publicadminfalse22301879635m 262087145 cntcttriggerTRIGGERmCREATE TRIGGER cntcttrigger BEFORE INSERT OR UPDATE ON cntct FOR EACH ROW EXECUTE PROCEDURE _cntcttrigger(); +DROP TRIGGER cntcttrigger ON public.cntct; publicadminfalse18722289635p 262087149cntcttriggerafterTRIGGERCREATE TRIGGER cntcttriggerafter AFTER INSERT OR DELETE OR UPDATE ON cntct FOR EACH ROW EXECUTE PROCEDURE _cntcttriggerafter(); 0DROP TRIGGER cntcttriggerafter ON public.cntct; publicadminfalse22311879635n 262087146cntcttriggerbeforedeleteTRIGGER{CREATE TRIGGER cntcttriggerbeforedelete BEFORE DELETE ON cntct FOR EACH ROW EXECUTE PROCEDURE _cntcttriggerbeforedelete(); 7DROP TRIGGER cntcttriggerbeforedelete ON public.cntct; publicadminfalse18722299635R 262087150cntsliptriggerTRIGGER}CREATE TRIGGER cntsliptrigger BEFORE INSERT OR DELETE OR UPDATE ON cntslip FOR EACH ROW EXECUTE PROCEDURE _cntsliptrigger(); /DROP TRIGGER cntsliptrigger ON public.cntslip; publicadminfalse22321729635 262087151cobillbeforetriggerTRIGGERCREATE TRIGGER cobillbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON cobill FOR EACH ROW EXECUTE PROCEDURE _cobillbeforetrigger(); 3DROP TRIGGER cobillbeforetrigger ON public.cobill; publicadminfalse22333999635 262087152 cobilltriggerTRIGGERyCREATE TRIGGER cobilltrigger AFTER INSERT OR DELETE OR UPDATE ON cobill FOR EACH ROW EXECUTE PROCEDURE _cobilltrigger(); -DROP TRIGGER cobilltrigger ON public.cobill; publicadminfalse39922369635!262087153cobmiscbeforetriggerTRIGGERCREATE TRIGGER cobmiscbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON cobmisc FOR EACH ROW EXECUTE PROCEDURE _cobmiscbeforetrigger(); 5DROP TRIGGER cobmiscbeforetrigger ON public.cobmisc; publicadminfalse40222379635!262087154cobmisctriggerTRIGGER|CREATE TRIGGER cobmisctrigger AFTER INSERT OR DELETE OR UPDATE ON cobmisc FOR EACH ROW EXECUTE PROCEDURE _cobmisctrigger(); /DROP TRIGGER cobmisctrigger ON public.cobmisc; publicadminfalse22384029635\ 262087159coheadafterdeletetriggerTRIGGER{CREATE TRIGGER coheadafterdeletetrigger AFTER DELETE ON cohead FOR EACH ROW EXECUTE PROCEDURE _coheadafterdeletetrigger(); 8DROP TRIGGER coheadafterdeletetrigger ON public.cohead; publicadminfalse17822419635b 262087169coitembeforeimptaxtypedefTRIGGERCREATE TRIGGER coitembeforeimptaxtypedef BEFORE INSERT ON coitem FOR EACH ROW EXECUTE PROCEDURE _coitembeforeimptaxtypedeftrigger(); 9DROP TRIGGER coitembeforeimptaxtypedef ON public.coitem; publicadminfalse22341799635 262087170commenttriggerTRIGGERrCREATE TRIGGER commenttrigger AFTER INSERT OR UPDATE ON comment FOR EACH ROW EXECUTE PROCEDURE _commenttrigger(); /DROP TRIGGER commenttrigger ON public.comment; publicadminfalse22352179635!262087171companytriggerTRIGGERiCREATE TRIGGER companytrigger BEFORE UPDATE ON company FOR EACH ROW EXECUTE PROCEDURE _companytrigger(); /DROP TRIGGER companytrigger ON public.company; publicadminfalse40922479635 262087172contrctaftertriggerTRIGGERrCREATE TRIGGER contrctaftertrigger AFTER UPDATE ON contrct FOR EACH ROW EXECUTE PROCEDURE _contrctaftertrigger(); 4DROP TRIGGER contrctaftertrigger ON public.contrct; publicadminfalse25922489635s 262087176crmacctafterdeletetriggerTRIGGER~CREATE TRIGGER crmacctafterdeletetrigger AFTER DELETE ON crmacct FOR EACH ROW EXECUTE PROCEDURE _crmacctafterdeletetrigger(); :DROP TRIGGER crmacctafterdeletetrigger ON public.crmacct; publicadminfalse22511889635r 262087174crmacctaftertriggerTRIGGERCREATE TRIGGER crmacctaftertrigger AFTER INSERT OR DELETE OR UPDATE ON crmacct FOR EACH ROW EXECUTE PROCEDURE _crmacctaftertrigger(); 4DROP TRIGGER crmacctaftertrigger ON public.crmacct; publicadminfalse18822509635q 262087173crmacctbeforetriggerTRIGGERCREATE TRIGGER crmacctbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON crmacct FOR EACH ROW EXECUTE PROCEDURE _crmacctbeforetrigger(); 5DROP TRIGGER crmacctbeforetrigger ON public.crmacct; publicadminfalse22491889635!262087177currexchangecheckoverlapTRIGGERCREATE TRIGGER currexchangecheckoverlap BEFORE INSERT OR UPDATE ON curr_rate FOR EACH ROW EXECUTE PROCEDURE currexchangecheckoverlap(); ;DROP TRIGGER currexchangecheckoverlap ON public.curr_rate; publicadminfalse22524299635y 262087178 curronebaseTRIGGERoCREATE TRIGGER curronebase AFTER INSERT OR UPDATE ON curr_symbol FOR EACH ROW EXECUTE PROCEDURE curronebase(); 0DROP TRIGGER curronebase ON public.curr_symbol; publicadminfalse22541919635 262087180custaftertriggerTRIGGERwCREATE TRIGGER custaftertrigger AFTER INSERT OR UPDATE ON custinfo FOR EACH ROW EXECUTE PROCEDURE _custaftertrigger(); 2DROP TRIGGER custaftertrigger ON public.custinfo; publicadminfalse22561969635 262087182custinfoafterdeletetriggerTRIGGERCREATE TRIGGER custinfoafterdeletetrigger AFTER DELETE ON custinfo FOR EACH ROW EXECUTE PROCEDURE _custinfoafterdeletetrigger(); <DROP TRIGGER custinfoafterdeletetrigger ON public.custinfo; publicadminfalse22581969635 262087181custinfobeforedeletetriggerTRIGGERCREATE TRIGGER custinfobeforedeletetrigger BEFORE DELETE ON custinfo FOR EACH ROW EXECUTE PROCEDURE _custinfobeforedeletetrigger(); =DROP TRIGGER custinfobeforedeletetrigger ON public.custinfo; publicadminfalse22571969635 262087179 custtriggerTRIGGERnCREATE TRIGGER custtrigger BEFORE INSERT OR UPDATE ON custinfo FOR EACH ROW EXECUTE PROCEDURE _custtrigger(); -DROP TRIGGER custtrigger ON public.custinfo; publicadminfalse22551969635 262087184custtypeafterdeletetriggerTRIGGERCREATE TRIGGER custtypeafterdeletetrigger AFTER DELETE ON custtype FOR EACH ROW EXECUTE PROCEDURE _custtypeafterdeletetrigger(); <DROP TRIGGER custtypeafterdeletetrigger ON public.custtype; publicadminfalse23622539635 262087183custtypetriggerTRIGGERvCREATE TRIGGER custtypetrigger BEFORE INSERT OR UPDATE ON custtype FOR EACH ROW EXECUTE PROCEDURE _custtypetrigger(); 1DROP TRIGGER custtypetrigger ON public.custtype; publicadminfalse23622599635 262087185 docasstriggerTRIGGERoCREATE TRIGGER docasstrigger AFTER INSERT OR UPDATE ON docass FOR EACH ROW EXECUTE PROCEDURE _docasstrigger(); -DROP TRIGGER docasstrigger ON public.docass; publicadminfalse21822609635 262087189empafterdeletetriggerTRIGGERrCREATE TRIGGER empafterdeletetrigger AFTER DELETE ON emp FOR EACH ROW EXECUTE PROCEDURE _empafterdeletetrigger(); 2DROP TRIGGER empafterdeletetrigger ON public.emp; publicadminfalse24222649635 262087187empaftertriggerTRIGGERpCREATE TRIGGER empaftertrigger AFTER INSERT OR UPDATE ON emp FOR EACH ROW EXECUTE PROCEDURE _empaftertrigger(); ,DROP TRIGGER empaftertrigger ON public.emp; publicadminfalse24222629635 262087188empbeforedeletetriggerTRIGGERuCREATE TRIGGER empbeforedeletetrigger BEFORE DELETE ON emp FOR EACH ROW EXECUTE PROCEDURE _empbeforedeletetrigger(); 3DROP TRIGGER empbeforedeletetrigger ON public.emp; publicadminfalse22632429635 262087186empbeforetriggerTRIGGERsCREATE TRIGGER empbeforetrigger BEFORE INSERT OR UPDATE ON emp FOR EACH ROW EXECUTE PROCEDURE _empbeforetrigger(); -DROP TRIGGER empbeforetrigger ON public.emp; publicadminfalse22612429635!262084207evntlogafterinserttriggerTRIGGER~CREATE TRIGGER evntlogafterinserttrigger AFTER INSERT ON evntlog FOR EACH ROW EXECUTE PROCEDURE _evntlogafterinserttrigger(); :DROP TRIGGER evntlogafterinserttrigger ON public.evntlog; publicadminfalse9214509635 262087191gltransaltertriggerTRIGGER}CREATE TRIGGER gltransaltertrigger BEFORE DELETE OR UPDATE ON gltrans FOR EACH ROW EXECUTE PROCEDURE _gltransaltertrigger(); 4DROP TRIGGER gltransaltertrigger ON public.gltrans; publicadminfalse26522669635 262087190gltransinserttriggerTRIGGERuCREATE TRIGGER gltransinserttrigger BEFORE INSERT ON gltrans FOR EACH ROW EXECUTE PROCEDURE _gltransinserttrigger(); 5DROP TRIGGER gltransinserttrigger ON public.gltrans; publicadminfalse26522659635!262087192grpprivtriggerTRIGGERsCREATE TRIGGER grpprivtrigger BEFORE INSERT OR UPDATE ON grppriv FOR EACH ROW EXECUTE PROCEDURE _grpprivtrigger(); /DROP TRIGGER grpprivtrigger ON public.grppriv; publicadminfalse48522679635 262087193imageasstriggerTRIGGERuCREATE TRIGGER imageasstrigger AFTER INSERT OR UPDATE ON imageass FOR EACH ROW EXECUTE PROCEDURE _imageasstrigger(); 1DROP TRIGGER imageasstrigger ON public.imageass; publicadminfalse22418069635w 262087198incdtafterdeletetriggerTRIGGERxCREATE TRIGGER incdtafterdeletetrigger AFTER DELETE ON incdt FOR EACH ROW EXECUTE PROCEDURE _incdtafterdeletetrigger(); 6DROP TRIGGER incdtafterdeletetrigger ON public.incdt; publicadminfalse18922719635u 262087195incdtbeforedeletetriggerTRIGGER{CREATE TRIGGER incdtbeforedeletetrigger BEFORE DELETE ON incdt FOR EACH ROW EXECUTE PROCEDURE _incdtbeforedeletetrigger(); 7DROP TRIGGER incdtbeforedeletetrigger ON public.incdt; publicadminfalse22691899635t 262087194incdtbeforetriggerTRIGGERyCREATE TRIGGER incdtbeforetrigger BEFORE INSERT OR UPDATE ON incdt FOR EACH ROW EXECUTE PROCEDURE _incdtbeforetrigger(); 1DROP TRIGGER incdtbeforetrigger ON public.incdt; publicadminfalse22681899635v 262087196 incdttriggerTRIGGERvCREATE TRIGGER incdttrigger AFTER INSERT OR DELETE OR UPDATE ON incdt FOR EACH ROW EXECUTE PROCEDURE _incdttrigger(); +DROP TRIGGER incdttrigger ON public.incdt; publicadminfalse18922709635 262087203invcheadafterdeletetriggerTRIGGERCREATE TRIGGER invcheadafterdeletetrigger AFTER DELETE ON invchead FOR EACH ROW EXECUTE PROCEDURE _invcheadafterdeletetrigger(); <DROP TRIGGER invcheadafterdeletetrigger ON public.invchead; publicadminfalse20518129635 262087201invcheadaftertriggerTRIGGERuCREATE TRIGGER invcheadaftertrigger AFTER UPDATE ON invchead FOR EACH ROW EXECUTE PROCEDURE _invcheadaftertrigger(); 6DROP TRIGGER invcheadaftertrigger ON public.invchead; publicadminfalse22742059635 262087199invcheadbeforetriggerTRIGGERCREATE TRIGGER invcheadbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON invchead FOR EACH ROW EXECUTE PROCEDURE _invcheadbeforetrigger(); 7DROP TRIGGER invcheadbeforetrigger ON public.invchead; publicadminfalse22722059635 262087200invcheadtriggerTRIGGERCREATE TRIGGER invcheadtrigger AFTER INSERT OR DELETE OR UPDATE ON invchead FOR EACH ROW EXECUTE PROCEDURE _invcheadtrigger(); 1DROP TRIGGER invcheadtrigger ON public.invchead; publicadminfalse22732059635 262087204invcitembeforetriggerTRIGGERCREATE TRIGGER invcitembeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON invcitem FOR EACH ROW EXECUTE PROCEDURE _invcitembeforetrigger(); 7DROP TRIGGER invcitembeforetrigger ON public.invcitem; publicadminfalse22752099635 262087205invcitemtriggerTRIGGERCREATE TRIGGER invcitemtrigger AFTER INSERT OR DELETE OR UPDATE ON invcitem FOR EACH ROW EXECUTE PROCEDURE _invcitemtrigger(); 1DROP TRIGGER invcitemtrigger ON public.invcitem; publicadminfalse22762099635!262087206invhisttriggerTRIGGERoCREATE TRIGGER invhisttrigger BEFORE INSERT OR UPDATE ON invhist FOR EACH ROW EXECUTE PROCEDURE invhisttrig(); /DROP TRIGGER invhisttrigger ON public.invhist; publicadminfalse22775059635 262087207ipsassbeforetriggerTRIGGERCREATE TRIGGER ipsassbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON ipsass FOR EACH ROW EXECUTE PROCEDURE _ipsassbeforetrigger(); 3DROP TRIGGER ipsassbeforetrigger ON public.ipsass; publicadminfalse26822789635 262087208ipsheadbeforetriggerTRIGGERCREATE TRIGGER ipsheadbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON ipshead FOR EACH ROW EXECUTE PROCEDURE _ipsheadbeforetrigger(); 5DROP TRIGGER ipsheadbeforetrigger ON public.ipshead; publicadminfalse24722799635 262087209ipsitemcharbeforetriggerTRIGGERCREATE TRIGGER ipsitemcharbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON ipsitemchar FOR EACH ROW EXECUTE PROCEDURE _ipsitemcharbeforetrigger(); =DROP TRIGGER ipsitemcharbeforetrigger ON public.ipsitemchar; publicadminfalse22802709635 262087210ipsiteminfobeforetriggerTRIGGERCREATE TRIGGER ipsiteminfobeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON ipsiteminfo FOR EACH ROW EXECUTE PROCEDURE _ipsiteminfobeforetrigger(); =DROP TRIGGER ipsiteminfobeforetrigger ON public.ipsiteminfo; publicadminfalse26922819635V 262087217item_uom_checkTRIGGERpCREATE TRIGGER item_uom_check BEFORE INSERT OR UPDATE ON item FOR EACH ROW EXECUTE PROCEDURE _item_uom_check(); ,DROP TRIGGER item_uom_check ON public.item; publicadminfalse22851749635U 262087215itemafterdeletetriggerTRIGGERuCREATE TRIGGER itemafterdeletetrigger AFTER DELETE ON item FOR EACH ROW EXECUTE PROCEDURE _itemafterdeletetrigger(); 4DROP TRIGGER itemafterdeletetrigger ON public.item; publicadminfalse17422849635T 262087213itemaftertriggerTRIGGER}CREATE TRIGGER itemaftertrigger AFTER INSERT OR DELETE OR UPDATE ON item FOR EACH ROW EXECUTE PROCEDURE _itemaftertrigger(); .DROP TRIGGER itemaftertrigger ON public.item; publicadminfalse9231749635 262087219itemcostaftertriggerTRIGGERCREATE TRIGGER itemcostaftertrigger AFTER INSERT OR UPDATE ON itemcost FOR EACH ROW EXECUTE PROCEDURE _itemcostaftertrigger(); 6DROP TRIGGER itemcostaftertrigger ON public.itemcost; publicadminfalse25622879635 262087218itemcosttriggerTRIGGERCREATE TRIGGER itemcosttrigger BEFORE INSERT OR DELETE OR UPDATE ON itemcost FOR EACH ROW EXECUTE PROCEDURE _itemcosttrigger(); 1DROP TRIGGER itemcosttrigger ON public.itemcost; publicadminfalse22862569635X 262087222itemsiteaftertriggerTRIGGERCREATE TRIGGER itemsiteaftertrigger AFTER INSERT OR UPDATE ON itemsite FOR EACH ROW EXECUTE PROCEDURE _itemsiteaftertrigger(); 6DROP TRIGGER itemsiteaftertrigger ON public.itemsite; publicadminfalse17522899635W 262087220itemsitetriggerTRIGGERvCREATE TRIGGER itemsitetrigger BEFORE INSERT OR UPDATE ON itemsite FOR EACH ROW EXECUTE PROCEDURE _itemsitetrigger(); 1DROP TRIGGER itemsitetrigger ON public.itemsite; publicadminfalse17522889635 262087224itemsrcaftertriggerTRIGGER|CREATE TRIGGER itemsrcaftertrigger AFTER INSERT OR UPDATE ON itemsrc FOR EACH ROW EXECUTE PROCEDURE _itemsrcaftertrigger(); 4DROP TRIGGER itemsrcaftertrigger ON public.itemsrc; publicadminfalse26022149635 262087225itemsrcptriggerTRIGGERvCREATE TRIGGER itemsrcptrigger BEFORE INSERT OR UPDATE ON itemsrcp FOR EACH ROW EXECUTE PROCEDURE _itemsrcptrigger(); 1DROP TRIGGER itemsrcptrigger ON public.itemsrcp; publicadminfalse22212619635 262087223itemsrctriggerTRIGGERsCREATE TRIGGER itemsrctrigger BEFORE INSERT OR UPDATE ON itemsrc FOR EACH ROW EXECUTE PROCEDURE _itemsrctrigger(); /DROP TRIGGER itemsrctrigger ON public.itemsrc; publicadminfalse26022909635 262087226itemsubtriggerTRIGGERrCREATE TRIGGER itemsubtrigger AFTER INSERT OR UPDATE ON itemsub FOR EACH ROW EXECUTE PROCEDURE _itemsubtrigger(); /DROP TRIGGER itemsubtrigger ON public.itemsub; publicadminfalse22822629635 262087227itemtaxtriggerTRIGGERrCREATE TRIGGER itemtaxtrigger AFTER INSERT OR UPDATE ON itemtax FOR EACH ROW EXECUTE PROCEDURE _itemtaxtrigger(); /DROP TRIGGER itemtaxtrigger ON public.itemtax; publicadminfalse22912639635S 262087211 itemtriggerTRIGGERjCREATE TRIGGER itemtrigger BEFORE INSERT OR UPDATE ON item FOR EACH ROW EXECUTE PROCEDURE _itemtrigger(); )DROP TRIGGER itemtrigger ON public.item; publicadminfalse17422839635 262087228itemuomconvtriggerTRIGGER~CREATE TRIGGER itemuomconvtrigger AFTER INSERT OR UPDATE ON itemuomconv FOR EACH ROW EXECUTE PROCEDURE _itemuomconvtrigger(); 7DROP TRIGGER itemuomconvtrigger ON public.itemuomconv; publicadminfalse26420379635 262087230locationaftertriggerTRIGGERCREATE TRIGGER locationaftertrigger AFTER INSERT OR UPDATE ON location FOR EACH ROW EXECUTE PROCEDURE _locationaftertrigger(); 6DROP TRIGGER locationaftertrigger ON public.location; publicadminfalse26622939635 262087229locationtriggerTRIGGERvCREATE TRIGGER locationtrigger BEFORE INSERT OR UPDATE ON location FOR EACH ROW EXECUTE PROCEDURE _locationtrigger(); 1DROP TRIGGER locationtrigger ON public.location; publicadminfalse22922669635 262084239metasqlaltertriggerTRIGGER}CREATE TRIGGER metasqlaltertrigger BEFORE INSERT OR UPDATE ON metasql FOR EACH ROW EXECUTE PROCEDURE _metasqlaltertrigger(); 4DROP TRIGGER metasqlaltertrigger ON public.metasql; publicadminfalse9242949635 262084240metasqltriggerTRIGGERsCREATE TRIGGER metasqltrigger BEFORE INSERT OR UPDATE ON metasql FOR EACH ROW EXECUTE PROCEDURE _metasqltrigger(); /DROP TRIGGER metasqltrigger ON public.metasql; publicadminfalse9252949635 262087234opheadafterdeletetriggerTRIGGER{CREATE TRIGGER opheadafterdeletetrigger AFTER DELETE ON ophead FOR EACH ROW EXECUTE PROCEDURE _opheadafterdeletetrigger(); 8DROP TRIGGER opheadafterdeletetrigger ON public.ophead; publicadminfalse21022969635 262087232opheadaftertriggerTRIGGERCREATE TRIGGER opheadaftertrigger AFTER INSERT OR DELETE OR UPDATE ON ophead FOR EACH ROW EXECUTE PROCEDURE _opheadaftertrigger(); 2DROP TRIGGER opheadaftertrigger ON public.ophead; publicadminfalse21022959635 262087231opheadbeforetriggerTRIGGER|CREATE TRIGGER opheadbeforetrigger BEFORE INSERT OR UPDATE ON ophead FOR EACH ROW EXECUTE PROCEDURE _opheadbeforetrigger(); 3DROP TRIGGER opheadbeforetrigger ON public.ophead; publicadminfalse22942109635 !262087235packbeforetriggerTRIGGERvCREATE TRIGGER packbeforetrigger BEFORE INSERT OR UPDATE ON pack FOR EACH ROW EXECUTE PROCEDURE _packbeforetrigger(); /DROP TRIGGER packbeforetrigger ON public.pack; publicadminfalse22975849635 262087236periodaftertriggerTRIGGERCREATE TRIGGER periodaftertrigger AFTER INSERT OR DELETE OR UPDATE ON period FOR EACH STATEMENT EXECUTE PROCEDURE _periodaftertrigger(); 2DROP TRIGGER periodaftertrigger ON public.period; publicadminfalse23022989635 !262087237pkgheadbeforetriggerTRIGGERCREATE TRIGGER pkgheadbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkghead FOR EACH ROW EXECUTE PROCEDURE _pkgheadbeforetrigger(); 5DROP TRIGGER pkgheadbeforetrigger ON public.pkghead; publicadminfalse59123009635 !262087239pkgitembeforetriggerTRIGGERCREATE TRIGGER pkgitembeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgitem FOR EACH ROW EXECUTE PROCEDURE _pkgitembeforetrigger(); 5DROP TRIGGER pkgitembeforetrigger ON public.pkgitem; publicadminfalse9265939635e 262087243poheadafterdeletetriggerTRIGGER{CREATE TRIGGER poheadafterdeletetrigger AFTER DELETE ON pohead FOR EACH ROW EXECUTE PROCEDURE _poheadafterdeletetrigger(); 8DROP TRIGGER poheadafterdeletetrigger ON public.pohead; publicadminfalse23251809635c 262087240 poheadtriggerTRIGGERzCREATE TRIGGER poheadtrigger BEFORE INSERT OR DELETE OR UPDATE ON pohead FOR EACH ROW EXECUTE PROCEDURE _poheadtrigger(); -DROP TRIGGER poheadtrigger ON public.pohead; publicadminfalse23231809635d 262087241poheadtriggerafterTRIGGERoCREATE TRIGGER poheadtriggerafter AFTER UPDATE ON pohead FOR EACH ROW EXECUTE PROCEDURE _poheadtriggerafter(); 2DROP TRIGGER poheadtriggerafter ON public.pohead; publicadminfalse23241809635i 262087248poitemafterdeletetriggerTRIGGER{CREATE TRIGGER poitemafterdeletetrigger AFTER DELETE ON poitem FOR EACH ROW EXECUTE PROCEDURE _poitemafterdeletetrigger(); 8DROP TRIGGER poitemafterdeletetrigger ON public.poitem; publicadminfalse23301819635g 262087246poitemaftertriggerTRIGGERyCREATE TRIGGER poitemaftertrigger AFTER INSERT OR UPDATE ON poitem FOR EACH ROW EXECUTE PROCEDURE _poitemaftertrigger(); 2DROP TRIGGER poitemaftertrigger ON public.poitem; publicadminfalse23271819635h 262087247poitemdeletetriggerTRIGGERrCREATE TRIGGER poitemdeletetrigger BEFORE DELETE ON poitem FOR EACH ROW EXECUTE PROCEDURE _poitemdeletetrigger(); 3DROP TRIGGER poitemdeletetrigger ON public.poitem; publicadminfalse18123299635f 262087245 poitemtriggerTRIGGERpCREATE TRIGGER poitemtrigger BEFORE INSERT OR UPDATE ON poitem FOR EACH ROW EXECUTE PROCEDURE _poitemtrigger(); -DROP TRIGGER poitemtrigger ON public.poitem; publicadminfalse18123269635 262087252prjafterdeletetriggerTRIGGERrCREATE TRIGGER prjafterdeletetrigger AFTER DELETE ON prj FOR EACH ROW EXECUTE PROCEDURE _prjafterdeletetrigger(); 2DROP TRIGGER prjafterdeletetrigger ON public.prj; publicadminfalse20623339635 262087253prjaftertriggerTRIGGERpCREATE TRIGGER prjaftertrigger AFTER INSERT OR UPDATE ON prj FOR EACH ROW EXECUTE PROCEDURE _prjaftertrigger(); ,DROP TRIGGER prjaftertrigger ON public.prj; publicadminfalse23342069635 262087250prjbeforedeletetriggerTRIGGERuCREATE TRIGGER prjbeforedeletetrigger BEFORE DELETE ON prj FOR EACH ROW EXECUTE PROCEDURE _prjbeforedeletetrigger(); 3DROP TRIGGER prjbeforedeletetrigger ON public.prj; publicadminfalse23322069635 262087257prjtaskafterdeletetriggerTRIGGER~CREATE TRIGGER prjtaskafterdeletetrigger AFTER DELETE ON prjtask FOR EACH ROW EXECUTE PROCEDURE _prjtaskafterdeletetrigger(); :DROP TRIGGER prjtaskafterdeletetrigger ON public.prjtask; publicadminfalse21121679635 262087255prjtaskaftertriggerTRIGGER|CREATE TRIGGER prjtaskaftertrigger AFTER INSERT OR UPDATE ON prjtask FOR EACH ROW EXECUTE PROCEDURE _prjtaskaftertrigger(); 4DROP TRIGGER prjtaskaftertrigger ON public.prjtask; publicadminfalse23362119635 262087254prjtasktriggerTRIGGERsCREATE TRIGGER prjtasktrigger BEFORE INSERT OR UPDATE ON prjtask FOR EACH ROW EXECUTE PROCEDURE _prjtasktrigger(); /DROP TRIGGER prjtasktrigger ON public.prjtask; publicadminfalse21123359635 262087261prospectafterdeletetriggerTRIGGERCREATE TRIGGER prospectafterdeletetrigger AFTER DELETE ON prospect FOR EACH ROW EXECUTE PROCEDURE _prospectafterdeletetrigger(); <DROP TRIGGER prospectafterdeletetrigger ON public.prospect; publicadminfalse27223399635 262087259prospectaftertriggerTRIGGERCREATE TRIGGER prospectaftertrigger AFTER INSERT OR UPDATE ON prospect FOR EACH ROW EXECUTE PROCEDURE _prospectaftertrigger(); 6DROP TRIGGER prospectaftertrigger ON public.prospect; publicadminfalse27223379635 262087260prospectbeforedeletetriggerTRIGGERCREATE TRIGGER prospectbeforedeletetrigger BEFORE DELETE ON prospect FOR EACH ROW EXECUTE PROCEDURE _prospectbeforedeletetrigger(); =DROP TRIGGER prospectbeforedeletetrigger ON public.prospect; publicadminfalse23382729635 262087258prospecttriggerTRIGGERvCREATE TRIGGER prospecttrigger BEFORE INSERT OR UPDATE ON prospect FOR EACH ROW EXECUTE PROCEDURE _prospecttrigger(); 1DROP TRIGGER prospecttrigger ON public.prospect; publicadminfalse22992729635 !262087249 prtriggerTRIGGERYCREATE TRIGGER prtrigger AFTER INSERT ON pr FOR EACH ROW EXECUTE PROCEDURE _prtrigger(); %DROP TRIGGER prtrigger ON public.pr; publicadminfalse60423319635 262087265quheadafterdeletetriggerTRIGGER{CREATE TRIGGER quheadafterdeletetrigger AFTER DELETE ON quhead FOR EACH ROW EXECUTE PROCEDURE _quheadafterdeletetrigger(); 8DROP TRIGGER quheadafterdeletetrigger ON public.quhead; publicadminfalse23412779635 262087263 quheadtriggerTRIGGERzCREATE TRIGGER quheadtrigger BEFORE INSERT OR DELETE OR UPDATE ON quhead FOR EACH ROW EXECUTE PROCEDURE _quheadtrigger(); -DROP TRIGGER quheadtrigger ON public.quhead; publicadminfalse23402779635 262087270quitemafterdeletetriggerTRIGGER{CREATE TRIGGER quitemafterdeletetrigger AFTER DELETE ON quitem FOR EACH ROW EXECUTE PROCEDURE _quitemafterdeletetrigger(); 8DROP TRIGGER quitemafterdeletetrigger ON public.quitem; publicadminfalse27823459635 262087268quitemaftertriggerTRIGGERyCREATE TRIGGER quitemaftertrigger AFTER INSERT OR UPDATE ON quitem FOR EACH ROW EXECUTE PROCEDURE _quitemaftertrigger(); 2DROP TRIGGER quitemaftertrigger ON public.quitem; publicadminfalse23442789635 262087267quitembeforetriggerTRIGGER|CREATE TRIGGER quitembeforetrigger BEFORE INSERT OR UPDATE ON quitem FOR EACH ROW EXECUTE PROCEDURE _quitembeforetrigger(); 3DROP TRIGGER quitembeforetrigger ON public.quitem; publicadminfalse23432789635 262087266 quitemtriggerTRIGGERzCREATE TRIGGER quitemtrigger BEFORE INSERT OR DELETE OR UPDATE ON quitem FOR EACH ROW EXECUTE PROCEDURE _quitemtrigger(); -DROP TRIGGER quitemtrigger ON public.quitem; publicadminfalse23422789635!262087271recuraftertriggerTRIGGERlCREATE TRIGGER recuraftertrigger AFTER DELETE ON recur FOR EACH ROW EXECUTE PROCEDURE _recuraftertrigger(); 0DROP TRIGGER recuraftertrigger ON public.recur; publicadminfalse23466249635 262087272 reporttriggerTRIGGERpCREATE TRIGGER reporttrigger BEFORE INSERT OR UPDATE ON report FOR EACH ROW EXECUTE PROCEDURE _reporttrigger(); -DROP TRIGGER reporttrigger ON public.report; publicadminfalse23283009635 262087275salesrepafterdeletetriggerTRIGGERCREATE TRIGGER salesrepafterdeletetrigger AFTER DELETE ON salesrep FOR EACH ROW EXECUTE PROCEDURE _salesrepafterdeletetrigger(); <DROP TRIGGER salesrepafterdeletetrigger ON public.salesrep; publicadminfalse23491999635 262087274salesrepaftertriggerTRIGGERCREATE TRIGGER salesrepaftertrigger AFTER INSERT OR UPDATE ON salesrep FOR EACH ROW EXECUTE PROCEDURE _salesrepaftertrigger(); 6DROP TRIGGER salesrepaftertrigger ON public.salesrep; publicadminfalse19923489635 262087273salesrepbeforetriggerTRIGGERCREATE TRIGGER salesrepbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON salesrep FOR EACH ROW EXECUTE PROCEDURE _salesrepbeforetrigger(); 7DROP TRIGGER salesrepbeforetrigger ON public.salesrep; publicadminfalse23471999635 262087278saletype_after_changeTRIGGERCREATE TRIGGER saletype_after_change AFTER INSERT OR UPDATE ON saletype FOR EACH ROW EXECUTE PROCEDURE _saletypeaftertrigger(); 7DROP TRIGGER saletype_after_change ON public.saletype; publicadminfalse23512079635 262087276saletypebeforedeletetriggerTRIGGERCREATE TRIGGER saletypebeforedeletetrigger BEFORE DELETE ON saletype FOR EACH ROW EXECUTE PROCEDURE _saletypebeforedeletetrigger(); =DROP TRIGGER saletypebeforedeletetrigger ON public.saletype; publicadminfalse23502079635!262087280shipdatasumtriggerTRIGGERCREATE TRIGGER shipdatasumtrigger BEFORE INSERT OR UPDATE ON shipdatasum FOR EACH ROW EXECUTE PROCEDURE _shipdatasumtrigger(); 7DROP TRIGGER shipdatasumtrigger ON public.shipdatasum; publicadminfalse23536449635 262087279shipdatatriggerTRIGGERvCREATE TRIGGER shipdatatrigger BEFORE INSERT OR UPDATE ON shipdata FOR EACH ROW EXECUTE PROCEDURE _shipdatatrigger(); 1DROP TRIGGER shipdatatrigger ON public.shipdata; publicadminfalse24423529635 262087281shipformafterdeletetriggerTRIGGERCREATE TRIGGER shipformafterdeletetrigger AFTER DELETE ON shipform FOR EACH ROW EXECUTE PROCEDURE _shipformafterdeletetrigger(); <DROP TRIGGER shipformafterdeletetrigger ON public.shipform; publicadminfalse23823549635!262087282shipheadbeforetriggerTRIGGERCREATE TRIGGER shipheadbeforetrigger BEFORE INSERT OR UPDATE ON shiphead FOR EACH ROW EXECUTE PROCEDURE _shipheadbeforetrigger(); 7DROP TRIGGER shipheadbeforetrigger ON public.shiphead; publicadminfalse23554129635 262087283shiptoinfoaftertriggerTRIGGERCREATE TRIGGER shiptoinfoaftertrigger AFTER INSERT OR UPDATE ON shiptoinfo FOR EACH ROW EXECUTE PROCEDURE _shiptoinfoaftertrigger(); :DROP TRIGGER shiptoinfoaftertrigger ON public.shiptoinfo; publicadminfalse20223569635 262087284shipviaafterdeletetriggerTRIGGER~CREATE TRIGGER shipviaafterdeletetrigger AFTER DELETE ON shipvia FOR EACH ROW EXECUTE PROCEDURE _shipviaafterdeletetrigger(); :DROP TRIGGER shipviaafterdeletetrigger ON public.shipvia; publicadminfalse23572839635!262087288sltransaltertriggerTRIGGER}CREATE TRIGGER sltransaltertrigger BEFORE DELETE OR UPDATE ON sltrans FOR EACH ROW EXECUTE PROCEDURE _sltransaltertrigger(); 4DROP TRIGGER sltransaltertrigger ON public.sltrans; publicadminfalse23606549635!262087287sltransinserttriggerTRIGGERuCREATE TRIGGER sltransinserttrigger BEFORE INSERT ON sltrans FOR EACH ROW EXECUTE PROCEDURE _sltransinserttrigger(); 5DROP TRIGGER sltransinserttrigger ON public.sltrans; publicadminfalse23596549635Z 262087156 soheadtriggerTRIGGERzCREATE TRIGGER soheadtrigger BEFORE INSERT OR DELETE OR UPDATE ON cohead FOR EACH ROW EXECUTE PROCEDURE _soheadtrigger(); -DROP TRIGGER soheadtrigger ON public.cohead; publicadminfalse17822399635[ 262087157soheadtriggerafterTRIGGERoCREATE TRIGGER soheadtriggerafter AFTER UPDATE ON cohead FOR EACH ROW EXECUTE PROCEDURE _soheadtriggerafter(); 2DROP TRIGGER soheadtriggerafter ON public.cohead; publicadminfalse17822409635a 262087167soitemafterdeletetriggerTRIGGER{CREATE TRIGGER soitemafterdeletetrigger AFTER DELETE ON coitem FOR EACH ROW EXECUTE PROCEDURE _soitemafterdeletetrigger(); 8DROP TRIGGER soitemafterdeletetrigger ON public.coitem; publicadminfalse17922469635_ 262087165soitemaftertriggerTRIGGERyCREATE TRIGGER soitemaftertrigger AFTER INSERT OR UPDATE ON coitem FOR EACH ROW EXECUTE PROCEDURE _soitemaftertrigger(); 2DROP TRIGGER soitemaftertrigger ON public.coitem; publicadminfalse22441799635` 262087166soitembeforedeletetriggerTRIGGER~CREATE TRIGGER soitembeforedeletetrigger BEFORE DELETE ON coitem FOR EACH ROW EXECUTE PROCEDURE _soitembeforedeletetrigger(); 9DROP TRIGGER soitembeforedeletetrigger ON public.coitem; publicadminfalse22451799635^ 262087163soitembeforetriggerTRIGGER|CREATE TRIGGER soitembeforetrigger BEFORE INSERT OR UPDATE ON coitem FOR EACH ROW EXECUTE PROCEDURE _soitembeforetrigger(); 3DROP TRIGGER soitembeforetrigger ON public.coitem; publicadminfalse22431799635] 262087161 soitemtriggerTRIGGERpCREATE TRIGGER soitemtrigger BEFORE INSERT OR UPDATE ON coitem FOR EACH ROW EXECUTE PROCEDURE _soitemtrigger(); -DROP TRIGGER soitemtrigger ON public.coitem; publicadminfalse17922429635!262087286sourcebeforeupserttriggerTRIGGERCREATE TRIGGER sourcebeforeupserttrigger BEFORE INSERT OR UPDATE ON source FOR EACH ROW EXECUTE PROCEDURE _sourcebeforeupserttrigger(); 9DROP TRIGGER sourcebeforeupserttrigger ON public.source; publicadminfalse65823589635 262087292taxauthafterdeletetriggerTRIGGER~CREATE TRIGGER taxauthafterdeletetrigger AFTER DELETE ON taxauth FOR EACH ROW EXECUTE PROCEDURE _taxauthafterdeletetrigger(); :DROP TRIGGER taxauthafterdeletetrigger ON public.taxauth; publicadminfalse23642399635 262087290taxauthaftertriggerTRIGGER|CREATE TRIGGER taxauthaftertrigger AFTER INSERT OR UPDATE ON taxauth FOR EACH ROW EXECUTE PROCEDURE _taxauthaftertrigger(); 4DROP TRIGGER taxauthaftertrigger ON public.taxauth; publicadminfalse23923629635 262087291taxauthbeforedeletetriggerTRIGGERCREATE TRIGGER taxauthbeforedeletetrigger BEFORE DELETE ON taxauth FOR EACH ROW EXECUTE PROCEDURE _taxauthbeforedeletetrigger(); ;DROP TRIGGER taxauthbeforedeletetrigger ON public.taxauth; publicadminfalse23632399635 262087289taxauthbeforetriggerTRIGGERCREATE TRIGGER taxauthbeforetrigger BEFORE INSERT OR UPDATE ON taxauth FOR EACH ROW EXECUTE PROCEDURE _taxauthbeforetrigger(); 5DROP TRIGGER taxauthbeforetrigger ON public.taxauth; publicadminfalse23612399635z 262087293termsafterdeletetriggerTRIGGERxCREATE TRIGGER termsafterdeletetrigger AFTER DELETE ON terms FOR EACH ROW EXECUTE PROCEDURE _termsafterdeletetrigger(); 6DROP TRIGGER termsafterdeletetrigger ON public.terms; publicadminfalse23651929635 262087294todoitemtriggerTRIGGERkCREATE TRIGGER todoitemtrigger AFTER DELETE ON todoitem FOR EACH ROW EXECUTE PROCEDURE _todoitemtrigger(); 1DROP TRIGGER todoitemtrigger ON public.todoitem; publicadminfalse21223669635!262087296trialbalaltertriggerTRIGGERCREATE TRIGGER trialbalaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON trialbal FOR EACH ROW EXECUTE PROCEDURE _trialbalaltertrigger(); 6DROP TRIGGER trialbalaltertrigger ON public.trialbal; publicadminfalse23676919635!262087297 uomconvupdateTRIGGERgCREATE TRIGGER uomconvupdate BEFORE UPDATE ON uomconv FOR EACH ROW EXECUTE PROCEDURE _uomconvupdate(); .DROP TRIGGER uomconvupdate ON public.uomconv; publicadminfalse69423689635!262087299usrprefaftertriggerTRIGGERCREATE TRIGGER usrprefaftertrigger AFTER INSERT OR DELETE OR UPDATE ON usrpref FOR EACH ROW EXECUTE PROCEDURE _usrprefaftertrigger(); 4DROP TRIGGER usrprefaftertrigger ON public.usrpref; publicadminfalse69923709635!262087298usrprefbeforetriggerTRIGGERCREATE TRIGGER usrprefbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON usrpref FOR EACH ROW EXECUTE PROCEDURE _usrprefbeforetrigger(); 5DROP TRIGGER usrprefbeforetrigger ON public.usrpref; publicadminfalse23696999635 !262087300usrprivtriggerTRIGGERsCREATE TRIGGER usrprivtrigger BEFORE INSERT OR UPDATE ON usrpriv FOR EACH ROW EXECUTE PROCEDURE _usrprivtrigger(); /DROP TRIGGER usrprivtrigger ON public.usrpriv; publicadminfalse23716099635 262087305vendaddrtriggerTRIGGERCREATE TRIGGER vendaddrtrigger BEFORE INSERT OR DELETE OR UPDATE ON vendaddrinfo FOR EACH ROW EXECUTE PROCEDURE _vendaddrtrigger(); 5DROP TRIGGER vendaddrtrigger ON public.vendaddrinfo; publicadminfalse27623769635| 262087302vendaftertriggerTRIGGERwCREATE TRIGGER vendaftertrigger AFTER INSERT OR UPDATE ON vendinfo FOR EACH ROW EXECUTE PROCEDURE _vendaftertrigger(); 2DROP TRIGGER vendaftertrigger ON public.vendinfo; publicadminfalse23731939635~ 262087304vendinfoafterdeletetriggerTRIGGERCREATE TRIGGER vendinfoafterdeletetrigger AFTER DELETE ON vendinfo FOR EACH ROW EXECUTE PROCEDURE _vendinfoafterdeletetrigger(); <DROP TRIGGER vendinfoafterdeletetrigger ON public.vendinfo; publicadminfalse23751939635} 262087303vendinfobeforedeletetriggerTRIGGERCREATE TRIGGER vendinfobeforedeletetrigger BEFORE DELETE ON vendinfo FOR EACH ROW EXECUTE PROCEDURE _vendinfobeforedeletetrigger(); =DROP TRIGGER vendinfobeforedeletetrigger ON public.vendinfo; publicadminfalse19323749635{ 262087301 vendtriggerTRIGGERnCREATE TRIGGER vendtrigger BEFORE INSERT OR UPDATE ON vendinfo FOR EACH ROW EXECUTE PROCEDURE _vendtrigger(); -DROP TRIGGER vendtrigger ON public.vendinfo; publicadminfalse19323729635!262087307vodistaftertriggerTRIGGERCREATE TRIGGER vodistaftertrigger AFTER INSERT OR DELETE OR UPDATE ON vodist FOR EACH ROW EXECUTE PROCEDURE _vodistaftertrigger(); 2DROP TRIGGER vodistaftertrigger ON public.vodist; publicadminfalse71123789635!262087306vodistbeforetriggerTRIGGERCREATE TRIGGER vodistbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON vodist FOR EACH ROW EXECUTE PROCEDURE _vodistbeforetrigger(); 3DROP TRIGGER vodistbeforetrigger ON public.vodist; publicadminfalse23777119635!262087311voheadafterdeletetriggerTRIGGER{CREATE TRIGGER voheadafterdeletetrigger AFTER DELETE ON vohead FOR EACH ROW EXECUTE PROCEDURE _voheadafterdeletetrigger(); 8DROP TRIGGER voheadafterdeletetrigger ON public.vohead; publicadminfalse71323819635!262087309voheadaftertriggerTRIGGERCREATE TRIGGER voheadaftertrigger AFTER INSERT OR DELETE OR UPDATE ON vohead FOR EACH ROW EXECUTE PROCEDURE _voheadaftertrigger(); 2DROP TRIGGER voheadaftertrigger ON public.vohead; publicadminfalse23807139635!262087308voheadbeforetriggerTRIGGERCREATE TRIGGER voheadbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON vohead FOR EACH ROW EXECUTE PROCEDURE _voheadbeforetrigger(); 3DROP TRIGGER voheadbeforetrigger ON public.vohead; publicadminfalse23797139635!262087313voitemaftertriggerTRIGGERCREATE TRIGGER voitemaftertrigger AFTER INSERT OR DELETE OR UPDATE ON voitem FOR EACH ROW EXECUTE PROCEDURE _voitemaftertrigger(); 2DROP TRIGGER voitemaftertrigger ON public.voitem; publicadminfalse23837169635!262087312voitembeforetriggerTRIGGERCREATE TRIGGER voitembeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON voitem FOR EACH ROW EXECUTE PROCEDURE _voitembeforetrigger(); 3DROP TRIGGER voitembeforetrigger ON public.voitem; publicadminfalse71623829635Y 262087315warehoustriggerTRIGGERuCREATE TRIGGER warehoustrigger BEFORE INSERT OR UPDATE ON whsinfo FOR EACH ROW EXECUTE PROCEDURE _warehoustrigger(); 0DROP TRIGGER warehoustrigger ON public.whsinfo; publicadminfalse23851769635 262087314whsezonetriggerTRIGGERvCREATE TRIGGER whsezonetrigger BEFORE INSERT OR UPDATE ON whsezone FOR EACH ROW EXECUTE PROCEDURE _whsezonetrigger(); 1DROP TRIGGER whsezonetrigger ON public.whsezone; publicadminfalse26723849635 262087317womatlaftertriggerTRIGGERCREATE TRIGGER womatlaftertrigger AFTER INSERT OR DELETE OR UPDATE ON womatl FOR EACH ROW EXECUTE PROCEDURE _womatlaftertrigger(); 2DROP TRIGGER womatlaftertrigger ON public.womatl; publicadminfalse23872749635!262087316 wotriggerTRIGGERnCREATE TRIGGER wotrigger BEFORE INSERT OR DELETE OR UPDATE ON wo FOR EACH ROW EXECUTE PROCEDURE _wotrigger(); %DROP TRIGGER wotrigger ON public.wo; publicadminfalse44423869635!262084312pkgcmdaftertriggerTRIGGERCREATE TRIGGER pkgcmdaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdaftertrigger(); .DROP TRIGGER pkgcmdaftertrigger ON te.pkgcmd; teadminfalse23037339635!262084313pkgcmdaltertriggerTRIGGERCREATE TRIGGER pkgcmdaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdaltertrigger(); .DROP TRIGGER pkgcmdaltertrigger ON te.pkgcmd; teadminfalse23027339635!!262084314pkgcmdargaftertriggerTRIGGERCREATE TRIGGER pkgcmdargaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargaftertrigger(); 4DROP TRIGGER pkgcmdargaftertrigger ON te.pkgcmdarg; teadminfalse23067349635"!262084315pkgcmdargaltertriggerTRIGGERCREATE TRIGGER pkgcmdargaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargaltertrigger(); 4DROP TRIGGER pkgcmdargaltertrigger ON te.pkgcmdarg; teadminfalse23057349635#!262084316pkgcmdargbeforetriggerTRIGGERCREATE TRIGGER pkgcmdargbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargbeforetrigger(); 5DROP TRIGGER pkgcmdargbeforetrigger ON te.pkgcmdarg; teadminfalse23047349635 !262084317pkgcmdbeforetriggerTRIGGERCREATE TRIGGER pkgcmdbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdbeforetrigger(); /DROP TRIGGER pkgcmdbeforetrigger ON te.pkgcmd; teadminfalse23017339635$!262084318pkgimageaftertriggerTRIGGERCREATE TRIGGER pkgimageaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimageaftertrigger(); 2DROP TRIGGER pkgimageaftertrigger ON te.pkgimage; teadminfalse23097359635%!262084319pkgimagealtertriggerTRIGGERCREATE TRIGGER pkgimagealtertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimagealtertrigger(); 2DROP TRIGGER pkgimagealtertrigger ON te.pkgimage; teadminfalse23087359635&!262084320pkgimagebeforetriggerTRIGGERCREATE TRIGGER pkgimagebeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimagebeforetrigger(); 3DROP TRIGGER pkgimagebeforetrigger ON te.pkgimage; teadminfalse23077359635'!262084321pkgmetasqlaftertriggerTRIGGERCREATE TRIGGER pkgmetasqlaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlaftertrigger(); 6DROP TRIGGER pkgmetasqlaftertrigger ON te.pkgmetasql; teadminfalse23127369635(!262084322pkgmetasqlaltertriggerTRIGGERCREATE TRIGGER pkgmetasqlaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlaltertrigger(); 6DROP TRIGGER pkgmetasqlaltertrigger ON te.pkgmetasql; teadminfalse23117369635)!262084323pkgmetasqlbeforetriggerTRIGGERCREATE TRIGGER pkgmetasqlbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlbeforetrigger(); 7DROP TRIGGER pkgmetasqlbeforetrigger ON te.pkgmetasql; teadminfalse23107369635*!262084324pkgprivaftertriggerTRIGGERCREATE TRIGGER pkgprivaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivaftertrigger(); 0DROP TRIGGER pkgprivaftertrigger ON te.pkgpriv; teadminfalse23157379635+!262084325pkgprivaltertriggerTRIGGERCREATE TRIGGER pkgprivaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivaltertrigger(); 0DROP TRIGGER pkgprivaltertrigger ON te.pkgpriv; teadminfalse23147379635,!262084326pkgprivbeforetriggerTRIGGERCREATE TRIGGER pkgprivbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivbeforetrigger(); 1DROP TRIGGER pkgprivbeforetrigger ON te.pkgpriv; teadminfalse73723139635-!262084327pkgreportaftertriggerTRIGGERCREATE TRIGGER pkgreportaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportaftertrigger(); 4DROP TRIGGER pkgreportaftertrigger ON te.pkgreport; teadminfalse20537389635.!262084328pkgreportaltertriggerTRIGGERCREATE TRIGGER pkgreportaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportaltertrigger(); 4DROP TRIGGER pkgreportaltertrigger ON te.pkgreport; teadminfalse73823179635/!262084329pkgreportbeforetriggerTRIGGERCREATE TRIGGER pkgreportbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportbeforetrigger(); 5DROP TRIGGER pkgreportbeforetrigger ON te.pkgreport; teadminfalse231673896350!262084330pkgscriptaftertriggerTRIGGERCREATE TRIGGER pkgscriptaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptaftertrigger(); 4DROP TRIGGER pkgscriptaftertrigger ON te.pkgscript; teadminfalse231973996351!262084331pkgscriptaltertriggerTRIGGERCREATE TRIGGER pkgscriptaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptaltertrigger(); 4DROP TRIGGER pkgscriptaltertrigger ON te.pkgscript; teadminfalse231873996352!262084332pkgscriptbeforetriggerTRIGGERCREATE TRIGGER pkgscriptbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptbeforetrigger(); 5DROP TRIGGER pkgscriptbeforetrigger ON te.pkgscript; teadminfalse208973996353!262084333pkguiformaftertriggerTRIGGERCREATE TRIGGER pkguiformaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformaftertrigger(); 4DROP TRIGGER pkguiformaftertrigger ON te.pkguiform; teadminfalse232274096354!262084334pkguiformaltertriggerTRIGGERCREATE TRIGGER pkguiformaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformaltertrigger(); 4DROP TRIGGER pkguiformaltertrigger ON te.pkguiform; teadminfalse232174096355!262084335pkguiformbeforetriggerTRIGGERCREATE TRIGGER pkguiformbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformbeforetrigger(); 5DROP TRIGGER pkguiformbeforetrigger ON te.pkguiform; teadminfalse232074096356!2620153476 teheadtriggerTRIGGERnCREATE TRIGGER teheadtrigger AFTER INSERT OR UPDATE ON tehead FOR EACH ROW EXECUTE PROCEDURE triggertehead(); )DROP TRIGGER teheadtrigger ON te.tehead; teadminfalse91574796357!2620153490 teitemtriggerTRIGGERnCREATE TRIGGER teitemtrigger AFTER INSERT OR UPDATE ON teitem FOR EACH ROW EXECUTE PROCEDURE triggerteitem(); )DROP TRIGGER teitemtrigger ON te.teitem; teadminfalse74991696358!2620153493 teprjtriggerTRIGGERkCREATE TRIGGER teprjtrigger AFTER INSERT OR UPDATE ON teprj FOR EACH ROW EXECUTE PROCEDURE triggerteprj(); 'DROP TRIGGER teprjtrigger ON te.teprj; teadminfalse102675196359!262084339pkgcmdaftertriggerTRIGGERCREATE TRIGGER pkgcmdaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdaftertrigger(); 5DROP TRIGGER pkgcmdaftertrigger ON xtdesktop.pkgcmd;  xtdesktopadminfalse23037559635:!262084340pkgcmdaltertriggerTRIGGERCREATE TRIGGER pkgcmdaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdaltertrigger(); 5DROP TRIGGER pkgcmdaltertrigger ON xtdesktop.pkgcmd;  xtdesktopadminfalse23027559635!262084343pkgcmdargbeforetriggerTRIGGERCREATE TRIGGER pkgcmdargbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmdarg FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdargbeforetrigger(); <DROP TRIGGER pkgcmdargbeforetrigger ON xtdesktop.pkgcmdarg;  xtdesktopadminfalse23047569635;!262084344pkgcmdbeforetriggerTRIGGERCREATE TRIGGER pkgcmdbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgcmd FOR EACH ROW EXECUTE PROCEDURE public._pkgcmdbeforetrigger(); 6DROP TRIGGER pkgcmdbeforetrigger ON xtdesktop.pkgcmd;  xtdesktopadminfalse23017559635?!262084345pkgimageaftertriggerTRIGGERCREATE TRIGGER pkgimageaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimageaftertrigger(); 9DROP TRIGGER pkgimageaftertrigger ON xtdesktop.pkgimage;  xtdesktopadminfalse23097579635@!262084346pkgimagealtertriggerTRIGGERCREATE TRIGGER pkgimagealtertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimagealtertrigger(); 9DROP TRIGGER pkgimagealtertrigger ON xtdesktop.pkgimage;  xtdesktopadminfalse23087579635A!262084347pkgimagebeforetriggerTRIGGERCREATE TRIGGER pkgimagebeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgimage FOR EACH ROW EXECUTE PROCEDURE public._pkgimagebeforetrigger(); :DROP TRIGGER pkgimagebeforetrigger ON xtdesktop.pkgimage;  xtdesktopadminfalse23077579635B!262084348pkgmetasqlaftertriggerTRIGGERCREATE TRIGGER pkgmetasqlaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlaftertrigger(); =DROP TRIGGER pkgmetasqlaftertrigger ON xtdesktop.pkgmetasql;  xtdesktopadminfalse23127589635C!262084349pkgmetasqlaltertriggerTRIGGERCREATE TRIGGER pkgmetasqlaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlaltertrigger(); =DROP TRIGGER pkgmetasqlaltertrigger ON xtdesktop.pkgmetasql;  xtdesktopadminfalse23117589635D!262084350pkgmetasqlbeforetriggerTRIGGERCREATE TRIGGER pkgmetasqlbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgmetasql FOR EACH ROW EXECUTE PROCEDURE public._pkgmetasqlbeforetrigger(); >DROP TRIGGER pkgmetasqlbeforetrigger ON xtdesktop.pkgmetasql;  xtdesktopadminfalse23107589635E!262084351pkgprivaftertriggerTRIGGERCREATE TRIGGER pkgprivaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivaftertrigger(); 7DROP TRIGGER pkgprivaftertrigger ON xtdesktop.pkgpriv;  xtdesktopadminfalse23157599635F!262084352pkgprivaltertriggerTRIGGERCREATE TRIGGER pkgprivaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivaltertrigger(); 7DROP TRIGGER pkgprivaltertrigger ON xtdesktop.pkgpriv;  xtdesktopadminfalse23147599635G!262084353pkgprivbeforetriggerTRIGGERCREATE TRIGGER pkgprivbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgpriv FOR EACH ROW EXECUTE PROCEDURE public._pkgprivbeforetrigger(); 8DROP TRIGGER pkgprivbeforetrigger ON xtdesktop.pkgpriv;  xtdesktopadminfalse23137599635H!262084354pkgreportaftertriggerTRIGGERCREATE TRIGGER pkgreportaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportaftertrigger(); ;DROP TRIGGER pkgreportaftertrigger ON xtdesktop.pkgreport;  xtdesktopadminfalse20537609635I!262084355pkgreportaltertriggerTRIGGERCREATE TRIGGER pkgreportaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportaltertrigger(); ;DROP TRIGGER pkgreportaltertrigger ON xtdesktop.pkgreport;  xtdesktopadminfalse23177609635J!262084356pkgreportbeforetriggerTRIGGERCREATE TRIGGER pkgreportbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgreport FOR EACH ROW EXECUTE PROCEDURE public._pkgreportbeforetrigger(); <DROP TRIGGER pkgreportbeforetrigger ON xtdesktop.pkgreport;  xtdesktopadminfalse23167609635K!262084357pkgscriptaftertriggerTRIGGERCREATE TRIGGER pkgscriptaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptaftertrigger(); ;DROP TRIGGER pkgscriptaftertrigger ON xtdesktop.pkgscript;  xtdesktopadminfalse76123199635L!262084358pkgscriptaltertriggerTRIGGERCREATE TRIGGER pkgscriptaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptaltertrigger(); ;DROP TRIGGER pkgscriptaltertrigger ON xtdesktop.pkgscript;  xtdesktopadminfalse23187619635M!262084359pkgscriptbeforetriggerTRIGGERCREATE TRIGGER pkgscriptbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkgscript FOR EACH ROW EXECUTE PROCEDURE public._pkgscriptbeforetrigger(); <DROP TRIGGER pkgscriptbeforetrigger ON xtdesktop.pkgscript;  xtdesktopadminfalse76120899635N!262084360pkguiformaftertriggerTRIGGERCREATE TRIGGER pkguiformaftertrigger AFTER INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformaftertrigger(); ;DROP TRIGGER pkguiformaftertrigger ON xtdesktop.pkguiform;  xtdesktopadminfalse76223229635O!262084361pkguiformaltertriggerTRIGGERCREATE TRIGGER pkguiformaltertrigger BEFORE INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformaltertrigger(); ;DROP TRIGGER pkguiformaltertrigger ON xtdesktop.pkguiform;  xtdesktopadminfalse76223219635P!262084362pkguiformbeforetriggerTRIGGERCREATE TRIGGER pkguiformbeforetrigger BEFORE INSERT OR DELETE OR UPDATE ON pkguiform FOR EACH ROW EXECUTE PROCEDURE public._pkguiformbeforetrigger(); <DROP TRIGGER pkguiformbeforetrigger ON xtdesktop.pkguiform;  xtdesktopadminfalse23207629635260684363pkgcmdarg_cmdarg_cmd_id_fkey FK CONSTRAINTALTER TABLE ONLY pkgcmdarg ADD CONSTRAINT pkgcmdarg_cmdarg_cmd_id_fkey FOREIGN KEY (cmdarg_cmd_id) REFERENCES pkgcmd(cmd_id); TALTER TABLE ONLY fixcountry.pkgcmdarg DROP CONSTRAINT pkgcmdarg_cmdarg_cmd_id_fkey;  fixcountryadminfalse29128872559635A260684368accnt_accnt_company_fkey FK CONSTRAINTALTER TABLE ONLY accnt ADD CONSTRAINT accnt_accnt_company_fkey FOREIGN KEY (accnt_company) REFERENCES company(company_number) ON UPDATE CASCADE; HALTER TABLE ONLY public.accnt DROP CONSTRAINT accnt_accnt_company_fkey; publicadminfalse22840974109635B260684373accnt_to_curr_symbol FK CONSTRAINT|ALTER TABLE ONLY accnt ADD CONSTRAINT accnt_to_curr_symbol FOREIGN KEY (accnt_curr_id) REFERENCES curr_symbol(curr_id); DALTER TABLE ONLY public.accnt DROP CONSTRAINT accnt_to_curr_symbol; publicadminfalse22819169129635260684378!apapply_apapply_checkhead_id_fkey FK CONSTRAINTALTER TABLE ONLY apapply ADD CONSTRAINT apapply_apapply_checkhead_id_fkey FOREIGN KEY (apapply_checkhead_id) REFERENCES checkhead(checkhead_id); SALTER TABLE ONLY public.apapply DROP CONSTRAINT apapply_apapply_checkhead_id_fkey; publicadminfalse31631872959635260684383apapply_apapply_vend_id_fkey FK CONSTRAINTALTER TABLE ONLY apapply ADD CONSTRAINT apapply_apapply_vend_id_fkey FOREIGN KEY (apapply_vend_id) REFERENCES vendinfo(vend_id); NALTER TABLE ONLY public.apapply DROP CONSTRAINT apapply_apapply_vend_id_fkey; publicadminfalse31619369199635260684388apapply_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY apapply ADD CONSTRAINT apapply_to_curr_symbol FOREIGN KEY (apapply_curr_id) REFERENCES curr_symbol(curr_id); HALTER TABLE ONLY public.apapply DROP CONSTRAINT apapply_to_curr_symbol; publicadminfalse31619169129635260684393apcreditapply_curr_symbol FK CONSTRAINTALTER TABLE ONLY apcreditapply ADD CONSTRAINT apcreditapply_curr_symbol FOREIGN KEY (apcreditapply_curr_id) REFERENCES curr_symbol(curr_id); QALTER TABLE ONLY public.apcreditapply DROP CONSTRAINT apcreditapply_curr_symbol; publicadminfalse32219169129635260684398apopen_apopen_vend_id_fkey FK CONSTRAINTALTER TABLE ONLY apopen ADD CONSTRAINT apopen_apopen_vend_id_fkey FOREIGN KEY (apopen_vend_id) REFERENCES vendinfo(vend_id); KALTER TABLE ONLY public.apopen DROP CONSTRAINT apopen_apopen_vend_id_fkey; publicadminfalse19019369199635260684403apopen_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY apopen ADD CONSTRAINT apopen_to_curr_symbol FOREIGN KEY (apopen_curr_id) REFERENCES curr_symbol(curr_id); FALTER TABLE ONLY public.apopen DROP CONSTRAINT apopen_to_curr_symbol; publicadminfalse19019169129635260684408#apopentax_taxhist_basis_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY apopentax ADD CONSTRAINT apopentax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); WALTER TABLE ONLY public.apopentax DROP CONSTRAINT apopentax_taxhist_basis_tax_id_fkey; publicadminfalse32627572099635260684413 apopentax_taxhist_parent_id_fkey FK CONSTRAINTALTER TABLE ONLY apopentax ADD CONSTRAINT apopentax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES apopen(apopen_id) ON DELETE CASCADE; TALTER TABLE ONLY public.apopentax DROP CONSTRAINT apopentax_taxhist_parent_id_fkey; publicadminfalse32619069069635260684418apopentax_taxhist_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY apopentax ADD CONSTRAINT apopentax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); QALTER TABLE ONLY public.apopentax DROP CONSTRAINT apopentax_taxhist_tax_id_fkey; publicadminfalse32627572099635260684423!apopentax_taxhist_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY apopentax ADD CONSTRAINT apopentax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); UALTER TABLE ONLY public.apopentax DROP CONSTRAINT apopentax_taxhist_taxtype_id_fkey; publicadminfalse32618268749635260684428apselect_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY apselect ADD CONSTRAINT apselect_to_curr_symbol FOREIGN KEY (apselect_curr_id) REFERENCES curr_symbol(curr_id); JALTER TABLE ONLY public.apselect DROP CONSTRAINT apselect_to_curr_symbol; publicadminfalse32719169129635260684433arapply_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY arapply ADD CONSTRAINT arapply_to_curr_symbol FOREIGN KEY (arapply_curr_id) REFERENCES curr_symbol(curr_id); HALTER TABLE ONLY public.arapply DROP CONSTRAINT arapply_to_curr_symbol; publicadminfalse33119169129635260684438arcreditapply_curr_symbol FK CONSTRAINTALTER TABLE ONLY arcreditapply ADD CONSTRAINT arcreditapply_curr_symbol FOREIGN KEY (arcreditapply_curr_id) REFERENCES curr_symbol(curr_id); QALTER TABLE ONLY public.arcreditapply DROP CONSTRAINT arcreditapply_curr_symbol; publicadminfalse33419169129635260684443aropen_aropen_cust_id_fkey FK CONSTRAINTALTER TABLE ONLY aropen ADD CONSTRAINT aropen_aropen_cust_id_fkey FOREIGN KEY (aropen_cust_id) REFERENCES custinfo(cust_id); KALTER TABLE ONLY public.aropen DROP CONSTRAINT aropen_aropen_cust_id_fkey; publicadminfalse19519669319635260684448aropen_aropen_salesrep_id_fkey FK CONSTRAINTALTER TABLE ONLY aropen ADD CONSTRAINT aropen_aropen_salesrep_id_fkey FOREIGN KEY (aropen_salesrep_id) REFERENCES salesrep(salesrep_id); OALTER TABLE ONLY public.aropen DROP CONSTRAINT aropen_aropen_salesrep_id_fkey; publicadminfalse19519969439635260684453aropen_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY aropen ADD CONSTRAINT aropen_to_curr_symbol FOREIGN KEY (aropen_curr_id) REFERENCES curr_symbol(curr_id); FALTER TABLE ONLY public.aropen DROP CONSTRAINT aropen_to_curr_symbol; publicadminfalse19519169129635260684458#aropentax_taxhist_basis_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY aropentax ADD CONSTRAINT aropentax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); WALTER TABLE ONLY public.aropentax DROP CONSTRAINT aropentax_taxhist_basis_tax_id_fkey; publicadminfalse33827572099635260684463 aropentax_taxhist_parent_id_fkey FK CONSTRAINTALTER TABLE ONLY aropentax ADD CONSTRAINT aropentax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES aropen(aropen_id) ON DELETE CASCADE; TALTER TABLE ONLY public.aropentax DROP CONSTRAINT aropentax_taxhist_parent_id_fkey; publicadminfalse33819569279635260684468aropentax_taxhist_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY aropentax ADD CONSTRAINT aropentax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); QALTER TABLE ONLY public.aropentax DROP CONSTRAINT aropentax_taxhist_tax_id_fkey; publicadminfalse33827572099635260684473!aropentax_taxhist_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY aropentax ADD CONSTRAINT aropentax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); UALTER TABLE ONLY public.aropentax DROP CONSTRAINT aropentax_taxhist_taxtype_id_fkey; publicadminfalse33818268749635260684478asohist_asohist_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY asohist ADD CONSTRAINT asohist_asohist_taxtype_id_fkey FOREIGN KEY (asohist_taxtype_id) REFERENCES taxtype(taxtype_id); QALTER TABLE ONLY public.asohist DROP CONSTRAINT asohist_asohist_taxtype_id_fkey; publicadminfalse33918268749635260684483asohist_asohist_taxzone_id_fkey FK CONSTRAINTALTER TABLE ONLY asohist ADD CONSTRAINT asohist_asohist_taxzone_id_fkey FOREIGN KEY (asohist_taxzone_id) REFERENCES taxzone(taxzone_id); QALTER TABLE ONLY public.asohist DROP CONSTRAINT asohist_asohist_taxzone_id_fkey; publicadminfalse33920369569635260684488asohist_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY asohist ADD CONSTRAINT asohist_to_curr_symbol FOREIGN KEY (asohist_curr_id) REFERENCES curr_symbol(curr_id); HALTER TABLE ONLY public.asohist DROP CONSTRAINT asohist_to_curr_symbol; publicadminfalse33919169129635260684493$asohisttax_taxhist_basis_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY asohisttax ADD CONSTRAINT asohisttax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); YALTER TABLE ONLY public.asohisttax DROP CONSTRAINT asohisttax_taxhist_basis_tax_id_fkey; publicadminfalse34127572099635260684498!asohisttax_taxhist_parent_id_fkey FK CONSTRAINTALTER TABLE ONLY asohisttax ADD CONSTRAINT asohisttax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES asohist(asohist_id) ON DELETE CASCADE; VALTER TABLE ONLY public.asohisttax DROP CONSTRAINT asohisttax_taxhist_parent_id_fkey; publicadminfalse34133973269635260684503asohisttax_taxhist_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY asohisttax ADD CONSTRAINT asohisttax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); SALTER TABLE ONLY public.asohisttax DROP CONSTRAINT asohisttax_taxhist_tax_id_fkey; publicadminfalse34127572099635260684508"asohisttax_taxhist_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY asohisttax ADD CONSTRAINT asohisttax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); WALTER TABLE ONLY public.asohisttax DROP CONSTRAINT asohisttax_taxhist_taxtype_id_fkey; publicadminfalse34118268749635E260684513bankaccnt_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY bankaccnt ADD CONSTRAINT bankaccnt_to_curr_symbol FOREIGN KEY (bankaccnt_curr_id) REFERENCES curr_symbol(curr_id); LALTER TABLE ONLY public.bankaccnt DROP CONSTRAINT bankaccnt_to_curr_symbol; publicadminfalse23119169129635260684518bankadj_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY bankadj ADD CONSTRAINT bankadj_to_curr_symbol FOREIGN KEY (bankadj_curr_id) REFERENCES curr_symbol(curr_id); HALTER TABLE ONLY public.bankadj DROP CONSTRAINT bankadj_to_curr_symbol; publicadminfalse34619169129635>260684523bomhead_bomhead_item_id_fkey FK CONSTRAINTALTER TABLE ONLY bomhead ADD CONSTRAINT bomhead_bomhead_item_id_fkey FOREIGN KEY (bomhead_item_id) REFERENCES item(item_id) ON UPDATE RESTRICT ON DELETE CASCADE; NALTER TABLE ONLY public.bomhead DROP CONSTRAINT bomhead_bomhead_item_id_fkey; publicadminfalse22517468299635260684528bomitem_bomitem_char_id_fkey FK CONSTRAINTALTER TABLE ONLY bomitem ADD CONSTRAINT bomitem_bomitem_char_id_fkey FOREIGN KEY (bomitem_char_id) REFERENCES "char"(char_id); NALTER TABLE ONLY public.bomitem DROP CONSTRAINT bomitem_bomitem_char_id_fkey; publicadminfalse18621470039635260684533bomitem_bomitem_item_id_fkey FK CONSTRAINTALTER TABLE ONLY bomitem ADD CONSTRAINT bomitem_bomitem_item_id_fkey FOREIGN KEY (bomitem_item_id) REFERENCES item(item_id); NALTER TABLE ONLY public.bomitem DROP CONSTRAINT bomitem_bomitem_item_id_fkey; publicadminfalse18617468299635260684538#bomitem_bomitem_parent_item_id_fkey FK CONSTRAINTALTER TABLE ONLY bomitem ADD CONSTRAINT bomitem_bomitem_parent_item_id_fkey FOREIGN KEY (bomitem_parent_item_id) REFERENCES item(item_id) ON UPDATE RESTRICT ON DELETE CASCADE; UALTER TABLE ONLY public.bomitem DROP CONSTRAINT bomitem_bomitem_parent_item_id_fkey; publicadminfalse18617468299635260684543bomitem_bomitem_uom_id_fkey FK CONSTRAINT}ALTER TABLE ONLY bomitem ADD CONSTRAINT bomitem_bomitem_uom_id_fkey FOREIGN KEY (bomitem_uom_id) REFERENCES uom(uom_id); MALTER TABLE ONLY public.bomitem DROP CONSTRAINT bomitem_bomitem_uom_id_fkey; publicadminfalse18618368789635260684548'bomitemcost_bomitemcost_bomitem_id_fkey FK CONSTRAINTALTER TABLE ONLY bomitemcost ADD CONSTRAINT bomitemcost_bomitemcost_bomitem_id_fkey FOREIGN KEY (bomitemcost_bomitem_id) REFERENCES bomitem(bomitem_id); ]ALTER TABLE ONLY public.bomitemcost DROP CONSTRAINT bomitemcost_bomitemcost_bomitem_id_fkey; publicadminfalse35618668889635260684553(bomitemcost_bomitemcost_costelem_id_fkey FK CONSTRAINTALTER TABLE ONLY bomitemcost ADD CONSTRAINT bomitemcost_bomitemcost_costelem_id_fkey FOREIGN KEY (bomitemcost_costelem_id) REFERENCES costelem(costelem_id); ^ALTER TABLE ONLY public.bomitemcost DROP CONSTRAINT bomitemcost_bomitemcost_costelem_id_fkey; publicadminfalse35625571339635260684558$bomitemcost_bomitemcost_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY bomitemcost ADD CONSTRAINT bomitemcost_bomitemcost_curr_id_fkey FOREIGN KEY (bomitemcost_curr_id) REFERENCES curr_symbol(curr_id); ZALTER TABLE ONLY public.bomitemcost DROP CONSTRAINT bomitemcost_bomitemcost_curr_id_fkey; publicadminfalse35619169129635?260684563%bomitemsub_bomitemsub_bomitem_id_fkey FK CONSTRAINTALTER TABLE ONLY bomitemsub ADD CONSTRAINT bomitemsub_bomitemsub_bomitem_id_fkey FOREIGN KEY (bomitemsub_bomitem_id) REFERENCES bomitem(bomitem_id) ON UPDATE RESTRICT ON DELETE CASCADE; ZALTER TABLE ONLY public.bomitemsub DROP CONSTRAINT bomitemsub_bomitemsub_bomitem_id_fkey; publicadminfalse22618668889635@260684568"bomitemsub_bomitemsub_item_id_fkey FK CONSTRAINTALTER TABLE ONLY bomitemsub ADD CONSTRAINT bomitemsub_bomitemsub_item_id_fkey FOREIGN KEY (bomitemsub_item_id) REFERENCES item(item_id) ON UPDATE RESTRICT ON DELETE CASCADE; WALTER TABLE ONLY public.bomitemsub DROP CONSTRAINT bomitemsub_bomitemsub_item_id_fkey; publicadminfalse22617468299635260684573bomwork_bomwork_char_id_fkey FK CONSTRAINTALTER TABLE ONLY bomwork ADD CONSTRAINT bomwork_bomwork_char_id_fkey FOREIGN KEY (bomwork_char_id) REFERENCES "char"(char_id); NALTER TABLE ONLY public.bomwork DROP CONSTRAINT bomwork_bomwork_char_id_fkey; publicadminfalse35921470039635C260684578"budgitem_budgitem_budghead_id_fkey FK CONSTRAINTALTER TABLE ONLY budgitem ADD CONSTRAINT budgitem_budgitem_budghead_id_fkey FOREIGN KEY (budgitem_budghead_id) REFERENCES budghead(budghead_id); UALTER TABLE ONLY public.budgitem DROP CONSTRAINT budgitem_budgitem_budghead_id_fkey; publicadminfalse22922770369635D260684583 budgitem_budgitem_period_id_fkey FK CONSTRAINTALTER TABLE ONLY budgitem ADD CONSTRAINT budgitem_budgitem_period_id_fkey FOREIGN KEY (budgitem_period_id) REFERENCES period(period_id); SALTER TABLE ONLY public.budgitem DROP CONSTRAINT budgitem_budgitem_period_id_fkey; publicadminfalse22923070439635F260684588$cashrcpt_bankaccnt_bankaccnt_id_fkey FK CONSTRAINTALTER TABLE ONLY cashrcpt ADD CONSTRAINT cashrcpt_bankaccnt_bankaccnt_id_fkey FOREIGN KEY (cashrcpt_bankaccnt_id) REFERENCES bankaccnt(bankaccnt_id); WALTER TABLE ONLY public.cashrcpt DROP CONSTRAINT cashrcpt_bankaccnt_bankaccnt_id_fkey; publicadminfalse23223170479635G260684593cashrcpt_cust_cust_id_fkey FK CONSTRAINTALTER TABLE ONLY cashrcpt ADD CONSTRAINT cashrcpt_cust_cust_id_fkey FOREIGN KEY (cashrcpt_cust_id) REFERENCES custinfo(cust_id); MALTER TABLE ONLY public.cashrcpt DROP CONSTRAINT cashrcpt_cust_cust_id_fkey; publicadminfalse23219669319635H260684598cashrcpt_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY cashrcpt ADD CONSTRAINT cashrcpt_to_curr_symbol FOREIGN KEY (cashrcpt_curr_id) REFERENCES curr_symbol(curr_id); JALTER TABLE ONLY public.cashrcpt DROP CONSTRAINT cashrcpt_to_curr_symbol; publicadminfalse23219169129635I260684603"cashrcptitem_aropen_aropen_id_fkey FK CONSTRAINTALTER TABLE ONLY cashrcptitem ADD CONSTRAINT cashrcptitem_aropen_aropen_id_fkey FOREIGN KEY (cashrcptitem_aropen_id) REFERENCES aropen(aropen_id); YALTER TABLE ONLY public.cashrcptitem DROP CONSTRAINT cashrcptitem_aropen_aropen_id_fkey; publicadminfalse23319569279635J260684608&cashrcptitem_cashrcpt_cashrcpt_id_fkey FK CONSTRAINTALTER TABLE ONLY cashrcptitem ADD CONSTRAINT cashrcptitem_cashrcpt_cashrcpt_id_fkey FOREIGN KEY (cashrcptitem_cashrcpt_id) REFERENCES cashrcpt(cashrcpt_id); ]ALTER TABLE ONLY public.cashrcptitem DROP CONSTRAINT cashrcptitem_cashrcpt_cashrcpt_id_fkey; publicadminfalse23323270519635K260684613 cashrcptmisc_accnt_accnt_id_fkey FK CONSTRAINTALTER TABLE ONLY cashrcptmisc ADD CONSTRAINT cashrcptmisc_accnt_accnt_id_fkey FOREIGN KEY (cashrcptmisc_accnt_id) REFERENCES accnt(accnt_id); WALTER TABLE ONLY public.cashrcptmisc DROP CONSTRAINT cashrcptmisc_accnt_accnt_id_fkey; publicadminfalse23422870389635L260684618&cashrcptmisc_cashrcpt_cashrcpt_id_fkey FK CONSTRAINTALTER TABLE ONLY cashrcptmisc ADD CONSTRAINT cashrcptmisc_cashrcpt_cashrcpt_id_fkey FOREIGN KEY (cashrcptmisc_cashrcpt_id) REFERENCES cashrcpt(cashrcpt_id); ]ALTER TABLE ONLY public.cashrcptmisc DROP CONSTRAINT cashrcptmisc_cashrcpt_cashrcpt_id_fkey; publicadminfalse23423270519635M260684623ccard_ccard_cust_id_fkey FK CONSTRAINT}ALTER TABLE ONLY ccard ADD CONSTRAINT ccard_ccard_cust_id_fkey FOREIGN KEY (ccard_cust_id) REFERENCES custinfo(cust_id); HALTER TABLE ONLY public.ccard DROP CONSTRAINT ccard_ccard_cust_id_fkey; publicadminfalse23519669319635260684628ccbank_ccbank_bankaccnt_id_fkey FK CONSTRAINTALTER TABLE ONLY ccbank ADD CONSTRAINT ccbank_ccbank_bankaccnt_id_fkey FOREIGN KEY (ccbank_bankaccnt_id) REFERENCES bankaccnt(bankaccnt_id); PALTER TABLE ONLY public.ccbank DROP CONSTRAINT ccbank_ccbank_bankaccnt_id_fkey; publicadminfalse37123170479635260684633charopt_charopt_char_id_fkey FK CONSTRAINTALTER TABLE ONLY charopt ADD CONSTRAINT charopt_charopt_char_id_fkey FOREIGN KEY (charopt_char_id) REFERENCES "char"(char_id) ON DELETE CASCADE; NALTER TABLE ONLY public.charopt DROP CONSTRAINT charopt_charopt_char_id_fkey; publicadminfalse37721470039635Q 260687355charuse_charuse_char_id_fkey FK CONSTRAINTALTER TABLE ONLY charuse ADD CONSTRAINT charuse_charuse_char_id_fkey FOREIGN KEY (charuse_char_id) REFERENCES "char"(char_id) ON DELETE CASCADE; NALTER TABLE ONLY public.charuse DROP CONSTRAINT charuse_charuse_char_id_fkey; publicadminfalse70037852149635260684638%checkhead_checkhead_bankaccnt_id_fkey FK CONSTRAINTALTER TABLE ONLY checkhead ADD CONSTRAINT checkhead_checkhead_bankaccnt_id_fkey FOREIGN KEY (checkhead_bankaccnt_id) REFERENCES bankaccnt(bankaccnt_id); YALTER TABLE ONLY public.checkhead DROP CONSTRAINT checkhead_checkhead_bankaccnt_id_fkey; publicadminfalse31823170479635260684643 checkhead_checkhead_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY checkhead ADD CONSTRAINT checkhead_checkhead_curr_id_fkey FOREIGN KEY (checkhead_curr_id) REFERENCES curr_symbol(curr_id); TALTER TABLE ONLY public.checkhead DROP CONSTRAINT checkhead_checkhead_curr_id_fkey; publicadminfalse31819169129635260684648"checkhead_checkhead_expcat_id_fkey FK CONSTRAINTALTER TABLE ONLY checkhead ADD CONSTRAINT checkhead_checkhead_expcat_id_fkey FOREIGN KEY (checkhead_expcat_id) REFERENCES expcat(expcat_id); VALTER TABLE ONLY public.checkhead DROP CONSTRAINT checkhead_checkhead_expcat_id_fkey; publicadminfalse31827372039635260684653"checkitem_checkitem_apopen_id_fkey FK CONSTRAINTALTER TABLE ONLY checkitem ADD CONSTRAINT checkitem_checkitem_apopen_id_fkey FOREIGN KEY (checkitem_apopen_id) REFERENCES apopen(apopen_id); VALTER TABLE ONLY public.checkitem DROP CONSTRAINT checkitem_checkitem_apopen_id_fkey; publicadminfalse32019069069635260684658"checkitem_checkitem_aropen_id_fkey FK CONSTRAINTALTER TABLE ONLY checkitem ADD CONSTRAINT checkitem_checkitem_aropen_id_fkey FOREIGN KEY (checkitem_aropen_id) REFERENCES aropen(aropen_id); VALTER TABLE ONLY public.checkitem DROP CONSTRAINT checkitem_checkitem_aropen_id_fkey; publicadminfalse32019569279635260684663%checkitem_checkitem_checkhead_id_fkey FK CONSTRAINTALTER TABLE ONLY checkitem ADD CONSTRAINT checkitem_checkitem_checkhead_id_fkey FOREIGN KEY (checkitem_checkhead_id) REFERENCES checkhead(checkhead_id); YALTER TABLE ONLY public.checkitem DROP CONSTRAINT checkitem_checkitem_checkhead_id_fkey; publicadminfalse32031872959635260684668 checkitem_checkitem_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY checkitem ADD CONSTRAINT checkitem_checkitem_curr_id_fkey FOREIGN KEY (checkitem_curr_id) REFERENCES curr_symbol(curr_id); TALTER TABLE ONLY public.checkitem DROP CONSTRAINT checkitem_checkitem_curr_id_fkey; publicadminfalse32019169129635260684673cmdarg_cmdarg_cmd_id_fkey FK CONSTRAINTALTER TABLE ONLY cmdarg ADD CONSTRAINT cmdarg_cmdarg_cmd_id_fkey FOREIGN KEY (cmdarg_cmd_id) REFERENCES cmd(cmd_id) ON DELETE CASCADE; JALTER TABLE ONLY public.cmdarg DROP CONSTRAINT cmdarg_cmdarg_cmd_id_fkey; publicadminfalse28928672539635260684678cmhead_cmhead_cust_id_fkey FK CONSTRAINTALTER TABLE ONLY cmhead ADD CONSTRAINT cmhead_cmhead_cust_id_fkey FOREIGN KEY (cmhead_cust_id) REFERENCES custinfo(cust_id); KALTER TABLE ONLY public.cmhead DROP CONSTRAINT cmhead_cmhead_cust_id_fkey; publicadminfalse20119669319635260684683$cmhead_cmhead_freighttaxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY cmhead ADD CONSTRAINT cmhead_cmhead_freighttaxtype_id_fkey FOREIGN KEY (cmhead_freighttaxtype_id) REFERENCES taxtype(taxtype_id); UALTER TABLE ONLY public.cmhead DROP CONSTRAINT cmhead_cmhead_freighttaxtype_id_fkey; publicadminfalse20118268749635260684688cmhead_cmhead_prj_id_fkey FK CONSTRAINTyALTER TABLE ONLY cmhead ADD CONSTRAINT cmhead_cmhead_prj_id_fkey FOREIGN KEY (cmhead_prj_id) REFERENCES prj(prj_id); JALTER TABLE ONLY public.cmhead DROP CONSTRAINT cmhead_cmhead_prj_id_fkey; publicadminfalse20120669709635260684693cmhead_cmhead_salesrep_id_fkey FK CONSTRAINTALTER TABLE ONLY cmhead ADD CONSTRAINT cmhead_cmhead_salesrep_id_fkey FOREIGN KEY (cmhead_salesrep_id) REFERENCES salesrep(salesrep_id); OALTER TABLE ONLY public.cmhead DROP CONSTRAINT cmhead_cmhead_salesrep_id_fkey; publicadminfalse20119969439635260684698cmhead_cmhead_saletype_id_fkey FK CONSTRAINTALTER TABLE ONLY cmhead ADD CONSTRAINT cmhead_cmhead_saletype_id_fkey FOREIGN KEY (cmhead_saletype_id) REFERENCES saletype(saletype_id); OALTER TABLE ONLY public.cmhead DROP CONSTRAINT cmhead_cmhead_saletype_id_fkey; publicadminfalse20120769749635260684703cmhead_cmhead_shipzone_id_fkey FK CONSTRAINTALTER TABLE ONLY cmhead ADD CONSTRAINT cmhead_cmhead_shipzone_id_fkey FOREIGN KEY (cmhead_shipzone_id) REFERENCES shipzone(shipzone_id); OALTER TABLE ONLY public.cmhead DROP CONSTRAINT cmhead_cmhead_shipzone_id_fkey; publicadminfalse20120869769635260684708cmhead_cmhead_taxzone_id_fkey FK CONSTRAINTALTER TABLE ONLY cmhead ADD CONSTRAINT cmhead_cmhead_taxzone_id_fkey FOREIGN KEY (cmhead_taxzone_id) REFERENCES taxzone(taxzone_id); NALTER TABLE ONLY public.cmhead DROP CONSTRAINT cmhead_cmhead_taxzone_id_fkey; publicadminfalse20120369569635260684713cmhead_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY cmhead ADD CONSTRAINT cmhead_to_curr_symbol FOREIGN KEY (cmhead_curr_id) REFERENCES curr_symbol(curr_id); FALTER TABLE ONLY public.cmhead DROP CONSTRAINT cmhead_to_curr_symbol; publicadminfalse20119169129635260684718#cmheadtax_taxhist_basis_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY cmheadtax ADD CONSTRAINT cmheadtax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); WALTER TABLE ONLY public.cmheadtax DROP CONSTRAINT cmheadtax_taxhist_basis_tax_id_fkey; publicadminfalse38327572099635260684723 cmheadtax_taxhist_parent_id_fkey FK CONSTRAINTALTER TABLE ONLY cmheadtax ADD CONSTRAINT cmheadtax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES cmhead(cmhead_id) ON DELETE CASCADE; TALTER TABLE ONLY public.cmheadtax DROP CONSTRAINT cmheadtax_taxhist_parent_id_fkey; publicadminfalse38320169509635260684728cmheadtax_taxhist_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY cmheadtax ADD CONSTRAINT cmheadtax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); QALTER TABLE ONLY public.cmheadtax DROP CONSTRAINT cmheadtax_taxhist_tax_id_fkey; publicadminfalse38327572099635260684733!cmheadtax_taxhist_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY cmheadtax ADD CONSTRAINT cmheadtax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); UALTER TABLE ONLY public.cmheadtax DROP CONSTRAINT cmheadtax_taxhist_taxtype_id_fkey; publicadminfalse38318268749635 260684738cmitem_cmhead_id_fkey FK CONSTRAINTALTER TABLE ONLY cmitem ADD CONSTRAINT cmitem_cmhead_id_fkey FOREIGN KEY (cmitem_cmhead_id) REFERENCES cmhead(cmhead_id) ON UPDATE CASCADE ON DELETE CASCADE; FALTER TABLE ONLY public.cmitem DROP CONSTRAINT cmitem_cmhead_id_fkey; publicadminfalse20420169509635!260684743cmitem_cmitem_price_uom_id_fkey FK CONSTRAINTALTER TABLE ONLY cmitem ADD CONSTRAINT cmitem_cmitem_price_uom_id_fkey FOREIGN KEY (cmitem_price_uom_id) REFERENCES uom(uom_id); PALTER TABLE ONLY public.cmitem DROP CONSTRAINT cmitem_cmitem_price_uom_id_fkey; publicadminfalse20418368789635"260684748cmitem_cmitem_qty_uom_id_fkey FK CONSTRAINTALTER TABLE ONLY cmitem ADD CONSTRAINT cmitem_cmitem_qty_uom_id_fkey FOREIGN KEY (cmitem_qty_uom_id) REFERENCES uom(uom_id); NALTER TABLE ONLY public.cmitem DROP CONSTRAINT cmitem_cmitem_qty_uom_id_fkey; publicadminfalse20418368789635#260684753cmitem_cmitem_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY cmitem ADD CONSTRAINT cmitem_cmitem_taxtype_id_fkey FOREIGN KEY (cmitem_taxtype_id) REFERENCES taxtype(taxtype_id); NALTER TABLE ONLY public.cmitem DROP CONSTRAINT cmitem_cmitem_taxtype_id_fkey; publicadminfalse20418268749635260684758#cmitemtax_taxhist_basis_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY cmitemtax ADD CONSTRAINT cmitemtax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); WALTER TABLE ONLY public.cmitemtax DROP CONSTRAINT cmitemtax_taxhist_basis_tax_id_fkey; publicadminfalse38527572099635260684763 cmitemtax_taxhist_parent_id_fkey FK CONSTRAINTALTER TABLE ONLY cmitemtax ADD CONSTRAINT cmitemtax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES cmitem(cmitem_id) ON DELETE CASCADE; TALTER TABLE ONLY public.cmitemtax DROP CONSTRAINT cmitemtax_taxhist_parent_id_fkey; publicadminfalse38520469629635260684768cmitemtax_taxhist_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY cmitemtax ADD CONSTRAINT cmitemtax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); QALTER TABLE ONLY public.cmitemtax DROP CONSTRAINT cmitemtax_taxhist_tax_id_fkey; publicadminfalse38527572099635260684773!cmitemtax_taxhist_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY cmitemtax ADD CONSTRAINT cmitemtax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); UALTER TABLE ONLY public.cmitemtax DROP CONSTRAINT cmitemtax_taxhist_taxtype_id_fkey; publicadminfalse38518268749635260687387.cmnttypesource_cmnttypesource_cmnttype_id_fkey FK CONSTRAINTALTER TABLE ONLY cmnttypesource ADD CONSTRAINT cmnttypesource_cmnttypesource_cmnttype_id_fkey FOREIGN KEY (cmnttypesource_cmnttype_id) REFERENCES cmnttype(cmnttype_id); gALTER TABLE ONLY public.cmnttypesource DROP CONSTRAINT cmnttypesource_cmnttypesource_cmnttype_id_fkey; publicadminfalse38721670119635260687392,cmnttypesource_cmnttypesource_source_id_fkey FK CONSTRAINTALTER TABLE ONLY cmnttypesource ADD CONSTRAINT cmnttypesource_cmnttypesource_source_id_fkey FOREIGN KEY (cmnttypesource_source_id) REFERENCES source(source_id); eALTER TABLE ONLY public.cmnttypesource DROP CONSTRAINT cmnttypesource_cmnttypesource_source_id_fkey; publicadminfalse38777026589635260684778cntct_cntct_addr_id_fkey FK CONSTRAINTyALTER TABLE ONLY cntct ADD CONSTRAINT cntct_cntct_addr_id_fkey FOREIGN KEY (cntct_addr_id) REFERENCES addr(addr_id); HALTER TABLE ONLY public.cntct DROP CONSTRAINT cntct_cntct_addr_id_fkey; publicadminfalse18721369999635260684783cntct_cntct_crmacct_id_fkey FK CONSTRAINTALTER TABLE ONLY cntct ADD CONSTRAINT cntct_cntct_crmacct_id_fkey FOREIGN KEY (cntct_crmacct_id) REFERENCES crmacct(crmacct_id); KALTER TABLE ONLY public.cntct DROP CONSTRAINT cntct_cntct_crmacct_id_fkey; publicadminfalse18718868989635260684788 cntctaddr_cntctaddr_addr_id_fkey FK CONSTRAINTALTER TABLE ONLY cntctaddr ADD CONSTRAINT cntctaddr_cntctaddr_addr_id_fkey FOREIGN KEY (cntctaddr_addr_id) REFERENCES addr(addr_id); TALTER TABLE ONLY public.cntctaddr DROP CONSTRAINT cntctaddr_cntctaddr_addr_id_fkey; publicadminfalse39021369999635260684793!cntctaddr_cntctaddr_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY cntctaddr ADD CONSTRAINT cntctaddr_cntctaddr_cntct_id_fkey FOREIGN KEY (cntctaddr_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE; UALTER TABLE ONLY public.cntctaddr DROP CONSTRAINT cntctaddr_cntctaddr_cntct_id_fkey; publicadminfalse39018768949635260684798!cntctdata_cntctdata_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY cntctdata ADD CONSTRAINT cntctdata_cntctdata_cntct_id_fkey FOREIGN KEY (cntctdata_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE; UALTER TABLE ONLY public.cntctdata DROP CONSTRAINT cntctdata_cntctdata_cntct_id_fkey; publicadminfalse39218768949635260684803cntcteml_cntcteml_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY cntcteml ADD CONSTRAINT cntcteml_cntcteml_cntct_id_fkey FOREIGN KEY (cntcteml_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE; RALTER TABLE ONLY public.cntcteml DROP CONSTRAINT cntcteml_cntcteml_cntct_id_fkey; publicadminfalse39418768949635260684808!cntctmrgd_cntctmrgd_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY cntctmrgd ADD CONSTRAINT cntctmrgd_cntctmrgd_cntct_id_fkey FOREIGN KEY (cntctmrgd_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE; UALTER TABLE ONLY public.cntctmrgd DROP CONSTRAINT cntctmrgd_cntctmrgd_cntct_id_fkey; publicadminfalse39618768949635260684813cntctsel_cntctsel_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY cntctsel ADD CONSTRAINT cntctsel_cntctsel_cntct_id_fkey FOREIGN KEY (cntctsel_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE; RALTER TABLE ONLY public.cntctsel DROP CONSTRAINT cntctsel_cntctsel_cntct_id_fkey; publicadminfalse39718768949635260684818cobill_cobill_invcitem_id_fkey FK CONSTRAINTALTER TABLE ONLY cobill ADD CONSTRAINT cobill_cobill_invcitem_id_fkey FOREIGN KEY (cobill_invcitem_id) REFERENCES invcitem(invcitem_id); OALTER TABLE ONLY public.cobill DROP CONSTRAINT cobill_cobill_invcitem_id_fkey; publicadminfalse39920969849635260684823cobill_cobill_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY cobill ADD CONSTRAINT cobill_cobill_taxtype_id_fkey FOREIGN KEY (cobill_taxtype_id) REFERENCES taxtype(taxtype_id); NALTER TABLE ONLY public.cobill DROP CONSTRAINT cobill_cobill_taxtype_id_fkey; publicadminfalse39918268749635260684828#cobilltax_taxhist_basis_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY cobilltax ADD CONSTRAINT cobilltax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); WALTER TABLE ONLY public.cobilltax DROP CONSTRAINT cobilltax_taxhist_basis_tax_id_fkey; publicadminfalse40127572099635260684833 cobilltax_taxhist_parent_id_fkey FK CONSTRAINTALTER TABLE ONLY cobilltax ADD CONSTRAINT cobilltax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES cobill(cobill_id) ON DELETE CASCADE; TALTER TABLE ONLY public.cobilltax DROP CONSTRAINT cobilltax_taxhist_parent_id_fkey; publicadminfalse40139973949635260684838cobilltax_taxhist_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY cobilltax ADD CONSTRAINT cobilltax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); QALTER TABLE ONLY public.cobilltax DROP CONSTRAINT cobilltax_taxhist_tax_id_fkey; publicadminfalse40127572099635260684843!cobilltax_taxhist_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY cobilltax ADD CONSTRAINT cobilltax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); UALTER TABLE ONLY public.cobilltax DROP CONSTRAINT cobilltax_taxhist_taxtype_id_fkey; publicadminfalse40118268749635260684848 cobmisc_cobmisc_invchead_id_fkey FK CONSTRAINTALTER TABLE ONLY cobmisc ADD CONSTRAINT cobmisc_cobmisc_invchead_id_fkey FOREIGN KEY (cobmisc_invchead_id) REFERENCES invchead(invchead_id); RALTER TABLE ONLY public.cobmisc DROP CONSTRAINT cobmisc_cobmisc_invchead_id_fkey; publicadminfalse40220569689635260684853cobmisc_cobmisc_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY cobmisc ADD CONSTRAINT cobmisc_cobmisc_taxtype_id_fkey FOREIGN KEY (cobmisc_taxtype_id) REFERENCES taxtype(taxtype_id); QALTER TABLE ONLY public.cobmisc DROP CONSTRAINT cobmisc_cobmisc_taxtype_id_fkey; publicadminfalse40218268749635260684858cobmisc_cobmisc_taxzone_id_fkey FK CONSTRAINTALTER TABLE ONLY cobmisc ADD CONSTRAINT cobmisc_cobmisc_taxzone_id_fkey FOREIGN KEY (cobmisc_taxzone_id) REFERENCES taxzone(taxzone_id); QALTER TABLE ONLY public.cobmisc DROP CONSTRAINT cobmisc_cobmisc_taxzone_id_fkey; publicadminfalse40220369569635260684863cobmisc_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY cobmisc ADD CONSTRAINT cobmisc_to_curr_symbol FOREIGN KEY (cobmisc_curr_id) REFERENCES curr_symbol(curr_id); HALTER TABLE ONLY public.cobmisc DROP CONSTRAINT cobmisc_to_curr_symbol; publicadminfalse40219169129635260684868$cobmisctax_taxhist_basis_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY cobmisctax ADD CONSTRAINT cobmisctax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); YALTER TABLE ONLY public.cobmisctax DROP CONSTRAINT cobmisctax_taxhist_basis_tax_id_fkey; publicadminfalse40427572099635260684873!cobmisctax_taxhist_parent_id_fkey FK CONSTRAINTALTER TABLE ONLY cobmisctax ADD CONSTRAINT cobmisctax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES cobmisc(cobmisc_id) ON DELETE CASCADE; VALTER TABLE ONLY public.cobmisctax DROP CONSTRAINT cobmisctax_taxhist_parent_id_fkey; publicadminfalse40440274029635260684878cobmisctax_taxhist_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY cobmisctax ADD CONSTRAINT cobmisctax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); SALTER TABLE ONLY public.cobmisctax DROP CONSTRAINT cobmisctax_taxhist_tax_id_fkey; publicadminfalse40427572099635260684883"cobmisctax_taxhist_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY cobmisctax ADD CONSTRAINT cobmisctax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); WALTER TABLE ONLY public.cobmisctax DROP CONSTRAINT cobmisctax_taxhist_taxtype_id_fkey; publicadminfalse40418268749635260684888"cohead_cohead_billto_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_billto_cntct_id_fkey FOREIGN KEY (cohead_billto_cntct_id) REFERENCES cntct(cntct_id); SALTER TABLE ONLY public.cohead DROP CONSTRAINT cohead_cohead_billto_cntct_id_fkey; publicadminfalse17818768949635260684893cohead_cohead_cust_id_fkey FK CONSTRAINTALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_cust_id_fkey FOREIGN KEY (cohead_cust_id) REFERENCES custinfo(cust_id); KALTER TABLE ONLY public.cohead DROP CONSTRAINT cohead_cohead_cust_id_fkey; publicadminfalse17819669319635260684898 cohead_cohead_misc_accnt_id_fkey FK CONSTRAINTALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_misc_accnt_id_fkey FOREIGN KEY (cohead_misc_accnt_id) REFERENCES accnt(accnt_id); QALTER TABLE ONLY public.cohead DROP CONSTRAINT cohead_cohead_misc_accnt_id_fkey; publicadminfalse17822870389635260684903cohead_cohead_ophead_id_fkey FK CONSTRAINTALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_ophead_id_fkey FOREIGN KEY (cohead_ophead_id) REFERENCES ophead(ophead_id); MALTER TABLE ONLY public.cohead DROP CONSTRAINT cohead_cohead_ophead_id_fkey; publicadminfalse17821069889635260684908cohead_cohead_prj_id_fkey FK CONSTRAINTyALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_prj_id_fkey FOREIGN KEY (cohead_prj_id) REFERENCES prj(prj_id); JALTER TABLE ONLY public.cohead DROP CONSTRAINT cohead_cohead_prj_id_fkey; publicadminfalse17820669709635260684913cohead_cohead_salesrep_id_fkey FK CONSTRAINTALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_salesrep_id_fkey FOREIGN KEY (cohead_salesrep_id) REFERENCES salesrep(salesrep_id); OALTER TABLE ONLY public.cohead DROP CONSTRAINT cohead_cohead_salesrep_id_fkey; publicadminfalse17819969439635260684918cohead_cohead_saletype_id_fkey FK CONSTRAINTALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_saletype_id_fkey FOREIGN KEY (cohead_saletype_id) REFERENCES saletype(saletype_id); OALTER TABLE ONLY public.cohead DROP CONSTRAINT cohead_cohead_saletype_id_fkey; publicadminfalse17820769749635260684923cohead_cohead_shipform_id_fkey FK CONSTRAINTALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_shipform_id_fkey FOREIGN KEY (cohead_shipform_id) REFERENCES shipform(shipform_id); OALTER TABLE ONLY public.cohead DROP CONSTRAINT cohead_cohead_shipform_id_fkey; publicadminfalse17823870689635260684928"cohead_cohead_shipto_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_shipto_cntct_id_fkey FOREIGN KEY (cohead_shipto_cntct_id) REFERENCES cntct(cntct_id); SALTER TABLE ONLY public.cohead DROP CONSTRAINT cohead_cohead_shipto_cntct_id_fkey; publicadminfalse17818768949635260684933cohead_cohead_shipto_id_fkey FK CONSTRAINTALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_shipto_id_fkey FOREIGN KEY (cohead_shipto_id) REFERENCES shiptoinfo(shipto_id); MALTER TABLE ONLY public.cohead DROP CONSTRAINT cohead_cohead_shipto_id_fkey; publicadminfalse17820269549635260684938cohead_cohead_shipzone_id_fkey FK CONSTRAINTALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_shipzone_id_fkey FOREIGN KEY (cohead_shipzone_id) REFERENCES shipzone(shipzone_id); OALTER TABLE ONLY public.cohead DROP CONSTRAINT cohead_cohead_shipzone_id_fkey; publicadminfalse17820869769635260684943cohead_cohead_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_taxtype_id_fkey FOREIGN KEY (cohead_taxtype_id) REFERENCES taxtype(taxtype_id); NALTER TABLE ONLY public.cohead DROP CONSTRAINT cohead_cohead_taxtype_id_fkey; publicadminfalse17818268749635260684948cohead_cohead_taxzone_id_fkey FK CONSTRAINTALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_taxzone_id_fkey FOREIGN KEY (cohead_taxzone_id) REFERENCES taxzone(taxzone_id); NALTER TABLE ONLY public.cohead DROP CONSTRAINT cohead_cohead_taxzone_id_fkey; publicadminfalse17820369569635260684953cohead_cohead_terms_id_fkey FK CONSTRAINTALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_terms_id_fkey FOREIGN KEY (cohead_terms_id) REFERENCES terms(terms_id); LALTER TABLE ONLY public.cohead DROP CONSTRAINT cohead_cohead_terms_id_fkey; publicadminfalse17819269149635260684958cohead_cohead_warehous_id_fkey FK CONSTRAINTALTER TABLE ONLY cohead ADD CONSTRAINT cohead_cohead_warehous_id_fkey FOREIGN KEY (cohead_warehous_id) REFERENCES whsinfo(warehous_id); OALTER TABLE ONLY public.cohead DROP CONSTRAINT cohead_cohead_warehous_id_fkey; publicadminfalse17817668419635260684963cohead_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY cohead ADD CONSTRAINT cohead_to_curr_symbol FOREIGN KEY (cohead_curr_id) REFERENCES curr_symbol(curr_id); FALTER TABLE ONLY public.cohead DROP CONSTRAINT cohead_to_curr_symbol; publicadminfalse17819169129635260684968"cohist_cohist_cohead_ccpay_id_fkey FK CONSTRAINTALTER TABLE ONLY cohist ADD CONSTRAINT cohist_cohist_cohead_ccpay_id_fkey FOREIGN KEY (cohist_cohead_ccpay_id) REFERENCES ccpay(ccpay_id); SALTER TABLE ONLY public.cohist DROP CONSTRAINT cohist_cohist_cohead_ccpay_id_fkey; publicadminfalse28037373669635260684973cohist_cohist_cust_id_fkey FK CONSTRAINTALTER TABLE ONLY cohist ADD CONSTRAINT cohist_cohist_cust_id_fkey FOREIGN KEY (cohist_cust_id) REFERENCES custinfo(cust_id); KALTER TABLE ONLY public.cohist DROP CONSTRAINT cohist_cohist_cust_id_fkey; publicadminfalse28019669319635260684978cohist_cohist_salesrep_id_fkey FK CONSTRAINTALTER TABLE ONLY cohist ADD CONSTRAINT cohist_cohist_salesrep_id_fkey FOREIGN KEY (cohist_salesrep_id) REFERENCES salesrep(salesrep_id); OALTER TABLE ONLY public.cohist DROP CONSTRAINT cohist_cohist_salesrep_id_fkey; publicadminfalse28019969439635260684983cohist_cohist_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY cohist ADD CONSTRAINT cohist_cohist_taxtype_id_fkey FOREIGN KEY (cohist_taxtype_id) REFERENCES taxtype(taxtype_id); NALTER TABLE ONLY public.cohist DROP CONSTRAINT cohist_cohist_taxtype_id_fkey; publicadminfalse28018268749635260684988cohist_cohist_taxzone_id_fkey FK CONSTRAINTALTER TABLE ONLY cohist ADD CONSTRAINT cohist_cohist_taxzone_id_fkey FOREIGN KEY (cohist_taxzone_id) REFERENCES taxzone(taxzone_id); NALTER TABLE ONLY public.cohist DROP CONSTRAINT cohist_cohist_taxzone_id_fkey; publicadminfalse28020369569635260684993cohist_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY cohist ADD CONSTRAINT cohist_to_curr_symbol FOREIGN KEY (cohist_curr_id) REFERENCES curr_symbol(curr_id); FALTER TABLE ONLY public.cohist DROP CONSTRAINT cohist_to_curr_symbol; publicadminfalse28019169129635260684998#cohisttax_taxhist_basis_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY cohisttax ADD CONSTRAINT cohisttax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); WALTER TABLE ONLY public.cohisttax DROP CONSTRAINT cohisttax_taxhist_basis_tax_id_fkey; publicadminfalse28227572099635260685003 cohisttax_taxhist_parent_id_fkey FK CONSTRAINTALTER TABLE ONLY cohisttax ADD CONSTRAINT cohisttax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES cohist(cohist_id) ON DELETE CASCADE; TALTER TABLE ONLY public.cohisttax DROP CONSTRAINT cohisttax_taxhist_parent_id_fkey; publicadminfalse28228072279635260685008cohisttax_taxhist_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY cohisttax ADD CONSTRAINT cohisttax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); QALTER TABLE ONLY public.cohisttax DROP CONSTRAINT cohisttax_taxhist_tax_id_fkey; publicadminfalse28227572099635260685013!cohisttax_taxhist_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY cohisttax ADD CONSTRAINT cohisttax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); UALTER TABLE ONLY public.cohisttax DROP CONSTRAINT cohisttax_taxhist_taxtype_id_fkey; publicadminfalse28218268749635260685018coitem_coitem_cohead_id_fkey FK CONSTRAINTALTER TABLE ONLY coitem ADD CONSTRAINT coitem_coitem_cohead_id_fkey FOREIGN KEY (coitem_cohead_id) REFERENCES cohead(cohead_id) ON DELETE CASCADE; MALTER TABLE ONLY public.coitem DROP CONSTRAINT coitem_coitem_cohead_id_fkey; publicadminfalse17917868519635260685023coitem_coitem_cos_accnt_id_fkey FK CONSTRAINTALTER TABLE ONLY coitem ADD CONSTRAINT coitem_coitem_cos_accnt_id_fkey FOREIGN KEY (coitem_cos_accnt_id) REFERENCES accnt(accnt_id); PALTER TABLE ONLY public.coitem DROP CONSTRAINT coitem_coitem_cos_accnt_id_fkey; publicadminfalse17922870389635260685028coitem_coitem_itemsite_id_fkey FK CONSTRAINTALTER TABLE ONLY coitem ADD CONSTRAINT coitem_coitem_itemsite_id_fkey FOREIGN KEY (coitem_itemsite_id) REFERENCES itemsite(itemsite_id); OALTER TABLE ONLY public.coitem DROP CONSTRAINT coitem_coitem_itemsite_id_fkey; publicadminfalse17917568369635260685033coitem_coitem_price_uom_id_fkey FK CONSTRAINTALTER TABLE ONLY coitem ADD CONSTRAINT coitem_coitem_price_uom_id_fkey FOREIGN KEY (coitem_price_uom_id) REFERENCES uom(uom_id); PALTER TABLE ONLY public.coitem DROP CONSTRAINT coitem_coitem_price_uom_id_fkey; publicadminfalse17918368789635260685038coitem_coitem_qty_uom_id_fkey FK CONSTRAINTALTER TABLE ONLY coitem ADD CONSTRAINT coitem_coitem_qty_uom_id_fkey FOREIGN KEY (coitem_qty_uom_id) REFERENCES uom(uom_id); NALTER TABLE ONLY public.coitem DROP CONSTRAINT coitem_coitem_qty_uom_id_fkey; publicadminfalse17918368789635260685043coitem_coitem_rev_accnt_id_fkey FK CONSTRAINTALTER TABLE ONLY coitem ADD CONSTRAINT coitem_coitem_rev_accnt_id_fkey FOREIGN KEY (coitem_rev_accnt_id) REFERENCES accnt(accnt_id); PALTER TABLE ONLY public.coitem DROP CONSTRAINT coitem_coitem_rev_accnt_id_fkey; publicadminfalse17922870389635260685048%coitem_coitem_substitute_item_id_fkey FK CONSTRAINTALTER TABLE ONLY coitem ADD CONSTRAINT coitem_coitem_substitute_item_id_fkey FOREIGN KEY (coitem_substitute_item_id) REFERENCES item(item_id); VALTER TABLE ONLY public.coitem DROP CONSTRAINT coitem_coitem_substitute_item_id_fkey; publicadminfalse17417968299635260685053coitem_coitem_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY coitem ADD CONSTRAINT coitem_coitem_taxtype_id_fkey FOREIGN KEY (coitem_taxtype_id) REFERENCES taxtype(taxtype_id); NALTER TABLE ONLY public.coitem DROP CONSTRAINT coitem_coitem_taxtype_id_fkey; publicadminfalse68741791829635=260685058 comment_comment_cmnttype_id_fkey FK CONSTRAINTALTER TABLE ONLY comment ADD CONSTRAINT comment_comment_cmnttype_id_fkey FOREIGN KEY (comment_cmnttype_id) REFERENCES cmnttype(cmnttype_id); RALTER TABLE ONLY public.comment DROP CONSTRAINT comment_comment_cmnttype_id_fkey; publicadminfalse21770112169635260685063company_company_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY company ADD CONSTRAINT company_company_curr_id_fkey FOREIGN KEY (company_curr_id) REFERENCES curr_symbol(curr_id); NALTER TABLE ONLY public.company DROP CONSTRAINT company_company_curr_id_fkey; publicadminfalse40919169129635260685068#company_company_dscrp_accnt_id_fkey FK CONSTRAINTALTER TABLE ONLY company ADD CONSTRAINT company_company_dscrp_accnt_id_fkey FOREIGN KEY (company_dscrp_accnt_id) REFERENCES accnt(accnt_id); UALTER TABLE ONLY public.company DROP CONSTRAINT company_company_dscrp_accnt_id_fkey; publicadminfalse40922870389635260685073&company_company_gainloss_accnt_id_fkey FK CONSTRAINTALTER TABLE ONLY company ADD CONSTRAINT company_company_gainloss_accnt_id_fkey FOREIGN KEY (company_gainloss_accnt_id) REFERENCES accnt(accnt_id); XALTER TABLE ONLY public.company DROP CONSTRAINT company_company_gainloss_accnt_id_fkey; publicadminfalse22840970389635260685078+company_company_unrlzgainloss_accnt_id_fkey FK CONSTRAINTALTER TABLE ONLY company ADD CONSTRAINT company_company_unrlzgainloss_accnt_id_fkey FOREIGN KEY (company_unrlzgainloss_accnt_id) REFERENCES accnt(accnt_id); ]ALTER TABLE ONLY public.company DROP CONSTRAINT company_company_unrlzgainloss_accnt_id_fkey; publicadminfalse70382284099635260685083%company_company_yearend_accnt_id_fkey FK CONSTRAINTALTER TABLE ONLY company ADD CONSTRAINT company_company_yearend_accnt_id_fkey FOREIGN KEY (company_yearend_accnt_id) REFERENCES accnt(accnt_id); WALTER TABLE ONLY public.company DROP CONSTRAINT company_company_yearend_accnt_id_fkey; publicadminfalse40970382289635h260685088contrct_contrct_vend_id_fkey FK CONSTRAINTALTER TABLE ONLY contrct ADD CONSTRAINT contrct_contrct_vend_id_fkey FOREIGN KEY (contrct_vend_id) REFERENCES vendinfo(vend_id); NALTER TABLE ONLY public.contrct DROP CONSTRAINT contrct_contrct_vend_id_fkey; publicadminfalse25919369199635260685093costhist_new_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY costhist ADD CONSTRAINT costhist_new_to_curr_symbol FOREIGN KEY (costhist_newcurr_id) REFERENCES curr_symbol(curr_id); NALTER TABLE ONLY public.costhist DROP CONSTRAINT costhist_new_to_curr_symbol; publicadminfalse69121914219635260685098costhist_old_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY costhist ADD CONSTRAINT costhist_old_to_curr_symbol FOREIGN KEY (costhist_oldcurr_id) REFERENCES curr_symbol(curr_id); NALTER TABLE ONLY public.costhist DROP CONSTRAINT costhist_old_to_curr_symbol; publicadminfalse19142169129635260685103crmacct_crmacct_cntct_id_1_fkey FK CONSTRAINTALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_crmacct_cntct_id_1_fkey FOREIGN KEY (crmacct_cntct_id_1) REFERENCES cntct(cntct_id); QALTER TABLE ONLY public.crmacct DROP CONSTRAINT crmacct_crmacct_cntct_id_1_fkey; publicadminfalse68941871889635260685108crmacct_crmacct_cntct_id_2_fkey FK CONSTRAINTALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_crmacct_cntct_id_2_fkey FOREIGN KEY (crmacct_cntct_id_2) REFERENCES cntct(cntct_id); QALTER TABLE ONLY public.crmacct DROP CONSTRAINT crmacct_crmacct_cntct_id_2_fkey; publicadminfalse18868941879635260685113crmacct_crmacct_cust_id_fkey FK CONSTRAINTALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_crmacct_cust_id_fkey FOREIGN KEY (crmacct_cust_id) REFERENCES custinfo(cust_id); NALTER TABLE ONLY public.crmacct DROP CONSTRAINT crmacct_crmacct_cust_id_fkey; publicadminfalse69311961889635260685118crmacct_crmacct_emp_id_fkey FK CONSTRAINT}ALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_crmacct_emp_id_fkey FOREIGN KEY (crmacct_emp_id) REFERENCES emp(emp_id); MALTER TABLE ONLY public.crmacct DROP CONSTRAINT crmacct_crmacct_emp_id_fkey; publicadminfalse18870862429635260685123crmacct_crmacct_parent_id_fkey FK CONSTRAINTALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_crmacct_parent_id_fkey FOREIGN KEY (crmacct_parent_id) REFERENCES crmacct(crmacct_id); PALTER TABLE ONLY public.crmacct DROP CONSTRAINT crmacct_crmacct_parent_id_fkey; publicadminfalse18818868989635260685128 crmacct_crmacct_prospect_id_fkey FK CONSTRAINTALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_crmacct_prospect_id_fkey FOREIGN KEY (crmacct_prospect_id) REFERENCES prospect(prospect_id); RALTER TABLE ONLY public.crmacct DROP CONSTRAINT crmacct_crmacct_prospect_id_fkey; publicadminfalse71972721889635260685133 crmacct_crmacct_salesrep_id_fkey FK CONSTRAINTALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_crmacct_salesrep_id_fkey FOREIGN KEY (crmacct_salesrep_id) REFERENCES salesrep(salesrep_id); RALTER TABLE ONLY public.crmacct DROP CONSTRAINT crmacct_crmacct_salesrep_id_fkey; publicadminfalse18869431999635260685138crmacct_crmacct_taxauth_id_fkey FK CONSTRAINTALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_crmacct_taxauth_id_fkey FOREIGN KEY (crmacct_taxauth_id) REFERENCES taxauth(taxauth_id); QALTER TABLE ONLY public.crmacct DROP CONSTRAINT crmacct_crmacct_taxauth_id_fkey; publicadminfalse23918870729635260685143crmacct_crmacct_vend_id_fkey FK CONSTRAINTALTER TABLE ONLY crmacct ADD CONSTRAINT crmacct_crmacct_vend_id_fkey FOREIGN KEY (crmacct_vend_id) REFERENCES vendinfo(vend_id); NALTER TABLE ONLY public.crmacct DROP CONSTRAINT crmacct_crmacct_vend_id_fkey; publicadminfalse19318869199635260685148*crmacctsel_crmacctsel_dest_crmacct_id_fkey FK CONSTRAINTALTER TABLE ONLY crmacctsel ADD CONSTRAINT crmacctsel_crmacctsel_dest_crmacct_id_fkey FOREIGN KEY (crmacctsel_dest_crmacct_id) REFERENCES crmacct(crmacct_id) ON DELETE CASCADE; _ALTER TABLE ONLY public.crmacctsel DROP CONSTRAINT crmacctsel_crmacctsel_dest_crmacct_id_fkey; publicadminfalse42868981889635260685153)crmacctsel_crmacctsel_src_crmacct_id_fkey FK CONSTRAINTALTER TABLE ONLY crmacctsel ADD CONSTRAINT crmacctsel_crmacctsel_src_crmacct_id_fkey FOREIGN KEY (crmacctsel_src_crmacct_id) REFERENCES crmacct(crmacct_id) ON DELETE CASCADE; ^ALTER TABLE ONLY public.crmacctsel DROP CONSTRAINT crmacctsel_crmacctsel_src_crmacct_id_fkey; publicadminfalse42868981889635260685158curr_rate_to_curr_symbol FK CONSTRAINT~ALTER TABLE ONLY curr_rate ADD CONSTRAINT curr_rate_to_curr_symbol FOREIGN KEY (curr_id) REFERENCES curr_symbol(curr_id); LALTER TABLE ONLY public.curr_rate DROP CONSTRAINT curr_rate_to_curr_symbol; publicadminfalse42969121919635260685163cust_creditlmt_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY custinfo ADD CONSTRAINT cust_creditlmt_to_curr_symbol FOREIGN KEY (cust_creditlmt_curr_id) REFERENCES curr_symbol(curr_id); PALTER TABLE ONLY public.custinfo DROP CONSTRAINT cust_creditlmt_to_curr_symbol; publicadminfalse69121961919635260685168cust_to_curr_symbol FK CONSTRAINT}ALTER TABLE ONLY custinfo ADD CONSTRAINT cust_to_curr_symbol FOREIGN KEY (cust_curr_id) REFERENCES curr_symbol(curr_id); FALTER TABLE ONLY public.custinfo DROP CONSTRAINT cust_to_curr_symbol; publicadminfalse19669121919635260685173custinfo_cust_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY custinfo ADD CONSTRAINT custinfo_cust_cntct_id_fkey FOREIGN KEY (cust_cntct_id) REFERENCES cntct(cntct_id); NALTER TABLE ONLY public.custinfo DROP CONSTRAINT custinfo_cust_cntct_id_fkey; publicadminfalse18719668949635260685178custinfo_cust_corrcntct_id_fkey FK CONSTRAINTALTER TABLE ONLY custinfo ADD CONSTRAINT custinfo_cust_corrcntct_id_fkey FOREIGN KEY (cust_corrcntct_id) REFERENCES cntct(cntct_id); RALTER TABLE ONLY public.custinfo DROP CONSTRAINT custinfo_cust_corrcntct_id_fkey; publicadminfalse18719668949635 260685183custinfo_cust_custtype_fkey FK CONSTRAINTALTER TABLE ONLY custinfo ADD CONSTRAINT custinfo_cust_custtype_fkey FOREIGN KEY (cust_custtype_id) REFERENCES custtype(custtype_id) ON UPDATE RESTRICT ON DELETE RESTRICT; NALTER TABLE ONLY public.custinfo DROP CONSTRAINT custinfo_cust_custtype_fkey; publicadminfalse70642361969635 260685188custinfo_cust_salesrep_fkey FK CONSTRAINTALTER TABLE ONLY custinfo ADD CONSTRAINT custinfo_cust_salesrep_fkey FOREIGN KEY (cust_salesrep_id) REFERENCES salesrep(salesrep_id) ON UPDATE RESTRICT ON DELETE RESTRICT; NALTER TABLE ONLY public.custinfo DROP CONSTRAINT custinfo_cust_salesrep_fkey; publicadminfalse19669431999635 260685193custinfo_cust_shipform_fkey FK CONSTRAINTALTER TABLE ONLY custinfo ADD CONSTRAINT custinfo_cust_shipform_fkey FOREIGN KEY (cust_shipform_id) REFERENCES shipform(shipform_id) ON UPDATE RESTRICT ON DELETE RESTRICT; NALTER TABLE ONLY public.custinfo DROP CONSTRAINT custinfo_cust_shipform_fkey; publicadminfalse23819670689635 260685198custinfo_cust_taxzone_id_fkey FK CONSTRAINTALTER TABLE ONLY custinfo ADD CONSTRAINT custinfo_cust_taxzone_id_fkey FOREIGN KEY (cust_taxzone_id) REFERENCES taxzone(taxzone_id); PALTER TABLE ONLY public.custinfo DROP CONSTRAINT custinfo_cust_taxzone_id_fkey; publicadminfalse20319669569635 260685203custinfo_cust_terms_fkey FK CONSTRAINTALTER TABLE ONLY custinfo ADD CONSTRAINT custinfo_cust_terms_fkey FOREIGN KEY (cust_terms_id) REFERENCES terms(terms_id) ON UPDATE RESTRICT ON DELETE RESTRICT; KALTER TABLE ONLY public.custinfo DROP CONSTRAINT custinfo_cust_terms_fkey; publicadminfalse19619269149635S260685208emp_emp_cntct_id_fkey FK CONSTRAINTuALTER TABLE ONLY emp ADD CONSTRAINT emp_emp_cntct_id_fkey FOREIGN KEY (emp_cntct_id) REFERENCES cntct(cntct_id); CALTER TABLE ONLY public.emp DROP CONSTRAINT emp_emp_cntct_id_fkey; publicadminfalse18724268949635T260685213emp_emp_dept_id_fkey FK CONSTRAINTqALTER TABLE ONLY emp ADD CONSTRAINT emp_emp_dept_id_fkey FOREIGN KEY (emp_dept_id) REFERENCES dept(dept_id); BALTER TABLE ONLY public.emp DROP CONSTRAINT emp_emp_dept_id_fkey; publicadminfalse24124270809635U260685218emp_emp_image_id_fkey FK CONSTRAINTuALTER TABLE ONLY emp ADD CONSTRAINT emp_emp_image_id_fkey FOREIGN KEY (emp_image_id) REFERENCES image(image_id); CALTER TABLE ONLY public.emp DROP CONSTRAINT emp_emp_image_id_fkey; publicadminfalse24270262239635V260685223emp_emp_mgr_emp_id_fkey FK CONSTRAINTuALTER TABLE ONLY emp ADD CONSTRAINT emp_emp_mgr_emp_id_fkey FOREIGN KEY (emp_mgr_emp_id) REFERENCES emp(emp_id); EALTER TABLE ONLY public.emp DROP CONSTRAINT emp_emp_mgr_emp_id_fkey; publicadminfalse70862422429635W260685228emp_emp_shift_id_fkey FK CONSTRAINTuALTER TABLE ONLY emp ADD CONSTRAINT emp_emp_shift_id_fkey FOREIGN KEY (emp_shift_id) REFERENCES shift(shift_id); CALTER TABLE ONLY public.emp DROP CONSTRAINT emp_emp_shift_id_fkey; publicadminfalse24270882439635X260685233emp_emp_wage_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY emp ADD CONSTRAINT emp_emp_wage_curr_id_fkey FOREIGN KEY (emp_wage_curr_id) REFERENCES curr_symbol(curr_id); GALTER TABLE ONLY public.emp DROP CONSTRAINT emp_emp_wage_curr_id_fkey; publicadminfalse24269121919635Y260685238emp_emp_warehous_id_fkey FK CONSTRAINTALTER TABLE ONLY emp ADD CONSTRAINT emp_emp_warehous_id_fkey FOREIGN KEY (emp_warehous_id) REFERENCES whsinfo(warehous_id); FALTER TABLE ONLY public.emp DROP CONSTRAINT emp_emp_warehous_id_fkey; publicadminfalse24217668419635260685243!empgrpitem_empgrpitem_emp_id_fkey FK CONSTRAINTALTER TABLE ONLY empgrpitem ADD CONSTRAINT empgrpitem_empgrpitem_emp_id_fkey FOREIGN KEY (empgrpitem_emp_id) REFERENCES emp(emp_id); VALTER TABLE ONLY public.empgrpitem DROP CONSTRAINT empgrpitem_empgrpitem_emp_id_fkey; publicadminfalse24270864489635260685248$empgrpitem_empgrpitem_empgrp_id_fkey FK CONSTRAINTALTER TABLE ONLY empgrpitem ADD CONSTRAINT empgrpitem_empgrpitem_empgrp_id_fkey FOREIGN KEY (empgrpitem_empgrp_id) REFERENCES empgrp(empgrp_id); YALTER TABLE ONLY public.empgrpitem DROP CONSTRAINT empgrpitem_empgrpitem_empgrp_id_fkey; publicadminfalse44844674629635 260685253flnotes_flnotes_flhead_id_fkey FK CONSTRAINTALTER TABLE ONLY flnotes ADD CONSTRAINT flnotes_flnotes_flhead_id_fkey FOREIGN KEY (flnotes_flhead_id) REFERENCES flhead(flhead_id) ON DELETE CASCADE; PALTER TABLE ONLY public.flnotes DROP CONSTRAINT flnotes_flnotes_flhead_id_fkey; publicadminfalse74854624709635 260685258flnotes_flnotes_period_id_fkey FK CONSTRAINTALTER TABLE ONLY flnotes ADD CONSTRAINT flnotes_flnotes_period_id_fkey FOREIGN KEY (flnotes_period_id) REFERENCES period(period_id) ON DELETE CASCADE; PALTER TABLE ONLY public.flnotes DROP CONSTRAINT flnotes_flnotes_period_id_fkey; publicadminfalse70432304709635 260685263grppriv_grppriv_grp_id_fkey FK CONSTRAINT}ALTER TABLE ONLY grppriv ADD CONSTRAINT grppriv_grppriv_grp_id_fkey FOREIGN KEY (grppriv_grp_id) REFERENCES grp(grp_id); MALTER TABLE ONLY public.grppriv DROP CONSTRAINT grppriv_grppriv_grp_id_fkey; publicadminfalse48575074839635260685268incdt_incdt_aropen_id_fkey FK CONSTRAINTALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_aropen_id_fkey FOREIGN KEY (incdt_aropen_id) REFERENCES aropen(aropen_id); JALTER TABLE ONLY public.incdt DROP CONSTRAINT incdt_incdt_aropen_id_fkey; publicadminfalse18969271959635260685273incdt_incdt_cntct_id_fkey FK CONSTRAINT}ALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_cntct_id_fkey FOREIGN KEY (incdt_cntct_id) REFERENCES cntct(cntct_id); IALTER TABLE ONLY public.incdt DROP CONSTRAINT incdt_incdt_cntct_id_fkey; publicadminfalse18718968949635260685278incdt_incdt_crmacct_id_fkey FK CONSTRAINTALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_crmacct_id_fkey FOREIGN KEY (incdt_crmacct_id) REFERENCES crmacct(crmacct_id); KALTER TABLE ONLY public.incdt DROP CONSTRAINT incdt_incdt_crmacct_id_fkey; publicadminfalse68981881899635260685283incdt_incdt_incdtcat_id_fkey FK CONSTRAINTALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_incdtcat_id_fkey FOREIGN KEY (incdt_incdtcat_id) REFERENCES incdtcat(incdtcat_id); LALTER TABLE ONLY public.incdt DROP CONSTRAINT incdt_incdt_incdtcat_id_fkey; publicadminfalse24818971059635260685288!incdt_incdt_incdtpriority_id_fkey FK CONSTRAINTALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_incdtpriority_id_fkey FOREIGN KEY (incdt_incdtpriority_id) REFERENCES incdtpriority(incdtpriority_id); QALTER TABLE ONLY public.incdt DROP CONSTRAINT incdt_incdt_incdtpriority_id_fkey; publicadminfalse18971092499635260685293#incdt_incdt_incdtresolution_id_fkey FK CONSTRAINTALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_incdtresolution_id_fkey FOREIGN KEY (incdt_incdtresolution_id) REFERENCES incdtresolution(incdtresolution_id); SALTER TABLE ONLY public.incdt DROP CONSTRAINT incdt_incdt_incdtresolution_id_fkey; publicadminfalse25018971139635260685298!incdt_incdt_incdtseverity_id_fkey FK CONSTRAINTALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_incdtseverity_id_fkey FOREIGN KEY (incdt_incdtseverity_id) REFERENCES incdtseverity(incdtseverity_id); QALTER TABLE ONLY public.incdt DROP CONSTRAINT incdt_incdt_incdtseverity_id_fkey; publicadminfalse18925171179635260685303incdt_incdt_item_id_fkey FK CONSTRAINTyALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_item_id_fkey FOREIGN KEY (incdt_item_id) REFERENCES item(item_id); HALTER TABLE ONLY public.incdt DROP CONSTRAINT incdt_incdt_item_id_fkey; publicadminfalse68291741899635260685308incdt_incdt_prj_id_fkey FK CONSTRAINTuALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_prj_id_fkey FOREIGN KEY (incdt_prj_id) REFERENCES prj(prj_id); GALTER TABLE ONLY public.incdt DROP CONSTRAINT incdt_incdt_prj_id_fkey; publicadminfalse69701892069635260685313#incdt_incdt_recurring_incdt_id_fkey FK CONSTRAINTALTER TABLE ONLY incdt ADD CONSTRAINT incdt_incdt_recurring_incdt_id_fkey FOREIGN KEY (incdt_recurring_incdt_id) REFERENCES incdt(incdt_id); SALTER TABLE ONLY public.incdt DROP CONSTRAINT incdt_incdt_recurring_incdt_id_fkey; publicadminfalse18918969029635 260685318!incdthist_incdthist_incdt_id_fkey FK CONSTRAINTALTER TABLE ONLY incdthist ADD CONSTRAINT incdthist_incdthist_incdt_id_fkey FOREIGN KEY (incdthist_incdt_id) REFERENCES incdt(incdt_id); UALTER TABLE ONLY public.incdthist DROP CONSTRAINT incdthist_incdthist_incdt_id_fkey; publicadminfalse18949169029635260685323invbal_invbal_itemsite_id_fkey FK CONSTRAINTALTER TABLE ONLY invbal ADD CONSTRAINT invbal_invbal_itemsite_id_fkey FOREIGN KEY (invbal_itemsite_id) REFERENCES itemsite(itemsite_id) ON DELETE CASCADE; OALTER TABLE ONLY public.invbal DROP CONSTRAINT invbal_invbal_itemsite_id_fkey; publicadminfalse18568361759635260685328invbal_invbal_period_id_fkey FK CONSTRAINTALTER TABLE ONLY invbal ADD CONSTRAINT invbal_invbal_period_id_fkey FOREIGN KEY (invbal_period_id) REFERENCES period(period_id) ON DELETE CASCADE; MALTER TABLE ONLY public.invbal DROP CONSTRAINT invbal_invbal_period_id_fkey; publicadminfalse18570432309635$260685333"invchead_invchead_saletype_id_fkey FK CONSTRAINTALTER TABLE ONLY invchead ADD CONSTRAINT invchead_invchead_saletype_id_fkey FOREIGN KEY (invchead_saletype_id) REFERENCES saletype(saletype_id); UALTER TABLE ONLY public.invchead DROP CONSTRAINT invchead_invchead_saletype_id_fkey; publicadminfalse69742072059635%260685338"invchead_invchead_shipzone_id_fkey FK CONSTRAINTALTER TABLE ONLY invchead ADD CONSTRAINT invchead_invchead_shipzone_id_fkey FOREIGN KEY (invchead_shipzone_id) REFERENCES shipzone(shipzone_id); UALTER TABLE ONLY public.invchead DROP CONSTRAINT invchead_invchead_shipzone_id_fkey; publicadminfalse69762082059635&260685343!invchead_invchead_taxzone_id_fkey FK CONSTRAINTALTER TABLE ONLY invchead ADD CONSTRAINT invchead_invchead_taxzone_id_fkey FOREIGN KEY (invchead_taxzone_id) REFERENCES taxzone(taxzone_id); TALTER TABLE ONLY public.invchead DROP CONSTRAINT invchead_invchead_taxzone_id_fkey; publicadminfalse69562032059635'260685348invchead_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY invchead ADD CONSTRAINT invchead_to_curr_symbol FOREIGN KEY (invchead_curr_id) REFERENCES curr_symbol(curr_id); JALTER TABLE ONLY public.invchead DROP CONSTRAINT invchead_to_curr_symbol; publicadminfalse20569121919635 260685353%invcheadtax_taxhist_basis_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY invcheadtax ADD CONSTRAINT invcheadtax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); [ALTER TABLE ONLY public.invcheadtax DROP CONSTRAINT invcheadtax_taxhist_basis_tax_id_fkey; publicadminfalse27549972099635 260685358"invcheadtax_taxhist_parent_id_fkey FK CONSTRAINTALTER TABLE ONLY invcheadtax ADD CONSTRAINT invcheadtax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES invchead(invchead_id) ON DELETE CASCADE; XALTER TABLE ONLY public.invcheadtax DROP CONSTRAINT invcheadtax_taxhist_parent_id_fkey; publicadminfalse69682054999635 260685363invcheadtax_taxhist_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY invcheadtax ADD CONSTRAINT invcheadtax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); UALTER TABLE ONLY public.invcheadtax DROP CONSTRAINT invcheadtax_taxhist_tax_id_fkey; publicadminfalse49927572099635 260685368#invcheadtax_taxhist_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY invcheadtax ADD CONSTRAINT invcheadtax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); YALTER TABLE ONLY public.invcheadtax DROP CONSTRAINT invcheadtax_taxhist_taxtype_id_fkey; publicadminfalse68741824999635,260685373invcitem_invchead_id_fkey FK CONSTRAINTALTER TABLE ONLY invcitem ADD CONSTRAINT invcitem_invchead_id_fkey FOREIGN KEY (invcitem_invchead_id) REFERENCES invchead(invchead_id) ON UPDATE CASCADE ON DELETE CASCADE; LALTER TABLE ONLY public.invcitem DROP CONSTRAINT invcitem_invchead_id_fkey; publicadminfalse69682052099635-260685378#invcitem_invcitem_price_uom_id_fkey FK CONSTRAINTALTER TABLE ONLY invcitem ADD CONSTRAINT invcitem_invcitem_price_uom_id_fkey FOREIGN KEY (invcitem_price_uom_id) REFERENCES uom(uom_id); VALTER TABLE ONLY public.invcitem DROP CONSTRAINT invcitem_invcitem_price_uom_id_fkey; publicadminfalse20968781839635.260685383!invcitem_invcitem_qty_uom_id_fkey FK CONSTRAINTALTER TABLE ONLY invcitem ADD CONSTRAINT invcitem_invcitem_qty_uom_id_fkey FOREIGN KEY (invcitem_qty_uom_id) REFERENCES uom(uom_id); TALTER TABLE ONLY public.invcitem DROP CONSTRAINT invcitem_invcitem_qty_uom_id_fkey; publicadminfalse20968781839635/260685388#invcitem_invcitem_rev_accnt_id_fkey FK CONSTRAINTALTER TABLE ONLY invcitem ADD CONSTRAINT invcitem_invcitem_rev_accnt_id_fkey FOREIGN KEY (invcitem_rev_accnt_id) REFERENCES accnt(accnt_id); VALTER TABLE ONLY public.invcitem DROP CONSTRAINT invcitem_invcitem_rev_accnt_id_fkey; publicadminfalse703822820996350260685393!invcitem_invcitem_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY invcitem ADD CONSTRAINT invcitem_invcitem_taxtype_id_fkey FOREIGN KEY (invcitem_taxtype_id) REFERENCES taxtype(taxtype_id); TALTER TABLE ONLY public.invcitem DROP CONSTRAINT invcitem_invcitem_taxtype_id_fkey; publicadminfalse20968741829635 260685398%invcitemtax_taxhist_basis_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY invcitemtax ADD CONSTRAINT invcitemtax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); [ALTER TABLE ONLY public.invcitemtax DROP CONSTRAINT invcitemtax_taxhist_basis_tax_id_fkey; publicadminfalse50172092759635 260685403"invcitemtax_taxhist_parent_id_fkey FK CONSTRAINTALTER TABLE ONLY invcitemtax ADD CONSTRAINT invcitemtax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES invcitem(invcitem_id) ON DELETE CASCADE; XALTER TABLE ONLY public.invcitemtax DROP CONSTRAINT invcitemtax_taxhist_parent_id_fkey; publicadminfalse69845012099635 260685408invcitemtax_taxhist_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY invcitemtax ADD CONSTRAINT invcitemtax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); UALTER TABLE ONLY public.invcitemtax DROP CONSTRAINT invcitemtax_taxhist_tax_id_fkey; publicadminfalse50172092759635 260685413#invcitemtax_taxhist_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY invcitemtax ADD CONSTRAINT invcitemtax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); YALTER TABLE ONLY public.invcitemtax DROP CONSTRAINT invcitemtax_taxhist_taxtype_id_fkey; publicadminfalse50118268749635 260685418*invhistexpcat_invhistexpcat_expcat_id_fkey FK CONSTRAINTALTER TABLE ONLY invhistexpcat ADD CONSTRAINT invhistexpcat_invhistexpcat_expcat_id_fkey FOREIGN KEY (invhistexpcat_expcat_id) REFERENCES expcat(expcat_id) ON UPDATE CASCADE ON DELETE CASCADE; bALTER TABLE ONLY public.invhistexpcat DROP CONSTRAINT invhistexpcat_invhistexpcat_expcat_id_fkey; publicadminfalse72032735079635 260685423+invhistexpcat_invhistexpcat_invhist_id_fkey FK CONSTRAINTALTER TABLE ONLY invhistexpcat ADD CONSTRAINT invhistexpcat_invhistexpcat_invhist_id_fkey FOREIGN KEY (invhistexpcat_invhist_id) REFERENCES invhist(invhist_id) ON UPDATE CASCADE ON DELETE CASCADE; cALTER TABLE ONLY public.invhistexpcat DROP CONSTRAINT invhistexpcat_invhistexpcat_invhist_id_fkey; publicadminfalse50750575349635v260685428ipsass_ipsass_ipshead_id_fkey FK CONSTRAINTALTER TABLE ONLY ipsass ADD CONSTRAINT ipsass_ipsass_ipshead_id_fkey FOREIGN KEY (ipsass_ipshead_id) REFERENCES ipshead(ipshead_id); NALTER TABLE ONLY public.ipsass DROP CONSTRAINT ipsass_ipsass_ipshead_id_fkey; publicadminfalse26871012479635]260685433*ipsfreight_ipsfreight_freightclass_id_fkey FK CONSTRAINTALTER TABLE ONLY ipsfreight ADD CONSTRAINT ipsfreight_ipsfreight_freightclass_id_fkey FOREIGN KEY (ipsfreight_freightclass_id) REFERENCES freightclass(freightclass_id); _ALTER TABLE ONLY public.ipsfreight DROP CONSTRAINT ipsfreight_ipsfreight_freightclass_id_fkey; publicadminfalse24670952459635^260685438%ipsfreight_ipsfreight_ipshead_id_fkey FK CONSTRAINTALTER TABLE ONLY ipsfreight ADD CONSTRAINT ipsfreight_ipsfreight_ipshead_id_fkey FOREIGN KEY (ipsfreight_ipshead_id) REFERENCES ipshead(ipshead_id); ZALTER TABLE ONLY public.ipsfreight DROP CONSTRAINT ipsfreight_ipsfreight_ipshead_id_fkey; publicadminfalse71012462479635_260685443&ipsfreight_ipsfreight_shipzone_id_fkey FK CONSTRAINTALTER TABLE ONLY ipsfreight ADD CONSTRAINT ipsfreight_ipsfreight_shipzone_id_fkey FOREIGN KEY (ipsfreight_shipzone_id) REFERENCES shipzone(shipzone_id); [ALTER TABLE ONLY public.ipsfreight DROP CONSTRAINT ipsfreight_ipsfreight_shipzone_id_fkey; publicadminfalse69762082469635`260685448&ipsfreight_ipsfreight_warehous_id_fkey FK CONSTRAINTALTER TABLE ONLY ipsfreight ADD CONSTRAINT ipsfreight_ipsfreight_warehous_id_fkey FOREIGN KEY (ipsfreight_warehous_id) REFERENCES whsinfo(warehous_id); [ALTER TABLE ONLY public.ipsfreight DROP CONSTRAINT ipsfreight_ipsfreight_warehous_id_fkey; publicadminfalse68411762469635a260685453ipshead_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY ipshead ADD CONSTRAINT ipshead_to_curr_symbol FOREIGN KEY (ipshead_curr_id) REFERENCES curr_symbol(curr_id); HALTER TABLE ONLY public.ipshead DROP CONSTRAINT ipshead_to_curr_symbol; publicadminfalse24719169129635w260685458ipsitem_ipshead_id_fk FK CONSTRAINTALTER TABLE ONLY ipsiteminfo ADD CONSTRAINT ipsitem_ipshead_id_fk FOREIGN KEY (ipsitem_ipshead_id) REFERENCES ipshead(ipshead_id) ON DELETE CASCADE; KALTER TABLE ONLY public.ipsiteminfo DROP CONSTRAINT ipsitem_ipshead_id_fk; publicadminfalse26924771019635x260685463!ipsitem_ipsitem_price_uom_id_fkey FK CONSTRAINTALTER TABLE ONLY ipsiteminfo ADD CONSTRAINT ipsitem_ipsitem_price_uom_id_fkey FOREIGN KEY (ipsitem_price_uom_id) REFERENCES uom(uom_id); WALTER TABLE ONLY public.ipsiteminfo DROP CONSTRAINT ipsitem_ipsitem_price_uom_id_fkey; publicadminfalse68781832699635y260685468ipsitem_ipsitem_qty_uom_id_fkey FK CONSTRAINTALTER TABLE ONLY ipsiteminfo ADD CONSTRAINT ipsitem_ipsitem_qty_uom_id_fkey FOREIGN KEY (ipsitem_qty_uom_id) REFERENCES uom(uom_id); UALTER TABLE ONLY public.ipsiteminfo DROP CONSTRAINT ipsitem_ipsitem_qty_uom_id_fkey; publicadminfalse26968781839635z260685473 ipsitem_ipsitem_warehous_id_fkey FK CONSTRAINTALTER TABLE ONLY ipsiteminfo ADD CONSTRAINT ipsitem_ipsitem_warehous_id_fkey FOREIGN KEY (ipsitem_warehous_id) REFERENCES whsinfo(warehous_id); VALTER TABLE ONLY public.ipsiteminfo DROP CONSTRAINT ipsitem_ipsitem_warehous_id_fkey; publicadminfalse17626968419635{260685478ipsitem_item_id_fk FK CONSTRAINT{ALTER TABLE ONLY ipsiteminfo ADD CONSTRAINT ipsitem_item_id_fk FOREIGN KEY (ipsitem_item_id) REFERENCES item(item_id); HALTER TABLE ONLY public.ipsiteminfo DROP CONSTRAINT ipsitem_item_id_fk; publicadminfalse68291742699635|260685483$ipsitemchar_ipsitemchar_char_id_fkey FK CONSTRAINTALTER TABLE ONLY ipsitemchar ADD CONSTRAINT ipsitemchar_ipsitemchar_char_id_fkey FOREIGN KEY (ipsitemchar_char_id) REFERENCES "char"(char_id); ZALTER TABLE ONLY public.ipsitemchar DROP CONSTRAINT ipsitemchar_ipsitemchar_char_id_fkey; publicadminfalse27021470039635}260685488'ipsitemchar_ipsitemchar_ipsitem_id_fkey FK CONSTRAINTALTER TABLE ONLY ipsitemchar ADD CONSTRAINT ipsitemchar_ipsitemchar_ipsitem_id_fkey FOREIGN KEY (ipsitemchar_ipsitem_id) REFERENCES ipsiteminfo(ipsitem_id) ON DELETE CASCADE; ]ALTER TABLE ONLY public.ipsitemchar DROP CONSTRAINT ipsitemchar_ipsitemchar_ipsitem_id_fkey; publicadminfalse27026971899635260685493item_item_classcode_id_fkey FK CONSTRAINTALTER TABLE ONLY item ADD CONSTRAINT item_item_classcode_id_fkey FOREIGN KEY (item_classcode_id) REFERENCES classcode(classcode_id); JALTER TABLE ONLY public.item DROP CONSTRAINT item_item_classcode_id_fkey; publicadminfalse25217471219635260685498item_item_freightclass_id_fkey FK CONSTRAINTALTER TABLE ONLY item ADD CONSTRAINT item_item_freightclass_id_fkey FOREIGN KEY (item_freightclass_id) REFERENCES freightclass(freightclass_id); MALTER TABLE ONLY public.item DROP CONSTRAINT item_item_freightclass_id_fkey; publicadminfalse17424570959635260685503item_item_inv_uom_id_fkey FK CONSTRAINTyALTER TABLE ONLY item ADD CONSTRAINT item_item_inv_uom_id_fkey FOREIGN KEY (item_inv_uom_id) REFERENCES uom(uom_id); HALTER TABLE ONLY public.item DROP CONSTRAINT item_item_inv_uom_id_fkey; publicadminfalse17418368789635260685508item_item_price_uom_id_fkey FK CONSTRAINT}ALTER TABLE ONLY item ADD CONSTRAINT item_item_price_uom_id_fkey FOREIGN KEY (item_price_uom_id) REFERENCES uom(uom_id); JALTER TABLE ONLY public.item DROP CONSTRAINT item_item_price_uom_id_fkey; publicadminfalse68781831749635b260685513#itemalias_itemalias_crmacct_id_fkey FK CONSTRAINTALTER TABLE ONLY itemalias ADD CONSTRAINT itemalias_itemalias_crmacct_id_fkey FOREIGN KEY (itemalias_crmacct_id) REFERENCES crmacct(crmacct_id); WALTER TABLE ONLY public.itemalias DROP CONSTRAINT itemalias_itemalias_crmacct_id_fkey; publicadminfalse25468981889635c260685518 itemalias_itemalias_item_id_fkey FK CONSTRAINTALTER TABLE ONLY itemalias ADD CONSTRAINT itemalias_itemalias_item_id_fkey FOREIGN KEY (itemalias_item_id) REFERENCES item(item_id); TALTER TABLE ONLY public.itemalias DROP CONSTRAINT itemalias_itemalias_item_id_fkey; publicadminfalse68291742549635d260685523"itemcost_itemcost_costelem_id_fkey FK CONSTRAINTALTER TABLE ONLY itemcost ADD CONSTRAINT itemcost_itemcost_costelem_id_fkey FOREIGN KEY (itemcost_costelem_id) REFERENCES costelem(costelem_id); UALTER TABLE ONLY public.itemcost DROP CONSTRAINT itemcost_itemcost_costelem_id_fkey; publicadminfalse25525671339635e260685528itemcost_itemcost_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY itemcost ADD CONSTRAINT itemcost_itemcost_curr_id_fkey FOREIGN KEY (itemcost_curr_id) REFERENCES curr_symbol(curr_id); QALTER TABLE ONLY public.itemcost DROP CONSTRAINT itemcost_itemcost_curr_id_fkey; publicadminfalse19125669129635f260685533itemcost_itemcost_item_id_fkey FK CONSTRAINTALTER TABLE ONLY itemcost ADD CONSTRAINT itemcost_itemcost_item_id_fkey FOREIGN KEY (itemcost_item_id) REFERENCES item(item_id); QALTER TABLE ONLY public.itemcost DROP CONSTRAINT itemcost_itemcost_item_id_fkey; publicadminfalse17425668299635g260685538itemcost_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY itemcost ADD CONSTRAINT itemcost_to_curr_symbol FOREIGN KEY (itemcost_curr_id) REFERENCES curr_symbol(curr_id); JALTER TABLE ONLY public.itemcost DROP CONSTRAINT itemcost_to_curr_symbol; publicadminfalse25669121919635260685543!itemsite_itemsite_costcat_id_fkey FK CONSTRAINTALTER TABLE ONLY itemsite ADD CONSTRAINT itemsite_itemsite_costcat_id_fkey FOREIGN KEY (itemsite_costcat_id) REFERENCES costcat(costcat_id); TALTER TABLE ONLY public.itemsite DROP CONSTRAINT itemsite_itemsite_costcat_id_fkey; publicadminfalse71412571759635260685548itemsite_itemsite_item_id_fkey FK CONSTRAINTALTER TABLE ONLY itemsite ADD CONSTRAINT itemsite_itemsite_item_id_fkey FOREIGN KEY (itemsite_item_id) REFERENCES item(item_id); QALTER TABLE ONLY public.itemsite DROP CONSTRAINT itemsite_itemsite_item_id_fkey; publicadminfalse17417568299635260685553"itemsite_itemsite_plancode_id_fkey FK CONSTRAINTALTER TABLE ONLY itemsite ADD CONSTRAINT itemsite_itemsite_plancode_id_fkey FOREIGN KEY (itemsite_plancode_id) REFERENCES plancode(plancode_id); UALTER TABLE ONLY public.itemsite DROP CONSTRAINT itemsite_itemsite_plancode_id_fkey; publicadminfalse17571432589635260685558"itemsite_itemsite_warehous_id_fkey FK CONSTRAINTALTER TABLE ONLY itemsite ADD CONSTRAINT itemsite_itemsite_warehous_id_fkey FOREIGN KEY (itemsite_warehous_id) REFERENCES whsinfo(warehous_id); UALTER TABLE ONLY public.itemsite DROP CONSTRAINT itemsite_itemsite_warehous_id_fkey; publicadminfalse68411761759635i260685563itemsrc_itemsrc_contrct_id_fkey FK CONSTRAINTALTER TABLE ONLY itemsrc ADD CONSTRAINT itemsrc_itemsrc_contrct_id_fkey FOREIGN KEY (itemsrc_contrct_id) REFERENCES contrct(contrct_id); QALTER TABLE ONLY public.itemsrc DROP CONSTRAINT itemsrc_itemsrc_contrct_id_fkey; publicadminfalse71482592609635j260685568itemsrc_itemsrc_item_id_fkey FK CONSTRAINTALTER TABLE ONLY itemsrc ADD CONSTRAINT itemsrc_itemsrc_item_id_fkey FOREIGN KEY (itemsrc_item_id) REFERENCES item(item_id) ON DELETE CASCADE; NALTER TABLE ONLY public.itemsrc DROP CONSTRAINT itemsrc_itemsrc_item_id_fkey; publicadminfalse68291742609635k260685573itemsrc_itemsrc_vend_id_fkey FK CONSTRAINTALTER TABLE ONLY itemsrc ADD CONSTRAINT itemsrc_itemsrc_vend_id_fkey FOREIGN KEY (itemsrc_vend_id) REFERENCES vendinfo(vend_id) ON DELETE CASCADE; NALTER TABLE ONLY public.itemsrc DROP CONSTRAINT itemsrc_itemsrc_vend_id_fkey; publicadminfalse69191932609635l260685578!itemsrcp_itemsrcp_itemsrc_id_fkey FK CONSTRAINTALTER TABLE ONLY itemsrcp ADD CONSTRAINT itemsrcp_itemsrcp_itemsrc_id_fkey FOREIGN KEY (itemsrcp_itemsrc_id) REFERENCES itemsrc(itemsrc_id) ON DELETE CASCADE; TALTER TABLE ONLY public.itemsrcp DROP CONSTRAINT itemsrcp_itemsrcp_itemsrc_id_fkey; publicadminfalse26126071529635m260685583itemsrcp_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY itemsrcp ADD CONSTRAINT itemsrcp_to_curr_symbol FOREIGN KEY (itemsrcp_curr_id) REFERENCES curr_symbol(curr_id); JALTER TABLE ONLY public.itemsrcp DROP CONSTRAINT itemsrcp_to_curr_symbol; publicadminfalse19126169129635n260685588#itemsub_itemsub_parent_item_id_fkey FK CONSTRAINTALTER TABLE ONLY itemsub ADD CONSTRAINT itemsub_itemsub_parent_item_id_fkey FOREIGN KEY (itemsub_parent_item_id) REFERENCES item(item_id); UALTER TABLE ONLY public.itemsub DROP CONSTRAINT itemsub_itemsub_parent_item_id_fkey; publicadminfalse68292621749635o260685593 itemsub_itemsub_sub_item_id_fkey FK CONSTRAINTALTER TABLE ONLY itemsub ADD CONSTRAINT itemsub_itemsub_sub_item_id_fkey FOREIGN KEY (itemsub_sub_item_id) REFERENCES item(item_id); RALTER TABLE ONLY public.itemsub DROP CONSTRAINT itemsub_itemsub_sub_item_id_fkey; publicadminfalse17426268299635p260685598itemtax_itemtax_item_id_fkey FK CONSTRAINTALTER TABLE ONLY itemtax ADD CONSTRAINT itemtax_itemtax_item_id_fkey FOREIGN KEY (itemtax_item_id) REFERENCES item(item_id); NALTER TABLE ONLY public.itemtax DROP CONSTRAINT itemtax_itemtax_item_id_fkey; publicadminfalse68291742639635q260685603itemtax_itemtax_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY itemtax ADD CONSTRAINT itemtax_itemtax_taxtype_id_fkey FOREIGN KEY (itemtax_taxtype_id) REFERENCES taxtype(taxtype_id); QALTER TABLE ONLY public.itemtax DROP CONSTRAINT itemtax_itemtax_taxtype_id_fkey; publicadminfalse68741822639635r260685608itemtax_itemtax_taxzone_id_fkey FK CONSTRAINTALTER TABLE ONLY itemtax ADD CONSTRAINT itemtax_itemtax_taxzone_id_fkey FOREIGN KEY (itemtax_taxzone_id) REFERENCES taxzone(taxzone_id); QALTER TABLE ONLY public.itemtax DROP CONSTRAINT itemtax_itemtax_taxzone_id_fkey; publicadminfalse69562632039635 260685613'itemtrans_itemtrans_source_item_id_fkey FK CONSTRAINTALTER TABLE ONLY itemtrans ADD CONSTRAINT itemtrans_itemtrans_source_item_id_fkey FOREIGN KEY (itemtrans_source_item_id) REFERENCES item(item_id); [ALTER TABLE ONLY public.itemtrans DROP CONSTRAINT itemtrans_itemtrans_source_item_id_fkey; publicadminfalse17454268299635 260685618'itemtrans_itemtrans_target_item_id_fkey FK CONSTRAINTALTER TABLE ONLY itemtrans ADD CONSTRAINT itemtrans_itemtrans_target_item_id_fkey FOREIGN KEY (itemtrans_target_item_id) REFERENCES item(item_id); [ALTER TABLE ONLY public.itemtrans DROP CONSTRAINT itemtrans_itemtrans_target_item_id_fkey; publicadminfalse17454268299635 260685623#itemuom_itemuom_itemuomconv_id_fkey FK CONSTRAINTALTER TABLE ONLY itemuom ADD CONSTRAINT itemuom_itemuom_itemuomconv_id_fkey FOREIGN KEY (itemuom_itemuomconv_id) REFERENCES itemuomconv(itemuomconv_id); UALTER TABLE ONLY public.itemuom DROP CONSTRAINT itemuom_itemuom_itemuomconv_id_fkey; publicadminfalse54426471689635 260685628itemuom_itemuom_uomtype_id_fkey FK CONSTRAINTALTER TABLE ONLY itemuom ADD CONSTRAINT itemuom_itemuom_uomtype_id_fkey FOREIGN KEY (itemuom_uomtype_id) REFERENCES uomtype(uomtype_id); QALTER TABLE ONLY public.itemuom DROP CONSTRAINT itemuom_itemuom_uomtype_id_fkey; publicadminfalse54477486969635s260685633(itemuomconv_itemuomconv_from_uom_id_fkey FK CONSTRAINTALTER TABLE ONLY itemuomconv ADD CONSTRAINT itemuomconv_itemuomconv_from_uom_id_fkey FOREIGN KEY (itemuomconv_from_uom_id) REFERENCES uom(uom_id); ^ALTER TABLE ONLY public.itemuomconv DROP CONSTRAINT itemuomconv_itemuomconv_from_uom_id_fkey; publicadminfalse68781832649635t260685638$itemuomconv_itemuomconv_item_id_fkey FK CONSTRAINTALTER TABLE ONLY itemuomconv ADD CONSTRAINT itemuomconv_itemuomconv_item_id_fkey FOREIGN KEY (itemuomconv_item_id) REFERENCES item(item_id); ZALTER TABLE ONLY public.itemuomconv DROP CONSTRAINT itemuomconv_itemuomconv_item_id_fkey; publicadminfalse26468291749635u260685643&itemuomconv_itemuomconv_to_uom_id_fkey FK CONSTRAINTALTER TABLE ONLY itemuomconv ADD CONSTRAINT itemuomconv_itemuomconv_to_uom_id_fkey FOREIGN KEY (itemuomconv_to_uom_id) REFERENCES uom(uom_id); \ALTER TABLE ONLY public.itemuomconv DROP CONSTRAINT itemuomconv_itemuomconv_to_uom_id_fkey; publicadminfalse26468781839635 260685648mrghist_mrghist_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY mrghist ADD CONSTRAINT mrghist_mrghist_cntct_id_fkey FOREIGN KEY (mrghist_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE; OALTER TABLE ONLY public.mrghist DROP CONSTRAINT mrghist_mrghist_cntct_id_fkey; publicadminfalse567187689496351260685653ophead_ophead_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY ophead ADD CONSTRAINT ophead_ophead_cntct_id_fkey FOREIGN KEY (ophead_cntct_id) REFERENCES cntct(cntct_id); LALTER TABLE ONLY public.ophead DROP CONSTRAINT ophead_ophead_cntct_id_fkey; publicadminfalse210689418796352260685658ophead_ophead_crmacct_id_fkey FK CONSTRAINTALTER TABLE ONLY ophead ADD CONSTRAINT ophead_ophead_crmacct_id_fkey FOREIGN KEY (ophead_crmacct_id) REFERENCES crmacct(crmacct_id); NALTER TABLE ONLY public.ophead DROP CONSTRAINT ophead_ophead_crmacct_id_fkey; publicadminfalse689818821096353260685663ophead_ophead_opsource_id_fkey FK CONSTRAINTALTER TABLE ONLY ophead ADD CONSTRAINT ophead_ophead_opsource_id_fkey FOREIGN KEY (ophead_opsource_id) REFERENCES opsource(opsource_id); OALTER TABLE ONLY public.ophead DROP CONSTRAINT ophead_ophead_opsource_id_fkey; publicadminfalse210760357696354260685668ophead_ophead_opstage_id_fkey FK CONSTRAINTALTER TABLE ONLY ophead ADD CONSTRAINT ophead_ophead_opstage_id_fkey FOREIGN KEY (ophead_opstage_id) REFERENCES opstage(opstage_id); NALTER TABLE ONLY public.ophead DROP CONSTRAINT ophead_ophead_opstage_id_fkey; publicadminfalse210760757896355260685673ophead_ophead_optype_id_fkey FK CONSTRAINTALTER TABLE ONLY ophead ADD CONSTRAINT ophead_ophead_optype_id_fkey FOREIGN KEY (ophead_optype_id) REFERENCES optype(optype_id); MALTER TABLE ONLY public.ophead DROP CONSTRAINT ophead_ophead_optype_id_fkey; publicadminfalse210761158096356260685678ophead_ophead_priority_id_fkey FK CONSTRAINTALTER TABLE ONLY ophead ADD CONSTRAINT ophead_ophead_priority_id_fkey FOREIGN KEY (ophead_priority_id) REFERENCES incdtpriority(incdtpriority_id); OALTER TABLE ONLY public.ophead DROP CONSTRAINT ophead_ophead_priority_id_fkey; publicadminfalse71092102499635 260685683pack_pack_shiphead_id_fkey FK CONSTRAINTALTER TABLE ONLY pack ADD CONSTRAINT pack_pack_shiphead_id_fkey FOREIGN KEY (pack_shiphead_id) REFERENCES shiphead(shiphead_id); IALTER TABLE ONLY public.pack DROP CONSTRAINT pack_pack_shiphead_id_fkey; publicadminfalse41274155849635 260685688payco_payco_ccpay_id_fkey FK CONSTRAINT}ALTER TABLE ONLY payco ADD CONSTRAINT payco_payco_ccpay_id_fkey FOREIGN KEY (payco_ccpay_id) REFERENCES ccpay(ccpay_id); IALTER TABLE ONLY public.payco DROP CONSTRAINT payco_payco_ccpay_id_fkey; publicadminfalse58737373669635 260685693payco_payco_cohead_id_fkey FK CONSTRAINTALTER TABLE ONLY payco ADD CONSTRAINT payco_payco_cohead_id_fkey FOREIGN KEY (payco_cohead_id) REFERENCES cohead(cohead_id); JALTER TABLE ONLY public.payco DROP CONSTRAINT payco_payco_cohead_id_fkey; publicadminfalse68511785879635 260685698$pkgdep_pkgdep_parent_pkghead_id_fkey FK CONSTRAINTALTER TABLE ONLY pkgdep ADD CONSTRAINT pkgdep_pkgdep_parent_pkghead_id_fkey FOREIGN KEY (pkgdep_parent_pkghead_id) REFERENCES pkghead(pkghead_id); UALTER TABLE ONLY public.pkgdep DROP CONSTRAINT pkgdep_pkgdep_parent_pkghead_id_fkey; publicadminfalse58959176319635 260685703pkgdep_pkgdep_pkghead_id_fkey FK CONSTRAINTALTER TABLE ONLY pkgdep ADD CONSTRAINT pkgdep_pkgdep_pkghead_id_fkey FOREIGN KEY (pkgdep_pkghead_id) REFERENCES pkghead(pkghead_id); NALTER TABLE ONLY public.pkgdep DROP CONSTRAINT pkgdep_pkgdep_pkghead_id_fkey; publicadminfalse76315915899635 260685708pkgitem_pkgitem_pkghead_id_fkey FK CONSTRAINTALTER TABLE ONLY pkgitem ADD CONSTRAINT pkgitem_pkgitem_pkghead_id_fkey FOREIGN KEY (pkgitem_pkghead_id) REFERENCES pkghead(pkghead_id) ON DELETE CASCADE; QALTER TABLE ONLY public.pkgitem DROP CONSTRAINT pkgitem_pkgitem_pkghead_id_fkey; publicadminfalse76315935919635260685713pohead_pohead_cohead_id_fkey FK CONSTRAINTALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_cohead_id_fkey FOREIGN KEY (pohead_cohead_id) REFERENCES cohead(cohead_id) ON DELETE SET NULL; MALTER TABLE ONLY public.pohead DROP CONSTRAINT pohead_pohead_cohead_id_fkey; publicadminfalse17868511809635260685718"pohead_pohead_shipto_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_shipto_cntct_id_fkey FOREIGN KEY (pohead_shipto_cntct_id) REFERENCES cntct(cntct_id); SALTER TABLE ONLY public.pohead DROP CONSTRAINT pohead_pohead_shipto_cntct_id_fkey; publicadminfalse18718068949635260685723"pohead_pohead_shiptoddress_id_fkey FK CONSTRAINTALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_shiptoddress_id_fkey FOREIGN KEY (pohead_shiptoaddress_id) REFERENCES addr(addr_id); SALTER TABLE ONLY public.pohead DROP CONSTRAINT pohead_pohead_shiptoddress_id_fkey; publicadminfalse69991802139635260685728pohead_pohead_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_taxtype_id_fkey FOREIGN KEY (pohead_taxtype_id) REFERENCES taxtype(taxtype_id); NALTER TABLE ONLY public.pohead DROP CONSTRAINT pohead_pohead_taxtype_id_fkey; publicadminfalse68741821809635260685733pohead_pohead_taxzone_id_fkey FK CONSTRAINTALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_taxzone_id_fkey FOREIGN KEY (pohead_taxzone_id) REFERENCES taxzone(taxzone_id); NALTER TABLE ONLY public.pohead DROP CONSTRAINT pohead_pohead_taxzone_id_fkey; publicadminfalse18069562039635260685738pohead_pohead_terms_id_fkey FK CONSTRAINTALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_terms_id_fkey FOREIGN KEY (pohead_terms_id) REFERENCES terms(terms_id); LALTER TABLE ONLY public.pohead DROP CONSTRAINT pohead_pohead_terms_id_fkey; publicadminfalse18069141929635260685743 pohead_pohead_vend_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_vend_cntct_id_fkey FOREIGN KEY (pohead_vend_cntct_id) REFERENCES cntct(cntct_id); QALTER TABLE ONLY public.pohead DROP CONSTRAINT pohead_pohead_vend_cntct_id_fkey; publicadminfalse68941871809635260685748pohead_pohead_vend_id_fkey FK CONSTRAINTALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_vend_id_fkey FOREIGN KEY (pohead_vend_id) REFERENCES vendinfo(vend_id); KALTER TABLE ONLY public.pohead DROP CONSTRAINT pohead_pohead_vend_id_fkey; publicadminfalse19318069199635260685753pohead_pohead_vendaddr_id_fkey FK CONSTRAINTALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_vendaddr_id_fkey FOREIGN KEY (pohead_vendaddr_id) REFERENCES vendaddrinfo(vendaddr_id); OALTER TABLE ONLY public.pohead DROP CONSTRAINT pohead_pohead_vendaddr_id_fkey; publicadminfalse72111802769635260685758pohead_pohead_warehous_id_fkey FK CONSTRAINTALTER TABLE ONLY pohead ADD CONSTRAINT pohead_pohead_warehous_id_fkey FOREIGN KEY (pohead_warehous_id) REFERENCES whsinfo(warehous_id); OALTER TABLE ONLY public.pohead DROP CONSTRAINT pohead_pohead_warehous_id_fkey; publicadminfalse68411801769635260685763pohead_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY pohead ADD CONSTRAINT pohead_to_curr_symbol FOREIGN KEY (pohead_curr_id) REFERENCES curr_symbol(curr_id); FALTER TABLE ONLY public.pohead DROP CONSTRAINT pohead_to_curr_symbol; publicadminfalse18019169129635260685768poitem_poitem_expcat_id_fkey FK CONSTRAINTALTER TABLE ONLY poitem ADD CONSTRAINT poitem_poitem_expcat_id_fkey FOREIGN KEY (poitem_expcat_id) REFERENCES expcat(expcat_id); MALTER TABLE ONLY public.poitem DROP CONSTRAINT poitem_poitem_expcat_id_fkey; publicadminfalse27318172039635260685773poitem_poitem_itemsite_id_fkey FK CONSTRAINTALTER TABLE ONLY poitem ADD CONSTRAINT poitem_poitem_itemsite_id_fkey FOREIGN KEY (poitem_itemsite_id) REFERENCES itemsite(itemsite_id); OALTER TABLE ONLY public.poitem DROP CONSTRAINT poitem_poitem_itemsite_id_fkey; publicadminfalse68361751819635260685778poitem_poitem_itemsrc_id_fkey FK CONSTRAINTALTER TABLE ONLY poitem ADD CONSTRAINT poitem_poitem_itemsrc_id_fkey FOREIGN KEY (poitem_itemsrc_id) REFERENCES itemsrc(itemsrc_id); NALTER TABLE ONLY public.poitem DROP CONSTRAINT poitem_poitem_itemsrc_id_fkey; publicadminfalse71521812609635260685783poitem_poitem_prj_id_fkey FK CONSTRAINTyALTER TABLE ONLY poitem ADD CONSTRAINT poitem_poitem_prj_id_fkey FOREIGN KEY (poitem_prj_id) REFERENCES prj(prj_id); JALTER TABLE ONLY public.poitem DROP CONSTRAINT poitem_poitem_prj_id_fkey; publicadminfalse69702061819635260685788poitem_poitem_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY poitem ADD CONSTRAINT poitem_poitem_taxtype_id_fkey FOREIGN KEY (poitem_taxtype_id) REFERENCES taxtype(taxtype_id); NALTER TABLE ONLY public.poitem DROP CONSTRAINT poitem_poitem_taxtype_id_fkey; publicadminfalse18168741829635! 260685793poreject_poreject_recv_id_fkey FK CONSTRAINTALTER TABLE ONLY poreject ADD CONSTRAINT poreject_poreject_recv_id_fkey FOREIGN KEY (poreject_recv_id) REFERENCES recv(recv_id); QALTER TABLE ONLY public.poreject DROP CONSTRAINT poreject_poreject_recv_id_fkey; publicadminfalse59960276409635" 260685798poreject_poreject_vend_id_fkey FK CONSTRAINTALTER TABLE ONLY poreject ADD CONSTRAINT poreject_poreject_vend_id_fkey FOREIGN KEY (poreject_vend_id) REFERENCES vendinfo(vend_id); QALTER TABLE ONLY public.poreject DROP CONSTRAINT poreject_poreject_vend_id_fkey; publicadminfalse19369196029635(260685803prj_prj_cntct_id_fkey FK CONSTRAINTuALTER TABLE ONLY prj ADD CONSTRAINT prj_prj_cntct_id_fkey FOREIGN KEY (prj_cntct_id) REFERENCES cntct(cntct_id); CALTER TABLE ONLY public.prj DROP CONSTRAINT prj_prj_cntct_id_fkey; publicadminfalse18720668949635)260685808prj_prj_crmacct_id_fkey FK CONSTRAINT}ALTER TABLE ONLY prj ADD CONSTRAINT prj_prj_crmacct_id_fkey FOREIGN KEY (prj_crmacct_id) REFERENCES crmacct(crmacct_id); EALTER TABLE ONLY public.prj DROP CONSTRAINT prj_prj_crmacct_id_fkey; publicadminfalse68982061889635*260685813prj_prj_prjtype_id_fkey FK CONSTRAINT}ALTER TABLE ONLY prj ADD CONSTRAINT prj_prj_prjtype_id_fkey FOREIGN KEY (prj_prjtype_id) REFERENCES prjtype(prjtype_id); EALTER TABLE ONLY public.prj DROP CONSTRAINT prj_prj_prjtype_id_fkey; publicadminfalse61476562069635+260685818prj_prj_recurring_prj_id_fkey FK CONSTRAINTALTER TABLE ONLY prj ADD CONSTRAINT prj_prj_recurring_prj_id_fkey FOREIGN KEY (prj_recurring_prj_id) REFERENCES prj(prj_id); KALTER TABLE ONLY public.prj DROP CONSTRAINT prj_prj_recurring_prj_id_fkey; publicadminfalse206206697096357260685823prjtask_prjtask_prj_id_fkey FK CONSTRAINT}ALTER TABLE ONLY prjtask ADD CONSTRAINT prjtask_prjtask_prj_id_fkey FOREIGN KEY (prjtask_prj_id) REFERENCES prj(prj_id); MALTER TABLE ONLY public.prjtask DROP CONSTRAINT prjtask_prjtask_prj_id_fkey; publicadminfalse21120669709635~260685828prospect_prospect_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY prospect ADD CONSTRAINT prospect_prospect_cntct_id_fkey FOREIGN KEY (prospect_cntct_id) REFERENCES cntct(cntct_id); RALTER TABLE ONLY public.prospect DROP CONSTRAINT prospect_prospect_cntct_id_fkey; publicadminfalse68941872729635260685833"prospect_prospect_salesrep_id_fkey FK CONSTRAINTALTER TABLE ONLY prospect ADD CONSTRAINT prospect_prospect_salesrep_id_fkey FOREIGN KEY (prospect_salesrep_id) REFERENCES salesrep(salesrep_id); UALTER TABLE ONLY public.prospect DROP CONSTRAINT prospect_prospect_salesrep_id_fkey; publicadminfalse19927269439635260685838!prospect_prospect_taxzone_id_fkey FK CONSTRAINTALTER TABLE ONLY prospect ADD CONSTRAINT prospect_prospect_taxzone_id_fkey FOREIGN KEY (prospect_taxzone_id) REFERENCES taxzone(taxzone_id); TALTER TABLE ONLY public.prospect DROP CONSTRAINT prospect_prospect_taxzone_id_fkey; publicadminfalse69562032729635260685843"prospect_prospect_warehous_id_fkey FK CONSTRAINTALTER TABLE ONLY prospect ADD CONSTRAINT prospect_prospect_warehous_id_fkey FOREIGN KEY (prospect_warehous_id) REFERENCES whsinfo(warehous_id); UALTER TABLE ONLY public.prospect DROP CONSTRAINT prospect_prospect_warehous_id_fkey; publicadminfalse68411762729635$ 260685848qryitem_qryitem_qryhead_id_fkey FK CONSTRAINTALTER TABLE ONLY qryitem ADD CONSTRAINT qryitem_qryitem_qryhead_id_fkey FOREIGN KEY (qryitem_qryhead_id) REFERENCES qryhead(qryhead_id); QALTER TABLE ONLY public.qryitem DROP CONSTRAINT qryitem_qryitem_qryhead_id_fkey; publicadminfalse61961776609635260685853"quhead_quhead_billto_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_billto_cntct_id_fkey FOREIGN KEY (quhead_billto_cntct_id) REFERENCES cntct(cntct_id); SALTER TABLE ONLY public.quhead DROP CONSTRAINT quhead_quhead_billto_cntct_id_fkey; publicadminfalse27718768949635260685858 quhead_quhead_misc_accnt_id_fkey FK CONSTRAINTALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_misc_accnt_id_fkey FOREIGN KEY (quhead_misc_accnt_id) REFERENCES accnt(accnt_id); QALTER TABLE ONLY public.quhead DROP CONSTRAINT quhead_quhead_misc_accnt_id_fkey; publicadminfalse27770382289635260685863quhead_quhead_ophead_id_fkey FK CONSTRAINTALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_ophead_id_fkey FOREIGN KEY (quhead_ophead_id) REFERENCES ophead(ophead_id); MALTER TABLE ONLY public.quhead DROP CONSTRAINT quhead_quhead_ophead_id_fkey; publicadminfalse69882102779635260685868quhead_quhead_prj_id_fkey FK CONSTRAINTyALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_prj_id_fkey FOREIGN KEY (quhead_prj_id) REFERENCES prj(prj_id); JALTER TABLE ONLY public.quhead DROP CONSTRAINT quhead_quhead_prj_id_fkey; publicadminfalse27769702069635260685873quhead_quhead_salesrep_id_fkey FK CONSTRAINTALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_salesrep_id_fkey FOREIGN KEY (quhead_salesrep_id) REFERENCES salesrep(salesrep_id); OALTER TABLE ONLY public.quhead DROP CONSTRAINT quhead_quhead_salesrep_id_fkey; publicadminfalse69431992779635260685878quhead_quhead_saletype_id_fkey FK CONSTRAINTALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_saletype_id_fkey FOREIGN KEY (quhead_saletype_id) REFERENCES saletype(saletype_id); OALTER TABLE ONLY public.quhead DROP CONSTRAINT quhead_quhead_saletype_id_fkey; publicadminfalse69742072779635260685883"quhead_quhead_shipto_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_shipto_cntct_id_fkey FOREIGN KEY (quhead_shipto_cntct_id) REFERENCES cntct(cntct_id); SALTER TABLE ONLY public.quhead DROP CONSTRAINT quhead_quhead_shipto_cntct_id_fkey; publicadminfalse27768941879635260685888quhead_quhead_shipto_id_fkey FK CONSTRAINTALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_shipto_id_fkey FOREIGN KEY (quhead_shipto_id) REFERENCES shiptoinfo(shipto_id); MALTER TABLE ONLY public.quhead DROP CONSTRAINT quhead_quhead_shipto_id_fkey; publicadminfalse27769542029635260685893quhead_quhead_shipzone_id_fkey FK CONSTRAINTALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_shipzone_id_fkey FOREIGN KEY (quhead_shipzone_id) REFERENCES shipzone(shipzone_id); OALTER TABLE ONLY public.quhead DROP CONSTRAINT quhead_quhead_shipzone_id_fkey; publicadminfalse20827769769635260685898quhead_quhead_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_taxtype_id_fkey FOREIGN KEY (quhead_taxtype_id) REFERENCES taxtype(taxtype_id); NALTER TABLE ONLY public.quhead DROP CONSTRAINT quhead_quhead_taxtype_id_fkey; publicadminfalse68741822779635260685903quhead_quhead_taxzone_id_fkey FK CONSTRAINTALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_taxzone_id_fkey FOREIGN KEY (quhead_taxzone_id) REFERENCES taxzone(taxzone_id); NALTER TABLE ONLY public.quhead DROP CONSTRAINT quhead_quhead_taxzone_id_fkey; publicadminfalse27769562039635260685908quhead_quhead_terms_id_fkey FK CONSTRAINTALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_terms_id_fkey FOREIGN KEY (quhead_terms_id) REFERENCES terms(terms_id); LALTER TABLE ONLY public.quhead DROP CONSTRAINT quhead_quhead_terms_id_fkey; publicadminfalse19227769149635260685913quhead_quhead_warehous_id_fkey FK CONSTRAINTALTER TABLE ONLY quhead ADD CONSTRAINT quhead_quhead_warehous_id_fkey FOREIGN KEY (quhead_warehous_id) REFERENCES whsinfo(warehous_id); OALTER TABLE ONLY public.quhead DROP CONSTRAINT quhead_quhead_warehous_id_fkey; publicadminfalse17627768419635260685918quhead_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY quhead ADD CONSTRAINT quhead_to_curr_symbol FOREIGN KEY (quhead_curr_id) REFERENCES curr_symbol(curr_id); FALTER TABLE ONLY public.quhead DROP CONSTRAINT quhead_to_curr_symbol; publicadminfalse69122771919635260685923quitem_quitem_itemsrc_id_fkey FK CONSTRAINTALTER TABLE ONLY quitem ADD CONSTRAINT quitem_quitem_itemsrc_id_fkey FOREIGN KEY (quitem_itemsrc_id) REFERENCES itemsrc(itemsrc_id); NALTER TABLE ONLY public.quitem DROP CONSTRAINT quitem_quitem_itemsrc_id_fkey; publicadminfalse27871522609635260685928quitem_quitem_price_uom_id_fkey FK CONSTRAINTALTER TABLE ONLY quitem ADD CONSTRAINT quitem_quitem_price_uom_id_fkey FOREIGN KEY (quitem_price_uom_id) REFERENCES uom(uom_id); PALTER TABLE ONLY public.quitem DROP CONSTRAINT quitem_quitem_price_uom_id_fkey; publicadminfalse18327868789635260685933quitem_quitem_qty_uom_id_fkey FK CONSTRAINTALTER TABLE ONLY quitem ADD CONSTRAINT quitem_quitem_qty_uom_id_fkey FOREIGN KEY (quitem_qty_uom_id) REFERENCES uom(uom_id); NALTER TABLE ONLY public.quitem DROP CONSTRAINT quitem_quitem_qty_uom_id_fkey; publicadminfalse68781832789635260685938quitem_quitem_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY quitem ADD CONSTRAINT quitem_quitem_taxtype_id_fkey FOREIGN KEY (quitem_taxtype_id) REFERENCES taxtype(taxtype_id); NALTER TABLE ONLY public.quitem DROP CONSTRAINT quitem_quitem_taxtype_id_fkey; publicadminfalse68741822789635 260685943recv_recv_freight_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY recv ADD CONSTRAINT recv_recv_freight_curr_id_fkey FOREIGN KEY (recv_freight_curr_id) REFERENCES curr_symbol(curr_id); MALTER TABLE ONLY public.recv DROP CONSTRAINT recv_recv_freight_curr_id_fkey; publicadminfalse69121915999635 260685948recv_recv_itemsite_id_fkey FK CONSTRAINTALTER TABLE ONLY recv ADD CONSTRAINT recv_recv_itemsite_id_fkey FOREIGN KEY (recv_itemsite_id) REFERENCES itemsite(itemsite_id); IALTER TABLE ONLY public.recv DROP CONSTRAINT recv_recv_itemsite_id_fkey; publicadminfalse68361755999635 260685953 recv_recv_purchcost_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY recv ADD CONSTRAINT recv_recv_purchcost_curr_id_fkey FOREIGN KEY (recv_purchcost_curr_id) REFERENCES curr_symbol(curr_id); OALTER TABLE ONLY public.recv DROP CONSTRAINT recv_recv_purchcost_curr_id_fkey; publicadminfalse59969121919635 260685958recv_recv_recvcost_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY recv ADD CONSTRAINT recv_recv_recvcost_curr_id_fkey FOREIGN KEY (recv_recvcost_curr_id) REFERENCES curr_symbol(curr_id); NALTER TABLE ONLY public.recv DROP CONSTRAINT recv_recv_recvcost_curr_id_fkey; publicadminfalse59969121919635 260685963recv_recv_splitfrom_id_fkey FK CONSTRAINTALTER TABLE ONLY recv ADD CONSTRAINT recv_recv_splitfrom_id_fkey FOREIGN KEY (recv_splitfrom_id) REFERENCES recv(recv_id); JALTER TABLE ONLY public.recv DROP CONSTRAINT recv_recv_splitfrom_id_fkey; publicadminfalse59959976409635 260685968recv_recv_vend_id_fkey FK CONSTRAINTyALTER TABLE ONLY recv ADD CONSTRAINT recv_recv_vend_id_fkey FOREIGN KEY (recv_vend_id) REFERENCES vendinfo(vend_id); EALTER TABLE ONLY public.recv DROP CONSTRAINT recv_recv_vend_id_fkey; publicadminfalse69191935999635 260685973recv_recv_vohead_id_fkey FK CONSTRAINT}ALTER TABLE ONLY recv ADD CONSTRAINT recv_recv_vohead_id_fkey FOREIGN KEY (recv_vohead_id) REFERENCES vohead(vohead_id); GALTER TABLE ONLY public.recv DROP CONSTRAINT recv_recv_vohead_id_fkey; publicadminfalse77617135999635 260685978recv_recv_voitem_id_fkey FK CONSTRAINT}ALTER TABLE ONLY recv ADD CONSTRAINT recv_recv_voitem_id_fkey FOREIGN KEY (recv_voitem_id) REFERENCES voitem(voitem_id); GALTER TABLE ONLY public.recv DROP CONSTRAINT recv_recv_voitem_id_fkey; publicadminfalse59971677709635260685983salesrep_salesrep_emp_id_fkey FK CONSTRAINTALTER TABLE ONLY salesrep ADD CONSTRAINT salesrep_salesrep_emp_id_fkey FOREIGN KEY (salesrep_emp_id) REFERENCES emp(emp_id); PALTER TABLE ONLY public.salesrep DROP CONSTRAINT salesrep_salesrep_emp_id_fkey; publicadminfalse19924270869635Z260685988+shipdata_shipdata_base_freight_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY shipdata ADD CONSTRAINT shipdata_shipdata_base_freight_curr_id_fkey FOREIGN KEY (shipdata_base_freight_curr_id) REFERENCES curr_symbol(curr_id); ^ALTER TABLE ONLY public.shipdata DROP CONSTRAINT shipdata_shipdata_base_freight_curr_id_fkey; publicadminfalse24469121919635[260685993&shipdata_shipdata_shiphead_number_fkey FK CONSTRAINTALTER TABLE ONLY shipdata ADD CONSTRAINT shipdata_shipdata_shiphead_number_fkey FOREIGN KEY (shipdata_shiphead_number) REFERENCES shiphead(shiphead_number); YALTER TABLE ONLY public.shipdata DROP CONSTRAINT shipdata_shipdata_shiphead_number_fkey; publicadminfalse41224474179635\260685998,shipdata_shipdata_total_freight_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY shipdata ADD CONSTRAINT shipdata_shipdata_total_freight_curr_id_fkey FOREIGN KEY (shipdata_total_freight_curr_id) REFERENCES curr_symbol(curr_id); _ALTER TABLE ONLY public.shipdata DROP CONSTRAINT shipdata_shipdata_total_freight_curr_id_fkey; publicadminfalse19169122449635% 2606860031shipdatasum_shipdatasum_base_freight_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY shipdatasum ADD CONSTRAINT shipdatasum_shipdatasum_base_freight_curr_id_fkey FOREIGN KEY (shipdatasum_base_freight_curr_id) REFERENCES curr_symbol(curr_id); gALTER TABLE ONLY public.shipdatasum DROP CONSTRAINT shipdatasum_shipdatasum_base_freight_curr_id_fkey; publicadminfalse69121916449635& 260686008,shipdatasum_shipdatasum_shiphead_number_fkey FK CONSTRAINTALTER TABLE ONLY shipdatasum ADD CONSTRAINT shipdatasum_shipdatasum_shiphead_number_fkey FOREIGN KEY (shipdatasum_shiphead_number) REFERENCES shiphead(shiphead_number); bALTER TABLE ONLY public.shipdatasum DROP CONSTRAINT shipdatasum_shipdatasum_shiphead_number_fkey; publicadminfalse74174126449635' 2606860132shipdatasum_shipdatasum_total_freight_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY shipdatasum ADD CONSTRAINT shipdatasum_shipdatasum_total_freight_curr_id_fkey FOREIGN KEY (shipdatasum_total_freight_curr_id) REFERENCES curr_symbol(curr_id); hALTER TABLE ONLY public.shipdatasum DROP CONSTRAINT shipdatasum_shipdatasum_total_freight_curr_id_fkey; publicadminfalse64419169129635260686018&shiphead_shiphead_freight_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY shiphead ADD CONSTRAINT shiphead_shiphead_freight_curr_id_fkey FOREIGN KEY (shiphead_freight_curr_id) REFERENCES curr_symbol(curr_id); YALTER TABLE ONLY public.shiphead DROP CONSTRAINT shiphead_shiphead_freight_curr_id_fkey; publicadminfalse69121914129635260686023"shiphead_shiphead_shipchrg_id_fkey FK CONSTRAINTALTER TABLE ONLY shiphead ADD CONSTRAINT shiphead_shiphead_shipchrg_id_fkey FOREIGN KEY (shiphead_shipchrg_id) REFERENCES shipchrg(shipchrg_id); UALTER TABLE ONLY public.shiphead DROP CONSTRAINT shiphead_shiphead_shipchrg_id_fkey; publicadminfalse41270662379635260686028"shiphead_shiphead_shipform_id_fkey FK CONSTRAINTALTER TABLE ONLY shiphead ADD CONSTRAINT shiphead_shiphead_shipform_id_fkey FOREIGN KEY (shiphead_shipform_id) REFERENCES shipform(shipform_id); UALTER TABLE ONLY public.shiphead DROP CONSTRAINT shiphead_shiphead_shipform_id_fkey; publicadminfalse41223870689635260686033"shipitem_shipitem_invcitem_id_fkey FK CONSTRAINTALTER TABLE ONLY shipitem ADD CONSTRAINT shipitem_shipitem_invcitem_id_fkey FOREIGN KEY (shipitem_invcitem_id) REFERENCES invcitem(invcitem_id); UALTER TABLE ONLY public.shipitem DROP CONSTRAINT shipitem_shipitem_invcitem_id_fkey; publicadminfalse41320969849635260686038!shipitem_shipitem_invhist_id_fkey FK CONSTRAINTALTER TABLE ONLY shipitem ADD CONSTRAINT shipitem_shipitem_invhist_id_fkey FOREIGN KEY (shipitem_invhist_id) REFERENCES invhist(invhist_id); TALTER TABLE ONLY public.shipitem DROP CONSTRAINT shipitem_shipitem_invhist_id_fkey; publicadminfalse41375345059635260686043"shipitem_shipitem_shiphead_id_fkey FK CONSTRAINTALTER TABLE ONLY shipitem ADD CONSTRAINT shipitem_shipitem_shiphead_id_fkey FOREIGN KEY (shipitem_shiphead_id) REFERENCES shiphead(shiphead_id); UALTER TABLE ONLY public.shipitem DROP CONSTRAINT shipitem_shipitem_shiphead_id_fkey; publicadminfalse74154124139635260686048shiptoinfo_shipto_addr_id_fkey FK CONSTRAINTALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shiptoinfo_shipto_addr_id_fkey FOREIGN KEY (shipto_addr_id) REFERENCES addr(addr_id); SALTER TABLE ONLY public.shiptoinfo DROP CONSTRAINT shiptoinfo_shipto_addr_id_fkey; publicadminfalse69992132029635260686053shiptoinfo_shipto_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shiptoinfo_shipto_cntct_id_fkey FOREIGN KEY (shipto_cntct_id) REFERENCES cntct(cntct_id); TALTER TABLE ONLY public.shiptoinfo DROP CONSTRAINT shiptoinfo_shipto_cntct_id_fkey; publicadminfalse18720268949635260686058shiptoinfo_shipto_cust_id_fkey FK CONSTRAINTALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shiptoinfo_shipto_cust_id_fkey FOREIGN KEY (shipto_cust_id) REFERENCES custinfo(cust_id); SALTER TABLE ONLY public.shiptoinfo DROP CONSTRAINT shiptoinfo_shipto_cust_id_fkey; publicadminfalse19620269319635260686063shiptoinfo_shipto_salesrep_fkey FK CONSTRAINTALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shiptoinfo_shipto_salesrep_fkey FOREIGN KEY (shipto_salesrep_id) REFERENCES salesrep(salesrep_id) ON UPDATE RESTRICT ON DELETE RESTRICT; TALTER TABLE ONLY public.shiptoinfo DROP CONSTRAINT shiptoinfo_shipto_salesrep_fkey; publicadminfalse19969432029635260686068"shiptoinfo_shipto_salesrep_id_fkey FK CONSTRAINTALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shiptoinfo_shipto_salesrep_id_fkey FOREIGN KEY (shipto_salesrep_id) REFERENCES salesrep(salesrep_id); WALTER TABLE ONLY public.shiptoinfo DROP CONSTRAINT shiptoinfo_shipto_salesrep_id_fkey; publicadminfalse19920269439635260686073shiptoinfo_shipto_shipform_fkey FK CONSTRAINTALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shiptoinfo_shipto_shipform_fkey FOREIGN KEY (shipto_shipform_id) REFERENCES shipform(shipform_id) ON UPDATE RESTRICT ON DELETE RESTRICT; TALTER TABLE ONLY public.shiptoinfo DROP CONSTRAINT shiptoinfo_shipto_shipform_fkey; publicadminfalse70682382029635260686078"shiptoinfo_shipto_shipform_id_fkey FK CONSTRAINTALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shiptoinfo_shipto_shipform_id_fkey FOREIGN KEY (shipto_shipform_id) REFERENCES shipform(shipform_id); WALTER TABLE ONLY public.shiptoinfo DROP CONSTRAINT shiptoinfo_shipto_shipform_id_fkey; publicadminfalse70682382029635260686083"shiptoinfo_shipto_shipzone_id_fkey FK CONSTRAINTALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shiptoinfo_shipto_shipzone_id_fkey FOREIGN KEY (shipto_shipzone_id) REFERENCES shipzone(shipzone_id); WALTER TABLE ONLY public.shiptoinfo DROP CONSTRAINT shiptoinfo_shipto_shipzone_id_fkey; publicadminfalse69762082029635260686088!shiptoinfo_shipto_taxzone_id_fkey FK CONSTRAINTALTER TABLE ONLY shiptoinfo ADD CONSTRAINT shiptoinfo_shipto_taxzone_id_fkey FOREIGN KEY (shipto_taxzone_id) REFERENCES taxzone(taxzone_id); VALTER TABLE ONLY public.shiptoinfo DROP CONSTRAINT shiptoinfo_shipto_taxzone_id_fkey; publicadminfalse69562032029635( 260686093state_state_country_id_fkey FK CONSTRAINTALTER TABLE ONLY state ADD CONSTRAINT state_state_country_id_fkey FOREIGN KEY (state_country_id) REFERENCES country(country_id); KALTER TABLE ONLY public.state DROP CONSTRAINT state_state_country_id_fkey; publicadminfalse66042474339635260686098tax_tax_basis_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY tax ADD CONSTRAINT tax_tax_basis_tax_id_fkey FOREIGN KEY (tax_basis_tax_id) REFERENCES tax(tax_id) ON DELETE CASCADE; GALTER TABLE ONLY public.tax DROP CONSTRAINT tax_tax_basis_tax_id_fkey; publicadminfalse72092752759635260686103tax_tax_sales_accnt_id_fkey FK CONSTRAINTALTER TABLE ONLY tax ADD CONSTRAINT tax_tax_sales_accnt_id_fkey FOREIGN KEY (tax_sales_accnt_id) REFERENCES accnt(accnt_id); IALTER TABLE ONLY public.tax DROP CONSTRAINT tax_tax_sales_accnt_id_fkey; publicadminfalse22827570389635260686108tax_tax_taxauth_id_fkey FK CONSTRAINT}ALTER TABLE ONLY tax ADD CONSTRAINT tax_tax_taxauth_id_fkey FOREIGN KEY (tax_taxauth_id) REFERENCES taxauth(taxauth_id); EALTER TABLE ONLY public.tax DROP CONSTRAINT tax_tax_taxauth_id_fkey; publicadminfalse70722392759635260686113tax_tax_taxclass_id_fkey FK CONSTRAINTALTER TABLE ONLY tax ADD CONSTRAINT tax_tax_taxclass_id_fkey FOREIGN KEY (tax_taxclass_id) REFERENCES taxclass(taxclass_id); FALTER TABLE ONLY public.tax DROP CONSTRAINT tax_tax_taxclass_id_fkey; publicadminfalse27577376809635) 260686118taxass_taxass_tax_id_fkey FK CONSTRAINTyALTER TABLE ONLY taxass ADD CONSTRAINT taxass_taxass_tax_id_fkey FOREIGN KEY (taxass_tax_id) REFERENCES tax(tax_id); JALTER TABLE ONLY public.taxass DROP CONSTRAINT taxass_taxass_tax_id_fkey; publicadminfalse27567772099635* 260686123taxass_taxass_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY taxass ADD CONSTRAINT taxass_taxass_taxtype_id_fkey FOREIGN KEY (taxass_taxtype_id) REFERENCES taxtype(taxtype_id); NALTER TABLE ONLY public.taxass DROP CONSTRAINT taxass_taxass_taxtype_id_fkey; publicadminfalse18267768749635+ 260686128taxass_taxass_taxzone_id_fkey FK CONSTRAINTALTER TABLE ONLY taxass ADD CONSTRAINT taxass_taxass_taxzone_id_fkey FOREIGN KEY (taxass_taxzone_id) REFERENCES taxzone(taxzone_id); NALTER TABLE ONLY public.taxass DROP CONSTRAINT taxass_taxass_taxzone_id_fkey; publicadminfalse67720369569635N260686133taxauth_taxauth_accnt_id_fkey FK CONSTRAINTALTER TABLE ONLY taxauth ADD CONSTRAINT taxauth_taxauth_accnt_id_fkey FOREIGN KEY (taxauth_accnt_id) REFERENCES accnt(accnt_id); OALTER TABLE ONLY public.taxauth DROP CONSTRAINT taxauth_taxauth_accnt_id_fkey; publicadminfalse23970382289635O260686138taxauth_taxauth_addr_id_fkey FK CONSTRAINTALTER TABLE ONLY taxauth ADD CONSTRAINT taxauth_taxauth_addr_id_fkey FOREIGN KEY (taxauth_addr_id) REFERENCES addr(addr_id); NALTER TABLE ONLY public.taxauth DROP CONSTRAINT taxauth_taxauth_addr_id_fkey; publicadminfalse23921369999635P260686143taxauth_taxauth_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY taxauth ADD CONSTRAINT taxauth_taxauth_curr_id_fkey FOREIGN KEY (taxauth_curr_id) REFERENCES curr_symbol(curr_id); NALTER TABLE ONLY public.taxauth DROP CONSTRAINT taxauth_taxauth_curr_id_fkey; publicadminfalse19123969129635260686148taxhist_taxhist_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY taxhist ADD CONSTRAINT taxhist_taxhist_curr_id_fkey FOREIGN KEY (taxhist_curr_id) REFERENCES curr_symbol(curr_id); NALTER TABLE ONLY public.taxhist DROP CONSTRAINT taxhist_taxhist_curr_id_fkey; publicadminfalse69121912819635260686153taxhist_taxhist_tax_id_fkey FK CONSTRAINT}ALTER TABLE ONLY taxhist ADD CONSTRAINT taxhist_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); MALTER TABLE ONLY public.taxhist DROP CONSTRAINT taxhist_taxhist_tax_id_fkey; publicadminfalse28127572099635260686158taxhist_taxhist_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY taxhist ADD CONSTRAINT taxhist_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); QALTER TABLE ONLY public.taxhist DROP CONSTRAINT taxhist_taxhist_taxtype_id_fkey; publicadminfalse68741822819635, 260686163taxrate_taxrate_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY taxrate ADD CONSTRAINT taxrate_taxrate_curr_id_fkey FOREIGN KEY (taxrate_curr_id) REFERENCES curr_symbol(curr_id); NALTER TABLE ONLY public.taxrate DROP CONSTRAINT taxrate_taxrate_curr_id_fkey; publicadminfalse69121916839635- 260686168taxrate_taxrate_tax_id_fkey FK CONSTRAINT}ALTER TABLE ONLY taxrate ADD CONSTRAINT taxrate_taxrate_tax_id_fkey FOREIGN KEY (taxrate_tax_id) REFERENCES tax(tax_id); MALTER TABLE ONLY public.taxrate DROP CONSTRAINT taxrate_taxrate_tax_id_fkey; publicadminfalse72092756839635Q260686173taxreg_taxreg_taxauth_id_fkey FK CONSTRAINTALTER TABLE ONLY taxreg ADD CONSTRAINT taxreg_taxreg_taxauth_id_fkey FOREIGN KEY (taxreg_taxauth_id) REFERENCES taxauth(taxauth_id); NALTER TABLE ONLY public.taxreg DROP CONSTRAINT taxreg_taxreg_taxauth_id_fkey; publicadminfalse70722392409635R260686178taxreg_taxreg_taxzone_id_fkey FK CONSTRAINTALTER TABLE ONLY taxreg ADD CONSTRAINT taxreg_taxreg_taxzone_id_fkey FOREIGN KEY (taxreg_taxzone_id) REFERENCES taxzone(taxzone_id); NALTER TABLE ONLY public.taxreg DROP CONSTRAINT taxreg_taxreg_taxzone_id_fkey; publicadminfalse695620324096358260686183todoitem_todoitem_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY todoitem ADD CONSTRAINT todoitem_todoitem_cntct_id_fkey FOREIGN KEY (todoitem_cntct_id) REFERENCES cntct(cntct_id); RALTER TABLE ONLY public.todoitem DROP CONSTRAINT todoitem_todoitem_cntct_id_fkey; publicadminfalse187212689496359260686188!todoitem_todoitem_crmacct_id_fkey FK CONSTRAINTALTER TABLE ONLY todoitem ADD CONSTRAINT todoitem_todoitem_crmacct_id_fkey FOREIGN KEY (todoitem_crmacct_id) REFERENCES crmacct(crmacct_id); TALTER TABLE ONLY public.todoitem DROP CONSTRAINT todoitem_todoitem_crmacct_id_fkey; publicadminfalse68981882129635:260686193todoitem_todoitem_incdt_id_fkey FK CONSTRAINTALTER TABLE ONLY todoitem ADD CONSTRAINT todoitem_todoitem_incdt_id_fkey FOREIGN KEY (todoitem_incdt_id) REFERENCES incdt(incdt_id); RALTER TABLE ONLY public.todoitem DROP CONSTRAINT todoitem_todoitem_incdt_id_fkey; publicadminfalse69021892129635;260686198 todoitem_todoitem_ophead_id_fkey FK CONSTRAINTALTER TABLE ONLY todoitem ADD CONSTRAINT todoitem_todoitem_ophead_id_fkey FOREIGN KEY (todoitem_ophead_id) REFERENCES ophead(ophead_id) ON UPDATE RESTRICT ON DELETE RESTRICT; SALTER TABLE ONLY public.todoitem DROP CONSTRAINT todoitem_todoitem_ophead_id_fkey; publicadminfalse21021269889635<260686203,todoitem_todoitem_recurring_todoitem_id_fkey FK CONSTRAINTALTER TABLE ONLY todoitem ADD CONSTRAINT todoitem_todoitem_recurring_todoitem_id_fkey FOREIGN KEY (todoitem_recurring_todoitem_id) REFERENCES todoitem(todoitem_id); _ALTER TABLE ONLY public.todoitem DROP CONSTRAINT todoitem_todoitem_recurring_todoitem_id_fkey; publicadminfalse69942122129635. 260686208#trgthist_trgthist_src_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY trgthist ADD CONSTRAINT trgthist_trgthist_src_cntct_id_fkey FOREIGN KEY (trgthist_src_cntct_id) REFERENCES cntctmrgd(cntctmrgd_cntct_id) ON DELETE CASCADE; VALTER TABLE ONLY public.trgthist DROP CONSTRAINT trgthist_trgthist_src_cntct_id_fkey; publicadminfalse73883966909635/ 260686213$trgthist_trgthist_trgt_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY trgthist ADD CONSTRAINT trgthist_trgthist_trgt_cntct_id_fkey FOREIGN KEY (trgthist_trgt_cntct_id) REFERENCES cntct(cntct_id) ON DELETE CASCADE; WALTER TABLE ONLY public.trgthist DROP CONSTRAINT trgthist_trgthist_trgt_cntct_id_fkey; publicadminfalse689418769096350 260686218 uomconv_uomconv_from_uom_id_fkey FK CONSTRAINTALTER TABLE ONLY uomconv ADD CONSTRAINT uomconv_uomconv_from_uom_id_fkey FOREIGN KEY (uomconv_from_uom_id) REFERENCES uom(uom_id); RALTER TABLE ONLY public.uomconv DROP CONSTRAINT uomconv_uomconv_from_uom_id_fkey; publicadminfalse687818369496351 260686223uomconv_uomconv_to_uom_id_fkey FK CONSTRAINTALTER TABLE ONLY uomconv ADD CONSTRAINT uomconv_uomconv_to_uom_id_fkey FOREIGN KEY (uomconv_to_uom_id) REFERENCES uom(uom_id); PALTER TABLE ONLY public.uomconv DROP CONSTRAINT uomconv_uomconv_to_uom_id_fkey; publicadminfalse18369468789635# 260686228usrgrp_usrgrp_grp_id_fkey FK CONSTRAINTyALTER TABLE ONLY usrgrp ADD CONSTRAINT usrgrp_usrgrp_grp_id_fkey FOREIGN KEY (usrgrp_grp_id) REFERENCES grp(grp_id); JALTER TABLE ONLY public.usrgrp DROP CONSTRAINT usrgrp_usrgrp_grp_id_fkey; publicadminfalse60875074839635260686233vend_to_curr_symbol FK CONSTRAINT}ALTER TABLE ONLY vendinfo ADD CONSTRAINT vend_to_curr_symbol FOREIGN KEY (vend_curr_id) REFERENCES curr_symbol(curr_id); FALTER TABLE ONLY public.vendinfo DROP CONSTRAINT vend_to_curr_symbol; publicadminfalse69121911939635260686238vend_vend_cntct1_id_fkey FK CONSTRAINTALTER TABLE ONLY vendinfo ADD CONSTRAINT vend_vend_cntct1_id_fkey FOREIGN KEY (vend_cntct1_id) REFERENCES cntct(cntct_id); KALTER TABLE ONLY public.vendinfo DROP CONSTRAINT vend_vend_cntct1_id_fkey; publicadminfalse68941931879635260686243vend_vend_cntct2_id_fkey FK CONSTRAINTALTER TABLE ONLY vendinfo ADD CONSTRAINT vend_vend_cntct2_id_fkey FOREIGN KEY (vend_cntct2_id) REFERENCES cntct(cntct_id); KALTER TABLE ONLY public.vendinfo DROP CONSTRAINT vend_vend_cntct2_id_fkey; publicadminfalse68941871939635260686248"vendaddrinfo_vendaddr_addr_id_fkey FK CONSTRAINTALTER TABLE ONLY vendaddrinfo ADD CONSTRAINT vendaddrinfo_vendaddr_addr_id_fkey FOREIGN KEY (vendaddr_addr_id) REFERENCES addr(addr_id); YALTER TABLE ONLY public.vendaddrinfo DROP CONSTRAINT vendaddrinfo_vendaddr_addr_id_fkey; publicadminfalse69992132769635260686253#vendaddrinfo_vendaddr_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY vendaddrinfo ADD CONSTRAINT vendaddrinfo_vendaddr_cntct_id_fkey FOREIGN KEY (vendaddr_cntct_id) REFERENCES cntct(cntct_id); ZALTER TABLE ONLY public.vendaddrinfo DROP CONSTRAINT vendaddrinfo_vendaddr_cntct_id_fkey; publicadminfalse27668941879635260686258%vendaddrinfo_vendaddr_taxzone_id_fkey FK CONSTRAINTALTER TABLE ONLY vendaddrinfo ADD CONSTRAINT vendaddrinfo_vendaddr_taxzone_id_fkey FOREIGN KEY (vendaddr_taxzone_id) REFERENCES taxzone(taxzone_id); \ALTER TABLE ONLY public.vendaddrinfo DROP CONSTRAINT vendaddrinfo_vendaddr_taxzone_id_fkey; publicadminfalse27669562039635260686263vendinfo_vend_addr_id_fkey FK CONSTRAINT}ALTER TABLE ONLY vendinfo ADD CONSTRAINT vendinfo_vend_addr_id_fkey FOREIGN KEY (vend_addr_id) REFERENCES addr(addr_id); MALTER TABLE ONLY public.vendinfo DROP CONSTRAINT vendinfo_vend_addr_id_fkey; publicadminfalse19369992139635260686268vendinfo_vend_taxzone_id_fkey FK CONSTRAINTALTER TABLE ONLY vendinfo ADD CONSTRAINT vendinfo_vend_taxzone_id_fkey FOREIGN KEY (vend_taxzone_id) REFERENCES taxzone(taxzone_id); PALTER TABLE ONLY public.vendinfo DROP CONSTRAINT vendinfo_vend_taxzone_id_fkey; publicadminfalse69562031939635260686273vendinfo_vend_vendtype_id_fkey FK CONSTRAINTALTER TABLE ONLY vendinfo ADD CONSTRAINT vendinfo_vend_vendtype_id_fkey FOREIGN KEY (vend_vendtype_id) REFERENCES vendtype(vendtype_id); QALTER TABLE ONLY public.vendinfo DROP CONSTRAINT vendinfo_vend_vendtype_id_fkey; publicadminfalse193724928596352 260686278vohead_to_curr_symbol FK CONSTRAINTALTER TABLE ONLY vohead ADD CONSTRAINT vohead_to_curr_symbol FOREIGN KEY (vohead_curr_id) REFERENCES curr_symbol(curr_id); FALTER TABLE ONLY public.vohead DROP CONSTRAINT vohead_to_curr_symbol; publicadminfalse691219171396353 260686283 vohead_vohead_adjtaxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY vohead ADD CONSTRAINT vohead_vohead_adjtaxtype_id_fkey FOREIGN KEY (vohead_adjtaxtype_id) REFERENCES taxtype(taxtype_id); QALTER TABLE ONLY public.vohead DROP CONSTRAINT vohead_vohead_adjtaxtype_id_fkey; publicadminfalse713687418296354 260686288$vohead_vohead_freighttaxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY vohead ADD CONSTRAINT vohead_vohead_freighttaxtype_id_fkey FOREIGN KEY (vohead_freighttaxtype_id) REFERENCES taxtype(taxtype_id); UALTER TABLE ONLY public.vohead DROP CONSTRAINT vohead_vohead_freighttaxtype_id_fkey; publicadminfalse713182687496355 260686293vohead_vohead_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY vohead ADD CONSTRAINT vohead_vohead_taxtype_id_fkey FOREIGN KEY (vohead_taxtype_id) REFERENCES taxtype(taxtype_id); NALTER TABLE ONLY public.vohead DROP CONSTRAINT vohead_vohead_taxtype_id_fkey; publicadminfalse182713687496356 260686298vohead_vohead_taxzone_id_fkey FK CONSTRAINTALTER TABLE ONLY vohead ADD CONSTRAINT vohead_vohead_taxzone_id_fkey FOREIGN KEY (vohead_taxzone_id) REFERENCES taxzone(taxzone_id); NALTER TABLE ONLY public.vohead DROP CONSTRAINT vohead_vohead_taxzone_id_fkey; publicadminfalse695620371396357 260686303vohead_vohead_vend_id_fkey FK CONSTRAINTALTER TABLE ONLY vohead ADD CONSTRAINT vohead_vohead_vend_id_fkey FOREIGN KEY (vohead_vend_id) REFERENCES vendinfo(vend_id); KALTER TABLE ONLY public.vohead DROP CONSTRAINT vohead_vohead_vend_id_fkey; publicadminfalse691919371396358 260686308#voheadtax_taxhist_basis_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY voheadtax ADD CONSTRAINT voheadtax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); WALTER TABLE ONLY public.voheadtax DROP CONSTRAINT voheadtax_taxhist_basis_tax_id_fkey; publicadminfalse275715720996359 260686313 voheadtax_taxhist_parent_id_fkey FK CONSTRAINTALTER TABLE ONLY voheadtax ADD CONSTRAINT voheadtax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES vohead(vohead_id) ON DELETE CASCADE; TALTER TABLE ONLY public.voheadtax DROP CONSTRAINT voheadtax_taxhist_parent_id_fkey; publicadminfalse71377617159635: 260686318voheadtax_taxhist_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY voheadtax ADD CONSTRAINT voheadtax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); QALTER TABLE ONLY public.voheadtax DROP CONSTRAINT voheadtax_taxhist_tax_id_fkey; publicadminfalse72097152759635; 260686323!voheadtax_taxhist_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY voheadtax ADD CONSTRAINT voheadtax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); UALTER TABLE ONLY public.voheadtax DROP CONSTRAINT voheadtax_taxhist_taxtype_id_fkey; publicadminfalse71568741829635< 260686328voitem_voitem_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY voitem ADD CONSTRAINT voitem_voitem_taxtype_id_fkey FOREIGN KEY (voitem_taxtype_id) REFERENCES taxtype(taxtype_id); NALTER TABLE ONLY public.voitem DROP CONSTRAINT voitem_voitem_taxtype_id_fkey; publicadminfalse71618268749635= 260686333#voitemtax_taxhist_basis_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY voitemtax ADD CONSTRAINT voitemtax_taxhist_basis_tax_id_fkey FOREIGN KEY (taxhist_basis_tax_id) REFERENCES tax(tax_id); WALTER TABLE ONLY public.voitemtax DROP CONSTRAINT voitemtax_taxhist_basis_tax_id_fkey; publicadminfalse27571872099635> 260686338 voitemtax_taxhist_parent_id_fkey FK CONSTRAINTALTER TABLE ONLY voitemtax ADD CONSTRAINT voitemtax_taxhist_parent_id_fkey FOREIGN KEY (taxhist_parent_id) REFERENCES voitem(voitem_id) ON DELETE CASCADE; TALTER TABLE ONLY public.voitemtax DROP CONSTRAINT voitemtax_taxhist_parent_id_fkey; publicadminfalse77707187169635? 260686343voitemtax_taxhist_tax_id_fkey FK CONSTRAINTALTER TABLE ONLY voitemtax ADD CONSTRAINT voitemtax_taxhist_tax_id_fkey FOREIGN KEY (taxhist_tax_id) REFERENCES tax(tax_id); QALTER TABLE ONLY public.voitemtax DROP CONSTRAINT voitemtax_taxhist_tax_id_fkey; publicadminfalse72097182759635@ 260686348!voitemtax_taxhist_taxtype_id_fkey FK CONSTRAINTALTER TABLE ONLY voitemtax ADD CONSTRAINT voitemtax_taxhist_taxtype_id_fkey FOREIGN KEY (taxhist_taxtype_id) REFERENCES taxtype(taxtype_id); UALTER TABLE ONLY public.voitemtax DROP CONSTRAINT voitemtax_taxhist_taxtype_id_fkey; publicadminfalse71868741829635260686353whsinfo_warehous_accnt_id_fkey FK CONSTRAINTALTER TABLE ONLY whsinfo ADD CONSTRAINT whsinfo_warehous_accnt_id_fkey FOREIGN KEY (warehous_default_accnt_id) REFERENCES accnt(accnt_id); PALTER TABLE ONLY public.whsinfo DROP CONSTRAINT whsinfo_warehous_accnt_id_fkey; publicadminfalse17670382289635260686358whsinfo_warehous_addr_id_fkey FK CONSTRAINTALTER TABLE ONLY whsinfo ADD CONSTRAINT whsinfo_warehous_addr_id_fkey FOREIGN KEY (warehous_addr_id) REFERENCES addr(addr_id); OALTER TABLE ONLY public.whsinfo DROP CONSTRAINT whsinfo_warehous_addr_id_fkey; publicadminfalse69991762139635260686363whsinfo_warehous_cntct_id_fkey FK CONSTRAINTALTER TABLE ONLY whsinfo ADD CONSTRAINT whsinfo_warehous_cntct_id_fkey FOREIGN KEY (warehous_cntct_id) REFERENCES cntct(cntct_id); PALTER TABLE ONLY public.whsinfo DROP CONSTRAINT whsinfo_warehous_cntct_id_fkey; publicadminfalse68941761879635260686368 whsinfo_warehous_costcat_id_fkey FK CONSTRAINTALTER TABLE ONLY whsinfo ADD CONSTRAINT whsinfo_warehous_costcat_id_fkey FOREIGN KEY (warehous_costcat_id) REFERENCES costcat(costcat_id); RALTER TABLE ONLY public.whsinfo DROP CONSTRAINT whsinfo_warehous_costcat_id_fkey; publicadminfalse71412571769635260686373!whsinfo_warehous_shipform_id_fkey FK CONSTRAINTALTER TABLE ONLY whsinfo ADD CONSTRAINT whsinfo_warehous_shipform_id_fkey FOREIGN KEY (warehous_shipform_id) REFERENCES shipform(shipform_id); SALTER TABLE ONLY public.whsinfo DROP CONSTRAINT whsinfo_warehous_shipform_id_fkey; publicadminfalse70682381769635260686378 whsinfo_warehous_shipvia_id_fkey FK CONSTRAINTALTER TABLE ONLY whsinfo ADD CONSTRAINT whsinfo_warehous_shipvia_id_fkey FOREIGN KEY (warehous_shipvia_id) REFERENCES shipvia(shipvia_id); RALTER TABLE ONLY public.whsinfo DROP CONSTRAINT whsinfo_warehous_shipvia_id_fkey; publicadminfalse28317672419635260686383!whsinfo_warehous_sitetype_id_fkey FK CONSTRAINTALTER TABLE ONLY whsinfo ADD CONSTRAINT whsinfo_warehous_sitetype_id_fkey FOREIGN KEY (warehous_sitetype_id) REFERENCES sitetype(sitetype_id); SALTER TABLE ONLY public.whsinfo DROP CONSTRAINT whsinfo_warehous_sitetype_id_fkey; publicadminfalse28472451769635260686388 whsinfo_warehous_taxzone_id_fkey FK CONSTRAINTALTER TABLE ONLY whsinfo ADD CONSTRAINT whsinfo_warehous_taxzone_id_fkey FOREIGN KEY (warehous_taxzone_id) REFERENCES taxzone(taxzone_id); RALTER TABLE ONLY public.whsinfo DROP CONSTRAINT whsinfo_warehous_taxzone_id_fkey; publicadminfalse17669562039635260686393wo_wo_womatl_id_fkey FK CONSTRAINTALTER TABLE ONLY wo ADD CONSTRAINT wo_wo_womatl_id_fkey FOREIGN KEY (wo_womatl_id) REFERENCES womatl(womatl_id) ON DELETE SET NULL; AALTER TABLE ONLY public.wo DROP CONSTRAINT wo_wo_womatl_id_fkey; publicadminfalse72062744449635260686398womatl_womatl_uom_id_fkey FK CONSTRAINTyALTER TABLE ONLY womatl ADD CONSTRAINT womatl_womatl_uom_id_fkey FOREIGN KEY (womatl_uom_id) REFERENCES uom(uom_id); JALTER TABLE ONLY public.womatl DROP CONSTRAINT womatl_womatl_uom_id_fkey; publicadminfalse27468781839635A 260686403%womatlpost_womatlpost_invhist_id_fkey FK CONSTRAINTALTER TABLE ONLY womatlpost ADD CONSTRAINT womatlpost_womatlpost_invhist_id_fkey FOREIGN KEY (womatlpost_invhist_id) REFERENCES invhist(invhist_id); ZALTER TABLE ONLY public.womatlpost DROP CONSTRAINT womatlpost_womatlpost_invhist_id_fkey; publicadminfalse75345057249635B 260686408$womatlpost_womatlpost_womatl_id_fkey FK CONSTRAINTALTER TABLE ONLY womatlpost ADD CONSTRAINT womatlpost_womatlpost_womatl_id_fkey FOREIGN KEY (womatlpost_womatl_id) REFERENCES womatl(womatl_id) ON DELETE CASCADE; YALTER TABLE ONLY public.womatlpost DROP CONSTRAINT womatlpost_womatlpost_womatl_id_fkey; publicadminfalse72062747249635C 260686413pkgcmdarg_cmdarg_cmd_id_fkey FK CONSTRAINTALTER TABLE ONLY pkgcmdarg ADD CONSTRAINT pkgcmdarg_cmdarg_cmd_id_fkey FOREIGN KEY (cmdarg_cmd_id) REFERENCES pkgcmd(cmd_id); LALTER TABLE ONLY te.pkgcmdarg DROP CONSTRAINT pkgcmdarg_cmdarg_cmd_id_fkey; teadminfalse73373477889635D 260686418"tecustrate_tecustrate_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY tecustrate ADD CONSTRAINT tecustrate_tecustrate_curr_id_fkey FOREIGN KEY (tecustrate_curr_id) REFERENCES public.curr_symbol(curr_id) ON DELETE SET DEFAULT; SALTER TABLE ONLY te.tecustrate DROP CONSTRAINT tecustrate_tecustrate_curr_id_fkey; teadminfalse69121917419635E 260686423"tecustrate_tecustrate_cust_id_fkey FK CONSTRAINTALTER TABLE ONLY tecustrate ADD CONSTRAINT tecustrate_tecustrate_cust_id_fkey FOREIGN KEY (tecustrate_cust_id) REFERENCES public.custinfo(cust_id) ON DELETE CASCADE; SALTER TABLE ONLY te.tecustrate DROP CONSTRAINT tecustrate_tecustrate_cust_id_fkey; teadminfalse19674169319635F 260686428teemp_teemp_emp_id_fkey FK CONSTRAINTALTER TABLE ONLY teemp ADD CONSTRAINT teemp_teemp_emp_id_fkey FOREIGN KEY (teemp_emp_id) REFERENCES public.emp(emp_id) ON DELETE CASCADE; CALTER TABLE ONLY te.teemp DROP CONSTRAINT teemp_teemp_emp_id_fkey; teadminfalse74324270869635G 260686433teitem_teitem_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY teitem ADD CONSTRAINT teitem_teitem_curr_id_fkey FOREIGN KEY (teitem_curr_id) REFERENCES public.curr_symbol(curr_id) ON DELETE SET DEFAULT; GALTER TABLE ONLY te.teitem DROP CONSTRAINT teitem_teitem_curr_id_fkey; teadminfalse69127491919635H 260686438teitem_teitem_invcitem_id_fkey FK CONSTRAINTALTER TABLE ONLY teitem ADD CONSTRAINT teitem_teitem_invcitem_id_fkey FOREIGN KEY (teitem_invcitem_id) REFERENCES public.invcitem(invcitem_id) ON DELETE SET NULL; KALTER TABLE ONLY te.teitem DROP CONSTRAINT teitem_teitem_invcitem_id_fkey; teadminfalse69842097499635K 2606153485teitem_teitem_prjtask_id_fkey FK CONSTRAINTALTER TABLE ONLY teitem ADD CONSTRAINT teitem_teitem_prjtask_id_fkey FOREIGN KEY (teitem_prjtask_id) REFERENCES public.prjtask(prjtask_id); JALTER TABLE ONLY te.teitem DROP CONSTRAINT teitem_teitem_prjtask_id_fkey; teadminfalse74969902119635I 260686443teitem_teitem_tehead_id_fkey FK CONSTRAINTALTER TABLE ONLY teitem ADD CONSTRAINT teitem_teitem_tehead_id_fkey FOREIGN KEY (teitem_tehead_id) REFERENCES tehead(tehead_id) ON DELETE CASCADE; IALTER TABLE ONLY te.teitem DROP CONSTRAINT teitem_teitem_tehead_id_fkey; teadminfalse74774978089635J 260686448teitem_teitem_vodist_id_fkey FK CONSTRAINTALTER TABLE ONLY teitem ADD CONSTRAINT teitem_teitem_vodist_id_fkey FOREIGN KEY (teitem_vodist_id) REFERENCES public.vodist(vodist_id) ON DELETE SET NULL; IALTER TABLE ONLY te.teitem DROP CONSTRAINT teitem_teitem_vodist_id_fkey; teadminfalse77597117499635L 260686453teprj_teprj_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY teprj ADD CONSTRAINT teprj_teprj_curr_id_fkey FOREIGN KEY (teprj_curr_id) REFERENCES public.curr_symbol(curr_id) ON DELETE SET NULL; DALTER TABLE ONLY te.teprj DROP CONSTRAINT teprj_teprj_curr_id_fkey; teadminfalse69121917519635M 260686458teprj_teprj_cust_id_fkey FK CONSTRAINTALTER TABLE ONLY teprj ADD CONSTRAINT teprj_teprj_cust_id_fkey FOREIGN KEY (teprj_cust_id) REFERENCES public.custinfo(cust_id) ON DELETE SET NULL; DALTER TABLE ONLY te.teprj DROP CONSTRAINT teprj_teprj_cust_id_fkey; teadminfalse19669317519635N 260686463 teprjtask_teprjtask_curr_id_fkey FK CONSTRAINTALTER TABLE ONLY teprjtask ADD CONSTRAINT teprjtask_teprjtask_curr_id_fkey FOREIGN KEY (teprjtask_curr_id) REFERENCES public.curr_symbol(curr_id) ON DELETE SET DEFAULT; PALTER TABLE ONLY te.teprjtask DROP CONSTRAINT teprjtask_teprjtask_curr_id_fkey; teadminfalse75369121919635O 260686468 teprjtask_teprjtask_item_id_fkey FK CONSTRAINTALTER TABLE ONLY teprjtask ADD CONSTRAINT teprjtask_teprjtask_item_id_fkey FOREIGN KEY (teprjtask_item_id) REFERENCES public.item(item_id) ON DELETE SET NULL; PALTER TABLE ONLY te.teprjtask DROP CONSTRAINT teprjtask_teprjtask_item_id_fkey; teadminfalse17475368299635P 260686478pkgcmdarg_cmdarg_cmd_id_fkey FK CONSTRAINTALTER TABLE ONLY pkgcmdarg ADD CONSTRAINT pkgcmdarg_cmdarg_cmd_id_fkey FOREIGN KEY (cmdarg_cmd_id) REFERENCES pkgcmd(cmd_id); SALTER TABLE ONLY xtdesktop.pkgcmdarg DROP CONSTRAINT pkgcmdarg_cmdarg_cmd_id_fkey;  xtdesktopadminfalse75675578219635# x# x# x#9xQo0ǟOqKȔV{˺l-m"܂ ٦kl$!?wZwѓOYq\!Z `0xHI~bGSİ8A“@J8$vI H g3 wdpDdLc0;`$$׌S (e,"9KIAt[Uě2q*F9zjpaz2Ҕ=RYfOW)b'EOpu9N]o[[ƴ  `8 ^dx[n#b! :tLqH>pOͥy2qAuut&$ _ujA$U]}s!\W'7U̧b>c"4ڍ[\]?rn.PIIQXX[:̼t1'<[y_}ZX4bUCq6XyG'q]Av(r2 ԶZA@7DRG;J%T<[|,X/bP14D7&oJ}XWn~KW}Ks- =SyOۛ;4~+:5F#]' k4ڎ76=kW7a|OG]$hӑꞎq'{ёN{=9񓽒Mq2YmM 7[ٷ]6  7'=B8е.86sn-#"f 1τvW /N4Os tin{=ompzkX8z Caց./>e@I) #Jbʘ:L)v܁ O]ƃ;OenDG駪)zEuUԋ. &Oȥъ=zL c;(Mo""0 #U*F(j2e'[g.frn T NZoMl&2?ݯ>@Vd 0MxOi1JZDHxH^:,t/[z Qe/&?ŰD1D9D1Op+Sh0e=$|!ÄID^YDoZڌto B[;Qb6345ً)%)ZB$v?G>\xMK0f֋ӱ݃3I8g81%0'ha bpS'T~qbp^z%E%QuaV6IT#ҙ+g{gNbDp5!vC| 4+NB|TT/؆j]2wF*oF{U],VQaEaA7X"hu!arYӿ 4t0XW; pUW*kr@U]G5VuAQo a6=mYfE3X E#Pq.WJ:{@|-Xԫ֦b(7@0& 25A.\#V4 gC k uF"8r(cS%Tj@U]5&Ka93n<ҝ+AM\XƋ,O"GȩC ll:5ضKv cb~I͘Ew|EH|Q+#SLg䪚 :cYFdI% 4*{H~#e!CPYB+$J!,H.TAsX,:@>qrh!3jONpSQ3YOq%0hR;zDm$0w* M`ؒD 6?arۯ;dz4a nR{JJ7BF\.ׂR+kt) :~>Y</^?]2KIi#ooy+ynHsE{"d\~'1gCuGOAnKg|yrRmlL''&.+y i kJVj]K7x?#͎*rEz%]$V赮~S{ 祒M6nNN]WݹFN@jҭu}]WrbAzW`2<WV6.!s[0߲TU;n6$P~@ .тB>!bvi16ʱ<  *׉USzH|wC/ΏFJѮO7~ $lN<ͯ32tc%|bU\/ $a@~4*Z@2-V* ŬԊ*wo;0ԷM%) Բ' Ni$[Ÿgtt7_?k#E3k b{f#s=N) o+j#s=gg[lLJ /|F˩qYOs[Rv MPVUP'SJE"q' /^+f#S xZmo8 ?4-P[v^ڞx&馀m^v (hR*Qwo^-i.m`XÙ ×;3h9eVZai`X_f>-g|s߆s9 tɃ4Lm#xbopX>e=J~ἶQЕL%9De;W, \rt+Et8Z.Akwp|š|Hu 36,ݥbKUα~PLuC2R":ek'uY\&nR *0,LF&mw9*b Qe?Hp/wWFRK9R \UmmpZ+!ZYfbW xʄy{k;jYd RQ⯝Ӛ? 2 "N\L蔉  cq k*Qq>8qޛZW*:b-{s}\t}FU=Oy:KQ/lM q]*Mv`N=Q+S]7IGψ_d]$YwHh^c,Tz+(dbug4b5ܝ.(9#d g8؏ ~ CTኪ4d4G˼<1`3U!zXM~Uݩ.$DA"4*C$HE $g6[&<ԄBB=̌L GH!myD8V=Z%h ih"y I/0JQu=u@E4sXT*1dAVfYDsȴO%WcE<1p'rF`닉ń<L/3pN `t+ Di$)+cUiDaH|={.&xvɂ+_JK4>!M6M j>m {?R/Z9x>BG[LrSH+LؐuTEiGGtf̃ :ק4 >릱&{˻ɫj9jdII{ CZxѠu4WG|JhD`R~pdcլH`MPFy}H#,Im@9l[mo)iUD&e&Æ* UL!*pѱ.| VY![d#׸eKk&[l(TCؠ1IR8ɺ'W48D2A}vchmhژdˋw>l^Y{)Q3dVP** 紭DRd.`l2f*q ouo64Ue0ײ) y?wR%۰Ξ AkCǫ5hLeg^jߧ"x7Wm75HT(yic_˵)B qy$w4W.\G+<{kcuiaеW\A^c$ۆwaN,^)VyuK )G"z=/# x#AxVr8}VB?߱Y YBf/UỳLIr*n<|[vH)ٖ O;~KR*Vs B44/( { ‡c G{J^`lE" \ℇՏF|ЉN]lǨ]apZlz.U(ò tiFֵWxNŎ jn\̄X&CahcǣN>N,!-qlSxq\Ҿ h R(+D{zY_I!IGY(6J}Ia` {M N 𒖔r{ [h "@=3Fl ?]=b :HR};\os]W}u9ye*( @' /)~vUvಇ! !DbB]ihW }]x`ydu`dKoCb`p #o箆F;">seE(5BP^3aj;Ե@@7^5fž#Q !3#< HI?arj,I#CC['q.]PF E@c-Y'+Z7-rR1AqkcQ00p.iȑ)GgwP2^R80. lX.D0Q^bFN-c Ifݾ94{h!hɈ63^?}c&> w Klė  4#x6)jOZeVԗOu7V9ް"nB^ǀOSxoELYQuSUаbxKHJn]8D总yA[yз(8E~|٬;KלKi_ @E#(“8ǼB?~R`[g-Ս.i] /Á#x0 Eg+1 @QXʣ>Z+r{$@Α6P8O(瀚zVær z%D@ 0UKn[>E,eD#+;$6?-$xѻ0C,f_ǒLtAtxߓ{IDl#3x34MSO,J/-N Q ' LT \1z\\\0$ x2$ x4$ x6$ x7$ x_# x9$ x;$ x<$ x>$ xd# x# x# xe# x#x109Ew*N^n3 3KQbq~җ+R$8mNl0%nk_]?HXΧ#nDd5A5`j"D& pT51QmL FUAUTZUAPUjLAթvDujթ#SoGTގN/C šC$ x# x#Qx36tv qu4t/.QpN,IM/T0042,8 ,NK# ˘J1~@QC=...M#Jx3M,I-L,?N]C.N̢Ĥ"p\ #9#3/U,(#51EڔprjM$x10{$s sO"E"A`[  B&M!4ao!/o`X'WfN+ʒSDCE\i9Z+uXiс5dH*zI*OsX}S8FI|~48Hb>gR3O$ xP$xZKoJv^ .R/K-JrۘMbKH_G^"? , yf;UEwV_OQŪ>ߩm }\׉Y$xN槼0Pن"Q jf(usVENQҗFa!54 qovi!wh욝؊=߶â5?m"K0co<ˈe 6̖(uš4ۢH|EEFPsW7Uߜ65GcrDBӔ S'qN%YmԜ9hN4|٫vu|zC>mZVsIKi䐓cj`?df,e ŵBj.Y"=&9\IbZvF';߀SozzGvCQ5)E#ݐWL,g@&~>Od?RZj;ϞLw ^.&f +V:?RbdX!ɟN-ģ #4lZ]j%MZϪ϶ ǣ,W8UӼ*D`]xFټK^m[՛9J'BFLn f ;5"H3ㆊp|j *[ jZq PCkHa "mp:bQB)[ ֧ * Eu8b5霞؆ .}f=L[5r]pԚc@4,(ibV ?(+6lֶ\Z l]YȾrgZ9)sMCKUE%Rvd nFy@C*dVk¡ -;伦R N 뫴@H_PMTm8ƞR%@`H(4܀maZw}ye.#(LAL?a)sw"Y(72\Gm$6lc6?$VO?sn lw-D80уPI◴|U+:Wj{ Qx~2.D{6Ǔ&$y1xp6+޳ nf2z '< G OkOn鶒jivbIop==AC?C9̛sSy03 Q#YRKB{9Dxd׋{^A\%Xu Z%GJxO폐@TqxS=·o}|(k4ir$Dӗ};Ӱ_0GpYý-t,(يBuczWe 4gʗ" 3Z4cN.6#(4ua_ʷ 0|:=.:L66F&ԁkk:UR 1T(Y cRH.uehP(d\9> f) VK.WD>&#"x^PܦKhJ hUI=bMWטcIڳ] m 8t%v2c~7;D4g;Zsʣk՘{ ί̫Mp#p>gDmWSS)uWX\AI=q1PHd8L$VJFĢĚ Eܲ șAvꟴk9ʵl5>-t}и󇝼Mc^gΟ9tF5͇o\(= ɦ83=nRlS:)`>Ns~;lCHG>)j矅H=%P)OGoGUz ga(JJ9X ;r69'jSP|` +Nu4N)2L4n0T\ Z\N&Oy ]c&cf-Ca<ҴT섮:óDq,~@L.C mR%/>a{l+/5/iu`6ҙ '(/NB>y,k7^RPCMTO 8H)lj"7ta"`V.td6 T5 ӄ|wP+.l;`FGtbD3Oř 5}RgRňϣI[Bة(3ξc3$$Eo,BA-^D|CcIOڞ1 0iAl*y\9zZsu:,cTF㥃iHg <\Q<=9¯'p\}|cPs9z<`ס1Q OG5_2P|aHU8tV`ѬKͺYaJ,g=,3mM>̀tӧ'L;`8{7Vp|@< ãLԃڈ[ݑKhhBwD =ue}5Hw99hlCcd&4K| p@V(8 9?6w@vJצP V Y}6^Q ،eߟ'LEt'A>4͹Rմ[H.͓*KM("B1{YӉT&HH1Os=Ir Yȕ=#%ꃺW||:=VMN717J<)nqu*8`=oBHD@BC(ĭΟ>;U׆"b M|ܞ𣷒eWܱMqS }d|w)%Y zm>@<{'OtF5AÖ#Tc0R|RgC~~UG6)iύ8xr\x(w@"zP{ÊR9V,`ʏχ]AS˾C[dQ5R#ˏi3](VSy]Cن4`97^>Oxs(ߣd3c{w~olۮoɐl-G LQ-G:*o7>ֿ]77x"$E^Gu)_^6`=$koҝm -NP0@Ϟx\ ¶ƖG>-B sޖЉlb~qM cZA.?CR5" i1֏ gɶЪd/}^zWK)zXj?(R<@D@`&IM@cy. &un[D|@UrVd- 7@Ak\mN)S3Xu].H?v6}a([EdȲswʚOw-{}%z2]rXKYZжӦ嘖??heӪ1r̢Me\o2?hyKˢPfy$~S&.-hzZBoC3ZЀ{66$1[q%G#wnL}$0L2 eU`?$bu[&ˀWa*-6ivYhz5PE}ZMh&n4Yt|yPV"DY\9!JWUɅlb1G R&&/ڠ0e?jmnd+sEir -"Cc^_;Zaՠ>RV`>Sy7GI?ލN]gލ곉0ܵI@wNS'aKm#x344+LIUNI-,#,$ AjY\RX_Dq "7-=˘b us\> !%%P/*$V(8deT G1 b*L+F RT$ xU$%x3443NCKs]C 4242bp#;x3LtJ,NUp.-*JKTUpHKOUp,VKMN-.N,T vY$bx=ȱ@0S$E$Z^mg2S!6 22E ->x^E+KGx{! vm-$V$'ߩhmQPVJ[$ x]$ xt# x#)x3u/MQp.-.M-L A#6x3usM+MKL.)-K2tttL,.)J,O a$ x# x#Sx3ttLL,"a$D&e%qrCMK'42AjTc,he$ xg$ xi$ xk$x];1 zrP켜 !roOgdpLmx++:hh8j*(d2$*nӄ) 9-!k& WP7ІL-yk8Z]Gy ʓDؐ_yRTͷ1q˯{)aជm$xVr6 }?8cVڋ;XfZ#ndR%x ^$K:N2c%"2!a₉7ѠR(zu7^&x18Zz)zcõ&'(OPhdUAN.V@ YIAI8Y545WqAofHrs;nLdPң:ֽgpPG!MµQ|[(&F~} zrQ&\|0Rp)luDo]TrNRVj\iDQ 4hy`'fI M<̎2fh*vjK2/e 61g֑ w$ò"WE} l-'TN+vc#1M_&ޖ2{ ]c=>lg6`\J.- nT=u+#wU ʯQ=$9w' Lu!K0$YA4 ;OpBpXw6vdJW=,s pF5/qQ}@V p.t t5zlUwd{m)|vN8wm@xC4 Ԥ t#Mf ג\C \zh.v/ƛNjyj8Y*+pmNs}'. ە%0\>Lo xQ%UfA%|{78FF68 %K.iC[5m}*? yC9JHkȀWfuu"FĮ~g7vŵ6rw}_s\|cF/0xX#xuM 0ر.;6C Z3C?Ƅx^h9 QhhY(VE{L#X 7, K$r˒3i,۩yU̝lYtYҀ*O]{k:|7leG,^ft?)K # xq$ xs$ xw$xMn006$YMk uVJABuUBa`>y3J('8^u'aIop GVi.⎑a'30C9` `yf<>N(ᆁs_ Uވ6BEA3{ePZеZ""{A{pn[&ߴ@3 kPĤkk;2SGq<\Y;ckζAE9};B7HD Rmz\%/,,Yemat}i]q|ovxue )gR0(M6nMXi;c&:`]u9E}~JDc1፤!(Gq%z%9Tu[Q<e*$y$xV]0}N~E@;?yn2]iT,D@DPl: {In !=" `apj$ZoᲚSm\x4@'w. =c/a_nQޥ&"$29O 'GR4}&lw4WaTmS$-GN--De]o?S#kV =k@@}bt? C?tB =dI$KCDP#%2 mk}ROU_yahH8Iﳌ Yv2Bȉt/dNf1ZlcKO<̲t3y$MbTYRۂP@Hk$<Ź90{vylURSzȳ-y y94oaJ;r/nSAƿExٸN z>ll oCaEAy!'eLנ@"Dumျ/R?cڡZ Q/d+C=?0[K`^/_:Cg6zcT-˯t@$}1!XW.G_]u,u$x34tJ,LVpJIKNUHM-D)$r?b' 24Z䙗 4h`nj^ '.#OfP)8'g(-P@CK8=\C}4BC}C=|Ãt R !M,.s,F CJ`v$x= 0_ZrP3k Վ4%Z9$!:wFo~wJ/peP ,p?ojYbw,4ͯT!7}hz!0fALY`x@`Ր%$&)Qej"$RDGDJبo%dƙ3A> E%TM`+"%x/|=nݜ) &=;n_,A3wgP5 +%,RKliE695BDJlE695[:eMoMD&׷&Ri*Ytd*i*?:G'2>[ܞ赬DieZ^q-Zɤlk\H}:t8<$~Iا8O/c^>}zN%Kl1اbO/Q`^>D}* U $3H#`>#`>}F@}F= 'X:Iȥ4H`I H` H` g" 3I1g> Js!v? !Js "? &bt"v@ .b tcP5@"P5H1xRe "D*%ŠJI|R_<2*%ŠJId1RYAbM 56{ǀ5筓ԟiZpՓ^%ePff -RX@#RS'Kj-J%HJU-75;UaI!HWQf6W^jL.o-LjXcܻ@k~yuBq'D֎1k9l9wLd"^ vݎBd"vLdLll*/?1]sVg[[2%掬/7mɔHR9P큫 %殦n]XI= n[,5gz^%g׻Az :mTDW;/,KvJ>T%2Ln>l2%tpuܐ)c#7dJԍ m#7dJ5*^ٜUZn̛'nv!%m u7hhu&7C%\)fbج";X8nca$lWƼĞU-JԜ-/ĽZڈ{"n]&Dr\&چjӆ21*S2cͅ;VeZ@WhsXT( 2y7%Kd#ueBmkYRǼqhUG:5.`{M,2nL~>e׽MRf>l5wsAU:%ef-Z̴; [2ywȖL ;-̼>? 8wا([BX3ǖPLm,x;4`֯W3ufo iE=ofঝ-34ԬV8sp?Wbˤ;-ę}/%8pf:Bo&} vz]C$ Bu3=\pf6np!Ȯp!nxx_c,lf0b,lv&^>c;V3^) VJ-+~um?g;L-`z8~)Azrn#AF*? +S?>oSlXX)ZJgВUdD %MIvYJ%qy!B0Ҽ`Z?̻,ІV[Ӣ`Z?$,»HZ?$,b^ hb,Zk#Z% hh.Z В|X.ZŽ@Zo$KhFXBD c 7%H1z#q]B.mLG",=b Z/hiBH/%ֲDXT`xeql wQEJ42z Pvy!z ѐ[;<@Zoo k G|z2Gp[a87{hmgEMHe.\s)(oSRe%I()y^sI!͒+!A˽"!A˽";9KQh1hr/DABB˃D ,$W$ȴ#QɣHl2z0KxM c@ՃH@D,\f T=@ #P`m%UKX@ (3Gq.zg i~[D]T}M Xĝi ^F®L+YZv`Zڂp* yģiKy 0nwW\ 1AϬӂÌC>2$A} tv\h~^- 56 aSPu1N7ex E%a.jʩSp  E!P/JB] `.<hOaʛ`ޕu7OalJ[;JljIU/#f{FjZP$ K9š|-)aY$-RBRBRB1؋z٨!> QC|&,Oۤ^gYRXQBv C0 K2gkذz W'*vղ6=w;+{942C̷ DunWUbdX~A\\F*BQUhS$+ˊP$+fpJM>v٘g1GK e'c * S^`B e/e}ra pFaZSqQlpǶbғJHb'0ǢT2 VRnkrP$r͝:A f3?/5H BeMC q)*on|WY=D hNaÏ޸v\t.k* ,=Ʋ:`;ٸ/x$:Eu8uR U碗7bKu~.zMruKlg:k $6Xꀗ=ӭѷ`o>9!/o_O???闫>^(FPcD/,!_`"[Ra yb m qL)HP <Ӳ \(H?EAbְe+ ]r,^AIb) 鷒rĈX؝|&EqL}>8_DCݺ:8Uqv[2IB;FhЎsm+cL1) \+cL1Ў Ľ:&@ۮc4m׏s4\\¸: \¸: z\Ǹ: <= L)@0֦g=Q)N gf'\n t{$w].~0ӏߘBdBWsRl+u^I7Ip' (uLͺ<Z'"4`k$4"}J{ 2D߀DsGoN:#>V't*Nf :%ehu2Z$dIX)@qR&V'LN&:V'bdJ\=Y' rdb\,--`-`-5WwA WwA Ww< Ww<2Ww<Ww82Ww82Ww8 Ww8 Ww82W= WJ2ǠǠV{V{ pRG1Gl1Gl1 Ea`(@RQ2szpR:/3zR&(e2zHR&AdpLWm\e2XW.W) W% W%2W+ W+2WO12WO62WO<2WOA WOA WO\=)\=)\=(\=\|;gQ,@G9.]|} cQ*G@ebJIT~>JG`jP=mb#Q*@G2s"} (cpQ*b@G-{} b^'^RR\:`T-Ք~F«_[zpmhZ)ޥGN&0QB |BJ/P?w`!9 @G8D 2Q>AG0.|qY(ȥ|@%*qgT?R  XdByn fS,@hnQč, @簀<DqA/HjpE"WZ&0y) LrL%Yf`Faw?EPSzp~ݑFQ%R*`o:+G^G5:,F1J)X8D$`CZX,G,X8D;Gk3( ү)X7zp.y1M,X4)55Fⓣp+S yMMhYЭ/=8R4`܄R yM(`܄R yMJ" ),@S-v"8c, 4E( P)XD@%`1R P)XD@%`E,  .XD`qPhW`0;%, SH=˂|KEr  cYKby$e,d,H,􀴐Y"W"peY: P,v_ kkp4uKpnBa`-A7RU^sS;MZU{MVU)J6tZB<;*R(^)6_|rn|n`JZ)Qy=MhYx ]s`/3:)f{Yx3~{'GP,f&5JE2Z) wb;J1Ck570tI҉>z֘]xp ‰n+gjN,,hM:Sa95oT*yi_A[S}$/LЊ$G-fa=y?=yiqK>iVTޖ6 =ѐGG/=0,DžDžnRSUpRDc&n3i=c̀rdp&K_mw&8pIm 6ˠrylLd-.bfB^˨<64Ce6t6Ï*WI,'p8bsUʹ Q:3@ǥ^~7Wjzc9lMKBojvYn6?+-MRj70=YnPƚ4lHj;*a.-`5M!nq!͆?8l~ZlY=F߁ϴ"i9~+YqiQ]HIahW3-ŘU)<˲ƿqSLގ23}\Z)Q8_[lIq:;QŠF,`zðiakxc[8N~/(%^<_Ғ849r}=M$j6X{jcj{ja.$#=%)Ms[J8{褕3Z| f0aw1#./}Z- kd{svGen8WJfR!h5ev>-/´$I^nvo!y`@%?vɍBMoЎ !ĐsJ[eD}c\qi i^}mZRlK% e}$FRK7stSx`6scG2153-)=;VGaܧbAN{獛skk+?.IOegN—4RVqڎxk.Vzi[2y"suV鐬vi̬eO>+TJhw[[zS0m@:1bEw-7z\#e2;$M;>q7$^kI5Ԭy;ͳy19=*p>/ p3~9Ӛa>hMHIpI`z^p*_tUϿ.w],VK.(1$ҦV=;oӭJ;ext|ͿJe¹Fw2줺&mw(͖aLm bS˜7%^ZƑ\RIDVZ5HPȋ̐e .R7DžVgs1@8 .z.{uf|_7yb7+Pb6ݙE2<`8jRђbq>{IQܺ$q/ 9Ex{hs(S-,`pe1%m[RC(z3PdQݵ6 l\͌#fQjeEmӓo"f3!l;,lLN"aפEߔfY*ߚ 65ڼFY- #i#\hus&Km ÓmL aprE[dk 1#a@?[[-ԖNU(S;̦$Da7()RwR7⿛gȧ0OI08G -SON_)%Wp +88$r NA$¸+8@r N9}@N_i 4WpH+8 H$7$rN 1]6H6 gv3Rr_@+ –|@+ OpzW?aK>HaCEbI8 $ $l?(JogG{g2l2"dE8k{:#氌ma K8,/җppFK8;З UFW9|s] aڻ[R1صw#bkB/aхpBfXBm:زszXBՊ Ӊ?ͫf[)Z{-“NFKf{#݈yLq:51)oxv#3b7b^:SkF]mCy]j4ԒPJj'mA`nD$mA@(mAHj$ mA n$@"mA n$\m$ % h% h}v?j?j9?j^v?x9? ᤴ ^fk'hxHCa6_M h*xT Y& +$fט2 ^c~h*x 4Q ^4K^c"h+xV5`Vs7fhG`}t+fW⤒ ;^P vE)`yNy f:5f%;pkq-9 oXN[(-`pi0x 4@  9 wHr; w@N; `i0x4  DN{ = `Vn{& n0@+y_Vvc!ZIh%Kٗb4Kr?6)+A}hG;G.^M"">{{Фt"KJ!"t"&B,r:SXJ!bK DL`)ptAH]ϐ0O>J a ?H|w;01!SRZS]DR NRj:hw,7f+J~+tʛ 0ÌB^#,fVC^!A!t+3x;OR Hu_%)7l~/bT߂?|MR4S 0zgN!R<``_Vk =RSM_JOr?('\yWߥᔫJTn|呚rj[)`ɩ 8kOa[) y)nJr?h@]m)毿: H`O4I. `@%Ԓjh ׸-`@^NO X@ o8hP@ EJt,܂{_@8 |aTQh|4)ifMFAp7 vh8_F 8݁NNoAp#w-C=A#12(1~=ƒ[4`0loV4'Ұ+|iX rYT{&-*ɋ~nJiURʟVžh-E[yMnc֨ f˧/Ӧ f?g*]WWi?%4W:˟T|S\GC_5.h\ }ոXBq) `벺0xEܖ"sC)4VhA9Xe /[P,}r`ՋC;[ ]E q@CUuX9r2~zpDwu3.U=փ#:׭G[^0(*N^^w.(N^w'P#ϹE"aX%AMUxli)FתVQ,j '+Hnp씀- sB Ok*uҼm x6ȁ4[p@cҼU Y.4oSNy@jsJU! [+r(LB(L*r)L(¤*lr*L'L*trNH%\*P,LK @ɹ0 @98 @ɹ0 @I> K I޲LNd*NNs 'Sg󆓩KުL`fT">LeYTP6L`d+s6'[M? V0%oOflP6-5Lo؞lMGI(c~ru۾IKn26'W縌+S\ E? nF٢\Vx$\󓯣4+QNym!qaukߔ%oܾ@k@ V3ju@Tojqx\Y|̒4j\7啿帼).,{).|)W] FWX ƍ\ W>^" /8jɣtV䕗eE٦E٦e٦Xmq|u)V{_sm:TІ%^PfOW.ߟdUܼ8`@;(WWrsBck*.Sz,OWK ]%7f#5ͱzVr~f*XksL{slSymEU\UOa:?OVչi1[!T%l[!t^㖿f.=ncoʭp9/jUm hrݴBؚʣ 8aӆ M^a>QCy1mpaKhy/5%m^abSʭhU۾agD*dڼ(7f 6OCߐClɭ#]. /b.?}W/7MT'zզ c~_*=`'Ѧ',㷿}SGag.A 5~61)?|:]6CG뗿~?-+Pn\7eE5Mj}I͇ϟǿ|?oj<R/Tǟ|j<'V}W-eMq6ιmӇ_ӟ?L m_; jǑ~z-2*F-ԃCnkζ%@¦ a~Sl\# ǹsMyJhd&VrIJhJ.% >+ КJS2@kQ;5~Hl&d2[9 AU 7!s 'drUށ P2W ݔU8$dB-#6c8#6Ы{AT@=P,zޣX |@b) RK^PD( 5Qn8F3z[ьVH6G Qn:n3zPی5TX6+Xrѣ ftiF:&RѱB(+rѱ%+\ѱ#+8ѩB!*K#*NU)C{%rd}Ԟ/#\WW)k< =~+WbwϓV#_{ƛ|es_}ʙۦٍ._ztusiv4J[9Xg-rgzDE-vUKyfԤr\z񀶝@IQ3SuYAf:T耍 9;bRC-}ޡzC}{hwY{@4{D?d է.C&%R}~@P}+6~|ITS]|^4Y}|rv{Yu3ʫO.vkgNTVT H{<%~B]R'~V*wɭ+'wI~:q3}*/7_t9ӮWnN.r~*/s/m^0T^P_Pu0T7rf?0+Tyce Kq6pΤvs+aiX2YS9EF{eYdOńo*d;9?oڣC]Y{+kd1=&ޓweI=iޕ'SST=U.+kO#Tywbrp=Y*וrq=Y*וrr]Yĭ'kC庲v=Tn'kC溲v=T^}X*/ؕkU] dZՙkUcZUN]YV5ڵSObZߓkQ}O֮UBYjڵV#kZ]k;v-jڵv]ʥueZW.'k׺ry=Y֕vm*>]uep}Y\\Wn*חeNܺvSyTn+k7m߉ er]Y`WnLmޑ/k5VzCG' w?:)רIAN-*tRPyrʉG'Ri褽rFN+WkYYʑ?:iG'嵛#=k ;Tt?y&]ʹy(;fqcv"*;fq@8JA8VΨgv+o3;ʑ̎czfDZre=Xq|Y8Uάcv*G1;N=!;N;{Jv*E͎}Z5MPSDPy *A~ٱ4*~ٱ,*ffp~ٱ*g1;6C:ffY #UyٱQ+U~ٱQ/U9~ٱQU']ݲcj7ώ3c*̎yͼ?_+1TNw\&gc06_FvwnP-ǤX-CֆaM+Kň,|^P+ ^Nꄵ-/mdJg303̓ːiPYgnavFiu0NÚfam~@rV#gkcQJW3e3eRLh(ҋC6S'=);R#ÓV/ffL~53S6S%m^L͔H_|nr[[=ۼ=Gv: *i6SR1 Nvx4_RJv)ҳ3G$+#Q/fgi3d INtwr247B;d杈9zdd2vߩn+x*9=YoR*)#NB/ߣv/|9+Õ:+$UsvbfZdز+P#*a-cbX3Uq2l9bvƜ:͞>fag99AM{2\37l?۟>_8^GFuZZˇTUWh\_>/ߊs-+OX!*vĔmGy(gu +M9m.'(-s>t/~O ~4&T0Ξ闕 tv-Tc>h~_oSHeޔ&_ן~ß}"[tMMvM?& ˞:M?ï~?~_>t}] Mnz~x7.v /ͯ?|?v͚jE_N i$ x$Vx32tpu@"59۷4$3 1=Ȉ3_19;/<'5%=575!PӹĿ(%M+F W$# x$ x# x$!x3tttLS-N-*Wz$x-Q!brKt'N`?'owooF>_dbH$DHDꧯBXJ]Q(/ {OE-;bVO:VԚ QnA寣Q45ʚBYiuPo,PޚBY7]( #|w,>GYw(шޱ㍽041KF>bx/^eEY7}QM_|VNO]7>og0}Vq> i(w0:;΃ƙ#kd|:G>+GW_q5Se2 j@V+@.;T0m s 8(؃2()Pndo'[h7PYCYM[h]M ֞`,b < v`љf`wU$j-_zUxd^UЫ|/. _zgN*R ,leX ӝ"[E@ceܣG$]Ymyր\n d,8eM-2Q&YY$KyddnKdž,^ QO,GvMu˚}Lݗ-5@ ԆggegkhV1)ޚPЬV46F^Ҭ4G)N 4;N]H}"V<^/>Z;i Sg4ҏg'iki7fnZuAix{ N* |aZ=sjM%Zw$'x3t)2,.2-2\\1z\\\~ #7 xWҪ

I@QAQAPA$55RӸs"UvlQ7~~oP_~\揿|_?{PY/OtO_$aj(sbI G`y~ҙHkƟr\f w>Ӱ*g-m/q A7Mןto߿7 |9N7JQmL#C,ڜ1~钟){<53jf8Ex8@)0M0 & ݆I0 rs&NH00FL S#`j:3LI0&XC`LNWap  0hL)0bC@8D@5X4X0A ,G,{0AK ,0>aSx#,xd d?`d]t :0]hb,6,xBd# SgM,,Y@ϡ`d{>7,,``d1C3d1CKf8<oZ\<,<,Y@`d]| Sȣ FmY@f!Ń# X"X0Aby9, 8{Z zuߣ= 6ꋃNMWn#kyiPy:R:(ރK+숌%%q˶~;m]ɋޫ?=A\8/n05#-m"ޔ bv͆+xVx{3b.3N}:]vlգZĤ3)Hi}Ϩ39(ykz-/D*fs&6i*E;iշNTlվnT㕾 f]UᦿZZ16 \p|^h&!|X'#K3m/lrd[dd 5^nY:QUOulU'L^m~ڌ!y][Y,䖹뭖${/j3.GcpGs01hPHڌ{ʉ8w-G,=bQge-3nM߯x8m %F=?it;1? 1i15# //ة̃tlW<dzRӝRVAd}u߼nHi(0:j֝:Cݍn!<E:j3`\ݴ^?S[ӱlҒq? jm_ېh"+pCsO[.և64n%^;7wU81 }j&bߟ<+<ޙjec0NTp +ʒ_gsQhԤ8)jBr^VFgmZm,%vtP$}=_}j7Jvլ ԧQvaX-ez^γ{ޡkZO+ց b.=,:a.oW1a9 ӄYQcz@^w]QN5hudﻕzRdSWoƲpweKE6kan Cbm4aJȑ>o%(׋IMX 6pp=QH2`7wW7-|Fkٿ {;NohW~O@# xn# x#+x3t.-.M-RpIM.+44.j$ x#@x3L42/M4L8}9ALSΰԢJ7: @1z\\\#Dx3tˬHM42t)-LN,I4 s(U$&rL8 =..."#Ix3 ),L42/4q9rRF gpjYjQ*1g\Y 5cj# x|# x$ x# x$ x`# x$ x$ x$ x# x# x# x# x# x$ xa# x# x# x$ x$ x$ x$ x$ xb# x# x# x# x# x$ x$ x# x$ x$yxE1 0 %YN2N]} }d`,o3_IVzubk?$C!KUmr.K ,]|ϴ7 <s@YS} /$$ x$xuZYs6}޾IU/*?yL{sJ9G{4|wNMQΣ)6ק,hT_f{ 1$#ړd1'e #QB6ѐ͐,.ذI1%I$"iܦQɂ>L>. WlŷCxכ䂜K:!=Y]TaH.a(H+( 3@RakF3n;˪I[δ  ZKY򒝣>bR;yMs2ݟ~xŐ%3k_meEVҦY:ά,HԅqyAjEjԆV$e;:WM6I% ]A:ۋ7(lrEK>ƻʀJvHݛV&߀ߗ"ǎHp=;o\m lo< һH~7m>̺_?{t~E)K~jWXkrEaePn@NeH%\St`B_S͹uTrNgy|mNZܣ/2{eqQ9I/HjL޼YbQ:9={1\G!>wK#9{-#9VG,3}k,rhH2D{絉tz.t~h t|97븸k[%ȵ)>nKm3 A"צ+PM7kS>d6m\s?LB2JI~ع ߚ1WT25H6ܯp}f8%#Z[mξT(TNPaǥӀ^t!O/םHz1;;K+ȺQ[`]mO z^.j b{SBײR8Ւn[ם)Ak:=d6Q9]#vƝ)1V & m=#Dxه]gN͓xԶ% F-=g=(&?{=׸wJHI]&rFDZrnElvOEM+NPcXK5ȴL~mIT N M+F5`^d뎭;(j=c ]J+-v)!`Cv+yEF5B^OK*+&k5c4Ak ASȼz !ݽisbt%PR,-= O7װ¿k3Lh'`S&ݕI:%l>GVbPژN ֍dB64{׋K l3 _jj$ v^%F18$7d/Dm;IfD~ԏ`4]=ԯ=J,¯`~FwClhs=y_G iGYfQ;doyFyce$e$Ɵ9H7;__` nu6k]A^ )Q7ru?w$ʪG[0d \W:Rd!J15+d&bi볌0>a9;Bn 2Ŷ'3{w]%bAB15"qgkH q;"G݅-#H=p+FرvKdҎAQ7|q3Cw}q>NرXl1Q"7"+Қ@y K$puH'X>DdDfG3JjSsUGj}a=×DmZH wf q hRR-u5`mA U4'WxhP#C]-5W*T @D;KA-]ѓ7=Hv8"Nz{1WLRx $#{3xwbÖL3@L$d y[ Y·Bܗ-ۘU@=tC!((uFFw` ;J:QNeNcmFZOZ/z̫#?TE1RhttrEVU&<@\R!&uu3yf91l̹ F(NLy`w@y~D~@-Gr+Q!s-r0My8hzzoD+?wi7**B-Ʀݮ0gJuV>3QڨۭHVJ:WZ AGVJi%mO]PH}o(d|XVV}Gq6ʣ-nq\ĵ@zn萾,Tۍ 9"$bײbȇX/`Z:!ĔRzkG RJDDx|X&ţ>ęOVNpjeT@rwC}JţbͯA Ɨ ORAJۧP OVMb~&p.4X fr 9`! SHkNf00, fJsbmZgF2_Q?h;RAL>_4!hUmGxA . Bī*%D} 0 Һg ƅj FU XE۵CeyU㑋R~[xY0*/]"AX=xálC!~-h餾 2K_>W}2<8<2h]s)XlmXD[!P}! h-8&P[h_t,O_WԪv[]%Kƒ! d`pk ļ.kxԪf7CszV+|xmfwxwmãVb,A=Ӟф _@^[eQw2E<^my!`Ǔ'\H ؕyƒ IMwJ$ x3 &6D;@t P A #f Cq\2^Ъ'_HU>icY?O~]n ?$ VcDzEy6B0xD =,,!| {t+#YxVQ-LR0zk/ ^nCG};ȓPJ< B m_Vaв6_C[xSZ5Q'C꾀B;t9Dl(d?JkKIfHzo_6N+=<ީr{)-*qoEL9`CsݒޜCP:$%IǕ$xRKn0]' L@r J@89KOVCDڤ=Y4!*2Z1 wI @Y˹x'ɘvoF:& 9'X2i>;Dwq~q2}m*0+X ]/jiv)ԝWZ;9Ἰ9|`ȯv6pH*iC~tLHiS)#%§./⦺uI)2g^;[y'޿ # x$ x#x}ks7g_ѳ_H:-N&[d濜O /璘&~BKTObuMQOXn3`Qۤ/a\9El!3Gڱp.9?` fj_nVZNN;o'g'd*eѪNE<{y=z2 [TYIp(K;uhQC^$#g//wġO L^j ]>'Z6dx=%G˗>?,m.ۢg#]wjo~x/gس+PQæ|bxHI5/H#"OHް.'G 2+F;$&&9rJj\QG  .18VĨ/P/AMrDJ bʩ/E꤯PUB㬪q`+tNH$f5"ټ?Ywl}ӝUeK_LIqV8Og_1i*AI$ r%;@J3 xU?%#+-5|@<$BsT9Fh9iwJ<oG]A_:uQ큦`K]KILo=H#s\=^Gbv5ܬbjojBEy|^: 9q*b6z̘ufx5a+Hx'@@{ et Jv1xg[مM*1`x\[VIU_JBjnbn2pVmT3'C瓋''oCM$- SW%=SI04}jve{&(7S&9ʋ:Р6dg{%Y/Ɏ[4*fکn$xM_i"yP.$wEGz+]ۈ*SzW,Mz̟%[]U-s*ʪQ0\'O<xvr[a_ld0QӶ7b3mTZ5l\1:9XeH86pt cQ9mkPpZ+Diհ0TЗߴFR Wri5'hݼf'3諢"^ vjK16-~[HX4yIXP/OΏe+5 ceϾ߹U;l[64Dl( ٔC7ӺLs: )#C{^O1~!l&~Y5IW~VJ EF(Xx(4`U dƕ87Dx#k1TŤM=3%҅%*8U_z"I-UeS 7dUrrrs[1r3*Pγ/&_?z&/i89ϲ'^STRfb:MsAU\ U?T;/sVs*-ɦʙ.n%L^#:IHTjx]i_3 AR4;ɖdjl9|.X517ɼ>I z'I >II{ߧ}K^b}$0.~>lT't25֑W݄^eɗ\^𵯷oU+tF&R^[Ri@E䟾A"(S$)NJJ%dMX}c5 X4#iIo͘TWXrE$Ec}d\bŹCIx2zM/p-3Y9 @&YPwG>aV&=M9Wz-whRx{zIEZ1>|/Gd Yt"38{迥1I\H [Zvwl V[yZZƤEڅ5N%8XM5n Բسij'c;2CC7e:"+W3.'AUzh ܧS1%6+U-f0`pdN*}Փ z VI8V(sjTU異^lf>Lܘ`p}'.zJ|:IoG!*d֯KnHk#bo0al 2+lik-AI}ZB㿄G`[mqvT=Tułp!.ezpRQjw?b8'p Qd46&d@΋#5B\p""'Hb} V0Q,t$Ӭm贪``wӏ9g2lvOLkzveN$ޝ8[7q^N=߾"OS{w&Ą ؁,d1.trCۦ`s"7]D_`;4ri M#u\6LCG }Q j/rdcf`zqi`/ H˒.GueI =۠z|MD\"ޚ 2I8G 1vH$f? ]/y˿ُo^x~8t,%QS!p' s"lG%P{ZT%s$В2”93%s񰯎Oxo(쌛y`%<wǑc/s*-ގH dO$YvE9!!Xԅ"$KRyQfHKD% ""C,s!6$84DQ bKubp}5Q0`G]![憸iXfx}j=IK*s3Rgi(9Gљ*KƵd D'a085w)8c#h7mސ;~' ˗d>Jv]Pz)`ý^]RZN-Kٕcq5 3]a^K] ׵ŀsK|q{0 $5E.'bFVmq^sG%S-͝MLK(~G/HBJ/(mUT ])=9do߿~b" 0P+ģ&DO)=/HtvCXJN(SL*Wn[YkuQ4tWDTXǰ虏Xa"Cs\䣴vȽU|4]_`>8G Mĸ%/`cȳbVƜ"1H'G=V97pS:gѵt0,zR*Dl$yG;){LOcl*Wx-rdá{v`b"m( =޺vD+414EQWq_\z iI^g7D.@$^Oʪ'9ڲoBT 5+#'R+ [K~LD=n1XV[t^^%5jq&c*[TvDåB9/flBH|N)4BQ] % ?Kvd@*4N]?\m ,i *RaG ZqUAiVDA N`2HT3U 8s %Pi5zv{рb՜7"?aϫAtB \U&*J+j [a5I)wU޴"RfBR~b3"|kh[ibL@lz輰d{ q[+YNȤgKeeޞI_Dz~L闲AL3YY9܀'NHo3XG#P{tL.j>_"<Sa9`RhB1) 2t0u3+iu;XX C/гJDͩEoަW&8jaCu2caF'7ܧ^;g:>-|zY#5w"!ts`HĀ:~4MdipΖ|_CJ dv1 waw uۣ# fؘxi*.mfsWs:?FWY}u_girSzC>fe2uһ[S- mm XVsNK#Bs<1SʮɰZMDY%# kM:jqyܜKѸnMR)/U#侈v$I Oh#!bKR!~Sj,00C^aHǍCьQMb]4w Epc  -3=Pd&(Ť$MC']lQ-yZp-)7 Ir(4!tG8-b0x@YBMg" %/&)5!<) 9<£IIM yѺ+vRd:R;^b?w.q4hj#|.f .,P8tE5F NZŁ`X*x[sTle fb1Fqz'D2Iy]RT* AXh8h|$tc"bP0<$d\6n[/Deb%uږl]ݽ/G j Qʲg@[ζ&AxH<27l۸ I#TXCeYZ޻AD|X3 >cYg&_uuPCnGөEJ Ԫevi >1|󭦸R/m?iVol73~_o3ow ,;4Afr1xOpqYB$&38?Yy#)K&dtKAWѓh>NF)KpMH+Ӈ0QM BQoG,%"&/+/V`W WApKYA^qpcFٕVqVIY"!`Rq/- #M&CHnHkzQ5Zi;Y Ō]lA3t3\k-ʇ_|n?' `&OfwHh{Lzl-7*2E!@Y(FP ]7d&W{Of]ֹ=/kG5#5~y7#~ 3R8 F[[%Gͽm5n [Co;CoQt߹X6#2F2 fFei$OI3eFւ;FhXR[ [B6K?.yM6Z+RbKqLjU?D-~(qoN6n\,a x?O]% ϓô ˛0P¹8Kjf]0-{K39̹; =[e$ E9 1x(_,no+lBhXֵ__FYdѫhגؚ&ob)rd\SK{f'[~$jA2ioa@aOGS}vγi6buX lRB/cOEQpX;=bRI7&qsZчTu4}~ E9 Mc#Ez}L墘1%Q}I="/,RIJIboJ,eVoZR6j~319={'f+Vr ˫V z2}iӺuq9MK9$$ ~ \W ;<р!~Xk[1g4=AWf=KXxl봱$T=TunjhkިSis "1_$^1W`'-k*ihy E @a%^崩X+5" H֜iU,a6XHƥ>ޮ2UꍞxRW69@ԦV{7ywЬU!U0:$C&q&*ؠ$62q2#KBHS$pe$${>#yefIEdzl0jn{win9«k/KpMr[?NnRkVPkZ&BDи`"'*1$O{"7o^Տ罁!CHk_%fFY-B_ps>!alx5it*Y-22nXfZ)ss70A 1Ydnvs#\ 8ƖĄ3[\+-å &IA0)A2ꃤ.m(c"& ј"2i=4&Y̋2w6[ڋ.†F L2pZLwEx$-!>jGQ e1lOЊlw9xT|fzgyAs$~ i:yI% 's]WI}I'irxQ*=)DeyXO3fwBw%|5i 2hV$yO3CxW*GrSI'g5lj PyߓjZьMՄjzfYZ`9w*{XLǤIJ;~rwKeMVDg.4$L3I67$C'@h/bL4n1I MwArk5%]֙]xQ;ނ>XFIˆ+S7-yf  yxuAe>z<搈@I~[ܽ7B[I:bۣ=;ftk;حz⛜U81v玟dflEܒx:-LR-]&l {Lms3V+tPg:eopY/~|mHJzNm?t[l4Vs22S[]>^t}htmXi7Cr}/4+l M5K &=3 #[ȦIߍ^%s&`bw%yŽyGg̳f]%@Z bϤ/ +cJ1U2fi$3y9)۬#˫Pш& Vi^'KVU_VX}K1Ѥ|&dh(%JsBSS5!Z'&MULpթXkXnaK7 <:g̩ʾ\ý>3Ԇ81g}G\%WeY4C4 ~ !EhA:F*ϧq$qyݯ>,|T5M˸p@&Zn tb+ K17:`RSjIvMտ8PAYeϹ[ J1{!G( uBċ!I't*ĜƵp9ohZ,<>FA`lHc&";1G܋Mv]X 5z!7HևhekY@ٽזyp^(2JWŵ2id4ygג>|)K#Bw^"vC;0'񓴆ʾNa8&5VwS8|ĚcG^xdJ t3xP$[)FcWcV4{ ]߾" A\i 7C;Ck&8%keGDb}!Rx*@džN Zj{}۵Ednd.T>T_Ö.#pH>>4D v}]VmZKHw[2]_:omKĦ[ \)fM5aYǨ{eVT8c3yyB<(Ma1ƒ/}mIzZ` -P'Š圽${jL +vtU"|#3b,uZ 1{Mz-飲(An3'cc ~*_4 ،yV ]!yȗ(.H`֐Ǐ߷iT٭0(\D!ٸ9YPp&KNTNS 4Mllo|5YvJGjmdm@[8yYGi+zڰgJLI<Z@u'IBEd]2JF?rM@4WxDK|\_mk5yXz_ kOF[k݊"z˵~//}a߭}wذİ!LW 䣐a0 C;Wiq-y\1tNYZ@ʘ@鄠%l$N'a0r&{?%Gӓlҍc9f Um3O5Ba{}/,ɋdgS=g`ΊE#{Y~[j9M P 7|S(F?G霷0Ssd`1Tg0CR2]>z@0wKz{q+a$sY!D^^mB["b»✾Tg*eWA$*E޾srQ[n\"` Gb`Q :&6 ]A÷&4à 'GoRh&l4ƆWoN/޼7_דrZla 3V$db4D:⪪'B'2cMN e Ke (.&RL an7qȫe1yˌ ̧w8m{xҶ\LAjS6bU _gdKc m ./ zEcYakUަ؇Kc m *]`_>*0vMASZi9"zV\ b1,I ήQIB1M}"ځV6Xk1n8f-v೧+GOad{7 :!]zD[qvEyl(E]rA\íN xeaXW0~3\`Ke] A |m}][_ʋMߠɮKXo8'F8$m;i,ouHO!y%9a7/OUD}NDՖg/6[v:hڭ l[Aun[Aun[Au*[m'pV8oS=hɓJoQ騞eD?HG;m6J"L};!/XwYINGr@DmG9YFy͇g ع2RW4;ɻeUyo&E^m:%gw/H<Ӽ~ueV-wЯU&<M'#2a,J֜t.{`8s"w? AI~.RJQd $ ??_ %crN)SػND!P坞>ddjFЩ* Su]A;mY{s^Jl BaPOHWx˜{{b??dH_O bbwFTxF1/&Ínohuy9]_Xj8g$:wE -c"'w >U7/xQS<{aL.%ϲDsϘ`n%Xʗ62CPFsWvO3OITFM*`q^7ơ6%EY>2 zWk'5Y<qsi$AS1u-w/ȁ {o pJaZ,| GXp!y/rl (MU20F :DĠj"%ِꚤ%لRS<s7\Ua+QiSW}wl`r1n:"2]J"p\bYvalFQi%CE/@a=~vBӌVd!' 4rΥ8͸"Fs]D&*X_[U۲!(%j!8L,*eW<1 2aPGZb@|(XU,6cJ]-FjqX[[ xjyO(B"z@{԰Gz% L3?ձ .$ՂyUD#4!/x1<=$u1 rjOO܈y9hE}NvB:}kWm'u ;" bhkˍVFOܨA[ .Ag18J`XږMn٤&a|ЛŴ|%}GuKQ;}GbJ)c=/[K$G7o)Rۨ֌Td.l.Zٗg0A&x#Џ,ީ=zyN޽QrjS./nTcb9 gPܩ8wj^sQk^0"D|1zydlul1"G:)u^Jt`%CSl:%0")DI-Od{;"ωv/ќL'>gn1.',~ܘdxQqK ys KXu:w\WɖaQmBLggJ) e22qґɛn ]j"/rWSVgMAj>mKb2=dQY]p}})Gk17E +נ`r uy5H1yt[z^ OD0WTߋ[$XMiaJ~Y,XlDZ90Y<+`O.a& ncNW_= ,v@DIMEA:"F)?!ߚTHM)' Z4L0`:xO#<{,7md5@r?avD5ۆX'^ i]}|UD1 OYе[Uyr%x.Pc$d+T ^z@I^Eػ:5HD$N+LlJ˓9I)K%) 4;DGP迅&bG !,0M*18k/YciLCv|m[GEaݽ~M.N_qҖܦ.uIIi>N>W"ӑ&%ni 'l1zU:Kb !0 wM4F3~C!b tT4P ҈"y4J[ѧ:%i 3FA ]?GCq~ 3@-sN'4-o})]YԬ ˛H.bZ%EN˥s%2q `}=JI~zU(u3 {ٍvТ̾|󷳵:= &hQ$yܴMdvr4ј}q`iFz?jnL9A=˗! De׳鶴ljiPHIf* DžVOrLO^Pw:%9*k?>Պ|g7rL[vC+we+-=.7b87oCE@=1[t+n lHܞ7͚(ҟbV(2 fE%Ƭ}`[C]Q ҋ#BqiYX1-CO/5,ž hK'^*T!<[/Ef#q&qtȲQ.M N4Ot6!iS0CZ,=֫pZՖRuA8 צԎ6A)$KSСEIkNR=^Ey:̣|7ԗ!̼3ӟsJBQ[L%FJS[F0f71{-=v}݆S,U: '\LmMV 9\Ε/εGM6.:Ba&(bfJPl:wFq/)Jg@w&X3_o.7=c#GA2Rxv>~zs 궸{ǣ} CYx08.^Oʙsr>1:qΌ[ ÇP4 :&[=lf4M{{(5\Ye^E eU~5~1+-׊3,-h@sb ABw$,`ּ8w iZC%VŢf8j:.f2k0[o\Dm/ͪrtw[Qiscm[&eRި( |^ Qc( Q,Ojϧ=%cG5 ,hh02 ]k%}oْ &)MP >&׭G8~S@!/7Y͎>a<~;ŲO4g47bcމp 1-ǺߪvA#id8.:o&DabGiݧ_/E~ HL[(VWӬbcovj ױIIo&|"LQ^tBqVVSbhhfD;. y"V d̈́C# Y}uN(R"d=m諓Oh)Z+UyFvs.DZP oF4{! Zsx^Հ<($+6a V>9¤\ڭţDITLĀi QvAs(S)uo$JvZo|7apѢVaq(j#|JT/Thb%lT5 5ѝrlk&}B#r.E 0<Ջtj0+4('7; aepC)d^Ujk"_s;A d`;wzt)C5ZPE-j∶;LeKi7Ixe*ڇTl#Xoa^˖1CVgL^oQXs@C*?zm  L̽Eap,#6"T.menBac+Ì+yfrxAwtN>:ghR\pC–!D K|02Ű؅-]դ(7mq@p>T+Ԕ(bBS~N|sLq-C☋$^:@ yaY8 KmQGO~kɀ3k$F p`15ci%riǢnEw\aJ>&p5lͺHcp+nӭ`Ե`jJQJ 5k e}Bo[Gr2s/}`M|'~BV*HϺJiDPٖW=m癱⫬@[-Ylv@Kɖ NM'UqNKT_-@}M1< ?;rQ)o:b^H]Z@&\5ǟo>w>f}wa]Y8޲29Cݽ;l-T?m̑m!U*g|<2>g )tuU:.'d gyMOLғ"8XU q|D%%|ދc.c(Yfs> 42;gW0ɛN3uN~|XJ7R"E5dz*ߴD"G`zuz5TuTV;'7$_Zl|C= wNrk|6WȚbP}eTޅNd 8GiUi&b$q(2;ъ ΰ-bj2k@ ?ɯD0E4n D^ީaB u`w^@`de΋s%yWpKFY@Fe19pDߜ:v6 -Ie[D (@Ďt2-q-,.OO_`H$n [p5o [p5o [F;Q\juUe5#ܬ9hZex@5TTS9YSh=Vz=j$>v∎;oDޮ6* ӻD|M5E\iSE FJ 3`gUZ\Jc2:d~,:Xyv غЗĝ+C/ G YtzW !QJ7&Y^%  8^^85Da0vݰj5WEyD5A,75,fh$u6Mg;L- Op+.޷鸿ڀ!c92k뺌힃xS}_TfH)uV?fehjB|7{ҴH9L88GŽ_qӤS^ [0C]sYMAllm'{H]hl>;T7IƁ& .yI6i\TuN^jm.ڈ\#|qWYzt&IbԔ|~z.֚{OEű20wǀ޹KlOݶwRYbx61'|Tu@4PrD<"g@[6@)֡{?mmӃScV-0Deg}z?g-f[*qt1LJm0 .ٔlߛouMkh'Ճ,V0 A~M6Gh{;ኗ:en2LvB-gB%`tmV2B]d9v)*r/ Yv.d,0`4GDz>ڢ;X΢̊gvl}"8%v2NL)s0r^Zz;0_ ;J j ~@$/ݙtS/¢4_8F(7KuEܖRk]V*.>MEQ")#Ӕ Oseݹ[е_r89e,ײ-9RpC&DpT`楧޼ \(4CARHQA,)gItS:Db9 #3̈́ 5;Nɫ'(c`A?a_.~ܘDkܠܓDf'$it$ j g xJ2J:_<.Mkj!{JuFsi& ī<_1dB!-1n V6נuFVoygY39i 1e1*4[Nݡ؂'nt7, axhet~G c.F UaX, = K^OʪE=1w*8x }8_x"X<AS^0XUL*v:ԉTMsΣ["HG#甦x*y ]аO y1yu<=ԣw SfP@PyN(y;׺zSs`CXX0 QMnR~,\9DpCޢ0q:8SY}an@8v2ZTXM+ܼ&u& SKuw&MqS90&A&w8\m{,vh+9th/L8k#Q vK-I@NWծS2uȬFO;'fqQ%rJVa i<hrӨ8 GEhT3`n-qO9+B c?o{. /.,O|iӃ5޳G4DAxj8{iJkוt<ʖ%㜅Cf dgCDgp8g|, Sr5j 諗JqMS V,-AQzkTaV)Vuo0PANAr#ƙ ̪b` Non(C yE{T}',#Þͅ5bl_*Ҷ.<BJ;,йrz kV>x1LMb}EHvjy}-pE<}k>ELǡ9'!D( -Yq5AkZ5 `ډLo L\XNGH3D׊>v5HѹXTt8:*+~^Np>I#M((½+ӃR˗E u ެ:5|⃃9m j&Dd _SQyXn~AiXV KC*!+x_h"_H_zqpa[ )d{ww9Ag#yAv"&e9 @ADyszR{(JD686! Z|9D׿y[Cs1.PwdKvGZ5] ]٭km9pEv_t.AQFϚsDfA4_F,@$DHQܙh)m 1wJa ΦQ=qk(h{lʱ~Sw{ځ!^-٢vy7D} A׵[YH\5EQV<}tbwgſB!:֕Mm qp# Nex*ːPL0-LVT PC1( *yJ"ӷ*Eȕ\ēCУ TVRh@l:Ks(Ac:OtX#"w')O ul1Lrg~^|ppX^Ta}tHI37%HRhDJu_eq=}7|y<.!?R:H60JA IDƒ鐯S;@fF̶"wj zY~fw>= [RX-`O}X! L%HՔ3B, z -xocIE#8 uR '¡ӧE)Ίؖ{pb-:+~KV&7`̬Y=^a~YCQJ p| `CWCSE 4Sű:ܯ/՞^ڬ4V#Kj_4]4V"ë8V+?VjdiWkXl4,)qҤkOӅk GzN:#~&TwA&TU(%#4ۧ /+{䏺 Jtl:>ecC¾y~n<7!rKqj=@=ckm`/͆ސ(8Qg\+YZOEXI~ʇ'<PU ,F*>OK!&ᢘ<Ec)XbȂCvo@MLj`!OW[$VןnRnb%hC}G5Ǣ2<T¡[99P\r;fԸRŝcPÁ&1V١.^IQWT\p-NJCastuĺW4K;BI߸id4N﫶h@Y/tC`fP "-?\|81f=V 2~Ё~\x&4M1ߢV*\b֟nE%=?46ufܖz.'ALo%QPTQEkN~ *h"Fv`9qe[_N߿ڵC~}63hТTClN@e?:ȼIͼ%u~"t(#5 >in&Jn7IuFMɍIjb"jW\ҦVO6VQ(nrhl1S-b&A*jNmJPѻWt!7ȧ{ud?RT8=/_3F@#mSz ^q(j♿R};) wSUgzꯘO Χʩ(zde;^'S a|%s_͜zpꂾ4߁5vf=]Myj`M* 8N0Ea3h/?Cp#! Y0~Xo8 JYapju8Tַ2`4& n}o9VX`JG`FX=⭤gP"ܔ yK獋8 GϽU'B7|'ߠ 2IT#܎ Y|@}<%)&lVxF'{ ekP y%Bx2ɊɟCBc)-^k ›"tFf@q6G3@]][}RWD7+  1ъf 6TYUuRAB` }>/' ~[%klk8j6C\D"5u/zIg6cu 760U^#@X*1k`7INU V,YTCu^h{œz`rFEdK~5>qZE#xlzemZMՉ4Ӥr&NLK~BȡG <-oOxd{RLH96D@MTwTqm-0.SVF>,$_Yk':ƪ33-*ΚHyH\@4;AJŸMɾ|~DXgE;h"_X ƶFJmjq-R[z]3EPm PL?t-VٶnLHL9tXǦQ1B#ai6*~D `3 'G*Iq.oۧX7c֗*?V忁FʊXJ<%klɹvt./Bdl:AU6+˄n\=Ag@CtPa lCfiW!'U^¸XUq$9}ʮ޻ѥocXFXhER>0B)٣dwz Ɵƒ[jgfJ3Fnb|{? Wmն.+;ZmCImSD`${/{9XZ3̤*hґQR:TjgN!G*Ҥ\Rr5b2&(,׬xSW?NWFQБ ڠB܂'݂7i7V z)D -!F=9l%{eY7C%Ti;&-h?ۚH`&Xg3&J!e1wKkig]C9&  x74 }*<_MW `9[%ʗtPA CjSgSԕd1g%$\-9Lx_w267٦f)WryYJ߈m>PRYHޒHaTf)lfs,%~hfqYJ7j0"2ǝJs`_undAG96A't|nt5͂O\67KF>'&m1.2QZOaRFن)s/R1a @ 2X%o%@x 2GPgA(F}=2ȜmhWd3Hv#<zNx!v͋j4]/q'#+$6K+[;4'Uđ "e\5O>չma{j?6dink KgB .I]i^]\PJbDJtL.3M&+8z扷t _c,[\aB:(˖ٵVQwhǃ˶ { C[㑿e1<`ʞRN٣Ft-Mk+z9 t1Ύ/HY6&c[dG Q9 Tv Ze !b'Tlt(VTB9l ă7Q޶:ML xtgS3%E.VSԣ3Prt[JUQƴߠ6IeJ˫ĈwQ<1޳4N-J?w‹lRgif'Pw1p424Hfe>u5 iR /ǜfH im%ۦ 35.K7~$]B,2]gZGK0!BCy8TB F zD8*Kxp  g1D8?o=fY>&.e=:髜Io 'kon1͔먬 QE)ݰ[: hH,*d4k݇fv+N碘mm.;fR 9(JC*vt1F6HτLX8-#Azwto!卵'6i&5XI:2&AJ+N? A~p0ˤB!-Dd{fayM^e$97C]'p,E.\aZ0د9QR&C0?y`+8*0iǠ& {({jZA bnhE;*&BBLNHr~LLKCh6Xzym-<֮9r eAm=A`^ Fy[ApK9ЃA0Apqti* Ŕl J: ǠO~OXy2X*by`c"Nmѐ 4--~AͽU? 589Uӥ+~,hGЪ#|5BAc#񘄮DJ.vB?inVX}_J! 녨Y IQE X\"_aDŽ> b\4%zj'+ H DwT7,hm6PcÀ;A"5ˣ$^KuѢLBm$s$5[RL8>=!KӀ tIKv`.tFmU2d$ߍ=('N6mN,}Lȶ#hdbբW ]1h{)S.zzwq & ̳(F:*0&مlU s^gb&uPD#(92-wFKm /.cl|ʪ0#f`[Υ25&>'_>1!oy", v‰&T޾rNNCձX1J#\FlEyx "鍶+tg{L?M.WG;٘竨҃$HT ;Ys h#YB4A05c%rjT֟`Ygl21;燥{6FZr.Lr_b&0+6X izhm<#,U kS<cQˠd0,׿.5%w3DZ#brO86հ@#jY4:y!IdDVb 4Y2:q޹'R ɟ=ۡl3B&gR,J.Tp>LՔqd]gdTd^`4$4Q3p\EHrXrK4^׀u3W1Bk^ 7sWf 8! N\0t_A DwF9 \<ɽøÂOu_4s#ߝb;XOhXx$9Lzgz]"ׯ5!ժ;nwC~T*UwAV\;d(aa%d13:Xo hrQy {G/>I|V0/֐Øp=ӇE2zW.@9XjU{~2%grd #jwDbx]_sٔWg4m6WVK nK( TN`iTmb/~L~ɂ(6i5sY=}dOd=Z;G'Gi~S7 ~v>=ij"RxHѣ2Y_A3I8t;]}{ iY]g(fJB~pr71XOgs`J-#נu]ljUYw21#9?x5-2a)T( @i֬kC1tG17A1U̮kdf4ނ_WspbL!T1bL+T[1#AT ;c?`yX1&31:j)1{$T1UmKЖT|v5!!UwbI1É!;z.|Mfьpq/ْG)pUzv0]Kvkp 7YExiFwJ<+E_`&GUd_Q.Mk]#c/z;<(%g8"ht:pV䝒ݾh0{}IKn 0:mp0M$0i6)H[r!5Ή#j$PTવz׽xBۑ$ ED/YIOQA*xL uEC[[a3@nԾa՞Al6$6q<ઇ'g=\`,+IMkܮ tc.DJ?FJ)ɓU7-$vamdZB;CXd-ɶZFtȂK"B7Tm[^1vcly''%I7]e%)d6d)1P^ >'h94*-D{ ̽(Wk)EĦm0|ƄGfFoWcWR6{*]#b;4sˡuwaEesݙQQ2m7R,wJnܥlF+4Rw6lã"$&]J)oS%Ѭ͢[\\cl/zlnN fN=T`B{ Fao.zx5s 9?ኑ`KW _X,j/Le$Rrl}“iEK'*4>T߀JPL-yTe!Z?^ }buKz]+Kݍۜu)Tf=h!6G3eCIt1&vY{FH5KO"f-Q6ɒ.-jVXPZ&9aR|srmKފ8D]1AN],7Kó&mH[~_TcIgΐ~2KU:9oD(/MZ4, *&\kq1.?Td1n_K`9` AeQXμ=us,8=80Mh|Gw>fE۟ ;;B ЬJ-<.;\J4˚`YQ|h޹L-bc,ڸNhT蘢 QeZܖS*A8'k*H[Gȋ&om2JT'k B.ʽIڹ\]\}E83> OvmH;9CXc=&+vF 9d#+CܖD3n!UV<"6Op',D%YY9cvi&*D>^!6uYY./:}| D[댔:\/]V +ŷ$юpMBgπ7&Ĝh/2ߜ9r]ݐm*' _QYyO_чpK/f5sWYV*~LJn'(Ȍ%D6Jg֩Q"!ދښubtȡ;*cZ'KR  c~!&G<2"L<σ68%C2/cO$A%-a0-e2 5Yi y汤PiM0D._['UDo Rcօ05`#r(sڧ ,AL2gPc:B^vM \:/ՙ~yʦ,H//iNO t|_84(ԍi&/i֤䔴J*BUޥ,}:%ϳqZQ}~ }-4_]*r-v[M,W{9|3p aZĎ;PC%K_L|u&ڑQ8%r`́ɛ_50-:|eUM=g4՛2Th+᪮ #>@['ǰBq``ڰӆ̙ r=:;?:ǚ>l B(+߉AرxF<=-CxY NBmoNz$s3Y t-"07Gļ3wh@pX̫r2NmV5BkiesOCq-1j6!AUj, r0M5^3t5ݙp0yH=qݏ*]DTygTm/^ܺ0+A959!dΦxK(ӹ"<ICzbmx2qi'g D=ǟ㾰H;38WO+`ƭ?&O9%HBA9M2q75E@!A6^FR(?jt%4 iTR݄2 c0U/A@S5]4?i:${XF;pE'[bcSqâC+58D[jMa_ A{yVX}kKjB'>[K4:qzаBGj!,q*^a'Wf5ѽhVzBzIScΗZmIzP vˮWyZqUN>"e^:~*:9-Hfv@EYꃧ(cY>G8>:8Y$$]v-D!kq-sRum{kn<Ů6he~ױG5"O{M+: X[^=Ba1 t7w;oi]PXxОR5U6:{FB7ǸZY3[lXx\W;X y!֓X)&\_π >6,N ?{lV!*zaOkw;cHNT~]PݛeyY~ݠJ.DmNB#X39$"89Lz=񘮳f[udDEٷ6"32Q*1*]7>qY-\5it 8(DMJbh{0jEy!^@M~1n /A8dO56w $ͳ/nY5֠QNxk::͊uM6y:Ic*$X”Ⱦ^H >/DQT2ٗ^_,wUFT12ɦč5oH(j*N$/TYTF6? [&27I>hj%Ph z@[6`+ xuH4ۻʀt6/vW^,D*~Z7ͱ뀛W9$ F.U0JOZclzzN*i~7 D?]\'xd(E+`M0?\@M 3c᱀55]~r^o..SB8 jsZK"*>`H+!*gar3 'H1 5#a!"PabctI3ʢ͡+_dU340"I|eΤkʷD"0LT1SUxOŭiv%_z!5;sd==zλד[wOFR -cN7s!0oeV|ވ=P`粏V1 d#D<>-h^4UdAGЇIy&1>0!~Z(=٧D~HIbR)ނ`R?`xkadyshj=,GitC Aw Ge=:;uv bԫYSBbI5n)֚^,zD0tLx:K4 {oavmѽMmzn ,u;SZt ᒹ !+#1 c,lp?O?Ib]C.#||`} m68ڿ,uB DfhSK;&rO&.nmZ֗!gMr`zIB'tߣ*~.t <7],t8`.TjkzMestՇa#{4)YaP[M9I"p^Nd[`n9=:=/qEZwNuV ZMeNbFl$U% 9ߏ0s`\5#rr&}B ߖU8Nzǔ+j'mxW6⒄ i%9*^UvGVNaiMv{]yUBx2({(z4bgUybtBG]jQ'd:Trd*KXrVlVB]ڵ6.[zT.KC`C"]_^5&%K38>[ kXrPW:R_ٔ3{G_w ͦdTHbY]ח]\Ogm aYݲLc[(|ݞQz-WO &H\WveD|nϧ(|Laܨԋl7 -".V7a:(;H8`F;suyM+VW'j|n2׷@ɿaOWJ癹둉pj`6)(^*J3@fd$C8]_3%#*0ˎ(E.JZNWE>?_-\A5DH*VB[<zji&QikKL褏A@B0糭2;L^} _K"&nFE6@^4 YIC0.L@F'KT%bp[NʌvsqJo1>Vs^Lx&ZS ;+^|R՟ 8L/zc1'-qO?Q kSY= a7>e(]3n[j& Qv/TWGd4V#HDžD;t2:8:(o%ѯZ ۀ' {!˩q^ ?vj;D{TBbIdJVQ􅟦:@P塦p8s2m:@H?"ZcQL8Yb?yWj| j3LVbPC7=B4}%@{ DK@҉b#;H5OA~u'2hpex H# E* DY˥l)3fi^ K-PM(g:vr[[')/9EnIf$~ NO(|7Du. '?<( P)]MrRI{׭2<;ьZ·K8P%K#x$Z:ױaH1-+{ݠ:u0gyR!6"_*> ̠WU"uSJt[ ]МE|jh5tb ! aHBKi&Q=/ƓKsQ $ ^̨iM&phFepIO!CqV}cK0aYNdZWuPxPLU\ԝAnFhZIړ}URWb1ff쵌yNG +(.$ Kw&D{)qP3ig^INj8Njry.kAdkJju/qЦm f^}0 Kh&DhuoT۱>;vȁurEX)eyxm⽝  %Xy=s;A}.:c;RiqS/JxeD7?|ʑpմ/\Ɣ"e5u&YhqWU9c jsFZxH P~Qh5G\ k%SxcRsܕ_gYumXl[[onmv-=.lg[2uO2?askqfѡV$,dm&+i #VAM"i=7]O6`pAD$dazn,T׍b׼)a$RzՋi/$PP TR+:v)/2ԦRjVl5V!=B n`v ufN0DfjF /?ل}UȦ3Ju}O+f lZ &7iMuVMjF$-ʵu!ϦN;* tQ_\/{E:w(/tqA"r`3a5-3\[zaÈd6XVD;+;aٜ0{^{&K0v MYU~%X'y795ajz(1t/^'WHvBHo/Q N]~. @ h)H'ML[ƟtB:'6 zqu08밝A*4)z_Ȼ[8y{zbX酾u#e֍][;u.ע癱+fjҘmztA祡`/Li|IdD)Wm^.n½0LB{ Ͼ+09"ѾfP»:7U^G4(,BVxl͜M@v5^vMHfϱ Y,4LrHA~M]܊eLq[%w %|O: [,/7cdm|ņK,_W%BhFr 8 H$=69oKqDaԧqkkT\r>wʒܐNn僋ivM ˳L/6J|Hy}h>6mw'aW7pP_?cb\ee>`M@Px8OOT8Q\IuAfqHxDN6yKD@S 6YcjJQ"{%<7f;<4 `/ZKt>֦RJֆPyD&榔rI=<8&'F=B؊|;XS6@(jA混EŮU_٘9 |@&|N 6[ͻuaRg@ܮNM=Ai3Pt,tR ɗz1CWPZUmzYy vzo[Tt"8hC*o*͙nRdee''6B(TUPSQ~)tb':ڇ Xx&?+Zm)=MZDjׇ(cV(BG0 )oRD^78nJף]"Vn(N%UxRVoytR]Y|noUPiHK-[ittLI.)F]Zص2PIΥsp2 %'go)Q*sWKd2wy/J>|<=k,=]tCouB-֕#Ut?/KUwirT- _ 2E eB ~CɑGϏD^? 8һ 7F鶐ROxTƨ~ר^??t9;=J ^z wOZ^c{c/^^wEۋh|h^4^4]z=`Q!jq TQ% H*B @䜦uMޝ/{Pu(30r1 >Ex:80Wmr%2Ӳ*O)T͏ނSc+#w{PeuʬTmV}Ԭxl-۞)/ޅW,s֬⁚{Ɔؠm Hׇu$Ic0Ei{z^=mWO۫lXT䄺}+Eio@9 t{.Wpr`ȶ}3/hQBAQ*7x(csUƂ&T~Ei ɫc'X^l/靊wrVuΊvSizlLa9mdDSF6Ur:Ȍ'TquNWfQe߫S.clDH]N~^(,\N 3pm W4sY{1KH0xXJ"iM G@#!& 3SS!V9Dm8<mpXb3Wqࢊє1X=~Dh8{/~آi>wI@~s+w)6I͋u( *iMya"xEL2;x8*쥫*|Mpw%3)SjSbDpLJZ9=U{=hP&-};▔hkP)Ӊ n~9:7l,zĹM(7:Ltd/^1zMP}S:2tNxGWT(.ʄH{ h^CFp pR܉u^&+6c;ycܰ4ǂ .8xo!Oݠ˛#-R4FmT޾zp64t*VMxkl35dA}iGV sѶXqD۰pE9)[vG[6Do)aG[RKE$2eeJkCxk¨gvlVxotNdoi}"EsGgji-~bշ1u ZEl2+_$FtH hjy: K4C-Zh%%ہ$tGDr=g*VLB7!#*C~_w]Һq`x84?f7i5uqZߜf,I;^M9-NYLEnD~]n<&b8>з,ԤXg>qʽ1bc4+}(]ja歍fXC%!;9<$Ww_g]AI@6RE>.e-.]S^өM<;*!U7@rCIC]hu{?rWjg8̺/{*& :Ɛ-R-E=p. ?(gƺ|<><=:hK"N!Γ%/r3]E&oš[!)rvD)*Zlh4xB l7ݔS'qX@WxRk?X@Gz 4(]0{E|'*^zѵցwc.e[9HKfFP_ }]`0qH}.sv MZw.l˻1+~:ćW@> UCT",qO~;: }ǫƇAms=, v; w=z栲"6TYʱ Z ̍#WU6!v>N1¹t.t fϬ)>Xr]w y]#z,%Gn Pk8?F 43^y(\66qGӳP,K;UZVJ7U;6#%y6Ja"XPJ#24ggST9ATCejF( ؏V3AJ`Q+l˯*6Xr7/vxY'$KͶ-W!RY$q*qz럪eMG~a(UF+ DCՄ<$&!⼿ ͮ pVէ7Y1&U,bܔUOzv|E.&Nt<"_s½haUOvCudO^X)uedvׄ[˰<;2Fq.QҷqNNjid׷/ks@\ !/4@]!UvR$q#=,izQԃY`֘> :OtNν.r UJ_Ց=^oOa sX"/Tg͋:iH4 k&b.-=̶l4<2L?Wn1.#Ba믤*2u˵bVUNo>ˀAی<Γ]Vb7T97%M:I/E|«L63cyFD%Ο?^Yy4.H;q1z߄fSkyh ou^^o+@SԆ\^9/M܁V]@>Ѷ;g,9L w!G!|M]nfQCj`d7ϖ+>> ':l6]qYȄN=c޾/,eζXrQz+9#D֬*դ!Dr܆2R`L8yrkSjf<&*Ϧk^$Y:0^ŵlR\niM׺:Od}zMg<ətIɤb184zE9qBˢGI8 ^K3HZo{K֡%o%`8O"a7I1ȇ̂Y3Mz,`|A  bB:S,+<5CECMUM3hBZ'_u,-JʂڌZ?gy&9.7Lʶ@)$+ &0X ryLڵK~`C'ݼduco>|gO^TPܷvfdDX0Ri1/.uuL=f7_\hi6:{fC2hc(N;}Cœ-H.-. "Xfku30~u}1 <;23~k9kS;G k0F?;ݑTa(AuݧԆK>#F rx8XzƱ`x^"L#+%gdk6:hh3Sykj]&ߣս?"EU] |xuH> X 81 An^Sn?cWಲ ޓv0.WCS&QqүZ;GڲXyzKp;Hp CM:M N]"@ޥu}N&yUW蹀] U oZ 폄xrKys24 VN4owTZ֢-uà0q@Ȋ,\5e[\pScL3,j} _[bz@GT<Ƈ%UU5-߷x$ bZinQd(^ Y ĘC3.i ]Z2NPOʫӔh}YQ}9G|wێAH hu#o~qwAUv- ^jiJj Z5>QgHF.;.5}X{:Z|6*:jq*ڗ!|'MK! :ZtjU?蘵UqYV9PSm`qx: -㻃ͪ:/ GnF O9ue98+XCޔe-&s ó)C;%Iv9\?~=b{ʭ S-7:s è}A{KfR݂OODT @_V4ʘMwr<%=ydX54"0~wv*y;P۷keDW7.cl[3{0hj y's&ۨˁN$,8b>ע{[z"Aj-VAs+2 RNhQ#GAYn MWnHY9S^O~iK4]]9Fł}wLSO6%64Ss6)(&px3D[uJR֑g( P.,+ZhLBq2mmWحzr]61X?o|b"]Ԕa4d&Ke]Fh`݆;‚l+2Jc 쏱ߜڳFt+y Hˣ;ڢڐF0r4IQF;Jam[#׀>wwmUuo=ܥkj6/&G*4ms*"8%}x)8<߲G%va #9E?fj^߯kwG$#xit=+zG`=vGD5#L}65+T''{שtJ<8!ȑD\:ˊF9tΫh>'r5 Bm 5Q`:eɋ@sYaǜyY5,ZLTW i^ŵtfþxb R`&YP rr+#5鮫tMje\b+2yPd;A]1Dl]x qn|;,).$.jҩgp/?~SJY>b/>`3usi5?3LrLKG&io0`^ۻFqaq{NvaឆR <["IFwJL,moY4B !'22o)ԒsƋ+VENj*,k{R`>6gЏ5 Ko;JF~)VH Q;}T>,x|߿B޴\*Z0:|HVNG[5Cԧ5oVYw&-08X͏V我J>f΂^B90Io`dO%OD?N6qMfJ 'UqJH-ZA4HcDZH!HYN¿x\0RjFf4t*sLY|{E}VqYdw7g``Ҡg%" ;UiUcֲcQ7ײ ;wm p"ظ֔p M)&0kw]8+;^z| KQOwO1~wpIe>& u>S!~h_)s%ExGZB?PmL)@.T-\eTqѡ0dYOڤ #dS)_ߪ.!}ALJ1>9ӷMK1B( ҁP۲ɅI,i( 2ҙDMypsϽ9CA!w T>ltB`dSJ˂]o J B/oK7΃s$ӏX)-$5\KhTTvw5!rdrD7)HMtNXIYG4Nt1mC]H/2QXX]+MG,DG 'i |./)ʄc8[LE)@JZ1i/|Z*'Ȇ>BQ'>R(}2&*j͠T%3b5uW@UP!մw `^ڂᔯZ0i#o?zQD,RnjX"S,n,zM4Hc23>`ˏ܄Dd ;l R9ʧ jIJz^ )u)z! SBjrsMEjY">HUCMw"|2W.'̥hEF=qМ7O;=Hl; pw-n0GsW v -5&=NxgV=;DVE5F-SmXB^J=)9F@JIc\XW(mˁo]-ȧ:񥍵!{nPmD4,? ry>%Zkc!ɮZGVZ#hXKwq=<.i z=mi$ګKE2%i),62c i^oo[ ִC;!QVXq@utl ޝSFg*&xQbDd. I/Zy*x-[l>-l#˶};Yva" /M]=E~ VDYYp 4 dehU(KR_ m"*ظL&B 8O⺹f6#}2"*ïq -)+R-|Zv"RRx"(ջ,lBkG@HffC%Gb!1kt<`` LcC?\tWZyՂKZxqY[M^ 鸲u[`[{4* K!f^âg"ָe)yde]tNRWA@i:1ɜ (.jxO~غfgDx4M:o3{f۠4Ny]䜍JF.-5[ߤ׬"NCZLLб"/鞼;:>:OvΣApV~6{A^-~+]*.L޳E@c Fwwef}3ljPiZxo]ޚ񴬍7T]%Uܠoiv{aRhQ@o?*߼ . φCg) c{ymP 6y1Ɋ˼R <0,Mm(K,Xҕ] Մj6R)hBX$@RE 8vR2TFe4ViTFFO*E(D6 pf޵2s2wgS&@rE͜T9D?UTlE k|sz]Va-zV L`yu躇"H65ՆÊ#V$< ߪҍe1|8Y}2aڳe(/բ'ٕL_:u8Br-36m7 ѪJ,r.J," 2"Yoa5{ZΞ-g驋^ܮΏ]M:w_S@֫M4T~; eCy*kC#CPσH,mxs-" ~z;3E$\SJX3]JX F1 #e[QS-7q,]Eѕ*x2ꥮ}+S"SP1P3:Cq a7z )5WnB-Xas a7P4j̮s &=J"o#~ۼϧVzF2<1Ziqgܜe.wm k:2D`0yuA]5W CU̫*oFM\R֪CCuG#Y$[GC.=z6Uϭ =iQmeUUP%*CKh-+Z&;eIU4UhD-@.ů-s W]29$'Qv Z Po;~[%8sQov̀oŮ }iGƁ[ 8FCrJh< l5Vz(d"~ T`sP:l#k,i\ҶX|4=fKSi+߳a)mhV^!qsvmIl6RY/&<9<5,<3!2cqSS[7wY¡U^"JI͢FD(/XY6!Ё]h\d9kԾ]*: UY]NoC9G]cx !NqR\~) 8lVw".Tca^CEУK­\;ԥ zPRsIM OˊŮb׽zʜ˜0aYF ƜqY4SAѽ6鍧EDJJz@'B'%=v#SQ&0AqScU&]`7"phlMf*!U"tl%OJV(|ݚq)cɲ*e,ynY8|ki|C 5ȯ3ƱWӓۚ}Csco{3%CƮ$V.ϋt*^͆*|mƯ[ _í k- ¤i2.:w:-%*VUZ.QE#G-lLvS Y'͍܅)=HcӤCl AAuYZζОF[嵶oWh[}]G$Xhs`3 ɵj_MV/f0#=7"R ]H TAHA㰉o%Uh~FSpP3v+Ľ2bYxz}0S{eL-D`2-1ϹIF:H,svLö4N!pyD"OxM5A CvSMQ ; vY⏻#a]r~o+/HM>1 w`Gݤ#޹ޱ\͉l˚lD;Q%p14ʀ8z<5 MO}rXŠY3l`﫳[EFԞLM|9dU""';`(K }ҟ䏢Dˮj:ڿ'.D)PCkY\җMdz NS)ٲN-WZpi  r-(/{/IVHVHN88JVPEvJ."Oth^IzdnfMZud3#7˪z.e7D";CѮlT=C+aU^ FX0!y5AڎDT5y2$QIq ?\f赨Z԰wF; |{H}5ҚWaE\vy9ڎmإd-Ux&tqvV`.Q+QZ-sZsyC[BiZ䯸pVHC_])W":/^ؚ׿z۽=ȔJ< JV 48x[:mC 9hJfb2LN!:< Y#Gd 1 -O,G:@B g{,|Nm5FdGfa:<^ 3S2J+b8鷴zä!*|tgT#AL-zc{al`"f&G7[¾`|AR"!flh¡J9-MW5uZ/G'I0Yz" 5c1 ?I3! mO}![pmZ/4yJ %iT}叚mUMq3o=MbqcyMZi5u`]j#X׻k`x>P^.@Oh۔"tTn#}Qg;]q0tTG'9<S6HEsbi:+C @6Yؠj-Ak͓9hesГr/ڋEg; LN)s8F]gnV(o%Mk1W:m|CO2A^GGXլ)a+6LX(,/BA}^dD u]*)U; YJ5N>52,:E* p@wo=]W8^>ݼ6ah>v0jU!{GzHPp?'Nw]z,*vJA8]©֫JX?OviWxDY{smo)7n]A4gX6c _<Ml[Jgٸwdv~1H? I<4␈M\CLyS@,Ԇ!S~YG Dun"h# 摶<;F%#iؙw 'R5u#RU! q [0ln2ҘZ%cO5A *Ɉ;02iƗ'@eKL~U^1֫3T 0 6sj1 -ÑJ;)"X[aZ1h* ] ZX+ռ}fBN)oyptZa 58j}tocݺ<?y;Uv JYi\$WHف2T+D⬦4YC+dZWo_=bWDZ #?3*e"*kfxXXyF[-煬8D›zBlSfc;] kR~]U177J4>"}?\\Oaձ[+ wPyN}_wfI="T?gH%kmJ c?M аk2HtײDI㉨byC׆)u9z6TV/%9%|({d"࿔q7|ddIWfJm#H'd;*}X/ ~EX ,msCxPцn b^عvN@i j $uCUE8J)BQࢁ XT0KK3(l9ɧc*2 GJS0tC0xt?*礏r}Qq8ٽKR/lc9/>=qu$Lr3xQrVN09*.vpug*d.%BTQ)KM] U`QwMM_Ə}/CVEs,aP0s) ŵ#^X9ZWI|Qո2YU2<]DX^}A̡lbC/A~# ϻQ#Oe"iso٦K$|N/WMdw%]+1K4˚z/LG ʍ+$7/BśƈΠZ FpQg ՖK- d1a3`?$YZ9O,d :1TZ]:r&3q # tVBi0Yo#;!(m{ʘ fL{pnϖx2m5tR=8cK{<~ʙ}dd3wv>x(K]+QϭnhIs"&QN15r]j"{ itEcl]Z`z5D*,@$Wk%,k'WC}v#2eEvDTwO@p5IIMYE5; 5ڎխWXj;_sm>V8 r<.lvO M]5ϼiyZRRsf@m ն0W qS"zn7?M&^Z%aCC&ysJֆԁ/o&ټ$ފjQLjp&܁#*&]fiMr{b# }EJjש[$m9ƿ6bo77uAK^eD#n8D|6'LGf`5ِL6)%H]Yx\zf^8x$qKEUYzdNJ/p^I,`b5$ev #:F#T~n#3H_=l Fe*ɚ^I\{?4AVres촢kV=Ғf%Tв-xImwp=mEntl !*h:3"0 C3ey5!N0.8f->M=bgt{%?:1}Kdxt%GMM /T[a3dk,p o n!<7ҫ[]kc4x{6ivmvom]?0o׫6M+_ۊ)1 Enً+_DaۈZwOO߼2аޣcngplh;Ǧ,d6nI"-Ԏc5X܎iEؔԎ:2晗NP2i<./gdWJFEINXh Ȣ,oDq?Lt@N+{2_/DsLYDTe2Ls++WD7\ߜ/X j-j^j5jPĂQ v(9ZUwAup=xx=멍}4zvXoԎ_omm-?-]-s7`CpE-מE9᧭nBaivx.k0]e*La(ܝMԓI=?̀]Zaf]+$|m(fpop WkD7vc\pMokMhG+<{? UF£= mkbt؈46#!i.EanK&Sp)u'(bn]eb墓-눩cP9ve؂IJjԞI[y]/翔6ǁ]o!Nf[ 6CeAPKh&ݵvt7<kKU{ h[+llOl5Bm҅cdq 5jЅu挾bzc& (wGCZPE>ˋDܑv_ %@#O %fQ^F]50`ȋ~}OKҢzRHᬄ8%҈ Ъ9=͜30)CdvӦ P01($i4Etwv/+*W{*OR{B0;{Ȑ?*L͜3,.y!×\7\XҲ H2fi1!1J3Y;캎vǦ5MðF(En߂t{|0$ʝNIݓ{/h+#kSk~ACJ{H)Gv9B{o[s}׬k׸&ȽoxjLQf6t&Q{!TVp'rK]ΡakV9drAsQ 4XM,!PӺi L2H~C bCRPDY9ᩬ֊6mMe,lxP $ިa p@ Uj惸gHy@ò%d+ >SI(_ƍyx͜63˷ư׻=D#5[`ؿֻ2%G#uWfeY}zVZ/y'yHupjb/G6Vlt<}@[uu  A| jd ăgd2uzU{~:Jv >g3ВJ!_lX~rke 1#PR : P 7Y]yfa:oT!V$J?)yG5V3%IjjwEysX+$'7m֤sԴ ̿ "/y;l[^#!Zpp9,Vq[MSxƆ9H~>RW.{j)%u "s_@jQޕa4g/YqIʘeE1Dǔ2xWDm3AC<^0. T 6sזv.s|^K~ځ]v/ZN-ѩpqU-~Kʌ. 'W! .x/O [Ar>ioR .+j8ŵź. m4lAgS#Gyr7$}j[j[л ]nhQuf5HW(M1Wz VI2jDp{dӦJ^~曆 VbElG~\XU :Z!ԢګE4ٻh/oM~P?,%R/j3܁'r#VJP4 uFMt:xf뢺NGo3<>FP欀[!:e[;fGKFdT&ki7TĮ6nfhadP )D(f,whBc{И(пta?ruWf|<+A÷abiȵlՀvR( G@T1Q#8ѿqȡڻ;`E{-j!WSԌ2xid7sj*R` 7jU kmŠt 9DͫU-MW[G`IJ(cd/D-}X&CCDUρ+fBe9r#jeRbKGLC98bD="B!7-窾b:Wh1tE>dlL* sS5Mas`!&_E'yX>Uw)v "KWw -#xc^Gt)ZI5-x&'[7^g0tl^WⲆA %F`ѝQ7MtTjr,Ʒu VlxO&̓cpD|n@mȪAV1zxdyO._li*ɛ2㔃+^n.ӳŚFN@&h/ޖɨ?rKњU>\Is= 7ڊGo`VKV%Q߿U;A`(â$?L#1TFz$f$Cڃ s[,-H-b?[~ 4}n ;B҅i')KRE{%UV܊T$jz٭VMi>-Ա9j)DD!g-y~\CfE\LQ 2~S^ˌ'(IVF`Ռ9P[7<)lD1-2uQdski-˩d: G FDqV`?)Q~qч7Aa>$R͔/.u_ǝ'y$:ĨC0wQ&nXIx|P~ٶɟ!oǐϐC#uz/Q A1֪_'jtK'76 qr/=,Wsd V/`z -P| 1ILNc9'٦$+,O@ʵ "'3PqKKi,`1F2*Q@ovq92{~! ^ߵQ(3yI)RŹZ?ʁ"AJzBOڛ=;3ɬ 9sw}g<ـR"SE^L)yĔZ+d q,'^۹ٌ\^2>gHRP\3}0cǫdszg&E=ssޘ 4p}hNtf͝N6P 8`>kvfnB;U)V+^f(G9>ڦ Ap9 #8~'CνHηgdvhAEq걶oڙv歠3pX1^A"vuvbA<< -w2DUNyžu٦ۍ"Y1Z:ĵ4AnpTٞZ!SCk^8;Twf&D)M}}C"se\+yɱ7pB&vs.Ϲ \u~J:o@Kw:_enQLltvoit1b=QX?kV+e3GG67nj+^ $ϋ-3crknq yףJ*W-L`83!EPR O MR[v{kGQ_a+ xs{{6XMJ_*`ђZYg ھuܒxK|׊U3r%%a"r?$|D6T TňpSKV'+K "t|W-$GkG _\NtT!6Y~̎3R`Hdh=C4epI}pSS S U:)D^t.fy!tM7{ŦK-W{js/8uZ@wqNim-ASX;>(gΝ/ޡ#?O"Roj8y fjeF^uEhaR[rp` ڙ BK@`*,8v3Sɼ)@A$sF!yРI=K:v 6v.Rf߅U$`U'y؉}<1wNXF@z. ɻfx5^DaȳG#kKXnj<}ŴBEA@KI?f( %CRt4 jLtb၂n@猥L 5rp1|n{ ;z^7p@j ϗz] ˝}#fׁ]}LK8HϷ:]Tg㸉WCƃ5Uz3lQ kTؕV}4uǬ+NU7)|)Qu񻬅BY22 d>Y$BuOR>\@&7n{ D^6X}"iw*/`mG]qu8[G;zEW!rӘh}#~Y*]ڰ{]{,Z[Oˎ,pJK89U 6:H΋ _J)-$DPmz\DBiH<sA&,FYO3H_9킢찃!O$Y5+2/{CzdpO*HnҰW_|~jms7]}|b  Şz >!¾F-jTZ̰|=fW"H HuQ=mT]lQK1Xksw7KH£7ϴ bi& u:][h;, %~WHR[y!`}%! YXexxh:+9"aN$І k|rtA b9lߓ;l/BBmlG}kPڻ?T͎'4iZ_Um5$ |:F4#in5gRma|&թuwF;y3+6?* <~{d mWh۔oJ:=7Eu2E ص !zdqL&it=3tz@Waumob,`J=CJ +wnve:Y[Tg;Wlz2 ]m estTtN{h1 uN u#|inJLJ9+=31nd w* ]~\!b2o|W\DNA9ĵ?^ 9/#h m-_Y~h=C0[Xӧv L/ģ괎>3,:J;,v"XLjc˦R.1ڬȟ:2T%So!(]@?/:Ml(a- |" Vya9*tݵ<+ׇp1;ϯh)<1c'z $bYU#]QO@ƶ*$<Գca#b&P6F :J'ôeDDWq;zbnh6^g,F<ߡˬTv,ؾ,fź0Zs26!./gx2)[Ӱe,tOR8YԢte78B0TVIUn"Òt\S6PJ<9=-N> Y:%C3f8fSQH9$"jǷ6a4mpKj? 6a4M/_+mB-sL}MbKҲ9?!}ͨ>ħ_  "Apͱ!bI_σuyeCiM ?b j6Aw = -iml'hr9*s d, /k}`%|V\.4d2g(┚)AêH*&:5PY՚UY*C>A>f2͎\bB#v7ƅ}db W|q:}įsZtxpTTe GfbS=e;":X괮cI:PIxZceMؑY=mXn/=1Euyi]_ǒu˚ֱ#h{Pz ZW5M`0K5@t' +99;!4{;l#缎׻WgNFzw t!6Enl_ܒk2HJB []wW]d-Fru )Hk@Z(LZ[fT{#آ+&x=G-,F[(k AP)wvׁ<(}`KX颂,Lei64T 4"83ǥb{h6"xҶ+qT]峊ä/Wg{bڷ[r@ Qq^^h %; cx} 0"`A~[x;C֤#t0t"Oa0Ա,jB)u ^ON^2l?t{4i_6{\2^ lv4rG{4n#SXg3uA 2P 3}PKȼ-h&|d/aMU@dX_/v"Qr7S@%)L͐[u׼H*R&^ ;ۀ6euI7 qaI=(5Ih2U9g yf@R4e6ujU!/Lʩ¹ҙuuLGMt2~)i^F~DMۺL 3TS7Wؐ*K wUz>rYp4Hk|]j7زd'rL8SQ]J;ܒ˖EܶM/[%BN5;V<4Oq #=y\`ן7i~a F;8'-{ ߃UK}i 6Sˋ31PEzk~OdX]7P' fNc~ `aq#Cq#<5+곯p ٣r:B`p |cĈ@Qj|LEr\Bs{WBC&CIlS2OvI?q'|:3b|: Se&QȊ}C?w(gTe\eʟTw?'tT i Lz&Ö)M8xdԫ![$4Sp~^bu:/_:YYs{E} nxT 6,n^y5Vy偠@VDX*AN$^)ei)EZzQ-lbyäƙIH`5r$ҍӌe|<ܗC뼺G0RGHR'=a 4fybv'"Q lhSA^euN*Q|$$\hUp> /+xA!U7Q;)qVƆu{pN#xh2"%p\m x!14njMWgߣXC*pJU{ޮnd|$ARjAs"-`E6։Bl%G'zF􍪒PVI07|rTi||kЙmX /[fb%?aΚ+JDZo -z.yQEwӻdחsJGy=tTb=a- k1ݣYe!/E\}+7#0)/UûVk\5} (~vm?"K(Vb>:}eI6} .!m"IŒ8>@vAHͱ!awG@ tvh#Á(LK UoT_Vެ["Bn}_r Xǯ6o6v<~ٖGx@[5&׌ekνj;L |<<>E&~;ϾuVQ|!z+UАgpSނo**iW*Y`DYƑ f |Xs :CUd,;[Pס2j}i}BI~L֝jc[Z,)_+( u=7t~6J)8]H9s-R1nm׎0ei_FB93>+WaUʳZx4ob. Gi?+ YiAy4#<$5 y75nX"kK fS sqVrGS^VS|Ib,k~2?~e2iqINe3ݴ]fo2iS^S^]լ;*Xuym߯s>_5_gv)Cu:]osX;L)B/HubbA;LqQ>DqKdm*;TyP̟MwxFzȍZ6ɮIF+͟k\77Ԧ BlnNbLm)N~B9G sힺ ED!Ey\QtfYHzϙOmf!J2l2wfWZpuRxD[|/OygvyaGyYW6-߇)}w+fkfQi:1Ljfgxdɓtx=ϫR2pw˼J|8>{zvtO`'D__!׉␞\؁RArp D@ssG_Η z'`De3|Vb(TCbyƘ;֨fhӛ;Ig6l0T 62U ӻ5n^SjRITB{ۄ/ywq]%8`>uE^$.\?]?AޠNMziHLA.7 ٰ0uJԮy>osjnz`AdqjH mO%y'uz-8ezmyu 5͔<3"I:.s$O$gx^hKX9 nz^$3Κe4\1郵ퟣ>H' r*煩V~Ю>WpƁRԫ382d "WO>tJ'ô\ 8j^ⴎST-5UtT5 MTR*Q*㨩GM5;|V%aƹYQTbq/TKT'|= ('t{z=#8d?ɫ2d |%*؂O{_VgO% ! Er=*: s^Wrް:M*?'bmKN6/{YdIgUŰyQIW'ģ:x 1e8ö>dsoCLNp)cQ}*Sd,Jנ Ko=upw4MD3b=~qM8:88c-6OѾʮ8S"F܂}3n`ˌ1 FmW/];;q g= (&|%)m̆1:Tڱ1_*i(Y]t9IRۑcHl"~i6GlG16AmMYH}x E?Ѥ$M ߠ(U!8ihߟ l3eHK r^'- %G7twpf_ *e˽;rē;- l㞔Sg'?9 ԌuY?jz}DTsI`2-_u~DTGt+w%kk GDu9'eUp5+I$X_I:Ue&t[+ o.*-e޿e[ ^z(_3AH wBDY ,W}D5q0y{3RqplZP>wY|8K޻2( Yt9rS=i- Wo*h$}Դ͇pۥ\ |b,2(NƾPB`: V2,$ C;w:?F+`QPBɗI4?Ԍ4 厶*U?BY"Xsu&0нo D‰U΂uF㝥T'vQ_G(;Wu61 'Ց-ZtCqP&{-}2˧HCE~2\>SaD15.g np`A9c>+[/'UdTI5+=RwpNՓ8K X+XefŊ6˕yM=%+\)iOBȅ$$]S J %xu:xE$Zl {yt5t-v%:\fn4BP &)risBlhYc]ٱjۏخbĎDI=y'2H>kup΀- @O8`(WwR.VeLYYyF*fD0C*}rW`GG0((Q(x7#8΍Gp#(jVPDCll`ΦOO)4%Ʌ.xr:8EM؈W}轣15^Hh-Vs"0J@G;Q:;PkX~TB& l% s˼JZ$ $O66PR9Zb W쮑!J0ЊoMH`R.<:ܽa^z>;RS".R >?/1WV5O诏k[oFjdඓBgm^~g3#N"ena%}8y@tYpǔnL7;cæj}X)BT L1=eЬdB0 })x%7(>T8_^/Zt+Fz CZqpKl+=,r:_FK! o2d 6g&lyD~1a[ A3-o>%wodJޗ/8;,+g՝:>4nAӐiS;>O0V.D/7NV 6/E8%ĉ MrnHiS̡4L8ifD?Y;F7qv?vN?Qpms & HԧKD)oǴ'Lt; P.Kz: ,k}+PqD͢'E@*J_9ʋ*l} $'wׂi WR6xNp&+>HjKjZ|b ͖GZ*ɗgC4]yS_c(*gt5=#C@?o~Qc(1H\<~0eG\ LutĤ2ΙAtm: d5w:T2A/{?Y? h;ŹTp?j/S\FhZ9$|l?0~Lҷ:i7vAHi1H#N,BO8T%Zd_%;U8B6]d uqB q9R+D/N*zv(Ý+! F&(!F^afT[tBmP vHHaei*H `V^\@Ei,;L~Й,G˝X7qffpV1RJ\ j2zfCGi7t!Q, 䇤nF+4ɇSG%o^gX-! GsdUOg wLV/Hs!Y:kg)t]3/W{"82~ A7`o q`HĿN Cv8YGOeDYI@oSJlv,m*fVө`n,?@3rjD="36?Щ { Eԉ yuBL036rfSG.@@h-g`*;P󦅆Z޴D5/8 "9l&K\řw7 IY?sú6ݽ@l,9J5h ZWnۯ]vQM?;V$q]zf WE0 򠻱4 %˾w$|ąس'X>Z4ׂkk9ۊۉgƦ;@ycrGMFy|\$Ω I3l>wԞ8;x:\fHqwMJʭpzaϵ aDm1;Cנhǥ'P-e6>8:YhxO>`}Ej*habydQO_yAX/W7$Z`Ein+&}0O{z}}xDFQW/Ȇe/yϩZ@E\⠿bmǞ Z] z0pk_Qe2ɉ< o%Q!\S6@©rSs.D.3ͩlAZY'q/V)^iO\=;U]x5G[W4ݡSx`?)>O\e6t$!?4/h )S \ Ƞǟ~VVvV Xoflip+..靟F *DUɍ)\qb)YkYoUV W?8)͠O~R$pbP1WN6 P}c2l\P﵁ AdP+ ֵi[;owti9Y[t0?QVyXϓ\`^Edem=IK /Z4G>B%DA#գDoMsyt젃(=YKbN;T,‹:X!L4 #TJMڑ`|Ca" v.“$D ="fge2iNb5NeX2q(i/Y>n Neܜ=a18'3a=MsA $ƒ/^Tt+6k5&J%|R/e0N'z$kL =utFt_h0A5Esz UaCuWC2=KtOb@\y(ryq9w'igL.<%@5K^{d%s8*nŽ07lpUKPfeHWXR(2.g!Np!j8` ?{;C@hTi$^p8ؙEHtqaCHHc%Nb`S|m !@o2(-Eh"/y#$$sF~p~O=Gd0 Ω7vQ&'*CI}Dh<߫ޛփT[ :jk U?$SAha\ eF~<+uYk85" ` 5 E1H+݁]OE9$rtqv;E+ >p7VA>!j@1݃MI`ԧF~[mMd6'&3NID֋'X*UʢH?euӼ~˄oL9fJ}M BԮhA.~TG;AVJ'%FLM^˫uы7:E \TMHM@BòsM'.쫛΍&(OÓt8u 0YqZ>ŤJy+Hat^x߀aي1nw0oWW&sGȇtVR__SH^-Kﶘ)u]&J] ".QUJb$<+kw3T,,jf5kM;rmR[n#Ԗ1ԇ XC% :$k0ĴIO"=oޅvP5uFQAԪ Zfnv 䵊IP|UJE~=M'wH談պN3a7 1wG iPe䛣]Sn;R(҅G_ӓn3㈾ݩ@C]ןdrANϘ=^͍/jSެf. WE:)J2-N$;IgQ{A}(_@y?=z=zz=9$>~tjnͪO9~eB Ï&IMK|uzkŭ|S`oF/>/pZfݪ~ׅ{mC=Z$Wcl.']{/ ܙ¬6%Q@=fbKD(sƟ5a&'A033hC"hPsM6cgsx_DHW+3~pSkJE*W% պeQUx|YGox0FV(h'bǐHӫQ|e]IڬA&"17rnseUO 1Hǃ٘7)7*IoѰ$&Hrt $-3VpޣBe '|Yti77%UV53oJ]l3e9'Y5NDs6FG/#_6HawK> ̋;X×{5+{]ƕ:V(onyb:D*_߽BDOz{h;,>-%Hpys9笴8j%hY3suo$tm.j'~ apd5`4]wŭgL(N[9$` o>'`i4 Nσ&YCށCM/An{f{GstH ;bߎd'BVU/.FCD3N!$g7돂?ԟ񄔛gy ?8+Na;ׇKzq"+䰊|kW5_$V˴T>a[j\l qɎz&{W$Δٲsܓ!vD`LL5Y%k*i*胊 D?X"r.dߌbvgriF"ݡL┣:Tyz.#-*Nb lyQ`Gk~s;i\!b-"S&~.]%״:IC |3KcJ rӽU:ܼ:\ x5?#Pg3D3%]~fn7 oR7g$ Yɛ[[ct092䌚I S! 3E4fO^$I *RϠMVuvIǗlRCJnDHRCu&)[:FRfəâM_`ţl2{"F͈ [Y^U~&٫Z!3uE0*9a}zʦ'RܭlOt;䝾ꀧ$p$ɝzX=I8>uf2}%CFlx\jqqʬBMSoئspdRi +v2%S1^2w^%I37nNJ]J(1Sρa K݊_))V(Z[!4@}g%Nv#(aƉ 7,i~o9UfvC'yǚ¡w?$p+? A='<\lc29Ց,r~%XО0KT*`Vg7cz*]ϦHqU L(Yaev6{RM7L P70`Ob[XS{؊{$LZ&D֒| ]H, TT%)PD뀵ћQZߛӓ$YX4 SK_Z1|B|R:TR3T'`Xo)O*3^)~Ғ"N`.]@[@c`ctcKD-58T7" QߎrzQ) IFcb+ %xΫ\yb' D') |2`1!ҹ/Ɛ\G1ဝ_[~s{+9}n/єX{=:?pWXyKC- &(+bpudn< MۈMtUL_/ f<ɦ%)ƣlBZB^2w%.L؀+PCm:%We/7"NBq:c0w^&l_n6!/o暹#9n!N#Ш|0250`6 ۩/(W)w1G)YϲwIǣd@cf8ˋ=hXR$r$bxH<5r(D[O]&wK^^'WpvWppB-;! ||i\A%+[yZ1;wd2GˠJ |LJ!T|dJɒLG(U#zזEimSzܛ=19=z9 *<1sEimSa9Kǹ4F9t=Y4D4{N(m*AF}ʌ@$zKBu}d#>g@MĭW0i]+e54%lr$+ZwT]ۯ[CCPu+fM6l.W nȯk*`-+@̰pCN^cU\}Ea+k!eѠ~߸+q7B-mL ]*e ?A70QHW͞wE,i {Kăi" S+hNR lq5[{E>êk)C0YiN*[IF$G bSδTV{TUE`H[pxuRoI]Geu'3 Uv|zAI;5t42\n.^a~D]]lt*ChzAvBn$k]H3N (EU*==ּ1g'>ɊrOo7$2;H911H'.aIYyd5R[D6~Ahܬ녨kwȦd0Th e#x:†uwexN|VZ[ +t1sxݗZ{"N.G=lj(65`R%\j(Xeha{r5;UG}Qe`q" JQ =&⸩ZjYꪪ޿Ic/_&LȼH'S6x%:ں:6M#dd܇lj#llb $';Iw#猍^5"^m4)g/Ya 20y7o$oiyᖡ_&$KpI,M;O׾p޻y= K =)>+_nH"4jYw|7VBww8̡Fezf젘Kqvp,<ǰ<] .鄎 yl4? *PekiQ N3AŢTk(EkR+B̓g|'wͧ{O[`[[*S`XթRVDhTNŵ,.Xi{Kc"&""-G 1*whg0l\$كȲy:=@HL,M4Z\kvWHO(UgiqW~1NjtC4+o7E[pxy}AyB ލ-wHL;k=!o뇸N.TS8;(]$ֺ?RmӌoS0 ZW ,Orӌoa?uX Rl=P-@U~x2S*d|ӏCYOq : IwcUdd~2iJa6-c^a5?&()P?xr=~B6EZ7vxףr@E55 45?QI'YCj-u #FN>O$.@f[\k+e4hQXxo$ y ~.*?KO\v-Vb :5:j* N;8X~;$ JyҎmm? Pַ[1|v ^g&* ܼdrjjp4W!y̧&"-x.ۓvp7l<Tɋ@^58ɗ9v\) Z>[p%Ckq` 2­*ʸWwZ˜{Uis<1%X<:uOð BE °"?^79h56R΃.A\R:Z**]D@K ,aaÔYKWN{kl~{VåRAGdTĴ>^k.aL_ }22dXY#9k= Qut5lI֯抛`@}ADNmqL}@TKXGj./ٌqD EVWp9[MGS gkے ׎k2P0NB r[miPO1)m)'Yz͆>l*"bf "f¡}$"nֱ`M.Ҭ u8z's!Z\`[}q-(+/ T54ۂZY/ulw5YLJ^BdAvI_RѲg񚣮9ꚣ9*FkL71nt#xx7|<1*m۷sy#ܮ'#mk7 Gnswv5qcPMc^(r]G+rb2 4{uhaM7UE_\HAqe'ؠb^_K_֚ͯ$G1:Mpvb߫ҔuוP`?Љvԫ Ps o}NYGBOܻ6o5㽿;9mEVwsi17@k+}mV շi1>-;;NgQhk'B;aoi[? iK&ۃZ[h0vUdβCcYsbusGsMv[8{RoDhiS -ԇ,zo5쵵P^]s%=iֹroa~Gg7]ǢV-y:]aR}OY) FUypPpM#C/6ղ/k,FA2~<g<S*\K.nڼHST45 3Ʈ BgEXeOռl2<<uQЩì;\iA>MF8@ |Ї8b%/=cf1 IՒA㛏R׸e _>MKښu:zӭ9"\6) bYZ ΦiUEi]f0f{`\*&~qAwR0]ّi[ BܳVPqx{u$IZ wPjů+m $]=j ]ߤAq<*~ ha&T(!IN?oXLHvR+!io2\A< r8YFp{Ɛ!Eh^1|H)L+}fԲetAFZX7W$q=7+t䍂4O_+D]قRH0 s0C0-o\UgiYr{Le(ѫ;&+,G&IAZP}SK[썫p@CMD]2Tl5L##ZQ5XEJtش~jƸj'G:/N66l? . |2̪t4~ɧw&A/7]r8&?{ ?Kϧ3Ơ6I%+qgovD &b6'd/ă2nS6eƣA6)9'/̆L m|a-I"ɔO*+_&$3emp|h7 \h{_'B y%T*#!y2(r  ٟl"(;I|5(O$VFT2EcJշ/zZ[:@q-HXЖ1*Tn~V8rzOjEחH?/NKv"hĪ>CԚ/DxxE"]b .j kk -!njt/%\B2>HՂ i-j9V9r4nc.c Ș8j6C8~• 2uL) 8)%^<ΘH|)OQdEi\ruJƍH0ЇM<*gE&b&MV=3<&~X?yɞ,O7q8;|  v:ڤPVMTyIدmns|ۃ)DVc&[~b[~bZ~bplqS6䐿h`iLm8nr )[jϋ>W*/I \(e⒉,(ۦ/IFD\yon{` `_f?^$dqJsECl`*tab<A;-97c>"8(rƐ+Fg[V7cwxJW,&ͫ<=-@5ckE\Udjzو( a+ 6XABgA?ȄeKJӮ4wb9b6n$sC;&W$-$'{J5"GcÐC9ںht HQ6+"3[ht`!)i3vׇwHOȳf1$/^Hsދe*عO&=M{{]yn&8[~\vlIGT}s`ۭzw jQ\J=/=={{"@= $D a KIOo4MѲ]17gR<b!.fBT˘Wws5ABf3\ʺ,y1d4SZ oAiY}.dȯ?H7\Xk ⣼NKњTq\eeXlO3laj 4Hb(!|pz{Ovta-c 5lLۑDϹEC%dK>z%IYcǭvumzY6a= .];07֋"e5i#I{3(r l1wۈ:p8nnP* m}i+Zʂ5+|d_0g"+vB4q/jȩF~ F'x7-{{}XuQNQs[ԓRH/o@L6F&4lU̟a8=huk8)pB闸Y*p{gMH}y>IY%KoX0`'IA*~ܦ8oYK$n>Kxb]szXn*Əeca# (OasE5>ݱ uC&Pr.ي{:݁DGH)%ծ&6ϠK6A5zd<PXL^L|utRj Ri[(2I)!.CP+s 1E Nh2X1>C(]>*?<)WX*4&o9Fgj>پX׶F DjF3t͠lG{Ve>W7=)ǣP"lL6oR @Yp|؏ SNKtwXԸ0'*2.Ÿ1¡{Ahm?M$6)ᯍBT-UѲ*˭f">$^]L-Q:{H63'aSCjgB|&I O0rq@<.>ȳ:uXW]VyAq w^wzZ=Üdj%Q1hb^x;mJPD ).Iylb7/鏫GiZn}AKwiDE~ ɒ.ՕV즵L'Zա2uQK!cFqb}%'"fca`wO,9Gdf(]-4ml%!4V/2olۭ\棖qS.&QӱyiTͦ HwC 6J6Pԙ͂()jL=5'wmß99<NN$.^I\'qNڶD͉+[}ֹZ|?O|NרĽtMGB gt.npU jMMESf!7(ãt´6G/D.p>|;y{{Cǵ97̑c~_蝥/AlLE/Id{=r1o\Tz$+,e$ *J 4\\[t"҉lGw 2(Zcc):i`TmmXҾf Z*._6b$d`O1 _InjT3k:5u8K-NKt0L=QTVh<]"ʿ бr\UJGe#@䎣zl7\lpzf3- [Uicrpפ%=JJjDQgla9Q., V>(vϴ+:d+Lٵ‹||n1ꃴ4@o$|I*%%0]rj|~ -U?[œX-* q9#U"Y}-ხʭyabDnd"'}(zCnmA[ XVѩEYBm H2^7NrHC+,PABE\u}pUʬ ggR9񨜋cAXr+ÙdHA{9::p͖Wk6-lZnfK5bfӒUY"3!jtawòH x9 au!jp]- V52?o)6m+q~RFIjB<\o:GR"*H0ܔ qC8 >>(sg .*?h-@RᎳ汮 dY^{)*Ua#dђ*S`#vB%į_{ree[K&fy4HQFmM4~w -2 ]LK`(TLj4TDiw8 +`ߵԟA- d^i+'lt3w:K mDpVT3%ݍ>0h"= eQg!.?N*V#w+Qr,h`G?7v]D3pF|n`mw9`MdVn:57:vVq5b/U B ~ukieo\ֵIF8/'=$Ʉ/ e`WB޿DU^s> ( vpv=H:8v#,pւdC[*z\q1C`3vY 2*_õP?ƦZ:Z<] .t y>6N]\4Wl&ȭ;YvD'ݛ{Fud>M@lwEێ yJB:4[-N8tPYr/إoayZw#ʶF`-ݱߘiFl_w=D7`a7vK6&Wm>*]m[ZzOcU ﰥ1cZw`YBqC`9ٜ6! ͐.d 'x͇DèWMB 65G2\Zb.smcw~n))/l>9ݵG"VEdVqJ\u.fAED_ a@cEm4k}Uٔˏx%̵Sm,."*'^72;GK8`W^}S'_3keEwեU~T{u;ǻbhm(VMb-U {4n+~ױ -"eNyN=bMbXj%UJs~{Ўd uHh),ψݍ->V02^8U%[X]wiO[hihYu]TQP"h&#[l$i:)9؄'?h7t?HTA*-I03/w[^(Rl# ˸rVGK6Q} ϱyy+=;~YoږEk#9TD[7oS ~J<+=R8oGX݃cW Wgo9.$*x| |5M'\e+]ą@RL~Hq'Λz!x,rs.I˛!12zB?_ ?]W*4 /{u#0;&0`mzx)AT dS $0Jt{y` sHÜ" j*^Nur9gj Pnq^9DTF2^d9~FB%ii ?@Qk ɺ\ z?h D3>9攢u Gj0!-]t% S2ɶfۉ=/GŴܪ6(uJlPӰ0:kD!EQ2≂=P&::69:ЗBn*W@zq98rgnPr A*#x1y@̉Jj.A215w0,w](Ҹx1MگM~-1~YeVk  x Qa,gXIG12|-iȑrEB) ik6,бRf*~-K~꨻}OVf"n>l` sѶQG3ɭ4`vj͚F-^#b~#oA1/odRaY;%jެ0~71Du:HqW^lQCv0$TDjՐ&Dx{HE>^ME2eNJ4m]f)_0MWDlH>q8"ܜŗ,Va{$\(4 Si.OlLZ,] D. ҈7τ&5Mv[MwLyb}iA}I(>8.g%MXd>UkNޙ.E{utNزlxoN&o_Ph2TuR WӳߛhjBk~`-]BBWlk%@<4erPc`%NiH{Li5־ rHIv~tzjwp0,e ~Lu5Q-PRAn-yiz\hZ}ռݨ31zI;nUq+79`W/f=R`rA-F`<P]?tbG:1E7CtE۴U#Gπ}MҒ fd4`JuXc032N,[G ,)nNt\&D2$MeмҨqBYs nz:9OfZ-DŽ:nEsg~Kt[Xް#XUAp׎fᾙɼ E+kKu^K{ҒFX?T謜Ds"z9 yxHbD9L-O7Ģ=HM%Bte+ F:!:,꺜 Y,`99pt$WOP KmmJc_澱~ݼ\sS҆^@xuprzVW#)=Onx%(Q*(xsw& LǦT"JO. DsFEqL|6$X$ٸ~N|c7)\y3jΥ4x_JiօlJr9+mYrA 0)sΪ@ɷ50MA?| Re"U9hPVSqYB*WIu2JpX`h{|N{znd(pqFWSUQ@' =8FfC2U>Vn2Xfe)Q0U[.aЇ?;cûnܙsDP%;wH&qx7JlZA9HySRI'r#[cNY%\R_.k^-B{Dŗ:Swp]\|UtaV#ϼ62{7Blݔ. iLA,Tk+mf8v-r#mހez! SH$E`t.]/ x<|6kyzcރΜkdI3?KrT2g]s _l.x/iu9{>pnq_l}H%UIb<٬[Iͽ5:z}%ώ&7k`C|GҾ-qQ@V|X}-Gdэee~A.t/a r4ѐ<V3A wzFz3< {r :bܚpqc1iu ns]h H' |y*ݖOT:UWM&*$ (^~'~5kHj*q8RQe:^yE vE~jM-V ry8VJllx%6iLTLc{ȏ޳GZC'tc {WF}plm4pe0zŽ4B#qJж!6luwh?X`^ O&jA g׮|ccOMO09*ffn&tC+w1Wl[WO_sX&|roƻXvd\]62,Vۙ_eۦ 14TVhDz?3 u-DKp7N<9[{#vSOuG~)C$/w>J{m6R^Ua^SPI.%< -`8h|d|D` 2H&cƕ!(Jp2@fwNӊo1B>gKE 5;Ad/P/_Pop1;^{ηuOh 1{Om(Pz# WCY9AX,˶ orD'rۯ"g{BdJɯtG6M=Kt3|#r ~V~W=Dsv- ڣs0۴U߽=>Y}U0f=0^҄ <!yg͹ akdžvoR 'ֆG`ی_#-]?SL9vs/3w/عgK/1-g9}ak]1.k c%_uпax!dA]=vp`3F(n98[dcrqOS=لLjq6o1BWFj']D=`ɣ„[5A-r5V{J)M)Vlm۱ - &'Ў܃zjr9of\'Njл?~j@nc4/"’ [ 4l8?#Qq]&B9-Cڅva8׵nӦ[qO7[0abn.PHOzȟK/P̵-ɶ ND.v|_CEfGQ~UA}|C:8l7oO>tzHO՜#J}\ ~Q. X}nTsR Q`)(hW+n&x멶;~{G#û?5d|:'tps=`r sM4`Sd8_U"JrӚ*˫+Yջ4qfKKܩ@9<߇ُw!tlG:EM,)#BS]is8'Q|&jڂ4r%#awl>yt:Ag!utrwImB&à_/p8+dbvZ?&l *v<#ͮmU9C~e M;hp*9t]kVܢU3>2!„8,Pr9,fo;z-*ѳLCC_k 3HB65[w~+pj ?BB彜8&BqqEYb*[*JywSJU+ׇO.ZLǷfpuaԺ^D5i7L@%v+/ [\zIC2AH#`4r}ܓVdvAHcބ.FOyHF8& œ5wep¦L#;Ȅf~Oelq^C*͸zP_dm|*H_"{X{mz氻 K=Q.2SUF=%9~m|ن@ٱcP_z+$\(jЉhR Zpuo^N)w#s}9̩ꎲTy̎X=AF"PF8 Rs|ȟ!Wۏ⨼UGQV Aۓ.Ky=NIz ?խ ޞ/ R \ty')1J?%"o"V@We/>zP-@#`[:-^Ln_qU~+ts[zݺir MM.>`T^P鵴cV/k05肺:Azk^fk+3^j7Bj+$5_>r &NbKNODuҳĸ۝r]2qQ}KQw\a,oy$#H\0/_޾RT̅诮wQ45;GbS&ȱ!1HAT.'>nߒk JBu.R'#c鮋V¼ дiewP)2(d!Y9xO|KY% ΤYy~ڇg7ttҗ87N<)#iݭ3c@/pc[a@805ll>l.Ñ d &c`B&W@\W Kr0W,FE0EΕ=%QLZ{4|H!f Б![ -=Ҷ"p,*կVDEaDE8}.bKN-! ypO]{S,=x6KHc}@F\>輿(!8C^}pkcv2T}Ll }\c.nC 8G$~,c_2̋JB,ʆ:TL.z7_LTFD'׉D6H 'Q~GՀ I rsb纳`M az2f#z4Q|U Lr g0Qǐ-7ZZWIM 7)Qq:'h?puʋ"rCE(EaXY8+ }Ei; būt4]ۣvw>& us[H!wLfs[NOv Ri Aᬚϕ!oGDjv>}ڄf<ۮYB.HpWZ'ZKž903 # >:%H\Rxu F} (l =4YNB65 =4ع7iϾ}h>?os;Xn_[E2$?,A̾>RX6d3@V U>}V-UɕQx5rP%)MyS[vta X]^Ɂ6cLdRx"pR@ydicD_#(9x{1/UoIqN95jtؘ&R?qŘy=c.M_y&|V] b`= ]?Zr0SUӢO"Wsڷ_BoOr[3d|^~. ux5 $><߼7vdz< |^ 3ծEuQJ]!`VZ.A9-ha0CY܂@ a,^R7Tю̕-RwŎ+7ś7c! )daaH!jJ F‹T]7yۣ}kМY?%Ej֦ǭ S7︯|լ`%@+Gd\pS2YϲQn dJ*\vQN3oM;NCgTljoSI$szzQP[&?h!znDJlT Iힶ LdFMt4mc2 N|&Eq=Y F_(o`6Atwk"'Lup.MM7ih NLⅮvG_2KmqVMWx!Sj3iA@1:u5Bu6IS:d<ۙ¥?*yk8n5'3Bñ;Ka9 Hw)G!98K8q̪fVePsǙޔ9xLƮJOPh^c=Wʕ=*sx;+mKm %k тz_Z+V.G#gDwaq}TwU0ˑ~R|=HY{sk8dPތJ:u) -sBo^GrXԻJE_BAaUp;ok |iqTHX`S}ya;–uUf%= a= -4y'gEv-se*va)Bĉv̳l5w00iF6EMxRVz U3J1!3!Hx ]fPUŘ֜0XpNaǂ;Ub "^EweQt}P_[= Q); !^zc۱JQnZ06

#_L $4łp91y&xP{F&C K<$4"~R%,ɭPeS'Ǭ6iοyMv>`[g]1G $;aWh/xV'Tq1Qypĝ]ɑY&[񢫫ɐR&&y7//lDF9ttQZw?>&TJ_Zy.iǻ(7㒬.Vq7R/#7k/™u9O7"6ws\e7VrWLׯۨ`4/hsy=/ 8yςrzO$@ F: v6zƃmމ|;SFz5*Ptᶯ5^\OE9 m<Џƣh"mմ54)1}=j^{kjԍ =Â~_'2.)Lx0DU,ѯ.X W\k1^r%~VsM~ܖ_m:Ub?^Y PR!&QSLSfϙ5 R/f07m4'}աaߺ,UZ'>>u[>6\iZzĒwٷ{1\cۭM.ϵ߮8'NG 튲VvZej2 )b%hJ[裉fox0#Y\QZ@}o4@ܫ=;˂ǂKC9T^=M<v4p p}dC؀Kȏ1ഞx2.%9Ľ#os?Sp @N¿=9a xᡋ[XcԄv~xREm`ՁhRmel!B| _HT0;cXΝ{%gKcr)*NPѲyU*[}ʐeUiUU @7֒KZi=OU7 IA<tN(\JRُfPԨ$.xvZ!y& ӾڵliγTK3v s1 u_d-}~7hSL8ޏ<0s7Ik_oۚW:cW\nMYB)_mlխ, tzcd~#{ןFd9\؍pg f":қ'f[QcΤY{Fy3Y'!AnLm5ĪM^ fk5f&439_8lmH(r+ti/W%R(G6&ȵm.#`u]acI ).Gڎ(hSި[¤[ޙ%Thf]Т pM6rC(6,7p6ڴҐ dA x F#9 ԦH;nZvV "%G'K3',DAN9?Ƕo$h>2ys挰:!ۻte4T.޽S# ,ǃX4Upn0~6#D %ܵqy6Uʹ9dpeI6X#rƒ΀⏓(U5|^3v︯XiÉ.;=dci3/v I`4*lX 8 P\p"rn_4-CH52 FW[M[{d݌sxc24D"i ]Amg 1 Ncހ15_.w§R̘iOf6+#LH13 4h@k@e$^Ҭ|M\`W D7h&s2,611Ƣeu|Gp=9 1Q^83:-# FLq*=xv)ov6tdP%)Y3+651=ic|=!A SG'$j;BTxM/p7_[O)\Gt$/aXQ\I}o̽5gfM7N5bShM\ J5`vT~}#$aQ#g{gcC "fIjZ{bL ̘}Vh{PyP06 1ZG6HsvH@2s]ԵCoguXlU۳5'&if)eb倫l0Gڊ 7Sڙ|NՎ[)&X( M;/Mn kqnb|9^ߴp%w@ca^Gsc:)u[@ر :5qcH͘^8 .n)a~#j#hJDwt[{n83z:ұp(e7`.=XzH܇{Mȶ(wF G"R,Qh"O^(F@O(;>|IQ];t "ٚڟaE_jGNM{k٩\?ƿT7±$^L;'Py)Z+e8-B Oh۬b6y7,~@Ytu9E/x,rK$̎ AQL$qsN2`[Lh`->T¶\D`qT 0R+֯RWtܷBȍ&uu]ԑH(1-oφ# юC5.ob6)H{P`nPn'XjHfcr$p)"2$I VRj ) dRUӈB9YeI3|.ra@5 Af5ο94r~SH+^\+$ -KayŢY$^2; mLsױi)*_< 5=ٷhErH/N$X*ߊ_FDRT 2 ߪ6 NŗL(mbP{g`,QmI qR)(L.'HL.oԄŕPG"ғWzj<6ڳ=,' \ڃm:>9,2Ϙ ak"7#ehP;k v=bLYjLPܱn[ |{2ԫ' UԞ5,K, خ/fLZEY>˴rmKݭUc8]J"B+"O| *0Kï.@E QF}E Ek N z+_aG-,vx QSk>f46x7nq^ ʅX YfR4e%n;I2tB_on`TMj v:WT-|IPcEo|Fh*9ڍ"Q0]?8F,Y_A& FSm2|/˓ndkGer_ᨆK"+r[ i<=nWxLU~b)>@Ix\7VZH<(::r T'b ⧪O.=9Rϵ0AP(Z'd8q[V.bdQʢ< n0&xfEKg=9I44KFoCV?"n-A'#E}4h`|:j?&c/ꏤRH QkXnMHu%-Dt55ik'vD6Z#q"'m$p^Nλ Z248# UpЃ Tcw`[QH>xW}e# ʧI@0E+:k TA`"B} <'2mKT{SX"p>=e!ݜu%reniC znՇ'-kЛ&гJ)K͂fDӪrp%n!R< ~q3LL`j8yE9>i9鰾کfZh5m$&C42~b![B7h^/:/=csYnፅ΀>"hw= qiH2X^u Bк[I/M}kV0d]&#UD]d 11#4i j.uE5SʈN O&7grjo@YA{R6>h=Ed=鸜HVp, 0ʦQ+ĜB!Z~`lWJsEQRz$ҼZĊx6^r#D@ x~@G.l*m!u-)Vwj/:p䉋EF2s_ ֨$WCb,^^ ܱhjZs=jDU)ff }a9f+?r잎>-(_4ꇌP_q9s,+I_~0!SeL$ AqlYӲdE?k?Xzy?VK!prse&zl"&Zn8p}@Ha!~A:.A9-B|75$ŲZto{'`?D*A=;>et7rnM4=RҲLCXtRDڭc,-6i}>og\ٍ?|br^sjß^vMsFxݠ]+.V;|SNY̪e<Ao1'1lWK9 ?rMX&Tڕ`o/48 _/Z֯NNފ/5X/]](dBlQ&-\[:VW[[bjPnnV׺)!+iV n hnǺ9>&ḓC6KNmfd~q܅ty`JG7M\$(_أS;oF pU3\xr=N ߘlQ>E(|r֝B}"Dܷ N}Ϳc>Y֝&B\m6[ G5s_ 4K:n=<^e%Uy)wbH*R Tj)ۊ',ڶXǴUUa_2 ac(L֜le& p+F`R݁xT {#x-{[re;mU;NFSQ.MP2X cOYG4 0#Ti2PnZ'K5[N;En~Nv NCǫv]g*F+QBҮ[r j@vkj$4*ɘ˄F)J`SRB tK"ض1_ Eh<**!VZsA1yniWsj \מC?¬%pH6<@۰G;Dǘ<83$ }'Mk' h?Qe&Mrmdh_irkm Iera%JnUTsIα0=RR|fYf](S2+!R_]G.cͻYf4]ŎXA!с=V#۷ҹV^96GM9YMW?5E6I TshsRç)e{HEATrGB8%}.fz2(2@љlL(w]w* d8\_UlЦSO5kF#At |". pYd?nFrY4!Rd鬚w9S_y ySTU03nY4h>fթ4e_tN#s@3{j,5P߭s'erWC.gSlsk F9э . ]oo aQ Ыbzo~i_8v'\ !}T=f AQxrU$mw0jNcARpTcD}L/pH>6M2Z9_ Xa^z3*$ 2@G'x`ڬ>eQ9?SҡɄ^/q:-Hr@B'*5S9\1&;O؅nj*϶Ֆ7$#{ L<50ư"s)^DI~Sm+溤w$؄pIi,z_wZt}_]:Ec]̀O-vߝtx|vOzY}UCS|rV>U7e(z6{teQJQB1h%F(w%WCwx&f1nF\ <=}{h'l`my,WJe Yf1&,'YAl\^$&O<,sٞ0|ћ ۏi8cRBtl!a oz9F{JsSYZ`M܎7s$f29)+%[R` :/n~-,/O4_"2|Wp[T.\-/Llqy{樁X58mL.yw zq́gK]3p9 E(Ϲ7¥a6,QrW+wx5 ƋannN`/˥1NwGԅƯ$Zl[mZ@ɂxIPn[{:|S]CF,٨BY#TeɁ]9Gߌ&'j*7}ɶ8R 7ŵ@nĭ#x?1XۿӀMuWPn"T=&V-?[cRU4-XCCH!Սm͆ZlkBγ geoJ{0Ҹ/Dm= *v93Yλdy703|ҹl:JxK(":=ZL*}$SbR_Fbm BF-T/ٲߔ7H:C;޵;z{ W}-F6a.$Eh $0d^`t㢻tKF_[[O7hM"q8,nSbAf1KB.#Įg[z9 #RM[S֢˨S{,Cyd.@=εyՒϻ`jzpnÅGV{z&N`c:U6yb2C5i(bF FxlĽmodj>l 9X\}]:/|'8? ̙q]Xҳ=`vn-.>jn$IWUNZE>?ބMxqjODy\3侫{KHSi͖f_/ A|_%{:)e~*O/Mݭ0Q|z9K!96# Ю+Q%\k^R e RS<"I5O_ װOhc(Ğ=NlEI cq (8:Ne3ֻBq}kk~zTp'¦3J1}-/IDžG.QՇQsUL&.܍4M-97gkطiD=C^D7}5AG9H5j /<FI|mU;aw&!vmE5%RCgz4i'j\^+h7oeBSXLWE_X@)_Y*-捆{ZX@ͭPV03Y哾ig~=kCtJ39^P=K->70(ڎP[Hk"?Yr,uK]nXH s◲fC࣊௪Y8AIO;5G^X(je[9_(5 |zmOc=6=ax.)|'{!7Zi '8'}Y)Z6z #u=P/oD) f]z{ :޻Q4ƺy)Aq.*ׇozYx^ޤ]DžzV! 7}hRڞ `-.1epļ `CP"!eeՏ9z$#ԳݣD3-)-xak)!K֢3NǷVtM]7g:{ȷ~˺ۮ.#hm_~e 9ք]/Lᢈg;X9D9@88&,iMn;đ`&]u+ɼˊi.xbS㼔b 7 HC!f6#>܂Oi+O<9G`˽nmzz,k\p\m Q x+(al3pZjbڷc&LN~tȘPCU;z| ,8\pL9U;ټ^rlCnۃ OZrmq< w57OXp[4ZlJI(˧ b}7d+"m^/`E| ?pq.ϲCY.1GX!@pϐy.]r[>_n^u 6TH`Gy1_*@̸=3N7d  "g-ÒQܾ& M {V.{‘UN>|t{]꫷DY (}gs􀳱u3,(ߔY9sQdC\CM@\m Q*#+osNdMU>U,ٚ*VWA_jB` -aG@5'kRJX3ⷨrx,e?jx'r/P:ESGZ}d#疿Ӽl+~n+oy ¿ddM=;>ek7h@.GU!iYP*uV2n\wCKr;~=d`U`Ak~[][(e -" ޕhW'8+Zjej^B|eB%WBK]"xF LhAk9Ih`syc& !z! x.{iƜf*d±@1DXw Mr[fU_ߕqX/3FF&+Ț0)#.*?Hr[rC[N^1gbaYrnƢ51 $޸\M{vHoy]AI;Hhr/ɤpHH]G䂲IS|r:BļR產MYe[)!`e"7q 5l͹Gb^9L2"X;2w:)wGjT}O${}c [I`&7*$buZϓ*qRt}^- zhB \ nY07>q) 1es5c+^ؓ}l8o:5C1B,1Fg!Yg hЙ$yLce+&YbNZ+aZXYG?k20^UoOs( `pC~QT$H"&Wku={>WXlق2IaKMj'ɛxzv"8H^=_[Ёl7Loy$[lCćZ}B-T\ tBWV+Ow OCN} x4M<}_Nr@p_τU8iyigD7ڶ4=ɪSz/1zbuЛۘ M$U Z1 @=Vr[ZUCES^^{b_n0B[V0kZ6 -GES2/;!c[I9"IK{nzԾz;VQ-KzS!V)_#B~BO, ZI ~G +'7pRX^HҶs-d)1ݝ&M=F_4رzTdA0v˱X#C>⨉Y1caSk zᎫKV36ٸ5,3SlCv˱ ؑNJւRp!b.yLuXŋjVZ]O2rTO@AZfMf}A{\ %40,jF'TjVVCj0`fS.O*c1w|GU;;*z@];e9ijcHU30bVntv<LShLAщ .`s-8,^-M/Ԓ2ʶ``;8}"$qbŁ2VCtsxפ<.L'7S;5Yz 6\yMi FOH肮G‡gA aG*[HBi5Lʤ tK$#;{rr/Q:ZaR†hRgpdaMIDŽttW*v4KMKaˍʯ!Ć2"a{@QYfa;rF#-/f2L^` ^ЈoG?(Ŷ"[nq..ƽ@9oԒb1U$N?Xa]*rB\~qaA+4ndo"ix3,`]+B[ Ead6BHI]B|S@ʓ91H [GMCgh!S4@p n .*?Ժ![;2u\ÝI^h1b؊xY4oB4oFG~Ai5Az9]"ޞE@2K3z tس36ˤ"JuSɧz#weV]`ZEaBɍ)2(kVmyt:{N΂O,:Zf1Zk,Y1+< YpvrJz/fWu渺9v;/t|[z-'!.k6R=O}L(,I+ԙ5D抖(=ff/Eb z$P$"OR/ow6@13lO&US75qo $4.bawS}_ I<{F}% 墲=;| {7s \SN`Z8Z W+֏J&_)KG2/-HV?mђ<^ !63Con /M4_t~w{hvgkAۯ> BQQ3׸2dA܎xmWϜFd6*ǼfΉblf-ݍD<5 V\ {r@ɛr(bfY=C]Oټ -;-uD.Ffo]{Oyw cf}z{6ouɍ`)ɤ~[]fxRh~)ԪBEՉ.a#Y#E@  ge&pK=mFBHC =̘D&-c Ʒh3b%6M)Y洚Lmx'YK&c%\ɉ79ol;jf D並TQõۦ#aՍodilsZO0>C x!hVा\̱.$NwGi)ըI`,(dN5T+֤v 2 @V'NMRPFVSҴb7N78\UŸjt|ƕs|qPUW|DOp 0pt% ɏhw( ĉH]qڍ |awe@H𹎇@!px56sVe`ɛG"xFtDӤgwpm,*a;^/cOt[RO_ۑj& z"YqP N;.W[?ݴev2ht,X>?ϪqUGTyNy.?n´GŸY#R4BOh'!b(XS1wNDS1֒iz[ڜa=vts7䙡)ĩjߊ'HN˹]o[GX^-2pK_1Π@^..\VhAж߳Ilǎնl.fNd۳^Wg@M^7f@c\-"CBQ#b= 5[b+_ZKǐZ2g"oGXkp4 >)83آNSCCu7Y-;)7cHJNN ^SCq:Ɔ/,fC^NO8^9.̀ϗ+XM̮Qhz @`+#dzr<ل4  s<.C$Bhn3ę>PڻrH? !$Ċ;JL<UrW )Ŏk-/T&l 1֨ȲrnTmcW2(aP~ȟ׵rIE%ki2A*PPG zA^\~_6@i[A@*2_ٞ  zhpng^+ *"u}5EO ʧoJe-*|zs`UUsAXT5n H#>ͰHD#d0}NR~c1ecexB+oMd<#]\6arP!J)$A9V*:'cGl(2-|#< :0l`-_2qB}MH`9bűWl.rHsB;c+.S@Aӥ\xle&-g }NO`-]ղʸ}6Wg.oyΥ g|Ц!׷16e}tkܾůu&\Z$RX8dL$ݤS4Kfq)/bلVڨvTG:֮GW41lkO)N$BI_Jx({Ox3}z_6Kܮc6g.GQx@^yr}w<1=11ƺge%nuH f&:V+())_ÕJjK(賧+9J)'}ĀcNqɇi.*-QmUϱ=( ;(_Sf :Xz-6wBKOb]QT66!Au%8lh,tE< !Ql۠R _-L ( T5q)SF_}vgؗa勝UUG glzTFi>;KyIGh[˽Hϫ){[^^D%X//D +v4~*^xHE^LxVQA=*AX{!W" 5TGuSkseq/b0㐄NFy)l4\[2Oc!J~J9:j⺦HdK8 g~'̖ G36Df=F F)f/|"Ll>{%_85Ȋs~N!#Ǟ%x1x)pa@.k#ڂ@Q'|ث5ئE}_W"d̥L?s4 O:fn@:iOYcVh{]Q?1~}燵pc]qbQD/GD˅)ǥ#kTXD "/4 !.>Ze};lA = v/DFkVj5J|ƿC[&%NøX׉xYwCv5g9SL!t@zLѳ XKz1 o@]&g;VL0An?{[pr_ ;!Fㅡٿ~Z7UC7E3ZBˁѲcw(JEƻ8SG_!ib}Eg<M$T: *u|io bK7DcΠO)vV=s&HO!O<ˊ1NGDĹMQ412`__"UipQۍ6>isqz93,&鳌8TACV!'AL~֒6Ԭ{[wW %{FT?\M`Rm)݅ W4n/ōFI$B.GZ砘Ͼؿ׳)')]埪yZ8JJA!<f1[鼫EgK^bg ?[{ID}%g ZLs˔ŽݯO>.$ x$ x$ x$ x$ x$1x34 NI-VI@bpq! WP t# x$ x$ x$ x$ox_O0c쟏ȋ&n"}YBk3w+ i]gP )giBQ+w(^eAzV!\pMPkN|N8v kȎD#FĐ7DcmF"XW{{>)=ub=L}H5QOF7:Ql>r~z|HAGCQr>!D/O^iju{/oEbж|W1DnzGM,z۾oo_"~rtT_o81ʼn ?}|T"{6(G GjCT2*n*"^<nzEߧ*NF[?'2"޶3'xFB2*PÁ)2*PÅ).2*P'3%N5D9 !ꄚ"y{ TP3D% !4!ˡgT4#jѷ鄪RFB iAd}TftBuRWB>$0Ņ|0IHh%D ԜPsBq=jNΨD%D ԜeDo+%sJ;NoĶ=uXY?l6>Bv(7K(n[~n\˿[7V-sgNy=4V7 t3́;+z7皫ԋ P,ڲkb*Wp#U^hn7eڻU;/\$-!pd~v[/sTUxTt b;U MaBP+2uhzqY N)bzGٳԗQQ MqDPH,<]nnMim$CUE 48}?bku^n ]R% ܑnh T˿r]W4qM Js n&IC6W^J)oGK  MUC6}6l#\0;2E 0BD䖎?4ejdVh뮒4Ûhf(V<ActF6o#i8N59[wXٺP4]&& phAm]92>Fh:DKGцG cX;2feUuڭT*jE6ܨqtYF\ñ`a"yvԤNTp&UW4sćAq@6+9X2W ٢̋p>I(~}]]C n>HO&0mPm4?"8ȯ]{|rFEn]h|SهY{iտ~z,sk]/wiw2Z18qCP%*,ro½Tijikc`G7P10-sƄ&8f]DoCąED`!d~S."RiSwZ7.;.jT..DTʩLy/h^y0tV1N&X]-ZX۲+!L!2؈RTHO*L,m5dffk-ǔlԜm].NDȴ29h^k562écM.{(B d,:YL*-&Òs=ZGKʐtcFACfrla}.꣈( n>QÊ .uM^:wٶR9|-k4.'M؂<acV9wLr,BP,J>Mݧ,j瀎?6Q-h6P}G&}#}wP>QUK2ZQCB^[Iڪ1 Q cȝ9{=CY*eG>ǜT٨h-mUh&x2U\)O>^B4I)Xr9qio_& iCD3fS ,].ȪՓːDX4K,rcFft@0A(Hۅ rHu4mHmGlܹ EW(eDɡ.0Z2~<M'وrL'(kSpskJ+|a"\F:UddMT!*6@(0};*AD#mzwSbB<:_嶼c1k%E`BA뷐ANȗlJAǐ1U  G`*&K|mRϳk͓tdNW"D:r$< UNxUϻyʣ־Np{]ErE,7SQKAǞYM\@8:{=4gthVυ_O[@`1Y8 oÄX@PEWZzpFx.ݥo񑎷n BEhfAJV0dmo}"DI -d1ɝ IKЇ dzS/H+l6/tʚS,v6$QxfXڽ8ˤhL!3)ON ?,ҌFl"|dSd dAJvtY)r{΅%"k>~"`1p|FMp X$2qֿݷĸB3Дieu, iHc5k(4) uI@E8Ӓ1mwWRm`+i : xNܹ0q22O ʝ'ƸMj]:6`[>10 G6@˔g[es2I[[xHh ;k |k~Gdk,55Qnb8:A)*Dӽ'uT)ZEY=VMǜ<Յ .Dfa AL47&я!J; dgO4 *9GNՙrAu{P5>DB0\hN5cFmpq4(B{q)Ƞm)˄c:OE0+1i|VE=Ȕ$J4e~ J܏s@N$37 ]w`7ԂEuqjo֢ɅJ!dq8"1vk3~¸8ߨV[/A63sC N/c〈9<CɸµQp(W$º L!=dֺ+;P_oE7At!h7'Iܰ-6 wt.&QA58 8)]7Guj eUJ7h3[L >?kqpzrUu}< 4f9Crn82(TcT F6EtѱxX;[_.Lj-Dn59bz I<,`7>" 庉"/h?0@bPDǻf!\`wcP<?(,:udR̞͂sN1eG=O0i]#figr~+]0v /سX1l6ۆ_")%{=ZQGLG\"Q]oT#FLӬ͈T{EZ} ܤ*74srY4P*6 O\kŵ.ָҤҤHT\ڜ'%_l[U^I N誯G.) =$0D_ƌ&P M.9'u'UzoC%_}`=|\;Xt>h'8U[Ѣڮ,î|us{,ǚWz`IfӔ\`32Y\QLon !pn4gqt@G%rFjƭL{$z aɟCdJQUͮzv}zU# | ՁKB&<6j.xv-ho{RI rpBi϶?;ړ!,̹q 9;iZT:r0.3Kr~[< |s(H44ef9EWN *3#$g!xg\x]Ơ*m+LajH*K^&p_̊OL >3gy;&th7pb.C~ S 3}5GD u)V9t-'>7<ux:$MDaO% ӕk8!ۅQg~?Pr*M pMxIx|nOυ_C^GfCΖ./c}x-;"_}Z{I+9`S6Y%^x$:vd.e{`ġ؁otPNۧs)7v&d"O{OJ?x [LE{rZ {P))Ct]/$7z\a'IP18əh T(7Z.-aW^5~[;fzDD$m|  VxC#x/>} +O0Z&ߥz5E|! >I@cõJ֔ezAg^+@g{ 2~S|uڔO]Tfݩ;6PwU],>[o>-KΟ,O8Xt?O_OW]{!]{63ؚnӀqIij~-CiTg=Kd&(& 1tKU,qBQ}vF\4 vRD3h> ƒ1CG4:P*LS@N+h>@,XA;t4_~ iO7ƳFnQ>"` TugiAngjrDR.J'+̦V QXUIrEu@ؒ;:許l>״+>Q6HSHoWl95>2W/\PHMٽQr>d`XO,erQ>*rGOЏZqIuɹߑNu]$'5%,8* </S=m63hxmkʓJrR2|Rj=<7m~.v5k R6mK2V ٢8›-әuv0ZK1bHtonOF(A:&H,N|w+d&\@,l57|bOS 0R:- d[-attilq*erG~ O;sZ/](Iו'`a`P|>%ЧQCqA0> Vo6aGU\:0pRHBuBݷYT"w#mnhj=ͼW;If~} _%;:IU<|8t@/?<}# x# x % x %$x3 .IKI,J3RK9Kb ?#"x3 qsq r .IKI,J]# x% x% x# x# x%cx-ͻ0 Cњ%9I}2j5#6@6a.pd@eHB)IIQ~4G]&HdPBr&%-"աx)KQ % x%Dx}Qn0}t| ]$_|<\qy ;9q|ݹ/:S -}q!z$@IgueKj#2'}z;Kbl[~ Q8 LaB'^?}z P/ ݗu 5"x^upPɟI`޴ڽ'~L} aP|g揎i2{kCaww^zkJO>=L7z?uOo\!X\g37קNo)s5zpG2ܭֿ&EDZgIx[Ƥ oV[­;'p[kSeJ<}w}*bߟ]5į%'$N>ͶZ hƒ+F@nLyH~ng;߁?'x;M zthݢ=c`5>Ʉk c&S;ɄE-YxBCk-[U9| 驃|29Uw~@*yŸiwԙPT`#$zܧ-xk!>T޶8aS =4#)AOn'ZwG}&*ڱ [qIM 5#Z{|}#Q]?_]0҃D_DbEs@:[ї'/ HhCer p)Q(70yӓdrHc?re [ {ߠl?6?oH@f3]b>lhIQRm (w-xs Fxfu(P#7^Ni< 2ɟS V,6bgp!2"1qP݄^ZQ>.imt ;?<g+L{9u§=pMNmc#\criŴ4j)8`22vh{AkWNb=N7[ωoڐLזz$[;矒]sK(lܞ$9wDyo"0vl,w&m+6gWhv%f,whzYBHVF㌌%vqI&A$%IheL4sO|-w8 [˃"'&gaQN$L\i8`i6t<>rg$~*¬g 1iͅ:N=hi ]죔mN{z)&Ï;o_Wn}\_ɟDT\qZQ-cdڢZ`4lNapjWW6R+X8VU56&` ,il`uI9ŷ Hormm(PlͦQ1\]oc!!)]nDg({&BTC!f(G% 7f#w1If+TrE #3@EB!* 7iZ!m ]YwQzq5~ ˝ m$c.pЎQg-&p2ko jz% }XhOh,?{=P}Tq%}s'S0-LE$l?Rm>"& mYm{}v}ѽ|pw!u^#f O3)* . $!STk5)l%GhF p>ܵhMwʒ8=-@)ۃ*IDSB 6%!m9?A4fQ\>!/#[%sGOfKןxkt叜iDF5g Mbt6S3qLghYĪie]R׍*b`x;aO-d;WI(rQ$E\g@͛ZqV#Qr\%eGֱcьzp8diw[Eǎ 4<8 ࿸ o.?4|);y%Y;eHTH~ɗ+ry%_*A%3ea 4/0i3C2 U322VhcšQ[X)];FSe2?{b8P= (vFuxhe&К]SYLKCO% SbW.)%̀63KЧ*Q_o}ڕ_Q>"CUL3*dMH5$bN:v̶ (rɂtE7cW5Cbߵi2%bl4UV$ GM&IJq^>l{MXyyysxiRd.M%ko.f>Do3ߨy}5Gߨ2Ev붔 UP Lfy?f Eߴod6ӊM]܃8< e-%O`@p"z уGPIAk{['QelC#aaGtC]NҀ6ErZEf]hdҿ&"z[-F47P)i4yD>g0$J>jQXdޝ|.>ܜ^rHe *֝2@$?SAΔCa^{,*(ĭI2Gۛ/d\drG~pmA Hǘ(Yt8u\xrB Dx̔lQiq9%ȾTeZ*XX)%S!VK+ôF*PuOX v߿=9 ]^]_к᷷8I?!F%9c)XzKAs)kAERЂZέ%lSɠ">LFbu:Air''`qf9m8T Gz%)_ B(R>L3E(b,k,r3DOr>tYFF*-p.Ec`D֣è`4?8r8Aw2t#Z?Q̣8k 69 攵b2PD@DH5DswLe7 Il8~Ji) zs玔QH )*bL4T x8hXBDϟЩG.fk1e:ROw0bfI*ǞC6?E𶭻ϯxg"i*#N)JrNQnՋB38?f.;.h=^ZЊ]9z;wF~7WG7Ep&+=TFgх\9OE㠋 lĜ'Ul$jAS&F@,XUDK75 Oơ\<ͤY/ Yi,*I Ubҵ1t :"7wob3. [ʐ]-aDGt_k22/o*85٫P ΞxwnBdž="H܈a+!cAǤ.vV6ӏ@NS[ 䇡4di_ 1fa nb,_]Q#{9qpzǭ$io jhrb ^S@C7Rm"g -Za沘 Yc0͗zAe!;X/mv}`KD!H1 ~/^F>N IKnGX*ɥ"an:|ʠcE_4.!d=lIԳ,~u_p2rrZ,}m^J wi;+@-Uø+Rrdq5Ex%R=s(&kZijRث 4$'Z7}}"]&9v0G,r]RjQV=-&Td[r)UŀXC7(*F˕!j:*ʦ$Y3E=)OpI!{2yRytCBdY3yϪAgCҪS+у(ZT{PpL1mwv6:֫gw`u/N1F.` >]N3* $'@ǘ[`̨_MI)մM3 fD RX+¬4r)Om9GtFʹ'BĻQ]b5 1)w4 IBw;f⧠͡EQPh:D.hI9gc<&+'9P;BrSb.UG 35Uar ?D2@ Z < -VS~omDډy9ȥ[IuRLW( 11d|' qBQ`E>q |%(#Cot(q{F( T, ZWd9;vqa !䯝~¤ šDzq0d6CՂOŽno&)[w~%AG!:puuz~s{rts s]L=#48OAwŕ\ߥXxm1lR=\0*?hf)_g:i+,u 󘛡I?050 qѤI3ԍ=Ҍ87aQk&XsxewFxARdRuE*D08!(ĸuтs窵-$ZNI;^h}ʡ)=Z[gLJ8BTjN*/Wm U+xxDsll6ܻB [6?/{pR?9U2kPc +ߞ*os_ \ 0hV*M3\B 0]I?U6q )9fJM' H2ECwW`v×XdZ019=M.AT7R5,-c"B+!bflČ%_!*L}Y ] aYh5ZT3() OvjVx󱊚1f;).6I_54髺Yf8dD{-}s:8MNi{j 1`f 5ͨX@#/Qkխ2C a j >A#X6 >+k/Ѡ+ -5BMFK)tЊP-[n#pcYS]EihPKDEmX9}TGR+ MK""l--)WW!LeFfOukCe] h M|QPa¦jg^F4_dM@&L""=mvH:z7z?mEDx %@TxZZ"<[[֮E(I\[­+^0ĤS;kԦm_I]85cKvd7φWʉ_إE]\DWew~:>QA4Cɱ_NɕTJGQaKGI``(_}u ɔ ĺcLL2u{gpaк`q"g8L'>'L(!Q|%WFxEg#;.;l9-+BB25R4n9Ь?h+p-Iv]%Ŧ <:y+l\|uD7bWŃVS XqU)R1F.EU{PgY(ET9Ձ9+vh4 ݅4Fqbщ|{lF"MEےvw?']oȍ:$ݦPޡ0n. 7m."bq1U%H ,AyU!\L`* #HCfjƾO9\|A!R_q7gcdci]FO9vv6uA7>W$}Op&(`J^S2EF\{HqFv2a!(wVҼe{5<% הmoΐ[`q4V^wE,Ĩ[(g{h-3ߞ{yL/E8O#!ix}]}[QeGE_|g'/eT8ز/#w?+C٣=q_&SsO|7y/(4\G z8waI_==Lc%Bi 1C>к\ JMwL |sJJkhOX5*[qˮ>wLT#:<-q@_(!SP|S,%ź`70AwuGM/S̨d^qVkl6ʦ6ʦRdZ'te芟F*vQ4-t>y4u|Sn`KNt{|~kr4x qn-,w*<Ł[ E>̼COwdVoUȑM8uܲR6T]g fA{so"Ԛ $)YcO#;4XG}9C+/QJV ڪk0ㄲq V~ 'h\JAFuUlmf4Q,8EEKbv; < %iMNX V_[v`oR$ZQ c|&~߿(4 ZJ]f֑SXfVJHݘ@8m)نH}Fc/r#U'乒 "a9IT$p*p8):J\?bu{AD? HRkqgj$ %x';gg&9ȏ$a˺@ :Sg6r[GsƊ Hz0H#QDH "2c~$LD N,$ h} F_;>>z[;p~kЛz#g yYp<"*'&MR|.]T&,gIsvGA\ eqn "DΆ} 2pk!Z1n~yҷm5+(E&'q63b kqN-o@^2N?”1h,BY{…3=z$ߛqW1!g6RŬˑ/&vT1Y}b^E`_^FW\LRƧB2PyMC̙KsX.T➒'hG{aZ`L 6UPΌos5Wyws:UљթhZL onjl/ ƈ姦̙q 4I=]YY bâs= L9_{Kơ3Wcj,:,Xɱ˸gt%hq{(#"A+~ri~v3ZUҐʯPʼWϲ Z%%+#ٮ+0#w$juGsfy,qUZNu]&3ˆGɱlcNJ~ gGן|o*Z`gm+.+u%Ξ̨)߫|{Vݷi߻+/?Ϧ̴\KV\1w|΂ IA[\UrlmDZAYV!3i:yKT\clN1*mOIc7PuA=@~'aI&!cl;5?R}"r w4"߇j"z }g'vU{]ِ{}1zzWř ;`wk՝mjk\,o-IO:W|=2Kc nGccӊ$3.#$SDu8rbX[ U;+޳vtNoǺʛ/:Oii&\jFZn͜EkjuT&i`e&UVR\Bʃv'.Jv HD d'h1GpҠ-^O"z(KjqgQOc3RȁZ";͑wTȚTmad$ %pĥpQ}$ I9cC$v̐lV=XVO 7}ՠYQbf31Ì* ~s4Mi]bQTYO /ZZC6S-c7 dŒdž4@z=ޛe<'@Yz-ӯz DϿG/-ki,SBCm˻9}{k` ;?8oԶCqh[{~kBvW8>zL15:!3@3xYRTy2\,0]8Wc]FH=.؆Tϴ؄ZlF1a# aT1 ]Lx%k.dv ^Lkvn{un 3K3T |2Dp5ֈ/JWǮ_<.i;"3w#- 6'>z]$ե? VGĆ9J#>`S|k[&!wV W;w? P,&@J( qFTxg~02[8WwbV<1-kl\ i.eD#*ܷ|W㼔DNWBq9I[/^,XFǔưxRT铮2-Rq5RObyoOo~?==ܷqV=<~lU I£+5FjK1J 3S]]Ѡɓѧ $kcsq~Y-#uΨ'g7ghjM+u7V!35q#o@M!υ/4{a6H:͗_Km, +j&?[.i,LswFW;te@YPȮ$Nj\5Qh-j\ElykӈPR<KM FTJ!Z/g2}W[Y/|xqurzD2keᏃ9|Fg\_vlrlR"lT\LFS*&|nDҖBd;{ gh~?[URt ?&!A wuE[F 4Ж9=1+@7)^ :ʺ2Yd_zas5C.$, *1tF0|l9W% vx?y9Ic/J76F4r٦|\gSӥ&5\i+Yh߄nKR-mu[߬#dD A`6#ZJ'ҧ1$\? A>`s/J~LA"+mިTd9OR7-`Fn[EME6-'V knREE]NFpLݸMM. t.@ e>N<Eك5fhkGng]b5 ^;.㬵L |!'2jWLV}7e3QAS+crũ^; pv@K!Lٚ XKD1Ѩb"Qe,h 3nXǣI$z|pUcKkV u6M;fvQf)wlŤDZQ60f/<&=j/c%M;:I~KZl/;f9͠-KYB8 *էk7*|kVȲXv YE5KSLndI@Y4D UԺo٣haa0>XPs4_mߖ_Ь.x9>ί S7l07<}_һ=a8n{k~tv:O֩:DM]6WQ1n=g=bإ-pD`[vT; \NP7!FbٙmIPCZDT & (Jr[G) E8}!FbwJF0l[<o7sN:q ¯UrI,E(,;*2+ geǓ;z`yJ.q^x?pʶϬ~_84 汴$m9썹hNZ+<; w_6̸a2LRB튊LkȱIGTb]ٝsuy4]}l\oT|c/ݖ|URxOJKL{Qԙ#L4TK[u+:I5Jdue&"yYej<ނ)2MVBkNS>8:ωkYzW^k?/N掏I!]rˑ*8S7}AE2 ?%Q_G:/5 6ʼn*{27}{ y.Vx>ǟ`(fz Vt hM ; V 簃z 394QE@§bDٷ;5%Y@bꫩ2Oun7tZ.-a"F%̐.gNA3ҟ9Dtl֎t$hIRN `vxH]3a2 B5-&Uj *_+]B[m+(8[䞗hfZ~˹ |mԄ@˜9c3%Ɇ1^vWjlV;DVn%ڃB\<ƙwekWoPe#kOh} ;Ag~nu7PSU*' ^`[ Em rU ք@_Sd>g!8}77 ./t Fփ@dބ@ES 94d xQQQƱ7Z<~ݓï {{g1 _l7Ub ]+ybn%~%@zravɘ¦~U_M$Hگp$t 8Ac-o&İk{(t{^FQi(tڥRTx8>d);R_&NMpKE&yL,_d(s&79j 8[C>,cȖA@aOuNdvﱙ18/KC dn򀹙_J=x (?|FOrN-reWCN$" zL8>>E@ޝr7ǰɌPmLp m -_B>rw׸O4%O磗voSTމfpǬp;*,GNa-6xPf\l+STb6!=m0[v-Tg?CM[~;V aJ2@cGp0y2 nkVA'c5Lvquy0W0?CS^w،}Ԋ~{ca9ߢ7mz~& (sD0>b㋣wǧ[+v"Aj H Ej_MJQ`{mNQ`Y_]|8?-fo Ph1CF1EPXiQ 7϶\/C.df?=H; NS/|2M;_Ōw'O3&h BO@/H diMaAI ]\|<=w4~PriDdKcG'D(*g,~3A%le)V;;`B+2lM2]܃ϧ蚹mZ]?mswE1 {dJp:$)> ĥIa_!wZxWeg/$ vNgluۊr‰^H`d4D"5Q>[f᧑&OYM51;C䇶!S{w'of^O--N!mNu=,:-% ;RŽ!% >GGjO:#3k$2ճxmqזyӴ0 Kr?Fϝqn BZ RqKcSo|̞.}n&@4U2.v_LM1zILAiH SP9UPjDvі3'&?./W'~itX gVQL==03A6VL%m9/[NϏ(\VRSu Ÿ܁bBȰVJ9޻[ּv&v^ 8lɆ23P\n6g淛?>9=)c$ݽFb@h LCKW(89!VyQluUL()LLyC^h9s+{{oSXsSU[UfV4q5"]#p#s\ֆ6TG(:,晥;fKd3*enЯox./$J@su%76 ܢ v@]bsPEH,\o J"Q{E]"x>+V=[-8h3G-oU0v4Wg7iBPPG ):%1嘛 r&/81-G*G-p1\ B0It0&L>ى! +RMFr̜>sڊ ȇ8,tnw3ݺl\K1#]FނwN\{pT\.#P˪C[ٷ )bQK^2f)b|oTx 5w]_v}'R )<{._oQHzMA92vŤDY}Kimws縴PV8f.d-.DSA/6/a܍{*=EE~7sJK{ҧC7-;k}!p>6|,t<׭w(e0p \tjͽx qooSC))F=oSc9d<% 4~ri 9I=p^MOfw,ު :崎Nd=hIfc4&#aJ S#4]v@ 7SXp` oS{'w}+?O1oyq%DD4nۖMѶ`n+GX+f2y!ܾ!_# KJ68bU oyay~"'|NAʎj9a,FR,2ܾN[ߋ Gǻ6 ߙ_(h΂`@WdP51iP))(=(&r:.D4b@c8x\ MpzyA./=2T؄ ͆ZԷ *DvbQ*-jdlRRXJ6XJCfGX/=楩 o}5)kϱӨĕ;r'_kd/~A.^uctKVX6gh}q}ml_݊[MBFx(P igo5ۉ6mP_Qd!nk6I`6p&ʒvQZ*؈'z%jVg_AѪ5m˩Z/lCa9}OfB KXX^^RԜ`P&`.%X-CkUۼAƩЖ ?-#.JA+Э5pڠPqG-_PwT{% tE B>x./瀺ek-jȣ\ Hrk ,wHA֏%cRYDksopw㛊ä"s|*$F*|u+cUܘ kcg΋04Id{aW]UIvnⷋ_>]:Fa 5qql#*P 4O3ƯO|"(E_)y5 `|qQ d(7J NPĨscXK4UAQ(/-"8KJ`"J/(I lv)1.'IT@H8i{7|IjT#~&~Gg6۠Fm;˼G= gp ᤸ3Y҈:,:FGSO/H-@ '42 J>bTZCN 90'P? Gn'Om1iw1;NȢuHH@S¿Gק(l_(4pt7r, nPֹ7s[ `icsi\!q"~Jӫ?f3ԥߐ<(IHL*hju#W-<^"-G: ѼŽ r4 )azW( :?b NOZ @2yʍPV\NUH r~os/Tvr84l LKb]ZJ%!Rʸˈ|/]|~(Ď&!߃peW.݆.@btOa*_Qi;&oq.Z\X S77k%y ,)5=_fwu؊/\;}R/SAc*:3>IMvd#|t_I(P'{y^j9P":Z}2U#}jֲ@Oh&%(/a(pFٶa,G*SRzJxhE\3W~cM{LI Ch! ؏$"- r hcoD=zg{<;| %c{s'nwQJ跲AJ/{5^Zrl'ߊw٨ׯls $1. o'tu p+wl 42/B=* p"U4*6rYOR!isp`t6$+"GP& ԂVim,h6tSAcdX \dB7 īqQ l!DvUP =r^BB܁|0,X*;B| >,"~]F$o1A1RT:o~k;@MB{V{mk }C>xq6?DtǙbpnpnd ̾8ȉc.69<[RJ{%E\ɫ2B|2cT?ŏ-|9|?q*GtݹL7ɏG0_aI8 1y~|t}BΓ&{Gў_܀wgu PP2_n yCNw)Q9L~1I~eEYT Q|q}h)%]+K Bg6v|)~-*wse)3(ybp?r ?gW!FgR`3] T; lBF)|ob2l 9ejaLGޑLJ3WJ %4VߣnUc$0E]qtW~?lz_(e|ouy+]WZ7WLf;okcj {?cԍFF`,q:!Ϡ8+4KŋX^%:xWa,"J;K_X]͔[]j f =0fnvbb#8ۉp \Hh ]%E:#c(l-nr>81r69Y@ѦٔSJBAJ"4S %h(\.,;|/!NSIxM'IDX|؄}B] WD3ʘ&Ʉj]_۲EF胼b>ȓ<&37˜3}\s?'4>'?'TNsz{槐u'¬E :ZJee' udhRWt˾fxFX~#!Ѽgx֤ t>Ȅl3ӣI" i!oY4}">'&ҭk0Ɍifbꓖ(ZH܎4w")FZDQb`G]1$ }<_g;SӚ\]م'g7g꾔PU3|l:ho)W)(( 9h ~g'wgzJKVsi\/4At8&]bF;BXęd3K`']qFW}#:uKTef-\H)Ng4YQI9Nfs9lu6:cͱX'Wڱ;VgN\ydIK$hs9ڜm΁6@s9hρ~2k AM(GG!|q?]N,k'n`k&ȮymJ6ֺP{cϔeLv6 -|5UtD#"I]3DyZ.vÚݖEzwtГbL>Oa[JrJƶ̿8'acJ淋_CcǓm+}Pe@Mac aeu8Eer- :ӖrDo? ̑]__aXU׸YI6&)dl{\:1}fB`j6{La巰+ۺgPmdQ@ciSdD<Rl.6:ܠ˺gLycZ6K]5ʾXjDs]&/:KnK8A6J,͆sS-~8b&cxQh#]Q*p]hN[k%SΚlU,QnhUuoz\5[ڭo8^7#{Zh.{Q"Sl\ nosi̅P>bN+O c&{|(}%B黎<¤srȏy7gqp3'wwT&ܜE[2onxjixLW}I(! "[ [h`Fz+ph< _K)*KDkхX?6G TܞV{+Ts-"v['}R ApcUB]Sݽۤd[T"J^SD"(vk##UN{L#PުR[U*F#ȓ+V&SPӠ$A|/q<y|f[9Ǩ6ON^h?Q 8U,+}PTNjęN*tbJN(9ԊR"SG^Ei1MBGVyiL˓[u0f' VlmCsHXw/h)Z~YЊ" *~G#z)"̺GY~[C]$s:]s|aeΊ>V :9siat(MP12geyU.!HD 3|8}""m$g)vp["X?bKV//;{`8~ !j8fvZݶ+7ݮŸ9˛^p꾉2'옼|_Ȍ7vH~ `h dD |"&пsCMB2#gNBQ8f~ #Qko\A5ES9đٰiZ?A--5,;*ːɧĔonn[( *Sp-)JesoƉSFe'KHH JCISn$82F|\SALF#o1 uz(&Pvc+z-קiQo?53^)HSg#uEPޥ{#<w&MfI38-Ig^;HR.P)| NܻIKe5<@apZH- eY4o*m:aX/BwdžQ~~vT_>*ʿ0VR XoDmDV#ص;.ΧIj=7|nvZwL5'G"$/f3h߈[ϛq#GnN(G"EëvhЋ6c ߖ?ߗ8Rɀ7Ewr'NXn\R4Yqܙ= 3n}DZOF}ꁯBh{0z`qqM;&0Β ,+k09@JmDNf*K$e;ihXwNݭmVV,nYTw'Op](|AB`tB:1/]0B5+=w#R7|=bjxUU\$s!_)qLY B?Mȁ#;㿋ɏ2j%Ee15A*Rk3y).f6,_YEUϏ@QA&h8v+wNa>6D9%*6jб$!Lb~/񉑧Πٽǽd!:iJLh0S8H-1u_FWL͂ѵ\a 6 HwO&SCv ]ߌsכº RT!~] S $WP~=քټߓ0- 3ORdSrӱ(=f4C~usxb*eRqs?9I0:O x>ڏ38}?P][j{E_!#b=}&ЋO!y߷q 0 "tHDm422J"fZJl#eLseRMlWTr-L̯5S0OW17wIe/0+Ї3(GÉM(?pPrx1hrF3/n#R>'O8+JqС=G/&lUSD*cGҵ)ՆL2Sَs֠<̫67YіU8E4`:ΫN븵N^^bs+xǃkKg)`JpѠbm"JI;nLCϹ6#'ȉ_lmq g 1`); C_ca&)٪YXj;_޾&rJP}!"hi{dPlW.˖O+owܔה1tݑJ]Fi#Nqi~跡!n.tkrY 3'x9z,L lb/ޕQֲ;^㩐+̧yϧqٴcb;29TA"g^T[twٳ:=[f\4[,*^*ZlzN]vW>h=~QgobW^[)3c:IsETjup4)`]/*sDh_زM 5Oo"L^@&Sdr~{_&4S6 1%<07[?٬=L2]\os!pou;ݼroc:{:gOg(OJ/v * ԶKtK):E|=-c>$C+K ~3-[=W78#@s5.z8_:(dN#Цp'nboK+.l)k,dԾ;L ]IKEpY{X&UvJEm0G6j~kЌM6v„!ɜ#kkqx#|VζƛEms+GpU^tRXk+xrOF%*ȳjy3 #+.k VNܲcCIr]hjΔ,BJ{so,P=L%Qڛ8ϫY%Zvnm"ջT_$kB8"BgeEΌn}GF !r&pDzz'+TN&Hb ߂:<6'8BZMQ@ޤ.!"P"j ,j #Zos B{{ }g'&/!/TWUuC\Ey:74+).q-J$0| Al]w U)7gB%4֦אs:JmG璕 땬:a- V [Wa"jQVVg/IDͿ_ ߍ_nsr wm:Kh+օ4%$JiѤ+O$ykC_D#l^|d5Qk˫Mz_X6n[㝺^5.884elʚ=Ȟ?Z0 H ,a(vSh#A xMe[ ˵_Ex>%4F!)BA |,w9b?ްkSlOaj3(EV}D@vGiHZp! PgQepPH6rc>iFwU @kH5ԣ2 1=6O\R, 6H-ezRxn$`;wқDܜa|o )lOQq'B>9sm{qdo﹟78z=3=Rb$YTDʉOgx#W$!ٍ%FhtU\yJWJ8.h%VfL|؛wt~h1F~.e cXly&l)5*9d-d$t Ee!X_BkYvmp.@1<$*hK Vr:Gy:;N5*SA,o1AR92TX@<(hD IhٛA~YHJxv[t@qϏG/#RH"gZ-ӦƯȷ67ȷYn%,CZဠpm.*uE}Jcޜ\qrrR&"hk?twwy1GP6Bv"Lt>^:x{r;6yc ]-PFѸV59/Ѯ51'U$rzaaIEHI9<+~~ݖ6fn]famEH&__qYA&UbAb~LT_ ̮׽9)yoϜU21ST 9AJI8&4"n|k{?c11@|m k;N3KIU#*TZ=a1f..}.a sXU7Qh؎^]fI[{(E5k"4t晎e#~eeWɫ,e7,TbSۉe vj\lкnB{D]66WxҸ ӑ Sixa4W^ +D[!P:uҚ3Vҁ:$fިY6N'{ɻ u$5@yM>gA4Yy'=T$o1!\괗Z'Mlƕm oTHÔQ/tUE:nF79/5j4a5*Y!nO&tF#$P}}`$Mf<|!SF$UhB[/[߿'W)+J jq)&%|JJ [рOQLcT?X癆_x =𝒆X3o9"? ]EA;q `pOBi(>rsYB[#e(rL7Z)'OLB( \,rLI.OИ($X%8xz i8krr YV\mrk%V0 ^D8b2_Rh<&Ύ0({ [q񇥛ݸp\Ş#2hWd9l6_;-RGZ[ci {wD*{s/ѳK`5Ըc' 4 ^ή443E#oa twNoc N+ݐ킿liddo!ӱF8Up}c%Tzh''\W'$ vhon3(9iSdܗ0!M}|n ~uL+iZ:P6i.$-b2ZU7F=jd{6]uhKu'\^}e0e }mDʳ*7NUEfɣ#| C5ezm+jpK\,uCN (d57uu߂oAӁo@'GhƠ!fK\g}[-BB-B[Ȧ2 BdU`E7G{j\@ؑS5&7Qף+\ &f>#XA\z5wEBcX_qn}h0_`ПhY|EZfV'sF_.ys8B߰o?Ye0Y*NhYUo25X+8Pf?gWQ8laFds*˲{kư`~3\IHT߿K]Y%hB9ӓ㓝%4ƹ|V?oBӅ;[{1jtg19OZZVoLa-`?vb: /"M v wӅ>@vC/`|#:y^j#b96+[-8.ZˮoPCY$Xa[N_b2L5m.亘ڧ'\W'!~2ƤpIAbF ]Pۜ,D5"QE9H1m<[.5?HE7m]ܙN[cCiC i1̀+_ȕMH(%_wn~.|cuB?$ f(y='~v`΍;*Lx@sRUC.j6.Aڏr%ӿT e 5ݦpt f7tCM" n)X>..JګD- kd7C Mյ+؟ͼde+W󑊆)H4'>M}SN-7 -! s^:1C~Ƌ5q(5&&@~lz!(Q%q! [97/l߷͘VhGjhSxްW '(pwY ?5Bˁ !W9/ًeyy"+yL60˔#RPw4$Ȑ?&16!3m!Y5C']%<dSi1y^oAhco፧V7 M^YҨYNaUՌ'),AY%<ɻu71h0)S l'$bHʁR Wp($CW~6ԗ6Ùz,8^k6)kRTJ69U1SVfix"RbdžFXC1 %f̪3t'8@rcl{[Bwaѥt~ZZy] %<}A}ck(2{'JB]릛je a[7 25\)&nCQF )vt2^Kps+}Qj/tUfz:kYk:4LDžmSuT )C:'][rQv`|N,ZK&9B=I9FT"100saM#f\A≒D%BXf7)'s1۔":Š|i6YL=rktȿI`ZlZ|L#հoCg6%$iT4V8r7 +ƃOp NHWL r@eL{9 d q+G4-o]L<8@LPa:INqdUnM }9WU[cp5ngpbWh^1o"Ʌ7A&?*,ST&mB"YL9Ŕ`!=O3{xw=t^` swA$c6ܗnjs3\g8QSV׌f;t:.2-9[{|k^͐"ifO=~lYTQI,dgy͆2؄dy'{)Sz4`n oOh:ː#lۉK#zU"2Dnĸx0䏒a+m#瘟%b,nsLZVc cÞK/P*U@)SZ+H_MDjWQ$ ?tk 9b ;2 ,CB3'Π\v=5X;Ton}Ww}/LGFǢ'mBͭ>6ATvB\QEiekKup֊b)^T׎k44Y )zK.X4)I#CfZ_ZNT-&^e=k#~*:'YXTE|0B1Tik{V҇"j$ u}>Ve0`uݝsCvjR]kڧA%{#T'o'`^[fT70 <Ͽn~]xR./ ޝYJk;a=6[h\k*鹞nn^hB' @e* ޅb2L&NYB6Wz(w$#&( ύL L1Εn&uٛ 8qDS%: ̹,'1َu!Wi_ųي8&crin\ϺR<SQ6TQhiK"=05xJx\mWh_x({vt|}7'P[LҲΝ3֖I{և %@1p'>0g=3)܍c)96:ÂQ@5U![jIsmqëqzqzAmsI@j{]MBf'P"@%K52SLb+ FJ>GHqB'rfXt p5/7ME0>ujkRU9I\ߙt/^ m;dcbIc]9YR6H_'6uQmG 劐kp9>D9!G>jL]F?4'-*V aVm}8ݧ qFjϣB F1ћclj&!M5qhdmkK`c wVo.V@vz G3jM3q\$aVb Bf'xEGcY/}GQ\8ߨeC!ƔT_\b7Xπ9S7Vh-Ϫ^iv{JSM92|HԴ`,J+&M[&~7eB&` meZ$$+km=K8GN=άlMtjkc>J8Fo=rt([ιm06:KvISn5j9͕a.6n\'9\OyȻEk렙FvZ8%YmT@˱֡W0嘲[2hԪsL(Y7I,$_ w6<֔c!'iBbQR{<4lV5gfODz>ȕ\!Yoz~Z ܯ 9R&,aeI[K9j*C_0MDQ /Я7U]-脾ʒ6%\użn˃ ١aZ4hn7{ 8oTrpSn Ѡ$m]3o6hۗ  )}=|pƍ[}aWV`=7zh,TXMGG 2xՒ|IёJIubFt΍+mG(' eCh7:Zovnݬd y!&8ZxX'69Ԟn :cWwr0U'ZcM\ᒔg9)jf5wam7~HP<@J̰m*hM*+,6E٩,z֕R>r:7(7WpRy;o:}8[~#'eCo>)]f떳u*~BN-KB.Hy|i[J2YʞjQ9%Fɣmz*Z- ~M[E}oVK6ŀ7B Gr5뎌2 OHŅ Hq;Bk_Ky{׀˿H:IR3\Ƿ-xoXKv$#~#Q=cG 1H.NsF̔hs9^z<?e2}Gv*gq1k!1Z k|Źf,EE^lBm` K*&!c+\'&c&P$ƟX?ojR2E8i;&eV8P.0lf4lB9۱$-{J}˾ #;YGc>EߴviyM\NbFT ?^\]]=:aH+)7`xTEٻ3%]0̂B&+XI+v$-`ggשkBNEY0 iZ]" l,5sL}y13~7O6p?L;I@o(z|~tzry|szro)wHOW9Vn<LFfa+ DYP'?׋}f"~?H4ti}2%˻U`^Ida(@&bċ5٣Oӑ7jWP4oEv$ Tx`P)'* $To+XIJBc*SUOZUt"2 ]T@mdMs:|lB^(/ޞ\7&)弓˧|jzp$:h\N$xePYDs2&Ӳgr_l-)9!q&LQ=7Nۭ$nv8U J]]z.סo!P/F89v,$&{0qZ 'OEK[܊g/Bkk"grJd 1viKsdKIDI8h$Smiؑ-Sf=VӬǦ\Ϲd9] \[-*ExLh'bM($õE;_7D6j[mbS8?|aIs B rL)&fڱWL;re{&% rn]}EIbc52ϴͽJ| tz<^K ԵG4x q?eEX/}]x D]me$ݠytmi8X c:_r-,_`sO?0[X>$E`?|X 2D.9qHEK_P|}>nk}) tG™#!R\N`x_ϯ_D˕qev Vx.OáyP0ˆU_RL\6rI^/&Z"W&YL[BF8^Iʨȣi?6j|n_tĴ̒ILAՑd2*ɷNT8TQi2 ~TݟNu~-{m m>2w|a|3L( bR}ʛG=ov|\>(C;˲vhLn5!2j`OGmrSEeRb'Vܬ;%8oAcFK2j/)$Ui`ƨ*ePmd2]T}Mb=.CGcĘw$AUNDSd<"KN@ӊԌhO И n \QСNN/\/΍Y͡gȇ-%S9.7A`$E!M~q]2i- WSB%bavƢMkR  1֕VͦK#~^tG??{{p,y:wX]xKXRv[͢/ø ^tr6<'/zbFώG+gUn_47^|~W^޽pG+{ R4Y)o/&?Qe('0V;I60Kx  *F fm"|aW54 RSEtTKq0>{do_ݘ|$';A$.)KΐWɮJÇħ(\vk|k@ÙW*Aп!|kZ,a M { i\BzqTG1n<6/aԑ{O土40}PyHB x ww Xޑc15us(ax4I39sW^&,wp03^k}hAsW.]01Cؽ\;(ŒiBCY86d #T1wuEȇ1*~s|C Z;66^iKs{!dȜ}0lҏV˹=+tJLx^Si+Yol}ήQ tWP̻_B$1lqGZ aeQ>ZhI_:! j9€Q8aP&" 2!NRJd-(&15_,=2;kt}F7rw`me-ROVD ~606$dXkf#Ȳ~Ǖcj5h"I+ZT8}H|&srKM|Nv@CoSK ɖq57,"q6{@]DVa1=mT)Mٝ<%Q-׫l_gqdGJ0˹att0@ra"sh^bt` Su;fiRLe`D,XX<1еFɦ5{ k&`>*e_gWBuQ{!6VK:\K {[4=loqY'C՜VcI5Ucme8"'­ύ!51, :x(SVWM"ޚa<'_e5Se Ԯ`% {`yQ<&[C^I:䗋8;P-UԐgPeR#e,64~'2{Ĕ0W9ԙ^,Ƹ0'1pcR9)SBq^,.\_e oQu.chư80*"a$ˬiuWWYk݆5VNU9Bg6rp,ult߂86F>E6J|ԝ[m`l#td@'b,c٬r՜gaY~~^| 6s۰mx܆-@BY䇲(0f~xˣ̟p+7v )miYp W| FwD8!#@\މ_O'9 7'Nĥ2eqmopw1~޾_QQZ*"-}8Eӯh{2!t?ɠǵsBZ inBZ)vYH*Hq9kzVy2y:Ea t{6[OG;h?ՠ}Lҳj-k+P^y3;WK {KƗ"M/E*/E^ ]Yo|kxkƄ-̣wpӘsPzcA e۽v:%Hcdq}F K2--$VJBb-z31bF2T3^O2D|E(Bkw"DYc(f 10GW1C`mڤ\ 'Kuп-n%5>6}8%X 6rK*XX.i?(u{Ss[f6/7Œh={ԃ{8!o0Fj)_v~2VNQ9Zbp s㒂x[D+!e`;Ivz֛L2% oQ+/ 8K )fM3dksYB[.GFL Q-ys4Qh FR2P%{(Yf.ޯf.+ uM2`+MtMW**,p""L<=K7oq -|!9=ܶb8{SC/ Ze>^?aiR_ѕJ(|<_/$;4X&*eo-"Φ;3yDW TI_\%s'6'{HqԀ| $#yҲWn8),W= l'vR6ȄQYieUu1`)_ =_q Wl*dI;]QL!G."Ζkif@X[XM d;}RXnY3C2`{=ۧrkRFKe=(dGΓR } ï, p˚y9ME= !_d=Et.*}:NA' Zt=: 0ya݆ 8̞vb̐gmS.A~,DV3(jC t*L=0 \=<Wy_3dCqNFK>ƪca[uLz 옐-9!ɒgDG*24fʹPܘO u)dñeb1=!w' 0oPXBmꖞUĹK;d#OvNuT03ÜpDT;3ufΘ)c~z8~lx2jk/*w*&滑Klr{4 Ȝȥ^=) /&h_6@l7jԮ,mONrA$% &[ӡ!(d?ϕ))5=Hkjl0}³RS R cY80xԃA_e*1bF,L_ 2h@ ΡncXC5߀qhNIg/W3&K9p@"'?E_ʯ,S]f̉k" &dر;hjf_X' [JyE?- {E`էzJ*ik{w?k9Wt]C^ޔ>Tp6ui o_K:"pb q`[C)dٖs6.a6d2 ?wDW½`uG >»?)Nz}7"U!N˅?2Gd=}oMvY [W🤻ی*}.xC>Kg )lPdЃis9^z r~ SG.w4ۅ%a!onF' W1A\jkӥJm͡P_rMB!V{<Č-i=cfm܎]MU;I.`AHb^ӿ&ˉȐ#G35Kq뚸#L duVUŸzk'4ɋƴ^擘 9Hpu 5_b5G/EG.10 @rC(i\5Nwp췉QE^NV:v=7^SD6]\sr|F΃H:ÔSаK3=6re Rq\_ViٝQgX++FV֗8T8IO ٸP5tLp^g0Gs +gM#xdlt+6F 꼐 >5XD'+F V,A,L]֯I&h#ՆFFw=w5JJ5pn[r(r`8׬b8YNL^gJ: `Uă昨[JM#>k|g)Z ؅ @ۄ,/NԼ7>jx,@&I}GI9roȉSdV &M*6#O;ʙd4Jq@OҚDh ZrH$ISpZ6O7iJ6Ngb W[ytfiԔB9|l0ؠegEci+m$6Pɚ<5$ݼӲ27q٧M;g@AȐ\H2KA 2I" G[WM&o7~luqibd,9J6WV u(]Bdv{U5[/ᄶLV97\HL1&[ 3 ˣpCg\HiБ7)(Uqzuu$'A.T|)*J^sq)ګVH7{Y$lUu-84[PL: p37+lwt2y1z[mE{˖+egyOmxy/;uEe?^eq/?)4l k·p-hBx|_K t&lmm^`͈ Ζ~8,N=fis);kK)P,e]d0z֠٠,&,_+72X-~Lv-.!ԍk;XgVBp5Ag<7J81:0͵ Q4K*i}X%5%x;`sKMcDv5 MyFΒX#)ؗFͥ2r0V(Solz$<+X&;*6Jv׬QǷ2kAG\Em:iEd-4샷tC)GY(TI +V4<7Le(b{n>Q T;Pic:rj$Jd9nSt:GOR]Vgc6: 1gyO|į{sy@$K6n`udɤJ])7F,lOWGREFQB8!^}cB;n(ACe+iv#!d Ruވ\*F4TX&Q굨'K\1 n-p30 %T7\&{L0g KĔk{P,0zB6q]([/ʮAsq ,׊k5YtG M  bl1OyRȢ?r|}<@7og^?l k y9S-Rot8 M_VAWoz:!$dZC"rE~zN7p"񖓴eQ!r -ȏim7+xa  qXގ%;cӇ40 PF^E : 'ՃnN BTAPC1NA{`~N. * NN<$DVrX ̓3? h"u-:~m^]vOZ戴kk8U()'٧o9(j0dǟ0lK')Bmvav嵾OGgo`t%q}OaXj~1\4/>?<ւz0 D֗zӌ)aũՒ6:H^f%܉ s4?x{r[aizw=?v!$c[ cryœR^s-w澫b~m#~< ҄Jzqp \q.KזkEm*)H1h3i8 [ršg]h [5hv Z['{p,l5⛙w[ Wwˋ`'8B8B}j C!g>@RaNnٍ3+ۙ#hEyjF_I߶B&T%ԫNY=v V3q<6كf 4^f/^/)TJ>OSRR3IAS}EFOM9Y7nEZ\OcVњꘜKMjp=7޹l4I}i*#iT\/LǦi8'9>,e?GXJOCģX8w"zwg.)N_i<wv;u[Or+Y R*AJT {Uբ[eǽk n`+ަ.GFeԜyJ^ UMǻnrOsj` $>S=Qv?@(l3t]sLiw >%eo$_W^[w >AÅq7T4⯾\v 5 ~YXM֐uכ!\ 5u s *T_+F[rᳮP0Ir$lWy6^Tep)6Db' h,ĤA^SCJ^lް a6לzz桇ha> )Q* (r*]nŮ0rQ(iNlmԒ?q+؆ybwrɿf3pRB$HWEZ &c֫3b+UJ-r8:YD%|Y92f/2MOFUimm netO9c_V&]dQ+NY{RSȠ Wy)FVpZTPr`Xz˴iR}lޚ&iWiْS~GykBjqK%ʨD)k w V }ƱįLKH#*).EسؕMȑ`yy3Zm0^C1`g/PV)eRxW/ϛ_ߝ!PGN. h6r(1 @-82< B4{ ] -.uoXK\1W%rr哠K XP<m/{UZЙW⯵YP46*/\[[zЀJ5] Ю$-}|x)|Lx9s-qtzr)%@Avx:V*{>>aAT 1<`c\dr|p|o /Wn rb Z16ya.fߌ zΦ=T0?Qvƫy"@dpAEDB,i $+"wNP7p2^(JR|z'uRhv5 F7!6pФi MkX;*AtG ˗ND7Ҧݻ⮼cnQrO^lFrby&9nC o_|-pMބ7g\j`*bzgOOP v֮D187Pp-)P^lzq$,D(EE!m"SuWQv6^WB^g?-9jWXwpco<6e((BB}Bx C>Fֈ?y?f-}ӵIBrJ  &[^SzK uWk)I*e[r.!G :jsMqդ޴"!vd>Y9ҎR OIUhFX4~ƳWD[N 䒟W|R<Gy"?C`:]gJ~_ tRO KoԍLH6LY9| =&±jGݧdzwPȦ#57^|!{hnJnVeܜy dOvO1lK}䆞pC(ho߁nCY MJ6=ޤ+EhO܈(FGU;:帣[v_ſrjmGZ4WkI9\j}T`+ృMW*V`hd :WشJN={_j %umU[Pe4(aRNK&Ed!wKPCh2jHGR=:Ս>A.EڤOB` ozE*"-,2JVTb6sNp*[쭊UqG$tStNiC6vVF&hES˧-,X7'P6(Cqi]qqļQ2|s{T"RW4avao51_!fpU4XmʮjQA X7UD3TöVyMи!mQk3 @IksLξ3U-*jR&ӖkhV&Bsc_v`CC5:/V_CR0$st3qM%kf#UHgo)I"ډ哚F19Q۟9=mm0d5<&={QJ{d(1gest{#=>?+@. .4I}Y4$.-uyJDnjmi3כB欲(r|t[,lNy'Q4Yꎶ+o e]k3&;fe;&+ne6.CSs3vT fZ(Zz? fj:/P>{yx_>4⛵W[ 8n4S VS$|Ȑ7doka+Ÿ~\_?_I2 M6[o%@PSS6me/ 髷 $P@+>c]s[{0҇]`j%NF~hf1~,QOda%1`JZhg?[IHNcSt 9yJ ʼnby{\ϦC-)0"0 {E58jVc36n6u0j x.s ij`o E~7N1Le]9Ne({򰄅TNX_ݸY F2 L1p2zY8 ͢59JqJ9䈉_:}˄7*C8&ȞZ- Y[U_d,,`zuKq$F_AP(Ȣh cFLE6:h;Y{:5ZjH@J̪,YZ78$f/\[gYlfh%6 ;2> tIWE$UTlYg$\DzK)"Rs3͑c}=:usɢE4d9i"la0`".2޻[d#V^V}'~[յ~zj1ZpXg5CUe8FZG{5{ o<2<fѱeGh6urqq~aE5(P!J{P>1/a1#\x kݦyjxp>iHbxɐ6YvHPǹ .gra(NcAzkAz9e ='3 um()KN2,ݺ3xPTXA 9g8vG:w"zy9 !|@zN9Q\@Vk]kĝ,k^05o7*y.k0 +ƞl;V'ɔY㤈ޡU,ztTմbό^3].ɳnFԮX#4!i&9Ȯx̪xlH xKL} S{~&j- a(SM YJKUe*aOmȌvO 3FmhFuQK9C~Oց~Վ^j9Fwlh1rt Ͷ; Yl+r#`~}؁$`ٺeX怸tå1G̬l5qđ3~Ҕ qVQ\@rW,9JW>}"D3wcYG ` )n<5纎@#l*g"l9™dWmT먜mSlhS^>hFqy ;Ž9d8D 6D .ŝxrRނс ^pqM=J\EJrjz/ʓ;xyA' =IǾg%;ȋmefn^-yxav%c+ Bۘ*B?Ψ?).!lK֔qk#UeYPTfA,ZMH=H$ v:m)Y{ UgPgPmmBH~ m*ll,Y>.cup -}k7\ pԫ%O<<#syUqNһ("mO`:V> , Ϡ? }u~ fGM+j"a咏+N]1l}n,xaZ鞖:A\:iƽT")ZBj?;1:}a@Շ` zpb]=ө:9҅9e!avPv4'P1#p)2,ڔ{GQ}{)?ji2Bp(īI!0/pPԿG@X^#a,_BC/Edy]WH59ȦJ}'%^LT8ZH]t\/'~ALGhɒ+uL-!t|6Ƒ?UX>J8dv6 YȺ.3)pG<`WxLoiz[E,x]=wD"^N%c쐂7ϱ5`Ƚg/yB*Iwt}E[Kv[1Ϊ9EڞWkV4l tJ*Th{gI7{n{C0NFV,˿a"BFgEDӍKMɺ$t&uiVI@tNdu5saaD!E٢ t4G*`2\;0WXk/Y8oٍI)^gkQ56{{TP%e4}WR̕Kxf`Iܒ~SXf5lҘ&ycR4rqSF>Y`PyHk7F+j[,ҖW7BTN Mg]3@4)gPNl \SLß1~zZ+ia3(b"h"0s1S'4W=Lg3܀So(u o BBf A^@6/ Cؒ_@sĿ߽at(|.ٯZFQv٨~FVam&bdLhp+ 7# >"؇tL#.wqw>R^)7\꼆WPBP+~v{}̓v({TLhsƕ4[Y/ <$_-X׌PRH&NO~N.H{4"7ȇZƕO݇t 2k 3k i+4Pb0_) 41Pt0Z8pCьgn v =RX ?bR-|q> -ӱ/)\o*C:ÖHp%&w`B4 "s?"lّZz?iejM0[[S͞g[L\% iQvnO>ʳogDlWJ&#s˝y'6MP a\kɴ2 bӚ{0g~1="?Rp!rrBu#3֛u =dLCpDw>!2gdD_dxr 6p3+X_VS ^my-{7Qj բͶZp}[,/‹ާOsD&>›@}愊=DBӛvar|,PuegE,t$rrFE=3A$GG܍c>ۏצ*ǬϙXoг)4IT֛k'ǝ=4Frgrׇjc΢c7`B݌=8<|Sȥ00e`|Kw"Ùĩ1ל"I~K!$҄7E,t>AKڂpNp;tJxmy3p-/0\u;RjPEZo3~_ZZw28#eu9gFVRjX#3K3i@CY}s87O'Suz)zױ3S*-ѶNdQ%'~o$J$d[@h4<z V]"j/7}# Pq> ;Q0YLrO3}qjq^ KcZuc?zp5=K/Cg^z夌釆 zFVT=ddfiY43 }XJS˱&(A9BҲ0C4(aGЅjB]1 wph1@Zػ# -G6#5a(*qļWSo9|AX!z_sܕ7Ύ㯇8p1h6娎n+j9s磿 zTk5o5`5,LPL`ٺ~'8/G? )Mȣhp0`K2"b_WhBܑ^5 \[ }F 4MNVVL#>6LowihN}T{ bʈyZXAlCKj#B},&=|}ZoYW~^tj).WXF R0,0$ RXUfBGsZS7aWNzZod5 eUxA O@%i2^]CX%[f-ђYj&ŭ36Pb Rz/:æmmX;jG6AOw\]H `[?&"op f(h84 @م )O(ʦIY8I7\C!Lm2?].P֠^v` [MkSӞHUe$zK2KQ&. X.#@!A:YjR`)J; &C}Jʢ *jϓJU.`Y:c+u8a cbUuōY=mc@-QN, {uoVg?-P/(Vl:%R2rVKU^KhmXm>ΪkFw'sy![Y͞m,L+?QT"Dôl S3y 1@f]\}Gzѹ57/l碈3P}֏AW]tRV4ʑ¤`4;fN'ŒSʫ\\Q)aNՍ/z(}Y{0R~bD, p}n`"@e:)#YVZT=]mE'"2f@>Nsz`AIa/i|2#B;b?Rt4{\-=x!n.T~lEiqAcuTj#l+:9)0 mpa3/I2_;k,XopvCGv.l @ÈmhiθFQz"I@|%`O *pr4eInj#⸍T 2Dπi&xp0B„'hJ#:>O4].4 Tq@a.B߷Ɍj  FCS.Ht`-}: dSxUԐAJ|wFH{s8q.hdQ@Y"]Ǔ]9:?97>PQd9~#T'_gfOi:Q =~-&Ggԇ;!ҟ?BA1aW٭\ MJ L=G\pcP#Y?{c_d %9ڋ^Ks y"O̻Y:)a!4 /O9zO2=;|$apr>%&CYadG1r Yx,sď%AE';Og'ggtbCNh=ND8IT<*N뗘KsM~/Wro/o[)s+~X`ǣ"k x6lN2]b0JOH:ĝlCJ_AnG[/&Dh pZƉFZv[npm&w<1c[Tg5$]K4n1<{6:A$cOR_C.R)*KkJiʹVId#<\^<dWi$rSsHRLT,u@ڕǍ qd6)WPMv /&rtҀEN?wH'}Ahq3cC {$`BVF'J?|Ҫ&<}lp,6Hd*++¾PٝC0^Kʵ[yg<.&uStA3"uպl]iZ'^l*:*2kAG'nS3腔ݐ;=_PDe3 R٘]78VFuG;>q#"%l=18P$ څ~?Sdr놆Q"ʲ{]t|-:vKKVFؠjx>o,Lumsdܩ󦓖q#iSI+ZJDY+otlȃN:eEJ)+y@aVM`w-mNubkOd?kDX w!t7:yqyߗJ}́%k_vOf 5׋˹68B/u96YU)s'0W_S |1vȡY|͎a:K"?<4Cc[+#2Ghs)b2}Y"d޿Y.V eY3+"7D7j ˔قt%Oe ??ʁʍࠫLW!Jmk: {8SCH1`dr`t*+Ң;$>|o "(+,P| U轰<#Jǝ#3檌tW?|^o#P_6)ǔ p=ZA}?NQ®ҧh?w1 ›^ Ql#G* Ai٢}QsQ1wTV}K,dAKI8=+^(|3}6 YAzh\~yӎLHq yj'|8'?A(Y8BbP op Z ft\MpY;:H_W vbD<|?!0;^;4/Ϡ ~SJVI,H]UoUKP-DP*:~i.T)13JzAi)a/Ŧ5:50T'ٖSaՃ:rM#ˆ:i'-ԙ֧^=]vyQV7].d]eoRJљ^D@]NJjfշ3qfU-B%6>kUa5 Q%}h }[bHmUݨp g-mK VW6Q:5t9)e"}V-P.Pc HH$${v;$?&_% ,N0c*]?vhꕍ~2WLjg`'n R=!у`!_GzG|#)0yzs|vDIB|^pfO 3l—(tWV[\-ir.Woor']Z֝G}IƑHWg?C ,p=bG99q7dDO8F#ueHdȶ("S 3B$Mx)48C–DUTS4DV1[~1Of.%_%b˳ȩ(ǢU Nj1pE! < x"4{%k0DXC%+.sJ.'9aAWQ"1TQ z "XDds&iu]>5'z)HKU~| p.~y+.qNTznt-eb!7NK XoKv'9#n s4jt<$SY>$1;G;ó.`=/riˀ.B9'yi7mBk1 Q B%$[Y0B+.2 ҙ˽l8LĬ(kNQLZӱNBno {:QL G n*8Rd4+LF-) +!5ɐSbҸl;(.Y%&mKZVOPV\jLP@ZnX= ಚWia`h|,}#JAxoi,kLk["L:ܮ%Vpp}1k;uB\q0Ѥ"pʲ ^?r(dF Px25_!~1c9=CI*O8FC/ 9u#0^>5ڤ`&(B ]d>qMfѲ%h_&a>I7&F>i?ZQDֻ' KHأ$E߉éC^G2CC%\_~:;i<{+P89緃Sh\dהz0v vӅM.A2h6fdmwqQX3I^ kŌ\.z67`/()J"D,F9=O15p$@v]AiBus8Zn,|s-C}<"lyC?ohGҘƕ?qE0ɛJT^S dC%Pó& U=E/4pՄ^lb"EGtp|O'íVeg.FZ>7w'"\$8=5= xEuNwsW E_fʦ=b *S0}ւrIO5׵Tk˰Uƪ=2֍yЊ#:Rz oQ#0ʱ k0>\@o$1[v)qFFq(Ê.&y p3Me:NMXzvU>*y*^ Ak[wp~{خ&} 'v*c@E1,r&ۮ<YL]FKnO,@w|s6sH6|A>n:l1]H!ǴrmNg I}Uê_<"?摍\[Y |vo_a$G+lijS\Avgש<=3]E(~(YVʾDC N'kc SS"*^hG"H$6$TǨUu{HhݧQovWԓv!@j{Ov#j-á@eٚntS@e1 6O|R/ K ]9%PSU%IXm4Airz~x.pZx#, @1o3T͈Krs?G*CO$|xpv>z]x %q_~^b,478XG;d;$Iί"POPbM=xߡv_LԒǮ|*| 4Tݠ vٰxl&/ew.Z#gH2=f?# hR.ųOg'pS*4WfrEMH#}5&Q @pҥ pƠ Z[5\_)(5z4WXȠ_H)*T?iQJ\T|2f]Z) , pr%ؒx%gV"qly^!`N-įbRxB.v:qaduಐlyVhf>g-K5 _A bP2eBy'-QY5Ffw{R> KUx#.05WbIKAg64pZA<4Dau-F唑0Nh)xrv SN̒P[trO6ڰC5pʉ.9@6\XlXRNZzw)GIf*8hv)U']`|șu<$#44j=݅5GrNUJь93s5vtbFO'Uq$.{fK ?~2s6B%>[*х QRFQUqQ+rQϫEwT˷@+O"g_w:ԉ]JXܚ[A'Ժ\%J]1 ZE">@f, (cqv`xŋMGT'6H, ft(ˆC%wogvhNPXkoKXp@ێqń!&nIdN'D1evqˬ#*Mi$`c}R#T$a)ǗGmqi31e28B0&I+ujD!N}YKw nWr2{fXyo/_pϳHN5V{Ak wIb"SlABwe^543gQRȧR9b|]z;T酕e8x͑ Wv==@]L'^l`r\Fմ )+7vt䙚)?%uj |o8NCW!U1^F)h%255͊~ ,_\DQyI| Ѱ)\Pø >{ZU[`V:E1.e<1h'9Lgb%xWH?HM"nLahs w).] 7ťIWWb0U%h3RK9d1D BBOc g4STR8Ef4l/ K±¢ ʑ 8U-KjN)ST]TE]p5i6X"j0Mk971iHEhb+rsynh!6`❞0օubAb.+@ڶ-i봩[sWbVw9 xl5"lk,x! #^;A$Dnإ^`AsD/֪ȍpp,\;FQti+1i՛([ʂJ +1߮Q[Ȥf&!fޢ hYGG^;Hԭa1 Ce/sЖg1 xz1~19@7 {gBv@`_- @> H2>~ؙa](,YRVs7܅ூ0}]_Uʠ|eL􇡄91/3woH,=34rbxuId؉Kgm?IFy"ISSI)4w=UF,V$zc˜ q>>_Sɛ*J+Xr` X)zSE;@ߒCTw=߯l,scxwČ+:^.Uy e~wǨ+0G+/7H2+=0""i2I4զ"dtUV 1jޅIuL`m=:/ț<>*bkEa$LG\daЩ$67'[k+y.WAfM]ŮD1VtEcjgnԀح~a0O~'jd+:Q^&9]\ݖDs0TE֯,i0ƶ1MGmQN{"")9q^kԊ*KAKDUCDn0hnqu\s:Mc%icZ'!/5>jERNڒ¡v,]Gr"8+AAx\uInKLNɤe]=F  |wͿΌLw!PͲq\6NkW!d$$}^U8n}ii)VG3蔑g}YWNSwdqTo:S&?Cw#%b۬Oshcgg!%"~%Hs6.H^0#JZi( Rxݬo| qqUȶ8-9eTae)r"f&~] ZqR R,M6?`h+@ji7 (lM"J1$ir}4ê] ¼Ƣ-[ׂNŃMD*R'I1JV1fTTRt8EQ[1qǏ֣- aycX)BnPN٨@ Cj {vmFmSo2eĈbHXaw[5!Aj ނ_evPCr z&safOY촍lebm )%Wꃱ5G֑+$-r2˨5!atm>/jQ0uX &kz:X7gPgURp|ګ3\8Yge |~>d20w}s.㧴)8fSk(~gWJt:%5Uuq7؄6m]} 蕐j]`V'o.7uJmiϦz5Sˆ:ͤtsub:%tld{f=.;NCSDo֗,EMlFNϵ!N*lsl%P :Ę,zYvS:}H|m@GEW I黛p]$9t4}YPl˶ā69p)&4-q#ms 0%&m ñ"nBkx^v/g ;Rܒ &Q%l}7]""{Ne>A@% <1^Fyre0}W, ⁾l/R?44[F.:V4F  o_MCEEtb"c)hd c{g^8Wq!!p_wEn /EDAnPטEHi =BNQ {L8Aπ$dLfO|l7S#*L ob!AcokϞ3W+/R7#IlxJ44:*-CFv' ɂ)+˰ F&!6fp'LmE=1QLFjje6bmnA::"ؤ-bY@NIר\CݭKEoÇZ odNLVδTC[ WTHV+{e{e>$M"ιAi$Mf{̗"@'LuK4ŤvT)YhS l֔0ldUz'4P'IG.^xYFAe*md 9tnUǜw+Mb9–C|T$+{mf0m,6Cgb5um %nX(sP ۠/cāp`M A16Mx4LP cxYL8o\CBqӻHńΎ`ΩF?܏|&_֮([Iǐo e?dhM`ȓ58?;`j;{p+tě^Kf=M|.OFǓqÃcAz_* WZQ { QCF˴:/y6sչ7niU*pBV׶|`>MÉ)|Zb[zƗd>d||kYm-|SĶ/Oc> X_ !\SJSBN'UQ1[_Z;4?F ~ƒ-r_z=h 7: ;=BLRJ+6H%Ai-g^)ɓ)pNe],It+BHVXٔ;HU]v*I~ Ou[ȆCܗr|LbżQD8 7ĕ2ɶ(Ъ=|)>Òe-`ē^9xR큐D{R -a r"p;;La\pLH*:0>NGk~&m 5_ "vD ٽzT ۞<}Gj+NuJB{ф4JjI#dmﴛF>#.I 5wB_0Ebヶ =xo;4h حhObTqXYU ^W凗`9B5?p̍5/DR 刔(5炓Dj]6 R {MJ6?oAS z}heu5{XL6RR;Pk tX)47DŽ:Uഗ4SS& oHŞj9]i3W\kp9w{4T.=RR9\c&3Pi-SLm8Ʊ|>౨8 ^kUeuEEIRlRʰj^PFmmbPj "j! j5q̨DaB{[ Bեj 7X]s3)LY!#/+fhJK1BXo"B2  Lj-Y}͍Rzۙ&p`oy=3tbBY^JFkI%ѧ0lH_8e;–ٱ2v*>`f݅'κȯ,<0gy6)--el.ٚLhyϭJrh-SV߷pG_o&VG~LYxvĮjຯ<_>ڵOR&W>jd8a+FiL&'jIO9NLIQ*L)JIS9R_TMʯV)T 'zIW8)V +ɣULJֈ3W)IݲMR+g&S_/+LGLV^٬0TﱗFefɓFAɚeItN]u 5tօ"ʘ@U,Si֐[53$S8)FeC56q`cT )ĝcԏh<1LxyOy&|q9'H¾h+SWi>u{X*(atLPBˣ< jj?LPVa |I8&r:yatFn `\ $7Qn#< I C׾|bjb׎ tͱqK>6ގ!l`*9k'^4ZIFE :`+@yc%(OFjaNeE!/ ΌG``Tb:edc#%(h;t p;6Hp4JKD.d{4` @Zl Hi7j% Et"5ʾz֐Ю *ݠW&YF&iK=qx?Y-^cśbOwI"2  'ፒ{|2ЀFB;Oٝn8U*", ,zz"&c P5ׅxtb&=~\._.a1Z +ȮZlu*HI됉ZaWczjjL74Y԰4kdS)ѺUTl H"VH3/B(Psg)C:v8=DMY9ͱ-&`& U zNn1&HۤbH\j6BB ut [颩;,hzɡ8(6`f* ut萞N¹jZ5VThZeOT'7O tӤ|['͢B'*`1/ܯ#JiU0Pz~!xѭ:$"r$&M,?ZE]cڜlkY5ȏgd}{cCd{FEY92d87hz[jv͌UHS"z7Q uJ Q^6Τt{c~&d:4E._ C"@Ɋ8&ʜ0/A=Ѽytt7 \$*NE-pX)#MlQƆTmYhLqJ &ġeKo=P ɸA+g>,3T Q A#C3`}7xVdK34: >$Xf%i jOrSVMZbFÃc59ɁFْKC S!CE%CľBݨ# ?!?|};!?`S4L8lN|mzӰ18Ϸ7V%Rbp#ӑH?#`&4/=4QGmǯep4"-ܼ6ox%-j0]T”`80 #YISVe¬EFAmr,Xi]ǭ0uNٵRD^6SȲ(<:uCّeqLם g bm_DK-ZÔsPMCS,Lǂ.aұPk0t t>Χ bp㿷 .P!ϥ8QJv?^ɣxq;/ &~OHOPb3/z|ޔvdڨg#DM1@|E:{1G %1ޢGt >8eON.v7Tg'h'S71`C|jv}oFxO#tql =o{8l*XR"Wc(T9kgG'bG#>d~wW|rKh<&| 8)l%ĹO/3 J%xR {X#HRNpR@c̢1l9Z ! { 7{05"i($aP4h4Wr4D12+^x3|z4QS& NZ$v70d!:QIywϠIN CF$vk7To*BE׿]dWIaKx~fmyisbZY23ef.6X o)ՂILQ&}D|EjUMTo@aw|c v6&qɵ??6:G޾![k!@/<#~}{̞F>mi*4Nfp0~ 4'$z6G7eiw!6 _.h'n?qWsg?T5aBlVw3Zxc Q=!{BCk PN!5S~eCnDY)h~}:;9?C?(þ}{t| >@bdOU͞D* sν"ztH8N?N_a[e~WS8:?{Σ3a`C1cyِi&q4Y -V'FQѶUB^ HL_\ ?9g裚#4PuK_ٕnKѓ~$Lj2/Ӹ6E;R ZD7J- W;0qqHʯ !Pΰc6;ڛ+*(I{g+]kύb't%[N`dRnlsD4bk!h}N)!Y,7T LA a$IȩR/i>ͭlZmgٞt&L>U _8FZn뛘_r밣 5m0ַٚ͌8Z^ךYNN(Fqt-&4E( MJ3Չ ~]d[5mKͶs$e*nO:lH}ymxDcyS!VPTRy13WUh%13@Rjfؖ뚒90kVҴ^utF눪tCq*=JkVUq@ET\ EǁIt߀%+o@:d[!`^'*Y{7ĝ1d֦Ʊsm*\[ٝl3 jyū9xTga@b$hW7Ow1fe`~&KͿǘķ7,&M:al{kaﱭ_֯c[ݯ ;9=dlIc/A zM0l\[ ~I+\.~x| [%4$4-ɓçtJg`2(.j 6Z `R9xџib4+3찶&ԝ;8x%D_?祻p01aN{+OS*0=T,T(.cpC?႕RB Zz"s!x=t}[Z>Lgܘ13z[l,|m)=Enm&3/ccc| (Twyz16l+L3Lph$ <(vg1D4Al\t5MOh2~rLA-l Io_̹ !-?ye{,>'#0sIY"u a[_97/Y3Ox<19JWvGtn)Eڝ@6]B~}"JMkA.q(ub*",֝-!#Êb"bԌHI?ɓ{ pxDf}MRP/՜=b;u.< ޿q@oO mq#n]lаmv_G֏7_ @İWx2U'qe?GH]sb8m(z#݂FL$\kB7ɛtcMDzQ|Mƫoy])2^#5T`FSB1UɤD ^_%`y+kǯ#ݨ\BQ *gBO7R_z-d-\$RF™ɝ#f(?:CQZ*jyH٩vr2CZq hmMkIt˺";JjWdz,m 3ݐc,9lZ5&0p>ยs]I\_< n]ѝi+--*/*X]hAi}kDspF{Rq:)s#w^ߏleѧߞt+l7 0mɿr>2K7X=xL7{3*z\.-AG"<0MuFUѵP XCϰB+ߎZy J31rj}a̦JdA8&ܯM:"ѫuM::Y6e*~F<t0f O!ȱ,<Tr!ѹ1d\[ĵ  G飱! b6Z#4bQPhⅱ.De WGT8v"&v$V8R8>O`@4NH&P6F'ᡊt/ ax»?`H"/A!#s4b8=MO 9643qʺ,3!Cc,=G_ @.=.D 腅&^7?)OI2ES6Y*f^Rr6 Hw "4NCAZY?3S&qYHBsT aAUqܐ)SBz' '#*R!NJ-zKb4 "Y0Tl[fאPΛс*lņBidXrr<󽠂 2LɆ"܉A;' J~B&k6 V=.aϳ3;&`ͻͻi;;㙗4է`)يQHq![UIf 'O|S5)L9[E."O|W\1)9[#9Ty˘Ia*q,s1\Y/):G8ҹNT牭&J_!(҉bS{h>Vc\ 1LY5UI1*AiSQ$20=g\#Kcl@V VNkÛssT{Ke킦XM{K5z"rKexěT ĥ)`>U/] ;k+'IJ-)xR퉜O*1*Qff^ |[}x%a+6aTUlc^a },Ǯ[ DEk+*ʁtkoun`j LuH"ݺzr~mqn[[wBqnKΦ59`/x`n2Ik~h%͜Ev %`+`ec%Ln1W w &C+\c:-\? Odhe?f]ґRCa%߉7uU\E\#IsEmaCר/2KuP]&Vqػo%K3frUa>*{t(݅$M$prl2*[(#eI0)|_i,K++[6YxHy,?o+q)q N#8%9髮s(Nd[e),D!{oy x2DlDdOF^Լub)r&/n(n!43*~. KY {²\{PͰD RG=UvB 8c༞j/Uɠ'h#yT6*?n*!Ia`OId϶iUhނ*VmP'n 8>i>8<:D|dȷ:=G:jNbHtt'qY+r]!VȢY ,ustbQ%dQd)X D %6Kr<9Njc 92 SpYSZbNNw[I mRP4HMWHL(i - ':xM@jwtgI!=#Z -1$˱UbzCUHvb-*{Y_Yz@f^AqXƆ\f0 ë*&"~41۟s-su]cݛHֽ`J{ɚ72c~& (3!eDiFIF;l5@T4ln՘Y['MRU7Xté/' ]0& p,N u;b4u% ]RFdf:iƔ 22&m@55RQU^]`},^ZuK U2nw L|wSF4`; lƆGmYHqH$3ZF1^̗/GkF2Nt{|<zC= yiR3`z7IO7ppy>f'K1cѰ?Ri /ɈA9.jvDw< su(6S{fCN7P@A6 (`D RF3N*PCnKUJ6\O#:0}H P3Y!Y')ej21a ̕:,fT8HM a,ւ>(-EXL_fL [[R6ǚQG7ۺ,Ӕ;`*rߊthS~K99ɫɦD:G+/(9` X{\a _: ~c+d |?DR^o_pwN/Llm2RUQuj-cb_ ʗL֟Or 6^Ga2T\PsQx~՗7NG|N-SZ_-܈}l/ orsv@Jn.d̢\uȆǻyvSYn ~$O>g?}u5Z^k?,;q. 圉]kn܄ ge١җ 1Ԝԃ~u9t{Y{teEg4\/fϯ3`I2z'%OC9{eiO'(0-Pjwז#Fio> WdSkFRQ9#4#=kvm|v/yG@ auj8 k#E#}vP.Ev_IZn]a8VG=CoO:T0E fqc؀rUpy5*LnI!Әi0VYijHiZ=;'7BxĕӴ_>]"ӵ͖-ƳjKjE]gK4ی+o!@NpVh)/ eCe fA f M$39VVqAxly#dۉ2#3 %S%IǑ9OxF@w1xHPt\hGJ/tgc*P'xg-I ǾAR3>ޔ<݇Kq.!; l:#iDAt$ϻs-#~<J X6-ӂi5+!CL `Kz¶h)4G?".]t$2݋ f\1]'5`.}H%?v.2enԇ1)-WPKǷDN@K#A PyF7Ef3rd3 ;u?Ҙ2 -Nj\f-epQvF3$o)̯ ξNw([v?TĄDͺh=*qF%Nfv: UShFCseE k:貓HNr2a2pr;j^~)ɫj\#؍R27 bzH%#|H-tkE ^ثU;/ Q)%V`!^٨%,,.bL[k͔FkH 1|Q%敢nАVĺދQ52Yw-{~׈N xkKxmį121 G619ckM~34"jU80*?h:aTpN4ouN]W02]2b:zV R hBלPBwQox}|u7YK4~4(뤲rX1=m[y'ueE3= CS%eJi[h Ul"K%ijZKޣQ*DY us2-+fM\Vk!X& Iu\T?|yc`$IGI郯ʭΤmQF thViqr)ʊJDY>{6[i͐.1/]e`XZږր6z ҂ҥ햓^:qO]\ ï%KwO]q$l U;rhui.|qn M:@} ԧdRf<%@SKd ϥ $~NaB. }B42q| êU"r -]M,~]>nGrᎾ,;}'Ϳ`ť" J6FbVh6$xG7/>L3ۿjI~q,ńA0 }ПPۏg)]ѐ1 F% v=wg1>ܞ/RKonoQoȑ(!%Ж}AEpq޲URSĽL'Ԋ|/%_{fju#r U"4ycJrgǿ^OǗ'g ~#o+쳛>8G#@Pc$r=\'cerM#HsI ^f{ϖMjZSgjuk-*+*`(_݆ݷ1*k%vcA加Ь>$W.D)_ N;,j%ɵ-cy/c v" r"Xtjr$"9Rm'YA2UV*yE"—Vj3{RB>tDc9kHk]ԍ ve]PpvR+7yAӹWKJ]r'8トԳ2~/j*er xe뱕{hRݥ3yqڑ o1AN@2q|QdV72+}GN*ƴ(%?¢xair\nyףf< EktH=) .K ZϒpoVz%G ?ɯX8:)_"(I`((8Ƙ(VKFj6'YH!VU4B$.a䕷zjlѴrnߘp4os.Qۃ<˄ B!kߞmC!N8 8>ByӜG VP奇r#~M8<OOp\~H> N cF5[; nDce zk~pN}c<2}:pd؂ )&ξ5sBʧܥO;&{Օ~A WK yMK&&o'D$n9c{W/B}7_dɃ@"oE CuEufxA4jTn,-5Fl0JGu)MH{}4+Mlʱk7[o߆|&;=C$;1%ޘ &NoLqb/طl]ӵJrVv*|XO&Xnkו&UNMTgu)^ 㵵|?=MRũVoc-+ {\:M%.Jf7$ת`˓Gݨcuuk&l4^۸q5{Ik$I=FTr+T>|V뇃xO6o)#ԝyU8@î|[ Zh@FRcfo56JL]u40B،{=BvK2^B@O_CƓfMqwR5JOg'g1&>CY; &PPܤ : Lfw~"h_p2%S O,1ӵ" u**Z(i~Lj0d<,=$܅ITT!h6Dâ&}Y%[Х̽n"<*8;pdwo܋N'WOBbLQ^NVa&\ qvɭ]98n9*^7}J ဆ߸aja;ṣ7A*BQi~Òn޸Ӊ֦pj.ܩ5,v,fEpP^yP6`k.E\bu]xdi }zRC9I#j#4&}xMez<?4.k'D{ln;U%Y{qlmsί:Hw{ʱ3obglgz*U.ZmMˢBRNk / $%LG$|.S%w6~=|VByAI wvz4mCeʥOzi hYr^'+g5Id .e;G=W6N\ } ~FFv()$>0XǶ#iw쑑6UٍڣV>D$O{T<@%Fox_!=IIX?"Tr8}6w4}2Д]D Nnctr,3ҕrbpfBݠJ7LnUu#qu 5b2 R^ eUz!STS  I-E"D5 ;kI闛hۉPEQb+SU3#(\NQuO͇$ UI%|P|>V"qUa(:b XU k.d2PHʫ$GJG>˜(PDUŸFJkҫJ/Ay/a5[4}Š(ϩH;,%8&Ua*цYq=ʔ=JWՍMvmA&WPI6|aDiL*Tͪh44NMSȏ.ߍTנ\C-±22S`,c(S)KT Ba5+ӈ6DbQ†ͬ.B?հ9P'/l^Ir %p"`_%uecW&Nݍ /f{ B{=y;|{wz|.fc:- &ܻ B?{+k. ?1aonV\>dagDYr֏{Xu|:K}?g"Xm!rk[5uϵZKk5@Qr$uEY]μ[/ݛ  4 * WH%b~F=) $^t`SSN͢)Zׇ«2@|7 ϴ_//>0䃄x?a 8ژZv.@7Q|""DJRTM_} ⚰6Q炌O;`݋>do>࿙}G EVa䫘joK! B0LA霢aM)A-~p6^Rp7/.O.V88Uk)|ǷҔ+{w?;~* >%VB4G kkL10Al 9&B&ifoTohB,#!bE9-\ ěM2V6P ['Pғ<~I~^((O1nC Cq.癩*-!Ȧrs"!љ:ke=EcXGŧ" (:B\*(RI!DU6$q舣BƹKWs|NtL3&5 trv >>,AΨv Qj%js#c-!*p);9":]z]cJ!}!y}ky篭{;0 `K|~~HTehi Kmbr. i"S+G("y2ɝ4^JpNhQBlg$mDE$qɅNՉ(4%,Nlxe2;4|YFҖ\666a;VѰg@6rJ N `P66r\F\nps5dBc݄$MP`u&5BW&;1D5V/nfآO~C,(ә'8 Բȶ=74_ nlh%Cl@рb/VA_Qx50,껰=LסN^j.'8}Tqyz$ 1,sON`=eH 𲎺;O#O%y.1D"##| Iz\IVo©wBxǀI57dzRy,C~a4P+`I&mfІk6[qȷ.% %HB<.Ñvo'(U蒭|TLEמ/|pb󌐓cNgs:XhqnXEEq4)i"9:IԬ ,dhJ!evX Nm86J{mTBվ N*4)ZKwW[b=j3Mfe qETÊ3 ް4P_MdM H*gF2QO4Nn'^.`#e83J X,ZO)#ЋoZzP5 frf2p˨1i\u,};Uw$C2M%0BSG/xP#˶\utJA?we7[ΜsSX:M\"*E>=pfAA:WXx!~_._|8.“V}|D_) / .]=_;oSٜ@JqNQB0^>hD@Ҥ sgg Ѡp)d`bC7%,6Brk 13q ELsçL6B,h=*IJ+ؔ[n+=v,m+G#ug=A9_GcXcDzDρWft#*ġôSm R)0$8D!F[4S"q;܉vlȹ;"|L kjͬ]+0X:Wy< #oK-]gb Awѭ@jxUZC:֐klxziĄ^fAv~~pV60 Y)4u_8F1*Q~1^i8븬ĮT)+L df"*H5t.j(X #4,LհQXXW~o|^Y&4 IY^.g 7T:R -vp7l#~S蛣<\nZ(feNU[֌LNZ .D)AX=MJNRIv$e6N5l%cw]`2k5n7", fZr$6.+7hj~v,㰲{n"6aS,NHAi}{I}kAI SVaI`VfJ,o AbyCvy/#3Z$3p1GPWzJz ;wV*t6nt+_sW9m?,Ϟ\؇+ki{䑒/jf PÀ H< 8H}D_ wЃ5uAP=*8s6U `n"H/BKNv$0?^.·Wc5KU9#3x $o$hN:l -0<8L&z8L qiRCt37qI?r),pakҊ7vT8 P (8&w@-P- W:V*/T. ƀʐ1㞓:tglTMvb|c >,AA!wO9v.:ss˪r>d4nd `gٔR]3cs`ip<]8$L}sD>cOjIJfO2)&:$f$E OoLBd'Eڃ^%߲%rhNbiİ^~&FRQ$B͝jWX׀Jo9rt1s*H U0MWl(e-Z:Da%F٥=OlN({FSj31eo_>c_[GvG&Qn?Z4KYXc`)aXIaR:6Ce4P&\EW l~:X&W#PݙZLn' }[5aQEf3k^GK"cn5bؙ5/LĜI7uێkdҥ'c³Ym`T@odǭ HRX^&XhPF=vKi3EniEwTI nRnl܈CSUaC[#Ě<% o޻ rWy|\xzb m>]H\"=YaYҼآ2aa" Պkش[2OU[HCNzd%jw'y:܊T$|\a  uy8[|3)Jiei1\~&ki RqX`maQ0@OsoImrԴqj4J67~vbasH+̆ҎYivXtPh*vwo0z)a5h*2fLd]͘f>4W:DeDٴ*_]J4KEoCsx4Л@fz Je,]q)i??V'[7{YIo yXK%BnrD(8즸!T%f~"m6q!H 􁍼˹__#Ԉ.V]"*ΜةՇA[ݍ<ᯉx3ej#ߌȬR#lS^QET$ױe3-)[JK"(Qc3bMh|)Z l T`53YXO^WUF^,jFz:Oҍ tt dt#6,MK!Xwvbﮠ aɋBfb~Ox>r *.OH{#Ox7?1`ØҸYx2t=rOGbZx!{`SApg_ߞ&a$z),IL!eU,M 7v"|FV"V!hv#h^0DG {tZhYrAV$I*9Iң {Ќ ~[.ĕ=rSɧPTI@h#ѓ"| (wJ8kAvq qCwLx.Ggܦ ?&al$"faGM*ҳC9^.·Wc5KU9-Dľ~wp_B~qPh8[)x6#tf qIZO M|{F'bÅF}$ip?r),gs}ĉ*xm ~TYY9<- [T @_FOAXyCeȘqX!EAwPu7U( EnDG=>۹%χ>, ;w޺<= b:Ț"UoTa1Dw!wN&Fm~[Ky ]E.&@9?荚ĸhI6mM7A7t߆o>gRݠbZ~T+2/xEt7-E]{e"U%kw17=*K]8Jq'}!&9¬|Ȥ' 5ͻ,5i)ؤ3N(AɅ-\!52^ƹ%-v4='xqVŧ1;^ /2R4ÔlVs lIYҌ?` |YO |;HC/?cס8zFWPR}Qv=v]Sshne~$˧ D>.Ǜtd5Z*kCSHV 鴊ǕX9N_ۭ;Z5 U־ZU]Bi.!9ܿfsX!FjIHteWXc q`ۡ)[`H\\bM@Uv S[sfn7*nC}Ac l-yw}2ܴjI˃jpai+~SQ-$< iZa1MfVܴ;$K+?Gx+˕5(|9]XSƇ{G+~k3IܱD7Q_N5Gp1,.d֢(9h "!ĉ;k;l|v.uJlYCd\8_Uu1 e,ՌX l^[NIMKYε5@掉;p50mv~JzԞŒ[E47{;Oioܪ,$s!e]XFM;ܭ4㦰Iˆޭ_ogw09R%ʞvIpz^܃Ek.;0cwě@Xr+yRocnΝ#.;0ޜXå=k;/ W@@-ԄŎgݽ[Y{p?;{|L kAoaugks s};6z ; 6>v<.J'Wgțĕ6?mp:'}p'Si=سY7!2[drI&? |g3#s0(ƺFGgk)NO~2Ńyaaϳ=쭵ݚVw|]dADŽ,VwUkHTb~D_`> ҘU܂_鏟y ]}9pqu%buv&(}+F rz"ˣ^ 0]mL|2T#CGLj rOFE_@N$ ex,6%,pA#)ځ0kL7<>[ψ ú[ 5Z?Xa'5Xk$=Z%Y5Pp3$| + Kqcl^bs|$0;:r2Y/stm(<')=m4 ΀ `Ҧ}%G09(,nIcsc >1HX$/T1G9,tRNjj8mYJFKIu.2.x_wK2\Ũ?H{Ķ,E;kFXXhh50јeCNs!qP9D3,bu{4Qqߵfo-?:DpIcn7 %oR zO j"zeMTPNFVi&(;wF[diJ7ʄo.i<tH֬[˪ Uc_nc^x ]|<\|>}x68›7Q=C̺$y]^|M})06sՄG6(pcD:; h^ puaYn(Zm^w;RSzGjEhG78ѧ_RRm_Y p Wrg?>\ڏ |+Zo)nw}lţ>?k>G@t.>}> CNE:UZu/";(R]Wh7hjë(Wt|^~t(\Q]GQ q8O?w\7u "~PΑ= EU!(p]w;8D{Q$Tn&F'~ ?r2%R1E@e~5!8g|HO[ {(<(rA/L/W:d]y'HR-kC&1u]iUD+ =)k">BԤǾP5CР\)iHEA-0U^Kdz.= W+|z4QY" g赈u0Б$!B:QYy@C*"N ^Oqɛ@*UL~a/czY}G/{*}N_[h^ꜘg&#+( BL.؄H4}J<"U0qNDidg]zpG `Hn ߝf񐍄u6ȴUMxₔ&;dB!0 HV1y~9BMмZѹK9+ &ť^H*nddg!I-YBnw! Y'EXF2N眎e?DMNʽl2XS׆,Y N  PFoмE-ga?8`0(UA!Io2 'rR:*nSЭYO6 ;0qB* 5KmTlVObfCCQnkxД hyXӄK(SGN nWo൵r;ҮH;Kl[sq4hBK|,l `w!'R$2xy~M61OanR;H*#EI6&U)P*;uȩv%eNKggT*%J GI 죪2AI3hoא4x)vb s )yr&<ޙ'-2 SDb`r][8b1rsK~Tr @{{hEǺЂ=p&.О0 {[u?f: {(5'86S뤍WFrna3s<8V+ά!#E>;+6yc1iaȣ^Ofrе}CXvxLBh_ I)gq86vT2 raAOjnYK}gFMZ߭l&dDZ§2)ib*Rpx$a;-ƍD@Yra{>IK'cfG;l>bmQQG# 7`C>lafB DrQXT:hNFT1%aY(݋ Zq|1딌{Y<›!G*U~ R _0 y\z8&i[۳\q(;~.1kЪ* ò2>v '(3v b'Ʉ|fχ%c>%4@Ě=Z!\ǝs3lvd4b"yDd#-<1RCuܔft!)"0aB؂wē? xtk[Qۻ \G0`o0)jl1я̤sR={'w11/N":}BН/.dO0-j)XCV^po0KHnLBEzz儼9| m3p_t?:cܸI1\=T3@}j1[4A"SmzʳѼ7id ]\BA20!L]LR684̵sz Lu?qm'/!P 3ueˆٴʼnt zUN1Ͷ0Ϳ]^|x$)Xh"6/#J=*W3 l"XlAZ6RDj4O1R7OpvX$#l@?e҂<(;#.LGռx.~?J\d2- ,2ص6$2/8䒛x\L"gA"#̲ Ѷtrğ|X+C30-S<>COv{gOR6|Sa&B{,t܍q` ad4u.%8x8Y˲bw@ňA$7%~^(-%i9*bi{n;v,S;&/)pDQ֒ɋ(mH(qh"X K&M\'r,5FBfs)?>=lI4xA1d *J:\$4%Dp8zmW_u2lhWK5pK6VT9\;dC>Z)2nBDnSo_{Tdab%USX8]tkoB៳!=y@Zݸjtq3e|30!8BQtN/O*ɈkYT';>5${yAi 8 >i B 4J9MI&DgIԳ M VzŬd_ݴ<H4Q5#KBI b$F+COe~ߜ,-;qBF 7p 4P|(A53F8g/!]cA9G\1~uf3S[el<]aX~ W" |7ybbN矵ҚgST ~/':,8Q!cR.r M&uTKګ[UoIT˙.#Ӆ|.JZ#5㞄 t]xԐ# } ={ V-q!ymNsZK]oFЙ;tJvf kʗ],t?OȊcF0ʷ-9txz{{|Z0mIr5bl{aDk;4 yٴЙD?ǁK ų!9L41Wfh{0E5$9 X/\a.4p#DU1.l渆rvwgb ]"z)yt0QuDHbMۏ$]⯮TXmei.(M%EYv!n[EkaeDN!UXy_ˠGJ2+xNe yf[v:SqbG|hur "\jz$܄vb uoM!cKK؊F3@%*\(טOu$*sjvV5;ṳy .;F@JS )L 1Y~\q L<φ ҹWg'upqo GguBP ɴ;0q6.ٕuVG$BwLPNW33a[w$(ٙ5)팠}Agb3QϢ O\,?ĭLOTD]'2Y\:2XC`ԕGq'tO,Q NPB PVO*_F4\s1!ü\X.%}!a1Y҆ڵV\.ǰmp-ctwI4)@CM]UQ!+E>2װiT]MKrM5*zCߒ|phaśV6P)e@c-GlgP8uq#F䌓NJ(sc븹>,6M29sDS Or[K-D"@_υbNװbEbW3ŷZHT nijȫOS+Tmo !b*Ȱm]*6+7]!J/QaМvxN)FƑ5X.o`}[Z)н{<"FpcP69OU%`.=w ĵih]~G><d㎱KNʷVs˝kh5E!D}tTtpshՁDAT pFU(_|8Gs\.3Q8]n5&R)zS- $^}>;v@@[c/}}kac 1bq\ʯ!l./a[2D!JHTd˛|khXQ=oc?3-Ǘ,yl|]ƕdcxvLgW'gQ(gw׋G iQ&6ԧgfbj-[τ_dYlO:  I} !p;-XAwE'Ȼ/uQ܆Z6UL /L*mM#U2–k˵d_#z<(1@[v˔]%VZ(ZiBb!.Oo :|= J᝹e0駝4f-ʤah;kVԾ}+?·A6꓏[oKp[jLH1m14WľO}mCsV@r$}n;ˀCMUGO!0̈^ kjOKYZ{CzB3*E~kk*HîPȷeWhNR0i |dW֞[Ma!fmaZ:V'wZv|a=sǜ^zXoɱ4o3 i((̞ KGFؐU&eϙ\0tC\cE7{J5sŢn 5ŢSJhU1YBB.|TW VMI|ՂB&sz"iط Yq]PȜ8 cY$yL;|:jjU^ņ< Wv1`QXQ Cq`3Tlb3&Zb!̵U-oNʿZ.gqіamTWHXގj[l<~ oPA/Q柕[]Ab׃9 bu|v2Q0z-~ %.I m? "E5PAxyXWƎbrpXgnXh]8䂭fq49AT)*|W4xlrqyzv v堇!-% RO1!xM2kWxhÌAS0B>*f>؟h|EHyk2uGx(5I`Mخ 菆\F(w/::!]O2\qK0[GWyuOH|닧][, [ cآm"3rgNe #e (Di,Ba;eA0yO-ܹSJΞvʥ{U\b3fƢfqڊ&J;KxqkWmSoW?@z!ϝcsAոjv5+1g wg~RG:TS4̗7k{6 3P*60r^x^sf˅%ALMZoؔפ&e7 T-b+G/0 Oa3]gsRWs\t~ul gKcF7#ͯ(u1UvH 4:Qfʌ\.a|}euGWǏAN'9l:de>;V&{YqS^6*_?4J ~%iEG";ؠ7ֆȓD;8ļ?I߂|,(fF'}1:~G]vwo ~m>Pf` ܥm,EU5U=- Rk6nAb%ە'\eEYqdx: 1X= |"A9X4l5/~o26;Mq[:G˾Heg6è{&<0m3ZS[m-G %l,αVOO>>L9QkyiAd$8@Z̷بh!s?ldعվvI}W 5vq]vE;6Ͼ(@롈+ Ng߲NVV:i10.iw 8_[ iB{RPAs&]7 _oviQ˷ adj.9auI6 Ay mJy=J'(]%dmr;v27EKQwZ$`iӟq-77Ip'Ժ 6=*zF|<t<{yjyMx'BŝCzԊt*#ճ|3X1*ڣcU S%S+}!ҚF/j {4`:h;8ͶG eSMPplK[>{B6M< rNmOw&HWTHM!DX횧v0i TM<\+ ¥/UB~< ilR96ݪY8)uH[j&ixipi|#LqBSl2V+mRDpU`"Pc q[%+Qc*!}Ɔi; =_IU2D0ŕ1;}RMD\VRjg&'j*{{r{vN&}xpV=&hr)FV99J \)MdZE 0 `q* &ҖLH57SZ ز;h9rvvl;z+N Dˎ (ػEһ>9usk; l\^͞{k˅X;s,=`e>ݍ z rI_G{Gt/*!{ *? wpŽK8H3'=Ό&P6J\g{z@~\N%F-(1wfQ76M ],c;X%n]Y|?|eREgFH28l"0R oP7yL/pP&@-(!^"EÀrIq4 Brd}yktD!޾]9p!p<Z/аdw1IT݁(MXf8% .HY#D=k'!dEpq o\vJ#0009ahZkt'b+~}8 oIZP@Wwai|(Ob`JD> SOW@4<*v93$NXJ~d쯾|RCIX#Zc[JXQ۫;:ns>w9GX=lˋ/a DtFLuB纓UY$H47<$5NdΎZ DTy I0HHR*v&r,ЀZB<'_,QS_%"%`UZʀ;|p ƈw|xqX|8` w5|^>Z9F4ׇF swl=kӤ]HY=Mc&2 r?CWB"y5\|V0>l_6 iPF7 Q얔n^62e^G jYua$%h >(S"Q<"t(<ɱjg} 9_[sZ||4侳. w|tof\EİAUaN؆d4\?uftM `A,+f+-lF{Qє쿀1uulБfmޗ/+tuguu$B`G7EBE`SXXF$5> v9iavhfw^/_)~lb%7|&yh]ɜ4!mP?pNwq| kՀCcό?. ­dAj݂w"H*CfMpzi(N:BdUA&dxbad"<=m$LmyNIX|\UeQU9lӒnۂ#Xެ=4 "h;焺"Z'ó4> )=1.wŠGWFƙW]gx3?AL|x,"P ߴ,b=CneB웑t79w|K.` 6H0JYQUd=,Cw;M#0qK`ܳx XlX5U&ºl|AN~Ֆr]^ XE:+k9%`۫bȶ~IȥBbB^PpqRFX ^_"S{sˋT1G'E B ⭇y;VSOrureNܙQ%mYeJJ% N3`U<*?g3q|ݶA4\Gpk뇖D`fPx z5+fS g6pLj!B32Y)[vōOePBr화Ť ޗ=k+Ez.W)6Lkt]|Aty1р: P8a)jψ>fG2Ry *6mw1OFҥ.ǯFAG0\51L|APd_7c$x ƉÅ(_(#{gA/o1| ԥ5ñ 5 (9,8b_(_G:QsRfC1 (E9gΥjΑ2Q9g]S B\I3~Up$L (iv^&]H#||\1ReHY=XV'沺weIQ Jz3 JJ: a<ڹ\ 1UR <; A  a_T]w32 r_lSe DMP^a<=+ 'Sʻs =s+ʱZiFPɉO<<忺Mzd'5(1e }v27^+4{ϥ0z aV|A`9'bMj J&z;d#d*j/Z5W_d /+ضC#$xW_^6kъᴑl9yV@[#ZzJ2ZXݜš0|k{MKj1c ǽ<K/}փ; t%6^Zb^ExF}N\0l \vCT2!7d, z7o$' Tv[g?f |UE d0> D~5uOo|wc2fsXmy`p"$Z\4,'_Evb[˳"7~ Y~?XgB|x ~ 嗳,q_9WAIJ9*':֔NQWj 3H2uw9&&@U.GIN\ dՁj%($àhi6@WGlWܕl|8h#G9T2?2hu/T$K@]gmqrTc`|"T$Qfk3ꌤ>#]-.KTj$uqӱ2HCN̍\ۄj^+)F"%CW"w:`\:f"s`l@d-KZK^jKbjS &lo49)e.Nvuٶ@'(T1 2pc?sT:rdAK ֵCX%uŸ؝d4!@xbg z4c)̧0Z+'ZL[wQћ~-,j.f8µhJ] 0vu;5ՐZ/SrƔ nۨ׉\ոH<:d7;wDЗO|T)M}Q1S6Bw։?5?opg&%ŏV$8W3Ȧ@Г;疻GLyA~܏gO Ʉ4&)aZ?8+;B_q]&#%Ă!< qX.i.$T(H%Qm=-ދ!Ch1Dc"y)J0}TGI5p.Vw8`C0n.IڇEdz_ŗH5<0aJhI\ smX'U!&sDV'kkOAH-{xn',By1o*h4#XAE7<+֖L᪚]ufvyVkPԸ+q݌ pG,5O,b dF, ~ˆB>9eIo`ωhp6>jDL?}8l /5<Us_@_XOpYO:XI~m/ fMtѨEdJX⽤4/ixs_<"w/Bn@:Hy!%Ҹ@hdܻ_Ep?1<!/{.2\Gn}ĭWGNH6-IT2k|Aq34wȢ$] Z7k68ݗKUqnE*H"S#K|ztWޗu!̩:de:bc4w1HP(< buTb~;Ca`2n/ +F1$ .YP]۟=e]}M9! _t,SѴLijv68Vs2Qe,tFfʣdwKbwέy!!&}d5!\0E)isa%nkW. "Θea-#rɊ Ƞ#}>RpULd=4Y²86TJzSg|u'܏ÊO}Ba~#%s"{^D3䟆yVj׋:rȥZ#%3Zԍ_ӢM_P'^4 (C*TѤ,lSp(0c0 ( ;&2@Gtv7OU'1MeaD4P8`}zFcp8oxc4<-7Aj+I|tv OO/Ϯ2dXT\pTL6L#>)'Ԁ\ȫ%yM` >XɞɑN57ɉ1չN2AY -Gh2.Z,E&jD+L./)v<;a~ Yʑ@`?IR8֏n!6ԓ)B,PNKkqN8 d72 %5N9 !Z6[_15@ ,7lWq˃؉MV> ;qffrj__ȋFX `*`Xl-HR}W{WE7J)]K!o(-dI* ^i%sTeCh0Z IGrf``OK (g{I,(x %Y.;^b@ҀPX5_\ ;<)v2RypF.{12QW);'Qf֥~Z $'ÿmUʺ5Q`ť]J{iJ%>raA8V`nY,GhZz@51.f{\. pPN>*N𨂏ֳ=dFz >Hܹ( [qQ|KRAQ+\ߧXvֶpb܎g8>܁ϸFS-jd 99:# q>ňQ;}B*}p(rF7(m8%W(/j x%%xogW'eBnh ^@F/p`ĉhk8- \њk?ë}6/-AwK7vOҧU$8!4 BӀ̧&187o>C>])m]a+kPǏ #@>HMp<ayx~HEG1K =^Omn5 q56B:<}x7~mx?b=O%{"C_"gmKJz-<)ߎ?9zf19O{AcވH"TWD!(ݻ@|`a qBŽϤz z$ՓTXy=p̄8֋4.?xD2PD/ݼ>_@OdzEq ߅z((wT-;<[(UBm6c5,~ ޙ|uƺD{\'!x>o,,;K&e\XjG8 ͑Hg_9%ͪEݶ|B-vϪ7T%ոT%KmkñFW$Q/$D"|$JFNSn1*57d8w/$(8q=󨬪p3#j(샴אE9y( o2WwI~^~exABPp\Do߃pEfƷBZwguCyXcmVeͤ~$uCs*Kj9]\Q3 L P&^?kUT9Zwf |;R8XзM/JoUp 4)v.2!)}Xv un~$?.i'&k] E EOXd(b'4J"#=K.1A2닙`*1sV-+b>+6䵁uAc]IAZˌ֮\"1U1ˉ,ҔmerǣS?9zKغ m Z4h񻢱REc F/Y N]6/אHHNF`jhUH?Qj8FI#gD~Gx?-6@޵6@hm 6fJ!6FV$B ౡS$lKc h5,{51mFd|Y^/wPlCS1eX͢@ dzbx~{_Abm2MSd{A[> ݫmNkf\&K}E^i i:ͯI/Knwq.d^܀ X+p~/9V;ZrnS!{ Q vA8w_ 4m"Jw-S)mg兊-8IѶ$$LÂi iX\ @$#<8XNq=_M$G%՜IXWbJ,^IJ觸n2]ĄZx bQ,9|AizpJfit@D"pY- I1Ͳk~Pcذ1g Θ/jFk8(;WAW Ti"3fCKE/U9>܎9'l63HKr7q[YY\_fșYX)/=E,[ RXK\R-Lpd,0RE2bƔZ_f̎}jrL?ZmpATW CK!bFǐx]ȘX+%ˇa$h_s栗 i[ % U9>[xW|`į_1ǹn5,M6⍄ƲjO:? 4!%?{*( w9YåO4?w%.@|~T[p?~!>n v9O򈒚I[Zwo{=@~{(=oOUW|+лr,ht!-(d5^FaqAp<#SZygDh#HzlPtmTN<(ς%9CޖwJ"J HD#w0oH~{,=Q|NWq_4Di߲Hsid.IHvhGcTt1Psv~}:= I0Ҟ9O9Ovs=uh77inPvs#͍uh77iqWCkfS͞Y'/oM;3XndS)LV=!I$e*vB/aOD!` cĿ8*E,KYaYwՋn٣KuǬ'MwAf7~Cu- Օ Ruu[F-ͩN~Sov84e}IXfҮS'NqvjsNQMeUU(7+>K)Zz"봝:9[ZO҇VIZz-I͞ Xmhi.Na8w! 3OtfcrGZrpLzAtL xL^$iP6. YM3]Kc> 0굽414Y%##4f,|ܵ4VӸoƌaҘ?0BcҘ_ʊwo_\w2Yd؝TEpBp̌4YIxk< r*;̩WpR? DzC(OP2,%=s6^-Oz`A-HASɹI"i~s7j;o/Ҁ@x"́a.G}XiqX l>. 6>\ia3t>t0`rVGȀW Xx"{ຐe;`bRl^[%2ښIإ^5J48H:%lzdTo|/ze)~3n δ~nǡv9W =Gޚ׳TL) ( O1VHB5!̳ iGV=L3- hbTl.N=71/:fc%g\)a{ث /Th;?{^=:G|pVΩ?RzE0CJ"ӧKoGPa_<}7K܃fkx]Თ2?pjeW[sF^p^!![G!I] /ȹ?"o|򐴭l?X~ ?r*λ_e\pEºkısY=~/8u+W 5ƨj0p d`%8:<*ٝ:΁9:WN:''pAjۅW W7_N u>F{+%ŤIJg;E#_wvڷ\nK[CF2ժnDQRDZ<^e+%sߐy(%(`6JǖNi8<`mNK1$WēOX`aV>GӮ5ҭxyy8nUYarIYI>ZLOz. u#%oa6)OM4MGlƲ|GE}X*)?-rhgZk]YGC^oTE!jnz!Z)7JGT_17/>k˰6r1k*l7^Rz5P[H& 9h)XnZޫ$9+ߞ-dm AD7LbtK 4b'LAln2pHnqH=yO|Ox$zFnHޱsCp#H1ް 󄎲Os<I2.f ʧc~Z͜ˍXQ\_Ηz⯗9IOŌw:-W,aGAo&$ByLb°W>I*Fcq©H7QQ9؍7􋣗h Ҕ[_-3E㈁  Ǟ÷/ _ ;c!j%_?#yqɘb pRb eH6@,<\ w O9Fvw.f6swx*9N~9N9@}89z] 0ܿOr(8>P3(P=ofcu#${QB#0e Z%uO[48ۉYہTsv.itR r?{`^]D.$SK#DtC_eq?pPȧB`dtRLh!\dZ0mDygW[1%,-ǙRL5A4wf:XC=+ ΁\?zXHoW=ULr{M`6m&@Cƈ!c{H+,MrQWp5^3J%{=LoY-+*&.DV1t󒖏t rFqIK -~Y'Еҗg)qI_@,7h?>.%czZox\|jpO`^ LX(;@[zlczzH`4ĽtN$/gJGT_fD/Se$+>/)qs Ϡg3~<5g'L 03ӾȘbܚ':x`^%LE9Q3-s`ʫߴ+_qf~;*zf>|[t0GzĿ&5}lÇ s#qjËy8]}!Ol=XWmMV]}^5ҷƪ,YJ# ;Mꔰƈ2 ax`^P&.L7OLV%aӕlbebBBjƹ//^Ku]?BK1?QeT[ny \m>! Dzu\@AI@ݒAp`ͫDZS@0 4] ˑKPܾX*Wvζw0X#Amgחg!![40f>|\-g͜; M4t1ℌC s"l$.h'[Yk7(t]:E+OlքDWO֤g5'*rcdM'FdTץ ).D4 9u _DH~a2޷DslKWF 51/P$\;*e zHއѪXoVNgĎrr3$G[_\ؤ;U2W`Qq6XXNySܪIO,G<*9_s[w P6,gS/hhȐͫ- d+C4uD):͵`s"8.I .~ nZ@r߽9l!g eis(\Z t v2ZsC֑b' |RRk)kҚBIAwaBh ,<ZH.vVµOv{u"vQ;r>=(Wt߹z~L]v2A9TVhxG%nO 4YfӜH f8|{ᐕu`f˷m=V i2]|DJYmc7>~PX mᦗEFDRi`GȊ19ih_3u+lL<uͅuYmveVfm ׳b&. n M++`3SbmS&G$.0*(s >E8OĢߥhfE;>3!ine1Wpm,G?uo븣o7~4&k*Bӆ !Nt WϾ]ā۷W-l=nn3,5TO,v.9Sp?"%{ra9 6@;؟?gnz&W>37` T>L=.?+3O@f$5^\Oo׫%pn٪yӈX3&}A #@~y 8?sv*A}G;1NjnZztK!ŋ.ifX|?-7W` }TU.7>/* 'ɇ$.ruL'e{ܒWl- +Eg?^ !J &(nCx*1߻>>5"m%xbG)h&J$/ॕ00V#t̶hb:)P?>tXV-ƪ/3e\^Q~ZP7(BnsT(^7s7)j^}$UA -!yzOg3^}7A|%G5reZ$6u2ʅ]^*iro:ק5S?.wڟ.1Cj;kKϰXɳ)Xj[U2'λ_i7oW㓚I^ S42x9'PЮ'CdZ_#S}oMoL۴LJpAjm K/Yiާq5_*\ΠLQ,- "tAQ~`?* *IZ~ժe @ϥ7 ѦlJ>G)!W49t+-3wپ# E5X3gY\uP@~hW}ErVB0q.m#P7n6ʈR}B׼WrV`E[7\`8B[ne)B\m 9VEʪH^Nt/,Gܮ4bs&i{y=}7oT6z4@ eO+=?o 6j#Z l$*xjcB20gAe@^WƔ2$= ](o]`66Z4e`\ Mψg-L5IME[&M 0kח&,ɼJ4>e@;H/\Yۙ :dk^E/M"MFk3$^5ajf ;Iu~*bt$ )z7&nkr@u1 K£gyzdF//_s_L./vgV# r"m[(- $ VsMc'unT"gCe_\/>j"`Lf:95R!Hb)W_`S)Ȱ(P0}xoa`9Ŷp.azȊc R?q3QKHlX)j*FYT}Rj[KFQ~[c~y#[j }&` =/Rփ%mOBxoYPФiܤeR x/w*hޡkSCyh ͩ%ʔQxmPy^H֨ṗR16Jd 7Ы"M 7X(#MF_`g?!x<䌍[pplC/yv$|v4)1yj;*Ŏkς Xv< \'% Jן'λ_i:P9CXZH٩ ems!3?XEހݮ1f4onWncRO\E $N<5GLvP4]dehH]fNs RL.c6`JN>ԱJۃ%åɨ(d d┷Bm(qMlp*yp /9ԼwՖivLՀ7ZY8UQEE(z,(``{n|:;E_`@I7;,E .h.Y?jy~^ Sr7.W`WˤᏧi|_Ny~dV|\PDuVůgK@l.'|ʿy7@:|=:<Kg?qw|_a w]2%ww)'N'yrv{1o#w_x]}x'u0寧zO+r #7ckq?tnpGHdO kx蚼C}{L!4) ; i MKs$nx—a+$<䭔e[xɛ$Aή'C%S/n'OϚ;YcEm o2'}i1Ul\ހ48/ 8f*Je4wSk̐9KTh6}THx|FS-kߚWJiSGlNZB$ &[/E4j6U,B0ò;fY`dIȲѾF('ԈQ$<)FX6A0()#PP#5`s4Yz]-l`T_-)ߛ嬱 jSl@h;ͱ٥d8>Ũ.(1vi+IVGҊQ*de1 j<{>]M}hj ȍsҠsDMJPzd,ێ,M>tk9ep~9 C89sZ-ʪടnH2WOt5C p 8 *+"$#?vDVes?T~:Yk5|rj(*2P™,&xj=C #QRO"J*x}7ժ? Syx-͚hWgTZjj^H/՟k.# K!G}$.kL0W7HAf~`C!8lj}“ ga}4>[F.zmYS"߭tWHw+s!c!}#MsfFW͡nO&IR[{޼$”3.Y C}hfg|0cLsT4WAAeľf3vF(,Zv^#@x#fY_[]ZEhR1wfݲW 3ü} ipS! L$V$- BvXP &nbZVٖeuYj^ 7i;il8[Q{m")i[zF#z Y̓EkFfѳ0^,?A,Y=zW's <YTс52YmPp'1T.Gm,V&D8y}q^==~߽E%g}e௧W>%篿8Tט:7¨jF:|QP~l8xP K-yq-}[pK%kLIئ~k[u-@S/Qcs} ;Q`LBV*~#Ĵ/4 8R(,KE[+>OQTğMҋcxczSS"!SViu#>]$'ZdBpu%5̓L5aqd{ Awc6gb9K =&ƬxthSYxꇅ҆\2fIlYE"+IlVA_l.qDVHRxX)%S |sD (û6:?<HH.p<qqj\l7ǙKwԔ aTg[li:;1[TQ=/$*N'N;_n1=*aYc5)egz%>fFѵ1ߍQ](j% +*/J߲ 57d&nh ,yRf&ӳ ']#.;4KLvֱ^D:6/7qglnq]2m,F[6h&" [5{2TU-:|ˠ/t`9-E\j="2NeU,2*9Y[f. Y;C#{;5yA[Xeԩh$jm}nU۩j]޸SͭЉ٣<ƸfN9~?k쬔#ۗOjTҖ?j*mcthQ?,yÒ2~ܦWUl{ޘ,/Gztlӣ#}`}aZay:`;TwZ"1lGK/$ZK@g3DtC0s'䗟N.NËgPV@4_H bX(r2C0,?0;I!~y w%t (E%39C](x ]%Ϙ$ZoP7 cNFO;eRRt7Sȿ xJ;n \"]6)wo\A;qCx3=+Ψo#h/Hm+Q=~| 'pc eQwM~e߆jCy̗>;Y7b1;C"PxWYNS(~Z=`"$Mςi5?owBo -~_D݇ (2 aוZRMYp^^X_q(_bP-N8C)2r&TdQsO\d/^E{LqS7t1y bcleXП?EL3$|zEY)JA\u/Ow<ûZރtw+qSPL,᜜9Ԡ'1!# ڋ=Ⱥ{ID #5\?ώ)迪b4CǮ$E? n96^iL4pѧë?{7 NdP)Kj8mpUmbL2wW:$}_&f)?<8 0{@G2| !+ ~{oX#ň'$^\]tT 84G*u%vǶЈY6ng k/~~s!<٧u~zO6eϠl/ll2?<9ԧVYl@:r^&bGQZtiO!i&t nBt9ғW[V^_ESO IbD7vG a b R)吋͊fND:;MU\6G\i!Mi֡I2U&&p$42QOty{pY$&LJKf󟊰׀[$*H襃fYҵإ0Ar8vT(=/y^ֆb WyΩ&$y}Yw" @%u뻸hUҎ:$ڪFWjGvRQwfwFlt[=d}]ooEj:XN ­KN@mǷqYЛ[VyρP+xuƥGSq3w͢(:v=3@pG=1ƙKYq:t7[Y5~yI蚐*LI{߃#CT65 Oxkm6",v!n?aW-\)Hr+Y>j;bH:HQJQ"W}:{~V]]z2I4Kd.@ߖ?q:N+p$N_͌.N:'$`*W7MUhJMSFUBdR˒P }HTvzL)-_g8}%U.鋝r%K[M"8'?\9矮N.&s~hijgLU}* zaDDw<#%s1Ts̑ǘ!_x)~,G++Xi`4ˮXMXg,?)X~.澫bk`W ӝ_t錆.n6sډQQhKo)fڍ]fZ 9:{ppTb9qbmnHd0!n ,d$yɜ'Z.-"Xmw7:h# 9mXn_;Tg`avT&ͅIJ;QB8@EECeNAX}4gUџ5=?['Ve'$"ÉHHN >eԐ )Byk'{'Do Ev l(K֑0 "4ɤ/ABt+OPDdBuDbGXh] m1CfQU3:kO=$n$IN#IcJ c[PixnG򗡡l̓gt^!Cϕ #c^i239\+j95]GVR),g@َ,h5RQZ͵jƥBݷqe&+Ul)R8fb=˵gv46*aV t5ѻXHp V}rMyk9 PIф8ϣ?><`&3fd$$,ecʠ籦Ά*m ײ=jƽIC9-5[*e=RS#ɠdKM|:r9z4Q_,v|Wv =fӯ| f_BPHH^%|^=p{t;&K%m),`zſv1|W }>Y 0DD(dC$t#.+\dYD9CD"aNCWOpΠF? k@i([ 9s75LGKҶ7ܑkԼWdo\I7锓pRO3*Of+oΥ(wSO|exZkEki+kw&y#2Tt/&yTs~^GqpU|%qb_KQX $<2 zBRpx;|Itw=HE't\ٸqԨ7֜hԝuknJYO4N!i􂇡MyݣXXg,mF7Be?z"o_H6V9O2ߞS͞xy#%%{ z-Rͮ)oC$) =퍌%اR2Hzé#BҎϴz #H'Jϳz$J%O4,yу*Oz"nVzv9!':H!8B4ֵ4˵&G剢sDad%j~ bts'n_̳weM.X"Nu~p6ӿr@S:[^kҠqj34Z$Yba54,;[qPv9i:I=󨬪p3#j(I@=?4~RvBg>!},9h2*{@ve?xݑkzî'Co$&ur omSy$Np 9[l*s&P%hHnT0Iw_uODA)e'&-Yڗwpm8 WGH#eR.L XOLRߢ̲c.@Gqw$:h.=K^3sJ7[s9t-y 7xnw<FD"cHC` >"3Qy|:$A#Kz%:j4BC))Pp pE$D#ǟ m͏,+9"bx,zOdz(.?JݼfԆ,L dhUHAwAXc_RTN#E_ΜwNK#Z1*jcm̢Y16f,,C =6ІCzhC5zbCm =4zIeltN,X>>цt2w ?LQ`02#H-IKG#ؠA9&4U9h&e9Bv)@-S R4I~eH m(X">JC;M XT5VцY0kfmf]bNr?^imI<]h77ϲlZ$ kI[ ,JnAo2xԓ3_tr!K*`cƱנ NTYI YFkIZcNmM kZ#Ѳ-9-%aoaXH6 Iaf)%z w8D=9N_ g!30K"0R34N3\9LIA RuW6,PJye D!b:X<&x^('J ZZ0)I,XKi$XE9i5 [w`δ:j1TłXP bAU,U*TłXP n2 b!U2fE8xc*չI]1!)o*tf*;@HhZMT3NҖE4%2FLg**UV(xB2^rnV:<] 6Bݎl8|4pLE ൘H#䄡`/6Y}<Ȑ[ɍy9+vdu#㺑%yu}Kvy%a O63vk84#[Qk&lP[J̢6Ѥ;{*nKe}Wt#P1 +1h8˄bR 2kapqYYBiR5D4D:}E0~RX4nPɲs[F3`4/ FRЂXH!4Kl&e =5O`ѐFi bXLIpL Ic!i,$4BXH Ic!i,$MZ,$M iX@ HS @D7‚lQo[ <S"k@ְy-o-8#J6PyfE )8 - BSԂ%`'7PC刡l1ZE0aLYPBШuڪ@ @6}[5Ţr?fQ(,a w&MFBe1ٟz2(|l ؄ RZn_A W pfDg<3@i3bs3JNa Y'y!}, P3P3}]T)b{r3Y 5P3hLF5 1fpi 0cf,i8cf,ŒE3a"Xa"X0cf0Ie!f,L5!flDw#-CJYY\(6º؝Uqq]S$p8i-Ē(bɼ*`Y܏-ߴ,բZ- ͬ.$r03j4]l B#E4VZ#ڪ{(FQR` TH1 +Ai(۶X/ UcQfj2c Y`XĤ,^3['EMjh Ќ)b{,pKX$/43ρ1ҜL\"X"ܭd!>QzwJ$mE-PMj,r,rE19"Xcc,rE1xXؘưP6X\j@Ft~@#xJVdQ0*ƵT7k!N DaZmE!޳3~3"@LzI8ȖdFu~Ll cYQRf],ZUޥzpft-qޤ׃'_|P[}ĂaԮP Qި׆pZ^QŰX0va,K* 90V`|KdIźX7ecaWPEN_bX:׶Q ?fA~,(M!{~We45j en~Cyr!9Tkn΁H,}Fd'4E*#O06 qybY~!! էAnEV$oݍ$qɽ!s NԔp5y]3 UA}r[G|wlddցJt&PBS,-LR4sJph<w;-<-VKqOkz*״q]Ӵ]~4N(6OC\U)H"&e YPgT9rf"t,t6yɢS{ƒ#^ٳۇn>tjkLPo8j }F]Mׄ=c0/a3@6}u48snw4`$ ˉW-lѡ0J]>bRnkxXYX YS ] $ʮNWZsFUP9*:mׂ^f5YS|F*k1àp' /lAp,:d14Ag{-BXvz`~^"yYl&h:z| ki\:5ҷNYg^Տ&cYtTq 7"&6v(2u(jd)BMNTt+C⣣!:^lQö$:}vZA&|fN6 k6W3-53ӌ#3|#BV܈ىQi5FGY?FnV$z|^RH:T;_է20eVb8k |[֌yZ/ܵ[Rt?/oWW dL7(u 9qя]i-84*S'M>W 3g)Pqab[\ %taY4z‡@y77=D|KHDЕ8bN,w+Cgt~XOg$P!ܯ(>`MVΑF<\>wpob'miWrU6nKsubу2e$4;NI%zvs6ΰ7 h$dUxsxN3cBSݓ#T@),[>:@SA\(;Z^y'˚^LiK2 ikDD]"*^Qhe09{G,&39F9Gs.nSw+m$>+`e%A86}CCy`,8{p $) gXrw_;X5 -w/TکbX0[y%p:g,5JJlݦ8:?<=<:ى0_DwXlsaTR<>;{\RH('wwwA;{rn%1IKp!My/,ԢܳRA)Z/!ty~;\{g>w9_8sh9.\`~Y[IKK$PK(Q xygTmݜo/ F|y`޸Ac^gpG5h1j|@sdpM U[ tu2h)DOcז6d[ bRf$|Wؙ~l$GlĔ[>?eZE}g 19?,SGHY ;݈J*]7k#uӣS,C'i[g䨬tuO֗mNpaUS2jFvLnmeTVw:ȐWBi$B9|wTˌ*e4N9yem I'?e݊%פUJG+ǶA1p6o*z*]Qc eJw6 ͯ&FF(p@čeע}MsTԈ yW{w#hVwHx3dR_;aQtxVǂ{nP͉)7pbTKCx [}nع6>JI'RBf1~ip0# V m=Y'.UuhH.ƍQx}A0TYWlf|{( g=Ch9tQ!!o%EhFӈԌf@}uoF4U khfJAG}K^ uy x7j֕)12vV4m۸Ef2aMH1D̘u#s4 %(Ѽ&ڎ F&Y6?x;]61|Me9csq~< >sf7 i߭dK`u??'r|njZdkeѕ4$S 6tN ͦCǐ[:&)mG7\2g<1S4WeTS&א:\/@K;޹%#v@iTt'һ jvd9nW%̓Z̻ː|#)ʐ >IWQ!%QcYVڏS(l/?]"FIn86F}x v}'.W`ʢ·4rT@N$WƝZ|8o\.I,N-dY5ެ:齕d+mƤZ$y|112{(n…1;gg xIywr Cj)W&I^b~x Yۗ.[It+ HFAL{OǛ'G Ga,u![dpȵOKˡ\Ԥޠ!3L8".*H\a.Qjp>iQɺߙK+?SPCԇ*QzmaVC/"Eys^&wœ4[OlmnPQӇs:'GTwRW,9,@NjOFpZ8QNL"s2sBop.ۥKٚS3C'\۬Xǫ龙D><5n;h/T]#WͰ<y51!B:z')Y!ݬMNUuV¤ɢR& Ec `W?4 |V0i]raw~PKZH"zd 8MiR/'%. ~롟f22fꝛ4D_Kسt2a;hz~4#O+a}1yyݫ &ʬP/nHV3XH).4yVn g(A玷\dy눈aⷞҸ8Щ>vC(D'E7gQHa( @>0,C)ci>#7GnF/U[CX$NBLќEQ0GGt:E!Gq2! ir#73*NL@|d I&کvNM,d`eh0?2I "acWI 5q-vI14M4>$%rrwZCrSbB9w,dƄUp>}sD bD[@o8ȥ9&n5 !TDw<a>WrT$tGϊ)}{(}.rm<7l0"J|߃agsu.QoO+4|äW%WkEϨwK6DŢAN+;9]@*>+K1SaNaHPgAhf,(yS-z!u9*vS ׷=>^vѓ/ sVOzG4jqj@)Qx?[Q@""_Gb<7ǒ0.eRF 0 `_za=WtI-9}c; ^M LsD](u] L#R$}!'*09)9! %Py8|0/_ Zӷ1^M@gilT±BFTr # ̹݇?8h*q#}w8/w?>zzvxֱӶӽ7(kZJ{gF$HB6IQ=K$BP R |Ք|t"01NIp]#}_t&" ¦%rq=$nc +*ݽ !K\DEIM, **F9x)g!o745E\y/^E0**gsޜQY'h_M8$7mp)pRiJg$$:-^@nC5~c2k ;I1TǾ+"-x~;E*JRPd2kdO4JMjXHNT)ƍΞYI/֬ۤ?rkm2)$I㰪͙u3ߝ |h ٍ 2 ǓMr" 9rrcOsoCG5Q ׹ o9 (XN6R1d^yxx|#xrg6npG+HŽ?G7/a4mgP黥@فBqs̀?[oR>C _XGkg.Arʦm_ 7X#kxM! ѯңo z'~Ia:QD.gǺd-f܌auu^eݎJ @8g'7[:3Q@=Û32W Wvݛ}W l}[;OxpN_)ETTtE/N;Ԗwf*qa DT?)Go*[ʐ$z-Ew~.X6ƥLOg,wkmf_RgY]2 8ʵN98-_.tzxGp&Z^'U4g<дӋ<\ԬoHp(Si:TU_"b ow_=C?,a]~.mJԐsQޣ;-Y9Sta%5}9L 4SD)'򭳫jboǣ/7mj/ܢChba3 ejf չq[3e^mi]'Gz P[dIad:#F|hw(Yvw(n3LFΠ"JЍ}_gu|zoN!el8MGɚsZ7 OKxӓT=PUPP) xf\$)Rq%g92ODr:"߽/G:=ʏ{u(&bFFOn~jAW|WK$ḣs+ bK r x43 fsEYŒgIK"K(f :[v7wZ{itW6&7՘O.XnVZ'60",nA)rXM )!*f mn(ˆX SX cBƈF8ٕg Y5b4Jx;уrWy(wYkMjN9g'#QZG+f4>Fh,nlLߒ(u1Oa*5Ow㚺6 7k'qZBWcvn΍j}l߽c>}ޛ?FK_^&[k9\Ot̮iU㬯whhDx.L`tM jko tyƖo~Z6HM0hJG(NO W`e 6 ;_ONA{mmЖOi saԘOqU $Z`&,/{VRg뫿#dټw{}[g 8%,q/lh XShQoX$̫v_"ON3SYT)2ٳo,%ف8 ͱ,rIn.J:[W\IT$Z:F]L8 5*yk>߶* q}Іr@Vamߛ۫Od8H ҩiӉSV(k5ZƓ,$U-TrT[e3e#a;0` u(Qt_8V(Mu@pՊi݉f TOAZՊ1H SJ'M͚YԷެ:([ó1βi i]'؜X$jSReDM1řEC;g9ȉ"2z1/A,C*FCTjKﳓ`^("i/˥ ,Hlbl;8ouGsp%G3ō h!]llaN(+{KD[ЅɖSh\qfk}7{l07HCp/ LG/%OR_Jbٕ8U&dž dȴ\o =>Ţ&Xl,PJ~#Ş" wDB"¦Qqyp;`>1V O6XGƷ):.צ up+;'IIwDhwqtqZUZL-r;EoK?6x ;WPEs`Jr &\KkaH;U e4!Y22'u.l{C{x 躅A$z!oGOX yF{U{CulvgAz$qgjш! ҧ0JIw~T6)eYN  9PUNEإBwri\S@eO:^ϊ%ciXItm.tS'Puy%>h#NOB8с8 dV*UXjYzdmNJC=p3p3sm(뒀Ӭ.P_"N S`(vՉ,EEV[Y֊!#A]|R#W'W?mB)Ag~vYx3HMy&zӫNe:( v/dgdɬ:*ID`v;@:5q@E 2@RQ?dӀ0ZD If/_ f̱v/T/3 {1b>;1Νhihv줓5'ׁUcqƮȝX5ҷ>555acdMM(6VV\nYSQGo>oL%QUhڊi9(sp_ډ H(ծ1V%*;tLhQX~?m5l{Wel2FSKͿ +Eγ%kJNw˩vFa)P_xˮ Ye\U0k(ܛ?Xө&*♪j13P&.XsQ7D b~Jص؎;- {čcDgBg֊=gy SX]yV`=9 \= 9"r+A^ H1qŹ R1#K^w,@j@,hR  aatN6{ gh!w7uv ' ̊GUqkʜͅ9(>bsv;#7ys6'Lg3߁(.=$!>~>M<4Yοkq!r]%6j^W"NchZ/m۰ hEϿE5ȟvh5@h];=imG1-_y;:eC ȷ3c.'T6u,F1aAҕ廚( \:tr?wh  yKF)Hт/\ ]"fǗGǧwwT/6Lw7pjbC"knPˎf_GX92ZէMB6o--K/|CwZhjs j8;K4"V4?9-޽[nQ#@I(zaHٻ~GRp)$TT(ii6Ă{R^&x;6:.۰HnPΘImEt5T)味0i$rvz9KGنhV\[g|.tpފ,N%@I:gѱ}9{HW}6%,bv}AJA~{h\hюIkTY4l=E*׆ݼ:ߢYy^*hW|JG GTF\@[JVD" ttyG{(djRYeF91SmPAgU@ʺA}<գ3L?^]:,7wuYkl_/JR9Ks=_)I4Yم[WoOf2UVQDVzfćHo4K$$Hwwaq-7ɇ(T%ž4":@HTc axD"!m'8 At{8M"Ռ_%_84&_=0M#SdKW'W?)hz79M8á75Pইn{=-iSD"t$`Ī&]-t&тݝX0!? i cAQ4M&ֹ F9ce1)ACzgB ~¾.fhz]|-'b/~(ޡRjɽ{FŇPh,P-. Ȣ,gϡ)D'~-{܎GJ|.Lu~4J[Wx_x*%f{ҦWsv܂R+xK/ +D YhS_MYR\EoՈY2@-PeUA,\)pr&[98998420r&8: D{jpm[PL"h+eu:8tfV3sHrKl*[?Q4 'L_Vexr"< c 3w7}w_k T^&J<=ߎ*9EzI%Z4К)bh %"OTq5uI04Kkik$F*j;it|wczP.nN=jOG(L"ٲȃAK#QmfgfMN,$D=K}0tm,Q#gt}Z%U7[,觓Cy[YbjPaVr`-%9.P|u5OҭuJxf犳s<ҳ4婋ḒYu:i]gH_`Zv:Ab07seŁXa͏wٚXDuT ٌzOE)@+;v 1L,?tT dygŷv0 ڶ%JXHG6Y4!#ぎ ʹ=HZQlx5U&cdM0̈eݎ_@ח[Kr>(P-6;Xk~Jtb+!^_PΑp]gPDYAnU ' 8v2tȹ5";,dO+LS`JH+)x~+`Vxi"{:S娈tj̲U3|zi6ReI rbSUL> (VSVKubwA LPͣhӍQIVg_ M<靈0џ>"nY dSY^R}CD߰Mpj6:Uu"y\c[jE6~}ibcQ(5(f*auDWFb4c %%2ֈT^h(8\41a;UM'oɉ b.HWV^u> qTn'21O[@R]zH^ tihAxm|5ע06}122:&禯u`5w(+mO@nH{Ɲ3Kv=5쫔Vr}5xr daVsY6c`6ИypzÞg*oy j6`~4|AJk]h\!p@ VV3Ya*aX?b1{w5xu H!}; C2Ę%noqmHRmS#+ շ)h6'7$EYZ t4H:FhrлkiL˭"WF B?ƌ0kH m+{g~#Ax#?RKݤ (FAe6zł@W *[~!2]@ EȎq/~P =@K մ$҂Ha{ԧ˃= bɲ͍" c\UEW_/gU \%A8D&8/;ad6:ݭaRGZwKjK؛Xi*ˣSTz`Pw#eZYF/4?fƉHk>Xk Vg7s~?EO⇁$ $c9 N7D8Ɵ5j9sT#[ŏ+ c4֞ Mۚ㌵ˉc!?5d=2l'v2|L(3zH9h@DH| Q-=݃H*) Ojdu 2Bq zP'+v;4iZB zzr .S3aukj-ʅ).eTum'cJI Yü\͡iONΩ[D)ː9UDkZpNE+?`K<01NoωV8w̵Ve^ ݹ[^cQx9q>dsfZ QX=Չ.R6\ ƥ|S \G>ViR,[:X Xe݆dxi&OQ㰠ܞ$q<ޟ{,i@]#`Epp膌G D)YO&tp';DN{bΤCg j|$P~c Ⱥ2ɰ@|ֆ|r+p.f𘕺i(ϺOvN? \2 -;gZ-Ĭ<(?23'?Zs) 8ǟr果 Y },1a4À?Olh]}kh3`FBG+N]fD), 3Zh ntZ}NmtlDJeC(~}r O8dr*1dN&d#9{ֈܠ5!8-]{2JQxs6YF]eQL5.@ah[H]i0 w}!u5E!u7Op 5lXiN-hpdahm8h=uVo&׍"k ʑ X^# @$dfV[QHq%ϰ%hץAɎ.aݧve.hC %k9.A[2M,x"PZoYR\492IڼI @7č|o/K 5itRdQi)\bqKqAS\)H"ښ[eU2+ C'y,Jٱv )gCJ ͔|`S  0j"0Z>J;`q-@kqak-5r[{)7$I`zi%QziFwIn ]4"%=sB_QCJN_M$s'|S2иQX%bC!TM~Yhʋ Jc/ ? |g߈'~B??5_`ùq-0yr]zv} ;A&9} '^wK!xC?{O 8:HzdiBpR@ޝc+2r7uUp;'(j;8oNxGfG]Vb lKKmBx3.NPĸLpBQ@MckJp˓}Nήo.o4MycU3|\xYBrwbE13miB [Sn3-NyE>x &WxNw6n@: HufǷ 䃑a/OM/}O͘ /@5^)WMaK]#KvMTNՌƨ!.]ܜzzOl0kɖ툜 vu/F]Bx~f{D6fkԞ94An jnx^6RxP\'Q'8j 㶗cNbA?ҿm2iF8~bIN8 5E+FNynS@_³:犳s<ҳ4婋Z̭(w]i?$kBTӺ@ $@}-Aȍ }07seŁXa͏wٚXDuT ٌzOE)@+`VK)%oC:Jtt; iMM!,H2 騂r4!#ぎ ʹ=HZQlx5̵O#"`$NGr6 FFXUI4}Q?ҏbCWvm<{K<FOXR'q$]k 9y#;Si/I]i>~_gN)-G׌6T4v~dO:!j6@:s L9c@9T\5xy眩Z{~QW7.|Ru1? S |KъtV.ة--/fTc *(ݏN5 HyO)#fr^.(<޻M^wJ}22f M|靈0<"zaf{C[j[Ksɖo#ۜk5! F閯VR쬘k4"Vuw,ueO˜Mىg#^>Y9kP͡Vfb(G,(G4X&qԞ(^#Py%ZPwS8-'T[.8- 熶24Y꺖 /#ACaQ|M1*i%bB# ~s̐p꺄GT2|n^V= n$}0MǑq Cq "L1u u EFY РD=L~)pM#g)3?kIp8Fˊ)0Cu-.|88^-|.oĻfዃ`+M<O/Iο1&K-t~/D6uzUMџ8,zE+y&?i.Y0^Ai|ŋ#N~}ǝٰ7c~|y0 F'hr @e!ȩK6n|G%}"F"a3V̥O·^Ǿwb-KRSÝqA@_sɹg GK&>c P|5NVH {1"'&!m$y[+écL7H_V-y ts sL d tϘ31䢸#^#ߌ#uVpave_:FѼE ;Hլ;+\jٴr)ԍ܁Yf IEҭU=5Jƈ7$o+dIlmhb-̃**Ɵ$kfdO#4nEϸa<MctKcnh?9d\Ӥ|J"izBm}s!^c60ӓDO͒bnr[7\[̵}g\ Sv^]D|N&62)#AQUxP|LI'PoC5yX]A?. D̬& [J[bOYE&ţҗ<4lO<|ܖK$aH%v]B. S2 ~%NT%1S!JF ̙"oܙŸ̤"SXTn#N_hq2R/oWCytZb  Ov {VFtSLr9N%W>!G&sHkD(EʫxJjyq\]y?ff\8&D*[JKLe:rtH\ 76q9yimNU[Z^#yT7PpdqaTfPҙi ~r5\twҙDUC19O8](Uϧ!y eƹܜeC5*Q k:%F!ZZZhFcCRJԠ?UפyO&;g[1!o @g$^CUɡ*\:[ΪcX?@Aoʼn5FW=e؅wDȜWCE :ە7} ye_s5 &u.*{b@=TЖI^1r1`cy&'nGd32@A~'ldN߿:CpF#B)M{=Gȭ%I7n*q{e^,6}8 } :k!vc'%,w&J+0J:Ͻ4 弙,3 -UfFI5k\JD[M5Xհv]bU j6+sNS q5G&:7D0j`4$Z%L T?dOٷ0 @&x&ӰDx2L;˩i&캟8wK%N:# yw[:VfJ$Ү['QlM:Ȃ_vB/BF -PďYv76s\'*k)霦1ہVT~RiL,R֊~QpsO";2q5p^M>+q  /V8f·h?.)]0.s8:jzROR-KRġsp`w`dF+̰:cm0(i%0^"XPxŗUb7̍G!Fn$Qa i6BY4 -> CnpO͔.˝*aM-!B,{F̼%~XQvSI: ivd2KGI:j^>3I$j Xg׫x43a ݗ|UVnMu&͔crbsD9Q}!Som*Dj-JS3RVRcf(i55Au`.;׃M8-u{ւ:yW7׫ۚE=5г4|L 7y,EBEEnfzǰo藞ёLdo Q7,Y$JM6*''Mh'9*ޜ7{{DN,c":N#XXzұf@E&r~Fʭ1vvs|f=ӳ(n=$:wL{pK8~ ^vv_v@gNo{u{ w.N.o ׮w7'z4{2i85WW*cG?Obp[)~E埄aw%lp^x x4$'wLsdϽ0Ę~FYdd,?MQln #H$m*'W#ns?]ZR~%c ` tXdI&<?dP6+ط5a+/\\?[4a&VA&&mZ{$J\!)o+o+Wi쎹-5u[JA௿o-u`5tEt1'Kq  /N&XkqZ͋Ӣ‹k)/ݙn/?|_n+˳ Њ@v;%W39۰Gy~0Wg?'2 Ƌ6װʯW߁7xy%RDj\y)J52NbLADLH 3؜QkKOr{'OpLi0(9Z FȺ/H."K AP) uB]M\'&H"vu3,wh̑6.0D0xC,pO4/m o,?IptqՠvHB镝5X*:-gt( 0,GQS qt<  6AeuVc}[['|TZW*{p &b3oGRUGˉuM> FuĺGp8'휈T_ȕexZV/ilFu?ĺLY½󝷴nR&\S8\BQ\sG6_rsKN9|UBד(a52_~ QLv PT;LF-ȟ ^p TyCUֺ:dJ$8w1`k&H]\cƖҙ([Ԣp(D%$+UG9>Jztq膨޽YVrYe7GgYCah;:^4vT^;ԥh~g~-3]MQ͎0֑_i9AwP'}P\P|-hiqZ7,.3^lf:Կ'!$QqUhOLdd3I6"_:hj$@R9"/ȒqrUS=S[03p&ll+vf6ۨ,S޶6Ƽ9  PYr2;S[6TyVڱ21~pVdM4O w##oFA;rI4[-O< &@۾vs6ò$P6mm6Iq Kcy(6;rVd~Jr_Tjn_nW %8@M x6=ASnqCM #pDX+.PN"Zaey\"Xcl$;;=1.ފ芀FB<]=ѕg@'\: K0%u^R5䄀imLIQǏPO":Ry]H-+tzY*8q&::-\sCB+@BӄC4^p[̩[}ÎY2,,&W&O\ْ2N͞ ь5'AO%4a'?:s 0X(W4E! &|%U5PR\݌2m[lAAQBKp;ηsG[bxxF֬1oDap_'ЈrTBAʣBWpioxb)lDGo\-HD0 Y0Q=2$_k*DH0o E!b3ЩvP+Kp5p"5p}TX`m'P&Pn#,H1Ƃ@Gb4\Q84` H[6?*W@ԎjX5(9Q ;GWNP:y03쉶n1t-m{j9(LR VK}T{I b Ra:\Keﷵ% Tyy}kk?Qc,w=Uaj)*mEZ2'Ek"I0K4/oZTWW[fS e`*`;jUY~gPQA3Z? gPdT*g]?2jA3ȼ~ܬǸ~*Tw~X? gzLzfLbԠb rAeNV[xw_h약psa`;O}R[y{s@^d*jH  !+X 92*`Jae)seTteI 6޾%{slANNxi3hKH{vy*iRafA:etEÙil c|(ckצ+NB#~ Qjl=Y,B4ʯJe6uJʄ7,UURhVN Wң97Nq|đͣ&8rӏHap2@<ѸGBǙJlVayQs,cA'`d`4eg ђ '8|.W q5yr@U\C7+҆k[.S+`DGʀdI@t75Մ$o !"t5Z8>W˞σ]D + T*"uPW÷E\wQQ= HY8넲]*EGnmVDʎ=ʊ WóZ-j$l]p SdRi;;N1̈ )z #觲nJ2kg:3XͣfGs qe?BBÖ VnN(+Ȉ?Bր?S:|D=_W e"]?ܠ)$?/R v1 oo`m%R1Gh9A&XkzV(!Pq3\*A݊q(6&jג%(NJry ?~Z°Hh-FWmp |޲\z-Zw8;LIZ}ՖG֛peKq*o-:#30jVT }{-۬9D7y|#%cxܭ0lIs LxmbZEDөVq"@& ~P j碟jߌCpؕ8/;.齙F8D<'hWA/i0_zTHJ8%\,#ɭJCGW) !Se-K/xّQس1,I uj1íxy+tқ/ Jԟ?\N ;|ԈєU'^q1K,>@zcBBZ324b*sWr( =(Mr:6Nwܡ$Ksm·0cUI'*g#1MJ`x[8QeL "Qv+jy(FV%$侧<"5vt>AvY^,8yOorW`Fr,.. r˙Ჺ=PPӦy6WվLS]<}$Y=pp=)_e4ʎ#vS<_N] EX2^{C uv7Z p['4JV`Yst pōnmn(1%qr@jhJMoHȈRX.kbO;&9M@J,|孤*uV"#ߢeOCMY:q뫍#*OsmXn]) &_L?W[TxZfb055ז i!C๜D:ѥОA~iVR%Չ[%3 |Ĕ]γ!\aغFsΪNBz )A;HgZY/a3L+'m݂z\WFnp}LV@_{AI$hko(`e f!e7"4+nWdA)d=,ryQ90\a ,ÿ<W=yYVe9+&Z(E<䩝 o}1/ nDa-!gȡ ]e>Qh.>?>'z16T?OQeF ?c-:x6D:>>Eo}?>mtlqՈPs,DuNۄEƅ5.~zqB^"AjitGJpʇ[!/c>.*s+Wb 0@̟q# yS0cbݶE^Af'ițgYNeȎ, Ӹ=\r%{-ӷkZrdd)e֔Ui-;mӺKN.NH۳pN,QNT=eSZ%R8}?w㤬w9} 9Ս~."$sG8#D 6:rsz k'@iL+],fQex\]yo#kT6W*i&ɥj9W 75rNqG}޷.|6Tm5̻jWZq58Fbȅq|^׼~P=a랴 T8 奭녌7qz*Ƴj-d^9(dPtqNlOƕͽ{̇;g(׭#mԈѹRa\ØJNm Iz1FCF>hV\  lBt\}!Q)& r*k}Rқu#4js2<{ٌc`K7qcr$9sǗHq:MҸ܈+80L.ca\hS~Ws?"}=[}_PV%0W6#_C̹v:' k(['8.j{DܲWуM?2 XD/$d2wbi.y΃R`Bw6dj'ƖOwwq kZ[>,gsm};:׳nS A˸)#vԣnw2kι`$|>]`f^=A`Gq뢪v.o]8 yd-:q{l zYyWZ]DGvwnN12Ǡeo>=khYj$ BOkEŽiq!I1՜r}{|҆L=G#-IowV#jScfkLL`/g2zʲÜ:ȲR1v={ģ 'YY@JDaqFlGmũN56F{B'^d)Z 6i z L"I:=:,u!AߗFC?|HOw4)k00*%qgLȜȜ'3QGz$̲cg z*7n/F+^hI[û,Le3ZsUz2iQ}٩/JbVIef-v 7u{~*e6[=N'OEu2EՈ(u>*8:A+Tj׾Beݍ/+{iɔas5Urjvv4 벣pnOCFS7}28:]Z@اvt$9AAXS^/reǘKU^8eBv:sm|{w?(mb&7FX zcܤc513W%cP]O2gfh8RM]gja4_A WK8ը /8蚶;:N:P>ׄ?RUM4Y'\Ne )[KqS9; Ӽ]i^gp!UHY7vt[Q*4K'M)5;\H/:Sq'U:D)ٯQn 7iQ9DZ&d9A41WQ6c #ޛ8rf;Ȕ&ZޫfuKBA1+\Ƞ%(X`J^q{IYpɭYqI]O,Y] Msֺk8k)CkiQuhZ%:\cV\Dduz K06d a;t ho.|-d; ]K-j1"{;鉫B.I539(  &aG*en-B$`^<6ls,Rqa>/+u:c?,d` yWd{ߝOrͯG3/G$`P}rʢiٹγuUfQS%_'ޢXqD 5ʦ2q'Cl f)}T&h%>W˫IUW+I W}А:{(cƩw)im_#*b@re> Mytdil \eo?$'bɯQ)癗RYP|RP4qdΆ ,n,0;2怩'%:ar|ȏt6 }g`;d4%$J1 vcj g2g7rZjCDN?,I A/4LJOv|XʍG?ؿHznyp-Egl.&rr=a.A m0G 83Cxzd""Gק!Qn:\_[[mpnl)ok%kKqo+ /H]ƷOL9E-˜X,br4z=\ 4 !V(.V{ޛLk'G7GBH#~aP-Bc|G $ 8?\9<`-/t5./H8uxn.9mOptLI(H KoQXM[KTNI֊4JR|}V0Cz Y3\G6ch2!<[.f#Y~|$da(+ h{ q rNU+QJ>/G׊,ReYP8yMڋטMw,fJ-~uZSMn uR,G9ܷ,cЮq5"߅Ѭ* $وK:KL;5 ^QDf󞆈e?3FN1;=Ta:T5[:XٹKMAtY<h5ҞWU.I4{VM$洠큑sEZ7eC_ZDq9e.n_-zuǚo&&B}m֞qч$HlZk;f}4!lCؚ|քBv;#$0ObM-Z 5fKQ[|G a[Ra*N;Q;G hzҚ(`|$(YiON q?3]S+FIYW{Tv;*:;+IG =3\g]#e\Bgqָ9o{?cXiˮ $_ yzbW ?]:ċ+x3zP&$7x$3H\s3*@)(%+H͈u;:gTBAd!B~gp.5Kk=%R,Vt$,ZX 4|h̽PvSt? *o3o {*Eo V`[^-RuRhU?JՄF L&dB##Y-Ś&լ3g[3o|(lIv>ޜ}ގ FG+Դ<|Rg2FMolM4iyNI ᑫ f_R.%V\t^ˍ麟P̕仌˪VKw\oroq9&}}$AzE](Dƣ u1k *G?%@;PX-`X&Ԋ7z@B9z8MhqagPEIYgWsuzzq8)SeKi1'F)eWA A̭ug$yG}ttO6+D$.FU2b@I`Ee~_*I &.{n4u3V8-b65|RP_͵MKEf䃒`Dzg(82uLgq9x*aK3  jt^mօo@LMY-,ݛELɥ5Nů,qt;iALwmӐHjm?7S Sո|>T';DS}{s(,Nԉ.&dBRئ D]b;Sσ-oQلm |~X, X75NHiH+q-յv! 눲!- rΝJWc^yXܠ@Ho]H>7Baa],"w-p з[Œ~SU>/eja M? %xj$tes8H @@_Pq"@E`![%C`l[8"F3%msG[ D ˳ syZ26M KCiERUiMP*Г/{8FU g[)+v/*=imcзkqou6rZcY 㡤ԙBIeE#׫Á[v& 8e+b􇂠j2\h A VHw\ hRյR ;*JSēePR3NHXM`vNY{CCMyɭGYp%+Oba㱵xv&8\tufg.tXUX_p 1Ŷ\+e;3zCay"Պ] RxĞ-`%}RųT X#uZk44ף Mp݈?<5Zy܀'hi =p{$ËtΤT57N?]6&/h V& N-B |Ky`5& vZ bpah{ 42h(e'Tvd Ay ${NĮK5hpzk oB5+'Fc81 XUU P6+TAF{ k4A.  !ժ'For|@5UVP4ƭ3>-hA=\{+N,X㟏Q*p0|Fhz4|h9z %x]qwo'"Wwo̡ Q{`y][DBܰX$m!ogD~JAWt=[wWskL\S#=+dqO'JU] j4 O"`R ~&Op 9ȋM2*Ve3=`갽^$CIq'ނ.Woxsm7Pwɰ-5wKP>"tze˯|tms^r\`IжІ"QcndX&YU<3fk+6JxIֻ,L4]G]oUcaE=( wSQIo)30(H+WֆKsol@". 6%L辜\ kkRmꨁ/:#|aK o -+~?sj?l(-|l}iPc [:BH!o9/|K|c2>̕`+z>z>7`/y=b:!?Ԡ81-M@iWr|@rji:W,Ll(`1u) Т6/\lo JK/2$oڦI biԴm1]©BDꂿN%?I#OϯOMUȃ^М}c*_??GܘQ)ަnt(:U<}C?$NH+2E!$&q.+W,N<υx^pI5"`0;q;"@bnzazq;~t~#Wڴ4|>0+ہ[?G!ќ 1Q=>q c'әODŌ@IJkF'10j~c^# )Uqo ߡp mJsts|)!^B1DHm輐]hH1-￰^c2s1u"3;9~WnGjRyH*j7L^ԬH\WQ͎D!c>ǰ7SCU /z5-)7XG?}>GAK=#M9z|L8c& cq|1Ar;1\aݔ3/* [?.$mknݑv p cAG8#~>L:"$z2JH俯vGf,bIf*qЀ.}D 1r 8u沪w8$?;ơQ-yMx>AҞd{A؉`d &\_GWC ~w4z4%NvlRr7G&|8=a\Kʠ#Q2tb9ɩD(5j嚓)NQfG4uхfŗei]28P+Q"};;\<.\糫S^L6DHۖ)o<+|\-Wt叴y|4= &I.5{ڲEEzTxtHх,#.jw<*̎LZOY12 rO,BpI-hE/,Ԫ۞9Kȱ$]Q\ȸ#*V<"E w$}ܣrY͛FTo"X+V}~'u*^$yT)_Nl~!WQe%0/uG$Rir4/2qbe"U/#d([ 5+Fo DYxxB?-JE;ARM_#!$U)}łeǾY7Ү^ɛk"3S̷H0L;#AS>%(h{_1 +a<,Ut!Yf*+ VJ7[Uud{IFox [U2(jkmAVsYPZch? fjTڞƘr;!ZN,mR [d誺u`8[Gl;hػ* MncuZMnQ xduY$X3Ձu u3\Z|.!o>ZBm#ŷۈ"HX`l@crԐSv BhJ!pm$EH1]*k `r[U^哻 M-^Жn"iv~-BFL3,3$m$$b.qcG,)qr ^C ԡW!-튗ΥR5/,eV5m<Y ̀e"Z냛LD>kc*n8ìo Kf_Fy@2V<XE}w3eZ,󝃶00:khdd;! Dv +xq_aì P.Ųmh!3D֖jEUtx9m|NR[ИdZo *A2{W?VXq'*J0+1hqDEe[:U8D\7n+MJӶҴ^mݼ&ؐwȖd"8+Íli!XՎ0Qn ^N=REkq=]g@QMۄ^vG`+7,z~z]X}̞=L,1݊ݓߏsSȔ\:H?D-롮ݡvI WXiſ/o z'I_P"Q~/y֕ RŸ?턫Go2hb|x$)/qžiA[c#D,XmڤL*m9].{i sdj Yr |WZ;;EvUv}u2^Z/;\N6dJ[TY"wIaZ[!R(\S_ +vZK[WZp 柭l3u=ܫkkO^`-̅)z,b mjUiկJk{D42Fχ|Ηqf<ʭmemYYm:b= rAH[Vq:Vugt張F8ቄXUEVH!P Gn_\["`W] W pZ1zɶI׶ҽ"WFE؞tl> aTfrxWn;q$~#y lzFᬄ6~v]eR9%xuYc"J+ʄOBiثPr +5?;5HM+ O U@76$cJ[e\UT-M z&EmQFNSW~,m3se""(!^!a^[݄aa$ r@T2v_V8͌/2"}dIox:|)l@N|1/qvv=ӪŕX("rrf|#.J/IK(`MrdjΠ& &`HB&=9Yn[Փ!u?oE yQ#* 6t[?[?(d ׶Gyz Md[ۦO#e m^/k؟OV2Yptc$N]B`1ޜ.'>؍/'ݣoئ8zYg j-\<']9%: e~/YUh:} _wK޳p+ԭe;oEׂZLf.s g~v Pd-{Җ콦tAᮄƬ](>9Pf W{(пzxDZo:VcZG*G9A\tJpZr5.S1BſZ28Ԏˤ/b(9ӐzKe2q#nBy7H?E @jB@4*i{x+EoOq薤Si==8rur=9 ?=~Xt$>9ΉSr.5ͱY Ip>Iv]}9x~uWZ[abC[ϛxE$sq {h`܅ƫYOOHM.V)m$<:c$~@k#&&z:C^HTCPCБrj+f'\&=I`+cKVneJf;zS?VjR,9}yG}4$LHX,S38mC:9O%_YvXf%8}fd5ĉ?cE"3^~)i$wLm[h7MjBLJ(7R`{>jR6Ac v\Cv蟜Qr |#n!1С'8S3:.hڑ|pO^X^~N=ב9~1~NK vvߣoRDg(;H]> ~t.4Hcoo d1׏Y/'LGKӯ5>޾}su}C":ϻ{ʒ*7Key/R OK[b !,];J{/0qW5r'sN? CB:k1g(֌dL> ydu,v:^X+XRmϗOSbH7/.~fAjŗ"o9;͜ɓ&72>j̜]j4u2iP?|: vKӪ>oy٣Xo?ztUGU?Am^@  3>xIts2kKBpȲ>y=V^ZzHF`_Wu"o^Ю>KmJݒd큤zL:tOQ7٣ᝠ ? pk>G.W5 : d^AWi!/.v:}T&(0=3yrb<hL\g&g1&T~'C(%XҘU' fd9b5dճHuY7Pa(+PEWcjWz6JjP%3~bTbMQQruR`уhy-Us-VS%eBqR6yzjM2ؽӞَeS u_kѴ?7iw Cmgj9rXYK|Dd“6}`{&ŗCr4EwJԼS=<|=J\C)j ƿ/)NtN|_&+o1!Cl_&t$8 \@h9tEсY$Y`ǒ \`1&(luف7; &\M%(?'4AӼ JN R Cwj@ >PWX}Y+ؤm@(3sTJӹ;xpI7{#N26d)dt{l7y~%پR<(TPlf:W* J3"J6\ogI0GQ"rU `d*>cI1沲#Wo޸lF# ߠ͋"5APW<13 hwl'{o!߰AMrZ?MVw_u2?$-= :'Ⱦ-b]-B9]ʑ<įd5V4@P"HD mHnH nʖًEm^<**~˦4G6)q!ޞdP!eL/8y' `x'rgo]މȽcsoYjK#oŠU'!ਥmʂq hF0[ 񘞲AЍ"_?gR^7C|#u~uFH~|svfͫߵv%]y?{zi?GLa]iwdk^*ؓ,Riv@:WB_0R>)SRJ5MXZeǽ.?>)_T CaveP\&f=T,8I$ /x21t7)4:VfgqhM;>' LQ1slBsm($-Z)<f%* *ҭr2:(XMwǿw c{vQۏm[0r=|#yc630hM>fe=7!x&$Mj6+ p L'rWii> bVy \­!yp^Ή*>z 䡤X(Zp`U:|USk9ٻ#*Ov$$ϕ9xBGR+ K_azuHB&{JL){ .^Hrx/"r"$KHv)OfrNךHddƫ΋[?5%I I+ MY*+- ߈dbeI @1#[ 1$6ʱzíL+)s*̺}v5V"&t~Å@m=mWԱ+Vؘ ),  =X_O+2zpFc4Đ:zYg[ `?yK/ANHa3C4/z%bY O d!)%l#s08flL@>@h?urt~v?Ư{ݟޠ7pߟO-/>_}nѳ'JWy«Q..IRѷYÒEs|ԙ0iG6Bϊ,hoYyt2׌xꇯ/|w`6Idߠ}*bQjGYhza. s5a|:Fa< q4ׯJq2YIߟ\?z~3" G(+\Fp&v -E5CAQ)_E<1A5Ϳ'W3zjS!c5ulqZg@Z͜p2'-rfYKS34j&ܕb8sD9sfwnn͜c"KVLK,IS,a,QYFѱ_S'r^v "딵ZL#{j>lRK-'N@ )T BфG11g_nIn<-΄JNς}! PψN|U)my"ve8Rӽ qP$j? $A@< s4!QfDbOcZL{i3mSf`KY$]h)0tCI73馜;3nzvbrHۥ3jNkik(VuJLY5֕tb`J* I~x%'F{gB/q+Rũ-EE日_/bfG@Iǜ92\"y|4byRg7^dĞ =)} 3%4ECkײ^XAp@)\!Õe4s%['wKm@-XL,|lrm,Չ΢T*Qg@hwm,pCĚ퇓E[(&GIg8q߻L4LŞup('Ѕ&ɘ**B\|juH-T&QE&"Eۥ^d \$a>.bjQ EС>@ly6 3a9O4"AT t&/W‘PH2YӉ%W`3d&V 8l6c^u9d-2ejX&F+ $V5)0s(VdZ^ll%vkTp5\d&gh4Vq% ǐ[.5dj4( Q c9(+Q6!<`؊JQ⥕AY%v%:[5O x Ɉ eב {f{L{ԼM u^R)ݐ2_'鏅&$Ύ&2*UR8Z!x ,,2ĝjlmd q5.}.6́m#W|A` Xe's"DH hG؜5jxcT0h'LTLKS=^Y)`#*=` 0gv]x-5vY7$Qh\N4lȠҜ] ) {^Hث!ZwF=k$ޝa)u/u2ؙ;*X+‚65,谖5аjt'7G;!H۽ No^'%_MsG9ee'@3=S%E`EF)ZR7UH(Q-,Ֆ!תG<(ȯ6FՆ[m$[R?v B|xOE'cã)amSb֚ >Pc4\F#kݔWSڳݢse"~ _j.Eі,)LJm 2et0"Zx;kH`_y5b٘f .YlQ!#mԁUYX[R+i"p{}o)M51 /X ݵs"Hqjd~r2OrY \e5k8.# tsJhHIU XkYk˙Ke@Aψxw7/ȗvCKEvm΍2<LcbK*)`??緷h\GwBg"AK.듂9t1MSO> vxܿeh1'9f'ON/(#]+&˙[G?JBoCOƿnoI&}Iܤ@ HN $I ЇI ~"}p4{| |YrުMUrzX\NW[O{>7`ס~&]I>/~L>5]{sϼ'oȝ>KN>|3H޽e'2Ϗ]5N >%}:kԹ|p憺Pbo*>sd=8dBiE(K 1ƪE N~?O6}9x~u\D]4v4hV}#hGkc(aXD`t~wlTh#^)~=>ASOCɓ LзN/^4go l+F! ln4?εTz .=Y7\klFԅ0e4rmTFǹ r ~ᲁʛ8S<@笧<ԍ`^4!PDa]"T }eEǩu-,Y%mhe9\ÖXUMaUDX$e㱾ː8~}^D6 ?C6mG6GA‰Z{G?$R*K+]F_]1Ҵ:KiAm| @ΞM{ y 8r^g/C+[{p 5r bik)5j1mrOx@kt@Q]/c ch̻r~mDQtmZdbKn>$0K([k*Z K!C_4gԳS)ji "WMwmsʭw!¹o,74z/ lz9V(P/G9fB{إVȺnb'նReNvhɷ'[cnb[nZX+S풮\ǖqfT˕fxRzG- m]/[AͰeka[R*m~8oyerW*$W:+[R^1oiÂdytXY;h-d>*uS5̀$[QN$E  |1 B<ń߻ъ&_o<ݝw?1fL]'i3g6?gE(7 X{`릷ɠ@|*T+_bJfAZ"ۯs+rڡj{3U(8zUל8rj0xBklf),\!r2 LyJ'rlR:7Q$lIIb5l]2wKO]Rj>+qAIKMUM8lTל&DN'oQjr{-@yT6I)$bht}ex(z;9^ݚӂW;Iv-Sdk7%Lӈ=7E8_+>9${zc0X&O¨BT`l`Pд5gmYΖVgg&1FCi*іLmKx ^%̡jB/bΠ2+dt5_q kMNE 4x 7VO U1y 'tX]θj;ΨҗiViK]E<}i#t\ǵ[𷇕?[Z?+V|%*|ϟ>'0Q:<[yG/9+LB|=E-˧k`CGsE8,S2S WT&I/Bϔ6J?, LHw}ymGYۥ}c{7p1r_ \NAJ?FlN_E�T[@d-"]JCQ˄͍j1:J-؋*+HA#n:dN%IZ|cI `kM~ʔ5y&m'SHeH&u?j歴$yso@ǜ(^cŶbYFڶE ۃP*ڎ^V IاuÃlV,FZVIYZ1J}S6 J8Oެ_0㪪)Vr LmncO1OW(3W-YyFBֆc4kdTɬq5 vOA؞!N\Ͷ SZڊD~7Hg ld3ĚRH)2C\ 8KKǮ+8[= ݽz/pz?5m+X.eG ^"# ?2MqH]&a#eI8Ȭ64LlJFxihJ8qMMvx¼PVJv#a.LUR-y(_rr/Ja^VJU GeyXi9Ewr^D͘sɕ ]1H >AaD(NAޠPxٹo;'7~Zr znpB Y颰Ɖےb#S@m8f2S-JfZ̴\+iqc{ppa;Я;-]*P[j5P@ZtCIvbiZYZҥu\*yOȢBɸbB5-<a2{iCB E w8Ct\GGOOru7E; L3- 8L=TYa fq 0zExmЇ;+tos8 y:|U:*/ iVjkV6򿝵Dw$VbԌDG$,RVAS-Q+[%9sc+PaVю뿲Aî1loQBp=nU (zDEbr '96&(ިMiC!}d>{דy_AI&~3_~F1z>f'6 kl~8b2q{ڰ1[-Ђ#'+`H.uiWf BMIU<>aoG_I5v^ tͮUjH95kpjL#oB#1bDOOyο\\{1y0@#S)[z\%Q6|%vx4!-5@ -Էּ5m"rqg DPMAzf痜^/Q!lse.\j!tƇ\ZڢiD9}fkгZ)YФ0ZX=z&Ȓk A &C/e3J2$ : [X9V^UŒ`}Ur> kҸ 3NIҪQLJ*Gz A)jڮ:i=!6 ']?etR+Պ޺#gvjZgܛ 9ܘԇ6͕r .͕se3ޣKeRFZSHN5.$+,v") j {S!\ƙSփKk5i!+_^KY `Jlަ8]n0BoS?1nDЕZ+3d˫ ]Zc]B,@~S_LAH&?k;OI̥/$fl> `v~ +5rQ~)3 $@_"M+=w$IBH!7e ]?@ m,j95]m;D-o|TE:1.6d2 \1|Ƀ* "Ï>ΉD:A 2jAAFP( @b_U]^G&*n3_,B#A@R,oٓdo? A] e{qCeh?.XDurhdA%5R+#^FRFJF䨉P2B<0BJ%~w 5.4$#b =Sd]b 5*W,GD>Ep/DeNP)e&f^TVX 'ƍ|\dHZb\ :zMz7//wތ4\1-eatWN!!) GOė"xSxbeE> DX$ #Bܷ"5&5%:H8.yLgj;Qzď~7l+0c FFlz@w?JpށC@ѩLN{ jKS7<K}49BK;C]v3WZ{Rݎ!N>ypꝾn'Z\_% Ξ }O 2r)v;}&"+2yY1|Ii7d.t gǀGvOaOS2 /Fr>u-aHό, ZqhQ _%"3A1:Z43%vl@l! 9' ot=@ ?oG_AALHLVs_0B=;^o<-GX@Ǿ"s&3x t= <X-wPLA*œ1O~R;H LAb$FF"·'D=dpRΗ+%ycoK):{_XN cKC=H*ӧ⻠}|e$ m0xՑB% ئϦcҕ`BܨDi)#9,\(6sx_\u*U68¤+x}io;iwrWjkUBGf] vTIS-T_K(q%B]3dDZYҊ}C*@:6._%hkE0 ݞ)zeź䆋^E=FO??VGI&qVwpqcai-5 o-% As!,LuQ=7Äsyqla2zƕFA(W'Bet2;Qy5`1> (^ϩX .cFzdNTz9Ξjd҄ B_Gn딙&RÖN)/́dq&?em ȐϘz4(UqNΣNn%WU>{8D1Xw%doY|XؗؗZܗd۽F Iާ 'HQfϿ=T6ݍ6mk7(RYD2( v/F{=򐵰7^b2e?w)MVa w/9|̅/QI!viZVJʲ@㋠AJOR,5mfG,f8FHS\3;:'R2ΎŢB55F=E}:Q%쑵݁%@eʤ <-$-[d98U̘26̨ڍaq$Pan|ІjKM}ˀI} o5A1赁V#r;qɸ3eJIX9aٍ~ BN)o0%$g'E?R˱tM?+|X2ԯLߡHކ@s,8fwϱ:ό$^j8݄})xb}+*)2tN]oz{Ռ%k{9{ ca?MKHaH.jMr2ߨ /CcOG~Lx g%P,EhZ+azIxq_KX}f܏܏Lp?/D8 spZ܂z \AۙlW-a~ce6Wň2HThIJwz5z9e 6p\$h ^Yș1p]r++ q˵\|\2&!LUDE/ߤE r:ڢi-MDsD=;Zl*]7j~4r:'[:J? ZmDv/s:j됕aS-A\.^[_{%Fl *4FcUBz1K}mq|B/&秴Fەc39F92DOKfuHk녣WYxKf.5k%3I\"X(%2iBX"d1`{0 ԊԵC>ȥ=+ nҨ4H #J%(ddڡ33z8lQ f4*O g6?ްl* x#6\X Q]NdNqM+@*E 6B cE[&r|kD.) \ok^9uJ/de8F_S'`$9dV'J<,pY4pRW9^efZQXy,ɘRsvqr3tN1LG`u6u\WYdRRRQNJTb& x98v"ԡ)Rl*ii* +`ݓFȂ3" #Eh-H4%ǵ%#'z6XzM)_G4c$K}D@'CnaphmL85sP~H̕/,WB{ШJ-*`O-r$7IH'J4SrʧbrYxCeC=3`JdFB y[1]`YbbJ+>w}QEJ_f`;K=|Y\cuU]r\9:D6v駂5o5 DtP $Hޤ@HʮP~b91}gdeA䤚6g_m@'Ib^@:Pyj;qZy/2"r{dG臓o-d(n>ںq;_*m_!5Nj sMNi ¾Nsjߤ^٫|o^'T3F%-DeH,R9M1/JI;2ľ%%1B7(؇`ƆVԬ&04XR;ffViIM"&&FkSDsiMf/G+]m{cK)61% +%`cJl,&a/[B#"Jsϐ2yzZrIU*Sމ1_DQI03oHjZA1p,nt"">x 0ONM `VSC/Y:l"*P 2yӇ{W)ߛͥ jedl ui6Y+}GU+߳C / / ޿Xx7k$z(Hà v cnh3la(]`HM4A^:!Xqջ,+aE#Jqzx ڸ ¨׭PaZP܁tHw L4k: Ѵ^#ǟ _̻/"5)ckU`6@ (M<}[y^ Ok<.Vb_}n p.e"(_:KHMRķI;<Hpq5ǬQE1<΁o :8 uJ\To|Y'bJhEJya8LMN*L "=A qDQ=o&urojh$s E> p3V|61^^bȀAj̉mB~dmv5G:=a4Pwt@0 8 RZ 9gj%`.Ea9iK꟬kܲ'm~:_+!A~& j1-2bZeD*eDdD( %#o:)e8 o+~CIt_fK$c*/"CC3R41/r1|d^i9<#O<7׺[GMze8~a8*/67l^ FFtz@w?RIZ.%s\&-'wAKw9~3MfiǗ'c[-^WY\Sx/'gP_P׍ >^akH{}?ypn8_y7 /ÂΞ }O #E|syР ڕ @-×4I.vB6qeP8D#DG?>2uP^ 9<5㘙p|c(4t=GO#/_Gs; FLgWx+RwɧN}w|z~y~<;<=>^~>=7?a+go'\;w8k";VW Wڏʻͳ/ Մ=~xtr' (<DA[ex_x8A=X/#FLi>-eq W}m ~I"ۢNg// BNGlL 4:#}Xwp)eDTGejf(}6 IR-<'uT'aT}YGHnZ摼llQ%$#i KxC\ q*# [: sE)"c?ħ@ɞC6'z6jdk}~t;|ԮJ棦sW^!.j 1z8gt>uKt#e V[& 83t( z󖭈&MbFc//*髙.K4,\UL× \XB[#d %C+E29QZ؉#`c'IRWy/s*ma`H7J F/cKwEJb9Ed6cWRjCZ)Ts2g->/ 1^0uJ%s͕WX57onV,_3{&h,$JqQއHˎ$uYlw7 ^W5JQ<X ~IߤT Y<2 ԥ$S;u B BO/#S6hUf  a-$/ hʇ~C*KRhUQ ڱc$>u %RB5A1G鵁V#ru. Y *(  <\:Du2Hj!sa}[lDSwܘ`E8uǕxJprh͇xΠb :/'+& Cgں]#xaH:\!;UAsR8cshJRx;mS `>4S,/ *ϙ>9/)Gy(rS:P8Z\j Yеes L=`Mƍn2b*HKEy)QqPk3^ *Ydy^hWҶx7@qw0+QȎ⩻Pܛ7gpv^w }F~t6vO"F S˃t5yrM_x"#î+{:qe1ck5!S}#Etgy$7'bg;tL87É %&-ﴱ "|{DJ'|$=d6eP> ؏U*"X2m׊ 9o*9R$ђF斢^a7_=x 89p|u"! VAޢȓ_Qmb|F};sx Ő"T[=}>I$6p1c~!$ Nͅl)CUBUlMK3+v. p0eRVChD2r+|ǡϧT$<VCQ)U{hHZIWdt#6pⱣT(N_J 6MplIfDCd[fNIecWA잗s}]GeΑɥ(ǧF:)+,|IUQpձJg*3 CWׂ4zCg6`YB%mBX\y|&n{9*>f.Z#t,fUlg:[G&m቞7B(4[dDaJ#0FJJZRZ^-7nNb U!ڦ挓h܍q,B5st-W`&:a׊tFdq jŜT lޒ@ɖcټh*.*x .Qē7т "iA`{:P5vI'\ѝDm+nRP *H{`$?M-nS$kb۔6Дb(.3:Т*GU;-RIh%R0.>O%8%֨s6] !"p-kwP.rj,e1ZQX+\hV<`z(X>!ִ2 S^&ϠUp=G7SFl|b F^c,?V W (X- CXJ֩i[&M-,˰Op m: CۉiSxhQM TbUZ4@chqPZ *P붾J*VCگbmk)Zmo1M0MZJ6aںvF[)JZFqߴp \_ -'"4Zo7Bac4;c<q8ߖAnT\ ]PB3i m5(XNmSg}UEHg"<+ʙ$;:AYoTmnt(T0 GLqKrAϏOO.ߟ잞տnw$Pm|]6{QhUؑ([JrLO#dFj#T#%qPdFYw710E"02 EfWu݌]ek"]'ӣwFc `fa dp+xƙ*SMV,$++p o@f5Num\jƴ1UTt*P5LuMuSl~٦xjnd̮`Gl1 uBw_gHBh ҷfL^^tkY+DPMm9JJb28[k'ю !%U8 |%_-6Fțy{xoj&̙ r%.%IVP޶t4[@P,I7oуƷ+>+T3s^^ˑqAJb,Z|i0ĆQ\( Wf@zW])ҁZȊL 6hNk$mH"H[DF*'ϗ("9DE$" /BdP)H'/"yJ36NSy1Y.|]~ yߩ 8޿Xx7 Iȩig/2#Ӂ9LoSf}m>yތ>'M{4~Gt&@M"߄,b)#?a~2$V`O!nI__bF2NaDY\:]]JlPA#{]XΑD$fa.I cPcEVo0muM+xgڡJ&N4jxh5<5lv i4ų@qE:w/^sF;Y<`v 6^+فK-[v٪,`нEp)_CR``hīGO~b0/ @/K4H6 rȩ'6RRrrrcGVNZ?/K9peu)[be0omx%<4_dĊ2˪doLs-PbٖTHSR6QMl(RIdo$8CϏ$0o( =#~|Y#х"H.=t11Ds9%$`88qIh}_Tg:'bagHC-guN*{ rx΃01Yywcg'$-AQ4I1 B$u 6끿o'\B v:>d|cB  A1#mA#RctYWgH9D6_>]#݂&bF܀}cv ,+Nzvq"n_|[o|мy2K#ˀq{\Ģjk{2&7KKxM/F )JQþ>/9T^ϵMjP>(q++LFV\W+ Ҟ>J3́][y6L zjedYP:y1SQm4 rU%e&̂~ FR%k o͟PDy 6. $,2eӀoȔeAJ6OC~fټ_Wf&he3d˦P+FP7F 혥*d\nY+,b#їO"ijk.oUt9JǕnY8$n- 1wM-x5̪ՆY]eKl4NA-xWTE x۸.a|8cUv6g 6wW= .. W/}I`1MԔ!O;HrUBR[kx{4Y=K;)p%]u5@SuZ|̬ӹ 'xvf"8dFy ~p!d' K{+,(YfI ZX<5Gk{Y&ضg;dۖdqk2ˇZ12,l첂p`] 7S[mM+\%p s[X +-|!|E<"Od#O4ڂQ]5UIYv0d%N6 #t"U2Wod\-c #w84hm< c-RloUTEEPVľ٩isUL~(dVx‹sUv.) ^%j5U?RqfJkVXU_bObmVUYXԆ6z2x[*]9t_GCE#U/T98\mD!i3nb]V|lMtcBeO5lkqeF-ljbHV[NKm9 rbYC7R]r|7ӑk}s}[9!fڒⶤ@_Z9hkyKƒo'#.b5RE1{3:'c8 t:jx 6i=|Lx,{g\_|]Tm>Gr)h TkDo$|'S앥O~>ẽ_N_}Ly1Y.8G;&'O|,'{)|^.9rrLp/t MA]Ϙ={}ok~W)D_y } aC1PCFL$x w75sd~];y`|_|8 Rl>-A!ɘsc!eC@X FyY:!Q]aKꘝnݫo%vmXd#%PE+ ݺ E zA`n1Ǭf.;3!YJo>0#,zaU%Gp%SSnP٨uI[+;k{*pjUF3UAHꦊceAN֤an\Kr|IEvY &^5Uj+(p4h D=az(zrVb[TAd_J.cPv++\idNvVl[lGik-[*`TqWS`[k|%Bpu\cQڅ;\Fʅa oPb \88a2S_ I\NWK"orW(Gi#N+[KIҥgdmMFK *AT ۣK2w$xޟy2t5]u{-sG?J\g"NMZW_o|=ɝZH5uo&sY3Y&-υ 447SAYG|_u ӭ]*uLF /F}` $=IHc$'FU"$3Һ]&!ѐ&W4п05|UNkش6 |t4+MP(!RMw'W@y{0Y$-ő-dYZm^əC 9xgqK'y9eYrF5Q}+eXD!pM} ,  mk,赜 ^ghJZJV`l(r ذY\@ AJID 6I2%9OxSJ6:^Y~mQJx6]fMKVziܡi(gK>tԤ"P,eLٱ&ITq/kմeHkМcg'>)6$zLc)VD8WHREVܭx`3 і[Rµ[84_{˵5mK4vȮڣ?rU8YOs/k %" VC GV_W ͯ)K(~$ 7;$.g޷]Yw](*^Н.`@:=9EClVe9{?;8{q~?M/Bc|!΅[rhn >y?K[{RѤ6QeFw< ' $o.hn_fHU^2k]=np@rɩ_0/3M &5`Of\nv|MVݛɷsV])Eogfi@i `k'S!1xS, tc֊!\Ӭ";Bl|2Yj8V"Wp$JKv{4 N7B;0{殯p.<\y NaD*oF%!pQwBk+l;+Jޚ$N!8}V.rk)H Vj[0nJVPsQJݧOI#Fn (/9CA' T3h6anPWᶳD9r(4 MkVEV">J({++mSJYڊ(nVzA#۳;b0mdEaZ9ć8a-8xdS22.^l_DNBlzztcdp[1ͪR"7KK+banpkϨOP.\M~8YY17 _z[eo@4{ٷy- *TAh IB Pr8FyoRDI7~ިN)1ynD3OK/=s/"a gEIFGtV-뤕TsFg_= > Sݙ; $oNÄP|1d+bK`B¤9GCzgZi M@neznERS?|}须’dzΪha`(g[)鮼\JPu3ٶ[eq!qhNKFVWgUp,bҍ^"h5Zr9*oڙ5aa{w1ֻ;+B>`< Փ!H>[#jԈf70_,K5]EƋD]o4lAǮ! Kf6ufk{.W!IR2-s-0H-T(xqxM@=M㔟 !YVV?{6 S`3ﳒgGn̸Gݓ^N2\DږIET~7 $ENG$\4'Z CC*oǙmqaE=X_ST0`a<_Chk='9Y$11q};K$z.B)or%u Ea@4,w:ʚ .*=HxS%t9[[Doypicэ^#tށ['EfOn\{˕ 6i'+i*Jo:=Ar=⎟J ݓq3/zU>9"/.CZ;{ >'SXKUr&QgIC؞td2)2\QJ2)0a(pHinƐCsg&L{qH+p~}5?:Yx._{ fk?܈r(s\ APJ%q*|@Ts2˂9.`n8*/c( xC(~QZ#jru1go!f(#LNmn{w`Cְ\&@o򀵶c hA%A7k]6!}[rO> ŗz1VME_nC#V`FAo첯;L%f՞S4E2_/"=ܛ{< _-Kifoʦ r"|S똡o஑؞#܀eH~tqZ p,#@eQmZ3't(A{?{ '{a!w{W'P }aV -`.}:|>' ŲpBJ#|͇yV~.St)4yNlZC&S^&iQ+T ΖVWYh?5̞+KL1앂vy{q~}q+3g,.+Dd;_xr~|:9Pc0NFbX= qdo2{@ ? >ѾPak(zE'7(ޒ $#5= [3\.CDawz --M巸[q2 ς IW MoHU$ AO4m"s72wPST)z5%Y(_#굯?k.d!_L  |i9X) mK93=#7)՝5WM 6_oOY 4&5 ‘d$o+/砟!x e$T<朠<^I& >:-x -2JwytY(c`[JgP>YC [̋Z*(9Nm:B+"O̮xZ`]ڕv/!w?x`ThTAl?V@+B( ܅*mE`fRnou.DuQ@&G}'pP"ȣP`Ҏf攘S>S E/u8-v]gҏfQ经p"}9OrYk};QvN*/;DfN<,1˶ P(ܸ$]qjTq9֨2RZЛgpWpw_윴 ZȲB []Xv [/f"mɚKZ `h޻wKU| VqF#WͳhN4O4U4z~mRsʚ<(aj A!i2iS@2 *mdBxbɁ($RƀB'A$F sA a KD.>;Hڗͩ.@,zpdMvθ@pLzUbWV"Z5cH'td+]ԹiqK@>fDC{]f C{dME[Bt}jzV ;@ye[;H&rC ʛK6=UK&.AƪI閜(~r}jxb#&VdTɭ҂%#eDb>XbT_S\dSNU9qHO5D?HŚT:wHX5zIl<fM/zt(Ҡ~bpKuGF!t]n]!3xB^V+!lCj?HMTݖMˉ*QQ6: |ӗZP Q1!K#1!gDAdJJ9ٚOCK@Z<7}*.$x8 )#s8M`/d1FLFF1"(mva%KU#F 9fZShSyP*םE#."6dIff }yR&ok 1^8I u竄vSs>w_<޸_O`\٘އM7F__F< \ĝ۟-ton>\+۹rѾGmMÅo/HH94~ byEH<2 CS# ZؐģpGty@%0L=GO+qe̥UOuQZhЪ͙*E<Ƅx2#?SR~fTrieG啵QȨ}om۷\>z{o-=-X.<^?{ ^]Goֳwg~{ \7l`-PP!pנ6= =[?;xgQpva t?؀|7#.8>`;(# m-l *@E=M޾Oh컲u0{46qsپnm8tįpW5{t{$. uԁ$e/ X 2KFO/g7a:2cBG>0T#d"$D >8B5'ǧ˓iɄ[8tGq}\R3tdDEMeöbNӅ]QMr_.~3Qvtj݄uٖ`/n{ʓrwWjz~>t?.*68?_p|ss/ 6@*Gȭ= D}G CxRyGZ>x>t~vSf8# ;>=&L!]B=JDY@JK(о ^.wRO9J)@H?aL W9%K[dN`n_b9ʔL?KbO65U{'!RHA9<ڮvɆrCC'ZDz{mE6ԩj$:P@ج5MuL]ٳ`Y*n\r,+4\NQHS]?6>N$XFp J~Z5V*4[>ZdK+'z("+gVP=+h T ƁiE=Vj ,$ȀǹvZdzHc>O#zʐvr$0CG,C<  P!Ϙ&&cڞ(' ж' «bܞ(' UF=Q !' B }csaX*^>痧Ol62Xgej>?0ݓE!q$j"ͣjݖTS36nWX3;A}}Sڑ« r@Hűq62:f;zPjuKh'vlgAdnN _(ޙY%r y"D{ޤMoȷEh[&SrڞV+7_5ڭ;Ƅ~cI-ՕKͅCNX)}x^#ZN<BikTKK{z}0V"z7,xPwOxuo-?#<%?ket߆]R^;Q5׺W [8fnwq:OI.y;*8ӁJiVKȕ]?AggWu lT#!O-d`/M_00d8Rwd~~| |KV>_t{O eaױ@1ŧۣY 7bT,J?Rۢ@pr+8O?W+Tƈ7g/yXL;==N>QB4[ohUh={2c*!J̝Y]Jb1q2)B3wN"y[v" Ci\<:x`ه3H˄ɚPO/6%$QRPwxt;R.?J "-pD 8B$@W=٪г8O4|ދ*94,4؅%8;90VD,hl*Z ݿdž'+()i&NL8E+g!S($G[6"ݸI"K?P#`XӀ "6R^2TW*l2od$1WKi2EmJgb_] 'R`¦h#RJI/lT1"^YULɤ2#>.-;ո` (2829*e& B` ІcIhٽEK9_ n-sk_򺯃ʍa{Zz^U|FY(IpӤH$ 4x^+|* 6DCoMn ^wFX(kC֛uZ nJ5+ۨjtiy4fl%r6\ ,z*K$HfmX;s'y oPv`^PZkEUރi?zR3#]'?8tk[d|Zݬ(x{ s5U݉ri5YMb@m]{hJ!)rd- %??BBq 48GaҤ|49Lſ@a§ςOdqi.S#Op?1)yU@րyeú ~ QI# bJF y|7~.j.Ӈ!~KDvC^2[,UwZb~@tũWD64o.lv7^BWw۝>n쓵=_Տ$Q@Zh6JG ^o8 ‹8A]W|ÅW<۠mi/-)7~}a_ڟ땴;~Fo`3x_W]a:UG8W^gOoAo.>k wš8 }0цo@s7!cd/U-=qgah !dM񈔲 `=68쀟ҦeHϮc?Á^}¶ѝ03k9[[m=='hݍA;Z I[y@oJmdtffyFܰ-0T7h.zJ2&p: __M/΂ʃ32,-wP #h7p"G 5˖a.m}V+D7G(qqo3Rœ=?07 6~O;,zIx3Ϸ:Ġg`H|:|I]$kZQEI"TYsK׳!zF#H-d%yy+}'EfjƸf.=Eu}Hx)H{i=wG zpyrCȳ ZW쾝Nc<PA#p@^ ɾz8t┠>!ModiSn αG0e|Bnn|U|. $~Dq(ؔ_KIz'ӳۏWS8w#;U4~)YowrQ缃U|^:sC!7[΄OeB}Kktq~q6/kGv=Ƣ[pf2tB{TzVS> { so$Z_vITZ.zʠHfPm1A瞉6-9tg-sq冯}vGẌdau{*l_i'P]kD&a*ަ)VokT]-pxۯћ3h]eo9"! xSXĢjwõ[!g7X>5;VPevlE2fN_QP_[|׷ '4$Lf-PWBxn.{A.c^ 6'Sd$hu:i*X#$xoœ=՝bw<?Wg$lyӅǭ`AZ9gIbStzk6sP7e ^ 9v;#?i|-=:۶{~ OK>~[~]BxA!zp}#;=ϒL_O^-/ r}s,|tnyVVOR xa1{)#yg??{j?, 0Ix>\3_ǂKą**\3AԂ$HUAwA_C+4_85@pkR.JC 4 Ke3ɰaZLH)nFD3Γ T|=q=y̝$tWŅQi!ϲVVs҆SO^MWpҗFW9q+IdÖ_,TOnnKqKXu 'Q·[˞n9ߋc#`UQ]X^E"nۚ36m"x <>8mPߚ$Ƥhr[FIeapq -"i k5Acu$Vx#ƏY BBM ojdjlLnJ%l|t[L(ț-qJ2`|(l2:$\qq9GK7^w\r]H;޽lp.w87Gܞ|^{ `z3ظ ܯGt?k_XTvA?KhYҢG 8P&Db_nE%=3,!ezE;e.?wOΏO'.j52޶Ȫ;$ĺ Hz[GrfҔABGv Sh}j͖g#6t@en<{ =)Iޤ1sBu:);m I\G_SΩ._]bSbjG'A`ۋp,!6SiXa5 9Ճ[8n 8xίOt !\!_Q's{ao*i9_=X`<΢֙Q.S!X[!,]~Ș"9qYRMq@K,s>tά Ay?!{04HgklUҡM0ў䰽3x ˝tl/ߟ? O7>Mjbկ 5`/6JhƬ+̈́XGj3@ Bʉa' x^kP,J @JJ5(%T>͸vch>7_ Qc!vH(_l*\͵hQ0a6tsA7K{InW6:K=.LqNFY;&jF4$UZ*ed&y6?|2h~|pM@E> ެJ\/cPWX\1&:-x~NAڳ{R95\efyb^ogwyyLhA"p$cL', 8O&28AěyV:ꊄvymTTܞHv("G`&\9~MCXoy}kf-a h,!p^49֕WRdp)w.ا9}V֔q$6;'m02jM2ΖsvM&r)r amΒ!3aUNՊy 'ye935g_ :c6{pӟߏ8y|L` j7FxPAskA9neG2Ƴ*.s`=gN0рH&*x N" h^iݳ-$PnQu^:gjPc<̆wKjg /޼::1;:1y$MVTV𢾪=(57XfϿXϏ^~(m-$E%I[pZ!\qZUkE\ffI7*8dPG[~lfo}^鐺{L^~3mzx*+L,8n^;a([OoVD`U(^FMMu8u\TPN1^s(f*IE%@$x6CaՏĕ]gNշ1d>T5LXTLnݩn#y/\ty^'B ՊoW޾3۠P)bVE?UKj2!ik]6)m%r$t$ ?u'Iyg8etpG.`1gE! ̆G(eT2R6c~SHid&151)-+b6PL/㳰i*?!yS9.@2V9s襐WP`~HKV]'d n ԣs:mO%_*gָ%TsQbm)odN [K,8؁3g3nI-z6y/qLFPvatٓķx%X3':7'B _]>F_Ѧ$eO/ t<+tdҕ), =|:=>D^3u `hV| >aAm ȽW08&i@J镤 bs9fȍfo2E"?wIuyO./XLQzGF}3ƒ"| Ownjyh6RT{@]| tA6% \f YCd8" %h)yuC/KCP" ^^Ɵۣx JD^@h`|@iRY 11 vĴC(\pb~w?wQ&=aoXu2;m 7DFsyޑVViӘ~^:+Gʲ ,gxtXgPGĺ*ȹ!/dJ^"TIO_;8I9s2Gxr/[%Lgk2KmgYs/JxNd>o٧3'$?0PjjJ!ֳ)y"E]} [HҏZ_زo]͗l~del> L/cIqK7kZc]8x1kAZ6;Ze@ 7''>:)V/CRe1quJD u+4b^rM%mԢ,YDF FP8TJɤSHPHp  sH*lOaXEqU=^fd4NTf[Sm?{!7\.72 9~X6$nxM^6ӟ8Ua}7Sg (z 6i|dW+uh)3FK1idGF(SSi.*Eݬk]β) 9 #BhU'_cȏb8G2},B֘G Ob<ڹ=Z5=ZѮ"[׃gJvnu=4l@u2FfC 4ng,5K됕ꑥw{\J`͊oz) 8ƙ\0<儙CQb1w;DCtPindh4Y2 &jP-ePV6KU6$Wމ^\Z&,`껧/ 8v7 ArMQ.hQ9ItZP14 ɫbMw&*gSI$^U:VZ61NK*xwRt0;hEz;9v[?lb~9b %Gj!Pu:,˭rml3'sX?K+ӋT_̮z*Kr}KMGs|Ϯc?Ry)<sEWZIzԋ5?:#Yst娳_J&Մ1l?yN>QXz#Z8:aE1b»c5Wu2x,Rkct`;GY,4m0 B8gקd! =W:-`>[wE7ԁˡFNHO\k\0 ?~VmIzὠW7|[99|n=n3޺u{Ժ=nzYw\9{oo l}{kdo6|{,][6]"h"(՚Fed h ɝԶd IwaB9l!$hEGBFm<1:0kx Ө m<WiaTtpx0(k[sj͑ 6F thcah xO`0On *h 4%1 |<[0H ,QCؿ/oOB18,akL ĊPs[KpY,ZR\5 !a1̒JZ()F0\J?9&2}x<H#(mFx!y` "߽ }4 |4L|STSlA[bf%ϭ,pFرShP҇d:lOȞS1F9눈 E%qd]9N=iYTųe۩ld#g2wr!ƝL>*S_E V$5TmS~{|+h@D jx;>R𮙻q3ֆ{:q< $Xz-x RS|@8\2!~>tˣ,ѻ᭠ x!ExFBXxtLC;xKoaE,~Q|$1/N6GB[>JJ yIڎjWHֿ++_sl&04T^T) Q%?#џ #$^Ԟ*>H<o?ʚ4-pYp{ROC0`}_}4EB-L$ƤsՑ̊ZcQ-:h 8k:E9MQ6Q03~bC%Njs$RC&iHM&*|>UOVzN}<؉S/fI} ˧xXpS"cFzR^ŪAptIaBc,J3y0+ z!3qD*y뉉Q0)&O B&1ҁZ`?\T9_cŦGTϳ 8$ #":6J -QJͰ#Uw#r+ q!w$o\yҕ-([˘>`-l-*[ZŽi™j\临ږVۢî-^›U_:[sY|{Gj T+i5v~y*K{iYRb<M3tD|ԹLpQh/W{OB*pc .~enSd(9Ȇe\E,_+1\e㸖9Qh.@J%.J{y`4/. q?G;OK)x :h!ɋȢ$4EѭWY5d/F\0J\SiT[ZεlVek;8.rdTO9TarFŖ|`fVW(eQ_Qu<ܮD\fD(Z[bvI˦h\Jc[Lg]Jza{Lp,=ˡ YZ^W1G1GK~4S> E'ilTc xST[p  3ܲ6TЎE cQp+-Vo.bK`>nl.0rГS4/]0z+Phۚ$;'-Ňl]Zׁ6CL݇89" I1  IFF#QZ;Fq P(mD'6Z6mh_ ܁[5WRRsRˌ GjRKs Hu,o=޿t̖9r/_ :ڂ } k|Pe=w_"ep- )>4 ..5[$nz"s5k9s$ kO4u(gvDSP¹woW ps8K!egp ߈TH(o='z=s8nGiDHH BBgf䦳%f;5|E|#g_ɮZn<Vn{  2eX~v8IКCTn͑1Ȅ`?ITG> t,/j(:KJznmm{$ORՅx3|! 0aAJyc( vwCs0Aʗf.T2vctJh=6L \,C)}džYdKt;;s Ef 4 ̬Y$ٮ`i} &,II9;ޞvu|5<=g=p44dLv<1Vv݃$C"džLY#i&,洼q y96z܆ ĆLEuyM>u,;ݵPzO2eĐ1szJ%PH֩:vtl9ȥ5EڋakOc9G!8Yd+Cr5ׅ`xx^˖!'ִdgBm\h B *6MQpazRP:*nRLbr2g%`dj+DDAvQ `=}a6j2}li| #mǤM9iklF a;wa |g1g+$2' c@DU[8Hi*2=E9MTT(LIskSLB˚ Y;#/ c,H3o&+ͼkQh`άz{"~9f`|B.Qf $U\!' A%FIHt+)l((x0y7MYf0COJoQ\I^az f9ܺx7&m9w]^% KǤG \nhAX4FǞ顇^ӑ1~NoQB _Q8 ncϳ%SӅuX.|LVCR|m\m\O/B?m$0b j%ױab 87xͰ^ۏQSz'9RJ/hE5 ` ;@~֐>g{i,t!uYrۊ؆We9y;kl7mβnT6ru)=o| P{|ۏyԸ15P{2EujN _+7ftDP]{q~nsrC]aA3~h_F~eEMn/=ճ/~׉p{*ǗwD eM'&}t1`3 ba<ˍ=?ӹ~PfqˉEGG p QmZ[Us׶d/¿G}B9mb 熿x7,*'gd gҝE{. F>GV.i"h%; 88nfl|Ęuaۄsr}q1=%YbwniT(s}|܋ V4F|IyAvmUĦNYda3b3 tmI>ܖ wY0֦SX_* v@4jPB\mCI뭁Gzn56»q=X`! 2~^M%sVzKoB(x-Ak hs%}D|ˠb k4-,GQV\nPaA3%n'kiI jZ]<>#8BaߕB)( nCJhO0{Gn-}TWaLbE`R]oCSUą$=Y6` g M~ҕq?WSy}!c gNK -̥ k9tb$;n})BQLX(R1'rmX] GcGR(}l O8eJLJf\HR %>K l?&jdKชޚn9vݟ L DȤatNeW%fD6$[IרmwqJkuTiMkue_b$ie*N2M_^ǓKf7ќ¦a6rڿjikX+BW撶HK'&,Nԋuk_Nv^j jmdc4F52Dgٚk9Xck Fza dM$޹bZGR-RHF0T7,|=SaΠz2m6>B>ber/٢`kI;up5>*xgrbLRJ:؛+eٞt ; 5[z+uz~The>"S+^oߐQf_̮cks64^.K-}|%JS;h>Bmh΢&('qp5ESCӓ3ylzu:ݛ=ؘƃR፴!tx%i3gv\qݮ_~!9xk4+(as@nT5n kg•GyQZrEDt29PR:4LD+"[S\9bWhS59Jn8RNbci9o\. t ήOOz#d'U''3ί@j3HYTJɔ‚2b'~t[ǂZ8)[Yϧأ~HNW L~$Nn3k&n1$I ~B6E } nV)kKѥD R =IH5OJiʟ.ίtю+ycۃ12|X8cO1B&ڔ{dEBJcg-q,oͿ&[Ie\B kL^gpRQi^7N<{ơSfxIvvinԿvi2f:4#!dRyV[3<ܼABỲw_̛a|=oE ,-F)etaĔ`XS9lRE˶D+fY,ve\O\=>ד;>  #$c% LQ)SX YvKgj]8ҳ`#B9QXhRF`..[r8@%.nZnk,ww6t*z)0%:Bu#[;jY:22x>Z0FH-LAwUM-j|L*!JJʼn$c쵝ISg^|) ~n%eFͻx8d7lեI栟aTu>[W?q>+ UV:set@,dVFS%Px㬉]_p*Q]ԯ004M[ 5MFT+MRG~Kc͊n2!:3 ܄B9=/#̏1u @ŔeHk~NqG.č:/Ćx;&Bl&x. @ mQ8d}psgMp\pstler-isP+q%m`X-_!Y{TmQ*h![q('@͙,֙"006CΥF}c)dž 0_i#d鶐o+hFn Jf_{s !?$tf l t!>Q]HX88j]aBRVK6|"8>8PbMN"^:H,rD89ῐm.V%x5AfljF%m 4M-T*ֵ5hT"Vx?녿Pbק eL+4P;1ǤƏڍ}jF\'9NN]&[ŔQIUUw1cYKFfk{51}Ǵ+!IZmgH'.sGf\&&FhQ9LG=nм2Wn\n0$g/sЫڕ2x-Yd\8 bmL+l5+gЊᯥ;Y}x'皂CeU7Yp=Փ<(hkemwk/(Ny(.SBtJإ]35*: __M/`6%ˤ~;.lUsIM3"b,n%uOY]4'=tzf~'UUrhӊRFSŖdazNIdp'KRABi0 ^#Ìh*\^>S\u:UL.-l57s@|U8Owp_B`B`+N* Ary%Xi }k왵ؖ3+n:wH q>Ap|zpp/Ah ` [}\% nC;KHOE.)= LPdhtʍkdRiҭ!ft$,};qiFexH㌴Jn`~T@^8.[kw]m%VRIނ$Kpv~ήOOH]n[sO+ VW)7zk䋕-N']1v9I `1rG d!XU@K.+(d~j^ZeGxs3M+٨H6#}jf'isɭDO.2e .?zJ^h)x1|" X9+XTH*NZ}tJfAq);&cS !KhyI!l$G>M7yUTgRXB+E+6 dtNV"6 <;? U~rGz\!rEBսr;ˏ |)P[rj1qьya5FfeQ6*] 7"HX\-(e+M7WTD#&MRyL.E*@!*}cg B+ǴBu'X#e@+Go Ў1y M@Woȳ_ "\"qؾ費m+ܝW.'SPPElc­1T^DڎK(X$XGd!?0sB`{آMѥ?EW)IeKo6 ܖc3  _ǁw\ZQbSqQ-2bѨ)K%9T>1ȢfJ]fr&569䋽P%=ұekE_!Gp<ș * 7l:::Qұk S*k_&7WM׺AA"Al>s K.FVY,Nd5:aJsg𰞺5k gեpHxCG&ҝ*up>*([3pg F$.Qs"] |k-0umؘ}U.]P]Y>]CX@M֓go.h,"2A' \f^>:;>zBԹL'˗ti9`Nʱ*USt\߀O<P [,GoMBOA 4@.>ӫSbF9$LWn3A;N}8[G),][c6rt#4)3:3i-`6'棭YBI4DS>h7;gôV7t]^f36t%M:u]L5:n-Fןq9>8%j:˭Gm[$ q (ojopLٜ{GoOzf?_/*8n wb֦yV ˃߄D0*-fۦEma,@MBNG~Ω)\1./d>*A~8L\ u/c;&r/ǫ~ Xb;2:\=a)lcЯ]^7ဋs"?܍hVaгl{T~|cΆӄvf߆FnZ ԃJC@@dp$'J,0& T<_RYUUgWܭ\ K/ x,VlQTl)^.w:N^ͦnl:L l: d9|8rzzɴ!8ϜQ=TNE;"؉ /W>?`o] 0tlcЗ-*΃ml9N[i ޙj4w"L4"^T2 G Pͨ\,#tyy.kci+ǒD0DAHkyU=eJ mr|ZT|D뎔y VUpEֻf'xOP"8$hU0)P5M%u-e]$`V=ج7`ڤ[MlpT&% ѷ$ j+B76YZlҥə?ТDK/+I1xS)¿?~l#_l$jU/7id"ws  7DrLYTweK\QlI`ʶA4Sb@ud!1Ȳx]~n' UZ2'Ƈ=df}&e^0lܠ/UŦJnúd9\9/KNڬ#dQ$q8*(ԏ| 0: wrZ,j2MD\%50GVFg]7|ܵj 0*piQKMckOEaߡnGXhæphZ8pkY_Z)ژ3I1RU^uuaA/F*VخPߺĖfUY֫5KoU j /rSfEg݄Z4#M|+){Sۜ=P).$K@oe.e|^}]M Agh&q#J0x i`5_4{?l47Ng\ i_J> S\44h^EG{s n`_&E{bkx.Wcqhp]1$%}i Q+̭-)(RT![CPFxz7 NZ̽?M%HÄ4юJǙ"g֚1U9crLoXBKezHSQYQ(T3-ϬLA).D\Q9S '3B&׵ Re#R;vR Sm!!=gIU\BQv$5qdU"IV.527P(u^,z9a,ʞ@WVj*UX#)_ +ټU,saCvm N(6SܵLua`v/@{^-&tY3gN}  ]HP٭x4!( M7C'8(%+WbS%DzQrnT'|8z#^?Sg1o/>SSy8q<ru%ș;2c$+g* B~8L\ u/;r0ǫ~ {OJGHK 6XV1^Na~./z|V'f sIX oo ,Ybӝ0 jGfSeT8W6!u[@@еp$qh\Vz1e*papM-a6]6Y8!lF?|$K9ӛ/ɑL hI ͌xbAx4r&a'!A7[T@KrsM;I2KwSf$.ybk\'W(_J +Wid4#&Q9XxY~wtZ`~EA4o)EEWQm-mBZpeUlFYFH'ݬ/yUv&Lb{6^ u&T⩆h||`VD>_,=,k2棝6:kmVt'~;Щ6m֕+Ƙ<g|J!z81bMG 5GJhw@z,̓KCp͝ф1=*gFI ;ǡ5pj$XMm,FJc{4Gc{4n{2u|.b*iuŽ~3}E~lΪgM4Iv!S?g76 8OfB v-|HG0H7 !=KѤQ+-B4x/.4e%iNTɤv,2Ft+Y}!ھ/p~i tK&/ ʋVh~jrzOMr5篞AFB"Kifʥ܅7PhM:{sѺF 4`R|/o%ىwt)iпXy=:_+lUBs4㕋a^"x]Fc6'h6 4p;2>hGpGЕd~lC{>cZs;02s&X\vHog"]67೅^#92f]L[&2?F1!S J%X7m_i2IvK)>PU.%á<_L +pExQ+ܱIZd)ҴAu jL_cAǶ7䓫Eȷ/3n&E᧝81x$i\V RK*]H(Zvh~h\WDĵ\*vA}^(ڜY.PZC搲9,!e7QXy xP!e*h?. f )&mx)h|j^[_o|+*]4]Ϝ Ͻm!i&>{<|Wlt .VEʾo_ t^b󒁙7B!Y yL#ߟ|cpe2;I˯Z5\T 8٦Yr1ed2쎆2Υ8,# ҏ c?Q9)t<tQ, ce~w_e%e>c01Yh;.}^]6%; ;eLRp.gcΘqYDuO~ ovr6bdU*f%n2%<4l4;6&3#MLA>CT]Sz5I'" qCq2AH,8ް gF̎2v,cBɛ`g^f =_ ;ZM~!)̝'-h`P>(mÙﷶSp4yߖn5y!~UbiBJKͯE[6C |Pw%gI?b:Zjf"^g&Lx4{E@>5FD'M'(I:rԞv}i9~kս3wAM{ /D7]y>W7':oW眞ɏO'pi!dӧ$_-qt f@9x'*tzWAk%[-vbIJz-/$  HP=A(sCVF ?fߍ|Ď Řf2i. Dn f,RʫPƘJ'WE"baB$C׷k7]p ; S};Ҵo!/<ݒ V?S!bC:\F*}yCZ;xBDH1%ةs22f*Mi#y*Ec"8A)sPZ;-UXQ{￐1 $Sf(?Wk=` ˔e9`2K!ɒF\#+8z_>8P[G-.PL  dE;:U84 nb5N!0(K +ΪirYYSM~rr]"eΠoV4oK2?kVٓX^J%R&d%/ITk%)p*m,5[sY+QQ h~38Ĵԇmm;Q-&5 }lwL%rsCHZ.7 %v²LUqW H(qop׊r6k#`!-<^dJۘc Ɖ%xF6C?S&Y&+ΥH;$V5ZO1sjdƤ:Jd+_LQRV=4HD/= zxzdTӱͯGG~ رYeM"h\R|%Z(wt\?2jϊ3^)r$Os>3=ϮhGe ɓ;CGp(2I('M1{JL25LF}h'︐_YHd)8(l ~/f/Jq>Aы$TNn7*d XAZAr5*ͨ9ATr3!e!dwۙ3O'蒄}v8zw H/w#P٩uQ YZP3W }tH)cs'L0> {ndYƿ3" R(8IoI~Ba2LƇ_EV_y_ <3M)J7]ahƓz0s13|:-ʁp~uxZi ycļ"/sT\3ƠA)qPl-3X[HPxقŚ[DjU5aA4-ֆ<隤I؉{;qN,*M +f,lU!IvM21*xb-8v&1pV,( DYC։wo a9:_0x*N@B*\$u>m( {_82=r ֲ8B+ۄ;0`OoRS|Ǡah@ nЏlчk- Yt{;xz~Bqz53(U Gcจ2 +_?ToNE](eѻS_$NC tBPsF?_|:' .xrd8pq{szEn끻iZq?ÖoQ*/Ov,40gS~NoBrı"}I|'fwLS#Le$P8ޗEt':\cT$لkh [ & .!Mwƞ.ԛd#sPe $9Pst_+mxlwt*cqDg(DyIXA/Y(3Qn1 IK!]FP$A$l$cP^'UIJfeTDmhw Q9R.;;:t] i )G_R((A"1 xiK q)@cw({u XA_|k5qjj\ c+Z نdKJI([^PDwvl$̢hLjLuod WXpMh(X}VUKh!+$Nf`Q*}C-P ȆrG e9o."إrFfɒ.{VCN2ykķcbZ r:* mqfdǂ &+kћ 6_M,țЏ,ѿҙ0 spiDIE'a?љX@zX b8rH"Dv*NFꃑ"p="%\49xH&rQA z6QJG'Ww6R|揄׳!Pu2 $\7W21`f2Qb6iiR+Drc kw1qsd &ǠLQȒdf-}L(4Pd,*SIq9 h.>EN"G7(s)~vdD+>vmˆxlL>^N['>롘F .5?{XxOu#rJǢh ;~sFޘ||qtvz}|CO>f?BV. vDM»ÁwΣW,)|iE$|!vmc.$߹@J .nOBdᙊk+ ;M#oO4fE_WbĕJԩ$ׯHH@Q+DUDt08I>OP|C:?[8,>[3^;]x v]ԎX3LpN'$KnLjr{d>AK`@ƭ_OZo'&4`Zp0DrgRy+c / %Vz(ve[pK?en˹"ׅ{+BX]%Q0z?i{? Qlۨ'P"t{<>?6 9 iX+J" iu4A>{0rwή 2'"~&7SĤĂno͘+W8դPJ8 ʧ>ѧ+K&6*ck&g?>Q5&O5$;mJ_Itukz7F./$K$KWH#v-.=ם(=ů8 I)T49, ba S]?)iH&AxbeDt T֏+XOyǁRŚr`jJ5 _~J)zu/^WQ'DZ%֘w}LS.UҾn\TgE 6іć~#̅Hw{*df wɂV<+,G̻]l2"}x+B 7s4^H ac`,\RoVф';=Pl9:5oVER0-s6es؜?!Iބ+ K7IVǏ7?~D)Ŝ@X8n#ܩ_o)Vͪ}nMua?tl :"֎X|l4].7R׿m{Y=i^;bƱr9YJn#@7{tf `o]h˂/(H}v۴ l)AbN B0rc$-KZ .\i0(9hSu=~,zm|h m-/ "tcc T'bA`Dh0DUH̉퓻|CV Dъ$/Aq9 y:mg'*T>mK藰vjay#=|yDi,3(l=bG*MhhDs8j"4-vW!m 4U[@=}+r7j7Lv*,LRd`v7!l#c3yeɛIWGQΉ 8pC{ oL_.diϠHO#4'Ь[d68n }`\,O4g^v@ɤK/!V]ܦ&npd|AFޣrKBEDFN&72!z'Iޤ/x0և\/_NFp);Q2Am1Xȝ~m(MB2srrȫi|+OߧJpKЎ!%~5wߗXۄlw 2 TEk,3w;h] U 6ш .A9ﯲF .}1ף30}E2{01vUfۣ?W ivWLQ\ORYՇJq2S(G&N,de è'%1zMvl^a__: h@Y2ָf虱KR bWgGVY,)ձrBEūJ̒S*&[]xXA'GNT_6b}h>q~  6%h(}ύ6l7g>z+?9am @ Q/b^z/%4elv!,WY*vb"zSvB   \kRZJnP= =HX+ e@Ghq Aೠݟn}wv|8_V G#zQ Q*Xw_ܭ 9,|魸>M|1mϛ8p{vi~T%7e܉N3%Y35}ߡ?|r^h0Ԏ˔fT18Dku20%Kƴi,{ϰ2Ƭ (?$)M>k0]'%.=pS[|hC14$aJ PwPJA iLd„ KOT~3G?B?1%fVzk TvJqL\h@Tkjjb@Ncv)lJ^b# ;)d.b_ϭmSȮЕC:0Vlh.=#:ZܘR#ʷH\Nը;uSѲqFjDK7HVWdJ~x޼>F\.&ϓMY~Ghr2Sxw{Mal ߟ|&^lL|E=>M !676ce}93S!G72IAv]>dO4cL;3"=V]DaGiYWr7$F~/O,'(ѼW9ab5i^uiI`/!˕SM+Լ­; _*&-G2 B,EGct Kz2,uQ1H$vwiRf]6YDj8z;NX :QRO )1D>Cl=@cy qBu(`+00"ׇ*YB 4G3kp NO&"^,2%D`M;jEx5G0QQ4&"<0AmňD^p3Z-kSm0Y4He E$"{h T誏9U SP/Nv=AlHՄ֬d۳ kXYRЎ홫`!qE(c[ѩ,eJty)a%$\8|@V,ԍbWg:#l> =w*b0bӳd'R{p՗{0M&h¬\WAOfM/ŒvHٙ\1ڠ-<;]JkmMe;"u*QDaL6E`MJ&mbnQ_kJ|,e|b{61)7M𦅋D f]$c ڇ } 3ٗ ;@ Ӎ{`l.dd;:Od],o39tgBYt<:<_q̒6T4nbz6/9ru y"U{L5Db˴"EFK;p랪ET )V0A:¬l*H/tXw R3DȡZ0_)6<5.A2WDUB]E P\(ŲSP.zf72.=[ ^YJf+zM@l'!\ͪ$e[(HJB#)BR ཤ\]&G9jj(eDJQ^0 0g.`#w"FԬP g]vxY߭ uʁ+k*W0(_7fgWh{ ~B^n@oWF/"@/jK Vm)Ea!&m0:l!||ſrP1uZ!"O/ѿl܃קImn-dgoŧs8'@"<4Gx8<ÂM ~c8;_fpKJL& z\## :)x/徔MXTu(~-B8QPʧ>9(Jz|ެgۨۦ WEU:/Ϙ/tl>.:lIguň(Qi]CBq EؠAb IhgLLkE(]p)sЮQJ"v2 63N;o5 }Y5X;FcyL_@l!Dͦej4 4j\[Z9J'GqtSb%u7JUu=;N@]yP#8K|[gՠ2lCkG6"F١mδŷF(@зSB<>U xSiu?%6{m⫛׍ӛ;D] CU<61t Ɂ]DbeJC~B..҆\ް2V{?T .1NU -nkyPc K{ŪDq]N1W*и6xof1{?}cˇJ-.chn T3FsN9\+_=~MrWJBmRQ|AO}-ȓz}Q虖g%-%Z.uM|rsLIUm(T%KmR~zӕ0 eUsǸUGm)Jz;LOZ\“5*ቘ+*yȖģZrMn2{C<[T}oMoЃE}s6lb6}g;+xw|4St/ۤit|ggmE OT6*ɬu=S~r>MhQf*&_,CFT9YXBAm i#f_j§CץY&h(T/3PiKuTbuT0>rϪ0!.ӱA/,̬|rW-/6,PI=YQd]ZٮI΄& u ۋYuyPvWY (ΑZAod-YC`ƶʵdsEH}!)>u{RxtIqHKcTU+Iq]tsgMak!p՘GG }:vP΀QUY'm3slG%F2*LjQʆIe!LUc&iVV9H"g%!8=S5ю8y\.]P)UG+o>1 [+o_̡opo/ -!Il؜(?DcP(?sMf#7 fku_è=x5_x㑳 ~4Lc1pqΆx6$_x_xPƆ1w4w_No.0xAXpq{szEơo >dhd<%2Яhk^+G+fXJCUNYSz_ uHaI$$D1u>2]Eb}{8@T_OOο:+û苊j3g~,G^xb508"3xWplW_8NJ?ކ6G(A+`Ǡn_ɖPeIgl /JPAo9*gB*!A}-Gj,D+" ət`r:mnI,A ۮBU8_YD!tܞBo]kq_iU PG&8b[HDH@?c-+ooo=ԓSmF/J hz?nlrX:\M? v lzE=hW3xI w)Tut4xP&C%Q1?H/͖ǏX2AC|7Õup㸁Tݐ{+M~"bda0ob'K?f;uuzyzt;px%X|mo?@piʱl h-{(;YzXCpYD3G0tu^q ֍ҖFIƲg^vnjJ6^.w_})DtDT6ILLȨC&PZ ~.[zG1XA1<4Ĺia"0DSZӕ OS0מ1\J^a:r v{5]җwhg JϮE^TKxKPN[ ei5+-J%U" e# T5y]B9?oW%i"sW '*%1'0Î$b*CzU~m'Tֶ?e7W]Lʰ(ڄFL&ZA$)_/v*h҆v*^ cXvV/&#CҎfG|mH!~BMa~^\$›Qeb깰f,rbSNNZ]Zܫ[%VdiN&M1"_HOR`KJ x҂v*Q&4uf>N5Z9-b*%bYxP_->n$85J:tlPwld)0$w{|%퐷K㘀WKG]`*d(?;VX!1!bػRzLC\EJ& Toj)yMꜢ 5P"6F)܈<{ۭ"𺔚"}$Gֲ̽b]Vf;M̔ WPt yPYݟ\\j7+rD?&2Hs :" v" O-oAoAK|jOIQpC.6el:$]X)Já lOgs"3 \3U!H_$4gRIi^Qrsuӿݐ4%(D'O̍ e.J.i2%85amsNqssOd^O;ŪLT)0:1DA2MJ\} {U^BH"a$>IohY)~A`-/m²`JU,A9PUFK)/R y*q: D E"z2t-:vGqKg HH8g99.UXD@>ULu)̼ʓUh YND<ʩdUId $Wbٳ*1崀y3S["(Ma© 8"otvE;YgąWVzS&A"Y /Ul`ɔ)"4_.V1CA[b(B,ý8I1KZuwjoLq,TYoAi^?H >X%?1eCg <́+ C$^.lwMA4}h JGň1Y4fdImf ȣ%QDfCaPI]_ "T"c >J UR1M6{qA8g|5+fȁB[o &b|j~uq\Wuy^קݯ"&*.g6:>BFJNRVZj19NNNNNNNO ݴrJZjzʞπ§ƧʧΧҧ֧ڧ" `f01L$1QLƤ1_> /PtGZ^$pIh#B>\8~'붹:CT<#9ސi |/Z%M i8\ٗ7cDA, gC~'.NARWd* cYQUOSD|>#Wx%λ 0O(_~Bhia.;:=/>kFPDdf7D=)WC;.&b?N7?'#x3 v O,J/-NGW1% x2% x4%v xZo8~lqhΒ8)4)%uv}X`LUINo>Hb{ K̏3p:9V* LWw|VNRTd`6`. _W!\z޿?R+.{*ZAlYol 蕎QUHJ:&yQRE'YN1{:ѨQMz_t8!Nk( f4$"Ӆ.޽+ՏmmwDZKΐ?05gY< 🄖p"rF3>UQ5mSZ9,TepL2?I2dkubޡg9L/~Bh~ 4ca3t7^+1ϋ눽'pzp$Ez7(&7!O"y,[xc]9 яaXмy5A_Թ,ܭR^+o `V Lʕ?a]BvZpz sUn K]5¶h@ZzpUXiB%< *)/Fw8`SLO2 ]ޅ_=8\딟8;nƴ,jѽ2*YViNQKAJ` ^fYzy.vE~l`(eMF?H_ؚa\MH hݶyV /һ 9FN?-a g3IU)O+D=3n6QG}曨c$.$Ryhm)zd]1 ½I;">@d QHq>Z ӵjGPV Avjњ46LzXN9v-DD{W҈AngA g(+~oN*ɤ4邕-pT 6Zk0ϿJj\MpW8: mE܀Q؏8: J pi~.e֓)Ѹ<z^p:DX-Z;VcZ]ŅA&PBI0d15IVޭCRF\r]],t^nӤ|p ,7y\GԔiyL+=UPk]0i7 _! ˿ҏ/)edi'6aa5D垰_+Gf GěA&g 'ܴ:LvdD.P괁Uk(̝w!ngR2qT;'bb'u~ɪ:6أɶyco|$L0GT]k]ZevX]  1}!/c=aZh{Ӯ't$# n*̗>3(B^0BZ uO:~a5zA84Sr1f]b30-Դm{HCi$d2BunLo7eX:=e/ mX_.zK r͋&}o&2nmLEce,?_Q?2b2 JŞ./g(ceRM0gQ^6J}$ ؜@z9C6Wh(S۵@>_R=C 8%XrE4L]R3_^3%̎eEy yM;$&%Vu᤬~]5h&8]?zc5o%V^GIJsu5Gc2ApL5(xJeYv_T. IYLZiC\Yn<nnF/:" H]k~;NzÍwR߽8sm ?FO<?\9O$WԝϕFK!Ft{xP > /ÀJ${'-ovW+^Bo6y y9w*eT|a_Kbcagb뮅1x.X钴/2 se s#ܖw8.힛|t2$kX˃[+c Ƞ8^2aO#P e*d?"o(mL4ruY#='캠y4l~ X PyEuWUd^f?$F1ı_0̎:$σW^7U6%Mx]Vn:]WB3$?m'1FflȤAIy~]j搥t4#Щ"YSRRGq(;Wg|:=ޥĪoFg+QQH&TOj%hxl@S+& h-ZMMG4xVt摰CSUհ6OniΏw:aqHAZQCW9*Ѳ5+F8i.=BgF]7L;(E%}ZrZFUl/R@|)##ZW|Qn9Z([x~"ZFUU{.PZҚum(`YB*Z/Xswњ-Ju !T'ud4Tfr5[weGo;7 =o0rv})5>a ׸dQ+gc!vVf mؼnD.ptcXy46 .e e{Q&#!)5\'4P`&.~Q*|+n;%lh?LIp#rSѣxuI'<<"݌˸C_ZFCʳz5p 0ԦR2/ ;M%VP"aqءES*]VХ])PZv֋sd% |ٶBhz؀Zk)ixdLEբb`7 c|2Ez/{Qq0sXQSF-W%[A c=Ow;' SB /hB/R3Hev (YqvBZGF8yc`KC!4 _JV _frG`O0yxBghl85;>i k?oü; 0[Ku65g+_1\Z1%ۋ')^&8|#9-Z3+'K֟zdD<}'AJ ̍rTPD]4n(ḓR7?7vE9L3%;k;D( l# YJ-A2LFQf FhS^0U u-)i4EزvF`_%l<[P&[<pC//@XbYhJC9+O2QI9;egg@ 6?quu?ɽ8%x-̱ 0.i6tL\CqtQK6`@_lqt#mg.!̷ 5Ӓ*X߯0ZGMi] b5'L!QCx^S[Ŕɧzgr (:% x<% x>% x@% xB% x340 .MJLN/+Q00OD%+xUMn0FSU PE7LSK`;F!m%{󞿙DCBG/;ޱi̠%6.![ʞ!ؑx`-ĚuvfP6 e~'bWF-JG)б4Ξx^5kT [õCEAb%z4$J(/[l %TTC3ݘ`Z#>x3 vq Vq .I,IUNI-VIPp,-/,4440eJ%1x34IMOLTpI,.V0424B4 s cc # x% xM%0xA _6  pC;9[!(K6o|m# xh#fx3t+JL( ,.IUpIMKMQ +$V(T)+(8{8qpq%rRa'4.cNǔ< s2v0z#3x3 vq Vq .I,IUNI-VIPp,-/, q#Ix31454s 56@ap CN=# 4,A.cN_jKbe1D5X=...# xT% xU% x=bK^n}؜@'M@I]~_xjyk?~YϤ:^ߟIu?z}&:|?{s{:|uޟ?{ޯpL PԐ>5$uL ISCRԐ=5!ujH35$M ISCRԐ95$uM ISCP{jHjZ>SCzr֩!н@]5$5DjjWCTۯ_ Q:5DujՐx{x{x_ Z.ww9yw9yw9yw9yw9y]j]j]j]j]j夎yدʯ>SCRԐ>5$uL ISCRԐ=5>Ր25$N I}!}jH:!{jN~ܿt9}g5!9QyjCTs:!9QyjCTs՜Tؒҟ՚`< X &bM0Ě`5ۚ`5k!C X &bM0Ě`5ۛ`5k!CR ]- /, Y $bG $dI0Ȓ`% KA, Y $bg $dI0Ȓ`% K2 cy3 Y + Y $dI0Ȓ`% KA, Y ; Y $dI0Ȓ`% KAy ^- ~q`% KA, Y $dI0Ȓ`%[`% KA, Y $dI0Ȓ`%$: x`PM~A5դT^PMvA5$R .&؂jR -&Ȃj ,&& +xdsql*ȒU% KVA,Y؞,YY dd*ȒU% KVA,Yؑ,YY d|Uj*PG fb*ĚU*ĚU5kV!֬BYX fb*ĚU]*ĚU5kV!֬BYfZFjV!֬nV!֬BYX fb*ĚU5kV!֬♝fb*ĚU5kV!֬BYX =*tdsq.*ȒU% KVA,YY dd*ȒU*ȒU% KVA,YY dd*ȒUU}m>ԟt[ۂ,d KY-mAn -d KY-mAn t[ۂ,dmAn me~4vT2?/yCT2?/yKe~^*R<ԙyKe~^*zr2?k%X3YY dd*Įdd*ȒU% KVA,YY dd*dd*ȒU% KVAe ^!N<Nu2D!b dX'C:"N- dX'C:"Nu2D!z;5x fb*ĚU5kV!֬BYX fb*>*ĚU5kV!֬BYX fb*ĚU-*l{lV?lV?lV?lV?=[O*[O*[O*[O*[V?l_;[tl9Gr.-Rr.-Rr.-PgKe˹TKe˹TKe˹TKe˹TKe9ԕ-Rr.-Rr''[uvP<bkX;(vPBbkX;(A! vPvPBbkX;(XBWTzJPM&!L$A5TGPMA5iՄTEPMA5I:ATCPM A5!dTAPM'z^+߂z~?T%oAI[PRT%oAI[PRT[PRT%oAI[PRT%oAI[PRԚoAAAܖtA!bA!bA!bA!`GwPuXwPuXwPuXwPuXwPubA?}wPjXQg:2Aue,sbW:2Aue,sd \Y:2!vg,sd \ujݢû[4źES[4źE}ݢ)-bݢ)-bݢ)-bݢ)-bݢ)-`KhuXhuXhun+W,bkz%+A^ JW,d KYz%+!IYz%+A^ JW,dC^ ^m{kX{%+!^ JWBbkX{%JWBbkX{%+!^ JW^ s`\X::!ֹuuCs`g::!ֹuuCsb\X::vuCswCWk8 eM0Ě`5k!C C X &bM0Ě`5k!C 3[M0Ě`5k ־w\ UB}`K*W!־ UB}bk_X*WB}bk_X*WDz}Zp?K ا X &bM0Ě`5k!C X X &bM0Ě`5k!CyG7Yxm# xi#Jx3q /K),2ttN,NL2tutML8|8srRK< NowN̜b 'F oX%#x3443201N NC=8,yZ%ox3 NK zzz E`n^BpFfA[YeXYR g@Ҹ9sJ@vjQ^bIBN_xQfbgqqi*"lK_6# x^%Tx3MKOL/HusWp2KK8c89]|=8K!"1 'U/9?"ȉ?=...a'%x34LL0]%U x[r6}|E> ~yǗƱknEHbL HyT>> -W5S2Ӹ5 ! ˷"Œ&4JE[I}[K][H۶VKd.PsSf[Q⻢LK[.]nEw uv=Ȃ-4{s-^}n,zf;sk٪ؖ鸮غ~=֟'.؂nJ׳m|Jt.l_lZg/4S[cB쀨z.,ݔtK#)%䀶/UےOnR 6K?,^g/YfMout͊mE $iHkUTmr ˰l&"_-g7rn`8_)8ԚL-H! MCs/iu^*sG(9bXS7Z -_A>>DHO]88U$Fb%mxo-]MN$?quN0ҿ#Uş#ȑ9%NzMHWt=EkY}Qdw*ڪdb.6j+x FC^jؒ~'&=.Jx3lp~D+9"HLq)OgbR՜JN"d\ Ȇ:gKtpL8etcYg'Ca@]:xDbrrU GWuEmۖW0,TRXROǷl"nhC9/e / ;BwMݬ2;9ASlDq,,<_+;d8V(.ɢMO׍ewJ2%`1m@Fݳm1Fw.؎^rZNj0۪0NӌfrJ~! w86S}v;a;Ws5mgwl|qw[5hGPyqYcʐ '/:pe+RR}tra2mM9M--~-z-v-r-n-jWbIiX6)]{MB~ŒCbIءr$Xwh\UYK ˝%nCbߡn$m[kQłxUZuE={EgE%IҢ0Xg$萳XYG]ZVV?ъŶˊ0g Ŋa~U*"&`Vͩb*cS:LEę3 K+"tN-D(weqT" xD3`bJ"΄;Tؘ8DkSq|!BLBMf `F"ʀ#D)A8vP[өAD/N tF@Ԝ1D b߇DkGQ66$6C(1fNgtχR`:Demc!1%`πB4wBBs 1e*e7N"ЊmT!1 K]h="˯zf5!a6E mbXexR̋L&5z $}tbUmnlHY"˫{1n쪕#V> zâF=rC nR/#L~*i|a<LJb lg2 M.i^Rn򵔷YM7UK=˪Ku2qe!K`OۥV =߈or{&Wgl`Eyչx,w(\Eߎx7 spoZ$֞BE:O=E.xVH֬8+̢;jWmۃ_C gv }RK_| PU|&cr3C bP`A_K9zdl<t:VlϟϚ7Pߞ+׎k>͠9杍b)j#}go=~0Ǫv;;b>|7`N% x]ZͲ0 [{Iwa rlzDql%ֹϿϿϟ=?fW=vǮLgXY,k%d)T=S:䃌әqC!d>S9T8##cg~ˈѤ 5kŁThQ=M5ϐ!m: ť$h(>@/V,)-6XeLu$K: ,GXe5V-c`Zƚ:Fաnuܵ kWmWmh(^eEt]_e<@Q^4hmWh> o(S|"1eZmβCUbVN L;4(ޕǞİ'] l`vcFw+rz1>*=7HwU= M`ЦsϮuP}EA"(u{ޔ7jDjmFx{nwy*T7~+³JjQf%ɬDӖ*|:`f%tZ|WS2w +ŻZuJ-z1nY`nCS-kG-Soę7lo R;[*-sMȊbE[xRzl{{l|m֭![_+z׊ת/l>V/($;b+'[b+͞f};N JkE([(vVN+VNi_ThO!2!ssȹEi!g}g"y%D%pUd4Mzʁ-@؀؀vb5KvGj- ʹǭ}b-xp'~4?DN?A.?nף(u%A&͛12$+D eI@oW&aEaT%`) 1Y/&o&2ePr"PM&ڀ2AZDXm3huh%:t]?jDxNw<Р9ȞLci@92ʡ~>nO6HҡkpO<pppsoknfMn&I7xsnze*-FmHVn&+E#!❵M4FRf ar7v#m]+M]ɉw??0`;`V > ypzopycp{k~-cO *#~D,wNəf _[KY9=!hr,!X_VBh7 7738i2P6dn\gndvzflun͆ ά Y7fo #`Vf_k~}RK]Kr&uApOa 5CymI, ƽࡴgvJ{fgv:5Ky"zg`kW}) B~(m淔6h+oWܡqcv7*q+*uGgln4Nwy.7tnwji^h~-~͑vowu Edrk,Jpu?iEQ~P=^@s;2t,r[-sy%SxE 0 CsKQ¹@"|b* ENL9wBS)#(2#)Fj;'݇<%]{% x|% x}% x~%x=S9?{ vΰ&!!%NW80nqE Κgf@۟R7]<խnZVϭyJUٚU2Ui>b/;Ln׌z,5;Nýob:lq{7o;=#*}/doʾ$Eq>Kl]e}+Z?^#e>O%Vv>KptmE6IY:ѵ){|,qQP̀݃ްszQ`R%7(/.XdMQ4M"`@L8)}37/yN"/z@QHDf"e}]Ņ.-P=;8pߤ"裠<;&M|g\W,+M˪X_=2$[&$ڧل>sD4\ NqËƋ9\9/k.3Z L M:.xz.`{=6ݍ| 6y4e_~ݼO˟wVݤj1*X~e~U}Mͦ4+4T!b[NHx˧ <{5h@tSD]B% l_XY~f%>HRV㼘4ՄZɈ(YGh+=X-/We\{p6<ѣP p{FkJWI)v|i鷟]2QV#gj{ZҲ~1`֟' ָkX5gvAup* +|4ʤ\ Zr*OS'7rS(ii,,fD5@Ec3BgV203q{YQpi2CJ+A<}=#:#:T#ڬ($$Jh=3 WݠJY'N9i,=jTo:)YiMVb >/5V4nU m\9=k0ۯwa6җlK]EYƳQX#4}g;n8hY2gUsY K 9$2[RdJ32f3 zJ 2j _M,Bh \[wv_3 duë;fvRSD#>jqnJgbd#dUPxcA$`)!""5`ݽQ=I8(.E]OmTӤ<AgHWGfie+OJ9a h31ׯAUd.2}f^|2>(i7%04!KL%dh{LSA[@ D :"HCo<74{@v717MN_HhmlA4&p֔&qE (i()4-1%B A!d`Ak3$Mˏ ,FXFR;Bjo%آr3-WWZhbyjP/kQbFa C/REk_T~ \>q(PQ3A9[#9$q0ma/UňS8N5YxxaPawnN-3 (bOr9ҙ'.|$q^Vb'̾&שQx>v-4޹)f߈3$Xog+{et-@7!EwƆg6^w0A> {+}y5-[Z2]G ~7ׁ8Ww&C8F1k-W2. źX[ƙZxv״/߇efAq~|vJ OK8M;*,k[-,Nߗ,EX'27NplO7>x"GEme}=>-O`TPs"FvCgpd̝I3NF5<`o!(7Ț O`۵)zLMstحp9 9LƾyP_=D ms[W-)zn']*>j2SqPH頒ILe:f:2q_zDNfHss"#fHo)Y⸘"BPO`4o&h=w#Wd~fu__o1Svx4bgB.(#&*#ޘUH0F?U>IqwwCΛ<aݸId8.oP.~2߿ /sOS+,&X`G-n]cהX*Ja4tn|v̿Iv)[yğe9Pgؽ-*JsPS{ǧyD02߿ѩnhFJQ'3;7 Kߤz~T[g*Xͥ⻥2)[yWMk~fK3&x`jգ*YCܷk;Բv2.4sՒ^sM Q~$nX~3fVxz^e @E=W(J{*aEΒJ:˷)bݫrZbThB SG\6>4P;;>w/GF8Ni*qWk2 UW 3 5zbl9ydXA*R`4*$U"$bE[VwY#u e9Ee?ARuե%BI"݄IB!oޟu)Y)ZFsڡ{l*͠C^,lesQdY Zr&uqC8|:ywmљk":?Ƴl)VX}ljԀ91Tjegdr~2Avb)H0Vl m췔P*}6~-|PM˖;k+z$Qj%tks E")ӭH)jlŵ ]_K:0k(jW}pˏ-[&.e~?xl)~?֗:vp|~LV%!xMn0)mRh.D Vl04OdܾvI73}y,yy4myoR)Qh!xCpS=ZlJDH pα$nPaz~«#,qlB-rU~oǀ\i8B^K"BLuZ +e4BFrQ;Du /f&ǜ]6 .B/NxӫwG7C̙ق6n5e/b[#Y/ͱq4%x]s6 {]< p]E☖wZΣ<7d Q =؞g/±g^A`NQ5p6v@g^\>958? 6icѱ׫s |g!QeؔIXP%7f 9@d|sc*&:hQPٚxs zc7Ne _cc:&ҏ)Ocx>rLXt=Z>=Ũd= R`c"0bCj HJJtU')>36B?Ys d-G A@erdt-@^g'>K%>X694zj8|ꁅ]VeC/|U)@Ts&(4J' 3{}n\Q*qM!2hX\5j euL橇PPG_<򀉨0:/*jH"f=x>N0Dz>qx#." R&( :$9=!e*qMdLο!49뽌*4"DwoVIɻG7w'۞yE7zTL~>5UT5L0&pX//=poJ4C=Eܐ9 Y"sfQ"{0k9?y kOz`H]@>Pzp:>d7׈7d?ȋɋS^w()REbnL4Y|`w:ʱ>[sNO~3%\<.GՅzw`>HINM֎x)R!D' F>;A^ k 7.3!xE@}ʖn <+˃wu{ [߉I%6+Lw j椴5QY)٠ʹR~*"?#nZ-k*7,uE>+I9Ekv%xM?TR,ҕu7؛t~Yn`2fFi%ck4&h0`u"H0I7KGX*]δ̢ٚNO3J4@$FgK\N1Cf{t5HOc"#Xr$t$3'jq$CO@YyN@pBPS $tZ_+| .+ck2_}㖝$~dfNDle6r=mPN+:*jʂ!mXKTV#ӱuEC숮6yvUt ~k.TFMs\FĆn|Cf8*6Dݒ5SKƧH+aMYv89?Ťoq(H0~R~v*C†xm BiwyBl%X)~1R*6סYA1XV`^-PFbҠiL,3ߐ f'~84=ĉZjSZdieA 6U$%˳S-Y/TKrq*Lc*b'KX(s*vy-+{^U= {uv7 e=Izcӓrf"`۟3l9 K76h3\ԀpnP?Z &p[:v ( ;ϓkR!+4+I2+6jl1A._v%Zöbەh>HN$W) p0&h2°WFGվEPg">HJTFyTd?ݪǚEsŮ[VxnڹQx9_D>#`bE1vXbIlbV< sczV"5Q7sC32B 'nn38|mbf+82!p6Q5,ɭJھ \xw֮9v#ng^~pm G%(ϖVpE<#m() co"DJgEw"d"sc5H^M!U)ExEXDHp2:+XS٢FyƅS=.{;g$qb^iA؞= 1N&28B&zs4GG*++E~%+{*~P2xJyXfxч./I6StƐ(tq7H|a(uT:āHKѱ%]K ݙ*@'7>ao ! 2D6bمYSH3{ 2 u3mGA1dNDMzWe2Qt<}yX X{ l[c0A&8%<.4)8)Y "uofQ.Ou?z<N.28xw/44w*b\frc^5~/jM5\)b]VlRiUʁMR9.4(Hm2":\=:r\-߃@=Z^gvy˫RcVuSA1.U }Jo3j[FnZ8ijò;j~P|k #>)d}[O7AubWA5;^Qf1MmPhZښ/Iy xT:}Pc? 1 hs(>~&u*;ڊpu,VdG"ge+O;dEI%2׽M4ӏs"HXiu^_0uߥCŋCZ.%x}[70wϧP1%[/H>}Y6C=~3wvH!-ػh4H_ i2wo&8J"f_~Q|1^&9;O1(+XzΊ˘E 9Nl;Jq )te;EMBӬEEM$q, 8_yqe1˧Iwv:ee[WٌާO~d]6X9[a=*W`;I;`EfMǃ8VmQ:fG3a[E%gSleUlڥb q2_v2l'`9\&gIw]E0:EDr?lm{@;o&"Ak# P=Xr&muّSw(JvD]UXn3ap݅Q<4 S.J ל(eӉEբRO\ NX=>*B%`FLu nu*n2[mN7!bov%,ʧ-yXr;aCd9m="T#B]v <t ^b@=ݩl'>I2'qag7I'!hx |:!О. Pr.MK *x3,M#,mf c x˱|2H>'Jx|g\& ,x.x Z]p,$Dq6@)(7WL~,%Nw o/UGj(0_n;aTT!#qM1BtOےlyWA{) \CjYAl6-yhmj"u[ Tjճ,KƢ)d$vZGAxkV'?>upV?}|l`ǖN~im!_wON1{zh1=bg;{?vg=;.в+!2]>aOw[NZ`uO-vu|l=;>:vq`{t oAϨ( @Gܓۥ.e{O/{H982CIp\^7Ȝ#uc0޾SW8(db[q<_r <8&8>FK]fd`6 G tTc` qa Γq) |lo<ow )%~<(uXiq&Fh.ЄW;o  `z].,E˥xu0R\`)z].GY.R*DGaÂC\[V4pUleJDebj|OF_VxeB#`$4ww鿗-/uV0 Z ;SZ^ڰ T#\8[`oˋhrFe'v70Q/ۣtx;]_~vXgvQ*7 ֭v6s 6@Tx-ZQ2Gm)'6Q5`%bo IHD˻~_!NY!Հ3Pf1?ʊ( qʊʼnew.:&[z"" rOB tp+2@(kb8 ̨o2>9 "g=Xo_.Fx x"byPwWV0@A<& Z_pNtgEY.x&;7$A.i%ٰ_XJ۴N˲OسZ*]0iWSRNFӑ MdP\֔楮ޏ5oQ`y?r=DʨF^+# Ws< qdҵ]h"}63BMJ2[̮/cڹpeEcN(% >k鑁ѢH de3P* L>j]&.! cWD/^5F =%Xٮlg)UB҂%WR+#20%쬺ry(/] DF5_KgAG`e?22tKLrw++KK{2¾/U,fbZU)W/  K)J$c(Եd߆]}om}tؔ'ئ'Y&>>>kka0|ǧ3g߶Ӽ'`Hu/R w~eBo.6]J/n h# Ema<(.ݻ8)ܿ'p_7ޅ*Ў-=ܼD176lv4Uͣ#B"Cp4xYIZ0Iy_Eioa/G`I톿ϱeD/ɖE,/bg(>>8^$7b\t:'V2 TՏ7kZf;[N4j6v(!؛u@ fs\ Y޾Y_Y%~ 짋/HhWcix Ҟ%1XrkJ[{ Ɓ=ZR;]aܛy"ZМt8-bP#p2Yܔ_Oe ·5\&e3!`,"!bكQ#nc}a5C.BWB|(R4H|lRfzBI@.b&ä=+iЎ%OqƲځ5jItӡ`7 $'.utX$t lp%wA;gТ~Ygfa3|7+bT|}tVvp/3;_+ll=*Xve/T{av#"mt6 1s֓լK]v<ن= f5Yͳ`ݬj\f F`]{VZ@ZuAn9=|)j5ku]֜z~}=rӎ9lcUqk,++O4%ϊםkګm;ΑHv9u:QkjJÒgj^"^t2nj!%p\]O`m/u\RLdIf^on~8xM+%0I lkq-˞Wy| yo1GZw`d?4LhŪ u= 8вԔ-\$/ReVU-N:4{ I b{e5 sk{X`3Yq`5Qݡؔc\jま5]Sz1I':X(A )&%6zzL=41'Y? Vh=fd?c@Cs.p85(m{wY5e*`.ةw᪾*_uفup] WCp;݉{| uO(ǰ#1Wrf 98(-Y3wԘgJWkq3S:( 6 x8ײ*l4$Mp>vk zp=)-fK. Ws-UG.u6 jCA_nzE,$ 61O8_ߊgw:lS17|CYK9Q.Yѫ86\o:{u\U0dT8;Ve+uzm۟r,SX(xK )#j 鉪|R0G2E  |ݿKĀR!38%2t=ǘ撤Zo9ʽӜo׍/MVp2Y~|>K"1Mzmy&IZ@Shhnm-"e ^"Dz@'yĉ/ ={k17>ZU=.r>J)zlF27/b`e}SN dAp%~, K,R < fv9vo:w6:8c2R7=;eno,-3x"jct_N3)-ENҵ')E#VyI5)fR}$n6;- e iHEzj0#TJ3-V cu¬U$sE—?k)YѦX"^n ZiP (QOw7 l%@G1QnRb T;Y3|Ĉ ǭʨrlr 7Br(pW*NyGoq;CCtF4݇P2]:edȍ}.G+2VLXC;p(f$a+|hd:53=ëou3=憿6 m Srd@gKUڵS߷< zbiRsK {ʖ{R |K`[:X领?tԈ" _kFuvݰ{m︢5acFX~R|Gp[7#umr gTۿV5l71wa}rUn~#VE~39i{1 Mnu7?.2J<'oVd2V%YtRnl׹ֱQg8Ęn5#ena2+DwI'Y_͂Zl:Fp!1Ï2?4?SwԜ=X?Ev $ٷ" CyG54`yt+ߊTA53ǩ*,2!QA}e-C?Ub|gLL"le/zc_}exnNo+eļ VWzeڵoo6ghb "Vګ{L YAIoyk,r8 D2oVě-^yp@?Y Y/m諵\׻잏Gi|-P P[:PKA ~!jKBkkR>%{" v]ei\=O#<_}7_ tVX +_rOcoW'K %J9 t ,"&bf"?/.nO'v)0CY|nf,VGоd;kߡ%UF[|Zk$. {L 3+_d]Yhey,FEro03FZ}>tU|Io wzdH' !4>\9R`SFV5V͑.MDSYF\PxP͎ObXh{ CR{Nz{'{G]`V܂Uw QL\&A<\"hgLR9tv7N+m(KWQA序H*s0-7ۗh?K/X 2HQn xnvAF(tVtWO~PE`%G0/ '%JJ}_bwvjBU21Q][z=*4qmY7A-h{҂GZ,SCg 9ӰWUa45 WMdʻ~8vm֫%g ty*J#;'tq7G??G0 Liea)5"XqM%(ۤUȐ|$hHw7{A=[kxtm { %r^1dx _zW[C|cpݍ+{/`9Wx"Q \.ɺVvՒ9/wE9 riQZ屺wZ |~/5YVxݲvgEb*D+Yt_ceBRͰG(fV{?}zw|7X ҏj=UgWEE2^v>EP$ q+K$y2>`prE{7 {t7uHl-=0E U``jG\ZxP1ٟ 5 Yk>5 YIPӐ5kk5k|ϿIg|5߅V.k[W1k.IDZ3H? 8x EGPL.V\*0~*b0<0wFV2,fi HTeuOv[nBKNAygk}ȥ۸S]!&6<źol+Cm^b0CFl#-lD2>k"2DP;_R 5'ھD W]%tt_ns9D G.mHZށ$weOM^udo~9FMe*DTEd%d5_$'Y<|G&m{W`8T U5 Y&]7/h"1:j5 ɰL7ˮeHqږVQ|g 80":^wp&Yڏ]Zdqzろq, W/GQ$`3^xދo0ls2x $=΋mqZnwQ 4E@m R9|U]{ל9҆x RӟfRJ*#Xmڗ0E$ ӷ=>?ӛS>IG EJw j@a|k^uoۭ,[ng(΅)E),b;_'w:h8[JWʮf%G8 H?)J",agl5|G4- ATʊ=hgCSf pa+{S&{$N1<ޠ@AN>}#ʲuh|KKVT1mf>h~+(%qv6J0O6O*KE)c0Ίm3hx \X@=z&_Sr/A_׌cTiZkm)ta¦ü㲏LBn+gC 2Qs 0INe7 I]鎼% axtƒfN].kY$JJ/cKPC f02j>^\J!<8f4ߙEk  d,; M]of߹$Y\,O]Hd[ a8|m~r+;a[Z__sA`pM4G&c';@䧘T B?lPc 02)l2)/Kԇ6sj&oW {"-m Dw[]:DO8!G@ďjhFg]Gk6绉f"7&sLbԱR̎YqK+V,=P[=)ѳDރN\Y4pHX mYepKdy s:oŶ9>ZZII!y -2ҟ wOE |3e$c|>vR$(|W 5֏.Smfas@s`k^.*7F)9& 7ӤD#N ZddJ&D& sytbyu!꣕DGhI^B k "‘œ!8P+\tɒvr>VdND9=˜.bA#yKA{;Eڿ7xJQZ*`\[3GUw^,]_o bEZ=@W@ذ"ReUʤ;m%ӎ TJFU(ӆC\_-Z2K+rnyWؤ#G&8lUU2z G/m_>֓|4(&"- ڠYW;/6eؘ!YSq^WvϞّEQmJ/F4v ̹ y %| 򔵻hBoo%X)~TwX ɭd TĎ|_kkxd''_~Q|R8X>Fp.QeQm] G&O?X0IK0ã a2`:$ So33YO:53`h_@̳'[Ͳspz}xuwxad5[Ey"̾?Ex0jHDE&̏H,NpBpԧHF<^+#۳Hexv^м}Q!#퇿??|X%zjZƳb|_$6Cbs,:Y-YRҲneN*ICYDтL.5 qw0 ᭡22Lb$"Lt!e;k.< i|FkB-d|9y0w9&׫*)[]}[_Qj_ FF{BK/gpX.["uckaU{B^Zy4oqy|?t!.<Ҧ<-~=y,X!Wkq =m]Ĵ|s:dPQuvnvIR7ϏvQ'&ȜhǸߍKO8Rt2w?,^?}#J$Q=fUqpFNMmEMe tSz]J<ŔPx-+dNi˞R\&gIw]EɐGD2cgl#2r%SD~t%\ОX桚Yb<(oW9UqG4'z^1ZsAeLmiUb9`|6' óŸ%z*TX?% s׻.{fcQ PUdK\^y_[$>ƜS-N$Bw8 Hw 27½h0xL_ڜBfzNzNAHz=-/R9hxp h]Ax8 ѢK)XD2U+%k {Z/^k4SU^J .M$zk@ ?,IH1<䪩_ ],YL3ѥyLK>2) [ wX|aGa;6aHP0|V|NuiA2L1מzt2I e):s$2HZ(8Ж>^D>"+_w%*5!U"ޙ]#7Cdww嫗'LJO3{.=|/v%ph7P1~1w &tAX/ 7ĹQ1Ș(⛸?-⟧q6k]/"@;dgśْ~˚rԂ1t\-^QV%=TtqIF&\Ee#K)FpH_e:CQa3!eu*l ͗BZxp x?8 ,- @U;͈7ا(ɀԨыcUD]qiP"DK1%d$Q^0;_{^lS%Fyold(zR0poVPBbZCnu.rՏ#GEi X)bBJd B:rzUR2/T1(515EkQ/•F,kJ舢'j;CXGǑE)ږ{ Ӯ?d4if_Sl|b@&6%ƚUGPe=-!Wi ?'efj9/nGf(8셑U*@  hxG ah7g*m2;@ /U!$CY&aҧROA$.Q>vtfXY!ڿjD[,3,-;ԁ6kCF9ptOТ&:1O/tYR`zضG7d+mЈ/z$;!PڝI̙i)SVwڿ7WO S%6e Gv=Uwcˁ"|#cHa׾/DM·Ov:$fN\t铮a Xh#9U  5dVĢŸ==D{Dd#KH(*"[S]DBQ~8@x4Jdd\tZCs ӿ”k5,[Xp??_8_ь7kJ6 1\'L-d/|0t`-,N__>KU~a$zi~)B @~IlWfy,R\#ĜқA\^Ofn*+xU.V^V3*:5UrxE?qã+ Km6`٠G 9>h]!;zxoWV^Y9aJil4\Y=heQLNKĵ(FZRXC 9LV`7[ hb67[V`,eopv)i#RQAF`/l bywоX=\pWy]Phf'}VfK_# VO?\A$ئ3ר}h#LwY …P2U^XW<Ein_QAzűR2VNHsTʹ,juu3~EfM>޺V̰%gQtL)^}&'߯=p۫߬ݳ~x7?xp߯~{kCo=pv(IC>oP#-H=V-Iboњ">rM zarԊ)5ÓF];~ # $0%9R#>5):=)3P ۜ6+oǘ< p'w ̸Y^qƓ@.񸌠8~U3NOT3,Qy[r[@ỹmA_˿'ŎNUOږբxR]K{v(#Ct #$ܿjˮ&q/ y2Ϧ~76k1/0a9KEVM`9F]1J˅qC#ٹ ,(%ތÖ1 ځ8.6W툊؎f%Ƭ(8)2AAiťf-WQzQI,פ(A4k ,0OY}Q i'pՔ֐p&tKHv_ڥDyaH KJKb Cg*KZrԂƧ#\ߢ(b\Ю3:q誷:]<)IntaC|ABD6O"-_x,u(;7gTI-͝ȍxR:GIQф}%Ŋ!yF4ߔ1A6k0fu+:]*Wy|f*m526S5qL֬Q2\lTO.u~,d(sX6fvqAt>Qm3pЈiK4j3[Hxm-;:4m10I]]xpq' e1EǴV]]boGkF}IU=Z5-RO,TtY" 2/zc'fcLaڨؘ=4,aa;}ƳiIV'Hj"Z[Eo[7FKrlgEZ` %Z`㺰˴-—>-rm@v17i" j Wڌ΢1R!J,7E5xOyh+{{ - k !qO@ZܙlQTFd C$1`偠1?kk8cƫ;=ު+y_>TUo x :g/ӬOStt|?vzY.ţ*'3cC傸&(vјȉh,.R+TzRYջ'tsHT+ f.8Aʃuȅd,/]<"rƌi\-Nr2I7y;@6>ߜ'( Ϥv;U_yRQߜ918(G,\:A3 |B)֊':O )Fwʌ8"az#2 C?Kq4seZm"#5^^$ձJMhW=5xl[4e]1u=QK) ~`kbޢMu4.+mN1J鄘bZNFBoM$9zI,p:;N:`i+XŘ,X~&GXs`}UoIJwEꔢq͗dט=ϼS cnH>Ϙ\i<9.;Mo; EzA΀ sSE*gg¼C _,p$gLd!4(ĺNjJGLL\p(W47 uS%:S o>f9q`J=ptp!!D#z*v濏)Zd稏># -N|"_Z0;G0Q'"&ܹ|/c;G,&D&%2xNB(m\!&'[ j;jJs(vƣ>VzHabe:bj^ љ5sa[Z~rIxv>oN@_gH`#wRc1X4#zpZ;WwޒR/\sPk1oEjdQ#ux7u̺::uZ5_2} VPVfr}۫7W_G a8+}oJ[ҝMx&D&hE[V bS]Rh>[@lЛHi*bO2PH3%"Veqj~7ji}e~b{e`y}-,)1D~6Sx茛e|of3uj .kQ6O gLs+>?Ǵ6W3xʉ8s>ŴiA)Bg2"G2w l,C-S}[nvHOp΄]Rho_+~W`@Ӽ8-z#\d##=1rӖ\^ATt́ЖQNaݷW ZFW7ҪrR rاEqbgե8 ;t`$/jPJ$€U u>7]W9aO75W+Ye3 z~C.˃<{i1ۏa}9 i_DUC!P$J ]^bꨗP4&%9['.4s; &5q7Z=c. (PZ ǀSb ȢZ%Z/CfiS|֤5SmsDFAJ7tT9qpv#F๲ wD{D-$LEF:75aul<­YDQ+0,ML}d2 .3uf|nYꓴ#@ Iyc7 #Ӵ8)gN̄Ӊ/Z+&\ U 4VB? y}6qBt^lxӧpTivZ{aVTT!V! A@FJ%j /*xYc M*iJ`Zx<68PYQ@ ;3mВgtm!EN5t'Q:MNrq+qEw,.um@FڕPc -MG0YDĥNDsb )#i95dS5h.\уI36cnB Llvo_; 5 /[þ ߂ܢTEx+w鉈!Wo Tת80#>ub @]twrgI:(g8T.1<:ͣJ(l= *g#P=emy*;ȳyNo_6w#ܩ p^6'DVLhxK@)y X oyjb/BᛓvBM#B1etu:+?Qh+BVE1LyyJ?& x-(u1:u!:Ӫ1l|D, ӔK鍸Pgq"p:qĠV_{8/[ʼn^nx-&bf:xUL?fC1^̲ZXT1{y)WX9s8٩*+ LT!2WZ-M5dq軌pvcX0aZ7 -rcn92RE]90$.b\hH+GC9@MuK vTmcWm״`ՇËxV:Mn9_8 {zJw WDa>a%,d_wœ[0 P>`0V[oyXL'iW+*Ȣqs1m_Nﲲ%*oc< j 0"ӏ58pΟ@\x&Q4a:hu+.w;nWeiՖq J&G1=@ۭ z\:uC0};`mu8^2t:-%=ƃE . oYvT7/7CZNӠQMZHB[2 f5҃K"GxsYG{4|Qr It3j*^q 1W0#a#`}`΅TnvZdZvhbRT'qӢyxQNNjˉuN`01T'у? $׈1͛d%_L|7p#Dψ Bzps y(Vܜ5`Wdʍm `u-b4!I~U͖P}wRh׎*N1]~?f`W)1J4R.[{NU uKKO&<i:\!^B7v$qҿv{{8s̀3}D̂j wdQHM/YH#76ګ](w{ykۆӋ11`Ȋo,10M%Ӛj{Ǥ'q g爄|KN 6l)&ۼM57`Ǡ1 9@[1{<;2@fߴ4Öm!q[,*v (UUD+hv-F]g4) 5z۸@29!s?dsZ)nd4؆b[r+jЁΚH<-wO$[|ysF"#S _N;B "z4:Hj؄eE)CwUe&`X?/y[5y|ʈ7~oKO(TvU-̭ eԎ*w[JF1gO=g«wdS΍Iץ "ϯ̮=vy꽌Mr1FQr->D~dR5l.|2>D/9n Xc>G[88*mHDMcW>ƍ4-Ë{Go|ҞnQa) %žmI}ol`DZlMX. 蔚=7w(2NH.TJӵ8 hj&*mNȨ'ҙ!N: ac\b.+[wN1IJ0| {oQHJ?b9K[<fuT";bc Lq*I-t)lNtH H`c2b1ϗmա]I/RO-Y*,.d1-qݱWEJ_dal.uR'ؚyA9~_2Ol|R9% w_;}>;8Yө-y]NT i+G9Y JN4g&I$l xi -2NBuk *Ó}V;5QTayW .t" ]qM]LƮ"/Eow Һ<ƒ#P.s05K宑M2{;%n&߿ܱݍ{75q} v hvϳn*,6o6l'V*ߧL;\IvC.6)dEM6RWt鎠KMKqiREG." %&FJ+c}g )n _tl7BiTr8+6]woA)gOZ .7r,r CURhp՗;/(j w&,f+{V.gՔ4j&[á.` hI21PBa{|2ʷ*bOEB[YTJ?*m"X%3V je0j @]R\qX_Rl\=[-i^h%x+8t8Qb/ L"*~=5,HP 벟0E @K[)7•ieJ0=P:gWI4X^ 偢?Bɑ٤%{GGn|> /WBʥlpq\v,;Y(=nhf4pRPeJVnǻb߇ lWnb.ymX}(f+$i^ b 'm#j#,68dv1'cB~ _\ . nMքQU-_c߁qYiٶZcE= Hw믬gFRt8O rθ@D<3xO=ePgG3Q|?j M>IWv93з^^L$>Uj,Սs-_"JYd<vRy'uYk0=3? zۂ >* l2=I8SP,s:юt 'm)+4;8Tמp" #I(3pF * ip wkK/aJY^4Jw#~{jCl[ 6ZMR30RyBcdpNba.xb5E _zހ\շeЈB!e/~5ܺ$ # (p" { t1a3'J؝)dqeή\Z] fqK~Gqt) 巛E5.W>Rz÷=I$!}D*Z7JB@!%Yt,HxhX4-VaWu[r(`# 'B;&HYr abo2ekPJ 7qQ׶ Y%linUd0iP`GPi`x}z3=I躪G1%[ʠUP v7&Lv7'd0x̾\: Cғx c ա0 0tTLE?C dYAϧ+RSÆeUmnbM?4B쬏>F )k4m##&9 7*oJP΁A!6:+^U/JKhYXx5@[K w u[,+*} TyiHikS*R0T: bb29!PY|qRͩs$#߷C&-b3<.‰-Z𮺱\L&[I3_q 9T kwf-mlɿ#E^!BZNäjJeAE=9" 7:aV>YotS.Leʟ;"_q[ǡh]p@z^z>R)H;SmnK^Mf Aվէ}GC>8{d._k,e(h&F>mZ\&x7< bztPhqEK$xSwY]Ib&Q%¬K5~kT!ʗɰvQPknm .+5Q=#!%aͳGBgK5R;RzGGvEUBƙrFE23׫eNM &Wb^7+tOSH'BHu;bT O>lN-`b5Ϝ}3NPfũ^j*PJ';8?==:tw$Ex(W1%X'v߅.%P?F>JaZ -WJ'nJvxhZὔ]{ yyiyOGQ_n rV^čq4QMRHbY \Wդ wEP+&+hT3Oxw r)U=w.@-%uaOgQz`EEiRߋZe"?4uՙ$_RȡxY/SʩF|_\9 ~h6BsnV[D6SnҶز^/ٔr]Uw)tNe}6 ;Q L|TaaetJ!U|4.WdJtE.=eٸ #AQFYDSPЮ,;]fo Iq$ о.F"i w|Ffo"d_!p/JS^d~P-ԏ^L#xfY#X2Q@z=ҁ;=&]-38dr/eu7%ٰtVlW)sh&lT,zQ$a2K]4_Onb~Զ [Be$*mnNtٗOfR!@PvR{Pabm0{^p<|YՄAFknh#K֦Q6^v PXH:^kŋ16%x=[o8ϝ_!L۹E뤝Nd:}(P6ck+KIn]Û$i6(/W3o%ϟ |w&UB!X ^}8/2&=%d2DBw<rF!AgN|t)}7җٽ7ġsw_ӝ ^(YM(${ "4N؟`u?謲_kk'}>!GE7븓9;4G*pc￘Ha$9q2QR:q d;#>=w)O K' ? *v,ǹ[O!'!_Zo;+@U^P,CgFN *Bw(dZ<tK= #P2Q&NW o9x󡳽JEٻQUcF"BD۱)ā3wW>8<2T3%`OuG[Jc44`o0H$"ItFoqY2-՜b zȍ~ѿͧJ֥vF3s fMˏҎ %UI|>{=`g2y.orhJ #fI !!z f:x"Bv0'LLR%%zR`1s1`Yz'?$h>;ulX9*؅t/PGv̦ގejYj@2ȶ^ U(\.p:)}X7<-ap;VTS-G)J9 }f9A8|boOYȃ'mpAMQ&fRd@( S%z6* ' _t')+Ŝad fff;9FGч7ˏ}/"*dkɁcWq-tM¹a$irM'œCD+ wQē[N+bg[tF5(!`b-RYR0]57ZAc Ge@lGlaqX`-,&]/Da'&gggo7HM~p&?8]OCg"h~ѐͲ1Viw]XHBqDa0}E7](V\Z!30DA6T+!@Fr#ARN'/DW rNUsЗH^B.%V_[u{Qk Fe-ɿ2V'h@@8◼Kkanه)uNt.I{G{sk=vn2Xx[~* {stCjO~H /^`%.1n1f]4q~TwôEnEEցlC@;Jfv'R;Jq?HWLtĆsibBN><%grS$Bc}%0i~cC6 ˀ+:E-&Gqvج|ji-ߡ<fOP*t=:<]lQc: $}'MK@.{-&- !As\K4.􋍸DK{ԭ<(IULΒ}Y"xI4ЋoY]Y:k{`dGܠƇP.lZjf>=ͧ@@9mi2 6~cCG ( '3@O[w`ģ2e`E>fg=`9l&Fb:Nl:+Kp₷6DLL(陘sh 4-`6f@&F--݉raxx#@qFY2EQؒ X9~C{O+Fth0# yɯt'H39ʑl!?B"jٚk,G_KOl%ԭ Unh~Qٱ劶6iʕJWfЪŧu+h׷Ji52"fL/ 驂"ڝiIk!>fL^Q`/&sz|c -Ŋq!Dy5_a;ܦʻRc \.7iWL*?o&Z[Ofês蠡wzީLacJ4V dM|!Zd:2LxmjEKo4^b T;~B[h7Fre^0]%p{{gy iՃo dIBud-U僲؎@=W15+h@Jr1uVV[@}-;7DNJɫ`q S+xh!87 |,^@܏QjT!;d4 acxxê< +@Ir{Kvw,}R̀"jA=IXYAe"ea)~qYQam]/c tX4X Qɏ % he{'V<(q0\U"X :Q~!HEZo`[#{WJRHS _ 1M+ݤѸ؍6M]<-|3t_V*ƕ^z5$(ԛKMEpU|8_Mźǂn ơzRtbC]t9W#c+W]QaTc짵ZkF5$S˴\ Iv-|S H;B5zdtF0) *͕]e'nXP}<6V3d(\! 0x~_L٬y>.Z7$XgMC+׋Ɩ4iK+ O$KW `R*6 t\GE'RGDrE<+k7 @ 6-.fphE')rm:pd*ּ[*VL`[A8L"b?QD(eWRF\Pt8Ϝ?f͊O|Z/B$]6oNإ޴,x\7*rUWK?$oAr\O`N$ZW2*bWݶBj[k#xA mp |Ԯ$`CYFXVRT)eE%S%٘m&uY`1 Ӗʥ!*\+| o0IHԌVt[<ݎd5q`qgkO!uƮdҢGܘ*Yl>& ?#wޱNM .\ɱ՞4bYbϿLgayY O\/̕z=j*lO1}@f>t,Z?{/&9jBq(mFЏ ?yG\):'j$ H:A8n P}ϰg %:!yeܝ[Ţ`כcVzV3bpaDțC5Uad cF-۫v˝.QK [Xt'ouEfc\Pq5[ھ#1BmFM^1|DDH~DRҼq=iese zW/UyCRMsttR rip+5j㊔;F)bqߊ5wTsk*r>wm *K}-5* Q_ vCI  1-qdØ&%5Qsi/{Ȣz VgH4݅M^7r1W7 4G+ Ctȫw]3+YI 3 ݉2Z\蛅/|?Gx_Q)g @o4IO;Kup-T%&7ή"t']F$n$-ȽHI' tp #SD>E|vg&Fh򹳉3DZtVN0_9Iu-6n"WƐ׎/iplu kI\7y4C$PHq užѱA}F3v$مlB60,j>T*J&DE~ʃzECQb!T6yE<>ވGF;߯RLi (Fюبp! &z~8ͯNu:Ūvo35L4 ˀ'H&-1"4(h1tU@8(Gʖf`']C.Ste;Xx[L~a >E4| EJmH \yoyWГp:zSB7 CZid*nU~xox{tuy ^:g?ln% x% x% x% x% x% x% x%x}isƲ_:b"E[cK9%SWuA$1Hmg!Y*[$0`~nnf_|{^/?}qR俷Ip:&8 ~>xyۃYO|U> 2Ƿ0 iyDf'HY0OYNI|,"4$^mp:N矨^LN?i~999/.48II>ς8 ݭxk^lee:N.Erm]$y5d ~˒n|6 % 'YNnc(;*<|iuN L$i=jn*?>ggI# !wtEoaZ?]Ƥf~}/"N3aP֢` [fd9%iaLNץX1'qw[&+JP-8H $9WvS,x>t/"I /vi"A)>+k qR>I7gy|y frHH+23g~z%f;yuty1+Cguđ}+pR=ʚܣ_fiEE$}rv{_5;: mƾ'ŲqvXL BƐE#M&yH ܨ& :5x47tM^/DXtmS/&h x){\(2:&ս},Dkb+ ZtiȽhu,G<څZuuu41 *{.d^T4ׅhwEޜ'H?3/||(1+WZr!4hp~B]RH*'jqX)$9ab$[Ns}p 0>d#sѠ rY4DdӠ/~'KGja>$џO&Y:I`i6L??g99(]gBP" ;h 0U|4QQ~DOz)յznVF #8?3ULT(Xv UCC{ψxh:zԝ$3#UW}՗~e=AڠKt `N78?dBɛROhݿVUcv>97/&I#ǐa3< ?QU\` 'Zt0kxhU&==OpI z/}GZBp.X}y ,7y%͊%M{Mg]jrHpL`1w2n621SJ2dd$s! &hzL΁br gj oBԍaѬ~-clj' fh&v*94 arZ5"LIi ګ0r._s**|GzT22>r.ds**|z b}TE/\X?={UQs**|zߗ*ms**|zb}TE/\Xb}TE/\Xt p1>r.OQ 316L; w[45+wu6SKQx-ijJ<&3)z Odx@!,+fG07Ґ:*y>9 kvFe'e2C4w(Se2s;y(v-4AY-4},UVa`䦆/ QP .EE^Cd0/%\)hY,u2V('CfIp?X5ݵ6~*w~JB[{=y3u~bk3̓=f)jgjdl4Z TUjƢ 5sީ8!Usp=/ WR\XE%m%%6j5X5YT5H M!>S6r9eC<@wZ`Gyfh}?x(2 ф4F.C{N h{@3 uTl} ?o,Q}cD̓#KuTFh; FwGX >WLN Lܷ| ˄Ҁ .)!Y"AA:b0.Đ`U,kWEzI,* ~ 2ӹc@f 2h]ԇ}gSΓCNhH¡2~ˌ-y,GH:weƓ8dA M\ckk\YKUVb_KRE_'IZddNœ8}2?IɶgUFga d)!,N$1 ɟ!G7 >ărdS1*YJvCïL1P/yV `,)BPe18.rtAAų%Yj_rV7[S .Y&oZ1DNK[:pIe]24C`űk\DxQDKY K:QȜ3q?/p7gӹ\cG$i=睳,|Q.ImR#ҵ_XD6أu.l"{>~Ox y,^z/ ǎ1^I2 d8,` _ދXfg=T6lqd;*E ޾T3]%ȫ l6w|Mz~_JCB'#W]-v3YX2[ܸ ?]xA8"Gn@jpў֟B }VhxOauM}ʳb:An8smHaJc Vκtd \Yl/u9ZΓK4DT2 yauO A3K&w HG[8:D֊ε ]-Ivp˒Ǧ9<7qg\SS+ v\15GD]c!6/wCJ3 Zb eﰢX,=ڰ {*͞gx \(:Q!)ZHzf[ ť@R|5H(rf$6Qg+W(H݄Utbd8u\(^L;aIXV{RDit$I뎗9Q_"HVc?}$XSy\w@0((Kll_P):Za#+j+$eqi]kQFFX`A3n;F(Y-bbsktʑϒ|Com;..C s^- g;g;9 s-qw&"&8ZR}dVqdNj!Gr>-p]LOe-FKpd08d'm^wՊ2l{C1x+%ld#>-Ɏ\ GX[PⒸS˶Y(;cPLI~M9PA%q3҈sh 3&: :Wمʤ?$4O3 VZ326b>VAxyfn_Tg`Wj%uf؆؍0Y2V&憮uK*7~dCY4p.(#wo|I_'fW:p3 +=1Wi, X9Sզ``Д_Qi$M*m&H&amƳ5IX&ammf&aLƯ$bmŴvX~q'Ӯ2űqH]Ɋ۸-e3LcnQ \6pSuwH촩'(}-i&GCR`rh  ZMiͨB`0Bc,quDY~?5+NZ9TaŦ>X.U% rbfGsnl7 t9Il7x|9CNX*q1dW0o?Co VqoC] mnC3uP팝9kN{StvQ56GhYTwن̎:Q]u %Zf Eqsh&M[70Y{ɹnmg/)FZ]h^Ej>DoNA>Ό l:POZU!n&^ b w l0s6_uVXoZps=1yMB&mw={K՛M#iW#HcP}VӣQuvw֒UTO$Z7BsOm&mU'3W+S[)1ur\zA;Bq̀wv]#9PA`juql^=>7ea|Z)%,k B1 䬊6~|~N3_Gt[v`[xm+y C=,k@͸:<$'[5(v>P*(v nIFExp2Պakkt^mvEjT;쀜=q ;%ǰ|CS{(Mj/+oc YIT'p:)x—]!%mkR判] M{rǘ1s(xF5/MV#P-M@F!*y@HhM\F=r|0O4܎aSh>3}'&w'r=mC|\Qz*<|tAMCS\N<:3}L%]"<3׾H}lcWOxҾÅ;guGfn"_<tG8cAPn}dnWe3M:. jơs]r&PuSNP{;LA6 ȶYXmf.6h,!HX9l?[ymr;Cy> a _m>fV@+e> ܘ~>g-gg Iu!y؏, ip\,Ye*2BvU0~`ڳpf8l>sFOɄtEH>`ʎ@TzKH``n|3 hO;C:ܚiv4vܖ >_y\vz:ͳڡ|CW;t6tݸpn W1Ta[8R|&q蛉C69"6D DyzG2`FRw2Npf.zznq=h4Of Dk K=fEVNtb%_r)nnbn0ۙN65v'+r~Žv蛎W5\'j-udB$wM7Ehg0)4K7nhɃvv]IֶB.m O<^npŒU# vVs0D`d>'ergY'6Qf\uLhqv7|icBa;sja\ fJKKS7T/kqY[{߂|npx$oqi2\ӧ'ӞY9P,W^5ԛ?ټFnwRknPXawG(Gv6ƌF_-S sHƍZ{f,Oy 2bsK7à "k`Bca5Hk*;.|Ʃ~<t$˹qB#6Tl-`X-Ujy#EJFG!ҶWOVeS- )Ƅ"|PjjR o: {ۛ+O|'{n6+a|>WAwġ|s2:ٓ|/jN&c?CH Di+֪ۙH*enu"- J=1dxpv Ͱ` [T 7pjv0[VGwuU~B@.dD,vNFs9W^-\zAϱfBꋄw+q5M[r`]Nؿ-oG);Z.8Q0Lm`iw"` G^* 1J|wUT͵'9\^5t>ȹ Tmo_lv}jwb6xܻF) ŵԿ0;n.oy%=@@{S2Pdە @DCwP0w;i\dz\Y%wάғ,̖oX OHq3WJjוz<׶mjO'LMGnT֝J;3yWSI+ݵ$]cSI m&")M?m<~`f|۫f| p7;j$ntJd|7ooo~}6<Q KI:[>iyr51!J|9tP ݐt6eiHfiHEѕvV]>px΢WU:UB-xl⡛]ǽV8̨JIQPغ5GYG-8(Uea 6Rþ*y.u8xCtA>>x 'ЍLjY6I/&88X)]ۭ;猊ww&k̮= {:= {1_M:iZ1< FN҄>vݴ{a/5R' d +ʊ/|g~K>74iݜY0j aTdh##M)_U*5JVWYN;aͰҰvgac=YJ19A1Aml/˾3q65 G f8 *}ʃHD>gyF"~U@;~]ΑV WNj=C%/Oc# }2NoCqSc#v5Gm丢C^E/;^]ӞݯԽmeы-jW ҍaMB lȅע(qdЎ#W9rEn#*K1q]r \UoI7^Vu4UZk^Gw4#>ܺtMy&HǕ8Wd`^m\tqG:6n `s7#J;"T?9vo߱J\LRС{ȋpc<k\\i|W;ךrid07My;y;y;_`^e1:qYZ2@Oi|έ 5U?Xbk4;A7hP?X=mԸpƳ o]YgSҘmSwà TykC俒K;6&/m6#5҅|^lӆ%9iiu<6V:PZK9~/SφZ0KAlg6R% e`51{)A#{VgP}hzgF#/B݆LY:(SK:ڥ$Hm :t=[{zرElqS$ڽ۹ǥajcuSg߃ot hks{|,ܭ:Zm!$r.Em*b$ѩ6n-6{qOѼȣWxYMy!*~|-نܭBp˷,nKiO;z{MyZ]]$4ۖkԵ!6]d 45q1yimE]k83mQ;}c2LF{kLypQ9M47zzǕ-7  U /vdI/$ÄQ^ c^.p/G˰ ' @tgoͺKBFvJJ>kUs}j@9Dvk`ZzXIj~K-Av6V._ԺvdA Œ{̹!$O,bu[4HR&_z{Zc .GUh=\/mr#3"!:xID^>  "l?xs,I<[͍4͍FFBs#\HΚR",Hׯ^+:x} {'(mt }N]qfZo>1>2Ћh:f!>c&C/BXXːTe.C<*W.H4 L:`$4wkHhoHjHܑ#57V$CP+T FFnD#@҈>Џ:sdBDf` MV~ ܆m6u4*i$ GH7*F2HOjQ 5v=Q툷 4 qE"EHPm ZO$XOHHHHo=h=z"z"z"z"DDDD QFXp 4B7BP6@qG@]B׺x Hv@l҉?Z)zPEBnpi8 `j#A;@܀kHЄ#&F&`$hbHHmAۖ0ݶdv2;- bJښT54_AXU2ޔg8#v$W׊-!TU_9kGru-s ʠVEFXKoF2=zR t5d'Š"A},|2;v|x'7QX]$(oKN.Qrx}r"MU) )-Iw,?:<]Ni "~>*,9Bw''dW~$Ӻ"6 #VмfrM'Y.n.lIr 0M2<0%i&X76fKڦJd* * (ã{TFߎp:vZlr2=Q:IqQ=#R}w<|:_\ؤO2[dc)žx37OYgu ScA=; >ϗ? Pl%l>Pi<4A<&q]&7oQ80",Wi%/'D_~~N㋋$kjلxmtr5O/22Bm%'D~Q7 9#4M'H|>Ų㱔2QT*y@0?<=ۢI~7x$ @-NYHIgHKńrM 5b3-lVU"N]ӿ֡ 76UbXqueۭ̒0^w;-zs:J-8H؟Y^,Lvc\UYwʌze'[ڸZ0?tK1OU~}SS /lv@44s >LjiqOm 㞆#j#̕܄{vf<ƚJ>S[Kɟ!G7o){# '"x\*>%Wɭ4nuSpT4E+`,4Nh;{AXdk$'8-'i/2~K6GFn8ଦP;e*SX,= ei\N#EG')t-#b*ɪTtf /֦>_ = =d<K$,` _9g&(TRę[V?  vՖH"*0^xp|Mz~@O%!YI-H)#x9U{sH,' ʛ"M"'{\} `kX@i;s%VZM :tCCxP!Fmfziϖ'Q6Yl(v3x386Cp܅-*sy;+ }CP{ oj(,YS%& |OauM@4NNC&AOUv֥(Aou9ZΓK4DTF7{#"I~8U#E`f¹&}6t;$-їO;,)xl*ssSWpf*x<5Ln /{lFw;|),~[CyO5F!lr|=9ӀX,P^+ځң ˰G0[ )~ZS2aO6+2_W+*Jhu )pWߏ"nF]orMX^ sǡ'w4[,#y;, ]y @\'+pAGx*@(d%;>Vy(h%HQBJOwP_a!3|? ΂|4+ٺL"jf4Kp~E:^nrH Er');ϑM;ݒV޼c^xQ-}o ;_w-{%Qx M﨏q鴠,Rp ӉBVZ/(~Q[BVGo4RdVH6w7:ba voD*O}/D}x^ӅuOT9W4ձy\1F{Wrڗ (Ź0Õb:A Ûk ;-e^~hHIKJn\-x׷ ;rׄnq>,x1&R<^vkII}'y z'J% x% x%x̼i̖WL}}'3I5ףw{$#2eFuWuu 'γ,_o(?oݿQ@s@ nzݿ(^ ѽ^,xg=WᎿ?eI 44k<2h2fi8"B ^g#(Ի.%m)ϿzՃ󽏮6j,5.ϓƽpI5(~\spua^Yk@CWy+=8Ody#I"XAEDGoIwJ87D=hq$D2 2l{9e=xjix`3@گ457e˹)_`.Ga;t4P+tqIˠ  xM_↩aMb*n q]8KJ Wq׽e'I??gײQMpuXc@@*D{'!2)Nyr$. В닢ly܌eWvhV`(\l%,3L 2硷[hkcV~!sa[ޘYODO\")L^/G QyS01;F4#RxU@~9zzik ]5;t#qZ7j"}ԿPN oZ~퓼h]ˌJT; `7`x9{u'-s]֨|\gڈ%Zlm>T;}`?l7! rhI^?L+|sN^e!;ϱwp]Xs (&5Q+Ei>da5fP9?LIf .V&XJrm$;8w9?%D@öZ3.tm֋VAHa.pjޚ.έ=outLz2xě*Lq_   9:\M~Wfm'f q8ecc F![="'-qGmo}0&P5Pͷ .r0)Eq/v;\<l4`/Xܫպ8b:ZvRG^ɥw-"˛ek/TP˵^WQ x}?6",x[LfCUlش&0ԙ471t QPmdz9JR5rKVuS_rXDD}Y/Pp<c|vdhGCbXA)\}HI^egtԂrt? ]Ɵ9/o7vĘ0ʲW< i:ݸMi4J!rwII>͗#N؎2@z"3n ٯL;?-rCs$#Qey]z`}s d?)8*{?HxM?dMS&׼\ս5, Emg0[6TYkN?wҿ~[ь8ٽe5n,awdY%OyW|4gj@MiV{%'~R~aŽ=&|y j+#$vs[=gbqKBxqhtK{60.\zr#t>^>jVOϦHꌇK0\1yKV~\zn@& Ķ="rzATTzGJDŽ]lu>$~+I)nzy %%xb^6F`<r.ș K1TZ/QN8@s)|ڍtcc3IܫyЄ|cKxylo9Rf$AS!>_}_M(JJgPk")UN.:wEy PGM$XHs'6;H䆛,tzUW ff,La3؅cY)"'?(*JsTdPXF@ZIj6$‰fI$V(CV"}%`0l MQkӚ11b* C$ צJƔjjOXz7C\ (yz1S*[G/B20lsR**.*kOk< 1Wi?RO̙ 0j:^X?ca3g#@ņ®KAIe?T0a6x?|L²Ӣn:Lj1?ˢةsqHNNT9fp*`q%3֙% 93uV`(Tj}?ž ፃP3Ӭ(D˩tyL"=["J{mqtki;>~a=l~ Ɍ&cN\c$/M-x`y #'7ٛ9fiӉX}3_?*Gp_l<  10SE~>o`P@(i}_e!G!WOeGp$|J)GF:%vw` PU Lp?X u#SVfWܤ,F_BvFjdͳ㗪EXTP"88*UwJoKZrAGY?Si6?E0rW?iU E%s{o}j޺DG\+z?'KEHkQ<]:JХ3í'v滫Sฟy9N1@ivU~Mcv?  ^e5ǭu,ZZ~3܅e_ò^٨$y K-٧) ǷA;\Hiֱ{J<.1mHÛ8K_NR[}' &s-i?TŌ#@o^0l^'tJJ5+i K"ra-)X[ߪ5ypEoP{D`Hz. 7Atw]T -.~&tV)(?Rw|u3U/S!㝂ij1*0ȢyR i YYXo)/d,Ioٸ!< /=줇l-Ɗē:TAc5] }Vj;HFpSoH) W>x$ ᇙT[j{ ηofCCι@$4m$FI¨hʤF;B[gAo3EB]REQպg%{no؅j`5bVG9۱ 15ǫ<cjiwX&tY `N\zODW#D0S]`[FukTDA*ǭ=:Az[Et_se` kx%@B^_3T-*L bq:g"{.3J,_c5v; u$e^a mυ"OR+ӎߏ2ڱVōTNR j#Duk[sHzesAFl\>pMnTE>+/6aK!<)0p-[Bq\2zJ尒g@ձƈ5`ǒHpc*~Ұg/"9PKl`"R7Ȼ0z3-Y P9EmAАfo?58oY5Ko ـܮh[΂aj `w}"82*ȨfY뭱@Wt~M^F)L3b8(kC 6Knq?nQn|,s]ԜU.4= o{J IG;I# Ȭ`t- j~"paJ>n8fm$ٿmX%OSXm qW(h_[`TјؑWiÑݼ`>q>uR"z/:1CʣjISTrҪ|K&e*\E:"| "F=_2a{ڝXw\q dAGTJ<4L6Ӗ\6Ϣ:UM|Z~Q%fp3Ayp"zJO!ЊP.8H vZ+m,9tDEvoK"Q-z\|##'ykVܗlkP֏ D?ɏora 0!P_{cU^&7B @S3Uuy oPH/Z~\YيFŀ(Hvíe[ӿ۪%"LxFs!@z˂ `PMU K8nc^V["S~N`f1{wqR'^>PQQks}HX /uABA6&cg$M|dXQn%`3Yvxǫ{B$5mhXezúQOP:b,88"GI\0yOAЃBe/6˄!!%Yj^Je4W<'m[ljK* 짵 ~me{RP2ϕvm.=+yϛ7KrbѨ ^l#g?{.!X+z?<"o??kip껭VFy):/&hz<;Teb0+&A"D߈\SH#cWKt%kP1h=g΄_vCEgէQe]閟]?';<_$dpOHg 0٘XEL"Pכ7v-UċHP"IQF .,QW,eH~c)~17%G~Wct>&n%bS=+8VF:pq{.oRxu?OL$V|?|4 BoƏ[C}H$hM2d䥨RkJ" $4Ehe!O_4s6Z O=?07XKVQ/ yl ,X ]Kl3EH>E$ew'w1ZEaHl-E%WIhȬQdDXwS!zIs#H}(؟׿ߚm6Sw~qw~AV)M%S%cyZZ-h &me`19`-E&go L\b(vsAa}X +]zp[q~"s`ca^x fjNfUoyӷMgA s^.TM-}r}wfm~ ku2削D4O|5g!#;f aZ!g9az.Z&E5C= CxqK8ɪ#YgӪҌ7qMܞ롿POGE;p&`9/N4w'mٷ($뷦|EiL' ΰD&:2( x٣6~$7mY7g%lR=顐S0yNH'M6j{Pcb{klR4?GP󴙝sdΨra"?oa[yj#Y ja%C[aΛn*VS ҞWY8KT dWeV"k[?S =G:#t4Wݤ&+]Th~;#imA 96'!?w5ZHls[&%-u=U0)Kn}ʑ FOg#~d>2y=Z4,~}tKB8Lȫ]ݙ| 6ΜT'(\er]xԌ&EvRu$0wV iDr&,\u/I~n;BEO'#ǹWgIهTU=勛kϓ=?-;~@ $΂O!+Fu?ɕs^ H14峜4I_o׿5*OtAͣ]Hn4yZ9B,@)+v:N>VL9lSyvҦ\ *~5JH{+V&ڏq;ޓln dY< ]5͛ 2)r71E ӥfʾ&@4[\g 0' )wNLbyyRQ|X)._.|GxZbSyCS^Eg!^!sӥhӟ㘗]BvEtK[6C!&4oޏ慑?Eלh gu&K+lnGvvvK7V* B^2f-G3$DlkxzfmRQEҭk+tAkC6H_bYpqW*&R{ ?R&#r<5\?ˈSG0?(.el_Q`22{i |,@&ny m4fh nNFAƄrl0nEpE5= `2քR5ȹD4ꟊZ"ˊp^CXY1~"^J|~Xls`ˈly䍺 :Xl YMZV=S8Y@$QΟ.xbODR:~Rwl-/:ػw}mٚf% ?XĄfBTAtڇVC& ,@w Mw0{RZ^.&:u;Wa?X)͇:c}969}E2(hrauscFIZΏ]0uEP@N~N'\ A@aP~ {ag1d6KaR;'ZSMe.2Qܽڴ7,Q 5XztS=CK]w!#CJ@kmgZ![6Alcۛp3Ouk;X5FRRT|N ȓ^Jc3R:)ob΢O&k ט^]mLܓn,$~g< vVK,KKfro;۷/}~&0eH\CKE?3)9aMga"B87vnu.fUg=?xRĿ?W{G['_kgf&f6gK!^aJxaxpM*D^!B vob0TljslH7Ԛq"mUK3(m3ώwb.=',r. li+iu&y!KXj Sևd5ȬMrRMszAU)bdL3x`KխN ) >N]4S&>MÌuOLOhl[.$ܩcyCcl moRVӤ?aӅAƘ e;D_5V32BaS m]I^؇TAn|J,6>٘bS^Qr9\QOf݋,&~v]6zm%}r6r1ky<}Q± rPNd j =oBmrr%kSݎg:nL V_(NZ>nZ g[qPl R⌝t5&(KzLQéuZIaw 'U~V܃ngz_&8DrzCqtJOd췳xD`AEVO3PȴR@2ѭ6,M-MQ|t@=[ڗ<{M~×p!q/s93I0RŞIʱqc;sd[}b;6Uz5o)ṅT/?sro(Go-_]gm8VB7(ɜ=ANxӂAюڼo%dnd?%XN-R O -I㮎t}q* o3}jÆͤ{x3Ʃv"i!//_CcSQO"4† _0,oH^v|uZew Bq}\^y7n&IxxD ʵ8wnrQRqm<BIdx%BiՒl=GbRӭ-FuAռ8΋$/3>H68jc(/4/Gv(X{&$Y4-@Fa A" 0{!A.PuQIĉ&MZMjisE],> L4;朖,i@/. (M֎@<; =YXz Hsg[kgշm &ZJ;eo_>E0\hj*:,y7%RbV_if]8@u;1e.Vϫs碆y7&Il쩭)L9VCB %{V8Pm_9tAOLP1Y'pq:dmP6}Q,AlFZ8Zw1f€/+AXA ǫ`$&Y\>EGGy| {<]&MdEAKxcG~!5cmbW9_e2D~/Dvm'ݭj_ w7B;𬯿дg̀e,?V>}{omgE4Ciٳbo:J?n,i+9:)&9%Gǽf} uL,fRSSu$xΝv8/{ҧ̈%R0bZgNg)=Ǎk(nY#TspgfQ|'+oa`X/A8ux(.YdexV1!"x]ikhPq$ǔ4ˊ-t?p؎b@)M Ooǩ Oܣ|xG _^Y]~z8H2S=p)@s֞IW4,j}g`*M1 ,@* T x̤ '/ SX颴,9>|λi:w\,=%vy&7Eam;z/SGX<9`B  *^94'Z%HJj[g; ՜^1:EGjBc\,6!ISDbelRgJơ7I${w ߅Yָͤ|2BI>c[Ћ:R a?r?n(!ȑp#Okܩ~ 1ImgJ)3+u}n&׮yl_)γDuw7 Zf-@[,"Mi{ANfբ:IbYIKx)lEKִt,X,Rh$)Z1mL K0̄U 6jO$#xDFg~_L4)؈HqpQ駄&voˌ@ .a"'|#)l?#zg͋CsJ904Y=+4Suo&-܀ZddO_Mk̔y 촅cУի< &*.MËh l^Ʌ$/oeP^P G ,`.[Yd渓k?&2ͽ1er~A1myVS W V!.O4dw,svuLk_Pkz"l6yr 7U`g3#]iϯߨvnIjr.q(>4l5@<'%dXqU7ݶ}dge_^lL?#7IYZ턟хT%'n%簿48T"v^swioMffM}{d_ Bmnf~[@9_y{ ,^u?imϳW(Y\ëG ( "zdQ(}xC[{Ir-ȳݝ F:tf3|%7ԕ5٘Z,-)Ǚp;6rggͮ-*vMkYvWsHi?}k kA|ĘڹLoNPȇc9`}F**;ETת֢ZӁ`f%E%w.uX_$^DY / ̶(7 lUY4~1(|\[Iy, {SFM,'F }_#=N~RWEB`Č Q]iN-d%d^h=7N1^+&EPꠘMz!H(> ?Y ~f?3i 673%9m:/`*CٍWs لĥR"&DS /VIÚd t2"\7;Q s`d4]AGV|2eN=SxE5瓛HEY< 7lb9r}P  ,Þ+K\hnMrكi[ÿ$Mq_ E2JU'$5YRVacChD?Dk^:5c^° ˣ_Lĸf{bD ~NMpfk^w45 <]ml!~0"oh|dn!Y0'_l}1=*\YjTmf_˰m`Mm#%\}Yn ~WO^6;ЋӴJ$1xT .f=8-lM2v_'{A! YoJ`kQMiq{yz8%rMtzEsܦٻ_/ _Ȋm3b|16Db.O/TXjS@>#x3*[+C >3?9ЬUSM ,D9d67-[(.%쫶U?ɓ#ߴ`rqDك;|$TnE`mY `I9~/ȩO˝uyƿGAeF|OE~1J{Q>o=AbqW}sKq6,Ąp}%5:Zwz +Uȣ7 ;t1Aʇ!&Yo:C8}GpM~&]ãfțt1B:Ā7 1GxiKTF)O^!bn_6S-(}h_^a%ⰸK.7PQ袨+zO cb%~sx[uu|? [ ? EEM1!8n-B \x\>k秶}"Q 8܊8D1C8I0|Y4HsR[g(WIKM<@a\:0~p>uvx*9j\>k)!?_ *vC%Pkvܝ6}, +÷D= WrPgPYcB)9Wcd]gHTO.Wm/)fC|`\kQy]g6P* "ul.ߑncͮj&-C[~߸Z9Ub}mJ46\Z:zF̓3/<@4oSc\ "Xf$ =ۛw^'^\ʖYI?g~^ۍy*T+fc˨T蘘w2۟%iXB+ȱ~w2m4X ]è "^>Xm׾cK/p34V5Na T|ʁIp NpZ-VmTv"ta~_۵ S_`{%hLH]<'w+=,iK'$Xam.YZ]aCpF;?4v]Y=YG{qyz*asZn~ jHLb]+<ۮMqzH?+=}qi-a8tzgLTHynuPR3hv7qGdlO{`k{}i[ #UAWbio%e?Km2Ojhm_F3LNcB0ھ[V{oDäy85`: u4y$Oe\Wjhh}w7~oԳOTM:s:jb_ή0"Lq x0#QZVuၗF UӫA/\b3&gu;2ب}qRQ{' aa{ʉZ˓5~,!L#'_Y(?E!(X?hAJ6"}#[HfQCݿ'XR#[1p.s2$觽R8@wn9!]nϰxIeISRa%P"ŁY'[4Kp\joˌK3ةj.S'$Hce-kxHSR+yS5%p3`MŪ4r #9I&k#oJr:h_)W 6!`YhvӁ;)p{ZuW(dl.D4V4IaNQ}v*I Tb'Y=?=/cRzzd޿ D G`ߴkvnxnhI |(5„*36{|}O: 9XnjV+ rG{H{0P$'ݱNo[; 5oUՕ{%ˤ {St"@f&+dS`I yZ7tLOʜb)R:M_PrhwSPy!n͇0<ti h ?G7{ eHq3g )b(*0U[G,/TjS =\5,+pa|M!s~ x5um_#hc ,dO+.<6<4Jr=Vy^pekkYՇGrD}|ϣό(8#kR0͂nn)%8muux JuXnZ!;zZv7o# N_ VRxUhh.op.՜k yT*7$:l>R@QV^!alݵJ$T1JN`]ʦ}Uh՝&EW} ƺU]D//ފ#4`zoGGOӢ}f8-qBEQP\$^1GV2 ?缤Hu# &ӈ}6Qwo>k7!!ua7Wu9$ - >pٴ9 |v"eA QWq_TK!Im"V-OQ2 xG7_*Ͱl0yGB8~rڰ4mcͷ|3u]-k>= 4xĽŽ}WA1p+[U2i]CI [$`-`W;t ֕o6 >*%7JA>>P{ټ͓m5gMN^.0ʿF)ꕩPb_uYJaϩy ~d֋zT0S 8$G*Bf<"jz޷Qq ~I}b[9T;jK6#x{:>6O0Xmj|4w$h@Zh+fF 2q\/0k"̶ &7 >{;t>iigDnt_T{Ғ?1٨\q\ | :a[Ud >h 'gS)p5ӲT6g")氖t4a:|C [~ &!ͱh$ni7\5mZג=VYMiZ!NJJN B;A?@"§)|i zJ6?1x)܊`S[heC0R&(G; ?|8\4AO2O7'XX[:!x<ʇǺdQ1[p9(mߑ4;GV!b " |[nP0|ʊl#7i>/0)|.VxRO:YV>^U6}wȾ/„u9i+(&{v9 [Ua+f}T.aV0 (^].^jS9V?W8[:VʾluΜs+)ߒK'8Y9~[@Tw9nl[n$š-E̍Gk~,&g6т P/6E>xPf4 jV}N#r~,1uS"_b%>Sk4DFŠ&4-um8,`3U6SZ1CPHdd p؂tO\.֙B; +}9ߟpy^} {v{vvͶ̿ YS+ݣ ;fu{,=v<}t4c-躬pԲ )ز"]}  o9Nj\NY1-k [ 48g/_gsKXWS|kxͳs_"X]bb9xzo+ݗzuTcIFO+EO_ϛ=}z򮗿VrtI Y9*Wf5+U y {#JwNxct>hshHk+k>25Ȯa[yGmmڏJI#Kc(->?ڽ+-.bXg:fal/*ShEBGYqjrf\p嚹j|Ie%i*u*ɺ@re9nrRtcZA&-5/*?QcVoӒR>z>~Y=!:C s:4+}8x4+H>") HZ|g8`BЄ ;a|MgoќYU>"UYil5R?}5QK#nS!~ Ee Y,MTjV0z@Hج۬Čo'U$wzKMz=}jalW܀xp%Sw|sk K Oa ~KM~m c9T岛Te bChrPb)m>n\i\,퇬}p|hbp Gm{ڭ:w(iwȚʜY%K"3.)d>BV;SԘ}EɃ5gT|&Tyn{ "Ӆ|tV"`G#fۨR Hq&#N*WiR%q#*3,.ÂygqDy$:|w2V?Kz¾䦜 ~_ÍrYr0^v /!$.BͲ/FA•%{/qL 2< *Z04SRw#oYq]qbF{% %> GePy-,pVK?'"Fb@ܾ/ Z+u p ~!Gy3y-! jd*}s@.&ŁկOCNEمfRvA 8SߤH8\>Aq1Fks-G^ l - |0&A?o) 0vaA%ږn;CW!Q#xq>1AH1J&zC ;Yye$ղ~(п%LG2jK>ުiٺ6f?™FU߷ Ԡk"y߁DZ+Urx vqA+!Nq!&HMBh% _wbi ؊x Ly:\r~T \6\fEb4u^Cr?3qLӿxLBpz4KAJ}Ůޝ/ 0f؏~kO-8а?^dj*#ykSJfP?Z~8a?Rz\g▋-_po>sb_4xpǜ GaešIK8?{eAMVQҔ䀩Ư* ͒$V ӔK,OJ_S?~or1Ah#ƋAtI`0=!$d$sgOb$wdJ0O`>De5߳QHgVS]smoͼfpz%!ىK C=<'**InB?58D#߯/ OhD%x4O_+,%zVQC7CǴwtmAå$v닏ۣgwSv!]a僵, ř=<4 Y᜛i+xss%YTNoҺGΕg h(^\zl8/-֕n"z}'wLo A7%T)@yF~']Z~DОgdAw/x/t#XTE6'%T)(qx{ldûl^B~ J϶vϜbo q~K*%&Ǹ:H]E20y*"__R]v,A!Ip\9>y{uZ/+If;xʹlm% 6i݃W\ո ߮;گ`Zyz{$$=Km}3 #([1ÿL{d)b|6kbR>IMu(r9뜼*/Rj7$~ozh%fFlA;Tol\۹q[t$Goma왡T%Wj8| vey϶:'xc0 nrT6QCVH~h ﯽ \B{ty?~l22ZF$dk|$P_p 鿷<e~w_{U:6#o^|ǽIߴXX͎B}9!wݱ79Z<Ġ~ͦ޲/_I:{b9+W7jg_0@GHm0q_FjG^F)BqyW,IXDEow1(̏[Ț)F_r I*4ٱٽ?u8C0xU]O {hC!u1yЎ>1)Dz)r݈'YEfj1Ç`qk?jo4VFrDZ7(yJ]ܢ~~A\$+,3fިPrpv}͖X8MKNG'&z?cR7#;-48Q%t'eÄ Cqp@Z43`ʝ$j_/NBNb'.PӲ_Kcc㧰jSc;݀ik S 0~WQnI;Q`}4>߬sAW0{g81FʂdT58 \b DUP0倈Uq|& o^mZ;r+5K jpЗ~,?־Mܓ~{OYWh` @3ofbӑn"B)7}Q"FEZX؍Q֠MeNI7>$f՟vX$NcG2Ww1lTr8]4g+xxϴoԻv}O$ [n;YR>b;byl1Tfgdlӗxқ?/OӾ 1c>br>$v2qr9:,3G4dc29{d*mMq۴6| >z+qm//HXQ uHR7h~+o~-?{YiZ?Kgr.j>8!4kN,i@=:mqًp`3|TS:穅Z-o jĠE'"fk{'>"}~7RLe._"bYKJVI\>|-GbqcM:%co vibI\>L0*>$fyc9/ߙ?U6dV٨GOR٧mXS]l縷@xZ3vm [S|SjnAz5BDw$Qs-[7?T\ XʹqNKZM?L$pt Vs9_q6y5}׽]RQic)[){B#qhlW_ -!6IN1)$fb3sl2Oh)ICz;?Rm}}~cO)a)^1vV1P0 /)p\cinv'&z3rgz츟ȼmjclXªX̖*-iWOv2pøYoD&9n02+̇0L!-d9f`bYZ@,n_C+n$%bq9@ >;!éE21q̈fN0 õ- ԗP~'7G1MYh4Gk~(> lTB߿JC:Hfi]9yy x =ꆘY`{W?,⿖dDјe܇~yPM 5y&{<&M `d͗-2iQJ0[! .KLb(NinUY0cUrKtZ)cFCh7ԲKEd6N*\ UƿM99~tl[A+ISl{7#9f>WTk`\skri{uE(ɚ w&WZtty4ҩKO߾ҸݤL >5QA4?z(Pj9-$(PQ0wa/s''PEN"_ 4}Zqphx1m?_V07r}=E%\k)H,M}o~ Ƌ_~ǡR.P#>~]UxcwsO)Xg7mn- 6:N&ITkEDo8ic5s".Dj@ikA? NE꺪 t& T譪.7hW#عVlȪwv2ޙN4^f*,!ouɫ} +>"[C38K󓎏PzNfE]~u Ӹ o6y 7sv5JG 2INc֦&#u9џz=?UG:ƨg$0>am +94݊`|+㠥㜀nH`.틂3}*$5EZc$īP ̷lum^G.~oK NZ|lﵗ9g_aaW].KVYO!APÉ ]cY#NǐE>s58#kF#GtDHHg$dVPDU7{?"aE:1>҉(~ Y\M[zgldc,%~BxXS9`-pd0$Z'QHP A,_` ߿}K'LFtDDwQ]ܛ;L[`ZIFyob:]y}4utH]vne uWTL3a *'Bg"yJok3s:T>0z74 #/vXLEx' TCɷm|ǚd0n7^ĄqY o UZ-ye[jz~Yb +ű֏xz9v Yqs7Y CSЖijF4[ u:xD<*N9'f]/ ]3,YE hc>RF o3AƜݛ $-rC6 җ@@K"~0C Ny_&ʬ*F&gq:zK}ȯTNOveiېFA~vRH_EُK p&P۾.)6>rI}@,v I$nKljL@oݒ4=A\rHIXE棗5^5GISܣz2g$S&@_dX҅-a~N*@z3m`䕗Teض> )9Y#b[P2NfjqE ѵi *tv %K6j1 I=~AbJd="E9W3ȩ^H !GR7||SmܶGr{C"@1b˅ʋqv.Qa/.h \4RAY>aG,߇Qsr>Ta+10v*jM}Mw#%rO%C[-%[|DY}jk*LĔ( /A|>$!r-*JrHhpѢe#v?"}5>]q?)àT#x;7&O MW {`.FA/(B"fK)tX9veGSePI|/Sg3[,!sW $'>4piżImlڊu$pUaՄaLeKCOM³z7%ܣX(%|zhS-AP,K&7T,{9UUh Com&k%0`Ҥ1~bUU[<"& !WXO7f˟XC0|Wܿ=cݿB.SqO祷]xK No JԤ!'}~l1[/7fHy\ 5wsSvzGkMvd[PY^s.Vhuxo)WVY*MtPa_=tf=Ϭɣfff@'ߧ;e~l\5Ҝvʫ#~N1|K_*H%F/NHmjKBPŦ`h8Vup WeH[e74vͭvVIDR*3ݼ".B&7hE`fa=тj6o/p A)VlkzSK; zp(Sg,^&fA!Zw']ӖfIN{bq'a}$엜N^ OsbN,Dl뚀GTmYNեD$NQo#}/{r x{FUvSKسΠodx2mȞm TL{aW)~ D|ۆF,Z2 V Z'w.-k2+ {&AcY~>3.) 󧫅zT'Lف=q{Fw<"QX-? Ob:iVV$Ҕ*aίM$ȗ>@㇪2$D%XTLi d V%)yYZ,)Iѫt`]$q~FhVSj:7K `@~yQLs61"sw,ڐ-=ϓijVћ= Q0aIy}:%@/IFMz#͖Ԭ;v7jz߆BM/x'U6Ҩ7v1R=ŘCa6o 5FI\͘fw:Qk@ I?)z*/X˻{CBI3>k.DCoRk"xU-%QpVӸpԠf0X"#l6?;Fy@y<d戆"4FeIJ޽WY"Z\}SW:LEfOߜݎg2_*?leD'\q%fdܽqHh^W4Ŋ{Yْ{qsҸ,* 5Mo_N;TLcrJq2K)1Tlʿ[dW(gYu$xDkMW0Tf9 !b6͙oڎ8A=FLSU!lYĥS1(+r6B~9 ZPWv}g.0٦\,D Z5Kusk_|O D$ \8Ƣ|Xګ:oO: ЃG%=u_  i\>kk(Cx}9A!"Q*E&ĕk_7חu4#8E}FӅb8F8G0*~u 04?}oW|!J\\츳Y ] A:jC3iC{ ?Kh#_U~^Z8kh|T+$?gvYϷͳn|B,:' 4^zJtzX<ܸaꮽ[@ZdN97(g[ˍ=MxFJVE&F9kQS)dF'e>*qu's7=Οb~d P1ĺχLig4x&pWU~"9=G"n־2x1˛יTA_qv|b "P`(nlD\7d'szf#Fb˦&u#D -RmX++^Xxf{XX\H&G9h~NjV( %r&IE&Z{{4c+Ybj43o6;DqtpKy˫—B?~TҢ{/bLx!3)R]O%+wkʹǛ7<ЭB%fр 1y1}a_Ba,8$<y@BTȼ2L6eq/MȔO ydJP7^:D%:k8 VR,5\\m;X29{?1 _9tĶ06L'ӌ1koz͏+We)B2y0}T*ۺ%M"DAgQPy=?gĜmw8$n",^/W Ooj~6mQq][jX{t~LiNQ:z@&ڀD>~(4@6u4@T;Aϲ @]3l\/D/u]s@UG w<b ۥ2b8l{t؇8XWzTUP@i13;mP\jKyJחɛO%dAN^mfǩea|rcc4|pP nuh S~K\M?&^=/ W=&S1:ҿ*ImUmYɹ~!5Qd~ !9)&XۢB-Mp 'VH K=#㝱nec 9@sey?پ%j5*,]Wcݨ@R:| ANNi(PF&NDv֦R~4!I*#1}7K6` tyN"ö\W'nJrWV2ǡo PScd8Wc #{l>bNj>@:G/\h* ՝5A]P-T̘?[e1 i;_'-%#C] P1a]Gpڌo3y6ꏸLrlnBL[^-[:ڋfW2۶_&g0r H݆jUx2]WNU4QaN!-%iށ@WOM0G]m Y2&! `Oe@9F?߿_nX!2I>oWl{9o  }xRA?04KE$lb MmVKl~u g.-{ *zٶw"R̜->4.:r!f%, q؈U92>p85:@7sh 48Kj],@ @?ܚ#XX4[-]Z"YGlenf=fe`$J]i,m4|hPTTaH/ ;3r4N`DCć !EP1A!$#m.J)U?BmN<'2!J|jHLgg>\RÞ+lguN - {ě=^43$Q!-#Y cFx׭pK%^R'QC"mh 驖 \mbCA6 q߿A i&ɵ#L^I !Kb@7ݶP[e3fQfr}#:eœ{ZɹBzˣຓP]0#l6-C='P[m(4(v}6GoKe*//f\_wknᬐ|Q^+`"޸vuv#?3 :eg!RΞJmLd˘?h!Z#Lٲ^<1Y D¥brx%d:)׀$Gd)Z O]3O P1$Fl@oc"::do]5+ EyhRkL?a6MdžiyUc3Q.O˂OzD);F_LDkb{IMzh[Zh#¼?/f -oB_8.%Z^N3G ݕG突5ja27V/ (:eZ²2Bx5Hq|t.65r՜5QJl΁.w&N>Y/WyX?XKqxגFӒ\yϽqWWjmH*2%GD7Ldre5bj]VMfE6;K {Imbפ/[+$&Z?,z@ʞI:,챷rQzXYx2f<mB%|t&$5_J{ֿPʵL3|c_ŗ)}l=үY%XJsقKAq>q^ Uu'`TLo%'"VisD|PsQ!6IIGXrص=iI}Nfu% NrE{oOKuߣ6_N N\NfNasu] &ɮo4q_L|/^mX箺p(@%S;4[!f<_zx !W{Ha"_ԙhK37MAv tF{;{@ūg\[p>^ةF@6llVv< ji陵囝fU9C ѭa"],$kEįR/ *Q ^`wY' "CV.ƛp$\@&QRB:D\TdҡE2Pa$wX:g$5TʛTi>QWW Nb\)y q$EKԧuBS/Tn?yh#mš&Zc?%f2D_.3$ʲ:OPt!Z`"ihu P#p'__Z8FzA'n3-M'וbF>]{?}zJ$&{)$D|S 8"_+6^ˠsTQwwHy*STvcm8Di(_.Ogc:_Ve2% *Јrpu}kt#[7zg&-Y] nh:'&nzq/޲LrwUz |ӳ>"ksyり4"y~ҝ33>ZlOkoX.N>]P ,8C7Ud-m?qڭ#ӿVcBMx]l.#%M po]dy SۈuHR3Bzͣgږ (LZ/U^!&.xhws=x*fg#jbI3 2ف.7%hcZy*791|8'<ד{eXO5T ~%`8eH%n3*](zI :|xe^]h~oԯC$)w OzDq=~]aDtF0.w+S"J8fGb_`qWg\Pv?#VP&G=.ilZR h}ӢPd.T%s suf arC26p樎M"E&AYp\DF@x4]3H29/V|@͎[=Iyi2j2>>O u椔߂ $ȱjbع2*s#[_-KG՘>S+0X˝v9p2H9 j3 fX-]"dr0_ |g/GKQ9j,K&h2J۱27MMW|_գ\7&BvG͈P1$*ݒ3唬Рv]UI1_su59'`ٹ_^Uoʹ.#\쌃b"2,j#xN? +M3EQ(5\8d }"Qg=b(_'#Ab{gr/80ud@H3S]-i\ܳG5EU&|2'X[S3qF&V"UU뙚GH}Pn; AT9q#CTCz"?Ytg!mSl35QcA< T`՚TAJ _%=xXPxD2U)= 7x:Mowk+Iʲʛ&wв5YRW>׵anL Ӫ2xc?}G@73X @C _C2C b]+sIxw]Y Yn(qvPJK#/L[6u("v'~1$ L?2+.n7o<3Ⱦƴ`Y8mj5n9C]QIjVjFA9粦mj- JH z>[͵o^ŸѠ+*PqDk_IsZR/vP؇ԙ-.x}~DG}f. q~9!QbpFT:-uXpA6 #M.Ey ئ:K';YDX_ ]Eċk?svsmj A:potAXxAz&0{ARߟ0qYFHYQoQh QBh'KSr.&]AMo6(wX&ۊ^oM~c3A%,`^[u>17%GHi\_d1^f}bbWCDxmjsź#13|DډwhNT\^[i& tW>8q**Z3J/Iz #$90[;Wաo>a-f|8Rzݤ(_@[;Y򔅿I;ӵgNohYwUO| eUt{!703_8?z$ !W9"끶yEtpt F)QDdi\ т Sn= eznYgFH;љ1Lg_oU{ YH,"nyo#iU\%9 }7xm~.抝Zd:p= Րp#]-#uݭ L޶**yDp` nn=?^=7͘Uk+F4|G.6g ؠ{x}*}rA ƺ,㴁4cd !U/m oa0ɼH\ C 櫪юy>3E%抦%c%l%m]Tjj {?8mt1/7#6x[I.Kʀw]o\K1ב#5VY'z=qur⬚V ; FhD?waE]-TCr+>.!]<<6Ѧ(|}9zJ@zhCS8ۇ%m>.d(Srqޥ{t* >&}@*v˯U˙&M ڠ} J}G K> W`J _m*RNbS,gW&Ћoӌ0rDdo͎z/>0D[}Tb_oV R<Uz(pVT32$7oOcoOu^m3xC_bm `Z8J4iWD LƜ&y&={7q~2ge¼P+z_S>SNR.&+ fw맾C>+:ӿTR4&.͛[n!Uq\<'s2݃gѨYDt~R%O|X7QZ9i6<쎧og-R)28HGmoߡ&ݎ%> ir܈"!#Y,J&f{="Jdjt<, I!}5RbPRɰ*R {rp i' }rG9a~yCPGZ2DERn4w8J2 VmMv414ީ|4 [r?=\P1!Xmz$7m+:7P)'jKoכlx` G,P3%&6 }knI[չ>Qf9qp^Ei(&/KzA>ffZyJ'1l!vXreZj櫯s *&xXK4'= 0o?KBbPyO0G)dd*|d?0h|,;idHݑ<&UpPFyVE(v?+Lr{]_s> ־KVFa~o*{po+ H@ &Lj콇AqB'~7AtϠ+f>(eޕ@;J,VE+hrȻ',i>;adX }u?pv]HC?!A12Y>56j뛎 fAX/uwCjstBuT (yt3I7_ގ#],hG@ԉ e!ϮX!kO:a/%bWV$OSᔴkT]OsX:5q?<m7@Ծcz";:eҒ_KRGRa\W5 \GfS ]`iTs:㵷2cNJOUkuh\m#L!jv%."._#/P.tC&pE3GtK3MOg/c;Ǧ' O͢ 5dBJ*YI?AU}]œ#{5Cٞ!XXtĚ?=7Y1{0#U We$wV5.GJQEg^އ+ՙꓣ|=P0+7)03yͰŷƼtkX'3gY\& }+ nV,$jF6{,> ]=,q{;93/"H_zp@) Z 7@Ql@69^jȈ.Y O &r13|(@_[tv8V* d1\oLix_"X,H\@\ ?Zs`VwNd:}ʅ[ɞ/zцcN҃z } %&ؽ6o5%;J`&cTVǘZЯ Zw(@T`Q<^>| i_}&ru{/bk͗;eGrVw`Q?uI`y1W8t ƹ&ǐlnA C?1'OЬ*S?Yx9K!ɥ>qHwD81$Odnu G5'F3C/]8i]}Dc{ +XRy4wҎ_=!G3؁Ǭ%>v)Rm))?yi>4R/;Q+AM4k]}XGk {<B2[_l}-̏}ə,Vr~RK5 Ob*gPBW+}|b[l^io>4̀j/wŎuY&0hGU*gzdlZ0bʬ Ȅ.z;2o</41TXl{ nRa=f̞G7Q[7cZ[g="fBbl,У 2;}!~@SHKs #xϔ0W|tGі[eDUtH |c,TԄl)V|w|YhY}|!)dK?Oȁ,*vГuL[A\^5nڮrJ\oK +s K_r9h1YmEa!An0q;-0Ľls}Y'<D&uxL?`ayyN'^1ˏ@@څǒبQѭ(! #h gxl 0&d:vFlA? &5I$s*LnU"^UaoߖM."F$ 4{Ϭ_ƴφj3_z8G}AzG6pg$oG=r".i@KC*-C4 \ 4QvЅ<4* ĄD(lǵh,s!DP:}QaFBzaT&S XG׶+Mo HA%MFw5'97/uFM;UG"Dso6]{{HA+ ]SzD]ZGn}U g]3 BILC 9&"dcrDZ7MZrU>},B٩2 dSE `cR͕2ebf1;wqa^{Ç}_қjibh Ϋ B*Q쳤H{*ܲ$Oً2Z;D$KlFxwDj (v(rɛw?^{߿Aa/oi"O4iކ}X3kֽqW#- +qHp@R x2L_HҢ@rq2+` $AX U$&^v..BHM@^~tLVa d '-I 2܎໧;f_{K0?&{0V2 0i & ǿ٘Gsnu;D5H8dg_}Ar0/*{S4"cbte|\g:f[?k BkA\׆+9E T<{tT^TlEvw6滄u#%jU޽X O/53P5e5 4PkK0T_JQ;;&4wzgֳfiC׸ I+aۂ l+ gܷyqT8y+S_#:& Pus{cC2rr_E0og;*QKFd#<5QmX2Iߺz)f-S 5Yeӑy! -[Wm\V#0\Yc0ȨSD#/x$7 fvppgmSdq.T.jsv6 %oRyD$gG:ɸDžIcE'۾Quzךje鳳l/we.$3MU țheTzCO`L^Ĭ c(K&ӖhRe$}X}.!oZ; T}|`;>RIҿ,v c-ޜy_tM‚ b@R(tuF~{_8Y (~J`;~g`Ul5[o¬KLBm< >|]k60玾`}&jCy@i ͈ j(KQ<@0^G@83N꙯&|l_o.jࠍkڇ?.L̵:5oWջÚz|Λdkc)ՉD?a4_ O詘h&Y"$ 罳yFdJMX_=:|LVVb[&j.ż(fnv6{݀gʈu~(__j[$pE`SW\1ҋqG]YqF,]e5i\XY?x"tDLK7ީ.vf-u ҐҰ|+B1J ˝.cw$DnbAs>cgN-\\$l:d&U|#leޑ:}_mKwykX~,<_׽&NiC=r w+q_ÔZk;|5LLXWk!ǭ]p)pǭ㨩Ӭ]vaŮXbh(y8ZPF˙K:nX[ټX > ױĕ`"\mU>AqM!"Y9*)Ub~wֵ|EIE@k@4Hx4*1g겠??yL 'B?tAcOτ}8uM? GIm߮; 'ViXO9“/ e&Ӕͣ$(3rDHv ܿ{B? ÇOw_P͇ߪu#}f<#v` 뉏gEkri%8x3C={kGƪx)Kv\_-Wz Sz/!Sy=|:9:2֌00H!kW}獾B&1c{q)8[ɐb(S Xso1A|P0SZI= n>߶-!K&s2a:<E!Ql8F.uQj琌!Pmpf>y|\M M|KF{$u,)y!(sK9'rÊ8Ozz4ϬJQGF^_\ۦ&]0hK?r7yufC?3/!j JSsrցBƆgGBjgږCYZ`uQ9k/4c0C,`F8hdsjs^ %>9p /Au`+ߒ0ٽDjB@q~`:{D/nՓ%TE{>.M}08GɪJ.wBQƛ8YR5bXգ?Ǐآ ݢ=~ϰ (^J9RHύ/ uq~HsЦyW˱^Qb g)Xy[a73tE]rٴu{- {73T)X41c'Z>Ѿgu:-ofXJLN4{??@܊ͽUZ@+r ӀePuIǥnlF;CJ"XAgz]|+!1pX*V#jewvŇ Ijl=.Mˈ g%=kRuN3fy[7Subb`𮀛@`*U<>یpO`֫~Fl I4Ȥ_ p q־!3^Y/7;؃zM/-*HA6*Xh0ZE&YGܯ'Ң¿1͌Ap??0&3gb(鮶x7c1!Pל30ۼI-d29a3z1mw^|W`b'(wЇEF'-gv2̫AƼ1 [T6C!K0kYj_O4@y]g8l_cgr[c$}{g$4-hF=H=h۵WU$/#N7n7A92}_ $TlX膧FP^>57n]c}+SfLHѭUxu2܃bϑO j GW$7`1+-DJy?\3 ?/[; 8v<΍Tŧ*Ug8DI5IzHI/YF8Xq2 ԥ%Sб8b YDg6g >z 磙HYXwc28% @N(6bĎ'TLS^Dl#{6BRw!~7U~047ÏzfcCj[r7+dv+z *t_*s1i'ݙ'pƱMo41H08W>Nҧ-'DSZdyuf8"Y=NRp8U{zR.Arb ciZ!ۗ޻!YjFXe%Ns-enIO߿_EQ-?????"QpCLIK0:7XWp/vq#OU* M.% 06 +) l 8TO$F: SbAbA-#y晸 EQKp }t9dqSށsT,kzJ;$ Zz<^2>/Ҫx6 d&zky"ND!J,hIfA wj=$S[w0Xy>czڶ( װce{7h\F(2:_$EN(~۷}?7uh}VK !vA1XƂ! |R|E'cDYknnٵ{^8,:,BtPDm ZՔLƌ/Bi1nj51 `xB䐩B-e'UbpxTF5)"3>p}ZY'w gv/^"Zh,S[Mc:bêiۭIu,/*s5,89 ||0T՗B^z: ORѵ ޤat)Yh]%q7jyl;d+ף޸ ^ mo倡p<m#C|~Jq t*A>3IosHe^&,/el-A(`eqV4z8i ުkc{?b9CCEV4A T^[PF{b?^ ޛۭK΃x?&:wEW m2MUZоa1~P"S6ۡM0{RN@*i ɤI տ hHa>2td>{)3E]~z1c&khMQ+B ʀ\I\Eᖈ%a?{ 2)W7BxV1I3f?SQ,ϱ'b;cN&.-@#ġo]Atn.|8b rS:H!cTjn3N0k?u<*Pgikϯ0,Vs_\w~Ԙ8RL Ґ|l}&x(C Gn%p9XJ1,/FBW 7KAZ%~(8ObkU5 3O7d j13|0(m1Y؛XqmOŹPUz (W[bN-fPWE~RJcLO|) 6Us!xURhgքN8b# d̥bKuzr85]L'Л^On.(4cz2sYwd㭙pĻur2Y^*LP,N(>$0Z^^셌.R]I {N.XI$tb93ѨtaYD`>~s3kX%~\ r-p*HreQ꛽|H#z3; ͔-CJ9 d i:V+N_51μmi?p/"#qq_\pc ]z!$ʺŶtq"%7J'(|Ϸ7tݔ`M?&6fD1C.XUe,/D]='#2̚.$NT*14GaLAa}0EDlcg-Z&ӡפ~Zc^S.A|ݞ>t%d Y}bjCla'j^;~:/ԢYJ% a p5l6@h(;x9FUk/[ ًr _s_S|G4D[Q^Wr˳#LCAFJP89^OՙSm@ھHziƾm$nbeB!Tk Qǐ]f?}d,YrDS1xմ'!{G|sv/koΨ_^%?a=G'Cm|'XШ)kV9UǗ.)%lz0 Xv i> NX$t ELVy͜atD,~z?|hi5v8J{/tẮl e.wˉnRGFEq(KѪ2 f TzmF V@6Cݩk穉p~_M~)~3& ;~V+oA]]>z ܴ<.tz>f$b:}c=J~޺E# {;_oOw%tں~: U"YBnb=:fR`Sx/fzX U M$_Q7":q%n*ez7)xqzSj+z7K>#Z U wZ۱c1Ri2+7hrl[+b(Ib,7}:spٽV:Y#>FDί3,8bʂ,ґʗ>[XT SX[L \h@/ihC \_\.ѷ쒂 MP&HH oNNPYȳ@bxg)x;}\pWnIJ.,{s-Е}#3>Pj<_0"Eځ$ Ұ {%w}9(w;wr^/l*bO ~:B'9)n_$F[Apk.xylA( U, % Y^v$f2>$T=`ރeE:+zbaԲ0˨v3X.hhkJ[K'fE[~'b0ɷ ;rC<| b,~U =^Ż%X-t ?k980$L٧ wvةR^k2U:iX]"ۘZA*ZYۭbΛXl!lr;pЕ?o4$,БL1FSHkŒ{ݑ͑ǒ{tppVI\=Oya@*ITx;!RW:JyRzg[Z:wּzO]̼ [~N6Uh/գ"\zPg3t.4Fsl9ɕ'T3IAS+w!3=DZc^V'yrR;m9Bك]PZG,7;`2^ GL[1fݴѷY/ 2"#IҔ0bQqT-vx }gu9UZ&\"K'ޣ026ϙX0#8?_.TutGM Ԟ.%\`kM) ,7 sW7Ǔ~srA@U5. >>*ʗp~<˙羥5R);x=ziϖ.0ٹ j?\o— 5a:&yYϮ˺ O V%˂q/k! >v^{ וf؅`Dfk`[#r8_L6oAPWJcs}nE+)x>>Ff*R_sNoJ5V"/$NͺpgXDֹz'{3mւ $*g'OCX fyt8+a{dy߯EE;ZNݾ> t1ФqE'PvPNe++wD9ЁNP`GH8QJ‘Sz<'74ҐЪBSɵM㸱\*W.Sh~E~#Wi_n.Ed_cPJŅ5]?))qK뭐I8~><ɠ95n%K~ %>sR7X9=Y E!}}5 |5k'v3k.:S#֢9huRo7i,e};M".ѣu9yBÈi Mۮ_oT?$mngӣ*Tuy:Ll`N6g +bZx1㽞VR])ᚰZbܣՉ2Sz}+؄ڕ**ynAG^qN0-rx~)*6GuȫeB05ijoL߯@$+nH'| -PU)>ۇ/1*ob0f`^Ş^HY'*`?#BspG㊹тڏӭm>4=3=e򕑑[>r]| -żL [ L-=Yާ"I%+>:%O<ǁ;'!0 )X$ixNS($y$XޱZH*/)Ӱd{nJBP ״3 MJ e}z菪Z vǷʲjxbx7"r\fO] IS-Y%m>Eǧy:nDccE}U(Lz,E:PԽF}]#ǤҾ7L$:_0Ym0td&uRTlZ`_ɂQwYV/$sh=f`9i KVO >7B">ӕ82&]od6͛>g8MFA5~7+ܴ0ǝU/-">&U^l ܭ&feħ 9]hCgCHD4pٷl)v@5*O$.l^S1ÌZ?ɥb1 9W4L3ڡb/1>7Ӏ1b?~nfеgQj+sn[;&=Gw^35E8уA=v!uQЇ5v8a*z.U^9tW# ~ӄ&g'aGL;z%~Bw~Ϊk@`d~;I~W/_q&ʓ ޔOk飌׊ҡ,@ M'UWrjP1Q#Ґz؇f}f*. cwU/h\{EHf&aU]sFUAX(gY:|\Im)-xuOfD X՝iZ`P%h_Lx0t.墈Ly~>zoB?;wL>xܜL^hFg;v: `o J@7Nv|St,* ?O^)z*x@¶#emQ7k_ģ ՇOsWS|95Pq{>PC?X,,nᡂ@H5J6_.y_brT4}LU|=O^O8 >tmH0lOO=`˝-gZv[U4->HV_$ޣ4Q zd}'SxJ^Ü~6t 4f"}\ܶy-wix*K,~{!'$㵡j?7^h9jџ~&'ixw;o_B_=4Z&xs=6vvliy vc7t؇i^n3 z7}w8,BP N~r[*?˿)@c-Y7eC۴ms{C}r5D - ?Cѝft/_Hԑp]D@UU՞m |+)b]z]2Ƶ:o^+cNg8l6Yt7:;L&td/"MRi.qbLDN둝t뷅n;!a`HO'B4>Lˆ8ށ"Sh!W>z/áy aX+U-Ssb ft1J],s_k>AѽC &,'Tꅊ#$MU d `Z國g)uO^wJ!&K?/I"@(Lɾ &ՠ}j pМZB0! `O]|p[0\kV,!j~% nVKSw 2I8/מ>#}sf=1'No /~8 AwYEcWaQB٪ 3$p82L/*qRJzRXvF~jkpxqy"HLf|Q趭K>m/ [Z:S9vve*[XTsLaDze|1znz4ޫ`bz}(IxN<*)c֥&<]TJ]{f_ukUs@M-#[4J[ yէQ˘z0-:wZH*A7״Y6kwV}yo&8tv2XzzDíg Fs8k:V[OZ/0o5;?Q_TjGx_?e[vǢЖūT0Mng˴B;H`ːӂn9 Hpg[ 0Xo A@~>m7N3vÓb;ۡK[T6lj4*7Y׋dza3ӾZgs@Uu(|vAmLӕכ.DOϧ|}yz{,l';=zeJ؆I=_nyzo{-4rDw982nQ$?Ή|">0Ւ@V\M$W8a#-m]8[?N wFHW4}a\ŖM|b=;@Oο5wg6 l;&$-@d7ռ{hnOy\w`\"*#>)d bS^}8!0%fנ'vuSӡ@]C_YQ@<?fC8Mn)i:koAy e^Lg<#e(r^,;r0| .uSheʒ.6My|/ұ䓤/=GKhb~_hF&|ISqF- KYHv;ދn+O'"2f',t˂aV-ш)Wy~9EGog`oiIohIhOin D}zj=v&MdcMl1pM(qZCv~ʊa#z'tgX!e wH%dBiSӦ-CC=8Cļ[)o:ے{_(miP7-FYq<^L?dw667oUJAV&CҮY 8n}w/Pۀ"HSm'lJ@͹$;ݾk2,Vޗ_IRJloެ8.gpS@YW_+o~6T$=K.$ǤkC18ނ%^$q /1GT11(GdWP̠6ߖ2$*d7E BkmZ;IY]$ٺ0?07f(!RFk-LYh;LEl] o> /v?[\#'{7"%MUW}5_ZҭCXRASU붬CDSᰁS5&)&!(W0\f+)YbG<:^u]f>}{fhvhnU𨔥Jfj>ϋzb-CŮ'("J83ȅ7 tL5?yZ!CIcCry; l&L:]OeCwDaȨCI.Fa^ƾpuk]})o^J P'$ Ⅺꊴ^Ǜ>a(4&P)@.W{N,~-F 㶴P"ļSF:9 CXj$hF}X)|(e}xoJ_&T& ((P^^ʵ@H'>!DDѪ+ o4lUdusS ݀xb^ms ﳤsc\p;tl 5Կb7˛H8@ (Hҕ~zR;E>oM;J]D>)Q]#fG~>Ҩr|iGhL0oH*?fUOc-rBM`PSY5g%b3'#Kx4hxUZ'tYr yrпY,?ҾWh>; ˂ahZ4}~:/:*KvRS?˿g)&*4H_.A8L-BLMy?u;Be`B:%:SSt5~OW5 ClqE WQ}#>g3qgֱiNo[=<֖BL]0(v1K A_ra+K CS tWLy n2x=ar덉WoMLHDkUcuMu-Kг %iLü 8GDToPwuxe`RG BM(q1zGLϤaVjnyzfy@4)ʣ>Qލ.kTpgl p߉I;~^ oϔK0652>,J8 A1S-Ce-j<uyIq 77-؏~lGy"cCԟ!bxJ(UiwᠧR1Ȉ|6&`yɞ۽0~dn>dt32Sz >2rՄyT!<7J{/3sX<$2JG(Y F?!gI}F]H^V#.- |ҌJI*x>vY]J<!Kz@r=y&.$B'&j78#]5.sΝM?OG kG|ژwr2{&YY05;;!'P:bޭ?٭< O!-re{"Ǩ =x4Ҏ;(p`T<׉ZkbCBzT4xPg DQځʛηQfESsʜ5 Aj}|z-}}X(9{!yيѾ{9DB U.R)K'$"<|T_b)~*ۆK=W`ٺ'mw_aC-H=~m_|߀ ^C"o߼ǮZ%6ϠIz64 < pd͈kŎsP.SG-0xCTPHAAfz'iׇl=u7lB贮gbc懨tUmM?stom;8; sh)3x4wݗYMBc%&WnۚV)CV^&i._D?ð7`Mqn0Zi Ra˓ԛƝU!04!PC0Q0qSK\BFμ++<ۖEPQ_vY T;#5{uU<)]U鑘٬Z'ݾ!C ]~)SZ|ךV>)QʞFe5le]if:, ;u|/€_Q%m Dͼ ^ir飽.Ve Ec䞩f lMHj+tfP2Դxw]V!v|n9P|ou~_?0ԡgӬ΋zj9}>τlkK2!&f.m81 !oJCB*L 5?ەa`,!@"VӪCxnӢ9$)acaX^Dy7&x,Ml^nDrt]Vh癧iP r0(p !ڕ|k'V*D փY-Y!ÿ YPT6wGd?6 p\E7"zZOB , 6_ Nk'Xiߣ 5R;=~& 4x-o852@–cφ8ۯ9<{n}-!}4>eSWC'6o`#)@A<(Q[6t^XY#<(ym^v3O/y#~hf|sQYu eI|t (,J;+g1Bc-U+^%c$goWnJy 0%5+vfW|K'Qr)oʴ24M[ҟQ.ib-l8,E,~'<lz;lVQ Ǻ5`7G|aU.`dS* $Ls ݤ{q='?~:y)ճ/BNtXoϿ$@tt׋:6P'pVs \@g}nVvس${Wm~ KGdub,|*]}.+/Yk[>Vd#*W bfoDE5M`ܴO̗/7cx,2O;1RFw2%^jWiMƲe{z+~i(X-DyZ@.ZٞdFe\.:Kӗ1 ˏRh7#\@g+j9 O]"\o64Bm;4x!Ѥ}ܥte!UۼZuYYZַkkp|/&я;+Ģ3kz04#dBp젪$nY+ĩGe<@񾇗_#j5oBI迦g=a}ֲXPHآAa.g&x-`zG4;{ZOq`ex88XyƆ!:IGCIܩHKN=Nѡ?}R wvb?ubQZSnc9مjEѮʎJcV<&W!øV qgAS>~M 5H07?2ox,fv~VP|)ܢ ~}ڹ\a‹'w W'ZqƔE=L_o?HgHCkK6CVν۷jvF2+]![3pd4QQ}%ݙa]e"EAbxN`?Z&nNo!CtpQSPl+bԎێ &JG^A!᎔QdhMAF/g'9=y9MD! o' <o 9> mC6pfl`E])ݐLٖ=0w=>#ڇ%ȟrz@mC~KjKOdn> .Ml/L>oVb/H>hh~%)2H$G' /O;2Y!anz3:Ḑg},M:WKr:3°8}L^$/LoI<ۚ"-Qq* .^XpydW?H s8shrI՚ak2KOE~R" f+;Bo)?-W? Sh%_ o%Ԣz@q_Rl*;˖j]Q/M@ȓjoL&Q?Q#BB{$lx Z_~GcB&dHG_5e/{ 4݉ˁQ3ppQ.߇x'pޏWܫ%\:f ?47r{JKRD`q%v_>a= 9CUjO B,-ɂ ]ͣtněqFD77ǑW7|"lj65hK %8@mMRD|gp#xK=)2ۏJθL OCޘe6h$5>[I5'ZbZkDM_>I( thsTR=yHXދɧ_&y2vynDcVG.wG|7 B 9`%h"rĢl6vC8/*O꾼VZtk̚2tlL.vHm7o-Q'5'zAa7e[2 &S5ʘۋkZ _Thf_D0,:H3_\%ɥEfS#(GxG4l'w~O"`YQrDBhZbPȿGJjsR3HJ$ VȽW%ey8•s L=z^(>r5tQF_sI }kIq)Bd'%wtF2vlS5Q>U,lBM{D^kl$eW,:y6S9~p0}rrT bySUo[*6i}RSF4/ e305bz͐ X{7үK>0ot}5-g/Tr_FߪߧnG#ѯH|:=za2DBDf2AѪ6[ѽy5CĖeW"i =mE O7>c /+k芪ram[G9Z EZ4Byv]"o{a*JqnZUWo PN~EeqbTQMJ ѸѢ5ea5vUL2*p`4PR,`h H 6'il1N|]`ݘTRS_J'Վeۥ|kS`& &ɀŝ-'ZW̕HG zFhЇ؏j/YIـf'P`">0mJƯ$>Z ׅq>{R<+N6:Rpqp9e G_l7oOA) ʔz u+Iǁ}&CGڧG~ Ԫt`ju;dڍr'TgCԎb^]RO0k L'`Cx`%`O>cy;|cYYr^3G"sJh\fqk!'ڬ2~휽1[.yߛ2SG`#隉_V36YF>Xc2&z8j9X1v^Iܙ}B]a s 0GNFK60Neh/q+h}~CTPfƔԒ˷*[n塅m  ? A$jCŰv jغJCH7~\(_ /˖Q*>VR8 w;L#)J'c`ɛxfīqnFs6o56ɨؚ\bW.OXkxA}wC?9ieNZQvJ`&L݋QkO<]+33NF`SNײYCWaȼgd>6߉ܩ:Z<^_ 7zQKt*X~h`-*] rΠ^z^KYHX9HJ^m6 'nQyZN@JzIƗ Nվ<43XhsNhK2``c%zVaT/;B@*#>Q($A?2C@3~4%wP0y !e٢jcbg~yQ6v45lZ\T@%W9-Uɟ=pԀK^kї_{dP@l} U J _rarb5}bG=@kK*;@4p_> #UWzyDo,MZdJ wpCV-Ʈykd9#_<_%[B>\s ; MDj[ORSRfE/2'aì4%9Bp3 Q)!FdEn(X 2-e *z^7s@QU: 4,Ik%E5F#&exEl3dGY³ /{ &^3ipH-}#5 ޡ`k\si< C s[C(&?RJ )ɖ]sc"`Ë edVa!GorYB،F8yqAi=Z zX~h?7p+a& vx6Az9ǵA6S#eECt̕!&-@HUX(>0Ͽ+ Tt j_&pCJfsU/o+jkyVtO=SY7F!IU`XLN _A</ rw:J4=j@Fה˙ݣg[`"C׹v)݉5p⚹a–~]\.LOHvcXi]+5V{k0uAڍA21»qh'+$ bȺ4 GIUyd-MW'N΀ϧ$kE|e/! m8@Ӛe_u*67d7GuUҔ$5H=pDoanz6G>){d5`@~@C}PsY9- AICh '@z+ѣtxS_kTC u\} 7k;yI2`$81RL%x T7G]qp,ьQeOtI$!LU\? bN ln aCˉ,jGcY*vKj;P2G[~X bNm}w1#P A0Ӯ`,)jyȞI.v` ڄKKRP -x (C'!uKhă Td*mq`N;^U7{U2 )Lj=Z(:1G $qACd ڻ7z 2)PSRSͯiRQ+q8^۬Ue@T+D`}ZON^$l jwѫo7Gtcei{SͩI]?ĞSu Sqa?f׫L/-'r[>ż=aHp\Hilpk3klETeBi, }[ NmߔytbNs}uYJo;5&k!@"J<)%#Ѕ4)AJzFPfGxu4٣+ V$E@}4TS]fE6swo9٠_߳-1Bj]ᄋ`؂yueyv]x)K 1HoS XɴLN jԳy㸳lNOlJA`i W,c7FL|)y)bf5R=x~A1m'@!-nw Dsa_re]9R=ڗ_=MdƄw4H{}_Z> #2^,ť2:+>xT`~:wvJ\8qk#,J"E/*vU¾8ؠw3/ɷY0ݵ% ~ sTK2NXbqwsjy3f7B(]>lě-)^zjg2eƛcJM,T;_Fp?*41]Zo'-}dLtbc R_o[m"@JZ2V"<?<'?]~6A^/qPHU*jS '}8wQ9BS NdPZ$ }pvjv̞S+ߐ{gs8ie#@Eg~KSsG y=5 } RR  vᑆ%q㍵6sCwSYtdIiNzh{Ġc8#\> I9vco渝a(e% _%YW啇TpA;`n!Usj u-:~Vc/(nǚX%Syc905WL_\o;TX!P _OtiPTjC0rWD't>Mg\ LHd's؃u<Ϧ&?J}ȑzj= qχ(`J;\/?Ēz H}٢փث*[L9ؚ7Ǎa=7h'Ii@f/^u6k#9A?妤tK#)j%)E9/(-h& `҆I;¾_Q?,y Q)_eFa=RPnHR,֌su^wzbI?\IUa"Ȉ|ɰʳ\:{?utA^` :hZڐr^j9:%)Mvo{$uhe~Z Ƞ( IY Oʇ~&;RX%keIMngg!:.Ձd/N|_''Ol* RP n`'0O:/dH}{.lTRC2,%H) u/8`}>jY[z!S;ŀbMH2 g^(!D~6Z("T]Ϸ֗+X?W~Ow4Mz`0#?[u4T%jqRNbߜJCA#EW5'#bW+䊒:S+l^:p:h z I  ܢ7ɌiE|luq}̦FvA'PV_cX,hḓ_ɶF1(SGAp0ǹwIRfeJc1L(CWDth&tl`h'C6yG|,13lħ>:یkTE/$U<5%ˋ|gh~F1Ѿ_M$t5ב ./ ߪ= [l$bXr>BztMe4:T괳**j8hQ.meILz`0KT`k2/ٜI9CA|Q+N?i"(NW!zPWJ/hF)ЍP^ޤc{QxBA hӺB;'!SU:^ڇqg%QW\49<+Poqya!Yyhzml $ٽ7SOl4\OFn`9y^n·'yEdq: eo槹ze5Ps#%ϩ8pۀE݈#m2yoɆqS#0!]r=|^y/piئY"GPyn =CnĸVYG%D>+n/֒a켷rp]:<#콬QǠHc?1~O4'f'~cm y}'?!xC. Ԭs¤Eff!Ss*jFJUm -?ݓ^4&,|lp-^rTe\a1rهa'pX˟LAM0oQR椡HiĒՓN[acCZ!5]aJ@[ ^wEcSt7r9%E Pʠ#mjA6>/uYM?\6H-L[_w&k{t]*bo B=#ZiVND;v-2_731l8\,y]ɁK\cP5Zkɠ jhPoИM/ D.9ff`I4 tRۑ@!hlk&5,""-_$Xr ڔ^ ~6lRPLRxG b}WFeӴksoQ&u<]D l!o.*CDFF9XF?F 73Q k(شu=ʙE͒)jKqN^t !La ȯj<y[Xg îMebm|0D ߪPr4A<-igwg~W;LHGؔĢ= yX Β@kNyi\zŤx`_.t=O=j楙1oƤ= lG7:h\5uH_v1{x?L@vZڄ.>Jυ*_ أ}g{9͆嚜S$e;߬;Kr ْYu~/ڍ\um$CZu im=އ}x/ ]| nUC'|V%l+AfkMQRAP`ѼbU]짌<'Хw?Q~k˧ĺFKI ǡq#J-ٍ#`'=6ɺזw.w-?o]c=2c,Q1F!bU!AT\ K٧spI%}:.MLT_WVmLSoqּ.T9GUܛ9~O.lߚVih FJzӐXߨ{Czih(01cOYlHakgٗinնIuMȈȉr3%st+{|wjn̢xO_0$J>Qk%vFꧦѣ|O+dzagG&vr!C@l wC Trݿo5,3l}.w "dtE8 "^JAOɰ,xsWwuw?h׷q`UB,̗0K?rzdV܂CH.UVkaEDi@|8Ny4}h__u%YUUS_X׹Aoʥ98> Ǧ\AOCYrߧU{_;X ֧ד?&F}TesG^xerҤZ~?.k چgMy T^iU My2 8q=<5#ƾװ5`؝i(qgd4id~B@c;p?9ݝeY{ gNwLnq:K񾬒{x\+,VdD Yg"˳~?f{EM46l }7=3vNZXf"N`cgvz#nO@XL_Q$ ^IMD~P#2j嬒Iw;& =Ncc{L` ވW7tn\tyeRX).@D-]c ~Ȟ@t(~Xm$χ>$ItۅF[Kُɾ0 1x0L\!1IȲL%L_LxbM6?ϳ,D*]oܟ8U}̯ʍs2B7a[1UC`BJ SCdC" "B플 >RS l-ʠdž3R'(?xZhD8Q˷ٍȞ?|jENu6 > QΆegtzG~%1x'c\S٠N3\WH: { xUhe#}eqE8<)݇og+6Oj~CoNzV0d”8*Y f4 :c*;퀡0$cMnpP C.$qأ$n!b.Ԁ&=gn)ֈ7yS-$VucT87Rh7)E?=Q[CYk4}pi/Vة"]պsVL#iΦ㡟'J(`\ݎHj\֙CT;,Y!*8'abP ;vLgg|"VmP_tw $ǟ: 0w;>2m r1>1MVx|nCti3@!!iIj㷃畮gase"_[R KfV{ˊ@Xh[oܦc[SФ,J.>&9k>uIڇfTͽ?XX*TiWc~P tn|uPq\Ճ,>0}i-掊t61zod- CPCSUHM&x[XjkYS35;~c5]0!237K'g|E@!!10 yhU|YwQ[o(OJZv(ս ۝KSLs} 5OVCO<Ց?/x{s%O\22*7 BٗO{w^A?iP@H5R}t [ȇ+Eטrx&M,BWtA2R ] ' 6H^9:yNfw./XMB{(_TF %~aPBLSFig%GO3-D*oWCulҗ6A[uv%r;Kػҗu }.L%c0]4,ֲ zPZ6Բ\-Gb΍F=Sd4c%#5cV uT, duC<>g-FU*\֙*Fu_;v?j,{Ԟcu6$#%7ǿ<'yw}GLS?lymHu2LK?"vH M#p0-=Ք31ڷ\o")uEZ$$Y V[_^b)J_=7)d=yB1 ɕ>|jkzyOg.u{Ki:{ZeE'U5YJռdt}1}z.pB,.0%R°w%V< jsmL0>ߵtrԢϒZXg-SAXo@$lG԰\YT!+]_RI}qtÃ_–LOjpd^3BHBWٖS? %%99p 潣Aõ;Xo.Q4V\UF 5? 23.)&3 Yfh;5F<"=ʊH!]$0DvfJ)݈|=_uD T'\!UHc@د?ŢHiֵ*9۔bP%vhT>MmL'eP#_Bh yZܞm֮)lO Pw< ֓lcS>:1QdX?Cep=j^? -Mjx{c8H 2( @5k䕽 j=m|^}tcg)Xhȭ6mӤS ONwRa|*tU)_U%=/Z{UO?稆k5Nfwi7ݶ5ϹR*c8B{ TSLdA[пFz+>I ɡqJqq0Ovor7X Z(DZeĻU~gR@#6Vghh7 2jS#YcC,|P빡׻`{PW].i{a]n\<$hR? *|2OS @ޯN'|<^y6NugrZWy>M_[9ȢiNMhKvj#^̺t?UrVER9Up"Tf2i\ǣ Ҵ/p$z\zjfz% yZ#rJC]Er ¬枙ld#OpܸΖ{V@61sgd#o"ﳪ.EQq1e#|6Iǩl;"1H: EP !iHPiFE >2Q|rI7| cƕz}If5s&I}&Uݻ爧녠f%y\) So-wO-aMAej"z(rԠU#G2f)E*KɃtP!KIْUV!$NcZ]AiL쓱(b{"[>x70GZNE {j(ؤ XSe),`@4,WmY9mPNr ?Z)\x7_P`KMQZ eV>& KƦcKY ;a'{ge #s:/ R}CIk7)S}K,TҐ 9<278uͧ:- 2|7Pƹ<3Őи:,KLjL A1"v :w^@[$g |cڱ(JNbv~n5+DR@f&<銅"eZ(}qc"O0߾b,$.I$!O杋պ$|f<}$X5?iUeUύanW`zQ?TE*sv 1Hy{)d 2'ιj=#}̽s^FSco!I78`Y1|^NJͫvo^)1(>}-?<?y )伵$>P҄Qݶ ڊo0Gl\عIwzvzHӊGQ7U9\NzDqg\ٚHͩ)q;}伶p"XG3R|b^g!b 9T]# [JlvS[9l/cg/5 k~;]fx:c1K!%#}b+Iۮ*#a>NQWG@E_W=; 5kA.,{Y!asY~[d[e3)g`@$w至iM{Zӄ+~)TS.b߄ !#_,vBNhﯔ*w7HHCdN)pjM_ Ah(#Y? ϵg@ m]u]jԨ~KuԣUy#${f >Sy7hp!QwC8X)v46L0{y&ch ԬrbRȿ'u2o>vS:{Dla_оNN2747Fqvϩ n$l|2^p8&{e{zՀ>eیd9TmT"!1b2ް5mSBwXX*ÞpǧgasrVRzx:3d1`/#uh1(|sO`,-܊#%SH Q7|Xf)M"I3/'H78oP[RK@x9#/HL:Ś] s+߉M:>20AJK,V`[B|Y(&EQUHc"Rb# 5dímv,?-۪G~c"+B=Iӷj:5"b6LPu:$4$5Urݸ.1״T_y?׷uoܣb">8ȕ񘿡mZ& 1LLIoϨx؝zm/?1 Y)dDT*rgъyKOFڌp_kww{ sѧ2g'?ahUuإ`=W/a<S>5JNDXSy6T/8!/<-G:9V'x*s4c}d1p'_s+Q?'ى KX-Kz!MŚt|Rj%G?pw;F&t X471 \qt?1V-ÁHegO)"׋.ߙ1l.2mS{^O*kE txr`W` OVR_ÒN[$h& @t((/+r^l[}c}R@W  &6'N{W]5t -a9ݗ~O!rlDm(5Cm:ztE5+Ė/a~=7`Sij~ݫi&ia`nTC=٫W*Ӛ69XsiNmM굓~ôχn`w VTP Wo#$<Ϻ":uRJuaP!ZS mi~} ɖHK}agif S_uq0ϟ}bKۅ}̃d1L/ Q0 ǒgEĕ3^h(#$1=gRhH[bR`,˓/RvT\P#}|_utbQy.iNY6꩎*aOdmo6!Ps;Y ci "+V+]nIkfy>zF# EhB ,d (rR3/,5W*ȟ^Q''S%Ih?X44^lU Ѳ%?#ڶlN i_=07Dj$)he|zHx)"U[>r4p 40NlPQW>PGȌ0-vc֚\yl<x,<"C6r0}?Td|<> x5=6Ĭbݜ.R 'sKQ) qgR% $h7Gk`s(ZODu&64_>04 kI-.(:Hy^Ow72w~t9kbNwʺiV'Ku[_\&g|VHyv Wz5N➈0ź7&B M![@ b,睠hv&_|+L-mԤM@!/q(P}4X F p\D+}L } : Xj1Z4BOe5G`AU6o˥ѥ]8Tzi?F>oB9#m:ym ²".7D*(a`!f!햎765F/T{4HZνYaZ:l?bՑG'Οy?I5_#atgE&Ǜ8!lpB?Y4c+bTV%Er[K/\Hp?W'J[ A7o9x=s89TT70DzҋEđݪIϹE(wdo=n (C RNzvKx`:K_˺Ο_7es'S;β76Xn)Uo+002 %-qk5;3 siM酚[%}a*A ˎzn4L ]lӡEi! ʹ.KאAoNc<pZl.HgTV谨f 6 Ty/2~?8¥ayy#ojCRꍚDK!-ֻ2VQͦ c` O!KQws?Yi>6/c /3ܝ->Oﯞ_a7H¼aPa-K\#\B{b3@e 8Pa*I_|ZKbX~-ړmz;q:.!b907׻z{fk)$T7ǯW//KE,ݮhF? 0_!TM{v|e,|S(Q."?uMcSRp_s8C`ױxYn$,{͞ ]W@w^1fBX5xDA%&+aI?ߊc + C9 =R A 'tP=r0:):gW©[ި]vͲ673]wjgzO͈Uo ̌QV+FlƓon=3>20MMO+<%4&+X:-Q+,J_ҺzϹ hk}KMVD%N#B@34?ght }K~W%Ώ;h4XTxi:Yj$I~[;p#ۆ͔:Ú1ucDzBW*vmʌ[oU/% $R~FO&=cnlh4\YhF7z^r]eiqЮqtUw,XDL}gy8ʙ)&aqSKhoD_`2F?#ɐ78(/iRkc1FҋJw_2Q`SH"6CI_:NAhV׹i{'cDž#= 'Շ rDti: ax6leEy1aRx׺% ""pxIM~[5h-Z~8$ h6Y~T7 a!]  -`/ .cA\8 Q2կ&oxɁ`[ \g{S{l~:G?AĒ _zNfXy;(jLYJ }]yFKM{uۧ<k;f~Dpji J0 Q%ƻNe*Y݌wS0Gp~-b D(A,Ou#sŃ %e|Q+d W8RyĖ02)[ȫ 2 ]纵a|WԇW$rY3O0i0rYDH=ꀋ .Dfa 1|1 ]-Kbkqڇ(>L"^67@C"dݗtjLv[=px< ՠ˓`JNqz]c ڞm?{*fhɵփٿqDiIZJ}|ˀ1ә?-KsoğZv%нXݖH:ylV 6}h\0=(i۳dFm'”_8Xm^`?_t=&l@L#3_d, <"|g}ZF88٪Y'w3"c%I(Z`] _vߟo;y nU=b-JV`c?ZXg!>LyFwɴ罚%冷~{~bksěDJfAIq(Ęz(]U=pO=yU(P {|U5TN|`Y9ў\=qtN~UoRl_#?ͦ#>h߆ x B^z̏N t)$Is>T=KwVYmӻw|_.ƨW(5ၣZ=vfZ}D\@A8%űi4G.z)"1HjM7swzn64Nׯ"+G?׶ګiqَZl岕1ٺkJWB4pddp\2rΆ7]_RX*KN#Ԋ|݈:O\a_Jߩ%fݤ{\/[%֕;{ Ј>Y v-A&V\ t.QDC݈Ob-1ETl|Pպ6N>ۅW";:UM}&kt.'Il L7[?kɿ/ = 1M}y|}s8-zr&=xcJLbwZE0l^n䢷('WE>1Jnp3tϢ j\LR=)\)nJ;?<$hR5Qc>| L,񘼃+%kI}u%ũT>/'y@&fh(\7@:S"rv™rqV7j?(jY_6>xS={\G,H]a[7eBG X3Ꮈۚ T1Eet&M轘Bf#&PGOr}`M׶"d |hx3{K"ݶ'a{Ag9ں|awP^C?޸@;pK ok)Cn.x}Pkht_DmCY˒MVhr1O-|ulD+"xQw@/; C;3[ >Wȗ'Q 28+# J2B@QIƄy&YMx A2[Z#DtC:$QЀڣ>k޷ب-%y)Mb!}yh%wQP/4 Ӫa 6ON@'sQ%EFeq{?+e4wM7dkX.:SB 47q7&Wdwhj`@[!C;)IzH F6yTտ %0iFR+d2Q^Ǯ49szжH<~|geA7jLhC㎌:;s®ESW3 C։B UtBc/n:I؊HW[vJیlEYwe8- |9o"3SQ:+DUG:|AA})~U- ^fτ5%6g_ OؗT/(IY$.aROԇz8+3ì.Yu?ب8CT4 zDٮ#x}(Y(+/0>7pa>z2˅,o| `EǀeX܇ɯK:Jvi*!&xK?0@j#4S<) űmdNi͏A|LzYpc_* [ ` vg 5P @ܳ4#etF` FIV n;[o]M lft (,wh7vă-KiulS8 7I cgGb%C,8($~~#<$ $)`|[k< D; )IRM˟0$Xb~]8 B>KܤKH;Ǩ<g/zBwRJ\,{=~l6'H"e i$7>Hfo1s rWeAHiG,AoRoa5T >}09mZf,9s]c~"߳^%]"'\cv6P(r{+PH4!کZvݞȘu :UICpوqF%~z2qV<\QLB\e+Noqac=5OPvѰAĻynvޅ\k\ZJ`<ԩ޷|6>;Gÿ6#X>ynHM{4e_Xar=v{c[@3obD67%:V&jq h^I{/Aۋ8D75ciQa'8.)8DMAߡ 4gs9~BWʚpߔf+m/WVDoZ!aUuk%w""$)?:14J[7q¸^^x)eq >TKrNIxM|5u^L&BKme()8W!M I]_W/d?8R\莚+6w8QG*EP34jCKxr0q8SB% ;Extdd0d|㡣C8d8Z޿bGp;"ɖ&ٻt&ZraUl޼! z_~L}(69VD.Q ?|JVE1xlw͟G&(^D?{j7r)0~,nMqq/9WVV}w wRv bpڃ nƴvr8udR=OnS'k_Uwssؚy]l90C̔QӁܔE@!'/=o]іbd>@FNo'P+Dž`NoBBs{|C®=y{)}5 Sg-kd7[pc/J=AQ= Z )ω|CkvqN t2ΪկLOWÛc'ת?NQGfkh3HSwc$qĔ7gmo^aTZYh3.hg=<usdlk;e:;zr&+eg}cKGrpkZ lδ}wO9^RG4?Rw.Ǹ(MI~h_mzѤw*gޭڴwn tl]#~8^+)w&#_穅nKI_ Ұ2`P;7@ (fȹDqjy;P/ׇW vs}-%os)X7҂4AߜR ~N+i|$~e,Q&=)?FJ p|/Xֶe̯f|'^|mFfTӔ)Qqs΄o2'/R<Y@:MW9򲬫Q| qyelh%D*HuWQG;Lx5[Yϵvby{o<2PEטǮbLϡz'NC 'Mw˒ dJsn ӇI|8^ݛ0¿M~ >E7ZEaz-zen9VZ΋+Bovb߫q(ـGJ1iUf&0*Y1gѯmN*"^9G>[ Cχc>oTXxdӢLw.~ oLVuپqz^6c2uӳWk]l$`גq=ݾdvɓN.LRH 'sږuP,rg|s/MA áV9O-C\g^ɵ嚉27(zAܥ2;OǭR1En @exeZ $ ޾uig\\c-b[v@">o]o0!(DBI}b'C(afZN ʏ?^H5>+ڗcQ ERBuMȽm(ZWPEJoa> [ۮݳ^@K?bz=aU$xzݮuG-S>  zlrP:fTPwgm/[Vl,"A_^O'k zϔM =-o:|h7D }[[iqdV_Tlq;A?Ƀi+<`XTߟgSF;u{RB54#d lX9$TЂn$ ʼnEM`yi_WG^fx9?юzh̔aUs1r>.It08p2h݇h,faWHEɃ?D+e{XG(́-nV_kdY.OyA޳w4"F3Mj]p:Ot"z=CjR9o lk1&[˭82=*|5 :8|>d%(0m ky!*$u Db'59]1<`UsVd =%UD$~|iq-n6/;M 0HAEװπ[@ »ƒ% )x8lCXܒi SsehW~(8Ji!! 5 b2xm 7^ ƛ&xU_:Yx%9)<:7,xN ؝ąM }I3\l!'FS.?"^SP!!Gm&C «װƫV^Os8<:b%"UkI? ~q^1G//v;:a6V_)fS.^G5踼fVvgS#t0>Eo6PeT84Ln*g4;G# Pd*;]_}MS r^V,zN )ɱ>[]nY&o4?t$+V#ۨOUW*rzot ?T/4*&JW YPʚU7>/d]G־K-cÑSI9ZvKsaaj=c#`>8e uRyvۚ?VljbqMӯ"[iR& KUHʵ/w>(tڠھVMrg* 5P Gk)0WQ{0дHI[& Wߝ_/b]Τ%ͦŐF:lH¿?~$3E|f(xLgn1Oґm#|E}Y"7_܈ˀn.b+KMuIj~9CoOnȼ0J &owY U{@X#,UJm/ٌ޹ޒ PQA#96ؑB "Q/M|h-ݖȑ6`K %u@HS*#"3z|}2K$`d-<{\p'ڲjBn\EBY<JNTpMSJ{E8,P@EZ* ǎãrXdI@SeX>[7HQ'&w`7B0i󯰜͡L`6i=۵K(,PW?R 3ƷcOq:@ aq N|Co)!z pZչ߿VCP/Vs0hZ21! }d\3YjvD;.~3-'Z{dZ$ =ܠsNT&΅O o*FU}z =v0qNEK"w3w` ~<"@E<4<%C KOEtpH/v"AرO6_fighwu.E3#|#l E 5 _~oldz>2O$ p<:z^~ M4@6[e De{q0 Fᯝ8'V1<>7_h|h2GD;CV۟z8f񯯵%n?[<[PmR_!V$O-D^?+RD%w7~՘hёT&5])IxAFWZj 7Ӊ(ԑ"?g>?Yc 2sdp8v#3L xQKC-bM+o?m("Bw$={)|\lĵ.3dOuybj/r>gDT[X#9g~ܼ 'G' rV>ciiɟrjlJ.sOJ@ պ‡y.DzQ Awg]kV}98l>^4w ou:JG KhC'i hj5SU˒mO/$w}s]]h՝Rs'|3FduC+#Zӻw=/r &*ьAP |bʲлr|:W`M3NQ>|'6kZ'jMOPìT* tٌ3?mh.CF{rK^l]gWO g?KߟW9vU|{W\ޱW:eGrqoL3l(ɢfiu꘯g}A_IuMQzP!_s֮Jtx󻘞}H%pՏ]?>xr ~葫L*)^CT09|9[& \ }j뙛(G3HMZ°K&CXo!ySa5sMt>oγ-A'*^DŽcd+nWpw/uIPZuAV=viRWf];D_aׇ{|\Y;E%GD8[}À竰DֶdY3k|^=Cb8g9v-N{)kU~g /Mwkx'c&pCOZ (?6I[tYcLLc[_FrMa4n'r 2XEv2vt٬w Ӗ^QQ\9TS:21mg\'Y{xdl<=b$_ZrG`„{ fy7!bEjAYو$"7-;ǭ;=2}GqBVV-/&rwF?Fs@MʸJLaΈ > ߟ 7۹j3sO)%,X)jv*S,&M\ՋlŶt?:\=%`Pò}{ (H|9~ 1z> 춂@%#V@Qpq_ѰC{`煉gw8&qO(9+>%^ a uF0h ?<& D7Rݤ̿@٣# 7)OqIcfl-Rڿ6q/U| !j)zͫ'Ox|Lݟo$3"ӽ`|_+Bjc1])8, K=@B=OGc##`CIMyLԶ$Hn> jpK}бV&ϐgl݆ Нv*տb؀m'v dCn2+t MP4#tI373Q;#ϣd/IzSk _A 4<vif?4,ڄ,16 M bwK#J%xQΧN'4})5 Moy55"" _G`5avοBΘ<)R!T GKw7*3!@`b:n|jj腠v.W$.)2P:h7|Ø)PF4W;K"$eHb"E G7Gzt $#~XY|ϣ>^"1G-Dф@؈#sx-{x_@ )#|8-OxGEx`3|є+(ܲ}%8_}i :~dqUC@MיQF`ᨼAZ0=V(XQXJFmu~n'-ɾ(m)( Z\4pHt|6Dt晁U\덡jog/2ϕI; y֑3LH&3?W!Ґ6U-egN>x9:ķL&iJnѧM$9u_OuqʑVD31Аndp0PogZ %ϓ?dVg.tZ/S>F\`MCGlx8eW+߉7>J)+tAVD?{XY7%A]0xR`w 7hzЖBV™?yag(O(Y GK-*sOv#Q ھZ%v2?φon05]7':]N=q hq3 *PS@gϋP?5;-/1fnֳ0('!}~Ock<*}5@#ڿɆuwZ^ک/ *x[>Y6Q/m, !$}Tc+rZE.ŵWr$fAiyz`7LZ1*[PߦqV p =qh1OXyD@U{y"ŗ7D$N ׈nXvo d<Ӗhp#kS ^צi(lxl^qAA>ntk <cWͲ cw="ď>>sJ^%r)=f5Kf!Ж=Taaߤ 87w!:T\eܨH iFO:?^JQ=o%JRAer56korSR)hw BG883[ L |#[U*.k[QO5+N̛h~&]޷尉4>LnKfL#q*ӳ~V/xϝ=L d֥}N ]'S0؇&.fUrip9MSxv! ~u|99Uw'vh ͡_~H`CkëI $LC۟\n񂂜vh~,"s@'9)!*BنGcT#*ӡ{窨#fVT` kϯ$/9 79PڿqXdi:PSƷ܏gPae*|G{/B`=o2x:FM ):4őJ~kGCAVKuߧWpK8O*zޛeG:]N:'lPzo͜~;LUӗRY̼2X"=ocv.GR2 ž*vg~s! /(beQNNNhuyEt A8|[{K_dS+4^tujyU=RK~ju3*o͛R09EFtLfJ'C7& S ^z(z(eTǸAL- Ƕa_e?g VYl;a@g܍ljұ|T=/ 2?9 B@аȟv.j0Br"J{Q'lqN\os;oۏ% ױw9{kjڣU;e ]4-kXC 3y€@_e+=jK$&|[K$^ʌ"V0qzޢD$wV? d~Ī4F=c[3vX Tȴ\kò&165YN1f~:l۳Bեd~vVmQSb˅RK#,Jh,aWp@oΨyvƦK8XogMdQA_G+'CD/APb3ϡOpf\z8u_8LbMF^9oEI.aJ&+Ѫbz0dc6h?(JmAf:g'U&If*whfSUk: v 2|PLݦ}ĺ"$&#:Jg3eK$p62N!q{+;=CrӰr{BAԦG_k1Dj=C>5IimqRA9(Jɾ̏ߗdcoyV[AݵOysZkAʍ!<. jTBh9 eH:D]VGx QC+{kFD%4LJ[ww(p[g6S߉.tpRVO}mͩ#Ic%{)c^@ )jEu"8XJӝid/CT{~b2Vd؄ j^NpP7==y/]6LWD"D(X ^ZWqcOq Y:hf s!<ƐY|IxP'.8t-^0ܜ"6>[>]HeaZ3$  Y'a6 6p,+R8AkER,1HQ]Ƕ*V\T<DbZ(2'|<ЏFFQ=p uscfKaT&_E*cC<7zU 2G jSiIY)^x;\tVHa k"io`ĤUBK~'0Q߃ҮJAjGqa23E9oBhYl>R+Ğ9vV2'_p-K6, }U* _GO椆gI?DHM]+qvB:( v~,!H >5VƭjbXo6$q@o(ABi"okq = R\$i*礟}6jg֒7g؆Ch#"zKv> nhΟ9*ЗGR.fRF(=eV6UZxL1@Gދ\|o=9GvT:EU/ ᆛd/ .=*uZȃh}$d+~AT Wg7#'srD|>NKҔK)f ]_sql.H!)&u*`.t6K,U::=XAqJgG-(!ep NȬwQBt\l#0>~WZA_jB]0SMFzv9&My^Tf_oc~wbSf5 >]q4?)IiM\aN6@Zܜ/Kj^nUP,@.[- }ƝVO%>$Mf"׹?O%{Љ?ئ=$+(l U4U|Aɶz@cZÝZF)n}jȌʙ{~6. zU3Ĉi$#s\1J$3"=wa `do٪%Šc0d3a"How@GWJ8RXzj':$V^5 /{8Z ZrN5= ߖp'O/$opt"#:~5<];\Q88ط$ll3e&z>Ϳ Z=oX/ٰ1ʃM?"L2oo/`ы7`?=&J!.K1o7WyTJ|liԀF s%شhm_LGf!V@Wg@'w|Q@@/ST\>aE]= G <<'2 {yg8ܓ#.t,pPȤ Pi_=TfMq|'ePա,̀jyƽӆY* ÇAh+ns河oi#ՏWk8E 2|V !Q3:V4a❹EM{[Okn F}3S&ZeyrNԻ aڻHfr,ѽ-D|X]P|NSUJEț/>` >C8UtU~D{Iցvϵ9Dύe7&>t{CkFeDWEf$d!:wcw6vlTCjl}? GneF (B#}YyJ꬇ǹ=^ZPQ["@7 ͒|JdzK bh"̕) LGˑ H?_M C÷DYigԷK5ƏY ʩ}].ߠV6 ~}f*7"'80C^Uoo~+S 2(?=͂UՑ[$Wa~7VͫSe|i 䵺hNمѴWoHsMZ@N/zRҼ7'7Ԕj ჩ L@+(4wU 4ARL*< qؖkDb%1xXk"QY$i˚ke)8W6 qvЋ]9B벐߷bV.cvswugNxz.܀zƛ `ӫYV3_W}8ʵsB넌Ǡ)Eq mݤ
х:JR6m5;Gذh޲[TOTG$L0 U>į5jP'n%ypjΦ Arz\_Lv~pCu1anoM3d([ckQ Vj~so;n+ d/,,%x $?䡫EUrhyK*P=%k'+?,$8X-Rm5Ƞppj pj Bfx>1"Eb}_[ߖߚ2oP=]J1.x 9;1 e ;m_ F[.JCȍr͢z_ A=Nsۏs6:k&/8跤ϝa7a_TFX+bmOAQ7%3mĮ7y#KgQVA]ns|r~~v3.|) b;Y-KV_y0)ITM17si9XQ&t|A)LJn3}Y0\Y>!8Uu=mȋ*o\.LpgdtI$U,onI^ OIEѴ3;ej֪N {믢3@,M@U7t7MϦd#m\ mYڍrfDp^Bya]?Y=N!D4_uF{-폕uW7Wx6o"ړr+eM`eYlUX쵄+A*{) W!՗[:_0Ƣ?[\D]-Ia-K^>zB !_bFD,LrzFF泘|)_~ f91F LesXJ8={aO:71?CŠ+'\>BsظR]H$G^ÒL:~,Kܣ9i8= DmdQ&F}wK`( WvmJ[?Fw?TmhgѦt %:`lS?ι]tj1o*ΪwF7w^HA81$@N>Dy-3dOv™Աf\9nC&8ַz8 +܊TN Lq;5Svœ06Ȍk"3Q+v7?[?%"罩Mb)2vol, Ay?9Wr3nfKIjmWJyKY{ w 7ssmrLe!n2Qpsp xM9 <8t˦yj߰X-øz5kB b0G)gt( IsϵKc9+yZR#,]i2醍%\1L:stN(#1w@z4'GL<d${PG_+%o~i[4p'!`R>w'R44xWK} j7?RJ6Xv 8wf vo!z΂p=\:C )c@hGgm_aKr]}5,@)^tocתdRb(4 ڔoj&JI_L )1H 7jM>WG.][60a"eM- iJT BISWoMjVÎvG$q-4aLnDÍ)4:x@Poy#`@^r<2fUwu1=.}*x>Nlt{ f"UHD@~+czHх?vbsyB *h{$xuZQQ&Uk,7\ C%`l ڿ"ढH9sgT\L"؊BO P-"C̺eH4S[#Gn &ZSI*<_w'Q}=yd:RP".jv_?$׵=$If+S  0~2z{<ׁiۚ:y*]_6&w9_ LS( . CKkr;;+-p KKT+S0==ĺacGΥT@Ke9.# @F)d?Mk?( yc/M9¤0{Bcʼ_ ݉HO(A~vX7d/YX' ma6^ ēW<)ivԢ}Py%.I kc(<`S%jW^@ZQ̇=Dʘ霻fb|puǨ|mg {{X  -YJ٫YhKš).JKXK-2OfVLA ?;H(joG!@ynT(_TǓԵHt0gd4dR 3ߕ82req.,}%S,\Q3o}+yXn0yM6N͏}>FCh8`#HmL~z_9M:Iq`L)EMrSB'kf,:_WzzH(Z"1@p)D%bTNGCՌzx\f 2=@+3F5s%;~ߞiճhɡ:Pʨm'"k"]Ӽ)(˚}YqjK󴬊ʇ$^Ԁ>zi''L}VKm`ΘIчS5H}_Cca͚Xd^BQ7Zʝ>s=o8Gқv-_w3*MkoTt-UZ<܎ |Q{ߢD0 z k+ :p `<$v-,ohfw.[ȂɦӖ6VCbS-]DSpD}󳜻s-쾓S;M6v\Hܲ-# Ox(Hynz(H4 wF‡Wuܸ,_E28}|}׹65ZUN,}D vC52$(ˬ0J(R̮_ʎ«Kb:g#!z[:~ uCYX  w9X- !20[_:5)ljwU@ZiUs6k$(@vaaٲN ?:oTc%0č* cPQ9}Hubk/"-/?3JJ߲f/׶flUA?y!& ߎJ5 t6>O uL5OKA_KԧhЕ7Xv=(("do= ʃDcKt7u"2# */Ig"^t63%*+zz2#S2sq<M bQKic-`:2hG knR"Qdl=~jt)g!~֏:OY&,ێ\~ze)_w%r;O2 1TD 4]+˸%|P_ξs'7gEђHKf I#Ѫw{ߤ?q~|oTlF-A64Mзn 4zZhh+@V J88x~xbj@Å%ʹ|OF7q3؝]3ȧJחw'0Q&fC= 햁Ea2=hd8(%'ޚ+GP Ba'zp0Ӧ<B&ar1 =Ht &Dv:k_'yŞagopw^vyHOtl$\jDEnf/~^3Vigq=}.<*fePl蛱Q/gh2!ux".]Y^8)c?^##7+U5]]o7էL`e39:X:Q/&7=sD[ͲP?c#?iUxKoHbs7~,(YyS]G!uyvՏu> |Pshy _H~|}.XT]٪;U|jL{Lf5q)dx_`X)ZM(!F{(Ppq٫>\T`x9t(Z"mKA6YyKg!U, 眺DUﶥu NvF%clpdޭ2 217X u<ٜMQyEx[c@a$y!Z5׼]?//5i"a#YfxoS|gRZ5?w_>FoiXL0uyG6}Rn5]Mnt fHӴtwFȱAv3*or ~/9hBݮwʤ#M[A8kzoʜwk|8٨cbpZެZp#Bay0Ŀ{bL uAԕ/p(@R-# rL--@.^= 6droxAzf8YL Ӛ"Mw&K%ɳO{lt>$kܷ!]U;qG p1x ;n(t* x\cANՌ!wNM}ɲ\C+e-wm@5voe;u&}O=>{z#cr.:v.yn Q|eMz} d!+"cXV0W#`Xףqk7h_&'gӣYoQb83U V3?E~c=2>3 i;wp  s>Ƈӽ衅}c ׭LɅr KWi5VO7,o.uO! d b|~EpϔN#(>$QB'Xm2Ay׀➫mՁ: E%c>5* Mˆ5MZ+?Gh8Mmn dJn~XX <&b4÷^h"D*^N?$PN}HkM @ʨ´Rfg4Kn{V_)";|y|xY Axh2x ^_~44& $ҪUِmՉK F ?RUh~7OYa%ƭs~\zIQ`Ŧ[w(~|B@JèYJK?zaynBp!8[E(hHIFK'݊:5J?8^HBo2NŢ5`WɝϚ,)Hzً͹eAv/Nޝڏ\pŀokcq ?>c ,}~I=+:Htek9IKȧX2ۭ$=8wʠ / ;U]o!!% xs&*f7@AB^=w 6ݫC,RJlVQr탒MrV}v <]d$h4*|hRUoX!Boen!GELcF`i/}-L'bN,@T7̏ARh?A~tI"v~p%>=oΗZ4E%ޢWO`>ڃq\!r@ jsBB$U^7n0ݢTkQd-?dN ZV^B88y,D,ʏ.ym&w`p򷹽\2NTo[zly{J_)_rn8 #u-c&E8܆|nL J8D=Tʝz2ODM)ˍ zpfB ـV \]{qT9"}a\.dx)=u$ H+F xC1\C;$pس: =Pۋd/E&"B'i|YҦCKgݹ۫*]tS^S-cի[~Oͣ/fXeJ\گ?uѵ`8wWњÍ&I8Y=n3AXoڻ>A%z$O@57雔H} ;RZ7I2Uorĉ9xdӻzOTn]ՇX,ɲCo>]?& ?%ڵv9>gnN2:Hw2b>~/ҫЪ/k綺: iYwH H>ÐBƣZq'Wg6zaD% ZCi^j@bN'R9^zxTty8p(Ép > ^⹏FtAq5~$E}^Mŭt]zﮡZcn"` #zz9rGFQo gۣH]^;k5shvb@鱿stvZVUu>?a>a_%L6zp喭==NJϣf'H"/nsՂruXH"/⽑d<C Y?:,!z ڜǫSOy0EeMETYIe/:ENF=ά`/\w3M(+.[=LYKD®7шyd;z&}Wxhz3@qA$9JF/GQ-AMta[ htԧ \$k2aև0ϓ\8>u>pfqi2V E? SDǜ紿U S>b9Q,'YO{U ӳ7KZM6sςY\xanݹrѬDoLʦ&)gxÓɰƯ+Y=F1N7董${e׿h̔S7x!A؟aN:sCoz܇Io$D,j+[ [wDdrr"]?+uu{]qx+DL^2kdA,3妘wDcX%DDsm`DUDjH-J7sFm?Fb1;(EF'(@H7̙4t9J'd,+v$:u ߣWG׎m4y:X=4z1%!'•wi~~ !c\` ,wJ3%r<>5ӚN$.|11cF嫝lNH EYrus}#V_:,I C? p8]rf֊udvIN'kr\&Ϥ+R6ֻB%w _;'g#-$I.SܳU̴k4.N]j'"C}onS`b^[-M4TWEL;m̆<@z b=5&%՚ѴpI%/~CWJXf?[{ >Vqwߚ#VrւŮi4p)XHqW>|/$0#/Lݩ~̐7#$HmT̢֯,|cMo }{E[N3%x;{{]&bp7r*k h2D|p. +iQ{tŇA4CWx`ѽj9 n>y .S>ZZVw~AAqAi_bKq9Ļ[&.MO:;=!Q`~t"ݞ!-zR;Ϻ~*Գ7D Pdn2{0/?xvCAs{mϮh`!%exO_k+oZjBzmePL,_ԚMBy%.f0Co K߂ VA='ZA$RjDf ܒ "Q`y_C.FFMTd*x~A3 xcHKonw< Po>y (ϖ}1~" 0(OHAah`\@*,kK>ZoJz 6['㷺D|ߞm= & HX脖o]c,xoXPX  n^XhCoTf𷧍FEM`[1㒕ERHqpK8 Z0M`XL"GRhTkV wĜvr *#կH,с',0TxQL&#-UKy\W 8:=t¥[1{Sޏ,^Q*v0V% : Aӕm2meBQYC6jD·*ާi.7i{u[wJV|B^h0rTI#}uD}֊Ɯ Ի2AZBa}eRڏ폖g'6cTO@jۧS 7cdyb("CtPz wAX#S.ށ\]vCw}x#QZʓW8Q'ċ!p~>}5|n܎ºLnb]3R[[?'`\ ZQiRRon0 Pb3r,tz8-ZGbe"`Lb/NɛX+GA>6ϖȒMASn+pLu=8"+Wcf_JIv4qZ^S J5@tN!?_Q[78ܒ`-TUM*p.C()4iz~J  %u5J1ICpԭ^u])1I?XuH'E=H ݠD(zL޽܀ڴO_ɵ #{Zܷ0w6, )H| $*N\>-v0 &yX+OHUHPZ:`ww~ϫ;)V[𬋤cYHNL=K)Gӟ@}ʩ<O}GrM_1DN( :" !8/Kѐ"e@~o~*zu[F7-V6iKE:knv{[eFB{;!= >( +NsSb>ӎﻸx6<7(53"ܓ3q4e]4.MݺBѼSe>vlY~ ЍI/*/{ r\ȕ/bM. ?új?eoYJ/Nn7{+@PZ_:tٟ.@Xѷw6S|\Ky qVJT,gתOUz 2:eIqx}2+I k sAnhB#,)R=G;-@@MD4Hkoڷ.ߏϼIkiMP1W\x*8 Wԥ#/Mz_6E-0)6~;t?k5H;Bxh;3H5\ 63lK1x@zqo4@}wpO;C`(/7\ ǔXXyy5y7N>Nj7|mOW7M븎}mBڃS?oa?~>ۡ.K<=úrHZ_o'ꂨʢ/\%_:L1aq47R 2P)Gꞓ,7n`~ e1sr|s^TWz^/;© HrWv2BSſ)gwF5K!=fG<ˮˠ̺!וYQ>TGqI)ߤ- 4=߿oW}\!KW˾, ^Ԯ{cGt] u:Ymow ȗ-.MR{爰T1{˥߼.y!-wufm'$j(׷1iġIi ˫y%T6T:L{Kxkmn>'ըF}FJN8͎*|hW0Sd8< 15 n :ktLu]KI:2t0=w>Wl'UrZb;ASg8fRL5E$:BGimq9r;mu7\6cD/цU1⌆v|̓]w lXag::fbsoPo6(3cUuN ~t}Ru9@&{2:Po i!x>> ֘*IoњU0?odL. ЗNj$;p^;6&yDps]; &~CF-*p{ G zHتTc=}ޏ{ rbDuzG 9A$h2KyɿM _hFsGE 69m$&Ǡt#cKV)0>F ][,E12Y/9 Q 4h\/RJKM݊ aD1fE\C\<x1GigJDtU#(\Hn}|9 [ T:V$%Iml(k~h_`N}zi.ġnpXIY@S-f5MDjj$f%X~AW)w]*u+N1K볻7KGaR |1勯U7 np Q9kp5ۏCD#}|1mA!D&8 #OWs+#N]p,9o9Qkp丙r&$0vp\苫A͑Ly7~ ;trmu{[ۿmoGȻBs\1Wgs$:[L(ybWy]Ճj?ڝOwFd* {G\E]֬a0îNUX/; ؼ.wg 88,z~%E?IG#(QL^G˱ﰪyC:gc=ۯy˭1jXQFJScj~ {雇0CcLK,YqT%F>0u Wn7`!0CyL͌˃y<]p/iう|$;gη ñP؊ʣxJД6ݪb`>FX|XM y!A=aJH4yXHږ9T9Sft$~W@H|觔1y5|DjACza"3LzK>8+otj.:~ü#T? ) rp-#s(zhf{9¿@{b;u(mDvkk;~aZC%a psb4j,/s!hwM꾍5Ɯ)y"]Tf?ӗLk%^W]cƐU?RqfQud. o| ,iK#jA`&x[φ1+A1xdEL!^0S=wA٭VZ+[Q3Vis@O7U[bVvw D7F=aL[%܅'g%'keוyH!Trq^߫)~ c&B\c<{i\Љ,Z*4lXkmJKG=ei&Y2 0czvz}(]V޴z?T aڲqL+w*~QgZZX6r t ctJ7x9aeꏉ>nۃ*TWXa>?ߒ^A@^!A-aΌ1!z"x.p$]ᐼr= <$渴!/Ə0Mq~4zȁ4_Joa5MЙ-I;IOUv0_J4IGjf7]]+`E;,؟)|it/!z"_Y+8ߪ#o\+#-Ki|Xd8_[\?!\!84FW#U9MLC)zӏp?s(˾ã}/N9gkLe0,V88XlβBS F[%t_W`?eڭj{:8Ň֊8@1*QYy;.;;B6zH 4<( S7M[` eƣgfx,NA"\E"Yx_?*;5綵5(-)b\ &Vûh3Ůneg^Ӹߢ|׺'1\f2?p|"ISTC|SWj.ͳF_N˚z̸^ ;|,l+_ cbRTڏzQok??]frJHA6Iny'0}MS{FB52#r],k:GigySkKk^@C;̘i}8Dv\o  yxEz]?oy  1Ѥ]F;hdy[ęEC[{%,DG:GY{T!k,VDZ=`RރC(xcpdӜٙDM,,}Cw/wܖo'}tC+0m `.SK< e *{#Uȧ(9~.A~}{ \ EOzY]'ɾǠz x\Xsڧ&i}[OC"Z~-aq>^ǁ4:,NB~.N!>?5D60;P:bQR']\(8 Cg `Lq#P̕(lX#ox|jgdp*3!|Q1\Ŀ?{A0.5pJukxLc iа4+&#< |)%9%?Wlo9ԫ,׾ 8?} SHuCl~ oȅcO~%x-LrIXzG Z^54-x7WMg2jT*c^- ǝ6 X̔ׄG-GJJ輾aH|($/R}r_tK*_[5頤-\II SW5;辶} C$;P>l nM{7 H!1$#YI¿u" !5yR^|n<`N6N|/z^ ǟoy0}TV|f3|"x$*[Nъ%n +~q6:4ht #;U rqC-nAfd^~% ;R\vTVQ(5a/_0OyHq</݊ε܅|Bt`f=A"B>sg!W|ʶl9S!MҚ.þy=x'gfb;.%:#:_ z!Z rQ\FIBΙ 7'xX;WKq$A%M_P9 it)MzdA1{;a FpYp.C gv 4iG+9MK9m vOKŅ%v]J{e2Ľ}%1O{ο}Ueu0̃=C@ zAݾ uwf$\FH)i&;U +=XcAd]8kݸ͗ i |o"w3T@%i`|@zS*!oG)N,ɤ=/Iw (0A9)bI=/ԭVU^յB6 `O79uFeܭ#A^΀7D^l.@x|Е]{L!U|6EH+7or9.mu]AV>ջMfNGl]Y()zcBR8wz$N9+%. \ʵfe}vn8Ʉ%DY6 H-@+)nQS&p,3I xXO#OfFwf]gXmyq\)ׁ{c {GMJ NI0fZ<ˡ.?GʴGtL0J* `05kK~|5/ /m~HI 0@AV记jD{#͂Fr.2:ާ>y[-P+zĤ!ɌT;ur^z/ACJ&!Dۨ+ɼHb̉+B ة zhlfTibffPO)"p<+8Dj_È"]BU{KYQwj?⣽M%P3?#o(L.'͏-x:X l޾Fy\׶nC:@+4UձaG-60iKjIV<̳Mb? 7X*5oCW(%,>̡睦K)Pp8qG-7fu$bQ{; MM *][V"t)n#ָg­F>2̀qy揁 Df/$/V*76ЋZ~OsvۂM0J>4v[bnN _<oY;lћâGۅv0vR<$Ɏ y}(|No P&hW-k4*5 h##f8,IhQ܉2tf*s1kxꭁ5==fv:ۥ# &ͶoT#t=D, DϠNF1+N Km(-ɓ`p \6,HZlDOK#NwV[hVA8a]}oxأRbpU99} N2 eKSH8TIv6A  V謁Db`NԀjR<9 ##G w,f9o#Uˋ`pTJzAٰSqFZ]*c>ӷH:#oA NW+$KBm*c0K*e'#ѯb_Rx揀/f\a 0U ilԣ0w$v/H5'Rhc;_?JT۫/^Ztb?J#g+XZw<ǔi&\L/qmƛ8.rԒ=ŶèF(ӥ_bH]<3hN]P;{=+|nݏgn@BWؙT}M!Pi8T9# 2,+s=|]ί\LʢGh|ڣ2('囜DI=?(Z?'͕d讹0Gdv2xɁM ޟc397ɗae/lh|$| 0ͮSU|\GX}qRdj q|?ߓZjDo&[k9s*MM_]Va/̄ZH%‹4vN4^d>>\yK6~M ~\~Y2:q,*|u5)}U6_MI8Ȥw,ڦX;-=5')|q@AVNsZ:6Pq)&a[n#1ZG_SǥSۺnvqWe2t+U{:9eگg0^pMf7xX}|6U4G/[85AH>(.l3faQzpl;~7V+ewku՜ԥ^_@hoSB)izoP<7o-b5FE`~{$2~K~fwm.%|wM(jI|ڧ9a`GجGL?,m\JNSH~PVI+MS|DF7m7=3A"҃ ! bAyp,u EcG0+Y$Wf-7oK}9-Ve2_ERz(];3 :|LuZ~UἘ], t\v_9X?.fѩ(w8g%>2ߚ'{Mp4L>t>ɲjJtq۵l|S2h;#LK:̗?e3/ >1u!b%|홅*I-`{ z!2ҥr-kz7$7qj҈ۄC9Y?~V`:|?'aP<=iQ .kE}iU쏫6 崕()xƛzCS2b3o%u@pG+ ' 0::f^Ԅn' .9)r.Ccp jeMHݍx}_O+&23,}`@[PU^*ɥwpyI/t"ۭ|sh -4c~Đ~+Y\-˺s{X? o VqNyx} Q2(~Hε!tbs5NĂKZ>wb3Ϲ}⧈IL:ͮto?ӊ_wM/#  3BEDӬ=[&7LZw؋VZ,{T2ECҵÁ}ߛCX`춵'·^!`Tu TIe =1]Ut9'+صg]geE(0f8cUfSt-?+;;o#mM GuGU[1Q+w8O}s#» #8>ÿ T4nIcCl&49^}ߒď^/h@X8O J*\}/1M߽*:ρzGm1cO_h.ctr||~A&uJ`stYÏd"|)!onkz T; cZfp^߯ '?qB1m+҅H]iPQ5&/]# xX܁7i0$n K_1BH-Kj҇n6w·7HI818 |M=/d 3ImR=²9 >*lBH}TQ}pC ]5HQ0c7EX40 #'!`xi N z̟ڸGkf=BuمFwzAYd8K^۵gPsRMw]ܧ~Q0)v+OY=,څ m< }18I^g@S! y\4V=%t8'}M7!D%y;'$- T?Q`*wYiד6e(s[OjvyVT ]?au_ S&@$\o:6 G0`O WϘ4L|W:t{炓z&6p8!/Rdh |Tf_`Wy<1DwQ/> [6#pvF&+" S6r+Ʉjq.yNAW,BZR ]'$%~~pM4aw 3Do&@iִYI∇%biK+0P%8ʌv"΃;8, (` 6189 ṾM`z4Ò F { ~Q`#hO7` 7DH?'$@Z1g),lzwBN\A*1Wk*kɞf;6d΀5^ ߲tHmPHhd ;I?IMw_Ʋ|y&qXx,_~HRT`^E pw @dy(*OBL//hmD6DNUN,!{w," 9\FoE~;pa$C5S'^NXi=V=I瘾'j"I.kek5W5_1SIE!N)yglNXsshyBQxB9$=-9raY8Z_o-9?u :9<I=!9IX'(iX&rr 3Q`-kWf^[+޸Tc W6w:q y&iZԡH~ז?'*PwGxH[Z%ZfhغFVN+Q2eZg*~(7x.g @eCLZs&\>= Q{ 1QL =7CrkW z77 >0olጤQ?8EӖWv 5ZR R~Tn,em: >5no |? ذ(Q)p4gU zNO:⾒&{*+"pśn8KRƹҝWLl+/r-fmwU[Q 1Ҷ\jS}kDhƤV'<E%tLϰWZA`bd捪VjaRe@F݅эMv\￿b;:]e*ុۤVdẁy㣣 t~0Dg7tQ._FN<ϭ]xf$c7WGc 2^oZ#Y?+Wb﹜exA3N]ff>B+]X`Χ>yi4D9 [[;/mqT6N5yWZi a@Z0[*'bx5|bPGJ;˘h:^VHW2 5A%?+$Cm ^+d1Du+m #n 7 Rʇ&VkCAliД YNC3wEXSwV0D*- E^o N&IFleD5MU;5rRTg%.-MFy1loIG4u+Ґ:UliVaZ;:`9CчF x艏8tJB=7H)TX˟ , 1>%s>jӱPcY=.>4SN w~6J<.-.nhXDg+CaLUPe|cLdK-b:GT* e'2݃MPomvoMu xdNH^Ry%XkI) DiOH=;it,RE;h}!9pj>7!}Bԡ{GDz Ά=mcJd ~S\ЅIR~'U$/gx%J-=25ݞvϪ]:ԍz ᰦ;Nuva`x=u5ejR: =ri?V/u̐1 DI\.oß{+\2{O_ J [5)y9_ٙu^^ߥ6PvB[rqЅ|o.?D竸YZ[(nSx3XHO_[Q?N`ٓ`:.◷ע̾9'FmLDY> uO90f0q^fhsSZ>! !o!#vODr9kL3ƱJ]bjiF7n׽E"dŢtH&YV Ơ;.%'_ˀk Pq%kK^u@pQvĜoV$`\ mChi`}{h4-DIHuTS&RHfC|!(D,f\\vAx0%l4)ps㞞z߫Rs0?B%xsU@oۙ'A8)NJ;%X|՞yl¥Z` .;p\d1 % // ~W-U'DY8QV"!Ļhoc}4m^lyV^ӭ|U|hy$}M n'?tKx4jkl 155e ^ͰH0U=/t "ccoe0Yo=ns՟7w aCv|JG8J[1|A*mι.;`f$\p}"L#䒚aËR%?rj._r%?bv=]HA?{m֋A\XP3ݓ-h"J恻qRjREdL[Jod,BK~}A|n_4mB*n$"ÎVG~p?F1Ko̴]%E^ %,Qh&AIKr-OB%| )=${que$+X&L#0L1eܤ4qc!ipױIKeytˆ6㼨?tKg|Lcho jׁ_L(I^пSyuxԅ_x0 76q)sWm-96޷tm_;R2)ۯ\G%`9v*nS8|$M2^w/ߐz/EpZ9prbޓ -DAѠ~5l=WnY R<>aQM?=#NU!>mJI`zTmPG(KWmy@fߓ8݄||\ﯢWUWɜk#1.G9=G%*W~` Q]]^ ~:%QXxlg8hX ~rv>@C+\Чf1!1֍RnA?KJ<83RԒ )RfK,9uM`w?rX\^yy&Bo]QVJ)|LJ]_Vޜl˕e5USeq۹&Ͱ\8/_yFD=;vMhx4ɜt'c&<"7#oG+@H_T[^ny(FuhĚv B1-1Ϟ$gZ=';GA.uF3օ:xq E kW$lYNAfӤaG"&L\o͗8h:` =ÉUK}ĉ^QI~s`& !g>&g^ ;A+.P9金'5?]OjK(kmW'r>q7m?9K-yXzޛlR]5xV,-EU黂->x[+Q_0䏐 ﯇U@4W"='l*Ǻ :2faGFVCh VC B`HQ戟@5"js;sPuS8Vq>D>{!'p1Ik55UzѮ;\B"ؿJ^ w"rӮg'2EqD9t- jb 4e21T[5fL~HJ=}I'KJgzSe o;w mʹ?i a2 օp Wʭ7!۾imӶYȣQ>x肳ŠaN %߬Շ FͪR| KY. NxCܻL sjOYy0c{M=G08a<3fec+>U#01sTB)>/!JGbL5 v\jBTVV%^.!opxoLDF(1IRëo9)r׊'~46!7ΔP3bmM8JJLJ" m = (h&kq鷧-k!4@%z2 {OG\sAYam(05ׇ`y[Hbr o7{VMMŕ,H2 V*4 bg15ck;}'kK8=S'IHVCno8G"~.Yt7Zy/G(:4l0PrRO;БPL&ļC@yY0az;EM\ sD7|{ҩdm,5 uL8t+"0\Os3.mEV#F 'n|]b'=4Xz2$ MŒ]7^= n{f:-'_wȲ~:LMZ<^Ԥ-6ŷB3C⾧t?tȈDY&9^r_t'M@ i^PY*;eo7n\*Xcd?:l~6SU˅޻IV`>* ~]rl V[isp<{H,!9#禮W11n ;wn9$d/ -:`7ҞaU(őP_P: O'ɱh3k{aw Ԑ0*ǽ}D kDm][N<Ζ~y>RRcMb.䝊!oa|d}xp>`E,D$hWZ9OkUݫ}P’BkNL.40+{V}V-d 4>K΅$liNp&w0&I}~Kl|?*c}9O',z.{iD'҉ 7|^5`>ҪC[{^K SVcxwow6v}ºS;vyYs?jfH3Ս%A}&u73+P\M}f8b9+.~I0w ~R t)rXtcNjQ 4Fs,!D+UA;]]kǸANMp ̏15@ j ^ݽu$XK71eiY3Frh.),ƙTo'+-6̄ "@ GIJErUX h0gt4Dg"r;g]cZ#vuĀTWb :$󢎑ߔ>ˋz 0 d@FbH1t Z Iwo /ovf{ Hdimp7$cgA =#tDZ y1̱ۙ%xߒGjh#R1aIIr#꽆V3&D їAw囋X\*c@O#Q!9#1 E/8 v(0;e[-:}I\[/Mg*g\wOt};BQU 2J <$H;O0BE)<62lԤ:K9hKulXVL=zQG4L[z ;vퟸG͌FBY<^k%]c[k+ |~) C`w-xrG 5@>R+N·u1}y<ޡ{PuʙKD \)¸͕lo>F F{7("3̵4<$/eO7%BWz(t LŒoN|D@>B%gBꌊ/!2u%-3J ٵD#w e}[\FrwfpAo'5 |՗=x Lˇ]I?vK/o3GGC-]lR&TqB63hFkO߳Tkt S(2I7AI6<*N [VxW-(g.}sClfF-UnP@CY_<{7!+? 6zH0% cǬ!Z:P0|uћ`[!"{F LLܘo?guJʹ^nP>gZ'L`4hLz*dM"jJ-+\&]Y7EorCzz 6:oxw]R=ޤ H QQjv!lJeݰޏ2)H iY󍝙E-gR򛠔=`b$EڷK)`x܆a'-Xr78$u[ N+#3ݸ.*jW|d.@ۅ#iY>,-T̏܇>[̺l,*e븪8%Xd]{@֯`"{ h=|6~?5Jm@3 X73ؙ] q?{]䡑&JJ=?P 8=8dkر#:YrL1?vYMZgGBiQR9xɮeLTRʀZ瘔V>f*0ⴷjC+O1tSm]H/y|x5c>rGX鏞 mj;6O^[ nfT)\ʋJ_k5'ōrO%MMPPd.pzP{߸N*б ˞xw;1T?- u!Uj`kCweڟ&\xQ}PWI@MW { YlH7LR@_(H9p3h,wh PNvG+I]0F 94͇ 5ݪ.8k5MY0k R%%V g ]w}mvrFSY*:6{V`!^ 0B548 y{/"56bdA#<êkBz_|Tr>~ 6ps[( LZ7 y6{Arf:A_bm =gL ߍP[ {V#ᶺ8<œSn-uJ> Yd."srܜi3v}M;"-!aN'7_pLA]p{;΄GU4-t]rRh@jgssm%ª=T77B#wyu!{:o.#e1*=-vu~/u:A*o}{a0@sDM廍q\j#{(?9:J8)yσ_8t_3!%/ ]]OD<'bJTo<*AJun< :0ñBgZ/"һ[NdI kMA.^54xh}N>^~4itw]z:GCVӂ6߿Lx#-sDmdZܦYӏHs-0|, ަRhKd;~{no9kxSv*L)ԣk'ii>e'xZ(uGAoh0Fix`$E!~?@YJ/|6ͱ/kCGʰ?i<ίpn%Q:1۷8{=PK\x|E-]T$bSk?d~Û4.||41W ga{PU..D):Nk7npѢ=`XrZмu)U:l))a!$oK۳{1 nػ- ]#/U2>tKt_VV{v߶蛔p*W;}9E^͋J5! a^k' Ih"]AFP^S,~Gd:I"#˲7|RkhnF:떱;DI6 ,e;Yy{nX>rHDXr&XfV>?lܢL3c,p\YI~ ;>U<xr);~(?| -ϐjtW3vO[ 7j꒹ȚIIxNšstUAyяfshkaMsJC3]Gv(G읒_ʼ0nh0C,5o3Lw*7qχSÚ7*nfŞӐn1c(DZ^ TZdߧ: Yi-#ec sWXgYkv̄@SA3CGڠUϗKR0K-:|&os_4mJ~;{ |"92ucm "(QզY yA:hTd;{VdBLZ: zc%{oq4IMbfO$y\m<0nyZUX{\?ADTWQן 'ZYpz 0IAG@!!8GvK(xc tJ$΃xV &nU.SlVh>" ,jwJ;\wBZ QS3 #r&;I[G "p^tI~|Gƺif-p:e9|Il LᙈO9,."eq!u\@a" s\z&EK7%>Ѽ@\Y}7 +'|iO-EޜFvq2<9zWŤ _;*:cad^GDcG>gogy$˷4˕Zf[x@5?v L6vJ)fDwO j~j7@}*~p]s1q_NR&y=fOy4kw/}J'|Mwr=^2CC!D]< וsXlyfdnE6BԔXdd=3&޴ *74ez 4I'+ ^ ⤴x<^߆' cyD]c;l9)˪*Ptl΀U*An9jQr=zȅ6N(iy T'NǴFۈ%]Ryj RagVP?Sv_ӆi)p<|Ox;5܇!%laD6rj[zwDy5?d((-7>a&EK̆XPc &.eV~MK7 $74`rxc{'b^9۰i:d%bR𱜫`5P}Z}~0  󕋙h}$C}E%ꏂTW @9Ɵ{ -9g+~UhE-De\ݸ1 V 8%l!@Os =P뮼,@؉Y&n'%}XK᪦<*SNOC JglYMowủ#ۙ=];z[D4؅/tyF,grIآlndNG >Eo8L>~XdGrX˧)>.>L4.gc:{ߟnyr+0 .p׬oo2dCjX`j,mm~ǻΪ"OuoHݱi4lL7?w]i՚N+6x|wU y}^ :мFxg3fՎ < ǁGXNɇ\дl_qW:ʄ[||H>l LV~Lۑr}Vm LrRBNۇe'[4x 3}r^LYt&1|_@Uei)6ZFd5]UDݽ ֿٙ΢{9 Y͏> lG[ӽ*.X+b:Po 2YJLyOn oFZq )9'eZkkytv77 bҦڥɸlgs=@/2;mll(58KXLJEv70|¶P \~&(ү/̐U'./E|8{a$oF Thhax/ra0M5r:4ulw%YgJ$1l=}.f%Xc|LOi3\z4itQrn7_=C48mZ*Vâo% a/tJS˞]>[c{O=v.H~_| ѽwW K͍'M(^*`0~6+7 EuX[Sr{f}Zi]ŁvDUA݊d<1#rP a\_ UMϘ.iBN,9pd3)bpOt7Í+KPPsifZd@'4{zӵ7f|D.!_c\ M8]̷N5SjiLaVuS}/+]1FQKH=^5aD `?mu@ZαzB9+vBu:6Ar[ ,k, j~kUPpBM|9PzG"CToݾ^pu:wnɬ,ASŚdhX)m\&J z%/Ӱ@!~}^ѩUs׳n!P8?!*%ӥնg}zQ)[ߩ f)ŏ6'X42U.dfQ W@&tlGHl,z{Hā7X Pϼw,cװ1}Ȑx cUDI04B" 4̬vAJVkh.b9cZe(q493Hi&Ѱi^(2` ޺][~Z>~*= O\Y9~V;H3挔q"C)mkpk.G`,RJM$87̺,KЋ ;Khii&XI(;mUڤb},!1H~W $k?mkضo< EM/OG~8 |/爘 vtQSӎG%N 6n+?AB~j㗀,)hs@ tfԹɬp;}b3)KW?`h Z~bc:3$TO^h1P F<ǚє(݉k[8I544a$UɁ>"ׇ<{0y쵾CG/!5찀)K2[J|SS"uJzL n)zG@]`H:>fjH?Uv٥%M:qvB-wUpqP19!X` ŞMҒBt_ܘwYUF[!dA#x3Y`ÕMi C ϸ3I ]4d]=p8h]4F(A~ S ` 3FZ)F*R#Ƕ|0&UȂ@L)61}x<?_T){8mZ`f, A dsW?<\N#}v8t][:'c'9Bh|GěF3.qEJ&)td" 2C&(cCe8ҼXھaC5z2 X !/noV$^ub!-b*Q 񴔂H]"JdUqy]x_H{7S48 :]^M>o UJ$gy}awmˇ#M 1bׁ$ ZrCM_]R ]O2Fg*iNg-vo}p$ ]Ě3cSo6 2跨7?LQ\3 ٲqߪ\S1Y $7S*5}aֲtWӲ%oPLAeNkq5ϯ:fO z' 2AA<-Mi\&1=#]\ؗ]i| ' VFC{5wa9oPpϨ1ʸ"SbS| utfZ*A-59KcER{X¡pvy%NWgk=CR;>ĠQvsoꏎ=QBVxnj-O!Pal +%EnQysK2ס)OsE3afBYxRNQ_zgjUbw>}{3r@7m W&Y-B&""9zi$Bs Bj;>Uav42=-77Эw\!#/ }Ga~rAxhy\4mv2oQrUʾ_'SG0RKV Rd7ҊU6UU z3ʕ1dZ[C0:G x+*[b"'9e|v|zH=.D&9U}֚yq]*~o}ŖNì~QG= K߮Aj Y.t?q(c5gIEShGB5XTsc z LUk1YڋwqYHv.zդ` lyh氚3q9@H>領#AՇ-=*Zɹ ]T)DvAŗk5^Xvڔ/%yUqfW$1YH՞1]U BN$B ~ NkO87ixN[L~@M&z*ytc[` {r%%!ZAqOh}k?gfof'od_^4Lg|dcn7 KFFF10Hx#HoXH[PzW_~`փMX:AoxxrrOsXQOH|@i hGH)EZ' ޶r/ iO4δijs)sۦP&(]V?0%baUiBq?3M}0{Wn9B-8[dd4Y"9xe;cqyJ [-,~<^<Ի+V[HE6s/SܴȀ{>:h8̯ }~ǍBx%rAjۮVuų -H;uKaш}%x Fo`.~VXQ~ltuɧGH 8*Ɖ3\76b|ùIcvy w=`mF7B2?51tq(kSB1!R#VN=-M0IS ae&ںVU!2|ֱ\RVDK>oD>KWU_r#I 3~#eƣIw#4jiYeo  B1fi&KU3gdn<($`#G@y;8@5#/4_-)nY|%.X#k@XU[v @JʷvYRpRnsR=w$D2/MtRAKisDJDDUiid_ 7su$r'mI~N"ʶeFSU&T @x?_XylVvOW&]b, vnpM߂G9^A{_ҥz%_[:P DS@C Ld,OR !N;pnBzWa75%}Jm|>DL Ky>3*d٬%٫6NA7V;W _x\G9&P'E|wiZ an]]5Xm a`ZVkkԃOeJͨ06gKvLjѢK;;(e =;̈́ɣ;/Z؁))edCD֊uVi:m%PS3_.=N_|?t]Kib5]0}=ik`/TQALcA Ge.!0FFQְ*`Ol=xpwRYn81&|xh`_E{*]{}1'"jп&~a 90c7vȉ 4ǒCq D0c7CgJT)]KkU. B_3;U33-ĺ+$r\i_mޏ'fC/Ԋt?C~]N3RNw:<4di\ |N7i6Mc | t>3$eRG{1raxF.'z&+x]{rځof+J FF 3e Um? `m^_XZE2׏<{W`6k똰>Eq( S:/Xb-Yjʤ@LWt@?v 6ȘC1o<((>O|;c[.hDڨ1ȯJY^BaAbōB|_Zy<)IUY~뉯zaBy&]LM4P#xʳi@HzaVJ$B6E۱h(V/pbogzZ`H旔ZhDV8~gY!܏qHmּ#k5n-v_̾cȣB:rj)fb=:˄ x^̠8hvT/XabrVJDx3)T6dqڹ>O"]h)Bhe7Ol{p:MƂ0|4g(2edޜJF8Fk)N5 WR~Ƴ+q*LK$hE8'P䷠a^HKˊǾ},s_Q)s F@|mL!RF J#NT .Bn&%P@?_+V7 JQZxu)"/HwԡuG0|nX I M%L%w"6QL,'h$~ě8;vx=C]#/cިa@tAoj`/e-`Nܷ5/`?oBI履Ec v ,u\ػ-jK:*e?H7N |+ F?eeUV#7o8yV$R[$t)"QRp'r3ӤD+Z7;þ?]7DŽNJDjP%iW%f<VNt$2 x N_͂:&ŏ:ϰ˼@d ρ_iY 7Q4$ OTO'bpg챃K I*o0haa+RhTym4bfp A%ҟd,}!k@LߌIa)&w|zҋ:ST P22nGx(x:=)GKѕV+[,d]ltq B$YᄨK瑛cfVUBLxqUn{ SxzŽ{cP"D2x+DYTq'"zp®' ߎCc0]K1 0\7 TwaR ;^-5ETE-~4"v2 ^)w\+=G `PұN5n?`CAS*^NȖ& iho{zLt&P@l0z$7Y;/&is}X[T-erۆh $"Q OlNL)1gd}AFQԿ'eF&plc?ĈP(`b8TKY|Joy5Y0bXּcZrY |3r4 khY Pq}z@tڝNAkbNQҙYWbT =:qKZs5h~Љ[fn~|VdDl]g+R?%]-qP 8M-~wy:ᗆ^4 /5LZ ۱ aP85 OH9lxԒU3g5D‡U<h>2@دk9wcrj\@ 58Rr0crlѠ?!(e䩄|?aq|jA`_o+9lɢ{S4Yh"{ , tw"3#NAQPz1]]mwc}@H}P6L[Mѿ@?ܦo'6XڜiA6ڠ, 7-_f\W~xҤu_3Msa ZI*ڸ!aߴdPü;)IC4 X.) *&%EoR߼J*(SnʌXى7#YK. ҷ^?S*Wn)?0ia|)O.d /Msh(>w~]}ggYi0cA58#haKu(KI*p>{V wݾ5oItFm]( `z->[5hN@oY߬a)G;Pitԡ馁`:~'*eE J&]b<6_a"r\/bȏWam))"?`Nlhm_Vx#[ne9QXEZ.C,?%u9w8[ bjUYu|P|Ol3ZZ8lЇB 9@ŕ?Dcvk>S[4,¸2Aaf'O[:;8O[#Ķ:ϹmNdcxLg((/Fà+˱ezb>8|bm}H$֗#_$*,!ܮÔ W0W#`-K ,f]yW]9+  ytM}DL #C=H874}/o@H6 4Y=y\ 'ȳj*{OG֭@1gRl62b #Q= X ~"I7`qUuw'e֥nٛW$tAx\.:,EW1pKx@yis 45H| "4r'=eX(6+>p $)G_oɓ ?OpN4!mR( GwN!T "2 > ̶~J>¿~Pڻ6_?]0:&ڥ.8`[O9[%Y6<_obᰦ~{YJ2W \70CSF4?hC.f872,8LsӠ+nπPNf]RVB?spvG1sX1?JvMIS8dΪcfɷĭ߬`7E" ]}ZY% Y'dgO}#WX=-*͝R /\Ny|`E)Cp=5欕MM>#9.!Idq+h.'(;>ط(3,Hh0(ϷPiպxLM !qgHa#X&^E7D@_5FMS{Fi͜ qR:OǾ0<L)n`Ph<Ͽnt'B0ZK(_Z)!)N&6Q lj𵠝?g,7\٪˜T0jb1 8^ a9駮#H#PGkAр2?ٓg]J+Qmux%bIHjg9jÿL\k=er:l7c5"yZnYo9p=D\qf"0:8ʢ?bOIPK:𚍦ϨzUIkѾgi8NOR۟d@Dy8Л~57j'J£b.?ܶx4d7ZUZHڨNj?0^*}CSuAgU""۟GLbqn3ya)fb@H'?cT@8I >?A{ vg<2!Y qorK<`:ܵlI@=z̦eh܌MzluO^3-B:|ՙ!Uڌd) PNX@ʝ`NB? i;!=ޕRF>}Z4+ޛ EQ1't! h^hC_œeW} @bڲHWo~@],DR#3߃xɽ 3 ,X5CwyY,^$|rIC-+8z ~6cR}ULk[Zn/ 3:VZ볝G' Wup#|#I<礼f/e\o|D!ZXM'3Øq lܩag99à++Swi6t\af$RvlXZOB6A(.VǷZ:w1֨G!ʁ €L@ ;ERx q51Vw)r$LmV7/2;/~Trg#@&00a>`%›mqy|#.P/߾i)ߟ</;~w! }{2tutPs*R,?($! C0tJ}o!ћn6/XXn Wqort>:?m֧+cy[>Lu.L_]auREb_MUQA%P:DYZ%Fm#`]S㰲bq"(ڶ?=(KN DdGKHO ܚN}tMt.'м\z>j'b:k*B>f;9T]Y: F+jp y速xKiaoo6xho428} _uwLG 8wлpֈAʹ`?{|>:ogvz>o_Cƺ.R9ANbg:(ea9DáV5!\Yd `~PhwDfZ?Ae$}Rw0w="e~4$ߟ?|/J >p0l$2{iODڿǍe.2]?(+5QDxրn$VBR@g+b%N.?6KQNv:&i- HK\{136J  x,2)"~nhqٔe6Ӵt56?PMYT?;:[@R]g7PG6?5h >&۹I4u&wcqHQ*J&Y$yq|{Zt+Z,]]y!=0zO_fNPE9_YjCU7II)#`M=Euh x- kQDD^3Ŕ+D:z8s)0,xJBR 9j;n/\e(jXl%Sr]xA-`_RNsԮub ^^+g")2bxXgx]{%.!T,d n`XM10}N&y6>rɑ{LK&+` BʷAW]*q@d A\3 j}"phSZ pϦ |WVmҝB}LIqk^PR<'7 ~P]u&:6]٭'Yϋ[ ݸ $+HHQEv^h"ś9B9o}|g=GJ:G }(JXW.wrFbm{1*zޭ)Cl&#ɍ1]{׮ WӤnD/cy3w4v݅ք>F~5 VM'biHAB70S ]Tߩ/a͈o2BVtk'Pmts|#! m&Qxce]]\Sv&-=Eo_·~)`[WeQf(IoEAKQGFer}Qϟ;mB5Ò3B6qf[d$R(h0=C"Qg/ZƅiʟBj+vc!Sʘpkz>Q` a'`L&=ɠ[֋ۖ2K~nJa|;a1 )qT6?=X)HXMð&C;O1Jl&*:N_@g2{Y6%䌭ڼj׹zmoN-ډ8ϕ}\=p씅R9i_|cC{J!'t{<0Yb3g[}bK ~EMoa} u~A62`'ij"Y^A"'xm4zh2J 3 Lt^39ӉH;PBD9֛,k87yll򏅐J!L+0bCg@?-\BB YlA^Q>_f|^DP}AEfy]0 ñCm.$s ;$L8<S ',_tG؃S]_䷣:=0 ;C=>{wu?vN;1jJ!$Fb- L?*cn'xi#{FĕУPZgLQ'}.^* o;Eט+z*h9h{'xh'te<CcDDbC{7R+"5 '#ŀC"Oj`CC Ϻ-f7QB8|",UԼjS 1+&o>4rg {Mc6d`>͚9QX|cwKUn*7oswTx>/vs0A ҕI r4e3 қjHI3.yDogPČ(n?/hhΕ/H jWsǪϐ&!!QL ,=bgAA$5ʨd^ŜTyW!+ 4gIdyBN _[}"-WlL&I$X!,uL i԰:VQ} N (YDur$"_k+qO ~ @L=5h/pxrUϧˡNBW FImCuEK 5.DCjn7zXv 7bk|8"i~`ۺ9$F.m~Q 1H8oGSV }LMy%SbnܜBvӄo[oWĪ XTe!a;`s"<$%GhiTz+%sBz;MN#2S善fFK .©#ja{YᐊƸ@dDjG1Kl.!Xnw<^[NߖiƗFɅ;+~)n5V!nnpfD{ݕg}bN^~ ~dxX8ں@!kTػ|-w7[DGx?B~ Htt\k+8y91¼5"μu7'dH^j1Tɥ T.jwUuq:1NxCĿ?*\eIRp$Nijs8=_ΫdT wW[}:=( C I$vW-V;?ӳ}~d>~.ٶ^b?.T[.8̓vdo#gkZC+ZK :#9RDPW`*}h6OĐl%ű/v) V?C ѯ'j]ik}y({dOg_1'aVet0ulԷG_p[v8 8XvBjм8)rJ)6SluvgY+ ~+Y*`*KoM {Y,O,_̛l!ZR3II /St4 hx&B>/#}p皵KU4yT9&'3ݣ>eTFQ$ !kY@u8qc(%BDT>-c0Y 7գG L8[򋛼{k h,~?4:1K,B[Ȝ=BShr_ ! 4 "ٵ#9eLR3Ө~ 5Ow]eпя k폞z4͟5yj 4Ery,bax^axO(V/jS`R,Q{, oToLr9j zth5SsT㔻coG<䌋Lǀ`;.w:ѡ픿N\lZxSp JwX&) Yfg4SBp㺆JFxP* .y:BZ 'w2j^3$6q) &ඖ~H#%~]gg (4B:"3kZ4g"$_grM\vz}N&68ߎG篎/O&ye0ol{HKN5R`s7ǁu6[?o{ITmH=( >_ⴥRx?ɇKj9p1v4*G> Mj3cz'ͻ@PGzij7ʗcUGSL='b$=U? u0tQ0*Mg `J8 IA^ 7TڹF0wi~ѧϵ0e˃c۳>,c8$*G <oS?.%#Ԡ2_CZ<4"d$LQ@0kǒ3ҙ)x`"6#1N;HL@S31D$e|{=Y00LkjE=\),-bV |\7pPUѴv!bt0U-e!+kKݗ!Cеk?{:1>tJAPikE Pjg.ixy*gާ(>jpVJ,`_w|\9p~s'#EjQܦE(P٦H&Mdi ٲ;NEy&Pp ׏^qO]KBg4]&!ѠTqo(_`dB#`䣲'JWKyl"1r_˴Px밭G96b.x˦DJR0'Ԋ 0@n98:)Wi?+`DbX#zH[VԶf%]R}aһLx%;?extִ2gt%Ҥr%)N1+9f=?|z֙Jl&AxW]ƫZ8/@f*\*E8;CCqsfdw^ JA FJzaZ / xUn*enң WLq_JG9D"WfCYa  YWly!fV. xu=X/GѰѹҀdQc nЈh[P#WTMw{3zWK= !!}Qd6-<8ɭFxz'Ћ= b 8* A^ԋ0nb! ~()WPC}WxmbV#MPH㬎蔄fo0~$~VaSŗNVE?b+&ӟ͹owR^Y}?'ȶ1蟿,12<;9-WжJ #ż0;raKIO|c8չQ!JmeoǺZisBei~G8Xb*RXEL]ޚ{Ws~'p4-Ӊ8ܸ&.Wb(X36 K}hY-E3뻃EeْKسT5TMY\ll4>Xg.P<$z{X3VD*bs Vb~]Ũܪ3͙MTBώ[ LeMO`jA0B/QL3__OVY=kZ̙1O3 6]aB0Csj1pHLh]3 H0m>"0p_MDoOH& ]PDfZzvu.M!aN2-R7\fVf^y֯~`XXCZu, ^zyUde;ɖմv2:E(-gIAI ~Pl|'y*qy~wʲRߗlΗC 4>pηFoʿAvթ SR4ѮKsJj]Zg=3H~v@d_9in_zƁvJC)\Hg)ye! Dv~0L}&S8lB_S٢ ׂ3\2#Ϋ.!ڲm6/~{!پgj׏2elUb߼D=!p[bY\8DMg(12悀n;\X]Laz/pPOHWkyoCRYbDfƶ mə.|RsM?Pk|!IP /;yLBH!n)&0 r%_{xB  V:Sg5>|`,P%̜^p8h!}}zG,\ғe3ᔼ8e9Q lkR,)<$ۭa?pn40n N*Zһf;Res?8~#*nէ+*_n9ḲXT_>yH}+!Wՙc&]JyB]WKug UTyc6[֝otY ar+Cy ͸K:)7of{Pc(5&L-B(TݏԄ 5ztpߞiYV44%UNW^ר[60*Zn-H`"`Lu3uT7wBttSR5`snBZb^8D7h9R7%8?(ގoߠ*ĻB0 \llh.X?~a=`iQ$xc;&] gBCyJ$ΥC4rGyw߼b-UL}xF<"Ay-8WE:|PA%P_í} ;DD1.R 5wǠΝ=Qd]dƉW|^@a}ªL s$Dބ4bnΚuj]?]׊)55Cgڊz }C'? ȇ>G-iXF^WŠoAѶA-pU8/=UJ{4(-މmFٍŚWUߺ#@W ~^.мw+HatJhՙKs һ@2;fμ)5: ~"bǍRKzkY0SOkaJJUlgVU}m/p,{p ! T[˕j}MvjS^b82Nds 1i(n4fڍB)L*z_11kcX, /KS: 6dfwܾ'yn(fyjPaP?QWJc~6ctcT,F*?82 hޖ#{*.4ET`~C؏QAJLɘ8H/1 2/ډ0NGģz3{>G{Es(:#{ j"{n 3 l;XNCXw9i^>q1ɬȲ6>THeW02>>yߠ'$ xƖ;4滥rQr̨$ mN7H{6CT{MЧ/OH? PCp9d'jC-lCH?[|wUһű)'+Xz_`)q[亳q0j$ |2ʩZeg.Az~w){tdꆆ#폡,x7ΔVD<4N=tx Ŧӝ+mf/7:籰qb/IhDmUe]r*?럱ijMN\  /9_Eoo)'Zg >+L:EZw8[!e0 Ot]eoʖ&VbU?j](i?DCݞrn!ύK[bLXXxg s2+DIC%sOj˵c.bVDo(1C0y@C'ב҈ʹDovs@ a*|6E>QԔ=$ >&ִ}gF%M)k߄>r۽ayjj0mw{' 1  o!s8]`:+vrQ`49u+I52ɂd!۲hյNUhS?mA=>@/L攲37Fq:b 2NXŢ2 ].@ZB1(S09 r,< ,-,^ n ːC7?Y/G(\y*d;/G RA>˴*П=i@aK%bPi lgEH bt6{ۼ{%Y`1+ ǻn";{~ݟ,Ig5]c]usBMwOS___-ƪ_M6m-ٺ ͨu@o"D1[tY>e'=H<+a o{7-ؒJt"|B 6!?/٧k&v={?rS9mzbtX[G ' >nKrܛk! ]u DXk>"՛J6}~C=`nVx7iQ# l[@J C+6nLm62Nf 9k(u yh}8'$u͏-nB-YG2Zd[30čZՙ-.GNCJzYŗkTӮ%{\LA1sZY} >?H>6]p}A+l ? yZ=#{sGwvƐ3TONht! |J obm{x>6J`=n}с"!lx}fhP T0ah5}SAQ|bwYȈN) -ggL.Y>n1;)|m`Z{M-3-;ץ1*UB.I7M8881*wެ9nʃ¹#Z\|+7j7eԳ,))l~+9@*(k3ȁ|ؽ&͏N3 'i]!ȝrN_ c5b|50%59GgSq+;5)CDv}.6z[`&%7n+; w ;6:ٲDzk5M0M. ա>M.p}n/=}=r).p_Oyrd_ 0k.<4;X҇(N/on:ioo/ ~eN2큞pr*I" i'jI\(px>`#X+N4>Ȝv˛^ִL9?LE/[ml1sAlUkrd_Q璨pt}UDl|Gx ;M@8{nՇ?+ \S 1rK`>1*Ȁ#1* wST4暾?з껯, Edi>ErB̾]v ةMuuƑs,hI8\(Nrk=# ;$ʹL>,h?ybj'߷bk9ea%%ɛ/V\v1[ D vkA`%7/',*9X!HS%M dhL׏x`&ÜN;Rr>L8K1C-Cwg.*;T0l;"0G>b(i [*` }tw4q詘8x{=[8^t>>[joaCGiM; 7{bhǀ&XdήOd*CB"Y(b}“32XF-bC,} jXͶEJekF!x8/|]F0AAPAalnpbIca\ Hn}*";HФn7(!d b22lh©鲶;i2Y"p~ .2Vv fܸ4  鶿7A]޾ 2~ J,VP8{nw{/FpLO *j`ch&tJ?C0k ͹!R\#M"#Ml$nFDH#!&/AHi)<Ě )⣶.4U XUd@iuu.pE!X=E{>(`YԣE Fcq0DSiHrF@dQ7g#_#"O>z). RHo.!%j U(+h`gaTЖܚ0mu]`e9%Ԕ'#0NjzC-w$b4쮾ھ3W"$*a,H]kS03s!\u0ɼe*m>bbhk'7馸 b Yw][,(SR܄61b"Rn`ٮaO?de8=8I?-(`9wnidab-z0􅺬,kR/sXݣNa盋cʕ ఉm!?!QOh:npՙԖϤCCN-FS㍳8oau}B9 2 ㆓KGItyit|)qaޱr W5&775W) gեi|[εK׭wIE1pHޯ}:ؐOWҫ3 zK:諰>w/yDUNzt&q"8V܄Ө$ѤHUl߷^BpQg/s$)\Ǟɴ -X&F ~Q*..เ #BF}I^hΰ~zKlAp>H]c] w(uDe̢z@FsHtU葝G|kG@ޣ r0a6D^(D6vUK'^.txciw|-]4Jrڰ;yej/8L|'\4 3ۻiԢ0!YWrxP0GhpVškxc-__=W8`?Np&{RN@GͳP_UOȖ&`Kܸk'ͅi@ Iz͇֩"yYQŰT[b𭺷D1srځLp=vMy}0BEt{.:˟@Dg/y}=~6xÚfL8M@yx/;k܎u=.FX}6Qш AAx?P_#k!>XnQ(=5'>bNFo5t"A͏Q @0O{qaL>bW暇gw:1O?c0&qxGWs<)'B[$N=T%_2%&7i8-Rx=8 uJ Eh!WPKy?t`uq^NjT%T0%.uqw5woo*br>P{mM 6+gflm^%{yߒyu%wjF2s%.?^{* (|1NB)[C9Ӷ9$t. +`mA:d|j@BbĠQNV70{=uK, j=@~gZ߿0籊5@HnLc,_L%Di9`\ @%}bw;a6"ƆsRn]/-|yK{hu)u&j8*'E]ѣ}cƗ6}n>zW]qaH9J"Di.6+|0aEJ{tN"lFcP*+$^Np'+Pe_q ],SZIq|-2ͻp,^CGd6kQN{TAr r5 ˁ!cѥuc&n:On?"P |U(t!S%;7#0wA `ѬE X#c:Q?YY.8;]ηw>L@-~'x-4HRa1=Q&MQzNPˑ@V4JƇ{P|GcĈq##QI9NE)4"*ا<` Lnwb&{scw 'Uࢮ(n" a)FpU߅7zMoڒqrZ)bХ4?j⼑U&] a7vír=z`,c-m-K{6o?O٬~& u+S#~gӸe=qp&)Dq{o̓HּO.=VqI}g|B]7MwUp_x NgꗿPVkʟIԯ}(5+Gzo3{m]*F+V`PS}7δ`j߬ P31/odxΦ̒%WF@ڿ8to`L`Ҽ11 {CEXX3,OH >QItt}PQm`guɾV*?Z$L@)HYb(JxVnUtPrܣ_ ^B^^ڰy\t&S xW[&C^PBAvJ4;4}(|-0|6:z}?ۯ!l^V;寛.hwm ^ՃO*efY֙e&~[70G+u9pgi/}uZ fI6\7VࡓмڋٓklNuY팉hYbrssXΘbM= x_NES]@\g\o\ז;!픣V[ ΢4 \{'֍3u q1ء3g_p|/V[~+{%uz\ީvCv;AǗiyWbV:{Gy&]zZW}u9'}']>Ӑ8_eD~s6T̚+f.-<hh_ޖC]Erމdǖ{я&aD%ڪJ<|_|!RNwg- /F]Zaƫ ک; V<hDG6k/EUt?h]g +aVK3(}/0܉|M]xҾS`2V3lj3er%v5:0E|[5DQDӚ"mޞ>ȁP3W{i(ZUm:Fy =}U #S'Y1L1j5xMsTO$~@PMiiT% htF%I0pyID z^/%׌ӛb%:jV฿|)RTp n'))ݞdUBD=:.-G57=yɣ_7:\e tPF#{]jCrq6|0Opg׍V}e4#p=3{+UЪϝWcE,:o3;eY *^j=1:͌=Iy,p{ǘZ|o> *=yʼn0P&k;UD W&?~VSRaP>Y[ߦ:zP>Gzhζ=sQapw0-R[4hyH 7VtтZoY[xhQ E!m'xKJ3ɹ|[Rg}޼:91Z--i¯`Yqnkyΰxjz]k^QhQT+5b3hjL~GǷ`MDY>MR,oRZ*ZZ>W= C Q (4@<1 H@M,}& ;m 9-jϛ] 2S$`d]zsO3{s?~#{"/ ) 7 $ \^"Ĝ ]3Ujy"?/ W [ ;uK'9apkIkxX2TvmΉc d N͑-}Gy4ͼ,}{o.CfoVCxIF/I`y$OpVi*Ҳ#}&/Ti ixRnoz%gŚ1]0` %tOm=û0Ye1 tn:Mޥk;;K]2D#x2geҁ!6#ӘEQWb *ثr&~[2ܲ4[."N/B`Ҕg. ڇFNTᑮO,81@Xdr"`d`؊٬P=<5U$Ls=a.n ^{HKXHLW$NGqA6W;6su@MB_w-:3CN嬚ZC(C@>knm ^&}~>ДɭqnqRY=-jWnUHnazQ+?#owIk6j>îI״ 9)?4~_D/Z:KynVNsV.X[BCaD#!=ܧUy+ Hw9 < }&`,+ʆhʷcKҬ?Q͡č`r^m>boyS Ia*Vl @QU0fՐR8| t_\qfGi+]M !;ؼV' x, bMO|KsOv>}>_}T^ h79dШΉCBqS1.QY4\eo[4Y쓕~{l ZUʹSh[ =ǔ^Cxi\kQB2UKxB|NF/-iÿHt' 82^F=vމe)izhPK4I .Dt=[yHɪ;d|*bDo~ L =:.L8;G -V S&sH~aͯylvMfU7x?$3PY_yф'u;0t׉|i-Q-h*13Wñ&s7UJ2w?J9d9f}z~+_- o~SsMI9nYz&xWnWmGJ¸4h$ ]# tR\~{05uIOYZJҦˎ[xidl99v oǸQةV%Nw9Q۵\rqY~\{Ś.kw9~fvZgLqF{Aiw)&my^i,4~ ȭ|,hL< Z5X+~P;2<6H@Jŗsim~Wi֍W/ ݷ4!M֘ʒD_VßXQ_EñxlHЏB~hmjHP@r+k-sIS"1ɣܕ2, Sj0~o& }}VA;'9B~}t:n H"La4ןj>`gt\YWz,&q3jO BH{aϥ$itCmKsx:8ƣ턙7/Gn lp.g@܆a?Ĥ~bn߾b5sEGm{؄O+=n0s_V}+ *G1.!95Zh :A—In6Kwsbz\/I]lg׋\x6N\6iI5!8n?ir%o a(fHB|D-d^G*2{kz1ST k%?=P#(k/.#'TN,+*Vȱ {I3&gR.8Ex >{?Ei[zr֚T :ե|S.G?$pQ~":%.G\}+_ {t MSavػTt/>=I.d9?s$_-^{(wiD⇻NqM?̳/!q|1Ηc/!"" Q?ȕOaZdk_;g7K=D!苑Բ1TN͂\KU߅yrt?{ |5un'+N4E@q1 Q6B#/Kj\H jg%_V#_ꋐΤdS%g%\&&/z`6-i4GVFU7}V`cBj)fPi)_N_S䃓D*wt؆zypKn1۬Ǽf4TӪ7cǟ ?I$]AE NBjKVWOz ^BBӔ1@ ah2_W']+Rtx=0Ŵn2S,t1ǧj,ħicl)#aF Z(mDڼVK8Xr),(| c>.Ff)Pg3n7iLԻG3HMA?Dqq_Lk92q[i?JQXzXk(#{?'橾 (b,L5d\RtAu2`yܩђ擏XmBLۤ}Nsf1e6$R)(8DU޷ՔbBP wkxR[U3<" N N>֫oZ~[(t,%vKZҦex5vs|Seϕ[?Ǧݴ鿶.~'5A4ݺȺ2ږQAf܉Fc} رC5'mAX|vVtW$mMĩd(ȿl LٝB~VҔl %({o_hLz,,)&Lbf {\+[4x/m_u q^S3kĈ-9F"N|3xPٗDP?-mRqfvV;v?)`Q:h['J^}fB?1 ?;/  Z$jy`Muh֊5j_J/;;0BMBǴnf.#=? |~-+2 ժM5-WG泙a^q/\X-|߿ߓTN noFDZׁ&# ӅI<~eǏ[Qco 漦EߦQ^zo7jBlaS٧\e~Hgb'̘|1/,%L(L_ũob򭾋@݊a=6(柪xmfN"2:j&-nR1ټR:qgzQUBG&w~EXg!/>q(}ёKaMQ`}4HcDžNr@訅A{]u޳M@bޢ>56 EQpZwl0sJ@ %|b#+&eŤ+ Vo9sSFI^g̈́a@m{uT]coҗRl"W\eul~% x?3; Qt:}x<ͦ1[Qhde̻d#;">n~}66Xj_/ec&NKlϱx̤ۘkG'ȱ}#z&xU-lâ`a?Ca,z lc/ U OӁL;wں^ ۜ GCQwq? m@3'au#7Lb{>*lA0?QC~6>h 1j>ۛZCcڔ2a(6җ_Q[{= M;$&Ozs*잖Хؙ}cؽL>67x_]т[O|8 -#mKz#2O=f KhEpodzvB%q?OxQ$F$ !{vÂӃѓoMbz T+J"- ,jj?+D#x!V%SZEd96 /Ҋz2i <$u"-GZn~k*L@G~Wb>̪vCp/6kr;qnbX47$U?~"acML-W*c98Ja` 7_)6QlֈP^wiG)sT@uy& MBK#~n@[O:> $`-wY;<4IIm2ea'CqԛKAޚnYYJݜwCQ L`("Cخ,3G5  [qFSĻXs[ES ߿<eSژFUЯ"Yd#ˉ',+eͺ뼎VQ}AN,_K IQ's͟C$>Չ ~ՙMIsۡBô;bc6Dxkb{󐔗kܙC풤-E%qc}>!XGr뚦d>aX+LS?\W7{# nm cFS 2Ǭ:ұj_,<ݖxꪱ;=8=<7j) q9ez5$L=n{3myZ ;dM ;XwUF Q},#£tko`6RmP6czJN7V2FMz#yOM߾v豥s.s_vCq ̿$-4Rs1R9A:^d|$[وCLW)@zJA{II%i.0FPA" Nz"[@~࣋rp\ܿ#?I₴5&w#?t ?S~M,'lKY}N@gzRzո+a| 3(9,K"lb y}o(i[{Fn:a6{'P9 i!(&{ҿAնyS.n?N݊{ׂ`ۊ OOyZk"*%#u29zCGoNK0F~p/u=" ~>])Bl7?do§8cD}eL&ٷXkupߟkС;vбۃ  Z6a{pFϮ颋+s1\/Djf|ԩ ݖsooPZcS*%~/|xoErZ&zG^BORG }Y@ǽ sCH2A kGnky BBh^)7֣?Qߟ__3r'kX= ! &b-5O!aunD9"+gb1'Wl QgP&#zw\Pd꣘o!}L[q2"P!J/ez!#q uWhҚ>k=೧܈cm*I u.iC fh+($ T_t-U6< y]Bp=VhGƳi`ԯ3fϩ1\cv~yҺ+&\;p4eᾙk6lkdqkuN3R%֩?s@fH;Sop1D)*`Ib(+3*7p[U"r E*^o LA&~3Co? )Boccbo,NmUdKY I$=6ȗ-&.gu0(vnGc `^&p+~FZ!IP}[?珐;:@== Px@tS|?m|z (oz/V8`1"rk j  ]٩krSC8:t!oՏ1RRF/4!܏PDY)Z=oXQ\*ӯÅ; H="iV4ctN{b9\٨zNQ )o1Ց~L(#[z:*.E;{w?]޲$p)(U95$8nD&%G)!:1Yq:. ]H)=OetToK¾Y-$F`>eb!v嬷GP3QW<N^IO&}P#<Q"y+Rua VGC&l2[+ҭmli\$L_l3GE/-㈎弐$8QL9chQ.]> 8$/B\F_hH`2Ͽh qlVDBSžNk Ĭh1lҕILneƍ{ˠwrF(PK\Zf$'L[/*DGQV =EKZ|{UEqz@r B`h & O_5A/^g ~dZY|ߥJ|)#C AUۘNNQ>LTQ+(L'Wt vK`7nSwhtE 68U]AB>+`u F춢Iy~-0y侓3ss\0`UgrR6V2Z]v:vܔ'aoědⷠXu[) u^ݹ[–}ΏG0!RzMsyfFDă Qsh}Ý U ·溶[qK0DU.!7ay^);^8|cc>"J8; 2Bz؏ЏW:E%t HZkZpz2[!d LD H|f4xJdF9g?Ǚ=z`i0m&gfB7:ѡ(tEevWy~ OYZc)H<(=wQlwXc/s0'25I&9ڟOׁ] =l]D#,@daMB- dЙH9wzԠnN8M%GSɈ (ʵIr}10i2#hUls}A=fthZ3>M-^D |rYM\d4/AKd!NI;,Y;`r+_L;-h2$0Y`R8·6n,#TiIE/fȄd^)ZvFBhdhvmym#7QFbZi$VK$ꙕ@ >S lSLR&労5jۇ(K#jbqA,7i+v{kx3R $-?aجenK;q6H)7}eg%Jb3hnM%|MCnVgf#ᑰc_V_G|R 跃6!^}x{  X u ߄{?Ɵ{dHd  7Iʵ#~(`3;C KځCٕH/>4)D!H3IuhAC48b(CBnAnER3I~LY`MtHmMN~券 yfefw%NN9~WS0ΆizYɗkn|7-vpAJi/C牄/݋1RTGx?d)4*}Pg \n%SIh5qV@'qeC}<:70p/%!Bm(7Ѻ*.`q!^ $%3(:OQ`0-gURaDzݡEsR; kRz}[ )$!PmrHgڸŘWjS_@UH`R~QI@ 3_ P2CЏ@U9ZQ|68Qx胞=d׭Ar $/bD+w717SFxnT.zޣ<@GX{={5[G<(f-rZ] '={@|bS:XL;1+$1V0I7fkFf6EQFZ5c4U>P^~ڿBo?;pu`* cF!.{73Rɓ@/ NltHDF[M;]hҶP(;h…jXڨ}RzդGvb룜MC֛Z(.e{PY>kۆ]@.PNj:s 6U_RC'GeEvhSUE}MdxXu+VdI(urjxۄ2ՙ6lIVf:oRRw=Qqpd4stC>Zdx(w/bU,FeDV97:gm"uԅ8{PF3:݋ >3P}^/J Wh0z!FP[fwvkr۽'uIf\/lLSP7_h"$S"8,z_'6lqQ0$aM=003_^,&eqUio&fù[}]"f{egeA2l=tj96=ߗпd_F%mSS5[_oA )iqh- hGo㛖?$ M1y}~=jG'N5gV,&!FA^qSfЂhoXLM^@V&>_$Lةh/wImWnj0XAXEd'pyg,nnJy;m}+yo7?rSYK *]Aii^|teBF喝u"KaUޯa!߯SpkCߙ'&PIx\ P|OƸ=d6DRAcR%[|"r;̒ƓY^hE|࣑\B!)[JLAF4*ο1.)a&|J=$eɬ+*~QA*6N1'݋2bZq/N}9Pq#۵H#uL5۞:4SC'öؾi(IJ^P^^ XEq >)¯Qo f 0]|J=[t5UvoV~w:)4m=LtҌVnƊ +0<]A~G=l.m(OW6&G4y3n2=DTv+&2m[Oɮ}e1K"\aH&uX(з|uZ(םAB8CRηikOA`]G9n\[|lE0 ?y|]3v;~~v(UIydF%X훩o)"F"r#IaDvpeu1Sc[nS@@hA@3\ˡEe N?cLׇ\EftGo h0d*,_DW4QR(K7=v2FFPm-iT(wU)膬oAX-140b8D|K_U$Uw28 -ݠQA8{1uZ vp&bdDҜy|ns.њpՆW'uul'x; h5a!Æ/ƕ $ 7 sm> b_BھkVHWu}hF˶iX :S`/eTF ^{l%]jT?)ӎ1Cvhˊ˜$Yٔ~^:됐]ˋM"v2=O-S5Γvd{\o. ,p;_۫9UOI2YF4onVC~%YK >^wJX^_ͥo_^KH/eWV;T?z~u$Kp~:K;\{ԷUdܒ fPڷXnXBx^@.9Fu5i&zI? DW TC++υէ_, .r߮'^O낂'BKI ӑVv [7sXIt8}t<G~YzGTzDȩՒED}#7wE !5̬f}>&l<.}4MtWaV@Yjx`Ӌ>;´+aڦxI^|]Z"oH.Kۥo /RFaΏZ o՝kҎO>(Z:; 0ݯX'M_@QcJ*sK˲ )_O wfp2e&:G4sbGQE`.${%'TQg>a0HdFD!n.wYd5_hƟͥo&/D8x{ < %U2ƣߛC2fs#RE~C W^'M o4# zp~} SNzB)GwpT ?$:ϫ=~zek;}L@lK"(q.H  %[1U15.3Zn5ԀkIZvD~_Bc/"?-#bX i0#YH$؇22Z^'DBֳn>+N#?:v'}\m2Lmʱ拺o囮`~u#c#LJq; )*8jBe;Y|VG' O#KmwGG&Ar5kѻW{+U F_SQ}hbPhsPJDyarHˌҊ8nWQ ;rsg!> C+.k6U9.Z{_@AMAt1u`3d n]t [nV|#rv I28֢ >껴\w+&4w~h(S;/i~?l̹KN}u`>"YS9>y|Ei2*c{-v+6᳽T XC8dD/„j밃*.{$od.@2?{4hAB  cVD?`T*io_n>TkkxVIݜ,)M^N ['0W0۪AL>G,Lzˣ~;vXtڙ۱{C)r,TJa 0/l_-9×4 t_6M&5.bfQV$v>to;cLȫ>tp|lOa&& m85D ERBedIWέ֗ηl#(/"eaP8[o\|G( XXRZ&ΡժSnz#gdcԅT72/gSAe"x-}!,_ҙj(oKi>%} n/ p%ow}q +ٹXC_GvHms;'pm"Jį)4g{󸶩k{ֿ@A}~T` >yu_9|,.BC0ͺ@> B+oX}ۧ3_zz OvnT_9:ߖXL& đnCheqL5JnNmѤrCǰ[P\ōF1ǟ4㛣w2X,%"j}s4I ؝;\Mei(>bCr48Iqvgl\Yd&=) dťL0[3( N Aϰ5b{N}k4\>CE$#'"VۼeTD m[2tCzACǑ䗩Lo注Li_6j֭)r?L6l*s$׮#_{onubu/x!IYb/~0T"r+--fQ˨h[ƛ nm+ ׽/T`yXө@a'0OOT_bwKI]P{zE=l ݙ3_M*F$޻73!bF.H)e(1i/yrѨH2׀!doՋ7m"VVg "V! }'IA×0xr[|Ce8Ŕ-(;jt/)<4d~-4dݳ "կ8o!ȝߢјZS_<;DVos.6YO`[N{ Ɇ'q\[ť`|7^^3og0Hyui_1 V$Jfl17DJG4uwY|I5fzinA  1Z۝*Y;[ٶ_Y[5Om6BPCM`\/T+cK1/"3uvg])yF+^s)-8]==w*}lW<|ُzs.R.b0؋wsRyńNPb>0SaQ7*o+5vEPyv^m o[c)[ IxҀj%Em W+9*Zzݼ9!fPSsڼim%qz8=!ed~7.ϒ@IzƁo!}߷ [{ƒog`XfWyе&k{<Փ3 Z~|9&0#ҩvӷi2x>CL,ێx_,.ou튞TOY@.)N峂-CRM*#af.0u , "uz^/6}L{?/#Uq|s7/:cH 6S:U?̧q˱흚vnu'ٔ-gJe2;{wI$k{$~U7`A@E@ޕμ]_~6cppPs=yKx ;Cj?hzr BWʂ}UR)[^gO{z棐9 8ןq3_$@(sAhoZLfk ''f Mno37J[BDEYT zŸ,uKYHGy9~dz,BiZ.`Դ$Jo,՛ۓ=#%tnُ%WXMtnUHT PT%+!O =pJuKAьcCu<*PZ)1.ˣnR[$jQ*x e-VV潜=2T#0HXqj-^Ө.4( MIyB,g=~}T \h"'8M~JYnfXFǔ3+NIW7nfOou$$sRfA<ʘ2BOJ%c@v/G:`Hb[^Z [RG֟8  V%-/KD nQ֬`ABu?resZ,@\#^"ց=[H:N36271*[&ш[rYlʐ,F.5/Mw|2r6P/15JՃ'#@-P}l@rH!Ljj|GU0"b:hr}lzc 9cBqHҍoA>/'8z2`7u r(@F]Kݐvo>p[DvblB@?2 8~hCk-=085_&.(pE>,ɔE9bRaL ћd`uI+2}2WFng nQI$oX)n/u S"%$U?\g *\6P})c @/. YqV44S(9lH T o O[ 5JZO97>7lHȹ.JكNϒq"Δ=d (đG5N_{p$rJ1`j O46iS3?rOCodqVaxxXb9_e|B Ji>k%=Yhy?X/"ێl6 ,?q.w;!FgYtX5n 0KQ_(ReX3юO#웞9SgQD ߊ"*~B@6/Z,z8w7=+FxS^ĪM 1m{-̴Zy;b?Jp"{9r4N{"FC!X sCQU$Ns"`nvh6PtޢkƊi6khah&>qUkFP[*&zKzw3GØ2$"j^+]AB^f+k9 _> S^T D Ӑ~Kp5)m4]nt ) 'INl\w`QFG[Ag2Z}*Oחur CN<*kEljAP-9@lu_7x3T͎adj(s ^6Ϣ@7KNJrwgaJ׏(UR e/bF:QgW~;QFzk}{#bI ~3K oW3[m'V,So.C-W`8f.s7!޹x}u'u9\Njz.p&܊>-Υ%>ę&S(g.99qtcʁ|fHG1!‹b9Њ(ɢ]84 oK6̇ꛈZ5&KV3M}~ޫ&8Q #xY {k+Ve~[v{^Tb~X&EeJMF Y'lZ048n(cdu3Qb`OYgo`[}2e"}u2ճߟ,R6׺1p}4ѯx_ *n5iBXW'%N?&7sl|b2k,ȟFimj LL(F}_tƥ39y>.O \.Su1FO]s3(jiH:˯_ P+'ZB燦X*mHYVkگ`,4k$dE %lAH&@0 @›"5Mcy3albA6\&T/V{o,LN4)#T<;ؤrȩ_1-6dS) #}e t 1%WZ4˄;BRQDs7v Ľ=vN7E'TH-RG<}BF,|}U2Nk!@KD6x ¶>85H"dpBL\2?`L2 \Փɤ?bޕ_a ;ꖈ~Qra#+& S$+Ftwx0R5,"sYE1IG>NfHxQ8[{KFVO ;*T·0$ t|>_2 p^ݳ7r$v/X@)^p!W㌧߾QYeppגX cz~~r Y`w-Pk Lh*W0тv jZc9CZ&}@tTrxbIq .Il`ɱ&ZEnPu^z|c74郉]eI,=Ӕ`a v2X(QJ{Fܫb,K!S!cܷw'^╱%gx4uFSe6QO >S ԫe,~Mo!<wl\웤ĕo7dmz/pEŨﳛ֜z/UzHL3LD}^oTo.ؔ~;:!h~ Ι9g\v!][|dPN ƯWj<׾zr٠e "b zıAߞ+ f`ˮy!FHS4(:ҶW\/5COȊPN(* xGPX| TSw'0NZެ$?z:%۱6YYlͣ5^EuGQ/=aϼ8ɝ$,}mJN34\v)E9 ̧jQz::L* .35L-N1˾vr4y#jC|yZzɟŬXiaΛaB-$`qG 6gYm?[pT併USodzzf9憱5`-'9 3Wpsfrڬb=*BչUk?}}oPFb'|cd|l Uvܪry/@[ {tm[Ran# *撥T?)Ôuڎ[9l{OnK;%E5FL:+YQ}D8fsA_6Ae1on{mͻ yM#(XE1 +/#Db +uH r=L5 h'pLF0\(ږMKJ2܆ED {{bғxseJSnmͣm+t\SqA]M LH@59k0x .m#0{72G6$!#]LX? Sy}205~F6";~C[HֶOR+ Hq8W1F\GSn(V34p Ԉ @ky6o 0;}GXu, FkOꖗǼ%4.֍PU>m:i ~&J]ުo!7O׊)OaR% ];C9Kgxrn(Q5`i!>\ pRQo#ɼ7QP}jU 3I\Nͣ*o.GK iv<5gO 3zzL1˘B'Z&mDx2C6$~>ШWF= Y~ ;1ٯL!OP,,?-^jOL)TmaP/H3 〴c;G6`huK-e8+\4d\n}%^xqnwt$Ґ255 o`39; & #!w:`\ܜFU%ښpEuzv Jp$2!r=iI*xh4(rK$֏rOɋ9ƫo^ܮ_sL{>ݷ>u*ui ܌؋GIFc֙~cxO]fE g|`Ƞ%˻~rwWB,}Mh1۰^6;:c`'e- &·jE&JB0Z_KDQIeVKL_i*pQ p`E9ݘAKoVKPߜs6YdQb7 [v?<+b%FZƣK*h(:ƒO&  .ɔqǛ!g˚.3SJ>7.>r[_7qgQ.R2B mo)qLo#vN]:09 gNAŰdD 氤i(crsYe}`qgϐm؆+ @+퉎6(<eC XR&p\C qO(C/'X9^VopfvtJçx[ ]GqR#}KޑBM($fd&Ԃ qQq+gy{`;CÈ,bZ3}zYyFb~ͧ~KǩM_I$;zR@|Ƈ^WC*& j:2 kP>^7R s7-fMÆob-O4=Zӌc I2ZINSd_dr= #h货 H@E][D3v븙+?m K{ 6AI-vQyж/VubVb(Ɩ2/y$m\~JS|1,Eq^P b]9 i3`k~D&zTTm&F[ɼ7R•Ey:TQ$8TW}nnwueuoxi-ض¯<%Ć~K<4z&WUuOAPc у.b ؤG{’8:0a*~ӬG|+d(urx߈zLJ`7 c@BD'1{E~"oo:@Lm{esqt`n*ͬ~fiM 6 P8a?hD|=rQ~%XGC~>n Tf2_!ĦNK#T[NyDg8w) kG#rP(`ݼMM?v(oS{ sF) $Ix$6UoZCp^q1"iF1ey9XwHsٓ^$}Nvh{I1`L$-]j "p>e׷TֶpGM~PRc=-@@N"ȋEkT݀1a~j'Y[%(H݂+Z/[tX m?_\pZj~3W.` uk}4m^ {c+Pc!D,L09ހeWPxo'._rER:r,u\j؉>N/I[ pHփZ/8J Gn̊UT af(;۞ ŶvsOWU4Ib'bR|goVm+9CLF<[tPׂȥKc\{p>f,W-XCߘG]"IijLW0ԓncvDm0NzhϔNBTE3+'}pEI=CfhBWȶuVOCZ)4IobK$/)vw g}3mc7eAB|Kfi~s[KE4hgo/ ˳nu:g3<[X8^MFqN%EKo[1' NntQ@qDqoH*Ɲ7 e6&r62 ɋk5>{hcyjd&  .Y޶L6녊W3 k"C ^t8>q2oE ,Cяƣ7XrS4ĎH,s+}y*/{Kk*X/Kg+yӽ$.PoFfX_e pM4@#g6]@>k>=1_Yxߝ_tM؊e>Σxdo: lԳ^[/FJ⸫  /*t w3 ^vf+C%+;3 C{yјC.-0T'Hƒ]a|p~\Kp65nT̼fph? 2g܎^F S=a&wI~;^y)G!YGAOWK>>iD*aG U³@(Hn4J nyEnD? [B~F$>Ө (%,P6KH& Y\1kL U1Q>8oL&J7i/k6%^]4_*<'<~nZ_Ra`M<7o.3א pcE aÒOڒִ W9MK3Sq}|N1E B1:$[tE5 vhntХPvAW߯@򟭭 u9!)kc&9i"b؜gN$vYDEȬ.FxE'3Ab_t+l`wױDgit4{@{FmyEI049BmmrjJf~f,߮/:^Axzn7s  Js̎ @TE|2D+c>,eh^ۛ×?Jxg~Z犆޽G.'H,dV-GVM6%0*#!=L}DS>Yi{__T*tMĄ}T?)kO^I$V5-9lҒII8 = LɂD ߏBtzwn dPD+Ղ),R x,/3I*g޸,ASs_e|O\56,hƀ+=Qf:/}.*wRnf{]b8x Pxhxg9o$;dg{MWI*yJ, #7 Ւn<'f&!qW ;Mgq|϶LbwMOݟrl ϙ yo/%sN7 ės2 [o:6fj0g_E;eº (`i$=A"`?.pL-WLlP̻A`7&zCz>7NY{vcF_b Ge}B^O_|b(*kR|euT;m>2<~"߬4Ui}!x-џnwb; YGyZTkǙȴ~'@rӕjP1I&ط.B]8v)̂ (6:9*t/ @f;IeOl)?YYռ41ߥ6uݣ`ǃ†1l Xɣ5>ۋ$y:*_ad!n kAωH`J=zaiF:#mvnIUCŅ+8 -ܿТ{-]Vo]f>Sё0mR, cbWY!`CeD!nwH=zlX%mQ9GpY2Ji}˲wr 9ä ͵e UFw\Oy}L ^sO`[v1A^kf:4?h/˲N%c^퇵ˢ2XavpxUyZ]z>n|weОI=Ys+( H^ R_uؗPr٩@cs Y:^>/ll-L_,FE MI7<#뫒d3DDMwThJE/ ɏޅ?jn65c3`zɓBFg}]nc7-|:dx6{$mHe܆tJygv-_b;QO/@grމ؆eIPJ>aDnAZBefVbx%EܭNz&r`6 "…Eͳ,N) t&ˬ>5tSvIfķ7ϱn] V[>);caKZ*+l^ʤaXUMkBoNT^m J^3ĚxF.z>kXı탭^ T ]qE85ѹoMohkB3Qt;ߐLxe940JTf/2O+JD~ 'WX$Ŕ읍֌6+e}ӹ:4Yсp|`>(6f`i֞&J%8ޮ+ I> 0'z~WJyכUțUSm! g5IlC6u9Řh2RtKF"I h:5]FetՊA 90ٌ \帗>оE@_]lXs_S!X=W=G؊ cu&C'aiaDE 9l|T=&\*msH*Qn35 74L'KLw>Ngҽ`".5"*H;8A, ̧mt3} [poW61:Kia&j #+nh&E֭6[ߌNlB9Td2@wE8[m싇># AB ՗O, -/w7P,{6ːmɑ} &)bnp]x/a7=uhJS:9~s/QNT杉Za ΡօHZ q$MpjFs?õ0խg`&`pxM  HY0:3H}c^E5#)d@ox]A+<ϭ^p^Aۻ޶١eTFUҨ3Fyi3jpŴmǐZluWwl(Zo0`s{ω^S poƘA`]ckdD%/E, D>ء˭=kokM8`jYu|ZEUKP^5y-I05D'-/RvZ _žE>YF '!0q1]RBc<}nHĤqFxo;>]pCs+ӥ 61} Bf^Xs3mX!9߿1p8Ӵ]XqN7(PЁ)ԟfo48( MӁRʮqk]SUEon /yO~#ĆlӰ٤h+<;m[_-) ڠΝ7R`\zXh!Z4LJ s)$6]GD 2+4f⓶3XЧ8h_afr }Ea {)(4yXʼ5}09+R(xIJ)(}\xfzIJ~7 Xr{ci&qyAՙj,_?&b ~kToJ." JNAb;ALܤyTGqSמ߷(eYwtVțp+e4Џ>\ 3n\[8PIAMfTOCH!drg "c/AF)2o6>K4' ~{Ҳ5?ixP9t!ﯡsդ:q$a:< vv)lL%^.IY ^8 g'{]׹[T۴UѢ4m8}?6mݿE[{?U{nHMrӗuSoЪv;mZn<5P8]8ZUF\~wPv}j՝Ϡ-::dM<ʹ&^GRsKcFh:8[>[Y@wۺkKoh> "~"G, L`(hʐ nydTއW6Sqɩ1=yMĬA|v'*\ 3rd4ȯ  B2,5z'ǎVz%פJrK '7 [EioIWP m{C\KjHni`0__IGnYG+fГO?cYȼ5Y]DPW2zVУ05tg#9v : B\h"q{{T]d}8DaqT1a Xտ8`I޺,oġgf{ƿ8r7 eتtޛ^#3%֛bdJ E>H1,_LZ!0X%Rݫ)otF4M$3S_7 ӹV' :`b)G{ /|QB)W ,yo=/Dz>VXEEܠ|d> GKi7w9yuMXgrrϙ,ڻyAr;ְ]~L-@9Ʒ08mOu7 X{!MP"$zWkY\i`4GHf|ХʷZyn :7:!(\^u1UD$ "4TLxf7n@B9Tl/hSҊgf#m!L^x޿\^f8C//@XxMQSfCGFZ_ E`O+Ĺ,+*4uZ A}]/]9}_ W"Q+A_QˠB@T@ 2WmhFqdDT~ >B2gevg ;A^=ι^|Qn$vo-ZFVw)`=1]H@7~HQQv5 Fr"&u0^-R`G_&(6 _HPѫ8Dj2MFo g}UE`ޞH`4}vz>V&fu;VlP@&ZA1"κP^,/f8we(CiI@(љ,z)=b$9v/(!);BX@  ^B^G 쵂)b|Z}ІDj!-ɄxbS߼[+Hx-rn'o]E׌K7!23nt?֧9|A3fDKS\.I"<ӇuA7@P^ K=K&NrcCM'N|zz0_(yJ>k $ofwzܒLu([?&^&)*sBn=Ff&|&llonРRy=/7d"lO[r ­d\ySDq٥ NꠥB{C~<7uXIcti-PȨOnxsq hn'UN\]e?$|R^B8HDf0M:^_jݫjSeS>LKվw:`k->"3iuW<$vN'.nV6Ӗv$7ɪˌL$y/_jOpǾ'YX fJΊ}ZX_3oڑŤ.LcsB^ ޲yEaF`L~P6K8=9%hDC7;YM&M N ֤1tA&/M 5r`*}BisԤ{jv**<eyg b>W1Dޝ[$樰pAXktg@'W\g56^I9cTbXc]vG Ǎ$[G+:]tne*4V]_`o"#I@ᄱrmTx`q hza[,5+_F< lɌWmh$Rtm|h;4HDh )7~7AڸffJ褗7l//2>!}5@ Q@@FF&kH!m|iV_i%>tǼ`[sԔ,Eˆz;*+,1 PyEUoÞO_r$K&9*Ś _IOۄ[C\&gD并9Ca-eiKjnٙbm%mk WEƐQ]s~0z:InU*Zzo;/ #Hj󡄧R,?76 [{uY7MIJ}J>(o}|5;+!ako1g'u8EC(Wdp.W)J\G ,j/e-lQhT uB[7/ćPR4ʘCU[7X5kН lףOKk>ӥB*m'oUon\f>8?۰5v9۶ǹs tr$r}$utty} ɂb$(3\O ݻ _wA1I5C黽mjv< JOY' 9:;C_t\fƶ&u5U/΢t$댞"Ϡ/b@wtGudXߕCV.!2P<#e2\];Hy[QyIw |e  J5˼;ʙb^hќHVJa5~`#Y0V.5\CZSKjx~;I Эv;l#9+ [mݼ+mHIN< $U?TU_u~Gob eB f~؁=^jԙ{@כA.6kO1)JA@{L6(`Q-xaG߼ #c.:;.b܉ͬU K19ېnUp]\ussc-ȶd ,Dc0k3WDB׊hgqSr7n0 Fl/9l;پۧ|8IїzY2ӱʥ*7C߉*3;=ex?Pi\:p2>`yZtB l4b i(1xGx]}ӤkvoĐS]T\ƖWCRbG-S3ɕ >h[r x9袊u99< I\3ႚ!| ,>Sk%KEs{#Mno7/IPpZ,&^=n2+),>F43u`J rrnQ_v`Y}! {M1S }^q83\*$) $k*051A l9ѭBh&zĩk6 H[]@ZNxԮ`f;UE`SɆmyzk'$N8U 9UrMrPޮyE`s<)c|1Ti(ewUG'OV0YH Xc{^j #-Ρy "!ΪHR+ԵެfM32wf3é[DN\Yh{*ƕ|S7Խ(Ə?8X'>}@Zߗ"GV@qwW[[8Į߯~9N)Pܫ(0xtdTobBb mbe}{Kn6B?6P7.-^|QuI1'E3h=mgvzCNuǐ8T - Bv؄ZN~P`fe,Sր2Cp×]l i\4>Ss\:=*?i`v,_%v+2Ӳ̏%ȼӬdzO^0#DR,t,0v9 c]`KwuzPG/.p1?S֘4qS Ԍ ͢-4?;VٕVjQXEda\O>6B 9 8*噒!x$5QuJ?m0o^GsO-qZO]/ϫQ8uʉhY[VqRԠ )0a7ڪ춛c=3oHYZ-LTȸ PtE@|u[6]OD]~nsXl3No$d|u2k籜 x Qe}ꛡf%?JI n*AaĆQJ1ׄu$\ѭ!~E@Q g2 qfͯd;9ro8#tZrx3:~_tK ӱ—)`};6CbFǍb,Ae2~>ޢ*痹 oaf>6+YgxY!ބ_^쬪ޟKUpzADv"]" nrgAGHXn?[|{wS1ܻE,/^qw9=r~z!8nn7#w<ɜm,8)Ez˒&eYK&BqIJPt{秪DMQ{ityӃP8FQhJ2 ͋og=Y|Ѱaczfo4TW;qd0#z=J_Z2bխDq(N-lfX}㜏B7{%ۗq ɥo}_cZMl&Ku#Rgm藎{%p4NxBO x#n}JHI>$u.qol&?-; ԞuIe r.:c_O4Ms:ڄJqˈ:!3[#1ХX"P>H~lĈ9R托NW1ֽɄ )>Ӂv,NP'>kH:&s%C&YM[NRJ/Aj$aN~?چ+I Wt0$W)6mԛC?k:P<_% l/;tkЛJ}XHaM3*D etb}P&3_W'q =՟3y7C}d Jpzs1SV:xHȐ9|- A͒ܭs8Mxz;7ir@;}A42߯xl BBW)Ug˕8d@K·l:״ۜc>OpUՕen|]y`X7A,;܊aNrHwHS'M:i%@/Eޏ@c2U)ؕEWEɢg{4v$F}fF{}DDFmU9sk$\@,_J `:g.pZJ E9FOc$"v #mB͙͊:}16t,Kr2,3sƹلhh҇h@Gru*m01}"^+kݟIT qˌ9rxҍZ!|bxgww:g÷# #3paO߱j֡}m&GZ\rO#ʛ >~Kk~s[D(ݜ47YFG8>1!ϒ zm8q>k.&~q7\J}L jE5Ftes?D5t#:n+(6u8OV [NCTuש\|3*@J鴋aW[~ $DWڝj' *?uj$lY*^<">W0~x/ַv '@*sqplA-ĎtڋYB5=\CC^BF6kdPP7~:W߬ `e4_&д&q qw:WnK`d5v~ ;gȌX4% Aٺ܂Фk;i;BdSx6'3^7>׌, KM} +u:Bh@rb&ͥЅ!c…zH7|$>/H{rƊcѢbXoO\_gWvYj*\@geoO.d&]VL̕ȇăgf~)lgX{:C^qSW=Tefx44x;zyg%sY0x: 歏`S34[og|/1E`(m߉ `͡5Qi+5a6I`{lq?\^PJZ*./M!:D/>4Zm7C8wS{'k/ۃ~ -37rFUt| ͿJEnvKWJr+)+3KF=dZd|Ә.>rBq{D|7kvhXV,IRZSNj9= IXC3U[,g%Q]2^褽a4rzlԤW^!.=]X3˝|̫w՘MQAKx!1xޗtI' kW8pqp% O,#hIJ $33;0M80? /!I.tz /!9O`,0JxcH9O2 NcB4?4_}D(3rWw8a]IN.Z-.Tvs]/N)-A/G>ގF8m%GԼջ0 /NӤH+#ATe0O:]>CT!ֳ~'|؂+yl]c,'wf%]a?5{7vزmd}yrBgomO̧Ezz./:\/2~QREHLN~NqD&R7q ۏ~T䨧0)jtꭿZ|~Ǔ*EFgy̼'IB'f vU)Knu2k3qPJy(XX"wԜ怽+f 4eMrkiGJrHuRC?>]ul۞2uQ۴ ^ l= cXeRa,>d/Ǖ&sj;9vLbI_]_"-̾y'n" NO1e xnif:r~o*sNT_*77+wǕ>L߿=Z}ϒQ%D^ןO N&,T,_^2MDEl"RW=%;20sh-8j/YQ izYcnsf|(*y{> :=$-PΉ^KЛ+'n{\GFIGBJuOKUh|\7ga>cL9xn8֮/*ڎO}p`4_]tu5Oe\#rdh:`iO˭r/ _A<ǎ3Y{Ӝ3 baЏc(A_1/v{;^5|LM@$r!E\@)'dWN-UuW|}hNr.NlK\ $HX!J|=a_R KJ  "[ZsG#Q9XOjF1RLWh+꠲l9Q:3F)kNUpAzZrX@v}t]w%Ri.ݿ xλ,&CxF^uϧPÿ5,:y1:A#D_JqjHe1"!kVRQoA{a?}P~cpڊ:ZO#و =nF4X 6ѯI{*e9Z4m(AW( :@p8ͱ^ޯ <6*w?5hx({f+0AݛJ.yGEY['15XoT9I;;;隩 >lӿpR)]Nk%tx$rVg6c)pɜ$4.1D"kLΦCO :6_s$ 5//@4" * =Y9X2IT 9ǶeDı1EBt2:P[\PTM{ EW`jo'Ta6Kǫ~@]דTVnw? c /7d8~$4hj%$Gc U 6HkeyzC_6=Qy6ܗJuty-xMc&ʇƦ'fĥMm#Ņ$NH[n g6}1wp}Ir|.n "Znz7a!Q5|Ɛ 8H (Erʹ"{|+5Uzqxa]kp_e/X@ȮA2I 2UƼLf&= |y͠gvXu/~9i׃ᐤI!yn'SlG0cb.8Rwn(н`U6}~brd}ڜ>,d' mo! ~Dr%)I߬6B_P&Codf[$VtXWZCh9e Q [8.BHyӿ䝐@.#̝kFw\yy'l5뺞a۵_BvXD ۶\C ժF*1^kO,Y;0jp#5nj?|Ïtn]~yZūkRo' & a> s0ʧPL =ѱ/KYeg}_u'wƒ^O<1`.} hN߮QޢAKvu]5}r"SYљj% TC!C& r$ B ;|g)t$ p#yW ){.j}ZK$ i~U} cc'!C@&OgXnܛ_ IB^q.iQaO4z#@U_ȸ@^BNyER(p =ssOIϛ L P3;ڑ*1'ǫuvS *10~pH>=Z;п_ B87~jafQɿ%MM#>XyptQECL>a,< ,"v C[O9o*b"4mB.FJuG__g=#dSPk( D8zxvy)+U Q~3Áf_L~7Ҙr@PzOz!ۗ͟L(±WIe"ܜ{LNq(&UHfm:O a̅e\Od#Ʃ̽!"ƌ܉o߿{D ǐr&~s;;rh){BB!rrr+ہ=G4t|пbx7%!J^޿§G-rd?"UuZ衻8yxyo ^X;$[?M & Yq<Z&&-&X)?Bu&O3Y6-[:B!<tE"lMR9PpM$w O#H_ tc(i]LB?/ojf(*\6M`/n ze+ ~}; ]'Bu$:8$< 4:6 o]x hٸRI-ɑ*ӿ.X2ؕ G^0D.<σ<AHA?Yll&Eե͟[1OӴՊXh#[6+S,v6d#ye,iNݦF0Eܭk$_k-P}C%M+b2&П3 |T0~L \ZoA)`>} o 3zުՀQ4q)7Jxj`sxA]Dޑc){&.|Tqȓ|:y7ڡ_s%4Y# fEZř=d.+u Z E kZI_9mUS|F#+3zየ-㕹t?  "EtqaR&C֝(40qN~J\= p_P!U%bj@#7##q4^)]_[bR*]lx ׀Q[Qg)r"8г&TدLdd^x%ga0aGSؽ#ʽ#6A;:ɗ]9ݣ'|$A͕ѱ;ec)w%*YaM+…)SBYRmB,u,UسqЋG NٓeF `eW%on8$1K&"i}^KFn%#z׸-ڲyBVX0~0u,jq^zB Q)O*G%޶NM">JtL~8.xwD}siU/:=k|`XPLzdDl:"-SW W~K=8[&uDYԨ+0jhJ) oT; ^x;7|cM2 ^b2j<Ĕ; |2 [,&K'26,I9a9*C;7U;Vf.WJ58$EO%^޹'.t$á:%`*~ lW$V> .evE*ryϻvB?cjPR~ɭan3^RnD ⭉k`S6:}ʅM>(I`3S?Y^A|$#hM~ϪJo9R\c8dud*E[Eן/"f褫mK`"{\?ڏQ"8m*Ks_e8D9ۺw̻1Gd}%C!Ԙ=|r!\LzP]1Oxۿ؝9X3M wwp2uڥȫ|+_KO&X.9c8 h2;S3%cp{补x%V 4p)O?"Iȴ`,q&AnUuuLs7Y:ε⟿mЙPk<7q QcDeKmekoOȊ2V3 0I'!C6ryh'y QECJ2 ip?z'Ek8^P['{ni\'ӻ߮&>Y!uqS %ONR.oh>'J^iw4ND5c/It֠ض(Q07T]Tl性.@ lY{Z5'}>fܿ<(Sf*Sא5hKQ,B{ "y4* p8f zC\[)z=rCy w(:q{ 8/` @+'E Hy})lɼ읱(BOf& pZ6q[_ Z@k:w/B4v|7xjK.\gÙ i'{ ZM U+bݷk?ѾN7z>RRc2-Q$cl<6Jt8N{Ε|7h-Ѭgmǝ8'#qϳ1;{ QTRArb޽[3]|~r#D+193ۘ\&JK) jtȾӌL g׿SdͪMⲹݹf6ȿΤ;.#pk^b ,dteQ}ɏzk͹ 䚁!Ĝ)=fG}]g>RDH4f`̸v ΜʒLE>\,k(xxAᥝבwW&ၝ%$^de5O܋DQJ^z#hf'8{XbH o8bϦ Q<$kv{گDY#\b$8 B+MsS>ă0>ׄ"OmK5P. j/`B: rcc,LsS @?Io^$7#) T ^@?K3$\Ľ $U Cƞжe3lFy3ܛ/rj$|룂g󥠌ͯl<+;HKZG%@ 6m4;.I) j=C^dO+N2Pڞ#Jwi#{Hh?(_9- *_cJǽUʽJI$#ۿ9'ZK+C Y^_zuߚ3)TmT)s8#trЄz"Lg C6!D_fW^J[.5em' x备V7< Db+HY? xv'P) 1ǡ}?7}FTS5'mbq `Qg3K&0#uyUGh?AcKJ<+$"7L<5rOib iKvi_{]iqh[ dO1%E:B[GU1>TJm<w/ӻ&=M*U:iiRF]QX]O}|˼'af7]!OVчR$]ͬ`-+TqG/Hcp,3S5U>5>]kH*m5mm˳|mЪt6e{8kfg݁ۨIER ߄L ǀu1Tq}NϾ?34D=Ft3Mxxn>߸Q:w} f[12CJ3_<3;VQݹUפt-+KM3SI'-<__aO zlM_iJ?Oqx#)#Oc}fe`[P 7뱨iQТ:w-vٹ;\7׍7}==wO<@P,Xnm"I|5E&$QCy"&ߢ8)I9N}]xlj!9 cEl ]=j]MFhHn`P<4|^ay j}6@^ؔta>V`ۖ#c:L,-1~;N0ъ=e7,\bb[7 -%?7RH^|iW's+Lx b0egN[K?ƫ]NJ19BՋ.:Kuy)RџD,^ j~qQDX[zƨo"9rNfjN|]c -14'xc=Wܑ큜jyH,w\6?kTw.'{= VRŬ&зUe87o+;a9眇! ػVOn]2`/t/9awW*M~6IivQAQ_ա6ZJӊ$/h|r`k_5@*s4z{-]jW~(MH}r@?N|d(4eGaX6+@E.hJCmlCTF>Ul $fLwJK*u[4_?z|q 9kB?S#cFi3PL3`%}&w~7OʧY8c0%E M7v춣uaoNۏ ݴcoGh:zuKcL#$+БdKU>擱9} 5n@@цP^B/ ^y9E{}?I=n9;+q;$~ PE CHbLĵ~g{YOWƫj/YDoCTKNMi.i\a?b~7Pܦ NƆjhȷEZ9& AA4 5XLH4p/XnZW_shHo{A~0c,U"-aZLWQ"LDv]Q,͗F7%kI _1 yXLOU-DHíhtvq1kt3 ˵-o5Hw"¿J,YD_u ưi0B+Xx厗%y&}/ro+/6QdOb7,~f1h=dž=\Uyŵ7T`c bxƐ6 EvLrw7+z8K|zW쉬QX-UbK*';HzV3Q꽭 )4Ubx&]]9MIF`0 c / :-RuX5}$x'7j$, ӼA] (1v:u3JEݞ@N +=Ĕ{6?mDū<34ZP8 nH4 Kh¿ v}6Z=񖘞Tr9 گxJ7qoޕo.}!+2hEXz |^;!8.ʽ/ZD|@.(ϩPkCwflufl(ȃ:?@G {ZYM|ͷ7h^=̥Z{U?t佝ޥ4R&! K0N@3Vd%z\? {,7n͢J@\ors=k*]nhy\T 'ُq {1{>~{ΟխW'O2ލsk4:loe^;y$ LFaQ!yINX"H}周v)\8c[GE_:ʁ'&鳢B-]8;w;[B_ ]DB|F88G4)U(=?@{⵮Ln: Wa9V26e*{MXt g\\"18bEtStcuSɼZ') wF7!dۤɐ.Gy[DEx89^k_)Ff&BF{*4Uf89coe5*~2XÁ2ԑ~y ;!$a kУzv8n ͬ'~Nya |HYQ6I=o?:Ok7(5wmy%>Ǵ^:i/hz}_g RT MŲﭾxoe[t'w1;\ySH ìNtgDА!@p;6鲙c΋#Ok03 }%r >u9 k&*gC{: cf79TQQRܴ + 1#얃Cl#k\EXni7$PoŎQz7g-+-}ؽ_xϦNGHe#Y Ndsy%C!u> @B 8~>Fs@wQOiߟ!_t`rt[o8ϱєc\u'G3|xs:őRϙMՄ@kˤ b46``Hڧ Euֳ_Ja skn7f0'w*;̃jZKrq+~<)&L{I:싂!Y*0 {cs>:P`}ᆴ\ w`srmֶ6t7~Fʍa9߿fO67[lj~Ҟb- M6#',iQ8U9BZ3OxX.X~VMp~\iyZƿ&:`.6l bmqBl}LX`vrth:|(`w6Uੳȥ"ݷ|4YjX-hCSCz|ʚƲ)%=>~|81F_P/Ma0^75\2\E4/bz3'W/弞:՝| >DHtm3Oy:g__~دg I{I2Kv=86WӃc5YQ~+?&ItzW:(x;TY9K11wE_o`{n_;΍| pŏ%B%CcQK?d/<-JB1U'6_,ְڢ,c3q9h15IX"H &} &(FkL1\I8ɛ'jޗP[Z*Y*/3I9Y3<#8}UoaJlգ؛P82KSjF!ykx%~aF89ezE/;w<3 ؋wHzm OwF]xm]f~G *g=/ '!4G@ډq-3U(nJF?=,=8j)D8 .~w,MST$~)ݫ-4xM̅$= hK V !FL] ൷>+ z,Y^^ Oe;D~O%O8E'y`H̔t?{}(E)eڦcyIe 9F6杻^'$\|U졒_ N}Z3|f5bKC孕Ivj kCpSj^Z]chu{E(VYE+X?G! fPR$pG wpƩGs(sM6j=!_%9/a$W_uc;8޺mB?dxf6te_HRy$9CT9ʌ8|ϱ1EqTTe/8#4 f??gt9WsU oGy7!e Qoh7U\!Ԡɓt' $)kޅ<܎07 " x"U^OEue30Qc#0AEveG' 7>7E1rynC@ɻxP@ڱ%S>Y_j^ܬsz X~xv:|lE+"g/n 9)%~ߐǛ/#IJ`tb>oDKBF<=h+G9PA*bw5|*اAOZ30o{ Tiy +ϴƞ6KN>K'hNwZX93C̽RxJ+39AyR%J-{2r$,Q&;8_+&5`ٶP 6j1j}o*C& vE͵9;x g "|$#`wdRx2Z iqHQV/v $=09^M|EKsЎf)ac jܩ5pdԎBD77N`r XJq3uNijtT*E·߿ dg`4㊜Dq{3eJL=c(>PJ \_{5K1*Pi$:A=yf9x ThUVBg~'Bw'܌Eʏg8;b6PRgzX2L5C5!nĪ+sUƩp{c*J*O(3 VRqVUE"P-< l3AG0$0^$f=-L}+uhQ?]6;X?=LR^UH(Q"_(1BʋI)o0/Kx$twg+ux+@d-Wulv.s>}<]%u**TFN^ئ~}|җ38qs?ySiZ>r&tF+@˄@GE)kЌ"?o?2tdl6ÓjC;(}2?4ӝH2@ABAo. KFLO<& ޭM4Q?lhAa{~pepW#ή|lVc=[l9طibpz*i],~cҴG⧼r[ 0j+Q@xqm`);ydL8U Wi56W ̽-G4oek?$2e6KU5V/ }q# +`v rkqsO>.**Y`S~چDu ~9~#^C%#˷V+uoϕxf2邧Ra =zbo?p`WbE :֫w - -` 9ŷr]><qf A)0^:ϫ3T\<=Wۑ,΍J0YGz;Q*/\Ocd++%ұP/\Hϥkr|IEE[ꮏ_(rhjXr|[kI4MK$ f]]vdrF% vE@("<'&Y/W޹Cx( .zD~1=N^w&JUyl꧁Gj~#,hKٿYŒf65֩$q]CLի0ﻬTlWh-eЙlOՒ}ԧk`q,㫊fccFeȓ1x/_D{q+_gNT#f}>k(گ"^_w8Ӥtth+nn|9?(˞>u}gwledh_$ EBQCiʥS!t̞`w별yA"umY .IXu*KB׽͖pSy@)KRKD ݃I >UVA|VH 7Ek{xJ5!+WX,DkFb֣0W%_ϰ'9^rw@qau}v&/JԿje86wau0̳{Y&C+:DdLX`P:4Հ>*}b4pXx>9)8UWWi %$tj^z!o Rgi !+lAYQ dtFW+∈`и q)Y1KO$~chU.?WT"yZᵿ+"ҋ~H+&#u%R<4 TVXThX۹Ԑv0J?sӗxepWN`qm4 Ľ+^GwbH`؜Crj:Woqͱ r*eaK5P"rmes &2&Ru=`g:>azeCȍ8zj城]?@&x{jwKbw"GHpl-l?7 i`QB-kx/t-2߂JŖi 4cgXXCL{h:Xc3r !fL&R=yP&w>j*jTw_IWj9z-H"xgli&x)xEyڜ7*DǮbf|'Rz yGL̓9)(̼,P +-vk@Xt߸vPegH3A3ff\97zD"]? II"Qr$`Tb[AlIi(Y`5{{>]T//^6%7~ɾƉIѯ^ Z_W\nwN% gq9 /;uA'}GWI\袉,8k ku 9hђ^A!óufNVɁ7Rmn| ,$˿2\1-mcؼ'W>nfFv=uЎu$$8G1T145)U7bpr ;PٔM!Mgtl(j%]w7Sâs/$+nIZxփB!)v1@7h/[A(|Ɯb?pux^8L8Wn]|:+oB7k: (iȝӞ1 ohr~9TwyO^lRoW+gn#+){fr#<۠Kqd5?=rP?LaU$#E旵6{vIBCɇ.ScXoW<1UyνH)W^XُQهbU,acrÀyr4x0Ӹkv4JiigIv-ZL+1,MXHwFFpގwݼV+Y p~ MHa09TwopC GصFZ6M9h5Zy̴ND9`A2S:Wu 0ۍo>FBb@w#ڷzK8H>ў8,0sڰC;Cˢ&d@9d5BӰhPxag%{c^~j~ 4תD 2yB(FVH"5D(A,}Jy|e@JE8OGuWx_}a2j1G~WM}bf(e_y@y2Vm 'Uّ/=Own97V Ė++GԽa!ZȆMiʠUL#gEpE4 6 wRuWQ{nX1YF;v퓠Y%%CmjMW(!)otms};Тc(jA4&֖lk[i4|c'MEc4piT$y-Y S$6^`9$e՞"k~!L`'ZͶHnu\; t̸)jmIyjzLfp"b|?(|x׎ N3?;8O<љQw_}p c,g@w3<fdH|?YYZԓrCF$ʣHC(ȀxK^IϩjPmTKl ;:BcgekGEvB7!bsAAUJ>-/:1iQZq3ۑJG--"r_}3pF̄s.jݝg>ogpmDմu Q#Vy58k]KPc_s'8Go{H0FK.T8;=Uu# HW0d_H/Hw?bAg>1YOanz5L+ࠦaD7O^ALmןoO^Imdڐ4x{K B1j# cX$nNQ.")TM0+OpOkZ$ kc9x Hps}_vbB m /݃߂aL8|7Z꧰  !(&b|(|cW^ C)"|y\H ̽Q Y:oEƹIv3{D6_zzݓ¼m+9ZVj,MR]~ZHqk[D"}p1ΰ?ް]\#?mp^E,2˚:r 8M>ᛌSSGٺ8 liU;n G]ZjuN\Jwax|9@e^L4O{AD7[^'EX0 s6>GqB3woHב^OAj?'7`'0&y;{DcEavhJzT7Vwk<}iHRV~Kd˜vSE=Ǘ1DxE ā/C.]؎;=,ȟ-KI1/&ϫ5o:\^e[cbˋl]$$\;ڲ][]s~hUL[םܗ⤳rP>KBL^+7 O,/8woť -EJKo _ř#8Kny.7j]O8| pcg+fz?|LW/>GPבny;wOb'iNf.5[p> zTlϲBFCa(o|B%y ^N]hw"| XS_;k"~/n\>O,rDO+GOz0COBVRS[0DXzG(6s̴q*D%"ST at3c0 a>Egsd"Ocxh ӥ1|wsc8>&v;欢tM_$gPbKFq#Z'6cO.>iv5OCdz?w^_| B?yq0EW:ט̐X/uP1|.UuIHќ,5o~^>ji~V%Oƅl1aoFJ-KyYx%3 _*<>_ o]_7ܧ@w'zjxn* ['/!%Z[J?;Bb$8|q_Gno)?HuH̴[+HzN_W 5x^2,xPHm?Ͳ_bv R {g@AM~+>a.5[{&YLIK7Spl207+򙆀kI-X`B NB#@BƛW9LXQ>Fjۈ!te(T`T~eʸi}{+Sn5o/7*+dXch-L27'/ӋGMEg(vN&֊a=6Ɖbrt)RlMie` UXXz ށJS K 4)7]:ZֲE#071A7uNFU%ʣyHdluudC^\hӗi/D`'Q#c]1tYT[VԣA?eA@^)]zh-^h- pF?>ɤKwJ/6Ѱ{D0DQױ0$"v6Z>" < p)ӻ(v!>3rZjѴI9pt- R9 ZK_o |7xC;۵(Ԡhg3j[gb k.M/L$woC0ktXFPBO$PUfWT(=$i0_1aPM`?XNj;v&>-r? .G`4rpKɏm&lE%:{*k/TD'x%|[{T;n 纈_r!y~,ZYW>nP W^~M(kC7nZ\:"|VV;3 !x~Bg 'XւiBTe!¿?2X؃Փ1l(TrTㅺ`!Tì'UMf!:IRP?AqЦ[W;`xuO #ɗ*XZ{.J-MVdKe25&kCSsFkҬ/S'boO]ܑ6lCM%Gك%/aŐt@@=qhUin鍸T2\b trau[[.V{kӷp np"3(k$tLȄߴ)EV^V%G]mA~"a Scم ʀhf})v/@aXZvI2 ն( V%X[G*F) D|VG7M(B_g-DQUdzaL`}$kb3A :nt(ϠL)sŸf%,6n^-GĒ F']hٙad#a{Cu^h[(ё\. 8E8>.%߃d:νc* `׮$i6>jrN_:qR7Ws7̺|P%a9I'\]b9[=,Z[Ss͏8~=ٿ֭2,k:D5Tp9B:.#ڂyL/gP+6Sܮ;3qW.JӏO?mہFԹ2ϵlP׿d8 o|1DL}fZuk}?/ۇO3O4߶ sNY[tHb*s%b=Va 'U!:9PGhՕBѺh)E,t!tA/xo}΄?q3F$@\NC3 Ռ9Vnگ?~kr$%SVr miգ ?k` 9F,PWi0KU VV_8㯐.g$}^]Zݿa !x!4#T`:㕋InK Xo` TF~'΃w<䛎1 W1j(0P0NB*{w\ْ9 :t p—!z?jor/|wF=tcӒXՐ^#iWz5 > 5! FpE-NJ?<;I T@;Jah@_t+ZTv$ݽ]~#􄠝C֪PC9DI< % E!F't,tP1DӦGf"2z ꕝڀ#x?=/>j|ZeLX1"0~#D9r]?D Z3'SJ^ ŀAkuR9Qu߻.C_I7,N]rM)0I|bjD,UJhOWӅ(wM u?Af,Jh/1fF[;#ca'Mj;pXɤ9z=J_hFgԡxUܡ;У!?:nHIul|E, Gހ)AJ[+y, Dk'_UNk࿮-uMqOhkQ؁r/,6/-N"w2"58w7!W##уB3F"$G%PsqA|oR\6hO0O|ֆ\b ቬ'}p=uAc4P.`4J,ܟݼʚ7 ķ\Bc=DJ 7dJ"7 KR_UlUs(4׊)!ZWb.A+-:i̟0BM >J0'W~RP{?!"MS aaӫ:Y,qί}躇l{Vj'ߤVF -|\d=/Heo=+d;֨,7gߥV,5vPЌhį3W;#6h~%R|YpIϜFyӋ#j@mJFˬ*DP0F[x[Ƹ`"毗<C;r@(fNA&&"e!ɌK?d=_~)N#:mw.}e0}o "Rńź=3p Z[kEC{TbJbxwRH\ΕĔOߟg AtF\ ݤ`L|g;4 _sŠ[K!jPp۟;*KhtdHr}٬!!=>.VכQz }`(':ElQ}&jJ_ԪMΗH6+%;,!\k9Aszk>b18A )v,"225맗>S56о4gKo|ݡX h]i=+߬8띡ag9;(h("@͑.A)l$>J_}kTAew^UNi*塸&\ e>|+QZ71zx=-.p7LG$h`Rl M@SACT@.Q>޳8ZQ<LCPzf"L3eoO7ӛM%Gm@OËejADX䇫VطJ1c G@@w>';3Lmq'_cx}ihGV2 d- TQ:]2<ۧz-,[/O F%_E#`i 5e^U/!O"%Ntn zB:PO3UPI,{tx 킺Rةך_pl{#0W]֤SvhǗզ1'L61 l2!{G}yyZur<36yG=?QEL m&v7}-~ITWha3fWK(u<{>tWsJw)0ݮ΂1uRErz`\sQ.Խ\;.:WۚPuOEƊ7 igiMt/C#`I./xDLJ Ȥ7ƂK|9OCfG}yݭx\^R^r6ZES"ZVd-8{{5za3F 9P~o(u!X ~Hdh(2f:kLbo~!0ɳ{s@<%p0dD*_MS+oY>e棌o!Gm4:bGQ?q @km!mN:yd'rolg.Z/vIw>az3C@ajvɿ 15(e5u.ãtR͛%l4R=xuXH 谘Nc;8pG<<">ϡɷR!o~Q}C]}Y6[a.YUGFX`_JO#wpL C;}k@2h{ )KiV;;ԯߥnV1"}wbۡ!Cr5Ah!箨CA?ow7+C@UBrR7#R~ oJM,؝ٻВ5w֗Fc7"5 Z>O} F;uR_Q<{,AwX6].c(**Q"{iO X0T/|DTNbb?./! A0 .5Ry" 51S" A5CU4[]9U䡁)"Z2~h8ds4ote4x7Uͩe>.0f/wtWPT_pߖI`aHw#%?M48vQ4|`Ġev @bCL6)$/%\IgS$~ύF bvA o5FOP(,҈h j$ۤ幸 fqI1Q9n 8tvk=YhZn77W1AifvyW(ξBGjk>uko.ZQK*j C1Z\\bS|xkP?h|0pR_Yl^hZ9\ء#\\K{K ]y%25+fs~Jett~BhOIf\X ֌[3kJ}vwxL^~ZRQa( ;JZ ~v9FYp\~BY{\ 4u٢Zx01Fs p?jGbAN#U7hFnn Eܔ0շjHY%84vpGzc޴o7=w%IR8TBV{(^5f :mxn)itOl6o}ӖnE_ kڣ:]ȠE-S>H@gd^R7:Nwa6o(=4ܫoSm oJ&U*UZ2 3-.tL| %:3e]IBJf-ާ.Qr Hą n2 I Z8-3K[E=X8Чg%HxPbAᄯrM@{)ueZ=:?}ՌM 4y9Yb'(ecEE^hOHE}?ϼZ2yO̠:ֽx$0{B*gSa*:wJ=(.aS)~JF|o.$$ ih:g_Vl9Е!~P/Am2a;Vi5P YK̻,tbf,CxWґ;˓6=4/Dϟ +؜IR5[-{Ҙ'^f$>ܱYkYa9 2C8rU_Gt@U6~OKz[!Vq<! 8u>4fn Bfz7K,.ߔ:ݾOk[aՑ Vϥ]vL @GCYlG#PH*צ d2Zh LhN/_͚',>6w.ѮYC깇UP@pT;S  ǝaALjlg[{婅9ij,www '{N'RD; LF,q!6d `|pjJl2lQDC,%$!RPye!ژi9F'DJ;̕>h`(vjԹ혷N| ڗ}Z) N3h0]la2>rs~ϋ\~~nkƷѮ~2x02oTԢjpVS#.Cg'ozM{*̡z\$ d=1FeY:Z؅$#rޯLw O08i/jDJhj1?z%Vuڸ0s&bҼćӶ0b֩XJ~I1 $M~g2?rIɽ\m/ Ho励!:q)v?Jߚ:|o!7#*3ni/6uVFWi^ZHwΉNnc`Kyz%SaB1L^YXmR6هfh e{hf~X|pBc;Nﯜ@ _2J A*"T=>?vy46LZ\͈K.dgwɳmRauUr=E%Y-iƯh+ب^e$rÉs2Zԥ?g. __æ-2T wr7,;1+z`vzŁ\|gaX>?׬2¸@<鷹rVVpA\Ga]b#xNϛ/DCtba2MޯjT|>;\(9\EDNw٫Vb<= ;j߁٢|XcΙ4%y Zרڟ^D;H+@ت˺+9"2n [3 A,t2G _6 ,;M\'5-w Ng*";kkv֣/H'T G>կXEI)!t,g~JkkCo/Ya̷cĿwAh<1R'HDAn_z通I,zon5n+;.(;;cɫk`a}!jER2*e6gK!aoٵBS;cU|uhK(y--e$"3g.7!VeΐY@+'s[wQ83$^rbҍoa-@Y3h ( ĉ ߆D -9D_s3u8UY/lV7/Lw#AHۇ֏qjSn*\4 g/#B$<B+x5U.YԨ 6]8c23tA%FQ {),w_BoRyY%[&ҥҺ.;* ~ˤ5,#%,gyaE{ |RZTA)+[;Oi]~Xp#\4D(F5cW x0mO&BpJAYKw] F;xzz?/]%2S*J$m͞|R5fhDE*cd$`( `!g""YDUT~η?m@\ Ǧ?D#b\CbŽVEFʇ7U敥veنjb}i𩲷\/5hN W aַ{ϋP/$D9gf>dthuIsf\F_^A5] s\_~gjSPԃ gĶ_շI%euޮ y…pSp* 1.fGQJΝ1Wita >`I$)mo;)cL!NoN/|; ) 7jH\ژ" Zj@SGtխ fG]CL b ^3.L Er2$ |,G,Տ|v8'kEQ,&`]}$6="y3tɂ.ِ~7`_|]1zk@pYi @GH0/P3&]YB"}tU[/.>u;>؆3u1a/hF"ZEo ĹdzO !|JdnbyַF;K \λuJU]Niu%_&w* UgJiʿrU-bb_~G{^U$5&A'f#( )|(#eaFnpm} 9!k.FJ7z'8Ub >+',KqQ^i}k=?nGe 8#}kԑv^@ k_[&<y+֪ho:g'ʳ;+ 3c l!jaN?u\|&1Pr.q?D yE$G&KD :|=&I?'` 1>G6^]XX5ƂpeTpKo+R2(pͣi/Die<.NjP',YKd[`ReNsX_&I_.OtWDpbߑhYW(qF]c0cv?Z/MvmmW6,K T n%S +(q]#v!bEH6od¾3z>^&|~X߸ Ḿu{ScgZa]*Ӏt!!\@+D%feȲ_p9$OfZB ! H,P~l^w/Wk/iuۑ_lvkvG߂׏GTN CJ36 dp Vxq!!/s?OE~{=[~d hg*Ԏ|>+.Ks3N W&eB%Q6w'}*r?ޮqXb1d÷MDz rx.3eLBTXر,aKTp]ӭ p Щ mo4.E]'jh@ `PM&Jb%骮C> ƸN[q<` 򎱰|Eczz'/kG(c(mtk9e֝`)wkeKʡ4vӜ{1fZ00}WG _ubɏ[J  Bs:|D?Dۚ2U+RG8 Ejor2Mj*ۂy<֨}ޅAUhƺR,v^ߙ1o} xVjE %M=s?ҸTdDj $FF^_}D\lC񝀂%"/Q!t3aݢ9As&"FZ7xW,7t\p[C (kXyo7"(_h>Ps>3)<8q)$~HhޠeO \#cr(!`MA<9&xXQ{nȠeK˻AYX[!3g!:/1ss]ã+'ou @*& Y[ DŽîSw',pSbk 2 V$yX iÂ\ځ8k_{Q=.} 1hnQ`@=rI&*6 +rI{78B 8q+oQ3s@ų̷_u@֢j`A03~}& q_ _e{?"$~pYgt]*Xho^g'ji 3e?z<$YFo52<8c 2C<I7bDb3[Hi΂6ڡB1JsR`A@Y!ɫ{x!D_W2yj:h xCdLju:rnUo_%rEIϲ@$Ia֐I* 齆K%$Us^7%f47"@qV3_ӲrV^F$5=v|-7HC8D -'  M!y) ˓]O}јuY@ER&haVPWP}#qqFRCqRȑ3`yrΔU$(LCeO-!rk79<(mkwr?p2 B_D|2'Jo}a^o0E55&"*N;)#2@t{ܯm͛r;5ՂcG1ZIJecK T,'mMZ#lw{Eټ]zTXoUvfAH`͝o+}$WDR@ҬSuz03FZGze=GX`&T퇸&eWer oG?*I@`+9"t{*5-O  s!$;W)MGo:1\ge]⭹E#Tor>DOI3#ez rRb\_C`ly$.+oorsv]C7?gwX:ɋ*IS$ўg_L#E:dVV5K(e ?O ǔr_,a@4'oT9VUzh]7g)yF] !Y{0)f8Ňe^G$M9vGif̥ S*NLt@̒*p +y+!ʖ2Xk' -ŎJ+}>IPE;1rgH_V$/j{-%BO=!؃~P F}8Ee욟LS(s#nm~^<̓dQȏpp5iFKV/ R=־(1D3ܗq!WD]=.hptZђqD% Vd+Dɿ~\2~^7p`޻jĬ*ʐp>N[P7F̙)fU߉y{2>c>5*oΡJjl> rl[(r|J]&ATE%#DĐfH-f>FS 7"L,B>0m E>"pH/jGR{w9!Tudn+ނDe @FUQ&g~sΗ+?,T}O^#$` ;i+BhGy9A+G=ݗqӏvQFY_k> 2\]I8Ng  \D8"I) H A'ǔ/tkgƴ,Gz̃;;,RKgl}&/{'_9]rxn]m,+Ƕ .kQ*w}~#£~MH 9[tTuoypS#Ms|H?"hFS}$g"IXYmdZ6e"!3y}IBi 57k{ZpzejZvQLT37JeR3k<^" n6ɋmNG𬤘lU̪.sRm~i0.eGܲ]PTGٺlp W0v}='e_ߤS|d)\s/[G:?v}n$RӭȑBlaaɍ@Z& %z"O͇cץ^ WD3G@_|ȅ9 M4sy aOvȢmy/UPA/'nDv>xXS|Yn_Y¶9`Wqh>S*g']V08.DP@R_$y{$^XbDϫϏ'=L}ʥ/a!̓LQ.N-mϏCYri6;7.x??WEԹh/ ƎWY3 I$<; cgɹoe:Ltw2"v4?N3UCdCRMon{{&Zsl1ϪX pLWig [3ݥjzKJX"~߃*ƣIu<\މ}?ʑsX|<ŴodV?J&-"an /`KEQ]n\  D!ej!hC'/kjvٱɝ(37&[jO45%oyYf0>jaؾ#?8#D''+t sՐ`1Cz5mS^n"]lOMʲ}(*¨ ʐW0ɭstKcdX9@w(닽'=﯎T)' @ 0H#< ~@zу!$JVDY)B֜YZ`-> N$~F>.?s%rndL3|C#)iOJ؇DF>wZ:A%iNk$\`waAȀ?qQy] kӈ(}"wa;@Q]},Hˇp-7x! C\kdΫ/qX`*X,SoUUEx -7$II^ _r瑄6h6*Jٶpk殇[ nP. '0,hѺT,$63BƄȭ ^ :R@?_|NCV~7N,G=J|BϋG~7Bij<`n~]%w>˕60ni+#{E[mϊܣ:# Sѡ*EZz Tҽ&A}C'?yQ!`cP6Ldc0ʝʯ}y4*=6vqWK]fPh⩇9 #h*i(ݶ!hJ6scSYzs>UW|-#핶@D*NEGZyB7C2AkP#lM*4-H,Eu.z"rs@mYH$ IQYun6a$ۑo~ZXy v/K3iGu/ C#)*+#%?/ZWg*=LxW4fҎkmqǜ:y#vF_~ֵ-LbU;h{v0_>A^$%]}UF[*T'^'D} o1 hx+|23_w5&3qtHf?9-?xGcJi@=Bݎ-D0Hà&vW!o)[Cŀ q .B*ž;"}.K_ZFfg7bGw_d H'#ޏk ?꠷/_f] 6/$ds-a㣹^IA K;0w 8h!auCGVH8sv2ȭ 24Q35cQ U~_rzqCВ8~A%P'Z A?' 6A. ช2\E04C!PgGER&T9V)Z!kxN'Ч(3}Uyw@YQ DB'ҹw6Jbl]Gko/zFo;Q >ƥ\j:RKLtD>v9?B|-=t!%x{ý=#}0(y`ӛcpZ(%J1 WPa,M|P"5HyC8pf~v|Ta;]o+ =&ILC}S$ {&2D|\(>ļL4il).VB_86g^)5 o!+{7a|lCe?F:"^4۳B;#>zcxߣl`AU9LVbNHiNA,vG00EáH ^I!tn ߴ'pON|hu=Zگko8x6>-V[>o[3Y_yR=dK$Ceт58PFn|+(''mc\& 3%-R{8^v&.oq6m0dúǣɫkPϳJRbKE|[׆=B? yq(m5>/r?6upsKGv(R ?V1L'IӂKHYJ ټD-p? yxi!5>Z˽)k-޸P(#ļ-1׊ی֠[#;Gf_" 1e˷=0(7GOaV4,9+UN |njA@(h>MsLj@+FwtߊoC G,ݽ>υF䁡3\;4y[g:&ܙ 61QNuQ! 3"D+)gF5cJNWFReXԙKV E)M$4Fs>w3q j!(R z$m4TxWD  LJ+$%=7Jwdt<{>'_]뫄q9r5n\'n퇒%(W1;D:KhLF8]yO>@(+  o!DHaQC5>Mn ERdZu̥;`$~>P1{txK0=҆G228۴|۰sȅ/x3J B;P[B@w5?_$}X74T CajBE "QIKW@˒M0tc(>=R{ZSXTe 9\%2̎Z>6K(j#"ećmH蘥/dź3GNxy!8&0͛WH &55% )I9xb*@jH s99(+CPmr >@a?F(%NKLQdR$˗aI<˘X'Zh!q=ɦ$#@jimJz{3,̋P[H9@k-6}d~DMG=ytKmeW)]5Qc{]7qZ| GII`U˰^l3zq!H̳PfGg}=(h QL8EF{3z] WKJQ#^$> ::(} `q}^'ͰPaeumϭ]\aKڙs#BxA ''-kiͶн#`(ꭜqFZT@Vl)ajN@V;5] yJt =G #_SJ|߇m&%!t3S3Lxe79Kǐ`"X-T@ǿMq&v}3-Wnm4ws*˰TJ)hY-zJXTXǜ|d:fԶB ,/2 /%5TU^h@ŧpF~cϬKcF)T^CX6oS· + ({Vfq(A \ꡁcczr-V&0^%{ZUsEO=W^oز.n{﷟mo,e0Qx+fhhTnmf FV{@LaJQ*Kz }'Bi Aǖ#!G4"U#xu~AAx٘JnJb؋\~; 5ߛ%??ro1SS!8>ZȨ$yHYXԂ9P, AJhy[O[/omז]]uPݠ^h[V'9F.^"ڂ F"e2^"&!1b;cP; ,}{!8QT`o<\Ӱ3F׼`NݚRďI~~d^ a$: rBE&-F(3-9Ps!hu ^4&:!gU=fFM,++5l~Gd)ȝۋbp[P!@BPm# DRqÌRx;WӖuI:FEX75"c@)NwFn 1~rr=(1K1@AsB8F"]PLJp| zwt=I'pqtgZ[ *sgYMlGv07ZV>c)dM$EgbS(|gd+#YQޑ%\ڒ1I\eYq\Bvu}Sˊa51rRѶ kUBQW)DhG[ڙPV]S%vr$m e73@mo6ك:M+aKp^EwaB;.'EΣ@}D x1.fH/kR~b|?OgRy{eɁ`;lπh{тBZT I\LLύۍʓdfeȴ>_y5)U,I/AAkIeCxDv?e֘t{"6 Bsn :fL{TAAqY Rό2;!L <x?[8 Ns9biNA<@ K.wEg捩Įk7$,{x$X]d#V4JnLfr՚Y`%M=^w`=4蝛Y#T C2  AT+z^&Rok kA"qTܯRa 491Ra kBZu|cu$M2^p ]ջwT hjG,f o@8C)h#񇚖rӮ*+Ut#&aS,H jk#NA&NA p<}P(̉l"K8(+1Ԥj㻑sз!AʿPYnգaEEl]2ͪ3% a'/|Yav{N!RA감V7Cd &[3Ex`@_"L+Órwp7/[ e$JP6)[GR:V+J`V%yBu'M(J"K/91:8u O|BU,naNF&3%8Fu톄+X-v$̿q:-.r?jksfxE_ۥy_UT7e&".rPAn*ǸmDewĘOjh7K4Z¯FaT (?}6&&)wqoJ+9hZrW'_9% mH4hƄ28sAAVyښXƣ5߀X9\%GܷdJ#l"D=cŌҋu_N2qK>dyhBLncVv rW 7jFT-Lb=<`W߹!qL>\68&- ^RB$ȍM@F*K nTQgɴ ^ Ae$+{-Oݤ{3FRjB˩MP <+n-Urn‹02gFm3zlWe朓bYj3R*qU_/YjGŸڤm}w ,@>|FHU8ś J-$S,Of&y_}]fwI71qFN0y@]Y(~>3):ƴbQϮQmf>s\cE\eʃ+ %!,Sc:$Pz(`g9cu\XGRz=F#ᆦA4: %9m0eymT0~=<j_3OL31@YbLM-}Z0nMvhM r-G9$bd%nQ@(CyNxp9AYw7o! OL >MOë>+c|6@Д;A̴? zW\w-7 ]y ïg0$"T=dKmiJ pbImH~VO[$Cj%g Cq\RݏSXo"f"4*8">RCʵEVzN@5@e|`R9cӎ!`2yj(C=K68GQ_Zy]GxƁV"V!Jo1B>uܙmn!\L_\L3v% (fpW7 C$ %yC_b4_h6~6d1fEaJ -^W\QW/Ǯ&2>bl%|77쥵s\?}`wQx6uGlN8K"4}ƹt.i?_ 35rfSىNVet@%5_{X9iqSdEAM  k*DK)=WqcUy[053eQGgo ©ח}e|]욟˲m"9 PNiB>c"1"p%nh7Iohp>U@kyLwm$(Sh4>"SdґuI; ;iHf,p?Z#Cv8fc͸l^63'bA6mMufN~{ÓI|1%$)h_ k'Jf^"V-2G2^.۩m Ӯ^=W׬tlk7q2C%]9nÈmd9j1^si#e#d,?JyjAg- ޛCNRo/p>Yxn^йZv6`{x]t"dM‰2@^iYXe$aR0OywE]K&lGP-Rkv8uK~$"F}u#b-r/߲)m]8>=ԓqeKw=7z{^ϗq% ( J2s)fF>R?X;>Z=y߾5Gefa*=ʵJjn}]]Oy/= =(L g5[Ylu_3,K+ѹ\dhZ͆vA3MuV?HXG?_CF@ۑjrp!Gnm1LJԩuX\؋SL\? 6ѐރ3q@"Gfai|FCi嫖);?Ļu6qYrӏ=eq?.k_^um 4ߟzW #_< 8=/?o/AOͱ9 ci>*;+ nZ;@ - n…( H[t4Ek)n tG`jΐ/s:_̕Jn^`;ueiھE0WDuCUi*j|j+dy]@mo0;d`e/n6{X_UTg{2>uU]n=gUn6yK)B8/ɲ^$I؇8MޒbPwHZ 7;&n-{,\=w.y͕pX/:Sm+ls_*W7naĎ~Ǿ-R[o̳,b:|Կrg=q?b'VA!9k,h`fi}#6waGֺJ=?%Ӭwvd23YψL>ˎV'a3ocVh`.|@o\U=/f?f lNYy9b\l9Ə}dř=|H<*5_EE|3xrb'c ƶAнU҂OΙGCShBCه>s]~-1@--[ '>U>@+ץL"*WykA$ U?E^0cfcͫ-E5,7.e)9c68Fʖ]$Fu?]}/{Stnvo0Q4`(͵jBԱfZX_^{>;i@2kM gek`ír7PonF m~ld ͜)R~\EkN8E(Ln2Zbjޕ`XZ MaT1[*;c QIw[? 4@nR\5{| Q&ީV.C==ZuoT3ViF  rߟLz9NaIJ~ѮU@T-|g`j1"=~ [l•- 5o,3lvu[>Bdu`7SM]$Cœ8il>ιRMZYc󤰤ZMJ Zn[;:Sj E >q<Bƌ1 ,][Zʏ.&ud3&~w_SlFm=+݋ Fn 7U%N]F{!0}͝0p[ѶE cP1[}yؿ7lū @a/-;~a4zr{a%k[hDR۲u-r<"T(a-W7^Ty ؆2|ڄCcU=Un"uRdR_@(rQALjt$JNBS }jc5yb4(8PQ}4j>ClߣQ.}0_-ҳʜ1M<(\^JLfQ4N^!N~h*Fkl,#0_J9!Hs=ZrkJ k;GUqk:{_2r#}cDN~y\͒e9eyHvpK* щ{ބU#ZZcH-d| 2볢ee_{7,1^eDojiˮB$bxMVU_:FP-Yu6Vl8MEDIyv$՞,^V_)9ʰg>U].&c8/zobva3BUP)PU؀*_Wo9߾U8:ZiADYʀ R}- w֔s)}v:yo787+4xs/63c~r+cam3JNNdG VJ\"2BS:Qa)?|ѭ"h GxUTadaJnc??&PbF{]CG:C^ݢ(eD#g 2B4,2/ݯ+FID쟲qHҀ&4mHPҳ!,'W=^?aB*&pKD+0ܯQ-á8# "Fb0)y%gub 0_BD͊͊%5=@y8?YSK-ˑM{Uٝ尩[B>.4ƛ>:1aX^G~+.`ړom{,}G:  x>.m@A>b`(ʔsUmuZ^T|j/DAPqߔmqJ @śa$,M6vѿ۷Bb\X Si)ZkBh oҗ"aTp jZ<׮y#`:N?t7=?eXħ$TT4^DxIvx2N~4IpC. v͡M0ONs;UU$//ayzXjXk=32&UF:qAUu!)l拒c2ns^雼ґ{ p#~3 ¤EomRf4+a1W-LʋQRiHh)xy}QLH Xz_0V \da>҃O9tvV{~M &^XUCF-qpFO狞Bp0!P}sWQo?)n_`PZx`"JXt=)mK8FpEi~\k{!6b #'X~8%8rO*o"~D:߮1}c1)<)ܔ/is*/3͇k7:> ZR7~AJ==4=h݁*UX'q3#\UNch G{'JcrW9K#L>*-YE JsO$7uW8zs-m>"o;ӃJȵ5 C 2Tl״#:ghVuIˆv)J\y?Y}`E(s S ZG/l3m ܏c!2)%SFC7r^`hQW̏FN3/t/NLlv8$Φev.%9|8b馰Cpj}(PR1?te/TAL}i[:6,V2g#( ufߜ[jpB>٫@" |! y62cCӟњuz<g hV-? += ˪8l>8WG:n7콁 `D( yyXp!h6J6D8 R0+^qg۷k^@i= ~(Ukլ͞T!f;d5Zlqk&k4+W>%J0vp:4$4[˭l87FFXBro1P~V 7q r_?V^z)vxiy"lx"nX>A ⃲ƻ:d8;/UHy4叐3+i$VĴs/^fLFP&_θr.>q0V#(>LSqu:@rVr_^Gn9vk.0ǹtc3zކ,ců{q;oeo8&oq1?حn}9v1b6Ud~\1#7Ǚ7"O 9B\\2_'ɀ/M]`e׫f|ek\kbvJԏi<1i[ΝVv[0х҃ K{T{^706kp9ݟdtm4{b OKusۛKą Ç+akcIe<s XwlE豼뉈c)}\6e׸I'ϥjqóLDJ%V"&#+:<uU۴# 13Irh'0H6a4f($;wڥw!ȃc:h/ƴ4"1"czݻ  n^zD}tyOљ+eβ7lΆϓu\Z1e M }]VnB!m /^jaj4P,1_afi {Eԇ8^fr^H & "/ӮYAH P!b#_eN\*BQiAm0>zgga($!v%iȳFn%`,p^&>I4 &E޴yJYc!˹`7r@F' ցrMLݎ($|-m2C$|,UE?vjP]͐/S~.LsJ"_ljG+H\]^K?KL[/"Dˏٿ&;&"0*Jӝ 5ݏ ZME`f, s^G\kQ٢%k꘿>֎aQVMBHCvt5TRil2 ( S,0K'LJ A-'x PL@ODNoy;XBJذ㌹쓎e̊d21{;02=wїvl7`]% ;Ҏ'%Z$`&̫uARa$LflE<}Dd& ß5;nb|G;=rIH;8'g<|[ ;@'=ܙhT=M!5Z\#:ӓ3N.\p=kW] +1fմ$_0H';732[:'C9\S:@sΈUxJA*PZvOw'191Y/>!_E4بM Չ $F^ M,M%S@vO2y p#W䀤GgX"C2ruh0T8iK"d)n]{!>4[s/T&l\05g @a!0M?#l%Q6~a,w8]?iX9K>HmJe%]?ڦ>f..qNT ˩Q>:ݹtTl#/%gt3-:? \SaR9C+>xi_zqD{$f[2Hs&*CNZܸ =I2'<\Ni(O~ x9\xCvahքFjUhߢE/^:teJr\2飯DF^0m "&doÞg!/_bXyC^D/W#|ʿ$-z(fd0{Hn:Q}#k2$wӿ)ӱq Ammp>;$'/7!Ng7#zd0uܿeH2j x?{{+n߰Bb$?aor_M0|kyY򭌿uOی;JHW_ ]&\1.wFZ5E1"?VK6'ы|CFV釣NZ\`kf"ggY$bA5j0R]LUwM?m$q{j5;"ax!,D?/> T75xTqIK?ft x=*%Y~-$HUȇ]|XOOUI\dXӸ Z7MG_ zŐ=_oH5 y9UۚEvY~Z=Ցmаq ;z#.'٭Vn62eӥp|)ɪYMy|ʧmVԪg`5D*@WBJ>lN!ebpGXYBȹ#ݽ94lX-5>JHp:ԟ|l?f.lN e-Bbwg=z:F=gLe@U.[GC}C`K ZRd$xN&أ Gcբ/_%$_PA#-W`?YKx4EA{,şSGѫ(~~KUN2(R|#ʲ\7ifO_{_]$G2@XZ<<,˪ssz~ I]7VЯm R=:4W-ihſh,Z!7q'|հcu_{ ))!lZ+,eNJ# P +P2z"(t{kQMb;m{4>GFQXGm,,5x?3.^gTS g|4}Gm;o#^y+2XK<E*zWJZuPO;D- n`-Y!kU=6y@h7ŨN/h\Xدⓩ^3-Ov_OUXCt)8K#ʄ L9q [FOӣGӄ9ĝ: 7С _Έ΃k?[x <|lr;B-rjӓ<φ. # cF!ofL[l cS~6cC`vu}S =? )t8H.B؞=.yMgB߃jE ]ߗe"p굱l՜T6BSfCeRrCQo7i!7EmW:^^_]>j >|@+qIjE홽3s4 4t[:1Yo vC)8^kƢplUtH%Yv00Uc͹^'6C?S G+[vlK7W}rҘ8chٌ~;]JMSOw~C|N4)DJc[$#y$M#k3! bj.AC!$vyDϜQL{#e -blCc5׫<@} v=bNǣ?ve ɛTߺnn&9}:u0ڪŔ$j3/qsdU=1ŴyhSeG{|TJc2}G-tF;OrTYldcq%3s1eh6J6zo5̣@n2E̴Mʱ2[Cp`9ɽҕSiXu$a7(G?y:o_}9 rwxUtG3E8CH_߽WL&t g9nh@BZ~>w/O}|NUZr˝ܻ|1e=>w w0>abZj@|\=|0OMPw8_amɏ&S֓E6wMuzkUPYIl_.ҸH8VFCزؽ:C椱6*1yOj~|o{&vYEEUE`> X''=ӇWꈯwsO63>^z =_twqټ%|~~5cU 5U_%f5m=g=>ܤ&(G^&T]Vw:Հۻoo`Fu`^/M޲`ے^SqhpT5pMֈ9Xax-;s<' ogYx*Kt]1[`[ByVN۬LhlGFEAC,a3+!5j]V&ֻz (tθީh38fZy) 8#k@[>C#%x+Nr~hb8wUQ:.EstFIm;Z s, Ho!f*X_{ 0lT u#lAtv@ '*n8pO0Ja~JйU,M~.1-^M˾Qkd?Q0fD"v~H>Z%UB:ҞExcBv= P/ 8AfF9f9V~M.T!ǔvʦn䇃ٮi>,ȞzWφjq::Tek.컸 wn)\rwyJ?(80B΁aLmOԼ4˒w~5 pX]lMnMl}~p/.^(4QIҡ+JFJLOSL9m+"h{U(;u-s4mB} T@o Rvb{~(wմykLVf=~r4!r._*7i~sIPrpZs+ؔwQ*?yEMk4=^N%=uџ<բS2rCf5K1$+ILx5 _sTxnx~ ۼZ/cx:X ͢w1w7n 6fr v;iݱg~ĿsoU5$T77%Sy]GiPp\+.'zP>2E: OC$^5y%~*:(M DJ<{p;BOYQҊ5DJ%+#*x3?ucDCVH8f_8ל)|H%ev^@;riƺVaO'$*fiI<5m+֥W1zLEr$$/ν{TW u ̾ϒprAl~s|I^ zˣh Al2ڋ$L$5;㷱Z&>?gex "XatY6G=Z>_wScDVK +ȦÓx|)RJTAz1&.cU$,oόD^;l/8wV!O}|Z8q_8\~k`*@RcG,~L]\c5%O1/Z|S}zj՗+̋8"[,IE;KBU?`-D.y#B\xaQb>^ 2S;ϛJRH^/v<5s1r&䋊#?IjSyư(!Z$GRmrYpk@"]/VJՁ IAk[k` c_uOHKze8;T2#*4M{\,⽱!q'd֙<0)mn+F@p-9 b_NѺ|$15$(Jx"H *uƇ Q:ECvwYƶ(mb˿)#B7 ^ک[~|' dE蓈 5SPl=:*I;Ѥ1-waкdT)~ r. S@-./ "}oHOl_M^\[(kA-۹[0+!ǡGVw!(kX8،A4ˋ7m /u0^>J Rhv񜰮^FA%8IozAptp[lMVƐxvleēP@R8 !=΀$Nn V0jc\3F05?\Ia ϙބqUΑ/b?_uBooHD4_[jd͜AM߿(bM[-bḰzrB?2 G;R ^\ Ŕbgʹ!` fdQniKwYobusBT W_+-5+MT@ x)~G'Y|(uI*_'IEQ#CF/ 6F GBKy̐z2eq_^t4Lc!p@[~!nGeJ"]vfsd7m!DRcVdZ}"C+QI Hy7_uSƏblcpǭrbq>搥rIM r>4"\}.F4Y;iŧ_X>#K?pB?sѳĺ dп,`jAlо2uj?O#Tgͳg@7eEE}x>kjwf,:l{&3VEl{!bD,i^䳰U5M < qݝPwl#'^L o}Rxz{,3 +0 cK/(#{$jbՏEi]뢨JGp[\b 9Ekh?t6T QAQHcʹgwh6m9k趿PL忮BYr&ד,xz𐵮Rl.eÅJ9<Ċcԩ(#E qa }{f>Cf$)LDl3zMuR*dki5U;E.e6K^Ƥ`?1/m?bw jS7Ms+NjیF!DRXq4'a)XG- S"6D6 .t6G=bKV+( KrDm ?l=tEKHf+#p+f܌Ab2Z 믙fkҟM?BYX7bq\ j}͈t?l9haCWz^n:n?Q[ C[K_6V2sYGtr9 O}`)%bcrc%"2J  .{:%ɚ3gbU3qţY~7OD 5,Tyy/*Gԗmm9q?uKN"6=9 % M D񭲳{uU^s&MS|u'Z!!IamZ*>钕3VŠw"տ@G3m*EKZܺ\L jHλG2E5r>Y/QucHf=FqӾ ,~2??mķNHH@p;4Ϯʛ.vqz_Kvbc<~hOH&u%_);ܯXklfPЌ,7]#$&j+A^| r~bH)9qjmW.FD{FOMs%9Y>j9#n3︣j2o* 3wC)Xzˁc{ʐ/Lߗ¦cB)5T)W*iv`5nZ(jF&`]w3 54b0Z5Kߘw 7 qTi؛CȢzϣf)a4!ujW3[s/_Rw](wktQRo|?vBh(g 540pT$1Xx4 +[/s~q݆;iyލQkfڿM漚a[C76\&&xoi8T"e##zqmu:Y >S}Fq 3OY;+&a@ڎ-tF?UQs~׈\:`}(NM3^SGrClMލ `˃-ն䄆5fpdy|*moQRDFKKdA `IcP]5bkp[1}k:eЀ5띢W)GSݔoJ6uzAjܐ 싗h5A;4z"^;Z@"~ini;p\u24X[oSf ބ>(Yg ڐ>e LL*ϒPpg{5:Ҽ  ^ˢ~Rw~"Ѷ:rNY2iQ&xTЎa3N)" @oD%EE;M:v_qD BFă<2#Op + 9BӰ fQVصwb'ef|*"疞KqE>7<[RJJE4bo9NI=7tB4= uv ?.'TRmĎp&w'Vep~}=HGmDR3^1̏熲y4>*G <Boѽɩx-* Uz3ؽ1w})Z$+7cWξʗ Tn_Uͺa"4G6Xͮv:]} ƒ i|`aCi.9h]lY?P$*>M@k,+e8t˷F=9K~T*VqխUcqBV5_ f{<Ѻ :ޢKL%RR Z8zjmJB{Ł!k^.(y?z1M0=whR8,:uOIy&1h1AExx?oѿo|{bH@[`窴J3wi+yuq2X3)~IlEag[OMNkE'}nL G^W2 וqH+MFt͔T#odxg4 ^p<wO~_Aܵ4 B#-Nǵn{0Hk5G=L1rGg)ae;~|x ڑ GWS80jf'? 2ހW|kb1"K. 0xCE8W ia['} 5{Bw5d;T积t#i/{)v$@eNXlN FJ"@*HQdvNS47}&VeM:(:0b{+)aiڕAXwTle]Фdq-_fso[jRTW?ڨlf/rJ.hi6r-|i~*ӔF-ѹz2k'buG9[<]f}'yi?%PѬzsNfƌW/[%8QDC͋8]+)k*,bxp28_)*U&'wke`p.u xQs_3PȱOtHCyJ]dji̼kWPR5X@N W٥'vE!ytE~r fC>c3~ 4ߛrAwYo)P]/P C"LW+Mi0%Ð-`\ҙTj*jr+p*1w6R݀ [q_+ۖ7nX 3RZWrPEyoJ8NkTFxxsUݱVCGc-t(q_ȸJjfrf ;Hh=1CEyot'/i@̂^7vT y8gGngPkb$XR~ϡT(ZyO w휏įTԴjU%}4 [wkvC/6uˍJbbp:xٍ~־UuNP,CCY*h`9Tzre|}a9SX~/nfRyd ]OaishNj.qo'5tDO…xZCDo45ws o+| b]k**mI$@Oآ_1e#s?{omZx+׿'۪">g֦qq7O}p +mU= S #&]ԙryv` *m"Ypn0#\q =w "[9Nj5kܗ%yg/ >+&+}&s)^?SuKm~%$(82WB.n`$Da@ z3 XTT؂VtlJc3W~T? \%x}w6ٿw#)++6mRwc+Zr$%}7mH? >$INԽnL !0x|4H?f?Gy\K9Ix}!{7 At 999'gُOOU& WٌdW ;/ ,( zvvț$^.^>$"Zv̓E "VB[<4' YE8㈎^ O!OQq$ATzw6ULΞPG'ۀ,YBg 9Gտ^9vߣgݿ>WLvE_yGuPMr1\z3/򃔄W[,(=YLH$*$D >֘ h#{20:$HR⫳!m0y%dzvԋ5`FAL"t'.;m 2]`pk ^|΢<$1О!߮?>xm"atM.bD"X({H,!dW @USHtL ^}%u" u)thiH?@%'':Ek' 9óq"gb_dj3'~6bxј7f4|w12拗?7Nm()aϧ2FHzg\-RS+wNڞղ6:YI\sjLt])\(2!|Q-%Y*.eF[5>ck=6"Nfub5r ( kx6̓ox iVGv3i:(\Ǟϗn”\zGzWO{v?DOSee [`)&>KO F=O8aO(C<*M(I,@6jcU x% 0vnqV [ѸěOzp|Ơpj\ZgE^S?d?xRʗ:25FWZ+kZq鐣%4<&jk0|4.,1P//_V`J`s'^ WBPa=t>]Ex'T qleIU13BrP%~R ?rU&ڌ7`rGS@f)= &m\*!rUc.s/wXl*zLMcu2|bla->u^XPji[Թa]My%:(p=5P W^@Mh㸜.jʺ>F=,eߜ d0+zR.3NѱVo!t0Hi,8ђvnO;qɲNk'>ɗ>.w.-[|i8J 5.[E|Cl%-Γ j"-'ǜn轠dY4Yhvx zó>}f/2`xcFor+ Փ_17.oӥXqa!- w=]X-;fYJpu!e1ZJͻ4շVu\!:f}:[_E3k:)} rlUQ;!¥3ۙfUx1.8*S\|H%hKbWoN">Jk *sR{.#4Jk&eT"2<#aS.)(b%%4 V6|[П '5bnqG%zk7L؀eZjV9)poǏVNiSv'ΐ@K[3 . ՌjV(AA@PW55#W٥,ARU*\DMt (,vtƅ|*EMǛ"a5}qm[Y vUH5~-B`R\(v7m.&W0 9W|isxhf.ƶeJy8Luq(f@fGFC2a C1]Cj][0oX1D8aї?вẐ<[='"sm`V Z#M긌VℱPZ`UwMwg2lhzYgr3-6P6X.XNqw ݤh_fCvE#{]]^hd ǎa7-[嬦?99gUAU[ȴ)"> \|M]Un#9J:R{E3kجY*%}sk'FCxØE!Xvٴ:?g\lNENp*E%=8/d"iTT\oW>Ƨ֯CF<./  ھ zuUAц:nK༣ĿT^..]\QIhpiº@B`y".w…gg[H%ȀD&\zL%"89 Ox5_Ki$j.4Qvvّx# d݀SrMY6zIHuSǀ"DƋ=f71mw\W{ l܅K#_BƓ!#F燙a}<,kh,ŒxiRTwavÆ{VYK@s!0MIKBP5E{C&kVBiKjd W)͹8u"Wfi`bbtg98Ӊn J05õHnVӦo2FSƣO|xPQ"|2$VMp]i ɢJak OY5+4!(|O1:Β:1fa7W!w ϭjMQN݄>uÔj&([>m˂ސSՁ;:OTtpWɯ} uuL+13xE L.أPvb~|,݆$lZ-ۑBMNx1sN#%dpVHYi054QU_誌ػѻѨ6;C\>ه.\bwf$pɰxt` DHc~fz в0"pph5Uh0u@.3t ޸<vPpG:@Kt{V'#dkiiUv{e'V[˷Qp"» Vk_݄ ~.KJ=Ea`(\ QV@|T0@D}xN\y4<\k8<+2ئf)6ۣ!/RFA dbdO7Hak@ [A5|Nh=ão}x {ybixoNKTEQQ+R5]L'^?B; Nw_`\q]rID>OZZ#B:** =iHN]$Ht GhҀ'>cJ0[m-髲娄-E,(*aB^ņuh48o\_q9Pf.޲m[UT`Qbêz.oܤRϚW\%ӆًl *G*(g/Yx={^LJWPQ_+A u^;;Ђ&+oڃc>LaE.ac5/Q{5:-7Q@(+^|.'m4.iVTvC6 sdž1`q͸* KXlE5L%ʳU'Mťcj`UHOUaRz H0#^ (kf_VHqJAKozVw]~5|E;Aov]DWG7o+R{[g#)0>7%,+rOdeq`[ʜ 3XOj3z^Zz?ڄ/X[тeߪZeJ wSrz[aZ,/g\E|i gҩZĿ-owڽ<6Z?_ےS,Iy[&%i: _|Z}6D$"%U9jfVFࣲRh'}9CEEΓ+NFYp^.";& wm Mc~:xNWDrP̭hg^|Ceۣ!h]tzήVMj#иzP$}9ѯ $dcDQ躒{r- WF@?HUм + WРm_U ۘ1z;WwɃ{w2_ m n'T_H;:R9qOijS~5/zd4hX!up%Ξ+PmzͫwES>9RRLq8RL k1̒lGHűE\P9ͭ0[5%F#^*%JJh+R ĮjEcy6ˌ r2V'ꍊ8D|kϟQ=aj@ͅzSa !Op![]+mIKxǺ&V J)'q e.kX rӖOڠ Ez]R`!o=W-{ O /XӰwpw-#n VBxj)\@ׯ q0[t#J]DсєE̪nLhBE`範]&ye%C_Fg?z䮏c"&ɥ?ʧdmn.okj[j{;Dpg7ZPN?[36! "‘^~cAk`B)(/U1ђrJJRDc"NX*#.ȉEVݩ!4PQZM+jWX" ܤߢjƗ&t)Ʈ4\k Z?MUW{Zz.nC/#p.9Akn(N«VH"0I5!t:]{5l>]^]եXyAU4@,nD&y 2# 2P0UhGwS!OC)l_GJsDO"55Tw#ߥg/$b4|$;:217jllEF mPЏROZ?^0?Za7Z6fW?ay+Q]}ˆ0_DDzRr,[ Mk떝s$lp\&U'.X%CSn@4<ԨM9maaզڕc ,,6-`p^(~?$Oa~.ԏAd|wV՟ݡWՂPKWN! gJ!oZB\!Yu?YJhvOnPwPJnJPc>/-2#f}XHsL*Wvzør|nǹNb. %*`|U\WLLM\NhZ-@S4{!NLË7K(%) u)] 0aM#k(l9SFE U,o<цbzuFhCG+>CN zX?g~XxW>q=`|+GAeN5L3TYm1"^G&\B%6hZm6m6mж۠m h4.P Ѵl#Ԥ_mW @:.  oc-y3Jγ\u^iw+Vxg6HJ>%xG}CgoؗnĿHe/BB.0H*FV⑝K zw} C4pX3Ō`杝|Q-ɲhd -[ nQ6}ڲmw_ы [7BevMi* Xv-s"aAAрFT(H} M`KE2H{ZL 6|]\PDdS/m, 9Ǵ mAN; cE|Յ{Y|~Nn 7Ax up˖7c:>6@Y%\<@u)Ds^5}`;K3XP|0Hi1]GV,DqDȟ-im_CM̼#Nj5SV)?/4% IuCr<$Itjb0AޢͲ[iZ#mK6(!5)>KjM&kkʞQ gΰx7\8kJę {O6ˀWL0Y[ )-ftmftȿy /OKh9? 1=ע GFpW+v,eʷ^zw'/SMO0OTmkY%w\bRCLnMlQuK4*XBѸG0-ni; fF62~,^trΎǔ Jit)R65)-e+4)+ԦS ,gٝ:SФ:aThx>:돚TlH sJ򓼐$R3bH):l n& >$O˷uݼ,uMl| 1Q Է.G \%⺿WM Y'Z)/,YEGyΕ22Y̑V9%Q5 ])o clcʩ51yi 8 bnh@*X<_[ICI{\{-I)荄mb#؆18e>*0%7q1\Ii hԵҪ3}8t@p:*Jߛ& kzUxy4 tw!zg~DCfx2R;|oѦj$XA2Mp%xMs0 W^vMC1mvcҋ`l PZk},K`fkq,Y ̞ jcfl~2w>ޒښ&`ex7>{U?bѨEJrqP@]  :,hCc:1wwTbb 9]!9XU&aXKDE/>CT:b|…C|ξTtZ2.uBB1%ohFr9:EZfI5l2?;`%Yn_69L^?%Ϟ&{'RܫQ>eä.b&ìAq1If'P'ٮ2?g AyHd}*5;FI} b\O [MA~ `|8OZ!`O>G P/5<(v%dV!鯈Jg@Y9ɒĀ>r\6m>-7nҬd2y,BH@M&0( &[O"e5y2'Dq 'CNg:} ՟؛:p$Sk< =^oeZg-3w/9q l MQ^ĵt8ܡwq=OYoe5׶GYvZ W, Ut1lͪAOD~pAiUfM5 ]v$4Gl8+jo1aAS~3)I(Al["xMf7ڛ(l2ca%O6It?{]+ʣ9O'g Q`gJ0j?`{2XY,F7^ }.F/yvM;uRI~L Ms?_Zg1qV% zì/ ~k%B_>j|G#@xN+`k LD UVuNL6ۺSX CI h$=aqP">;P}AΤ#`TCK>/zW$ÿ BIv8beMp ThZPWٙUu1&A QuZl8yaE @}h4|vY58qzfFqVջ^>kbuqٴ( ugV[n2 I!Y~Zc>Y6iz{GԨqZOgcNGy61cۡn%%'ieߕz,]1~]Z!l,+/ڽU8ȥުSQL,6:5@PlvAx O4 wfg9X`JMYYEq2%Ͳ~SжT!vɈӷ:~1pZ:%?dM" Q"_ D*$jDv` z=Βf9a9[yCPʥ nwB5Mxwf@P^gɞb{=+~oC̲dگ< vj{,f4d:LQBRhPɁrG6U!,RՉ j2{þ=oT FEO|Ȉ>t^H[{hE.qGM$=Xujˈu*b@n|/P(? yŕ)Ɏf& [S#eZj!S̀Q;..K_ћZ[.0HVJfqo.([cW&v C܋h-9GU㧴mxeBl%fJD6PZ#mj l;;A7*:Yx q+9F2xApwo7gXxDg厘`|k*gJ~d2QkF d6"\;®Vi(ܻ!ŐD4Lc]L@8fJ/x#*<.> \u5z5(l73V^:dS@ֻ (P(^ɚjegep` ({?R\XQhw/4H q8spw*ɪ5J ܚf1#X&*o^t8-0φ)5skfm1 YjSU 騸̲žq<U Ҟ=(G(;:̓J<m4L&u69x69-(}PXG?8ɇ,s%O}".;=tv#|z}@&ϴ9B%+t樒r(SjVVSع%.u>w|dw^J~(tʵiU7bG l"hxUd oj5^6kqyBhڀ%m##/EmDL?PBy4ΰ^ ђ:.}!ɵ$1 ?|FډwWpn-Ai8ʃW0%`?,Ʒ< 0uݪ"y\j2*&gǰAY"T'<'.\d@ bѯf!b2L}|ǧg!Tu: _:~G M='kF&f-?$rhd U'j̨Ĩ!7lYWLO?EJ7_א>j nS[Ij6e_m $Ƽva!ABYM&6z.rXCcsMUf&X)G ˻)GI;P`4hu})6 2#Y1ih ?4ZVϲ9(ur3Vᇻw5eĄa`'O96طWб . 3Ǹ*,,q[l-p U鴯NLl\SjO?z?#`Z!Q>0V~{~[C ۞Yv˷@~!aBX7gRݼ. tx>4WU&O9ՊC2M/k>@m*sZ>8ujV n2.`Ia}.@Ɓr(DKig 6q>όZ ފ9)&*4 ~7Q2Fs%IiC V*c (l0KCoVz+\E6g=yjrV&xG$響}uA qoĪ(4%31Cr* לbY%BgP6IVcUѠk,tjhHH[۽5Bu3yfq|es'2.g_<)>oFҒ=/v~a_c[Xy?Ѝ7r٬0}KN,:Ņ?0c0q˸%q/K>0jsKk▬zk9II %Ǡuu+Q| fp*I;סhn^U8 A!^6Ev6oQVYD3k:YF˺p@U3\T/Kd-531k"'OeV3\.uzӱL}ZwB-Go w=HAvvQN@Ŧ=( (gDbτi;cvnߕ1TN8׮f~F"܌!n,t)3`18a, MNqW8v4ooǮ(}E@=g$a^$*-!*ǜ" /60^%n0ސn?\'kgJ|1>/ḓ66e*PgpIcw`y1M~w=d\\VbBj6Ma5S]I1bHnixA>J5%HumrCSm"́WJN٨HRqz߄WX<='(`wzkODCO0vh ӟx),<Klт#;"mE4g㓬lV>l.ӵX \--pùZ,`49&uMXʍ c\!nWs4Z&ڕ"])-;#---C$$ (ʷ/Jma *0@**@ںå؉[=knV\.K,e`\\rU'Hj6hPÔ0Cu!ڎ"SnǏ1UW bytOxXOUyj恗bʋz^ΘW tBVvd7(O.וb1m~ەn3Nw3iWQj3<-J%)lPSRr&Inx9,ɶ{+glt*>-XH:OνUbFfӉQgٺ{R=ԱxQ(V~WQC׫ttG%Żwg j*pu.-ekɈ6g-^QȽ_rS΢#"JGxk;EtR<Nj.$X\y«;X Y C@_0p&jD"Y(L~GL^3Վ'oi64͠p8: 2B3'YbOA{]!_ ӑ ؠ)@Ε԰/*}j\˴Mqu{}!ye䡗]˛ԗt.u7<66D20෵+v]cMXOz5>0n!|sZw֩pԺ߯Y;l;m|^5̑IG3q/ᷫɺv[V&ciK맠hZmu!ȶ4 :/:x\Zn6x,[+TwuMe-RQljaYj&d%x)"c e\w){wWП~u&sVzj52;!㪆+t+5/c(GSL.Ec&;bt&Ʋ-YnCvfaIr:!t^\yE >>&Yf͡_H67/@̶]c6X6W[)B50T=v~UԻL:sIjM6hv֍RDJ~o|UUsݵm*ۦaKwn3!O 0cV?rGۯP=dhtaJ݈֞"/b%u#%7ѱ+hd7IqI/d#t  [SoYZ7l.a Bc*kL."B˵d[>K`VctQYEubljwfk_zFokFXTj#@Dp[sxWG蟘uEu389;"xq6>fWDDnmڒ},=b 2NYIg-n J.fPlIןh'JlFcє\j2Bpqz̒=+Z ` ^kJl_S xOw߀s#ߺ򆡇/򅝬ˉ21v|UtVKS:㖃r辱S691L">iL^JZI]ZybN~{<}o<ٵW"fprVaj0C:$ظG9Z\L+J=m:CB{sJmzIoJlǥ+.c:&6fx'vxyՀ<"7V yS-xs"Oj sk%Ed=9k=D jP 3qiS}`*b–ڄb[Y gUUۖv(kݝR-U'\E1U5;ikR&UP)MJ#02δ^wMݪk8}޲ seoÀxMUbTw@ub]TEB*UI13>+va`fnNҤ$F&Bz,4b. ={Y=8džٱX Xcm,% ub"V>ijkgyPW'߷BO2'YO[UWFPoX澋)':Ӆ31뼮,p^\Xj˽G ~%'6vR SwQS1E7jmb+2y&` ^-)dŦp5ޔȋmݼάO* -F톏<[gkӜQl1+uo> c_Gʧ.)Tq{ 0`tFΥ(j.>T:)ﱓ^^w;&C];#&jn@'JAQ"CjGOl~ ,b"ěۋX4[toGƳttRRpSV(屻hq=vE>aT0YQ 4h0|R+Iԃsh;N, *ƀ|5Q KR%7ZdQPwrrD[>#5\ CGAw5t`33pOȵR`ପA"v-bZ5(Ksh8ټ5Ƨap}YSk+?DmxQBVpa4qt6e`pµnH|~K_ Iuؒ{Jfu78kyօ۠ҡ1(?|6|cշQBY4|;x[ZB efNRbGv@ή;ZD\oPOf#K\yQ~ wۚ\ƶ!/w,rn.YrVt%[@>bk[-T1xN. wкĝɤE 9;1Sa'AG3ga/afmfV6cEl)&:'W޻S'HlmT ',AU|/Ŋj&N׼KͶyQzL;_νHݲЏUeDac_҃mp:c}&IL;?vGG{ 1`8Z)Dr5ؑċtg1+=jZӇ^ܼWVPNp1E ^k wp$-៰18740~!!?슇h8Od@A"'(A@,'z&Ѵa 60aaD9( J|KSy$q(2-A,@McdqW Х&-! =m͘Odu"jNѨQ8\FJz^)([l5"Ki'8Mm8gG˕ފQ1PA5G>6i(j$ӔoncDڻ6 6k$wv]M>Yy|A?ǐ;CfCC>!&Y,)XX9 '0P1ElYwV,lis.zM~Vu?PL=l6IZrrt.9\MwUjJWqWnF'Ikm$PP[*h<m`Q`]Ѭ ䷫Zuǐo TZM5⁛Thtd5j@zq*a{xelGuټc}^(/lrXM( :_Bw\FH֝&AmHzF)}݃6Txvx%9AR2'ij⻹h1O"w 'F~Xhp!8\R[JEUsY'<7,W˖G(D֬hL]w:s͇[ c2N싋3t.8AKeN8$*K;,PYKYVSޢ!N1$*iF]8`WnB;7KqIl4{պ-N  ݾ˗3ѳ:͖s$Ư紟ϯY_OΦd=yçP 4O$kn}ZN~r~?[/H{婷|Ja=B>LmPjy9fONM=4~EvՎ{T:9TVq,&y *5Ih"(ׯ7"(fF4Xw!^Rϋ/zN[ճiR_[X,\{ՆZ9X`[uv=cM{PR)=*?uiA܃o,+3PJ*zB(];mG |Ov*RGA~Dw(}gqTYd@:Oj$] d50Gk2IT+I'ڭ# :Fwcށ8@Q"X:g+|3-A])5Nl"E%\֐NE0f1;ժfyh"Daz!v* ]d0(^S8p`qE8iv7UQRVNJ:}mq8{}{J`B&Q *P vN}>CaY=8dž$İ*NX x dI 2`xXLٸ>l^$/6|f`Z'U;M)`|\Z3W^rDi9:i&1+EDjJ7)|iUFhct7A+n#Rlb/fn=<9+/E.ctZjeٔYJ &hZNB4PO:~Sl=#O9SW i|H#l:H'%^T 1a',vCІIyo1C+ @rBH^uҹ\'e蟰[@mo貘-@#:C] zϽgZY[b[ uKUkR'.𴑸 e4 o}5^m%JI L|I=adl|r/`lܩ=ʃxǁ9"͑T`(2h n%`wSez=>˽榲9&F'X Kԫ e|Ÿ%-/pq:_PQ㳽W([k;m˘ISm-˕VX/˵$;,j{R$sԁ/P@!IM`| a-Χ1Ӵ>'}uXu'hǤ7$l}c X *; $f0R)N>n4+6YX!g!$C€ -gӷnnb [yZq}6P"zy} /t!+fTA1" <%%|-OSkK6p" lG= h=XJUU^t:)r6X4i~E,p{z<%_4{ 6ɽ݇lh[0J&x}vz0BD5wHhz6 hf1؀GaGܴ;R.ޑ#(ypG!IT;'VxD"xD6-+#Ewf gW F]īL=דXgr!ؑCv0SЎm>uuY( -"dsL2,) cAD#qLӺyrWq=X3o׫\l'l -7{"N俼O*IZIaxZЮ712DK)^JMְZLikjJ[ӎoNSE3!YYV\v m 0y7o6 8OʧbiXlR6=RJVkyhVyh\C+bxk}sq 2^\ѥ'L^Yˡ,_ђ$_+,Z|y+,_^a :Vo* g,YϜWos nsi?Wy*%/R_Q(X>5"`bnêZʀ:[Uf)KBtN`! f5< 0CN`wn4"|l2wlDuexsۻŧ; Z\xF=y8?)lκ;֜_7sh$fn-:3MQDg @Ii**r9RTƈ7yN0bnJZXx-1d Ј#'3*5FIzZTX),xM^אw<@ H"z@؛ 5N_ []NǣeX{u}"Gf8(X2?R]f:5B ^{ ٵl-~dq_zR7=ˮYmm]˴#In/M8KmA0sߓHFV«-F5 w |XY-C@&6BǁD;p9|5p. W *jZ>y5LG2DC {f9WͅX$[իKrnqȋ_<2Gd]f(V;Q/6\N>QZ >U6{bD6{]7SV* bsht5\lM=֟|odg5}E>F%dgٞlVRAUBӆmѕތ<^WP%Ll7g~מYeVBs O7\{&#|\1||i/9+m?9,<=I[o Ho|`S޼4qbL8͛u$F`'-ӓ#UeSNCo0dөVDwQ# مIٕ]VGy2EP<*c,cκfMFVz#~th?+^IU\2&Uې67MHo!7!W|y7s8*!=o>>?T[3 %!oSp]o,2hr\8pܻe3ss9ܫR[]BF߰3G¬4ȴuq֑ӗvhw&Xc{o7D-H@;hn[rZx{p{ Jbfӵtm̧m[:t aIs&5n^kaľ>L#'+*ohߺ&Kb/š--#?꫱t,ޮ0/HVЅ/o'YPk "tF'ܞVow-߭E9ބ^(!L+]DF8Dnyxt! O4ڢ+lͳ;d֜l dކb؝#V]CW7\jH#.Y8z"FZS?Q2/"4Emh=4'U|e=4w ayxͦPÆx^uH[.Wrf]^w08lqkJˈ؎ϾkԻV@]{ۧ-wd|26)&%SeG-uj}K7HI꿒K[ú /*c_S^ N1 IQSڹ&rgX8CRtz!#CY~1DkqQ9ʕ5dc;:׏`YwjЋS$?3>J? 6X [:}'{'wt|ԗYoЙҪJs+,$/Zc1Sf8813aKP/9H#`H"E> Ye&1'q}"3 9.{M8j4Gԏ: =q g'9Ls=r BYryV!dMsU<7͟KH wZ5Y=X/1AY`R6`#T4`"K1(~1Q]{8ȸ E}X"6LFDiC ?edqA +;߻VF7>kK#z,fMVe4ށvz6uCCmڂ~پ"f9hXynM/ۉ$+6X;k7iͯe4{'%Q;r~OB:Nh1x7.a,G.@Q! .Հ :_ lJF{'Mh'׏7ұQØO~QAw"}A[Z}{*^ϫѿn'kW [XDy+Gd6Q8PMf,ABʂ#ar8 IXgQf9}`55uM ۬eW44A,qr,eEi ju5{ia`j40bfn7lt{/m5XPHc1a;V S]fk@c٨i0K #ւ7&8cRD޻-[U6]ˇ{+:So6RRgȯLS܏'2BFi?UPfx<(dF" pESL![mlh Lzv@&g @²;PM KZnkaS-oewa~| +?ZBΝQPt1ї?1!\eSY&Vts.?NEVN-Lղ3^<) $)ON"CiPl)N;k ,AQO= ^8*> 2JPP5)}IQ;ʑ1gD'LT7X5vs0f'bfr4r$Y2Qlu$L+ۿV"'c;('FKKiv"i7.¿?d q,Dؕz< ,ϓK%]*gC^{q=7ǭPc7әgJ]VTFwɲ*Xx\tXsL*o)U}gml$tK a[Oֻ/ߧؚ\!duHo,-C'0`PuG毑'[Z6Qwon$d.+Nz^5JbOy-~CͲjMj +J_ٺuTguXs_BQO~AG~P._]f l~^xVŗ#[ pF{/s6Ӣg o7ט0ѿL+]~S]O=]жTϣ߷(!btphUF\V'EZ'5:oBt0C꩞;VjPUұ#6YMUe0V*k,τ¤F8SUr*%Xz8(1Ls61|1 4=9^Ko> Ƚu(WP}H)^jLK]%ho$w{<@L S0@,]F2JA/G7*E8#/G(^z/_<3¨ѻ(~\|?BȯE:|7^l c97@MII%޴9:OEi~ɡ EޭtI>a$-٤FdޘBbyqفt /~*6?e~Ru6B{09A7P Qr93>.:|g_<S[ سbZ5YɛA3'Y_4ujv"~Aw4{i ;Q=>.# $Ix\uQa.j(7B\V 9Jr³@9퉨Aq^$0._8iyg%tLŌdEY%`[~5tM|ܛ|X9'X{zIbX lYz^^EOLH!n2jO)["d>UB‰liԦȲ43 X*"L- 0X{H GͰw1ya %B@i`Fup❨:Fsj όG Pp'QE8nlsr&9%GI PfDܢ61EW+ ,Vp!ɤSC/_z!ɎPhK&Ce Eb ; i?tjvGiX@lΉ=">12jJ`X/:TϬ[nG(TT5Qq6G,M5T%x&It1?$;~$VL2)ކQt`-Y@^˔UOI~WP1<;Y(˒_q4ֿ;9r6Qw}B<ؒߑxAVji};Bl*ZxV)=Zr&XYlhp5A vՃsiC">Z`jvTR6?,Rjȉfl`\aT^Bf0bT8: F.Q^H[qmA,ӰF띳$ׁr֛>S-O5|x~x%Kݑ|RIB@Z'Ae\Q$|AlLtU6hF׋Joe./UIPBro(soS$%p6B-3?P2WcTTC&eZybu꣤O %+jRo,nKlJs7}\ߒol| ,q-q[Mi[]*j/cd66hSю/e I v"h⫝TD#7Ju ehjF 2bӤ?[jgM~.0'a /P&)F`v}E'%, Z؝'&"&'cS)GoyїQBM珧B gJ)W.n׹6ZZkgW zQOB'[q[FYB7D|id?xq9&ɳD ˝+Crm~ZNQJڄ}gSv.shbdcv"ui\ީ3 YS^O5M\9'OE9ww@vYcfKdC=S 2|/?.R#rJ-El)*ELtoDg:?(NJhG:_cX~%9<,&'ZoXe Z&Y￾ )A|a GGyTxvDYHHp AO)d֡Y9\=]8֗5TX1j2&k3^/_[O(kj\(54f_szePW5ȵ?|B[ޜ@30&ՁIoK/Y:"kŰy Tޜ'yblU qӤ_i`is(|_9,5O14L11/nKV(b9uwt4O:d;# V$MM&}PanrZVz~-PX[H =[X'*3 Z DCfzefMtnL6㙰 ~"&\Ak7ӽ2|ox[Śto{/5WnMvg46V]r=x@vťU2bF3%Z?cfrT{bbi*;cR,q6Q(mO<uGVw7[ٝ hntH8MQ3>a S"Xn/K9##=h1⠡ =YQ1ϔ6}ᅂC\ :@,> Sh\0 CJ16"TE[>b'Y "2zE6g!qv^aU;\`Ṅc:[,7uJoF~{.b9a͍Nwx.j42pNDX7+?;|(Ah>@vHaV E 4q:߲&$?vVr4jYl/BA3TU^@Y PUxTy"~[UxOO觜A$If;[+=# ؀Lu$12y1F$@;tY]Y $!X]XQ". +#$u+Nby҄0/荦5ЅȲ#v>6Sm`هc$W`/x$@׳8?J~2w <0;u , W9/ f%\I+J%w^`'[ G5ɱzxKauRةlYEUJLyL* n4 =bCfea3rm=csCIpE?ZI}DVFm"!($P~׽~lH"*3zWB]S9? 1X%i:* N' f+UŲd~X0n9 %y6Gz[zWX|c[NEށuRYm57*\B LgԧNPiR@}$h&B-rA̠mG+JW` =`a1$hRgz3hİU˾El?=?|zTzzjP\O VᇓSU$? RҁZk \کU|ר`d:&xM)p#̭(kߟ#0泊fA!k33ܻ$k ӹ[Q^ ]FiO˳|":RlU>z9#UEɪw>*K~H.r4n DãˊPɑxolzgEtcZ lYg.I5-M ;Y_N(0{7k=>lEv6ʢ,פO5=7AM-]z o&ߥ}@9i:GyIg]M~H' B P]-_'=MP0:@g'_MVt)=ޕUC쬾)`NlEr:my%;՜k2_ˣAY0yQ`F^3 sF`6.n p/J$8e556ms9Ѱ?Ȣ11JaM qVһ|Xθ?ب6I%«@WD6z7PN*,'ȨH7<4$LA !'wӲ,.4lؘ(n9l v=lFOH#ޱb5`si&r>QX<ǚ{oR&@[‡yEe}5Y_a5o*7; ; ^MTCnh QfByM e5x:rdZ)h%U4ɨJjD1}n{-;t([۸""=.ûzh@Js +Մ1KqD'zB? P&3 ߷(|DY ;MwVCzAk> 8{n4w ͦS6lJXv|ns0&ZQe5*X(GH/*Z\'Iٰ:S`s?-@,#BjG2з(kiL'8=!q>& N&'U(qWWo}m3rq6Kcl:fc1R>3:Zb7mըJ<-|G'Hmn * /yYhVy=gOh%MK=D#>a>FK,&Y<ʅA [,cj q[.(:,Sh-fad%{.ʷED-g-8c[,mլ^5Z d;L︚x!ߖB @K,CpC< X=sm;$;Hlw?-3T{b!BMmk+Ց6=ӷ;c;̪s]] g1ř̈cn8{46diWWy1u=ذd)xY˜z)ssY_W@&{ 8^D/%F]%Z΁$@Z 𠘕9PvV$&bRr6ȼ=CU5x FG$.-)HX4I9 1W>Mc 90#5d{(x}"pk`F TҤN_MnAzYx{i·}DsoԳiY&\ e1q\V!$m3n5?s{ETx~;"mRKƿ-ZDXo_6Wc-(mo 1OkOh' *b]A`_|D-XH܉De]ofU<"|=P[/# Xu`6LB输{VLLZ/<ظUQ EW ࣾk5J/j.V\К)їuQ^lϼ)馍-^SO򥏏 L,vb*p_'o-_;áeJ;dX&Ӏf%em/5oBj.|=G$p0rz"gs/rFeq}Y\K^\BP}I򙯼}f!G]]}CO%uQ%ay*Eja`lu4E:GrYH~L/6L ȗ E_FRa2΃)j-7s CͰ;quq#X{V EMS<䏱?5k^*`JɩwXM6VN CMDŽG"|T_"e߽ 5ڿ]-$k}=/v9;xe WUX{ΐT{$|11GED^6Ȥ=;_L0 ; 4Djϟt|8k1LEƏɝN9?lvU(NpZ`FC(Vz5-iW#JjaȻP LfUz#2蝖Xu$9- Cf *2$K(YK$N )F &40F z`V$.%?G!*=Jßٷ+[}ǕPq[}b?%x][s6Ӿn'3eǸ߱4;vn]dĆ"XNg<""XP+z򵢍#: Mjr f5$UFrN3ʹ`}R+'(5{5 Ł/L-˹ΕuS5\eol )\&<S.(raՏ.oϯvb6-ɡ(5̈*SLIkTt"^; Y{2H!͠ bUm¤-A^ywS US9}9=V*EώOGޟ9m}vp: %-Y5tǀP6i]svׄByR]kN2Z1n,0; :g1͟Zmjٻ`:5^$|e 9=HiX׮إYt%hEu F__;"]OvF+0F.ZO8MgcW쑥⼛SdhaK?/J'*qQQ/ ؈j:q\m$>`Z%hG`Kwb,^[fήPZz<,%n7.k %KܭXbI654 qkYJ`≠-9A3@Q5yx?δNN-3X_}ڼdR;b;`)}+Ͷo[~˾:_($-֟K5+UuX~ʺ()ۘ)O"!ѺBv(o^x9H y Ȅ Z43$ NvZtLB;.15w A*ԟG ^ !ft7=<ga"Hpv/^_Y;DmQ4k3CY\uUԴOs'~3.Hv+kR3cw~gBij1ԍ-[+V.ֺEh/n:'AnSĆS#m?b"@unrC M5}ƺXB<Qg3E>O>0ޛN;:]BLaqA^!gccs1εHN@0 nH^t#8f<LU70w7Dq|\iIܯ^Bi6K_-*aj?& 8 AASn!9NW@r%BGP+C& 4:]z2+}Qކn<\;{$vOhp%F wcsi$ziu/9t*)Z?Y<, Kq/; Ӕ⵺Dwjo#GIu(9):e,U{*8M4O@ YA+݄'$H{NjP%$1H D~RQ jPQ-`l3r} d1Z!xH[Wm95xLAj݌ݰ<šXLό!K`i@`ySDE^{ |&*03fu~=38z+iߺ< e^􅻸I"abH<>JUe5ښi6Ril+D6^FFZo#z)ؗd1<cQӐg,EBzH,ǰXK+Y>ꦓ3 Lv!<#I.ޣK~QKL4㍡z~!#f?ѱ=@#/^7ۙʳl/0r?!OxEJ`yD #W'ǽÀZR2IJ"J&&\L5 &azF&VpUN$}+7iku 4)WVZoQ(]"a8o5%'1_s n)$جZ|F&h)u.pgj[LaeB,SY}Lwڒ A"e=G͙w"wH _;Uءڣx _ TP$C hk`=ݸF^kCO0z%צf%y;p+1Z%4LkU:5|!/j?nMu-57m9=A:Q BMm7z7kA0'At7}Ƀ$KWyv!?M"Af%_5F.r kw ?}`̴yX}"e V݂qSf[LZ+ⰑAwN:5CkbY45uGp8o%D1b%};tcVc-X_$¼7͊رZ[ϺS$ A6-vCXX(_,;>|Ôo5 .vZœ׊}LU޸_Yis 'f~ц[ojl k b';>C yJdž馪k9,˄J&nHokUlsi Bsh tvG, =yZ qo~6b`=G'rP^ZI5 bPiB9{ݳ1bPH"6Ɗ,s@KS5:f>$q}"k[.piHX<^nE_:B#4!%B{b M.!֟NG"ƃ7bI>A8 wB7A^Bh.`˜6 !sIS^=(WgtG_ tgrN0R Y"![g#dw{ܫNG8^C 7[o1[rRCG2%s>T 9h)=Z098W1W"<*Dvѓ/[jijDZZFHM$G (%-,.i1{9- jpCXBL4[GDKT)x_ m]PMȵ;e\ЈT.K/v$v$[sHŽRT7[+mbl}NGA;O!QbJ ԩ+x2-$*WPs 1N9dUuN 6=m3S9QC1y!l]8^Ji]ޖ:`md4k:]~.||c=枋k (uiئ܉11:A~^{l}PF05A[g :v9''n9h/-q m ztVT}vooP3At;;LN %nqX}[Eʎ7D/r\4mcِClȚmBf/~D%~;1E (~]=@FVfg3ߴ'}ɩow ͉Rmq)dMAwwL^!AZ`vśiӢv<8voKtlGjl ]'*|PlhZ[$7wN[@+S/.VTrU%o8B:w{_m]pOSH^ZzPAlX"``ϻ=15Eo-p ;Wj&/SX0@l=ܹGS+.,!K/4HkwnJN 韪dBj CT'w^jL{ uRJ\?03ݲP';<7w j$̈OJJ. B*D4v'ì?iVR陰bO!U:AzE䰃"f< ަ٦͚lLlIFFꨑĻH74s\^hכXEubP 8@m;an@XwK[IB'Mw=&.tSi!6xJ@H o9CH9Gzh&cl:/S|H*Xlȭ8)n!(Y B @u0J ڗ,P{ސsiZ>@R:; 1O(n yLI$)bU@VғX>=ɐ>,%l[SքgG@9osڱhGڜv>qz&:FFi-%\QIe [0CSw*MϪʲ155a[ǘB)=K[U'މ+m`#@vjW@#:a E*BoۏacVt5),xmV3yF:8]}Yb˱ &cQtVD¾tl[^x֎6_-G=B-P8$vftKBs4R{/)b;8#څXYr/(}`Q˸$UW%\Q9&ʒY*ku&)g]Mu9z߼rVmF7?^XaX}8Tl kecV4?ɥg=3gAc#g5M600i<ڶJ'x>ja_ɁRUd.Tg譓K?I'XC INm@#u% /Ix08ҿPgIg qH$zq@w hK?W@҄kwF?A(d7뾡DS\PoNwM}#O#-UѬ@R[NEcҀ10Oי/>$hCgjfݑbP!fKqpP2?َrQk1ҳy.e]I["^XfCR?ԇbD2HsUsvrt: 4% ,3X'L`l3PkX kJ.n5' gެ)D-4PYtAC[VԽPEZd?6!$U3Lm> :XugDV݇Ji_-z$ {}]ZN|0co nuV+ܼndMa @NO䐓`׾=i rSs|qW976=b,/=Wb`=a H91%Xh\x{w/ p6gDH\" ht,1 ]N߇wwQmge98O94`'Ϧ?O^+K[$mE0Ք DmQ<ܒq[6# KO*-LFȹ;ԈDUp+>ύt -Ɇ꽡Rcc>Cb#O{\+\5 @+ΥM MG_'с2X30f0y9?/sga4s~aph"mm?-@/-%,yy}|BVF]4mlI[ޗAvAm җ/=t@SVV'xǻoŇADK3YްYɻJ,˗+yo9M%"XrNLkjXb G4ݒ@.zvȸ eۀ.$>9X=v-s=| t8=V5;[8 -j?Zv)7N Nz  aEПEf GJAm"dd4lB FKF#a(S(UQNv&uXE^k[vݣ E8]dq?zCl`7IgZ:\g: u.꽃<*"R3KIgw{{P'D5ԠQ楓Ng^r7I!_|kAғBLQuoqɥvފok?'ߵ{ 3 ]uhV{+."cˆX+UԈ/o, Mcä YĈn0Tz^/`xιD9>'wãԑJ<sYfov4m}P"N`p{Zìm J6ͷd +qTh1DIfJI] Xy%xmr t:Of|=۫w7{n홀L[LA[\x6w_I0pB=\ܒ{th}$-Kݫf[I ΄_I JjTX4iBtMu ?xIdJ4R|.bT/7~60&*AxѬMeTKNRzW:]LڑRNp]Q8O }$ ¸٩IqsT)D6Zؕ_NxDxh$ F(gl,EG N'}aE㝤GX[3TR4ts\Z [11rW:Ft cدI!" \dM# m 6ŇbOUݖ^U{*4`vwa"J1?$O(xwJ4y~ U۰)\T#.5eMK х4x5 rF8% IbBt|7$?Pk}N,u-6G((hhAz$?kI=a\;8i0S|"|=6X(8[Bz#ԸضH֯mmel_XJ4 CiLYI晉2}.@vfsbEci")\q"Z,'nżT^&eʉ`Oİ"gXdtΊ_X@Y3O䧮D!d&" b䊠<^J0/e!)R,BFI,(%į)j+:Hf}TPtr4]ZݭҼ- rkpWH. x$)Юxқxv;3Ou8U-6crp놡/aN?<ĂMR4ݶHNR]Ɯ[zcu+30l[;ޤzbqd#*Z8*b>E~